From 23b913eb0659cc87a1ef39133ec96bca9e3c6c09 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Mon, 1 Aug 2016 20:19:29 +0300 Subject: [PATCH 0001/1491] TAS-171 initial setup --- .../resources/alfresco-restapi-context.xml | 18 ++++++++++++++++++ e2e-test/resources/default.properties | 8 ++++++++ 2 files changed, 26 insertions(+) create mode 100644 e2e-test/resources/alfresco-restapi-context.xml create mode 100644 e2e-test/resources/default.properties diff --git a/e2e-test/resources/alfresco-restapi-context.xml b/e2e-test/resources/alfresco-restapi-context.xml new file mode 100644 index 000000000..b23c39c76 --- /dev/null +++ b/e2e-test/resources/alfresco-restapi-context.xml @@ -0,0 +1,18 @@ + + + + + + + + + + diff --git a/e2e-test/resources/default.properties b/e2e-test/resources/default.properties new file mode 100644 index 000000000..12cd3c525 --- /dev/null +++ b/e2e-test/resources/default.properties @@ -0,0 +1,8 @@ +alfresco.url=http://localhost:8080/alfresco + +# credentials +admin.user=admin +admin.password=admin + +# rest related +rest.basePath=alfresco/api/-default-/public/alfresco/versions/1 \ No newline at end of file From 2ba01df148e7defc172417bfabe77cb3d93dda7f Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Wed, 3 Aug 2016 10:08:36 +0300 Subject: [PATCH 0002/1491] no message --- .../java/org/alfresco/rest/BaseRestTest.java | 22 +++++++++++++++++++ .../java/org/alfresco/rest/v1/SitesTest.java | 17 ++++++++++++++ .../resources/alfresco-restapi-context.xml | 3 +-- e2e-test/resources/default.properties | 5 ++++- e2e-test/resources/log4j.properties | 19 ++++++++++++++++ 5 files changed, 63 insertions(+), 3 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/BaseRestTest.java create mode 100644 e2e-test/java/org/alfresco/rest/v1/SitesTest.java create mode 100644 e2e-test/resources/log4j.properties diff --git a/e2e-test/java/org/alfresco/rest/BaseRestTest.java b/e2e-test/java/org/alfresco/rest/BaseRestTest.java new file mode 100644 index 000000000..4af4aa815 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/BaseRestTest.java @@ -0,0 +1,22 @@ +package org.alfresco.rest; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; +import org.testng.annotations.BeforeClass; + +import com.jayway.restassured.RestAssured; + +@ContextConfiguration("classpath:alfresco-restapi-context.xml") +public class BaseRestTest extends AbstractTestNGSpringContextTests { + + @Autowired + protected RestProperties restProperties; + + @BeforeClass + public void setup() { + RestAssured.baseURI = restProperties.envProperty().getTestServerUrl(); + RestAssured.port = restProperties.envProperty().getPort(); + RestAssured.basePath = restProperties.getRestBasePath(); + } +} diff --git a/e2e-test/java/org/alfresco/rest/v1/SitesTest.java b/e2e-test/java/org/alfresco/rest/v1/SitesTest.java new file mode 100644 index 000000000..ad9231c61 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/v1/SitesTest.java @@ -0,0 +1,17 @@ +package org.alfresco.rest.v1; + +import static org.alfresco.rest.RestClientWrapper.onRestAPI; + +import org.alfresco.rest.BaseRestTest; +import org.alfresco.tester.model.UserModel; +import org.testng.annotations.Test; + +public class SitesTest extends BaseRestTest { + + @Test + public void getSite() { + UserModel admin = new UserModel("admin", "admin"); + System.out.println(onRestAPI().withAuthUser(admin).onSites().getSite("SiteName1470151654495").getTitle()); + + } +} diff --git a/e2e-test/resources/alfresco-restapi-context.xml b/e2e-test/resources/alfresco-restapi-context.xml index b23c39c76..8b2ce79cb 100644 --- a/e2e-test/resources/alfresco-restapi-context.xml +++ b/e2e-test/resources/alfresco-restapi-context.xml @@ -11,8 +11,7 @@ - + - diff --git a/e2e-test/resources/default.properties b/e2e-test/resources/default.properties index 12cd3c525..96caacc10 100644 --- a/e2e-test/resources/default.properties +++ b/e2e-test/resources/default.properties @@ -1,4 +1,7 @@ -alfresco.url=http://localhost:8080/alfresco +# dataprep related +alfresco.scheme=http +alfresco.server=172.29.100.215 +alfresco.port=9090 # credentials admin.user=admin diff --git a/e2e-test/resources/log4j.properties b/e2e-test/resources/log4j.properties new file mode 100644 index 000000000..4a2fd1bd3 --- /dev/null +++ b/e2e-test/resources/log4j.properties @@ -0,0 +1,19 @@ +# Log levels +log4j.rootLogger=INFO,CONSOLE,R +# Appender Configuration +log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender +# Identifies whether the appender honors reassignments of System.out or System.err via System.setOut or System.setErr made after configuration +log4j.appender.CONSOLE.follow=true +# Pattern to output the caller's file name and line number +log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout +log4j.appender.CONSOLE.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n +# Rolling File Appender +log4j.appender.R=org.apache.log4j.RollingFileAppender +# Path and file name to store the log file +log4j.appender.R.File=./target/alfresco-tas.log +# log4j.appender.R.MaxFileSize=200KB +# Number of backup files +log4j.appender.R.MaxBackupIndex=2 +# Layout for Rolling File Appender +log4j.appender.R.layout=org.apache.log4j.PatternLayout +log4j.appender.R.layout.ConversionPattern=%d - %c - %p - %m%n \ No newline at end of file From 2c8dcec779169a91073354b7fb012d9da348b1f5 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Wed, 3 Aug 2016 15:56:17 +0300 Subject: [PATCH 0003/1491] update simple test --- .../java/org/alfresco/rest/BaseRestTest.java | 20 ++++++++++--------- .../java/org/alfresco/rest/v1/SitesTest.java | 14 +++++++------ 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/BaseRestTest.java b/e2e-test/java/org/alfresco/rest/BaseRestTest.java index 4af4aa815..35a7c7a74 100644 --- a/e2e-test/java/org/alfresco/rest/BaseRestTest.java +++ b/e2e-test/java/org/alfresco/rest/BaseRestTest.java @@ -8,15 +8,17 @@ import org.testng.annotations.BeforeClass; import com.jayway.restassured.RestAssured; @ContextConfiguration("classpath:alfresco-restapi-context.xml") -public class BaseRestTest extends AbstractTestNGSpringContextTests { +public class BaseRestTest extends AbstractTestNGSpringContextTests +{ - @Autowired - protected RestProperties restProperties; + @Autowired + protected RestProperties restProperties; - @BeforeClass - public void setup() { - RestAssured.baseURI = restProperties.envProperty().getTestServerUrl(); - RestAssured.port = restProperties.envProperty().getPort(); - RestAssured.basePath = restProperties.getRestBasePath(); - } + @BeforeClass + public void setup() + { + RestAssured.baseURI = restProperties.envProperty().getTestServerUrl(); + RestAssured.port = restProperties.envProperty().getPort(); + RestAssured.basePath = restProperties.getRestBasePath(); + } } diff --git a/e2e-test/java/org/alfresco/rest/v1/SitesTest.java b/e2e-test/java/org/alfresco/rest/v1/SitesTest.java index ad9231c61..d3dc955bf 100644 --- a/e2e-test/java/org/alfresco/rest/v1/SitesTest.java +++ b/e2e-test/java/org/alfresco/rest/v1/SitesTest.java @@ -6,12 +6,14 @@ import org.alfresco.rest.BaseRestTest; import org.alfresco.tester.model.UserModel; import org.testng.annotations.Test; -public class SitesTest extends BaseRestTest { +public class SitesTest extends BaseRestTest +{ - @Test - public void getSite() { - UserModel admin = new UserModel("admin", "admin"); - System.out.println(onRestAPI().withAuthUser(admin).onSites().getSite("SiteName1470151654495").getTitle()); + @Test + public void getSite() + { + UserModel admin = new UserModel("admin", "admin"); + System.out.println(onRestAPI().withAuthUser(admin).onSites().getSite("SiteName1470151654495").getTitle()); - } + } } From d3507fa904fd56a3dd6b63ec0d79339b6e46a1d1 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Thu, 4 Aug 2016 12:20:11 +0300 Subject: [PATCH 0004/1491] TAS-188 add support for wrapper (single,collection jsons) --- .../java/org/alfresco/rest/BaseRestTest.java | 1 - .../java/org/alfresco/rest/v1/SitesTest.java | 18 ++++++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/BaseRestTest.java b/e2e-test/java/org/alfresco/rest/BaseRestTest.java index 35a7c7a74..049265d0b 100644 --- a/e2e-test/java/org/alfresco/rest/BaseRestTest.java +++ b/e2e-test/java/org/alfresco/rest/BaseRestTest.java @@ -10,7 +10,6 @@ import com.jayway.restassured.RestAssured; @ContextConfiguration("classpath:alfresco-restapi-context.xml") public class BaseRestTest extends AbstractTestNGSpringContextTests { - @Autowired protected RestProperties restProperties; diff --git a/e2e-test/java/org/alfresco/rest/v1/SitesTest.java b/e2e-test/java/org/alfresco/rest/v1/SitesTest.java index d3dc955bf..2eb3be0d2 100644 --- a/e2e-test/java/org/alfresco/rest/v1/SitesTest.java +++ b/e2e-test/java/org/alfresco/rest/v1/SitesTest.java @@ -1,19 +1,33 @@ package org.alfresco.rest.v1; -import static org.alfresco.rest.RestClientWrapper.onRestAPI; +import static org.alfresco.rest.RestWrapper.onRestAPI; + +import java.io.IOException; import org.alfresco.rest.BaseRestTest; import org.alfresco.tester.model.UserModel; +import org.testng.Assert; import org.testng.annotations.Test; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.JsonMappingException; + public class SitesTest extends BaseRestTest { - @Test public void getSite() { UserModel admin = new UserModel("admin", "admin"); System.out.println(onRestAPI().withAuthUser(admin).onSites().getSite("SiteName1470151654495").getTitle()); + } + @Test + public void getSites() throws JsonParseException, JsonMappingException, IOException + { + UserModel admin = new UserModel("admin", "admin"); + + Assert.assertEquals(onRestAPI().withAuthUser(admin).onSites().getSites().getPagination().getTotalItems(), 281); + + Assert.assertEquals(onRestAPI().withAuthUser(admin).onSites().getSites().getEntries().get(0).onModel().getTitle(), "0-C2291-1470255221170"); } } From 19c7436c363373f9695576c27fc90f9a0ced8261 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Thu, 4 Aug 2016 14:58:19 +0300 Subject: [PATCH 0005/1491] TAS-188 add autowired capability and parallel execution --- .../java/org/alfresco/rest/SampleATest.java | 30 +++++++++++++++++ .../java/org/alfresco/rest/SampleBTest.java | 31 +++++++++++++++++ .../java/org/alfresco/rest/v1/SitesTest.java | 33 ------------------- e2e-test/resources/smoke-rest.xml | 11 +++++++ 4 files changed, 72 insertions(+), 33 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/SampleATest.java create mode 100644 e2e-test/java/org/alfresco/rest/SampleBTest.java delete mode 100644 e2e-test/java/org/alfresco/rest/v1/SitesTest.java create mode 100644 e2e-test/resources/smoke-rest.xml diff --git a/e2e-test/java/org/alfresco/rest/SampleATest.java b/e2e-test/java/org/alfresco/rest/SampleATest.java new file mode 100644 index 000000000..e2a310e37 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/SampleATest.java @@ -0,0 +1,30 @@ +package org.alfresco.rest; + +import org.alfresco.rest.v1.Sites; +import org.alfresco.tester.model.UserModel; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.Assert; +import org.testng.annotations.Test; + +public class SampleATest extends BaseRestTest +{ + @Autowired + Sites onSites; + + @Test + public void sampleATestMethod1() + { + UserModel admin = new UserModel("admin", "admin"); + Assert.assertFalse(onSites.withAuthUser(admin).getSites().getEntries().isEmpty(), "We have sites"); + } + + @Test + public void sampleATestMethod2() + { + UserModel admin = new UserModel("admin", "a"); + Assert.assertTrue(onSites.withAuthUser(admin).getSites().getEntries().isEmpty(), "We have sites"); + + Assert.assertEquals(onSites.usingRestWrapper().getLastStatus().getName(), HttpStatus.ACCEPTED.name(), "Status Code Name"); + } +} diff --git a/e2e-test/java/org/alfresco/rest/SampleBTest.java b/e2e-test/java/org/alfresco/rest/SampleBTest.java new file mode 100644 index 000000000..720544108 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/SampleBTest.java @@ -0,0 +1,31 @@ +package org.alfresco.rest; + +import org.alfresco.rest.v1.Sites; +import org.alfresco.tester.model.UserModel; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.Assert; +import org.testng.annotations.Test; + +public class SampleBTest extends BaseRestTest +{ + @Autowired + Sites onSites; + + @Test + public void sampleBTestMethod1() + { + UserModel admin = new UserModel("admin", "admin"); + Assert.assertFalse(onSites.withAuthUser(admin).getSites().getEntries().isEmpty(), "We have sites"); + } + + @Test + public void sampleBTestMethod2() + { + UserModel admin = new UserModel("admin", "a"); + Assert.assertTrue(onSites.withAuthUser(admin).getSites().getEntries().isEmpty(), "We have sites"); + + Assert.assertEquals(onSites.usingRestWrapper().getLastStatus().getName().toLowerCase(), HttpStatus.UNAUTHORIZED.name().toLowerCase(), "Status Code Name"); + } + +} diff --git a/e2e-test/java/org/alfresco/rest/v1/SitesTest.java b/e2e-test/java/org/alfresco/rest/v1/SitesTest.java deleted file mode 100644 index 2eb3be0d2..000000000 --- a/e2e-test/java/org/alfresco/rest/v1/SitesTest.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.alfresco.rest.v1; - -import static org.alfresco.rest.RestWrapper.onRestAPI; - -import java.io.IOException; - -import org.alfresco.rest.BaseRestTest; -import org.alfresco.tester.model.UserModel; -import org.testng.Assert; -import org.testng.annotations.Test; - -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.databind.JsonMappingException; - -public class SitesTest extends BaseRestTest -{ - @Test - public void getSite() - { - UserModel admin = new UserModel("admin", "admin"); - System.out.println(onRestAPI().withAuthUser(admin).onSites().getSite("SiteName1470151654495").getTitle()); - } - - @Test - public void getSites() throws JsonParseException, JsonMappingException, IOException - { - UserModel admin = new UserModel("admin", "admin"); - - Assert.assertEquals(onRestAPI().withAuthUser(admin).onSites().getSites().getPagination().getTotalItems(), 281); - - Assert.assertEquals(onRestAPI().withAuthUser(admin).onSites().getSites().getEntries().get(0).onModel().getTitle(), "0-C2291-1470255221170"); - } -} diff --git a/e2e-test/resources/smoke-rest.xml b/e2e-test/resources/smoke-rest.xml new file mode 100644 index 000000000..942c2ff01 --- /dev/null +++ b/e2e-test/resources/smoke-rest.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + From fe9b4dfb03dd303b5da708c38bd9311c2422d093 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Thu, 4 Aug 2016 15:11:17 +0300 Subject: [PATCH 0006/1491] TAS-188 update rest models --- e2e-test/java/org/alfresco/rest/SampleBTest.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/SampleBTest.java b/e2e-test/java/org/alfresco/rest/SampleBTest.java index 720544108..45ab0fed3 100644 --- a/e2e-test/java/org/alfresco/rest/SampleBTest.java +++ b/e2e-test/java/org/alfresco/rest/SampleBTest.java @@ -27,5 +27,14 @@ public class SampleBTest extends BaseRestTest Assert.assertEquals(onSites.usingRestWrapper().getLastStatus().getName().toLowerCase(), HttpStatus.UNAUTHORIZED.name().toLowerCase(), "Status Code Name"); } + + + @Test + public void getSite() + { + UserModel admin = new UserModel("admin", "admin"); + + Assert.assertEquals(onSites.withAuthUser(admin).getSite("0-C2291-1470305685222").getId(), "asd"); + } } From 57458b28ae0c1acfb928aca00c5322c905e56947 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Thu, 4 Aug 2016 15:47:44 +0300 Subject: [PATCH 0007/1491] TAS-188 update packages for models --- e2e-test/java/org/alfresco/rest/SampleATest.java | 4 ++-- e2e-test/java/org/alfresco/rest/SampleBTest.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/SampleATest.java b/e2e-test/java/org/alfresco/rest/SampleATest.java index e2a310e37..c1ed96803 100644 --- a/e2e-test/java/org/alfresco/rest/SampleATest.java +++ b/e2e-test/java/org/alfresco/rest/SampleATest.java @@ -1,6 +1,6 @@ package org.alfresco.rest; -import org.alfresco.rest.v1.Sites; +import org.alfresco.rest.v1.RestSites; import org.alfresco.tester.model.UserModel; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; @@ -10,7 +10,7 @@ import org.testng.annotations.Test; public class SampleATest extends BaseRestTest { @Autowired - Sites onSites; + RestSites onSites; @Test public void sampleATestMethod1() diff --git a/e2e-test/java/org/alfresco/rest/SampleBTest.java b/e2e-test/java/org/alfresco/rest/SampleBTest.java index 45ab0fed3..133d7a986 100644 --- a/e2e-test/java/org/alfresco/rest/SampleBTest.java +++ b/e2e-test/java/org/alfresco/rest/SampleBTest.java @@ -1,6 +1,6 @@ package org.alfresco.rest; -import org.alfresco.rest.v1.Sites; +import org.alfresco.rest.v1.RestSites; import org.alfresco.tester.model.UserModel; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; @@ -10,7 +10,7 @@ import org.testng.annotations.Test; public class SampleBTest extends BaseRestTest { @Autowired - Sites onSites; + RestSites onSites; @Test public void sampleBTestMethod1() From 72b44f18cbcb870499023d90926e76ee8f52a6cc Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Thu, 4 Aug 2016 23:25:37 +0300 Subject: [PATCH 0008/1491] upgrade to TasProperties --- e2e-test/java/org/alfresco/rest/BaseRestTest.java | 12 +++++++++++- e2e-test/java/org/alfresco/rest/SampleATest.java | 4 ++-- e2e-test/java/org/alfresco/rest/SampleBTest.java | 6 +++--- e2e-test/resources/smoke-rest.xml | 3 +++ 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/BaseRestTest.java b/e2e-test/java/org/alfresco/rest/BaseRestTest.java index 049265d0b..e8047ecca 100644 --- a/e2e-test/java/org/alfresco/rest/BaseRestTest.java +++ b/e2e-test/java/org/alfresco/rest/BaseRestTest.java @@ -1,5 +1,7 @@ package org.alfresco.rest; +import org.alfresco.tester.ServerHealth; +import org.alfresco.tester.TasProperties; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; @@ -13,9 +15,17 @@ public class BaseRestTest extends AbstractTestNGSpringContextTests @Autowired protected RestProperties restProperties; + @Autowired + protected TasProperties properties; + + @Autowired + protected ServerHealth serverHealth; + @BeforeClass - public void setup() + public void setup() throws Exception { + serverHealth.assertIfServerOnline(); + RestAssured.baseURI = restProperties.envProperty().getTestServerUrl(); RestAssured.port = restProperties.envProperty().getPort(); RestAssured.basePath = restProperties.getRestBasePath(); diff --git a/e2e-test/java/org/alfresco/rest/SampleATest.java b/e2e-test/java/org/alfresco/rest/SampleATest.java index c1ed96803..2a6f5dec9 100644 --- a/e2e-test/java/org/alfresco/rest/SampleATest.java +++ b/e2e-test/java/org/alfresco/rest/SampleATest.java @@ -12,14 +12,14 @@ public class SampleATest extends BaseRestTest @Autowired RestSites onSites; - @Test + @Test(groups = {"rest-api-v1", "sanity"}) public void sampleATestMethod1() { UserModel admin = new UserModel("admin", "admin"); Assert.assertFalse(onSites.withAuthUser(admin).getSites().getEntries().isEmpty(), "We have sites"); } - @Test + @Test(groups = {"rest-api-v1", "sanity"}) public void sampleATestMethod2() { UserModel admin = new UserModel("admin", "a"); diff --git a/e2e-test/java/org/alfresco/rest/SampleBTest.java b/e2e-test/java/org/alfresco/rest/SampleBTest.java index 133d7a986..f1001f40f 100644 --- a/e2e-test/java/org/alfresco/rest/SampleBTest.java +++ b/e2e-test/java/org/alfresco/rest/SampleBTest.java @@ -12,14 +12,14 @@ public class SampleBTest extends BaseRestTest @Autowired RestSites onSites; - @Test + @Test(groups = {"rest-api-v1", "sanity"}) public void sampleBTestMethod1() { UserModel admin = new UserModel("admin", "admin"); Assert.assertFalse(onSites.withAuthUser(admin).getSites().getEntries().isEmpty(), "We have sites"); } - @Test + @Test(groups = {"rest-api-v1", "sanity"}) public void sampleBTestMethod2() { UserModel admin = new UserModel("admin", "a"); @@ -29,7 +29,7 @@ public class SampleBTest extends BaseRestTest } - @Test + @Test(groups = {"rest-api-v1"}) public void getSite() { UserModel admin = new UserModel("admin", "admin"); diff --git a/e2e-test/resources/smoke-rest.xml b/e2e-test/resources/smoke-rest.xml index 942c2ff01..57a892739 100644 --- a/e2e-test/resources/smoke-rest.xml +++ b/e2e-test/resources/smoke-rest.xml @@ -1,6 +1,9 @@ + + + From 820130eaaa8c8bdce52f845452a1b2ce199f6c45 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Fri, 5 Aug 2016 10:29:28 +0300 Subject: [PATCH 0009/1491] Add get sites/get site APIs tests --- e2e-test/java/sites/SitesTest.java | 77 ++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 e2e-test/java/sites/SitesTest.java diff --git a/e2e-test/java/sites/SitesTest.java b/e2e-test/java/sites/SitesTest.java new file mode 100644 index 000000000..23bd22129 --- /dev/null +++ b/e2e-test/java/sites/SitesTest.java @@ -0,0 +1,77 @@ +package sites; + +import java.util.List; + +import org.alfresco.rest.BaseRestTest; +import org.alfresco.rest.model.RestSiteModel; +import org.alfresco.rest.v1.RestSites; +import org.alfresco.tester.data.DataSite; +import org.alfresco.tester.data.DataUser; +import org.alfresco.tester.exception.DataPreparationException; +import org.alfresco.tester.model.SiteModel; +import org.alfresco.tester.model.UserModel; +import org.apache.commons.lang3.RandomStringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.social.alfresco.api.entities.Role; +import org.springframework.social.alfresco.api.entities.Site.Visibility; +import org.testng.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class SitesTest extends BaseRestTest +{ + @Autowired + RestSites onSites; + + @Autowired + DataUser dataUser; + + @Autowired + DataSite dataSite; + + private UserModel userModel; + private SiteModel siteModel; + + @BeforeClass + public void setUp() throws DataPreparationException + { + userModel = dataUser.createUser(RandomStringUtils.randomAlphanumeric(20)); + siteModel = new SiteModel(Role.SiteManager.toString(), Visibility.PUBLIC, "", RandomStringUtils.randomAlphanumeric(20), + RandomStringUtils.randomAlphanumeric(20), RandomStringUtils.randomAlphanumeric(20)); + + siteModel = dataSite.createSite(siteModel); + } + + @Test + public void getSitesResponseNotNull() + { + Assert.assertNotNull(onSites.withAuthUser(userModel).getSites().getEntries(), "Get sites response should not be null"); + } + + @Test + public void getSitesCheckStatusCode() + { + onSites.withAuthUser(userModel).getSites(); + Assert.assertEquals(onSites.usingRestWrapper().getStatusCode(), HttpStatus.OK.toString(), "Get sites response status code is not correct"); + } + + @Test + public void getSiteResponseNotNull() + { + Assert.assertNotNull(onSites.withAuthUser(userModel).getSite(siteModel.getId()), "Get site response should not be null"); + } + + @Test + public void getSiteCheckStatusCode() + { + onSites.withAuthUser(userModel).getSite(siteModel.getId()); + Assert.assertEquals(onSites.usingRestWrapper().getStatusCode(), HttpStatus.OK.toString(), "Get site response status code is not correct"); + } + + @Test + public void isSitePresent() + { + onSites.withAuthUser(userModel).getSites().hasSite(siteModel.getId()); + } +} \ No newline at end of file From 7aa1aa5e332723145dbcbf466227bf9b2f658186 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Fri, 5 Aug 2016 12:32:36 +0300 Subject: [PATCH 0010/1491] Add tests for get Person API --- e2e-test/java/people/PeopleTest.java | 44 ++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 e2e-test/java/people/PeopleTest.java diff --git a/e2e-test/java/people/PeopleTest.java b/e2e-test/java/people/PeopleTest.java new file mode 100644 index 000000000..1007fd577 --- /dev/null +++ b/e2e-test/java/people/PeopleTest.java @@ -0,0 +1,44 @@ +package people; + +import org.alfresco.rest.BaseRestTest; +import org.alfresco.rest.v1.RestPeople; +import org.alfresco.tester.data.DataUser; +import org.alfresco.tester.exception.DataPreparationException; +import org.alfresco.tester.model.UserModel; +import org.apache.commons.lang3.RandomStringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class PeopleTest extends BaseRestTest +{ + @Autowired + RestPeople onPeople; + + @Autowired + DataUser dataUser; + + private UserModel userModel; + + @BeforeClass + public void setUp() throws DataPreparationException + { + userModel = dataUser.createUser(RandomStringUtils.randomAlphanumeric(20)); + } + + @Test + public void getPersonResponseNotNull() + { + Assert.assertNotNull(onPeople.withAuthUser(userModel).getPerson(userModel.getUsername()), "Get person response should not be null"); + } + + @Test + public void getPersonCheckStatusCode() + { + onPeople.withAuthUser(userModel).getPerson(userModel.getUsername()); + Assert.assertEquals(onPeople.usingRestWrapper().getStatusCode(), HttpStatus.OK.toString(), "Get person response status code is not correct"); + } + +} \ No newline at end of file From 87dcc5b7e96846380d5b0ff8fa153b5bbd493afb Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Sun, 7 Aug 2016 20:58:52 +0300 Subject: [PATCH 0011/1491] renamings --- .../java/org/alfresco/rest/SampleATest.java | 30 -------- .../java/org/alfresco/rest/SampleBTest.java | 40 ---------- .../{BaseRestTest.java => v1/RestTest.java} | 13 +++- .../org/alfresco/rest/v1/SampleATest.java | 40 ++++++++++ .../org/alfresco/rest/v1/SampleBTest.java | 50 ++++++++++++ .../alfresco/rest/v1/SamplePeopleTest.java | 68 ++++++++++++++++ .../org/alfresco/rest/v1/SampleSitesTest.java | 71 +++++++++++++++++ e2e-test/java/people/PeopleTest.java | 44 ----------- e2e-test/java/sites/SitesTest.java | 77 ------------------- e2e-test/resources/smoke-rest.xml | 6 +- 10 files changed, 242 insertions(+), 197 deletions(-) delete mode 100644 e2e-test/java/org/alfresco/rest/SampleATest.java delete mode 100644 e2e-test/java/org/alfresco/rest/SampleBTest.java rename e2e-test/java/org/alfresco/rest/{BaseRestTest.java => v1/RestTest.java} (72%) create mode 100644 e2e-test/java/org/alfresco/rest/v1/SampleATest.java create mode 100644 e2e-test/java/org/alfresco/rest/v1/SampleBTest.java create mode 100644 e2e-test/java/org/alfresco/rest/v1/SamplePeopleTest.java create mode 100644 e2e-test/java/org/alfresco/rest/v1/SampleSitesTest.java delete mode 100644 e2e-test/java/people/PeopleTest.java delete mode 100644 e2e-test/java/sites/SitesTest.java diff --git a/e2e-test/java/org/alfresco/rest/SampleATest.java b/e2e-test/java/org/alfresco/rest/SampleATest.java deleted file mode 100644 index 2a6f5dec9..000000000 --- a/e2e-test/java/org/alfresco/rest/SampleATest.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.alfresco.rest; - -import org.alfresco.rest.v1.RestSites; -import org.alfresco.tester.model.UserModel; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.testng.Assert; -import org.testng.annotations.Test; - -public class SampleATest extends BaseRestTest -{ - @Autowired - RestSites onSites; - - @Test(groups = {"rest-api-v1", "sanity"}) - public void sampleATestMethod1() - { - UserModel admin = new UserModel("admin", "admin"); - Assert.assertFalse(onSites.withAuthUser(admin).getSites().getEntries().isEmpty(), "We have sites"); - } - - @Test(groups = {"rest-api-v1", "sanity"}) - public void sampleATestMethod2() - { - UserModel admin = new UserModel("admin", "a"); - Assert.assertTrue(onSites.withAuthUser(admin).getSites().getEntries().isEmpty(), "We have sites"); - - Assert.assertEquals(onSites.usingRestWrapper().getLastStatus().getName(), HttpStatus.ACCEPTED.name(), "Status Code Name"); - } -} diff --git a/e2e-test/java/org/alfresco/rest/SampleBTest.java b/e2e-test/java/org/alfresco/rest/SampleBTest.java deleted file mode 100644 index f1001f40f..000000000 --- a/e2e-test/java/org/alfresco/rest/SampleBTest.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.alfresco.rest; - -import org.alfresco.rest.v1.RestSites; -import org.alfresco.tester.model.UserModel; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.testng.Assert; -import org.testng.annotations.Test; - -public class SampleBTest extends BaseRestTest -{ - @Autowired - RestSites onSites; - - @Test(groups = {"rest-api-v1", "sanity"}) - public void sampleBTestMethod1() - { - UserModel admin = new UserModel("admin", "admin"); - Assert.assertFalse(onSites.withAuthUser(admin).getSites().getEntries().isEmpty(), "We have sites"); - } - - @Test(groups = {"rest-api-v1", "sanity"}) - public void sampleBTestMethod2() - { - UserModel admin = new UserModel("admin", "a"); - Assert.assertTrue(onSites.withAuthUser(admin).getSites().getEntries().isEmpty(), "We have sites"); - - Assert.assertEquals(onSites.usingRestWrapper().getLastStatus().getName().toLowerCase(), HttpStatus.UNAUTHORIZED.name().toLowerCase(), "Status Code Name"); - } - - - @Test(groups = {"rest-api-v1"}) - public void getSite() - { - UserModel admin = new UserModel("admin", "admin"); - - Assert.assertEquals(onSites.withAuthUser(admin).getSite("0-C2291-1470305685222").getId(), "asd"); - } - -} diff --git a/e2e-test/java/org/alfresco/rest/BaseRestTest.java b/e2e-test/java/org/alfresco/rest/v1/RestTest.java similarity index 72% rename from e2e-test/java/org/alfresco/rest/BaseRestTest.java rename to e2e-test/java/org/alfresco/rest/v1/RestTest.java index e8047ecca..ea7c37bf9 100644 --- a/e2e-test/java/org/alfresco/rest/BaseRestTest.java +++ b/e2e-test/java/org/alfresco/rest/v1/RestTest.java @@ -1,5 +1,7 @@ -package org.alfresco.rest; +package org.alfresco.rest.v1; +import org.alfresco.rest.core.RestProperties; +import org.alfresco.rest.core.RestWrapper; import org.alfresco.tester.ServerHealth; import org.alfresco.tester.TasProperties; import org.springframework.beans.factory.annotation.Autowired; @@ -10,7 +12,7 @@ import org.testng.annotations.BeforeClass; import com.jayway.restassured.RestAssured; @ContextConfiguration("classpath:alfresco-restapi-context.xml") -public class BaseRestTest extends AbstractTestNGSpringContextTests +public abstract class RestTest extends AbstractTestNGSpringContextTests { @Autowired protected RestProperties restProperties; @@ -21,8 +23,11 @@ public class BaseRestTest extends AbstractTestNGSpringContextTests @Autowired protected ServerHealth serverHealth; - @BeforeClass - public void setup() throws Exception + @Autowired + protected RestWrapper restClient; + + @BeforeClass(alwaysRun = true) + public void setupRestTest() throws Exception { serverHealth.assertIfServerOnline(); diff --git a/e2e-test/java/org/alfresco/rest/v1/SampleATest.java b/e2e-test/java/org/alfresco/rest/v1/SampleATest.java new file mode 100644 index 000000000..37e5ef766 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/v1/SampleATest.java @@ -0,0 +1,40 @@ +package org.alfresco.rest.v1; + +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.v1.RestSitesApi; +import org.alfresco.tester.model.UserModel; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class SampleATest extends RestTest +{ + @Autowired + RestSitesApi siteAPI; + + @BeforeClass + public void initTest() + { + siteAPI.useRestClient(restClient); + } + + @Test(groups = {"rest-api-v1", "sanity"}) + public void sampleATestMethod1() throws JsonToModelConversionException + { + UserModel admin = new UserModel("admin", "admin"); + restClient.authenticateUser(admin); + + Assert.assertFalse(siteAPI.getSites().getEntries().isEmpty(), "We have sites"); + } + + @Test(groups = {"rest-api-v1", "sanity"}) + public void sampleATestMethod2() throws JsonToModelConversionException + { + UserModel admin = new UserModel("admin", "a"); + restClient.authenticateUser(admin); + Assert.assertTrue(siteAPI.getSites().getEntries().isEmpty(), "We have sites"); + Assert.assertEquals(siteAPI.usingRestWrapper().getLastStatus().getName().toLowerCase(), HttpStatus.UNAUTHORIZED.name().toLowerCase(), "Status Code Name"); + } +} diff --git a/e2e-test/java/org/alfresco/rest/v1/SampleBTest.java b/e2e-test/java/org/alfresco/rest/v1/SampleBTest.java new file mode 100644 index 000000000..7629d9f6c --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/v1/SampleBTest.java @@ -0,0 +1,50 @@ +package org.alfresco.rest.v1; + +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.v1.RestSitesApi; +import org.alfresco.tester.model.UserModel; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class SampleBTest extends RestTest +{ + @Autowired + RestSitesApi siteAPI; + + @BeforeClass + public void initTest() + { + siteAPI.useRestClient(restClient); + } + + @Test(groups = { "rest-api-v1", "sanity" }) + public void sampleBTestMethod1() throws JsonToModelConversionException + { + UserModel admin = new UserModel("admin", "admin"); + restClient.authenticateUser(admin); + Assert.assertFalse(siteAPI.getSites().getEntries().isEmpty(), "We have sites"); + } + + @Test(groups = { "rest-api-v1", "sanity" }) + public void sampleBTestMethod2() throws JsonToModelConversionException + { + UserModel admin = new UserModel("admin", "a"); + restClient.authenticateUser(admin); + Assert.assertTrue(siteAPI.getSites().getEntries().isEmpty(), "We have sites"); + + Assert.assertEquals(siteAPI.usingRestWrapper().getLastStatus().getName().toLowerCase(), HttpStatus.UNAUTHORIZED.name().toLowerCase(), + "Status Code Name"); + } + + @Test(groups = { "rest-api-v1" }) + public void getSite() throws JsonToModelConversionException + { + UserModel admin = new UserModel("admin", "admin"); + restClient.authenticateUser(admin); + Assert.assertEquals(siteAPI.getSite("0-C2291-1470305685222").getId(), "no-id"); + } + +} diff --git a/e2e-test/java/org/alfresco/rest/v1/SamplePeopleTest.java b/e2e-test/java/org/alfresco/rest/v1/SamplePeopleTest.java new file mode 100644 index 000000000..9f0c7e36a --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/v1/SamplePeopleTest.java @@ -0,0 +1,68 @@ +package org.alfresco.rest.v1; + +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.v1.RestPeopleApi; +import org.alfresco.tester.data.DataUser; +import org.alfresco.tester.exception.DataPreparationException; +import org.alfresco.tester.model.UserModel; +import org.apache.commons.lang3.RandomStringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class SamplePeopleTest extends RestTest +{ + @Autowired + RestPeopleApi peopleAPI; + + @Autowired + DataUser dataUser; + + private UserModel userModel; + + @BeforeClass + public void setUp() throws DataPreparationException + { + userModel = dataUser.createUser(RandomStringUtils.randomAlphanumeric(20)); + restClient.authenticateUser(userModel); + peopleAPI.useRestClient(restClient); + } + + @Test + public void getPerson() throws JsonToModelConversionException + { + Assert.assertNotNull(peopleAPI.getPerson(userModel.getUsername()), "Get person response should not be null"); + Assert.assertEquals(peopleAPI.usingRestWrapper().getStatusCode(), HttpStatus.OK.toString(), "Get person response status code is not correct"); + } + + @Test + public void getPersonResponseNotNull() throws JsonToModelConversionException + { + Assert.assertNotNull(peopleAPI.getPerson(userModel.getUsername()), "Get person response should not be null"); + } + + @Test + public void getPersonCheckStatusCode() throws JsonToModelConversionException + { + peopleAPI.getPerson(userModel.getUsername()); + Assert.assertEquals(peopleAPI.usingRestWrapper().getStatusCode(), HttpStatus.OK.toString(), "Get person response status code is not correct"); + } + + @Test + public void getPersonResponseNotNull1() throws JsonToModelConversionException + { + Assert.assertNotNull(peopleAPI.getPerson(userModel.getUsername()), "Get person response should not be null"); + } + + @Test + public void getPersonCheckStatusCode1() throws JsonToModelConversionException + { + peopleAPI.getPerson(userModel.getUsername()); + Assert.assertEquals(peopleAPI.usingRestWrapper().getStatusCode(), HttpStatus.OK.toString(), "Get person response status code is not correct"); + } + + + +} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/v1/SampleSitesTest.java b/e2e-test/java/org/alfresco/rest/v1/SampleSitesTest.java new file mode 100644 index 000000000..95aebea83 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/v1/SampleSitesTest.java @@ -0,0 +1,71 @@ +package org.alfresco.rest.v1; + +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.v1.RestSitesApi; +import org.alfresco.tester.data.DataSite; +import org.alfresco.tester.data.DataUser; +import org.alfresco.tester.exception.DataPreparationException; +import org.alfresco.tester.model.SiteModel; +import org.alfresco.tester.model.UserModel; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class SampleSitesTest extends RestTest +{ + @Autowired + RestSitesApi siteAPI; + + @Autowired + DataUser dataUser; + + @Autowired + DataSite dataSite; + + private UserModel userModel; + private SiteModel siteModel; + + @BeforeClass + public void initTest() throws DataPreparationException + { + userModel = dataUser.createRandomTestUser(); + restClient.authenticateUser(userModel); + siteModel = dataSite.createPublicRandomSite(); + siteAPI.useRestClient(restClient); + } + + @Test + public void getSitesResponseNotNull() throws JsonToModelConversionException + { + Assert.assertNotNull(siteAPI.getSites().getEntries(), "Get sites response should not be null"); + } + + @Test + public void getSitesCheckStatusCode() + { + Assert.assertEquals(siteAPI.usingRestWrapper().getStatusCode(), HttpStatus.OK.toString(), "Get sites response status code is not correct"); + } + + @Test + public void getSiteResponseNotNull() throws JsonToModelConversionException + { + Assert.assertNotNull(siteAPI.getSite(siteModel.getId()), "Get site response should not be null"); + } + + @Test + public void getSiteCheckStatusCode() throws JsonToModelConversionException + { + siteAPI.getSite(siteModel.getId()); + Assert.assertEquals(siteAPI.usingRestWrapper().getStatusCode(), HttpStatus.OK.toString(), "Get site response status code is not correct"); + } + + @Test + public void collectionHasPagination() throws JsonToModelConversionException + { + siteAPI.getSites().assertPagination(); + Assert.assertEquals(siteAPI.getSites().getPagination().getCount(), 100); + } + +} \ No newline at end of file diff --git a/e2e-test/java/people/PeopleTest.java b/e2e-test/java/people/PeopleTest.java deleted file mode 100644 index 1007fd577..000000000 --- a/e2e-test/java/people/PeopleTest.java +++ /dev/null @@ -1,44 +0,0 @@ -package people; - -import org.alfresco.rest.BaseRestTest; -import org.alfresco.rest.v1.RestPeople; -import org.alfresco.tester.data.DataUser; -import org.alfresco.tester.exception.DataPreparationException; -import org.alfresco.tester.model.UserModel; -import org.apache.commons.lang3.RandomStringUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.testng.Assert; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class PeopleTest extends BaseRestTest -{ - @Autowired - RestPeople onPeople; - - @Autowired - DataUser dataUser; - - private UserModel userModel; - - @BeforeClass - public void setUp() throws DataPreparationException - { - userModel = dataUser.createUser(RandomStringUtils.randomAlphanumeric(20)); - } - - @Test - public void getPersonResponseNotNull() - { - Assert.assertNotNull(onPeople.withAuthUser(userModel).getPerson(userModel.getUsername()), "Get person response should not be null"); - } - - @Test - public void getPersonCheckStatusCode() - { - onPeople.withAuthUser(userModel).getPerson(userModel.getUsername()); - Assert.assertEquals(onPeople.usingRestWrapper().getStatusCode(), HttpStatus.OK.toString(), "Get person response status code is not correct"); - } - -} \ No newline at end of file diff --git a/e2e-test/java/sites/SitesTest.java b/e2e-test/java/sites/SitesTest.java deleted file mode 100644 index 23bd22129..000000000 --- a/e2e-test/java/sites/SitesTest.java +++ /dev/null @@ -1,77 +0,0 @@ -package sites; - -import java.util.List; - -import org.alfresco.rest.BaseRestTest; -import org.alfresco.rest.model.RestSiteModel; -import org.alfresco.rest.v1.RestSites; -import org.alfresco.tester.data.DataSite; -import org.alfresco.tester.data.DataUser; -import org.alfresco.tester.exception.DataPreparationException; -import org.alfresco.tester.model.SiteModel; -import org.alfresco.tester.model.UserModel; -import org.apache.commons.lang3.RandomStringUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.social.alfresco.api.entities.Role; -import org.springframework.social.alfresco.api.entities.Site.Visibility; -import org.testng.Assert; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class SitesTest extends BaseRestTest -{ - @Autowired - RestSites onSites; - - @Autowired - DataUser dataUser; - - @Autowired - DataSite dataSite; - - private UserModel userModel; - private SiteModel siteModel; - - @BeforeClass - public void setUp() throws DataPreparationException - { - userModel = dataUser.createUser(RandomStringUtils.randomAlphanumeric(20)); - siteModel = new SiteModel(Role.SiteManager.toString(), Visibility.PUBLIC, "", RandomStringUtils.randomAlphanumeric(20), - RandomStringUtils.randomAlphanumeric(20), RandomStringUtils.randomAlphanumeric(20)); - - siteModel = dataSite.createSite(siteModel); - } - - @Test - public void getSitesResponseNotNull() - { - Assert.assertNotNull(onSites.withAuthUser(userModel).getSites().getEntries(), "Get sites response should not be null"); - } - - @Test - public void getSitesCheckStatusCode() - { - onSites.withAuthUser(userModel).getSites(); - Assert.assertEquals(onSites.usingRestWrapper().getStatusCode(), HttpStatus.OK.toString(), "Get sites response status code is not correct"); - } - - @Test - public void getSiteResponseNotNull() - { - Assert.assertNotNull(onSites.withAuthUser(userModel).getSite(siteModel.getId()), "Get site response should not be null"); - } - - @Test - public void getSiteCheckStatusCode() - { - onSites.withAuthUser(userModel).getSite(siteModel.getId()); - Assert.assertEquals(onSites.usingRestWrapper().getStatusCode(), HttpStatus.OK.toString(), "Get site response status code is not correct"); - } - - @Test - public void isSitePresent() - { - onSites.withAuthUser(userModel).getSites().hasSite(siteModel.getId()); - } -} \ No newline at end of file diff --git a/e2e-test/resources/smoke-rest.xml b/e2e-test/resources/smoke-rest.xml index 57a892739..8f9623235 100644 --- a/e2e-test/resources/smoke-rest.xml +++ b/e2e-test/resources/smoke-rest.xml @@ -6,8 +6,10 @@ - - + + + + From 902f6fe271ffd816e1ac491b284b8215895565ba Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Mon, 8 Aug 2016 11:07:47 +0300 Subject: [PATCH 0012/1491] TAS-188 add RestRequest and sample test --- .../org/alfresco/rest/v1/SampleSitesTest.java | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/v1/SampleSitesTest.java b/e2e-test/java/org/alfresco/rest/v1/SampleSitesTest.java index 95aebea83..14a16b994 100644 --- a/e2e-test/java/org/alfresco/rest/v1/SampleSitesTest.java +++ b/e2e-test/java/org/alfresco/rest/v1/SampleSitesTest.java @@ -1,7 +1,6 @@ package org.alfresco.rest.v1; import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.v1.RestSitesApi; import org.alfresco.tester.data.DataSite; import org.alfresco.tester.data.DataUser; import org.alfresco.tester.exception.DataPreparationException; @@ -30,7 +29,7 @@ public class SampleSitesTest extends RestTest @BeforeClass public void initTest() throws DataPreparationException { - userModel = dataUser.createRandomTestUser(); + userModel = dataUser.getAdminUser(); restClient.authenticateUser(userModel); siteModel = dataSite.createPublicRandomSite(); siteAPI.useRestClient(restClient); @@ -67,5 +66,21 @@ public class SampleSitesTest extends RestTest siteAPI.getSites().assertPagination(); Assert.assertEquals(siteAPI.getSites().getPagination().getCount(), 100); } + + @Autowired RestCommentsApi commentsAPI; + @Test + public void getComments() throws JsonToModelConversionException + { + commentsAPI.useRestClient(restClient); + System.out.println(commentsAPI.getNodeComments("bc95c7bf-0593-422f-af7d-b92f9d8129de").getEntries().size()); + } + + + @Test + public void addComments() throws JsonToModelConversionException + { + commentsAPI.useRestClient(restClient); + commentsAPI.addCommentToNode("bc95c7bf-0593-422f-af7d-b92f9d8129de"); + } } \ No newline at end of file From 8523f1a98f149a0224e3941300fac5c9452935a6 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Tue, 9 Aug 2016 11:21:45 +0300 Subject: [PATCH 0013/1491] Add comments API tests | Fix requests with/without body --- .../alfresco/rest/v1/SampleCommentsTest.java | 63 +++++++++++++++++++ .../org/alfresco/rest/v1/SampleSitesTest.java | 49 ++++++--------- 2 files changed, 82 insertions(+), 30 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/v1/SampleCommentsTest.java diff --git a/e2e-test/java/org/alfresco/rest/v1/SampleCommentsTest.java b/e2e-test/java/org/alfresco/rest/v1/SampleCommentsTest.java new file mode 100644 index 000000000..382e8984e --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/v1/SampleCommentsTest.java @@ -0,0 +1,63 @@ +package org.alfresco.rest.v1; + +import java.io.File; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.dataprep.ContentService; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.Content; +import org.alfresco.tester.data.DataUser; +import org.alfresco.tester.exception.DataPreparationException; +import org.alfresco.tester.model.UserModel; +import org.apache.chemistry.opencmis.client.api.Document; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class SampleCommentsTest extends RestTest +{ + @Autowired + DataUser dataUser; + + @Autowired + ContentService content; + + @Autowired + RestCommentsApi commentsAPI; + + private UserModel userModel; + private File file; + private Document document; + private String documentName = "textDocument-" + System.currentTimeMillis(); + + @BeforeClass + public void initTest() throws DataPreparationException + { + userModel = dataUser.getAdminUser(); + restClient.authenticateUser(userModel); + commentsAPI.useRestClient(restClient); + + file = new File(documentName); + document = content.createDocumentInRepository(userModel.getUsername(), userModel.getPassword(), "Shared", DocumentType.TEXT_PLAIN, file, + "shared document content"); + } + + @Test + public void addComments() throws JsonToModelConversionException + { + Content content = new Content("This is a new comment"); + commentsAPI.addCommentToNode(document.getId(), content); + Assert.assertEquals(commentsAPI.usingRestWrapper().getStatusCode(), HttpStatus.CREATED.toString(), "Add comments response status code is not correct"); + + } + + @Test + public void getCommentsCheckStatusCode() throws JsonToModelConversionException + { + commentsAPI.getNodeComments(document.getId()); + Assert.assertEquals(commentsAPI.usingRestWrapper().getStatusCode(), HttpStatus.OK.toString(), "Get comments response status code is not correct"); + } + +} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/v1/SampleSitesTest.java b/e2e-test/java/org/alfresco/rest/v1/SampleSitesTest.java index 14a16b994..6200da3d0 100644 --- a/e2e-test/java/org/alfresco/rest/v1/SampleSitesTest.java +++ b/e2e-test/java/org/alfresco/rest/v1/SampleSitesTest.java @@ -1,5 +1,6 @@ package org.alfresco.rest.v1; +import org.alfresco.dataprep.ContentService; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.tester.data.DataSite; import org.alfresco.tester.data.DataUser; @@ -23,6 +24,9 @@ public class SampleSitesTest extends RestTest @Autowired DataSite dataSite; + @Autowired + ContentService content; + private UserModel userModel; private SiteModel siteModel; @@ -35,18 +39,6 @@ public class SampleSitesTest extends RestTest siteAPI.useRestClient(restClient); } - @Test - public void getSitesResponseNotNull() throws JsonToModelConversionException - { - Assert.assertNotNull(siteAPI.getSites().getEntries(), "Get sites response should not be null"); - } - - @Test - public void getSitesCheckStatusCode() - { - Assert.assertEquals(siteAPI.usingRestWrapper().getStatusCode(), HttpStatus.OK.toString(), "Get sites response status code is not correct"); - } - @Test public void getSiteResponseNotNull() throws JsonToModelConversionException { @@ -61,26 +53,23 @@ public class SampleSitesTest extends RestTest } @Test - public void collectionHasPagination() throws JsonToModelConversionException + public void getSitesResponseNotNull() throws JsonToModelConversionException + { + Assert.assertNotNull(siteAPI.getSites().getEntries(), "Get sites response should not be null"); + } + + @Test + public void getSitesCheckStatusCode() throws JsonToModelConversionException + { + siteAPI.getSites(); + Assert.assertEquals(siteAPI.usingRestWrapper().getStatusCode(), HttpStatus.OK.toString(), "Get sites response status code is not correct"); + } + + @Test + public void sitesCollectionHasPagination() throws JsonToModelConversionException { siteAPI.getSites().assertPagination(); - Assert.assertEquals(siteAPI.getSites().getPagination().getCount(), 100); - } - - @Autowired RestCommentsApi commentsAPI; - @Test - public void getComments() throws JsonToModelConversionException - { - commentsAPI.useRestClient(restClient); - System.out.println(commentsAPI.getNodeComments("bc95c7bf-0593-422f-af7d-b92f9d8129de").getEntries().size()); - } - - - @Test - public void addComments() throws JsonToModelConversionException - { - commentsAPI.useRestClient(restClient); - commentsAPI.addCommentToNode("bc95c7bf-0593-422f-af7d-b92f9d8129de"); + Assert.assertEquals(siteAPI.getSites().getPagination().getCount(), 100, "Sites collection should have pagination"); } } \ No newline at end of file From d842f6b268f6d9a1065ac8edf4a94bb3c916be2f Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Tue, 9 Aug 2016 12:25:20 +0300 Subject: [PATCH 0014/1491] Add new site member --- .../java/org/alfresco/rest/v1/SamplePeopleTest.java | 6 ++---- .../java/org/alfresco/rest/v1/SampleSitesTest.java | 12 ++++++++++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/v1/SamplePeopleTest.java b/e2e-test/java/org/alfresco/rest/v1/SamplePeopleTest.java index 9f0c7e36a..6b47a16a7 100644 --- a/e2e-test/java/org/alfresco/rest/v1/SamplePeopleTest.java +++ b/e2e-test/java/org/alfresco/rest/v1/SamplePeopleTest.java @@ -36,7 +36,7 @@ public class SamplePeopleTest extends RestTest Assert.assertNotNull(peopleAPI.getPerson(userModel.getUsername()), "Get person response should not be null"); Assert.assertEquals(peopleAPI.usingRestWrapper().getStatusCode(), HttpStatus.OK.toString(), "Get person response status code is not correct"); } - + @Test public void getPersonResponseNotNull() throws JsonToModelConversionException { @@ -49,7 +49,7 @@ public class SamplePeopleTest extends RestTest peopleAPI.getPerson(userModel.getUsername()); Assert.assertEquals(peopleAPI.usingRestWrapper().getStatusCode(), HttpStatus.OK.toString(), "Get person response status code is not correct"); } - + @Test public void getPersonResponseNotNull1() throws JsonToModelConversionException { @@ -62,7 +62,5 @@ public class SamplePeopleTest extends RestTest peopleAPI.getPerson(userModel.getUsername()); Assert.assertEquals(peopleAPI.usingRestWrapper().getStatusCode(), HttpStatus.OK.toString(), "Get person response status code is not correct"); } - - } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/v1/SampleSitesTest.java b/e2e-test/java/org/alfresco/rest/v1/SampleSitesTest.java index 6200da3d0..ff96650cf 100644 --- a/e2e-test/java/org/alfresco/rest/v1/SampleSitesTest.java +++ b/e2e-test/java/org/alfresco/rest/v1/SampleSitesTest.java @@ -2,6 +2,7 @@ package org.alfresco.rest.v1; import org.alfresco.dataprep.ContentService; import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.SiteMember; import org.alfresco.tester.data.DataSite; import org.alfresco.tester.data.DataUser; import org.alfresco.tester.exception.DataPreparationException; @@ -9,6 +10,7 @@ import org.alfresco.tester.model.SiteModel; import org.alfresco.tester.model.UserModel; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; +import org.springframework.social.alfresco.api.entities.Role; import org.testng.Assert; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -72,4 +74,14 @@ public class SampleSitesTest extends RestTest Assert.assertEquals(siteAPI.getSites().getPagination().getCount(), 100, "Sites collection should have pagination"); } + @Test + public void addMemberToSiteCheckStatusCode() throws JsonToModelConversionException, DataPreparationException + { + UserModel newMember = dataUser.createRandomTestUser(); + SiteMember siteMember = new SiteMember(Role.SiteCollaborator.toString(), newMember.getUsername()); + siteAPI.addPerson(siteModel.getId(), siteMember); + Assert.assertEquals(siteAPI.usingRestWrapper().getStatusCode(), HttpStatus.CREATED.toString(), + "Add member to site response status code is not correct"); + } + } \ No newline at end of file From eacab1602bf8359b03997067c01aa9eb892478ad Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Tue, 9 Aug 2016 17:15:41 +0300 Subject: [PATCH 0015/1491] PUT request sample for comments API --- .../alfresco/rest/v1/SampleCommentsTest.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/v1/SampleCommentsTest.java b/e2e-test/java/org/alfresco/rest/v1/SampleCommentsTest.java index 382e8984e..3689221c5 100644 --- a/e2e-test/java/org/alfresco/rest/v1/SampleCommentsTest.java +++ b/e2e-test/java/org/alfresco/rest/v1/SampleCommentsTest.java @@ -6,6 +6,8 @@ import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.ContentService; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.Content; +import org.alfresco.rest.model.RestCommentModel; +import org.alfresco.rest.model.RestCommentsModel; import org.alfresco.tester.data.DataUser; import org.alfresco.tester.exception.DataPreparationException; import org.alfresco.tester.model.UserModel; @@ -48,7 +50,7 @@ public class SampleCommentsTest extends RestTest public void addComments() throws JsonToModelConversionException { Content content = new Content("This is a new comment"); - commentsAPI.addCommentToNode(document.getId(), content); + commentsAPI.addComment(document.getId(), content); Assert.assertEquals(commentsAPI.usingRestWrapper().getStatusCode(), HttpStatus.CREATED.toString(), "Add comments response status code is not correct"); } @@ -60,4 +62,17 @@ public class SampleCommentsTest extends RestTest Assert.assertEquals(commentsAPI.usingRestWrapper().getStatusCode(), HttpStatus.OK.toString(), "Get comments response status code is not correct"); } + @Test + public void updateComment() throws JsonToModelConversionException + { + // add initial comment + Content content = new Content("This is a new comment"); + String commentId = commentsAPI.addComment(document.getId(), content).getId(); + + // update comment + content = new Content("This is the updated comment"); + RestCommentModel commentEntry = commentsAPI.updateComment(document.getId(), commentId, content); + Assert.assertEquals(commentEntry.getContent(), "This is the updated comment", "New comment was not updated"); + } + } \ No newline at end of file From fede1b64187e26835c5a88f840dbbc261ccaf733 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Tue, 16 Aug 2016 11:34:03 +0300 Subject: [PATCH 0016/1491] TAS-345 update package imports --- e2e-test/java/org/alfresco/rest/v1/RestTest.java | 4 ++-- e2e-test/java/org/alfresco/rest/v1/SampleATest.java | 4 ++-- e2e-test/java/org/alfresco/rest/v1/SampleBTest.java | 4 ++-- .../java/org/alfresco/rest/v1/SampleCommentsTest.java | 8 ++++---- .../java/org/alfresco/rest/v1/SamplePeopleTest.java | 8 ++++---- .../java/org/alfresco/rest/v1/SampleSitesTest.java | 11 ++++++----- 6 files changed, 20 insertions(+), 19 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/v1/RestTest.java b/e2e-test/java/org/alfresco/rest/v1/RestTest.java index ea7c37bf9..8b39a4b5a 100644 --- a/e2e-test/java/org/alfresco/rest/v1/RestTest.java +++ b/e2e-test/java/org/alfresco/rest/v1/RestTest.java @@ -2,8 +2,8 @@ package org.alfresco.rest.v1; import org.alfresco.rest.core.RestProperties; import org.alfresco.rest.core.RestWrapper; -import org.alfresco.tester.ServerHealth; -import org.alfresco.tester.TasProperties; +import org.alfresco.utility.ServerHealth; +import org.alfresco.utility.TasProperties; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; diff --git a/e2e-test/java/org/alfresco/rest/v1/SampleATest.java b/e2e-test/java/org/alfresco/rest/v1/SampleATest.java index 37e5ef766..674851468 100644 --- a/e2e-test/java/org/alfresco/rest/v1/SampleATest.java +++ b/e2e-test/java/org/alfresco/rest/v1/SampleATest.java @@ -1,8 +1,8 @@ package org.alfresco.rest.v1; +import org.alfresco.rest.RestSitesApi; import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.v1.RestSitesApi; -import org.alfresco.tester.model.UserModel; +import org.alfresco.utility.model.UserModel; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.Assert; diff --git a/e2e-test/java/org/alfresco/rest/v1/SampleBTest.java b/e2e-test/java/org/alfresco/rest/v1/SampleBTest.java index 7629d9f6c..c1919baf9 100644 --- a/e2e-test/java/org/alfresco/rest/v1/SampleBTest.java +++ b/e2e-test/java/org/alfresco/rest/v1/SampleBTest.java @@ -1,8 +1,8 @@ package org.alfresco.rest.v1; +import org.alfresco.rest.RestSitesApi; import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.v1.RestSitesApi; -import org.alfresco.tester.model.UserModel; +import org.alfresco.utility.model.UserModel; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.Assert; diff --git a/e2e-test/java/org/alfresco/rest/v1/SampleCommentsTest.java b/e2e-test/java/org/alfresco/rest/v1/SampleCommentsTest.java index 3689221c5..38a3d468e 100644 --- a/e2e-test/java/org/alfresco/rest/v1/SampleCommentsTest.java +++ b/e2e-test/java/org/alfresco/rest/v1/SampleCommentsTest.java @@ -4,13 +4,13 @@ import java.io.File; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.ContentService; +import org.alfresco.rest.RestCommentsApi; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.Content; import org.alfresco.rest.model.RestCommentModel; -import org.alfresco.rest.model.RestCommentsModel; -import org.alfresco.tester.data.DataUser; -import org.alfresco.tester.exception.DataPreparationException; -import org.alfresco.tester.model.UserModel; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.exception.DataPreparationException; +import org.alfresco.utility.model.UserModel; import org.apache.chemistry.opencmis.client.api.Document; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; diff --git a/e2e-test/java/org/alfresco/rest/v1/SamplePeopleTest.java b/e2e-test/java/org/alfresco/rest/v1/SamplePeopleTest.java index 6b47a16a7..75a7bbcd9 100644 --- a/e2e-test/java/org/alfresco/rest/v1/SamplePeopleTest.java +++ b/e2e-test/java/org/alfresco/rest/v1/SamplePeopleTest.java @@ -1,10 +1,10 @@ package org.alfresco.rest.v1; +import org.alfresco.rest.RestPeopleApi; import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.v1.RestPeopleApi; -import org.alfresco.tester.data.DataUser; -import org.alfresco.tester.exception.DataPreparationException; -import org.alfresco.tester.model.UserModel; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.exception.DataPreparationException; +import org.alfresco.utility.model.UserModel; import org.apache.commons.lang3.RandomStringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; diff --git a/e2e-test/java/org/alfresco/rest/v1/SampleSitesTest.java b/e2e-test/java/org/alfresco/rest/v1/SampleSitesTest.java index ff96650cf..44580745f 100644 --- a/e2e-test/java/org/alfresco/rest/v1/SampleSitesTest.java +++ b/e2e-test/java/org/alfresco/rest/v1/SampleSitesTest.java @@ -1,13 +1,14 @@ package org.alfresco.rest.v1; import org.alfresco.dataprep.ContentService; +import org.alfresco.rest.RestSitesApi; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.SiteMember; -import org.alfresco.tester.data.DataSite; -import org.alfresco.tester.data.DataUser; -import org.alfresco.tester.exception.DataPreparationException; -import org.alfresco.tester.model.SiteModel; -import org.alfresco.tester.model.UserModel; +import org.alfresco.utility.data.DataSite; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.exception.DataPreparationException; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.social.alfresco.api.entities.Role; From 5f106f7f7996b33ba52b4a2e8303c2fb7c372732 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Tue, 16 Aug 2016 14:56:56 +0300 Subject: [PATCH 0017/1491] Small updates to REST API framework --- e2e-test/java/org/alfresco/rest/v1/RestTest.java | 2 +- .../java/org/alfresco/rest/v1/SampleSitesTest.java | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/v1/RestTest.java b/e2e-test/java/org/alfresco/rest/v1/RestTest.java index 8b39a4b5a..7e9d131f5 100644 --- a/e2e-test/java/org/alfresco/rest/v1/RestTest.java +++ b/e2e-test/java/org/alfresco/rest/v1/RestTest.java @@ -29,7 +29,7 @@ public abstract class RestTest extends AbstractTestNGSpringContextTests @BeforeClass(alwaysRun = true) public void setupRestTest() throws Exception { - serverHealth.assertIfServerOnline(); + serverHealth.assertServerIsOnline(); RestAssured.baseURI = restProperties.envProperty().getTestServerUrl(); RestAssured.port = restProperties.envProperty().getPort(); diff --git a/e2e-test/java/org/alfresco/rest/v1/SampleSitesTest.java b/e2e-test/java/org/alfresco/rest/v1/SampleSitesTest.java index 44580745f..7f36c8f65 100644 --- a/e2e-test/java/org/alfresco/rest/v1/SampleSitesTest.java +++ b/e2e-test/java/org/alfresco/rest/v1/SampleSitesTest.java @@ -85,4 +85,16 @@ public class SampleSitesTest extends RestTest "Add member to site response status code is not correct"); } + @Test + public void isSiteReturned() throws JsonToModelConversionException + { + siteAPI.getAllSites().hasSite(siteModel.getId()); + } + + @Test + public void checkSiteDetails() throws JsonToModelConversionException + { + siteAPI.getSite(siteModel.getId()); + } + } \ No newline at end of file From 5f2937197cf8442f2c1d7890b1306b6b541c10d9 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Wed, 24 Aug 2016 14:47:44 +0300 Subject: [PATCH 0018/1491] Added tests for demo | Add getSiteMember/getSiteMembers calls | Assertions for Comments API | Assertions for Site Members API --- .../org/alfresco/rest/v1/RestDemoTest.java | 124 ++++++++++++++++++ .../org/alfresco/rest/v1/SampleSitesTest.java | 2 +- 2 files changed, 125 insertions(+), 1 deletion(-) create mode 100644 e2e-test/java/org/alfresco/rest/v1/RestDemoTest.java diff --git a/e2e-test/java/org/alfresco/rest/v1/RestDemoTest.java b/e2e-test/java/org/alfresco/rest/v1/RestDemoTest.java new file mode 100644 index 000000000..d33de206f --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/v1/RestDemoTest.java @@ -0,0 +1,124 @@ +package org.alfresco.rest.v1; + +import java.io.File; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.dataprep.ContentService; +import org.alfresco.rest.RestCommentsApi; +import org.alfresco.rest.RestSitesApi; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.Content; +import org.alfresco.rest.model.RestCommentModel; +import org.alfresco.rest.model.SiteMember; +import org.alfresco.utility.data.DataSite; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.exception.DataPreparationException; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; +import org.apache.chemistry.opencmis.client.api.Document; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.social.alfresco.api.entities.Role; +import org.springframework.social.alfresco.api.entities.Site.Visibility; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class RestDemoTest extends RestTest +{ + @Autowired + RestSitesApi sitesApi; + + @Autowired + DataUser dataUser; + + @Autowired + DataSite dataSite; + + @Autowired + ContentService content; + + @Autowired + RestCommentsApi commentsAPI; + + private UserModel userModel; + private SiteModel siteModel; + + @BeforeClass + public void initTest() + { + userModel = dataUser.getAdminUser(); + siteModel = dataSite.createPublicRandomSite(); + restClient.authenticateUser(userModel); + } + + /** + * Data preparation – create site with custom details
+ * Perform GET sites call using admin user
+ * Check that created site is included in response
+ * Perform GET site call, validate that site title, description and visibility are correct
+ * + * @throws JsonToModelConversionException + * @throws Exception + */ + @Test + public void sitesTest() throws JsonToModelConversionException, Exception + { + sitesApi.useRestClient(restClient); + + sitesApi.getAllSites().assertThatResponseHasSite(siteModel.getId()).getSite(siteModel.getId()) + .assertSiteHasVisibility(Visibility.PUBLIC).assertSiteHasTitle(siteModel.getTitle()) + .assertSiteHasDescription(siteModel.getDescription()); + } + + /** + * Data preparation – create site and document on server
+ * POST one comment to file using admin user
+ * Perform GET comments, check the new one is listed
+ * Update existing comment using PUT call, check that comment content is updated
+ * + * @throws JsonToModelConversionException + */ + @Test + public void commentsTest() throws JsonToModelConversionException + { + commentsAPI.useRestClient(restClient); + + File file = new File("textDocument-" + System.currentTimeMillis()); + Document document = content.createDocumentInRepository(userModel.getUsername(), + userModel.getPassword(), "Shared", DocumentType.TEXT_PLAIN, file, "This is a text file"); + + // add new comment + Content content = new Content("This is a new comment"); + RestCommentModel commentEntry = commentsAPI.addComment(document.getId(), content); + commentsAPI.getNodeComments(document.getId()).assertThatResponseIsNotEmpty().assertThatCommentWithIdExists(commentEntry.getId()) + .assertThatCommentWithContentExists(content); + + // update comment + content = new Content("This is the updated comment"); + commentEntry = commentsAPI.updateComment(document.getId(), commentEntry.getId(), content); + commentsAPI.getNodeComments(document.getId()).assertThatResponseIsNotEmpty().assertThatCommentWithIdExists(commentEntry.getId()) + .assertThatCommentWithContentExists(content); + } + + /** + * Data preparation – create site and a new user
+ * As admin, add user as Consumer to site as a new site member using POST call
+ * Update site member role to Manager using PUT call
+ * Delete site member using DELETE call
+ * + * @throws DataPreparationException + * @throws JsonToModelConversionException + */ + @Test + public void siteMembersTest() throws DataPreparationException, JsonToModelConversionException + { + sitesApi.useRestClient(restClient); + + UserModel newUser = dataUser.createRandomTestUser(); + SiteMember siteMember = new SiteMember(Role.SiteConsumer.toString(), newUser.getUsername()); + + sitesApi.addPerson(siteModel.getId(), siteMember); + sitesApi.getSiteMembers(siteModel.getId()).assertThatSiteHasMember(siteMember.getId()).getSiteMember(siteMember.getId()) + .assertSiteMemberHasRole(Role.SiteConsumer); + + } +} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/v1/SampleSitesTest.java b/e2e-test/java/org/alfresco/rest/v1/SampleSitesTest.java index 7f36c8f65..65bb0f838 100644 --- a/e2e-test/java/org/alfresco/rest/v1/SampleSitesTest.java +++ b/e2e-test/java/org/alfresco/rest/v1/SampleSitesTest.java @@ -88,7 +88,7 @@ public class SampleSitesTest extends RestTest @Test public void isSiteReturned() throws JsonToModelConversionException { - siteAPI.getAllSites().hasSite(siteModel.getId()); + siteAPI.getAllSites().assertThatResponseHasSite(siteModel.getId()); } @Test From b7e64e08518db65114aa6cbfd0ed62121e4b5244 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Wed, 24 Aug 2016 15:03:12 +0300 Subject: [PATCH 0019/1491] Updates to sanity suite, remove sample tests --- .../org/alfresco/rest/v1/SampleATest.java | 40 --------------- .../org/alfresco/rest/v1/SampleBTest.java | 50 ------------------- e2e-test/resources/smoke-rest.xml | 5 +- 3 files changed, 2 insertions(+), 93 deletions(-) delete mode 100644 e2e-test/java/org/alfresco/rest/v1/SampleATest.java delete mode 100644 e2e-test/java/org/alfresco/rest/v1/SampleBTest.java diff --git a/e2e-test/java/org/alfresco/rest/v1/SampleATest.java b/e2e-test/java/org/alfresco/rest/v1/SampleATest.java deleted file mode 100644 index 674851468..000000000 --- a/e2e-test/java/org/alfresco/rest/v1/SampleATest.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.alfresco.rest.v1; - -import org.alfresco.rest.RestSitesApi; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.utility.model.UserModel; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.testng.Assert; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class SampleATest extends RestTest -{ - @Autowired - RestSitesApi siteAPI; - - @BeforeClass - public void initTest() - { - siteAPI.useRestClient(restClient); - } - - @Test(groups = {"rest-api-v1", "sanity"}) - public void sampleATestMethod1() throws JsonToModelConversionException - { - UserModel admin = new UserModel("admin", "admin"); - restClient.authenticateUser(admin); - - Assert.assertFalse(siteAPI.getSites().getEntries().isEmpty(), "We have sites"); - } - - @Test(groups = {"rest-api-v1", "sanity"}) - public void sampleATestMethod2() throws JsonToModelConversionException - { - UserModel admin = new UserModel("admin", "a"); - restClient.authenticateUser(admin); - Assert.assertTrue(siteAPI.getSites().getEntries().isEmpty(), "We have sites"); - Assert.assertEquals(siteAPI.usingRestWrapper().getLastStatus().getName().toLowerCase(), HttpStatus.UNAUTHORIZED.name().toLowerCase(), "Status Code Name"); - } -} diff --git a/e2e-test/java/org/alfresco/rest/v1/SampleBTest.java b/e2e-test/java/org/alfresco/rest/v1/SampleBTest.java deleted file mode 100644 index c1919baf9..000000000 --- a/e2e-test/java/org/alfresco/rest/v1/SampleBTest.java +++ /dev/null @@ -1,50 +0,0 @@ -package org.alfresco.rest.v1; - -import org.alfresco.rest.RestSitesApi; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.utility.model.UserModel; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.testng.Assert; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class SampleBTest extends RestTest -{ - @Autowired - RestSitesApi siteAPI; - - @BeforeClass - public void initTest() - { - siteAPI.useRestClient(restClient); - } - - @Test(groups = { "rest-api-v1", "sanity" }) - public void sampleBTestMethod1() throws JsonToModelConversionException - { - UserModel admin = new UserModel("admin", "admin"); - restClient.authenticateUser(admin); - Assert.assertFalse(siteAPI.getSites().getEntries().isEmpty(), "We have sites"); - } - - @Test(groups = { "rest-api-v1", "sanity" }) - public void sampleBTestMethod2() throws JsonToModelConversionException - { - UserModel admin = new UserModel("admin", "a"); - restClient.authenticateUser(admin); - Assert.assertTrue(siteAPI.getSites().getEntries().isEmpty(), "We have sites"); - - Assert.assertEquals(siteAPI.usingRestWrapper().getLastStatus().getName().toLowerCase(), HttpStatus.UNAUTHORIZED.name().toLowerCase(), - "Status Code Name"); - } - - @Test(groups = { "rest-api-v1" }) - public void getSite() throws JsonToModelConversionException - { - UserModel admin = new UserModel("admin", "admin"); - restClient.authenticateUser(admin); - Assert.assertEquals(siteAPI.getSite("0-C2291-1470305685222").getId(), "no-id"); - } - -} diff --git a/e2e-test/resources/smoke-rest.xml b/e2e-test/resources/smoke-rest.xml index 8f9623235..32f515d5f 100644 --- a/e2e-test/resources/smoke-rest.xml +++ b/e2e-test/resources/smoke-rest.xml @@ -2,14 +2,13 @@ - + - - + From 9e028dd20f389f4dcb818c4bf70707460449894d Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Wed, 24 Aug 2016 16:17:14 +0300 Subject: [PATCH 0020/1491] Added support for update site member role and delete site member | Add test for update/delete site member --- .../org/alfresco/rest/v1/RestDemoTest.java | 32 ++++++++++++++----- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/v1/RestDemoTest.java b/e2e-test/java/org/alfresco/rest/v1/RestDemoTest.java index d33de206f..6f8a65849 100644 --- a/e2e-test/java/org/alfresco/rest/v1/RestDemoTest.java +++ b/e2e-test/java/org/alfresco/rest/v1/RestDemoTest.java @@ -17,6 +17,7 @@ import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; import org.apache.chemistry.opencmis.client.api.Document; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; import org.springframework.social.alfresco.api.entities.Role; import org.springframework.social.alfresco.api.entities.Site.Visibility; import org.testng.annotations.BeforeClass; @@ -43,7 +44,7 @@ public class RestDemoTest extends RestTest private SiteModel siteModel; @BeforeClass - public void initTest() + public void setUp() { userModel = dataUser.getAdminUser(); siteModel = dataSite.createPublicRandomSite(); @@ -65,8 +66,9 @@ public class RestDemoTest extends RestTest sitesApi.useRestClient(restClient); sitesApi.getAllSites().assertThatResponseHasSite(siteModel.getId()).getSite(siteModel.getId()) - .assertSiteHasVisibility(Visibility.PUBLIC).assertSiteHasTitle(siteModel.getTitle()) - .assertSiteHasDescription(siteModel.getDescription()); + .assertSiteHasVisibility(Visibility.PUBLIC) + .assertSiteHasTitle(siteModel.getTitle()) + .assertSiteHasDescription(siteModel.getDescription()); } /** @@ -89,13 +91,15 @@ public class RestDemoTest extends RestTest // add new comment Content content = new Content("This is a new comment"); RestCommentModel commentEntry = commentsAPI.addComment(document.getId(), content); - commentsAPI.getNodeComments(document.getId()).assertThatResponseIsNotEmpty().assertThatCommentWithIdExists(commentEntry.getId()) + commentsAPI.getNodeComments(document.getId()).assertThatResponseIsNotEmpty() + .assertThatCommentWithIdExists(commentEntry.getId()) .assertThatCommentWithContentExists(content); // update comment content = new Content("This is the updated comment"); commentEntry = commentsAPI.updateComment(document.getId(), commentEntry.getId(), content); - commentsAPI.getNodeComments(document.getId()).assertThatResponseIsNotEmpty().assertThatCommentWithIdExists(commentEntry.getId()) + commentsAPI.getNodeComments(document.getId()).assertThatResponseIsNotEmpty() + .assertThatCommentWithIdExists(commentEntry.getId()) .assertThatCommentWithContentExists(content); } @@ -115,10 +119,22 @@ public class RestDemoTest extends RestTest UserModel newUser = dataUser.createRandomTestUser(); SiteMember siteMember = new SiteMember(Role.SiteConsumer.toString(), newUser.getUsername()); - + + // add user as Consumer to site sitesApi.addPerson(siteModel.getId(), siteMember); - sitesApi.getSiteMembers(siteModel.getId()).assertThatSiteHasMember(siteMember.getId()).getSiteMember(siteMember.getId()) - .assertSiteMemberHasRole(Role.SiteConsumer); + sitesApi.getSiteMembers(siteModel.getId()).assertThatSiteHasMember(siteMember.getId()) + .getSiteMember(siteMember.getId()).assertSiteMemberHasRole(Role.SiteConsumer); + + // update site member to Manager + siteMember.setRole(Role.SiteManager.toString()); + ; + sitesApi.updateSiteMember(siteModel.getId(), newUser.getUsername(), siteMember); + sitesApi.getSiteMembers(siteModel.getId()).assertThatSiteHasMember(siteMember.getId()) + .getSiteMember(siteMember.getId()).assertSiteMemberHasRole(Role.SiteManager); + + // delete site member + sitesApi.deleteSiteMember(siteModel.getId(), newUser.getUsername()); + sitesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT.toString()); } } \ No newline at end of file From 477e545be6e3b772934afa103c02a7c8b8a12c9c Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Tue, 30 Aug 2016 13:30:42 +0300 Subject: [PATCH 0021/1491] Updates to REST API framework - javadocs, updates to API calls --- .../alfresco/rest/{v1 => }/RestDemoTest.java | 17 ++++++----------- .../org/alfresco/rest/{v1 => }/RestTest.java | 2 +- .../rest/{v1 => }/SampleCommentsTest.java | 12 ++++-------- .../rest/{v1 => }/SamplePeopleTest.java | 2 +- .../alfresco/rest/{v1 => }/SampleSitesTest.java | 4 ++-- 5 files changed, 14 insertions(+), 23 deletions(-) rename e2e-test/java/org/alfresco/rest/{v1 => }/RestDemoTest.java (91%) rename e2e-test/java/org/alfresco/rest/{v1 => }/RestTest.java (97%) rename e2e-test/java/org/alfresco/rest/{v1 => }/SampleCommentsTest.java (86%) rename e2e-test/java/org/alfresco/rest/{v1 => }/SamplePeopleTest.java (98%) rename e2e-test/java/org/alfresco/rest/{v1 => }/SampleSitesTest.java (97%) diff --git a/e2e-test/java/org/alfresco/rest/v1/RestDemoTest.java b/e2e-test/java/org/alfresco/rest/RestDemoTest.java similarity index 91% rename from e2e-test/java/org/alfresco/rest/v1/RestDemoTest.java rename to e2e-test/java/org/alfresco/rest/RestDemoTest.java index 6f8a65849..010ebf341 100644 --- a/e2e-test/java/org/alfresco/rest/v1/RestDemoTest.java +++ b/e2e-test/java/org/alfresco/rest/RestDemoTest.java @@ -1,13 +1,10 @@ -package org.alfresco.rest.v1; +package org.alfresco.rest; import java.io.File; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.ContentService; -import org.alfresco.rest.RestCommentsApi; -import org.alfresco.rest.RestSitesApi; import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.Content; import org.alfresco.rest.model.RestCommentModel; import org.alfresco.rest.model.SiteMember; import org.alfresco.utility.data.DataSite; @@ -44,7 +41,7 @@ public class RestDemoTest extends RestTest private SiteModel siteModel; @BeforeClass - public void setUp() + public void setUp() throws DataPreparationException { userModel = dataUser.getAdminUser(); siteModel = dataSite.createPublicRandomSite(); @@ -89,18 +86,16 @@ public class RestDemoTest extends RestTest userModel.getPassword(), "Shared", DocumentType.TEXT_PLAIN, file, "This is a text file"); // add new comment - Content content = new Content("This is a new comment"); - RestCommentModel commentEntry = commentsAPI.addComment(document.getId(), content); + RestCommentModel commentEntry = commentsAPI.addComment(document.getId(), "This is a new comment"); commentsAPI.getNodeComments(document.getId()).assertThatResponseIsNotEmpty() .assertThatCommentWithIdExists(commentEntry.getId()) - .assertThatCommentWithContentExists(content); + .assertThatCommentWithContentExists("This is a new comment"); // update comment - content = new Content("This is the updated comment"); - commentEntry = commentsAPI.updateComment(document.getId(), commentEntry.getId(), content); + commentEntry = commentsAPI.updateComment(document.getId(), commentEntry.getId(), "This is the updated comment"); commentsAPI.getNodeComments(document.getId()).assertThatResponseIsNotEmpty() .assertThatCommentWithIdExists(commentEntry.getId()) - .assertThatCommentWithContentExists(content); + .assertThatCommentWithContentExists("This is the updated comment"); } /** diff --git a/e2e-test/java/org/alfresco/rest/v1/RestTest.java b/e2e-test/java/org/alfresco/rest/RestTest.java similarity index 97% rename from e2e-test/java/org/alfresco/rest/v1/RestTest.java rename to e2e-test/java/org/alfresco/rest/RestTest.java index 7e9d131f5..f54d21d73 100644 --- a/e2e-test/java/org/alfresco/rest/v1/RestTest.java +++ b/e2e-test/java/org/alfresco/rest/RestTest.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.v1; +package org.alfresco.rest; import org.alfresco.rest.core.RestProperties; import org.alfresco.rest.core.RestWrapper; diff --git a/e2e-test/java/org/alfresco/rest/v1/SampleCommentsTest.java b/e2e-test/java/org/alfresco/rest/SampleCommentsTest.java similarity index 86% rename from e2e-test/java/org/alfresco/rest/v1/SampleCommentsTest.java rename to e2e-test/java/org/alfresco/rest/SampleCommentsTest.java index 38a3d468e..614397783 100644 --- a/e2e-test/java/org/alfresco/rest/v1/SampleCommentsTest.java +++ b/e2e-test/java/org/alfresco/rest/SampleCommentsTest.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.v1; +package org.alfresco.rest; import java.io.File; @@ -6,7 +6,6 @@ import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.ContentService; import org.alfresco.rest.RestCommentsApi; import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.Content; import org.alfresco.rest.model.RestCommentModel; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.exception.DataPreparationException; @@ -49,8 +48,7 @@ public class SampleCommentsTest extends RestTest @Test public void addComments() throws JsonToModelConversionException { - Content content = new Content("This is a new comment"); - commentsAPI.addComment(document.getId(), content); + commentsAPI.addComment(document.getId(), "This is a new comment"); Assert.assertEquals(commentsAPI.usingRestWrapper().getStatusCode(), HttpStatus.CREATED.toString(), "Add comments response status code is not correct"); } @@ -66,12 +64,10 @@ public class SampleCommentsTest extends RestTest public void updateComment() throws JsonToModelConversionException { // add initial comment - Content content = new Content("This is a new comment"); - String commentId = commentsAPI.addComment(document.getId(), content).getId(); + String commentId = commentsAPI.addComment(document.getId(), "This is a new comment").getId(); // update comment - content = new Content("This is the updated comment"); - RestCommentModel commentEntry = commentsAPI.updateComment(document.getId(), commentId, content); + RestCommentModel commentEntry = commentsAPI.updateComment(document.getId(), commentId, "This is the updated comment"); Assert.assertEquals(commentEntry.getContent(), "This is the updated comment", "New comment was not updated"); } diff --git a/e2e-test/java/org/alfresco/rest/v1/SamplePeopleTest.java b/e2e-test/java/org/alfresco/rest/SamplePeopleTest.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/v1/SamplePeopleTest.java rename to e2e-test/java/org/alfresco/rest/SamplePeopleTest.java index 75a7bbcd9..592daab8b 100644 --- a/e2e-test/java/org/alfresco/rest/v1/SamplePeopleTest.java +++ b/e2e-test/java/org/alfresco/rest/SamplePeopleTest.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.v1; +package org.alfresco.rest; import org.alfresco.rest.RestPeopleApi; import org.alfresco.rest.exception.JsonToModelConversionException; diff --git a/e2e-test/java/org/alfresco/rest/v1/SampleSitesTest.java b/e2e-test/java/org/alfresco/rest/SampleSitesTest.java similarity index 97% rename from e2e-test/java/org/alfresco/rest/v1/SampleSitesTest.java rename to e2e-test/java/org/alfresco/rest/SampleSitesTest.java index 65bb0f838..e6c67b12e 100644 --- a/e2e-test/java/org/alfresco/rest/v1/SampleSitesTest.java +++ b/e2e-test/java/org/alfresco/rest/SampleSitesTest.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.v1; +package org.alfresco.rest; import org.alfresco.dataprep.ContentService; import org.alfresco.rest.RestSitesApi; @@ -71,7 +71,7 @@ public class SampleSitesTest extends RestTest @Test public void sitesCollectionHasPagination() throws JsonToModelConversionException { - siteAPI.getSites().assertPagination(); + siteAPI.getSites().assertResponseHasPagination(); Assert.assertEquals(siteAPI.getSites().getPagination().getCount(), 100, "Sites collection should have pagination"); } From 5cccdaf80b0c8ca29a6e11b105a9f7f370c98b47 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Tue, 30 Aug 2016 20:37:49 +0300 Subject: [PATCH 0022/1491] small refactoring: using helper of DataContent for creation of files --- .../java/org/alfresco/rest/RestDemoTest.java | 46 ++++++------------- e2e-test/java/org/alfresco/rest/RestTest.java | 12 +++++ 2 files changed, 27 insertions(+), 31 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/RestDemoTest.java b/e2e-test/java/org/alfresco/rest/RestDemoTest.java index 010ebf341..5c5481343 100644 --- a/e2e-test/java/org/alfresco/rest/RestDemoTest.java +++ b/e2e-test/java/org/alfresco/rest/RestDemoTest.java @@ -1,14 +1,9 @@ package org.alfresco.rest; -import java.io.File; - import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.dataprep.ContentService; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestCommentModel; import org.alfresco.rest.model.SiteMember; -import org.alfresco.utility.data.DataSite; -import org.alfresco.utility.data.DataUser; import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; @@ -25,15 +20,6 @@ public class RestDemoTest extends RestTest @Autowired RestSitesApi sitesApi; - @Autowired - DataUser dataUser; - - @Autowired - DataSite dataSite; - - @Autowired - ContentService content; - @Autowired RestCommentsApi commentsAPI; @@ -46,6 +32,9 @@ public class RestDemoTest extends RestTest userModel = dataUser.getAdminUser(); siteModel = dataSite.createPublicRandomSite(); restClient.authenticateUser(userModel); + + sitesApi.useRestClient(restClient); + commentsAPI.useRestClient(restClient); } /** @@ -60,12 +49,11 @@ public class RestDemoTest extends RestTest @Test public void sitesTest() throws JsonToModelConversionException, Exception { - sitesApi.useRestClient(restClient); - - sitesApi.getAllSites().assertThatResponseHasSite(siteModel.getId()).getSite(siteModel.getId()) - .assertSiteHasVisibility(Visibility.PUBLIC) - .assertSiteHasTitle(siteModel.getTitle()) - .assertSiteHasDescription(siteModel.getDescription()); + sitesApi.getAllSites().assertThatResponseHasSite(siteModel) + .getSite(siteModel) + .assertSiteHasVisibility(Visibility.PUBLIC) + .assertSiteHasTitle(siteModel.getTitle()) + .assertSiteHasDescription(siteModel.getDescription()); } /** @@ -79,17 +67,15 @@ public class RestDemoTest extends RestTest @Test public void commentsTest() throws JsonToModelConversionException { - commentsAPI.useRestClient(restClient); - - File file = new File("textDocument-" + System.currentTimeMillis()); - Document document = content.createDocumentInRepository(userModel.getUsername(), - userModel.getPassword(), "Shared", DocumentType.TEXT_PLAIN, file, "This is a text file"); - + Document document = dataContent.usingPath("Shared") + .usingUser(userModel) + .createDocument(DocumentType.TEXT_PLAIN); // add new comment RestCommentModel commentEntry = commentsAPI.addComment(document.getId(), "This is a new comment"); - commentsAPI.getNodeComments(document.getId()).assertThatResponseIsNotEmpty() - .assertThatCommentWithIdExists(commentEntry.getId()) - .assertThatCommentWithContentExists("This is a new comment"); + commentsAPI.getNodeComments(document.getId()) + .assertThatResponseIsNotEmpty() + .assertThatCommentWithIdExists(commentEntry.getId()) + .assertThatCommentWithContentExists("This is a new comment"); // update comment commentEntry = commentsAPI.updateComment(document.getId(), commentEntry.getId(), "This is the updated comment"); @@ -110,8 +96,6 @@ public class RestDemoTest extends RestTest @Test public void siteMembersTest() throws DataPreparationException, JsonToModelConversionException { - sitesApi.useRestClient(restClient); - UserModel newUser = dataUser.createRandomTestUser(); SiteMember siteMember = new SiteMember(Role.SiteConsumer.toString(), newUser.getUsername()); diff --git a/e2e-test/java/org/alfresco/rest/RestTest.java b/e2e-test/java/org/alfresco/rest/RestTest.java index f54d21d73..f0ca294b9 100644 --- a/e2e-test/java/org/alfresco/rest/RestTest.java +++ b/e2e-test/java/org/alfresco/rest/RestTest.java @@ -4,6 +4,9 @@ import org.alfresco.rest.core.RestProperties; import org.alfresco.rest.core.RestWrapper; import org.alfresco.utility.ServerHealth; import org.alfresco.utility.TasProperties; +import org.alfresco.utility.data.DataContent; +import org.alfresco.utility.data.DataSite; +import org.alfresco.utility.data.DataUser; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; @@ -25,6 +28,15 @@ public abstract class RestTest extends AbstractTestNGSpringContextTests @Autowired protected RestWrapper restClient; + + @Autowired + DataUser dataUser; + + @Autowired + DataSite dataSite; + + @Autowired + DataContent dataContent; @BeforeClass(alwaysRun = true) public void setupRestTest() throws Exception From da16d2c24101e8e141da67d8a0118bed15274680 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Wed, 31 Aug 2016 12:03:37 +0300 Subject: [PATCH 0023/1491] Updates to REST API - formatting, additional assertions, fix suite --- .../java/org/alfresco/rest/RestDemoTest.java | 28 ++++++++------ .../org/alfresco/rest/SampleCommentsTest.java | 25 ++++--------- .../org/alfresco/rest/SamplePeopleTest.java | 33 ++++------------- .../org/alfresco/rest/SampleSitesTest.java | 37 ++++++++++--------- e2e-test/resources/smoke-rest.xml | 6 +-- 5 files changed, 56 insertions(+), 73 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/RestDemoTest.java b/e2e-test/java/org/alfresco/rest/RestDemoTest.java index 5c5481343..8849d8f14 100644 --- a/e2e-test/java/org/alfresco/rest/RestDemoTest.java +++ b/e2e-test/java/org/alfresco/rest/RestDemoTest.java @@ -68,8 +68,8 @@ public class RestDemoTest extends RestTest public void commentsTest() throws JsonToModelConversionException { Document document = dataContent.usingPath("Shared") - .usingUser(userModel) - .createDocument(DocumentType.TEXT_PLAIN); + .usingUser(userModel) + .createDocument(DocumentType.TEXT_PLAIN); // add new comment RestCommentModel commentEntry = commentsAPI.addComment(document.getId(), "This is a new comment"); commentsAPI.getNodeComments(document.getId()) @@ -78,10 +78,13 @@ public class RestDemoTest extends RestTest .assertThatCommentWithContentExists("This is a new comment"); // update comment - commentEntry = commentsAPI.updateComment(document.getId(), commentEntry.getId(), "This is the updated comment"); - commentsAPI.getNodeComments(document.getId()).assertThatResponseIsNotEmpty() - .assertThatCommentWithIdExists(commentEntry.getId()) - .assertThatCommentWithContentExists("This is the updated comment"); + commentEntry = commentsAPI.updateComment(document.getId(), + commentEntry.getId(), + "This is the updated comment"); + commentsAPI.getNodeComments(document.getId()) + .assertThatResponseIsNotEmpty() + .assertThatCommentWithIdExists(commentEntry.getId()) + .assertThatCommentWithContentExists("This is the updated comment"); } /** @@ -101,19 +104,22 @@ public class RestDemoTest extends RestTest // add user as Consumer to site sitesApi.addPerson(siteModel.getId(), siteMember); - sitesApi.getSiteMembers(siteModel.getId()).assertThatSiteHasMember(siteMember.getId()) - .getSiteMember(siteMember.getId()).assertSiteMemberHasRole(Role.SiteConsumer); + sitesApi.getSiteMembers(siteModel.getId()) + .assertThatSiteHasMember(siteMember.getId()) + .getSiteMember(siteMember.getId()) + .assertSiteMemberHasRole(Role.SiteConsumer); // update site member to Manager siteMember.setRole(Role.SiteManager.toString()); ; sitesApi.updateSiteMember(siteModel.getId(), newUser.getUsername(), siteMember); - sitesApi.getSiteMembers(siteModel.getId()).assertThatSiteHasMember(siteMember.getId()) - .getSiteMember(siteMember.getId()).assertSiteMemberHasRole(Role.SiteManager); + sitesApi.getSiteMembers(siteModel.getId()) + .assertThatSiteHasMember(siteMember.getId()) + .getSiteMember(siteMember.getId()) + .assertSiteMemberHasRole(Role.SiteManager); // delete site member sitesApi.deleteSiteMember(siteModel.getId(), newUser.getUsername()); sitesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT.toString()); - } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/SampleCommentsTest.java b/e2e-test/java/org/alfresco/rest/SampleCommentsTest.java index 614397783..ba09905e9 100644 --- a/e2e-test/java/org/alfresco/rest/SampleCommentsTest.java +++ b/e2e-test/java/org/alfresco/rest/SampleCommentsTest.java @@ -1,10 +1,6 @@ package org.alfresco.rest; -import java.io.File; - import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.dataprep.ContentService; -import org.alfresco.rest.RestCommentsApi; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestCommentModel; import org.alfresco.utility.data.DataUser; @@ -13,7 +9,6 @@ import org.alfresco.utility.model.UserModel; import org.apache.chemistry.opencmis.client.api.Document; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; -import org.testng.Assert; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -22,16 +17,11 @@ public class SampleCommentsTest extends RestTest @Autowired DataUser dataUser; - @Autowired - ContentService content; - @Autowired RestCommentsApi commentsAPI; private UserModel userModel; - private File file; private Document document; - private String documentName = "textDocument-" + System.currentTimeMillis(); @BeforeClass public void initTest() throws DataPreparationException @@ -40,24 +30,25 @@ public class SampleCommentsTest extends RestTest restClient.authenticateUser(userModel); commentsAPI.useRestClient(restClient); - file = new File(documentName); - document = content.createDocumentInRepository(userModel.getUsername(), userModel.getPassword(), "Shared", DocumentType.TEXT_PLAIN, file, - "shared document content"); + document = dataContent.usingPath("Shared") + .usingUser(userModel) + .createDocument(DocumentType.TEXT_PLAIN); } @Test public void addComments() throws JsonToModelConversionException { commentsAPI.addComment(document.getId(), "This is a new comment"); - Assert.assertEquals(commentsAPI.usingRestWrapper().getStatusCode(), HttpStatus.CREATED.toString(), "Add comments response status code is not correct"); - + commentsAPI.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.CREATED.toString()); } @Test public void getCommentsCheckStatusCode() throws JsonToModelConversionException { commentsAPI.getNodeComments(document.getId()); - Assert.assertEquals(commentsAPI.usingRestWrapper().getStatusCode(), HttpStatus.OK.toString(), "Get comments response status code is not correct"); + commentsAPI.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.OK.toString()); } @Test @@ -68,7 +59,7 @@ public class SampleCommentsTest extends RestTest // update comment RestCommentModel commentEntry = commentsAPI.updateComment(document.getId(), commentId, "This is the updated comment"); - Assert.assertEquals(commentEntry.getContent(), "This is the updated comment", "New comment was not updated"); + commentEntry.assertCommentContentIs("This is the updated comment"); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/SamplePeopleTest.java b/e2e-test/java/org/alfresco/rest/SamplePeopleTest.java index 592daab8b..d4247b267 100644 --- a/e2e-test/java/org/alfresco/rest/SamplePeopleTest.java +++ b/e2e-test/java/org/alfresco/rest/SamplePeopleTest.java @@ -8,7 +8,6 @@ import org.alfresco.utility.model.UserModel; import org.apache.commons.lang3.RandomStringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; -import org.testng.Assert; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -31,36 +30,20 @@ public class SamplePeopleTest extends RestTest } @Test - public void getPerson() throws JsonToModelConversionException + public void getPersonCheckResponseAndStatus() throws JsonToModelConversionException { - Assert.assertNotNull(peopleAPI.getPerson(userModel.getUsername()), "Get person response should not be null"); - Assert.assertEquals(peopleAPI.usingRestWrapper().getStatusCode(), HttpStatus.OK.toString(), "Get person response status code is not correct"); - } - - @Test - public void getPersonResponseNotNull() throws JsonToModelConversionException - { - Assert.assertNotNull(peopleAPI.getPerson(userModel.getUsername()), "Get person response should not be null"); - } - - @Test - public void getPersonCheckStatusCode() throws JsonToModelConversionException - { - peopleAPI.getPerson(userModel.getUsername()); - Assert.assertEquals(peopleAPI.usingRestWrapper().getStatusCode(), HttpStatus.OK.toString(), "Get person response status code is not correct"); - } - - @Test - public void getPersonResponseNotNull1() throws JsonToModelConversionException - { - Assert.assertNotNull(peopleAPI.getPerson(userModel.getUsername()), "Get person response should not be null"); + peopleAPI.getPerson(userModel.getUsername()) + .assertResponseIsNotEmpty(); + + peopleAPI.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.OK.toString()); } @Test public void getPersonCheckStatusCode1() throws JsonToModelConversionException { - peopleAPI.getPerson(userModel.getUsername()); - Assert.assertEquals(peopleAPI.usingRestWrapper().getStatusCode(), HttpStatus.OK.toString(), "Get person response status code is not correct"); + peopleAPI.getPerson(userModel.getUsername()) + .assertPersonHasName(userModel.getUsername()); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/SampleSitesTest.java b/e2e-test/java/org/alfresco/rest/SampleSitesTest.java index e6c67b12e..8637f7db6 100644 --- a/e2e-test/java/org/alfresco/rest/SampleSitesTest.java +++ b/e2e-test/java/org/alfresco/rest/SampleSitesTest.java @@ -1,7 +1,5 @@ package org.alfresco.rest; -import org.alfresco.dataprep.ContentService; -import org.alfresco.rest.RestSitesApi; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.SiteMember; import org.alfresco.utility.data.DataSite; @@ -12,7 +10,6 @@ import org.alfresco.utility.model.UserModel; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.social.alfresco.api.entities.Role; -import org.testng.Assert; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -27,9 +24,6 @@ public class SampleSitesTest extends RestTest @Autowired DataSite dataSite; - @Autowired - ContentService content; - private UserModel userModel; private SiteModel siteModel; @@ -45,56 +39,65 @@ public class SampleSitesTest extends RestTest @Test public void getSiteResponseNotNull() throws JsonToModelConversionException { - Assert.assertNotNull(siteAPI.getSite(siteModel.getId()), "Get site response should not be null"); + siteAPI.getSite(siteModel.getId()).assertResponseIsNotEmpty(); } @Test public void getSiteCheckStatusCode() throws JsonToModelConversionException { siteAPI.getSite(siteModel.getId()); - Assert.assertEquals(siteAPI.usingRestWrapper().getStatusCode(), HttpStatus.OK.toString(), "Get site response status code is not correct"); + siteAPI.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.OK.toString()); } @Test - public void getSitesResponseNotNull() throws JsonToModelConversionException + public void getSitesResponseNotEmpty() throws JsonToModelConversionException { - Assert.assertNotNull(siteAPI.getSites().getEntries(), "Get sites response should not be null"); + siteAPI.getSites() + .assertThatResponseIsNotEmpty(); } @Test public void getSitesCheckStatusCode() throws JsonToModelConversionException { siteAPI.getSites(); - Assert.assertEquals(siteAPI.usingRestWrapper().getStatusCode(), HttpStatus.OK.toString(), "Get sites response status code is not correct"); + siteAPI.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.OK.toString()); } @Test public void sitesCollectionHasPagination() throws JsonToModelConversionException { siteAPI.getSites().assertResponseHasPagination(); - Assert.assertEquals(siteAPI.getSites().getPagination().getCount(), 100, "Sites collection should have pagination"); } @Test public void addMemberToSiteCheckStatusCode() throws JsonToModelConversionException, DataPreparationException { UserModel newMember = dataUser.createRandomTestUser(); - SiteMember siteMember = new SiteMember(Role.SiteCollaborator.toString(), newMember.getUsername()); + SiteMember siteMember = new SiteMember(Role.SiteCollaborator.toString(), + newMember.getUsername()); + siteAPI.addPerson(siteModel.getId(), siteMember); - Assert.assertEquals(siteAPI.usingRestWrapper().getStatusCode(), HttpStatus.CREATED.toString(), - "Add member to site response status code is not correct"); + siteAPI.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.CREATED.toString()); } @Test public void isSiteReturned() throws JsonToModelConversionException { - siteAPI.getAllSites().assertThatResponseHasSite(siteModel.getId()); + siteAPI.getAllSites() + .assertThatResponseHasSite(siteModel.getId()); } @Test public void checkSiteDetails() throws JsonToModelConversionException { - siteAPI.getSite(siteModel.getId()); + siteAPI.getSite(siteModel.getId()) + .assertResponseIsNotEmpty() + .assertSiteHasDescription(siteModel.getDescription()) + .assertSiteHasTitle(siteModel.getTitle()) + .assertSiteHasVisibility(siteModel.getVisibility()); } } \ No newline at end of file diff --git a/e2e-test/resources/smoke-rest.xml b/e2e-test/resources/smoke-rest.xml index 32f515d5f..c60cb048c 100644 --- a/e2e-test/resources/smoke-rest.xml +++ b/e2e-test/resources/smoke-rest.xml @@ -6,9 +6,9 @@ - - - + + + From d341d02aeeeccb79a6697a3f675cc1b82a4fe81b Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Fri, 2 Sep 2016 10:47:16 +0300 Subject: [PATCH 0024/1491] TAS-387 Add support for JSON schema validation --- .../java/org/alfresco/rest/RestDemoTest.java | 4 ++-- .../org/alfresco/rest/SampleCommentsTest.java | 4 ++-- .../java/org/alfresco/rest/SamplePeopleTest.java | 6 ++---- .../java/org/alfresco/rest/SampleSitesTest.java | 16 ++++++++-------- 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/RestDemoTest.java b/e2e-test/java/org/alfresco/rest/RestDemoTest.java index 8849d8f14..bc45af0be 100644 --- a/e2e-test/java/org/alfresco/rest/RestDemoTest.java +++ b/e2e-test/java/org/alfresco/rest/RestDemoTest.java @@ -65,7 +65,7 @@ public class RestDemoTest extends RestTest * @throws JsonToModelConversionException */ @Test - public void commentsTest() throws JsonToModelConversionException + public void commentsTest() throws JsonToModelConversionException, Exception { Document document = dataContent.usingPath("Shared") .usingUser(userModel) @@ -97,7 +97,7 @@ public class RestDemoTest extends RestTest * @throws JsonToModelConversionException */ @Test - public void siteMembersTest() throws DataPreparationException, JsonToModelConversionException + public void siteMembersTest() throws DataPreparationException, JsonToModelConversionException, Exception { UserModel newUser = dataUser.createRandomTestUser(); SiteMember siteMember = new SiteMember(Role.SiteConsumer.toString(), newUser.getUsername()); diff --git a/e2e-test/java/org/alfresco/rest/SampleCommentsTest.java b/e2e-test/java/org/alfresco/rest/SampleCommentsTest.java index ba09905e9..ad3f01989 100644 --- a/e2e-test/java/org/alfresco/rest/SampleCommentsTest.java +++ b/e2e-test/java/org/alfresco/rest/SampleCommentsTest.java @@ -36,7 +36,7 @@ public class SampleCommentsTest extends RestTest } @Test - public void addComments() throws JsonToModelConversionException + public void addComments() throws JsonToModelConversionException, Exception { commentsAPI.addComment(document.getId(), "This is a new comment"); commentsAPI.usingRestWrapper() @@ -52,7 +52,7 @@ public class SampleCommentsTest extends RestTest } @Test - public void updateComment() throws JsonToModelConversionException + public void updateComment() throws JsonToModelConversionException, Exception { // add initial comment String commentId = commentsAPI.addComment(document.getId(), "This is a new comment").getId(); diff --git a/e2e-test/java/org/alfresco/rest/SamplePeopleTest.java b/e2e-test/java/org/alfresco/rest/SamplePeopleTest.java index d4247b267..2b2c67c40 100644 --- a/e2e-test/java/org/alfresco/rest/SamplePeopleTest.java +++ b/e2e-test/java/org/alfresco/rest/SamplePeopleTest.java @@ -1,7 +1,5 @@ package org.alfresco.rest; -import org.alfresco.rest.RestPeopleApi; -import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.UserModel; @@ -30,7 +28,7 @@ public class SamplePeopleTest extends RestTest } @Test - public void getPersonCheckResponseAndStatus() throws JsonToModelConversionException + public void getPersonCheckResponseAndStatus() throws Exception { peopleAPI.getPerson(userModel.getUsername()) .assertResponseIsNotEmpty(); @@ -40,7 +38,7 @@ public class SamplePeopleTest extends RestTest } @Test - public void getPersonCheckStatusCode1() throws JsonToModelConversionException + public void getPersonCheckStatusCode1() throws Exception { peopleAPI.getPerson(userModel.getUsername()) .assertPersonHasName(userModel.getUsername()); diff --git a/e2e-test/java/org/alfresco/rest/SampleSitesTest.java b/e2e-test/java/org/alfresco/rest/SampleSitesTest.java index 8637f7db6..27768ba27 100644 --- a/e2e-test/java/org/alfresco/rest/SampleSitesTest.java +++ b/e2e-test/java/org/alfresco/rest/SampleSitesTest.java @@ -37,13 +37,13 @@ public class SampleSitesTest extends RestTest } @Test - public void getSiteResponseNotNull() throws JsonToModelConversionException + public void getSiteResponseNotNull() throws JsonToModelConversionException, Exception { siteAPI.getSite(siteModel.getId()).assertResponseIsNotEmpty(); } @Test - public void getSiteCheckStatusCode() throws JsonToModelConversionException + public void getSiteCheckStatusCode() throws JsonToModelConversionException, Exception { siteAPI.getSite(siteModel.getId()); siteAPI.usingRestWrapper() @@ -51,14 +51,14 @@ public class SampleSitesTest extends RestTest } @Test - public void getSitesResponseNotEmpty() throws JsonToModelConversionException + public void getSitesResponseNotEmpty() throws JsonToModelConversionException, Exception { siteAPI.getSites() .assertThatResponseIsNotEmpty(); } @Test - public void getSitesCheckStatusCode() throws JsonToModelConversionException + public void getSitesCheckStatusCode() throws JsonToModelConversionException, Exception { siteAPI.getSites(); siteAPI.usingRestWrapper() @@ -66,13 +66,13 @@ public class SampleSitesTest extends RestTest } @Test - public void sitesCollectionHasPagination() throws JsonToModelConversionException + public void sitesCollectionHasPagination() throws JsonToModelConversionException, Exception { siteAPI.getSites().assertResponseHasPagination(); } @Test - public void addMemberToSiteCheckStatusCode() throws JsonToModelConversionException, DataPreparationException + public void addMemberToSiteCheckStatusCode() throws JsonToModelConversionException, DataPreparationException, Exception { UserModel newMember = dataUser.createRandomTestUser(); SiteMember siteMember = new SiteMember(Role.SiteCollaborator.toString(), @@ -84,14 +84,14 @@ public class SampleSitesTest extends RestTest } @Test - public void isSiteReturned() throws JsonToModelConversionException + public void isSiteReturned() throws JsonToModelConversionException, Exception { siteAPI.getAllSites() .assertThatResponseHasSite(siteModel.getId()); } @Test - public void checkSiteDetails() throws JsonToModelConversionException + public void checkSiteDetails() throws JsonToModelConversionException, Exception { siteAPI.getSite(siteModel.getId()) .assertResponseIsNotEmpty() From d1037f13d70c0db4f03c5f6785524ed87c7aedf4 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Fri, 2 Sep 2016 10:47:16 +0300 Subject: [PATCH 0025/1491] TAS-387 Add support for JSON schema validation --- .../java/org/alfresco/rest/RestDemoTest.java | 8 ++++---- .../org/alfresco/rest/SampleCommentsTest.java | 4 ++-- .../org/alfresco/rest/SamplePeopleTest.java | 6 ++---- .../org/alfresco/rest/SampleSitesTest.java | 18 +++++++++--------- 4 files changed, 17 insertions(+), 19 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/RestDemoTest.java b/e2e-test/java/org/alfresco/rest/RestDemoTest.java index 8849d8f14..b9a414fb6 100644 --- a/e2e-test/java/org/alfresco/rest/RestDemoTest.java +++ b/e2e-test/java/org/alfresco/rest/RestDemoTest.java @@ -28,9 +28,9 @@ public class RestDemoTest extends RestTest @BeforeClass public void setUp() throws DataPreparationException - { + { userModel = dataUser.getAdminUser(); - siteModel = dataSite.createPublicRandomSite(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); restClient.authenticateUser(userModel); sitesApi.useRestClient(restClient); @@ -65,7 +65,7 @@ public class RestDemoTest extends RestTest * @throws JsonToModelConversionException */ @Test - public void commentsTest() throws JsonToModelConversionException + public void commentsTest() throws JsonToModelConversionException, Exception { Document document = dataContent.usingPath("Shared") .usingUser(userModel) @@ -97,7 +97,7 @@ public class RestDemoTest extends RestTest * @throws JsonToModelConversionException */ @Test - public void siteMembersTest() throws DataPreparationException, JsonToModelConversionException + public void siteMembersTest() throws DataPreparationException, JsonToModelConversionException, Exception { UserModel newUser = dataUser.createRandomTestUser(); SiteMember siteMember = new SiteMember(Role.SiteConsumer.toString(), newUser.getUsername()); diff --git a/e2e-test/java/org/alfresco/rest/SampleCommentsTest.java b/e2e-test/java/org/alfresco/rest/SampleCommentsTest.java index ba09905e9..ad3f01989 100644 --- a/e2e-test/java/org/alfresco/rest/SampleCommentsTest.java +++ b/e2e-test/java/org/alfresco/rest/SampleCommentsTest.java @@ -36,7 +36,7 @@ public class SampleCommentsTest extends RestTest } @Test - public void addComments() throws JsonToModelConversionException + public void addComments() throws JsonToModelConversionException, Exception { commentsAPI.addComment(document.getId(), "This is a new comment"); commentsAPI.usingRestWrapper() @@ -52,7 +52,7 @@ public class SampleCommentsTest extends RestTest } @Test - public void updateComment() throws JsonToModelConversionException + public void updateComment() throws JsonToModelConversionException, Exception { // add initial comment String commentId = commentsAPI.addComment(document.getId(), "This is a new comment").getId(); diff --git a/e2e-test/java/org/alfresco/rest/SamplePeopleTest.java b/e2e-test/java/org/alfresco/rest/SamplePeopleTest.java index d4247b267..2b2c67c40 100644 --- a/e2e-test/java/org/alfresco/rest/SamplePeopleTest.java +++ b/e2e-test/java/org/alfresco/rest/SamplePeopleTest.java @@ -1,7 +1,5 @@ package org.alfresco.rest; -import org.alfresco.rest.RestPeopleApi; -import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.UserModel; @@ -30,7 +28,7 @@ public class SamplePeopleTest extends RestTest } @Test - public void getPersonCheckResponseAndStatus() throws JsonToModelConversionException + public void getPersonCheckResponseAndStatus() throws Exception { peopleAPI.getPerson(userModel.getUsername()) .assertResponseIsNotEmpty(); @@ -40,7 +38,7 @@ public class SamplePeopleTest extends RestTest } @Test - public void getPersonCheckStatusCode1() throws JsonToModelConversionException + public void getPersonCheckStatusCode1() throws Exception { peopleAPI.getPerson(userModel.getUsername()) .assertPersonHasName(userModel.getUsername()); diff --git a/e2e-test/java/org/alfresco/rest/SampleSitesTest.java b/e2e-test/java/org/alfresco/rest/SampleSitesTest.java index 8637f7db6..66482ae12 100644 --- a/e2e-test/java/org/alfresco/rest/SampleSitesTest.java +++ b/e2e-test/java/org/alfresco/rest/SampleSitesTest.java @@ -32,18 +32,18 @@ public class SampleSitesTest extends RestTest { userModel = dataUser.getAdminUser(); restClient.authenticateUser(userModel); - siteModel = dataSite.createPublicRandomSite(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); siteAPI.useRestClient(restClient); } @Test - public void getSiteResponseNotNull() throws JsonToModelConversionException + public void getSiteResponseNotNull() throws JsonToModelConversionException, Exception { siteAPI.getSite(siteModel.getId()).assertResponseIsNotEmpty(); } @Test - public void getSiteCheckStatusCode() throws JsonToModelConversionException + public void getSiteCheckStatusCode() throws JsonToModelConversionException, Exception { siteAPI.getSite(siteModel.getId()); siteAPI.usingRestWrapper() @@ -51,14 +51,14 @@ public class SampleSitesTest extends RestTest } @Test - public void getSitesResponseNotEmpty() throws JsonToModelConversionException + public void getSitesResponseNotEmpty() throws JsonToModelConversionException, Exception { siteAPI.getSites() .assertThatResponseIsNotEmpty(); } @Test - public void getSitesCheckStatusCode() throws JsonToModelConversionException + public void getSitesCheckStatusCode() throws JsonToModelConversionException, Exception { siteAPI.getSites(); siteAPI.usingRestWrapper() @@ -66,13 +66,13 @@ public class SampleSitesTest extends RestTest } @Test - public void sitesCollectionHasPagination() throws JsonToModelConversionException + public void sitesCollectionHasPagination() throws JsonToModelConversionException, Exception { siteAPI.getSites().assertResponseHasPagination(); } @Test - public void addMemberToSiteCheckStatusCode() throws JsonToModelConversionException, DataPreparationException + public void addMemberToSiteCheckStatusCode() throws JsonToModelConversionException, DataPreparationException, Exception { UserModel newMember = dataUser.createRandomTestUser(); SiteMember siteMember = new SiteMember(Role.SiteCollaborator.toString(), @@ -84,14 +84,14 @@ public class SampleSitesTest extends RestTest } @Test - public void isSiteReturned() throws JsonToModelConversionException + public void isSiteReturned() throws JsonToModelConversionException, Exception { siteAPI.getAllSites() .assertThatResponseHasSite(siteModel.getId()); } @Test - public void checkSiteDetails() throws JsonToModelConversionException + public void checkSiteDetails() throws JsonToModelConversionException, Exception { siteAPI.getSite(siteModel.getId()) .assertResponseIsNotEmpty() From 00169fcc9c56afb906fadcd5f50d65adb92f21e2 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Fri, 2 Sep 2016 12:30:17 +0300 Subject: [PATCH 0026/1491] update based on DSL --- .../java/org/alfresco/rest/RestDemoTest.java | 23 +++++++++---------- .../org/alfresco/rest/SampleCommentsTest.java | 7 +++--- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/RestDemoTest.java b/e2e-test/java/org/alfresco/rest/RestDemoTest.java index b9a414fb6..4760e48cc 100644 --- a/e2e-test/java/org/alfresco/rest/RestDemoTest.java +++ b/e2e-test/java/org/alfresco/rest/RestDemoTest.java @@ -5,9 +5,9 @@ import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestCommentModel; import org.alfresco.rest.model.SiteMember; import org.alfresco.utility.exception.DataPreparationException; +import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; -import org.apache.chemistry.opencmis.client.api.Document; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.social.alfresco.api.entities.Role; @@ -61,27 +61,26 @@ public class RestDemoTest extends RestTest * POST one comment to file using admin user
* Perform GET comments, check the new one is listed
* Update existing comment using PUT call, check that comment content is updated
- * - * @throws JsonToModelConversionException + * @throws Exception */ - @Test - public void commentsTest() throws JsonToModelConversionException, Exception + @Test + public void commentsTest() throws Exception { - Document document = dataContent.usingPath("Shared") + FileModel fileModel = dataContent.usingResource("Shared") .usingUser(userModel) - .createDocument(DocumentType.TEXT_PLAIN); + .createContent(DocumentType.TEXT_PLAIN); // add new comment - RestCommentModel commentEntry = commentsAPI.addComment(document.getId(), "This is a new comment"); - commentsAPI.getNodeComments(document.getId()) + RestCommentModel commentEntry = commentsAPI.addComment(fileModel.getNodeRef(), "This is a new comment"); + commentsAPI.getNodeComments(fileModel.getNodeRef()) .assertThatResponseIsNotEmpty() .assertThatCommentWithIdExists(commentEntry.getId()) .assertThatCommentWithContentExists("This is a new comment"); // update comment - commentEntry = commentsAPI.updateComment(document.getId(), + commentEntry = commentsAPI.updateComment(fileModel.getNodeRef(), commentEntry.getId(), "This is the updated comment"); - commentsAPI.getNodeComments(document.getId()) + commentsAPI.getNodeComments(fileModel.getNodeRef()) .assertThatResponseIsNotEmpty() .assertThatCommentWithIdExists(commentEntry.getId()) .assertThatCommentWithContentExists("This is the updated comment"); @@ -97,7 +96,7 @@ public class RestDemoTest extends RestTest * @throws JsonToModelConversionException */ @Test - public void siteMembersTest() throws DataPreparationException, JsonToModelConversionException, Exception + public void siteMembersTest() throws Exception { UserModel newUser = dataUser.createRandomTestUser(); SiteMember siteMember = new SiteMember(Role.SiteConsumer.toString(), newUser.getUsername()); diff --git a/e2e-test/java/org/alfresco/rest/SampleCommentsTest.java b/e2e-test/java/org/alfresco/rest/SampleCommentsTest.java index ad3f01989..5a50cbc3b 100644 --- a/e2e-test/java/org/alfresco/rest/SampleCommentsTest.java +++ b/e2e-test/java/org/alfresco/rest/SampleCommentsTest.java @@ -4,7 +4,6 @@ import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestCommentModel; import org.alfresco.utility.data.DataUser; -import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.UserModel; import org.apache.chemistry.opencmis.client.api.Document; import org.springframework.beans.factory.annotation.Autowired; @@ -24,15 +23,15 @@ public class SampleCommentsTest extends RestTest private Document document; @BeforeClass - public void initTest() throws DataPreparationException + public void initTest() throws Exception { userModel = dataUser.getAdminUser(); restClient.authenticateUser(userModel); commentsAPI.useRestClient(restClient); - document = dataContent.usingPath("Shared") + document = dataContent.usingResource("Shared") .usingUser(userModel) - .createDocument(DocumentType.TEXT_PLAIN); + .createContent(DocumentType.TEXT_PLAIN); } @Test From 932ddb2e02b29ec2b8698202f6be61e2b2b16688 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Fri, 2 Sep 2016 12:34:53 +0300 Subject: [PATCH 0027/1491] update Document to FileModel --- .../java/org/alfresco/rest/SampleCommentsTest.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/SampleCommentsTest.java b/e2e-test/java/org/alfresco/rest/SampleCommentsTest.java index 5a50cbc3b..5c0c32f25 100644 --- a/e2e-test/java/org/alfresco/rest/SampleCommentsTest.java +++ b/e2e-test/java/org/alfresco/rest/SampleCommentsTest.java @@ -4,8 +4,8 @@ import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestCommentModel; import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.UserModel; -import org.apache.chemistry.opencmis.client.api.Document; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; @@ -20,7 +20,7 @@ public class SampleCommentsTest extends RestTest RestCommentsApi commentsAPI; private UserModel userModel; - private Document document; + private FileModel document; @BeforeClass public void initTest() throws Exception @@ -37,7 +37,7 @@ public class SampleCommentsTest extends RestTest @Test public void addComments() throws JsonToModelConversionException, Exception { - commentsAPI.addComment(document.getId(), "This is a new comment"); + commentsAPI.addComment(document.getNodeRef(), "This is a new comment"); commentsAPI.usingRestWrapper() .assertStatusCodeIs(HttpStatus.CREATED.toString()); } @@ -45,7 +45,7 @@ public class SampleCommentsTest extends RestTest @Test public void getCommentsCheckStatusCode() throws JsonToModelConversionException { - commentsAPI.getNodeComments(document.getId()); + commentsAPI.getNodeComments(document.getNodeRef()); commentsAPI.usingRestWrapper() .assertStatusCodeIs(HttpStatus.OK.toString()); } @@ -54,10 +54,10 @@ public class SampleCommentsTest extends RestTest public void updateComment() throws JsonToModelConversionException, Exception { // add initial comment - String commentId = commentsAPI.addComment(document.getId(), "This is a new comment").getId(); + String commentId = commentsAPI.addComment(document.getNodeRef(), "This is a new comment").getId(); // update comment - RestCommentModel commentEntry = commentsAPI.updateComment(document.getId(), commentId, "This is the updated comment"); + RestCommentModel commentEntry = commentsAPI.updateComment(document.getNodeRef(), commentId, "This is the updated comment"); commentEntry.assertCommentContentIs("This is the updated comment"); } From 5bb07e9f4d642d8ad4d681672d2ce67baf45e035 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Fri, 2 Sep 2016 16:57:19 +0300 Subject: [PATCH 0028/1491] Formatting, change test names --- .../java/org/alfresco/rest/RestDemoTest.java | 54 ++++++++++--------- .../org/alfresco/rest/SampleCommentsTest.java | 10 ++-- .../org/alfresco/rest/SamplePeopleTest.java | 12 +++-- .../org/alfresco/rest/SampleSitesTest.java | 16 +++--- 4 files changed, 50 insertions(+), 42 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/RestDemoTest.java b/e2e-test/java/org/alfresco/rest/RestDemoTest.java index 4760e48cc..060340417 100644 --- a/e2e-test/java/org/alfresco/rest/RestDemoTest.java +++ b/e2e-test/java/org/alfresco/rest/RestDemoTest.java @@ -47,13 +47,14 @@ public class RestDemoTest extends RestTest * @throws Exception */ @Test - public void sitesTest() throws JsonToModelConversionException, Exception + public void adminRetrievesCorrectSiteDetails() throws JsonToModelConversionException, Exception { - sitesApi.getAllSites().assertThatResponseHasSite(siteModel) - .getSite(siteModel) - .assertSiteHasVisibility(Visibility.PUBLIC) - .assertSiteHasTitle(siteModel.getTitle()) - .assertSiteHasDescription(siteModel.getDescription()); + sitesApi.getAllSites() + .assertThatResponseHasSite(siteModel) + .getSite(siteModel) + .assertSiteHasVisibility(Visibility.PUBLIC) + .assertSiteHasTitle(siteModel.getTitle()) + .assertSiteHasDescription(siteModel.getDescription()); } /** @@ -64,7 +65,7 @@ public class RestDemoTest extends RestTest * @throws Exception */ @Test - public void commentsTest() throws Exception + public void adminCanPostAndUpdateComments() throws Exception { FileModel fileModel = dataContent.usingResource("Shared") .usingUser(userModel) @@ -72,18 +73,18 @@ public class RestDemoTest extends RestTest // add new comment RestCommentModel commentEntry = commentsAPI.addComment(fileModel.getNodeRef(), "This is a new comment"); commentsAPI.getNodeComments(fileModel.getNodeRef()) - .assertThatResponseIsNotEmpty() - .assertThatCommentWithIdExists(commentEntry.getId()) - .assertThatCommentWithContentExists("This is a new comment"); + .assertThatResponseIsNotEmpty() + .assertThatCommentWithIdExists(commentEntry.getId()) + .assertThatCommentWithContentExists("This is a new comment"); // update comment commentEntry = commentsAPI.updateComment(fileModel.getNodeRef(), commentEntry.getId(), "This is the updated comment"); commentsAPI.getNodeComments(fileModel.getNodeRef()) - .assertThatResponseIsNotEmpty() - .assertThatCommentWithIdExists(commentEntry.getId()) - .assertThatCommentWithContentExists("This is the updated comment"); + .assertThatResponseIsNotEmpty() + .assertThatCommentWithIdExists(commentEntry.getId()) + .assertThatCommentWithContentExists("This is the updated comment"); } /** @@ -96,29 +97,32 @@ public class RestDemoTest extends RestTest * @throws JsonToModelConversionException */ @Test - public void siteMembersTest() throws Exception + public void adminCanAddAndUpdateSiteMemberDetails() throws Exception { UserModel newUser = dataUser.createRandomTestUser(); - SiteMember siteMember = new SiteMember(Role.SiteConsumer.toString(), newUser.getUsername()); + SiteMember siteMember = new SiteMember(Role.SiteConsumer.toString(), + newUser.getUsername()); // add user as Consumer to site sitesApi.addPerson(siteModel.getId(), siteMember); sitesApi.getSiteMembers(siteModel.getId()) - .assertThatSiteHasMember(siteMember.getId()) - .getSiteMember(siteMember.getId()) - .assertSiteMemberHasRole(Role.SiteConsumer); + .assertThatSiteHasMember(siteMember.getId()) + .getSiteMember(siteMember.getId()) + .assertSiteMemberHasRole(Role.SiteConsumer); // update site member to Manager siteMember.setRole(Role.SiteManager.toString()); - ; - sitesApi.updateSiteMember(siteModel.getId(), newUser.getUsername(), siteMember); + sitesApi.updateSiteMember(siteModel.getId(), + newUser.getUsername(), siteMember); sitesApi.getSiteMembers(siteModel.getId()) - .assertThatSiteHasMember(siteMember.getId()) - .getSiteMember(siteMember.getId()) - .assertSiteMemberHasRole(Role.SiteManager); + .assertThatSiteHasMember(siteMember.getId()) + .getSiteMember(siteMember.getId()) + .assertSiteMemberHasRole(Role.SiteManager); // delete site member - sitesApi.deleteSiteMember(siteModel.getId(), newUser.getUsername()); - sitesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT.toString()); + sitesApi.deleteSiteMember(siteModel.getId(), + newUser.getUsername()); + sitesApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.NO_CONTENT.toString()); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/SampleCommentsTest.java b/e2e-test/java/org/alfresco/rest/SampleCommentsTest.java index 5c0c32f25..360377166 100644 --- a/e2e-test/java/org/alfresco/rest/SampleCommentsTest.java +++ b/e2e-test/java/org/alfresco/rest/SampleCommentsTest.java @@ -35,7 +35,7 @@ public class SampleCommentsTest extends RestTest } @Test - public void addComments() throws JsonToModelConversionException, Exception + public void adminIsAbleToAddComment() throws JsonToModelConversionException, Exception { commentsAPI.addComment(document.getNodeRef(), "This is a new comment"); commentsAPI.usingRestWrapper() @@ -43,7 +43,7 @@ public class SampleCommentsTest extends RestTest } @Test - public void getCommentsCheckStatusCode() throws JsonToModelConversionException + public void adminIsAbleToRetrieveComments() throws JsonToModelConversionException { commentsAPI.getNodeComments(document.getNodeRef()); commentsAPI.usingRestWrapper() @@ -51,13 +51,15 @@ public class SampleCommentsTest extends RestTest } @Test - public void updateComment() throws JsonToModelConversionException, Exception + public void adminIsAbleToUpdateComment() throws JsonToModelConversionException, Exception { // add initial comment String commentId = commentsAPI.addComment(document.getNodeRef(), "This is a new comment").getId(); // update comment - RestCommentModel commentEntry = commentsAPI.updateComment(document.getNodeRef(), commentId, "This is the updated comment"); + RestCommentModel commentEntry = commentsAPI.updateComment(document.getNodeRef(), + commentId, + "This is the updated comment"); commentEntry.assertCommentContentIs("This is the updated comment"); } diff --git a/e2e-test/java/org/alfresco/rest/SamplePeopleTest.java b/e2e-test/java/org/alfresco/rest/SamplePeopleTest.java index 2b2c67c40..38a8b2980 100644 --- a/e2e-test/java/org/alfresco/rest/SamplePeopleTest.java +++ b/e2e-test/java/org/alfresco/rest/SamplePeopleTest.java @@ -18,17 +18,19 @@ public class SamplePeopleTest extends RestTest DataUser dataUser; private UserModel userModel; + private UserModel adminUser; @BeforeClass public void setUp() throws DataPreparationException { userModel = dataUser.createUser(RandomStringUtils.randomAlphanumeric(20)); - restClient.authenticateUser(userModel); + adminUser = dataUser.getAdminUser(); + restClient.authenticateUser(adminUser); peopleAPI.useRestClient(restClient); } @Test - public void getPersonCheckResponseAndStatus() throws Exception + public void adminIsAbleToRetrievePerson() throws Exception { peopleAPI.getPerson(userModel.getUsername()) .assertResponseIsNotEmpty(); @@ -38,10 +40,10 @@ public class SamplePeopleTest extends RestTest } @Test - public void getPersonCheckStatusCode1() throws Exception + public void adminIsAbleToRetrieveItself() throws Exception { - peopleAPI.getPerson(userModel.getUsername()) - .assertPersonHasName(userModel.getUsername()); + peopleAPI.getPerson(adminUser.getUsername()) + .assertPersonHasName(adminUser.getUsername()); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/SampleSitesTest.java b/e2e-test/java/org/alfresco/rest/SampleSitesTest.java index 66482ae12..d7de96f03 100644 --- a/e2e-test/java/org/alfresco/rest/SampleSitesTest.java +++ b/e2e-test/java/org/alfresco/rest/SampleSitesTest.java @@ -37,13 +37,13 @@ public class SampleSitesTest extends RestTest } @Test - public void getSiteResponseNotNull() throws JsonToModelConversionException, Exception + public void adminCanGetSiteDetails() throws JsonToModelConversionException, Exception { siteAPI.getSite(siteModel.getId()).assertResponseIsNotEmpty(); } @Test - public void getSiteCheckStatusCode() throws JsonToModelConversionException, Exception + public void adminCanAccessSiteDetails() throws JsonToModelConversionException, Exception { siteAPI.getSite(siteModel.getId()); siteAPI.usingRestWrapper() @@ -51,14 +51,14 @@ public class SampleSitesTest extends RestTest } @Test - public void getSitesResponseNotEmpty() throws JsonToModelConversionException, Exception + public void adminCanAccessSites() throws JsonToModelConversionException, Exception { siteAPI.getSites() .assertThatResponseIsNotEmpty(); } @Test - public void getSitesCheckStatusCode() throws JsonToModelConversionException, Exception + public void adminIsAbleToRetrieveSites() throws JsonToModelConversionException, Exception { siteAPI.getSites(); siteAPI.usingRestWrapper() @@ -66,13 +66,13 @@ public class SampleSitesTest extends RestTest } @Test - public void sitesCollectionHasPagination() throws JsonToModelConversionException, Exception + public void adminIsAbleToAccessResponsePagination() throws JsonToModelConversionException, Exception { siteAPI.getSites().assertResponseHasPagination(); } @Test - public void addMemberToSiteCheckStatusCode() throws JsonToModelConversionException, DataPreparationException, Exception + public void adminIsAbleToAddNewSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception { UserModel newMember = dataUser.createRandomTestUser(); SiteMember siteMember = new SiteMember(Role.SiteCollaborator.toString(), @@ -84,14 +84,14 @@ public class SampleSitesTest extends RestTest } @Test - public void isSiteReturned() throws JsonToModelConversionException, Exception + public void adminIsAbleToGetSiteFromSitesList() throws JsonToModelConversionException, Exception { siteAPI.getAllSites() .assertThatResponseHasSite(siteModel.getId()); } @Test - public void checkSiteDetails() throws JsonToModelConversionException, Exception + public void adminIsAbleToAccessSiteDetails() throws JsonToModelConversionException, Exception { siteAPI.getSite(siteModel.getId()) .assertResponseIsNotEmpty() From cee81cb83768ffd0057cf558e5b666ec7bf71cc4 Mon Sep 17 00:00:00 2001 From: cnechifor Date: Fri, 9 Sep 2016 15:53:55 +0300 Subject: [PATCH 0029/1491] TAS-442 add support for logging --- e2e-test/resources/TransformLog.xsl | 150 ++++++++++++++++++++++++++ e2e-test/resources/default.properties | 26 ++++- e2e-test/resources/logo.png | Bin 0 -> 9190 bytes e2e-test/resources/smoke-rest.xml | 4 +- 4 files changed, 178 insertions(+), 2 deletions(-) create mode 100644 e2e-test/resources/TransformLog.xsl create mode 100644 e2e-test/resources/logo.png diff --git a/e2e-test/resources/TransformLog.xsl b/e2e-test/resources/TransformLog.xsl new file mode 100644 index 000000000..78debb87a --- /dev/null +++ b/e2e-test/resources/TransformLog.xsl @@ -0,0 +1,150 @@ + + + + + + Report +
+ + + + + + +
+
+
+
+
+ +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + +
SUITETOTALPASSEDFAILEDSKIPPEDRATE
+ + + + + + + + + + + +
+
+ +
+ + +
+ + + + + + + + + + + + + + + +
+

Tests

+
+

Status

+
+

Steps

+
+ + + + + + + + + + + + +
+ + +
+
+
+ +
+
+
+ + + + +
+ +
\ No newline at end of file diff --git a/e2e-test/resources/default.properties b/e2e-test/resources/default.properties index 96caacc10..321c98aca 100644 --- a/e2e-test/resources/default.properties +++ b/e2e-test/resources/default.properties @@ -8,4 +8,28 @@ admin.user=admin admin.password=admin # rest related -rest.basePath=alfresco/api/-default-/public/alfresco/versions/1 \ No newline at end of file +rest.basePath=alfresco/api/-default-/public/alfresco/versions/1 + + +# TEST MANAGEMENT SECTION - Test Rail +# +# (currently supporting Test Rail v5.2.1.3472 integration) +# +# Example of configuration: +# ------------------------------------------------------ +# testManagement.endPoint=https://alfresco.testrail.com/ +# testManagement.username= +# testManagement.apiKey= +# testManagement.project= +# testManagement.justUploadTest=false +# if testManagement.justUploadTest=false we only update test cases in test rail +# ------------------------------------------------------ +testManagement.endPoint=https://alfresco.testrail.com/ +testManagement.username=tas.alfresco@gmail.com +testManagement.apiKey=EYpY7.fV0AoMGWbmyuVC-k5u.nzwHy6a.QWzJq8.S +testManagement.project=7 +testManagement.testRun=Automation +testManagement.justUploadTest=false + +log.path=/Users/p3700299/Documents/AlfrescoLogs diff --git a/e2e-test/resources/logo.png b/e2e-test/resources/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..cf143364ac251c17ab8e9e167ef71292c46ccf82 GIT binary patch literal 9190 zcmVKLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o#eyhGvpiOA@W-aonk<7r1(?fC{oI5N*U!4 zfg=2N-7=cNnjjOr{yriy6mMFgG#l znCF=fnQv8CDz++o6_Lscl}eQ+l^ZHARH>?_s@|##Rr6KLRFA1%Q+=*RRWnoLsR`7U zt5vFIcfW3@?wFpwUVxrVZ>QdQz32KIeJ}k~{cZZE^+ya? z2D1z#2HOnI7(B%_ac?{wFUQ;QQA1tBKtrWrm0_3Rgps+?Jfqb{jYbcQX~taRB;#$y zZN{S}1|}gUOHJxc?wV3fxuz+mJ4`!F$IZ;mqRrNsHJd##*D~ju=bP7?-?v~|cv>vB zsJ6IeNwVZxrdjT`yl#bBIa#GxRa#xMMy;K#CDyyGyQdMSxlWT#tDe?p!?5wT$+oGt z8L;Kp2HUQ-ZMJ=3XJQv;x5ci*?vuTfeY$;({XGW_huIFR9a(?@3)XSs8O^N5RyOM=TTmp(3=8^+zpz2r)C z^>JO{deZfso3oq3?Wo(Y?l$ge?uXo;%ru`Vo>?<<(8I_>;8Eq#KMS9gFl*neeosSB zfoHYnBQIkwkyowPu(zdms`p{<7e4kra-ZWq<2*OsGTvEV%s0Td$hXT+!*8Bnh2KMe zBmZRodjHV?r+_5^X9J0WL4jKW`}lf%A-|44I@@LTvf1rHjG(ze6+w@Jt%Bvjts!X0 z?2xS?_ve_-kiKB_KiJlZ$9G`c^=E@oNG)mWWaNo-3TIW8)$Hg0Ub-~8?KhvJ>$ z3*&nim@mj(aCxE5!t{lw7O5^0EIO7zOo&c6l<+|iDySBWCGrz@C5{St!X3hAA}`T4 z(TLbXTq+(;@<=L8dXnssyft|w#WSTW<++3>sgS%(4NTpeI-VAqb|7ssJvzNHgOZVu zaYCvgO_R1~>SyL=cFU|~g|hy|Zi}}s9+d~lYqOB71z9Z$wnC=pR9Yz4DhIM>Wmjgu z&56o6maCpC&F##y%G;1PobR9i?GnNg;gYtchD%p19a!eQtZF&3JaKv33gZ<8D~47E ztUS1iwkmDaPpj=$m#%)jCVEY4fnLGNg2A-`YwHVD3gv};>)hAvT~AmqS>Lr``i7kw zJ{5_It`yrBmlc25DBO7E8;5VoznR>Ww5hAaxn$2~(q`%A-YuS64wkBy=9dm`4cXeX z4c}I@?e+FW+b@^RDBHV(wnMq2zdX3SWv9u`%{xC-q*U}&`cyXV(%rRT*Z6MH?i+i& z_B8C(+grT%{XWUQ+f@NoP1R=AW&26{v-dx)iK^-Nmiuj8txj!m?Z*Ss1N{dh4z}01 z)YTo*JycSU)+_5r4#yw9{+;i4Ee$peRgIj+;v;ZGdF1K$3E%e~4LaI(jC-u%2h$&R z9cLXcYC@Xwnns&bn)_Q~Te?roKGD|d-g^8;+aC{{G(1^(O7m37Y1-+6)01cN&y1aw zoqc{T`P^XJqPBbIW6s}d4{z_f5Om?vMgNQEJG?v2T=KYd^0M3I6IZxbny)%vZR&LD zJpPl@Psh8QyPB@KTx+@RdcC!KX7}kEo;S|j^u2lU7XQ}Oo;f|;z4Ll+_r>@1-xl3| zawq-H%e&ckC+@AhPrP6BKT#_XdT7&;F71j}Joy zkC~6lh7E@6o;W@^IpRNZ{ptLtL(gQ-CY~4mqW;US7Zxvm_|@yz&e53Bp_lTPlfP|z zrTyx_>lv@x#=^!PzR7qqF<$gm`|ZJZ+;<)Cqu&ot2z=00004XF*Lt006O$eEU(80000WV@Og>004R=004l4008;_004mL004C` z008P>0026e000+nl3&F}000>QNklqxAErr;48Vx4rr2qwZM0w!pkysE09pCTI-x6k4 z3G?d)y%(GY#(1zQB6#+@_ynX`fk9B4| zIK5pCQ~^8^r(*j;yn70p&wvO3z_O6qffB$3P;7ev%gjrqz5k>vAcN?^q-lqq<42Mt6&IJ3mzRs8*!`iRD0Ox9B_*Y0 zW#v|z?RSjX6?V{ULwXIsK%!k360iys7BB#&D_69Z;d~<|_@nRyVCxDp01EDi25B#m z<(@YN7%0UbF|q5wYHm6qo6WZAz4x=Sv)$ZX-+bfs(BR;{V;UP9pI`r?-o@p`zdrBh z=Lf*yaD4gY*Wd2^zO}X0ZnLj=@PTDZ|40b)JCCyx6Kc!=z_4&r!9@iqkVGgVU;y|l zaYAL(nJ_H?5PL3uz#U0pz=ge(bmc~+>#B}Ru+-jC=ibwc$6eTk=>w}Lz1TcTz+(nD-3JDGQ9ZPao!a-oLY!F6zW3&&5j1CbhEq*A$ zXT_)_fDSNq4d-yt0xu1q>ZxmC$~+7sKTBuNbppl!44?oa-~gy})7el;_wW0qsi|q| zr6UK}tgn$r+VSfLZ4fn>} zAnZ7YZCNO5fxuxz5aveUyBXM9gJ-NjK49<6gjNx4jvi5JgL*i=o?bxqEvGh+!C?IW z6~F)@YQB=84gonvvlj;J13!gKxa`_R(W`C8cGebphlSyT7*E?S~HKvcSUm^9UgW!^8dj{Bm-0TU+n<@-kkt6xY?))z;QH93lauD9Y(m zr`_D$RDz(_8(K^)-rn9`Mk9c>wzdwlxv8lsctEhLs{w%3YPH#Hm+I?fQ4&;wuaA#j zukV{qJIv<7!lL~Ae2dj4iVmZvF(@z~CML$i!@V!Ak}TKO)>gwu5N%Hmal_b&K-TfMvDHPj_u;mmWfboOU z3N!$07g=Wk4N!$i?<4zRd^ig$C~zL40!0C=P(`6^RhhB)IjQ6eZVVt?O-!5|#P``6 z@zROb?31n8gIyMeXs7pR1+G|AQ&Udv;ppfgfq?-4LPJA_4;#9BZ`z@pL-Xd&?Hy!P z5mdtN-FtEmA5|3D)Y?iF`sOQyrpI28_x0p1k|7skcKu`JsY+VYBu zFLvxGEiMyfNfaGafv2Z?{HXW^bLV+^83`dxO_wj!)K*kgS=!C>=FPbVW-WHSaRMM9 z1Plu$5}-g6!1Qpe8d537zK4Sk;e%ONWrMdK8Xlg(_H&DBe9B)^O1|Jm0qU#6O93dX z#z&jgQ$D|tEK|t9&vo~&3@zb^rtdo4vp21=sp*0Hm$|yS0$^Eo;`j-BQ`1vZGm?{& zwHi&YAQMF?JUrYkN}@x|JD%roIO2zopbR|SJa~bvD6jPJ^vFL~@XTMHYiw)`4h{|s z3UG6CJC>LC+8b{*HZ~3%7@ja@3<#QAnyad+-hcnU4&~%L^VE~h=Ar5GtQdVA> zG;QjP>C*xOf+SfiD=pjg)9$S7Y?I0K`m29)b8`bwUtj;$JDakzvpqdLhmRa)Fc=&* zd$Xw}=TPqPyyHujEM9WY-A>pfN!q=8?}s06X)(3L#l;2&1PGj9wcCmc3%6|j$DuGdmJ@S`z_?&tYCEqdQyCRI~iY=C*+AzEE{U-3=)-A5GnpF%~pv+R+Dpq+4k$u>Q z{Xk}>x3|~0v17YG96dTdG&H2Rq@=QH9MF z?c2X_;R37G`s!=1XCKT-o}RSmt~;Znqa31007X%<4<34d^9NhDZ67=+A|YWkr8Mi{ z!8hM}TdmVQ_Q=C2Daky?vn9j5sMU}Z02B%j;>JZw zLU036Xx^LE^tU<(1g0}MtQ6JOjJ}wiK69qDtbF$DnZCY0-5+W+n#q$UZT{ecw2X{_ z1H*eU5r$<5pwVb}o;P<`WJwkTf#Wy;o<=VKyLaz3dV0LP;ic&4D3)bqMfu_HAJ*43 zJoe}#ciyqkx%M?0HGr_tkSEtZK^T&nmT~0hvG|cAN=i!9f@<8jvE6_<&1m$z`|i8; zq^724>|eNW!Ja*P4(8;JA2;@e=buxl1OUzn0GOUMO_r7QFTM1|j<1FfA8NPT-{1US zf?D;&nn#nSP3@U5g8~Epw0e~w2p@gCb@S%UufFoKi_489bx!PqrDOwuXirQXi7+=1 z3IGxXOTZ8`T2O07q8}w7aPi9z8q_S-sALv|b*4j^HrgH8&E|J1%*Sgiotq!JymK`@X;rs7)=Hwo^_m4|FuEvZdM3f|_2%=EMd7n=9FUd|> zYxSyCv9U4E56_=JpMCI9Tx`tDnJGP8<}`y|zjFEVoI^Q3{`gZ+V1TRM0HC0tuy=d| z5rYOkzUEPHFYmUt_V0G?(!1zau6)o5*j3YG*~Em=5rZNMi;CLX+K!(%SzUc$&L8F^ zPfzMgK3SGsviP3Ntb->{pUFR0Ff=aqMwn^%t8{%h5aojnV-V?DbitZg-BDl`n*oL+ zARwZ|3~*~Vy6c)9Pq^|S4yDbN33@euWqB*yRZu7hpa3=sHw}FB@X$h0AS+i1mTK0c z*CdLIOOBs7F=R;8sQCC^UxkK*L=TBNc<4}G-tpw=NxcP;>%5hs$aYbTiH(UK64l+U zx0+fnUv8c^e{QeR*lnJk9s_N?M>iCf(g93xDc|(K2^_g{RTTCX7<1;g}c%Gj>Z_f3)1+7*)dE$hRwr(vi zE02qfxj|FGO$)?}3=|4N01*$5Z2$AH#rZSeZ@o&^RVdUvW(`5CaZ`Cmmbd2O z`L?eDb@49`JDIX;c##EK{;CXY&>-9k(f;5VXX1oRp=A)FNxr%xmQS5NQ(xCGBRSb* zYQ5at+&x_a!m`YeA<>7A9NCkaI&JEdzVXpZ)auf;8AXwU0s;+PnT=AKcj6?^bC(-0 zr>3P*fVtW!qA1$!4pEX@+uH~*Vf^?-ci;8R*WbSK+Uw!r;Uh;3_xAFNh!`{=Xn?_> zSE*E#(i107SuB>3BS*Nn=&tQtj*X6v2GG{lUQto$=i}?7#Mcw##*Itdy8WN0&YYe< zf9{RqEXoa$UMOq?rMNdnc_zN$*`v3AQgq57z|bQEB?VdyQU+sH=(bji{~M({3316@wvOlRGTFi_6p4HHk_zJvjyWqJ7IHBjBt(7aelo-;ncKrLE!hM zrsf{brAjZVLCozPEW?%*mlhNh#Ky+n(oQZRgbU308R5uLQ)GIqQn&rFFJ9LbPgIhIgRS(3fH zy;Uk9EHo5=i%yp^BYDi|QIw+K{Q1(dvckfm%BrewzyJQ=p`53mTI-^7aoFs#BzHgM z21+W+u~xgy#pOma5CKGos8R{+4aHK90Q17Id^o%`w4!~>r^RQz)K@t{qA+NX6oFM? z+s#)06GVC%ptJ$rt{C8k zd;B;0sz&u<9|sN`pp@ReV17zUO5f%044PACPXBfNOX>Ue&zm>bpw}zPEsFM6hVeY_ zY4i|9am4Tu2?=AacR^cQo1!R$5LuQPh9QJFyX^7f#*QC1)@-)a*Vljb^*2B7-t*DN zTc=H%qS0zkoH}*eZ7J7F+6S_-&z;SmIB~qMxA*zNBCFNfi-`8L+S-ezR#S9T)Qtsh z#_87A67lRPYijMMPRbxtND4#+gkXR>rVqwL1Gkzj{tsj(*K|O~LzLkz__^=~hJoFI zj3T^vc8SCt`#L3KVfZKjCI?zYw23e|&>=!Ed9DcFGR$=~L#~RF3pF))$4?r)yi!tT zxVyP|c)0idad&qc8XG%!(BPt?k|Rfs0ALt$(|SfJ?G>^kh7DsmCM|uREX&uEl%9U( z*@quplXv|1=U;r8m6hFdPZfYprwt1WefXi(lP6CsudHZoZS(W>J#*%4dwcseZ)mkz zckcZ0$Dek)y19)`7-Ke@Q`0kWUEZXmXJly98edqQMzTll}1W4GqdXJ>k`L|b~U)(V3r;p9up^y2e5D7 zF97~EE!fN3D=;81>)^qvs;X-aIC1jS(c{Ml1O<6}`+WG(mVbWwnJg=Phq<`8gocEg zEf!y2pJ7AeDl4nL`+jG4o6*xMDk@K&Iu$%1(8Jw5E;dG`R;8z>H#9U}^XbQrpFDE( zn75C2VnX7r?s>M$B^m)S{zweRqzH_UKzuNK+z_gB9jKlEMDBv>Hn{Me>4pGWCRERL zI+|tBVMAUOc3t}HlbShZX78ft39E2;dH-_LK}+&{FonqGhFor@RidV1O6 za8y-Y_|Nw@Yc!h0ix-E7g+)dUE-5K3C^*+QDBIiH^YaU|YE4{R?9zMx=kibO*9%vCKnToojRK{c+%qid z+F-JPXDvU}?f9vF2T#B=u*)zj2v=VtI7-XP3eKM&IyBDT&-bR71qApH8#**IEBkEz zxr8yJZ^9dyYni|<(! z9TiCk7S5Z${-q5s{q5Bi4=#@%Io!+3%USK(J32o4cw6q_!wCtae7wC42E(I|JoNTE z@4olm`{m{3iHV6mK0Y?9_3XKGscC72g(Y)l&73-El2ad9{=oe$&8B_(_cvW`N={0O zj2x`hYFpb{^N!{1O-pNNY`S;J;^gF{|G}Q8QHXNkg;vSIIQ5LK&1+xP&=1aRw#(44 zot&7Jp%rk^o*C#et_S3Bh-hesj{$0?lK?mrFa#Du`5_2~nUS2dH!bb!Z@vo;3$xj6tc7*P3Z>L+Hd`&$?$A*bxudR1DC647De)vxd=g)U8p6SU+HMKQ6zW!#z%P)t8gocHO z^1M)AUtfLULStj&(4ldUuUTU-7@QiFL2vl<^Uu@w?ce`PCdY9KmF+f%O08P{z|y<# zx{K@DhV?QUpIrO6kB?8*!R(K>ZWRQ9A&jiZqA2?M_}sf>$?RD(ueW`3ZOk;RPo!>o zwdH4?Twz^04g$OiO-H(;K$79Eg;9?)rtfBZuL{ti$p%dqzwfYJNl2szdy6yti6MM1 z%%UPAq9P-vOqy^j8;OLF#KeS$R`hN+|{pj);gD6ftPfl_kh9%a-07Gi1mwnVA(8 z6=h`=pj4w(M@A05Z`r+LMvZdH|IUdeB#e%Y9dh#2>HPe27K>R>2?m4f(73q15|q(s zT)pbS`Sa%-J9fOKrMcZ~cGc?x0|Up59&Iq_Z*i0TsvJ^dJNQod1d9wOY!qu`vD)xw@@tHorpS#1Cn z1eL*{*Jw1?E2xqrvn)dhaX1`;a3h^pQ51$@oWK9|b5{TY)MIb=+W??jIJU}?mDYHv z0~87hIAnx+BElP#!lBST^{bXfFTZo(*cL~ZXvTw(9)Ky(65Jj5ZC}8g!s!2KtDX=r z48yXl6X~9B%P>sOKb_y+^ybd90yhB6sV@3>dj|&(2o4VR^Yhi|bT{xa$92BZjREUk zUjN!bBj)NpoEhcz_>zEUU0B!@h!kxSnjA%Ugsqe*6pBIK7!?9AkQE3FPPUevXnpmS z#P|LfF~K6DLxe#KkwT=fE3nD%Q(^gl?E|%Q&~N`fy9U3KspF#U@PW%uU$o^mJLm-C zf)ToR799w7)g#mcEOSMtr+`8+$v7q6b?y14i#y6*3Gyl9Sx`X7ss_8vndJF5SAHNt z|Nnsg%9wSfwN{7HZW2og*g(yM%;rCTQM-}v<9-T=3j8&g?D-#K-Jfp}%dK(~OLQK> zAQpna==)v#zlT}xQml0RSidl%F^vKOa}_7FD&L9$`Z4Rbe~ - + + + From 56493284dc72abd0afea43abd5f328ae9010b6d9 Mon Sep 17 00:00:00 2001 From: cnechifor Date: Fri, 9 Sep 2016 15:55:29 +0300 Subject: [PATCH 0030/1491] TAS-437 added TestRail annotation --- .../org/alfresco/rest/SampleCommentsTest.java | 27 ++++---- .../org/alfresco/rest/SamplePeopleTest.java | 19 +++--- .../org/alfresco/rest/SampleSitesTest.java | 64 ++++++++++--------- 3 files changed, 58 insertions(+), 52 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/SampleCommentsTest.java b/e2e-test/java/org/alfresco/rest/SampleCommentsTest.java index 360377166..e22fc7ec3 100644 --- a/e2e-test/java/org/alfresco/rest/SampleCommentsTest.java +++ b/e2e-test/java/org/alfresco/rest/SampleCommentsTest.java @@ -6,11 +6,14 @@ import org.alfresco.rest.model.RestCommentModel; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +@Test(groups = { "rest-api", "comments", "sanity" }) public class SampleCommentsTest extends RestTest { @Autowired @@ -29,37 +32,33 @@ public class SampleCommentsTest extends RestTest restClient.authenticateUser(userModel); commentsAPI.useRestClient(restClient); - document = dataContent.usingResource("Shared") - .usingUser(userModel) - .createContent(DocumentType.TEXT_PLAIN); + document = dataContent.usingResource("Shared").usingUser(userModel).createContent(DocumentType.TEXT_PLAIN); } - @Test - public void adminIsAbleToAddComment() throws JsonToModelConversionException, Exception + @TestRail(section={"rest-api", "comments"}, executionType= ExecutionType.SANITY) + public void admiShouldAddComment() throws JsonToModelConversionException, Exception { commentsAPI.addComment(document.getNodeRef(), "This is a new comment"); commentsAPI.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.CREATED.toString()); + .assertStatusCodeIs(HttpStatus.CREATED.toString()); } - @Test - public void adminIsAbleToRetrieveComments() throws JsonToModelConversionException + @TestRail(section={"rest-api", "comments"}, executionType= ExecutionType.SANITY) + public void admiShouldRetrieveComments() throws JsonToModelConversionException { commentsAPI.getNodeComments(document.getNodeRef()); commentsAPI.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.OK.toString()); + .assertStatusCodeIs(HttpStatus.OK.toString()); } - @Test - public void adminIsAbleToUpdateComment() throws JsonToModelConversionException, Exception + @TestRail(section={"rest-api", "comments"}, executionType= ExecutionType.SANITY) + public void adminShouldUpdateComment() throws JsonToModelConversionException, Exception { // add initial comment String commentId = commentsAPI.addComment(document.getNodeRef(), "This is a new comment").getId(); // update comment - RestCommentModel commentEntry = commentsAPI.updateComment(document.getNodeRef(), - commentId, - "This is the updated comment"); + RestCommentModel commentEntry = commentsAPI.updateComment(document.getNodeRef(), commentId, "This is the updated comment"); commentEntry.assertCommentContentIs("This is the updated comment"); } diff --git a/e2e-test/java/org/alfresco/rest/SamplePeopleTest.java b/e2e-test/java/org/alfresco/rest/SamplePeopleTest.java index 38a8b2980..6164d4ecb 100644 --- a/e2e-test/java/org/alfresco/rest/SamplePeopleTest.java +++ b/e2e-test/java/org/alfresco/rest/SamplePeopleTest.java @@ -3,12 +3,15 @@ package org.alfresco.rest; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; import org.apache.commons.lang3.RandomStringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +@Test(groups = { "rest-api", "people", "sanity" }) public class SamplePeopleTest extends RestTest { @Autowired @@ -29,21 +32,21 @@ public class SamplePeopleTest extends RestTest peopleAPI.useRestClient(restClient); } - @Test - public void adminIsAbleToRetrievePerson() throws Exception + @TestRail(section={"rest-api", "people"}, executionType= ExecutionType.SANITY) + public void adminShouldRetrievePerson() throws Exception { peopleAPI.getPerson(userModel.getUsername()) - .assertResponseIsNotEmpty(); - + .assertResponseIsNotEmpty(); + peopleAPI.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.OK.toString()); + .assertStatusCodeIs(HttpStatus.OK.toString()); } - @Test - public void adminIsAbleToRetrieveItself() throws Exception + @TestRail(section={"rest-api", "people"}, executionType= ExecutionType.SANITY) + public void adminShouldRetrieveItself() throws Exception { peopleAPI.getPerson(adminUser.getUsername()) - .assertPersonHasName(adminUser.getUsername()); + .assertPersonHasName(adminUser.getUsername()); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/SampleSitesTest.java b/e2e-test/java/org/alfresco/rest/SampleSitesTest.java index d7de96f03..b2643eebd 100644 --- a/e2e-test/java/org/alfresco/rest/SampleSitesTest.java +++ b/e2e-test/java/org/alfresco/rest/SampleSitesTest.java @@ -7,12 +7,15 @@ import org.alfresco.utility.data.DataUser; import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.social.alfresco.api.entities.Role; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +@Test(groups = { "rest-api", "people", "sanity" }) public class SampleSitesTest extends RestTest { @Autowired @@ -36,68 +39,69 @@ public class SampleSitesTest extends RestTest siteAPI.useRestClient(restClient); } - @Test - public void adminCanGetSiteDetails() throws JsonToModelConversionException, Exception + @TestRail(section={"rest-api", "sites"}, executionType= ExecutionType.SANITY) + public void adminShouldGetSiteDetails() throws JsonToModelConversionException, Exception { - siteAPI.getSite(siteModel.getId()).assertResponseIsNotEmpty(); + siteAPI.getSite(siteModel.getId()) + .assertResponseIsNotEmpty(); } - @Test - public void adminCanAccessSiteDetails() throws JsonToModelConversionException, Exception + @TestRail(section={"rest-api", "sites"}, executionType= ExecutionType.SANITY) + public void adminShouldGetSites() throws JsonToModelConversionException, Exception { siteAPI.getSite(siteModel.getId()); siteAPI.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.OK.toString()); + .assertStatusCodeIs(HttpStatus.OK.toString()); } - @Test - public void adminCanAccessSites() throws JsonToModelConversionException, Exception + @TestRail(section={"rest-api", "sites"}, executionType= ExecutionType.SANITY) + public void adminShouldAccessSites() throws JsonToModelConversionException, Exception { siteAPI.getSites() - .assertThatResponseIsNotEmpty(); + .assertThatResponseIsNotEmpty(); } - @Test - public void adminIsAbleToRetrieveSites() throws JsonToModelConversionException, Exception + @TestRail(section={"rest-api", "sites"}, executionType= ExecutionType.SANITY) + public void adminShouldRetrieveSites() throws JsonToModelConversionException, Exception { siteAPI.getSites(); siteAPI.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.OK.toString()); + .assertStatusCodeIs(HttpStatus.OK.toString()); } - @Test - public void adminIsAbleToAccessResponsePagination() throws JsonToModelConversionException, Exception + @TestRail(section={"rest-api", "sites"}, executionType= ExecutionType.SANITY) + public void adminShouldAccessResponsePagination() throws JsonToModelConversionException, Exception { - siteAPI.getSites().assertResponseHasPagination(); + siteAPI.getSites() + .assertResponseHasPagination(); } - @Test - public void adminIsAbleToAddNewSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception + @TestRail(section={"rest-api", "sites"}, executionType= ExecutionType.SANITY) + public void adminShouldAddNewSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception { UserModel newMember = dataUser.createRandomTestUser(); - SiteMember siteMember = new SiteMember(Role.SiteCollaborator.toString(), - newMember.getUsername()); - + SiteMember siteMember = new SiteMember(Role.SiteCollaborator.toString(), newMember.getUsername()); + siteAPI.addPerson(siteModel.getId(), siteMember); siteAPI.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.CREATED.toString()); + .assertStatusCodeIs(HttpStatus.CREATED.toString()); } - @Test - public void adminIsAbleToGetSiteFromSitesList() throws JsonToModelConversionException, Exception + @TestRail(section={"rest-api", "sites"}, executionType= ExecutionType.SANITY) + public void adminShouldGetSiteFromSitesList() throws JsonToModelConversionException, Exception { siteAPI.getAllSites() - .assertThatResponseHasSite(siteModel.getId()); + .assertThatResponseHasSite(siteModel.getId()); } - @Test - public void adminIsAbleToAccessSiteDetails() throws JsonToModelConversionException, Exception + @TestRail(section={"rest-api", "sites"}, executionType= ExecutionType.SANITY) + public void adminShouldAccessSiteDetails1() throws JsonToModelConversionException, Exception { siteAPI.getSite(siteModel.getId()) - .assertResponseIsNotEmpty() - .assertSiteHasDescription(siteModel.getDescription()) - .assertSiteHasTitle(siteModel.getTitle()) - .assertSiteHasVisibility(siteModel.getVisibility()); + .assertResponseIsNotEmpty() + .assertSiteHasDescription(siteModel.getDescription()) + .assertSiteHasTitle(siteModel.getTitle()) + .assertSiteHasVisibility(siteModel.getVisibility()); } } \ No newline at end of file From af79a68fb25a6db3b880b80a4bff29e33cea04f5 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Tue, 13 Sep 2016 17:03:44 +0300 Subject: [PATCH 0031/1491] TAS-429 Adding report config file --- e2e-test/resources/alfresco-report-config.xml | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 e2e-test/resources/alfresco-report-config.xml diff --git a/e2e-test/resources/alfresco-report-config.xml b/e2e-test/resources/alfresco-report-config.xml new file mode 100644 index 000000000..0b4669153 --- /dev/null +++ b/e2e-test/resources/alfresco-report-config.xml @@ -0,0 +1,54 @@ + + + + + + standard + + + + UTF-8 + + + + https + + + Test Automation System + + + + TAS Automation Report + + + + + + + + + yyyy-MM-dd + + + + HH:mm:ss + + + + + + + + + img {margin-left: auto; margin-right:auto; width: auto; } + ]]> + + + \ No newline at end of file From 429af545afe94bdca11cb8e6a953f4202274e3ff Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Wed, 14 Sep 2016 16:07:22 +0300 Subject: [PATCH 0032/1491] TAS-460 using shared-resources --- e2e-test/resources/TransformLog.xsl | 150 ------------------ e2e-test/resources/alfresco-report-config.xml | 54 ------- e2e-test/resources/default.properties | 3 +- e2e-test/resources/log4j.properties | 2 +- e2e-test/resources/logo.png | Bin 9190 -> 0 bytes 5 files changed, 3 insertions(+), 206 deletions(-) delete mode 100644 e2e-test/resources/TransformLog.xsl delete mode 100644 e2e-test/resources/alfresco-report-config.xml delete mode 100644 e2e-test/resources/logo.png diff --git a/e2e-test/resources/TransformLog.xsl b/e2e-test/resources/TransformLog.xsl deleted file mode 100644 index 78debb87a..000000000 --- a/e2e-test/resources/TransformLog.xsl +++ /dev/null @@ -1,150 +0,0 @@ - - - - - - Report -
- - - - - - -
-
-
-
-
- -
-
-
-
-
- - - - - - - - - - - - - - - - - - - -
SUITETOTALPASSEDFAILEDSKIPPEDRATE
- - - - - - - - - - - -
-
- -
- - -
- - - - - - - - - - - - - - - -
-

Tests

-
-

Status

-
-

Steps

-
- - - - - - - - - - - - -
- - -
-
-
- -
-
-
- - - - -
- -
\ No newline at end of file diff --git a/e2e-test/resources/alfresco-report-config.xml b/e2e-test/resources/alfresco-report-config.xml deleted file mode 100644 index 0b4669153..000000000 --- a/e2e-test/resources/alfresco-report-config.xml +++ /dev/null @@ -1,54 +0,0 @@ - - - - - - standard - - - - UTF-8 - - - - https - - - Test Automation System - - - - TAS Automation Report - - - - - - - - - yyyy-MM-dd - - - - HH:mm:ss - - - - - - - - - img {margin-left: auto; margin-right:auto; width: auto; } - ]]> - - - \ No newline at end of file diff --git a/e2e-test/resources/default.properties b/e2e-test/resources/default.properties index 321c98aca..ac9896f0d 100644 --- a/e2e-test/resources/default.properties +++ b/e2e-test/resources/default.properties @@ -32,4 +32,5 @@ testManagement.project=7 testManagement.testRun=Automation testManagement.justUploadTest=false -log.path=/Users/p3700299/Documents/AlfrescoLogs +# The location of the reports path +reports.path=./target/reports diff --git a/e2e-test/resources/log4j.properties b/e2e-test/resources/log4j.properties index 4a2fd1bd3..2f7205f81 100644 --- a/e2e-test/resources/log4j.properties +++ b/e2e-test/resources/log4j.properties @@ -10,7 +10,7 @@ log4j.appender.CONSOLE.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n # Rolling File Appender log4j.appender.R=org.apache.log4j.RollingFileAppender # Path and file name to store the log file -log4j.appender.R.File=./target/alfresco-tas.log +log4j.appender.R.File=./target/reports/alfresco-tas.log # log4j.appender.R.MaxFileSize=200KB # Number of backup files log4j.appender.R.MaxBackupIndex=2 diff --git a/e2e-test/resources/logo.png b/e2e-test/resources/logo.png deleted file mode 100644 index cf143364ac251c17ab8e9e167ef71292c46ccf82..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 9190 zcmVKLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o#eyhGvpiOA@W-aonk<7r1(?fC{oI5N*U!4 zfg=2N-7=cNnjjOr{yriy6mMFgG#l znCF=fnQv8CDz++o6_Lscl}eQ+l^ZHARH>?_s@|##Rr6KLRFA1%Q+=*RRWnoLsR`7U zt5vFIcfW3@?wFpwUVxrVZ>QdQz32KIeJ}k~{cZZE^+ya? z2D1z#2HOnI7(B%_ac?{wFUQ;QQA1tBKtrWrm0_3Rgps+?Jfqb{jYbcQX~taRB;#$y zZN{S}1|}gUOHJxc?wV3fxuz+mJ4`!F$IZ;mqRrNsHJd##*D~ju=bP7?-?v~|cv>vB zsJ6IeNwVZxrdjT`yl#bBIa#GxRa#xMMy;K#CDyyGyQdMSxlWT#tDe?p!?5wT$+oGt z8L;Kp2HUQ-ZMJ=3XJQv;x5ci*?vuTfeY$;({XGW_huIFR9a(?@3)XSs8O^N5RyOM=TTmp(3=8^+zpz2r)C z^>JO{deZfso3oq3?Wo(Y?l$ge?uXo;%ru`Vo>?<<(8I_>;8Eq#KMS9gFl*neeosSB zfoHYnBQIkwkyowPu(zdms`p{<7e4kra-ZWq<2*OsGTvEV%s0Td$hXT+!*8Bnh2KMe zBmZRodjHV?r+_5^X9J0WL4jKW`}lf%A-|44I@@LTvf1rHjG(ze6+w@Jt%Bvjts!X0 z?2xS?_ve_-kiKB_KiJlZ$9G`c^=E@oNG)mWWaNo-3TIW8)$Hg0Ub-~8?KhvJ>$ z3*&nim@mj(aCxE5!t{lw7O5^0EIO7zOo&c6l<+|iDySBWCGrz@C5{St!X3hAA}`T4 z(TLbXTq+(;@<=L8dXnssyft|w#WSTW<++3>sgS%(4NTpeI-VAqb|7ssJvzNHgOZVu zaYCvgO_R1~>SyL=cFU|~g|hy|Zi}}s9+d~lYqOB71z9Z$wnC=pR9Yz4DhIM>Wmjgu z&56o6maCpC&F##y%G;1PobR9i?GnNg;gYtchD%p19a!eQtZF&3JaKv33gZ<8D~47E ztUS1iwkmDaPpj=$m#%)jCVEY4fnLGNg2A-`YwHVD3gv};>)hAvT~AmqS>Lr``i7kw zJ{5_It`yrBmlc25DBO7E8;5VoznR>Ww5hAaxn$2~(q`%A-YuS64wkBy=9dm`4cXeX z4c}I@?e+FW+b@^RDBHV(wnMq2zdX3SWv9u`%{xC-q*U}&`cyXV(%rRT*Z6MH?i+i& z_B8C(+grT%{XWUQ+f@NoP1R=AW&26{v-dx)iK^-Nmiuj8txj!m?Z*Ss1N{dh4z}01 z)YTo*JycSU)+_5r4#yw9{+;i4Ee$peRgIj+;v;ZGdF1K$3E%e~4LaI(jC-u%2h$&R z9cLXcYC@Xwnns&bn)_Q~Te?roKGD|d-g^8;+aC{{G(1^(O7m37Y1-+6)01cN&y1aw zoqc{T`P^XJqPBbIW6s}d4{z_f5Om?vMgNQEJG?v2T=KYd^0M3I6IZxbny)%vZR&LD zJpPl@Psh8QyPB@KTx+@RdcC!KX7}kEo;S|j^u2lU7XQ}Oo;f|;z4Ll+_r>@1-xl3| zawq-H%e&ckC+@AhPrP6BKT#_XdT7&;F71j}Joy zkC~6lh7E@6o;W@^IpRNZ{ptLtL(gQ-CY~4mqW;US7Zxvm_|@yz&e53Bp_lTPlfP|z zrTyx_>lv@x#=^!PzR7qqF<$gm`|ZJZ+;<)Cqu&ot2z=00004XF*Lt006O$eEU(80000WV@Og>004R=004l4008;_004mL004C` z008P>0026e000+nl3&F}000>QNklqxAErr;48Vx4rr2qwZM0w!pkysE09pCTI-x6k4 z3G?d)y%(GY#(1zQB6#+@_ynX`fk9B4| zIK5pCQ~^8^r(*j;yn70p&wvO3z_O6qffB$3P;7ev%gjrqz5k>vAcN?^q-lqq<42Mt6&IJ3mzRs8*!`iRD0Ox9B_*Y0 zW#v|z?RSjX6?V{ULwXIsK%!k360iys7BB#&D_69Z;d~<|_@nRyVCxDp01EDi25B#m z<(@YN7%0UbF|q5wYHm6qo6WZAz4x=Sv)$ZX-+bfs(BR;{V;UP9pI`r?-o@p`zdrBh z=Lf*yaD4gY*Wd2^zO}X0ZnLj=@PTDZ|40b)JCCyx6Kc!=z_4&r!9@iqkVGgVU;y|l zaYAL(nJ_H?5PL3uz#U0pz=ge(bmc~+>#B}Ru+-jC=ibwc$6eTk=>w}Lz1TcTz+(nD-3JDGQ9ZPao!a-oLY!F6zW3&&5j1CbhEq*A$ zXT_)_fDSNq4d-yt0xu1q>ZxmC$~+7sKTBuNbppl!44?oa-~gy})7el;_wW0qsi|q| zr6UK}tgn$r+VSfLZ4fn>} zAnZ7YZCNO5fxuxz5aveUyBXM9gJ-NjK49<6gjNx4jvi5JgL*i=o?bxqEvGh+!C?IW z6~F)@YQB=84gonvvlj;J13!gKxa`_R(W`C8cGebphlSyT7*E?S~HKvcSUm^9UgW!^8dj{Bm-0TU+n<@-kkt6xY?))z;QH93lauD9Y(m zr`_D$RDz(_8(K^)-rn9`Mk9c>wzdwlxv8lsctEhLs{w%3YPH#Hm+I?fQ4&;wuaA#j zukV{qJIv<7!lL~Ae2dj4iVmZvF(@z~CML$i!@V!Ak}TKO)>gwu5N%Hmal_b&K-TfMvDHPj_u;mmWfboOU z3N!$07g=Wk4N!$i?<4zRd^ig$C~zL40!0C=P(`6^RhhB)IjQ6eZVVt?O-!5|#P``6 z@zROb?31n8gIyMeXs7pR1+G|AQ&Udv;ppfgfq?-4LPJA_4;#9BZ`z@pL-Xd&?Hy!P z5mdtN-FtEmA5|3D)Y?iF`sOQyrpI28_x0p1k|7skcKu`JsY+VYBu zFLvxGEiMyfNfaGafv2Z?{HXW^bLV+^83`dxO_wj!)K*kgS=!C>=FPbVW-WHSaRMM9 z1Plu$5}-g6!1Qpe8d537zK4Sk;e%ONWrMdK8Xlg(_H&DBe9B)^O1|Jm0qU#6O93dX z#z&jgQ$D|tEK|t9&vo~&3@zb^rtdo4vp21=sp*0Hm$|yS0$^Eo;`j-BQ`1vZGm?{& zwHi&YAQMF?JUrYkN}@x|JD%roIO2zopbR|SJa~bvD6jPJ^vFL~@XTMHYiw)`4h{|s z3UG6CJC>LC+8b{*HZ~3%7@ja@3<#QAnyad+-hcnU4&~%L^VE~h=Ar5GtQdVA> zG;QjP>C*xOf+SfiD=pjg)9$S7Y?I0K`m29)b8`bwUtj;$JDakzvpqdLhmRa)Fc=&* zd$Xw}=TPqPyyHujEM9WY-A>pfN!q=8?}s06X)(3L#l;2&1PGj9wcCmc3%6|j$DuGdmJ@S`z_?&tYCEqdQyCRI~iY=C*+AzEE{U-3=)-A5GnpF%~pv+R+Dpq+4k$u>Q z{Xk}>x3|~0v17YG96dTdG&H2Rq@=QH9MF z?c2X_;R37G`s!=1XCKT-o}RSmt~;Znqa31007X%<4<34d^9NhDZ67=+A|YWkr8Mi{ z!8hM}TdmVQ_Q=C2Daky?vn9j5sMU}Z02B%j;>JZw zLU036Xx^LE^tU<(1g0}MtQ6JOjJ}wiK69qDtbF$DnZCY0-5+W+n#q$UZT{ecw2X{_ z1H*eU5r$<5pwVb}o;P<`WJwkTf#Wy;o<=VKyLaz3dV0LP;ic&4D3)bqMfu_HAJ*43 zJoe}#ciyqkx%M?0HGr_tkSEtZK^T&nmT~0hvG|cAN=i!9f@<8jvE6_<&1m$z`|i8; zq^724>|eNW!Ja*P4(8;JA2;@e=buxl1OUzn0GOUMO_r7QFTM1|j<1FfA8NPT-{1US zf?D;&nn#nSP3@U5g8~Epw0e~w2p@gCb@S%UufFoKi_489bx!PqrDOwuXirQXi7+=1 z3IGxXOTZ8`T2O07q8}w7aPi9z8q_S-sALv|b*4j^HrgH8&E|J1%*Sgiotq!JymK`@X;rs7)=Hwo^_m4|FuEvZdM3f|_2%=EMd7n=9FUd|> zYxSyCv9U4E56_=JpMCI9Tx`tDnJGP8<}`y|zjFEVoI^Q3{`gZ+V1TRM0HC0tuy=d| z5rYOkzUEPHFYmUt_V0G?(!1zau6)o5*j3YG*~Em=5rZNMi;CLX+K!(%SzUc$&L8F^ zPfzMgK3SGsviP3Ntb->{pUFR0Ff=aqMwn^%t8{%h5aojnV-V?DbitZg-BDl`n*oL+ zARwZ|3~*~Vy6c)9Pq^|S4yDbN33@euWqB*yRZu7hpa3=sHw}FB@X$h0AS+i1mTK0c z*CdLIOOBs7F=R;8sQCC^UxkK*L=TBNc<4}G-tpw=NxcP;>%5hs$aYbTiH(UK64l+U zx0+fnUv8c^e{QeR*lnJk9s_N?M>iCf(g93xDc|(K2^_g{RTTCX7<1;g}c%Gj>Z_f3)1+7*)dE$hRwr(vi zE02qfxj|FGO$)?}3=|4N01*$5Z2$AH#rZSeZ@o&^RVdUvW(`5CaZ`Cmmbd2O z`L?eDb@49`JDIX;c##EK{;CXY&>-9k(f;5VXX1oRp=A)FNxr%xmQS5NQ(xCGBRSb* zYQ5at+&x_a!m`YeA<>7A9NCkaI&JEdzVXpZ)auf;8AXwU0s;+PnT=AKcj6?^bC(-0 zr>3P*fVtW!qA1$!4pEX@+uH~*Vf^?-ci;8R*WbSK+Uw!r;Uh;3_xAFNh!`{=Xn?_> zSE*E#(i107SuB>3BS*Nn=&tQtj*X6v2GG{lUQto$=i}?7#Mcw##*Itdy8WN0&YYe< zf9{RqEXoa$UMOq?rMNdnc_zN$*`v3AQgq57z|bQEB?VdyQU+sH=(bji{~M({3316@wvOlRGTFi_6p4HHk_zJvjyWqJ7IHBjBt(7aelo-;ncKrLE!hM zrsf{brAjZVLCozPEW?%*mlhNh#Ky+n(oQZRgbU308R5uLQ)GIqQn&rFFJ9LbPgIhIgRS(3fH zy;Uk9EHo5=i%yp^BYDi|QIw+K{Q1(dvckfm%BrewzyJQ=p`53mTI-^7aoFs#BzHgM z21+W+u~xgy#pOma5CKGos8R{+4aHK90Q17Id^o%`w4!~>r^RQz)K@t{qA+NX6oFM? z+s#)06GVC%ptJ$rt{C8k zd;B;0sz&u<9|sN`pp@ReV17zUO5f%044PACPXBfNOX>Ue&zm>bpw}zPEsFM6hVeY_ zY4i|9am4Tu2?=AacR^cQo1!R$5LuQPh9QJFyX^7f#*QC1)@-)a*Vljb^*2B7-t*DN zTc=H%qS0zkoH}*eZ7J7F+6S_-&z;SmIB~qMxA*zNBCFNfi-`8L+S-ezR#S9T)Qtsh z#_87A67lRPYijMMPRbxtND4#+gkXR>rVqwL1Gkzj{tsj(*K|O~LzLkz__^=~hJoFI zj3T^vc8SCt`#L3KVfZKjCI?zYw23e|&>=!Ed9DcFGR$=~L#~RF3pF))$4?r)yi!tT zxVyP|c)0idad&qc8XG%!(BPt?k|Rfs0ALt$(|SfJ?G>^kh7DsmCM|uREX&uEl%9U( z*@quplXv|1=U;r8m6hFdPZfYprwt1WefXi(lP6CsudHZoZS(W>J#*%4dwcseZ)mkz zckcZ0$Dek)y19)`7-Ke@Q`0kWUEZXmXJly98edqQMzTll}1W4GqdXJ>k`L|b~U)(V3r;p9up^y2e5D7 zF97~EE!fN3D=;81>)^qvs;X-aIC1jS(c{Ml1O<6}`+WG(mVbWwnJg=Phq<`8gocEg zEf!y2pJ7AeDl4nL`+jG4o6*xMDk@K&Iu$%1(8Jw5E;dG`R;8z>H#9U}^XbQrpFDE( zn75C2VnX7r?s>M$B^m)S{zweRqzH_UKzuNK+z_gB9jKlEMDBv>Hn{Me>4pGWCRERL zI+|tBVMAUOc3t}HlbShZX78ft39E2;dH-_LK}+&{FonqGhFor@RidV1O6 za8y-Y_|Nw@Yc!h0ix-E7g+)dUE-5K3C^*+QDBIiH^YaU|YE4{R?9zMx=kibO*9%vCKnToojRK{c+%qid z+F-JPXDvU}?f9vF2T#B=u*)zj2v=VtI7-XP3eKM&IyBDT&-bR71qApH8#**IEBkEz zxr8yJZ^9dyYni|<(! z9TiCk7S5Z${-q5s{q5Bi4=#@%Io!+3%USK(J32o4cw6q_!wCtae7wC42E(I|JoNTE z@4olm`{m{3iHV6mK0Y?9_3XKGscC72g(Y)l&73-El2ad9{=oe$&8B_(_cvW`N={0O zj2x`hYFpb{^N!{1O-pNNY`S;J;^gF{|G}Q8QHXNkg;vSIIQ5LK&1+xP&=1aRw#(44 zot&7Jp%rk^o*C#et_S3Bh-hesj{$0?lK?mrFa#Du`5_2~nUS2dH!bb!Z@vo;3$xj6tc7*P3Z>L+Hd`&$?$A*bxudR1DC647De)vxd=g)U8p6SU+HMKQ6zW!#z%P)t8gocHO z^1M)AUtfLULStj&(4ldUuUTU-7@QiFL2vl<^Uu@w?ce`PCdY9KmF+f%O08P{z|y<# zx{K@DhV?QUpIrO6kB?8*!R(K>ZWRQ9A&jiZqA2?M_}sf>$?RD(ueW`3ZOk;RPo!>o zwdH4?Twz^04g$OiO-H(;K$79Eg;9?)rtfBZuL{ti$p%dqzwfYJNl2szdy6yti6MM1 z%%UPAq9P-vOqy^j8;OLF#KeS$R`hN+|{pj);gD6ftPfl_kh9%a-07Gi1mwnVA(8 z6=h`=pj4w(M@A05Z`r+LMvZdH|IUdeB#e%Y9dh#2>HPe27K>R>2?m4f(73q15|q(s zT)pbS`Sa%-J9fOKrMcZ~cGc?x0|Up59&Iq_Z*i0TsvJ^dJNQod1d9wOY!qu`vD)xw@@tHorpS#1Cn z1eL*{*Jw1?E2xqrvn)dhaX1`;a3h^pQ51$@oWK9|b5{TY)MIb=+W??jIJU}?mDYHv z0~87hIAnx+BElP#!lBST^{bXfFTZo(*cL~ZXvTw(9)Ky(65Jj5ZC}8g!s!2KtDX=r z48yXl6X~9B%P>sOKb_y+^ybd90yhB6sV@3>dj|&(2o4VR^Yhi|bT{xa$92BZjREUk zUjN!bBj)NpoEhcz_>zEUU0B!@h!kxSnjA%Ugsqe*6pBIK7!?9AkQE3FPPUevXnpmS z#P|LfF~K6DLxe#KkwT=fE3nD%Q(^gl?E|%Q&~N`fy9U3KspF#U@PW%uU$o^mJLm-C zf)ToR799w7)g#mcEOSMtr+`8+$v7q6b?y14i#y6*3Gyl9Sx`X7ss_8vndJF5SAHNt z|Nnsg%9wSfwN{7HZW2og*g(yM%;rCTQM-}v<9-T=3j8&g?D-#K-Jfp}%dK(~OLQK> zAQpna==)v#zlT}xQml0RSidl%F^vKOa}_7FD&L9$`Z4Rbe~ Date: Fri, 16 Sep 2016 12:19:49 +0300 Subject: [PATCH 0033/1491] adde description for tests --- .../org/alfresco/rest/SampleCommentsTest.java | 9 ++++--- .../org/alfresco/rest/SamplePeopleTest.java | 6 +++-- .../org/alfresco/rest/SampleSitesTest.java | 24 ++++++++++++------- 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/SampleCommentsTest.java b/e2e-test/java/org/alfresco/rest/SampleCommentsTest.java index e22fc7ec3..3bb334cdf 100644 --- a/e2e-test/java/org/alfresco/rest/SampleCommentsTest.java +++ b/e2e-test/java/org/alfresco/rest/SampleCommentsTest.java @@ -35,7 +35,8 @@ public class SampleCommentsTest extends RestTest document = dataContent.usingResource("Shared").usingUser(userModel).createContent(DocumentType.TEXT_PLAIN); } - @TestRail(section={"rest-api", "comments"}, executionType= ExecutionType.SANITY) + @TestRail(section={"rest-api", "comments"}, executionType= ExecutionType.SANITY, + description= "Verify admin user adds comments with Rest API") public void admiShouldAddComment() throws JsonToModelConversionException, Exception { commentsAPI.addComment(document.getNodeRef(), "This is a new comment"); @@ -43,7 +44,8 @@ public class SampleCommentsTest extends RestTest .assertStatusCodeIs(HttpStatus.CREATED.toString()); } - @TestRail(section={"rest-api", "comments"}, executionType= ExecutionType.SANITY) + @TestRail(section={"rest-api", "comments"}, executionType= ExecutionType.SANITY, + description= "Verify admin user gets comments with Rest API") public void admiShouldRetrieveComments() throws JsonToModelConversionException { commentsAPI.getNodeComments(document.getNodeRef()); @@ -51,7 +53,8 @@ public class SampleCommentsTest extends RestTest .assertStatusCodeIs(HttpStatus.OK.toString()); } - @TestRail(section={"rest-api", "comments"}, executionType= ExecutionType.SANITY) + @TestRail(section={"rest-api", "comments"}, executionType= ExecutionType.SANITY, + description= "Verify admin user updates comments with Rest API") public void adminShouldUpdateComment() throws JsonToModelConversionException, Exception { // add initial comment diff --git a/e2e-test/java/org/alfresco/rest/SamplePeopleTest.java b/e2e-test/java/org/alfresco/rest/SamplePeopleTest.java index 6164d4ecb..265267d4e 100644 --- a/e2e-test/java/org/alfresco/rest/SamplePeopleTest.java +++ b/e2e-test/java/org/alfresco/rest/SamplePeopleTest.java @@ -32,7 +32,8 @@ public class SamplePeopleTest extends RestTest peopleAPI.useRestClient(restClient); } - @TestRail(section={"rest-api", "people"}, executionType= ExecutionType.SANITY) + @TestRail(section={"rest-api", "people"}, executionType= ExecutionType.SANITY, + description = "Verify admin user gets person with Rest API and response is not empty") public void adminShouldRetrievePerson() throws Exception { peopleAPI.getPerson(userModel.getUsername()) @@ -42,7 +43,8 @@ public class SamplePeopleTest extends RestTest .assertStatusCodeIs(HttpStatus.OK.toString()); } - @TestRail(section={"rest-api", "people"}, executionType= ExecutionType.SANITY) + @TestRail(section={"rest-api", "people"}, executionType= ExecutionType.SANITY, + description = "Admin user gets own person information with Rest Api and assert that name is correct") public void adminShouldRetrieveItself() throws Exception { peopleAPI.getPerson(adminUser.getUsername()) diff --git a/e2e-test/java/org/alfresco/rest/SampleSitesTest.java b/e2e-test/java/org/alfresco/rest/SampleSitesTest.java index b2643eebd..834a5afea 100644 --- a/e2e-test/java/org/alfresco/rest/SampleSitesTest.java +++ b/e2e-test/java/org/alfresco/rest/SampleSitesTest.java @@ -39,14 +39,16 @@ public class SampleSitesTest extends RestTest siteAPI.useRestClient(restClient); } - @TestRail(section={"rest-api", "sites"}, executionType= ExecutionType.SANITY) + @TestRail(section={"rest-api", "sites"}, executionType= ExecutionType.SANITY, + description = "Verify admin user gets site details with Rest API and response is not empty") public void adminShouldGetSiteDetails() throws JsonToModelConversionException, Exception { siteAPI.getSite(siteModel.getId()) .assertResponseIsNotEmpty(); } - @TestRail(section={"rest-api", "sites"}, executionType= ExecutionType.SANITY) + @TestRail(section={"rest-api", "sites"}, executionType= ExecutionType.SANITY, + description = "Verify admin user gets site information and gets status code OK (200)") public void adminShouldGetSites() throws JsonToModelConversionException, Exception { siteAPI.getSite(siteModel.getId()); @@ -54,14 +56,16 @@ public class SampleSitesTest extends RestTest .assertStatusCodeIs(HttpStatus.OK.toString()); } - @TestRail(section={"rest-api", "sites"}, executionType= ExecutionType.SANITY) + @TestRail(section={"rest-api", "sites"}, executionType= ExecutionType.SANITY, + description = "Verify admin user gets sites with Rest API and the response is not empty") public void adminShouldAccessSites() throws JsonToModelConversionException, Exception { siteAPI.getSites() .assertThatResponseIsNotEmpty(); } - @TestRail(section={"rest-api", "sites"}, executionType= ExecutionType.SANITY) + @TestRail(section={"rest-api", "sites"}, executionType= ExecutionType.SANITY, + description = "Verify admin user gets sites with Rest API and status code is 200") public void adminShouldRetrieveSites() throws JsonToModelConversionException, Exception { siteAPI.getSites(); @@ -69,14 +73,16 @@ public class SampleSitesTest extends RestTest .assertStatusCodeIs(HttpStatus.OK.toString()); } - @TestRail(section={"rest-api", "sites"}, executionType= ExecutionType.SANITY) + @TestRail(section={"rest-api", "sites"}, executionType= ExecutionType.SANITY, + description = "Verify admin user gets sites with Rest API and status code is 200") public void adminShouldAccessResponsePagination() throws JsonToModelConversionException, Exception { siteAPI.getSites() .assertResponseHasPagination(); } - @TestRail(section={"rest-api", "sites"}, executionType= ExecutionType.SANITY) + @TestRail(section={"rest-api", "sites"}, executionType= ExecutionType.SANITY, + description = "Verify admin user adds site member with Rest API and status code is 201") public void adminShouldAddNewSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception { UserModel newMember = dataUser.createRandomTestUser(); @@ -87,14 +93,16 @@ public class SampleSitesTest extends RestTest .assertStatusCodeIs(HttpStatus.CREATED.toString()); } - @TestRail(section={"rest-api", "sites"}, executionType= ExecutionType.SANITY) + @TestRail(section={"rest-api", "sites"}, executionType= ExecutionType.SANITY, + description = "Verify that site exists from get all sites request") public void adminShouldGetSiteFromSitesList() throws JsonToModelConversionException, Exception { siteAPI.getAllSites() .assertThatResponseHasSite(siteModel.getId()); } - @TestRail(section={"rest-api", "sites"}, executionType= ExecutionType.SANITY) + @TestRail(section={"rest-api", "sites"}, executionType= ExecutionType.SANITY, + description = "Verify site details: response not empty, description, title, visibility") public void adminShouldAccessSiteDetails1() throws JsonToModelConversionException, Exception { siteAPI.getSite(siteModel.getId()) From 06818b44153a7a7e55f1a58e26f01a1123fad641 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Fri, 16 Sep 2016 14:36:34 +0300 Subject: [PATCH 0034/1491] up default --- e2e-test/resources/default.properties | 1 - 1 file changed, 1 deletion(-) diff --git a/e2e-test/resources/default.properties b/e2e-test/resources/default.properties index ac9896f0d..451c05025 100644 --- a/e2e-test/resources/default.properties +++ b/e2e-test/resources/default.properties @@ -30,7 +30,6 @@ testManagement.username=tas.alfresco@gmail.com testManagement.apiKey=EYpY7.fV0AoMGWbmyuVC-k5u.nzwHy6a.QWzJq8.S testManagement.project=7 testManagement.testRun=Automation -testManagement.justUploadTest=false # The location of the reports path reports.path=./target/reports From 18bf405462b9b93864d99401d8f9a09ddc58674d Mon Sep 17 00:00:00 2001 From: cnechifor Date: Fri, 16 Sep 2016 18:50:15 +0300 Subject: [PATCH 0035/1491] added read.md --- e2e-test/java/org/alfresco/rest/SampleCommentsTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/SampleCommentsTest.java b/e2e-test/java/org/alfresco/rest/SampleCommentsTest.java index 3bb334cdf..a77017c92 100644 --- a/e2e-test/java/org/alfresco/rest/SampleCommentsTest.java +++ b/e2e-test/java/org/alfresco/rest/SampleCommentsTest.java @@ -36,7 +36,7 @@ public class SampleCommentsTest extends RestTest } @TestRail(section={"rest-api", "comments"}, executionType= ExecutionType.SANITY, - description= "Verify admin user adds comments with Rest API") + description= "Verify admin user adds comments with Rest API and status code is 200") public void admiShouldAddComment() throws JsonToModelConversionException, Exception { commentsAPI.addComment(document.getNodeRef(), "This is a new comment"); @@ -45,7 +45,7 @@ public class SampleCommentsTest extends RestTest } @TestRail(section={"rest-api", "comments"}, executionType= ExecutionType.SANITY, - description= "Verify admin user gets comments with Rest API") + description= "Verify admin user gets comments with Rest API and status code is 200") public void admiShouldRetrieveComments() throws JsonToModelConversionException { commentsAPI.getNodeComments(document.getNodeRef()); From e002a901ebf72a629ce2f0fbde63d8289e7d30e5 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Sun, 18 Sep 2016 23:03:14 +0300 Subject: [PATCH 0036/1491] remove steps --- e2e-test/java/org/alfresco/rest/SampleSitesTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/SampleSitesTest.java b/e2e-test/java/org/alfresco/rest/SampleSitesTest.java index 834a5afea..51e49d1b8 100644 --- a/e2e-test/java/org/alfresco/rest/SampleSitesTest.java +++ b/e2e-test/java/org/alfresco/rest/SampleSitesTest.java @@ -103,7 +103,7 @@ public class SampleSitesTest extends RestTest @TestRail(section={"rest-api", "sites"}, executionType= ExecutionType.SANITY, description = "Verify site details: response not empty, description, title, visibility") - public void adminShouldAccessSiteDetails1() throws JsonToModelConversionException, Exception + public void adminShouldAccessSiteDetails() throws JsonToModelConversionException, Exception { siteAPI.getSite(siteModel.getId()) .assertResponseIsNotEmpty() From dc253cd9e1abe82ad58519226457efab216b21f5 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Tue, 20 Sep 2016 11:52:23 +0300 Subject: [PATCH 0037/1491] Fix pretty print response when this is empty, change suite file name --- e2e-test/resources/{smoke-rest.xml => sanity-rest.xml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename e2e-test/resources/{smoke-rest.xml => sanity-rest.xml} (100%) diff --git a/e2e-test/resources/smoke-rest.xml b/e2e-test/resources/sanity-rest.xml similarity index 100% rename from e2e-test/resources/smoke-rest.xml rename to e2e-test/resources/sanity-rest.xml From 23aa877f1a0a01fdabd41445046cb925df847966 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Thu, 22 Sep 2016 16:01:49 +0300 Subject: [PATCH 0038/1491] added jolokia properties --- e2e-test/java/org/alfresco/rest/RestTest.java | 2 +- e2e-test/resources/default.properties | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/RestTest.java b/e2e-test/java/org/alfresco/rest/RestTest.java index f0ca294b9..1b90121b8 100644 --- a/e2e-test/java/org/alfresco/rest/RestTest.java +++ b/e2e-test/java/org/alfresco/rest/RestTest.java @@ -2,11 +2,11 @@ package org.alfresco.rest; import org.alfresco.rest.core.RestProperties; import org.alfresco.rest.core.RestWrapper; -import org.alfresco.utility.ServerHealth; import org.alfresco.utility.TasProperties; import org.alfresco.utility.data.DataContent; import org.alfresco.utility.data.DataSite; import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.network.ServerHealth; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; diff --git a/e2e-test/resources/default.properties b/e2e-test/resources/default.properties index ac9896f0d..213526039 100644 --- a/e2e-test/resources/default.properties +++ b/e2e-test/resources/default.properties @@ -1,7 +1,7 @@ # dataprep related alfresco.scheme=http -alfresco.server=172.29.100.215 -alfresco.port=9090 +alfresco.server=172.29.100.206 +alfresco.port=8070 # credentials admin.user=admin @@ -34,3 +34,7 @@ testManagement.justUploadTest=false # The location of the reports path reports.path=./target/reports + +# in containers we cannot access directly JMX, so we will use http://jolokia.org agent +# disabling this we will use direct JMX calls to server +jmx.useJolokiaAgent=true From 5146c2f3fc5e475cd02eab3ce6f1486817d53284 Mon Sep 17 00:00:00 2001 From: bogdanbocancea Date: Fri, 23 Sep 2016 10:23:16 +0300 Subject: [PATCH 0039/1491] update test with the new ContentModel --- e2e-test/java/org/alfresco/rest/RestDemoTest.java | 3 ++- e2e-test/java/org/alfresco/rest/SampleCommentsTest.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/RestDemoTest.java b/e2e-test/java/org/alfresco/rest/RestDemoTest.java index 060340417..9b867955f 100644 --- a/e2e-test/java/org/alfresco/rest/RestDemoTest.java +++ b/e2e-test/java/org/alfresco/rest/RestDemoTest.java @@ -6,6 +6,7 @@ import org.alfresco.rest.model.RestCommentModel; import org.alfresco.rest.model.SiteMember; import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; import org.springframework.beans.factory.annotation.Autowired; @@ -67,7 +68,7 @@ public class RestDemoTest extends RestTest @Test public void adminCanPostAndUpdateComments() throws Exception { - FileModel fileModel = dataContent.usingResource("Shared") + FileModel fileModel = dataContent.usingResource(new FolderModel("Shared")) .usingUser(userModel) .createContent(DocumentType.TEXT_PLAIN); // add new comment diff --git a/e2e-test/java/org/alfresco/rest/SampleCommentsTest.java b/e2e-test/java/org/alfresco/rest/SampleCommentsTest.java index a77017c92..592e9a8e8 100644 --- a/e2e-test/java/org/alfresco/rest/SampleCommentsTest.java +++ b/e2e-test/java/org/alfresco/rest/SampleCommentsTest.java @@ -5,6 +5,7 @@ import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestCommentModel; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; @@ -32,7 +33,7 @@ public class SampleCommentsTest extends RestTest restClient.authenticateUser(userModel); commentsAPI.useRestClient(restClient); - document = dataContent.usingResource("Shared").usingUser(userModel).createContent(DocumentType.TEXT_PLAIN); + document = dataContent.usingResource(new FolderModel("Shared")).usingUser(userModel).createContent(DocumentType.TEXT_PLAIN); } @TestRail(section={"rest-api", "comments"}, executionType= ExecutionType.SANITY, From bbd2b7ff73d075127d6335b0bc936696a8a8315a Mon Sep 17 00:00:00 2001 From: cnechifor Date: Mon, 26 Sep 2016 12:12:32 +0300 Subject: [PATCH 0040/1491] organised the packages --- e2e-test/java/org/alfresco/rest/RestTest.java | 6 +++--- .../java/org/alfresco/rest/{ => demo}/RestDemoTest.java | 7 +++++-- .../org/alfresco/rest/{ => demo}/SampleCommentsTest.java | 4 +++- .../org/alfresco/rest/{ => demo}/SamplePeopleTest.java | 4 +++- .../java/org/alfresco/rest/{ => demo}/SampleSitesTest.java | 6 ++++-- e2e-test/resources/sanity-rest.xml | 6 +++--- 6 files changed, 21 insertions(+), 12 deletions(-) rename e2e-test/java/org/alfresco/rest/{ => demo}/RestDemoTest.java (96%) rename e2e-test/java/org/alfresco/rest/{ => demo}/SampleCommentsTest.java (95%) rename e2e-test/java/org/alfresco/rest/{ => demo}/SamplePeopleTest.java (94%) rename e2e-test/java/org/alfresco/rest/{ => demo}/SampleSitesTest.java (96%) diff --git a/e2e-test/java/org/alfresco/rest/RestTest.java b/e2e-test/java/org/alfresco/rest/RestTest.java index 1b90121b8..b50cad0ea 100644 --- a/e2e-test/java/org/alfresco/rest/RestTest.java +++ b/e2e-test/java/org/alfresco/rest/RestTest.java @@ -30,13 +30,13 @@ public abstract class RestTest extends AbstractTestNGSpringContextTests protected RestWrapper restClient; @Autowired - DataUser dataUser; + protected DataUser dataUser; @Autowired - DataSite dataSite; + protected DataSite dataSite; @Autowired - DataContent dataContent; + protected DataContent dataContent; @BeforeClass(alwaysRun = true) public void setupRestTest() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/RestDemoTest.java b/e2e-test/java/org/alfresco/rest/demo/RestDemoTest.java similarity index 96% rename from e2e-test/java/org/alfresco/rest/RestDemoTest.java rename to e2e-test/java/org/alfresco/rest/demo/RestDemoTest.java index 9b867955f..6a3fea0e6 100644 --- a/e2e-test/java/org/alfresco/rest/RestDemoTest.java +++ b/e2e-test/java/org/alfresco/rest/demo/RestDemoTest.java @@ -1,9 +1,12 @@ -package org.alfresco.rest; +package org.alfresco.rest.demo; import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.body.SiteMember; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestCommentModel; -import org.alfresco.rest.model.SiteMember; +import org.alfresco.rest.requests.RestCommentsApi; +import org.alfresco.rest.requests.RestSitesApi; import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FolderModel; diff --git a/e2e-test/java/org/alfresco/rest/SampleCommentsTest.java b/e2e-test/java/org/alfresco/rest/demo/SampleCommentsTest.java similarity index 95% rename from e2e-test/java/org/alfresco/rest/SampleCommentsTest.java rename to e2e-test/java/org/alfresco/rest/demo/SampleCommentsTest.java index 592e9a8e8..9c596472b 100644 --- a/e2e-test/java/org/alfresco/rest/SampleCommentsTest.java +++ b/e2e-test/java/org/alfresco/rest/demo/SampleCommentsTest.java @@ -1,8 +1,10 @@ -package org.alfresco.rest; +package org.alfresco.rest.demo; import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestCommentModel; +import org.alfresco.rest.requests.RestCommentsApi; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FolderModel; diff --git a/e2e-test/java/org/alfresco/rest/SamplePeopleTest.java b/e2e-test/java/org/alfresco/rest/demo/SamplePeopleTest.java similarity index 94% rename from e2e-test/java/org/alfresco/rest/SamplePeopleTest.java rename to e2e-test/java/org/alfresco/rest/demo/SamplePeopleTest.java index 265267d4e..a5718b2dc 100644 --- a/e2e-test/java/org/alfresco/rest/SamplePeopleTest.java +++ b/e2e-test/java/org/alfresco/rest/demo/SamplePeopleTest.java @@ -1,5 +1,7 @@ -package org.alfresco.rest; +package org.alfresco.rest.demo; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.requests.RestPeopleApi; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.UserModel; diff --git a/e2e-test/java/org/alfresco/rest/SampleSitesTest.java b/e2e-test/java/org/alfresco/rest/demo/SampleSitesTest.java similarity index 96% rename from e2e-test/java/org/alfresco/rest/SampleSitesTest.java rename to e2e-test/java/org/alfresco/rest/demo/SampleSitesTest.java index 51e49d1b8..53bcfad31 100644 --- a/e2e-test/java/org/alfresco/rest/SampleSitesTest.java +++ b/e2e-test/java/org/alfresco/rest/demo/SampleSitesTest.java @@ -1,7 +1,9 @@ -package org.alfresco.rest; +package org.alfresco.rest.demo; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.body.SiteMember; import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.SiteMember; +import org.alfresco.rest.requests.RestSitesApi; import org.alfresco.utility.data.DataSite; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.exception.DataPreparationException; diff --git a/e2e-test/resources/sanity-rest.xml b/e2e-test/resources/sanity-rest.xml index f67c6a619..385353b4f 100644 --- a/e2e-test/resources/sanity-rest.xml +++ b/e2e-test/resources/sanity-rest.xml @@ -8,9 +8,9 @@ - - - + + + From 186f96cf7e6a3a84274b8453e115edd7181c9f3a Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Mon, 26 Sep 2016 14:06:13 +0300 Subject: [PATCH 0041/1491] Creating input data for tests --- .../java/org/alfresco/rest/demo/SampleCommentsTest.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/demo/SampleCommentsTest.java b/e2e-test/java/org/alfresco/rest/demo/SampleCommentsTest.java index 9c596472b..1551c0fb9 100644 --- a/e2e-test/java/org/alfresco/rest/demo/SampleCommentsTest.java +++ b/e2e-test/java/org/alfresco/rest/demo/SampleCommentsTest.java @@ -8,6 +8,7 @@ import org.alfresco.rest.requests.RestCommentsApi; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; @@ -26,16 +27,20 @@ public class SampleCommentsTest extends RestTest RestCommentsApi commentsAPI; private UserModel userModel; + private FolderModel folderModel; + private SiteModel siteModel; private FileModel document; @BeforeClass public void initTest() throws Exception { userModel = dataUser.getAdminUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); restClient.authenticateUser(userModel); commentsAPI.useRestClient(restClient); - document = dataContent.usingResource(new FolderModel("Shared")).usingUser(userModel).createContent(DocumentType.TEXT_PLAIN); + document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); } @TestRail(section={"rest-api", "comments"}, executionType= ExecutionType.SANITY, From 093d38d53b2b158826a1b0d9a3e628b30cb40dd0 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Tue, 27 Sep 2016 15:14:11 +0300 Subject: [PATCH 0042/1491] Add support for site membership request --- .../AddSiteMembershipRequestSanityTest.java | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/sites/AddSiteMembershipRequestSanityTest.java diff --git a/e2e-test/java/org/alfresco/rest/sites/AddSiteMembershipRequestSanityTest.java b/e2e-test/java/org/alfresco/rest/sites/AddSiteMembershipRequestSanityTest.java new file mode 100644 index 000000000..36183ed72 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/sites/AddSiteMembershipRequestSanityTest.java @@ -0,0 +1,64 @@ +package org.alfresco.rest.sites; + +import java.util.Arrays; +import java.util.HashMap; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.body.SiteMembership; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.requests.RestSitesApi; +import org.alfresco.utility.data.DataSite; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.data.UserRole; +import org.alfresco.utility.exception.DataPreparationException; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +@Test(groups = { "rest-api", "sites", "sanity" }) +public class AddSiteMembershipRequestSanityTest extends RestTest +{ + @Autowired + RestSitesApi siteAPI; + + @Autowired + DataUser dataUser; + + @Autowired + DataSite dataSite; + + private SiteModel siteModel; + + private HashMap usersWithRoles; + + private UserModel adminUser; + + @BeforeClass + public void initTest() throws DataPreparationException + { + adminUser = dataUser.getAdminUser(); + siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); + usersWithRoles = dataUser.addUsersToSiteWithRoles(siteModel, + Arrays.asList(UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor)); + + siteAPI.useRestClient(restClient); + } + + @TestRail(section = { "rest-api", + "sites" }, executionType = ExecutionType.SANITY, description = "Verify site manager is able to create new site membership request") + @Test(enabled = false, description = "Fails due to MNT-16557") + public void siteManagerCanCreateSiteMembershipRequest() throws JsonToModelConversionException, Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + SiteMembership siteMembership = new SiteMembership("Please accept me", siteModel.getId(), "New request"); + + restClient.authenticateUser(usersWithRoles.get(UserRole.SiteManager)); + siteAPI.addSiteMembershipRequest(newMember.getUsername(), siteMembership); + siteAPI.getSite(siteModel.getId()).assertResponseIsNotEmpty(); + } + +} \ No newline at end of file From 7db30c75da9dd990e24b9676a274e6a7446d1a34 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Tue, 27 Sep 2016 16:02:44 +0300 Subject: [PATCH 0043/1491] fix typo --- .../rest/sites/AddSiteMembershipRequestSanityTest.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/sites/AddSiteMembershipRequestSanityTest.java b/e2e-test/java/org/alfresco/rest/sites/AddSiteMembershipRequestSanityTest.java index 36183ed72..fd01119d8 100644 --- a/e2e-test/java/org/alfresco/rest/sites/AddSiteMembershipRequestSanityTest.java +++ b/e2e-test/java/org/alfresco/rest/sites/AddSiteMembershipRequestSanityTest.java @@ -32,7 +32,7 @@ public class AddSiteMembershipRequestSanityTest extends RestTest DataSite dataSite; private SiteModel siteModel; - + private HashMap usersWithRoles; private UserModel adminUser; @@ -42,9 +42,9 @@ public class AddSiteMembershipRequestSanityTest extends RestTest { adminUser = dataUser.getAdminUser(); siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); - usersWithRoles = dataUser.addUsersToSiteWithRoles(siteModel, + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, Arrays.asList(UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor)); - + siteAPI.useRestClient(restClient); } @@ -55,7 +55,7 @@ public class AddSiteMembershipRequestSanityTest extends RestTest { UserModel newMember = dataUser.createRandomTestUser(); SiteMembership siteMembership = new SiteMembership("Please accept me", siteModel.getId(), "New request"); - + restClient.authenticateUser(usersWithRoles.get(UserRole.SiteManager)); siteAPI.addSiteMembershipRequest(newMember.getUsername(), siteMembership); siteAPI.getSite(siteModel.getId()).assertResponseIsNotEmpty(); From 8e49b9108b1902d49661e3f53108579fc7324568 Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Tue, 27 Sep 2016 16:14:23 +0300 Subject: [PATCH 0044/1491] TAS-848 getSites with Manager role --- .../java/org/alfresco/rest/GetSitesTests.java | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/GetSitesTests.java diff --git a/e2e-test/java/org/alfresco/rest/GetSitesTests.java b/e2e-test/java/org/alfresco/rest/GetSitesTests.java new file mode 100644 index 000000000..1c95115f5 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/GetSitesTests.java @@ -0,0 +1,59 @@ +package org.alfresco.rest; + +import java.util.Arrays; +import java.util.HashMap; + +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.requests.RestSitesApi; +import org.alfresco.utility.data.DataSite; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.data.UserRole; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * @author iulia.cojocea + */ +@Test(groups = { "rest-api", "comments", "sanity" }) +public class GetSitesTests extends RestTest +{ + @Autowired + RestSitesApi siteAPI; + + @Autowired + DataUser dataUser; + + @Autowired + DataSite dataSite; + + private UserModel adminUserModel; + private HashMap usersWithRoles; + private SiteModel siteModel; + + @BeforeClass + public void initTest() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + restClient.authenticateUser(adminUserModel); + siteAPI.useRestClient(restClient); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, + Arrays.asList(UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor)); + + } + + @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role gets sites information and gets status code OK (200)") + public void getSitesWithManagerRole() throws JsonToModelConversionException, Exception + { + + restClient.authenticateUser(usersWithRoles.get(UserRole.SiteManager)); + siteAPI.getAllSites(); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + } +} From 2c640e1e703d6b3f1ac3a0872bb29c6c1e6d1e06 Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Tue, 27 Sep 2016 16:16:31 +0300 Subject: [PATCH 0045/1491] TAS-849 getSite with Collaborator role --- e2e-test/java/org/alfresco/rest/GetSitesTests.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/GetSitesTests.java b/e2e-test/java/org/alfresco/rest/GetSitesTests.java index 1c95115f5..6fbaf5098 100644 --- a/e2e-test/java/org/alfresco/rest/GetSitesTests.java +++ b/e2e-test/java/org/alfresco/rest/GetSitesTests.java @@ -56,4 +56,13 @@ public class GetSitesTests extends RestTest siteAPI.getAllSites(); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); } + + @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify user with Collaborator role gets sites information and gets status code OK (200)") + public void getSitesWithCollaboratorRole() throws JsonToModelConversionException, Exception + { + + restClient.authenticateUser(usersWithRoles.get(UserRole.SiteCollaborator)); + siteAPI.getAllSites(); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + } } From 06822847703ffd8ca352402ca3e2b671a777d073 Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Tue, 27 Sep 2016 16:17:27 +0300 Subject: [PATCH 0046/1491] TAS-858 getSites with Contributor role --- e2e-test/java/org/alfresco/rest/GetSitesTests.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/GetSitesTests.java b/e2e-test/java/org/alfresco/rest/GetSitesTests.java index 6fbaf5098..3415133c1 100644 --- a/e2e-test/java/org/alfresco/rest/GetSitesTests.java +++ b/e2e-test/java/org/alfresco/rest/GetSitesTests.java @@ -65,4 +65,13 @@ public class GetSitesTests extends RestTest siteAPI.getAllSites(); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); } + + @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify user with Contributor role gets sites information and gets status code OK (200)") + public void getSitesWithContributorRole() throws JsonToModelConversionException, Exception + { + + restClient.authenticateUser(usersWithRoles.get(UserRole.SiteContributor)); + siteAPI.getAllSites(); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + } } From c74603a8193253f4da220c522b1da6a95d5bfa38 Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Tue, 27 Sep 2016 16:19:36 +0300 Subject: [PATCH 0047/1491] TAS-859 getSites with Consumer role --- e2e-test/java/org/alfresco/rest/GetSitesTests.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/GetSitesTests.java b/e2e-test/java/org/alfresco/rest/GetSitesTests.java index 3415133c1..2f24eb52f 100644 --- a/e2e-test/java/org/alfresco/rest/GetSitesTests.java +++ b/e2e-test/java/org/alfresco/rest/GetSitesTests.java @@ -74,4 +74,13 @@ public class GetSitesTests extends RestTest siteAPI.getAllSites(); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); } + + @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role gets sites information and gets status code OK (200)") + public void getSitesWithConsumerRole() throws JsonToModelConversionException, Exception + { + + restClient.authenticateUser(usersWithRoles.get(UserRole.SiteConsumer)); + siteAPI.getAllSites(); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + } } From 7441b807cb0c8adebcc1d95c28082afe4d9c686a Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Tue, 27 Sep 2016 16:20:23 +0300 Subject: [PATCH 0048/1491] TAS-860 getSites with admin user --- e2e-test/java/org/alfresco/rest/GetSitesTests.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/GetSitesTests.java b/e2e-test/java/org/alfresco/rest/GetSitesTests.java index 2f24eb52f..d2d3020e7 100644 --- a/e2e-test/java/org/alfresco/rest/GetSitesTests.java +++ b/e2e-test/java/org/alfresco/rest/GetSitesTests.java @@ -83,4 +83,12 @@ public class GetSitesTests extends RestTest siteAPI.getAllSites(); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); } + + @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify user with Admin user gets sites information and gets status code OK (200)") + public void getSitesWithAdminUser() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel); + siteAPI.getAllSites(); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + } } From 67b46759a22a1e01e3d1eb54c466eb1f866d7f0f Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Tue, 27 Sep 2016 16:29:54 +0300 Subject: [PATCH 0049/1491] TAS-856 getComment with admin --- .../org/alfresco/rest/GetCommentsTest.java | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/GetCommentsTest.java diff --git a/e2e-test/java/org/alfresco/rest/GetCommentsTest.java b/e2e-test/java/org/alfresco/rest/GetCommentsTest.java new file mode 100644 index 000000000..186f16613 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/GetCommentsTest.java @@ -0,0 +1,50 @@ +package org.alfresco.rest; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.requests.RestCommentsApi; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +@Test(groups = { "rest-api", "comments", "sanity" }) +public class GetCommentsTest extends RestTest +{ + @Autowired + RestCommentsApi commentsAPI; + + @Autowired + DataUser dataUser; + + private UserModel adminUserModel; + + private FileModel document; + private SiteModel siteModel; + + @BeforeClass + public void initTest() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + restClient.authenticateUser(adminUserModel); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + commentsAPI.useRestClient(restClient); + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + commentsAPI.addComment(document.getNodeRef(), "This is a new comment"); + } + + @TestRail(section={"rest-api", "comments"}, executionType= ExecutionType.SANITY, + description= "Verify Admin user gets comments with Rest API and status code is 200") + public void adminIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception + { + commentsAPI.getNodeComments(document.getNodeRef()); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + } + +} From e54d1c7f87176187d7f50f477b6d663e833f0d40 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Tue, 27 Sep 2016 16:32:31 +0300 Subject: [PATCH 0050/1491] TAS-851 getComment with Manager --- .../java/org/alfresco/rest/GetCommentsTest.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/GetCommentsTest.java b/e2e-test/java/org/alfresco/rest/GetCommentsTest.java index 186f16613..5e576a038 100644 --- a/e2e-test/java/org/alfresco/rest/GetCommentsTest.java +++ b/e2e-test/java/org/alfresco/rest/GetCommentsTest.java @@ -1,9 +1,13 @@ package org.alfresco.rest; +import java.util.Arrays; +import java.util.HashMap; + import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.requests.RestCommentsApi; import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.data.UserRole; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; @@ -27,6 +31,7 @@ public class GetCommentsTest extends RestTest private FileModel document; private SiteModel siteModel; + private HashMap usersWithRoles; @BeforeClass public void initTest() throws Exception @@ -37,6 +42,8 @@ public class GetCommentsTest extends RestTest commentsAPI.useRestClient(restClient); document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); commentsAPI.addComment(document.getNodeRef(), "This is a new comment"); + + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, Arrays.asList(UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor)); } @TestRail(section={"rest-api", "comments"}, executionType= ExecutionType.SANITY, @@ -47,4 +54,12 @@ public class GetCommentsTest extends RestTest commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); } + @TestRail(section={"rest-api", "comments"}, executionType= ExecutionType.SANITY, + description= "Verify Manager user gets comments created by admin user with Rest API and status code is 200") + public void managerIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.get(UserRole.SiteManager)); + commentsAPI.getNodeComments(document.getNodeRef()); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + } } From c0b4eadab0b2f431bf75d98e2b9b750b24ce24e4 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Tue, 27 Sep 2016 16:34:29 +0300 Subject: [PATCH 0051/1491] TAS-853 getComment with Contributor --- e2e-test/java/org/alfresco/rest/GetCommentsTest.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/GetCommentsTest.java b/e2e-test/java/org/alfresco/rest/GetCommentsTest.java index 5e576a038..d7083a61d 100644 --- a/e2e-test/java/org/alfresco/rest/GetCommentsTest.java +++ b/e2e-test/java/org/alfresco/rest/GetCommentsTest.java @@ -62,4 +62,13 @@ public class GetCommentsTest extends RestTest commentsAPI.getNodeComments(document.getNodeRef()); commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); } + + @TestRail(section={"rest-api", "comments"}, executionType= ExecutionType.SANITY, + description= "Verify Contributor user gets comments created by admin user with Rest API and status code is 200") + public void contributorIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.get(UserRole.SiteContributor)); + commentsAPI.getNodeComments(document.getNodeRef()); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + } } From 1f4b9752cea0ed9edd171e95a2798623bb3a19a1 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Tue, 27 Sep 2016 16:35:45 +0300 Subject: [PATCH 0052/1491] TAS-854 getComment with Collaborator --- e2e-test/java/org/alfresco/rest/GetCommentsTest.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/GetCommentsTest.java b/e2e-test/java/org/alfresco/rest/GetCommentsTest.java index d7083a61d..8e9aefbe9 100644 --- a/e2e-test/java/org/alfresco/rest/GetCommentsTest.java +++ b/e2e-test/java/org/alfresco/rest/GetCommentsTest.java @@ -71,4 +71,13 @@ public class GetCommentsTest extends RestTest commentsAPI.getNodeComments(document.getNodeRef()); commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); } + + @TestRail(section={"rest-api", "comments"}, executionType= ExecutionType.SANITY, + description= "Verify Collaborator user gets comments created by admin user with Rest API and status code is 200") + public void collaboratorIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.get(UserRole.SiteCollaborator)); + commentsAPI.getNodeComments(document.getNodeRef()); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + } } From 3ac827ccc905a7b3480dd53147a7bc489bc31005 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Tue, 27 Sep 2016 16:36:32 +0300 Subject: [PATCH 0053/1491] TAS-855 getComment with Consumer --- e2e-test/java/org/alfresco/rest/GetCommentsTest.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/GetCommentsTest.java b/e2e-test/java/org/alfresco/rest/GetCommentsTest.java index 8e9aefbe9..577066e2a 100644 --- a/e2e-test/java/org/alfresco/rest/GetCommentsTest.java +++ b/e2e-test/java/org/alfresco/rest/GetCommentsTest.java @@ -80,4 +80,13 @@ public class GetCommentsTest extends RestTest commentsAPI.getNodeComments(document.getNodeRef()); commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); } + + @TestRail(section={"rest-api", "comments"}, executionType= ExecutionType.SANITY, + description= "Verify Consumer user gets comments created by admin user with Rest API and status code is 200") + public void consumerIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.get(UserRole.SiteConsumer)); + commentsAPI.getNodeComments(document.getNodeRef()); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + } } From bcf916fe5a1b2caccfcebf7c8a3cadd95f7a6377 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Tue, 27 Sep 2016 16:38:24 +0300 Subject: [PATCH 0054/1491] TAS-857 failed authentication call returns status code 401 with Manager role --- .../java/org/alfresco/rest/GetCommentsTest.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/GetCommentsTest.java b/e2e-test/java/org/alfresco/rest/GetCommentsTest.java index 577066e2a..79e2a8315 100644 --- a/e2e-test/java/org/alfresco/rest/GetCommentsTest.java +++ b/e2e-test/java/org/alfresco/rest/GetCommentsTest.java @@ -31,6 +31,7 @@ public class GetCommentsTest extends RestTest private FileModel document; private SiteModel siteModel; + private UserModel userModel; private HashMap usersWithRoles; @BeforeClass @@ -89,4 +90,17 @@ public class GetCommentsTest extends RestTest commentsAPI.getNodeComments(document.getNodeRef()); commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); } + + @TestRail(section={"rest-api", "comments"}, executionType= ExecutionType.SANITY, + description= "Verify Manager user gets status code 401 if authentication call fails") + public void managerIsNotAbleToRetrieveCommentIfAuthenticationFails() throws JsonToModelConversionException, Exception + { + userModel = usersWithRoles.get(UserRole.SiteManager); + userModel.setPassword("incorrectPassword"); + restClient.authenticateUser(userModel); + commentsAPI.getNodeComments(document.getNodeRef()); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED.toString()); + userModel.setPassword("password"); + restClient.authenticateUser(userModel); + } } From e8a4e73cb66c0337fd89ea5c51efeacea8e28cf1 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Tue, 27 Sep 2016 16:39:22 +0300 Subject: [PATCH 0055/1491] TAS-863 getComment created by another user --- .../java/org/alfresco/rest/GetCommentsTest.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/GetCommentsTest.java b/e2e-test/java/org/alfresco/rest/GetCommentsTest.java index 79e2a8315..027cb3db7 100644 --- a/e2e-test/java/org/alfresco/rest/GetCommentsTest.java +++ b/e2e-test/java/org/alfresco/rest/GetCommentsTest.java @@ -103,4 +103,17 @@ public class GetCommentsTest extends RestTest userModel.setPassword("password"); restClient.authenticateUser(userModel); } + + @TestRail(section={"rest-api", "comments"}, executionType= ExecutionType.SANITY, + description= "Verify Manager user gets comments created by another user and status code is 200") + public void managerIsAbleToRetrieveCommentsCreatedByAnotherUser() throws JsonToModelConversionException, Exception + { + userModel = usersWithRoles.get(UserRole.SiteCollaborator); + restClient.authenticateUser(userModel); + commentsAPI.addComment(document.getNodeRef(), "This is a new comment added by " + userModel.getUsername()); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED.toString()); + restClient.authenticateUser(usersWithRoles.get(UserRole.SiteManager)); + commentsAPI.getNodeComments(document.getNodeRef()); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + } } From 5c455ecbbb5ef51ec9c3c99b2eac9d8cde06be8c Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Tue, 27 Sep 2016 16:40:12 +0300 Subject: [PATCH 0056/1491] TAS-864 admin gets comment created by another user --- .../java/org/alfresco/rest/GetCommentsTest.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/GetCommentsTest.java b/e2e-test/java/org/alfresco/rest/GetCommentsTest.java index 027cb3db7..15ed3ca25 100644 --- a/e2e-test/java/org/alfresco/rest/GetCommentsTest.java +++ b/e2e-test/java/org/alfresco/rest/GetCommentsTest.java @@ -116,4 +116,17 @@ public class GetCommentsTest extends RestTest commentsAPI.getNodeComments(document.getNodeRef()); commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); } + + @TestRail(section={"rest-api", "comments"}, executionType= ExecutionType.SANITY, + description= "Verify admin user gets comments created by another user and status code is 200") + public void adminIsAbleToRetrieveCommentsCreatedByAnotherUser() throws JsonToModelConversionException, Exception + { + userModel = usersWithRoles.get(UserRole.SiteCollaborator); + restClient.authenticateUser(userModel); + commentsAPI.addComment(document.getNodeRef(), "This is a new comment added by " + userModel.getUsername()); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED.toString()); + restClient.authenticateUser(adminUserModel); + commentsAPI.getNodeComments(document.getNodeRef()); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + } } From 5fe8c016e84c8288021df9162ed154713576b78f Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Tue, 27 Sep 2016 16:49:08 +0300 Subject: [PATCH 0057/1491] TAS-893 getSite with Manager role --- .../java/org/alfresco/rest/GetSiteTests.java | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/GetSiteTests.java diff --git a/e2e-test/java/org/alfresco/rest/GetSiteTests.java b/e2e-test/java/org/alfresco/rest/GetSiteTests.java new file mode 100644 index 000000000..48b4226ed --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/GetSiteTests.java @@ -0,0 +1,61 @@ +package org.alfresco.rest; + +import java.util.Arrays; +import java.util.HashMap; + +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.requests.RestSitesApi; +import org.alfresco.utility.data.DataSite; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.data.UserRole; +import org.alfresco.utility.exception.DataPreparationException; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * @author iulia.cojocea + */ + +@Test(groups = { "rest-api", "sites", "sanity" }) +public class GetSiteTests extends RestTest +{ + + @Autowired + DataUser dataUser; + + @Autowired + RestSitesApi siteAPI; + + @Autowired + DataSite dataSite; + + private UserModel adminUserModel; + private HashMap usersWithRoles; + private SiteModel siteModel; + + @BeforeClass + public void initTest() throws DataPreparationException + { + adminUserModel = dataUser.createRandomTestUser(); + restClient.authenticateUser(adminUserModel); + siteAPI.useRestClient(restClient); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, + Arrays.asList(UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor)); + } + + @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role gets site information and gets status code OK (200)") + public void getSiteWithManagerRole() throws JsonToModelConversionException, Exception + { + + restClient.authenticateUser(usersWithRoles.get(UserRole.SiteManager)); + siteAPI.getSite(siteModel.getId()); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + } +} From c4a3a3f6d0b35a75874705f52672fcd61768d847 Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Tue, 27 Sep 2016 16:50:10 +0300 Subject: [PATCH 0058/1491] TAS-894 getSite with Collaborator role --- e2e-test/java/org/alfresco/rest/GetSiteTests.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/GetSiteTests.java b/e2e-test/java/org/alfresco/rest/GetSiteTests.java index 48b4226ed..01b43814b 100644 --- a/e2e-test/java/org/alfresco/rest/GetSiteTests.java +++ b/e2e-test/java/org/alfresco/rest/GetSiteTests.java @@ -58,4 +58,13 @@ public class GetSiteTests extends RestTest siteAPI.getSite(siteModel.getId()); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); } + + @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify user with Collaborator role gets site information and gets status code OK (200)") + public void getSiteWithCollaboratorRole() throws JsonToModelConversionException, Exception + { + + restClient.authenticateUser(usersWithRoles.get(UserRole.SiteCollaborator)); + siteAPI.getSite(siteModel.getId()); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + } } From 8992be8755688f43c4df66aa4186cd945fbfb8f2 Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Tue, 27 Sep 2016 16:50:51 +0300 Subject: [PATCH 0059/1491] TAS-895 getSite with Contributor role --- e2e-test/java/org/alfresco/rest/GetSiteTests.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/GetSiteTests.java b/e2e-test/java/org/alfresco/rest/GetSiteTests.java index 01b43814b..25d8da11e 100644 --- a/e2e-test/java/org/alfresco/rest/GetSiteTests.java +++ b/e2e-test/java/org/alfresco/rest/GetSiteTests.java @@ -67,4 +67,13 @@ public class GetSiteTests extends RestTest siteAPI.getSite(siteModel.getId()); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); } + + @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify user with Contributor role gets site information and gets status code OK (200)") + public void getSiteWithContributorRole() throws JsonToModelConversionException, Exception + { + + restClient.authenticateUser(usersWithRoles.get(UserRole.SiteContributor)); + siteAPI.getSite(siteModel.getId()); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + } } From 4f6107294f8b463da1c591167b6a25805d5ba974 Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Tue, 27 Sep 2016 16:51:51 +0300 Subject: [PATCH 0060/1491] TAS-896 getSite with Consumer role --- e2e-test/java/org/alfresco/rest/GetSiteTests.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/GetSiteTests.java b/e2e-test/java/org/alfresco/rest/GetSiteTests.java index 25d8da11e..1788490e2 100644 --- a/e2e-test/java/org/alfresco/rest/GetSiteTests.java +++ b/e2e-test/java/org/alfresco/rest/GetSiteTests.java @@ -76,4 +76,13 @@ public class GetSiteTests extends RestTest siteAPI.getSite(siteModel.getId()); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); } + + @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role gets site information and gets status code OK (200)") + public void getSiteWithConsumerRole() throws JsonToModelConversionException, Exception + { + + restClient.authenticateUser(usersWithRoles.get(UserRole.SiteConsumer)); + siteAPI.getSite(siteModel.getId()); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + } } From 16758317b886e52ec7e86ce13fe22b6c2b424215 Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Tue, 27 Sep 2016 16:52:30 +0300 Subject: [PATCH 0061/1491] TAS-897 getSite with admin user --- e2e-test/java/org/alfresco/rest/GetSiteTests.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/GetSiteTests.java b/e2e-test/java/org/alfresco/rest/GetSiteTests.java index 1788490e2..9da55c4ab 100644 --- a/e2e-test/java/org/alfresco/rest/GetSiteTests.java +++ b/e2e-test/java/org/alfresco/rest/GetSiteTests.java @@ -85,4 +85,13 @@ public class GetSiteTests extends RestTest siteAPI.getSite(siteModel.getId()); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); } + + @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role gets site information and gets status code OK (200)") + public void getSiteWithAdminRole() throws JsonToModelConversionException, Exception + { + + restClient.authenticateUser(adminUserModel); + siteAPI.getSite(siteModel.getId()); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + } } From 84cc427d1c2bb498d88dd60cb6eac77527e45d44 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Tue, 27 Sep 2016 17:00:48 +0300 Subject: [PATCH 0062/1491] TAS-713 getNetwork API tests --- .../org/alfresco/rest/RestNetworksTest.java | 123 ++++++++++++++++++ .../rest/demo/SampleCommentsTest.java | 4 - .../alfresco/rest/demo/SamplePeopleTest.java | 4 - .../alfresco/rest/demo/SampleSitesTest.java | 8 -- e2e-test/resources/default.properties | 6 +- 5 files changed, 126 insertions(+), 19 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/RestNetworksTest.java diff --git a/e2e-test/java/org/alfresco/rest/RestNetworksTest.java b/e2e-test/java/org/alfresco/rest/RestNetworksTest.java new file mode 100644 index 000000000..9eecc6d10 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/RestNetworksTest.java @@ -0,0 +1,123 @@ +package org.alfresco.rest; + +import org.alfresco.rest.requests.RestNetworksApi; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Created by Cristina Axinte on 9/26/2016. + */ +@Test(groups = { "rest-api", "networks", "sanity" }) +public class RestNetworksTest extends RestTest +{ + @Autowired + RestNetworksApi networkApi; + + UserModel adminTenantUser; + UserModel tenantUser; + + @BeforeClass + public void setup() + { + // input data should be created for handle tenants: + // create tenant "tenant1" with password "password" + + // with admin "admin@tenant1" create user "test1@tenant1" with password "password" + adminTenantUser = new UserModel("admin@tenant1", "password"); + tenantUser = new UserModel("test1@tenant1", "password"); + } + + @TestRail(section = { "rest-api", "networks" }, executionType = ExecutionType.SANITY, description = "Verify non existing user gets another exisiting network with Rest API and checks the forbidden status") + public void nonExistingTenantUserIsNotAuthorizedToRequest() throws Exception + { + String tenantName = "tenant1"; + UserModel tenantUser = new UserModel("nonexisting@tenant1", "password"); + restClient.authenticateUser(tenantUser); + networkApi.useRestClient(restClient); + networkApi.getNetwork(tenantName); + networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED.toString()); + } + + @TestRail(section = { "rest-api", "networks" }, executionType = ExecutionType.SANITY, description = "Verify tenant admin user gets specific network with Rest API and response is not empty") + public void adminTenantChecksIfNetworkIsPresent() throws Exception + { + String tenantName = "tenant1"; + restClient.authenticateUser(adminTenantUser); + networkApi.useRestClient(restClient); + networkApi.getNetwork(tenantName); + networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + } + + @TestRail(section = { "rest-api", "networks" }, executionType = ExecutionType.SANITY, description = "Verify tenant admin user gets specific network with Rest API and checks response parameters are correct") + public void adminTenantChecksNetworkParamsAreCorrect() throws Exception + { + String tenantName = "tenant1"; + restClient.authenticateUser(adminTenantUser); + networkApi.useRestClient(restClient); + networkApi.getNetwork(tenantName).assertNetworkHasName(tenantName).assertNetworkIsEnabled(true); + } + + @TestRail(section = { "rest-api", "networks" }, executionType = ExecutionType.SANITY, description = "Verify tenant admin user gets non exisiting network with Rest API and checks the not found status") + public void adminTenantChecksIfNonExistingNetworkIsNotFound() throws Exception + { + String tenantName = "netenant"; + restClient.authenticateUser(adminTenantUser); + networkApi.useRestClient(restClient); + networkApi.getNetwork(tenantName); + networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND.toString()); + } + + @TestRail(section = { "rest-api", "networks" }, executionType = ExecutionType.SANITY, description = "Verify tenant admin user gets another exisiting network with Rest API and checks the forbidden status") + public void adminTenantChecksIfAnotherExistingNetworkIsForbidden() throws Exception + { + String tenantName = "tenant2"; + restClient.authenticateUser(adminTenantUser); + networkApi.useRestClient(restClient); + networkApi.getNetwork(tenantName); + networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN.toString()); + } + + @TestRail(section = { "rest-api", "networks" }, executionType = ExecutionType.SANITY, description = "Verify any tenant user gets its network with Rest API and response is not empty") + public void userTenantChecksIfNetworkIsPresent() throws Exception + { + String tenantName = "tenant1"; + restClient.authenticateUser(tenantUser); + networkApi.useRestClient(restClient); + networkApi.getNetwork(tenantName); + networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + } + + @TestRail(section = { "rest-api", "networks" }, executionType = ExecutionType.SANITY, description = "Verify any tenant user gets specific network with Rest API and checks response parameters are correct") + public void userTenantChecksNetworkParamsAreCorrect() throws Exception + { + String tenantName = "tenant1"; + restClient.authenticateUser(tenantUser); + networkApi.useRestClient(restClient); + networkApi.getNetwork(tenantName).assertNetworkHasName(tenantName).assertNetworkIsEnabled(true); + } + + @TestRail(section = { "rest-api", "networks" }, executionType = ExecutionType.SANITY, description = "Verify any tenant user gets non exisiting network with Rest API and checks the not found status") + public void userTenantChecksIfNonExistingNetworkIsNotFound() throws Exception + { + String tenantName = "netenant"; + restClient.authenticateUser(tenantUser); + networkApi.useRestClient(restClient); + networkApi.getNetwork(tenantName); + networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND.toString()); + } + + @TestRail(section = { "rest-api", "networks" }, executionType = ExecutionType.SANITY, description = "Verify any tenant user gets another exisiting network with Rest API and checks the forbidden status") + public void userTenantChecksIfAnotherExistingNetworkIsForbidden() throws Exception + { + String tenantName = "tenant2"; + restClient.authenticateUser(tenantUser); + networkApi.useRestClient(restClient); + networkApi.getNetwork(tenantName); + networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN.toString()); + } +} diff --git a/e2e-test/java/org/alfresco/rest/demo/SampleCommentsTest.java b/e2e-test/java/org/alfresco/rest/demo/SampleCommentsTest.java index 1551c0fb9..6b3384457 100644 --- a/e2e-test/java/org/alfresco/rest/demo/SampleCommentsTest.java +++ b/e2e-test/java/org/alfresco/rest/demo/SampleCommentsTest.java @@ -5,7 +5,6 @@ import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestCommentModel; import org.alfresco.rest.requests.RestCommentsApi; -import org.alfresco.utility.data.DataUser; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; @@ -20,9 +19,6 @@ import org.testng.annotations.Test; @Test(groups = { "rest-api", "comments", "sanity" }) public class SampleCommentsTest extends RestTest { - @Autowired - DataUser dataUser; - @Autowired RestCommentsApi commentsAPI; diff --git a/e2e-test/java/org/alfresco/rest/demo/SamplePeopleTest.java b/e2e-test/java/org/alfresco/rest/demo/SamplePeopleTest.java index a5718b2dc..82b3e5ee5 100644 --- a/e2e-test/java/org/alfresco/rest/demo/SamplePeopleTest.java +++ b/e2e-test/java/org/alfresco/rest/demo/SamplePeopleTest.java @@ -2,7 +2,6 @@ package org.alfresco.rest.demo; import org.alfresco.rest.RestTest; import org.alfresco.rest.requests.RestPeopleApi; -import org.alfresco.utility.data.DataUser; import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; @@ -19,9 +18,6 @@ public class SamplePeopleTest extends RestTest @Autowired RestPeopleApi peopleAPI; - @Autowired - DataUser dataUser; - private UserModel userModel; private UserModel adminUser; diff --git a/e2e-test/java/org/alfresco/rest/demo/SampleSitesTest.java b/e2e-test/java/org/alfresco/rest/demo/SampleSitesTest.java index 53bcfad31..11c5fee5d 100644 --- a/e2e-test/java/org/alfresco/rest/demo/SampleSitesTest.java +++ b/e2e-test/java/org/alfresco/rest/demo/SampleSitesTest.java @@ -4,8 +4,6 @@ import org.alfresco.rest.RestTest; import org.alfresco.rest.body.SiteMember; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.requests.RestSitesApi; -import org.alfresco.utility.data.DataSite; -import org.alfresco.utility.data.DataUser; import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; @@ -23,12 +21,6 @@ public class SampleSitesTest extends RestTest @Autowired RestSitesApi siteAPI; - @Autowired - DataUser dataUser; - - @Autowired - DataSite dataSite; - private UserModel userModel; private SiteModel siteModel; diff --git a/e2e-test/resources/default.properties b/e2e-test/resources/default.properties index 213526039..1ff526c0b 100644 --- a/e2e-test/resources/default.properties +++ b/e2e-test/resources/default.properties @@ -1,14 +1,14 @@ # dataprep related alfresco.scheme=http -alfresco.server=172.29.100.206 -alfresco.port=8070 +alfresco.server=172.29.100.215 +alfresco.port=8080 # credentials admin.user=admin admin.password=admin # rest related -rest.basePath=alfresco/api/-default-/public/alfresco/versions/1 +rest.basePath=alfresco/api/tenant1/public/alfresco/versions/1 # TEST MANAGEMENT SECTION - Test Rail From 4bd3fe1b1d977fd20764f2b2bb03e21ba02ba404 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Tue, 27 Sep 2016 17:10:47 +0300 Subject: [PATCH 0063/1491] Renamed test class and moved it to a new package --- .../RestGetNetworkTest.java} | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) rename e2e-test/java/org/alfresco/rest/{RestNetworksTest.java => networks/RestGetNetworkTest.java} (98%) diff --git a/e2e-test/java/org/alfresco/rest/RestNetworksTest.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkTest.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/RestNetworksTest.java rename to e2e-test/java/org/alfresco/rest/networks/RestGetNetworkTest.java index 9eecc6d10..6029b2761 100644 --- a/e2e-test/java/org/alfresco/rest/RestNetworksTest.java +++ b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkTest.java @@ -1,5 +1,6 @@ -package org.alfresco.rest; +package org.alfresco.rest.networks; +import org.alfresco.rest.RestTest; import org.alfresco.rest.requests.RestNetworksApi; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; @@ -13,7 +14,7 @@ import org.testng.annotations.Test; * Created by Cristina Axinte on 9/26/2016. */ @Test(groups = { "rest-api", "networks", "sanity" }) -public class RestNetworksTest extends RestTest +public class RestGetNetworkTest extends RestTest { @Autowired RestNetworksApi networkApi; From a223bd893c50ef5a878a2ee709ff898c48dd9d1e Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Tue, 27 Sep 2016 17:16:17 +0300 Subject: [PATCH 0064/1491] TAS-912 - REST API - valid site membership information request returns success status code 200 with Manager role --- ...etSiteMembershipInformationSanityTest.java | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/sites/GetSiteMembershipInformationSanityTest.java diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembershipInformationSanityTest.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembershipInformationSanityTest.java new file mode 100644 index 000000000..abfe6fb0f --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembershipInformationSanityTest.java @@ -0,0 +1,61 @@ +package org.alfresco.rest.sites; + +import java.util.Arrays; +import java.util.HashMap; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.body.SiteMembership; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.requests.RestSitesApi; +import org.alfresco.utility.data.DataSite; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.data.UserRole; +import org.alfresco.utility.exception.DataPreparationException; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +@Test(groups = { "rest-api", "sites", "sanity" }) +public class GetSiteMembershipInformationSanityTest extends RestTest +{ + @Autowired + RestSitesApi siteAPI; + + @Autowired + DataUser dataUser; + + @Autowired + DataSite dataSite; + + private SiteModel siteModel; + + private HashMap usersWithRoles; + + private UserModel adminUser; + + @BeforeClass + public void initTest() throws DataPreparationException + { + adminUser = dataUser.getAdminUser(); + siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); + usersWithRoles = dataUser.addUsersToSiteWithRoles(siteModel, + Arrays.asList(UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor)); + + siteAPI.useRestClient(restClient); + } + + @TestRail(section = { "rest-api", + "sites" }, executionType = ExecutionType.SANITY, description = "Verify site manager is able to retrieve site membership information of another user") + public void siteManagerCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.get(UserRole.SiteManager)); + siteAPI.getSiteMembershipInformation(adminUser.getUsername()); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + } + +} \ No newline at end of file From 35195c024ec75b807f6085657ae7ccda909f813e Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Tue, 27 Sep 2016 17:19:49 +0300 Subject: [PATCH 0065/1491] TAS-913 - REST API - valid site membership information request returns success status code 200 with Collaborator role --- ...etSiteMembershipInformationSanityTest.java | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembershipInformationSanityTest.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembershipInformationSanityTest.java index abfe6fb0f..48b03ef79 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembershipInformationSanityTest.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembershipInformationSanityTest.java @@ -4,7 +4,6 @@ import java.util.Arrays; import java.util.HashMap; import org.alfresco.rest.RestTest; -import org.alfresco.rest.body.SiteMembership; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.requests.RestSitesApi; import org.alfresco.utility.data.DataSite; @@ -33,10 +32,8 @@ public class GetSiteMembershipInformationSanityTest extends RestTest DataSite dataSite; private SiteModel siteModel; - - private HashMap usersWithRoles; - private UserModel adminUser; + private HashMap usersWithRoles; @BeforeClass public void initTest() throws DataPreparationException @@ -45,17 +42,30 @@ public class GetSiteMembershipInformationSanityTest extends RestTest siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); usersWithRoles = dataUser.addUsersToSiteWithRoles(siteModel, Arrays.asList(UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor)); - + siteAPI.useRestClient(restClient); } - @TestRail(section = { "rest-api", - "sites" }, executionType = ExecutionType.SANITY, description = "Verify site manager is able to retrieve site membership information of another user") + @TestRail(section = { "rest-api", "sites" }, + executionType = ExecutionType.SANITY, + description = "Verify site manager is able to retrieve site membership information of another user") public void siteManagerCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.get(UserRole.SiteManager)); siteAPI.getSiteMembershipInformation(adminUser.getUsername()); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + siteAPI.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.OK.toString()); + } + + @TestRail(section = { "rest-api", "sites" }, + executionType = ExecutionType.SANITY, + description = "Verify site collaborator is able to retrieve site membership information of another user") + public void siteCollaboratorCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.get(UserRole.SiteCollaborator)); + siteAPI.getSiteMembershipInformation(adminUser.getUsername()); + siteAPI.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.OK.toString()); } } \ No newline at end of file From daa26d1a913993c56944edc9561f6827efa9091e Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Tue, 27 Sep 2016 17:21:07 +0300 Subject: [PATCH 0066/1491] TAS-903 postComment with admin --- .../org/alfresco/rest/PostCommentsTest.java | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/PostCommentsTest.java diff --git a/e2e-test/java/org/alfresco/rest/PostCommentsTest.java b/e2e-test/java/org/alfresco/rest/PostCommentsTest.java new file mode 100644 index 000000000..04077b5b3 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/PostCommentsTest.java @@ -0,0 +1,48 @@ +package org.alfresco.rest; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.requests.RestCommentsApi; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +@Test(groups = { "rest-api", "comments", "sanity" }) +public class PostCommentsTest extends RestTest +{ + @Autowired + RestCommentsApi commentsAPI; + + @Autowired + DataUser dataUser; + + private UserModel adminUserModel; + private FileModel document; + private SiteModel siteModel; + + @BeforeClass + public void initTest() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + restClient.authenticateUser(adminUserModel); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + commentsAPI.useRestClient(restClient); + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + } + + @TestRail(section={"rest-api", "comments"}, executionType= ExecutionType.SANITY, + description= "Verify admin user adds comments with Rest API and status code is 201") + public void admiIsAbleToAddComment() throws JsonToModelConversionException, Exception + { + commentsAPI.addComment(document.getNodeRef(), "This is a new comment added by " + adminUserModel.getUsername()); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED.toString()); + } + +} From eafcc41859b2672deb4cbe36e2e04c047a8550d3 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Tue, 27 Sep 2016 17:21:18 +0300 Subject: [PATCH 0067/1491] TAS-914 - REST API - valid site membership information request returns success status code 200 with Contributor role --- .../sites/GetSiteMembershipInformationSanityTest.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembershipInformationSanityTest.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembershipInformationSanityTest.java index 48b03ef79..4a9bbc9a5 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembershipInformationSanityTest.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembershipInformationSanityTest.java @@ -67,5 +67,16 @@ public class GetSiteMembershipInformationSanityTest extends RestTest siteAPI.usingRestWrapper() .assertStatusCodeIs(HttpStatus.OK.toString()); } + + @TestRail(section = { "rest-api", "sites" }, + executionType = ExecutionType.SANITY, + description = "Verify site contributor is able to retrieve site membership information of another user") + public void siteContributorCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.get(UserRole.SiteContributor)); + siteAPI.getSiteMembershipInformation(adminUser.getUsername()); + siteAPI.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.OK.toString()); + } } \ No newline at end of file From d04577c7ee4c28b196cd003cce943fc081b029a3 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Tue, 27 Sep 2016 17:24:04 +0300 Subject: [PATCH 0068/1491] TAS-915 - REST API - valid site membership information request returns success status code 200 with Consumer role --- .../sites/GetSiteMembershipInformationSanityTest.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembershipInformationSanityTest.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembershipInformationSanityTest.java index 4a9bbc9a5..6eda2d010 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembershipInformationSanityTest.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembershipInformationSanityTest.java @@ -78,5 +78,16 @@ public class GetSiteMembershipInformationSanityTest extends RestTest siteAPI.usingRestWrapper() .assertStatusCodeIs(HttpStatus.OK.toString()); } + + @TestRail(section = { "rest-api", "sites" }, + executionType = ExecutionType.SANITY, + description = "Verify site consumer is able to retrieve site membership information of another user") + public void siteConsumerCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.get(UserRole.SiteConsumer)); + siteAPI.getSiteMembershipInformation(adminUser.getUsername()); + siteAPI.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.OK.toString()); + } } \ No newline at end of file From d74a0f3e04a7a680769c0f82907a91a19873e084 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Tue, 27 Sep 2016 17:24:40 +0300 Subject: [PATCH 0069/1491] TAS-899 postComment with manager --- .../org/alfresco/rest/PostCommentsTest.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/PostCommentsTest.java b/e2e-test/java/org/alfresco/rest/PostCommentsTest.java index 04077b5b3..82bacce33 100644 --- a/e2e-test/java/org/alfresco/rest/PostCommentsTest.java +++ b/e2e-test/java/org/alfresco/rest/PostCommentsTest.java @@ -1,9 +1,13 @@ package org.alfresco.rest; +import java.util.Arrays; +import java.util.HashMap; + import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.requests.RestCommentsApi; import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.data.UserRole; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; @@ -26,6 +30,7 @@ public class PostCommentsTest extends RestTest private UserModel adminUserModel; private FileModel document; private SiteModel siteModel; + private HashMap usersWithRoles; @BeforeClass public void initTest() throws Exception @@ -34,7 +39,8 @@ public class PostCommentsTest extends RestTest restClient.authenticateUser(adminUserModel); siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); commentsAPI.useRestClient(restClient); - document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, Arrays.asList(UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor)); } @TestRail(section={"rest-api", "comments"}, executionType= ExecutionType.SANITY, @@ -44,5 +50,14 @@ public class PostCommentsTest extends RestTest commentsAPI.addComment(document.getNodeRef(), "This is a new comment added by " + adminUserModel.getUsername()); commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED.toString()); } + + @TestRail(section={"rest-api", "comments"}, executionType= ExecutionType.SANITY, + description= "Verify Manager user adds comments with Rest API and status code is 201") + public void managerIsAbleToAddComment() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.get(UserRole.SiteManager)); + commentsAPI.addComment(document.getNodeRef(), "This is a new comment added by user with role: " + UserRole.SiteManager); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED.toString()); + } } From 6671ae2607546fd8928292f434ae606afa437c36 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Tue, 27 Sep 2016 17:25:37 +0300 Subject: [PATCH 0070/1491] TAS-900 postComment with contributor --- e2e-test/java/org/alfresco/rest/PostCommentsTest.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/PostCommentsTest.java b/e2e-test/java/org/alfresco/rest/PostCommentsTest.java index 82bacce33..d4cb16cee 100644 --- a/e2e-test/java/org/alfresco/rest/PostCommentsTest.java +++ b/e2e-test/java/org/alfresco/rest/PostCommentsTest.java @@ -59,5 +59,14 @@ public class PostCommentsTest extends RestTest commentsAPI.addComment(document.getNodeRef(), "This is a new comment added by user with role: " + UserRole.SiteManager); commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED.toString()); } + + @TestRail(section={"rest-api", "comments"}, executionType= ExecutionType.SANITY, + description= "Verify Contributor user adds comments with Rest API and status code is 201") + public void contributorIsAbleToAddComment() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.get(UserRole.SiteContributor)); + commentsAPI.addComment(document.getNodeRef(), "This is a new comment added by user with role" + UserRole.SiteContributor); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED.toString()); + } } From eff154b61ec5f2abb48aabbdf072cceb218e81ed Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Tue, 27 Sep 2016 17:27:48 +0300 Subject: [PATCH 0071/1491] TAS-916 - REST API - valid site membership information request returns success status code 200 with admin user --- .../sites/GetSiteMembershipInformationSanityTest.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembershipInformationSanityTest.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembershipInformationSanityTest.java index 6eda2d010..2437bdffa 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembershipInformationSanityTest.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembershipInformationSanityTest.java @@ -89,5 +89,16 @@ public class GetSiteMembershipInformationSanityTest extends RestTest siteAPI.usingRestWrapper() .assertStatusCodeIs(HttpStatus.OK.toString()); } + + @TestRail(section = { "rest-api", "sites" }, + executionType = ExecutionType.SANITY, + description = "Verify admin is able to retrieve site membership information of another user") + public void siteAdminCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUser); + siteAPI.getSiteMembershipInformation(usersWithRoles.get(UserRole.SiteManager).getUsername()); + siteAPI.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.OK.toString()); + } } \ No newline at end of file From 313f23a29dfda91e76886f51fb60ca90a3e4c326 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Tue, 27 Sep 2016 18:14:01 +0300 Subject: [PATCH 0072/1491] Adding tests for tasks TAS-874, TAS-875, TAS-876, TAS-877, TAS-878 --- .../rest/networks/RestGetNetworkTest.java | 64 ++++++++++++++++++- 1 file changed, 63 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkTest.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkTest.java index 6029b2761..3167bc28f 100644 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkTest.java +++ b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkTest.java @@ -2,6 +2,9 @@ package org.alfresco.rest.networks; import org.alfresco.rest.RestTest; import org.alfresco.rest.requests.RestNetworksApi; +import org.alfresco.utility.data.UserRole; +import org.alfresco.utility.exception.DataPreparationException; +import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; @@ -21,9 +24,13 @@ public class RestGetNetworkTest extends RestTest UserModel adminTenantUser; UserModel tenantUser; + UserModel managerTenantUser; + UserModel collaboratorTenantUser; + UserModel consumerTenantUser; + UserModel contributorTenantUser; @BeforeClass - public void setup() + public void setup() throws DataPreparationException { // input data should be created for handle tenants: // create tenant "tenant1" with password "password" @@ -31,6 +38,21 @@ public class RestGetNetworkTest extends RestTest // with admin "admin@tenant1" create user "test1@tenant1" with password "password" adminTenantUser = new UserModel("admin@tenant1", "password"); tenantUser = new UserModel("test1@tenant1", "password"); +// managerTenantUser = dataUser.usingUser(adminTenantUser).createUser("manTenant2@tenant1"); +// collaboratorTenantUser = dataUser.usingUser(adminTenantUser).createUser("manTenant2@tenant1"); +// consumerTenantUser = dataUser.usingUser(adminTenantUser).createUser("manTenant2@tenant1"); +// contributorTenantUser = dataUser.usingUser(adminTenantUser).createUser("manTenant2@tenant1"); + managerTenantUser = new UserModel("manTenant@tenant1", "password"); + collaboratorTenantUser = new UserModel("colTenant@tenant1", "password"); + consumerTenantUser = new UserModel("consTenant@tenant1", "password"); + contributorTenantUser = new UserModel("contTenant@tenant1", "password"); + + SiteModel site=dataSite.usingUser(adminTenantUser).createPublicRandomSite(); + dataUser.usingUser(adminTenantUser).addUserToSite(managerTenantUser, site, UserRole.SiteManager); + dataUser.usingUser(adminTenantUser).addUserToSite(collaboratorTenantUser, site, UserRole.SiteCollaborator); + dataUser.usingUser(adminTenantUser).addUserToSite(consumerTenantUser, site, UserRole.SiteConsumer); + dataUser.usingUser(adminTenantUser).addUserToSite(contributorTenantUser, site, UserRole.SiteConsumer); + } @TestRail(section = { "rest-api", "networks" }, executionType = ExecutionType.SANITY, description = "Verify non existing user gets another exisiting network with Rest API and checks the forbidden status") @@ -121,4 +143,44 @@ public class RestGetNetworkTest extends RestTest networkApi.getNetwork(tenantName); networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN.toString()); } + + @TestRail(section = { "rest-api", "networks" }, executionType = ExecutionType.SANITY, description = "Verify manager tenant user gets its network with Rest API and response is not empty") + public void tenantManagerUserChecksIfNetworkIsPresent() throws Exception + { + String tenantName = "tenant1"; + restClient.authenticateUser(managerTenantUser); + networkApi.useRestClient(restClient); + networkApi.getNetwork(tenantName); + networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + } + + @TestRail(section = { "rest-api", "networks" }, executionType = ExecutionType.SANITY, description = "Verify collaborator tenant user gets its network with Rest API and response is not empty") + public void tenantCollaboratorUserChecksIfNetworkIsPresent() throws Exception + { + String tenantName = "tenant1"; + restClient.authenticateUser(collaboratorTenantUser); + networkApi.useRestClient(restClient); + networkApi.getNetwork(tenantName); + networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + } + + @TestRail(section = { "rest-api", "networks" }, executionType = ExecutionType.SANITY, description = "Verify consumer tenant user gets its network with Rest API and response is not empty") + public void tenantConsumerUserChecksIfNetworkIsPresent() throws Exception + { + String tenantName = "tenant1"; + restClient.authenticateUser(consumerTenantUser); + networkApi.useRestClient(restClient); + networkApi.getNetwork(tenantName); + networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + } + + @TestRail(section = { "rest-api", "networks" }, executionType = ExecutionType.SANITY, description = "Verify contributor tenant user gets its network with Rest API and response is not empty") + public void tenantContributorUserChecksIfNetworkIsPresent() throws Exception + { + String tenantName = "tenant1"; + restClient.authenticateUser(contributorTenantUser); + networkApi.useRestClient(restClient); + networkApi.getNetwork(tenantName); + networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + } } From 1471894dc69c1734e4fcf8bbcd65efecd531b13e Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Tue, 27 Sep 2016 16:21:28 +0300 Subject: [PATCH 0073/1491] TAS-861 getsSites 401 with manager role --- .../alfresco/rest/GetSitesSanityTests.java | 111 ++++++++++++++++++ .../java/org/alfresco/rest/GetSitesTests.java | 13 ++ 2 files changed, 124 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/GetSitesSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/GetSitesSanityTests.java b/e2e-test/java/org/alfresco/rest/GetSitesSanityTests.java new file mode 100644 index 000000000..610954b34 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/GetSitesSanityTests.java @@ -0,0 +1,111 @@ +package org.alfresco.rest; + +import java.util.Arrays; +import java.util.HashMap; + +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.requests.RestSitesApi; +import org.alfresco.utility.data.DataSite; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.data.UserRole; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * @author iulia.cojocea + */ +@Test(groups = { "rest-api", "sites", "sanity" }) +public class GetSitesSanityTests extends RestTest +{ + @Autowired + RestSitesApi siteAPI; + + @Autowired + DataUser dataUser; + + @Autowired + DataSite dataSite; + + private UserModel adminUserModel; + private UserModel userModel; + private HashMap usersWithRoles; + private SiteModel siteModel; + + @BeforeClass + public void initTest() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + restClient.authenticateUser(adminUserModel); + siteAPI.useRestClient(restClient); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, + Arrays.asList(UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor)); + } + + @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role gets sites information and gets status code OK (200)") + public void getSitesWithManagerRole() throws JsonToModelConversionException, Exception + { + + restClient.authenticateUser(usersWithRoles.get(UserRole.SiteManager)); + siteAPI.getAllSites(); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + } + + @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, + description = "Verify user with Collaborator role gets sites information and gets status code OK (200)") + public void getSitesWithCollaboratorRole() throws JsonToModelConversionException, Exception + { + + restClient.authenticateUser(usersWithRoles.get(UserRole.SiteCollaborator)); + siteAPI.getAllSites(); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + } + + @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, + description = "Verify user with Contributor role gets sites information and gets status code OK (200)") + public void getSitesWithContributorRole() throws JsonToModelConversionException, Exception + { + + restClient.authenticateUser(usersWithRoles.get(UserRole.SiteContributor)); + siteAPI.getAllSites(); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + } + + @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, + description = "Verify user with Consumer role gets sites information and gets status code OK (200)") + public void getSitesWithConsumerRole() throws JsonToModelConversionException, Exception + { + + restClient.authenticateUser(usersWithRoles.get(UserRole.SiteConsumer)); + siteAPI.getAllSites(); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + } + + @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, + description = "Verify user with Admin user gets sites information and gets status code OK (200)") + public void getSitesWithAdminUser() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel); + siteAPI.getAllSites(); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + } + + @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, + description = "Failed authentication get sites call returns status code 401 with Manager role") + public void getSitesWithManagerRoleFailedAuth() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.get(UserRole.SiteManager)); + userModel = dataUser.createRandomTestUser(); + userModel.setPassword("user wrong password"); + dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); + restClient.authenticateUser(userModel); + siteAPI.getAllSites(); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED.toString()); + } +} diff --git a/e2e-test/java/org/alfresco/rest/GetSitesTests.java b/e2e-test/java/org/alfresco/rest/GetSitesTests.java index d2d3020e7..e1e38d290 100644 --- a/e2e-test/java/org/alfresco/rest/GetSitesTests.java +++ b/e2e-test/java/org/alfresco/rest/GetSitesTests.java @@ -33,6 +33,7 @@ public class GetSitesTests extends RestTest DataSite dataSite; private UserModel adminUserModel; + private UserModel userModel; private HashMap usersWithRoles; private SiteModel siteModel; @@ -91,4 +92,16 @@ public class GetSitesTests extends RestTest siteAPI.getAllSites(); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); } + + @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Failed authentication get sites call returns status code 401 with Manager role") + public void getSitesWithManagerRoleFailedAuth() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.get(UserRole.SiteManager)); + userModel = dataUser.createRandomTestUser(); + userModel.setPassword("user wrong password"); + dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); + restClient.authenticateUser(userModel); + siteAPI.getAllSites(); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED.toString()); + } } From a316935c77f5335aa7b6dfa1f7de14b042b71bb1 Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Tue, 27 Sep 2016 16:54:49 +0300 Subject: [PATCH 0074/1491] TAS-898 getSite status code 401 with Manager role --- ...SiteTests.java => GetSiteSanityTests.java} | 37 +++++++++++++------ 1 file changed, 25 insertions(+), 12 deletions(-) rename e2e-test/java/org/alfresco/rest/{GetSiteTests.java => GetSiteSanityTests.java} (69%) diff --git a/e2e-test/java/org/alfresco/rest/GetSiteTests.java b/e2e-test/java/org/alfresco/rest/GetSiteSanityTests.java similarity index 69% rename from e2e-test/java/org/alfresco/rest/GetSiteTests.java rename to e2e-test/java/org/alfresco/rest/GetSiteSanityTests.java index 9da55c4ab..32076dc28 100644 --- a/e2e-test/java/org/alfresco/rest/GetSiteTests.java +++ b/e2e-test/java/org/alfresco/rest/GetSiteSanityTests.java @@ -23,7 +23,7 @@ import org.testng.annotations.Test; */ @Test(groups = { "rest-api", "sites", "sanity" }) -public class GetSiteTests extends RestTest +public class GetSiteSanityTests extends RestTest { @Autowired @@ -37,12 +37,13 @@ public class GetSiteTests extends RestTest private UserModel adminUserModel; private HashMap usersWithRoles; + private UserModel userModel; private SiteModel siteModel; @BeforeClass public void initTest() throws DataPreparationException { - adminUserModel = dataUser.createRandomTestUser(); + adminUserModel = dataUser.getAdminUser(); restClient.authenticateUser(adminUserModel); siteAPI.useRestClient(restClient); siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); @@ -50,48 +51,60 @@ public class GetSiteTests extends RestTest Arrays.asList(UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor)); } - @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role gets site information and gets status code OK (200)") + @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, + description = "Verify user with Manager role gets site information and gets status code OK (200)") public void getSiteWithManagerRole() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.get(UserRole.SiteManager)); siteAPI.getSite(siteModel.getId()); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); } - @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify user with Collaborator role gets site information and gets status code OK (200)") + @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, + description = "Verify user with Collaborator role gets site information and gets status code OK (200)") public void getSiteWithCollaboratorRole() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.get(UserRole.SiteCollaborator)); siteAPI.getSite(siteModel.getId()); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); } - @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify user with Contributor role gets site information and gets status code OK (200)") + @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, + description = "Verify user with Contributor role gets site information and gets status code OK (200)") public void getSiteWithContributorRole() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.get(UserRole.SiteContributor)); siteAPI.getSite(siteModel.getId()); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); } - @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role gets site information and gets status code OK (200)") + @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, + description = "Verify user with Consumer role gets site information and gets status code OK (200)") public void getSiteWithConsumerRole() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.get(UserRole.SiteConsumer)); siteAPI.getSite(siteModel.getId()); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); } - @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role gets site information and gets status code OK (200)") + @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, + description = "Verify user with admin role gets site information and gets status code OK (200)") public void getSiteWithAdminRole() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(adminUserModel); siteAPI.getSite(siteModel.getId()); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); } + + @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, + description = "Failed authentication get site call returns status code 401 with Manager role") + public void getSiteWithManagerRoleFailedAuth() throws JsonToModelConversionException, Exception + { + userModel = dataUser.createRandomTestUser(); + userModel.setPassword("user wrong password"); + dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); + restClient.authenticateUser(userModel); + siteAPI.getAllSites(); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED.toString()); + } } From 8d46b77fb744643203e949e8c486000551d3704c Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Tue, 27 Sep 2016 16:40:12 +0300 Subject: [PATCH 0075/1491] TAS-864 admin gets comment created by another user --- .../GetCommentsSanityTest.java} | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) rename e2e-test/java/org/alfresco/rest/{GetCommentsTest.java => comments/GetCommentsSanityTest.java} (82%) diff --git a/e2e-test/java/org/alfresco/rest/GetCommentsTest.java b/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTest.java similarity index 82% rename from e2e-test/java/org/alfresco/rest/GetCommentsTest.java rename to e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTest.java index 027cb3db7..d2e81797d 100644 --- a/e2e-test/java/org/alfresco/rest/GetCommentsTest.java +++ b/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTest.java @@ -1,9 +1,10 @@ -package org.alfresco.rest; +package org.alfresco.rest.comments; import java.util.Arrays; import java.util.HashMap; import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.requests.RestCommentsApi; import org.alfresco.utility.data.DataUser; @@ -19,7 +20,7 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @Test(groups = { "rest-api", "comments", "sanity" }) -public class GetCommentsTest extends RestTest +public class GetCommentsSanityTest extends RestTest { @Autowired RestCommentsApi commentsAPI; @@ -95,13 +96,10 @@ public class GetCommentsTest extends RestTest description= "Verify Manager user gets status code 401 if authentication call fails") public void managerIsNotAbleToRetrieveCommentIfAuthenticationFails() throws JsonToModelConversionException, Exception { - userModel = usersWithRoles.get(UserRole.SiteManager); - userModel.setPassword("incorrectPassword"); - restClient.authenticateUser(userModel); + UserModel nonexistentModel = new UserModel("nonexistentUser", "nonexistentPassword"); + restClient.authenticateUser(nonexistentModel); commentsAPI.getNodeComments(document.getNodeRef()); commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED.toString()); - userModel.setPassword("password"); - restClient.authenticateUser(userModel); } @TestRail(section={"rest-api", "comments"}, executionType= ExecutionType.SANITY, @@ -116,4 +114,17 @@ public class GetCommentsTest extends RestTest commentsAPI.getNodeComments(document.getNodeRef()); commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); } + + @TestRail(section={"rest-api", "comments"}, executionType= ExecutionType.SANITY, + description= "Verify admin user gets comments created by another user and status code is 200") + public void adminIsAbleToRetrieveCommentsCreatedByAnotherUser() throws JsonToModelConversionException, Exception + { + userModel = usersWithRoles.get(UserRole.SiteCollaborator); + restClient.authenticateUser(userModel); + commentsAPI.addComment(document.getNodeRef(), "This is a new comment added by " + userModel.getUsername()); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED.toString()); + restClient.authenticateUser(adminUserModel); + commentsAPI.getNodeComments(document.getNodeRef()); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + } } From 129a80cfa528420d34f63a8166c4e27a75f23686 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Wed, 28 Sep 2016 09:27:40 +0300 Subject: [PATCH 0076/1491] TAS-901 addComment with Collaborator --- e2e-test/java/org/alfresco/rest/PostCommentsTest.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/PostCommentsTest.java b/e2e-test/java/org/alfresco/rest/PostCommentsTest.java index d4cb16cee..bcd4cdfda 100644 --- a/e2e-test/java/org/alfresco/rest/PostCommentsTest.java +++ b/e2e-test/java/org/alfresco/rest/PostCommentsTest.java @@ -68,5 +68,14 @@ public class PostCommentsTest extends RestTest commentsAPI.addComment(document.getNodeRef(), "This is a new comment added by user with role" + UserRole.SiteContributor); commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED.toString()); } + + @TestRail(section={"rest-api", "comments"}, executionType= ExecutionType.SANITY, + description= "Verify Collaborator user adds comments with Rest API and status code is 201") + public void collaboratorIsAbleToAddComment() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.get(UserRole.SiteCollaborator)); + commentsAPI.addComment(document.getNodeRef(), "This is a new comment added by user with role: " + UserRole.SiteCollaborator); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED.toString()); + } } From 753f3989f5b0cf52e3b4a9846b7b83dfa81860fa Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Wed, 28 Sep 2016 09:29:42 +0300 Subject: [PATCH 0077/1491] TAS-902 postComment with Consumer --- e2e-test/java/org/alfresco/rest/PostCommentsTest.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/PostCommentsTest.java b/e2e-test/java/org/alfresco/rest/PostCommentsTest.java index bcd4cdfda..d73595935 100644 --- a/e2e-test/java/org/alfresco/rest/PostCommentsTest.java +++ b/e2e-test/java/org/alfresco/rest/PostCommentsTest.java @@ -77,5 +77,14 @@ public class PostCommentsTest extends RestTest commentsAPI.addComment(document.getNodeRef(), "This is a new comment added by user with role: " + UserRole.SiteCollaborator); commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED.toString()); } + + @TestRail(section={"rest-api", "comments"}, executionType= ExecutionType.SANITY, + description= "Verify Consumer user adds comments with Rest API and status code is 201") + public void consumerIsAbleToAddComment() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.get(UserRole.SiteConsumer)); + commentsAPI.addComment(document.getNodeRef(), "This is a new comment added by user with role: " + UserRole.SiteConsumer); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN.toString()); + } } From 0bd1d1a85bec1eff05af1173ce8d4cee49498a8e Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Wed, 28 Sep 2016 10:25:48 +0300 Subject: [PATCH 0078/1491] TAS-904 failed authentication call returns status code 401 with Manager role --- .../java/org/alfresco/rest/PostCommentsTest.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/PostCommentsTest.java b/e2e-test/java/org/alfresco/rest/PostCommentsTest.java index d73595935..b0cdb3a03 100644 --- a/e2e-test/java/org/alfresco/rest/PostCommentsTest.java +++ b/e2e-test/java/org/alfresco/rest/PostCommentsTest.java @@ -1,4 +1,4 @@ -package org.alfresco.rest; +package org.alfresco.rest.comments; import java.util.Arrays; import java.util.HashMap; @@ -86,5 +86,15 @@ public class PostCommentsTest extends RestTest commentsAPI.addComment(document.getNodeRef(), "This is a new comment added by user with role: " + UserRole.SiteConsumer); commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN.toString()); } + + @TestRail(section = { "rest-api", + "comments" }, executionType = ExecutionType.SANITY, description = "Verify Manager user gets status code 401 if authentication call fails") + public void managerIsNotAbleToAddCommentIfAuthenticationFails() throws JsonToModelConversionException, Exception + { + usersWithRoles.get(UserRole.SiteManager).setPassword("wrongPassword"); + restClient.authenticateUser(usersWithRoles.get(UserRole.SiteManager)); + commentsAPI.addComment(document.getNodeRef(), "This is a new comment added by user with role: " + UserRole.SiteManager); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED.toString()); + } } From da9463dfd6e0f1cd4c9a976af6b1171e47e934fe Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Wed, 28 Sep 2016 10:36:03 +0300 Subject: [PATCH 0079/1491] Renamed PostCommentsTest to PostCommentsSanityTest --- .../PostCommentsSanityTest.java} | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) rename e2e-test/java/org/alfresco/rest/{PostCommentsTest.java => comments/PostCommentsSanityTest.java} (96%) diff --git a/e2e-test/java/org/alfresco/rest/PostCommentsTest.java b/e2e-test/java/org/alfresco/rest/comments/PostCommentsSanityTest.java similarity index 96% rename from e2e-test/java/org/alfresco/rest/PostCommentsTest.java rename to e2e-test/java/org/alfresco/rest/comments/PostCommentsSanityTest.java index b0cdb3a03..fa884f8eb 100644 --- a/e2e-test/java/org/alfresco/rest/PostCommentsTest.java +++ b/e2e-test/java/org/alfresco/rest/comments/PostCommentsSanityTest.java @@ -4,6 +4,7 @@ import java.util.Arrays; import java.util.HashMap; import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.requests.RestCommentsApi; import org.alfresco.utility.data.DataUser; @@ -19,7 +20,7 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @Test(groups = { "rest-api", "comments", "sanity" }) -public class PostCommentsTest extends RestTest +public class PostCommentsSanityTest extends RestTest { @Autowired RestCommentsApi commentsAPI; From cff30d3f5bd1c5b6a97634c0530ff2ac97b32969 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Wed, 28 Sep 2016 12:28:48 +0300 Subject: [PATCH 0080/1491] update imports on contants --- e2e-test/java/org/alfresco/rest/GetSiteSanityTests.java | 2 +- e2e-test/java/org/alfresco/rest/GetSitesSanityTests.java | 2 +- e2e-test/java/org/alfresco/rest/GetSitesTests.java | 2 +- .../java/org/alfresco/rest/comments/GetCommentsSanityTest.java | 2 +- .../alfresco/rest/sites/AddSiteMembershipRequestSanityTest.java | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/GetSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/GetSiteSanityTests.java index 32076dc28..e96d59e3f 100644 --- a/e2e-test/java/org/alfresco/rest/GetSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/GetSiteSanityTests.java @@ -5,9 +5,9 @@ import java.util.HashMap; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.requests.RestSitesApi; +import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataSite; import org.alfresco.utility.data.DataUser; -import org.alfresco.utility.data.UserRole; import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; diff --git a/e2e-test/java/org/alfresco/rest/GetSitesSanityTests.java b/e2e-test/java/org/alfresco/rest/GetSitesSanityTests.java index 610954b34..bf783d99b 100644 --- a/e2e-test/java/org/alfresco/rest/GetSitesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/GetSitesSanityTests.java @@ -5,9 +5,9 @@ import java.util.HashMap; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.requests.RestSitesApi; +import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataSite; import org.alfresco.utility.data.DataUser; -import org.alfresco.utility.data.UserRole; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; diff --git a/e2e-test/java/org/alfresco/rest/GetSitesTests.java b/e2e-test/java/org/alfresco/rest/GetSitesTests.java index e1e38d290..7a594bbdb 100644 --- a/e2e-test/java/org/alfresco/rest/GetSitesTests.java +++ b/e2e-test/java/org/alfresco/rest/GetSitesTests.java @@ -5,9 +5,9 @@ import java.util.HashMap; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.requests.RestSitesApi; +import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataSite; import org.alfresco.utility.data.DataUser; -import org.alfresco.utility.data.UserRole; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; diff --git a/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTest.java b/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTest.java index d2e81797d..c57e55d23 100644 --- a/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTest.java +++ b/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTest.java @@ -7,8 +7,8 @@ import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.requests.RestCommentsApi; +import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; -import org.alfresco.utility.data.UserRole; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; diff --git a/e2e-test/java/org/alfresco/rest/sites/AddSiteMembershipRequestSanityTest.java b/e2e-test/java/org/alfresco/rest/sites/AddSiteMembershipRequestSanityTest.java index fd01119d8..f47f6de31 100644 --- a/e2e-test/java/org/alfresco/rest/sites/AddSiteMembershipRequestSanityTest.java +++ b/e2e-test/java/org/alfresco/rest/sites/AddSiteMembershipRequestSanityTest.java @@ -7,9 +7,9 @@ import org.alfresco.rest.RestTest; import org.alfresco.rest.body.SiteMembership; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.requests.RestSitesApi; +import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataSite; import org.alfresco.utility.data.DataUser; -import org.alfresco.utility.data.UserRole; import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; From 6f43b2b6ad0b1504eab90ba4c9b1f12e3e4348a4 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Wed, 28 Sep 2016 13:39:14 +0300 Subject: [PATCH 0081/1491] TAS-903 updateComment with admin --- .../rest/comments/UpdateCommentsTest.java | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/comments/UpdateCommentsTest.java diff --git a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsTest.java b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsTest.java new file mode 100644 index 000000000..7e0d3dd0e --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsTest.java @@ -0,0 +1,53 @@ +package org.alfresco.rest.comments; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestCommentModel; +import org.alfresco.rest.requests.RestCommentsApi; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +@Test(groups = { "rest-api", "comments", "sanity" }) +public class UpdateCommentsTest extends RestTest +{ + + @Autowired + RestCommentsApi commentsAPI; + + @Autowired + DataUser dataUser; + + private UserModel adminUserModel; + private FileModel document; + private SiteModel siteModel; + private RestCommentModel commentModel; + + @BeforeClass + public void initTest() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + restClient.authenticateUser(adminUserModel); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + commentsAPI.useRestClient(restClient); + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + commentModel = commentsAPI.addComment(document.getNodeRef(), "This is a new comment"); + } + + @TestRail(section = { "rest-api", + "comments" }, executionType = ExecutionType.SANITY, description = "Verify Admin user updates comments with Rest API and status code is 200") + public void adminIsAbleToUpdateComments() throws JsonToModelConversionException, Exception + { + commentsAPI.updateComment(document.getNodeRef(), commentModel.getId(), commentModel.getContent()); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + } + +} From 4e133b2a921fc31788319a985e461e276b9e4b6c Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Wed, 28 Sep 2016 13:42:17 +0300 Subject: [PATCH 0082/1491] TAS-926 updateComment with Manager --- ...Test.java => UpdateCommentsSanityTest.java} | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) rename e2e-test/java/org/alfresco/rest/comments/{UpdateCommentsTest.java => UpdateCommentsSanityTest.java} (65%) diff --git a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsTest.java b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTest.java similarity index 65% rename from e2e-test/java/org/alfresco/rest/comments/UpdateCommentsTest.java rename to e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTest.java index 7e0d3dd0e..c9db75e0e 100644 --- a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsTest.java +++ b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTest.java @@ -1,10 +1,14 @@ package org.alfresco.rest.comments; +import java.util.Arrays; +import java.util.HashMap; + import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestCommentModel; import org.alfresco.rest.requests.RestCommentsApi; +import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; @@ -17,7 +21,7 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @Test(groups = { "rest-api", "comments", "sanity" }) -public class UpdateCommentsTest extends RestTest +public class UpdateCommentsSanityTest extends RestTest { @Autowired @@ -30,6 +34,7 @@ public class UpdateCommentsTest extends RestTest private FileModel document; private SiteModel siteModel; private RestCommentModel commentModel; + private HashMap usersWithRoles; @BeforeClass public void initTest() throws Exception @@ -40,6 +45,8 @@ public class UpdateCommentsTest extends RestTest commentsAPI.useRestClient(restClient); document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); commentModel = commentsAPI.addComment(document.getNodeRef(), "This is a new comment"); + + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, Arrays.asList(UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor)); } @TestRail(section = { "rest-api", @@ -49,5 +56,14 @@ public class UpdateCommentsTest extends RestTest commentsAPI.updateComment(document.getNodeRef(), commentModel.getId(), commentModel.getContent()); commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); } + + @TestRail(section={"rest-api", "comments"}, executionType= ExecutionType.SANITY, + description= "Verify Manager user updates comments created by admin user with Rest API and status code is 200") + public void managerIsAbleToUpdateComment() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.get(UserRole.SiteManager)); + commentsAPI.updateComment(document.getNodeRef(), commentModel.getId(), commentModel.getContent()); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + } } From d5ca004407ebf62ce88517eee8fcb6865100e0cf Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Wed, 28 Sep 2016 13:43:46 +0300 Subject: [PATCH 0083/1491] TAS-928 --- .../comments/UpdateCommentsSanityTest.java | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTest.java b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTest.java index c9db75e0e..551e26dfe 100644 --- a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTest.java +++ b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTest.java @@ -45,8 +45,9 @@ public class UpdateCommentsSanityTest extends RestTest commentsAPI.useRestClient(restClient); document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); commentModel = commentsAPI.addComment(document.getNodeRef(), "This is a new comment"); - - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, Arrays.asList(UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor)); + + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, + Arrays.asList(UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor)); } @TestRail(section = { "rest-api", @@ -56,9 +57,9 @@ public class UpdateCommentsSanityTest extends RestTest commentsAPI.updateComment(document.getNodeRef(), commentModel.getId(), commentModel.getContent()); commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); } - - @TestRail(section={"rest-api", "comments"}, executionType= ExecutionType.SANITY, - description= "Verify Manager user updates comments created by admin user with Rest API and status code is 200") + + @TestRail(section = { "rest-api", + "comments" }, executionType = ExecutionType.SANITY, description = "Verify Manager user updates comments created by admin user with Rest API and status code is 200") public void managerIsAbleToUpdateComment() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.get(UserRole.SiteManager)); @@ -66,4 +67,13 @@ public class UpdateCommentsSanityTest extends RestTest commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); } + @TestRail(section = { "rest-api", + "comments" }, executionType = ExecutionType.SANITY, description = "Verify Contributor user updates comments created by admin user with Rest API and status code is 200") + public void contributorIsAbleToUpdateComment() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.get(UserRole.SiteContributor)); + commentsAPI.updateComment(document.getNodeRef(), commentModel.getId(), "This is the updated comment with Contributor user"); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN.toString()); + } + } From cffdbe4a4e71cd08c3104bdeb1529ce2b18c9c32 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Wed, 28 Sep 2016 13:45:02 +0300 Subject: [PATCH 0084/1491] TAS-929 updateComment with Consumer --- .../alfresco/rest/comments/UpdateCommentsSanityTest.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTest.java b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTest.java index 551e26dfe..8281cd17b 100644 --- a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTest.java +++ b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTest.java @@ -76,4 +76,13 @@ public class UpdateCommentsSanityTest extends RestTest commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN.toString()); } + @TestRail(section = { "rest-api", + "comments" }, executionType = ExecutionType.SANITY, description = "Verify Consumer user updates comments created by admin user with Rest API and status code is 200") + public void consumerIsAbleToUpdateComment() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.get(UserRole.SiteConsumer)); + commentsAPI.updateComment(document.getNodeRef(), commentModel.getId(), commentModel.getContent()); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN.toString()); + } + } From ea16b55f5b5af85d42eab1f74567994347eacd3a Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Wed, 28 Sep 2016 13:54:14 +0300 Subject: [PATCH 0085/1491] Fix response handling in case of failure, add some small fixes --- .../java/org/alfresco/rest/GetSitesTests.java | 107 ------------------ .../rest/comments/GetCommentsSanityTest.java | 3 +- .../org/alfresco/rest/demo/RestDemoTest.java | 6 +- .../rest/{ => sites}/GetSiteSanityTests.java | 11 +- .../rest/{ => sites}/GetSitesSanityTests.java | 28 +++-- 5 files changed, 22 insertions(+), 133 deletions(-) delete mode 100644 e2e-test/java/org/alfresco/rest/GetSitesTests.java rename e2e-test/java/org/alfresco/rest/{ => sites}/GetSiteSanityTests.java (95%) rename e2e-test/java/org/alfresco/rest/{ => sites}/GetSitesSanityTests.java (80%) diff --git a/e2e-test/java/org/alfresco/rest/GetSitesTests.java b/e2e-test/java/org/alfresco/rest/GetSitesTests.java deleted file mode 100644 index e1e38d290..000000000 --- a/e2e-test/java/org/alfresco/rest/GetSitesTests.java +++ /dev/null @@ -1,107 +0,0 @@ -package org.alfresco.rest; - -import java.util.Arrays; -import java.util.HashMap; - -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.requests.RestSitesApi; -import org.alfresco.utility.data.DataSite; -import org.alfresco.utility.data.DataUser; -import org.alfresco.utility.data.UserRole; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * @author iulia.cojocea - */ -@Test(groups = { "rest-api", "comments", "sanity" }) -public class GetSitesTests extends RestTest -{ - @Autowired - RestSitesApi siteAPI; - - @Autowired - DataUser dataUser; - - @Autowired - DataSite dataSite; - - private UserModel adminUserModel; - private UserModel userModel; - private HashMap usersWithRoles; - private SiteModel siteModel; - - @BeforeClass - public void initTest() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - restClient.authenticateUser(adminUserModel); - siteAPI.useRestClient(restClient); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, - Arrays.asList(UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor)); - - } - - @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role gets sites information and gets status code OK (200)") - public void getSitesWithManagerRole() throws JsonToModelConversionException, Exception - { - - restClient.authenticateUser(usersWithRoles.get(UserRole.SiteManager)); - siteAPI.getAllSites(); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); - } - - @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify user with Collaborator role gets sites information and gets status code OK (200)") - public void getSitesWithCollaboratorRole() throws JsonToModelConversionException, Exception - { - - restClient.authenticateUser(usersWithRoles.get(UserRole.SiteCollaborator)); - siteAPI.getAllSites(); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); - } - - @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify user with Contributor role gets sites information and gets status code OK (200)") - public void getSitesWithContributorRole() throws JsonToModelConversionException, Exception - { - - restClient.authenticateUser(usersWithRoles.get(UserRole.SiteContributor)); - siteAPI.getAllSites(); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); - } - - @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role gets sites information and gets status code OK (200)") - public void getSitesWithConsumerRole() throws JsonToModelConversionException, Exception - { - - restClient.authenticateUser(usersWithRoles.get(UserRole.SiteConsumer)); - siteAPI.getAllSites(); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); - } - - @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify user with Admin user gets sites information and gets status code OK (200)") - public void getSitesWithAdminUser() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel); - siteAPI.getAllSites(); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); - } - - @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Failed authentication get sites call returns status code 401 with Manager role") - public void getSitesWithManagerRoleFailedAuth() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.get(UserRole.SiteManager)); - userModel = dataUser.createRandomTestUser(); - userModel.setPassword("user wrong password"); - dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); - restClient.authenticateUser(userModel); - siteAPI.getAllSites(); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED.toString()); - } -} diff --git a/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTest.java b/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTest.java index d2e81797d..1f1ed3616 100644 --- a/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTest.java +++ b/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTest.java @@ -45,7 +45,8 @@ public class GetCommentsSanityTest extends RestTest document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); commentsAPI.addComment(document.getNodeRef(), "This is a new comment"); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, Arrays.asList(UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor)); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, + Arrays.asList(UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor)); } @TestRail(section={"rest-api", "comments"}, executionType= ExecutionType.SANITY, diff --git a/e2e-test/java/org/alfresco/rest/demo/RestDemoTest.java b/e2e-test/java/org/alfresco/rest/demo/RestDemoTest.java index 6a3fea0e6..e63510935 100644 --- a/e2e-test/java/org/alfresco/rest/demo/RestDemoTest.java +++ b/e2e-test/java/org/alfresco/rest/demo/RestDemoTest.java @@ -9,7 +9,6 @@ import org.alfresco.rest.requests.RestCommentsApi; import org.alfresco.rest.requests.RestSitesApi; import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; import org.springframework.beans.factory.annotation.Autowired; @@ -71,9 +70,8 @@ public class RestDemoTest extends RestTest @Test public void adminCanPostAndUpdateComments() throws Exception { - FileModel fileModel = dataContent.usingResource(new FolderModel("Shared")) - .usingUser(userModel) - .createContent(DocumentType.TEXT_PLAIN); + FileModel fileModel = dataContent.usingUser(userModel).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + // add new comment RestCommentModel commentEntry = commentsAPI.addComment(fileModel.getNodeRef(), "This is a new comment"); commentsAPI.getNodeComments(fileModel.getNodeRef()) diff --git a/e2e-test/java/org/alfresco/rest/GetSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteSanityTests.java similarity index 95% rename from e2e-test/java/org/alfresco/rest/GetSiteSanityTests.java rename to e2e-test/java/org/alfresco/rest/sites/GetSiteSanityTests.java index 32076dc28..324adbe5e 100644 --- a/e2e-test/java/org/alfresco/rest/GetSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteSanityTests.java @@ -1,8 +1,9 @@ -package org.alfresco.rest; +package org.alfresco.rest.sites; import java.util.Arrays; import java.util.HashMap; +import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.requests.RestSitesApi; import org.alfresco.utility.data.DataSite; @@ -21,7 +22,6 @@ import org.testng.annotations.Test; /** * @author iulia.cojocea */ - @Test(groups = { "rest-api", "sites", "sanity" }) public class GetSiteSanityTests extends RestTest { @@ -44,7 +44,6 @@ public class GetSiteSanityTests extends RestTest public void initTest() throws DataPreparationException { adminUserModel = dataUser.getAdminUser(); - restClient.authenticateUser(adminUserModel); siteAPI.useRestClient(restClient); siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, @@ -88,7 +87,7 @@ public class GetSiteSanityTests extends RestTest } @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, - description = "Verify user with admin role gets site information and gets status code OK (200)") + description = "Verify admin user gets site information and gets status code OK (200)") public void getSiteWithAdminRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); @@ -97,7 +96,7 @@ public class GetSiteSanityTests extends RestTest } @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, - description = "Failed authentication get site call returns status code 401 with Manager role") + description = "Failed authentication get site call returns status code 401") public void getSiteWithManagerRoleFailedAuth() throws JsonToModelConversionException, Exception { userModel = dataUser.createRandomTestUser(); @@ -107,4 +106,4 @@ public class GetSiteSanityTests extends RestTest siteAPI.getAllSites(); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED.toString()); } -} +} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/GetSitesSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java similarity index 80% rename from e2e-test/java/org/alfresco/rest/GetSitesSanityTests.java rename to e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java index 610954b34..abcb146ee 100644 --- a/e2e-test/java/org/alfresco/rest/GetSitesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java @@ -1,8 +1,9 @@ -package org.alfresco.rest; +package org.alfresco.rest.sites; import java.util.Arrays; import java.util.HashMap; +import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.requests.RestSitesApi; import org.alfresco.utility.data.DataSite; @@ -48,10 +49,10 @@ public class GetSitesSanityTests extends RestTest Arrays.asList(UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor)); } - @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role gets sites information and gets status code OK (200)") - public void getSitesWithManagerRole() throws JsonToModelConversionException, Exception + @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, + description = "Verify user with Manager role gets sites information and gets status code OK (200)") + public void managerIsAbleToRetrieveSites() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.get(UserRole.SiteManager)); siteAPI.getAllSites(); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); @@ -59,9 +60,8 @@ public class GetSitesSanityTests extends RestTest @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify user with Collaborator role gets sites information and gets status code OK (200)") - public void getSitesWithCollaboratorRole() throws JsonToModelConversionException, Exception + public void collaboratorIsAbleToRetrieveSites() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.get(UserRole.SiteCollaborator)); siteAPI.getAllSites(); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); @@ -69,9 +69,8 @@ public class GetSitesSanityTests extends RestTest @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify user with Contributor role gets sites information and gets status code OK (200)") - public void getSitesWithContributorRole() throws JsonToModelConversionException, Exception + public void contributorIsAbleToRetrieveSites() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.get(UserRole.SiteContributor)); siteAPI.getAllSites(); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); @@ -79,17 +78,16 @@ public class GetSitesSanityTests extends RestTest @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role gets sites information and gets status code OK (200)") - public void getSitesWithConsumerRole() throws JsonToModelConversionException, Exception + public void consumerIsAbleToRetrieveSites() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.get(UserRole.SiteConsumer)); siteAPI.getAllSites(); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); } @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, - description = "Verify user with Admin user gets sites information and gets status code OK (200)") - public void getSitesWithAdminUser() throws JsonToModelConversionException, Exception + description = "Verify admin user gets sites information and gets status code OK (200)") + public void adminUserIsAbleToRetrieveSites() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); siteAPI.getAllSites(); @@ -97,8 +95,8 @@ public class GetSitesSanityTests extends RestTest } @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, - description = "Failed authentication get sites call returns status code 401 with Manager role") - public void getSitesWithManagerRoleFailedAuth() throws JsonToModelConversionException, Exception + description = "Failed authentication on get sites call returns status code 401") + public void unauthenticatedUserIsNotAuthorizedToRetrieveSites() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.get(UserRole.SiteManager)); userModel = dataUser.createRandomTestUser(); @@ -108,4 +106,4 @@ public class GetSitesSanityTests extends RestTest siteAPI.getAllSites(); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED.toString()); } -} +} \ No newline at end of file From 0b5f85bee25ff0780662f1f97ccc33dc5a307062 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Wed, 28 Sep 2016 15:21:25 +0300 Subject: [PATCH 0086/1491] Merge branch 'TAS-925' of https://gitlab.alfresco.com/tas/alfresco-tas-restapi-test into TAS-925 --- .../java/org/alfresco/rest/comments/GetCommentsSanityTest.java | 2 +- .../alfresco/rest/sites/AddSiteMembershipRequestSanityTest.java | 2 +- e2e-test/java/org/alfresco/rest/sites/GetSiteSanityTests.java | 2 +- e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTest.java b/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTest.java index 1f1ed3616..e748aafb3 100644 --- a/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTest.java +++ b/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTest.java @@ -7,8 +7,8 @@ import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.requests.RestCommentsApi; +import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; -import org.alfresco.utility.data.UserRole; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; diff --git a/e2e-test/java/org/alfresco/rest/sites/AddSiteMembershipRequestSanityTest.java b/e2e-test/java/org/alfresco/rest/sites/AddSiteMembershipRequestSanityTest.java index fd01119d8..f47f6de31 100644 --- a/e2e-test/java/org/alfresco/rest/sites/AddSiteMembershipRequestSanityTest.java +++ b/e2e-test/java/org/alfresco/rest/sites/AddSiteMembershipRequestSanityTest.java @@ -7,9 +7,9 @@ import org.alfresco.rest.RestTest; import org.alfresco.rest.body.SiteMembership; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.requests.RestSitesApi; +import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataSite; import org.alfresco.utility.data.DataUser; -import org.alfresco.utility.data.UserRole; import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteSanityTests.java index 324adbe5e..5f6043f19 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteSanityTests.java @@ -6,9 +6,9 @@ import java.util.HashMap; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.requests.RestSitesApi; +import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataSite; import org.alfresco.utility.data.DataUser; -import org.alfresco.utility.data.UserRole; import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java index abcb146ee..a0cbe1865 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java @@ -6,9 +6,9 @@ import java.util.HashMap; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.requests.RestSitesApi; +import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataSite; import org.alfresco.utility.data.DataUser; -import org.alfresco.utility.data.UserRole; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; From 2ab9812299725d2137daee0886ab3c15e5b3fa53 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Wed, 28 Sep 2016 15:32:02 +0300 Subject: [PATCH 0087/1491] TAS-917 - REST API - failed authentication call returns status code 401 --- .../AddSiteMembershipRequestSanityTest.java | 4 ++-- .../GetSiteMembershipInformationSanityTest.java | 17 +++++++++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/sites/AddSiteMembershipRequestSanityTest.java b/e2e-test/java/org/alfresco/rest/sites/AddSiteMembershipRequestSanityTest.java index 36183ed72..161382860 100644 --- a/e2e-test/java/org/alfresco/rest/sites/AddSiteMembershipRequestSanityTest.java +++ b/e2e-test/java/org/alfresco/rest/sites/AddSiteMembershipRequestSanityTest.java @@ -7,9 +7,9 @@ import org.alfresco.rest.RestTest; import org.alfresco.rest.body.SiteMembership; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.requests.RestSitesApi; +import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataSite; import org.alfresco.utility.data.DataUser; -import org.alfresco.utility.data.UserRole; import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; @@ -42,7 +42,7 @@ public class AddSiteMembershipRequestSanityTest extends RestTest { adminUser = dataUser.getAdminUser(); siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); - usersWithRoles = dataUser.addUsersToSiteWithRoles(siteModel, + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, Arrays.asList(UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor)); siteAPI.useRestClient(restClient); diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembershipInformationSanityTest.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembershipInformationSanityTest.java index 2437bdffa..e395d0177 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembershipInformationSanityTest.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembershipInformationSanityTest.java @@ -6,9 +6,10 @@ import java.util.HashMap; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.requests.RestSitesApi; +import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataSite; import org.alfresco.utility.data.DataUser; -import org.alfresco.utility.data.UserRole; +import org.alfresco.utility.data.TestData; import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; @@ -40,7 +41,7 @@ public class GetSiteMembershipInformationSanityTest extends RestTest { adminUser = dataUser.getAdminUser(); siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); - usersWithRoles = dataUser.addUsersToSiteWithRoles(siteModel, + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, Arrays.asList(UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor)); siteAPI.useRestClient(restClient); @@ -100,5 +101,17 @@ public class GetSiteMembershipInformationSanityTest extends RestTest siteAPI.usingRestWrapper() .assertStatusCodeIs(HttpStatus.OK.toString()); } + + @TestRail(section = { "rest-api", "sites" }, + executionType = ExecutionType.SANITY, + description = "Verify that unauthenticated user is not able to retrieve site membership information") + public void unauthenticatedUserCannotRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception + { + UserModel inexistentUser = new UserModel("inexistent user", "wrong password"); + restClient.authenticateUser(inexistentUser); + siteAPI.getSiteMembershipInformation(usersWithRoles.get(UserRole.SiteManager).getUsername()); + siteAPI.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.UNAUTHORIZED.toString()); + } } \ No newline at end of file From 5db79de2f5518107964690f3506c52a433fcc62b Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Wed, 28 Sep 2016 15:37:42 +0300 Subject: [PATCH 0088/1491] TAS-931 failed authentication call returns status code 401 with Manager role --- .../rest/comments/UpdateCommentsSanityTest.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTest.java b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTest.java index 8281cd17b..379d8cf51 100644 --- a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTest.java +++ b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTest.java @@ -85,4 +85,14 @@ public class UpdateCommentsSanityTest extends RestTest commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN.toString()); } + @TestRail(section = { "rest-api", + "comments" }, executionType = ExecutionType.SANITY, description = "Verify Manager user gets status code 401 if authentication call fails") + public void managerIsNotAbleToUpdateCommentIfAuthenticationFails() throws JsonToModelConversionException, Exception + { + UserModel incorrectUserModel = new UserModel("userName", "password"); + restClient.authenticateUser(incorrectUserModel); + commentsAPI.getNodeComments(document.getNodeRef()); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED.toString()); + } + } From 3d6f93d2357c908dd8842ca124af0d2faaf76799 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Wed, 28 Sep 2016 15:43:59 +0300 Subject: [PATCH 0089/1491] TAS-932 status 404 if nodeId doesn not exist --- .../alfresco/rest/comments/UpdateCommentsSanityTest.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTest.java b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTest.java index 379d8cf51..f982b4136 100644 --- a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTest.java +++ b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTest.java @@ -94,5 +94,14 @@ public class UpdateCommentsSanityTest extends RestTest commentsAPI.getNodeComments(document.getNodeRef()); commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED.toString()); } + + @TestRail(section={"rest-api", "comments"}, executionType= ExecutionType.SANITY, + description= "Verify if nodeId is not set the status code is 404") + public void canNotUpdateCommentIfNodeIdIsNotSet() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel); + commentsAPI.updateComment("unexistingId", commentModel.getId(), commentModel.getContent()); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND.toString()); + } } From c7091d7f2a7461f8c28853b645aa4ae1ec65fd20 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Wed, 28 Sep 2016 15:44:51 +0300 Subject: [PATCH 0090/1491] TAS-933 status 404 if commentId does not exist --- .../alfresco/rest/comments/UpdateCommentsSanityTest.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTest.java b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTest.java index f982b4136..fe79d5cbd 100644 --- a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTest.java +++ b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTest.java @@ -103,5 +103,14 @@ public class UpdateCommentsSanityTest extends RestTest commentsAPI.updateComment("unexistingId", commentModel.getId(), commentModel.getContent()); commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND.toString()); } + + @TestRail(section={"rest-api", "comments"}, executionType= ExecutionType.SANITY, + description= "Verify if commentId is not set the status code is 404") + public void canNotUpdateCommentIfCommentIdIsNotSet() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel); + commentsAPI.updateComment(document.getNodeRef(), "unexistingId", commentModel.getContent()); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND.toString()); + } } From a65db3e70bd278f06025303996940ba5eb79ba4c Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Wed, 28 Sep 2016 15:46:11 +0300 Subject: [PATCH 0091/1491] TAS-927 updateComment with Collaborator --- .../rest/comments/UpdateCommentsSanityTest.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTest.java b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTest.java index fe79d5cbd..acbc78d8e 100644 --- a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTest.java +++ b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTest.java @@ -84,6 +84,16 @@ public class UpdateCommentsSanityTest extends RestTest commentsAPI.updateComment(document.getNodeRef(), commentModel.getId(), commentModel.getContent()); commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN.toString()); } + + @TestRail(section={"rest-api", "comments"}, executionType= ExecutionType.SANITY, + description= "Verify Collaborator user updates comments created by admin user with Rest API and status code is 200") + public void collaboratorIsAbleToUpdateComment() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.get(UserRole.SiteCollaborator)); + RestCommentModel commentEntry = commentsAPI.updateComment(document.getNodeRef(), commentModel.getId(), "This is the updated comment with Collaborator user"); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN.toString()); + commentEntry.assertCommentContentIs("This is the updated comment with Collaborator user"); + } @TestRail(section = { "rest-api", "comments" }, executionType = ExecutionType.SANITY, description = "Verify Manager user gets status code 401 if authentication call fails") From c1b62b69292a3093cad233c2a5e772a8e154af13 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Wed, 28 Sep 2016 16:07:10 +0300 Subject: [PATCH 0092/1491] Formatting the code --- .../comments/UpdateCommentsSanityTest.java | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTest.java b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTest.java index acbc78d8e..1c141f75b 100644 --- a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTest.java +++ b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTest.java @@ -84,13 +84,14 @@ public class UpdateCommentsSanityTest extends RestTest commentsAPI.updateComment(document.getNodeRef(), commentModel.getId(), commentModel.getContent()); commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN.toString()); } - - @TestRail(section={"rest-api", "comments"}, executionType= ExecutionType.SANITY, - description= "Verify Collaborator user updates comments created by admin user with Rest API and status code is 200") + + @TestRail(section = { "rest-api", + "comments" }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user updates comments created by admin user with Rest API and status code is 200") public void collaboratorIsAbleToUpdateComment() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.get(UserRole.SiteCollaborator)); - RestCommentModel commentEntry = commentsAPI.updateComment(document.getNodeRef(), commentModel.getId(), "This is the updated comment with Collaborator user"); + RestCommentModel commentEntry = commentsAPI.updateComment(document.getNodeRef(), commentModel.getId(), + "This is the updated comment with Collaborator user"); commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN.toString()); commentEntry.assertCommentContentIs("This is the updated comment with Collaborator user"); } @@ -104,18 +105,16 @@ public class UpdateCommentsSanityTest extends RestTest commentsAPI.getNodeComments(document.getNodeRef()); commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED.toString()); } - - @TestRail(section={"rest-api", "comments"}, executionType= ExecutionType.SANITY, - description= "Verify if nodeId is not set the status code is 404") + + @TestRail(section = { "rest-api", "comments" }, executionType = ExecutionType.SANITY, description = "Verify if nodeId is not set the status code is 404") public void canNotUpdateCommentIfNodeIdIsNotSet() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); commentsAPI.updateComment("unexistingId", commentModel.getId(), commentModel.getContent()); commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND.toString()); } - - @TestRail(section={"rest-api", "comments"}, executionType= ExecutionType.SANITY, - description= "Verify if commentId is not set the status code is 404") + + @TestRail(section = { "rest-api", "comments" }, executionType = ExecutionType.SANITY, description = "Verify if commentId is not set the status code is 404") public void canNotUpdateCommentIfCommentIdIsNotSet() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); From 28d29d9225d62e47d5ea740a83560d6e4e86a918 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Wed, 28 Sep 2016 16:32:29 +0300 Subject: [PATCH 0093/1491] Added createTenant method to use it in dataPreparation of tests and updated dataPreparation accordingly --- .../rest/networks/RestGetNetworkTest.java | 101 ++++++++---------- e2e-test/resources/default.properties | 2 +- e2e-test/resources/sanity-rest.xml | 18 ++-- 3 files changed, 58 insertions(+), 63 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkTest.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkTest.java index 3167bc28f..2f812540d 100644 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkTest.java +++ b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkTest.java @@ -2,8 +2,8 @@ package org.alfresco.rest.networks; import org.alfresco.rest.RestTest; import org.alfresco.rest.requests.RestNetworksApi; -import org.alfresco.utility.data.UserRole; -import org.alfresco.utility.exception.DataPreparationException; +import org.alfresco.rest.requests.RestTenantApi; +import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; @@ -16,81 +16,85 @@ import org.testng.annotations.Test; /** * Created by Cristina Axinte on 9/26/2016. */ -@Test(groups = { "rest-api", "networks", "sanity" }) +@Test(groups = { "rest-api", "networks" }) public class RestGetNetworkTest extends RestTest { @Autowired RestNetworksApi networkApi; + @Autowired + RestTenantApi tenantApi; + UserModel adminTenantUser; UserModel tenantUser; UserModel managerTenantUser; UserModel collaboratorTenantUser; UserModel consumerTenantUser; UserModel contributorTenantUser; + String tenantName; + String anotherTenantName; - @BeforeClass - public void setup() throws DataPreparationException + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception { - // input data should be created for handle tenants: - // create tenant "tenant1" with password "password" + UserModel adminuser = dataUser.getAdminUser(); + adminTenantUser = UserModel.getAdminTenantUser(); + tenantName = adminTenantUser.getDomain(); - // with admin "admin@tenant1" create user "test1@tenant1" with password "password" - adminTenantUser = new UserModel("admin@tenant1", "password"); - tenantUser = new UserModel("test1@tenant1", "password"); -// managerTenantUser = dataUser.usingUser(adminTenantUser).createUser("manTenant2@tenant1"); -// collaboratorTenantUser = dataUser.usingUser(adminTenantUser).createUser("manTenant2@tenant1"); -// consumerTenantUser = dataUser.usingUser(adminTenantUser).createUser("manTenant2@tenant1"); -// contributorTenantUser = dataUser.usingUser(adminTenantUser).createUser("manTenant2@tenant1"); - managerTenantUser = new UserModel("manTenant@tenant1", "password"); - collaboratorTenantUser = new UserModel("colTenant@tenant1", "password"); - consumerTenantUser = new UserModel("consTenant@tenant1", "password"); - contributorTenantUser = new UserModel("contTenant@tenant1", "password"); - - SiteModel site=dataSite.usingUser(adminTenantUser).createPublicRandomSite(); + restClient.authenticateUser(adminuser); + tenantApi.useRestClient(restClient); + tenantApi.createTenant(adminTenantUser.getDomain()); + UserModel adminAnotherTenantUser = UserModel.getAdminTenantUser(); + anotherTenantName = adminAnotherTenantUser.getDomain(); + tenantApi.createTenant(anotherTenantName); + + tenantUser = dataUser.usingUser(adminTenantUser).createRandomTestUser("uTenant"); + managerTenantUser = dataUser.usingUser(adminTenantUser).createRandomTestUser("manTenant"); + collaboratorTenantUser = dataUser.usingUser(adminTenantUser).createRandomTestUser("colTenant"); + consumerTenantUser = dataUser.usingUser(adminTenantUser).createRandomTestUser("consTenant"); + contributorTenantUser = dataUser.usingUser(adminTenantUser).createRandomTestUser("contTenant"); + + SiteModel site = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); dataUser.usingUser(adminTenantUser).addUserToSite(managerTenantUser, site, UserRole.SiteManager); dataUser.usingUser(adminTenantUser).addUserToSite(collaboratorTenantUser, site, UserRole.SiteCollaborator); dataUser.usingUser(adminTenantUser).addUserToSite(consumerTenantUser, site, UserRole.SiteConsumer); dataUser.usingUser(adminTenantUser).addUserToSite(contributorTenantUser, site, UserRole.SiteConsumer); - + + networkApi.useRestClient(restClient); } + @Test(groups = "sanity") @TestRail(section = { "rest-api", "networks" }, executionType = ExecutionType.SANITY, description = "Verify non existing user gets another exisiting network with Rest API and checks the forbidden status") public void nonExistingTenantUserIsNotAuthorizedToRequest() throws Exception { - String tenantName = "tenant1"; - UserModel tenantUser = new UserModel("nonexisting@tenant1", "password"); + UserModel tenantUser = new UserModel("nonexisting", "password"); + tenantUser.setDomain(tenantName); restClient.authenticateUser(tenantUser); - networkApi.useRestClient(restClient); networkApi.getNetwork(tenantName); networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED.toString()); } + @Test(groups = "sanity") @TestRail(section = { "rest-api", "networks" }, executionType = ExecutionType.SANITY, description = "Verify tenant admin user gets specific network with Rest API and response is not empty") public void adminTenantChecksIfNetworkIsPresent() throws Exception { - String tenantName = "tenant1"; restClient.authenticateUser(adminTenantUser); - networkApi.useRestClient(restClient); - networkApi.getNetwork(tenantName); + networkApi.getNetwork(adminTenantUser.getDomain()); networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); } @TestRail(section = { "rest-api", "networks" }, executionType = ExecutionType.SANITY, description = "Verify tenant admin user gets specific network with Rest API and checks response parameters are correct") public void adminTenantChecksNetworkParamsAreCorrect() throws Exception { - String tenantName = "tenant1"; restClient.authenticateUser(adminTenantUser); - networkApi.useRestClient(restClient); networkApi.getNetwork(tenantName).assertNetworkHasName(tenantName).assertNetworkIsEnabled(true); } @TestRail(section = { "rest-api", "networks" }, executionType = ExecutionType.SANITY, description = "Verify tenant admin user gets non exisiting network with Rest API and checks the not found status") public void adminTenantChecksIfNonExistingNetworkIsNotFound() throws Exception { - String tenantName = "netenant"; + String tenantName = "notenant"; restClient.authenticateUser(adminTenantUser); - networkApi.useRestClient(restClient); networkApi.getNetwork(tenantName); networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND.toString()); } @@ -98,19 +102,15 @@ public class RestGetNetworkTest extends RestTest @TestRail(section = { "rest-api", "networks" }, executionType = ExecutionType.SANITY, description = "Verify tenant admin user gets another exisiting network with Rest API and checks the forbidden status") public void adminTenantChecksIfAnotherExistingNetworkIsForbidden() throws Exception { - String tenantName = "tenant2"; restClient.authenticateUser(adminTenantUser); - networkApi.useRestClient(restClient); - networkApi.getNetwork(tenantName); + networkApi.getNetwork(anotherTenantName); networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN.toString()); } @TestRail(section = { "rest-api", "networks" }, executionType = ExecutionType.SANITY, description = "Verify any tenant user gets its network with Rest API and response is not empty") public void userTenantChecksIfNetworkIsPresent() throws Exception { - String tenantName = "tenant1"; restClient.authenticateUser(tenantUser); - networkApi.useRestClient(restClient); networkApi.getNetwork(tenantName); networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); } @@ -118,18 +118,15 @@ public class RestGetNetworkTest extends RestTest @TestRail(section = { "rest-api", "networks" }, executionType = ExecutionType.SANITY, description = "Verify any tenant user gets specific network with Rest API and checks response parameters are correct") public void userTenantChecksNetworkParamsAreCorrect() throws Exception { - String tenantName = "tenant1"; restClient.authenticateUser(tenantUser); - networkApi.useRestClient(restClient); networkApi.getNetwork(tenantName).assertNetworkHasName(tenantName).assertNetworkIsEnabled(true); } @TestRail(section = { "rest-api", "networks" }, executionType = ExecutionType.SANITY, description = "Verify any tenant user gets non exisiting network with Rest API and checks the not found status") public void userTenantChecksIfNonExistingNetworkIsNotFound() throws Exception { - String tenantName = "netenant"; + String tenantName = "nontenant"; restClient.authenticateUser(tenantUser); - networkApi.useRestClient(restClient); networkApi.getNetwork(tenantName); networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND.toString()); } @@ -137,49 +134,43 @@ public class RestGetNetworkTest extends RestTest @TestRail(section = { "rest-api", "networks" }, executionType = ExecutionType.SANITY, description = "Verify any tenant user gets another exisiting network with Rest API and checks the forbidden status") public void userTenantChecksIfAnotherExistingNetworkIsForbidden() throws Exception { - String tenantName = "tenant2"; restClient.authenticateUser(tenantUser); - networkApi.useRestClient(restClient); - networkApi.getNetwork(tenantName); + networkApi.getNetwork(anotherTenantName); networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN.toString()); } - + + @Test(groups = "sanity") @TestRail(section = { "rest-api", "networks" }, executionType = ExecutionType.SANITY, description = "Verify manager tenant user gets its network with Rest API and response is not empty") public void tenantManagerUserChecksIfNetworkIsPresent() throws Exception { - String tenantName = "tenant1"; restClient.authenticateUser(managerTenantUser); - networkApi.useRestClient(restClient); networkApi.getNetwork(tenantName); networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); } - + + @Test(groups = "sanity") @TestRail(section = { "rest-api", "networks" }, executionType = ExecutionType.SANITY, description = "Verify collaborator tenant user gets its network with Rest API and response is not empty") public void tenantCollaboratorUserChecksIfNetworkIsPresent() throws Exception { - String tenantName = "tenant1"; restClient.authenticateUser(collaboratorTenantUser); - networkApi.useRestClient(restClient); networkApi.getNetwork(tenantName); networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); } - + + @Test(groups = "sanity") @TestRail(section = { "rest-api", "networks" }, executionType = ExecutionType.SANITY, description = "Verify consumer tenant user gets its network with Rest API and response is not empty") public void tenantConsumerUserChecksIfNetworkIsPresent() throws Exception { - String tenantName = "tenant1"; restClient.authenticateUser(consumerTenantUser); - networkApi.useRestClient(restClient); networkApi.getNetwork(tenantName); networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); } - + + @Test(groups = "sanity") @TestRail(section = { "rest-api", "networks" }, executionType = ExecutionType.SANITY, description = "Verify contributor tenant user gets its network with Rest API and response is not empty") public void tenantContributorUserChecksIfNetworkIsPresent() throws Exception { - String tenantName = "tenant1"; restClient.authenticateUser(contributorTenantUser); - networkApi.useRestClient(restClient); networkApi.getNetwork(tenantName); networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); } diff --git a/e2e-test/resources/default.properties b/e2e-test/resources/default.properties index 1ff526c0b..cc323e95e 100644 --- a/e2e-test/resources/default.properties +++ b/e2e-test/resources/default.properties @@ -8,7 +8,7 @@ admin.user=admin admin.password=admin # rest related -rest.basePath=alfresco/api/tenant1/public/alfresco/versions/1 +rest.basePath=alfresco/api/-default-/public/alfresco/versions/1 # TEST MANAGEMENT SECTION - Test Rail diff --git a/e2e-test/resources/sanity-rest.xml b/e2e-test/resources/sanity-rest.xml index 385353b4f..2bd3c3f62 100644 --- a/e2e-test/resources/sanity-rest.xml +++ b/e2e-test/resources/sanity-rest.xml @@ -3,15 +3,19 @@ - + - - - - - - + + + + + + + + + + From 8c5c6bc0a64ef72dddc465f153dd109c282da549 Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Wed, 28 Sep 2016 16:42:02 +0300 Subject: [PATCH 0094/1491] TAS-934 getSiteContainers with Manager role --- .../sites/GetSiteContainersSanityTests.java | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java new file mode 100644 index 000000000..6b1f0bb6a --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java @@ -0,0 +1,58 @@ +package org.alfresco.rest.sites; + +import java.util.Arrays; +import java.util.HashMap; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.requests.RestSitesApi; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataSite; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * @author iulia.cojocea + */ +@Test(groups = { "rest-api", "sites", "sanity" }) +public class GetSiteContainersSanityTests extends RestTest +{ + @Autowired + RestSitesApi siteAPI; + + @Autowired + DataUser dataUser; + + @Autowired + DataSite dataSite; + + private UserModel adminUserModel; + private SiteModel siteModel; + private HashMap usersWithRoles; + + @BeforeClass + public void initTest() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + siteAPI.useRestClient(restClient); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, + Arrays.asList(UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor)); + } + + @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, + description = "Verify user with Manager role gets site containers and gets status code OK (200)") + public void getSiteContainersWithManagerRole() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.get(UserRole.SiteManager)); + siteAPI.getSiteContainers(siteModel.getId()); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + } +} From b705ff908abc821b67df84d184da92439025a7de Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Wed, 28 Sep 2016 16:43:22 +0300 Subject: [PATCH 0095/1491] TAS-935 getSiteContainers with Collaborator role --- .../rest/sites/GetSiteContainersSanityTests.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java index 6b1f0bb6a..c80c74124 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java @@ -55,4 +55,13 @@ public class GetSiteContainersSanityTests extends RestTest siteAPI.getSiteContainers(siteModel.getId()); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); } + + @TestRail(section = {"rest-api", "sites" }, executionType = ExecutionType.SANITY, + description = "Verify user with Collaborator role gets site containers and gets status code OK (200)") + public void getSiteContainersWithCollaboratorRole() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.get(UserRole.SiteCollaborator)); + siteAPI.getSiteContainers(siteModel.getId()); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + } } From 404d8fc55d94b3d82724ebf5ef10e74ea47ded5c Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Wed, 28 Sep 2016 16:44:41 +0300 Subject: [PATCH 0096/1491] TAS-936 getSiteContainers with Contributor role --- .../rest/sites/GetSiteContainersSanityTests.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java index c80c74124..f76004333 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java @@ -64,4 +64,13 @@ public class GetSiteContainersSanityTests extends RestTest siteAPI.getSiteContainers(siteModel.getId()); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); } + + @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, + description = "Verify user with Contributor role gets site containers and gets status code OK (200)") + public void getSiteContainersWithContributorRole() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.get(UserRole.SiteContributor)); + siteAPI.getSiteContainers(siteModel.getId()); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + } } From 078f04dfd8071b1eba9415a16c01e9cafe857750 Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Wed, 28 Sep 2016 16:45:58 +0300 Subject: [PATCH 0097/1491] TAS-937 getSiteContainers with Consumer role --- .../rest/sites/GetSiteContainersSanityTests.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java index f76004333..2befeaec4 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java @@ -73,4 +73,13 @@ public class GetSiteContainersSanityTests extends RestTest siteAPI.getSiteContainers(siteModel.getId()); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); } + + @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, + description = "Verify user with Consumer role gets site containers and gets status code OK (200)") + public void getSiteContainersWithConsumerRole() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.get(UserRole.SiteConsumer)); + siteAPI.getSiteContainers(siteModel.getId()); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + } } From dfe87d4352fd1e11cad77b5094cbf049a98f6a13 Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Wed, 28 Sep 2016 16:46:39 +0300 Subject: [PATCH 0098/1491] TAS-938 getSiteContainers with admin user --- .../rest/sites/GetSiteContainersSanityTests.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java index 2befeaec4..f31bc3d73 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java @@ -82,4 +82,13 @@ public class GetSiteContainersSanityTests extends RestTest siteAPI.getSiteContainers(siteModel.getId()); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); } + + @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, + description = "Verify user with Admin user gets site containers information and gets status code OK (200)") + public void getSiteContainersWithAdminUser() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel); + siteAPI.getSiteContainers(siteModel.getId()); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + } } From 9ddd0a76cabf4f2eac146b96e4957c21fb92ef46 Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Wed, 28 Sep 2016 16:48:17 +0300 Subject: [PATCH 0099/1491] TAS-939 getSiteContainers status code 401 with Manager role --- .../rest/sites/GetSiteContainersSanityTests.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java index f31bc3d73..f3d768638 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java @@ -36,6 +36,7 @@ public class GetSiteContainersSanityTests extends RestTest private UserModel adminUserModel; private SiteModel siteModel; private HashMap usersWithRoles; + private UserModel userModel; @BeforeClass public void initTest() throws Exception @@ -91,4 +92,16 @@ public class GetSiteContainersSanityTests extends RestTest siteAPI.getSiteContainers(siteModel.getId()); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); } + + @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, + description = "Failed authentication get site containers call returns status code 401 with Manager role") + public void getSiteContainersWithManagerRoleFailedAuth() throws JsonToModelConversionException, Exception + { + userModel = dataUser.createRandomTestUser(); + userModel.setPassword("user wrong password"); + dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); + restClient.authenticateUser(userModel); + siteAPI.getSiteContainers(siteModel.getId()); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED.toString()); + } } From 61e7c9cd32887b486db893183362d59fb265de9f Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Thu, 29 Sep 2016 09:48:07 +0300 Subject: [PATCH 0100/1491] TAS-963 deleteComment with admin --- .../comments/DeleteCommentsSanityTests.java | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java new file mode 100644 index 000000000..299970f21 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java @@ -0,0 +1,53 @@ +package org.alfresco.rest.comments; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.requests.RestCommentsApi; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +@Test(groups = { "rest-api", "comments", "sanity" }) +public class DeleteCommentsSanityTests extends RestTest +{ + + @Autowired + RestCommentsApi commentsAPI; + + @Autowired + DataUser dataUser; + + private UserModel adminUserModel; + + private FileModel document; + private SiteModel siteModel; + private String commentId; + + @BeforeClass + public void initTest() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + restClient.authenticateUser(adminUserModel); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + commentsAPI.useRestClient(restClient); + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + commentId = commentsAPI.addComment(document.getNodeRef(), "This is a new comment").getId(); + } + + @TestRail(section={"rest-api", "comments"}, executionType= ExecutionType.SANITY, + description= "Verify Admin user gets comments with Rest API and status code is 200") + public void adminIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception + { + commentsAPI.deleteComment(document.getNodeRef(), commentId); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT.toString()); + } + +} From 2a13d867d277089d95483f35c2d9a80dbd149883 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Thu, 29 Sep 2016 10:00:14 +0300 Subject: [PATCH 0101/1491] TAS-959 deleteComment with Manager --- .../comments/DeleteCommentsSanityTests.java | 41 +++++++++++++++---- 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java index 299970f21..07c2e5aea 100644 --- a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java @@ -1,9 +1,13 @@ package org.alfresco.rest.comments; +import java.util.Arrays; +import java.util.HashMap; + import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.requests.RestCommentsApi; +import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; @@ -13,6 +17,7 @@ import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @Test(groups = { "rest-api", "comments", "sanity" }) @@ -21,16 +26,17 @@ public class DeleteCommentsSanityTests extends RestTest @Autowired RestCommentsApi commentsAPI; - + @Autowired DataUser dataUser; - + private UserModel adminUserModel; - + private FileModel document; private SiteModel siteModel; private String commentId; - + private HashMap usersWithRoles; + @BeforeClass public void initTest() throws Exception { @@ -39,15 +45,34 @@ public class DeleteCommentsSanityTests extends RestTest siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); commentsAPI.useRestClient(restClient); document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, + Arrays.asList(UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor)); + } + + @BeforeMethod + public void initMethod() throws Exception + { + restClient.authenticateUser(adminUserModel); + commentsAPI.useRestClient(restClient); commentId = commentsAPI.addComment(document.getNodeRef(), "This is a new comment").getId(); } - - @TestRail(section={"rest-api", "comments"}, executionType= ExecutionType.SANITY, - description= "Verify Admin user gets comments with Rest API and status code is 200") - public void adminIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception + + @TestRail(section = { "rest-api", + "comments" }, executionType = ExecutionType.SANITY, description = "Verify Admin user delete comments with Rest API and status code is 204") + public void adminIsAbleToDeleteComments() throws JsonToModelConversionException, Exception { commentsAPI.deleteComment(document.getNodeRef(), commentId); commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT.toString()); } + @TestRail(section = { "rest-api", + "comments" }, executionType = ExecutionType.SANITY, description = "Verify Manager user delete comments created by admin user with Rest API and status code is 204") + public void managerIsAbleToDeleteComments() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.get(UserRole.SiteManager)); + commentsAPI.deleteComment(document.getNodeRef(), commentId); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT.toString()); + } + } From a7d6b996ed3bec5d1b098e9f9946d28c7ce68462 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Thu, 29 Sep 2016 10:12:56 +0300 Subject: [PATCH 0102/1491] TAS-960 Collaborator doesn't have permission to delete comment created by other user --- .../rest/comments/DeleteCommentsSanityTests.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java index 07c2e5aea..79b0f9928 100644 --- a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java @@ -75,4 +75,13 @@ public class DeleteCommentsSanityTests extends RestTest commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT.toString()); } + @TestRail(section = { "rest-api", + "comments" }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user delete comments created by admin user with Rest API and status code is 403") + public void collaboratorIsNotAbleToDeleteComments() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.get(UserRole.SiteCollaborator)); + commentsAPI.deleteComment(document.getNodeRef(), commentId); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN.toString()); + } + } From 1bac95bec7c53cd009f909271b244cda2946b311 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Thu, 29 Sep 2016 10:16:48 +0300 Subject: [PATCH 0103/1491] TAS-961 contributor can't delete comment created by admin --- .../rest/comments/DeleteCommentsSanityTests.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java index 79b0f9928..e85b5d0a8 100644 --- a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java @@ -76,7 +76,7 @@ public class DeleteCommentsSanityTests extends RestTest } @TestRail(section = { "rest-api", - "comments" }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user delete comments created by admin user with Rest API and status code is 403") + "comments" }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user can't delete comments created by admin user with Rest API and status code is 403") public void collaboratorIsNotAbleToDeleteComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.get(UserRole.SiteCollaborator)); @@ -84,4 +84,13 @@ public class DeleteCommentsSanityTests extends RestTest commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN.toString()); } + @TestRail(section = { "rest-api", + "comments" }, executionType = ExecutionType.SANITY, description = "Verify Contributor user can't delete comments created by admin user with Rest API and status code is 403") + public void contributorIsNotAbleToDeleteComments() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.get(UserRole.SiteContributor)); + commentsAPI.deleteComment(document.getNodeRef(), commentId); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN.toString()); + } + } From 135a26ca57a4cfa6a7e5af3caed823b849107f2b Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Thu, 29 Sep 2016 10:19:49 +0300 Subject: [PATCH 0104/1491] TAS-962 consumer can't delete comment created by admin --- .../rest/comments/DeleteCommentsSanityTests.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java index e85b5d0a8..be5189f6e 100644 --- a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java @@ -93,4 +93,13 @@ public class DeleteCommentsSanityTests extends RestTest commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN.toString()); } + @TestRail(section = { "rest-api", + "comments" }, executionType = ExecutionType.SANITY, description = "Verify Consumer user can't delete comments created by admin user with Rest API and status code is 403") + public void consumerIsNotAbleToDeleteComments() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.get(UserRole.SiteConsumer)); + commentsAPI.deleteComment(document.getNodeRef(), commentId); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN.toString()); + } + } From 93309b75ac5b962cee2a27cbc22a7f1043e4b99b Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Thu, 29 Sep 2016 10:28:18 +0300 Subject: [PATCH 0105/1491] TAS-964 manager gets status code 401 if authentication fails --- .../rest/comments/DeleteCommentsSanityTests.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java index be5189f6e..fbd91f837 100644 --- a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java @@ -102,4 +102,14 @@ public class DeleteCommentsSanityTests extends RestTest commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN.toString()); } + @TestRail(section = { "rest-api", + "comments" }, executionType = ExecutionType.SANITY, description = "Verify Manager user gets status code 401 if authentication call fails") + public void managerIsNotAbleToDeleteCommentIfAuthenticationFails() throws JsonToModelConversionException, Exception + { + UserModel nonexistentModel = new UserModel("nonexistentUser", "nonexistentPassword"); + restClient.authenticateUser(nonexistentModel); + commentsAPI.deleteComment(document.getNodeRef(), commentId); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED.toString()); + } + } From 680b7fee839239964365db4cfb910729d8a34dc4 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Thu, 29 Sep 2016 10:45:17 +0300 Subject: [PATCH 0106/1491] TAS-965 REST API - valid delete site member request returns success status code 204 with Manager role --- .../people/DeleteSiteMemberSanityTests.java | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java new file mode 100644 index 000000000..3698a2723 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java @@ -0,0 +1,74 @@ +package org.alfresco.rest.people; + +import java.util.Arrays; +import java.util.HashMap; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.body.SiteMember; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.requests.RestPeopleApi; +import org.alfresco.rest.requests.RestSitesApi; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataSite; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.exception.DataPreparationException; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.social.alfresco.api.entities.Role; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +@Test(groups = { "rest-api", "people", "sanity" }) +public class DeleteSiteMemberSanityTests extends RestTest +{ + @Autowired + RestPeopleApi peopleApi; + + @Autowired + RestSitesApi sitesApi; + + @Autowired + DataUser dataUser; + + @Autowired + DataSite dataSite; + + private SiteModel siteModel; + private UserModel adminUser; + private UserModel newUser; + private SiteMember siteMember; + private HashMap usersWithRoles; + + @BeforeClass + public void initTest() throws DataPreparationException + { + adminUser = dataUser.getAdminUser(); + siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); + + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, + Arrays.asList(UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor)); + + peopleApi.useRestClient(restClient); + sitesApi.useRestClient(restClient); + } + + @TestRail(section = { "rest-api", "people" }, + executionType = ExecutionType.SANITY, + description = "Verify site manager is able to delete another member of the site") + public void siteManagerCanDeleteSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception + { + newUser = dataUser.createRandomTestUser(); + siteMember = new SiteMember(Role.SiteCollaborator.toString(), newUser.getUsername()); + restClient.authenticateUser(usersWithRoles.get(UserRole.SiteManager)); + sitesApi.addPerson(siteModel.getId(), siteMember); + + peopleApi.deleteSiteMember(newUser.getUsername(), siteModel.getId()); + sitesApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.NO_CONTENT.toString()); + } + +} \ No newline at end of file From 76955b5361084a8c54db8d39e77254f84132ef0b Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Thu, 29 Sep 2016 11:24:47 +0300 Subject: [PATCH 0107/1491] TAS-966 REST API - valid delete site member request returns success status code 403 with Collaborator role --- .../rest/people/DeleteSiteMemberSanityTests.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java index 3698a2723..ef9566108 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java @@ -70,5 +70,21 @@ public class DeleteSiteMemberSanityTests extends RestTest sitesApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.NO_CONTENT.toString()); } + + @TestRail(section = { "rest-api", "people" }, + executionType = ExecutionType.SANITY, + description = "Verify site collaborator does not have permission to delete another member of the site") + // TODO BUG ACE-5444 + public void siteCollaboratorCanDeleteSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception + { + newUser = dataUser.createRandomTestUser(); + siteMember = new SiteMember(Role.SiteContributor.toString(), newUser.getUsername()); + restClient.authenticateUser(adminUser); + sitesApi.addPerson(siteModel.getId(), siteMember); + restClient.authenticateUser(usersWithRoles.get(UserRole.SiteCollaborator)); + + peopleApi.deleteSiteMember(newUser.getUsername(), siteModel.getId()); + sitesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN.toString()); + } } \ No newline at end of file From 45edd29f466cfe8360d0a26a9ebba734ad88a202 Mon Sep 17 00:00:00 2001 From: cnechifor Date: Thu, 29 Sep 2016 11:29:46 +0300 Subject: [PATCH 0108/1491] moved assertResponseIsNotEmpty and removed the duplication --- e2e-test/java/org/alfresco/rest/demo/RestDemoTest.java | 4 ++-- e2e-test/java/org/alfresco/rest/demo/SampleSitesTest.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/demo/RestDemoTest.java b/e2e-test/java/org/alfresco/rest/demo/RestDemoTest.java index 6a3fea0e6..bd6a29a16 100644 --- a/e2e-test/java/org/alfresco/rest/demo/RestDemoTest.java +++ b/e2e-test/java/org/alfresco/rest/demo/RestDemoTest.java @@ -77,7 +77,7 @@ public class RestDemoTest extends RestTest // add new comment RestCommentModel commentEntry = commentsAPI.addComment(fileModel.getNodeRef(), "This is a new comment"); commentsAPI.getNodeComments(fileModel.getNodeRef()) - .assertThatResponseIsNotEmpty() + .assertResponseIsNotEmpty() .assertThatCommentWithIdExists(commentEntry.getId()) .assertThatCommentWithContentExists("This is a new comment"); @@ -86,7 +86,7 @@ public class RestDemoTest extends RestTest commentEntry.getId(), "This is the updated comment"); commentsAPI.getNodeComments(fileModel.getNodeRef()) - .assertThatResponseIsNotEmpty() + .assertResponseIsNotEmpty() .assertThatCommentWithIdExists(commentEntry.getId()) .assertThatCommentWithContentExists("This is the updated comment"); } diff --git a/e2e-test/java/org/alfresco/rest/demo/SampleSitesTest.java b/e2e-test/java/org/alfresco/rest/demo/SampleSitesTest.java index 53bcfad31..8a830ddda 100644 --- a/e2e-test/java/org/alfresco/rest/demo/SampleSitesTest.java +++ b/e2e-test/java/org/alfresco/rest/demo/SampleSitesTest.java @@ -63,7 +63,7 @@ public class SampleSitesTest extends RestTest public void adminShouldAccessSites() throws JsonToModelConversionException, Exception { siteAPI.getSites() - .assertThatResponseIsNotEmpty(); + .assertResponseIsNotEmpty(); } @TestRail(section={"rest-api", "sites"}, executionType= ExecutionType.SANITY, From 3910d6df819779e01f200b529013cb3e00a55676 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Thu, 29 Sep 2016 11:30:05 +0300 Subject: [PATCH 0109/1491] TAS-967 REST API - valid request returns status code 403 with Contributor role --- .../people/DeleteSiteMemberSanityTests.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java index ef9566108..6cfc53f84 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java @@ -75,7 +75,7 @@ public class DeleteSiteMemberSanityTests extends RestTest executionType = ExecutionType.SANITY, description = "Verify site collaborator does not have permission to delete another member of the site") // TODO BUG ACE-5444 - public void siteCollaboratorCanDeleteSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception + public void siteCollaboratorIsNotAbleToDeleteSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception { newUser = dataUser.createRandomTestUser(); siteMember = new SiteMember(Role.SiteContributor.toString(), newUser.getUsername()); @@ -86,5 +86,21 @@ public class DeleteSiteMemberSanityTests extends RestTest peopleApi.deleteSiteMember(newUser.getUsername(), siteModel.getId()); sitesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN.toString()); } + + @TestRail(section = { "rest-api", "people" }, + executionType = ExecutionType.SANITY, + description = "Verify site contributor does not have permission to delete another member of the site") + // TODO BUG ACE-5444 + public void siteContributorUIsNotAbleToDeleteSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception + { + newUser = dataUser.createRandomTestUser(); + siteMember = new SiteMember(Role.SiteCollaborator.toString(), newUser.getUsername()); + restClient.authenticateUser(adminUser); + sitesApi.addPerson(siteModel.getId(), siteMember); + restClient.authenticateUser(usersWithRoles.get(UserRole.SiteContributor)); + + peopleApi.deleteSiteMember(newUser.getUsername(), siteModel.getId()); + sitesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN.toString()); + } } \ No newline at end of file From ca21198ef56a51049a0b831aa7d8e3e4d6f05d67 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Thu, 29 Sep 2016 11:33:18 +0300 Subject: [PATCH 0110/1491] TAS-968 REST API - valid remove site member request returns status code 403 with Consumer role --- .../people/DeleteSiteMemberSanityTests.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java index 6cfc53f84..d143bb377 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java @@ -91,7 +91,7 @@ public class DeleteSiteMemberSanityTests extends RestTest executionType = ExecutionType.SANITY, description = "Verify site contributor does not have permission to delete another member of the site") // TODO BUG ACE-5444 - public void siteContributorUIsNotAbleToDeleteSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception + public void siteContributorIsNotAbleToDeleteSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception { newUser = dataUser.createRandomTestUser(); siteMember = new SiteMember(Role.SiteCollaborator.toString(), newUser.getUsername()); @@ -102,5 +102,21 @@ public class DeleteSiteMemberSanityTests extends RestTest peopleApi.deleteSiteMember(newUser.getUsername(), siteModel.getId()); sitesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN.toString()); } + + @TestRail(section = { "rest-api", "people" }, + executionType = ExecutionType.SANITY, + description = "Verify site consumer does not have permission to delete another member of the site") + // TODO BUG ACE-5444 + public void siteConsumerIsNotAbleToDeleteSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception + { + newUser = dataUser.createRandomTestUser(); + siteMember = new SiteMember(Role.SiteCollaborator.toString(), newUser.getUsername()); + restClient.authenticateUser(adminUser); + sitesApi.addPerson(siteModel.getId(), siteMember); + restClient.authenticateUser(usersWithRoles.get(UserRole.SiteConsumer)); + + peopleApi.deleteSiteMember(newUser.getUsername(), siteModel.getId()); + sitesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN.toString()); + } } \ No newline at end of file From e6cd9c7058130541d852722efe783e90dc434755 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Thu, 29 Sep 2016 11:38:33 +0300 Subject: [PATCH 0111/1491] TAS-969 REST API - valid remove site member request returns success status code 204 with admin user --- .../rest/people/DeleteSiteMemberSanityTests.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java index d143bb377..b73788042 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java @@ -118,5 +118,20 @@ public class DeleteSiteMemberSanityTests extends RestTest peopleApi.deleteSiteMember(newUser.getUsername(), siteModel.getId()); sitesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN.toString()); } + + @TestRail(section = { "rest-api", "people" }, + executionType = ExecutionType.SANITY, + description = "Verify admin user is able to delete another member of the site") + public void adminIsAbleToDeleteSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception + { + newUser = dataUser.createRandomTestUser(); + siteMember = new SiteMember(Role.SiteCollaborator.toString(), newUser.getUsername()); + restClient.authenticateUser(adminUser); + sitesApi.addPerson(siteModel.getId(), siteMember); + + peopleApi.deleteSiteMember(newUser.getUsername(), siteModel.getId()); + sitesApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.NO_CONTENT.toString()); + } } \ No newline at end of file From 2614ebaf0c723361a22ec68a7541037e87401065 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Thu, 29 Sep 2016 11:45:30 +0300 Subject: [PATCH 0112/1491] Spliting datapreparation for each test --- .../rest/networks/RestGetNetworkTest.java | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkTest.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkTest.java index 2f812540d..c397c7274 100644 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkTest.java +++ b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkTest.java @@ -26,6 +26,7 @@ public class RestGetNetworkTest extends RestTest RestTenantApi tenantApi; UserModel adminTenantUser; + SiteModel site; UserModel tenantUser; UserModel managerTenantUser; UserModel collaboratorTenantUser; @@ -48,18 +49,9 @@ public class RestGetNetworkTest extends RestTest anotherTenantName = adminAnotherTenantUser.getDomain(); tenantApi.createTenant(anotherTenantName); - tenantUser = dataUser.usingUser(adminTenantUser).createRandomTestUser("uTenant"); - managerTenantUser = dataUser.usingUser(adminTenantUser).createRandomTestUser("manTenant"); - collaboratorTenantUser = dataUser.usingUser(adminTenantUser).createRandomTestUser("colTenant"); - consumerTenantUser = dataUser.usingUser(adminTenantUser).createRandomTestUser("consTenant"); - contributorTenantUser = dataUser.usingUser(adminTenantUser).createRandomTestUser("contTenant"); - - SiteModel site = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); - dataUser.usingUser(adminTenantUser).addUserToSite(managerTenantUser, site, UserRole.SiteManager); - dataUser.usingUser(adminTenantUser).addUserToSite(collaboratorTenantUser, site, UserRole.SiteCollaborator); - dataUser.usingUser(adminTenantUser).addUserToSite(consumerTenantUser, site, UserRole.SiteConsumer); - dataUser.usingUser(adminTenantUser).addUserToSite(contributorTenantUser, site, UserRole.SiteConsumer); - + tenantUser = dataUser.usingUser(adminTenantUser).createRandomTestUser("uTenant"); + site = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); + networkApi.useRestClient(restClient); } @@ -143,6 +135,9 @@ public class RestGetNetworkTest extends RestTest @TestRail(section = { "rest-api", "networks" }, executionType = ExecutionType.SANITY, description = "Verify manager tenant user gets its network with Rest API and response is not empty") public void tenantManagerUserChecksIfNetworkIsPresent() throws Exception { + managerTenantUser = dataUser.usingUser(adminTenantUser).createRandomTestUser("manTenant"); + dataUser.usingUser(adminTenantUser).addUserToSite(managerTenantUser, site, UserRole.SiteManager); + restClient.authenticateUser(managerTenantUser); networkApi.getNetwork(tenantName); networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); @@ -152,6 +147,9 @@ public class RestGetNetworkTest extends RestTest @TestRail(section = { "rest-api", "networks" }, executionType = ExecutionType.SANITY, description = "Verify collaborator tenant user gets its network with Rest API and response is not empty") public void tenantCollaboratorUserChecksIfNetworkIsPresent() throws Exception { + collaboratorTenantUser = dataUser.usingUser(adminTenantUser).createRandomTestUser("colTenant"); + dataUser.usingUser(adminTenantUser).addUserToSite(collaboratorTenantUser, site, UserRole.SiteCollaborator); + restClient.authenticateUser(collaboratorTenantUser); networkApi.getNetwork(tenantName); networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); @@ -161,6 +159,9 @@ public class RestGetNetworkTest extends RestTest @TestRail(section = { "rest-api", "networks" }, executionType = ExecutionType.SANITY, description = "Verify consumer tenant user gets its network with Rest API and response is not empty") public void tenantConsumerUserChecksIfNetworkIsPresent() throws Exception { + consumerTenantUser = dataUser.usingUser(adminTenantUser).createRandomTestUser("contTenant"); + dataUser.usingUser(adminTenantUser).addUserToSite(consumerTenantUser, site, UserRole.SiteConsumer); + restClient.authenticateUser(consumerTenantUser); networkApi.getNetwork(tenantName); networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); @@ -170,6 +171,9 @@ public class RestGetNetworkTest extends RestTest @TestRail(section = { "rest-api", "networks" }, executionType = ExecutionType.SANITY, description = "Verify contributor tenant user gets its network with Rest API and response is not empty") public void tenantContributorUserChecksIfNetworkIsPresent() throws Exception { + contributorTenantUser = dataUser.usingUser(adminTenantUser).createRandomTestUser("contTenant"); + dataUser.usingUser(adminTenantUser).addUserToSite(contributorTenantUser, site, UserRole.SiteContributor); + restClient.authenticateUser(contributorTenantUser); networkApi.getNetwork(tenantName); networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); From 98a784f2d262f938801c2f409de5a3701601c57c Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Thu, 29 Sep 2016 11:47:37 +0300 Subject: [PATCH 0113/1491] TAS-970 REST API - failed authentication for remove site member call returns status code 401 --- .../people/DeleteSiteMemberSanityTests.java | 32 ++++++++++++------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java index b73788042..7741eb8c5 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java @@ -71,6 +71,21 @@ public class DeleteSiteMemberSanityTests extends RestTest .assertStatusCodeIs(HttpStatus.NO_CONTENT.toString()); } + @TestRail(section = { "rest-api", "people" }, + executionType = ExecutionType.SANITY, + description = "Verify admin user is able to delete another member of the site") + public void adminIsAbleToDeleteSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception + { + newUser = dataUser.createRandomTestUser(); + siteMember = new SiteMember(Role.SiteCollaborator.toString(), newUser.getUsername()); + restClient.authenticateUser(adminUser); + sitesApi.addPerson(siteModel.getId(), siteMember); + + peopleApi.deleteSiteMember(newUser.getUsername(), siteModel.getId()); + sitesApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.NO_CONTENT.toString()); + } + @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify site collaborator does not have permission to delete another member of the site") @@ -121,17 +136,12 @@ public class DeleteSiteMemberSanityTests extends RestTest @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, - description = "Verify admin user is able to delete another member of the site") - public void adminIsAbleToDeleteSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception + description = "Verify unauthenticated user is not able to delete another member of the site") + public void unauthenticatedUserIsNotAbleToDeleteSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception { - newUser = dataUser.createRandomTestUser(); - siteMember = new SiteMember(Role.SiteCollaborator.toString(), newUser.getUsername()); - restClient.authenticateUser(adminUser); - sitesApi.addPerson(siteModel.getId(), siteMember); - - peopleApi.deleteSiteMember(newUser.getUsername(), siteModel.getId()); - sitesApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.NO_CONTENT.toString()); - } + restClient.authenticateUser(new UserModel("random user", "random password")); + peopleApi.deleteSiteMember(usersWithRoles.get(UserRole.SiteConsumer).getUsername(), siteModel.getId()); + sitesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED.toString()); + } } \ No newline at end of file From d694685631f3c7b012e7122300c5283195dd783a Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Thu, 29 Sep 2016 12:40:15 +0300 Subject: [PATCH 0114/1491] TAS-971 created test: getPerson call test with Manager role --- .../alfresco/rest/people/GetPeopleTest.java | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/people/GetPeopleTest.java diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleTest.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleTest.java new file mode 100644 index 000000000..ec70fcd44 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleTest.java @@ -0,0 +1,47 @@ +package org.alfresco.rest.people; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.requests.RestPeopleApi; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +@Test(groups = { "rest-api", "people" }) +public class GetPeopleTest extends RestTest +{ + @Autowired + RestPeopleApi peopleApi; + + UserModel userModel; + SiteModel siteModel; + UserModel searchedUser; + + @BeforeClass + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + searchedUser = dataUser.createRandomTestUser(); + + peopleApi.useRestClient(restClient); + } + + @Test(groups = "sanity") + @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify manager user gets a person with Rest API and response is successful") + public void managerUserChecksIfPersonIsPresent() throws Exception + { + UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); + + restClient.authenticateUser(managerUser); + peopleApi.getPerson(searchedUser.getUsername()); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + } +} From 26763e1d3566fda4e390509e53b62796727253ef Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Thu, 29 Sep 2016 12:41:46 +0300 Subject: [PATCH 0115/1491] TAS-972 created test: getPerson call test with Collaborator role --- .../org/alfresco/rest/people/GetPeopleTest.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleTest.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleTest.java index ec70fcd44..9d7a85164 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleTest.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleTest.java @@ -3,7 +3,6 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; import org.alfresco.rest.requests.RestPeopleApi; import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; @@ -44,4 +43,16 @@ public class GetPeopleTest extends RestTest peopleApi.getPerson(searchedUser.getUsername()); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); } + + @Test(groups = "sanity") + @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify collaborator user gets a person with Rest API and response is successful") + public void collaboratorUserChecksIfPersonIsPresent() throws Exception + { + UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(collaboratorUser, siteModel, UserRole.SiteCollaborator); + + restClient.authenticateUser(collaboratorUser); + peopleApi.getPerson(searchedUser.getUsername()); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + } } From 2bce4ccc4388457b6aec41efaf3d178e41feeb49 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Thu, 29 Sep 2016 12:42:41 +0300 Subject: [PATCH 0116/1491] TAS-973 created test: getPerson call test with Contributor role --- .../java/org/alfresco/rest/people/GetPeopleTest.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleTest.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleTest.java index 9d7a85164..218aeb5b4 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleTest.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleTest.java @@ -55,4 +55,16 @@ public class GetPeopleTest extends RestTest peopleApi.getPerson(searchedUser.getUsername()); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); } + + @Test(groups = "sanity") + @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify contributor user gets a person with Rest API and response is successful") + public void contributorUserChecksIfPersonIsPresent() throws Exception + { + UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(contributorUser, siteModel, UserRole.SiteContributor); + + restClient.authenticateUser(contributorUser); + peopleApi.getPerson(searchedUser.getUsername()); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + } } From 5745ef3b60ed57a86ce186c90e12fcaa3fa820e5 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Thu, 29 Sep 2016 12:43:27 +0300 Subject: [PATCH 0117/1491] TAS-974 created test: getPerson call test with Consumer role --- .../java/org/alfresco/rest/people/GetPeopleTest.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleTest.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleTest.java index 218aeb5b4..23f18a5f1 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleTest.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleTest.java @@ -67,4 +67,16 @@ public class GetPeopleTest extends RestTest peopleApi.getPerson(searchedUser.getUsername()); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); } + + @Test(groups = "sanity") + @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify consumer user gets a person with Rest API and response is successful") + public void consumerUserChecksIfPersonIsPresent() throws Exception + { + UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel, UserRole.SiteConsumer); + + restClient.authenticateUser(consumerUser); + peopleApi.getPerson(searchedUser.getUsername()); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + } } From 598cbccca26c0890cea4a1993c0538ffedac1bc9 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Thu, 29 Sep 2016 12:44:15 +0300 Subject: [PATCH 0118/1491] TAS-975 created test: getPerson call test with admin user --- .../java/org/alfresco/rest/people/GetPeopleTest.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleTest.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleTest.java index 23f18a5f1..3b28db902 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleTest.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleTest.java @@ -79,4 +79,15 @@ public class GetPeopleTest extends RestTest peopleApi.getPerson(searchedUser.getUsername()); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); } + + @Test(groups = "sanity") + @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify admin user gets a person with Rest API and response is successful") + public void adminUserChecksIfPersonIsPresent() throws Exception + { + UserModel adminUser = dataUser.getAdminUser(); + + restClient.authenticateUser(adminUser); + peopleApi.getPerson(searchedUser.getUsername()); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + } } From 29dd7b433adde3a9670e97f287e302d84bbd9a68 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Thu, 29 Sep 2016 12:45:11 +0300 Subject: [PATCH 0119/1491] TAS-976 created test: fail getPerson call test with Manager role --- .../org/alfresco/rest/people/GetPeopleTest.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleTest.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleTest.java index 3b28db902..bc8fd52ed 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleTest.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleTest.java @@ -3,6 +3,7 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; import org.alfresco.rest.requests.RestPeopleApi; import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; @@ -90,4 +91,17 @@ public class GetPeopleTest extends RestTest peopleApi.getPerson(searchedUser.getUsername()); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); } + + @Test(groups = "sanity") + @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify manager user gets a non existing person with Rest API and person is not found") + public void managerUserChecksIfNonExistingPersonIsPresent() throws Exception + { + UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); + UserModel searchedNonUser = new UserModel("nonexistinguser", DataUser.PASSWORD); + + restClient.authenticateUser(managerUser); + peopleApi.getPerson(searchedNonUser.getUsername()); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND.toString()); + } } From 0924ba98298702068d84e4d4fd7426e3cba2bd0e Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Thu, 29 Sep 2016 14:10:49 +0300 Subject: [PATCH 0120/1491] TAS-986 getSiteMembers with Manager Role --- .../rest/sites/GetSiteMembersSanityTests.java | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java new file mode 100644 index 000000000..3068c34fe --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java @@ -0,0 +1,61 @@ +package org.alfresco.rest.sites; + +import java.util.Arrays; +import java.util.HashMap; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.requests.RestSitesApi; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataSite; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.exception.DataPreparationException; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * @author iulia.cojocea + */ +@Test(groups = { "rest-api", "sites", "sanity" }) +public class GetSiteMembersSanityTests extends RestTest +{ + @Autowired + RestSitesApi siteAPI; + + @Autowired + DataUser dataUser; + + @Autowired + DataSite dataSite; + + private SiteModel siteModel; + private UserModel adminUser; + private HashMap usersWithRoles; + private UserModel userModel; + + @BeforeClass(alwaysRun=true) + public void initTest() throws DataPreparationException + { + adminUser = dataUser.getAdminUser(); + siteAPI.useRestClient(restClient); + siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, + Arrays.asList(UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor)); + + } + + @TestRail(section = {"rest-api", "sites" }, executionType = ExecutionType.SANITY, + description = "Verify user with Manager role gets site members and gets status code OK (200)") + public void getSiteMembersWithManagerRole() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.get(UserRole.SiteManager)); + siteAPI.getSiteMembers(siteModel.getId()); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + } +} From 6d552a4bc48e29b79a85f69d068d483c0e33d77f Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Thu, 29 Sep 2016 14:11:47 +0300 Subject: [PATCH 0121/1491] TAS-987 getSiteMembers with Collaborator role --- .../alfresco/rest/sites/GetSiteMembersSanityTests.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java index 3068c34fe..5c47a5b9f 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java @@ -58,4 +58,13 @@ public class GetSiteMembersSanityTests extends RestTest siteAPI.getSiteMembers(siteModel.getId()); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); } + + @TestRail(section = {"rest-api", "sites" }, executionType = ExecutionType.SANITY, + description = "Verify user with Collaborator role gets site members and gets status code OK (200)") + public void getSiteMembersWithCollaboratorRole() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.get(UserRole.SiteCollaborator)); + siteAPI.getSiteMembers(siteModel.getId()); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + } } From ba5ccbbb67e18281dd0291784436327f5f2903c6 Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Thu, 29 Sep 2016 14:12:36 +0300 Subject: [PATCH 0122/1491] TAS-988 getSiteMembers with Contributor role --- .../alfresco/rest/sites/GetSiteMembersSanityTests.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java index 5c47a5b9f..b371b1993 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java @@ -67,4 +67,13 @@ public class GetSiteMembersSanityTests extends RestTest siteAPI.getSiteMembers(siteModel.getId()); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); } + + @TestRail(section = {"rest-api", "sites" }, executionType = ExecutionType.SANITY, + description = "Verify user with Contributor role gets site members and gets status code OK (200)") + public void getSiteMembersWithContributorRole() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.get(UserRole.SiteContributor)); + siteAPI.getSiteMembers(siteModel.getId()); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + } } From 2d41ab7972011cfc75e5ffbd18d6467971dadb8d Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Thu, 29 Sep 2016 14:14:33 +0300 Subject: [PATCH 0123/1491] TAS-989 getSiteMembers with Consumer role --- .../alfresco/rest/sites/GetSiteMembersSanityTests.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java index b371b1993..9049346af 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java @@ -76,4 +76,13 @@ public class GetSiteMembersSanityTests extends RestTest siteAPI.getSiteMembers(siteModel.getId()); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); } + + @TestRail(section = {"rest-api", "sites" }, executionType = ExecutionType.SANITY, + description = "Verify user with Consumer role gets site members and gets status code OK (200)") + public void getSiteMembersWithConsumerRole() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.get(UserRole.SiteConsumer)); + siteAPI.getSiteMembers(siteModel.getId()); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + } } From 86bb62503747b67f62387af0ee84fc9b99680ea1 Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Thu, 29 Sep 2016 14:15:23 +0300 Subject: [PATCH 0124/1491] TAS-990 getSiteMembers with admin user --- .../alfresco/rest/sites/GetSiteMembersSanityTests.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java index 9049346af..034fd9f28 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java @@ -85,4 +85,13 @@ public class GetSiteMembersSanityTests extends RestTest siteAPI.getSiteMembers(siteModel.getId()); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); } + + @TestRail(section = {"rest-api", "sites" }, executionType = ExecutionType.SANITY, + description = "Verify user with admin usere gets site members and gets status code OK (200)") + public void getSiteMembersWithAdminUser() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUser); + siteAPI.getSiteMembers(siteModel.getId()); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + } } From d7d9c0cb6e5fd1fce34b2b0dd06993a30330ac65 Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Thu, 29 Sep 2016 14:18:43 +0300 Subject: [PATCH 0125/1491] TAS-991 getSiteMembers call returns status code 401 with Manager role --- .../rest/sites/GetSiteMembersSanityTests.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java index 034fd9f28..a01eae781 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java @@ -94,4 +94,16 @@ public class GetSiteMembersSanityTests extends RestTest siteAPI.getSiteMembers(siteModel.getId()); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); } + + @TestRail(section = {"rest-api", "sites" }, executionType = ExecutionType.SANITY, + description = "Failed authentication get site members call returns status code 401 with Manager role") + public void getSiteMembersWithManagerRoleFailedAuth() throws JsonToModelConversionException, Exception + { + userModel = dataUser.createRandomTestUser(); + userModel.setPassword("user wrong password"); + dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); + restClient.authenticateUser(userModel); + siteAPI.getSiteMembers(siteModel.getId()); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED.toString()); + } } From 44b810bffa5a26ed17f0690f17eb75539ca8a194 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Thu, 29 Sep 2016 14:56:54 +0300 Subject: [PATCH 0126/1491] using only models as parameters adding ListUserWithRoles (removing HashMaps) update sanity-rest --- .../org/alfresco/rest/GetSiteSanityTests.java | 44 ++++++------ .../alfresco/rest/GetSitesSanityTests.java | 35 +++++----- .../java/org/alfresco/rest/GetSitesTests.java | 36 +++++----- e2e-test/java/org/alfresco/rest/RestTest.java | 6 +- ...yTest.java => GetCommentsSanityTests.java} | 70 +++++++++---------- .../{RestDemoTest.java => RestDemoTests.java} | 42 ++++++----- ...entsTest.java => SampleCommentsTests.java} | 26 +++---- ...PeopleTest.java => SamplePeopleTests.java} | 20 +++--- ...leSitesTest.java => SampleSitesTests.java} | 40 +++++------ ... AddSiteMembershipRequestSanityTests.java} | 26 ++++--- ...SiteMembershipInformationSanityTests.java} | 40 +++++------ e2e-test/resources/sanity-rest.xml | 19 +++-- 12 files changed, 195 insertions(+), 209 deletions(-) rename e2e-test/java/org/alfresco/rest/comments/{GetCommentsSanityTest.java => GetCommentsSanityTests.java} (71%) rename e2e-test/java/org/alfresco/rest/demo/{RestDemoTest.java => RestDemoTests.java} (79%) rename e2e-test/java/org/alfresco/rest/demo/{SampleCommentsTest.java => SampleCommentsTests.java} (73%) rename e2e-test/java/org/alfresco/rest/demo/{SamplePeopleTest.java => SamplePeopleTests.java} (69%) rename e2e-test/java/org/alfresco/rest/demo/{SampleSitesTest.java => SampleSitesTests.java} (74%) rename e2e-test/java/org/alfresco/rest/sites/{AddSiteMembershipRequestSanityTest.java => AddSiteMembershipRequestSanityTests.java} (66%) rename e2e-test/java/org/alfresco/rest/sites/{GetSiteMembershipInformationSanityTest.java => GetSiteMembershipInformationSanityTests.java} (75%) diff --git a/e2e-test/java/org/alfresco/rest/GetSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/GetSiteSanityTests.java index e96d59e3f..b38609f39 100644 --- a/e2e-test/java/org/alfresco/rest/GetSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/GetSiteSanityTests.java @@ -1,13 +1,11 @@ package org.alfresco.rest; -import java.util.Arrays; -import java.util.HashMap; - import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.requests.RestSitesApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataSite; import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; @@ -25,7 +23,6 @@ import org.testng.annotations.Test; @Test(groups = { "rest-api", "sites", "sanity" }) public class GetSiteSanityTests extends RestTest { - @Autowired DataUser dataUser; @@ -36,55 +33,54 @@ public class GetSiteSanityTests extends RestTest DataSite dataSite; private UserModel adminUserModel; - private HashMap usersWithRoles; + private ListUserWithRoles usersWithRoles; private UserModel userModel; private SiteModel siteModel; - @BeforeClass - public void initTest() throws DataPreparationException + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws DataPreparationException { adminUserModel = dataUser.getAdminUser(); restClient.authenticateUser(adminUserModel); siteAPI.useRestClient(restClient); siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, - Arrays.asList(UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor)); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); } @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role gets site information and gets status code OK (200)") public void getSiteWithManagerRole() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.get(UserRole.SiteManager)); - siteAPI.getSite(siteModel.getId()); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + siteAPI.getSite(siteModel); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify user with Collaborator role gets site information and gets status code OK (200)") public void getSiteWithCollaboratorRole() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.get(UserRole.SiteCollaborator)); - siteAPI.getSite(siteModel.getId()); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + siteAPI.getSite(siteModel); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify user with Contributor role gets site information and gets status code OK (200)") public void getSiteWithContributorRole() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.get(UserRole.SiteContributor)); - siteAPI.getSite(siteModel.getId()); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + siteAPI.getSite(siteModel); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role gets site information and gets status code OK (200)") public void getSiteWithConsumerRole() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.get(UserRole.SiteConsumer)); - siteAPI.getSite(siteModel.getId()); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + siteAPI.getSite(siteModel); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, @@ -92,8 +88,8 @@ public class GetSiteSanityTests extends RestTest public void getSiteWithAdminRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); - siteAPI.getSite(siteModel.getId()); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + siteAPI.getSite(siteModel); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, @@ -105,6 +101,6 @@ public class GetSiteSanityTests extends RestTest dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); restClient.authenticateUser(userModel); siteAPI.getAllSites(); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED.toString()); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/GetSitesSanityTests.java b/e2e-test/java/org/alfresco/rest/GetSitesSanityTests.java index bf783d99b..a25066a81 100644 --- a/e2e-test/java/org/alfresco/rest/GetSitesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/GetSitesSanityTests.java @@ -1,13 +1,11 @@ package org.alfresco.rest; -import java.util.Arrays; -import java.util.HashMap; - import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.requests.RestSitesApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataSite; import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; @@ -34,27 +32,26 @@ public class GetSitesSanityTests extends RestTest private UserModel adminUserModel; private UserModel userModel; - private HashMap usersWithRoles; + private ListUserWithRoles usersWithRoles; private SiteModel siteModel; - @BeforeClass - public void initTest() throws Exception + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception { adminUserModel = dataUser.getAdminUser(); restClient.authenticateUser(adminUserModel); siteAPI.useRestClient(restClient); siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, - Arrays.asList(UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor)); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); } @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role gets sites information and gets status code OK (200)") public void getSitesWithManagerRole() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.get(UserRole.SiteManager)); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); siteAPI.getAllSites(); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, @@ -62,9 +59,9 @@ public class GetSitesSanityTests extends RestTest public void getSitesWithCollaboratorRole() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.get(UserRole.SiteCollaborator)); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); siteAPI.getAllSites(); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, @@ -72,9 +69,9 @@ public class GetSitesSanityTests extends RestTest public void getSitesWithContributorRole() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.get(UserRole.SiteContributor)); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); siteAPI.getAllSites(); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, @@ -82,9 +79,9 @@ public class GetSitesSanityTests extends RestTest public void getSitesWithConsumerRole() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.get(UserRole.SiteConsumer)); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); siteAPI.getAllSites(); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, @@ -93,19 +90,19 @@ public class GetSitesSanityTests extends RestTest { restClient.authenticateUser(adminUserModel); siteAPI.getAllSites(); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Failed authentication get sites call returns status code 401 with Manager role") public void getSitesWithManagerRoleFailedAuth() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.get(UserRole.SiteManager)); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); userModel = dataUser.createRandomTestUser(); userModel.setPassword("user wrong password"); dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); restClient.authenticateUser(userModel); siteAPI.getAllSites(); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED.toString()); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/GetSitesTests.java b/e2e-test/java/org/alfresco/rest/GetSitesTests.java index 7a594bbdb..5790a8dc8 100644 --- a/e2e-test/java/org/alfresco/rest/GetSitesTests.java +++ b/e2e-test/java/org/alfresco/rest/GetSitesTests.java @@ -1,13 +1,11 @@ package org.alfresco.rest; -import java.util.Arrays; -import java.util.HashMap; - import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.requests.RestSitesApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataSite; import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; @@ -34,55 +32,53 @@ public class GetSitesTests extends RestTest private UserModel adminUserModel; private UserModel userModel; - private HashMap usersWithRoles; + private ListUserWithRoles usersWithRoles; private SiteModel siteModel; - @BeforeClass - public void initTest() throws Exception + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception { adminUserModel = dataUser.getAdminUser(); restClient.authenticateUser(adminUserModel); siteAPI.useRestClient(restClient); siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, - Arrays.asList(UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor)); - + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); } @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role gets sites information and gets status code OK (200)") public void getSitesWithManagerRole() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.get(UserRole.SiteManager)); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); siteAPI.getAllSites(); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify user with Collaborator role gets sites information and gets status code OK (200)") public void getSitesWithCollaboratorRole() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.get(UserRole.SiteCollaborator)); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); siteAPI.getAllSites(); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify user with Contributor role gets sites information and gets status code OK (200)") public void getSitesWithContributorRole() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.get(UserRole.SiteContributor)); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); siteAPI.getAllSites(); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role gets sites information and gets status code OK (200)") public void getSitesWithConsumerRole() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.get(UserRole.SiteConsumer)); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); siteAPI.getAllSites(); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify user with Admin user gets sites information and gets status code OK (200)") @@ -90,18 +86,18 @@ public class GetSitesTests extends RestTest { restClient.authenticateUser(adminUserModel); siteAPI.getAllSites(); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Failed authentication get sites call returns status code 401 with Manager role") public void getSitesWithManagerRoleFailedAuth() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.get(UserRole.SiteManager)); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); userModel = dataUser.createRandomTestUser(); userModel.setPassword("user wrong password"); dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); restClient.authenticateUser(userModel); siteAPI.getAllSites(); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED.toString()); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/RestTest.java b/e2e-test/java/org/alfresco/rest/RestTest.java index b50cad0ea..69cc678cc 100644 --- a/e2e-test/java/org/alfresco/rest/RestTest.java +++ b/e2e-test/java/org/alfresco/rest/RestTest.java @@ -8,12 +8,16 @@ import org.alfresco.utility.data.DataSite; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.network.ServerHealth; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; import org.testng.annotations.BeforeClass; import com.jayway.restassured.RestAssured; +@Component +@Scope(value = "prototype") @ContextConfiguration("classpath:alfresco-restapi-context.xml") public abstract class RestTest extends AbstractTestNGSpringContextTests { @@ -39,7 +43,7 @@ public abstract class RestTest extends AbstractTestNGSpringContextTests protected DataContent dataContent; @BeforeClass(alwaysRun = true) - public void setupRestTest() throws Exception + public void checkServerHealth() throws Exception { serverHealth.assertServerIsOnline(); diff --git a/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTest.java b/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java similarity index 71% rename from e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTest.java rename to e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java index c57e55d23..6b38898d0 100644 --- a/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTest.java +++ b/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java @@ -1,14 +1,12 @@ package org.alfresco.rest.comments; -import java.util.Arrays; -import java.util.HashMap; - import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.requests.RestCommentsApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; @@ -20,7 +18,7 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @Test(groups = { "rest-api", "comments", "sanity" }) -public class GetCommentsSanityTest extends RestTest +public class GetCommentsSanityTests extends RestTest { @Autowired RestCommentsApi commentsAPI; @@ -33,63 +31,63 @@ public class GetCommentsSanityTest extends RestTest private FileModel document; private SiteModel siteModel; private UserModel userModel; - private HashMap usersWithRoles; + private ListUserWithRoles usersWithRoles; - @BeforeClass - public void initTest() throws Exception + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception { adminUserModel = dataUser.getAdminUser(); restClient.authenticateUser(adminUserModel); siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); commentsAPI.useRestClient(restClient); document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - commentsAPI.addComment(document.getNodeRef(), "This is a new comment"); + commentsAPI.addComment(document, "This is a new comment"); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, Arrays.asList(UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor)); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); } @TestRail(section={"rest-api", "comments"}, executionType= ExecutionType.SANITY, description= "Verify Admin user gets comments with Rest API and status code is 200") public void adminIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception { - commentsAPI.getNodeComments(document.getNodeRef()); - commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + commentsAPI.getNodeComments(document); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @TestRail(section={"rest-api", "comments"}, executionType= ExecutionType.SANITY, description= "Verify Manager user gets comments created by admin user with Rest API and status code is 200") public void managerIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.get(UserRole.SiteManager)); - commentsAPI.getNodeComments(document.getNodeRef()); - commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + commentsAPI.getNodeComments(document); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @TestRail(section={"rest-api", "comments"}, executionType= ExecutionType.SANITY, description= "Verify Contributor user gets comments created by admin user with Rest API and status code is 200") public void contributorIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.get(UserRole.SiteContributor)); - commentsAPI.getNodeComments(document.getNodeRef()); - commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + commentsAPI.getNodeComments(document); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @TestRail(section={"rest-api", "comments"}, executionType= ExecutionType.SANITY, description= "Verify Collaborator user gets comments created by admin user with Rest API and status code is 200") public void collaboratorIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.get(UserRole.SiteCollaborator)); - commentsAPI.getNodeComments(document.getNodeRef()); - commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + commentsAPI.getNodeComments(document); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @TestRail(section={"rest-api", "comments"}, executionType= ExecutionType.SANITY, description= "Verify Consumer user gets comments created by admin user with Rest API and status code is 200") public void consumerIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.get(UserRole.SiteConsumer)); - commentsAPI.getNodeComments(document.getNodeRef()); - commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + commentsAPI.getNodeComments(document); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @TestRail(section={"rest-api", "comments"}, executionType= ExecutionType.SANITY, @@ -98,33 +96,33 @@ public class GetCommentsSanityTest extends RestTest { UserModel nonexistentModel = new UserModel("nonexistentUser", "nonexistentPassword"); restClient.authenticateUser(nonexistentModel); - commentsAPI.getNodeComments(document.getNodeRef()); - commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED.toString()); + commentsAPI.getNodeComments(document); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } @TestRail(section={"rest-api", "comments"}, executionType= ExecutionType.SANITY, description= "Verify Manager user gets comments created by another user and status code is 200") public void managerIsAbleToRetrieveCommentsCreatedByAnotherUser() throws JsonToModelConversionException, Exception { - userModel = usersWithRoles.get(UserRole.SiteCollaborator); + userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); restClient.authenticateUser(userModel); - commentsAPI.addComment(document.getNodeRef(), "This is a new comment added by " + userModel.getUsername()); - commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED.toString()); - restClient.authenticateUser(usersWithRoles.get(UserRole.SiteManager)); - commentsAPI.getNodeComments(document.getNodeRef()); - commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + commentsAPI.addComment(document, "This is a new comment added by " + userModel.getUsername()); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + commentsAPI.getNodeComments(document); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @TestRail(section={"rest-api", "comments"}, executionType= ExecutionType.SANITY, description= "Verify admin user gets comments created by another user and status code is 200") public void adminIsAbleToRetrieveCommentsCreatedByAnotherUser() throws JsonToModelConversionException, Exception { - userModel = usersWithRoles.get(UserRole.SiteCollaborator); + userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); restClient.authenticateUser(userModel); - commentsAPI.addComment(document.getNodeRef(), "This is a new comment added by " + userModel.getUsername()); - commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED.toString()); + commentsAPI.addComment(document, "This is a new comment added by " + userModel.getUsername()); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); restClient.authenticateUser(adminUserModel); - commentsAPI.getNodeComments(document.getNodeRef()); - commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + commentsAPI.getNodeComments(document); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } } diff --git a/e2e-test/java/org/alfresco/rest/demo/RestDemoTest.java b/e2e-test/java/org/alfresco/rest/demo/RestDemoTests.java similarity index 79% rename from e2e-test/java/org/alfresco/rest/demo/RestDemoTest.java rename to e2e-test/java/org/alfresco/rest/demo/RestDemoTests.java index 6a3fea0e6..c68d578fc 100644 --- a/e2e-test/java/org/alfresco/rest/demo/RestDemoTest.java +++ b/e2e-test/java/org/alfresco/rest/demo/RestDemoTests.java @@ -19,7 +19,8 @@ import org.springframework.social.alfresco.api.entities.Site.Visibility; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -public class RestDemoTest extends RestTest +@Test(groups = { "demo" }) +public class RestDemoTests extends RestTest { @Autowired RestSitesApi sitesApi; @@ -30,8 +31,8 @@ public class RestDemoTest extends RestTest private UserModel userModel; private SiteModel siteModel; - @BeforeClass - public void setUp() throws DataPreparationException + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws DataPreparationException { userModel = dataUser.getAdminUser(); siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); @@ -70,24 +71,24 @@ public class RestDemoTest extends RestTest */ @Test public void adminCanPostAndUpdateComments() throws Exception - { - FileModel fileModel = dataContent.usingResource(new FolderModel("Shared")) - .usingUser(userModel) + { + FileModel fileModel = dataContent.usingUser(userModel) + .usingResource(FolderModel.getSharedFolderModel()) .createContent(DocumentType.TEXT_PLAIN); // add new comment - RestCommentModel commentEntry = commentsAPI.addComment(fileModel.getNodeRef(), "This is a new comment"); - commentsAPI.getNodeComments(fileModel.getNodeRef()) + RestCommentModel commentEntry = commentsAPI.addComment(fileModel, "This is a new comment"); + commentsAPI.getNodeComments(fileModel) .assertThatResponseIsNotEmpty() - .assertThatCommentWithIdExists(commentEntry.getId()) + .assertThatCommentWithIdExists(commentEntry) .assertThatCommentWithContentExists("This is a new comment"); // update comment - commentEntry = commentsAPI.updateComment(fileModel.getNodeRef(), - commentEntry.getId(), + commentEntry = commentsAPI.updateComment(fileModel, + commentEntry, "This is the updated comment"); - commentsAPI.getNodeComments(fileModel.getNodeRef()) + commentsAPI.getNodeComments(fileModel) .assertThatResponseIsNotEmpty() - .assertThatCommentWithIdExists(commentEntry.getId()) + .assertThatCommentWithIdExists(commentEntry) .assertThatCommentWithContentExists("This is the updated comment"); } @@ -108,25 +109,22 @@ public class RestDemoTest extends RestTest newUser.getUsername()); // add user as Consumer to site - sitesApi.addPerson(siteModel.getId(), siteMember); - sitesApi.getSiteMembers(siteModel.getId()) + sitesApi.addPerson(siteModel, siteMember); + sitesApi.getSiteMembers(siteModel) .assertThatSiteHasMember(siteMember.getId()) .getSiteMember(siteMember.getId()) .assertSiteMemberHasRole(Role.SiteConsumer); // update site member to Manager siteMember.setRole(Role.SiteManager.toString()); - sitesApi.updateSiteMember(siteModel.getId(), - newUser.getUsername(), siteMember); - sitesApi.getSiteMembers(siteModel.getId()) + sitesApi.updateSiteMember(siteModel, newUser, siteMember); + sitesApi.getSiteMembers(siteModel) .assertThatSiteHasMember(siteMember.getId()) .getSiteMember(siteMember.getId()) .assertSiteMemberHasRole(Role.SiteManager); - // delete site member - sitesApi.deleteSiteMember(siteModel.getId(), - newUser.getUsername()); + sitesApi.deleteSiteMember(siteModel, newUser); sitesApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.NO_CONTENT.toString()); + .assertStatusCodeIs(HttpStatus.NO_CONTENT); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/demo/SampleCommentsTest.java b/e2e-test/java/org/alfresco/rest/demo/SampleCommentsTests.java similarity index 73% rename from e2e-test/java/org/alfresco/rest/demo/SampleCommentsTest.java rename to e2e-test/java/org/alfresco/rest/demo/SampleCommentsTests.java index 1551c0fb9..0398cadae 100644 --- a/e2e-test/java/org/alfresco/rest/demo/SampleCommentsTest.java +++ b/e2e-test/java/org/alfresco/rest/demo/SampleCommentsTests.java @@ -17,8 +17,8 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { "rest-api", "comments", "sanity" }) -public class SampleCommentsTest extends RestTest +@Test(groups = { "demo" }) +public class SampleCommentsTests extends RestTest { @Autowired DataUser dataUser; @@ -31,8 +31,8 @@ public class SampleCommentsTest extends RestTest private SiteModel siteModel; private FileModel document; - @BeforeClass - public void initTest() throws Exception + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception { userModel = dataUser.getAdminUser(); siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); @@ -43,33 +43,33 @@ public class SampleCommentsTest extends RestTest document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); } - @TestRail(section={"rest-api", "comments"}, executionType= ExecutionType.SANITY, + @TestRail(section={"demo", "sample-section"}, executionType= ExecutionType.SANITY, description= "Verify admin user adds comments with Rest API and status code is 200") public void admiShouldAddComment() throws JsonToModelConversionException, Exception { - commentsAPI.addComment(document.getNodeRef(), "This is a new comment"); + commentsAPI.addComment(document, "This is a new comment"); commentsAPI.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.CREATED.toString()); + .assertStatusCodeIs(HttpStatus.CREATED); } - @TestRail(section={"rest-api", "comments"}, executionType= ExecutionType.SANITY, + @TestRail(section={"demo", "sample-section"}, executionType= ExecutionType.SANITY, description= "Verify admin user gets comments with Rest API and status code is 200") public void admiShouldRetrieveComments() throws JsonToModelConversionException { - commentsAPI.getNodeComments(document.getNodeRef()); + commentsAPI.getNodeComments(document); commentsAPI.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.OK.toString()); + .assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section={"rest-api", "comments"}, executionType= ExecutionType.SANITY, + @TestRail(section={"demo", "sample-section"}, executionType= ExecutionType.SANITY, description= "Verify admin user updates comments with Rest API") public void adminShouldUpdateComment() throws JsonToModelConversionException, Exception { // add initial comment - String commentId = commentsAPI.addComment(document.getNodeRef(), "This is a new comment").getId(); + RestCommentModel commentModel = commentsAPI.addComment(document, "This is a new comment"); // update comment - RestCommentModel commentEntry = commentsAPI.updateComment(document.getNodeRef(), commentId, "This is the updated comment"); + RestCommentModel commentEntry = commentsAPI.updateComment(document, commentModel, "This is the updated comment"); commentEntry.assertCommentContentIs("This is the updated comment"); } diff --git a/e2e-test/java/org/alfresco/rest/demo/SamplePeopleTest.java b/e2e-test/java/org/alfresco/rest/demo/SamplePeopleTests.java similarity index 69% rename from e2e-test/java/org/alfresco/rest/demo/SamplePeopleTest.java rename to e2e-test/java/org/alfresco/rest/demo/SamplePeopleTests.java index a5718b2dc..1eba0d771 100644 --- a/e2e-test/java/org/alfresco/rest/demo/SamplePeopleTest.java +++ b/e2e-test/java/org/alfresco/rest/demo/SamplePeopleTests.java @@ -13,8 +13,8 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { "rest-api", "people", "sanity" }) -public class SamplePeopleTest extends RestTest +@Test(groups = { "demo" }) +public class SamplePeopleTests extends RestTest { @Autowired RestPeopleApi peopleAPI; @@ -25,8 +25,8 @@ public class SamplePeopleTest extends RestTest private UserModel userModel; private UserModel adminUser; - @BeforeClass - public void setUp() throws DataPreparationException + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws DataPreparationException { userModel = dataUser.createUser(RandomStringUtils.randomAlphanumeric(20)); adminUser = dataUser.getAdminUser(); @@ -34,23 +34,21 @@ public class SamplePeopleTest extends RestTest peopleAPI.useRestClient(restClient); } - @TestRail(section={"rest-api", "people"}, executionType= ExecutionType.SANITY, + @TestRail(section={"demo", "sample-section"}, executionType= ExecutionType.SANITY, description = "Verify admin user gets person with Rest API and response is not empty") public void adminShouldRetrievePerson() throws Exception { - peopleAPI.getPerson(userModel.getUsername()) - .assertResponseIsNotEmpty(); + peopleAPI.getPerson(userModel).assertResponseIsNotEmpty(); peopleAPI.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.OK.toString()); + .assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section={"rest-api", "people"}, executionType= ExecutionType.SANITY, + @TestRail(section={"demo", "sample-section"}, executionType= ExecutionType.SANITY, description = "Admin user gets own person information with Rest Api and assert that name is correct") public void adminShouldRetrieveItself() throws Exception { - peopleAPI.getPerson(adminUser.getUsername()) - .assertPersonHasName(adminUser.getUsername()); + peopleAPI.getPerson(adminUser).assertPersonHasName(adminUser); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/demo/SampleSitesTest.java b/e2e-test/java/org/alfresco/rest/demo/SampleSitesTests.java similarity index 74% rename from e2e-test/java/org/alfresco/rest/demo/SampleSitesTest.java rename to e2e-test/java/org/alfresco/rest/demo/SampleSitesTests.java index 53bcfad31..b759bd775 100644 --- a/e2e-test/java/org/alfresco/rest/demo/SampleSitesTest.java +++ b/e2e-test/java/org/alfresco/rest/demo/SampleSitesTests.java @@ -17,8 +17,8 @@ import org.springframework.social.alfresco.api.entities.Role; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { "rest-api", "people", "sanity" }) -public class SampleSitesTest extends RestTest +@Test(groups = { "demo" }) +public class SampleSitesTests extends RestTest { @Autowired RestSitesApi siteAPI; @@ -32,8 +32,8 @@ public class SampleSitesTest extends RestTest private UserModel userModel; private SiteModel siteModel; - @BeforeClass - public void initTest() throws DataPreparationException + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws DataPreparationException { userModel = dataUser.getAdminUser(); restClient.authenticateUser(userModel); @@ -41,24 +41,24 @@ public class SampleSitesTest extends RestTest siteAPI.useRestClient(restClient); } - @TestRail(section={"rest-api", "sites"}, executionType= ExecutionType.SANITY, + @TestRail(section={"demo", "sample-section"}, executionType= ExecutionType.SANITY, description = "Verify admin user gets site details with Rest API and response is not empty") public void adminShouldGetSiteDetails() throws JsonToModelConversionException, Exception { - siteAPI.getSite(siteModel.getId()) + siteAPI.getSite(siteModel) .assertResponseIsNotEmpty(); } - @TestRail(section={"rest-api", "sites"}, executionType= ExecutionType.SANITY, + @TestRail(section={"demo", "sample-section"}, executionType= ExecutionType.SANITY, description = "Verify admin user gets site information and gets status code OK (200)") public void adminShouldGetSites() throws JsonToModelConversionException, Exception { - siteAPI.getSite(siteModel.getId()); + siteAPI.getSite(siteModel); siteAPI.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.OK.toString()); + .assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section={"rest-api", "sites"}, executionType= ExecutionType.SANITY, + @TestRail(section={"demo", "sample-section"}, executionType= ExecutionType.SANITY, description = "Verify admin user gets sites with Rest API and the response is not empty") public void adminShouldAccessSites() throws JsonToModelConversionException, Exception { @@ -66,16 +66,16 @@ public class SampleSitesTest extends RestTest .assertThatResponseIsNotEmpty(); } - @TestRail(section={"rest-api", "sites"}, executionType= ExecutionType.SANITY, + @TestRail(section={"demo", "sample-section"}, executionType= ExecutionType.SANITY, description = "Verify admin user gets sites with Rest API and status code is 200") public void adminShouldRetrieveSites() throws JsonToModelConversionException, Exception { siteAPI.getSites(); siteAPI.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.OK.toString()); + .assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section={"rest-api", "sites"}, executionType= ExecutionType.SANITY, + @TestRail(section={"demo", "sample-section"}, executionType= ExecutionType.SANITY, description = "Verify admin user gets sites with Rest API and status code is 200") public void adminShouldAccessResponsePagination() throws JsonToModelConversionException, Exception { @@ -83,31 +83,31 @@ public class SampleSitesTest extends RestTest .assertResponseHasPagination(); } - @TestRail(section={"rest-api", "sites"}, executionType= ExecutionType.SANITY, + @TestRail(section={"demo", "sample-section"}, executionType= ExecutionType.SANITY, description = "Verify admin user adds site member with Rest API and status code is 201") public void adminShouldAddNewSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception { UserModel newMember = dataUser.createRandomTestUser(); SiteMember siteMember = new SiteMember(Role.SiteCollaborator.toString(), newMember.getUsername()); - siteAPI.addPerson(siteModel.getId(), siteMember); + siteAPI.addPerson(siteModel, siteMember); siteAPI.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.CREATED.toString()); + .assertStatusCodeIs(HttpStatus.CREATED); } - @TestRail(section={"rest-api", "sites"}, executionType= ExecutionType.SANITY, + @TestRail(section={"demo", "sample-section"}, executionType= ExecutionType.SANITY, description = "Verify that site exists from get all sites request") public void adminShouldGetSiteFromSitesList() throws JsonToModelConversionException, Exception { siteAPI.getAllSites() - .assertThatResponseHasSite(siteModel.getId()); + .assertThatResponseHasSite(siteModel); } - @TestRail(section={"rest-api", "sites"}, executionType= ExecutionType.SANITY, + @TestRail(section={"demo", "sample-section"}, executionType= ExecutionType.SANITY, description = "Verify site details: response not empty, description, title, visibility") public void adminShouldAccessSiteDetails() throws JsonToModelConversionException, Exception { - siteAPI.getSite(siteModel.getId()) + siteAPI.getSite(siteModel) .assertResponseIsNotEmpty() .assertSiteHasDescription(siteModel.getDescription()) .assertSiteHasTitle(siteModel.getTitle()) diff --git a/e2e-test/java/org/alfresco/rest/sites/AddSiteMembershipRequestSanityTest.java b/e2e-test/java/org/alfresco/rest/sites/AddSiteMembershipRequestSanityTests.java similarity index 66% rename from e2e-test/java/org/alfresco/rest/sites/AddSiteMembershipRequestSanityTest.java rename to e2e-test/java/org/alfresco/rest/sites/AddSiteMembershipRequestSanityTests.java index f47f6de31..28722398e 100644 --- a/e2e-test/java/org/alfresco/rest/sites/AddSiteMembershipRequestSanityTest.java +++ b/e2e-test/java/org/alfresco/rest/sites/AddSiteMembershipRequestSanityTests.java @@ -1,8 +1,5 @@ package org.alfresco.rest.sites; -import java.util.Arrays; -import java.util.HashMap; - import org.alfresco.rest.RestTest; import org.alfresco.rest.body.SiteMembership; import org.alfresco.rest.exception.JsonToModelConversionException; @@ -10,9 +7,11 @@ import org.alfresco.rest.requests.RestSitesApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataSite; import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.beans.factory.annotation.Autowired; @@ -20,7 +19,7 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @Test(groups = { "rest-api", "sites", "sanity" }) -public class AddSiteMembershipRequestSanityTest extends RestTest +public class AddSiteMembershipRequestSanityTests extends RestTest { @Autowired RestSitesApi siteAPI; @@ -33,32 +32,31 @@ public class AddSiteMembershipRequestSanityTest extends RestTest private SiteModel siteModel; - private HashMap usersWithRoles; + private ListUserWithRoles usersWithRoles; private UserModel adminUser; - @BeforeClass + @BeforeClass(alwaysRun=true) public void initTest() throws DataPreparationException { adminUser = dataUser.getAdminUser(); siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, - Arrays.asList(UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor)); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); siteAPI.useRestClient(restClient); } - @TestRail(section = { "rest-api", - "sites" }, executionType = ExecutionType.SANITY, description = "Verify site manager is able to create new site membership request") - @Test(enabled = false, description = "Fails due to MNT-16557") + @TestRail(section = { "rest-api","sites" }, executionType = ExecutionType.SANITY, description = "Verify site manager is able to create new site membership request") + @Bug(id="MNT-16557") + @Test(enabled=false) public void siteManagerCanCreateSiteMembershipRequest() throws JsonToModelConversionException, Exception { UserModel newMember = dataUser.createRandomTestUser(); SiteMembership siteMembership = new SiteMembership("Please accept me", siteModel.getId(), "New request"); - restClient.authenticateUser(usersWithRoles.get(UserRole.SiteManager)); - siteAPI.addSiteMembershipRequest(newMember.getUsername(), siteMembership); - siteAPI.getSite(siteModel.getId()).assertResponseIsNotEmpty(); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + siteAPI.addSiteMembershipRequest(newMember, siteMembership); + siteAPI.getSite(siteModel).assertResponseIsNotEmpty(); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembershipInformationSanityTest.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembershipInformationSanityTests.java similarity index 75% rename from e2e-test/java/org/alfresco/rest/sites/GetSiteMembershipInformationSanityTest.java rename to e2e-test/java/org/alfresco/rest/sites/GetSiteMembershipInformationSanityTests.java index e395d0177..7e9254d97 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembershipInformationSanityTest.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembershipInformationSanityTests.java @@ -1,15 +1,12 @@ package org.alfresco.rest.sites; -import java.util.Arrays; -import java.util.HashMap; - import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.requests.RestSitesApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataSite; import org.alfresco.utility.data.DataUser; -import org.alfresco.utility.data.TestData; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; @@ -21,7 +18,7 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @Test(groups = { "rest-api", "sites", "sanity" }) -public class GetSiteMembershipInformationSanityTest extends RestTest +public class GetSiteMembershipInformationSanityTests extends RestTest { @Autowired RestSitesApi siteAPI; @@ -34,15 +31,14 @@ public class GetSiteMembershipInformationSanityTest extends RestTest private SiteModel siteModel; private UserModel adminUser; - private HashMap usersWithRoles; + private ListUserWithRoles usersWithRoles; - @BeforeClass - public void initTest() throws DataPreparationException + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws DataPreparationException { adminUser = dataUser.getAdminUser(); siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, - Arrays.asList(UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor)); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); siteAPI.useRestClient(restClient); } @@ -52,10 +48,10 @@ public class GetSiteMembershipInformationSanityTest extends RestTest description = "Verify site manager is able to retrieve site membership information of another user") public void siteManagerCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.get(UserRole.SiteManager)); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); siteAPI.getSiteMembershipInformation(adminUser.getUsername()); siteAPI.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.OK.toString()); + .assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { "rest-api", "sites" }, @@ -63,10 +59,10 @@ public class GetSiteMembershipInformationSanityTest extends RestTest description = "Verify site collaborator is able to retrieve site membership information of another user") public void siteCollaboratorCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.get(UserRole.SiteCollaborator)); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); siteAPI.getSiteMembershipInformation(adminUser.getUsername()); siteAPI.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.OK.toString()); + .assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { "rest-api", "sites" }, @@ -74,10 +70,10 @@ public class GetSiteMembershipInformationSanityTest extends RestTest description = "Verify site contributor is able to retrieve site membership information of another user") public void siteContributorCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.get(UserRole.SiteContributor)); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); siteAPI.getSiteMembershipInformation(adminUser.getUsername()); siteAPI.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.OK.toString()); + .assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { "rest-api", "sites" }, @@ -85,10 +81,10 @@ public class GetSiteMembershipInformationSanityTest extends RestTest description = "Verify site consumer is able to retrieve site membership information of another user") public void siteConsumerCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.get(UserRole.SiteConsumer)); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); siteAPI.getSiteMembershipInformation(adminUser.getUsername()); siteAPI.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.OK.toString()); + .assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { "rest-api", "sites" }, @@ -97,9 +93,9 @@ public class GetSiteMembershipInformationSanityTest extends RestTest public void siteAdminCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUser); - siteAPI.getSiteMembershipInformation(usersWithRoles.get(UserRole.SiteManager).getUsername()); + siteAPI.getSiteMembershipInformation(usersWithRoles.getOneUserWithRole(UserRole.SiteManager).getUsername()); siteAPI.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.OK.toString()); + .assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { "rest-api", "sites" }, @@ -109,9 +105,9 @@ public class GetSiteMembershipInformationSanityTest extends RestTest { UserModel inexistentUser = new UserModel("inexistent user", "wrong password"); restClient.authenticateUser(inexistentUser); - siteAPI.getSiteMembershipInformation(usersWithRoles.get(UserRole.SiteManager).getUsername()); + siteAPI.getSiteMembershipInformation(usersWithRoles.getOneUserWithRole(UserRole.SiteManager).getUsername()); siteAPI.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.UNAUTHORIZED.toString()); + .assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } \ No newline at end of file diff --git a/e2e-test/resources/sanity-rest.xml b/e2e-test/resources/sanity-rest.xml index 385353b4f..36b07a328 100644 --- a/e2e-test/resources/sanity-rest.xml +++ b/e2e-test/resources/sanity-rest.xml @@ -1,17 +1,22 @@ - + - - - - - - + + + + + + + + + + + From 5d34578370f0fdb3160baad4231337a1c19c6caf Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Thu, 29 Sep 2016 15:22:08 +0300 Subject: [PATCH 0127/1491] using only models --- ...GetPeopleTest.java => GetPeopleTests.java} | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) rename e2e-test/java/org/alfresco/rest/people/{GetPeopleTest.java => GetPeopleTests.java} (90%) diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleTest.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleTests.java similarity index 90% rename from e2e-test/java/org/alfresco/rest/people/GetPeopleTest.java rename to e2e-test/java/org/alfresco/rest/people/GetPeopleTests.java index bc8fd52ed..e0695b06a 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleTest.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleTests.java @@ -14,7 +14,7 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @Test(groups = { "rest-api", "people" }) -public class GetPeopleTest extends RestTest +public class GetPeopleTests extends RestTest { @Autowired RestPeopleApi peopleApi; @@ -41,8 +41,8 @@ public class GetPeopleTest extends RestTest dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); restClient.authenticateUser(managerUser); - peopleApi.getPerson(searchedUser.getUsername()); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + peopleApi.getPerson(searchedUser); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @Test(groups = "sanity") @@ -53,8 +53,8 @@ public class GetPeopleTest extends RestTest dataUser.usingUser(userModel).addUserToSite(collaboratorUser, siteModel, UserRole.SiteCollaborator); restClient.authenticateUser(collaboratorUser); - peopleApi.getPerson(searchedUser.getUsername()); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + peopleApi.getPerson(searchedUser); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @Test(groups = "sanity") @@ -65,8 +65,8 @@ public class GetPeopleTest extends RestTest dataUser.usingUser(userModel).addUserToSite(contributorUser, siteModel, UserRole.SiteContributor); restClient.authenticateUser(contributorUser); - peopleApi.getPerson(searchedUser.getUsername()); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + peopleApi.getPerson(searchedUser); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @Test(groups = "sanity") @@ -77,8 +77,8 @@ public class GetPeopleTest extends RestTest dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel, UserRole.SiteConsumer); restClient.authenticateUser(consumerUser); - peopleApi.getPerson(searchedUser.getUsername()); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + peopleApi.getPerson(searchedUser); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @Test(groups = "sanity") @@ -88,8 +88,8 @@ public class GetPeopleTest extends RestTest UserModel adminUser = dataUser.getAdminUser(); restClient.authenticateUser(adminUser); - peopleApi.getPerson(searchedUser.getUsername()); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + peopleApi.getPerson(searchedUser); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @Test(groups = "sanity") @@ -101,7 +101,7 @@ public class GetPeopleTest extends RestTest UserModel searchedNonUser = new UserModel("nonexistinguser", DataUser.PASSWORD); restClient.authenticateUser(managerUser); - peopleApi.getPerson(searchedNonUser.getUsername()); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND.toString()); + peopleApi.getPerson(searchedNonUser); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); } } From 176ebbdcd6a7afc354e587f2200f8875a78611d4 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Thu, 29 Sep 2016 15:26:44 +0300 Subject: [PATCH 0128/1491] refactor based on latest conventions --- .../rest/comments/PostCommentsSanityTest.java | 101 ------------------ .../comments/PostCommentsSanityTests.java | 100 +++++++++++++++++ 2 files changed, 100 insertions(+), 101 deletions(-) delete mode 100644 e2e-test/java/org/alfresco/rest/comments/PostCommentsSanityTest.java create mode 100644 e2e-test/java/org/alfresco/rest/comments/PostCommentsSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/comments/PostCommentsSanityTest.java b/e2e-test/java/org/alfresco/rest/comments/PostCommentsSanityTest.java deleted file mode 100644 index fa884f8eb..000000000 --- a/e2e-test/java/org/alfresco/rest/comments/PostCommentsSanityTest.java +++ /dev/null @@ -1,101 +0,0 @@ -package org.alfresco.rest.comments; - -import java.util.Arrays; -import java.util.HashMap; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.requests.RestCommentsApi; -import org.alfresco.utility.data.DataUser; -import org.alfresco.utility.data.UserRole; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -@Test(groups = { "rest-api", "comments", "sanity" }) -public class PostCommentsSanityTest extends RestTest -{ - @Autowired - RestCommentsApi commentsAPI; - - @Autowired - DataUser dataUser; - - private UserModel adminUserModel; - private FileModel document; - private SiteModel siteModel; - private HashMap usersWithRoles; - - @BeforeClass - public void initTest() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - restClient.authenticateUser(adminUserModel); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - commentsAPI.useRestClient(restClient); - document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, Arrays.asList(UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor)); - } - - @TestRail(section={"rest-api", "comments"}, executionType= ExecutionType.SANITY, - description= "Verify admin user adds comments with Rest API and status code is 201") - public void admiIsAbleToAddComment() throws JsonToModelConversionException, Exception - { - commentsAPI.addComment(document.getNodeRef(), "This is a new comment added by " + adminUserModel.getUsername()); - commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED.toString()); - } - - @TestRail(section={"rest-api", "comments"}, executionType= ExecutionType.SANITY, - description= "Verify Manager user adds comments with Rest API and status code is 201") - public void managerIsAbleToAddComment() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.get(UserRole.SiteManager)); - commentsAPI.addComment(document.getNodeRef(), "This is a new comment added by user with role: " + UserRole.SiteManager); - commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED.toString()); - } - - @TestRail(section={"rest-api", "comments"}, executionType= ExecutionType.SANITY, - description= "Verify Contributor user adds comments with Rest API and status code is 201") - public void contributorIsAbleToAddComment() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.get(UserRole.SiteContributor)); - commentsAPI.addComment(document.getNodeRef(), "This is a new comment added by user with role" + UserRole.SiteContributor); - commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED.toString()); - } - - @TestRail(section={"rest-api", "comments"}, executionType= ExecutionType.SANITY, - description= "Verify Collaborator user adds comments with Rest API and status code is 201") - public void collaboratorIsAbleToAddComment() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.get(UserRole.SiteCollaborator)); - commentsAPI.addComment(document.getNodeRef(), "This is a new comment added by user with role: " + UserRole.SiteCollaborator); - commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED.toString()); - } - - @TestRail(section={"rest-api", "comments"}, executionType= ExecutionType.SANITY, - description= "Verify Consumer user adds comments with Rest API and status code is 201") - public void consumerIsAbleToAddComment() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.get(UserRole.SiteConsumer)); - commentsAPI.addComment(document.getNodeRef(), "This is a new comment added by user with role: " + UserRole.SiteConsumer); - commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN.toString()); - } - - @TestRail(section = { "rest-api", - "comments" }, executionType = ExecutionType.SANITY, description = "Verify Manager user gets status code 401 if authentication call fails") - public void managerIsNotAbleToAddCommentIfAuthenticationFails() throws JsonToModelConversionException, Exception - { - usersWithRoles.get(UserRole.SiteManager).setPassword("wrongPassword"); - restClient.authenticateUser(usersWithRoles.get(UserRole.SiteManager)); - commentsAPI.addComment(document.getNodeRef(), "This is a new comment added by user with role: " + UserRole.SiteManager); - commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED.toString()); - } - -} diff --git a/e2e-test/java/org/alfresco/rest/comments/PostCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/PostCommentsSanityTests.java new file mode 100644 index 000000000..d7e8f85d7 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/comments/PostCommentsSanityTests.java @@ -0,0 +1,100 @@ +package org.alfresco.rest.comments; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.requests.RestCommentsApi; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +@Test(groups = { "rest-api", "comments", "sanity" }) +public class PostCommentsSanityTests extends RestTest +{ + @Autowired + RestCommentsApi commentsAPI; + + @Autowired + DataUser dataUser; + + private UserModel adminUserModel; + private FileModel document; + private SiteModel siteModel; + private ListUserWithRoles usersWithRoles; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + restClient.authenticateUser(adminUserModel); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + commentsAPI.useRestClient(restClient); + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + } + + @TestRail(section = { "rest-api", + "comments" }, executionType = ExecutionType.SANITY, description = "Verify admin user adds comments with Rest API and status code is 201") + public void admiIsAbleToAddComment() throws JsonToModelConversionException, Exception + { + commentsAPI.addComment(document, "This is a new comment added by " + adminUserModel.getUsername()); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + } + + @TestRail(section = { "rest-api", + "comments" }, executionType = ExecutionType.SANITY, description = "Verify Manager user adds comments with Rest API and status code is 201") + public void managerIsAbleToAddComment() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + commentsAPI.addComment(document, "This is a new comment added by user with role: " + UserRole.SiteManager); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + } + + @TestRail(section = { "rest-api", + "comments" }, executionType = ExecutionType.SANITY, description = "Verify Contributor user adds comments with Rest API and status code is 201") + public void contributorIsAbleToAddComment() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + commentsAPI.addComment(document, "This is a new comment added by user with role" + UserRole.SiteContributor); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + } + + @TestRail(section = { "rest-api", + "comments" }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user adds comments with Rest API and status code is 201") + public void collaboratorIsAbleToAddComment() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + commentsAPI.addComment(document, "This is a new comment added by user with role: " + UserRole.SiteCollaborator); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + } + + @TestRail(section = { "rest-api", + "comments" }, executionType = ExecutionType.SANITY, description = "Verify Consumer user adds comments with Rest API and status code is 201") + public void consumerIsAbleToAddComment() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + commentsAPI.addComment(document, "This is a new comment added by user with role: " + UserRole.SiteConsumer); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + } + + @TestRail(section = { "rest-api", + "comments" }, executionType = ExecutionType.SANITY, description = "Verify Manager user gets status code 401 if authentication call fails") + public void managerIsNotAbleToAddCommentIfAuthenticationFails() throws JsonToModelConversionException, Exception + { + UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); + siteManager.setPassword("wrongPassword"); + restClient.authenticateUser(siteManager); + commentsAPI.addComment(document, "This is a new comment added by user with role: " + UserRole.SiteManager); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + } + +} From 0a0e586283d8a5a3be0e7eaa1572939a3b37d97f Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Thu, 29 Sep 2016 16:17:50 +0300 Subject: [PATCH 0129/1491] refacor based on naming conventions --- ...st.java => UpdateCommentsSanityTests.java} | 59 +++++++++---------- 1 file changed, 28 insertions(+), 31 deletions(-) rename e2e-test/java/org/alfresco/rest/comments/{UpdateCommentsSanityTest.java => UpdateCommentsSanityTests.java} (72%) diff --git a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTest.java b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java similarity index 72% rename from e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTest.java rename to e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java index 1c141f75b..3a431ae44 100644 --- a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTest.java +++ b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java @@ -1,8 +1,5 @@ package org.alfresco.rest.comments; -import java.util.Arrays; -import java.util.HashMap; - import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; @@ -10,7 +7,9 @@ import org.alfresco.rest.model.RestCommentModel; import org.alfresco.rest.requests.RestCommentsApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; @@ -21,9 +20,8 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @Test(groups = { "rest-api", "comments", "sanity" }) -public class UpdateCommentsSanityTest extends RestTest +public class UpdateCommentsSanityTests extends RestTest { - @Autowired RestCommentsApi commentsAPI; @@ -34,65 +32,64 @@ public class UpdateCommentsSanityTest extends RestTest private FileModel document; private SiteModel siteModel; private RestCommentModel commentModel; - private HashMap usersWithRoles; + private ListUserWithRoles usersWithRoles; - @BeforeClass - public void initTest() throws Exception + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception { adminUserModel = dataUser.getAdminUser(); restClient.authenticateUser(adminUserModel); siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); commentsAPI.useRestClient(restClient); document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - commentModel = commentsAPI.addComment(document.getNodeRef(), "This is a new comment"); + commentModel = commentsAPI.addComment(document, "This is a new comment"); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, - Arrays.asList(UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor)); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); } @TestRail(section = { "rest-api", "comments" }, executionType = ExecutionType.SANITY, description = "Verify Admin user updates comments with Rest API and status code is 200") public void adminIsAbleToUpdateComments() throws JsonToModelConversionException, Exception { - commentsAPI.updateComment(document.getNodeRef(), commentModel.getId(), commentModel.getContent()); - commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + commentsAPI.updateComment(document, commentModel, commentModel.getContent()); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { "rest-api", "comments" }, executionType = ExecutionType.SANITY, description = "Verify Manager user updates comments created by admin user with Rest API and status code is 200") public void managerIsAbleToUpdateComment() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.get(UserRole.SiteManager)); - commentsAPI.updateComment(document.getNodeRef(), commentModel.getId(), commentModel.getContent()); - commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + commentsAPI.updateComment(document, commentModel, commentModel.getContent()); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { "rest-api", "comments" }, executionType = ExecutionType.SANITY, description = "Verify Contributor user updates comments created by admin user with Rest API and status code is 200") public void contributorIsAbleToUpdateComment() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.get(UserRole.SiteContributor)); - commentsAPI.updateComment(document.getNodeRef(), commentModel.getId(), "This is the updated comment with Contributor user"); - commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN.toString()); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + commentsAPI.updateComment(document, commentModel, "This is the updated comment with Contributor user"); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } @TestRail(section = { "rest-api", "comments" }, executionType = ExecutionType.SANITY, description = "Verify Consumer user updates comments created by admin user with Rest API and status code is 200") public void consumerIsAbleToUpdateComment() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.get(UserRole.SiteConsumer)); - commentsAPI.updateComment(document.getNodeRef(), commentModel.getId(), commentModel.getContent()); - commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN.toString()); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + commentsAPI.updateComment(document, commentModel, commentModel.getContent()); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } @TestRail(section = { "rest-api", "comments" }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user updates comments created by admin user with Rest API and status code is 200") public void collaboratorIsAbleToUpdateComment() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.get(UserRole.SiteCollaborator)); - RestCommentModel commentEntry = commentsAPI.updateComment(document.getNodeRef(), commentModel.getId(), + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + RestCommentModel commentEntry = commentsAPI.updateComment(document, commentModel, "This is the updated comment with Collaborator user"); - commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN.toString()); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); commentEntry.assertCommentContentIs("This is the updated comment with Collaborator user"); } @@ -102,24 +99,24 @@ public class UpdateCommentsSanityTest extends RestTest { UserModel incorrectUserModel = new UserModel("userName", "password"); restClient.authenticateUser(incorrectUserModel); - commentsAPI.getNodeComments(document.getNodeRef()); - commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED.toString()); + commentsAPI.getNodeComments(document); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } @TestRail(section = { "rest-api", "comments" }, executionType = ExecutionType.SANITY, description = "Verify if nodeId is not set the status code is 404") public void canNotUpdateCommentIfNodeIdIsNotSet() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); - commentsAPI.updateComment("unexistingId", commentModel.getId(), commentModel.getContent()); - commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND.toString()); + commentsAPI.updateComment(FolderModel.getRandomFolderModel(), commentModel, commentModel.getContent()); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); } @TestRail(section = { "rest-api", "comments" }, executionType = ExecutionType.SANITY, description = "Verify if commentId is not set the status code is 404") public void canNotUpdateCommentIfCommentIdIsNotSet() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); - commentsAPI.updateComment(document.getNodeRef(), "unexistingId", commentModel.getContent()); - commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND.toString()); + commentsAPI.updateComment(document, new RestCommentModel(), commentModel.getContent()); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); } } From ac086a64ad077634f232e19d12963df789001123 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Thu, 29 Sep 2016 16:37:50 +0300 Subject: [PATCH 0130/1491] adding bug annotation --- .../people/DeleteSiteMemberSanityTests.java | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java index b96d1dd54..dc6e25f8c 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java @@ -12,6 +12,7 @@ import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.beans.factory.annotation.Autowired; @@ -64,7 +65,7 @@ public class DeleteSiteMemberSanityTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); sitesApi.addPerson(siteModel, siteMember); - peopleApi.deleteSiteMember(newUser.getUsername(), siteModel.getId()); + peopleApi.deleteSiteMember(newUser, siteModel); sitesApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.NO_CONTENT); } @@ -79,15 +80,15 @@ public class DeleteSiteMemberSanityTests extends RestTest restClient.authenticateUser(adminUser); sitesApi.addPerson(siteModel, siteMember); - peopleApi.deleteSiteMember(newUser.getUsername(), siteModel.getId()); + peopleApi.deleteSiteMember(newUser, siteModel); sitesApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.NO_CONTENT); } @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, - description = "Verify site collaborator does not have permission to delete another member of the site") - // TODO BUG ACE-5444 + description = "Verify site collaborator does not have permission to delete another member of the site") + @Bug(id="ACE-5444") public void siteCollaboratorIsNotAbleToDeleteSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception { newUser = dataUser.createRandomTestUser(); @@ -96,14 +97,14 @@ public class DeleteSiteMemberSanityTests extends RestTest sitesApi.addPerson(siteModel, siteMember); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - peopleApi.deleteSiteMember(newUser.getUsername(), siteModel.getId()); + peopleApi.deleteSiteMember(newUser, siteModel); sitesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify site contributor does not have permission to delete another member of the site") - // TODO BUG ACE-5444 + @Bug(id="ACE-5444") public void siteContributorIsNotAbleToDeleteSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception { newUser = dataUser.createRandomTestUser(); @@ -112,14 +113,14 @@ public class DeleteSiteMemberSanityTests extends RestTest sitesApi.addPerson(siteModel, siteMember); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - peopleApi.deleteSiteMember(newUser.getUsername(), siteModel.getId()); + peopleApi.deleteSiteMember(newUser, siteModel); sitesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify site consumer does not have permission to delete another member of the site") - // TODO BUG ACE-5444 + @Bug(id="ACE-5444") public void siteConsumerIsNotAbleToDeleteSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception { newUser = dataUser.createRandomTestUser(); @@ -128,7 +129,7 @@ public class DeleteSiteMemberSanityTests extends RestTest sitesApi.addPerson(siteModel, siteMember); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - peopleApi.deleteSiteMember(newUser.getUsername(), siteModel.getId()); + peopleApi.deleteSiteMember(newUser, siteModel); sitesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } @@ -139,7 +140,7 @@ public class DeleteSiteMemberSanityTests extends RestTest { restClient.authenticateUser(new UserModel("random user", "random password")); - peopleApi.deleteSiteMember(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer).getUsername(), siteModel.getId()); + peopleApi.deleteSiteMember(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer), siteModel); sitesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } \ No newline at end of file From e977463b48c451fe628a0381a78c3aa3843989c7 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Thu, 29 Sep 2016 17:02:06 +0300 Subject: [PATCH 0131/1491] merge story 738 --- .../rest/sites/GetSiteMembersSanityTests.java | 42 +++++++++---------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java index a01eae781..93bb6ea26 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java @@ -1,14 +1,12 @@ package org.alfresco.rest.sites; -import java.util.Arrays; -import java.util.HashMap; - import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.requests.RestSitesApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataSite; import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; @@ -36,7 +34,7 @@ public class GetSiteMembersSanityTests extends RestTest private SiteModel siteModel; private UserModel adminUser; - private HashMap usersWithRoles; + private ListUserWithRoles usersWithRoles; private UserModel userModel; @BeforeClass(alwaysRun=true) @@ -45,45 +43,43 @@ public class GetSiteMembersSanityTests extends RestTest adminUser = dataUser.getAdminUser(); siteAPI.useRestClient(restClient); siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, - Arrays.asList(UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor)); - + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); } @TestRail(section = {"rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role gets site members and gets status code OK (200)") public void getSiteMembersWithManagerRole() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.get(UserRole.SiteManager)); - siteAPI.getSiteMembers(siteModel.getId()); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + siteAPI.getSiteMembers(siteModel); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = {"rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify user with Collaborator role gets site members and gets status code OK (200)") public void getSiteMembersWithCollaboratorRole() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.get(UserRole.SiteCollaborator)); - siteAPI.getSiteMembers(siteModel.getId()); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + siteAPI.getSiteMembers(siteModel); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = {"rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify user with Contributor role gets site members and gets status code OK (200)") public void getSiteMembersWithContributorRole() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.get(UserRole.SiteContributor)); - siteAPI.getSiteMembers(siteModel.getId()); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + siteAPI.getSiteMembers(siteModel); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = {"rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role gets site members and gets status code OK (200)") public void getSiteMembersWithConsumerRole() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.get(UserRole.SiteConsumer)); - siteAPI.getSiteMembers(siteModel.getId()); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + siteAPI.getSiteMembers(siteModel); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = {"rest-api", "sites" }, executionType = ExecutionType.SANITY, @@ -91,8 +87,8 @@ public class GetSiteMembersSanityTests extends RestTest public void getSiteMembersWithAdminUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUser); - siteAPI.getSiteMembers(siteModel.getId()); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + siteAPI.getSiteMembers(siteModel); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = {"rest-api", "sites" }, executionType = ExecutionType.SANITY, @@ -103,7 +99,7 @@ public class GetSiteMembersSanityTests extends RestTest userModel.setPassword("user wrong password"); dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); restClient.authenticateUser(userModel); - siteAPI.getSiteMembers(siteModel.getId()); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED.toString()); + siteAPI.getSiteMembers(siteModel); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } From ea96dd0f35cc42fa06d089cf73530b63296450c0 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Thu, 29 Sep 2016 17:18:01 +0300 Subject: [PATCH 0132/1491] update sanity and abstract restTest --- e2e-test/java/org/alfresco/rest/RestTest.java | 4 ---- e2e-test/resources/sanity-rest.xml | 3 +-- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/RestTest.java b/e2e-test/java/org/alfresco/rest/RestTest.java index 69cc678cc..28598c139 100644 --- a/e2e-test/java/org/alfresco/rest/RestTest.java +++ b/e2e-test/java/org/alfresco/rest/RestTest.java @@ -8,16 +8,12 @@ import org.alfresco.utility.data.DataSite; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.network.ServerHealth; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Scope; -import org.springframework.stereotype.Component; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; import org.testng.annotations.BeforeClass; import com.jayway.restassured.RestAssured; -@Component -@Scope(value = "prototype") @ContextConfiguration("classpath:alfresco-restapi-context.xml") public abstract class RestTest extends AbstractTestNGSpringContextTests { diff --git a/e2e-test/resources/sanity-rest.xml b/e2e-test/resources/sanity-rest.xml index 36b07a328..80bd6abc1 100644 --- a/e2e-test/resources/sanity-rest.xml +++ b/e2e-test/resources/sanity-rest.xml @@ -10,8 +10,7 @@ - - + From 9799b4e3ce13884172fd6c4b4c5a50fd1a7f2236 Mon Sep 17 00:00:00 2001 From: cnechifor Date: Thu, 29 Sep 2016 23:47:58 +0300 Subject: [PATCH 0133/1491] added RestTagsModel &Collection, RestTagsApi and GetTagsSanityTests --- e2e-test/java/tags/GetTagsSanityTests.java | 98 ++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 e2e-test/java/tags/GetTagsSanityTests.java diff --git a/e2e-test/java/tags/GetTagsSanityTests.java b/e2e-test/java/tags/GetTagsSanityTests.java new file mode 100644 index 000000000..a19dfb9bd --- /dev/null +++ b/e2e-test/java/tags/GetTagsSanityTests.java @@ -0,0 +1,98 @@ +package tags; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.requests.RestTagsApi; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +@Test(groups = { "rest-api", "tags", "sanity" }) +public class GetTagsSanityTests extends RestTest +{ + @Autowired + private DataUser dataUser; + + @Autowired + private RestTagsApi tagsAPI; + + private UserModel adminUserModel; + private UserModel userModel; + private SiteModel siteModel; + private ListUserWithRoles usersWithRoles; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + restClient.authenticateUser(adminUserModel); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + tagsAPI.useRestClient(restClient); + } + + + @TestRail(section = { "rest-api", "tags" }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role gets tags using REST API and status code is OK (200)") + public void getTagsWithManagerRole() throws JsonToModelConversionException, Exception + { + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + tagsAPI.getTags(); + tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { "rest-api", "tags" }, executionType = ExecutionType.SANITY, description = "Verify user with Collaborator role gets tags using REST API and status code is OK (200)") + public void getTagsWithCollaboratorRole() throws JsonToModelConversionException, Exception + { + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + tagsAPI.getTags(); + tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { "rest-api", "tags" }, executionType = ExecutionType.SANITY, description = "Verify user with Contributor role gets tags using REST API and status code is OK (200)") + public void getTagsWithContributorRole() throws JsonToModelConversionException, Exception + { + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + tagsAPI.getTags(); + tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { "rest-api", "tags" }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role gets tags using REST API and status code is OK (200)") + public void getTagsWithConsumerRole() throws JsonToModelConversionException, Exception + { + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + tagsAPI.getTags(); + tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { "rest-api", "tags" }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets tags using REST API and status code is OK (200)") + public void getTagsWithAdminUser() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel); + tagsAPI.getTags(); + tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { "rest-api", "tags" }, executionType = ExecutionType.SANITY, description = "Failed authentication get tags call returns status code 401 with Manager role") + public void getTagsWithManagerRoleFailedAuth() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + userModel = dataUser.createRandomTestUser(); + userModel.setPassword("user wrong password"); + dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); + restClient.authenticateUser(userModel); + tagsAPI.getTags(); + tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + } +} From 4954d740fa3ef7638847fb758fe9c419d5ff2c93 Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Fri, 30 Sep 2016 10:21:05 +0300 Subject: [PATCH 0134/1491] TAS-978 getSiteContainer with Manager Role --- .../sites/GetSiteContainerSanityTests.java | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java new file mode 100644 index 000000000..b25291a87 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java @@ -0,0 +1,61 @@ +package org.alfresco.rest.sites; + +import java.util.List; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestSiteContainerModel; +import org.alfresco.rest.requests.RestSitesApi; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataSite; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * @author iulia.cojocea + */ +@Test(groups = { "rest-api", "sites", "sanity" }) +public class GetSiteContainerSanityTests extends RestTest +{ + @Autowired + RestSitesApi siteAPI; + + @Autowired + DataUser dataUser; + + @Autowired + DataSite dataSite; + + private UserModel adminUserModel; + private SiteModel siteModel; + private ListUserWithRoles usersWithRoles; + private List listOfFoldersIds; + + @BeforeClass(alwaysRun=true) + public void initTest() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + siteAPI.useRestClient(restClient); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + } + + @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, + description = "Verify user with Manager role gets site container and gets status code OK (200)") + public void getSiteContainerWithManagerRole() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + listOfFoldersIds = siteAPI.getSiteContainers(siteModel).getSiteContainersList(); + siteAPI.getSiteContainer(siteModel, listOfFoldersIds.get(0)); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } +} From 761a41e28e77e3488799214f02445de19a3ba03e Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Fri, 30 Sep 2016 10:23:50 +0300 Subject: [PATCH 0135/1491] TAS-979 getSiteContainer with Collaborator role --- .../rest/sites/GetSiteContainerSanityTests.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java index b25291a87..36ceea1e6 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java @@ -58,4 +58,14 @@ public class GetSiteContainerSanityTests extends RestTest siteAPI.getSiteContainer(siteModel, listOfFoldersIds.get(0)); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, + description = "Verify user with Collaborator role gets site container and gets status code OK (200)") + public void getSiteContainerWithCollaboratorRole() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + listOfFoldersIds = siteAPI.getSiteContainers(siteModel).getSiteContainersList(); + siteAPI.getSiteContainer(siteModel, listOfFoldersIds.get(0)); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } } From 0bf3be833993c5a8d298acd7a1d6ab4706755eef Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Fri, 30 Sep 2016 10:27:39 +0300 Subject: [PATCH 0136/1491] TAS-980 getSiteContainer with Contributor role --- .../rest/sites/GetSiteContainerSanityTests.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java index 36ceea1e6..2c1ce48ce 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java @@ -58,7 +58,7 @@ public class GetSiteContainerSanityTests extends RestTest siteAPI.getSiteContainer(siteModel, listOfFoldersIds.get(0)); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - + @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify user with Collaborator role gets site container and gets status code OK (200)") public void getSiteContainerWithCollaboratorRole() throws JsonToModelConversionException, Exception @@ -68,4 +68,14 @@ public class GetSiteContainerSanityTests extends RestTest siteAPI.getSiteContainer(siteModel, listOfFoldersIds.get(0)); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, + description = "Verify user with Contributor role gets site container and gets status code OK (200)") + public void getSiteContainerWithContributorRole() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + listOfFoldersIds = siteAPI.getSiteContainers(siteModel).getSiteContainersList(); + siteAPI.getSiteContainer(siteModel, listOfFoldersIds.get(0)); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } } From ba186fea036488509ea1dc8e799157c81b600fc7 Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Fri, 30 Sep 2016 10:28:40 +0300 Subject: [PATCH 0137/1491] TAS-981 getSiteContainer with Consumer role --- .../rest/sites/GetSiteContainerSanityTests.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java index 2c1ce48ce..96324027f 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java @@ -78,4 +78,14 @@ public class GetSiteContainerSanityTests extends RestTest siteAPI.getSiteContainer(siteModel, listOfFoldersIds.get(0)); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, + description = "Verify user with Consumer role gets site container and gets status code OK (200)") + public void getSiteContainerWithConsumerRole() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + listOfFoldersIds = siteAPI.getSiteContainers(siteModel).getSiteContainersList(); + siteAPI.getSiteContainer(siteModel, listOfFoldersIds.get(0)); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } } From d16a8618d259e15335b7f3f187e1fd2c964c0575 Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Fri, 30 Sep 2016 10:30:27 +0300 Subject: [PATCH 0138/1491] TAS-982 getSiteContainer with admin user --- .../rest/sites/GetSiteContainerSanityTests.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java index 96324027f..060214fe8 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java @@ -88,4 +88,14 @@ public class GetSiteContainerSanityTests extends RestTest siteAPI.getSiteContainer(siteModel, listOfFoldersIds.get(0)); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, + description = "Verify user with admin user gets site container and gets status code OK (200)") + public void getSiteContainerWithAdminUser() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel); + listOfFoldersIds = siteAPI.getSiteContainers(siteModel).getSiteContainersList(); + siteAPI.getSiteContainer(siteModel, listOfFoldersIds.get(0)); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } } From 69f7ec4e6c5cab6e151a7ecc63b885f1745367b5 Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Fri, 30 Sep 2016 10:35:25 +0300 Subject: [PATCH 0139/1491] TAS-983 getSiteContainer call returns status code 401 with Manager role --- .../rest/sites/GetSiteContainerSanityTests.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java index 060214fe8..1286ab2e4 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java @@ -38,6 +38,7 @@ public class GetSiteContainerSanityTests extends RestTest private SiteModel siteModel; private ListUserWithRoles usersWithRoles; private List listOfFoldersIds; + private UserModel userModel; @BeforeClass(alwaysRun=true) public void initTest() throws Exception @@ -98,4 +99,18 @@ public class GetSiteContainerSanityTests extends RestTest siteAPI.getSiteContainer(siteModel, listOfFoldersIds.get(0)); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, + description = "Failed authentication get site container call returns status code 401 with Manager role") + public void unauthenticatedUserIsNotAuthorizedToRetrieveSiteContainer() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + userModel = dataUser.createRandomTestUser(); + userModel.setPassword("user wrong password"); + dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); + restClient.authenticateUser(userModel); + listOfFoldersIds = siteAPI.getSiteContainers(siteModel).getSiteContainersList(); + siteAPI.getSiteContainer(siteModel, listOfFoldersIds.get(0)); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + } } From 9ede329caea30e6b7284a1ea1cf002edb311e825 Mon Sep 17 00:00:00 2001 From: cnechifor Date: Fri, 30 Sep 2016 11:56:37 +0300 Subject: [PATCH 0140/1491] moved getSites and getTags --- e2e-test/java/org/alfresco/rest/{ => sites}/GetSitesTests.java | 3 ++- .../java/{ => org/alfresco/rest}/tags/GetTagsSanityTests.java | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) rename e2e-test/java/org/alfresco/rest/{ => sites}/GetSitesTests.java (98%) rename e2e-test/java/{ => org/alfresco/rest}/tags/GetTagsSanityTests.java (99%) diff --git a/e2e-test/java/org/alfresco/rest/GetSitesTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSitesTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/GetSitesTests.java rename to e2e-test/java/org/alfresco/rest/sites/GetSitesTests.java index 5790a8dc8..3f4a54291 100644 --- a/e2e-test/java/org/alfresco/rest/GetSitesTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSitesTests.java @@ -1,5 +1,6 @@ -package org.alfresco.rest; +package org.alfresco.rest.sites; +import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.requests.RestSitesApi; import org.alfresco.utility.constants.UserRole; diff --git a/e2e-test/java/tags/GetTagsSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java similarity index 99% rename from e2e-test/java/tags/GetTagsSanityTests.java rename to e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java index a19dfb9bd..733a17bfe 100644 --- a/e2e-test/java/tags/GetTagsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java @@ -1,4 +1,4 @@ -package tags; +package org.alfresco.rest.tags; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; From bc988f10e4bd0a1d5fa7435e555769dded867461 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Fri, 30 Sep 2016 14:07:16 +0300 Subject: [PATCH 0141/1491] Fix failing tests due to framework extention --- .../comments/PostCommentsSanityTests.java | 12 ++-- .../comments/UpdateCommentsSanityTests.java | 62 ++++++++++++++----- .../org/alfresco/rest/demo/RestDemoTests.java | 6 +- .../rest/demo/SampleCommentsTests.java | 6 +- .../alfresco/rest/demo/SamplePeopleTests.java | 7 --- 5 files changed, 56 insertions(+), 37 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/comments/PostCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/PostCommentsSanityTests.java index d7e8f85d7..a4a360f24 100644 --- a/e2e-test/java/org/alfresco/rest/comments/PostCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/PostCommentsSanityTests.java @@ -87,13 +87,11 @@ public class PostCommentsSanityTests extends RestTest } @TestRail(section = { "rest-api", - "comments" }, executionType = ExecutionType.SANITY, description = "Verify Manager user gets status code 401 if authentication call fails") - public void managerIsNotAbleToAddCommentIfAuthenticationFails() throws JsonToModelConversionException, Exception - { - UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); - siteManager.setPassword("wrongPassword"); - restClient.authenticateUser(siteManager); - commentsAPI.addComment(document, "This is a new comment added by user with role: " + UserRole.SiteManager); + "comments" }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user gets status code 401 on post comments call") + public void unauthenticatedUserIsNotAbleToAddComment() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(new UserModel("random user", "random password")); + commentsAPI.addComment(document, "This is a new comment"); commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } diff --git a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java index 3a431ae44..b52dff072 100644 --- a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java @@ -2,6 +2,7 @@ package org.alfresco.rest.comments; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; +import org.alfresco.rest.body.CommentContent; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestCommentModel; import org.alfresco.rest.requests.RestCommentsApi; @@ -12,6 +13,7 @@ import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.beans.factory.annotation.Autowired; @@ -48,54 +50,68 @@ public class UpdateCommentsSanityTests extends RestTest } @TestRail(section = { "rest-api", - "comments" }, executionType = ExecutionType.SANITY, description = "Verify Admin user updates comments with Rest API and status code is 200") + "comments" }, executionType = ExecutionType.SANITY, description = "Verify Admin user updates comments and status code is 200") public void adminIsAbleToUpdateComments() throws JsonToModelConversionException, Exception { - commentsAPI.updateComment(document, commentModel, commentModel.getContent()); + CommentContent commentContent = new CommentContent("This is the updated comment with admin user"); + + commentsAPI.updateComment(document, commentModel, commentContent); commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { "rest-api", - "comments" }, executionType = ExecutionType.SANITY, description = "Verify Manager user updates comments created by admin user with Rest API and status code is 200") + "comments" }, executionType = ExecutionType.SANITY, description = "Verify Manager user updates comments created by admin user and status code is 200") public void managerIsAbleToUpdateComment() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - commentsAPI.updateComment(document, commentModel, commentModel.getContent()); + + CommentContent commentContent = new CommentContent("This is the updated comment with Manager user"); + + commentsAPI.updateComment(document, commentModel, commentContent); commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { "rest-api", - "comments" }, executionType = ExecutionType.SANITY, description = "Verify Contributor user updates comments created by admin user with Rest API and status code is 200") + "comments" }, executionType = ExecutionType.SANITY, description = "Verify Contributor user updates comments created by admin user and status code is 200") public void contributorIsAbleToUpdateComment() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - commentsAPI.updateComment(document, commentModel, "This is the updated comment with Contributor user"); + + CommentContent commentContent = new CommentContent("This is the updated comment with Contributor user"); + + commentsAPI.updateComment(document, commentModel, commentContent); commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } @TestRail(section = { "rest-api", - "comments" }, executionType = ExecutionType.SANITY, description = "Verify Consumer user updates comments created by admin user with Rest API and status code is 200") + "comments" }, executionType = ExecutionType.SANITY, description = "Verify Consumer user updates comments created by admin user and status code is 200") public void consumerIsAbleToUpdateComment() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - commentsAPI.updateComment(document, commentModel, commentModel.getContent()); + + CommentContent commentContent = new CommentContent("This is the updated comment with Consumer user"); + + commentsAPI.updateComment(document, commentModel, commentContent); commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } @TestRail(section = { "rest-api", - "comments" }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user updates comments created by admin user with Rest API and status code is 200") + "comments" }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user updates comment created by admin user and status code is 200") + @Bug(id="REPO-1011") public void collaboratorIsAbleToUpdateComment() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - RestCommentModel commentEntry = commentsAPI.updateComment(document, commentModel, - "This is the updated comment with Collaborator user"); + + CommentContent commentContent = new CommentContent("This is the updated comment with Collaborator user"); + + RestCommentModel commentEntry = commentsAPI.updateComment(document, commentModel, commentContent); commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); commentEntry.assertCommentContentIs("This is the updated comment with Collaborator user"); } @TestRail(section = { "rest-api", - "comments" }, executionType = ExecutionType.SANITY, description = "Verify Manager user gets status code 401 if authentication call fails") - public void managerIsNotAbleToUpdateCommentIfAuthenticationFails() throws JsonToModelConversionException, Exception + "comments" }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user gets status code 401 on update comment call") + public void unauthenticatedUserIsNotAbleToUpdateComment() throws JsonToModelConversionException, Exception { UserModel incorrectUserModel = new UserModel("userName", "password"); restClient.authenticateUser(incorrectUserModel); @@ -103,11 +119,17 @@ public class UpdateCommentsSanityTests extends RestTest commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } - @TestRail(section = { "rest-api", "comments" }, executionType = ExecutionType.SANITY, description = "Verify if nodeId is not set the status code is 404") + @TestRail(section = { "rest-api", "comments" }, executionType = ExecutionType.SANITY, description = "Verify update comment with inexistent nodeId returns status code 404") public void canNotUpdateCommentIfNodeIdIsNotSet() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); - commentsAPI.updateComment(FolderModel.getRandomFolderModel(), commentModel, commentModel.getContent()); + + FolderModel content = FolderModel.getRandomFolderModel(); + content.setNodeRef("node ref that does not exist"); + + CommentContent comment = new CommentContent("This is the updated comment."); + + commentsAPI.updateComment(content, commentModel, comment); commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); } @@ -115,8 +137,14 @@ public class UpdateCommentsSanityTests extends RestTest public void canNotUpdateCommentIfCommentIdIsNotSet() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); - commentsAPI.updateComment(document, new RestCommentModel(), commentModel.getContent()); + + RestCommentModel comment = new RestCommentModel(); + comment.setId("comment id that does not exist"); + + CommentContent commentContent = new CommentContent("This is the updated comment."); + + commentsAPI.updateComment(document, comment, commentContent); commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); } -} +} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/demo/RestDemoTests.java b/e2e-test/java/org/alfresco/rest/demo/RestDemoTests.java index abc93e8f2..d9bc66df4 100644 --- a/e2e-test/java/org/alfresco/rest/demo/RestDemoTests.java +++ b/e2e-test/java/org/alfresco/rest/demo/RestDemoTests.java @@ -2,6 +2,7 @@ package org.alfresco.rest.demo; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; +import org.alfresco.rest.body.CommentContent; import org.alfresco.rest.body.SiteMember; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestCommentModel; @@ -82,9 +83,8 @@ public class RestDemoTests extends RestTest .assertCommentWithIdExists(commentEntry); // update comment - commentEntry = commentsAPI.updateComment(fileModel, - commentEntry, - "This is the updated comment"); + CommentContent commentContent = new CommentContent("This is the updated comment with Collaborator user"); + commentEntry = commentsAPI.updateComment(fileModel, commentEntry, commentContent); commentsAPI.getNodeComments(fileModel) .assertResponseIsNotEmpty() diff --git a/e2e-test/java/org/alfresco/rest/demo/SampleCommentsTests.java b/e2e-test/java/org/alfresco/rest/demo/SampleCommentsTests.java index ce58f0191..4ae593295 100644 --- a/e2e-test/java/org/alfresco/rest/demo/SampleCommentsTests.java +++ b/e2e-test/java/org/alfresco/rest/demo/SampleCommentsTests.java @@ -2,6 +2,7 @@ package org.alfresco.rest.demo; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; +import org.alfresco.rest.body.CommentContent; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestCommentModel; import org.alfresco.rest.requests.RestCommentsApi; @@ -61,11 +62,10 @@ public class SampleCommentsTests extends RestTest description= "Verify admin user updates comments with Rest API") public void adminShouldUpdateComment() throws JsonToModelConversionException, Exception { - // add initial comment RestCommentModel commentModel = commentsAPI.addComment(document, "This is a new comment"); - // update comment - RestCommentModel commentEntry = commentsAPI.updateComment(document, commentModel, "This is the updated comment"); + CommentContent commentContent = new CommentContent("This is the updated comment with Collaborator user"); + RestCommentModel commentEntry = commentsAPI.updateComment(document, commentModel, commentContent); commentEntry.assertCommentContentIs("This is the updated comment"); } diff --git a/e2e-test/java/org/alfresco/rest/demo/SamplePeopleTests.java b/e2e-test/java/org/alfresco/rest/demo/SamplePeopleTests.java index 479de2cce..2c0c6dd99 100644 --- a/e2e-test/java/org/alfresco/rest/demo/SamplePeopleTests.java +++ b/e2e-test/java/org/alfresco/rest/demo/SamplePeopleTests.java @@ -40,11 +40,4 @@ public class SamplePeopleTests extends RestTest .assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section={"demo", "sample-section"}, executionType= ExecutionType.SANITY, - description = "Admin user gets own person information with Rest Api and assert that name is correct") - public void adminShouldRetrieveItself() throws Exception - { - peopleAPI.getPerson(adminUser).assertPersonHasName(adminUser); - } - } \ No newline at end of file From 51b5e27578e49baa02a3f3efb3d5200c5e1c9e9d Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Fri, 30 Sep 2016 17:10:35 +0300 Subject: [PATCH 0142/1491] TAS-1014 REST API - valid request returns success status code 200 with Manager role | Move people APIs from sites to people --- .../AddSiteMembershipRequestSanityTests.java | 22 ++-- .../people/GetSiteMembershipSanityTests.java | 59 ++++++++++ ...itesMembershipInformationSanityTests.java} | 72 ++++++------ .../alfresco/rest/sites/GetSitesTests.java | 104 ------------------ 4 files changed, 107 insertions(+), 150 deletions(-) rename e2e-test/java/org/alfresco/rest/{sites => people}/AddSiteMembershipRequestSanityTests.java (74%) create mode 100644 e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java rename e2e-test/java/org/alfresco/rest/{sites/GetSiteMembershipInformationSanityTests.java => people/GetSitesMembershipInformationSanityTests.java} (59%) delete mode 100644 e2e-test/java/org/alfresco/rest/sites/GetSitesTests.java diff --git a/e2e-test/java/org/alfresco/rest/sites/AddSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java similarity index 74% rename from e2e-test/java/org/alfresco/rest/sites/AddSiteMembershipRequestSanityTests.java rename to e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java index 6d9aaca6f..01c3dad8b 100644 --- a/e2e-test/java/org/alfresco/rest/sites/AddSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java @@ -1,9 +1,9 @@ -package org.alfresco.rest.sites; +package org.alfresco.rest.people; import org.alfresco.rest.RestTest; import org.alfresco.rest.body.SiteMembership; import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.requests.RestSitesApi; +import org.alfresco.rest.requests.RestPeopleApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataSite; import org.alfresco.utility.data.DataUser; @@ -15,14 +15,15 @@ import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { "rest-api", "sites", "sanity" }) +@Test(groups = { "rest-api", "people", "sanity" }) public class AddSiteMembershipRequestSanityTests extends RestTest { @Autowired - RestSitesApi siteAPI; + RestPeopleApi peopleApi; @Autowired DataUser dataUser; @@ -43,20 +44,21 @@ public class AddSiteMembershipRequestSanityTests extends RestTest siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); - siteAPI.useRestClient(restClient); + peopleApi.useRestClient(restClient); } - @TestRail(section = { "rest-api","sites" }, executionType = ExecutionType.SANITY, description = "Verify site manager is able to create new site membership request") - @Bug(id="MNT-16557") - @Test(enabled=false) + @TestRail(section = { "rest-api","people" }, + executionType = ExecutionType.SANITY, description = "Verify site manager is able to create new site membership request") + @Bug(id="MNT-16557") public void siteManagerCanCreateSiteMembershipRequest() throws JsonToModelConversionException, Exception { UserModel newMember = dataUser.createRandomTestUser(); SiteMembership siteMembership = new SiteMembership("Please accept me", siteModel.getId(), "New request"); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - siteAPI.addSiteMembershipRequest(newMember, siteMembership); - siteAPI.getSite(siteModel).assertResponseIsNotEmpty(); + peopleApi.addSiteMembershipRequest(newMember, siteMembership); + peopleApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.OK); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java new file mode 100644 index 000000000..634f38684 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java @@ -0,0 +1,59 @@ +package org.alfresco.rest.people; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.requests.RestPeopleApi; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataSite; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.exception.DataPreparationException; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +@Test(groups = { "rest-api", "people", "sanity" }) +public class GetSiteMembershipSanityTests extends RestTest +{ + @Autowired + RestPeopleApi peopleApi; + + @Autowired + DataUser dataUser; + + @Autowired + DataSite dataSite; + + private SiteModel siteModel; + private UserModel adminUser; + private ListUserWithRoles usersWithRoles; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws DataPreparationException + { + adminUser = dataUser.getAdminUser(); + siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); + + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, + UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + + peopleApi.useRestClient(restClient); + } + + @TestRail(section = { "rest-api", "people" }, + executionType = ExecutionType.SANITY, + description = "Verify site manager is able to retrieve site membership information of another user") + public void siteManagerCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + peopleApi.getSiteMembership(adminUser, siteModel); + peopleApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.OK); + } + +} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembershipInformationSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java similarity index 59% rename from e2e-test/java/org/alfresco/rest/sites/GetSiteMembershipInformationSanityTests.java rename to e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java index 6d06d5809..264beff65 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembershipInformationSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java @@ -1,8 +1,8 @@ -package org.alfresco.rest.sites; +package org.alfresco.rest.people; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.requests.RestSitesApi; +import org.alfresco.rest.requests.RestPeopleApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataSite; import org.alfresco.utility.data.DataUser; @@ -17,11 +17,11 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { "rest-api", "sites", "sanity" }) -public class GetSiteMembershipInformationSanityTests extends RestTest +@Test(groups = { "rest-api", "people", "sanity" }) +public class GetSitesMembershipInformationSanityTests extends RestTest { @Autowired - RestSitesApi siteAPI; + RestPeopleApi peopleApi; @Autowired DataUser dataUser; @@ -40,73 +40,73 @@ public class GetSiteMembershipInformationSanityTests extends RestTest siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); - siteAPI.useRestClient(restClient); + peopleApi.useRestClient(restClient); } - @TestRail(section = { "rest-api", "sites" }, + @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, - description = "Verify site manager is able to retrieve site membership information of another user") - public void siteManagerCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception + description = "Verify site manager is able to retrieve sites membership information of another user") + public void siteManagerCanRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - siteAPI.getSiteMembershipInformation(adminUser); - siteAPI.usingRestWrapper() + peopleApi.getSitesMembershipInformation(adminUser); + peopleApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "sites" }, + @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, - description = "Verify site collaborator is able to retrieve site membership information of another user") - public void siteCollaboratorCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception + description = "Verify site collaborator is able to retrieve sites membership information of another user") + public void siteCollaboratorCanRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - siteAPI.getSiteMembershipInformation(adminUser); - siteAPI.usingRestWrapper() + peopleApi.getSitesMembershipInformation(adminUser); + peopleApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "sites" }, + @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, - description = "Verify site contributor is able to retrieve site membership information of another user") - public void siteContributorCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception + description = "Verify site contributor is able to retrieve sites membership information of another user") + public void siteContributorCanRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - siteAPI.getSiteMembershipInformation(adminUser); - siteAPI.usingRestWrapper() + peopleApi.getSitesMembershipInformation(adminUser); + peopleApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "sites" }, + @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, - description = "Verify site consumer is able to retrieve site membership information of another user") - public void siteConsumerCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception + description = "Verify site consumer is able to retrieve sites membership information of another user") + public void siteConsumerCanRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - siteAPI.getSiteMembershipInformation(adminUser); - siteAPI.usingRestWrapper() + peopleApi.getSitesMembershipInformation(adminUser); + peopleApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "sites" }, + @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, - description = "Verify admin is able to retrieve site membership information of another user") - public void siteAdminCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception + description = "Verify admin is able to retrieve sites membership information of another user") + public void siteAdminCanRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUser); - siteAPI.getSiteMembershipInformation(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - siteAPI.usingRestWrapper() + peopleApi.getSitesMembershipInformation(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + peopleApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "sites" }, + @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, - description = "Verify that unauthenticated user is not able to retrieve site membership information") - public void unauthenticatedUserCannotRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception + description = "Verify that unauthenticated user is not able to retrieve sites membership information") + public void unauthenticatedUserCannotRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception { UserModel inexistentUser = new UserModel("inexistent user", "wrong password"); restClient.authenticateUser(inexistentUser); - siteAPI.getSiteMembershipInformation(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - siteAPI.usingRestWrapper() + peopleApi.getSitesMembershipInformation(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + peopleApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSitesTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSitesTests.java deleted file mode 100644 index 3f4a54291..000000000 --- a/e2e-test/java/org/alfresco/rest/sites/GetSitesTests.java +++ /dev/null @@ -1,104 +0,0 @@ -package org.alfresco.rest.sites; - -import org.alfresco.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.requests.RestSitesApi; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataSite; -import org.alfresco.utility.data.DataUser; -import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * @author iulia.cojocea - */ -@Test(groups = { "rest-api", "comments", "sanity" }) -public class GetSitesTests extends RestTest -{ - @Autowired - RestSitesApi siteAPI; - - @Autowired - DataUser dataUser; - - @Autowired - DataSite dataSite; - - private UserModel adminUserModel; - private UserModel userModel; - private ListUserWithRoles usersWithRoles; - private SiteModel siteModel; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - restClient.authenticateUser(adminUserModel); - siteAPI.useRestClient(restClient); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); - } - - @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role gets sites information and gets status code OK (200)") - public void getSitesWithManagerRole() throws JsonToModelConversionException, Exception - { - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - siteAPI.getAllSites(); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify user with Collaborator role gets sites information and gets status code OK (200)") - public void getSitesWithCollaboratorRole() throws JsonToModelConversionException, Exception - { - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - siteAPI.getAllSites(); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify user with Contributor role gets sites information and gets status code OK (200)") - public void getSitesWithContributorRole() throws JsonToModelConversionException, Exception - { - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - siteAPI.getAllSites(); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role gets sites information and gets status code OK (200)") - public void getSitesWithConsumerRole() throws JsonToModelConversionException, Exception - { - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - siteAPI.getAllSites(); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify user with Admin user gets sites information and gets status code OK (200)") - public void getSitesWithAdminUser() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel); - siteAPI.getAllSites(); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Failed authentication get sites call returns status code 401 with Manager role") - public void getSitesWithManagerRoleFailedAuth() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - userModel = dataUser.createRandomTestUser(); - userModel.setPassword("user wrong password"); - dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); - restClient.authenticateUser(userModel); - siteAPI.getAllSites(); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); - } -} From f450bc6418f690988542e62bdbb185fb0c1b64cc Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Fri, 30 Sep 2016 17:15:31 +0300 Subject: [PATCH 0143/1491] TAS-1015 REST API - valid request returns success status code 200 with Collaborator role --- .../rest/people/GetSiteMembershipSanityTests.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java index 634f38684..623d15524 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java @@ -56,4 +56,13 @@ public class GetSiteMembershipSanityTests extends RestTest .assertStatusCodeIs(HttpStatus.OK); } + @TestRail(section = { "rest-api", + "people" }, executionType = ExecutionType.SANITY, description = "Verify site collaborator is able to retrieve site membership information of another user") + public void siteCollaboratorCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + peopleApi.getSiteMembership(adminUser, siteModel); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } + } \ No newline at end of file From 1880053d421498752fe1aa686210bf81fa619847 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Fri, 30 Sep 2016 17:17:34 +0300 Subject: [PATCH 0144/1491] TAS-1016 REST API - valid request returns success status code 200 with Contributor role --- .../rest/people/GetSiteMembershipSanityTests.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java index 623d15524..529509aee 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java @@ -62,7 +62,18 @@ public class GetSiteMembershipSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); peopleApi.getSiteMembership(adminUser, siteModel); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + peopleApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { "rest-api", + "people" }, executionType = ExecutionType.SANITY, description = "Verify site contributor is able to retrieve site membership information of another user") + public void siteContributorCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + peopleApi.getSiteMembership(adminUser, siteModel); + peopleApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.OK); } } \ No newline at end of file From 748f064b2b6139994d2ecda42d6e00b3296d5643 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Fri, 30 Sep 2016 17:18:32 +0300 Subject: [PATCH 0145/1491] TAS-1017 REST API - valid request returns success status code 200 with Consumer role --- .../rest/people/GetSiteMembershipSanityTests.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java index 529509aee..e02574983 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java @@ -76,4 +76,14 @@ public class GetSiteMembershipSanityTests extends RestTest .assertStatusCodeIs(HttpStatus.OK); } + @TestRail(section = { "rest-api", + "people" }, executionType = ExecutionType.SANITY, description = "Verify site consumer is able to retrieve site membership information of another user") + public void siteConsumerCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + peopleApi.getSiteMembership(adminUser, siteModel); + peopleApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.OK); +} + } \ No newline at end of file From ea0dbe40661e472b091df5548560e0bc26b030e1 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Fri, 30 Sep 2016 17:20:03 +0300 Subject: [PATCH 0146/1491] TAS-1018 REST API - valid request returns success status code 200 with admin user --- .../rest/people/GetSiteMembershipSanityTests.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java index e02574983..a099f719e 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java @@ -84,6 +84,16 @@ public class GetSiteMembershipSanityTests extends RestTest peopleApi.getSiteMembership(adminUser, siteModel); peopleApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.OK); -} + } + + @TestRail(section = { "rest-api", + "people" }, executionType = ExecutionType.SANITY, description = "Verify admin user is able to retrieve site membership information of another user") + public void adminCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUser); + peopleApi.getSiteMembership(usersWithRoles.getOneUserWithRole(UserRole.SiteManager), siteModel); + peopleApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.OK); + } } \ No newline at end of file From a654c31d57813d2491dfc51d589ab6b17a053793 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Fri, 30 Sep 2016 17:20:39 +0300 Subject: [PATCH 0147/1491] TAS-992 getPersonActivities call test with Manager role --- .../rest/people/GetPeopleActivitiesTests.java | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesTests.java diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesTests.java new file mode 100644 index 000000000..4dc57da78 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesTests.java @@ -0,0 +1,53 @@ +package org.alfresco.rest.people; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.requests.RestPeopleApi; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * @author Cristina Axinte + * + * Tests for getActivities (/people/{personId}/activities) RestAPI call + * + */ +@Test(groups = { "rest-api", "people", "activities" }) +public class GetPeopleActivitiesTests extends RestTest +{ + @Autowired + RestPeopleApi peopleApi; + + UserModel userModel; + SiteModel siteModel; + UserModel searchedUser; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + + peopleApi.useRestClient(restClient); + } + + @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify manager user gets a person with Rest API and response is successful") + public void managerUserChecksIfPersonIsPresent() throws Exception + { + UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); + dataContent.usingUser(managerUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(managerUser); + peopleApi.getPersonActivities(managerUser); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } +} From ff40e3abe5374f110179c032edb8fb743fc4b845 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Fri, 30 Sep 2016 17:25:25 +0300 Subject: [PATCH 0148/1491] TAS-1019 REST API - failed authentication call returns status code 401 --- .../rest/people/GetSiteMembershipSanityTests.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java index a099f719e..08f8d9bff 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java @@ -96,4 +96,14 @@ public class GetSiteMembershipSanityTests extends RestTest .assertStatusCodeIs(HttpStatus.OK); } + @TestRail(section = { "rest-api", + "people" }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to retrieve site membership information of another user") + public void unauthenticatedUserCannotRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(new UserModel("random user", "random password")); + peopleApi.getSiteMembership(usersWithRoles.getOneUserWithRole(UserRole.SiteManager), siteModel); + peopleApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + } + } \ No newline at end of file From 5cd4d65a171bcd1d2bc2c0f65e98c1300ab7042b Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Fri, 30 Sep 2016 17:37:51 +0300 Subject: [PATCH 0149/1491] TAS-993 getPersonActivities call test with Collaborator role --- .../rest/people/GetPeopleActivitiesTests.java | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesTests.java index 4dc57da78..585c13a35 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesTests.java @@ -19,7 +19,7 @@ import org.testng.annotations.Test; * Tests for getActivities (/people/{personId}/activities) RestAPI call * */ -@Test(groups = { "rest-api", "people", "activities" }) +@Test(groups = { "rest-api", "people", "activities", "sanity" }) public class GetPeopleActivitiesTests extends RestTest { @Autowired @@ -39,15 +39,27 @@ public class GetPeopleActivitiesTests extends RestTest peopleApi.useRestClient(restClient); } - @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify manager user gets a person with Rest API and response is successful") - public void managerUserChecksIfPersonIsPresent() throws Exception + @TestRail(section = { "rest-api", "people", "activities" }, executionType = ExecutionType.SANITY, description = "Verify manager user gets its activities with Rest API and response is successful") + public void managerUserGetsPeopleActivitiesListSuccessful() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); dataContent.usingUser(managerUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); restClient.authenticateUser(managerUser); - peopleApi.getPersonActivities(managerUser); + peopleApi.getPersonActivities(managerUser).assertActivityListIsNotEmpty(); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { "rest-api", "people", "activities" }, executionType = ExecutionType.SANITY, description = "Verify collaborator user gets its activities with Rest API and response is successful") + public void collaboratorUserGetsPeopleActivitiesListSuccessful() throws Exception + { + UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(collaboratorUser, siteModel, UserRole.SiteCollaborator); + dataContent.usingUser(collaboratorUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(collaboratorUser); + peopleApi.getPersonActivities(collaboratorUser).assertActivityListIsNotEmpty(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } } From 345edf223967196bf4f1f582265c16c7801883f5 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Fri, 30 Sep 2016 17:45:20 +0300 Subject: [PATCH 0150/1491] TAS-994 getPersonActivities call test with Contributor role --- .../rest/people/GetPeopleActivitiesTests.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesTests.java index 585c13a35..988905877 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesTests.java @@ -62,4 +62,16 @@ public class GetPeopleActivitiesTests extends RestTest peopleApi.getPersonActivities(collaboratorUser).assertActivityListIsNotEmpty(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + @TestRail(section = { "rest-api", "people", "activities" }, executionType = ExecutionType.SANITY, description = "Verify contributor user gets its activities with Rest API and response is successful") + public void contributorUserGetsPeopleActivitiesListSuccessful() throws Exception + { + UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(contributorUser, siteModel, UserRole.SiteContributor); + dataContent.usingUser(contributorUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(contributorUser); + peopleApi.getPersonActivities(contributorUser).assertActivityListIsNotEmpty(); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } } From acd602122748289338c7db09333bc20341866432 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Fri, 30 Sep 2016 17:51:17 +0300 Subject: [PATCH 0151/1491] TAS-995 getPersonActivities call test with Consumer role --- .../rest/people/GetPeopleActivitiesTests.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesTests.java index 988905877..90c1a01f4 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesTests.java @@ -74,4 +74,15 @@ public class GetPeopleActivitiesTests extends RestTest peopleApi.getPersonActivities(contributorUser).assertActivityListIsNotEmpty(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + @TestRail(section = { "rest-api", "people", "activities" }, executionType = ExecutionType.SANITY, description = "Verify consumer user gets its activities with Rest API and response is successful") + public void consumerUserGetsPeopleActivitiesListSuccessful() throws Exception + { + UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel, UserRole.SiteConsumer); + + restClient.authenticateUser(consumerUser); + peopleApi.getPersonActivities(consumerUser).assertActivityListIsNotEmpty(); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } } From bc2db32cbe60ec86bb7af1f52dec3f3bfd3a4bdc Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Fri, 30 Sep 2016 17:59:31 +0300 Subject: [PATCH 0152/1491] TAS-996 getPersonActivities call test with admin user --- .../alfresco/rest/people/GetPeopleActivitiesTests.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesTests.java index 90c1a01f4..1c9714577 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesTests.java @@ -85,4 +85,14 @@ public class GetPeopleActivitiesTests extends RestTest peopleApi.getPersonActivities(consumerUser).assertActivityListIsNotEmpty(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + @TestRail(section = { "rest-api", "people", "activities" }, executionType = ExecutionType.SANITY, description = "Verify admin user gets another user activities with Rest API and response is successful") + public void adminUserGetsPeopleActivitiesListSuccessful() throws Exception + { + UserModel adminUser = dataUser.getAdminUser(); + + restClient.authenticateUser(adminUser); + peopleApi.getPersonActivities(userModel).assertActivityListIsNotEmpty(); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } } From 3298eb0d759380372ef7cb7fed8d1edfa5832b86 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Fri, 30 Sep 2016 18:47:10 +0300 Subject: [PATCH 0153/1491] TAS-997 fail getPersonActivities call test with Manager role --- .../rest/people/GetPeopleActivitiesTests.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesTests.java index 1c9714577..22d4e8800 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesTests.java @@ -6,6 +6,7 @@ import org.alfresco.rest.requests.RestPeopleApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.beans.factory.annotation.Autowired; @@ -95,4 +96,17 @@ public class GetPeopleActivitiesTests extends RestTest peopleApi.getPersonActivities(userModel).assertActivityListIsNotEmpty(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + @Bug(id = "") + @TestRail(section = { "rest-api", "people", "activities" }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized to gets another user activities with Rest API") + public void managerUserGetsPeopleActivitiesListIsNotAuthorized() throws Exception + { + UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); + managerUser.setPassword("newpassword"); + + restClient.authenticateUser(managerUser); + peopleApi.getPersonActivities(userModel); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + } } From 4f55965270b3a48dc85e5d24f8785defd554fd78 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Mon, 3 Oct 2016 10:40:57 +0300 Subject: [PATCH 0154/1491] TAS-1042 pom.xml updates, moved sanity to shared-resources --- e2e-test/resources/sanity-rest.xml | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100644 e2e-test/resources/sanity-rest.xml diff --git a/e2e-test/resources/sanity-rest.xml b/e2e-test/resources/sanity-rest.xml deleted file mode 100644 index 80bd6abc1..000000000 --- a/e2e-test/resources/sanity-rest.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - From fd308572444981ad0d0b1dba16ff26dc01567577 Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Mon, 3 Oct 2016 11:23:36 +0300 Subject: [PATCH 0155/1491] TAS-1007 getSiteMember with Manager role --- .../rest/sites/GetSiteMemberSanityTests.java | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java new file mode 100644 index 000000000..e7585c58e --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java @@ -0,0 +1,60 @@ +package org.alfresco.rest.sites; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.requests.RestSitesApi; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataSite; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.exception.DataPreparationException; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * @author iulia.cojocea + */ +@Test(groups = { "rest-api", "sites", "sanity" }) +public class GetSiteMemberSanityTests extends RestTest +{ + + @Autowired + RestSitesApi restSitesApi; + + @Autowired + DataUser dataUser; + + @Autowired + DataSite dataSite; + + private UserModel adminUser; + private SiteModel siteModel; + private ListUserWithRoles usersWithRoles; + private UserModel userModel; + + @BeforeClass(alwaysRun = true) + public void initSetup() throws DataPreparationException + { + adminUser = dataUser.getAdminUser(); + restSitesApi.useRestClient(restClient); + siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + userModel = dataUser.createRandomTestUser(); + dataUser.addUserToSite(userModel, siteModel, UserRole.SiteConsumer); + } + + @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, + description = "Verify user with Manager role gets site member and gets status code OK (200)") + public void getSiteMemberWithManagerRole() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + restSitesApi.getSiteMember(siteModel, userModel); + restSitesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } +} From 42962a06d8492d0d361880a58bab5ffcc939c444 Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Mon, 3 Oct 2016 11:41:53 +0300 Subject: [PATCH 0156/1491] TAS-1008 getSiteMember with collaborator role --- .../alfresco/rest/sites/GetSiteMemberSanityTests.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java index e7585c58e..bb4f217dd 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java @@ -57,4 +57,13 @@ public class GetSiteMemberSanityTests extends RestTest restSitesApi.getSiteMember(siteModel, userModel); restSitesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, + 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)); + restSitesApi.getSiteMember(siteModel, userModel); + restSitesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } } From 65cb337974258e46a31c0670db751ab17f724fec Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Mon, 3 Oct 2016 11:43:06 +0300 Subject: [PATCH 0157/1491] TAS-1009 getSiteMember with contributor role --- .../alfresco/rest/sites/GetSiteMemberSanityTests.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java index bb4f217dd..38e0a063a 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java @@ -66,4 +66,13 @@ public class GetSiteMemberSanityTests extends RestTest restSitesApi.getSiteMember(siteModel, userModel); restSitesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, + 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)); + restSitesApi.getSiteMember(siteModel, userModel); + restSitesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } } From 06ef6297fbddaca2856ebe57b746ca734ed519ab Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Mon, 3 Oct 2016 11:44:33 +0300 Subject: [PATCH 0158/1491] TAS-1010 getSiteMember with consumer role --- .../alfresco/rest/sites/GetSiteMemberSanityTests.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java index 38e0a063a..e35b8f453 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java @@ -75,4 +75,13 @@ public class GetSiteMemberSanityTests extends RestTest restSitesApi.getSiteMember(siteModel, userModel); restSitesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, + 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)); + restSitesApi.getSiteMember(siteModel, userModel); + restSitesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } } From c1015bfc0c86d9ad0b8ae692d3434530dbd297c4 Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Mon, 3 Oct 2016 11:45:59 +0300 Subject: [PATCH 0159/1491] TAS-1011 getSiteMember with admin user --- .../alfresco/rest/sites/GetSiteMemberSanityTests.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java index e35b8f453..b65912094 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java @@ -84,4 +84,13 @@ public class GetSiteMemberSanityTests extends RestTest restSitesApi.getSiteMember(siteModel, userModel); restSitesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, + description = "Verify user with admin user gets site member and gets status code OK (200)") + public void getSiteMemberWithAdminUser() throws Exception + { + restClient.authenticateUser(adminUser); + restSitesApi.getSiteMember(siteModel, userModel); + restSitesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } } From ab9c5246bc3e3b56a28be38485c13ff91c10857b Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Mon, 3 Oct 2016 11:57:52 +0300 Subject: [PATCH 0160/1491] TAS-1012 getSiteMember call returns status code 401 --- .../alfresco/rest/sites/GetSiteMemberSanityTests.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java index b65912094..22eeaeccb 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java @@ -1,6 +1,7 @@ package org.alfresco.rest.sites; import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.requests.RestSitesApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataSite; @@ -93,4 +94,14 @@ public class GetSiteMemberSanityTests extends RestTest restSitesApi.getSiteMember(siteModel, userModel); restSitesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, + description = "Failed authentication get site member call returns status code 401 with Manager role") + public void unauthenticatedUserIsNotAuthorizedToRetrieveSiteMember() throws JsonToModelConversionException, Exception + { + UserModel inexistentUser = new UserModel("inexistent user", "inexistent password"); + restClient.authenticateUser(inexistentUser); + restSitesApi.getSiteMember(siteModel, userModel); + restSitesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + } } From 73b37d332d2a32049542de9cd32992d3616c514f Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Mon, 3 Oct 2016 12:50:44 +0300 Subject: [PATCH 0161/1491] TAS-1024 getPreferences call test with Manager role --- .../people/GetPeoplePreferencesTests.java | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesTests.java diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesTests.java new file mode 100644 index 000000000..48dd3bc83 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesTests.java @@ -0,0 +1,51 @@ +package org.alfresco.rest.people; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.requests.RestPeopleApi; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Tests for Get Peferences (/people/{personId}/preferences) RestAPI call + * + * @author Cristina Axinte + * + */ +@Test(groups = { "rest-api", "people", "preferences", "sanity" }) +public class GetPeoplePreferencesTests extends RestTest +{ + @Autowired + RestPeopleApi peopleApi; + + UserModel userModel; + SiteModel siteModel; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + //mark site as favorite (cum fac asta? fol data prep-care face call la rest API sau pot sa fol durect restAPI necesar? + + peopleApi.useRestClient(restClient); + } + + @TestRail(section = { "rest-api", "people", "preferences" }, executionType = ExecutionType.SANITY, description = "Verify manager user gets its preferences with Rest API and response is successful (200)") + public void managerUserGetsPeoplePreferencesWithSuccess() throws Exception + { + UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); + dataSite.usingUser(managerUser).usingSite(siteModel).addSiteToFavorites(); + + restClient.authenticateUser(managerUser); + peopleApi.getPersonPreferences(managerUser).assertPreferencesListIsNotEmpty(); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } +} From e136e29f2bdbd9b6fab6a4ae59203f52de3475c7 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Mon, 3 Oct 2016 12:56:22 +0300 Subject: [PATCH 0162/1491] TAS-1025 getPreferences call test with Collaborator role --- .../rest/people/GetPeoplePreferencesTests.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesTests.java index 48dd3bc83..d7cc828d7 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesTests.java @@ -32,7 +32,6 @@ public class GetPeoplePreferencesTests extends RestTest { userModel = dataUser.createRandomTestUser(); siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - //mark site as favorite (cum fac asta? fol data prep-care face call la rest API sau pot sa fol durect restAPI necesar? peopleApi.useRestClient(restClient); } @@ -48,4 +47,16 @@ public class GetPeoplePreferencesTests extends RestTest peopleApi.getPersonPreferences(managerUser).assertPreferencesListIsNotEmpty(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + @TestRail(section = { "rest-api", "people", "preferences" }, executionType = ExecutionType.SANITY, description = "Verify collaborator user gets its preferences with Rest API and response is successful (200)") + public void collaboratorUserGetsPeoplePreferencesWithSuccess() throws Exception + { + UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(collaboratorUser, siteModel, UserRole.SiteCollaborator); + dataSite.usingUser(collaboratorUser).usingSite(siteModel).addSiteToFavorites(); + + restClient.authenticateUser(collaboratorUser); + peopleApi.getPersonPreferences(collaboratorUser).assertPreferencesListIsNotEmpty(); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } } From c40dc7ab537438235e1b0b297388186684a7b833 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Mon, 3 Oct 2016 14:19:33 +0300 Subject: [PATCH 0163/1491] TAS-1026 getPreferences call test with Contributor role --- .../rest/people/GetPeoplePreferencesTests.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesTests.java index d7cc828d7..0e21a8f8a 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesTests.java @@ -59,4 +59,16 @@ public class GetPeoplePreferencesTests extends RestTest peopleApi.getPersonPreferences(collaboratorUser).assertPreferencesListIsNotEmpty(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + @TestRail(section = { "rest-api", "people", "preferences" }, executionType = ExecutionType.SANITY, description = "Verify contributor user gets its preferences with Rest API and response is successful (200)") + public void contributorUserGetsPeoplePreferencesWithSuccess() throws Exception + { + UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(contributorUser, siteModel, UserRole.SiteContributor); + dataSite.usingUser(contributorUser).usingSite(siteModel).addSiteToFavorites(); + + restClient.authenticateUser(contributorUser); + peopleApi.getPersonPreferences(contributorUser).assertPreferencesListIsNotEmpty(); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } } From 653de92a53cc08e792fbe5f3420361b5e57da325 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Mon, 3 Oct 2016 14:21:58 +0300 Subject: [PATCH 0164/1491] TAS-1027 getPreferences call test with Consumer role --- .../rest/people/GetPeoplePreferencesTests.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesTests.java index 0e21a8f8a..ca0dd4715 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesTests.java @@ -71,4 +71,16 @@ public class GetPeoplePreferencesTests extends RestTest peopleApi.getPersonPreferences(contributorUser).assertPreferencesListIsNotEmpty(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + @TestRail(section = { "rest-api", "people", "preferences" }, executionType = ExecutionType.SANITY, description = "Verify consumer user gets its preferences with Rest API and response is successful (200)") + public void consumerUserGetsPeoplePreferencesWithSuccess() throws Exception + { + UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel, UserRole.SiteConsumer); + dataSite.usingUser(consumerUser).usingSite(siteModel).addSiteToFavorites(); + + restClient.authenticateUser(consumerUser); + peopleApi.getPersonPreferences(consumerUser).assertPreferencesListIsNotEmpty(); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } } From 6866733bcfb21f831ddcf52baac010e3d702f42d Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Mon, 3 Oct 2016 14:31:33 +0300 Subject: [PATCH 0165/1491] TAS-1028 getPreferences call test with admin user --- .../rest/people/GetPeoplePreferencesTests.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesTests.java index ca0dd4715..1db528e68 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesTests.java @@ -83,4 +83,17 @@ public class GetPeoplePreferencesTests extends RestTest peopleApi.getPersonPreferences(consumerUser).assertPreferencesListIsNotEmpty(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + @TestRail(section = { "rest-api", "people", "preferences" }, executionType = ExecutionType.SANITY, description = "Verify admin user gets another user preferences with Rest API and response is successful (200)") + public void adminUserGetsPeoplePreferencesWithSuccess() throws Exception + { + UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); + dataSite.usingUser(managerUser).usingSite(siteModel).addSiteToFavorites(); + UserModel adminUser = dataUser.getAdminUser(); + + restClient.authenticateUser(adminUser); + peopleApi.getPersonPreferences(managerUser).assertPreferencesListIsNotEmpty(); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } } From 11ce80a494ec4dcf7812d993ff852a1b69bf3916 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Mon, 3 Oct 2016 14:32:42 +0300 Subject: [PATCH 0166/1491] TAS-1030 addFavorites with admin user --- .../Favorites/PostFavoritesSanityTests.java | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/Favorites/PostFavoritesSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/Favorites/PostFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/Favorites/PostFavoritesSanityTests.java new file mode 100644 index 000000000..ca6dbe253 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/Favorites/PostFavoritesSanityTests.java @@ -0,0 +1,54 @@ +package org.alfresco.rest.Favorites; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.requests.RestFavoritesApi; +import org.alfresco.rest.requests.RestSitesApi; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +@Test(groups = { "rest-api", "favorites", "sanity" }) +public class PostFavoritesSanityTests extends RestTest +{ + + @Autowired + RestFavoritesApi favoritesAPI; + + @Autowired + RestSitesApi sitesApi; + + @Autowired + DataUser dataUser; + + private UserModel adminUserModel; + private SiteModel siteModel; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + restClient.authenticateUser(adminUserModel); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + favoritesAPI.useRestClient(restClient); + sitesApi.useRestClient(restClient); + siteModel.setGuid(sitesApi.getSite(siteModel).getGuid()); + } + + @TestRail(section={"rest-api", "favorites"}, executionType= ExecutionType.SANITY, + description= "Verify Admin user add site to favorites with Rest API and status code is 201") + public void adminIsAbleToAddToFavorites() throws JsonToModelConversionException, Exception + { + + favoritesAPI.addUserFavorites(adminUserModel, siteModel); + favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + } + + +} From 62416d883fa51441c510e55b5cba3ca11fedeac2 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Mon, 3 Oct 2016 14:35:00 +0300 Subject: [PATCH 0167/1491] TAS-1031 addFavorites with manager role --- .../rest/Favorites/PostFavoritesSanityTests.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/Favorites/PostFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/Favorites/PostFavoritesSanityTests.java index ca6dbe253..e6092623e 100644 --- a/e2e-test/java/org/alfresco/rest/Favorites/PostFavoritesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/Favorites/PostFavoritesSanityTests.java @@ -4,7 +4,9 @@ import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.requests.RestFavoritesApi; import org.alfresco.rest.requests.RestSitesApi; +import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; @@ -29,6 +31,7 @@ public class PostFavoritesSanityTests extends RestTest private UserModel adminUserModel; private SiteModel siteModel; + private ListUserWithRoles usersWithRoles; @BeforeClass(alwaysRun=true) public void dataPreparation() throws Exception @@ -39,6 +42,8 @@ public class PostFavoritesSanityTests extends RestTest favoritesAPI.useRestClient(restClient); sitesApi.useRestClient(restClient); siteModel.setGuid(sitesApi.getSite(siteModel).getGuid()); + + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); } @TestRail(section={"rest-api", "favorites"}, executionType= ExecutionType.SANITY, @@ -50,5 +55,12 @@ public class PostFavoritesSanityTests extends RestTest favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } - + @TestRail(section={"rest-api", "favorites"}, executionType= ExecutionType.SANITY, + description= "Verify Manager user add site to favorites with Rest API and status code is 201") + public void managerIsAbleToAddToFavorites() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + favoritesAPI.addUserFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteManager), siteModel); + favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + } } From a7a99b03f29c462928b2fdefe118f6b324fe2db8 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Mon, 3 Oct 2016 14:41:13 +0300 Subject: [PATCH 0168/1491] TAS-1032 addFavorites with Collbaorator role --- .../rest/Favorites/PostFavoritesSanityTests.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/Favorites/PostFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/Favorites/PostFavoritesSanityTests.java index e6092623e..1827c841a 100644 --- a/e2e-test/java/org/alfresco/rest/Favorites/PostFavoritesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/Favorites/PostFavoritesSanityTests.java @@ -63,4 +63,14 @@ public class PostFavoritesSanityTests extends RestTest favoritesAPI.addUserFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteManager), siteModel); favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } + + @TestRail(section={"rest-api", "favorites"}, executionType= ExecutionType.SANITY, + description= "Verify Collaborator user add site to favorites with Rest API and status code is 201") + public void collaboratorIsAbleToAddToFavorites() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + favoritesAPI.addUserFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), siteModel); + favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + } + } From abf442b3c0fc5e4d27de12ac3d8bd5926713c970 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Mon, 3 Oct 2016 14:42:11 +0300 Subject: [PATCH 0169/1491] TAS-1033 addFavorites with Contributor role --- .../alfresco/rest/Favorites/PostFavoritesSanityTests.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/Favorites/PostFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/Favorites/PostFavoritesSanityTests.java index 1827c841a..a4f8d3adb 100644 --- a/e2e-test/java/org/alfresco/rest/Favorites/PostFavoritesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/Favorites/PostFavoritesSanityTests.java @@ -73,4 +73,12 @@ public class PostFavoritesSanityTests extends RestTest favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } + @TestRail(section={"rest-api", "favorites"}, executionType= ExecutionType.SANITY, + description= "Verify Contributor user add site to favorites with Rest API and status code is 201") + public void contributorIsAbleToAddToFavorites() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + favoritesAPI.addUserFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor), siteModel); + favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + } } From 34fe1169754a4b5dbf84f7b6d5f73143cb02470f Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Mon, 3 Oct 2016 14:43:44 +0300 Subject: [PATCH 0170/1491] TAS-1034 addFavorites with Consumer role --- .../rest/Favorites/PostFavoritesSanityTests.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/Favorites/PostFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/Favorites/PostFavoritesSanityTests.java index a4f8d3adb..45475cb61 100644 --- a/e2e-test/java/org/alfresco/rest/Favorites/PostFavoritesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/Favorites/PostFavoritesSanityTests.java @@ -81,4 +81,13 @@ public class PostFavoritesSanityTests extends RestTest favoritesAPI.addUserFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor), siteModel); favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } + + @TestRail(section={"rest-api", "favorites"}, executionType= ExecutionType.SANITY, + description= "Verify Consumer user add site to favorites with Rest API and status code is 201") + public void consumerIsAbleToAddToFavorites() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + favoritesAPI.addUserFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer), siteModel); + favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + } } From 7acbc5cb4815d7fcf62454c40bd05a0dfbcc1ed6 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Mon, 3 Oct 2016 14:51:35 +0300 Subject: [PATCH 0171/1491] TAS-1035 failed authentication call returns status code 401 with Manager role --- .../Favorites/PostFavoritesSanityTests.java | 60 +++++++++++-------- 1 file changed, 36 insertions(+), 24 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/Favorites/PostFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/Favorites/PostFavoritesSanityTests.java index 45475cb61..dfd0a04a1 100644 --- a/e2e-test/java/org/alfresco/rest/Favorites/PostFavoritesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/Favorites/PostFavoritesSanityTests.java @@ -22,18 +22,18 @@ public class PostFavoritesSanityTests extends RestTest @Autowired RestFavoritesApi favoritesAPI; - + @Autowired RestSitesApi sitesApi; - + @Autowired DataUser dataUser; - - private UserModel adminUserModel; + + private UserModel adminUserModel; private SiteModel siteModel; private ListUserWithRoles usersWithRoles; - - @BeforeClass(alwaysRun=true) + + @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception { adminUserModel = dataUser.getAdminUser(); @@ -42,52 +42,64 @@ public class PostFavoritesSanityTests extends RestTest favoritesAPI.useRestClient(restClient); sitesApi.useRestClient(restClient); siteModel.setGuid(sitesApi.getSite(siteModel).getGuid()); - - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); } - - @TestRail(section={"rest-api", "favorites"}, executionType= ExecutionType.SANITY, - description= "Verify Admin user add site to favorites with Rest API and status code is 201") + + @TestRail(section = { "rest-api", + "favorites" }, executionType = ExecutionType.SANITY, description = "Verify Admin user add site to favorites with Rest API and status code is 201") public void adminIsAbleToAddToFavorites() throws JsonToModelConversionException, Exception { - + favoritesAPI.addUserFavorites(adminUserModel, siteModel); favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } - - @TestRail(section={"rest-api", "favorites"}, executionType= ExecutionType.SANITY, - description= "Verify Manager user add site to favorites with Rest API and status code is 201") + + @TestRail(section = { "rest-api", + "favorites" }, executionType = ExecutionType.SANITY, description = "Verify Manager user add site to favorites with Rest API and status code is 201") public void managerIsAbleToAddToFavorites() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); favoritesAPI.addUserFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteManager), siteModel); favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } - - @TestRail(section={"rest-api", "favorites"}, executionType= ExecutionType.SANITY, - description= "Verify Collaborator user add site to favorites with Rest API and status code is 201") + + @TestRail(section = { "rest-api", + "favorites" }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user add site to favorites with Rest API and status code is 201") public void collaboratorIsAbleToAddToFavorites() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); favoritesAPI.addUserFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), siteModel); favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } - - @TestRail(section={"rest-api", "favorites"}, executionType= ExecutionType.SANITY, - description= "Verify Contributor user add site to favorites with Rest API and status code is 201") + + @TestRail(section = { "rest-api", + "favorites" }, executionType = ExecutionType.SANITY, description = "Verify Contributor user add site to favorites with Rest API and status code is 201") public void contributorIsAbleToAddToFavorites() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); favoritesAPI.addUserFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor), siteModel); favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } - - @TestRail(section={"rest-api", "favorites"}, executionType= ExecutionType.SANITY, - description= "Verify Consumer user add site to favorites with Rest API and status code is 201") + + @TestRail(section = { "rest-api", + "favorites" }, executionType = ExecutionType.SANITY, description = "Verify Consumer user add site to favorites with Rest API and status code is 201") public void consumerIsAbleToAddToFavorites() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); favoritesAPI.addUserFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer), siteModel); favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } + + @TestRail(section = { "rest-api", + "favorites" }, executionType = ExecutionType.SANITY, description = "Verify Manager user gets status code 401 if authentication call fails") + public void managerIsNotAbleToAddCommentIfAuthenticationFails() throws JsonToModelConversionException, Exception + { + UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); + siteManager.setPassword("wrongPassword"); + restClient.authenticateUser(siteManager); + favoritesAPI.addUserFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer), siteModel); + favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + } } From 1410b8a69784488ba4ce8e08bd2b8b7060346eb6 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Mon, 3 Oct 2016 14:58:02 +0300 Subject: [PATCH 0172/1491] TAS-1029 failed getPreferences call test with Manager role --- .../rest/people/GetPeoplePreferencesTests.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesTests.java index 1db528e68..09ed913ff 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesTests.java @@ -5,6 +5,7 @@ import org.alfresco.rest.requests.RestPeopleApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.beans.factory.annotation.Autowired; @@ -96,4 +97,18 @@ public class GetPeoplePreferencesTests extends RestTest peopleApi.getPersonPreferences(managerUser).assertPreferencesListIsNotEmpty(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + @Bug(id = "") + @TestRail(section = { "rest-api", "people", "preferences" }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized to gets its preferences with Rest API when authentication fails(401)") + public void managerUserGetsPeoplePreferencesIsNotAUthorized() throws Exception + { + UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); + dataSite.usingUser(managerUser).usingSite(siteModel).addSiteToFavorites(); + managerUser.setPassword("newpassword"); + + restClient.authenticateUser(managerUser); + peopleApi.getPersonPreferences(managerUser); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + } } From a6537f0bf462afa13b8b51f91666e606a0627552 Mon Sep 17 00:00:00 2001 From: cagache Date: Mon, 3 Oct 2016 15:10:51 +0300 Subject: [PATCH 0173/1491] TAS-1051- add test "Valid request returns success status code 201 with admin user" --- .../alfresco/rest/tags/AddTagSanityTests.java | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java new file mode 100644 index 000000000..66b2fa15d --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java @@ -0,0 +1,55 @@ +package org.alfresco.rest.tags; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.requests.RestTagsApi; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Created by Claudia Agache on 10/3/2016. + */ +@Test(groups = { "rest-api", "tags", "sanity" }) +public class AddTagSanityTests extends RestTest +{ + @Autowired + private DataUser dataUser; + + @Autowired + private RestTagsApi tagsAPI; + + private UserModel adminUserModel; + private FileModel document; + private SiteModel siteModel; + private DataUser.ListUserWithRoles usersWithRoles; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + restClient.authenticateUser(adminUserModel); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + tagsAPI.useRestClient(restClient); + } + @TestRail(section = { "rest-api", + "comments" }, executionType = ExecutionType.SANITY, description = "Verify admin user adds tags with Rest API and status code is 201") + public void adminIsAbleToAddTag() throws JsonToModelConversionException, Exception + { + tagsAPI.addTag(document, "tag" + adminUserModel.getUsername()); + tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + } + + +} From 6a970a2902f42a5a6f77511ed65b013fc4fdf67f Mon Sep 17 00:00:00 2001 From: cagache Date: Mon, 3 Oct 2016 15:16:02 +0300 Subject: [PATCH 0174/1491] TAS-1052 - add test "Valid request returns success status code 201 with manager user" --- .../org/alfresco/rest/tags/AddTagSanityTests.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java index 66b2fa15d..7951f7d39 100644 --- a/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java @@ -44,12 +44,19 @@ public class AddTagSanityTests extends RestTest tagsAPI.useRestClient(restClient); } @TestRail(section = { "rest-api", - "comments" }, executionType = ExecutionType.SANITY, description = "Verify admin user adds tags with Rest API and status code is 201") + "tags" }, executionType = ExecutionType.SANITY, description = "Verify admin user adds tags with Rest API and status code is 201") public void adminIsAbleToAddTag() throws JsonToModelConversionException, Exception { tagsAPI.addTag(document, "tag" + adminUserModel.getUsername()); tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } - + @TestRail(section = { "rest-api", + "tags" }, executionType = ExecutionType.SANITY, description = "Verify Manager user adds tags with Rest API and status code is 201") + public void managerIsAbleToAddTag() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + tagsAPI.addTag(document, "tag" + UserRole.SiteManager); + tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + } } From d0f209bb3c3c055d8bd6b48d636974a5279b048f Mon Sep 17 00:00:00 2001 From: cagache Date: Mon, 3 Oct 2016 15:17:32 +0300 Subject: [PATCH 0175/1491] TAS-1053 - add test "Valid request returns success status code 201 with collaborator user" --- .../java/org/alfresco/rest/tags/AddTagSanityTests.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java index 7951f7d39..d0fb2ee6b 100644 --- a/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java @@ -59,4 +59,13 @@ public class AddTagSanityTests extends RestTest tagsAPI.addTag(document, "tag" + UserRole.SiteManager); tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } + + @TestRail(section = { "rest-api", + "tags" }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user adds tags with Rest API and status code is 201") + public void collaboratorIsAbleToAddTag() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + tagsAPI.addTag(document, "tag" + UserRole.SiteCollaborator); + tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + } } From 7e62b061eb7cc61befc00b448ec692bcb52c60eb Mon Sep 17 00:00:00 2001 From: cagache Date: Mon, 3 Oct 2016 15:20:01 +0300 Subject: [PATCH 0176/1491] TAS-1054 - add test "request returns status code 403 with contributor user" --- .../java/org/alfresco/rest/tags/AddTagSanityTests.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java index d0fb2ee6b..04509a5f9 100644 --- a/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java @@ -68,4 +68,13 @@ public class AddTagSanityTests extends RestTest tagsAPI.addTag(document, "tag" + UserRole.SiteCollaborator); tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } + + @TestRail(section = { "rest-api", + "tags" }, executionType = ExecutionType.SANITY, description = "Verify Contributor user doesn't have permission to add tags with Rest API and status code is 403") + public void contributorIsNotAbleToAddTag() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + tagsAPI.addTag(document, "tag" + UserRole.SiteContributor); + tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + } } From 5dbeddc3fae1e34361ffed90a46cd9f7fc7410f2 Mon Sep 17 00:00:00 2001 From: cagache Date: Mon, 3 Oct 2016 15:21:21 +0300 Subject: [PATCH 0177/1491] TAS-1055 - add test "request returns status code 403 with consumer user" --- .../java/org/alfresco/rest/tags/AddTagSanityTests.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java index 04509a5f9..ec169a79d 100644 --- a/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java @@ -77,4 +77,13 @@ public class AddTagSanityTests extends RestTest tagsAPI.addTag(document, "tag" + UserRole.SiteContributor); tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } + + @TestRail(section = { "rest-api", + "tags" }, executionType = ExecutionType.SANITY, description = "Verify Consumer user doesn't have permission to add tags with Rest API and status code is 403") + public void consumerIsNotAbleToAddTag() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + tagsAPI.addTag(document, "tag" + UserRole.SiteConsumer); + tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + } } From 35e6563b191379328265744de4fc06cb07be25aa Mon Sep 17 00:00:00 2001 From: cagache Date: Mon, 3 Oct 2016 15:23:10 +0300 Subject: [PATCH 0178/1491] TAS-1056 - add test "failed authentication call returns status code 401 with Manager role" --- .../org/alfresco/rest/tags/AddTagSanityTests.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java index ec169a79d..4da8f740a 100644 --- a/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java @@ -86,4 +86,15 @@ public class AddTagSanityTests extends RestTest tagsAPI.addTag(document, "tag" + UserRole.SiteConsumer); tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } + + @TestRail(section = { "rest-api", + "tags" }, executionType = ExecutionType.SANITY, description = "Verify Manager user gets status code 401 if authentication call fails") + public void managerIsNotAbleToAddTagIfAuthenticationFails() throws JsonToModelConversionException, Exception + { + UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); + siteManager.setPassword("wrongPassword"); + restClient.authenticateUser(siteManager); + tagsAPI.addTag(document, "tagUnauthorized"); + tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + } } From a649e39e7beb79ad8992d7c16ef9b157e2d642df Mon Sep 17 00:00:00 2001 From: cnechifor Date: Mon, 3 Oct 2016 17:28:17 +0300 Subject: [PATCH 0179/1491] sample commit --- .../org/alfresco/rest/sites/GetSiteContainerSanityTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java index 1286ab2e4..50a735b1d 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java @@ -55,7 +55,7 @@ public class GetSiteContainerSanityTests extends RestTest public void getSiteContainerWithManagerRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - listOfFoldersIds = siteAPI.getSiteContainers(siteModel).getSiteContainersList(); + listOfFoldersIds = siteAPI.getSiteContainers(siteModel).getEntries(); siteAPI.getSiteContainer(siteModel, listOfFoldersIds.get(0)); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } From 4358ae390dbde9ceb32416c187c642f742411eff Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Mon, 3 Oct 2016 18:09:34 +0300 Subject: [PATCH 0180/1491] TAS-1071 REST API - add like valid request returns success status code 201 with Manager role --- .../rest/ratings/AddRateSanityTests.java | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/ratings/AddRateSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/ratings/AddRateSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/AddRateSanityTests.java new file mode 100644 index 000000000..6dd61e1bb --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/ratings/AddRateSanityTests.java @@ -0,0 +1,61 @@ +package org.alfresco.rest.ratings; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.body.LikeRatingBody; +import org.alfresco.rest.body.LikeRatingBody.ratingTypes; +import org.alfresco.rest.requests.RestRatingsApi; +import org.alfresco.utility.exception.DataPreparationException; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.apache.commons.lang3.RandomStringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +@Test(groups = { "rest-api", "ratings", "sanity" }) +public class AddRateSanityTests extends RestTest +{ + @Autowired + RestRatingsApi ratingsApi; + + private UserModel userModel; + private SiteModel siteModel; + private UserModel adminUser; + private FolderModel folderModel; + private FileModel document; + private LikeRatingBody rating; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws DataPreparationException + { + userModel = dataUser.createUser(RandomStringUtils.randomAlphanumeric(20)); + adminUser = dataUser.getAdminUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + + restClient.authenticateUser(adminUser); + ratingsApi.useRestClient(restClient); + } + + @BeforeMethod + public void setUp() throws Exception { + folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + } + + @TestRail(section = {"rest-api", "ratings" }, executionType = ExecutionType.SANITY, + description = "Verify user with Manager role is able to post like rating to a document") + public void managerIsAbleToLikeDocument() throws Exception + { + rating = new LikeRatingBody(ratingTypes.likes.toString(), true); + ratingsApi.addRate(document, rating); + ratingsApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.CREATED); + } +} \ No newline at end of file From 23e4967c40971904d27e9bacefe515d808dcaf29 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Mon, 3 Oct 2016 18:16:11 +0300 Subject: [PATCH 0181/1491] TAS-1072 REST API - add like valid request returns success status code 201 with Collaborator role --- .../rest/ratings/AddRateSanityTests.java | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/ratings/AddRateSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/AddRateSanityTests.java index 6dd61e1bb..582a8d105 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/AddRateSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/AddRateSanityTests.java @@ -5,6 +5,8 @@ import org.alfresco.rest.RestTest; import org.alfresco.rest.body.LikeRatingBody; import org.alfresco.rest.body.LikeRatingBody.ratingTypes; import org.alfresco.rest.requests.RestRatingsApi; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FolderModel; @@ -31,6 +33,7 @@ public class AddRateSanityTests extends RestTest private FolderModel folderModel; private FileModel document; private LikeRatingBody rating; + private ListUserWithRoles usersWithRoles; @BeforeClass(alwaysRun=true) public void dataPreparation() throws DataPreparationException @@ -38,9 +41,9 @@ public class AddRateSanityTests extends RestTest userModel = dataUser.createUser(RandomStringUtils.randomAlphanumeric(20)); adminUser = dataUser.getAdminUser(); siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - - restClient.authenticateUser(adminUser); ratingsApi.useRestClient(restClient); + + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); } @BeforeMethod @@ -54,6 +57,20 @@ public class AddRateSanityTests extends RestTest public void managerIsAbleToLikeDocument() throws Exception { rating = new LikeRatingBody(ratingTypes.likes.toString(), true); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + ratingsApi.addRate(document, rating); + ratingsApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.CREATED); + } + + @TestRail(section = {"rest-api", "ratings" }, executionType = ExecutionType.SANITY, + description = "Verify user with Collaborator role is able to post like rating to a document") + public void collaboratorIsAbleToLikeDocument() throws Exception + { + rating = new LikeRatingBody(ratingTypes.likes.toString(), true); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); ratingsApi.addRate(document, rating); ratingsApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.CREATED); From b588c84e863af068301d2b9cc4e142cdf8bf8d63 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Mon, 3 Oct 2016 18:17:13 +0300 Subject: [PATCH 0182/1491] TAS-1073 REST API - add like valid request returns success status code 201 with Contributor role --- .../alfresco/rest/ratings/AddRateSanityTests.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/ratings/AddRateSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/AddRateSanityTests.java index 582a8d105..e4091e317 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/AddRateSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/AddRateSanityTests.java @@ -75,4 +75,16 @@ public class AddRateSanityTests extends RestTest ratingsApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.CREATED); } + + @TestRail(section = {"rest-api", "ratings" }, executionType = ExecutionType.SANITY, + description = "Verify user with Contributor role is able to post like rating to a document") + public void contributorIsAbleToLikeDocument() throws Exception + { + rating = new LikeRatingBody(ratingTypes.likes.toString(), true); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + ratingsApi.addRate(document, rating); + ratingsApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.CREATED); + } } \ No newline at end of file From ffb374cc2ebd61819bf6e983c07658deaaf4f6ba Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Mon, 3 Oct 2016 18:18:21 +0300 Subject: [PATCH 0183/1491] TAS-1074 REST API - add like valid request returns success status code 201 with Consumer role --- .../alfresco/rest/ratings/AddRateSanityTests.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/ratings/AddRateSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/AddRateSanityTests.java index e4091e317..a7455b0fd 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/AddRateSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/AddRateSanityTests.java @@ -87,4 +87,16 @@ public class AddRateSanityTests extends RestTest ratingsApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.CREATED); } + + @TestRail(section = {"rest-api", "ratings" }, executionType = ExecutionType.SANITY, + description = "Verify user with Consumer role is able to post like rating to a document") + public void consumerIsAbleToLikeDocument() throws Exception + { + rating = new LikeRatingBody(ratingTypes.likes.toString(), true); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + ratingsApi.addRate(document, rating); + ratingsApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.CREATED); + } } \ No newline at end of file From f0ace093074922506c5165a990c320308c1c645b Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Mon, 3 Oct 2016 18:23:44 +0300 Subject: [PATCH 0184/1491] TAS-1075 REST API - add like valid request returns success status code 201 with admin user --- .../alfresco/rest/ratings/AddRateSanityTests.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/ratings/AddRateSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/AddRateSanityTests.java index a7455b0fd..c73e7f97f 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/AddRateSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/AddRateSanityTests.java @@ -99,4 +99,16 @@ public class AddRateSanityTests extends RestTest ratingsApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.CREATED); } + + @TestRail(section = {"rest-api", "ratings" }, executionType = ExecutionType.SANITY, + description = "Verify admin user is able to post like rating to a document") + public void adminIsAbleToLikeDocument() throws Exception + { + rating = new LikeRatingBody(ratingTypes.likes.toString(), true); + + restClient.authenticateUser(adminUser); + ratingsApi.addRate(document, rating); + ratingsApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.CREATED); + } } \ No newline at end of file From 5628df71187edb450c47685be20e721b42285a28 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Mon, 3 Oct 2016 18:28:12 +0300 Subject: [PATCH 0185/1491] TAS-1076 REST API - failed authentication call returns status code 401 --- .../alfresco/rest/ratings/AddRateSanityTests.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/ratings/AddRateSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/AddRateSanityTests.java index c73e7f97f..fe92a7690 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/AddRateSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/AddRateSanityTests.java @@ -111,4 +111,16 @@ public class AddRateSanityTests extends RestTest ratingsApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.CREATED); } + + @TestRail(section = {"rest-api", "ratings" }, executionType = ExecutionType.SANITY, + description = "Verify unauthenticated user is not able to post like rating to a document") + public void unauthenticatedUserIsNotAbleToLikeDocument() throws Exception + { + rating = new LikeRatingBody(ratingTypes.likes.toString(), true); + + restClient.authenticateUser(new UserModel("random user", "random password")); + ratingsApi.addRate(document, rating); + ratingsApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + } } \ No newline at end of file From f2c6a6da6957ee59c02dd4356212345532540910 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Mon, 3 Oct 2016 18:45:17 +0300 Subject: [PATCH 0186/1491] TAS-1083 REST API - add stars valid request returns success status code 201 with Manager role --- .../rest/ratings/AddRateSanityTests.java | 40 +++++++++++++------ 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/ratings/AddRateSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/AddRateSanityTests.java index fe92a7690..fdbf34325 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/AddRateSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/AddRateSanityTests.java @@ -2,6 +2,7 @@ package org.alfresco.rest.ratings; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; +import org.alfresco.rest.body.FiveStarRatingBody; import org.alfresco.rest.body.LikeRatingBody; import org.alfresco.rest.body.LikeRatingBody.ratingTypes; import org.alfresco.rest.requests.RestRatingsApi; @@ -32,7 +33,8 @@ public class AddRateSanityTests extends RestTest private UserModel adminUser; private FolderModel folderModel; private FileModel document; - private LikeRatingBody rating; + private LikeRatingBody likeRating; + private FiveStarRatingBody fiveStarRating; private ListUserWithRoles usersWithRoles; @BeforeClass(alwaysRun=true) @@ -56,10 +58,10 @@ public class AddRateSanityTests extends RestTest description = "Verify user with Manager role is able to post like rating to a document") public void managerIsAbleToLikeDocument() throws Exception { - rating = new LikeRatingBody(ratingTypes.likes.toString(), true); + likeRating = new LikeRatingBody(ratingTypes.fiveStar.toString(), true); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - ratingsApi.addRate(document, rating); + ratingsApi.likeDocument(document, likeRating); ratingsApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.CREATED); } @@ -68,10 +70,10 @@ public class AddRateSanityTests extends RestTest description = "Verify user with Collaborator role is able to post like rating to a document") public void collaboratorIsAbleToLikeDocument() throws Exception { - rating = new LikeRatingBody(ratingTypes.likes.toString(), true); + likeRating = new LikeRatingBody(ratingTypes.likes.toString(), true); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - ratingsApi.addRate(document, rating); + ratingsApi.likeDocument(document, likeRating); ratingsApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.CREATED); } @@ -80,10 +82,10 @@ public class AddRateSanityTests extends RestTest description = "Verify user with Contributor role is able to post like rating to a document") public void contributorIsAbleToLikeDocument() throws Exception { - rating = new LikeRatingBody(ratingTypes.likes.toString(), true); + likeRating = new LikeRatingBody(ratingTypes.likes.toString(), true); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - ratingsApi.addRate(document, rating); + ratingsApi.likeDocument(document, likeRating); ratingsApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.CREATED); } @@ -92,10 +94,10 @@ public class AddRateSanityTests extends RestTest description = "Verify user with Consumer role is able to post like rating to a document") public void consumerIsAbleToLikeDocument() throws Exception { - rating = new LikeRatingBody(ratingTypes.likes.toString(), true); + likeRating = new LikeRatingBody(ratingTypes.likes.toString(), true); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - ratingsApi.addRate(document, rating); + ratingsApi.likeDocument(document, likeRating); ratingsApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.CREATED); } @@ -104,10 +106,10 @@ public class AddRateSanityTests extends RestTest description = "Verify admin user is able to post like rating to a document") public void adminIsAbleToLikeDocument() throws Exception { - rating = new LikeRatingBody(ratingTypes.likes.toString(), true); + likeRating = new LikeRatingBody(ratingTypes.likes.toString(), true); restClient.authenticateUser(adminUser); - ratingsApi.addRate(document, rating); + ratingsApi.likeDocument(document, likeRating); ratingsApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.CREATED); } @@ -116,11 +118,23 @@ public class AddRateSanityTests extends RestTest description = "Verify unauthenticated user is not able to post like rating to a document") public void unauthenticatedUserIsNotAbleToLikeDocument() throws Exception { - rating = new LikeRatingBody(ratingTypes.likes.toString(), true); + likeRating = new LikeRatingBody(ratingTypes.likes.toString(), true); restClient.authenticateUser(new UserModel("random user", "random password")); - ratingsApi.addRate(document, rating); + ratingsApi.likeDocument(document, likeRating); ratingsApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } + + @TestRail(section = {"rest-api", "ratings" }, executionType = ExecutionType.SANITY, + description = "Verify user with Manager role is able to post stars rating to a document") + public void managerIsAbleToAddStarsToDocument() throws Exception + { + fiveStarRating = new FiveStarRatingBody(ratingTypes.fiveStar.toString(), 5); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + ratingsApi.rateStarsToDocument(document, fiveStarRating); + ratingsApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.CREATED); + } } \ No newline at end of file From 193e8d622fd06428f080638e9e423ac371402fc5 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Mon, 3 Oct 2016 18:46:21 +0300 Subject: [PATCH 0187/1491] TAS-1084 REST API - add stars valid request returns success status code 201 with Collaborator role --- .../alfresco/rest/ratings/AddRateSanityTests.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/ratings/AddRateSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/AddRateSanityTests.java index fdbf34325..16c8d108b 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/AddRateSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/AddRateSanityTests.java @@ -137,4 +137,16 @@ public class AddRateSanityTests extends RestTest ratingsApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.CREATED); } + + @TestRail(section = {"rest-api", "ratings" }, executionType = ExecutionType.SANITY, + description = "Verify user with Collaborator role is able to post stars rating to a document") + public void collaboratorIsAbleToAddStarsToDocument() throws Exception + { + fiveStarRating = new FiveStarRatingBody(ratingTypes.fiveStar.toString(), 5); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + ratingsApi.rateStarsToDocument(document, fiveStarRating); + ratingsApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.CREATED); + } } \ No newline at end of file From 0884142a03d8208e9cbefb0177600e43452c55f6 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Mon, 3 Oct 2016 18:47:11 +0300 Subject: [PATCH 0188/1491] TAS-1085 REST API - add stars valid request returns success status code 201 with Contributor role --- .../alfresco/rest/ratings/AddRateSanityTests.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/ratings/AddRateSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/AddRateSanityTests.java index 16c8d108b..5dc4b92c8 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/AddRateSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/AddRateSanityTests.java @@ -149,4 +149,16 @@ public class AddRateSanityTests extends RestTest ratingsApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.CREATED); } + + @TestRail(section = {"rest-api", "ratings" }, executionType = ExecutionType.SANITY, + description = "Verify user with Contributor role is able to post stars rating to a document") + public void contributorIsAbleToAddStarsToDocument() throws Exception + { + fiveStarRating = new FiveStarRatingBody(ratingTypes.fiveStar.toString(), 5); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + ratingsApi.rateStarsToDocument(document, fiveStarRating); + ratingsApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.CREATED); + } } \ No newline at end of file From d5568cca3fba61a41ac931782ff3c4d8225fedb6 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Mon, 3 Oct 2016 18:47:59 +0300 Subject: [PATCH 0189/1491] TAS-1086 REST API - add stars valid request returns success status code 201 with Consumer role --- .../alfresco/rest/ratings/AddRateSanityTests.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/ratings/AddRateSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/AddRateSanityTests.java index 5dc4b92c8..1aca0712b 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/AddRateSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/AddRateSanityTests.java @@ -161,4 +161,16 @@ public class AddRateSanityTests extends RestTest ratingsApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.CREATED); } + + @TestRail(section = {"rest-api", "ratings" }, executionType = ExecutionType.SANITY, + description = "Verify user with Consumer role is able to post stars rating to a document") + public void consumerIsAbleToAddStarsToDocument() throws Exception + { + fiveStarRating = new FiveStarRatingBody(ratingTypes.fiveStar.toString(), 5); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + ratingsApi.rateStarsToDocument(document, fiveStarRating); + ratingsApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.CREATED); + } } \ No newline at end of file From f7eebe1a161897b2521820f5a42afa24fe6c4c66 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Mon, 3 Oct 2016 18:49:01 +0300 Subject: [PATCH 0190/1491] TAS-1087 REST API - add stars valid request returns success status code 201 with admin user --- .../alfresco/rest/ratings/AddRateSanityTests.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/ratings/AddRateSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/AddRateSanityTests.java index 1aca0712b..4ce978807 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/AddRateSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/AddRateSanityTests.java @@ -173,4 +173,16 @@ public class AddRateSanityTests extends RestTest ratingsApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.CREATED); } + + @TestRail(section = {"rest-api", "ratings" }, executionType = ExecutionType.SANITY, + description = "Verify admin user is able to post stars rating to a document") + public void adminIsAbleToAddStarsToDocument() throws Exception + { + fiveStarRating = new FiveStarRatingBody(ratingTypes.fiveStar.toString(), 5); + + restClient.authenticateUser(adminUser); + ratingsApi.rateStarsToDocument(document, fiveStarRating); + ratingsApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.CREATED); + } } \ No newline at end of file From 5c218c63591c7c388aa51ad0fb7c7f6d965b32c9 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Mon, 3 Oct 2016 18:51:23 +0300 Subject: [PATCH 0191/1491] TAS-1088 REST API - failed authentication call on post stars returns status code 401 --- .../alfresco/rest/ratings/AddRateSanityTests.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/ratings/AddRateSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/AddRateSanityTests.java index 4ce978807..e76113ee9 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/AddRateSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/AddRateSanityTests.java @@ -185,4 +185,16 @@ public class AddRateSanityTests extends RestTest ratingsApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.CREATED); } + + @TestRail(section = {"rest-api", "ratings" }, executionType = ExecutionType.SANITY, + description = "Verify unauthenticated user is not able to post stars rating to a document") + public void unauthenticatedUserIsNotAbleToRateStarsToDocument() throws Exception + { + fiveStarRating = new FiveStarRatingBody(ratingTypes.fiveStar.toString(), 5); + + restClient.authenticateUser(new UserModel("random user", "random password")); + ratingsApi.rateStarsToDocument(document, fiveStarRating); + ratingsApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + } } \ No newline at end of file From 3fa68d7109b17a684f82101dd0e1dd7e3881160c Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Mon, 3 Oct 2016 18:55:46 +0300 Subject: [PATCH 0192/1491] TAS-1078 getFavoriteSites call test with Manager role --- .../rest/people/GatFavoriteSitesTests.java | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/people/GatFavoriteSitesTests.java diff --git a/e2e-test/java/org/alfresco/rest/people/GatFavoriteSitesTests.java b/e2e-test/java/org/alfresco/rest/people/GatFavoriteSitesTests.java new file mode 100644 index 000000000..a3ecc93e4 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/people/GatFavoriteSitesTests.java @@ -0,0 +1,45 @@ +package org.alfresco.rest.people; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.requests.RestPeopleApi; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +@Test(groups = { "rest-api", "people", "sanity" }) +public class GatFavoriteSitesTests extends RestTest +{ + @Autowired + RestPeopleApi peopleApi; + + UserModel userModel; + SiteModel siteModel; + UserModel searchedUser; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + + peopleApi.useRestClient(restClient); + } + + @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify manager user gets its favorite sites with Rest API and response is successful (200)") + public void managerUserGetsFavoriteSitesWithSuccess() throws Exception + { + UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); + dataSite.usingUser(managerUser).usingSite(siteModel).addSiteToFavorites(); + + restClient.authenticateUser(managerUser); + peopleApi.getFavoriteSites(managerUser).assertResponseIsNotEmpty(); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } +} From 6ea3e6bfd18f3af4a12f9ff71aca5639e4b29e3b Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Mon, 3 Oct 2016 19:00:47 +0300 Subject: [PATCH 0193/1491] TAS-1079 getFavoriteSites call test with Collaborator role --- .../alfresco/rest/people/GatFavoriteSitesTests.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/people/GatFavoriteSitesTests.java b/e2e-test/java/org/alfresco/rest/people/GatFavoriteSitesTests.java index a3ecc93e4..ac17f6c88 100644 --- a/e2e-test/java/org/alfresco/rest/people/GatFavoriteSitesTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GatFavoriteSitesTests.java @@ -42,4 +42,16 @@ public class GatFavoriteSitesTests extends RestTest peopleApi.getFavoriteSites(managerUser).assertResponseIsNotEmpty(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify collaborator user gets its favorite sites with Rest API and response is successful (200)") + public void collaboratorUserGetsFavoriteSitesWithSuccess() throws Exception + { + UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(collaboratorUser, siteModel, UserRole.SiteCollaborator); + dataSite.usingUser(collaboratorUser).usingSite(siteModel).addSiteToFavorites(); + + restClient.authenticateUser(collaboratorUser); + peopleApi.getFavoriteSites(collaboratorUser).assertResponseIsNotEmpty(); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } } From a30eef120fa815ffb769dc414c2a58f6903d9e8f Mon Sep 17 00:00:00 2001 From: cnechifor Date: Mon, 3 Oct 2016 19:29:05 +0300 Subject: [PATCH 0194/1491] Added some changes to TAS-374 --- .../sites/GetSiteContainerSanityTests.java | 48 ++++++++----------- 1 file changed, 20 insertions(+), 28 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java index 50a735b1d..1d05da61f 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java @@ -1,7 +1,5 @@ package org.alfresco.rest.sites; -import java.util.List; - import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestSiteContainerModel; @@ -28,20 +26,14 @@ public class GetSiteContainerSanityTests extends RestTest @Autowired RestSitesApi siteAPI; - @Autowired - DataUser dataUser; - - @Autowired - DataSite dataSite; - private UserModel adminUserModel; private SiteModel siteModel; private ListUserWithRoles usersWithRoles; - private List listOfFoldersIds; + private RestSiteContainerModel siteContainerModel; private UserModel userModel; @BeforeClass(alwaysRun=true) - public void initTest() throws Exception + public void dataPreparation() throws Exception { adminUserModel = dataUser.getAdminUser(); siteAPI.useRestClient(restClient); @@ -52,65 +44,65 @@ public class GetSiteContainerSanityTests extends RestTest @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role gets site container and gets status code OK (200)") - public void getSiteContainerWithManagerRole() throws JsonToModelConversionException, Exception + public void getSiteContainerWithManagerRole() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - listOfFoldersIds = siteAPI.getSiteContainers(siteModel).getEntries(); - siteAPI.getSiteContainer(siteModel, listOfFoldersIds.get(0)); + siteContainerModel = siteAPI.getSiteContainers(siteModel).getOneEntry(); + siteAPI.getSiteContainer(siteModel, siteContainerModel); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify user with Collaborator role gets site container and gets status code OK (200)") - public void getSiteContainerWithCollaboratorRole() throws JsonToModelConversionException, Exception + public void getSiteContainerWithCollaboratorRole() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - listOfFoldersIds = siteAPI.getSiteContainers(siteModel).getSiteContainersList(); - siteAPI.getSiteContainer(siteModel, listOfFoldersIds.get(0)); + siteContainerModel = siteAPI.getSiteContainers(siteModel).getOneEntry(); + siteAPI.getSiteContainer(siteModel, siteContainerModel); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify user with Contributor role gets site container and gets status code OK (200)") - public void getSiteContainerWithContributorRole() throws JsonToModelConversionException, Exception + public void getSiteContainerWithContributorRole() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - listOfFoldersIds = siteAPI.getSiteContainers(siteModel).getSiteContainersList(); - siteAPI.getSiteContainer(siteModel, listOfFoldersIds.get(0)); + siteContainerModel = siteAPI.getSiteContainers(siteModel).getOneEntry(); + siteAPI.getSiteContainer(siteModel, siteContainerModel); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role gets site container and gets status code OK (200)") - public void getSiteContainerWithConsumerRole() throws JsonToModelConversionException, Exception + public void getSiteContainerWithConsumerRole() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - listOfFoldersIds = siteAPI.getSiteContainers(siteModel).getSiteContainersList(); - siteAPI.getSiteContainer(siteModel, listOfFoldersIds.get(0)); + siteContainerModel = siteAPI.getSiteContainers(siteModel).getOneEntry(); + siteAPI.getSiteContainer(siteModel, siteContainerModel); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify user with admin user gets site container and gets status code OK (200)") - public void getSiteContainerWithAdminUser() throws JsonToModelConversionException, Exception + public void getSiteContainerWithAdminUser() throws Exception { restClient.authenticateUser(adminUserModel); - listOfFoldersIds = siteAPI.getSiteContainers(siteModel).getSiteContainersList(); - siteAPI.getSiteContainer(siteModel, listOfFoldersIds.get(0)); + siteContainerModel = siteAPI.getSiteContainers(siteModel).getOneEntry(); + siteAPI.getSiteContainer(siteModel, siteContainerModel); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Failed authentication get site container call returns status code 401 with Manager role") - public void unauthenticatedUserIsNotAuthorizedToRetrieveSiteContainer() throws JsonToModelConversionException, Exception + public void unauthenticatedUserIsNotAuthorizedToRetrieveSiteContainer() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); userModel = dataUser.createRandomTestUser(); userModel.setPassword("user wrong password"); dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); restClient.authenticateUser(userModel); - listOfFoldersIds = siteAPI.getSiteContainers(siteModel).getSiteContainersList(); - siteAPI.getSiteContainer(siteModel, listOfFoldersIds.get(0)); + siteContainerModel = siteAPI.getSiteContainers(siteModel).getOneEntry(); + siteAPI.getSiteContainer(siteModel, siteContainerModel); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } From ce628d7de63c527d7a1f5e732dbbd919884f0429 Mon Sep 17 00:00:00 2001 From: cnechifor Date: Tue, 4 Oct 2016 00:41:12 +0300 Subject: [PATCH 0195/1491] small changes after TAS-729 --- .../AddSiteMembershipRequestSanityTests.java | 2 +- ...GetSitesMembershipInformationSanityTests.java | 16 +++++----------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java index 01c3dad8b..88566bb90 100644 --- a/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java @@ -58,7 +58,7 @@ public class AddSiteMembershipRequestSanityTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); peopleApi.addSiteMembershipRequest(newMember, siteMembership); peopleApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.OK); + .assertStatusCodeIs(HttpStatus.CREATED); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java index 264beff65..646c2952f 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java @@ -23,12 +23,6 @@ public class GetSitesMembershipInformationSanityTests extends RestTest @Autowired RestPeopleApi peopleApi; - @Autowired - DataUser dataUser; - - @Autowired - DataSite dataSite; - private SiteModel siteModel; private UserModel adminUser; private ListUserWithRoles usersWithRoles; @@ -46,7 +40,7 @@ public class GetSitesMembershipInformationSanityTests extends RestTest @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify site manager is able to retrieve sites membership information of another user") - public void siteManagerCanRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception + public void siteManagerIsAbleToRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); peopleApi.getSitesMembershipInformation(adminUser); @@ -57,7 +51,7 @@ public class GetSitesMembershipInformationSanityTests extends RestTest @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify site collaborator is able to retrieve sites membership information of another user") - public void siteCollaboratorCanRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception + public void siteCollaboratorIsAbleToRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); peopleApi.getSitesMembershipInformation(adminUser); @@ -68,7 +62,7 @@ public class GetSitesMembershipInformationSanityTests extends RestTest @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify site contributor is able to retrieve sites membership information of another user") - public void siteContributorCanRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception + public void siteContributorIsAbleToRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); peopleApi.getSitesMembershipInformation(adminUser); @@ -79,7 +73,7 @@ public class GetSitesMembershipInformationSanityTests extends RestTest @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify site consumer is able to retrieve sites membership information of another user") - public void siteConsumerCanRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception + public void siteConsumerIsAbleToRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); peopleApi.getSitesMembershipInformation(adminUser); @@ -90,7 +84,7 @@ public class GetSitesMembershipInformationSanityTests extends RestTest @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify admin is able to retrieve sites membership information of another user") - public void siteAdminCanRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception + public void siteAdminIsAbleToRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUser); peopleApi.getSitesMembershipInformation(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); From 373ffe9699afa0bb2edef86ea5168888b7d7746d Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Tue, 4 Oct 2016 08:47:30 +0300 Subject: [PATCH 0196/1491] TAS-1080 getFavoriteSites call test with Contributor role --- .../alfresco/rest/people/GatFavoriteSitesTests.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/people/GatFavoriteSitesTests.java b/e2e-test/java/org/alfresco/rest/people/GatFavoriteSitesTests.java index ac17f6c88..bfba9637b 100644 --- a/e2e-test/java/org/alfresco/rest/people/GatFavoriteSitesTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GatFavoriteSitesTests.java @@ -54,4 +54,16 @@ public class GatFavoriteSitesTests extends RestTest peopleApi.getFavoriteSites(collaboratorUser).assertResponseIsNotEmpty(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify contributor user gets its favorite sites with Rest API and response is successful (200)") + public void contributorUserGetsFavoriteSitesWithSuccess() throws Exception + { + UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(contributorUser, siteModel, UserRole.SiteContributor); + dataSite.usingUser(contributorUser).usingSite(siteModel).addSiteToFavorites(); + + restClient.authenticateUser(contributorUser); + peopleApi.getFavoriteSites(contributorUser).assertResponseIsNotEmpty(); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } } From 3fbd6aec2d0f66936ded68acc188a8b308c2141a Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Tue, 4 Oct 2016 08:49:15 +0300 Subject: [PATCH 0197/1491] TAS-1081 getFavoriteSites call test with Consumer role --- .../alfresco/rest/people/GatFavoriteSitesTests.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/people/GatFavoriteSitesTests.java b/e2e-test/java/org/alfresco/rest/people/GatFavoriteSitesTests.java index bfba9637b..5755b4363 100644 --- a/e2e-test/java/org/alfresco/rest/people/GatFavoriteSitesTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GatFavoriteSitesTests.java @@ -66,4 +66,16 @@ public class GatFavoriteSitesTests extends RestTest peopleApi.getFavoriteSites(contributorUser).assertResponseIsNotEmpty(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify consumer user gets its favorite sites with Rest API and response is successful (200)") + public void consumerUserGetsFavoriteSitesWithSuccess() throws Exception + { + UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel, UserRole.SiteConsumer); + dataSite.usingUser(consumerUser).usingSite(siteModel).addSiteToFavorites(); + + restClient.authenticateUser(consumerUser); + peopleApi.getFavoriteSites(consumerUser).assertResponseIsNotEmpty(); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } } From e94f3414f3b4e013c5ed516cb8e2e9dddaea62e8 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Tue, 4 Oct 2016 08:51:23 +0300 Subject: [PATCH 0198/1491] TAS-1082 getFavoriteSites call test with admin user --- .../alfresco/rest/people/GatFavoriteSitesTests.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/people/GatFavoriteSitesTests.java b/e2e-test/java/org/alfresco/rest/people/GatFavoriteSitesTests.java index 5755b4363..661f58f76 100644 --- a/e2e-test/java/org/alfresco/rest/people/GatFavoriteSitesTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GatFavoriteSitesTests.java @@ -78,4 +78,15 @@ public class GatFavoriteSitesTests extends RestTest peopleApi.getFavoriteSites(consumerUser).assertResponseIsNotEmpty(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify admin user gets its favorite sites with Rest API and response is successful (200)") + public void adminUserGetsFavoriteSitesWithSuccess() throws Exception + { + UserModel adminUser = dataUser.getAdminUser(); + dataSite.usingUser(adminUser).usingSite(siteModel).addSiteToFavorites(); + + restClient.authenticateUser(adminUser); + peopleApi.getFavoriteSites(adminUser).assertResponseIsNotEmpty(); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } } From 7094ab22637d49f49f085980526ea335add2d1a7 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Tue, 4 Oct 2016 09:26:25 +0300 Subject: [PATCH 0199/1491] TAS-1089 getFavoriteSites failed call test with Manager role --- .../rest/people/GatFavoriteSitesTests.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/people/GatFavoriteSitesTests.java b/e2e-test/java/org/alfresco/rest/people/GatFavoriteSitesTests.java index 661f58f76..50dc99283 100644 --- a/e2e-test/java/org/alfresco/rest/people/GatFavoriteSitesTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GatFavoriteSitesTests.java @@ -5,6 +5,7 @@ import org.alfresco.rest.requests.RestPeopleApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.beans.factory.annotation.Autowired; @@ -89,4 +90,18 @@ public class GatFavoriteSitesTests extends RestTest peopleApi.getFavoriteSites(adminUser).assertResponseIsNotEmpty(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + @Bug(id = "") + @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized to get its favorite sites with Rest API when authentication fails (401)") + public void managerUserGetsFavoriteSitesIsNotAuthorized() throws Exception + { + UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); + dataSite.usingUser(managerUser).usingSite(siteModel).addSiteToFavorites(); + managerUser.setPassword("newpassword"); + + restClient.authenticateUser(managerUser); + peopleApi.getFavoriteSites(managerUser); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + } } From b46ab64eb3e55757bdeddfc611c3b7af2ab0f683 Mon Sep 17 00:00:00 2001 From: cagache Date: Tue, 4 Oct 2016 09:28:33 +0300 Subject: [PATCH 0200/1491] TAS-1069 - add scenario for delete tag with admin --- .../rest/tags/RemoveTagSanityTests.java | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/tags/RemoveTagSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/tags/RemoveTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/RemoveTagSanityTests.java new file mode 100644 index 000000000..4b02fbd18 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/tags/RemoveTagSanityTests.java @@ -0,0 +1,65 @@ +package org.alfresco.rest.tags; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestTagModel; +import org.alfresco.rest.requests.RestTagsApi; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +/** + * Created by Claudia Agache on 10/4/2016. + */ +@Test(groups = { "rest-api", "tags", "sanity" }) +public class RemoveTagSanityTests extends RestTest +{ + @Autowired + private DataUser dataUser; + + @Autowired + private RestTagsApi tagsAPI; + + private UserModel adminUserModel; + private SiteModel siteModel; + private DataUser.ListUserWithRoles usersWithRoles; + private RestTagModel tag; + private FileModel document; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + } + + @BeforeMethod(alwaysRun=true) + public void addTagToDocument() throws Exception + { + restClient.authenticateUser(adminUserModel); + tagsAPI.useRestClient(restClient); + tag = tagsAPI.addTag(document, "testtag"); + } + + @TestRail(section = { "rest-api", + "tags" }, executionType = ExecutionType.SANITY, description = "Verify Admin user deletes tags with Rest API and status code is 204") + public void adminIsAbleToDeleteTags() throws JsonToModelConversionException, Exception + { + tagsAPI.deleteTag(document, tag); + tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + +} From 6c50d4e72cac8a23124d6cdc56dc810cfde53fe0 Mon Sep 17 00:00:00 2001 From: cagache Date: Tue, 4 Oct 2016 09:29:51 +0300 Subject: [PATCH 0201/1491] TAS-1061 - add scenario for delete tag by site manager --- .../org/alfresco/rest/tags/RemoveTagSanityTests.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/tags/RemoveTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/RemoveTagSanityTests.java index 4b02fbd18..374fe87be 100644 --- a/e2e-test/java/org/alfresco/rest/tags/RemoveTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/RemoveTagSanityTests.java @@ -61,5 +61,12 @@ public class RemoveTagSanityTests extends RestTest tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); } - + @TestRail(section = { "rest-api", + "tags" }, executionType = ExecutionType.SANITY, description = "Verify Manager user deletes tags created by admin user with Rest API and status code is 204") + public void managerIsAbleToDeleteTags() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + tagsAPI.deleteTag(document, tag); + tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); + } } From 630882e5f3578ed03c61fa7c22510811ffe979c8 Mon Sep 17 00:00:00 2001 From: cagache Date: Tue, 4 Oct 2016 09:30:37 +0300 Subject: [PATCH 0202/1491] TAS-1064 - add scenario for delete tag by site collaborator --- .../org/alfresco/rest/tags/RemoveTagSanityTests.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/tags/RemoveTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/RemoveTagSanityTests.java index 374fe87be..0f7d2196d 100644 --- a/e2e-test/java/org/alfresco/rest/tags/RemoveTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/RemoveTagSanityTests.java @@ -69,4 +69,13 @@ public class RemoveTagSanityTests extends RestTest tagsAPI.deleteTag(document, tag); tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); } + + @TestRail(section = { "rest-api", + "tags" }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user deletes tags created by admin user with Rest API and status code is 204") + public void collaboratorIsAbleToDeleteTags() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + tagsAPI.deleteTag(document, tag); + tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); + } } From ff6873484862390e3bea5870e34817e5f77d01c4 Mon Sep 17 00:00:00 2001 From: cagache Date: Tue, 4 Oct 2016 09:31:54 +0300 Subject: [PATCH 0203/1491] TAS-1065 - add scenario for delete tag by site contributor --- .../org/alfresco/rest/tags/RemoveTagSanityTests.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/tags/RemoveTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/RemoveTagSanityTests.java index 0f7d2196d..69e84b07f 100644 --- a/e2e-test/java/org/alfresco/rest/tags/RemoveTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/RemoveTagSanityTests.java @@ -78,4 +78,13 @@ public class RemoveTagSanityTests extends RestTest tagsAPI.deleteTag(document, tag); tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); } + + @TestRail(section = { "rest-api", + "tags" }, executionType = ExecutionType.SANITY, description = "Verify Contributor user can't delete tags created by admin user with Rest API and status code is 403") + public void contributorIsNotAbleToDeleteTags() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + tagsAPI.deleteTag(document, tag); + tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + } } From 0d5753d1c49d5989daaf76afdae5dd88c47f97a3 Mon Sep 17 00:00:00 2001 From: cagache Date: Tue, 4 Oct 2016 09:32:53 +0300 Subject: [PATCH 0204/1491] TAS-1068 - add scenario for delete tag by site consumer --- .../org/alfresco/rest/tags/RemoveTagSanityTests.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/tags/RemoveTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/RemoveTagSanityTests.java index 69e84b07f..8d2dc6cdb 100644 --- a/e2e-test/java/org/alfresco/rest/tags/RemoveTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/RemoveTagSanityTests.java @@ -87,4 +87,14 @@ public class RemoveTagSanityTests extends RestTest tagsAPI.deleteTag(document, tag); tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } + + @TestRail(section = { "rest-api", + "tags" }, executionType = ExecutionType.SANITY, description = "Verify Consumer user can't delete tags created by admin user with Rest API and status code is 403") + public void consumerIsNotAbleToDeleteTags() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + tagsAPI.deleteTag(document, tag); + tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + } + } From e305a933c153bc552414a3b457c5eb6c5a9973f5 Mon Sep 17 00:00:00 2001 From: cagache Date: Tue, 4 Oct 2016 09:34:40 +0300 Subject: [PATCH 0205/1491] TAS-1070 - add scenario for delete tag by unauthorized user --- .../org/alfresco/rest/tags/RemoveTagSanityTests.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/tags/RemoveTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/RemoveTagSanityTests.java index 8d2dc6cdb..250cfbc08 100644 --- a/e2e-test/java/org/alfresco/rest/tags/RemoveTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/RemoveTagSanityTests.java @@ -97,4 +97,14 @@ public class RemoveTagSanityTests extends RestTest tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } + @TestRail(section = { "rest-api", + "tags" }, executionType = ExecutionType.SANITY, description = "Verify Manager user gets status code 401 if authentication call fails") + public void managerIsNotAbleToDeleteTagIfAuthenticationFails() throws JsonToModelConversionException, Exception + { + UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); + siteManager.setPassword("wrongPassword"); + restClient.authenticateUser(siteManager); + tagsAPI.deleteTag(document, tag); + tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + } } From 10f8ecac5baaa4512b09be4a5283a468002ebde9 Mon Sep 17 00:00:00 2001 From: cnechifor Date: Tue, 4 Oct 2016 10:28:55 +0300 Subject: [PATCH 0206/1491] refactor --- .../rest/people/GetPeopleActivitiesTests.java | 29 +++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesTests.java index 22d4e8800..ab02b12c8 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesTests.java @@ -41,65 +41,64 @@ public class GetPeopleActivitiesTests extends RestTest } @TestRail(section = { "rest-api", "people", "activities" }, executionType = ExecutionType.SANITY, description = "Verify manager user gets its activities with Rest API and response is successful") - public void managerUserGetsPeopleActivitiesListSuccessful() throws Exception + public void managerUserShouldGetPeopleActivitiesList() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); dataContent.usingUser(managerUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); restClient.authenticateUser(managerUser); - peopleApi.getPersonActivities(managerUser).assertActivityListIsNotEmpty(); + peopleApi.getPersonActivities(managerUser).assertResponseIsNotEmpty(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { "rest-api", "people", "activities" }, executionType = ExecutionType.SANITY, description = "Verify collaborator user gets its activities with Rest API and response is successful") - public void collaboratorUserGetsPeopleActivitiesListSuccessful() throws Exception + public void collaboratorUserShouldGetPeopleActivitiesList() throws Exception { UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(collaboratorUser, siteModel, UserRole.SiteCollaborator); dataContent.usingUser(collaboratorUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); restClient.authenticateUser(collaboratorUser); - peopleApi.getPersonActivities(collaboratorUser).assertActivityListIsNotEmpty(); + peopleApi.getPersonActivities(collaboratorUser).assertResponseIsNotEmpty(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { "rest-api", "people", "activities" }, executionType = ExecutionType.SANITY, description = "Verify contributor user gets its activities with Rest API and response is successful") - public void contributorUserGetsPeopleActivitiesListSuccessful() throws Exception + public void contributorUserShouldGetPeopleActivitiesList() throws Exception { UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(contributorUser, siteModel, UserRole.SiteContributor); dataContent.usingUser(contributorUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); restClient.authenticateUser(contributorUser); - peopleApi.getPersonActivities(contributorUser).assertActivityListIsNotEmpty(); + peopleApi.getPersonActivities(contributorUser).assertResponseIsNotEmpty(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { "rest-api", "people", "activities" }, executionType = ExecutionType.SANITY, description = "Verify consumer user gets its activities with Rest API and response is successful") - public void consumerUserGetsPeopleActivitiesListSuccessful() throws Exception + public void consumerUserShouldGetPeopleActivitiesList() throws Exception { UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel, UserRole.SiteConsumer); - + dataContent.usingUser(consumerUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(consumerUser); - peopleApi.getPersonActivities(consumerUser).assertActivityListIsNotEmpty(); + peopleApi.getPersonActivities(consumerUser).assertResponseIsNotEmpty(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { "rest-api", "people", "activities" }, executionType = ExecutionType.SANITY, description = "Verify admin user gets another user activities with Rest API and response is successful") - public void adminUserGetsPeopleActivitiesListSuccessful() throws Exception + public void adminUserShouldGetPeopleActivitiesList() throws Exception { - UserModel adminUser = dataUser.getAdminUser(); - - restClient.authenticateUser(adminUser); - peopleApi.getPersonActivities(userModel).assertActivityListIsNotEmpty(); + restClient.authenticateUser(dataUser.getAdminUser()); + peopleApi.getPersonActivities(userModel).assertResponseIsNotEmpty(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @Bug(id = "") @TestRail(section = { "rest-api", "people", "activities" }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized to gets another user activities with Rest API") - public void managerUserGetsPeopleActivitiesListIsNotAuthorized() throws Exception + public void managerUserShouldGetPeopleActivitiesListIsNotAuthorized() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); From 4ddd27fd998009783139fb231495e67f0cba94b4 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Tue, 4 Oct 2016 10:56:28 +0300 Subject: [PATCH 0207/1491] TAS-1077 fail getNetwork for Person call with non existing tenant user --- .../RestGetNetworkForPersonSanityTests.java | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java new file mode 100644 index 000000000..a92a2dabf --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java @@ -0,0 +1,52 @@ +package org.alfresco.rest.networks; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.requests.RestNetworksApi; +import org.alfresco.rest.requests.RestTenantApi; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +@Test(groups = { "rest-api", "networks", "sanity" }) +public class RestGetNetworkForPersonSanityTests extends RestTest +{ + + @Autowired + RestTenantApi tenantApi; + + @Autowired + RestNetworksApi networkApi; + + private UserModel adminUserModel; + UserModel adminTenantUser; + UserModel tenantUser; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUserModel); + tenantApi.useRestClient(restClient); + tenantApi.createTenant(adminTenantUser); + + tenantUser = dataUser.usingUser(adminTenantUser).createRandomTestUser("uTenant"); + networkApi.useRestClient(restClient); + } + + @Test(groups = "sanity") + @TestRail(section = { "rest-api", + "networks" }, executionType = ExecutionType.SANITY, description = "Verify non existing user gets another exisiting network with Rest API and checks the forbidden status") + public void nonExistingTenantUserIsNotAuthorizedToRequest() throws Exception + { + UserModel tenantUser = new UserModel("nonexisting", "password"); + tenantUser.setDomain(adminTenantUser.getDomain()); + restClient.authenticateUser(tenantUser); + networkApi.getNetworkForUser(adminTenantUser); + networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + } +} From 86f27ef4ebcf3ceebf3b8aa139e95b84fde10d84 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Tue, 4 Oct 2016 11:02:22 +0300 Subject: [PATCH 0208/1491] TAS-886 REST API - valid request returns success status code 201 with Collaborator role --- .../AddSiteMembershipRequestSanityTests.java | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java index 88566bb90..2de39a5c6 100644 --- a/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java @@ -1,7 +1,7 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; -import org.alfresco.rest.body.SiteMembership; +import org.alfresco.rest.body.SiteMembershipRequest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.requests.RestPeopleApi; import org.alfresco.utility.constants.UserRole; @@ -47,18 +47,32 @@ public class AddSiteMembershipRequestSanityTests extends RestTest peopleApi.useRestClient(restClient); } - @TestRail(section = { "rest-api","people" }, + @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify site manager is able to create new site membership request") @Bug(id="MNT-16557") public void siteManagerCanCreateSiteMembershipRequest() throws JsonToModelConversionException, Exception { UserModel newMember = dataUser.createRandomTestUser(); - SiteMembership siteMembership = new SiteMembership("Please accept me", siteModel.getId(), "New request"); + SiteMembershipRequest siteMembership = new SiteMembershipRequest("Please accept me", siteModel.getId(), "New request"); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); peopleApi.addSiteMembershipRequest(newMember, siteMembership); peopleApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.CREATED); } + + @TestRail(section = { "rest-api", "people" }, + executionType = ExecutionType.SANITY, description = "Verify site collaborator is able to create new site membership request") + @Bug(id = "MNT-16557") + public void siteCollaboatorCanCreateSiteMembershipRequest() throws JsonToModelConversionException, Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + SiteMembershipRequest siteMembership = new SiteMembershipRequest("Please accept me", siteModel.getId(), "New request"); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + peopleApi.addSiteMembershipRequest(newMember, siteMembership); + peopleApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.CREATED); +} } \ No newline at end of file From 042219b059e4857c8c1d3358b6f8f60a7894e0d9 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Tue, 4 Oct 2016 11:11:07 +0300 Subject: [PATCH 0209/1491] TAS-887 REST API - valid request returns success status code 201 with Contributor role --- .../AddSiteMembershipRequestSanityTests.java | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java index 2de39a5c6..12fe4ea21 100644 --- a/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java @@ -50,7 +50,7 @@ public class AddSiteMembershipRequestSanityTests extends RestTest @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify site manager is able to create new site membership request") @Bug(id="MNT-16557") - public void siteManagerCanCreateSiteMembershipRequest() throws JsonToModelConversionException, Exception + public void siteManagerIsAbleToCreateSiteMembershipRequest() throws JsonToModelConversionException, Exception { UserModel newMember = dataUser.createRandomTestUser(); SiteMembershipRequest siteMembership = new SiteMembershipRequest("Please accept me", siteModel.getId(), "New request"); @@ -64,7 +64,7 @@ public class AddSiteMembershipRequestSanityTests extends RestTest @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify site collaborator is able to create new site membership request") @Bug(id = "MNT-16557") - public void siteCollaboatorCanCreateSiteMembershipRequest() throws JsonToModelConversionException, Exception + public void siteCollaboatorIsAbleToCreateSiteMembershipRequest() throws JsonToModelConversionException, Exception { UserModel newMember = dataUser.createRandomTestUser(); SiteMembershipRequest siteMembership = new SiteMembershipRequest("Please accept me", siteModel.getId(), "New request"); @@ -73,6 +73,20 @@ public class AddSiteMembershipRequestSanityTests extends RestTest peopleApi.addSiteMembershipRequest(newMember, siteMembership); peopleApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.CREATED); -} + } + @TestRail(section = { "rest-api", "people" }, + executionType = ExecutionType.SANITY, description = "Verify site contributor is able to create new site membership request") + @Bug(id = "MNT-16557") + public void siteContributorIsAbleToCreateSiteMembershipRequest() throws JsonToModelConversionException, Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + SiteMembershipRequest siteMembership = new SiteMembershipRequest("Please accept me", siteModel.getId(), "New request"); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + peopleApi.addSiteMembershipRequest(newMember, siteMembership); + peopleApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.CREATED); + } + } \ No newline at end of file From 1fd6a6c44c448f04645513dc3d89a0138c05ff7e Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Tue, 4 Oct 2016 11:13:13 +0300 Subject: [PATCH 0210/1491] TAS-888 REST API - valid request returns success status code 201 with Consumer role --- .../AddSiteMembershipRequestSanityTests.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java index 12fe4ea21..1f938c9ec 100644 --- a/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java @@ -89,4 +89,18 @@ public class AddSiteMembershipRequestSanityTests extends RestTest .assertStatusCodeIs(HttpStatus.CREATED); } + @TestRail(section = { "rest-api", "people" }, + executionType = ExecutionType.SANITY, description = "Verify site consumer is able to create new site membership request") + @Bug(id = "MNT-16557") + public void siteConsumerIsAbleToCreateSiteMembershipRequest() throws JsonToModelConversionException, Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + SiteMembershipRequest siteMembership = new SiteMembershipRequest("Please accept me", siteModel.getId(), "New request"); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + peopleApi.addSiteMembershipRequest(newMember, siteMembership); + peopleApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.CREATED); +} + } \ No newline at end of file From f682b0605ad83de6fd9f659fddc8c2973bd0d3dd Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Tue, 4 Oct 2016 11:21:31 +0300 Subject: [PATCH 0211/1491] TAS-1099 admin tenant checks if network is present --- .../networks/RestGetNetworkForPersonSanityTests.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java index a92a2dabf..36a1dad90 100644 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java @@ -49,4 +49,14 @@ public class RestGetNetworkForPersonSanityTests extends RestTest networkApi.getNetworkForUser(adminTenantUser); networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } + + @Test(groups = "sanity") + @TestRail(section = { "rest-api", + "networks" }, executionType = ExecutionType.SANITY, description = "Verify tenant admin user gets specific network with Rest API and response is not empty") + public void adminTenantChecksIfNetworkIsPresent() throws Exception + { + restClient.authenticateUser(adminTenantUser); + networkApi.getNetworkForUser(adminTenantUser); + networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } } From 600a3a4e30dc048c6a417d0994341652655108b4 Mon Sep 17 00:00:00 2001 From: cnechifor Date: Tue, 4 Oct 2016 11:27:26 +0300 Subject: [PATCH 0212/1491] review tests --- .../rest/sites/GetSiteMemberSanityTests.java | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java index 22eeaeccb..38eb23a6e 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java @@ -27,31 +27,23 @@ public class GetSiteMemberSanityTests extends RestTest @Autowired RestSitesApi restSitesApi; - @Autowired - DataUser dataUser; - - @Autowired - DataSite dataSite; - private UserModel adminUser; private SiteModel siteModel; private ListUserWithRoles usersWithRoles; private UserModel userModel; @BeforeClass(alwaysRun = true) - public void initSetup() throws DataPreparationException + public void dataPreparation() throws DataPreparationException { adminUser = dataUser.getAdminUser(); restSitesApi.useRestClient(restClient); siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); - userModel = dataUser.createRandomTestUser(); - dataUser.addUserToSite(userModel, siteModel, UserRole.SiteConsumer); } @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, - description = "Verify user with Manager role gets site member and gets status code OK (200)") + 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)); @@ -96,7 +88,7 @@ public class GetSiteMemberSanityTests extends RestTest } @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, - description = "Failed authentication get site member call returns status code 401 with Manager role") + description = "Failed authentication get site member call returns status code 401") public void unauthenticatedUserIsNotAuthorizedToRetrieveSiteMember() throws JsonToModelConversionException, Exception { UserModel inexistentUser = new UserModel("inexistent user", "inexistent password"); From 51613aefac498c33736f1e579ee8ed1e9567aca0 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Tue, 4 Oct 2016 11:29:10 +0300 Subject: [PATCH 0213/1491] TAS-889 REST API - valid request returns success status code 201 with admin user --- .../AddSiteMembershipRequestSanityTests.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java index 1f938c9ec..f301f25ff 100644 --- a/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java @@ -9,6 +9,7 @@ import org.alfresco.utility.data.DataSite; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.exception.DataPreparationException; +import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; @@ -101,6 +102,20 @@ public class AddSiteMembershipRequestSanityTests extends RestTest peopleApi.addSiteMembershipRequest(newMember, siteMembership); peopleApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.CREATED); -} + } + + @TestRail(section = { "rest-api", "people" }, + executionType = ExecutionType.SANITY, description = "Verify admin user is able to create new site membership request") + @Bug(id = "MNT-16557") + public void adminUserIsAbleToCreateSiteMembershipRequest() throws JsonToModelConversionException, Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + SiteMembershipRequest siteMembership = new SiteMembershipRequest("Please accept me", siteModel.getId(), "New request"); + + restClient.authenticateUser(adminUser); + peopleApi.addSiteMembershipRequest(newMember, siteMembership); + peopleApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.CREATED); + } } \ No newline at end of file From 75768855dd20ddd0b0cd14a1b811e87d79f0bef2 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Tue, 4 Oct 2016 11:35:11 +0300 Subject: [PATCH 0214/1491] TAS-890 REST API - failed authentication call returns status code 401 with Manager role --- .../AddSiteMembershipRequestSanityTests.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java index f301f25ff..eb63f95c8 100644 --- a/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java @@ -9,7 +9,6 @@ import org.alfresco.utility.data.DataSite; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.exception.DataPreparationException; -import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; @@ -118,4 +117,17 @@ public class AddSiteMembershipRequestSanityTests extends RestTest .assertStatusCodeIs(HttpStatus.CREATED); } + @TestRail(section = { "rest-api", "people" }, + executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to create new site membership request") + @Bug(id = "MNT-16557") + public void unauthenticatedUserIsNotAbleToCreateSiteMembershipRequest() throws JsonToModelConversionException, Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + SiteMembershipRequest siteMembership = new SiteMembershipRequest("Please accept me", siteModel.getId(), "New request"); + + restClient.authenticateUser(new UserModel("random user", "random password")); + peopleApi.addSiteMembershipRequest(newMember, siteMembership); + peopleApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + } } \ No newline at end of file From d2c821d0f01c49b6bc50ea07160bf078dabf6c04 Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Tue, 4 Oct 2016 12:23:18 +0300 Subject: [PATCH 0215/1491] TAS-1045 removeSiteMmember using a site manager user --- .../sites/RemoveSiteMemberSanityTests.java | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java new file mode 100644 index 000000000..ebc43ed26 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java @@ -0,0 +1,61 @@ +package org.alfresco.rest.sites; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.requests.RestSitesApi; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.exception.DataPreparationException; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +/** + * @author iulia.cojocea + */ +@Test(groups = {"rest-api", "sites", "sanity"}) +public class RemoveSiteMemberSanityTests extends RestTest +{ + + @Autowired + RestSitesApi restSitesAPI; + + @Autowired + DataUser dataUser; + + private SiteModel siteModel; + private UserModel adminUserModel; + private ListUserWithRoles usersWithRoles; + private UserModel testUserModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws DataPreparationException{ + adminUserModel = dataUser.getAdminUser(); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, + UserRole.SiteConsumer, UserRole.SiteContributor); + restSitesAPI.useRestClient(restClient); + } + + @BeforeMethod + public void addUserToSite() throws DataPreparationException{ + testUserModel = dataUser.createRandomTestUser(); + dataUser.addUserToSite(testUserModel, siteModel, UserRole.SiteConsumer); + } + + @TestRail(section = {"rest-api", "sites" }, executionType = ExecutionType.SANITY, + description = "Verify that site manager can delete site member and gets status code 204, 'No Content'") + public void siteManagerIsAbleToDeleteSiteMember() throws JsonToModelConversionException{ + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + restSitesAPI.deleteSiteMember(siteModel, testUserModel); + restSitesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); + } +} From a56d80d1f0cbaea772d1e40bbba2b554f7d2965e Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Tue, 4 Oct 2016 12:24:05 +0300 Subject: [PATCH 0216/1491] TAS-1046 removeSiteMember using a site collaborator user --- .../alfresco/rest/sites/RemoveSiteMemberSanityTests.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java index ebc43ed26..f7452eef1 100644 --- a/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java @@ -58,4 +58,13 @@ public class RemoveSiteMemberSanityTests extends RestTest restSitesAPI.deleteSiteMember(siteModel, testUserModel); restSitesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); } + + @Bug(id="ACE-5444") + @TestRail(section = {"rest-api", "sites" }, executionType = ExecutionType.SANITY, + description = "Verify that site collaborator cannot delete site member and gets status code 403, 'Forbidden'") + public void siteCollaboratorIsNotAbleToDeleteSiteMember() throws JsonToModelConversionException{ + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + restSitesAPI.deleteSiteMember(siteModel, testUserModel); + restSitesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + } } From d4a0ca414822efe9df95bc0d468326cbbdffcd3e Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Tue, 4 Oct 2016 12:25:04 +0300 Subject: [PATCH 0217/1491] TAS-1047 removeSiteMember using a site contributor user --- .../alfresco/rest/sites/RemoveSiteMemberSanityTests.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java index f7452eef1..58dbb926e 100644 --- a/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java @@ -67,4 +67,13 @@ public class RemoveSiteMemberSanityTests extends RestTest restSitesAPI.deleteSiteMember(siteModel, testUserModel); restSitesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } + + @Bug(id="ACE-5444") + @TestRail(section = {"rest-api", "sites" }, executionType = ExecutionType.SANITY, + description = "Verify that site contributor cannot delete site member and gets status code 403, 'Forbidden'") + public void siteContributorIsNotAbleToDeleteSiteMember() throws JsonToModelConversionException{ + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + restSitesAPI.deleteSiteMember(siteModel, testUserModel); + restSitesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + } } From 1a33d31a0b43771dcac0314be5deb2cb18ceb6bb Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Tue, 4 Oct 2016 12:25:49 +0300 Subject: [PATCH 0218/1491] TAS-1048 removeSiteMember using a site consumer user --- .../alfresco/rest/sites/RemoveSiteMemberSanityTests.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java index 58dbb926e..8ed24db03 100644 --- a/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java @@ -76,4 +76,13 @@ public class RemoveSiteMemberSanityTests extends RestTest restSitesAPI.deleteSiteMember(siteModel, testUserModel); restSitesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } + + @Bug(id="ACE-5444") + @TestRail(section = {"rest-api", "sites" }, executionType = ExecutionType.SANITY, + description = "Verify that site consumer cannot delete site member and gets status code 403, 'Forbidden'") + public void siteConsumerIsNotAbleToDeleteSiteMember() throws JsonToModelConversionException{ + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + restSitesAPI.deleteSiteMember(siteModel, testUserModel); + restSitesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + } } From 7dc569ae83a6896d2399863ee33809a9e45165f5 Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Tue, 4 Oct 2016 12:26:37 +0300 Subject: [PATCH 0219/1491] TAS-1049 removeSiteMember using admin user --- .../alfresco/rest/sites/RemoveSiteMemberSanityTests.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java index 8ed24db03..0f4d664a4 100644 --- a/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java @@ -85,4 +85,12 @@ public class RemoveSiteMemberSanityTests extends RestTest restSitesAPI.deleteSiteMember(siteModel, testUserModel); restSitesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } + + @TestRail(section = {"rest-api", "sites" }, executionType = ExecutionType.SANITY, + description = "Verify that admin user can delete site member and gets status code 204, 'No Content'") + public void adminUserIsAbleToDeleteSiteMember() throws JsonToModelConversionException{ + restClient.authenticateUser(adminUserModel); + restSitesAPI.deleteSiteMember(siteModel, testUserModel); + restSitesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); + } } From db59ac8c80e8ebad985905c1ffb62e86ca2a9db1 Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Tue, 4 Oct 2016 12:28:53 +0300 Subject: [PATCH 0220/1491] TAS-1050 removeSiteMember using an unauthenticated user --- .../alfresco/rest/sites/RemoveSiteMemberSanityTests.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java index 0f4d664a4..7af8adff8 100644 --- a/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java @@ -93,4 +93,13 @@ public class RemoveSiteMemberSanityTests extends RestTest restSitesAPI.deleteSiteMember(siteModel, testUserModel); restSitesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); } + + @TestRail(section = {"rest-api", "sites" }, executionType = ExecutionType.SANITY, + description = "Verify that unauthenticated user is not able to delete site member") + public void unauthenticatedUserIsNotAuthorizedToDeleteSiteMmeber() throws Exception{ + UserModel inexistentUser = new UserModel("inexistent user", "inexistent password"); + restClient.authenticateUser(inexistentUser); + restSitesAPI.deleteSiteMember(siteModel, testUserModel); + restSitesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + } } From 94c0ade52eb71ebe29b7cda8bf116bc5762972e7 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Tue, 4 Oct 2016 14:13:21 +0300 Subject: [PATCH 0221/1491] TAS-1116 --- .../RestGetNetworkForPersonSanityTests.java | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java index 36a1dad90..bb02bd0ff 100644 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java @@ -14,17 +14,17 @@ import org.testng.annotations.Test; @Test(groups = { "rest-api", "networks", "sanity" }) public class RestGetNetworkForPersonSanityTests extends RestTest { - + @Autowired RestTenantApi tenantApi; - + @Autowired RestNetworksApi networkApi; - + private UserModel adminUserModel; UserModel adminTenantUser; UserModel tenantUser; - + @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception { @@ -37,7 +37,7 @@ public class RestGetNetworkForPersonSanityTests extends RestTest tenantUser = dataUser.usingUser(adminTenantUser).createRandomTestUser("uTenant"); networkApi.useRestClient(restClient); } - + @Test(groups = "sanity") @TestRail(section = { "rest-api", "networks" }, executionType = ExecutionType.SANITY, description = "Verify non existing user gets another exisiting network with Rest API and checks the forbidden status") @@ -49,7 +49,7 @@ public class RestGetNetworkForPersonSanityTests extends RestTest networkApi.getNetworkForUser(adminTenantUser); networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } - + @Test(groups = "sanity") @TestRail(section = { "rest-api", "networks" }, executionType = ExecutionType.SANITY, description = "Verify tenant admin user gets specific network with Rest API and response is not empty") @@ -59,4 +59,15 @@ public class RestGetNetworkForPersonSanityTests extends RestTest networkApi.getNetworkForUser(adminTenantUser); networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + @Test(groups = "sanity") + @TestRail(section = { "rest-api", + "networks" }, executionType = ExecutionType.SANITY, description = "Verify tenant user is not authorized to check network of another user with Rest API and checks the forbidden status") + public void tenantUserIsNotAuthorizedToCheckNetworkOfAnotherUser() throws Exception + { + restClient.authenticateUser(tenantUser); + networkApi.getNetworkForUser(adminTenantUser); + networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + } + } From 88c98096db514a2e8e756e8328b6d2ad6ff0cbe6 Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Tue, 4 Oct 2016 14:39:34 +0300 Subject: [PATCH 0222/1491] TAS-1117 fix getSiteContainer request --- .../org/alfresco/rest/sites/GetSiteContainerSanityTests.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java index 1d05da61f..9a0430995 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java @@ -1,12 +1,9 @@ package org.alfresco.rest.sites; import org.alfresco.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestSiteContainerModel; import org.alfresco.rest.requests.RestSitesApi; import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataSite; -import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; @@ -93,7 +90,7 @@ public class GetSiteContainerSanityTests extends RestTest } @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, - description = "Failed authentication get site container call returns status code 401 with Manager role") + description = "Failed authentication get site container call returns status code 401") public void unauthenticatedUserIsNotAuthorizedToRetrieveSiteContainer() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); From 158fe5435d0b4aa1f1236ba6b3eda7defac642d2 Mon Sep 17 00:00:00 2001 From: cagache Date: Tue, 4 Oct 2016 15:57:36 +0300 Subject: [PATCH 0223/1491] checked that response contains tag --- e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java index 4da8f740a..4c86e47a1 100644 --- a/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java @@ -47,7 +47,7 @@ public class AddTagSanityTests extends RestTest "tags" }, executionType = ExecutionType.SANITY, description = "Verify admin user adds tags with Rest API and status code is 201") public void adminIsAbleToAddTag() throws JsonToModelConversionException, Exception { - tagsAPI.addTag(document, "tag" + adminUserModel.getUsername()); + tagsAPI.addTag(document, "tag" + adminUserModel.getUsername()).assertTagIs("tag" + adminUserModel.getUsername()); tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } @@ -56,7 +56,7 @@ public class AddTagSanityTests extends RestTest public void managerIsAbleToAddTag() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - tagsAPI.addTag(document, "tag" + UserRole.SiteManager); + tagsAPI.addTag(document, "tag" + UserRole.SiteManager).assertTagIs("tag" + UserRole.SiteManager); tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } @@ -65,7 +65,7 @@ public class AddTagSanityTests extends RestTest public void collaboratorIsAbleToAddTag() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - tagsAPI.addTag(document, "tag" + UserRole.SiteCollaborator); + tagsAPI.addTag(document, "tag" + UserRole.SiteCollaborator).assertTagIs("tag" + UserRole.SiteCollaborator); tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } From 5cf900dede1b9dbfb0539c0c2152274fb47f5524 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Tue, 4 Oct 2016 16:55:28 +0300 Subject: [PATCH 0224/1491] TAS-1125 get network of another user as admin call returns status code 401 --- .../RestGetNetworkForPersonSanityTests.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java index bb02bd0ff..8dd34398e 100644 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java @@ -62,12 +62,23 @@ public class RestGetNetworkForPersonSanityTests extends RestTest @Test(groups = "sanity") @TestRail(section = { "rest-api", - "networks" }, executionType = ExecutionType.SANITY, description = "Verify tenant user is not authorized to check network of another user with Rest API and checks the forbidden status") - public void tenantUserIsNotAuthorizedToCheckNetworkOfAnotherUser() throws Exception - { + "networks" }, executionType = ExecutionType.SANITY, description = "Verify tenant user is not authorized to check network of admin user with Rest API and checks the forbidden status") + public void tenantUserIsNotAuthorizedToCheckNetworkOfAdminUser() throws Exception + { restClient.authenticateUser(tenantUser); networkApi.getNetworkForUser(adminTenantUser); networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } + + @Test(groups = "sanity") + @TestRail(section = { "rest-api", + "networks" }, executionType = ExecutionType.SANITY, description = "Verify admin tenant user is not authorized to check network of another user with Rest API and checks the forbidden status") + public void adminTenantUserIsNotAuthorizedToCheckNetworkOfAnotherUser() throws Exception + { + tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("anotherTenant"); + restClient.authenticateUser(adminTenantUser); + networkApi.getNetworkForUser(tenantUser); + networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + } } From d03ad6fe9685e917565e1ac6087307a89d8e0a9a Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Tue, 4 Oct 2016 17:14:01 +0300 Subject: [PATCH 0225/1491] TAS-1126 REST API - valid request returns success status code 200 with Manager role --- .../GetSiteMembershipRequestSanityTests.java | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestSanityTests.java new file mode 100644 index 000000000..0fa78e8b2 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestSanityTests.java @@ -0,0 +1,67 @@ +package org.alfresco.rest.people; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.body.SiteMembership; +import org.alfresco.rest.body.SiteMembershipRequest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.requests.RestPeopleApi; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataSite; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.exception.DataPreparationException; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +@Test(groups = { "rest-api", "people", "sanity" }) +public class GetSiteMembershipRequestSanityTests extends RestTest +{ + @Autowired + RestPeopleApi peopleApi; + + @Autowired + DataUser dataUser; + + @Autowired + DataSite dataSite; + + private SiteModel siteModel; + + private ListUserWithRoles usersWithRoles; + + private UserModel adminUser; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws DataPreparationException + { + adminUser = dataUser.getAdminUser(); + siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + + peopleApi.useRestClient(restClient); + } + + @TestRail(section = { "rest-api","people" }, + executionType = ExecutionType.SANITY, description = "Verify site manager is able to retrieve site membership request") + @Bug(id="MNT-16557") + public void siteManagerIsAbleToRetrieveSiteMembershipRequest() throws JsonToModelConversionException, Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + SiteMembership siteMembership = new SiteMembership("Please accept me", siteModel.getId(), "New request"); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + peopleApi.addSiteMembershipRequest(newMember, siteMembership); + + peopleApi.getSiteMembershipRequest(newMember, siteModel); + peopleApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.OK); + } + +} \ No newline at end of file From a3879df048f2246b090d6f3d5aa99ded588ebd33 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Tue, 4 Oct 2016 17:15:27 +0300 Subject: [PATCH 0226/1491] TAS-1127 REST API - valid request returns success status code 200 with Collaborator role --- .../GetSiteMembershipRequestSanityTests.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestSanityTests.java index 0fa78e8b2..1f25c309b 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestSanityTests.java @@ -63,5 +63,21 @@ public class GetSiteMembershipRequestSanityTests extends RestTest peopleApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.OK); } + + @TestRail(section = { "rest-api", + "people" }, executionType = ExecutionType.SANITY, description = "Verify site collaborator is able to retrieve site membership request") + @Bug(id = "MNT-16557") + public void siteCollaboratorIsAbleToRetrieveSiteMembershipRequest() throws JsonToModelConversionException, Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + SiteMembership siteMembership = new SiteMembership("Please accept me", siteModel.getId(), "New request"); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + peopleApi.addSiteMembershipRequest(newMember, siteMembership); + + peopleApi.getSiteMembershipRequest(newMember, siteModel); + peopleApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.OK); + } } \ No newline at end of file From d213f837113a8f4e0922f807d8af29f12f25cb8a Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Tue, 4 Oct 2016 17:16:46 +0300 Subject: [PATCH 0227/1491] TAS-1128 REST API - valid request returns success status code 200 with Contributor role --- .../GetSiteMembershipRequestSanityTests.java | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestSanityTests.java index 1f25c309b..5fea397ca 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestSanityTests.java @@ -64,8 +64,8 @@ public class GetSiteMembershipRequestSanityTests extends RestTest .assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", - "people" }, executionType = ExecutionType.SANITY, description = "Verify site collaborator is able to retrieve site membership request") + @TestRail(section = { "rest-api", "people" }, + executionType = ExecutionType.SANITY, description = "Verify site collaborator is able to retrieve site membership request") @Bug(id = "MNT-16557") public void siteCollaboratorIsAbleToRetrieveSiteMembershipRequest() throws JsonToModelConversionException, Exception { @@ -79,5 +79,20 @@ public class GetSiteMembershipRequestSanityTests extends RestTest peopleApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.OK); } + + @TestRail(section = { "rest-api", "people" }, + executionType = ExecutionType.SANITY, description = "Verify site contributor is able to retrieve site membership request") + @Bug(id = "MNT-16557") + public void siteContributorIsAbleToRetrieveSiteMembershipRequest() throws JsonToModelConversionException, Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + SiteMembership siteMembership = new SiteMembership("Please accept me", siteModel.getId(), "New request"); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + peopleApi.addSiteMembershipRequest(newMember, siteMembership); + + peopleApi.getSiteMembershipRequest(newMember, siteModel); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); +} } \ No newline at end of file From 50e9077275cff74414bbf9a711b4c3bc76d290c3 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Tue, 4 Oct 2016 17:18:05 +0300 Subject: [PATCH 0228/1491] TAS-1129 REST API - valid request returns success status code 200 with Consumer role --- .../GetSiteMembershipRequestSanityTests.java | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestSanityTests.java index 5fea397ca..6b595cd2e 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestSanityTests.java @@ -92,7 +92,24 @@ public class GetSiteMembershipRequestSanityTests extends RestTest peopleApi.addSiteMembershipRequest(newMember, siteMembership); peopleApi.getSiteMembershipRequest(newMember, siteModel); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); -} + peopleApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { "rest-api", "people" }, + executionType = ExecutionType.SANITY, description = "Verify site consumer is able to retrieve site membership request") + @Bug(id = "MNT-16557") + public void siteConsumerIsAbleToRetrieveSiteMembershipRequest() throws JsonToModelConversionException, Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + SiteMembership siteMembership = new SiteMembership("Please accept me", siteModel.getId(), "New request"); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + peopleApi.addSiteMembershipRequest(newMember, siteMembership); + + peopleApi.getSiteMembershipRequest(newMember, siteModel); + peopleApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.OK); + } } \ No newline at end of file From 43a010b4c173dae4daa15ce1119a6a5c317c38a6 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Tue, 4 Oct 2016 17:19:10 +0300 Subject: [PATCH 0229/1491] TAS-1130 REST API - valid request returns success status code 200 with admin user --- .../GetSiteMembershipRequestSanityTests.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestSanityTests.java index 6b595cd2e..52807ab95 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestSanityTests.java @@ -111,5 +111,21 @@ public class GetSiteMembershipRequestSanityTests extends RestTest peopleApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.OK); } + + @TestRail(section = { "rest-api", "people" }, + executionType = ExecutionType.SANITY, description = "Verify admin user is able to retrieve site membership request") + @Bug(id = "MNT-16557") + public void adminIsAbleToRetrieveSiteMembershipRequest() throws JsonToModelConversionException, Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + SiteMembership siteMembership = new SiteMembership("Please accept me", siteModel.getId(), "New request"); + + restClient.authenticateUser(adminUser); + peopleApi.addSiteMembershipRequest(newMember, siteMembership); + + peopleApi.getSiteMembershipRequest(newMember, siteModel); + peopleApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.OK); + } } \ No newline at end of file From 5056b352d069abb788c3939f3db614c9c6a7e1a4 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Tue, 4 Oct 2016 17:23:00 +0300 Subject: [PATCH 0230/1491] TAS-1131 REST API - failed authentication call returns status code 401 --- .../GetSiteMembershipRequestSanityTests.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestSanityTests.java index 52807ab95..de776b7e6 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestSanityTests.java @@ -2,7 +2,6 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; import org.alfresco.rest.body.SiteMembership; -import org.alfresco.rest.body.SiteMembershipRequest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.requests.RestPeopleApi; import org.alfresco.utility.constants.UserRole; @@ -128,4 +127,20 @@ public class GetSiteMembershipRequestSanityTests extends RestTest .assertStatusCodeIs(HttpStatus.OK); } + @TestRail(section = { "rest-api", "people" }, + executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to retrieve site membership request") + @Bug(id = "MNT-16557") + public void unauthenticatedUserIsNotAbleToRetrieveSiteMembershipRequest() throws JsonToModelConversionException, Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + SiteMembership siteMembership = new SiteMembership("Please accept me", siteModel.getId(), "New request"); + + restClient.authenticateUser(new UserModel("random user", "random password")); + peopleApi.addSiteMembershipRequest(newMember, siteMembership); + + peopleApi.getSiteMembershipRequest(newMember, siteModel); + peopleApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + } + } \ No newline at end of file From 32862987a1a1f441cf83accd170bacbf8a4dd185 Mon Sep 17 00:00:00 2001 From: cnechifor Date: Tue, 4 Oct 2016 17:43:34 +0300 Subject: [PATCH 0231/1491] review --- .../rest/people/GetPeoplePreferencesTests.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesTests.java index 09ed913ff..67a5b56c0 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesTests.java @@ -45,7 +45,7 @@ public class GetPeoplePreferencesTests extends RestTest dataSite.usingUser(managerUser).usingSite(siteModel).addSiteToFavorites(); restClient.authenticateUser(managerUser); - peopleApi.getPersonPreferences(managerUser).assertPreferencesListIsNotEmpty(); + peopleApi.getPersonPreferences(managerUser).assertEntriesListIsNotEmpty(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -57,7 +57,7 @@ public class GetPeoplePreferencesTests extends RestTest dataSite.usingUser(collaboratorUser).usingSite(siteModel).addSiteToFavorites(); restClient.authenticateUser(collaboratorUser); - peopleApi.getPersonPreferences(collaboratorUser).assertPreferencesListIsNotEmpty(); + peopleApi.getPersonPreferences(collaboratorUser).assertEntriesListIsNotEmpty(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -69,7 +69,7 @@ public class GetPeoplePreferencesTests extends RestTest dataSite.usingUser(contributorUser).usingSite(siteModel).addSiteToFavorites(); restClient.authenticateUser(contributorUser); - peopleApi.getPersonPreferences(contributorUser).assertPreferencesListIsNotEmpty(); + peopleApi.getPersonPreferences(contributorUser).assertEntriesListIsNotEmpty(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -81,7 +81,7 @@ public class GetPeoplePreferencesTests extends RestTest dataSite.usingUser(consumerUser).usingSite(siteModel).addSiteToFavorites(); restClient.authenticateUser(consumerUser); - peopleApi.getPersonPreferences(consumerUser).assertPreferencesListIsNotEmpty(); + peopleApi.getPersonPreferences(consumerUser).assertEntriesListIsNotEmpty(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -94,7 +94,7 @@ public class GetPeoplePreferencesTests extends RestTest UserModel adminUser = dataUser.getAdminUser(); restClient.authenticateUser(adminUser); - peopleApi.getPersonPreferences(managerUser).assertPreferencesListIsNotEmpty(); + peopleApi.getPersonPreferences(managerUser).assertEntriesListIsNotEmpty(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } From ab42eb6991959e5611e22953b3273d3fe8057ced Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Tue, 4 Oct 2016 18:03:04 +0300 Subject: [PATCH 0232/1491] TAS-1102 post favoriteSite call test with Manager role --- .../rest/people/AddFavoriteSiteTests.java | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteTests.java diff --git a/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteTests.java b/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteTests.java new file mode 100644 index 000000000..175b336fa --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteTests.java @@ -0,0 +1,44 @@ +package org.alfresco.rest.people; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.requests.RestPeopleApi; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +@Test(groups = { "rest-api", "people", "sanity" }) +public class AddFavoriteSiteTests extends RestTest +{ + @Autowired + RestPeopleApi peopleApi; + + UserModel userModel; + SiteModel siteModel; + UserModel searchedUser; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + + peopleApi.useRestClient(restClient); + } + + @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify manager user add a favorite site with Rest API and response is successful (201)") + public void managerUserAddFavoriteSiteWithSuccess() throws Exception + { + UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); + + restClient.authenticateUser(managerUser); + peopleApi.addFavoriteSite(managerUser, siteModel); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + } +} From 51b55a76a2fcd13aaefc8dc58fc6f99789ab2fb7 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Tue, 4 Oct 2016 18:11:23 +0300 Subject: [PATCH 0233/1491] TAS-1104 post favoriteSite call test with Collaborator role --- .../alfresco/rest/people/AddFavoriteSiteTests.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteTests.java b/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteTests.java index 175b336fa..382074e64 100644 --- a/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteTests.java +++ b/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteTests.java @@ -41,4 +41,15 @@ public class AddFavoriteSiteTests extends RestTest peopleApi.addFavoriteSite(managerUser, siteModel); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } + + @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify collaborator user add a favorite site with Rest API and response is successful (201)") + public void collaboratorUserAddFavoriteSiteWithSuccess() throws Exception + { + UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(collaboratorUser, siteModel, UserRole.SiteCollaborator); + + restClient.authenticateUser(collaboratorUser); + peopleApi.addFavoriteSite(collaboratorUser, siteModel); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + } } From e5a2836bda3a1bf46da66a57a543041945c4fac3 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Tue, 4 Oct 2016 18:12:09 +0300 Subject: [PATCH 0234/1491] TAS-1106 post favoriteSite call test with Contributor role --- .../alfresco/rest/people/AddFavoriteSiteTests.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteTests.java b/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteTests.java index 382074e64..363701e0e 100644 --- a/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteTests.java +++ b/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteTests.java @@ -52,4 +52,15 @@ public class AddFavoriteSiteTests extends RestTest peopleApi.addFavoriteSite(collaboratorUser, siteModel); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } + + @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify contributor user add a favorite site with Rest API and response is successful (201)") + public void contributorUserAddFavoriteSiteWithSuccess() throws Exception + { + UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(contributorUser, siteModel, UserRole.SiteContributor); + + restClient.authenticateUser(contributorUser); + peopleApi.addFavoriteSite(contributorUser, siteModel); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + } } From 1e077f1bf730a6b12c36c283bcd9237e64a65198 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Tue, 4 Oct 2016 18:13:44 +0300 Subject: [PATCH 0235/1491] TAS-1107 post favoriteSite call test with Consumer role --- .../alfresco/rest/people/AddFavoriteSiteTests.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteTests.java b/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteTests.java index 363701e0e..b0620d8d2 100644 --- a/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteTests.java +++ b/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteTests.java @@ -63,4 +63,15 @@ public class AddFavoriteSiteTests extends RestTest peopleApi.addFavoriteSite(contributorUser, siteModel); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } + + @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify consumer user add a favorite site with Rest API and response is successful (201)") + public void consumerUserAddFavoriteSiteWithSuccess() throws Exception + { + UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel, UserRole.SiteConsumer); + + restClient.authenticateUser(consumerUser); + peopleApi.addFavoriteSite(consumerUser, siteModel); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + } } From 97524a46f20a0aa448df6fbdce0ca035964f2b15 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Tue, 4 Oct 2016 18:16:07 +0300 Subject: [PATCH 0236/1491] TAS-1108 post favoriteSite call test with admin user --- .../org/alfresco/rest/people/AddFavoriteSiteTests.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteTests.java b/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteTests.java index b0620d8d2..6c92a414c 100644 --- a/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteTests.java +++ b/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteTests.java @@ -74,4 +74,14 @@ public class AddFavoriteSiteTests extends RestTest peopleApi.addFavoriteSite(consumerUser, siteModel); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } + + @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify admin user add a favorite site with Rest API and response is successful (201)") + public void adminUserAddFavoriteSiteWithSuccess() throws Exception + { + UserModel adminUser = dataUser.getAdminUser(); + + restClient.authenticateUser(adminUser); + peopleApi.addFavoriteSite(adminUser, siteModel); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + } } From d344cc0ee6fbe0248a5fa355731d5bed4f9ec0ed Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Tue, 4 Oct 2016 18:22:14 +0300 Subject: [PATCH 0237/1491] TAS-1109post favoriteSite failed call test with Manager role --- .../rest/people/AddFavoriteSiteTests.java | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteTests.java b/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteTests.java index 6c92a414c..59b1b2bd7 100644 --- a/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteTests.java +++ b/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteTests.java @@ -5,6 +5,7 @@ import org.alfresco.rest.requests.RestPeopleApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.beans.factory.annotation.Autowired; @@ -41,7 +42,7 @@ public class AddFavoriteSiteTests extends RestTest peopleApi.addFavoriteSite(managerUser, siteModel); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } - + @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify collaborator user add a favorite site with Rest API and response is successful (201)") public void collaboratorUserAddFavoriteSiteWithSuccess() throws Exception { @@ -52,7 +53,7 @@ public class AddFavoriteSiteTests extends RestTest peopleApi.addFavoriteSite(collaboratorUser, siteModel); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } - + @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify contributor user add a favorite site with Rest API and response is successful (201)") public void contributorUserAddFavoriteSiteWithSuccess() throws Exception { @@ -63,7 +64,7 @@ public class AddFavoriteSiteTests extends RestTest peopleApi.addFavoriteSite(contributorUser, siteModel); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } - + @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify consumer user add a favorite site with Rest API and response is successful (201)") public void consumerUserAddFavoriteSiteWithSuccess() throws Exception { @@ -74,7 +75,7 @@ public class AddFavoriteSiteTests extends RestTest peopleApi.addFavoriteSite(consumerUser, siteModel); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } - + @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify admin user add a favorite site with Rest API and response is successful (201)") public void adminUserAddFavoriteSiteWithSuccess() throws Exception { @@ -84,4 +85,17 @@ public class AddFavoriteSiteTests extends RestTest peopleApi.addFavoriteSite(adminUser, siteModel); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } + + @Bug(id = "") + @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify a manager user is NOT Authorized to add a favorite site with Rest API when authentication fails (401)") + public void managerUserNotAuthorizedFailsToAddFavoriteSite() throws Exception + { + UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); + managerUser.setPassword("newpassword"); + + restClient.authenticateUser(managerUser); + peopleApi.addFavoriteSite(managerUser, siteModel); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + } } From bf42c68e0e812c818b9a953c83286bea80bd7ebc Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Tue, 4 Oct 2016 20:05:21 +0300 Subject: [PATCH 0238/1491] TAS-1059 getPreference call test with Manager role --- .../rest/people/GetPeoplePreferenceTests.java | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceTests.java diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceTests.java new file mode 100644 index 000000000..dc3418b53 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceTests.java @@ -0,0 +1,51 @@ +package org.alfresco.rest.people; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.requests.RestPeopleApi; +import org.alfresco.utility.constants.PreferenceName; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Tests for Get a Peference (/people/{personId}/preferences/{preferenceName}) RestAPI call + * + * @author Cristina Axinte + * + */ +@Test(groups = { "rest-api", "people", "preferences", "sanity" }) +public class GetPeoplePreferenceTests extends RestTest +{ + @Autowired + RestPeopleApi peopleApi; + + UserModel userModel; + SiteModel siteModel; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + + peopleApi.useRestClient(restClient); + } + + @TestRail(section = { "rest-api", "people", "preferences" }, executionType = ExecutionType.SANITY, description = "Verify manager user gets a specific preference with Rest API and response is successful (200)") + public void managerUserGetsAPreferenceWithSuccess() throws Exception + { + UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); + dataSite.usingUser(managerUser).usingSite(siteModel).addSiteToFavorites(); + + restClient.authenticateUser(managerUser); + peopleApi.getPersonPreferenceInformation(managerUser, PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } +} From ffaa3da73b564e0a6389977e31539c1d45c4c3ba Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Tue, 4 Oct 2016 20:15:12 +0300 Subject: [PATCH 0239/1491] TAS-1060 getPreference call test with Collaborator role --- .../rest/people/GetPeoplePreferenceTests.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceTests.java index dc3418b53..c69aee00a 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceTests.java @@ -48,4 +48,16 @@ public class GetPeoplePreferenceTests extends RestTest peopleApi.getPersonPreferenceInformation(managerUser, PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + @TestRail(section = { "rest-api", "people", "preferences" }, executionType = ExecutionType.SANITY, description = "Verify collaborator user gets a specific preference with Rest API and response is successful (200)") + public void collaboratorUserGetsAPreferenceWithSuccess() throws Exception + { + UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(collaboratorUser, siteModel, UserRole.SiteCollaborator); + dataSite.usingUser(collaboratorUser).usingSite(siteModel).addSiteToFavorites(); + + restClient.authenticateUser(collaboratorUser); + peopleApi.getPersonPreferenceInformation(collaboratorUser, PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } } From d8f6cca778f65ff53d1e23cb7d9ac8ae04e1aef4 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Tue, 4 Oct 2016 20:17:24 +0300 Subject: [PATCH 0240/1491] TAS-1062 getPreference call test with Contributor role --- .../rest/people/GetPeoplePreferenceTests.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceTests.java index c69aee00a..c97108b36 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceTests.java @@ -60,4 +60,16 @@ public class GetPeoplePreferenceTests extends RestTest peopleApi.getPersonPreferenceInformation(collaboratorUser, PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + @TestRail(section = { "rest-api", "people", "preferences" }, executionType = ExecutionType.SANITY, description = "Verify contributor user gets a specific preference with Rest API and response is successful (200)") + public void contributorUserGetsAPreferenceWithSuccess() throws Exception + { + UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(contributorUser, siteModel, UserRole.SiteContributor); + dataSite.usingUser(contributorUser).usingSite(siteModel).addSiteToFavorites(); + + restClient.authenticateUser(contributorUser); + peopleApi.getPersonPreferenceInformation(contributorUser, PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } } From 7b102f367cfc5f3a063a1668e53b1c63dea59f5f Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Tue, 4 Oct 2016 20:19:17 +0300 Subject: [PATCH 0241/1491] TAS-1063 getPreference call test with Consumer role --- .../rest/people/GetPeoplePreferenceTests.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceTests.java index c97108b36..58ca930e6 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceTests.java @@ -72,4 +72,16 @@ public class GetPeoplePreferenceTests extends RestTest peopleApi.getPersonPreferenceInformation(contributorUser, PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + @TestRail(section = { "rest-api", "people", "preferences" }, executionType = ExecutionType.SANITY, description = "Verify consumer user gets a specific preference with Rest API and response is successful (200)") + public void consumerUserGetsAPreferenceWithSuccess() throws Exception + { + UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel, UserRole.SiteConsumer); + dataSite.usingUser(consumerUser).usingSite(siteModel).addSiteToFavorites(); + + restClient.authenticateUser(consumerUser); + peopleApi.getPersonPreferenceInformation(consumerUser, PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } } From 083bab5f65d7035d64c75673f06e63f0b1a49169 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Tue, 4 Oct 2016 20:21:28 +0300 Subject: [PATCH 0242/1491] TAS-1066 getPreference call test with admin user --- .../rest/people/GetPeoplePreferenceTests.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceTests.java index 58ca930e6..4b71cfb9f 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceTests.java @@ -84,4 +84,15 @@ public class GetPeoplePreferenceTests extends RestTest peopleApi.getPersonPreferenceInformation(consumerUser, PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + @TestRail(section = { "rest-api", "people", "preferences" }, executionType = ExecutionType.SANITY, description = "Verify admin user gets a specific preference with Rest API and response is successful (200)") + public void adminUserGetsAPreferenceWithSuccess() throws Exception + { + UserModel adminUser = dataUser.getAdminUser(); + dataSite.usingUser(adminUser).usingSite(siteModel).addSiteToFavorites(); + + restClient.authenticateUser(adminUser); + peopleApi.getPersonPreferenceInformation(adminUser, PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } } From d3c27709e39c9efd11514b2cda8792dfe9417723 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Tue, 4 Oct 2016 20:27:53 +0300 Subject: [PATCH 0243/1491] TAS-1132 getPreference call failed test with Manager role --- .../rest/people/GetPeoplePreferenceTests.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceTests.java index 4b71cfb9f..5bf64d185 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceTests.java @@ -6,6 +6,7 @@ import org.alfresco.utility.constants.PreferenceName; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.beans.factory.annotation.Autowired; @@ -95,4 +96,18 @@ public class GetPeoplePreferenceTests extends RestTest peopleApi.getPersonPreferenceInformation(adminUser, PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + @Bug(id = "") + @TestRail(section = { "rest-api", "people", "preferences" }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized to get a specific preference with Rest API when authentication fails (401)") + public void managerUserNotAuthorizedFailsToGetsAPreference() throws Exception + { + UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); + dataSite.usingUser(managerUser).usingSite(siteModel).addSiteToFavorites(); + managerUser.setPassword("newpassword"); + + restClient.authenticateUser(managerUser); + peopleApi.getPersonPreferenceInformation(managerUser, PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + } } From 02789f8fa16fa83b0cadabee80b667de89f8260f Mon Sep 17 00:00:00 2001 From: cnechifor Date: Tue, 4 Oct 2016 20:39:35 +0300 Subject: [PATCH 0244/1491] code review --- .../alfresco/rest/tags/AddTagSanityTests.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java index 4c86e47a1..d1a74f2fd 100644 --- a/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java @@ -6,6 +6,7 @@ import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.requests.RestTagsApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.data.RandomData; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; @@ -32,6 +33,7 @@ public class AddTagSanityTests extends RestTest private FileModel document; private SiteModel siteModel; private DataUser.ListUserWithRoles usersWithRoles; + private String tagValue; @BeforeClass(alwaysRun=true) public void dataPreparation() throws Exception @@ -47,16 +49,20 @@ public class AddTagSanityTests extends RestTest "tags" }, executionType = ExecutionType.SANITY, description = "Verify admin user adds tags with Rest API and status code is 201") public void adminIsAbleToAddTag() throws JsonToModelConversionException, Exception { - tagsAPI.addTag(document, "tag" + adminUserModel.getUsername()).assertTagIs("tag" + adminUserModel.getUsername()); + tagValue = RandomData.getRandomName("tag"); + restClient.authenticateUser(adminUserModel); + tagsAPI.addTag(document, tagValue).assertTagIs(tagValue); tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + } @TestRail(section = { "rest-api", "tags" }, executionType = ExecutionType.SANITY, description = "Verify Manager user adds tags with Rest API and status code is 201") public void managerIsAbleToAddTag() throws JsonToModelConversionException, Exception { + tagValue = RandomData.getRandomName("tag"); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - tagsAPI.addTag(document, "tag" + UserRole.SiteManager).assertTagIs("tag" + UserRole.SiteManager); + tagsAPI.addTag(document, tagValue).assertTagIs(tagValue); tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } @@ -64,8 +70,9 @@ public class AddTagSanityTests extends RestTest "tags" }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user adds tags with Rest API and status code is 201") public void collaboratorIsAbleToAddTag() throws JsonToModelConversionException, Exception { + tagValue = RandomData.getRandomName("tag"); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - tagsAPI.addTag(document, "tag" + UserRole.SiteCollaborator).assertTagIs("tag" + UserRole.SiteCollaborator); + tagsAPI.addTag(document, tagValue).assertTagIs(tagValue); tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } @@ -73,8 +80,9 @@ public class AddTagSanityTests extends RestTest "tags" }, executionType = ExecutionType.SANITY, description = "Verify Contributor user doesn't have permission to add tags with Rest API and status code is 403") public void contributorIsNotAbleToAddTag() throws JsonToModelConversionException, Exception { + tagValue = RandomData.getRandomName("tag"); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - tagsAPI.addTag(document, "tag" + UserRole.SiteContributor); + tagsAPI.addTag(document, tagValue); tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } @@ -82,8 +90,9 @@ public class AddTagSanityTests extends RestTest "tags" }, executionType = ExecutionType.SANITY, description = "Verify Consumer user doesn't have permission to add tags with Rest API and status code is 403") public void consumerIsNotAbleToAddTag() throws JsonToModelConversionException, Exception { + tagValue = RandomData.getRandomName("tag"); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - tagsAPI.addTag(document, "tag" + UserRole.SiteConsumer); + tagsAPI.addTag(document, tagValue); tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } From c5b0e74cbf07c9767c639b966a5f944ca5a5f8a0 Mon Sep 17 00:00:00 2001 From: cnechifor Date: Tue, 4 Oct 2016 22:03:09 +0300 Subject: [PATCH 0245/1491] code review --- .../rest/ratings/AddRateSanityTests.java | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/ratings/AddRateSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/AddRateSanityTests.java index e76113ee9..63ab3923d 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/AddRateSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/AddRateSanityTests.java @@ -4,8 +4,8 @@ import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.body.FiveStarRatingBody; import org.alfresco.rest.body.LikeRatingBody; -import org.alfresco.rest.body.LikeRatingBody.ratingTypes; import org.alfresco.rest.requests.RestRatingsApi; +import org.alfresco.utility.constants.Rating; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.exception.DataPreparationException; @@ -58,7 +58,7 @@ public class AddRateSanityTests extends RestTest description = "Verify user with Manager role is able to post like rating to a document") public void managerIsAbleToLikeDocument() throws Exception { - likeRating = new LikeRatingBody(ratingTypes.fiveStar.toString(), true); + likeRating = new LikeRatingBody(Rating.fiveStar, true); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); ratingsApi.likeDocument(document, likeRating); @@ -70,7 +70,7 @@ public class AddRateSanityTests extends RestTest description = "Verify user with Collaborator role is able to post like rating to a document") public void collaboratorIsAbleToLikeDocument() throws Exception { - likeRating = new LikeRatingBody(ratingTypes.likes.toString(), true); + likeRating = new LikeRatingBody(Rating.likes, true); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); ratingsApi.likeDocument(document, likeRating); @@ -82,7 +82,7 @@ public class AddRateSanityTests extends RestTest description = "Verify user with Contributor role is able to post like rating to a document") public void contributorIsAbleToLikeDocument() throws Exception { - likeRating = new LikeRatingBody(ratingTypes.likes.toString(), true); + likeRating = new LikeRatingBody(Rating.likes, true); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); ratingsApi.likeDocument(document, likeRating); @@ -94,7 +94,7 @@ public class AddRateSanityTests extends RestTest description = "Verify user with Consumer role is able to post like rating to a document") public void consumerIsAbleToLikeDocument() throws Exception { - likeRating = new LikeRatingBody(ratingTypes.likes.toString(), true); + likeRating = new LikeRatingBody(Rating.likes, true); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); ratingsApi.likeDocument(document, likeRating); @@ -106,7 +106,7 @@ public class AddRateSanityTests extends RestTest description = "Verify admin user is able to post like rating to a document") public void adminIsAbleToLikeDocument() throws Exception { - likeRating = new LikeRatingBody(ratingTypes.likes.toString(), true); + likeRating = new LikeRatingBody(Rating.likes, true); restClient.authenticateUser(adminUser); ratingsApi.likeDocument(document, likeRating); @@ -118,7 +118,7 @@ public class AddRateSanityTests extends RestTest description = "Verify unauthenticated user is not able to post like rating to a document") public void unauthenticatedUserIsNotAbleToLikeDocument() throws Exception { - likeRating = new LikeRatingBody(ratingTypes.likes.toString(), true); + likeRating = new LikeRatingBody(Rating.likes, true); restClient.authenticateUser(new UserModel("random user", "random password")); ratingsApi.likeDocument(document, likeRating); @@ -130,7 +130,7 @@ public class AddRateSanityTests extends RestTest description = "Verify user with Manager role is able to post stars rating to a document") public void managerIsAbleToAddStarsToDocument() throws Exception { - fiveStarRating = new FiveStarRatingBody(ratingTypes.fiveStar.toString(), 5); + fiveStarRating = new FiveStarRatingBody(Rating.fiveStar, 5); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); ratingsApi.rateStarsToDocument(document, fiveStarRating); @@ -142,7 +142,7 @@ public class AddRateSanityTests extends RestTest description = "Verify user with Collaborator role is able to post stars rating to a document") public void collaboratorIsAbleToAddStarsToDocument() throws Exception { - fiveStarRating = new FiveStarRatingBody(ratingTypes.fiveStar.toString(), 5); + fiveStarRating = new FiveStarRatingBody(Rating.fiveStar, 5); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); ratingsApi.rateStarsToDocument(document, fiveStarRating); @@ -154,7 +154,7 @@ public class AddRateSanityTests extends RestTest description = "Verify user with Contributor role is able to post stars rating to a document") public void contributorIsAbleToAddStarsToDocument() throws Exception { - fiveStarRating = new FiveStarRatingBody(ratingTypes.fiveStar.toString(), 5); + fiveStarRating = new FiveStarRatingBody(Rating.fiveStar, 5); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); ratingsApi.rateStarsToDocument(document, fiveStarRating); @@ -166,7 +166,7 @@ public class AddRateSanityTests extends RestTest description = "Verify user with Consumer role is able to post stars rating to a document") public void consumerIsAbleToAddStarsToDocument() throws Exception { - fiveStarRating = new FiveStarRatingBody(ratingTypes.fiveStar.toString(), 5); + fiveStarRating = new FiveStarRatingBody(Rating.fiveStar, 5); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); ratingsApi.rateStarsToDocument(document, fiveStarRating); @@ -178,7 +178,7 @@ public class AddRateSanityTests extends RestTest description = "Verify admin user is able to post stars rating to a document") public void adminIsAbleToAddStarsToDocument() throws Exception { - fiveStarRating = new FiveStarRatingBody(ratingTypes.fiveStar.toString(), 5); + fiveStarRating = new FiveStarRatingBody(Rating.fiveStar, 5); restClient.authenticateUser(adminUser); ratingsApi.rateStarsToDocument(document, fiveStarRating); @@ -190,7 +190,7 @@ public class AddRateSanityTests extends RestTest description = "Verify unauthenticated user is not able to post stars rating to a document") public void unauthenticatedUserIsNotAbleToRateStarsToDocument() throws Exception { - fiveStarRating = new FiveStarRatingBody(ratingTypes.fiveStar.toString(), 5); + fiveStarRating = new FiveStarRatingBody(Rating.fiveStar, 5); restClient.authenticateUser(new UserModel("random user", "random password")); ratingsApi.rateStarsToDocument(document, fiveStarRating); From 46bf206d3a4bfd7a2681e9503760798c21415654 Mon Sep 17 00:00:00 2001 From: cnechifor Date: Tue, 4 Oct 2016 22:26:09 +0300 Subject: [PATCH 0246/1491] code review --- .../rest/people/GatFavoriteSitesTests.java | 34 +++++++++++++------ 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/GatFavoriteSitesTests.java b/e2e-test/java/org/alfresco/rest/people/GatFavoriteSitesTests.java index 50dc99283..8936ecd47 100644 --- a/e2e-test/java/org/alfresco/rest/people/GatFavoriteSitesTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GatFavoriteSitesTests.java @@ -36,11 +36,12 @@ public class GatFavoriteSitesTests extends RestTest public void managerUserGetsFavoriteSitesWithSuccess() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); + UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); - dataSite.usingUser(managerUser).usingSite(siteModel).addSiteToFavorites(); + dataSite.usingUser(collaboratorUser).usingSite(siteModel).addSiteToFavorites(); restClient.authenticateUser(managerUser); - peopleApi.getFavoriteSites(managerUser).assertResponseIsNotEmpty(); + peopleApi.getFavoriteSites(collaboratorUser).assertResponseIsNotEmpty(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -48,11 +49,14 @@ public class GatFavoriteSitesTests extends RestTest public void collaboratorUserGetsFavoriteSitesWithSuccess() throws Exception { UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); + UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(collaboratorUser, siteModel, UserRole.SiteCollaborator); + dataUser.usingUser(userModel).addUserToSite(contributorUser, siteModel, UserRole.SiteContributor); + dataSite.usingUser(collaboratorUser).usingSite(siteModel).addSiteToFavorites(); restClient.authenticateUser(collaboratorUser); - peopleApi.getFavoriteSites(collaboratorUser).assertResponseIsNotEmpty(); + peopleApi.getFavoriteSites(contributorUser).assertResponseIsNotEmpty(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -60,11 +64,13 @@ public class GatFavoriteSitesTests extends RestTest public void contributorUserGetsFavoriteSitesWithSuccess() throws Exception { UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); + UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(contributorUser, siteModel, UserRole.SiteContributor); - dataSite.usingUser(contributorUser).usingSite(siteModel).addSiteToFavorites(); + dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); + dataSite.usingUser(managerUser).usingSite(siteModel).addSiteToFavorites(); restClient.authenticateUser(contributorUser); - peopleApi.getFavoriteSites(contributorUser).assertResponseIsNotEmpty(); + peopleApi.getFavoriteSites(managerUser).assertResponseIsNotEmpty(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -72,11 +78,13 @@ public class GatFavoriteSitesTests extends RestTest public void consumerUserGetsFavoriteSitesWithSuccess() throws Exception { UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); + UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel, UserRole.SiteConsumer); + dataUser.usingUser(collaboratorUser).addUserToSite(collaboratorUser, siteModel, UserRole.SiteCollaborator); dataSite.usingUser(consumerUser).usingSite(siteModel).addSiteToFavorites(); restClient.authenticateUser(consumerUser); - peopleApi.getFavoriteSites(consumerUser).assertResponseIsNotEmpty(); + peopleApi.getFavoriteSites(collaboratorUser).assertResponseIsNotEmpty(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -84,10 +92,12 @@ public class GatFavoriteSitesTests extends RestTest public void adminUserGetsFavoriteSitesWithSuccess() throws Exception { UserModel adminUser = dataUser.getAdminUser(); - dataSite.usingUser(adminUser).usingSite(siteModel).addSiteToFavorites(); + UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel, UserRole.SiteConsumer); + dataSite.usingUser(consumerUser).usingSite(siteModel).addSiteToFavorites(); restClient.authenticateUser(adminUser); - peopleApi.getFavoriteSites(adminUser).assertResponseIsNotEmpty(); + peopleApi.getFavoriteSites(consumerUser).assertResponseIsNotEmpty(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -96,12 +106,16 @@ public class GatFavoriteSitesTests extends RestTest public void managerUserGetsFavoriteSitesIsNotAuthorized() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); + UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); - dataSite.usingUser(managerUser).usingSite(siteModel).addSiteToFavorites(); + dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel, UserRole.SiteConsumer); + dataSite.usingUser(consumerUser).usingSite(siteModel).addSiteToFavorites(); + managerUser.setPassword("newpassword"); restClient.authenticateUser(managerUser); - peopleApi.getFavoriteSites(managerUser); + peopleApi.getFavoriteSites(consumerUser); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } From 739b8693063c3b2e7f73eab5516db4ec14fbe7b4 Mon Sep 17 00:00:00 2001 From: cnechifor Date: Tue, 4 Oct 2016 22:50:20 +0300 Subject: [PATCH 0247/1491] code review --- .../tags/{RemoveTagSanityTests.java => DeleteTagSanityTests.java} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename e2e-test/java/org/alfresco/rest/tags/{RemoveTagSanityTests.java => DeleteTagSanityTests.java} (100%) diff --git a/e2e-test/java/org/alfresco/rest/tags/RemoveTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/DeleteTagSanityTests.java similarity index 100% rename from e2e-test/java/org/alfresco/rest/tags/RemoveTagSanityTests.java rename to e2e-test/java/org/alfresco/rest/tags/DeleteTagSanityTests.java From eaed05ce96d6275ebbc792ec64242f89be1721f1 Mon Sep 17 00:00:00 2001 From: cnechifor Date: Tue, 4 Oct 2016 22:50:33 +0300 Subject: [PATCH 0248/1491] code review --- .../rest/tags/DeleteTagSanityTests.java | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/tags/DeleteTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/DeleteTagSanityTests.java index 250cfbc08..4774f2a9b 100644 --- a/e2e-test/java/org/alfresco/rest/tags/DeleteTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/DeleteTagSanityTests.java @@ -22,7 +22,7 @@ import org.testng.annotations.Test; * Created by Claudia Agache on 10/4/2016. */ @Test(groups = { "rest-api", "tags", "sanity" }) -public class RemoveTagSanityTests extends RestTest +public class DeleteTagSanityTests extends RestTest { @Autowired private DataUser dataUser; @@ -43,20 +43,16 @@ public class RemoveTagSanityTests extends RestTest siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); - } - - @BeforeMethod(alwaysRun=true) - public void addTagToDocument() throws Exception - { - restClient.authenticateUser(adminUserModel); tagsAPI.useRestClient(restClient); - tag = tagsAPI.addTag(document, "testtag"); } @TestRail(section = { "rest-api", "tags" }, executionType = ExecutionType.SANITY, description = "Verify Admin user deletes tags with Rest API and status code is 204") public void adminIsAbleToDeleteTags() throws JsonToModelConversionException, Exception { + restClient.authenticateUser(adminUserModel); + tag = tagsAPI.addTag(document, "testtag"); + tagsAPI.deleteTag(document, tag); tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); } @@ -65,6 +61,9 @@ public class RemoveTagSanityTests extends RestTest "tags" }, executionType = ExecutionType.SANITY, description = "Verify Manager user deletes tags created by admin user with Rest API and status code is 204") public void managerIsAbleToDeleteTags() throws JsonToModelConversionException, Exception { + restClient.authenticateUser(adminUserModel); + tag = tagsAPI.addTag(document, "testtag"); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); tagsAPI.deleteTag(document, tag); tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); @@ -74,6 +73,9 @@ public class RemoveTagSanityTests extends RestTest "tags" }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user deletes tags created by admin user with Rest API and status code is 204") public void collaboratorIsAbleToDeleteTags() throws JsonToModelConversionException, Exception { + restClient.authenticateUser(adminUserModel); + tag = tagsAPI.addTag(document, "testtag"); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); tagsAPI.deleteTag(document, tag); tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); @@ -83,6 +85,9 @@ public class RemoveTagSanityTests extends RestTest "tags" }, executionType = ExecutionType.SANITY, description = "Verify Contributor user can't delete tags created by admin user with Rest API and status code is 403") public void contributorIsNotAbleToDeleteTags() throws JsonToModelConversionException, Exception { + restClient.authenticateUser(adminUserModel); + tag = tagsAPI.addTag(document, "testtag"); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); tagsAPI.deleteTag(document, tag); tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); @@ -92,6 +97,9 @@ public class RemoveTagSanityTests extends RestTest "tags" }, executionType = ExecutionType.SANITY, description = "Verify Consumer user can't delete tags created by admin user with Rest API and status code is 403") public void consumerIsNotAbleToDeleteTags() throws JsonToModelConversionException, Exception { + restClient.authenticateUser(adminUserModel); + tag = tagsAPI.addTag(document, "testtag"); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); tagsAPI.deleteTag(document, tag); tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); @@ -101,6 +109,9 @@ public class RemoveTagSanityTests extends RestTest "tags" }, executionType = ExecutionType.SANITY, description = "Verify Manager user gets status code 401 if authentication call fails") public void managerIsNotAbleToDeleteTagIfAuthenticationFails() throws JsonToModelConversionException, Exception { + restClient.authenticateUser(adminUserModel); + tag = tagsAPI.addTag(document, "testtag"); + UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); siteManager.setPassword("wrongPassword"); restClient.authenticateUser(siteManager); From 8350cc8c78dc7980eecd974b2b2b8eed9df8fcaa Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 5 Oct 2016 11:35:19 +0300 Subject: [PATCH 0249/1491] added scenario for delete tag by contributor to his created content --- .../rest/tags/DeleteTagSanityTests.java | 31 +++++++++++++------ 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/tags/DeleteTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/DeleteTagSanityTests.java index 4774f2a9b..6887082f6 100644 --- a/e2e-test/java/org/alfresco/rest/tags/DeleteTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/DeleteTagSanityTests.java @@ -7,6 +7,7 @@ import org.alfresco.rest.model.RestTagModel; import org.alfresco.rest.requests.RestTagsApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.data.RandomData; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; @@ -30,11 +31,11 @@ public class DeleteTagSanityTests extends RestTest @Autowired private RestTagsApi tagsAPI; - private UserModel adminUserModel; + private UserModel adminUserModel, userModel; private SiteModel siteModel; private DataUser.ListUserWithRoles usersWithRoles; private RestTagModel tag; - private FileModel document; + private FileModel document, contributorDoc; @BeforeClass(alwaysRun=true) public void dataPreparation() throws Exception @@ -52,7 +53,7 @@ public class DeleteTagSanityTests extends RestTest { restClient.authenticateUser(adminUserModel); tag = tagsAPI.addTag(document, "testtag"); - + tagsAPI.deleteTag(document, tag); tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); } @@ -63,7 +64,7 @@ public class DeleteTagSanityTests extends RestTest { restClient.authenticateUser(adminUserModel); tag = tagsAPI.addTag(document, "testtag"); - + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); tagsAPI.deleteTag(document, tag); tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); @@ -75,7 +76,7 @@ public class DeleteTagSanityTests extends RestTest { restClient.authenticateUser(adminUserModel); tag = tagsAPI.addTag(document, "testtag"); - + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); tagsAPI.deleteTag(document, tag); tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); @@ -83,23 +84,35 @@ public class DeleteTagSanityTests extends RestTest @TestRail(section = { "rest-api", "tags" }, executionType = ExecutionType.SANITY, description = "Verify Contributor user can't delete tags created by admin user with Rest API and status code is 403") - public void contributorIsNotAbleToDeleteTags() throws JsonToModelConversionException, Exception + public void contributorIsNotAbleToDeleteTagsForAnotherUserContent() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); tag = tagsAPI.addTag(document, "testtag"); - + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); tagsAPI.deleteTag(document, tag); tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } + @TestRail(section = { "rest-api", + "tags" }, executionType = ExecutionType.SANITY, description = "Verify Contributor user deletes tags created by him with Rest API and status code is 204") + public void contributorIsAbleToDeleteTagsForHisContent() throws JsonToModelConversionException, Exception + { + userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); + restClient.authenticateUser(userModel); + contributorDoc = dataContent.usingSite(siteModel).usingUser(userModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);; + tag = tagsAPI.addTag(contributorDoc, "contributortag"); + tagsAPI.deleteTag(document, tag); + tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + @TestRail(section = { "rest-api", "tags" }, executionType = ExecutionType.SANITY, description = "Verify Consumer user can't delete tags created by admin user with Rest API and status code is 403") public void consumerIsNotAbleToDeleteTags() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); tag = tagsAPI.addTag(document, "testtag"); - + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); tagsAPI.deleteTag(document, tag); tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); @@ -111,7 +124,7 @@ public class DeleteTagSanityTests extends RestTest { restClient.authenticateUser(adminUserModel); tag = tagsAPI.addTag(document, "testtag"); - + UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); siteManager.setPassword("wrongPassword"); restClient.authenticateUser(siteManager); From d9857c420f1fb78e7c4a7e64e04242bd6c4fbc55 Mon Sep 17 00:00:00 2001 From: cnechifor Date: Wed, 5 Oct 2016 13:29:30 +0300 Subject: [PATCH 0250/1491] added getTag tests --- ...sTests.java => GetFavoriteSitesTests.java} | 2 +- .../alfresco/rest/tags/GetTagSanityTests.java | 127 ++++++++++++++++++ 2 files changed, 128 insertions(+), 1 deletion(-) rename e2e-test/java/org/alfresco/rest/people/{GatFavoriteSitesTests.java => GetFavoriteSitesTests.java} (99%) create mode 100644 e2e-test/java/org/alfresco/rest/tags/GetTagSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/people/GatFavoriteSitesTests.java b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/people/GatFavoriteSitesTests.java rename to e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesTests.java index 8936ecd47..efc1319b7 100644 --- a/e2e-test/java/org/alfresco/rest/people/GatFavoriteSitesTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesTests.java @@ -14,7 +14,7 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @Test(groups = { "rest-api", "people", "sanity" }) -public class GatFavoriteSitesTests extends RestTest +public class GetFavoriteSitesTests extends RestTest { @Autowired RestPeopleApi peopleApi; diff --git a/e2e-test/java/org/alfresco/rest/tags/GetTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagSanityTests.java new file mode 100644 index 000000000..195ccb8a1 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/tags/GetTagSanityTests.java @@ -0,0 +1,127 @@ +package org.alfresco.rest.tags; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestTagModel; +import org.alfresco.rest.requests.RestTagsApi; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.data.RandomData; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.log.LogsListener; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Listeners; +import org.testng.annotations.Test; + +@Test(groups = { "rest-api", "tags", "sanity" }) +@Listeners(LogsListener.class) +public class GetTagSanityTests extends RestTest +{ + + @Autowired + private DataUser dataUser; + + @Autowired + private RestTagsApi tagsAPI; + + private UserModel adminUserModel; + private SiteModel siteModel; + private ListUserWithRoles usersWithRoles; + private FileModel document; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + restClient.authenticateUser(adminUserModel); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + tagsAPI.useRestClient(restClient); + } + + + @TestRail(section = { "rest-api", "tags" }, executionType = ExecutionType.SANITY, description = "Verify admin user gets tag using REST API and status code is OK (200)") + public void userWithAdminIsAbletoGetTag() throws JsonToModelConversionException, Exception + { + String tagValue = RandomData.getRandomName("tag"); + restClient.authenticateUser(adminUserModel); + RestTagModel tag = tagsAPI.addTag(document, tagValue); + + tagsAPI.getTag(tag).assertTagIs(tagValue.toLowerCase()); + tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } + + + @TestRail(section = { "rest-api", "tags" }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role gets tag using REST API and status code is OK (200)") + public void userWithManagerRoleIsAbletoGetTag() throws JsonToModelConversionException, Exception + { + String tagValue = RandomData.getRandomName("tag"); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + RestTagModel tag = tagsAPI.addTag(document, tagValue); + + tagsAPI.getTag(tag).assertTagIs(tagValue.toLowerCase()); + tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { "rest-api", "tags" }, executionType = ExecutionType.SANITY, description = "Verify user with Collaborator role gets tag using REST API and status code is OK (200)") + public void userWithCollaboratorRoleIsAbletoGetTag() throws JsonToModelConversionException, Exception + { + String tagValue = RandomData.getRandomName("tag"); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + RestTagModel tag = tagsAPI.addTag(document, tagValue); + + tagsAPI.getTag(tag).assertTagIs(tagValue.toLowerCase()); + tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { "rest-api", "tags" }, executionType = ExecutionType.SANITY, description = "Verify user with Contributor role gets tag using REST API and status code is OK (200)") + public void userWithContributorRoleIsAbletoGetTag() throws JsonToModelConversionException, Exception + { + String tagValue = RandomData.getRandomName("tag"); + restClient.authenticateUser(adminUserModel); + RestTagModel tag = tagsAPI.addTag(document, tagValue); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + tagsAPI.getTag(tag).assertTagIs(tagValue.toLowerCase()); + tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } + + + @TestRail(section = { "rest-api", "tags" }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role gets tag using REST API and status code is OK (200)") + public void userWithConsumerRoleIsAbletoGetTag() throws JsonToModelConversionException, Exception + { + String tagValue = RandomData.getRandomName("tag"); + restClient.authenticateUser(adminUserModel); + RestTagModel tag = tagsAPI.addTag(document, tagValue); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + tagsAPI.getTag(tag).assertTagIs(tagValue.toLowerCase()); + tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { "rest-api", "tags" }, executionType = ExecutionType.SANITY, description = "Verify Manager user gets status code 401 if authentication call fails") + public void managerIsNotAbleToGetTagIfAuthenticationFails() throws JsonToModelConversionException, Exception + { + String tagValue = RandomData.getRandomName("tag"); + UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.addUserToSite(managerUser, siteModel, UserRole.SiteManager); + restClient.authenticateUser(managerUser); + RestTagModel tag = tagsAPI.addTag(document, tagValue); + + managerUser.setPassword("wrongPassword"); + restClient.authenticateUser(managerUser); + tagsAPI.getTag(tag); + tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + } + +} \ No newline at end of file From 024c481657937200a792ca277355f382380e5013 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Wed, 5 Oct 2016 13:42:27 +0300 Subject: [PATCH 0251/1491] TAS-1141 deleteFavoriteSite call test with Manager role --- .../people/DeleteFavoriteSiteSanityTests.java | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java new file mode 100644 index 000000000..b374c3a51 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java @@ -0,0 +1,53 @@ +package org.alfresco.rest.people; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.requests.RestPeopleApi; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * + * @author Cristina Axinte + * + */ +@Test(groups = { "rest-api", "people", "sanity" }) +public class DeleteFavoriteSiteSanityTests extends RestTest +{ + @Autowired + RestPeopleApi peopleApi; + + UserModel userModel; + SiteModel siteModel1; + SiteModel siteModel2; + UserModel searchedUser; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + siteModel1 = dataSite.usingUser(userModel).createPublicRandomSite(); + siteModel2 = dataSite.usingUser(userModel).createPublicRandomSite(); + + peopleApi.useRestClient(restClient); + } + + @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify manager user removes a site from its favorite sites list with Rest API and response is successful (204)") + public void managerUserRemovesFavoriteSiteWithSuccess() throws Exception + { + UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel1, UserRole.SiteManager); + dataSite.usingUser(managerUser).usingSite(siteModel1).addSiteToFavorites(); + dataSite.usingUser(managerUser).usingSite(siteModel2).addSiteToFavorites(); + + restClient.authenticateUser(managerUser); + peopleApi.removeFavoriteSite(managerUser,siteModel1); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); + } +} From 1f0e1965edb285afc9ebcb422b100bb8388ae505 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Wed, 5 Oct 2016 13:45:57 +0300 Subject: [PATCH 0252/1491] TAS-1142 deleteFavoriteSite call test with Collaborator role --- .../people/DeleteFavoriteSiteSanityTests.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java index b374c3a51..69893d63a 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java @@ -37,7 +37,7 @@ public class DeleteFavoriteSiteSanityTests extends RestTest peopleApi.useRestClient(restClient); } - + @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify manager user removes a site from its favorite sites list with Rest API and response is successful (204)") public void managerUserRemovesFavoriteSiteWithSuccess() throws Exception { @@ -50,4 +50,17 @@ public class DeleteFavoriteSiteSanityTests extends RestTest peopleApi.removeFavoriteSite(managerUser,siteModel1); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); } + + @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify collaborator user removes a site from its favorite sites list with Rest API and response is successful (204)") + public void collaboratorUserRemovesFavoriteSiteWithSuccess() throws Exception + { + UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(collaboratorUser, siteModel1, UserRole.SiteCollaborator); + dataSite.usingUser(collaboratorUser).usingSite(siteModel1).addSiteToFavorites(); + dataSite.usingUser(collaboratorUser).usingSite(siteModel2).addSiteToFavorites(); + + restClient.authenticateUser(collaboratorUser); + peopleApi.removeFavoriteSite(collaboratorUser,siteModel1); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); + } } From b8c03ea93bd0b78cc350e2a23db1bca8c74de17d Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 5 Oct 2016 16:14:03 +0300 Subject: [PATCH 0253/1491] TAS-1110 - update tag with manager role --- .../rest/tags/UpdateTagSanityTests.java | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java new file mode 100644 index 000000000..4c87ec215 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java @@ -0,0 +1,69 @@ +package org.alfresco.rest.tags; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.body.Tag; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestTagModel; +import org.alfresco.rest.requests.RestTagsApi; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.data.RandomData; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +/** + * Created by Claudia Agache on 10/4/2016. + */ +@Test(groups = { "rest-api", "tags", "sanity" }) +public class UpdateTagSanityTests extends RestTest +{ + @Autowired RestTagsApi tagsAPI; + + @Autowired DataUser dataUser; + + private UserModel adminUserModel; + private FileModel document; + private SiteModel siteModel; + private RestTagModel oldTag; + private DataUser.ListUserWithRoles usersWithRoles; + private Tag newTag; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + } + + @BeforeMethod(alwaysRun=true) + public void addTagToDocument() throws Exception + { + restClient.authenticateUser(adminUserModel); + tagsAPI.useRestClient(restClient); + oldTag = tagsAPI.addTag(document, RandomData.getRandomName("old")); + newTag = new Tag(RandomData.getRandomName("tag")); + } + + + @TestRail(section = { "rest-api", + "tags" }, executionType = ExecutionType.SANITY, description = "Verify Manager user can't update tags with Rest API and status code is 403") + public void managerIsNotAbleToUpdateTag() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + tagsAPI.updateTag(oldTag, newTag); + tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + } + +} From 2ab2a07936eece05e91ac22cf06032610dc1c83d Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 5 Oct 2016 16:14:49 +0300 Subject: [PATCH 0254/1491] TAS-1114 - update tag with admin --- .../java/org/alfresco/rest/tags/UpdateTagSanityTests.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java index 4c87ec215..1aed39596 100644 --- a/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java @@ -56,6 +56,13 @@ public class UpdateTagSanityTests extends RestTest newTag = new Tag(RandomData.getRandomName("tag")); } + @TestRail(section = { "rest-api", + "tags" }, executionType = ExecutionType.SANITY, description = "Verify Admin user updates tags and status code is 200") + public void adminIsAbleToUpdateTags() throws JsonToModelConversionException, Exception + { + tagsAPI.updateTag(oldTag, newTag).assertTagIs(newTag.getTag()); + tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } @TestRail(section = { "rest-api", "tags" }, executionType = ExecutionType.SANITY, description = "Verify Manager user can't update tags with Rest API and status code is 403") From 08cbc408fa089471e210bfb0bc225f7facc3fe85 Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 5 Oct 2016 16:16:09 +0300 Subject: [PATCH 0255/1491] TAS-1111 - update tag with collaborator role --- .../org/alfresco/rest/tags/UpdateTagSanityTests.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java index 1aed39596..6bd1b495d 100644 --- a/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java @@ -73,4 +73,14 @@ public class UpdateTagSanityTests extends RestTest tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } + @TestRail(section = { "rest-api", + "tags" }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user can't update tags with Rest API and status code is 403") + public void collaboratorIsNotAbleToUpdateTag() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + tagsAPI.updateTag(oldTag, newTag); + tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + } + + } From 20a70d7053709113148313aae54d1bbabcac7bf7 Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 5 Oct 2016 16:16:55 +0300 Subject: [PATCH 0256/1491] TAS-1112 - update tag with contributor role --- .../org/alfresco/rest/tags/UpdateTagSanityTests.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java index 6bd1b495d..de7a81613 100644 --- a/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java @@ -82,5 +82,14 @@ public class UpdateTagSanityTests extends RestTest tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } + @TestRail(section = { "rest-api", + "tags" }, executionType = ExecutionType.SANITY, description = "Verify Contributor user can't update tags with Rest API and status code is 403") + public void contributorIsNotAbleToUpdateTag() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + tagsAPI.updateTag(oldTag, newTag); + tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + } + } From 835e630643658d7b73c986351a147a2778765037 Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 5 Oct 2016 16:17:40 +0300 Subject: [PATCH 0257/1491] TAS-1113 - update tag with consumer role --- .../org/alfresco/rest/tags/UpdateTagSanityTests.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java index de7a81613..40c74e248 100644 --- a/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java @@ -90,6 +90,16 @@ public class UpdateTagSanityTests extends RestTest tagsAPI.updateTag(oldTag, newTag); tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } + + @TestRail(section = { "rest-api", + "tags" }, executionType = ExecutionType.SANITY, description = "Verify Consumer user can't update tags with Rest API and status code is 403") + public void consumerIsNotAbleToUpdateTag() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + tagsAPI.updateTag(oldTag, newTag); + tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + } + } From 4b3faa7f50ff16f1478bb734c2b0cab2df18a245 Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 5 Oct 2016 16:20:42 +0300 Subject: [PATCH 0258/1491] TAS-1115 - update tag with unauthorized user --- .../alfresco/rest/tags/UpdateTagSanityTests.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java index 40c74e248..406180532 100644 --- a/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java @@ -90,7 +90,7 @@ public class UpdateTagSanityTests extends RestTest tagsAPI.updateTag(oldTag, newTag); tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } - + @TestRail(section = { "rest-api", "tags" }, executionType = ExecutionType.SANITY, description = "Verify Consumer user can't update tags with Rest API and status code is 403") public void consumerIsNotAbleToUpdateTag() throws JsonToModelConversionException, Exception @@ -100,6 +100,15 @@ public class UpdateTagSanityTests extends RestTest tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } - + @TestRail(section = { "rest-api", + "tags" }, executionType = ExecutionType.SANITY, description = "Verify Manager user gets status code 401 if authentication call fails") + public void managerIsNotAbleToUpdateTagIfAuthenticationFails() throws JsonToModelConversionException, Exception + { + UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); + siteManager.setPassword("wrongPassword"); + restClient.authenticateUser(siteManager); + tagsAPI.updateTag(oldTag, newTag); + tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + } } From 5778622a3df29c5d749dad0bd177ef6d47a51655 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Wed, 5 Oct 2016 16:30:29 +0300 Subject: [PATCH 0259/1491] TAS-1143 deleteFavoriteSite call test with Contributor role --- .../rest/people/DeleteFavoriteSiteSanityTests.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java index 69893d63a..30ab17bcc 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java @@ -63,4 +63,17 @@ public class DeleteFavoriteSiteSanityTests extends RestTest peopleApi.removeFavoriteSite(collaboratorUser,siteModel1); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); } + + @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify contributor user removes a site from its favorite sites list with Rest API and response is successful (204)") + public void contributorUserRemovesFavoriteSiteWithSuccess() throws Exception + { + UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(contributorUser, siteModel1, UserRole.SiteContributor); + dataSite.usingUser(contributorUser).usingSite(siteModel1).addSiteToFavorites(); + dataSite.usingUser(contributorUser).usingSite(siteModel2).addSiteToFavorites(); + + restClient.authenticateUser(contributorUser); + peopleApi.removeFavoriteSite(contributorUser,siteModel1); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); + } } From c263289aaaa4c09b810f906841ac8af5b68aead2 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Wed, 5 Oct 2016 16:32:54 +0300 Subject: [PATCH 0260/1491] TAS-1144 deleteFavoriteSite call test with Consumer role --- .../people/DeleteFavoriteSiteSanityTests.java | 29 +++++++++++++------ 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java index 30ab17bcc..25fcd2736 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java @@ -13,9 +13,7 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; /** - * * @author Cristina Axinte - * */ @Test(groups = { "rest-api", "people", "sanity" }) public class DeleteFavoriteSiteSanityTests extends RestTest @@ -28,7 +26,7 @@ public class DeleteFavoriteSiteSanityTests extends RestTest SiteModel siteModel2; UserModel searchedUser; - @BeforeClass(alwaysRun=true) + @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception { userModel = dataUser.createRandomTestUser(); @@ -37,7 +35,7 @@ public class DeleteFavoriteSiteSanityTests extends RestTest peopleApi.useRestClient(restClient); } - + @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify manager user removes a site from its favorite sites list with Rest API and response is successful (204)") public void managerUserRemovesFavoriteSiteWithSuccess() throws Exception { @@ -47,10 +45,10 @@ public class DeleteFavoriteSiteSanityTests extends RestTest dataSite.usingUser(managerUser).usingSite(siteModel2).addSiteToFavorites(); restClient.authenticateUser(managerUser); - peopleApi.removeFavoriteSite(managerUser,siteModel1); + peopleApi.removeFavoriteSite(managerUser, siteModel1); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); } - + @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify collaborator user removes a site from its favorite sites list with Rest API and response is successful (204)") public void collaboratorUserRemovesFavoriteSiteWithSuccess() throws Exception { @@ -60,10 +58,10 @@ public class DeleteFavoriteSiteSanityTests extends RestTest dataSite.usingUser(collaboratorUser).usingSite(siteModel2).addSiteToFavorites(); restClient.authenticateUser(collaboratorUser); - peopleApi.removeFavoriteSite(collaboratorUser,siteModel1); + peopleApi.removeFavoriteSite(collaboratorUser, siteModel1); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); } - + @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify contributor user removes a site from its favorite sites list with Rest API and response is successful (204)") public void contributorUserRemovesFavoriteSiteWithSuccess() throws Exception { @@ -73,7 +71,20 @@ public class DeleteFavoriteSiteSanityTests extends RestTest dataSite.usingUser(contributorUser).usingSite(siteModel2).addSiteToFavorites(); restClient.authenticateUser(contributorUser); - peopleApi.removeFavoriteSite(contributorUser,siteModel1); + peopleApi.removeFavoriteSite(contributorUser, siteModel1); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify consumer user removes a site from its favorite sites list with Rest API and response is successful (204)") + public void consumerUserRemovesFavoriteSiteWithSuccess() throws Exception + { + UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel1, UserRole.SiteConsumer); + dataSite.usingUser(consumerUser).usingSite(siteModel1).addSiteToFavorites(); + dataSite.usingUser(consumerUser).usingSite(siteModel2).addSiteToFavorites(); + + restClient.authenticateUser(consumerUser); + peopleApi.removeFavoriteSite(consumerUser, siteModel1); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); } } From 17146d2640d46c19bc849a06ea4d3f8fe74acae9 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Wed, 5 Oct 2016 16:59:01 +0300 Subject: [PATCH 0261/1491] TAS-1145 deleteFavoriteSite call test with admin user --- .../rest/people/DeleteFavoriteSiteSanityTests.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java index 25fcd2736..0048729b9 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java @@ -87,4 +87,17 @@ public class DeleteFavoriteSiteSanityTests extends RestTest peopleApi.removeFavoriteSite(consumerUser, siteModel1); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); } + + @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify admin user removes a site from any user's favorite sites list with Rest API and response is successful (204)") + public void adminUserRemovesAnyFavoriteSiteWithSuccess() throws Exception + { + UserModel adminUser = dataUser.getAdminUser(); + UserModel anyUser = dataUser.usingAdmin().createRandomTestUser(); + dataSite.usingUser(anyUser).usingSite(siteModel1).addSiteToFavorites(); + dataSite.usingUser(anyUser).usingSite(siteModel2).addSiteToFavorites(); + + restClient.authenticateUser(adminUser); + peopleApi.removeFavoriteSite(anyUser, siteModel1); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); + } } From 87202a1a630369d6e480b9c1a60079ce4c9aa75c Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Wed, 5 Oct 2016 17:14:55 +0300 Subject: [PATCH 0262/1491] TAS-1146 deleteFavoriteSite failed call test with Manager role --- .../people/DeleteFavoriteSiteSanityTests.java | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java index 0048729b9..a707f4e3b 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java @@ -87,7 +87,7 @@ public class DeleteFavoriteSiteSanityTests extends RestTest peopleApi.removeFavoriteSite(consumerUser, siteModel1); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); } - + @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify admin user removes a site from any user's favorite sites list with Rest API and response is successful (204)") public void adminUserRemovesAnyFavoriteSiteWithSuccess() throws Exception { @@ -100,4 +100,31 @@ public class DeleteFavoriteSiteSanityTests extends RestTest peopleApi.removeFavoriteSite(anyUser, siteModel1); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); } + + @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify a user removes a site from another user's favorite sites list with Rest API and response is permission denied (403)") + public void userUserRemovesAnotherUserFavoriteSiteWithSuccess() throws Exception + { + UserModel userAuth = dataUser.usingAdmin().createRandomTestUser(); + UserModel anotherUser = dataUser.usingAdmin().createRandomTestUser(); + dataSite.usingUser(anotherUser).usingSite(siteModel1).addSiteToFavorites(); + dataSite.usingUser(anotherUser).usingSite(siteModel2).addSiteToFavorites(); + + restClient.authenticateUser(userAuth); + peopleApi.removeFavoriteSite(anotherUser, siteModel1); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + } + + @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized to remove a site from its favorite sites list with Rest API when authentication fails (401)") + public void managerUserNotAuthorizedFailsToRemoveFavoriteSite() throws Exception + { + UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel1, UserRole.SiteManager); + dataSite.usingUser(managerUser).usingSite(siteModel1).addSiteToFavorites(); + dataSite.usingUser(managerUser).usingSite(siteModel2).addSiteToFavorites(); + managerUser.setPassword("newpassword"); + + restClient.authenticateUser(managerUser); + peopleApi.removeFavoriteSite(managerUser, siteModel1); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + } } From 0052b0bc7a125b1177ac6f963a1442a1842907b1 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Wed, 5 Oct 2016 17:17:42 +0300 Subject: [PATCH 0263/1491] TAS-1159 getFavoritesSites with admin --- .../favorites/GetFavoritesSanityTests.java | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java new file mode 100644 index 000000000..968b7415b --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java @@ -0,0 +1,60 @@ +package org.alfresco.rest.favorites; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.requests.RestFavoritesApi; +import org.alfresco.rest.requests.RestSitesApi; +import org.alfresco.utility.constants.SpecificParametersForFavorites; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +@Test(groups = { "rest-api", "favorites", "sanity" }) +public class GetFavoritesSanityTests extends RestTest +{ + + @Autowired + RestFavoritesApi favoritesAPI; + + @Autowired + RestSitesApi sitesApi; + + private UserModel adminUserModel; + private SiteModel firstSiteModel; + private SiteModel secondSiteModel; + private ListUserWithRoles usersWithRoles; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + restClient.authenticateUser(adminUserModel); + firstSiteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + secondSiteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + + favoritesAPI.useRestClient(restClient); + sitesApi.useRestClient(restClient); + firstSiteModel.setGuid(sitesApi.getSite(firstSiteModel).getGuid()); + secondSiteModel.setGuid(sitesApi.getSite(secondSiteModel).getGuid()); + + usersWithRoles = dataUser.addUsersWithRolesToSite(firstSiteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + } + + @TestRail(section = { "rest-api", + "favorites" }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets favorites sites with Rest API and status code is 200") + public void adminIsAbleToRetrieveFavoritesSites() throws JsonToModelConversionException, Exception + { + favoritesAPI.addUserFavorites(adminUserModel, firstSiteModel); + favoritesAPI.addUserFavorites(adminUserModel, secondSiteModel); + favoritesAPI.getUserFavorites(adminUserModel, SpecificParametersForFavorites.SITE.toString()); + favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } +} From 73ef8de63dd19521d075cca933b64b1c91e86b28 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Wed, 5 Oct 2016 17:20:33 +0300 Subject: [PATCH 0264/1491] TAS-1160 getFoldersFavorites with admin --- .../favorites/GetFavoritesSanityTests.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java index 968b7415b..00316d82c 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java @@ -1,5 +1,6 @@ package org.alfresco.rest.favorites; +import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.requests.RestFavoritesApi; @@ -7,6 +8,8 @@ import org.alfresco.rest.requests.RestSitesApi; import org.alfresco.utility.constants.SpecificParametersForFavorites; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; @@ -29,6 +32,10 @@ public class GetFavoritesSanityTests extends RestTest private UserModel adminUserModel; private SiteModel firstSiteModel; private SiteModel secondSiteModel; + private FileModel firstFileModel; + private FileModel secondFileModel; + private FolderModel firstFolderModel; + private FolderModel secondFolderModel; private ListUserWithRoles usersWithRoles; @BeforeClass(alwaysRun = true) @@ -38,6 +45,10 @@ public class GetFavoritesSanityTests extends RestTest restClient.authenticateUser(adminUserModel); firstSiteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); secondSiteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + firstFolderModel = dataContent.usingUser(adminUserModel).usingSite(firstSiteModel).createFolder(); + secondFolderModel = dataContent.usingUser(adminUserModel).usingSite(firstSiteModel).createFolder(); + firstFileModel = dataContent.usingUser(adminUserModel).usingResource(firstFolderModel).createContent(DocumentType.TEXT_PLAIN); + secondFileModel = dataContent.usingUser(adminUserModel).usingResource(firstFolderModel).createContent(DocumentType.TEXT_PLAIN); favoritesAPI.useRestClient(restClient); sitesApi.useRestClient(restClient); @@ -57,4 +68,14 @@ public class GetFavoritesSanityTests extends RestTest favoritesAPI.getUserFavorites(adminUserModel, SpecificParametersForFavorites.SITE.toString()); favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + @TestRail(section = { "rest-api", + "favorites" }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets favorites folders with Rest API and status code is 200") + public void adminIsAbleToRetrieveFavoritesFolders() throws JsonToModelConversionException, Exception + { + favoritesAPI.addUserFavorites(adminUserModel, firstFolderModel); + favoritesAPI.addUserFavorites(adminUserModel, secondFolderModel); + favoritesAPI.getUserFavorites(adminUserModel, SpecificParametersForFavorites.FOLDER.toString()); + favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } } From 4e8d4a24ea19a9c45c1f6837d3aa176f29fbd2c1 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Wed, 5 Oct 2016 17:22:19 +0300 Subject: [PATCH 0265/1491] TAS-1161 getFavoritesFiles with admin --- .../rest/favorites/GetFavoritesSanityTests.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java index 00316d82c..427b1bddb 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java @@ -78,4 +78,14 @@ public class GetFavoritesSanityTests extends RestTest favoritesAPI.getUserFavorites(adminUserModel, SpecificParametersForFavorites.FOLDER.toString()); favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + @TestRail(section = { "rest-api", + "favorites" }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets favorites files with Rest API and status code is 200") + public void adminIsAbleToRetrieveFavoritesFiles() throws JsonToModelConversionException, Exception + { + favoritesAPI.addUserFavorites(adminUserModel, firstFileModel); + favoritesAPI.addUserFavorites(adminUserModel, secondFileModel); + favoritesAPI.getUserFavorites(adminUserModel, SpecificParametersForFavorites.FILE.toString()); + favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } } From 6619df6024cda8ef160af1baed0fc0429b53b6f8 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Wed, 5 Oct 2016 17:23:49 +0300 Subject: [PATCH 0266/1491] TAS-977 getFavoritesSites with manager --- .../rest/favorites/GetFavoritesSanityTests.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java index 427b1bddb..88cb9a5fb 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java @@ -88,4 +88,15 @@ public class GetFavoritesSanityTests extends RestTest favoritesAPI.getUserFavorites(adminUserModel, SpecificParametersForFavorites.FILE.toString()); favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + @TestRail(section = { "rest-api", + "favorites" }, executionType = ExecutionType.SANITY, description = "Verify Manager user gets favorites with Rest API and status code is 200") + public void managerIsAbleToRetrieveFavorites() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + favoritesAPI.addUserFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteManager), firstSiteModel); + favoritesAPI.addUserFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteManager), secondSiteModel); + favoritesAPI.getUserFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteManager), SpecificParametersForFavorites.SITE.toString()); + favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } } From 74a784ee8f64a9069cc430cb85309964bce71d2a Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Wed, 5 Oct 2016 17:25:36 +0300 Subject: [PATCH 0267/1491] TAS-1162 getFavoritesSites with collaborator --- .../rest/favorites/GetFavoritesSanityTests.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java index 88cb9a5fb..375f3c014 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java @@ -99,4 +99,15 @@ public class GetFavoritesSanityTests extends RestTest favoritesAPI.getUserFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteManager), SpecificParametersForFavorites.SITE.toString()); favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + @TestRail(section = { "rest-api", + "favorites" }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user gets favorites with Rest API and status code is 200") + public void collaboratorIsAbleToRetrieveFavorites() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + favoritesAPI.addUserFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), firstSiteModel); + favoritesAPI.addUserFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), secondSiteModel); + favoritesAPI.getUserFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), SpecificParametersForFavorites.SITE.toString()); + favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } } From b02aa138a7e7ea2043386ac0ab6affc6514e6d96 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Wed, 5 Oct 2016 17:28:12 +0300 Subject: [PATCH 0268/1491] TAS-1164 getFavoritesSites with contributor --- .../rest/favorites/GetFavoritesSanityTests.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java index 375f3c014..b53d38674 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java @@ -110,4 +110,15 @@ public class GetFavoritesSanityTests extends RestTest favoritesAPI.getUserFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), SpecificParametersForFavorites.SITE.toString()); favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + @TestRail(section = { "rest-api", + "favorites" }, executionType = ExecutionType.SANITY, description = "Verify Contributor user gets favorites with Rest API and status code is 200") + public void contributorIsAbleToRetrieveFavorites() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + favoritesAPI.addUserFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor), firstSiteModel); + favoritesAPI.addUserFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor), secondSiteModel); + favoritesAPI.getUserFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor), SpecificParametersForFavorites.SITE.toString()); + favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } } From bf418cb0a4433e5d738150662cc9b9dbc9c06048 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Wed, 5 Oct 2016 17:29:06 +0300 Subject: [PATCH 0269/1491] TAS-1166 getFavoritesSites with consumer --- .../rest/favorites/GetFavoritesSanityTests.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java index b53d38674..aaff8fe43 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java @@ -121,4 +121,15 @@ public class GetFavoritesSanityTests extends RestTest favoritesAPI.getUserFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor), SpecificParametersForFavorites.SITE.toString()); favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + @TestRail(section = { "rest-api", + "favorites" }, executionType = ExecutionType.SANITY, description = "Verify Consumer user gets favorites with Rest API and status code is 200") + public void consumerIsAbleToRetrieveFavorites() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + favoritesAPI.addUserFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer), firstSiteModel); + favoritesAPI.addUserFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer), secondSiteModel); + favoritesAPI.getUserFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer), SpecificParametersForFavorites.SITE.toString()); + favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } } From 4af5b824592d04544b03e879257b014e3f37c0a1 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Wed, 5 Oct 2016 17:35:49 +0300 Subject: [PATCH 0270/1491] TAS-1171 getFavoritesSites of an user with another user --- .../alfresco/rest/favorites/GetFavoritesSanityTests.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java index aaff8fe43..6a88db420 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java @@ -132,4 +132,13 @@ public class GetFavoritesSanityTests extends RestTest favoritesAPI.getUserFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer), SpecificParametersForFavorites.SITE.toString()); favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + @TestRail(section = { "rest-api", + "favorites" }, executionType = ExecutionType.SANITY, description = "Verify user doesn't have permission to get favorites of another user with Rest API and status code is 404") + public void userIsNotAbleToRetrieveFavoritesOfAnotherUser() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + favoritesAPI.getUserFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), SpecificParametersForFavorites.SITE.toString()); + favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); + } } From 5c60bc1eefd8a1cfd0f695570672a289ea3d06b3 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Wed, 5 Oct 2016 17:37:51 +0300 Subject: [PATCH 0271/1491] TAS-1172 getFavoritesSites of admin with another user --- .../alfresco/rest/favorites/GetFavoritesSanityTests.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java index 6a88db420..817c6ab12 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java @@ -141,4 +141,13 @@ public class GetFavoritesSanityTests extends RestTest favoritesAPI.getUserFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), SpecificParametersForFavorites.SITE.toString()); favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); } + + @TestRail(section = { "rest-api", + "favorites" }, executionType = ExecutionType.SANITY, description = "Verify user doesn't have permission to get favorites of admin user with Rest API and status code is 200") + public void userIsNotAbleToRetrieveFavoritesOfAdminUser() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + favoritesAPI.getUserFavorites(adminUserModel, SpecificParametersForFavorites.SITE.toString()); + favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); + } } From 133732fd483d05f355950b4158dd1f947cf70aac Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Wed, 5 Oct 2016 17:39:33 +0300 Subject: [PATCH 0272/1491] TAS-1173 getFavoritesSites of user with admin --- .../alfresco/rest/favorites/GetFavoritesSanityTests.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java index 817c6ab12..bfce96a7f 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java @@ -150,4 +150,13 @@ public class GetFavoritesSanityTests extends RestTest favoritesAPI.getUserFavorites(adminUserModel, SpecificParametersForFavorites.SITE.toString()); favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); } + + @TestRail(section = { "rest-api", + "favorites" }, executionType = ExecutionType.SANITY, description = "Verify admin user doesn't have permission to get favorites of another user with Rest API and status code is 200") + public void adminIsNotAbleToRetrieveFavoritesOfAnotherUser() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel); + favoritesAPI.getUserFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), SpecificParametersForFavorites.SITE.toString()); + favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); + } } From a1efb562cd73bb138f9e8817840ab26077396283 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Wed, 5 Oct 2016 17:41:35 +0300 Subject: [PATCH 0273/1491] TAS-1174 if authentication fails status code is 401 --- .../rest/favorites/GetFavoritesSanityTests.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java index bfce96a7f..47ff9a6df 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java @@ -159,4 +159,16 @@ public class GetFavoritesSanityTests extends RestTest favoritesAPI.getUserFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), SpecificParametersForFavorites.SITE.toString()); favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); } + + @TestRail(section = { "rest-api", + "favorites" }, executionType = ExecutionType.SANITY, description = "Verify user gets status code 401 if authentication call fails") + public void userIsNotAbleToRetrieveFavoritesIfAuthenticationFails() throws JsonToModelConversionException, Exception + { + UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); + siteManager.setPassword("wrongPassword"); + restClient.authenticateUser(siteManager); + favoritesAPI.addUserFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteManager), firstSiteModel); + favoritesAPI.addUserFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteManager), secondSiteModel); + favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + } } From 9e2da8e9591fe4d7d4659bce79a6261cefa78648 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Wed, 5 Oct 2016 18:09:56 +0300 Subject: [PATCH 0274/1491] TAS-1090 REST API - valid request returns success status code 200 with Manager role --- ...tyTests.java => AddRatingSanityTests.java} | 2 +- .../rest/ratings/GetRatingSanityTests.java | 76 +++++++++++++++++++ 2 files changed, 77 insertions(+), 1 deletion(-) rename e2e-test/java/org/alfresco/rest/ratings/{AddRateSanityTests.java => AddRatingSanityTests.java} (99%) create mode 100644 e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/ratings/AddRateSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/ratings/AddRateSanityTests.java rename to e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java index 63ab3923d..3d3f5c823 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/AddRateSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java @@ -23,7 +23,7 @@ import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @Test(groups = { "rest-api", "ratings", "sanity" }) -public class AddRateSanityTests extends RestTest +public class AddRatingSanityTests extends RestTest { @Autowired RestRatingsApi ratingsApi; diff --git a/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java new file mode 100644 index 000000000..daa5e18cf --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java @@ -0,0 +1,76 @@ +package org.alfresco.rest.ratings; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.body.FiveStarRatingBody; +import org.alfresco.rest.body.LikeRatingBody; +import org.alfresco.rest.requests.RestRatingsApi; +import org.alfresco.utility.constants.Rating; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.exception.DataPreparationException; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.apache.commons.lang3.RandomStringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +@Test(groups = { "rest-api", "ratings", "sanity" }) +public class GetRatingSanityTests extends RestTest +{ + @Autowired + RestRatingsApi ratingsApi; + + private UserModel userModel; + private SiteModel siteModel; + private UserModel adminUser; + private FolderModel folderModel; + private FileModel document; + private LikeRatingBody likeRating; + private FiveStarRatingBody fiveStarRating; + private ListUserWithRoles usersWithRoles; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws DataPreparationException + { + userModel = dataUser.createUser(RandomStringUtils.randomAlphanumeric(20)); + adminUser = dataUser.getAdminUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + ratingsApi.useRestClient(restClient); + + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + } + + @BeforeClass + public void setUp() throws Exception { + folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(adminUser); + + likeRating = new LikeRatingBody(Rating.likes, true); + ratingsApi.likeDocument(document, likeRating); + + fiveStarRating = new FiveStarRatingBody(Rating.fiveStar, 5); + ratingsApi.rateStarsToDocument(document, fiveStarRating); + + restClient.disconnect(); + } + + @TestRail(section = {"rest-api", "ratings" }, executionType = ExecutionType.SANITY, + description = "Verify user with Manager role is able to retrieve document ratings") + public void managerIsAbleToRetrieveDocumentRatings() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + ratingsApi.getRatings(document); + ratingsApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.OK); + } + +} \ No newline at end of file From 54e5fb6da67f568e670afae103295f40a22fc855 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Wed, 5 Oct 2016 18:11:16 +0300 Subject: [PATCH 0275/1491] TAS-1094 REST API - valid request returns success status code 200 with Collaborator role --- .../org/alfresco/rest/ratings/GetRatingSanityTests.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java index daa5e18cf..b6c467a9f 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java @@ -73,4 +73,13 @@ public class GetRatingSanityTests extends RestTest .assertStatusCodeIs(HttpStatus.OK); } + @TestRail(section = {"rest-api", "ratings" }, executionType = ExecutionType.SANITY, + description = "Verify user with Collaborator role is able to retrieve document ratings") + public void collaboratorIsAbleToRetrieveDocumentRatings() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + ratingsApi.getRatings(document); + ratingsApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.OK); + } } \ No newline at end of file From 22348f4536bb0502f80e15bd69aee46c4e97ba2f Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Wed, 5 Oct 2016 18:12:46 +0300 Subject: [PATCH 0276/1491] TAS-1095 REST API - valid request returns success status code 200 with Contributor role --- .../alfresco/rest/ratings/GetRatingSanityTests.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java index b6c467a9f..fa432b621 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java @@ -82,4 +82,14 @@ public class GetRatingSanityTests extends RestTest ratingsApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.OK); } + + @TestRail(section = {"rest-api", "ratings" }, executionType = ExecutionType.SANITY, + description = "Verify user with Contributor role is able to retrieve document ratings") + public void contributorIsAbleToRetrieveDocumentRatings() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + ratingsApi.getRatings(document); + ratingsApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.OK); + } } \ No newline at end of file From ebca4751aee4c67d6c92ed38757c533b1431f80b Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Wed, 5 Oct 2016 18:14:44 +0300 Subject: [PATCH 0277/1491] TAS-1096 REST API - valid request returns success status code 200 with Consumer role --- .../alfresco/rest/ratings/GetRatingSanityTests.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java index fa432b621..33b356d40 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java @@ -92,4 +92,14 @@ public class GetRatingSanityTests extends RestTest ratingsApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.OK); } + + @TestRail(section = {"rest-api", "ratings" }, executionType = ExecutionType.SANITY, + description = "Verify user with Consumer role is able to retrieve document ratings") + public void consumerIsAbleToRetrieveDocumentRatings() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + ratingsApi.getRatings(document); + ratingsApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.OK); + } } \ No newline at end of file From 2bd71b456a4254b83bebe8f84bbec3a98fe4f85e Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Wed, 5 Oct 2016 18:15:54 +0300 Subject: [PATCH 0278/1491] TAS-1097 REST API - valid request returns success status code 200 with admin user --- .../alfresco/rest/ratings/GetRatingSanityTests.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java index 33b356d40..207a8f23e 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java @@ -102,4 +102,14 @@ public class GetRatingSanityTests extends RestTest ratingsApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.OK); } + + @TestRail(section = {"rest-api", "ratings" }, executionType = ExecutionType.SANITY, + description = "Verify admin user is able to retrieve document ratings") + public void adminIsAbleToRetrieveDocumentRatings() throws Exception + { + restClient.authenticateUser(adminUser); + ratingsApi.getRatings(document); + ratingsApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.OK); + } } \ No newline at end of file From efd5906baa68efcffbb8003e56f8de7485f5ed99 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Wed, 5 Oct 2016 18:44:33 +0300 Subject: [PATCH 0279/1491] TAS-1098 REST API - failed authentication call returns status code 401 --- .../rest/people/GetSiteMembershipSanityTests.java | 2 ++ .../GetSitesMembershipInformationSanityTests.java | 2 ++ .../alfresco/rest/ratings/AddRatingSanityTests.java | 3 +++ .../alfresco/rest/ratings/GetRatingSanityTests.java | 12 ++++++++++++ 4 files changed, 19 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java index 08f8d9bff..a87e5e20b 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java @@ -10,6 +10,7 @@ import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.beans.factory.annotation.Autowired; @@ -98,6 +99,7 @@ public class GetSiteMembershipSanityTests extends RestTest @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to retrieve site membership information of another user") + @Bug(id = "MNT-16904") public void unauthenticatedUserCannotRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception { restClient.authenticateUser(new UserModel("random user", "random password")); diff --git a/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java index 646c2952f..7fafa4614 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java @@ -10,6 +10,7 @@ import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.beans.factory.annotation.Autowired; @@ -95,6 +96,7 @@ public class GetSitesMembershipInformationSanityTests extends RestTest @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify that unauthenticated user is not able to retrieve sites membership information") + @Bug(id = "MNT-16904") public void unauthenticatedUserCannotRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception { UserModel inexistentUser = new UserModel("inexistent user", "wrong password"); diff --git a/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java index 3d3f5c823..80515f719 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java @@ -13,6 +13,7 @@ import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.apache.commons.lang3.RandomStringUtils; @@ -116,6 +117,7 @@ public class AddRatingSanityTests extends RestTest @TestRail(section = {"rest-api", "ratings" }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to post like rating to a document") + @Bug(id = "MNT-16904") public void unauthenticatedUserIsNotAbleToLikeDocument() throws Exception { likeRating = new LikeRatingBody(Rating.likes, true); @@ -188,6 +190,7 @@ public class AddRatingSanityTests extends RestTest @TestRail(section = {"rest-api", "ratings" }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to post stars rating to a document") + @Bug(id = "MNT-16904") public void unauthenticatedUserIsNotAbleToRateStarsToDocument() throws Exception { fiveStarRating = new FiveStarRatingBody(Rating.fiveStar, 5); diff --git a/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java index 207a8f23e..3e698b252 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java @@ -13,6 +13,7 @@ import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.apache.commons.lang3.RandomStringUtils; @@ -112,4 +113,15 @@ public class GetRatingSanityTests extends RestTest ratingsApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.OK); } + + @TestRail(section = {"rest-api", "ratings" }, executionType = ExecutionType.SANITY, + description = "Verify unauthenticated user is not able to retrieve document ratings") + @Bug(id = "MNT-16904") + public void unauthenticatedUserIsNotAbleToRetrieveDocumentRatings() throws Exception + { + restClient.authenticateUser(new UserModel("random user", "random password")); + ratingsApi.getRatings(document); + ratingsApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + } } \ No newline at end of file From d0a42331ec4834b12055ef8d2d0740507005daaf Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Wed, 5 Oct 2016 19:06:41 +0300 Subject: [PATCH 0280/1491] TAS-1163 getFavoriteSite call test with Manager role --- .../people/GetFavoriteSiteSanityTests.java | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java new file mode 100644 index 000000000..802f20624 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java @@ -0,0 +1,54 @@ +package org.alfresco.rest.people; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.requests.RestPeopleApi; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Tests for Get Favorite Sites (/people/{personId}/preferences) RestAPI call + * + * @author Cristina Axinte + * + */ +@Test(groups = { "rest-api", "people", "sanity" }) +public class GetFavoriteSiteSanityTests extends RestTest +{ + @Autowired + RestPeopleApi peopleApi; + + UserModel userModel; + SiteModel siteModel1; + SiteModel siteModel2; + UserModel searchedUser; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + siteModel1 = dataSite.usingUser(userModel).createPublicRandomSite(); + siteModel2 = dataSite.usingUser(userModel).createPublicRandomSite(); + + peopleApi.useRestClient(restClient); + } + + @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify manager user gets its favorite sites with Rest API and response is successful (200)") + public void managerUserGetsFavoriteSitesWithSuccess() throws Exception + { + UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel1, UserRole.SiteManager); + dataSite.usingUser(managerUser).usingSite(siteModel1).addSiteToFavorites(); + dataSite.usingUser(managerUser).usingSite(siteModel2).addSiteToFavorites(); + + restClient.authenticateUser(managerUser); + peopleApi.getFavoriteSite(managerUser, siteModel1).assertResponseIsNotEmpty(); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } +} From 8460b26196ab042bdcb7731f121cf266b829a003 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Wed, 5 Oct 2016 19:08:33 +0300 Subject: [PATCH 0281/1491] TAS-1176 getFavoriteSite with admin --- .../favorites/GetFavoriteSanityTests.java | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java new file mode 100644 index 000000000..2db688e24 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java @@ -0,0 +1,61 @@ +package org.alfresco.rest.favorites; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.requests.RestFavoritesApi; +import org.alfresco.rest.requests.RestSitesApi; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class GetFavoriteSanityTests extends RestTest +{ + + @Autowired + RestFavoritesApi favoritesAPI; + + @Autowired + RestSitesApi sitesApi; + + private UserModel adminUserModel; + private SiteModel siteModel; + private FolderModel folderModel; + private FileModel fileModel; + private ListUserWithRoles usersWithRoles; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + restClient.authenticateUser(adminUserModel); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + + folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); + fileModel = dataContent.usingUser(adminUserModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + favoritesAPI.useRestClient(restClient); + sitesApi.useRestClient(restClient); + siteModel.setGuid(sitesApi.getSite(siteModel).getGuid()); + + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + } + + @TestRail(section = { "rest-api", + "favorites" }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets favorite site with Rest API and status code is 200") + public void adminIsAbleToRetrieveFavoritesSite() throws JsonToModelConversionException, Exception + { + favoritesAPI.addUserFavorites(adminUserModel, siteModel); + favoritesAPI.getUserFavorite(adminUserModel, siteModel.getGuid()); + favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } +} From a0ca1d3d178dfcf320b55b066ebe49503257d999 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Wed, 5 Oct 2016 19:09:47 +0300 Subject: [PATCH 0282/1491] TAS-1177 getFavoriteFolder with admin --- .../alfresco/rest/favorites/GetFavoriteSanityTests.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java index 2db688e24..7d0d7af02 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java @@ -58,4 +58,13 @@ public class GetFavoriteSanityTests extends RestTest favoritesAPI.getUserFavorite(adminUserModel, siteModel.getGuid()); favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + @TestRail(section = { "rest-api", + "favorites" }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets favorite folder with Rest API and status code is 200") + public void adminIsAbleToRetrieveFavoritesFolder() throws JsonToModelConversionException, Exception + { + favoritesAPI.addUserFavorites(adminUserModel, folderModel); + favoritesAPI.getUserFavorite(adminUserModel, folderModel.getNodeRef()); + favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } } From fa6a1707b2d148e5c5188b883a29864f2a50ebc4 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Wed, 5 Oct 2016 19:10:30 +0300 Subject: [PATCH 0283/1491] TAS-1178 getfavoriteFile with admin --- .../alfresco/rest/favorites/GetFavoriteSanityTests.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java index 7d0d7af02..58ebc8510 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java @@ -67,4 +67,13 @@ public class GetFavoriteSanityTests extends RestTest favoritesAPI.getUserFavorite(adminUserModel, folderModel.getNodeRef()); favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + @TestRail(section = { "rest-api", + "favorites" }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets favorite file with Rest API and status code is 200") + public void adminIsAbleToRetrieveFavoritesFile() throws JsonToModelConversionException, Exception + { + favoritesAPI.addUserFavorites(adminUserModel, fileModel); + favoritesAPI.getUserFavorite(adminUserModel, fileModel.getNodeRef()); + favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } } From ec3801961b33cc6f881497e55e51ccad87f3501b Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Wed, 5 Oct 2016 19:11:19 +0300 Subject: [PATCH 0284/1491] TAS-1175 getFavoriteSite with manager --- .../rest/favorites/GetFavoriteSanityTests.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java index 58ebc8510..5f69a7ad1 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java @@ -76,4 +76,14 @@ public class GetFavoriteSanityTests extends RestTest favoritesAPI.getUserFavorite(adminUserModel, fileModel.getNodeRef()); favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + @TestRail(section = { "rest-api", + "favorites" }, executionType = ExecutionType.SANITY, description = "Verify Manager user gets favorite site with Rest API and status code is 200") + public void managerIsAbleToRetrieveFavorite() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + favoritesAPI.addUserFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteManager), siteModel); + favoritesAPI.getUserFavorite(usersWithRoles.getOneUserWithRole(UserRole.SiteManager), siteModel.getGuid()); + favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } } From f95d512c170c157c0ebc00917106a43f51bd0e23 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Wed, 5 Oct 2016 19:12:10 +0300 Subject: [PATCH 0285/1491] TAS-1179 getFavoriteSite with collaborator --- .../rest/favorites/GetFavoriteSanityTests.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java index 5f69a7ad1..a2e397c3f 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java @@ -86,4 +86,14 @@ public class GetFavoriteSanityTests extends RestTest favoritesAPI.getUserFavorite(usersWithRoles.getOneUserWithRole(UserRole.SiteManager), siteModel.getGuid()); favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + @TestRail(section = { "rest-api", + "favorites" }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user gets favorite site with Rest API and status code is 200") + public void collaboratorIsAbleToRetrieveFavorites() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + favoritesAPI.addUserFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), siteModel); + favoritesAPI.getUserFavorite(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), siteModel.getGuid()); + favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } } From 2a0369190ab30f9b0ead5795d3395883cae7c58a Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Wed, 5 Oct 2016 19:13:01 +0300 Subject: [PATCH 0286/1491] TAS-1180 getFavoriteSite with contributor --- .../rest/favorites/GetFavoriteSanityTests.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java index a2e397c3f..fc47cf40a 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java @@ -96,4 +96,15 @@ public class GetFavoriteSanityTests extends RestTest favoritesAPI.getUserFavorite(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), siteModel.getGuid()); favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + @TestRail(section = { "rest-api", + "favorites" }, executionType = ExecutionType.SANITY, description = "Verify Contributor user gets favorite site with Rest API and status code is 200") + public void contributorIsAbleToRetrieveFavorite() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + favoritesAPI.addUserFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor), siteModel); + favoritesAPI.getUserFavorite(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor), siteModel.getGuid()); + favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } + } From 9d08792e70dbfa451d0949735fefc2e6f10149f9 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Wed, 5 Oct 2016 19:14:11 +0300 Subject: [PATCH 0287/1491] TAS-1181 getFavoriteSite with consumer --- .../rest/favorites/GetFavoriteSanityTests.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java index fc47cf40a..96efcab1f 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java @@ -107,4 +107,14 @@ public class GetFavoriteSanityTests extends RestTest favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + @TestRail(section = { "rest-api", + "favorites" }, executionType = ExecutionType.SANITY, description = "Verify Consumer user gets favorite site with Rest API and status code is 200") + public void consumerIsAbleToRetrieveFavorites() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + favoritesAPI.addUserFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer), siteModel); + favoritesAPI.getUserFavorite(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer), siteModel.getGuid()); + favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } + } From 4bb77fda84f303f4c6fd13327996554c1ba9cf01 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Wed, 5 Oct 2016 19:15:40 +0300 Subject: [PATCH 0288/1491] TAS-1182, TAS-1183, TAS-1184, TAS-1185 --- .../favorites/GetFavoriteSanityTests.java | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java index 96efcab1f..86c3e00c8 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java @@ -117,4 +117,42 @@ public class GetFavoriteSanityTests extends RestTest favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + @TestRail(section = { "rest-api", + "favorites" }, executionType = ExecutionType.SANITY, description = "Verify user doesn't get favorite site of another user with Rest API and status code is 404") + public void userIsNotAbleToRetrieveFavoriteSiteOfAnotherUser() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + favoritesAPI.getUserFavorite(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), siteModel.getGuid()); + favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); + } + + @TestRail(section = { "rest-api", + "favorites" }, executionType = ExecutionType.SANITY, description = "Verify user doesn't get favorite site of admin user with Rest API and status code is 404") + public void userIsNotAbleToRetrieveFavoritesOfAdminUser() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + favoritesAPI.getUserFavorite(adminUserModel, siteModel.getGuid()); + favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); + } + + @TestRail(section = { "rest-api", + "favorites" }, executionType = ExecutionType.SANITY, description = "Verify admin user doesn't get favorite site of another user with Rest API and status code is 404") + public void adminIsNotAbleToRetrieveFavoritesOfAnotherUser() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel); + favoritesAPI.getUserFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), siteModel.getGuid()); + favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); + } + + @TestRail(section = { "rest-api", + "favorites" }, executionType = ExecutionType.SANITY, description = "Verify user gets status code 401 if authentication call fails") + public void userIsNotAbleToRetrieveFavoritesIfAuthenticationFails() throws JsonToModelConversionException, Exception + { + UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); + siteManager.setPassword("wrongPassword"); + restClient.authenticateUser(siteManager); + favoritesAPI.getUserFavorite(usersWithRoles.getOneUserWithRole(UserRole.SiteManager), siteModel.getGuid()); + favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + } + } From 7364c10a9d9ebaa956014224d6442a499a9a9ef7 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Thu, 6 Oct 2016 10:13:02 +0300 Subject: [PATCH 0289/1491] TAS-1165 getFavoriteSite call test with Collaborator role --- .../rest/people/GetFavoriteSiteSanityTests.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java index 802f20624..9b83c4692 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java @@ -39,7 +39,7 @@ public class GetFavoriteSiteSanityTests extends RestTest peopleApi.useRestClient(restClient); } - @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify manager user gets its favorite sites with Rest API and response is successful (200)") + @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify manager user gets its specific favorite site with Rest API and response is successful (200)") public void managerUserGetsFavoriteSitesWithSuccess() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -51,4 +51,17 @@ public class GetFavoriteSiteSanityTests extends RestTest peopleApi.getFavoriteSite(managerUser, siteModel1).assertResponseIsNotEmpty(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify collaborator user gets its specific favorite site with Rest API and response is successful (200)") + public void collaboratorUserGetsFavoriteSitesWithSuccess() throws Exception + { + UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(collaboratorUser, siteModel1, UserRole.SiteCollaborator); + dataSite.usingUser(collaboratorUser).usingSite(siteModel1).addSiteToFavorites(); + dataSite.usingUser(collaboratorUser).usingSite(siteModel2).addSiteToFavorites(); + + restClient.authenticateUser(collaboratorUser); + peopleApi.getFavoriteSite(collaboratorUser, siteModel1).assertResponseIsNotEmpty(); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } } From e35faca0e3c2429c30b6c8f351be174df8397f3c Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Thu, 6 Oct 2016 10:17:18 +0300 Subject: [PATCH 0290/1491] TAS-1167 getFavoriteSite call test with Contributor role --- .../rest/people/GetFavoriteSiteSanityTests.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java index 9b83c4692..d3f91c38b 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java @@ -40,7 +40,7 @@ public class GetFavoriteSiteSanityTests extends RestTest } @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify manager user gets its specific favorite site with Rest API and response is successful (200)") - public void managerUserGetsFavoriteSitesWithSuccess() throws Exception + public void managerUserGetsFavoriteSiteWithSuccess() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel1, UserRole.SiteManager); @@ -53,7 +53,7 @@ public class GetFavoriteSiteSanityTests extends RestTest } @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify collaborator user gets its specific favorite site with Rest API and response is successful (200)") - public void collaboratorUserGetsFavoriteSitesWithSuccess() throws Exception + public void collaboratorUserGetsFavoriteSiteWithSuccess() throws Exception { UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(collaboratorUser, siteModel1, UserRole.SiteCollaborator); @@ -64,4 +64,17 @@ public class GetFavoriteSiteSanityTests extends RestTest peopleApi.getFavoriteSite(collaboratorUser, siteModel1).assertResponseIsNotEmpty(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify contributor user gets its specific favorite site with Rest API and response is successful (200)") + public void contributorUserGetsFavoriteSiteWithSuccess() throws Exception + { + UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(contributorUser, siteModel1, UserRole.SiteContributor); + dataSite.usingUser(contributorUser).usingSite(siteModel1).addSiteToFavorites(); + dataSite.usingUser(contributorUser).usingSite(siteModel2).addSiteToFavorites(); + + restClient.authenticateUser(contributorUser); + peopleApi.getFavoriteSite(contributorUser, siteModel1).assertResponseIsNotEmpty(); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } } From 639e15db6c41b2381598dece53865c99c28e66e2 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Thu, 6 Oct 2016 10:19:37 +0300 Subject: [PATCH 0291/1491] TAS-1168 getFavoriteSite call test with Consumer role --- .../rest/people/GetFavoriteSiteSanityTests.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java index d3f91c38b..281fbacec 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java @@ -77,4 +77,17 @@ public class GetFavoriteSiteSanityTests extends RestTest peopleApi.getFavoriteSite(contributorUser, siteModel1).assertResponseIsNotEmpty(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify consumer user gets its specific favorite site with Rest API and response is successful (200)") + public void consumerUserGetsFavoriteSiteWithSuccess() throws Exception + { + UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel1, UserRole.SiteConsumer); + dataSite.usingUser(consumerUser).usingSite(siteModel1).addSiteToFavorites(); + dataSite.usingUser(consumerUser).usingSite(siteModel2).addSiteToFavorites(); + + restClient.authenticateUser(consumerUser); + peopleApi.getFavoriteSite(consumerUser, siteModel1).assertResponseIsNotEmpty(); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } } From bbd344b9616edc6930488a5266c6a79fc721b313 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Thu, 6 Oct 2016 10:23:24 +0300 Subject: [PATCH 0292/1491] TAS-1169 getFavoriteSite call test with admin user --- .../rest/people/GetFavoriteSiteSanityTests.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java index 281fbacec..66af00426 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java @@ -90,4 +90,17 @@ public class GetFavoriteSiteSanityTests extends RestTest peopleApi.getFavoriteSite(consumerUser, siteModel1).assertResponseIsNotEmpty(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify admin user gets specific favorite site of any user with Rest API and response is successful (200)") + public void adminUserGetsAnyFavoriteSiteWithSuccess() throws Exception + { + UserModel adminUset = dataUser.getAdminUser(); + UserModel anyUser = dataUser.usingAdmin().createRandomTestUser(); + dataSite.usingUser(anyUser).usingSite(siteModel1).addSiteToFavorites(); + dataSite.usingUser(anyUser).usingSite(siteModel2).addSiteToFavorites(); + + restClient.authenticateUser(adminUset); + peopleApi.getFavoriteSite(anyUser, siteModel1).assertResponseIsNotEmpty(); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } } From b6ea4f61670322c26a3a91d6064ce78eaf6ca163 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Thu, 6 Oct 2016 10:35:51 +0300 Subject: [PATCH 0293/1491] TAS-1170 getFavoriteSite failed call test with Manager role --- .../people/GetFavoriteSiteSanityTests.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java index 66af00426..8f80da586 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java @@ -103,4 +103,31 @@ public class GetFavoriteSiteSanityTests extends RestTest peopleApi.getFavoriteSite(anyUser, siteModel1).assertResponseIsNotEmpty(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify manager user fails to get specific favorite site of another user with Rest API and response is successful (403)") + public void managerUserFailsToGetFavoriteSiteOfAnotherUser() throws Exception + { + UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel1, UserRole.SiteManager); + dataSite.usingUser(managerUser).usingSite(siteModel1).addSiteToFavorites(); + dataSite.usingUser(managerUser).usingSite(siteModel2).addSiteToFavorites(); + + restClient.authenticateUser(managerUser); + peopleApi.getFavoriteSite(userModel, siteModel1); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + } + + @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized gets its specific favorite site with Rest API when authentication fails (401)") + public void managerUserNotAuthorizedFailsToGetFavoriteSite() throws Exception + { + UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel1, UserRole.SiteManager); + dataSite.usingUser(managerUser).usingSite(siteModel1).addSiteToFavorites(); + dataSite.usingUser(managerUser).usingSite(siteModel2).addSiteToFavorites(); + managerUser.setPassword("newpassword"); + + restClient.authenticateUser(managerUser); + peopleApi.getFavoriteSite(managerUser, siteModel1); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + } } From a2a282cda75a93ab259734d4b007c3d7aa352859 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Thu, 6 Oct 2016 11:37:16 +0300 Subject: [PATCH 0294/1491] TAS-1193 REST API - valid request returns success status code 204 with Manager role --- .../rest/ratings/DeleteRatingSanityTests.java | 81 +++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java new file mode 100644 index 000000000..526e11d78 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java @@ -0,0 +1,81 @@ +package org.alfresco.rest.ratings; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.body.FiveStarRatingBody; +import org.alfresco.rest.body.LikeRatingBody; +import org.alfresco.rest.requests.RestRatingsApi; +import org.alfresco.utility.constants.Rating; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.exception.DataPreparationException; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +@Test(groups = { "rest-api", "ratings", "sanity" }) +public class DeleteRatingSanityTests extends RestTest +{ + @Autowired + RestRatingsApi ratingsApi; + + private UserModel userModel; + private SiteModel siteModel; + private UserModel adminUser; + private FolderModel folderModel; + private FileModel document; + private LikeRatingBody likeRating; + private FiveStarRatingBody fiveStarRating; + private ListUserWithRoles usersWithRoles; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws DataPreparationException + { + adminUser = dataUser.getAdminUser(); + siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); + + ratingsApi.useRestClient(restClient); + + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, + UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + } + + @BeforeMethod() + public void setUp() throws DataPreparationException, Exception { + folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + likeRating = new LikeRatingBody(Rating.likes, true); + fiveStarRating = new FiveStarRatingBody(Rating.fiveStar, 5); + } + + @TestRail(section = {"rest-api", "ratings" }, executionType = ExecutionType.SANITY, + description = "Verify user with Manager role is able to remove its own rating of a document") + public void managerIsAbleToDeleteItsOwnRatings() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + + ratingsApi.likeDocument(document, likeRating); + ratingsApi.rateStarsToDocument(document, fiveStarRating); + + ratingsApi.deleteLikeRating(document); + ratingsApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.NO_CONTENT); + + ratingsApi.deleteFiveStarRating(document); + ratingsApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.NO_CONTENT); + + ratingsApi.getRatings(document) + .assertNodeIsNotLiked() + .assertNodeHasNoFiveStarRating(); + } +} \ No newline at end of file From e3c5ece6301300f2e73619e1147814a5d76ffb1a Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Thu, 6 Oct 2016 11:53:35 +0300 Subject: [PATCH 0295/1491] TAS-1197 REST API - valid request returns success status code 204 with Collaborator role --- .../rest/ratings/DeleteRatingSanityTests.java | 28 +++++++++++++++++-- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java index 526e11d78..acdad7153 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java @@ -46,15 +46,15 @@ public class DeleteRatingSanityTests extends RestTest usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + + likeRating = new LikeRatingBody(Rating.likes, true); + fiveStarRating = new FiveStarRatingBody(Rating.fiveStar, 5); } @BeforeMethod() public void setUp() throws DataPreparationException, Exception { folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - likeRating = new LikeRatingBody(Rating.likes, true); - fiveStarRating = new FiveStarRatingBody(Rating.fiveStar, 5); } @TestRail(section = {"rest-api", "ratings" }, executionType = ExecutionType.SANITY, @@ -78,4 +78,26 @@ public class DeleteRatingSanityTests extends RestTest .assertNodeIsNotLiked() .assertNodeHasNoFiveStarRating(); } + + @TestRail(section = {"rest-api", "ratings" }, executionType = ExecutionType.SANITY, + description = "Verify user with Collaborator role is able to remove its own rating of a document") + public void collaboratorIsAbleToDeleteItsOwnRatings() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + + ratingsApi.likeDocument(document, likeRating); + ratingsApi.rateStarsToDocument(document, fiveStarRating); + + ratingsApi.deleteLikeRating(document); + ratingsApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.NO_CONTENT); + + ratingsApi.deleteFiveStarRating(document); + ratingsApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.NO_CONTENT); + + ratingsApi.getRatings(document) + .assertNodeIsNotLiked() + .assertNodeHasNoFiveStarRating(); + } } \ No newline at end of file From 8e1fd386425fc1df74fec458765d96f809fc3df4 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Thu, 6 Oct 2016 11:56:22 +0300 Subject: [PATCH 0296/1491] TAS-1198 REST API - valid request returns success status code 204 with Contributor role --- .../rest/ratings/DeleteRatingSanityTests.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java index acdad7153..1597d54dc 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java @@ -100,4 +100,26 @@ public class DeleteRatingSanityTests extends RestTest .assertNodeIsNotLiked() .assertNodeHasNoFiveStarRating(); } + + @TestRail(section = {"rest-api", "ratings" }, executionType = ExecutionType.SANITY, + description = "Verify user with Contributor role is able to remove its own rating of a document") + public void contributorIsAbleToDeleteItsOwnRatings() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + + ratingsApi.likeDocument(document, likeRating); + ratingsApi.rateStarsToDocument(document, fiveStarRating); + + ratingsApi.deleteLikeRating(document); + ratingsApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.NO_CONTENT); + + ratingsApi.deleteFiveStarRating(document); + ratingsApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.NO_CONTENT); + + ratingsApi.getRatings(document) + .assertNodeIsNotLiked() + .assertNodeHasNoFiveStarRating(); + } } \ No newline at end of file From 4969f3500eab7bc54792ca155a8728190b8fcd25 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Thu, 6 Oct 2016 11:59:01 +0300 Subject: [PATCH 0297/1491] TAS-1199 REST API - valid request returns success status code 204 with Consumer role --- .../rest/ratings/DeleteRatingSanityTests.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java index 1597d54dc..d7b2168f8 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java @@ -122,4 +122,26 @@ public class DeleteRatingSanityTests extends RestTest .assertNodeIsNotLiked() .assertNodeHasNoFiveStarRating(); } + + @TestRail(section = {"rest-api", "ratings" }, executionType = ExecutionType.SANITY, + description = "Verify user with Consumer role is able to remove its own rating of a document") + public void consumerIsAbleToDeleteItsOwnRatings() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + + ratingsApi.likeDocument(document, likeRating); + ratingsApi.rateStarsToDocument(document, fiveStarRating); + + ratingsApi.deleteLikeRating(document); + ratingsApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.NO_CONTENT); + + ratingsApi.deleteFiveStarRating(document); + ratingsApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.NO_CONTENT); + + ratingsApi.getRatings(document) + .assertNodeIsNotLiked() + .assertNodeHasNoFiveStarRating(); + } } \ No newline at end of file From 4c3776ef915d61debd76094ce21f761ec80a4af3 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Thu, 6 Oct 2016 12:00:39 +0300 Subject: [PATCH 0298/1491] TAS-1200 REST API - valid request returns success status code 204 with admin user --- .../rest/ratings/DeleteRatingSanityTests.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java index d7b2168f8..f9c1e74a4 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java @@ -144,4 +144,26 @@ public class DeleteRatingSanityTests extends RestTest .assertNodeIsNotLiked() .assertNodeHasNoFiveStarRating(); } + + @TestRail(section = {"rest-api", "ratings" }, executionType = ExecutionType.SANITY, + description = "Verify admin user is able to remove its own rating of a document") + public void adminIsAbleToDeleteItsOwnRatings() throws Exception + { + restClient.authenticateUser(adminUser); + + ratingsApi.likeDocument(document, likeRating); + ratingsApi.rateStarsToDocument(document, fiveStarRating); + + ratingsApi.deleteLikeRating(document); + ratingsApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.NO_CONTENT); + + ratingsApi.deleteFiveStarRating(document); + ratingsApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.NO_CONTENT); + + ratingsApi.getRatings(document) + .assertNodeIsNotLiked() + .assertNodeHasNoFiveStarRating(); + } } \ No newline at end of file From 902f2c59789fa6ebcf0400ccdaebe951b4c71833 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Thu, 6 Oct 2016 12:14:07 +0300 Subject: [PATCH 0299/1491] TAS-1201 REST API - failed authentication call returns status code 401 --- .../rest/ratings/DeleteRatingSanityTests.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java index f9c1e74a4..81e5b54ec 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java @@ -166,4 +166,24 @@ public class DeleteRatingSanityTests extends RestTest .assertNodeIsNotLiked() .assertNodeHasNoFiveStarRating(); } + + @TestRail(section = {"rest-api", "ratings" }, executionType = ExecutionType.SANITY, + description = "Verify unauthenticated user is not able to remove its own rating of a document") + public void unauthenticatedUserIsNotAbleToDeleteRatings() throws Exception + { + restClient.authenticateUser(adminUser); + + ratingsApi.likeDocument(document, likeRating); + ratingsApi.rateStarsToDocument(document, fiveStarRating); + + restClient.authenticateUser(new UserModel("random user", "random password")); + + ratingsApi.deleteLikeRating(document); + ratingsApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + + ratingsApi.deleteFiveStarRating(document); + ratingsApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + } } \ No newline at end of file From a8cb353f9f205c7aaab79c0f8937881d626c1762 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Thu, 6 Oct 2016 13:55:08 +0300 Subject: [PATCH 0300/1491] TAS-1206 REST API - one user should not be able to delete rating added by another user --- .../rest/ratings/DeleteRatingSanityTests.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java index 81e5b54ec..7b63dfae1 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java @@ -13,6 +13,7 @@ import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.beans.factory.annotation.Autowired; @@ -186,4 +187,28 @@ public class DeleteRatingSanityTests extends RestTest ratingsApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } + + @TestRail(section = {"rest-api", "ratings" }, executionType = ExecutionType.SANITY, + description = "Verify one user is not able to remove rating added by another user") + @Bug(id = "ACE-5459") + public void oneUserIsNotAbleToDeleteRatingsOfAnotherUser() throws Exception + { + UserModel userA = dataUser.createRandomTestUser(); + UserModel userB = dataUser.createRandomTestUser(); + + restClient.authenticateUser(userA); + + ratingsApi.likeDocument(document, likeRating); + ratingsApi.rateStarsToDocument(document, fiveStarRating); + + restClient.authenticateUser(userB); + + ratingsApi.deleteLikeRating(document); + ratingsApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + + ratingsApi.deleteFiveStarRating(document); + ratingsApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + } } \ No newline at end of file From 1ea5ef65dd756ff9c465761b2511a328c8357a22 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Thu, 6 Oct 2016 14:08:25 +0300 Subject: [PATCH 0301/1491] added glassfish jason & jsonBodyGenerator, updated tests --- .../Favorites/PostFavoritesSanityTests.java | 25 ++++++++++--------- .../rest/demo/SampleCommentsTests.java | 2 +- .../sites/RemoveSiteMemberSanityTests.java | 10 ++++---- 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/Favorites/PostFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/Favorites/PostFavoritesSanityTests.java index dfd0a04a1..9b67c80c8 100644 --- a/e2e-test/java/org/alfresco/rest/Favorites/PostFavoritesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/Favorites/PostFavoritesSanityTests.java @@ -9,6 +9,7 @@ import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.beans.factory.annotation.Autowired; @@ -49,28 +50,27 @@ public class PostFavoritesSanityTests extends RestTest @TestRail(section = { "rest-api", "favorites" }, executionType = ExecutionType.SANITY, description = "Verify Admin user add site to favorites with Rest API and status code is 201") - public void adminIsAbleToAddToFavorites() throws JsonToModelConversionException, Exception + public void adminIsAbleToAddToFavorites() throws Exception { - - favoritesAPI.addUserFavorites(adminUserModel, siteModel); + favoritesAPI.addSiteToFavorites(adminUserModel, siteModel); favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } @TestRail(section = { "rest-api", "favorites" }, executionType = ExecutionType.SANITY, description = "Verify Manager user add site to favorites with Rest API and status code is 201") - public void managerIsAbleToAddToFavorites() throws JsonToModelConversionException, Exception + public void managerIsAbleToAddToFavorites() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - favoritesAPI.addUserFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteManager), siteModel); + favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteManager), siteModel); favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } @TestRail(section = { "rest-api", "favorites" }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user add site to favorites with Rest API and status code is 201") - public void collaboratorIsAbleToAddToFavorites() throws JsonToModelConversionException, Exception + public void collaboratorIsAbleToAddToFavorites() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - favoritesAPI.addUserFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), siteModel); + favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), siteModel); favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } @@ -79,27 +79,28 @@ public class PostFavoritesSanityTests extends RestTest public void contributorIsAbleToAddToFavorites() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - favoritesAPI.addUserFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor), siteModel); + favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor), siteModel); favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } @TestRail(section = { "rest-api", "favorites" }, executionType = ExecutionType.SANITY, description = "Verify Consumer user add site to favorites with Rest API and status code is 201") - public void consumerIsAbleToAddToFavorites() throws JsonToModelConversionException, Exception + public void consumerIsAbleToAddToFavorites() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - favoritesAPI.addUserFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer), siteModel); + favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer), siteModel); favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } @TestRail(section = { "rest-api", "favorites" }, executionType = ExecutionType.SANITY, description = "Verify Manager user gets status code 401 if authentication call fails") - public void managerIsNotAbleToAddCommentIfAuthenticationFails() throws JsonToModelConversionException, Exception + @Bug(id="MNT-16904") + public void managerIsNotAbleToAddCommentIfAuthenticationFails() throws Exception { UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); siteManager.setPassword("wrongPassword"); restClient.authenticateUser(siteManager); - favoritesAPI.addUserFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer), siteModel); + favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer), siteModel); favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/demo/SampleCommentsTests.java b/e2e-test/java/org/alfresco/rest/demo/SampleCommentsTests.java index 4ae593295..6bb8fe67e 100644 --- a/e2e-test/java/org/alfresco/rest/demo/SampleCommentsTests.java +++ b/e2e-test/java/org/alfresco/rest/demo/SampleCommentsTests.java @@ -51,7 +51,7 @@ public class SampleCommentsTests extends RestTest @TestRail(section={"demo", "sample-section"}, executionType= ExecutionType.SANITY, description= "Verify admin user gets comments with Rest API and status code is 200") - public void admiShouldRetrieveComments() throws JsonToModelConversionException + public void admiShouldRetrieveComments() throws Exception { commentsAPI.getNodeComments(document); commentsAPI.usingRestWrapper() diff --git a/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java index 7af8adff8..d32c33696 100644 --- a/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java @@ -53,7 +53,7 @@ public class RemoveSiteMemberSanityTests extends RestTest @TestRail(section = {"rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify that site manager can delete site member and gets status code 204, 'No Content'") - public void siteManagerIsAbleToDeleteSiteMember() throws JsonToModelConversionException{ + public void siteManagerIsAbleToDeleteSiteMember() throws Exception{ restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); restSitesAPI.deleteSiteMember(siteModel, testUserModel); restSitesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); @@ -62,7 +62,7 @@ public class RemoveSiteMemberSanityTests extends RestTest @Bug(id="ACE-5444") @TestRail(section = {"rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify that site collaborator cannot delete site member and gets status code 403, 'Forbidden'") - public void siteCollaboratorIsNotAbleToDeleteSiteMember() throws JsonToModelConversionException{ + public void siteCollaboratorIsNotAbleToDeleteSiteMember() throws Exception{ restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); restSitesAPI.deleteSiteMember(siteModel, testUserModel); restSitesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); @@ -71,7 +71,7 @@ public class RemoveSiteMemberSanityTests extends RestTest @Bug(id="ACE-5444") @TestRail(section = {"rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify that site contributor cannot delete site member and gets status code 403, 'Forbidden'") - public void siteContributorIsNotAbleToDeleteSiteMember() throws JsonToModelConversionException{ + public void siteContributorIsNotAbleToDeleteSiteMember() throws Exception{ restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); restSitesAPI.deleteSiteMember(siteModel, testUserModel); restSitesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); @@ -80,7 +80,7 @@ public class RemoveSiteMemberSanityTests extends RestTest @Bug(id="ACE-5444") @TestRail(section = {"rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify that site consumer cannot delete site member and gets status code 403, 'Forbidden'") - public void siteConsumerIsNotAbleToDeleteSiteMember() throws JsonToModelConversionException{ + public void siteConsumerIsNotAbleToDeleteSiteMember() throws Exception{ restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); restSitesAPI.deleteSiteMember(siteModel, testUserModel); restSitesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); @@ -88,7 +88,7 @@ public class RemoveSiteMemberSanityTests extends RestTest @TestRail(section = {"rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify that admin user can delete site member and gets status code 204, 'No Content'") - public void adminUserIsAbleToDeleteSiteMember() throws JsonToModelConversionException{ + public void adminUserIsAbleToDeleteSiteMember() throws Exception{ restClient.authenticateUser(adminUserModel); restSitesAPI.deleteSiteMember(siteModel, testUserModel); restSitesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); From 4de46c4faa04084753ac55a7c99a0227684aca5c Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Thu, 6 Oct 2016 14:21:00 +0300 Subject: [PATCH 0302/1491] formatting --- .../org/alfresco/rest/Favorites/PostFavoritesSanityTests.java | 1 - 1 file changed, 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/Favorites/PostFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/Favorites/PostFavoritesSanityTests.java index 9b67c80c8..f51f21673 100644 --- a/e2e-test/java/org/alfresco/rest/Favorites/PostFavoritesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/Favorites/PostFavoritesSanityTests.java @@ -20,7 +20,6 @@ import org.testng.annotations.Test; @Test(groups = { "rest-api", "favorites", "sanity" }) public class PostFavoritesSanityTests extends RestTest { - @Autowired RestFavoritesApi favoritesAPI; From 18aae188906a1521c1ec71a5af3383b8c564673c Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Thu, 6 Oct 2016 14:28:12 +0300 Subject: [PATCH 0303/1491] added MNT-16904 --- .../org/alfresco/rest/people/GetPeoplePreferenceTests.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceTests.java index bc836134f..fe2bf9455 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceTests.java @@ -2,6 +2,7 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; import org.alfresco.rest.requests.RestPeopleApi; +import org.alfresco.utility.constants.PreferenceName; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; @@ -96,7 +97,7 @@ public class GetPeoplePreferenceTests extends RestTest peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @Bug(id = "") + @Bug(id = "MNT-16904") @TestRail(section = { "rest-api", "people", "preferences" }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized to get a specific preference with Rest API when authentication fails (401)") public void managerUserNotAuthorizedFailsToGetsAPreference() throws Exception { From 859ae0d92b3811b3464f9359369fc519d0896eab Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Thu, 6 Oct 2016 14:35:44 +0300 Subject: [PATCH 0304/1491] TAS-1118 updateSiteMember using a site manager --- .../sites/UpdateSiteMemberSanityTests.java | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java new file mode 100644 index 000000000..0428ab17d --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java @@ -0,0 +1,52 @@ +package org.alfresco.rest.sites; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.body.SiteMember; +import org.alfresco.rest.requests.RestSitesApi; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.social.alfresco.api.entities.Role; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +@Test(groups = { "rest-api", "sites", "sanity" }) +public class UpdateSiteMemberSanityTests extends RestTest +{ + @Autowired + RestSitesApi siteAPI; + + private UserModel adminUserModel; + private SiteModel siteModel; + private ListUserWithRoles usersWithRoles; + private UserModel testUserModel; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + siteAPI.useRestClient(restClient); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + testUserModel = dataUser.createRandomTestUser(); + dataUser.addUserToSite(testUserModel, siteModel, UserRole.SiteConsumer); + + } + + @TestRail(section = {"rest-api", "sites" }, executionType = ExecutionType.SANITY, + description = "Verify that manager is able to update site member and gets status code OK (200)") + public void managerIsAbleToUpdateSiteMember() throws Exception + { + SiteMember siteMember = new SiteMember(Role.SiteCollaborator.toString(), testUserModel.getUsername()); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + siteAPI.updateSiteMember(siteModel, testUserModel, siteMember); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } +} From 00fb1f5c6e5fe551c15102b1586e5b46301e4ce8 Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Thu, 6 Oct 2016 14:36:39 +0300 Subject: [PATCH 0305/1491] TAS-1119 site collaborator cannot update site member --- .../rest/sites/UpdateSiteMemberSanityTests.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java index 0428ab17d..bc1ffcf4c 100644 --- a/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java @@ -49,4 +49,15 @@ public class UpdateSiteMemberSanityTests extends RestTest siteAPI.updateSiteMember(siteModel, testUserModel, siteMember); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + @Bug(id="ACE-5444") + @TestRail(section = {"rest-api", "sites" }, executionType = ExecutionType.SANITY, + description = "Verify that collaborator is not able to update site member and gets status code FORBIDDEN (403)") + public void collaboratorIsNotAbleToUpdateSiteMember() throws Exception + { + SiteMember siteMember = new SiteMember(Role.SiteConsumer.toString(), testUserModel.getUsername()); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + siteAPI.updateSiteMember(siteModel, testUserModel, siteMember); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + } } From 2a8ec47282f538e0ccd89c3dce12271b9b8b273a Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Thu, 6 Oct 2016 14:37:32 +0300 Subject: [PATCH 0306/1491] TAS-1120 site contributor cannot update a site member --- .../rest/sites/UpdateSiteMemberSanityTests.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java index bc1ffcf4c..a4ad47819 100644 --- a/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java @@ -60,4 +60,15 @@ public class UpdateSiteMemberSanityTests extends RestTest siteAPI.updateSiteMember(siteModel, testUserModel, siteMember); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } + + @Bug(id="ACE-5444") + @TestRail(section = {"rest-api", "sites" }, executionType = ExecutionType.SANITY, + description = "Verify that contributor is not able to update site member and gets status code FORBIDDEN (403)") + public void contributorIsNotAbleToUpdateSiteMember() throws Exception + { + SiteMember siteMember = new SiteMember(Role.SiteConsumer.toString(), testUserModel.getUsername()); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + siteAPI.updateSiteMember(siteModel, testUserModel, siteMember); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + } } From f78659e30db861401fb184447fecda948a781df8 Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Thu, 6 Oct 2016 14:38:24 +0300 Subject: [PATCH 0307/1491] TAS-1121 site consumer cannot update a site memeber --- .../rest/sites/UpdateSiteMemberSanityTests.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java index a4ad47819..60521a539 100644 --- a/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java @@ -71,4 +71,15 @@ public class UpdateSiteMemberSanityTests extends RestTest siteAPI.updateSiteMember(siteModel, testUserModel, siteMember); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } + + @Bug(id="ACE-5444") + @TestRail(section = {"rest-api", "sites" }, executionType = ExecutionType.SANITY, + description = "Verify that consumer is not able to update site member and gets status code FORBIDDEN (403)") + public void consumerIsNotAbleToUpdateSiteMember() throws Exception + { + SiteMember siteMember = new SiteMember(Role.SiteConsumer.toString(), testUserModel.getUsername()); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + siteAPI.updateSiteMember(siteModel, testUserModel, siteMember); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + } } From 1b5de61481a6d02579fd9b6d4ed688040aa00848 Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Thu, 6 Oct 2016 14:39:06 +0300 Subject: [PATCH 0308/1491] TAS-1122 admin user can update a site member --- .../rest/sites/UpdateSiteMemberSanityTests.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java index 60521a539..3f2d683b1 100644 --- a/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java @@ -82,4 +82,14 @@ public class UpdateSiteMemberSanityTests extends RestTest siteAPI.updateSiteMember(siteModel, testUserModel, siteMember); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } + + @TestRail(section = {"rest-api", "sites" }, executionType = ExecutionType.SANITY, + description = "Verify that admin is able to update site member and gets status code OK (200)") + public void adminIsAbleToUpdateSiteMember() throws Exception + { + SiteMember siteMember = new SiteMember(Role.SiteConsumer.toString(), testUserModel.getUsername()); + restClient.authenticateUser(adminUserModel); + siteAPI.updateSiteMember(siteModel, testUserModel, siteMember); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } } From 93074ba38b29a5fce8da298df11f16b09e5445fe Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Thu, 6 Oct 2016 14:40:01 +0300 Subject: [PATCH 0309/1491] add tag --- .../alfresco/rest/tags/AddTagSanityTests.java | 39 +++++++++++++------ 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java index d1a74f2fd..db6cfa66e 100644 --- a/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java @@ -10,11 +10,13 @@ import org.alfresco.utility.data.RandomData; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; /** @@ -29,38 +31,44 @@ public class AddTagSanityTests extends RestTest @Autowired private RestTagsApi tagsAPI; - private UserModel adminUserModel; - private FileModel document; + private UserModel adminUserModel, userModel; + private FileModel document, contributorDoc; private SiteModel siteModel; private DataUser.ListUserWithRoles usersWithRoles; private String tagValue; - @BeforeClass(alwaysRun=true) + @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception { adminUserModel = dataUser.getAdminUser(); restClient.authenticateUser(adminUserModel); siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); tagsAPI.useRestClient(restClient); } + + @BeforeMethod(alwaysRun = true) + public void generateRandomTag() + { + tagValue = RandomData.getRandomName("tag"); + } + @TestRail(section = { "rest-api", "tags" }, executionType = ExecutionType.SANITY, description = "Verify admin user adds tags with Rest API and status code is 201") public void adminIsAbleToAddTag() throws JsonToModelConversionException, Exception { - tagValue = RandomData.getRandomName("tag"); restClient.authenticateUser(adminUserModel); tagsAPI.addTag(document, tagValue).assertTagIs(tagValue); tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); - + } @TestRail(section = { "rest-api", "tags" }, executionType = ExecutionType.SANITY, description = "Verify Manager user adds tags with Rest API and status code is 201") public void managerIsAbleToAddTag() throws JsonToModelConversionException, Exception { - tagValue = RandomData.getRandomName("tag"); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); tagsAPI.addTag(document, tagValue).assertTagIs(tagValue); tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); @@ -70,7 +78,6 @@ public class AddTagSanityTests extends RestTest "tags" }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user adds tags with Rest API and status code is 201") public void collaboratorIsAbleToAddTag() throws JsonToModelConversionException, Exception { - tagValue = RandomData.getRandomName("tag"); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); tagsAPI.addTag(document, tagValue).assertTagIs(tagValue); tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); @@ -78,19 +85,28 @@ public class AddTagSanityTests extends RestTest @TestRail(section = { "rest-api", "tags" }, executionType = ExecutionType.SANITY, description = "Verify Contributor user doesn't have permission to add tags with Rest API and status code is 403") - public void contributorIsNotAbleToAddTag() throws JsonToModelConversionException, Exception + public void contributorIsNotAbleToAddTagToAnotherContent() throws JsonToModelConversionException, Exception { - tagValue = RandomData.getRandomName("tag"); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); tagsAPI.addTag(document, tagValue); tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } + @TestRail(section = { "rest-api", + "tags" }, executionType = ExecutionType.SANITY, description = "Verify Contributor user adds tags to his content with Rest API and status code is 201") + public void contributorIsAbleToAddTagToHisContent() throws JsonToModelConversionException, Exception + { + userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); + restClient.authenticateUser(userModel); + contributorDoc = dataContent.usingSite(siteModel).usingUser(userModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + tagsAPI.addTag(contributorDoc, tagValue).assertTagIs(tagValue); + tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + } + @TestRail(section = { "rest-api", "tags" }, executionType = ExecutionType.SANITY, description = "Verify Consumer user doesn't have permission to add tags with Rest API and status code is 403") public void consumerIsNotAbleToAddTag() throws JsonToModelConversionException, Exception { - tagValue = RandomData.getRandomName("tag"); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); tagsAPI.addTag(document, tagValue); tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); @@ -98,6 +114,7 @@ public class AddTagSanityTests extends RestTest @TestRail(section = { "rest-api", "tags" }, executionType = ExecutionType.SANITY, description = "Verify Manager user gets status code 401 if authentication call fails") + @Bug(id="MNT-16904") public void managerIsNotAbleToAddTagIfAuthenticationFails() throws JsonToModelConversionException, Exception { UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); From 9c2bfd2c6251b082950669cea560d3d7b570b9d3 Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Thu, 6 Oct 2016 14:40:40 +0300 Subject: [PATCH 0310/1491] TAS-1123 updateSiteMember failed authentication --- .../rest/sites/UpdateSiteMemberSanityTests.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java index 3f2d683b1..a1ca78492 100644 --- a/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java @@ -92,4 +92,15 @@ public class UpdateSiteMemberSanityTests extends RestTest siteAPI.updateSiteMember(siteModel, testUserModel, siteMember); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + @Bug(id="MNT-16904") + @TestRail(section = {"rest-api", "sites" }, executionType = ExecutionType.SANITY, + description = "Verify that unauthenticated user is not able to update site member") + public void unauthenticatedUserIsNotAuthorizedToUpdateSiteMmeber() throws Exception{ + SiteMember siteMember = new SiteMember(Role.SiteConsumer.toString(), testUserModel.getUsername()); + UserModel inexistentUser = new UserModel("inexistent user", "inexistent password"); + restClient.authenticateUser(inexistentUser); + siteAPI.updateSiteMember(siteModel, testUserModel, siteMember); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + } } From 76e08fded2994c76fda3cd1c3e2115449220a39c Mon Sep 17 00:00:00 2001 From: cagache Date: Thu, 6 Oct 2016 14:44:29 +0300 Subject: [PATCH 0311/1491] added scenario for delete tag by contributor --- .../java/org/alfresco/rest/tags/DeleteTagSanityTests.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/tags/DeleteTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/DeleteTagSanityTests.java index 6887082f6..5616e570f 100644 --- a/e2e-test/java/org/alfresco/rest/tags/DeleteTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/DeleteTagSanityTests.java @@ -82,8 +82,8 @@ public class DeleteTagSanityTests extends RestTest tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); } - @TestRail(section = { "rest-api", - "tags" }, executionType = ExecutionType.SANITY, description = "Verify Contributor user can't delete tags created by admin user with Rest API and status code is 403") + @TestRail(section = { "rest-api", "tags" }, + executionType = ExecutionType.SANITY, description = "Verify Contributor user can't delete tags created by admin user with Rest API and status code is 403") public void contributorIsNotAbleToDeleteTagsForAnotherUserContent() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); From 8d6e583b44d586501134965c9e09798f5006bdbd Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Thu, 6 Oct 2016 14:45:19 +0300 Subject: [PATCH 0312/1491] TAS-1187 getSiteMembershipRequests call test with Manager role --- .../GetSiteMembershipRequestsSanityTests.java | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java new file mode 100644 index 000000000..18e10936f --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java @@ -0,0 +1,59 @@ +package org.alfresco.rest.people; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.body.SiteMembershipRequest; +import org.alfresco.rest.requests.RestPeopleApi; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.RandomData; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.social.alfresco.api.entities.Site.Visibility; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Tests for getSiteMembershipRequests (get /people/{personId}/site-membership-requests) RestAPI call + * + * @author Cristina Axinte + */ +@Test(groups = { "rest-api", "people", "sanity" }) +public class GetSiteMembershipRequestsSanityTests extends RestTest +{ + @Autowired + RestPeopleApi peopleApi; + + UserModel userModel; + SiteModel siteModel; + UserModel newMember; + SiteMembershipRequest siteMembershipRequest; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + String siteId = RandomData.getRandomName("site"); + siteModel = dataSite.usingUser(userModel).createSite(new SiteModel(Visibility.PRIVATE, siteId, siteId, siteId, siteId)); + newMember = dataUser.createRandomTestUser(); + siteMembershipRequest = new SiteMembershipRequest("Please accept me", siteModel.getId(), "New request"); + + peopleApi.useRestClient(restClient); + } + + @Bug(id = "MNT-16557") + @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify manager user gets all site membership requests of a specific person with Rest API and response is successful (200)") + public void managerUserGetsSiteMembershipRequestsWithSuccess() throws Exception + { + UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); + restClient.authenticateUser(managerUser); + peopleApi.addSiteMembershipRequest(newMember, siteMembershipRequest); + + peopleApi.getSiteMembershipRequests(newMember).assertEntriesListIsNotEmpty(); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } +} From 9c419b7864428abf32629de2c4f3ca6d143fe7ef Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Thu, 6 Oct 2016 15:03:53 +0300 Subject: [PATCH 0313/1491] TAS-1153 addSiteMember using a site manager --- .../rest/sites/AddSiteMemberSanityTests.java | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java new file mode 100644 index 000000000..f2e8b2ad9 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java @@ -0,0 +1,50 @@ +package org.alfresco.rest.sites; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.body.SiteMember; +import org.alfresco.rest.requests.RestSitesApi; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.social.alfresco.api.entities.Role; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +@Test(groups = { "rest-api", "sites", "sanity" }) +public class AddSiteMemberSanityTests extends RestTest +{ + @Autowired + RestSitesApi siteAPI; + + private UserModel adminUserModel; + private SiteModel siteModel; + private ListUserWithRoles usersWithRoles; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + siteAPI.useRestClient(restClient); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + + } + + @TestRail(section = {"rest-api", "sites" }, executionType = ExecutionType.SANITY, + description = "Verify that manager is able to update site member and gets status code OK (200)") + public void managerIsAbleToAddSiteMember() throws Exception + { + UserModel newUser = dataUser.createRandomTestUser(); + SiteMember siteMember = new SiteMember(Role.SiteConsumer.toString(), newUser.getUsername()); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + siteAPI.addPerson(siteModel, siteMember); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + } +} From d2dc693aa415929e12050d138f5627f1f51e8406 Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Thu, 6 Oct 2016 15:06:06 +0300 Subject: [PATCH 0314/1491] TAS-1154 addSiteMember using a collaborator user --- .../rest/sites/AddSiteMemberSanityTests.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java index f2e8b2ad9..13a51891f 100644 --- a/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java @@ -38,7 +38,7 @@ public class AddSiteMemberSanityTests extends RestTest } @TestRail(section = {"rest-api", "sites" }, executionType = ExecutionType.SANITY, - description = "Verify that manager is able to update site member and gets status code OK (200)") + description = "Verify that manager is able to add site member and gets status code CREATED (201)") public void managerIsAbleToAddSiteMember() throws Exception { UserModel newUser = dataUser.createRandomTestUser(); @@ -47,4 +47,15 @@ public class AddSiteMemberSanityTests extends RestTest siteAPI.addPerson(siteModel, siteMember); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } + + @TestRail(section = {"rest-api", "sites" }, executionType = ExecutionType.SANITY, + description = "Verify that site collaborator is not able to add site member and gets status code FORBIDDEN (403)") + public void collaboratorIsNotAbleToAddSiteMember() throws Exception + { + UserModel newUser = dataUser.createRandomTestUser(); + SiteMember siteMember = new SiteMember(Role.SiteConsumer.toString(), newUser.getUsername()); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + siteAPI.addPerson(siteModel, siteMember); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + } } From 9514a5ccb37654fdac5077e909607f28b162422a Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Thu, 6 Oct 2016 15:07:12 +0300 Subject: [PATCH 0315/1491] TAS-1155 addSiteMember using a contributor user --- .../alfresco/rest/sites/AddSiteMemberSanityTests.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java index 13a51891f..b98d96e9f 100644 --- a/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java @@ -58,4 +58,15 @@ public class AddSiteMemberSanityTests extends RestTest siteAPI.addPerson(siteModel, siteMember); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } + + @TestRail(section = {"rest-api", "sites" }, executionType = ExecutionType.SANITY, + description = "Verify that site contributor is not able to add site member and gets status code FORBIDDEN (403)") + public void contributorIsNotAbleToAddSiteMember() throws Exception + { + UserModel newUser = dataUser.createRandomTestUser(); + SiteMember siteMember = new SiteMember(Role.SiteConsumer.toString(), newUser.getUsername()); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + siteAPI.addPerson(siteModel, siteMember); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + } } From 795efd077469520eb3fb3c51a0da3871ebb698fc Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Thu, 6 Oct 2016 15:08:19 +0300 Subject: [PATCH 0316/1491] TAS-1156 addSiteMember using a consumer user --- .../alfresco/rest/sites/AddSiteMemberSanityTests.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java index b98d96e9f..09ba75f28 100644 --- a/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java @@ -69,4 +69,15 @@ public class AddSiteMemberSanityTests extends RestTest siteAPI.addPerson(siteModel, siteMember); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } + + @TestRail(section = {"rest-api", "sites" }, executionType = ExecutionType.SANITY, + description = "Verify that site consumer is not able to add site member and gets status code FORBIDDEN (403)") + public void consumerIsNotAbleToAddSiteMember() throws Exception + { + UserModel newUser = dataUser.createRandomTestUser(); + SiteMember siteMember = new SiteMember(Role.SiteConsumer.toString(), newUser.getUsername()); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + siteAPI.addPerson(siteModel, siteMember); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + } } From 1d02db6a8f3db510a4eeee0853d152954491db3f Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Thu, 6 Oct 2016 15:09:17 +0300 Subject: [PATCH 0317/1491] TAS-1157 addSiteMember using admin user --- .../alfresco/rest/sites/AddSiteMemberSanityTests.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java index 09ba75f28..8e8d81a50 100644 --- a/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java @@ -80,4 +80,15 @@ public class AddSiteMemberSanityTests extends RestTest siteAPI.addPerson(siteModel, siteMember); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } + + @TestRail(section = {"rest-api", "sites" }, executionType = ExecutionType.SANITY, + description = "Verify that admin user is able to add site member and gets status code CREATED (201)") + public void adminIsAbleToAddSiteMember() throws Exception + { + UserModel newUser = dataUser.createRandomTestUser(); + SiteMember siteMember = new SiteMember(Role.SiteConsumer.toString(), newUser.getUsername()); + restClient.authenticateUser(adminUserModel); + siteAPI.addPerson(siteModel, siteMember); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + } } From a412b427120eb2d60dd492374f6e9e9fc00656ca Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Thu, 6 Oct 2016 15:10:34 +0300 Subject: [PATCH 0318/1491] TAS-1158 addSiteMember failed authentication --- .../rest/sites/AddSiteMemberSanityTests.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java index 8e8d81a50..26a8b26cd 100644 --- a/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java @@ -91,4 +91,16 @@ public class AddSiteMemberSanityTests extends RestTest siteAPI.addPerson(siteModel, siteMember); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } + + @Bug(id="MNT-16904") + @TestRail(section = {"rest-api", "sites" }, executionType = ExecutionType.SANITY, + description = "Verify that unauthenticated user is not able to add site member") + public void unauthenticatedUserIsNotAuthorizedToAddSiteMmeber() throws Exception{ + UserModel newUser = dataUser.createRandomTestUser(); + SiteMember siteMember = new SiteMember(Role.SiteConsumer.toString(), newUser.getUsername()); + UserModel inexistentUser = new UserModel("inexistent user", "inexistent password"); + restClient.authenticateUser(inexistentUser); + siteAPI.addPerson(siteModel, siteMember); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + } } From 0302506377227d8bbec001009b8279cff6cd6a6c Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Thu, 6 Oct 2016 15:12:55 +0300 Subject: [PATCH 0319/1491] TAS-1207 REST API - valid request returns success status code 200 with Manager role --- .../rest/ratings/GetRatingSanityTests.java | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java new file mode 100644 index 000000000..09981e659 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java @@ -0,0 +1,83 @@ +package org.alfresco.rest.ratings; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.body.FiveStarRatingBody; +import org.alfresco.rest.body.LikeRatingBody; +import org.alfresco.rest.requests.RestRatingsApi; +import org.alfresco.utility.constants.Rating; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.exception.DataPreparationException; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +@Test(groups = { "rest-api", "ratings", "sanity" }) +public class GetRatingSanityTests extends RestTest +{ + @Autowired + RestRatingsApi ratingsApi; + + private UserModel userModel; + private SiteModel siteModel; + private UserModel adminUser; + private FolderModel folderModel; + private FileModel document; + private LikeRatingBody likeRating; + private FiveStarRatingBody fiveStarRating; + private ListUserWithRoles usersWithRoles; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws DataPreparationException + { + // userModel = dataUser.createRandomTestUser(); + adminUser = dataUser.getAdminUser(); + siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); + + ratingsApi.useRestClient(restClient); + + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, + UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + + likeRating = new LikeRatingBody(Rating.likes, true); + fiveStarRating = new FiveStarRatingBody(Rating.fiveStar, 5); + } + + @BeforeMethod() + public void setUp() throws DataPreparationException, Exception { + folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + } + + @TestRail(section = {"rest-api", "ratings" }, executionType = ExecutionType.SANITY, + description = "Verify user with Manager role is able to retrieve rating of a document") + public void managerIsAbleToRetrieveRating() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + + ratingsApi.likeDocument(document, likeRating); + ratingsApi.rateStarsToDocument(document, fiveStarRating); + + ratingsApi.getLikeRating(document) + .assertLikeRatingExists() + .assertMyLikeRatingIs(Boolean.TRUE); + ratingsApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.OK); + + ratingsApi.getFiveStarRating(document) + .assertFiveStarRatingExists() + .assertMyFiveStarRatingIs(5); + ratingsApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.OK); + } + +} \ No newline at end of file From 0f9fed5c4ad5289b7fce7d8194b78f734a7c8ab7 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Thu, 6 Oct 2016 15:14:14 +0300 Subject: [PATCH 0320/1491] TAS-1208 REST API - valid request returns success status code 200 with Collaborator role --- .../rest/ratings/GetRatingSanityTests.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java index 09981e659..435557f5b 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java @@ -80,4 +80,26 @@ public class GetRatingSanityTests extends RestTest .assertStatusCodeIs(HttpStatus.OK); } + @TestRail(section = {"rest-api", "ratings" }, executionType = ExecutionType.SANITY, + description = "Verify user with Collaborator role is able to retrieve rating of a document") + public void collaboratorIsAbleToRetrieveRating() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + + ratingsApi.likeDocument(document, likeRating); + ratingsApi.rateStarsToDocument(document, fiveStarRating); + + ratingsApi.getLikeRating(document) + .assertLikeRatingExists() + .assertMyLikeRatingIs(Boolean.TRUE); + ratingsApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.OK); + + ratingsApi.getFiveStarRating(document) + .assertFiveStarRatingExists() + .assertMyFiveStarRatingIs(5); + ratingsApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.OK); + } + } \ No newline at end of file From 6739209493d6df3632ab7e2433d4bcd7cc165849 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Thu, 6 Oct 2016 15:15:47 +0300 Subject: [PATCH 0321/1491] TAS-1209 REST API - valid request returns success status code 200 with Contributor role --- .../rest/ratings/GetRatingSanityTests.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java index 435557f5b..eaaafc6e3 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java @@ -102,4 +102,26 @@ public class GetRatingSanityTests extends RestTest .assertStatusCodeIs(HttpStatus.OK); } + @TestRail(section = {"rest-api", "ratings" }, executionType = ExecutionType.SANITY, + description = "Verify user with Contributor role is able to retrieve rating of a document") + public void contributorIsAbleToRetrieveRating() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + + ratingsApi.likeDocument(document, likeRating); + ratingsApi.rateStarsToDocument(document, fiveStarRating); + + ratingsApi.getLikeRating(document) + .assertLikeRatingExists() + .assertMyLikeRatingIs(Boolean.TRUE); + ratingsApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.OK); + + ratingsApi.getFiveStarRating(document) + .assertFiveStarRatingExists() + .assertMyFiveStarRatingIs(5); + ratingsApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.OK); + } + } \ No newline at end of file From 1ca6041c355c6522fcc7fa43186fde58e1505554 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Thu, 6 Oct 2016 15:17:12 +0300 Subject: [PATCH 0322/1491] TAS-1210 REST API - valid request returns success status code 200 with Consumer role --- .../rest/ratings/GetRatingSanityTests.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java index eaaafc6e3..b2f442cde 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java @@ -124,4 +124,26 @@ public class GetRatingSanityTests extends RestTest .assertStatusCodeIs(HttpStatus.OK); } + @TestRail(section = {"rest-api", "ratings" }, executionType = ExecutionType.SANITY, + description = "Verify user with Consumer role is able to retrieve rating of a document") + public void consumerIsAbleToRetrieveRating() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + + ratingsApi.likeDocument(document, likeRating); + ratingsApi.rateStarsToDocument(document, fiveStarRating); + + ratingsApi.getLikeRating(document) + .assertLikeRatingExists() + .assertMyLikeRatingIs(Boolean.TRUE); + ratingsApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.OK); + + ratingsApi.getFiveStarRating(document) + .assertFiveStarRatingExists() + .assertMyFiveStarRatingIs(5); + ratingsApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.OK); + } + } \ No newline at end of file From e56acc9d84e5cc7d0852ab6392f55786d74ba123 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Thu, 6 Oct 2016 16:16:22 +0300 Subject: [PATCH 0323/1491] TAS-1188 getSiteMembershipRequests failed call test with Collaborator role --- .../GetSiteMembershipRequestsSanityTests.java | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java index 18e10936f..74d7eb694 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java @@ -37,9 +37,13 @@ public class GetSiteMembershipRequestsSanityTests extends RestTest { userModel = dataUser.createRandomTestUser(); String siteId = RandomData.getRandomName("site"); - siteModel = dataSite.usingUser(userModel).createSite(new SiteModel(Visibility.PRIVATE, siteId, siteId, siteId, siteId)); + siteModel = dataSite.usingUser(userModel).createSite(new SiteModel(Visibility.MODERATED, siteId, siteId, siteId, siteId)); newMember = dataUser.createRandomTestUser(); siteMembershipRequest = new SiteMembershipRequest("Please accept me", siteModel.getId(), "New request"); + restClient.authenticateUser(newMember); + peopleApi.useRestClient(restClient); + peopleApi.addSiteMembershipRequest(newMember, siteMembershipRequest); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); peopleApi.useRestClient(restClient); } @@ -50,10 +54,21 @@ public class GetSiteMembershipRequestsSanityTests extends RestTest { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); + restClient.authenticateUser(managerUser); - peopleApi.addSiteMembershipRequest(newMember, siteMembershipRequest); - peopleApi.getSiteMembershipRequests(newMember).assertEntriesListIsNotEmpty(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + @Bug(id = "MNT-16557") + @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify collaborator user fails to get all site membership requests of another user with Rest API (403)") + public void collaboratorUserFailsToGetSiteMembershipRequestsOfAnotherUser() throws Exception + { + UserModel collaboratorrUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(collaboratorrUser, siteModel, UserRole.SiteCollaborator); + + restClient.authenticateUser(collaboratorrUser); + peopleApi.getSiteMembershipRequests(newMember).assertEntriesListIsNotEmpty(); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + } } From 742c9e7720210fd05e4c11867d64506e25e69f4b Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Thu, 6 Oct 2016 16:21:53 +0300 Subject: [PATCH 0324/1491] TAS-1189 getSiteMembershipRequests call test with Contributor role --- .../GetSiteMembershipRequestsSanityTests.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java index 74d7eb694..72fee49df 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java @@ -64,10 +64,22 @@ public class GetSiteMembershipRequestsSanityTests extends RestTest @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify collaborator user fails to get all site membership requests of another user with Rest API (403)") public void collaboratorUserFailsToGetSiteMembershipRequestsOfAnotherUser() throws Exception { - UserModel collaboratorrUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(collaboratorrUser, siteModel, UserRole.SiteCollaborator); + UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(collaboratorUser, siteModel, UserRole.SiteCollaborator); - restClient.authenticateUser(collaboratorrUser); + restClient.authenticateUser(collaboratorUser); + peopleApi.getSiteMembershipRequests(newMember).assertEntriesListIsNotEmpty(); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + } + + @Bug(id = "MNT-16557") + @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify contributor user fails to get all site membership requests of another user with Rest API (403)") + public void contributorUserFailsToGetSiteMembershipRequestsOfAnotherUser() throws Exception + { + UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(contributorUser, siteModel, UserRole.SiteContributor); + + restClient.authenticateUser(contributorUser); peopleApi.getSiteMembershipRequests(newMember).assertEntriesListIsNotEmpty(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } From 5698f45ad7276916337fbb4fb88d3c751cc75d43 Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Thu, 6 Oct 2016 16:21:58 +0300 Subject: [PATCH 0325/1491] TAS-1216 fix GetSiteMemberSanityTests --- .../org/alfresco/rest/sites/GetSiteMemberSanityTests.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java index 38eb23a6e..874047c7a 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java @@ -4,8 +4,6 @@ import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.requests.RestSitesApi; import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataSite; -import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.SiteModel; @@ -40,6 +38,8 @@ public class GetSiteMemberSanityTests extends RestTest siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + userModel = dataUser.createRandomTestUser(); + dataUser.addUserToSite(userModel, siteModel, UserRole.SiteConsumer); } @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, From 174cd50d0af4ace590b43de93c10e466379f5dc7 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Thu, 6 Oct 2016 16:25:12 +0300 Subject: [PATCH 0326/1491] TAS-1190 getSiteMembershipRequests failed call test with Consumer role --- .../GetSiteMembershipRequestsSanityTests.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java index 72fee49df..f97902375 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java @@ -68,7 +68,7 @@ public class GetSiteMembershipRequestsSanityTests extends RestTest dataUser.usingUser(userModel).addUserToSite(collaboratorUser, siteModel, UserRole.SiteCollaborator); restClient.authenticateUser(collaboratorUser); - peopleApi.getSiteMembershipRequests(newMember).assertEntriesListIsNotEmpty(); + peopleApi.getSiteMembershipRequests(newMember); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } @@ -80,7 +80,19 @@ public class GetSiteMembershipRequestsSanityTests extends RestTest dataUser.usingUser(userModel).addUserToSite(contributorUser, siteModel, UserRole.SiteContributor); restClient.authenticateUser(contributorUser); - peopleApi.getSiteMembershipRequests(newMember).assertEntriesListIsNotEmpty(); + peopleApi.getSiteMembershipRequests(newMember); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + } + + @Bug(id = "MNT-16557") + @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify consumer user fails to get all site membership requests of another user with Rest API (403)") + public void consumerUserFailsToGetSiteMembershipRequestsOfAnotherUser() throws Exception + { + UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel, UserRole.SiteContributor); + + restClient.authenticateUser(consumerUser); + peopleApi.getSiteMembershipRequests(newMember); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } } From 5dbc2c143241dac4e465550204e850ec19d4830a Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Thu, 6 Oct 2016 16:30:09 +0300 Subject: [PATCH 0327/1491] TAS-1211 REST API - valid request returns success status code 200 with admin user --- .../rest/ratings/GetRatingSanityTests.java | 30 ++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java index b2f442cde..aff8888e4 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java @@ -27,7 +27,6 @@ public class GetRatingSanityTests extends RestTest @Autowired RestRatingsApi ratingsApi; - private UserModel userModel; private SiteModel siteModel; private UserModel adminUser; private FolderModel folderModel; @@ -39,7 +38,6 @@ public class GetRatingSanityTests extends RestTest @BeforeClass(alwaysRun=true) public void dataPreparation() throws DataPreparationException { - // userModel = dataUser.createRandomTestUser(); adminUser = dataUser.getAdminUser(); siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); @@ -54,8 +52,8 @@ public class GetRatingSanityTests extends RestTest @BeforeMethod() public void setUp() throws DataPreparationException, Exception { - folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); } @TestRail(section = {"rest-api", "ratings" }, executionType = ExecutionType.SANITY, @@ -146,4 +144,28 @@ public class GetRatingSanityTests extends RestTest .assertStatusCodeIs(HttpStatus.OK); } + @TestRail(section = {"rest-api", "ratings" }, executionType = ExecutionType.SANITY, + description = "Verify admin user is able to retrieve rating of a document") + public void adminIsAbleToRetrieveRating() throws Exception + { + document = dataContent.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(adminUser); + ratingsApi.likeDocument(document, likeRating); + ratingsApi.rateStarsToDocument(document, fiveStarRating); + + + ratingsApi.getLikeRating(document) + .assertLikeRatingExists() + .assertMyLikeRatingIs(Boolean.TRUE); + ratingsApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.OK); + + ratingsApi.getFiveStarRating(document) + .assertFiveStarRatingExists() + .assertMyFiveStarRatingIs(5); + ratingsApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.OK); + } + } \ No newline at end of file From 7fa45a48e9c241ce41517a98e0fbdda9b0fc3074 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Thu, 6 Oct 2016 16:33:00 +0300 Subject: [PATCH 0328/1491] TAS-1191 getSiteMembershipRequests call test with admin user --- .../GetSiteMembershipRequestsSanityTests.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java index f97902375..9b0460e64 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java @@ -40,8 +40,8 @@ public class GetSiteMembershipRequestsSanityTests extends RestTest siteModel = dataSite.usingUser(userModel).createSite(new SiteModel(Visibility.MODERATED, siteId, siteId, siteId, siteId)); newMember = dataUser.createRandomTestUser(); siteMembershipRequest = new SiteMembershipRequest("Please accept me", siteModel.getId(), "New request"); - restClient.authenticateUser(newMember); peopleApi.useRestClient(restClient); + restClient.authenticateUser(newMember); peopleApi.addSiteMembershipRequest(newMember, siteMembershipRequest); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); @@ -89,10 +89,21 @@ public class GetSiteMembershipRequestsSanityTests extends RestTest public void consumerUserFailsToGetSiteMembershipRequestsOfAnotherUser() throws Exception { UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel, UserRole.SiteContributor); + dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel, UserRole.SiteConsumer); restClient.authenticateUser(consumerUser); peopleApi.getSiteMembershipRequests(newMember); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } + + @Bug(id = "MNT-16557") + @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify admin user gets all site membership requests of a specific person with Rest API and response is successful (200)") + public void adminUserGetsSiteMembershipRequestsWithSuccess() throws Exception + { + UserModel adminUser = dataUser.getAdminUser(); + + restClient.authenticateUser(adminUser); + peopleApi.getSiteMembershipRequests(newMember).assertEntriesListIsNotEmpty(); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } } From b2331e66ae7636689d52c1895fd53de85641e281 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Thu, 6 Oct 2016 16:37:03 +0300 Subject: [PATCH 0329/1491] TAS-1212 REST API - failed authentication call returns status code 401 --- .../rest/ratings/GetRatingSanityTests.java | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java index aff8888e4..c4bec69ce 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java @@ -13,6 +13,7 @@ import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.beans.factory.annotation.Autowired; @@ -154,7 +155,6 @@ public class GetRatingSanityTests extends RestTest ratingsApi.likeDocument(document, likeRating); ratingsApi.rateStarsToDocument(document, fiveStarRating); - ratingsApi.getLikeRating(document) .assertLikeRatingExists() .assertMyLikeRatingIs(Boolean.TRUE); @@ -168,4 +168,23 @@ public class GetRatingSanityTests extends RestTest .assertStatusCodeIs(HttpStatus.OK); } + @TestRail(section = {"rest-api", "ratings" }, executionType = ExecutionType.SANITY, + description = "Verify unauthenticated user is not able to retrieve rating of a document") + @Bug(id = "MNT-16904") + public void unauthenticatedUserIsNotAbleToRetrieveRating() throws Exception + { + restClient.authenticateUser(adminUser); + ratingsApi.likeDocument(document, likeRating); + ratingsApi.rateStarsToDocument(document, fiveStarRating); + + restClient.authenticateUser(new UserModel("random user", "random password")); + + ratingsApi.getLikeRating(document); + ratingsApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + + ratingsApi.getFiveStarRating(document); + ratingsApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + } } \ No newline at end of file From 881c809924707707a265193414278e3ab1f27b6b Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Thu, 6 Oct 2016 16:41:37 +0300 Subject: [PATCH 0330/1491] TAS-1192 getSiteMembershipRequests failed call tests with Manager role --- .../GetSiteMembershipRequestsSanityTests.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java index 9b0460e64..b374720f3 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java @@ -106,4 +106,17 @@ public class GetSiteMembershipRequestsSanityTests extends RestTest peopleApi.getSiteMembershipRequests(newMember).assertEntriesListIsNotEmpty(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + @Bug(id = "MNT-16904") + @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify manager user fails to get all site membership requests of a specific person with Rest API when the authentication fails (401)") + public void managerUserNotAuthorizedFailsToGetSiteMembershipRequests() throws Exception + { + UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); + managerUser.setPassword("newpassword"); + + restClient.authenticateUser(managerUser); + peopleApi.getSiteMembershipRequests(newMember); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } } From 04ca74aa0e0859706906fa3bcd865c6a397ed9f4 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Thu, 6 Oct 2016 16:51:20 +0300 Subject: [PATCH 0331/1491] refactored and pushed Tas 707 --- .../favorites/GetFavoritesSanityTests.java | 55 ++++++++++--------- .../PostFavoritesSanityTests.java | 2 +- 2 files changed, 29 insertions(+), 28 deletions(-) rename e2e-test/java/org/alfresco/rest/{Favorites => favorites}/PostFavoritesSanityTests.java (97%) diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java index 47ff9a6df..9507f2644 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java @@ -5,13 +5,13 @@ import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.requests.RestFavoritesApi; import org.alfresco.rest.requests.RestSitesApi; -import org.alfresco.utility.constants.SpecificParametersForFavorites; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.beans.factory.annotation.Autowired; @@ -63,9 +63,9 @@ public class GetFavoritesSanityTests extends RestTest "favorites" }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets favorites sites with Rest API and status code is 200") public void adminIsAbleToRetrieveFavoritesSites() throws JsonToModelConversionException, Exception { - favoritesAPI.addUserFavorites(adminUserModel, firstSiteModel); - favoritesAPI.addUserFavorites(adminUserModel, secondSiteModel); - favoritesAPI.getUserFavorites(adminUserModel, SpecificParametersForFavorites.SITE.toString()); + favoritesAPI.addSiteToFavorites(adminUserModel, firstSiteModel); + favoritesAPI.addSiteToFavorites(adminUserModel, secondSiteModel); + favoritesAPI.where().targetSiteExist().filterAnd().getFavorites(adminUserModel); favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -73,9 +73,9 @@ public class GetFavoritesSanityTests extends RestTest "favorites" }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets favorites folders with Rest API and status code is 200") public void adminIsAbleToRetrieveFavoritesFolders() throws JsonToModelConversionException, Exception { - favoritesAPI.addUserFavorites(adminUserModel, firstFolderModel); - favoritesAPI.addUserFavorites(adminUserModel, secondFolderModel); - favoritesAPI.getUserFavorites(adminUserModel, SpecificParametersForFavorites.FOLDER.toString()); + favoritesAPI.addFolderToFavorites(adminUserModel, firstFolderModel); + favoritesAPI.addFolderToFavorites(adminUserModel, secondFolderModel); + favoritesAPI.where().targetFolderExist().filterAnd().getFavorites(adminUserModel); favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -83,9 +83,9 @@ public class GetFavoritesSanityTests extends RestTest "favorites" }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets favorites files with Rest API and status code is 200") public void adminIsAbleToRetrieveFavoritesFiles() throws JsonToModelConversionException, Exception { - favoritesAPI.addUserFavorites(adminUserModel, firstFileModel); - favoritesAPI.addUserFavorites(adminUserModel, secondFileModel); - favoritesAPI.getUserFavorites(adminUserModel, SpecificParametersForFavorites.FILE.toString()); + favoritesAPI.addFileToFavorites(adminUserModel, firstFileModel); + favoritesAPI.addFileToFavorites(adminUserModel, secondFileModel); + favoritesAPI.where().targetFileExist().filterAnd().getFavorites(adminUserModel); favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -94,9 +94,9 @@ public class GetFavoritesSanityTests extends RestTest public void managerIsAbleToRetrieveFavorites() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - favoritesAPI.addUserFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteManager), firstSiteModel); - favoritesAPI.addUserFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteManager), secondSiteModel); - favoritesAPI.getUserFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteManager), SpecificParametersForFavorites.SITE.toString()); + favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteManager), firstSiteModel); + favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteManager), secondSiteModel); + favoritesAPI.where().targetSiteExist().filterAnd().getFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -105,9 +105,9 @@ public class GetFavoritesSanityTests extends RestTest public void collaboratorIsAbleToRetrieveFavorites() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - favoritesAPI.addUserFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), firstSiteModel); - favoritesAPI.addUserFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), secondSiteModel); - favoritesAPI.getUserFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), SpecificParametersForFavorites.SITE.toString()); + favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), firstSiteModel); + favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), secondSiteModel); + favoritesAPI.where().targetSiteExist().filterAnd().getFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -116,9 +116,9 @@ public class GetFavoritesSanityTests extends RestTest public void contributorIsAbleToRetrieveFavorites() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - favoritesAPI.addUserFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor), firstSiteModel); - favoritesAPI.addUserFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor), secondSiteModel); - favoritesAPI.getUserFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor), SpecificParametersForFavorites.SITE.toString()); + favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor), firstSiteModel); + favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor), secondSiteModel); + favoritesAPI.where().targetSiteExist().filterAnd().getFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -127,9 +127,9 @@ public class GetFavoritesSanityTests extends RestTest public void consumerIsAbleToRetrieveFavorites() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - favoritesAPI.addUserFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer), firstSiteModel); - favoritesAPI.addUserFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer), secondSiteModel); - favoritesAPI.getUserFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer), SpecificParametersForFavorites.SITE.toString()); + favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer), firstSiteModel); + favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer), secondSiteModel); + favoritesAPI.where().targetSiteExist().filterAnd().getFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -138,7 +138,7 @@ public class GetFavoritesSanityTests extends RestTest public void userIsNotAbleToRetrieveFavoritesOfAnotherUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - favoritesAPI.getUserFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), SpecificParametersForFavorites.SITE.toString()); + favoritesAPI.where().targetSiteExist().filterAnd().getFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); } @@ -147,7 +147,7 @@ public class GetFavoritesSanityTests extends RestTest public void userIsNotAbleToRetrieveFavoritesOfAdminUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - favoritesAPI.getUserFavorites(adminUserModel, SpecificParametersForFavorites.SITE.toString()); + favoritesAPI.where().targetSiteExist().filterAnd().getFavorites(adminUserModel); favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); } @@ -156,19 +156,20 @@ public class GetFavoritesSanityTests extends RestTest public void adminIsNotAbleToRetrieveFavoritesOfAnotherUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); - favoritesAPI.getUserFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), SpecificParametersForFavorites.SITE.toString()); + favoritesAPI.where().targetSiteExist().filterAnd().getFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); } @TestRail(section = { "rest-api", "favorites" }, executionType = ExecutionType.SANITY, description = "Verify user gets status code 401 if authentication call fails") + @Bug(id="MNT-16904") public void userIsNotAbleToRetrieveFavoritesIfAuthenticationFails() throws JsonToModelConversionException, Exception { UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); siteManager.setPassword("wrongPassword"); restClient.authenticateUser(siteManager); - favoritesAPI.addUserFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteManager), firstSiteModel); - favoritesAPI.addUserFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteManager), secondSiteModel); + favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteManager), firstSiteModel); + favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteManager), secondSiteModel); favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/Favorites/PostFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/PostFavoritesSanityTests.java similarity index 97% rename from e2e-test/java/org/alfresco/rest/Favorites/PostFavoritesSanityTests.java rename to e2e-test/java/org/alfresco/rest/favorites/PostFavoritesSanityTests.java index f51f21673..09d3c126c 100644 --- a/e2e-test/java/org/alfresco/rest/Favorites/PostFavoritesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/PostFavoritesSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.Favorites; +package org.alfresco.rest.favorites; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; From 2c9f162501d8c3ebba33ceaeba94eed3ce7eba07 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Thu, 6 Oct 2016 16:59:14 +0300 Subject: [PATCH 0332/1491] TAS-1217 getSiteMembershipRequests call test with itself --- .../rest/people/GetSiteMembershipRequestsSanityTests.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java index b374720f3..3f77ae31a 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java @@ -119,4 +119,12 @@ public class GetSiteMembershipRequestsSanityTests extends RestTest peopleApi.getSiteMembershipRequests(newMember); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify a user gets all its own site membership requests with Rest API and response is successful (200)") + public void oneUserGetsItsOwnSiteMembershipRequestsWithSuccess() throws Exception + { + restClient.authenticateUser(newMember); + peopleApi.getSiteMembershipRequests(newMember).assertEntriesListIsNotEmpty(); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } } From 0597686c21b99725e48412671abf856f444a3bd5 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Thu, 6 Oct 2016 17:19:36 +0300 Subject: [PATCH 0333/1491] refactor & push 710 to master --- .../rest/ratings/AddRatingSanityTests.java | 173 +++++++----------- .../rest/ratings/GetRatingSanityTests.java | 80 ++++---- .../rest/tags/DeleteTagSanityTests.java | 2 - 3 files changed, 99 insertions(+), 156 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java index 80515f719..db14b1ff3 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java @@ -2,10 +2,7 @@ package org.alfresco.rest.ratings; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; -import org.alfresco.rest.body.FiveStarRatingBody; -import org.alfresco.rest.body.LikeRatingBody; import org.alfresco.rest.requests.RestRatingsApi; -import org.alfresco.utility.constants.Rating; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.exception.DataPreparationException; @@ -34,170 +31,134 @@ public class AddRatingSanityTests extends RestTest private UserModel adminUser; private FolderModel folderModel; private FileModel document; - private LikeRatingBody likeRating; - private FiveStarRatingBody fiveStarRating; private ListUserWithRoles usersWithRoles; - - @BeforeClass(alwaysRun=true) + + @BeforeClass(alwaysRun = true) public void dataPreparation() throws DataPreparationException { userModel = dataUser.createUser(RandomStringUtils.randomAlphanumeric(20)); adminUser = dataUser.getAdminUser(); siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); ratingsApi.useRestClient(restClient); - - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); } - + @BeforeMethod - public void setUp() throws Exception { + public void setUp() throws Exception + { folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); } - @TestRail(section = {"rest-api", "ratings" }, executionType = ExecutionType.SANITY, - description = "Verify user with Manager role is able to post like rating to a document") + @TestRail(section = { "rest-api", + "ratings" }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role is able to post like rating to a document") public void managerIsAbleToLikeDocument() throws Exception { - likeRating = new LikeRatingBody(Rating.fiveStar, true); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - ratingsApi.likeDocument(document, likeRating); - ratingsApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.CREATED); + ratingsApi.likeDocument(document); + ratingsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } - - @TestRail(section = {"rest-api", "ratings" }, executionType = ExecutionType.SANITY, - description = "Verify user with Collaborator role is able to post like rating to a document") + + @TestRail(section = { "rest-api", + "ratings" }, executionType = ExecutionType.SANITY, description = "Verify user with Collaborator role is able to post like rating to a document") public void collaboratorIsAbleToLikeDocument() throws Exception { - likeRating = new LikeRatingBody(Rating.likes, true); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - ratingsApi.likeDocument(document, likeRating); - ratingsApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.CREATED); + ratingsApi.likeDocument(document); + ratingsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } - - @TestRail(section = {"rest-api", "ratings" }, executionType = ExecutionType.SANITY, - description = "Verify user with Contributor role is able to post like rating to a document") + + @TestRail(section = { "rest-api", + "ratings" }, executionType = ExecutionType.SANITY, description = "Verify user with Contributor role is able to post like rating to a document") public void contributorIsAbleToLikeDocument() throws Exception { - likeRating = new LikeRatingBody(Rating.likes, true); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - ratingsApi.likeDocument(document, likeRating); - ratingsApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.CREATED); + ratingsApi.likeDocument(document); + ratingsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } - - @TestRail(section = {"rest-api", "ratings" }, executionType = ExecutionType.SANITY, - description = "Verify user with Consumer role is able to post like rating to a document") + + @TestRail(section = { "rest-api", + "ratings" }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role is able to post like rating to a document") public void consumerIsAbleToLikeDocument() throws Exception { - likeRating = new LikeRatingBody(Rating.likes, true); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - ratingsApi.likeDocument(document, likeRating); - ratingsApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.CREATED); + ratingsApi.likeDocument(document); + ratingsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } - - @TestRail(section = {"rest-api", "ratings" }, executionType = ExecutionType.SANITY, - description = "Verify admin user is able to post like rating to a document") + + @TestRail(section = { "rest-api", + "ratings" }, executionType = ExecutionType.SANITY, description = "Verify admin user is able to post like rating to a document") public void adminIsAbleToLikeDocument() throws Exception { - likeRating = new LikeRatingBody(Rating.likes, true); - restClient.authenticateUser(adminUser); - ratingsApi.likeDocument(document, likeRating); - ratingsApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.CREATED); + ratingsApi.likeDocument(document); + ratingsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } - - @TestRail(section = {"rest-api", "ratings" }, executionType = ExecutionType.SANITY, - description = "Verify unauthenticated user is not able to post like rating to a document") + + @TestRail(section = { "rest-api", + "ratings" }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to post like rating to a document") @Bug(id = "MNT-16904") public void unauthenticatedUserIsNotAbleToLikeDocument() throws Exception { - likeRating = new LikeRatingBody(Rating.likes, true); - restClient.authenticateUser(new UserModel("random user", "random password")); - ratingsApi.likeDocument(document, likeRating); - ratingsApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + ratingsApi.likeDocument(document); + ratingsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } - - @TestRail(section = {"rest-api", "ratings" }, executionType = ExecutionType.SANITY, - description = "Verify user with Manager role is able to post stars rating to a document") + + @TestRail(section = { "rest-api", + "ratings" }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role is able to post stars rating to a document") public void managerIsAbleToAddStarsToDocument() throws Exception { - fiveStarRating = new FiveStarRatingBody(Rating.fiveStar, 5); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - ratingsApi.rateStarsToDocument(document, fiveStarRating); - ratingsApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.CREATED); + ratingsApi.rateStarsToDocument(document, 5); + ratingsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } - - @TestRail(section = {"rest-api", "ratings" }, executionType = ExecutionType.SANITY, - description = "Verify user with Collaborator role is able to post stars rating to a document") + + @TestRail(section = { "rest-api", + "ratings" }, executionType = ExecutionType.SANITY, description = "Verify user with Collaborator role is able to post stars rating to a document") public void collaboratorIsAbleToAddStarsToDocument() throws Exception { - fiveStarRating = new FiveStarRatingBody(Rating.fiveStar, 5); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - ratingsApi.rateStarsToDocument(document, fiveStarRating); - ratingsApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.CREATED); + ratingsApi.rateStarsToDocument(document, 5); + ratingsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } - - @TestRail(section = {"rest-api", "ratings" }, executionType = ExecutionType.SANITY, - description = "Verify user with Contributor role is able to post stars rating to a document") + + @TestRail(section = { "rest-api", + "ratings" }, executionType = ExecutionType.SANITY, description = "Verify user with Contributor role is able to post stars rating to a document") public void contributorIsAbleToAddStarsToDocument() throws Exception { - fiveStarRating = new FiveStarRatingBody(Rating.fiveStar, 5); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - ratingsApi.rateStarsToDocument(document, fiveStarRating); - ratingsApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.CREATED); + ratingsApi.rateStarsToDocument(document, 5); + ratingsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } - - @TestRail(section = {"rest-api", "ratings" }, executionType = ExecutionType.SANITY, - description = "Verify user with Consumer role is able to post stars rating to a document") + + @TestRail(section = { "rest-api", + "ratings" }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role is able to post stars rating to a document") public void consumerIsAbleToAddStarsToDocument() throws Exception { - fiveStarRating = new FiveStarRatingBody(Rating.fiveStar, 5); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - ratingsApi.rateStarsToDocument(document, fiveStarRating); - ratingsApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.CREATED); + ratingsApi.rateStarsToDocument(document, 5); + ratingsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } - - @TestRail(section = {"rest-api", "ratings" }, executionType = ExecutionType.SANITY, - description = "Verify admin user is able to post stars rating to a document") + + @TestRail(section = { "rest-api", + "ratings" }, executionType = ExecutionType.SANITY, description = "Verify admin user is able to post stars rating to a document") public void adminIsAbleToAddStarsToDocument() throws Exception { - fiveStarRating = new FiveStarRatingBody(Rating.fiveStar, 5); - restClient.authenticateUser(adminUser); - ratingsApi.rateStarsToDocument(document, fiveStarRating); - ratingsApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.CREATED); + ratingsApi.rateStarsToDocument(document, 5); + ratingsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } - - @TestRail(section = {"rest-api", "ratings" }, executionType = ExecutionType.SANITY, - description = "Verify unauthenticated user is not able to post stars rating to a document") + + @TestRail(section = { "rest-api", + "ratings" }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to post stars rating to a document") @Bug(id = "MNT-16904") public void unauthenticatedUserIsNotAbleToRateStarsToDocument() throws Exception { - fiveStarRating = new FiveStarRatingBody(Rating.fiveStar, 5); - restClient.authenticateUser(new UserModel("random user", "random password")); - ratingsApi.rateStarsToDocument(document, fiveStarRating); - ratingsApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + ratingsApi.rateStarsToDocument(document, 5); + ratingsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java index 3e698b252..85f89ca61 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java @@ -2,10 +2,7 @@ package org.alfresco.rest.ratings; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; -import org.alfresco.rest.body.FiveStarRatingBody; -import org.alfresco.rest.body.LikeRatingBody; import org.alfresco.rest.requests.RestRatingsApi; -import org.alfresco.utility.constants.Rating; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.exception.DataPreparationException; @@ -33,95 +30,82 @@ public class GetRatingSanityTests extends RestTest private UserModel adminUser; private FolderModel folderModel; private FileModel document; - private LikeRatingBody likeRating; - private FiveStarRatingBody fiveStarRating; private ListUserWithRoles usersWithRoles; - - @BeforeClass(alwaysRun=true) + + @BeforeClass(alwaysRun = true) public void dataPreparation() throws DataPreparationException { userModel = dataUser.createUser(RandomStringUtils.randomAlphanumeric(20)); adminUser = dataUser.getAdminUser(); siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); ratingsApi.useRestClient(restClient); - - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); } - + @BeforeClass - public void setUp() throws Exception { + public void setUp() throws Exception + { folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(adminUser); - - likeRating = new LikeRatingBody(Rating.likes, true); - ratingsApi.likeDocument(document, likeRating); - - fiveStarRating = new FiveStarRatingBody(Rating.fiveStar, 5); - ratingsApi.rateStarsToDocument(document, fiveStarRating); - + ratingsApi.likeDocument(document); + ratingsApi.rateStarsToDocument(document, 5); restClient.disconnect(); } - @TestRail(section = {"rest-api", "ratings" }, executionType = ExecutionType.SANITY, - description = "Verify user with Manager role is able to retrieve document ratings") + @TestRail(section = { "rest-api", + "ratings" }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role is able to retrieve document ratings") public void managerIsAbleToRetrieveDocumentRatings() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); ratingsApi.getRatings(document); - ratingsApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.OK); + ratingsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - - @TestRail(section = {"rest-api", "ratings" }, executionType = ExecutionType.SANITY, - description = "Verify user with Collaborator role is able to retrieve document ratings") + + @TestRail(section = { "rest-api", + "ratings" }, executionType = ExecutionType.SANITY, description = "Verify user with Collaborator role is able to retrieve document ratings") public void collaboratorIsAbleToRetrieveDocumentRatings() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); ratingsApi.getRatings(document); - ratingsApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.OK); + ratingsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - - @TestRail(section = {"rest-api", "ratings" }, executionType = ExecutionType.SANITY, - description = "Verify user with Contributor role is able to retrieve document ratings") + + @TestRail(section = { "rest-api", + "ratings" }, executionType = ExecutionType.SANITY, description = "Verify user with Contributor role is able to retrieve document ratings") public void contributorIsAbleToRetrieveDocumentRatings() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); ratingsApi.getRatings(document); - ratingsApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.OK); + ratingsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - - @TestRail(section = {"rest-api", "ratings" }, executionType = ExecutionType.SANITY, - description = "Verify user with Consumer role is able to retrieve document ratings") + + @TestRail(section = { "rest-api", + "ratings" }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role is able to retrieve document ratings") public void consumerIsAbleToRetrieveDocumentRatings() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); ratingsApi.getRatings(document); - ratingsApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.OK); + ratingsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - - @TestRail(section = {"rest-api", "ratings" }, executionType = ExecutionType.SANITY, - description = "Verify admin user is able to retrieve document ratings") + + @TestRail(section = { "rest-api", "ratings" }, executionType = ExecutionType.SANITY, description = "Verify admin user is able to retrieve document ratings") public void adminIsAbleToRetrieveDocumentRatings() throws Exception { restClient.authenticateUser(adminUser); ratingsApi.getRatings(document); - ratingsApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.OK); + ratingsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - - @TestRail(section = {"rest-api", "ratings" }, executionType = ExecutionType.SANITY, - description = "Verify unauthenticated user is not able to retrieve document ratings") + + @TestRail(section = { "rest-api", + "ratings" }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to retrieve document ratings") @Bug(id = "MNT-16904") public void unauthenticatedUserIsNotAbleToRetrieveDocumentRatings() throws Exception { restClient.authenticateUser(new UserModel("random user", "random password")); ratingsApi.getRatings(document); - ratingsApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + ratingsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/tags/DeleteTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/DeleteTagSanityTests.java index 5616e570f..6ce9fe0e1 100644 --- a/e2e-test/java/org/alfresco/rest/tags/DeleteTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/DeleteTagSanityTests.java @@ -7,7 +7,6 @@ import org.alfresco.rest.model.RestTagModel; import org.alfresco.rest.requests.RestTagsApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; -import org.alfresco.utility.data.RandomData; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; @@ -16,7 +15,6 @@ import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; /** From d74a2d0fcf61914c84fec0164268b7df2dd41388 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Thu, 6 Oct 2016 17:54:01 +0300 Subject: [PATCH 0334/1491] Add "Sanity" in test class name and add issue id for @Bug --- ...FavoriteSiteTests.java => AddFavoriteSiteSanityTests.java} | 4 ++-- ...voriteSitesTests.java => GetFavoriteSitesSanityTests.java} | 4 ++-- ...tivitiesTests.java => GetPeopleActivitiesSanityTests.java} | 4 ++-- ...eferenceTests.java => GetPeoplePreferenceSanityTests.java} | 2 +- ...erencesTests.java => GetPeoplePreferencesSanityTests.java} | 4 ++-- .../people/{GetPeopleTests.java => GetPeopleSanityTests.java} | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) rename e2e-test/java/org/alfresco/rest/people/{AddFavoriteSiteTests.java => AddFavoriteSiteSanityTests.java} (98%) rename e2e-test/java/org/alfresco/rest/people/{GetFavoriteSitesTests.java => GetFavoriteSitesSanityTests.java} (98%) rename e2e-test/java/org/alfresco/rest/people/{GetPeopleActivitiesTests.java => GetPeopleActivitiesSanityTests.java} (98%) rename e2e-test/java/org/alfresco/rest/people/{GetPeoplePreferenceTests.java => GetPeoplePreferenceSanityTests.java} (99%) rename e2e-test/java/org/alfresco/rest/people/{GetPeoplePreferencesTests.java => GetPeoplePreferencesSanityTests.java} (98%) rename e2e-test/java/org/alfresco/rest/people/{GetPeopleTests.java => GetPeopleSanityTests.java} (98%) diff --git a/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteTests.java b/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteSanityTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteTests.java rename to e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteSanityTests.java index 59b1b2bd7..d4895a72a 100644 --- a/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteTests.java +++ b/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteSanityTests.java @@ -14,7 +14,7 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @Test(groups = { "rest-api", "people", "sanity" }) -public class AddFavoriteSiteTests extends RestTest +public class AddFavoriteSiteSanityTests extends RestTest { @Autowired RestPeopleApi peopleApi; @@ -86,7 +86,7 @@ public class AddFavoriteSiteTests extends RestTest peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } - @Bug(id = "") + @Bug(id = "MNT-16904") @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify a manager user is NOT Authorized to add a favorite site with Rest API when authentication fails (401)") public void managerUserNotAuthorizedFailsToAddFavoriteSite() throws Exception { diff --git a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesTests.java b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesTests.java rename to e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java index efc1319b7..1e6b1bfa0 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java @@ -14,7 +14,7 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @Test(groups = { "rest-api", "people", "sanity" }) -public class GetFavoriteSitesTests extends RestTest +public class GetFavoriteSitesSanityTests extends RestTest { @Autowired RestPeopleApi peopleApi; @@ -101,7 +101,7 @@ public class GetFavoriteSitesTests extends RestTest peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @Bug(id = "") + @Bug(id = "MNT-16904") @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized to get its favorite sites with Rest API when authentication fails (401)") public void managerUserGetsFavoriteSitesIsNotAuthorized() throws Exception { diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesTests.java rename to e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java index ab02b12c8..c65011c12 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java @@ -21,7 +21,7 @@ import org.testng.annotations.Test; * */ @Test(groups = { "rest-api", "people", "activities", "sanity" }) -public class GetPeopleActivitiesTests extends RestTest +public class GetPeopleActivitiesSanityTests extends RestTest { @Autowired RestPeopleApi peopleApi; @@ -96,7 +96,7 @@ public class GetPeopleActivitiesTests extends RestTest peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @Bug(id = "") + @Bug(id = "MNT-16904") @TestRail(section = { "rest-api", "people", "activities" }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized to gets another user activities with Rest API") public void managerUserShouldGetPeopleActivitiesListIsNotAuthorized() throws Exception { diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceTests.java rename to e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceSanityTests.java index fe2bf9455..80bb706af 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceSanityTests.java @@ -21,7 +21,7 @@ import org.testng.annotations.Test; * */ @Test(groups = { "rest-api", "people", "preferences", "sanity" }) -public class GetPeoplePreferenceTests extends RestTest +public class GetPeoplePreferenceSanityTests extends RestTest { @Autowired RestPeopleApi peopleApi; diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesSanityTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesTests.java rename to e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesSanityTests.java index 67a5b56c0..a59284ea5 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesSanityTests.java @@ -20,7 +20,7 @@ import org.testng.annotations.Test; * */ @Test(groups = { "rest-api", "people", "preferences", "sanity" }) -public class GetPeoplePreferencesTests extends RestTest +public class GetPeoplePreferencesSanityTests extends RestTest { @Autowired RestPeopleApi peopleApi; @@ -98,7 +98,7 @@ public class GetPeoplePreferencesTests extends RestTest peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @Bug(id = "") + @Bug(id = "MNT-16904") @TestRail(section = { "rest-api", "people", "preferences" }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized to gets its preferences with Rest API when authentication fails(401)") public void managerUserGetsPeoplePreferencesIsNotAUthorized() throws Exception { diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleSanityTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/people/GetPeopleTests.java rename to e2e-test/java/org/alfresco/rest/people/GetPeopleSanityTests.java index 36f342cd7..416e5d2b9 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleSanityTests.java @@ -14,7 +14,7 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @Test(groups = { "rest-api", "people", "sanity" }) -public class GetPeopleTests extends RestTest +public class GetPeopleSanityTests extends RestTest { @Autowired RestPeopleApi peopleApi; From c69fff40e562dddb4d3a77384add5a51e1b7d79a Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Thu, 6 Oct 2016 18:04:12 +0300 Subject: [PATCH 0335/1491] Added the bug id --- .../org/alfresco/rest/people/GetFavoriteSiteSanityTests.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java index 8f80da586..90ab0b2cc 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java @@ -5,6 +5,7 @@ import org.alfresco.rest.requests.RestPeopleApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.beans.factory.annotation.Autowired; @@ -117,6 +118,7 @@ public class GetFavoriteSiteSanityTests extends RestTest peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } + @Bug(id = "MNT-16904") @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized gets its specific favorite site with Rest API when authentication fails (401)") public void managerUserNotAuthorizedFailsToGetFavoriteSite() throws Exception { From 08a72bb7380e97807ab8e1065b6bb85bca7555c3 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Thu, 6 Oct 2016 18:25:24 +0300 Subject: [PATCH 0336/1491] increased the number of seconds to wait for list of activities to be retrieved and consumer cannot create content --- .../org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java | 1 - 1 file changed, 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java index c65011c12..155b3acf0 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java @@ -81,7 +81,6 @@ public class GetPeopleActivitiesSanityTests extends RestTest { UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel, UserRole.SiteConsumer); - dataContent.usingUser(consumerUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); restClient.authenticateUser(consumerUser); peopleApi.getPersonActivities(consumerUser).assertResponseIsNotEmpty(); From 56e5fe2764b89d25d0f98804ed1723a8f846fe1e Mon Sep 17 00:00:00 2001 From: cnechifor Date: Fri, 7 Oct 2016 09:47:38 +0300 Subject: [PATCH 0337/1491] reviewed tas-710 --- .../favorites/GetFavoriteSanityTests.java | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java index 86c3e00c8..a0a100110 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java @@ -54,8 +54,8 @@ public class GetFavoriteSanityTests extends RestTest "favorites" }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets favorite site with Rest API and status code is 200") public void adminIsAbleToRetrieveFavoritesSite() throws JsonToModelConversionException, Exception { - favoritesAPI.addUserFavorites(adminUserModel, siteModel); - favoritesAPI.getUserFavorite(adminUserModel, siteModel.getGuid()); + favoritesAPI.addSiteToFavorites(adminUserModel, siteModel); + favoritesAPI.getSiteFavorites(adminUserModel, siteModel); favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -63,8 +63,8 @@ public class GetFavoriteSanityTests extends RestTest "favorites" }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets favorite folder with Rest API and status code is 200") public void adminIsAbleToRetrieveFavoritesFolder() throws JsonToModelConversionException, Exception { - favoritesAPI.addUserFavorites(adminUserModel, folderModel); - favoritesAPI.getUserFavorite(adminUserModel, folderModel.getNodeRef()); + favoritesAPI.addFolderToFavorites(adminUserModel, folderModel); + favoritesAPI.getFolderFavorites(adminUserModel, folderModel); favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -72,8 +72,8 @@ public class GetFavoriteSanityTests extends RestTest "favorites" }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets favorite file with Rest API and status code is 200") public void adminIsAbleToRetrieveFavoritesFile() throws JsonToModelConversionException, Exception { - favoritesAPI.addUserFavorites(adminUserModel, fileModel); - favoritesAPI.getUserFavorite(adminUserModel, fileModel.getNodeRef()); + favoritesAPI.addFileToFavorites(adminUserModel, fileModel); + favoritesAPI.getFileFavorites(adminUserModel, fileModel); favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -82,8 +82,8 @@ public class GetFavoriteSanityTests extends RestTest public void managerIsAbleToRetrieveFavorite() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - favoritesAPI.addUserFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteManager), siteModel); - favoritesAPI.getUserFavorite(usersWithRoles.getOneUserWithRole(UserRole.SiteManager), siteModel.getGuid()); + favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteManager), siteModel); + favoritesAPI.getSiteFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteManager), siteModel); favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -92,8 +92,8 @@ public class GetFavoriteSanityTests extends RestTest public void collaboratorIsAbleToRetrieveFavorites() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - favoritesAPI.addUserFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), siteModel); - favoritesAPI.getUserFavorite(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), siteModel.getGuid()); + favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), siteModel); + favoritesAPI.getSiteFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), siteModel); favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -102,8 +102,8 @@ public class GetFavoriteSanityTests extends RestTest public void contributorIsAbleToRetrieveFavorite() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - favoritesAPI.addUserFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor), siteModel); - favoritesAPI.getUserFavorite(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor), siteModel.getGuid()); + favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor), siteModel); + favoritesAPI.getSiteFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor), siteModel); favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -112,8 +112,8 @@ public class GetFavoriteSanityTests extends RestTest public void consumerIsAbleToRetrieveFavorites() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - favoritesAPI.addUserFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer), siteModel); - favoritesAPI.getUserFavorite(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer), siteModel.getGuid()); + favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer), siteModel); + favoritesAPI.getSiteFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer), siteModel); favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -122,7 +122,7 @@ public class GetFavoriteSanityTests extends RestTest public void userIsNotAbleToRetrieveFavoriteSiteOfAnotherUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - favoritesAPI.getUserFavorite(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), siteModel.getGuid()); + favoritesAPI.getSiteFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), siteModel); favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); } @@ -131,7 +131,7 @@ public class GetFavoriteSanityTests extends RestTest public void userIsNotAbleToRetrieveFavoritesOfAdminUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - favoritesAPI.getUserFavorite(adminUserModel, siteModel.getGuid()); + favoritesAPI.getSiteFavorites(adminUserModel, siteModel); favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); } @@ -140,7 +140,7 @@ public class GetFavoriteSanityTests extends RestTest public void adminIsNotAbleToRetrieveFavoritesOfAnotherUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); - favoritesAPI.getUserFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), siteModel.getGuid()); + favoritesAPI.getSiteFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), siteModel); favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); } @@ -151,7 +151,7 @@ public class GetFavoriteSanityTests extends RestTest UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); siteManager.setPassword("wrongPassword"); restClient.authenticateUser(siteManager); - favoritesAPI.getUserFavorite(usersWithRoles.getOneUserWithRole(UserRole.SiteManager), siteModel.getGuid()); + favoritesAPI.getSiteFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteManager), siteModel); favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } From f312d12168964d2c6540c4b2f0806716d8374299 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Fri, 7 Oct 2016 10:37:50 +0300 Subject: [PATCH 0338/1491] Fix GetFavoriteSanityTests --- .../java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java | 1 + 1 file changed, 1 insertion(+) diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java index a0a100110..55080a087 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java @@ -18,6 +18,7 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +@Test(groups = { "rest-api", "favorites", "sanity" }) public class GetFavoriteSanityTests extends RestTest { From 6563819eee299cf542cfca691c537362bc7d9145 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Fri, 7 Oct 2016 10:54:48 +0300 Subject: [PATCH 0339/1491] remove unused imports, ratings --- .../org/alfresco/rest/favorites/GetFavoriteSanityTests.java | 1 - .../rest/people/GetSitesMembershipInformationSanityTests.java | 2 -- .../java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java | 2 -- .../org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java | 1 - 4 files changed, 6 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java index a0a100110..2fdf7b507 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java @@ -16,7 +16,6 @@ import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; public class GetFavoriteSanityTests extends RestTest { diff --git a/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java index 7fafa4614..fe30fe3e3 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java @@ -4,8 +4,6 @@ import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.requests.RestPeopleApi; import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataSite; -import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.SiteModel; diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java index 38eb23a6e..66ced1843 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java @@ -4,8 +4,6 @@ import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.requests.RestSitesApi; import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataSite; -import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.SiteModel; diff --git a/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java index d32c33696..c937001b1 100644 --- a/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java @@ -1,7 +1,6 @@ package org.alfresco.rest.sites; import org.alfresco.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.requests.RestSitesApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; From ce27642b96bb720fbb38a79c6b25aaae20abe4d6 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Fri, 7 Oct 2016 11:13:14 +0300 Subject: [PATCH 0340/1491] TAS-1204, TAS-1224, TAS-1225, TAS-1226, TAS-1227, TAS-1228, TAS-1229, TAS-1230, TAS-1231 Delete Favorites sanity tests --- .../favorites/DeleteFavoritesSanityTests.java | 147 ++++++++++++++++++ 1 file changed, 147 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/favorites/DeleteFavoritesSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoritesSanityTests.java new file mode 100644 index 000000000..f7edfd546 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoritesSanityTests.java @@ -0,0 +1,147 @@ +package org.alfresco.rest.favorites; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.requests.RestFavoritesApi; +import org.alfresco.rest.requests.RestSitesApi; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +@Test(groups = { "rest-api", "favorites", "sanity" }) +public class DeleteFavoritesSanityTests extends RestTest +{ + @Autowired + RestFavoritesApi favoritesAPI; + + @Autowired + RestSitesApi sitesApi; + + private UserModel adminUserModel; + private SiteModel siteModel; + private FileModel fileModel; + private FolderModel folderModel; + private ListUserWithRoles usersWithRoles; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + restClient.authenticateUser(adminUserModel); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); + fileModel = dataContent.usingUser(adminUserModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + favoritesAPI.useRestClient(restClient); + sitesApi.useRestClient(restClient); + siteModel.setGuid(sitesApi.getSite(siteModel).getGuid()); + + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + } + + @TestRail(section = { "rest-api", + "favorites" }, executionType = ExecutionType.SANITY, description = "Verify Admin user delets site from favorites with Rest API and status code is 204") + public void adminIsAbleToDeleteFavorites() throws JsonToModelConversionException, Exception + { + favoritesAPI.addSiteToFavorites(adminUserModel, siteModel); + favoritesAPI.deleteSiteFromFavorites(adminUserModel, siteModel); + favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @TestRail(section = { "rest-api", + "favorites" }, executionType = ExecutionType.SANITY, description = "Verify Manager user delets site from favorites with Rest API and status code is 204") + public void managerIsAbleToDeleteFavorites() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteManager), siteModel); + favoritesAPI.deleteSiteFromFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteManager), siteModel); + favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @TestRail(section = { "rest-api", + "favorites" }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user delets site from favorites with Rest API and status code is 204") + public void collaboratorIsAbleToDeleteFavorites() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), siteModel); + favoritesAPI.deleteSiteFromFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), siteModel); + favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @TestRail(section = { "rest-api", + "favorites" }, executionType = ExecutionType.SANITY, description = "Verify Contributor user delets site from favorites with Rest API and status code is 204") + public void contributorIsAbleToDeleteFavorites() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor), siteModel); + favoritesAPI.deleteSiteFromFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor), siteModel); + favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @TestRail(section = { "rest-api", + "favorites" }, executionType = ExecutionType.SANITY, description = "Verify Consumer user delets site from favorites with Rest API and status code is 204") + public void consumerIsAbleToDeleteFavorites() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer), siteModel); + favoritesAPI.deleteSiteFromFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer), siteModel); + favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @TestRail(section = { "rest-api", + "favorites" }, executionType = ExecutionType.SANITY, description = "Verify user doesn't have permission to delete favorites of another user with Rest API and status code is 404") + public void userIsNotAbleToDeleteFavoritesOfAnotherUser() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), siteModel); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + favoritesAPI.deleteSiteFromFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), siteModel); + favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); + } + + @TestRail(section = { "rest-api", + "favorites" }, executionType = ExecutionType.SANITY, description = "Verify user doesn't have permission to delete favorites of admin user with Rest API and status code is 404") + public void userIsNotAbleToDeleteFavoritesOfAdminUser() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel); + favoritesAPI.addSiteToFavorites(adminUserModel, siteModel); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + favoritesAPI.deleteSiteFromFavorites(adminUserModel, siteModel); + favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); + } + + @TestRail(section = { "rest-api", + "favorites" }, executionType = ExecutionType.SANITY, description = "Verify admin user doesn't have permission to delete favorites of another user with Rest API and status code is 404") + public void adminIsNotAbleToDeleteFavoritesOfAnotherUser() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), siteModel); + restClient.authenticateUser(adminUserModel); + favoritesAPI.deleteSiteFromFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), siteModel); + favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); + } + + @TestRail(section = { "rest-api", + "favorites" }, executionType = ExecutionType.SANITY, description = "Verify user gets status code 401 if authentication call fails") + @Bug(id = "MNT-16904") + public void userIsNotAbleToDeleteFavoritesIfAuthenticationFails() throws JsonToModelConversionException, Exception + { + UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); + siteManager.setPassword("wrongPassword"); + restClient.authenticateUser(siteManager); + favoritesAPI.deleteSiteFromFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteManager), siteModel); + favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + } +} From 03f96277ffe956994917293415ac51b31f1ecd63 Mon Sep 17 00:00:00 2001 From: cagache Date: Fri, 7 Oct 2016 11:24:41 +0300 Subject: [PATCH 0341/1491] added jira id for the bug found by adminIsAbleToUpdateTags() test --- e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java index f6c3d9866..ac0d1f9ae 100644 --- a/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java @@ -56,7 +56,7 @@ public class UpdateTagSanityTests extends RestTest } @TestRail(section = { "rest-api", "tags" }, executionType = ExecutionType.SANITY, description = "Verify Admin user updates tags and status code is 200") - @Bug(id="N/A") + @Bug(id="MNT-16917") public void adminIsAbleToUpdateTags() throws JsonToModelConversionException, Exception { tagsAPI.updateTag(oldTag, randomTag).assertTagIs(randomTag); From 62c81ce5b34ab572c235a9260d63db8efd6264f9 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Fri, 7 Oct 2016 11:42:28 +0300 Subject: [PATCH 0342/1491] Added @Bug(id="MNT-16557") annotation --- .../alfresco/rest/favorites/DeleteFavoritesSanityTests.java | 3 +++ .../org/alfresco/rest/favorites/GetFavoriteSanityTests.java | 2 ++ 2 files changed, 5 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoritesSanityTests.java index f7edfd546..65efd135f 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoritesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoritesSanityTests.java @@ -102,6 +102,7 @@ public class DeleteFavoritesSanityTests extends RestTest @TestRail(section = { "rest-api", "favorites" }, executionType = ExecutionType.SANITY, description = "Verify user doesn't have permission to delete favorites of another user with Rest API and status code is 404") + @Bug(id="MNT-16557") public void userIsNotAbleToDeleteFavoritesOfAnotherUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); @@ -113,6 +114,7 @@ public class DeleteFavoritesSanityTests extends RestTest @TestRail(section = { "rest-api", "favorites" }, executionType = ExecutionType.SANITY, description = "Verify user doesn't have permission to delete favorites of admin user with Rest API and status code is 404") + @Bug(id="MNT-16557") public void userIsNotAbleToDeleteFavoritesOfAdminUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); @@ -124,6 +126,7 @@ public class DeleteFavoritesSanityTests extends RestTest @TestRail(section = { "rest-api", "favorites" }, executionType = ExecutionType.SANITY, description = "Verify admin user doesn't have permission to delete favorites of another user with Rest API and status code is 404") + @Bug(id="MNT-16557") public void adminIsNotAbleToDeleteFavoritesOfAnotherUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java index 2fdf7b507..2c76b39e5 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java @@ -11,6 +11,7 @@ import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.beans.factory.annotation.Autowired; @@ -145,6 +146,7 @@ public class GetFavoriteSanityTests extends RestTest @TestRail(section = { "rest-api", "favorites" }, executionType = ExecutionType.SANITY, description = "Verify user gets status code 401 if authentication call fails") + @Bug(id="MNT-16904") public void userIsNotAbleToRetrieveFavoritesIfAuthenticationFails() throws JsonToModelConversionException, Exception { UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); From 51eb0be48725dfb8ce84d0da041c4322a6a6a23b Mon Sep 17 00:00:00 2001 From: cagache Date: Fri, 7 Oct 2016 11:42:51 +0300 Subject: [PATCH 0343/1491] TAS-1233 - add scenario for add tags by manager TAS-1234 - add scenario for add tags by collaborator TAS-1235 - add scenario for add tags by contributor TAS-1236 - add scenario for add tags by consumer TAS-1237 - add scenario for add tags by admin TAS-1238 - add scenario for add tags by unauthorized user --- .../rest/tags/AddTagsSanityTests.java | 133 ++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/tags/AddTagsSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/tags/AddTagsSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/AddTagsSanityTests.java new file mode 100644 index 000000000..9f7461388 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/tags/AddTagsSanityTests.java @@ -0,0 +1,133 @@ +package org.alfresco.rest.tags; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.requests.RestTagsApi; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.data.RandomData; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by Claudia Agache on 10/7/2016. + */ +@Test(groups = { "rest-api", "tags", "sanity" }) +public class AddTagsSanityTests extends RestTest +{ + @Autowired + private DataUser dataUser; + + @Autowired + private RestTagsApi tagsAPI; + + private UserModel adminUserModel, userModel; + private FileModel document, contributorDoc; + private SiteModel siteModel; + private DataUser.ListUserWithRoles usersWithRoles; + private List tagValues; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + restClient.authenticateUser(adminUserModel); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + tagsAPI.useRestClient(restClient); + } + + @BeforeMethod(alwaysRun = true) + public void generateRandomTagsList() + { + tagValues = new ArrayList<>(); + for (int i = 0; i < 3; i++) + { + tagValues.add(RandomData.getRandomName("tag")); + } + } + + @TestRail(section = { "rest-api", + "tags" }, executionType = ExecutionType.SANITY, description = "Verify admin user adds multiple tags with Rest API and status code is 201") + public void adminIsAbleToAddTags() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel); + tagsAPI.addTags(document, tagValues).assertThatResponseHasTags(tagValues); + tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + } + + @TestRail(section = { "rest-api", + "tags" }, executionType = ExecutionType.SANITY, description = "Verify Manager user adds multiple tags with Rest API and status code is 201") + public void managerIsAbleToAddTags() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + tagsAPI.addTags(document, tagValues).assertThatResponseHasTags(tagValues); + tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + } + + @TestRail(section = { "rest-api", + "tags" }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user adds multiple tags with Rest API and status code is 201") + public void collaboratorIsAbleToAddTags() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + tagsAPI.addTags(document, tagValues).assertThatResponseHasTags(tagValues); + tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + } + + @TestRail(section = { "rest-api", + "tags" }, executionType = ExecutionType.SANITY, description = "Verify Contributor user doesn't have permission to add multiple tags with Rest API and status code is 403") + public void contributorIsNotAbleToAddTagsToAnotherContent() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + tagsAPI.addTags(document, tagValues); + tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + } + + @TestRail(section = { "rest-api", + "tags" }, executionType = ExecutionType.SANITY, description = "Verify Contributor user adds multiple tags to his content with Rest API and status code is 201") + public void contributorIsAbleToAddTagsToHisContent() throws JsonToModelConversionException, Exception + { + userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); + restClient.authenticateUser(userModel); + contributorDoc = dataContent.usingSite(siteModel).usingUser(userModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + tagsAPI.addTags(contributorDoc, tagValues).assertThatResponseHasTags(tagValues); + tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + } + + @TestRail(section = { "rest-api", + "tags" }, executionType = ExecutionType.SANITY, description = "Verify Consumer user doesn't have permission to add multiple tags with Rest API and status code is 403") + public void consumerIsNotAbleToAddTags() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + tagsAPI.addTags(document, tagValues); + tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + } + + @TestRail(section = { "rest-api", + "tags" }, executionType = ExecutionType.SANITY, description = "Verify Manager user gets status code 401 if authentication call fails") + @Bug(id="MNT-16904") + public void managerIsNotAbleToAddTagsIfAuthenticationFails() throws JsonToModelConversionException, Exception + { + UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); + siteManager.setPassword("wrongPassword"); + restClient.authenticateUser(siteManager); + tagsAPI.addTags(document, tagValues); + tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + } +} + From c45cf8182fc3ab1d47f7d55ff2a83e54450fa99a Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Fri, 7 Oct 2016 11:48:30 +0300 Subject: [PATCH 0344/1491] Updating the test to check another user favorite sites and not only its own --- .../people/GetFavoriteSitesSanityTests.java | 88 ++++++++++--------- 1 file changed, 46 insertions(+), 42 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java index 1e6b1bfa0..4c0960a9e 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java @@ -32,90 +32,94 @@ public class GetFavoriteSitesSanityTests extends RestTest peopleApi.useRestClient(restClient); } - @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify manager user gets its favorite sites with Rest API and response is successful (200)") - public void managerUserGetsFavoriteSitesWithSuccess() throws Exception + @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify manager user fails to get an user favorite sites with Rest API (403)") + public void managerUserFailsToGetAnUserFavoriteSites() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); - UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); - dataSite.usingUser(collaboratorUser).usingSite(siteModel).addSiteToFavorites(); + UserModel anotherUser = dataUser.usingAdmin().createRandomTestUser(); + dataSite.usingUser(anotherUser).usingSite(siteModel).addSiteToFavorites(); restClient.authenticateUser(managerUser); - peopleApi.getFavoriteSites(collaboratorUser).assertResponseIsNotEmpty(); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + peopleApi.getFavoriteSites(anotherUser); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } - @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify collaborator user gets its favorite sites with Rest API and response is successful (200)") - public void collaboratorUserGetsFavoriteSitesWithSuccess() throws Exception + @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify collaborator user fails to get an user favorite sites with Rest API (403)") + public void collaboratorUserFailsToGetAnUserFavoriteSites() throws Exception { UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); - UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(collaboratorUser, siteModel, UserRole.SiteCollaborator); - dataUser.usingUser(userModel).addUserToSite(contributorUser, siteModel, UserRole.SiteContributor); - - dataSite.usingUser(collaboratorUser).usingSite(siteModel).addSiteToFavorites(); + UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(contributorUser, siteModel, UserRole.SiteContributor); + dataSite.usingUser(contributorUser).usingSite(siteModel).addSiteToFavorites(); restClient.authenticateUser(collaboratorUser); - peopleApi.getFavoriteSites(contributorUser).assertResponseIsNotEmpty(); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + peopleApi.getFavoriteSites(contributorUser); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } - @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify contributor user gets its favorite sites with Rest API and response is successful (200)") - public void contributorUserGetsFavoriteSitesWithSuccess() throws Exception + @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify contributor user fails to get an user favorite sites with Rest API (403)") + public void contributorUserFailsToGetAnUserFavoriteSites() throws Exception { UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); - UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); + UserModel contributorUser2 = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(contributorUser, siteModel, UserRole.SiteContributor); - dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); - dataSite.usingUser(managerUser).usingSite(siteModel).addSiteToFavorites(); + dataUser.usingUser(userModel).addUserToSite(contributorUser2, siteModel, UserRole.SiteContributor); + dataSite.usingUser(contributorUser2).usingSite(siteModel).addSiteToFavorites(); restClient.authenticateUser(contributorUser); - peopleApi.getFavoriteSites(managerUser).assertResponseIsNotEmpty(); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + peopleApi.getFavoriteSites(contributorUser2); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } - @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify consumer user gets its favorite sites with Rest API and response is successful (200)") - public void consumerUserGetsFavoriteSitesWithSuccess() throws Exception + @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify consumer user fails to get an user favorite sites with Rest API (403)") + public void consumerUserFailsToGetAnUserFavoriteSites() throws Exception { UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel, UserRole.SiteConsumer); dataUser.usingUser(collaboratorUser).addUserToSite(collaboratorUser, siteModel, UserRole.SiteCollaborator); - dataSite.usingUser(consumerUser).usingSite(siteModel).addSiteToFavorites(); + dataSite.usingUser(collaboratorUser).usingSite(siteModel).addSiteToFavorites(); restClient.authenticateUser(consumerUser); - peopleApi.getFavoriteSites(collaboratorUser).assertResponseIsNotEmpty(); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + peopleApi.getFavoriteSites(collaboratorUser); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify admin user gets its favorite sites with Rest API and response is successful (200)") public void adminUserGetsFavoriteSitesWithSuccess() throws Exception { UserModel adminUser = dataUser.getAdminUser(); - UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel, UserRole.SiteConsumer); - dataSite.usingUser(consumerUser).usingSite(siteModel).addSiteToFavorites(); + UserModel anotherUser = dataUser.usingAdmin().createRandomTestUser(); + dataSite.usingUser(anotherUser).usingSite(siteModel).addSiteToFavorites(); restClient.authenticateUser(adminUser); - peopleApi.getFavoriteSites(consumerUser).assertResponseIsNotEmpty(); + peopleApi.getFavoriteSites(anotherUser).assertResponseIsNotEmpty(); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify any user gets its own user favorite sites with Rest API and response is successful (200)") + public void anyUserGetsItsUserFavoriteSites() throws Exception + { + UserModel anyUser = dataUser.usingAdmin().createRandomTestUser(); + dataSite.usingUser(anyUser).usingSite(siteModel).addSiteToFavorites(); + + restClient.authenticateUser(anyUser); + peopleApi.getFavoriteSites(anyUser); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @Bug(id = "MNT-16904") - @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized to get its favorite sites with Rest API when authentication fails (401)") - public void managerUserGetsFavoriteSitesIsNotAuthorized() throws Exception + @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify any user is NOT Authorized to get its favorite sites with Rest API when authentication fails (401)") + public void anyUserNotAuthenticatedIsNotAuthorizedToGetFavoriteSites() throws Exception { - UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); - UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); - - dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); - dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel, UserRole.SiteConsumer); - dataSite.usingUser(consumerUser).usingSite(siteModel).addSiteToFavorites(); - - managerUser.setPassword("newpassword"); + UserModel anyUser = dataUser.usingAdmin().createRandomTestUser(); + dataSite.usingUser(anyUser).usingSite(siteModel).addSiteToFavorites(); + anyUser.setPassword("newpassword"); - restClient.authenticateUser(managerUser); - peopleApi.getFavoriteSites(consumerUser); + restClient.authenticateUser(anyUser); + peopleApi.getFavoriteSites(anyUser); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } From 12e824d8fffb0210703b020b5dc09fda4db9f393 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Fri, 7 Oct 2016 13:50:39 +0300 Subject: [PATCH 0345/1491] TAS-1240 REST API - user is able to update its own site membership request --- ...pdateSiteMembershipRequestSanityTests.java | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestSanityTests.java new file mode 100644 index 000000000..08cb5661b --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestSanityTests.java @@ -0,0 +1,71 @@ +package org.alfresco.rest.people; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.body.SiteMembershipRequest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.requests.RestPeopleApi; +import org.alfresco.utility.constants.UserRole; +import org.springframework.social.alfresco.api.entities.Site.Visibility; +import org.alfresco.utility.data.DataSite; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.data.RandomData; +import org.alfresco.utility.exception.DataPreparationException; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +@Test(groups = { "rest-api", "people", "sanity" }) +public class UpdateSiteMembershipRequestSanityTests extends RestTest +{ + @Autowired + RestPeopleApi peopleApi; + + @Autowired + DataUser dataUser; + + @Autowired + DataSite dataSite; + + private SiteModel siteModel; + + private ListUserWithRoles usersWithRoles; + + private UserModel adminUser; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws DataPreparationException + { + adminUser = dataUser.getAdminUser(); + String siteId = RandomData.getRandomName("site"); + siteModel = dataSite.usingUser(adminUser).createSite(new SiteModel(Visibility.MODERATED, siteId, siteId, siteId, siteId)); + + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + + peopleApi.useRestClient(restClient); + } + + @TestRail(section = { "rest-api", "people" }, + executionType = ExecutionType.SANITY, description = "Verify user is able to update its own site membership request") + public void userIsAbleToUpdateItsOwnSiteMembershipRequest() throws JsonToModelConversionException, Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + SiteMembershipRequest siteMembership = new SiteMembershipRequest("Please accept me", siteModel.getId(), "New request"); + + restClient.authenticateUser(newMember); + peopleApi.addSiteMembershipRequest(newMember, siteMembership); + + String newMessage = "Please review my request"; + siteMembership = new SiteMembershipRequest(newMessage, siteModel.getId(), null); + peopleApi.updateSiteMembershipRequest(newMember, siteMembership).assertMembershipRequestMessageIs(newMessage); + + peopleApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.OK); + } + +} \ No newline at end of file From 20568f0b2523f6b482fd7941b1f96ace64e5e2a5 Mon Sep 17 00:00:00 2001 From: cagache Date: Fri, 7 Oct 2016 14:03:30 +0300 Subject: [PATCH 0346/1491] updated tests based on review comments --- .../rest/tags/AddTagsSanityTests.java | 26 +++++++------------ 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/tags/AddTagsSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/AddTagsSanityTests.java index 9f7461388..1e4a439e5 100644 --- a/e2e-test/java/org/alfresco/rest/tags/AddTagsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/AddTagsSanityTests.java @@ -19,9 +19,6 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import java.util.ArrayList; -import java.util.List; - /** * Created by Claudia Agache on 10/7/2016. */ @@ -38,7 +35,7 @@ public class AddTagsSanityTests extends RestTest private FileModel document, contributorDoc; private SiteModel siteModel; private DataUser.ListUserWithRoles usersWithRoles; - private List tagValues; + private String tag1, tag2; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception @@ -55,11 +52,8 @@ public class AddTagsSanityTests extends RestTest @BeforeMethod(alwaysRun = true) public void generateRandomTagsList() { - tagValues = new ArrayList<>(); - for (int i = 0; i < 3; i++) - { - tagValues.add(RandomData.getRandomName("tag")); - } + tag1 = RandomData.getRandomName("tag"); + tag2 = RandomData.getRandomName("tag"); } @TestRail(section = { "rest-api", @@ -67,7 +61,7 @@ public class AddTagsSanityTests extends RestTest public void adminIsAbleToAddTags() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); - tagsAPI.addTags(document, tagValues).assertThatResponseHasTags(tagValues); + tagsAPI.addTags(document, tag1, tag2).assertThatResponseHasTags(tag1, tag2); tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } @@ -76,7 +70,7 @@ public class AddTagsSanityTests extends RestTest public void managerIsAbleToAddTags() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - tagsAPI.addTags(document, tagValues).assertThatResponseHasTags(tagValues); + tagsAPI.addTags(document, tag1, tag2).assertThatResponseHasTags(tag1, tag2); tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } @@ -85,7 +79,7 @@ public class AddTagsSanityTests extends RestTest public void collaboratorIsAbleToAddTags() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - tagsAPI.addTags(document, tagValues).assertThatResponseHasTags(tagValues); + tagsAPI.addTags(document, tag1, tag2).assertThatResponseHasTags(tag1, tag2); tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } @@ -94,7 +88,7 @@ public class AddTagsSanityTests extends RestTest public void contributorIsNotAbleToAddTagsToAnotherContent() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - tagsAPI.addTags(document, tagValues); + tagsAPI.addTags(document, tag1, tag2); tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } @@ -105,7 +99,7 @@ public class AddTagsSanityTests extends RestTest userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); restClient.authenticateUser(userModel); contributorDoc = dataContent.usingSite(siteModel).usingUser(userModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - tagsAPI.addTags(contributorDoc, tagValues).assertThatResponseHasTags(tagValues); + tagsAPI.addTags(contributorDoc, tag1, tag2).assertThatResponseHasTags(tag1, tag2); tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } @@ -114,7 +108,7 @@ public class AddTagsSanityTests extends RestTest public void consumerIsNotAbleToAddTags() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - tagsAPI.addTags(document, tagValues); + tagsAPI.addTags(document, tag1, tag2); tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } @@ -126,7 +120,7 @@ public class AddTagsSanityTests extends RestTest UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); siteManager.setPassword("wrongPassword"); restClient.authenticateUser(siteManager); - tagsAPI.addTags(document, tagValues); + tagsAPI.addTags(document, tag1, tag2); tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } From 5dc5ca590782840b8e2bb63d91b1dbecc2a70f8a Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Fri, 7 Oct 2016 14:04:42 +0300 Subject: [PATCH 0347/1491] TAS-1242 delete siteMmebership request with the user that created the request --- ...eleteSiteMembershipRequestSanityTests.java | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java new file mode 100644 index 000000000..b5910fc3a --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java @@ -0,0 +1,60 @@ +package org.alfresco.rest.people; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.body.SiteMembershipRequest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.requests.RestPeopleApi; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.data.RandomData; +import org.alfresco.utility.exception.DataPreparationException; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.social.alfresco.api.entities.Site.Visibility; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * @author iulia.cojocea + */ +@Test(groups = {"rest-api", "people", "sanity" }) +public class DeleteSiteMembershipRequestSanityTests extends RestTest +{ + @Autowired + RestPeopleApi peopleApi; + + UserModel userModel; + UserModel siteMember; + SiteModel siteModel; + SiteMembershipRequest siteMembershipRequest; + private ListUserWithRoles usersWithRoles; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception{ + String siteId = RandomData.getRandomName("site"); + siteModel = dataSite.usingUser(userModel).createSite(new SiteModel(Visibility.MODERATED, siteId, siteId, siteId, siteId)); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, + UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + siteMembershipRequest = new SiteMembershipRequest("Please accept me", siteModel.getId(), "New request"); + + peopleApi.useRestClient(restClient); + } + + @TestRail(section = {"rest-api", "people" }, executionType = ExecutionType.SANITY, + description = "Verify one user is able to delete his one site memebership request") + public void userCanDeleteHisOwnSiteMembershipRequest() throws JsonToModelConversionException, DataPreparationException, Exception + { + siteMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(siteMember); + peopleApi.addSiteMembershipRequest(siteMember, siteMembershipRequest); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + peopleApi.deleteSiteMembershipRequest(siteMember, siteModel); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); + } +} From ebd1ff92aa2f464b33dd466bc3853125abf1491c Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Fri, 7 Oct 2016 15:12:30 +0300 Subject: [PATCH 0348/1491] TAS-1239 deleteSiteMembershipRequest with site manager role --- .../DeleteSiteMembershipRequestSanityTests.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java index b5910fc3a..6f151a812 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java @@ -57,4 +57,17 @@ public class DeleteSiteMembershipRequestSanityTests extends RestTest peopleApi.deleteSiteMembershipRequest(siteMember, siteModel); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); } + + @Bug(id="MNT-16916") + @TestRail(section = {"rest-api", "people" }, executionType = ExecutionType.SANITY, + description = "Verify site manager is able to delete site membership request") + public void siteManagerCanDeleteSiteMembershipRequest() throws JsonToModelConversionException, DataPreparationException, Exception + { + siteMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(siteMember); + peopleApi.addSiteMembershipRequest(siteMember, siteMembershipRequest); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + peopleApi.deleteSiteMembershipRequest(usersWithRoles.getOneUserWithRole(UserRole.SiteManager), siteModel); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); + } } From e12f6f3f82d9e70e91ef1b92893d2fbb1eeafae7 Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Fri, 7 Oct 2016 15:13:32 +0300 Subject: [PATCH 0349/1491] TAS-1241 deleteSiteMembershipRequest using admin user --- .../DeleteSiteMembershipRequestSanityTests.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java index 6f151a812..da57080f6 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java @@ -70,4 +70,19 @@ public class DeleteSiteMembershipRequestSanityTests extends RestTest peopleApi.deleteSiteMembershipRequest(usersWithRoles.getOneUserWithRole(UserRole.SiteManager), siteModel); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); } + + @Bug(id="MNT-16916") + @TestRail(section = {"rest-api", "people" }, executionType = ExecutionType.SANITY, + description = "Verify admin user is able to delete site memebership request") + public void adminUserCanDeleteSiteMembershipRequest() throws JsonToModelConversionException, DataPreparationException, Exception + { + siteMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(siteMember); + peopleApi.addSiteMembershipRequest(siteMember, siteMembershipRequest); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + UserModel adminUser = dataUser.getAdminUser(); + restClient.authenticateUser(adminUser); + peopleApi.deleteSiteMembershipRequest(adminUser, siteModel); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); + } } From 4a7c13cbeae049c0366f93ac00ac6a05abd6431a Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Fri, 7 Oct 2016 15:14:35 +0300 Subject: [PATCH 0350/1491] TAS-1243 REST API - site manager is not able to update a site membership request --- ...pdateSiteMembershipRequestSanityTests.java | 41 +++++++++++++++---- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestSanityTests.java index 08cb5661b..0b1222b25 100644 --- a/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestSanityTests.java @@ -5,7 +5,6 @@ import org.alfresco.rest.body.SiteMembershipRequest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.requests.RestPeopleApi; import org.alfresco.utility.constants.UserRole; -import org.springframework.social.alfresco.api.entities.Site.Visibility; import org.alfresco.utility.data.DataSite; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.DataUser.ListUserWithRoles; @@ -13,10 +12,12 @@ import org.alfresco.utility.data.RandomData; import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; +import org.springframework.social.alfresco.api.entities.Site.Visibility; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -33,10 +34,13 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest DataSite dataSite; private SiteModel siteModel; - private ListUserWithRoles usersWithRoles; - private UserModel adminUser; + private String initialMessage; + private String updatedMessage; + + private SiteMembershipRequest initialSiteMembership; + private SiteMembershipRequest updatedSiteMembership; @BeforeClass(alwaysRun=true) public void dataPreparation() throws DataPreparationException @@ -48,6 +52,12 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); peopleApi.useRestClient(restClient); + + initialMessage = "Please accept me"; + updatedMessage = "Please review my request"; + + initialSiteMembership = new SiteMembershipRequest(initialMessage, siteModel.getId(), "New request"); + updatedSiteMembership = new SiteMembershipRequest(updatedMessage, siteModel.getId(), "New request updated"); } @TestRail(section = { "rest-api", "people" }, @@ -55,17 +65,30 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest public void userIsAbleToUpdateItsOwnSiteMembershipRequest() throws JsonToModelConversionException, Exception { UserModel newMember = dataUser.createRandomTestUser(); - SiteMembershipRequest siteMembership = new SiteMembershipRequest("Please accept me", siteModel.getId(), "New request"); restClient.authenticateUser(newMember); - peopleApi.addSiteMembershipRequest(newMember, siteMembership); - - String newMessage = "Please review my request"; - siteMembership = new SiteMembershipRequest(newMessage, siteModel.getId(), null); - peopleApi.updateSiteMembershipRequest(newMember, siteMembership).assertMembershipRequestMessageIs(newMessage); + peopleApi.addSiteMembershipRequest(newMember, initialSiteMembership); + peopleApi.updateSiteMembershipRequest(newMember, updatedSiteMembership) + .assertMembershipRequestMessageIs(updatedMessage); peopleApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.OK); } + @TestRail(section = { "rest-api", "people" }, + executionType = ExecutionType.SANITY, description = "Verify site manager is not able to update membership request of another user") + @Bug(id = "MNT-16919") + public void siteManagerIsNotAbleToUpdateSiteMembershipRequestOfAnotherUser() throws JsonToModelConversionException, Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + + restClient.authenticateUser(newMember); + peopleApi.addSiteMembershipRequest(newMember, initialSiteMembership); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + peopleApi.updateSiteMembershipRequest(newMember, updatedSiteMembership); + + peopleApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.FORBIDDEN); + } } \ No newline at end of file From 52ffc3d5dfa9c5b48118797f3a91aac082dfc31b Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Fri, 7 Oct 2016 15:16:35 +0300 Subject: [PATCH 0351/1491] deteleSiteMembershipRequest using collaborator user --- .../DeleteSiteMembershipRequestSanityTests.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java index da57080f6..e260fab7c 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java @@ -85,4 +85,17 @@ public class DeleteSiteMembershipRequestSanityTests extends RestTest peopleApi.deleteSiteMembershipRequest(adminUser, siteModel); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); } + + @Bug(id="MNT-16916") + @TestRail(section = {"rest-api", "people" }, executionType = ExecutionType.SANITY, + description = "Verify collaborator user is not able to delete site memebership request") + public void collaboratorCannotDeleteSiteMembershipRequest() throws JsonToModelConversionException, DataPreparationException, Exception + { + siteMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(siteMember); + peopleApi.addSiteMembershipRequest(siteMember, siteMembershipRequest); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + peopleApi.deleteSiteMembershipRequest(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), siteModel); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + } } From 94300c82696545318609b301b9797b39d9aea93e Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Fri, 7 Oct 2016 15:17:27 +0300 Subject: [PATCH 0352/1491] deleteSiteMembershipRequest using a contributor role --- .../DeleteSiteMembershipRequestSanityTests.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java index e260fab7c..9273e2f20 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java @@ -98,4 +98,17 @@ public class DeleteSiteMembershipRequestSanityTests extends RestTest peopleApi.deleteSiteMembershipRequest(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), siteModel); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } + + @Bug(id="MNT-16916") + @TestRail(section = {"rest-api", "people" }, executionType = ExecutionType.SANITY, + description = "Verify contributor user is not able to delete site memebership request") + public void contributorCannotDeleteSiteMembershipRequest() throws JsonToModelConversionException, DataPreparationException, Exception + { + siteMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(siteMember); + peopleApi.addSiteMembershipRequest(siteMember, siteMembershipRequest); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + peopleApi.deleteSiteMembershipRequest(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor), siteModel); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + } } From ed65b6ea83a1ac99c3f830dae32a27336704e7e2 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Fri, 7 Oct 2016 15:17:27 +0300 Subject: [PATCH 0353/1491] TAS-1249 REST API - site collaborator is not able to update a site membership request --- .../UpdateSiteMembershipRequestSanityTests.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestSanityTests.java index 0b1222b25..8af1b183b 100644 --- a/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestSanityTests.java @@ -91,4 +91,21 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest peopleApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.FORBIDDEN); } + + @TestRail(section = { "rest-api", "people" }, + executionType = ExecutionType.SANITY, description = "Verify site collaborator is not able to update membership request of another user") + @Bug(id = "MNT-16919") + public void siteCollaboratorIsNotAbleToUpdateSiteMembershipRequestOfAnotherUser() throws JsonToModelConversionException, Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + + restClient.authenticateUser(newMember); + peopleApi.addSiteMembershipRequest(newMember, initialSiteMembership); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + peopleApi.updateSiteMembershipRequest(newMember, updatedSiteMembership); + + peopleApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.FORBIDDEN); + } } \ No newline at end of file From 4744413847e45c99603e23a2d6273fffcc6184c8 Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Fri, 7 Oct 2016 15:18:00 +0300 Subject: [PATCH 0354/1491] deleteSiteMembershipRequest using a consumer role --- .../DeleteSiteMembershipRequestSanityTests.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java index 9273e2f20..e13c6a49f 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java @@ -111,4 +111,17 @@ public class DeleteSiteMembershipRequestSanityTests extends RestTest peopleApi.deleteSiteMembershipRequest(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor), siteModel); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } + + @Bug(id="MNT-16916") + @TestRail(section = {"rest-api", "people" }, executionType = ExecutionType.SANITY, + description = "Verify consumer user is not able to delete site memebership request") + public void consumerCannotDeleteSiteMembershipRequest() throws JsonToModelConversionException, DataPreparationException, Exception + { + siteMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(siteMember); + peopleApi.addSiteMembershipRequest(siteMember, siteMembershipRequest); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + peopleApi.deleteSiteMembershipRequest(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer), siteModel); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + } } From f37a3452dc50c123a0113535a439ea20139b13c5 Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Fri, 7 Oct 2016 15:18:54 +0300 Subject: [PATCH 0355/1491] TAS-1247 deletesiteMembershipRequest using a random user --- .../DeleteSiteMembershipRequestSanityTests.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java index e13c6a49f..56ac6fc87 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java @@ -124,4 +124,18 @@ public class DeleteSiteMembershipRequestSanityTests extends RestTest peopleApi.deleteSiteMembershipRequest(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer), siteModel); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } + + @Bug(id="MNT-16916") + @TestRail(section = {"rest-api", "people" }, executionType = ExecutionType.SANITY, + description = "Verify random user is not able to delete site memebership request") + public void randomUserCanDeleteSiteMembershipRequest() throws JsonToModelConversionException, DataPreparationException, Exception + { + siteMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(siteMember); + peopleApi.addSiteMembershipRequest(siteMember, siteMembershipRequest); + UserModel randomUser = dataUser.createRandomTestUser(); + restClient.authenticateUser(randomUser); + peopleApi.deleteSiteMembershipRequest(randomUser, siteModel); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + } } From 2aba5fffbfecf9039ff85b4835094562689560e5 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Fri, 7 Oct 2016 15:18:54 +0300 Subject: [PATCH 0356/1491] TAS-1250 REST API - site contributor is not able to update a site membership request --- .../UpdateSiteMembershipRequestSanityTests.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestSanityTests.java index 8af1b183b..99f6323c8 100644 --- a/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestSanityTests.java @@ -108,4 +108,21 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest peopleApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.FORBIDDEN); } + + @TestRail(section = { "rest-api", "people" }, + executionType = ExecutionType.SANITY, description = "Verify site contributor is not able to update membership request of another user") + @Bug(id = "MNT-16919") + public void siteContributorIsNotAbleToUpdateSiteMembershipRequestOfAnotherUser() throws JsonToModelConversionException, Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + + restClient.authenticateUser(newMember); + peopleApi.addSiteMembershipRequest(newMember, initialSiteMembership); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + peopleApi.updateSiteMembershipRequest(newMember, updatedSiteMembership); + + peopleApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.FORBIDDEN); + } } \ No newline at end of file From 29e32094e7efdc91d7f5a7f84c657ce9863a18ce Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Fri, 7 Oct 2016 15:20:35 +0300 Subject: [PATCH 0357/1491] TAS-1248 deleteSiteMembershipRequest failed authentication call returns status code 401 --- .../DeleteSiteMembershipRequestSanityTests.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java index 56ac6fc87..64ac71615 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java @@ -138,4 +138,18 @@ public class DeleteSiteMembershipRequestSanityTests extends RestTest peopleApi.deleteSiteMembershipRequest(randomUser, siteModel); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } + + @Bug(id="MNT-16904") + @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, + description = "Failed authentication get site member call returns status code 401") + public void unauthenticatedUserIsNotAuthorizedToDeleteSiteMmebershipRequest() throws JsonToModelConversionException, Exception + { + siteMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(siteMember); + peopleApi.addSiteMembershipRequest(siteMember, siteMembershipRequest); + UserModel inexistentUser = new UserModel("inexistent user", "inexistent password"); + restClient.authenticateUser(inexistentUser); + peopleApi.deleteSiteMembershipRequest(inexistentUser, siteModel); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + } } From a338699b7a92cd32cca1ba0137b8c5168e182260 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Fri, 7 Oct 2016 15:21:41 +0300 Subject: [PATCH 0358/1491] TAS-1251 REST API - site consumer is not able to update a site membership request --- .../UpdateSiteMembershipRequestSanityTests.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestSanityTests.java index 99f6323c8..be644f76e 100644 --- a/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestSanityTests.java @@ -125,4 +125,21 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest peopleApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.FORBIDDEN); } + + @TestRail(section = { "rest-api", "people" }, + executionType = ExecutionType.SANITY, description = "Verify site consumer is not able to update membership request of another user") + @Bug(id = "MNT-16919") + public void siteConsumerIsNotAbleToUpdateSiteMembershipRequestOfAnotherUser() throws JsonToModelConversionException, Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + + restClient.authenticateUser(newMember); + peopleApi.addSiteMembershipRequest(newMember, initialSiteMembership); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + peopleApi.updateSiteMembershipRequest(newMember, updatedSiteMembership); + + peopleApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.FORBIDDEN); + } } \ No newline at end of file From 5dcbf5e00d5aaff248fb1846334fa1fae0660680 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Fri, 7 Oct 2016 15:24:28 +0300 Subject: [PATCH 0359/1491] TAS-1253 REST API - user is not able to update a site membership request of another user --- ...UpdateSiteMembershipRequestSanityTests.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestSanityTests.java index be644f76e..ce8ceb712 100644 --- a/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestSanityTests.java @@ -142,4 +142,22 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest peopleApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.FORBIDDEN); } + + @TestRail(section = { "rest-api", "people" }, + executionType = ExecutionType.SANITY, description = "Verify one user is not able to update membership request of another user") + @Bug(id = "MNT-16919") + public void oneUserIsNotAbleToUpdateSiteMembershipRequestOfAnotherUser() throws JsonToModelConversionException, Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + UserModel otherMember = dataUser.createRandomTestUser(); + + restClient.authenticateUser(newMember); + peopleApi.addSiteMembershipRequest(newMember, initialSiteMembership); + + restClient.authenticateUser(otherMember); + peopleApi.updateSiteMembershipRequest(newMember, updatedSiteMembership); + + peopleApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.FORBIDDEN); + } } \ No newline at end of file From 04340be53658d36d1584600073f3bc80ff333894 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Fri, 7 Oct 2016 15:29:41 +0300 Subject: [PATCH 0360/1491] TAS-1252 REST API - admin user is not able to update a site membership request --- .../UpdateSiteMembershipRequestSanityTests.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestSanityTests.java index ce8ceb712..d25e26644 100644 --- a/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestSanityTests.java @@ -160,4 +160,21 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest peopleApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.FORBIDDEN); } + + @TestRail(section = { "rest-api", "people" }, + executionType = ExecutionType.SANITY, description = "Verify admin is not able to update membership request of another user") + @Bug(id = "MNT-16919") + public void adminIsNotAbleToUpdateSiteMembershipRequestOfAnotherUser() throws JsonToModelConversionException, Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + + restClient.authenticateUser(newMember); + peopleApi.addSiteMembershipRequest(newMember, initialSiteMembership); + + restClient.authenticateUser(adminUser); + peopleApi.updateSiteMembershipRequest(newMember, updatedSiteMembership); + + peopleApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.FORBIDDEN); + } } \ No newline at end of file From 9a5b07f85b966ad7495defe8c5040f99cfd1d6be Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Fri, 7 Oct 2016 16:35:27 +0300 Subject: [PATCH 0361/1491] Updates due to new utility method createUserWithTenant --- .../rest/networks/RestGetNetworkTest.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkTest.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkTest.java index 19567c85e..c5108822a 100644 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkTest.java +++ b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkTest.java @@ -4,8 +4,10 @@ import org.alfresco.rest.RestTest; import org.alfresco.rest.requests.RestNetworksApi; import org.alfresco.rest.requests.RestTenantApi; import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.beans.factory.annotation.Autowired; @@ -29,10 +31,6 @@ public class RestGetNetworkTest extends RestTest UserModel adminAnotherTenantUser; SiteModel site; UserModel tenantUser; - UserModel managerTenantUser; - UserModel collaboratorTenantUser; - UserModel consumerTenantUser; - UserModel contributorTenantUser; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception @@ -45,12 +43,13 @@ public class RestGetNetworkTest extends RestTest adminAnotherTenantUser = UserModel.getAdminTenantUser(); tenantApi.createTenant(adminAnotherTenantUser); - tenantUser = dataUser.usingUser(adminTenantUser).createRandomTestUser("uTenant"); + tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); site = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); networkApi.useRestClient(restClient); } + @Bug(id = "MNT-16904") @Test(groups = "sanity") @TestRail(section = { "rest-api", "networks" }, executionType = ExecutionType.SANITY, description = "Verify non existing user gets another exisiting network with Rest API and checks the forbidden status") @@ -124,6 +123,7 @@ public class RestGetNetworkTest extends RestTest networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); } + @Test(groups = "sanity") @TestRail(section = { "rest-api", "networks" }, description = "Verify any tenant user gets another exisiting network with Rest API and checks the forbidden status") public void userTenantChecksIfAnotherExistingNetworkIsForbidden() throws Exception @@ -138,7 +138,7 @@ public class RestGetNetworkTest extends RestTest "networks" }, executionType = ExecutionType.SANITY, description = "Verify manager tenant user gets its network with Rest API and response is not empty") public void tenantManagerUserChecksIfNetworkIsPresent() throws Exception { - managerTenantUser = dataUser.usingUser(adminTenantUser).createRandomTestUser("manTenant"); + UserModel managerTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("manTenant"); dataUser.usingUser(adminTenantUser).addUserToSite(managerTenantUser, site, UserRole.SiteManager); restClient.authenticateUser(managerTenantUser); @@ -151,7 +151,7 @@ public class RestGetNetworkTest extends RestTest "networks" }, executionType = ExecutionType.SANITY, description = "Verify collaborator tenant user gets its network with Rest API and response is not empty") public void tenantCollaboratorUserChecksIfNetworkIsPresent() throws Exception { - collaboratorTenantUser = dataUser.usingUser(adminTenantUser).createRandomTestUser("colTenant"); + UserModel collaboratorTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("colTenant"); dataUser.usingUser(adminTenantUser).addUserToSite(collaboratorTenantUser, site, UserRole.SiteCollaborator); restClient.authenticateUser(collaboratorTenantUser); @@ -164,7 +164,7 @@ public class RestGetNetworkTest extends RestTest "networks" }, executionType = ExecutionType.SANITY, description = "Verify consumer tenant user gets its network with Rest API and response is not empty") public void tenantConsumerUserChecksIfNetworkIsPresent() throws Exception { - consumerTenantUser = dataUser.usingUser(adminTenantUser).createRandomTestUser("contTenant"); + UserModel consumerTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("consTenant"); dataUser.usingUser(adminTenantUser).addUserToSite(consumerTenantUser, site, UserRole.SiteConsumer); restClient.authenticateUser(consumerTenantUser); @@ -175,9 +175,9 @@ public class RestGetNetworkTest extends RestTest @Test(groups = "sanity") @TestRail(section = { "rest-api", "networks" }, executionType = ExecutionType.SANITY, description = "Verify contributor tenant user gets its network with Rest API and response is not empty") - public void tenantContributorUserChecksIfNetworkIsPresent() throws Exception + public void tenantContributorUserChecksIfItsNetworkIsPresent() throws Exception { - contributorTenantUser = dataUser.usingUser(adminTenantUser).createRandomTestUser("contTenant"); + UserModel contributorTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("contTenant"); dataUser.usingUser(adminTenantUser).addUserToSite(contributorTenantUser, site, UserRole.SiteContributor); restClient.authenticateUser(contributorTenantUser); From cd12b2a522fbfd4e2da6124acbd5c401e27686c9 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Fri, 7 Oct 2016 16:52:41 +0300 Subject: [PATCH 0362/1491] TAS-1254 REST API - valid request returns success status code 200 with Manager role --- .../favorites/GetFavoriteSanityTests.java | 2 +- .../rest/tags/GetNodeTagsSanityTests.java | 73 +++++++++++++++++++ 2 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java index 5b9884c0c..fac32e580 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java @@ -17,11 +17,11 @@ import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; @Test(groups = { "rest-api", "favorites", "sanity" }) public class GetFavoriteSanityTests extends RestTest { - @Autowired RestFavoritesApi favoritesAPI; diff --git a/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java new file mode 100644 index 000000000..566e8fc25 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java @@ -0,0 +1,73 @@ +package org.alfresco.rest.tags; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.requests.RestTagsApi; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.data.RandomData; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +@Test(groups = { "rest-api", "tags", "sanity" }) +public class GetNodeTagsSanityTests extends RestTest +{ + @Autowired + private DataUser dataUser; + + @Autowired + private RestTagsApi tagsAPI; + + private UserModel adminUserModel; + private SiteModel siteModel; + private ListUserWithRoles usersWithRoles; + private FileModel document; + + private String tagValue; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + restClient.authenticateUser(adminUserModel); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, + UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + + tagsAPI.useRestClient(restClient); + } + + @BeforeMethod(alwaysRun = true) + public void generateRandomTag() + { + tagValue = RandomData.getRandomName("tag"); + } + + @TestRail(section = { "rest-api", "tags" }, + executionType = ExecutionType.SANITY, description = "Verify site Manager is able to get node tags") + public void siteManagerIsAbleToRetrieveNodeTags() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + tagsAPI.addTag(document, tagValue); + + tagsAPI.getNodeTags(document) + .assertTagExists(tagValue); + + tagsAPI.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.OK); + } + +} \ No newline at end of file From e55bbf4cc28d4fcf6ce433aeb9fc812fbdfce87f Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Fri, 7 Oct 2016 16:54:06 +0300 Subject: [PATCH 0363/1491] TAS-920 valid request returns success status code 200 with Collaborator role --- .../alfresco/rest/tags/GetNodeTagsSanityTests.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java index 566e8fc25..c45a8a50c 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java @@ -70,4 +70,17 @@ public class GetNodeTagsSanityTests extends RestTest .assertStatusCodeIs(HttpStatus.OK); } + @TestRail(section = { "rest-api", "tags" }, + executionType = ExecutionType.SANITY, description = "Verify site Collaborator is able to get node tags") + public void siteCollaboratorIsAbleToRetrieveNodeTags() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + tagsAPI.addTag(document, tagValue); + + tagsAPI.getNodeTags(document).assertTagExists(tagValue); + + tagsAPI.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.OK); + } + } \ No newline at end of file From f231fae9e23c159b1ede54b12425f0aeff14cbf4 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Fri, 7 Oct 2016 16:56:02 +0300 Subject: [PATCH 0364/1491] TAS-921 valid request returns success status code 200 with Contributor role --- .../alfresco/rest/tags/GetNodeTagsSanityTests.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java index c45a8a50c..f4eecc98d 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java @@ -83,4 +83,16 @@ public class GetNodeTagsSanityTests extends RestTest .assertStatusCodeIs(HttpStatus.OK); } + @TestRail(section = { "rest-api", "tags" }, + executionType = ExecutionType.SANITY, description = "Verify site Contributor is able to get node tags") + public void siteContributorIsAbleToRetrieveNodeTags() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + tagsAPI.addTag(document, tagValue); + + tagsAPI.getNodeTags(document).assertTagExists(tagValue); + + tagsAPI.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.OK); + } } \ No newline at end of file From a108ac3e2995fc3170d73ecd46cd940bed6c8844 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Fri, 7 Oct 2016 17:19:14 +0300 Subject: [PATCH 0365/1491] TAS-1255 REST API - valid request returns success status code 200 with Consumer role --- .../rest/tags/GetNodeTagsSanityTests.java | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java index f4eecc98d..42352ef66 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java @@ -48,12 +48,9 @@ public class GetNodeTagsSanityTests extends RestTest document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); tagsAPI.useRestClient(restClient); - } - - @BeforeMethod(alwaysRun = true) - public void generateRandomTag() - { + tagValue = RandomData.getRandomName("tag"); + tagsAPI.addTag(document, tagValue); } @TestRail(section = { "rest-api", "tags" }, @@ -75,7 +72,7 @@ public class GetNodeTagsSanityTests extends RestTest public void siteCollaboratorIsAbleToRetrieveNodeTags() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - tagsAPI.addTag(document, tagValue); + tagsAPI.getNodeTags(document).assertTagExists(tagValue); @@ -88,8 +85,17 @@ public class GetNodeTagsSanityTests extends RestTest public void siteContributorIsAbleToRetrieveNodeTags() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - tagsAPI.addTag(document, tagValue); + tagsAPI.getNodeTags(document).assertTagExists(tagValue); + tagsAPI.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { "rest-api", "tags" }, + executionType = ExecutionType.SANITY, description = "Verify site Consumer is able to get node tags") + public void siteConsumerIsAbleToRetrieveNodeTags() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); tagsAPI.getNodeTags(document).assertTagExists(tagValue); tagsAPI.usingRestWrapper() From 19071f28d7037cc5bda8b329191a422916c62e7b Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Fri, 7 Oct 2016 18:33:31 +0300 Subject: [PATCH 0366/1491] TAS-1256 REST API - valid request returns success status code 200 with admin --- .../rest/sites/GetSiteContainerSanityTests.java | 2 ++ .../alfresco/rest/tags/GetNodeTagsSanityTests.java | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java index 9a0430995..f6d8b65ab 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java @@ -7,6 +7,7 @@ import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.beans.factory.annotation.Autowired; @@ -91,6 +92,7 @@ public class GetSiteContainerSanityTests extends RestTest @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Failed authentication get site container call returns status code 401") + @Bug(id="MNT-16904") public void unauthenticatedUserIsNotAuthorizedToRetrieveSiteContainer() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); diff --git a/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java index 42352ef66..e2c808b05 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java @@ -101,4 +101,15 @@ public class GetNodeTagsSanityTests extends RestTest tagsAPI.usingRestWrapper() .assertStatusCodeIs(HttpStatus.OK); } + + @TestRail(section = { "rest-api", "tags" }, + executionType = ExecutionType.SANITY, description = "Verify admin is able to get node tags") + public void adminIsAbleToRetrieveNodeTags() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel); + tagsAPI.getNodeTags(document).assertTagExists(tagValue); + + tagsAPI.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.OK); + } } \ No newline at end of file From 592c8e9908a7a3bfb47220b7e4dfb1b9a84c76ca Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Fri, 7 Oct 2016 18:36:20 +0300 Subject: [PATCH 0367/1491] TAS-1257 REST API - request with unauthenticated user returns status code 401 --- .../alfresco/rest/tags/GetNodeTagsSanityTests.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java index e2c808b05..fac8e59aa 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java @@ -11,12 +11,12 @@ import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @Test(groups = { "rest-api", "tags", "sanity" }) @@ -112,4 +112,16 @@ public class GetNodeTagsSanityTests extends RestTest tagsAPI.usingRestWrapper() .assertStatusCodeIs(HttpStatus.OK); } + + @TestRail(section = { "rest-api", "tags" }, + executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to get node tags") + @Bug(id="MNT-16904") + public void unauthenticatedUserIsNotAbleToRetrieveNodeTags() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(new UserModel("random user", "random password")); + tagsAPI.getNodeTags(document).assertTagExists(tagValue); + + tagsAPI.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + } } \ No newline at end of file From 6751e8b9cf131dafecdf11fbdf698883b11aff2b Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Fri, 7 Oct 2016 18:37:14 +0300 Subject: [PATCH 0368/1491] listener updates --- e2e-test/java/org/alfresco/rest/tags/GetTagSanityTests.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/tags/GetTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagSanityTests.java index 195ccb8a1..e76a13e0c 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetTagSanityTests.java @@ -7,22 +7,19 @@ import org.alfresco.rest.model.RestTagModel; import org.alfresco.rest.requests.RestTagsApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; -import org.alfresco.utility.data.RandomData; import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.data.RandomData; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.log.LogsListener; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; -import org.testng.annotations.Listeners; import org.testng.annotations.Test; @Test(groups = { "rest-api", "tags", "sanity" }) -@Listeners(LogsListener.class) public class GetTagSanityTests extends RestTest { From d50865c55002073f375423a97a97f2ac44d28aac Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Fri, 7 Oct 2016 19:20:44 +0300 Subject: [PATCH 0369/1491] TAS-711 getNetworks --- .../rest/comments/GetCommentsSanityTests.java | 2 + .../comments/PostCommentsSanityTests.java | 2 + .../comments/UpdateCommentsSanityTests.java | 1 + .../favorites/DeleteFavoritesSanityTests.java | 13 +-- .../RestGetNetworkForPersonSanityTests.java | 10 ++- .../RestGetNetworksForPersonSanityTests.java | 86 +++++++++++++++++++ 6 files changed, 101 insertions(+), 13 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java index 6b38898d0..365684cdb 100644 --- a/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java @@ -10,6 +10,7 @@ import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.beans.factory.annotation.Autowired; @@ -92,6 +93,7 @@ public class GetCommentsSanityTests extends RestTest @TestRail(section={"rest-api", "comments"}, executionType= ExecutionType.SANITY, description= "Verify Manager user gets status code 401 if authentication call fails") + @Bug(id="MNT-16904") public void managerIsNotAbleToRetrieveCommentIfAuthenticationFails() throws JsonToModelConversionException, Exception { UserModel nonexistentModel = new UserModel("nonexistentUser", "nonexistentPassword"); diff --git a/e2e-test/java/org/alfresco/rest/comments/PostCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/PostCommentsSanityTests.java index a4a360f24..1930a75a5 100644 --- a/e2e-test/java/org/alfresco/rest/comments/PostCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/PostCommentsSanityTests.java @@ -10,6 +10,7 @@ import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.beans.factory.annotation.Autowired; @@ -88,6 +89,7 @@ public class PostCommentsSanityTests extends RestTest @TestRail(section = { "rest-api", "comments" }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user gets status code 401 on post comments call") + @Bug(id="MNT-16904") public void unauthenticatedUserIsNotAbleToAddComment() throws JsonToModelConversionException, Exception { restClient.authenticateUser(new UserModel("random user", "random password")); diff --git a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java index b52dff072..3098da11f 100644 --- a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java @@ -111,6 +111,7 @@ public class UpdateCommentsSanityTests extends RestTest @TestRail(section = { "rest-api", "comments" }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user gets status code 401 on update comment call") + @Bug(id="MNT-16904") public void unauthenticatedUserIsNotAbleToUpdateComment() throws JsonToModelConversionException, Exception { UserModel incorrectUserModel = new UserModel("userName", "password"); diff --git a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoritesSanityTests.java index 65efd135f..4630342b2 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoritesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoritesSanityTests.java @@ -1,14 +1,11 @@ package org.alfresco.rest.favorites; -import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.requests.RestFavoritesApi; import org.alfresco.rest.requests.RestSitesApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; @@ -30,8 +27,6 @@ public class DeleteFavoritesSanityTests extends RestTest private UserModel adminUserModel; private SiteModel siteModel; - private FileModel fileModel; - private FolderModel folderModel; private ListUserWithRoles usersWithRoles; @BeforeClass(alwaysRun = true) @@ -40,8 +35,6 @@ public class DeleteFavoritesSanityTests extends RestTest adminUserModel = dataUser.getAdminUser(); restClient.authenticateUser(adminUserModel); siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); - fileModel = dataContent.usingUser(adminUserModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); favoritesAPI.useRestClient(restClient); sitesApi.useRestClient(restClient); @@ -109,7 +102,7 @@ public class DeleteFavoritesSanityTests extends RestTest favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), siteModel); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); favoritesAPI.deleteSiteFromFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), siteModel); - favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); + favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } @TestRail(section = { "rest-api", @@ -121,7 +114,7 @@ public class DeleteFavoritesSanityTests extends RestTest favoritesAPI.addSiteToFavorites(adminUserModel, siteModel); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); favoritesAPI.deleteSiteFromFavorites(adminUserModel, siteModel); - favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); + favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } @TestRail(section = { "rest-api", @@ -133,7 +126,7 @@ public class DeleteFavoritesSanityTests extends RestTest favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), siteModel); restClient.authenticateUser(adminUserModel); favoritesAPI.deleteSiteFromFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), siteModel); - favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); + favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } @TestRail(section = { "rest-api", diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java index 8dd34398e..e45ee1d12 100644 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java @@ -4,6 +4,7 @@ import org.alfresco.rest.RestTest; import org.alfresco.rest.requests.RestNetworksApi; import org.alfresco.rest.requests.RestTenantApi; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.beans.factory.annotation.Autowired; @@ -34,10 +35,11 @@ public class RestGetNetworkForPersonSanityTests extends RestTest tenantApi.useRestClient(restClient); tenantApi.createTenant(adminTenantUser); - tenantUser = dataUser.usingUser(adminTenantUser).createRandomTestUser("uTenant"); + tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); networkApi.useRestClient(restClient); } + @Bug(id = "MNT-16904") @Test(groups = "sanity") @TestRail(section = { "rest-api", "networks" }, executionType = ExecutionType.SANITY, description = "Verify non existing user gets another exisiting network with Rest API and checks the forbidden status") @@ -67,7 +69,7 @@ public class RestGetNetworkForPersonSanityTests extends RestTest { restClient.authenticateUser(tenantUser); networkApi.getNetworkForUser(adminTenantUser); - networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); } @Test(groups = "sanity") @@ -75,10 +77,12 @@ public class RestGetNetworkForPersonSanityTests extends RestTest "networks" }, executionType = ExecutionType.SANITY, description = "Verify admin tenant user is not authorized to check network of another user with Rest API and checks the forbidden status") public void adminTenantUserIsNotAuthorizedToCheckNetworkOfAnotherUser() throws Exception { + UserModel secondAdminTenantUser = UserModel.getAdminTenantUser(); + tenantApi.createTenant(secondAdminTenantUser); tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("anotherTenant"); restClient.authenticateUser(adminTenantUser); networkApi.getNetworkForUser(tenantUser); - networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); } } diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonSanityTests.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonSanityTests.java new file mode 100644 index 000000000..c73237065 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonSanityTests.java @@ -0,0 +1,86 @@ +package org.alfresco.rest.networks; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.requests.RestNetworksApi; +import org.alfresco.rest.requests.RestTenantApi; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +@Test(groups = { "rest-api", "networks", "sanity" }) +public class RestGetNetworksForPersonSanityTests extends RestTest +{ + @Autowired + RestTenantApi tenantApi; + + @Autowired + RestNetworksApi networkApi; + + private UserModel adminUserModel; + UserModel adminTenantUser; + UserModel tenantUser; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUserModel); + tenantApi.useRestClient(restClient); + tenantApi.createTenant(adminTenantUser); + + tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + networkApi.useRestClient(restClient); + } + + @Bug(id = "MNT-16904") + @Test(groups = "sanity") + @TestRail(section = { "rest-api", + "networks" }, executionType = ExecutionType.SANITY, description = "Verify non existing user gets another exisiting network with Rest API and checks the forbidden status") + public void nonExistingTenantUserIsNotAuthorizedToRequest() throws Exception + { + UserModel tenantUser = new UserModel("nonexisting", "password"); + tenantUser.setDomain(adminTenantUser.getDomain()); + restClient.authenticateUser(tenantUser); + networkApi.getNetworksForUser(adminTenantUser); + networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + } + + @Test(groups = "sanity") + @TestRail(section = { "rest-api", + "networks" }, executionType = ExecutionType.SANITY, description = "Verify tenant admin user gets specific network with Rest API and response is not empty") + public void adminTenantChecksIfNetworkIsPresent() throws Exception + { + restClient.authenticateUser(adminTenantUser); + networkApi.getNetworksForUser(adminTenantUser); + networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = "sanity") + @TestRail(section = { "rest-api", + "networks" }, executionType = ExecutionType.SANITY, description = "Verify tenant user is not authorized to check network of admin user with Rest API and checks the forbidden status") + public void tenantUserIsNotAuthorizedToCheckNetworkOfAdminUser() throws Exception + { + restClient.authenticateUser(tenantUser); + networkApi.getNetworksForUser(adminTenantUser); + networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); + } + + @Test(groups = "sanity") + @TestRail(section = { "rest-api", + "networks" }, executionType = ExecutionType.SANITY, description = "Verify admin tenant user is not authorized to check network of another user with Rest API and checks the forbidden status") + public void adminTenantUserIsNotAuthorizedToCheckNetworkOfAnotherUser() throws Exception + { + UserModel secondAdminTenantUser = UserModel.getAdminTenantUser(); + tenantApi.createTenant(secondAdminTenantUser); + tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("anotherTenant"); + restClient.authenticateUser(secondAdminTenantUser); + networkApi.getNetworksForUser(tenantUser); + networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); + } +} From 04d5c2b455e36f8287fb1e2d33e8eb73082dbeda Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Mon, 10 Oct 2016 10:02:34 +0300 Subject: [PATCH 0370/1491] TAS-1261 Add @bug annotation to tests --- .../people/DeleteSiteMembershipRequestSanityTests.java | 1 - .../org/alfresco/rest/sites/AddSiteMemberSanityTests.java | 3 +++ .../alfresco/rest/sites/GetSiteContainerSanityTests.java | 2 ++ .../alfresco/rest/sites/GetSiteContainersSanityTests.java | 4 +++- .../alfresco/rest/sites/GetSiteMembersSanityTests.java | 8 +++++--- .../java/org/alfresco/rest/sites/GetSiteSanityTests.java | 6 ++++-- .../java/org/alfresco/rest/sites/GetSitesSanityTests.java | 4 +++- .../alfresco/rest/sites/RemoveSiteMemberSanityTests.java | 2 +- 8 files changed, 21 insertions(+), 9 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java index 64ac71615..3a24e5084 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java @@ -139,7 +139,6 @@ public class DeleteSiteMembershipRequestSanityTests extends RestTest peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } - @Bug(id="MNT-16904") @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Failed authentication get site member call returns status code 401") public void unauthenticatedUserIsNotAuthorizedToDeleteSiteMmebershipRequest() throws JsonToModelConversionException, Exception diff --git a/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java index 26a8b26cd..44eb58d0d 100644 --- a/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java @@ -8,15 +8,18 @@ import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; +import org.alfresco.utility.report.HtmlReportListener; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.social.alfresco.api.entities.Role; import org.testng.annotations.BeforeClass; +import org.testng.annotations.Listeners; import org.testng.annotations.Test; @Test(groups = { "rest-api", "sites", "sanity" }) +@Listeners(value=HtmlReportListener.class) public class AddSiteMemberSanityTests extends RestTest { @Autowired diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java index 9a0430995..a73fe9cb1 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java @@ -7,6 +7,7 @@ import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.beans.factory.annotation.Autowired; @@ -89,6 +90,7 @@ public class GetSiteContainerSanityTests extends RestTest siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + @Bug(id="MNT-16904") @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Failed authentication get site container call returns status code 401") public void unauthenticatedUserIsNotAuthorizedToRetrieveSiteContainer() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java index b1071dae5..5782402f4 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java @@ -9,6 +9,7 @@ import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.beans.factory.annotation.Autowired; @@ -90,9 +91,10 @@ public class GetSiteContainersSanityTests extends RestTest siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + @Bug(id="MNT-16904") @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Failed authentication get site containers call returns status code 401 with Manager role") - public void getSiteContainersWithManagerRoleFailedAuth() throws JsonToModelConversionException, Exception + public void unauthenticatedUserIsNotAuthorizedToRetrieveSiteContainers() throws JsonToModelConversionException, Exception { userModel = dataUser.createRandomTestUser(); userModel.setPassword("user wrong password"); diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java index 93bb6ea26..e05fcd296 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java @@ -10,6 +10,7 @@ import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.beans.factory.annotation.Autowired; @@ -38,7 +39,7 @@ public class GetSiteMembersSanityTests extends RestTest private UserModel userModel; @BeforeClass(alwaysRun=true) - public void initTest() throws DataPreparationException + public void dataPreparation() throws DataPreparationException { adminUser = dataUser.getAdminUser(); siteAPI.useRestClient(restClient); @@ -91,9 +92,10 @@ public class GetSiteMembersSanityTests extends RestTest siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + @Bug(id="MNT-16904") @TestRail(section = {"rest-api", "sites" }, executionType = ExecutionType.SANITY, - description = "Failed authentication get site members call returns status code 401 with Manager role") - public void getSiteMembersWithManagerRoleFailedAuth() throws JsonToModelConversionException, Exception + description = "Failed authentication get site members call returns status code 401") + public void unauthenticatedUserIsNotAuthorizedToRetrieveSiteMembers() throws JsonToModelConversionException, Exception { userModel = dataUser.createRandomTestUser(); userModel.setPassword("user wrong password"); diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteSanityTests.java index ba94aa109..c7e8d7555 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteSanityTests.java @@ -10,6 +10,7 @@ import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.beans.factory.annotation.Autowired; @@ -93,9 +94,10 @@ public class GetSiteSanityTests extends RestTest siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + @Bug(id="MNT-16904") @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, - description = "Failed authentication get site call returns status code 401 with Manager role") - public void getSiteWithManagerRoleFailedAuth() throws JsonToModelConversionException, Exception + description = "Failed authentication get site call returns status code 401") + public void unauthenticatedUserIsNotAuthorizedToRetrieveSite() throws JsonToModelConversionException, Exception { userModel = dataUser.createRandomTestUser(); userModel.setPassword("user wrong password"); diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java index 293173d8d..b1b759fac 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java @@ -9,6 +9,7 @@ import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.beans.factory.annotation.Autowired; @@ -94,8 +95,9 @@ public class GetSitesSanityTests extends RestTest siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + @Bug(id="MNT-16904") @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, - description = "Failed authentication get sites call returns status code 401 with Manager role") + description = "Failed authentication get sites call returns status code 401") public void unauthenticatedUserIsNotAuthorizedToRetrieveSites() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); diff --git a/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java index c937001b1..6b3b1ec71 100644 --- a/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java @@ -95,7 +95,7 @@ public class RemoveSiteMemberSanityTests extends RestTest @TestRail(section = {"rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify that unauthenticated user is not able to delete site member") - public void unauthenticatedUserIsNotAuthorizedToDeleteSiteMmeber() throws Exception{ + public void unauthenticatedUserIsNotAuthorizedToDeleteSiteMember() throws Exception{ UserModel inexistentUser = new UserModel("inexistent user", "inexistent password"); restClient.authenticateUser(inexistentUser); restSitesAPI.deleteSiteMember(siteModel, testUserModel); From 311d9c582166ae6437589715db7def61b904c79d Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Mon, 10 Oct 2016 10:38:08 +0300 Subject: [PATCH 0371/1491] Fix for networks tests --- .../rest/networks/RestGetNetworkForPersonSanityTests.java | 4 ++-- .../rest/networks/RestGetNetworksForPersonSanityTests.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java index e45ee1d12..7c0fb2ad8 100644 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java @@ -79,9 +79,9 @@ public class RestGetNetworkForPersonSanityTests extends RestTest { UserModel secondAdminTenantUser = UserModel.getAdminTenantUser(); tenantApi.createTenant(secondAdminTenantUser); - tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("anotherTenant"); + UserModel secondTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("anotherTenant"); restClient.authenticateUser(adminTenantUser); - networkApi.getNetworkForUser(tenantUser); + networkApi.getNetworkForUser(secondTenantUser); networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); } diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonSanityTests.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonSanityTests.java index c73237065..91c153b08 100644 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonSanityTests.java @@ -78,9 +78,9 @@ public class RestGetNetworksForPersonSanityTests extends RestTest { UserModel secondAdminTenantUser = UserModel.getAdminTenantUser(); tenantApi.createTenant(secondAdminTenantUser); - tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("anotherTenant"); + UserModel secondTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("anotherTenant"); restClient.authenticateUser(secondAdminTenantUser); - networkApi.getNetworksForUser(tenantUser); + networkApi.getNetworksForUser(secondTenantUser); networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); } } From a1950728116ff4a06445d0af9fa9bf1e8739c12d Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Mon, 10 Oct 2016 10:56:17 +0300 Subject: [PATCH 0372/1491] Remove listener from class --- .../java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java index 44eb58d0d..26a8b26cd 100644 --- a/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java @@ -8,18 +8,15 @@ import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; -import org.alfresco.utility.report.HtmlReportListener; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.social.alfresco.api.entities.Role; import org.testng.annotations.BeforeClass; -import org.testng.annotations.Listeners; import org.testng.annotations.Test; @Test(groups = { "rest-api", "sites", "sanity" }) -@Listeners(value=HtmlReportListener.class) public class AddSiteMemberSanityTests extends RestTest { @Autowired From eee67602d95a6848a9790d3d271a74cb17b66b49 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Mon, 10 Oct 2016 15:18:14 +0300 Subject: [PATCH 0373/1491] Added corresponding bug for 2 tests --- .../java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java | 2 ++ e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java | 2 ++ 2 files changed, 4 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java index 874047c7a..0d7007111 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java @@ -8,6 +8,7 @@ import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.beans.factory.annotation.Autowired; @@ -89,6 +90,7 @@ public class GetSiteMemberSanityTests extends RestTest @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Failed authentication get site member call returns status code 401") + @Bug(id = "MNT-16904") public void unauthenticatedUserIsNotAuthorizedToRetrieveSiteMember() throws JsonToModelConversionException, Exception { UserModel inexistentUser = new UserModel("inexistent user", "inexistent password"); diff --git a/e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java index 733a17bfe..4b6f7d7f2 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java @@ -8,6 +8,7 @@ import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.beans.factory.annotation.Autowired; @@ -85,6 +86,7 @@ public class GetTagsSanityTests extends RestTest } @TestRail(section = { "rest-api", "tags" }, executionType = ExecutionType.SANITY, description = "Failed authentication get tags call returns status code 401 with Manager role") + @Bug(id = "MNT-16904") public void getTagsWithManagerRoleFailedAuth() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); From 7d5210ffa58efbe2e1891f8db71051a4b3a77d82 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Mon, 10 Oct 2016 18:57:27 +0300 Subject: [PATCH 0374/1491] remove unused imports --- .../java/org/alfresco/rest/networks/RestGetNetworkTest.java | 1 - .../org/alfresco/rest/sites/GetSiteContainerSanityTests.java | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkTest.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkTest.java index c5108822a..977056fde 100644 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkTest.java +++ b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkTest.java @@ -4,7 +4,6 @@ import org.alfresco.rest.RestTest; import org.alfresco.rest.requests.RestNetworksApi; import org.alfresco.rest.requests.RestTenantApi; import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java index 7495a8369..871be5d45 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java @@ -90,7 +90,7 @@ public class GetSiteContainerSanityTests extends RestTest siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @Bug(id="MNT-16904") + @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Failed authentication get site container call returns status code 401") @Bug(id="MNT-16904") From e60a3b3bf3566e145bf3e9e88f82440d44bd74c5 Mon Sep 17 00:00:00 2001 From: cagache Date: Tue, 11 Oct 2016 10:42:03 +0300 Subject: [PATCH 0375/1491] renamed class --- ...yTests.java => AddCommentSanityTests.java} | 200 +++++++++--------- 1 file changed, 100 insertions(+), 100 deletions(-) rename e2e-test/java/org/alfresco/rest/comments/{PostCommentsSanityTests.java => AddCommentSanityTests.java} (95%) diff --git a/e2e-test/java/org/alfresco/rest/comments/PostCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java similarity index 95% rename from e2e-test/java/org/alfresco/rest/comments/PostCommentsSanityTests.java rename to e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java index 1930a75a5..ec1483ff3 100644 --- a/e2e-test/java/org/alfresco/rest/comments/PostCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java @@ -1,100 +1,100 @@ -package org.alfresco.rest.comments; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.requests.RestCommentsApi; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser; -import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -@Test(groups = { "rest-api", "comments", "sanity" }) -public class PostCommentsSanityTests extends RestTest -{ - @Autowired - RestCommentsApi commentsAPI; - - @Autowired - DataUser dataUser; - - private UserModel adminUserModel; - private FileModel document; - private SiteModel siteModel; - private ListUserWithRoles usersWithRoles; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - restClient.authenticateUser(adminUserModel); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - commentsAPI.useRestClient(restClient); - document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); - } - - @TestRail(section = { "rest-api", - "comments" }, executionType = ExecutionType.SANITY, description = "Verify admin user adds comments with Rest API and status code is 201") - public void admiIsAbleToAddComment() throws JsonToModelConversionException, Exception - { - commentsAPI.addComment(document, "This is a new comment added by " + adminUserModel.getUsername()); - commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); - } - - @TestRail(section = { "rest-api", - "comments" }, executionType = ExecutionType.SANITY, description = "Verify Manager user adds comments with Rest API and status code is 201") - public void managerIsAbleToAddComment() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - commentsAPI.addComment(document, "This is a new comment added by user with role: " + UserRole.SiteManager); - commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); - } - - @TestRail(section = { "rest-api", - "comments" }, executionType = ExecutionType.SANITY, description = "Verify Contributor user adds comments with Rest API and status code is 201") - public void contributorIsAbleToAddComment() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - commentsAPI.addComment(document, "This is a new comment added by user with role" + UserRole.SiteContributor); - commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); - } - - @TestRail(section = { "rest-api", - "comments" }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user adds comments with Rest API and status code is 201") - public void collaboratorIsAbleToAddComment() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - commentsAPI.addComment(document, "This is a new comment added by user with role: " + UserRole.SiteCollaborator); - commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); - } - - @TestRail(section = { "rest-api", - "comments" }, executionType = ExecutionType.SANITY, description = "Verify Consumer user adds comments with Rest API and status code is 201") - public void consumerIsAbleToAddComment() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - commentsAPI.addComment(document, "This is a new comment added by user with role: " + UserRole.SiteConsumer); - commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); - } - - @TestRail(section = { "rest-api", - "comments" }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user gets status code 401 on post comments call") - @Bug(id="MNT-16904") - public void unauthenticatedUserIsNotAbleToAddComment() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(new UserModel("random user", "random password")); - commentsAPI.addComment(document, "This is a new comment"); - commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); - } - -} +package org.alfresco.rest.comments; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.requests.RestCommentsApi; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +@Test(groups = { "rest-api", "comments", "sanity" }) +public class AddCommentSanityTests extends RestTest +{ + @Autowired + RestCommentsApi commentsAPI; + + @Autowired + DataUser dataUser; + + private UserModel adminUserModel; + private FileModel document; + private SiteModel siteModel; + private ListUserWithRoles usersWithRoles; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + restClient.authenticateUser(adminUserModel); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + commentsAPI.useRestClient(restClient); + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + } + + @TestRail(section = { "rest-api", + "comments" }, executionType = ExecutionType.SANITY, description = "Verify admin user adds comments with Rest API and status code is 201") + public void adminIsAbleToAddComment() throws JsonToModelConversionException, Exception + { + commentsAPI.addComment(document, "This is a new comment added by " + adminUserModel.getUsername()); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + } + + @TestRail(section = { "rest-api", + "comments" }, executionType = ExecutionType.SANITY, description = "Verify Manager user adds comments with Rest API and status code is 201") + public void managerIsAbleToAddComment() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + commentsAPI.addComment(document, "This is a new comment added by user with role: " + UserRole.SiteManager); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + } + + @TestRail(section = { "rest-api", + "comments" }, executionType = ExecutionType.SANITY, description = "Verify Contributor user adds comments with Rest API and status code is 201") + public void contributorIsAbleToAddComment() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + commentsAPI.addComment(document, "This is a new comment added by user with role" + UserRole.SiteContributor); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + } + + @TestRail(section = { "rest-api", + "comments" }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user adds comments with Rest API and status code is 201") + public void collaboratorIsAbleToAddComment() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + commentsAPI.addComment(document, "This is a new comment added by user with role: " + UserRole.SiteCollaborator); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + } + + @TestRail(section = { "rest-api", + "comments" }, executionType = ExecutionType.SANITY, description = "Verify Consumer user adds comments with Rest API and status code is 201") + public void consumerIsAbleToAddComment() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + commentsAPI.addComment(document, "This is a new comment added by user with role: " + UserRole.SiteConsumer); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + } + + @TestRail(section = { "rest-api", + "comments" }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user gets status code 401 on post comments call") + @Bug(id="MNT-16904") + public void unauthenticatedUserIsNotAbleToAddComment() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(new UserModel("random user", "random password")); + commentsAPI.addComment(document, "This is a new comment"); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + } + +} From 317908ed6e43dff873db6f7c0a288e4c02da161e Mon Sep 17 00:00:00 2001 From: cagache Date: Tue, 11 Oct 2016 10:45:42 +0300 Subject: [PATCH 0376/1491] TAS-1378 - add comments by admin --- .../rest/comments/AddCommentsSanityTests.java | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java new file mode 100644 index 000000000..2d225a7b6 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java @@ -0,0 +1,65 @@ +package org.alfresco.rest.comments; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.requests.RestCommentsApi; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.data.RandomData; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +/** + * Created by Claudia Agache on 10/10/2016. + */ +@Test(groups = { "rest-api", "comments", "sanity" }) +public class AddCommentsSanityTests extends RestTest +{ + @Autowired RestCommentsApi commentsAPI; + + @Autowired DataUser dataUser; + + private UserModel adminUserModel; + private FileModel document; + private SiteModel siteModel; + private DataUser.ListUserWithRoles usersWithRoles; + private String comment1, comment2; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + restClient.authenticateUser(adminUserModel); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + commentsAPI.useRestClient(restClient); + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + } + + @BeforeMethod(alwaysRun = true) + public void generateRandomComments() + { + comment1 = RandomData.getRandomName("comment1"); + comment2 = RandomData.getRandomName("comment2"); + } + + @TestRail(section = { "rest-api", + "comments" }, executionType = ExecutionType.SANITY, description = "Verify admin user adds multiple comments with Rest API and status code is 201") + public void adminIsAbleToAddComments() throws JsonToModelConversionException, Exception + { + commentsAPI.addComments(document, comment1, comment2); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + } + + +} From c5131c88434333137f0c5b9a5bd504d5dc566a55 Mon Sep 17 00:00:00 2001 From: cagache Date: Tue, 11 Oct 2016 10:46:10 +0300 Subject: [PATCH 0377/1491] TAS-1377 - add comments by manager --- .../alfresco/rest/comments/AddCommentsSanityTests.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java index 2d225a7b6..2c31b800b 100644 --- a/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java @@ -61,5 +61,13 @@ public class AddCommentsSanityTests extends RestTest commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } + @TestRail(section = { "rest-api", + "comments" }, executionType = ExecutionType.SANITY, description = "Verify Manager user adds multiple comments with Rest API and status code is 201") + public void managerIsAbleToAddComments() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + commentsAPI.addComments(document, comment1, comment2); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + } } From a8187e550e1c7b41ac5b7625571fc3faf55a0db2 Mon Sep 17 00:00:00 2001 From: cagache Date: Tue, 11 Oct 2016 10:47:18 +0300 Subject: [PATCH 0378/1491] TAS-1379 - add comments by contributor --- .../alfresco/rest/comments/AddCommentsSanityTests.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java index 2c31b800b..fb393cde2 100644 --- a/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java @@ -70,4 +70,13 @@ public class AddCommentsSanityTests extends RestTest commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } + @TestRail(section = { "rest-api", + "comments" }, executionType = ExecutionType.SANITY, description = "Verify Contributor user adds multiple comments with Rest API and status code is 201") + public void contributorIsAbleToAddComments() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + commentsAPI.addComments(document, comment1, comment2); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + } + } From a411695a3004f2ff2c088b96a6c8ea924096619d Mon Sep 17 00:00:00 2001 From: cagache Date: Tue, 11 Oct 2016 10:48:34 +0300 Subject: [PATCH 0379/1491] TAS-1381 - add comments by collaborator --- .../alfresco/rest/comments/AddCommentsSanityTests.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java index fb393cde2..98ad503f1 100644 --- a/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java @@ -79,4 +79,13 @@ public class AddCommentsSanityTests extends RestTest commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } + @TestRail(section = { "rest-api", + "comments" }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user adds multiple comments with Rest API and status code is 201") + public void collaboratorIsAbleToAddComments() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + commentsAPI.addComments(document, comment1, comment2); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + } + } From 0717c2bc90554cb8bd700561191cd1b0190e98a7 Mon Sep 17 00:00:00 2001 From: cagache Date: Tue, 11 Oct 2016 10:50:39 +0300 Subject: [PATCH 0380/1491] TAS-1382 - add comments by consumer --- .../alfresco/rest/comments/AddCommentsSanityTests.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java index 98ad503f1..b771591a4 100644 --- a/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java @@ -88,4 +88,13 @@ public class AddCommentsSanityTests extends RestTest commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } + @TestRail(section = { "rest-api", + "comments" }, executionType = ExecutionType.SANITY, description = "Verify Consumer user adds multiple comments with Rest API and status code is 201") + public void consumerIsAbleToAddComments() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + commentsAPI.addComments(document, comment1, comment2); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + } + } From b7d7f46441b0ae224c85efdcd6fe0f4db03880fa Mon Sep 17 00:00:00 2001 From: cagache Date: Tue, 11 Oct 2016 10:54:25 +0300 Subject: [PATCH 0381/1491] TAS-1385 - add comments by unauthenticated user --- .../alfresco/rest/comments/AddCommentsSanityTests.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java index b771591a4..2ff5857fd 100644 --- a/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java @@ -97,4 +97,13 @@ public class AddCommentsSanityTests extends RestTest commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } + @TestRail(section = { "rest-api", + "comments" }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user gets status code 401 on post multiple comments call") + @Bug(id="MNT-16904") + public void unauthenticatedUserIsNotAbleToAddComments() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(new UserModel("random user", "random password")); + commentsAPI.addComments(document, comment1, comment2); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + } } From 69d305952047b99166d76c898da2416ecfadb99c Mon Sep 17 00:00:00 2001 From: cagache Date: Tue, 11 Oct 2016 11:11:31 +0300 Subject: [PATCH 0382/1491] TAS-1384 replaced CommentsContent & FavoritesSiteBody classes with JsonBodyGenerator --- .../comments/UpdateCommentsSanityTests.java | 47 +++++-------------- .../org/alfresco/rest/demo/RestDemoTests.java | 4 +- .../rest/demo/SampleCommentsTests.java | 4 +- 3 files changed, 15 insertions(+), 40 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java index 3098da11f..4d1b6355a 100644 --- a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java @@ -2,7 +2,6 @@ package org.alfresco.rest.comments; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; -import org.alfresco.rest.body.CommentContent; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestCommentModel; import org.alfresco.rest.requests.RestCommentsApi; @@ -53,9 +52,7 @@ public class UpdateCommentsSanityTests extends RestTest "comments" }, executionType = ExecutionType.SANITY, description = "Verify Admin user updates comments and status code is 200") public void adminIsAbleToUpdateComments() throws JsonToModelConversionException, Exception { - CommentContent commentContent = new CommentContent("This is the updated comment with admin user"); - - commentsAPI.updateComment(document, commentModel, commentContent); + commentsAPI.updateComment(document, commentModel, "This is the updated comment with admin user"); commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -64,47 +61,35 @@ public class UpdateCommentsSanityTests extends RestTest public void managerIsAbleToUpdateComment() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - - CommentContent commentContent = new CommentContent("This is the updated comment with Manager user"); - - commentsAPI.updateComment(document, commentModel, commentContent); + commentsAPI.updateComment(document, commentModel, "This is the updated comment with Manager user"); commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { "rest-api", - "comments" }, executionType = ExecutionType.SANITY, description = "Verify Contributor user updates comments created by admin user and status code is 200") - public void contributorIsAbleToUpdateComment() throws JsonToModelConversionException, Exception + "comments" }, executionType = ExecutionType.SANITY, description = "Verify Contributor user can not update comments created by admin user and status code is 403") + public void contributorIsNotAbleToUpdateComment() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - - CommentContent commentContent = new CommentContent("This is the updated comment with Contributor user"); - - commentsAPI.updateComment(document, commentModel, commentContent); + commentsAPI.updateComment(document, commentModel, "This is the updated comment with Contributor user"); commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } @TestRail(section = { "rest-api", - "comments" }, executionType = ExecutionType.SANITY, description = "Verify Consumer user updates comments created by admin user and status code is 200") - public void consumerIsAbleToUpdateComment() throws JsonToModelConversionException, Exception + "comments" }, executionType = ExecutionType.SANITY, description = "Verify Consumer user can not update comments created by admin user and status code is 403") + public void consumerIsNotAbleToUpdateComment() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - - CommentContent commentContent = new CommentContent("This is the updated comment with Consumer user"); - - commentsAPI.updateComment(document, commentModel, commentContent); + commentsAPI.updateComment(document, commentModel, "This is the updated comment with Consumer user"); commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } @TestRail(section = { "rest-api", - "comments" }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user updates comment created by admin user and status code is 200") + "comments" }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user can not update comment created by admin user and status code is 403") @Bug(id="REPO-1011") - public void collaboratorIsAbleToUpdateComment() throws JsonToModelConversionException, Exception + public void collaboratorIsNotAbleToUpdateComment() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - - CommentContent commentContent = new CommentContent("This is the updated comment with Collaborator user"); - - RestCommentModel commentEntry = commentsAPI.updateComment(document, commentModel, commentContent); + RestCommentModel commentEntry = commentsAPI.updateComment(document, commentModel, "This is the updated comment with Collaborator user"); commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); commentEntry.assertCommentContentIs("This is the updated comment with Collaborator user"); } @@ -127,10 +112,7 @@ public class UpdateCommentsSanityTests extends RestTest FolderModel content = FolderModel.getRandomFolderModel(); content.setNodeRef("node ref that does not exist"); - - CommentContent comment = new CommentContent("This is the updated comment."); - - commentsAPI.updateComment(content, commentModel, comment); + commentsAPI.updateComment(content, commentModel, "This is the updated comment."); commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); } @@ -141,10 +123,7 @@ public class UpdateCommentsSanityTests extends RestTest RestCommentModel comment = new RestCommentModel(); comment.setId("comment id that does not exist"); - - CommentContent commentContent = new CommentContent("This is the updated comment."); - - commentsAPI.updateComment(document, comment, commentContent); + commentsAPI.updateComment(document, comment, "This is the updated comment."); commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); } diff --git a/e2e-test/java/org/alfresco/rest/demo/RestDemoTests.java b/e2e-test/java/org/alfresco/rest/demo/RestDemoTests.java index d9bc66df4..371746561 100644 --- a/e2e-test/java/org/alfresco/rest/demo/RestDemoTests.java +++ b/e2e-test/java/org/alfresco/rest/demo/RestDemoTests.java @@ -2,7 +2,6 @@ package org.alfresco.rest.demo; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; -import org.alfresco.rest.body.CommentContent; import org.alfresco.rest.body.SiteMember; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestCommentModel; @@ -83,8 +82,7 @@ public class RestDemoTests extends RestTest .assertCommentWithIdExists(commentEntry); // update comment - CommentContent commentContent = new CommentContent("This is the updated comment with Collaborator user"); - commentEntry = commentsAPI.updateComment(fileModel, commentEntry, commentContent); + commentEntry = commentsAPI.updateComment(fileModel, commentEntry, "This is the updated comment with Collaborator user"); commentsAPI.getNodeComments(fileModel) .assertResponseIsNotEmpty() diff --git a/e2e-test/java/org/alfresco/rest/demo/SampleCommentsTests.java b/e2e-test/java/org/alfresco/rest/demo/SampleCommentsTests.java index 6bb8fe67e..876820d43 100644 --- a/e2e-test/java/org/alfresco/rest/demo/SampleCommentsTests.java +++ b/e2e-test/java/org/alfresco/rest/demo/SampleCommentsTests.java @@ -2,7 +2,6 @@ package org.alfresco.rest.demo; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; -import org.alfresco.rest.body.CommentContent; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestCommentModel; import org.alfresco.rest.requests.RestCommentsApi; @@ -64,8 +63,7 @@ public class SampleCommentsTests extends RestTest { RestCommentModel commentModel = commentsAPI.addComment(document, "This is a new comment"); - CommentContent commentContent = new CommentContent("This is the updated comment with Collaborator user"); - RestCommentModel commentEntry = commentsAPI.updateComment(document, commentModel, commentContent); + RestCommentModel commentEntry = commentsAPI.updateComment(document, commentModel, "This is the updated comment with Collaborator user"); commentEntry.assertCommentContentIs("This is the updated comment"); } From a36e08dafff87d6bae3813659792ea773c614826 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Tue, 11 Oct 2016 17:05:27 +0300 Subject: [PATCH 0383/1491] TAS-1376 getTasks call for admin --- .../org/alfresco/rest/RestWorkflowTest.java | 18 +++++++++ .../workflow/tasks/GetTasksSanityTests.java | 40 +++++++++++++++++++ e2e-test/resources/default.properties | 1 + 3 files changed, 59 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/RestWorkflowTest.java create mode 100644 e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/RestWorkflowTest.java b/e2e-test/java/org/alfresco/rest/RestWorkflowTest.java new file mode 100644 index 000000000..641e7cf47 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/RestWorkflowTest.java @@ -0,0 +1,18 @@ +package org.alfresco.rest; + +import org.testng.annotations.BeforeClass; + +import com.jayway.restassured.RestAssured; + +public abstract class RestWorkflowTest extends RestTest +{ + @BeforeClass(alwaysRun = true) + public void checkServerHealth() throws Exception + { + serverHealth.assertServerIsOnline(); + + RestAssured.baseURI = restProperties.envProperty().getTestServerUrl(); + RestAssured.port = restProperties.envProperty().getPort(); + RestAssured.basePath = restProperties.getRestWorkflowPath(); + } +} diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksSanityTests.java new file mode 100644 index 000000000..fa33b2d4f --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksSanityTests.java @@ -0,0 +1,40 @@ +package org.alfresco.rest.workflow.tasks; + +import org.alfresco.rest.RestWorkflowTest; +import org.alfresco.rest.requests.RestTasksApi; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +@Test(groups = { "rest-api", "workflow", "tasks", "sanity" }) +public class GetTasksSanityTests extends RestWorkflowTest +{ + @Autowired + RestTasksApi tasksApi; + + UserModel userModel; + SiteModel siteModel; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + + tasksApi.useRestClient(restClient); + } + + @TestRail(section = { "rest-api", "workflow", "tasks" }, executionType = ExecutionType.SANITY, description = "Verify manager user fails to get an user favorite sites with Rest API (403)") + public void managerUserFailsToGetAnUserFavoriteSites() throws Exception + { + UserModel adminUser=dataUser.getAdminUser(); + restClient.authenticateUser(adminUser); + tasksApi.getTasks().assertEntriesListIsNotEmpty(); + tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } +} diff --git a/e2e-test/resources/default.properties b/e2e-test/resources/default.properties index cc323e95e..0dcbd8fd4 100644 --- a/e2e-test/resources/default.properties +++ b/e2e-test/resources/default.properties @@ -9,6 +9,7 @@ admin.password=admin # rest related rest.basePath=alfresco/api/-default-/public/alfresco/versions/1 +rest.workflowPath=alfresco/api/-default-/public/workflow/versions/1 # TEST MANAGEMENT SECTION - Test Rail From 3b048dece46e95097c2c1c227fadaa91c53397ba Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Wed, 12 Oct 2016 09:22:30 +0300 Subject: [PATCH 0384/1491] TAS-1383 Remove from body package: SiteMember & SiteMemberShipRequest classes and update tests to use JsobBodyGenerator instead. --- .../org/alfresco/rest/demo/RestDemoTests.java | 25 ++++++------ .../alfresco/rest/demo/SampleSitesTests.java | 10 ++--- .../AddSiteMembershipRequestSanityTests.java | 32 +++++----------- .../people/DeleteSiteMemberSanityTests.java | 34 ++++++++--------- ...eleteSiteMembershipRequestSanityTests.java | 19 ++++------ .../GetSiteMembershipRequestSanityTests.java | 25 +++--------- .../GetSiteMembershipRequestsSanityTests.java | 5 +-- ...pdateSiteMembershipRequestSanityTests.java | 38 ++++++++----------- .../rest/sites/AddSiteMemberSanityTests.java | 38 +++++++++---------- .../sites/UpdateSiteMemberSanityTests.java | 31 +++++++-------- 10 files changed, 102 insertions(+), 155 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/demo/RestDemoTests.java b/e2e-test/java/org/alfresco/rest/demo/RestDemoTests.java index d9bc66df4..fa6e5c073 100644 --- a/e2e-test/java/org/alfresco/rest/demo/RestDemoTests.java +++ b/e2e-test/java/org/alfresco/rest/demo/RestDemoTests.java @@ -3,11 +3,11 @@ package org.alfresco.rest.demo; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.body.CommentContent; -import org.alfresco.rest.body.SiteMember; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestCommentModel; import org.alfresco.rest.requests.RestCommentsApi; import org.alfresco.rest.requests.RestSitesApi; +import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FolderModel; @@ -104,26 +104,25 @@ public class RestDemoTests extends RestTest @Test public void adminCanAddAndUpdateSiteMemberDetails() throws Exception { - UserModel newUser = dataUser.createRandomTestUser(); - SiteMember siteMember = new SiteMember(Role.SiteConsumer.toString(), - newUser.getUsername()); + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteConsumer); // add user as Consumer to site - sitesApi.addPerson(siteModel, siteMember); + sitesApi.addPerson(siteModel, testUser); sitesApi.getSiteMembers(siteModel) - .assertThatSiteHasMember(siteMember.getId()) - .getSiteMember(siteMember.getId()) + .assertThatSiteHasMember(testUser.getUsername()) + .getSiteMember(testUser.getUsername()) .assertSiteMemberHasRole(Role.SiteConsumer); // update site member to Manager - siteMember.setRole(Role.SiteManager.toString()); - sitesApi.updateSiteMember(siteModel, newUser, siteMember); + testUser.setUserRole(UserRole.SiteCollaborator); + sitesApi.updateSiteMember(siteModel, testUser); sitesApi.getSiteMembers(siteModel) - .assertThatSiteHasMember(siteMember.getId()) - .getSiteMember(siteMember.getId()) - .assertSiteMemberHasRole(Role.SiteManager); + .assertThatSiteHasMember(testUser.getUsername()) + .getSiteMember(testUser.getUsername()) + .assertSiteMemberHasRole(Role.SiteCollaborator); - sitesApi.deleteSiteMember(siteModel, newUser); + sitesApi.deleteSiteMember(siteModel, testUser); sitesApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.NO_CONTENT); } diff --git a/e2e-test/java/org/alfresco/rest/demo/SampleSitesTests.java b/e2e-test/java/org/alfresco/rest/demo/SampleSitesTests.java index e0210679a..cc8774666 100644 --- a/e2e-test/java/org/alfresco/rest/demo/SampleSitesTests.java +++ b/e2e-test/java/org/alfresco/rest/demo/SampleSitesTests.java @@ -1,9 +1,9 @@ package org.alfresco.rest.demo; import org.alfresco.rest.RestTest; -import org.alfresco.rest.body.SiteMember; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.requests.RestSitesApi; +import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; @@ -11,7 +11,6 @@ import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; -import org.springframework.social.alfresco.api.entities.Role; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -79,10 +78,9 @@ public class SampleSitesTests extends RestTest description = "Verify admin user adds site member with Rest API and status code is 201") public void adminShouldAddNewSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception { - UserModel newMember = dataUser.createRandomTestUser(); - SiteMember siteMember = new SiteMember(Role.SiteCollaborator.toString(), newMember.getUsername()); - - siteAPI.addPerson(siteModel, siteMember); + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteConsumer); + siteAPI.addPerson(siteModel, testUser); siteAPI.usingRestWrapper() .assertStatusCodeIs(HttpStatus.CREATED); } diff --git a/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java index eb63f95c8..3011d99c2 100644 --- a/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java @@ -1,7 +1,6 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; -import org.alfresco.rest.body.SiteMembershipRequest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.requests.RestPeopleApi; import org.alfresco.utility.constants.UserRole; @@ -53,10 +52,8 @@ public class AddSiteMembershipRequestSanityTests extends RestTest public void siteManagerIsAbleToCreateSiteMembershipRequest() throws JsonToModelConversionException, Exception { UserModel newMember = dataUser.createRandomTestUser(); - SiteMembershipRequest siteMembership = new SiteMembershipRequest("Please accept me", siteModel.getId(), "New request"); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - peopleApi.addSiteMembershipRequest(newMember, siteMembership); + peopleApi.addSiteMembershipRequest(newMember, siteModel); peopleApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.CREATED); } @@ -67,10 +64,8 @@ public class AddSiteMembershipRequestSanityTests extends RestTest public void siteCollaboatorIsAbleToCreateSiteMembershipRequest() throws JsonToModelConversionException, Exception { UserModel newMember = dataUser.createRandomTestUser(); - SiteMembershipRequest siteMembership = new SiteMembershipRequest("Please accept me", siteModel.getId(), "New request"); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - peopleApi.addSiteMembershipRequest(newMember, siteMembership); + peopleApi.addSiteMembershipRequest(newMember, siteModel); peopleApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.CREATED); } @@ -81,10 +76,8 @@ public class AddSiteMembershipRequestSanityTests extends RestTest public void siteContributorIsAbleToCreateSiteMembershipRequest() throws JsonToModelConversionException, Exception { UserModel newMember = dataUser.createRandomTestUser(); - SiteMembershipRequest siteMembership = new SiteMembershipRequest("Please accept me", siteModel.getId(), "New request"); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - peopleApi.addSiteMembershipRequest(newMember, siteMembership); + peopleApi.addSiteMembershipRequest(newMember, siteModel); peopleApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.CREATED); } @@ -95,26 +88,21 @@ public class AddSiteMembershipRequestSanityTests extends RestTest public void siteConsumerIsAbleToCreateSiteMembershipRequest() throws JsonToModelConversionException, Exception { UserModel newMember = dataUser.createRandomTestUser(); - SiteMembershipRequest siteMembership = new SiteMembershipRequest("Please accept me", siteModel.getId(), "New request"); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - peopleApi.addSiteMembershipRequest(newMember, siteMembership); + peopleApi.addSiteMembershipRequest(newMember, siteModel); peopleApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.CREATED); } - @TestRail(section = { "rest-api", "people" }, - executionType = ExecutionType.SANITY, description = "Verify admin user is able to create new site membership request") + @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, + description = "Verify admin user is able to create new site membership request") @Bug(id = "MNT-16557") public void adminUserIsAbleToCreateSiteMembershipRequest() throws JsonToModelConversionException, Exception { UserModel newMember = dataUser.createRandomTestUser(); - SiteMembershipRequest siteMembership = new SiteMembershipRequest("Please accept me", siteModel.getId(), "New request"); - restClient.authenticateUser(adminUser); - peopleApi.addSiteMembershipRequest(newMember, siteMembership); - peopleApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.CREATED); + peopleApi.addSiteMembershipRequest(newMember, siteModel); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } @TestRail(section = { "rest-api", "people" }, @@ -123,10 +111,8 @@ public class AddSiteMembershipRequestSanityTests extends RestTest public void unauthenticatedUserIsNotAbleToCreateSiteMembershipRequest() throws JsonToModelConversionException, Exception { UserModel newMember = dataUser.createRandomTestUser(); - SiteMembershipRequest siteMembership = new SiteMembershipRequest("Please accept me", siteModel.getId(), "New request"); - restClient.authenticateUser(new UserModel("random user", "random password")); - peopleApi.addSiteMembershipRequest(newMember, siteMembership); + peopleApi.addSiteMembershipRequest(newMember, siteModel); peopleApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java index 7d5a135ec..1da61496b 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java @@ -1,7 +1,6 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; -import org.alfresco.rest.body.SiteMember; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.requests.RestPeopleApi; import org.alfresco.rest.requests.RestSitesApi; @@ -17,7 +16,6 @@ import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; -import org.springframework.social.alfresco.api.entities.Role; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -38,8 +36,6 @@ public class DeleteSiteMemberSanityTests extends RestTest private SiteModel siteModel; private UserModel adminUser; - private UserModel newUser; - private SiteMember siteMember; private ListUserWithRoles usersWithRoles; @BeforeClass(alwaysRun=true) @@ -60,10 +56,10 @@ public class DeleteSiteMemberSanityTests extends RestTest description = "Verify site manager is able to delete another member of the site") public void siteManagerCanDeleteSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception { - newUser = dataUser.createRandomTestUser(); - siteMember = new SiteMember(Role.SiteCollaborator.toString(), newUser.getUsername()); + UserModel newUser = dataUser.createRandomTestUser("testUser"); + newUser.setUserRole(UserRole.SiteCollaborator); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - sitesApi.addPerson(siteModel, siteMember); + sitesApi.addPerson(siteModel, newUser); peopleApi.deleteSiteMember(newUser, siteModel); sitesApi.usingRestWrapper() @@ -75,10 +71,10 @@ public class DeleteSiteMemberSanityTests extends RestTest description = "Verify admin user is able to delete another member of the site") public void adminIsAbleToDeleteSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception { - newUser = dataUser.createRandomTestUser(); - siteMember = new SiteMember(Role.SiteCollaborator.toString(), newUser.getUsername()); + UserModel newUser = dataUser.createRandomTestUser("testUser"); + newUser.setUserRole(UserRole.SiteCollaborator); restClient.authenticateUser(adminUser); - sitesApi.addPerson(siteModel, siteMember); + sitesApi.addPerson(siteModel, newUser); peopleApi.deleteSiteMember(newUser, siteModel); sitesApi.usingRestWrapper() @@ -91,10 +87,10 @@ public class DeleteSiteMemberSanityTests extends RestTest @Bug(id="ACE-5444") public void siteCollaboratorIsNotAbleToDeleteSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception { - newUser = dataUser.createRandomTestUser(); - siteMember = new SiteMember(Role.SiteContributor.toString(), newUser.getUsername()); + UserModel newUser = dataUser.createRandomTestUser("testUser"); + newUser.setUserRole(UserRole.SiteCollaborator); restClient.authenticateUser(adminUser); - sitesApi.addPerson(siteModel, siteMember); + sitesApi.addPerson(siteModel, newUser); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); peopleApi.deleteSiteMember(newUser, siteModel); @@ -107,10 +103,10 @@ public class DeleteSiteMemberSanityTests extends RestTest @Bug(id="ACE-5444") public void siteContributorIsNotAbleToDeleteSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception { - newUser = dataUser.createRandomTestUser(); - siteMember = new SiteMember(Role.SiteCollaborator.toString(), newUser.getUsername()); + UserModel newUser = dataUser.createRandomTestUser("testUser"); + newUser.setUserRole(UserRole.SiteCollaborator); restClient.authenticateUser(adminUser); - sitesApi.addPerson(siteModel, siteMember); + sitesApi.addPerson(siteModel, newUser); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); peopleApi.deleteSiteMember(newUser, siteModel); @@ -123,10 +119,10 @@ public class DeleteSiteMemberSanityTests extends RestTest @Bug(id="ACE-5444") public void siteConsumerIsNotAbleToDeleteSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception { - newUser = dataUser.createRandomTestUser(); - siteMember = new SiteMember(Role.SiteCollaborator.toString(), newUser.getUsername()); + UserModel newUser = dataUser.createRandomTestUser("testUser"); + newUser.setUserRole(UserRole.SiteCollaborator); restClient.authenticateUser(adminUser); - sitesApi.addPerson(siteModel, siteMember); + sitesApi.addPerson(siteModel, newUser); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); peopleApi.deleteSiteMember(newUser, siteModel); diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java index 3a24e5084..2c3d2a991 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java @@ -1,7 +1,6 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; -import org.alfresco.rest.body.SiteMembershipRequest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.requests.RestPeopleApi; import org.alfresco.utility.constants.UserRole; @@ -31,7 +30,6 @@ public class DeleteSiteMembershipRequestSanityTests extends RestTest UserModel userModel; UserModel siteMember; SiteModel siteModel; - SiteMembershipRequest siteMembershipRequest; private ListUserWithRoles usersWithRoles; @BeforeClass(alwaysRun=true) @@ -40,7 +38,6 @@ public class DeleteSiteMembershipRequestSanityTests extends RestTest siteModel = dataSite.usingUser(userModel).createSite(new SiteModel(Visibility.MODERATED, siteId, siteId, siteId, siteId)); usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); - siteMembershipRequest = new SiteMembershipRequest("Please accept me", siteModel.getId(), "New request"); peopleApi.useRestClient(restClient); } @@ -51,7 +48,7 @@ public class DeleteSiteMembershipRequestSanityTests extends RestTest { siteMember = dataUser.createRandomTestUser(); restClient.authenticateUser(siteMember); - peopleApi.addSiteMembershipRequest(siteMember, siteMembershipRequest); + peopleApi.addSiteMembershipRequest(siteMember, siteModel); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); peopleApi.deleteSiteMembershipRequest(siteMember, siteModel); @@ -65,7 +62,7 @@ public class DeleteSiteMembershipRequestSanityTests extends RestTest { siteMember = dataUser.createRandomTestUser(); restClient.authenticateUser(siteMember); - peopleApi.addSiteMembershipRequest(siteMember, siteMembershipRequest); + peopleApi.addSiteMembershipRequest(siteMember, siteModel); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); peopleApi.deleteSiteMembershipRequest(usersWithRoles.getOneUserWithRole(UserRole.SiteManager), siteModel); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); @@ -78,7 +75,7 @@ public class DeleteSiteMembershipRequestSanityTests extends RestTest { siteMember = dataUser.createRandomTestUser(); restClient.authenticateUser(siteMember); - peopleApi.addSiteMembershipRequest(siteMember, siteMembershipRequest); + peopleApi.addSiteMembershipRequest(siteMember, siteModel); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); UserModel adminUser = dataUser.getAdminUser(); restClient.authenticateUser(adminUser); @@ -93,7 +90,7 @@ public class DeleteSiteMembershipRequestSanityTests extends RestTest { siteMember = dataUser.createRandomTestUser(); restClient.authenticateUser(siteMember); - peopleApi.addSiteMembershipRequest(siteMember, siteMembershipRequest); + peopleApi.addSiteMembershipRequest(siteMember, siteModel); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); peopleApi.deleteSiteMembershipRequest(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), siteModel); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); @@ -106,7 +103,7 @@ public class DeleteSiteMembershipRequestSanityTests extends RestTest { siteMember = dataUser.createRandomTestUser(); restClient.authenticateUser(siteMember); - peopleApi.addSiteMembershipRequest(siteMember, siteMembershipRequest); + peopleApi.addSiteMembershipRequest(siteMember, siteModel); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); peopleApi.deleteSiteMembershipRequest(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor), siteModel); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); @@ -119,7 +116,7 @@ public class DeleteSiteMembershipRequestSanityTests extends RestTest { siteMember = dataUser.createRandomTestUser(); restClient.authenticateUser(siteMember); - peopleApi.addSiteMembershipRequest(siteMember, siteMembershipRequest); + peopleApi.addSiteMembershipRequest(siteMember, siteModel); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); peopleApi.deleteSiteMembershipRequest(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer), siteModel); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); @@ -132,7 +129,7 @@ public class DeleteSiteMembershipRequestSanityTests extends RestTest { siteMember = dataUser.createRandomTestUser(); restClient.authenticateUser(siteMember); - peopleApi.addSiteMembershipRequest(siteMember, siteMembershipRequest); + peopleApi.addSiteMembershipRequest(siteMember, siteModel); UserModel randomUser = dataUser.createRandomTestUser(); restClient.authenticateUser(randomUser); peopleApi.deleteSiteMembershipRequest(randomUser, siteModel); @@ -145,7 +142,7 @@ public class DeleteSiteMembershipRequestSanityTests extends RestTest { siteMember = dataUser.createRandomTestUser(); restClient.authenticateUser(siteMember); - peopleApi.addSiteMembershipRequest(siteMember, siteMembershipRequest); + peopleApi.addSiteMembershipRequest(siteMember, siteModel); UserModel inexistentUser = new UserModel("inexistent user", "inexistent password"); restClient.authenticateUser(inexistentUser); peopleApi.deleteSiteMembershipRequest(inexistentUser, siteModel); diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestSanityTests.java index badc5e1be..3342c087a 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestSanityTests.java @@ -1,7 +1,6 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; -import org.alfresco.rest.body.SiteMembershipRequest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.requests.RestPeopleApi; import org.alfresco.utility.constants.UserRole; @@ -53,10 +52,8 @@ public class GetSiteMembershipRequestSanityTests extends RestTest public void siteManagerIsAbleToRetrieveSiteMembershipRequest() throws JsonToModelConversionException, Exception { UserModel newMember = dataUser.createRandomTestUser(); - SiteMembershipRequest siteMembership = new SiteMembershipRequest("Please accept me", siteModel.getId(), "New request"); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - peopleApi.addSiteMembershipRequest(newMember, siteMembership); + peopleApi.addSiteMembershipRequest(newMember, siteModel); peopleApi.getSiteMembershipRequest(newMember, siteModel); peopleApi.usingRestWrapper() @@ -69,10 +66,8 @@ public class GetSiteMembershipRequestSanityTests extends RestTest public void siteCollaboratorIsAbleToRetrieveSiteMembershipRequest() throws JsonToModelConversionException, Exception { UserModel newMember = dataUser.createRandomTestUser(); - SiteMembershipRequest siteMembership = new SiteMembershipRequest("Please accept me", siteModel.getId(), "New request"); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - peopleApi.addSiteMembershipRequest(newMember, siteMembership); + peopleApi.addSiteMembershipRequest(newMember, siteModel); peopleApi.getSiteMembershipRequest(newMember, siteModel); peopleApi.usingRestWrapper() @@ -85,10 +80,8 @@ public class GetSiteMembershipRequestSanityTests extends RestTest public void siteContributorIsAbleToRetrieveSiteMembershipRequest() throws JsonToModelConversionException, Exception { UserModel newMember = dataUser.createRandomTestUser(); - SiteMembershipRequest siteMembership = new SiteMembershipRequest("Please accept me", siteModel.getId(), "New request"); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - peopleApi.addSiteMembershipRequest(newMember, siteMembership); + peopleApi.addSiteMembershipRequest(newMember, siteModel); peopleApi.getSiteMembershipRequest(newMember, siteModel); peopleApi.usingRestWrapper() @@ -101,10 +94,8 @@ public class GetSiteMembershipRequestSanityTests extends RestTest public void siteConsumerIsAbleToRetrieveSiteMembershipRequest() throws JsonToModelConversionException, Exception { UserModel newMember = dataUser.createRandomTestUser(); - SiteMembershipRequest siteMembership = new SiteMembershipRequest("Please accept me", siteModel.getId(), "New request"); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - peopleApi.addSiteMembershipRequest(newMember, siteMembership); + peopleApi.addSiteMembershipRequest(newMember, siteModel); peopleApi.getSiteMembershipRequest(newMember, siteModel); peopleApi.usingRestWrapper() @@ -117,10 +108,8 @@ public class GetSiteMembershipRequestSanityTests extends RestTest public void adminIsAbleToRetrieveSiteMembershipRequest() throws JsonToModelConversionException, Exception { UserModel newMember = dataUser.createRandomTestUser(); - SiteMembershipRequest siteMembership = new SiteMembershipRequest("Please accept me", siteModel.getId(), "New request"); - restClient.authenticateUser(adminUser); - peopleApi.addSiteMembershipRequest(newMember, siteMembership); + peopleApi.addSiteMembershipRequest(newMember, siteModel); peopleApi.getSiteMembershipRequest(newMember, siteModel); peopleApi.usingRestWrapper() @@ -133,10 +122,8 @@ public class GetSiteMembershipRequestSanityTests extends RestTest public void unauthenticatedUserIsNotAbleToRetrieveSiteMembershipRequest() throws JsonToModelConversionException, Exception { UserModel newMember = dataUser.createRandomTestUser(); - SiteMembershipRequest siteMembership = new SiteMembershipRequest("Please accept me", siteModel.getId(), "New request"); - restClient.authenticateUser(new UserModel("random user", "random password")); - peopleApi.addSiteMembershipRequest(newMember, siteMembership); + peopleApi.addSiteMembershipRequest(newMember, siteModel); peopleApi.getSiteMembershipRequest(newMember, siteModel); peopleApi.usingRestWrapper() diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java index 3f77ae31a..a9aa8968a 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java @@ -1,7 +1,6 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; -import org.alfresco.rest.body.SiteMembershipRequest; import org.alfresco.rest.requests.RestPeopleApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.RandomData; @@ -30,7 +29,6 @@ public class GetSiteMembershipRequestsSanityTests extends RestTest UserModel userModel; SiteModel siteModel; UserModel newMember; - SiteMembershipRequest siteMembershipRequest; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception @@ -39,10 +37,9 @@ public class GetSiteMembershipRequestsSanityTests extends RestTest String siteId = RandomData.getRandomName("site"); siteModel = dataSite.usingUser(userModel).createSite(new SiteModel(Visibility.MODERATED, siteId, siteId, siteId, siteId)); newMember = dataUser.createRandomTestUser(); - siteMembershipRequest = new SiteMembershipRequest("Please accept me", siteModel.getId(), "New request"); peopleApi.useRestClient(restClient); restClient.authenticateUser(newMember); - peopleApi.addSiteMembershipRequest(newMember, siteMembershipRequest); + peopleApi.addSiteMembershipRequest(newMember, siteModel); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); peopleApi.useRestClient(restClient); diff --git a/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestSanityTests.java index d25e26644..7e947a007 100644 --- a/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestSanityTests.java @@ -1,7 +1,6 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; -import org.alfresco.rest.body.SiteMembershipRequest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.requests.RestPeopleApi; import org.alfresco.utility.constants.UserRole; @@ -36,12 +35,8 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest private SiteModel siteModel; private ListUserWithRoles usersWithRoles; private UserModel adminUser; - private String initialMessage; private String updatedMessage; - private SiteMembershipRequest initialSiteMembership; - private SiteMembershipRequest updatedSiteMembership; - @BeforeClass(alwaysRun=true) public void dataPreparation() throws DataPreparationException { @@ -53,11 +48,8 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest peopleApi.useRestClient(restClient); - initialMessage = "Please accept me"; updatedMessage = "Please review my request"; - - initialSiteMembership = new SiteMembershipRequest(initialMessage, siteModel.getId(), "New request"); - updatedSiteMembership = new SiteMembershipRequest(updatedMessage, siteModel.getId(), "New request updated"); + } @TestRail(section = { "rest-api", "people" }, @@ -67,9 +59,9 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest UserModel newMember = dataUser.createRandomTestUser(); restClient.authenticateUser(newMember); - peopleApi.addSiteMembershipRequest(newMember, initialSiteMembership); + peopleApi.addSiteMembershipRequest(newMember, siteModel); - peopleApi.updateSiteMembershipRequest(newMember, updatedSiteMembership) + peopleApi.updateSiteMembershipRequest(newMember, siteModel, updatedMessage) .assertMembershipRequestMessageIs(updatedMessage); peopleApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.OK); @@ -83,10 +75,10 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest UserModel newMember = dataUser.createRandomTestUser(); restClient.authenticateUser(newMember); - peopleApi.addSiteMembershipRequest(newMember, initialSiteMembership); + peopleApi.addSiteMembershipRequest(newMember, siteModel); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - peopleApi.updateSiteMembershipRequest(newMember, updatedSiteMembership); + peopleApi.updateSiteMembershipRequest(newMember, siteModel, updatedMessage); peopleApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.FORBIDDEN); @@ -100,10 +92,10 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest UserModel newMember = dataUser.createRandomTestUser(); restClient.authenticateUser(newMember); - peopleApi.addSiteMembershipRequest(newMember, initialSiteMembership); + peopleApi.addSiteMembershipRequest(newMember, siteModel); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - peopleApi.updateSiteMembershipRequest(newMember, updatedSiteMembership); + peopleApi.updateSiteMembershipRequest(newMember, siteModel, updatedMessage); peopleApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.FORBIDDEN); @@ -117,10 +109,10 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest UserModel newMember = dataUser.createRandomTestUser(); restClient.authenticateUser(newMember); - peopleApi.addSiteMembershipRequest(newMember, initialSiteMembership); + peopleApi.addSiteMembershipRequest(newMember, siteModel); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - peopleApi.updateSiteMembershipRequest(newMember, updatedSiteMembership); + peopleApi.updateSiteMembershipRequest(newMember, siteModel, updatedMessage); peopleApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.FORBIDDEN); @@ -134,10 +126,10 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest UserModel newMember = dataUser.createRandomTestUser(); restClient.authenticateUser(newMember); - peopleApi.addSiteMembershipRequest(newMember, initialSiteMembership); + peopleApi.addSiteMembershipRequest(newMember, siteModel); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - peopleApi.updateSiteMembershipRequest(newMember, updatedSiteMembership); + peopleApi.updateSiteMembershipRequest(newMember, siteModel, updatedMessage); peopleApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.FORBIDDEN); @@ -152,10 +144,10 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest UserModel otherMember = dataUser.createRandomTestUser(); restClient.authenticateUser(newMember); - peopleApi.addSiteMembershipRequest(newMember, initialSiteMembership); + peopleApi.addSiteMembershipRequest(newMember, siteModel); restClient.authenticateUser(otherMember); - peopleApi.updateSiteMembershipRequest(newMember, updatedSiteMembership); + peopleApi.updateSiteMembershipRequest(newMember, siteModel, updatedMessage); peopleApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.FORBIDDEN); @@ -169,10 +161,10 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest UserModel newMember = dataUser.createRandomTestUser(); restClient.authenticateUser(newMember); - peopleApi.addSiteMembershipRequest(newMember, initialSiteMembership); + peopleApi.addSiteMembershipRequest(newMember, siteModel); restClient.authenticateUser(adminUser); - peopleApi.updateSiteMembershipRequest(newMember, updatedSiteMembership); + peopleApi.updateSiteMembershipRequest(newMember, siteModel, updatedMessage); peopleApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.FORBIDDEN); diff --git a/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java index 26a8b26cd..7cf0fedf8 100644 --- a/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java @@ -1,7 +1,6 @@ package org.alfresco.rest.sites; import org.alfresco.rest.RestTest; -import org.alfresco.rest.body.SiteMember; import org.alfresco.rest.requests.RestSitesApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; @@ -12,7 +11,6 @@ import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; -import org.springframework.social.alfresco.api.entities.Role; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -41,10 +39,10 @@ public class AddSiteMemberSanityTests extends RestTest description = "Verify that manager is able to add site member and gets status code CREATED (201)") public void managerIsAbleToAddSiteMember() throws Exception { - UserModel newUser = dataUser.createRandomTestUser(); - SiteMember siteMember = new SiteMember(Role.SiteConsumer.toString(), newUser.getUsername()); + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteConsumer); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - siteAPI.addPerson(siteModel, siteMember); + siteAPI.addPerson(siteModel, testUser); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } @@ -52,10 +50,10 @@ public class AddSiteMemberSanityTests extends RestTest description = "Verify that site collaborator is not able to add site member and gets status code FORBIDDEN (403)") public void collaboratorIsNotAbleToAddSiteMember() throws Exception { - UserModel newUser = dataUser.createRandomTestUser(); - SiteMember siteMember = new SiteMember(Role.SiteConsumer.toString(), newUser.getUsername()); + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteConsumer); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - siteAPI.addPerson(siteModel, siteMember); + siteAPI.addPerson(siteModel, testUser); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } @@ -63,10 +61,10 @@ public class AddSiteMemberSanityTests extends RestTest description = "Verify that site contributor is not able to add site member and gets status code FORBIDDEN (403)") public void contributorIsNotAbleToAddSiteMember() throws Exception { - UserModel newUser = dataUser.createRandomTestUser(); - SiteMember siteMember = new SiteMember(Role.SiteConsumer.toString(), newUser.getUsername()); + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteConsumer); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - siteAPI.addPerson(siteModel, siteMember); + siteAPI.addPerson(siteModel, testUser); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } @@ -74,10 +72,10 @@ public class AddSiteMemberSanityTests extends RestTest description = "Verify that site consumer is not able to add site member and gets status code FORBIDDEN (403)") public void consumerIsNotAbleToAddSiteMember() throws Exception { - UserModel newUser = dataUser.createRandomTestUser(); - SiteMember siteMember = new SiteMember(Role.SiteConsumer.toString(), newUser.getUsername()); + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteConsumer); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - siteAPI.addPerson(siteModel, siteMember); + siteAPI.addPerson(siteModel, testUser); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } @@ -85,10 +83,10 @@ public class AddSiteMemberSanityTests extends RestTest description = "Verify that admin user is able to add site member and gets status code CREATED (201)") public void adminIsAbleToAddSiteMember() throws Exception { - UserModel newUser = dataUser.createRandomTestUser(); - SiteMember siteMember = new SiteMember(Role.SiteConsumer.toString(), newUser.getUsername()); + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteConsumer); restClient.authenticateUser(adminUserModel); - siteAPI.addPerson(siteModel, siteMember); + siteAPI.addPerson(siteModel, testUser); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } @@ -96,11 +94,11 @@ public class AddSiteMemberSanityTests extends RestTest @TestRail(section = {"rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify that unauthenticated user is not able to add site member") public void unauthenticatedUserIsNotAuthorizedToAddSiteMmeber() throws Exception{ - UserModel newUser = dataUser.createRandomTestUser(); - SiteMember siteMember = new SiteMember(Role.SiteConsumer.toString(), newUser.getUsername()); + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteConsumer); UserModel inexistentUser = new UserModel("inexistent user", "inexistent password"); restClient.authenticateUser(inexistentUser); - siteAPI.addPerson(siteModel, siteMember); + siteAPI.addPerson(siteModel, testUser); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java index a1ca78492..caccec1ba 100644 --- a/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java @@ -1,7 +1,6 @@ package org.alfresco.rest.sites; import org.alfresco.rest.RestTest; -import org.alfresco.rest.body.SiteMember; import org.alfresco.rest.requests.RestSitesApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; @@ -12,7 +11,6 @@ import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; -import org.springframework.social.alfresco.api.entities.Role; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -37,16 +35,15 @@ public class UpdateSiteMemberSanityTests extends RestTest UserRole.SiteContributor); testUserModel = dataUser.createRandomTestUser(); dataUser.addUserToSite(testUserModel, siteModel, UserRole.SiteConsumer); - } @TestRail(section = {"rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify that manager is able to update site member and gets status code OK (200)") public void managerIsAbleToUpdateSiteMember() throws Exception { - SiteMember siteMember = new SiteMember(Role.SiteCollaborator.toString(), testUserModel.getUsername()); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - siteAPI.updateSiteMember(siteModel, testUserModel, siteMember); + testUserModel.setUserRole(UserRole.SiteConsumer); + siteAPI.updateSiteMember(siteModel, testUserModel); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -55,9 +52,9 @@ public class UpdateSiteMemberSanityTests extends RestTest description = "Verify that collaborator is not able to update site member and gets status code FORBIDDEN (403)") public void collaboratorIsNotAbleToUpdateSiteMember() throws Exception { - SiteMember siteMember = new SiteMember(Role.SiteConsumer.toString(), testUserModel.getUsername()); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - siteAPI.updateSiteMember(siteModel, testUserModel, siteMember); + testUserModel.setUserRole(UserRole.SiteCollaborator); + siteAPI.updateSiteMember(siteModel, testUserModel); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } @@ -66,9 +63,9 @@ public class UpdateSiteMemberSanityTests extends RestTest description = "Verify that contributor is not able to update site member and gets status code FORBIDDEN (403)") public void contributorIsNotAbleToUpdateSiteMember() throws Exception { - SiteMember siteMember = new SiteMember(Role.SiteConsumer.toString(), testUserModel.getUsername()); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - siteAPI.updateSiteMember(siteModel, testUserModel, siteMember); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + testUserModel.setUserRole(UserRole.SiteCollaborator); + siteAPI.updateSiteMember(siteModel, testUserModel); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } @@ -77,9 +74,9 @@ public class UpdateSiteMemberSanityTests extends RestTest description = "Verify that consumer is not able to update site member and gets status code FORBIDDEN (403)") public void consumerIsNotAbleToUpdateSiteMember() throws Exception { - SiteMember siteMember = new SiteMember(Role.SiteConsumer.toString(), testUserModel.getUsername()); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - siteAPI.updateSiteMember(siteModel, testUserModel, siteMember); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + testUserModel.setUserRole(UserRole.SiteCollaborator); + siteAPI.updateSiteMember(siteModel, testUserModel); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } @@ -87,9 +84,9 @@ public class UpdateSiteMemberSanityTests extends RestTest description = "Verify that admin is able to update site member and gets status code OK (200)") public void adminIsAbleToUpdateSiteMember() throws Exception { - SiteMember siteMember = new SiteMember(Role.SiteConsumer.toString(), testUserModel.getUsername()); restClient.authenticateUser(adminUserModel); - siteAPI.updateSiteMember(siteModel, testUserModel, siteMember); + testUserModel.setUserRole(UserRole.SiteCollaborator); + siteAPI.updateSiteMember(siteModel, testUserModel); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -97,10 +94,10 @@ public class UpdateSiteMemberSanityTests extends RestTest @TestRail(section = {"rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify that unauthenticated user is not able to update site member") public void unauthenticatedUserIsNotAuthorizedToUpdateSiteMmeber() throws Exception{ - SiteMember siteMember = new SiteMember(Role.SiteConsumer.toString(), testUserModel.getUsername()); UserModel inexistentUser = new UserModel("inexistent user", "inexistent password"); restClient.authenticateUser(inexistentUser); - siteAPI.updateSiteMember(siteModel, testUserModel, siteMember); + testUserModel.setUserRole(UserRole.SiteCollaborator); + siteAPI.updateSiteMember(siteModel, testUserModel); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } From 8384d3923e42068baf38a7d1498319bdd02ffdfa Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Wed, 12 Oct 2016 11:14:38 +0300 Subject: [PATCH 0385/1491] TAS-1374 getTasks call for asignee --- .../org/alfresco/rest/RestWorkflowTest.java | 5 +++++ .../workflow/tasks/GetTasksSanityTests.java | 22 ++++++++++++++++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/RestWorkflowTest.java b/e2e-test/java/org/alfresco/rest/RestWorkflowTest.java index 641e7cf47..2409a2fc3 100644 --- a/e2e-test/java/org/alfresco/rest/RestWorkflowTest.java +++ b/e2e-test/java/org/alfresco/rest/RestWorkflowTest.java @@ -1,11 +1,16 @@ package org.alfresco.rest; +import org.alfresco.utility.data.DataWorkflow; +import org.springframework.beans.factory.annotation.Autowired; import org.testng.annotations.BeforeClass; import com.jayway.restassured.RestAssured; public abstract class RestWorkflowTest extends RestTest { + @Autowired + protected DataWorkflow dataWorkflow; + @BeforeClass(alwaysRun = true) public void checkServerHealth() throws Exception { diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksSanityTests.java index fa33b2d4f..f39420bf2 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksSanityTests.java @@ -1,7 +1,9 @@ package org.alfresco.rest.workflow.tasks; +import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestWorkflowTest; import org.alfresco.rest.requests.RestTasksApi; +import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; @@ -19,22 +21,36 @@ public class GetTasksSanityTests extends RestWorkflowTest UserModel userModel; SiteModel siteModel; + UserModel candidateUser; + FileModel fileModel; + UserModel assigneeUser; @BeforeClass(alwaysRun=true) public void dataPreparation() throws Exception { userModel = dataUser.createRandomTestUser(); siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + assigneeUser = dataUser.createRandomTestUser(); + dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); tasksApi.useRestClient(restClient); } - @TestRail(section = { "rest-api", "workflow", "tasks" }, executionType = ExecutionType.SANITY, description = "Verify manager user fails to get an user favorite sites with Rest API (403)") - public void managerUserFailsToGetAnUserFavoriteSites() throws Exception + @TestRail(section = { "rest-api", "workflow", "tasks" }, executionType = ExecutionType.SANITY, description = "Verify admin user gets all existing tasks with Rest API and response is successfull (200)") + public void adminUserGetsAllTasks() throws Exception { - UserModel adminUser=dataUser.getAdminUser(); + UserModel adminUser = dataUser.getAdminUser(); restClient.authenticateUser(adminUser); tasksApi.getTasks().assertEntriesListIsNotEmpty(); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + @TestRail(section = { "rest-api", "workflow", "tasks" }, executionType = ExecutionType.SANITY, description = "Verify admin user gets all existing tasks with Rest API and response is successfull (200)") + public void asigneeUserGetsItsTasks() throws Exception + { + restClient.authenticateUser(assigneeUser); + tasksApi.getTasks().assertEntriesListIsNotEmpty(); + tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } } From 18fe8f1b92d697e0614405aadb5feb977574aa11 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Wed, 12 Oct 2016 11:16:58 +0300 Subject: [PATCH 0386/1491] TAS-1375 getTasks call for candidate --- .../rest/workflow/tasks/GetTasksSanityTests.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksSanityTests.java index f39420bf2..7ad86a5df 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksSanityTests.java @@ -46,11 +46,19 @@ public class GetTasksSanityTests extends RestWorkflowTest tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "workflow", "tasks" }, executionType = ExecutionType.SANITY, description = "Verify admin user gets all existing tasks with Rest API and response is successfull (200)") + @TestRail(section = { "rest-api", "workflow", "tasks" }, executionType = ExecutionType.SANITY, description = "Verify asignee user gets its existing tasks with Rest API and response is successfull (200)") public void asigneeUserGetsItsTasks() throws Exception { restClient.authenticateUser(assigneeUser); tasksApi.getTasks().assertEntriesListIsNotEmpty(); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + @TestRail(section = { "rest-api", "workflow", "tasks" }, executionType = ExecutionType.SANITY, description = "Verify candidate user gets its existing tasks with Rest API and response is successfull (200)") + public void candidateUserGetsItsTasks() throws Exception + { + restClient.authenticateUser(assigneeUser); + tasksApi.getTasks().assertEntriesListIsNotEmpty(); + tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } } From aad421f2233b1ab95d5ad97594f9c8dc2a114f1f Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 12 Oct 2016 14:51:34 +0300 Subject: [PATCH 0387/1491] TAS-1398 - get processes by user who started a process --- .../processes/GetProcessesSanityTests.java | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java new file mode 100644 index 000000000..07c5ff7ed --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java @@ -0,0 +1,57 @@ +package org.alfresco.rest.workflow.processes; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestWorkflowTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.requests.RestProcessesApi; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TaskModel; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Created by Claudia Agache on 10/11/2016. + */ +@Test(groups = { "rest-api", "processes", "sanity" }) +public class GetProcessesSanityTests extends RestWorkflowTest +{ + @Autowired + private DataUser dataUser; + + @Autowired + private RestProcessesApi processesApi; + + private FileModel document; + private SiteModel siteModel; + private UserModel userWhoStartsTask, assignee, anotherUser; + private TaskModel task; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + userWhoStartsTask = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + anotherUser = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + task = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); + processesApi.useRestClient(restClient); + } + + @TestRail(section = { "rest-api", + "processes" }, executionType = ExecutionType.SANITY, description = "Verify User gets all processes started by him using REST API and status code is OK (200)") + public void getProcessesByUserWhoStartedProcess() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(userWhoStartsTask); + processesApi.getProcesses().assertProcessExists(task.getNodeRef()); + processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } + +} From 08627a68afe737ce620825ddf991d2c8bfa7b0e3 Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 12 Oct 2016 14:52:33 +0300 Subject: [PATCH 0388/1491] TAS-1399 - get processes by user who is assigned to a process --- .../rest/workflow/processes/GetProcessesSanityTests.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java index 07c5ff7ed..39fd15c59 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java @@ -54,4 +54,13 @@ public class GetProcessesSanityTests extends RestWorkflowTest processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + @TestRail(section = { "rest-api", + "processes" }, executionType = ExecutionType.SANITY, description = "Verify User gets all processes assigned to him using REST API and status code is OK (200)") + public void getProcessesByAssignedUser() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(assignee); + processesApi.getProcesses().assertProcessExists(task.getNodeRef()); + processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } + } From d8e9082034fac186f0fbb56123bf0ff2355eda5d Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 12 Oct 2016 14:53:34 +0300 Subject: [PATCH 0389/1491] TAS-1400 - get processes by user who is not involved in a process --- .../rest/workflow/processes/GetProcessesSanityTests.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java index 39fd15c59..7b15f5a28 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java @@ -63,4 +63,13 @@ public class GetProcessesSanityTests extends RestWorkflowTest processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + @TestRail(section = { "rest-api", + "processes" }, executionType = ExecutionType.SANITY, description = "Verify User that is not involved in a process can not get that process using REST API and status code is OK (200)") + public void getProcessesByAnotherUser() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(anotherUser); + processesApi.getProcesses().assertProcessDoesNotExist(task.getNodeRef()); + processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } + } From 2013e76f38633b8f4c5d4a89ad4d4801e723b4b2 Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 12 Oct 2016 14:54:35 +0300 Subject: [PATCH 0390/1491] TAS-1401 - get processes by admin --- .../rest/workflow/processes/GetProcessesSanityTests.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java index 7b15f5a28..9ee7ca759 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java @@ -72,4 +72,12 @@ public class GetProcessesSanityTests extends RestWorkflowTest processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + @TestRail(section = { "rest-api", + "processes" }, executionType = ExecutionType.SANITY, description = "Verify Admin gets all processes, even if he isn't involved in a process, using REST API and status code is OK (200)") + public void getProcessesByAdmin() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(dataUser.getAdminUser()); + processesApi.getProcesses().assertProcessExists(task.getNodeRef()); + processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } } From 2e09477a619e6177734b4e97842acca53c87ccfa Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 12 Oct 2016 15:07:02 +0300 Subject: [PATCH 0391/1491] TAS-1416 - get deployments by non-network admin --- .../GetDeploymentsSanityTests.java | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsSanityTests.java new file mode 100644 index 000000000..63325420e --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsSanityTests.java @@ -0,0 +1,50 @@ +package org.alfresco.rest.workflow.deployments; + +import org.alfresco.rest.RestWorkflowTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.requests.RestDeploymentsApi; +import org.alfresco.rest.requests.RestTenantApi; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Created by Claudia Agache on 10/4/2016. + */ +@Test(groups = { "rest-api", "deployments", "sanity" }) +public class GetDeploymentsSanityTests extends RestWorkflowTest +{ + @Autowired + RestTenantApi tenantApi; + @Autowired + private DataUser dataUser; + @Autowired + private RestDeploymentsApi deploymentsApi; + + private UserModel adminUserModel, adminTenantUser; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUserModel); + deploymentsApi.useRestClient(restClient); + } + + // works on docker + @TestRail(section = { "rest-api", + "deployments" }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets non-network deployments using REST API and status code is OK (200)") + public void getNonNetworkDeploymentsWithAdmin() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel); + deploymentsApi.getDeployments().assertResponseIsNotEmpty(); + deploymentsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } + +} From 667ba7442bd210d74bf8302a96b481566a299039 Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 12 Oct 2016 15:08:41 +0300 Subject: [PATCH 0392/1491] TAS-1417 - get deployments by tenant admin --- .../deployments/GetDeploymentsSanityTests.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsSanityTests.java index 63325420e..dfc293bc7 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsSanityTests.java @@ -47,4 +47,17 @@ public class GetDeploymentsSanityTests extends RestWorkflowTest deploymentsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + // works on alfresco.server=172.29.100.215 + @TestRail(section = { "rest-api", + "deployments" }, executionType = ExecutionType.SANITY, description = "Verify Tenant Admin user gets network deployments using REST API and status code is OK (200)") + + @Test(groups = { "networks" }) + public void getNetworkDeploymentsWithAdmin() throws JsonToModelConversionException, Exception + { + tenantApi.useRestClient(restClient); + tenantApi.createTenant(adminTenantUser); + restClient.authenticateUser(adminTenantUser); + deploymentsApi.getDeployments().assertResponseIsNotEmpty(); + deploymentsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } } From 7bf85e9f7af57a38077c5ace18c3bcb87da84d10 Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 12 Oct 2016 16:09:57 +0300 Subject: [PATCH 0393/1491] TAS-1425 - delete process by user who started a process --- .../processes/DeleteProcessSanityTests.java | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java new file mode 100644 index 000000000..6a3c48529 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java @@ -0,0 +1,63 @@ +package org.alfresco.rest.workflow.processes; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestWorkflowTest; +import org.alfresco.rest.requests.RestProcessesApi; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TaskModel; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +/** + * Created by Claudia Agache on 10/12/2016. + */ +@Test(groups = { "rest-api", "processes", "sanity" }) +public class DeleteProcessSanityTests extends RestWorkflowTest +{ + @Autowired + private DataUser dataUser; + + @Autowired + private RestProcessesApi processesApi; + + private FileModel document; + private SiteModel siteModel; + private UserModel userWhoStartsTask, assignee, anotherUser; + private TaskModel task; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + userWhoStartsTask = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + anotherUser = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + processesApi.useRestClient(restClient); + } + + @BeforeMethod(alwaysRun = true) + public void createTask() throws Exception + { + task = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); + } + + @TestRail(section = { "rest-api", + "processes" }, executionType = ExecutionType.SANITY, description = "Verify User is able to delete process started by him using REST API and status code is OK (204)") + public void deleteProcessByUserWhoStartedProcess() throws Exception + { + restClient.authenticateUser(userWhoStartsTask); + processesApi.deleteProcess(task); + processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); + processesApi.getProcesses().assertProcessDoesNotExist(task); + } + +} From d1605249d409fcf6391b0700c24ff4e651be0053 Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 12 Oct 2016 16:11:34 +0300 Subject: [PATCH 0394/1491] TAS-1432 - delete process by assigned user --- .../workflow/processes/DeleteProcessSanityTests.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java index 6a3c48529..62199aea3 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java @@ -60,4 +60,14 @@ public class DeleteProcessSanityTests extends RestWorkflowTest processesApi.getProcesses().assertProcessDoesNotExist(task); } + @TestRail(section = { "rest-api", + "processes" }, executionType = ExecutionType.SANITY, description = "Verify User is able to delete process assigned to him using REST API and status code is OK (204)") + public void deleteProcessByAssignedUser() throws Exception + { + restClient.authenticateUser(assignee); + processesApi.deleteProcess(task); + processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); + processesApi.getProcesses().assertProcessDoesNotExist(task); + } + } From db11b2562f50e35ce1bd3df07e104fb59be914f2 Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 12 Oct 2016 16:13:39 +0300 Subject: [PATCH 0395/1491] TAS-1433 - delete process by not involved user --- .../workflow/processes/DeleteProcessSanityTests.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java index 62199aea3..aa20eb22b 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java @@ -70,4 +70,13 @@ public class DeleteProcessSanityTests extends RestWorkflowTest processesApi.getProcesses().assertProcessDoesNotExist(task); } + @TestRail(section = { "rest-api", + "processes" }, executionType = ExecutionType.SANITY, description = "Verify User that is not involved in a process is not authorized to delete it using REST API and status code is 403") + public void deleteProcessByAnotherUser() throws Exception + { + restClient.authenticateUser(anotherUser); + processesApi.deleteProcess(task); + processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + } + } From 4badf68ea82b6dc120240b9e9134957c13734d90 Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 12 Oct 2016 16:14:25 +0300 Subject: [PATCH 0396/1491] updated parameter type --- .../rest/workflow/processes/GetProcessesSanityTests.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java index 9ee7ca759..6ef8c2ab4 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java @@ -50,7 +50,7 @@ public class GetProcessesSanityTests extends RestWorkflowTest public void getProcessesByUserWhoStartedProcess() throws JsonToModelConversionException, Exception { restClient.authenticateUser(userWhoStartsTask); - processesApi.getProcesses().assertProcessExists(task.getNodeRef()); + processesApi.getProcesses().assertProcessExists(task); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -59,7 +59,7 @@ public class GetProcessesSanityTests extends RestWorkflowTest public void getProcessesByAssignedUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(assignee); - processesApi.getProcesses().assertProcessExists(task.getNodeRef()); + processesApi.getProcesses().assertProcessExists(task); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -68,7 +68,7 @@ public class GetProcessesSanityTests extends RestWorkflowTest public void getProcessesByAnotherUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(anotherUser); - processesApi.getProcesses().assertProcessDoesNotExist(task.getNodeRef()); + processesApi.getProcesses().assertProcessDoesNotExist(task); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -77,7 +77,7 @@ public class GetProcessesSanityTests extends RestWorkflowTest public void getProcessesByAdmin() throws JsonToModelConversionException, Exception { restClient.authenticateUser(dataUser.getAdminUser()); - processesApi.getProcesses().assertProcessExists(task.getNodeRef()); + processesApi.getProcesses().assertProcessExists(task); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } } From c88b037d267418ade245b93f200dea7a4a0b77ba Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Wed, 12 Oct 2016 16:35:09 +0300 Subject: [PATCH 0397/1491] TAS-1375 getTasks call for candidate - 2 test cases --- e2e-test/java/org/alfresco/rest/RestTest.java | 4 +++ .../workflow/tasks/GetTasksSanityTests.java | 30 +++++++++++++++++-- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/RestTest.java b/e2e-test/java/org/alfresco/rest/RestTest.java index 28598c139..cc5e41e4b 100644 --- a/e2e-test/java/org/alfresco/rest/RestTest.java +++ b/e2e-test/java/org/alfresco/rest/RestTest.java @@ -4,6 +4,7 @@ import org.alfresco.rest.core.RestProperties; import org.alfresco.rest.core.RestWrapper; import org.alfresco.utility.TasProperties; import org.alfresco.utility.data.DataContent; +import org.alfresco.utility.data.DataGroup; import org.alfresco.utility.data.DataSite; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.network.ServerHealth; @@ -37,6 +38,9 @@ public abstract class RestTest extends AbstractTestNGSpringContextTests @Autowired protected DataContent dataContent; + + @Autowired + protected DataGroup dataGroup; @BeforeClass(alwaysRun = true) public void checkServerHealth() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksSanityTests.java index 7ad86a5df..79539cf57 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksSanityTests.java @@ -4,7 +4,9 @@ import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestWorkflowTest; import org.alfresco.rest.requests.RestTasksApi; import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.GroupModel; import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TaskModel; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; @@ -54,11 +56,33 @@ public class GetTasksSanityTests extends RestWorkflowTest tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "workflow", "tasks" }, executionType = ExecutionType.SANITY, description = "Verify candidate user gets its existing tasks with Rest API and response is successfull (200)") - public void candidateUserGetsItsTasks() throws Exception + @TestRail(section = { "rest-api", "workflow", "tasks" }, executionType = ExecutionType.SANITY, description = "Verify candidate user that claims the task gets its existing tasks with Rest API and response is successfull (200)") + public void candidateUserThatClaimsTaskGetsItsTasks() throws Exception { - restClient.authenticateUser(assigneeUser); + UserModel userModel1 = dataUser.createRandomTestUser(); + UserModel userModel2 = dataUser.createRandomTestUser(); + GroupModel group = dataGroup.createRandomGroup(); + dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); + TaskModel taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); + dataWorkflow.usingUser(userModel1).claimTask(taskModel); + + restClient.authenticateUser(userModel1); tasksApi.getTasks().assertEntriesListIsNotEmpty(); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + @TestRail(section = { "rest-api", "workflow", "tasks" }, executionType = ExecutionType.SANITY, description = "Verify candidate user without claim gets no tasks with Rest API and response is successfull (200)") + public void candidateUserWithoutClaimTaskGetsNoTasks() throws Exception + { + UserModel userModel1 = dataUser.createRandomTestUser(); + UserModel userModel2 = dataUser.createRandomTestUser(); + GroupModel group = dataGroup.createRandomGroup(); + dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); + TaskModel taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); + dataWorkflow.usingUser(userModel1).claimTask(taskModel); + + restClient.authenticateUser(userModel2); + tasksApi.getTasks().assertEntriesListIsEmpty(); + tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } } From 392fbaa8fda7f9b5e2d5f2f152cb8614e5953822 Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Wed, 12 Oct 2016 16:56:56 +0300 Subject: [PATCH 0398/1491] TAS-1418 getProcessVariables with user that started process --- .../GetProcessesVariablesSanityTests.java | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesVariablesSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesVariablesSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesVariablesSanityTests.java new file mode 100644 index 000000000..377621cdd --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesVariablesSanityTests.java @@ -0,0 +1,56 @@ +package org.alfresco.rest.workflow.processes; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestWorkflowTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.requests.RestProcessesApi; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * @author iulia.cojocea + */ +@Test(groups = { "rest-api", "processes", "sanity" }) +public class GetProcessesVariablesSanityTests extends RestWorkflowTest +{ + @Autowired + private DataUser dataUser; + + @Autowired + private RestProcessesApi processesApi; + + private FileModel document; + private SiteModel siteModel; + private UserModel userWhoStartsTask, assignee; + private RestProcessModel processModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + userWhoStartsTask = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); + processesApi.useRestClient(restClient); + } + + @TestRail(section = {"rest-api", "processes" }, executionType = ExecutionType.SANITY, + description = "Verify that user that started the process gets all process variables") + public void getProcessVariablesUsingTheUserWhoStartedProcess() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(userWhoStartsTask); + processModel = processesApi.getProcesses().getOneEntry(); + processesApi.getProcessesVariables(processModel); + processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } +} From ed3a4f6382813005bbf1cd2b6b0b3887cf58b681 Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Wed, 12 Oct 2016 17:00:07 +0300 Subject: [PATCH 0399/1491] TAS-1419 getProcessVariables using a user that is involved in the prosess --- .../processes/GetProcessesVariablesSanityTests.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesVariablesSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesVariablesSanityTests.java index 377621cdd..26f585226 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesVariablesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesVariablesSanityTests.java @@ -53,4 +53,14 @@ public class GetProcessesVariablesSanityTests extends RestWorkflowTest processesApi.getProcessesVariables(processModel); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + @TestRail(section = { "rest-api", "processes" }, executionType = ExecutionType.SANITY, + description = "Verify get all process variables call using a user that is involved in the process") + public void getProcessVariablesUsingUserInvolvedInProcess() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(assignee); + processModel = processesApi.getProcesses().getOneEntry(); + processesApi.getProcessesVariables(processModel); + processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } } From 47ebdef1830e3dd5d0d30e1768ef35726777b0ad Mon Sep 17 00:00:00 2001 From: cagache Date: Thu, 13 Oct 2016 11:08:31 +0300 Subject: [PATCH 0400/1491] TAS-1434 - get process definitions by admin for non-networks deployments --- .../GetProcessDefinitionsSanityTests.java | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java new file mode 100644 index 000000000..d64b9c577 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java @@ -0,0 +1,49 @@ +package org.alfresco.rest.workflow.processDefinitions; + +import org.alfresco.rest.RestWorkflowTest; +import org.alfresco.rest.requests.RestProcessDefinitionsApi; +import org.alfresco.rest.requests.RestTenantApi; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Created by Claudia Agache on 10/13/2016. + */ +@Test(groups = { "rest-api", "process-definitions", "sanity" }) +public class GetProcessDefinitionsSanityTests extends RestWorkflowTest +{ + @Autowired + RestTenantApi tenantApi; + @Autowired + private DataUser dataUser; + @Autowired + private RestProcessDefinitionsApi processDefinitionsApi; + + private UserModel adminUserModel, adminTenantUser; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUserModel); + processDefinitionsApi.useRestClient(restClient); + } + + // works on docker + @TestRail(section = { "rest-api", + "process-definitions" }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets process definitions for non-network deployments using REST API and status code is OK (200)") + public void nonNetworkAdminGetsProcessDefinitions() throws Exception + { + restClient.authenticateUser(adminUserModel); + processDefinitionsApi.getProcessDefinitions().assertResponseIsNotEmpty(); + processDefinitionsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } + +} From a4035f417d3fb23781132e8eae27ed643f247cb5 Mon Sep 17 00:00:00 2001 From: cagache Date: Thu, 13 Oct 2016 11:09:47 +0300 Subject: [PATCH 0401/1491] TAS-1435 - get process definitions by admin for networks deployments --- .../GetProcessDefinitionsSanityTests.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java index d64b9c577..7a03eab1e 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java @@ -37,8 +37,8 @@ public class GetProcessDefinitionsSanityTests extends RestWorkflowTest } // works on docker - @TestRail(section = { "rest-api", - "process-definitions" }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets process definitions for non-network deployments using REST API and status code is OK (200)") + @TestRail(section = { "rest-api", "process-definitions" }, + executionType = ExecutionType.SANITY, description = "Verify Admin user gets process definitions for non-network deployments using REST API and status code is OK (200)") public void nonNetworkAdminGetsProcessDefinitions() throws Exception { restClient.authenticateUser(adminUserModel); @@ -46,4 +46,17 @@ public class GetProcessDefinitionsSanityTests extends RestWorkflowTest processDefinitionsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + // works on alfresco.server=172.29.100.215 + @TestRail(section = { "rest-api", "process-definitions" }, + executionType = ExecutionType.SANITY, description = "Verify Tenant Admin user gets process definitions for network deployments using REST API and status code is OK (200)") + + @Test(groups = { "networks" }) + public void networkAdminGetsProcessDefinitions() throws Exception + { + tenantApi.useRestClient(restClient); + tenantApi.createTenant(adminTenantUser); + restClient.authenticateUser(adminTenantUser); + processDefinitionsApi.getProcessDefinitions().assertResponseIsNotEmpty(); + processDefinitionsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } } From 2eb7e1cb2cae73f92dc26ac3aeab91ba4c52c719 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Thu, 13 Oct 2016 11:27:27 +0300 Subject: [PATCH 0402/1491] TAS-1456 getTask call for admin user --- .../workflow/tasks/GetTaskSanityTests.java | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskSanityTests.java new file mode 100644 index 000000000..c4e79b3b3 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskSanityTests.java @@ -0,0 +1,50 @@ +package org.alfresco.rest.workflow.tasks; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestWorkflowTest; +import org.alfresco.rest.requests.RestTasksApi; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TaskModel; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +@Test(groups = { "rest-api", "workflow", "tasks", "sanity" }) +public class GetTaskSanityTests extends RestWorkflowTest +{ + @Autowired + RestTasksApi tasksApi; + + UserModel userModel; + SiteModel siteModel; + UserModel candidateUser; + FileModel fileModel; + UserModel assigneeUser; + TaskModel taskModel; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + assigneeUser = dataUser.createRandomTestUser(); + taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + + tasksApi.useRestClient(restClient); + } + + @TestRail(section = { "rest-api", "workflow", "tasks" }, executionType = ExecutionType.SANITY, description = "Verify admin user gets any existing task with Rest API and response is successfull (200)") + public void adminUserGetsAnyTaskWithSuccess() throws Exception + { + UserModel adminUser = dataUser.getAdminUser(); + restClient.authenticateUser(adminUser); + tasksApi.getTask(taskModel); + tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } +} From 6e463c367d9147c5d4e834ed611500b316889e2c Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Thu, 13 Oct 2016 11:38:46 +0300 Subject: [PATCH 0403/1491] TAS-1436 getTask call for assignee --- .../alfresco/rest/workflow/tasks/GetTaskSanityTests.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskSanityTests.java index c4e79b3b3..d69196720 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskSanityTests.java @@ -47,4 +47,12 @@ public class GetTaskSanityTests extends RestWorkflowTest tasksApi.getTask(taskModel); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + @TestRail(section = { "rest-api", "workflow", "tasks" }, executionType = ExecutionType.SANITY, description = "Verify assignee user gets its assigned task with Rest API and response is successfull (200)") + public void assigneeUserGetsItsTaskWithSuccess() throws Exception + { + restClient.authenticateUser(assigneeUser); + tasksApi.getTask(taskModel); + tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } } From 10a9e77ce75c24d487c35f4cc8306cc124cd0fe4 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Thu, 13 Oct 2016 11:56:55 +0300 Subject: [PATCH 0404/1491] TAS-1437 getTask call for user that started process --- .../alfresco/rest/workflow/tasks/GetTaskSanityTests.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskSanityTests.java index d69196720..9574d2cf1 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskSanityTests.java @@ -55,4 +55,12 @@ public class GetTaskSanityTests extends RestWorkflowTest tasksApi.getTask(taskModel); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + @TestRail(section = { "rest-api", "workflow", "tasks" }, executionType = ExecutionType.SANITY, description = "Verify user that started the task gets the started task with Rest API and response is successfull (200)") + public void starterUserGetsItsTaskWithSuccess() throws Exception + { + restClient.authenticateUser(userModel); + tasksApi.getTask(taskModel); + tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } } From daaa0a287a354ba48c6388b57787df2fa9399b9c Mon Sep 17 00:00:00 2001 From: cagache Date: Thu, 13 Oct 2016 12:42:50 +0300 Subject: [PATCH 0405/1491] TAS-1451 - get a specific process by admin --- .../GetProcessDefinitionSanityTests.java | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java new file mode 100644 index 000000000..ace852b2a --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java @@ -0,0 +1,48 @@ +package org.alfresco.rest.workflow.processDefinitions; + +import org.alfresco.rest.RestWorkflowTest; +import org.alfresco.rest.model.RestProcessDefinitionModel; +import org.alfresco.rest.model.RestProcessDefinitionModelsCollection; +import org.alfresco.rest.requests.RestProcessDefinitionsApi; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Created by Claudia Agache on 10/13/2016. + */ +@Test(groups = { "rest-api", "process-definitions", "sanity" }) +public class GetProcessDefinitionSanityTests extends RestWorkflowTest +{ + @Autowired + private DataUser dataUser; + @Autowired + private RestProcessDefinitionsApi processDefinitionsApi; + + private UserModel testUser; + private RestProcessDefinitionModel randomProcessDefinition; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + testUser = dataUser.createRandomTestUser(); + processDefinitionsApi.useRestClient(restClient); + restClient.authenticateUser(dataUser.getAdminUser()); + randomProcessDefinition = processDefinitionsApi.getProcessDefinitions().getOneEntry(); + } + + @TestRail(section = { "rest-api", "process-definitions" }, + executionType = ExecutionType.SANITY, + description = "Verify Admin user gets a specific process definition for non-network deployments using REST API and status code is OK (200)") + public void adminGetsProcessDefinition() throws Exception + { + processDefinitionsApi.getProcessDefinition(randomProcessDefinition).assertProcessDefinitionNameIs(randomProcessDefinition.onModel().getName()); + processDefinitionsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } + +} From a3e654e0636bf17719a12cfeba417f860b69c77b Mon Sep 17 00:00:00 2001 From: cagache Date: Thu, 13 Oct 2016 12:43:41 +0300 Subject: [PATCH 0406/1491] TAS-1450 - get a specific process by any user --- .../GetProcessDefinitionSanityTests.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java index ace852b2a..179e55396 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java @@ -45,4 +45,13 @@ public class GetProcessDefinitionSanityTests extends RestWorkflowTest processDefinitionsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + @TestRail(section = { "rest-api", "process-definitions" }, + executionType = ExecutionType.SANITY, + description = "Verify Any user gets a specific process definition for non-network deployments using REST API and status code is OK (200)") + public void anyUserGetsProcessDefinition() throws Exception + { + restClient.authenticateUser(testUser); + processDefinitionsApi.getProcessDefinition(randomProcessDefinition).assertProcessDefinitionNameIs(randomProcessDefinition.onModel().getName()); + processDefinitionsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } } From 80f5c04718a37c17c44bc0ad58bc56490c36c1fe Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Thu, 13 Oct 2016 13:03:16 +0300 Subject: [PATCH 0407/1491] TAS-1446 valid request to create non-existing variable, 201 --- .../AddProcessVariableSanityTests.java | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java new file mode 100644 index 000000000..1247b374b --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java @@ -0,0 +1,61 @@ +package org.alfresco.rest.workflow.processes; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestWorkflowTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestProcessVariableModel; +import org.alfresco.rest.requests.RestProcessesApi; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.data.RandomData; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * @author iulia.cojocea + */ +@Test(groups = { "rest-api", "processes", "sanity" }) +public class AddProcessVariableSanityTests extends RestWorkflowTest +{ + @Autowired + private DataUser dataUser; + + @Autowired + private RestProcessesApi processesApi; + + private FileModel document; + private SiteModel siteModel; + private UserModel userWhoStartsTask, assignee; + private RestProcessModel processModel; + private UserModel adminUser; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userWhoStartsTask = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); + processesApi.useRestClient(restClient); + } + + @TestRail(section = {"rest-api", "processes" }, executionType = ExecutionType.SANITY, + description = "Create non-existing variable") + public void addProcessVariable() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(userWhoStartsTask); + RestProcessVariableModel variableModel = new RestProcessVariableModel(RandomData.getRandomName("name"), RandomData.getRandomName("value"), "d:text"); + processModel = processesApi.getProcesses().getOneEntry(); + processesApi.addProcessVariable(processModel, variableModel); + processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + } +} From 304e387b6a0e8dbdc990a95abe3f0ccdc5731b61 Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Thu, 13 Oct 2016 13:09:14 +0300 Subject: [PATCH 0408/1491] TAS-1447 update process variable --- .../processes/AddProcessVariableSanityTests.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java index 1247b374b..1c1050c06 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java @@ -58,4 +58,18 @@ public class AddProcessVariableSanityTests extends RestWorkflowTest processesApi.addProcessVariable(processModel, variableModel); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } + + @TestRail(section = {"rest-api", "processes" }, executionType = ExecutionType.SANITY, + description = "Update existing variable") + public void updateExistingProcessVariable() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(userWhoStartsTask); + String variableName = RandomData.getRandomName("name"); + RestProcessVariableModel variableModel = new RestProcessVariableModel(variableName, RandomData.getRandomName("value"), "d:text"); + processModel = processesApi.getProcesses().getOneEntry(); + processesApi.addProcessVariable(processModel, variableModel); + variableModel.setValue(RandomData.getRandomName("newValue")); + processesApi.addProcessVariable(processModel, variableModel); + processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + } } From 9be5c0472340037e640c77e704261a144c7d038c Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Thu, 13 Oct 2016 13:09:56 +0300 Subject: [PATCH 0409/1491] TAS-1448 add process variable using admin user --- .../processes/AddProcessVariableSanityTests.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java index 1c1050c06..71ab5a84b 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java @@ -72,4 +72,15 @@ public class AddProcessVariableSanityTests extends RestWorkflowTest processesApi.addProcessVariable(processModel, variableModel); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } + + @TestRail(section = {"rest-api", "processes" }, executionType = ExecutionType.SANITY, + description = "Add process variable using admin user") + public void addProcessVariableByAdmin() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUser); + RestProcessVariableModel variableModel = new RestProcessVariableModel(RandomData.getRandomName("name"), RandomData.getRandomName("value"), "d:text"); + processModel = processesApi.getProcesses().getOneEntry(); + processesApi.addProcessVariable(processModel, variableModel); + processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + } From 2db85e7e978530438f400cbae9cbe2fbd48457da Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Thu, 13 Oct 2016 13:10:57 +0300 Subject: [PATCH 0410/1491] TAS-1449 adding process variable is falling in case invalid variableBody is provided --- .../processes/AddProcessVariableSanityTests.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java index 71ab5a84b..cef187405 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java @@ -82,5 +82,16 @@ public class AddProcessVariableSanityTests extends RestWorkflowTest processModel = processesApi.getProcesses().getOneEntry(); processesApi.addProcessVariable(processModel, variableModel); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + } + @TestRail(section = {"rest-api", "processes" }, executionType = ExecutionType.SANITY, + description = "Adding process variable is falling in case invalid variableBody is provided") + public void failedAddingProcessVariableIfInvalidBodyIsProvided() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUser); + RestProcessVariableModel variableModel = new RestProcessVariableModel(RandomData.getRandomName("name"), RandomData.getRandomName("value"), "incorrect type"); + processModel = processesApi.getProcesses().getOneEntry(); + processesApi.addProcessVariable(processModel, variableModel); + processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.BAD_REQUEST); + } } From 330290749f87278f8fc8f47da539bc93e18203be Mon Sep 17 00:00:00 2001 From: cagache Date: Thu, 13 Oct 2016 16:37:15 +0300 Subject: [PATCH 0411/1491] TAS-1480 - get a specific process definition image by any user --- .../GetProcessDefinitionImageSanityTests.java | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java new file mode 100644 index 000000000..3c7139015 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java @@ -0,0 +1,46 @@ +package org.alfresco.rest.workflow.processDefinitions; + +import org.alfresco.rest.RestWorkflowTest; +import org.alfresco.rest.model.RestProcessDefinitionModel; +import org.alfresco.rest.requests.RestProcessDefinitionsApi; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Created by Claudia Agache on 10/13/2016. + */ +@Test(groups = { "rest-api", "process-definitions", "sanity" }) +public class GetProcessDefinitionImageSanityTests extends RestWorkflowTest +{ + @Autowired + private DataUser dataUser; + @Autowired + private RestProcessDefinitionsApi processDefinitionsApi; + + private UserModel testUser; + private RestProcessDefinitionModel randomProcessDefinition; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + testUser = dataUser.createRandomTestUser(); + processDefinitionsApi.useRestClient(restClient); + restClient.authenticateUser(dataUser.getAdminUser()); + randomProcessDefinition = processDefinitionsApi.getProcessDefinitions().getOneEntry(); + } + + @TestRail(section = { "rest-api", "process-definitions" }, + executionType = ExecutionType.SANITY, description = "Verify Any user gets a specific process definition image for non-network deployments using REST API and status code is OK (200)") + public void anyUserGetsProcessDefinitionImage() throws Exception + { + restClient.authenticateUser(testUser); + processDefinitionsApi.getProcessDefinitionImage(randomProcessDefinition).assertResponseContainsImage(); + processDefinitionsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } +} \ No newline at end of file From ea0a8603843e7f8d93485189fa13703cc1b31124 Mon Sep 17 00:00:00 2001 From: cagache Date: Thu, 13 Oct 2016 16:38:32 +0300 Subject: [PATCH 0412/1491] TAS-1481 - get a specific process definition image by admin --- .../GetProcessDefinitionImageSanityTests.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java index 3c7139015..7017aab42 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java @@ -43,4 +43,12 @@ public class GetProcessDefinitionImageSanityTests extends RestWorkflowTest processDefinitionsApi.getProcessDefinitionImage(randomProcessDefinition).assertResponseContainsImage(); processDefinitionsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + @TestRail(section = { "rest-api", "process-definitions" }, + executionType = ExecutionType.SANITY, description = "Verify Admin user gets a specific process definition image for non-network deployments using REST API and status code is OK (200)") + public void adminGetsProcessDefinitionImage() throws Exception + { + processDefinitionsApi.getProcessDefinitionImage(randomProcessDefinition).assertResponseContainsImage(); + processDefinitionsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } } \ No newline at end of file From 52492867289eecf342c9345513c611a6177bb0c8 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Thu, 13 Oct 2016 16:43:13 +0300 Subject: [PATCH 0413/1491] TAS-1439 getTask failed call for any user --- .../rest/workflow/tasks/GetTaskSanityTests.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskSanityTests.java index 9574d2cf1..2d0e416c6 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskSanityTests.java @@ -63,4 +63,14 @@ public class GetTaskSanityTests extends RestWorkflowTest tasksApi.getTask(taskModel); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + @TestRail(section = { "rest-api", "workflow", "tasks" }, executionType = ExecutionType.SANITY, description = "Verify any user with no relation to task id forbidden to get other task with Rest API (403)") + public void anyUserIsForbiddenToGetOtherTask() throws Exception + { + UserModel anyUser= dataUser.createRandomTestUser(); + + restClient.authenticateUser(anyUser); + tasksApi.getTask(taskModel); + tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + } } From ba28a3c715bf9dea36ffa415754609883df61434 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Thu, 13 Oct 2016 17:03:47 +0300 Subject: [PATCH 0414/1491] TAS-1438 getTask call for user candidate in process --- .../rest/workflow/tasks/GetTaskSanityTests.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskSanityTests.java index 2d0e416c6..7bb8675bb 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskSanityTests.java @@ -4,6 +4,7 @@ import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestWorkflowTest; import org.alfresco.rest.requests.RestTasksApi; import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.GroupModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TaskModel; import org.alfresco.utility.model.UserModel; @@ -73,4 +74,18 @@ public class GetTaskSanityTests extends RestWorkflowTest tasksApi.getTask(taskModel); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } + + @TestRail(section = { "rest-api", "workflow", "tasks" }, executionType = ExecutionType.SANITY, description = "Verify candidate user gets its specific task and no other user claimed the task with Rest API and response is successfull (200)") + public void candidateUserGetsItsTasks() throws Exception + { + UserModel userModel1 = dataUser.createRandomTestUser(); + UserModel userModel2 = dataUser.createRandomTestUser(); + GroupModel group = dataGroup.createRandomGroup(); + dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); + TaskModel taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); + + restClient.authenticateUser(userModel1); + tasksApi.getTask(taskModel); + tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } } From 55a1865c20aa0692d8c372d1d616b6979bb50aaf Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Thu, 13 Oct 2016 17:39:42 +0300 Subject: [PATCH 0415/1491] TAS-1487 getTask call for user involved in process --- .../rest/workflow/tasks/GetTaskSanityTests.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskSanityTests.java index 7bb8675bb..efb85a120 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskSanityTests.java @@ -8,6 +8,7 @@ import org.alfresco.utility.model.GroupModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TaskModel; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.beans.factory.annotation.Autowired; @@ -88,4 +89,20 @@ public class GetTaskSanityTests extends RestWorkflowTest tasksApi.getTask(taskModel); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + @Bug(id = "") + @TestRail(section = { "rest-api", "workflow", "tasks" }, executionType = ExecutionType.SANITY, description = "Verify involved user in a task without claim it gets the task with Rest API and response is successfull (200)") + public void involvedUserWithoutClaimTaskGetsTask() throws Exception + { + UserModel userModel1 = dataUser.createRandomTestUser(); + UserModel userModel2 = dataUser.createRandomTestUser(); + GroupModel group = dataGroup.createRandomGroup(); + dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); + TaskModel taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); + dataWorkflow.usingUser(userModel1).claimTask(taskModel); + + restClient.authenticateUser(userModel2); + tasksApi.getTask(taskModel); + tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } } From 2115c925648c1059bca463cf49f2afce54139c18 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Thu, 13 Oct 2016 17:54:40 +0300 Subject: [PATCH 0416/1491] Added one more test for a candidate user --- .../rest/workflow/tasks/GetTasksSanityTests.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksSanityTests.java index 79539cf57..ddaa147ca 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksSanityTests.java @@ -8,6 +8,7 @@ import org.alfresco.utility.model.GroupModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TaskModel; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.beans.factory.annotation.Autowired; @@ -56,6 +57,21 @@ public class GetTasksSanityTests extends RestWorkflowTest tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + @Bug(id = "") + @TestRail(section = { "rest-api", "workflow", "tasks" }, executionType = ExecutionType.SANITY, description = "Verify candidate user gets its existing tasks and no other user claimed the task with Rest API and response is successfull (200)") + public void candidateUserGetsItsTasks() throws Exception + { + UserModel userModel1 = dataUser.createRandomTestUser(); + UserModel userModel2 = dataUser.createRandomTestUser(); + GroupModel group = dataGroup.createRandomGroup(); + dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); + dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); + + restClient.authenticateUser(userModel1); + tasksApi.getTasks().assertEntriesListIsNotEmpty(); + tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } + @TestRail(section = { "rest-api", "workflow", "tasks" }, executionType = ExecutionType.SANITY, description = "Verify candidate user that claims the task gets its existing tasks with Rest API and response is successfull (200)") public void candidateUserThatClaimsTaskGetsItsTasks() throws Exception { From f55f48d7e7fb88912f8a0d9a410c63e82d361dd8 Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Thu, 13 Oct 2016 17:23:08 +0300 Subject: [PATCH 0417/1491] TAS-1475 get process items call with user that started process --- .../DeleteProcessVariableSanityTests.java | 51 +++++++++++++++ .../processes/GetProcessItemsSanityTests.java | 64 +++++++++++++++++++ 2 files changed, 115 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableSanityTests.java create mode 100644 e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableSanityTests.java new file mode 100644 index 000000000..1d6c2a66a --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableSanityTests.java @@ -0,0 +1,51 @@ +package org.alfresco.rest.workflow.processes; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestWorkflowTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.requests.RestProcessesApi; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; + +public class DeleteProcessVariableSanityTests extends RestWorkflowTest +{ + @Autowired + private DataUser dataUser; + + @Autowired + private RestProcessesApi processesApi; + + private FileModel document; + private SiteModel siteModel; + private UserModel adminUser, assignee; + private RestProcessModel processModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + assignee = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + dataWorkflow.usingUser(adminUser).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); + processesApi.useRestClient(restClient); + } + + @TestRail(section = {"rest-api", "processes" }, executionType = ExecutionType.SANITY, + description = "Delete process variable call returns 204 status code") + public void deleteProcessVariable() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUser); + processModel = processesApi.getProcesses().getOneEntry(); + // processesApi.deleteProcessVariable(processModel, ); + processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } +} diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsSanityTests.java new file mode 100644 index 000000000..0b6177238 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsSanityTests.java @@ -0,0 +1,64 @@ +package org.alfresco.rest.workflow.processes; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestWorkflowTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.requests.RestProcessesApi; +import org.alfresco.rest.requests.RestTenantApi; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * @author iulia.cojocea + */ + +@Test(groups = { "rest-api", "processes", "sanity" }) +public class GetProcessItemsSanityTests extends RestWorkflowTest +{ + @Autowired + private DataUser dataUser; + + @Autowired + private RestProcessesApi processesApi; + + @Autowired + RestTenantApi tenantApi; + + private FileModel document; + private SiteModel siteModel; + private UserModel userWhoStartsTask, assignee, adminTenantUser, tenantUser; + private RestProcessModel processModel; + + private UserModel tenantUserAssignee; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + userWhoStartsTask = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); + processesApi.useRestClient(restClient); + } + + //Run on docker + @TestRail(section = {"rest-api", "processes" }, executionType = ExecutionType.SANITY, + description = "Verify that user that started the process gets all process items") + public void getProcessItemsUsingTheUserWhoStartedProcess() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(userWhoStartsTask); + processModel = processesApi.getProcesses().getOneEntry(); + processesApi.getProcessesItems(processModel); + processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } +} From a6ad94a3f667890c67b3c5c50f502a179719c0f9 Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Fri, 14 Oct 2016 09:44:32 +0300 Subject: [PATCH 0418/1491] TAS-1476 Get process items with user that is involved in process --- .../processes/GetProcessItemsSanityTests.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsSanityTests.java index 0b6177238..5d3b473f0 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsSanityTests.java @@ -61,4 +61,15 @@ public class GetProcessItemsSanityTests extends RestWorkflowTest processesApi.getProcessesItems(processModel); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + // Run on docker + @TestRail(section = { "rest-api", "processes" }, executionType = ExecutionType.SANITY, + description = "Verify that user that is involved in the process gets all process items") + public void getProcessItemsUsingUserInvolvedInProcess() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(assignee); + processModel = processesApi.getProcesses().getOneEntry(); + processesApi.getProcessesItems(processModel); + processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } } From 85fe99b6094857422a4e0b089dfe4f6cc5956551 Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Fri, 14 Oct 2016 09:45:38 +0300 Subject: [PATCH 0419/1491] TAS-1477 Get process items with admin from same network --- .../DeleteProcessVariableSanityTests.java | 51 ------------------- .../processes/GetProcessItemsSanityTests.java | 25 ++++++++- 2 files changed, 23 insertions(+), 53 deletions(-) delete mode 100644 e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableSanityTests.java deleted file mode 100644 index 1d6c2a66a..000000000 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableSanityTests.java +++ /dev/null @@ -1,51 +0,0 @@ -package org.alfresco.rest.workflow.processes; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestWorkflowTest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.requests.RestProcessesApi; -import org.alfresco.utility.data.DataUser; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; - -public class DeleteProcessVariableSanityTests extends RestWorkflowTest -{ - @Autowired - private DataUser dataUser; - - @Autowired - private RestProcessesApi processesApi; - - private FileModel document; - private SiteModel siteModel; - private UserModel adminUser, assignee; - private RestProcessModel processModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - assignee = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - dataWorkflow.usingUser(adminUser).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); - processesApi.useRestClient(restClient); - } - - @TestRail(section = {"rest-api", "processes" }, executionType = ExecutionType.SANITY, - description = "Delete process variable call returns 204 status code") - public void deleteProcessVariable() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUser); - processModel = processesApi.getProcesses().getOneEntry(); - // processesApi.deleteProcessVariable(processModel, ); - processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); - } -} diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsSanityTests.java index 5d3b473f0..4808c85c4 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsSanityTests.java @@ -51,7 +51,6 @@ public class GetProcessItemsSanityTests extends RestWorkflowTest processesApi.useRestClient(restClient); } - //Run on docker @TestRail(section = {"rest-api", "processes" }, executionType = ExecutionType.SANITY, description = "Verify that user that started the process gets all process items") public void getProcessItemsUsingTheUserWhoStartedProcess() throws JsonToModelConversionException, Exception @@ -62,7 +61,6 @@ public class GetProcessItemsSanityTests extends RestWorkflowTest processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - // Run on docker @TestRail(section = { "rest-api", "processes" }, executionType = ExecutionType.SANITY, description = "Verify that user that is involved in the process gets all process items") public void getProcessItemsUsingUserInvolvedInProcess() throws JsonToModelConversionException, Exception @@ -72,4 +70,27 @@ public class GetProcessItemsSanityTests extends RestWorkflowTest processesApi.getProcessesItems(processModel); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + @Test(groups = { "networks" }) + @TestRail(section = {"rest-api", "processes" }, executionType = ExecutionType.SANITY, + description = "Get process items using admin from same network") + public void getProcessItemsUsingAdminUserFromSameNetwork() throws JsonToModelConversionException, Exception + { + UserModel adminuser = dataUser.getAdminUser(); + restClient.authenticateUser(adminuser); + + adminTenantUser = UserModel.getAdminTenantUser(); + tenantApi.useRestClient(restClient); + tenantApi.createTenant(adminTenantUser); + + tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); + + siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); + dataWorkflow.usingUser(tenantUser).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(tenantUserAssignee); + + processModel = processesApi.getProcesses().getOneEntry(); + processesApi.getProcessesItems(processModel); + processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } } From 300ffe02474efc674f1d5f946928760cfb3d11d3 Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Fri, 14 Oct 2016 16:19:25 +0300 Subject: [PATCH 0420/1491] TAS-1468 removeProcessVariable returns 204 --- .../RemoveProcessVariableSanityTests.java | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessVariableSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessVariableSanityTests.java new file mode 100644 index 000000000..4351e8a07 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessVariableSanityTests.java @@ -0,0 +1,61 @@ +package org.alfresco.rest.workflow.processes; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestWorkflowTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestProcessVariableModel; +import org.alfresco.rest.requests.RestProcessesApi; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * @author iulia.cojocea + */ +@Test(groups = { "rest-api", "processes", "sanity" }) +public class RemoveProcessVariableSanityTests extends RestWorkflowTest +{ + @Autowired + private DataUser dataUser; + + @Autowired + private RestProcessesApi processesApi; + + private FileModel document; + private SiteModel siteModel; + private UserModel userWhoStartsTask, assignee; + private RestProcessModel processModel; + private UserModel adminUser; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userWhoStartsTask = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); + processesApi.useRestClient(restClient); + } + + @TestRail(section = {"rest-api", "processes" }, executionType = ExecutionType.SANITY, + description = "Delete existing variable") + public void deleteProcessVariable() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUser); + RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = processesApi.getProcesses().getOneEntry(); + processesApi.addProcessVariable(processModel, variableModel); + processesApi.deleteProcessVariable(processModel, variableModel); + processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); + } +} From 75b686d857fec88ca5b472918591619c391bd1d2 Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Fri, 14 Oct 2016 16:20:34 +0300 Subject: [PATCH 0421/1491] TAS-1469 removeProcessVariable for invalid processId returns 404 --- .../processes/RemoveProcessVariableSanityTests.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessVariableSanityTests.java index 4351e8a07..019e17adc 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessVariableSanityTests.java @@ -58,4 +58,17 @@ public class RemoveProcessVariableSanityTests extends RestWorkflowTest processesApi.deleteProcessVariable(processModel, variableModel); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); } + + @TestRail(section = {"rest-api", "processes" }, executionType = ExecutionType.SANITY, + description = "Try to delete existing variable using invalid processId") + public void deleteProcessVariableUsingInvalidProcessId() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUser); + RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = processesApi.getProcesses().getOneEntry(); + processesApi.addProcessVariable(processModel, variableModel); + processModel = processesApi.getProcesses().getOneEntry(); + processesApi.deleteProcessVariable(processModel, variableModel); + processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); + } } From f2c3d4b293d8ac9341dc4a844fec7c7381b5ad1b Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Fri, 14 Oct 2016 16:20:34 +0300 Subject: [PATCH 0422/1491] TAS-1469 removeProcessVariable for invalid processId returns 404 --- .../processes/AddProcessVariableSanityTests.java | 1 + .../processes/RemoveProcessVariableSanityTests.java | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java index fa17c148a..47b28505c 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java @@ -76,6 +76,7 @@ public class AddProcessVariableSanityTests extends RestWorkflowTest processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } + @Test(groups = { "networks" }) @TestRail(section = {"rest-api", "processes" }, executionType = ExecutionType.SANITY, description = "Add process variable using admin user from same network") public void addProcessVariableByAdmin() throws JsonToModelConversionException, Exception diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessVariableSanityTests.java index 4351e8a07..019e17adc 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessVariableSanityTests.java @@ -58,4 +58,17 @@ public class RemoveProcessVariableSanityTests extends RestWorkflowTest processesApi.deleteProcessVariable(processModel, variableModel); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); } + + @TestRail(section = {"rest-api", "processes" }, executionType = ExecutionType.SANITY, + description = "Try to delete existing variable using invalid processId") + public void deleteProcessVariableUsingInvalidProcessId() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUser); + RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = processesApi.getProcesses().getOneEntry(); + processesApi.addProcessVariable(processModel, variableModel); + processModel = processesApi.getProcesses().getOneEntry(); + processesApi.deleteProcessVariable(processModel, variableModel); + processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); + } } From f4395c91ea8397fee5914ba2c20deb493698daf1 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Fri, 14 Oct 2016 17:17:04 +0300 Subject: [PATCH 0423/1491] TAS-1498 getProcessTasks call with starter user --- .../processes/GetProcessTasksSanityTests.java | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksSanityTests.java new file mode 100644 index 000000000..c38a23bf7 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksSanityTests.java @@ -0,0 +1,61 @@ +package org.alfresco.rest.workflow.processes; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestWorkflowTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.requests.RestProcessesApi; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.ProcessModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Tests for GET "/processes/{processId}/tasks" REST API call + * + * @author Cristina Axinte + * + */ +@Test(groups = { "rest-api", "workflow", "processes", "sanity" }) +public class GetProcessTasksSanityTests extends RestWorkflowTest +{ + @Autowired + private RestProcessesApi processesApi; + + private UserModel userModel; + private FileModel document; + private SiteModel siteModel; + private UserModel assignee1, assignee2, assignee3; + private ProcessModel process; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + assignee1 = dataUser.createRandomTestUser(); + assignee2 = dataUser.createRandomTestUser(); + assignee3 = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + process = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(document).createMoreReviewersWorkflowAndAssignTo(assignee1, assignee2, assignee3); + processesApi.useRestClient(restClient); + } + + @TestRail(section = { "rest-api", "workflow", + "processes" }, executionType = ExecutionType.SANITY, description = "Verify user who started the task gets the all tasks started task with Rest API and response is successfull (200) (200)") + public void userWhoStartedProcesCanGetProcessTasks() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(userModel); + processesApi.getProcessTasks(process) + .assertEntriesListIsNotEmpty() + .assertTaskWithAssigneeExists(assignee1) + .assertTaskWithAssigneeExists(assignee2) + .assertTaskWithAssigneeExists(assignee3); + processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } +} From 6ef179cdb9803fd7505e477025e7efcb3b98f31a Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Fri, 14 Oct 2016 17:47:11 +0300 Subject: [PATCH 0424/1491] TAS-1500 getProcessTasks call with assignee user --- .../processes/GetProcessTasksSanityTests.java | 31 +++++++++++++------ 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksSanityTests.java index c38a23bf7..db9af562c 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksSanityTests.java @@ -5,8 +5,10 @@ import org.alfresco.rest.RestWorkflowTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.requests.RestProcessesApi; import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.GroupModel; import org.alfresco.utility.model.ProcessModel; import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TaskModel; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; @@ -19,7 +21,6 @@ import org.testng.annotations.Test; * Tests for GET "/processes/{processId}/tasks" REST API call * * @author Cristina Axinte - * */ @Test(groups = { "rest-api", "workflow", "processes", "sanity" }) public class GetProcessTasksSanityTests extends RestWorkflowTest @@ -42,20 +43,32 @@ public class GetProcessTasksSanityTests extends RestWorkflowTest assignee3 = dataUser.createRandomTestUser(); siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - process = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(document).createMoreReviewersWorkflowAndAssignTo(assignee1, assignee2, assignee3); + process = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(document) + .createMoreReviewersWorkflowAndAssignTo(assignee1, assignee2, assignee3); processesApi.useRestClient(restClient); } - @TestRail(section = { "rest-api", "workflow", - "processes" }, executionType = ExecutionType.SANITY, description = "Verify user who started the task gets the all tasks started task with Rest API and response is successfull (200) (200)") - public void userWhoStartedProcesCanGetProcessTasks() throws JsonToModelConversionException, Exception + @TestRail(section = { "rest-api", "workflow", "processes" }, executionType = ExecutionType.SANITY, description = "Verify user who started the process gets all tasks of started process with Rest API and response is successfull (200)") + public void userWhoStartedProcessCanGetProcessTasks() throws JsonToModelConversionException, Exception { restClient.authenticateUser(userModel); processesApi.getProcessTasks(process) - .assertEntriesListIsNotEmpty() - .assertTaskWithAssigneeExists(assignee1) - .assertTaskWithAssigneeExists(assignee2) - .assertTaskWithAssigneeExists(assignee3); + .assertEntriesListIsNotEmpty() + .assertTaskWithAssigneeExists(assignee1) + .assertTaskWithAssigneeExists(assignee2) + .assertTaskWithAssigneeExists(assignee3); + processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { "rest-api", "workflow", "processes" }, executionType = ExecutionType.SANITY, description = "Verify any assignee user of the process gets all tasks of the process with Rest API and response is successfull (200)") + public void assigneeUserCanGetAllProcessTasks() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(assignee1); + processesApi.getProcessTasks(process) + .assertEntriesListIsNotEmpty() + .assertTaskWithAssigneeExists(assignee1) + .assertTaskWithAssigneeExists(assignee2) + .assertTaskWithAssigneeExists(assignee3); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } } From 004589a0d9f2c61384f72dd574b7b8d2916072c2 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Fri, 14 Oct 2016 18:16:02 +0300 Subject: [PATCH 0425/1491] TAS-1499 getProcessTasks call with involved user --- .../processes/GetProcessTasksSanityTests.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksSanityTests.java index db9af562c..c696dd92a 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksSanityTests.java @@ -71,4 +71,18 @@ public class GetProcessTasksSanityTests extends RestWorkflowTest .assertTaskWithAssigneeExists(assignee3); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + @TestRail(section = { "rest-api", "workflow", "processes" }, executionType = ExecutionType.SANITY, description = "Verify any assignee user of the process gets all tasks of the process with Rest API and response is successfull (200)") + public void involvedUserCanGetAllProcessTasks() throws JsonToModelConversionException, Exception + { + ProcessModel process = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(document) + .createMoreReviewersWorkflowAndAssignTo(assignee1, assignee2, assignee3); + dataWorkflow.usingUser(assignee1).approveTask(process); + + restClient.authenticateUser(assignee2); + processesApi.getProcessTasks(process) + .assertEntriesListIsNotEmpty() + .assertTaskWithAssigneeExists(userModel); + processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } } From 083d46305f872ff69565a9ff2971cea2fc528b0f Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Mon, 17 Oct 2016 12:51:06 +0300 Subject: [PATCH 0426/1491] TAS-1530 getDeployment valid request with admin user --- .../deployments/GetDeploymentSanityTests.java | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentSanityTests.java new file mode 100644 index 000000000..51017450c --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentSanityTests.java @@ -0,0 +1,46 @@ +package org.alfresco.rest.workflow.deployments; + +import org.alfresco.rest.RestWorkflowTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestDeploymentModel; +import org.alfresco.rest.requests.RestDeploymentsApi; +import org.alfresco.rest.requests.RestTenantApi; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Tests for REST API call GET "/deployments/{deploymentId}" + * + * @author Cristina Axinte + * + */ +@Test(groups = { "rest-api", "workflow", "deployments", "sanity" }) +public class GetDeploymentSanityTests extends RestWorkflowTest +{ + @Autowired + private RestDeploymentsApi deploymentsApi; + + private UserModel adminUserModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + deploymentsApi.useRestClient(restClient); + } + + @TestRail(section = { "rest-api", "workflow", "deployments" }, + executionType = ExecutionType.SANITY, description = "Verify admin user gets a non-network deployment using REST API and status code is OK (200)") + public void adminGetsNonNetworkDeploymentWithSuccess() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel); + deploymentsApi.getDeployment(deploymentsApi.getDeployments().getOneEntry()); + deploymentsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } +} From ca4e16f461cba22108cc71c24edbcfc8e5192776 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Mon, 17 Oct 2016 13:02:26 +0300 Subject: [PATCH 0427/1491] TAS-1531 getDeployment permission denied with non-admin user --- .../deployments/GetDeploymentSanityTests.java | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentSanityTests.java index 51017450c..cc69a8fa4 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentSanityTests.java @@ -26,21 +26,36 @@ public class GetDeploymentSanityTests extends RestWorkflowTest @Autowired private RestDeploymentsApi deploymentsApi; - private UserModel adminUserModel; + private UserModel adminUser; + private UserModel anotherUser; + private RestDeploymentModel deployment; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception { - adminUserModel = dataUser.getAdminUser(); + adminUser = dataUser.getAdminUser(); + anotherUser = dataUser.createRandomTestUser(); + deploymentsApi.useRestClient(restClient); + restClient.authenticateUser(adminUser); + deployment = deploymentsApi.getDeployments().getOneEntry(); } @TestRail(section = { "rest-api", "workflow", "deployments" }, executionType = ExecutionType.SANITY, description = "Verify admin user gets a non-network deployment using REST API and status code is OK (200)") public void adminGetsNonNetworkDeploymentWithSuccess() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(adminUserModel); - deploymentsApi.getDeployment(deploymentsApi.getDeployments().getOneEntry()); + restClient.authenticateUser(adminUser); + deploymentsApi.getDeployment(deployment); deploymentsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + @TestRail(section = { "rest-api", "workflow", "deployments" }, + executionType = ExecutionType.SANITY, description = "Verify non admin user is forbidden to get a non-network deployment using REST API (403)") + public void nonAdminIsForbiddenToGetNonNetworkDeployment() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(anotherUser); + deploymentsApi.getDeployment(deployment); + deploymentsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + } } From 0fd961c37bfb2cc6cecd32bc1c822fb450edab13 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Mon, 17 Oct 2016 16:59:10 +0300 Subject: [PATCH 0428/1491] Added new bug id --- .../org/alfresco/rest/workflow/tasks/GetTasksSanityTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksSanityTests.java index ddaa147ca..8b9d63c3f 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksSanityTests.java @@ -57,7 +57,7 @@ public class GetTasksSanityTests extends RestWorkflowTest tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @Bug(id = "") + @Bug(id = "MNT-16967") @TestRail(section = { "rest-api", "workflow", "tasks" }, executionType = ExecutionType.SANITY, description = "Verify candidate user gets its existing tasks and no other user claimed the task with Rest API and response is successfull (200)") public void candidateUserGetsItsTasks() throws Exception { From 71bd12c9f9b554b821d66e147ae6473d6bb19159 Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Mon, 17 Oct 2016 17:10:38 +0300 Subject: [PATCH 0429/1491] AddProcessItem (post /processes/{processId}/items) call --- .../processes/AddProcessItemSanityTests.java | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemSanityTests.java new file mode 100644 index 000000000..77b8228ec --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemSanityTests.java @@ -0,0 +1,79 @@ +package org.alfresco.rest.workflow.processes; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestWorkflowTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestProcessItemModel; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.requests.RestProcessesApi; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * @author iulia.cojocea + */ +@Test(groups = { "rest-api", "processes", "sanity" }) +public class AddProcessItemSanityTests extends RestWorkflowTest +{ + @Autowired + private DataUser dataUser; + + @Autowired + private RestProcessesApi processesApi; + + private FileModel document, document2, document3; + private SiteModel siteModel; + private UserModel userWhoStartsTask, assignee; + private RestProcessModel processModel; + private UserModel adminUser; + + private RestProcessItemModel processItem; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userWhoStartsTask = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); + processesApi.useRestClient(restClient); + } + + @TestRail(section = {"rest-api", "processes" }, executionType = ExecutionType.SANITY, + description = "Create non-existing process item") + public void addProcessItem() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUser); + document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + processModel = processesApi.getProcesses().getOneEntry(); + processItem = processesApi.addProcessItem(processModel, document2); + processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + processesApi.getProcessesItems(processModel).assertProcessItemExists(processItem); + } + + @Bug(id= "MNT-16966") + @TestRail(section = {"rest-api", "processes" }, executionType = ExecutionType.SANITY, + description = "Add process item that already exists") + public void addProcessItemThatAlreadyExists() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUser); + document3 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + processModel = processesApi.getProcesses().getOneEntry(); + processItem = processesApi.addProcessItem(processModel, document3); + processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + processesApi.getProcessesItems(processModel).assertProcessItemExists(processItem); + processItem = processesApi.addProcessItem(processModel, document3); + processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.BAD_REQUEST); + } +} From 6d0c6c72aee4f32850fbead3af5a900913be8fb6 Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Mon, 17 Oct 2016 10:21:05 +0300 Subject: [PATCH 0430/1491] TAS-1506, Valid request to create non-existing variable --- .../UpdateProcessVariableSanityTests.java | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/processes/UpdateProcessVariableSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/UpdateProcessVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/UpdateProcessVariableSanityTests.java new file mode 100644 index 000000000..4815f9a61 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/UpdateProcessVariableSanityTests.java @@ -0,0 +1,61 @@ +package org.alfresco.rest.workflow.processes; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestWorkflowTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestProcessVariableModel; +import org.alfresco.rest.requests.RestProcessesApi; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * @author iulia.cojocea + */ +@Test(groups = { "rest-api", "processes", "sanity" }) +public class UpdateProcessVariableSanityTests extends RestWorkflowTest +{ + @Autowired + private DataUser dataUser; + + @Autowired + private RestProcessesApi processesApi; + + private FileModel document; + private SiteModel siteModel; + private UserModel userWhoStartsTask, assignee; + private RestProcessModel processModel; + private UserModel adminUser; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userWhoStartsTask = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); + processesApi.useRestClient(restClient); + } + + @TestRail(section = {"rest-api", "processes" }, executionType = ExecutionType.SANITY, + description = "Create non-existing variable using put call") + public void addProcessVariable() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUser); + RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = processesApi.getProcesses().getOneEntry(); + processesApi.updateProcessVariable(processModel, variableModel); + processesApi.getProcessesVariables(processModel).assertProcessVariableExists(variableModel); + processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } +} From 17817228ffe6ffea54f9f6c3218b6784ae8fc7e8 Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Mon, 17 Oct 2016 17:26:01 +0300 Subject: [PATCH 0431/1491] TAS-1507, Valid request to update existing variable, 201 --- .../processes/UpdateProcessVariableSanityTests.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/UpdateProcessVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/UpdateProcessVariableSanityTests.java index 4815f9a61..e869bf70d 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/UpdateProcessVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/UpdateProcessVariableSanityTests.java @@ -58,4 +58,17 @@ public class UpdateProcessVariableSanityTests extends RestWorkflowTest processesApi.getProcessesVariables(processModel).assertProcessVariableExists(variableModel); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + @TestRail(section = {"rest-api", "processes" }, executionType = ExecutionType.SANITY, + description = "Update existing variable using put call") + public void updateProcessVariable() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUser); + RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = processesApi.getProcesses().getOneEntry(); + processesApi.addProcessVariable(processModel, variableModel); + variableModel.setValue("newValue"); + processesApi.updateProcessVariable(processModel, variableModel).assertProcessVariableHasValue("newValue"); + processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } } From eebf006984e8984e3a1eae4301fd40ccdbaa6d15 Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Mon, 17 Oct 2016 17:26:39 +0300 Subject: [PATCH 0432/1491] TAS-1508, Provide invalid processId --- .../processes/UpdateProcessVariableSanityTests.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/UpdateProcessVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/UpdateProcessVariableSanityTests.java index e869bf70d..e080e73a1 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/UpdateProcessVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/UpdateProcessVariableSanityTests.java @@ -71,4 +71,16 @@ public class UpdateProcessVariableSanityTests extends RestWorkflowTest processesApi.updateProcessVariable(processModel, variableModel).assertProcessVariableHasValue("newValue"); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + @TestRail(section = {"rest-api", "processes" }, executionType = ExecutionType.SANITY, + description = "Try to add process variable using an invalid processId") + public void addProcessVariableUsingInvalidProcessId() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUser); + RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = processesApi.getProcesses().getOneEntry(); + processModel.onModel().setId("abc"); + processesApi.updateProcessVariable(processModel, variableModel); + processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); + } } From 0248eb04bc522724191ce8ec97390c2fb97b4b29 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Mon, 17 Oct 2016 18:37:43 +0300 Subject: [PATCH 0433/1491] TAS-1520 removeDeployment with admin user --- .../DeleteDeploymentSanityTests.java | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java new file mode 100644 index 000000000..b0d6d8a9d --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java @@ -0,0 +1,50 @@ +package org.alfresco.rest.workflow.deployments; + +import org.alfresco.rest.RestWorkflowTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestDeploymentModel; +import org.alfresco.rest.requests.RestDeploymentsApi; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Tests for REST API call DELETE "/deployments/{deploymentId}" + * Class has priority 100 in order to be executed last in the list of tests classes + * + * @author Cristina Axinte + * + */ +@Test(groups = { "rest-api", "workflow", "deployments", "sanity" }, priority = 100) +public class DeleteDeploymentSanityTests extends RestWorkflowTest +{ + @Autowired + private RestDeploymentsApi deploymentsApi; + + private UserModel adminUser; + private RestDeploymentModel deployment; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + deploymentsApi.useRestClient(restClient); + } + + @Test(groups ={"extension-points"}) + @TestRail(section = { "rest-api", "workflow", "deployments" }, + executionType = ExecutionType.SANITY, description = "Verify admin user deletes a specific deployment using REST API and status code is successful (204)") + public void adminDeletesDeploymentWithSuccess() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUser); + // The deployment with name "customWorkflowExtentionForRest.bpmn" is created by Workflow Extention Point + deployment = deploymentsApi.getDeployments().getDeploymentWithName("customWorkflowExtentionForRest.bpmn"); + + deploymentsApi.deleteDeployment(deployment); + deploymentsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); + } +} From 871b8299f1801b8ba034028f90fbdb3ce836058f Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Mon, 17 Oct 2016 18:53:32 +0300 Subject: [PATCH 0434/1491] remove duplicate method --- .../java/org/alfresco/rest/demo/RestDemoTests.java | 4 ++-- .../org/alfresco/rest/demo/SampleSitesTests.java | 2 +- .../rest/people/GetFavoriteSitesSanityTests.java | 2 +- .../rest/people/GetPeopleActivitiesSanityTests.java | 10 +++++----- .../rest/sites/GetSiteContainerSanityTests.java | 12 ++++++------ .../deployments/GetDeploymentsSanityTests.java | 4 ++-- .../GetProcessDefinitionImageSanityTests.java | 2 +- .../GetProcessDefinitionSanityTests.java | 3 +-- .../GetProcessDefinitionsSanityTests.java | 4 ++-- .../processes/AddProcessVariableSanityTests.java | 8 ++++---- .../processes/GetProcessItemsSanityTests.java | 6 +++--- .../processes/GetProcessTasksSanityTests.java | 2 -- .../processes/GetProcessesVariablesSanityTests.java | 4 ++-- .../processes/RemoveProcessVariableSanityTests.java | 6 +++--- 14 files changed, 33 insertions(+), 36 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/demo/RestDemoTests.java b/e2e-test/java/org/alfresco/rest/demo/RestDemoTests.java index f3bdcf729..b6dea37af 100644 --- a/e2e-test/java/org/alfresco/rest/demo/RestDemoTests.java +++ b/e2e-test/java/org/alfresco/rest/demo/RestDemoTests.java @@ -78,14 +78,14 @@ public class RestDemoTests extends RestTest // add new comment RestCommentModel commentEntry = commentsAPI.addComment(fileModel, "This is a new comment"); commentsAPI.getNodeComments(fileModel) - .assertResponseIsNotEmpty() + .assertEntriesListIsNotEmpty() .assertCommentWithIdExists(commentEntry); // update comment commentEntry = commentsAPI.updateComment(fileModel, commentEntry, "This is the updated comment with Collaborator user"); commentsAPI.getNodeComments(fileModel) - .assertResponseIsNotEmpty() + .assertEntriesListIsNotEmpty() .assertCommentWithIdExists(commentEntry) .assertCommentWithContentExists("This is the updated comment"); } diff --git a/e2e-test/java/org/alfresco/rest/demo/SampleSitesTests.java b/e2e-test/java/org/alfresco/rest/demo/SampleSitesTests.java index cc8774666..7f7ee6de8 100644 --- a/e2e-test/java/org/alfresco/rest/demo/SampleSitesTests.java +++ b/e2e-test/java/org/alfresco/rest/demo/SampleSitesTests.java @@ -54,7 +54,7 @@ public class SampleSitesTests extends RestTest public void adminShouldAccessSites() throws JsonToModelConversionException, Exception { siteAPI.getSites() - .assertResponseIsNotEmpty(); + .assertEntriesListIsNotEmpty(); } @TestRail(section={"demo", "sample-section"}, executionType= ExecutionType.SANITY, diff --git a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java index 4c0960a9e..7e2716413 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java @@ -95,7 +95,7 @@ public class GetFavoriteSitesSanityTests extends RestTest dataSite.usingUser(anotherUser).usingSite(siteModel).addSiteToFavorites(); restClient.authenticateUser(adminUser); - peopleApi.getFavoriteSites(anotherUser).assertResponseIsNotEmpty(); + peopleApi.getFavoriteSites(anotherUser).assertEntriesListIsNotEmpty(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java index 155b3acf0..fd6a0c34c 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java @@ -48,7 +48,7 @@ public class GetPeopleActivitiesSanityTests extends RestTest dataContent.usingUser(managerUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); restClient.authenticateUser(managerUser); - peopleApi.getPersonActivities(managerUser).assertResponseIsNotEmpty(); + peopleApi.getPersonActivities(managerUser).assertEntriesListIsNotEmpty(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -60,7 +60,7 @@ public class GetPeopleActivitiesSanityTests extends RestTest dataContent.usingUser(collaboratorUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); restClient.authenticateUser(collaboratorUser); - peopleApi.getPersonActivities(collaboratorUser).assertResponseIsNotEmpty(); + peopleApi.getPersonActivities(collaboratorUser).assertEntriesListIsNotEmpty(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -72,7 +72,7 @@ public class GetPeopleActivitiesSanityTests extends RestTest dataContent.usingUser(contributorUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); restClient.authenticateUser(contributorUser); - peopleApi.getPersonActivities(contributorUser).assertResponseIsNotEmpty(); + peopleApi.getPersonActivities(contributorUser).assertEntriesListIsNotEmpty(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -83,7 +83,7 @@ public class GetPeopleActivitiesSanityTests extends RestTest dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel, UserRole.SiteConsumer); restClient.authenticateUser(consumerUser); - peopleApi.getPersonActivities(consumerUser).assertResponseIsNotEmpty(); + peopleApi.getPersonActivities(consumerUser).assertEntriesListIsNotEmpty(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -91,7 +91,7 @@ public class GetPeopleActivitiesSanityTests extends RestTest public void adminUserShouldGetPeopleActivitiesList() throws Exception { restClient.authenticateUser(dataUser.getAdminUser()); - peopleApi.getPersonActivities(userModel).assertResponseIsNotEmpty(); + peopleApi.getPersonActivities(userModel).assertEntriesListIsNotEmpty(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java index 871be5d45..8ddf9c3b3 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java @@ -45,7 +45,7 @@ public class GetSiteContainerSanityTests extends RestTest public void getSiteContainerWithManagerRole() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - siteContainerModel = siteAPI.getSiteContainers(siteModel).getOneEntry(); + siteContainerModel = siteAPI.getSiteContainers(siteModel).getOneRandomEntry(); siteAPI.getSiteContainer(siteModel, siteContainerModel); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -55,7 +55,7 @@ public class GetSiteContainerSanityTests extends RestTest public void getSiteContainerWithCollaboratorRole() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - siteContainerModel = siteAPI.getSiteContainers(siteModel).getOneEntry(); + siteContainerModel = siteAPI.getSiteContainers(siteModel).getOneRandomEntry(); siteAPI.getSiteContainer(siteModel, siteContainerModel); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -65,7 +65,7 @@ public class GetSiteContainerSanityTests extends RestTest public void getSiteContainerWithContributorRole() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - siteContainerModel = siteAPI.getSiteContainers(siteModel).getOneEntry(); + siteContainerModel = siteAPI.getSiteContainers(siteModel).getOneRandomEntry(); siteAPI.getSiteContainer(siteModel, siteContainerModel); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -75,7 +75,7 @@ public class GetSiteContainerSanityTests extends RestTest public void getSiteContainerWithConsumerRole() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - siteContainerModel = siteAPI.getSiteContainers(siteModel).getOneEntry(); + siteContainerModel = siteAPI.getSiteContainers(siteModel).getOneRandomEntry(); siteAPI.getSiteContainer(siteModel, siteContainerModel); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -85,7 +85,7 @@ public class GetSiteContainerSanityTests extends RestTest public void getSiteContainerWithAdminUser() throws Exception { restClient.authenticateUser(adminUserModel); - siteContainerModel = siteAPI.getSiteContainers(siteModel).getOneEntry(); + siteContainerModel = siteAPI.getSiteContainers(siteModel).getOneRandomEntry(); siteAPI.getSiteContainer(siteModel, siteContainerModel); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -101,7 +101,7 @@ public class GetSiteContainerSanityTests extends RestTest userModel.setPassword("user wrong password"); dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); restClient.authenticateUser(userModel); - siteContainerModel = siteAPI.getSiteContainers(siteModel).getOneEntry(); + siteContainerModel = siteAPI.getSiteContainers(siteModel).getOneRandomEntry(); siteAPI.getSiteContainer(siteModel, siteContainerModel); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsSanityTests.java index dfc293bc7..1683e2c2f 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsSanityTests.java @@ -43,7 +43,7 @@ public class GetDeploymentsSanityTests extends RestWorkflowTest public void getNonNetworkDeploymentsWithAdmin() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); - deploymentsApi.getDeployments().assertResponseIsNotEmpty(); + deploymentsApi.getDeployments().assertEntriesListIsNotEmpty(); deploymentsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -57,7 +57,7 @@ public class GetDeploymentsSanityTests extends RestWorkflowTest tenantApi.useRestClient(restClient); tenantApi.createTenant(adminTenantUser); restClient.authenticateUser(adminTenantUser); - deploymentsApi.getDeployments().assertResponseIsNotEmpty(); + deploymentsApi.getDeployments().assertEntriesListIsNotEmpty(); deploymentsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java index 7017aab42..0765f427d 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java @@ -32,7 +32,7 @@ public class GetProcessDefinitionImageSanityTests extends RestWorkflowTest testUser = dataUser.createRandomTestUser(); processDefinitionsApi.useRestClient(restClient); restClient.authenticateUser(dataUser.getAdminUser()); - randomProcessDefinition = processDefinitionsApi.getProcessDefinitions().getOneEntry(); + randomProcessDefinition = processDefinitionsApi.getProcessDefinitions().getOneRandomEntry(); } @TestRail(section = { "rest-api", "process-definitions" }, diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java index 179e55396..e6d624253 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java @@ -2,7 +2,6 @@ package org.alfresco.rest.workflow.processDefinitions; import org.alfresco.rest.RestWorkflowTest; import org.alfresco.rest.model.RestProcessDefinitionModel; -import org.alfresco.rest.model.RestProcessDefinitionModelsCollection; import org.alfresco.rest.requests.RestProcessDefinitionsApi; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.model.UserModel; @@ -33,7 +32,7 @@ public class GetProcessDefinitionSanityTests extends RestWorkflowTest testUser = dataUser.createRandomTestUser(); processDefinitionsApi.useRestClient(restClient); restClient.authenticateUser(dataUser.getAdminUser()); - randomProcessDefinition = processDefinitionsApi.getProcessDefinitions().getOneEntry(); + randomProcessDefinition = processDefinitionsApi.getProcessDefinitions().getOneRandomEntry(); } @TestRail(section = { "rest-api", "process-definitions" }, diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java index 7a03eab1e..b83eec472 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java @@ -42,7 +42,7 @@ public class GetProcessDefinitionsSanityTests extends RestWorkflowTest public void nonNetworkAdminGetsProcessDefinitions() throws Exception { restClient.authenticateUser(adminUserModel); - processDefinitionsApi.getProcessDefinitions().assertResponseIsNotEmpty(); + processDefinitionsApi.getProcessDefinitions().assertEntriesListIsNotEmpty(); processDefinitionsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -56,7 +56,7 @@ public class GetProcessDefinitionsSanityTests extends RestWorkflowTest tenantApi.useRestClient(restClient); tenantApi.createTenant(adminTenantUser); restClient.authenticateUser(adminTenantUser); - processDefinitionsApi.getProcessDefinitions().assertResponseIsNotEmpty(); + processDefinitionsApi.getProcessDefinitions().assertEntriesListIsNotEmpty(); processDefinitionsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java index 47b28505c..13eb59b47 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java @@ -58,7 +58,7 @@ public class AddProcessVariableSanityTests extends RestWorkflowTest { restClient.authenticateUser(userWhoStartsTask); RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = processesApi.getProcesses().getOneEntry(); + processModel = processesApi.getProcesses().getOneRandomEntry(); processesApi.addProcessVariable(processModel, variableModel); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } @@ -69,7 +69,7 @@ public class AddProcessVariableSanityTests extends RestWorkflowTest { restClient.authenticateUser(userWhoStartsTask); RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = processesApi.getProcesses().getOneEntry(); + processModel = processesApi.getProcesses().getOneRandomEntry(); processesApi.addProcessVariable(processModel, variableModel); variableModel.setValue(RandomData.getRandomName("newValue")); processesApi.addProcessVariable(processModel, variableModel); @@ -95,7 +95,7 @@ public class AddProcessVariableSanityTests extends RestWorkflowTest dataWorkflow.usingUser(tenantUser).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(tenantUserAssignee); RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = processesApi.getProcesses().getOneEntry(); + processModel = processesApi.getProcesses().getOneRandomEntry(); processesApi.addProcessVariable(processModel, variableModel); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } @@ -106,7 +106,7 @@ public class AddProcessVariableSanityTests extends RestWorkflowTest { restClient.authenticateUser(adminUser); RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("incorrect type"); - processModel = processesApi.getProcesses().getOneEntry(); + processModel = processesApi.getProcesses().getOneRandomEntry(); processesApi.addProcessVariable(processModel, variableModel); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.BAD_REQUEST); } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsSanityTests.java index 4808c85c4..9ae18c912 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsSanityTests.java @@ -56,7 +56,7 @@ public class GetProcessItemsSanityTests extends RestWorkflowTest public void getProcessItemsUsingTheUserWhoStartedProcess() throws JsonToModelConversionException, Exception { restClient.authenticateUser(userWhoStartsTask); - processModel = processesApi.getProcesses().getOneEntry(); + processModel = processesApi.getProcesses().getOneRandomEntry(); processesApi.getProcessesItems(processModel); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -66,7 +66,7 @@ public class GetProcessItemsSanityTests extends RestWorkflowTest public void getProcessItemsUsingUserInvolvedInProcess() throws JsonToModelConversionException, Exception { restClient.authenticateUser(assignee); - processModel = processesApi.getProcesses().getOneEntry(); + processModel = processesApi.getProcesses().getOneRandomEntry(); processesApi.getProcessesItems(processModel); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -89,7 +89,7 @@ public class GetProcessItemsSanityTests extends RestWorkflowTest siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); dataWorkflow.usingUser(tenantUser).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(tenantUserAssignee); - processModel = processesApi.getProcesses().getOneEntry(); + processModel = processesApi.getProcesses().getOneRandomEntry(); processesApi.getProcessesItems(processModel); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksSanityTests.java index c696dd92a..bb00f9ddf 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksSanityTests.java @@ -5,10 +5,8 @@ import org.alfresco.rest.RestWorkflowTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.requests.RestProcessesApi; import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.GroupModel; import org.alfresco.utility.model.ProcessModel; import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TaskModel; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesVariablesSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesVariablesSanityTests.java index 26f585226..5861e1734 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesVariablesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesVariablesSanityTests.java @@ -49,7 +49,7 @@ public class GetProcessesVariablesSanityTests extends RestWorkflowTest public void getProcessVariablesUsingTheUserWhoStartedProcess() throws JsonToModelConversionException, Exception { restClient.authenticateUser(userWhoStartsTask); - processModel = processesApi.getProcesses().getOneEntry(); + processModel = processesApi.getProcesses().getOneRandomEntry(); processesApi.getProcessesVariables(processModel); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -59,7 +59,7 @@ public class GetProcessesVariablesSanityTests extends RestWorkflowTest public void getProcessVariablesUsingUserInvolvedInProcess() throws JsonToModelConversionException, Exception { restClient.authenticateUser(assignee); - processModel = processesApi.getProcesses().getOneEntry(); + processModel = processesApi.getProcesses().getOneRandomEntry(); processesApi.getProcessesVariables(processModel); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessVariableSanityTests.java index 019e17adc..d896f04be 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessVariableSanityTests.java @@ -53,7 +53,7 @@ public class RemoveProcessVariableSanityTests extends RestWorkflowTest { restClient.authenticateUser(adminUser); RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = processesApi.getProcesses().getOneEntry(); + processModel = processesApi.getProcesses().getOneRandomEntry(); processesApi.addProcessVariable(processModel, variableModel); processesApi.deleteProcessVariable(processModel, variableModel); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); @@ -65,9 +65,9 @@ public class RemoveProcessVariableSanityTests extends RestWorkflowTest { restClient.authenticateUser(adminUser); RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = processesApi.getProcesses().getOneEntry(); + processModel = processesApi.getProcesses().getOneRandomEntry(); processesApi.addProcessVariable(processModel, variableModel); - processModel = processesApi.getProcesses().getOneEntry(); + processModel = processesApi.getProcesses().getOneRandomEntry(); processesApi.deleteProcessVariable(processModel, variableModel); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); } From 292987c1f0594c9f199559ac0d87192d727e0d48 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Mon, 17 Oct 2016 19:07:26 +0300 Subject: [PATCH 0435/1491] TAS-1521 removeDeployment using inexistent deploymentId --- .../deployments/DeleteDeploymentSanityTests.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java index b0d6d8a9d..35bee13bd 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java @@ -47,4 +47,16 @@ public class DeleteDeploymentSanityTests extends RestWorkflowTest deploymentsApi.deleteDeployment(deployment); deploymentsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); } + + @TestRail(section = { "rest-api", "workflow", "deployments" }, + executionType = ExecutionType.SANITY, description = "Verify admin user cannot delete an inexistent deployment using REST API and status code is successful (204)") + public void adminCannotDeleteInexistentDeployment() throws JsonToModelConversionException, Exception + { + deployment = new RestDeploymentModel(); + deployment.setId(String.valueOf(1000)); + + restClient.authenticateUser(adminUser); + deploymentsApi.deleteDeployment(deployment); + deploymentsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); + } } From 105d737959e6735f03db41b8fa9864b7bf7c571e Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Mon, 17 Oct 2016 22:14:07 +0300 Subject: [PATCH 0436/1491] add constant group name --- .../rest/comments/AddCommentSanityTests.java | 27 ++++---- .../rest/comments/AddCommentsSanityTests.java | 27 ++++---- .../comments/DeleteCommentsSanityTests.java | 27 ++++---- .../rest/comments/GetCommentsSanityTests.java | 19 +++--- .../comments/UpdateCommentsSanityTests.java | 31 ++++----- .../favorites/DeleteFavoritesSanityTests.java | 36 +++++----- .../favorites/GetFavoriteSanityTests.java | 25 +++---- .../favorites/GetFavoritesSanityTests.java | 25 +++---- .../favorites/PostFavoritesSanityTests.java | 15 +++-- .../RestGetNetworkForPersonSanityTests.java | 27 ++++---- .../rest/networks/RestGetNetworkTest.java | 67 ++++++++++--------- .../RestGetNetworksForPersonSanityTests.java | 27 ++++---- .../people/AddFavoriteSiteSanityTests.java | 15 +++-- .../AddSiteMembershipRequestSanityTests.java | 15 +++-- .../people/DeleteFavoriteSiteSanityTests.java | 17 ++--- .../people/DeleteSiteMemberSanityTests.java | 15 +++-- ...eleteSiteMembershipRequestSanityTests.java | 19 +++--- .../people/GetFavoriteSiteSanityTests.java | 17 ++--- .../people/GetFavoriteSitesSanityTests.java | 17 ++--- .../GetPeopleActivitiesSanityTests.java | 15 +++-- .../GetPeoplePreferenceSanityTests.java | 15 +++-- .../GetPeoplePreferencesSanityTests.java | 15 +++-- .../rest/people/GetPeopleSanityTests.java | 17 ++--- .../GetSiteMembershipRequestSanityTests.java | 15 +++-- .../GetSiteMembershipRequestsSanityTests.java | 17 ++--- .../people/GetSiteMembershipSanityTests.java | 25 +++---- ...SitesMembershipInformationSanityTests.java | 15 +++-- ...pdateSiteMembershipRequestSanityTests.java | 17 ++--- .../rest/ratings/AddRatingSanityTests.java | 51 +++++++------- .../rest/ratings/DeleteRatingSanityTests.java | 17 ++--- .../rest/ratings/GetRatingSanityTests.java | 15 +++-- .../rest/sites/AddSiteMemberSanityTests.java | 15 +++-- .../sites/GetSiteContainerSanityTests.java | 15 +++-- .../sites/GetSiteContainersSanityTests.java | 15 +++-- .../rest/sites/GetSiteMemberSanityTests.java | 15 +++-- .../rest/sites/GetSiteMembersSanityTests.java | 15 +++-- .../rest/sites/GetSiteSanityTests.java | 15 +++-- .../rest/sites/GetSitesSanityTests.java | 15 +++-- .../sites/RemoveSiteMemberSanityTests.java | 15 +++-- .../sites/UpdateSiteMemberSanityTests.java | 15 +++-- .../alfresco/rest/tags/AddTagSanityTests.java | 31 ++++----- .../rest/tags/AddTagsSanityTests.java | 31 ++++----- .../rest/tags/DeleteTagSanityTests.java | 29 ++++---- .../rest/tags/GetNodeTagsSanityTests.java | 17 ++--- .../alfresco/rest/tags/GetTagSanityTests.java | 15 +++-- .../rest/tags/GetTagsSanityTests.java | 15 +++-- .../rest/tags/UpdateTagSanityTests.java | 25 +++---- .../GetDeploymentsSanityTests.java | 11 ++- .../GetProcessDefinitionImageSanityTests.java | 63 +++++++++-------- .../GetProcessDefinitionSanityTests.java | 7 +- .../GetProcessDefinitionsSanityTests.java | 9 +-- .../AddProcessVariableSanityTests.java | 13 ++-- .../processes/DeleteProcessSanityTests.java | 9 +-- .../processes/GetProcessItemsSanityTests.java | 11 +-- .../processes/GetProcessTasksSanityTests.java | 9 +-- .../processes/GetProcessesSanityTests.java | 11 +-- .../GetProcessesVariablesSanityTests.java | 7 +- .../RemoveProcessVariableSanityTests.java | 7 +- .../workflow/tasks/GetTaskSanityTests.java | 15 +++-- .../workflow/tasks/GetTasksSanityTests.java | 11 +-- 60 files changed, 617 insertions(+), 566 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java index ec1483ff3..a7e0d9621 100644 --- a/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java @@ -9,6 +9,7 @@ import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; @@ -18,7 +19,7 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { "rest-api", "comments", "sanity" }) +@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) public class AddCommentSanityTests extends RestTest { @Autowired @@ -43,16 +44,16 @@ public class AddCommentSanityTests extends RestTest usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); } - @TestRail(section = { "rest-api", - "comments" }, executionType = ExecutionType.SANITY, description = "Verify admin user adds comments with Rest API and status code is 201") + @TestRail(section = { TestGroup.REST_API, + TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify admin user adds comments with Rest API and status code is 201") public void adminIsAbleToAddComment() throws JsonToModelConversionException, Exception { commentsAPI.addComment(document, "This is a new comment added by " + adminUserModel.getUsername()); commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } - @TestRail(section = { "rest-api", - "comments" }, executionType = ExecutionType.SANITY, description = "Verify Manager user adds comments with Rest API and status code is 201") + @TestRail(section = { TestGroup.REST_API, + TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Manager user adds comments with Rest API and status code is 201") public void managerIsAbleToAddComment() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); @@ -60,8 +61,8 @@ public class AddCommentSanityTests extends RestTest commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } - @TestRail(section = { "rest-api", - "comments" }, executionType = ExecutionType.SANITY, description = "Verify Contributor user adds comments with Rest API and status code is 201") + @TestRail(section = { TestGroup.REST_API, + TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Contributor user adds comments with Rest API and status code is 201") public void contributorIsAbleToAddComment() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); @@ -69,8 +70,8 @@ public class AddCommentSanityTests extends RestTest commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } - @TestRail(section = { "rest-api", - "comments" }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user adds comments with Rest API and status code is 201") + @TestRail(section = { TestGroup.REST_API, + TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user adds comments with Rest API and status code is 201") public void collaboratorIsAbleToAddComment() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); @@ -78,8 +79,8 @@ public class AddCommentSanityTests extends RestTest commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } - @TestRail(section = { "rest-api", - "comments" }, executionType = ExecutionType.SANITY, description = "Verify Consumer user adds comments with Rest API and status code is 201") + @TestRail(section = { TestGroup.REST_API, + TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Consumer user adds comments with Rest API and status code is 201") public void consumerIsAbleToAddComment() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); @@ -87,8 +88,8 @@ public class AddCommentSanityTests extends RestTest commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } - @TestRail(section = { "rest-api", - "comments" }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user gets status code 401 on post comments call") + @TestRail(section = { TestGroup.REST_API, + TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user gets status code 401 on post comments call") @Bug(id="MNT-16904") public void unauthenticatedUserIsNotAbleToAddComment() throws JsonToModelConversionException, Exception { diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java index 2ff5857fd..9ee678cd5 100644 --- a/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java @@ -9,6 +9,7 @@ import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.RandomData; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; @@ -22,7 +23,7 @@ import org.testng.annotations.Test; /** * Created by Claudia Agache on 10/10/2016. */ -@Test(groups = { "rest-api", "comments", "sanity" }) +@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) public class AddCommentsSanityTests extends RestTest { @Autowired RestCommentsApi commentsAPI; @@ -53,16 +54,16 @@ public class AddCommentsSanityTests extends RestTest comment2 = RandomData.getRandomName("comment2"); } - @TestRail(section = { "rest-api", - "comments" }, executionType = ExecutionType.SANITY, description = "Verify admin user adds multiple comments with Rest API and status code is 201") + @TestRail(section = { TestGroup.REST_API, + TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify admin user adds multiple comments with Rest API and status code is 201") public void adminIsAbleToAddComments() throws JsonToModelConversionException, Exception { commentsAPI.addComments(document, comment1, comment2); commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } - @TestRail(section = { "rest-api", - "comments" }, executionType = ExecutionType.SANITY, description = "Verify Manager user adds multiple comments with Rest API and status code is 201") + @TestRail(section = { TestGroup.REST_API, + TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Manager user adds multiple comments with Rest API and status code is 201") public void managerIsAbleToAddComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); @@ -70,8 +71,8 @@ public class AddCommentsSanityTests extends RestTest commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } - @TestRail(section = { "rest-api", - "comments" }, executionType = ExecutionType.SANITY, description = "Verify Contributor user adds multiple comments with Rest API and status code is 201") + @TestRail(section = { TestGroup.REST_API, + TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Contributor user adds multiple comments with Rest API and status code is 201") public void contributorIsAbleToAddComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); @@ -79,8 +80,8 @@ public class AddCommentsSanityTests extends RestTest commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } - @TestRail(section = { "rest-api", - "comments" }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user adds multiple comments with Rest API and status code is 201") + @TestRail(section = { TestGroup.REST_API, + TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user adds multiple comments with Rest API and status code is 201") public void collaboratorIsAbleToAddComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); @@ -88,8 +89,8 @@ public class AddCommentsSanityTests extends RestTest commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } - @TestRail(section = { "rest-api", - "comments" }, executionType = ExecutionType.SANITY, description = "Verify Consumer user adds multiple comments with Rest API and status code is 201") + @TestRail(section = { TestGroup.REST_API, + TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Consumer user adds multiple comments with Rest API and status code is 201") public void consumerIsAbleToAddComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); @@ -97,8 +98,8 @@ public class AddCommentsSanityTests extends RestTest commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } - @TestRail(section = { "rest-api", - "comments" }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user gets status code 401 on post multiple comments call") + @TestRail(section = { TestGroup.REST_API, + TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user gets status code 401 on post multiple comments call") @Bug(id="MNT-16904") public void unauthenticatedUserIsNotAbleToAddComments() throws JsonToModelConversionException, Exception { diff --git a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java index 2ab4ae8d5..96e4183db 100644 --- a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java @@ -10,6 +10,7 @@ import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; @@ -19,7 +20,7 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -@Test(groups = { "rest-api", "comments", "sanity" }) +@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) public class DeleteCommentsSanityTests extends RestTest { @@ -56,16 +57,16 @@ public class DeleteCommentsSanityTests extends RestTest comment = commentsAPI.addComment(document, "This is a new comment"); } - @TestRail(section = { "rest-api", - "comments" }, executionType = ExecutionType.SANITY, description = "Verify Admin user delete comments with Rest API and status code is 204") + @TestRail(section = { TestGroup.REST_API, + TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Admin user delete comments with Rest API and status code is 204") public void adminIsAbleToDeleteComments() throws JsonToModelConversionException, Exception { commentsAPI.deleteComment(document, comment); commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); } - @TestRail(section = { "rest-api", - "comments" }, executionType = ExecutionType.SANITY, description = "Verify Manager user delete comments created by admin user with Rest API and status code is 204") + @TestRail(section = { TestGroup.REST_API, + TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Manager user delete comments created by admin user with Rest API and status code is 204") public void managerIsAbleToDeleteComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); @@ -73,8 +74,8 @@ public class DeleteCommentsSanityTests extends RestTest commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); } - @TestRail(section = { "rest-api", - "comments" }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user can't delete comments created by admin user with Rest API and status code is 403") + @TestRail(section = { TestGroup.REST_API, + TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user can't delete comments created by admin user with Rest API and status code is 403") public void collaboratorIsNotAbleToDeleteComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); @@ -82,8 +83,8 @@ public class DeleteCommentsSanityTests extends RestTest commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } - @TestRail(section = { "rest-api", - "comments" }, executionType = ExecutionType.SANITY, description = "Verify Contributor user can't delete comments created by admin user with Rest API and status code is 403") + @TestRail(section = { TestGroup.REST_API, + TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Contributor user can't delete comments created by admin user with Rest API and status code is 403") public void contributorIsNotAbleToDeleteComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); @@ -91,8 +92,8 @@ public class DeleteCommentsSanityTests extends RestTest commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } - @TestRail(section = { "rest-api", - "comments" }, executionType = ExecutionType.SANITY, description = "Verify Consumer user can't delete comments created by admin user with Rest API and status code is 403") + @TestRail(section = { TestGroup.REST_API, + TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Consumer user can't delete comments created by admin user with Rest API and status code is 403") public void consumerIsNotAbleToDeleteComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); @@ -100,8 +101,8 @@ public class DeleteCommentsSanityTests extends RestTest commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } - @TestRail(section = { "rest-api", - "comments" }, executionType = ExecutionType.SANITY, description = "Verify Manager user gets status code 401 if authentication call fails") + @TestRail(section = { TestGroup.REST_API, + TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Manager user gets status code 401 if authentication call fails") public void managerIsNotAbleToDeleteCommentIfAuthenticationFails() throws JsonToModelConversionException, Exception { UserModel nonexistentModel = new UserModel("nonexistentUser", "nonexistentPassword"); diff --git a/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java index 365684cdb..36af7a435 100644 --- a/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java @@ -9,6 +9,7 @@ import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; @@ -18,7 +19,7 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { "rest-api", "comments", "sanity" }) +@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) public class GetCommentsSanityTests extends RestTest { @Autowired @@ -47,7 +48,7 @@ public class GetCommentsSanityTests extends RestTest usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); } - @TestRail(section={"rest-api", "comments"}, executionType= ExecutionType.SANITY, + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.SANITY, description= "Verify Admin user gets comments with Rest API and status code is 200") public void adminIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception { @@ -55,7 +56,7 @@ public class GetCommentsSanityTests extends RestTest commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section={"rest-api", "comments"}, executionType= ExecutionType.SANITY, + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.SANITY, description= "Verify Manager user gets comments created by admin user with Rest API and status code is 200") public void managerIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception { @@ -64,7 +65,7 @@ public class GetCommentsSanityTests extends RestTest commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section={"rest-api", "comments"}, executionType= ExecutionType.SANITY, + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.SANITY, description= "Verify Contributor user gets comments created by admin user with Rest API and status code is 200") public void contributorIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception { @@ -73,7 +74,7 @@ public class GetCommentsSanityTests extends RestTest commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section={"rest-api", "comments"}, executionType= ExecutionType.SANITY, + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.SANITY, description= "Verify Collaborator user gets comments created by admin user with Rest API and status code is 200") public void collaboratorIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception { @@ -82,7 +83,7 @@ public class GetCommentsSanityTests extends RestTest commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section={"rest-api", "comments"}, executionType= ExecutionType.SANITY, + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.SANITY, description= "Verify Consumer user gets comments created by admin user with Rest API and status code is 200") public void consumerIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception { @@ -91,7 +92,7 @@ public class GetCommentsSanityTests extends RestTest commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section={"rest-api", "comments"}, executionType= ExecutionType.SANITY, + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.SANITY, description= "Verify Manager user gets status code 401 if authentication call fails") @Bug(id="MNT-16904") public void managerIsNotAbleToRetrieveCommentIfAuthenticationFails() throws JsonToModelConversionException, Exception @@ -102,7 +103,7 @@ public class GetCommentsSanityTests extends RestTest commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } - @TestRail(section={"rest-api", "comments"}, executionType= ExecutionType.SANITY, + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.SANITY, description= "Verify Manager user gets comments created by another user and status code is 200") public void managerIsAbleToRetrieveCommentsCreatedByAnotherUser() throws JsonToModelConversionException, Exception { @@ -115,7 +116,7 @@ public class GetCommentsSanityTests extends RestTest commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section={"rest-api", "comments"}, executionType= ExecutionType.SANITY, + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.SANITY, description= "Verify admin user gets comments created by another user and status code is 200") public void adminIsAbleToRetrieveCommentsCreatedByAnotherUser() throws JsonToModelConversionException, Exception { diff --git a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java index 4d1b6355a..be47e11e2 100644 --- a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java @@ -11,6 +11,7 @@ import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; @@ -20,7 +21,7 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { "rest-api", "comments", "sanity" }) +@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) public class UpdateCommentsSanityTests extends RestTest { @Autowired @@ -48,16 +49,16 @@ public class UpdateCommentsSanityTests extends RestTest usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); } - @TestRail(section = { "rest-api", - "comments" }, executionType = ExecutionType.SANITY, description = "Verify Admin user updates comments and status code is 200") + @TestRail(section = { TestGroup.REST_API, + TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Admin user updates comments and status code is 200") public void adminIsAbleToUpdateComments() throws JsonToModelConversionException, Exception { commentsAPI.updateComment(document, commentModel, "This is the updated comment with admin user"); commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", - "comments" }, executionType = ExecutionType.SANITY, description = "Verify Manager user updates comments created by admin user and status code is 200") + @TestRail(section = { TestGroup.REST_API, + TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Manager user updates comments created by admin user and status code is 200") public void managerIsAbleToUpdateComment() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); @@ -65,8 +66,8 @@ public class UpdateCommentsSanityTests extends RestTest commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", - "comments" }, executionType = ExecutionType.SANITY, description = "Verify Contributor user can not update comments created by admin user and status code is 403") + @TestRail(section = { TestGroup.REST_API, + TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Contributor user can not update comments created by admin user and status code is 403") public void contributorIsNotAbleToUpdateComment() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); @@ -74,8 +75,8 @@ public class UpdateCommentsSanityTests extends RestTest commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } - @TestRail(section = { "rest-api", - "comments" }, executionType = ExecutionType.SANITY, description = "Verify Consumer user can not update comments created by admin user and status code is 403") + @TestRail(section = { TestGroup.REST_API, + TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Consumer user can not update comments created by admin user and status code is 403") public void consumerIsNotAbleToUpdateComment() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); @@ -83,8 +84,8 @@ public class UpdateCommentsSanityTests extends RestTest commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } - @TestRail(section = { "rest-api", - "comments" }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user can not update comment created by admin user and status code is 403") + @TestRail(section = { TestGroup.REST_API, + TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user can not update comment created by admin user and status code is 403") @Bug(id="REPO-1011") public void collaboratorIsNotAbleToUpdateComment() throws JsonToModelConversionException, Exception { @@ -94,8 +95,8 @@ public class UpdateCommentsSanityTests extends RestTest commentEntry.assertCommentContentIs("This is the updated comment with Collaborator user"); } - @TestRail(section = { "rest-api", - "comments" }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user gets status code 401 on update comment call") + @TestRail(section = { TestGroup.REST_API, + TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user gets status code 401 on update comment call") @Bug(id="MNT-16904") public void unauthenticatedUserIsNotAbleToUpdateComment() throws JsonToModelConversionException, Exception { @@ -105,7 +106,7 @@ public class UpdateCommentsSanityTests extends RestTest commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } - @TestRail(section = { "rest-api", "comments" }, executionType = ExecutionType.SANITY, description = "Verify update comment with inexistent nodeId returns status code 404") + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify update comment with inexistent nodeId returns status code 404") public void canNotUpdateCommentIfNodeIdIsNotSet() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); @@ -116,7 +117,7 @@ public class UpdateCommentsSanityTests extends RestTest commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); } - @TestRail(section = { "rest-api", "comments" }, executionType = ExecutionType.SANITY, description = "Verify if commentId is not set the status code is 404") + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify if commentId is not set the status code is 404") public void canNotUpdateCommentIfCommentIdIsNotSet() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); diff --git a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoritesSanityTests.java index 4630342b2..caf712229 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoritesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoritesSanityTests.java @@ -7,6 +7,7 @@ import org.alfresco.rest.requests.RestSitesApi; 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.report.Bug; import org.alfresco.utility.testrail.ExecutionType; @@ -16,7 +17,7 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { "rest-api", "favorites", "sanity" }) +@Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.COMMENTS }) public class DeleteFavoritesSanityTests extends RestTest { @Autowired @@ -44,8 +45,8 @@ public class DeleteFavoritesSanityTests extends RestTest UserRole.SiteContributor); } - @TestRail(section = { "rest-api", - "favorites" }, executionType = ExecutionType.SANITY, description = "Verify Admin user delets site from favorites with Rest API and status code is 204") + @TestRail(section = { TestGroup.REST_API, + TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Admin user delets site from favorites with Rest API and status code is 204") public void adminIsAbleToDeleteFavorites() throws JsonToModelConversionException, Exception { favoritesAPI.addSiteToFavorites(adminUserModel, siteModel); @@ -53,8 +54,8 @@ public class DeleteFavoritesSanityTests extends RestTest favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); } - @TestRail(section = { "rest-api", - "favorites" }, executionType = ExecutionType.SANITY, description = "Verify Manager user delets site from favorites with Rest API and status code is 204") + @TestRail(section = { TestGroup.REST_API, + TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Manager user delets site from favorites with Rest API and status code is 204") public void managerIsAbleToDeleteFavorites() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); @@ -63,8 +64,8 @@ public class DeleteFavoritesSanityTests extends RestTest favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); } - @TestRail(section = { "rest-api", - "favorites" }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user delets site from favorites with Rest API and status code is 204") + @TestRail(section = { TestGroup.REST_API, + TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user delets site from favorites with Rest API and status code is 204") public void collaboratorIsAbleToDeleteFavorites() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); @@ -73,8 +74,8 @@ public class DeleteFavoritesSanityTests extends RestTest favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); } - @TestRail(section = { "rest-api", - "favorites" }, executionType = ExecutionType.SANITY, description = "Verify Contributor user delets site from favorites with Rest API and status code is 204") + @TestRail(section = { TestGroup.REST_API, + TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Contributor user delets site from favorites with Rest API and status code is 204") public void contributorIsAbleToDeleteFavorites() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); @@ -83,8 +84,8 @@ public class DeleteFavoritesSanityTests extends RestTest favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); } - @TestRail(section = { "rest-api", - "favorites" }, executionType = ExecutionType.SANITY, description = "Verify Consumer user delets site from favorites with Rest API and status code is 204") + @TestRail(section = { TestGroup.REST_API, + TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Consumer user delets site from favorites with Rest API and status code is 204") public void consumerIsAbleToDeleteFavorites() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); @@ -93,8 +94,8 @@ public class DeleteFavoritesSanityTests extends RestTest favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); } - @TestRail(section = { "rest-api", - "favorites" }, executionType = ExecutionType.SANITY, description = "Verify user doesn't have permission to delete favorites of another user with Rest API and status code is 404") + @TestRail(section = { TestGroup.REST_API, + TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify user doesn't have permission to delete favorites of another user with Rest API and status code is 404") @Bug(id="MNT-16557") public void userIsNotAbleToDeleteFavoritesOfAnotherUser() throws JsonToModelConversionException, Exception { @@ -105,8 +106,7 @@ public class DeleteFavoritesSanityTests extends RestTest favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } - @TestRail(section = { "rest-api", - "favorites" }, executionType = ExecutionType.SANITY, description = "Verify user doesn't have permission to delete favorites of admin user with Rest API and status code is 404") + @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify user doesn't have permission to delete favorites of admin user with Rest API and status code is 404") @Bug(id="MNT-16557") public void userIsNotAbleToDeleteFavoritesOfAdminUser() throws JsonToModelConversionException, Exception { @@ -117,8 +117,7 @@ public class DeleteFavoritesSanityTests extends RestTest favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } - @TestRail(section = { "rest-api", - "favorites" }, executionType = ExecutionType.SANITY, description = "Verify admin user doesn't have permission to delete favorites of another user with Rest API and status code is 404") + @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify admin user doesn't have permission to delete favorites of another user with Rest API and status code is 404") @Bug(id="MNT-16557") public void adminIsNotAbleToDeleteFavoritesOfAnotherUser() throws JsonToModelConversionException, Exception { @@ -129,8 +128,7 @@ public class DeleteFavoritesSanityTests extends RestTest favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } - @TestRail(section = { "rest-api", - "favorites" }, executionType = ExecutionType.SANITY, description = "Verify user gets status code 401 if authentication call fails") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify user gets status code 401 if authentication call fails") @Bug(id = "MNT-16904") public void userIsNotAbleToDeleteFavoritesIfAuthenticationFails() throws JsonToModelConversionException, Exception { diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java index fac32e580..98a56704e 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java @@ -10,6 +10,7 @@ import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; @@ -19,7 +20,7 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { "rest-api", "favorites", "sanity" }) +@Test(groups = { TestGroup.REST_API, "favorites", TestGroup.COMMENTS }) public class GetFavoriteSanityTests extends RestTest { @Autowired @@ -51,7 +52,7 @@ public class GetFavoriteSanityTests extends RestTest UserRole.SiteContributor); } - @TestRail(section = { "rest-api", + @TestRail(section = { TestGroup.REST_API, "favorites" }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets favorite site with Rest API and status code is 200") public void adminIsAbleToRetrieveFavoritesSite() throws JsonToModelConversionException, Exception { @@ -60,7 +61,7 @@ public class GetFavoriteSanityTests extends RestTest favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", + @TestRail(section = { TestGroup.REST_API, "favorites" }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets favorite folder with Rest API and status code is 200") public void adminIsAbleToRetrieveFavoritesFolder() throws JsonToModelConversionException, Exception { @@ -69,7 +70,7 @@ public class GetFavoriteSanityTests extends RestTest favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", + @TestRail(section = { TestGroup.REST_API, "favorites" }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets favorite file with Rest API and status code is 200") public void adminIsAbleToRetrieveFavoritesFile() throws JsonToModelConversionException, Exception { @@ -78,7 +79,7 @@ public class GetFavoriteSanityTests extends RestTest favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", + @TestRail(section = { TestGroup.REST_API, "favorites" }, executionType = ExecutionType.SANITY, description = "Verify Manager user gets favorite site with Rest API and status code is 200") public void managerIsAbleToRetrieveFavorite() throws JsonToModelConversionException, Exception { @@ -88,7 +89,7 @@ public class GetFavoriteSanityTests extends RestTest favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", + @TestRail(section = { TestGroup.REST_API, "favorites" }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user gets favorite site with Rest API and status code is 200") public void collaboratorIsAbleToRetrieveFavorites() throws JsonToModelConversionException, Exception { @@ -98,7 +99,7 @@ public class GetFavoriteSanityTests extends RestTest favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", + @TestRail(section = { TestGroup.REST_API, "favorites" }, executionType = ExecutionType.SANITY, description = "Verify Contributor user gets favorite site with Rest API and status code is 200") public void contributorIsAbleToRetrieveFavorite() throws JsonToModelConversionException, Exception { @@ -108,7 +109,7 @@ public class GetFavoriteSanityTests extends RestTest favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", + @TestRail(section = { TestGroup.REST_API, "favorites" }, executionType = ExecutionType.SANITY, description = "Verify Consumer user gets favorite site with Rest API and status code is 200") public void consumerIsAbleToRetrieveFavorites() throws JsonToModelConversionException, Exception { @@ -118,7 +119,7 @@ public class GetFavoriteSanityTests extends RestTest favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", + @TestRail(section = { TestGroup.REST_API, "favorites" }, executionType = ExecutionType.SANITY, description = "Verify user doesn't get favorite site of another user with Rest API and status code is 404") public void userIsNotAbleToRetrieveFavoriteSiteOfAnotherUser() throws JsonToModelConversionException, Exception { @@ -127,7 +128,7 @@ public class GetFavoriteSanityTests extends RestTest favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); } - @TestRail(section = { "rest-api", + @TestRail(section = { TestGroup.REST_API, "favorites" }, executionType = ExecutionType.SANITY, description = "Verify user doesn't get favorite site of admin user with Rest API and status code is 404") public void userIsNotAbleToRetrieveFavoritesOfAdminUser() throws JsonToModelConversionException, Exception { @@ -136,7 +137,7 @@ public class GetFavoriteSanityTests extends RestTest favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); } - @TestRail(section = { "rest-api", + @TestRail(section = { TestGroup.REST_API, "favorites" }, executionType = ExecutionType.SANITY, description = "Verify admin user doesn't get favorite site of another user with Rest API and status code is 404") public void adminIsNotAbleToRetrieveFavoritesOfAnotherUser() throws JsonToModelConversionException, Exception { @@ -145,7 +146,7 @@ public class GetFavoriteSanityTests extends RestTest favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); } - @TestRail(section = { "rest-api", + @TestRail(section = { TestGroup.REST_API, "favorites" }, executionType = ExecutionType.SANITY, description = "Verify user gets status code 401 if authentication call fails") @Bug(id="MNT-16904") public void userIsNotAbleToRetrieveFavoritesIfAuthenticationFails() throws JsonToModelConversionException, Exception diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java index 9507f2644..a17a14471 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java @@ -10,6 +10,7 @@ import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; @@ -19,7 +20,7 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { "rest-api", "favorites", "sanity" }) +@Test(groups = { TestGroup.REST_API, "favorites", TestGroup.COMMENTS }) public class GetFavoritesSanityTests extends RestTest { @@ -59,7 +60,7 @@ public class GetFavoritesSanityTests extends RestTest UserRole.SiteContributor); } - @TestRail(section = { "rest-api", + @TestRail(section = { TestGroup.REST_API, "favorites" }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets favorites sites with Rest API and status code is 200") public void adminIsAbleToRetrieveFavoritesSites() throws JsonToModelConversionException, Exception { @@ -69,7 +70,7 @@ public class GetFavoritesSanityTests extends RestTest favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", + @TestRail(section = { TestGroup.REST_API, "favorites" }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets favorites folders with Rest API and status code is 200") public void adminIsAbleToRetrieveFavoritesFolders() throws JsonToModelConversionException, Exception { @@ -79,7 +80,7 @@ public class GetFavoritesSanityTests extends RestTest favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", + @TestRail(section = { TestGroup.REST_API, "favorites" }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets favorites files with Rest API and status code is 200") public void adminIsAbleToRetrieveFavoritesFiles() throws JsonToModelConversionException, Exception { @@ -89,7 +90,7 @@ public class GetFavoritesSanityTests extends RestTest favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", + @TestRail(section = { TestGroup.REST_API, "favorites" }, executionType = ExecutionType.SANITY, description = "Verify Manager user gets favorites with Rest API and status code is 200") public void managerIsAbleToRetrieveFavorites() throws JsonToModelConversionException, Exception { @@ -100,7 +101,7 @@ public class GetFavoritesSanityTests extends RestTest favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", + @TestRail(section = { TestGroup.REST_API, "favorites" }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user gets favorites with Rest API and status code is 200") public void collaboratorIsAbleToRetrieveFavorites() throws JsonToModelConversionException, Exception { @@ -111,7 +112,7 @@ public class GetFavoritesSanityTests extends RestTest favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", + @TestRail(section = { TestGroup.REST_API, "favorites" }, executionType = ExecutionType.SANITY, description = "Verify Contributor user gets favorites with Rest API and status code is 200") public void contributorIsAbleToRetrieveFavorites() throws JsonToModelConversionException, Exception { @@ -122,7 +123,7 @@ public class GetFavoritesSanityTests extends RestTest favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", + @TestRail(section = { TestGroup.REST_API, "favorites" }, executionType = ExecutionType.SANITY, description = "Verify Consumer user gets favorites with Rest API and status code is 200") public void consumerIsAbleToRetrieveFavorites() throws JsonToModelConversionException, Exception { @@ -133,7 +134,7 @@ public class GetFavoritesSanityTests extends RestTest favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", + @TestRail(section = { TestGroup.REST_API, "favorites" }, executionType = ExecutionType.SANITY, description = "Verify user doesn't have permission to get favorites of another user with Rest API and status code is 404") public void userIsNotAbleToRetrieveFavoritesOfAnotherUser() throws JsonToModelConversionException, Exception { @@ -142,7 +143,7 @@ public class GetFavoritesSanityTests extends RestTest favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); } - @TestRail(section = { "rest-api", + @TestRail(section = { TestGroup.REST_API, "favorites" }, executionType = ExecutionType.SANITY, description = "Verify user doesn't have permission to get favorites of admin user with Rest API and status code is 200") public void userIsNotAbleToRetrieveFavoritesOfAdminUser() throws JsonToModelConversionException, Exception { @@ -151,7 +152,7 @@ public class GetFavoritesSanityTests extends RestTest favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); } - @TestRail(section = { "rest-api", + @TestRail(section = { TestGroup.REST_API, "favorites" }, executionType = ExecutionType.SANITY, description = "Verify admin user doesn't have permission to get favorites of another user with Rest API and status code is 200") public void adminIsNotAbleToRetrieveFavoritesOfAnotherUser() throws JsonToModelConversionException, Exception { @@ -160,7 +161,7 @@ public class GetFavoritesSanityTests extends RestTest favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); } - @TestRail(section = { "rest-api", + @TestRail(section = { TestGroup.REST_API, "favorites" }, executionType = ExecutionType.SANITY, description = "Verify user gets status code 401 if authentication call fails") @Bug(id="MNT-16904") public void userIsNotAbleToRetrieveFavoritesIfAuthenticationFails() throws JsonToModelConversionException, Exception diff --git a/e2e-test/java/org/alfresco/rest/favorites/PostFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/PostFavoritesSanityTests.java index 09d3c126c..0e0b69bd5 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/PostFavoritesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/PostFavoritesSanityTests.java @@ -8,6 +8,7 @@ import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; 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.report.Bug; import org.alfresco.utility.testrail.ExecutionType; @@ -17,7 +18,7 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { "rest-api", "favorites", "sanity" }) +@Test(groups = { TestGroup.REST_API, "favorites", TestGroup.COMMENTS }) public class PostFavoritesSanityTests extends RestTest { @Autowired @@ -47,7 +48,7 @@ public class PostFavoritesSanityTests extends RestTest UserRole.SiteContributor); } - @TestRail(section = { "rest-api", + @TestRail(section = { TestGroup.REST_API, "favorites" }, executionType = ExecutionType.SANITY, description = "Verify Admin user add site to favorites with Rest API and status code is 201") public void adminIsAbleToAddToFavorites() throws Exception { @@ -55,7 +56,7 @@ public class PostFavoritesSanityTests extends RestTest favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } - @TestRail(section = { "rest-api", + @TestRail(section = { TestGroup.REST_API, "favorites" }, executionType = ExecutionType.SANITY, description = "Verify Manager user add site to favorites with Rest API and status code is 201") public void managerIsAbleToAddToFavorites() throws Exception { @@ -64,7 +65,7 @@ public class PostFavoritesSanityTests extends RestTest favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } - @TestRail(section = { "rest-api", + @TestRail(section = { TestGroup.REST_API, "favorites" }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user add site to favorites with Rest API and status code is 201") public void collaboratorIsAbleToAddToFavorites() throws Exception { @@ -73,7 +74,7 @@ public class PostFavoritesSanityTests extends RestTest favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } - @TestRail(section = { "rest-api", + @TestRail(section = { TestGroup.REST_API, "favorites" }, executionType = ExecutionType.SANITY, description = "Verify Contributor user add site to favorites with Rest API and status code is 201") public void contributorIsAbleToAddToFavorites() throws JsonToModelConversionException, Exception { @@ -82,7 +83,7 @@ public class PostFavoritesSanityTests extends RestTest favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } - @TestRail(section = { "rest-api", + @TestRail(section = { TestGroup.REST_API, "favorites" }, executionType = ExecutionType.SANITY, description = "Verify Consumer user add site to favorites with Rest API and status code is 201") public void consumerIsAbleToAddToFavorites() throws Exception { @@ -91,7 +92,7 @@ public class PostFavoritesSanityTests extends RestTest favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } - @TestRail(section = { "rest-api", + @TestRail(section = { TestGroup.REST_API, "favorites" }, executionType = ExecutionType.SANITY, description = "Verify Manager user gets status code 401 if authentication call fails") @Bug(id="MNT-16904") public void managerIsNotAbleToAddCommentIfAuthenticationFails() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java index 7c0fb2ad8..8de10da4c 100644 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java @@ -3,6 +3,7 @@ package org.alfresco.rest.networks; import org.alfresco.rest.RestTest; import org.alfresco.rest.requests.RestNetworksApi; import org.alfresco.rest.requests.RestTenantApi; +import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; @@ -12,7 +13,7 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { "rest-api", "networks", "sanity" }) +@Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.COMMENTS }) public class RestGetNetworkForPersonSanityTests extends RestTest { @@ -40,9 +41,9 @@ public class RestGetNetworkForPersonSanityTests extends RestTest } @Bug(id = "MNT-16904") - @Test(groups = "sanity") - @TestRail(section = { "rest-api", - "networks" }, executionType = ExecutionType.SANITY, description = "Verify non existing user gets another exisiting network with Rest API and checks the forbidden status") + @Test(groups = TestGroup.COMMENTS) + @TestRail(section = { TestGroup.REST_API, + TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify non existing user gets another exisiting network with Rest API and checks the forbidden status") public void nonExistingTenantUserIsNotAuthorizedToRequest() throws Exception { UserModel tenantUser = new UserModel("nonexisting", "password"); @@ -52,9 +53,9 @@ public class RestGetNetworkForPersonSanityTests extends RestTest networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } - @Test(groups = "sanity") - @TestRail(section = { "rest-api", - "networks" }, executionType = ExecutionType.SANITY, description = "Verify tenant admin user gets specific network with Rest API and response is not empty") + @Test(groups = TestGroup.COMMENTS) + @TestRail(section = { TestGroup.REST_API, + TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify tenant admin user gets specific network with Rest API and response is not empty") public void adminTenantChecksIfNetworkIsPresent() throws Exception { restClient.authenticateUser(adminTenantUser); @@ -62,9 +63,9 @@ public class RestGetNetworkForPersonSanityTests extends RestTest networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @Test(groups = "sanity") - @TestRail(section = { "rest-api", - "networks" }, executionType = ExecutionType.SANITY, description = "Verify tenant user is not authorized to check network of admin user with Rest API and checks the forbidden status") + @Test(groups = TestGroup.COMMENTS) + @TestRail(section = { TestGroup.REST_API, + TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify tenant user is not authorized to check network of admin user with Rest API and checks the forbidden status") public void tenantUserIsNotAuthorizedToCheckNetworkOfAdminUser() throws Exception { restClient.authenticateUser(tenantUser); @@ -72,9 +73,9 @@ public class RestGetNetworkForPersonSanityTests extends RestTest networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); } - @Test(groups = "sanity") - @TestRail(section = { "rest-api", - "networks" }, executionType = ExecutionType.SANITY, description = "Verify admin tenant user is not authorized to check network of another user with Rest API and checks the forbidden status") + @Test(groups = TestGroup.COMMENTS) + @TestRail(section = { TestGroup.REST_API, + TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify admin tenant user is not authorized to check network of another user with Rest API and checks the forbidden status") public void adminTenantUserIsNotAuthorizedToCheckNetworkOfAnotherUser() throws Exception { UserModel secondAdminTenantUser = UserModel.getAdminTenantUser(); diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkTest.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkTest.java index 977056fde..c750f68d1 100644 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkTest.java +++ b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkTest.java @@ -5,6 +5,7 @@ import org.alfresco.rest.requests.RestNetworksApi; import org.alfresco.rest.requests.RestTenantApi; 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.report.Bug; import org.alfresco.utility.testrail.ExecutionType; @@ -17,7 +18,7 @@ import org.testng.annotations.Test; /** * Created by Cristina Axinte on 9/26/2016. */ -@Test(groups = { "rest-api", "networks" }) +@Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS }) public class RestGetNetworkTest extends RestTest { @Autowired @@ -49,9 +50,9 @@ public class RestGetNetworkTest extends RestTest } @Bug(id = "MNT-16904") - @Test(groups = "sanity") - @TestRail(section = { "rest-api", - "networks" }, executionType = ExecutionType.SANITY, description = "Verify non existing user gets another exisiting network with Rest API and checks the forbidden status") + @Test(groups = TestGroup.COMMENTS) + @TestRail(section = { TestGroup.REST_API, + TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify non existing user gets another exisiting network with Rest API and checks the forbidden status") public void nonExistingTenantUserIsNotAuthorizedToRequest() throws Exception { UserModel tenantUser = new UserModel("nonexisting", "password"); @@ -61,9 +62,9 @@ public class RestGetNetworkTest extends RestTest networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } - @Test(groups = "sanity") - @TestRail(section = { "rest-api", - "networks" }, executionType = ExecutionType.SANITY, description = "Verify tenant admin user gets specific network with Rest API and response is not empty") + @Test(groups = TestGroup.COMMENTS) + @TestRail(section = { TestGroup.REST_API, + TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify tenant admin user gets specific network with Rest API and response is not empty") public void adminTenantChecksIfNetworkIsPresent() throws Exception { restClient.authenticateUser(adminTenantUser); @@ -71,16 +72,16 @@ public class RestGetNetworkTest extends RestTest networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", - "networks" }, description = "Verify tenant admin user gets specific network with Rest API and checks response parameters are correct") + @TestRail(section = { TestGroup.REST_API, + TestGroup.NETWORKS }, description = "Verify tenant admin user gets specific network with Rest API and checks response parameters are correct") public void adminTenantChecksNetworkParamsAreCorrect() throws Exception { restClient.authenticateUser(adminTenantUser); networkApi.getNetwork(adminTenantUser).assertNetworkHasName(adminTenantUser).assertNetworkIsEnabled(); } - @TestRail(section = { "rest-api", - "networks" }, description = "Verify tenant admin user gets non exisiting network with Rest API and checks the not found status") + @TestRail(section = { TestGroup.REST_API, + TestGroup.NETWORKS }, description = "Verify tenant admin user gets non exisiting network with Rest API and checks the not found status") public void adminTenantChecksIfNonExistingNetworkIsNotFound() throws Exception { restClient.authenticateUser(adminTenantUser); @@ -88,8 +89,8 @@ public class RestGetNetworkTest extends RestTest networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); } - @TestRail(section = { "rest-api", - "networks" }, description = "Verify tenant admin user gets another exisiting network with Rest API and checks the forbidden status") + @TestRail(section = { TestGroup.REST_API, + TestGroup.NETWORKS }, description = "Verify tenant admin user gets another exisiting network with Rest API and checks the forbidden status") public void adminTenantChecksIfAnotherExistingNetworkIsForbidden() throws Exception { restClient.authenticateUser(adminTenantUser); @@ -97,7 +98,7 @@ public class RestGetNetworkTest extends RestTest networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } - @TestRail(section = { "rest-api", "networks" }, description = "Verify any tenant user gets its network with Rest API and response is not empty") + @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, description = "Verify any tenant user gets its network with Rest API and response is not empty") public void userTenantChecksIfNetworkIsPresent() throws Exception { restClient.authenticateUser(tenantUser); @@ -105,16 +106,16 @@ public class RestGetNetworkTest extends RestTest networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", - "networks" }, description = "Verify any tenant user gets specific network with Rest API and checks response parameters are correct") + @TestRail(section = { TestGroup.REST_API, + TestGroup.NETWORKS }, description = "Verify any tenant user gets specific network with Rest API and checks response parameters are correct") public void userTenantChecksNetworkParamsAreCorrect() throws Exception { restClient.authenticateUser(tenantUser); networkApi.getNetwork(adminTenantUser).assertNetworkHasName(adminTenantUser).assertNetworkIsEnabled(); } - @TestRail(section = { "rest-api", - "networks" }, description = "Verify any tenant user gets non exisiting network with Rest API and checks the not found status") + @TestRail(section = { TestGroup.REST_API, + TestGroup.NETWORKS }, description = "Verify any tenant user gets non exisiting network with Rest API and checks the not found status") public void userTenantChecksIfNonExistingNetworkIsNotFound() throws Exception { restClient.authenticateUser(tenantUser); @@ -122,9 +123,9 @@ public class RestGetNetworkTest extends RestTest networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); } - @Test(groups = "sanity") - @TestRail(section = { "rest-api", - "networks" }, description = "Verify any tenant user gets another exisiting network with Rest API and checks the forbidden status") + @Test(groups = TestGroup.COMMENTS) + @TestRail(section = { TestGroup.REST_API, + TestGroup.NETWORKS }, description = "Verify any tenant user gets another exisiting network with Rest API and checks the forbidden status") public void userTenantChecksIfAnotherExistingNetworkIsForbidden() throws Exception { restClient.authenticateUser(tenantUser); @@ -132,9 +133,9 @@ public class RestGetNetworkTest extends RestTest networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } - @Test(groups = "sanity") - @TestRail(section = { "rest-api", - "networks" }, executionType = ExecutionType.SANITY, description = "Verify manager tenant user gets its network with Rest API and response is not empty") + @Test(groups = TestGroup.COMMENTS) + @TestRail(section = { TestGroup.REST_API, + TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify manager tenant user gets its network with Rest API and response is not empty") public void tenantManagerUserChecksIfNetworkIsPresent() throws Exception { UserModel managerTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("manTenant"); @@ -145,9 +146,9 @@ public class RestGetNetworkTest extends RestTest networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @Test(groups = "sanity") - @TestRail(section = { "rest-api", - "networks" }, executionType = ExecutionType.SANITY, description = "Verify collaborator tenant user gets its network with Rest API and response is not empty") + @Test(groups = TestGroup.COMMENTS) + @TestRail(section = { TestGroup.REST_API, + TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify collaborator tenant user gets its network with Rest API and response is not empty") public void tenantCollaboratorUserChecksIfNetworkIsPresent() throws Exception { UserModel collaboratorTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("colTenant"); @@ -158,9 +159,9 @@ public class RestGetNetworkTest extends RestTest networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @Test(groups = "sanity") - @TestRail(section = { "rest-api", - "networks" }, executionType = ExecutionType.SANITY, description = "Verify consumer tenant user gets its network with Rest API and response is not empty") + @Test(groups = TestGroup.COMMENTS) + @TestRail(section = { TestGroup.REST_API, + TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify consumer tenant user gets its network with Rest API and response is not empty") public void tenantConsumerUserChecksIfNetworkIsPresent() throws Exception { UserModel consumerTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("consTenant"); @@ -171,9 +172,9 @@ public class RestGetNetworkTest extends RestTest networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @Test(groups = "sanity") - @TestRail(section = { "rest-api", - "networks" }, executionType = ExecutionType.SANITY, description = "Verify contributor tenant user gets its network with Rest API and response is not empty") + @Test(groups = TestGroup.COMMENTS) + @TestRail(section = { TestGroup.REST_API, + TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify contributor tenant user gets its network with Rest API and response is not empty") public void tenantContributorUserChecksIfItsNetworkIsPresent() throws Exception { UserModel contributorTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("contTenant"); diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonSanityTests.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonSanityTests.java index 91c153b08..306836a22 100644 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonSanityTests.java @@ -3,6 +3,7 @@ package org.alfresco.rest.networks; import org.alfresco.rest.RestTest; import org.alfresco.rest.requests.RestNetworksApi; import org.alfresco.rest.requests.RestTenantApi; +import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; @@ -12,7 +13,7 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { "rest-api", "networks", "sanity" }) +@Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.COMMENTS }) public class RestGetNetworksForPersonSanityTests extends RestTest { @Autowired @@ -39,9 +40,9 @@ public class RestGetNetworksForPersonSanityTests extends RestTest } @Bug(id = "MNT-16904") - @Test(groups = "sanity") - @TestRail(section = { "rest-api", - "networks" }, executionType = ExecutionType.SANITY, description = "Verify non existing user gets another exisiting network with Rest API and checks the forbidden status") + @Test(groups = TestGroup.COMMENTS) + @TestRail(section = { TestGroup.REST_API, + TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify non existing user gets another exisiting network with Rest API and checks the forbidden status") public void nonExistingTenantUserIsNotAuthorizedToRequest() throws Exception { UserModel tenantUser = new UserModel("nonexisting", "password"); @@ -51,9 +52,9 @@ public class RestGetNetworksForPersonSanityTests extends RestTest networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } - @Test(groups = "sanity") - @TestRail(section = { "rest-api", - "networks" }, executionType = ExecutionType.SANITY, description = "Verify tenant admin user gets specific network with Rest API and response is not empty") + @Test(groups = TestGroup.COMMENTS) + @TestRail(section = { TestGroup.REST_API, + TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify tenant admin user gets specific network with Rest API and response is not empty") public void adminTenantChecksIfNetworkIsPresent() throws Exception { restClient.authenticateUser(adminTenantUser); @@ -61,9 +62,9 @@ public class RestGetNetworksForPersonSanityTests extends RestTest networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @Test(groups = "sanity") - @TestRail(section = { "rest-api", - "networks" }, executionType = ExecutionType.SANITY, description = "Verify tenant user is not authorized to check network of admin user with Rest API and checks the forbidden status") + @Test(groups = TestGroup.COMMENTS) + @TestRail(section = { TestGroup.REST_API, + TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify tenant user is not authorized to check network of admin user with Rest API and checks the forbidden status") public void tenantUserIsNotAuthorizedToCheckNetworkOfAdminUser() throws Exception { restClient.authenticateUser(tenantUser); @@ -71,9 +72,9 @@ public class RestGetNetworksForPersonSanityTests extends RestTest networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); } - @Test(groups = "sanity") - @TestRail(section = { "rest-api", - "networks" }, executionType = ExecutionType.SANITY, description = "Verify admin tenant user is not authorized to check network of another user with Rest API and checks the forbidden status") + @Test(groups = TestGroup.COMMENTS) + @TestRail(section = { TestGroup.REST_API, + TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify admin tenant user is not authorized to check network of another user with Rest API and checks the forbidden status") public void adminTenantUserIsNotAuthorizedToCheckNetworkOfAnotherUser() throws Exception { UserModel secondAdminTenantUser = UserModel.getAdminTenantUser(); diff --git a/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteSanityTests.java index d4895a72a..194077c6b 100644 --- a/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteSanityTests.java @@ -4,6 +4,7 @@ import org.alfresco.rest.RestTest; import org.alfresco.rest.requests.RestPeopleApi; 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.report.Bug; import org.alfresco.utility.testrail.ExecutionType; @@ -13,7 +14,7 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { "rest-api", "people", "sanity" }) +@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.COMMENTS }) public class AddFavoriteSiteSanityTests extends RestTest { @Autowired @@ -32,7 +33,7 @@ public class AddFavoriteSiteSanityTests extends RestTest peopleApi.useRestClient(restClient); } - @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify manager user add a favorite site with Rest API and response is successful (201)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user add a favorite site with Rest API and response is successful (201)") public void managerUserAddFavoriteSiteWithSuccess() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -43,7 +44,7 @@ public class AddFavoriteSiteSanityTests extends RestTest peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } - @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify collaborator user add a favorite site with Rest API and response is successful (201)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify collaborator user add a favorite site with Rest API and response is successful (201)") public void collaboratorUserAddFavoriteSiteWithSuccess() throws Exception { UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); @@ -54,7 +55,7 @@ public class AddFavoriteSiteSanityTests extends RestTest peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } - @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify contributor user add a favorite site with Rest API and response is successful (201)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify contributor user add a favorite site with Rest API and response is successful (201)") public void contributorUserAddFavoriteSiteWithSuccess() throws Exception { UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); @@ -65,7 +66,7 @@ public class AddFavoriteSiteSanityTests extends RestTest peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } - @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify consumer user add a favorite site with Rest API and response is successful (201)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify consumer user add a favorite site with Rest API and response is successful (201)") public void consumerUserAddFavoriteSiteWithSuccess() throws Exception { UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -76,7 +77,7 @@ public class AddFavoriteSiteSanityTests extends RestTest peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } - @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify admin user add a favorite site with Rest API and response is successful (201)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify admin user add a favorite site with Rest API and response is successful (201)") public void adminUserAddFavoriteSiteWithSuccess() throws Exception { UserModel adminUser = dataUser.getAdminUser(); @@ -87,7 +88,7 @@ public class AddFavoriteSiteSanityTests extends RestTest } @Bug(id = "MNT-16904") - @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify a manager user is NOT Authorized to add a favorite site with Rest API when authentication fails (401)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify a manager user is NOT Authorized to add a favorite site with Rest API when authentication fails (401)") public void managerUserNotAuthorizedFailsToAddFavoriteSite() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); diff --git a/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java index 3011d99c2..92d666594 100644 --- a/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java @@ -9,6 +9,7 @@ import org.alfresco.utility.data.DataUser; 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.report.Bug; import org.alfresco.utility.testrail.ExecutionType; @@ -18,7 +19,7 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { "rest-api", "people", "sanity" }) +@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.COMMENTS }) public class AddSiteMembershipRequestSanityTests extends RestTest { @Autowired @@ -46,7 +47,7 @@ public class AddSiteMembershipRequestSanityTests extends RestTest peopleApi.useRestClient(restClient); } - @TestRail(section = { "rest-api", "people" }, + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site manager is able to create new site membership request") @Bug(id="MNT-16557") public void siteManagerIsAbleToCreateSiteMembershipRequest() throws JsonToModelConversionException, Exception @@ -58,7 +59,7 @@ public class AddSiteMembershipRequestSanityTests extends RestTest .assertStatusCodeIs(HttpStatus.CREATED); } - @TestRail(section = { "rest-api", "people" }, + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site collaborator is able to create new site membership request") @Bug(id = "MNT-16557") public void siteCollaboatorIsAbleToCreateSiteMembershipRequest() throws JsonToModelConversionException, Exception @@ -70,7 +71,7 @@ public class AddSiteMembershipRequestSanityTests extends RestTest .assertStatusCodeIs(HttpStatus.CREATED); } - @TestRail(section = { "rest-api", "people" }, + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site contributor is able to create new site membership request") @Bug(id = "MNT-16557") public void siteContributorIsAbleToCreateSiteMembershipRequest() throws JsonToModelConversionException, Exception @@ -82,7 +83,7 @@ public class AddSiteMembershipRequestSanityTests extends RestTest .assertStatusCodeIs(HttpStatus.CREATED); } - @TestRail(section = { "rest-api", "people" }, + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site consumer is able to create new site membership request") @Bug(id = "MNT-16557") public void siteConsumerIsAbleToCreateSiteMembershipRequest() throws JsonToModelConversionException, Exception @@ -94,7 +95,7 @@ public class AddSiteMembershipRequestSanityTests extends RestTest .assertStatusCodeIs(HttpStatus.CREATED); } - @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify admin user is able to create new site membership request") @Bug(id = "MNT-16557") public void adminUserIsAbleToCreateSiteMembershipRequest() throws JsonToModelConversionException, Exception @@ -105,7 +106,7 @@ public class AddSiteMembershipRequestSanityTests extends RestTest peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } - @TestRail(section = { "rest-api", "people" }, + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to create new site membership request") @Bug(id = "MNT-16557") public void unauthenticatedUserIsNotAbleToCreateSiteMembershipRequest() throws JsonToModelConversionException, Exception diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java index a707f4e3b..267b75cab 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java @@ -4,6 +4,7 @@ import org.alfresco.rest.RestTest; import org.alfresco.rest.requests.RestPeopleApi; 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; @@ -15,7 +16,7 @@ import org.testng.annotations.Test; /** * @author Cristina Axinte */ -@Test(groups = { "rest-api", "people", "sanity" }) +@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.COMMENTS }) public class DeleteFavoriteSiteSanityTests extends RestTest { @Autowired @@ -36,7 +37,7 @@ public class DeleteFavoriteSiteSanityTests extends RestTest peopleApi.useRestClient(restClient); } - @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify manager user removes a site from its favorite sites list with Rest API and response is successful (204)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user removes a site from its favorite sites list with Rest API and response is successful (204)") public void managerUserRemovesFavoriteSiteWithSuccess() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -49,7 +50,7 @@ public class DeleteFavoriteSiteSanityTests extends RestTest peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); } - @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify collaborator user removes a site from its favorite sites list with Rest API and response is successful (204)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify collaborator user removes a site from its favorite sites list with Rest API and response is successful (204)") public void collaboratorUserRemovesFavoriteSiteWithSuccess() throws Exception { UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); @@ -62,7 +63,7 @@ public class DeleteFavoriteSiteSanityTests extends RestTest peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); } - @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify contributor user removes a site from its favorite sites list with Rest API and response is successful (204)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify contributor user removes a site from its favorite sites list with Rest API and response is successful (204)") public void contributorUserRemovesFavoriteSiteWithSuccess() throws Exception { UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); @@ -75,7 +76,7 @@ public class DeleteFavoriteSiteSanityTests extends RestTest peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); } - @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify consumer user removes a site from its favorite sites list with Rest API and response is successful (204)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify consumer user removes a site from its favorite sites list with Rest API and response is successful (204)") public void consumerUserRemovesFavoriteSiteWithSuccess() throws Exception { UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -88,7 +89,7 @@ public class DeleteFavoriteSiteSanityTests extends RestTest peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); } - @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify admin user removes a site from any user's favorite sites list with Rest API and response is successful (204)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify admin user removes a site from any user's favorite sites list with Rest API and response is successful (204)") public void adminUserRemovesAnyFavoriteSiteWithSuccess() throws Exception { UserModel adminUser = dataUser.getAdminUser(); @@ -101,7 +102,7 @@ public class DeleteFavoriteSiteSanityTests extends RestTest peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); } - @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify a user removes a site from another user's favorite sites list with Rest API and response is permission denied (403)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify a user removes a site from another user's favorite sites list with Rest API and response is permission denied (403)") public void userUserRemovesAnotherUserFavoriteSiteWithSuccess() throws Exception { UserModel userAuth = dataUser.usingAdmin().createRandomTestUser(); @@ -114,7 +115,7 @@ public class DeleteFavoriteSiteSanityTests extends RestTest peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } - @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized to remove a site from its favorite sites list with Rest API when authentication fails (401)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized to remove a site from its favorite sites list with Rest API when authentication fails (401)") public void managerUserNotAuthorizedFailsToRemoveFavoriteSite() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java index 1da61496b..fbab60db0 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java @@ -10,6 +10,7 @@ import org.alfresco.utility.data.DataUser; 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.report.Bug; import org.alfresco.utility.testrail.ExecutionType; @@ -19,7 +20,7 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { "rest-api", "people", "sanity" }) +@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.COMMENTS }) public class DeleteSiteMemberSanityTests extends RestTest { @Autowired @@ -51,7 +52,7 @@ public class DeleteSiteMemberSanityTests extends RestTest sitesApi.useRestClient(restClient); } - @TestRail(section = { "rest-api", "people" }, + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site manager is able to delete another member of the site") public void siteManagerCanDeleteSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception @@ -66,7 +67,7 @@ public class DeleteSiteMemberSanityTests extends RestTest .assertStatusCodeIs(HttpStatus.NO_CONTENT); } - @TestRail(section = { "rest-api", "people" }, + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify admin user is able to delete another member of the site") public void adminIsAbleToDeleteSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception @@ -81,7 +82,7 @@ public class DeleteSiteMemberSanityTests extends RestTest .assertStatusCodeIs(HttpStatus.NO_CONTENT); } - @TestRail(section = { "rest-api", "people" }, + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site collaborator does not have permission to delete another member of the site") @Bug(id="ACE-5444") @@ -97,7 +98,7 @@ public class DeleteSiteMemberSanityTests extends RestTest sitesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } - @TestRail(section = { "rest-api", "people" }, + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site contributor does not have permission to delete another member of the site") @Bug(id="ACE-5444") @@ -113,7 +114,7 @@ public class DeleteSiteMemberSanityTests extends RestTest sitesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } - @TestRail(section = { "rest-api", "people" }, + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site consumer does not have permission to delete another member of the site") @Bug(id="ACE-5444") @@ -129,7 +130,7 @@ public class DeleteSiteMemberSanityTests extends RestTest sitesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } - @TestRail(section = { "rest-api", "people" }, + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to delete another member of the site") public void unauthenticatedUserIsNotAbleToDeleteSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java index 2c3d2a991..f8f32266b 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java @@ -8,6 +8,7 @@ import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.data.RandomData; 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.report.Bug; import org.alfresco.utility.testrail.ExecutionType; @@ -21,7 +22,7 @@ import org.testng.annotations.Test; /** * @author iulia.cojocea */ -@Test(groups = {"rest-api", "people", "sanity" }) +@Test(groups = {TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.COMMENTS }) public class DeleteSiteMembershipRequestSanityTests extends RestTest { @Autowired @@ -42,7 +43,7 @@ public class DeleteSiteMembershipRequestSanityTests extends RestTest peopleApi.useRestClient(restClient); } - @TestRail(section = {"rest-api", "people" }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify one user is able to delete his one site memebership request") public void userCanDeleteHisOwnSiteMembershipRequest() throws JsonToModelConversionException, DataPreparationException, Exception { @@ -56,7 +57,7 @@ public class DeleteSiteMembershipRequestSanityTests extends RestTest } @Bug(id="MNT-16916") - @TestRail(section = {"rest-api", "people" }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site manager is able to delete site membership request") public void siteManagerCanDeleteSiteMembershipRequest() throws JsonToModelConversionException, DataPreparationException, Exception { @@ -69,7 +70,7 @@ public class DeleteSiteMembershipRequestSanityTests extends RestTest } @Bug(id="MNT-16916") - @TestRail(section = {"rest-api", "people" }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify admin user is able to delete site memebership request") public void adminUserCanDeleteSiteMembershipRequest() throws JsonToModelConversionException, DataPreparationException, Exception { @@ -84,7 +85,7 @@ public class DeleteSiteMembershipRequestSanityTests extends RestTest } @Bug(id="MNT-16916") - @TestRail(section = {"rest-api", "people" }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify collaborator user is not able to delete site memebership request") public void collaboratorCannotDeleteSiteMembershipRequest() throws JsonToModelConversionException, DataPreparationException, Exception { @@ -97,7 +98,7 @@ public class DeleteSiteMembershipRequestSanityTests extends RestTest } @Bug(id="MNT-16916") - @TestRail(section = {"rest-api", "people" }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify contributor user is not able to delete site memebership request") public void contributorCannotDeleteSiteMembershipRequest() throws JsonToModelConversionException, DataPreparationException, Exception { @@ -110,7 +111,7 @@ public class DeleteSiteMembershipRequestSanityTests extends RestTest } @Bug(id="MNT-16916") - @TestRail(section = {"rest-api", "people" }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify consumer user is not able to delete site memebership request") public void consumerCannotDeleteSiteMembershipRequest() throws JsonToModelConversionException, DataPreparationException, Exception { @@ -123,7 +124,7 @@ public class DeleteSiteMembershipRequestSanityTests extends RestTest } @Bug(id="MNT-16916") - @TestRail(section = {"rest-api", "people" }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify random user is not able to delete site memebership request") public void randomUserCanDeleteSiteMembershipRequest() throws JsonToModelConversionException, DataPreparationException, Exception { @@ -136,7 +137,7 @@ public class DeleteSiteMembershipRequestSanityTests extends RestTest peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } - @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Failed authentication get site member call returns status code 401") public void unauthenticatedUserIsNotAuthorizedToDeleteSiteMmebershipRequest() throws JsonToModelConversionException, Exception { diff --git a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java index 90ab0b2cc..d6b38605f 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java @@ -4,6 +4,7 @@ import org.alfresco.rest.RestTest; import org.alfresco.rest.requests.RestPeopleApi; 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.report.Bug; import org.alfresco.utility.testrail.ExecutionType; @@ -19,7 +20,7 @@ import org.testng.annotations.Test; * @author Cristina Axinte * */ -@Test(groups = { "rest-api", "people", "sanity" }) +@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.COMMENTS }) public class GetFavoriteSiteSanityTests extends RestTest { @Autowired @@ -40,7 +41,7 @@ public class GetFavoriteSiteSanityTests extends RestTest peopleApi.useRestClient(restClient); } - @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify manager user gets its specific favorite site with Rest API and response is successful (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user gets its specific favorite site with Rest API and response is successful (200)") public void managerUserGetsFavoriteSiteWithSuccess() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -53,7 +54,7 @@ public class GetFavoriteSiteSanityTests extends RestTest peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify collaborator user gets its specific favorite site with Rest API and response is successful (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify collaborator user gets its specific favorite site with Rest API and response is successful (200)") public void collaboratorUserGetsFavoriteSiteWithSuccess() throws Exception { UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); @@ -66,7 +67,7 @@ public class GetFavoriteSiteSanityTests extends RestTest peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify contributor user gets its specific favorite site with Rest API and response is successful (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify contributor user gets its specific favorite site with Rest API and response is successful (200)") public void contributorUserGetsFavoriteSiteWithSuccess() throws Exception { UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); @@ -79,7 +80,7 @@ public class GetFavoriteSiteSanityTests extends RestTest peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify consumer user gets its specific favorite site with Rest API and response is successful (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify consumer user gets its specific favorite site with Rest API and response is successful (200)") public void consumerUserGetsFavoriteSiteWithSuccess() throws Exception { UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -92,7 +93,7 @@ public class GetFavoriteSiteSanityTests extends RestTest peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify admin user gets specific favorite site of any user with Rest API and response is successful (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify admin user gets specific favorite site of any user with Rest API and response is successful (200)") public void adminUserGetsAnyFavoriteSiteWithSuccess() throws Exception { UserModel adminUset = dataUser.getAdminUser(); @@ -105,7 +106,7 @@ public class GetFavoriteSiteSanityTests extends RestTest peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify manager user fails to get specific favorite site of another user with Rest API and response is successful (403)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user fails to get specific favorite site of another user with Rest API and response is successful (403)") public void managerUserFailsToGetFavoriteSiteOfAnotherUser() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -119,7 +120,7 @@ public class GetFavoriteSiteSanityTests extends RestTest } @Bug(id = "MNT-16904") - @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized gets its specific favorite site with Rest API when authentication fails (401)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized gets its specific favorite site with Rest API when authentication fails (401)") public void managerUserNotAuthorizedFailsToGetFavoriteSite() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); diff --git a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java index 7e2716413..b04ca65cc 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java @@ -4,6 +4,7 @@ import org.alfresco.rest.RestTest; import org.alfresco.rest.requests.RestPeopleApi; 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.report.Bug; import org.alfresco.utility.testrail.ExecutionType; @@ -13,7 +14,7 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { "rest-api", "people", "sanity" }) +@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.COMMENTS }) public class GetFavoriteSitesSanityTests extends RestTest { @Autowired @@ -32,7 +33,7 @@ public class GetFavoriteSitesSanityTests extends RestTest peopleApi.useRestClient(restClient); } - @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify manager user fails to get an user favorite sites with Rest API (403)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user fails to get an user favorite sites with Rest API (403)") public void managerUserFailsToGetAnUserFavoriteSites() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -45,7 +46,7 @@ public class GetFavoriteSitesSanityTests extends RestTest peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } - @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify collaborator user fails to get an user favorite sites with Rest API (403)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify collaborator user fails to get an user favorite sites with Rest API (403)") public void collaboratorUserFailsToGetAnUserFavoriteSites() throws Exception { UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); @@ -59,7 +60,7 @@ public class GetFavoriteSitesSanityTests extends RestTest peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } - @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify contributor user fails to get an user favorite sites with Rest API (403)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify contributor user fails to get an user favorite sites with Rest API (403)") public void contributorUserFailsToGetAnUserFavoriteSites() throws Exception { UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); @@ -73,7 +74,7 @@ public class GetFavoriteSitesSanityTests extends RestTest peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } - @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify consumer user fails to get an user favorite sites with Rest API (403)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify consumer user fails to get an user favorite sites with Rest API (403)") public void consumerUserFailsToGetAnUserFavoriteSites() throws Exception { UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -87,7 +88,7 @@ public class GetFavoriteSitesSanityTests extends RestTest peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } - @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify admin user gets its favorite sites with Rest API and response is successful (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify admin user gets its favorite sites with Rest API and response is successful (200)") public void adminUserGetsFavoriteSitesWithSuccess() throws Exception { UserModel adminUser = dataUser.getAdminUser(); @@ -99,7 +100,7 @@ public class GetFavoriteSitesSanityTests extends RestTest peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify any user gets its own user favorite sites with Rest API and response is successful (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify any user gets its own user favorite sites with Rest API and response is successful (200)") public void anyUserGetsItsUserFavoriteSites() throws Exception { UserModel anyUser = dataUser.usingAdmin().createRandomTestUser(); @@ -111,7 +112,7 @@ public class GetFavoriteSitesSanityTests extends RestTest } @Bug(id = "MNT-16904") - @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify any user is NOT Authorized to get its favorite sites with Rest API when authentication fails (401)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify any user is NOT Authorized to get its favorite sites with Rest API when authentication fails (401)") public void anyUserNotAuthenticatedIsNotAuthorizedToGetFavoriteSites() throws Exception { UserModel anyUser = dataUser.usingAdmin().createRandomTestUser(); diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java index fd6a0c34c..22565c701 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java @@ -5,6 +5,7 @@ import org.alfresco.rest.RestTest; import org.alfresco.rest.requests.RestPeopleApi; 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.report.Bug; import org.alfresco.utility.testrail.ExecutionType; @@ -20,7 +21,7 @@ import org.testng.annotations.Test; * Tests for getActivities (/people/{personId}/activities) RestAPI call * */ -@Test(groups = { "rest-api", "people", "activities", "sanity" }) +@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, "activities", TestGroup.COMMENTS }) public class GetPeopleActivitiesSanityTests extends RestTest { @Autowired @@ -40,7 +41,7 @@ public class GetPeopleActivitiesSanityTests extends RestTest peopleApi.useRestClient(restClient); } - @TestRail(section = { "rest-api", "people", "activities" }, executionType = ExecutionType.SANITY, description = "Verify manager user gets its activities with Rest API and response is successful") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, "activities" }, executionType = ExecutionType.SANITY, description = "Verify manager user gets its activities with Rest API and response is successful") public void managerUserShouldGetPeopleActivitiesList() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -52,7 +53,7 @@ public class GetPeopleActivitiesSanityTests extends RestTest peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "people", "activities" }, executionType = ExecutionType.SANITY, description = "Verify collaborator user gets its activities with Rest API and response is successful") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, "activities" }, executionType = ExecutionType.SANITY, description = "Verify collaborator user gets its activities with Rest API and response is successful") public void collaboratorUserShouldGetPeopleActivitiesList() throws Exception { UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); @@ -64,7 +65,7 @@ public class GetPeopleActivitiesSanityTests extends RestTest peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "people", "activities" }, executionType = ExecutionType.SANITY, description = "Verify contributor user gets its activities with Rest API and response is successful") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, "activities" }, executionType = ExecutionType.SANITY, description = "Verify contributor user gets its activities with Rest API and response is successful") public void contributorUserShouldGetPeopleActivitiesList() throws Exception { UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); @@ -76,7 +77,7 @@ public class GetPeopleActivitiesSanityTests extends RestTest peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "people", "activities" }, executionType = ExecutionType.SANITY, description = "Verify consumer user gets its activities with Rest API and response is successful") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, "activities" }, executionType = ExecutionType.SANITY, description = "Verify consumer user gets its activities with Rest API and response is successful") public void consumerUserShouldGetPeopleActivitiesList() throws Exception { UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -87,7 +88,7 @@ public class GetPeopleActivitiesSanityTests extends RestTest peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "people", "activities" }, executionType = ExecutionType.SANITY, description = "Verify admin user gets another user activities with Rest API and response is successful") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, "activities" }, executionType = ExecutionType.SANITY, description = "Verify admin user gets another user activities with Rest API and response is successful") public void adminUserShouldGetPeopleActivitiesList() throws Exception { restClient.authenticateUser(dataUser.getAdminUser()); @@ -96,7 +97,7 @@ public class GetPeopleActivitiesSanityTests extends RestTest } @Bug(id = "MNT-16904") - @TestRail(section = { "rest-api", "people", "activities" }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized to gets another user activities with Rest API") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, "activities" }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized to gets another user activities with Rest API") public void managerUserShouldGetPeopleActivitiesListIsNotAuthorized() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceSanityTests.java index 80bb706af..c156ca29b 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceSanityTests.java @@ -5,6 +5,7 @@ import org.alfresco.rest.requests.RestPeopleApi; import org.alfresco.utility.constants.PreferenceName; 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.report.Bug; import org.alfresco.utility.testrail.ExecutionType; @@ -20,7 +21,7 @@ import org.testng.annotations.Test; * @author Cristina Axinte * */ -@Test(groups = { "rest-api", "people", "preferences", "sanity" }) +@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, "preferences", TestGroup.COMMENTS }) public class GetPeoplePreferenceSanityTests extends RestTest { @Autowired @@ -38,7 +39,7 @@ public class GetPeoplePreferenceSanityTests extends RestTest peopleApi.useRestClient(restClient); } - @TestRail(section = { "rest-api", "people", "preferences" }, executionType = ExecutionType.SANITY, description = "Verify manager user gets a specific preference with Rest API and response is successful (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, "preferences" }, executionType = ExecutionType.SANITY, description = "Verify manager user gets a specific preference with Rest API and response is successful (200)") public void managerUserGetsAPreferenceWithSuccess() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -50,7 +51,7 @@ public class GetPeoplePreferenceSanityTests extends RestTest peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "people", "preferences" }, executionType = ExecutionType.SANITY, description = "Verify collaborator user gets a specific preference with Rest API and response is successful (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, "preferences" }, executionType = ExecutionType.SANITY, description = "Verify collaborator user gets a specific preference with Rest API and response is successful (200)") public void collaboratorUserGetsAPreferenceWithSuccess() throws Exception { UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); @@ -62,7 +63,7 @@ public class GetPeoplePreferenceSanityTests extends RestTest peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "people", "preferences" }, executionType = ExecutionType.SANITY, description = "Verify contributor user gets a specific preference with Rest API and response is successful (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, "preferences" }, executionType = ExecutionType.SANITY, description = "Verify contributor user gets a specific preference with Rest API and response is successful (200)") public void contributorUserGetsAPreferenceWithSuccess() throws Exception { UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); @@ -74,7 +75,7 @@ public class GetPeoplePreferenceSanityTests extends RestTest peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "people", "preferences" }, executionType = ExecutionType.SANITY, description = "Verify consumer user gets a specific preference with Rest API and response is successful (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, "preferences" }, executionType = ExecutionType.SANITY, description = "Verify consumer user gets a specific preference with Rest API and response is successful (200)") public void consumerUserGetsAPreferenceWithSuccess() throws Exception { UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -86,7 +87,7 @@ public class GetPeoplePreferenceSanityTests extends RestTest peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "people", "preferences" }, executionType = ExecutionType.SANITY, description = "Verify admin user gets a specific preference with Rest API and response is successful (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, "preferences" }, executionType = ExecutionType.SANITY, description = "Verify admin user gets a specific preference with Rest API and response is successful (200)") public void adminUserGetsAPreferenceWithSuccess() throws Exception { UserModel adminUser = dataUser.getAdminUser(); @@ -98,7 +99,7 @@ public class GetPeoplePreferenceSanityTests extends RestTest } @Bug(id = "MNT-16904") - @TestRail(section = { "rest-api", "people", "preferences" }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized to get a specific preference with Rest API when authentication fails (401)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, "preferences" }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized to get a specific preference with Rest API when authentication fails (401)") public void managerUserNotAuthorizedFailsToGetsAPreference() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesSanityTests.java index a59284ea5..33eb8d4c4 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesSanityTests.java @@ -4,6 +4,7 @@ import org.alfresco.rest.RestTest; import org.alfresco.rest.requests.RestPeopleApi; 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.report.Bug; import org.alfresco.utility.testrail.ExecutionType; @@ -19,7 +20,7 @@ import org.testng.annotations.Test; * @author Cristina Axinte * */ -@Test(groups = { "rest-api", "people", "preferences", "sanity" }) +@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, "preferences", TestGroup.COMMENTS }) public class GetPeoplePreferencesSanityTests extends RestTest { @Autowired @@ -37,7 +38,7 @@ public class GetPeoplePreferencesSanityTests extends RestTest peopleApi.useRestClient(restClient); } - @TestRail(section = { "rest-api", "people", "preferences" }, executionType = ExecutionType.SANITY, description = "Verify manager user gets its preferences with Rest API and response is successful (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, "preferences" }, executionType = ExecutionType.SANITY, description = "Verify manager user gets its preferences with Rest API and response is successful (200)") public void managerUserGetsPeoplePreferencesWithSuccess() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -49,7 +50,7 @@ public class GetPeoplePreferencesSanityTests extends RestTest peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "people", "preferences" }, executionType = ExecutionType.SANITY, description = "Verify collaborator user gets its preferences with Rest API and response is successful (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, "preferences" }, executionType = ExecutionType.SANITY, description = "Verify collaborator user gets its preferences with Rest API and response is successful (200)") public void collaboratorUserGetsPeoplePreferencesWithSuccess() throws Exception { UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); @@ -61,7 +62,7 @@ public class GetPeoplePreferencesSanityTests extends RestTest peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "people", "preferences" }, executionType = ExecutionType.SANITY, description = "Verify contributor user gets its preferences with Rest API and response is successful (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, "preferences" }, executionType = ExecutionType.SANITY, description = "Verify contributor user gets its preferences with Rest API and response is successful (200)") public void contributorUserGetsPeoplePreferencesWithSuccess() throws Exception { UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); @@ -73,7 +74,7 @@ public class GetPeoplePreferencesSanityTests extends RestTest peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "people", "preferences" }, executionType = ExecutionType.SANITY, description = "Verify consumer user gets its preferences with Rest API and response is successful (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, "preferences" }, executionType = ExecutionType.SANITY, description = "Verify consumer user gets its preferences with Rest API and response is successful (200)") public void consumerUserGetsPeoplePreferencesWithSuccess() throws Exception { UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -85,7 +86,7 @@ public class GetPeoplePreferencesSanityTests extends RestTest peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "people", "preferences" }, executionType = ExecutionType.SANITY, description = "Verify admin user gets another user preferences with Rest API and response is successful (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, "preferences" }, executionType = ExecutionType.SANITY, description = "Verify admin user gets another user preferences with Rest API and response is successful (200)") public void adminUserGetsPeoplePreferencesWithSuccess() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -99,7 +100,7 @@ public class GetPeoplePreferencesSanityTests extends RestTest } @Bug(id = "MNT-16904") - @TestRail(section = { "rest-api", "people", "preferences" }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized to gets its preferences with Rest API when authentication fails(401)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, "preferences" }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized to gets its preferences with Rest API when authentication fails(401)") public void managerUserGetsPeoplePreferencesIsNotAUthorized() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleSanityTests.java index 416e5d2b9..f5f6d7f1b 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleSanityTests.java @@ -5,6 +5,7 @@ import org.alfresco.rest.requests.RestPeopleApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; 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; @@ -13,7 +14,7 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { "rest-api", "people", "sanity" }) +@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.COMMENTS }) public class GetPeopleSanityTests extends RestTest { @Autowired @@ -33,7 +34,7 @@ public class GetPeopleSanityTests extends RestTest peopleApi.useRestClient(restClient); } - @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify manager user gets a person with Rest API and response is successful") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user gets a person with Rest API and response is successful") public void managerUserChecksIfPersonIsPresent() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -44,7 +45,7 @@ public class GetPeopleSanityTests extends RestTest peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify collaborator user gets a person with Rest API and response is successful") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify collaborator user gets a person with Rest API and response is successful") public void collaboratorUserChecksIfPersonIsPresent() throws Exception { UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); @@ -55,8 +56,8 @@ public class GetPeopleSanityTests extends RestTest peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @Test(groups = "sanity") - @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify contributor user gets a person with Rest API and response is successful") + @Test(groups = TestGroup.COMMENTS) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify contributor user gets a person with Rest API and response is successful") public void contributorUserChecksIfPersonIsPresent() throws Exception { UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); @@ -67,7 +68,7 @@ public class GetPeopleSanityTests extends RestTest peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify consumer user gets a person with Rest API and response is successful") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify consumer user gets a person with Rest API and response is successful") public void consumerUserChecksIfPersonIsPresent() throws Exception { UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -78,7 +79,7 @@ public class GetPeopleSanityTests extends RestTest peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify admin user gets a person with Rest API and response is successful") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify admin user gets a person with Rest API and response is successful") public void adminUserChecksIfPersonIsPresent() throws Exception { UserModel adminUser = dataUser.getAdminUser(); @@ -88,7 +89,7 @@ public class GetPeopleSanityTests extends RestTest peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify manager user gets a non existing person with Rest API and person is not found") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user gets a non existing person with Rest API and person is not found") public void managerUserChecksIfNonExistingPersonIsPresent() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestSanityTests.java index 3342c087a..1618b9622 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestSanityTests.java @@ -9,6 +9,7 @@ import org.alfresco.utility.data.DataUser; 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.report.Bug; import org.alfresco.utility.testrail.ExecutionType; @@ -18,7 +19,7 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { "rest-api", "people", "sanity" }) +@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.COMMENTS }) public class GetSiteMembershipRequestSanityTests extends RestTest { @Autowired @@ -46,7 +47,7 @@ public class GetSiteMembershipRequestSanityTests extends RestTest peopleApi.useRestClient(restClient); } - @TestRail(section = { "rest-api","people" }, + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site manager is able to retrieve site membership request") @Bug(id="MNT-16557") public void siteManagerIsAbleToRetrieveSiteMembershipRequest() throws JsonToModelConversionException, Exception @@ -60,7 +61,7 @@ public class GetSiteMembershipRequestSanityTests extends RestTest .assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "people" }, + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site collaborator is able to retrieve site membership request") @Bug(id = "MNT-16557") public void siteCollaboratorIsAbleToRetrieveSiteMembershipRequest() throws JsonToModelConversionException, Exception @@ -74,7 +75,7 @@ public class GetSiteMembershipRequestSanityTests extends RestTest .assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "people" }, + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site contributor is able to retrieve site membership request") @Bug(id = "MNT-16557") public void siteContributorIsAbleToRetrieveSiteMembershipRequest() throws JsonToModelConversionException, Exception @@ -88,7 +89,7 @@ public class GetSiteMembershipRequestSanityTests extends RestTest .assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "people" }, + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site consumer is able to retrieve site membership request") @Bug(id = "MNT-16557") public void siteConsumerIsAbleToRetrieveSiteMembershipRequest() throws JsonToModelConversionException, Exception @@ -102,7 +103,7 @@ public class GetSiteMembershipRequestSanityTests extends RestTest .assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "people" }, + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify admin user is able to retrieve site membership request") @Bug(id = "MNT-16557") public void adminIsAbleToRetrieveSiteMembershipRequest() throws JsonToModelConversionException, Exception @@ -116,7 +117,7 @@ public class GetSiteMembershipRequestSanityTests extends RestTest .assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "people" }, + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to retrieve site membership request") @Bug(id = "MNT-16557") public void unauthenticatedUserIsNotAbleToRetrieveSiteMembershipRequest() throws JsonToModelConversionException, Exception diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java index a9aa8968a..c5c051aa9 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java @@ -5,6 +5,7 @@ import org.alfresco.rest.requests.RestPeopleApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.RandomData; import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; @@ -20,7 +21,7 @@ import org.testng.annotations.Test; * * @author Cristina Axinte */ -@Test(groups = { "rest-api", "people", "sanity" }) +@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.COMMENTS }) public class GetSiteMembershipRequestsSanityTests extends RestTest { @Autowired @@ -46,7 +47,7 @@ public class GetSiteMembershipRequestsSanityTests extends RestTest } @Bug(id = "MNT-16557") - @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify manager user gets all site membership requests of a specific person with Rest API and response is successful (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user gets all site membership requests of a specific person with Rest API and response is successful (200)") public void managerUserGetsSiteMembershipRequestsWithSuccess() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -58,7 +59,7 @@ public class GetSiteMembershipRequestsSanityTests extends RestTest } @Bug(id = "MNT-16557") - @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify collaborator user fails to get all site membership requests of another user with Rest API (403)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify collaborator user fails to get all site membership requests of another user with Rest API (403)") public void collaboratorUserFailsToGetSiteMembershipRequestsOfAnotherUser() throws Exception { UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); @@ -70,7 +71,7 @@ public class GetSiteMembershipRequestsSanityTests extends RestTest } @Bug(id = "MNT-16557") - @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify contributor user fails to get all site membership requests of another user with Rest API (403)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify contributor user fails to get all site membership requests of another user with Rest API (403)") public void contributorUserFailsToGetSiteMembershipRequestsOfAnotherUser() throws Exception { UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); @@ -82,7 +83,7 @@ public class GetSiteMembershipRequestsSanityTests extends RestTest } @Bug(id = "MNT-16557") - @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify consumer user fails to get all site membership requests of another user with Rest API (403)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify consumer user fails to get all site membership requests of another user with Rest API (403)") public void consumerUserFailsToGetSiteMembershipRequestsOfAnotherUser() throws Exception { UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -94,7 +95,7 @@ public class GetSiteMembershipRequestsSanityTests extends RestTest } @Bug(id = "MNT-16557") - @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify admin user gets all site membership requests of a specific person with Rest API and response is successful (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify admin user gets all site membership requests of a specific person with Rest API and response is successful (200)") public void adminUserGetsSiteMembershipRequestsWithSuccess() throws Exception { UserModel adminUser = dataUser.getAdminUser(); @@ -105,7 +106,7 @@ public class GetSiteMembershipRequestsSanityTests extends RestTest } @Bug(id = "MNT-16904") - @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify manager user fails to get all site membership requests of a specific person with Rest API when the authentication fails (401)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user fails to get all site membership requests of a specific person with Rest API when the authentication fails (401)") public void managerUserNotAuthorizedFailsToGetSiteMembershipRequests() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -117,7 +118,7 @@ public class GetSiteMembershipRequestsSanityTests extends RestTest peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "people" }, executionType = ExecutionType.SANITY, description = "Verify a user gets all its own site membership requests with Rest API and response is successful (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify a user gets all its own site membership requests with Rest API and response is successful (200)") public void oneUserGetsItsOwnSiteMembershipRequestsWithSuccess() throws Exception { restClient.authenticateUser(newMember); diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java index a87e5e20b..930aae70e 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java @@ -9,6 +9,7 @@ import org.alfresco.utility.data.DataUser; 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.report.Bug; import org.alfresco.utility.testrail.ExecutionType; @@ -18,7 +19,7 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { "rest-api", "people", "sanity" }) +@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.COMMENTS }) public class GetSiteMembershipSanityTests extends RestTest { @Autowired @@ -46,7 +47,7 @@ public class GetSiteMembershipSanityTests extends RestTest peopleApi.useRestClient(restClient); } - @TestRail(section = { "rest-api", "people" }, + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site manager is able to retrieve site membership information of another user") public void siteManagerCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception @@ -57,8 +58,8 @@ public class GetSiteMembershipSanityTests extends RestTest .assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", - "people" }, executionType = ExecutionType.SANITY, description = "Verify site collaborator is able to retrieve site membership information of another user") + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site collaborator is able to retrieve site membership information of another user") public void siteCollaboratorCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); @@ -67,8 +68,8 @@ public class GetSiteMembershipSanityTests extends RestTest .assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", - "people" }, executionType = ExecutionType.SANITY, description = "Verify site contributor is able to retrieve site membership information of another user") + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site contributor is able to retrieve site membership information of another user") public void siteContributorCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); @@ -77,8 +78,8 @@ public class GetSiteMembershipSanityTests extends RestTest .assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", - "people" }, executionType = ExecutionType.SANITY, description = "Verify site consumer is able to retrieve site membership information of another user") + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site consumer is able to retrieve site membership information of another user") public void siteConsumerCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); @@ -87,8 +88,8 @@ public class GetSiteMembershipSanityTests extends RestTest .assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", - "people" }, executionType = ExecutionType.SANITY, description = "Verify admin user is able to retrieve site membership information of another user") + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify admin user is able to retrieve site membership information of another user") public void adminCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUser); @@ -97,8 +98,8 @@ public class GetSiteMembershipSanityTests extends RestTest .assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", - "people" }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to retrieve site membership information of another user") + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to retrieve site membership information of another user") @Bug(id = "MNT-16904") public void unauthenticatedUserCannotRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception { diff --git a/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java index fe30fe3e3..f7624949a 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java @@ -7,6 +7,7 @@ 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.report.Bug; import org.alfresco.utility.testrail.ExecutionType; @@ -16,7 +17,7 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { "rest-api", "people", "sanity" }) +@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.COMMENTS }) public class GetSitesMembershipInformationSanityTests extends RestTest { @Autowired @@ -36,7 +37,7 @@ public class GetSitesMembershipInformationSanityTests extends RestTest peopleApi.useRestClient(restClient); } - @TestRail(section = { "rest-api", "people" }, + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site manager is able to retrieve sites membership information of another user") public void siteManagerIsAbleToRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception @@ -47,7 +48,7 @@ public class GetSitesMembershipInformationSanityTests extends RestTest .assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "people" }, + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site collaborator is able to retrieve sites membership information of another user") public void siteCollaboratorIsAbleToRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception @@ -58,7 +59,7 @@ public class GetSitesMembershipInformationSanityTests extends RestTest .assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "people" }, + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site contributor is able to retrieve sites membership information of another user") public void siteContributorIsAbleToRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception @@ -69,7 +70,7 @@ public class GetSitesMembershipInformationSanityTests extends RestTest .assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "people" }, + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site consumer is able to retrieve sites membership information of another user") public void siteConsumerIsAbleToRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception @@ -80,7 +81,7 @@ public class GetSitesMembershipInformationSanityTests extends RestTest .assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "people" }, + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify admin is able to retrieve sites membership information of another user") public void siteAdminIsAbleToRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception @@ -91,7 +92,7 @@ public class GetSitesMembershipInformationSanityTests extends RestTest .assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "people" }, + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify that unauthenticated user is not able to retrieve sites membership information") @Bug(id = "MNT-16904") diff --git a/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestSanityTests.java index 7e947a007..d2ffc78fe 100644 --- a/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestSanityTests.java @@ -10,6 +10,7 @@ import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.data.RandomData; 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.report.Bug; import org.alfresco.utility.testrail.ExecutionType; @@ -20,7 +21,7 @@ import org.springframework.social.alfresco.api.entities.Site.Visibility; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { "rest-api", "people", "sanity" }) +@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.COMMENTS }) public class UpdateSiteMembershipRequestSanityTests extends RestTest { @Autowired @@ -52,7 +53,7 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest } - @TestRail(section = { "rest-api", "people" }, + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify user is able to update its own site membership request") public void userIsAbleToUpdateItsOwnSiteMembershipRequest() throws JsonToModelConversionException, Exception { @@ -67,7 +68,7 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest .assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "people" }, + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site manager is not able to update membership request of another user") @Bug(id = "MNT-16919") public void siteManagerIsNotAbleToUpdateSiteMembershipRequestOfAnotherUser() throws JsonToModelConversionException, Exception @@ -84,7 +85,7 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest .assertStatusCodeIs(HttpStatus.FORBIDDEN); } - @TestRail(section = { "rest-api", "people" }, + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site collaborator is not able to update membership request of another user") @Bug(id = "MNT-16919") public void siteCollaboratorIsNotAbleToUpdateSiteMembershipRequestOfAnotherUser() throws JsonToModelConversionException, Exception @@ -101,7 +102,7 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest .assertStatusCodeIs(HttpStatus.FORBIDDEN); } - @TestRail(section = { "rest-api", "people" }, + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site contributor is not able to update membership request of another user") @Bug(id = "MNT-16919") public void siteContributorIsNotAbleToUpdateSiteMembershipRequestOfAnotherUser() throws JsonToModelConversionException, Exception @@ -118,7 +119,7 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest .assertStatusCodeIs(HttpStatus.FORBIDDEN); } - @TestRail(section = { "rest-api", "people" }, + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site consumer is not able to update membership request of another user") @Bug(id = "MNT-16919") public void siteConsumerIsNotAbleToUpdateSiteMembershipRequestOfAnotherUser() throws JsonToModelConversionException, Exception @@ -135,7 +136,7 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest .assertStatusCodeIs(HttpStatus.FORBIDDEN); } - @TestRail(section = { "rest-api", "people" }, + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify one user is not able to update membership request of another user") @Bug(id = "MNT-16919") public void oneUserIsNotAbleToUpdateSiteMembershipRequestOfAnotherUser() throws JsonToModelConversionException, Exception @@ -153,7 +154,7 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest .assertStatusCodeIs(HttpStatus.FORBIDDEN); } - @TestRail(section = { "rest-api", "people" }, + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify admin is not able to update membership request of another user") @Bug(id = "MNT-16919") public void adminIsNotAbleToUpdateSiteMembershipRequestOfAnotherUser() throws JsonToModelConversionException, Exception diff --git a/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java index db14b1ff3..13c8fc2a6 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java @@ -9,6 +9,7 @@ import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; @@ -20,7 +21,7 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -@Test(groups = { "rest-api", "ratings", "sanity" }) +@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.COMMENTS }) public class AddRatingSanityTests extends RestTest { @Autowired @@ -52,8 +53,8 @@ public class AddRatingSanityTests extends RestTest document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); } - @TestRail(section = { "rest-api", - "ratings" }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role is able to post like rating to a document") + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role is able to post like rating to a document") public void managerIsAbleToLikeDocument() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); @@ -61,8 +62,8 @@ public class AddRatingSanityTests extends RestTest ratingsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } - @TestRail(section = { "rest-api", - "ratings" }, executionType = ExecutionType.SANITY, description = "Verify user with Collaborator role is able to post like rating to a document") + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Collaborator role is able to post like rating to a document") public void collaboratorIsAbleToLikeDocument() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); @@ -70,8 +71,8 @@ public class AddRatingSanityTests extends RestTest ratingsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } - @TestRail(section = { "rest-api", - "ratings" }, executionType = ExecutionType.SANITY, description = "Verify user with Contributor role is able to post like rating to a document") + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Contributor role is able to post like rating to a document") public void contributorIsAbleToLikeDocument() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); @@ -79,8 +80,8 @@ public class AddRatingSanityTests extends RestTest ratingsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } - @TestRail(section = { "rest-api", - "ratings" }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role is able to post like rating to a document") + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role is able to post like rating to a document") public void consumerIsAbleToLikeDocument() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); @@ -88,8 +89,8 @@ public class AddRatingSanityTests extends RestTest ratingsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } - @TestRail(section = { "rest-api", - "ratings" }, executionType = ExecutionType.SANITY, description = "Verify admin user is able to post like rating to a document") + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify admin user is able to post like rating to a document") public void adminIsAbleToLikeDocument() throws Exception { restClient.authenticateUser(adminUser); @@ -97,8 +98,8 @@ public class AddRatingSanityTests extends RestTest ratingsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } - @TestRail(section = { "rest-api", - "ratings" }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to post like rating to a document") + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to post like rating to a document") @Bug(id = "MNT-16904") public void unauthenticatedUserIsNotAbleToLikeDocument() throws Exception { @@ -107,8 +108,8 @@ public class AddRatingSanityTests extends RestTest ratingsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } - @TestRail(section = { "rest-api", - "ratings" }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role is able to post stars rating to a document") + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role is able to post stars rating to a document") public void managerIsAbleToAddStarsToDocument() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); @@ -116,8 +117,8 @@ public class AddRatingSanityTests extends RestTest ratingsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } - @TestRail(section = { "rest-api", - "ratings" }, executionType = ExecutionType.SANITY, description = "Verify user with Collaborator role is able to post stars rating to a document") + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Collaborator role is able to post stars rating to a document") public void collaboratorIsAbleToAddStarsToDocument() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); @@ -125,8 +126,8 @@ public class AddRatingSanityTests extends RestTest ratingsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } - @TestRail(section = { "rest-api", - "ratings" }, executionType = ExecutionType.SANITY, description = "Verify user with Contributor role is able to post stars rating to a document") + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Contributor role is able to post stars rating to a document") public void contributorIsAbleToAddStarsToDocument() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); @@ -134,8 +135,8 @@ public class AddRatingSanityTests extends RestTest ratingsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } - @TestRail(section = { "rest-api", - "ratings" }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role is able to post stars rating to a document") + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role is able to post stars rating to a document") public void consumerIsAbleToAddStarsToDocument() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); @@ -143,8 +144,8 @@ public class AddRatingSanityTests extends RestTest ratingsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } - @TestRail(section = { "rest-api", - "ratings" }, executionType = ExecutionType.SANITY, description = "Verify admin user is able to post stars rating to a document") + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify admin user is able to post stars rating to a document") public void adminIsAbleToAddStarsToDocument() throws Exception { restClient.authenticateUser(adminUser); @@ -152,8 +153,8 @@ public class AddRatingSanityTests extends RestTest ratingsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } - @TestRail(section = { "rest-api", - "ratings" }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to post stars rating to a document") + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to post stars rating to a document") @Bug(id = "MNT-16904") public void unauthenticatedUserIsNotAbleToRateStarsToDocument() throws Exception { diff --git a/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java index 7b9526fb6..b2659f895 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java @@ -9,6 +9,7 @@ import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; @@ -19,7 +20,7 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -@Test(groups = { "rest-api", "ratings", "sanity" }) +@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.COMMENTS }) public class DeleteRatingSanityTests extends RestTest { @Autowired @@ -50,7 +51,7 @@ public class DeleteRatingSanityTests extends RestTest document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); } - @TestRail(section = {"rest-api", "ratings" }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role is able to remove its own rating of a document") public void managerIsAbleToDeleteItsOwnRatings() throws Exception { @@ -72,7 +73,7 @@ public class DeleteRatingSanityTests extends RestTest .assertNodeHasNoFiveStarRating(); } - @TestRail(section = {"rest-api", "ratings" }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Collaborator role is able to remove its own rating of a document") public void collaboratorIsAbleToDeleteItsOwnRatings() throws Exception { @@ -94,7 +95,7 @@ public class DeleteRatingSanityTests extends RestTest .assertNodeHasNoFiveStarRating(); } - @TestRail(section = {"rest-api", "ratings" }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Contributor role is able to remove its own rating of a document") public void contributorIsAbleToDeleteItsOwnRatings() throws Exception { @@ -116,7 +117,7 @@ public class DeleteRatingSanityTests extends RestTest .assertNodeHasNoFiveStarRating(); } - @TestRail(section = {"rest-api", "ratings" }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role is able to remove its own rating of a document") public void consumerIsAbleToDeleteItsOwnRatings() throws Exception { @@ -138,7 +139,7 @@ public class DeleteRatingSanityTests extends RestTest .assertNodeHasNoFiveStarRating(); } - @TestRail(section = {"rest-api", "ratings" }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify admin user is able to remove its own rating of a document") public void adminIsAbleToDeleteItsOwnRatings() throws Exception { @@ -160,7 +161,7 @@ public class DeleteRatingSanityTests extends RestTest .assertNodeHasNoFiveStarRating(); } - @TestRail(section = {"rest-api", "ratings" }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to remove its own rating of a document") public void unauthenticatedUserIsNotAbleToDeleteRatings() throws Exception { @@ -180,7 +181,7 @@ public class DeleteRatingSanityTests extends RestTest .assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } - @TestRail(section = {"rest-api", "ratings" }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify one user is not able to remove rating added by another user") @Bug(id = "ACE-5459") public void oneUserIsNotAbleToDeleteRatingsOfAnotherUser() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java index 9c930b6c7..01482d89f 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java @@ -9,6 +9,7 @@ import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; @@ -19,7 +20,7 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -@Test(groups = { "rest-api", "ratings", "sanity" }) +@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.COMMENTS }) public class GetRatingSanityTests extends RestTest { @Autowired @@ -49,7 +50,7 @@ public class GetRatingSanityTests extends RestTest document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); } - @TestRail(section = {"rest-api", "ratings" }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role is able to retrieve rating of a document") public void managerIsAbleToRetrieveRating() throws Exception { @@ -71,7 +72,7 @@ public class GetRatingSanityTests extends RestTest .assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = {"rest-api", "ratings" }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Collaborator role is able to retrieve rating of a document") public void collaboratorIsAbleToRetrieveRating() throws Exception { @@ -93,7 +94,7 @@ public class GetRatingSanityTests extends RestTest .assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = {"rest-api", "ratings" }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Contributor role is able to retrieve rating of a document") public void contributorIsAbleToRetrieveRating() throws Exception { @@ -115,7 +116,7 @@ public class GetRatingSanityTests extends RestTest .assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = {"rest-api", "ratings" }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role is able to retrieve rating of a document") public void consumerIsAbleToRetrieveRating() throws Exception { @@ -137,7 +138,7 @@ public class GetRatingSanityTests extends RestTest .assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = {"rest-api", "ratings" }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify admin user is able to retrieve rating of a document") public void adminIsAbleToRetrieveRating() throws Exception { @@ -160,7 +161,7 @@ public class GetRatingSanityTests extends RestTest .assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = {"rest-api", "ratings" }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to retrieve rating of a document") @Bug(id = "MNT-16904") public void unauthenticatedUserIsNotAbleToRetrieveRating() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java index 7cf0fedf8..d2c86b50d 100644 --- a/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java @@ -5,6 +5,7 @@ import org.alfresco.rest.requests.RestSitesApi; 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.report.Bug; import org.alfresco.utility.testrail.ExecutionType; @@ -14,7 +15,7 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { "rest-api", "sites", "sanity" }) +@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.COMMENTS }) public class AddSiteMemberSanityTests extends RestTest { @Autowired @@ -35,7 +36,7 @@ public class AddSiteMemberSanityTests extends RestTest } - @TestRail(section = {"rest-api", "sites" }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that manager is able to add site member and gets status code CREATED (201)") public void managerIsAbleToAddSiteMember() throws Exception { @@ -46,7 +47,7 @@ public class AddSiteMemberSanityTests extends RestTest siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } - @TestRail(section = {"rest-api", "sites" }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that site collaborator is not able to add site member and gets status code FORBIDDEN (403)") public void collaboratorIsNotAbleToAddSiteMember() throws Exception { @@ -57,7 +58,7 @@ public class AddSiteMemberSanityTests extends RestTest siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } - @TestRail(section = {"rest-api", "sites" }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that site contributor is not able to add site member and gets status code FORBIDDEN (403)") public void contributorIsNotAbleToAddSiteMember() throws Exception { @@ -68,7 +69,7 @@ public class AddSiteMemberSanityTests extends RestTest siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } - @TestRail(section = {"rest-api", "sites" }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that site consumer is not able to add site member and gets status code FORBIDDEN (403)") public void consumerIsNotAbleToAddSiteMember() throws Exception { @@ -79,7 +80,7 @@ public class AddSiteMemberSanityTests extends RestTest siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } - @TestRail(section = {"rest-api", "sites" }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that admin user is able to add site member and gets status code CREATED (201)") public void adminIsAbleToAddSiteMember() throws Exception { @@ -91,7 +92,7 @@ public class AddSiteMemberSanityTests extends RestTest } @Bug(id="MNT-16904") - @TestRail(section = {"rest-api", "sites" }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that unauthenticated user is not able to add site member") public void unauthenticatedUserIsNotAuthorizedToAddSiteMmeber() throws Exception{ UserModel testUser = dataUser.createRandomTestUser("testUser"); diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java index 8ddf9c3b3..29f2286e3 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java @@ -6,6 +6,7 @@ import org.alfresco.rest.requests.RestSitesApi; 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.report.Bug; import org.alfresco.utility.testrail.ExecutionType; @@ -18,7 +19,7 @@ import org.testng.annotations.Test; /** * @author iulia.cojocea */ -@Test(groups = { "rest-api", "sites", "sanity" }) +@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.COMMENTS }) public class GetSiteContainerSanityTests extends RestTest { @Autowired @@ -40,7 +41,7 @@ public class GetSiteContainerSanityTests extends RestTest UserRole.SiteContributor); } - @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role gets site container and gets status code OK (200)") public void getSiteContainerWithManagerRole() throws Exception { @@ -50,7 +51,7 @@ public class GetSiteContainerSanityTests extends RestTest siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify user with Collaborator role gets site container and gets status code OK (200)") public void getSiteContainerWithCollaboratorRole() throws Exception { @@ -60,7 +61,7 @@ public class GetSiteContainerSanityTests extends RestTest siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify user with Contributor role gets site container and gets status code OK (200)") public void getSiteContainerWithContributorRole() throws Exception { @@ -70,7 +71,7 @@ public class GetSiteContainerSanityTests extends RestTest siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role gets site container and gets status code OK (200)") public void getSiteContainerWithConsumerRole() throws Exception { @@ -80,7 +81,7 @@ public class GetSiteContainerSanityTests extends RestTest siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify user with admin user gets site container and gets status code OK (200)") public void getSiteContainerWithAdminUser() throws Exception { @@ -91,7 +92,7 @@ public class GetSiteContainerSanityTests extends RestTest } - @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Failed authentication get site container call returns status code 401") @Bug(id="MNT-16904") public void unauthenticatedUserIsNotAuthorizedToRetrieveSiteContainer() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java index 5782402f4..6f6dce146 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java @@ -8,6 +8,7 @@ import org.alfresco.utility.data.DataSite; import org.alfresco.utility.data.DataUser; 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.report.Bug; import org.alfresco.utility.testrail.ExecutionType; @@ -20,7 +21,7 @@ import org.testng.annotations.Test; /** * @author iulia.cojocea */ -@Test(groups = { "rest-api", "sites", "sanity" }) +@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.COMMENTS }) public class GetSiteContainersSanityTests extends RestTest { @Autowired @@ -46,7 +47,7 @@ public class GetSiteContainersSanityTests extends RestTest usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); } - @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role gets site containers and gets status code OK (200)") public void getSiteContainersWithManagerRole() throws JsonToModelConversionException, Exception { @@ -55,7 +56,7 @@ public class GetSiteContainersSanityTests extends RestTest siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = {"rest-api", "sites" }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify user with Collaborator role gets site containers and gets status code OK (200)") public void getSiteContainersWithCollaboratorRole() throws JsonToModelConversionException, Exception { @@ -64,7 +65,7 @@ public class GetSiteContainersSanityTests extends RestTest siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify user with Contributor role gets site containers and gets status code OK (200)") public void getSiteContainersWithContributorRole() throws JsonToModelConversionException, Exception { @@ -73,7 +74,7 @@ public class GetSiteContainersSanityTests extends RestTest siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role gets site containers and gets status code OK (200)") public void getSiteContainersWithConsumerRole() throws JsonToModelConversionException, Exception { @@ -82,7 +83,7 @@ public class GetSiteContainersSanityTests extends RestTest siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify user with Admin user gets site containers information and gets status code OK (200)") public void getSiteContainersWithAdminUser() throws JsonToModelConversionException, Exception { @@ -92,7 +93,7 @@ public class GetSiteContainersSanityTests extends RestTest } @Bug(id="MNT-16904") - @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Failed authentication get site containers call returns status code 401 with Manager role") public void unauthenticatedUserIsNotAuthorizedToRetrieveSiteContainers() throws JsonToModelConversionException, Exception { diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java index 0d7007111..7ac8041ff 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java @@ -7,6 +7,7 @@ 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.report.Bug; import org.alfresco.utility.testrail.ExecutionType; @@ -19,7 +20,7 @@ import org.testng.annotations.Test; /** * @author iulia.cojocea */ -@Test(groups = { "rest-api", "sites", "sanity" }) +@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.COMMENTS }) public class GetSiteMemberSanityTests extends RestTest { @@ -43,7 +44,7 @@ public class GetSiteMemberSanityTests extends RestTest dataUser.addUserToSite(userModel, siteModel, UserRole.SiteConsumer); } - @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.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 { @@ -52,7 +53,7 @@ public class GetSiteMemberSanityTests extends RestTest restSitesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify user with Collaborator role gets site member and gets status code OK (200)") public void getSiteMemberWithCollaboratorRole() throws Exception { @@ -61,7 +62,7 @@ public class GetSiteMemberSanityTests extends RestTest restSitesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify user with Contributor role gets site member and gets status code OK (200)") public void getSiteMemberWithContributorRole() throws Exception { @@ -70,7 +71,7 @@ public class GetSiteMemberSanityTests extends RestTest restSitesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role gets site member and gets status code OK (200)") public void getSiteMemberWithConsumerRole() throws Exception { @@ -79,7 +80,7 @@ public class GetSiteMemberSanityTests extends RestTest restSitesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify user with admin user gets site member and gets status code OK (200)") public void getSiteMemberWithAdminUser() throws Exception { @@ -88,7 +89,7 @@ public class GetSiteMemberSanityTests extends RestTest restSitesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.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") public void unauthenticatedUserIsNotAuthorizedToRetrieveSiteMember() throws JsonToModelConversionException, Exception diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java index e05fcd296..0c63197ea 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java @@ -9,6 +9,7 @@ import org.alfresco.utility.data.DataUser; 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.report.Bug; import org.alfresco.utility.testrail.ExecutionType; @@ -21,7 +22,7 @@ import org.testng.annotations.Test; /** * @author iulia.cojocea */ -@Test(groups = { "rest-api", "sites", "sanity" }) +@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.COMMENTS }) public class GetSiteMembersSanityTests extends RestTest { @Autowired @@ -47,7 +48,7 @@ public class GetSiteMembersSanityTests extends RestTest usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); } - @TestRail(section = {"rest-api", "sites" }, executionType = ExecutionType.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 JsonToModelConversionException, Exception { @@ -56,7 +57,7 @@ public class GetSiteMembersSanityTests extends RestTest siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = {"rest-api", "sites" }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify user with Collaborator role gets site members and gets status code OK (200)") public void getSiteMembersWithCollaboratorRole() throws JsonToModelConversionException, Exception { @@ -65,7 +66,7 @@ public class GetSiteMembersSanityTests extends RestTest siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = {"rest-api", "sites" }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify user with Contributor role gets site members and gets status code OK (200)") public void getSiteMembersWithContributorRole() throws JsonToModelConversionException, Exception { @@ -74,7 +75,7 @@ public class GetSiteMembersSanityTests extends RestTest siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = {"rest-api", "sites" }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role gets site members and gets status code OK (200)") public void getSiteMembersWithConsumerRole() throws JsonToModelConversionException, Exception { @@ -83,7 +84,7 @@ public class GetSiteMembersSanityTests extends RestTest siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = {"rest-api", "sites" }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify user with admin usere gets site members and gets status code OK (200)") public void getSiteMembersWithAdminUser() throws JsonToModelConversionException, Exception { @@ -93,7 +94,7 @@ public class GetSiteMembersSanityTests extends RestTest } @Bug(id="MNT-16904") - @TestRail(section = {"rest-api", "sites" }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Failed authentication get site members call returns status code 401") public void unauthenticatedUserIsNotAuthorizedToRetrieveSiteMembers() throws JsonToModelConversionException, Exception { diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteSanityTests.java index c7e8d7555..d6f5d6c72 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteSanityTests.java @@ -9,6 +9,7 @@ import org.alfresco.utility.data.DataUser; 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.report.Bug; import org.alfresco.utility.testrail.ExecutionType; @@ -22,7 +23,7 @@ import org.testng.annotations.Test; * @author iulia.cojocea */ -@Test(groups = { "rest-api", "sites", "sanity" }) +@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.COMMENTS }) public class GetSiteSanityTests extends RestTest { @Autowired @@ -49,7 +50,7 @@ public class GetSiteSanityTests extends RestTest usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); } - @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role gets site information and gets status code OK (200)") public void getSiteWithManagerRole() throws JsonToModelConversionException, Exception { @@ -58,7 +59,7 @@ public class GetSiteSanityTests extends RestTest siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify user with Collaborator role gets site information and gets status code OK (200)") public void getSiteWithCollaboratorRole() throws JsonToModelConversionException, Exception { @@ -67,7 +68,7 @@ public class GetSiteSanityTests extends RestTest siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify user with Contributor role gets site information and gets status code OK (200)") public void getSiteWithContributorRole() throws JsonToModelConversionException, Exception { @@ -76,7 +77,7 @@ public class GetSiteSanityTests extends RestTest siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role gets site information and gets status code OK (200)") public void getSiteWithConsumerRole() throws JsonToModelConversionException, Exception { @@ -85,7 +86,7 @@ public class GetSiteSanityTests extends RestTest siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify user with admin role gets site information and gets status code OK (200)") public void getSiteWithAdminRole() throws JsonToModelConversionException, Exception { @@ -95,7 +96,7 @@ public class GetSiteSanityTests extends RestTest } @Bug(id="MNT-16904") - @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Failed authentication get site call returns status code 401") public void unauthenticatedUserIsNotAuthorizedToRetrieveSite() throws JsonToModelConversionException, Exception { diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java index b1b759fac..5262aae4d 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java @@ -8,6 +8,7 @@ import org.alfresco.utility.data.DataSite; import org.alfresco.utility.data.DataUser; 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.report.Bug; import org.alfresco.utility.testrail.ExecutionType; @@ -20,7 +21,7 @@ import org.testng.annotations.Test; /** * @author iulia.cojocea */ -@Test(groups = { "rest-api", "sites", "sanity" }) +@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.COMMENTS }) public class GetSitesSanityTests extends RestTest { @Autowired @@ -47,7 +48,7 @@ public class GetSitesSanityTests extends RestTest usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); } - @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role gets sites information and gets status code OK (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role gets sites information and gets status code OK (200)") public void managerIsAbleToRetrieveSites() throws JsonToModelConversionException, Exception { @@ -56,7 +57,7 @@ public class GetSitesSanityTests extends RestTest siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify user with Collaborator role gets sites information and gets status code OK (200)") public void collaboratorIsAbleToRetrieveSites() throws JsonToModelConversionException, Exception { @@ -66,7 +67,7 @@ public class GetSitesSanityTests extends RestTest siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify user with Contributor role gets sites information and gets status code OK (200)") public void contributorIsAbleToRetrieveSites() throws JsonToModelConversionException, Exception { @@ -76,7 +77,7 @@ public class GetSitesSanityTests extends RestTest siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role gets sites information and gets status code OK (200)") public void consumerIsAbleToRetrieveSites() throws JsonToModelConversionException, Exception { @@ -86,7 +87,7 @@ public class GetSitesSanityTests extends RestTest siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify user with Admin user gets sites information and gets status code OK (200)") public void adminUserIsAbleToRetrieveSites() throws JsonToModelConversionException, Exception { @@ -96,7 +97,7 @@ public class GetSitesSanityTests extends RestTest } @Bug(id="MNT-16904") - @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Failed authentication get sites call returns status code 401") public void unauthenticatedUserIsNotAuthorizedToRetrieveSites() throws JsonToModelConversionException, Exception { diff --git a/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java index 6b3b1ec71..10848b847 100644 --- a/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java @@ -7,6 +7,7 @@ import org.alfresco.utility.data.DataUser; 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.report.Bug; import org.alfresco.utility.testrail.ExecutionType; @@ -20,7 +21,7 @@ import org.testng.annotations.Test; /** * @author iulia.cojocea */ -@Test(groups = {"rest-api", "sites", "sanity"}) +@Test(groups = {TestGroup.REST_API, TestGroup.SITES, TestGroup.COMMENTS}) public class RemoveSiteMemberSanityTests extends RestTest { @@ -50,7 +51,7 @@ public class RemoveSiteMemberSanityTests extends RestTest dataUser.addUserToSite(testUserModel, siteModel, UserRole.SiteConsumer); } - @TestRail(section = {"rest-api", "sites" }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that site manager can delete site member and gets status code 204, 'No Content'") public void siteManagerIsAbleToDeleteSiteMember() throws Exception{ restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); @@ -59,7 +60,7 @@ public class RemoveSiteMemberSanityTests extends RestTest } @Bug(id="ACE-5444") - @TestRail(section = {"rest-api", "sites" }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that site collaborator cannot delete site member and gets status code 403, 'Forbidden'") public void siteCollaboratorIsNotAbleToDeleteSiteMember() throws Exception{ restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); @@ -68,7 +69,7 @@ public class RemoveSiteMemberSanityTests extends RestTest } @Bug(id="ACE-5444") - @TestRail(section = {"rest-api", "sites" }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that site contributor cannot delete site member and gets status code 403, 'Forbidden'") public void siteContributorIsNotAbleToDeleteSiteMember() throws Exception{ restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); @@ -77,7 +78,7 @@ public class RemoveSiteMemberSanityTests extends RestTest } @Bug(id="ACE-5444") - @TestRail(section = {"rest-api", "sites" }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that site consumer cannot delete site member and gets status code 403, 'Forbidden'") public void siteConsumerIsNotAbleToDeleteSiteMember() throws Exception{ restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); @@ -85,7 +86,7 @@ public class RemoveSiteMemberSanityTests extends RestTest restSitesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } - @TestRail(section = {"rest-api", "sites" }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that admin user can delete site member and gets status code 204, 'No Content'") public void adminUserIsAbleToDeleteSiteMember() throws Exception{ restClient.authenticateUser(adminUserModel); @@ -93,7 +94,7 @@ public class RemoveSiteMemberSanityTests extends RestTest restSitesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); } - @TestRail(section = {"rest-api", "sites" }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that unauthenticated user is not able to delete site member") public void unauthenticatedUserIsNotAuthorizedToDeleteSiteMember() throws Exception{ UserModel inexistentUser = new UserModel("inexistent user", "inexistent password"); diff --git a/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java index caccec1ba..27f3cc6eb 100644 --- a/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java @@ -5,6 +5,7 @@ import org.alfresco.rest.requests.RestSitesApi; 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.report.Bug; import org.alfresco.utility.testrail.ExecutionType; @@ -14,7 +15,7 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { "rest-api", "sites", "sanity" }) +@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.COMMENTS }) public class UpdateSiteMemberSanityTests extends RestTest { @Autowired @@ -37,7 +38,7 @@ public class UpdateSiteMemberSanityTests extends RestTest dataUser.addUserToSite(testUserModel, siteModel, UserRole.SiteConsumer); } - @TestRail(section = {"rest-api", "sites" }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that manager is able to update site member and gets status code OK (200)") public void managerIsAbleToUpdateSiteMember() throws Exception { @@ -48,7 +49,7 @@ public class UpdateSiteMemberSanityTests extends RestTest } @Bug(id="ACE-5444") - @TestRail(section = {"rest-api", "sites" }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that collaborator is not able to update site member and gets status code FORBIDDEN (403)") public void collaboratorIsNotAbleToUpdateSiteMember() throws Exception { @@ -59,7 +60,7 @@ public class UpdateSiteMemberSanityTests extends RestTest } @Bug(id="ACE-5444") - @TestRail(section = {"rest-api", "sites" }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that contributor is not able to update site member and gets status code FORBIDDEN (403)") public void contributorIsNotAbleToUpdateSiteMember() throws Exception { @@ -70,7 +71,7 @@ public class UpdateSiteMemberSanityTests extends RestTest } @Bug(id="ACE-5444") - @TestRail(section = {"rest-api", "sites" }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that consumer is not able to update site member and gets status code FORBIDDEN (403)") public void consumerIsNotAbleToUpdateSiteMember() throws Exception { @@ -80,7 +81,7 @@ public class UpdateSiteMemberSanityTests extends RestTest siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } - @TestRail(section = {"rest-api", "sites" }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that admin is able to update site member and gets status code OK (200)") public void adminIsAbleToUpdateSiteMember() throws Exception { @@ -91,7 +92,7 @@ public class UpdateSiteMemberSanityTests extends RestTest } @Bug(id="MNT-16904") - @TestRail(section = {"rest-api", "sites" }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that unauthenticated user is not able to update site member") public void unauthenticatedUserIsNotAuthorizedToUpdateSiteMmeber() throws Exception{ UserModel inexistentUser = new UserModel("inexistent user", "inexistent password"); diff --git a/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java index db6cfa66e..45e1ca2c6 100644 --- a/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java @@ -9,6 +9,7 @@ import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.RandomData; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; @@ -22,7 +23,7 @@ import org.testng.annotations.Test; /** * Created by Claudia Agache on 10/3/2016. */ -@Test(groups = { "rest-api", "tags", "sanity" }) +@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.COMMENTS }) public class AddTagSanityTests extends RestTest { @Autowired @@ -55,8 +56,8 @@ public class AddTagSanityTests extends RestTest tagValue = RandomData.getRandomName("tag"); } - @TestRail(section = { "rest-api", - "tags" }, executionType = ExecutionType.SANITY, description = "Verify admin user adds tags with Rest API and status code is 201") + @TestRail(section = { TestGroup.REST_API, + TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify admin user adds tags with Rest API and status code is 201") public void adminIsAbleToAddTag() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); @@ -65,8 +66,8 @@ public class AddTagSanityTests extends RestTest } - @TestRail(section = { "rest-api", - "tags" }, executionType = ExecutionType.SANITY, description = "Verify Manager user adds tags with Rest API and status code is 201") + @TestRail(section = { TestGroup.REST_API, + TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Manager user adds tags with Rest API and status code is 201") public void managerIsAbleToAddTag() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); @@ -74,8 +75,8 @@ public class AddTagSanityTests extends RestTest tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } - @TestRail(section = { "rest-api", - "tags" }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user adds tags with Rest API and status code is 201") + @TestRail(section = { TestGroup.REST_API, + TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user adds tags with Rest API and status code is 201") public void collaboratorIsAbleToAddTag() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); @@ -83,8 +84,8 @@ public class AddTagSanityTests extends RestTest tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } - @TestRail(section = { "rest-api", - "tags" }, executionType = ExecutionType.SANITY, description = "Verify Contributor user doesn't have permission to add tags with Rest API and status code is 403") + @TestRail(section = { TestGroup.REST_API, + TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Contributor user doesn't have permission to add tags with Rest API and status code is 403") public void contributorIsNotAbleToAddTagToAnotherContent() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); @@ -92,8 +93,8 @@ public class AddTagSanityTests extends RestTest tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } - @TestRail(section = { "rest-api", - "tags" }, executionType = ExecutionType.SANITY, description = "Verify Contributor user adds tags to his content with Rest API and status code is 201") + @TestRail(section = { TestGroup.REST_API, + TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Contributor user adds tags to his content with Rest API and status code is 201") public void contributorIsAbleToAddTagToHisContent() throws JsonToModelConversionException, Exception { userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); @@ -103,8 +104,8 @@ public class AddTagSanityTests extends RestTest tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } - @TestRail(section = { "rest-api", - "tags" }, executionType = ExecutionType.SANITY, description = "Verify Consumer user doesn't have permission to add tags with Rest API and status code is 403") + @TestRail(section = { TestGroup.REST_API, + TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Consumer user doesn't have permission to add tags with Rest API and status code is 403") public void consumerIsNotAbleToAddTag() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); @@ -112,8 +113,8 @@ public class AddTagSanityTests extends RestTest tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } - @TestRail(section = { "rest-api", - "tags" }, executionType = ExecutionType.SANITY, description = "Verify Manager user gets status code 401 if authentication call fails") + @TestRail(section = { TestGroup.REST_API, + TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Manager user gets status code 401 if authentication call fails") @Bug(id="MNT-16904") public void managerIsNotAbleToAddTagIfAuthenticationFails() throws JsonToModelConversionException, Exception { diff --git a/e2e-test/java/org/alfresco/rest/tags/AddTagsSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/AddTagsSanityTests.java index 1e4a439e5..a12a11918 100644 --- a/e2e-test/java/org/alfresco/rest/tags/AddTagsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/AddTagsSanityTests.java @@ -9,6 +9,7 @@ import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.RandomData; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; @@ -22,7 +23,7 @@ import org.testng.annotations.Test; /** * Created by Claudia Agache on 10/7/2016. */ -@Test(groups = { "rest-api", "tags", "sanity" }) +@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.COMMENTS }) public class AddTagsSanityTests extends RestTest { @Autowired @@ -56,8 +57,8 @@ public class AddTagsSanityTests extends RestTest tag2 = RandomData.getRandomName("tag"); } - @TestRail(section = { "rest-api", - "tags" }, executionType = ExecutionType.SANITY, description = "Verify admin user adds multiple tags with Rest API and status code is 201") + @TestRail(section = { TestGroup.REST_API, + TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify admin user adds multiple tags with Rest API and status code is 201") public void adminIsAbleToAddTags() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); @@ -65,8 +66,8 @@ public class AddTagsSanityTests extends RestTest tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } - @TestRail(section = { "rest-api", - "tags" }, executionType = ExecutionType.SANITY, description = "Verify Manager user adds multiple tags with Rest API and status code is 201") + @TestRail(section = { TestGroup.REST_API, + TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Manager user adds multiple tags with Rest API and status code is 201") public void managerIsAbleToAddTags() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); @@ -74,8 +75,8 @@ public class AddTagsSanityTests extends RestTest tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } - @TestRail(section = { "rest-api", - "tags" }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user adds multiple tags with Rest API and status code is 201") + @TestRail(section = { TestGroup.REST_API, + TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user adds multiple tags with Rest API and status code is 201") public void collaboratorIsAbleToAddTags() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); @@ -83,8 +84,8 @@ public class AddTagsSanityTests extends RestTest tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } - @TestRail(section = { "rest-api", - "tags" }, executionType = ExecutionType.SANITY, description = "Verify Contributor user doesn't have permission to add multiple tags with Rest API and status code is 403") + @TestRail(section = { TestGroup.REST_API, + TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Contributor user doesn't have permission to add multiple tags with Rest API and status code is 403") public void contributorIsNotAbleToAddTagsToAnotherContent() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); @@ -92,8 +93,8 @@ public class AddTagsSanityTests extends RestTest tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } - @TestRail(section = { "rest-api", - "tags" }, executionType = ExecutionType.SANITY, description = "Verify Contributor user adds multiple tags to his content with Rest API and status code is 201") + @TestRail(section = { TestGroup.REST_API, + TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Contributor user adds multiple tags to his content with Rest API and status code is 201") public void contributorIsAbleToAddTagsToHisContent() throws JsonToModelConversionException, Exception { userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); @@ -103,8 +104,8 @@ public class AddTagsSanityTests extends RestTest tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } - @TestRail(section = { "rest-api", - "tags" }, executionType = ExecutionType.SANITY, description = "Verify Consumer user doesn't have permission to add multiple tags with Rest API and status code is 403") + @TestRail(section = { TestGroup.REST_API, + TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Consumer user doesn't have permission to add multiple tags with Rest API and status code is 403") public void consumerIsNotAbleToAddTags() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); @@ -112,8 +113,8 @@ public class AddTagsSanityTests extends RestTest tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } - @TestRail(section = { "rest-api", - "tags" }, executionType = ExecutionType.SANITY, description = "Verify Manager user gets status code 401 if authentication call fails") + @TestRail(section = { TestGroup.REST_API, + TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Manager user gets status code 401 if authentication call fails") @Bug(id="MNT-16904") public void managerIsNotAbleToAddTagsIfAuthenticationFails() throws JsonToModelConversionException, Exception { diff --git a/e2e-test/java/org/alfresco/rest/tags/DeleteTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/DeleteTagSanityTests.java index 6ce9fe0e1..b8c906b58 100644 --- a/e2e-test/java/org/alfresco/rest/tags/DeleteTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/DeleteTagSanityTests.java @@ -9,6 +9,7 @@ import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; @@ -20,7 +21,7 @@ import org.testng.annotations.Test; /** * Created by Claudia Agache on 10/4/2016. */ -@Test(groups = { "rest-api", "tags", "sanity" }) +@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.COMMENTS }) public class DeleteTagSanityTests extends RestTest { @Autowired @@ -45,8 +46,8 @@ public class DeleteTagSanityTests extends RestTest tagsAPI.useRestClient(restClient); } - @TestRail(section = { "rest-api", - "tags" }, executionType = ExecutionType.SANITY, description = "Verify Admin user deletes tags with Rest API and status code is 204") + @TestRail(section = { TestGroup.REST_API, + TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Admin user deletes tags with Rest API and status code is 204") public void adminIsAbleToDeleteTags() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); @@ -56,8 +57,8 @@ public class DeleteTagSanityTests extends RestTest tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); } - @TestRail(section = { "rest-api", - "tags" }, executionType = ExecutionType.SANITY, description = "Verify Manager user deletes tags created by admin user with Rest API and status code is 204") + @TestRail(section = { TestGroup.REST_API, + TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Manager user deletes tags created by admin user with Rest API and status code is 204") public void managerIsAbleToDeleteTags() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); @@ -68,8 +69,8 @@ public class DeleteTagSanityTests extends RestTest tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); } - @TestRail(section = { "rest-api", - "tags" }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user deletes tags created by admin user with Rest API and status code is 204") + @TestRail(section = { TestGroup.REST_API, + TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user deletes tags created by admin user with Rest API and status code is 204") public void collaboratorIsAbleToDeleteTags() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); @@ -80,7 +81,7 @@ public class DeleteTagSanityTests extends RestTest tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); } - @TestRail(section = { "rest-api", "tags" }, + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Contributor user can't delete tags created by admin user with Rest API and status code is 403") public void contributorIsNotAbleToDeleteTagsForAnotherUserContent() throws JsonToModelConversionException, Exception { @@ -92,8 +93,8 @@ public class DeleteTagSanityTests extends RestTest tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } - @TestRail(section = { "rest-api", - "tags" }, executionType = ExecutionType.SANITY, description = "Verify Contributor user deletes tags created by him with Rest API and status code is 204") + @TestRail(section = { TestGroup.REST_API, + TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Contributor user deletes tags created by him with Rest API and status code is 204") public void contributorIsAbleToDeleteTagsForHisContent() throws JsonToModelConversionException, Exception { userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); @@ -104,8 +105,8 @@ public class DeleteTagSanityTests extends RestTest tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); } - @TestRail(section = { "rest-api", - "tags" }, executionType = ExecutionType.SANITY, description = "Verify Consumer user can't delete tags created by admin user with Rest API and status code is 403") + @TestRail(section = { TestGroup.REST_API, + TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Consumer user can't delete tags created by admin user with Rest API and status code is 403") public void consumerIsNotAbleToDeleteTags() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); @@ -116,8 +117,8 @@ public class DeleteTagSanityTests extends RestTest tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } - @TestRail(section = { "rest-api", - "tags" }, executionType = ExecutionType.SANITY, description = "Verify Manager user gets status code 401 if authentication call fails") + @TestRail(section = { TestGroup.REST_API, + TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Manager user gets status code 401 if authentication call fails") public void managerIsNotAbleToDeleteTagIfAuthenticationFails() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); diff --git a/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java index fac8e59aa..f08461656 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java @@ -6,10 +6,11 @@ import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.requests.RestTagsApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; -import org.alfresco.utility.data.RandomData; import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.data.RandomData; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; @@ -19,7 +20,7 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { "rest-api", "tags", "sanity" }) +@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.COMMENTS }) public class GetNodeTagsSanityTests extends RestTest { @Autowired @@ -53,7 +54,7 @@ public class GetNodeTagsSanityTests extends RestTest tagsAPI.addTag(document, tagValue); } - @TestRail(section = { "rest-api", "tags" }, + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify site Manager is able to get node tags") public void siteManagerIsAbleToRetrieveNodeTags() throws JsonToModelConversionException, Exception { @@ -67,7 +68,7 @@ public class GetNodeTagsSanityTests extends RestTest .assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "tags" }, + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify site Collaborator is able to get node tags") public void siteCollaboratorIsAbleToRetrieveNodeTags() throws JsonToModelConversionException, Exception { @@ -80,7 +81,7 @@ public class GetNodeTagsSanityTests extends RestTest .assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "tags" }, + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify site Contributor is able to get node tags") public void siteContributorIsAbleToRetrieveNodeTags() throws JsonToModelConversionException, Exception { @@ -91,7 +92,7 @@ public class GetNodeTagsSanityTests extends RestTest .assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "tags" }, + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify site Consumer is able to get node tags") public void siteConsumerIsAbleToRetrieveNodeTags() throws JsonToModelConversionException, Exception { @@ -102,7 +103,7 @@ public class GetNodeTagsSanityTests extends RestTest .assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "tags" }, + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify admin is able to get node tags") public void adminIsAbleToRetrieveNodeTags() throws JsonToModelConversionException, Exception { @@ -113,7 +114,7 @@ public class GetNodeTagsSanityTests extends RestTest .assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "tags" }, + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to get node tags") @Bug(id="MNT-16904") public void unauthenticatedUserIsNotAbleToRetrieveNodeTags() throws JsonToModelConversionException, Exception diff --git a/e2e-test/java/org/alfresco/rest/tags/GetTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagSanityTests.java index e76a13e0c..8fdc23e67 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetTagSanityTests.java @@ -11,6 +11,7 @@ import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.data.RandomData; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; @@ -19,7 +20,7 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { "rest-api", "tags", "sanity" }) +@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.COMMENTS }) public class GetTagSanityTests extends RestTest { @@ -47,7 +48,7 @@ public class GetTagSanityTests extends RestTest } - @TestRail(section = { "rest-api", "tags" }, executionType = ExecutionType.SANITY, description = "Verify admin user gets tag using REST API and status code is OK (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify admin user gets tag using REST API and status code is OK (200)") public void userWithAdminIsAbletoGetTag() throws JsonToModelConversionException, Exception { String tagValue = RandomData.getRandomName("tag"); @@ -59,7 +60,7 @@ public class GetTagSanityTests extends RestTest } - @TestRail(section = { "rest-api", "tags" }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role gets tag using REST API and status code is OK (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role gets tag using REST API and status code is OK (200)") public void userWithManagerRoleIsAbletoGetTag() throws JsonToModelConversionException, Exception { String tagValue = RandomData.getRandomName("tag"); @@ -70,7 +71,7 @@ public class GetTagSanityTests extends RestTest tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "tags" }, executionType = ExecutionType.SANITY, description = "Verify user with Collaborator role gets tag using REST API and status code is OK (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user with Collaborator role gets tag using REST API and status code is OK (200)") public void userWithCollaboratorRoleIsAbletoGetTag() throws JsonToModelConversionException, Exception { String tagValue = RandomData.getRandomName("tag"); @@ -81,7 +82,7 @@ public class GetTagSanityTests extends RestTest tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "tags" }, executionType = ExecutionType.SANITY, description = "Verify user with Contributor role gets tag using REST API and status code is OK (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user with Contributor role gets tag using REST API and status code is OK (200)") public void userWithContributorRoleIsAbletoGetTag() throws JsonToModelConversionException, Exception { String tagValue = RandomData.getRandomName("tag"); @@ -94,7 +95,7 @@ public class GetTagSanityTests extends RestTest } - @TestRail(section = { "rest-api", "tags" }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role gets tag using REST API and status code is OK (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role gets tag using REST API and status code is OK (200)") public void userWithConsumerRoleIsAbletoGetTag() throws JsonToModelConversionException, Exception { String tagValue = RandomData.getRandomName("tag"); @@ -106,7 +107,7 @@ public class GetTagSanityTests extends RestTest tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "tags" }, executionType = ExecutionType.SANITY, description = "Verify Manager user gets status code 401 if authentication call fails") + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Manager user gets status code 401 if authentication call fails") public void managerIsNotAbleToGetTagIfAuthenticationFails() throws JsonToModelConversionException, Exception { String tagValue = RandomData.getRandomName("tag"); diff --git a/e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java index 4b6f7d7f2..d016f7deb 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java @@ -7,6 +7,7 @@ import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; 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.report.Bug; import org.alfresco.utility.testrail.ExecutionType; @@ -16,7 +17,7 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { "rest-api", "tags", "sanity" }) +@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.COMMENTS }) public class GetTagsSanityTests extends RestTest { @Autowired @@ -41,7 +42,7 @@ public class GetTagsSanityTests extends RestTest } - @TestRail(section = { "rest-api", "tags" }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role gets tags using REST API and status code is OK (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role gets tags using REST API and status code is OK (200)") public void getTagsWithManagerRole() throws JsonToModelConversionException, Exception { @@ -50,7 +51,7 @@ public class GetTagsSanityTests extends RestTest tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "tags" }, executionType = ExecutionType.SANITY, description = "Verify user with Collaborator role gets tags using REST API and status code is OK (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user with Collaborator role gets tags using REST API and status code is OK (200)") public void getTagsWithCollaboratorRole() throws JsonToModelConversionException, Exception { @@ -59,7 +60,7 @@ public class GetTagsSanityTests extends RestTest tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "tags" }, executionType = ExecutionType.SANITY, description = "Verify user with Contributor role gets tags using REST API and status code is OK (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user with Contributor role gets tags using REST API and status code is OK (200)") public void getTagsWithContributorRole() throws JsonToModelConversionException, Exception { @@ -68,7 +69,7 @@ public class GetTagsSanityTests extends RestTest tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "tags" }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role gets tags using REST API and status code is OK (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role gets tags using REST API and status code is OK (200)") public void getTagsWithConsumerRole() throws JsonToModelConversionException, Exception { @@ -77,7 +78,7 @@ public class GetTagsSanityTests extends RestTest tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "tags" }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets tags using REST API and status code is OK (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets tags using REST API and status code is OK (200)") public void getTagsWithAdminUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); @@ -85,7 +86,7 @@ public class GetTagsSanityTests extends RestTest tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "tags" }, executionType = ExecutionType.SANITY, description = "Failed authentication get tags call returns status code 401 with Manager role") + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Failed authentication get tags call returns status code 401 with Manager role") @Bug(id = "MNT-16904") public void getTagsWithManagerRoleFailedAuth() throws JsonToModelConversionException, Exception { diff --git a/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java index ac0d1f9ae..1e8ae61e2 100644 --- a/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java @@ -10,6 +10,7 @@ import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.RandomData; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; @@ -23,7 +24,7 @@ import org.testng.annotations.Test; /** * Created by Claudia Agache on 10/4/2016. */ -@Test(groups = { "rest-api", "tags", "sanity" }) +@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.COMMENTS }) public class UpdateTagSanityTests extends RestTest { @Autowired RestTagsApi tagsAPI; @@ -55,7 +56,7 @@ public class UpdateTagSanityTests extends RestTest randomTag = RandomData.getRandomName("tag"); } - @TestRail(section = { "rest-api", "tags" }, executionType = ExecutionType.SANITY, description = "Verify Admin user updates tags and status code is 200") + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Admin user updates tags and status code is 200") @Bug(id="MNT-16917") public void adminIsAbleToUpdateTags() throws JsonToModelConversionException, Exception { @@ -63,8 +64,8 @@ public class UpdateTagSanityTests extends RestTest tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", - "tags" }, executionType = ExecutionType.SANITY, description = "Verify Manager user can't update tags with Rest API and status code is 403") + @TestRail(section = { TestGroup.REST_API, + TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Manager user can't update tags with Rest API and status code is 403") public void managerIsNotAbleToUpdateTag() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); @@ -72,8 +73,8 @@ public class UpdateTagSanityTests extends RestTest tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } - @TestRail(section = { "rest-api", - "tags" }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user can't update tags with Rest API and status code is 403") + @TestRail(section = { TestGroup.REST_API, + TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user can't update tags with Rest API and status code is 403") public void collaboratorIsNotAbleToUpdateTag() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); @@ -81,8 +82,8 @@ public class UpdateTagSanityTests extends RestTest tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } - @TestRail(section = { "rest-api", - "tags" }, executionType = ExecutionType.SANITY, description = "Verify Contributor user can't update tags with Rest API and status code is 403") + @TestRail(section = { TestGroup.REST_API, + TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Contributor user can't update tags with Rest API and status code is 403") public void contributorIsNotAbleToUpdateTag() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); @@ -90,8 +91,8 @@ public class UpdateTagSanityTests extends RestTest tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } - @TestRail(section = { "rest-api", - "tags" }, executionType = ExecutionType.SANITY, description = "Verify Consumer user can't update tags with Rest API and status code is 403") + @TestRail(section = { TestGroup.REST_API, + TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Consumer user can't update tags with Rest API and status code is 403") public void consumerIsNotAbleToUpdateTag() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); @@ -99,8 +100,8 @@ public class UpdateTagSanityTests extends RestTest tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } - @TestRail(section = { "rest-api", - "tags" }, executionType = ExecutionType.SANITY, description = "Verify Manager user gets status code 401 if authentication call fails") + @TestRail(section = { TestGroup.REST_API, + TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Manager user gets status code 401 if authentication call fails") @Bug(id="MNT-16904") public void managerIsNotAbleToUpdateTagIfAuthenticationFails() throws JsonToModelConversionException, Exception { diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsSanityTests.java index 1683e2c2f..2878d4e2a 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsSanityTests.java @@ -5,6 +5,7 @@ import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.requests.RestDeploymentsApi; import org.alfresco.rest.requests.RestTenantApi; import org.alfresco.utility.data.DataUser; +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; @@ -16,7 +17,7 @@ import org.testng.annotations.Test; /** * Created by Claudia Agache on 10/4/2016. */ -@Test(groups = { "rest-api", "deployments", "sanity" }) +@Test(groups = { TestGroup.REST_API, "deployments", TestGroup.COMMENTS, TestGroup.NETWORKS }) public class GetDeploymentsSanityTests extends RestWorkflowTest { @Autowired @@ -37,8 +38,7 @@ public class GetDeploymentsSanityTests extends RestWorkflowTest deploymentsApi.useRestClient(restClient); } - // works on docker - @TestRail(section = { "rest-api", + @TestRail(section = { TestGroup.REST_API, "deployments" }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets non-network deployments using REST API and status code is OK (200)") public void getNonNetworkDeploymentsWithAdmin() throws JsonToModelConversionException, Exception { @@ -47,11 +47,8 @@ public class GetDeploymentsSanityTests extends RestWorkflowTest deploymentsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - // works on alfresco.server=172.29.100.215 - @TestRail(section = { "rest-api", + @TestRail(section = { TestGroup.REST_API, "deployments" }, executionType = ExecutionType.SANITY, description = "Verify Tenant Admin user gets network deployments using REST API and status code is OK (200)") - - @Test(groups = { "networks" }) public void getNetworkDeploymentsWithAdmin() throws JsonToModelConversionException, Exception { tenantApi.useRestClient(restClient); diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java index 0765f427d..d9980d2b7 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java @@ -4,6 +4,7 @@ import org.alfresco.rest.RestWorkflowTest; import org.alfresco.rest.model.RestProcessDefinitionModel; import org.alfresco.rest.requests.RestProcessDefinitionsApi; import org.alfresco.utility.data.DataUser; +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; @@ -15,40 +16,38 @@ import org.testng.annotations.Test; /** * Created by Claudia Agache on 10/13/2016. */ -@Test(groups = { "rest-api", "process-definitions", "sanity" }) -public class GetProcessDefinitionImageSanityTests extends RestWorkflowTest -{ - @Autowired - private DataUser dataUser; - @Autowired - private RestProcessDefinitionsApi processDefinitionsApi; +@Test(groups = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION, TestGroup.COMMENTS }) +public class GetProcessDefinitionImageSanityTests extends RestWorkflowTest { + @Autowired + private DataUser dataUser; + @Autowired + private RestProcessDefinitionsApi processDefinitionsApi; - private UserModel testUser; - private RestProcessDefinitionModel randomProcessDefinition; + private UserModel testUser; + private RestProcessDefinitionModel randomProcessDefinition; - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - testUser = dataUser.createRandomTestUser(); - processDefinitionsApi.useRestClient(restClient); - restClient.authenticateUser(dataUser.getAdminUser()); - randomProcessDefinition = processDefinitionsApi.getProcessDefinitions().getOneRandomEntry(); - } + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception { + testUser = dataUser.createRandomTestUser(); + processDefinitionsApi.useRestClient(restClient); + restClient.authenticateUser(dataUser.getAdminUser()); + randomProcessDefinition = processDefinitionsApi.getProcessDefinitions().getOneRandomEntry(); + } - @TestRail(section = { "rest-api", "process-definitions" }, - executionType = ExecutionType.SANITY, description = "Verify Any user gets a specific process definition image for non-network deployments using REST API and status code is OK (200)") - public void anyUserGetsProcessDefinitionImage() throws Exception - { - restClient.authenticateUser(testUser); - processDefinitionsApi.getProcessDefinitionImage(randomProcessDefinition).assertResponseContainsImage(); - processDefinitionsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); - } + @TestRail(section = { TestGroup.REST_API, + TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.SANITY, description = "Verify Any user gets a specific process definition image for non-network deployments using REST API and status code is OK (200)") + public void anyUserGetsProcessDefinitionImage() throws Exception { + restClient.authenticateUser(testUser); + processDefinitionsApi.getProcessDefinitionImage(randomProcessDefinition) + .assertResponseContainsImage(); + processDefinitionsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } - @TestRail(section = { "rest-api", "process-definitions" }, - executionType = ExecutionType.SANITY, description = "Verify Admin user gets a specific process definition image for non-network deployments using REST API and status code is OK (200)") - public void adminGetsProcessDefinitionImage() throws Exception - { - processDefinitionsApi.getProcessDefinitionImage(randomProcessDefinition).assertResponseContainsImage(); - processDefinitionsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); - } + @TestRail(section = { TestGroup.REST_API, + TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets a specific process definition image for non-network deployments using REST API and status code is OK (200)") + public void adminGetsProcessDefinitionImage() throws Exception { + processDefinitionsApi.getProcessDefinitionImage(randomProcessDefinition) + .assertResponseContainsImage(); + processDefinitionsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java index e6d624253..97d97b98a 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java @@ -4,6 +4,7 @@ import org.alfresco.rest.RestWorkflowTest; import org.alfresco.rest.model.RestProcessDefinitionModel; import org.alfresco.rest.requests.RestProcessDefinitionsApi; import org.alfresco.utility.data.DataUser; +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; @@ -15,7 +16,7 @@ import org.testng.annotations.Test; /** * Created by Claudia Agache on 10/13/2016. */ -@Test(groups = { "rest-api", "process-definitions", "sanity" }) +@Test(groups = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION, TestGroup.COMMENTS }) public class GetProcessDefinitionSanityTests extends RestWorkflowTest { @Autowired @@ -35,7 +36,7 @@ public class GetProcessDefinitionSanityTests extends RestWorkflowTest randomProcessDefinition = processDefinitionsApi.getProcessDefinitions().getOneRandomEntry(); } - @TestRail(section = { "rest-api", "process-definitions" }, + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets a specific process definition for non-network deployments using REST API and status code is OK (200)") public void adminGetsProcessDefinition() throws Exception @@ -44,7 +45,7 @@ public class GetProcessDefinitionSanityTests extends RestWorkflowTest processDefinitionsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "process-definitions" }, + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.SANITY, description = "Verify Any user gets a specific process definition for non-network deployments using REST API and status code is OK (200)") public void anyUserGetsProcessDefinition() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java index b83eec472..1528350f4 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java @@ -4,6 +4,7 @@ import org.alfresco.rest.RestWorkflowTest; import org.alfresco.rest.requests.RestProcessDefinitionsApi; import org.alfresco.rest.requests.RestTenantApi; import org.alfresco.utility.data.DataUser; +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; @@ -15,7 +16,7 @@ import org.testng.annotations.Test; /** * Created by Claudia Agache on 10/13/2016. */ -@Test(groups = { "rest-api", "process-definitions", "sanity" }) +@Test(groups = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION, TestGroup.COMMENTS }) public class GetProcessDefinitionsSanityTests extends RestWorkflowTest { @Autowired @@ -37,7 +38,7 @@ public class GetProcessDefinitionsSanityTests extends RestWorkflowTest } // works on docker - @TestRail(section = { "rest-api", "process-definitions" }, + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets process definitions for non-network deployments using REST API and status code is OK (200)") public void nonNetworkAdminGetsProcessDefinitions() throws Exception { @@ -47,10 +48,10 @@ public class GetProcessDefinitionsSanityTests extends RestWorkflowTest } // works on alfresco.server=172.29.100.215 - @TestRail(section = { "rest-api", "process-definitions" }, + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.SANITY, description = "Verify Tenant Admin user gets process definitions for network deployments using REST API and status code is OK (200)") - @Test(groups = { "networks" }) + @Test(groups = { TestGroup.NETWORKS }) public void networkAdminGetsProcessDefinitions() throws Exception { tenantApi.useRestClient(restClient); diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java index 13eb59b47..4dc749e68 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java @@ -11,6 +11,7 @@ import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.RandomData; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; @@ -22,7 +23,7 @@ import org.testng.annotations.Test; /** * @author iulia.cojocea */ -@Test(groups = { "rest-api", "processes", "sanity" }) +@Test(groups = { TestGroup.REST_API, "processes", TestGroup.COMMENTS }) public class AddProcessVariableSanityTests extends RestWorkflowTest { @Autowired @@ -52,7 +53,7 @@ public class AddProcessVariableSanityTests extends RestWorkflowTest processesApi.useRestClient(restClient); } - @TestRail(section = {"rest-api", "processes" }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, "processes" }, executionType = ExecutionType.SANITY, description = "Create non-existing variable") public void addProcessVariable() throws JsonToModelConversionException, Exception { @@ -63,7 +64,7 @@ public class AddProcessVariableSanityTests extends RestWorkflowTest processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } - @TestRail(section = {"rest-api", "processes" }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, "processes" }, executionType = ExecutionType.SANITY, description = "Update existing variable") public void updateExistingProcessVariable() throws JsonToModelConversionException, Exception { @@ -76,8 +77,8 @@ public class AddProcessVariableSanityTests extends RestWorkflowTest processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } - @Test(groups = { "networks" }) - @TestRail(section = {"rest-api", "processes" }, executionType = ExecutionType.SANITY, + @Test(groups = { TestGroup.NETWORKS }) + @TestRail(section = {TestGroup.REST_API, "processes" }, executionType = ExecutionType.SANITY, description = "Add process variable using admin user from same network") public void addProcessVariableByAdmin() throws JsonToModelConversionException, Exception { @@ -100,7 +101,7 @@ public class AddProcessVariableSanityTests extends RestWorkflowTest processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } - @TestRail(section = {"rest-api", "processes" }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, "processes" }, executionType = ExecutionType.SANITY, description = "Adding process variable is falling in case invalid variableBody is provided") public void failedAddingProcessVariableIfInvalidBodyIsProvided() throws JsonToModelConversionException, Exception { diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java index aa20eb22b..819835f72 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java @@ -7,6 +7,7 @@ import org.alfresco.utility.data.DataUser; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TaskModel; +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; @@ -19,7 +20,7 @@ import org.testng.annotations.Test; /** * Created by Claudia Agache on 10/12/2016. */ -@Test(groups = { "rest-api", "processes", "sanity" }) +@Test(groups = { TestGroup.REST_API, "processes", TestGroup.COMMENTS }) public class DeleteProcessSanityTests extends RestWorkflowTest { @Autowired @@ -50,7 +51,7 @@ public class DeleteProcessSanityTests extends RestWorkflowTest task = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); } - @TestRail(section = { "rest-api", + @TestRail(section = { TestGroup.REST_API, "processes" }, executionType = ExecutionType.SANITY, description = "Verify User is able to delete process started by him using REST API and status code is OK (204)") public void deleteProcessByUserWhoStartedProcess() throws Exception { @@ -60,7 +61,7 @@ public class DeleteProcessSanityTests extends RestWorkflowTest processesApi.getProcesses().assertProcessDoesNotExist(task); } - @TestRail(section = { "rest-api", + @TestRail(section = { TestGroup.REST_API, "processes" }, executionType = ExecutionType.SANITY, description = "Verify User is able to delete process assigned to him using REST API and status code is OK (204)") public void deleteProcessByAssignedUser() throws Exception { @@ -70,7 +71,7 @@ public class DeleteProcessSanityTests extends RestWorkflowTest processesApi.getProcesses().assertProcessDoesNotExist(task); } - @TestRail(section = { "rest-api", + @TestRail(section = { TestGroup.REST_API, "processes" }, executionType = ExecutionType.SANITY, description = "Verify User that is not involved in a process is not authorized to delete it using REST API and status code is 403") public void deleteProcessByAnotherUser() throws Exception { diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsSanityTests.java index 9ae18c912..9bc76022b 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsSanityTests.java @@ -9,6 +9,7 @@ import org.alfresco.rest.requests.RestTenantApi; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; @@ -21,7 +22,7 @@ import org.testng.annotations.Test; * @author iulia.cojocea */ -@Test(groups = { "rest-api", "processes", "sanity" }) +@Test(groups = { TestGroup.REST_API, "processes", TestGroup.COMMENTS }) public class GetProcessItemsSanityTests extends RestWorkflowTest { @Autowired @@ -51,7 +52,7 @@ public class GetProcessItemsSanityTests extends RestWorkflowTest processesApi.useRestClient(restClient); } - @TestRail(section = {"rest-api", "processes" }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, "processes" }, executionType = ExecutionType.SANITY, description = "Verify that user that started the process gets all process items") public void getProcessItemsUsingTheUserWhoStartedProcess() throws JsonToModelConversionException, Exception { @@ -61,7 +62,7 @@ public class GetProcessItemsSanityTests extends RestWorkflowTest processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "processes" }, executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API, "processes" }, executionType = ExecutionType.SANITY, description = "Verify that user that is involved in the process gets all process items") public void getProcessItemsUsingUserInvolvedInProcess() throws JsonToModelConversionException, Exception { @@ -71,8 +72,8 @@ public class GetProcessItemsSanityTests extends RestWorkflowTest processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @Test(groups = { "networks" }) - @TestRail(section = {"rest-api", "processes" }, executionType = ExecutionType.SANITY, + @Test(groups = { TestGroup.NETWORKS }) + @TestRail(section = {TestGroup.REST_API, "processes" }, executionType = ExecutionType.SANITY, description = "Get process items using admin from same network") public void getProcessItemsUsingAdminUserFromSameNetwork() throws JsonToModelConversionException, Exception { diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksSanityTests.java index bb00f9ddf..c50b21218 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksSanityTests.java @@ -7,6 +7,7 @@ import org.alfresco.rest.requests.RestProcessesApi; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.ProcessModel; import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; @@ -20,7 +21,7 @@ import org.testng.annotations.Test; * * @author Cristina Axinte */ -@Test(groups = { "rest-api", "workflow", "processes", "sanity" }) +@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, "processes", TestGroup.COMMENTS }) public class GetProcessTasksSanityTests extends RestWorkflowTest { @Autowired @@ -46,7 +47,7 @@ public class GetProcessTasksSanityTests extends RestWorkflowTest processesApi.useRestClient(restClient); } - @TestRail(section = { "rest-api", "workflow", "processes" }, executionType = ExecutionType.SANITY, description = "Verify user who started the process gets all tasks of started process with Rest API and response is successfull (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, "processes" }, executionType = ExecutionType.SANITY, description = "Verify user who started the process gets all tasks of started process with Rest API and response is successfull (200)") public void userWhoStartedProcessCanGetProcessTasks() throws JsonToModelConversionException, Exception { restClient.authenticateUser(userModel); @@ -58,7 +59,7 @@ public class GetProcessTasksSanityTests extends RestWorkflowTest processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "workflow", "processes" }, executionType = ExecutionType.SANITY, description = "Verify any assignee user of the process gets all tasks of the process with Rest API and response is successfull (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, "processes" }, executionType = ExecutionType.SANITY, description = "Verify any assignee user of the process gets all tasks of the process with Rest API and response is successfull (200)") public void assigneeUserCanGetAllProcessTasks() throws JsonToModelConversionException, Exception { restClient.authenticateUser(assignee1); @@ -70,7 +71,7 @@ public class GetProcessTasksSanityTests extends RestWorkflowTest processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "workflow", "processes" }, executionType = ExecutionType.SANITY, description = "Verify any assignee user of the process gets all tasks of the process with Rest API and response is successfull (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, "processes" }, executionType = ExecutionType.SANITY, description = "Verify any assignee user of the process gets all tasks of the process with Rest API and response is successfull (200)") public void involvedUserCanGetAllProcessTasks() throws JsonToModelConversionException, Exception { ProcessModel process = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(document) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java index 6ef8c2ab4..aa038cce1 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java @@ -8,6 +8,7 @@ import org.alfresco.utility.data.DataUser; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TaskModel; +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; @@ -19,7 +20,7 @@ import org.testng.annotations.Test; /** * Created by Claudia Agache on 10/11/2016. */ -@Test(groups = { "rest-api", "processes", "sanity" }) +@Test(groups = { TestGroup.REST_API, "processes", TestGroup.COMMENTS }) public class GetProcessesSanityTests extends RestWorkflowTest { @Autowired @@ -45,7 +46,7 @@ public class GetProcessesSanityTests extends RestWorkflowTest processesApi.useRestClient(restClient); } - @TestRail(section = { "rest-api", + @TestRail(section = { TestGroup.REST_API, "processes" }, executionType = ExecutionType.SANITY, description = "Verify User gets all processes started by him using REST API and status code is OK (200)") public void getProcessesByUserWhoStartedProcess() throws JsonToModelConversionException, Exception { @@ -54,7 +55,7 @@ public class GetProcessesSanityTests extends RestWorkflowTest processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", + @TestRail(section = { TestGroup.REST_API, "processes" }, executionType = ExecutionType.SANITY, description = "Verify User gets all processes assigned to him using REST API and status code is OK (200)") public void getProcessesByAssignedUser() throws JsonToModelConversionException, Exception { @@ -63,7 +64,7 @@ public class GetProcessesSanityTests extends RestWorkflowTest processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", + @TestRail(section = { TestGroup.REST_API, "processes" }, executionType = ExecutionType.SANITY, description = "Verify User that is not involved in a process can not get that process using REST API and status code is OK (200)") public void getProcessesByAnotherUser() throws JsonToModelConversionException, Exception { @@ -72,7 +73,7 @@ public class GetProcessesSanityTests extends RestWorkflowTest processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", + @TestRail(section = { TestGroup.REST_API, "processes" }, executionType = ExecutionType.SANITY, description = "Verify Admin gets all processes, even if he isn't involved in a process, using REST API and status code is OK (200)") public void getProcessesByAdmin() throws JsonToModelConversionException, Exception { diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesVariablesSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesVariablesSanityTests.java index 5861e1734..11197bf30 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesVariablesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesVariablesSanityTests.java @@ -8,6 +8,7 @@ import org.alfresco.rest.requests.RestProcessesApi; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; @@ -19,7 +20,7 @@ import org.testng.annotations.Test; /** * @author iulia.cojocea */ -@Test(groups = { "rest-api", "processes", "sanity" }) +@Test(groups = { TestGroup.REST_API, "processes", TestGroup.COMMENTS }) public class GetProcessesVariablesSanityTests extends RestWorkflowTest { @Autowired @@ -44,7 +45,7 @@ public class GetProcessesVariablesSanityTests extends RestWorkflowTest processesApi.useRestClient(restClient); } - @TestRail(section = {"rest-api", "processes" }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, "processes" }, executionType = ExecutionType.SANITY, description = "Verify that user that started the process gets all process variables") public void getProcessVariablesUsingTheUserWhoStartedProcess() throws JsonToModelConversionException, Exception { @@ -54,7 +55,7 @@ public class GetProcessesVariablesSanityTests extends RestWorkflowTest processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "processes" }, executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API, "processes" }, executionType = ExecutionType.SANITY, description = "Verify get all process variables call using a user that is involved in the process") public void getProcessVariablesUsingUserInvolvedInProcess() throws JsonToModelConversionException, Exception { diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessVariableSanityTests.java index d896f04be..9a5ac3ed2 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessVariableSanityTests.java @@ -9,6 +9,7 @@ import org.alfresco.rest.requests.RestProcessesApi; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; @@ -20,7 +21,7 @@ import org.testng.annotations.Test; /** * @author iulia.cojocea */ -@Test(groups = { "rest-api", "processes", "sanity" }) +@Test(groups = { TestGroup.REST_API, "processes", TestGroup.COMMENTS }) public class RemoveProcessVariableSanityTests extends RestWorkflowTest { @Autowired @@ -47,7 +48,7 @@ public class RemoveProcessVariableSanityTests extends RestWorkflowTest processesApi.useRestClient(restClient); } - @TestRail(section = {"rest-api", "processes" }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, "processes" }, executionType = ExecutionType.SANITY, description = "Delete existing variable") public void deleteProcessVariable() throws JsonToModelConversionException, Exception { @@ -59,7 +60,7 @@ public class RemoveProcessVariableSanityTests extends RestWorkflowTest processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); } - @TestRail(section = {"rest-api", "processes" }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, "processes" }, executionType = ExecutionType.SANITY, description = "Try to delete existing variable using invalid processId") public void deleteProcessVariableUsingInvalidProcessId() throws JsonToModelConversionException, Exception { diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskSanityTests.java index efb85a120..5c731fd72 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskSanityTests.java @@ -7,6 +7,7 @@ import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.GroupModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TaskModel; +import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; @@ -16,7 +17,7 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { "rest-api", "workflow", "tasks", "sanity" }) +@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.COMMENTS }) public class GetTaskSanityTests extends RestWorkflowTest { @Autowired @@ -41,7 +42,7 @@ public class GetTaskSanityTests extends RestWorkflowTest tasksApi.useRestClient(restClient); } - @TestRail(section = { "rest-api", "workflow", "tasks" }, executionType = ExecutionType.SANITY, description = "Verify admin user gets any existing task with Rest API and response is successfull (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify admin user gets any existing task with Rest API and response is successfull (200)") public void adminUserGetsAnyTaskWithSuccess() throws Exception { UserModel adminUser = dataUser.getAdminUser(); @@ -50,7 +51,7 @@ public class GetTaskSanityTests extends RestWorkflowTest tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "workflow", "tasks" }, executionType = ExecutionType.SANITY, description = "Verify assignee user gets its assigned task with Rest API and response is successfull (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify assignee user gets its assigned task with Rest API and response is successfull (200)") public void assigneeUserGetsItsTaskWithSuccess() throws Exception { restClient.authenticateUser(assigneeUser); @@ -58,7 +59,7 @@ public class GetTaskSanityTests extends RestWorkflowTest tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "workflow", "tasks" }, executionType = ExecutionType.SANITY, description = "Verify user that started the task gets the started task with Rest API and response is successfull (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify user that started the task gets the started task with Rest API and response is successfull (200)") public void starterUserGetsItsTaskWithSuccess() throws Exception { restClient.authenticateUser(userModel); @@ -66,7 +67,7 @@ public class GetTaskSanityTests extends RestWorkflowTest tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "workflow", "tasks" }, executionType = ExecutionType.SANITY, description = "Verify any user with no relation to task id forbidden to get other task with Rest API (403)") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify any user with no relation to task id forbidden to get other task with Rest API (403)") public void anyUserIsForbiddenToGetOtherTask() throws Exception { UserModel anyUser= dataUser.createRandomTestUser(); @@ -76,7 +77,7 @@ public class GetTaskSanityTests extends RestWorkflowTest tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } - @TestRail(section = { "rest-api", "workflow", "tasks" }, executionType = ExecutionType.SANITY, description = "Verify candidate user gets its specific task and no other user claimed the task with Rest API and response is successfull (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify candidate user gets its specific task and no other user claimed the task with Rest API and response is successfull (200)") public void candidateUserGetsItsTasks() throws Exception { UserModel userModel1 = dataUser.createRandomTestUser(); @@ -91,7 +92,7 @@ public class GetTaskSanityTests extends RestWorkflowTest } @Bug(id = "") - @TestRail(section = { "rest-api", "workflow", "tasks" }, executionType = ExecutionType.SANITY, description = "Verify involved user in a task without claim it gets the task with Rest API and response is successfull (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify involved user in a task without claim it gets the task with Rest API and response is successfull (200)") public void involvedUserWithoutClaimTaskGetsTask() throws Exception { UserModel userModel1 = dataUser.createRandomTestUser(); diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksSanityTests.java index 79539cf57..ec70c8b9f 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksSanityTests.java @@ -7,6 +7,7 @@ import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.GroupModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TaskModel; +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; @@ -15,7 +16,7 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { "rest-api", "workflow", "tasks", "sanity" }) +@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.COMMENTS }) public class GetTasksSanityTests extends RestWorkflowTest { @Autowired @@ -39,7 +40,7 @@ public class GetTasksSanityTests extends RestWorkflowTest tasksApi.useRestClient(restClient); } - @TestRail(section = { "rest-api", "workflow", "tasks" }, executionType = ExecutionType.SANITY, description = "Verify admin user gets all existing tasks with Rest API and response is successfull (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify admin user gets all existing tasks with Rest API and response is successfull (200)") public void adminUserGetsAllTasks() throws Exception { UserModel adminUser = dataUser.getAdminUser(); @@ -48,7 +49,7 @@ public class GetTasksSanityTests extends RestWorkflowTest tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "workflow", "tasks" }, executionType = ExecutionType.SANITY, description = "Verify asignee user gets its existing tasks with Rest API and response is successfull (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify asignee user gets its existing tasks with Rest API and response is successfull (200)") public void asigneeUserGetsItsTasks() throws Exception { restClient.authenticateUser(assigneeUser); @@ -56,7 +57,7 @@ public class GetTasksSanityTests extends RestWorkflowTest tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "workflow", "tasks" }, executionType = ExecutionType.SANITY, description = "Verify candidate user that claims the task gets its existing tasks with Rest API and response is successfull (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify candidate user that claims the task gets its existing tasks with Rest API and response is successfull (200)") public void candidateUserThatClaimsTaskGetsItsTasks() throws Exception { UserModel userModel1 = dataUser.createRandomTestUser(); @@ -71,7 +72,7 @@ public class GetTasksSanityTests extends RestWorkflowTest tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { "rest-api", "workflow", "tasks" }, executionType = ExecutionType.SANITY, description = "Verify candidate user without claim gets no tasks with Rest API and response is successfull (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify candidate user without claim gets no tasks with Rest API and response is successfull (200)") public void candidateUserWithoutClaimTaskGetsNoTasks() throws Exception { UserModel userModel1 = dataUser.createRandomTestUser(); From 3bacbd4247356afa7b15473c0cf544adc5907ab6 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Mon, 17 Oct 2016 22:34:45 +0300 Subject: [PATCH 0437/1491] fix getOneRandomEntry --- .../org/alfresco/rest/comments/AddCommentSanityTests.java | 2 +- .../org/alfresco/rest/comments/AddCommentsSanityTests.java | 2 +- .../alfresco/rest/comments/DeleteCommentsSanityTests.java | 2 +- .../org/alfresco/rest/comments/GetCommentsSanityTests.java | 2 +- .../alfresco/rest/comments/UpdateCommentsSanityTests.java | 2 +- .../processes/UpdateProcessVariableSanityTests.java | 6 +++--- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java index 7ffd56aa4..a7e0d9621 100644 --- a/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java @@ -19,7 +19,7 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { TestGroup.REST_API, TestGroup.SANITY, TestGroup.SANITY }) +@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) public class AddCommentSanityTests extends RestTest { @Autowired diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java index 4c688c3ac..9ee678cd5 100644 --- a/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java @@ -23,7 +23,7 @@ import org.testng.annotations.Test; /** * Created by Claudia Agache on 10/10/2016. */ -@Test(groups = { TestGroup.REST_API, TestGroup.SANITY, TestGroup.SANITY }) +@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) public class AddCommentsSanityTests extends RestTest { @Autowired RestCommentsApi commentsAPI; diff --git a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java index 286ec655c..96e4183db 100644 --- a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java @@ -20,7 +20,7 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -@Test(groups = { TestGroup.REST_API, TestGroup.SANITY, TestGroup.SANITY }) +@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) public class DeleteCommentsSanityTests extends RestTest { diff --git a/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java index fe03521b8..b0e80372d 100644 --- a/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java @@ -19,7 +19,7 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { TestGroup.REST_API, TestGroup.SANITY, TestGroup.SANITY }) +@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) public class GetCommentsSanityTests extends RestTest { @Autowired diff --git a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java index 88fe81794..e6a4f9e36 100644 --- a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java @@ -21,7 +21,7 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { TestGroup.REST_API, TestGroup.SANITY, TestGroup.SANITY }) +@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) public class UpdateCommentsSanityTests extends RestTest { @Autowired diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/UpdateProcessVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/UpdateProcessVariableSanityTests.java index 14a4857bc..cef48aab1 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/UpdateProcessVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/UpdateProcessVariableSanityTests.java @@ -54,7 +54,7 @@ public class UpdateProcessVariableSanityTests extends RestWorkflowTest { restClient.authenticateUser(adminUser); RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = processesApi.getProcesses().getOneEntry(); + processModel = processesApi.getProcesses().getOneRandomEntry(); processesApi.updateProcessVariable(processModel, variableModel); processesApi.getProcessesVariables(processModel).assertProcessVariableExists(variableModel); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); @@ -66,7 +66,7 @@ public class UpdateProcessVariableSanityTests extends RestWorkflowTest { restClient.authenticateUser(adminUser); RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = processesApi.getProcesses().getOneEntry(); + processModel = processesApi.getProcesses().getOneRandomEntry(); processesApi.addProcessVariable(processModel, variableModel); variableModel.setValue("newValue"); processesApi.updateProcessVariable(processModel, variableModel).assertProcessVariableHasValue("newValue"); @@ -79,7 +79,7 @@ public class UpdateProcessVariableSanityTests extends RestWorkflowTest { restClient.authenticateUser(adminUser); RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = processesApi.getProcesses().getOneEntry(); + processModel = processesApi.getProcesses().getOneRandomEntry(); processModel.onModel().setId("abc"); processesApi.updateProcessVariable(processModel, variableModel); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); From 89d1151c7f3289617d4571bbcef134195a641a9b Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Mon, 17 Oct 2016 22:48:44 +0300 Subject: [PATCH 0438/1491] add preference group --- .../people/GetPeoplePreferenceSanityTests.java | 14 +++++++------- .../people/GetPeoplePreferencesSanityTests.java | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceSanityTests.java index 550628f8b..f5814ae0b 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceSanityTests.java @@ -21,7 +21,7 @@ import org.testng.annotations.Test; * @author Cristina Axinte * */ -@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, "preferences", TestGroup.SANITY }) +@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) public class GetPeoplePreferenceSanityTests extends RestTest { @Autowired @@ -39,7 +39,7 @@ public class GetPeoplePreferenceSanityTests extends RestTest peopleApi.useRestClient(restClient); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, "preferences" }, executionType = ExecutionType.SANITY, description = "Verify manager user gets a specific preference with Rest API and response is successful (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify manager user gets a specific preference with Rest API and response is successful (200)") public void managerUserGetsAPreferenceWithSuccess() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -51,7 +51,7 @@ public class GetPeoplePreferenceSanityTests extends RestTest peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, "preferences" }, executionType = ExecutionType.SANITY, description = "Verify collaborator user gets a specific preference with Rest API and response is successful (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify collaborator user gets a specific preference with Rest API and response is successful (200)") public void collaboratorUserGetsAPreferenceWithSuccess() throws Exception { UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); @@ -63,7 +63,7 @@ public class GetPeoplePreferenceSanityTests extends RestTest peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, "preferences" }, executionType = ExecutionType.SANITY, description = "Verify contributor user gets a specific preference with Rest API and response is successful (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify contributor user gets a specific preference with Rest API and response is successful (200)") public void contributorUserGetsAPreferenceWithSuccess() throws Exception { UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); @@ -75,7 +75,7 @@ public class GetPeoplePreferenceSanityTests extends RestTest peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, "preferences" }, executionType = ExecutionType.SANITY, description = "Verify consumer user gets a specific preference with Rest API and response is successful (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify consumer user gets a specific preference with Rest API and response is successful (200)") public void consumerUserGetsAPreferenceWithSuccess() throws Exception { UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -87,7 +87,7 @@ public class GetPeoplePreferenceSanityTests extends RestTest peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, "preferences" }, executionType = ExecutionType.SANITY, description = "Verify admin user gets a specific preference with Rest API and response is successful (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify admin user gets a specific preference with Rest API and response is successful (200)") public void adminUserGetsAPreferenceWithSuccess() throws Exception { UserModel adminUser = dataUser.getAdminUser(); @@ -99,7 +99,7 @@ public class GetPeoplePreferenceSanityTests extends RestTest } @Bug(id = "MNT-16904") - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, "preferences" }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized to get a specific preference with Rest API when authentication fails (401)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized to get a specific preference with Rest API when authentication fails (401)") public void managerUserNotAuthorizedFailsToGetsAPreference() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesSanityTests.java index 364435569..256240033 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesSanityTests.java @@ -20,7 +20,7 @@ import org.testng.annotations.Test; * @author Cristina Axinte * */ -@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, "preferences", TestGroup.SANITY }) +@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) public class GetPeoplePreferencesSanityTests extends RestTest { @Autowired @@ -38,7 +38,7 @@ public class GetPeoplePreferencesSanityTests extends RestTest peopleApi.useRestClient(restClient); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, "preferences" }, executionType = ExecutionType.SANITY, description = "Verify manager user gets its preferences with Rest API and response is successful (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify manager user gets its preferences with Rest API and response is successful (200)") public void managerUserGetsPeoplePreferencesWithSuccess() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -50,7 +50,7 @@ public class GetPeoplePreferencesSanityTests extends RestTest peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, "preferences" }, executionType = ExecutionType.SANITY, description = "Verify collaborator user gets its preferences with Rest API and response is successful (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify collaborator user gets its preferences with Rest API and response is successful (200)") public void collaboratorUserGetsPeoplePreferencesWithSuccess() throws Exception { UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); @@ -62,7 +62,7 @@ public class GetPeoplePreferencesSanityTests extends RestTest peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, "preferences" }, executionType = ExecutionType.SANITY, description = "Verify contributor user gets its preferences with Rest API and response is successful (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify contributor user gets its preferences with Rest API and response is successful (200)") public void contributorUserGetsPeoplePreferencesWithSuccess() throws Exception { UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); @@ -74,7 +74,7 @@ public class GetPeoplePreferencesSanityTests extends RestTest peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, "preferences" }, executionType = ExecutionType.SANITY, description = "Verify consumer user gets its preferences with Rest API and response is successful (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify consumer user gets its preferences with Rest API and response is successful (200)") public void consumerUserGetsPeoplePreferencesWithSuccess() throws Exception { UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -86,7 +86,7 @@ public class GetPeoplePreferencesSanityTests extends RestTest peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, "preferences" }, executionType = ExecutionType.SANITY, description = "Verify admin user gets another user preferences with Rest API and response is successful (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify admin user gets another user preferences with Rest API and response is successful (200)") public void adminUserGetsPeoplePreferencesWithSuccess() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -100,7 +100,7 @@ public class GetPeoplePreferencesSanityTests extends RestTest } @Bug(id = "MNT-16904") - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, "preferences" }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized to gets its preferences with Rest API when authentication fails(401)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized to gets its preferences with Rest API when authentication fails(401)") public void managerUserGetsPeoplePreferencesIsNotAUthorized() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); From c4e3c6f6846d5de58c72e090d32142f4cd049e21 Mon Sep 17 00:00:00 2001 From: cnechifor Date: Tue, 18 Oct 2016 00:34:39 +0300 Subject: [PATCH 0439/1491] added authentication step for admin tests --- .../java/org/alfresco/rest/comments/AddCommentSanityTests.java | 1 + .../java/org/alfresco/rest/comments/AddCommentsSanityTests.java | 1 + .../org/alfresco/rest/comments/DeleteCommentsSanityTests.java | 1 + .../java/org/alfresco/rest/comments/GetCommentsSanityTests.java | 1 + .../org/alfresco/rest/comments/UpdateCommentsSanityTests.java | 1 + e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java | 1 + 6 files changed, 6 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java index a7e0d9621..f9a375b77 100644 --- a/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java @@ -48,6 +48,7 @@ public class AddCommentSanityTests extends RestTest TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify admin user adds comments with Rest API and status code is 201") public void adminIsAbleToAddComment() throws JsonToModelConversionException, Exception { + restClient.authenticateUser(adminUserModel); commentsAPI.addComment(document, "This is a new comment added by " + adminUserModel.getUsername()); commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java index 9ee678cd5..d60499925 100644 --- a/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java @@ -58,6 +58,7 @@ public class AddCommentsSanityTests extends RestTest TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify admin user adds multiple comments with Rest API and status code is 201") public void adminIsAbleToAddComments() throws JsonToModelConversionException, Exception { + restClient.authenticateUser(adminUserModel); commentsAPI.addComments(document, comment1, comment2); commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } diff --git a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java index 96e4183db..e9ebd6296 100644 --- a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java @@ -61,6 +61,7 @@ public class DeleteCommentsSanityTests extends RestTest TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Admin user delete comments with Rest API and status code is 204") public void adminIsAbleToDeleteComments() throws JsonToModelConversionException, Exception { + restClient.authenticateUser(adminUserModel); commentsAPI.deleteComment(document, comment); commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); } diff --git a/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java index b0e80372d..d1a82d698 100644 --- a/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java @@ -52,6 +52,7 @@ public class GetCommentsSanityTests extends RestTest description= "Verify Admin user gets comments with Rest API and status code is 200") public void adminIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception { + restClient.authenticateUser(adminUserModel); commentsAPI.getNodeComments(document); commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } diff --git a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java index e6a4f9e36..5937f4910 100644 --- a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java @@ -53,6 +53,7 @@ public class UpdateCommentsSanityTests extends RestTest TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Admin user updates comments and status code is 200") public void adminIsAbleToUpdateComments() throws JsonToModelConversionException, Exception { + restClient.authenticateUser(adminUserModel); commentsAPI.updateComment(document, commentModel, "This is the updated comment with admin user"); commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } diff --git a/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java index e8f7f6947..b4cd32b6e 100644 --- a/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java @@ -60,6 +60,7 @@ public class UpdateTagSanityTests extends RestTest @Bug(id="MNT-16917") public void adminIsAbleToUpdateTags() throws JsonToModelConversionException, Exception { + restClient.authenticateUser(adminUserModel); tagsAPI.updateTag(oldTag, randomTag).assertTagIs(randomTag); tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } From aa06116b07c1141b4b664b93d0dd656a8e44ca0f Mon Sep 17 00:00:00 2001 From: cnechifor Date: Tue, 18 Oct 2016 00:39:06 +0300 Subject: [PATCH 0440/1491] added @bug annotation --- e2e-test/java/org/alfresco/rest/tags/GetTagSanityTests.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/tags/GetTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagSanityTests.java index bc89901e9..bc38b0fb5 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetTagSanityTests.java @@ -13,6 +13,7 @@ import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.beans.factory.annotation.Autowired; @@ -108,6 +109,7 @@ public class GetTagSanityTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Manager user gets status code 401 if authentication call fails") + @Bug(id = "MNT-16904") public void managerIsNotAbleToGetTagIfAuthenticationFails() throws JsonToModelConversionException, Exception { String tagValue = RandomData.getRandomName("tag"); From 6c8287a45efe92178158ac3935e37da7497547a5 Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Tue, 18 Oct 2016 08:52:07 +0300 Subject: [PATCH 0441/1491] TAS-1524 removeProcessItem call, provide valid details, code is 204 --- .../RemoveProcessItemSanityTests.java | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessItemSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessItemSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessItemSanityTests.java new file mode 100644 index 000000000..9bbf6564e --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessItemSanityTests.java @@ -0,0 +1,64 @@ +package org.alfresco.rest.workflow.processes; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestWorkflowTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestProcessItemModel; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.requests.RestProcessesApi; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * @author iulia.cojocea + */ +@Test(groups = { TestGroup.REST_API, "processes", TestGroup.SANITY }) +public class RemoveProcessItemSanityTests extends RestWorkflowTest +{ + @Autowired + private DataUser dataUser; + + @Autowired + private RestProcessesApi processesApi; + + private FileModel document, document2, document3; + private SiteModel siteModel; + private UserModel userWhoStartsTask, assignee; + private RestProcessModel processModel; + private UserModel adminUser; + private RestProcessItemModel processItem; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userWhoStartsTask = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); + processesApi.useRestClient(restClient); + } + + @TestRail(section = {TestGroup.REST_API, "processes" }, executionType = ExecutionType.SANITY, + description = "Delete existing process item") + public void deleteProcessItem() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUser); + processModel = processesApi.getProcesses().getOneRandomEntry(); + document2 = dataContent.usingSite(siteModel).createContent(DocumentType.MSWORD); + processItem = processesApi.addProcessItem(processModel, document2); + processesApi.deleteProcessItem(processModel, processItem); + processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); + processesApi.getProcessesItems(processModel).assertProcessItemDoesNotExists(processItem); + } +} From 60ae0bd9902fa6bc57044980ad6764bc5a6fe97e Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Tue, 18 Oct 2016 08:55:43 +0300 Subject: [PATCH 0442/1491] TAS-1525, removeProcessItem call, for invalid processId return 404 --- .../processes/RemoveProcessItemSanityTests.java | 13 +++++++++++++ .../processes/RemoveProcessVariableSanityTests.java | 3 ++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessItemSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessItemSanityTests.java index 9bbf6564e..055909b16 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessItemSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessItemSanityTests.java @@ -61,4 +61,17 @@ public class RemoveProcessItemSanityTests extends RestWorkflowTest processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); processesApi.getProcessesItems(processModel).assertProcessItemDoesNotExists(processItem); } + + @TestRail(section = {TestGroup.REST_API, "processes" }, executionType = ExecutionType.SANITY, + description = "Try to delete existing process item using invalid processId") + public void deleteProcessItemUsingInvalidProcessId() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUser); + processModel = processesApi.getProcesses().getOneRandomEntry(); + document3 = dataContent.usingSite(siteModel).createContent(DocumentType.MSPOWERPOINT); + processItem = processesApi.addProcessItem(processModel, document3); + processModel.onModel().setId("incorrectProcessId"); + processesApi.deleteProcessItem(processModel, processItem); + processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); + } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessVariableSanityTests.java index dcfd45294..fa4eaec76 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessVariableSanityTests.java @@ -58,6 +58,7 @@ public class RemoveProcessVariableSanityTests extends RestWorkflowTest processesApi.addProcessVariable(processModel, variableModel); processesApi.deleteProcessVariable(processModel, variableModel); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); + processesApi.getProcessesVariables(processModel).assertProcessVariableDoesNotExist(variableModel); } @TestRail(section = {TestGroup.REST_API, "processes" }, executionType = ExecutionType.SANITY, @@ -68,7 +69,7 @@ public class RemoveProcessVariableSanityTests extends RestWorkflowTest RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); processModel = processesApi.getProcesses().getOneRandomEntry(); processesApi.addProcessVariable(processModel, variableModel); - processModel = processesApi.getProcesses().getOneRandomEntry(); + processModel.onModel().setId("incorrectProcessId"); processesApi.deleteProcessVariable(processModel, variableModel); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); } From 007d2f16057cf2c47e24b8f2747a5737dcfa9234 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Tue, 18 Oct 2016 11:24:52 +0300 Subject: [PATCH 0443/1491] update group --- .../processes/AddProcessVariableSanityTests.java | 10 +++++----- .../workflow/processes/DeleteProcessSanityTests.java | 8 ++++---- .../workflow/processes/GetProcessItemsSanityTests.java | 8 ++++---- .../workflow/processes/GetProcessTasksSanityTests.java | 6 +++--- .../workflow/processes/GetProcessesSanityTests.java | 10 +++++----- .../processes/GetProcessesVariablesSanityTests.java | 6 +++--- .../processes/RemoveProcessItemSanityTests.java | 6 +++--- .../processes/RemoveProcessVariableSanityTests.java | 6 +++--- .../processes/UpdateProcessVariableSanityTests.java | 6 +++--- 9 files changed, 33 insertions(+), 33 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java index d0e28bb87..af9ea4e1c 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java @@ -23,7 +23,7 @@ import org.testng.annotations.Test; /** * @author iulia.cojocea */ -@Test(groups = { TestGroup.REST_API, "processes", TestGroup.SANITY }) +@Test(groups = { TestGroup.REST_API, TestGroup.PROCESSES, TestGroup.SANITY }) public class AddProcessVariableSanityTests extends RestWorkflowTest { @Autowired @@ -53,7 +53,7 @@ public class AddProcessVariableSanityTests extends RestWorkflowTest processesApi.useRestClient(restClient); } - @TestRail(section = {TestGroup.REST_API, "processes" }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Create non-existing variable") public void addProcessVariable() throws JsonToModelConversionException, Exception { @@ -64,7 +64,7 @@ public class AddProcessVariableSanityTests extends RestWorkflowTest processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } - @TestRail(section = {TestGroup.REST_API, "processes" }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Update existing variable") public void updateExistingProcessVariable() throws JsonToModelConversionException, Exception { @@ -78,7 +78,7 @@ public class AddProcessVariableSanityTests extends RestWorkflowTest } @Test(groups = { TestGroup.NETWORKS }) - @TestRail(section = {TestGroup.REST_API, "processes" }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Add process variable using admin user from same network") public void addProcessVariableByAdmin() throws JsonToModelConversionException, Exception { @@ -101,7 +101,7 @@ public class AddProcessVariableSanityTests extends RestWorkflowTest processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } - @TestRail(section = {TestGroup.REST_API, "processes" }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Adding process variable is falling in case invalid variableBody is provided") public void failedAddingProcessVariableIfInvalidBodyIsProvided() throws JsonToModelConversionException, Exception { diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java index 69c551fc6..9b1d2ab6e 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java @@ -20,7 +20,7 @@ import org.testng.annotations.Test; /** * Created by Claudia Agache on 10/12/2016. */ -@Test(groups = { TestGroup.REST_API, "processes", TestGroup.SANITY }) +@Test(groups = { TestGroup.REST_API, TestGroup.PROCESSES, TestGroup.SANITY }) public class DeleteProcessSanityTests extends RestWorkflowTest { @Autowired @@ -52,7 +52,7 @@ public class DeleteProcessSanityTests extends RestWorkflowTest } @TestRail(section = { TestGroup.REST_API, - "processes" }, executionType = ExecutionType.SANITY, description = "Verify User is able to delete process started by him using REST API and status code is OK (204)") + TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify User is able to delete process started by him using REST API and status code is OK (204)") public void deleteProcessByUserWhoStartedProcess() throws Exception { restClient.authenticateUser(userWhoStartsTask); @@ -62,7 +62,7 @@ public class DeleteProcessSanityTests extends RestWorkflowTest } @TestRail(section = { TestGroup.REST_API, - "processes" }, executionType = ExecutionType.SANITY, description = "Verify User is able to delete process assigned to him using REST API and status code is OK (204)") + TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify User is able to delete process assigned to him using REST API and status code is OK (204)") public void deleteProcessByAssignedUser() throws Exception { restClient.authenticateUser(assignee); @@ -72,7 +72,7 @@ public class DeleteProcessSanityTests extends RestWorkflowTest } @TestRail(section = { TestGroup.REST_API, - "processes" }, executionType = ExecutionType.SANITY, description = "Verify User that is not involved in a process is not authorized to delete it using REST API and status code is 403") + TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify User that is not involved in a process is not authorized to delete it using REST API and status code is 403") public void deleteProcessByAnotherUser() throws Exception { restClient.authenticateUser(anotherUser); diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsSanityTests.java index 73f19bded..4c3b4c982 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsSanityTests.java @@ -22,7 +22,7 @@ import org.testng.annotations.Test; * @author iulia.cojocea */ -@Test(groups = { TestGroup.REST_API, "processes", TestGroup.SANITY }) +@Test(groups = { TestGroup.REST_API, TestGroup.PROCESSES, TestGroup.SANITY }) public class GetProcessItemsSanityTests extends RestWorkflowTest { @Autowired @@ -52,7 +52,7 @@ public class GetProcessItemsSanityTests extends RestWorkflowTest processesApi.useRestClient(restClient); } - @TestRail(section = {TestGroup.REST_API, "processes" }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify that user that started the process gets all process items") public void getProcessItemsUsingTheUserWhoStartedProcess() throws JsonToModelConversionException, Exception { @@ -62,7 +62,7 @@ public class GetProcessItemsSanityTests extends RestWorkflowTest processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API, "processes" }, executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify that user that is involved in the process gets all process items") public void getProcessItemsUsingUserInvolvedInProcess() throws JsonToModelConversionException, Exception { @@ -73,7 +73,7 @@ public class GetProcessItemsSanityTests extends RestWorkflowTest } @Test(groups = { TestGroup.NETWORKS }) - @TestRail(section = {TestGroup.REST_API, "processes" }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Get process items using admin from same network") public void getProcessItemsUsingAdminUserFromSameNetwork() throws JsonToModelConversionException, Exception { diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksSanityTests.java index 57a63140a..023fb59fa 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksSanityTests.java @@ -47,7 +47,7 @@ public class GetProcessTasksSanityTests extends RestWorkflowTest processesApi.useRestClient(restClient); } - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, "processes" }, executionType = ExecutionType.SANITY, description = "Verify user who started the process gets all tasks of started process with Rest API and response is successfull (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify user who started the process gets all tasks of started process with Rest API and response is successfull (200)") public void userWhoStartedProcessCanGetProcessTasks() throws JsonToModelConversionException, Exception { restClient.authenticateUser(userModel); @@ -59,7 +59,7 @@ public class GetProcessTasksSanityTests extends RestWorkflowTest processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, "processes" }, executionType = ExecutionType.SANITY, description = "Verify any assignee user of the process gets all tasks of the process with Rest API and response is successfull (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify any assignee user of the process gets all tasks of the process with Rest API and response is successfull (200)") public void assigneeUserCanGetAllProcessTasks() throws JsonToModelConversionException, Exception { restClient.authenticateUser(assignee1); @@ -71,7 +71,7 @@ public class GetProcessTasksSanityTests extends RestWorkflowTest processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, "processes" }, executionType = ExecutionType.SANITY, description = "Verify any assignee user of the process gets all tasks of the process with Rest API and response is successfull (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify any assignee user of the process gets all tasks of the process with Rest API and response is successfull (200)") public void involvedUserCanGetAllProcessTasks() throws JsonToModelConversionException, Exception { ProcessModel process = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(document) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java index 63c7f8549..2a3cb8766 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java @@ -20,7 +20,7 @@ import org.testng.annotations.Test; /** * Created by Claudia Agache on 10/11/2016. */ -@Test(groups = { TestGroup.REST_API, "processes", TestGroup.SANITY }) +@Test(groups = { TestGroup.REST_API, TestGroup.PROCESSES, TestGroup.SANITY }) public class GetProcessesSanityTests extends RestWorkflowTest { @Autowired @@ -47,7 +47,7 @@ public class GetProcessesSanityTests extends RestWorkflowTest } @TestRail(section = { TestGroup.REST_API, - "processes" }, executionType = ExecutionType.SANITY, description = "Verify User gets all processes started by him using REST API and status code is OK (200)") + TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify User gets all processes started by him using REST API and status code is OK (200)") public void getProcessesByUserWhoStartedProcess() throws JsonToModelConversionException, Exception { restClient.authenticateUser(userWhoStartsTask); @@ -56,7 +56,7 @@ public class GetProcessesSanityTests extends RestWorkflowTest } @TestRail(section = { TestGroup.REST_API, - "processes" }, executionType = ExecutionType.SANITY, description = "Verify User gets all processes assigned to him using REST API and status code is OK (200)") + TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify User gets all processes assigned to him using REST API and status code is OK (200)") public void getProcessesByAssignedUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(assignee); @@ -65,7 +65,7 @@ public class GetProcessesSanityTests extends RestWorkflowTest } @TestRail(section = { TestGroup.REST_API, - "processes" }, executionType = ExecutionType.SANITY, description = "Verify User that is not involved in a process can not get that process using REST API and status code is OK (200)") + TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify User that is not involved in a process can not get that process using REST API and status code is OK (200)") public void getProcessesByAnotherUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(anotherUser); @@ -74,7 +74,7 @@ public class GetProcessesSanityTests extends RestWorkflowTest } @TestRail(section = { TestGroup.REST_API, - "processes" }, executionType = ExecutionType.SANITY, description = "Verify Admin gets all processes, even if he isn't involved in a process, using REST API and status code is OK (200)") + TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify Admin gets all processes, even if he isn't involved in a process, using REST API and status code is OK (200)") public void getProcessesByAdmin() throws JsonToModelConversionException, Exception { restClient.authenticateUser(dataUser.getAdminUser()); diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesVariablesSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesVariablesSanityTests.java index f7c4c63ca..454c554fc 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesVariablesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesVariablesSanityTests.java @@ -20,7 +20,7 @@ import org.testng.annotations.Test; /** * @author iulia.cojocea */ -@Test(groups = { TestGroup.REST_API, "processes", TestGroup.SANITY }) +@Test(groups = { TestGroup.REST_API, TestGroup.PROCESSES, TestGroup.SANITY }) public class GetProcessesVariablesSanityTests extends RestWorkflowTest { @Autowired @@ -45,7 +45,7 @@ public class GetProcessesVariablesSanityTests extends RestWorkflowTest processesApi.useRestClient(restClient); } - @TestRail(section = {TestGroup.REST_API, "processes" }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify that user that started the process gets all process variables") public void getProcessVariablesUsingTheUserWhoStartedProcess() throws JsonToModelConversionException, Exception { @@ -55,7 +55,7 @@ public class GetProcessesVariablesSanityTests extends RestWorkflowTest processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API, "processes" }, executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify get all process variables call using a user that is involved in the process") public void getProcessVariablesUsingUserInvolvedInProcess() throws JsonToModelConversionException, Exception { diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessItemSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessItemSanityTests.java index 055909b16..bccabecf2 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessItemSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessItemSanityTests.java @@ -21,7 +21,7 @@ import org.testng.annotations.Test; /** * @author iulia.cojocea */ -@Test(groups = { TestGroup.REST_API, "processes", TestGroup.SANITY }) +@Test(groups = { TestGroup.REST_API, TestGroup.PROCESSES, TestGroup.SANITY }) public class RemoveProcessItemSanityTests extends RestWorkflowTest { @Autowired @@ -49,7 +49,7 @@ public class RemoveProcessItemSanityTests extends RestWorkflowTest processesApi.useRestClient(restClient); } - @TestRail(section = {TestGroup.REST_API, "processes" }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Delete existing process item") public void deleteProcessItem() throws JsonToModelConversionException, Exception { @@ -62,7 +62,7 @@ public class RemoveProcessItemSanityTests extends RestWorkflowTest processesApi.getProcessesItems(processModel).assertProcessItemDoesNotExists(processItem); } - @TestRail(section = {TestGroup.REST_API, "processes" }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Try to delete existing process item using invalid processId") public void deleteProcessItemUsingInvalidProcessId() throws JsonToModelConversionException, Exception { diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessVariableSanityTests.java index fa4eaec76..da177bc99 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessVariableSanityTests.java @@ -21,7 +21,7 @@ import org.testng.annotations.Test; /** * @author iulia.cojocea */ -@Test(groups = { TestGroup.REST_API, "processes", TestGroup.SANITY }) +@Test(groups = { TestGroup.REST_API, TestGroup.PROCESSES, TestGroup.SANITY }) public class RemoveProcessVariableSanityTests extends RestWorkflowTest { @Autowired @@ -48,7 +48,7 @@ public class RemoveProcessVariableSanityTests extends RestWorkflowTest processesApi.useRestClient(restClient); } - @TestRail(section = {TestGroup.REST_API, "processes" }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Delete existing variable") public void deleteProcessVariable() throws JsonToModelConversionException, Exception { @@ -61,7 +61,7 @@ public class RemoveProcessVariableSanityTests extends RestWorkflowTest processesApi.getProcessesVariables(processModel).assertProcessVariableDoesNotExist(variableModel); } - @TestRail(section = {TestGroup.REST_API, "processes" }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Try to delete existing variable using invalid processId") public void deleteProcessVariableUsingInvalidProcessId() throws JsonToModelConversionException, Exception { diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/UpdateProcessVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/UpdateProcessVariableSanityTests.java index cef48aab1..35e323295 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/UpdateProcessVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/UpdateProcessVariableSanityTests.java @@ -48,7 +48,7 @@ public class UpdateProcessVariableSanityTests extends RestWorkflowTest processesApi.useRestClient(restClient); } - @TestRail(section = {"rest-api", "processes" }, executionType = ExecutionType.SANITY, + @TestRail(section = {"rest-api", TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Create non-existing variable using put call") public void addProcessVariable() throws JsonToModelConversionException, Exception { @@ -60,7 +60,7 @@ public class UpdateProcessVariableSanityTests extends RestWorkflowTest processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = {"rest-api", "processes" }, executionType = ExecutionType.SANITY, + @TestRail(section = {"rest-api", TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Update existing variable using put call") public void updateProcessVariable() throws JsonToModelConversionException, Exception { @@ -73,7 +73,7 @@ public class UpdateProcessVariableSanityTests extends RestWorkflowTest processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = {"rest-api", "processes" }, executionType = ExecutionType.SANITY, + @TestRail(section = {"rest-api", TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Try to add process variable using an invalid processId") public void addProcessVariableUsingInvalidProcessId() throws JsonToModelConversionException, Exception { From 9d9476952bbd286fd96ccd4e56479968b56d2ec1 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Tue, 18 Oct 2016 13:52:04 +0300 Subject: [PATCH 0444/1491] fix bug on checkif imbricated fields, added runner scripts --- .../people/GetPeopleActivitiesSanityTests.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java index e720fff01..860df1d26 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java @@ -21,7 +21,7 @@ import org.testng.annotations.Test; * Tests for getActivities (/people/{personId}/activities) RestAPI call * */ -@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, "activities", TestGroup.SANITY }) +@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.SANITY }) public class GetPeopleActivitiesSanityTests extends RestTest { @Autowired @@ -41,7 +41,7 @@ public class GetPeopleActivitiesSanityTests extends RestTest peopleApi.useRestClient(restClient); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, "activities" }, executionType = ExecutionType.SANITY, description = "Verify manager user gets its activities with Rest API and response is successful") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.SANITY, description = "Verify manager user gets its activities with Rest API and response is successful") public void managerUserShouldGetPeopleActivitiesList() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -53,7 +53,7 @@ public class GetPeopleActivitiesSanityTests extends RestTest peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, "activities" }, executionType = ExecutionType.SANITY, description = "Verify collaborator user gets its activities with Rest API and response is successful") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.SANITY, description = "Verify collaborator user gets its activities with Rest API and response is successful") public void collaboratorUserShouldGetPeopleActivitiesList() throws Exception { UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); @@ -65,7 +65,7 @@ public class GetPeopleActivitiesSanityTests extends RestTest peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, "activities" }, executionType = ExecutionType.SANITY, description = "Verify contributor user gets its activities with Rest API and response is successful") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.SANITY, description = "Verify contributor user gets its activities with Rest API and response is successful") public void contributorUserShouldGetPeopleActivitiesList() throws Exception { UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); @@ -77,7 +77,7 @@ public class GetPeopleActivitiesSanityTests extends RestTest peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, "activities" }, executionType = ExecutionType.SANITY, description = "Verify consumer user gets its activities with Rest API and response is successful") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.SANITY, description = "Verify consumer user gets its activities with Rest API and response is successful") public void consumerUserShouldGetPeopleActivitiesList() throws Exception { UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -88,7 +88,7 @@ public class GetPeopleActivitiesSanityTests extends RestTest peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, "activities" }, executionType = ExecutionType.SANITY, description = "Verify admin user gets another user activities with Rest API and response is successful") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.SANITY, description = "Verify admin user gets another user activities with Rest API and response is successful") public void adminUserShouldGetPeopleActivitiesList() throws Exception { restClient.authenticateUser(dataUser.getAdminUser()); @@ -97,7 +97,7 @@ public class GetPeopleActivitiesSanityTests extends RestTest } @Bug(id = "MNT-16904") - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, "activities" }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized to gets another user activities with Rest API") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized to gets another user activities with Rest API") public void managerUserShouldGetPeopleActivitiesListIsNotAuthorized() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); From ab1e36252f2642eb94e4f4a63bdd4eb792c786ee Mon Sep 17 00:00:00 2001 From: cagache Date: Tue, 18 Oct 2016 15:06:57 +0300 Subject: [PATCH 0445/1491] TAS-1553 - get start form model by non-network admin --- .../GetDeploymentsSanityTests.java | 3 +- ...ssDefinitionStartFormModelSanityTests.java | 54 +++++++++++++++++++ 2 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsSanityTests.java index 0f3a5b513..87212b542 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsSanityTests.java @@ -17,7 +17,7 @@ import org.testng.annotations.Test; /** * Created by Claudia Agache on 10/4/2016. */ -@Test(groups = { TestGroup.REST_API, TestGroup.DEPLOYMENTS, TestGroup.SANITY, TestGroup.NETWORKS }) +@Test(groups = { TestGroup.REST_API, TestGroup.DEPLOYMENTS, TestGroup.SANITY}) public class GetDeploymentsSanityTests extends RestWorkflowTest { @Autowired @@ -49,6 +49,7 @@ public class GetDeploymentsSanityTests extends RestWorkflowTest @TestRail(section = { TestGroup.REST_API, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.SANITY, description = "Verify Tenant Admin user gets network deployments using REST API and status code is OK (200)") + @Test(groups = { TestGroup.NETWORKS }) public void getNetworkDeploymentsWithAdmin() throws JsonToModelConversionException, Exception { tenantApi.useRestClient(restClient); diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java new file mode 100644 index 000000000..e7ee92896 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java @@ -0,0 +1,54 @@ +package org.alfresco.rest.workflow.processDefinitions; + +import org.alfresco.rest.RestWorkflowTest; +import org.alfresco.rest.model.RestProcessDefinitionModel; +import org.alfresco.rest.requests.RestProcessDefinitionsApi; +import org.alfresco.rest.requests.RestTenantApi; +import org.alfresco.utility.data.DataUser; +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.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Created by Claudia Agache on 10/18/2016. + */ +@Test(groups = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY }) +public class GetProcessDefinitionStartFormModelSanityTests extends RestWorkflowTest +{ + @Autowired + RestTenantApi tenantApi; + @Autowired + private DataUser dataUser; + @Autowired + private RestProcessDefinitionsApi processDefinitionsApi; + + private UserModel adminUserModel, adminTenantUser; + private RestProcessDefinitionModel randomProcessDefinition; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + adminTenantUser = UserModel.getAdminTenantUser(); + processDefinitionsApi.useRestClient(restClient); + restClient.authenticateUser(adminUserModel); + } + + // works on docker + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, + executionType = ExecutionType.SANITY, + description = "Verify Admin gets a model of the start form type definition for non-network deployments using REST API and status code is OK (200)") + public void nonNetworkAdminGetsStartFormModel() throws Exception + { + randomProcessDefinition = processDefinitionsApi.getProcessDefinitions().getOneRandomEntry(); + processDefinitionsApi.getProcessDefinitionStartFormModel(randomProcessDefinition).assertEntriesListIsNotEmpty(); + processDefinitionsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } + + +} From 745f21427c41bcdd7c3dff9e3746e6eeb8111d6d Mon Sep 17 00:00:00 2001 From: cagache Date: Tue, 18 Oct 2016 15:07:46 +0300 Subject: [PATCH 0446/1491] TAS-1554 - get start form model by network admin --- ...rocessDefinitionStartFormModelSanityTests.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java index e7ee92896..659224b61 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java @@ -50,5 +50,18 @@ public class GetProcessDefinitionStartFormModelSanityTests extends RestWorkflowT processDefinitionsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - + // works on 215 + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, + executionType = ExecutionType.SANITY, + description = "Verify Tenant Admin gets a model of the start form type definition for network deployments using REST API and status code is OK (200)") + @Test(groups = { TestGroup.NETWORKS }) + public void networkAdminGetsStartFormModel() throws Exception + { + tenantApi.useRestClient(restClient); + tenantApi.createTenant(adminTenantUser); + restClient.authenticateUser(adminTenantUser); + randomProcessDefinition = processDefinitionsApi.getProcessDefinitions().getOneRandomEntry(); + processDefinitionsApi.getProcessDefinitionStartFormModel(randomProcessDefinition).assertEntriesListIsNotEmpty(); + processDefinitionsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } } From f273c7af84810a9f76cc0668fef59236ee196243 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Tue, 18 Oct 2016 15:16:15 +0300 Subject: [PATCH 0447/1491] remove beforemethod --- .../processes/DeleteProcessSanityTests.java | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java index 9b1d2ab6e..8f547af24 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java @@ -14,7 +14,6 @@ import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; /** @@ -43,18 +42,13 @@ public class DeleteProcessSanityTests extends RestWorkflowTest siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); processesApi.useRestClient(restClient); - } - - @BeforeMethod(alwaysRun = true) - public void createTask() throws Exception - { - task = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); - } + } @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify User is able to delete process started by him using REST API and status code is OK (204)") public void deleteProcessByUserWhoStartedProcess() throws Exception { + task = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); restClient.authenticateUser(userWhoStartsTask); processesApi.deleteProcess(task); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); @@ -65,16 +59,17 @@ public class DeleteProcessSanityTests extends RestWorkflowTest TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify User is able to delete process assigned to him using REST API and status code is OK (204)") public void deleteProcessByAssignedUser() throws Exception { + task = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); restClient.authenticateUser(assignee); processesApi.deleteProcess(task); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); processesApi.getProcesses().assertProcessDoesNotExist(task); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify User that is not involved in a process is not authorized to delete it using REST API and status code is 403") + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify User that is not involved in a process is not authorized to delete it using REST API and status code is 403") public void deleteProcessByAnotherUser() throws Exception { + task = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); restClient.authenticateUser(anotherUser); processesApi.deleteProcess(task); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); From 4ffc4278f571095f4da40da04267a32463974d12 Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Tue, 18 Oct 2016 16:30:54 +0300 Subject: [PATCH 0448/1491] TAS-1563 updateTaskVariable, create non-existing variable, 201 --- .../tasks/UpdateTaskVariableSanityTests.java | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskVariableSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskVariableSanityTests.java new file mode 100644 index 000000000..56bd58ed3 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskVariableSanityTests.java @@ -0,0 +1,63 @@ +package org.alfresco.rest.workflow.tasks; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestWorkflowTest; +import org.alfresco.rest.model.RestVariableModel; +import org.alfresco.rest.requests.RestTasksApi; +import org.alfresco.rest.requests.RestTenantApi; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TaskModel; +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.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * @author iulia.cojocea + */ +@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) +public class UpdateTaskVariableSanityTests extends RestWorkflowTest +{ + @Autowired + RestTasksApi tasksApi; + + @Autowired + RestTenantApi tenantApi; + + private UserModel userModel; + private SiteModel siteModel; + private FileModel fileModel; + private UserModel assigneeUser; + private TaskModel taskModel, tenantTask; + + + private UserModel adminTenantUser, tenantUser, tenantUserAssignee; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + assigneeUser = dataUser.createRandomTestUser(); + taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + + tasksApi.useRestClient(restClient); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Create non-existing task variable") + public void createTaskVariable() throws Exception + { + UserModel adminUser = dataUser.getAdminUser(); + restClient.authenticateUser(adminUser); + RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + tasksApi.updateTaskVariable(taskModel, variableModel); + tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } +} \ No newline at end of file From a5ce07b6bb14580d650b8968134f83a999ddbe9a Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Tue, 18 Oct 2016 16:32:42 +0300 Subject: [PATCH 0449/1491] TAS-1564 updateTaskVariable, valid request to update existing variable, 200 --- .../tasks/UpdateTaskVariableSanityTests.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskVariableSanityTests.java index 56bd58ed3..99a06d30a 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskVariableSanityTests.java @@ -60,4 +60,17 @@ public class UpdateTaskVariableSanityTests extends RestWorkflowTest tasksApi.updateTaskVariable(taskModel, variableModel); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Update existing task variable") + public void updateTaskVariable() throws Exception + { + UserModel adminUser = dataUser.getAdminUser(); + restClient.authenticateUser(adminUser); + RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + tasksApi.updateTaskVariable(taskModel, variableModel); + variableModel.setValue("updatedValue"); + tasksApi.updateTaskVariable(taskModel, variableModel).assertTaskVariableHasValue("updatedValue"); + tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } } \ No newline at end of file From 512465025f7ddcd12ac8480e7f98be8a9f14bccb Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Tue, 18 Oct 2016 16:33:33 +0300 Subject: [PATCH 0450/1491] TAS-1565, updateTaskVariable, perform request by admin in the same network --- .../tasks/UpdateTaskVariableSanityTests.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskVariableSanityTests.java index 99a06d30a..5bf85602f 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskVariableSanityTests.java @@ -73,4 +73,29 @@ public class UpdateTaskVariableSanityTests extends RestWorkflowTest tasksApi.updateTaskVariable(taskModel, variableModel).assertTaskVariableHasValue("updatedValue"); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + @Test(groups = {TestGroup.NETWORKS }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Update existing task variable by admin in the same network") + public void updateTaskVariableByAdminInSameNetwork() throws Exception + { + UserModel adminUser = dataUser.getAdminUser(); + restClient.authenticateUser(adminUser); + + adminTenantUser = UserModel.getAdminTenantUser(); + tenantApi.useRestClient(restClient); + tenantApi.createTenant(adminTenantUser); + + tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); + + siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); + tenantTask = dataWorkflow.usingUser(tenantUser).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(tenantUserAssignee); + + RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + tasksApi.updateTaskVariable(tenantTask, variableModel); + variableModel.setValue("updatedValue"); + tasksApi.updateTaskVariable(taskModel, variableModel).assertTaskVariableHasValue("updatedValue"); + tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } } \ No newline at end of file From 2be47fd9e778d516ac7b491645154d0b5b8d30a3 Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Tue, 18 Oct 2016 17:28:40 +0300 Subject: [PATCH 0451/1491] TAS-1566 getTaskVariables call perform request with user that started the process --- .../tasks/GetTaskVariablesSanityTests.java | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskVariablesSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskVariablesSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskVariablesSanityTests.java new file mode 100644 index 000000000..ae46a28b1 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskVariablesSanityTests.java @@ -0,0 +1,53 @@ +package org.alfresco.rest.workflow.tasks; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestWorkflowTest; +import org.alfresco.rest.requests.RestTasksApi; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TaskModel; +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.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * @author iulia.cojocea + */ +@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) +public class GetTaskVariablesSanityTests extends RestWorkflowTest +{ + @Autowired + RestTasksApi tasksApi; + + private UserModel userModel, userWhoStartsTask, assignee; + private SiteModel siteModel; + private FileModel fileModel; + private TaskModel taskModel; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + userWhoStartsTask = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); + + tasksApi.useRestClient(restClient); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Verify that user that started the process gets task variables") + public void getTaskVariablesByUserWhoStartedProcess() throws Exception + { + restClient.authenticateUser(userWhoStartsTask); + tasksApi.getTaskVariables(taskModel); + tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } +} From 4358aaf5967438cbaf3d71d2df3312ec5a8b5d2e Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Tue, 18 Oct 2016 17:29:20 +0300 Subject: [PATCH 0452/1491] TAS-1567 perform request with user that is involved in process --- .../rest/workflow/tasks/GetTaskVariablesSanityTests.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskVariablesSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskVariablesSanityTests.java index ae46a28b1..86089393b 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskVariablesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskVariablesSanityTests.java @@ -50,4 +50,13 @@ public class GetTaskVariablesSanityTests extends RestWorkflowTest tasksApi.getTaskVariables(taskModel); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Verify that user that is involved in the process gets task variables") + public void getTaskVariablesByUserInvolvedInProcess() throws Exception + { + restClient.authenticateUser(assignee); + tasksApi.getTaskVariables(taskModel); + tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } } From 2412208e693fec068c4791ec7853bc770d7f60c1 Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Tue, 18 Oct 2016 17:29:54 +0300 Subject: [PATCH 0453/1491] TAS-1568, perform request with any user --- .../workflow/tasks/GetTaskVariablesSanityTests.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskVariablesSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskVariablesSanityTests.java index 86089393b..61c104b2f 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskVariablesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskVariablesSanityTests.java @@ -59,4 +59,15 @@ public class GetTaskVariablesSanityTests extends RestWorkflowTest tasksApi.getTaskVariables(taskModel); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Verify that user that is not involved in the process gets task variables") + public void getTaskVariablesUsingAnyUser() throws Exception + { + UserModel randomUser = dataUser.createRandomTestUser(); + + restClient.authenticateUser(randomUser); + tasksApi.getTaskVariables(taskModel); + tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + } } From 4af8a33d3fe4782cd2d47ba8c39f5373614a244d Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Tue, 18 Oct 2016 17:30:29 +0300 Subject: [PATCH 0454/1491] TAS-1569, perform request with admin --- .../workflow/tasks/GetTaskVariablesSanityTests.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskVariablesSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskVariablesSanityTests.java index 61c104b2f..cbc1f63d0 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskVariablesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskVariablesSanityTests.java @@ -70,4 +70,15 @@ public class GetTaskVariablesSanityTests extends RestWorkflowTest tasksApi.getTaskVariables(taskModel); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Verify that admin gets task variables") + public void getTaskVariablesUsingAdmin() throws Exception + { + UserModel adminUser = dataUser.getAdminUser(); + + restClient.authenticateUser(adminUser); + tasksApi.getTaskVariables(taskModel); + tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } } From 2feaf10cf8adaa666de44970f7a0d2b3f5f27405 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Tue, 18 Oct 2016 22:51:05 +0300 Subject: [PATCH 0455/1491] move JsonBodyGenerator to core --- e2e-test/java/org/alfresco/rest/demo/SamplePeopleTests.java | 2 +- .../java/org/alfresco/rest/people/GetPeopleSanityTests.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/demo/SamplePeopleTests.java b/e2e-test/java/org/alfresco/rest/demo/SamplePeopleTests.java index 2c0c6dd99..34bdb6b80 100644 --- a/e2e-test/java/org/alfresco/rest/demo/SamplePeopleTests.java +++ b/e2e-test/java/org/alfresco/rest/demo/SamplePeopleTests.java @@ -34,7 +34,7 @@ public class SamplePeopleTests extends RestTest description = "Verify admin user gets person with Rest API and response is not empty") public void adminShouldRetrievePerson() throws Exception { - peopleAPI.getPerson(userModel).assertResponseIsNotEmpty(); + peopleAPI.getPerson(userModel).assertIDIsNotEmpty(); peopleAPI.usingRestWrapper() .assertStatusCodeIs(HttpStatus.OK); diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleSanityTests.java index bbde7b8f5..32f0adcc0 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleSanityTests.java @@ -41,7 +41,7 @@ public class GetPeopleSanityTests extends RestTest dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); restClient.authenticateUser(managerUser); - peopleApi.getPerson(searchedUser); + peopleApi.getPerson(searchedUser).assertIDIsNotEmpty(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } From 6a22b86dfd2d90179e9f727fdc26c0fee2938a40 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Wed, 19 Oct 2016 01:03:22 +0300 Subject: [PATCH 0456/1491] add support for rest model assertion --- .../alfresco/rest/demo/SamplePeopleTests.java | 2 +- .../alfresco/rest/demo/SampleSitesTests.java | 10 +-- .../rest/model/ModelAssertionTest.java | 61 +++++++++++++++++++ .../people/GetFavoriteSiteSanityTests.java | 10 +-- .../rest/people/GetPeopleSanityTests.java | 2 +- 5 files changed, 73 insertions(+), 12 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/model/ModelAssertionTest.java diff --git a/e2e-test/java/org/alfresco/rest/demo/SamplePeopleTests.java b/e2e-test/java/org/alfresco/rest/demo/SamplePeopleTests.java index 34bdb6b80..cd4b42e38 100644 --- a/e2e-test/java/org/alfresco/rest/demo/SamplePeopleTests.java +++ b/e2e-test/java/org/alfresco/rest/demo/SamplePeopleTests.java @@ -34,7 +34,7 @@ public class SamplePeopleTests extends RestTest description = "Verify admin user gets person with Rest API and response is not empty") public void adminShouldRetrievePerson() throws Exception { - peopleAPI.getPerson(userModel).assertIDIsNotEmpty(); + peopleAPI.getPerson(userModel).and().assertField("id").isNotEmpty(); peopleAPI.usingRestWrapper() .assertStatusCodeIs(HttpStatus.OK); diff --git a/e2e-test/java/org/alfresco/rest/demo/SampleSitesTests.java b/e2e-test/java/org/alfresco/rest/demo/SampleSitesTests.java index 7f7ee6de8..6b749873a 100644 --- a/e2e-test/java/org/alfresco/rest/demo/SampleSitesTests.java +++ b/e2e-test/java/org/alfresco/rest/demo/SampleSitesTests.java @@ -37,7 +37,7 @@ public class SampleSitesTests extends RestTest public void adminShouldGetSiteDetails() throws JsonToModelConversionException, Exception { siteAPI.getSite(siteModel) - .assertResponseIsNotEmpty(); + .and().assertField("id").isNotNull(); } @TestRail(section={"demo", "sample-section"}, executionType= ExecutionType.SANITY, @@ -98,10 +98,10 @@ public class SampleSitesTests extends RestTest public void adminShouldAccessSiteDetails() throws JsonToModelConversionException, Exception { siteAPI.getSite(siteModel) - .assertResponseIsNotEmpty() - .assertSiteHasDescription(siteModel.getDescription()) - .assertSiteHasTitle(siteModel.getTitle()) - .assertSiteHasVisibility(siteModel.getVisibility()); + .and().assertField("id").isNotNull() + .and().assertField("description").is(siteModel.getDescription()) + .and().assertField("title").is(siteModel.getTitle()) + .and().assertField("visibility").is(siteModel.getVisibility()); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/model/ModelAssertionTest.java b/e2e-test/java/org/alfresco/rest/model/ModelAssertionTest.java new file mode 100644 index 000000000..0af963129 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/model/ModelAssertionTest.java @@ -0,0 +1,61 @@ +package org.alfresco.rest.model; + +import org.alfresco.rest.core.ModelAssertion; +import org.alfresco.utility.exception.TestConfigurationException; +import org.testng.annotations.Test; + +public class ModelAssertionTest { + @Test + public void iCanAssertExistingProperty() throws Exception { + Person p = new Person(); + p.and().assertField("id").is("1234"); + } + + @Test + public void iCanAssertExistingPropertyNegative() throws Exception { + Person p = new Person(); + p.and().assertField("id").isNot("12342"); + RestPersonModel rp = new RestPersonModel(); + + rp.getFirstName(); + } + + @Test(expectedExceptions = TestConfigurationException.class) + public void iHaveOneExceptionThrownWithSelfExplanatoryMessageOnMissingField() throws Exception { + Person p = new Person(); + p.and().assertField("id2").is("12342"); + + } + + @Test + public void iCanTakeTheValueOfFieldsThatDoesntHaveGetters() throws Exception { + Person p = new Person(); + + p.and().assertField("name").is("test"); + + } + + public class Person { + private String id = "1234"; + + @SuppressWarnings("unused") + private String name = "test"; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public ModelAssertion and() + { + return new ModelAssertion(this); + } + + } + + + +} diff --git a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java index 7b7424782..c477aae31 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java @@ -50,7 +50,7 @@ public class GetFavoriteSiteSanityTests extends RestTest dataSite.usingUser(managerUser).usingSite(siteModel2).addSiteToFavorites(); restClient.authenticateUser(managerUser); - peopleApi.getFavoriteSite(managerUser, siteModel1).assertResponseIsNotEmpty(); + peopleApi.getFavoriteSite(managerUser, siteModel1).and().assertField("id").isNotNull(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -63,7 +63,7 @@ public class GetFavoriteSiteSanityTests extends RestTest dataSite.usingUser(collaboratorUser).usingSite(siteModel2).addSiteToFavorites(); restClient.authenticateUser(collaboratorUser); - peopleApi.getFavoriteSite(collaboratorUser, siteModel1).assertResponseIsNotEmpty(); + peopleApi.getFavoriteSite(collaboratorUser, siteModel1).and().assertField("id").isNotNull(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -76,7 +76,7 @@ public class GetFavoriteSiteSanityTests extends RestTest dataSite.usingUser(contributorUser).usingSite(siteModel2).addSiteToFavorites(); restClient.authenticateUser(contributorUser); - peopleApi.getFavoriteSite(contributorUser, siteModel1).assertResponseIsNotEmpty(); + peopleApi.getFavoriteSite(contributorUser, siteModel1).and().assertField("id").isNotNull(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -89,7 +89,7 @@ public class GetFavoriteSiteSanityTests extends RestTest dataSite.usingUser(consumerUser).usingSite(siteModel2).addSiteToFavorites(); restClient.authenticateUser(consumerUser); - peopleApi.getFavoriteSite(consumerUser, siteModel1).assertResponseIsNotEmpty(); + peopleApi.getFavoriteSite(consumerUser, siteModel1).and().assertField("id").isNotNull(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -102,7 +102,7 @@ public class GetFavoriteSiteSanityTests extends RestTest dataSite.usingUser(anyUser).usingSite(siteModel2).addSiteToFavorites(); restClient.authenticateUser(adminUset); - peopleApi.getFavoriteSite(anyUser, siteModel1).assertResponseIsNotEmpty(); + peopleApi.getFavoriteSite(anyUser, siteModel1).and().assertField("id").isNotNull(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleSanityTests.java index 32f0adcc0..799ceaf54 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleSanityTests.java @@ -41,7 +41,7 @@ public class GetPeopleSanityTests extends RestTest dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); restClient.authenticateUser(managerUser); - peopleApi.getPerson(searchedUser).assertIDIsNotEmpty(); + peopleApi.getPerson(searchedUser).and().assertField("id").is(searchedUser.getUsername());; peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } From 8689e3d00b8124ae07859aa55e5597a56e554338 Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 19 Oct 2016 11:42:39 +0300 Subject: [PATCH 0457/1491] TAS-1584 - add new process by a network user --- .../processes/AddProcessSanityTests.java | 72 +++++++++++++++++++ .../processes/DeleteProcessSanityTests.java | 4 +- .../processes/GetProcessesSanityTests.java | 8 +-- 3 files changed, 78 insertions(+), 6 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessSanityTests.java new file mode 100644 index 000000000..93d0b8a1e --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessSanityTests.java @@ -0,0 +1,72 @@ +package org.alfresco.rest.workflow.processes; + +import org.alfresco.dataprep.CMISUtil.Priority; +import org.alfresco.rest.RestWorkflowTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestProcessDefinitionModel; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.requests.RestProcessDefinitionsApi; +import org.alfresco.rest.requests.RestProcessesApi; +import org.alfresco.rest.requests.RestTenantApi; +import org.alfresco.utility.data.DataUser; +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.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Created by Claudia Agache on 10/18/2016. + */ +@Test(groups = { TestGroup.REST_API, TestGroup.PROCESSES, TestGroup.SANITY }) +public class AddProcessSanityTests extends RestWorkflowTest +{ + @Autowired + private DataUser dataUser; + + @Autowired + private RestProcessesApi processesApi; + + @Autowired + private RestProcessDefinitionsApi processDefinitionsApi; + + @Autowired + private RestTenantApi tenantApi; + + private UserModel userWhoStartsProcess, assignee; + private UserModel adminTenantUser, tenantUserWhoStartsProcess, tenantAssignee; + private RestProcessDefinitionModel randomProcessDefinition; + private RestProcessModel addedProcess; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + processDefinitionsApi.useRestClient(restClient); + processesApi.useRestClient(restClient); + tenantApi.useRestClient(restClient); + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(dataUser.getAdminUser()); + } + + + + @TestRail(section = { TestGroup.REST_API, + TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify network user is able to start new process using REST API and status code is OK (200)") + @Test(groups = { TestGroup.NETWORKS }) + public void networkUserStartsNewProcess() throws JsonToModelConversionException, Exception + { + tenantApi.createTenant(adminTenantUser); + restClient.authenticateUser(adminTenantUser); + tenantUserWhoStartsProcess = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + tenantAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("u2Tenant"); + randomProcessDefinition = processDefinitionsApi.getProcessDefinitions().getOneRandomEntry(); + + restClient.authenticateUser(tenantUserWhoStartsProcess); + addedProcess = processesApi.addProcess(randomProcessDefinition, tenantAssignee, false, Priority.Normal); + processesApi.getProcesses().assertProcessExists(addedProcess.getId()); + processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } +} diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java index 8f547af24..3945122a7 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java @@ -52,7 +52,7 @@ public class DeleteProcessSanityTests extends RestWorkflowTest restClient.authenticateUser(userWhoStartsTask); processesApi.deleteProcess(task); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); - processesApi.getProcesses().assertProcessDoesNotExist(task); + processesApi.getProcesses().assertProcessDoesNotExist(task.getNodeRef()); } @TestRail(section = { TestGroup.REST_API, @@ -63,7 +63,7 @@ public class DeleteProcessSanityTests extends RestWorkflowTest restClient.authenticateUser(assignee); processesApi.deleteProcess(task); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); - processesApi.getProcesses().assertProcessDoesNotExist(task); + processesApi.getProcesses().assertProcessDoesNotExist(task.getNodeRef()); } @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify User that is not involved in a process is not authorized to delete it using REST API and status code is 403") diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java index 2a3cb8766..d67264595 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java @@ -51,7 +51,7 @@ public class GetProcessesSanityTests extends RestWorkflowTest public void getProcessesByUserWhoStartedProcess() throws JsonToModelConversionException, Exception { restClient.authenticateUser(userWhoStartsTask); - processesApi.getProcesses().assertProcessExists(task); + processesApi.getProcesses().assertProcessExists(task.getNodeRef()); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -60,7 +60,7 @@ public class GetProcessesSanityTests extends RestWorkflowTest public void getProcessesByAssignedUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(assignee); - processesApi.getProcesses().assertProcessExists(task); + processesApi.getProcesses().assertProcessExists(task.getNodeRef()); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -69,7 +69,7 @@ public class GetProcessesSanityTests extends RestWorkflowTest public void getProcessesByAnotherUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(anotherUser); - processesApi.getProcesses().assertProcessDoesNotExist(task); + processesApi.getProcesses().assertProcessDoesNotExist(task.getNodeRef()); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -78,7 +78,7 @@ public class GetProcessesSanityTests extends RestWorkflowTest public void getProcessesByAdmin() throws JsonToModelConversionException, Exception { restClient.authenticateUser(dataUser.getAdminUser()); - processesApi.getProcesses().assertProcessExists(task); + processesApi.getProcesses().assertProcessExists(task.getNodeRef()); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } } From 0582cca61d283129a2596f7e2085a9edee7fe9b2 Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 19 Oct 2016 11:44:08 +0300 Subject: [PATCH 0458/1491] removed comments --- .../GetProcessDefinitionStartFormModelSanityTests.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java index 659224b61..a02d8b5cb 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java @@ -39,7 +39,6 @@ public class GetProcessDefinitionStartFormModelSanityTests extends RestWorkflowT restClient.authenticateUser(adminUserModel); } - // works on docker @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.SANITY, description = "Verify Admin gets a model of the start form type definition for non-network deployments using REST API and status code is OK (200)") @@ -50,7 +49,6 @@ public class GetProcessDefinitionStartFormModelSanityTests extends RestWorkflowT processDefinitionsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - // works on 215 @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.SANITY, description = "Verify Tenant Admin gets a model of the start form type definition for network deployments using REST API and status code is OK (200)") From d1dd9c91bdd877dbf40200cce40ff2f2f2af3284 Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 19 Oct 2016 11:44:59 +0300 Subject: [PATCH 0459/1491] used ModelAssertion --- .../processDefinitions/GetProcessDefinitionSanityTests.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java index cc52a1a11..c72372954 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java @@ -41,7 +41,7 @@ public class GetProcessDefinitionSanityTests extends RestWorkflowTest description = "Verify Admin user gets a specific process definition for non-network deployments using REST API and status code is OK (200)") public void adminGetsProcessDefinition() throws Exception { - processDefinitionsApi.getProcessDefinition(randomProcessDefinition).assertProcessDefinitionNameIs(randomProcessDefinition.onModel().getName()); + processDefinitionsApi.getProcessDefinition(randomProcessDefinition).and().assertField("name").is(randomProcessDefinition.onModel().getName()); processDefinitionsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -51,7 +51,7 @@ public class GetProcessDefinitionSanityTests extends RestWorkflowTest public void anyUserGetsProcessDefinition() throws Exception { restClient.authenticateUser(testUser); - processDefinitionsApi.getProcessDefinition(randomProcessDefinition).assertProcessDefinitionNameIs(randomProcessDefinition.onModel().getName()); + processDefinitionsApi.getProcessDefinition(randomProcessDefinition).and().assertField("name").is(randomProcessDefinition.onModel().getName()); processDefinitionsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } } From 7f46f189d17692f34126e9f1fe0d54dac9bd6ba8 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Wed, 19 Oct 2016 15:20:44 +0300 Subject: [PATCH 0460/1491] adding params and model assertion dsl --- e2e-test/java/org/alfresco/rest/demo/RestDemoTests.java | 9 +++++---- .../java/org/alfresco/rest/demo/SampleSitesTests.java | 2 +- .../java/org/alfresco/rest/model/ModelAssertionTest.java | 7 ++----- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/demo/RestDemoTests.java b/e2e-test/java/org/alfresco/rest/demo/RestDemoTests.java index b6dea37af..2574fa3fb 100644 --- a/e2e-test/java/org/alfresco/rest/demo/RestDemoTests.java +++ b/e2e-test/java/org/alfresco/rest/demo/RestDemoTests.java @@ -15,7 +15,6 @@ import org.alfresco.utility.model.UserModel; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.social.alfresco.api.entities.Role; -import org.springframework.social.alfresco.api.entities.Site.Visibility; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -57,9 +56,11 @@ public class RestDemoTests extends RestTest sitesApi.getAllSites() .assertThatResponseHasSite(siteModel) .getSite(siteModel) - .assertSiteHasVisibility(Visibility.PUBLIC) - .assertSiteHasTitle(siteModel.getTitle()) - .assertSiteHasDescription(siteModel.getDescription()); + .and().assertField("").is(""); + +// .assertSiteHasVisibility(Visibility.PUBLIC) +// .assertSiteHasTitle(siteModel.getTitle()) +// .assertSiteHasDescription(siteModel.getDescription()); } /** diff --git a/e2e-test/java/org/alfresco/rest/demo/SampleSitesTests.java b/e2e-test/java/org/alfresco/rest/demo/SampleSitesTests.java index 6b749873a..7aae00c5e 100644 --- a/e2e-test/java/org/alfresco/rest/demo/SampleSitesTests.java +++ b/e2e-test/java/org/alfresco/rest/demo/SampleSitesTests.java @@ -71,7 +71,7 @@ public class SampleSitesTests extends RestTest public void adminShouldAccessResponsePagination() throws JsonToModelConversionException, Exception { siteAPI.getSites() - .assertResponseHasPagination(); + .assertPaginationExist(); } @TestRail(section={"demo", "sample-section"}, executionType= ExecutionType.SANITY, diff --git a/e2e-test/java/org/alfresco/rest/model/ModelAssertionTest.java b/e2e-test/java/org/alfresco/rest/model/ModelAssertionTest.java index 0af963129..6f8587505 100644 --- a/e2e-test/java/org/alfresco/rest/model/ModelAssertionTest.java +++ b/e2e-test/java/org/alfresco/rest/model/ModelAssertionTest.java @@ -49,13 +49,10 @@ public class ModelAssertionTest { this.id = id; } - public ModelAssertion and() + public ModelAssertion and() { - return new ModelAssertion(this); + return new ModelAssertion(this); } - } - - } From 9b3550afdefae87caac2c1b7e0655f7925d5f746 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Wed, 19 Oct 2016 15:45:35 +0300 Subject: [PATCH 0461/1491] WIP: dsl assertion --- .../rest/model/ModelAssertionTest.java | 58 ------------------- 1 file changed, 58 deletions(-) delete mode 100644 e2e-test/java/org/alfresco/rest/model/ModelAssertionTest.java diff --git a/e2e-test/java/org/alfresco/rest/model/ModelAssertionTest.java b/e2e-test/java/org/alfresco/rest/model/ModelAssertionTest.java deleted file mode 100644 index 6f8587505..000000000 --- a/e2e-test/java/org/alfresco/rest/model/ModelAssertionTest.java +++ /dev/null @@ -1,58 +0,0 @@ -package org.alfresco.rest.model; - -import org.alfresco.rest.core.ModelAssertion; -import org.alfresco.utility.exception.TestConfigurationException; -import org.testng.annotations.Test; - -public class ModelAssertionTest { - @Test - public void iCanAssertExistingProperty() throws Exception { - Person p = new Person(); - p.and().assertField("id").is("1234"); - } - - @Test - public void iCanAssertExistingPropertyNegative() throws Exception { - Person p = new Person(); - p.and().assertField("id").isNot("12342"); - RestPersonModel rp = new RestPersonModel(); - - rp.getFirstName(); - } - - @Test(expectedExceptions = TestConfigurationException.class) - public void iHaveOneExceptionThrownWithSelfExplanatoryMessageOnMissingField() throws Exception { - Person p = new Person(); - p.and().assertField("id2").is("12342"); - - } - - @Test - public void iCanTakeTheValueOfFieldsThatDoesntHaveGetters() throws Exception { - Person p = new Person(); - - p.and().assertField("name").is("test"); - - } - - public class Person { - private String id = "1234"; - - @SuppressWarnings("unused") - private String name = "test"; - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public ModelAssertion and() - { - return new ModelAssertion(this); - } - } - -} From c39b20ba706767e328999a1b139602920270e4bb Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Wed, 19 Oct 2016 16:33:21 +0300 Subject: [PATCH 0462/1491] TAS-1576 addTaskVariables, perform request with admin --- .../tasks/AddTaskVariablesSanityTests.java | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesSanityTests.java new file mode 100644 index 000000000..bf3595f45 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesSanityTests.java @@ -0,0 +1,61 @@ +package org.alfresco.rest.workflow.tasks; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestWorkflowTest; +import org.alfresco.rest.model.RestVariableModel; +import org.alfresco.rest.requests.RestTasksApi; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TaskModel; +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.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * @author iulia.cojocea + */ +@Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) +public class AddTaskVariablesSanityTests extends RestWorkflowTest +{ + @Autowired + RestTasksApi tasksApi; + + private UserModel userModel, userWhoStartsTask; + private SiteModel siteModel; + private FileModel fileModel; + private UserModel assigneeUser; + private TaskModel taskModel; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + userWhoStartsTask = dataUser.createRandomTestUser(); + assigneeUser = dataUser.createRandomTestUser(); + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + + tasksApi.useRestClient(restClient); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Create non-existing task variable with admin") + public void createTaskVariableWithAdmin() throws Exception + { + UserModel adminUser = dataUser.getAdminUser(); + restClient.authenticateUser(adminUser); + RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + tasksApi.addTaskVariable(taskModel, variableModel) + .and().assertField("scope").is(variableModel.getScope()) + .and().assertField("name").is(variableModel.getName()) + .and().assertField("value").is(variableModel.getValue()) + .and().assertField("type").is(variableModel.getType()); + tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + } +} From 703967592ab2d77fcb75d4ad61bca6f1114233f5 Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Wed, 19 Oct 2016 16:34:13 +0300 Subject: [PATCH 0463/1491] TAS-1577 addTaskVariables, perform request with involved user --- .../tasks/AddTaskVariablesSanityTests.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesSanityTests.java index bf3595f45..7fb3d3fde 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesSanityTests.java @@ -58,4 +58,18 @@ public class AddTaskVariablesSanityTests extends RestWorkflowTest .and().assertField("type").is(variableModel.getType()); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Create non-existing task variable with user involved in the process") + public void createTaskVariableWithInvolvedUser() throws Exception + { + restClient.authenticateUser(assigneeUser); + RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + tasksApi.addTaskVariable(taskModel, variableModel) + .and().assertField("scope").is(variableModel.getScope()) + .and().assertField("name").is(variableModel.getName()) + .and().assertField("value").is(variableModel.getValue()) + .and().assertField("type").is(variableModel.getType()); + tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + } } From d77db250d86da1826eb6402de0ed23316243bee2 Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Wed, 19 Oct 2016 16:34:49 +0300 Subject: [PATCH 0464/1491] TAS-1578, addTaskVariables, addTaskVariables --- .../tasks/AddTaskVariablesSanityTests.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesSanityTests.java index 7fb3d3fde..493d15b59 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesSanityTests.java @@ -72,4 +72,18 @@ public class AddTaskVariablesSanityTests extends RestWorkflowTest .and().assertField("type").is(variableModel.getType()); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Create non-existing task variable with task owner") + public void createTaskVariableWithTaskOwner() throws Exception + { + restClient.authenticateUser(userWhoStartsTask); + RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + tasksApi.addTaskVariable(taskModel, variableModel) + .and().assertField("scope").is(variableModel.getScope()) + .and().assertField("name").is(variableModel.getName()) + .and().assertField("value").is(variableModel.getValue()) + .and().assertField("type").is(variableModel.getType()); + tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + } } From ea30082597662338ae9ebf3564690d6e978c04bf Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Wed, 19 Oct 2016 16:35:41 +0300 Subject: [PATCH 0465/1491] TAS-1579 addTaskVariables, perform request with any other user --- .../java/org/alfresco/rest/demo/RestDemoTests.java | 11 +++++------ .../workflow/tasks/AddTaskVariablesSanityTests.java | 11 +++++++++++ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/demo/RestDemoTests.java b/e2e-test/java/org/alfresco/rest/demo/RestDemoTests.java index b6dea37af..379fb0c82 100644 --- a/e2e-test/java/org/alfresco/rest/demo/RestDemoTests.java +++ b/e2e-test/java/org/alfresco/rest/demo/RestDemoTests.java @@ -54,12 +54,11 @@ public class RestDemoTests extends RestTest @Test public void adminRetrievesCorrectSiteDetails() throws JsonToModelConversionException, Exception { - sitesApi.getAllSites() - .assertThatResponseHasSite(siteModel) - .getSite(siteModel) - .assertSiteHasVisibility(Visibility.PUBLIC) - .assertSiteHasTitle(siteModel.getTitle()) - .assertSiteHasDescription(siteModel.getDescription()); + sitesApi.getAllSites().assertThatResponseHasSite(siteModel).getSite(siteModel) + .and().assertField("id").isNotNull() + .and().assertField("description").is(siteModel.getDescription()) + .and().assertField("title").is(siteModel.getTitle()) + .and().assertField("visibility").is(siteModel.getVisibility()); } /** diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesSanityTests.java index 493d15b59..18784ede0 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesSanityTests.java @@ -86,4 +86,15 @@ public class AddTaskVariablesSanityTests extends RestWorkflowTest .and().assertField("type").is(variableModel.getType()); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Create non-existing task variable with any user") + public void createTaskVariableWithRandomUser() throws Exception + { + userModel = dataUser.createRandomTestUser(); + restClient.authenticateUser(userModel); + RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + tasksApi.addTaskVariable(taskModel, variableModel); + tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + } } From 30985912424705728838d38992a8d8a1b829b2fc Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 19 Oct 2016 16:38:56 +0300 Subject: [PATCH 0466/1491] TAS-1583 - add new process by a non-network user --- .../processes/AddProcessSanityTests.java | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessSanityTests.java index 93d0b8a1e..9c0a8e435 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessSanityTests.java @@ -30,28 +30,34 @@ public class AddProcessSanityTests extends RestWorkflowTest @Autowired private RestProcessesApi processesApi; - @Autowired - private RestProcessDefinitionsApi processDefinitionsApi; - @Autowired private RestTenantApi tenantApi; private UserModel userWhoStartsProcess, assignee; private UserModel adminTenantUser, tenantUserWhoStartsProcess, tenantAssignee; - private RestProcessDefinitionModel randomProcessDefinition; private RestProcessModel addedProcess; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception { - processDefinitionsApi.useRestClient(restClient); processesApi.useRestClient(restClient); tenantApi.useRestClient(restClient); adminTenantUser = UserModel.getAdminTenantUser(); restClient.authenticateUser(dataUser.getAdminUser()); } + @TestRail(section = { TestGroup.REST_API, + TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify non network user is able to start new process using REST API and status code is OK (200)") + public void nonNetworkUserStartsNewProcess() throws JsonToModelConversionException, Exception + { + userWhoStartsProcess = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + restClient.authenticateUser(userWhoStartsProcess); + addedProcess = processesApi.addProcess("activitiAdhoc", assignee, false, Priority.Normal); + processesApi.getProcesses().assertProcessExists(addedProcess.getId()); + processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify network user is able to start new process using REST API and status code is OK (200)") @@ -62,10 +68,9 @@ public class AddProcessSanityTests extends RestWorkflowTest restClient.authenticateUser(adminTenantUser); tenantUserWhoStartsProcess = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); tenantAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("u2Tenant"); - randomProcessDefinition = processDefinitionsApi.getProcessDefinitions().getOneRandomEntry(); restClient.authenticateUser(tenantUserWhoStartsProcess); - addedProcess = processesApi.addProcess(randomProcessDefinition, tenantAssignee, false, Priority.Normal); + addedProcess = processesApi.addProcess("activitiAdhoc", tenantAssignee, false, Priority.Normal); processesApi.getProcesses().assertProcessExists(addedProcess.getId()); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } From 3771c11c46565fcd43ae2b7c421f58588d6291b7 Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Wed, 19 Oct 2016 16:52:08 +0300 Subject: [PATCH 0467/1491] TAS-1551, removeTaskVariable, provide valid details, code is 204 --- .../tasks/DeleteTaskVariableSanityTests.java | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/tasks/DeleteTaskVariableSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/DeleteTaskVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/DeleteTaskVariableSanityTests.java new file mode 100644 index 000000000..93990bf90 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/DeleteTaskVariableSanityTests.java @@ -0,0 +1,57 @@ +package org.alfresco.rest.workflow.tasks; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestWorkflowTest; +import org.alfresco.rest.model.RestVariableModel; +import org.alfresco.rest.requests.RestTasksApi; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TaskModel; +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.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * @author iulia.cojocea + */ +@Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) +public class DeleteTaskVariableSanityTests extends RestWorkflowTest +{ + @Autowired + RestTasksApi tasksApi; + + private UserModel userModel, adminUser; + private SiteModel siteModel; + private FileModel fileModel; + private UserModel assigneeUser; + private TaskModel taskModel; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + assigneeUser = dataUser.createRandomTestUser(); + taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + + tasksApi.useRestClient(restClient); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Delete existing task variable") + public void deleteTaskVariable() throws Exception + { + restClient.authenticateUser(adminUser); + RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + tasksApi.updateTaskVariable(taskModel, variableModel); + tasksApi.deleteTaskVariable(taskModel, variableModel); + tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); + } +} From 01ee7e419283b4cb30e435ed7728689a2811b25b Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Wed, 19 Oct 2016 16:52:58 +0300 Subject: [PATCH 0468/1491] TAS-1552, removeTaskVariable, for invalid taskId return 404 --- .../tasks/DeleteTaskVariableSanityTests.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/DeleteTaskVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/DeleteTaskVariableSanityTests.java index 93990bf90..a83f35eff 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/DeleteTaskVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/DeleteTaskVariableSanityTests.java @@ -54,4 +54,16 @@ public class DeleteTaskVariableSanityTests extends RestWorkflowTest tasksApi.deleteTaskVariable(taskModel, variableModel); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Try to delete existing task variable using invalid task id") + public void tryToDeleteTaskVariableUsingInvalidTaskId() throws Exception + { + restClient.authenticateUser(adminUser); + RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + tasksApi.updateTaskVariable(taskModel, variableModel); + taskModel.setId("incorrectTaskId"); + tasksApi.deleteTaskVariable(taskModel, variableModel); + tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); + } } From 6023662be2a885d63a66aa59c305587cdac06304 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Wed, 19 Oct 2016 20:53:09 +0300 Subject: [PATCH 0469/1491] major update adding DSL of assertion --- .../comments/UpdateCommentsSanityTests.java | 14 ++-- .../org/alfresco/rest/demo/RMDemoTest.java | 80 +++++++++++++++++++ .../org/alfresco/rest/demo/RestDemoTests.java | 34 ++++---- .../rest/demo/SampleCommentsTests.java | 4 +- .../alfresco/rest/demo/SampleSitesTests.java | 2 +- .../people/AddFavoriteSiteSanityTests.java | 4 + .../rest/ratings/GetRatingSanityTests.java | 41 +++++----- .../rest/tags/AddTagsSanityTests.java | 19 ++++- .../rest/tags/GetNodeTagsSanityTests.java | 12 +-- .../DeleteDeploymentSanityTests.java | 3 +- .../GetProcessDefinitionSanityTests.java | 5 +- .../processes/AddProcessItemSanityTests.java | 5 +- .../processes/DeleteProcessSanityTests.java | 4 +- .../processes/GetProcessTasksSanityTests.java | 14 ++-- .../processes/GetProcessesSanityTests.java | 8 +- .../RemoveProcessItemSanityTests.java | 2 +- .../RemoveProcessVariableSanityTests.java | 2 +- .../UpdateProcessVariableSanityTests.java | 4 +- 18 files changed, 181 insertions(+), 76 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/demo/RMDemoTest.java diff --git a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java index 5937f4910..3e9c3be25 100644 --- a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java @@ -63,7 +63,9 @@ public class UpdateCommentsSanityTests extends RestTest public void managerIsAbleToUpdateComment() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - commentsAPI.updateComment(document, commentModel, "This is the updated comment with Manager user"); + commentsAPI.updateComment(document, commentModel, "This is the updated comment with Manager user") + .and().assertField("content").is("This is the updated comment with Manager user") + .and().assertField("canDelete").is(true); commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -91,9 +93,10 @@ public class UpdateCommentsSanityTests extends RestTest public void collaboratorIsNotAbleToUpdateComment() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - RestCommentModel commentEntry = commentsAPI.updateComment(document, commentModel, "This is the updated comment with Collaborator user"); - commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); - commentEntry.assertCommentContentIs("This is the updated comment with Collaborator user"); + commentsAPI.updateComment(document, commentModel, "This is the updated comment with Collaborator user") + .and().assertField("content").is("This is the updated comment with Collaborator user"); + + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } @TestRail(section = { TestGroup.REST_API, @@ -114,7 +117,7 @@ public class UpdateCommentsSanityTests extends RestTest FolderModel content = FolderModel.getRandomFolderModel(); content.setNodeRef("node ref that does not exist"); - commentsAPI.updateComment(content, commentModel, "This is the updated comment."); + commentsAPI.updateComment(content, commentModel, "This is the updated comment."); commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); } @@ -126,6 +129,7 @@ public class UpdateCommentsSanityTests extends RestTest RestCommentModel comment = new RestCommentModel(); comment.setId("comment id that does not exist"); commentsAPI.updateComment(document, comment, "This is the updated comment."); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); } diff --git a/e2e-test/java/org/alfresco/rest/demo/RMDemoTest.java b/e2e-test/java/org/alfresco/rest/demo/RMDemoTest.java new file mode 100644 index 000000000..54d685ca6 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/demo/RMDemoTest.java @@ -0,0 +1,80 @@ +package org.alfresco.rest.demo; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.requests.RestSitesApi; +import org.alfresco.utility.exception.DataPreparationException; +import org.alfresco.utility.exception.TestConfigurationException; +import org.alfresco.utility.model.SiteModel; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.social.alfresco.api.entities.Site.Visibility; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +@Test(groups = { "demo" }) +public class RMDemoTest extends RestTest { + @Autowired + RestSitesApi sitesApi; + + private SiteModel siteModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws DataPreparationException { + siteModel = dataSite.usingAdmin().createPublicRandomSite(); + restClient.authenticateUser(dataUser.getAdminUser()); + + sitesApi.useRestClient(restClient); + } + + @Test + public void adminCanSeeDetailsOfARandomSiteCreated() throws JsonToModelConversionException, Exception + { + sitesApi.getSite(siteModel) + .and().assertField("id").isNotNull() + .and().assertField("description").is(siteModel.getDescription()) + .and().assertField("title").is(siteModel.getTitle()); + } + + @Test + public void adminCanSeeSiteDetailsOfCustomSite() throws JsonToModelConversionException, Exception + { + siteModel = new SiteModel("MyTitle"); + siteModel.setDescription("my description"); + siteModel.setVisibility(Visibility.PUBLIC); + + // here we create the custom siteModel defined above + dataSite.usingAdmin().createSite(siteModel); + + sitesApi.getSite(siteModel) + .and().assertField("id").isNotNull() + .and().assertField("description").is("my description") + .and().assertField("title").is("MyTitle") + .and().assertField("visibility").is(Visibility.PUBLIC); + } + + /** + * This will throw this error message: + * "You missed some configuration settings in your tests: You try to assert field [fieldA] that + * doesn't exist in class: [org.alfresco.rest.model.RestSiteModel]. Please check your code!" + */ + @Test(expectedExceptions = TestConfigurationException.class) + public void assertingWithFieldsThatDoesNotExist() throws JsonToModelConversionException, Exception { + siteModel = dataSite.createPublicRandomSite(); + + sitesApi.getSite(siteModel).and().assertField("fieldA").isNotNull(); + } + + @Test + public void assertingPaginationAndUsingParameters() throws Exception + { + /* + * ~ each API has the possibility to pass parameters to httpMethod call + * you can use withParams(String... parameters) method before calling the http method. + */ + sitesApi.withParams("maxItems=2", "orderyBy=name").getSites() + .assertPaginationExist() + .assertPaginationField("maxItems").is("2") + .assertPaginationField("skipCount").is("0"); + } + +} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/demo/RestDemoTests.java b/e2e-test/java/org/alfresco/rest/demo/RestDemoTests.java index 2574fa3fb..08a1fd97b 100644 --- a/e2e-test/java/org/alfresco/rest/demo/RestDemoTests.java +++ b/e2e-test/java/org/alfresco/rest/demo/RestDemoTests.java @@ -15,6 +15,7 @@ import org.alfresco.utility.model.UserModel; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.social.alfresco.api.entities.Role; +import org.springframework.social.alfresco.api.entities.Site.Visibility; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -54,9 +55,9 @@ public class RestDemoTests extends RestTest public void adminRetrievesCorrectSiteDetails() throws JsonToModelConversionException, Exception { sitesApi.getAllSites() - .assertThatResponseHasSite(siteModel) - .getSite(siteModel) - .and().assertField("").is(""); + .assertEntriesListContains("id", siteModel.getId()) + .getSite(siteModel) + .and().assertField("visibility").is(Visibility.PUBLIC); // .assertSiteHasVisibility(Visibility.PUBLIC) // .assertSiteHasTitle(siteModel.getTitle()) @@ -74,21 +75,23 @@ public class RestDemoTests extends RestTest public void adminCanPostAndUpdateComments() throws Exception { FileModel fileModel = dataContent.usingUser(userModel) - .usingResource(FolderModel.getSharedFolderModel()) - .createContent(DocumentType.TEXT_PLAIN); + .usingResource(FolderModel.getSharedFolderModel()) + .createContent(DocumentType.TEXT_PLAIN); // add new comment RestCommentModel commentEntry = commentsAPI.addComment(fileModel, "This is a new comment"); commentsAPI.getNodeComments(fileModel) .assertEntriesListIsNotEmpty() - .assertCommentWithIdExists(commentEntry); + .assertEntriesListContains("content", "This is a new comment"); + //.assertEntriesListIsEmpty() + //.assertCommentWithIdExists(commentEntry); - // update comment - commentEntry = commentsAPI.updateComment(fileModel, commentEntry, "This is the updated comment with Collaborator user"); - - commentsAPI.getNodeComments(fileModel) - .assertEntriesListIsNotEmpty() - .assertCommentWithIdExists(commentEntry) - .assertCommentWithContentExists("This is the updated comment"); +// // update comment +// commentEntry = commentsAPI.updateComment(fileModel, commentEntry, "This is the updated comment with Collaborator user"); +// +// commentsAPI.getNodeComments(fileModel) +// .assertEntriesListIsNotEmpty(); + //.assertCommentWithIdExists(commentEntry) + //.assertCommentWithContentExists("This is the updated comment"); } /** @@ -108,8 +111,7 @@ public class RestDemoTests extends RestTest // add user as Consumer to site sitesApi.addPerson(siteModel, testUser); - sitesApi.getSiteMembers(siteModel) - .assertThatSiteHasMember(testUser.getUsername()) + sitesApi.getSiteMembers(siteModel).assertEntriesListContains("id", testUser.getUsername()) .getSiteMember(testUser.getUsername()) .assertSiteMemberHasRole(Role.SiteConsumer); @@ -117,7 +119,7 @@ public class RestDemoTests extends RestTest testUser.setUserRole(UserRole.SiteCollaborator); sitesApi.updateSiteMember(siteModel, testUser); sitesApi.getSiteMembers(siteModel) - .assertThatSiteHasMember(testUser.getUsername()) + .assertEntriesListContains("id", testUser.getUsername()) .getSiteMember(testUser.getUsername()) .assertSiteMemberHasRole(Role.SiteCollaborator); diff --git a/e2e-test/java/org/alfresco/rest/demo/SampleCommentsTests.java b/e2e-test/java/org/alfresco/rest/demo/SampleCommentsTests.java index 876820d43..94181f1ca 100644 --- a/e2e-test/java/org/alfresco/rest/demo/SampleCommentsTests.java +++ b/e2e-test/java/org/alfresco/rest/demo/SampleCommentsTests.java @@ -63,8 +63,8 @@ public class SampleCommentsTests extends RestTest { RestCommentModel commentModel = commentsAPI.addComment(document, "This is a new comment"); - RestCommentModel commentEntry = commentsAPI.updateComment(document, commentModel, "This is the updated comment with Collaborator user"); - commentEntry.assertCommentContentIs("This is the updated comment"); + commentsAPI.updateComment(document, commentModel, "This is the updated comment with Collaborator user") + .and().assertField("content").is("This is the updated comment"); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/demo/SampleSitesTests.java b/e2e-test/java/org/alfresco/rest/demo/SampleSitesTests.java index 7aae00c5e..72ece6f5f 100644 --- a/e2e-test/java/org/alfresco/rest/demo/SampleSitesTests.java +++ b/e2e-test/java/org/alfresco/rest/demo/SampleSitesTests.java @@ -90,7 +90,7 @@ public class SampleSitesTests extends RestTest public void adminShouldGetSiteFromSitesList() throws JsonToModelConversionException, Exception { siteAPI.getAllSites() - .assertThatResponseHasSite(siteModel); + .assertEntriesListContains("id", siteModel.getId()); } @TestRail(section={"demo", "sample-section"}, executionType= ExecutionType.SANITY, diff --git a/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteSanityTests.java index 381129504..160e301fd 100644 --- a/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteSanityTests.java @@ -42,6 +42,10 @@ public class AddFavoriteSiteSanityTests extends RestTest restClient.authenticateUser(managerUser); peopleApi.addFavoriteSite(managerUser, siteModel); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + + peopleApi.addFavoriteSite(managerUser, siteModel); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CONFLICT); + peopleApi.usingRestWrapper().assertLastError().containsSummary("i3s already a favourite site"); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify collaborator user add a favorite site with Rest API and response is successful (201)") diff --git a/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java index 42c2886e6..c2b254b16 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java @@ -60,14 +60,15 @@ public class GetRatingSanityTests extends RestTest ratingsApi.rateStarsToDocument(document, 5); ratingsApi.getLikeRating(document) - .assertLikeRatingExists() - .assertMyLikeRatingIs(Boolean.TRUE); + .and().assertField("id").is("likes") + .and().assertField("myRating").is("true"); + ratingsApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.OK); ratingsApi.getFiveStarRating(document) - .assertFiveStarRatingExists() - .assertMyFiveStarRatingIs(5); + .and().assertField("id").is("fiveStar") + .and().assertField("myRating").is("5"); ratingsApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.OK); } @@ -82,14 +83,14 @@ public class GetRatingSanityTests extends RestTest ratingsApi.rateStarsToDocument(document, 5); ratingsApi.getLikeRating(document) - .assertLikeRatingExists() - .assertMyLikeRatingIs(Boolean.TRUE); + .and().assertField("id").is("likes") + .and().assertField("myRating").is("true"); ratingsApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.OK); ratingsApi.getFiveStarRating(document) - .assertFiveStarRatingExists() - .assertMyFiveStarRatingIs(5); + .and().assertField("id").is("fiveStar") + .and().assertField("myRating").is("5"); ratingsApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.OK); } @@ -104,14 +105,14 @@ public class GetRatingSanityTests extends RestTest ratingsApi.rateStarsToDocument(document, 5); ratingsApi.getLikeRating(document) - .assertLikeRatingExists() - .assertMyLikeRatingIs(Boolean.TRUE); + .and().assertField("id").is("likes") + .and().assertField("myRating").is("true"); ratingsApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.OK); ratingsApi.getFiveStarRating(document) - .assertFiveStarRatingExists() - .assertMyFiveStarRatingIs(5); + .and().assertField("id").is("fiveStar") + .and().assertField("myRating").is("5"); ratingsApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.OK); } @@ -126,14 +127,14 @@ public class GetRatingSanityTests extends RestTest ratingsApi.rateStarsToDocument(document, 5); ratingsApi.getLikeRating(document) - .assertLikeRatingExists() - .assertMyLikeRatingIs(Boolean.TRUE); + .and().assertField("id").is("likes") + .and().assertField("myRating").is("true"); ratingsApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.OK); ratingsApi.getFiveStarRating(document) - .assertFiveStarRatingExists() - .assertMyFiveStarRatingIs(5); + .and().assertField("id").is("fiveStar") + .and().assertField("myRating").is("5"); ratingsApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.OK); } @@ -149,14 +150,14 @@ public class GetRatingSanityTests extends RestTest ratingsApi.rateStarsToDocument(document, 5); ratingsApi.getLikeRating(document) - .assertLikeRatingExists() - .assertMyLikeRatingIs(Boolean.TRUE); + .and().assertField("id").is("likes") + .and().assertField("myRating").is("true"); ratingsApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.OK); ratingsApi.getFiveStarRating(document) - .assertFiveStarRatingExists() - .assertMyFiveStarRatingIs(5); + .and().assertField("id").is("fiveStar") + .and().assertField("myRating").is("5"); ratingsApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.OK); } diff --git a/e2e-test/java/org/alfresco/rest/tags/AddTagsSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/AddTagsSanityTests.java index 1888d26cf..2e8ffc9fe 100644 --- a/e2e-test/java/org/alfresco/rest/tags/AddTagsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/AddTagsSanityTests.java @@ -62,7 +62,10 @@ public class AddTagsSanityTests extends RestTest public void adminIsAbleToAddTags() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); - tagsAPI.addTags(document, tag1, tag2).assertThatResponseHasTags(tag1, tag2); + tagsAPI.addTags(document, tag1, tag2) + .assertEntriesListContains("tag", tag1.toLowerCase()) + .assertEntriesListContains("tag", tag2.toLowerCase()); + tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } @@ -71,7 +74,10 @@ public class AddTagsSanityTests extends RestTest public void managerIsAbleToAddTags() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - tagsAPI.addTags(document, tag1, tag2).assertThatResponseHasTags(tag1, tag2); + tagsAPI.addTags(document, tag1, tag2) + .assertEntriesListContains("tag", tag1.toLowerCase()) + .assertEntriesListContains("tag", tag2.toLowerCase()); + tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } @@ -80,7 +86,10 @@ public class AddTagsSanityTests extends RestTest public void collaboratorIsAbleToAddTags() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - tagsAPI.addTags(document, tag1, tag2).assertThatResponseHasTags(tag1, tag2); + tagsAPI.addTags(document, tag1, tag2) + .assertEntriesListContains("tag", tag1.toLowerCase()) + .assertEntriesListContains("tag", tag2.toLowerCase()); + tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } @@ -100,7 +109,9 @@ public class AddTagsSanityTests extends RestTest userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); restClient.authenticateUser(userModel); contributorDoc = dataContent.usingSite(siteModel).usingUser(userModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - tagsAPI.addTags(contributorDoc, tag1, tag2).assertThatResponseHasTags(tag1, tag2); + tagsAPI.addTags(contributorDoc, tag1, tag2) + .assertEntriesListContains("tag", tag1.toLowerCase()) + .assertEntriesListContains("tag", tag2.toLowerCase()); tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } diff --git a/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java index e3341f26f..45eb26d4f 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java @@ -62,7 +62,7 @@ public class GetNodeTagsSanityTests extends RestTest tagsAPI.addTag(document, tagValue); tagsAPI.getNodeTags(document) - .assertTagExists(tagValue); + .assertEntriesListContains("tag", tagValue.toLowerCase()); tagsAPI.usingRestWrapper() .assertStatusCodeIs(HttpStatus.OK); @@ -75,7 +75,7 @@ public class GetNodeTagsSanityTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - tagsAPI.getNodeTags(document).assertTagExists(tagValue); + tagsAPI.getNodeTags(document).assertEntriesListContains("tag", tagValue.toLowerCase()); tagsAPI.usingRestWrapper() .assertStatusCodeIs(HttpStatus.OK); @@ -86,7 +86,7 @@ public class GetNodeTagsSanityTests extends RestTest public void siteContributorIsAbleToRetrieveNodeTags() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - tagsAPI.getNodeTags(document).assertTagExists(tagValue); + tagsAPI.getNodeTags(document).assertEntriesListContains("tag", tagValue.toLowerCase()); tagsAPI.usingRestWrapper() .assertStatusCodeIs(HttpStatus.OK); @@ -97,7 +97,7 @@ public class GetNodeTagsSanityTests extends RestTest public void siteConsumerIsAbleToRetrieveNodeTags() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - tagsAPI.getNodeTags(document).assertTagExists(tagValue); + tagsAPI.getNodeTags(document).assertEntriesListContains("tag", tagValue.toLowerCase()); tagsAPI.usingRestWrapper() .assertStatusCodeIs(HttpStatus.OK); @@ -108,7 +108,7 @@ public class GetNodeTagsSanityTests extends RestTest public void adminIsAbleToRetrieveNodeTags() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); - tagsAPI.getNodeTags(document).assertTagExists(tagValue); + tagsAPI.getNodeTags(document).assertEntriesListContains("tag", tagValue.toLowerCase()); tagsAPI.usingRestWrapper() .assertStatusCodeIs(HttpStatus.OK); @@ -120,7 +120,7 @@ public class GetNodeTagsSanityTests extends RestTest public void unauthenticatedUserIsNotAbleToRetrieveNodeTags() throws JsonToModelConversionException, Exception { restClient.authenticateUser(new UserModel("random user", "random password")); - tagsAPI.getNodeTags(document).assertTagExists(tagValue); + tagsAPI.getNodeTags(document).assertEntriesListContains("tag", tagValue.toLowerCase()); tagsAPI.usingRestWrapper() .assertStatusCodeIs(HttpStatus.UNAUTHORIZED); diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java index fc0ff623e..77253e697 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java @@ -44,7 +44,8 @@ public class DeleteDeploymentSanityTests extends RestWorkflowTest { restClient.authenticateUser(adminUser); // The deployment with name "customWorkflowExtentionForRest.bpmn" is created by Workflow Extention Point - deployment = deploymentsApi.getDeployments().getDeploymentWithName("customWorkflowExtentionForRest.bpmn"); + deploymentsApi.getDeployments() + .assertEntriesListContains("name", "customWorkflowExtentionForRest.bpmn"); deploymentsApi.deleteDeployment(deployment); deploymentsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java index cc52a1a11..b2311a262 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java @@ -41,7 +41,8 @@ public class GetProcessDefinitionSanityTests extends RestWorkflowTest description = "Verify Admin user gets a specific process definition for non-network deployments using REST API and status code is OK (200)") public void adminGetsProcessDefinition() throws Exception { - processDefinitionsApi.getProcessDefinition(randomProcessDefinition).assertProcessDefinitionNameIs(randomProcessDefinition.onModel().getName()); + processDefinitionsApi.getProcessDefinition(randomProcessDefinition). + and().assertField("name").is(randomProcessDefinition.onModel().getName()); processDefinitionsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -51,7 +52,7 @@ public class GetProcessDefinitionSanityTests extends RestWorkflowTest public void anyUserGetsProcessDefinition() throws Exception { restClient.authenticateUser(testUser); - processDefinitionsApi.getProcessDefinition(randomProcessDefinition).assertProcessDefinitionNameIs(randomProcessDefinition.onModel().getName()); + processDefinitionsApi.getProcessDefinition(randomProcessDefinition).and().assertField("name").is(randomProcessDefinition.onModel().getName()); processDefinitionsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemSanityTests.java index 09c163530..5a8b06ff8 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemSanityTests.java @@ -60,7 +60,8 @@ public class AddProcessItemSanityTests extends RestWorkflowTest processModel = processesApi.getProcesses().getOneRandomEntry(); processItem = processesApi.addProcessItem(processModel, document2); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); - processesApi.getProcessesItems(processModel).assertProcessItemExists(processItem); + processesApi.getProcessesItems(processModel).assertEntriesListContains("id", processItem.getId()); + } @Bug(id= "MNT-16966") @@ -73,7 +74,7 @@ public class AddProcessItemSanityTests extends RestWorkflowTest processModel = processesApi.getProcesses().getOneRandomEntry(); processItem = processesApi.addProcessItem(processModel, document3); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); - processesApi.getProcessesItems(processModel).assertProcessItemExists(processItem); + processesApi.getProcessesItems(processModel).assertEntriesListContains("id", processItem.getId()); processItem = processesApi.addProcessItem(processModel, document3); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.BAD_REQUEST); } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java index 8f547af24..f6895f617 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java @@ -52,7 +52,7 @@ public class DeleteProcessSanityTests extends RestWorkflowTest restClient.authenticateUser(userWhoStartsTask); processesApi.deleteProcess(task); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); - processesApi.getProcesses().assertProcessDoesNotExist(task); + processesApi.getProcesses().assertEntriesListDoesNotContain("id", task.getNodeRef()); } @TestRail(section = { TestGroup.REST_API, @@ -63,7 +63,7 @@ public class DeleteProcessSanityTests extends RestWorkflowTest restClient.authenticateUser(assignee); processesApi.deleteProcess(task); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); - processesApi.getProcesses().assertProcessDoesNotExist(task); + processesApi.getProcesses().assertEntriesListDoesNotContain("id", task.getNodeRef()); } @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify User that is not involved in a process is not authorized to delete it using REST API and status code is 403") diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksSanityTests.java index 023fb59fa..d38924343 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksSanityTests.java @@ -53,9 +53,9 @@ public class GetProcessTasksSanityTests extends RestWorkflowTest restClient.authenticateUser(userModel); processesApi.getProcessTasks(process) .assertEntriesListIsNotEmpty() - .assertTaskWithAssigneeExists(assignee1) - .assertTaskWithAssigneeExists(assignee2) - .assertTaskWithAssigneeExists(assignee3); + .assertEntriesListContains("assignee", assignee1.getUsername()) + .assertEntriesListContains("assignee", assignee2.getUsername()) + .assertEntriesListContains("assignee", assignee2.getUsername()); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -65,9 +65,9 @@ public class GetProcessTasksSanityTests extends RestWorkflowTest restClient.authenticateUser(assignee1); processesApi.getProcessTasks(process) .assertEntriesListIsNotEmpty() - .assertTaskWithAssigneeExists(assignee1) - .assertTaskWithAssigneeExists(assignee2) - .assertTaskWithAssigneeExists(assignee3); + .assertEntriesListContains("assignee", assignee1.getUsername()) + .assertEntriesListContains("assignee", assignee2.getUsername()) + .assertEntriesListContains("assignee", assignee2.getUsername()); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -81,7 +81,7 @@ public class GetProcessTasksSanityTests extends RestWorkflowTest restClient.authenticateUser(assignee2); processesApi.getProcessTasks(process) .assertEntriesListIsNotEmpty() - .assertTaskWithAssigneeExists(userModel); + .assertEntriesListContains("assignee", userModel.getUsername()); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java index 2a3cb8766..19ab2e9d9 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java @@ -51,7 +51,7 @@ public class GetProcessesSanityTests extends RestWorkflowTest public void getProcessesByUserWhoStartedProcess() throws JsonToModelConversionException, Exception { restClient.authenticateUser(userWhoStartsTask); - processesApi.getProcesses().assertProcessExists(task); + processesApi.getProcesses().assertEntriesListContains("id", task.getNodeRef()); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -60,7 +60,7 @@ public class GetProcessesSanityTests extends RestWorkflowTest public void getProcessesByAssignedUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(assignee); - processesApi.getProcesses().assertProcessExists(task); + processesApi.getProcesses().assertEntriesListContains("id", task.getNodeRef()); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -69,7 +69,7 @@ public class GetProcessesSanityTests extends RestWorkflowTest public void getProcessesByAnotherUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(anotherUser); - processesApi.getProcesses().assertProcessDoesNotExist(task); + processesApi.getProcesses().assertEntriesListDoesNotContain("id", task.getNodeRef()); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -78,7 +78,7 @@ public class GetProcessesSanityTests extends RestWorkflowTest public void getProcessesByAdmin() throws JsonToModelConversionException, Exception { restClient.authenticateUser(dataUser.getAdminUser()); - processesApi.getProcesses().assertProcessExists(task); + processesApi.getProcesses().assertEntriesListContains("id", task.getNodeRef()); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessItemSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessItemSanityTests.java index bccabecf2..73fd17535 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessItemSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessItemSanityTests.java @@ -59,7 +59,7 @@ public class RemoveProcessItemSanityTests extends RestWorkflowTest processItem = processesApi.addProcessItem(processModel, document2); processesApi.deleteProcessItem(processModel, processItem); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); - processesApi.getProcessesItems(processModel).assertProcessItemDoesNotExists(processItem); + processesApi.getProcessesItems(processModel).assertEntriesListDoesNotContain("id", processItem.getId()); } @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessVariableSanityTests.java index da177bc99..5cefa74c9 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessVariableSanityTests.java @@ -58,7 +58,7 @@ public class RemoveProcessVariableSanityTests extends RestWorkflowTest processesApi.addProcessVariable(processModel, variableModel); processesApi.deleteProcessVariable(processModel, variableModel); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); - processesApi.getProcessesVariables(processModel).assertProcessVariableDoesNotExist(variableModel); + processesApi.getProcessesVariables(processModel).assertEntriesListContains("name", variableModel.getName()); } @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/UpdateProcessVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/UpdateProcessVariableSanityTests.java index 35e323295..3dc8cd5f4 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/UpdateProcessVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/UpdateProcessVariableSanityTests.java @@ -56,7 +56,7 @@ public class UpdateProcessVariableSanityTests extends RestWorkflowTest RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); processModel = processesApi.getProcesses().getOneRandomEntry(); processesApi.updateProcessVariable(processModel, variableModel); - processesApi.getProcessesVariables(processModel).assertProcessVariableExists(variableModel); + processesApi.getProcessesVariables(processModel).assertEntriesListDoesNotContain("name", variableModel.getName()); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -69,7 +69,7 @@ public class UpdateProcessVariableSanityTests extends RestWorkflowTest processModel = processesApi.getProcesses().getOneRandomEntry(); processesApi.addProcessVariable(processModel, variableModel); variableModel.setValue("newValue"); - processesApi.updateProcessVariable(processModel, variableModel).assertProcessVariableHasValue("newValue"); + processesApi.updateProcessVariable(processModel, variableModel).and().assertField("value").is("newValue"); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } From fb3269b4ca9d1e0701983676a5475359f389ae35 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Wed, 19 Oct 2016 20:55:46 +0300 Subject: [PATCH 0470/1491] typo --- .../org/alfresco/rest/people/AddFavoriteSiteSanityTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteSanityTests.java index 160e301fd..4393d918f 100644 --- a/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteSanityTests.java @@ -45,7 +45,7 @@ public class AddFavoriteSiteSanityTests extends RestTest peopleApi.addFavoriteSite(managerUser, siteModel); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CONFLICT); - peopleApi.usingRestWrapper().assertLastError().containsSummary("i3s already a favourite site"); + peopleApi.usingRestWrapper().assertLastError().containsSummary("is already a favourite site"); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify collaborator user add a favorite site with Rest API and response is successful (201)") From 2537a46f20911b9fb73ca087dd3cf3636cf49fc4 Mon Sep 17 00:00:00 2001 From: cagache Date: Thu, 20 Oct 2016 10:15:17 +0300 Subject: [PATCH 0471/1491] TAS-1585 - get a specific process by user who started it --- .../processes/GetProcessSanityTests.java | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessSanityTests.java new file mode 100644 index 000000000..45903b4c9 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessSanityTests.java @@ -0,0 +1,52 @@ +package org.alfresco.rest.workflow.processes; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestWorkflowTest; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.requests.RestProcessesApi; +import org.alfresco.utility.data.DataUser; +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.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Created by Claudia Agache on 10/19/2016. + */ +@Test(groups = { TestGroup.REST_API, TestGroup.PROCESSES, TestGroup.SANITY }) +public class GetProcessSanityTests extends RestWorkflowTest +{ + @Autowired + private DataUser dataUser; + + @Autowired + private RestProcessesApi processesApi; + + private UserModel userWhoStartsProcess, assignee; + private RestProcessModel addedProcess; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + processesApi.useRestClient(restClient); + userWhoStartsProcess = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + restClient.authenticateUser(userWhoStartsProcess); + addedProcess = processesApi.addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.High); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify user is able to get the process started by him using REST API and status code is OK (200)") + public void getProcessByOwner() throws Exception + { + restClient.authenticateUser(userWhoStartsProcess); + processesApi.getProcess(addedProcess); + processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } + + +} From b645d99e51b913c97590d1f224c16c8411f7ccc6 Mon Sep 17 00:00:00 2001 From: cagache Date: Thu, 20 Oct 2016 10:16:30 +0300 Subject: [PATCH 0472/1491] TAS-1586 - get a specific process by user who is involved in process --- .../rest/workflow/processes/GetProcessSanityTests.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessSanityTests.java index 45903b4c9..baefb0e71 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessSanityTests.java @@ -48,5 +48,12 @@ public class GetProcessSanityTests extends RestWorkflowTest processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - + @TestRail(section = { TestGroup.REST_API, + TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify user is able to get the process assigned to him using REST API and status code is OK (200)") + public void getProcessByAssignee() throws Exception + { + restClient.authenticateUser(assignee); + processesApi.getProcess(addedProcess); + processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } } From 08a880df635a7578abb343c7538d94730f2a0677 Mon Sep 17 00:00:00 2001 From: cagache Date: Thu, 20 Oct 2016 10:17:27 +0300 Subject: [PATCH 0473/1491] TAS-1587 - get a specific process by admin --- .../rest/workflow/processes/GetProcessSanityTests.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessSanityTests.java index baefb0e71..440ac609f 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessSanityTests.java @@ -56,4 +56,13 @@ public class GetProcessSanityTests extends RestWorkflowTest processesApi.getProcess(addedProcess); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify admin is able to get any process using REST API and status code is OK (200)") + public void getProcessByAdmin() throws Exception + { + restClient.authenticateUser(dataUser.getAdminUser()); + processesApi.getProcess(addedProcess); + processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } } From aec5734f047de879f5a6483a83794affc1c5ab75 Mon Sep 17 00:00:00 2001 From: cagache Date: Thu, 20 Oct 2016 15:47:18 +0300 Subject: [PATCH 0474/1491] TAS-1605 - get task form models by admin --- .../tasks/GetTaskFormModelSanityTests.java | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelSanityTests.java new file mode 100644 index 000000000..54fed8499 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelSanityTests.java @@ -0,0 +1,47 @@ +package org.alfresco.rest.workflow.tasks; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestWorkflowTest; +import org.alfresco.rest.requests.RestTasksApi; +import org.alfresco.utility.model.*; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Created by Claudia Agache on 10/20/2016. + */ +@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) +public class GetTaskFormModelSanityTests extends RestWorkflowTest +{ + @Autowired RestTasksApi tasksApi; + + UserModel userModel; + SiteModel siteModel; + FileModel fileModel; + TaskModel taskModel; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + fileModel = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(userModel); + + tasksApi.useRestClient(restClient); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, + executionType = ExecutionType.SANITY, description = "Verify admin user gets all task form models with Rest API and response is successful (200)") + public void adminGetsTaskFormModels() throws Exception + { + restClient.authenticateUser(dataUser.getAdminUser()); + tasksApi.getTaskFormModel(taskModel).assertEntriesListIsNotEmpty(); + tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } + +} From b347a85ab08c8ecf672437a7a5379cbd19c026d7 Mon Sep 17 00:00:00 2001 From: cagache Date: Thu, 20 Oct 2016 15:48:36 +0300 Subject: [PATCH 0475/1491] TAS-1604 - get task form models by an involved user --- .../rest/workflow/tasks/GetTaskFormModelSanityTests.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelSanityTests.java index 54fed8499..b0d1d79e7 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelSanityTests.java @@ -44,4 +44,12 @@ public class GetTaskFormModelSanityTests extends RestWorkflowTest tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, + executionType = ExecutionType.SANITY, description = "Verify user involved in task gets all the task form models with Rest API and response is successful (200)") + public void involvedUserGetsTaskFormModels() throws Exception + { + restClient.authenticateUser(userModel); + tasksApi.getTaskFormModel(taskModel).assertEntriesListIsNotEmpty(); + tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } } From 8125ab03ee13ac2f0663c4aa7c66e2c10613fd33 Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Thu, 20 Oct 2016 17:11:50 +0300 Subject: [PATCH 0476/1491] TAS-1606, valid request to create non-existing item, 201 --- .../tasks/AddTaskItemSanityTests.java | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemSanityTests.java new file mode 100644 index 000000000..5dd880a3f --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemSanityTests.java @@ -0,0 +1,70 @@ +package org.alfresco.rest.workflow.tasks; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestWorkflowTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestProcessItemModel; +import org.alfresco.rest.requests.RestTasksApi; +import org.alfresco.rest.requests.RestTenantApi; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TaskModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +@Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) +public class AddTaskItemSanityTests extends RestWorkflowTest +{ + @Autowired + RestTasksApi tasksApi; + + @Autowired + RestTenantApi tenantApi; + + private UserModel userModel, userWhoStartsTask, assigneeUser, adminTenantUser, tenantUser, tenantUserAssignee;; + private SiteModel siteModel; + private FileModel fileModel, document2, document3, document4; + private TaskModel taskModel; + + private RestProcessItemModel taskItem; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + userWhoStartsTask = dataUser.createRandomTestUser(); + assigneeUser = dataUser.createRandomTestUser(); + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + + tasksApi.useRestClient(restClient); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Create non-existing task item") + public void createTaskItem() throws Exception + { + UserModel adminUser = dataUser.getAdminUser(); + restClient.authenticateUser(adminUser); + document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + taskItem = tasksApi.addTaskItem(taskModel, document2); + + taskItem.and().assertField("createdAt").is(taskItem.getCreatedAt()) + .and().assertField("size").is(taskItem.getSize()) + .and().assertField("createdBy").is(taskItem.getCreatedBy()) + .and().assertField("modifiedAt").is(taskItem.getModifiedAt()) + .and().assertField("name").is(taskItem.getName()) + .and().assertField("modifiedBy").is(taskItem.getModifiedBy()) + .and().assertField("id").is(taskItem.getId()) + .and().assertField("mimeType").is(taskItem.getMimeType()); + tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + } +} From 56f5bb826e626d0ed0bc4a8f99a63fde776b7d2e Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Thu, 20 Oct 2016 17:20:02 +0300 Subject: [PATCH 0477/1491] TAS-1607, valid request to update existing item without effect, 201 --- .../tasks/AddTaskItemSanityTests.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemSanityTests.java index 5dd880a3f..249d23c22 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemSanityTests.java @@ -67,4 +67,25 @@ public class AddTaskItemSanityTests extends RestWorkflowTest .and().assertField("mimeType").is(taskItem.getMimeType()); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } + + @Bug(id = "MNT-16966") + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Verify that in case task item exists request ") + public void createTaskItemThatAlreadyExists() throws Exception + { + UserModel adminUser = dataUser.getAdminUser(); + restClient.authenticateUser(adminUser); + document3 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + taskItem = tasksApi.addTaskItem(taskModel, document3); + taskItem.and().assertField("createdAt").is(taskItem.getCreatedAt()) + .and().assertField("size").is(taskItem.getSize()) + .and().assertField("createdBy").is(taskItem.getCreatedBy()) + .and().assertField("modifiedAt").is(taskItem.getModifiedAt()) + .and().assertField("name").is(taskItem.getName()) + .and().assertField("modifiedBy").is(taskItem.getModifiedBy()) + .and().assertField("id").is(taskItem.getId()) + .and().assertField("mimeType").is(taskItem.getMimeType()); + taskItem = tasksApi.addTaskItem(taskModel, document3); + tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.BAD_REQUEST); + } } From c9f1c419514f62a021e68a0c947290deac4d2066 Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Thu, 20 Oct 2016 17:21:01 +0300 Subject: [PATCH 0478/1491] TAS-1608, perform request by admin in the same network --- .../processes/AddProcessItemSanityTests.java | 4 +-- .../RemoveProcessItemSanityTests.java | 4 +-- .../tasks/AddTaskItemSanityTests.java | 27 +++++++++++++++++-- 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemSanityTests.java index 5a8b06ff8..21a6351c6 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemSanityTests.java @@ -3,7 +3,7 @@ package org.alfresco.rest.workflow.processes; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestWorkflowTest; import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestProcessItemModel; +import org.alfresco.rest.model.RestItemModel; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.rest.requests.RestProcessesApi; import org.alfresco.utility.data.DataUser; @@ -37,7 +37,7 @@ public class AddProcessItemSanityTests extends RestWorkflowTest private RestProcessModel processModel; private UserModel adminUser; - private RestProcessItemModel processItem; + private RestItemModel processItem; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessItemSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessItemSanityTests.java index 73fd17535..6db23ca79 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessItemSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessItemSanityTests.java @@ -3,7 +3,7 @@ package org.alfresco.rest.workflow.processes; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestWorkflowTest; import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestProcessItemModel; +import org.alfresco.rest.model.RestItemModel; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.rest.requests.RestProcessesApi; import org.alfresco.utility.data.DataUser; @@ -35,7 +35,7 @@ public class RemoveProcessItemSanityTests extends RestWorkflowTest private UserModel userWhoStartsTask, assignee; private RestProcessModel processModel; private UserModel adminUser; - private RestProcessItemModel processItem; + private RestItemModel processItem; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemSanityTests.java index 249d23c22..cff45252a 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemSanityTests.java @@ -3,7 +3,7 @@ package org.alfresco.rest.workflow.tasks; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestWorkflowTest; import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestProcessItemModel; +import org.alfresco.rest.model.RestItemModel; import org.alfresco.rest.requests.RestTasksApi; import org.alfresco.rest.requests.RestTenantApi; import org.alfresco.utility.model.FileModel; @@ -33,7 +33,7 @@ public class AddTaskItemSanityTests extends RestWorkflowTest private FileModel fileModel, document2, document3, document4; private TaskModel taskModel; - private RestProcessItemModel taskItem; + private RestItemModel taskItem; @BeforeClass(alwaysRun=true) public void dataPreparation() throws Exception @@ -88,4 +88,27 @@ public class AddTaskItemSanityTests extends RestWorkflowTest taskItem = tasksApi.addTaskItem(taskModel, document3); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.BAD_REQUEST); } + + @Test(groups = { TestGroup.NETWORKS }) + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Add task item using admin user from same network") + public void addTaskItemByAdminSameNetwork() throws JsonToModelConversionException, Exception + { + UserModel adminuser = dataUser.getAdminUser(); + restClient.authenticateUser(adminuser); + + adminTenantUser = UserModel.getAdminTenantUser(); + tenantApi.useRestClient(restClient); + tenantApi.createTenant(adminTenantUser); + + tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); + + siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); + dataWorkflow.usingUser(tenantUser).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(tenantUserAssignee); + + document4 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + taskItem = tasksApi.addTaskItem(taskModel, document4); + tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + } } From b515db19231ac2b518a723667d53aac976fcf50f Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Fri, 21 Oct 2016 12:58:04 +0300 Subject: [PATCH 0479/1491] adding new assertion --- .../tasks/GetTaskFormModelSanityTests.java | 31 +++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelSanityTests.java index b0d1d79e7..2cf2d89a3 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelSanityTests.java @@ -2,8 +2,13 @@ package org.alfresco.rest.workflow.tasks; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestWorkflowTest; +import org.alfresco.rest.model.RestFormModelsCollection; import org.alfresco.rest.requests.RestTasksApi; -import org.alfresco.utility.model.*; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TaskModel; +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.beans.factory.annotation.Autowired; @@ -40,7 +45,29 @@ public class GetTaskFormModelSanityTests extends RestWorkflowTest public void adminGetsTaskFormModels() throws Exception { restClient.authenticateUser(dataUser.getAdminUser()); - tasksApi.getTaskFormModel(taskModel).assertEntriesListIsNotEmpty(); + RestFormModelsCollection returnedCollection = tasksApi.getTaskFormModel(taskModel); + + + returnedCollection.assertEntriesListIsNotEmpty(); + + String[] qualifiedNames = { + "{http://www.alfresco.org/model/bpm/1.0}percentComplete", + "{http://www.alfresco.org/model/bpm/1.0}context", + "{http://www.alfresco.org/model/bpm/1.0}completedItems", + "{http://www.alfresco.org/model/content/1.0}name", + "{http://www.alfresco.org/model/bpm/1.0}packageActionGroup", + "{http://www.alfresco.org/model/bpm/1.0}reassignable", + "{http://www.alfresco.org/model/content/1.0}owner", + "{http://www.alfresco.org/model/bpm/1.0}outcome", + "{http://www.alfresco.org/model/bpm/1.0}taskId", + "{http://www.alfresco.org/model/bpm/1.0}packageItemActionGroup", + "{http://www.alfresco.org/model/bpm/1.0}completionDate"}; + + for(String formQualifiedName : qualifiedNames) + { + returnedCollection.assertEntriesListContains("qualifiedName", formQualifiedName); + } + tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } From 66ac099b3ec1c736d01c6c573b50289d1fc1d399 Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Fri, 21 Oct 2016 15:46:30 +0300 Subject: [PATCH 0480/1491] TAS-1597, get call with user that started task --- .../tasks/GetTaskItemsSanityTests.java | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskItemsSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskItemsSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskItemsSanityTests.java new file mode 100644 index 000000000..72055d7d0 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskItemsSanityTests.java @@ -0,0 +1,60 @@ +package org.alfresco.rest.workflow.tasks; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestWorkflowTest; +import org.alfresco.rest.model.RestItemModel; +import org.alfresco.rest.requests.RestTasksApi; +import org.alfresco.rest.requests.RestTenantApi; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TaskModel; +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.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +@Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) +public class GetTaskItemsSanityTests extends RestWorkflowTest +{ + @Autowired + RestTasksApi tasksApi; + + @Autowired + RestTenantApi tenantApi; + + private UserModel userModel, userWhoStartsTask, assignee, adminTenantUser, tenantUser, tenantUserAssignee; + private SiteModel siteModel; + private FileModel fileModel, document1; + private TaskModel taskModel; + private RestItemModel taskItem; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + userWhoStartsTask = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); + tasksApi.useRestClient(restClient); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Verify that user that started the process gets task items") + public void getTaskItemsByUserWhoStartedProcess() throws Exception + { + restClient.authenticateUser(userWhoStartsTask); + document1 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + taskItem = tasksApi.addTaskItem(taskModel, document1); + tasksApi.getTaskItems(taskModel) + .assertEntriesListIsNotEmpty() + .assertEntriesListContains("id", taskItem.getId()); + + tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } +} From b9ada52840dd8ff733dbcaa7e9375b40e150a386 Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Fri, 21 Oct 2016 15:47:29 +0300 Subject: [PATCH 0481/1491] TAS-1598, get call with user that is involved in task --- .../workflow/tasks/GetTaskItemsSanityTests.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskItemsSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskItemsSanityTests.java index 72055d7d0..d6cd1fba2 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskItemsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskItemsSanityTests.java @@ -57,4 +57,17 @@ public class GetTaskItemsSanityTests extends RestWorkflowTest tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Verify that involved user in process gets task items") + public void getTaskItemsByUserInvolvedInProcess() throws Exception + { + restClient.authenticateUser(assignee); + document1 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + taskItem = tasksApi.addTaskItem(taskModel, document1); + tasksApi.getTaskItems(taskModel) + .assertEntriesListIsNotEmpty() + .assertEntriesListContains("id", taskItem.getId()); + tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } } From 0b723816c42ed0a205b9163a77907005318daabc Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Fri, 21 Oct 2016 15:48:11 +0300 Subject: [PATCH 0482/1491] TAS-1599, get call with admin from same network --- .../tasks/GetTaskItemsSanityTests.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskItemsSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskItemsSanityTests.java index d6cd1fba2..20d79417c 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskItemsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskItemsSanityTests.java @@ -70,4 +70,29 @@ public class GetTaskItemsSanityTests extends RestWorkflowTest .assertEntriesListContains("id", taskItem.getId()); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Verify that user that started the process gets task items") + public void getTaskItemsByAdminInSameNetwork() throws Exception + { + UserModel adminuser = dataUser.getAdminUser(); + restClient.authenticateUser(adminuser); + + adminTenantUser = UserModel.getAdminTenantUser(); + tenantApi.useRestClient(restClient); + tenantApi.createTenant(adminTenantUser); + + tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); + + siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); + dataWorkflow.usingUser(tenantUser).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(tenantUserAssignee); + + document1 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + taskItem = tasksApi.addTaskItem(taskModel, document1); + tasksApi.getTaskItems(taskModel) + .assertEntriesListIsNotEmpty() + .assertEntriesListContains("id", taskItem.getId()); + tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } } From a466eb35e3f9bd40bb45ba7b1f6f75bb6269afb6 Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Fri, 21 Oct 2016 15:57:14 +0300 Subject: [PATCH 0483/1491] TAS-1609, provide valid details, code is 204 --- .../tasks/RemoveTaskItemSanityTests.java | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/tasks/RemoveTaskItemSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/RemoveTaskItemSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/RemoveTaskItemSanityTests.java new file mode 100644 index 000000000..ea77a36ac --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/RemoveTaskItemSanityTests.java @@ -0,0 +1,60 @@ +package org.alfresco.rest.workflow.tasks; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestWorkflowTest; +import org.alfresco.rest.model.RestItemModel; +import org.alfresco.rest.requests.RestTasksApi; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TaskModel; +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.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * @author iulia.cojocea + */ +@Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) +public class RemoveTaskItemSanityTests extends RestWorkflowTest +{ + @Autowired + RestTasksApi tasksApi; + + + private UserModel adminUser, userModel, userWhoStartsTask, assigneeUser; + private SiteModel siteModel; + private FileModel fileModel, document2; + private TaskModel taskModel; + + private RestItemModel taskItem; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + userWhoStartsTask = dataUser.createRandomTestUser(); + assigneeUser = dataUser.createRandomTestUser(); + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + + tasksApi.useRestClient(restClient); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Delete existing task item") + public void deleteTaskItem() throws Exception + { + restClient.authenticateUser(adminUser); + document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + taskItem = tasksApi.addTaskItem(taskModel, document2); + tasksApi.deleteTaskItem(taskModel, taskItem); + tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); + } +} From 2174e78757ef9322a66df42e5075e694cd5d9fb1 Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Fri, 21 Oct 2016 15:57:52 +0300 Subject: [PATCH 0484/1491] TAS-1610, for invalid taskId return 404 --- .../workflow/tasks/RemoveTaskItemSanityTests.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/RemoveTaskItemSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/RemoveTaskItemSanityTests.java index ea77a36ac..ad142e03d 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/RemoveTaskItemSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/RemoveTaskItemSanityTests.java @@ -57,4 +57,16 @@ public class RemoveTaskItemSanityTests extends RestWorkflowTest tasksApi.deleteTaskItem(taskModel, taskItem); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Try to D=delete existing task item using invalid taskId") + public void deleteTaskItemUsingInvalidTaskId() throws Exception + { + restClient.authenticateUser(adminUser); + document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + taskItem = tasksApi.addTaskItem(taskModel, document2); + taskModel.setId("invalidTaskId"); + tasksApi.deleteTaskItem(taskModel, taskItem); + tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); + } } From aa419786d58cf9a0571949dfb4a3c151590b1942 Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Fri, 21 Oct 2016 15:58:40 +0300 Subject: [PATCH 0485/1491] TAS-1611, for invalid itemId return 404 --- .../workflow/tasks/RemoveTaskItemSanityTests.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/RemoveTaskItemSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/RemoveTaskItemSanityTests.java index ad142e03d..aaae2fdd0 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/RemoveTaskItemSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/RemoveTaskItemSanityTests.java @@ -69,4 +69,16 @@ public class RemoveTaskItemSanityTests extends RestWorkflowTest tasksApi.deleteTaskItem(taskModel, taskItem); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Try to Delete existing task item using invalid itemId") + public void deleteTaskItemUsingInvalidItemId() throws Exception + { + restClient.authenticateUser(adminUser); + document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + taskItem = tasksApi.addTaskItem(taskModel, document2); + taskItem.setId("incorrectItemId"); + tasksApi.deleteTaskItem(taskModel, taskItem); + tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); + } } From 6f6cfd2bfec0911463a1f807feeee49510c8581f Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Fri, 21 Oct 2016 17:46:24 +0300 Subject: [PATCH 0486/1491] TAS-1440, TAS-1614, TAS-1615, TAS-1616, TAS-1617 updateTask with different roles --- .../workflow/tasks/UploadTaskSanityTests.java | 92 +++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/tasks/UploadTaskSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UploadTaskSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UploadTaskSanityTests.java new file mode 100644 index 000000000..320fdfc65 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/UploadTaskSanityTests.java @@ -0,0 +1,92 @@ +package org.alfresco.rest.workflow.tasks; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestWorkflowTest; +import org.alfresco.rest.requests.RestTasksApi; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.GroupModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TaskModel; +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.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) +public class UploadTaskSanityTests extends RestWorkflowTest +{ + @Autowired + RestTasksApi tasksApi; + + UserModel userModel; + SiteModel siteModel; + UserModel candidateUser; + FileModel fileModel; + UserModel assigneeUser; + TaskModel taskModel; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + assigneeUser = dataUser.createRandomTestUser(); + taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + + tasksApi.useRestClient(restClient); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify admin user updates task with Rest API and response is successfull (200)") + public void adminUserUpdatesAnyTaskWithSuccess() throws Exception + { + UserModel adminUser = dataUser.getAdminUser(); + restClient.authenticateUser(adminUser); + tasksApi.updateTask(taskModel); + tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify assignee user updates its assigned task with Rest API and response is successfull (200)") + public void assigneeUserUpdatesItsTaskWithSuccess() throws Exception + { + restClient.authenticateUser(assigneeUser); + tasksApi.updateTask(taskModel); + tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify user that started the task updates the started task with Rest API and response is successfull (200)") + public void starterUserUpdatesItsTaskWithSuccess() throws Exception + { + restClient.authenticateUser(userModel); + tasksApi.updateTask(taskModel); + tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify any user with no relation to task is forbidden to update other task with Rest API (403)") + public void anyUserIsForbiddenToUpdateOtherTask() throws Exception + { + UserModel anyUser= dataUser.createRandomTestUser(); + + restClient.authenticateUser(anyUser); + tasksApi.updateTask(taskModel); + tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify candidate user updates its specific task and no other user claimed the task with Rest API and response is successfull (200)") + public void candidateUserUpdatesItsTasks() throws Exception + { + UserModel userModel1 = dataUser.createRandomTestUser(); + UserModel userModel2 = dataUser.createRandomTestUser(); + GroupModel group = dataGroup.createRandomGroup(); + dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); + TaskModel taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); + + restClient.authenticateUser(userModel1); + tasksApi.updateTask(taskModel); + tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } +} From ecfac46624ba158ee28fc532b02a76f08db05e88 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Fri, 21 Oct 2016 19:28:31 +0300 Subject: [PATCH 0487/1491] Add TestGroup.Workflow to test classes, mark test with TestGroup.Networks and few fixes --- .../rest/workflow/deployments/GetDeploymentsSanityTests.java | 2 +- .../GetProcessDefinitionImageSanityTests.java | 2 +- .../processDefinitions/GetProcessDefinitionSanityTests.java | 2 +- .../GetProcessDefinitionStartFormModelSanityTests.java | 2 +- .../processDefinitions/GetProcessDefinitionsSanityTests.java | 2 +- .../rest/workflow/processes/AddProcessItemSanityTests.java | 2 +- .../rest/workflow/processes/AddProcessSanityTests.java | 2 +- .../workflow/processes/AddProcessVariableSanityTests.java | 2 +- .../rest/workflow/processes/DeleteProcessSanityTests.java | 2 +- .../rest/workflow/processes/GetProcessItemsSanityTests.java | 2 +- .../rest/workflow/processes/GetProcessSanityTests.java | 2 +- .../rest/workflow/processes/GetProcessesSanityTests.java | 2 +- .../workflow/processes/GetProcessesVariablesSanityTests.java | 2 +- .../rest/workflow/processes/RemoveProcessItemSanityTests.java | 2 +- .../workflow/processes/RemoveProcessVariableSanityTests.java | 4 ++-- .../workflow/processes/UpdateProcessVariableSanityTests.java | 4 ++-- .../alfresco/rest/workflow/tasks/GetTaskItemsSanityTests.java | 1 + 17 files changed, 19 insertions(+), 18 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsSanityTests.java index 87212b542..82967ba4b 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsSanityTests.java @@ -17,7 +17,7 @@ import org.testng.annotations.Test; /** * Created by Claudia Agache on 10/4/2016. */ -@Test(groups = { TestGroup.REST_API, TestGroup.DEPLOYMENTS, TestGroup.SANITY}) +@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.SANITY}) public class GetDeploymentsSanityTests extends RestWorkflowTest { @Autowired diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java index 8c6c80965..839223484 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java @@ -16,7 +16,7 @@ import org.testng.annotations.Test; /** * Created by Claudia Agache on 10/13/2016. */ -@Test(groups = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY }) +@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY }) public class GetProcessDefinitionImageSanityTests extends RestWorkflowTest { @Autowired private DataUser dataUser; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java index dd63d8bce..554d3a95a 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java @@ -16,7 +16,7 @@ import org.testng.annotations.Test; /** * Created by Claudia Agache on 10/13/2016. */ -@Test(groups = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY }) +@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY }) public class GetProcessDefinitionSanityTests extends RestWorkflowTest { @Autowired diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java index a02d8b5cb..cba8350c1 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java @@ -17,7 +17,7 @@ import org.testng.annotations.Test; /** * Created by Claudia Agache on 10/18/2016. */ -@Test(groups = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY }) +@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY }) public class GetProcessDefinitionStartFormModelSanityTests extends RestWorkflowTest { @Autowired diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java index 6b8b73997..f907b342d 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java @@ -16,7 +16,7 @@ import org.testng.annotations.Test; /** * Created by Claudia Agache on 10/13/2016. */ -@Test(groups = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY }) +@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY }) public class GetProcessDefinitionsSanityTests extends RestWorkflowTest { @Autowired diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemSanityTests.java index 21a6351c6..ff03ebea9 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemSanityTests.java @@ -22,7 +22,7 @@ import org.testng.annotations.Test; /** * @author iulia.cojocea */ -@Test(groups = { TestGroup.REST_API, TestGroup.PROCESSES, TestGroup.SANITY}) +@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY}) public class AddProcessItemSanityTests extends RestWorkflowTest { @Autowired diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessSanityTests.java index 6fc501519..44b998e77 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessSanityTests.java @@ -19,7 +19,7 @@ import org.testng.annotations.Test; /** * Created by Claudia Agache on 10/18/2016. */ -@Test(groups = { TestGroup.REST_API, TestGroup.PROCESSES, TestGroup.SANITY }) +@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public class AddProcessSanityTests extends RestWorkflowTest { @Autowired diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java index af9ea4e1c..592bc3585 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java @@ -23,7 +23,7 @@ import org.testng.annotations.Test; /** * @author iulia.cojocea */ -@Test(groups = { TestGroup.REST_API, TestGroup.PROCESSES, TestGroup.SANITY }) +@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public class AddProcessVariableSanityTests extends RestWorkflowTest { @Autowired diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java index a04b1d37d..74082d1fe 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java @@ -19,7 +19,7 @@ import org.testng.annotations.Test; /** * Created by Claudia Agache on 10/12/2016. */ -@Test(groups = { TestGroup.REST_API, TestGroup.PROCESSES, TestGroup.SANITY }) +@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public class DeleteProcessSanityTests extends RestWorkflowTest { @Autowired diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsSanityTests.java index 4c3b4c982..1249d90b4 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsSanityTests.java @@ -22,7 +22,7 @@ import org.testng.annotations.Test; * @author iulia.cojocea */ -@Test(groups = { TestGroup.REST_API, TestGroup.PROCESSES, TestGroup.SANITY }) +@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public class GetProcessItemsSanityTests extends RestWorkflowTest { @Autowired diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessSanityTests.java index 440ac609f..ea212c5ad 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessSanityTests.java @@ -17,7 +17,7 @@ import org.testng.annotations.Test; /** * Created by Claudia Agache on 10/19/2016. */ -@Test(groups = { TestGroup.REST_API, TestGroup.PROCESSES, TestGroup.SANITY }) +@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public class GetProcessSanityTests extends RestWorkflowTest { @Autowired diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java index a34ed242a..68f81c2d1 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java @@ -20,7 +20,7 @@ import org.testng.annotations.Test; /** * Created by Claudia Agache on 10/11/2016. */ -@Test(groups = { TestGroup.REST_API, TestGroup.PROCESSES, TestGroup.SANITY }) +@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public class GetProcessesSanityTests extends RestWorkflowTest { @Autowired diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesVariablesSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesVariablesSanityTests.java index 454c554fc..7dc33b9bc 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesVariablesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesVariablesSanityTests.java @@ -20,7 +20,7 @@ import org.testng.annotations.Test; /** * @author iulia.cojocea */ -@Test(groups = { TestGroup.REST_API, TestGroup.PROCESSES, TestGroup.SANITY }) +@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public class GetProcessesVariablesSanityTests extends RestWorkflowTest { @Autowired diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessItemSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessItemSanityTests.java index 6db23ca79..4976afd90 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessItemSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessItemSanityTests.java @@ -21,7 +21,7 @@ import org.testng.annotations.Test; /** * @author iulia.cojocea */ -@Test(groups = { TestGroup.REST_API, TestGroup.PROCESSES, TestGroup.SANITY }) +@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public class RemoveProcessItemSanityTests extends RestWorkflowTest { @Autowired diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessVariableSanityTests.java index 5cefa74c9..0a2002256 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessVariableSanityTests.java @@ -21,7 +21,7 @@ import org.testng.annotations.Test; /** * @author iulia.cojocea */ -@Test(groups = { TestGroup.REST_API, TestGroup.PROCESSES, TestGroup.SANITY }) +@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public class RemoveProcessVariableSanityTests extends RestWorkflowTest { @Autowired @@ -58,7 +58,7 @@ public class RemoveProcessVariableSanityTests extends RestWorkflowTest processesApi.addProcessVariable(processModel, variableModel); processesApi.deleteProcessVariable(processModel, variableModel); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); - processesApi.getProcessesVariables(processModel).assertEntriesListContains("name", variableModel.getName()); + processesApi.getProcessesVariables(processModel).assertEntriesListDoesNotContain("name", variableModel.getName()); } @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/UpdateProcessVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/UpdateProcessVariableSanityTests.java index 3dc8cd5f4..813a1dddd 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/UpdateProcessVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/UpdateProcessVariableSanityTests.java @@ -21,7 +21,7 @@ import org.testng.annotations.Test; /** * @author iulia.cojocea */ -@Test(groups = { TestGroup.REST_API, TestGroup.PROCESSES, TestGroup.SANITY }) +@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public class UpdateProcessVariableSanityTests extends RestWorkflowTest { @Autowired @@ -56,7 +56,7 @@ public class UpdateProcessVariableSanityTests extends RestWorkflowTest RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); processModel = processesApi.getProcesses().getOneRandomEntry(); processesApi.updateProcessVariable(processModel, variableModel); - processesApi.getProcessesVariables(processModel).assertEntriesListDoesNotContain("name", variableModel.getName()); + processesApi.getProcessesVariables(processModel).assertEntriesListContains("name", variableModel.getName()); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskItemsSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskItemsSanityTests.java index 20d79417c..b7a422959 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskItemsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskItemsSanityTests.java @@ -73,6 +73,7 @@ public class GetTaskItemsSanityTests extends RestWorkflowTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify that user that started the process gets task items") + @Test(groups = { TestGroup.NETWORKS }) public void getTaskItemsByAdminInSameNetwork() throws Exception { UserModel adminuser = dataUser.getAdminUser(); From 07262e8a7085c0157d5ace8bc90b64ac010fd127 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Mon, 24 Oct 2016 10:29:55 +0300 Subject: [PATCH 0488/1491] Added a necessary method and the new logged bug --- .../workflow/deployments/DeleteDeploymentSanityTests.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java index 77253e697..a95fa170e 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java @@ -6,6 +6,7 @@ import org.alfresco.rest.model.RestDeploymentModel; import org.alfresco.rest.requests.RestDeploymentsApi; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.beans.factory.annotation.Autowired; @@ -37,6 +38,7 @@ public class DeleteDeploymentSanityTests extends RestWorkflowTest deploymentsApi.useRestClient(restClient); } + @Bug(id = "MNT-16996") @Test(groups ={"extension-points"}) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.SANITY, description = "Verify admin user deletes a specific deployment using REST API and status code is successful (204)") @@ -47,10 +49,12 @@ public class DeleteDeploymentSanityTests extends RestWorkflowTest deploymentsApi.getDeployments() .assertEntriesListContains("name", "customWorkflowExtentionForRest.bpmn"); + deployment = deploymentsApi.getDeployments().getDeploymentByName("customWorkflowExtentionForRest.bpmn"); deploymentsApi.deleteDeployment(deployment); deploymentsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); } + @Bug(id = "MNT-16996") @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.SANITY, description = "Verify admin user cannot delete an inexistent deployment using REST API and status code is successful (204)") public void adminCannotDeleteInexistentDeployment() throws JsonToModelConversionException, Exception From b9a0bb62c9b8270fe7b2afe159034d2fba779bca Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Mon, 24 Oct 2016 14:58:53 +0300 Subject: [PATCH 0489/1491] Add assertions to REST API tests --- .../processes/AddProcessItemSanityTests.java | 18 +++++++++ .../processes/AddProcessSanityTests.java | 7 ++++ .../AddProcessVariableSanityTests.java | 25 +++++++++++-- .../processes/DeleteProcessSanityTests.java | 3 +- .../processes/GetProcessItemsSanityTests.java | 6 +-- .../processes/GetProcessSanityTests.java | 9 +++-- .../GetProcessesVariablesSanityTests.java | 4 +- .../tasks/AddTaskItemSanityTests.java | 37 ++++++++++++------- .../tasks/AddTaskVariablesSanityTests.java | 29 ++++++++------- .../tasks/DeleteTaskVariableSanityTests.java | 3 +- .../workflow/tasks/GetTaskSanityTests.java | 22 ++++++++--- .../tasks/GetTaskVariablesSanityTests.java | 8 ++-- .../tasks/RemoveTaskItemSanityTests.java | 3 +- .../tasks/UpdateTaskVariableSanityTests.java | 26 ++++++++++--- .../workflow/tasks/UploadTaskSanityTests.java | 14 +++++-- 15 files changed, 152 insertions(+), 62 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemSanityTests.java index ff03ebea9..f96f19728 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemSanityTests.java @@ -59,6 +59,15 @@ public class AddProcessItemSanityTests extends RestWorkflowTest document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); processModel = processesApi.getProcesses().getOneRandomEntry(); processItem = processesApi.addProcessItem(processModel, document2); + processItem.and().assertField("createdAt").is(processItem.getCreatedAt()) + .and().assertField("size").is(processItem.getSize()) + .and().assertField("createdBy").is(processItem.getCreatedBy()) + .and().assertField("modifiedAt").is(processItem.getModifiedAt()) + .and().assertField("name").is(processItem.getName()) + .and().assertField("modifiedBy").is(processItem.getModifiedBy()) + .and().assertField("id").is(processItem.getId()) + .and().assertField("mimeType").is(processItem.getMimeType()); + processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); processesApi.getProcessesItems(processModel).assertEntriesListContains("id", processItem.getId()); @@ -73,6 +82,15 @@ public class AddProcessItemSanityTests extends RestWorkflowTest document3 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); processModel = processesApi.getProcesses().getOneRandomEntry(); processItem = processesApi.addProcessItem(processModel, document3); + processItem.and().assertField("createdAt").is(processItem.getCreatedAt()) + .and().assertField("size").is(processItem.getSize()) + .and().assertField("createdBy").is(processItem.getCreatedBy()) + .and().assertField("modifiedAt").is(processItem.getModifiedAt()) + .and().assertField("name").is(processItem.getName()) + .and().assertField("modifiedBy").is(processItem.getModifiedBy()) + .and().assertField("id").is(processItem.getId()) + .and().assertField("mimeType").is(processItem.getMimeType()); + processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); processesApi.getProcessesItems(processModel).assertEntriesListContains("id", processItem.getId()); processItem = processesApi.addProcessItem(processModel, document3); diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessSanityTests.java index 44b998e77..b382c23a7 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessSanityTests.java @@ -53,6 +53,10 @@ public class AddProcessSanityTests extends RestWorkflowTest restClient.authenticateUser(userWhoStartsProcess); addedProcess = processesApi.addProcess("activitiAdhoc", assignee, false, Priority.Normal); + addedProcess.and().assertField("id").is(addedProcess.getId()) + .and().assertField("startUserId").is(addedProcess.getStartUserId()); + + processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); processesApi.getProcesses().assertEntriesListContains("id", addedProcess.getId()); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -69,6 +73,9 @@ public class AddProcessSanityTests extends RestWorkflowTest restClient.authenticateUser(tenantUserWhoStartsProcess); addedProcess = processesApi.addProcess("activitiAdhoc", tenantAssignee, false, Priority.Normal); + addedProcess.and().assertField("id").is(addedProcess.getId()) + .and().assertField("startUserId").is(addedProcess.getStartUserId()); + processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); processesApi.getProcesses().assertEntriesListContains("id", addedProcess.getId()); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java index 592bc3585..ce3cba96e 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java @@ -40,6 +40,7 @@ public class AddProcessVariableSanityTests extends RestWorkflowTest private UserModel userWhoStartsTask, assignee, adminTenantUser, tenantUser, tenantUserAssignee; private RestProcessModel processModel; private UserModel adminUser; + private RestProcessVariableModel processVariable; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception @@ -60,8 +61,14 @@ public class AddProcessVariableSanityTests extends RestWorkflowTest restClient.authenticateUser(userWhoStartsTask); RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); processModel = processesApi.getProcesses().getOneRandomEntry(); - processesApi.addProcessVariable(processModel, variableModel); + + processVariable = processesApi.addProcessVariable(processModel, variableModel); + processVariable.and().assertField("name").is(processVariable.getName()) + .and().assertField("type").is(processVariable.getType()) + .and().assertField("value").is(processVariable.getValue()); + processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + processesApi.getProcessesVariables(processModel).assertEntriesListContains("name", processVariable.getName()); } @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, @@ -71,9 +78,15 @@ public class AddProcessVariableSanityTests extends RestWorkflowTest restClient.authenticateUser(userWhoStartsTask); RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); processModel = processesApi.getProcesses().getOneRandomEntry(); - processesApi.addProcessVariable(processModel, variableModel); - variableModel.setValue(RandomData.getRandomName("newValue")); - processesApi.addProcessVariable(processModel, variableModel); + processVariable = processesApi.addProcessVariable(processModel, variableModel); + processVariable.and().assertField("name").is(processVariable.getName()) + .and().assertField("type").is(processVariable.getType()) + .and().assertField("value").is(processVariable.getValue()); + + String newValue = RandomData.getRandomName("value"); + variableModel.setValue(newValue); + processVariable = processesApi.addProcessVariable(processModel, variableModel) + .and().assertField("value").is(newValue); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } @@ -98,6 +111,10 @@ public class AddProcessVariableSanityTests extends RestWorkflowTest RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); processModel = processesApi.getProcesses().getOneRandomEntry(); processesApi.addProcessVariable(processModel, variableModel); + processVariable.and().assertField("name").is(processVariable.getName()) + .and().assertField("type").is(processVariable.getType()) + .and().assertField("value").is(processVariable.getValue()); + processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java index 74082d1fe..b4dc1e0f8 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java @@ -74,7 +74,6 @@ public class DeleteProcessSanityTests extends RestWorkflowTest task = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); restClient.authenticateUser(anotherUser); processesApi.deleteProcess(task); - processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("user is not allowed to access information about process"); } - } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsSanityTests.java index 1249d90b4..12c980794 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsSanityTests.java @@ -58,7 +58,7 @@ public class GetProcessItemsSanityTests extends RestWorkflowTest { restClient.authenticateUser(userWhoStartsTask); processModel = processesApi.getProcesses().getOneRandomEntry(); - processesApi.getProcessesItems(processModel); + processesApi.getProcessesItems(processModel).assertEntriesListIsNotEmpty(); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -68,7 +68,7 @@ public class GetProcessItemsSanityTests extends RestWorkflowTest { restClient.authenticateUser(assignee); processModel = processesApi.getProcesses().getOneRandomEntry(); - processesApi.getProcessesItems(processModel); + processesApi.getProcessesItems(processModel).assertEntriesListIsNotEmpty(); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -91,7 +91,7 @@ public class GetProcessItemsSanityTests extends RestWorkflowTest dataWorkflow.usingUser(tenantUser).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(tenantUserAssignee); processModel = processesApi.getProcesses().getOneRandomEntry(); - processesApi.getProcessesItems(processModel); + processesApi.getProcessesItems(processModel).assertEntriesListIsNotEmpty(); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessSanityTests.java index ea212c5ad..2c8646e39 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessSanityTests.java @@ -44,7 +44,8 @@ public class GetProcessSanityTests extends RestWorkflowTest public void getProcessByOwner() throws Exception { restClient.authenticateUser(userWhoStartsProcess); - processesApi.getProcess(addedProcess); + processesApi.getProcess(addedProcess).and().assertField("id").is(addedProcess.getId()) + .and().assertField("startUserId").is(addedProcess.getStartUserId()); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -53,7 +54,8 @@ public class GetProcessSanityTests extends RestWorkflowTest public void getProcessByAssignee() throws Exception { restClient.authenticateUser(assignee); - processesApi.getProcess(addedProcess); + processesApi.getProcess(addedProcess).and().assertField("id").is(addedProcess.getId()) + .and().assertField("startUserId").is(addedProcess.getStartUserId()); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -62,7 +64,8 @@ public class GetProcessSanityTests extends RestWorkflowTest public void getProcessByAdmin() throws Exception { restClient.authenticateUser(dataUser.getAdminUser()); - processesApi.getProcess(addedProcess); + processesApi.getProcess(addedProcess).and().assertField("id").is(addedProcess.getId()) + .and().assertField("startUserId").is(addedProcess.getStartUserId()); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesVariablesSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesVariablesSanityTests.java index 7dc33b9bc..1cac91426 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesVariablesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesVariablesSanityTests.java @@ -51,7 +51,7 @@ public class GetProcessesVariablesSanityTests extends RestWorkflowTest { restClient.authenticateUser(userWhoStartsTask); processModel = processesApi.getProcesses().getOneRandomEntry(); - processesApi.getProcessesVariables(processModel); + processesApi.getProcessesVariables(processModel).assertEntriesListIsNotEmpty(); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -61,7 +61,7 @@ public class GetProcessesVariablesSanityTests extends RestWorkflowTest { restClient.authenticateUser(assignee); processModel = processesApi.getProcesses().getOneRandomEntry(); - processesApi.getProcessesVariables(processModel); + processesApi.getProcessesVariables(processModel).assertEntriesListIsNotEmpty(); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemSanityTests.java index cff45252a..4f805cbb1 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemSanityTests.java @@ -58,14 +58,15 @@ public class AddTaskItemSanityTests extends RestWorkflowTest taskItem = tasksApi.addTaskItem(taskModel, document2); taskItem.and().assertField("createdAt").is(taskItem.getCreatedAt()) - .and().assertField("size").is(taskItem.getSize()) - .and().assertField("createdBy").is(taskItem.getCreatedBy()) - .and().assertField("modifiedAt").is(taskItem.getModifiedAt()) - .and().assertField("name").is(taskItem.getName()) - .and().assertField("modifiedBy").is(taskItem.getModifiedBy()) - .and().assertField("id").is(taskItem.getId()) - .and().assertField("mimeType").is(taskItem.getMimeType()); + .and().assertField("size").is(taskItem.getSize()) + .and().assertField("createdBy").is(taskItem.getCreatedBy()) + .and().assertField("modifiedAt").is(taskItem.getModifiedAt()) + .and().assertField("name").is(taskItem.getName()) + .and().assertField("modifiedBy").is(taskItem.getModifiedBy()) + .and().assertField("id").is(taskItem.getId()) + .and().assertField("mimeType").is(taskItem.getMimeType()); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + tasksApi.getTaskItems(taskModel).assertEntriesListContains("id", taskItem.getId()); } @Bug(id = "MNT-16966") @@ -78,13 +79,13 @@ public class AddTaskItemSanityTests extends RestWorkflowTest document3 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); taskItem = tasksApi.addTaskItem(taskModel, document3); taskItem.and().assertField("createdAt").is(taskItem.getCreatedAt()) - .and().assertField("size").is(taskItem.getSize()) - .and().assertField("createdBy").is(taskItem.getCreatedBy()) - .and().assertField("modifiedAt").is(taskItem.getModifiedAt()) - .and().assertField("name").is(taskItem.getName()) - .and().assertField("modifiedBy").is(taskItem.getModifiedBy()) - .and().assertField("id").is(taskItem.getId()) - .and().assertField("mimeType").is(taskItem.getMimeType()); + .and().assertField("size").is(taskItem.getSize()) + .and().assertField("createdBy").is(taskItem.getCreatedBy()) + .and().assertField("modifiedAt").is(taskItem.getModifiedAt()) + .and().assertField("name").is(taskItem.getName()) + .and().assertField("modifiedBy").is(taskItem.getModifiedBy()) + .and().assertField("id").is(taskItem.getId()) + .and().assertField("mimeType").is(taskItem.getMimeType()); taskItem = tasksApi.addTaskItem(taskModel, document3); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.BAD_REQUEST); } @@ -109,6 +110,14 @@ public class AddTaskItemSanityTests extends RestWorkflowTest document4 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); taskItem = tasksApi.addTaskItem(taskModel, document4); + taskItem.and().assertField("createdAt").is(taskItem.getCreatedAt()) + .and().assertField("size").is(taskItem.getSize()) + .and().assertField("createdBy").is(taskItem.getCreatedBy()) + .and().assertField("modifiedAt").is(taskItem.getModifiedAt()) + .and().assertField("name").is(taskItem.getName()) + .and().assertField("modifiedBy").is(taskItem.getModifiedBy()) + .and().assertField("id").is(taskItem.getId()) + .and().assertField("mimeType").is(taskItem.getMimeType()); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesSanityTests.java index 18784ede0..dfc100281 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesSanityTests.java @@ -52,11 +52,12 @@ public class AddTaskVariablesSanityTests extends RestWorkflowTest restClient.authenticateUser(adminUser); RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); tasksApi.addTaskVariable(taskModel, variableModel) - .and().assertField("scope").is(variableModel.getScope()) - .and().assertField("name").is(variableModel.getName()) - .and().assertField("value").is(variableModel.getValue()) - .and().assertField("type").is(variableModel.getType()); + .and().assertField("scope").is(variableModel.getScope()) + .and().assertField("name").is(variableModel.getName()) + .and().assertField("value").is(variableModel.getValue()) + .and().assertField("type").is(variableModel.getType()); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + tasksApi.getTaskVariables(taskModel).assertEntriesListContains("name", variableModel.getName()); } @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, @@ -66,11 +67,12 @@ public class AddTaskVariablesSanityTests extends RestWorkflowTest restClient.authenticateUser(assigneeUser); RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); tasksApi.addTaskVariable(taskModel, variableModel) - .and().assertField("scope").is(variableModel.getScope()) - .and().assertField("name").is(variableModel.getName()) - .and().assertField("value").is(variableModel.getValue()) - .and().assertField("type").is(variableModel.getType()); + .and().assertField("scope").is(variableModel.getScope()) + .and().assertField("name").is(variableModel.getName()) + .and().assertField("value").is(variableModel.getValue()) + .and().assertField("type").is(variableModel.getType()); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + tasksApi.getTaskVariables(taskModel).assertEntriesListContains("name", variableModel.getName()); } @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, @@ -80,11 +82,12 @@ public class AddTaskVariablesSanityTests extends RestWorkflowTest restClient.authenticateUser(userWhoStartsTask); RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); tasksApi.addTaskVariable(taskModel, variableModel) - .and().assertField("scope").is(variableModel.getScope()) - .and().assertField("name").is(variableModel.getName()) - .and().assertField("value").is(variableModel.getValue()) - .and().assertField("type").is(variableModel.getType()); + .and().assertField("scope").is(variableModel.getScope()) + .and().assertField("name").is(variableModel.getName()) + .and().assertField("value").is(variableModel.getValue()) + .and().assertField("type").is(variableModel.getType()); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + tasksApi.getTaskVariables(taskModel).assertEntriesListContains("name", variableModel.getName()); } @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, @@ -95,6 +98,6 @@ public class AddTaskVariablesSanityTests extends RestWorkflowTest restClient.authenticateUser(userModel); RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); tasksApi.addTaskVariable(taskModel, variableModel); - tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/DeleteTaskVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/DeleteTaskVariableSanityTests.java index a83f35eff..ca80153b3 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/DeleteTaskVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/DeleteTaskVariableSanityTests.java @@ -50,9 +50,10 @@ public class DeleteTaskVariableSanityTests extends RestWorkflowTest { restClient.authenticateUser(adminUser); RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - tasksApi.updateTaskVariable(taskModel, variableModel); + tasksApi.addTaskVariable(taskModel, variableModel); tasksApi.deleteTaskVariable(taskModel, variableModel); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); + tasksApi.getTaskVariables(taskModel).assertEntriesListDoesNotContain("name", variableModel.getName()); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskSanityTests.java index 3c3c0cc34..90532a6ad 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskSanityTests.java @@ -47,7 +47,9 @@ public class GetTaskSanityTests extends RestWorkflowTest { UserModel adminUser = dataUser.getAdminUser(); restClient.authenticateUser(adminUser); - tasksApi.getTask(taskModel); + tasksApi.getTask(taskModel) + .and().assertField("id").is(taskModel.getId()) + .and().assertField("message").is(taskModel.getMessage()); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -55,7 +57,9 @@ public class GetTaskSanityTests extends RestWorkflowTest public void assigneeUserGetsItsTaskWithSuccess() throws Exception { restClient.authenticateUser(assigneeUser); - tasksApi.getTask(taskModel); + tasksApi.getTask(taskModel) + .and().assertField("id").is(taskModel.getId()) + .and().assertField("message").is(taskModel.getMessage()); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -63,7 +67,9 @@ public class GetTaskSanityTests extends RestWorkflowTest public void starterUserGetsItsTaskWithSuccess() throws Exception { restClient.authenticateUser(userModel); - tasksApi.getTask(taskModel); + tasksApi.getTask(taskModel) + .and().assertField("id").is(taskModel.getId()) + .and().assertField("message").is(taskModel.getMessage()); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -74,7 +80,7 @@ public class GetTaskSanityTests extends RestWorkflowTest restClient.authenticateUser(anyUser); tasksApi.getTask(taskModel); - tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify candidate user gets its specific task and no other user claimed the task with Rest API and response is successfull (200)") @@ -87,7 +93,9 @@ public class GetTaskSanityTests extends RestWorkflowTest TaskModel taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); restClient.authenticateUser(userModel1); - tasksApi.getTask(taskModel); + tasksApi.getTask(taskModel) + .and().assertField("id").is(taskModel.getId()) + .and().assertField("message").is(taskModel.getMessage()); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -103,7 +111,9 @@ public class GetTaskSanityTests extends RestWorkflowTest dataWorkflow.usingUser(userModel1).claimTask(taskModel); restClient.authenticateUser(userModel2); - tasksApi.getTask(taskModel); + tasksApi.getTask(taskModel) + .and().assertField("id").is(taskModel.getId()) + .and().assertField("message").is(taskModel.getMessage()); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskVariablesSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskVariablesSanityTests.java index cbc1f63d0..923201bea 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskVariablesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskVariablesSanityTests.java @@ -47,7 +47,7 @@ public class GetTaskVariablesSanityTests extends RestWorkflowTest public void getTaskVariablesByUserWhoStartedProcess() throws Exception { restClient.authenticateUser(userWhoStartsTask); - tasksApi.getTaskVariables(taskModel); + tasksApi.getTaskVariables(taskModel).assertEntriesListIsNotEmpty(); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -56,7 +56,7 @@ public class GetTaskVariablesSanityTests extends RestWorkflowTest public void getTaskVariablesByUserInvolvedInProcess() throws Exception { restClient.authenticateUser(assignee); - tasksApi.getTaskVariables(taskModel); + tasksApi.getTaskVariables(taskModel).assertEntriesListIsNotEmpty(); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -68,7 +68,7 @@ public class GetTaskVariablesSanityTests extends RestWorkflowTest restClient.authenticateUser(randomUser); tasksApi.getTaskVariables(taskModel); - tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, @@ -78,7 +78,7 @@ public class GetTaskVariablesSanityTests extends RestWorkflowTest UserModel adminUser = dataUser.getAdminUser(); restClient.authenticateUser(adminUser); - tasksApi.getTaskVariables(taskModel); + tasksApi.getTaskVariables(taskModel).assertEntriesListIsNotEmpty(); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/RemoveTaskItemSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/RemoveTaskItemSanityTests.java index aaae2fdd0..2c2085edc 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/RemoveTaskItemSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/RemoveTaskItemSanityTests.java @@ -56,10 +56,11 @@ public class RemoveTaskItemSanityTests extends RestWorkflowTest taskItem = tasksApi.addTaskItem(taskModel, document2); tasksApi.deleteTaskItem(taskModel, taskItem); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); + tasksApi.getTaskItems(taskModel).assertEntriesListDoesNotContain("id", taskItem.getId()); } @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, - description = "Try to D=delete existing task item using invalid taskId") + description = "Try to Delete existing task item using invalid taskId") public void deleteTaskItemUsingInvalidTaskId() throws Exception { restClient.authenticateUser(adminUser); diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskVariableSanityTests.java index 5bf85602f..8e6a6e80d 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskVariableSanityTests.java @@ -38,6 +38,8 @@ public class UpdateTaskVariableSanityTests extends RestWorkflowTest private UserModel adminTenantUser, tenantUser, tenantUserAssignee; + private RestVariableModel taskVariable; + @BeforeClass(alwaysRun=true) public void dataPreparation() throws Exception { @@ -57,7 +59,11 @@ public class UpdateTaskVariableSanityTests extends RestWorkflowTest UserModel adminUser = dataUser.getAdminUser(); restClient.authenticateUser(adminUser); RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - tasksApi.updateTaskVariable(taskModel, variableModel); + taskVariable = tasksApi.updateTaskVariable(taskModel, variableModel); + taskVariable.and().assertField("scope").is(taskVariable.getScope()) + .and().assertField("name").is(taskVariable.getName()) + .and().assertField("type").is(taskVariable.getType()) + .and().assertField("value").is(taskVariable.getValue()); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -68,9 +74,13 @@ public class UpdateTaskVariableSanityTests extends RestWorkflowTest UserModel adminUser = dataUser.getAdminUser(); restClient.authenticateUser(adminUser); RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - tasksApi.updateTaskVariable(taskModel, variableModel); + taskVariable = tasksApi.updateTaskVariable(taskModel, variableModel); + taskVariable.and().assertField("scope").is(taskVariable.getScope()) + .and().assertField("name").is(taskVariable.getName()) + .and().assertField("type").is(taskVariable.getType()) + .and().assertField("value").is(taskVariable.getValue()); variableModel.setValue("updatedValue"); - tasksApi.updateTaskVariable(taskModel, variableModel).assertTaskVariableHasValue("updatedValue"); + taskVariable = tasksApi.updateTaskVariable(taskModel, variableModel).and().assertField("value").is("updatedValue"); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -93,9 +103,15 @@ public class UpdateTaskVariableSanityTests extends RestWorkflowTest tenantTask = dataWorkflow.usingUser(tenantUser).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(tenantUserAssignee); RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - tasksApi.updateTaskVariable(tenantTask, variableModel); + taskVariable = tasksApi.updateTaskVariable(tenantTask, variableModel); + + taskVariable.and().assertField("scope").is(taskVariable.getScope()) + .and().assertField("name").is(taskVariable.getName()) + .and().assertField("type").is(taskVariable.getType()) + .and().assertField("value").is(taskVariable.getValue()); + variableModel.setValue("updatedValue"); - tasksApi.updateTaskVariable(taskModel, variableModel).assertTaskVariableHasValue("updatedValue"); + taskVariable = tasksApi.updateTaskVariable(taskModel, variableModel).and().assertField("value").is("updatedValue"); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UploadTaskSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UploadTaskSanityTests.java index 320fdfc65..dede4f072 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/UploadTaskSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/UploadTaskSanityTests.java @@ -46,7 +46,9 @@ public class UploadTaskSanityTests extends RestWorkflowTest { UserModel adminUser = dataUser.getAdminUser(); restClient.authenticateUser(adminUser); - tasksApi.updateTask(taskModel); + tasksApi.updateTask(taskModel) + .and().assertField("id").is(taskModel.getId()) + .and().assertField("message").is(taskModel.getMessage()); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -54,7 +56,9 @@ public class UploadTaskSanityTests extends RestWorkflowTest public void assigneeUserUpdatesItsTaskWithSuccess() throws Exception { restClient.authenticateUser(assigneeUser); - tasksApi.updateTask(taskModel); + tasksApi.updateTask(taskModel) + .and().assertField("id").is(taskModel.getId()) + .and().assertField("message").is(taskModel.getMessage()); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -73,7 +77,7 @@ public class UploadTaskSanityTests extends RestWorkflowTest restClient.authenticateUser(anyUser); tasksApi.updateTask(taskModel); - tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify candidate user updates its specific task and no other user claimed the task with Rest API and response is successfull (200)") @@ -86,7 +90,9 @@ public class UploadTaskSanityTests extends RestWorkflowTest TaskModel taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); restClient.authenticateUser(userModel1); - tasksApi.updateTask(taskModel); + tasksApi.updateTask(taskModel) + .and().assertField("id").is(taskModel.getId()) + .and().assertField("message").is(taskModel.getMessage()); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } } From 8c61a6e55ba198ebe06ad081afadbc8c06f8eee2 Mon Sep 17 00:00:00 2001 From: cnechifor Date: Tue, 25 Oct 2016 00:09:16 +0300 Subject: [PATCH 0490/1491] perform changes for rest api assertion --- .../comments/UpdateCommentsSanityTests.java | 6 +-- .../org/alfresco/rest/demo/RMDemoTest.java | 23 ++++++----- .../org/alfresco/rest/demo/RestDemoTests.java | 18 ++++----- .../rest/demo/SampleCommentsTests.java | 2 +- .../alfresco/rest/demo/SamplePeopleTests.java | 2 +- .../alfresco/rest/demo/SampleSitesTests.java | 16 ++++---- .../people/GetFavoriteSiteSanityTests.java | 10 ++--- .../people/GetFavoriteSitesSanityTests.java | 2 +- .../GetPeopleActivitiesSanityTests.java | 10 ++--- .../GetPeoplePreferencesSanityTests.java | 10 ++--- .../rest/people/GetPeopleSanityTests.java | 2 +- .../GetSiteMembershipRequestsSanityTests.java | 6 +-- .../rest/ratings/GetRatingSanityTests.java | 40 +++++++++---------- .../alfresco/rest/tags/AddTagSanityTests.java | 24 ++++++++--- .../rest/tags/AddTagsSanityTests.java | 16 ++++---- .../rest/tags/GetNodeTagsSanityTests.java | 12 +++--- .../alfresco/rest/tags/GetTagSanityTests.java | 10 ++--- .../rest/tags/UpdateTagSanityTests.java | 2 +- .../DeleteDeploymentSanityTests.java | 2 +- .../GetDeploymentsSanityTests.java | 4 +- .../GetProcessDefinitionSanityTests.java | 6 +-- ...ssDefinitionStartFormModelSanityTests.java | 4 +- .../GetProcessDefinitionsSanityTests.java | 4 +- .../processes/AddProcessItemSanityTests.java | 4 +- .../processes/AddProcessSanityTests.java | 4 +- .../processes/DeleteProcessSanityTests.java | 4 +- .../processes/GetProcessTasksSanityTests.java | 20 +++++----- .../processes/GetProcessesSanityTests.java | 8 ++-- .../RemoveProcessItemSanityTests.java | 2 +- .../RemoveProcessVariableSanityTests.java | 2 +- .../UpdateProcessVariableSanityTests.java | 4 +- .../tasks/AddTaskItemSanityTests.java | 32 +++++++-------- .../tasks/AddTaskVariablesSanityTests.java | 24 +++++------ .../tasks/GetTaskFormModelSanityTests.java | 6 +-- .../tasks/GetTaskItemsSanityTests.java | 12 +++--- .../workflow/tasks/GetTasksSanityTests.java | 10 ++--- 36 files changed, 188 insertions(+), 175 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java index 3e9c3be25..d485783f5 100644 --- a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java @@ -64,8 +64,8 @@ public class UpdateCommentsSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); commentsAPI.updateComment(document, commentModel, "This is the updated comment with Manager user") - .and().assertField("content").is("This is the updated comment with Manager user") - .and().assertField("canDelete").is(true); + .assertThat().field("content").is("This is the updated comment with Manager user") + .and().field("canDelete").is(true); commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -94,7 +94,7 @@ public class UpdateCommentsSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); commentsAPI.updateComment(document, commentModel, "This is the updated comment with Collaborator user") - .and().assertField("content").is("This is the updated comment with Collaborator user"); + .assertThat().field("content").is("This is the updated comment with Collaborator user"); commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } diff --git a/e2e-test/java/org/alfresco/rest/demo/RMDemoTest.java b/e2e-test/java/org/alfresco/rest/demo/RMDemoTest.java index 54d685ca6..e02551162 100644 --- a/e2e-test/java/org/alfresco/rest/demo/RMDemoTest.java +++ b/e2e-test/java/org/alfresco/rest/demo/RMDemoTest.java @@ -30,9 +30,9 @@ public class RMDemoTest extends RestTest { public void adminCanSeeDetailsOfARandomSiteCreated() throws JsonToModelConversionException, Exception { sitesApi.getSite(siteModel) - .and().assertField("id").isNotNull() - .and().assertField("description").is(siteModel.getDescription()) - .and().assertField("title").is(siteModel.getTitle()); + .assertThat().field("id").isNotNull() + .and().field("description").is(siteModel.getDescription()) + .and().field("title").is(siteModel.getTitle()); } @Test @@ -46,10 +46,10 @@ public class RMDemoTest extends RestTest { dataSite.usingAdmin().createSite(siteModel); sitesApi.getSite(siteModel) - .and().assertField("id").isNotNull() - .and().assertField("description").is("my description") - .and().assertField("title").is("MyTitle") - .and().assertField("visibility").is(Visibility.PUBLIC); + .assertThat().field("id").isNotNull() + .and().field("description").is("my description") + .and().field("title").is("MyTitle") + .and().field("visibility").is(Visibility.PUBLIC); } /** @@ -61,7 +61,7 @@ public class RMDemoTest extends RestTest { public void assertingWithFieldsThatDoesNotExist() throws JsonToModelConversionException, Exception { siteModel = dataSite.createPublicRandomSite(); - sitesApi.getSite(siteModel).and().assertField("fieldA").isNotNull(); + sitesApi.getSite(siteModel).assertThat().field("fieldA").isNotNull(); } @Test @@ -72,9 +72,10 @@ public class RMDemoTest extends RestTest { * you can use withParams(String... parameters) method before calling the http method. */ sitesApi.withParams("maxItems=2", "orderyBy=name").getSites() - .assertPaginationExist() - .assertPaginationField("maxItems").is("2") - .assertPaginationField("skipCount").is("0"); + .assertThat().paginationExist() + .and().paginationField("maxItems").is("2") + .and().paginationField("skipCount").is("0"); + } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/demo/RestDemoTests.java b/e2e-test/java/org/alfresco/rest/demo/RestDemoTests.java index 28f775320..2e0115f41 100644 --- a/e2e-test/java/org/alfresco/rest/demo/RestDemoTests.java +++ b/e2e-test/java/org/alfresco/rest/demo/RestDemoTests.java @@ -56,12 +56,12 @@ public class RestDemoTests extends RestTest { sitesApi.getAllSites() - .assertEntriesListContains("id", siteModel.getId()) + .entriesListContains("id", siteModel.getId()) .getSite(siteModel) - .and().assertField("id").isNotNull() - .and().assertField("description").is(siteModel.getDescription()) - .and().assertField("title").is(siteModel.getTitle()) - .and().assertField("visibility").is(Visibility.PUBLIC); + .assertThat().field("id").isNotNull() + .assertThat().field("description").is(siteModel.getDescription()) + .assertThat().field("title").is(siteModel.getTitle()) + .assertThat().field("visibility").is(Visibility.PUBLIC); } /** @@ -80,8 +80,8 @@ public class RestDemoTests extends RestTest // add new comment RestCommentModel commentEntry = commentsAPI.addComment(fileModel, "This is a new comment"); commentsAPI.getNodeComments(fileModel) - .assertEntriesListIsNotEmpty() - .assertEntriesListContains("content", "This is a new comment"); + .entriesListIsNotEmpty() + .entriesListContains("content", "This is a new comment"); //.assertEntriesListIsEmpty() //.assertCommentWithIdExists(commentEntry); @@ -111,7 +111,7 @@ public class RestDemoTests extends RestTest // add user as Consumer to site sitesApi.addPerson(siteModel, testUser); - sitesApi.getSiteMembers(siteModel).assertEntriesListContains("id", testUser.getUsername()) + sitesApi.getSiteMembers(siteModel).entriesListContains("id", testUser.getUsername()) .getSiteMember(testUser.getUsername()) .assertSiteMemberHasRole(Role.SiteConsumer); @@ -119,7 +119,7 @@ public class RestDemoTests extends RestTest testUser.setUserRole(UserRole.SiteCollaborator); sitesApi.updateSiteMember(siteModel, testUser); sitesApi.getSiteMembers(siteModel) - .assertEntriesListContains("id", testUser.getUsername()) + .entriesListContains("id", testUser.getUsername()) .getSiteMember(testUser.getUsername()) .assertSiteMemberHasRole(Role.SiteCollaborator); diff --git a/e2e-test/java/org/alfresco/rest/demo/SampleCommentsTests.java b/e2e-test/java/org/alfresco/rest/demo/SampleCommentsTests.java index 94181f1ca..52e054d1f 100644 --- a/e2e-test/java/org/alfresco/rest/demo/SampleCommentsTests.java +++ b/e2e-test/java/org/alfresco/rest/demo/SampleCommentsTests.java @@ -64,7 +64,7 @@ public class SampleCommentsTests extends RestTest RestCommentModel commentModel = commentsAPI.addComment(document, "This is a new comment"); commentsAPI.updateComment(document, commentModel, "This is the updated comment with Collaborator user") - .and().assertField("content").is("This is the updated comment"); + .assertThat().field("content").is("This is the updated comment"); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/demo/SamplePeopleTests.java b/e2e-test/java/org/alfresco/rest/demo/SamplePeopleTests.java index cd4b42e38..8e77d5477 100644 --- a/e2e-test/java/org/alfresco/rest/demo/SamplePeopleTests.java +++ b/e2e-test/java/org/alfresco/rest/demo/SamplePeopleTests.java @@ -34,7 +34,7 @@ public class SamplePeopleTests extends RestTest description = "Verify admin user gets person with Rest API and response is not empty") public void adminShouldRetrievePerson() throws Exception { - peopleAPI.getPerson(userModel).and().assertField("id").isNotEmpty(); + peopleAPI.getPerson(userModel).assertThat().field("id").isNotEmpty(); peopleAPI.usingRestWrapper() .assertStatusCodeIs(HttpStatus.OK); diff --git a/e2e-test/java/org/alfresco/rest/demo/SampleSitesTests.java b/e2e-test/java/org/alfresco/rest/demo/SampleSitesTests.java index 72ece6f5f..30e4809a1 100644 --- a/e2e-test/java/org/alfresco/rest/demo/SampleSitesTests.java +++ b/e2e-test/java/org/alfresco/rest/demo/SampleSitesTests.java @@ -37,7 +37,7 @@ public class SampleSitesTests extends RestTest public void adminShouldGetSiteDetails() throws JsonToModelConversionException, Exception { siteAPI.getSite(siteModel) - .and().assertField("id").isNotNull(); + .assertThat().field("id").isNotNull(); } @TestRail(section={"demo", "sample-section"}, executionType= ExecutionType.SANITY, @@ -54,7 +54,7 @@ public class SampleSitesTests extends RestTest public void adminShouldAccessSites() throws JsonToModelConversionException, Exception { siteAPI.getSites() - .assertEntriesListIsNotEmpty(); + .entriesListIsNotEmpty(); } @TestRail(section={"demo", "sample-section"}, executionType= ExecutionType.SANITY, @@ -71,7 +71,7 @@ public class SampleSitesTests extends RestTest public void adminShouldAccessResponsePagination() throws JsonToModelConversionException, Exception { siteAPI.getSites() - .assertPaginationExist(); + .paginationExist(); } @TestRail(section={"demo", "sample-section"}, executionType= ExecutionType.SANITY, @@ -90,7 +90,7 @@ public class SampleSitesTests extends RestTest public void adminShouldGetSiteFromSitesList() throws JsonToModelConversionException, Exception { siteAPI.getAllSites() - .assertEntriesListContains("id", siteModel.getId()); + .entriesListContains("id", siteModel.getId()); } @TestRail(section={"demo", "sample-section"}, executionType= ExecutionType.SANITY, @@ -98,10 +98,10 @@ public class SampleSitesTests extends RestTest public void adminShouldAccessSiteDetails() throws JsonToModelConversionException, Exception { siteAPI.getSite(siteModel) - .and().assertField("id").isNotNull() - .and().assertField("description").is(siteModel.getDescription()) - .and().assertField("title").is(siteModel.getTitle()) - .and().assertField("visibility").is(siteModel.getVisibility()); + .assertThat().field("id").isNotNull() + .and().field("description").is(siteModel.getDescription()) + .and().field("title").is(siteModel.getTitle()) + .and().field("visibility").is(siteModel.getVisibility()); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java index c477aae31..7653859bc 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java @@ -50,7 +50,7 @@ public class GetFavoriteSiteSanityTests extends RestTest dataSite.usingUser(managerUser).usingSite(siteModel2).addSiteToFavorites(); restClient.authenticateUser(managerUser); - peopleApi.getFavoriteSite(managerUser, siteModel1).and().assertField("id").isNotNull(); + peopleApi.getFavoriteSite(managerUser, siteModel1).assertThat().field("id").isNotNull(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -63,7 +63,7 @@ public class GetFavoriteSiteSanityTests extends RestTest dataSite.usingUser(collaboratorUser).usingSite(siteModel2).addSiteToFavorites(); restClient.authenticateUser(collaboratorUser); - peopleApi.getFavoriteSite(collaboratorUser, siteModel1).and().assertField("id").isNotNull(); + peopleApi.getFavoriteSite(collaboratorUser, siteModel1).assertThat().field("id").isNotNull(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -76,7 +76,7 @@ public class GetFavoriteSiteSanityTests extends RestTest dataSite.usingUser(contributorUser).usingSite(siteModel2).addSiteToFavorites(); restClient.authenticateUser(contributorUser); - peopleApi.getFavoriteSite(contributorUser, siteModel1).and().assertField("id").isNotNull(); + peopleApi.getFavoriteSite(contributorUser, siteModel1).assertThat().field("id").isNotNull(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -89,7 +89,7 @@ public class GetFavoriteSiteSanityTests extends RestTest dataSite.usingUser(consumerUser).usingSite(siteModel2).addSiteToFavorites(); restClient.authenticateUser(consumerUser); - peopleApi.getFavoriteSite(consumerUser, siteModel1).and().assertField("id").isNotNull(); + peopleApi.getFavoriteSite(consumerUser, siteModel1).assertThat().field("id").isNotNull(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -102,7 +102,7 @@ public class GetFavoriteSiteSanityTests extends RestTest dataSite.usingUser(anyUser).usingSite(siteModel2).addSiteToFavorites(); restClient.authenticateUser(adminUset); - peopleApi.getFavoriteSite(anyUser, siteModel1).and().assertField("id").isNotNull(); + peopleApi.getFavoriteSite(anyUser, siteModel1).assertThat().field("id").isNotNull(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } diff --git a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java index 0d5ee4d42..b5a05d3ef 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java @@ -96,7 +96,7 @@ public class GetFavoriteSitesSanityTests extends RestTest dataSite.usingUser(anotherUser).usingSite(siteModel).addSiteToFavorites(); restClient.authenticateUser(adminUser); - peopleApi.getFavoriteSites(anotherUser).assertEntriesListIsNotEmpty(); + peopleApi.getFavoriteSites(anotherUser).entriesListIsNotEmpty(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java index 860df1d26..ab6d4fa4d 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java @@ -49,7 +49,7 @@ public class GetPeopleActivitiesSanityTests extends RestTest dataContent.usingUser(managerUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); restClient.authenticateUser(managerUser); - peopleApi.getPersonActivities(managerUser).assertEntriesListIsNotEmpty(); + peopleApi.getPersonActivities(managerUser).entriesListIsNotEmpty(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -61,7 +61,7 @@ public class GetPeopleActivitiesSanityTests extends RestTest dataContent.usingUser(collaboratorUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); restClient.authenticateUser(collaboratorUser); - peopleApi.getPersonActivities(collaboratorUser).assertEntriesListIsNotEmpty(); + peopleApi.getPersonActivities(collaboratorUser).entriesListIsNotEmpty(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -73,7 +73,7 @@ public class GetPeopleActivitiesSanityTests extends RestTest dataContent.usingUser(contributorUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); restClient.authenticateUser(contributorUser); - peopleApi.getPersonActivities(contributorUser).assertEntriesListIsNotEmpty(); + peopleApi.getPersonActivities(contributorUser).entriesListIsNotEmpty(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -84,7 +84,7 @@ public class GetPeopleActivitiesSanityTests extends RestTest dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel, UserRole.SiteConsumer); restClient.authenticateUser(consumerUser); - peopleApi.getPersonActivities(consumerUser).assertEntriesListIsNotEmpty(); + peopleApi.getPersonActivities(consumerUser).entriesListIsNotEmpty(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -92,7 +92,7 @@ public class GetPeopleActivitiesSanityTests extends RestTest public void adminUserShouldGetPeopleActivitiesList() throws Exception { restClient.authenticateUser(dataUser.getAdminUser()); - peopleApi.getPersonActivities(userModel).assertEntriesListIsNotEmpty(); + peopleApi.getPersonActivities(userModel).entriesListIsNotEmpty(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesSanityTests.java index 256240033..8ef9570a9 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesSanityTests.java @@ -46,7 +46,7 @@ public class GetPeoplePreferencesSanityTests extends RestTest dataSite.usingUser(managerUser).usingSite(siteModel).addSiteToFavorites(); restClient.authenticateUser(managerUser); - peopleApi.getPersonPreferences(managerUser).assertEntriesListIsNotEmpty(); + peopleApi.getPersonPreferences(managerUser).entriesListIsNotEmpty(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -58,7 +58,7 @@ public class GetPeoplePreferencesSanityTests extends RestTest dataSite.usingUser(collaboratorUser).usingSite(siteModel).addSiteToFavorites(); restClient.authenticateUser(collaboratorUser); - peopleApi.getPersonPreferences(collaboratorUser).assertEntriesListIsNotEmpty(); + peopleApi.getPersonPreferences(collaboratorUser).entriesListIsNotEmpty(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -70,7 +70,7 @@ public class GetPeoplePreferencesSanityTests extends RestTest dataSite.usingUser(contributorUser).usingSite(siteModel).addSiteToFavorites(); restClient.authenticateUser(contributorUser); - peopleApi.getPersonPreferences(contributorUser).assertEntriesListIsNotEmpty(); + peopleApi.getPersonPreferences(contributorUser).entriesListIsNotEmpty(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -82,7 +82,7 @@ public class GetPeoplePreferencesSanityTests extends RestTest dataSite.usingUser(consumerUser).usingSite(siteModel).addSiteToFavorites(); restClient.authenticateUser(consumerUser); - peopleApi.getPersonPreferences(consumerUser).assertEntriesListIsNotEmpty(); + peopleApi.getPersonPreferences(consumerUser).entriesListIsNotEmpty(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -95,7 +95,7 @@ public class GetPeoplePreferencesSanityTests extends RestTest UserModel adminUser = dataUser.getAdminUser(); restClient.authenticateUser(adminUser); - peopleApi.getPersonPreferences(managerUser).assertEntriesListIsNotEmpty(); + peopleApi.getPersonPreferences(managerUser).entriesListIsNotEmpty(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleSanityTests.java index 799ceaf54..55bd6f49e 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleSanityTests.java @@ -41,7 +41,7 @@ public class GetPeopleSanityTests extends RestTest dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); restClient.authenticateUser(managerUser); - peopleApi.getPerson(searchedUser).and().assertField("id").is(searchedUser.getUsername());; + peopleApi.getPerson(searchedUser).assertThat().field("id").is(searchedUser.getUsername());; peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java index 5e0faf79c..86cdc7171 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java @@ -54,7 +54,7 @@ public class GetSiteMembershipRequestsSanityTests extends RestTest dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); restClient.authenticateUser(managerUser); - peopleApi.getSiteMembershipRequests(newMember).assertEntriesListIsNotEmpty(); + peopleApi.getSiteMembershipRequests(newMember).entriesListIsNotEmpty(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -101,7 +101,7 @@ public class GetSiteMembershipRequestsSanityTests extends RestTest UserModel adminUser = dataUser.getAdminUser(); restClient.authenticateUser(adminUser); - peopleApi.getSiteMembershipRequests(newMember).assertEntriesListIsNotEmpty(); + peopleApi.getSiteMembershipRequests(newMember).entriesListIsNotEmpty(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -122,7 +122,7 @@ public class GetSiteMembershipRequestsSanityTests extends RestTest public void oneUserGetsItsOwnSiteMembershipRequestsWithSuccess() throws Exception { restClient.authenticateUser(newMember); - peopleApi.getSiteMembershipRequests(newMember).assertEntriesListIsNotEmpty(); + peopleApi.getSiteMembershipRequests(newMember).entriesListIsNotEmpty(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } } diff --git a/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java index c2b254b16..7486a1e78 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java @@ -60,15 +60,15 @@ public class GetRatingSanityTests extends RestTest ratingsApi.rateStarsToDocument(document, 5); ratingsApi.getLikeRating(document) - .and().assertField("id").is("likes") - .and().assertField("myRating").is("true"); + .assertThat().field("id").is("likes") + .and().field("myRating").is("true"); ratingsApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.OK); ratingsApi.getFiveStarRating(document) - .and().assertField("id").is("fiveStar") - .and().assertField("myRating").is("5"); + .assertThat().field("id").is("fiveStar") + .and().field("myRating").is("5"); ratingsApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.OK); } @@ -83,14 +83,14 @@ public class GetRatingSanityTests extends RestTest ratingsApi.rateStarsToDocument(document, 5); ratingsApi.getLikeRating(document) - .and().assertField("id").is("likes") - .and().assertField("myRating").is("true"); + .assertThat().field("id").is("likes") + .and().field("myRating").is("true"); ratingsApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.OK); ratingsApi.getFiveStarRating(document) - .and().assertField("id").is("fiveStar") - .and().assertField("myRating").is("5"); + .assertThat().field("id").is("fiveStar") + .and().field("myRating").is("5"); ratingsApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.OK); } @@ -105,14 +105,14 @@ public class GetRatingSanityTests extends RestTest ratingsApi.rateStarsToDocument(document, 5); ratingsApi.getLikeRating(document) - .and().assertField("id").is("likes") - .and().assertField("myRating").is("true"); + .assertThat().field("id").is("likes") + .and().field("myRating").is("true"); ratingsApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.OK); ratingsApi.getFiveStarRating(document) - .and().assertField("id").is("fiveStar") - .and().assertField("myRating").is("5"); + .assertThat().field("id").is("fiveStar") + .and().field("myRating").is("5"); ratingsApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.OK); } @@ -127,14 +127,14 @@ public class GetRatingSanityTests extends RestTest ratingsApi.rateStarsToDocument(document, 5); ratingsApi.getLikeRating(document) - .and().assertField("id").is("likes") - .and().assertField("myRating").is("true"); + .assertThat().field("id").is("likes") + .and().field("myRating").is("true"); ratingsApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.OK); ratingsApi.getFiveStarRating(document) - .and().assertField("id").is("fiveStar") - .and().assertField("myRating").is("5"); + .assertThat().field("id").is("fiveStar") + .and().field("myRating").is("5"); ratingsApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.OK); } @@ -150,14 +150,14 @@ public class GetRatingSanityTests extends RestTest ratingsApi.rateStarsToDocument(document, 5); ratingsApi.getLikeRating(document) - .and().assertField("id").is("likes") - .and().assertField("myRating").is("true"); + .assertThat().field("id").is("likes") + .and().field("myRating").is("true"); ratingsApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.OK); ratingsApi.getFiveStarRating(document) - .and().assertField("id").is("fiveStar") - .and().assertField("myRating").is("5"); + .assertThat().field("id").is("fiveStar") + .and().field("myRating").is("5"); ratingsApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.OK); } diff --git a/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java index 6853963ec..5dbf45ed4 100644 --- a/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java @@ -61,7 +61,9 @@ public class AddTagSanityTests extends RestTest public void adminIsAbleToAddTag() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); - tagsAPI.addTag(document, tagValue).assertTagIs(tagValue); + tagsAPI.addTag(document, tagValue) + .assertThat().field("tag").is("tagValue") + .and().field("id").isNotEmpty(); tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } @@ -71,7 +73,9 @@ public class AddTagSanityTests extends RestTest public void managerIsAbleToAddTag() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - tagsAPI.addTag(document, tagValue).assertTagIs(tagValue); + tagsAPI.addTag(document, tagValue) + .assertThat().field("id").isNotEmpty() + .and().field("tag").is(tagValue); tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } @@ -80,7 +84,9 @@ public class AddTagSanityTests extends RestTest public void collaboratorIsAbleToAddTag() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - tagsAPI.addTag(document, tagValue).assertTagIs(tagValue); + tagsAPI.addTag(document, tagValue) + .assertThat().field("id").isNotEmpty() + .and().field("tag").is(tagValue); tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } @@ -89,7 +95,9 @@ public class AddTagSanityTests extends RestTest public void contributorIsNotAbleToAddTagToAnotherContent() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - tagsAPI.addTag(document, tagValue); + tagsAPI.addTag(document, tagValue) + .assertThat().field("id").isNotEmpty() + .and().field("tag").is(tagValue); tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } @@ -100,7 +108,9 @@ public class AddTagSanityTests extends RestTest userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); restClient.authenticateUser(userModel); contributorDoc = dataContent.usingSite(siteModel).usingUser(userModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - tagsAPI.addTag(contributorDoc, tagValue).assertTagIs(tagValue); + tagsAPI.addTag(contributorDoc, tagValue) + .assertThat().field("id").isNotEmpty() + .and().field("tag").is(tagValue); tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } @@ -109,7 +119,9 @@ public class AddTagSanityTests extends RestTest public void consumerIsNotAbleToAddTag() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - tagsAPI.addTag(document, tagValue); + tagsAPI.addTag(document, tagValue) + .assertThat().field("id").isNotEmpty() + .and().field("tag").is(tagValue); tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } diff --git a/e2e-test/java/org/alfresco/rest/tags/AddTagsSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/AddTagsSanityTests.java index 2e8ffc9fe..5f8b58ea0 100644 --- a/e2e-test/java/org/alfresco/rest/tags/AddTagsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/AddTagsSanityTests.java @@ -63,8 +63,8 @@ public class AddTagsSanityTests extends RestTest { restClient.authenticateUser(adminUserModel); tagsAPI.addTags(document, tag1, tag2) - .assertEntriesListContains("tag", tag1.toLowerCase()) - .assertEntriesListContains("tag", tag2.toLowerCase()); + .assertThat().entriesListContains("tag", tag1.toLowerCase()) + .and().entriesListContains("tag", tag2.toLowerCase()); tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } @@ -75,8 +75,8 @@ public class AddTagsSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); tagsAPI.addTags(document, tag1, tag2) - .assertEntriesListContains("tag", tag1.toLowerCase()) - .assertEntriesListContains("tag", tag2.toLowerCase()); + .assertThat().entriesListContains("tag", tag1.toLowerCase()) + .and().entriesListContains("tag", tag2.toLowerCase()); tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } @@ -87,8 +87,8 @@ public class AddTagsSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); tagsAPI.addTags(document, tag1, tag2) - .assertEntriesListContains("tag", tag1.toLowerCase()) - .assertEntriesListContains("tag", tag2.toLowerCase()); + .assertThat().entriesListContains("tag", tag1.toLowerCase()) + .and().entriesListContains("tag", tag2.toLowerCase()); tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } @@ -110,8 +110,8 @@ public class AddTagsSanityTests extends RestTest restClient.authenticateUser(userModel); contributorDoc = dataContent.usingSite(siteModel).usingUser(userModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); tagsAPI.addTags(contributorDoc, tag1, tag2) - .assertEntriesListContains("tag", tag1.toLowerCase()) - .assertEntriesListContains("tag", tag2.toLowerCase()); + .assertThat().entriesListContains("tag", tag1.toLowerCase()) + .and().entriesListContains("tag", tag2.toLowerCase()); tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } diff --git a/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java index 45eb26d4f..acea123fa 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java @@ -62,7 +62,7 @@ public class GetNodeTagsSanityTests extends RestTest tagsAPI.addTag(document, tagValue); tagsAPI.getNodeTags(document) - .assertEntriesListContains("tag", tagValue.toLowerCase()); + .entriesListContains("tag", tagValue.toLowerCase()); tagsAPI.usingRestWrapper() .assertStatusCodeIs(HttpStatus.OK); @@ -75,7 +75,7 @@ public class GetNodeTagsSanityTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - tagsAPI.getNodeTags(document).assertEntriesListContains("tag", tagValue.toLowerCase()); + tagsAPI.getNodeTags(document).entriesListContains("tag", tagValue.toLowerCase()); tagsAPI.usingRestWrapper() .assertStatusCodeIs(HttpStatus.OK); @@ -86,7 +86,7 @@ public class GetNodeTagsSanityTests extends RestTest public void siteContributorIsAbleToRetrieveNodeTags() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - tagsAPI.getNodeTags(document).assertEntriesListContains("tag", tagValue.toLowerCase()); + tagsAPI.getNodeTags(document).entriesListContains("tag", tagValue.toLowerCase()); tagsAPI.usingRestWrapper() .assertStatusCodeIs(HttpStatus.OK); @@ -97,7 +97,7 @@ public class GetNodeTagsSanityTests extends RestTest public void siteConsumerIsAbleToRetrieveNodeTags() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - tagsAPI.getNodeTags(document).assertEntriesListContains("tag", tagValue.toLowerCase()); + tagsAPI.getNodeTags(document).entriesListContains("tag", tagValue.toLowerCase()); tagsAPI.usingRestWrapper() .assertStatusCodeIs(HttpStatus.OK); @@ -108,7 +108,7 @@ public class GetNodeTagsSanityTests extends RestTest public void adminIsAbleToRetrieveNodeTags() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); - tagsAPI.getNodeTags(document).assertEntriesListContains("tag", tagValue.toLowerCase()); + tagsAPI.getNodeTags(document).entriesListContains("tag", tagValue.toLowerCase()); tagsAPI.usingRestWrapper() .assertStatusCodeIs(HttpStatus.OK); @@ -120,7 +120,7 @@ public class GetNodeTagsSanityTests extends RestTest public void unauthenticatedUserIsNotAbleToRetrieveNodeTags() throws JsonToModelConversionException, Exception { restClient.authenticateUser(new UserModel("random user", "random password")); - tagsAPI.getNodeTags(document).assertEntriesListContains("tag", tagValue.toLowerCase()); + tagsAPI.getNodeTags(document).entriesListContains("tag", tagValue.toLowerCase()); tagsAPI.usingRestWrapper() .assertStatusCodeIs(HttpStatus.UNAUTHORIZED); diff --git a/e2e-test/java/org/alfresco/rest/tags/GetTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagSanityTests.java index bc38b0fb5..4027adcbd 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetTagSanityTests.java @@ -56,7 +56,7 @@ public class GetTagSanityTests extends RestTest restClient.authenticateUser(adminUserModel); RestTagModel tag = tagsAPI.addTag(document, tagValue); - tagsAPI.getTag(tag).assertTagIs(tagValue.toLowerCase()); + tagsAPI.getTag(tag).assertThat().field("tag").is(tagValue.toLowerCase()); tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -68,7 +68,7 @@ public class GetTagSanityTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); RestTagModel tag = tagsAPI.addTag(document, tagValue); - tagsAPI.getTag(tag).assertTagIs(tagValue.toLowerCase()); + tagsAPI.getTag(tag).assertThat().field("tag").is(tagValue.toLowerCase()); tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -79,7 +79,7 @@ public class GetTagSanityTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); RestTagModel tag = tagsAPI.addTag(document, tagValue); - tagsAPI.getTag(tag).assertTagIs(tagValue.toLowerCase()); + tagsAPI.getTag(tag).assertThat().field("tag").is(tagValue.toLowerCase()); tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -91,7 +91,7 @@ public class GetTagSanityTests extends RestTest RestTagModel tag = tagsAPI.addTag(document, tagValue); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - tagsAPI.getTag(tag).assertTagIs(tagValue.toLowerCase()); + tagsAPI.getTag(tag).assertThat().field("tag").is(tagValue.toLowerCase()); tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -104,7 +104,7 @@ public class GetTagSanityTests extends RestTest RestTagModel tag = tagsAPI.addTag(document, tagValue); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - tagsAPI.getTag(tag).assertTagIs(tagValue.toLowerCase()); + tagsAPI.getTag(tag).assertThat().field("tag").is(tagValue.toLowerCase()); tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } diff --git a/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java index b4cd32b6e..7429fef9d 100644 --- a/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java @@ -61,7 +61,7 @@ public class UpdateTagSanityTests extends RestTest public void adminIsAbleToUpdateTags() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); - tagsAPI.updateTag(oldTag, randomTag).assertTagIs(randomTag); + tagsAPI.updateTag(oldTag, randomTag).assertThat().field("tag").is(randomTag); tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java index a95fa170e..56fb909f7 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java @@ -47,7 +47,7 @@ public class DeleteDeploymentSanityTests extends RestWorkflowTest restClient.authenticateUser(adminUser); // The deployment with name "customWorkflowExtentionForRest.bpmn" is created by Workflow Extention Point deploymentsApi.getDeployments() - .assertEntriesListContains("name", "customWorkflowExtentionForRest.bpmn"); + .entriesListContains("name", "customWorkflowExtentionForRest.bpmn"); deployment = deploymentsApi.getDeployments().getDeploymentByName("customWorkflowExtentionForRest.bpmn"); deploymentsApi.deleteDeployment(deployment); diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsSanityTests.java index 82967ba4b..aaa59841f 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsSanityTests.java @@ -43,7 +43,7 @@ public class GetDeploymentsSanityTests extends RestWorkflowTest public void getNonNetworkDeploymentsWithAdmin() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); - deploymentsApi.getDeployments().assertEntriesListIsNotEmpty(); + deploymentsApi.getDeployments().entriesListIsNotEmpty(); deploymentsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -55,7 +55,7 @@ public class GetDeploymentsSanityTests extends RestWorkflowTest tenantApi.useRestClient(restClient); tenantApi.createTenant(adminTenantUser); restClient.authenticateUser(adminTenantUser); - deploymentsApi.getDeployments().assertEntriesListIsNotEmpty(); + deploymentsApi.getDeployments().entriesListIsNotEmpty(); deploymentsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java index 554d3a95a..072d6cdc2 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java @@ -43,9 +43,9 @@ public class GetProcessDefinitionSanityTests extends RestWorkflowTest { processDefinitionsApi.getProcessDefinition(randomProcessDefinition). - and().assertField("name").is(randomProcessDefinition.onModel().getName()); + assertThat().field("name").is(randomProcessDefinition.onModel().getName()); - processDefinitionsApi.getProcessDefinition(randomProcessDefinition).and().assertField("name").is(randomProcessDefinition.onModel().getName()); + processDefinitionsApi.getProcessDefinition(randomProcessDefinition).assertThat().field("name").is(randomProcessDefinition.onModel().getName()); processDefinitionsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -55,7 +55,7 @@ public class GetProcessDefinitionSanityTests extends RestWorkflowTest public void anyUserGetsProcessDefinition() throws Exception { restClient.authenticateUser(testUser); - processDefinitionsApi.getProcessDefinition(randomProcessDefinition).and().assertField("name").is(randomProcessDefinition.onModel().getName()); + processDefinitionsApi.getProcessDefinition(randomProcessDefinition).assertThat().field("name").is(randomProcessDefinition.onModel().getName()); processDefinitionsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java index cba8350c1..04b3b1bd5 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java @@ -45,7 +45,7 @@ public class GetProcessDefinitionStartFormModelSanityTests extends RestWorkflowT public void nonNetworkAdminGetsStartFormModel() throws Exception { randomProcessDefinition = processDefinitionsApi.getProcessDefinitions().getOneRandomEntry(); - processDefinitionsApi.getProcessDefinitionStartFormModel(randomProcessDefinition).assertEntriesListIsNotEmpty(); + processDefinitionsApi.getProcessDefinitionStartFormModel(randomProcessDefinition).entriesListIsNotEmpty(); processDefinitionsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -59,7 +59,7 @@ public class GetProcessDefinitionStartFormModelSanityTests extends RestWorkflowT tenantApi.createTenant(adminTenantUser); restClient.authenticateUser(adminTenantUser); randomProcessDefinition = processDefinitionsApi.getProcessDefinitions().getOneRandomEntry(); - processDefinitionsApi.getProcessDefinitionStartFormModel(randomProcessDefinition).assertEntriesListIsNotEmpty(); + processDefinitionsApi.getProcessDefinitionStartFormModel(randomProcessDefinition).entriesListIsNotEmpty(); processDefinitionsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java index f907b342d..ad09d23b5 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java @@ -43,7 +43,7 @@ public class GetProcessDefinitionsSanityTests extends RestWorkflowTest public void nonNetworkAdminGetsProcessDefinitions() throws Exception { restClient.authenticateUser(adminUserModel); - processDefinitionsApi.getProcessDefinitions().assertEntriesListIsNotEmpty(); + processDefinitionsApi.getProcessDefinitions().entriesListIsNotEmpty(); processDefinitionsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -57,7 +57,7 @@ public class GetProcessDefinitionsSanityTests extends RestWorkflowTest tenantApi.useRestClient(restClient); tenantApi.createTenant(adminTenantUser); restClient.authenticateUser(adminTenantUser); - processDefinitionsApi.getProcessDefinitions().assertEntriesListIsNotEmpty(); + processDefinitionsApi.getProcessDefinitions().entriesListIsNotEmpty(); processDefinitionsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemSanityTests.java index ff03ebea9..42314ed19 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemSanityTests.java @@ -60,7 +60,7 @@ public class AddProcessItemSanityTests extends RestWorkflowTest processModel = processesApi.getProcesses().getOneRandomEntry(); processItem = processesApi.addProcessItem(processModel, document2); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); - processesApi.getProcessesItems(processModel).assertEntriesListContains("id", processItem.getId()); + processesApi.getProcessesItems(processModel).entriesListContains("id", processItem.getId()); } @@ -74,7 +74,7 @@ public class AddProcessItemSanityTests extends RestWorkflowTest processModel = processesApi.getProcesses().getOneRandomEntry(); processItem = processesApi.addProcessItem(processModel, document3); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); - processesApi.getProcessesItems(processModel).assertEntriesListContains("id", processItem.getId()); + processesApi.getProcessesItems(processModel).entriesListContains("id", processItem.getId()); processItem = processesApi.addProcessItem(processModel, document3); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.BAD_REQUEST); } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessSanityTests.java index 44b998e77..01781efcb 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessSanityTests.java @@ -53,7 +53,7 @@ public class AddProcessSanityTests extends RestWorkflowTest restClient.authenticateUser(userWhoStartsProcess); addedProcess = processesApi.addProcess("activitiAdhoc", assignee, false, Priority.Normal); - processesApi.getProcesses().assertEntriesListContains("id", addedProcess.getId()); + processesApi.getProcesses().entriesListContains("id", addedProcess.getId()); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -69,7 +69,7 @@ public class AddProcessSanityTests extends RestWorkflowTest restClient.authenticateUser(tenantUserWhoStartsProcess); addedProcess = processesApi.addProcess("activitiAdhoc", tenantAssignee, false, Priority.Normal); - processesApi.getProcesses().assertEntriesListContains("id", addedProcess.getId()); + processesApi.getProcesses().entriesListContains("id", addedProcess.getId()); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java index 74082d1fe..6c6446554 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java @@ -53,7 +53,7 @@ public class DeleteProcessSanityTests extends RestWorkflowTest processesApi.deleteProcess(task); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); - processesApi.getProcesses().assertEntriesListDoesNotContain("id", task.getNodeRef()); + processesApi.getProcesses().entriesListDoesNotContain("id", task.getNodeRef()); } @TestRail(section = { TestGroup.REST_API, @@ -65,7 +65,7 @@ public class DeleteProcessSanityTests extends RestWorkflowTest processesApi.deleteProcess(task); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); - processesApi.getProcesses().assertEntriesListDoesNotContain("id", task.getNodeRef()); + processesApi.getProcesses().entriesListDoesNotContain("id", task.getNodeRef()); } @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify User that is not involved in a process is not authorized to delete it using REST API and status code is 403") diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksSanityTests.java index d38924343..a74281ea6 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksSanityTests.java @@ -52,10 +52,10 @@ public class GetProcessTasksSanityTests extends RestWorkflowTest { restClient.authenticateUser(userModel); processesApi.getProcessTasks(process) - .assertEntriesListIsNotEmpty() - .assertEntriesListContains("assignee", assignee1.getUsername()) - .assertEntriesListContains("assignee", assignee2.getUsername()) - .assertEntriesListContains("assignee", assignee2.getUsername()); + .entriesListIsNotEmpty() + .entriesListContains("assignee", assignee1.getUsername()) + .entriesListContains("assignee", assignee2.getUsername()) + .entriesListContains("assignee", assignee2.getUsername()); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -64,10 +64,10 @@ public class GetProcessTasksSanityTests extends RestWorkflowTest { restClient.authenticateUser(assignee1); processesApi.getProcessTasks(process) - .assertEntriesListIsNotEmpty() - .assertEntriesListContains("assignee", assignee1.getUsername()) - .assertEntriesListContains("assignee", assignee2.getUsername()) - .assertEntriesListContains("assignee", assignee2.getUsername()); + .entriesListIsNotEmpty() + .entriesListContains("assignee", assignee1.getUsername()) + .entriesListContains("assignee", assignee2.getUsername()) + .entriesListContains("assignee", assignee2.getUsername()); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -80,8 +80,8 @@ public class GetProcessTasksSanityTests extends RestWorkflowTest restClient.authenticateUser(assignee2); processesApi.getProcessTasks(process) - .assertEntriesListIsNotEmpty() - .assertEntriesListContains("assignee", userModel.getUsername()); + .entriesListIsNotEmpty() + .entriesListContains("assignee", userModel.getUsername()); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java index 68f81c2d1..5456ff1c1 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java @@ -52,7 +52,7 @@ public class GetProcessesSanityTests extends RestWorkflowTest { restClient.authenticateUser(userWhoStartsTask); - processesApi.getProcesses().assertEntriesListContains("id", task.getNodeRef()); + processesApi.getProcesses().entriesListContains("id", task.getNodeRef()); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -62,7 +62,7 @@ public class GetProcessesSanityTests extends RestWorkflowTest { restClient.authenticateUser(assignee); - processesApi.getProcesses().assertEntriesListContains("id", task.getNodeRef()); + processesApi.getProcesses().entriesListContains("id", task.getNodeRef()); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -72,7 +72,7 @@ public class GetProcessesSanityTests extends RestWorkflowTest { restClient.authenticateUser(anotherUser); - processesApi.getProcesses().assertEntriesListDoesNotContain("id", task.getNodeRef()); + processesApi.getProcesses().entriesListDoesNotContain("id", task.getNodeRef()); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -82,7 +82,7 @@ public class GetProcessesSanityTests extends RestWorkflowTest { restClient.authenticateUser(dataUser.getAdminUser()); - processesApi.getProcesses().assertEntriesListContains("id", task.getNodeRef()); + processesApi.getProcesses().entriesListContains("id", task.getNodeRef()); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessItemSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessItemSanityTests.java index 4976afd90..8d687e0ce 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessItemSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessItemSanityTests.java @@ -59,7 +59,7 @@ public class RemoveProcessItemSanityTests extends RestWorkflowTest processItem = processesApi.addProcessItem(processModel, document2); processesApi.deleteProcessItem(processModel, processItem); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); - processesApi.getProcessesItems(processModel).assertEntriesListDoesNotContain("id", processItem.getId()); + processesApi.getProcessesItems(processModel).entriesListDoesNotContain("id", processItem.getId()); } @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessVariableSanityTests.java index 0a2002256..57b51d034 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessVariableSanityTests.java @@ -58,7 +58,7 @@ public class RemoveProcessVariableSanityTests extends RestWorkflowTest processesApi.addProcessVariable(processModel, variableModel); processesApi.deleteProcessVariable(processModel, variableModel); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); - processesApi.getProcessesVariables(processModel).assertEntriesListDoesNotContain("name", variableModel.getName()); + processesApi.getProcessesVariables(processModel).entriesListDoesNotContain("name", variableModel.getName()); } @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/UpdateProcessVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/UpdateProcessVariableSanityTests.java index 813a1dddd..c3e34f939 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/UpdateProcessVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/UpdateProcessVariableSanityTests.java @@ -56,7 +56,7 @@ public class UpdateProcessVariableSanityTests extends RestWorkflowTest RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); processModel = processesApi.getProcesses().getOneRandomEntry(); processesApi.updateProcessVariable(processModel, variableModel); - processesApi.getProcessesVariables(processModel).assertEntriesListContains("name", variableModel.getName()); + processesApi.getProcessesVariables(processModel).entriesListContains("name", variableModel.getName()); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -69,7 +69,7 @@ public class UpdateProcessVariableSanityTests extends RestWorkflowTest processModel = processesApi.getProcesses().getOneRandomEntry(); processesApi.addProcessVariable(processModel, variableModel); variableModel.setValue("newValue"); - processesApi.updateProcessVariable(processModel, variableModel).and().assertField("value").is("newValue"); + processesApi.updateProcessVariable(processModel, variableModel).assertThat().field("value").is("newValue"); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemSanityTests.java index cff45252a..f4b1136b4 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemSanityTests.java @@ -57,14 +57,14 @@ public class AddTaskItemSanityTests extends RestWorkflowTest document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); taskItem = tasksApi.addTaskItem(taskModel, document2); - taskItem.and().assertField("createdAt").is(taskItem.getCreatedAt()) - .and().assertField("size").is(taskItem.getSize()) - .and().assertField("createdBy").is(taskItem.getCreatedBy()) - .and().assertField("modifiedAt").is(taskItem.getModifiedAt()) - .and().assertField("name").is(taskItem.getName()) - .and().assertField("modifiedBy").is(taskItem.getModifiedBy()) - .and().assertField("id").is(taskItem.getId()) - .and().assertField("mimeType").is(taskItem.getMimeType()); + taskItem.assertThat().field("createdAt").is(taskItem.getCreatedAt()) + .assertThat().field("size").is(taskItem.getSize()) + .assertThat().field("createdBy").is(taskItem.getCreatedBy()) + .assertThat().field("modifiedAt").is(taskItem.getModifiedAt()) + .assertThat().field("name").is(taskItem.getName()) + .assertThat().field("modifiedBy").is(taskItem.getModifiedBy()) + .assertThat().field("id").is(taskItem.getId()) + .assertThat().field("mimeType").is(taskItem.getMimeType()); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } @@ -77,14 +77,14 @@ public class AddTaskItemSanityTests extends RestWorkflowTest restClient.authenticateUser(adminUser); document3 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); taskItem = tasksApi.addTaskItem(taskModel, document3); - taskItem.and().assertField("createdAt").is(taskItem.getCreatedAt()) - .and().assertField("size").is(taskItem.getSize()) - .and().assertField("createdBy").is(taskItem.getCreatedBy()) - .and().assertField("modifiedAt").is(taskItem.getModifiedAt()) - .and().assertField("name").is(taskItem.getName()) - .and().assertField("modifiedBy").is(taskItem.getModifiedBy()) - .and().assertField("id").is(taskItem.getId()) - .and().assertField("mimeType").is(taskItem.getMimeType()); + taskItem.assertThat().field("createdAt").is(taskItem.getCreatedAt()) + .assertThat().field("size").is(taskItem.getSize()) + .and().field("createdBy").is(taskItem.getCreatedBy()) + .and().field("modifiedAt").is(taskItem.getModifiedAt()) + .and().field("name").is(taskItem.getName()) + .and().field("modifiedBy").is(taskItem.getModifiedBy()) + .and().field("id").is(taskItem.getId()) + .and().field("mimeType").is(taskItem.getMimeType()); taskItem = tasksApi.addTaskItem(taskModel, document3); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.BAD_REQUEST); } diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesSanityTests.java index 18784ede0..822beebbb 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesSanityTests.java @@ -52,10 +52,10 @@ public class AddTaskVariablesSanityTests extends RestWorkflowTest restClient.authenticateUser(adminUser); RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); tasksApi.addTaskVariable(taskModel, variableModel) - .and().assertField("scope").is(variableModel.getScope()) - .and().assertField("name").is(variableModel.getName()) - .and().assertField("value").is(variableModel.getValue()) - .and().assertField("type").is(variableModel.getType()); + .assertThat().field("scope").is(variableModel.getScope()) + .and().field("name").is(variableModel.getName()) + .and().field("value").is(variableModel.getValue()) + .and().field("type").is(variableModel.getType()); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } @@ -66,10 +66,10 @@ public class AddTaskVariablesSanityTests extends RestWorkflowTest restClient.authenticateUser(assigneeUser); RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); tasksApi.addTaskVariable(taskModel, variableModel) - .and().assertField("scope").is(variableModel.getScope()) - .and().assertField("name").is(variableModel.getName()) - .and().assertField("value").is(variableModel.getValue()) - .and().assertField("type").is(variableModel.getType()); + .assertThat().field("scope").is(variableModel.getScope()) + .and().field("name").is(variableModel.getName()) + .and().field("value").is(variableModel.getValue()) + .and().field("type").is(variableModel.getType()); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } @@ -80,10 +80,10 @@ public class AddTaskVariablesSanityTests extends RestWorkflowTest restClient.authenticateUser(userWhoStartsTask); RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); tasksApi.addTaskVariable(taskModel, variableModel) - .and().assertField("scope").is(variableModel.getScope()) - .and().assertField("name").is(variableModel.getName()) - .and().assertField("value").is(variableModel.getValue()) - .and().assertField("type").is(variableModel.getType()); + .assertThat().field("scope").is(variableModel.getScope()) + .and().field("name").is(variableModel.getName()) + .and().field("value").is(variableModel.getValue()) + .and().field("type").is(variableModel.getType()); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelSanityTests.java index 2cf2d89a3..88920c233 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelSanityTests.java @@ -48,7 +48,7 @@ public class GetTaskFormModelSanityTests extends RestWorkflowTest RestFormModelsCollection returnedCollection = tasksApi.getTaskFormModel(taskModel); - returnedCollection.assertEntriesListIsNotEmpty(); + returnedCollection.entriesListIsNotEmpty(); String[] qualifiedNames = { "{http://www.alfresco.org/model/bpm/1.0}percentComplete", @@ -65,7 +65,7 @@ public class GetTaskFormModelSanityTests extends RestWorkflowTest for(String formQualifiedName : qualifiedNames) { - returnedCollection.assertEntriesListContains("qualifiedName", formQualifiedName); + returnedCollection.entriesListContains("qualifiedName", formQualifiedName); } tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); @@ -76,7 +76,7 @@ public class GetTaskFormModelSanityTests extends RestWorkflowTest public void involvedUserGetsTaskFormModels() throws Exception { restClient.authenticateUser(userModel); - tasksApi.getTaskFormModel(taskModel).assertEntriesListIsNotEmpty(); + tasksApi.getTaskFormModel(taskModel).entriesListIsNotEmpty(); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskItemsSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskItemsSanityTests.java index b7a422959..5bb79e5c0 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskItemsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskItemsSanityTests.java @@ -52,8 +52,8 @@ public class GetTaskItemsSanityTests extends RestWorkflowTest document1 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); taskItem = tasksApi.addTaskItem(taskModel, document1); tasksApi.getTaskItems(taskModel) - .assertEntriesListIsNotEmpty() - .assertEntriesListContains("id", taskItem.getId()); + .entriesListIsNotEmpty() + .entriesListContains("id", taskItem.getId()); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -66,8 +66,8 @@ public class GetTaskItemsSanityTests extends RestWorkflowTest document1 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); taskItem = tasksApi.addTaskItem(taskModel, document1); tasksApi.getTaskItems(taskModel) - .assertEntriesListIsNotEmpty() - .assertEntriesListContains("id", taskItem.getId()); + .entriesListIsNotEmpty() + .entriesListContains("id", taskItem.getId()); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -92,8 +92,8 @@ public class GetTaskItemsSanityTests extends RestWorkflowTest document1 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); taskItem = tasksApi.addTaskItem(taskModel, document1); tasksApi.getTaskItems(taskModel) - .assertEntriesListIsNotEmpty() - .assertEntriesListContains("id", taskItem.getId()); + .entriesListIsNotEmpty() + .entriesListContains("id", taskItem.getId()); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksSanityTests.java index 6b3edb97f..88491847e 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksSanityTests.java @@ -46,7 +46,7 @@ public class GetTasksSanityTests extends RestWorkflowTest { UserModel adminUser = dataUser.getAdminUser(); restClient.authenticateUser(adminUser); - tasksApi.getTasks().assertEntriesListIsNotEmpty(); + tasksApi.getTasks().entriesListIsNotEmpty(); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -54,7 +54,7 @@ public class GetTasksSanityTests extends RestWorkflowTest public void asigneeUserGetsItsTasks() throws Exception { restClient.authenticateUser(assigneeUser); - tasksApi.getTasks().assertEntriesListIsNotEmpty(); + tasksApi.getTasks().entriesListIsNotEmpty(); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -70,7 +70,7 @@ public class GetTasksSanityTests extends RestWorkflowTest dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); restClient.authenticateUser(userModel1); - tasksApi.getTasks().assertEntriesListIsNotEmpty(); + tasksApi.getTasks().entriesListIsNotEmpty(); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -85,7 +85,7 @@ public class GetTasksSanityTests extends RestWorkflowTest dataWorkflow.usingUser(userModel1).claimTask(taskModel); restClient.authenticateUser(userModel1); - tasksApi.getTasks().assertEntriesListIsNotEmpty(); + tasksApi.getTasks().entriesListIsNotEmpty(); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -100,7 +100,7 @@ public class GetTasksSanityTests extends RestWorkflowTest dataWorkflow.usingUser(userModel1).claimTask(taskModel); restClient.authenticateUser(userModel2); - tasksApi.getTasks().assertEntriesListIsEmpty(); + tasksApi.getTasks().entriesListIsEmpty(); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } } From 63f576b83f8f579386b9d830cae1e13527c7222c Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Tue, 25 Oct 2016 10:17:07 +0300 Subject: [PATCH 0491/1491] add new test assertion --- .../tasks/GetTaskFormModelSanityTests.java | 26 ++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelSanityTests.java index 2cf2d89a3..9383e5cb7 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelSanityTests.java @@ -46,8 +46,8 @@ public class GetTaskFormModelSanityTests extends RestWorkflowTest { restClient.authenticateUser(dataUser.getAdminUser()); RestFormModelsCollection returnedCollection = tasksApi.getTaskFormModel(taskModel); - + tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); returnedCollection.assertEntriesListIsNotEmpty(); String[] qualifiedNames = { @@ -68,7 +68,7 @@ public class GetTaskFormModelSanityTests extends RestWorkflowTest returnedCollection.assertEntriesListContains("qualifiedName", formQualifiedName); } - tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, @@ -76,7 +76,27 @@ public class GetTaskFormModelSanityTests extends RestWorkflowTest public void involvedUserGetsTaskFormModels() throws Exception { restClient.authenticateUser(userModel); - tasksApi.getTaskFormModel(taskModel).assertEntriesListIsNotEmpty(); + RestFormModelsCollection returnedCollection = tasksApi.getTaskFormModel(taskModel).assertEntriesListIsNotEmpty(); + tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertEntriesListIsNotEmpty(); + + String[] qualifiedNames = { + "{http://www.alfresco.org/model/bpm/1.0}percentComplete", + "{http://www.alfresco.org/model/bpm/1.0}context", + "{http://www.alfresco.org/model/bpm/1.0}completedItems", + "{http://www.alfresco.org/model/content/1.0}name", + "{http://www.alfresco.org/model/bpm/1.0}packageActionGroup", + "{http://www.alfresco.org/model/bpm/1.0}reassignable", + "{http://www.alfresco.org/model/content/1.0}owner", + "{http://www.alfresco.org/model/bpm/1.0}outcome", + "{http://www.alfresco.org/model/bpm/1.0}taskId", + "{http://www.alfresco.org/model/bpm/1.0}packageItemActionGroup", + "{http://www.alfresco.org/model/bpm/1.0}completionDate"}; + + for(String formQualifiedName : qualifiedNames) + { + returnedCollection.assertEntriesListContains("qualifiedName", formQualifiedName); + } } } From 7539ab50973476022a24ebf515b9c4dc49d010fa Mon Sep 17 00:00:00 2001 From: Andreea Nechifor Date: Tue, 25 Oct 2016 10:23:30 +0300 Subject: [PATCH 0492/1491] Added Asserts on comments --- .../rest/comments/AddCommentSanityTests.java | 64 +++++++++++-------- .../rest/comments/AddCommentsSanityTests.java | 27 ++++++-- .../comments/DeleteCommentsSanityTests.java | 13 +++- .../rest/comments/GetCommentsSanityTests.java | 34 +++++++--- .../comments/UpdateCommentsSanityTests.java | 29 ++++++--- 5 files changed, 114 insertions(+), 53 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java index f9a375b77..09b72e779 100644 --- a/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java @@ -7,6 +7,7 @@ import org.alfresco.rest.requests.RestCommentsApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.model.ErrorModel; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; @@ -15,6 +16,7 @@ import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.dao.PermissionDeniedDataAccessException; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -24,15 +26,15 @@ public class AddCommentSanityTests extends RestTest { @Autowired RestCommentsApi commentsAPI; - + @Autowired DataUser dataUser; - + private UserModel adminUserModel; private FileModel document; private SiteModel siteModel; private ListUserWithRoles usersWithRoles; - + @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception { @@ -40,60 +42,70 @@ public class AddCommentSanityTests extends RestTest restClient.authenticateUser(adminUserModel); siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); commentsAPI.useRestClient(restClient); - document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify admin user adds comments with Rest API and status code is 201") + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify admin user adds comments with Rest API and status code is 201") public void adminIsAbleToAddComment() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); - commentsAPI.addComment(document, "This is a new comment added by " + adminUserModel.getUsername()); + String newContent = "This is a new comment added by " + adminUserModel.getUsername(); + commentsAPI.addComment(document, newContent) + .and().assertField("content").isNotEmpty() + .and().assertField("content").is(newContent); commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Manager user adds comments with Rest API and status code is 201") + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Manager user adds comments with Rest API and status code is 201") public void managerIsAbleToAddComment() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - commentsAPI.addComment(document, "This is a new comment added by user with role: " + UserRole.SiteManager); + String contentSiteManger = "This is a new comment added by user with role: " + UserRole.SiteManager; + commentsAPI.addComment(document, contentSiteManger) + .and().assertField("content").isNotEmpty() + .and().assertField("content").is(contentSiteManger); commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Contributor user adds comments with Rest API and status code is 201") + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Contributor user adds comments with Rest API and status code is 201") public void contributorIsAbleToAddComment() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - commentsAPI.addComment(document, "This is a new comment added by user with role" + UserRole.SiteContributor); + String contentSiteContributor = "This is a new comment added by user with role" + UserRole.SiteContributor; + commentsAPI.addComment(document, contentSiteContributor) + .and().assertField("content").isNotEmpty() + .and().assertField("content").is(contentSiteContributor); commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user adds comments with Rest API and status code is 201") + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user adds comments with Rest API and status code is 201") public void collaboratorIsAbleToAddComment() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - commentsAPI.addComment(document, "This is a new comment added by user with role: " + UserRole.SiteCollaborator); + String contentSiteCollaborator = "This is a new comment added by user with role: " + UserRole.SiteCollaborator; + commentsAPI.addComment(document, contentSiteCollaborator) + .and().assertField("content").isNotEmpty() + .and().assertField("content").is(contentSiteCollaborator); commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Consumer user adds comments with Rest API and status code is 201") - public void consumerIsAbleToAddComment() throws JsonToModelConversionException, Exception + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Consumer user can't add comments with Rest API and status code is 403") + public void consumerIsNotAbleToAddComment() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - commentsAPI.addComment(document, "This is a new comment added by user with role: " + UserRole.SiteConsumer); - commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + String contentSiteConsumer = "This is a new comment added by user with role: " + UserRole.SiteConsumer; + commentsAPI.addComment(document, contentSiteConsumer); + commentsAPI.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user gets status code 401 on post comments call") - @Bug(id="MNT-16904") + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user gets status code 401 on post comments call") + @Bug(id = "MNT-16904") public void unauthenticatedUserIsNotAbleToAddComment() throws JsonToModelConversionException, Exception - { + { restClient.authenticateUser(new UserModel("random user", "random password")); commentsAPI.addComment(document, "This is a new comment"); commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java index d60499925..7f8c7c280 100644 --- a/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java @@ -7,6 +7,7 @@ import org.alfresco.rest.requests.RestCommentsApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.RandomData; +import org.alfresco.utility.model.ErrorModel; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; @@ -59,7 +60,10 @@ public class AddCommentsSanityTests extends RestTest public void adminIsAbleToAddComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); - commentsAPI.addComments(document, comment1, comment2); + commentsAPI.addComments(document, comment1, comment2) + .assertEntriesListIsNotEmpty() + .assertEntriesListContains("content", comment1) + .assertEntriesListContains("content", comment2); commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } @@ -68,7 +72,11 @@ public class AddCommentsSanityTests extends RestTest public void managerIsAbleToAddComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - commentsAPI.addComments(document, comment1, comment2); + commentsAPI.addComments(document, comment1, comment2) + .assertEntriesListIsNotEmpty() + .assertEntriesListContains("content", comment1) + .assertEntriesListContains("content", comment2); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } @@ -77,7 +85,10 @@ public class AddCommentsSanityTests extends RestTest public void contributorIsAbleToAddComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - commentsAPI.addComments(document, comment1, comment2); + commentsAPI.addComments(document, comment1, comment2) + .assertEntriesListIsNotEmpty() + .assertEntriesListContains("content", comment1) + .assertEntriesListContains("content", comment2); commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } @@ -86,7 +97,10 @@ public class AddCommentsSanityTests extends RestTest public void collaboratorIsAbleToAddComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - commentsAPI.addComments(document, comment1, comment2); + commentsAPI.addComments(document, comment1, comment2) + .assertEntriesListIsNotEmpty() + .assertEntriesListContains("content", comment1) + .assertEntriesListContains("content", comment2); commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } @@ -96,7 +110,10 @@ public class AddCommentsSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); commentsAPI.addComments(document, comment1, comment2); - commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + commentsAPI.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + } @TestRail(section = { TestGroup.REST_API, diff --git a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java index e9ebd6296..789129ac7 100644 --- a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java @@ -8,6 +8,7 @@ import org.alfresco.rest.requests.RestCommentsApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.model.ErrorModel; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; @@ -81,7 +82,8 @@ public class DeleteCommentsSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); commentsAPI.deleteComment(document, comment); - commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, @@ -90,7 +92,9 @@ public class DeleteCommentsSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); commentsAPI.deleteComment(document, comment); - commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + commentsAPI.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, @@ -99,7 +103,9 @@ public class DeleteCommentsSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); commentsAPI.deleteComment(document, comment); - commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + commentsAPI.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, @@ -110,6 +116,7 @@ public class DeleteCommentsSanityTests extends RestTest restClient.authenticateUser(nonexistentModel); commentsAPI.deleteComment(document, comment); commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + } } diff --git a/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java index d1a82d698..11b145b26 100644 --- a/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java @@ -34,6 +34,7 @@ public class GetCommentsSanityTests extends RestTest private SiteModel siteModel; private UserModel userModel; private ListUserWithRoles usersWithRoles; + private String content; @BeforeClass(alwaysRun=true) public void dataPreparation() throws Exception @@ -43,7 +44,8 @@ public class GetCommentsSanityTests extends RestTest siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); commentsAPI.useRestClient(restClient); document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - commentsAPI.addComment(document, "This is a new comment"); + content = "This is a new comment"; + commentsAPI.addComment(document, content); usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); } @@ -62,7 +64,9 @@ public class GetCommentsSanityTests extends RestTest public void managerIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - commentsAPI.getNodeComments(document); + commentsAPI.getNodeComments(document) + .and().assertField("content").isNotEmpty() + .and().assertField("content").is(content); commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -71,7 +75,9 @@ public class GetCommentsSanityTests extends RestTest public void contributorIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - commentsAPI.getNodeComments(document); + commentsAPI.getNodeComments(document) + .and().assertField("content").isNotEmpty() + .and().assertField("content").is(content); commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -80,7 +86,9 @@ public class GetCommentsSanityTests extends RestTest public void collaboratorIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - commentsAPI.getNodeComments(document); + commentsAPI.getNodeComments(document) + .and().assertField("content").isNotEmpty() + .and().assertField("content").is(content); commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -89,7 +97,9 @@ public class GetCommentsSanityTests extends RestTest public void consumerIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - commentsAPI.getNodeComments(document); + commentsAPI.getNodeComments(document) + .and().assertField("content").isNotEmpty() + .and().assertField("content").is(content); commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -110,10 +120,13 @@ public class GetCommentsSanityTests extends RestTest { userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); restClient.authenticateUser(userModel); - commentsAPI.addComment(document, "This is a new comment added by " + userModel.getUsername()); + String contentManager = "This is a new comment added by " + userModel.getUsername(); + commentsAPI.addComment(document,contentManager); commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - commentsAPI.getNodeComments(document); + commentsAPI.getNodeComments(document) + .and().assertField("content").isNotEmpty() + .and().assertField("content").is(contentManager); commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -123,10 +136,13 @@ public class GetCommentsSanityTests extends RestTest { userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); restClient.authenticateUser(userModel); - commentsAPI.addComment(document, "This is a new comment added by " + userModel.getUsername()); + String contentCollaborator = "This is a new comment added by " + userModel.getUsername(); + commentsAPI.addComment(document, contentCollaborator); commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); restClient.authenticateUser(adminUserModel); - commentsAPI.getNodeComments(document); + commentsAPI.getNodeComments(document) + .and().assertField("content").isNotEmpty() + .and().assertField("content").is(contentCollaborator); commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } } diff --git a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java index 3e9c3be25..a463b594e 100644 --- a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java @@ -8,6 +8,7 @@ import org.alfresco.rest.requests.RestCommentsApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.model.ErrorModel; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; @@ -54,7 +55,10 @@ public class UpdateCommentsSanityTests extends RestTest public void adminIsAbleToUpdateComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); - commentsAPI.updateComment(document, commentModel, "This is the updated comment with admin user"); + String updatedContent = "This is the updated comment with admin user"; + commentsAPI.updateComment(document, commentModel, updatedContent) + .and().assertField("content").isNotEmpty() + .and().assertField("content").is(updatedContent); commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -65,7 +69,7 @@ public class UpdateCommentsSanityTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); commentsAPI.updateComment(document, commentModel, "This is the updated comment with Manager user") .and().assertField("content").is("This is the updated comment with Manager user") - .and().assertField("canDelete").is(true); + .and().assertField("canEdit").is(true); commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -74,8 +78,10 @@ public class UpdateCommentsSanityTests extends RestTest public void contributorIsNotAbleToUpdateComment() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - commentsAPI.updateComment(document, commentModel, "This is the updated comment with Contributor user"); - commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + String updatedContent = "This is the updated comment with Contributor user"; + commentsAPI.updateComment(document, commentModel, updatedContent); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, @@ -84,7 +90,8 @@ public class UpdateCommentsSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); commentsAPI.updateComment(document, commentModel, "This is the updated comment with Consumer user"); - commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, @@ -93,10 +100,10 @@ public class UpdateCommentsSanityTests extends RestTest public void collaboratorIsNotAbleToUpdateComment() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - commentsAPI.updateComment(document, commentModel, "This is the updated comment with Collaborator user") - .and().assertField("content").is("This is the updated comment with Collaborator user"); + commentsAPI.updateComment(document, commentModel, "This is the updated comment with Collaborator user"); - commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, @@ -118,7 +125,8 @@ public class UpdateCommentsSanityTests extends RestTest FolderModel content = FolderModel.getRandomFolderModel(); content.setNodeRef("node ref that does not exist"); commentsAPI.updateComment(content, commentModel, "This is the updated comment."); - commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary("node ref that does not exist was not found"); } @TestRail(section = { TestGroup.REST_API, TestGroup.SANITY }, executionType = ExecutionType.SANITY, description = "Verify if commentId is not set the status code is 404") @@ -130,7 +138,8 @@ public class UpdateCommentsSanityTests extends RestTest comment.setId("comment id that does not exist"); commentsAPI.updateComment(document, comment, "This is the updated comment."); - commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary("node ref that does not exist was not found"); } } From 9e15927e8541c64da07ae855cc81eef0cb27c4bf Mon Sep 17 00:00:00 2001 From: cagache Date: Tue, 25 Oct 2016 11:08:27 +0300 Subject: [PATCH 0493/1491] add assertions --- ...ests.java => AddFavoritesSanityTests.java} | 212 +++++++++--------- .../favorites/DeleteFavoritesSanityTests.java | 66 +++--- .../favorites/GetFavoriteSanityTests.java | 43 ++-- .../favorites/GetFavoritesSanityTests.java | 71 +++--- 4 files changed, 208 insertions(+), 184 deletions(-) rename e2e-test/java/org/alfresco/rest/favorites/{PostFavoritesSanityTests.java => AddFavoritesSanityTests.java} (87%) diff --git a/e2e-test/java/org/alfresco/rest/favorites/PostFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesSanityTests.java similarity index 87% rename from e2e-test/java/org/alfresco/rest/favorites/PostFavoritesSanityTests.java rename to e2e-test/java/org/alfresco/rest/favorites/AddFavoritesSanityTests.java index ce32d62de..d03130c54 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/PostFavoritesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesSanityTests.java @@ -1,106 +1,106 @@ -package org.alfresco.rest.favorites; - -import org.alfresco.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.requests.RestFavoritesApi; -import org.alfresco.rest.requests.RestSitesApi; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser; -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.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -@Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) -public class PostFavoritesSanityTests extends RestTest -{ - @Autowired - RestFavoritesApi favoritesAPI; - - @Autowired - RestSitesApi sitesApi; - - @Autowired - DataUser dataUser; - - private UserModel adminUserModel; - private SiteModel siteModel; - private ListUserWithRoles usersWithRoles; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - restClient.authenticateUser(adminUserModel); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - favoritesAPI.useRestClient(restClient); - sitesApi.useRestClient(restClient); - siteModel.setGuid(sitesApi.getSite(siteModel).getGuid()); - - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Admin user add site to favorites with Rest API and status code is 201") - public void adminIsAbleToAddToFavorites() throws Exception - { - favoritesAPI.addSiteToFavorites(adminUserModel, siteModel); - favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Manager user add site to favorites with Rest API and status code is 201") - public void managerIsAbleToAddToFavorites() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteManager), siteModel); - favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user add site to favorites with Rest API and status code is 201") - public void collaboratorIsAbleToAddToFavorites() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), siteModel); - favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Contributor user add site to favorites with Rest API and status code is 201") - public void contributorIsAbleToAddToFavorites() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor), siteModel); - favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Consumer user add site to favorites with Rest API and status code is 201") - public void consumerIsAbleToAddToFavorites() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer), siteModel); - favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Manager user gets status code 401 if authentication call fails") - @Bug(id="MNT-16904") - public void managerIsNotAbleToAddCommentIfAuthenticationFails() throws Exception - { - UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); - siteManager.setPassword("wrongPassword"); - restClient.authenticateUser(siteManager); - favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer), siteModel); - favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); - } -} +package org.alfresco.rest.favorites; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.requests.RestFavoritesApi; +import org.alfresco.rest.requests.RestSitesApi; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser; +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.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +@Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) +public class AddFavoritesSanityTests extends RestTest +{ + @Autowired + RestFavoritesApi favoritesAPI; + + @Autowired + RestSitesApi sitesApi; + + @Autowired + DataUser dataUser; + + private UserModel adminUserModel; + private SiteModel siteModel; + private ListUserWithRoles usersWithRoles; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + restClient.authenticateUser(adminUserModel); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + favoritesAPI.useRestClient(restClient); + sitesApi.useRestClient(restClient); + siteModel.setGuid(sitesApi.getSite(siteModel).getGuid()); + + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Admin user add site to favorites with Rest API and status code is 201") + public void adminIsAbleToAddToFavorites() throws Exception + { + favoritesAPI.addSiteToFavorites(adminUserModel, siteModel).and().assertField("targetGuid").is(siteModel.getGuid()); + favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Manager user add site to favorites with Rest API and status code is 201") + public void managerIsAbleToAddToFavorites() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteManager), siteModel).and().assertField("targetGuid").is(siteModel.getGuid()); + favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user add site to favorites with Rest API and status code is 201") + public void collaboratorIsAbleToAddToFavorites() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), siteModel).and().assertField("targetGuid").is(siteModel.getGuid()); + favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Contributor user add site to favorites with Rest API and status code is 201") + public void contributorIsAbleToAddToFavorites() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor), siteModel).and().assertField("targetGuid").is(siteModel.getGuid()); + favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Consumer user add site to favorites with Rest API and status code is 201") + public void consumerIsAbleToAddToFavorites() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer), siteModel).and().assertField("targetGuid").is(siteModel.getGuid()); + favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Manager user gets status code 401 if authentication call fails") + @Bug(id="MNT-16904") + public void managerIsNotAbleToAddToFavoritesIfAuthenticationFails() throws Exception + { + UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); + siteManager.setPassword("wrongPassword"); + restClient.authenticateUser(siteManager); + favoritesAPI.addSiteToFavorites(siteManager, siteModel); + favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + } +} diff --git a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoritesSanityTests.java index 017c03537..2908c437f 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoritesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoritesSanityTests.java @@ -6,6 +6,7 @@ import org.alfresco.rest.requests.RestFavoritesApi; import org.alfresco.rest.requests.RestSitesApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.model.ErrorModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; @@ -46,52 +47,61 @@ public class DeleteFavoritesSanityTests extends RestTest } @TestRail(section = { TestGroup.REST_API, - TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Admin user delets site from favorites with Rest API and status code is 204") + TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Admin user deletes site from favorites with Rest API and status code is 204") public void adminIsAbleToDeleteFavorites() throws JsonToModelConversionException, Exception { - favoritesAPI.addSiteToFavorites(adminUserModel, siteModel); + favoritesAPI.addSiteToFavorites(adminUserModel, siteModel).and().assertField("targetGuid").is(siteModel.getGuid()); favoritesAPI.deleteSiteFromFavorites(adminUserModel, siteModel); favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); + favoritesAPI.getFavorites(adminUserModel).assertEntriesListDoesNotContain("targetGuid", siteModel.getGuid()); } @TestRail(section = { TestGroup.REST_API, - TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Manager user delets site from favorites with Rest API and status code is 204") + TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Manager user deletes site from favorites with Rest API and status code is 204") public void managerIsAbleToDeleteFavorites() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteManager), siteModel); - favoritesAPI.deleteSiteFromFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteManager), siteModel); + UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); + restClient.authenticateUser(siteManager); + favoritesAPI.addSiteToFavorites(siteManager, siteModel).and().assertField("targetGuid").is(siteModel.getGuid()); + favoritesAPI.deleteSiteFromFavorites(siteManager, siteModel); favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); + favoritesAPI.getFavorites(siteManager).assertEntriesListDoesNotContain("targetGuid", siteModel.getGuid()); } @TestRail(section = { TestGroup.REST_API, - TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user delets site from favorites with Rest API and status code is 204") + TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user deletes site from favorites with Rest API and status code is 204") public void collaboratorIsAbleToDeleteFavorites() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), siteModel); - favoritesAPI.deleteSiteFromFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), siteModel); + UserModel siteCollaborator = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); + restClient.authenticateUser(siteCollaborator); + favoritesAPI.addSiteToFavorites(siteCollaborator, siteModel).and().assertField("targetGuid").is(siteModel.getGuid()); + favoritesAPI.deleteSiteFromFavorites(siteCollaborator, siteModel); favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); + favoritesAPI.getFavorites(siteCollaborator).assertEntriesListDoesNotContain("targetGuid", siteModel.getGuid()); } @TestRail(section = { TestGroup.REST_API, - TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Contributor user delets site from favorites with Rest API and status code is 204") + TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Contributor user deletes site from favorites with Rest API and status code is 204") public void contributorIsAbleToDeleteFavorites() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor), siteModel); - favoritesAPI.deleteSiteFromFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor), siteModel); + UserModel siteContributor = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); + restClient.authenticateUser(siteContributor); + favoritesAPI.addSiteToFavorites(siteContributor, siteModel).and().assertField("targetGuid").is(siteModel.getGuid()); + favoritesAPI.deleteSiteFromFavorites(siteContributor, siteModel); favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); + favoritesAPI.getFavorites(siteContributor).assertEntriesListDoesNotContain("targetGuid", siteModel.getGuid()); } @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Consumer user delets site from favorites with Rest API and status code is 204") public void consumerIsAbleToDeleteFavorites() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer), siteModel); - favoritesAPI.deleteSiteFromFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer), siteModel); + UserModel siteConsumer = usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer); + restClient.authenticateUser(siteConsumer); + favoritesAPI.addSiteToFavorites(siteConsumer, siteModel).and().assertField("targetGuid").is(siteModel.getGuid()); + favoritesAPI.deleteSiteFromFavorites(siteConsumer, siteModel); favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); + favoritesAPI.getFavorites(siteConsumer).assertEntriesListDoesNotContain("targetGuid", siteModel.getGuid()); } @TestRail(section = { TestGroup.REST_API, @@ -99,11 +109,12 @@ public class DeleteFavoritesSanityTests extends RestTest @Bug(id="MNT-16557") public void userIsNotAbleToDeleteFavoritesOfAnotherUser() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), siteModel); + UserModel siteCollaborator = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); + restClient.authenticateUser(siteCollaborator); + favoritesAPI.addSiteToFavorites(siteCollaborator, siteModel).and().assertField("targetGuid").is(siteModel.getGuid()); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - favoritesAPI.deleteSiteFromFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), siteModel); - favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + favoritesAPI.deleteSiteFromFavorites(siteCollaborator, siteModel); + favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify user doesn't have permission to delete favorites of admin user with Rest API and status code is 404") @@ -111,21 +122,22 @@ public class DeleteFavoritesSanityTests extends RestTest public void userIsNotAbleToDeleteFavoritesOfAdminUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); - favoritesAPI.addSiteToFavorites(adminUserModel, siteModel); + favoritesAPI.addSiteToFavorites(adminUserModel, siteModel).and().assertField("targetGuid").is(siteModel.getGuid()); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); favoritesAPI.deleteSiteFromFavorites(adminUserModel, siteModel); - favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify admin user doesn't have permission to delete favorites of another user with Rest API and status code is 404") @Bug(id="MNT-16557") public void adminIsNotAbleToDeleteFavoritesOfAnotherUser() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), siteModel); + UserModel siteCollaborator = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); + restClient.authenticateUser(siteCollaborator); + favoritesAPI.addSiteToFavorites(siteCollaborator, siteModel).and().assertField("targetGuid").is(siteModel.getGuid()); restClient.authenticateUser(adminUserModel); - favoritesAPI.deleteSiteFromFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), siteModel); - favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + favoritesAPI.deleteSiteFromFavorites(siteCollaborator, siteModel); + favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify user gets status code 401 if authentication call fails") diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java index 59d5febf2..937a4423f 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java @@ -7,11 +7,7 @@ import org.alfresco.rest.requests.RestFavoritesApi; import org.alfresco.rest.requests.RestSitesApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.model.*; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; @@ -56,8 +52,8 @@ public class GetFavoriteSanityTests extends RestTest TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets favorite site with Rest API and status code is 200") public void adminIsAbleToRetrieveFavoritesSite() throws JsonToModelConversionException, Exception { - favoritesAPI.addSiteToFavorites(adminUserModel, siteModel); - favoritesAPI.getSiteFavorites(adminUserModel, siteModel); + favoritesAPI.addSiteToFavorites(adminUserModel, siteModel).and().assertField("targetGuid").is(siteModel.getGuid()); + favoritesAPI.getSiteFavorites(adminUserModel, siteModel).and().assertField("targetGuid").is(siteModel.getGuid()); favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -65,8 +61,8 @@ public class GetFavoriteSanityTests extends RestTest TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets favorite folder with Rest API and status code is 200") public void adminIsAbleToRetrieveFavoritesFolder() throws JsonToModelConversionException, Exception { - favoritesAPI.addFolderToFavorites(adminUserModel, folderModel); - favoritesAPI.getFolderFavorites(adminUserModel, folderModel); + favoritesAPI.addFolderToFavorites(adminUserModel, folderModel).and().assertField("targetGuid").is(folderModel.getNodeRef()); + favoritesAPI.getFolderFavorites(adminUserModel, folderModel).and().assertField("targetGuid").is(folderModel.getNodeRef()); favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -74,8 +70,8 @@ public class GetFavoriteSanityTests extends RestTest TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets favorite file with Rest API and status code is 200") public void adminIsAbleToRetrieveFavoritesFile() throws JsonToModelConversionException, Exception { - favoritesAPI.addFileToFavorites(adminUserModel, fileModel); - favoritesAPI.getFileFavorites(adminUserModel, fileModel); + favoritesAPI.addFileToFavorites(adminUserModel, fileModel).and().assertField("targetGuid").is(fileModel.getNodeRef().replace(";1.0", "")); + favoritesAPI.getFileFavorites(adminUserModel, fileModel).and().assertField("targetGuid").is(fileModel.getNodeRef().replace(";1.0", "")); favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -84,8 +80,8 @@ public class GetFavoriteSanityTests extends RestTest public void managerIsAbleToRetrieveFavorite() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteManager), siteModel); - favoritesAPI.getSiteFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteManager), siteModel); + favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteManager), siteModel).and().assertField("targetGuid").is(siteModel.getGuid()); + favoritesAPI.getSiteFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteManager), siteModel).and().assertField("targetGuid").is(siteModel.getGuid()); favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -94,8 +90,8 @@ public class GetFavoriteSanityTests extends RestTest public void collaboratorIsAbleToRetrieveFavorites() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), siteModel); - favoritesAPI.getSiteFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), siteModel); + favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), siteModel).and().assertField("targetGuid").is(siteModel.getGuid()); + favoritesAPI.getSiteFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), siteModel).and().assertField("targetGuid").is(siteModel.getGuid()); favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -104,8 +100,8 @@ public class GetFavoriteSanityTests extends RestTest public void contributorIsAbleToRetrieveFavorite() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor), siteModel); - favoritesAPI.getSiteFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor), siteModel); + favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor), siteModel).and().assertField("targetGuid").is(siteModel.getGuid()); + favoritesAPI.getSiteFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor), siteModel).and().assertField("targetGuid").is(siteModel.getGuid()); favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -114,8 +110,8 @@ public class GetFavoriteSanityTests extends RestTest public void consumerIsAbleToRetrieveFavorites() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer), siteModel); - favoritesAPI.getSiteFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer), siteModel); + favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer), siteModel).and().assertField("targetGuid").is(siteModel.getGuid()); + favoritesAPI.getSiteFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer), siteModel).and().assertField("targetGuid").is(siteModel.getGuid()); favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -125,7 +121,8 @@ public class GetFavoriteSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); favoritesAPI.getSiteFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), siteModel); - favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); + favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator).getUsername())); } @TestRail(section = { TestGroup.REST_API, @@ -134,7 +131,8 @@ public class GetFavoriteSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); favoritesAPI.getSiteFavorites(adminUserModel, siteModel); - favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); + favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, adminUserModel.getUsername())); } @TestRail(section = { TestGroup.REST_API, @@ -143,7 +141,8 @@ public class GetFavoriteSanityTests extends RestTest { restClient.authenticateUser(adminUserModel); favoritesAPI.getSiteFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), siteModel); - favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); + favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator).getUsername())); } @TestRail(section = { TestGroup.REST_API, diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java index da1884097..0c1a337c1 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java @@ -7,11 +7,7 @@ import org.alfresco.rest.requests.RestFavoritesApi; import org.alfresco.rest.requests.RestSitesApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.model.*; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; @@ -64,9 +60,11 @@ public class GetFavoritesSanityTests extends RestTest TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets favorites sites with Rest API and status code is 200") public void adminIsAbleToRetrieveFavoritesSites() throws JsonToModelConversionException, Exception { - favoritesAPI.addSiteToFavorites(adminUserModel, firstSiteModel); - favoritesAPI.addSiteToFavorites(adminUserModel, secondSiteModel); - favoritesAPI.where().targetSiteExist().filterAnd().getFavorites(adminUserModel); + favoritesAPI.addSiteToFavorites(adminUserModel, firstSiteModel).and().assertField("targetGuid").is(firstSiteModel.getGuid()); + favoritesAPI.addSiteToFavorites(adminUserModel, secondSiteModel).and().assertField("targetGuid").is(secondSiteModel.getGuid()); + favoritesAPI.where().targetSiteExist().filterAnd().getFavorites(adminUserModel) + .assertEntriesListContains("targetGuid", firstSiteModel.getGuid()) + .assertEntriesListContains("targetGuid", secondSiteModel.getGuid()); favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -74,9 +72,11 @@ public class GetFavoritesSanityTests extends RestTest TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets favorites folders with Rest API and status code is 200") public void adminIsAbleToRetrieveFavoritesFolders() throws JsonToModelConversionException, Exception { - favoritesAPI.addFolderToFavorites(adminUserModel, firstFolderModel); - favoritesAPI.addFolderToFavorites(adminUserModel, secondFolderModel); - favoritesAPI.where().targetFolderExist().filterAnd().getFavorites(adminUserModel); + favoritesAPI.addFolderToFavorites(adminUserModel, firstFolderModel).and().assertField("targetGuid").is(firstFolderModel.getNodeRef()); + favoritesAPI.addFolderToFavorites(adminUserModel, secondFolderModel).and().assertField("targetGuid").is(secondFolderModel.getNodeRef()); + favoritesAPI.where().targetFolderExist().filterAnd().getFavorites(adminUserModel) + .assertEntriesListContains("targetGuid", firstFolderModel.getNodeRef()) + .assertEntriesListContains("targetGuid", secondFolderModel.getNodeRef()); favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -84,9 +84,11 @@ public class GetFavoritesSanityTests extends RestTest TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets favorites files with Rest API and status code is 200") public void adminIsAbleToRetrieveFavoritesFiles() throws JsonToModelConversionException, Exception { - favoritesAPI.addFileToFavorites(adminUserModel, firstFileModel); - favoritesAPI.addFileToFavorites(adminUserModel, secondFileModel); - favoritesAPI.where().targetFileExist().filterAnd().getFavorites(adminUserModel); + favoritesAPI.addFileToFavorites(adminUserModel, firstFileModel).and().assertField("targetGuid").is(firstFileModel.getNodeRef().replace(";1.0", "")); + favoritesAPI.addFileToFavorites(adminUserModel, secondFileModel).and().assertField("targetGuid").is(secondFileModel.getNodeRef().replace(";1.0", "")); + favoritesAPI.where().targetFileExist().filterAnd().getFavorites(adminUserModel) + .assertEntriesListContains("targetGuid", firstFileModel.getNodeRef().replace(";1.0", "")) + .assertEntriesListContains("targetGuid", secondFileModel.getNodeRef().replace(";1.0", "")); favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -95,9 +97,11 @@ public class GetFavoritesSanityTests extends RestTest public void managerIsAbleToRetrieveFavorites() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteManager), firstSiteModel); - favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteManager), secondSiteModel); - favoritesAPI.where().targetSiteExist().filterAnd().getFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteManager), firstSiteModel).and().assertField("targetGuid").is(firstSiteModel.getGuid()); + favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteManager), secondSiteModel).and().assertField("targetGuid").is(secondSiteModel.getGuid()); + favoritesAPI.where().targetSiteExist().filterAnd().getFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .assertEntriesListContains("targetGuid", firstSiteModel.getGuid()) + .assertEntriesListContains("targetGuid", secondSiteModel.getGuid()); favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -106,9 +110,11 @@ public class GetFavoritesSanityTests extends RestTest public void collaboratorIsAbleToRetrieveFavorites() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), firstSiteModel); - favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), secondSiteModel); - favoritesAPI.where().targetSiteExist().filterAnd().getFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), firstSiteModel).and().assertField("targetGuid").is(firstSiteModel.getGuid()); + favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), secondSiteModel).and().assertField("targetGuid").is(secondSiteModel.getGuid()); + favoritesAPI.where().targetSiteExist().filterAnd().getFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .assertEntriesListContains("targetGuid", firstSiteModel.getGuid()) + .assertEntriesListContains("targetGuid", secondSiteModel.getGuid()); favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -117,9 +123,11 @@ public class GetFavoritesSanityTests extends RestTest public void contributorIsAbleToRetrieveFavorites() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor), firstSiteModel); - favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor), secondSiteModel); - favoritesAPI.where().targetSiteExist().filterAnd().getFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor), firstSiteModel).and().assertField("targetGuid").is(firstSiteModel.getGuid()); + favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor), secondSiteModel).and().assertField("targetGuid").is(secondSiteModel.getGuid()); + favoritesAPI.where().targetSiteExist().filterAnd().getFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) + .assertEntriesListContains("targetGuid", firstSiteModel.getGuid()) + .assertEntriesListContains("targetGuid", secondSiteModel.getGuid()); favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -128,9 +136,11 @@ public class GetFavoritesSanityTests extends RestTest public void consumerIsAbleToRetrieveFavorites() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer), firstSiteModel); - favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer), secondSiteModel); - favoritesAPI.where().targetSiteExist().filterAnd().getFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer), firstSiteModel).and().assertField("targetGuid").is(firstSiteModel.getGuid()); + favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer), secondSiteModel).and().assertField("targetGuid").is(secondSiteModel.getGuid()); + favoritesAPI.where().targetSiteExist().filterAnd().getFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + .assertEntriesListContains("targetGuid", firstSiteModel.getGuid()) + .assertEntriesListContains("targetGuid", secondSiteModel.getGuid()); favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -140,7 +150,8 @@ public class GetFavoritesSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); favoritesAPI.where().targetSiteExist().filterAnd().getFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); + favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator).getUsername())); } @TestRail(section = { TestGroup.REST_API, @@ -149,7 +160,8 @@ public class GetFavoritesSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); favoritesAPI.where().targetSiteExist().filterAnd().getFavorites(adminUserModel); - favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); + favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, adminUserModel.getUsername())); } @TestRail(section = { TestGroup.REST_API, @@ -158,7 +170,8 @@ public class GetFavoritesSanityTests extends RestTest { restClient.authenticateUser(adminUserModel); favoritesAPI.where().targetSiteExist().filterAnd().getFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); + favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator).getUsername())); } @TestRail(section = { TestGroup.REST_API, From 0e6bdaabdd14036f2f1c345616196d94bf63c94e Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Tue, 25 Oct 2016 12:26:42 +0300 Subject: [PATCH 0494/1491] Add assertions to tests --- .../processes/AddProcessItemSanityTests.java | 25 +++------------ .../processes/AddProcessSanityTests.java | 10 +++--- .../AddProcessVariableSanityTests.java | 20 ++++++------ .../tasks/AddTaskItemSanityTests.java | 32 +++---------------- .../tasks/GetTaskItemsSanityTests.java | 21 ++++++------ .../tasks/RemoveTaskItemSanityTests.java | 2 +- .../tasks/UpdateTaskVariableSanityTests.java | 22 ++++++------- 7 files changed, 44 insertions(+), 88 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemSanityTests.java index f96f19728..4b9396a2f 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemSanityTests.java @@ -59,18 +59,9 @@ public class AddProcessItemSanityTests extends RestWorkflowTest document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); processModel = processesApi.getProcesses().getOneRandomEntry(); processItem = processesApi.addProcessItem(processModel, document2); - processItem.and().assertField("createdAt").is(processItem.getCreatedAt()) - .and().assertField("size").is(processItem.getSize()) - .and().assertField("createdBy").is(processItem.getCreatedBy()) - .and().assertField("modifiedAt").is(processItem.getModifiedAt()) - .and().assertField("name").is(processItem.getName()) - .and().assertField("modifiedBy").is(processItem.getModifiedBy()) - .and().assertField("id").is(processItem.getId()) - .and().assertField("mimeType").is(processItem.getMimeType()); - + processItem.and().assertField("name").is(document2.getName()); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); - processesApi.getProcessesItems(processModel).assertEntriesListContains("id", processItem.getId()); - + processesApi.getProcessesItems(processModel).assertEntriesListContains("name", document2.getName()); } @Bug(id= "MNT-16966") @@ -82,17 +73,9 @@ public class AddProcessItemSanityTests extends RestWorkflowTest document3 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); processModel = processesApi.getProcesses().getOneRandomEntry(); processItem = processesApi.addProcessItem(processModel, document3); - processItem.and().assertField("createdAt").is(processItem.getCreatedAt()) - .and().assertField("size").is(processItem.getSize()) - .and().assertField("createdBy").is(processItem.getCreatedBy()) - .and().assertField("modifiedAt").is(processItem.getModifiedAt()) - .and().assertField("name").is(processItem.getName()) - .and().assertField("modifiedBy").is(processItem.getModifiedBy()) - .and().assertField("id").is(processItem.getId()) - .and().assertField("mimeType").is(processItem.getMimeType()); - + processItem.and().assertField("name").is(document3.getName()); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); - processesApi.getProcessesItems(processModel).assertEntriesListContains("id", processItem.getId()); + processesApi.getProcessesItems(processModel).assertEntriesListContains("name", document3.getName()); processItem = processesApi.addProcessItem(processModel, document3); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.BAD_REQUEST); } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessSanityTests.java index b382c23a7..e4c94be03 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessSanityTests.java @@ -53,11 +53,10 @@ public class AddProcessSanityTests extends RestWorkflowTest restClient.authenticateUser(userWhoStartsProcess); addedProcess = processesApi.addProcess("activitiAdhoc", assignee, false, Priority.Normal); - addedProcess.and().assertField("id").is(addedProcess.getId()) - .and().assertField("startUserId").is(addedProcess.getStartUserId()); + addedProcess.and().assertField("startUserId").is(userWhoStartsProcess.getUsername()); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); - processesApi.getProcesses().assertEntriesListContains("id", addedProcess.getId()); + processesApi.getProcesses().assertEntriesListIsNotEmpty(); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -73,10 +72,9 @@ public class AddProcessSanityTests extends RestWorkflowTest restClient.authenticateUser(tenantUserWhoStartsProcess); addedProcess = processesApi.addProcess("activitiAdhoc", tenantAssignee, false, Priority.Normal); - addedProcess.and().assertField("id").is(addedProcess.getId()) - .and().assertField("startUserId").is(addedProcess.getStartUserId()); + addedProcess.and().assertField("startUserId").is(tenantUserWhoStartsProcess.getUsername()); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); - processesApi.getProcesses().assertEntriesListContains("id", addedProcess.getId()); + processesApi.getProcesses().assertEntriesListIsNotEmpty(); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java index ce3cba96e..8b73ae1a8 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java @@ -63,12 +63,12 @@ public class AddProcessVariableSanityTests extends RestWorkflowTest processModel = processesApi.getProcesses().getOneRandomEntry(); processVariable = processesApi.addProcessVariable(processModel, variableModel); - processVariable.and().assertField("name").is(processVariable.getName()) - .and().assertField("type").is(processVariable.getType()) - .and().assertField("value").is(processVariable.getValue()); + processVariable.and().assertField("name").is(variableModel.getName()) + .and().assertField("type").is(variableModel.getType()) + .and().assertField("value").is(variableModel.getValue()); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); - processesApi.getProcessesVariables(processModel).assertEntriesListContains("name", processVariable.getName()); + processesApi.getProcessesVariables(processModel).assertEntriesListContains("name", variableModel.getName()); } @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, @@ -79,9 +79,9 @@ public class AddProcessVariableSanityTests extends RestWorkflowTest RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); processModel = processesApi.getProcesses().getOneRandomEntry(); processVariable = processesApi.addProcessVariable(processModel, variableModel); - processVariable.and().assertField("name").is(processVariable.getName()) - .and().assertField("type").is(processVariable.getType()) - .and().assertField("value").is(processVariable.getValue()); + processVariable.and().assertField("name").is(variableModel.getName()) + .and().assertField("type").is(variableModel.getType()) + .and().assertField("value").is(variableModel.getValue()); String newValue = RandomData.getRandomName("value"); variableModel.setValue(newValue); @@ -111,9 +111,9 @@ public class AddProcessVariableSanityTests extends RestWorkflowTest RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); processModel = processesApi.getProcesses().getOneRandomEntry(); processesApi.addProcessVariable(processModel, variableModel); - processVariable.and().assertField("name").is(processVariable.getName()) - .and().assertField("type").is(processVariable.getType()) - .and().assertField("value").is(processVariable.getValue()); + processVariable.and().assertField("name").is(variableModel.getName()) + .and().assertField("type").is(variableModel.getType()) + .and().assertField("value").is(variableModel.getValue()); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemSanityTests.java index 4f805cbb1..99273116f 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemSanityTests.java @@ -55,18 +55,10 @@ public class AddTaskItemSanityTests extends RestWorkflowTest UserModel adminUser = dataUser.getAdminUser(); restClient.authenticateUser(adminUser); document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - taskItem = tasksApi.addTaskItem(taskModel, document2); - - taskItem.and().assertField("createdAt").is(taskItem.getCreatedAt()) - .and().assertField("size").is(taskItem.getSize()) - .and().assertField("createdBy").is(taskItem.getCreatedBy()) - .and().assertField("modifiedAt").is(taskItem.getModifiedAt()) - .and().assertField("name").is(taskItem.getName()) - .and().assertField("modifiedBy").is(taskItem.getModifiedBy()) - .and().assertField("id").is(taskItem.getId()) - .and().assertField("mimeType").is(taskItem.getMimeType()); + taskItem = tasksApi.addTaskItem(taskModel, document2); + taskItem.and().assertField("name").is(document2.getName()); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); - tasksApi.getTaskItems(taskModel).assertEntriesListContains("id", taskItem.getId()); + tasksApi.getTaskItems(taskModel).assertEntriesListContains("name", document2.getName()); } @Bug(id = "MNT-16966") @@ -78,14 +70,7 @@ public class AddTaskItemSanityTests extends RestWorkflowTest restClient.authenticateUser(adminUser); document3 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); taskItem = tasksApi.addTaskItem(taskModel, document3); - taskItem.and().assertField("createdAt").is(taskItem.getCreatedAt()) - .and().assertField("size").is(taskItem.getSize()) - .and().assertField("createdBy").is(taskItem.getCreatedBy()) - .and().assertField("modifiedAt").is(taskItem.getModifiedAt()) - .and().assertField("name").is(taskItem.getName()) - .and().assertField("modifiedBy").is(taskItem.getModifiedBy()) - .and().assertField("id").is(taskItem.getId()) - .and().assertField("mimeType").is(taskItem.getMimeType()); + taskItem.and().assertField("name").is(document3.getName()); taskItem = tasksApi.addTaskItem(taskModel, document3); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.BAD_REQUEST); } @@ -110,14 +95,7 @@ public class AddTaskItemSanityTests extends RestWorkflowTest document4 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); taskItem = tasksApi.addTaskItem(taskModel, document4); - taskItem.and().assertField("createdAt").is(taskItem.getCreatedAt()) - .and().assertField("size").is(taskItem.getSize()) - .and().assertField("createdBy").is(taskItem.getCreatedBy()) - .and().assertField("modifiedAt").is(taskItem.getModifiedAt()) - .and().assertField("name").is(taskItem.getName()) - .and().assertField("modifiedBy").is(taskItem.getModifiedBy()) - .and().assertField("id").is(taskItem.getId()) - .and().assertField("mimeType").is(taskItem.getMimeType()); + taskItem.and().assertField("name").is(document4.getName()); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskItemsSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskItemsSanityTests.java index b7a422959..2bcc0fb7e 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskItemsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskItemsSanityTests.java @@ -2,7 +2,6 @@ package org.alfresco.rest.workflow.tasks; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestWorkflowTest; -import org.alfresco.rest.model.RestItemModel; import org.alfresco.rest.requests.RestTasksApi; import org.alfresco.rest.requests.RestTenantApi; import org.alfresco.utility.model.FileModel; @@ -30,7 +29,6 @@ public class GetTaskItemsSanityTests extends RestWorkflowTest private SiteModel siteModel; private FileModel fileModel, document1; private TaskModel taskModel; - private RestItemModel taskItem; @BeforeClass(alwaysRun=true) public void dataPreparation() throws Exception @@ -50,11 +48,10 @@ public class GetTaskItemsSanityTests extends RestWorkflowTest { restClient.authenticateUser(userWhoStartsTask); document1 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - taskItem = tasksApi.addTaskItem(taskModel, document1); + tasksApi.addTaskItem(taskModel, document1); tasksApi.getTaskItems(taskModel) - .assertEntriesListIsNotEmpty() - .assertEntriesListContains("id", taskItem.getId()); - + .assertEntriesListIsNotEmpty() + .assertEntriesListContains("name", document1.getName()); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -64,10 +61,10 @@ public class GetTaskItemsSanityTests extends RestWorkflowTest { restClient.authenticateUser(assignee); document1 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - taskItem = tasksApi.addTaskItem(taskModel, document1); + tasksApi.addTaskItem(taskModel, document1); tasksApi.getTaskItems(taskModel) - .assertEntriesListIsNotEmpty() - .assertEntriesListContains("id", taskItem.getId()); + .assertEntriesListIsNotEmpty() + .assertEntriesListContains("name", document1.getName()); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -90,10 +87,10 @@ public class GetTaskItemsSanityTests extends RestWorkflowTest dataWorkflow.usingUser(tenantUser).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(tenantUserAssignee); document1 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - taskItem = tasksApi.addTaskItem(taskModel, document1); + tasksApi.addTaskItem(taskModel, document1); tasksApi.getTaskItems(taskModel) - .assertEntriesListIsNotEmpty() - .assertEntriesListContains("id", taskItem.getId()); + .assertEntriesListIsNotEmpty() + .assertEntriesListContains("name", document1.getName()); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/RemoveTaskItemSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/RemoveTaskItemSanityTests.java index 2c2085edc..e6f90092f 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/RemoveTaskItemSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/RemoveTaskItemSanityTests.java @@ -56,7 +56,7 @@ public class RemoveTaskItemSanityTests extends RestWorkflowTest taskItem = tasksApi.addTaskItem(taskModel, document2); tasksApi.deleteTaskItem(taskModel, taskItem); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); - tasksApi.getTaskItems(taskModel).assertEntriesListDoesNotContain("id", taskItem.getId()); + tasksApi.getTaskItems(taskModel).assertEntriesListDoesNotContain("name", document2.getName()); } @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskVariableSanityTests.java index 8e6a6e80d..729846396 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskVariableSanityTests.java @@ -60,10 +60,10 @@ public class UpdateTaskVariableSanityTests extends RestWorkflowTest restClient.authenticateUser(adminUser); RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); taskVariable = tasksApi.updateTaskVariable(taskModel, variableModel); - taskVariable.and().assertField("scope").is(taskVariable.getScope()) - .and().assertField("name").is(taskVariable.getName()) - .and().assertField("type").is(taskVariable.getType()) - .and().assertField("value").is(taskVariable.getValue()); + taskVariable.and().assertField("scope").is(variableModel.getScope()) + .and().assertField("name").is(variableModel.getName()) + .and().assertField("type").is(variableModel.getType()) + .and().assertField("value").is(variableModel.getValue()); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -75,10 +75,10 @@ public class UpdateTaskVariableSanityTests extends RestWorkflowTest restClient.authenticateUser(adminUser); RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); taskVariable = tasksApi.updateTaskVariable(taskModel, variableModel); - taskVariable.and().assertField("scope").is(taskVariable.getScope()) - .and().assertField("name").is(taskVariable.getName()) - .and().assertField("type").is(taskVariable.getType()) - .and().assertField("value").is(taskVariable.getValue()); + taskVariable.and().assertField("scope").is(variableModel.getScope()) + .and().assertField("name").is(variableModel.getName()) + .and().assertField("type").is(variableModel.getType()) + .and().assertField("value").is(variableModel.getValue()); variableModel.setValue("updatedValue"); taskVariable = tasksApi.updateTaskVariable(taskModel, variableModel).and().assertField("value").is("updatedValue"); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); @@ -106,9 +106,9 @@ public class UpdateTaskVariableSanityTests extends RestWorkflowTest taskVariable = tasksApi.updateTaskVariable(tenantTask, variableModel); taskVariable.and().assertField("scope").is(taskVariable.getScope()) - .and().assertField("name").is(taskVariable.getName()) - .and().assertField("type").is(taskVariable.getType()) - .and().assertField("value").is(taskVariable.getValue()); + .and().assertField("name").is(variableModel.getName()) + .and().assertField("type").is(variableModel.getType()) + .and().assertField("value").is(variableModel.getValue()); variableModel.setValue("updatedValue"); taskVariable = tasksApi.updateTaskVariable(taskModel, variableModel).and().assertField("value").is("updatedValue"); From be9cafb5caeda808d999b77514621e7237154ea3 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Tue, 25 Oct 2016 12:40:13 +0300 Subject: [PATCH 0495/1491] Added assertions to sites Rest tests. --- .../rest/sites/AddSiteMemberSanityTests.java | 9 +++++++-- .../sites/GetSiteContainerSanityTests.java | 15 +++++++++----- .../sites/GetSiteContainersSanityTests.java | 10 +++++----- .../rest/sites/GetSiteMemberSanityTests.java | 15 +++++++++----- .../rest/sites/GetSiteMembersSanityTests.java | 20 ++++++++++++++----- .../rest/sites/GetSiteSanityTests.java | 17 ++++++++++------ .../rest/sites/GetSitesSanityTests.java | 10 +++++----- .../sites/RemoveSiteMemberSanityTests.java | 10 ++++++++++ .../sites/UpdateSiteMemberSanityTests.java | 12 +++++++++-- 9 files changed, 83 insertions(+), 35 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java index 251fd5ed4..1116874b7 100644 --- a/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java @@ -43,7 +43,8 @@ public class AddSiteMemberSanityTests extends RestTest UserModel testUser = dataUser.createRandomTestUser("testUser"); testUser.setUserRole(UserRole.SiteConsumer); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - siteAPI.addPerson(siteModel, testUser); + siteAPI.addPerson(siteModel, testUser).and().assertField("id").is(testUser.getUsername()) + .and().assertField("role").is(testUser.getUserRole()); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } @@ -55,6 +56,7 @@ public class AddSiteMemberSanityTests extends RestTest testUser.setUserRole(UserRole.SiteConsumer); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); siteAPI.addPerson(siteModel, testUser); + siteAPI.usingRestWrapper().assertLastError().containsSummary("Permission was denied"); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } @@ -66,6 +68,7 @@ public class AddSiteMemberSanityTests extends RestTest testUser.setUserRole(UserRole.SiteConsumer); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); siteAPI.addPerson(siteModel, testUser); + siteAPI.usingRestWrapper().assertLastError().containsSummary("Permission was denied"); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } @@ -77,6 +80,7 @@ public class AddSiteMemberSanityTests extends RestTest testUser.setUserRole(UserRole.SiteConsumer); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); siteAPI.addPerson(siteModel, testUser); + siteAPI.usingRestWrapper().assertLastError().containsSummary("Permission was denied"); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } @@ -87,7 +91,8 @@ public class AddSiteMemberSanityTests extends RestTest UserModel testUser = dataUser.createRandomTestUser("testUser"); testUser.setUserRole(UserRole.SiteConsumer); restClient.authenticateUser(adminUserModel); - siteAPI.addPerson(siteModel, testUser); + siteAPI.addPerson(siteModel, testUser).and().assertField("id").is(testUser.getUsername()) + .and().assertField("role").is(testUser.getUserRole()); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java index 40df95495..91a82cbba 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java @@ -47,7 +47,8 @@ public class GetSiteContainerSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); siteContainerModel = siteAPI.getSiteContainers(siteModel).getOneRandomEntry(); - siteAPI.getSiteContainer(siteModel, siteContainerModel); + siteAPI.getSiteContainer(siteModel, siteContainerModel).and().assertField("id").is(siteContainerModel.onModel().getId()) + .and().assertField("folderId").is(siteContainerModel.onModel().getFolderId()); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -57,7 +58,8 @@ public class GetSiteContainerSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); siteContainerModel = siteAPI.getSiteContainers(siteModel).getOneRandomEntry(); - siteAPI.getSiteContainer(siteModel, siteContainerModel); + siteAPI.getSiteContainer(siteModel, siteContainerModel).and().assertField("id").is(siteContainerModel.onModel().getId()) + .and().assertField("folderId").is(siteContainerModel.onModel().getFolderId()); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -67,7 +69,8 @@ public class GetSiteContainerSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); siteContainerModel = siteAPI.getSiteContainers(siteModel).getOneRandomEntry(); - siteAPI.getSiteContainer(siteModel, siteContainerModel); + siteAPI.getSiteContainer(siteModel, siteContainerModel).and().assertField("id").is(siteContainerModel.onModel().getId()) + .and().assertField("folderId").is(siteContainerModel.onModel().getFolderId()); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -77,7 +80,8 @@ public class GetSiteContainerSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); siteContainerModel = siteAPI.getSiteContainers(siteModel).getOneRandomEntry(); - siteAPI.getSiteContainer(siteModel, siteContainerModel); + siteAPI.getSiteContainer(siteModel, siteContainerModel).and().assertField("id").is(siteContainerModel.onModel().getId()) + .and().assertField("folderId").is(siteContainerModel.onModel().getFolderId()); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -87,7 +91,8 @@ public class GetSiteContainerSanityTests extends RestTest { restClient.authenticateUser(adminUserModel); siteContainerModel = siteAPI.getSiteContainers(siteModel).getOneRandomEntry(); - siteAPI.getSiteContainer(siteModel, siteContainerModel); + siteAPI.getSiteContainer(siteModel, siteContainerModel).and().assertField("id").is(siteContainerModel.onModel().getId()) + .and().assertField("folderId").is(siteContainerModel.onModel().getFolderId()); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java index a34721798..1a10643d7 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java @@ -52,7 +52,7 @@ public class GetSiteContainersSanityTests extends RestTest public void getSiteContainersWithManagerRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - siteAPI.getSiteContainers(siteModel); + siteAPI.getSiteContainers(siteModel).assertEntriesListIsNotEmpty(); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -61,7 +61,7 @@ public class GetSiteContainersSanityTests extends RestTest public void getSiteContainersWithCollaboratorRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - siteAPI.getSiteContainers(siteModel); + siteAPI.getSiteContainers(siteModel).assertEntriesListIsNotEmpty(); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -70,7 +70,7 @@ public class GetSiteContainersSanityTests extends RestTest public void getSiteContainersWithContributorRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - siteAPI.getSiteContainers(siteModel); + siteAPI.getSiteContainers(siteModel).assertEntriesListIsNotEmpty(); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -79,7 +79,7 @@ public class GetSiteContainersSanityTests extends RestTest public void getSiteContainersWithConsumerRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - siteAPI.getSiteContainers(siteModel); + siteAPI.getSiteContainers(siteModel).assertEntriesListIsNotEmpty(); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -88,7 +88,7 @@ public class GetSiteContainersSanityTests extends RestTest public void getSiteContainersWithAdminUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); - siteAPI.getSiteContainers(siteModel); + siteAPI.getSiteContainers(siteModel).assertEntriesListIsNotEmpty(); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java index 802b94c4e..db9fef95d 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java @@ -49,7 +49,8 @@ public class GetSiteMemberSanityTests extends RestTest public void getSiteMemberWithManagerRole() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restSitesApi.getSiteMember(siteModel, userModel); + restSitesApi.getSiteMember(siteModel, userModel).and().assertField("id").is(userModel.getUsername()) + .and().assertField("role").is(userModel.getUserRole()); restSitesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -58,7 +59,8 @@ public class GetSiteMemberSanityTests extends RestTest public void getSiteMemberWithCollaboratorRole() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - restSitesApi.getSiteMember(siteModel, userModel); + restSitesApi.getSiteMember(siteModel, userModel).and().assertField("id").is(userModel.getUsername()) + .and().assertField("role").is(userModel.getUserRole()); restSitesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -67,7 +69,8 @@ public class GetSiteMemberSanityTests extends RestTest public void getSiteMemberWithContributorRole() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - restSitesApi.getSiteMember(siteModel, userModel); + restSitesApi.getSiteMember(siteModel, userModel).and().assertField("id").is(userModel.getUsername()) + .and().assertField("role").is(userModel.getUserRole()); restSitesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -76,7 +79,8 @@ public class GetSiteMemberSanityTests extends RestTest public void getSiteMemberWithConsumerRole() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restSitesApi.getSiteMember(siteModel, userModel); + restSitesApi.getSiteMember(siteModel, userModel).and().assertField("id").is(userModel.getUsername()) + .and().assertField("role").is(userModel.getUserRole()); restSitesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -85,7 +89,8 @@ public class GetSiteMemberSanityTests extends RestTest public void getSiteMemberWithAdminUser() throws Exception { restClient.authenticateUser(adminUser); - restSitesApi.getSiteMember(siteModel, userModel); + restSitesApi.getSiteMember(siteModel, userModel).and().assertField("id").is(userModel.getUsername()) + .and().assertField("role").is(userModel.getUserRole()); restSitesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java index 69fdf1a37..e6d65cf62 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java @@ -53,7 +53,9 @@ public class GetSiteMembersSanityTests extends RestTest public void getSiteMembersWithManagerRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - siteAPI.getSiteMembers(siteModel); + siteAPI.getSiteMembers(siteModel).assertEntriesListIsNotEmpty() + .assertEntriesListContains("id", usersWithRoles.getOneUserWithRole(UserRole.SiteManager).getUsername()) + .assertEntriesListContains("role", usersWithRoles.getOneUserWithRole(UserRole.SiteManager).getUserRole().toString()); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -62,7 +64,9 @@ public class GetSiteMembersSanityTests extends RestTest public void getSiteMembersWithCollaboratorRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - siteAPI.getSiteMembers(siteModel); + siteAPI.getSiteMembers(siteModel).assertEntriesListIsNotEmpty() + .assertEntriesListContains("id", usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator).getUsername()) + .assertEntriesListContains("role", usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator).getUserRole().toString()); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -71,7 +75,9 @@ public class GetSiteMembersSanityTests extends RestTest public void getSiteMembersWithContributorRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - siteAPI.getSiteMembers(siteModel); + siteAPI.getSiteMembers(siteModel).assertEntriesListIsNotEmpty() + .assertEntriesListContains("id", usersWithRoles.getOneUserWithRole(UserRole.SiteContributor).getUsername()) + .assertEntriesListContains("role", usersWithRoles.getOneUserWithRole(UserRole.SiteContributor).getUserRole().toString()); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -80,7 +86,9 @@ public class GetSiteMembersSanityTests extends RestTest public void getSiteMembersWithConsumerRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - siteAPI.getSiteMembers(siteModel); + siteAPI.getSiteMembers(siteModel).assertEntriesListIsNotEmpty() + .assertEntriesListContains("id", usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer).getUsername()) + .assertEntriesListContains("role", usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer).getUserRole().toString()); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -89,7 +97,9 @@ public class GetSiteMembersSanityTests extends RestTest public void getSiteMembersWithAdminUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUser); - siteAPI.getSiteMembers(siteModel); + siteAPI.getSiteMembers(siteModel).assertEntriesListIsNotEmpty() + .assertEntriesListContains("id", adminUser.getUsername()) + .assertEntriesListContains("role", adminUser.getUserRole().toString()); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteSanityTests.java index e5f117f17..c41ba9a2a 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteSanityTests.java @@ -47,7 +47,7 @@ public class GetSiteSanityTests extends RestTest restClient.authenticateUser(adminUserModel); siteAPI.useRestClient(restClient); siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); } @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, @@ -55,7 +55,8 @@ public class GetSiteSanityTests extends RestTest public void getSiteWithManagerRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - siteAPI.getSite(siteModel); + siteAPI.getSite(siteModel).and().assertField("id").is(siteModel.getId()) + .and().assertField("title").is(siteModel.getTitle()); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -64,7 +65,8 @@ public class GetSiteSanityTests extends RestTest public void getSiteWithCollaboratorRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - siteAPI.getSite(siteModel); + siteAPI.getSite(siteModel).and().assertField("id").is(siteModel.getId()) + .and().assertField("title").is(siteModel.getTitle()); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -73,7 +75,8 @@ public class GetSiteSanityTests extends RestTest public void getSiteWithContributorRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - siteAPI.getSite(siteModel); + siteAPI.getSite(siteModel).and().assertField("id").is(siteModel.getId()) + .and().assertField("title").is(siteModel.getTitle()); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -82,7 +85,8 @@ public class GetSiteSanityTests extends RestTest public void getSiteWithConsumerRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - siteAPI.getSite(siteModel); + siteAPI.getSite(siteModel).and().assertField("id").is(siteModel.getId()) + .and().assertField("title").is(siteModel.getTitle()); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -91,7 +95,8 @@ public class GetSiteSanityTests extends RestTest public void getSiteWithAdminRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); - siteAPI.getSite(siteModel); + siteAPI.getSite(siteModel).and().assertField("id").is(siteModel.getId()) + .and().assertField("title").is(siteModel.getTitle()); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java index 21d5e6d22..b1284661b 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java @@ -53,7 +53,7 @@ public class GetSitesSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - siteAPI.getAllSites(); + siteAPI.getAllSites().assertEntriesListIsNotEmpty(); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -63,7 +63,7 @@ public class GetSitesSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - siteAPI.getAllSites(); + siteAPI.getAllSites().assertEntriesListIsNotEmpty(); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -73,7 +73,7 @@ public class GetSitesSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - siteAPI.getAllSites(); + siteAPI.getAllSites().assertEntriesListIsNotEmpty(); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -83,7 +83,7 @@ public class GetSitesSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - siteAPI.getAllSites(); + siteAPI.getAllSites().assertEntriesListIsNotEmpty(); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -92,7 +92,7 @@ public class GetSitesSanityTests extends RestTest public void adminUserIsAbleToRetrieveSites() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); - siteAPI.getAllSites(); + siteAPI.getAllSites().assertEntriesListIsNotEmpty(); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } diff --git a/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java index be6cb7a3c..7832bc778 100644 --- a/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java @@ -57,6 +57,8 @@ public class RemoveSiteMemberSanityTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); restSitesAPI.deleteSiteMember(siteModel, testUserModel); restSitesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); + restSitesAPI.getAllSites().assertEntriesListDoesNotContain("id", testUserModel.getUsername()); + restSitesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @Bug(id="ACE-5444") @@ -66,6 +68,8 @@ public class RemoveSiteMemberSanityTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); restSitesAPI.deleteSiteMember(siteModel, testUserModel); restSitesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + restSitesAPI.getAllSites().assertEntriesListContains("id", testUserModel.getUsername()); + restSitesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @Bug(id="ACE-5444") @@ -75,6 +79,8 @@ public class RemoveSiteMemberSanityTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); restSitesAPI.deleteSiteMember(siteModel, testUserModel); restSitesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + restSitesAPI.getAllSites().assertEntriesListContains("id", testUserModel.getUsername()); + restSitesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @Bug(id="ACE-5444") @@ -84,6 +90,8 @@ public class RemoveSiteMemberSanityTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); restSitesAPI.deleteSiteMember(siteModel, testUserModel); restSitesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + restSitesAPI.getAllSites().assertEntriesListContains("id", testUserModel.getUsername()); + restSitesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, @@ -92,6 +100,8 @@ public class RemoveSiteMemberSanityTests extends RestTest restClient.authenticateUser(adminUserModel); restSitesAPI.deleteSiteMember(siteModel, testUserModel); restSitesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); + restSitesAPI.getAllSites().assertEntriesListDoesNotContain("id", testUserModel.getUsername()); + restSitesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, diff --git a/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java index fe481b0d5..473364777 100644 --- a/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java @@ -44,7 +44,8 @@ public class UpdateSiteMemberSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); testUserModel.setUserRole(UserRole.SiteConsumer); - siteAPI.updateSiteMember(siteModel, testUserModel); + siteAPI.updateSiteMember(siteModel, testUserModel).and().assertField("id").is(testUserModel.getUsername()) + .and().assertField("role").is(testUserModel.getUserRole()); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -56,6 +57,8 @@ public class UpdateSiteMemberSanityTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); testUserModel.setUserRole(UserRole.SiteCollaborator); siteAPI.updateSiteMember(siteModel, testUserModel); + siteAPI.usingRestWrapper().assertLastError() + .containsSummary(String.format("The current user does not have permissions to modify the membership details of the site %s.", siteModel.getTitle())); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } @@ -67,6 +70,8 @@ public class UpdateSiteMemberSanityTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); testUserModel.setUserRole(UserRole.SiteCollaborator); siteAPI.updateSiteMember(siteModel, testUserModel); + siteAPI.usingRestWrapper().assertLastError() + .containsSummary(String.format("The current user does not have permissions to modify the membership details of the site %s.", siteModel.getTitle())); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } @@ -78,6 +83,8 @@ public class UpdateSiteMemberSanityTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); testUserModel.setUserRole(UserRole.SiteCollaborator); siteAPI.updateSiteMember(siteModel, testUserModel); + siteAPI.usingRestWrapper().assertLastError() + .containsSummary(String.format("The current user does not have permissions to modify the membership details of the site %s.", siteModel.getTitle())); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); } @@ -87,7 +94,8 @@ public class UpdateSiteMemberSanityTests extends RestTest { restClient.authenticateUser(adminUserModel); testUserModel.setUserRole(UserRole.SiteCollaborator); - siteAPI.updateSiteMember(siteModel, testUserModel); + siteAPI.updateSiteMember(siteModel, testUserModel).and().assertField("id").is(testUserModel.getUsername()) + .and().assertField("role").is(testUserModel.getUserRole()); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } From 95acd92cb16a18b2c497193aac7b234b813f176d Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Tue, 25 Oct 2016 15:04:43 +0300 Subject: [PATCH 0496/1491] no message --- .../rest/sites/AddSiteMemberSanityTests.java | 10 ++++--- .../sites/GetSiteContainerSanityTests.java | 25 +++++++++------- .../sites/GetSiteContainersSanityTests.java | 10 +++---- .../rest/sites/GetSiteMemberSanityTests.java | 24 ++++++++------- .../rest/sites/GetSiteMembersSanityTests.java | 30 +++++++++---------- .../rest/sites/GetSiteSanityTests.java | 25 +++++++++------- .../rest/sites/GetSitesSanityTests.java | 10 +++---- .../sites/RemoveSiteMemberSanityTests.java | 10 +++---- .../sites/UpdateSiteMemberSanityTests.java | 10 ++++--- 9 files changed, 86 insertions(+), 68 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java index 1116874b7..4e8f17d29 100644 --- a/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java @@ -43,8 +43,9 @@ public class AddSiteMemberSanityTests extends RestTest UserModel testUser = dataUser.createRandomTestUser("testUser"); testUser.setUserRole(UserRole.SiteConsumer); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - siteAPI.addPerson(siteModel, testUser).and().assertField("id").is(testUser.getUsername()) - .and().assertField("role").is(testUser.getUserRole()); + siteAPI.addPerson(siteModel, testUser) + .assertThat().field("id").is(testUser.getUsername()) + .and().field("role").is(testUser.getUserRole()); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } @@ -91,8 +92,9 @@ public class AddSiteMemberSanityTests extends RestTest UserModel testUser = dataUser.createRandomTestUser("testUser"); testUser.setUserRole(UserRole.SiteConsumer); restClient.authenticateUser(adminUserModel); - siteAPI.addPerson(siteModel, testUser).and().assertField("id").is(testUser.getUsername()) - .and().assertField("role").is(testUser.getUserRole()); + siteAPI.addPerson(siteModel, testUser) + .and().field("id").is(testUser.getUsername()) + .and().field("role").is(testUser.getUserRole()); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java index 91a82cbba..eec7359c2 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java @@ -47,8 +47,9 @@ public class GetSiteContainerSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); siteContainerModel = siteAPI.getSiteContainers(siteModel).getOneRandomEntry(); - siteAPI.getSiteContainer(siteModel, siteContainerModel).and().assertField("id").is(siteContainerModel.onModel().getId()) - .and().assertField("folderId").is(siteContainerModel.onModel().getFolderId()); + siteAPI.getSiteContainer(siteModel, siteContainerModel) + .assertThat().field("id").is(siteContainerModel.onModel().getId()) + .and().field("folderId").is(siteContainerModel.onModel().getFolderId()); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -58,8 +59,9 @@ public class GetSiteContainerSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); siteContainerModel = siteAPI.getSiteContainers(siteModel).getOneRandomEntry(); - siteAPI.getSiteContainer(siteModel, siteContainerModel).and().assertField("id").is(siteContainerModel.onModel().getId()) - .and().assertField("folderId").is(siteContainerModel.onModel().getFolderId()); + siteAPI.getSiteContainer(siteModel, siteContainerModel) + .and().field("id").is(siteContainerModel.onModel().getId()) + .and().field("folderId").is(siteContainerModel.onModel().getFolderId()); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -69,8 +71,9 @@ public class GetSiteContainerSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); siteContainerModel = siteAPI.getSiteContainers(siteModel).getOneRandomEntry(); - siteAPI.getSiteContainer(siteModel, siteContainerModel).and().assertField("id").is(siteContainerModel.onModel().getId()) - .and().assertField("folderId").is(siteContainerModel.onModel().getFolderId()); + siteAPI.getSiteContainer(siteModel, siteContainerModel) + .assertThat().field("id").is(siteContainerModel.onModel().getId()) + .and().field("folderId").is(siteContainerModel.onModel().getFolderId()); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -80,8 +83,9 @@ public class GetSiteContainerSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); siteContainerModel = siteAPI.getSiteContainers(siteModel).getOneRandomEntry(); - siteAPI.getSiteContainer(siteModel, siteContainerModel).and().assertField("id").is(siteContainerModel.onModel().getId()) - .and().assertField("folderId").is(siteContainerModel.onModel().getFolderId()); + siteAPI.getSiteContainer(siteModel, siteContainerModel) + .assertThat().field("id").is(siteContainerModel.onModel().getId()) + .and().field("folderId").is(siteContainerModel.onModel().getFolderId()); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -91,8 +95,9 @@ public class GetSiteContainerSanityTests extends RestTest { restClient.authenticateUser(adminUserModel); siteContainerModel = siteAPI.getSiteContainers(siteModel).getOneRandomEntry(); - siteAPI.getSiteContainer(siteModel, siteContainerModel).and().assertField("id").is(siteContainerModel.onModel().getId()) - .and().assertField("folderId").is(siteContainerModel.onModel().getFolderId()); + siteAPI.getSiteContainer(siteModel, siteContainerModel) + .assertThat().field("id").is(siteContainerModel.onModel().getId()) + .and().field("folderId").is(siteContainerModel.onModel().getFolderId()); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java index 1a10643d7..71182c06d 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java @@ -52,7 +52,7 @@ public class GetSiteContainersSanityTests extends RestTest public void getSiteContainersWithManagerRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - siteAPI.getSiteContainers(siteModel).assertEntriesListIsNotEmpty(); + siteAPI.getSiteContainers(siteModel).assertThat().entriesListIsNotEmpty(); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -61,7 +61,7 @@ public class GetSiteContainersSanityTests extends RestTest public void getSiteContainersWithCollaboratorRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - siteAPI.getSiteContainers(siteModel).assertEntriesListIsNotEmpty(); + siteAPI.getSiteContainers(siteModel).assertThat().entriesListIsNotEmpty(); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -70,7 +70,7 @@ public class GetSiteContainersSanityTests extends RestTest public void getSiteContainersWithContributorRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - siteAPI.getSiteContainers(siteModel).assertEntriesListIsNotEmpty(); + siteAPI.getSiteContainers(siteModel).assertThat().entriesListIsNotEmpty(); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -79,7 +79,7 @@ public class GetSiteContainersSanityTests extends RestTest public void getSiteContainersWithConsumerRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - siteAPI.getSiteContainers(siteModel).assertEntriesListIsNotEmpty(); + siteAPI.getSiteContainers(siteModel).assertThat().entriesListIsNotEmpty(); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -88,7 +88,7 @@ public class GetSiteContainersSanityTests extends RestTest public void getSiteContainersWithAdminUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); - siteAPI.getSiteContainers(siteModel).assertEntriesListIsNotEmpty(); + siteAPI.getSiteContainers(siteModel).assertThat().entriesListIsNotEmpty(); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java index db9fef95d..8a6a1d60d 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java @@ -49,8 +49,9 @@ public class GetSiteMemberSanityTests extends RestTest public void getSiteMemberWithManagerRole() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restSitesApi.getSiteMember(siteModel, userModel).and().assertField("id").is(userModel.getUsername()) - .and().assertField("role").is(userModel.getUserRole()); + restSitesApi.getSiteMember(siteModel, userModel) + .assertThat().field("id").is(userModel.getUsername()) + .and().field("role").is(userModel.getUserRole()); restSitesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -59,8 +60,9 @@ public class GetSiteMemberSanityTests extends RestTest public void getSiteMemberWithCollaboratorRole() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - restSitesApi.getSiteMember(siteModel, userModel).and().assertField("id").is(userModel.getUsername()) - .and().assertField("role").is(userModel.getUserRole()); + restSitesApi.getSiteMember(siteModel, userModel) + .and().field("id").is(userModel.getUsername()) + .and().field("role").is(userModel.getUserRole()); restSitesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -69,8 +71,8 @@ public class GetSiteMemberSanityTests extends RestTest public void getSiteMemberWithContributorRole() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - restSitesApi.getSiteMember(siteModel, userModel).and().assertField("id").is(userModel.getUsername()) - .and().assertField("role").is(userModel.getUserRole()); + restSitesApi.getSiteMember(siteModel, userModel).and().field("id").is(userModel.getUsername()) + .and().field("role").is(userModel.getUserRole()); restSitesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -79,8 +81,9 @@ public class GetSiteMemberSanityTests extends RestTest public void getSiteMemberWithConsumerRole() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restSitesApi.getSiteMember(siteModel, userModel).and().assertField("id").is(userModel.getUsername()) - .and().assertField("role").is(userModel.getUserRole()); + restSitesApi.getSiteMember(siteModel, userModel) + .and().field("id").is(userModel.getUsername()) + .and().field("role").is(userModel.getUserRole()); restSitesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -89,8 +92,9 @@ public class GetSiteMemberSanityTests extends RestTest public void getSiteMemberWithAdminUser() throws Exception { restClient.authenticateUser(adminUser); - restSitesApi.getSiteMember(siteModel, userModel).and().assertField("id").is(userModel.getUsername()) - .and().assertField("role").is(userModel.getUserRole()); + restSitesApi.getSiteMember(siteModel, userModel) + .and().field("id").is(userModel.getUsername()) + .and().field("role").is(userModel.getUserRole()); restSitesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java index e6d65cf62..1e69878a6 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java @@ -53,9 +53,9 @@ public class GetSiteMembersSanityTests extends RestTest public void getSiteMembersWithManagerRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - siteAPI.getSiteMembers(siteModel).assertEntriesListIsNotEmpty() - .assertEntriesListContains("id", usersWithRoles.getOneUserWithRole(UserRole.SiteManager).getUsername()) - .assertEntriesListContains("role", usersWithRoles.getOneUserWithRole(UserRole.SiteManager).getUserRole().toString()); + siteAPI.getSiteMembers(siteModel).assertThat().entriesListIsNotEmpty() + .and().entriesListContains("id", usersWithRoles.getOneUserWithRole(UserRole.SiteManager).getUsername()) + .and().entriesListContains("role", usersWithRoles.getOneUserWithRole(UserRole.SiteManager).getUserRole().toString()); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -64,9 +64,9 @@ public class GetSiteMembersSanityTests extends RestTest public void getSiteMembersWithCollaboratorRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - siteAPI.getSiteMembers(siteModel).assertEntriesListIsNotEmpty() - .assertEntriesListContains("id", usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator).getUsername()) - .assertEntriesListContains("role", usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator).getUserRole().toString()); + siteAPI.getSiteMembers(siteModel).assertThat().entriesListIsNotEmpty().assertThat() + .entriesListContains("id", usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator).getUsername()).and() + .entriesListContains("role", usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator).getUserRole().toString()); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -75,9 +75,9 @@ public class GetSiteMembersSanityTests extends RestTest public void getSiteMembersWithContributorRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - siteAPI.getSiteMembers(siteModel).assertEntriesListIsNotEmpty() - .assertEntriesListContains("id", usersWithRoles.getOneUserWithRole(UserRole.SiteContributor).getUsername()) - .assertEntriesListContains("role", usersWithRoles.getOneUserWithRole(UserRole.SiteContributor).getUserRole().toString()); + siteAPI.getSiteMembers(siteModel).assertThat().entriesListIsNotEmpty() + .and().entriesListContains("id", usersWithRoles.getOneUserWithRole(UserRole.SiteContributor).getUsername()) + .and().entriesListContains("role", usersWithRoles.getOneUserWithRole(UserRole.SiteContributor).getUserRole().toString()); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -86,9 +86,9 @@ public class GetSiteMembersSanityTests extends RestTest public void getSiteMembersWithConsumerRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - siteAPI.getSiteMembers(siteModel).assertEntriesListIsNotEmpty() - .assertEntriesListContains("id", usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer).getUsername()) - .assertEntriesListContains("role", usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer).getUserRole().toString()); + siteAPI.getSiteMembers(siteModel).assertThat().entriesListIsNotEmpty() + .and().entriesListContains("id", usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer).getUsername()) + .and().entriesListContains("role", usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer).getUserRole().toString()); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -97,9 +97,9 @@ public class GetSiteMembersSanityTests extends RestTest public void getSiteMembersWithAdminUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUser); - siteAPI.getSiteMembers(siteModel).assertEntriesListIsNotEmpty() - .assertEntriesListContains("id", adminUser.getUsername()) - .assertEntriesListContains("role", adminUser.getUserRole().toString()); + siteAPI.getSiteMembers(siteModel).assertThat().entriesListIsNotEmpty() + .and().entriesListContains("id", adminUser.getUsername()) + .when().assertThat().entriesListContains("role", "SiteManager"); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteSanityTests.java index c41ba9a2a..08f8d45db 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteSanityTests.java @@ -55,8 +55,9 @@ public class GetSiteSanityTests extends RestTest public void getSiteWithManagerRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - siteAPI.getSite(siteModel).and().assertField("id").is(siteModel.getId()) - .and().assertField("title").is(siteModel.getTitle()); + siteAPI.getSite(siteModel) + .and().field("id").is(siteModel.getId()) + .and().field("title").is(siteModel.getTitle()); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -65,8 +66,9 @@ public class GetSiteSanityTests extends RestTest public void getSiteWithCollaboratorRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - siteAPI.getSite(siteModel).and().assertField("id").is(siteModel.getId()) - .and().assertField("title").is(siteModel.getTitle()); + siteAPI.getSite(siteModel) + .and().field("id").is(siteModel.getId()) + .and().field("title").is(siteModel.getTitle()); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -75,8 +77,9 @@ public class GetSiteSanityTests extends RestTest public void getSiteWithContributorRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - siteAPI.getSite(siteModel).and().assertField("id").is(siteModel.getId()) - .and().assertField("title").is(siteModel.getTitle()); + siteAPI.getSite(siteModel) + .and().field("id").is(siteModel.getId()) + .and().field("title").is(siteModel.getTitle()); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -85,8 +88,9 @@ public class GetSiteSanityTests extends RestTest public void getSiteWithConsumerRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - siteAPI.getSite(siteModel).and().assertField("id").is(siteModel.getId()) - .and().assertField("title").is(siteModel.getTitle()); + siteAPI.getSite(siteModel) + .and().field("id").is(siteModel.getId()) + .and().field("title").is(siteModel.getTitle()); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -95,8 +99,9 @@ public class GetSiteSanityTests extends RestTest public void getSiteWithAdminRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); - siteAPI.getSite(siteModel).and().assertField("id").is(siteModel.getId()) - .and().assertField("title").is(siteModel.getTitle()); + siteAPI.getSite(siteModel) + .and().field("id").is(siteModel.getId()) + .and().field("title").is(siteModel.getTitle()); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java index b1284661b..e5256ff0f 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java @@ -53,7 +53,7 @@ public class GetSitesSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - siteAPI.getAllSites().assertEntriesListIsNotEmpty(); + siteAPI.getAllSites().assertThat().entriesListIsNotEmpty(); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -63,7 +63,7 @@ public class GetSitesSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - siteAPI.getAllSites().assertEntriesListIsNotEmpty(); + siteAPI.getAllSites().assertThat().entriesListIsNotEmpty(); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -73,7 +73,7 @@ public class GetSitesSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - siteAPI.getAllSites().assertEntriesListIsNotEmpty(); + siteAPI.getAllSites().assertThat().entriesListIsNotEmpty(); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -83,7 +83,7 @@ public class GetSitesSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - siteAPI.getAllSites().assertEntriesListIsNotEmpty(); + siteAPI.getAllSites().assertThat().entriesListIsNotEmpty(); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -92,7 +92,7 @@ public class GetSitesSanityTests extends RestTest public void adminUserIsAbleToRetrieveSites() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); - siteAPI.getAllSites().assertEntriesListIsNotEmpty(); + siteAPI.getAllSites().assertThat().entriesListIsNotEmpty(); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } diff --git a/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java index 7832bc778..6a2c1f07d 100644 --- a/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java @@ -57,7 +57,7 @@ public class RemoveSiteMemberSanityTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); restSitesAPI.deleteSiteMember(siteModel, testUserModel); restSitesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); - restSitesAPI.getAllSites().assertEntriesListDoesNotContain("id", testUserModel.getUsername()); + restSitesAPI.getAllSites().assertThat().entriesListDoesNotContain("id", testUserModel.getUsername()); restSitesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -68,7 +68,7 @@ public class RemoveSiteMemberSanityTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); restSitesAPI.deleteSiteMember(siteModel, testUserModel); restSitesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); - restSitesAPI.getAllSites().assertEntriesListContains("id", testUserModel.getUsername()); + restSitesAPI.getAllSites().assertThat().entriesListContains("id", testUserModel.getUsername()); restSitesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -79,7 +79,7 @@ public class RemoveSiteMemberSanityTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); restSitesAPI.deleteSiteMember(siteModel, testUserModel); restSitesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); - restSitesAPI.getAllSites().assertEntriesListContains("id", testUserModel.getUsername()); + restSitesAPI.getAllSites().assertThat().entriesListContains("id", testUserModel.getUsername()); restSitesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -90,7 +90,7 @@ public class RemoveSiteMemberSanityTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); restSitesAPI.deleteSiteMember(siteModel, testUserModel); restSitesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); - restSitesAPI.getAllSites().assertEntriesListContains("id", testUserModel.getUsername()); + restSitesAPI.getAllSites().assertThat().entriesListContains("id", testUserModel.getUsername()); restSitesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -100,7 +100,7 @@ public class RemoveSiteMemberSanityTests extends RestTest restClient.authenticateUser(adminUserModel); restSitesAPI.deleteSiteMember(siteModel, testUserModel); restSitesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); - restSitesAPI.getAllSites().assertEntriesListDoesNotContain("id", testUserModel.getUsername()); + restSitesAPI.getAllSites().assertThat().entriesListDoesNotContain("id", testUserModel.getUsername()); restSitesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } diff --git a/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java index 473364777..02bc56501 100644 --- a/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java @@ -44,8 +44,9 @@ public class UpdateSiteMemberSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); testUserModel.setUserRole(UserRole.SiteConsumer); - siteAPI.updateSiteMember(siteModel, testUserModel).and().assertField("id").is(testUserModel.getUsername()) - .and().assertField("role").is(testUserModel.getUserRole()); + siteAPI.updateSiteMember(siteModel, testUserModel) + .assertThat().field("id").is(testUserModel.getUsername()) + .and().field("role").is(testUserModel.getUserRole()); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -94,8 +95,9 @@ public class UpdateSiteMemberSanityTests extends RestTest { restClient.authenticateUser(adminUserModel); testUserModel.setUserRole(UserRole.SiteCollaborator); - siteAPI.updateSiteMember(siteModel, testUserModel).and().assertField("id").is(testUserModel.getUsername()) - .and().assertField("role").is(testUserModel.getUserRole()); + siteAPI.updateSiteMember(siteModel, testUserModel) + .assertThat().field("id").is(testUserModel.getUsername()) + .and().field("role").is(testUserModel.getUserRole()); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } From 1f41e666b0ba5ca257cabcf61392e9458f5d9514 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Tue, 25 Oct 2016 15:27:18 +0300 Subject: [PATCH 0497/1491] Add missing tests for Get Ratings call --- .../rest/ratings/GetRatingsSanityTests.java | 150 ++++++++++++++++++ 1 file changed, 150 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/ratings/GetRatingsSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/ratings/GetRatingsSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/GetRatingsSanityTests.java new file mode 100644 index 000000000..bbe5c1cc9 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/ratings/GetRatingsSanityTests.java @@ -0,0 +1,150 @@ +package org.alfresco.rest.ratings; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.requests.RestRatingsApi; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.exception.DataPreparationException; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) +public class GetRatingsSanityTests extends RestTest +{ + @Autowired + RestRatingsApi ratingsApi; + + private SiteModel siteModel; + private UserModel adminUser; + private FolderModel folderModel; + private FileModel document; + private ListUserWithRoles usersWithRoles; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws DataPreparationException + { + adminUser = dataUser.getAdminUser(); + siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); + + ratingsApi.useRestClient(restClient); + + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, + UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + } + + @BeforeMethod() + public void setUp() throws DataPreparationException, Exception { + folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, + description = "Manager is able to retrieve document ratings") + public void managerIsAbleToRetrieveDocumentRatings() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + + ratingsApi.likeDocument(document); + ratingsApi.rateStarsToDocument(document, 5); + + ratingsApi.getRatings(document) + .assertNodeHasFiveStarRating() + .assertNodeIsLiked(); + ratingsApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, + description = "Collaborator is able to retrieve document ratings") + public void collaboratorIsAbleToRetrieveDocumentRatings() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + + ratingsApi.likeDocument(document); + ratingsApi.rateStarsToDocument(document, 5); + + ratingsApi.getRatings(document) + .assertNodeHasFiveStarRating() + .assertNodeIsLiked(); + ratingsApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, + description = "Contributor is able to retrieve document ratings") + public void contributorIsAbleToRetrieveDocumentRatings() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + + ratingsApi.likeDocument(document); + ratingsApi.rateStarsToDocument(document, 5); + + ratingsApi.getRatings(document) + .assertNodeHasFiveStarRating() + .assertNodeIsLiked(); + ratingsApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, + description = "Consumer is able to retrieve document ratings") + public void consumerIsAbleToRetrieveDocumentRatings() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + + ratingsApi.likeDocument(document); + ratingsApi.rateStarsToDocument(document, 5); + + ratingsApi.getRatings(document) + .assertNodeHasFiveStarRating() + .assertNodeIsLiked(); + ratingsApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, + description = "Admin user is able to retrieve document ratings") + public void adminIsAbleToRetrieveDocumentRatings() throws Exception + { + document = dataContent.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) + .usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(adminUser); + ratingsApi.likeDocument(document); + ratingsApi.rateStarsToDocument(document, 5); + + ratingsApi.getRatings(document) + .assertNodeHasFiveStarRating() + .assertNodeIsLiked(); + ratingsApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, + description = "Verify unauthenticated user is not able to retrieve document ratings") + @Bug(id = "MNT-16904") + public void unauthenticatedUserIsNotAbleToRetrieveRatings() throws Exception + { + restClient.authenticateUser(adminUser); + ratingsApi.likeDocument(document); + ratingsApi.rateStarsToDocument(document, 5); + + restClient.authenticateUser(new UserModel("random user", "random password")); + + ratingsApi.getRatings(document); + ratingsApi.usingRestWrapper() + .assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + } +} \ No newline at end of file From 0e9be83d422669f4269e829d82963a0be7c47757 Mon Sep 17 00:00:00 2001 From: cagache Date: Tue, 25 Oct 2016 16:27:20 +0300 Subject: [PATCH 0498/1491] fixed tests --- .../alfresco/rest/tags/AddTagSanityTests.java | 19 ++++++------------- .../rest/tags/AddTagsSanityTests.java | 16 ++++++++-------- 2 files changed, 14 insertions(+), 21 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java index 5dbf45ed4..ae1dbc646 100644 --- a/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java @@ -7,10 +7,7 @@ import org.alfresco.rest.requests.RestTagsApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.model.*; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; @@ -62,7 +59,7 @@ public class AddTagSanityTests extends RestTest { restClient.authenticateUser(adminUserModel); tagsAPI.addTag(document, tagValue) - .assertThat().field("tag").is("tagValue") + .assertThat().field("tag").is(tagValue) .and().field("id").isNotEmpty(); tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); @@ -95,10 +92,8 @@ public class AddTagSanityTests extends RestTest public void contributorIsNotAbleToAddTagToAnotherContent() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - tagsAPI.addTag(document, tagValue) - .assertThat().field("id").isNotEmpty() - .and().field("tag").is(tagValue); - tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + tagsAPI.addTag(document, tagValue); + tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, @@ -119,10 +114,8 @@ public class AddTagSanityTests extends RestTest public void consumerIsNotAbleToAddTag() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - tagsAPI.addTag(document, tagValue) - .assertThat().field("id").isNotEmpty() - .and().field("tag").is(tagValue); - tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + tagsAPI.addTag(document, tagValue); + tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, diff --git a/e2e-test/java/org/alfresco/rest/tags/AddTagsSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/AddTagsSanityTests.java index 5f8b58ea0..52d40f950 100644 --- a/e2e-test/java/org/alfresco/rest/tags/AddTagsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/AddTagsSanityTests.java @@ -63,8 +63,8 @@ public class AddTagsSanityTests extends RestTest { restClient.authenticateUser(adminUserModel); tagsAPI.addTags(document, tag1, tag2) - .assertThat().entriesListContains("tag", tag1.toLowerCase()) - .and().entriesListContains("tag", tag2.toLowerCase()); + .assertThat().entriesListContains("tag", tag1) + .and().entriesListContains("tag", tag2); tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } @@ -75,8 +75,8 @@ public class AddTagsSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); tagsAPI.addTags(document, tag1, tag2) - .assertThat().entriesListContains("tag", tag1.toLowerCase()) - .and().entriesListContains("tag", tag2.toLowerCase()); + .assertThat().entriesListContains("tag", tag1) + .and().entriesListContains("tag", tag2); tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } @@ -87,8 +87,8 @@ public class AddTagsSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); tagsAPI.addTags(document, tag1, tag2) - .assertThat().entriesListContains("tag", tag1.toLowerCase()) - .and().entriesListContains("tag", tag2.toLowerCase()); + .assertThat().entriesListContains("tag", tag1) + .and().entriesListContains("tag", tag2); tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } @@ -110,8 +110,8 @@ public class AddTagsSanityTests extends RestTest restClient.authenticateUser(userModel); contributorDoc = dataContent.usingSite(siteModel).usingUser(userModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); tagsAPI.addTags(contributorDoc, tag1, tag2) - .assertThat().entriesListContains("tag", tag1.toLowerCase()) - .and().entriesListContains("tag", tag2.toLowerCase()); + .assertThat().entriesListContains("tag", tag1) + .and().entriesListContains("tag", tag2); tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } From ea37f2af34126e2a4997417ef61b415171968a14 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Tue, 25 Oct 2016 18:38:26 +0300 Subject: [PATCH 0499/1491] Fix on UpdateComments and updates assertion on people calls --- .../rest/comments/AddCommentsSanityTests.java | 2 +- .../comments/UpdateCommentsSanityTests.java | 5 ++-- .../people/AddFavoriteSiteSanityTests.java | 17 ++++++++----- .../AddSiteMembershipRequestSanityTests.java | 24 ++++++++++++++----- .../people/DeleteFavoriteSiteSanityTests.java | 4 +++- .../people/DeleteSiteMemberSanityTests.java | 10 +++++--- ...eleteSiteMembershipRequestSanityTests.java | 13 ++++++---- 7 files changed, 52 insertions(+), 23 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java index e1ea52724..12ade18c3 100644 --- a/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java @@ -112,7 +112,7 @@ public class AddCommentsSanityTests extends RestTest commentsAPI.addComments(document, comment1, comment2); commentsAPI.usingRestWrapper() .assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED);; + .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, diff --git a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java index a1e5b8ccf..4b8a64cd4 100644 --- a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java @@ -137,11 +137,12 @@ public class UpdateCommentsSanityTests extends RestTest restClient.authenticateUser(adminUserModel); RestCommentModel comment = new RestCommentModel(); - comment.setId("comment id that does not exist"); + String id = "comment id that does not exist"; + comment.setId(id); commentsAPI.updateComment(document, comment, "This is the updated comment."); commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary("node ref that does not exist was not found"); + .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, id)); } } diff --git a/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteSanityTests.java index 4393d918f..66c393a1a 100644 --- a/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteSanityTests.java @@ -40,12 +40,13 @@ public class AddFavoriteSiteSanityTests extends RestTest dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); restClient.authenticateUser(managerUser); - peopleApi.addFavoriteSite(managerUser, siteModel); + peopleApi.addFavoriteSite(managerUser, siteModel) + .assertThat().field("id").is(siteModel.getId()); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); peopleApi.addFavoriteSite(managerUser, siteModel); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CONFLICT); - peopleApi.usingRestWrapper().assertLastError().containsSummary("is already a favourite site"); + peopleApi.usingRestWrapper().assertLastError().containsSummary(String.format("%s is already a favourite site", siteModel.getId())); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify collaborator user add a favorite site with Rest API and response is successful (201)") @@ -55,7 +56,8 @@ public class AddFavoriteSiteSanityTests extends RestTest dataUser.usingUser(userModel).addUserToSite(collaboratorUser, siteModel, UserRole.SiteCollaborator); restClient.authenticateUser(collaboratorUser); - peopleApi.addFavoriteSite(collaboratorUser, siteModel); + peopleApi.addFavoriteSite(collaboratorUser, siteModel) + .assertThat().field("id").is(siteModel.getId()); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } @@ -66,7 +68,8 @@ public class AddFavoriteSiteSanityTests extends RestTest dataUser.usingUser(userModel).addUserToSite(contributorUser, siteModel, UserRole.SiteContributor); restClient.authenticateUser(contributorUser); - peopleApi.addFavoriteSite(contributorUser, siteModel); + peopleApi.addFavoriteSite(contributorUser, siteModel) + .assertThat().field("id").is(siteModel.getId()); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } @@ -77,7 +80,8 @@ public class AddFavoriteSiteSanityTests extends RestTest dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel, UserRole.SiteConsumer); restClient.authenticateUser(consumerUser); - peopleApi.addFavoriteSite(consumerUser, siteModel); + peopleApi.addFavoriteSite(consumerUser, siteModel) + .assertThat().field("id").is(siteModel.getId()); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } @@ -87,7 +91,8 @@ public class AddFavoriteSiteSanityTests extends RestTest UserModel adminUser = dataUser.getAdminUser(); restClient.authenticateUser(adminUser); - peopleApi.addFavoriteSite(adminUser, siteModel); + peopleApi.addFavoriteSite(adminUser, siteModel) + .assertThat().field("id").is(siteModel.getId()); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } diff --git a/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java index fedfa10d7..47188c0fc 100644 --- a/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java @@ -54,7 +54,9 @@ public class AddSiteMembershipRequestSanityTests extends RestTest { UserModel newMember = dataUser.createRandomTestUser(); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - peopleApi.addSiteMembershipRequest(newMember, siteModel); + peopleApi.addSiteMembershipRequest(newMember, siteModel) + .assertThat().field("id").isNotEmpty() + .assertThat().field("title").is(siteModel.getTitle()); peopleApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.CREATED); } @@ -66,7 +68,9 @@ public class AddSiteMembershipRequestSanityTests extends RestTest { UserModel newMember = dataUser.createRandomTestUser(); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - peopleApi.addSiteMembershipRequest(newMember, siteModel); + peopleApi.addSiteMembershipRequest(newMember, siteModel) + .assertThat().field("id").isNotEmpty() + .assertThat().field("title").is(siteModel.getTitle()); peopleApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.CREATED); } @@ -78,7 +82,9 @@ public class AddSiteMembershipRequestSanityTests extends RestTest { UserModel newMember = dataUser.createRandomTestUser(); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - peopleApi.addSiteMembershipRequest(newMember, siteModel); + peopleApi.addSiteMembershipRequest(newMember, siteModel) + .assertThat().field("id").isNotEmpty() + .assertThat().field("title").is(siteModel.getTitle()); peopleApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.CREATED); } @@ -90,7 +96,9 @@ public class AddSiteMembershipRequestSanityTests extends RestTest { UserModel newMember = dataUser.createRandomTestUser(); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - peopleApi.addSiteMembershipRequest(newMember, siteModel); + peopleApi.addSiteMembershipRequest(newMember, siteModel) + .assertThat().field("id").isNotEmpty() + .assertThat().field("title").is(siteModel.getTitle()); peopleApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.CREATED); } @@ -102,7 +110,9 @@ public class AddSiteMembershipRequestSanityTests extends RestTest { UserModel newMember = dataUser.createRandomTestUser(); restClient.authenticateUser(adminUser); - peopleApi.addSiteMembershipRequest(newMember, siteModel); + peopleApi.addSiteMembershipRequest(newMember, siteModel) + .assertThat().field("id").isNotEmpty() + .assertThat().field("title").is(siteModel.getTitle()); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } @@ -113,7 +123,9 @@ public class AddSiteMembershipRequestSanityTests extends RestTest { UserModel newMember = dataUser.createRandomTestUser(); restClient.authenticateUser(new UserModel("random user", "random password")); - peopleApi.addSiteMembershipRequest(newMember, siteModel); + peopleApi.addSiteMembershipRequest(newMember, siteModel) + .assertThat().field("id").isNotEmpty() + .assertThat().field("title").is(siteModel.getTitle()); peopleApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java index 413e695e5..97727c320 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java @@ -3,6 +3,7 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; import org.alfresco.rest.requests.RestPeopleApi; import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.model.ErrorModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; @@ -112,7 +113,8 @@ public class DeleteFavoriteSiteSanityTests extends RestTest restClient.authenticateUser(userAuth); peopleApi.removeFavoriteSite(anotherUser, siteModel1); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized to remove a site from its favorite sites list with Rest API when authentication fails (401)") diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java index fc9ee1176..db4f020cd 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java @@ -9,6 +9,7 @@ import org.alfresco.utility.data.DataSite; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.exception.DataPreparationException; +import org.alfresco.utility.model.ErrorModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; @@ -95,7 +96,8 @@ public class DeleteSiteMemberSanityTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); peopleApi.deleteSiteMember(newUser, siteModel); - sitesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + sitesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -111,7 +113,8 @@ public class DeleteSiteMemberSanityTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); peopleApi.deleteSiteMember(newUser, siteModel); - sitesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + sitesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -127,7 +130,8 @@ public class DeleteSiteMemberSanityTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); peopleApi.deleteSiteMember(newUser, siteModel); - sitesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + sitesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java index ebe6dcb31..3a4c5da9b 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java @@ -7,6 +7,7 @@ import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.data.RandomData; import org.alfresco.utility.exception.DataPreparationException; +import org.alfresco.utility.model.ErrorModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; @@ -94,7 +95,8 @@ public class DeleteSiteMembershipRequestSanityTests extends RestTest peopleApi.addSiteMembershipRequest(siteMember, siteModel); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); peopleApi.deleteSiteMembershipRequest(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), siteModel); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @Bug(id="MNT-16916") @@ -107,7 +109,8 @@ public class DeleteSiteMembershipRequestSanityTests extends RestTest peopleApi.addSiteMembershipRequest(siteMember, siteModel); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); peopleApi.deleteSiteMembershipRequest(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor), siteModel); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @Bug(id="MNT-16916") @@ -120,7 +123,8 @@ public class DeleteSiteMembershipRequestSanityTests extends RestTest peopleApi.addSiteMembershipRequest(siteMember, siteModel); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); peopleApi.deleteSiteMembershipRequest(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer), siteModel); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @Bug(id="MNT-16916") @@ -134,7 +138,8 @@ public class DeleteSiteMembershipRequestSanityTests extends RestTest UserModel randomUser = dataUser.createRandomTestUser(); restClient.authenticateUser(randomUser); peopleApi.deleteSiteMembershipRequest(randomUser, siteModel); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, From 7d90a3a645c10a08222eaace966c76942935229f Mon Sep 17 00:00:00 2001 From: cagache Date: Thu, 27 Oct 2016 11:04:42 +0300 Subject: [PATCH 0500/1491] removed clearParameters method --- e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java index 940f14990..ed5887ac7 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java @@ -45,7 +45,6 @@ public class GetTagsSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role gets tags using REST API and status code is OK (200)") public void getTagsWithManagerRole() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); tagsAPI.getTags(); tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); @@ -54,7 +53,6 @@ public class GetTagsSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user with Collaborator role gets tags using REST API and status code is OK (200)") public void getTagsWithCollaboratorRole() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); tagsAPI.getTags(); tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); @@ -63,7 +61,6 @@ public class GetTagsSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user with Contributor role gets tags using REST API and status code is OK (200)") public void getTagsWithContributorRole() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); tagsAPI.getTags(); tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); From b2726637d432fb6119ddabc95176f9587fefeb86 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Thu, 27 Oct 2016 18:02:50 +0300 Subject: [PATCH 0501/1491] Fixes for tests AddTaskVariablesSanityTests and UpdateTaskVariableSanityTests --- .../GetProcessDefinitionImageSanityTests.java | 60 ++++++++++--------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java index 839223484..e47735bb3 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java @@ -17,37 +17,39 @@ import org.testng.annotations.Test; * Created by Claudia Agache on 10/13/2016. */ @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY }) -public class GetProcessDefinitionImageSanityTests extends RestWorkflowTest { - @Autowired - private DataUser dataUser; - @Autowired - private RestProcessDefinitionsApi processDefinitionsApi; +public class GetProcessDefinitionImageSanityTests extends RestWorkflowTest +{ + @Autowired + private DataUser dataUser; + @Autowired + private RestProcessDefinitionsApi processDefinitionsApi; - private UserModel testUser; - private RestProcessDefinitionModel randomProcessDefinition; + private UserModel testUser; + private RestProcessDefinitionModel randomProcessDefinition; - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception { - testUser = dataUser.createRandomTestUser(); - processDefinitionsApi.useRestClient(restClient); - restClient.authenticateUser(dataUser.getAdminUser()); - randomProcessDefinition = processDefinitionsApi.getProcessDefinitions().getOneRandomEntry(); - } + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + testUser = dataUser.createRandomTestUser(); + processDefinitionsApi.useRestClient(restClient); + restClient.authenticateUser(dataUser.getAdminUser()); + randomProcessDefinition = processDefinitionsApi.getProcessDefinitions().getOneRandomEntry(); + } - @TestRail(section = { TestGroup.REST_API, - TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.SANITY, description = "Verify Any user gets a specific process definition image for non-network deployments using REST API and status code is OK (200)") - public void anyUserGetsProcessDefinitionImage() throws Exception { - restClient.authenticateUser(testUser); - processDefinitionsApi.getProcessDefinitionImage(randomProcessDefinition) - .assertResponseContainsImage(); - processDefinitionsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); - } + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.SANITY, description = "Verify Any user gets a specific process definition image for non-network deployments using REST API and status code is OK (200)") + public void anyUserGetsProcessDefinitionImage() throws Exception + { + restClient.authenticateUser(testUser); + processDefinitionsApi.getProcessDefinitionImage(randomProcessDefinition) + .assertResponseContainsImage(); + processDefinitionsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } - @TestRail(section = { TestGroup.REST_API, - TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets a specific process definition image for non-network deployments using REST API and status code is OK (200)") - public void adminGetsProcessDefinitionImage() throws Exception { - processDefinitionsApi.getProcessDefinitionImage(randomProcessDefinition) - .assertResponseContainsImage(); - processDefinitionsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); - } + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets a specific process definition image for non-network deployments using REST API and status code is OK (200)") + public void adminGetsProcessDefinitionImage() throws Exception + { + processDefinitionsApi.getProcessDefinitionImage(randomProcessDefinition) + .assertResponseContainsImage(); + processDefinitionsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } } \ No newline at end of file From 4937b939faf5e70c510fd6d43387922bc7fa4ac1 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Fri, 28 Oct 2016 11:12:25 +0300 Subject: [PATCH 0502/1491] add missing db properties --- e2e-test/resources/default.properties | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/e2e-test/resources/default.properties b/e2e-test/resources/default.properties index 0dcbd8fd4..71dc4eb78 100644 --- a/e2e-test/resources/default.properties +++ b/e2e-test/resources/default.properties @@ -39,3 +39,10 @@ reports.path=./target/reports # in containers we cannot access directly JMX, so we will use http://jolokia.org agent # disabling this we will use direct JMX calls to server jmx.useJolokiaAgent=true + +# +# Database section +# +db.url = jdbc:mysql://${alfresco.server}:3306/alfresco +db.username = alfresco +db.password = alfresco From 018b6715727b5f5a80fb131c4a296571cc969ede Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Fri, 28 Oct 2016 11:41:43 +0300 Subject: [PATCH 0503/1491] up comments on default.properties --- e2e-test/resources/default.properties | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/e2e-test/resources/default.properties b/e2e-test/resources/default.properties index 71dc4eb78..9c7036b09 100644 --- a/e2e-test/resources/default.properties +++ b/e2e-test/resources/default.properties @@ -41,7 +41,23 @@ reports.path=./target/reports jmx.useJolokiaAgent=true # -# Database section +# Database Section +# You should provide here the database URL, that can be a differed server as alfresco. +# https://docs.oracle.com/javase/tutorial/jdbc/basics/connecting.html +# +# Current supported db.url: +# +# MySQL: +# db.url = jdbc:mysql://${alfresco.server}:3306/alfresco +# +# PostgreSQL: +# db.url = jdbc:postgresql://:3306/alfresco +# +# Oracle: +# db.url = jdbc:oracle://:3306/alfresco +# +# MariaDB: +# db.url = jdbc:mariadb://:3306/alfresco # db.url = jdbc:mysql://${alfresco.server}:3306/alfresco db.username = alfresco From dd61d9a035aeddd1a5aef8e87c9c62dd7a0c2284 Mon Sep 17 00:00:00 2001 From: Ioana Iacob Date: Fri, 28 Oct 2016 17:35:23 +0300 Subject: [PATCH 0504/1491] update assertions for People Api --- .../people/GetFavoriteSiteSanityTests.java | 24 ++++-- .../people/GetFavoriteSitesSanityTests.java | 23 +++-- .../GetPeopleActivitiesSanityTests.java | 25 ++++-- .../GetPeoplePreferenceSanityTests.java | 22 +++-- .../GetPeoplePreferencesSanityTests.java | 21 +++-- .../rest/people/GetPeopleSanityTests.java | 32 +++++-- .../people/GetSiteMembershipSanityTests.java | 24 ++++-- ...SitesMembershipInformationSanityTests.java | 25 ++++-- ...pdateSiteMembershipRequestSanityTests.java | 27 +++--- .../rest/ratings/AddRatingSanityTests.java | 51 +++++++++--- .../rest/ratings/DeleteRatingSanityTests.java | 83 +++++++++++++++---- .../rest/ratings/GetRatingSanityTests.java | 6 +- .../sites/GetSiteContainersSanityTests.java | 25 ++++-- .../rest/sites/GetSitesSanityTests.java | 24 ++++-- .../deployments/GetDeploymentSanityTests.java | 9 +- 15 files changed, 326 insertions(+), 95 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java index 7653859bc..5e5885f87 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java @@ -3,6 +3,7 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; import org.alfresco.rest.requests.RestPeopleApi; import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.model.ErrorModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; @@ -50,7 +51,9 @@ public class GetFavoriteSiteSanityTests extends RestTest dataSite.usingUser(managerUser).usingSite(siteModel2).addSiteToFavorites(); restClient.authenticateUser(managerUser); - peopleApi.getFavoriteSite(managerUser, siteModel1).assertThat().field("id").isNotNull(); + peopleApi.getFavoriteSite(managerUser, siteModel1) + .assertThat().field("id").is(siteModel1.getId()) + .and().field("title").isNotNull(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -63,7 +66,9 @@ public class GetFavoriteSiteSanityTests extends RestTest dataSite.usingUser(collaboratorUser).usingSite(siteModel2).addSiteToFavorites(); restClient.authenticateUser(collaboratorUser); - peopleApi.getFavoriteSite(collaboratorUser, siteModel1).assertThat().field("id").isNotNull(); + peopleApi.getFavoriteSite(collaboratorUser, siteModel1) + .assertThat().field("id").is(siteModel1.getId()) + .and().field("title").isNotNull(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -76,7 +81,9 @@ public class GetFavoriteSiteSanityTests extends RestTest dataSite.usingUser(contributorUser).usingSite(siteModel2).addSiteToFavorites(); restClient.authenticateUser(contributorUser); - peopleApi.getFavoriteSite(contributorUser, siteModel1).assertThat().field("id").isNotNull(); + peopleApi.getFavoriteSite(contributorUser, siteModel1) + .assertThat().field("id").is(siteModel1.getId()) + .and().field("title").isNotNull(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -89,7 +96,9 @@ public class GetFavoriteSiteSanityTests extends RestTest dataSite.usingUser(consumerUser).usingSite(siteModel2).addSiteToFavorites(); restClient.authenticateUser(consumerUser); - peopleApi.getFavoriteSite(consumerUser, siteModel1).assertThat().field("id").isNotNull(); + peopleApi.getFavoriteSite(consumerUser, siteModel1) + .assertThat().field("id").is(siteModel1.getId()) + .and().field("title").isNotNull(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -102,7 +111,9 @@ public class GetFavoriteSiteSanityTests extends RestTest dataSite.usingUser(anyUser).usingSite(siteModel2).addSiteToFavorites(); restClient.authenticateUser(adminUset); - peopleApi.getFavoriteSite(anyUser, siteModel1).assertThat().field("id").isNotNull(); + peopleApi.getFavoriteSite(anyUser, siteModel1) + .assertThat().field("id").is(siteModel1.getId()) + .and().field("title").isNotNull(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -116,7 +127,8 @@ public class GetFavoriteSiteSanityTests extends RestTest restClient.authenticateUser(managerUser); peopleApi.getFavoriteSite(userModel, siteModel1); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @Bug(id = "MNT-16904") diff --git a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java index cc03a9e67..de76461ff 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java @@ -3,6 +3,7 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; import org.alfresco.rest.requests.RestPeopleApi; import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.model.ErrorModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; @@ -43,7 +44,8 @@ public class GetFavoriteSitesSanityTests extends RestTest restClient.authenticateUser(managerUser); peopleApi.getFavoriteSites(anotherUser); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify collaborator user fails to get an user favorite sites with Rest API (403)") @@ -57,7 +59,8 @@ public class GetFavoriteSitesSanityTests extends RestTest restClient.authenticateUser(collaboratorUser); peopleApi.getFavoriteSites(contributorUser); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify contributor user fails to get an user favorite sites with Rest API (403)") @@ -71,7 +74,8 @@ public class GetFavoriteSitesSanityTests extends RestTest restClient.authenticateUser(contributorUser); peopleApi.getFavoriteSites(contributorUser2); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify consumer user fails to get an user favorite sites with Rest API (403)") @@ -85,7 +89,8 @@ public class GetFavoriteSitesSanityTests extends RestTest restClient.authenticateUser(consumerUser); peopleApi.getFavoriteSites(collaboratorUser); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify admin user gets its favorite sites with Rest API and response is successful (200)") @@ -96,7 +101,10 @@ public class GetFavoriteSitesSanityTests extends RestTest dataSite.usingUser(anotherUser).usingSite(siteModel).addSiteToFavorites(); restClient.authenticateUser(adminUser); - peopleApi.getFavoriteSites(anotherUser).assertThat().entriesListIsNotEmpty(); + peopleApi.getFavoriteSites(anotherUser) + .assertThat().entriesListIsNotEmpty() + .and().paginationExist() + .and().entriesListContains("id", siteModel.getId()); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -107,7 +115,10 @@ public class GetFavoriteSitesSanityTests extends RestTest dataSite.usingUser(anyUser).usingSite(siteModel).addSiteToFavorites(); restClient.authenticateUser(anyUser); - peopleApi.getFavoriteSites(anyUser); + peopleApi.getFavoriteSites(anyUser) + .assertThat().entriesListIsNotEmpty() + .and().entriesListContains("id", siteModel.getId()) + .and().paginationExist(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java index d1e87363b..a27b36758 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java @@ -49,7 +49,10 @@ public class GetPeopleActivitiesSanityTests extends RestTest dataContent.usingUser(managerUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); restClient.authenticateUser(managerUser); - peopleApi.getPersonActivities(managerUser).assertThat().entriesListIsNotEmpty(); + peopleApi.getPersonActivities(managerUser) + .assertThat().entriesListIsNotEmpty() + .and().entriesListContains("siteId", siteModel.getId()) + .and().paginationExist(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -61,7 +64,10 @@ public class GetPeopleActivitiesSanityTests extends RestTest dataContent.usingUser(collaboratorUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); restClient.authenticateUser(collaboratorUser); - peopleApi.getPersonActivities(collaboratorUser).assertThat().entriesListIsNotEmpty(); + peopleApi.getPersonActivities(collaboratorUser) + .assertThat().entriesListIsNotEmpty() + .and().entriesListContains("siteId", siteModel.getId()) + .and().paginationExist(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -73,7 +79,10 @@ public class GetPeopleActivitiesSanityTests extends RestTest dataContent.usingUser(contributorUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); restClient.authenticateUser(contributorUser); - peopleApi.getPersonActivities(contributorUser).assertThat().entriesListIsNotEmpty(); + peopleApi.getPersonActivities(contributorUser) + .assertThat().entriesListIsNotEmpty() + .and().entriesListContains("siteId", siteModel.getId()) + .and().paginationExist(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -84,7 +93,10 @@ public class GetPeopleActivitiesSanityTests extends RestTest dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel, UserRole.SiteConsumer); restClient.authenticateUser(consumerUser); - peopleApi.getPersonActivities(consumerUser).assertThat().entriesListIsNotEmpty(); + peopleApi.getPersonActivities(consumerUser) + .assertThat().entriesListIsNotEmpty() + .and().entriesListContains("siteId", siteModel.getId()) + .and().paginationExist(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -92,7 +104,10 @@ public class GetPeopleActivitiesSanityTests extends RestTest public void adminUserShouldGetPeopleActivitiesList() throws Exception { restClient.authenticateUser(dataUser.getAdminUser()); - peopleApi.getPersonActivities(userModel).assertThat().entriesListIsNotEmpty(); + peopleApi.getPersonActivities(userModel) + .assertThat().entriesListIsNotEmpty() + .and().entriesListContains("siteId", siteModel.getId()) + .and().paginationExist(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceSanityTests.java index f5814ae0b..dba3a41c3 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceSanityTests.java @@ -29,7 +29,7 @@ public class GetPeoplePreferenceSanityTests extends RestTest UserModel userModel; SiteModel siteModel; - + @BeforeClass(alwaysRun=true) public void dataPreparation() throws Exception { @@ -47,7 +47,9 @@ public class GetPeoplePreferenceSanityTests extends RestTest dataSite.usingUser(managerUser).usingSite(siteModel).addSiteToFavorites(); restClient.authenticateUser(managerUser); - peopleApi.getPersonPreferenceInformation(managerUser, PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); + peopleApi.getPersonPreferenceInformation(managerUser, PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) + .assertThat().field("id").is( PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) + .and().field("value").is("true"); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -59,7 +61,9 @@ public class GetPeoplePreferenceSanityTests extends RestTest dataSite.usingUser(collaboratorUser).usingSite(siteModel).addSiteToFavorites(); restClient.authenticateUser(collaboratorUser); - peopleApi.getPersonPreferenceInformation(collaboratorUser, PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); + peopleApi.getPersonPreferenceInformation(collaboratorUser, PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) + .assertThat().field("id").is(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) + .and().field("value").is("true"); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -71,7 +75,9 @@ public class GetPeoplePreferenceSanityTests extends RestTest dataSite.usingUser(contributorUser).usingSite(siteModel).addSiteToFavorites(); restClient.authenticateUser(contributorUser); - peopleApi.getPersonPreferenceInformation(contributorUser, PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); + peopleApi.getPersonPreferenceInformation(contributorUser, PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) + .assertThat().field("id").is(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) + .and().field("value").is("true"); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -83,7 +89,9 @@ public class GetPeoplePreferenceSanityTests extends RestTest dataSite.usingUser(consumerUser).usingSite(siteModel).addSiteToFavorites(); restClient.authenticateUser(consumerUser); - peopleApi.getPersonPreferenceInformation(consumerUser, PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); + peopleApi.getPersonPreferenceInformation(consumerUser, PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) + .assertThat().field("id").is(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) + .and().field("value").is("true"); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -94,7 +102,9 @@ public class GetPeoplePreferenceSanityTests extends RestTest dataSite.usingUser(adminUser).usingSite(siteModel).addSiteToFavorites(); restClient.authenticateUser(adminUser); - peopleApi.getPersonPreferenceInformation(adminUser, PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); + peopleApi.getPersonPreferenceInformation(adminUser, PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) + .assertThat().field("id").is(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) + .and().field("value").is("true"); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesSanityTests.java index de9e40f66..0c37b0cda 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesSanityTests.java @@ -2,6 +2,7 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; import org.alfresco.rest.requests.RestPeopleApi; +import org.alfresco.utility.constants.PreferenceName; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; @@ -46,7 +47,9 @@ public class GetPeoplePreferencesSanityTests extends RestTest dataSite.usingUser(managerUser).usingSite(siteModel).addSiteToFavorites(); restClient.authenticateUser(managerUser); - peopleApi.getPersonPreferences(managerUser).assertThat().entriesListIsNotEmpty(); + peopleApi.getPersonPreferences(managerUser).assertThat().entriesListIsNotEmpty() + .assertThat().paginationExist() + .and().entriesListContains("id", PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -58,7 +61,9 @@ public class GetPeoplePreferencesSanityTests extends RestTest dataSite.usingUser(collaboratorUser).usingSite(siteModel).addSiteToFavorites(); restClient.authenticateUser(collaboratorUser); - peopleApi.getPersonPreferences(collaboratorUser).assertThat().entriesListIsNotEmpty(); + peopleApi.getPersonPreferences(collaboratorUser).assertThat().entriesListIsNotEmpty() + .assertThat().paginationExist() + .and().entriesListContains("id", PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -70,7 +75,9 @@ public class GetPeoplePreferencesSanityTests extends RestTest dataSite.usingUser(contributorUser).usingSite(siteModel).addSiteToFavorites(); restClient.authenticateUser(contributorUser); - peopleApi.getPersonPreferences(contributorUser).assertThat().entriesListIsNotEmpty(); + peopleApi.getPersonPreferences(contributorUser).assertThat().entriesListIsNotEmpty() + .assertThat().paginationExist() + .and().entriesListContains("id", PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -82,7 +89,9 @@ public class GetPeoplePreferencesSanityTests extends RestTest dataSite.usingUser(consumerUser).usingSite(siteModel).addSiteToFavorites(); restClient.authenticateUser(consumerUser); - peopleApi.getPersonPreferences(consumerUser).assertThat().entriesListIsNotEmpty(); + peopleApi.getPersonPreferences(consumerUser).assertThat().entriesListIsNotEmpty() + .assertThat().paginationExist() + .and().entriesListContains("id", PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -95,7 +104,9 @@ public class GetPeoplePreferencesSanityTests extends RestTest UserModel adminUser = dataUser.getAdminUser(); restClient.authenticateUser(adminUser); - peopleApi.getPersonPreferences(managerUser).assertThat().entriesListIsNotEmpty(); + peopleApi.getPersonPreferences(managerUser).assertThat().entriesListIsNotEmpty() + .assertThat().paginationExist() + .and().entriesListContains("id", PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleSanityTests.java index 55bd6f49e..820eabf4c 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleSanityTests.java @@ -23,6 +23,8 @@ public class GetPeopleSanityTests extends RestTest UserModel userModel; SiteModel siteModel; UserModel searchedUser; + + private String domain = "@tas-automation.org"; @BeforeClass(alwaysRun=true) public void dataPreparation() throws Exception @@ -41,7 +43,11 @@ public class GetPeopleSanityTests extends RestTest dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); restClient.authenticateUser(managerUser); - peopleApi.getPerson(searchedUser).assertThat().field("id").is(searchedUser.getUsername());; + peopleApi.getPerson(searchedUser) + .assertThat().field("id").is(searchedUser.getUsername()) + .assertThat().field("firstName").is(searchedUser.getUsername()+" FirstName") + .and().field("email").is(searchedUser.getUsername()+ domain) + .and().field("emailNotificationsEnabled").is("true"); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -52,7 +58,11 @@ public class GetPeopleSanityTests extends RestTest dataUser.usingUser(userModel).addUserToSite(collaboratorUser, siteModel, UserRole.SiteCollaborator); restClient.authenticateUser(collaboratorUser); - peopleApi.getPerson(searchedUser); + peopleApi.getPerson(searchedUser) + .assertThat().field("id").is(searchedUser.getUsername()) + .assertThat().field("firstName").is(searchedUser.getUsername()+" FirstName") + .and().field("email").is(searchedUser.getUsername()+ domain) + .and().field("emailNotificationsEnabled").is("true"); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -64,7 +74,11 @@ public class GetPeopleSanityTests extends RestTest dataUser.usingUser(userModel).addUserToSite(contributorUser, siteModel, UserRole.SiteContributor); restClient.authenticateUser(contributorUser); - peopleApi.getPerson(searchedUser); + peopleApi.getPerson(searchedUser) + .assertThat().field("id").is(searchedUser.getUsername()) + .assertThat().field("firstName").is(searchedUser.getUsername()+" FirstName") + .and().field("email").is(searchedUser.getUsername()+ domain) + .and().field("emailNotificationsEnabled").is("true");; peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -75,7 +89,11 @@ public class GetPeopleSanityTests extends RestTest dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel, UserRole.SiteConsumer); restClient.authenticateUser(consumerUser); - peopleApi.getPerson(searchedUser); + peopleApi.getPerson(searchedUser) + .assertThat().field("id").is(searchedUser.getUsername()) + .assertThat().field("firstName").is(searchedUser.getUsername()+" FirstName") + .and().field("email").is(searchedUser.getUsername()+ domain) + .and().field("emailNotificationsEnabled").is("true");; peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -85,7 +103,11 @@ public class GetPeopleSanityTests extends RestTest UserModel adminUser = dataUser.getAdminUser(); restClient.authenticateUser(adminUser); - peopleApi.getPerson(searchedUser); + peopleApi.getPerson(searchedUser) + .assertThat().field("id").is(searchedUser.getUsername()) + .assertThat().field("firstName").is(searchedUser.getUsername()+" FirstName") + .and().field("email").is(searchedUser.getUsername()+ domain) + .and().field("emailNotificationsEnabled").is("true");; peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java index cc3f520bc..b1f3eaad6 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java @@ -53,7 +53,10 @@ public class GetSiteMembershipSanityTests extends RestTest public void siteManagerCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - peopleApi.getSiteMembership(adminUser, siteModel); + peopleApi.getSiteMembership(adminUser, siteModel) + .assertThat().field("role").is(UserRole.SiteManager) + .and().field("id").is(siteModel.getId()) + .and().field("site").isNotEmpty(); peopleApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.OK); } @@ -63,7 +66,9 @@ public class GetSiteMembershipSanityTests extends RestTest public void siteCollaboratorCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - peopleApi.getSiteMembership(adminUser, siteModel); + peopleApi.getSiteMembership(adminUser, siteModel).onSite() + .assertThat().field("role").is(UserRole.SiteCollaborator) + .and().field("id").is(siteModel.getId()); peopleApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.OK); } @@ -73,7 +78,10 @@ public class GetSiteMembershipSanityTests extends RestTest public void siteContributorCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - peopleApi.getSiteMembership(adminUser, siteModel); + peopleApi.getSiteMembership(adminUser, siteModel) + .assertThat().field("role").is(UserRole.SiteManager) + .and().field("id").is(siteModel.getId()) + .and().field("site").isNotEmpty(); peopleApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.OK); } @@ -83,7 +91,10 @@ public class GetSiteMembershipSanityTests extends RestTest public void siteConsumerCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - peopleApi.getSiteMembership(adminUser, siteModel); + peopleApi.getSiteMembership(adminUser, siteModel) + .assertThat().field("role").is(UserRole.SiteManager) + .and().field("id").is(siteModel.getId()) + .and().field("site").isNotEmpty(); peopleApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.OK); } @@ -93,7 +104,10 @@ public class GetSiteMembershipSanityTests extends RestTest public void adminCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUser); - peopleApi.getSiteMembership(usersWithRoles.getOneUserWithRole(UserRole.SiteManager), siteModel); + peopleApi.getSiteMembership(usersWithRoles.getOneUserWithRole(UserRole.SiteManager), siteModel) + .assertThat().field("role").is(UserRole.SiteManager) + .and().field("id").is(siteModel.getId()) + .and().field("site").isNotEmpty(); peopleApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.OK); } diff --git a/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java index 408d6fe0e..8250b2162 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java @@ -43,7 +43,10 @@ public class GetSitesMembershipInformationSanityTests extends RestTest public void siteManagerIsAbleToRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - peopleApi.getSitesMembershipInformation(adminUser); + peopleApi.getSitesMembershipInformation(adminUser) + .assertThat().entriesListIsNotEmpty() + .and().paginationExist() + .and().paginationField("count").isNot("0"); peopleApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.OK); } @@ -54,7 +57,10 @@ public class GetSitesMembershipInformationSanityTests extends RestTest public void siteCollaboratorIsAbleToRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - peopleApi.getSitesMembershipInformation(adminUser); + peopleApi.getSitesMembershipInformation(adminUser) + .assertThat().entriesListIsNotEmpty() + .and().paginationExist() + .and().paginationField("count").isNot("0"); peopleApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.OK); } @@ -65,7 +71,10 @@ public class GetSitesMembershipInformationSanityTests extends RestTest public void siteContributorIsAbleToRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - peopleApi.getSitesMembershipInformation(adminUser); + peopleApi.getSitesMembershipInformation(adminUser) + .assertThat().entriesListIsNotEmpty() + .and().paginationExist() + .and().paginationField("count").isNot("0"); peopleApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.OK); } @@ -76,7 +85,10 @@ public class GetSitesMembershipInformationSanityTests extends RestTest public void siteConsumerIsAbleToRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - peopleApi.getSitesMembershipInformation(adminUser); + peopleApi.getSitesMembershipInformation(adminUser) + .assertThat().entriesListIsNotEmpty() + .and().paginationExist() + .and().paginationField("count").isNot("0"); peopleApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.OK); } @@ -87,7 +99,10 @@ public class GetSitesMembershipInformationSanityTests extends RestTest public void siteAdminIsAbleToRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUser); - peopleApi.getSitesMembershipInformation(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + peopleApi.getSitesMembershipInformation(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .assertThat().entriesListIsNotEmpty() + .and().paginationExist() + .and().paginationField("count").isNot("0"); peopleApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.OK); } diff --git a/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestSanityTests.java index a76eee04b..3de639b01 100644 --- a/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestSanityTests.java @@ -9,6 +9,7 @@ import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.data.RandomData; import org.alfresco.utility.exception.DataPreparationException; +import org.alfresco.utility.model.ErrorModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; @@ -47,10 +48,8 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); - peopleApi.useRestClient(restClient); - + peopleApi.useRestClient(restClient); updatedMessage = "Please review my request"; - } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -63,7 +62,9 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest peopleApi.addSiteMembershipRequest(newMember, siteModel); peopleApi.updateSiteMembershipRequest(newMember, siteModel, updatedMessage) - .assertMembershipRequestMessageIs(updatedMessage); + .assertMembershipRequestMessageIs(updatedMessage) + .and().field("id").is(siteModel.getId()) + .and().field("modifiedAt").isNotEmpty(); peopleApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.OK); } @@ -82,7 +83,8 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest peopleApi.updateSiteMembershipRequest(newMember, siteModel, updatedMessage); peopleApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.FORBIDDEN); + .assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -99,7 +101,8 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest peopleApi.updateSiteMembershipRequest(newMember, siteModel, updatedMessage); peopleApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.FORBIDDEN); + .assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -116,7 +119,8 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest peopleApi.updateSiteMembershipRequest(newMember, siteModel, updatedMessage); peopleApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.FORBIDDEN); + .assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -133,7 +137,8 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest peopleApi.updateSiteMembershipRequest(newMember, siteModel, updatedMessage); peopleApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.FORBIDDEN); + .assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -151,7 +156,8 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest peopleApi.updateSiteMembershipRequest(newMember, siteModel, updatedMessage); peopleApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.FORBIDDEN); + .assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -168,6 +174,7 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest peopleApi.updateSiteMembershipRequest(newMember, siteModel, updatedMessage); peopleApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.FORBIDDEN); + .assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java index 02b4951a5..e8fa4a1dd 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java @@ -58,7 +58,10 @@ public class AddRatingSanityTests extends RestTest public void managerIsAbleToLikeDocument() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - ratingsApi.likeDocument(document); + ratingsApi.likeDocument(document) + .assertThat().field("myRating").is("true") + .and().field("id").is("likes") + .and().field("aggregate").isNotEmpty(); ratingsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } @@ -67,7 +70,10 @@ public class AddRatingSanityTests extends RestTest public void collaboratorIsAbleToLikeDocument() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - ratingsApi.likeDocument(document); + ratingsApi.likeDocument(document) + .assertThat().field("myRating").is("true") + .and().field("id").is("likes") + .and().field("aggregate").isNotEmpty(); ratingsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } @@ -76,7 +82,10 @@ public class AddRatingSanityTests extends RestTest public void contributorIsAbleToLikeDocument() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - ratingsApi.likeDocument(document); + ratingsApi.likeDocument(document) + .assertThat().field("myRating").is("true") + .and().field("id").is("likes") + .and().field("aggregate").isNotEmpty(); ratingsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } @@ -85,7 +94,10 @@ public class AddRatingSanityTests extends RestTest public void consumerIsAbleToLikeDocument() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - ratingsApi.likeDocument(document); + ratingsApi.likeDocument(document) + .assertThat().field("myRating").is("true") + .and().field("id").is("likes") + .and().field("aggregate").isNotEmpty(); ratingsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } @@ -94,7 +106,10 @@ public class AddRatingSanityTests extends RestTest public void adminIsAbleToLikeDocument() throws Exception { restClient.authenticateUser(adminUser); - ratingsApi.likeDocument(document); + ratingsApi.likeDocument(document) + .assertThat().field("myRating").is("true") + .and().field("id").is("likes") + .and().field("aggregate").isNotEmpty(); ratingsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } @@ -113,7 +128,10 @@ public class AddRatingSanityTests extends RestTest public void managerIsAbleToAddStarsToDocument() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - ratingsApi.rateStarsToDocument(document, 5); + ratingsApi.rateStarsToDocument(document, 5) + .assertThat().field("myRating").is("5") + .and().field("id").is("fiveStar") + .and().field("aggregate").isNotEmpty(); ratingsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } @@ -122,7 +140,10 @@ public class AddRatingSanityTests extends RestTest public void collaboratorIsAbleToAddStarsToDocument() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - ratingsApi.rateStarsToDocument(document, 5); + ratingsApi.rateStarsToDocument(document, 5) + .assertThat().field("myRating").is("5") + .and().field("id").is("fiveStar") + .and().field("aggregate").isNotEmpty();; ratingsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } @@ -131,7 +152,10 @@ public class AddRatingSanityTests extends RestTest public void contributorIsAbleToAddStarsToDocument() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - ratingsApi.rateStarsToDocument(document, 5); + ratingsApi.rateStarsToDocument(document, 5) + .assertThat().field("myRating").is("5") + .and().field("id").is("fiveStar") + .and().field("aggregate").isNotEmpty();; ratingsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } @@ -140,7 +164,10 @@ public class AddRatingSanityTests extends RestTest public void consumerIsAbleToAddStarsToDocument() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - ratingsApi.rateStarsToDocument(document, 5); + ratingsApi.rateStarsToDocument(document, 5) + .assertThat().field("myRating").is("5") + .and().field("id").is("fiveStar") + .and().field("aggregate").isNotEmpty();; ratingsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } @@ -148,8 +175,12 @@ public class AddRatingSanityTests extends RestTest TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify admin user is able to post stars rating to a document") public void adminIsAbleToAddStarsToDocument() throws Exception { + int starsNo=3; restClient.authenticateUser(adminUser); - ratingsApi.rateStarsToDocument(document, 5); + ratingsApi.rateStarsToDocument(document, starsNo) + .assertThat().field("myRating").is(String.valueOf(starsNo)) + .and().field("id").is("fiveStar") + .and().field("aggregate").isNotEmpty();; ratingsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } diff --git a/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java index e2bf71b46..1f2ce7351 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java @@ -57,8 +57,14 @@ public class DeleteRatingSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - ratingsApi.likeDocument(document); - ratingsApi.rateStarsToDocument(document, 5); + ratingsApi.likeDocument(document) + .assertThat().field("myRating").is("true") + .and().field("id").is("likes") + .and().field("aggregate").isNotEmpty(); + ratingsApi.rateStarsToDocument(document, 5) + .assertThat().field("myRating").is("5") + .and().field("id").is("fiveStar") + .and().field("aggregate").isNotEmpty(); ratingsApi.deleteLikeRating(document); ratingsApi.usingRestWrapper() @@ -70,7 +76,9 @@ public class DeleteRatingSanityTests extends RestTest ratingsApi.getRatings(document) .assertNodeIsNotLiked() - .assertNodeHasNoFiveStarRating(); + .assertNodeHasNoFiveStarRating() + .and().entriesListIsNotEmpty() + .and().paginationExist(); } @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, @@ -79,8 +87,14 @@ public class DeleteRatingSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - ratingsApi.likeDocument(document); - ratingsApi.rateStarsToDocument(document, 5); + ratingsApi.likeDocument(document) + .assertThat().field("myRating").is("true") + .and().field("id").is("likes") + .and().field("aggregate").isNotEmpty(); + ratingsApi.rateStarsToDocument(document, 5) + .assertThat().field("myRating").is("5") + .and().field("id").is("fiveStar") + .and().field("aggregate").isNotEmpty(); ratingsApi.deleteLikeRating(document); ratingsApi.usingRestWrapper() @@ -92,7 +106,9 @@ public class DeleteRatingSanityTests extends RestTest ratingsApi.getRatings(document) .assertNodeIsNotLiked() - .assertNodeHasNoFiveStarRating(); + .assertNodeHasNoFiveStarRating() + .and().entriesListIsNotEmpty() + .and().paginationExist(); } @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, @@ -101,8 +117,14 @@ public class DeleteRatingSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - ratingsApi.likeDocument(document); - ratingsApi.rateStarsToDocument(document, 5); + ratingsApi.likeDocument(document) + .assertThat().field("myRating").is("true") + .and().field("id").is("likes") + .and().field("aggregate").isNotEmpty(); + ratingsApi.rateStarsToDocument(document, 5) + .assertThat().field("myRating").is("5") + .and().field("id").is("fiveStar") + .and().field("aggregate").isNotEmpty(); ratingsApi.deleteLikeRating(document); ratingsApi.usingRestWrapper() @@ -114,7 +136,9 @@ public class DeleteRatingSanityTests extends RestTest ratingsApi.getRatings(document) .assertNodeIsNotLiked() - .assertNodeHasNoFiveStarRating(); + .assertNodeHasNoFiveStarRating() + .and().entriesListIsNotEmpty() + .and().paginationExist(); } @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, @@ -123,8 +147,14 @@ public class DeleteRatingSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - ratingsApi.likeDocument(document); - ratingsApi.rateStarsToDocument(document, 5); + ratingsApi.likeDocument(document) + .assertThat().field("myRating").is("true") + .and().field("id").is("likes") + .and().field("aggregate").isNotEmpty(); + ratingsApi.rateStarsToDocument(document, 5) + .assertThat().field("myRating").is("5") + .and().field("id").is("fiveStar") + .and().field("aggregate").isNotEmpty(); ratingsApi.deleteLikeRating(document); ratingsApi.usingRestWrapper() @@ -136,17 +166,27 @@ public class DeleteRatingSanityTests extends RestTest ratingsApi.getRatings(document) .assertNodeIsNotLiked() - .assertNodeHasNoFiveStarRating(); + .assertNodeHasNoFiveStarRating() + .and().entriesListIsNotEmpty() + .and().paginationExist(); } @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify admin user is able to remove its own rating of a document") public void adminIsAbleToDeleteItsOwnRatings() throws Exception { + document = dataContent.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(adminUser); - ratingsApi.likeDocument(document); - ratingsApi.rateStarsToDocument(document, 5); + ratingsApi.likeDocument(document) + .assertThat().field("myRating").is("true") + .and().field("id").is("likes") + .and().field("aggregate").isNotEmpty(); + ratingsApi.rateStarsToDocument(document, 5) + .assertThat().field("myRating").is("5") + .and().field("id").is("fiveStar") + .and().field("aggregate").isNotEmpty(); ratingsApi.deleteLikeRating(document); ratingsApi.usingRestWrapper() @@ -158,17 +198,26 @@ public class DeleteRatingSanityTests extends RestTest ratingsApi.getRatings(document) .assertNodeIsNotLiked() - .assertNodeHasNoFiveStarRating(); + .assertNodeHasNoFiveStarRating() + .and().entriesListIsNotEmpty() + .and().paginationExist(); } @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to remove its own rating of a document") public void unauthenticatedUserIsNotAbleToDeleteRatings() throws Exception { + document = dataContent.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); restClient.authenticateUser(adminUser); - ratingsApi.likeDocument(document); - ratingsApi.rateStarsToDocument(document, 5); + ratingsApi.likeDocument(document) + .assertThat().field("myRating").is("true") + .and().field("id").is("likes") + .and().field("aggregate").isNotEmpty(); + ratingsApi.rateStarsToDocument(document, 5) + .assertThat().field("myRating").is("5") + .and().field("id").is("fiveStar") + .and().field("aggregate").isNotEmpty(); restClient.authenticateUser(new UserModel("random user", "random password")); diff --git a/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java index 7486a1e78..b326d56b4 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java @@ -67,8 +67,8 @@ public class GetRatingSanityTests extends RestTest .assertStatusCodeIs(HttpStatus.OK); ratingsApi.getFiveStarRating(document) - .assertThat().field("id").is("fiveStar") - .and().field("myRating").is("5"); + .assertThat().field("id").is("fiveStar") + .and().field("myRating").is("5"); ratingsApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.OK); } @@ -86,7 +86,7 @@ public class GetRatingSanityTests extends RestTest .assertThat().field("id").is("likes") .and().field("myRating").is("true"); ratingsApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.OK); + .assertStatusCodeIs(HttpStatus.OK); ratingsApi.getFiveStarRating(document) .assertThat().field("id").is("fiveStar") diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java index 71182c06d..f2587f798 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java @@ -52,7 +52,10 @@ public class GetSiteContainersSanityTests extends RestTest public void getSiteContainersWithManagerRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - siteAPI.getSiteContainers(siteModel).assertThat().entriesListIsNotEmpty(); + siteAPI.getSiteContainers(siteModel) + .assertThat().entriesListIsNotEmpty() + .assertThat().paginationExist() + .and().paginationField("count").isNot("0"); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -61,7 +64,10 @@ public class GetSiteContainersSanityTests extends RestTest public void getSiteContainersWithCollaboratorRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - siteAPI.getSiteContainers(siteModel).assertThat().entriesListIsNotEmpty(); + siteAPI.getSiteContainers(siteModel) + .assertThat().entriesListIsNotEmpty() + .assertThat().paginationExist() + .and().paginationField("count").isNot("0"); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -70,7 +76,10 @@ public class GetSiteContainersSanityTests extends RestTest public void getSiteContainersWithContributorRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - siteAPI.getSiteContainers(siteModel).assertThat().entriesListIsNotEmpty(); + siteAPI.getSiteContainers(siteModel) + .assertThat().entriesListIsNotEmpty() + .assertThat().paginationExist() + .and().paginationField("count").isNot("0"); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -79,7 +88,10 @@ public class GetSiteContainersSanityTests extends RestTest public void getSiteContainersWithConsumerRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - siteAPI.getSiteContainers(siteModel).assertThat().entriesListIsNotEmpty(); + siteAPI.getSiteContainers(siteModel) + .assertThat().entriesListIsNotEmpty() + .assertThat().paginationExist() + .and().paginationField("count").isNot("0"); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -88,7 +100,10 @@ public class GetSiteContainersSanityTests extends RestTest public void getSiteContainersWithAdminUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); - siteAPI.getSiteContainers(siteModel).assertThat().entriesListIsNotEmpty(); + siteAPI.getSiteContainers(siteModel) + .assertThat().entriesListIsNotEmpty() + .assertThat().paginationExist() + .and().paginationField("count").isNot("0"); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java index e5256ff0f..4261aaa91 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java @@ -53,7 +53,10 @@ public class GetSitesSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - siteAPI.getAllSites().assertThat().entriesListIsNotEmpty(); + siteAPI.getAllSites() + .assertThat().entriesListIsNotEmpty() + .assertThat().entriesListContains("id", siteModel.getId()) + .and().paginationExist(); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -63,7 +66,9 @@ public class GetSitesSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - siteAPI.getAllSites().assertThat().entriesListIsNotEmpty(); + siteAPI.getAllSites().assertThat().entriesListIsNotEmpty() + .assertThat().entriesListContains("id", siteModel.getId()) + .and().paginationExist(); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -73,7 +78,10 @@ public class GetSitesSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - siteAPI.getAllSites().assertThat().entriesListIsNotEmpty(); + siteAPI.getAllSites() + .assertThat().entriesListIsNotEmpty() + .assertThat().entriesListContains("id", siteModel.getId()) + .and().paginationExist(); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -83,7 +91,10 @@ public class GetSitesSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - siteAPI.getAllSites().assertThat().entriesListIsNotEmpty(); + siteAPI.getAllSites() + .assertThat().entriesListIsNotEmpty() + .assertThat().entriesListContains("id", siteModel.getId()) + .and().paginationExist(); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -92,7 +103,10 @@ public class GetSitesSanityTests extends RestTest public void adminUserIsAbleToRetrieveSites() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); - siteAPI.getAllSites().assertThat().entriesListIsNotEmpty(); + siteAPI.getAllSites() + .assertThat().entriesListIsNotEmpty() + .assertThat().entriesListContains("id", siteModel.getId()) + .and().paginationExist(); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentSanityTests.java index c937517f0..e59a07302 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentSanityTests.java @@ -4,6 +4,7 @@ import org.alfresco.rest.RestWorkflowTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestDeploymentModel; import org.alfresco.rest.requests.RestDeploymentsApi; +import org.alfresco.utility.model.ErrorModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; @@ -45,7 +46,10 @@ public class GetDeploymentSanityTests extends RestWorkflowTest public void adminGetsNonNetworkDeploymentWithSuccess() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUser); - deploymentsApi.getDeployment(deployment); + deploymentsApi.getDeployment(deployment) + .assertThat().field("deployedAt").isNotEmpty() + .and().field("name").is(deployment.getName()) + .and().field("id").equals(deployment.getId()); deploymentsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -55,6 +59,7 @@ public class GetDeploymentSanityTests extends RestWorkflowTest { restClient.authenticateUser(anotherUser); deploymentsApi.getDeployment(deployment); - deploymentsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + deploymentsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } } From d51b733ded5605d51b1cc0036e4bfa000229e513 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Wed, 2 Nov 2016 00:51:10 +0200 Subject: [PATCH 0505/1491] Added implementation for get task candidates call and related sanity tests. Added methods to get specific task and process models. --- .../tasks/GetTaskCandidatesTests.java | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCandidatesTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCandidatesTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCandidatesTests.java new file mode 100644 index 000000000..236563c2f --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCandidatesTests.java @@ -0,0 +1,83 @@ +package org.alfresco.rest.workflow.tasks; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestWorkflowTest; +import org.alfresco.rest.requests.RestTasksApi; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.GroupModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TaskModel; +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.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * + * @author Cristina Axinte + * + */ +@Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) +public class GetTaskCandidatesTests extends RestWorkflowTest +{ + @Autowired + RestTasksApi tasksApi; + + private UserModel userModel, user, userModel1, userModel2; + private SiteModel siteModel; + private FileModel fileModel; + private TaskModel taskModel; + private GroupModel group; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + user = dataUser.createRandomTestUser(); + userModel1 = dataUser.createRandomTestUser(); + userModel2 = dataUser.createRandomTestUser(); + group = dataGroup.createRandomGroup(); + dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); + taskModel = dataWorkflow.usingUser(user).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); + tasksApi.useRestClient(restClient); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Verify that admin gets task candidates") + public void getTaskCandidatesByAdmin() throws Exception + { + restClient.authenticateUser(dataUser.getAdminUser()); + tasksApi.getTaskCandidates(taskModel) + .assertThat().entriesListContains("candidateType", "group") + .and().entriesListContains("candidateId", String.format("GROUP_%s", group.getGroupIdentifier())); + tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Verify that user that started the process gets task candidates") + public void getTaskCandidatesByUserWhoStartedProcess() throws Exception + { + restClient.authenticateUser(user); + tasksApi.getTaskCandidates(taskModel) + .assertThat().entriesListContains("candidateType", "group") + .and().entriesListContains("candidateId", String.format("GROUP_%s", group.getGroupIdentifier())); + tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Verify that user from the assighed group to the process gets task candidates") + public void getTaskCandidatesByCandidateUser() throws Exception + { + restClient.authenticateUser(userModel1); + tasksApi.getTaskCandidates(taskModel) + .assertThat().entriesListContains("candidateType", "group") + .and().entriesListContains("candidateId", String.format("GROUP_%s", group.getGroupIdentifier())); + tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } +} From 4a783aac5c86ceaaaa1da63e7346daf40f4ae15c Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Fri, 4 Nov 2016 11:30:53 +0200 Subject: [PATCH 0506/1491] Fixed some bamboo failures --- .../rest/workflow/deployments/GetDeploymentSanityTests.java | 2 +- .../org/alfresco/rest/workflow/tasks/GetTaskSanityTests.java | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentSanityTests.java index e59a07302..da372a6f9 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentSanityTests.java @@ -38,7 +38,7 @@ public class GetDeploymentSanityTests extends RestWorkflowTest deploymentsApi.useRestClient(restClient); restClient.authenticateUser(adminUser); - deployment = deploymentsApi.getDeployments().getOneRandomEntry(); + deployment = deploymentsApi.getDeployments().getOneRandomEntry().onModel(); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskSanityTests.java index cc4b291ec..32188daf0 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskSanityTests.java @@ -9,6 +9,7 @@ import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TaskModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.beans.factory.annotation.Autowired; @@ -97,7 +98,8 @@ public class GetTaskSanityTests extends RestWorkflowTest .and().field("message").is(taskModel.getMessage()); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - + + @Bug(id = "MNT-17051") @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify involved user in a task without claim it gets the task with Rest API and response is successfull (200)") public void involvedUserWithoutClaimTaskGetsTask() throws Exception { From 6401dbb38300b518ab9ee7e2eff39fc45bc7954e Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Fri, 4 Nov 2016 17:23:01 +0200 Subject: [PATCH 0507/1491] add default suite --- .../workflow/deployments/DeleteDeploymentSanityTests.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java index fbcc090f2..fcf190048 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java @@ -38,12 +38,12 @@ public class DeleteDeploymentSanityTests extends RestWorkflowTest deploymentsApi.useRestClient(restClient); } - @Bug(id = "MNT-16996") - @Test(groups ={"extension-points"}) + @Bug(id = "MNT-16996") @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.SANITY, description = "Verify admin user deletes a specific deployment using REST API and status code is successful (204)") public void adminDeletesDeploymentWithSuccess() throws JsonToModelConversionException, Exception { + dataContent.assertExtensionAmpExists("alfresco-workflow-extension"); restClient.authenticateUser(adminUser); // The deployment with name "customWorkflowExtentionForRest.bpmn" is created by Workflow Extention Point deploymentsApi.getDeployments().assertThat() From 4e11d1f5063145efd9851e4ec182744c0a77cb27 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Tue, 8 Nov 2016 11:49:06 +0000 Subject: [PATCH 0508/1491] Added tests classes for demo --- .../rest/demo/workshop/RestApiDemoTests.java | 52 +++++++++++++++++++ .../demo/workshop/RestApiWorkshopTests.java | 43 +++++++++++++++ 2 files changed, 95 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/demo/workshop/RestApiDemoTests.java create mode 100644 e2e-test/java/org/alfresco/rest/demo/workshop/RestApiWorkshopTests.java diff --git a/e2e-test/java/org/alfresco/rest/demo/workshop/RestApiDemoTests.java b/e2e-test/java/org/alfresco/rest/demo/workshop/RestApiDemoTests.java new file mode 100644 index 000000000..ecb02a793 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/demo/workshop/RestApiDemoTests.java @@ -0,0 +1,52 @@ +package org.alfresco.rest.demo.workshop; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.requests.RestSitesApi; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.Test; + +public class RestApiDemoTests extends RestTest +{ + @Autowired + RestSitesApi sitesAPI; + + @Test + public void verifyGetSiteMembersRestApiCall() throws Exception + { + UserModel user = dataUser.createRandomTestUser(); + UserModel member = dataUser.createRandomTestUser(); + SiteModel site = dataSite.usingUser(user).createPublicRandomSite(); + dataUser.usingUser(user).addUserToSite(member, site, UserRole.SiteCollaborator); + + restClient.authenticateUser(user); + + sitesAPI.useRestClient(restClient); + sitesAPI.getSiteMembers(site).assertThat().entriesListIsNotEmpty() + .and().entriesListContains("id", member.getUsername()) + .and().entriesListContains("role", member.getUserRole().toString()); + + sitesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + + } + + @Test + public void verifyGetASiteMemberApiCall() throws Exception + { + UserModel user = dataUser.createRandomTestUser(); + UserModel member = dataUser.createRandomTestUser(); + SiteModel site = dataSite.usingUser(user).createPublicRandomSite(); + dataUser.usingUser(user).addUserToSite(member, site, UserRole.SiteCollaborator); + + sitesAPI.useRestClient(restClient); + restClient.authenticateUser(user); + sitesAPI.getSiteMember(site, member) + .assertThat().field("id").is(member.getUsername()) + .assertThat().field("role").is(member.getUserRole().toString()); + + restClient.assertStatusCodeIs(HttpStatus.OK); + } +} diff --git a/e2e-test/java/org/alfresco/rest/demo/workshop/RestApiWorkshopTests.java b/e2e-test/java/org/alfresco/rest/demo/workshop/RestApiWorkshopTests.java new file mode 100644 index 000000000..5d5ae8b5b --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/demo/workshop/RestApiWorkshopTests.java @@ -0,0 +1,43 @@ +package org.alfresco.rest.demo.workshop; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.requests.RestSitesApi; +import org.springframework.beans.factory.annotation.Autowired; +import org.testng.annotations.Test; + +/** + * + * Demo workshop for RestAPI test + * + */ +public class RestApiWorkshopTests extends RestTest +{ + @Autowired + RestSitesApi sitesAPI; + + @Test + public void verifyGetSitesRestApiCall() throws Exception + { + // creating a random user in repository + + // create a new random site using your UserModel from above + + // using "siteApi", call get "/sites" Rest API and verify created site is present + + // verify status is OK + + } + + @Test + public void verifyGetASiteRestApiCall() throws Exception + { + // creating a random user in repository + + // create a new random site using your UserModel from above + + // using "siteApi", call get "/sites/{siteId}" Rest API + // using "siteApi", verify created site is present + + // verify status is OK + } +} From f02cc9a99b79e1c70c267f10929b1d448dbbc07a Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Wed, 9 Nov 2016 09:27:07 +0000 Subject: [PATCH 0509/1491] Added the precondition needed for demo tests --- .../rest/demo/workshop/RestApiDemoTests.java | 43 ++++++++++--------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/demo/workshop/RestApiDemoTests.java b/e2e-test/java/org/alfresco/rest/demo/workshop/RestApiDemoTests.java index ecb02a793..ff94e8d90 100644 --- a/e2e-test/java/org/alfresco/rest/demo/workshop/RestApiDemoTests.java +++ b/e2e-test/java/org/alfresco/rest/demo/workshop/RestApiDemoTests.java @@ -6,47 +6,48 @@ import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; import org.testng.annotations.Test; public class RestApiDemoTests extends RestTest { @Autowired RestSitesApi sitesAPI; - + + /* + * Test steps: + * 1. create a user + * 2. create a site + * 3. create a second user + * 4. add the second user to site with a user role + * 5. call rest api call " GET sites/{siteId}/members" with first user authenticated + * Expected: the response contains the user added as a member to the site + */ @Test public void verifyGetSiteMembersRestApiCall() throws Exception { UserModel user = dataUser.createRandomTestUser(); - UserModel member = dataUser.createRandomTestUser(); SiteModel site = dataSite.usingUser(user).createPublicRandomSite(); + UserModel member = dataUser.createRandomTestUser(); dataUser.usingUser(user).addUserToSite(member, site, UserRole.SiteCollaborator); - restClient.authenticateUser(user); - - sitesAPI.useRestClient(restClient); - sitesAPI.getSiteMembers(site).assertThat().entriesListIsNotEmpty() - .and().entriesListContains("id", member.getUsername()) - .and().entriesListContains("role", member.getUserRole().toString()); - - sitesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); - } - + + /* + * Test steps: + * 1. create a user + * 2. create a site + * 3. create a second user + * 4. add the second user to site with a user role + * 5. call rest api call " GET sites/{siteId}/members/{personId}" with first user authenticated + * Expected: the response contains the user added as a member to the site + */ @Test public void verifyGetASiteMemberApiCall() throws Exception { UserModel user = dataUser.createRandomTestUser(); - UserModel member = dataUser.createRandomTestUser(); SiteModel site = dataSite.usingUser(user).createPublicRandomSite(); + UserModel member = dataUser.createRandomTestUser(); dataUser.usingUser(user).addUserToSite(member, site, UserRole.SiteCollaborator); - sitesAPI.useRestClient(restClient); - restClient.authenticateUser(user); - sitesAPI.getSiteMember(site, member) - .assertThat().field("id").is(member.getUsername()) - .assertThat().field("role").is(member.getUserRole().toString()); - - restClient.assertStatusCodeIs(HttpStatus.OK); } } From 4aa7b73f5075ed28917a5a90c95a8b889b081f6e Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Wed, 9 Nov 2016 09:42:27 +0000 Subject: [PATCH 0510/1491] updates --- .../java/org/alfresco/rest/demo/workshop/RestApiDemoTests.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/demo/workshop/RestApiDemoTests.java b/e2e-test/java/org/alfresco/rest/demo/workshop/RestApiDemoTests.java index ff94e8d90..950bda9de 100644 --- a/e2e-test/java/org/alfresco/rest/demo/workshop/RestApiDemoTests.java +++ b/e2e-test/java/org/alfresco/rest/demo/workshop/RestApiDemoTests.java @@ -29,6 +29,8 @@ public class RestApiDemoTests extends RestTest SiteModel site = dataSite.usingUser(user).createPublicRandomSite(); UserModel member = dataUser.createRandomTestUser(); dataUser.usingUser(user).addUserToSite(member, site, UserRole.SiteCollaborator); + + //add here code for step 5 } @@ -49,5 +51,6 @@ public class RestApiDemoTests extends RestTest UserModel member = dataUser.createRandomTestUser(); dataUser.usingUser(user).addUserToSite(member, site, UserRole.SiteCollaborator); + //add here code for step 5 } } From 51fc07dcf3e3ddb0c0ec39ffb2bcac6de7b17bd3 Mon Sep 17 00:00:00 2001 From: cagache Date: Thu, 10 Nov 2016 17:48:33 +0200 Subject: [PATCH 0511/1491] fixed NPEs, fixed tests --- .../rest/comments/UpdateCommentsSanityTests.java | 3 +-- .../people/AddSiteMembershipRequestSanityTests.java | 12 ++++++------ .../rest/sites/GetSiteContainerSanityTests.java | 2 +- .../alfresco/rest/tags/GetNodeTagsSanityTests.java | 9 +++------ 4 files changed, 11 insertions(+), 15 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java index 4b8a64cd4..28293d364 100644 --- a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java @@ -101,8 +101,7 @@ public class UpdateCommentsSanityTests extends RestTest public void collaboratorIsNotAbleToUpdateComment() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - commentsAPI.updateComment(document, commentModel, "This is the updated comment with Collaborator user") - .assertThat().field("content").is("This is the updated comment with Collaborator user"); + commentsAPI.updateComment(document, commentModel, "This is the updated comment with Collaborator user"); commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN) .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); diff --git a/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java index 47188c0fc..2bb833d3a 100644 --- a/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java @@ -56,7 +56,7 @@ public class AddSiteMembershipRequestSanityTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); peopleApi.addSiteMembershipRequest(newMember, siteModel) .assertThat().field("id").isNotEmpty() - .assertThat().field("title").is(siteModel.getTitle()); + .assertThat().field("site").isNotEmpty(); peopleApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.CREATED); } @@ -70,7 +70,7 @@ public class AddSiteMembershipRequestSanityTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); peopleApi.addSiteMembershipRequest(newMember, siteModel) .assertThat().field("id").isNotEmpty() - .assertThat().field("title").is(siteModel.getTitle()); + .assertThat().field("site").isNotEmpty(); peopleApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.CREATED); } @@ -84,7 +84,7 @@ public class AddSiteMembershipRequestSanityTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); peopleApi.addSiteMembershipRequest(newMember, siteModel) .assertThat().field("id").isNotEmpty() - .assertThat().field("title").is(siteModel.getTitle()); + .assertThat().field("site").isNotEmpty(); peopleApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.CREATED); } @@ -98,7 +98,7 @@ public class AddSiteMembershipRequestSanityTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); peopleApi.addSiteMembershipRequest(newMember, siteModel) .assertThat().field("id").isNotEmpty() - .assertThat().field("title").is(siteModel.getTitle()); + .assertThat().field("site").isNotEmpty(); peopleApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.CREATED); } @@ -112,7 +112,7 @@ public class AddSiteMembershipRequestSanityTests extends RestTest restClient.authenticateUser(adminUser); peopleApi.addSiteMembershipRequest(newMember, siteModel) .assertThat().field("id").isNotEmpty() - .assertThat().field("title").is(siteModel.getTitle()); + .assertThat().field("site").isNotEmpty(); peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } @@ -125,7 +125,7 @@ public class AddSiteMembershipRequestSanityTests extends RestTest restClient.authenticateUser(new UserModel("random user", "random password")); peopleApi.addSiteMembershipRequest(newMember, siteModel) .assertThat().field("id").isNotEmpty() - .assertThat().field("title").is(siteModel.getTitle()); + .assertThat().field("site").isNotEmpty(); peopleApi.usingRestWrapper() .assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java index eec7359c2..bcfea636c 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java @@ -108,11 +108,11 @@ public class GetSiteContainerSanityTests extends RestTest public void unauthenticatedUserIsNotAuthorizedToRetrieveSiteContainer() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + siteContainerModel = siteAPI.getSiteContainers(siteModel).getOneRandomEntry(); userModel = dataUser.createRandomTestUser(); userModel.setPassword("user wrong password"); dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); restClient.authenticateUser(userModel); - siteContainerModel = siteAPI.getSiteContainers(siteModel).getOneRandomEntry(); siteAPI.getSiteContainer(siteModel, siteContainerModel); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } diff --git a/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java index fbf45d164..a00c17664 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java @@ -8,10 +8,7 @@ import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.model.*; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; @@ -121,9 +118,9 @@ public class GetNodeTagsSanityTests extends RestTest public void unauthenticatedUserIsNotAbleToRetrieveNodeTags() throws JsonToModelConversionException, Exception { restClient.authenticateUser(new UserModel("random user", "random password")); - tagsAPI.getNodeTags(document).assertThat().entriesListContains("tag", tagValue.toLowerCase()); + tagsAPI.getNodeTags(document); tagsAPI.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + .assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(ErrorModel.AUTHENTICATION_FAILED); } } \ No newline at end of file From 55489c03a7248138bd3e36fdd9573d2688ecdd19 Mon Sep 17 00:00:00 2001 From: cagache Date: Fri, 11 Nov 2016 09:49:59 +0200 Subject: [PATCH 0512/1491] fixed npe which appeared due to DataContent changes --- .../org/alfresco/rest/ratings/DeleteRatingSanityTests.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java index 1f2ce7351..92ab73435 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java @@ -26,7 +26,6 @@ public class DeleteRatingSanityTests extends RestTest @Autowired RestRatingsApi ratingsApi; - private UserModel userModel; private SiteModel siteModel; private UserModel adminUser; private FolderModel folderModel; @@ -47,8 +46,8 @@ public class DeleteRatingSanityTests extends RestTest @BeforeMethod() public void setUp() throws DataPreparationException, Exception { - folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); } @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, From 3a0b6fdace64372e09b26bfc3804fcf2df0fa63b Mon Sep 17 00:00:00 2001 From: cagache Date: Fri, 11 Nov 2016 09:56:13 +0200 Subject: [PATCH 0513/1491] fixed npe. Now test is failing due to annotated bug. --- .../processes/AddProcessItemSanityTests.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemSanityTests.java index 59749ff16..b07e007c7 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemSanityTests.java @@ -83,18 +83,18 @@ public class AddProcessItemSanityTests extends RestWorkflowTest processModel = processesApi.getProcesses().getOneRandomEntry(); processItem = processesApi.addProcessItem(processModel, document3); processItem.assertThat().field("createdAt").isNotEmpty() - .and().field("size").is("19") - .and().field("createdBy").is(restClient.getTestUser().getUsername().toLowerCase()) - .and().field("modifiedAt").isNotEmpty() - .and().field("name").isNotEmpty() - .and().field("modifiedBy").is(restClient.getTestUser().getUsername().toLowerCase()) - .and().field("id").is(processModel.getId()) - .and().field("mimeType").is(processItem.getMimeType()); - + .and().field("size").is("19") + .and().field("createdBy").is(restClient.getTestUser().getUsername().toLowerCase()) + .and().field("modifiedAt").isNotEmpty() + .and().field("name").is(document3.getName()) + .and().field("modifiedBy").is(restClient.getTestUser().getUsername().toLowerCase()) + .and().field("id").isNotEmpty() + .and().field("mimeType").is(document3.getFileType().mimeType); + processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); processesApi.getProcessesItems(processModel) - .assertThat().entriesListContains("id", processItem.getId()).and() - .entriesListContains("name", document3.getName()); + .assertThat().entriesListContains("id", processItem.getId()).and() + .entriesListContains("name", document3.getName()); processItem = processesApi.addProcessItem(processModel, document3); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.BAD_REQUEST); } From 2355f5678b488f0880d16b060d99c727fc5eb8f9 Mon Sep 17 00:00:00 2001 From: cagache Date: Fri, 11 Nov 2016 10:38:06 +0200 Subject: [PATCH 0514/1491] updated scenario because is not correct to compare processItem with itself --- .../processes/AddProcessItemSanityTests.java | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemSanityTests.java index b07e007c7..b6fdba621 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemSanityTests.java @@ -7,10 +7,7 @@ import org.alfresco.rest.model.RestItemModel; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.rest.requests.RestProcessesApi; import org.alfresco.utility.data.DataUser; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.model.*; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; @@ -56,17 +53,18 @@ public class AddProcessItemSanityTests extends RestWorkflowTest public void addProcessItem() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUser); - document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + document2 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file content"); + dataContent.usingSite(siteModel).createContent(document2); processModel = processesApi.getProcesses().getOneRandomEntry(); processItem = processesApi.addProcessItem(processModel, document2); - processItem.assertThat().field("createdAt").is(processItem.getCreatedAt()) - .and().field("size").is(processItem.getSize()) - .and().field("createdBy").is(processItem.getCreatedBy()) - .and().field("modifiedAt").is(processItem.getModifiedAt()) - .and().field("name").is(processItem.getName()) - .and().field("modifiedBy").is(processItem.getModifiedBy()) - .and().field("id").is(processItem.getId()) - .and().field("mimeType").is(processItem.getMimeType()); + processItem.assertThat().field("createdAt").isNotEmpty() + .and().field("size").is(document2.getContent().length()) + .and().field("createdBy").is(restClient.getTestUser().getUsername().toLowerCase()) + .and().field("modifiedAt").isNotEmpty() + .and().field("name").is(document2.getName()) + .and().field("modifiedBy").is(restClient.getTestUser().getUsername().toLowerCase()) + .and().field("id").isNotEmpty() + .and().field("mimeType").is(document2.getFileType().mimeType); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); processesApi.getProcessesItems(processModel).assertThat().entriesListContains("id", processItem.getId()); From 0ecd207fc13f0262203fef913626a3eafd999f4b Mon Sep 17 00:00:00 2001 From: cagache Date: Fri, 11 Nov 2016 10:41:18 +0200 Subject: [PATCH 0515/1491] updated expected createdBy and modifiedBy --- .../workflow/processes/AddProcessItemSanityTests.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemSanityTests.java index b6fdba621..a1d2e114c 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemSanityTests.java @@ -59,10 +59,10 @@ public class AddProcessItemSanityTests extends RestWorkflowTest processItem = processesApi.addProcessItem(processModel, document2); processItem.assertThat().field("createdAt").isNotEmpty() .and().field("size").is(document2.getContent().length()) - .and().field("createdBy").is(restClient.getTestUser().getUsername().toLowerCase()) + .and().field("createdBy").is(adminUser.getUsername()) .and().field("modifiedAt").isNotEmpty() .and().field("name").is(document2.getName()) - .and().field("modifiedBy").is(restClient.getTestUser().getUsername().toLowerCase()) + .and().field("modifiedBy").is(adminUser.getUsername()) .and().field("id").isNotEmpty() .and().field("mimeType").is(document2.getFileType().mimeType); @@ -82,10 +82,10 @@ public class AddProcessItemSanityTests extends RestWorkflowTest processItem = processesApi.addProcessItem(processModel, document3); processItem.assertThat().field("createdAt").isNotEmpty() .and().field("size").is("19") - .and().field("createdBy").is(restClient.getTestUser().getUsername().toLowerCase()) + .and().field("createdBy").is(adminUser.getUsername()) .and().field("modifiedAt").isNotEmpty() .and().field("name").is(document3.getName()) - .and().field("modifiedBy").is(restClient.getTestUser().getUsername().toLowerCase()) + .and().field("modifiedBy").is(adminUser.getUsername()) .and().field("id").isNotEmpty() .and().field("mimeType").is(document3.getFileType().mimeType); From 157551c201631d3378a964cf942c38267c29cbab Mon Sep 17 00:00:00 2001 From: cagache Date: Fri, 11 Nov 2016 10:57:31 +0200 Subject: [PATCH 0516/1491] Fix npe. Now test is failing due to annotated bug. --- .../workflow/deployments/DeleteDeploymentSanityTests.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java index fcf190048..c099745b0 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java @@ -59,10 +59,10 @@ public class DeleteDeploymentSanityTests extends RestWorkflowTest executionType = ExecutionType.SANITY, description = "Verify admin user cannot delete an inexistent deployment using REST API and status code is successful (204)") public void adminCannotDeleteInexistentDeployment() throws JsonToModelConversionException, Exception { - deployment = new RestDeploymentModel(); - deployment.setId(String.valueOf(1000)); - restClient.authenticateUser(adminUser); + deployment = deploymentsApi.getDeployments().getOneRandomEntry(); + deployment.onModel().setId(String.valueOf(1000)); + deploymentsApi.deleteDeployment(deployment); deploymentsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); } From 305168515593dadc0bf4f667de849a1d176fbbd0 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Sat, 12 Nov 2016 20:30:38 +0200 Subject: [PATCH 0517/1491] up v2 --- .../java/org/alfresco/rest/MySampleDSL.java | 64 ++++++++++++++++ .../alfresco/rest/demo/SampleSitesTests.java | 6 +- .../favorites/AddFavoritesSanityTests.java | 12 +-- .../favorites/DeleteFavoritesSanityTests.java | 10 +-- .../favorites/GetFavoriteSanityTests.java | 7 +- .../favorites/GetFavoritesSanityTests.java | 10 +-- .../rest/sites/AddSiteMemberSanityTests.java | 18 ++--- .../sites/GetSiteContainerSanityTests.java | 12 +-- .../sites/GetSiteContainersSanityTests.java | 12 +-- .../rest/sites/GetSiteMembersSanityTests.java | 12 +-- .../rest/sites/GetSiteSanityTests.java | 69 +++++++++--------- .../rest/sites/GetSitesSanityTests.java | 73 +++++++++---------- .../sites/UpdateSiteMemberSanityTests.java | 18 ++--- e2e-test/resources/default.properties | 2 +- 14 files changed, 185 insertions(+), 140 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/MySampleDSL.java diff --git a/e2e-test/java/org/alfresco/rest/MySampleDSL.java b/e2e-test/java/org/alfresco/rest/MySampleDSL.java new file mode 100644 index 000000000..92375185c --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/MySampleDSL.java @@ -0,0 +1,64 @@ +package org.alfresco.rest; + +import org.alfresco.rest.core.RestProperties; +import org.alfresco.rest.core.RestWrapper; +import org.alfresco.utility.data.DataUser; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import com.jayway.restassured.RestAssured; + +@ContextConfiguration("classpath:alfresco-restapi-context.xml") +public class MySampleDSL extends AbstractTestNGSpringContextTests { + @Autowired + RestWrapper restAPI; + + @Autowired + DataUser dataUser; + + @Autowired + protected RestProperties restProperties; + + @BeforeClass + public void asd() { + RestAssured.baseURI = restProperties.envProperty().getTestServerUrl(); + RestAssured.port = restProperties.envProperty().getPort(); + RestAssured.basePath = restProperties.getRestBasePath(); + } + + @Test + public void something() throws Exception { + // GET /Sites//containers + + + restAPI.authenticateUser(dataUser.getAdminUser()).usingSite("workshop").getContainers().assertThat().entriesListIsNotEmpty(); + + +// restAPI.usingSite("hahaha").getContainers().assertThat().field("level1").field("level2").field("level3").is("b") +// restAPI.usingSite("hahaha").getContainers().assertThat().field("level3").is("a"); +// restAPI.usingSite("hahaha").getContainers().assertThat().listIsNotEmpty() +// .listContains(level) +// .statusCode().is(HttpStatus.OK); +// +// +// +// //GET /sites/{siteId}/containers/{containerId} +// +// restAPI.usingSite("haha").getContainer("c1").assertThat().file("folderId").is("jjsjsj"); +// .statusCode(). +// +// +// SiteModel site; +// String body = JsonBodyGenerator.siteMemberhipRequest("Please accept me", site, "New request"); +// restAPI.usingPeople(people).withBody(body).addSiteMembershipRequest(); +// +// +// +// +// restAPI.usingPeople(people).withBody(body).addSiteMembershipRequest().assertthat().statusCode().is().and().fiels +// restApi.getBodyResponse. + } +} diff --git a/e2e-test/java/org/alfresco/rest/demo/SampleSitesTests.java b/e2e-test/java/org/alfresco/rest/demo/SampleSitesTests.java index 50aa2e3af..9f87c674e 100644 --- a/e2e-test/java/org/alfresco/rest/demo/SampleSitesTests.java +++ b/e2e-test/java/org/alfresco/rest/demo/SampleSitesTests.java @@ -45,7 +45,7 @@ public class SampleSitesTests extends RestTest public void adminShouldGetSites() throws JsonToModelConversionException, Exception { siteAPI.getSite(siteModel); - siteAPI.usingRestWrapper() + restClient() .assertStatusCodeIs(HttpStatus.OK); } @@ -62,7 +62,7 @@ public class SampleSitesTests extends RestTest public void adminShouldRetrieveSites() throws JsonToModelConversionException, Exception { siteAPI.getSites(); - siteAPI.usingRestWrapper() + restClient() .assertStatusCodeIs(HttpStatus.OK); } @@ -81,7 +81,7 @@ public class SampleSitesTests extends RestTest UserModel testUser = dataUser.createRandomTestUser("testUser"); testUser.setUserRole(UserRole.SiteConsumer); siteAPI.addPerson(siteModel, testUser); - siteAPI.usingRestWrapper() + restClient() .assertStatusCodeIs(HttpStatus.CREATED); } diff --git a/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesSanityTests.java index 6740be9ef..4a3999c1c 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesSanityTests.java @@ -3,7 +3,6 @@ package org.alfresco.rest.favorites; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.requests.RestFavoritesApi; -import org.alfresco.rest.requests.RestSitesApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.DataUser.ListUserWithRoles; @@ -24,9 +23,6 @@ public class AddFavoritesSanityTests extends RestTest @Autowired RestFavoritesApi favoritesAPI; - @Autowired - RestSitesApi sitesApi; - @Autowired DataUser dataUser; @@ -37,12 +33,12 @@ public class AddFavoritesSanityTests extends RestTest @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception { - adminUserModel = dataUser.getAdminUser(); - restClient.authenticateUser(adminUserModel); + adminUserModel = dataUser.getAdminUser(); siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + favoritesAPI.useRestClient(restClient); - sitesApi.useRestClient(restClient); - siteModel.setGuid(sitesApi.getSite(siteModel).getGuid()); + + siteModel.setGuid(restClient.authenticateUser(adminUserModel).usingSite(siteModel).getSite().getGuid()); usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); diff --git a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoritesSanityTests.java index 851394dae..a59969e32 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoritesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoritesSanityTests.java @@ -3,7 +3,6 @@ package org.alfresco.rest.favorites; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.requests.RestFavoritesApi; -import org.alfresco.rest.requests.RestSitesApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.ErrorModel; @@ -24,9 +23,6 @@ public class DeleteFavoritesSanityTests extends RestTest @Autowired RestFavoritesApi favoritesAPI; - @Autowired - RestSitesApi sitesApi; - private UserModel adminUserModel; private SiteModel siteModel; private ListUserWithRoles usersWithRoles; @@ -35,12 +31,12 @@ public class DeleteFavoritesSanityTests extends RestTest public void dataPreparation() throws Exception { adminUserModel = dataUser.getAdminUser(); - restClient.authenticateUser(adminUserModel); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); favoritesAPI.useRestClient(restClient); - sitesApi.useRestClient(restClient); - siteModel.setGuid(sitesApi.getSite(siteModel).getGuid()); + + siteModel.setGuid(restClient.authenticateUser(adminUserModel).usingSite(siteModel).getSite().getGuid()); usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java index cbc5bbe07..be644034d 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java @@ -4,7 +4,6 @@ import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.requests.RestFavoritesApi; -import org.alfresco.rest.requests.RestSitesApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.ErrorModel; @@ -27,8 +26,6 @@ public class GetFavoriteSanityTests extends RestTest @Autowired RestFavoritesApi favoritesAPI; - @Autowired - RestSitesApi sitesApi; private UserModel adminUserModel; private SiteModel siteModel; @@ -46,8 +43,8 @@ public class GetFavoriteSanityTests extends RestTest folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); fileModel = dataContent.usingUser(adminUserModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); favoritesAPI.useRestClient(restClient); - sitesApi.useRestClient(restClient); - siteModel.setGuid(sitesApi.getSite(siteModel).getGuid()); + + siteModel.setGuid(restClient.authenticateUser(adminUserModel).usingSite(siteModel).getSite().getGuid()); usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java index e37ab506c..40d8a965f 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java @@ -4,7 +4,6 @@ import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.requests.RestFavoritesApi; -import org.alfresco.rest.requests.RestSitesApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.ErrorModel; @@ -28,9 +27,6 @@ public class GetFavoritesSanityTests extends RestTest @Autowired RestFavoritesApi favoritesAPI; - @Autowired - RestSitesApi sitesApi; - private UserModel adminUserModel; private SiteModel firstSiteModel; private SiteModel secondSiteModel; @@ -53,9 +49,9 @@ public class GetFavoritesSanityTests extends RestTest secondFileModel = dataContent.usingUser(adminUserModel).usingResource(firstFolderModel).createContent(DocumentType.TEXT_PLAIN); favoritesAPI.useRestClient(restClient); - sitesApi.useRestClient(restClient); - firstSiteModel.setGuid(sitesApi.getSite(firstSiteModel).getGuid()); - secondSiteModel.setGuid(sitesApi.getSite(secondSiteModel).getGuid()); + + firstSiteModel.setGuid(restClient.authenticateUser(adminUserModel).usingSite(firstSiteModel).getSite().getGuid()); + secondSiteModel.setGuid(restClient.authenticateUser(adminUserModel).usingSite(secondSiteModel).getSite().getGuid()); usersWithRoles = dataUser.addUsersWithRolesToSite(firstSiteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); diff --git a/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java index 4e8f17d29..43c9c7eb0 100644 --- a/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java @@ -46,7 +46,7 @@ public class AddSiteMemberSanityTests extends RestTest siteAPI.addPerson(siteModel, testUser) .assertThat().field("id").is(testUser.getUsername()) .and().field("role").is(testUser.getUserRole()); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + restClient().assertStatusCodeIs(HttpStatus.CREATED); } @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, @@ -57,8 +57,8 @@ public class AddSiteMemberSanityTests extends RestTest testUser.setUserRole(UserRole.SiteConsumer); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); siteAPI.addPerson(siteModel, testUser); - siteAPI.usingRestWrapper().assertLastError().containsSummary("Permission was denied"); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + restClient().assertLastError().containsSummary("Permission was denied"); + restClient().assertStatusCodeIs(HttpStatus.FORBIDDEN); } @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, @@ -69,8 +69,8 @@ public class AddSiteMemberSanityTests extends RestTest testUser.setUserRole(UserRole.SiteConsumer); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); siteAPI.addPerson(siteModel, testUser); - siteAPI.usingRestWrapper().assertLastError().containsSummary("Permission was denied"); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + restClient().assertLastError().containsSummary("Permission was denied"); + restClient().assertStatusCodeIs(HttpStatus.FORBIDDEN); } @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, @@ -81,8 +81,8 @@ public class AddSiteMemberSanityTests extends RestTest testUser.setUserRole(UserRole.SiteConsumer); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); siteAPI.addPerson(siteModel, testUser); - siteAPI.usingRestWrapper().assertLastError().containsSummary("Permission was denied"); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + restClient().assertLastError().containsSummary("Permission was denied"); + restClient().assertStatusCodeIs(HttpStatus.FORBIDDEN); } @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, @@ -95,7 +95,7 @@ public class AddSiteMemberSanityTests extends RestTest siteAPI.addPerson(siteModel, testUser) .and().field("id").is(testUser.getUsername()) .and().field("role").is(testUser.getUserRole()); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + restClient().assertStatusCodeIs(HttpStatus.CREATED); } @Bug(id="MNT-16904") @@ -107,6 +107,6 @@ public class AddSiteMemberSanityTests extends RestTest UserModel inexistentUser = new UserModel("inexistent user", "inexistent password"); restClient.authenticateUser(inexistentUser); siteAPI.addPerson(siteModel, testUser); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java index eec7359c2..2eac5c0c7 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java @@ -50,7 +50,7 @@ public class GetSiteContainerSanityTests extends RestTest siteAPI.getSiteContainer(siteModel, siteContainerModel) .assertThat().field("id").is(siteContainerModel.onModel().getId()) .and().field("folderId").is(siteContainerModel.onModel().getFolderId()); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient().assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, @@ -62,7 +62,7 @@ public class GetSiteContainerSanityTests extends RestTest siteAPI.getSiteContainer(siteModel, siteContainerModel) .and().field("id").is(siteContainerModel.onModel().getId()) .and().field("folderId").is(siteContainerModel.onModel().getFolderId()); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient().assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, @@ -74,7 +74,7 @@ public class GetSiteContainerSanityTests extends RestTest siteAPI.getSiteContainer(siteModel, siteContainerModel) .assertThat().field("id").is(siteContainerModel.onModel().getId()) .and().field("folderId").is(siteContainerModel.onModel().getFolderId()); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient().assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, @@ -86,7 +86,7 @@ public class GetSiteContainerSanityTests extends RestTest siteAPI.getSiteContainer(siteModel, siteContainerModel) .assertThat().field("id").is(siteContainerModel.onModel().getId()) .and().field("folderId").is(siteContainerModel.onModel().getFolderId()); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient().assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, @@ -98,7 +98,7 @@ public class GetSiteContainerSanityTests extends RestTest siteAPI.getSiteContainer(siteModel, siteContainerModel) .assertThat().field("id").is(siteContainerModel.onModel().getId()) .and().field("folderId").is(siteContainerModel.onModel().getFolderId()); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient().assertStatusCodeIs(HttpStatus.OK); } @@ -114,6 +114,6 @@ public class GetSiteContainerSanityTests extends RestTest restClient.authenticateUser(userModel); siteContainerModel = siteAPI.getSiteContainers(siteModel).getOneRandomEntry(); siteAPI.getSiteContainer(siteModel, siteContainerModel); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java index f2587f798..3c0dbc0fa 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java @@ -56,7 +56,7 @@ public class GetSiteContainersSanityTests extends RestTest .assertThat().entriesListIsNotEmpty() .assertThat().paginationExist() .and().paginationField("count").isNot("0"); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient().assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, @@ -68,7 +68,7 @@ public class GetSiteContainersSanityTests extends RestTest .assertThat().entriesListIsNotEmpty() .assertThat().paginationExist() .and().paginationField("count").isNot("0"); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient().assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, @@ -80,7 +80,7 @@ public class GetSiteContainersSanityTests extends RestTest .assertThat().entriesListIsNotEmpty() .assertThat().paginationExist() .and().paginationField("count").isNot("0"); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient().assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, @@ -92,7 +92,7 @@ public class GetSiteContainersSanityTests extends RestTest .assertThat().entriesListIsNotEmpty() .assertThat().paginationExist() .and().paginationField("count").isNot("0"); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient().assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, @@ -104,7 +104,7 @@ public class GetSiteContainersSanityTests extends RestTest .assertThat().entriesListIsNotEmpty() .assertThat().paginationExist() .and().paginationField("count").isNot("0"); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient().assertStatusCodeIs(HttpStatus.OK); } @Bug(id="MNT-16904") @@ -117,6 +117,6 @@ public class GetSiteContainersSanityTests extends RestTest dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); restClient.authenticateUser(userModel); siteAPI.getSiteContainers(siteModel); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java index 1e69878a6..f41f3d8d0 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java @@ -56,7 +56,7 @@ public class GetSiteMembersSanityTests extends RestTest siteAPI.getSiteMembers(siteModel).assertThat().entriesListIsNotEmpty() .and().entriesListContains("id", usersWithRoles.getOneUserWithRole(UserRole.SiteManager).getUsername()) .and().entriesListContains("role", usersWithRoles.getOneUserWithRole(UserRole.SiteManager).getUserRole().toString()); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient().assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, @@ -67,7 +67,7 @@ public class GetSiteMembersSanityTests extends RestTest siteAPI.getSiteMembers(siteModel).assertThat().entriesListIsNotEmpty().assertThat() .entriesListContains("id", usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator).getUsername()).and() .entriesListContains("role", usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator).getUserRole().toString()); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient().assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, @@ -78,7 +78,7 @@ public class GetSiteMembersSanityTests extends RestTest siteAPI.getSiteMembers(siteModel).assertThat().entriesListIsNotEmpty() .and().entriesListContains("id", usersWithRoles.getOneUserWithRole(UserRole.SiteContributor).getUsername()) .and().entriesListContains("role", usersWithRoles.getOneUserWithRole(UserRole.SiteContributor).getUserRole().toString()); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient().assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, @@ -89,7 +89,7 @@ public class GetSiteMembersSanityTests extends RestTest siteAPI.getSiteMembers(siteModel).assertThat().entriesListIsNotEmpty() .and().entriesListContains("id", usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer).getUsername()) .and().entriesListContains("role", usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer).getUserRole().toString()); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient().assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, @@ -100,7 +100,7 @@ public class GetSiteMembersSanityTests extends RestTest siteAPI.getSiteMembers(siteModel).assertThat().entriesListIsNotEmpty() .and().entriesListContains("id", adminUser.getUsername()) .when().assertThat().entriesListContains("role", "SiteManager"); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient().assertStatusCodeIs(HttpStatus.OK); } @Bug(id="MNT-16904") @@ -113,6 +113,6 @@ public class GetSiteMembersSanityTests extends RestTest dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); restClient.authenticateUser(userModel); siteAPI.getSiteMembers(siteModel); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteSanityTests.java index 08f8d45db..e7ebcef66 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteSanityTests.java @@ -2,7 +2,6 @@ package org.alfresco.rest.sites; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.requests.RestSitesApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataSite; import org.alfresco.utility.data.DataUser; @@ -29,9 +28,6 @@ public class GetSiteSanityTests extends RestTest @Autowired DataUser dataUser; - @Autowired - RestSitesApi siteAPI; - @Autowired DataSite dataSite; @@ -44,8 +40,7 @@ public class GetSiteSanityTests extends RestTest public void dataPreparation() throws DataPreparationException { adminUserModel = dataUser.getAdminUser(); - restClient.authenticateUser(adminUserModel); - siteAPI.useRestClient(restClient); + restClient.authenticateUser(adminUserModel); siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); } @@ -54,55 +49,61 @@ public class GetSiteSanityTests extends RestTest description = "Verify user with Manager role gets site information and gets status code OK (200)") public void getSiteWithManagerRole() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - siteAPI.getSite(siteModel) - .and().field("id").is(siteModel.getId()) - .and().field("title").is(siteModel.getTitle()); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .usingSite(siteModel) + .getSite() + .and().field("id").is(siteModel.getId()) + .and().field("title").is(siteModel.getTitle()); + + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify user with Collaborator role gets site information and gets status code OK (200)") public void getSiteWithCollaboratorRole() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - siteAPI.getSite(siteModel) - .and().field("id").is(siteModel.getId()) - .and().field("title").is(siteModel.getTitle()); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .usingSite(siteModel) + .getSite() + .and().field("id").is(siteModel.getId()) + .and().field("title").is(siteModel.getTitle()); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify user with Contributor role gets site information and gets status code OK (200)") public void getSiteWithContributorRole() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - siteAPI.getSite(siteModel) - .and().field("id").is(siteModel.getId()) - .and().field("title").is(siteModel.getTitle()); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) + .usingSite(siteModel) + .getSite() + .and().field("id").is(siteModel.getId()) + .and().field("title").is(siteModel.getTitle()); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role gets site information and gets status code OK (200)") public void getSiteWithConsumerRole() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - siteAPI.getSite(siteModel) - .and().field("id").is(siteModel.getId()) - .and().field("title").is(siteModel.getTitle()); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + .usingSite(siteModel) + .getSite() + .and().field("id").is(siteModel.getId()) + .and().field("title").is(siteModel.getTitle()); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify user with admin role gets site information and gets status code OK (200)") public void getSiteWithAdminRole() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(adminUserModel); - siteAPI.getSite(siteModel) - .and().field("id").is(siteModel.getId()) - .and().field("title").is(siteModel.getTitle()); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.authenticateUser(adminUserModel) + .usingSite(siteModel) + .getSite() + .and().field("id").is(siteModel.getId()) + .and().field("title").is(siteModel.getTitle()); + restClient.assertStatusCodeIs(HttpStatus.OK); } @Bug(id="MNT-16904") @@ -113,8 +114,8 @@ public class GetSiteSanityTests extends RestTest userModel = dataUser.createRandomTestUser(); userModel.setPassword("user wrong password"); dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); - restClient.authenticateUser(userModel); - siteAPI.getAllSites(); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.authenticateUser(userModel).withParams("maxItems=10000") + .getSites(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java index 4261aaa91..f8fb6163b 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java @@ -2,7 +2,6 @@ package org.alfresco.rest.sites; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.requests.RestSitesApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataSite; import org.alfresco.utility.data.DataUser; @@ -24,9 +23,6 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) public class GetSitesSanityTests extends RestTest { - @Autowired - RestSitesApi siteAPI; - @Autowired DataUser dataUser; @@ -42,8 +38,7 @@ public class GetSitesSanityTests extends RestTest public void dataPreparation() throws Exception { adminUserModel = dataUser.getAdminUser(); - restClient.authenticateUser(adminUserModel); - siteAPI.useRestClient(restClient); + restClient.authenticateUser(adminUserModel); siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); } @@ -52,24 +47,24 @@ public class GetSitesSanityTests extends RestTest public void managerIsAbleToRetrieveSites() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - siteAPI.getAllSites() - .assertThat().entriesListIsNotEmpty() - .assertThat().entriesListContains("id", siteModel.getId()) - .and().paginationExist(); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .getSites() + .assertThat().entriesListIsNotEmpty() + .assertThat().entriesListContains("id", siteModel.getId()) + .and().paginationExist(); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify user with Collaborator role gets sites information and gets status code OK (200)") public void collaboratorIsAbleToRetrieveSites() throws JsonToModelConversionException, Exception { - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - siteAPI.getAllSites().assertThat().entriesListIsNotEmpty() - .assertThat().entriesListContains("id", siteModel.getId()) - .and().paginationExist(); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .getSites().assertThat().entriesListIsNotEmpty() + .assertThat().entriesListContains("id", siteModel.getId()) + .and().paginationExist(); + + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, @@ -77,12 +72,12 @@ public class GetSitesSanityTests extends RestTest public void contributorIsAbleToRetrieveSites() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - siteAPI.getAllSites() - .assertThat().entriesListIsNotEmpty() - .assertThat().entriesListContains("id", siteModel.getId()) - .and().paginationExist(); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) + .getSites() + .assertThat().entriesListIsNotEmpty() + .assertThat().entriesListContains("id", siteModel.getId()) + .and().paginationExist(); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, @@ -90,24 +85,24 @@ public class GetSitesSanityTests extends RestTest public void consumerIsAbleToRetrieveSites() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - siteAPI.getAllSites() - .assertThat().entriesListIsNotEmpty() - .assertThat().entriesListContains("id", siteModel.getId()) - .and().paginationExist(); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + .getSites() + .assertThat().entriesListIsNotEmpty() + .assertThat().entriesListContains("id", siteModel.getId()) + .and().paginationExist(); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify user with Admin user gets sites information and gets status code OK (200)") public void adminUserIsAbleToRetrieveSites() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(adminUserModel); - siteAPI.getAllSites() - .assertThat().entriesListIsNotEmpty() - .assertThat().entriesListContains("id", siteModel.getId()) - .and().paginationExist(); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.authenticateUser(adminUserModel) + .getSites() + .assertThat().entriesListIsNotEmpty() + .assertThat().entriesListContains("id", siteModel.getId()) + .and().paginationExist(); + restClient.assertStatusCodeIs(HttpStatus.OK); } @Bug(id="MNT-16904") @@ -119,8 +114,8 @@ public class GetSitesSanityTests extends RestTest userModel = dataUser.createRandomTestUser(); userModel.setPassword("user wrong password"); dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); - restClient.authenticateUser(userModel); - siteAPI.getAllSites(); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.authenticateUser(userModel) + .getSites(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java index 02bc56501..487f81f40 100644 --- a/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java @@ -47,7 +47,7 @@ public class UpdateSiteMemberSanityTests extends RestTest siteAPI.updateSiteMember(siteModel, testUserModel) .assertThat().field("id").is(testUserModel.getUsername()) .and().field("role").is(testUserModel.getUserRole()); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient().assertStatusCodeIs(HttpStatus.OK); } @Bug(id="ACE-5444") @@ -58,9 +58,9 @@ public class UpdateSiteMemberSanityTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); testUserModel.setUserRole(UserRole.SiteCollaborator); siteAPI.updateSiteMember(siteModel, testUserModel); - siteAPI.usingRestWrapper().assertLastError() + restClient().assertLastError() .containsSummary(String.format("The current user does not have permissions to modify the membership details of the site %s.", siteModel.getTitle())); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + restClient().assertStatusCodeIs(HttpStatus.FORBIDDEN); } @Bug(id="ACE-5444") @@ -71,9 +71,9 @@ public class UpdateSiteMemberSanityTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); testUserModel.setUserRole(UserRole.SiteCollaborator); siteAPI.updateSiteMember(siteModel, testUserModel); - siteAPI.usingRestWrapper().assertLastError() + restClient().assertLastError() .containsSummary(String.format("The current user does not have permissions to modify the membership details of the site %s.", siteModel.getTitle())); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + restClient().assertStatusCodeIs(HttpStatus.FORBIDDEN); } @Bug(id="ACE-5444") @@ -84,9 +84,9 @@ public class UpdateSiteMemberSanityTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); testUserModel.setUserRole(UserRole.SiteCollaborator); siteAPI.updateSiteMember(siteModel, testUserModel); - siteAPI.usingRestWrapper().assertLastError() + restClient().assertLastError() .containsSummary(String.format("The current user does not have permissions to modify the membership details of the site %s.", siteModel.getTitle())); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + restClient().assertStatusCodeIs(HttpStatus.FORBIDDEN); } @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, @@ -98,7 +98,7 @@ public class UpdateSiteMemberSanityTests extends RestTest siteAPI.updateSiteMember(siteModel, testUserModel) .assertThat().field("id").is(testUserModel.getUsername()) .and().field("role").is(testUserModel.getUserRole()); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient().assertStatusCodeIs(HttpStatus.OK); } @Bug(id="MNT-16904") @@ -109,6 +109,6 @@ public class UpdateSiteMemberSanityTests extends RestTest restClient.authenticateUser(inexistentUser); testUserModel.setUserRole(UserRole.SiteCollaborator); siteAPI.updateSiteMember(siteModel, testUserModel); - siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } diff --git a/e2e-test/resources/default.properties b/e2e-test/resources/default.properties index 9c7036b09..9f87e0902 100644 --- a/e2e-test/resources/default.properties +++ b/e2e-test/resources/default.properties @@ -38,7 +38,7 @@ reports.path=./target/reports # in containers we cannot access directly JMX, so we will use http://jolokia.org agent # disabling this we will use direct JMX calls to server -jmx.useJolokiaAgent=true +jmx.useJolokiaAgent=false # # Database Section From ec793386d7daff8b04c6c159c0c1983280c5bf23 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Sun, 13 Nov 2016 17:23:22 +0200 Subject: [PATCH 0518/1491] up comments --- .../rest/comments/AddCommentSanityTests.java | 33 +++++------ .../rest/comments/AddCommentsSanityTests.java | 44 +++++++------- .../comments/DeleteCommentsSanityTests.java | 45 +++++++-------- .../rest/comments/GetCommentsSanityTests.java | 49 ++++++++-------- .../comments/UpdateCommentsSanityTests.java | 44 +++++++------- .../org/alfresco/rest/demo/RestDemoTests.java | 34 ++++------- .../rest/demo/SampleCommentsTests.java | 25 +++----- .../alfresco/rest/demo/SampleSitesTests.java | 2 +- .../rest/demo/workshop/RestApiDemoTests.java | 7 +-- .../demo/workshop/RestApiWorkshopTests.java | 7 +-- .../people/DeleteSiteMemberSanityTests.java | 41 ++++++------- .../rest/sites/AddSiteMemberSanityTests.java | 35 +++++------- .../sites/GetSiteContainerSanityTests.java | 36 +++++------- .../sites/GetSiteContainersSanityTests.java | 21 +++---- .../rest/sites/GetSiteMemberSanityTests.java | 36 +++++------- .../rest/sites/GetSiteMembersSanityTests.java | 43 +++++++------- .../sites/RemoveSiteMemberSanityTests.java | 57 +++++++++---------- .../sites/UpdateSiteMemberSanityTests.java | 20 +++---- 18 files changed, 243 insertions(+), 336 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java index 6c2ea0668..b3eb6cea5 100644 --- a/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java @@ -3,7 +3,6 @@ package org.alfresco.rest.comments; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.requests.RestCommentsApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.DataUser.ListUserWithRoles; @@ -22,10 +21,7 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) public class AddCommentSanityTests extends RestTest -{ - @Autowired - RestCommentsApi commentsAPI; - +{ @Autowired DataUser dataUser; @@ -39,8 +35,7 @@ public class AddCommentSanityTests extends RestTest { adminUserModel = dataUser.getAdminUser(); restClient.authenticateUser(adminUserModel); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - commentsAPI.useRestClient(restClient); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); @@ -51,10 +46,10 @@ public class AddCommentSanityTests extends RestTest { restClient.authenticateUser(adminUserModel); String newContent = "This is a new comment added by " + adminUserModel.getUsername(); - commentsAPI.addComment(document, newContent) + restClient.usingNode(document).addComment(newContent) .assertThat().field("content").isNotEmpty() .and().field("content").is(newContent); - commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + restClient.assertStatusCodeIs(HttpStatus.CREATED); } @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Manager user adds comments with Rest API and status code is 201") @@ -62,10 +57,10 @@ public class AddCommentSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); String contentSiteManger = "This is a new comment added by user with role: " + UserRole.SiteManager; - commentsAPI.addComment(document, contentSiteManger) + restClient.usingNode(document).addComment(contentSiteManger) .assertThat().field("content").isNotEmpty() .and().field("content").is(contentSiteManger); - commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + restClient.assertStatusCodeIs(HttpStatus.CREATED); } @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Contributor user adds comments with Rest API and status code is 201") @@ -73,10 +68,10 @@ public class AddCommentSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); String contentSiteContributor = "This is a new comment added by user with role" + UserRole.SiteContributor; - commentsAPI.addComment(document, contentSiteContributor) + restClient.usingNode(document).addComment(contentSiteContributor) .assertThat().field("content").isNotEmpty() .and().field("content").is(contentSiteContributor); - commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + restClient.assertStatusCodeIs(HttpStatus.CREATED); } @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user adds comments with Rest API and status code is 201") @@ -84,10 +79,10 @@ public class AddCommentSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); String contentSiteCollaborator = "This is a new comment added by user with role: " + UserRole.SiteCollaborator; - commentsAPI.addComment(document, contentSiteCollaborator) + restClient.usingNode(document).addComment(contentSiteCollaborator) .assertThat().field("content").isNotEmpty() .and().field("content").is(contentSiteCollaborator); - commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + restClient.assertStatusCodeIs(HttpStatus.CREATED); } @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Consumer user can't add comments with Rest API and status code is 403") @@ -95,8 +90,8 @@ public class AddCommentSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); String contentSiteConsumer = "This is a new comment added by user with role: " + UserRole.SiteConsumer; - commentsAPI.addComment(document, contentSiteConsumer); - commentsAPI.usingRestWrapper() + restClient.usingNode(document).addComment(contentSiteConsumer); + restClient .assertStatusCodeIs(HttpStatus.FORBIDDEN) .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @@ -106,8 +101,8 @@ public class AddCommentSanityTests extends RestTest public void unauthenticatedUserIsNotAbleToAddComment() throws JsonToModelConversionException, Exception { restClient.authenticateUser(new UserModel("random user", "random password")); - commentsAPI.addComment(document, "This is a new comment"); - commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.usingNode(document).addComment("This is a new comment"); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java index 12ade18c3..e8b84614c 100644 --- a/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java @@ -3,7 +3,6 @@ package org.alfresco.rest.comments; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.requests.RestCommentsApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.RandomData; @@ -27,8 +26,6 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) public class AddCommentsSanityTests extends RestTest { - @Autowired RestCommentsApi commentsAPI; - @Autowired DataUser dataUser; private UserModel adminUserModel; @@ -43,7 +40,7 @@ public class AddCommentsSanityTests extends RestTest adminUserModel = dataUser.getAdminUser(); restClient.authenticateUser(adminUserModel); siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - commentsAPI.useRestClient(restClient); + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); } @@ -59,60 +56,59 @@ public class AddCommentsSanityTests extends RestTest TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify admin user adds multiple comments with Rest API and status code is 201") public void adminIsAbleToAddComments() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(adminUserModel); - commentsAPI.addComments(document, comment1, comment2) + restClient.authenticateUser(adminUserModel) + .usingNode(document).addComments(comment1, comment2) .assertThat().entriesListIsNotEmpty() .and().entriesListContains("content", comment1) .and().entriesListContains("content", comment2); - commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + restClient.assertStatusCodeIs(HttpStatus.CREATED); } @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Manager user adds multiple comments with Rest API and status code is 201") public void managerIsAbleToAddComments() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - commentsAPI.addComments(document, comment1, comment2) + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .usingNode(document).addComments(comment1, comment2) .assertThat().entriesListIsNotEmpty() .and().entriesListContains("content", comment1) .and().entriesListContains("content", comment2); - commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + restClient.assertStatusCodeIs(HttpStatus.CREATED); } @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Contributor user adds multiple comments with Rest API and status code is 201") public void contributorIsAbleToAddComments() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - commentsAPI.addComments(document, comment1, comment2) + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) + .usingNode(document).addComments(comment1, comment2) .assertThat().entriesListIsNotEmpty() .and().entriesListContains("content", comment1) .and().entriesListContains("content", comment2); - commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + restClient.assertStatusCodeIs(HttpStatus.CREATED); } @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user adds multiple comments with Rest API and status code is 201") public void collaboratorIsAbleToAddComments() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - commentsAPI.addComments(document, comment1, comment2) + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .usingNode(document).addComments(comment1, comment2) .assertThat().paginationExist().and().entriesListIsNotEmpty() .and().entriesListContains("content", comment1) .and().entriesListContains("content", comment2); - commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + restClient.assertStatusCodeIs(HttpStatus.CREATED); } @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Consumer user adds multiple comments with Rest API and status code is 201") public void consumerIsAbleToAddComments() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - commentsAPI.addComments(document, comment1, comment2); - commentsAPI.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + .usingNode(document).addComments(comment1, comment2); + + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, @@ -120,8 +116,8 @@ public class AddCommentsSanityTests extends RestTest @Bug(id="MNT-16904") public void unauthenticatedUserIsNotAbleToAddComments() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(new UserModel("random user", "random password")); - commentsAPI.addComments(document, comment1, comment2); - commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.authenticateUser(new UserModel("random user", "random password")) + .usingNode(document).addComments(comment1, comment2); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java index 789129ac7..e965552f1 100644 --- a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java @@ -4,7 +4,7 @@ import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestCommentModel; -import org.alfresco.rest.requests.RestCommentsApi; +import org.alfresco.rest.requests.Node; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.DataUser.ListUserWithRoles; @@ -26,7 +26,7 @@ public class DeleteCommentsSanityTests extends RestTest { @Autowired - RestCommentsApi commentsAPI; + Node commentsAPI; @Autowired DataUser dataUser; @@ -43,19 +43,16 @@ public class DeleteCommentsSanityTests extends RestTest { adminUserModel = dataUser.getAdminUser(); restClient.authenticateUser(adminUserModel); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - commentsAPI.useRestClient(restClient); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); } @BeforeMethod(alwaysRun=true) public void addCommentToDocument() throws Exception { - restClient.authenticateUser(adminUserModel); - commentsAPI.useRestClient(restClient); - comment = commentsAPI.addComment(document, "This is a new comment"); + restClient.authenticateUser(adminUserModel); + comment = restClient.usingNode(document).addComment("This is a new comment"); } @TestRail(section = { TestGroup.REST_API, @@ -63,8 +60,8 @@ public class DeleteCommentsSanityTests extends RestTest public void adminIsAbleToDeleteComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); - commentsAPI.deleteComment(document, comment); - commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.usingNode(document).deleteComment(comment); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } @TestRail(section = { TestGroup.REST_API, @@ -72,8 +69,8 @@ public class DeleteCommentsSanityTests extends RestTest public void managerIsAbleToDeleteComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - commentsAPI.deleteComment(document, comment); - commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.usingNode(document).deleteComment(comment); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } @TestRail(section = { TestGroup.REST_API, @@ -81,8 +78,8 @@ public class DeleteCommentsSanityTests extends RestTest public void collaboratorIsNotAbleToDeleteComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - commentsAPI.deleteComment(document, comment); - commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN) + restClient.usingNode(document).deleteComment(comment); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @@ -91,10 +88,9 @@ public class DeleteCommentsSanityTests extends RestTest public void contributorIsNotAbleToDeleteComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - commentsAPI.deleteComment(document, comment); - commentsAPI.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + restClient.usingNode(document).deleteComment(comment); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, @@ -102,10 +98,9 @@ public class DeleteCommentsSanityTests extends RestTest public void consumerIsNotAbleToDeleteComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - commentsAPI.deleteComment(document, comment); - commentsAPI.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + restClient.usingNode(document).deleteComment(comment); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, @@ -114,9 +109,7 @@ public class DeleteCommentsSanityTests extends RestTest { UserModel nonexistentModel = new UserModel("nonexistentUser", "nonexistentPassword"); restClient.authenticateUser(nonexistentModel); - commentsAPI.deleteComment(document, comment); - commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); - + restClient.usingNode(document).deleteComment(comment); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } - } diff --git a/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java index fdc16425d..672d81d78 100644 --- a/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java @@ -3,7 +3,7 @@ package org.alfresco.rest.comments; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.requests.RestCommentsApi; +import org.alfresco.rest.requests.Node; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.DataUser.ListUserWithRoles; @@ -23,7 +23,7 @@ import org.testng.annotations.Test; public class GetCommentsSanityTests extends RestTest { @Autowired - RestCommentsApi commentsAPI; + Node commentsAPI; @Autowired DataUser dataUser; @@ -41,11 +41,10 @@ public class GetCommentsSanityTests extends RestTest { adminUserModel = dataUser.getAdminUser(); restClient.authenticateUser(adminUserModel); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - commentsAPI.useRestClient(restClient); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); content = "This is a new comment"; - commentsAPI.addComment(document, content); + restClient.usingNode(document).addComment(content); usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); } @@ -55,8 +54,8 @@ public class GetCommentsSanityTests extends RestTest public void adminIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); - commentsAPI.getNodeComments(document); - commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.usingNode(document).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section={TestGroup.REST_API, TestGroup.SANITY}, executionType= ExecutionType.SANITY, @@ -64,10 +63,10 @@ public class GetCommentsSanityTests extends RestTest public void managerIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - commentsAPI.getNodeComments(document) + restClient.usingNode(document).getNodeComments() .assertThat().entriesListContains("content", content); - commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section={TestGroup.REST_API, TestGroup.SANITY}, executionType= ExecutionType.SANITY, @@ -75,10 +74,10 @@ public class GetCommentsSanityTests extends RestTest public void contributorIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - commentsAPI.getNodeComments(document) + restClient.usingNode(document).getNodeComments() .assertThat().entriesListContains("content", content); - commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section={TestGroup.REST_API, TestGroup.SANITY}, executionType= ExecutionType.SANITY, @@ -86,9 +85,9 @@ public class GetCommentsSanityTests extends RestTest public void collaboratorIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - commentsAPI.getNodeComments(document) + restClient.usingNode(document).getNodeComments() .assertThat().entriesListContains("content", content); - commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section={TestGroup.REST_API, TestGroup.SANITY}, executionType= ExecutionType.SANITY, @@ -96,9 +95,9 @@ public class GetCommentsSanityTests extends RestTest public void consumerIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - commentsAPI.getNodeComments(document) + restClient.usingNode(document).getNodeComments() .assertThat().entriesListContains("content", content); - commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section={TestGroup.REST_API, TestGroup.SANITY}, executionType= ExecutionType.SANITY, @@ -108,8 +107,8 @@ public class GetCommentsSanityTests extends RestTest { UserModel nonexistentModel = new UserModel("nonexistentUser", "nonexistentPassword"); restClient.authenticateUser(nonexistentModel); - commentsAPI.getNodeComments(document); - commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.usingNode(document).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } @TestRail(section={TestGroup.REST_API, TestGroup.SANITY}, executionType= ExecutionType.SANITY, @@ -119,13 +118,13 @@ public class GetCommentsSanityTests extends RestTest userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); restClient.authenticateUser(userModel); String contentManager = "This is a new comment added by " + userModel.getUsername(); - commentsAPI.addComment(document,contentManager); - commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + restClient.usingNode(document).addComment(contentManager); + restClient.assertStatusCodeIs(HttpStatus.CREATED); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - commentsAPI.getNodeComments(document) + restClient.usingNode(document).getNodeComments() .assertThat().entriesListContains("content", contentManager); - commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section={TestGroup.REST_API, TestGroup.SANITY}, executionType= ExecutionType.SANITY, @@ -135,12 +134,12 @@ public class GetCommentsSanityTests extends RestTest userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); restClient.authenticateUser(userModel); String contentCollaborator = "This is a new comment added by " + userModel.getUsername(); - commentsAPI.addComment(document, contentCollaborator); - commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + restClient.usingNode(document).addComment(contentCollaborator); + restClient.assertStatusCodeIs(HttpStatus.CREATED); restClient.authenticateUser(adminUserModel); - commentsAPI.getNodeComments(document) + restClient.usingNode(document).getNodeComments() .assertThat().entriesListContains("content", contentCollaborator); - commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.assertStatusCodeIs(HttpStatus.OK); } } diff --git a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java index 28293d364..4e3a071a5 100644 --- a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java @@ -4,7 +4,7 @@ import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestCommentModel; -import org.alfresco.rest.requests.RestCommentsApi; +import org.alfresco.rest.requests.Node; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.DataUser.ListUserWithRoles; @@ -26,7 +26,7 @@ import org.testng.annotations.Test; public class UpdateCommentsSanityTests extends RestTest { @Autowired - RestCommentsApi commentsAPI; + Node commentsAPI; @Autowired DataUser dataUser; @@ -43,9 +43,9 @@ public class UpdateCommentsSanityTests extends RestTest adminUserModel = dataUser.getAdminUser(); restClient.authenticateUser(adminUserModel); siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - commentsAPI.useRestClient(restClient); + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - commentModel = commentsAPI.addComment(document, "This is a new comment"); + commentModel = restClient.usingNode(document).addComment("This is a new comment"); usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); } @@ -56,10 +56,10 @@ public class UpdateCommentsSanityTests extends RestTest { restClient.authenticateUser(adminUserModel); String updatedContent = "This is the updated comment with admin user"; - commentsAPI.updateComment(document, commentModel, updatedContent) + restClient.usingNode(document).updateComment(commentModel, updatedContent) .assertThat().field("content").isNotEmpty() .and().field("content").is(updatedContent); - commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, @@ -67,11 +67,11 @@ public class UpdateCommentsSanityTests extends RestTest public void managerIsAbleToUpdateComment() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - commentsAPI.updateComment(document, commentModel, "This is the updated comment with Manager user") + restClient.usingNode(document).updateComment(commentModel, "This is the updated comment with Manager user") .and().field("content").is("This is the updated comment with Manager user") .and().field("canEdit").is(true) .and().field("canDelete").is(true); - commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, @@ -80,8 +80,8 @@ public class UpdateCommentsSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); String updatedContent = "This is the updated comment with Contributor user"; - commentsAPI.updateComment(document, commentModel, updatedContent); - commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN) + restClient.usingNode(document).updateComment(commentModel, updatedContent); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @@ -90,8 +90,8 @@ public class UpdateCommentsSanityTests extends RestTest public void consumerIsNotAbleToUpdateComment() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - commentsAPI.updateComment(document, commentModel, "This is the updated comment with Consumer user"); - commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN) + restClient.usingNode(document).updateComment(commentModel, "This is the updated comment with Consumer user"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @@ -101,9 +101,8 @@ public class UpdateCommentsSanityTests extends RestTest public void collaboratorIsNotAbleToUpdateComment() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - commentsAPI.updateComment(document, commentModel, "This is the updated comment with Collaborator user"); - - commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN) + restClient.usingNode(document).updateComment(commentModel, "This is the updated comment with Collaborator user"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @@ -113,9 +112,9 @@ public class UpdateCommentsSanityTests extends RestTest public void unauthenticatedUserIsNotAbleToUpdateComment() throws JsonToModelConversionException, Exception { UserModel incorrectUserModel = new UserModel("userName", "password"); - restClient.authenticateUser(incorrectUserModel); - commentsAPI.getNodeComments(document); - commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.authenticateUser(incorrectUserModel) + .usingNode(document).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } @TestRail(section = { TestGroup.REST_API, TestGroup.SANITY }, executionType = ExecutionType.SANITY, description = "Verify update comment with inexistent nodeId returns status code 404") @@ -125,8 +124,8 @@ public class UpdateCommentsSanityTests extends RestTest FolderModel content = FolderModel.getRandomFolderModel(); content.setNodeRef("node ref that does not exist"); - commentsAPI.updateComment(content, commentModel, "This is the updated comment."); - commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND) + restClient.usingNode(content).updateComment(commentModel, "This is the updated comment."); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) .assertLastError().containsSummary("node ref that does not exist was not found"); } @@ -138,9 +137,8 @@ public class UpdateCommentsSanityTests extends RestTest RestCommentModel comment = new RestCommentModel(); String id = "comment id that does not exist"; comment.setId(id); - commentsAPI.updateComment(document, comment, "This is the updated comment."); - - commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND) + restClient.usingNode(document).updateComment(comment, "This is the updated comment."); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, id)); } diff --git a/e2e-test/java/org/alfresco/rest/demo/RestDemoTests.java b/e2e-test/java/org/alfresco/rest/demo/RestDemoTests.java index 85dc6c271..9ce3b5b10 100644 --- a/e2e-test/java/org/alfresco/rest/demo/RestDemoTests.java +++ b/e2e-test/java/org/alfresco/rest/demo/RestDemoTests.java @@ -3,15 +3,12 @@ package org.alfresco.rest.demo; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.requests.RestCommentsApi; -import org.alfresco.rest.requests.RestSitesApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.social.alfresco.api.entities.Role; import org.springframework.social.alfresco.api.entities.Site.Visibility; @@ -20,13 +17,7 @@ import org.testng.annotations.Test; @Test(groups = { "demo" }) public class RestDemoTests extends RestTest -{ - @Autowired - RestSitesApi sitesApi; - - @Autowired - RestCommentsApi commentsAPI; - +{ private UserModel userModel; private SiteModel siteModel; @@ -35,10 +26,7 @@ public class RestDemoTests extends RestTest { userModel = dataUser.getAdminUser(); siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - restClient.authenticateUser(userModel); - - sitesApi.useRestClient(restClient); - commentsAPI.useRestClient(restClient); + restClient.authenticateUser(userModel); } /** @@ -77,11 +65,10 @@ public class RestDemoTests extends RestTest .usingResource(FolderModel.getSharedFolderModel()) .createContent(DocumentType.TEXT_PLAIN); // add new comment - commentsAPI.addComment(fileModel, "This is a new comment"); - commentsAPI.getNodeComments(fileModel) + restClient.usingNode(fileModel).addComment("This is a new comment"); + restClient.usingNode(fileModel).getNodeComments() .assertThat().entriesListIsNotEmpty().and() .entriesListContains("content", "This is a new comment"); - } /** @@ -100,21 +87,20 @@ public class RestDemoTests extends RestTest testUser.setUserRole(UserRole.SiteConsumer); // add user as Consumer to site - sitesApi.addPerson(siteModel, testUser); - sitesApi.getSiteMembers(siteModel).assertThat().entriesListContains("id", testUser.getUsername()) + restClient.usingSite(siteModel).addPerson(testUser); + restClient.usingSite(siteModel).getSiteMembers().assertThat().entriesListContains("id", testUser.getUsername()) .when().getSiteMember(testUser.getUsername()) .assertSiteMemberHasRole(Role.SiteConsumer); // update site member to Manager testUser.setUserRole(UserRole.SiteCollaborator); - sitesApi.updateSiteMember(siteModel, testUser); - sitesApi.getSiteMembers(siteModel).and() + restClient.usingSite(siteModel).updateSiteMember(testUser); + restClient.usingSite(siteModel).getSiteMembers().and() .entriesListContains("id", testUser.getUsername()) .when().getSiteMember(testUser.getUsername()) .assertSiteMemberHasRole(Role.SiteCollaborator); - sitesApi.deleteSiteMember(siteModel, testUser); - sitesApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.usingSite(siteModel).deleteSiteMember(testUser); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/demo/SampleCommentsTests.java b/e2e-test/java/org/alfresco/rest/demo/SampleCommentsTests.java index cd96582da..d8292d40b 100644 --- a/e2e-test/java/org/alfresco/rest/demo/SampleCommentsTests.java +++ b/e2e-test/java/org/alfresco/rest/demo/SampleCommentsTests.java @@ -4,24 +4,19 @@ import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestCommentModel; -import org.alfresco.rest.requests.RestCommentsApi; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @Test(groups = { "demo" }) public class SampleCommentsTests extends RestTest -{ - @Autowired - RestCommentsApi commentsAPI; - +{ private UserModel userModel; private FolderModel folderModel; private SiteModel siteModel; @@ -33,9 +28,7 @@ public class SampleCommentsTests extends RestTest userModel = dataUser.getAdminUser(); siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - restClient.authenticateUser(userModel); - commentsAPI.useRestClient(restClient); - + restClient.authenticateUser(userModel); document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); } @@ -43,27 +36,25 @@ public class SampleCommentsTests extends RestTest description= "Verify admin user adds comments with Rest API and status code is 200") public void admiShouldAddComment() throws JsonToModelConversionException, Exception { - commentsAPI.addComment(document, "This is a new comment"); - commentsAPI.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.CREATED); + restClient.usingNode(document).addComment("This is a new comment"); + restClient.assertStatusCodeIs(HttpStatus.CREATED); } @TestRail(section={"demo", "sample-section"}, executionType= ExecutionType.SANITY, description= "Verify admin user gets comments with Rest API and status code is 200") public void admiShouldRetrieveComments() throws Exception { - commentsAPI.getNodeComments(document); - commentsAPI.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.OK); + restClient.usingNode(document).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section={"demo", "sample-section"}, executionType= ExecutionType.SANITY, description= "Verify admin user updates comments with Rest API") public void adminShouldUpdateComment() throws JsonToModelConversionException, Exception { - RestCommentModel commentModel = commentsAPI.addComment(document, "This is a new comment"); + RestCommentModel commentModel = restClient.usingNode(document).addComment("This is a new comment"); - commentsAPI.updateComment(document, commentModel, "This is the updated comment with Collaborator user") + restClient.usingNode(document).updateComment(commentModel, "This is the updated comment with Collaborator user") .assertThat().field("content").is("This is the updated comment with Collaborator user"); } diff --git a/e2e-test/java/org/alfresco/rest/demo/SampleSitesTests.java b/e2e-test/java/org/alfresco/rest/demo/SampleSitesTests.java index c777dba8b..0c6c3cf47 100644 --- a/e2e-test/java/org/alfresco/rest/demo/SampleSitesTests.java +++ b/e2e-test/java/org/alfresco/rest/demo/SampleSitesTests.java @@ -63,7 +63,7 @@ public class SampleSitesTests extends RestTest { UserModel testUser = dataUser.createRandomTestUser("testUser"); testUser.setUserRole(UserRole.SiteConsumer); - siteAPI.addPerson(siteModel, testUser); + restClient.usingSite(siteModel).addPerson(testUser); restClient.assertStatusCodeIs(HttpStatus.CREATED); } diff --git a/e2e-test/java/org/alfresco/rest/demo/workshop/RestApiDemoTests.java b/e2e-test/java/org/alfresco/rest/demo/workshop/RestApiDemoTests.java index 950bda9de..1b07b14cb 100644 --- a/e2e-test/java/org/alfresco/rest/demo/workshop/RestApiDemoTests.java +++ b/e2e-test/java/org/alfresco/rest/demo/workshop/RestApiDemoTests.java @@ -1,18 +1,13 @@ package org.alfresco.rest.demo.workshop; import org.alfresco.rest.RestTest; -import org.alfresco.rest.requests.RestSitesApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; -import org.springframework.beans.factory.annotation.Autowired; import org.testng.annotations.Test; public class RestApiDemoTests extends RestTest -{ - @Autowired - RestSitesApi sitesAPI; - +{ /* * Test steps: * 1. create a user diff --git a/e2e-test/java/org/alfresco/rest/demo/workshop/RestApiWorkshopTests.java b/e2e-test/java/org/alfresco/rest/demo/workshop/RestApiWorkshopTests.java index 5d5ae8b5b..f863bddf2 100644 --- a/e2e-test/java/org/alfresco/rest/demo/workshop/RestApiWorkshopTests.java +++ b/e2e-test/java/org/alfresco/rest/demo/workshop/RestApiWorkshopTests.java @@ -1,8 +1,6 @@ package org.alfresco.rest.demo.workshop; import org.alfresco.rest.RestTest; -import org.alfresco.rest.requests.RestSitesApi; -import org.springframework.beans.factory.annotation.Autowired; import org.testng.annotations.Test; /** @@ -11,10 +9,7 @@ import org.testng.annotations.Test; * */ public class RestApiWorkshopTests extends RestTest -{ - @Autowired - RestSitesApi sitesAPI; - +{ @Test public void verifyGetSitesRestApiCall() throws Exception { diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java index db4f020cd..069e88489 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java @@ -3,7 +3,6 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.requests.RestPeopleApi; -import org.alfresco.rest.requests.RestSitesApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataSite; import org.alfresco.utility.data.DataUser; @@ -27,9 +26,6 @@ public class DeleteSiteMemberSanityTests extends RestTest @Autowired RestPeopleApi peopleApi; - @Autowired - RestSitesApi sitesApi; - @Autowired DataUser dataUser; @@ -49,8 +45,7 @@ public class DeleteSiteMemberSanityTests extends RestTest usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); - peopleApi.useRestClient(restClient); - sitesApi.useRestClient(restClient); + peopleApi.useRestClient(restClient); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -60,12 +55,11 @@ public class DeleteSiteMemberSanityTests extends RestTest { UserModel newUser = dataUser.createRandomTestUser("testUser"); newUser.setUserRole(UserRole.SiteCollaborator); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - sitesApi.addPerson(siteModel, newUser); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .usingSite(siteModel).addPerson(newUser); peopleApi.deleteSiteMember(newUser, siteModel); - sitesApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -75,12 +69,11 @@ public class DeleteSiteMemberSanityTests extends RestTest { UserModel newUser = dataUser.createRandomTestUser("testUser"); newUser.setUserRole(UserRole.SiteCollaborator); - restClient.authenticateUser(adminUser); - sitesApi.addPerson(siteModel, newUser); + restClient.authenticateUser(adminUser) + .usingSite(siteModel).addPerson(newUser); peopleApi.deleteSiteMember(newUser, siteModel); - sitesApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -91,12 +84,12 @@ public class DeleteSiteMemberSanityTests extends RestTest { UserModel newUser = dataUser.createRandomTestUser("testUser"); newUser.setUserRole(UserRole.SiteCollaborator); - restClient.authenticateUser(adminUser); - sitesApi.addPerson(siteModel, newUser); + restClient.authenticateUser(adminUser) + .usingSite(siteModel).addPerson(newUser); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); peopleApi.deleteSiteMember(newUser, siteModel); - sitesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN) + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @@ -108,12 +101,12 @@ public class DeleteSiteMemberSanityTests extends RestTest { UserModel newUser = dataUser.createRandomTestUser("testUser"); newUser.setUserRole(UserRole.SiteCollaborator); - restClient.authenticateUser(adminUser); - sitesApi.addPerson(siteModel, newUser); + restClient.authenticateUser(adminUser) + .usingSite(siteModel).addPerson(newUser); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); peopleApi.deleteSiteMember(newUser, siteModel); - sitesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN) + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @@ -125,12 +118,12 @@ public class DeleteSiteMemberSanityTests extends RestTest { UserModel newUser = dataUser.createRandomTestUser("testUser"); newUser.setUserRole(UserRole.SiteCollaborator); - restClient.authenticateUser(adminUser); - sitesApi.addPerson(siteModel, newUser); + restClient.authenticateUser(adminUser) + .usingSite(siteModel).addPerson(newUser); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); peopleApi.deleteSiteMember(newUser, siteModel); - sitesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN) + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @@ -142,6 +135,6 @@ public class DeleteSiteMemberSanityTests extends RestTest restClient.authenticateUser(new UserModel("random user", "random password")); peopleApi.deleteSiteMember(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer), siteModel); - sitesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java index ce3d4bac9..1355d4f39 100644 --- a/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java @@ -1,7 +1,6 @@ package org.alfresco.rest.sites; import org.alfresco.rest.RestTest; -import org.alfresco.rest.requests.RestSitesApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.SiteModel; @@ -10,7 +9,6 @@ import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -18,9 +16,6 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) public class AddSiteMemberSanityTests extends RestTest { - @Autowired - RestSitesApi siteAPI; - private UserModel adminUserModel; private SiteModel siteModel; private ListUserWithRoles usersWithRoles; @@ -28,8 +23,7 @@ public class AddSiteMemberSanityTests extends RestTest @BeforeClass(alwaysRun=true) public void dataPreparation() throws Exception { - adminUserModel = dataUser.getAdminUser(); - siteAPI.useRestClient(restClient); + adminUserModel = dataUser.getAdminUser(); siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); @@ -43,7 +37,7 @@ public class AddSiteMemberSanityTests extends RestTest UserModel testUser = dataUser.createRandomTestUser("testUser"); testUser.setUserRole(UserRole.SiteConsumer); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - siteAPI.addPerson(siteModel, testUser) + restClient.usingSite(siteModel).addPerson(testUser) .assertThat().field("id").is(testUser.getUsername()) .and().field("role").is(testUser.getUserRole()); restClient.assertStatusCodeIs(HttpStatus.CREATED); @@ -55,8 +49,9 @@ public class AddSiteMemberSanityTests extends RestTest { UserModel testUser = dataUser.createRandomTestUser("testUser"); testUser.setUserRole(UserRole.SiteConsumer); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - siteAPI.addPerson(siteModel, testUser); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .usingSite(siteModel).addPerson(testUser); + restClient.assertLastError().containsSummary("Permission was denied"); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); } @@ -67,8 +62,8 @@ public class AddSiteMemberSanityTests extends RestTest { UserModel testUser = dataUser.createRandomTestUser("testUser"); testUser.setUserRole(UserRole.SiteConsumer); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - siteAPI.addPerson(siteModel, testUser); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) + .usingSite(siteModel).addPerson(testUser); restClient.assertLastError().containsSummary("Permission was denied"); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); } @@ -79,8 +74,8 @@ public class AddSiteMemberSanityTests extends RestTest { UserModel testUser = dataUser.createRandomTestUser("testUser"); testUser.setUserRole(UserRole.SiteConsumer); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - siteAPI.addPerson(siteModel, testUser); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + .usingSite(siteModel).addPerson(testUser); restClient.assertLastError().containsSummary("Permission was denied"); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); } @@ -91,10 +86,10 @@ public class AddSiteMemberSanityTests extends RestTest { UserModel testUser = dataUser.createRandomTestUser("testUser"); testUser.setUserRole(UserRole.SiteConsumer); - restClient.authenticateUser(adminUserModel); - siteAPI.addPerson(siteModel, testUser) - .and().field("id").is(testUser.getUsername()) - .and().field("role").is(testUser.getUserRole()); + restClient.authenticateUser(adminUserModel) + .usingSite(siteModel).addPerson(testUser) + .and().field("id").is(testUser.getUsername()) + .and().field("role").is(testUser.getUserRole()); restClient.assertStatusCodeIs(HttpStatus.CREATED); } @@ -105,8 +100,8 @@ public class AddSiteMemberSanityTests extends RestTest UserModel testUser = dataUser.createRandomTestUser("testUser"); testUser.setUserRole(UserRole.SiteConsumer); UserModel inexistentUser = new UserModel("inexistent user", "inexistent password"); - restClient.authenticateUser(inexistentUser); - siteAPI.addPerson(siteModel, testUser); + restClient.authenticateUser(inexistentUser) + .usingSite(siteModel).addPerson(testUser); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java index a170a815b..b5a76fac5 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java @@ -2,7 +2,6 @@ package org.alfresco.rest.sites; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestSiteContainerModel; -import org.alfresco.rest.requests.RestSitesApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.SiteModel; @@ -11,7 +10,6 @@ import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -21,10 +19,7 @@ import org.testng.annotations.Test; */ @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) public class GetSiteContainerSanityTests extends RestTest -{ - @Autowired - RestSitesApi siteAPI; - +{ private UserModel adminUserModel; private SiteModel siteModel; private ListUserWithRoles usersWithRoles; @@ -34,8 +29,7 @@ public class GetSiteContainerSanityTests extends RestTest @BeforeClass(alwaysRun=true) public void dataPreparation() throws Exception { - adminUserModel = dataUser.getAdminUser(); - siteAPI.useRestClient(restClient); + adminUserModel = dataUser.getAdminUser(); siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); @@ -46,8 +40,8 @@ public class GetSiteContainerSanityTests extends RestTest public void getSiteContainerWithManagerRole() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - siteContainerModel = siteAPI.getSiteContainers(siteModel).getOneRandomEntry(); - siteAPI.getSiteContainer(siteModel, siteContainerModel) + siteContainerModel = restClient.usingSite(siteModel).getSiteContainers().getOneRandomEntry(); + restClient.usingSite(siteModel).getSiteContainer(siteContainerModel) .assertThat().field("id").is(siteContainerModel.onModel().getId()) .and().field("folderId").is(siteContainerModel.onModel().getFolderId()); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -58,8 +52,8 @@ public class GetSiteContainerSanityTests extends RestTest public void getSiteContainerWithCollaboratorRole() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - siteContainerModel = siteAPI.getSiteContainers(siteModel).getOneRandomEntry(); - siteAPI.getSiteContainer(siteModel, siteContainerModel) + siteContainerModel = restClient.usingSite(siteModel).getSiteContainers().getOneRandomEntry(); + restClient.usingSite(siteModel).getSiteContainer(siteContainerModel) .and().field("id").is(siteContainerModel.onModel().getId()) .and().field("folderId").is(siteContainerModel.onModel().getFolderId()); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -70,8 +64,8 @@ public class GetSiteContainerSanityTests extends RestTest public void getSiteContainerWithContributorRole() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - siteContainerModel = siteAPI.getSiteContainers(siteModel).getOneRandomEntry(); - siteAPI.getSiteContainer(siteModel, siteContainerModel) + siteContainerModel = restClient.usingSite(siteModel).getSiteContainers().getOneRandomEntry(); + restClient.usingSite(siteModel).getSiteContainer(siteContainerModel) .assertThat().field("id").is(siteContainerModel.onModel().getId()) .and().field("folderId").is(siteContainerModel.onModel().getFolderId()); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -82,8 +76,8 @@ public class GetSiteContainerSanityTests extends RestTest public void getSiteContainerWithConsumerRole() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - siteContainerModel = siteAPI.getSiteContainers(siteModel).getOneRandomEntry(); - siteAPI.getSiteContainer(siteModel, siteContainerModel) + siteContainerModel = restClient.usingSite(siteModel).getSiteContainers().getOneRandomEntry(); + restClient.usingSite(siteModel).getSiteContainer(siteContainerModel) .assertThat().field("id").is(siteContainerModel.onModel().getId()) .and().field("folderId").is(siteContainerModel.onModel().getFolderId()); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -94,8 +88,8 @@ public class GetSiteContainerSanityTests extends RestTest public void getSiteContainerWithAdminUser() throws Exception { restClient.authenticateUser(adminUserModel); - siteContainerModel = siteAPI.getSiteContainers(siteModel).getOneRandomEntry(); - siteAPI.getSiteContainer(siteModel, siteContainerModel) + siteContainerModel = restClient.usingSite(siteModel).getSiteContainers().getOneRandomEntry(); + restClient.usingSite(siteModel).getSiteContainer(siteContainerModel) .assertThat().field("id").is(siteContainerModel.onModel().getId()) .and().field("folderId").is(siteContainerModel.onModel().getFolderId()); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -108,12 +102,12 @@ public class GetSiteContainerSanityTests extends RestTest public void unauthenticatedUserIsNotAuthorizedToRetrieveSiteContainer() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - siteContainerModel = siteAPI.getSiteContainers(siteModel).getOneRandomEntry(); + siteContainerModel = restClient.usingSite(siteModel).getSiteContainers().getOneRandomEntry(); userModel = dataUser.createRandomTestUser(); userModel.setPassword("user wrong password"); dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); - restClient.authenticateUser(userModel); - siteAPI.getSiteContainer(siteModel, siteContainerModel); + restClient.authenticateUser(userModel) + .usingSite(siteModel).getSiteContainer(siteContainerModel); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java index 4f0528441..90a642cef 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java @@ -2,7 +2,6 @@ package org.alfresco.rest.sites; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.requests.RestSitesApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataSite; import org.alfresco.utility.data.DataUser; @@ -23,10 +22,7 @@ import org.testng.annotations.Test; */ @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) public class GetSiteContainersSanityTests extends RestTest -{ - @Autowired - RestSitesApi siteAPI; - +{ @Autowired DataUser dataUser; @@ -41,8 +37,7 @@ public class GetSiteContainersSanityTests extends RestTest @BeforeClass(alwaysRun=true) public void dataPreparation() throws Exception { - adminUserModel = dataUser.getAdminUser(); - siteAPI.useRestClient(restClient); + adminUserModel = dataUser.getAdminUser(); siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); } @@ -52,7 +47,7 @@ public class GetSiteContainersSanityTests extends RestTest public void getSiteContainersWithManagerRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - siteAPI.getSiteContainers(siteModel) + restClient.usingSite(siteModel).getSiteContainers() .assertThat().entriesListIsNotEmpty() .assertThat().paginationExist() .and().paginationField("count").isNot("0"); @@ -64,7 +59,7 @@ public class GetSiteContainersSanityTests extends RestTest public void getSiteContainersWithCollaboratorRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - siteAPI.getSiteContainers(siteModel) + restClient.usingSite(siteModel).getSiteContainers() .assertThat().entriesListIsNotEmpty() .assertThat().paginationExist() .and().paginationField("count").isNot("0"); @@ -76,7 +71,7 @@ public class GetSiteContainersSanityTests extends RestTest public void getSiteContainersWithContributorRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - siteAPI.getSiteContainers(siteModel) + restClient.usingSite(siteModel).getSiteContainers() .assertThat().entriesListIsNotEmpty() .assertThat().paginationExist() .and().paginationField("count").isNot("0"); @@ -88,7 +83,7 @@ public class GetSiteContainersSanityTests extends RestTest public void getSiteContainersWithConsumerRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - siteAPI.getSiteContainers(siteModel) + restClient.usingSite(siteModel).getSiteContainers() .assertThat().entriesListIsNotEmpty() .assertThat().paginationExist() .and().paginationField("count").isNot("0"); @@ -100,7 +95,7 @@ public class GetSiteContainersSanityTests extends RestTest public void getSiteContainersWithAdminUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); - siteAPI.getSiteContainers(siteModel) + restClient.usingSite(siteModel).getSiteContainers() .assertThat().entriesListIsNotEmpty() .assertThat().paginationExist() .and().paginationField("count").isNot("0"); @@ -116,7 +111,7 @@ public class GetSiteContainersSanityTests extends RestTest userModel.setPassword("user wrong password"); dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); restClient.authenticateUser(userModel); - siteAPI.getSiteContainers(siteModel); + restClient.usingSite(siteModel).getSiteContainers(); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java index 8a6a1d60d..c31c5dc19 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java @@ -2,7 +2,6 @@ package org.alfresco.rest.sites; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.requests.RestSitesApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.exception.DataPreparationException; @@ -12,7 +11,6 @@ import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -23,10 +21,6 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) public class GetSiteMemberSanityTests extends RestTest { - - @Autowired - RestSitesApi restSitesApi; - private UserModel adminUser; private SiteModel siteModel; private ListUserWithRoles usersWithRoles; @@ -35,8 +29,7 @@ public class GetSiteMemberSanityTests extends RestTest @BeforeClass(alwaysRun = true) public void dataPreparation() throws DataPreparationException { - adminUser = dataUser.getAdminUser(); - restSitesApi.useRestClient(restClient); + adminUser = dataUser.getAdminUser(); siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); @@ -49,10 +42,10 @@ public class GetSiteMemberSanityTests extends RestTest public void getSiteMemberWithManagerRole() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restSitesApi.getSiteMember(siteModel, userModel) + restClient.usingSite(siteModel).getSiteMember(userModel) .assertThat().field("id").is(userModel.getUsername()) .and().field("role").is(userModel.getUserRole()); - restSitesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, @@ -60,10 +53,10 @@ public class GetSiteMemberSanityTests extends RestTest public void getSiteMemberWithCollaboratorRole() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - restSitesApi.getSiteMember(siteModel, userModel) + restClient.usingSite(siteModel).getSiteMember(userModel) .and().field("id").is(userModel.getUsername()) .and().field("role").is(userModel.getUserRole()); - restSitesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, @@ -71,9 +64,10 @@ public class GetSiteMemberSanityTests extends RestTest public void getSiteMemberWithContributorRole() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - restSitesApi.getSiteMember(siteModel, userModel).and().field("id").is(userModel.getUsername()) - .and().field("role").is(userModel.getUserRole()); - restSitesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.usingSite(siteModel).getSiteMember(userModel) + .and().field("id").is(userModel.getUsername()) + .and().field("role").is(userModel.getUserRole()); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, @@ -81,10 +75,10 @@ public class GetSiteMemberSanityTests extends RestTest public void getSiteMemberWithConsumerRole() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restSitesApi.getSiteMember(siteModel, userModel) + restClient.usingSite(siteModel).getSiteMember(userModel) .and().field("id").is(userModel.getUsername()) .and().field("role").is(userModel.getUserRole()); - restSitesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, @@ -92,10 +86,10 @@ public class GetSiteMemberSanityTests extends RestTest public void getSiteMemberWithAdminUser() throws Exception { restClient.authenticateUser(adminUser); - restSitesApi.getSiteMember(siteModel, userModel) + restClient.usingSite(siteModel).getSiteMember(userModel) .and().field("id").is(userModel.getUsername()) .and().field("role").is(userModel.getUserRole()); - restSitesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, @@ -105,7 +99,7 @@ public class GetSiteMemberSanityTests extends RestTest { UserModel inexistentUser = new UserModel("inexistent user", "inexistent password"); restClient.authenticateUser(inexistentUser); - restSitesApi.getSiteMember(siteModel, userModel); - restSitesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.usingSite(siteModel).getSiteMember(userModel); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java index 4bca45a96..f0f301b95 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java @@ -2,7 +2,6 @@ package org.alfresco.rest.sites; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.requests.RestSitesApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataSite; import org.alfresco.utility.data.DataUser; @@ -25,9 +24,6 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) public class GetSiteMembersSanityTests extends RestTest { - @Autowired - RestSitesApi siteAPI; - @Autowired DataUser dataUser; @@ -42,8 +38,7 @@ public class GetSiteMembersSanityTests extends RestTest @BeforeClass(alwaysRun=true) public void dataPreparation() throws DataPreparationException { - adminUser = dataUser.getAdminUser(); - siteAPI.useRestClient(restClient); + adminUser = dataUser.getAdminUser(); siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); } @@ -52,10 +47,10 @@ public class GetSiteMembersSanityTests extends RestTest description = "Verify user with Manager role gets site members and gets status code OK (200)") public void getSiteMembersWithManagerRole() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - siteAPI.getSiteMembers(siteModel).assertThat().entriesListIsNotEmpty() - .and().entriesListContains("id", usersWithRoles.getOneUserWithRole(UserRole.SiteManager).getUsername()) - .and().entriesListContains("role", usersWithRoles.getOneUserWithRole(UserRole.SiteManager).getUserRole().toString()); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .usingSite(siteModel).getSiteMembers().assertThat().entriesListIsNotEmpty() + .and().entriesListContains("id", usersWithRoles.getOneUserWithRole(UserRole.SiteManager).getUsername()) + .and().entriesListContains("role", usersWithRoles.getOneUserWithRole(UserRole.SiteManager).getUserRole().toString()); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -63,10 +58,10 @@ public class GetSiteMembersSanityTests extends RestTest description = "Verify user with Collaborator role gets site members and gets status code OK (200)") public void getSiteMembersWithCollaboratorRole() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - siteAPI.getSiteMembers(siteModel).assertThat().entriesListIsNotEmpty().assertThat() - .entriesListContains("id", usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator).getUsername()).and() - .entriesListContains("role", usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator).getUserRole().toString()); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .usingSite(siteModel).getSiteMembers().assertThat().entriesListIsNotEmpty().assertThat() + .entriesListContains("id", usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator).getUsername()).and() + .entriesListContains("role", usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator).getUserRole().toString()); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -74,8 +69,8 @@ public class GetSiteMembersSanityTests extends RestTest description = "Verify user with Contributor role gets site members and gets status code OK (200)") public void getSiteMembersWithContributorRole() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - siteAPI.getSiteMembers(siteModel).assertThat().entriesListIsNotEmpty() + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) + .usingSite(siteModel).getSiteMembers().assertThat().entriesListIsNotEmpty() .and().entriesListContains("id", usersWithRoles.getOneUserWithRole(UserRole.SiteContributor).getUsername()) .and().entriesListContains("role", usersWithRoles.getOneUserWithRole(UserRole.SiteContributor).getUserRole().toString()); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -85,8 +80,8 @@ public class GetSiteMembersSanityTests extends RestTest description = "Verify user with Consumer role gets site members and gets status code OK (200)") public void getSiteMembersWithConsumerRole() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - siteAPI.getSiteMembers(siteModel).assertThat().entriesListIsNotEmpty() + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + .usingSite(siteModel).getSiteMembers().assertThat().entriesListIsNotEmpty() .and().entriesListContains("id", usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer).getUsername()) .and().entriesListContains("role", usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer).getUserRole().toString()); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -96,10 +91,10 @@ public class GetSiteMembersSanityTests extends RestTest description = "Verify user with admin usere gets site members and gets status code OK (200)") public void getSiteMembersWithAdminUser() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(adminUser); - siteAPI.getSiteMembers(siteModel).assertThat().entriesListIsNotEmpty() - .and().entriesListContains("id", adminUser.getUsername()) - .when().assertThat().entriesListContains("role", "SiteManager"); + restClient.authenticateUser(adminUser) + .usingSite(siteModel).getSiteMembers().assertThat().entriesListIsNotEmpty() + .and().entriesListContains("id", adminUser.getUsername()) + .when().assertThat().entriesListContains("role", "SiteManager"); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -111,8 +106,8 @@ public class GetSiteMembersSanityTests extends RestTest userModel = dataUser.createRandomTestUser(); userModel.setPassword("user wrong password"); dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); - restClient.authenticateUser(userModel); - siteAPI.getSiteMembers(siteModel); + restClient.authenticateUser(userModel) + .usingSite(siteModel).getSiteMembers(); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java index 7dfb04a33..70acd3ad6 100644 --- a/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java @@ -1,7 +1,6 @@ package org.alfresco.rest.sites; import org.alfresco.rest.RestTest; -import org.alfresco.rest.requests.RestSitesApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.DataUser.ListUserWithRoles; @@ -23,11 +22,7 @@ import org.testng.annotations.Test; */ @Test(groups = {TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY}) public class RemoveSiteMemberSanityTests extends RestTest -{ - - @Autowired - RestSitesApi restSitesAPI; - +{ @Autowired DataUser dataUser; @@ -41,8 +36,7 @@ public class RemoveSiteMemberSanityTests extends RestTest adminUserModel = dataUser.getAdminUser(); siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, - UserRole.SiteConsumer, UserRole.SiteContributor); - restSitesAPI.useRestClient(restClient); + UserRole.SiteConsumer, UserRole.SiteContributor); } @BeforeMethod @@ -55,10 +49,10 @@ public class RemoveSiteMemberSanityTests extends RestTest description = "Verify that site manager can delete site member and gets status code 204, 'No Content'") public void siteManagerIsAbleToDeleteSiteMember() throws Exception{ restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restSitesAPI.deleteSiteMember(siteModel, testUserModel); - restSitesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.usingSite(siteModel).deleteSiteMember(testUserModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); restClient.getSites().assertThat().entriesListDoesNotContain("id", testUserModel.getUsername()); - restSitesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.assertStatusCodeIs(HttpStatus.OK); } @Bug(id="ACE-5444") @@ -66,50 +60,55 @@ public class RemoveSiteMemberSanityTests extends RestTest description = "Verify that site collaborator cannot delete site member and gets status code 403, 'Forbidden'") public void siteCollaboratorIsNotAbleToDeleteSiteMember() throws Exception{ restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - restSitesAPI.deleteSiteMember(siteModel, testUserModel); - restSitesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + restClient.usingSite(siteModel).deleteSiteMember(testUserModel); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + restClient.getSites().assertThat().entriesListContains("id", testUserModel.getUsername()); - restSitesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.assertStatusCodeIs(HttpStatus.OK); } @Bug(id="ACE-5444") @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that site contributor cannot delete site member and gets status code 403, 'Forbidden'") public void siteContributorIsNotAbleToDeleteSiteMember() throws Exception{ - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - restSitesAPI.deleteSiteMember(siteModel, testUserModel); - restSitesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + restClient.usingSite(siteModel).deleteSiteMember(testUserModel); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + restClient.getSites().assertThat().entriesListContains("id", testUserModel.getUsername()); - restSitesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.assertStatusCodeIs(HttpStatus.OK); } @Bug(id="ACE-5444") @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that site consumer cannot delete site member and gets status code 403, 'Forbidden'") public void siteConsumerIsNotAbleToDeleteSiteMember() throws Exception{ - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restSitesAPI.deleteSiteMember(siteModel, testUserModel); - restSitesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + .usingSite(siteModel).deleteSiteMember(testUserModel); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + restClient.getSites().assertThat().entriesListContains("id", testUserModel.getUsername()); - restSitesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that admin user can delete site member and gets status code 204, 'No Content'") public void adminUserIsAbleToDeleteSiteMember() throws Exception{ - restClient.authenticateUser(adminUserModel); - restSitesAPI.deleteSiteMember(siteModel, testUserModel); - restSitesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.authenticateUser(adminUserModel) + .usingSite(siteModel).deleteSiteMember(testUserModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.getSites().assertThat().entriesListDoesNotContain("id", testUserModel.getUsername()); - restSitesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that unauthenticated user is not able to delete site member") public void unauthenticatedUserIsNotAuthorizedToDeleteSiteMember() throws Exception{ UserModel inexistentUser = new UserModel("inexistent user", "inexistent password"); - restClient.authenticateUser(inexistentUser); - restSitesAPI.deleteSiteMember(siteModel, testUserModel); - restSitesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.authenticateUser(inexistentUser) + .usingSite(siteModel).deleteSiteMember(testUserModel); + + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java index 57f9eed5d..2c57f1d92 100644 --- a/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java @@ -1,7 +1,6 @@ package org.alfresco.rest.sites; import org.alfresco.rest.RestTest; -import org.alfresco.rest.requests.RestSitesApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.SiteModel; @@ -10,7 +9,6 @@ import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -18,9 +16,6 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) public class UpdateSiteMemberSanityTests extends RestTest { - @Autowired - RestSitesApi siteAPI; - private UserModel adminUserModel; private SiteModel siteModel; private ListUserWithRoles usersWithRoles; @@ -29,8 +24,7 @@ public class UpdateSiteMemberSanityTests extends RestTest @BeforeClass(alwaysRun=true) public void dataPreparation() throws Exception { - adminUserModel = dataUser.getAdminUser(); - siteAPI.useRestClient(restClient); + adminUserModel = dataUser.getAdminUser(); siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); @@ -44,7 +38,7 @@ public class UpdateSiteMemberSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); testUserModel.setUserRole(UserRole.SiteConsumer); - siteAPI.updateSiteMember(siteModel, testUserModel) + restClient.usingSite(siteModel).updateSiteMember(testUserModel) .assertThat().field("id").is(testUserModel.getUsername()) .and().field("role").is(testUserModel.getUserRole()); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -57,7 +51,7 @@ public class UpdateSiteMemberSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); testUserModel.setUserRole(UserRole.SiteCollaborator); - siteAPI.updateSiteMember(siteModel, testUserModel); + restClient.usingSite(siteModel).updateSiteMember(testUserModel); restClient.assertLastError() .containsSummary(String.format("The current user does not have permissions to modify the membership details of the site %s.", siteModel.getTitle())); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); @@ -70,7 +64,7 @@ public class UpdateSiteMemberSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); testUserModel.setUserRole(UserRole.SiteCollaborator); - siteAPI.updateSiteMember(siteModel, testUserModel); + restClient.usingSite(siteModel).updateSiteMember(testUserModel); restClient.assertLastError() .containsSummary(String.format("The current user does not have permissions to modify the membership details of the site %s.", siteModel.getTitle())); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); @@ -83,7 +77,7 @@ public class UpdateSiteMemberSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); testUserModel.setUserRole(UserRole.SiteCollaborator); - siteAPI.updateSiteMember(siteModel, testUserModel); + restClient.usingSite(siteModel).updateSiteMember(testUserModel); restClient.assertLastError() .containsSummary(String.format("The current user does not have permissions to modify the membership details of the site %s.", siteModel.getTitle())); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); @@ -95,7 +89,7 @@ public class UpdateSiteMemberSanityTests extends RestTest { restClient.authenticateUser(adminUserModel); testUserModel.setUserRole(UserRole.SiteCollaborator); - siteAPI.updateSiteMember(siteModel, testUserModel) + restClient.usingSite(siteModel).updateSiteMember(testUserModel) .assertThat().field("id").is(testUserModel.getUsername()) .and().field("role").is(testUserModel.getUserRole()); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -108,7 +102,7 @@ public class UpdateSiteMemberSanityTests extends RestTest UserModel inexistentUser = new UserModel("inexistent user", "inexistent password"); restClient.authenticateUser(inexistentUser); testUserModel.setUserRole(UserRole.SiteCollaborator); - siteAPI.updateSiteMember(siteModel, testUserModel); + restClient.usingSite(siteModel).updateSiteMember(testUserModel); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } From f8a56b95c385efa69f6fcf22623e338cb109d7f9 Mon Sep 17 00:00:00 2001 From: cagache Date: Mon, 14 Nov 2016 16:35:07 +0200 Subject: [PATCH 0519/1491] update test --- .../workflow/processes/UpdateProcessVariableSanityTests.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/UpdateProcessVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/UpdateProcessVariableSanityTests.java index 177572ae2..ae7171697 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/UpdateProcessVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/UpdateProcessVariableSanityTests.java @@ -1,5 +1,6 @@ package org.alfresco.rest.workflow.processes; +import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestWorkflowTest; import org.alfresco.rest.exception.JsonToModelConversionException; @@ -54,7 +55,7 @@ public class UpdateProcessVariableSanityTests extends RestWorkflowTest { restClient.authenticateUser(adminUser); RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = processesApi.getProcesses().getOneRandomEntry(); + processModel = processesApi.addProcess("activitiAdhoc", adminUser, false, CMISUtil.Priority.Normal); processesApi.updateProcessVariable(processModel, variableModel); processesApi.getProcessesVariables(processModel).assertThat().entriesListContains("name", variableModel.getName()); processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); From e9446195cbe4c51b17f516a4b21d5cfbe6eb8e25 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Tue, 15 Nov 2016 00:07:45 +0200 Subject: [PATCH 0520/1491] up --- .../alfresco/rest/demo/SamplePeopleTests.java | 12 +- .../favorites/AddFavoritesSanityTests.java | 51 ++++---- .../favorites/DeleteFavoritesSanityTests.java | 113 ++++++++++-------- .../favorites/GetFavoriteSanityTests.java | 78 ++++++------ .../favorites/GetFavoritesSanityTests.java | 101 ++++++++-------- .../people/AddFavoriteSiteSanityTests.java | 67 +++++------ .../AddSiteMembershipRequestSanityTests.java | 73 +++++------ .../people/DeleteFavoriteSiteSanityTests.java | 50 ++++---- .../people/DeleteSiteMemberSanityTests.java | 22 ++-- ...eleteSiteMembershipRequestSanityTests.java | 110 ++++++++--------- .../people/GetFavoriteSiteSanityTests.java | 70 +++++------ .../people/GetFavoriteSitesSanityTests.java | 61 +++++----- .../GetPeopleActivitiesSanityTests.java | 73 +++++------ .../GetPeoplePreferenceSanityTests.java | 63 +++++----- .../GetPeoplePreferencesSanityTests.java | 65 +++++----- .../rest/people/GetPeopleSanityTests.java | 89 +++++++------- .../GetSiteMembershipRequestSanityTests.java | 71 +++++------ .../GetSiteMembershipRequestsSanityTests.java | 57 ++++----- .../people/GetSiteMembershipSanityTests.java | 88 +++++++------- ...SitesMembershipInformationSanityTests.java | 86 ++++++------- ...pdateSiteMembershipRequestSanityTests.java | 110 ++++++++--------- 21 files changed, 706 insertions(+), 804 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/demo/SamplePeopleTests.java b/e2e-test/java/org/alfresco/rest/demo/SamplePeopleTests.java index 8e77d5477..e5c302378 100644 --- a/e2e-test/java/org/alfresco/rest/demo/SamplePeopleTests.java +++ b/e2e-test/java/org/alfresco/rest/demo/SamplePeopleTests.java @@ -1,13 +1,11 @@ package org.alfresco.rest.demo; import org.alfresco.rest.RestTest; -import org.alfresco.rest.requests.RestPeopleApi; import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.apache.commons.lang3.RandomStringUtils; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -15,9 +13,6 @@ import org.testng.annotations.Test; @Test(groups = { "demo" }) public class SamplePeopleTests extends RestTest { - @Autowired - RestPeopleApi peopleAPI; - private UserModel userModel; private UserModel adminUser; @@ -27,17 +22,14 @@ public class SamplePeopleTests extends RestTest userModel = dataUser.createUser(RandomStringUtils.randomAlphanumeric(20)); adminUser = dataUser.getAdminUser(); restClient.authenticateUser(adminUser); - peopleAPI.useRestClient(restClient); } @TestRail(section={"demo", "sample-section"}, executionType= ExecutionType.SANITY, description = "Verify admin user gets person with Rest API and response is not empty") public void adminShouldRetrievePerson() throws Exception { - peopleAPI.getPerson(userModel).assertThat().field("id").isNotEmpty(); - - peopleAPI.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.OK); + restClient.usingUser(userModel).getPerson().assertThat().field("id").isNotEmpty(); + restClient.assertStatusCodeIs(HttpStatus.OK); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesSanityTests.java index 4a3999c1c..beb549f2b 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesSanityTests.java @@ -2,7 +2,6 @@ package org.alfresco.rest.favorites; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.requests.RestFavoritesApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.DataUser.ListUserWithRoles; @@ -20,9 +19,6 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) public class AddFavoritesSanityTests extends RestTest { - @Autowired - RestFavoritesApi favoritesAPI; - @Autowired DataUser dataUser; @@ -34,10 +30,7 @@ public class AddFavoritesSanityTests extends RestTest public void dataPreparation() throws Exception { adminUserModel = dataUser.getAdminUser(); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - - favoritesAPI.useRestClient(restClient); - + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); siteModel.setGuid(restClient.authenticateUser(adminUserModel).usingSite(siteModel).getSite().getGuid()); usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, @@ -48,44 +41,51 @@ public class AddFavoritesSanityTests extends RestTest TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Admin user add site to favorites with Rest API and status code is 201") public void adminIsAbleToAddToFavorites() throws Exception { - favoritesAPI.addSiteToFavorites(adminUserModel, siteModel).and().field("targetGuid").is(siteModel.getGuid()); - favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + restClient.usingAuthUser() + .addSiteToFavorites(siteModel) + .assertThat().field("targetGuid").is(siteModel.getGuid()); + restClient.assertStatusCodeIs(HttpStatus.CREATED); } @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Manager user add site to favorites with Rest API and status code is 201") public void managerIsAbleToAddToFavorites() throws Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteManager), siteModel).and().field("targetGuid").is(siteModel.getGuid()); - favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .usingAuthUser() + .addSiteToFavorites(siteModel) + .assertThat().field("targetGuid").is(siteModel.getGuid()); + restClient.assertStatusCodeIs(HttpStatus.CREATED); } @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user add site to favorites with Rest API and status code is 201") public void collaboratorIsAbleToAddToFavorites() throws Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), siteModel).and().field("targetGuid").is(siteModel.getGuid()); - favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .usingAuthUser() + .addSiteToFavorites(siteModel).and().field("targetGuid").is(siteModel.getGuid()); + restClient.assertStatusCodeIs(HttpStatus.CREATED); } @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Contributor user add site to favorites with Rest API and status code is 201") public void contributorIsAbleToAddToFavorites() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor), siteModel).and().field("targetGuid").is(siteModel.getGuid()); - favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) + .usingAuthUser() + .addSiteToFavorites(siteModel).and().field("targetGuid").is(siteModel.getGuid()); + restClient.assertStatusCodeIs(HttpStatus.CREATED); } @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Consumer user add site to favorites with Rest API and status code is 201") public void consumerIsAbleToAddToFavorites() throws Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer), siteModel).and().field("targetGuid").is(siteModel.getGuid()); - favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + .usingAuthUser() + .addSiteToFavorites(siteModel).and().field("targetGuid").is(siteModel.getGuid()); + restClient.assertStatusCodeIs(HttpStatus.CREATED); } @TestRail(section = { TestGroup.REST_API, @@ -95,8 +95,9 @@ public class AddFavoritesSanityTests extends RestTest { UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); siteManager.setPassword("wrongPassword"); - restClient.authenticateUser(siteManager); - favoritesAPI.addSiteToFavorites(siteManager, siteModel); - favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.authenticateUser(siteManager) + .usingAuthUser() + .addSiteToFavorites(siteModel); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoritesSanityTests.java index a59969e32..08fe85a38 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoritesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoritesSanityTests.java @@ -2,7 +2,6 @@ package org.alfresco.rest.favorites; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.requests.RestFavoritesApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.ErrorModel; @@ -12,7 +11,6 @@ import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -20,9 +18,6 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) public class DeleteFavoritesSanityTests extends RestTest { - @Autowired - RestFavoritesApi favoritesAPI; - private UserModel adminUserModel; private SiteModel siteModel; private ListUserWithRoles usersWithRoles; @@ -33,9 +28,6 @@ public class DeleteFavoritesSanityTests extends RestTest adminUserModel = dataUser.getAdminUser(); siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - - favoritesAPI.useRestClient(restClient); - siteModel.setGuid(restClient.authenticateUser(adminUserModel).usingSite(siteModel).getSite().getGuid()); usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, @@ -46,10 +38,12 @@ public class DeleteFavoritesSanityTests extends RestTest TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Admin user deletes site from favorites with Rest API and status code is 204") public void adminIsAbleToDeleteFavorites() throws JsonToModelConversionException, Exception { - favoritesAPI.addSiteToFavorites(adminUserModel, siteModel).and().field("targetGuid").is(siteModel.getGuid()); - favoritesAPI.deleteSiteFromFavorites(adminUserModel, siteModel); - favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); - favoritesAPI.getFavorites(adminUserModel).assertThat().entriesListDoesNotContain("targetGuid", siteModel.getGuid()); + restClient.usingUser(adminUserModel) + .addSiteToFavorites(siteModel).assertThat().field("targetGuid").is(siteModel.getGuid()); + + restClient.usingAuthUser().deleteSiteFromFavorites(siteModel) + .assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.usingAuthUser().getFavorites().assertThat().entriesListDoesNotContain("targetGuid", siteModel.getGuid()); } @TestRail(section = { TestGroup.REST_API, @@ -57,11 +51,14 @@ public class DeleteFavoritesSanityTests extends RestTest public void managerIsAbleToDeleteFavorites() throws JsonToModelConversionException, Exception { UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); - restClient.authenticateUser(siteManager); - favoritesAPI.addSiteToFavorites(siteManager, siteModel).and().field("targetGuid").is(siteModel.getGuid()); - favoritesAPI.deleteSiteFromFavorites(siteManager, siteModel); - favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); - favoritesAPI.getFavorites(siteManager).assertThat().entriesListDoesNotContain("targetGuid", siteModel.getGuid()); + restClient.authenticateUser(siteManager) + .usingAuthUser() + .addSiteToFavorites(siteModel).and().field("targetGuid").is(siteModel.getGuid()); + + restClient.usingAuthUser() + .deleteSiteFromFavorites(siteModel) + .assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.usingAuthUser().getFavorites().assertThat().entriesListDoesNotContain("targetGuid", siteModel.getGuid()); } @TestRail(section = { TestGroup.REST_API, @@ -69,11 +66,13 @@ public class DeleteFavoritesSanityTests extends RestTest public void collaboratorIsAbleToDeleteFavorites() throws JsonToModelConversionException, Exception { UserModel siteCollaborator = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); - restClient.authenticateUser(siteCollaborator); - favoritesAPI.addSiteToFavorites(siteCollaborator, siteModel).and().field("targetGuid").is(siteModel.getGuid()); - favoritesAPI.deleteSiteFromFavorites(siteCollaborator, siteModel); - favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); - favoritesAPI.getFavorites(siteCollaborator).assertThat().entriesListDoesNotContain("targetGuid", siteModel.getGuid()); + restClient.authenticateUser(siteCollaborator) + .usingAuthUser() + .addSiteToFavorites(siteModel).and().field("targetGuid").is(siteModel.getGuid()); + restClient.usingAuthUser().deleteSiteFromFavorites(siteModel) + .assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.usingAuthUser().getFavorites().assertThat().entriesListDoesNotContain("targetGuid", siteModel.getGuid()); } @TestRail(section = { TestGroup.REST_API, @@ -81,11 +80,13 @@ public class DeleteFavoritesSanityTests extends RestTest public void contributorIsAbleToDeleteFavorites() throws JsonToModelConversionException, Exception { UserModel siteContributor = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); - restClient.authenticateUser(siteContributor); - favoritesAPI.addSiteToFavorites(siteContributor, siteModel).and().field("targetGuid").is(siteModel.getGuid()); - favoritesAPI.deleteSiteFromFavorites(siteContributor, siteModel); - favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); - favoritesAPI.getFavorites(siteContributor).assertThat().entriesListDoesNotContain("targetGuid", siteModel.getGuid()); + restClient.authenticateUser(siteContributor) + .usingAuthUser() + .addSiteToFavorites(siteModel).and().field("targetGuid").is(siteModel.getGuid()); + restClient.usingAuthUser().deleteSiteFromFavorites(siteModel) + .assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.usingAuthUser().getFavorites().assertThat().entriesListDoesNotContain("targetGuid", siteModel.getGuid()); } @TestRail(section = { TestGroup.REST_API, @@ -93,11 +94,12 @@ public class DeleteFavoritesSanityTests extends RestTest public void consumerIsAbleToDeleteFavorites() throws JsonToModelConversionException, Exception { UserModel siteConsumer = usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer); - restClient.authenticateUser(siteConsumer); - favoritesAPI.addSiteToFavorites(siteConsumer, siteModel).and().field("targetGuid").is(siteModel.getGuid()); - favoritesAPI.deleteSiteFromFavorites(siteConsumer, siteModel); - favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); - favoritesAPI.getFavorites(siteConsumer).assertThat().entriesListDoesNotContain("targetGuid", siteModel.getGuid()); + restClient.authenticateUser(siteConsumer) + .usingAuthUser() + .addSiteToFavorites(siteModel).and().field("targetGuid").is(siteModel.getGuid()); + restClient.usingAuthUser().deleteSiteFromFavorites(siteModel).assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.usingAuthUser().getFavorites().assertThat().entriesListDoesNotContain("targetGuid", siteModel.getGuid()); } @TestRail(section = { TestGroup.REST_API, @@ -106,34 +108,42 @@ public class DeleteFavoritesSanityTests extends RestTest public void userIsNotAbleToDeleteFavoritesOfAnotherUser() throws JsonToModelConversionException, Exception { UserModel siteCollaborator = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); - restClient.authenticateUser(siteCollaborator); - favoritesAPI.addSiteToFavorites(siteCollaborator, siteModel).and().field("targetGuid").is(siteModel.getGuid()); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - favoritesAPI.deleteSiteFromFavorites(siteCollaborator, siteModel); - favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + restClient.authenticateUser(siteCollaborator) + .usingAuthUser() + .addSiteToFavorites(siteModel).and().field("targetGuid").is(siteModel.getGuid()); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + .usingAuthUser() + .deleteSiteFromFavorites(siteModel) + .assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify user doesn't have permission to delete favorites of admin user with Rest API and status code is 404") @Bug(id="MNT-16557") public void userIsNotAbleToDeleteFavoritesOfAdminUser() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(adminUserModel); - favoritesAPI.addSiteToFavorites(adminUserModel, siteModel).and().field("targetGuid").is(siteModel.getGuid()); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - favoritesAPI.deleteSiteFromFavorites(adminUserModel, siteModel); - favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + restClient.authenticateUser(adminUserModel) + .usingAuthUser() + .addSiteToFavorites(siteModel) + .and().field("targetGuid").is(siteModel.getGuid()); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + .usingAuthUser() + .deleteSiteFromFavorites(siteModel) + .assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify admin user doesn't have permission to delete favorites of another user with Rest API and status code is 404") @Bug(id="MNT-16557") public void adminIsNotAbleToDeleteFavoritesOfAnotherUser() throws JsonToModelConversionException, Exception { - UserModel siteCollaborator = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); - restClient.authenticateUser(siteCollaborator); - favoritesAPI.addSiteToFavorites(siteCollaborator, siteModel).and().field("targetGuid").is(siteModel.getGuid()); - restClient.authenticateUser(adminUserModel); - favoritesAPI.deleteSiteFromFavorites(siteCollaborator, siteModel); - favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .usingAuthUser() + .addSiteToFavorites(siteModel).and().field("targetGuid").is(siteModel.getGuid()); + + restClient.authenticateUser(adminUserModel) + .usingAuthUser() + .deleteSiteFromFavorites(siteModel) + .assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify user gets status code 401 if authentication call fails") @@ -142,8 +152,9 @@ public class DeleteFavoritesSanityTests extends RestTest { UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); siteManager.setPassword("wrongPassword"); - restClient.authenticateUser(siteManager); - favoritesAPI.deleteSiteFromFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteManager), siteModel); - favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.authenticateUser(siteManager) + .usingAuthUser() + .deleteSiteFromFavorites(siteModel) + .assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java index be644034d..7c925499d 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java @@ -3,7 +3,6 @@ package org.alfresco.rest.favorites; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.requests.RestFavoritesApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.ErrorModel; @@ -15,7 +14,6 @@ import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -23,10 +21,6 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) public class GetFavoriteSanityTests extends RestTest { - @Autowired - RestFavoritesApi favoritesAPI; - - private UserModel adminUserModel; private SiteModel siteModel; private FolderModel folderModel; @@ -42,7 +36,6 @@ public class GetFavoriteSanityTests extends RestTest folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); fileModel = dataContent.usingUser(adminUserModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - favoritesAPI.useRestClient(restClient); siteModel.setGuid(restClient.authenticateUser(adminUserModel).usingSite(siteModel).getSite().getGuid()); @@ -54,27 +47,27 @@ public class GetFavoriteSanityTests extends RestTest TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets favorite site with Rest API and status code is 200") public void adminIsAbleToRetrieveFavoritesSite() throws JsonToModelConversionException, Exception { - favoritesAPI.addSiteToFavorites(adminUserModel, siteModel).and().field("targetGuid").is(siteModel.getGuid()); - favoritesAPI.getSiteFavorites(adminUserModel, siteModel).and().field("targetGuid").is(siteModel.getGuid()); - favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.usingUser(adminUserModel).addSiteToFavorites(siteModel).and().field("targetGuid").is(siteModel.getGuid()); + restClient.usingUser(adminUserModel).getFavoriteSites().and().entriesListContains("guid",siteModel.getGuid()); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets favorite folder with Rest API and status code is 200") public void adminIsAbleToRetrieveFavoritesFolder() throws JsonToModelConversionException, Exception { - favoritesAPI.addFolderToFavorites(adminUserModel, folderModel).and().field("targetGuid").is(folderModel.getNodeRef()); - favoritesAPI.getFolderFavorites(adminUserModel, folderModel).and().field("targetGuid").is(folderModel.getNodeRef()); - favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.usingUser(adminUserModel).addFolderToFavorites(folderModel).and().field("targetGuid").is(folderModel.getNodeRef()); + restClient.usingUser(adminUserModel).getFavorites().and().entriesListContains("targetGuid", folderModel.getNodeRef()); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets favorite file with Rest API and status code is 200") public void adminIsAbleToRetrieveFavoritesFile() throws JsonToModelConversionException, Exception { - favoritesAPI.addFileToFavorites(adminUserModel, fileModel).and().field("targetGuid").is(fileModel.getNodeRef().replace(";1.0", "")); - favoritesAPI.getFileFavorites(adminUserModel, fileModel).and().field("targetGuid").is(fileModel.getNodeRef().replace(";1.0", "")); - favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.usingUser(adminUserModel).addFileToFavorites(fileModel); + restClient.usingUser(adminUserModel).getFavorites().and().entriesListContains("targetGuid", fileModel.getNodeRef()); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, @@ -82,9 +75,9 @@ public class GetFavoriteSanityTests extends RestTest public void managerIsAbleToRetrieveFavorite() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteManager), siteModel).and().field("targetGuid").is(siteModel.getGuid()); - favoritesAPI.getSiteFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteManager), siteModel).and().field("targetGuid").is(siteModel.getGuid()); - favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.usingAuthUser().addSiteToFavorites(siteModel); + restClient.usingAuthUser().getFavoriteSites().and().entriesListContains("guid",siteModel.getGuid()); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, @@ -92,9 +85,9 @@ public class GetFavoriteSanityTests extends RestTest public void collaboratorIsAbleToRetrieveFavorites() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), siteModel).and().field("targetGuid").is(siteModel.getGuid()); - favoritesAPI.getSiteFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), siteModel).and().field("targetGuid").is(siteModel.getGuid()); - favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.usingAuthUser().addSiteToFavorites(siteModel); + restClient.usingAuthUser().getFavoriteSites().and().entriesListContains("guid",siteModel.getGuid()); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, @@ -102,9 +95,9 @@ public class GetFavoriteSanityTests extends RestTest public void contributorIsAbleToRetrieveFavorite() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor), siteModel).and().field("targetGuid").is(siteModel.getGuid()); - favoritesAPI.getSiteFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor), siteModel).and().field("targetGuid").is(siteModel.getGuid()); - favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.usingAuthUser().addSiteToFavorites(siteModel); + restClient.usingAuthUser().getFavoriteSites().and().entriesListContains("guid",siteModel.getGuid()); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, @@ -112,9 +105,9 @@ public class GetFavoriteSanityTests extends RestTest public void consumerIsAbleToRetrieveFavorites() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer), siteModel).and().field("targetGuid").is(siteModel.getGuid()); - favoritesAPI.getSiteFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer), siteModel).and().field("targetGuid").is(siteModel.getGuid()); - favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.usingAuthUser().addSiteToFavorites(siteModel); + restClient.usingAuthUser().getFavoriteSites().and().entriesListContains("guid",siteModel.getGuid()); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, @@ -122,8 +115,10 @@ public class GetFavoriteSanityTests extends RestTest public void userIsNotAbleToRetrieveFavoriteSiteOfAnotherUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - favoritesAPI.getSiteFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), siteModel); - favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND) + restClient.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .getFavorite(siteModel.getGuid()); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator).getUsername())); } @@ -131,9 +126,11 @@ public class GetFavoriteSanityTests extends RestTest TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify user doesn't get favorite site of admin user with Rest API and status code is 404") public void userIsNotAbleToRetrieveFavoritesOfAdminUser() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - favoritesAPI.getSiteFavorites(adminUserModel, siteModel); - favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND) + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + .usingUser(adminUserModel) + .getFavorite(siteModel.getGuid()); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, adminUserModel.getUsername())); } @@ -141,9 +138,11 @@ public class GetFavoriteSanityTests extends RestTest TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify admin user doesn't get favorite site of another user with Rest API and status code is 404") public void adminIsNotAbleToRetrieveFavoritesOfAnotherUser() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(adminUserModel); - favoritesAPI.getSiteFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), siteModel); - favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND) + restClient.authenticateUser(adminUserModel) + .usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .getFavorite(siteModel.getGuid()); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator).getUsername())); } @@ -154,9 +153,10 @@ public class GetFavoriteSanityTests extends RestTest { UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); siteManager.setPassword("wrongPassword"); - restClient.authenticateUser(siteManager); - favoritesAPI.getSiteFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteManager), siteModel); - favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.authenticateUser(siteManager) + .usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .getFavorite(siteModel.getGuid()); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java index 40d8a965f..cf4c0cd02 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java @@ -3,7 +3,6 @@ package org.alfresco.rest.favorites; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.requests.RestFavoritesApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.ErrorModel; @@ -15,7 +14,6 @@ import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -23,10 +21,6 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) public class GetFavoritesSanityTests extends RestTest { - - @Autowired - RestFavoritesApi favoritesAPI; - private UserModel adminUserModel; private SiteModel firstSiteModel; private SiteModel secondSiteModel; @@ -48,7 +42,6 @@ public class GetFavoritesSanityTests extends RestTest firstFileModel = dataContent.usingUser(adminUserModel).usingResource(firstFolderModel).createContent(DocumentType.TEXT_PLAIN); secondFileModel = dataContent.usingUser(adminUserModel).usingResource(firstFolderModel).createContent(DocumentType.TEXT_PLAIN); - favoritesAPI.useRestClient(restClient); firstSiteModel.setGuid(restClient.authenticateUser(adminUserModel).usingSite(firstSiteModel).getSite().getGuid()); secondSiteModel.setGuid(restClient.authenticateUser(adminUserModel).usingSite(secondSiteModel).getSite().getGuid()); @@ -61,36 +54,36 @@ public class GetFavoritesSanityTests extends RestTest TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets favorites sites with Rest API and status code is 200") public void adminIsAbleToRetrieveFavoritesSites() throws JsonToModelConversionException, Exception { - favoritesAPI.addSiteToFavorites(adminUserModel, firstSiteModel).and().field("targetGuid").is(firstSiteModel.getGuid()); - favoritesAPI.addSiteToFavorites(adminUserModel, secondSiteModel).and().field("targetGuid").is(secondSiteModel.getGuid()); - favoritesAPI.where().targetSiteExist().filterAnd().getFavorites(adminUserModel) + restClient.usingUser(adminUserModel).addSiteToFavorites(firstSiteModel); + restClient.usingUser(adminUserModel).addSiteToFavorites(secondSiteModel); + restClient.usingAuthUser().where().targetSiteExist().getFavorites() .assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) .and().entriesListContains("targetGuid", secondSiteModel.getGuid()); - favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets favorites folders with Rest API and status code is 200") public void adminIsAbleToRetrieveFavoritesFolders() throws JsonToModelConversionException, Exception { - favoritesAPI.addFolderToFavorites(adminUserModel, firstFolderModel).and().field("targetGuid").is(firstFolderModel.getNodeRef()); - favoritesAPI.addFolderToFavorites(adminUserModel, secondFolderModel).and().field("targetGuid").is(secondFolderModel.getNodeRef()); - favoritesAPI.where().targetFolderExist().filterAnd().getFavorites(adminUserModel) + restClient.usingUser(adminUserModel).addFolderToFavorites(firstFolderModel); + restClient.usingUser(adminUserModel).addFolderToFavorites(secondFolderModel); + restClient.usingAuthUser().where().targetFolderExist().getFavorites() .assertThat().entriesListContains("targetGuid", firstFolderModel.getNodeRef()) .and().entriesListContains("targetGuid", secondFolderModel.getNodeRef()); - favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets favorites files with Rest API and status code is 200") public void adminIsAbleToRetrieveFavoritesFiles() throws JsonToModelConversionException, Exception - { - favoritesAPI.addFileToFavorites(adminUserModel, firstFileModel).and().field("targetGuid").is(firstFileModel.getNodeRef().replace(";1.0", "")); - favoritesAPI.addFileToFavorites(adminUserModel, secondFileModel).and().field("targetGuid").is(secondFileModel.getNodeRef().replace(";1.0", "")); - favoritesAPI.where().targetFileExist().filterAnd().getFavorites(adminUserModel) - .assertThat().entriesListContains("targetGuid", firstFileModel.getNodeRef().replace(";1.0", "")) - .and().entriesListContains("targetGuid", secondFileModel.getNodeRef().replace(";1.0", "")); - favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + { + restClient.usingUser(adminUserModel).addFileToFavorites(firstFileModel); + restClient.usingUser(adminUserModel).addFileToFavorites(secondFileModel); + restClient.usingAuthUser().where().targetFileExist().getFavorites() + .assertThat().entriesListContains("targetGuid", firstFileModel.getNodeRef()) + .and().entriesListContains("targetGuid", secondFileModel.getNodeRef()); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, @@ -98,60 +91,60 @@ public class GetFavoritesSanityTests extends RestTest public void managerIsAbleToRetrieveFavorites() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteManager), firstSiteModel).and().field("targetGuid").is(firstSiteModel.getGuid()); - favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteManager), secondSiteModel).and().field("targetGuid").is(secondSiteModel.getGuid()); - favoritesAPI.where().targetSiteExist().filterAnd().getFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + restClient.usingAuthUser().addSiteToFavorites(firstSiteModel); + restClient.usingAuthUser().addSiteToFavorites(secondSiteModel); + restClient.usingAuthUser().where().targetSiteExist().getFavorites() .assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) .assertThat().entriesListContains("targetGuid", secondSiteModel.getGuid()); - favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user gets favorites with Rest API and status code is 200") public void collaboratorIsAbleToRetrieveFavorites() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), firstSiteModel).and().field("targetGuid").is(firstSiteModel.getGuid()); - favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), secondSiteModel).and().field("targetGuid").is(secondSiteModel.getGuid()); - favoritesAPI.where().targetSiteExist().filterAnd().getFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .usingAuthUser().addSiteToFavorites(firstSiteModel); + restClient.usingAuthUser().addSiteToFavorites(secondSiteModel); + restClient.usingAuthUser().where().targetSiteExist().getFavorites() .assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) .and().entriesListContains("targetGuid", secondSiteModel.getGuid()); - favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Contributor user gets favorites with Rest API and status code is 200") public void contributorIsAbleToRetrieveFavorites() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor), firstSiteModel).and().field("targetGuid").is(firstSiteModel.getGuid()); - favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor), secondSiteModel).and().field("targetGuid").is(secondSiteModel.getGuid()); - favoritesAPI.where().targetSiteExist().filterAnd().getFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) + .usingAuthUser().addSiteToFavorites(firstSiteModel); + restClient.usingAuthUser().addSiteToFavorites(secondSiteModel); + restClient.usingAuthUser().where().targetSiteExist().getFavorites() .assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()).and() .entriesListContains("targetGuid", secondSiteModel.getGuid()); - favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Consumer user gets favorites with Rest API and status code is 200") public void consumerIsAbleToRetrieveFavorites() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer), firstSiteModel).and().field("targetGuid").is(firstSiteModel.getGuid()); - favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer), secondSiteModel).and().field("targetGuid").is(secondSiteModel.getGuid()); - favoritesAPI.where().targetSiteExist().filterAnd().getFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + .usingAuthUser().addSiteToFavorites(firstSiteModel); + restClient.usingAuthUser().addSiteToFavorites(secondSiteModel); + restClient.usingAuthUser().where().targetSiteExist().getFavorites() .assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) .assertThat().entriesListContains("targetGuid", secondSiteModel.getGuid()); - favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify user doesn't have permission to get favorites of another user with Rest API and status code is 404") public void userIsNotAbleToRetrieveFavoritesOfAnotherUser() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - favoritesAPI.where().targetSiteExist().filterAnd().getFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND) + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + .usingAuthUser().where().targetSiteExist().getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator).getUsername())); } @@ -159,9 +152,9 @@ public class GetFavoritesSanityTests extends RestTest TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify user doesn't have permission to get favorites of admin user with Rest API and status code is 200") public void userIsNotAbleToRetrieveFavoritesOfAdminUser() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - favoritesAPI.where().targetSiteExist().filterAnd().getFavorites(adminUserModel); - favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND) + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + .usingAuthUser().where().targetSiteExist().getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, adminUserModel.getUsername())); } @@ -169,9 +162,9 @@ public class GetFavoritesSanityTests extends RestTest TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify admin user doesn't have permission to get favorites of another user with Rest API and status code is 200") public void adminIsNotAbleToRetrieveFavoritesOfAnotherUser() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(adminUserModel); - favoritesAPI.where().targetSiteExist().filterAnd().getFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND) + restClient.authenticateUser(adminUserModel) + .usingAuthUser().where().targetSiteExist().getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator).getUsername())); } @@ -182,9 +175,9 @@ public class GetFavoritesSanityTests extends RestTest { UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); siteManager.setPassword("wrongPassword"); - restClient.authenticateUser(siteManager); - favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteManager), firstSiteModel); - favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteManager), secondSiteModel); - favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.authenticateUser(siteManager) + .usingAuthUser().addSiteToFavorites(firstSiteModel); + restClient.usingAuthUser().addSiteToFavorites(secondSiteModel); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteSanityTests.java index 66c393a1a..4a60a1104 100644 --- a/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteSanityTests.java @@ -1,7 +1,6 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; -import org.alfresco.rest.requests.RestPeopleApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; @@ -9,7 +8,6 @@ import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -17,9 +15,6 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) public class AddFavoriteSiteSanityTests extends RestTest { - @Autowired - RestPeopleApi peopleApi; - UserModel userModel; SiteModel siteModel; UserModel searchedUser; @@ -28,9 +23,7 @@ public class AddFavoriteSiteSanityTests extends RestTest public void dataPreparation() throws Exception { userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - - peopleApi.useRestClient(restClient); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user add a favorite site with Rest API and response is successful (201)") @@ -39,14 +32,15 @@ public class AddFavoriteSiteSanityTests extends RestTest UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); - restClient.authenticateUser(managerUser); - peopleApi.addFavoriteSite(managerUser, siteModel) - .assertThat().field("id").is(siteModel.getId()); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + restClient.authenticateUser(managerUser) + .usingUser(managerUser) + .addFavoriteSite(siteModel) + .assertThat().field("id").is(siteModel.getId()); + restClient.assertStatusCodeIs(HttpStatus.CREATED); - peopleApi.addFavoriteSite(managerUser, siteModel); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CONFLICT); - peopleApi.usingRestWrapper().assertLastError().containsSummary(String.format("%s is already a favourite site", siteModel.getId())); + restClient.usingUser(managerUser).addFavoriteSite(siteModel); + restClient.assertStatusCodeIs(HttpStatus.CONFLICT); + restClient.assertLastError().containsSummary(String.format("%s is already a favourite site", siteModel.getId())); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify collaborator user add a favorite site with Rest API and response is successful (201)") @@ -55,10 +49,11 @@ public class AddFavoriteSiteSanityTests extends RestTest UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(collaboratorUser, siteModel, UserRole.SiteCollaborator); - restClient.authenticateUser(collaboratorUser); - peopleApi.addFavoriteSite(collaboratorUser, siteModel) - .assertThat().field("id").is(siteModel.getId()); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + restClient.authenticateUser(collaboratorUser) + .usingAuthUser() + .addFavoriteSite(siteModel) + .assertThat().field("id").is(siteModel.getId()); + restClient.assertStatusCodeIs(HttpStatus.CREATED); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify contributor user add a favorite site with Rest API and response is successful (201)") @@ -67,10 +62,11 @@ public class AddFavoriteSiteSanityTests extends RestTest UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(contributorUser, siteModel, UserRole.SiteContributor); - restClient.authenticateUser(contributorUser); - peopleApi.addFavoriteSite(contributorUser, siteModel) - .assertThat().field("id").is(siteModel.getId()); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + restClient.authenticateUser(contributorUser) + .usingAuthUser() + .addFavoriteSite(siteModel) + .assertThat().field("id").is(siteModel.getId()); + restClient.assertStatusCodeIs(HttpStatus.CREATED); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify consumer user add a favorite site with Rest API and response is successful (201)") @@ -79,10 +75,11 @@ public class AddFavoriteSiteSanityTests extends RestTest UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel, UserRole.SiteConsumer); - restClient.authenticateUser(consumerUser); - peopleApi.addFavoriteSite(consumerUser, siteModel) - .assertThat().field("id").is(siteModel.getId()); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + restClient.authenticateUser(consumerUser) + .usingAuthUser() + .addFavoriteSite(siteModel) + .assertThat().field("id").is(siteModel.getId()); + restClient.assertStatusCodeIs(HttpStatus.CREATED); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify admin user add a favorite site with Rest API and response is successful (201)") @@ -90,10 +87,11 @@ public class AddFavoriteSiteSanityTests extends RestTest { UserModel adminUser = dataUser.getAdminUser(); - restClient.authenticateUser(adminUser); - peopleApi.addFavoriteSite(adminUser, siteModel) - .assertThat().field("id").is(siteModel.getId()); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + restClient.authenticateUser(adminUser) + .usingAuthUser() + .addFavoriteSite(siteModel) + .assertThat().field("id").is(siteModel.getId()); + restClient.assertStatusCodeIs(HttpStatus.CREATED); } @Bug(id = "MNT-16904") @@ -104,8 +102,9 @@ public class AddFavoriteSiteSanityTests extends RestTest dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); managerUser.setPassword("newpassword"); - restClient.authenticateUser(managerUser); - peopleApi.addFavoriteSite(managerUser, siteModel); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.authenticateUser(managerUser) + .usingAuthUser() + .addFavoriteSite(siteModel); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java index 2bb833d3a..f2b71682d 100644 --- a/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java @@ -2,7 +2,6 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.requests.RestPeopleApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataSite; import org.alfresco.utility.data.DataUser; @@ -21,10 +20,7 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) public class AddSiteMembershipRequestSanityTests extends RestTest -{ - @Autowired - RestPeopleApi peopleApi; - +{ @Autowired DataUser dataUser; @@ -43,8 +39,6 @@ public class AddSiteMembershipRequestSanityTests extends RestTest adminUser = dataUser.getAdminUser(); siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); - - peopleApi.useRestClient(restClient); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -53,12 +47,11 @@ public class AddSiteMembershipRequestSanityTests extends RestTest public void siteManagerIsAbleToCreateSiteMembershipRequest() throws JsonToModelConversionException, Exception { UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - peopleApi.addSiteMembershipRequest(newMember, siteModel) - .assertThat().field("id").isNotEmpty() - .assertThat().field("site").isNotEmpty(); - peopleApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.CREATED); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .usingUser(newMember).addSiteMembershipRequest(siteModel) + .assertThat().field("id").isNotEmpty() + .assertThat().field("site").isNotEmpty(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -67,12 +60,11 @@ public class AddSiteMembershipRequestSanityTests extends RestTest public void siteCollaboatorIsAbleToCreateSiteMembershipRequest() throws JsonToModelConversionException, Exception { UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - peopleApi.addSiteMembershipRequest(newMember, siteModel) - .assertThat().field("id").isNotEmpty() - .assertThat().field("site").isNotEmpty(); - peopleApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.CREATED); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .usingUser(newMember).addSiteMembershipRequest(siteModel) + .assertThat().field("id").isNotEmpty() + .assertThat().field("site").isNotEmpty(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -81,12 +73,11 @@ public class AddSiteMembershipRequestSanityTests extends RestTest public void siteContributorIsAbleToCreateSiteMembershipRequest() throws JsonToModelConversionException, Exception { UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - peopleApi.addSiteMembershipRequest(newMember, siteModel) - .assertThat().field("id").isNotEmpty() - .assertThat().field("site").isNotEmpty(); - peopleApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.CREATED); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) + .usingUser(newMember).addSiteMembershipRequest(siteModel) + .assertThat().field("id").isNotEmpty() + .assertThat().field("site").isNotEmpty(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -95,12 +86,11 @@ public class AddSiteMembershipRequestSanityTests extends RestTest public void siteConsumerIsAbleToCreateSiteMembershipRequest() throws JsonToModelConversionException, Exception { UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - peopleApi.addSiteMembershipRequest(newMember, siteModel) - .assertThat().field("id").isNotEmpty() - .assertThat().field("site").isNotEmpty(); - peopleApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.CREATED); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + .usingUser(newMember).addSiteMembershipRequest(siteModel) + .assertThat().field("id").isNotEmpty() + .assertThat().field("site").isNotEmpty(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, @@ -109,11 +99,11 @@ public class AddSiteMembershipRequestSanityTests extends RestTest public void adminUserIsAbleToCreateSiteMembershipRequest() throws JsonToModelConversionException, Exception { UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(adminUser); - peopleApi.addSiteMembershipRequest(newMember, siteModel) - .assertThat().field("id").isNotEmpty() - .assertThat().field("site").isNotEmpty(); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + restClient.authenticateUser(adminUser) + .usingUser(newMember).addSiteMembershipRequest(siteModel) + .assertThat().field("id").isNotEmpty() + .assertThat().field("site").isNotEmpty(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -122,11 +112,10 @@ public class AddSiteMembershipRequestSanityTests extends RestTest public void unauthenticatedUserIsNotAbleToCreateSiteMembershipRequest() throws JsonToModelConversionException, Exception { UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(new UserModel("random user", "random password")); - peopleApi.addSiteMembershipRequest(newMember, siteModel) - .assertThat().field("id").isNotEmpty() - .assertThat().field("site").isNotEmpty(); - peopleApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.authenticateUser(new UserModel("random user", "random password")) + .usingUser(newMember).addSiteMembershipRequest(siteModel) + .assertThat().field("id").isNotEmpty() + .assertThat().field("site").isNotEmpty(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java index 97727c320..ef21e8c65 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java @@ -1,7 +1,6 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; -import org.alfresco.rest.requests.RestPeopleApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.model.ErrorModel; import org.alfresco.utility.model.SiteModel; @@ -9,7 +8,6 @@ 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.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -20,9 +18,6 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) public class DeleteFavoriteSiteSanityTests extends RestTest { - @Autowired - RestPeopleApi peopleApi; - UserModel userModel; SiteModel siteModel1; SiteModel siteModel2; @@ -34,8 +29,6 @@ public class DeleteFavoriteSiteSanityTests extends RestTest userModel = dataUser.createRandomTestUser(); siteModel1 = dataSite.usingUser(userModel).createPublicRandomSite(); siteModel2 = dataSite.usingUser(userModel).createPublicRandomSite(); - - peopleApi.useRestClient(restClient); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user removes a site from its favorite sites list with Rest API and response is successful (204)") @@ -46,9 +39,10 @@ public class DeleteFavoriteSiteSanityTests extends RestTest dataSite.usingUser(managerUser).usingSite(siteModel1).addSiteToFavorites(); dataSite.usingUser(managerUser).usingSite(siteModel2).addSiteToFavorites(); - restClient.authenticateUser(managerUser); - peopleApi.removeFavoriteSite(managerUser, siteModel1); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.authenticateUser(managerUser) + .usingAuthUser().removeFavoriteSite(siteModel1); + + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify collaborator user removes a site from its favorite sites list with Rest API and response is successful (204)") @@ -59,9 +53,9 @@ public class DeleteFavoriteSiteSanityTests extends RestTest dataSite.usingUser(collaboratorUser).usingSite(siteModel1).addSiteToFavorites(); dataSite.usingUser(collaboratorUser).usingSite(siteModel2).addSiteToFavorites(); - restClient.authenticateUser(collaboratorUser); - peopleApi.removeFavoriteSite(collaboratorUser, siteModel1); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.authenticateUser(collaboratorUser) + .usingAuthUser().removeFavoriteSite(siteModel1); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify contributor user removes a site from its favorite sites list with Rest API and response is successful (204)") @@ -72,9 +66,9 @@ public class DeleteFavoriteSiteSanityTests extends RestTest dataSite.usingUser(contributorUser).usingSite(siteModel1).addSiteToFavorites(); dataSite.usingUser(contributorUser).usingSite(siteModel2).addSiteToFavorites(); - restClient.authenticateUser(contributorUser); - peopleApi.removeFavoriteSite(contributorUser, siteModel1); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.authenticateUser(contributorUser) + .usingAuthUser().removeFavoriteSite(siteModel1); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify consumer user removes a site from its favorite sites list with Rest API and response is successful (204)") @@ -85,9 +79,9 @@ public class DeleteFavoriteSiteSanityTests extends RestTest dataSite.usingUser(consumerUser).usingSite(siteModel1).addSiteToFavorites(); dataSite.usingUser(consumerUser).usingSite(siteModel2).addSiteToFavorites(); - restClient.authenticateUser(consumerUser); - peopleApi.removeFavoriteSite(consumerUser, siteModel1); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.authenticateUser(consumerUser) + .usingAuthUser().removeFavoriteSite(siteModel1); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify admin user removes a site from any user's favorite sites list with Rest API and response is successful (204)") @@ -98,9 +92,9 @@ public class DeleteFavoriteSiteSanityTests extends RestTest dataSite.usingUser(anyUser).usingSite(siteModel1).addSiteToFavorites(); dataSite.usingUser(anyUser).usingSite(siteModel2).addSiteToFavorites(); - restClient.authenticateUser(adminUser); - peopleApi.removeFavoriteSite(anyUser, siteModel1); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.authenticateUser(adminUser) + .usingAuthUser().removeFavoriteSite(siteModel1); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify a user removes a site from another user's favorite sites list with Rest API and response is permission denied (403)") @@ -111,9 +105,9 @@ public class DeleteFavoriteSiteSanityTests extends RestTest dataSite.usingUser(anotherUser).usingSite(siteModel1).addSiteToFavorites(); dataSite.usingUser(anotherUser).usingSite(siteModel2).addSiteToFavorites(); - restClient.authenticateUser(userAuth); - peopleApi.removeFavoriteSite(anotherUser, siteModel1); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN) + restClient.authenticateUser(userAuth) + .usingAuthUser().removeFavoriteSite(siteModel1); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @@ -126,8 +120,8 @@ public class DeleteFavoriteSiteSanityTests extends RestTest dataSite.usingUser(managerUser).usingSite(siteModel2).addSiteToFavorites(); managerUser.setPassword("newpassword"); - restClient.authenticateUser(managerUser); - peopleApi.removeFavoriteSite(managerUser, siteModel1); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.authenticateUser(managerUser) + .usingAuthUser().removeFavoriteSite(siteModel1); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java index 069e88489..da3c6aef3 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java @@ -2,7 +2,6 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.requests.RestPeopleApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataSite; import org.alfresco.utility.data.DataUser; @@ -22,10 +21,7 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) public class DeleteSiteMemberSanityTests extends RestTest -{ - @Autowired - RestPeopleApi peopleApi; - +{ @Autowired DataUser dataUser; @@ -43,9 +39,7 @@ public class DeleteSiteMemberSanityTests extends RestTest siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, - UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); - - peopleApi.useRestClient(restClient); + UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -58,7 +52,7 @@ public class DeleteSiteMemberSanityTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) .usingSite(siteModel).addPerson(newUser); - peopleApi.deleteSiteMember(newUser, siteModel); + restClient.usingUser(newUser).deleteSiteMember(siteModel); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } @@ -72,7 +66,7 @@ public class DeleteSiteMemberSanityTests extends RestTest restClient.authenticateUser(adminUser) .usingSite(siteModel).addPerson(newUser); - peopleApi.deleteSiteMember(newUser, siteModel); + restClient.usingUser(newUser).deleteSiteMember(siteModel); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } @@ -88,7 +82,7 @@ public class DeleteSiteMemberSanityTests extends RestTest .usingSite(siteModel).addPerson(newUser); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - peopleApi.deleteSiteMember(newUser, siteModel); + restClient.usingUser(newUser).deleteSiteMember(siteModel); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @@ -105,7 +99,7 @@ public class DeleteSiteMemberSanityTests extends RestTest .usingSite(siteModel).addPerson(newUser); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - peopleApi.deleteSiteMember(newUser, siteModel); + restClient.usingUser(newUser).deleteSiteMember(siteModel); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @@ -122,7 +116,7 @@ public class DeleteSiteMemberSanityTests extends RestTest .usingSite(siteModel).addPerson(newUser); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - peopleApi.deleteSiteMember(newUser, siteModel); + restClient.usingUser(newUser).deleteSiteMember(siteModel); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @@ -134,7 +128,7 @@ public class DeleteSiteMemberSanityTests extends RestTest { restClient.authenticateUser(new UserModel("random user", "random password")); - peopleApi.deleteSiteMember(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer), siteModel); + restClient.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).deleteSiteMember(siteModel); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java index 3a4c5da9b..be6a956b4 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java @@ -2,7 +2,6 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.requests.RestPeopleApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.data.RandomData; @@ -14,7 +13,6 @@ import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.social.alfresco.api.entities.Site.Visibility; import org.testng.annotations.BeforeClass; @@ -25,10 +23,7 @@ import org.testng.annotations.Test; */ @Test(groups = {TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) public class DeleteSiteMembershipRequestSanityTests extends RestTest -{ - @Autowired - RestPeopleApi peopleApi; - +{ UserModel userModel; UserModel siteMember; SiteModel siteModel; @@ -39,9 +34,10 @@ public class DeleteSiteMembershipRequestSanityTests extends RestTest String siteId = RandomData.getRandomName("site"); siteModel = dataSite.usingUser(userModel).createSite(new SiteModel(Visibility.MODERATED, siteId, siteId, siteId, siteId)); usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, - UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); - - peopleApi.useRestClient(restClient); + UserRole.SiteManager, + UserRole.SiteCollaborator, + UserRole.SiteConsumer, + UserRole.SiteContributor); } @TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, @@ -49,12 +45,12 @@ public class DeleteSiteMembershipRequestSanityTests extends RestTest public void userCanDeleteHisOwnSiteMembershipRequest() throws JsonToModelConversionException, DataPreparationException, Exception { siteMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(siteMember); - peopleApi.addSiteMembershipRequest(siteMember, siteModel); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - peopleApi.deleteSiteMembershipRequest(siteMember, siteModel); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.authenticateUser(siteMember) + .usingAuthUser().addSiteMembershipRequest(siteModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .usingUser(siteMember).deleteSiteMembershipRequest(siteModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } @Bug(id="MNT-16916") @@ -63,11 +59,11 @@ public class DeleteSiteMembershipRequestSanityTests extends RestTest public void siteManagerCanDeleteSiteMembershipRequest() throws JsonToModelConversionException, DataPreparationException, Exception { siteMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(siteMember); - peopleApi.addSiteMembershipRequest(siteMember, siteModel); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - peopleApi.deleteSiteMembershipRequest(usersWithRoles.getOneUserWithRole(UserRole.SiteManager), siteModel); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.authenticateUser(siteMember) + .usingUser(siteMember).addSiteMembershipRequest(siteModel); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .usingAuthUser().deleteSiteMembershipRequest(siteModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } @Bug(id="MNT-16916") @@ -76,13 +72,13 @@ public class DeleteSiteMembershipRequestSanityTests extends RestTest public void adminUserCanDeleteSiteMembershipRequest() throws JsonToModelConversionException, DataPreparationException, Exception { siteMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(siteMember); - peopleApi.addSiteMembershipRequest(siteMember, siteModel); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); - UserModel adminUser = dataUser.getAdminUser(); - restClient.authenticateUser(adminUser); - peopleApi.deleteSiteMembershipRequest(adminUser, siteModel); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.authenticateUser(siteMember) + .usingAuthUser().addSiteMembershipRequest(siteModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(dataUser.getAdminUser()) + .usingAuthUser().deleteSiteMembershipRequest(siteModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } @Bug(id="MNT-16916") @@ -91,12 +87,11 @@ public class DeleteSiteMembershipRequestSanityTests extends RestTest public void collaboratorCannotDeleteSiteMembershipRequest() throws JsonToModelConversionException, DataPreparationException, Exception { siteMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(siteMember); - peopleApi.addSiteMembershipRequest(siteMember, siteModel); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - peopleApi.deleteSiteMembershipRequest(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), siteModel); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + restClient.authenticateUser(siteMember) + .usingAuthUser().addSiteMembershipRequest(siteModel); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .usingAuthUser().deleteSiteMembershipRequest(siteModel); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @Bug(id="MNT-16916") @@ -105,11 +100,12 @@ public class DeleteSiteMembershipRequestSanityTests extends RestTest public void contributorCannotDeleteSiteMembershipRequest() throws JsonToModelConversionException, DataPreparationException, Exception { siteMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(siteMember); - peopleApi.addSiteMembershipRequest(siteMember, siteModel); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - peopleApi.deleteSiteMembershipRequest(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor), siteModel); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN) + restClient.authenticateUser(siteMember) + .usingAuthUser().addSiteMembershipRequest(siteModel); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) + .usingAuthUser().deleteSiteMembershipRequest(siteModel); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @@ -119,11 +115,11 @@ public class DeleteSiteMembershipRequestSanityTests extends RestTest public void consumerCannotDeleteSiteMembershipRequest() throws JsonToModelConversionException, DataPreparationException, Exception { siteMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(siteMember); - peopleApi.addSiteMembershipRequest(siteMember, siteModel); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - peopleApi.deleteSiteMembershipRequest(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer), siteModel); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN) + restClient.authenticateUser(siteMember) + .usingAuthUser().addSiteMembershipRequest(siteModel); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + .usingAuthUser().deleteSiteMembershipRequest(siteModel); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @@ -131,27 +127,25 @@ public class DeleteSiteMembershipRequestSanityTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify random user is not able to delete site memebership request") public void randomUserCanDeleteSiteMembershipRequest() throws JsonToModelConversionException, DataPreparationException, Exception - { - siteMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(siteMember); - peopleApi.addSiteMembershipRequest(siteMember, siteModel); - UserModel randomUser = dataUser.createRandomTestUser(); - restClient.authenticateUser(randomUser); - peopleApi.deleteSiteMembershipRequest(randomUser, siteModel); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN) + { + restClient.authenticateUser(dataUser.createRandomTestUser()) + .usingAuthUser().addSiteMembershipRequest(siteModel); + + restClient.authenticateUser(dataUser.createRandomTestUser()) + .usingAuthUser().deleteSiteMembershipRequest(siteModel); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Failed authentication get site member call returns status code 401") public void unauthenticatedUserIsNotAuthorizedToDeleteSiteMmebershipRequest() throws JsonToModelConversionException, Exception - { - siteMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(siteMember); - peopleApi.addSiteMembershipRequest(siteMember, siteModel); + { + restClient.authenticateUser(dataUser.createRandomTestUser()) + .usingAuthUser().addSiteMembershipRequest(siteModel); UserModel inexistentUser = new UserModel("inexistent user", "inexistent password"); - restClient.authenticateUser(inexistentUser); - peopleApi.deleteSiteMembershipRequest(inexistentUser, siteModel); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.authenticateUser(inexistentUser) + .usingAuthUser().deleteSiteMembershipRequest(siteModel); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java index 5e5885f87..bcdc438c4 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java @@ -1,7 +1,6 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; -import org.alfresco.rest.requests.RestPeopleApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.model.ErrorModel; import org.alfresco.utility.model.SiteModel; @@ -10,7 +9,6 @@ import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -24,9 +22,6 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) public class GetFavoriteSiteSanityTests extends RestTest { - @Autowired - RestPeopleApi peopleApi; - UserModel userModel; SiteModel siteModel1; SiteModel siteModel2; @@ -38,8 +33,6 @@ public class GetFavoriteSiteSanityTests extends RestTest userModel = dataUser.createRandomTestUser(); siteModel1 = dataSite.usingUser(userModel).createPublicRandomSite(); siteModel2 = dataSite.usingUser(userModel).createPublicRandomSite(); - - peopleApi.useRestClient(restClient); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user gets its specific favorite site with Rest API and response is successful (200)") @@ -50,11 +43,11 @@ public class GetFavoriteSiteSanityTests extends RestTest dataSite.usingUser(managerUser).usingSite(siteModel1).addSiteToFavorites(); dataSite.usingUser(managerUser).usingSite(siteModel2).addSiteToFavorites(); - restClient.authenticateUser(managerUser); - peopleApi.getFavoriteSite(managerUser, siteModel1) - .assertThat().field("id").is(siteModel1.getId()) - .and().field("title").isNotNull(); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.authenticateUser(managerUser) + .usingAuthUser().getFavoriteSite(siteModel1) + .assertThat().field("id").is(siteModel1.getId()) + .and().field("title").isNotNull(); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify collaborator user gets its specific favorite site with Rest API and response is successful (200)") @@ -65,11 +58,11 @@ public class GetFavoriteSiteSanityTests extends RestTest dataSite.usingUser(collaboratorUser).usingSite(siteModel1).addSiteToFavorites(); dataSite.usingUser(collaboratorUser).usingSite(siteModel2).addSiteToFavorites(); - restClient.authenticateUser(collaboratorUser); - peopleApi.getFavoriteSite(collaboratorUser, siteModel1) - .assertThat().field("id").is(siteModel1.getId()) - .and().field("title").isNotNull(); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.authenticateUser(collaboratorUser) + .usingAuthUser().getFavoriteSite(siteModel1) + .assertThat().field("id").is(siteModel1.getId()) + .and().field("title").isNotNull(); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify contributor user gets its specific favorite site with Rest API and response is successful (200)") @@ -80,11 +73,11 @@ public class GetFavoriteSiteSanityTests extends RestTest dataSite.usingUser(contributorUser).usingSite(siteModel1).addSiteToFavorites(); dataSite.usingUser(contributorUser).usingSite(siteModel2).addSiteToFavorites(); - restClient.authenticateUser(contributorUser); - peopleApi.getFavoriteSite(contributorUser, siteModel1) - .assertThat().field("id").is(siteModel1.getId()) - .and().field("title").isNotNull(); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.authenticateUser(contributorUser) + .usingAuthUser().getFavoriteSite(siteModel1) + .assertThat().field("id").is(siteModel1.getId()) + .and().field("title").isNotNull(); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify consumer user gets its specific favorite site with Rest API and response is successful (200)") @@ -95,11 +88,11 @@ public class GetFavoriteSiteSanityTests extends RestTest dataSite.usingUser(consumerUser).usingSite(siteModel1).addSiteToFavorites(); dataSite.usingUser(consumerUser).usingSite(siteModel2).addSiteToFavorites(); - restClient.authenticateUser(consumerUser); - peopleApi.getFavoriteSite(consumerUser, siteModel1) - .assertThat().field("id").is(siteModel1.getId()) - .and().field("title").isNotNull(); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.authenticateUser(consumerUser) + .usingAuthUser().getFavoriteSite(siteModel1) + .assertThat().field("id").is(siteModel1.getId()) + .and().field("title").isNotNull(); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify admin user gets specific favorite site of any user with Rest API and response is successful (200)") @@ -110,11 +103,11 @@ public class GetFavoriteSiteSanityTests extends RestTest dataSite.usingUser(anyUser).usingSite(siteModel1).addSiteToFavorites(); dataSite.usingUser(anyUser).usingSite(siteModel2).addSiteToFavorites(); - restClient.authenticateUser(adminUset); - peopleApi.getFavoriteSite(anyUser, siteModel1) - .assertThat().field("id").is(siteModel1.getId()) - .and().field("title").isNotNull(); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.authenticateUser(adminUset) + .usingAuthUser().getFavoriteSite(siteModel1) + .assertThat().field("id").is(siteModel1.getId()) + .and().field("title").isNotNull(); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user fails to get specific favorite site of another user with Rest API and response is successful (403)") @@ -125,10 +118,9 @@ public class GetFavoriteSiteSanityTests extends RestTest dataSite.usingUser(managerUser).usingSite(siteModel1).addSiteToFavorites(); dataSite.usingUser(managerUser).usingSite(siteModel2).addSiteToFavorites(); - restClient.authenticateUser(managerUser); - peopleApi.getFavoriteSite(userModel, siteModel1); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + restClient.authenticateUser(managerUser) + .usingAuthUser().getFavoriteSite(siteModel1); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @Bug(id = "MNT-16904") @@ -141,8 +133,8 @@ public class GetFavoriteSiteSanityTests extends RestTest dataSite.usingUser(managerUser).usingSite(siteModel2).addSiteToFavorites(); managerUser.setPassword("newpassword"); - restClient.authenticateUser(managerUser); - peopleApi.getFavoriteSite(managerUser, siteModel1); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.authenticateUser(managerUser) + .usingAuthUser().getFavoriteSite(siteModel1); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java index de76461ff..faa3817f9 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java @@ -1,7 +1,6 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; -import org.alfresco.rest.requests.RestPeopleApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.model.ErrorModel; import org.alfresco.utility.model.SiteModel; @@ -10,7 +9,6 @@ import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -18,9 +16,6 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) public class GetFavoriteSitesSanityTests extends RestTest { - @Autowired - RestPeopleApi peopleApi; - UserModel userModel; SiteModel siteModel; UserModel searchedUser; @@ -30,8 +25,6 @@ public class GetFavoriteSitesSanityTests extends RestTest { userModel = dataUser.createRandomTestUser(); siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - - peopleApi.useRestClient(restClient); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user fails to get an user favorite sites with Rest API (403)") @@ -42,9 +35,9 @@ public class GetFavoriteSitesSanityTests extends RestTest UserModel anotherUser = dataUser.usingAdmin().createRandomTestUser(); dataSite.usingUser(anotherUser).usingSite(siteModel).addSiteToFavorites(); - restClient.authenticateUser(managerUser); - peopleApi.getFavoriteSites(anotherUser); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN) + restClient.authenticateUser(managerUser) + .usingUser(anotherUser).getFavoriteSites(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @@ -57,9 +50,9 @@ public class GetFavoriteSitesSanityTests extends RestTest dataUser.usingUser(userModel).addUserToSite(contributorUser, siteModel, UserRole.SiteContributor); dataSite.usingUser(contributorUser).usingSite(siteModel).addSiteToFavorites(); - restClient.authenticateUser(collaboratorUser); - peopleApi.getFavoriteSites(contributorUser); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN) + restClient.authenticateUser(collaboratorUser) + .usingUser(contributorUser).getFavoriteSites(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @@ -72,9 +65,9 @@ public class GetFavoriteSitesSanityTests extends RestTest dataUser.usingUser(userModel).addUserToSite(contributorUser2, siteModel, UserRole.SiteContributor); dataSite.usingUser(contributorUser2).usingSite(siteModel).addSiteToFavorites(); - restClient.authenticateUser(contributorUser); - peopleApi.getFavoriteSites(contributorUser2); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN) + restClient.authenticateUser(contributorUser) + .usingUser(contributorUser2).getFavoriteSites(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @@ -87,9 +80,9 @@ public class GetFavoriteSitesSanityTests extends RestTest dataUser.usingUser(collaboratorUser).addUserToSite(collaboratorUser, siteModel, UserRole.SiteCollaborator); dataSite.usingUser(collaboratorUser).usingSite(siteModel).addSiteToFavorites(); - restClient.authenticateUser(consumerUser); - peopleApi.getFavoriteSites(collaboratorUser); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN) + restClient.authenticateUser(consumerUser) + .usingUser(collaboratorUser).getFavoriteSites(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @@ -100,12 +93,12 @@ public class GetFavoriteSitesSanityTests extends RestTest UserModel anotherUser = dataUser.usingAdmin().createRandomTestUser(); dataSite.usingUser(anotherUser).usingSite(siteModel).addSiteToFavorites(); - restClient.authenticateUser(adminUser); - peopleApi.getFavoriteSites(anotherUser) - .assertThat().entriesListIsNotEmpty() - .and().paginationExist() - .and().entriesListContains("id", siteModel.getId()); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.authenticateUser(adminUser) + .usingUser(anotherUser).getFavoriteSites() + .assertThat().entriesListIsNotEmpty() + .and().paginationExist() + .and().entriesListContains("id", siteModel.getId()); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify any user gets its own user favorite sites with Rest API and response is successful (200)") @@ -114,12 +107,12 @@ public class GetFavoriteSitesSanityTests extends RestTest UserModel anyUser = dataUser.usingAdmin().createRandomTestUser(); dataSite.usingUser(anyUser).usingSite(siteModel).addSiteToFavorites(); - restClient.authenticateUser(anyUser); - peopleApi.getFavoriteSites(anyUser) - .assertThat().entriesListIsNotEmpty() - .and().entriesListContains("id", siteModel.getId()) - .and().paginationExist(); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.authenticateUser(anyUser) + .usingAuthUser().getFavoriteSites() + .assertThat().entriesListIsNotEmpty() + .and().entriesListContains("id", siteModel.getId()) + .and().paginationExist(); + restClient.assertStatusCodeIs(HttpStatus.OK); } @Bug(id = "MNT-16904") @@ -130,8 +123,8 @@ public class GetFavoriteSitesSanityTests extends RestTest dataSite.usingUser(anyUser).usingSite(siteModel).addSiteToFavorites(); anyUser.setPassword("newpassword"); - restClient.authenticateUser(anyUser); - peopleApi.getFavoriteSites(anyUser); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.authenticateUser(anyUser) + .usingAuthUser().getFavoriteSites(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java index a27b36758..ea7f36f25 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java @@ -2,7 +2,6 @@ package org.alfresco.rest.people; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; -import org.alfresco.rest.requests.RestPeopleApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; @@ -10,7 +9,6 @@ import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -24,9 +22,6 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.SANITY }) public class GetPeopleActivitiesSanityTests extends RestTest { - @Autowired - RestPeopleApi peopleApi; - UserModel userModel; SiteModel siteModel; UserModel searchedUser; @@ -37,8 +32,6 @@ public class GetPeopleActivitiesSanityTests extends RestTest userModel = dataUser.createRandomTestUser(); siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - - peopleApi.useRestClient(restClient); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.SANITY, description = "Verify manager user gets its activities with Rest API and response is successful") @@ -48,12 +41,12 @@ public class GetPeopleActivitiesSanityTests extends RestTest dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); dataContent.usingUser(managerUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(managerUser); - peopleApi.getPersonActivities(managerUser) - .assertThat().entriesListIsNotEmpty() - .and().entriesListContains("siteId", siteModel.getId()) - .and().paginationExist(); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.authenticateUser(managerUser) + .usingAuthUser().getPersonActivities() + .assertThat().entriesListIsNotEmpty() + .and().entriesListContains("siteId", siteModel.getId()) + .and().paginationExist(); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.SANITY, description = "Verify collaborator user gets its activities with Rest API and response is successful") @@ -63,12 +56,12 @@ public class GetPeopleActivitiesSanityTests extends RestTest dataUser.usingUser(userModel).addUserToSite(collaboratorUser, siteModel, UserRole.SiteCollaborator); dataContent.usingUser(collaboratorUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(collaboratorUser); - peopleApi.getPersonActivities(collaboratorUser) - .assertThat().entriesListIsNotEmpty() - .and().entriesListContains("siteId", siteModel.getId()) - .and().paginationExist(); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.authenticateUser(collaboratorUser) + .usingAuthUser().getPersonActivities() + .assertThat().entriesListIsNotEmpty() + .and().entriesListContains("siteId", siteModel.getId()) + .and().paginationExist(); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.SANITY, description = "Verify contributor user gets its activities with Rest API and response is successful") @@ -78,12 +71,12 @@ public class GetPeopleActivitiesSanityTests extends RestTest dataUser.usingUser(userModel).addUserToSite(contributorUser, siteModel, UserRole.SiteContributor); dataContent.usingUser(contributorUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(contributorUser); - peopleApi.getPersonActivities(contributorUser) - .assertThat().entriesListIsNotEmpty() - .and().entriesListContains("siteId", siteModel.getId()) - .and().paginationExist(); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.authenticateUser(contributorUser) + .usingAuthUser().getPersonActivities() + .assertThat().entriesListIsNotEmpty() + .and().entriesListContains("siteId", siteModel.getId()) + .and().paginationExist(); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.SANITY, description = "Verify consumer user gets its activities with Rest API and response is successful") @@ -92,23 +85,23 @@ public class GetPeopleActivitiesSanityTests extends RestTest UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel, UserRole.SiteConsumer); - restClient.authenticateUser(consumerUser); - peopleApi.getPersonActivities(consumerUser) - .assertThat().entriesListIsNotEmpty() - .and().entriesListContains("siteId", siteModel.getId()) - .and().paginationExist(); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.authenticateUser(consumerUser) + .usingAuthUser().getPersonActivities() + .assertThat().entriesListIsNotEmpty() + .and().entriesListContains("siteId", siteModel.getId()) + .and().paginationExist(); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.SANITY, description = "Verify admin user gets another user activities with Rest API and response is successful") public void adminUserShouldGetPeopleActivitiesList() throws Exception { - restClient.authenticateUser(dataUser.getAdminUser()); - peopleApi.getPersonActivities(userModel) - .assertThat().entriesListIsNotEmpty() - .and().entriesListContains("siteId", siteModel.getId()) - .and().paginationExist(); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.authenticateUser(dataUser.getAdminUser()) + .usingUser(userModel).getPersonActivities() + .assertThat().entriesListIsNotEmpty() + .and().entriesListContains("siteId", siteModel.getId()) + .and().paginationExist(); + restClient.assertStatusCodeIs(HttpStatus.OK); } @Bug(id = "MNT-16904") @@ -119,8 +112,8 @@ public class GetPeopleActivitiesSanityTests extends RestTest dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); managerUser.setPassword("newpassword"); - restClient.authenticateUser(managerUser); - peopleApi.getPersonActivities(userModel); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.authenticateUser(managerUser) + .usingUser(userModel).getPersonActivities(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceSanityTests.java index dba3a41c3..e96f3fd54 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceSanityTests.java @@ -1,7 +1,6 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; -import org.alfresco.rest.requests.RestPeopleApi; import org.alfresco.utility.constants.PreferenceName; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.model.SiteModel; @@ -10,7 +9,6 @@ import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -24,9 +22,6 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) public class GetPeoplePreferenceSanityTests extends RestTest { - @Autowired - RestPeopleApi peopleApi; - UserModel userModel; SiteModel siteModel; @@ -35,8 +30,6 @@ public class GetPeoplePreferenceSanityTests extends RestTest { userModel = dataUser.createRandomTestUser(); siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - - peopleApi.useRestClient(restClient); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify manager user gets a specific preference with Rest API and response is successful (200)") @@ -46,11 +39,11 @@ public class GetPeoplePreferenceSanityTests extends RestTest dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); dataSite.usingUser(managerUser).usingSite(siteModel).addSiteToFavorites(); - restClient.authenticateUser(managerUser); - peopleApi.getPersonPreferenceInformation(managerUser, PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) - .assertThat().field("id").is( PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) - .and().field("value").is("true"); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.authenticateUser(managerUser) + .usingAuthUser().getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) + .assertThat().field("id").is( PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) + .and().field("value").is("true"); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify collaborator user gets a specific preference with Rest API and response is successful (200)") @@ -60,11 +53,11 @@ public class GetPeoplePreferenceSanityTests extends RestTest dataUser.usingUser(userModel).addUserToSite(collaboratorUser, siteModel, UserRole.SiteCollaborator); dataSite.usingUser(collaboratorUser).usingSite(siteModel).addSiteToFavorites(); - restClient.authenticateUser(collaboratorUser); - peopleApi.getPersonPreferenceInformation(collaboratorUser, PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) - .assertThat().field("id").is(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) - .and().field("value").is("true"); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.authenticateUser(collaboratorUser) + .usingAuthUser().getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) + .assertThat().field("id").is(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) + .and().field("value").is("true"); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify contributor user gets a specific preference with Rest API and response is successful (200)") @@ -74,11 +67,11 @@ public class GetPeoplePreferenceSanityTests extends RestTest dataUser.usingUser(userModel).addUserToSite(contributorUser, siteModel, UserRole.SiteContributor); dataSite.usingUser(contributorUser).usingSite(siteModel).addSiteToFavorites(); - restClient.authenticateUser(contributorUser); - peopleApi.getPersonPreferenceInformation(contributorUser, PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) - .assertThat().field("id").is(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) - .and().field("value").is("true"); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.authenticateUser(contributorUser) + .usingAuthUser().getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) + .assertThat().field("id").is(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) + .and().field("value").is("true"); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify consumer user gets a specific preference with Rest API and response is successful (200)") @@ -88,11 +81,11 @@ public class GetPeoplePreferenceSanityTests extends RestTest dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel, UserRole.SiteConsumer); dataSite.usingUser(consumerUser).usingSite(siteModel).addSiteToFavorites(); - restClient.authenticateUser(consumerUser); - peopleApi.getPersonPreferenceInformation(consumerUser, PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) - .assertThat().field("id").is(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) - .and().field("value").is("true"); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.authenticateUser(consumerUser) + .usingAuthUser().getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) + .assertThat().field("id").is(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) + .and().field("value").is("true"); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify admin user gets a specific preference with Rest API and response is successful (200)") @@ -101,11 +94,11 @@ public class GetPeoplePreferenceSanityTests extends RestTest UserModel adminUser = dataUser.getAdminUser(); dataSite.usingUser(adminUser).usingSite(siteModel).addSiteToFavorites(); - restClient.authenticateUser(adminUser); - peopleApi.getPersonPreferenceInformation(adminUser, PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) - .assertThat().field("id").is(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) - .and().field("value").is("true"); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.authenticateUser(adminUser) + .usingAuthUser().getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) + .assertThat().field("id").is(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) + .and().field("value").is("true"); + restClient.assertStatusCodeIs(HttpStatus.OK); } @Bug(id = "MNT-16904") @@ -117,8 +110,8 @@ public class GetPeoplePreferenceSanityTests extends RestTest dataSite.usingUser(managerUser).usingSite(siteModel).addSiteToFavorites(); managerUser.setPassword("newpassword"); - restClient.authenticateUser(managerUser); - peopleApi.getPersonPreferenceInformation(managerUser, PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.authenticateUser(managerUser) + .usingAuthUser().getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesSanityTests.java index 0c37b0cda..b20950c6e 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesSanityTests.java @@ -1,7 +1,6 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; -import org.alfresco.rest.requests.RestPeopleApi; import org.alfresco.utility.constants.PreferenceName; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.model.SiteModel; @@ -10,7 +9,6 @@ import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -24,9 +22,6 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) public class GetPeoplePreferencesSanityTests extends RestTest { - @Autowired - RestPeopleApi peopleApi; - UserModel userModel; SiteModel siteModel; @@ -35,8 +30,6 @@ public class GetPeoplePreferencesSanityTests extends RestTest { userModel = dataUser.createRandomTestUser(); siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - - peopleApi.useRestClient(restClient); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify manager user gets its preferences with Rest API and response is successful (200)") @@ -46,11 +39,12 @@ public class GetPeoplePreferencesSanityTests extends RestTest dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); dataSite.usingUser(managerUser).usingSite(siteModel).addSiteToFavorites(); - restClient.authenticateUser(managerUser); - peopleApi.getPersonPreferences(managerUser).assertThat().entriesListIsNotEmpty() - .assertThat().paginationExist() - .and().entriesListContains("id", PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.authenticateUser(managerUser) + .usingAuthUser() + .getPersonPreferences().assertThat().entriesListIsNotEmpty() + .assertThat().paginationExist() + .and().entriesListContains("id", PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify collaborator user gets its preferences with Rest API and response is successful (200)") @@ -60,11 +54,11 @@ public class GetPeoplePreferencesSanityTests extends RestTest dataUser.usingUser(userModel).addUserToSite(collaboratorUser, siteModel, UserRole.SiteCollaborator); dataSite.usingUser(collaboratorUser).usingSite(siteModel).addSiteToFavorites(); - restClient.authenticateUser(collaboratorUser); - peopleApi.getPersonPreferences(collaboratorUser).assertThat().entriesListIsNotEmpty() - .assertThat().paginationExist() - .and().entriesListContains("id", PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.authenticateUser(collaboratorUser) + .usingAuthUser().getPersonPreferences().assertThat().entriesListIsNotEmpty() + .assertThat().paginationExist() + .and().entriesListContains("id", PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify contributor user gets its preferences with Rest API and response is successful (200)") @@ -74,11 +68,11 @@ public class GetPeoplePreferencesSanityTests extends RestTest dataUser.usingUser(userModel).addUserToSite(contributorUser, siteModel, UserRole.SiteContributor); dataSite.usingUser(contributorUser).usingSite(siteModel).addSiteToFavorites(); - restClient.authenticateUser(contributorUser); - peopleApi.getPersonPreferences(contributorUser).assertThat().entriesListIsNotEmpty() - .assertThat().paginationExist() - .and().entriesListContains("id", PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.authenticateUser(contributorUser) + .usingAuthUser().getPersonPreferences().assertThat().entriesListIsNotEmpty() + .assertThat().paginationExist() + .and().entriesListContains("id", PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify consumer user gets its preferences with Rest API and response is successful (200)") @@ -88,11 +82,11 @@ public class GetPeoplePreferencesSanityTests extends RestTest dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel, UserRole.SiteConsumer); dataSite.usingUser(consumerUser).usingSite(siteModel).addSiteToFavorites(); - restClient.authenticateUser(consumerUser); - peopleApi.getPersonPreferences(consumerUser).assertThat().entriesListIsNotEmpty() - .assertThat().paginationExist() - .and().entriesListContains("id", PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.authenticateUser(consumerUser) + .usingAuthUser().getPersonPreferences().assertThat().entriesListIsNotEmpty() + .assertThat().paginationExist() + .and().entriesListContains("id", PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify admin user gets another user preferences with Rest API and response is successful (200)") @@ -103,11 +97,11 @@ public class GetPeoplePreferencesSanityTests extends RestTest dataSite.usingUser(managerUser).usingSite(siteModel).addSiteToFavorites(); UserModel adminUser = dataUser.getAdminUser(); - restClient.authenticateUser(adminUser); - peopleApi.getPersonPreferences(managerUser).assertThat().entriesListIsNotEmpty() - .assertThat().paginationExist() - .and().entriesListContains("id", PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.authenticateUser(adminUser) + .usingUser(managerUser).getPersonPreferences().assertThat().entriesListIsNotEmpty() + .assertThat().paginationExist() + .and().entriesListContains("id", PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); + restClient.assertStatusCodeIs(HttpStatus.OK); } @Bug(id = "MNT-16904") @@ -119,8 +113,9 @@ public class GetPeoplePreferencesSanityTests extends RestTest dataSite.usingUser(managerUser).usingSite(siteModel).addSiteToFavorites(); managerUser.setPassword("newpassword"); - restClient.authenticateUser(managerUser); - peopleApi.getPersonPreferences(managerUser); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.authenticateUser(managerUser) + .usingAuthUser() + .getPersonPreferences(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleSanityTests.java index 820eabf4c..d4258e6cb 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleSanityTests.java @@ -1,7 +1,6 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; -import org.alfresco.rest.requests.RestPeopleApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.model.SiteModel; @@ -9,7 +8,6 @@ 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.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -17,9 +15,6 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) public class GetPeopleSanityTests extends RestTest { - @Autowired - RestPeopleApi peopleApi; - UserModel userModel; SiteModel siteModel; UserModel searchedUser; @@ -32,8 +27,6 @@ public class GetPeopleSanityTests extends RestTest userModel = dataUser.createRandomTestUser(); siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); searchedUser = dataUser.createRandomTestUser(); - - peopleApi.useRestClient(restClient); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user gets a person with Rest API and response is successful") @@ -42,13 +35,14 @@ public class GetPeopleSanityTests extends RestTest UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); - restClient.authenticateUser(managerUser); - peopleApi.getPerson(searchedUser) - .assertThat().field("id").is(searchedUser.getUsername()) - .assertThat().field("firstName").is(searchedUser.getUsername()+" FirstName") - .and().field("email").is(searchedUser.getUsername()+ domain) - .and().field("emailNotificationsEnabled").is("true"); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.authenticateUser(managerUser) + .usingUser(searchedUser) + .getPerson() + .assertThat().field("id").is(searchedUser.getUsername()) + .assertThat().field("firstName").is(searchedUser.getUsername()+" FirstName") + .and().field("email").is(searchedUser.getUsername()+ domain) + .and().field("emailNotificationsEnabled").is("true"); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify collaborator user gets a person with Rest API and response is successful") @@ -57,13 +51,14 @@ public class GetPeopleSanityTests extends RestTest UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(collaboratorUser, siteModel, UserRole.SiteCollaborator); - restClient.authenticateUser(collaboratorUser); - peopleApi.getPerson(searchedUser) - .assertThat().field("id").is(searchedUser.getUsername()) - .assertThat().field("firstName").is(searchedUser.getUsername()+" FirstName") - .and().field("email").is(searchedUser.getUsername()+ domain) - .and().field("emailNotificationsEnabled").is("true"); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.authenticateUser(collaboratorUser) + .usingUser(searchedUser) + .getPerson() + .assertThat().field("id").is(searchedUser.getUsername()) + .assertThat().field("firstName").is(searchedUser.getUsername()+" FirstName") + .and().field("email").is(searchedUser.getUsername()+ domain) + .and().field("emailNotificationsEnabled").is("true"); + restClient.assertStatusCodeIs(HttpStatus.OK); } @Test(groups = TestGroup.COMMENTS) @@ -73,13 +68,14 @@ public class GetPeopleSanityTests extends RestTest UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(contributorUser, siteModel, UserRole.SiteContributor); - restClient.authenticateUser(contributorUser); - peopleApi.getPerson(searchedUser) - .assertThat().field("id").is(searchedUser.getUsername()) - .assertThat().field("firstName").is(searchedUser.getUsername()+" FirstName") - .and().field("email").is(searchedUser.getUsername()+ domain) - .and().field("emailNotificationsEnabled").is("true");; - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.authenticateUser(contributorUser) + .usingUser(searchedUser) + .getPerson() + .assertThat().field("id").is(searchedUser.getUsername()) + .assertThat().field("firstName").is(searchedUser.getUsername()+" FirstName") + .and().field("email").is(searchedUser.getUsername()+ domain) + .and().field("emailNotificationsEnabled").is("true");; + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify consumer user gets a person with Rest API and response is successful") @@ -88,13 +84,14 @@ public class GetPeopleSanityTests extends RestTest UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel, UserRole.SiteConsumer); - restClient.authenticateUser(consumerUser); - peopleApi.getPerson(searchedUser) - .assertThat().field("id").is(searchedUser.getUsername()) - .assertThat().field("firstName").is(searchedUser.getUsername()+" FirstName") - .and().field("email").is(searchedUser.getUsername()+ domain) - .and().field("emailNotificationsEnabled").is("true");; - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.authenticateUser(consumerUser) + .usingUser(searchedUser) + .getPerson() + .assertThat().field("id").is(searchedUser.getUsername()) + .assertThat().field("firstName").is(searchedUser.getUsername()+" FirstName") + .and().field("email").is(searchedUser.getUsername()+ domain) + .and().field("emailNotificationsEnabled").is("true");; + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify admin user gets a person with Rest API and response is successful") @@ -102,13 +99,14 @@ public class GetPeopleSanityTests extends RestTest { UserModel adminUser = dataUser.getAdminUser(); - restClient.authenticateUser(adminUser); - peopleApi.getPerson(searchedUser) - .assertThat().field("id").is(searchedUser.getUsername()) - .assertThat().field("firstName").is(searchedUser.getUsername()+" FirstName") - .and().field("email").is(searchedUser.getUsername()+ domain) - .and().field("emailNotificationsEnabled").is("true");; - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.authenticateUser(adminUser) + .usingUser(searchedUser) + .getPerson() + .assertThat().field("id").is(searchedUser.getUsername()) + .assertThat().field("firstName").is(searchedUser.getUsername()+" FirstName") + .and().field("email").is(searchedUser.getUsername()+ domain) + .and().field("emailNotificationsEnabled").is("true");; + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user gets a non existing person with Rest API and person is not found") @@ -118,8 +116,9 @@ public class GetPeopleSanityTests extends RestTest dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); UserModel searchedNonUser = new UserModel("nonexistinguser", DataUser.PASSWORD); - restClient.authenticateUser(managerUser); - peopleApi.getPerson(searchedNonUser); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); + restClient.authenticateUser(managerUser) + .usingUser(searchedNonUser) + .getPerson(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); } } diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestSanityTests.java index 43cd8cdec..6001a9600 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestSanityTests.java @@ -2,7 +2,6 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.requests.RestPeopleApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataSite; import org.alfresco.utility.data.DataUser; @@ -22,9 +21,6 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) public class GetSiteMembershipRequestSanityTests extends RestTest { - @Autowired - RestPeopleApi peopleApi; - @Autowired DataUser dataUser; @@ -43,8 +39,6 @@ public class GetSiteMembershipRequestSanityTests extends RestTest adminUser = dataUser.getAdminUser(); siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); - - peopleApi.useRestClient(restClient); } @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, @@ -53,12 +47,12 @@ public class GetSiteMembershipRequestSanityTests extends RestTest public void siteManagerIsAbleToRetrieveSiteMembershipRequest() throws JsonToModelConversionException, Exception { UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - peopleApi.addSiteMembershipRequest(newMember, siteModel); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .usingUser(newMember) + .addSiteMembershipRequest(siteModel); - peopleApi.getSiteMembershipRequest(newMember, siteModel); - peopleApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.OK); + restClient.usingUser(newMember).getSiteMembershipRequest(siteModel); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -67,12 +61,12 @@ public class GetSiteMembershipRequestSanityTests extends RestTest public void siteCollaboratorIsAbleToRetrieveSiteMembershipRequest() throws JsonToModelConversionException, Exception { UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - peopleApi.addSiteMembershipRequest(newMember, siteModel); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .usingUser(newMember) + .addSiteMembershipRequest(siteModel); - peopleApi.getSiteMembershipRequest(newMember, siteModel); - peopleApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.OK); + restClient.usingUser(newMember).getSiteMembershipRequest(siteModel); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -81,12 +75,12 @@ public class GetSiteMembershipRequestSanityTests extends RestTest public void siteContributorIsAbleToRetrieveSiteMembershipRequest() throws JsonToModelConversionException, Exception { UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - peopleApi.addSiteMembershipRequest(newMember, siteModel); - - peopleApi.getSiteMembershipRequest(newMember, siteModel); - peopleApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.OK); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) + .usingUser(newMember) + .addSiteMembershipRequest(siteModel); + + restClient.usingUser(newMember).getSiteMembershipRequest(siteModel); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -95,12 +89,12 @@ public class GetSiteMembershipRequestSanityTests extends RestTest public void siteConsumerIsAbleToRetrieveSiteMembershipRequest() throws JsonToModelConversionException, Exception { UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - peopleApi.addSiteMembershipRequest(newMember, siteModel); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + .usingUser(newMember) + .addSiteMembershipRequest(siteModel); - peopleApi.getSiteMembershipRequest(newMember, siteModel); - peopleApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.OK); + restClient.usingUser(newMember).getSiteMembershipRequest(siteModel); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -109,12 +103,12 @@ public class GetSiteMembershipRequestSanityTests extends RestTest public void adminIsAbleToRetrieveSiteMembershipRequest() throws JsonToModelConversionException, Exception { UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(adminUser); - peopleApi.addSiteMembershipRequest(newMember, siteModel); + restClient.authenticateUser(adminUser) + .usingUser(newMember) + .addSiteMembershipRequest(siteModel); - peopleApi.getSiteMembershipRequest(newMember, siteModel); - peopleApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.OK); + restClient.usingUser(newMember).getSiteMembershipRequest(siteModel); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -123,12 +117,11 @@ public class GetSiteMembershipRequestSanityTests extends RestTest public void unauthenticatedUserIsNotAbleToRetrieveSiteMembershipRequest() throws JsonToModelConversionException, Exception { UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(new UserModel("random user", "random password")); - peopleApi.addSiteMembershipRequest(newMember, siteModel); + restClient.authenticateUser(new UserModel("random user", "random password")) + .usingUser(newMember) + .addSiteMembershipRequest(siteModel); - peopleApi.getSiteMembershipRequest(newMember, siteModel); - peopleApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.UNAUTHORIZED); - } - + restClient.usingUser(newMember).getSiteMembershipRequest(siteModel); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java index 8461c2680..c0e8fa395 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java @@ -1,7 +1,6 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; -import org.alfresco.rest.requests.RestPeopleApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.RandomData; import org.alfresco.utility.model.SiteModel; @@ -10,7 +9,6 @@ import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.social.alfresco.api.entities.Site.Visibility; import org.testng.annotations.BeforeClass; @@ -24,9 +22,6 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) public class GetSiteMembershipRequestsSanityTests extends RestTest { - @Autowired - RestPeopleApi peopleApi; - UserModel userModel; SiteModel siteModel; UserModel newMember; @@ -38,12 +33,12 @@ public class GetSiteMembershipRequestsSanityTests extends RestTest String siteId = RandomData.getRandomName("site"); siteModel = dataSite.usingUser(userModel).createSite(new SiteModel(Visibility.MODERATED, siteId, siteId, siteId, siteId)); newMember = dataUser.createRandomTestUser(); - peopleApi.useRestClient(restClient); - restClient.authenticateUser(newMember); - peopleApi.addSiteMembershipRequest(newMember, siteModel); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(newMember) + .usingAuthUser().addSiteMembershipRequest(siteModel); + + restClient.assertStatusCodeIs(HttpStatus.CREATED); - peopleApi.useRestClient(restClient); } @Bug(id = "MNT-16557") @@ -53,9 +48,9 @@ public class GetSiteMembershipRequestsSanityTests extends RestTest UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); - restClient.authenticateUser(managerUser); - peopleApi.getSiteMembershipRequests(newMember).assertThat().entriesListIsNotEmpty(); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.authenticateUser(managerUser) + .usingUser(newMember).getSiteMembershipRequests().assertThat().entriesListIsNotEmpty(); + restClient.assertStatusCodeIs(HttpStatus.OK); } @Bug(id = "MNT-16557") @@ -65,9 +60,9 @@ public class GetSiteMembershipRequestsSanityTests extends RestTest UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(collaboratorUser, siteModel, UserRole.SiteCollaborator); - restClient.authenticateUser(collaboratorUser); - peopleApi.getSiteMembershipRequests(newMember); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + restClient.authenticateUser(collaboratorUser) + .usingUser(newMember).getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); } @Bug(id = "MNT-16557") @@ -77,9 +72,9 @@ public class GetSiteMembershipRequestsSanityTests extends RestTest UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(contributorUser, siteModel, UserRole.SiteContributor); - restClient.authenticateUser(contributorUser); - peopleApi.getSiteMembershipRequests(newMember); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + restClient.authenticateUser(contributorUser) + .usingUser(newMember).getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); } @Bug(id = "MNT-16557") @@ -89,9 +84,9 @@ public class GetSiteMembershipRequestsSanityTests extends RestTest UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel, UserRole.SiteConsumer); - restClient.authenticateUser(consumerUser); - peopleApi.getSiteMembershipRequests(newMember); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + restClient.authenticateUser(consumerUser) + .usingUser(newMember).getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); } @Bug(id = "MNT-16557") @@ -100,9 +95,9 @@ public class GetSiteMembershipRequestsSanityTests extends RestTest { UserModel adminUser = dataUser.getAdminUser(); - restClient.authenticateUser(adminUser); - peopleApi.getSiteMembershipRequests(newMember).assertThat().entriesListIsNotEmpty(); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.authenticateUser(adminUser) + .usingUser(newMember).getSiteMembershipRequests().assertThat().entriesListIsNotEmpty(); + restClient.assertStatusCodeIs(HttpStatus.OK); } @Bug(id = "MNT-16904") @@ -113,16 +108,16 @@ public class GetSiteMembershipRequestsSanityTests extends RestTest dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); managerUser.setPassword("newpassword"); - restClient.authenticateUser(managerUser); - peopleApi.getSiteMembershipRequests(newMember); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.authenticateUser(managerUser) + .usingUser(newMember).getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify a user gets all its own site membership requests with Rest API and response is successful (200)") public void oneUserGetsItsOwnSiteMembershipRequestsWithSuccess() throws Exception { - restClient.authenticateUser(newMember); - peopleApi.getSiteMembershipRequests(newMember).assertThat().entriesListIsNotEmpty(); - peopleApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.authenticateUser(newMember) + .usingUser(newMember).getSiteMembershipRequests().assertThat().entriesListIsNotEmpty(); + restClient.assertStatusCodeIs(HttpStatus.OK); } } diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java index b1f3eaad6..bf86866de 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java @@ -2,7 +2,6 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.requests.RestPeopleApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataSite; import org.alfresco.utility.data.DataUser; @@ -22,9 +21,6 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) public class GetSiteMembershipSanityTests extends RestTest { - @Autowired - RestPeopleApi peopleApi; - @Autowired DataUser dataUser; @@ -42,9 +38,7 @@ public class GetSiteMembershipSanityTests extends RestTest siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, - UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); - - peopleApi.useRestClient(restClient); + UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -52,64 +46,65 @@ public class GetSiteMembershipSanityTests extends RestTest description = "Verify site manager is able to retrieve site membership information of another user") public void siteManagerCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - peopleApi.getSiteMembership(adminUser, siteModel) - .assertThat().field("role").is(UserRole.SiteManager) - .and().field("id").is(siteModel.getId()) - .and().field("site").isNotEmpty(); - peopleApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.OK); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .usingUser(adminUser) + .getSiteMembership(siteModel) + .assertThat().field("role").is(UserRole.SiteManager) + .and().field("id").is(siteModel.getId()) + .and().field("site").isNotEmpty(); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site collaborator is able to retrieve site membership information of another user") public void siteCollaboratorCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - peopleApi.getSiteMembership(adminUser, siteModel).onSite() - .assertThat().field("role").is(UserRole.SiteCollaborator) - .and().field("id").is(siteModel.getId()); - peopleApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.OK); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .usingUser(adminUser) + .getSiteMembership(siteModel) + .onSite() + .assertThat().field("role").is(UserRole.SiteCollaborator) + .and().field("id").is(siteModel.getId()); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site contributor is able to retrieve site membership information of another user") public void siteContributorCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - peopleApi.getSiteMembership(adminUser, siteModel) - .assertThat().field("role").is(UserRole.SiteManager) - .and().field("id").is(siteModel.getId()) - .and().field("site").isNotEmpty(); - peopleApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.OK); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) + .usingUser(adminUser) + .getSiteMembership(siteModel) + .assertThat().field("role").is(UserRole.SiteManager) + .and().field("id").is(siteModel.getId()) + .and().field("site").isNotEmpty(); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site consumer is able to retrieve site membership information of another user") public void siteConsumerCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - peopleApi.getSiteMembership(adminUser, siteModel) - .assertThat().field("role").is(UserRole.SiteManager) - .and().field("id").is(siteModel.getId()) - .and().field("site").isNotEmpty(); - peopleApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.OK); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + .usingUser(adminUser) + .getSiteMembership(siteModel) + .assertThat().field("role").is(UserRole.SiteManager) + .and().field("id").is(siteModel.getId()) + .and().field("site").isNotEmpty(); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify admin user is able to retrieve site membership information of another user") public void adminCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(adminUser); - peopleApi.getSiteMembership(usersWithRoles.getOneUserWithRole(UserRole.SiteManager), siteModel) - .assertThat().field("role").is(UserRole.SiteManager) - .and().field("id").is(siteModel.getId()) - .and().field("site").isNotEmpty(); - peopleApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.OK); + restClient.authenticateUser(adminUser) + .usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .getSiteMembership(siteModel) + .assertThat().field("role").is(UserRole.SiteManager) + .and().field("id").is(siteModel.getId()) + .and().field("site").isNotEmpty(); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, @@ -117,10 +112,9 @@ public class GetSiteMembershipSanityTests extends RestTest @Bug(id = "MNT-16904") public void unauthenticatedUserCannotRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(new UserModel("random user", "random password")); - peopleApi.getSiteMembership(usersWithRoles.getOneUserWithRole(UserRole.SiteManager), siteModel); - peopleApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.UNAUTHORIZED); - } - + restClient.authenticateUser(new UserModel("random user", "random password")) + .usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .getSiteMembership(siteModel); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java index 8250b2162..18de516e2 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java @@ -2,7 +2,6 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.requests.RestPeopleApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.exception.DataPreparationException; @@ -12,7 +11,6 @@ import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -20,9 +18,6 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) public class GetSitesMembershipInformationSanityTests extends RestTest { - @Autowired - RestPeopleApi peopleApi; - private SiteModel siteModel; private UserModel adminUser; private ListUserWithRoles usersWithRoles; @@ -33,8 +28,6 @@ public class GetSitesMembershipInformationSanityTests extends RestTest adminUser = dataUser.getAdminUser(); siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); - - peopleApi.useRestClient(restClient); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -42,13 +35,13 @@ public class GetSitesMembershipInformationSanityTests extends RestTest description = "Verify site manager is able to retrieve sites membership information of another user") public void siteManagerIsAbleToRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - peopleApi.getSitesMembershipInformation(adminUser) - .assertThat().entriesListIsNotEmpty() - .and().paginationExist() - .and().paginationField("count").isNot("0"); - peopleApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.OK); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .usingUser(adminUser) + .getSitesMembershipInformation() + .assertThat().entriesListIsNotEmpty() + .and().paginationExist() + .and().paginationField("count").isNot("0"); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -56,13 +49,13 @@ public class GetSitesMembershipInformationSanityTests extends RestTest description = "Verify site collaborator is able to retrieve sites membership information of another user") public void siteCollaboratorIsAbleToRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - peopleApi.getSitesMembershipInformation(adminUser) - .assertThat().entriesListIsNotEmpty() - .and().paginationExist() - .and().paginationField("count").isNot("0"); - peopleApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.OK); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .usingUser(adminUser) + .getSitesMembershipInformation() + .assertThat().entriesListIsNotEmpty() + .and().paginationExist() + .and().paginationField("count").isNot("0"); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -70,13 +63,13 @@ public class GetSitesMembershipInformationSanityTests extends RestTest description = "Verify site contributor is able to retrieve sites membership information of another user") public void siteContributorIsAbleToRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - peopleApi.getSitesMembershipInformation(adminUser) - .assertThat().entriesListIsNotEmpty() - .and().paginationExist() - .and().paginationField("count").isNot("0"); - peopleApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.OK); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) + .usingUser(adminUser) + .getSitesMembershipInformation() + .assertThat().entriesListIsNotEmpty() + .and().paginationExist() + .and().paginationField("count").isNot("0"); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -84,13 +77,13 @@ public class GetSitesMembershipInformationSanityTests extends RestTest description = "Verify site consumer is able to retrieve sites membership information of another user") public void siteConsumerIsAbleToRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - peopleApi.getSitesMembershipInformation(adminUser) - .assertThat().entriesListIsNotEmpty() - .and().paginationExist() - .and().paginationField("count").isNot("0"); - peopleApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.OK); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + .usingUser(adminUser) + .getSitesMembershipInformation() + .assertThat().entriesListIsNotEmpty() + .and().paginationExist() + .and().paginationField("count").isNot("0"); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -98,13 +91,13 @@ public class GetSitesMembershipInformationSanityTests extends RestTest description = "Verify admin is able to retrieve sites membership information of another user") public void siteAdminIsAbleToRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(adminUser); - peopleApi.getSitesMembershipInformation(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .assertThat().entriesListIsNotEmpty() - .and().paginationExist() - .and().paginationField("count").isNot("0"); - peopleApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.OK); + restClient.authenticateUser(adminUser) + .usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .getSitesMembershipInformation() + .assertThat().entriesListIsNotEmpty() + .and().paginationExist() + .and().paginationField("count").isNot("0"); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -114,10 +107,9 @@ public class GetSitesMembershipInformationSanityTests extends RestTest public void unauthenticatedUserCannotRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception { UserModel inexistentUser = new UserModel("inexistent user", "wrong password"); - restClient.authenticateUser(inexistentUser); - peopleApi.getSitesMembershipInformation(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - peopleApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.authenticateUser(inexistentUser) + .usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .getSitesMembershipInformation(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } - } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestSanityTests.java index 3de639b01..b04bc76e5 100644 --- a/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestSanityTests.java @@ -2,7 +2,6 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.requests.RestPeopleApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataSite; import org.alfresco.utility.data.DataUser; @@ -25,9 +24,6 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) public class UpdateSiteMembershipRequestSanityTests extends RestTest { - @Autowired - RestPeopleApi peopleApi; - @Autowired DataUser dataUser; @@ -47,8 +43,6 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest siteModel = dataSite.usingUser(adminUser).createSite(new SiteModel(Visibility.MODERATED, siteId, siteId, siteId, siteId)); usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); - - peopleApi.useRestClient(restClient); updatedMessage = "Please review my request"; } @@ -58,15 +52,14 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest { UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember); - peopleApi.addSiteMembershipRequest(newMember, siteModel); - - peopleApi.updateSiteMembershipRequest(newMember, siteModel, updatedMessage) - .assertMembershipRequestMessageIs(updatedMessage) - .and().field("id").is(siteModel.getId()) - .and().field("modifiedAt").isNotEmpty(); - peopleApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.OK); + restClient.authenticateUser(newMember) + .usingAuthUser() + .addSiteMembershipRequest(siteModel); + restClient.usingUser(newMember).updateSiteMembershipRequest(siteModel, updatedMessage) + .assertMembershipRequestMessageIs(updatedMessage) + .and().field("id").is(siteModel.getId()) + .and().field("modifiedAt").isNotEmpty(); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -76,15 +69,15 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest { UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember); - peopleApi.addSiteMembershipRequest(newMember, siteModel); + restClient.authenticateUser(newMember) + .usingAuthUser() + .addSiteMembershipRequest(siteModel); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - peopleApi.updateSiteMembershipRequest(newMember, siteModel, updatedMessage); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .usingUser(newMember).updateSiteMembershipRequest(siteModel, updatedMessage); - peopleApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -94,15 +87,16 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest { UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember); - peopleApi.addSiteMembershipRequest(newMember, siteModel); + restClient.authenticateUser(newMember) + .usingAuthUser() + .addSiteMembershipRequest(siteModel); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - peopleApi.updateSiteMembershipRequest(newMember, siteModel, updatedMessage); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .usingUser(newMember) + .updateSiteMembershipRequest(siteModel, updatedMessage); - peopleApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -112,15 +106,14 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest { UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember); - peopleApi.addSiteMembershipRequest(newMember, siteModel); + restClient.authenticateUser(newMember) + .usingAuthUser().addSiteMembershipRequest(siteModel); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - peopleApi.updateSiteMembershipRequest(newMember, siteModel, updatedMessage); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) + .usingUser(newMember).updateSiteMembershipRequest(siteModel, updatedMessage); - peopleApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -130,15 +123,16 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest { UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember); - peopleApi.addSiteMembershipRequest(newMember, siteModel); + restClient.authenticateUser(newMember) + .usingAuthUser() + .addSiteMembershipRequest(siteModel); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - peopleApi.updateSiteMembershipRequest(newMember, siteModel, updatedMessage); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + .usingUser(newMember) + .updateSiteMembershipRequest(siteModel, updatedMessage); - peopleApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -149,15 +143,16 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest UserModel newMember = dataUser.createRandomTestUser(); UserModel otherMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember); - peopleApi.addSiteMembershipRequest(newMember, siteModel); + restClient.authenticateUser(newMember) + .usingAuthUser() + .addSiteMembershipRequest(siteModel); - restClient.authenticateUser(otherMember); - peopleApi.updateSiteMembershipRequest(newMember, siteModel, updatedMessage); + restClient.authenticateUser(otherMember) + .usingUser(newMember) + .updateSiteMembershipRequest(siteModel, updatedMessage); - peopleApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -167,14 +162,15 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest { UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember); - peopleApi.addSiteMembershipRequest(newMember, siteModel); + restClient.authenticateUser(newMember) + .usingAuthUser() + .addSiteMembershipRequest(siteModel); - restClient.authenticateUser(adminUser); - peopleApi.updateSiteMembershipRequest(newMember, siteModel, updatedMessage); + restClient.authenticateUser(adminUser) + .usingUser(newMember) + .updateSiteMembershipRequest(siteModel, updatedMessage); - peopleApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } } \ No newline at end of file From d016671cb23ba3292b8206dc6ab7e21270da830d Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Tue, 15 Nov 2016 00:30:41 +0200 Subject: [PATCH 0521/1491] addin parameters --- .../rest/people/DeleteFavoriteSiteSanityTests.java | 2 +- .../rest/people/GetFavoriteSiteSanityTests.java | 2 +- .../rest/sites/GetSiteContainerSanityTests.java | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java index ef21e8c65..c0b12ffb7 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java @@ -106,7 +106,7 @@ public class DeleteFavoriteSiteSanityTests extends RestTest dataSite.usingUser(anotherUser).usingSite(siteModel2).addSiteToFavorites(); restClient.authenticateUser(userAuth) - .usingAuthUser().removeFavoriteSite(siteModel1); + .usingUser(anotherUser).removeFavoriteSite(siteModel1); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } diff --git a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java index bcdc438c4..df0d7c2cb 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java @@ -119,7 +119,7 @@ public class GetFavoriteSiteSanityTests extends RestTest dataSite.usingUser(managerUser).usingSite(siteModel2).addSiteToFavorites(); restClient.authenticateUser(managerUser) - .usingAuthUser().getFavoriteSite(siteModel1); + .usingUser(userModel).getFavoriteSite(siteModel1); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java index b5a76fac5..4901b2e20 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java @@ -41,7 +41,7 @@ public class GetSiteContainerSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); siteContainerModel = restClient.usingSite(siteModel).getSiteContainers().getOneRandomEntry(); - restClient.usingSite(siteModel).getSiteContainer(siteContainerModel) + restClient.usingSite(siteModel).getSiteContainer(siteContainerModel.onModel()) .assertThat().field("id").is(siteContainerModel.onModel().getId()) .and().field("folderId").is(siteContainerModel.onModel().getFolderId()); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -53,7 +53,7 @@ public class GetSiteContainerSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); siteContainerModel = restClient.usingSite(siteModel).getSiteContainers().getOneRandomEntry(); - restClient.usingSite(siteModel).getSiteContainer(siteContainerModel) + restClient.usingSite(siteModel).getSiteContainer(siteContainerModel.onModel()) .and().field("id").is(siteContainerModel.onModel().getId()) .and().field("folderId").is(siteContainerModel.onModel().getFolderId()); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -65,7 +65,7 @@ public class GetSiteContainerSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); siteContainerModel = restClient.usingSite(siteModel).getSiteContainers().getOneRandomEntry(); - restClient.usingSite(siteModel).getSiteContainer(siteContainerModel) + restClient.usingSite(siteModel).getSiteContainer(siteContainerModel.onModel()) .assertThat().field("id").is(siteContainerModel.onModel().getId()) .and().field("folderId").is(siteContainerModel.onModel().getFolderId()); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -77,7 +77,7 @@ public class GetSiteContainerSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); siteContainerModel = restClient.usingSite(siteModel).getSiteContainers().getOneRandomEntry(); - restClient.usingSite(siteModel).getSiteContainer(siteContainerModel) + restClient.usingSite(siteModel).getSiteContainer(siteContainerModel.onModel()) .assertThat().field("id").is(siteContainerModel.onModel().getId()) .and().field("folderId").is(siteContainerModel.onModel().getFolderId()); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -89,7 +89,7 @@ public class GetSiteContainerSanityTests extends RestTest { restClient.authenticateUser(adminUserModel); siteContainerModel = restClient.usingSite(siteModel).getSiteContainers().getOneRandomEntry(); - restClient.usingSite(siteModel).getSiteContainer(siteContainerModel) + restClient.usingSite(siteModel).getSiteContainer(siteContainerModel.onModel()) .assertThat().field("id").is(siteContainerModel.onModel().getId()) .and().field("folderId").is(siteContainerModel.onModel().getFolderId()); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -107,7 +107,7 @@ public class GetSiteContainerSanityTests extends RestTest userModel.setPassword("user wrong password"); dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); restClient.authenticateUser(userModel) - .usingSite(siteModel).getSiteContainer(siteContainerModel); + .usingSite(siteModel).getSiteContainer(siteContainerModel.onModel()); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } From 2e8c88d5e105f2a6448ed77bb6c8b416608ed4be Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Tue, 15 Nov 2016 11:31:26 +0200 Subject: [PATCH 0522/1491] WIP: processes --- .../processes/AddProcessItemSanityTests.java | 22 +++++++++---------- .../processes/AddProcessSanityTests.java | 4 ++-- .../AddProcessVariableSanityTests.java | 4 ++-- .../processes/DeleteProcessSanityTests.java | 4 ++-- .../processes/GetProcessItemsSanityTests.java | 4 ++-- .../processes/GetProcessSanityTests.java | 4 ++-- .../processes/GetProcessTasksSanityTests.java | 4 ++-- .../processes/GetProcessesSanityTests.java | 4 ++-- .../GetProcessesVariablesSanityTests.java | 4 ++-- .../RemoveProcessItemSanityTests.java | 4 ++-- .../RemoveProcessVariableSanityTests.java | 4 ++-- .../UpdateProcessVariableSanityTests.java | 4 ++-- 12 files changed, 32 insertions(+), 34 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemSanityTests.java index a1d2e114c..8999d4641 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemSanityTests.java @@ -5,9 +5,12 @@ import org.alfresco.rest.RestWorkflowTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestItemModel; import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.requests.RestProcessesApi; import org.alfresco.utility.data.DataUser; -import org.alfresco.utility.model.*; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FileType; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; @@ -24,10 +27,6 @@ public class AddProcessItemSanityTests extends RestWorkflowTest { @Autowired private DataUser dataUser; - - @Autowired - private RestProcessesApi processesApi; - private FileModel document, document2, document3; private SiteModel siteModel; private UserModel userWhoStartsTask, assignee; @@ -44,8 +43,7 @@ public class AddProcessItemSanityTests extends RestWorkflowTest assignee = dataUser.createRandomTestUser(); siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); document = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); - processesApi.useRestClient(restClient); + dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); } @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, @@ -55,8 +53,8 @@ public class AddProcessItemSanityTests extends RestWorkflowTest restClient.authenticateUser(adminUser); document2 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file content"); dataContent.usingSite(siteModel).createContent(document2); - processModel = processesApi.getProcesses().getOneRandomEntry(); - processItem = processesApi.addProcessItem(processModel, document2); + processModel = restClient.getProcesses().getOneRandomEntry(); + processItem = restClient.usingProcess(processModel).addProcessItem(document2); processItem.assertThat().field("createdAt").isNotEmpty() .and().field("size").is(document2.getContent().length()) .and().field("createdBy").is(adminUser.getUsername()) @@ -66,8 +64,8 @@ public class AddProcessItemSanityTests extends RestWorkflowTest .and().field("id").isNotEmpty() .and().field("mimeType").is(document2.getFileType().mimeType); - processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); - processesApi.getProcessesItems(processModel).assertThat().entriesListContains("id", processItem.getId()); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.usingProcess(processModel).getProcessesItems().assertThat().entriesListContains("id", processItem.getId()); } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessSanityTests.java index 0eadb0c10..27192100f 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessSanityTests.java @@ -4,7 +4,7 @@ import org.alfresco.dataprep.CMISUtil.Priority; import org.alfresco.rest.RestWorkflowTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.requests.RestProcessesApi; +import org.alfresco.rest.requests.Processes; import org.alfresco.rest.requests.RestTenantApi; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.model.TestGroup; @@ -26,7 +26,7 @@ public class AddProcessSanityTests extends RestWorkflowTest private DataUser dataUser; @Autowired - private RestProcessesApi processesApi; + private Processes processesApi; @Autowired private RestTenantApi tenantApi; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java index 94d592a51..9761f44db 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java @@ -5,7 +5,7 @@ import org.alfresco.rest.RestWorkflowTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.rest.model.RestProcessVariableModel; -import org.alfresco.rest.requests.RestProcessesApi; +import org.alfresco.rest.requests.Processes; import org.alfresco.rest.requests.RestTenantApi; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.RandomData; @@ -30,7 +30,7 @@ public class AddProcessVariableSanityTests extends RestWorkflowTest private DataUser dataUser; @Autowired - private RestProcessesApi processesApi; + private Processes processesApi; @Autowired RestTenantApi tenantApi; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java index ceca23c82..bb90d0ec9 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java @@ -2,7 +2,7 @@ package org.alfresco.rest.workflow.processes; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestWorkflowTest; -import org.alfresco.rest.requests.RestProcessesApi; +import org.alfresco.rest.requests.Processes; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; @@ -26,7 +26,7 @@ public class DeleteProcessSanityTests extends RestWorkflowTest private DataUser dataUser; @Autowired - private RestProcessesApi processesApi; + private Processes processesApi; private FileModel document; private SiteModel siteModel; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsSanityTests.java index fd034b3a7..392fb21f2 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsSanityTests.java @@ -4,7 +4,7 @@ import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestWorkflowTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.requests.RestProcessesApi; +import org.alfresco.rest.requests.Processes; import org.alfresco.rest.requests.RestTenantApi; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.model.FileModel; @@ -29,7 +29,7 @@ public class GetProcessItemsSanityTests extends RestWorkflowTest private DataUser dataUser; @Autowired - private RestProcessesApi processesApi; + private Processes processesApi; @Autowired RestTenantApi tenantApi; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessSanityTests.java index 88e0ffd69..cb1820e85 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessSanityTests.java @@ -3,7 +3,7 @@ package org.alfresco.rest.workflow.processes; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestWorkflowTest; import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.requests.RestProcessesApi; +import org.alfresco.rest.requests.Processes; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; @@ -24,7 +24,7 @@ public class GetProcessSanityTests extends RestWorkflowTest private DataUser dataUser; @Autowired - private RestProcessesApi processesApi; + private Processes processesApi; private UserModel userWhoStartsProcess, assignee; private RestProcessModel addedProcess; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksSanityTests.java index a2a913a2c..747cd501a 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksSanityTests.java @@ -3,7 +3,7 @@ package org.alfresco.rest.workflow.processes; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestWorkflowTest; import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.requests.RestProcessesApi; +import org.alfresco.rest.requests.Processes; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.ProcessModel; import org.alfresco.utility.model.SiteModel; @@ -25,7 +25,7 @@ import org.testng.annotations.Test; public class GetProcessTasksSanityTests extends RestWorkflowTest { @Autowired - private RestProcessesApi processesApi; + private Processes processesApi; private UserModel userModel; private FileModel document; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java index 8f1bb24cf..31dbe544f 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java @@ -3,7 +3,7 @@ package org.alfresco.rest.workflow.processes; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestWorkflowTest; import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.requests.RestProcessesApi; +import org.alfresco.rest.requests.Processes; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; @@ -27,7 +27,7 @@ public class GetProcessesSanityTests extends RestWorkflowTest private DataUser dataUser; @Autowired - private RestProcessesApi processesApi; + private Processes processesApi; private FileModel document; private SiteModel siteModel; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesVariablesSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesVariablesSanityTests.java index a3ae34fac..3981f756e 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesVariablesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesVariablesSanityTests.java @@ -4,7 +4,7 @@ import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestWorkflowTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.requests.RestProcessesApi; +import org.alfresco.rest.requests.Processes; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; @@ -27,7 +27,7 @@ public class GetProcessesVariablesSanityTests extends RestWorkflowTest private DataUser dataUser; @Autowired - private RestProcessesApi processesApi; + private Processes processesApi; private FileModel document; private SiteModel siteModel; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessItemSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessItemSanityTests.java index 678402d23..acd4adf08 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessItemSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessItemSanityTests.java @@ -5,7 +5,7 @@ import org.alfresco.rest.RestWorkflowTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestItemModel; import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.requests.RestProcessesApi; +import org.alfresco.rest.requests.Processes; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; @@ -28,7 +28,7 @@ public class RemoveProcessItemSanityTests extends RestWorkflowTest private DataUser dataUser; @Autowired - private RestProcessesApi processesApi; + private Processes processesApi; private FileModel document, document2, document3; private SiteModel siteModel; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessVariableSanityTests.java index 7c61f5f41..3df3546fb 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessVariableSanityTests.java @@ -5,7 +5,7 @@ import org.alfresco.rest.RestWorkflowTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.rest.model.RestProcessVariableModel; -import org.alfresco.rest.requests.RestProcessesApi; +import org.alfresco.rest.requests.Processes; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; @@ -28,7 +28,7 @@ public class RemoveProcessVariableSanityTests extends RestWorkflowTest private DataUser dataUser; @Autowired - private RestProcessesApi processesApi; + private Processes processesApi; private FileModel document; private SiteModel siteModel; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/UpdateProcessVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/UpdateProcessVariableSanityTests.java index ae7171697..029bcd9c4 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/UpdateProcessVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/UpdateProcessVariableSanityTests.java @@ -6,7 +6,7 @@ import org.alfresco.rest.RestWorkflowTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.rest.model.RestProcessVariableModel; -import org.alfresco.rest.requests.RestProcessesApi; +import org.alfresco.rest.requests.Processes; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; @@ -29,7 +29,7 @@ public class UpdateProcessVariableSanityTests extends RestWorkflowTest private DataUser dataUser; @Autowired - private RestProcessesApi processesApi; + private Processes processesApi; private FileModel document; private SiteModel siteModel; From 5898e62723696e07fd025071e91ac8e76efa8203 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Tue, 15 Nov 2016 17:30:06 +0200 Subject: [PATCH 0523/1491] Refactor Test: AddRatingSanityTests.java --- .../rest/ratings/AddRatingSanityTests.java | 67 +++++++------------ 1 file changed, 25 insertions(+), 42 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java index e8fa4a1dd..ca7392560 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java @@ -2,7 +2,6 @@ package org.alfresco.rest.ratings; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; -import org.alfresco.rest.requests.RestRatingsApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.exception.DataPreparationException; @@ -15,7 +14,6 @@ import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.apache.commons.lang3.RandomStringUtils; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; @@ -24,9 +22,6 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) public class AddRatingSanityTests extends RestTest { - @Autowired - RestRatingsApi ratingsApi; - private UserModel userModel; private SiteModel siteModel; private UserModel adminUser; @@ -40,7 +35,7 @@ public class AddRatingSanityTests extends RestTest userModel = dataUser.createUser(RandomStringUtils.randomAlphanumeric(20)); adminUser = dataUser.getAdminUser(); siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - ratingsApi.useRestClient(restClient); + restClient.authenticateUser(adminUser); usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); @@ -57,60 +52,55 @@ public class AddRatingSanityTests extends RestTest TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role is able to post like rating to a document") public void managerIsAbleToLikeDocument() throws Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - ratingsApi.likeDocument(document) + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).usingNode(document).likeDocument() .assertThat().field("myRating").is("true") .and().field("id").is("likes") .and().field("aggregate").isNotEmpty(); - ratingsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + restClient.assertStatusCodeIs(HttpStatus.CREATED); } @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Collaborator role is able to post like rating to a document") public void collaboratorIsAbleToLikeDocument() throws Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - ratingsApi.likeDocument(document) + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).usingNode(document).likeDocument() .assertThat().field("myRating").is("true") .and().field("id").is("likes") .and().field("aggregate").isNotEmpty(); - ratingsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + restClient.assertStatusCodeIs(HttpStatus.CREATED); } @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Contributor role is able to post like rating to a document") public void contributorIsAbleToLikeDocument() throws Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - ratingsApi.likeDocument(document) + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingNode(document).likeDocument() .assertThat().field("myRating").is("true") .and().field("id").is("likes") .and().field("aggregate").isNotEmpty(); - ratingsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + restClient.assertStatusCodeIs(HttpStatus.CREATED); } @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role is able to post like rating to a document") public void consumerIsAbleToLikeDocument() throws Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - ratingsApi.likeDocument(document) + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).usingNode(document).likeDocument() .assertThat().field("myRating").is("true") .and().field("id").is("likes") .and().field("aggregate").isNotEmpty(); - ratingsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + restClient.assertStatusCodeIs(HttpStatus.CREATED); } @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify admin user is able to post like rating to a document") public void adminIsAbleToLikeDocument() throws Exception { - restClient.authenticateUser(adminUser); - ratingsApi.likeDocument(document) + restClient.authenticateUser(adminUser).usingNode(document).likeDocument() .assertThat().field("myRating").is("true") .and().field("id").is("likes") .and().field("aggregate").isNotEmpty(); - ratingsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + restClient.assertStatusCodeIs(HttpStatus.CREATED); } @TestRail(section = { TestGroup.REST_API, @@ -118,57 +108,52 @@ public class AddRatingSanityTests extends RestTest @Bug(id = "MNT-16904") public void unauthenticatedUserIsNotAbleToLikeDocument() throws Exception { - restClient.authenticateUser(new UserModel("random user", "random password")); - ratingsApi.likeDocument(document); - ratingsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.authenticateUser(new UserModel("random user", "random password")).usingNode(document).likeDocument(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role is able to post stars rating to a document") public void managerIsAbleToAddStarsToDocument() throws Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - ratingsApi.rateStarsToDocument(document, 5) + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).usingNode(document).rateStarsToDocument(5) .assertThat().field("myRating").is("5") .and().field("id").is("fiveStar") .and().field("aggregate").isNotEmpty(); - ratingsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + restClient.assertStatusCodeIs(HttpStatus.CREATED); } @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Collaborator role is able to post stars rating to a document") public void collaboratorIsAbleToAddStarsToDocument() throws Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - ratingsApi.rateStarsToDocument(document, 5) + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).usingNode(document).rateStarsToDocument(5) .assertThat().field("myRating").is("5") .and().field("id").is("fiveStar") .and().field("aggregate").isNotEmpty();; - ratingsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + restClient.assertStatusCodeIs(HttpStatus.CREATED); } @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Contributor role is able to post stars rating to a document") public void contributorIsAbleToAddStarsToDocument() throws Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - ratingsApi.rateStarsToDocument(document, 5) + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingNode(document).rateStarsToDocument(5) .assertThat().field("myRating").is("5") .and().field("id").is("fiveStar") .and().field("aggregate").isNotEmpty();; - ratingsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + restClient.assertStatusCodeIs(HttpStatus.CREATED); } @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role is able to post stars rating to a document") public void consumerIsAbleToAddStarsToDocument() throws Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - ratingsApi.rateStarsToDocument(document, 5) + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).usingNode(document).rateStarsToDocument(5) .assertThat().field("myRating").is("5") .and().field("id").is("fiveStar") .and().field("aggregate").isNotEmpty();; - ratingsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + restClient.assertStatusCodeIs(HttpStatus.CREATED); } @TestRail(section = { TestGroup.REST_API, @@ -176,12 +161,11 @@ public class AddRatingSanityTests extends RestTest public void adminIsAbleToAddStarsToDocument() throws Exception { int starsNo=3; - restClient.authenticateUser(adminUser); - ratingsApi.rateStarsToDocument(document, starsNo) + restClient.authenticateUser(adminUser).usingNode(document).rateStarsToDocument(starsNo) .assertThat().field("myRating").is(String.valueOf(starsNo)) .and().field("id").is("fiveStar") .and().field("aggregate").isNotEmpty();; - ratingsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + restClient.assertStatusCodeIs(HttpStatus.CREATED); } @TestRail(section = { TestGroup.REST_API, @@ -189,8 +173,7 @@ public class AddRatingSanityTests extends RestTest @Bug(id = "MNT-16904") public void unauthenticatedUserIsNotAbleToRateStarsToDocument() throws Exception { - restClient.authenticateUser(new UserModel("random user", "random password")); - ratingsApi.rateStarsToDocument(document, 5); - ratingsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.authenticateUser(new UserModel("random user", "random password")).usingNode(document).rateStarsToDocument(5); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } \ No newline at end of file From d9c66c17a0da3caba923d4eed1adb32e58bcc62b Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Tue, 15 Nov 2016 17:35:48 +0200 Subject: [PATCH 0524/1491] no message --- .../java/org/alfresco/rest/ratings/AddRatingSanityTests.java | 1 - 1 file changed, 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java index ca7392560..24246868d 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java @@ -35,7 +35,6 @@ public class AddRatingSanityTests extends RestTest userModel = dataUser.createUser(RandomStringUtils.randomAlphanumeric(20)); adminUser = dataUser.getAdminUser(); siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - restClient.authenticateUser(adminUser); usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); From 913c2407eab203d22654e6ee0ef7803bbd73fad4 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Tue, 15 Nov 2016 17:44:22 +0200 Subject: [PATCH 0525/1491] adding assertion on response code before further test checkings --- .../rest/ratings/AddRatingSanityTests.java | 97 ++++++++++--------- 1 file changed, 53 insertions(+), 44 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java index ca7392560..9aea115b3 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java @@ -2,6 +2,7 @@ package org.alfresco.rest.ratings; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestRatingModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.exception.DataPreparationException; @@ -28,6 +29,7 @@ public class AddRatingSanityTests extends RestTest private FolderModel folderModel; private FileModel document; private ListUserWithRoles usersWithRoles; + private RestRatingModel returnedRatingModel; //placeholder for returned model @BeforeClass(alwaysRun = true) public void dataPreparation() throws DataPreparationException @@ -52,55 +54,62 @@ public class AddRatingSanityTests extends RestTest TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role is able to post like rating to a document") public void managerIsAbleToLikeDocument() throws Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).usingNode(document).likeDocument() - .assertThat().field("myRating").is("true") - .and().field("id").is("likes") - .and().field("aggregate").isNotEmpty(); + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .usingNode(document).likeDocument(); restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("true") + .and().field("id").is("likes") + .and().field("aggregate").isNotEmpty(); } @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Collaborator role is able to post like rating to a document") public void collaboratorIsAbleToLikeDocument() throws Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).usingNode(document).likeDocument() - .assertThat().field("myRating").is("true") - .and().field("id").is("likes") - .and().field("aggregate").isNotEmpty(); + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .usingNode(document).likeDocument(); restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("true") + .and().field("id").is("likes") + .and().field("aggregate").isNotEmpty(); } @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Contributor role is able to post like rating to a document") public void contributorIsAbleToLikeDocument() throws Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingNode(document).likeDocument() - .assertThat().field("myRating").is("true") - .and().field("id").is("likes") - .and().field("aggregate").isNotEmpty(); - restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedRatingModel =restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingNode(document).likeDocument(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("true") + .and().field("id").is("likes") + .and().field("aggregate").isNotEmpty(); } @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role is able to post like rating to a document") public void consumerIsAbleToLikeDocument() throws Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).usingNode(document).likeDocument() - .assertThat().field("myRating").is("true") - .and().field("id").is("likes") - .and().field("aggregate").isNotEmpty(); + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).usingNode(document).likeDocument(); restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("true") + .and().field("id").is("likes") + .and().field("aggregate").isNotEmpty(); } @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify admin user is able to post like rating to a document") public void adminIsAbleToLikeDocument() throws Exception { - restClient.authenticateUser(adminUser).usingNode(document).likeDocument() - .assertThat().field("myRating").is("true") - .and().field("id").is("likes") - .and().field("aggregate").isNotEmpty(); + returnedRatingModel = restClient.authenticateUser(adminUser).usingNode(document).likeDocument(); restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("true") + .and().field("id").is("likes") + .and().field("aggregate").isNotEmpty(); } @TestRail(section = { TestGroup.REST_API, @@ -116,56 +125,56 @@ public class AddRatingSanityTests extends RestTest TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role is able to post stars rating to a document") public void managerIsAbleToAddStarsToDocument() throws Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).usingNode(document).rateStarsToDocument(5) - .assertThat().field("myRating").is("5") - .and().field("id").is("fiveStar") - .and().field("aggregate").isNotEmpty(); + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).usingNode(document).rateStarsToDocument(5); restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedRatingModel.assertThat().field("myRating").is("5") + .and().field("id").is("fiveStar") + .and().field("aggregate").isNotEmpty(); } @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Collaborator role is able to post stars rating to a document") public void collaboratorIsAbleToAddStarsToDocument() throws Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).usingNode(document).rateStarsToDocument(5) - .assertThat().field("myRating").is("5") - .and().field("id").is("fiveStar") - .and().field("aggregate").isNotEmpty();; - restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).usingNode(document).rateStarsToDocument(5); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedRatingModel.assertThat().field("myRating").is("5") + .and().field("id").is("fiveStar") + .and().field("aggregate").isNotEmpty(); + } @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Contributor role is able to post stars rating to a document") public void contributorIsAbleToAddStarsToDocument() throws Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingNode(document).rateStarsToDocument(5) - .assertThat().field("myRating").is("5") - .and().field("id").is("fiveStar") - .and().field("aggregate").isNotEmpty();; + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingNode(document).rateStarsToDocument(5); restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedRatingModel.assertThat().field("myRating").is("5") + .and().field("id").is("fiveStar") + .and().field("aggregate").isNotEmpty(); } @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role is able to post stars rating to a document") public void consumerIsAbleToAddStarsToDocument() throws Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).usingNode(document).rateStarsToDocument(5) - .assertThat().field("myRating").is("5") - .and().field("id").is("fiveStar") - .and().field("aggregate").isNotEmpty();; + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).usingNode(document).rateStarsToDocument(5); restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedRatingModel.assertThat().field("myRating").is("5") + .and().field("id").is("fiveStar") + .and().field("aggregate").isNotEmpty(); } @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify admin user is able to post stars rating to a document") public void adminIsAbleToAddStarsToDocument() throws Exception - { - int starsNo=3; - restClient.authenticateUser(adminUser).usingNode(document).rateStarsToDocument(starsNo) - .assertThat().field("myRating").is(String.valueOf(starsNo)) - .and().field("id").is("fiveStar") - .and().field("aggregate").isNotEmpty();; + { + returnedRatingModel = restClient.authenticateUser(adminUser).usingNode(document).rateStarsToDocument(3); restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedRatingModel.assertThat().field("myRating").is(String.valueOf(3)) + .and().field("id").is("fiveStar") + .and().field("aggregate").isNotEmpty();; } @TestRail(section = { TestGroup.REST_API, From e5c2e3703ae127347911fa2d23d0d39fefb15972 Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 16 Nov 2016 10:43:23 +0200 Subject: [PATCH 0526/1491] update tests based on new refactored DSL --- .../processes/AddProcessItemSanityTests.java | 60 ++++++++----------- 1 file changed, 25 insertions(+), 35 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemSanityTests.java index 8999d4641..d14fa629d 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemSanityTests.java @@ -5,16 +5,10 @@ import org.alfresco.rest.RestWorkflowTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestItemModel; import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.utility.data.DataUser; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FileType; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.model.*; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -25,14 +19,10 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY}) public class AddProcessItemSanityTests extends RestWorkflowTest { - @Autowired - private DataUser dataUser; - private FileModel document, document2, document3; + private FileModel document, document2; private SiteModel siteModel; - private UserModel userWhoStartsTask, assignee; + private UserModel userWhoStartsTask, assignee, adminUser; private RestProcessModel processModel; - private UserModel adminUser; - private RestItemModel processItem; @BeforeClass(alwaysRun = true) @@ -43,18 +33,19 @@ public class AddProcessItemSanityTests extends RestWorkflowTest assignee = dataUser.createRandomTestUser(); siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); document = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); + dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); } - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Create non-existing process item") public void addProcessItem() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(adminUser); document2 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file content"); dataContent.usingSite(siteModel).createContent(document2); - processModel = restClient.getProcesses().getOneRandomEntry(); + + processModel = restClient.authenticateUser(adminUser).getProcesses().getOneRandomEntry().onModel(); processItem = restClient.usingProcess(processModel).addProcessItem(document2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); processItem.assertThat().field("createdAt").isNotEmpty() .and().field("size").is(document2.getContent().length()) .and().field("createdBy").is(adminUser.getUsername()) @@ -63,35 +54,34 @@ public class AddProcessItemSanityTests extends RestWorkflowTest .and().field("modifiedBy").is(adminUser.getUsername()) .and().field("id").isNotEmpty() .and().field("mimeType").is(document2.getFileType().mimeType); - - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.usingProcess(processModel).getProcessesItems().assertThat().entriesListContains("id", processItem.getId()); - + + restClient.usingProcess(processModel).getProcessItems() + .assertThat().entriesListContains("id", processItem.getId()); } - + @Bug(id= "MNT-16966") - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Add process item that already exists") public void addProcessItemThatAlreadyExists() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(adminUser); - document3 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - processModel = processesApi.getProcesses().getOneRandomEntry(); - processItem = processesApi.addProcessItem(processModel, document3); + document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + + processModel = restClient.authenticateUser(adminUser).getProcesses().getOneRandomEntry().onModel(); + processItem = restClient.usingProcess(processModel).addProcessItem(document2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); processItem.assertThat().field("createdAt").isNotEmpty() .and().field("size").is("19") .and().field("createdBy").is(adminUser.getUsername()) .and().field("modifiedAt").isNotEmpty() - .and().field("name").is(document3.getName()) + .and().field("name").is(document2.getName()) .and().field("modifiedBy").is(adminUser.getUsername()) .and().field("id").isNotEmpty() - .and().field("mimeType").is(document3.getFileType().mimeType); + .and().field("mimeType").is(document2.getFileType().mimeType); - processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); - processesApi.getProcessesItems(processModel) - .assertThat().entriesListContains("id", processItem.getId()).and() - .entriesListContains("name", document3.getName()); - processItem = processesApi.addProcessItem(processModel, document3); - processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.BAD_REQUEST); + restClient.usingProcess(processModel).getProcessItems() + .assertThat().entriesListContains("id", processItem.getId()) + .and().entriesListContains("name", document2.getName()); + restClient.usingProcess(processModel).addProcessItem(document2); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); } } From 7ba600ec8f9bdc4193c85c692c658ab28fe95ab5 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Wed, 16 Nov 2016 10:48:36 +0200 Subject: [PATCH 0527/1491] added javaDoc, refactor usingNode to usingResource --- .../rest/comments/AddCommentSanityTests.java | 12 +++++----- .../rest/comments/AddCommentsSanityTests.java | 12 +++++----- .../comments/DeleteCommentsSanityTests.java | 14 +++++------ .../rest/comments/GetCommentsSanityTests.java | 22 ++++++++--------- .../comments/UpdateCommentsSanityTests.java | 18 +++++++------- .../org/alfresco/rest/demo/RestDemoTests.java | 4 ++-- .../rest/demo/SampleCommentsTests.java | 8 +++---- .../rest/ratings/AddRatingSanityTests.java | 24 +++++++++---------- 8 files changed, 57 insertions(+), 57 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java index b3eb6cea5..a21cdd903 100644 --- a/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java @@ -46,7 +46,7 @@ public class AddCommentSanityTests extends RestTest { restClient.authenticateUser(adminUserModel); String newContent = "This is a new comment added by " + adminUserModel.getUsername(); - restClient.usingNode(document).addComment(newContent) + restClient.usingResource(document).addComment(newContent) .assertThat().field("content").isNotEmpty() .and().field("content").is(newContent); restClient.assertStatusCodeIs(HttpStatus.CREATED); @@ -57,7 +57,7 @@ public class AddCommentSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); String contentSiteManger = "This is a new comment added by user with role: " + UserRole.SiteManager; - restClient.usingNode(document).addComment(contentSiteManger) + restClient.usingResource(document).addComment(contentSiteManger) .assertThat().field("content").isNotEmpty() .and().field("content").is(contentSiteManger); restClient.assertStatusCodeIs(HttpStatus.CREATED); @@ -68,7 +68,7 @@ public class AddCommentSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); String contentSiteContributor = "This is a new comment added by user with role" + UserRole.SiteContributor; - restClient.usingNode(document).addComment(contentSiteContributor) + restClient.usingResource(document).addComment(contentSiteContributor) .assertThat().field("content").isNotEmpty() .and().field("content").is(contentSiteContributor); restClient.assertStatusCodeIs(HttpStatus.CREATED); @@ -79,7 +79,7 @@ public class AddCommentSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); String contentSiteCollaborator = "This is a new comment added by user with role: " + UserRole.SiteCollaborator; - restClient.usingNode(document).addComment(contentSiteCollaborator) + restClient.usingResource(document).addComment(contentSiteCollaborator) .assertThat().field("content").isNotEmpty() .and().field("content").is(contentSiteCollaborator); restClient.assertStatusCodeIs(HttpStatus.CREATED); @@ -90,7 +90,7 @@ public class AddCommentSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); String contentSiteConsumer = "This is a new comment added by user with role: " + UserRole.SiteConsumer; - restClient.usingNode(document).addComment(contentSiteConsumer); + restClient.usingResource(document).addComment(contentSiteConsumer); restClient .assertStatusCodeIs(HttpStatus.FORBIDDEN) .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); @@ -101,7 +101,7 @@ public class AddCommentSanityTests extends RestTest public void unauthenticatedUserIsNotAbleToAddComment() throws JsonToModelConversionException, Exception { restClient.authenticateUser(new UserModel("random user", "random password")); - restClient.usingNode(document).addComment("This is a new comment"); + restClient.usingResource(document).addComment("This is a new comment"); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java index e8b84614c..751747cc3 100644 --- a/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java @@ -57,7 +57,7 @@ public class AddCommentsSanityTests extends RestTest public void adminIsAbleToAddComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel) - .usingNode(document).addComments(comment1, comment2) + .usingResource(document).addComments(comment1, comment2) .assertThat().entriesListIsNotEmpty() .and().entriesListContains("content", comment1) .and().entriesListContains("content", comment2); @@ -69,7 +69,7 @@ public class AddCommentsSanityTests extends RestTest public void managerIsAbleToAddComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .usingNode(document).addComments(comment1, comment2) + .usingResource(document).addComments(comment1, comment2) .assertThat().entriesListIsNotEmpty() .and().entriesListContains("content", comment1) .and().entriesListContains("content", comment2); @@ -81,7 +81,7 @@ public class AddCommentsSanityTests extends RestTest public void contributorIsAbleToAddComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) - .usingNode(document).addComments(comment1, comment2) + .usingResource(document).addComments(comment1, comment2) .assertThat().entriesListIsNotEmpty() .and().entriesListContains("content", comment1) .and().entriesListContains("content", comment2); @@ -93,7 +93,7 @@ public class AddCommentsSanityTests extends RestTest public void collaboratorIsAbleToAddComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .usingNode(document).addComments(comment1, comment2) + .usingResource(document).addComments(comment1, comment2) .assertThat().paginationExist().and().entriesListIsNotEmpty() .and().entriesListContains("content", comment1) .and().entriesListContains("content", comment2); @@ -106,7 +106,7 @@ public class AddCommentsSanityTests extends RestTest public void consumerIsAbleToAddComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .usingNode(document).addComments(comment1, comment2); + .usingResource(document).addComments(comment1, comment2); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @@ -117,7 +117,7 @@ public class AddCommentsSanityTests extends RestTest public void unauthenticatedUserIsNotAbleToAddComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(new UserModel("random user", "random password")) - .usingNode(document).addComments(comment1, comment2); + .usingResource(document).addComments(comment1, comment2); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java index e965552f1..79f39ae48 100644 --- a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java @@ -52,7 +52,7 @@ public class DeleteCommentsSanityTests extends RestTest public void addCommentToDocument() throws Exception { restClient.authenticateUser(adminUserModel); - comment = restClient.usingNode(document).addComment("This is a new comment"); + comment = restClient.usingResource(document).addComment("This is a new comment"); } @TestRail(section = { TestGroup.REST_API, @@ -60,7 +60,7 @@ public class DeleteCommentsSanityTests extends RestTest public void adminIsAbleToDeleteComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); - restClient.usingNode(document).deleteComment(comment); + restClient.usingResource(document).deleteComment(comment); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } @@ -69,7 +69,7 @@ public class DeleteCommentsSanityTests extends RestTest public void managerIsAbleToDeleteComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.usingNode(document).deleteComment(comment); + restClient.usingResource(document).deleteComment(comment); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } @@ -78,7 +78,7 @@ public class DeleteCommentsSanityTests extends RestTest public void collaboratorIsNotAbleToDeleteComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.usingNode(document).deleteComment(comment); + restClient.usingResource(document).deleteComment(comment); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @@ -88,7 +88,7 @@ public class DeleteCommentsSanityTests extends RestTest public void contributorIsNotAbleToDeleteComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - restClient.usingNode(document).deleteComment(comment); + restClient.usingResource(document).deleteComment(comment); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @@ -98,7 +98,7 @@ public class DeleteCommentsSanityTests extends RestTest public void consumerIsNotAbleToDeleteComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.usingNode(document).deleteComment(comment); + restClient.usingResource(document).deleteComment(comment); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @@ -109,7 +109,7 @@ public class DeleteCommentsSanityTests extends RestTest { UserModel nonexistentModel = new UserModel("nonexistentUser", "nonexistentPassword"); restClient.authenticateUser(nonexistentModel); - restClient.usingNode(document).deleteComment(comment); + restClient.usingResource(document).deleteComment(comment); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java index 672d81d78..3894b81a0 100644 --- a/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java @@ -44,7 +44,7 @@ public class GetCommentsSanityTests extends RestTest siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); content = "This is a new comment"; - restClient.usingNode(document).addComment(content); + restClient.usingResource(document).addComment(content); usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); } @@ -54,7 +54,7 @@ public class GetCommentsSanityTests extends RestTest public void adminIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); - restClient.usingNode(document).getNodeComments(); + restClient.usingResource(document).getNodeComments(); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -63,7 +63,7 @@ public class GetCommentsSanityTests extends RestTest public void managerIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.usingNode(document).getNodeComments() + restClient.usingResource(document).getNodeComments() .assertThat().entriesListContains("content", content); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -74,7 +74,7 @@ public class GetCommentsSanityTests extends RestTest public void contributorIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - restClient.usingNode(document).getNodeComments() + restClient.usingResource(document).getNodeComments() .assertThat().entriesListContains("content", content); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -85,7 +85,7 @@ public class GetCommentsSanityTests extends RestTest public void collaboratorIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.usingNode(document).getNodeComments() + restClient.usingResource(document).getNodeComments() .assertThat().entriesListContains("content", content); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -95,7 +95,7 @@ public class GetCommentsSanityTests extends RestTest public void consumerIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.usingNode(document).getNodeComments() + restClient.usingResource(document).getNodeComments() .assertThat().entriesListContains("content", content); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -107,7 +107,7 @@ public class GetCommentsSanityTests extends RestTest { UserModel nonexistentModel = new UserModel("nonexistentUser", "nonexistentPassword"); restClient.authenticateUser(nonexistentModel); - restClient.usingNode(document).getNodeComments(); + restClient.usingResource(document).getNodeComments(); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } @@ -118,10 +118,10 @@ public class GetCommentsSanityTests extends RestTest userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); restClient.authenticateUser(userModel); String contentManager = "This is a new comment added by " + userModel.getUsername(); - restClient.usingNode(document).addComment(contentManager); + restClient.usingResource(document).addComment(contentManager); restClient.assertStatusCodeIs(HttpStatus.CREATED); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.usingNode(document).getNodeComments() + restClient.usingResource(document).getNodeComments() .assertThat().entriesListContains("content", contentManager); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -134,10 +134,10 @@ public class GetCommentsSanityTests extends RestTest userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); restClient.authenticateUser(userModel); String contentCollaborator = "This is a new comment added by " + userModel.getUsername(); - restClient.usingNode(document).addComment(contentCollaborator); + restClient.usingResource(document).addComment(contentCollaborator); restClient.assertStatusCodeIs(HttpStatus.CREATED); restClient.authenticateUser(adminUserModel); - restClient.usingNode(document).getNodeComments() + restClient.usingResource(document).getNodeComments() .assertThat().entriesListContains("content", contentCollaborator); restClient.assertStatusCodeIs(HttpStatus.OK); diff --git a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java index 4e3a071a5..365ce310c 100644 --- a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java @@ -45,7 +45,7 @@ public class UpdateCommentsSanityTests extends RestTest siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - commentModel = restClient.usingNode(document).addComment("This is a new comment"); + commentModel = restClient.usingResource(document).addComment("This is a new comment"); usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); } @@ -56,7 +56,7 @@ public class UpdateCommentsSanityTests extends RestTest { restClient.authenticateUser(adminUserModel); String updatedContent = "This is the updated comment with admin user"; - restClient.usingNode(document).updateComment(commentModel, updatedContent) + restClient.usingResource(document).updateComment(commentModel, updatedContent) .assertThat().field("content").isNotEmpty() .and().field("content").is(updatedContent); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -67,7 +67,7 @@ public class UpdateCommentsSanityTests extends RestTest public void managerIsAbleToUpdateComment() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.usingNode(document).updateComment(commentModel, "This is the updated comment with Manager user") + restClient.usingResource(document).updateComment(commentModel, "This is the updated comment with Manager user") .and().field("content").is("This is the updated comment with Manager user") .and().field("canEdit").is(true) .and().field("canDelete").is(true); @@ -80,7 +80,7 @@ public class UpdateCommentsSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); String updatedContent = "This is the updated comment with Contributor user"; - restClient.usingNode(document).updateComment(commentModel, updatedContent); + restClient.usingResource(document).updateComment(commentModel, updatedContent); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @@ -90,7 +90,7 @@ public class UpdateCommentsSanityTests extends RestTest public void consumerIsNotAbleToUpdateComment() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.usingNode(document).updateComment(commentModel, "This is the updated comment with Consumer user"); + restClient.usingResource(document).updateComment(commentModel, "This is the updated comment with Consumer user"); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @@ -101,7 +101,7 @@ public class UpdateCommentsSanityTests extends RestTest public void collaboratorIsNotAbleToUpdateComment() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.usingNode(document).updateComment(commentModel, "This is the updated comment with Collaborator user"); + restClient.usingResource(document).updateComment(commentModel, "This is the updated comment with Collaborator user"); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @@ -113,7 +113,7 @@ public class UpdateCommentsSanityTests extends RestTest { UserModel incorrectUserModel = new UserModel("userName", "password"); restClient.authenticateUser(incorrectUserModel) - .usingNode(document).getNodeComments(); + .usingResource(document).getNodeComments(); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } @@ -124,7 +124,7 @@ public class UpdateCommentsSanityTests extends RestTest FolderModel content = FolderModel.getRandomFolderModel(); content.setNodeRef("node ref that does not exist"); - restClient.usingNode(content).updateComment(commentModel, "This is the updated comment."); + restClient.usingResource(content).updateComment(commentModel, "This is the updated comment."); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) .assertLastError().containsSummary("node ref that does not exist was not found"); } @@ -137,7 +137,7 @@ public class UpdateCommentsSanityTests extends RestTest RestCommentModel comment = new RestCommentModel(); String id = "comment id that does not exist"; comment.setId(id); - restClient.usingNode(document).updateComment(comment, "This is the updated comment."); + restClient.usingResource(document).updateComment(comment, "This is the updated comment."); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, id)); } diff --git a/e2e-test/java/org/alfresco/rest/demo/RestDemoTests.java b/e2e-test/java/org/alfresco/rest/demo/RestDemoTests.java index 9ce3b5b10..9c53bb227 100644 --- a/e2e-test/java/org/alfresco/rest/demo/RestDemoTests.java +++ b/e2e-test/java/org/alfresco/rest/demo/RestDemoTests.java @@ -65,8 +65,8 @@ public class RestDemoTests extends RestTest .usingResource(FolderModel.getSharedFolderModel()) .createContent(DocumentType.TEXT_PLAIN); // add new comment - restClient.usingNode(fileModel).addComment("This is a new comment"); - restClient.usingNode(fileModel).getNodeComments() + restClient.usingResource(fileModel).addComment("This is a new comment"); + restClient.usingResource(fileModel).getNodeComments() .assertThat().entriesListIsNotEmpty().and() .entriesListContains("content", "This is a new comment"); } diff --git a/e2e-test/java/org/alfresco/rest/demo/SampleCommentsTests.java b/e2e-test/java/org/alfresco/rest/demo/SampleCommentsTests.java index d8292d40b..dd82faea0 100644 --- a/e2e-test/java/org/alfresco/rest/demo/SampleCommentsTests.java +++ b/e2e-test/java/org/alfresco/rest/demo/SampleCommentsTests.java @@ -36,7 +36,7 @@ public class SampleCommentsTests extends RestTest description= "Verify admin user adds comments with Rest API and status code is 200") public void admiShouldAddComment() throws JsonToModelConversionException, Exception { - restClient.usingNode(document).addComment("This is a new comment"); + restClient.usingResource(document).addComment("This is a new comment"); restClient.assertStatusCodeIs(HttpStatus.CREATED); } @@ -44,7 +44,7 @@ public class SampleCommentsTests extends RestTest description= "Verify admin user gets comments with Rest API and status code is 200") public void admiShouldRetrieveComments() throws Exception { - restClient.usingNode(document).getNodeComments(); + restClient.usingResource(document).getNodeComments(); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -52,9 +52,9 @@ public class SampleCommentsTests extends RestTest description= "Verify admin user updates comments with Rest API") public void adminShouldUpdateComment() throws JsonToModelConversionException, Exception { - RestCommentModel commentModel = restClient.usingNode(document).addComment("This is a new comment"); + RestCommentModel commentModel = restClient.usingResource(document).addComment("This is a new comment"); - restClient.usingNode(document).updateComment(commentModel, "This is the updated comment with Collaborator user") + restClient.usingResource(document).updateComment(commentModel, "This is the updated comment with Collaborator user") .assertThat().field("content").is("This is the updated comment with Collaborator user"); } diff --git a/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java index f5b6d06bf..c93340c96 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java @@ -54,7 +54,7 @@ public class AddRatingSanityTests extends RestTest public void managerIsAbleToLikeDocument() throws Exception { returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .usingNode(document).likeDocument(); + .usingResource(document).likeDocument(); restClient.assertStatusCodeIs(HttpStatus.CREATED); returnedRatingModel.assertThat().field("myRating").is("true") @@ -67,7 +67,7 @@ public class AddRatingSanityTests extends RestTest public void collaboratorIsAbleToLikeDocument() throws Exception { returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .usingNode(document).likeDocument(); + .usingResource(document).likeDocument(); restClient.assertStatusCodeIs(HttpStatus.CREATED); returnedRatingModel.assertThat().field("myRating").is("true") @@ -79,7 +79,7 @@ public class AddRatingSanityTests extends RestTest TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Contributor role is able to post like rating to a document") public void contributorIsAbleToLikeDocument() throws Exception { - returnedRatingModel =restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingNode(document).likeDocument(); + returnedRatingModel =restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingResource(document).likeDocument(); restClient.assertStatusCodeIs(HttpStatus.CREATED); returnedRatingModel.assertThat().field("myRating").is("true") @@ -91,7 +91,7 @@ public class AddRatingSanityTests extends RestTest TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role is able to post like rating to a document") public void consumerIsAbleToLikeDocument() throws Exception { - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).usingNode(document).likeDocument(); + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).usingResource(document).likeDocument(); restClient.assertStatusCodeIs(HttpStatus.CREATED); returnedRatingModel.assertThat().field("myRating").is("true") @@ -103,7 +103,7 @@ public class AddRatingSanityTests extends RestTest TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify admin user is able to post like rating to a document") public void adminIsAbleToLikeDocument() throws Exception { - returnedRatingModel = restClient.authenticateUser(adminUser).usingNode(document).likeDocument(); + returnedRatingModel = restClient.authenticateUser(adminUser).usingResource(document).likeDocument(); restClient.assertStatusCodeIs(HttpStatus.CREATED); returnedRatingModel.assertThat().field("myRating").is("true") @@ -116,7 +116,7 @@ public class AddRatingSanityTests extends RestTest @Bug(id = "MNT-16904") public void unauthenticatedUserIsNotAbleToLikeDocument() throws Exception { - restClient.authenticateUser(new UserModel("random user", "random password")).usingNode(document).likeDocument(); + restClient.authenticateUser(new UserModel("random user", "random password")).usingResource(document).likeDocument(); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } @@ -124,7 +124,7 @@ public class AddRatingSanityTests extends RestTest TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role is able to post stars rating to a document") public void managerIsAbleToAddStarsToDocument() throws Exception { - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).usingNode(document).rateStarsToDocument(5); + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).usingResource(document).rateStarsToDocument(5); restClient.assertStatusCodeIs(HttpStatus.CREATED); returnedRatingModel.assertThat().field("myRating").is("5") .and().field("id").is("fiveStar") @@ -135,7 +135,7 @@ public class AddRatingSanityTests extends RestTest TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Collaborator role is able to post stars rating to a document") public void collaboratorIsAbleToAddStarsToDocument() throws Exception { - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).usingNode(document).rateStarsToDocument(5); + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).usingResource(document).rateStarsToDocument(5); restClient.assertStatusCodeIs(HttpStatus.CREATED); returnedRatingModel.assertThat().field("myRating").is("5") .and().field("id").is("fiveStar") @@ -147,7 +147,7 @@ public class AddRatingSanityTests extends RestTest TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Contributor role is able to post stars rating to a document") public void contributorIsAbleToAddStarsToDocument() throws Exception { - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingNode(document).rateStarsToDocument(5); + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingResource(document).rateStarsToDocument(5); restClient.assertStatusCodeIs(HttpStatus.CREATED); returnedRatingModel.assertThat().field("myRating").is("5") .and().field("id").is("fiveStar") @@ -158,7 +158,7 @@ public class AddRatingSanityTests extends RestTest TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role is able to post stars rating to a document") public void consumerIsAbleToAddStarsToDocument() throws Exception { - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).usingNode(document).rateStarsToDocument(5); + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).usingResource(document).rateStarsToDocument(5); restClient.assertStatusCodeIs(HttpStatus.CREATED); returnedRatingModel.assertThat().field("myRating").is("5") .and().field("id").is("fiveStar") @@ -169,7 +169,7 @@ public class AddRatingSanityTests extends RestTest TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify admin user is able to post stars rating to a document") public void adminIsAbleToAddStarsToDocument() throws Exception { - returnedRatingModel = restClient.authenticateUser(adminUser).usingNode(document).rateStarsToDocument(3); + returnedRatingModel = restClient.authenticateUser(adminUser).usingResource(document).rateStarsToDocument(3); restClient.assertStatusCodeIs(HttpStatus.CREATED); returnedRatingModel.assertThat().field("myRating").is(String.valueOf(3)) .and().field("id").is("fiveStar") @@ -181,7 +181,7 @@ public class AddRatingSanityTests extends RestTest @Bug(id = "MNT-16904") public void unauthenticatedUserIsNotAbleToRateStarsToDocument() throws Exception { - restClient.authenticateUser(new UserModel("random user", "random password")).usingNode(document).rateStarsToDocument(5); + restClient.authenticateUser(new UserModel("random user", "random password")).usingResource(document).rateStarsToDocument(5); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } \ No newline at end of file From 24b59dabb15b887cc039d9069a83e059a019c987 Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 16 Nov 2016 11:00:21 +0200 Subject: [PATCH 0528/1491] update tests based on new refactored DSL --- .../processes/GetProcessesSanityTests.java | 55 +++++++------------ 1 file changed, 19 insertions(+), 36 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java index 31dbe544f..b7ce50dad 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java @@ -2,17 +2,10 @@ package org.alfresco.rest.workflow.processes; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestWorkflowTest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.requests.Processes; -import org.alfresco.utility.data.DataUser; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TaskModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; +import org.alfresco.rest.model.RestProcessModelsCollection; +import org.alfresco.utility.model.*; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -23,16 +16,11 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public class GetProcessesSanityTests extends RestWorkflowTest { - @Autowired - private DataUser dataUser; - - @Autowired - private Processes processesApi; - private FileModel document; private SiteModel siteModel; private UserModel userWhoStartsTask, assignee, anotherUser; private TaskModel task; + private RestProcessModelsCollection allProcesses; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception @@ -43,46 +31,41 @@ public class GetProcessesSanityTests extends RestWorkflowTest siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); task = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); - processesApi.useRestClient(restClient); } @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify User gets all processes started by him using REST API and status code is OK (200)") - public void getProcessesByUserWhoStartedProcess() throws JsonToModelConversionException, Exception + public void getProcessesByUserWhoStartedProcess() throws Exception { - restClient.authenticateUser(userWhoStartsTask); - - processesApi.getProcesses().assertThat().entriesListContains("id", task.getNodeRef()); - processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + allProcesses = restClient.authenticateUser(userWhoStartsTask).getProcesses(); + restClient.assertStatusCodeIs(HttpStatus.OK); + allProcesses.assertThat().entriesListContains("id", task.getNodeRef()); } @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify User gets all processes assigned to him using REST API and status code is OK (200)") - public void getProcessesByAssignedUser() throws JsonToModelConversionException, Exception + public void getProcessesByAssignedUser() throws Exception { - restClient.authenticateUser(assignee); - - processesApi.getProcesses().assertThat().entriesListContains("id", task.getNodeRef()); - processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + allProcesses = restClient.authenticateUser(assignee).getProcesses(); + restClient.assertStatusCodeIs(HttpStatus.OK); + allProcesses.assertThat().entriesListContains("id", task.getNodeRef()); } @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify User that is not involved in a process can not get that process using REST API and status code is OK (200)") - public void getProcessesByAnotherUser() throws JsonToModelConversionException, Exception + public void getProcessesByAnotherUser() throws Exception { - restClient.authenticateUser(anotherUser); - - processesApi.getProcesses().assertThat().entriesListDoesNotContain("id", task.getNodeRef()); - processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + allProcesses = restClient.authenticateUser(anotherUser).getProcesses(); + restClient.assertStatusCodeIs(HttpStatus.OK); + allProcesses.assertThat().entriesListDoesNotContain("id", task.getNodeRef()); } @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify Admin gets all processes, even if he isn't involved in a process, using REST API and status code is OK (200)") - public void getProcessesByAdmin() throws JsonToModelConversionException, Exception + public void getProcessesByAdmin() throws Exception { - restClient.authenticateUser(dataUser.getAdminUser()); - - processesApi.getProcesses().assertThat().entriesListContains("id", task.getNodeRef()); - processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + allProcesses = restClient.authenticateUser(dataUser.getAdminUser()).getProcesses(); + restClient.assertStatusCodeIs(HttpStatus.OK); + allProcesses.assertThat().entriesListContains("id", task.getNodeRef()); } } From eae6485c160e6872d509a3b00eb2f483f78ccd40 Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 16 Nov 2016 11:04:50 +0200 Subject: [PATCH 0529/1491] update tests based on new refactored DSL --- .../processes/GetProcessTasksSanityTests.java | 42 +++++++------------ 1 file changed, 16 insertions(+), 26 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksSanityTests.java index 747cd501a..dee987533 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksSanityTests.java @@ -3,35 +3,27 @@ package org.alfresco.rest.workflow.processes; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestWorkflowTest; import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.requests.Processes; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.ProcessModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; +import org.alfresco.rest.model.RestTaskModelsCollection; +import org.alfresco.utility.model.*; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; /** * Tests for GET "/processes/{processId}/tasks" REST API call - * + * * @author Cristina Axinte */ @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public class GetProcessTasksSanityTests extends RestWorkflowTest { - @Autowired - private Processes processesApi; - - private UserModel userModel; private FileModel document; private SiteModel siteModel; - private UserModel assignee1, assignee2, assignee3; + private UserModel userModel, assignee1, assignee2, assignee3; private ProcessModel process; + private RestTaskModelsCollection processTasks; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception @@ -44,44 +36,42 @@ public class GetProcessTasksSanityTests extends RestWorkflowTest document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); process = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(document) .createMoreReviewersWorkflowAndAssignTo(assignee1, assignee2, assignee3); - processesApi.useRestClient(restClient); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify user who started the process gets all tasks of started process with Rest API and response is successfull (200)") public void userWhoStartedProcessCanGetProcessTasks() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(userModel); - processesApi.getProcessTasks(process).assertThat() + processTasks = restClient.authenticateUser(userModel).usingProcess(process).getProcessTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + processTasks.assertThat() .entriesListIsNotEmpty().and() .entriesListContains("assignee", assignee1.getUsername()).and() .entriesListContains("assignee", assignee2.getUsername()).and() .entriesListContains("assignee", assignee2.getUsername()); - processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify any assignee user of the process gets all tasks of the process with Rest API and response is successfull (200)") public void assigneeUserCanGetAllProcessTasks() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(assignee1); - processesApi.getProcessTasks(process).assertThat() - .entriesListIsNotEmpty().and() + processTasks = restClient.authenticateUser(assignee1).usingProcess(process).getProcessTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + processTasks.assertThat() .entriesListContains("assignee", assignee1.getUsername()).and() .entriesListContains("assignee", assignee2.getUsername()).and() .entriesListContains("assignee", assignee2.getUsername()); - processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify any assignee user of the process gets all tasks of the process with Rest API and response is successfull (200)") public void involvedUserCanGetAllProcessTasks() throws JsonToModelConversionException, Exception { ProcessModel process = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(document) .createMoreReviewersWorkflowAndAssignTo(assignee1, assignee2, assignee3); dataWorkflow.usingUser(assignee1).approveTask(process); - - restClient.authenticateUser(assignee2); - processesApi.getProcessTasks(process).assertThat() + + processTasks = restClient.authenticateUser(assignee2).usingProcess(process).getProcessTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + processTasks.assertThat() .entriesListIsNotEmpty().assertThat() .entriesListContains("assignee", userModel.getUsername()); - processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } } From bcb6336e7c4b5b8071ffeb418bb680ac047c2bcd Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 16 Nov 2016 11:11:05 +0200 Subject: [PATCH 0530/1491] update tests based on new refactored DSL --- ...va => GetProcessVariablesSanityTests.java} | 36 ++++++++----------- 1 file changed, 14 insertions(+), 22 deletions(-) rename e2e-test/java/org/alfresco/rest/workflow/processes/{GetProcessesVariablesSanityTests.java => GetProcessVariablesSanityTests.java} (66%) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesVariablesSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesSanityTests.java similarity index 66% rename from e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesVariablesSanityTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesSanityTests.java index 3981f756e..4f2c8b35c 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesVariablesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesSanityTests.java @@ -4,15 +4,13 @@ import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestWorkflowTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.requests.Processes; -import org.alfresco.utility.data.DataUser; +import org.alfresco.rest.model.RestProcessVariableCollection; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -21,18 +19,13 @@ import org.testng.annotations.Test; * @author iulia.cojocea */ @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) -public class GetProcessesVariablesSanityTests extends RestWorkflowTest +public class GetProcessVariablesSanityTests extends RestWorkflowTest { - @Autowired - private DataUser dataUser; - - @Autowired - private Processes processesApi; - private FileModel document; private SiteModel siteModel; private UserModel userWhoStartsTask, assignee; private RestProcessModel processModel; + private RestProcessVariableCollection variables; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception @@ -42,26 +35,25 @@ public class GetProcessesVariablesSanityTests extends RestWorkflowTest siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); - processesApi.useRestClient(restClient); } - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify that user that started the process gets all process variables") public void getProcessVariablesUsingTheUserWhoStartedProcess() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(userWhoStartsTask); - processModel = processesApi.getProcesses().getOneRandomEntry(); - processesApi.getProcessesVariables(processModel).assertThat().entriesListIsNotEmpty(); - processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + processModel = restClient.authenticateUser(userWhoStartsTask).getProcesses().getOneRandomEntry().onModel(); + variables = restClient.usingProcess(processModel).getProcessVariables(); + restClient.assertStatusCodeIs(HttpStatus.OK); + variables.assertThat().entriesListIsNotEmpty(); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify get all process variables call using a user that is involved in the process") public void getProcessVariablesUsingUserInvolvedInProcess() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(assignee); - processModel = processesApi.getProcesses().getOneRandomEntry(); - processesApi.getProcessesVariables(processModel).assertThat().entriesListIsNotEmpty(); - processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + processModel = restClient.authenticateUser(assignee).getProcesses().getOneRandomEntry().onModel(); + variables = restClient.usingProcess(processModel).getProcessVariables(); + restClient.assertStatusCodeIs(HttpStatus.OK); + variables.assertThat().entriesListIsNotEmpty(); } } From 91e262227792f386cb1189ab982f74952a7f1878 Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 16 Nov 2016 11:26:09 +0200 Subject: [PATCH 0531/1491] update tests based on new refactored DSL --- .../processes/AddProcessSanityTests.java | 54 +++++++------------ 1 file changed, 18 insertions(+), 36 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessSanityTests.java index 27192100f..4d344c150 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessSanityTests.java @@ -4,16 +4,13 @@ import org.alfresco.dataprep.CMISUtil.Priority; import org.alfresco.rest.RestWorkflowTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.requests.Processes; -import org.alfresco.rest.requests.RestTenantApi; -import org.alfresco.utility.data.DataUser; +import org.alfresco.rest.model.RestProcessModelsCollection; 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.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; /** @@ -22,27 +19,10 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public class AddProcessSanityTests extends RestWorkflowTest { - @Autowired - private DataUser dataUser; - - @Autowired - private Processes processesApi; - - @Autowired - private RestTenantApi tenantApi; - private UserModel userWhoStartsProcess, assignee; private UserModel adminTenantUser, tenantUserWhoStartsProcess, tenantAssignee; private RestProcessModel addedProcess; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - processesApi.useRestClient(restClient); - tenantApi.useRestClient(restClient); - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(dataUser.getAdminUser()); - } + private RestProcessModelsCollection processes; @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify non network user is able to start new process using REST API and status code is OK (200)") @@ -51,14 +31,14 @@ public class AddProcessSanityTests extends RestWorkflowTest userWhoStartsProcess = dataUser.createRandomTestUser(); assignee = dataUser.createRandomTestUser(); - restClient.authenticateUser(userWhoStartsProcess); - addedProcess = processesApi.addProcess("activitiAdhoc", assignee, false, Priority.Normal); + addedProcess = restClient.authenticateUser(userWhoStartsProcess).addProcess("activitiAdhoc", assignee, false, Priority.Normal); + restClient.assertStatusCodeIs(HttpStatus.CREATED); addedProcess.assertThat().field("id").is(addedProcess.getId()) - .and().field("startUserId").is(addedProcess.getStartUserId()); - - processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); - processesApi.getProcesses().assertThat().entriesListContains("id", addedProcess.getId()); - processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + .and().field("startUserId").is(addedProcess.getStartUserId()); + + processes = restClient.getProcesses(); + restClient.assertStatusCodeIs(HttpStatus.OK); + processes.assertThat().entriesListContains("id", addedProcess.getId()); } @TestRail(section = { TestGroup.REST_API, @@ -66,17 +46,19 @@ public class AddProcessSanityTests extends RestWorkflowTest @Test(groups = { TestGroup.NETWORKS }) public void networkUserStartsNewProcess() throws JsonToModelConversionException, Exception { - tenantApi.createTenant(adminTenantUser); - restClient.authenticateUser(adminTenantUser); + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(dataUser.getAdminUser()) + .usingTenant().createTenant(adminTenantUser); tenantUserWhoStartsProcess = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); tenantAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("u2Tenant"); - restClient.authenticateUser(tenantUserWhoStartsProcess); - addedProcess = processesApi.addProcess("activitiAdhoc", tenantAssignee, false, Priority.Normal); + addedProcess = restClient.authenticateUser(tenantUserWhoStartsProcess).addProcess("activitiAdhoc", tenantAssignee, false, Priority.Normal); + restClient.assertStatusCodeIs(HttpStatus.CREATED); addedProcess.assertThat().field("id").is(addedProcess.getId()) .and().field("startUserId").is(addedProcess.getStartUserId()); - processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); - processesApi.getProcesses().assertThat().entriesListContains("id", addedProcess.getId()); - processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + + processes = restClient.getProcesses(); + restClient.assertStatusCodeIs(HttpStatus.OK); + processes.assertThat().entriesListContains("id", addedProcess.getId()); } } From ffb24627ce737e73a24c8f1eebc322346a1fca4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alecsandru=20Prun=C4=83?= Date: Wed, 16 Nov 2016 11:42:11 +0200 Subject: [PATCH 0532/1491] TAS-1906 Refactor Test: RestGetNetworkTest --- .../rest/networks/RestGetNetworkTest.java | 64 ++++++++----------- 1 file changed, 26 insertions(+), 38 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkTest.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkTest.java index c750f68d1..13e299ac6 100644 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkTest.java +++ b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkTest.java @@ -1,8 +1,6 @@ package org.alfresco.rest.networks; import org.alfresco.rest.RestTest; -import org.alfresco.rest.requests.RestNetworksApi; -import org.alfresco.rest.requests.RestTenantApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; @@ -10,7 +8,6 @@ import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -21,12 +18,6 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS }) public class RestGetNetworkTest extends RestTest { - @Autowired - RestNetworksApi networkApi; - - @Autowired - RestTenantApi tenantApi; - UserModel adminTenantUser; UserModel adminAnotherTenantUser; SiteModel site; @@ -38,15 +29,12 @@ public class RestGetNetworkTest extends RestTest UserModel adminuser = dataUser.getAdminUser(); adminTenantUser = UserModel.getAdminTenantUser(); restClient.authenticateUser(adminuser); - tenantApi.useRestClient(restClient); - tenantApi.createTenant(adminTenantUser); + restClient.usingTenant().createTenant(adminTenantUser); adminAnotherTenantUser = UserModel.getAdminTenantUser(); - tenantApi.createTenant(adminAnotherTenantUser); + restClient.usingTenant().createTenant(adminAnotherTenantUser); tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); site = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); - - networkApi.useRestClient(restClient); } @Bug(id = "MNT-16904") @@ -58,8 +46,8 @@ public class RestGetNetworkTest extends RestTest UserModel tenantUser = new UserModel("nonexisting", "password"); tenantUser.setDomain(adminTenantUser.getDomain()); restClient.authenticateUser(tenantUser); - networkApi.getNetwork(adminTenantUser); - networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.usingNetworks().getNetwork(adminTenantUser); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } @Test(groups = TestGroup.COMMENTS) @@ -68,8 +56,8 @@ public class RestGetNetworkTest extends RestTest public void adminTenantChecksIfNetworkIsPresent() throws Exception { restClient.authenticateUser(adminTenantUser); - networkApi.getNetwork(adminTenantUser); - networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.usingNetworks().getNetwork(); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, @@ -77,7 +65,7 @@ public class RestGetNetworkTest extends RestTest public void adminTenantChecksNetworkParamsAreCorrect() throws Exception { restClient.authenticateUser(adminTenantUser); - networkApi.getNetwork(adminTenantUser).assertNetworkHasName(adminTenantUser).assertNetworkIsEnabled(); + restClient.usingNetworks().getNetwork().assertNetworkHasName(adminTenantUser).assertNetworkIsEnabled(); } @TestRail(section = { TestGroup.REST_API, @@ -85,8 +73,8 @@ public class RestGetNetworkTest extends RestTest public void adminTenantChecksIfNonExistingNetworkIsNotFound() throws Exception { restClient.authenticateUser(adminTenantUser); - networkApi.getNetwork(UserModel.getRandomTenantUser()); - networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); + restClient.usingNetworks().getNetwork(UserModel.getRandomTenantUser()); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); } @TestRail(section = { TestGroup.REST_API, @@ -94,16 +82,16 @@ public class RestGetNetworkTest extends RestTest public void adminTenantChecksIfAnotherExistingNetworkIsForbidden() throws Exception { restClient.authenticateUser(adminTenantUser); - networkApi.getNetwork(adminAnotherTenantUser); - networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + restClient.usingNetworks().getNetwork(adminAnotherTenantUser); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); } @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, description = "Verify any tenant user gets its network with Rest API and response is not empty") public void userTenantChecksIfNetworkIsPresent() throws Exception { restClient.authenticateUser(tenantUser); - networkApi.getNetwork(adminTenantUser); - networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.usingNetworks().getNetwork(adminTenantUser); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, @@ -111,7 +99,7 @@ public class RestGetNetworkTest extends RestTest public void userTenantChecksNetworkParamsAreCorrect() throws Exception { restClient.authenticateUser(tenantUser); - networkApi.getNetwork(adminTenantUser).assertNetworkHasName(adminTenantUser).assertNetworkIsEnabled(); + restClient.usingNetworks().getNetwork(adminTenantUser).assertNetworkHasName(adminTenantUser).assertNetworkIsEnabled(); } @TestRail(section = { TestGroup.REST_API, @@ -119,8 +107,8 @@ public class RestGetNetworkTest extends RestTest public void userTenantChecksIfNonExistingNetworkIsNotFound() throws Exception { restClient.authenticateUser(tenantUser); - networkApi.getNetwork(UserModel.getRandomTenantUser()); - networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); + restClient.usingNetworks().getNetwork(UserModel.getRandomTenantUser()); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); } @Test(groups = TestGroup.COMMENTS) @@ -129,8 +117,8 @@ public class RestGetNetworkTest extends RestTest public void userTenantChecksIfAnotherExistingNetworkIsForbidden() throws Exception { restClient.authenticateUser(tenantUser); - networkApi.getNetwork(adminAnotherTenantUser); - networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + restClient.usingNetworks().getNetwork(adminAnotherTenantUser); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); } @Test(groups = TestGroup.COMMENTS) @@ -142,8 +130,8 @@ public class RestGetNetworkTest extends RestTest dataUser.usingUser(adminTenantUser).addUserToSite(managerTenantUser, site, UserRole.SiteManager); restClient.authenticateUser(managerTenantUser); - networkApi.getNetwork(adminTenantUser); - networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.usingNetworks().getNetwork(adminTenantUser); + restClient.assertStatusCodeIs(HttpStatus.OK); } @Test(groups = TestGroup.COMMENTS) @@ -155,8 +143,8 @@ public class RestGetNetworkTest extends RestTest dataUser.usingUser(adminTenantUser).addUserToSite(collaboratorTenantUser, site, UserRole.SiteCollaborator); restClient.authenticateUser(collaboratorTenantUser); - networkApi.getNetwork(adminTenantUser); - networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.usingNetworks().getNetwork(adminTenantUser); + restClient.assertStatusCodeIs(HttpStatus.OK); } @Test(groups = TestGroup.COMMENTS) @@ -168,8 +156,8 @@ public class RestGetNetworkTest extends RestTest dataUser.usingUser(adminTenantUser).addUserToSite(consumerTenantUser, site, UserRole.SiteConsumer); restClient.authenticateUser(consumerTenantUser); - networkApi.getNetwork(adminTenantUser); - networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.usingNetworks().getNetwork(adminTenantUser); + restClient.assertStatusCodeIs(HttpStatus.OK); } @Test(groups = TestGroup.COMMENTS) @@ -181,7 +169,7 @@ public class RestGetNetworkTest extends RestTest dataUser.usingUser(adminTenantUser).addUserToSite(contributorTenantUser, site, UserRole.SiteContributor); restClient.authenticateUser(contributorTenantUser); - networkApi.getNetwork(adminTenantUser); - networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.usingNetworks().getNetwork(adminTenantUser); + restClient.assertStatusCodeIs(HttpStatus.OK); } } From 8523de5a82b592157d53b8e8a8bade5c23087ccf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alecsandru=20Prun=C4=83?= Date: Wed, 16 Nov 2016 11:44:40 +0200 Subject: [PATCH 0533/1491] TAS-1905 Refactor Test: RestGetNetworksForPersonSanityTests --- .../RestGetNetworksForPersonSanityTests.java | 32 ++++++------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonSanityTests.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonSanityTests.java index e163bd370..0c3fad337 100644 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonSanityTests.java @@ -1,14 +1,11 @@ package org.alfresco.rest.networks; import org.alfresco.rest.RestTest; -import org.alfresco.rest.requests.RestNetworksApi; -import org.alfresco.rest.requests.RestTenantApi; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -16,12 +13,6 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) public class RestGetNetworksForPersonSanityTests extends RestTest { - @Autowired - RestTenantApi tenantApi; - - @Autowired - RestNetworksApi networkApi; - private UserModel adminUserModel; UserModel adminTenantUser; UserModel tenantUser; @@ -32,11 +23,8 @@ public class RestGetNetworksForPersonSanityTests extends RestTest adminUserModel = dataUser.getAdminUser(); adminTenantUser = UserModel.getAdminTenantUser(); restClient.authenticateUser(adminUserModel); - tenantApi.useRestClient(restClient); - tenantApi.createTenant(adminTenantUser); - + restClient.usingTenant().createTenant(adminTenantUser); tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - networkApi.useRestClient(restClient); } @Bug(id = "MNT-16904") @@ -48,8 +36,8 @@ public class RestGetNetworksForPersonSanityTests extends RestTest UserModel tenantUser = new UserModel("nonexisting", "password"); tenantUser.setDomain(adminTenantUser.getDomain()); restClient.authenticateUser(tenantUser); - networkApi.getNetworksForUser(adminTenantUser); - networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.usingUser(tenantUser).getNetworks(adminTenantUser); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } @Test(groups = TestGroup.COMMENTS) @@ -58,8 +46,8 @@ public class RestGetNetworksForPersonSanityTests extends RestTest public void adminTenantChecksIfNetworkIsPresent() throws Exception { restClient.authenticateUser(adminTenantUser); - networkApi.getNetworksForUser(adminTenantUser); - networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.usingUser(adminTenantUser).getNetworks(); + restClient.assertStatusCodeIs(HttpStatus.OK); } @Test(groups = TestGroup.COMMENTS) @@ -68,8 +56,8 @@ public class RestGetNetworksForPersonSanityTests extends RestTest public void tenantUserIsNotAuthorizedToCheckNetworkOfAdminUser() throws Exception { restClient.authenticateUser(tenantUser); - networkApi.getNetworksForUser(adminTenantUser); - networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); + restClient.usingUser(tenantUser).getNetworks(adminTenantUser); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); } @Test(groups = TestGroup.COMMENTS) @@ -78,10 +66,10 @@ public class RestGetNetworksForPersonSanityTests extends RestTest public void adminTenantUserIsNotAuthorizedToCheckNetworkOfAnotherUser() throws Exception { UserModel secondAdminTenantUser = UserModel.getAdminTenantUser(); - tenantApi.createTenant(secondAdminTenantUser); + restClient.usingTenant().createTenant(secondAdminTenantUser); UserModel secondTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("anotherTenant"); restClient.authenticateUser(secondAdminTenantUser); - networkApi.getNetworksForUser(secondTenantUser); - networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); + restClient.usingUser(secondAdminTenantUser).getNetworks(secondTenantUser); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); } } From 85a43436461921d2e962236e4577276115f46ecc Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Wed, 16 Nov 2016 11:46:19 +0200 Subject: [PATCH 0534/1491] Refactor test: DeleteRatingSanityTests --- .../rest/ratings/DeleteRatingSanityTests.java | 168 ++++++------------ 1 file changed, 59 insertions(+), 109 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java index 92ab73435..d2b1f0302 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java @@ -2,7 +2,7 @@ package org.alfresco.rest.ratings; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; -import org.alfresco.rest.requests.RestRatingsApi; +import org.alfresco.rest.model.RestRatingModelsCollection; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.exception.DataPreparationException; @@ -14,7 +14,6 @@ import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; @@ -23,14 +22,13 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) public class DeleteRatingSanityTests extends RestTest { - @Autowired - RestRatingsApi ratingsApi; private SiteModel siteModel; private UserModel adminUser; private FolderModel folderModel; private FileModel document; private ListUserWithRoles usersWithRoles; + private RestRatingModelsCollection returnedRatingModelCollection; @BeforeClass(alwaysRun=true) public void dataPreparation() throws DataPreparationException @@ -38,8 +36,6 @@ public class DeleteRatingSanityTests extends RestTest adminUser = dataUser.getAdminUser(); siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); - ratingsApi.useRestClient(restClient); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); } @@ -55,26 +51,18 @@ public class DeleteRatingSanityTests extends RestTest public void managerIsAbleToDeleteItsOwnRatings() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - - ratingsApi.likeDocument(document) - .assertThat().field("myRating").is("true") - .and().field("id").is("likes") - .and().field("aggregate").isNotEmpty(); - ratingsApi.rateStarsToDocument(document, 5) - .assertThat().field("myRating").is("5") - .and().field("id").is("fiveStar") - .and().field("aggregate").isNotEmpty(); + restClient.usingNode(document).likeDocument(); + restClient.usingNode(document).rateStarsToDocument(5); - ratingsApi.deleteLikeRating(document); - ratingsApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.usingNode(document).deleteLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - ratingsApi.deleteFiveStarRating(document); - ratingsApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.usingNode(document).deleteFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - ratingsApi.getRatings(document) - .assertNodeIsNotLiked() + returnedRatingModelCollection = restClient.usingNode(document).getRatings(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedRatingModelCollection.assertNodeIsNotLiked() .assertNodeHasNoFiveStarRating() .and().entriesListIsNotEmpty() .and().paginationExist(); @@ -86,25 +74,18 @@ public class DeleteRatingSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - ratingsApi.likeDocument(document) - .assertThat().field("myRating").is("true") - .and().field("id").is("likes") - .and().field("aggregate").isNotEmpty(); - ratingsApi.rateStarsToDocument(document, 5) - .assertThat().field("myRating").is("5") - .and().field("id").is("fiveStar") - .and().field("aggregate").isNotEmpty(); + restClient.usingNode(document).likeDocument(); + restClient.usingNode(document).rateStarsToDocument(5); - ratingsApi.deleteLikeRating(document); - ratingsApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.usingNode(document).deleteLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - ratingsApi.deleteFiveStarRating(document); - ratingsApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.usingNode(document).deleteFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - ratingsApi.getRatings(document) - .assertNodeIsNotLiked() + returnedRatingModelCollection = restClient.usingNode(document).getRatings(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedRatingModelCollection.assertNodeIsNotLiked() .assertNodeHasNoFiveStarRating() .and().entriesListIsNotEmpty() .and().paginationExist(); @@ -116,25 +97,18 @@ public class DeleteRatingSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - ratingsApi.likeDocument(document) - .assertThat().field("myRating").is("true") - .and().field("id").is("likes") - .and().field("aggregate").isNotEmpty(); - ratingsApi.rateStarsToDocument(document, 5) - .assertThat().field("myRating").is("5") - .and().field("id").is("fiveStar") - .and().field("aggregate").isNotEmpty(); + restClient.usingNode(document).likeDocument(); + restClient.usingNode(document).rateStarsToDocument(5); - ratingsApi.deleteLikeRating(document); - ratingsApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.usingNode(document).deleteLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - ratingsApi.deleteFiveStarRating(document); - ratingsApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.usingNode(document).deleteFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - ratingsApi.getRatings(document) - .assertNodeIsNotLiked() + returnedRatingModelCollection = restClient.usingNode(document).getRatings(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedRatingModelCollection.assertNodeIsNotLiked() .assertNodeHasNoFiveStarRating() .and().entriesListIsNotEmpty() .and().paginationExist(); @@ -146,25 +120,18 @@ public class DeleteRatingSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - ratingsApi.likeDocument(document) - .assertThat().field("myRating").is("true") - .and().field("id").is("likes") - .and().field("aggregate").isNotEmpty(); - ratingsApi.rateStarsToDocument(document, 5) - .assertThat().field("myRating").is("5") - .and().field("id").is("fiveStar") - .and().field("aggregate").isNotEmpty(); + restClient.usingNode(document).likeDocument(); + restClient.usingNode(document).rateStarsToDocument(5); - ratingsApi.deleteLikeRating(document); - ratingsApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.usingNode(document).deleteLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - ratingsApi.deleteFiveStarRating(document); - ratingsApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.usingNode(document).deleteFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - ratingsApi.getRatings(document) - .assertNodeIsNotLiked() + returnedRatingModelCollection = restClient.usingNode(document).getRatings(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedRatingModelCollection.assertNodeIsNotLiked() .assertNodeHasNoFiveStarRating() .and().entriesListIsNotEmpty() .and().paginationExist(); @@ -178,25 +145,18 @@ public class DeleteRatingSanityTests extends RestTest restClient.authenticateUser(adminUser); - ratingsApi.likeDocument(document) - .assertThat().field("myRating").is("true") - .and().field("id").is("likes") - .and().field("aggregate").isNotEmpty(); - ratingsApi.rateStarsToDocument(document, 5) - .assertThat().field("myRating").is("5") - .and().field("id").is("fiveStar") - .and().field("aggregate").isNotEmpty(); + restClient.usingNode(document).likeDocument(); + restClient.usingNode(document).rateStarsToDocument(5); - ratingsApi.deleteLikeRating(document); - ratingsApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.usingNode(document).deleteLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - ratingsApi.deleteFiveStarRating(document); - ratingsApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.usingNode(document).deleteFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - ratingsApi.getRatings(document) - .assertNodeIsNotLiked() + returnedRatingModelCollection = restClient.usingNode(document).getRatings(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedRatingModelCollection.assertNodeIsNotLiked() .assertNodeHasNoFiveStarRating() .and().entriesListIsNotEmpty() .and().paginationExist(); @@ -209,24 +169,16 @@ public class DeleteRatingSanityTests extends RestTest document = dataContent.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); restClient.authenticateUser(adminUser); - ratingsApi.likeDocument(document) - .assertThat().field("myRating").is("true") - .and().field("id").is("likes") - .and().field("aggregate").isNotEmpty(); - ratingsApi.rateStarsToDocument(document, 5) - .assertThat().field("myRating").is("5") - .and().field("id").is("fiveStar") - .and().field("aggregate").isNotEmpty(); + restClient.usingNode(document).likeDocument(); + restClient.usingNode(document).rateStarsToDocument(5); restClient.authenticateUser(new UserModel("random user", "random password")); - ratingsApi.deleteLikeRating(document); - ratingsApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.usingNode(document).deleteLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); - ratingsApi.deleteFiveStarRating(document); - ratingsApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.usingNode(document).deleteFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, @@ -239,17 +191,15 @@ public class DeleteRatingSanityTests extends RestTest restClient.authenticateUser(userA); - ratingsApi.likeDocument(document); - ratingsApi.rateStarsToDocument(document, 5); + restClient.usingNode(document).likeDocument(); + restClient.usingNode(document).rateStarsToDocument(5); restClient.authenticateUser(userB); - ratingsApi.deleteLikeRating(document); - ratingsApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.authenticateUser(userB).usingNode(document).deleteLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); - ratingsApi.deleteFiveStarRating(document); - ratingsApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.usingNode(document).deleteFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } \ No newline at end of file From abd1ef3d6d2c39ee81003aefc6ee67e15508ad2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alecsandru=20Prun=C4=83?= Date: Wed, 16 Nov 2016 11:50:04 +0200 Subject: [PATCH 0535/1491] TAS-1904 Refactor Test: RestGetNetworkForPersonSanityTests --- .../RestGetNetworkForPersonSanityTests.java | 34 ++++++------------- 1 file changed, 10 insertions(+), 24 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java index 417a4f290..c160a6c2d 100644 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java @@ -1,14 +1,11 @@ package org.alfresco.rest.networks; import org.alfresco.rest.RestTest; -import org.alfresco.rest.requests.RestNetworksApi; -import org.alfresco.rest.requests.RestTenantApi; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -16,13 +13,6 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) public class RestGetNetworkForPersonSanityTests extends RestTest { - - @Autowired - RestTenantApi tenantApi; - - @Autowired - RestNetworksApi networkApi; - private UserModel adminUserModel; UserModel adminTenantUser; UserModel tenantUser; @@ -33,11 +23,8 @@ public class RestGetNetworkForPersonSanityTests extends RestTest adminUserModel = dataUser.getAdminUser(); adminTenantUser = UserModel.getAdminTenantUser(); restClient.authenticateUser(adminUserModel); - tenantApi.useRestClient(restClient); - tenantApi.createTenant(adminTenantUser); - + restClient.usingTenant().createTenant(adminTenantUser); tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - networkApi.useRestClient(restClient); } @Bug(id = "MNT-16904") @@ -49,8 +36,8 @@ public class RestGetNetworkForPersonSanityTests extends RestTest UserModel tenantUser = new UserModel("nonexisting", "password"); tenantUser.setDomain(adminTenantUser.getDomain()); restClient.authenticateUser(tenantUser); - networkApi.getNetworkForUser(adminTenantUser); - networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.usingUser(tenantUser).getNetwork(adminTenantUser); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } @Test(groups = TestGroup.COMMENTS) @@ -59,8 +46,8 @@ public class RestGetNetworkForPersonSanityTests extends RestTest public void adminTenantChecksIfNetworkIsPresent() throws Exception { restClient.authenticateUser(adminTenantUser); - networkApi.getNetworkForUser(adminTenantUser); - networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.usingUser(adminTenantUser).getNetwork(); + restClient.assertStatusCodeIs(HttpStatus.OK); } @Test(groups = TestGroup.COMMENTS) @@ -69,8 +56,8 @@ public class RestGetNetworkForPersonSanityTests extends RestTest public void tenantUserIsNotAuthorizedToCheckNetworkOfAdminUser() throws Exception { restClient.authenticateUser(tenantUser); - networkApi.getNetworkForUser(adminTenantUser); - networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); + restClient.usingUser(tenantUser).getNetwork(adminTenantUser); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); } @Test(groups = TestGroup.COMMENTS) @@ -79,11 +66,10 @@ public class RestGetNetworkForPersonSanityTests extends RestTest public void adminTenantUserIsNotAuthorizedToCheckNetworkOfAnotherUser() throws Exception { UserModel secondAdminTenantUser = UserModel.getAdminTenantUser(); - tenantApi.createTenant(secondAdminTenantUser); + restClient.usingTenant().createTenant(secondAdminTenantUser); UserModel secondTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("anotherTenant"); restClient.authenticateUser(adminTenantUser); - networkApi.getNetworkForUser(secondTenantUser); - networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); + restClient.usingUser(adminTenantUser).getNetwork(secondTenantUser); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); } - } From 2dc34cd8ed58b0231fca8729d87d4b760c9ca65b Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 16 Nov 2016 11:54:15 +0200 Subject: [PATCH 0536/1491] update tests based on new refactored DSL --- .../AddProcessVariableSanityTests.java | 127 +++++++----------- 1 file changed, 52 insertions(+), 75 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java index 9761f44db..56b9dc944 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java @@ -1,13 +1,10 @@ package org.alfresco.rest.workflow.processes; +import org.alfresco.dataprep.CMISUtil.Priority; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestWorkflowTest; -import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.rest.model.RestProcessVariableModel; -import org.alfresco.rest.requests.Processes; -import org.alfresco.rest.requests.RestTenantApi; -import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.RandomData; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; @@ -15,7 +12,6 @@ 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.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -26,21 +22,11 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public class AddProcessVariableSanityTests extends RestWorkflowTest { - @Autowired - private DataUser dataUser; - - @Autowired - private Processes processesApi; - - @Autowired - RestTenantApi tenantApi; - private FileModel document; private SiteModel siteModel; - private UserModel userWhoStartsTask, assignee, adminTenantUser, tenantUser, tenantUserAssignee; + private UserModel userWhoStartsTask, assignee, adminUser, adminTenantUser, tenantUser, tenantUserAssignee; private RestProcessModel processModel; - private UserModel adminUser; - private RestProcessVariableModel processVariable; + private RestProcessVariableModel variableModel, processVariable; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception @@ -51,81 +37,72 @@ public class AddProcessVariableSanityTests extends RestWorkflowTest siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); - processesApi.useRestClient(restClient); } - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Create non-existing variable") - public void addProcessVariable() throws JsonToModelConversionException, Exception + public void addProcessVariable() throws Exception { - restClient.authenticateUser(userWhoStartsTask); - RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = processesApi.getProcesses().getOneRandomEntry(); - - processVariable = processesApi.addProcessVariable(processModel, variableModel); - processVariable.assertThat().field("name").is(processVariable.getName()) - .and().field("type").is(processVariable.getType()) - .and().field("value").is(processVariable.getValue()); - - processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); - processesApi.getProcessesVariables(processModel).assertThat().entriesListContains("name", processVariable.getName()); + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(userWhoStartsTask).getProcesses().getOneRandomEntry().onModel(); + + processVariable = restClient.usingProcess(processModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + processVariable.assertThat().field("name").is(variableModel.getName()) + .and().field("type").is(variableModel.getType()) + .and().field("value").is(variableModel.getValue()); + + restClient.usingProcess(processModel).getProcessVariables() + .assertThat().entriesListContains("name", processVariable.getName()); } - - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Update existing variable") - public void updateExistingProcessVariable() throws JsonToModelConversionException, Exception + public void updateExistingProcessVariable() throws Exception { - restClient.authenticateUser(userWhoStartsTask); - RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = processesApi.getProcesses().getOneRandomEntry(); - processVariable = processesApi.addProcessVariable(processModel, variableModel); - processVariable.and().field("name").is(processVariable.getName()) - .and().field("type").is(processVariable.getType()) - .and().field("value").is(processVariable.getValue()); - + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(userWhoStartsTask).getProcesses().getOneRandomEntry().onModel(); + processVariable = restClient.usingProcess(processModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + processVariable.assertThat().field("name").is(variableModel.getName()) + .and().field("type").is(variableModel.getType()) + .and().field("value").is(variableModel.getValue()); + String newValue = RandomData.getRandomName("value"); - variableModel.setValue(newValue); - processVariable = processesApi.addProcessVariable(processModel, variableModel) - .and().field("value").is(newValue); - processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + variableModel.setValue(newValue); + processVariable = restClient.usingProcess(processModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + processVariable.assertThat().field("value").is(newValue); } - + @Test(groups = { TestGroup.NETWORKS }) - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Add process variable using admin user from same network") - public void addProcessVariableByAdmin() throws JsonToModelConversionException, Exception + public void addProcessVariableByAdmin() throws Exception { - UserModel adminuser = dataUser.getAdminUser(); - restClient.authenticateUser(adminuser); - adminTenantUser = UserModel.getAdminTenantUser(); - tenantApi.useRestClient(restClient); - tenantApi.createTenant(adminTenantUser); - + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser); tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); - - siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); - dataWorkflow.usingUser(tenantUser).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(tenantUserAssignee); - - RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = processesApi.getProcesses().getOneRandomEntry(); - processesApi.addProcessVariable(processModel, variableModel); - processVariable.assertThat().field("name").is(processVariable.getName()) - .and().field("type").is(processVariable.getType()) - .and().field("value").is(processVariable.getValue()); - - processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(tenantUser).addProcess("activitiAdhoc", tenantUserAssignee, false, Priority.Normal); + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(adminTenantUser).getProcesses().getOneRandomEntry().onModel(); + processVariable = restClient.usingProcess(processModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + processVariable.assertThat().field("name").is(variableModel.getName()) + .and().field("type").is(variableModel.getType()) + .and().field("value").is(variableModel.getValue()); } - - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Adding process variable is falling in case invalid variableBody is provided") - public void failedAddingProcessVariableIfInvalidBodyIsProvided() throws JsonToModelConversionException, Exception + public void failedAddingProcessVariableIfInvalidBodyIsProvided() throws Exception { - restClient.authenticateUser(adminUser); - RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("incorrect type"); - processModel = processesApi.getProcesses().getOneRandomEntry(); - processesApi.addProcessVariable(processModel, variableModel); - processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.BAD_REQUEST); + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("incorrect type"); + processModel = restClient.authenticateUser(adminUser).getProcesses().getOneRandomEntry().onModel(); + restClient.usingProcess(processModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary("Unsupported type of variable: 'incorrect type'."); } } From 8fdd661017b63bd3a1d6714838bf54d22673783a Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Wed, 16 Nov 2016 12:13:05 +0200 Subject: [PATCH 0537/1491] Fixed DeleteRatingsSanityTests --- .../rest/ratings/DeleteRatingSanityTests.java | 66 +++++++++---------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java index d2b1f0302..c670848b3 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java @@ -51,16 +51,16 @@ public class DeleteRatingSanityTests extends RestTest public void managerIsAbleToDeleteItsOwnRatings() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.usingNode(document).likeDocument(); - restClient.usingNode(document).rateStarsToDocument(5); + restClient.usingResource(document).likeDocument(); + restClient.usingResource(document).rateStarsToDocument(5); - restClient.usingNode(document).deleteLikeRating(); + restClient.usingResource(document).deleteLikeRating(); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.usingNode(document).deleteFiveStarRating(); + restClient.usingResource(document).deleteFiveStarRating(); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - returnedRatingModelCollection = restClient.usingNode(document).getRatings(); + returnedRatingModelCollection = restClient.usingResource(document).getRatings(); restClient.assertStatusCodeIs(HttpStatus.OK); returnedRatingModelCollection.assertNodeIsNotLiked() .assertNodeHasNoFiveStarRating() @@ -74,16 +74,16 @@ public class DeleteRatingSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.usingNode(document).likeDocument(); - restClient.usingNode(document).rateStarsToDocument(5); + restClient.usingResource(document).likeDocument(); + restClient.usingResource(document).rateStarsToDocument(5); - restClient.usingNode(document).deleteLikeRating(); + restClient.usingResource(document).deleteLikeRating(); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.usingNode(document).deleteFiveStarRating(); + restClient.usingResource(document).deleteFiveStarRating(); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - returnedRatingModelCollection = restClient.usingNode(document).getRatings(); + returnedRatingModelCollection = restClient.usingResource(document).getRatings(); restClient.assertStatusCodeIs(HttpStatus.OK); returnedRatingModelCollection.assertNodeIsNotLiked() .assertNodeHasNoFiveStarRating() @@ -97,16 +97,16 @@ public class DeleteRatingSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - restClient.usingNode(document).likeDocument(); - restClient.usingNode(document).rateStarsToDocument(5); + restClient.usingResource(document).likeDocument(); + restClient.usingResource(document).rateStarsToDocument(5); - restClient.usingNode(document).deleteLikeRating(); + restClient.usingResource(document).deleteLikeRating(); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.usingNode(document).deleteFiveStarRating(); + restClient.usingResource(document).deleteFiveStarRating(); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - returnedRatingModelCollection = restClient.usingNode(document).getRatings(); + returnedRatingModelCollection = restClient.usingResource(document).getRatings(); restClient.assertStatusCodeIs(HttpStatus.OK); returnedRatingModelCollection.assertNodeIsNotLiked() .assertNodeHasNoFiveStarRating() @@ -120,16 +120,16 @@ public class DeleteRatingSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.usingNode(document).likeDocument(); - restClient.usingNode(document).rateStarsToDocument(5); + restClient.usingResource(document).likeDocument(); + restClient.usingResource(document).rateStarsToDocument(5); - restClient.usingNode(document).deleteLikeRating(); + restClient.usingResource(document).deleteLikeRating(); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.usingNode(document).deleteFiveStarRating(); + restClient.usingResource(document).deleteFiveStarRating(); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - returnedRatingModelCollection = restClient.usingNode(document).getRatings(); + returnedRatingModelCollection = restClient.usingResource(document).getRatings(); restClient.assertStatusCodeIs(HttpStatus.OK); returnedRatingModelCollection.assertNodeIsNotLiked() .assertNodeHasNoFiveStarRating() @@ -145,16 +145,16 @@ public class DeleteRatingSanityTests extends RestTest restClient.authenticateUser(adminUser); - restClient.usingNode(document).likeDocument(); - restClient.usingNode(document).rateStarsToDocument(5); + restClient.usingResource(document).likeDocument(); + restClient.usingResource(document).rateStarsToDocument(5); - restClient.usingNode(document).deleteLikeRating(); + restClient.usingResource(document).deleteLikeRating(); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.usingNode(document).deleteFiveStarRating(); + restClient.usingResource(document).deleteFiveStarRating(); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - returnedRatingModelCollection = restClient.usingNode(document).getRatings(); + returnedRatingModelCollection = restClient.usingResource(document).getRatings(); restClient.assertStatusCodeIs(HttpStatus.OK); returnedRatingModelCollection.assertNodeIsNotLiked() .assertNodeHasNoFiveStarRating() @@ -169,15 +169,15 @@ public class DeleteRatingSanityTests extends RestTest document = dataContent.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); restClient.authenticateUser(adminUser); - restClient.usingNode(document).likeDocument(); - restClient.usingNode(document).rateStarsToDocument(5); + restClient.usingResource(document).likeDocument(); + restClient.usingResource(document).rateStarsToDocument(5); restClient.authenticateUser(new UserModel("random user", "random password")); - restClient.usingNode(document).deleteLikeRating(); + restClient.usingResource(document).deleteLikeRating(); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); - restClient.usingNode(document).deleteFiveStarRating(); + restClient.usingResource(document).deleteFiveStarRating(); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } @@ -191,15 +191,15 @@ public class DeleteRatingSanityTests extends RestTest restClient.authenticateUser(userA); - restClient.usingNode(document).likeDocument(); - restClient.usingNode(document).rateStarsToDocument(5); + restClient.usingResource(document).likeDocument(); + restClient.usingResource(document).rateStarsToDocument(5); restClient.authenticateUser(userB); - restClient.authenticateUser(userB).usingNode(document).deleteLikeRating(); + restClient.authenticateUser(userB).usingResource(document).deleteLikeRating(); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); - restClient.usingNode(document).deleteFiveStarRating(); + restClient.usingResource(document).deleteFiveStarRating(); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } \ No newline at end of file From f618e40df5bf6fa1e3950429e371b63a81a49009 Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 16 Nov 2016 12:18:49 +0200 Subject: [PATCH 0538/1491] update tests based on new refactored DSL --- .../processes/DeleteProcessSanityTests.java | 59 ++++++++----------- 1 file changed, 23 insertions(+), 36 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java index bb90d0ec9..437f5c0bd 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java @@ -1,17 +1,12 @@ package org.alfresco.rest.workflow.processes; -import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.dataprep.CMISUtil.Priority; import org.alfresco.rest.RestWorkflowTest; -import org.alfresco.rest.requests.Processes; -import org.alfresco.utility.data.DataUser; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TaskModel; +import org.alfresco.rest.model.RestProcessModel; 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.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -22,58 +17,50 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public class DeleteProcessSanityTests extends RestWorkflowTest { - @Autowired - private DataUser dataUser; - - @Autowired - private Processes processesApi; - - private FileModel document; - private SiteModel siteModel; - private UserModel userWhoStartsTask, assignee, anotherUser; - private TaskModel task; + private UserModel userWhoAddsProcess, assignee, anotherUser; + private RestProcessModel process; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception { - userWhoStartsTask = dataUser.createRandomTestUser(); + userWhoAddsProcess = dataUser.createRandomTestUser(); assignee = dataUser.createRandomTestUser(); anotherUser = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - processesApi.useRestClient(restClient); - } + } @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify User is able to delete process started by him using REST API and status code is OK (204)") public void deleteProcessByUserWhoStartedProcess() throws Exception { - task = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); - restClient.authenticateUser(userWhoStartsTask); - processesApi.deleteProcess(task); - processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); + process = restClient.authenticateUser(userWhoAddsProcess).addProcess("activitiAdhoc", assignee, false, Priority.Normal); + restClient.assertStatusCodeIs(HttpStatus.CREATED); - processesApi.getProcesses().assertThat().entriesListDoesNotContain("id", task.getNodeRef()); + restClient.usingProcess(process).deleteProcess(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.getProcesses().assertThat().entriesListDoesNotContain("id", process.getId()); } @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify User is able to delete process assigned to him using REST API and status code is OK (204)") public void deleteProcessByAssignedUser() throws Exception { - task = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); - restClient.authenticateUser(assignee); - processesApi.deleteProcess(task); - processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); + process = restClient.authenticateUser(userWhoAddsProcess).addProcess("activitiAdhoc", assignee, false, Priority.Normal); + restClient.assertStatusCodeIs(HttpStatus.CREATED); - processesApi.getProcesses().assertThat().entriesListDoesNotContain("id", task.getNodeRef()); + restClient.authenticateUser(assignee).usingProcess(process).deleteProcess(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.getProcesses().assertThat().entriesListDoesNotContain("id", process.getId()); } @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify User that is not involved in a process is not authorized to delete it using REST API and status code is 403") public void deleteProcessByAnotherUser() throws Exception { - task = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); - restClient.authenticateUser(anotherUser); - processesApi.deleteProcess(task); - processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("user is not allowed to access information about process"); + process = restClient.authenticateUser(userWhoAddsProcess).addProcess("activitiAdhoc", assignee, false, Priority.Normal); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(anotherUser).usingProcess(process).deleteProcess(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("user is not allowed to access information about process"); } } From 1787e7f75327ca4c0dae580e7232cb7c1b572976 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alecsandru=20Prun=C4=83?= Date: Wed, 16 Nov 2016 13:23:05 +0200 Subject: [PATCH 0539/1491] TAS-1937 Refactor Test: processDefinitionsGetProcessDefinitionImageSanityTests.java --- .../GetProcessDefinitionImageSanityTests.java | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java index e47735bb3..f0f6a2cef 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java @@ -2,7 +2,6 @@ package org.alfresco.rest.workflow.processDefinitions; import org.alfresco.rest.RestWorkflowTest; import org.alfresco.rest.model.RestProcessDefinitionModel; -import org.alfresco.rest.requests.RestProcessDefinitionsApi; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; @@ -21,8 +20,6 @@ public class GetProcessDefinitionImageSanityTests extends RestWorkflowTest { @Autowired private DataUser dataUser; - @Autowired - private RestProcessDefinitionsApi processDefinitionsApi; private UserModel testUser; private RestProcessDefinitionModel randomProcessDefinition; @@ -31,25 +28,24 @@ public class GetProcessDefinitionImageSanityTests extends RestWorkflowTest public void dataPreparation() throws Exception { testUser = dataUser.createRandomTestUser(); - processDefinitionsApi.useRestClient(restClient); restClient.authenticateUser(dataUser.getAdminUser()); - randomProcessDefinition = processDefinitionsApi.getProcessDefinitions().getOneRandomEntry(); + randomProcessDefinition = restClient.getAllProcessDefinitions().getOneRandomEntry(); } @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.SANITY, description = "Verify Any user gets a specific process definition image for non-network deployments using REST API and status code is OK (200)") public void anyUserGetsProcessDefinitionImage() throws Exception { restClient.authenticateUser(testUser); - processDefinitionsApi.getProcessDefinitionImage(randomProcessDefinition) + restClient.usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionImage() .assertResponseContainsImage(); - processDefinitionsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets a specific process definition image for non-network deployments using REST API and status code is OK (200)") public void adminGetsProcessDefinitionImage() throws Exception { - processDefinitionsApi.getProcessDefinitionImage(randomProcessDefinition) + restClient.usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionImage() .assertResponseContainsImage(); - processDefinitionsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.assertStatusCodeIs(HttpStatus.OK); } -} \ No newline at end of file +} From 3c2b2fba8b577280aedba50e584a5579de753528 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alecsandru=20Prun=C4=83?= Date: Wed, 16 Nov 2016 13:28:24 +0200 Subject: [PATCH 0540/1491] TAS-1938 Refactor Test: GetProcessDefinitionSanityTests.java --- .../GetProcessDefinitionSanityTests.java | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java index 072d6cdc2..edd668b68 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java @@ -2,7 +2,6 @@ package org.alfresco.rest.workflow.processDefinitions; import org.alfresco.rest.RestWorkflowTest; import org.alfresco.rest.model.RestProcessDefinitionModel; -import org.alfresco.rest.requests.RestProcessDefinitionsApi; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; @@ -21,9 +20,6 @@ public class GetProcessDefinitionSanityTests extends RestWorkflowTest { @Autowired private DataUser dataUser; - @Autowired - private RestProcessDefinitionsApi processDefinitionsApi; - private UserModel testUser; private RestProcessDefinitionModel randomProcessDefinition; @@ -31,9 +27,8 @@ public class GetProcessDefinitionSanityTests extends RestWorkflowTest public void dataPreparation() throws Exception { testUser = dataUser.createRandomTestUser(); - processDefinitionsApi.useRestClient(restClient); restClient.authenticateUser(dataUser.getAdminUser()); - randomProcessDefinition = processDefinitionsApi.getProcessDefinitions().getOneRandomEntry(); + randomProcessDefinition = restClient.getAllProcessDefinitions().getOneRandomEntry(); } @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, @@ -41,12 +36,11 @@ public class GetProcessDefinitionSanityTests extends RestWorkflowTest description = "Verify Admin user gets a specific process definition for non-network deployments using REST API and status code is OK (200)") public void adminGetsProcessDefinition() throws Exception { - - processDefinitionsApi.getProcessDefinition(randomProcessDefinition). + restClient.usingProcessDefinitions(randomProcessDefinition).getProcessDefinition(). assertThat().field("name").is(randomProcessDefinition.onModel().getName()); - - processDefinitionsApi.getProcessDefinition(randomProcessDefinition).assertThat().field("name").is(randomProcessDefinition.onModel().getName()); - processDefinitionsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.usingProcessDefinitions(randomProcessDefinition).getProcessDefinition().assertThat().field("name") + .is(randomProcessDefinition.onModel().getName()); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, @@ -55,7 +49,8 @@ public class GetProcessDefinitionSanityTests extends RestWorkflowTest public void anyUserGetsProcessDefinition() throws Exception { restClient.authenticateUser(testUser); - processDefinitionsApi.getProcessDefinition(randomProcessDefinition).assertThat().field("name").is(randomProcessDefinition.onModel().getName()); - processDefinitionsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.usingProcessDefinitions(randomProcessDefinition).getProcessDefinition().assertThat().field("name") + .is(randomProcessDefinition.onModel().getName()); + restClient.assertStatusCodeIs(HttpStatus.OK); } } From c91927e39f3b9a3ee835c445af8bfaa009b9490b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alecsandru=20Prun=C4=83?= Date: Wed, 16 Nov 2016 13:36:44 +0200 Subject: [PATCH 0541/1491] TAS-1939 Refactor Test: GetProcessDefinitionStartFormModelSanityTests.java --- ...ssDefinitionStartFormModelSanityTests.java | 22 ++++++------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java index 248fe75ff..710bf7bdc 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java @@ -2,8 +2,6 @@ package org.alfresco.rest.workflow.processDefinitions; import org.alfresco.rest.RestWorkflowTest; import org.alfresco.rest.model.RestProcessDefinitionModel; -import org.alfresco.rest.requests.RestProcessDefinitionsApi; -import org.alfresco.rest.requests.RestTenantApi; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; @@ -20,12 +18,8 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY }) public class GetProcessDefinitionStartFormModelSanityTests extends RestWorkflowTest { - @Autowired - RestTenantApi tenantApi; @Autowired private DataUser dataUser; - @Autowired - private RestProcessDefinitionsApi processDefinitionsApi; private UserModel adminUserModel, adminTenantUser; private RestProcessDefinitionModel randomProcessDefinition; @@ -35,7 +29,6 @@ public class GetProcessDefinitionStartFormModelSanityTests extends RestWorkflowT { adminUserModel = dataUser.getAdminUser(); adminTenantUser = UserModel.getAdminTenantUser(); - processDefinitionsApi.useRestClient(restClient); restClient.authenticateUser(adminUserModel); } @@ -44,9 +37,9 @@ public class GetProcessDefinitionStartFormModelSanityTests extends RestWorkflowT description = "Verify Admin gets a model of the start form type definition for non-network deployments using REST API and status code is OK (200)") public void nonNetworkAdminGetsStartFormModel() throws Exception { - randomProcessDefinition = processDefinitionsApi.getProcessDefinitions().getOneRandomEntry(); - processDefinitionsApi.getProcessDefinitionStartFormModel(randomProcessDefinition).assertThat().entriesListIsNotEmpty(); - processDefinitionsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + randomProcessDefinition = restClient.getAllProcessDefinitions().getOneRandomEntry(); + restClient.usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionStartFormModel().assertThat().entriesListIsNotEmpty(); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, @@ -55,11 +48,10 @@ public class GetProcessDefinitionStartFormModelSanityTests extends RestWorkflowT @Test(groups = { TestGroup.NETWORKS }) public void networkAdminGetsStartFormModel() throws Exception { - tenantApi.useRestClient(restClient); - tenantApi.createTenant(adminTenantUser); + restClient.usingTenant().createTenant(adminTenantUser); restClient.authenticateUser(adminTenantUser); - randomProcessDefinition = processDefinitionsApi.getProcessDefinitions().getOneRandomEntry(); - processDefinitionsApi.getProcessDefinitionStartFormModel(randomProcessDefinition).assertThat().entriesListIsNotEmpty(); - processDefinitionsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + randomProcessDefinition = restClient.getAllProcessDefinitions().getOneRandomEntry(); + restClient.usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionStartFormModel().assertThat().entriesListIsNotEmpty(); + restClient.assertStatusCodeIs(HttpStatus.OK); } } From 90574391bf93096623c73a3eaddf8123a87b13a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alecsandru=20Prun=C4=83?= Date: Wed, 16 Nov 2016 13:39:36 +0200 Subject: [PATCH 0542/1491] TAS-1940 Refactor Test: GetProcessDefinitionsSanityTests.java --- .../GetProcessDefinitionsSanityTests.java | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java index ea3cadd89..4537b15e9 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java @@ -1,8 +1,6 @@ package org.alfresco.rest.workflow.processDefinitions; import org.alfresco.rest.RestWorkflowTest; -import org.alfresco.rest.requests.RestProcessDefinitionsApi; -import org.alfresco.rest.requests.RestTenantApi; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; @@ -19,12 +17,8 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY }) public class GetProcessDefinitionsSanityTests extends RestWorkflowTest { - @Autowired - RestTenantApi tenantApi; @Autowired private DataUser dataUser; - @Autowired - private RestProcessDefinitionsApi processDefinitionsApi; private UserModel adminUserModel, adminTenantUser; @@ -34,7 +28,6 @@ public class GetProcessDefinitionsSanityTests extends RestWorkflowTest adminUserModel = dataUser.getAdminUser(); adminTenantUser = UserModel.getAdminTenantUser(); restClient.authenticateUser(adminUserModel); - processDefinitionsApi.useRestClient(restClient); } // works on docker @@ -43,8 +36,8 @@ public class GetProcessDefinitionsSanityTests extends RestWorkflowTest public void nonNetworkAdminGetsProcessDefinitions() throws Exception { restClient.authenticateUser(adminUserModel); - processDefinitionsApi.getProcessDefinitions().assertThat().entriesListIsNotEmpty(); - processDefinitionsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.getAllProcessDefinitions().assertThat().entriesListIsNotEmpty(); + restClient.assertStatusCodeIs(HttpStatus.OK); } // works on alfresco.server=172.29.100.215 @@ -54,10 +47,9 @@ public class GetProcessDefinitionsSanityTests extends RestWorkflowTest @Test(groups = { TestGroup.NETWORKS }) public void networkAdminGetsProcessDefinitions() throws Exception { - tenantApi.useRestClient(restClient); - tenantApi.createTenant(adminTenantUser); + restClient.usingTenant().createTenant(adminTenantUser); restClient.authenticateUser(adminTenantUser); - processDefinitionsApi.getProcessDefinitions().assertThat().entriesListIsNotEmpty(); - processDefinitionsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.getAllProcessDefinitions().assertThat().entriesListIsNotEmpty(); + restClient.assertStatusCodeIs(HttpStatus.OK); } } From d1ff61e354428f33a54ab333c424c215ba983fc2 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Wed, 16 Nov 2016 14:33:21 +0200 Subject: [PATCH 0543/1491] Refactor Test: GetRatingSanityTests --- .../rest/ratings/GetRatingSanityTests.java | 124 +++++++----------- 1 file changed, 49 insertions(+), 75 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java index b326d56b4..c07f4b2e8 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java @@ -2,10 +2,11 @@ package org.alfresco.rest.ratings; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; -import org.alfresco.rest.requests.RestRatingsApi; +import org.alfresco.rest.model.RestRatingModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.exception.DataPreparationException; +import org.alfresco.utility.model.ErrorModel; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; @@ -14,7 +15,6 @@ import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; @@ -23,14 +23,13 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) public class GetRatingSanityTests extends RestTest { - @Autowired - RestRatingsApi ratingsApi; private SiteModel siteModel; private UserModel adminUser; private FolderModel folderModel; private FileModel document; private ListUserWithRoles usersWithRoles; + private RestRatingModel restRatingModel; @BeforeClass(alwaysRun=true) public void dataPreparation() throws DataPreparationException @@ -38,8 +37,6 @@ public class GetRatingSanityTests extends RestTest adminUser = dataUser.getAdminUser(); siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); - ratingsApi.useRestClient(restClient); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); } @@ -56,21 +53,16 @@ public class GetRatingSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - ratingsApi.likeDocument(document); - ratingsApi.rateStarsToDocument(document, 5); + restClient.usingResource(document).likeDocument(); + restClient.usingResource(document).rateStarsToDocument(5); - ratingsApi.getLikeRating(document) - .assertThat().field("id").is("likes") - .and().field("myRating").is("true"); - - ratingsApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.OK); + restRatingModel = restClient.usingResource(document).getLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); - ratingsApi.getFiveStarRating(document) - .assertThat().field("id").is("fiveStar") - .and().field("myRating").is("5"); - ratingsApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.OK); + restRatingModel = restClient.usingResource(document).getFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").is("5"); } @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, @@ -79,20 +71,16 @@ public class GetRatingSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - ratingsApi.likeDocument(document); - ratingsApi.rateStarsToDocument(document, 5); + restClient.usingResource(document).likeDocument(); + restClient.usingResource(document).rateStarsToDocument(5); - ratingsApi.getLikeRating(document) - .assertThat().field("id").is("likes") - .and().field("myRating").is("true"); - ratingsApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.OK); + restRatingModel = restClient.usingResource(document).getLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); - ratingsApi.getFiveStarRating(document) - .assertThat().field("id").is("fiveStar") - .and().field("myRating").is("5"); - ratingsApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.OK); + restRatingModel = restClient.usingResource(document).getFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").is("5"); } @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, @@ -101,20 +89,16 @@ public class GetRatingSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - ratingsApi.likeDocument(document); - ratingsApi.rateStarsToDocument(document, 5); + restClient.usingResource(document).likeDocument(); + restClient.usingResource(document).rateStarsToDocument(5); - ratingsApi.getLikeRating(document) - .assertThat().field("id").is("likes") - .and().field("myRating").is("true"); - ratingsApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.OK); + restRatingModel = restClient.usingResource(document).getLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); - ratingsApi.getFiveStarRating(document) - .assertThat().field("id").is("fiveStar") - .and().field("myRating").is("5"); - ratingsApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.OK); + restRatingModel = restClient.usingResource(document).getFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").is("5"); } @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, @@ -123,20 +107,16 @@ public class GetRatingSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - ratingsApi.likeDocument(document); - ratingsApi.rateStarsToDocument(document, 5); + restClient.usingResource(document).likeDocument(); + restClient.usingResource(document).rateStarsToDocument(5); - ratingsApi.getLikeRating(document) - .assertThat().field("id").is("likes") - .and().field("myRating").is("true"); - ratingsApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.OK); + restRatingModel = restClient.usingResource(document).getLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); - ratingsApi.getFiveStarRating(document) - .assertThat().field("id").is("fiveStar") - .and().field("myRating").is("5"); - ratingsApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.OK); + restRatingModel = restClient.usingResource(document).getFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").is("5"); } @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, @@ -146,20 +126,16 @@ public class GetRatingSanityTests extends RestTest document = dataContent.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); restClient.authenticateUser(adminUser); - ratingsApi.likeDocument(document); - ratingsApi.rateStarsToDocument(document, 5); + restClient.usingResource(document).likeDocument(); + restClient.usingResource(document).rateStarsToDocument(5); - ratingsApi.getLikeRating(document) - .assertThat().field("id").is("likes") - .and().field("myRating").is("true"); - ratingsApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.OK); + restRatingModel = restClient.usingResource(document).getLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); - ratingsApi.getFiveStarRating(document) - .assertThat().field("id").is("fiveStar") - .and().field("myRating").is("5"); - ratingsApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.OK); + restRatingModel = restClient.usingResource(document).getFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").is("5"); } @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, @@ -168,17 +144,15 @@ public class GetRatingSanityTests extends RestTest public void unauthenticatedUserIsNotAbleToRetrieveRating() throws Exception { restClient.authenticateUser(adminUser); - ratingsApi.likeDocument(document); - ratingsApi.rateStarsToDocument(document, 5); + restClient.usingResource(document).likeDocument(); + restClient.usingResource(document).rateStarsToDocument(5); restClient.authenticateUser(new UserModel("random user", "random password")); - ratingsApi.getLikeRating(document); - ratingsApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.usingResource(document).getLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(ErrorModel.AUTHENTICATION_FAILED); - ratingsApi.getFiveStarRating(document); - ratingsApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.usingResource(document).getFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(ErrorModel.AUTHENTICATION_FAILED); } } \ No newline at end of file From f1bc8c238dc4e04049ec1596496fb57c0873eca1 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Wed, 16 Nov 2016 15:19:10 +0200 Subject: [PATCH 0544/1491] Refactor Test: GetRatingsSanityTests --- .../rest/ratings/GetRatingsSanityTests.java | 79 ++++++++----------- 1 file changed, 32 insertions(+), 47 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/ratings/GetRatingsSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/GetRatingsSanityTests.java index bbe5c1cc9..701b9f1ce 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/GetRatingsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/GetRatingsSanityTests.java @@ -2,10 +2,11 @@ package org.alfresco.rest.ratings; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; -import org.alfresco.rest.requests.RestRatingsApi; +import org.alfresco.rest.model.RestRatingModelsCollection; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.exception.DataPreparationException; +import org.alfresco.utility.model.ErrorModel; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; @@ -14,7 +15,6 @@ import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; @@ -23,14 +23,12 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) public class GetRatingsSanityTests extends RestTest { - @Autowired - RestRatingsApi ratingsApi; - private SiteModel siteModel; private UserModel adminUser; private FolderModel folderModel; private FileModel document; private ListUserWithRoles usersWithRoles; + private RestRatingModelsCollection restRatingModelsCollection; @BeforeClass(alwaysRun=true) public void dataPreparation() throws DataPreparationException @@ -38,8 +36,6 @@ public class GetRatingsSanityTests extends RestTest adminUser = dataUser.getAdminUser(); siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); - ratingsApi.useRestClient(restClient); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); } @@ -56,14 +52,12 @@ public class GetRatingsSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - ratingsApi.likeDocument(document); - ratingsApi.rateStarsToDocument(document, 5); + restClient.usingResource(document).likeDocument(); + restClient.usingResource(document).rateStarsToDocument(5); - ratingsApi.getRatings(document) - .assertNodeHasFiveStarRating() - .assertNodeIsLiked(); - ratingsApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.OK); + restRatingModelsCollection = restClient.usingResource(document).getRatings(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restRatingModelsCollection.assertNodeHasFiveStarRating().assertNodeIsLiked(); } @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, @@ -72,14 +66,12 @@ public class GetRatingsSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - ratingsApi.likeDocument(document); - ratingsApi.rateStarsToDocument(document, 5); + restClient.usingResource(document).likeDocument(); + restClient.usingResource(document).rateStarsToDocument(5); - ratingsApi.getRatings(document) - .assertNodeHasFiveStarRating() - .assertNodeIsLiked(); - ratingsApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.OK); + restRatingModelsCollection = restClient.usingResource(document).getRatings(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restRatingModelsCollection.assertNodeHasFiveStarRating().assertNodeIsLiked(); } @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, @@ -88,14 +80,12 @@ public class GetRatingsSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - ratingsApi.likeDocument(document); - ratingsApi.rateStarsToDocument(document, 5); + restClient.usingResource(document).likeDocument(); + restClient.usingResource(document).rateStarsToDocument(5); - ratingsApi.getRatings(document) - .assertNodeHasFiveStarRating() - .assertNodeIsLiked(); - ratingsApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.OK); + restRatingModelsCollection = restClient.usingResource(document).getRatings(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restRatingModelsCollection.assertNodeHasFiveStarRating().assertNodeIsLiked(); } @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, @@ -104,14 +94,12 @@ public class GetRatingsSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - ratingsApi.likeDocument(document); - ratingsApi.rateStarsToDocument(document, 5); + restClient.usingResource(document).likeDocument(); + restClient.usingResource(document).rateStarsToDocument(5); - ratingsApi.getRatings(document) - .assertNodeHasFiveStarRating() - .assertNodeIsLiked(); - ratingsApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.OK); + restRatingModelsCollection = restClient.usingResource(document).getRatings(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restRatingModelsCollection.assertNodeHasFiveStarRating().assertNodeIsLiked(); } @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, @@ -122,14 +110,12 @@ public class GetRatingsSanityTests extends RestTest .usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); restClient.authenticateUser(adminUser); - ratingsApi.likeDocument(document); - ratingsApi.rateStarsToDocument(document, 5); + restClient.usingResource(document).likeDocument(); + restClient.usingResource(document).rateStarsToDocument(5); - ratingsApi.getRatings(document) - .assertNodeHasFiveStarRating() - .assertNodeIsLiked(); - ratingsApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.OK); + restRatingModelsCollection = restClient.usingResource(document).getRatings(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restRatingModelsCollection.assertNodeHasFiveStarRating().assertNodeIsLiked(); } @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, @@ -138,13 +124,12 @@ public class GetRatingsSanityTests extends RestTest public void unauthenticatedUserIsNotAbleToRetrieveRatings() throws Exception { restClient.authenticateUser(adminUser); - ratingsApi.likeDocument(document); - ratingsApi.rateStarsToDocument(document, 5); + restClient.usingResource(document).likeDocument(); + restClient.usingResource(document).rateStarsToDocument(5); restClient.authenticateUser(new UserModel("random user", "random password")); - ratingsApi.getRatings(document); - ratingsApi.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.usingResource(document).getRatings(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(ErrorModel.AUTHENTICATION_FAILED); } } \ No newline at end of file From 6b51d34ca53ab7df03a68669bc71f2498f55df47 Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 16 Nov 2016 15:48:36 +0200 Subject: [PATCH 0545/1491] update tests based on new refactored DSL --- .../processes/GetProcessItemsSanityTests.java | 74 +++++++------------ 1 file changed, 27 insertions(+), 47 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsSanityTests.java index 392fb21f2..e71f67974 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsSanityTests.java @@ -1,19 +1,16 @@ package org.alfresco.rest.workflow.processes; import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.dataprep.CMISUtil.Priority; import org.alfresco.rest.RestWorkflowTest; -import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestItemModelsCollection; import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.requests.Processes; -import org.alfresco.rest.requests.RestTenantApi; -import org.alfresco.utility.data.DataUser; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -25,21 +22,11 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public class GetProcessItemsSanityTests extends RestWorkflowTest { - @Autowired - private DataUser dataUser; - - @Autowired - private Processes processesApi; - - @Autowired - RestTenantApi tenantApi; - private FileModel document; private SiteModel siteModel; - private UserModel userWhoStartsTask, assignee, adminTenantUser, tenantUser; + private UserModel userWhoStartsTask, assignee, adminTenantUser, tenantUser, tenantUserAssignee; private RestProcessModel processModel; - - private UserModel tenantUserAssignee; + private RestItemModelsCollection items; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception @@ -49,49 +36,42 @@ public class GetProcessItemsSanityTests extends RestWorkflowTest siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); - processesApi.useRestClient(restClient); } - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify that user that started the process gets all process items") - public void getProcessItemsUsingTheUserWhoStartedProcess() throws JsonToModelConversionException, Exception + public void getProcessItemsUsingTheUserWhoStartedProcess() throws Exception { - restClient.authenticateUser(userWhoStartsTask); - processModel = processesApi.getProcesses().getOneRandomEntry(); - processesApi.getProcessesItems(processModel).assertThat().entriesListIsNotEmpty(); - processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + processModel = restClient.authenticateUser(userWhoStartsTask).getProcesses().getOneRandomEntry().onModel(); + items = restClient.usingProcess(processModel).getProcessItems(); + restClient.assertStatusCodeIs(HttpStatus.OK); + items.assertThat().entriesListIsNotEmpty(); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify that user that is involved in the process gets all process items") - public void getProcessItemsUsingUserInvolvedInProcess() throws JsonToModelConversionException, Exception + public void getProcessItemsUsingUserInvolvedInProcess() throws Exception { - restClient.authenticateUser(assignee); - processModel = processesApi.getProcesses().getOneRandomEntry(); - processesApi.getProcessesItems(processModel).assertThat().entriesListIsNotEmpty(); - processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + processModel = restClient.authenticateUser(assignee).getProcesses().getOneRandomEntry().onModel(); + items = restClient.usingProcess(processModel).getProcessItems(); + restClient.assertStatusCodeIs(HttpStatus.OK); + items.assertThat().entriesListIsNotEmpty(); } - + @Test(groups = { TestGroup.NETWORKS }) - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Get process items using admin from same network") - public void getProcessItemsUsingAdminUserFromSameNetwork() throws JsonToModelConversionException, Exception + public void getProcessItemsUsingAdminUserFromSameNetwork() throws Exception { - UserModel adminuser = dataUser.getAdminUser(); - restClient.authenticateUser(adminuser); - adminTenantUser = UserModel.getAdminTenantUser(); - tenantApi.useRestClient(restClient); - tenantApi.createTenant(adminTenantUser); - + restClient.authenticateUser(dataUser.getAdminUser()).usingTenant().createTenant(adminTenantUser); tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); - - siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); - dataWorkflow.usingUser(tenantUser).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(tenantUserAssignee); - - processModel = processesApi.getProcesses().getOneRandomEntry(); - processesApi.getProcessesItems(processModel).assertThat().entriesListIsNotEmpty(); - processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.authenticateUser(tenantUser).addProcess("activitiAdhoc", tenantUserAssignee, false, Priority.Normal); + + processModel = restClient.authenticateUser(adminTenantUser).getProcesses().getOneRandomEntry().onModel(); + items = restClient.usingProcess(processModel).getProcessItems(); + restClient.assertStatusCodeIs(HttpStatus.OK); + items.assertThat().entriesListIsNotEmpty(); } } From 618d3a03c8091e53fbc1eb11f973ae184d257e6c Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 16 Nov 2016 15:54:45 +0200 Subject: [PATCH 0546/1491] update tests based on new refactored DSL --- .../processes/GetProcessSanityTests.java | 39 +++++++------------ 1 file changed, 14 insertions(+), 25 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessSanityTests.java index cb1820e85..74489edb4 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessSanityTests.java @@ -3,13 +3,10 @@ package org.alfresco.rest.workflow.processes; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestWorkflowTest; import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.requests.Processes; -import org.alfresco.utility.data.DataUser; 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.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -20,52 +17,44 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public class GetProcessSanityTests extends RestWorkflowTest { - @Autowired - private DataUser dataUser; - - @Autowired - private Processes processesApi; - private UserModel userWhoStartsProcess, assignee; - private RestProcessModel addedProcess; + private RestProcessModel addedProcess, process; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception { - processesApi.useRestClient(restClient); userWhoStartsProcess = dataUser.createRandomTestUser(); assignee = dataUser.createRandomTestUser(); - restClient.authenticateUser(userWhoStartsProcess); - addedProcess = processesApi.addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.High); + addedProcess = restClient.authenticateUser(userWhoStartsProcess).addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.High); } @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify user is able to get the process started by him using REST API and status code is OK (200)") public void getProcessByOwner() throws Exception { - restClient.authenticateUser(userWhoStartsProcess); - processesApi.getProcess(addedProcess).and().field("id").is(addedProcess.getId()) - .and().field("startUserId").is(addedProcess.getStartUserId()); - processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + process = restClient.authenticateUser(userWhoStartsProcess).usingProcess(addedProcess).getProcess(); + restClient.assertStatusCodeIs(HttpStatus.OK); + process.assertThat().field("id").is(addedProcess.getId()) + .and().field("startUserId").is(addedProcess.getStartUserId()); } @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify user is able to get the process assigned to him using REST API and status code is OK (200)") public void getProcessByAssignee() throws Exception { - restClient.authenticateUser(assignee); - processesApi.getProcess(addedProcess).and().field("id").is(addedProcess.getId()) - .and().field("startUserId").is(addedProcess.getStartUserId()); - processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + process = restClient.authenticateUser(assignee).usingProcess(addedProcess).getProcess(); + restClient.assertStatusCodeIs(HttpStatus.OK); + process.assertThat().field("id").is(addedProcess.getId()) + .and().field("startUserId").is(addedProcess.getStartUserId()); } @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify admin is able to get any process using REST API and status code is OK (200)") public void getProcessByAdmin() throws Exception { - restClient.authenticateUser(dataUser.getAdminUser()); - processesApi.getProcess(addedProcess).and().field("id").is(addedProcess.getId()) - .and().field("startUserId").is(addedProcess.getStartUserId()); - processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + process = restClient.authenticateUser(dataUser.getAdminUser()).usingProcess(addedProcess).getProcess(); + restClient.assertStatusCodeIs(HttpStatus.OK); + process.assertThat().field("id").is(addedProcess.getId()) + .and().field("startUserId").is(addedProcess.getStartUserId()); } } From 4bdeb7587e557c3a54fba17b9dfd86671ac5521c Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Wed, 16 Nov 2016 16:00:42 +0200 Subject: [PATCH 0547/1491] groupping rest API in own DSL updating test to use core or workflow API --- .../java/org/alfresco/rest/MySampleDSL.java | 64 ------------- e2e-test/java/org/alfresco/rest/RestTest.java | 6 -- .../org/alfresco/rest/RestWorkflowTest.java | 15 +--- .../rest/comments/AddCommentSanityTests.java | 17 ++-- .../rest/comments/AddCommentsSanityTests.java | 23 +++-- .../comments/DeleteCommentsSanityTests.java | 24 ++--- .../rest/comments/GetCommentsSanityTests.java | 33 +++---- .../comments/UpdateCommentsSanityTests.java | 30 +++---- .../org/alfresco/rest/demo/RestDemoTests.java | 18 ++-- .../rest/demo/SampleCommentsTests.java | 8 +- .../alfresco/rest/demo/SamplePeopleTests.java | 2 +- .../alfresco/rest/demo/SampleSitesTests.java | 14 +-- .../favorites/AddFavoritesSanityTests.java | 44 +++++---- .../favorites/DeleteFavoritesSanityTests.java | 37 +++++--- .../favorites/GetFavoriteSanityTests.java | 38 ++++---- .../favorites/GetFavoritesSanityTests.java | 90 +++++++++++-------- .../RestGetNetworkForPersonSanityTests.java | 29 +++--- .../rest/networks/RestGetNetworkTest.java | 26 +++--- .../RestGetNetworksForPersonSanityTests.java | 30 ++++--- .../people/AddFavoriteSiteSanityTests.java | 8 +- .../AddSiteMembershipRequestSanityTests.java | 25 ++++-- .../people/DeleteFavoriteSiteSanityTests.java | 35 ++++++-- .../people/DeleteSiteMemberSanityTests.java | 55 ++++++------ ...eleteSiteMembershipRequestSanityTests.java | 56 ++++++++---- .../people/GetFavoriteSiteSanityTests.java | 41 ++++++--- .../people/GetFavoriteSitesSanityTests.java | 47 ++++++---- .../GetPeopleActivitiesSanityTests.java | 34 +++++-- .../GetPeoplePreferenceSanityTests.java | 12 +-- .../GetPeoplePreferencesSanityTests.java | 40 ++++++--- .../rest/people/GetPeopleSanityTests.java | 30 +++++-- .../GetSiteMembershipRequestSanityTests.java | 18 ++-- .../GetSiteMembershipRequestsSanityTests.java | 38 ++++++-- .../people/GetSiteMembershipSanityTests.java | 44 ++++----- ...SitesMembershipInformationSanityTests.java | 30 ++++--- ...pdateSiteMembershipRequestSanityTests.java | 25 ++++-- .../rest/ratings/AddRatingSanityTests.java | 24 ++--- .../rest/ratings/DeleteRatingSanityTests.java | 66 +++++++------- .../rest/ratings/GetRatingSanityTests.java | 48 +++++----- .../rest/sites/AddSiteMemberSanityTests.java | 19 ++-- .../sites/GetSiteContainerSanityTests.java | 24 ++--- .../sites/GetSiteContainersSanityTests.java | 38 ++++---- .../rest/sites/GetSiteMemberSanityTests.java | 12 +-- .../rest/sites/GetSiteMembersSanityTests.java | 12 +-- .../rest/sites/GetSiteSanityTests.java | 13 +-- .../rest/sites/GetSitesSanityTests.java | 12 +-- .../sites/RemoveSiteMemberSanityTests.java | 22 ++--- .../sites/UpdateSiteMemberSanityTests.java | 12 +-- .../GetProcessDefinitionImageSanityTests.java | 6 +- .../GetProcessDefinitionSanityTests.java | 8 +- ...ssDefinitionStartFormModelSanityTests.java | 8 +- .../processes/AddProcessItemSanityTests.java | 20 +++-- .../processes/AddProcessSanityTests.java | 9 +- .../AddProcessVariableSanityTests.java | 24 ++--- .../processes/DeleteProcessSanityTests.java | 16 ++-- .../processes/GetProcessItemsSanityTests.java | 1 - .../processes/GetProcessTasksSanityTests.java | 6 +- .../GetProcessVariablesSanityTests.java | 8 +- .../processes/GetProcessesSanityTests.java | 8 +- 58 files changed, 816 insertions(+), 686 deletions(-) delete mode 100644 e2e-test/java/org/alfresco/rest/MySampleDSL.java diff --git a/e2e-test/java/org/alfresco/rest/MySampleDSL.java b/e2e-test/java/org/alfresco/rest/MySampleDSL.java deleted file mode 100644 index 92375185c..000000000 --- a/e2e-test/java/org/alfresco/rest/MySampleDSL.java +++ /dev/null @@ -1,64 +0,0 @@ -package org.alfresco.rest; - -import org.alfresco.rest.core.RestProperties; -import org.alfresco.rest.core.RestWrapper; -import org.alfresco.utility.data.DataUser; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import com.jayway.restassured.RestAssured; - -@ContextConfiguration("classpath:alfresco-restapi-context.xml") -public class MySampleDSL extends AbstractTestNGSpringContextTests { - @Autowired - RestWrapper restAPI; - - @Autowired - DataUser dataUser; - - @Autowired - protected RestProperties restProperties; - - @BeforeClass - public void asd() { - RestAssured.baseURI = restProperties.envProperty().getTestServerUrl(); - RestAssured.port = restProperties.envProperty().getPort(); - RestAssured.basePath = restProperties.getRestBasePath(); - } - - @Test - public void something() throws Exception { - // GET /Sites//containers - - - restAPI.authenticateUser(dataUser.getAdminUser()).usingSite("workshop").getContainers().assertThat().entriesListIsNotEmpty(); - - -// restAPI.usingSite("hahaha").getContainers().assertThat().field("level1").field("level2").field("level3").is("b") -// restAPI.usingSite("hahaha").getContainers().assertThat().field("level3").is("a"); -// restAPI.usingSite("hahaha").getContainers().assertThat().listIsNotEmpty() -// .listContains(level) -// .statusCode().is(HttpStatus.OK); -// -// -// -// //GET /sites/{siteId}/containers/{containerId} -// -// restAPI.usingSite("haha").getContainer("c1").assertThat().file("folderId").is("jjsjsj"); -// .statusCode(). -// -// -// SiteModel site; -// String body = JsonBodyGenerator.siteMemberhipRequest("Please accept me", site, "New request"); -// restAPI.usingPeople(people).withBody(body).addSiteMembershipRequest(); -// -// -// -// -// restAPI.usingPeople(people).withBody(body).addSiteMembershipRequest().assertthat().statusCode().is().and().fiels -// restApi.getBodyResponse. - } -} diff --git a/e2e-test/java/org/alfresco/rest/RestTest.java b/e2e-test/java/org/alfresco/rest/RestTest.java index cc5e41e4b..25118ed00 100644 --- a/e2e-test/java/org/alfresco/rest/RestTest.java +++ b/e2e-test/java/org/alfresco/rest/RestTest.java @@ -13,8 +13,6 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; import org.testng.annotations.BeforeClass; -import com.jayway.restassured.RestAssured; - @ContextConfiguration("classpath:alfresco-restapi-context.xml") public abstract class RestTest extends AbstractTestNGSpringContextTests { @@ -46,9 +44,5 @@ public abstract class RestTest extends AbstractTestNGSpringContextTests public void checkServerHealth() throws Exception { serverHealth.assertServerIsOnline(); - - RestAssured.baseURI = restProperties.envProperty().getTestServerUrl(); - RestAssured.port = restProperties.envProperty().getPort(); - RestAssured.basePath = restProperties.getRestBasePath(); } } diff --git a/e2e-test/java/org/alfresco/rest/RestWorkflowTest.java b/e2e-test/java/org/alfresco/rest/RestWorkflowTest.java index 2409a2fc3..34d216c9f 100644 --- a/e2e-test/java/org/alfresco/rest/RestWorkflowTest.java +++ b/e2e-test/java/org/alfresco/rest/RestWorkflowTest.java @@ -2,22 +2,9 @@ package org.alfresco.rest; import org.alfresco.utility.data.DataWorkflow; import org.springframework.beans.factory.annotation.Autowired; -import org.testng.annotations.BeforeClass; - -import com.jayway.restassured.RestAssured; public abstract class RestWorkflowTest extends RestTest { @Autowired - protected DataWorkflow dataWorkflow; - - @BeforeClass(alwaysRun = true) - public void checkServerHealth() throws Exception - { - serverHealth.assertServerIsOnline(); - - RestAssured.baseURI = restProperties.envProperty().getTestServerUrl(); - RestAssured.port = restProperties.envProperty().getPort(); - RestAssured.basePath = restProperties.getRestWorkflowPath(); - } + protected DataWorkflow dataWorkflow; } diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java index a21cdd903..9bf0330fe 100644 --- a/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java @@ -4,7 +4,6 @@ import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.ErrorModel; import org.alfresco.utility.model.FileModel; @@ -14,7 +13,6 @@ import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -22,9 +20,6 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) public class AddCommentSanityTests extends RestTest { - @Autowired - DataUser dataUser; - private UserModel adminUserModel; private FileModel document; private SiteModel siteModel; @@ -46,7 +41,7 @@ public class AddCommentSanityTests extends RestTest { restClient.authenticateUser(adminUserModel); String newContent = "This is a new comment added by " + adminUserModel.getUsername(); - restClient.usingResource(document).addComment(newContent) + restClient.onCoreAPI().usingResource(document).addComment(newContent) .assertThat().field("content").isNotEmpty() .and().field("content").is(newContent); restClient.assertStatusCodeIs(HttpStatus.CREATED); @@ -57,7 +52,7 @@ public class AddCommentSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); String contentSiteManger = "This is a new comment added by user with role: " + UserRole.SiteManager; - restClient.usingResource(document).addComment(contentSiteManger) + restClient.onCoreAPI().usingResource(document).addComment(contentSiteManger) .assertThat().field("content").isNotEmpty() .and().field("content").is(contentSiteManger); restClient.assertStatusCodeIs(HttpStatus.CREATED); @@ -68,7 +63,7 @@ public class AddCommentSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); String contentSiteContributor = "This is a new comment added by user with role" + UserRole.SiteContributor; - restClient.usingResource(document).addComment(contentSiteContributor) + restClient.onCoreAPI().usingResource(document).addComment(contentSiteContributor) .assertThat().field("content").isNotEmpty() .and().field("content").is(contentSiteContributor); restClient.assertStatusCodeIs(HttpStatus.CREATED); @@ -79,7 +74,7 @@ public class AddCommentSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); String contentSiteCollaborator = "This is a new comment added by user with role: " + UserRole.SiteCollaborator; - restClient.usingResource(document).addComment(contentSiteCollaborator) + restClient.onCoreAPI().usingResource(document).addComment(contentSiteCollaborator) .assertThat().field("content").isNotEmpty() .and().field("content").is(contentSiteCollaborator); restClient.assertStatusCodeIs(HttpStatus.CREATED); @@ -90,7 +85,7 @@ public class AddCommentSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); String contentSiteConsumer = "This is a new comment added by user with role: " + UserRole.SiteConsumer; - restClient.usingResource(document).addComment(contentSiteConsumer); + restClient.onCoreAPI().usingResource(document).addComment(contentSiteConsumer); restClient .assertStatusCodeIs(HttpStatus.FORBIDDEN) .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); @@ -101,7 +96,7 @@ public class AddCommentSanityTests extends RestTest public void unauthenticatedUserIsNotAbleToAddComment() throws JsonToModelConversionException, Exception { restClient.authenticateUser(new UserModel("random user", "random password")); - restClient.usingResource(document).addComment("This is a new comment"); + restClient.onCoreAPI().usingResource(document).addComment("This is a new comment"); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java index 751747cc3..e42f5dac3 100644 --- a/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java @@ -14,7 +14,6 @@ import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; @@ -25,9 +24,7 @@ import org.testng.annotations.Test; */ @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) public class AddCommentsSanityTests extends RestTest -{ - @Autowired DataUser dataUser; - +{ private UserModel adminUserModel; private FileModel document; private SiteModel siteModel; @@ -57,10 +54,10 @@ public class AddCommentsSanityTests extends RestTest public void adminIsAbleToAddComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel) - .usingResource(document).addComments(comment1, comment2) - .assertThat().entriesListIsNotEmpty() - .and().entriesListContains("content", comment1) - .and().entriesListContains("content", comment2); + .onCoreAPI().usingResource(document).addComments(comment1, comment2) + .assertThat().entriesListIsNotEmpty() + .and().entriesListContains("content", comment1) + .and().entriesListContains("content", comment2); restClient.assertStatusCodeIs(HttpStatus.CREATED); } @@ -69,7 +66,7 @@ public class AddCommentsSanityTests extends RestTest public void managerIsAbleToAddComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .usingResource(document).addComments(comment1, comment2) + .onCoreAPI().usingResource(document).addComments(comment1, comment2) .assertThat().entriesListIsNotEmpty() .and().entriesListContains("content", comment1) .and().entriesListContains("content", comment2); @@ -81,7 +78,7 @@ public class AddCommentsSanityTests extends RestTest public void contributorIsAbleToAddComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) - .usingResource(document).addComments(comment1, comment2) + .onCoreAPI().usingResource(document).addComments(comment1, comment2) .assertThat().entriesListIsNotEmpty() .and().entriesListContains("content", comment1) .and().entriesListContains("content", comment2); @@ -93,7 +90,7 @@ public class AddCommentsSanityTests extends RestTest public void collaboratorIsAbleToAddComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .usingResource(document).addComments(comment1, comment2) + .onCoreAPI().usingResource(document).addComments(comment1, comment2) .assertThat().paginationExist().and().entriesListIsNotEmpty() .and().entriesListContains("content", comment1) .and().entriesListContains("content", comment2); @@ -106,7 +103,7 @@ public class AddCommentsSanityTests extends RestTest public void consumerIsAbleToAddComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .usingResource(document).addComments(comment1, comment2); + .onCoreAPI().usingResource(document).addComments(comment1, comment2); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @@ -117,7 +114,7 @@ public class AddCommentsSanityTests extends RestTest public void unauthenticatedUserIsNotAbleToAddComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(new UserModel("random user", "random password")) - .usingResource(document).addComments(comment1, comment2); + .onCoreAPI().usingResource(document).addComments(comment1, comment2); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java index 79f39ae48..7773d76fe 100644 --- a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java @@ -4,9 +4,7 @@ import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestCommentModel; -import org.alfresco.rest.requests.Node; import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.ErrorModel; import org.alfresco.utility.model.FileModel; @@ -15,7 +13,6 @@ 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.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; @@ -24,13 +21,6 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) public class DeleteCommentsSanityTests extends RestTest { - - @Autowired - Node commentsAPI; - - @Autowired - DataUser dataUser; - private UserModel adminUserModel; private FileModel document; @@ -52,7 +42,7 @@ public class DeleteCommentsSanityTests extends RestTest public void addCommentToDocument() throws Exception { restClient.authenticateUser(adminUserModel); - comment = restClient.usingResource(document).addComment("This is a new comment"); + comment = restClient.onCoreAPI().usingResource(document).addComment("This is a new comment"); } @TestRail(section = { TestGroup.REST_API, @@ -60,7 +50,7 @@ public class DeleteCommentsSanityTests extends RestTest public void adminIsAbleToDeleteComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); - restClient.usingResource(document).deleteComment(comment); + restClient.onCoreAPI().usingResource(document).deleteComment(comment); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } @@ -69,7 +59,7 @@ public class DeleteCommentsSanityTests extends RestTest public void managerIsAbleToDeleteComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.usingResource(document).deleteComment(comment); + restClient.onCoreAPI().usingResource(document).deleteComment(comment); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } @@ -78,7 +68,7 @@ public class DeleteCommentsSanityTests extends RestTest public void collaboratorIsNotAbleToDeleteComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.usingResource(document).deleteComment(comment); + restClient.onCoreAPI().usingResource(document).deleteComment(comment); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @@ -88,7 +78,7 @@ public class DeleteCommentsSanityTests extends RestTest public void contributorIsNotAbleToDeleteComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - restClient.usingResource(document).deleteComment(comment); + restClient.onCoreAPI().usingResource(document).deleteComment(comment); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @@ -98,7 +88,7 @@ public class DeleteCommentsSanityTests extends RestTest public void consumerIsNotAbleToDeleteComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.usingResource(document).deleteComment(comment); + restClient.onCoreAPI().usingResource(document).deleteComment(comment); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @@ -109,7 +99,7 @@ public class DeleteCommentsSanityTests extends RestTest { UserModel nonexistentModel = new UserModel("nonexistentUser", "nonexistentPassword"); restClient.authenticateUser(nonexistentModel); - restClient.usingResource(document).deleteComment(comment); + restClient.onCoreAPI().usingResource(document).deleteComment(comment); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java index 3894b81a0..328870889 100644 --- a/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java @@ -3,9 +3,7 @@ package org.alfresco.rest.comments; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.requests.Node; import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; @@ -14,7 +12,6 @@ import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -22,13 +19,7 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) public class GetCommentsSanityTests extends RestTest { - @Autowired - Node commentsAPI; - - @Autowired - DataUser dataUser; - - private UserModel adminUserModel; + private UserModel adminUserModel; private FileModel document; private SiteModel siteModel; @@ -44,7 +35,7 @@ public class GetCommentsSanityTests extends RestTest siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); content = "This is a new comment"; - restClient.usingResource(document).addComment(content); + restClient.onCoreAPI().usingResource(document).addComment(content); usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); } @@ -54,7 +45,7 @@ public class GetCommentsSanityTests extends RestTest public void adminIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); - restClient.usingResource(document).getNodeComments(); + restClient.onCoreAPI().usingResource(document).getNodeComments(); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -63,7 +54,7 @@ public class GetCommentsSanityTests extends RestTest public void managerIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.usingResource(document).getNodeComments() + restClient.onCoreAPI().usingResource(document).getNodeComments() .assertThat().entriesListContains("content", content); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -74,7 +65,7 @@ public class GetCommentsSanityTests extends RestTest public void contributorIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - restClient.usingResource(document).getNodeComments() + restClient.onCoreAPI().usingResource(document).getNodeComments() .assertThat().entriesListContains("content", content); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -85,7 +76,7 @@ public class GetCommentsSanityTests extends RestTest public void collaboratorIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.usingResource(document).getNodeComments() + restClient.onCoreAPI().usingResource(document).getNodeComments() .assertThat().entriesListContains("content", content); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -95,7 +86,7 @@ public class GetCommentsSanityTests extends RestTest public void consumerIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.usingResource(document).getNodeComments() + restClient.onCoreAPI().usingResource(document).getNodeComments() .assertThat().entriesListContains("content", content); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -107,7 +98,7 @@ public class GetCommentsSanityTests extends RestTest { UserModel nonexistentModel = new UserModel("nonexistentUser", "nonexistentPassword"); restClient.authenticateUser(nonexistentModel); - restClient.usingResource(document).getNodeComments(); + restClient.onCoreAPI().usingResource(document).getNodeComments(); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } @@ -118,10 +109,10 @@ public class GetCommentsSanityTests extends RestTest userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); restClient.authenticateUser(userModel); String contentManager = "This is a new comment added by " + userModel.getUsername(); - restClient.usingResource(document).addComment(contentManager); + restClient.onCoreAPI().usingResource(document).addComment(contentManager); restClient.assertStatusCodeIs(HttpStatus.CREATED); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.usingResource(document).getNodeComments() + restClient.onCoreAPI().usingResource(document).getNodeComments() .assertThat().entriesListContains("content", contentManager); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -134,10 +125,10 @@ public class GetCommentsSanityTests extends RestTest userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); restClient.authenticateUser(userModel); String contentCollaborator = "This is a new comment added by " + userModel.getUsername(); - restClient.usingResource(document).addComment(contentCollaborator); + restClient.onCoreAPI().usingResource(document).addComment(contentCollaborator); restClient.assertStatusCodeIs(HttpStatus.CREATED); restClient.authenticateUser(adminUserModel); - restClient.usingResource(document).getNodeComments() + restClient.onCoreAPI().usingResource(document).getNodeComments() .assertThat().entriesListContains("content", contentCollaborator); restClient.assertStatusCodeIs(HttpStatus.OK); diff --git a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java index 365ce310c..da53f841f 100644 --- a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java @@ -4,9 +4,7 @@ import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestCommentModel; -import org.alfresco.rest.requests.Node; import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.ErrorModel; import org.alfresco.utility.model.FileModel; @@ -17,7 +15,6 @@ import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -25,12 +22,6 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) public class UpdateCommentsSanityTests extends RestTest { - @Autowired - Node commentsAPI; - - @Autowired - DataUser dataUser; - private UserModel adminUserModel; private FileModel document; private SiteModel siteModel; @@ -45,7 +36,7 @@ public class UpdateCommentsSanityTests extends RestTest siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - commentModel = restClient.usingResource(document).addComment("This is a new comment"); + commentModel = restClient.onCoreAPI().usingResource(document).addComment("This is a new comment"); usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); } @@ -56,7 +47,7 @@ public class UpdateCommentsSanityTests extends RestTest { restClient.authenticateUser(adminUserModel); String updatedContent = "This is the updated comment with admin user"; - restClient.usingResource(document).updateComment(commentModel, updatedContent) + restClient.onCoreAPI().usingResource(document).updateComment(commentModel, updatedContent) .assertThat().field("content").isNotEmpty() .and().field("content").is(updatedContent); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -67,7 +58,7 @@ public class UpdateCommentsSanityTests extends RestTest public void managerIsAbleToUpdateComment() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.usingResource(document).updateComment(commentModel, "This is the updated comment with Manager user") + restClient.onCoreAPI().usingResource(document).updateComment(commentModel, "This is the updated comment with Manager user") .and().field("content").is("This is the updated comment with Manager user") .and().field("canEdit").is(true) .and().field("canDelete").is(true); @@ -80,7 +71,7 @@ public class UpdateCommentsSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); String updatedContent = "This is the updated comment with Contributor user"; - restClient.usingResource(document).updateComment(commentModel, updatedContent); + restClient.onCoreAPI().usingResource(document).updateComment(commentModel, updatedContent); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @@ -90,7 +81,7 @@ public class UpdateCommentsSanityTests extends RestTest public void consumerIsNotAbleToUpdateComment() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.usingResource(document).updateComment(commentModel, "This is the updated comment with Consumer user"); + restClient.onCoreAPI().usingResource(document).updateComment(commentModel, "This is the updated comment with Consumer user"); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @@ -101,9 +92,8 @@ public class UpdateCommentsSanityTests extends RestTest public void collaboratorIsNotAbleToUpdateComment() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.usingResource(document).updateComment(commentModel, "This is the updated comment with Collaborator user"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + restClient.onCoreAPI().usingResource(document).updateComment(commentModel, "This is the updated comment with Collaborator user"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, @@ -113,7 +103,7 @@ public class UpdateCommentsSanityTests extends RestTest { UserModel incorrectUserModel = new UserModel("userName", "password"); restClient.authenticateUser(incorrectUserModel) - .usingResource(document).getNodeComments(); + .onCoreAPI().usingResource(document).getNodeComments(); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } @@ -124,7 +114,7 @@ public class UpdateCommentsSanityTests extends RestTest FolderModel content = FolderModel.getRandomFolderModel(); content.setNodeRef("node ref that does not exist"); - restClient.usingResource(content).updateComment(commentModel, "This is the updated comment."); + restClient.onCoreAPI().usingResource(content).updateComment(commentModel, "This is the updated comment."); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) .assertLastError().containsSummary("node ref that does not exist was not found"); } @@ -137,7 +127,7 @@ public class UpdateCommentsSanityTests extends RestTest RestCommentModel comment = new RestCommentModel(); String id = "comment id that does not exist"; comment.setId(id); - restClient.usingResource(document).updateComment(comment, "This is the updated comment."); + restClient.onCoreAPI().usingResource(document).updateComment(comment, "This is the updated comment."); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, id)); } diff --git a/e2e-test/java/org/alfresco/rest/demo/RestDemoTests.java b/e2e-test/java/org/alfresco/rest/demo/RestDemoTests.java index 9c53bb227..fe280d644 100644 --- a/e2e-test/java/org/alfresco/rest/demo/RestDemoTests.java +++ b/e2e-test/java/org/alfresco/rest/demo/RestDemoTests.java @@ -41,10 +41,10 @@ public class RestDemoTests extends RestTest @Test public void adminRetrievesCorrectSiteDetails() throws JsonToModelConversionException, Exception { - restClient.getSites().assertThat() + restClient.onCoreAPI().getSites().assertThat() .entriesListContains("id", siteModel.getId()); - restClient.usingSite(siteModel).getSite() + restClient.onCoreAPI().usingSite(siteModel).getSite() .assertThat().field("id").isNotNull() .assertThat().field("description").is(siteModel.getDescription()) .assertThat().field("title").is(siteModel.getTitle()) @@ -65,8 +65,8 @@ public class RestDemoTests extends RestTest .usingResource(FolderModel.getSharedFolderModel()) .createContent(DocumentType.TEXT_PLAIN); // add new comment - restClient.usingResource(fileModel).addComment("This is a new comment"); - restClient.usingResource(fileModel).getNodeComments() + restClient.onCoreAPI().usingResource(fileModel).addComment("This is a new comment"); + restClient.onCoreAPI().usingResource(fileModel).getNodeComments() .assertThat().entriesListIsNotEmpty().and() .entriesListContains("content", "This is a new comment"); } @@ -87,20 +87,20 @@ public class RestDemoTests extends RestTest testUser.setUserRole(UserRole.SiteConsumer); // add user as Consumer to site - restClient.usingSite(siteModel).addPerson(testUser); - restClient.usingSite(siteModel).getSiteMembers().assertThat().entriesListContains("id", testUser.getUsername()) + restClient.onCoreAPI().usingSite(siteModel).addPerson(testUser); + restClient.onCoreAPI().usingSite(siteModel).getSiteMembers().assertThat().entriesListContains("id", testUser.getUsername()) .when().getSiteMember(testUser.getUsername()) .assertSiteMemberHasRole(Role.SiteConsumer); // update site member to Manager testUser.setUserRole(UserRole.SiteCollaborator); - restClient.usingSite(siteModel).updateSiteMember(testUser); - restClient.usingSite(siteModel).getSiteMembers().and() + restClient.onCoreAPI().usingSite(siteModel).updateSiteMember(testUser); + restClient.onCoreAPI().usingSite(siteModel).getSiteMembers().and() .entriesListContains("id", testUser.getUsername()) .when().getSiteMember(testUser.getUsername()) .assertSiteMemberHasRole(Role.SiteCollaborator); - restClient.usingSite(siteModel).deleteSiteMember(testUser); + restClient.onCoreAPI().usingSite(siteModel).deleteSiteMember(testUser); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/demo/SampleCommentsTests.java b/e2e-test/java/org/alfresco/rest/demo/SampleCommentsTests.java index dd82faea0..5277aa2a3 100644 --- a/e2e-test/java/org/alfresco/rest/demo/SampleCommentsTests.java +++ b/e2e-test/java/org/alfresco/rest/demo/SampleCommentsTests.java @@ -36,7 +36,7 @@ public class SampleCommentsTests extends RestTest description= "Verify admin user adds comments with Rest API and status code is 200") public void admiShouldAddComment() throws JsonToModelConversionException, Exception { - restClient.usingResource(document).addComment("This is a new comment"); + restClient.onCoreAPI().usingResource(document).addComment("This is a new comment"); restClient.assertStatusCodeIs(HttpStatus.CREATED); } @@ -44,7 +44,7 @@ public class SampleCommentsTests extends RestTest description= "Verify admin user gets comments with Rest API and status code is 200") public void admiShouldRetrieveComments() throws Exception { - restClient.usingResource(document).getNodeComments(); + restClient.onCoreAPI().usingResource(document).getNodeComments(); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -52,9 +52,9 @@ public class SampleCommentsTests extends RestTest description= "Verify admin user updates comments with Rest API") public void adminShouldUpdateComment() throws JsonToModelConversionException, Exception { - RestCommentModel commentModel = restClient.usingResource(document).addComment("This is a new comment"); + RestCommentModel commentModel = restClient.onCoreAPI().usingResource(document).addComment("This is a new comment"); - restClient.usingResource(document).updateComment(commentModel, "This is the updated comment with Collaborator user") + restClient.onCoreAPI().usingResource(document).updateComment(commentModel, "This is the updated comment with Collaborator user") .assertThat().field("content").is("This is the updated comment with Collaborator user"); } diff --git a/e2e-test/java/org/alfresco/rest/demo/SamplePeopleTests.java b/e2e-test/java/org/alfresco/rest/demo/SamplePeopleTests.java index e5c302378..d61773e8b 100644 --- a/e2e-test/java/org/alfresco/rest/demo/SamplePeopleTests.java +++ b/e2e-test/java/org/alfresco/rest/demo/SamplePeopleTests.java @@ -28,7 +28,7 @@ public class SamplePeopleTests extends RestTest description = "Verify admin user gets person with Rest API and response is not empty") public void adminShouldRetrievePerson() throws Exception { - restClient.usingUser(userModel).getPerson().assertThat().field("id").isNotEmpty(); + restClient.onCoreAPI().usingUser(userModel).getPerson().assertThat().field("id").isNotEmpty(); restClient.assertStatusCodeIs(HttpStatus.OK); } diff --git a/e2e-test/java/org/alfresco/rest/demo/SampleSitesTests.java b/e2e-test/java/org/alfresco/rest/demo/SampleSitesTests.java index 0c6c3cf47..b363c0046 100644 --- a/e2e-test/java/org/alfresco/rest/demo/SampleSitesTests.java +++ b/e2e-test/java/org/alfresco/rest/demo/SampleSitesTests.java @@ -30,7 +30,7 @@ public class SampleSitesTests extends RestTest description = "Verify admin user gets site details with Rest API and response is not empty") public void adminShouldGetSiteDetails() throws JsonToModelConversionException, Exception { - restClient.usingSite(siteModel).getSite() + restClient.onCoreAPI().usingSite(siteModel).getSite() .assertThat().field("id").isNotNull(); } @@ -38,7 +38,7 @@ public class SampleSitesTests extends RestTest description = "Verify admin user gets site information and gets status code OK (200)") public void adminShouldGetSites() throws JsonToModelConversionException, Exception { - restClient.usingSite(siteModel).getSite(); + restClient.onCoreAPI().usingSite(siteModel).getSite(); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -46,7 +46,7 @@ public class SampleSitesTests extends RestTest description = "Verify admin user gets sites with Rest API and the response is not empty") public void adminShouldAccessSites() throws JsonToModelConversionException, Exception { - restClient.getSites().assertThat().entriesListIsNotEmpty(); + restClient.onCoreAPI().getSites().assertThat().entriesListIsNotEmpty(); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -54,7 +54,7 @@ public class SampleSitesTests extends RestTest description = "Verify admin user gets sites with Rest API and status code is 200") public void adminShouldAccessResponsePagination() throws JsonToModelConversionException, Exception { - restClient.getSites().assertThat().paginationExist(); + restClient.onCoreAPI().getSites().assertThat().paginationExist(); } @TestRail(section={"demo", "sample-section"}, executionType= ExecutionType.SANITY, @@ -63,7 +63,7 @@ public class SampleSitesTests extends RestTest { UserModel testUser = dataUser.createRandomTestUser("testUser"); testUser.setUserRole(UserRole.SiteConsumer); - restClient.usingSite(siteModel).addPerson(testUser); + restClient.onCoreAPI().usingSite(siteModel).addPerson(testUser); restClient.assertStatusCodeIs(HttpStatus.CREATED); } @@ -71,14 +71,14 @@ public class SampleSitesTests extends RestTest description = "Verify that site exists from get all sites request") public void adminShouldGetSiteFromSitesList() throws JsonToModelConversionException, Exception { - restClient.getSites().assertThat().entriesListContains("id", siteModel.getId()); + restClient.onCoreAPI().getSites().assertThat().entriesListContains("id", siteModel.getId()); } @TestRail(section={"demo", "sample-section"}, executionType= ExecutionType.SANITY, description = "Verify site details: response not empty, description, title, visibility") public void adminShouldAccessSiteDetails() throws JsonToModelConversionException, Exception { - restClient.usingSite(siteModel).getSite() + restClient.onCoreAPI().usingSite(siteModel).getSite() .assertThat().field("id").isNotNull() .and().field("description").is(siteModel.getDescription()) .and().field("title").is(siteModel.getTitle()) diff --git a/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesSanityTests.java index beb549f2b..d1c84348b 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesSanityTests.java @@ -31,72 +31,78 @@ public class AddFavoritesSanityTests extends RestTest { adminUserModel = dataUser.getAdminUser(); siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - siteModel.setGuid(restClient.authenticateUser(adminUserModel).usingSite(siteModel).getSite().getGuid()); + siteModel.setGuid(restClient.authenticateUser(adminUserModel).onCoreAPI().usingSite(siteModel).getSite().getGuid()); usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Admin user add site to favorites with Rest API and status code is 201") + @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, + executionType = ExecutionType.SANITY, + description = "Verify Admin user add site to favorites with Rest API and status code is 201") public void adminIsAbleToAddToFavorites() throws Exception { - restClient.usingAuthUser() + restClient.onCoreAPI().usingAuthUser() .addSiteToFavorites(siteModel) .assertThat().field("targetGuid").is(siteModel.getGuid()); restClient.assertStatusCodeIs(HttpStatus.CREATED); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Manager user add site to favorites with Rest API and status code is 201") + @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, + executionType = ExecutionType.SANITY, + description = "Verify Manager user add site to favorites with Rest API and status code is 201") public void managerIsAbleToAddToFavorites() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .usingAuthUser() + .onCoreAPI().usingAuthUser() .addSiteToFavorites(siteModel) .assertThat().field("targetGuid").is(siteModel.getGuid()); restClient.assertStatusCodeIs(HttpStatus.CREATED); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user add site to favorites with Rest API and status code is 201") + @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, + executionType = ExecutionType.SANITY, + description = "Verify Collaborator user add site to favorites with Rest API and status code is 201") public void collaboratorIsAbleToAddToFavorites() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .usingAuthUser() + .onCoreAPI().usingAuthUser() .addSiteToFavorites(siteModel).and().field("targetGuid").is(siteModel.getGuid()); restClient.assertStatusCodeIs(HttpStatus.CREATED); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Contributor user add site to favorites with Rest API and status code is 201") + @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, + executionType = ExecutionType.SANITY, + description = "Verify Contributor user add site to favorites with Rest API and status code is 201") public void contributorIsAbleToAddToFavorites() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) - .usingAuthUser() + .onCoreAPI().usingAuthUser() .addSiteToFavorites(siteModel).and().field("targetGuid").is(siteModel.getGuid()); restClient.assertStatusCodeIs(HttpStatus.CREATED); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Consumer user add site to favorites with Rest API and status code is 201") + @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, + executionType = ExecutionType.SANITY, + description = "Verify Consumer user add site to favorites with Rest API and status code is 201") public void consumerIsAbleToAddToFavorites() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .usingAuthUser() + .onCoreAPI().usingAuthUser() .addSiteToFavorites(siteModel).and().field("targetGuid").is(siteModel.getGuid()); restClient.assertStatusCodeIs(HttpStatus.CREATED); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Manager user gets status code 401 if authentication call fails") + @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, + executionType = ExecutionType.SANITY, + description = "Verify Manager user gets status code 401 if authentication call fails") @Bug(id="MNT-16904") public void managerIsNotAbleToAddToFavoritesIfAuthenticationFails() throws Exception { UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); siteManager.setPassword("wrongPassword"); restClient.authenticateUser(siteManager) - .usingAuthUser() + .onCoreAPI().usingAuthUser() .addSiteToFavorites(siteModel); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } diff --git a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoritesSanityTests.java index 08fe85a38..b551c5e31 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoritesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoritesSanityTests.java @@ -28,7 +28,7 @@ public class DeleteFavoritesSanityTests extends RestTest adminUserModel = dataUser.getAdminUser(); siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - siteModel.setGuid(restClient.authenticateUser(adminUserModel).usingSite(siteModel).getSite().getGuid()); + siteModel.setGuid(restClient.authenticateUser(adminUserModel).onCoreAPI().usingSite(siteModel).getSite().getGuid()); usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); @@ -38,12 +38,12 @@ public class DeleteFavoritesSanityTests extends RestTest TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Admin user deletes site from favorites with Rest API and status code is 204") public void adminIsAbleToDeleteFavorites() throws JsonToModelConversionException, Exception { - restClient.usingUser(adminUserModel) + restClient.onCoreAPI().usingUser(adminUserModel) .addSiteToFavorites(siteModel).assertThat().field("targetGuid").is(siteModel.getGuid()); - restClient.usingAuthUser().deleteSiteFromFavorites(siteModel) + restClient.onCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel) .assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.usingAuthUser().getFavorites().assertThat().entriesListDoesNotContain("targetGuid", siteModel.getGuid()); + restClient.onCoreAPI().usingAuthUser().getFavorites().assertThat().entriesListDoesNotContain("targetGuid", siteModel.getGuid()); } @TestRail(section = { TestGroup.REST_API, @@ -52,13 +52,14 @@ public class DeleteFavoritesSanityTests extends RestTest { UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); restClient.authenticateUser(siteManager) + .onCoreAPI() .usingAuthUser() .addSiteToFavorites(siteModel).and().field("targetGuid").is(siteModel.getGuid()); - restClient.usingAuthUser() + restClient.onCoreAPI().usingAuthUser() .deleteSiteFromFavorites(siteModel) .assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.usingAuthUser().getFavorites().assertThat().entriesListDoesNotContain("targetGuid", siteModel.getGuid()); + restClient.onCoreAPI().usingAuthUser().getFavorites().assertThat().entriesListDoesNotContain("targetGuid", siteModel.getGuid()); } @TestRail(section = { TestGroup.REST_API, @@ -67,12 +68,13 @@ public class DeleteFavoritesSanityTests extends RestTest { UserModel siteCollaborator = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); restClient.authenticateUser(siteCollaborator) + .onCoreAPI() .usingAuthUser() .addSiteToFavorites(siteModel).and().field("targetGuid").is(siteModel.getGuid()); - restClient.usingAuthUser().deleteSiteFromFavorites(siteModel) + restClient.onCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel) .assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.usingAuthUser().getFavorites().assertThat().entriesListDoesNotContain("targetGuid", siteModel.getGuid()); + restClient.onCoreAPI().usingAuthUser().getFavorites().assertThat().entriesListDoesNotContain("targetGuid", siteModel.getGuid()); } @TestRail(section = { TestGroup.REST_API, @@ -80,13 +82,14 @@ public class DeleteFavoritesSanityTests extends RestTest public void contributorIsAbleToDeleteFavorites() throws JsonToModelConversionException, Exception { UserModel siteContributor = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); - restClient.authenticateUser(siteContributor) + restClient.authenticateUser(siteContributor) + .onCoreAPI() .usingAuthUser() .addSiteToFavorites(siteModel).and().field("targetGuid").is(siteModel.getGuid()); - restClient.usingAuthUser().deleteSiteFromFavorites(siteModel) + restClient.onCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel) .assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.usingAuthUser().getFavorites().assertThat().entriesListDoesNotContain("targetGuid", siteModel.getGuid()); + restClient.onCoreAPI().usingAuthUser().getFavorites().assertThat().entriesListDoesNotContain("targetGuid", siteModel.getGuid()); } @TestRail(section = { TestGroup.REST_API, @@ -95,11 +98,12 @@ public class DeleteFavoritesSanityTests extends RestTest { UserModel siteConsumer = usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer); restClient.authenticateUser(siteConsumer) + .onCoreAPI() .usingAuthUser() .addSiteToFavorites(siteModel).and().field("targetGuid").is(siteModel.getGuid()); - restClient.usingAuthUser().deleteSiteFromFavorites(siteModel).assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.onCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel).assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.usingAuthUser().getFavorites().assertThat().entriesListDoesNotContain("targetGuid", siteModel.getGuid()); + restClient.onCoreAPI().usingAuthUser().getFavorites().assertThat().entriesListDoesNotContain("targetGuid", siteModel.getGuid()); } @TestRail(section = { TestGroup.REST_API, @@ -109,9 +113,11 @@ public class DeleteFavoritesSanityTests extends RestTest { UserModel siteCollaborator = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); restClient.authenticateUser(siteCollaborator) + .onCoreAPI() .usingAuthUser() .addSiteToFavorites(siteModel).and().field("targetGuid").is(siteModel.getGuid()); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + .onCoreAPI() .usingAuthUser() .deleteSiteFromFavorites(siteModel) .assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); @@ -122,11 +128,13 @@ public class DeleteFavoritesSanityTests extends RestTest public void userIsNotAbleToDeleteFavoritesOfAdminUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel) + .onCoreAPI() .usingAuthUser() .addSiteToFavorites(siteModel) .and().field("targetGuid").is(siteModel.getGuid()); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + .onCoreAPI() .usingAuthUser() .deleteSiteFromFavorites(siteModel) .assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); @@ -137,10 +145,12 @@ public class DeleteFavoritesSanityTests extends RestTest public void adminIsNotAbleToDeleteFavoritesOfAnotherUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .onCoreAPI() .usingAuthUser() .addSiteToFavorites(siteModel).and().field("targetGuid").is(siteModel.getGuid()); restClient.authenticateUser(adminUserModel) + .onCoreAPI() .usingAuthUser() .deleteSiteFromFavorites(siteModel) .assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); @@ -153,6 +163,7 @@ public class DeleteFavoritesSanityTests extends RestTest UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); siteManager.setPassword("wrongPassword"); restClient.authenticateUser(siteManager) + .onCoreAPI() .usingAuthUser() .deleteSiteFromFavorites(siteModel) .assertStatusCodeIs(HttpStatus.UNAUTHORIZED); diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java index 7c925499d..04c6cfe9b 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java @@ -37,7 +37,7 @@ public class GetFavoriteSanityTests extends RestTest folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); fileModel = dataContent.usingUser(adminUserModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - siteModel.setGuid(restClient.authenticateUser(adminUserModel).usingSite(siteModel).getSite().getGuid()); + siteModel.setGuid(restClient.authenticateUser(adminUserModel).onCoreAPI().usingSite(siteModel).getSite().getGuid()); usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); @@ -47,8 +47,8 @@ public class GetFavoriteSanityTests extends RestTest TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets favorite site with Rest API and status code is 200") public void adminIsAbleToRetrieveFavoritesSite() throws JsonToModelConversionException, Exception { - restClient.usingUser(adminUserModel).addSiteToFavorites(siteModel).and().field("targetGuid").is(siteModel.getGuid()); - restClient.usingUser(adminUserModel).getFavoriteSites().and().entriesListContains("guid",siteModel.getGuid()); + restClient.onCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel).and().field("targetGuid").is(siteModel.getGuid()); + restClient.onCoreAPI().usingUser(adminUserModel).getFavoriteSites().and().entriesListContains("guid",siteModel.getGuid()); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -56,8 +56,8 @@ public class GetFavoriteSanityTests extends RestTest TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets favorite folder with Rest API and status code is 200") public void adminIsAbleToRetrieveFavoritesFolder() throws JsonToModelConversionException, Exception { - restClient.usingUser(adminUserModel).addFolderToFavorites(folderModel).and().field("targetGuid").is(folderModel.getNodeRef()); - restClient.usingUser(adminUserModel).getFavorites().and().entriesListContains("targetGuid", folderModel.getNodeRef()); + restClient.onCoreAPI().usingUser(adminUserModel).addFolderToFavorites(folderModel).and().field("targetGuid").is(folderModel.getNodeRef()); + restClient.onCoreAPI().usingUser(adminUserModel).getFavorites().and().entriesListContains("targetGuid", folderModel.getNodeRef()); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -65,8 +65,8 @@ public class GetFavoriteSanityTests extends RestTest TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets favorite file with Rest API and status code is 200") public void adminIsAbleToRetrieveFavoritesFile() throws JsonToModelConversionException, Exception { - restClient.usingUser(adminUserModel).addFileToFavorites(fileModel); - restClient.usingUser(adminUserModel).getFavorites().and().entriesListContains("targetGuid", fileModel.getNodeRef()); + restClient.onCoreAPI().usingUser(adminUserModel).addFileToFavorites(fileModel); + restClient.onCoreAPI().usingUser(adminUserModel).getFavorites().and().entriesListContains("targetGuid", fileModel.getNodeRef()); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -75,8 +75,8 @@ public class GetFavoriteSanityTests extends RestTest public void managerIsAbleToRetrieveFavorite() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.usingAuthUser().addSiteToFavorites(siteModel); - restClient.usingAuthUser().getFavoriteSites().and().entriesListContains("guid",siteModel.getGuid()); + restClient.onCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + restClient.onCoreAPI().usingAuthUser().getFavoriteSites().and().entriesListContains("guid",siteModel.getGuid()); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -84,9 +84,10 @@ public class GetFavoriteSanityTests extends RestTest TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user gets favorite site with Rest API and status code is 200") public void collaboratorIsAbleToRetrieveFavorites() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.usingAuthUser().addSiteToFavorites(siteModel); - restClient.usingAuthUser().getFavoriteSites().and().entriesListContains("guid",siteModel.getGuid()); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .onCoreAPI() + .usingAuthUser().addSiteToFavorites(siteModel); + restClient.onCoreAPI().usingAuthUser().getFavoriteSites().and().entriesListContains("guid",siteModel.getGuid()); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -95,8 +96,8 @@ public class GetFavoriteSanityTests extends RestTest public void contributorIsAbleToRetrieveFavorite() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - restClient.usingAuthUser().addSiteToFavorites(siteModel); - restClient.usingAuthUser().getFavoriteSites().and().entriesListContains("guid",siteModel.getGuid()); + restClient.onCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + restClient.onCoreAPI().usingAuthUser().getFavoriteSites().and().entriesListContains("guid",siteModel.getGuid()); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -105,8 +106,8 @@ public class GetFavoriteSanityTests extends RestTest public void consumerIsAbleToRetrieveFavorites() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.usingAuthUser().addSiteToFavorites(siteModel); - restClient.usingAuthUser().getFavoriteSites().and().entriesListContains("guid",siteModel.getGuid()); + restClient.onCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + restClient.onCoreAPI().usingAuthUser().getFavoriteSites().and().entriesListContains("guid",siteModel.getGuid()); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -115,7 +116,7 @@ public class GetFavoriteSanityTests extends RestTest public void userIsNotAbleToRetrieveFavoriteSiteOfAnotherUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + restClient.onCoreAPI().usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) .getFavorite(siteModel.getGuid()); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) @@ -127,6 +128,7 @@ public class GetFavoriteSanityTests extends RestTest public void userIsNotAbleToRetrieveFavoritesOfAdminUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + .onCoreAPI() .usingUser(adminUserModel) .getFavorite(siteModel.getGuid()); @@ -139,6 +141,7 @@ public class GetFavoriteSanityTests extends RestTest public void adminIsNotAbleToRetrieveFavoritesOfAnotherUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel) + .onCoreAPI() .usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) .getFavorite(siteModel.getGuid()); @@ -154,6 +157,7 @@ public class GetFavoriteSanityTests extends RestTest UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); siteManager.setPassword("wrongPassword"); restClient.authenticateUser(siteManager) + .onCoreAPI() .usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) .getFavorite(siteModel.getGuid()); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java index cf4c0cd02..40b710cf5 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java @@ -43,8 +43,8 @@ public class GetFavoritesSanityTests extends RestTest secondFileModel = dataContent.usingUser(adminUserModel).usingResource(firstFolderModel).createContent(DocumentType.TEXT_PLAIN); - firstSiteModel.setGuid(restClient.authenticateUser(adminUserModel).usingSite(firstSiteModel).getSite().getGuid()); - secondSiteModel.setGuid(restClient.authenticateUser(adminUserModel).usingSite(secondSiteModel).getSite().getGuid()); + firstSiteModel.setGuid(restClient.authenticateUser(adminUserModel).onCoreAPI().usingSite(firstSiteModel).getSite().getGuidWithoutVersion()); + secondSiteModel.setGuid(restClient.authenticateUser(adminUserModel).onCoreAPI().usingSite(secondSiteModel).getSite().getGuidWithoutVersion()); usersWithRoles = dataUser.addUsersWithRolesToSite(firstSiteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); @@ -54,11 +54,12 @@ public class GetFavoritesSanityTests extends RestTest TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets favorites sites with Rest API and status code is 200") public void adminIsAbleToRetrieveFavoritesSites() throws JsonToModelConversionException, Exception { - restClient.usingUser(adminUserModel).addSiteToFavorites(firstSiteModel); - restClient.usingUser(adminUserModel).addSiteToFavorites(secondSiteModel); - restClient.usingAuthUser().where().targetSiteExist().getFavorites() - .assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) - .and().entriesListContains("targetGuid", secondSiteModel.getGuid()); + restClient.onCoreAPI().usingUser(adminUserModel).addSiteToFavorites(firstSiteModel); + restClient.onCoreAPI().usingUser(adminUserModel).addSiteToFavorites(secondSiteModel); + restClient.onCoreAPI() + .usingAuthUser().where().targetSiteExist().getFavorites() + .assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) + .and().entriesListContains("targetGuid", secondSiteModel.getGuid()); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -66,11 +67,12 @@ public class GetFavoritesSanityTests extends RestTest TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets favorites folders with Rest API and status code is 200") public void adminIsAbleToRetrieveFavoritesFolders() throws JsonToModelConversionException, Exception { - restClient.usingUser(adminUserModel).addFolderToFavorites(firstFolderModel); - restClient.usingUser(adminUserModel).addFolderToFavorites(secondFolderModel); - restClient.usingAuthUser().where().targetFolderExist().getFavorites() - .assertThat().entriesListContains("targetGuid", firstFolderModel.getNodeRef()) - .and().entriesListContains("targetGuid", secondFolderModel.getNodeRef()); + restClient.onCoreAPI().usingUser(adminUserModel).addFolderToFavorites(firstFolderModel); + restClient.onCoreAPI().usingUser(adminUserModel).addFolderToFavorites(secondFolderModel); + restClient.onCoreAPI() + .usingAuthUser().where().targetFolderExist().getFavorites() + .assertThat().entriesListContains("targetGuid", firstFolderModel.getNodeRef()) + .and().entriesListContains("targetGuid", secondFolderModel.getNodeRef()); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -78,11 +80,12 @@ public class GetFavoritesSanityTests extends RestTest TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets favorites files with Rest API and status code is 200") public void adminIsAbleToRetrieveFavoritesFiles() throws JsonToModelConversionException, Exception { - restClient.usingUser(adminUserModel).addFileToFavorites(firstFileModel); - restClient.usingUser(adminUserModel).addFileToFavorites(secondFileModel); - restClient.usingAuthUser().where().targetFileExist().getFavorites() - .assertThat().entriesListContains("targetGuid", firstFileModel.getNodeRef()) - .and().entriesListContains("targetGuid", secondFileModel.getNodeRef()); + restClient.onCoreAPI().usingUser(adminUserModel).addFileToFavorites(firstFileModel); + restClient.onCoreAPI().usingUser(adminUserModel).addFileToFavorites(secondFileModel); + restClient.onCoreAPI() + .usingAuthUser().where().targetFileExist().getFavorites() + .assertThat().entriesListContains("targetGuid", firstFileModel.getNodeRefWithoutVersion()) + .and().entriesListContains("targetGuid", secondFileModel.getNodeRefWithoutVersion()); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -91,11 +94,13 @@ public class GetFavoritesSanityTests extends RestTest public void managerIsAbleToRetrieveFavorites() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.usingAuthUser().addSiteToFavorites(firstSiteModel); - restClient.usingAuthUser().addSiteToFavorites(secondSiteModel); - restClient.usingAuthUser().where().targetSiteExist().getFavorites() - .assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) - .assertThat().entriesListContains("targetGuid", secondSiteModel.getGuid()); + restClient.onCoreAPI() + .usingAuthUser().addSiteToFavorites(firstSiteModel); + restClient.onCoreAPI().usingAuthUser().addSiteToFavorites(secondSiteModel); + restClient.onCoreAPI() + .usingAuthUser().where().targetSiteExist().getFavorites() + .assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) + .assertThat().entriesListContains("targetGuid", secondSiteModel.getGuid()); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -104,11 +109,14 @@ public class GetFavoritesSanityTests extends RestTest public void collaboratorIsAbleToRetrieveFavorites() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .onCoreAPI() .usingAuthUser().addSiteToFavorites(firstSiteModel); - restClient.usingAuthUser().addSiteToFavorites(secondSiteModel); - restClient.usingAuthUser().where().targetSiteExist().getFavorites() - .assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) - .and().entriesListContains("targetGuid", secondSiteModel.getGuid()); + restClient.onCoreAPI() + .usingAuthUser().addSiteToFavorites(secondSiteModel); + restClient.onCoreAPI() + .usingAuthUser().where().targetSiteExist().getFavorites() + .assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) + .and().entriesListContains("targetGuid", secondSiteModel.getGuid()); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -117,11 +125,13 @@ public class GetFavoritesSanityTests extends RestTest public void contributorIsAbleToRetrieveFavorites() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) + .onCoreAPI() .usingAuthUser().addSiteToFavorites(firstSiteModel); - restClient.usingAuthUser().addSiteToFavorites(secondSiteModel); - restClient.usingAuthUser().where().targetSiteExist().getFavorites() - .assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()).and() - .entriesListContains("targetGuid", secondSiteModel.getGuid()); + restClient.onCoreAPI().usingAuthUser().addSiteToFavorites(secondSiteModel); + restClient.onCoreAPI() + .usingAuthUser().where().targetSiteExist().getFavorites() + .assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()).and() + .entriesListContains("targetGuid", secondSiteModel.getGuid()); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -130,11 +140,13 @@ public class GetFavoritesSanityTests extends RestTest public void consumerIsAbleToRetrieveFavorites() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + .onCoreAPI() .usingAuthUser().addSiteToFavorites(firstSiteModel); - restClient.usingAuthUser().addSiteToFavorites(secondSiteModel); - restClient.usingAuthUser().where().targetSiteExist().getFavorites() - .assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) - .assertThat().entriesListContains("targetGuid", secondSiteModel.getGuid()); + restClient.onCoreAPI().usingAuthUser().addSiteToFavorites(secondSiteModel); + restClient.onCoreAPI() + .usingAuthUser().where().targetSiteExist().getFavorites() + .assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) + .assertThat().entriesListContains("targetGuid", secondSiteModel.getGuid()); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -143,6 +155,7 @@ public class GetFavoritesSanityTests extends RestTest public void userIsNotAbleToRetrieveFavoritesOfAnotherUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + .onCoreAPI() .usingAuthUser().where().targetSiteExist().getFavorites(); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator).getUsername())); @@ -153,9 +166,10 @@ public class GetFavoritesSanityTests extends RestTest public void userIsNotAbleToRetrieveFavoritesOfAdminUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + .onCoreAPI() .usingAuthUser().where().targetSiteExist().getFavorites(); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, adminUserModel.getUsername())); + .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, adminUserModel.getUsername())); } @TestRail(section = { TestGroup.REST_API, @@ -163,9 +177,10 @@ public class GetFavoritesSanityTests extends RestTest public void adminIsNotAbleToRetrieveFavoritesOfAnotherUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel) + .onCoreAPI() .usingAuthUser().where().targetSiteExist().getFavorites(); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator).getUsername())); + .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator).getUsername())); } @TestRail(section = { TestGroup.REST_API, @@ -176,8 +191,9 @@ public class GetFavoritesSanityTests extends RestTest UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); siteManager.setPassword("wrongPassword"); restClient.authenticateUser(siteManager) + .onCoreAPI() .usingAuthUser().addSiteToFavorites(firstSiteModel); - restClient.usingAuthUser().addSiteToFavorites(secondSiteModel); + restClient.onCoreAPI().usingAuthUser().addSiteToFavorites(secondSiteModel); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java index c160a6c2d..9d2abf403 100644 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java @@ -10,7 +10,6 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) public class RestGetNetworkForPersonSanityTests extends RestTest { private UserModel adminUserModel; @@ -29,47 +28,51 @@ public class RestGetNetworkForPersonSanityTests extends RestTest @Bug(id = "MNT-16904") @Test(groups = TestGroup.COMMENTS) - @TestRail(section = { TestGroup.REST_API, - TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify non existing user gets another exisiting network with Rest API and checks the forbidden status") + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, + executionType = ExecutionType.SANITY, + description = "Verify non existing user gets another exisiting network with Rest API and checks the forbidden status") public void nonExistingTenantUserIsNotAuthorizedToRequest() throws Exception { UserModel tenantUser = new UserModel("nonexisting", "password"); tenantUser.setDomain(adminTenantUser.getDomain()); restClient.authenticateUser(tenantUser); - restClient.usingUser(tenantUser).getNetwork(adminTenantUser); + restClient.onCoreAPI().usingUser(tenantUser).getNetwork(adminTenantUser); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } @Test(groups = TestGroup.COMMENTS) - @TestRail(section = { TestGroup.REST_API, - TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify tenant admin user gets specific network with Rest API and response is not empty") + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, + executionType = ExecutionType.SANITY, + description = "Verify tenant admin user gets specific network with Rest API and response is not empty") public void adminTenantChecksIfNetworkIsPresent() throws Exception { restClient.authenticateUser(adminTenantUser); - restClient.usingUser(adminTenantUser).getNetwork(); + restClient.onCoreAPI().usingUser(adminTenantUser).getNetwork(); restClient.assertStatusCodeIs(HttpStatus.OK); } @Test(groups = TestGroup.COMMENTS) - @TestRail(section = { TestGroup.REST_API, - TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify tenant user is not authorized to check network of admin user with Rest API and checks the forbidden status") + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, + executionType = ExecutionType.SANITY, + description = "Verify tenant user is not authorized to check network of admin user with Rest API and checks the forbidden status") public void tenantUserIsNotAuthorizedToCheckNetworkOfAdminUser() throws Exception { restClient.authenticateUser(tenantUser); - restClient.usingUser(tenantUser).getNetwork(adminTenantUser); + restClient.onCoreAPI().usingUser(tenantUser).getNetwork(adminTenantUser); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); } @Test(groups = TestGroup.COMMENTS) - @TestRail(section = { TestGroup.REST_API, - TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify admin tenant user is not authorized to check network of another user with Rest API and checks the forbidden status") + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, + executionType = ExecutionType.SANITY, + description = "Verify admin tenant user is not authorized to check network of another user with Rest API and checks the forbidden status") public void adminTenantUserIsNotAuthorizedToCheckNetworkOfAnotherUser() throws Exception { UserModel secondAdminTenantUser = UserModel.getAdminTenantUser(); restClient.usingTenant().createTenant(secondAdminTenantUser); UserModel secondTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("anotherTenant"); restClient.authenticateUser(adminTenantUser); - restClient.usingUser(adminTenantUser).getNetwork(secondTenantUser); + restClient.onCoreAPI().usingUser(adminTenantUser).getNetwork(secondTenantUser); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); } } diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkTest.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkTest.java index 13e299ac6..23ef6c5b9 100644 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkTest.java +++ b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkTest.java @@ -46,7 +46,7 @@ public class RestGetNetworkTest extends RestTest UserModel tenantUser = new UserModel("nonexisting", "password"); tenantUser.setDomain(adminTenantUser.getDomain()); restClient.authenticateUser(tenantUser); - restClient.usingNetworks().getNetwork(adminTenantUser); + restClient.onCoreAPI().usingNetworks().getNetwork(adminTenantUser); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } @@ -56,7 +56,7 @@ public class RestGetNetworkTest extends RestTest public void adminTenantChecksIfNetworkIsPresent() throws Exception { restClient.authenticateUser(adminTenantUser); - restClient.usingNetworks().getNetwork(); + restClient.onCoreAPI().usingNetworks().getNetwork(); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -65,7 +65,7 @@ public class RestGetNetworkTest extends RestTest public void adminTenantChecksNetworkParamsAreCorrect() throws Exception { restClient.authenticateUser(adminTenantUser); - restClient.usingNetworks().getNetwork().assertNetworkHasName(adminTenantUser).assertNetworkIsEnabled(); + restClient.onCoreAPI().usingNetworks().getNetwork().assertNetworkHasName(adminTenantUser).assertNetworkIsEnabled(); } @TestRail(section = { TestGroup.REST_API, @@ -73,7 +73,7 @@ public class RestGetNetworkTest extends RestTest public void adminTenantChecksIfNonExistingNetworkIsNotFound() throws Exception { restClient.authenticateUser(adminTenantUser); - restClient.usingNetworks().getNetwork(UserModel.getRandomTenantUser()); + restClient.onCoreAPI().usingNetworks().getNetwork(UserModel.getRandomTenantUser()); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); } @@ -82,7 +82,7 @@ public class RestGetNetworkTest extends RestTest public void adminTenantChecksIfAnotherExistingNetworkIsForbidden() throws Exception { restClient.authenticateUser(adminTenantUser); - restClient.usingNetworks().getNetwork(adminAnotherTenantUser); + restClient.onCoreAPI().usingNetworks().getNetwork(adminAnotherTenantUser); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); } @@ -90,7 +90,7 @@ public class RestGetNetworkTest extends RestTest public void userTenantChecksIfNetworkIsPresent() throws Exception { restClient.authenticateUser(tenantUser); - restClient.usingNetworks().getNetwork(adminTenantUser); + restClient.onCoreAPI().usingNetworks().getNetwork(adminTenantUser); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -99,7 +99,7 @@ public class RestGetNetworkTest extends RestTest public void userTenantChecksNetworkParamsAreCorrect() throws Exception { restClient.authenticateUser(tenantUser); - restClient.usingNetworks().getNetwork(adminTenantUser).assertNetworkHasName(adminTenantUser).assertNetworkIsEnabled(); + restClient.onCoreAPI().usingNetworks().getNetwork(adminTenantUser).assertNetworkHasName(adminTenantUser).assertNetworkIsEnabled(); } @TestRail(section = { TestGroup.REST_API, @@ -107,7 +107,7 @@ public class RestGetNetworkTest extends RestTest public void userTenantChecksIfNonExistingNetworkIsNotFound() throws Exception { restClient.authenticateUser(tenantUser); - restClient.usingNetworks().getNetwork(UserModel.getRandomTenantUser()); + restClient.onCoreAPI().usingNetworks().getNetwork(UserModel.getRandomTenantUser()); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); } @@ -117,7 +117,7 @@ public class RestGetNetworkTest extends RestTest public void userTenantChecksIfAnotherExistingNetworkIsForbidden() throws Exception { restClient.authenticateUser(tenantUser); - restClient.usingNetworks().getNetwork(adminAnotherTenantUser); + restClient.onCoreAPI().usingNetworks().getNetwork(adminAnotherTenantUser); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); } @@ -130,7 +130,7 @@ public class RestGetNetworkTest extends RestTest dataUser.usingUser(adminTenantUser).addUserToSite(managerTenantUser, site, UserRole.SiteManager); restClient.authenticateUser(managerTenantUser); - restClient.usingNetworks().getNetwork(adminTenantUser); + restClient.onCoreAPI().usingNetworks().getNetwork(adminTenantUser); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -143,7 +143,7 @@ public class RestGetNetworkTest extends RestTest dataUser.usingUser(adminTenantUser).addUserToSite(collaboratorTenantUser, site, UserRole.SiteCollaborator); restClient.authenticateUser(collaboratorTenantUser); - restClient.usingNetworks().getNetwork(adminTenantUser); + restClient.onCoreAPI().usingNetworks().getNetwork(adminTenantUser); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -156,7 +156,7 @@ public class RestGetNetworkTest extends RestTest dataUser.usingUser(adminTenantUser).addUserToSite(consumerTenantUser, site, UserRole.SiteConsumer); restClient.authenticateUser(consumerTenantUser); - restClient.usingNetworks().getNetwork(adminTenantUser); + restClient.onCoreAPI().usingNetworks().getNetwork(adminTenantUser); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -169,7 +169,7 @@ public class RestGetNetworkTest extends RestTest dataUser.usingUser(adminTenantUser).addUserToSite(contributorTenantUser, site, UserRole.SiteContributor); restClient.authenticateUser(contributorTenantUser); - restClient.usingNetworks().getNetwork(adminTenantUser); + restClient.onCoreAPI().usingNetworks().getNetwork(adminTenantUser); restClient.assertStatusCodeIs(HttpStatus.OK); } } diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonSanityTests.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonSanityTests.java index 0c3fad337..539d5d13b 100644 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonSanityTests.java @@ -10,7 +10,7 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) +@Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) public class RestGetNetworksForPersonSanityTests extends RestTest { private UserModel adminUserModel; @@ -29,47 +29,51 @@ public class RestGetNetworksForPersonSanityTests extends RestTest @Bug(id = "MNT-16904") @Test(groups = TestGroup.COMMENTS) - @TestRail(section = { TestGroup.REST_API, - TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify non existing user gets another exisiting network with Rest API and checks the forbidden status") + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, + executionType = ExecutionType.SANITY, + description = "Verify non existing user gets another exisiting network with Rest API and checks the forbidden status") public void nonExistingTenantUserIsNotAuthorizedToRequest() throws Exception { UserModel tenantUser = new UserModel("nonexisting", "password"); tenantUser.setDomain(adminTenantUser.getDomain()); restClient.authenticateUser(tenantUser); - restClient.usingUser(tenantUser).getNetworks(adminTenantUser); + restClient.onCoreAPI().usingUser(tenantUser).getNetworks(adminTenantUser); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } @Test(groups = TestGroup.COMMENTS) - @TestRail(section = { TestGroup.REST_API, - TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify tenant admin user gets specific network with Rest API and response is not empty") + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, + executionType = ExecutionType.SANITY, + description = "Verify tenant admin user gets specific network with Rest API and response is not empty") public void adminTenantChecksIfNetworkIsPresent() throws Exception { restClient.authenticateUser(adminTenantUser); - restClient.usingUser(adminTenantUser).getNetworks(); + restClient.onCoreAPI().usingUser(adminTenantUser).getNetworks(); restClient.assertStatusCodeIs(HttpStatus.OK); } @Test(groups = TestGroup.COMMENTS) - @TestRail(section = { TestGroup.REST_API, - TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify tenant user is not authorized to check network of admin user with Rest API and checks the forbidden status") + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, + executionType = ExecutionType.SANITY, + description = "Verify tenant user is not authorized to check network of admin user with Rest API and checks the forbidden status") public void tenantUserIsNotAuthorizedToCheckNetworkOfAdminUser() throws Exception { restClient.authenticateUser(tenantUser); - restClient.usingUser(tenantUser).getNetworks(adminTenantUser); + restClient.onCoreAPI().usingUser(tenantUser).getNetworks(adminTenantUser); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); } @Test(groups = TestGroup.COMMENTS) - @TestRail(section = { TestGroup.REST_API, - TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify admin tenant user is not authorized to check network of another user with Rest API and checks the forbidden status") + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, + executionType = ExecutionType.SANITY, + description = "Verify admin tenant user is not authorized to check network of another user with Rest API and checks the forbidden status") public void adminTenantUserIsNotAuthorizedToCheckNetworkOfAnotherUser() throws Exception { UserModel secondAdminTenantUser = UserModel.getAdminTenantUser(); restClient.usingTenant().createTenant(secondAdminTenantUser); UserModel secondTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("anotherTenant"); restClient.authenticateUser(secondAdminTenantUser); - restClient.usingUser(secondAdminTenantUser).getNetworks(secondTenantUser); + restClient.onCoreAPI().usingUser(secondAdminTenantUser).getNetworks(secondTenantUser); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); } } diff --git a/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteSanityTests.java index 4a60a1104..6ec92508a 100644 --- a/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteSanityTests.java @@ -33,12 +33,13 @@ public class AddFavoriteSiteSanityTests extends RestTest dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); restClient.authenticateUser(managerUser) + .onCoreAPI() .usingUser(managerUser) .addFavoriteSite(siteModel) .assertThat().field("id").is(siteModel.getId()); restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.usingUser(managerUser).addFavoriteSite(siteModel); + restClient.onCoreAPI().usingUser(managerUser).addFavoriteSite(siteModel); restClient.assertStatusCodeIs(HttpStatus.CONFLICT); restClient.assertLastError().containsSummary(String.format("%s is already a favourite site", siteModel.getId())); } @@ -50,6 +51,7 @@ public class AddFavoriteSiteSanityTests extends RestTest dataUser.usingUser(userModel).addUserToSite(collaboratorUser, siteModel, UserRole.SiteCollaborator); restClient.authenticateUser(collaboratorUser) + .onCoreAPI() .usingAuthUser() .addFavoriteSite(siteModel) .assertThat().field("id").is(siteModel.getId()); @@ -63,6 +65,7 @@ public class AddFavoriteSiteSanityTests extends RestTest dataUser.usingUser(userModel).addUserToSite(contributorUser, siteModel, UserRole.SiteContributor); restClient.authenticateUser(contributorUser) + .onCoreAPI() .usingAuthUser() .addFavoriteSite(siteModel) .assertThat().field("id").is(siteModel.getId()); @@ -76,6 +79,7 @@ public class AddFavoriteSiteSanityTests extends RestTest dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel, UserRole.SiteConsumer); restClient.authenticateUser(consumerUser) + .onCoreAPI() .usingAuthUser() .addFavoriteSite(siteModel) .assertThat().field("id").is(siteModel.getId()); @@ -88,6 +92,7 @@ public class AddFavoriteSiteSanityTests extends RestTest UserModel adminUser = dataUser.getAdminUser(); restClient.authenticateUser(adminUser) + .onCoreAPI() .usingAuthUser() .addFavoriteSite(siteModel) .assertThat().field("id").is(siteModel.getId()); @@ -103,6 +108,7 @@ public class AddFavoriteSiteSanityTests extends RestTest managerUser.setPassword("newpassword"); restClient.authenticateUser(managerUser) + .onCoreAPI() .usingAuthUser() .addFavoriteSite(siteModel); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); diff --git a/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java index f2b71682d..98c29394f 100644 --- a/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java @@ -42,12 +42,13 @@ public class AddSiteMembershipRequestSanityTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, description = "Verify site manager is able to create new site membership request") + executionType = ExecutionType.SANITY, description = "Verify site manager is able to create new site membership request") @Bug(id="MNT-16557") public void siteManagerIsAbleToCreateSiteMembershipRequest() throws JsonToModelConversionException, Exception { UserModel newMember = dataUser.createRandomTestUser(); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .onCoreAPI() .usingUser(newMember).addSiteMembershipRequest(siteModel) .assertThat().field("id").isNotEmpty() .assertThat().field("site").isNotEmpty(); @@ -55,12 +56,14 @@ public class AddSiteMembershipRequestSanityTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, description = "Verify site collaborator is able to create new site membership request") + executionType = ExecutionType.SANITY, + description = "Verify site collaborator is able to create new site membership request") @Bug(id = "MNT-16557") public void siteCollaboatorIsAbleToCreateSiteMembershipRequest() throws JsonToModelConversionException, Exception { UserModel newMember = dataUser.createRandomTestUser(); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .onCoreAPI() .usingUser(newMember).addSiteMembershipRequest(siteModel) .assertThat().field("id").isNotEmpty() .assertThat().field("site").isNotEmpty(); @@ -68,12 +71,14 @@ public class AddSiteMembershipRequestSanityTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, description = "Verify site contributor is able to create new site membership request") + executionType = ExecutionType.SANITY, + description = "Verify site contributor is able to create new site membership request") @Bug(id = "MNT-16557") public void siteContributorIsAbleToCreateSiteMembershipRequest() throws JsonToModelConversionException, Exception { UserModel newMember = dataUser.createRandomTestUser(); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) + .onCoreAPI() .usingUser(newMember).addSiteMembershipRequest(siteModel) .assertThat().field("id").isNotEmpty() .assertThat().field("site").isNotEmpty(); @@ -81,25 +86,29 @@ public class AddSiteMembershipRequestSanityTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, description = "Verify site consumer is able to create new site membership request") + executionType = ExecutionType.SANITY, + description = "Verify site consumer is able to create new site membership request") @Bug(id = "MNT-16557") public void siteConsumerIsAbleToCreateSiteMembershipRequest() throws JsonToModelConversionException, Exception { UserModel newMember = dataUser.createRandomTestUser(); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + .onCoreAPI() .usingUser(newMember).addSiteMembershipRequest(siteModel) .assertThat().field("id").isNotEmpty() .assertThat().field("site").isNotEmpty(); restClient.assertStatusCodeIs(HttpStatus.CREATED); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, - description = "Verify admin user is able to create new site membership request") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.SANITY, + description = "Verify admin user is able to create new site membership request") @Bug(id = "MNT-16557") public void adminUserIsAbleToCreateSiteMembershipRequest() throws JsonToModelConversionException, Exception { UserModel newMember = dataUser.createRandomTestUser(); restClient.authenticateUser(adminUser) + .onCoreAPI() .usingUser(newMember).addSiteMembershipRequest(siteModel) .assertThat().field("id").isNotEmpty() .assertThat().field("site").isNotEmpty(); @@ -107,12 +116,14 @@ public class AddSiteMembershipRequestSanityTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to create new site membership request") + executionType = ExecutionType.SANITY, + description = "Verify unauthenticated user is not able to create new site membership request") @Bug(id = "MNT-16557") public void unauthenticatedUserIsNotAbleToCreateSiteMembershipRequest() throws JsonToModelConversionException, Exception { UserModel newMember = dataUser.createRandomTestUser(); restClient.authenticateUser(new UserModel("random user", "random password")) + .onCoreAPI() .usingUser(newMember).addSiteMembershipRequest(siteModel) .assertThat().field("id").isNotEmpty() .assertThat().field("site").isNotEmpty(); diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java index c0b12ffb7..263cbc7b2 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java @@ -31,7 +31,9 @@ public class DeleteFavoriteSiteSanityTests extends RestTest siteModel2 = dataSite.usingUser(userModel).createPublicRandomSite(); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user removes a site from its favorite sites list with Rest API and response is successful (204)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.SANITY, + description = "Verify manager user removes a site from its favorite sites list with Rest API and response is successful (204)") public void managerUserRemovesFavoriteSiteWithSuccess() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -40,12 +42,15 @@ public class DeleteFavoriteSiteSanityTests extends RestTest dataSite.usingUser(managerUser).usingSite(siteModel2).addSiteToFavorites(); restClient.authenticateUser(managerUser) + .onCoreAPI() .usingAuthUser().removeFavoriteSite(siteModel1); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify collaborator user removes a site from its favorite sites list with Rest API and response is successful (204)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.SANITY, + description = "Verify collaborator user removes a site from its favorite sites list with Rest API and response is successful (204)") public void collaboratorUserRemovesFavoriteSiteWithSuccess() throws Exception { UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); @@ -54,11 +59,14 @@ public class DeleteFavoriteSiteSanityTests extends RestTest dataSite.usingUser(collaboratorUser).usingSite(siteModel2).addSiteToFavorites(); restClient.authenticateUser(collaboratorUser) + .onCoreAPI() .usingAuthUser().removeFavoriteSite(siteModel1); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify contributor user removes a site from its favorite sites list with Rest API and response is successful (204)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.SANITY, + description = "Verify contributor user removes a site from its favorite sites list with Rest API and response is successful (204)") public void contributorUserRemovesFavoriteSiteWithSuccess() throws Exception { UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); @@ -67,11 +75,14 @@ public class DeleteFavoriteSiteSanityTests extends RestTest dataSite.usingUser(contributorUser).usingSite(siteModel2).addSiteToFavorites(); restClient.authenticateUser(contributorUser) + .onCoreAPI() .usingAuthUser().removeFavoriteSite(siteModel1); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify consumer user removes a site from its favorite sites list with Rest API and response is successful (204)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.SANITY, + description = "Verify consumer user removes a site from its favorite sites list with Rest API and response is successful (204)") public void consumerUserRemovesFavoriteSiteWithSuccess() throws Exception { UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -80,11 +91,14 @@ public class DeleteFavoriteSiteSanityTests extends RestTest dataSite.usingUser(consumerUser).usingSite(siteModel2).addSiteToFavorites(); restClient.authenticateUser(consumerUser) + .onCoreAPI() .usingAuthUser().removeFavoriteSite(siteModel1); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify admin user removes a site from any user's favorite sites list with Rest API and response is successful (204)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.SANITY, + description = "Verify admin user removes a site from any user's favorite sites list with Rest API and response is successful (204)") public void adminUserRemovesAnyFavoriteSiteWithSuccess() throws Exception { UserModel adminUser = dataUser.getAdminUser(); @@ -93,11 +107,14 @@ public class DeleteFavoriteSiteSanityTests extends RestTest dataSite.usingUser(anyUser).usingSite(siteModel2).addSiteToFavorites(); restClient.authenticateUser(adminUser) + .onCoreAPI() .usingAuthUser().removeFavoriteSite(siteModel1); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify a user removes a site from another user's favorite sites list with Rest API and response is permission denied (403)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.SANITY, + description = "Verify a user removes a site from another user's favorite sites list with Rest API and response is permission denied (403)") public void userUserRemovesAnotherUserFavoriteSiteWithSuccess() throws Exception { UserModel userAuth = dataUser.usingAdmin().createRandomTestUser(); @@ -106,12 +123,15 @@ public class DeleteFavoriteSiteSanityTests extends RestTest dataSite.usingUser(anotherUser).usingSite(siteModel2).addSiteToFavorites(); restClient.authenticateUser(userAuth) + .onCoreAPI() .usingUser(anotherUser).removeFavoriteSite(siteModel1); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized to remove a site from its favorite sites list with Rest API when authentication fails (401)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.SANITY, + description = "Verify manager user is NOT Authorized to remove a site from its favorite sites list with Rest API when authentication fails (401)") public void managerUserNotAuthorizedFailsToRemoveFavoriteSite() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -121,6 +141,7 @@ public class DeleteFavoriteSiteSanityTests extends RestTest managerUser.setPassword("newpassword"); restClient.authenticateUser(managerUser) + .onCoreAPI() .usingAuthUser().removeFavoriteSite(siteModel1); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java index da3c6aef3..53a575224 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java @@ -3,8 +3,6 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataSite; -import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.ErrorModel; @@ -14,7 +12,6 @@ import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -22,12 +19,6 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) public class DeleteSiteMemberSanityTests extends RestTest { - @Autowired - DataUser dataUser; - - @Autowired - DataSite dataSite; - private SiteModel siteModel; private UserModel adminUser; private ListUserWithRoles usersWithRoles; @@ -39,96 +30,104 @@ public class DeleteSiteMemberSanityTests extends RestTest siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, - UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + UserRole.SiteManager, + UserRole.SiteCollaborator, + UserRole.SiteConsumer, + UserRole.SiteContributor); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify site manager is able to delete another member of the site") + executionType = ExecutionType.SANITY, + description = "Verify site manager is able to delete another member of the site") public void siteManagerCanDeleteSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception { UserModel newUser = dataUser.createRandomTestUser("testUser"); newUser.setUserRole(UserRole.SiteCollaborator); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .onCoreAPI() .usingSite(siteModel).addPerson(newUser); - restClient.usingUser(newUser).deleteSiteMember(siteModel); + restClient.onCoreAPI().usingUser(newUser).deleteSiteMember(siteModel); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify admin user is able to delete another member of the site") + executionType = ExecutionType.SANITY, + description = "Verify admin user is able to delete another member of the site") public void adminIsAbleToDeleteSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception { UserModel newUser = dataUser.createRandomTestUser("testUser"); newUser.setUserRole(UserRole.SiteCollaborator); restClient.authenticateUser(adminUser) + .onCoreAPI() .usingSite(siteModel).addPerson(newUser); - restClient.usingUser(newUser).deleteSiteMember(siteModel); + restClient.onCoreAPI().usingUser(newUser).deleteSiteMember(siteModel); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify site collaborator does not have permission to delete another member of the site") + executionType = ExecutionType.SANITY, + description = "Verify site collaborator does not have permission to delete another member of the site") @Bug(id="ACE-5444") public void siteCollaboratorIsNotAbleToDeleteSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception { UserModel newUser = dataUser.createRandomTestUser("testUser"); newUser.setUserRole(UserRole.SiteCollaborator); restClient.authenticateUser(adminUser) + .onCoreAPI() .usingSite(siteModel).addPerson(newUser); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.usingUser(newUser).deleteSiteMember(siteModel); + restClient.onCoreAPI().usingUser(newUser).deleteSiteMember(siteModel); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify site contributor does not have permission to delete another member of the site") + executionType = ExecutionType.SANITY, + description = "Verify site contributor does not have permission to delete another member of the site") @Bug(id="ACE-5444") public void siteContributorIsNotAbleToDeleteSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception { UserModel newUser = dataUser.createRandomTestUser("testUser"); newUser.setUserRole(UserRole.SiteCollaborator); restClient.authenticateUser(adminUser) + .onCoreAPI() .usingSite(siteModel).addPerson(newUser); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - restClient.usingUser(newUser).deleteSiteMember(siteModel); + restClient.onCoreAPI().usingUser(newUser).deleteSiteMember(siteModel); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify site consumer does not have permission to delete another member of the site") + executionType = ExecutionType.SANITY, + description = "Verify site consumer does not have permission to delete another member of the site") @Bug(id="ACE-5444") public void siteConsumerIsNotAbleToDeleteSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception { UserModel newUser = dataUser.createRandomTestUser("testUser"); newUser.setUserRole(UserRole.SiteCollaborator); restClient.authenticateUser(adminUser) + .onCoreAPI() .usingSite(siteModel).addPerson(newUser); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.usingUser(newUser).deleteSiteMember(siteModel); + restClient.onCoreAPI().usingUser(newUser).deleteSiteMember(siteModel); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify unauthenticated user is not able to delete another member of the site") + executionType = ExecutionType.SANITY, + description = "Verify unauthenticated user is not able to delete another member of the site") public void unauthenticatedUserIsNotAbleToDeleteSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception { restClient.authenticateUser(new UserModel("random user", "random password")); - restClient.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).deleteSiteMember(siteModel); + restClient.onCoreAPI().usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).deleteSiteMember(siteModel); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java index be6a956b4..1aad5da63 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java @@ -40,111 +40,135 @@ public class DeleteSiteMembershipRequestSanityTests extends RestTest UserRole.SiteContributor); } - @TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, - description = "Verify one user is able to delete his one site memebership request") + @TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.SANITY, + description = "Verify one user is able to delete his one site memebership request") public void userCanDeleteHisOwnSiteMembershipRequest() throws JsonToModelConversionException, DataPreparationException, Exception { siteMember = dataUser.createRandomTestUser(); restClient.authenticateUser(siteMember) + .onCoreAPI() .usingAuthUser().addSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .onCoreAPI() .usingUser(siteMember).deleteSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } @Bug(id="MNT-16916") - @TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, - description = "Verify site manager is able to delete site membership request") + @TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.SANITY, + description = "Verify site manager is able to delete site membership request") public void siteManagerCanDeleteSiteMembershipRequest() throws JsonToModelConversionException, DataPreparationException, Exception { siteMember = dataUser.createRandomTestUser(); restClient.authenticateUser(siteMember) + .onCoreAPI() .usingUser(siteMember).addSiteMembershipRequest(siteModel); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .onCoreAPI() .usingAuthUser().deleteSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } @Bug(id="MNT-16916") - @TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, - description = "Verify admin user is able to delete site memebership request") + @TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.SANITY, + description = "Verify admin user is able to delete site memebership request") public void adminUserCanDeleteSiteMembershipRequest() throws JsonToModelConversionException, DataPreparationException, Exception { siteMember = dataUser.createRandomTestUser(); restClient.authenticateUser(siteMember) + .onCoreAPI() .usingAuthUser().addSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); restClient.authenticateUser(dataUser.getAdminUser()) + .onCoreAPI() .usingAuthUser().deleteSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } @Bug(id="MNT-16916") - @TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, - description = "Verify collaborator user is not able to delete site memebership request") + @TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.SANITY, + description = "Verify collaborator user is not able to delete site memebership request") public void collaboratorCannotDeleteSiteMembershipRequest() throws JsonToModelConversionException, DataPreparationException, Exception { siteMember = dataUser.createRandomTestUser(); restClient.authenticateUser(siteMember) + .onCoreAPI() .usingAuthUser().addSiteMembershipRequest(siteModel); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .onCoreAPI() .usingAuthUser().deleteSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @Bug(id="MNT-16916") - @TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, - description = "Verify contributor user is not able to delete site memebership request") + @TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.SANITY, + description = "Verify contributor user is not able to delete site memebership request") public void contributorCannotDeleteSiteMembershipRequest() throws JsonToModelConversionException, DataPreparationException, Exception { siteMember = dataUser.createRandomTestUser(); restClient.authenticateUser(siteMember) + .onCoreAPI() .usingAuthUser().addSiteMembershipRequest(siteModel); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) + .onCoreAPI() .usingAuthUser().deleteSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @Bug(id="MNT-16916") - @TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, - description = "Verify consumer user is not able to delete site memebership request") + @TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.SANITY, + description = "Verify consumer user is not able to delete site memebership request") public void consumerCannotDeleteSiteMembershipRequest() throws JsonToModelConversionException, DataPreparationException, Exception { siteMember = dataUser.createRandomTestUser(); restClient.authenticateUser(siteMember) + .onCoreAPI() .usingAuthUser().addSiteMembershipRequest(siteModel); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + .onCoreAPI() .usingAuthUser().deleteSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @Bug(id="MNT-16916") - @TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, - description = "Verify random user is not able to delete site memebership request") + @TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.SANITY, + description = "Verify random user is not able to delete site memebership request") public void randomUserCanDeleteSiteMembershipRequest() throws JsonToModelConversionException, DataPreparationException, Exception { restClient.authenticateUser(dataUser.createRandomTestUser()) + .onCoreAPI() .usingAuthUser().addSiteMembershipRequest(siteModel); restClient.authenticateUser(dataUser.createRandomTestUser()) + .onCoreAPI() .usingAuthUser().deleteSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } - @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, - description = "Failed authentication get site member call returns status code 401") + @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, + executionType = ExecutionType.SANITY, + description = "Failed authentication get site member call returns status code 401") public void unauthenticatedUserIsNotAuthorizedToDeleteSiteMmebershipRequest() throws JsonToModelConversionException, Exception { restClient.authenticateUser(dataUser.createRandomTestUser()) + .onCoreAPI() .usingAuthUser().addSiteMembershipRequest(siteModel); UserModel inexistentUser = new UserModel("inexistent user", "inexistent password"); restClient.authenticateUser(inexistentUser) + .onCoreAPI() .usingAuthUser().deleteSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } diff --git a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java index df0d7c2cb..0bcdb34b6 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java @@ -30,12 +30,14 @@ public class GetFavoriteSiteSanityTests extends RestTest @BeforeClass(alwaysRun=true) public void dataPreparation() throws Exception { - userModel = dataUser.createRandomTestUser(); - siteModel1 = dataSite.usingUser(userModel).createPublicRandomSite(); - siteModel2 = dataSite.usingUser(userModel).createPublicRandomSite(); + userModel = dataUser.createRandomTestUser(); + siteModel1 = dataSite.usingUser(userModel).createPublicRandomSite(); + siteModel2 = dataSite.usingUser(userModel).createPublicRandomSite(); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user gets its specific favorite site with Rest API and response is successful (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.SANITY, + description = "Verify manager user gets its specific favorite site with Rest API and response is successful (200)") public void managerUserGetsFavoriteSiteWithSuccess() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -44,13 +46,16 @@ public class GetFavoriteSiteSanityTests extends RestTest dataSite.usingUser(managerUser).usingSite(siteModel2).addSiteToFavorites(); restClient.authenticateUser(managerUser) + .onCoreAPI() .usingAuthUser().getFavoriteSite(siteModel1) .assertThat().field("id").is(siteModel1.getId()) .and().field("title").isNotNull(); restClient.assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify collaborator user gets its specific favorite site with Rest API and response is successful (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.SANITY, + description = "Verify collaborator user gets its specific favorite site with Rest API and response is successful (200)") public void collaboratorUserGetsFavoriteSiteWithSuccess() throws Exception { UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); @@ -59,13 +64,16 @@ public class GetFavoriteSiteSanityTests extends RestTest dataSite.usingUser(collaboratorUser).usingSite(siteModel2).addSiteToFavorites(); restClient.authenticateUser(collaboratorUser) + .onCoreAPI() .usingAuthUser().getFavoriteSite(siteModel1) .assertThat().field("id").is(siteModel1.getId()) .and().field("title").isNotNull(); restClient.assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify contributor user gets its specific favorite site with Rest API and response is successful (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.SANITY, + description = "Verify contributor user gets its specific favorite site with Rest API and response is successful (200)") public void contributorUserGetsFavoriteSiteWithSuccess() throws Exception { UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); @@ -74,13 +82,16 @@ public class GetFavoriteSiteSanityTests extends RestTest dataSite.usingUser(contributorUser).usingSite(siteModel2).addSiteToFavorites(); restClient.authenticateUser(contributorUser) + .onCoreAPI() .usingAuthUser().getFavoriteSite(siteModel1) .assertThat().field("id").is(siteModel1.getId()) .and().field("title").isNotNull(); restClient.assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify consumer user gets its specific favorite site with Rest API and response is successful (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.SANITY, + description = "Verify consumer user gets its specific favorite site with Rest API and response is successful (200)") public void consumerUserGetsFavoriteSiteWithSuccess() throws Exception { UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -89,13 +100,16 @@ public class GetFavoriteSiteSanityTests extends RestTest dataSite.usingUser(consumerUser).usingSite(siteModel2).addSiteToFavorites(); restClient.authenticateUser(consumerUser) + .onCoreAPI() .usingAuthUser().getFavoriteSite(siteModel1) .assertThat().field("id").is(siteModel1.getId()) .and().field("title").isNotNull(); restClient.assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify admin user gets specific favorite site of any user with Rest API and response is successful (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.SANITY, + description = "Verify admin user gets specific favorite site of any user with Rest API and response is successful (200)") public void adminUserGetsAnyFavoriteSiteWithSuccess() throws Exception { UserModel adminUset = dataUser.getAdminUser(); @@ -104,13 +118,16 @@ public class GetFavoriteSiteSanityTests extends RestTest dataSite.usingUser(anyUser).usingSite(siteModel2).addSiteToFavorites(); restClient.authenticateUser(adminUset) + .onCoreAPI() .usingAuthUser().getFavoriteSite(siteModel1) .assertThat().field("id").is(siteModel1.getId()) .and().field("title").isNotNull(); restClient.assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user fails to get specific favorite site of another user with Rest API and response is successful (403)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.SANITY, + description = "Verify manager user fails to get specific favorite site of another user with Rest API and response is successful (403)") public void managerUserFailsToGetFavoriteSiteOfAnotherUser() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -119,12 +136,15 @@ public class GetFavoriteSiteSanityTests extends RestTest dataSite.usingUser(managerUser).usingSite(siteModel2).addSiteToFavorites(); restClient.authenticateUser(managerUser) + .onCoreAPI() .usingUser(userModel).getFavoriteSite(siteModel1); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @Bug(id = "MNT-16904") - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized gets its specific favorite site with Rest API when authentication fails (401)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.SANITY, + description = "Verify manager user is NOT Authorized gets its specific favorite site with Rest API when authentication fails (401)") public void managerUserNotAuthorizedFailsToGetFavoriteSite() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -134,6 +154,7 @@ public class GetFavoriteSiteSanityTests extends RestTest managerUser.setPassword("newpassword"); restClient.authenticateUser(managerUser) + .onCoreAPI() .usingAuthUser().getFavoriteSite(siteModel1); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } diff --git a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java index faa3817f9..1e1bbafc2 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java @@ -27,7 +27,9 @@ public class GetFavoriteSitesSanityTests extends RestTest siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user fails to get an user favorite sites with Rest API (403)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.SANITY, + description = "Verify manager user fails to get an user favorite sites with Rest API (403)") public void managerUserFailsToGetAnUserFavoriteSites() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -36,12 +38,14 @@ public class GetFavoriteSitesSanityTests extends RestTest dataSite.usingUser(anotherUser).usingSite(siteModel).addSiteToFavorites(); restClient.authenticateUser(managerUser) + .onCoreAPI() .usingUser(anotherUser).getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify collaborator user fails to get an user favorite sites with Rest API (403)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.SANITY, + description = "Verify collaborator user fails to get an user favorite sites with Rest API (403)") public void collaboratorUserFailsToGetAnUserFavoriteSites() throws Exception { UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); @@ -51,12 +55,14 @@ public class GetFavoriteSitesSanityTests extends RestTest dataSite.usingUser(contributorUser).usingSite(siteModel).addSiteToFavorites(); restClient.authenticateUser(collaboratorUser) + .onCoreAPI() .usingUser(contributorUser).getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify contributor user fails to get an user favorite sites with Rest API (403)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.SANITY, + description = "Verify contributor user fails to get an user favorite sites with Rest API (403)") public void contributorUserFailsToGetAnUserFavoriteSites() throws Exception { UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); @@ -66,12 +72,14 @@ public class GetFavoriteSitesSanityTests extends RestTest dataSite.usingUser(contributorUser2).usingSite(siteModel).addSiteToFavorites(); restClient.authenticateUser(contributorUser) + .onCoreAPI() .usingUser(contributorUser2).getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify consumer user fails to get an user favorite sites with Rest API (403)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.SANITY, + description = "Verify consumer user fails to get an user favorite sites with Rest API (403)") public void consumerUserFailsToGetAnUserFavoriteSites() throws Exception { UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -81,12 +89,14 @@ public class GetFavoriteSitesSanityTests extends RestTest dataSite.usingUser(collaboratorUser).usingSite(siteModel).addSiteToFavorites(); restClient.authenticateUser(consumerUser) + .onCoreAPI() .usingUser(collaboratorUser).getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify admin user gets its favorite sites with Rest API and response is successful (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.SANITY, + description = "Verify admin user gets its favorite sites with Rest API and response is successful (200)") public void adminUserGetsFavoriteSitesWithSuccess() throws Exception { UserModel adminUser = dataUser.getAdminUser(); @@ -94,6 +104,7 @@ public class GetFavoriteSitesSanityTests extends RestTest dataSite.usingUser(anotherUser).usingSite(siteModel).addSiteToFavorites(); restClient.authenticateUser(adminUser) + .onCoreAPI() .usingUser(anotherUser).getFavoriteSites() .assertThat().entriesListIsNotEmpty() .and().paginationExist() @@ -101,13 +112,16 @@ public class GetFavoriteSitesSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify any user gets its own user favorite sites with Rest API and response is successful (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.SANITY, + description = "Verify any user gets its own user favorite sites with Rest API and response is successful (200)") public void anyUserGetsItsUserFavoriteSites() throws Exception { UserModel anyUser = dataUser.usingAdmin().createRandomTestUser(); dataSite.usingUser(anyUser).usingSite(siteModel).addSiteToFavorites(); restClient.authenticateUser(anyUser) + .onCoreAPI() .usingAuthUser().getFavoriteSites() .assertThat().entriesListIsNotEmpty() .and().entriesListContains("id", siteModel.getId()) @@ -116,7 +130,9 @@ public class GetFavoriteSitesSanityTests extends RestTest } @Bug(id = "MNT-16904") - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify any user is NOT Authorized to get its favorite sites with Rest API when authentication fails (401)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.SANITY, + description = "Verify any user is NOT Authorized to get its favorite sites with Rest API when authentication fails (401)") public void anyUserNotAuthenticatedIsNotAuthorizedToGetFavoriteSites() throws Exception { UserModel anyUser = dataUser.usingAdmin().createRandomTestUser(); @@ -124,6 +140,7 @@ public class GetFavoriteSitesSanityTests extends RestTest anyUser.setPassword("newpassword"); restClient.authenticateUser(anyUser) + .onCoreAPI() .usingAuthUser().getFavoriteSites(); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java index ea7f36f25..444c90486 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java @@ -34,7 +34,9 @@ public class GetPeopleActivitiesSanityTests extends RestTest dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.SANITY, description = "Verify manager user gets its activities with Rest API and response is successful") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, + executionType = ExecutionType.SANITY, + description = "Verify manager user gets its activities with Rest API and response is successful") public void managerUserShouldGetPeopleActivitiesList() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -42,6 +44,7 @@ public class GetPeopleActivitiesSanityTests extends RestTest dataContent.usingUser(managerUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); restClient.authenticateUser(managerUser) + .onCoreAPI() .usingAuthUser().getPersonActivities() .assertThat().entriesListIsNotEmpty() .and().entriesListContains("siteId", siteModel.getId()) @@ -49,7 +52,9 @@ public class GetPeopleActivitiesSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.SANITY, description = "Verify collaborator user gets its activities with Rest API and response is successful") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, + executionType = ExecutionType.SANITY, + description = "Verify collaborator user gets its activities with Rest API and response is successful") public void collaboratorUserShouldGetPeopleActivitiesList() throws Exception { UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); @@ -57,6 +62,7 @@ public class GetPeopleActivitiesSanityTests extends RestTest dataContent.usingUser(collaboratorUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); restClient.authenticateUser(collaboratorUser) + .onCoreAPI() .usingAuthUser().getPersonActivities() .assertThat().entriesListIsNotEmpty() .and().entriesListContains("siteId", siteModel.getId()) @@ -64,7 +70,9 @@ public class GetPeopleActivitiesSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.SANITY, description = "Verify contributor user gets its activities with Rest API and response is successful") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, + executionType = ExecutionType.SANITY, + description = "Verify contributor user gets its activities with Rest API and response is successful") public void contributorUserShouldGetPeopleActivitiesList() throws Exception { UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); @@ -72,6 +80,7 @@ public class GetPeopleActivitiesSanityTests extends RestTest dataContent.usingUser(contributorUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); restClient.authenticateUser(contributorUser) + .onCoreAPI() .usingAuthUser().getPersonActivities() .assertThat().entriesListIsNotEmpty() .and().entriesListContains("siteId", siteModel.getId()) @@ -79,13 +88,16 @@ public class GetPeopleActivitiesSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.SANITY, description = "Verify consumer user gets its activities with Rest API and response is successful") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, + executionType = ExecutionType.SANITY, + description = "Verify consumer user gets its activities with Rest API and response is successful") public void consumerUserShouldGetPeopleActivitiesList() throws Exception { UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel, UserRole.SiteConsumer); restClient.authenticateUser(consumerUser) + .onCoreAPI() .usingAuthUser().getPersonActivities() .assertThat().entriesListIsNotEmpty() .and().entriesListContains("siteId", siteModel.getId()) @@ -93,11 +105,14 @@ public class GetPeopleActivitiesSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.SANITY, description = "Verify admin user gets another user activities with Rest API and response is successful") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, + executionType = ExecutionType.SANITY, + description = "Verify admin user gets another user activities with Rest API and response is successful") public void adminUserShouldGetPeopleActivitiesList() throws Exception { restClient.authenticateUser(dataUser.getAdminUser()) - .usingUser(userModel).getPersonActivities() + .onCoreAPI() + .usingUser(userModel).getPersonActivities() .assertThat().entriesListIsNotEmpty() .and().entriesListContains("siteId", siteModel.getId()) .and().paginationExist(); @@ -105,7 +120,9 @@ public class GetPeopleActivitiesSanityTests extends RestTest } @Bug(id = "MNT-16904") - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized to gets another user activities with Rest API") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, + executionType = ExecutionType.SANITY, + description = "Verify manager user is NOT Authorized to gets another user activities with Rest API") public void managerUserShouldGetPeopleActivitiesListIsNotAuthorized() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -113,7 +130,8 @@ public class GetPeopleActivitiesSanityTests extends RestTest managerUser.setPassword("newpassword"); restClient.authenticateUser(managerUser) - .usingUser(userModel).getPersonActivities(); + .onCoreAPI() + .usingUser(userModel).getPersonActivities(); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceSanityTests.java index e96f3fd54..3384c610f 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceSanityTests.java @@ -40,7 +40,7 @@ public class GetPeoplePreferenceSanityTests extends RestTest dataSite.usingUser(managerUser).usingSite(siteModel).addSiteToFavorites(); restClient.authenticateUser(managerUser) - .usingAuthUser().getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) + .onCoreAPI().usingAuthUser().getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) .assertThat().field("id").is( PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) .and().field("value").is("true"); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -54,7 +54,7 @@ public class GetPeoplePreferenceSanityTests extends RestTest dataSite.usingUser(collaboratorUser).usingSite(siteModel).addSiteToFavorites(); restClient.authenticateUser(collaboratorUser) - .usingAuthUser().getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) + .onCoreAPI().usingAuthUser().getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) .assertThat().field("id").is(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) .and().field("value").is("true"); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -68,7 +68,7 @@ public class GetPeoplePreferenceSanityTests extends RestTest dataSite.usingUser(contributorUser).usingSite(siteModel).addSiteToFavorites(); restClient.authenticateUser(contributorUser) - .usingAuthUser().getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) + .onCoreAPI().usingAuthUser().getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) .assertThat().field("id").is(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) .and().field("value").is("true"); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -82,7 +82,7 @@ public class GetPeoplePreferenceSanityTests extends RestTest dataSite.usingUser(consumerUser).usingSite(siteModel).addSiteToFavorites(); restClient.authenticateUser(consumerUser) - .usingAuthUser().getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) + .onCoreAPI().usingAuthUser().getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) .assertThat().field("id").is(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) .and().field("value").is("true"); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -95,7 +95,7 @@ public class GetPeoplePreferenceSanityTests extends RestTest dataSite.usingUser(adminUser).usingSite(siteModel).addSiteToFavorites(); restClient.authenticateUser(adminUser) - .usingAuthUser().getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) + .onCoreAPI().usingAuthUser().getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) .assertThat().field("id").is(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) .and().field("value").is("true"); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -111,7 +111,7 @@ public class GetPeoplePreferenceSanityTests extends RestTest managerUser.setPassword("newpassword"); restClient.authenticateUser(managerUser) - .usingAuthUser().getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); + .onCoreAPI().usingAuthUser().getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesSanityTests.java index b20950c6e..4f18d0f51 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesSanityTests.java @@ -32,7 +32,9 @@ public class GetPeoplePreferencesSanityTests extends RestTest siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify manager user gets its preferences with Rest API and response is successful (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, + executionType = ExecutionType.SANITY, + description = "Verify manager user gets its preferences with Rest API and response is successful (200)") public void managerUserGetsPeoplePreferencesWithSuccess() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -40,6 +42,7 @@ public class GetPeoplePreferencesSanityTests extends RestTest dataSite.usingUser(managerUser).usingSite(siteModel).addSiteToFavorites(); restClient.authenticateUser(managerUser) + .onCoreAPI() .usingAuthUser() .getPersonPreferences().assertThat().entriesListIsNotEmpty() .assertThat().paginationExist() @@ -47,7 +50,9 @@ public class GetPeoplePreferencesSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify collaborator user gets its preferences with Rest API and response is successful (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, + executionType = ExecutionType.SANITY, + description = "Verify collaborator user gets its preferences with Rest API and response is successful (200)") public void collaboratorUserGetsPeoplePreferencesWithSuccess() throws Exception { UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); @@ -55,13 +60,16 @@ public class GetPeoplePreferencesSanityTests extends RestTest dataSite.usingUser(collaboratorUser).usingSite(siteModel).addSiteToFavorites(); restClient.authenticateUser(collaboratorUser) + .onCoreAPI() .usingAuthUser().getPersonPreferences().assertThat().entriesListIsNotEmpty() - .assertThat().paginationExist() - .and().entriesListContains("id", PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); + .assertThat().paginationExist() + .and().entriesListContains("id", PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); restClient.assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify contributor user gets its preferences with Rest API and response is successful (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, + executionType = ExecutionType.SANITY, + description = "Verify contributor user gets its preferences with Rest API and response is successful (200)") public void contributorUserGetsPeoplePreferencesWithSuccess() throws Exception { UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); @@ -69,13 +77,16 @@ public class GetPeoplePreferencesSanityTests extends RestTest dataSite.usingUser(contributorUser).usingSite(siteModel).addSiteToFavorites(); restClient.authenticateUser(contributorUser) + .onCoreAPI() .usingAuthUser().getPersonPreferences().assertThat().entriesListIsNotEmpty() - .assertThat().paginationExist() - .and().entriesListContains("id", PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); + .assertThat().paginationExist() + .and().entriesListContains("id", PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); restClient.assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify consumer user gets its preferences with Rest API and response is successful (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, + executionType = ExecutionType.SANITY, + description = "Verify consumer user gets its preferences with Rest API and response is successful (200)") public void consumerUserGetsPeoplePreferencesWithSuccess() throws Exception { UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -83,13 +94,16 @@ public class GetPeoplePreferencesSanityTests extends RestTest dataSite.usingUser(consumerUser).usingSite(siteModel).addSiteToFavorites(); restClient.authenticateUser(consumerUser) + .onCoreAPI() .usingAuthUser().getPersonPreferences().assertThat().entriesListIsNotEmpty() .assertThat().paginationExist() .and().entriesListContains("id", PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); restClient.assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify admin user gets another user preferences with Rest API and response is successful (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, + executionType = ExecutionType.SANITY, + description = "Verify admin user gets another user preferences with Rest API and response is successful (200)") public void adminUserGetsPeoplePreferencesWithSuccess() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -98,14 +112,17 @@ public class GetPeoplePreferencesSanityTests extends RestTest UserModel adminUser = dataUser.getAdminUser(); restClient.authenticateUser(adminUser) - .usingUser(managerUser).getPersonPreferences().assertThat().entriesListIsNotEmpty() + .onCoreAPI() + .usingUser(managerUser).getPersonPreferences().assertThat().entriesListIsNotEmpty() .assertThat().paginationExist() .and().entriesListContains("id", PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); restClient.assertStatusCodeIs(HttpStatus.OK); } @Bug(id = "MNT-16904") - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized to gets its preferences with Rest API when authentication fails(401)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, + executionType = ExecutionType.SANITY, + description = "Verify manager user is NOT Authorized to gets its preferences with Rest API when authentication fails(401)") public void managerUserGetsPeoplePreferencesIsNotAUthorized() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -114,6 +131,7 @@ public class GetPeoplePreferencesSanityTests extends RestTest managerUser.setPassword("newpassword"); restClient.authenticateUser(managerUser) + .onCoreAPI() .usingAuthUser() .getPersonPreferences(); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleSanityTests.java index d4258e6cb..c8e9c4603 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleSanityTests.java @@ -29,13 +29,16 @@ public class GetPeopleSanityTests extends RestTest searchedUser = dataUser.createRandomTestUser(); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user gets a person with Rest API and response is successful") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.SANITY, + description = "Verify manager user gets a person with Rest API and response is successful") public void managerUserChecksIfPersonIsPresent() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); restClient.authenticateUser(managerUser) + .onCoreAPI() .usingUser(searchedUser) .getPerson() .assertThat().field("id").is(searchedUser.getUsername()) @@ -45,13 +48,16 @@ public class GetPeopleSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify collaborator user gets a person with Rest API and response is successful") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.SANITY, + description = "Verify collaborator user gets a person with Rest API and response is successful") public void collaboratorUserChecksIfPersonIsPresent() throws Exception { UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(collaboratorUser, siteModel, UserRole.SiteCollaborator); restClient.authenticateUser(collaboratorUser) + .onCoreAPI() .usingUser(searchedUser) .getPerson() .assertThat().field("id").is(searchedUser.getUsername()) @@ -62,13 +68,16 @@ public class GetPeopleSanityTests extends RestTest } @Test(groups = TestGroup.COMMENTS) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify contributor user gets a person with Rest API and response is successful") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.SANITY, + description = "Verify contributor user gets a person with Rest API and response is successful") public void contributorUserChecksIfPersonIsPresent() throws Exception { UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(contributorUser, siteModel, UserRole.SiteContributor); restClient.authenticateUser(contributorUser) + .onCoreAPI() .usingUser(searchedUser) .getPerson() .assertThat().field("id").is(searchedUser.getUsername()) @@ -78,13 +87,16 @@ public class GetPeopleSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify consumer user gets a person with Rest API and response is successful") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.SANITY, + description = "Verify consumer user gets a person with Rest API and response is successful") public void consumerUserChecksIfPersonIsPresent() throws Exception { UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel, UserRole.SiteConsumer); restClient.authenticateUser(consumerUser) + .onCoreAPI() .usingUser(searchedUser) .getPerson() .assertThat().field("id").is(searchedUser.getUsername()) @@ -94,12 +106,15 @@ public class GetPeopleSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify admin user gets a person with Rest API and response is successful") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.SANITY, + description = "Verify admin user gets a person with Rest API and response is successful") public void adminUserChecksIfPersonIsPresent() throws Exception { UserModel adminUser = dataUser.getAdminUser(); restClient.authenticateUser(adminUser) + .onCoreAPI() .usingUser(searchedUser) .getPerson() .assertThat().field("id").is(searchedUser.getUsername()) @@ -109,7 +124,9 @@ public class GetPeopleSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user gets a non existing person with Rest API and person is not found") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.SANITY, + description = "Verify manager user gets a non existing person with Rest API and person is not found") public void managerUserChecksIfNonExistingPersonIsPresent() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -117,6 +134,7 @@ public class GetPeopleSanityTests extends RestTest UserModel searchedNonUser = new UserModel("nonexistinguser", DataUser.PASSWORD); restClient.authenticateUser(managerUser) + .onCoreAPI() .usingUser(searchedNonUser) .getPerson(); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestSanityTests.java index 6001a9600..7a35afa96 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestSanityTests.java @@ -48,10 +48,11 @@ public class GetSiteMembershipRequestSanityTests extends RestTest { UserModel newMember = dataUser.createRandomTestUser(); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .onCoreAPI() .usingUser(newMember) .addSiteMembershipRequest(siteModel); - restClient.usingUser(newMember).getSiteMembershipRequest(siteModel); + restClient.onCoreAPI().usingUser(newMember).getSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -62,10 +63,11 @@ public class GetSiteMembershipRequestSanityTests extends RestTest { UserModel newMember = dataUser.createRandomTestUser(); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .onCoreAPI() .usingUser(newMember) .addSiteMembershipRequest(siteModel); - restClient.usingUser(newMember).getSiteMembershipRequest(siteModel); + restClient.onCoreAPI().usingUser(newMember).getSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -76,10 +78,11 @@ public class GetSiteMembershipRequestSanityTests extends RestTest { UserModel newMember = dataUser.createRandomTestUser(); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) + .onCoreAPI() .usingUser(newMember) .addSiteMembershipRequest(siteModel); - restClient.usingUser(newMember).getSiteMembershipRequest(siteModel); + restClient.onCoreAPI().usingUser(newMember).getSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -90,10 +93,11 @@ public class GetSiteMembershipRequestSanityTests extends RestTest { UserModel newMember = dataUser.createRandomTestUser(); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + .onCoreAPI() .usingUser(newMember) .addSiteMembershipRequest(siteModel); - restClient.usingUser(newMember).getSiteMembershipRequest(siteModel); + restClient.onCoreAPI().usingUser(newMember).getSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -104,10 +108,11 @@ public class GetSiteMembershipRequestSanityTests extends RestTest { UserModel newMember = dataUser.createRandomTestUser(); restClient.authenticateUser(adminUser) + .onCoreAPI() .usingUser(newMember) .addSiteMembershipRequest(siteModel); - restClient.usingUser(newMember).getSiteMembershipRequest(siteModel); + restClient.onCoreAPI().usingUser(newMember).getSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -118,10 +123,11 @@ public class GetSiteMembershipRequestSanityTests extends RestTest { UserModel newMember = dataUser.createRandomTestUser(); restClient.authenticateUser(new UserModel("random user", "random password")) + .onCoreAPI() .usingUser(newMember) .addSiteMembershipRequest(siteModel); - restClient.usingUser(newMember).getSiteMembershipRequest(siteModel); + restClient.onCoreAPI().usingUser(newMember).getSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java index c0e8fa395..cebf576d4 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java @@ -35,6 +35,7 @@ public class GetSiteMembershipRequestsSanityTests extends RestTest newMember = dataUser.createRandomTestUser(); restClient.authenticateUser(newMember) + .onCoreAPI() .usingAuthUser().addSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); @@ -42,66 +43,83 @@ public class GetSiteMembershipRequestsSanityTests extends RestTest } @Bug(id = "MNT-16557") - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user gets all site membership requests of a specific person with Rest API and response is successful (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.SANITY, + description = "Verify manager user gets all site membership requests of a specific person with Rest API and response is successful (200)") public void managerUserGetsSiteMembershipRequestsWithSuccess() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); restClient.authenticateUser(managerUser) + .onCoreAPI() .usingUser(newMember).getSiteMembershipRequests().assertThat().entriesListIsNotEmpty(); restClient.assertStatusCodeIs(HttpStatus.OK); } @Bug(id = "MNT-16557") - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify collaborator user fails to get all site membership requests of another user with Rest API (403)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.SANITY, + description = "Verify collaborator user fails to get all site membership requests of another user with Rest API (403)") public void collaboratorUserFailsToGetSiteMembershipRequestsOfAnotherUser() throws Exception { UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(collaboratorUser, siteModel, UserRole.SiteCollaborator); restClient.authenticateUser(collaboratorUser) + .onCoreAPI() .usingUser(newMember).getSiteMembershipRequests(); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); } @Bug(id = "MNT-16557") - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify contributor user fails to get all site membership requests of another user with Rest API (403)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.SANITY, + description = "Verify contributor user fails to get all site membership requests of another user with Rest API (403)") public void contributorUserFailsToGetSiteMembershipRequestsOfAnotherUser() throws Exception { UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(contributorUser, siteModel, UserRole.SiteContributor); restClient.authenticateUser(contributorUser) + .onCoreAPI() .usingUser(newMember).getSiteMembershipRequests(); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); } @Bug(id = "MNT-16557") - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify consumer user fails to get all site membership requests of another user with Rest API (403)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.SANITY, + description = "Verify consumer user fails to get all site membership requests of another user with Rest API (403)") public void consumerUserFailsToGetSiteMembershipRequestsOfAnotherUser() throws Exception { UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel, UserRole.SiteConsumer); restClient.authenticateUser(consumerUser) + .onCoreAPI() .usingUser(newMember).getSiteMembershipRequests(); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); } @Bug(id = "MNT-16557") - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify admin user gets all site membership requests of a specific person with Rest API and response is successful (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.SANITY, + description = "Verify admin user gets all site membership requests of a specific person with Rest API and response is successful (200)") public void adminUserGetsSiteMembershipRequestsWithSuccess() throws Exception { UserModel adminUser = dataUser.getAdminUser(); restClient.authenticateUser(adminUser) + .onCoreAPI() .usingUser(newMember).getSiteMembershipRequests().assertThat().entriesListIsNotEmpty(); restClient.assertStatusCodeIs(HttpStatus.OK); } @Bug(id = "MNT-16904") - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user fails to get all site membership requests of a specific person with Rest API when the authentication fails (401)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.SANITY, + description = "Verify manager user fails to get all site membership requests of a specific person with Rest API when the authentication fails (401)") public void managerUserNotAuthorizedFailsToGetSiteMembershipRequests() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -109,15 +127,19 @@ public class GetSiteMembershipRequestsSanityTests extends RestTest managerUser.setPassword("newpassword"); restClient.authenticateUser(managerUser) + .onCoreAPI() .usingUser(newMember).getSiteMembershipRequests(); restClient.assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify a user gets all its own site membership requests with Rest API and response is successful (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.SANITY, + description = "Verify a user gets all its own site membership requests with Rest API and response is successful (200)") public void oneUserGetsItsOwnSiteMembershipRequestsWithSuccess() throws Exception { restClient.authenticateUser(newMember) - .usingUser(newMember).getSiteMembershipRequests().assertThat().entriesListIsNotEmpty(); + .onCoreAPI() + .usingUser(newMember).getSiteMembershipRequests().assertThat().entriesListIsNotEmpty(); restClient.assertStatusCodeIs(HttpStatus.OK); } } diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java index bf86866de..bbf110d06 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java @@ -3,8 +3,6 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataSite; -import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.SiteModel; @@ -13,7 +11,6 @@ import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -21,12 +18,6 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) public class GetSiteMembershipSanityTests extends RestTest { - @Autowired - DataUser dataUser; - - @Autowired - DataSite dataSite; - private SiteModel siteModel; private UserModel adminUser; private ListUserWithRoles usersWithRoles; @@ -42,11 +33,12 @@ public class GetSiteMembershipSanityTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify site manager is able to retrieve site membership information of another user") + executionType = ExecutionType.SANITY, + description = "Verify site manager is able to retrieve site membership information of another user") public void siteManagerCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .onCoreAPI() .usingUser(adminUser) .getSiteMembership(siteModel) .assertThat().field("role").is(UserRole.SiteManager) @@ -55,11 +47,13 @@ public class GetSiteMembershipSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site collaborator is able to retrieve site membership information of another user") + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, + executionType = ExecutionType.SANITY, + description = "Verify site collaborator is able to retrieve site membership information of another user") public void siteCollaboratorCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .onCoreAPI() .usingUser(adminUser) .getSiteMembership(siteModel) .onSite() @@ -68,11 +62,13 @@ public class GetSiteMembershipSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site contributor is able to retrieve site membership information of another user") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.SANITY, + description = "Verify site contributor is able to retrieve site membership information of another user") public void siteContributorCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) + .onCoreAPI() .usingUser(adminUser) .getSiteMembership(siteModel) .assertThat().field("role").is(UserRole.SiteManager) @@ -81,11 +77,11 @@ public class GetSiteMembershipSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site consumer is able to retrieve site membership information of another user") + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site consumer is able to retrieve site membership information of another user") public void siteConsumerCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + .onCoreAPI() .usingUser(adminUser) .getSiteMembership(siteModel) .assertThat().field("role").is(UserRole.SiteManager) @@ -94,11 +90,13 @@ public class GetSiteMembershipSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify admin user is able to retrieve site membership information of another user") + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, + executionType = ExecutionType.SANITY, + description = "Verify admin user is able to retrieve site membership information of another user") public void adminCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUser) + .onCoreAPI() .usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) .getSiteMembership(siteModel) .assertThat().field("role").is(UserRole.SiteManager) @@ -107,12 +105,14 @@ public class GetSiteMembershipSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to retrieve site membership information of another user") + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, + executionType = ExecutionType.SANITY, + description = "Verify unauthenticated user is not able to retrieve site membership information of another user") @Bug(id = "MNT-16904") public void unauthenticatedUserCannotRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception { restClient.authenticateUser(new UserModel("random user", "random password")) + .onCoreAPI() .usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) .getSiteMembership(siteModel); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); diff --git a/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java index 18de516e2..99c6e09e8 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java @@ -31,11 +31,12 @@ public class GetSitesMembershipInformationSanityTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify site manager is able to retrieve sites membership information of another user") + executionType = ExecutionType.SANITY, + description = "Verify site manager is able to retrieve sites membership information of another user") public void siteManagerIsAbleToRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .onCoreAPI() .usingUser(adminUser) .getSitesMembershipInformation() .assertThat().entriesListIsNotEmpty() @@ -45,11 +46,12 @@ public class GetSitesMembershipInformationSanityTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify site collaborator is able to retrieve sites membership information of another user") + executionType = ExecutionType.SANITY, + description = "Verify site collaborator is able to retrieve sites membership information of another user") public void siteCollaboratorIsAbleToRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .onCoreAPI() .usingUser(adminUser) .getSitesMembershipInformation() .assertThat().entriesListIsNotEmpty() @@ -59,11 +61,12 @@ public class GetSitesMembershipInformationSanityTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify site contributor is able to retrieve sites membership information of another user") + executionType = ExecutionType.SANITY, + description = "Verify site contributor is able to retrieve sites membership information of another user") public void siteContributorIsAbleToRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) + .onCoreAPI() .usingUser(adminUser) .getSitesMembershipInformation() .assertThat().entriesListIsNotEmpty() @@ -73,11 +76,12 @@ public class GetSitesMembershipInformationSanityTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify site consumer is able to retrieve sites membership information of another user") + executionType = ExecutionType.SANITY, + description = "Verify site consumer is able to retrieve sites membership information of another user") public void siteConsumerIsAbleToRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + .onCoreAPI() .usingUser(adminUser) .getSitesMembershipInformation() .assertThat().entriesListIsNotEmpty() @@ -87,11 +91,12 @@ public class GetSitesMembershipInformationSanityTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify admin is able to retrieve sites membership information of another user") + executionType = ExecutionType.SANITY, + description = "Verify admin is able to retrieve sites membership information of another user") public void siteAdminIsAbleToRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUser) + .onCoreAPI() .usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) .getSitesMembershipInformation() .assertThat().entriesListIsNotEmpty() @@ -101,13 +106,14 @@ public class GetSitesMembershipInformationSanityTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify that unauthenticated user is not able to retrieve sites membership information") + executionType = ExecutionType.SANITY, + description = "Verify that unauthenticated user is not able to retrieve sites membership information") @Bug(id = "MNT-16904") public void unauthenticatedUserCannotRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception { UserModel inexistentUser = new UserModel("inexistent user", "wrong password"); restClient.authenticateUser(inexistentUser) + .onCoreAPI() .usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) .getSitesMembershipInformation(); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); diff --git a/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestSanityTests.java index b04bc76e5..8591c4167 100644 --- a/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestSanityTests.java @@ -53,9 +53,10 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest UserModel newMember = dataUser.createRandomTestUser(); restClient.authenticateUser(newMember) + .onCoreAPI() .usingAuthUser() .addSiteMembershipRequest(siteModel); - restClient.usingUser(newMember).updateSiteMembershipRequest(siteModel, updatedMessage) + restClient.onCoreAPI().usingUser(newMember).updateSiteMembershipRequest(siteModel, updatedMessage) .assertMembershipRequestMessageIs(updatedMessage) .and().field("id").is(siteModel.getId()) .and().field("modifiedAt").isNotEmpty(); @@ -70,10 +71,12 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest UserModel newMember = dataUser.createRandomTestUser(); restClient.authenticateUser(newMember) + .onCoreAPI() .usingAuthUser() .addSiteMembershipRequest(siteModel); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .onCoreAPI() .usingUser(newMember).updateSiteMembershipRequest(siteModel, updatedMessage); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) @@ -88,10 +91,12 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest UserModel newMember = dataUser.createRandomTestUser(); restClient.authenticateUser(newMember) + .onCoreAPI() .usingAuthUser() .addSiteMembershipRequest(siteModel); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .onCoreAPI() .usingUser(newMember) .updateSiteMembershipRequest(siteModel, updatedMessage); @@ -107,10 +112,12 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest UserModel newMember = dataUser.createRandomTestUser(); restClient.authenticateUser(newMember) + .onCoreAPI() .usingAuthUser().addSiteMembershipRequest(siteModel); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) - .usingUser(newMember).updateSiteMembershipRequest(siteModel, updatedMessage); + .onCoreAPI() + .usingUser(newMember).updateSiteMembershipRequest(siteModel, updatedMessage); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); @@ -124,11 +131,13 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest UserModel newMember = dataUser.createRandomTestUser(); restClient.authenticateUser(newMember) + .onCoreAPI() .usingAuthUser() .addSiteMembershipRequest(siteModel); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .usingUser(newMember) + .onCoreAPI() + .usingUser(newMember) .updateSiteMembershipRequest(siteModel, updatedMessage); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) @@ -144,11 +153,13 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest UserModel otherMember = dataUser.createRandomTestUser(); restClient.authenticateUser(newMember) + .onCoreAPI() .usingAuthUser() .addSiteMembershipRequest(siteModel); restClient.authenticateUser(otherMember) - .usingUser(newMember) + .onCoreAPI() + .usingUser(newMember) .updateSiteMembershipRequest(siteModel, updatedMessage); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) @@ -163,12 +174,14 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest UserModel newMember = dataUser.createRandomTestUser(); restClient.authenticateUser(newMember) + .onCoreAPI() .usingAuthUser() .addSiteMembershipRequest(siteModel); restClient.authenticateUser(adminUser) - .usingUser(newMember) - .updateSiteMembershipRequest(siteModel, updatedMessage); + .onCoreAPI() + .usingUser(newMember) + .updateSiteMembershipRequest(siteModel, updatedMessage); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); diff --git a/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java index c93340c96..aad8bed11 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java @@ -54,7 +54,7 @@ public class AddRatingSanityTests extends RestTest public void managerIsAbleToLikeDocument() throws Exception { returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .usingResource(document).likeDocument(); + .onCoreAPI().usingResource(document).likeDocument(); restClient.assertStatusCodeIs(HttpStatus.CREATED); returnedRatingModel.assertThat().field("myRating").is("true") @@ -67,7 +67,7 @@ public class AddRatingSanityTests extends RestTest public void collaboratorIsAbleToLikeDocument() throws Exception { returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .usingResource(document).likeDocument(); + .onCoreAPI().usingResource(document).likeDocument(); restClient.assertStatusCodeIs(HttpStatus.CREATED); returnedRatingModel.assertThat().field("myRating").is("true") @@ -79,7 +79,7 @@ public class AddRatingSanityTests extends RestTest TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Contributor role is able to post like rating to a document") public void contributorIsAbleToLikeDocument() throws Exception { - returnedRatingModel =restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingResource(document).likeDocument(); + returnedRatingModel =restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).onCoreAPI().usingResource(document).likeDocument(); restClient.assertStatusCodeIs(HttpStatus.CREATED); returnedRatingModel.assertThat().field("myRating").is("true") @@ -91,7 +91,7 @@ public class AddRatingSanityTests extends RestTest TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role is able to post like rating to a document") public void consumerIsAbleToLikeDocument() throws Exception { - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).usingResource(document).likeDocument(); + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).onCoreAPI().usingResource(document).likeDocument(); restClient.assertStatusCodeIs(HttpStatus.CREATED); returnedRatingModel.assertThat().field("myRating").is("true") @@ -103,7 +103,7 @@ public class AddRatingSanityTests extends RestTest TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify admin user is able to post like rating to a document") public void adminIsAbleToLikeDocument() throws Exception { - returnedRatingModel = restClient.authenticateUser(adminUser).usingResource(document).likeDocument(); + returnedRatingModel = restClient.authenticateUser(adminUser).onCoreAPI().usingResource(document).likeDocument(); restClient.assertStatusCodeIs(HttpStatus.CREATED); returnedRatingModel.assertThat().field("myRating").is("true") @@ -116,7 +116,7 @@ public class AddRatingSanityTests extends RestTest @Bug(id = "MNT-16904") public void unauthenticatedUserIsNotAbleToLikeDocument() throws Exception { - restClient.authenticateUser(new UserModel("random user", "random password")).usingResource(document).likeDocument(); + restClient.authenticateUser(new UserModel("random user", "random password")).onCoreAPI().usingResource(document).likeDocument(); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } @@ -124,7 +124,7 @@ public class AddRatingSanityTests extends RestTest TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role is able to post stars rating to a document") public void managerIsAbleToAddStarsToDocument() throws Exception { - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).usingResource(document).rateStarsToDocument(5); + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).onCoreAPI().usingResource(document).rateStarsToDocument(5); restClient.assertStatusCodeIs(HttpStatus.CREATED); returnedRatingModel.assertThat().field("myRating").is("5") .and().field("id").is("fiveStar") @@ -135,7 +135,7 @@ public class AddRatingSanityTests extends RestTest TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Collaborator role is able to post stars rating to a document") public void collaboratorIsAbleToAddStarsToDocument() throws Exception { - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).usingResource(document).rateStarsToDocument(5); + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).onCoreAPI().usingResource(document).rateStarsToDocument(5); restClient.assertStatusCodeIs(HttpStatus.CREATED); returnedRatingModel.assertThat().field("myRating").is("5") .and().field("id").is("fiveStar") @@ -147,7 +147,7 @@ public class AddRatingSanityTests extends RestTest TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Contributor role is able to post stars rating to a document") public void contributorIsAbleToAddStarsToDocument() throws Exception { - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingResource(document).rateStarsToDocument(5); + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).onCoreAPI().usingResource(document).rateStarsToDocument(5); restClient.assertStatusCodeIs(HttpStatus.CREATED); returnedRatingModel.assertThat().field("myRating").is("5") .and().field("id").is("fiveStar") @@ -158,7 +158,7 @@ public class AddRatingSanityTests extends RestTest TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role is able to post stars rating to a document") public void consumerIsAbleToAddStarsToDocument() throws Exception { - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).usingResource(document).rateStarsToDocument(5); + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).onCoreAPI().usingResource(document).rateStarsToDocument(5); restClient.assertStatusCodeIs(HttpStatus.CREATED); returnedRatingModel.assertThat().field("myRating").is("5") .and().field("id").is("fiveStar") @@ -169,7 +169,7 @@ public class AddRatingSanityTests extends RestTest TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify admin user is able to post stars rating to a document") public void adminIsAbleToAddStarsToDocument() throws Exception { - returnedRatingModel = restClient.authenticateUser(adminUser).usingResource(document).rateStarsToDocument(3); + returnedRatingModel = restClient.authenticateUser(adminUser).onCoreAPI().usingResource(document).rateStarsToDocument(3); restClient.assertStatusCodeIs(HttpStatus.CREATED); returnedRatingModel.assertThat().field("myRating").is(String.valueOf(3)) .and().field("id").is("fiveStar") @@ -181,7 +181,7 @@ public class AddRatingSanityTests extends RestTest @Bug(id = "MNT-16904") public void unauthenticatedUserIsNotAbleToRateStarsToDocument() throws Exception { - restClient.authenticateUser(new UserModel("random user", "random password")).usingResource(document).rateStarsToDocument(5); + restClient.authenticateUser(new UserModel("random user", "random password")).onCoreAPI().usingResource(document).rateStarsToDocument(5); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java index c670848b3..ae89140d8 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java @@ -51,16 +51,16 @@ public class DeleteRatingSanityTests extends RestTest public void managerIsAbleToDeleteItsOwnRatings() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.usingResource(document).likeDocument(); - restClient.usingResource(document).rateStarsToDocument(5); + restClient.onCoreAPI().usingResource(document).likeDocument(); + restClient.onCoreAPI().usingResource(document).rateStarsToDocument(5); - restClient.usingResource(document).deleteLikeRating(); + restClient.onCoreAPI().usingResource(document).deleteLikeRating(); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.usingResource(document).deleteFiveStarRating(); + restClient.onCoreAPI().usingResource(document).deleteFiveStarRating(); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - returnedRatingModelCollection = restClient.usingResource(document).getRatings(); + returnedRatingModelCollection = restClient.onCoreAPI().usingResource(document).getRatings(); restClient.assertStatusCodeIs(HttpStatus.OK); returnedRatingModelCollection.assertNodeIsNotLiked() .assertNodeHasNoFiveStarRating() @@ -74,16 +74,16 @@ public class DeleteRatingSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.usingResource(document).likeDocument(); - restClient.usingResource(document).rateStarsToDocument(5); + restClient.onCoreAPI().usingResource(document).likeDocument(); + restClient.onCoreAPI().usingResource(document).rateStarsToDocument(5); - restClient.usingResource(document).deleteLikeRating(); + restClient.onCoreAPI().usingResource(document).deleteLikeRating(); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.usingResource(document).deleteFiveStarRating(); + restClient.onCoreAPI().usingResource(document).deleteFiveStarRating(); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - returnedRatingModelCollection = restClient.usingResource(document).getRatings(); + returnedRatingModelCollection = restClient.onCoreAPI().usingResource(document).getRatings(); restClient.assertStatusCodeIs(HttpStatus.OK); returnedRatingModelCollection.assertNodeIsNotLiked() .assertNodeHasNoFiveStarRating() @@ -97,16 +97,16 @@ public class DeleteRatingSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - restClient.usingResource(document).likeDocument(); - restClient.usingResource(document).rateStarsToDocument(5); + restClient.onCoreAPI().usingResource(document).likeDocument(); + restClient.onCoreAPI().usingResource(document).rateStarsToDocument(5); - restClient.usingResource(document).deleteLikeRating(); + restClient.onCoreAPI().usingResource(document).deleteLikeRating(); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.usingResource(document).deleteFiveStarRating(); + restClient.onCoreAPI().usingResource(document).deleteFiveStarRating(); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - returnedRatingModelCollection = restClient.usingResource(document).getRatings(); + returnedRatingModelCollection = restClient.onCoreAPI().usingResource(document).getRatings(); restClient.assertStatusCodeIs(HttpStatus.OK); returnedRatingModelCollection.assertNodeIsNotLiked() .assertNodeHasNoFiveStarRating() @@ -120,16 +120,16 @@ public class DeleteRatingSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.usingResource(document).likeDocument(); - restClient.usingResource(document).rateStarsToDocument(5); + restClient.onCoreAPI().usingResource(document).likeDocument(); + restClient.onCoreAPI().usingResource(document).rateStarsToDocument(5); - restClient.usingResource(document).deleteLikeRating(); + restClient.onCoreAPI().usingResource(document).deleteLikeRating(); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.usingResource(document).deleteFiveStarRating(); + restClient.onCoreAPI().usingResource(document).deleteFiveStarRating(); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - returnedRatingModelCollection = restClient.usingResource(document).getRatings(); + returnedRatingModelCollection = restClient.onCoreAPI().usingResource(document).getRatings(); restClient.assertStatusCodeIs(HttpStatus.OK); returnedRatingModelCollection.assertNodeIsNotLiked() .assertNodeHasNoFiveStarRating() @@ -145,16 +145,16 @@ public class DeleteRatingSanityTests extends RestTest restClient.authenticateUser(adminUser); - restClient.usingResource(document).likeDocument(); - restClient.usingResource(document).rateStarsToDocument(5); + restClient.onCoreAPI().usingResource(document).likeDocument(); + restClient.onCoreAPI().usingResource(document).rateStarsToDocument(5); - restClient.usingResource(document).deleteLikeRating(); + restClient.onCoreAPI().usingResource(document).deleteLikeRating(); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.usingResource(document).deleteFiveStarRating(); + restClient.onCoreAPI().usingResource(document).deleteFiveStarRating(); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - returnedRatingModelCollection = restClient.usingResource(document).getRatings(); + returnedRatingModelCollection = restClient.onCoreAPI().usingResource(document).getRatings(); restClient.assertStatusCodeIs(HttpStatus.OK); returnedRatingModelCollection.assertNodeIsNotLiked() .assertNodeHasNoFiveStarRating() @@ -169,15 +169,15 @@ public class DeleteRatingSanityTests extends RestTest document = dataContent.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); restClient.authenticateUser(adminUser); - restClient.usingResource(document).likeDocument(); - restClient.usingResource(document).rateStarsToDocument(5); + restClient.onCoreAPI().usingResource(document).likeDocument(); + restClient.onCoreAPI().usingResource(document).rateStarsToDocument(5); restClient.authenticateUser(new UserModel("random user", "random password")); - restClient.usingResource(document).deleteLikeRating(); + restClient.onCoreAPI().usingResource(document).deleteLikeRating(); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); - restClient.usingResource(document).deleteFiveStarRating(); + restClient.onCoreAPI().usingResource(document).deleteFiveStarRating(); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } @@ -191,15 +191,15 @@ public class DeleteRatingSanityTests extends RestTest restClient.authenticateUser(userA); - restClient.usingResource(document).likeDocument(); - restClient.usingResource(document).rateStarsToDocument(5); + restClient.onCoreAPI().usingResource(document).likeDocument(); + restClient.onCoreAPI().usingResource(document).rateStarsToDocument(5); restClient.authenticateUser(userB); - restClient.authenticateUser(userB).usingResource(document).deleteLikeRating(); + restClient.authenticateUser(userB).onCoreAPI().usingResource(document).deleteLikeRating(); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); - restClient.usingResource(document).deleteFiveStarRating(); + restClient.onCoreAPI().usingResource(document).deleteFiveStarRating(); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java index c07f4b2e8..ee1ee5026 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java @@ -53,14 +53,14 @@ public class GetRatingSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.usingResource(document).likeDocument(); - restClient.usingResource(document).rateStarsToDocument(5); + restClient.onCoreAPI().usingResource(document).likeDocument(); + restClient.onCoreAPI().usingResource(document).rateStarsToDocument(5); - restRatingModel = restClient.usingResource(document).getLikeRating(); + restRatingModel = restClient.onCoreAPI().usingResource(document).getLikeRating(); restClient.assertStatusCodeIs(HttpStatus.OK); restRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); - restRatingModel = restClient.usingResource(document).getFiveStarRating(); + restRatingModel = restClient.onCoreAPI().usingResource(document).getFiveStarRating(); restClient.assertStatusCodeIs(HttpStatus.OK); restRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").is("5"); } @@ -71,14 +71,14 @@ public class GetRatingSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.usingResource(document).likeDocument(); - restClient.usingResource(document).rateStarsToDocument(5); + restClient.onCoreAPI().usingResource(document).likeDocument(); + restClient.onCoreAPI().usingResource(document).rateStarsToDocument(5); - restRatingModel = restClient.usingResource(document).getLikeRating(); + restRatingModel = restClient.onCoreAPI().usingResource(document).getLikeRating(); restClient.assertStatusCodeIs(HttpStatus.OK); restRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); - restRatingModel = restClient.usingResource(document).getFiveStarRating(); + restRatingModel = restClient.onCoreAPI().usingResource(document).getFiveStarRating(); restClient.assertStatusCodeIs(HttpStatus.OK); restRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").is("5"); } @@ -89,14 +89,14 @@ public class GetRatingSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - restClient.usingResource(document).likeDocument(); - restClient.usingResource(document).rateStarsToDocument(5); + restClient.onCoreAPI().usingResource(document).likeDocument(); + restClient.onCoreAPI().usingResource(document).rateStarsToDocument(5); - restRatingModel = restClient.usingResource(document).getLikeRating(); + restRatingModel = restClient.onCoreAPI().usingResource(document).getLikeRating(); restClient.assertStatusCodeIs(HttpStatus.OK); restRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); - restRatingModel = restClient.usingResource(document).getFiveStarRating(); + restRatingModel = restClient.onCoreAPI().usingResource(document).getFiveStarRating(); restClient.assertStatusCodeIs(HttpStatus.OK); restRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").is("5"); } @@ -107,14 +107,14 @@ public class GetRatingSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.usingResource(document).likeDocument(); - restClient.usingResource(document).rateStarsToDocument(5); + restClient.onCoreAPI().usingResource(document).likeDocument(); + restClient.onCoreAPI().usingResource(document).rateStarsToDocument(5); - restRatingModel = restClient.usingResource(document).getLikeRating(); + restRatingModel = restClient.onCoreAPI().usingResource(document).getLikeRating(); restClient.assertStatusCodeIs(HttpStatus.OK); restRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); - restRatingModel = restClient.usingResource(document).getFiveStarRating(); + restRatingModel = restClient.onCoreAPI().usingResource(document).getFiveStarRating(); restClient.assertStatusCodeIs(HttpStatus.OK); restRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").is("5"); } @@ -126,14 +126,14 @@ public class GetRatingSanityTests extends RestTest document = dataContent.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); restClient.authenticateUser(adminUser); - restClient.usingResource(document).likeDocument(); - restClient.usingResource(document).rateStarsToDocument(5); + restClient.onCoreAPI().usingResource(document).likeDocument(); + restClient.onCoreAPI().usingResource(document).rateStarsToDocument(5); - restRatingModel = restClient.usingResource(document).getLikeRating(); + restRatingModel = restClient.onCoreAPI().usingResource(document).getLikeRating(); restClient.assertStatusCodeIs(HttpStatus.OK); restRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); - restRatingModel = restClient.usingResource(document).getFiveStarRating(); + restRatingModel = restClient.onCoreAPI().usingResource(document).getFiveStarRating(); restClient.assertStatusCodeIs(HttpStatus.OK); restRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").is("5"); } @@ -144,15 +144,15 @@ public class GetRatingSanityTests extends RestTest public void unauthenticatedUserIsNotAbleToRetrieveRating() throws Exception { restClient.authenticateUser(adminUser); - restClient.usingResource(document).likeDocument(); - restClient.usingResource(document).rateStarsToDocument(5); + restClient.onCoreAPI().usingResource(document).likeDocument(); + restClient.onCoreAPI().usingResource(document).rateStarsToDocument(5); restClient.authenticateUser(new UserModel("random user", "random password")); - restClient.usingResource(document).getLikeRating(); + restClient.onCoreAPI().usingResource(document).getLikeRating(); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(ErrorModel.AUTHENTICATION_FAILED); - restClient.usingResource(document).getFiveStarRating(); + restClient.onCoreAPI().usingResource(document).getFiveStarRating(); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(ErrorModel.AUTHENTICATION_FAILED); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java index 1355d4f39..0d399f2a9 100644 --- a/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java @@ -25,8 +25,11 @@ public class AddSiteMemberSanityTests extends RestTest { adminUserModel = dataUser.getAdminUser(); siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, + UserRole.SiteManager, + UserRole.SiteCollaborator, + UserRole.SiteConsumer, + UserRole.SiteContributor); } @@ -37,7 +40,7 @@ public class AddSiteMemberSanityTests extends RestTest UserModel testUser = dataUser.createRandomTestUser("testUser"); testUser.setUserRole(UserRole.SiteConsumer); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.usingSite(siteModel).addPerson(testUser) + restClient.onCoreAPI().usingSite(siteModel).addPerson(testUser) .assertThat().field("id").is(testUser.getUsername()) .and().field("role").is(testUser.getUserRole()); restClient.assertStatusCodeIs(HttpStatus.CREATED); @@ -50,7 +53,7 @@ public class AddSiteMemberSanityTests extends RestTest UserModel testUser = dataUser.createRandomTestUser("testUser"); testUser.setUserRole(UserRole.SiteConsumer); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .usingSite(siteModel).addPerson(testUser); + .onCoreAPI().usingSite(siteModel).addPerson(testUser); restClient.assertLastError().containsSummary("Permission was denied"); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); @@ -63,7 +66,7 @@ public class AddSiteMemberSanityTests extends RestTest UserModel testUser = dataUser.createRandomTestUser("testUser"); testUser.setUserRole(UserRole.SiteConsumer); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) - .usingSite(siteModel).addPerson(testUser); + .onCoreAPI().usingSite(siteModel).addPerson(testUser); restClient.assertLastError().containsSummary("Permission was denied"); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); } @@ -75,7 +78,7 @@ public class AddSiteMemberSanityTests extends RestTest UserModel testUser = dataUser.createRandomTestUser("testUser"); testUser.setUserRole(UserRole.SiteConsumer); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .usingSite(siteModel).addPerson(testUser); + .onCoreAPI().usingSite(siteModel).addPerson(testUser); restClient.assertLastError().containsSummary("Permission was denied"); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); } @@ -87,7 +90,7 @@ public class AddSiteMemberSanityTests extends RestTest UserModel testUser = dataUser.createRandomTestUser("testUser"); testUser.setUserRole(UserRole.SiteConsumer); restClient.authenticateUser(adminUserModel) - .usingSite(siteModel).addPerson(testUser) + .onCoreAPI().usingSite(siteModel).addPerson(testUser) .and().field("id").is(testUser.getUsername()) .and().field("role").is(testUser.getUserRole()); restClient.assertStatusCodeIs(HttpStatus.CREATED); @@ -101,7 +104,7 @@ public class AddSiteMemberSanityTests extends RestTest testUser.setUserRole(UserRole.SiteConsumer); UserModel inexistentUser = new UserModel("inexistent user", "inexistent password"); restClient.authenticateUser(inexistentUser) - .usingSite(siteModel).addPerson(testUser); + .onCoreAPI().usingSite(siteModel).addPerson(testUser); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java index 4901b2e20..da6df431b 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java @@ -40,8 +40,8 @@ public class GetSiteContainerSanityTests extends RestTest public void getSiteContainerWithManagerRole() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - siteContainerModel = restClient.usingSite(siteModel).getSiteContainers().getOneRandomEntry(); - restClient.usingSite(siteModel).getSiteContainer(siteContainerModel.onModel()) + siteContainerModel = restClient.onCoreAPI().usingSite(siteModel).getSiteContainers().getOneRandomEntry(); + restClient.onCoreAPI().usingSite(siteModel).getSiteContainer(siteContainerModel.onModel()) .assertThat().field("id").is(siteContainerModel.onModel().getId()) .and().field("folderId").is(siteContainerModel.onModel().getFolderId()); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -52,8 +52,8 @@ public class GetSiteContainerSanityTests extends RestTest public void getSiteContainerWithCollaboratorRole() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - siteContainerModel = restClient.usingSite(siteModel).getSiteContainers().getOneRandomEntry(); - restClient.usingSite(siteModel).getSiteContainer(siteContainerModel.onModel()) + siteContainerModel = restClient.onCoreAPI().usingSite(siteModel).getSiteContainers().getOneRandomEntry(); + restClient.onCoreAPI().usingSite(siteModel).getSiteContainer(siteContainerModel.onModel()) .and().field("id").is(siteContainerModel.onModel().getId()) .and().field("folderId").is(siteContainerModel.onModel().getFolderId()); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -64,8 +64,8 @@ public class GetSiteContainerSanityTests extends RestTest public void getSiteContainerWithContributorRole() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - siteContainerModel = restClient.usingSite(siteModel).getSiteContainers().getOneRandomEntry(); - restClient.usingSite(siteModel).getSiteContainer(siteContainerModel.onModel()) + siteContainerModel = restClient.onCoreAPI().usingSite(siteModel).getSiteContainers().getOneRandomEntry(); + restClient.onCoreAPI().usingSite(siteModel).getSiteContainer(siteContainerModel.onModel()) .assertThat().field("id").is(siteContainerModel.onModel().getId()) .and().field("folderId").is(siteContainerModel.onModel().getFolderId()); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -76,8 +76,8 @@ public class GetSiteContainerSanityTests extends RestTest public void getSiteContainerWithConsumerRole() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - siteContainerModel = restClient.usingSite(siteModel).getSiteContainers().getOneRandomEntry(); - restClient.usingSite(siteModel).getSiteContainer(siteContainerModel.onModel()) + siteContainerModel = restClient.onCoreAPI().usingSite(siteModel).getSiteContainers().getOneRandomEntry(); + restClient.onCoreAPI().usingSite(siteModel).getSiteContainer(siteContainerModel.onModel()) .assertThat().field("id").is(siteContainerModel.onModel().getId()) .and().field("folderId").is(siteContainerModel.onModel().getFolderId()); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -88,8 +88,8 @@ public class GetSiteContainerSanityTests extends RestTest public void getSiteContainerWithAdminUser() throws Exception { restClient.authenticateUser(adminUserModel); - siteContainerModel = restClient.usingSite(siteModel).getSiteContainers().getOneRandomEntry(); - restClient.usingSite(siteModel).getSiteContainer(siteContainerModel.onModel()) + siteContainerModel = restClient.onCoreAPI().usingSite(siteModel).getSiteContainers().getOneRandomEntry(); + restClient.onCoreAPI().usingSite(siteModel).getSiteContainer(siteContainerModel.onModel()) .assertThat().field("id").is(siteContainerModel.onModel().getId()) .and().field("folderId").is(siteContainerModel.onModel().getFolderId()); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -102,12 +102,12 @@ public class GetSiteContainerSanityTests extends RestTest public void unauthenticatedUserIsNotAuthorizedToRetrieveSiteContainer() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - siteContainerModel = restClient.usingSite(siteModel).getSiteContainers().getOneRandomEntry(); + siteContainerModel = restClient.onCoreAPI().usingSite(siteModel).getSiteContainers().getOneRandomEntry(); userModel = dataUser.createRandomTestUser(); userModel.setPassword("user wrong password"); dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); restClient.authenticateUser(userModel) - .usingSite(siteModel).getSiteContainer(siteContainerModel.onModel()); + .onCoreAPI().usingSite(siteModel).getSiteContainer(siteContainerModel.onModel()); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java index 90a642cef..9640b97a2 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java @@ -47,7 +47,7 @@ public class GetSiteContainersSanityTests extends RestTest public void getSiteContainersWithManagerRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.usingSite(siteModel).getSiteContainers() + restClient.onCoreAPI().usingSite(siteModel).getSiteContainers() .assertThat().entriesListIsNotEmpty() .assertThat().paginationExist() .and().paginationField("count").isNot("0"); @@ -59,10 +59,10 @@ public class GetSiteContainersSanityTests extends RestTest public void getSiteContainersWithCollaboratorRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.usingSite(siteModel).getSiteContainers() - .assertThat().entriesListIsNotEmpty() - .assertThat().paginationExist() - .and().paginationField("count").isNot("0"); + restClient.onCoreAPI().usingSite(siteModel).getSiteContainers() + .assertThat().entriesListIsNotEmpty() + .assertThat().paginationExist() + .and().paginationField("count").isNot("0"); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -71,10 +71,10 @@ public class GetSiteContainersSanityTests extends RestTest public void getSiteContainersWithContributorRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - restClient.usingSite(siteModel).getSiteContainers() - .assertThat().entriesListIsNotEmpty() - .assertThat().paginationExist() - .and().paginationField("count").isNot("0"); + restClient.onCoreAPI().usingSite(siteModel).getSiteContainers() + .assertThat().entriesListIsNotEmpty() + .assertThat().paginationExist() + .and().paginationField("count").isNot("0"); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -83,10 +83,10 @@ public class GetSiteContainersSanityTests extends RestTest public void getSiteContainersWithConsumerRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.usingSite(siteModel).getSiteContainers() - .assertThat().entriesListIsNotEmpty() - .assertThat().paginationExist() - .and().paginationField("count").isNot("0"); + restClient.onCoreAPI().usingSite(siteModel).getSiteContainers() + .assertThat().entriesListIsNotEmpty() + .assertThat().paginationExist() + .and().paginationField("count").isNot("0"); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -95,10 +95,10 @@ public class GetSiteContainersSanityTests extends RestTest public void getSiteContainersWithAdminUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); - restClient.usingSite(siteModel).getSiteContainers() - .assertThat().entriesListIsNotEmpty() - .assertThat().paginationExist() - .and().paginationField("count").isNot("0"); + restClient.onCoreAPI().usingSite(siteModel).getSiteContainers() + .assertThat().entriesListIsNotEmpty() + .assertThat().paginationExist() + .and().paginationField("count").isNot("0"); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -110,8 +110,8 @@ public class GetSiteContainersSanityTests extends RestTest userModel = dataUser.createRandomTestUser(); userModel.setPassword("user wrong password"); dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); - restClient.authenticateUser(userModel); - restClient.usingSite(siteModel).getSiteContainers(); + restClient.authenticateUser(userModel) + .onCoreAPI().usingSite(siteModel).getSiteContainers(); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java index c31c5dc19..c9fdb171c 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java @@ -42,7 +42,7 @@ public class GetSiteMemberSanityTests extends RestTest public void getSiteMemberWithManagerRole() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.usingSite(siteModel).getSiteMember(userModel) + restClient.onCoreAPI().usingSite(siteModel).getSiteMember(userModel) .assertThat().field("id").is(userModel.getUsername()) .and().field("role").is(userModel.getUserRole()); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -53,7 +53,7 @@ public class GetSiteMemberSanityTests extends RestTest public void getSiteMemberWithCollaboratorRole() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.usingSite(siteModel).getSiteMember(userModel) + restClient.onCoreAPI().usingSite(siteModel).getSiteMember(userModel) .and().field("id").is(userModel.getUsername()) .and().field("role").is(userModel.getUserRole()); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -64,7 +64,7 @@ public class GetSiteMemberSanityTests extends RestTest public void getSiteMemberWithContributorRole() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - restClient.usingSite(siteModel).getSiteMember(userModel) + restClient.onCoreAPI().usingSite(siteModel).getSiteMember(userModel) .and().field("id").is(userModel.getUsername()) .and().field("role").is(userModel.getUserRole()); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -75,7 +75,7 @@ public class GetSiteMemberSanityTests extends RestTest public void getSiteMemberWithConsumerRole() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.usingSite(siteModel).getSiteMember(userModel) + restClient.onCoreAPI().usingSite(siteModel).getSiteMember(userModel) .and().field("id").is(userModel.getUsername()) .and().field("role").is(userModel.getUserRole()); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -86,7 +86,7 @@ public class GetSiteMemberSanityTests extends RestTest public void getSiteMemberWithAdminUser() throws Exception { restClient.authenticateUser(adminUser); - restClient.usingSite(siteModel).getSiteMember(userModel) + restClient.onCoreAPI().usingSite(siteModel).getSiteMember(userModel) .and().field("id").is(userModel.getUsername()) .and().field("role").is(userModel.getUserRole()); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -99,7 +99,7 @@ public class GetSiteMemberSanityTests extends RestTest { UserModel inexistentUser = new UserModel("inexistent user", "inexistent password"); restClient.authenticateUser(inexistentUser); - restClient.usingSite(siteModel).getSiteMember(userModel); + restClient.onCoreAPI().usingSite(siteModel).getSiteMember(userModel); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java index f0f301b95..6d8290986 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java @@ -48,7 +48,7 @@ public class GetSiteMembersSanityTests extends RestTest public void getSiteMembersWithManagerRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .usingSite(siteModel).getSiteMembers().assertThat().entriesListIsNotEmpty() + .onCoreAPI().usingSite(siteModel).getSiteMembers().assertThat().entriesListIsNotEmpty() .and().entriesListContains("id", usersWithRoles.getOneUserWithRole(UserRole.SiteManager).getUsername()) .and().entriesListContains("role", usersWithRoles.getOneUserWithRole(UserRole.SiteManager).getUserRole().toString()); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -59,7 +59,7 @@ public class GetSiteMembersSanityTests extends RestTest public void getSiteMembersWithCollaboratorRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .usingSite(siteModel).getSiteMembers().assertThat().entriesListIsNotEmpty().assertThat() + .onCoreAPI().usingSite(siteModel).getSiteMembers().assertThat().entriesListIsNotEmpty().assertThat() .entriesListContains("id", usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator).getUsername()).and() .entriesListContains("role", usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator).getUserRole().toString()); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -70,7 +70,7 @@ public class GetSiteMembersSanityTests extends RestTest public void getSiteMembersWithContributorRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) - .usingSite(siteModel).getSiteMembers().assertThat().entriesListIsNotEmpty() + .onCoreAPI().usingSite(siteModel).getSiteMembers().assertThat().entriesListIsNotEmpty() .and().entriesListContains("id", usersWithRoles.getOneUserWithRole(UserRole.SiteContributor).getUsername()) .and().entriesListContains("role", usersWithRoles.getOneUserWithRole(UserRole.SiteContributor).getUserRole().toString()); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -81,7 +81,7 @@ public class GetSiteMembersSanityTests extends RestTest public void getSiteMembersWithConsumerRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .usingSite(siteModel).getSiteMembers().assertThat().entriesListIsNotEmpty() + .onCoreAPI().usingSite(siteModel).getSiteMembers().assertThat().entriesListIsNotEmpty() .and().entriesListContains("id", usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer).getUsername()) .and().entriesListContains("role", usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer).getUserRole().toString()); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -92,7 +92,7 @@ public class GetSiteMembersSanityTests extends RestTest public void getSiteMembersWithAdminUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUser) - .usingSite(siteModel).getSiteMembers().assertThat().entriesListIsNotEmpty() + .onCoreAPI().usingSite(siteModel).getSiteMembers().assertThat().entriesListIsNotEmpty() .and().entriesListContains("id", adminUser.getUsername()) .when().assertThat().entriesListContains("role", "SiteManager"); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -107,7 +107,7 @@ public class GetSiteMembersSanityTests extends RestTest userModel.setPassword("user wrong password"); dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); restClient.authenticateUser(userModel) - .usingSite(siteModel).getSiteMembers(); + .onCoreAPI().usingSite(siteModel).getSiteMembers(); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteSanityTests.java index e7ebcef66..0db1549e9 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteSanityTests.java @@ -50,7 +50,7 @@ public class GetSiteSanityTests extends RestTest public void getSiteWithManagerRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .usingSite(siteModel) + .onCoreAPI().usingSite(siteModel) .getSite() .and().field("id").is(siteModel.getId()) .and().field("title").is(siteModel.getTitle()); @@ -63,7 +63,7 @@ public class GetSiteSanityTests extends RestTest public void getSiteWithCollaboratorRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .usingSite(siteModel) + .onCoreAPI().usingSite(siteModel) .getSite() .and().field("id").is(siteModel.getId()) .and().field("title").is(siteModel.getTitle()); @@ -75,7 +75,7 @@ public class GetSiteSanityTests extends RestTest public void getSiteWithContributorRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) - .usingSite(siteModel) + .onCoreAPI().usingSite(siteModel) .getSite() .and().field("id").is(siteModel.getId()) .and().field("title").is(siteModel.getTitle()); @@ -87,7 +87,7 @@ public class GetSiteSanityTests extends RestTest public void getSiteWithConsumerRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .usingSite(siteModel) + .onCoreAPI().usingSite(siteModel) .getSite() .and().field("id").is(siteModel.getId()) .and().field("title").is(siteModel.getTitle()); @@ -99,7 +99,7 @@ public class GetSiteSanityTests extends RestTest public void getSiteWithAdminRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel) - .usingSite(siteModel) + .onCoreAPI().usingSite(siteModel) .getSite() .and().field("id").is(siteModel.getId()) .and().field("title").is(siteModel.getTitle()); @@ -115,7 +115,8 @@ public class GetSiteSanityTests extends RestTest userModel.setPassword("user wrong password"); dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); restClient.authenticateUser(userModel).withParams("maxItems=10000") - .getSites(); + .onCoreAPI() + .getSites(); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java index f8fb6163b..6b89c4515 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java @@ -48,7 +48,7 @@ public class GetSitesSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .getSites() + .onCoreAPI().getSites() .assertThat().entriesListIsNotEmpty() .assertThat().entriesListContains("id", siteModel.getId()) .and().paginationExist(); @@ -60,7 +60,7 @@ public class GetSitesSanityTests extends RestTest public void collaboratorIsAbleToRetrieveSites() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .getSites().assertThat().entriesListIsNotEmpty() + .onCoreAPI().getSites().assertThat().entriesListIsNotEmpty() .assertThat().entriesListContains("id", siteModel.getId()) .and().paginationExist(); @@ -73,7 +73,7 @@ public class GetSitesSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) - .getSites() + .onCoreAPI().getSites() .assertThat().entriesListIsNotEmpty() .assertThat().entriesListContains("id", siteModel.getId()) .and().paginationExist(); @@ -86,7 +86,7 @@ public class GetSitesSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .getSites() + .onCoreAPI().getSites() .assertThat().entriesListIsNotEmpty() .assertThat().entriesListContains("id", siteModel.getId()) .and().paginationExist(); @@ -98,7 +98,7 @@ public class GetSitesSanityTests extends RestTest public void adminUserIsAbleToRetrieveSites() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel) - .getSites() + .onCoreAPI().getSites() .assertThat().entriesListIsNotEmpty() .assertThat().entriesListContains("id", siteModel.getId()) .and().paginationExist(); @@ -115,7 +115,7 @@ public class GetSitesSanityTests extends RestTest userModel.setPassword("user wrong password"); dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); restClient.authenticateUser(userModel) - .getSites(); + .onCoreAPI().getSites(); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java index 70acd3ad6..27942c321 100644 --- a/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java @@ -49,9 +49,9 @@ public class RemoveSiteMemberSanityTests extends RestTest description = "Verify that site manager can delete site member and gets status code 204, 'No Content'") public void siteManagerIsAbleToDeleteSiteMember() throws Exception{ restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.usingSite(siteModel).deleteSiteMember(testUserModel); + restClient.onCoreAPI().usingSite(siteModel).deleteSiteMember(testUserModel); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.getSites().assertThat().entriesListDoesNotContain("id", testUserModel.getUsername()); + restClient.onCoreAPI().getSites().assertThat().entriesListDoesNotContain("id", testUserModel.getUsername()); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -60,10 +60,10 @@ public class RemoveSiteMemberSanityTests extends RestTest description = "Verify that site collaborator cannot delete site member and gets status code 403, 'Forbidden'") public void siteCollaboratorIsNotAbleToDeleteSiteMember() throws Exception{ restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.usingSite(siteModel).deleteSiteMember(testUserModel); + restClient.onCoreAPI().usingSite(siteModel).deleteSiteMember(testUserModel); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - restClient.getSites().assertThat().entriesListContains("id", testUserModel.getUsername()); + restClient.onCoreAPI().getSites().assertThat().entriesListContains("id", testUserModel.getUsername()); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -72,10 +72,10 @@ public class RemoveSiteMemberSanityTests extends RestTest description = "Verify that site contributor cannot delete site member and gets status code 403, 'Forbidden'") public void siteContributorIsNotAbleToDeleteSiteMember() throws Exception{ restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - restClient.usingSite(siteModel).deleteSiteMember(testUserModel); + restClient.onCoreAPI().usingSite(siteModel).deleteSiteMember(testUserModel); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - restClient.getSites().assertThat().entriesListContains("id", testUserModel.getUsername()); + restClient.onCoreAPI().getSites().assertThat().entriesListContains("id", testUserModel.getUsername()); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -84,10 +84,10 @@ public class RemoveSiteMemberSanityTests extends RestTest description = "Verify that site consumer cannot delete site member and gets status code 403, 'Forbidden'") public void siteConsumerIsNotAbleToDeleteSiteMember() throws Exception{ restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .usingSite(siteModel).deleteSiteMember(testUserModel); + .onCoreAPI().usingSite(siteModel).deleteSiteMember(testUserModel); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - restClient.getSites().assertThat().entriesListContains("id", testUserModel.getUsername()); + restClient.onCoreAPI().getSites().assertThat().entriesListContains("id", testUserModel.getUsername()); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -95,10 +95,10 @@ public class RemoveSiteMemberSanityTests extends RestTest description = "Verify that admin user can delete site member and gets status code 204, 'No Content'") public void adminUserIsAbleToDeleteSiteMember() throws Exception{ restClient.authenticateUser(adminUserModel) - .usingSite(siteModel).deleteSiteMember(testUserModel); + .onCoreAPI().usingSite(siteModel).deleteSiteMember(testUserModel); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.getSites().assertThat().entriesListDoesNotContain("id", testUserModel.getUsername()); + restClient.onCoreAPI().getSites().assertThat().entriesListDoesNotContain("id", testUserModel.getUsername()); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -107,7 +107,7 @@ public class RemoveSiteMemberSanityTests extends RestTest public void unauthenticatedUserIsNotAuthorizedToDeleteSiteMember() throws Exception{ UserModel inexistentUser = new UserModel("inexistent user", "inexistent password"); restClient.authenticateUser(inexistentUser) - .usingSite(siteModel).deleteSiteMember(testUserModel); + .onCoreAPI().usingSite(siteModel).deleteSiteMember(testUserModel); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } diff --git a/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java index 2c57f1d92..297155c7e 100644 --- a/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java @@ -38,7 +38,7 @@ public class UpdateSiteMemberSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); testUserModel.setUserRole(UserRole.SiteConsumer); - restClient.usingSite(siteModel).updateSiteMember(testUserModel) + restClient.onCoreAPI().usingSite(siteModel).updateSiteMember(testUserModel) .assertThat().field("id").is(testUserModel.getUsername()) .and().field("role").is(testUserModel.getUserRole()); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -51,7 +51,7 @@ public class UpdateSiteMemberSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); testUserModel.setUserRole(UserRole.SiteCollaborator); - restClient.usingSite(siteModel).updateSiteMember(testUserModel); + restClient.onCoreAPI().usingSite(siteModel).updateSiteMember(testUserModel); restClient.assertLastError() .containsSummary(String.format("The current user does not have permissions to modify the membership details of the site %s.", siteModel.getTitle())); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); @@ -64,7 +64,7 @@ public class UpdateSiteMemberSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); testUserModel.setUserRole(UserRole.SiteCollaborator); - restClient.usingSite(siteModel).updateSiteMember(testUserModel); + restClient.onCoreAPI().usingSite(siteModel).updateSiteMember(testUserModel); restClient.assertLastError() .containsSummary(String.format("The current user does not have permissions to modify the membership details of the site %s.", siteModel.getTitle())); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); @@ -77,7 +77,7 @@ public class UpdateSiteMemberSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); testUserModel.setUserRole(UserRole.SiteCollaborator); - restClient.usingSite(siteModel).updateSiteMember(testUserModel); + restClient.onCoreAPI().usingSite(siteModel).updateSiteMember(testUserModel); restClient.assertLastError() .containsSummary(String.format("The current user does not have permissions to modify the membership details of the site %s.", siteModel.getTitle())); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); @@ -89,7 +89,7 @@ public class UpdateSiteMemberSanityTests extends RestTest { restClient.authenticateUser(adminUserModel); testUserModel.setUserRole(UserRole.SiteCollaborator); - restClient.usingSite(siteModel).updateSiteMember(testUserModel) + restClient.onCoreAPI().usingSite(siteModel).updateSiteMember(testUserModel) .assertThat().field("id").is(testUserModel.getUsername()) .and().field("role").is(testUserModel.getUserRole()); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -102,7 +102,7 @@ public class UpdateSiteMemberSanityTests extends RestTest UserModel inexistentUser = new UserModel("inexistent user", "inexistent password"); restClient.authenticateUser(inexistentUser); testUserModel.setUserRole(UserRole.SiteCollaborator); - restClient.usingSite(siteModel).updateSiteMember(testUserModel); + restClient.onCoreAPI().usingSite(siteModel).updateSiteMember(testUserModel); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java index f0f6a2cef..c5acd11dd 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java @@ -29,14 +29,14 @@ public class GetProcessDefinitionImageSanityTests extends RestWorkflowTest { testUser = dataUser.createRandomTestUser(); restClient.authenticateUser(dataUser.getAdminUser()); - randomProcessDefinition = restClient.getAllProcessDefinitions().getOneRandomEntry(); + randomProcessDefinition = restClient.onWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry(); } @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.SANITY, description = "Verify Any user gets a specific process definition image for non-network deployments using REST API and status code is OK (200)") public void anyUserGetsProcessDefinitionImage() throws Exception { restClient.authenticateUser(testUser); - restClient.usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionImage() + restClient.onWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionImage() .assertResponseContainsImage(); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -44,7 +44,7 @@ public class GetProcessDefinitionImageSanityTests extends RestWorkflowTest @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets a specific process definition image for non-network deployments using REST API and status code is OK (200)") public void adminGetsProcessDefinitionImage() throws Exception { - restClient.usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionImage() + restClient.onWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionImage() .assertResponseContainsImage(); restClient.assertStatusCodeIs(HttpStatus.OK); } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java index edd668b68..31ec535c9 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java @@ -28,7 +28,7 @@ public class GetProcessDefinitionSanityTests extends RestWorkflowTest { testUser = dataUser.createRandomTestUser(); restClient.authenticateUser(dataUser.getAdminUser()); - randomProcessDefinition = restClient.getAllProcessDefinitions().getOneRandomEntry(); + randomProcessDefinition = restClient.onWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry(); } @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, @@ -36,9 +36,9 @@ public class GetProcessDefinitionSanityTests extends RestWorkflowTest description = "Verify Admin user gets a specific process definition for non-network deployments using REST API and status code is OK (200)") public void adminGetsProcessDefinition() throws Exception { - restClient.usingProcessDefinitions(randomProcessDefinition).getProcessDefinition(). + restClient.onWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinition(). assertThat().field("name").is(randomProcessDefinition.onModel().getName()); - restClient.usingProcessDefinitions(randomProcessDefinition).getProcessDefinition().assertThat().field("name") + restClient.onWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinition().assertThat().field("name") .is(randomProcessDefinition.onModel().getName()); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -49,7 +49,7 @@ public class GetProcessDefinitionSanityTests extends RestWorkflowTest public void anyUserGetsProcessDefinition() throws Exception { restClient.authenticateUser(testUser); - restClient.usingProcessDefinitions(randomProcessDefinition).getProcessDefinition().assertThat().field("name") + restClient.onWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinition().assertThat().field("name") .is(randomProcessDefinition.onModel().getName()); restClient.assertStatusCodeIs(HttpStatus.OK); } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java index 710bf7bdc..8365ce963 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java @@ -37,8 +37,8 @@ public class GetProcessDefinitionStartFormModelSanityTests extends RestWorkflowT description = "Verify Admin gets a model of the start form type definition for non-network deployments using REST API and status code is OK (200)") public void nonNetworkAdminGetsStartFormModel() throws Exception { - randomProcessDefinition = restClient.getAllProcessDefinitions().getOneRandomEntry(); - restClient.usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionStartFormModel().assertThat().entriesListIsNotEmpty(); + randomProcessDefinition = restClient.onWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry(); + restClient.onWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionStartFormModel().assertThat().entriesListIsNotEmpty(); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -50,8 +50,8 @@ public class GetProcessDefinitionStartFormModelSanityTests extends RestWorkflowT { restClient.usingTenant().createTenant(adminTenantUser); restClient.authenticateUser(adminTenantUser); - randomProcessDefinition = restClient.getAllProcessDefinitions().getOneRandomEntry(); - restClient.usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionStartFormModel().assertThat().entriesListIsNotEmpty(); + randomProcessDefinition = restClient.onWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry(); + restClient.onWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionStartFormModel().assertThat().entriesListIsNotEmpty(); restClient.assertStatusCodeIs(HttpStatus.OK); } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemSanityTests.java index d14fa629d..1c049439c 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemSanityTests.java @@ -5,7 +5,11 @@ import org.alfresco.rest.RestWorkflowTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestItemModel; import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.utility.model.*; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FileType; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; @@ -43,8 +47,8 @@ public class AddProcessItemSanityTests extends RestWorkflowTest document2 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file content"); dataContent.usingSite(siteModel).createContent(document2); - processModel = restClient.authenticateUser(adminUser).getProcesses().getOneRandomEntry().onModel(); - processItem = restClient.usingProcess(processModel).addProcessItem(document2); + processModel = restClient.authenticateUser(adminUser).onWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processItem = restClient.onWorkflowAPI().usingProcess(processModel).addProcessItem(document2); restClient.assertStatusCodeIs(HttpStatus.CREATED); processItem.assertThat().field("createdAt").isNotEmpty() .and().field("size").is(document2.getContent().length()) @@ -55,7 +59,7 @@ public class AddProcessItemSanityTests extends RestWorkflowTest .and().field("id").isNotEmpty() .and().field("mimeType").is(document2.getFileType().mimeType); - restClient.usingProcess(processModel).getProcessItems() + restClient.onWorkflowAPI().usingProcess(processModel).getProcessItems() .assertThat().entriesListContains("id", processItem.getId()); } @@ -66,8 +70,8 @@ public class AddProcessItemSanityTests extends RestWorkflowTest { document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - processModel = restClient.authenticateUser(adminUser).getProcesses().getOneRandomEntry().onModel(); - processItem = restClient.usingProcess(processModel).addProcessItem(document2); + processModel = restClient.authenticateUser(adminUser).onWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processItem = restClient.onWorkflowAPI().usingProcess(processModel).addProcessItem(document2); restClient.assertStatusCodeIs(HttpStatus.CREATED); processItem.assertThat().field("createdAt").isNotEmpty() .and().field("size").is("19") @@ -78,10 +82,10 @@ public class AddProcessItemSanityTests extends RestWorkflowTest .and().field("id").isNotEmpty() .and().field("mimeType").is(document2.getFileType().mimeType); - restClient.usingProcess(processModel).getProcessItems() + restClient.onWorkflowAPI().usingProcess(processModel).getProcessItems() .assertThat().entriesListContains("id", processItem.getId()) .and().entriesListContains("name", document2.getName()); - restClient.usingProcess(processModel).addProcessItem(document2); + restClient.onWorkflowAPI().usingProcess(processModel).addProcessItem(document2); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessSanityTests.java index 4d344c150..8538292a7 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessSanityTests.java @@ -9,7 +9,6 @@ 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.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.Test; @@ -31,12 +30,12 @@ public class AddProcessSanityTests extends RestWorkflowTest userWhoStartsProcess = dataUser.createRandomTestUser(); assignee = dataUser.createRandomTestUser(); - addedProcess = restClient.authenticateUser(userWhoStartsProcess).addProcess("activitiAdhoc", assignee, false, Priority.Normal); + addedProcess = restClient.authenticateUser(userWhoStartsProcess).onWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); restClient.assertStatusCodeIs(HttpStatus.CREATED); addedProcess.assertThat().field("id").is(addedProcess.getId()) .and().field("startUserId").is(addedProcess.getStartUserId()); - processes = restClient.getProcesses(); + processes = restClient.onWorkflowAPI().getProcesses(); restClient.assertStatusCodeIs(HttpStatus.OK); processes.assertThat().entriesListContains("id", addedProcess.getId()); } @@ -52,12 +51,12 @@ public class AddProcessSanityTests extends RestWorkflowTest tenantUserWhoStartsProcess = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); tenantAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("u2Tenant"); - addedProcess = restClient.authenticateUser(tenantUserWhoStartsProcess).addProcess("activitiAdhoc", tenantAssignee, false, Priority.Normal); + addedProcess = restClient.authenticateUser(tenantUserWhoStartsProcess).onWorkflowAPI().addProcess("activitiAdhoc", tenantAssignee, false, Priority.Normal); restClient.assertStatusCodeIs(HttpStatus.CREATED); addedProcess.assertThat().field("id").is(addedProcess.getId()) .and().field("startUserId").is(addedProcess.getStartUserId()); - processes = restClient.getProcesses(); + processes = restClient.onWorkflowAPI().getProcesses(); restClient.assertStatusCodeIs(HttpStatus.OK); processes.assertThat().entriesListContains("id", addedProcess.getId()); } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java index 56b9dc944..007e4871e 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java @@ -1,7 +1,7 @@ package org.alfresco.rest.workflow.processes; -import org.alfresco.dataprep.CMISUtil.Priority; import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.dataprep.CMISUtil.Priority; import org.alfresco.rest.RestWorkflowTest; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.rest.model.RestProcessVariableModel; @@ -44,15 +44,15 @@ public class AddProcessVariableSanityTests extends RestWorkflowTest public void addProcessVariable() throws Exception { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(userWhoStartsTask).getProcesses().getOneRandomEntry().onModel(); + processModel = restClient.authenticateUser(userWhoStartsTask).onWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - processVariable = restClient.usingProcess(processModel).addProcessVariable(variableModel); + processVariable = restClient.onWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); processVariable.assertThat().field("name").is(variableModel.getName()) .and().field("type").is(variableModel.getType()) .and().field("value").is(variableModel.getValue()); - restClient.usingProcess(processModel).getProcessVariables() + restClient.onWorkflowAPI().usingProcess(processModel).getProcessVariables() .assertThat().entriesListContains("name", processVariable.getName()); } @@ -61,8 +61,8 @@ public class AddProcessVariableSanityTests extends RestWorkflowTest public void updateExistingProcessVariable() throws Exception { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(userWhoStartsTask).getProcesses().getOneRandomEntry().onModel(); - processVariable = restClient.usingProcess(processModel).addProcessVariable(variableModel); + processModel = restClient.authenticateUser(userWhoStartsTask).onWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processVariable = restClient.onWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); processVariable.assertThat().field("name").is(variableModel.getName()) .and().field("type").is(variableModel.getType()) @@ -70,7 +70,7 @@ public class AddProcessVariableSanityTests extends RestWorkflowTest String newValue = RandomData.getRandomName("value"); variableModel.setValue(newValue); - processVariable = restClient.usingProcess(processModel).addProcessVariable(variableModel); + processVariable = restClient.onWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); processVariable.assertThat().field("value").is(newValue); } @@ -85,10 +85,10 @@ public class AddProcessVariableSanityTests extends RestWorkflowTest tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); - restClient.authenticateUser(tenantUser).addProcess("activitiAdhoc", tenantUserAssignee, false, Priority.Normal); + restClient.authenticateUser(tenantUser).onWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee, false, Priority.Normal); variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(adminTenantUser).getProcesses().getOneRandomEntry().onModel(); - processVariable = restClient.usingProcess(processModel).addProcessVariable(variableModel); + processModel = restClient.authenticateUser(adminTenantUser).onWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processVariable = restClient.onWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); processVariable.assertThat().field("name").is(variableModel.getName()) .and().field("type").is(variableModel.getType()) @@ -100,8 +100,8 @@ public class AddProcessVariableSanityTests extends RestWorkflowTest public void failedAddingProcessVariableIfInvalidBodyIsProvided() throws Exception { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("incorrect type"); - processModel = restClient.authenticateUser(adminUser).getProcesses().getOneRandomEntry().onModel(); - restClient.usingProcess(processModel).addProcessVariable(variableModel); + processModel = restClient.authenticateUser(adminUser).onWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + restClient.onWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) .assertLastError().containsSummary("Unsupported type of variable: 'incorrect type'."); } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java index 437f5c0bd..392a58f27 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java @@ -32,35 +32,35 @@ public class DeleteProcessSanityTests extends RestWorkflowTest TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify User is able to delete process started by him using REST API and status code is OK (204)") public void deleteProcessByUserWhoStartedProcess() throws Exception { - process = restClient.authenticateUser(userWhoAddsProcess).addProcess("activitiAdhoc", assignee, false, Priority.Normal); + process = restClient.authenticateUser(userWhoAddsProcess).onWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.usingProcess(process).deleteProcess(); + restClient.onWorkflowAPI().usingProcess(process).deleteProcess(); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.getProcesses().assertThat().entriesListDoesNotContain("id", process.getId()); + restClient.onWorkflowAPI().getProcesses().assertThat().entriesListDoesNotContain("id", process.getId()); } @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify User is able to delete process assigned to him using REST API and status code is OK (204)") public void deleteProcessByAssignedUser() throws Exception { - process = restClient.authenticateUser(userWhoAddsProcess).addProcess("activitiAdhoc", assignee, false, Priority.Normal); + process = restClient.authenticateUser(userWhoAddsProcess).onWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.authenticateUser(assignee).usingProcess(process).deleteProcess(); + restClient.authenticateUser(assignee).onWorkflowAPI().usingProcess(process).deleteProcess(); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.getProcesses().assertThat().entriesListDoesNotContain("id", process.getId()); + restClient.onWorkflowAPI().getProcesses().assertThat().entriesListDoesNotContain("id", process.getId()); } @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify User that is not involved in a process is not authorized to delete it using REST API and status code is 403") public void deleteProcessByAnotherUser() throws Exception { - process = restClient.authenticateUser(userWhoAddsProcess).addProcess("activitiAdhoc", assignee, false, Priority.Normal); + process = restClient.authenticateUser(userWhoAddsProcess).onWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.authenticateUser(anotherUser).usingProcess(process).deleteProcess(); + restClient.authenticateUser(anotherUser).onWorkflowAPI().usingProcess(process).deleteProcess(); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("user is not allowed to access information about process"); } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsSanityTests.java index 392fb21f2..835b4bade 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsSanityTests.java @@ -5,7 +5,6 @@ import org.alfresco.rest.RestWorkflowTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.rest.requests.Processes; -import org.alfresco.rest.requests.RestTenantApi; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksSanityTests.java index dee987533..62fdb5e6f 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksSanityTests.java @@ -41,7 +41,7 @@ public class GetProcessTasksSanityTests extends RestWorkflowTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify user who started the process gets all tasks of started process with Rest API and response is successfull (200)") public void userWhoStartedProcessCanGetProcessTasks() throws JsonToModelConversionException, Exception { - processTasks = restClient.authenticateUser(userModel).usingProcess(process).getProcessTasks(); + processTasks = restClient.authenticateUser(userModel).onWorkflowAPI().usingProcess(process).getProcessTasks(); restClient.assertStatusCodeIs(HttpStatus.OK); processTasks.assertThat() .entriesListIsNotEmpty().and() @@ -53,7 +53,7 @@ public class GetProcessTasksSanityTests extends RestWorkflowTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify any assignee user of the process gets all tasks of the process with Rest API and response is successfull (200)") public void assigneeUserCanGetAllProcessTasks() throws JsonToModelConversionException, Exception { - processTasks = restClient.authenticateUser(assignee1).usingProcess(process).getProcessTasks(); + processTasks = restClient.authenticateUser(assignee1).onWorkflowAPI().usingProcess(process).getProcessTasks(); restClient.assertStatusCodeIs(HttpStatus.OK); processTasks.assertThat() .entriesListContains("assignee", assignee1.getUsername()).and() @@ -68,7 +68,7 @@ public class GetProcessTasksSanityTests extends RestWorkflowTest .createMoreReviewersWorkflowAndAssignTo(assignee1, assignee2, assignee3); dataWorkflow.usingUser(assignee1).approveTask(process); - processTasks = restClient.authenticateUser(assignee2).usingProcess(process).getProcessTasks(); + processTasks = restClient.authenticateUser(assignee2).onWorkflowAPI().usingProcess(process).getProcessTasks(); restClient.assertStatusCodeIs(HttpStatus.OK); processTasks.assertThat() .entriesListIsNotEmpty().assertThat() diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesSanityTests.java index 4f2c8b35c..3ebb2cc8e 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesSanityTests.java @@ -41,8 +41,8 @@ public class GetProcessVariablesSanityTests extends RestWorkflowTest description = "Verify that user that started the process gets all process variables") public void getProcessVariablesUsingTheUserWhoStartedProcess() throws JsonToModelConversionException, Exception { - processModel = restClient.authenticateUser(userWhoStartsTask).getProcesses().getOneRandomEntry().onModel(); - variables = restClient.usingProcess(processModel).getProcessVariables(); + processModel = restClient.authenticateUser(userWhoStartsTask).onWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + variables = restClient.onWorkflowAPI().usingProcess(processModel).getProcessVariables(); restClient.assertStatusCodeIs(HttpStatus.OK); variables.assertThat().entriesListIsNotEmpty(); } @@ -51,8 +51,8 @@ public class GetProcessVariablesSanityTests extends RestWorkflowTest description = "Verify get all process variables call using a user that is involved in the process") public void getProcessVariablesUsingUserInvolvedInProcess() throws JsonToModelConversionException, Exception { - processModel = restClient.authenticateUser(assignee).getProcesses().getOneRandomEntry().onModel(); - variables = restClient.usingProcess(processModel).getProcessVariables(); + processModel = restClient.authenticateUser(assignee).onWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + variables = restClient.onWorkflowAPI().usingProcess(processModel).getProcessVariables(); restClient.assertStatusCodeIs(HttpStatus.OK); variables.assertThat().entriesListIsNotEmpty(); } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java index b7ce50dad..60c1eac9b 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java @@ -37,7 +37,7 @@ public class GetProcessesSanityTests extends RestWorkflowTest TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify User gets all processes started by him using REST API and status code is OK (200)") public void getProcessesByUserWhoStartedProcess() throws Exception { - allProcesses = restClient.authenticateUser(userWhoStartsTask).getProcesses(); + allProcesses = restClient.authenticateUser(userWhoStartsTask).onWorkflowAPI().getProcesses(); restClient.assertStatusCodeIs(HttpStatus.OK); allProcesses.assertThat().entriesListContains("id", task.getNodeRef()); } @@ -46,7 +46,7 @@ public class GetProcessesSanityTests extends RestWorkflowTest TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify User gets all processes assigned to him using REST API and status code is OK (200)") public void getProcessesByAssignedUser() throws Exception { - allProcesses = restClient.authenticateUser(assignee).getProcesses(); + allProcesses = restClient.authenticateUser(assignee).onWorkflowAPI().getProcesses(); restClient.assertStatusCodeIs(HttpStatus.OK); allProcesses.assertThat().entriesListContains("id", task.getNodeRef()); } @@ -55,7 +55,7 @@ public class GetProcessesSanityTests extends RestWorkflowTest TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify User that is not involved in a process can not get that process using REST API and status code is OK (200)") public void getProcessesByAnotherUser() throws Exception { - allProcesses = restClient.authenticateUser(anotherUser).getProcesses(); + allProcesses = restClient.authenticateUser(anotherUser).onWorkflowAPI().getProcesses(); restClient.assertStatusCodeIs(HttpStatus.OK); allProcesses.assertThat().entriesListDoesNotContain("id", task.getNodeRef()); } @@ -64,7 +64,7 @@ public class GetProcessesSanityTests extends RestWorkflowTest TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify Admin gets all processes, even if he isn't involved in a process, using REST API and status code is OK (200)") public void getProcessesByAdmin() throws Exception { - allProcesses = restClient.authenticateUser(dataUser.getAdminUser()).getProcesses(); + allProcesses = restClient.authenticateUser(dataUser.getAdminUser()).onWorkflowAPI().getProcesses(); restClient.assertStatusCodeIs(HttpStatus.OK); allProcesses.assertThat().entriesListContains("id", task.getNodeRef()); } From e296b0d61c504df99b7558df59ed14f5cae4afee Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Wed, 16 Nov 2016 16:05:04 +0200 Subject: [PATCH 0548/1491] rename from onCoreAPI to withCoreAPI, the same for onWorkflowAPI --- .../rest/comments/AddCommentSanityTests.java | 12 ++-- .../rest/comments/AddCommentsSanityTests.java | 12 ++-- .../comments/DeleteCommentsSanityTests.java | 14 ++-- .../rest/comments/GetCommentsSanityTests.java | 22 +++---- .../comments/UpdateCommentsSanityTests.java | 18 ++--- .../org/alfresco/rest/demo/RestDemoTests.java | 18 ++--- .../rest/demo/SampleCommentsTests.java | 8 +-- .../alfresco/rest/demo/SamplePeopleTests.java | 2 +- .../alfresco/rest/demo/SampleSitesTests.java | 14 ++-- .../favorites/AddFavoritesSanityTests.java | 14 ++-- .../favorites/DeleteFavoritesSanityTests.java | 46 ++++++------- .../favorites/GetFavoriteSanityTests.java | 38 +++++------ .../favorites/GetFavoritesSanityTests.java | 56 ++++++++-------- .../RestGetNetworkForPersonSanityTests.java | 8 +-- .../rest/networks/RestGetNetworkTest.java | 26 ++++---- .../RestGetNetworksForPersonSanityTests.java | 8 +-- .../people/AddFavoriteSiteSanityTests.java | 14 ++-- .../AddSiteMembershipRequestSanityTests.java | 12 ++-- .../people/DeleteFavoriteSiteSanityTests.java | 14 ++-- .../people/DeleteSiteMemberSanityTests.java | 22 +++---- ...eleteSiteMembershipRequestSanityTests.java | 32 ++++----- .../people/GetFavoriteSiteSanityTests.java | 14 ++-- .../people/GetFavoriteSitesSanityTests.java | 14 ++-- .../GetPeopleActivitiesSanityTests.java | 12 ++-- .../GetPeoplePreferenceSanityTests.java | 12 ++-- .../GetPeoplePreferencesSanityTests.java | 12 ++-- .../rest/people/GetPeopleSanityTests.java | 12 ++-- .../GetSiteMembershipRequestSanityTests.java | 24 +++---- .../GetSiteMembershipRequestsSanityTests.java | 16 ++--- .../people/GetSiteMembershipSanityTests.java | 12 ++-- ...SitesMembershipInformationSanityTests.java | 12 ++-- ...pdateSiteMembershipRequestSanityTests.java | 28 ++++---- .../rest/ratings/AddRatingSanityTests.java | 24 +++---- .../rest/ratings/DeleteRatingSanityTests.java | 66 +++++++++---------- .../rest/ratings/GetRatingSanityTests.java | 48 +++++++------- .../rest/sites/AddSiteMemberSanityTests.java | 12 ++-- .../sites/GetSiteContainerSanityTests.java | 24 +++---- .../sites/GetSiteContainersSanityTests.java | 12 ++-- .../rest/sites/GetSiteMemberSanityTests.java | 12 ++-- .../rest/sites/GetSiteMembersSanityTests.java | 12 ++-- .../rest/sites/GetSiteSanityTests.java | 12 ++-- .../rest/sites/GetSitesSanityTests.java | 12 ++-- .../sites/RemoveSiteMemberSanityTests.java | 22 +++---- .../sites/UpdateSiteMemberSanityTests.java | 12 ++-- .../GetProcessDefinitionImageSanityTests.java | 6 +- .../GetProcessDefinitionSanityTests.java | 8 +-- ...ssDefinitionStartFormModelSanityTests.java | 8 +-- .../processes/AddProcessItemSanityTests.java | 14 ++-- .../processes/AddProcessSanityTests.java | 8 +-- .../AddProcessVariableSanityTests.java | 22 +++---- .../processes/DeleteProcessSanityTests.java | 16 ++--- .../processes/GetProcessItemsSanityTests.java | 14 ++-- .../processes/GetProcessTasksSanityTests.java | 6 +- .../GetProcessVariablesSanityTests.java | 8 +-- .../processes/GetProcessesSanityTests.java | 8 +-- 55 files changed, 482 insertions(+), 482 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java index 9bf0330fe..a10980ce4 100644 --- a/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java @@ -41,7 +41,7 @@ public class AddCommentSanityTests extends RestTest { restClient.authenticateUser(adminUserModel); String newContent = "This is a new comment added by " + adminUserModel.getUsername(); - restClient.onCoreAPI().usingResource(document).addComment(newContent) + restClient.withCoreAPI().usingResource(document).addComment(newContent) .assertThat().field("content").isNotEmpty() .and().field("content").is(newContent); restClient.assertStatusCodeIs(HttpStatus.CREATED); @@ -52,7 +52,7 @@ public class AddCommentSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); String contentSiteManger = "This is a new comment added by user with role: " + UserRole.SiteManager; - restClient.onCoreAPI().usingResource(document).addComment(contentSiteManger) + restClient.withCoreAPI().usingResource(document).addComment(contentSiteManger) .assertThat().field("content").isNotEmpty() .and().field("content").is(contentSiteManger); restClient.assertStatusCodeIs(HttpStatus.CREATED); @@ -63,7 +63,7 @@ public class AddCommentSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); String contentSiteContributor = "This is a new comment added by user with role" + UserRole.SiteContributor; - restClient.onCoreAPI().usingResource(document).addComment(contentSiteContributor) + restClient.withCoreAPI().usingResource(document).addComment(contentSiteContributor) .assertThat().field("content").isNotEmpty() .and().field("content").is(contentSiteContributor); restClient.assertStatusCodeIs(HttpStatus.CREATED); @@ -74,7 +74,7 @@ public class AddCommentSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); String contentSiteCollaborator = "This is a new comment added by user with role: " + UserRole.SiteCollaborator; - restClient.onCoreAPI().usingResource(document).addComment(contentSiteCollaborator) + restClient.withCoreAPI().usingResource(document).addComment(contentSiteCollaborator) .assertThat().field("content").isNotEmpty() .and().field("content").is(contentSiteCollaborator); restClient.assertStatusCodeIs(HttpStatus.CREATED); @@ -85,7 +85,7 @@ public class AddCommentSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); String contentSiteConsumer = "This is a new comment added by user with role: " + UserRole.SiteConsumer; - restClient.onCoreAPI().usingResource(document).addComment(contentSiteConsumer); + restClient.withCoreAPI().usingResource(document).addComment(contentSiteConsumer); restClient .assertStatusCodeIs(HttpStatus.FORBIDDEN) .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); @@ -96,7 +96,7 @@ public class AddCommentSanityTests extends RestTest public void unauthenticatedUserIsNotAbleToAddComment() throws JsonToModelConversionException, Exception { restClient.authenticateUser(new UserModel("random user", "random password")); - restClient.onCoreAPI().usingResource(document).addComment("This is a new comment"); + restClient.withCoreAPI().usingResource(document).addComment("This is a new comment"); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java index e42f5dac3..f5afee1ff 100644 --- a/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java @@ -54,7 +54,7 @@ public class AddCommentsSanityTests extends RestTest public void adminIsAbleToAddComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel) - .onCoreAPI().usingResource(document).addComments(comment1, comment2) + .withCoreAPI().usingResource(document).addComments(comment1, comment2) .assertThat().entriesListIsNotEmpty() .and().entriesListContains("content", comment1) .and().entriesListContains("content", comment2); @@ -66,7 +66,7 @@ public class AddCommentsSanityTests extends RestTest public void managerIsAbleToAddComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .onCoreAPI().usingResource(document).addComments(comment1, comment2) + .withCoreAPI().usingResource(document).addComments(comment1, comment2) .assertThat().entriesListIsNotEmpty() .and().entriesListContains("content", comment1) .and().entriesListContains("content", comment2); @@ -78,7 +78,7 @@ public class AddCommentsSanityTests extends RestTest public void contributorIsAbleToAddComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) - .onCoreAPI().usingResource(document).addComments(comment1, comment2) + .withCoreAPI().usingResource(document).addComments(comment1, comment2) .assertThat().entriesListIsNotEmpty() .and().entriesListContains("content", comment1) .and().entriesListContains("content", comment2); @@ -90,7 +90,7 @@ public class AddCommentsSanityTests extends RestTest public void collaboratorIsAbleToAddComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .onCoreAPI().usingResource(document).addComments(comment1, comment2) + .withCoreAPI().usingResource(document).addComments(comment1, comment2) .assertThat().paginationExist().and().entriesListIsNotEmpty() .and().entriesListContains("content", comment1) .and().entriesListContains("content", comment2); @@ -103,7 +103,7 @@ public class AddCommentsSanityTests extends RestTest public void consumerIsAbleToAddComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .onCoreAPI().usingResource(document).addComments(comment1, comment2); + .withCoreAPI().usingResource(document).addComments(comment1, comment2); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @@ -114,7 +114,7 @@ public class AddCommentsSanityTests extends RestTest public void unauthenticatedUserIsNotAbleToAddComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(new UserModel("random user", "random password")) - .onCoreAPI().usingResource(document).addComments(comment1, comment2); + .withCoreAPI().usingResource(document).addComments(comment1, comment2); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java index 7773d76fe..464525fa9 100644 --- a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java @@ -42,7 +42,7 @@ public class DeleteCommentsSanityTests extends RestTest public void addCommentToDocument() throws Exception { restClient.authenticateUser(adminUserModel); - comment = restClient.onCoreAPI().usingResource(document).addComment("This is a new comment"); + comment = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment"); } @TestRail(section = { TestGroup.REST_API, @@ -50,7 +50,7 @@ public class DeleteCommentsSanityTests extends RestTest public void adminIsAbleToDeleteComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); - restClient.onCoreAPI().usingResource(document).deleteComment(comment); + restClient.withCoreAPI().usingResource(document).deleteComment(comment); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } @@ -59,7 +59,7 @@ public class DeleteCommentsSanityTests extends RestTest public void managerIsAbleToDeleteComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.onCoreAPI().usingResource(document).deleteComment(comment); + restClient.withCoreAPI().usingResource(document).deleteComment(comment); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } @@ -68,7 +68,7 @@ public class DeleteCommentsSanityTests extends RestTest public void collaboratorIsNotAbleToDeleteComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.onCoreAPI().usingResource(document).deleteComment(comment); + restClient.withCoreAPI().usingResource(document).deleteComment(comment); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @@ -78,7 +78,7 @@ public class DeleteCommentsSanityTests extends RestTest public void contributorIsNotAbleToDeleteComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - restClient.onCoreAPI().usingResource(document).deleteComment(comment); + restClient.withCoreAPI().usingResource(document).deleteComment(comment); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @@ -88,7 +88,7 @@ public class DeleteCommentsSanityTests extends RestTest public void consumerIsNotAbleToDeleteComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.onCoreAPI().usingResource(document).deleteComment(comment); + restClient.withCoreAPI().usingResource(document).deleteComment(comment); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @@ -99,7 +99,7 @@ public class DeleteCommentsSanityTests extends RestTest { UserModel nonexistentModel = new UserModel("nonexistentUser", "nonexistentPassword"); restClient.authenticateUser(nonexistentModel); - restClient.onCoreAPI().usingResource(document).deleteComment(comment); + restClient.withCoreAPI().usingResource(document).deleteComment(comment); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java index 328870889..4c6d435eb 100644 --- a/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java @@ -35,7 +35,7 @@ public class GetCommentsSanityTests extends RestTest siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); content = "This is a new comment"; - restClient.onCoreAPI().usingResource(document).addComment(content); + restClient.withCoreAPI().usingResource(document).addComment(content); usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); } @@ -45,7 +45,7 @@ public class GetCommentsSanityTests extends RestTest public void adminIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); - restClient.onCoreAPI().usingResource(document).getNodeComments(); + restClient.withCoreAPI().usingResource(document).getNodeComments(); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -54,7 +54,7 @@ public class GetCommentsSanityTests extends RestTest public void managerIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.onCoreAPI().usingResource(document).getNodeComments() + restClient.withCoreAPI().usingResource(document).getNodeComments() .assertThat().entriesListContains("content", content); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -65,7 +65,7 @@ public class GetCommentsSanityTests extends RestTest public void contributorIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - restClient.onCoreAPI().usingResource(document).getNodeComments() + restClient.withCoreAPI().usingResource(document).getNodeComments() .assertThat().entriesListContains("content", content); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -76,7 +76,7 @@ public class GetCommentsSanityTests extends RestTest public void collaboratorIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.onCoreAPI().usingResource(document).getNodeComments() + restClient.withCoreAPI().usingResource(document).getNodeComments() .assertThat().entriesListContains("content", content); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -86,7 +86,7 @@ public class GetCommentsSanityTests extends RestTest public void consumerIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.onCoreAPI().usingResource(document).getNodeComments() + restClient.withCoreAPI().usingResource(document).getNodeComments() .assertThat().entriesListContains("content", content); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -98,7 +98,7 @@ public class GetCommentsSanityTests extends RestTest { UserModel nonexistentModel = new UserModel("nonexistentUser", "nonexistentPassword"); restClient.authenticateUser(nonexistentModel); - restClient.onCoreAPI().usingResource(document).getNodeComments(); + restClient.withCoreAPI().usingResource(document).getNodeComments(); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } @@ -109,10 +109,10 @@ public class GetCommentsSanityTests extends RestTest userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); restClient.authenticateUser(userModel); String contentManager = "This is a new comment added by " + userModel.getUsername(); - restClient.onCoreAPI().usingResource(document).addComment(contentManager); + restClient.withCoreAPI().usingResource(document).addComment(contentManager); restClient.assertStatusCodeIs(HttpStatus.CREATED); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.onCoreAPI().usingResource(document).getNodeComments() + restClient.withCoreAPI().usingResource(document).getNodeComments() .assertThat().entriesListContains("content", contentManager); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -125,10 +125,10 @@ public class GetCommentsSanityTests extends RestTest userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); restClient.authenticateUser(userModel); String contentCollaborator = "This is a new comment added by " + userModel.getUsername(); - restClient.onCoreAPI().usingResource(document).addComment(contentCollaborator); + restClient.withCoreAPI().usingResource(document).addComment(contentCollaborator); restClient.assertStatusCodeIs(HttpStatus.CREATED); restClient.authenticateUser(adminUserModel); - restClient.onCoreAPI().usingResource(document).getNodeComments() + restClient.withCoreAPI().usingResource(document).getNodeComments() .assertThat().entriesListContains("content", contentCollaborator); restClient.assertStatusCodeIs(HttpStatus.OK); diff --git a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java index da53f841f..85f70a03e 100644 --- a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java @@ -36,7 +36,7 @@ public class UpdateCommentsSanityTests extends RestTest siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - commentModel = restClient.onCoreAPI().usingResource(document).addComment("This is a new comment"); + commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment"); usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); } @@ -47,7 +47,7 @@ public class UpdateCommentsSanityTests extends RestTest { restClient.authenticateUser(adminUserModel); String updatedContent = "This is the updated comment with admin user"; - restClient.onCoreAPI().usingResource(document).updateComment(commentModel, updatedContent) + restClient.withCoreAPI().usingResource(document).updateComment(commentModel, updatedContent) .assertThat().field("content").isNotEmpty() .and().field("content").is(updatedContent); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -58,7 +58,7 @@ public class UpdateCommentsSanityTests extends RestTest public void managerIsAbleToUpdateComment() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.onCoreAPI().usingResource(document).updateComment(commentModel, "This is the updated comment with Manager user") + restClient.withCoreAPI().usingResource(document).updateComment(commentModel, "This is the updated comment with Manager user") .and().field("content").is("This is the updated comment with Manager user") .and().field("canEdit").is(true) .and().field("canDelete").is(true); @@ -71,7 +71,7 @@ public class UpdateCommentsSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); String updatedContent = "This is the updated comment with Contributor user"; - restClient.onCoreAPI().usingResource(document).updateComment(commentModel, updatedContent); + restClient.withCoreAPI().usingResource(document).updateComment(commentModel, updatedContent); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @@ -81,7 +81,7 @@ public class UpdateCommentsSanityTests extends RestTest public void consumerIsNotAbleToUpdateComment() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.onCoreAPI().usingResource(document).updateComment(commentModel, "This is the updated comment with Consumer user"); + restClient.withCoreAPI().usingResource(document).updateComment(commentModel, "This is the updated comment with Consumer user"); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @@ -92,7 +92,7 @@ public class UpdateCommentsSanityTests extends RestTest public void collaboratorIsNotAbleToUpdateComment() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.onCoreAPI().usingResource(document).updateComment(commentModel, "This is the updated comment with Collaborator user"); + restClient.withCoreAPI().usingResource(document).updateComment(commentModel, "This is the updated comment with Collaborator user"); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @@ -103,7 +103,7 @@ public class UpdateCommentsSanityTests extends RestTest { UserModel incorrectUserModel = new UserModel("userName", "password"); restClient.authenticateUser(incorrectUserModel) - .onCoreAPI().usingResource(document).getNodeComments(); + .withCoreAPI().usingResource(document).getNodeComments(); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } @@ -114,7 +114,7 @@ public class UpdateCommentsSanityTests extends RestTest FolderModel content = FolderModel.getRandomFolderModel(); content.setNodeRef("node ref that does not exist"); - restClient.onCoreAPI().usingResource(content).updateComment(commentModel, "This is the updated comment."); + restClient.withCoreAPI().usingResource(content).updateComment(commentModel, "This is the updated comment."); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) .assertLastError().containsSummary("node ref that does not exist was not found"); } @@ -127,7 +127,7 @@ public class UpdateCommentsSanityTests extends RestTest RestCommentModel comment = new RestCommentModel(); String id = "comment id that does not exist"; comment.setId(id); - restClient.onCoreAPI().usingResource(document).updateComment(comment, "This is the updated comment."); + restClient.withCoreAPI().usingResource(document).updateComment(comment, "This is the updated comment."); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, id)); } diff --git a/e2e-test/java/org/alfresco/rest/demo/RestDemoTests.java b/e2e-test/java/org/alfresco/rest/demo/RestDemoTests.java index fe280d644..e8b59de3d 100644 --- a/e2e-test/java/org/alfresco/rest/demo/RestDemoTests.java +++ b/e2e-test/java/org/alfresco/rest/demo/RestDemoTests.java @@ -41,10 +41,10 @@ public class RestDemoTests extends RestTest @Test public void adminRetrievesCorrectSiteDetails() throws JsonToModelConversionException, Exception { - restClient.onCoreAPI().getSites().assertThat() + restClient.withCoreAPI().getSites().assertThat() .entriesListContains("id", siteModel.getId()); - restClient.onCoreAPI().usingSite(siteModel).getSite() + restClient.withCoreAPI().usingSite(siteModel).getSite() .assertThat().field("id").isNotNull() .assertThat().field("description").is(siteModel.getDescription()) .assertThat().field("title").is(siteModel.getTitle()) @@ -65,8 +65,8 @@ public class RestDemoTests extends RestTest .usingResource(FolderModel.getSharedFolderModel()) .createContent(DocumentType.TEXT_PLAIN); // add new comment - restClient.onCoreAPI().usingResource(fileModel).addComment("This is a new comment"); - restClient.onCoreAPI().usingResource(fileModel).getNodeComments() + restClient.withCoreAPI().usingResource(fileModel).addComment("This is a new comment"); + restClient.withCoreAPI().usingResource(fileModel).getNodeComments() .assertThat().entriesListIsNotEmpty().and() .entriesListContains("content", "This is a new comment"); } @@ -87,20 +87,20 @@ public class RestDemoTests extends RestTest testUser.setUserRole(UserRole.SiteConsumer); // add user as Consumer to site - restClient.onCoreAPI().usingSite(siteModel).addPerson(testUser); - restClient.onCoreAPI().usingSite(siteModel).getSiteMembers().assertThat().entriesListContains("id", testUser.getUsername()) + restClient.withCoreAPI().usingSite(siteModel).addPerson(testUser); + restClient.withCoreAPI().usingSite(siteModel).getSiteMembers().assertThat().entriesListContains("id", testUser.getUsername()) .when().getSiteMember(testUser.getUsername()) .assertSiteMemberHasRole(Role.SiteConsumer); // update site member to Manager testUser.setUserRole(UserRole.SiteCollaborator); - restClient.onCoreAPI().usingSite(siteModel).updateSiteMember(testUser); - restClient.onCoreAPI().usingSite(siteModel).getSiteMembers().and() + restClient.withCoreAPI().usingSite(siteModel).updateSiteMember(testUser); + restClient.withCoreAPI().usingSite(siteModel).getSiteMembers().and() .entriesListContains("id", testUser.getUsername()) .when().getSiteMember(testUser.getUsername()) .assertSiteMemberHasRole(Role.SiteCollaborator); - restClient.onCoreAPI().usingSite(siteModel).deleteSiteMember(testUser); + restClient.withCoreAPI().usingSite(siteModel).deleteSiteMember(testUser); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/demo/SampleCommentsTests.java b/e2e-test/java/org/alfresco/rest/demo/SampleCommentsTests.java index 5277aa2a3..71b6b73de 100644 --- a/e2e-test/java/org/alfresco/rest/demo/SampleCommentsTests.java +++ b/e2e-test/java/org/alfresco/rest/demo/SampleCommentsTests.java @@ -36,7 +36,7 @@ public class SampleCommentsTests extends RestTest description= "Verify admin user adds comments with Rest API and status code is 200") public void admiShouldAddComment() throws JsonToModelConversionException, Exception { - restClient.onCoreAPI().usingResource(document).addComment("This is a new comment"); + restClient.withCoreAPI().usingResource(document).addComment("This is a new comment"); restClient.assertStatusCodeIs(HttpStatus.CREATED); } @@ -44,7 +44,7 @@ public class SampleCommentsTests extends RestTest description= "Verify admin user gets comments with Rest API and status code is 200") public void admiShouldRetrieveComments() throws Exception { - restClient.onCoreAPI().usingResource(document).getNodeComments(); + restClient.withCoreAPI().usingResource(document).getNodeComments(); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -52,9 +52,9 @@ public class SampleCommentsTests extends RestTest description= "Verify admin user updates comments with Rest API") public void adminShouldUpdateComment() throws JsonToModelConversionException, Exception { - RestCommentModel commentModel = restClient.onCoreAPI().usingResource(document).addComment("This is a new comment"); + RestCommentModel commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment"); - restClient.onCoreAPI().usingResource(document).updateComment(commentModel, "This is the updated comment with Collaborator user") + restClient.withCoreAPI().usingResource(document).updateComment(commentModel, "This is the updated comment with Collaborator user") .assertThat().field("content").is("This is the updated comment with Collaborator user"); } diff --git a/e2e-test/java/org/alfresco/rest/demo/SamplePeopleTests.java b/e2e-test/java/org/alfresco/rest/demo/SamplePeopleTests.java index d61773e8b..62cb2f8bb 100644 --- a/e2e-test/java/org/alfresco/rest/demo/SamplePeopleTests.java +++ b/e2e-test/java/org/alfresco/rest/demo/SamplePeopleTests.java @@ -28,7 +28,7 @@ public class SamplePeopleTests extends RestTest description = "Verify admin user gets person with Rest API and response is not empty") public void adminShouldRetrievePerson() throws Exception { - restClient.onCoreAPI().usingUser(userModel).getPerson().assertThat().field("id").isNotEmpty(); + restClient.withCoreAPI().usingUser(userModel).getPerson().assertThat().field("id").isNotEmpty(); restClient.assertStatusCodeIs(HttpStatus.OK); } diff --git a/e2e-test/java/org/alfresco/rest/demo/SampleSitesTests.java b/e2e-test/java/org/alfresco/rest/demo/SampleSitesTests.java index b363c0046..e5dd071e6 100644 --- a/e2e-test/java/org/alfresco/rest/demo/SampleSitesTests.java +++ b/e2e-test/java/org/alfresco/rest/demo/SampleSitesTests.java @@ -30,7 +30,7 @@ public class SampleSitesTests extends RestTest description = "Verify admin user gets site details with Rest API and response is not empty") public void adminShouldGetSiteDetails() throws JsonToModelConversionException, Exception { - restClient.onCoreAPI().usingSite(siteModel).getSite() + restClient.withCoreAPI().usingSite(siteModel).getSite() .assertThat().field("id").isNotNull(); } @@ -38,7 +38,7 @@ public class SampleSitesTests extends RestTest description = "Verify admin user gets site information and gets status code OK (200)") public void adminShouldGetSites() throws JsonToModelConversionException, Exception { - restClient.onCoreAPI().usingSite(siteModel).getSite(); + restClient.withCoreAPI().usingSite(siteModel).getSite(); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -46,7 +46,7 @@ public class SampleSitesTests extends RestTest description = "Verify admin user gets sites with Rest API and the response is not empty") public void adminShouldAccessSites() throws JsonToModelConversionException, Exception { - restClient.onCoreAPI().getSites().assertThat().entriesListIsNotEmpty(); + restClient.withCoreAPI().getSites().assertThat().entriesListIsNotEmpty(); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -54,7 +54,7 @@ public class SampleSitesTests extends RestTest description = "Verify admin user gets sites with Rest API and status code is 200") public void adminShouldAccessResponsePagination() throws JsonToModelConversionException, Exception { - restClient.onCoreAPI().getSites().assertThat().paginationExist(); + restClient.withCoreAPI().getSites().assertThat().paginationExist(); } @TestRail(section={"demo", "sample-section"}, executionType= ExecutionType.SANITY, @@ -63,7 +63,7 @@ public class SampleSitesTests extends RestTest { UserModel testUser = dataUser.createRandomTestUser("testUser"); testUser.setUserRole(UserRole.SiteConsumer); - restClient.onCoreAPI().usingSite(siteModel).addPerson(testUser); + restClient.withCoreAPI().usingSite(siteModel).addPerson(testUser); restClient.assertStatusCodeIs(HttpStatus.CREATED); } @@ -71,14 +71,14 @@ public class SampleSitesTests extends RestTest description = "Verify that site exists from get all sites request") public void adminShouldGetSiteFromSitesList() throws JsonToModelConversionException, Exception { - restClient.onCoreAPI().getSites().assertThat().entriesListContains("id", siteModel.getId()); + restClient.withCoreAPI().getSites().assertThat().entriesListContains("id", siteModel.getId()); } @TestRail(section={"demo", "sample-section"}, executionType= ExecutionType.SANITY, description = "Verify site details: response not empty, description, title, visibility") public void adminShouldAccessSiteDetails() throws JsonToModelConversionException, Exception { - restClient.onCoreAPI().usingSite(siteModel).getSite() + restClient.withCoreAPI().usingSite(siteModel).getSite() .assertThat().field("id").isNotNull() .and().field("description").is(siteModel.getDescription()) .and().field("title").is(siteModel.getTitle()) diff --git a/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesSanityTests.java index d1c84348b..3ef0648b8 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesSanityTests.java @@ -31,7 +31,7 @@ public class AddFavoritesSanityTests extends RestTest { adminUserModel = dataUser.getAdminUser(); siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - siteModel.setGuid(restClient.authenticateUser(adminUserModel).onCoreAPI().usingSite(siteModel).getSite().getGuid()); + siteModel.setGuid(restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(siteModel).getSite().getGuid()); usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); @@ -42,7 +42,7 @@ public class AddFavoritesSanityTests extends RestTest description = "Verify Admin user add site to favorites with Rest API and status code is 201") public void adminIsAbleToAddToFavorites() throws Exception { - restClient.onCoreAPI().usingAuthUser() + restClient.withCoreAPI().usingAuthUser() .addSiteToFavorites(siteModel) .assertThat().field("targetGuid").is(siteModel.getGuid()); restClient.assertStatusCodeIs(HttpStatus.CREATED); @@ -54,7 +54,7 @@ public class AddFavoritesSanityTests extends RestTest public void managerIsAbleToAddToFavorites() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .onCoreAPI().usingAuthUser() + .withCoreAPI().usingAuthUser() .addSiteToFavorites(siteModel) .assertThat().field("targetGuid").is(siteModel.getGuid()); restClient.assertStatusCodeIs(HttpStatus.CREATED); @@ -66,7 +66,7 @@ public class AddFavoritesSanityTests extends RestTest public void collaboratorIsAbleToAddToFavorites() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .onCoreAPI().usingAuthUser() + .withCoreAPI().usingAuthUser() .addSiteToFavorites(siteModel).and().field("targetGuid").is(siteModel.getGuid()); restClient.assertStatusCodeIs(HttpStatus.CREATED); } @@ -77,7 +77,7 @@ public class AddFavoritesSanityTests extends RestTest public void contributorIsAbleToAddToFavorites() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) - .onCoreAPI().usingAuthUser() + .withCoreAPI().usingAuthUser() .addSiteToFavorites(siteModel).and().field("targetGuid").is(siteModel.getGuid()); restClient.assertStatusCodeIs(HttpStatus.CREATED); } @@ -88,7 +88,7 @@ public class AddFavoritesSanityTests extends RestTest public void consumerIsAbleToAddToFavorites() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .onCoreAPI().usingAuthUser() + .withCoreAPI().usingAuthUser() .addSiteToFavorites(siteModel).and().field("targetGuid").is(siteModel.getGuid()); restClient.assertStatusCodeIs(HttpStatus.CREATED); } @@ -102,7 +102,7 @@ public class AddFavoritesSanityTests extends RestTest UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); siteManager.setPassword("wrongPassword"); restClient.authenticateUser(siteManager) - .onCoreAPI().usingAuthUser() + .withCoreAPI().usingAuthUser() .addSiteToFavorites(siteModel); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } diff --git a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoritesSanityTests.java index b551c5e31..d1efa1042 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoritesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoritesSanityTests.java @@ -28,7 +28,7 @@ public class DeleteFavoritesSanityTests extends RestTest adminUserModel = dataUser.getAdminUser(); siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - siteModel.setGuid(restClient.authenticateUser(adminUserModel).onCoreAPI().usingSite(siteModel).getSite().getGuid()); + siteModel.setGuid(restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(siteModel).getSite().getGuid()); usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); @@ -38,12 +38,12 @@ public class DeleteFavoritesSanityTests extends RestTest TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Admin user deletes site from favorites with Rest API and status code is 204") public void adminIsAbleToDeleteFavorites() throws JsonToModelConversionException, Exception { - restClient.onCoreAPI().usingUser(adminUserModel) + restClient.withCoreAPI().usingUser(adminUserModel) .addSiteToFavorites(siteModel).assertThat().field("targetGuid").is(siteModel.getGuid()); - restClient.onCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel) + restClient.withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel) .assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.onCoreAPI().usingAuthUser().getFavorites().assertThat().entriesListDoesNotContain("targetGuid", siteModel.getGuid()); + restClient.withCoreAPI().usingAuthUser().getFavorites().assertThat().entriesListDoesNotContain("targetGuid", siteModel.getGuid()); } @TestRail(section = { TestGroup.REST_API, @@ -52,14 +52,14 @@ public class DeleteFavoritesSanityTests extends RestTest { UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); restClient.authenticateUser(siteManager) - .onCoreAPI() + .withCoreAPI() .usingAuthUser() .addSiteToFavorites(siteModel).and().field("targetGuid").is(siteModel.getGuid()); - restClient.onCoreAPI().usingAuthUser() + restClient.withCoreAPI().usingAuthUser() .deleteSiteFromFavorites(siteModel) .assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.onCoreAPI().usingAuthUser().getFavorites().assertThat().entriesListDoesNotContain("targetGuid", siteModel.getGuid()); + restClient.withCoreAPI().usingAuthUser().getFavorites().assertThat().entriesListDoesNotContain("targetGuid", siteModel.getGuid()); } @TestRail(section = { TestGroup.REST_API, @@ -68,13 +68,13 @@ public class DeleteFavoritesSanityTests extends RestTest { UserModel siteCollaborator = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); restClient.authenticateUser(siteCollaborator) - .onCoreAPI() + .withCoreAPI() .usingAuthUser() .addSiteToFavorites(siteModel).and().field("targetGuid").is(siteModel.getGuid()); - restClient.onCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel) + restClient.withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel) .assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.onCoreAPI().usingAuthUser().getFavorites().assertThat().entriesListDoesNotContain("targetGuid", siteModel.getGuid()); + restClient.withCoreAPI().usingAuthUser().getFavorites().assertThat().entriesListDoesNotContain("targetGuid", siteModel.getGuid()); } @TestRail(section = { TestGroup.REST_API, @@ -83,13 +83,13 @@ public class DeleteFavoritesSanityTests extends RestTest { UserModel siteContributor = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); restClient.authenticateUser(siteContributor) - .onCoreAPI() + .withCoreAPI() .usingAuthUser() .addSiteToFavorites(siteModel).and().field("targetGuid").is(siteModel.getGuid()); - restClient.onCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel) + restClient.withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel) .assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.onCoreAPI().usingAuthUser().getFavorites().assertThat().entriesListDoesNotContain("targetGuid", siteModel.getGuid()); + restClient.withCoreAPI().usingAuthUser().getFavorites().assertThat().entriesListDoesNotContain("targetGuid", siteModel.getGuid()); } @TestRail(section = { TestGroup.REST_API, @@ -98,12 +98,12 @@ public class DeleteFavoritesSanityTests extends RestTest { UserModel siteConsumer = usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer); restClient.authenticateUser(siteConsumer) - .onCoreAPI() + .withCoreAPI() .usingAuthUser() .addSiteToFavorites(siteModel).and().field("targetGuid").is(siteModel.getGuid()); - restClient.onCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel).assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel).assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.onCoreAPI().usingAuthUser().getFavorites().assertThat().entriesListDoesNotContain("targetGuid", siteModel.getGuid()); + restClient.withCoreAPI().usingAuthUser().getFavorites().assertThat().entriesListDoesNotContain("targetGuid", siteModel.getGuid()); } @TestRail(section = { TestGroup.REST_API, @@ -113,11 +113,11 @@ public class DeleteFavoritesSanityTests extends RestTest { UserModel siteCollaborator = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); restClient.authenticateUser(siteCollaborator) - .onCoreAPI() + .withCoreAPI() .usingAuthUser() .addSiteToFavorites(siteModel).and().field("targetGuid").is(siteModel.getGuid()); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .onCoreAPI() + .withCoreAPI() .usingAuthUser() .deleteSiteFromFavorites(siteModel) .assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); @@ -128,13 +128,13 @@ public class DeleteFavoritesSanityTests extends RestTest public void userIsNotAbleToDeleteFavoritesOfAdminUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel) - .onCoreAPI() + .withCoreAPI() .usingAuthUser() .addSiteToFavorites(siteModel) .and().field("targetGuid").is(siteModel.getGuid()); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .onCoreAPI() + .withCoreAPI() .usingAuthUser() .deleteSiteFromFavorites(siteModel) .assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); @@ -145,12 +145,12 @@ public class DeleteFavoritesSanityTests extends RestTest public void adminIsNotAbleToDeleteFavoritesOfAnotherUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .onCoreAPI() + .withCoreAPI() .usingAuthUser() .addSiteToFavorites(siteModel).and().field("targetGuid").is(siteModel.getGuid()); restClient.authenticateUser(adminUserModel) - .onCoreAPI() + .withCoreAPI() .usingAuthUser() .deleteSiteFromFavorites(siteModel) .assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); @@ -163,7 +163,7 @@ public class DeleteFavoritesSanityTests extends RestTest UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); siteManager.setPassword("wrongPassword"); restClient.authenticateUser(siteManager) - .onCoreAPI() + .withCoreAPI() .usingAuthUser() .deleteSiteFromFavorites(siteModel) .assertStatusCodeIs(HttpStatus.UNAUTHORIZED); diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java index 04c6cfe9b..1612c41cd 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java @@ -37,7 +37,7 @@ public class GetFavoriteSanityTests extends RestTest folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); fileModel = dataContent.usingUser(adminUserModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - siteModel.setGuid(restClient.authenticateUser(adminUserModel).onCoreAPI().usingSite(siteModel).getSite().getGuid()); + siteModel.setGuid(restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(siteModel).getSite().getGuid()); usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); @@ -47,8 +47,8 @@ public class GetFavoriteSanityTests extends RestTest TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets favorite site with Rest API and status code is 200") public void adminIsAbleToRetrieveFavoritesSite() throws JsonToModelConversionException, Exception { - restClient.onCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel).and().field("targetGuid").is(siteModel.getGuid()); - restClient.onCoreAPI().usingUser(adminUserModel).getFavoriteSites().and().entriesListContains("guid",siteModel.getGuid()); + restClient.withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel).and().field("targetGuid").is(siteModel.getGuid()); + restClient.withCoreAPI().usingUser(adminUserModel).getFavoriteSites().and().entriesListContains("guid",siteModel.getGuid()); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -56,8 +56,8 @@ public class GetFavoriteSanityTests extends RestTest TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets favorite folder with Rest API and status code is 200") public void adminIsAbleToRetrieveFavoritesFolder() throws JsonToModelConversionException, Exception { - restClient.onCoreAPI().usingUser(adminUserModel).addFolderToFavorites(folderModel).and().field("targetGuid").is(folderModel.getNodeRef()); - restClient.onCoreAPI().usingUser(adminUserModel).getFavorites().and().entriesListContains("targetGuid", folderModel.getNodeRef()); + restClient.withCoreAPI().usingUser(adminUserModel).addFolderToFavorites(folderModel).and().field("targetGuid").is(folderModel.getNodeRef()); + restClient.withCoreAPI().usingUser(adminUserModel).getFavorites().and().entriesListContains("targetGuid", folderModel.getNodeRef()); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -65,8 +65,8 @@ public class GetFavoriteSanityTests extends RestTest TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets favorite file with Rest API and status code is 200") public void adminIsAbleToRetrieveFavoritesFile() throws JsonToModelConversionException, Exception { - restClient.onCoreAPI().usingUser(adminUserModel).addFileToFavorites(fileModel); - restClient.onCoreAPI().usingUser(adminUserModel).getFavorites().and().entriesListContains("targetGuid", fileModel.getNodeRef()); + restClient.withCoreAPI().usingUser(adminUserModel).addFileToFavorites(fileModel); + restClient.withCoreAPI().usingUser(adminUserModel).getFavorites().and().entriesListContains("targetGuid", fileModel.getNodeRef()); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -75,8 +75,8 @@ public class GetFavoriteSanityTests extends RestTest public void managerIsAbleToRetrieveFavorite() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.onCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - restClient.onCoreAPI().usingAuthUser().getFavoriteSites().and().entriesListContains("guid",siteModel.getGuid()); + restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + restClient.withCoreAPI().usingAuthUser().getFavoriteSites().and().entriesListContains("guid",siteModel.getGuid()); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -85,9 +85,9 @@ public class GetFavoriteSanityTests extends RestTest public void collaboratorIsAbleToRetrieveFavorites() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .onCoreAPI() + .withCoreAPI() .usingAuthUser().addSiteToFavorites(siteModel); - restClient.onCoreAPI().usingAuthUser().getFavoriteSites().and().entriesListContains("guid",siteModel.getGuid()); + restClient.withCoreAPI().usingAuthUser().getFavoriteSites().and().entriesListContains("guid",siteModel.getGuid()); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -96,8 +96,8 @@ public class GetFavoriteSanityTests extends RestTest public void contributorIsAbleToRetrieveFavorite() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - restClient.onCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - restClient.onCoreAPI().usingAuthUser().getFavoriteSites().and().entriesListContains("guid",siteModel.getGuid()); + restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + restClient.withCoreAPI().usingAuthUser().getFavoriteSites().and().entriesListContains("guid",siteModel.getGuid()); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -106,8 +106,8 @@ public class GetFavoriteSanityTests extends RestTest public void consumerIsAbleToRetrieveFavorites() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.onCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - restClient.onCoreAPI().usingAuthUser().getFavoriteSites().and().entriesListContains("guid",siteModel.getGuid()); + restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + restClient.withCoreAPI().usingAuthUser().getFavoriteSites().and().entriesListContains("guid",siteModel.getGuid()); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -116,7 +116,7 @@ public class GetFavoriteSanityTests extends RestTest public void userIsNotAbleToRetrieveFavoriteSiteOfAnotherUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.onCoreAPI().usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + restClient.withCoreAPI().usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) .getFavorite(siteModel.getGuid()); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) @@ -128,7 +128,7 @@ public class GetFavoriteSanityTests extends RestTest public void userIsNotAbleToRetrieveFavoritesOfAdminUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .onCoreAPI() + .withCoreAPI() .usingUser(adminUserModel) .getFavorite(siteModel.getGuid()); @@ -141,7 +141,7 @@ public class GetFavoriteSanityTests extends RestTest public void adminIsNotAbleToRetrieveFavoritesOfAnotherUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel) - .onCoreAPI() + .withCoreAPI() .usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) .getFavorite(siteModel.getGuid()); @@ -157,7 +157,7 @@ public class GetFavoriteSanityTests extends RestTest UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); siteManager.setPassword("wrongPassword"); restClient.authenticateUser(siteManager) - .onCoreAPI() + .withCoreAPI() .usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) .getFavorite(siteModel.getGuid()); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java index 40b710cf5..cf64d0956 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java @@ -43,8 +43,8 @@ public class GetFavoritesSanityTests extends RestTest secondFileModel = dataContent.usingUser(adminUserModel).usingResource(firstFolderModel).createContent(DocumentType.TEXT_PLAIN); - firstSiteModel.setGuid(restClient.authenticateUser(adminUserModel).onCoreAPI().usingSite(firstSiteModel).getSite().getGuidWithoutVersion()); - secondSiteModel.setGuid(restClient.authenticateUser(adminUserModel).onCoreAPI().usingSite(secondSiteModel).getSite().getGuidWithoutVersion()); + firstSiteModel.setGuid(restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(firstSiteModel).getSite().getGuidWithoutVersion()); + secondSiteModel.setGuid(restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(secondSiteModel).getSite().getGuidWithoutVersion()); usersWithRoles = dataUser.addUsersWithRolesToSite(firstSiteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); @@ -54,9 +54,9 @@ public class GetFavoritesSanityTests extends RestTest TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets favorites sites with Rest API and status code is 200") public void adminIsAbleToRetrieveFavoritesSites() throws JsonToModelConversionException, Exception { - restClient.onCoreAPI().usingUser(adminUserModel).addSiteToFavorites(firstSiteModel); - restClient.onCoreAPI().usingUser(adminUserModel).addSiteToFavorites(secondSiteModel); - restClient.onCoreAPI() + restClient.withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(firstSiteModel); + restClient.withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(secondSiteModel); + restClient.withCoreAPI() .usingAuthUser().where().targetSiteExist().getFavorites() .assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) .and().entriesListContains("targetGuid", secondSiteModel.getGuid()); @@ -67,9 +67,9 @@ public class GetFavoritesSanityTests extends RestTest TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets favorites folders with Rest API and status code is 200") public void adminIsAbleToRetrieveFavoritesFolders() throws JsonToModelConversionException, Exception { - restClient.onCoreAPI().usingUser(adminUserModel).addFolderToFavorites(firstFolderModel); - restClient.onCoreAPI().usingUser(adminUserModel).addFolderToFavorites(secondFolderModel); - restClient.onCoreAPI() + restClient.withCoreAPI().usingUser(adminUserModel).addFolderToFavorites(firstFolderModel); + restClient.withCoreAPI().usingUser(adminUserModel).addFolderToFavorites(secondFolderModel); + restClient.withCoreAPI() .usingAuthUser().where().targetFolderExist().getFavorites() .assertThat().entriesListContains("targetGuid", firstFolderModel.getNodeRef()) .and().entriesListContains("targetGuid", secondFolderModel.getNodeRef()); @@ -80,9 +80,9 @@ public class GetFavoritesSanityTests extends RestTest TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets favorites files with Rest API and status code is 200") public void adminIsAbleToRetrieveFavoritesFiles() throws JsonToModelConversionException, Exception { - restClient.onCoreAPI().usingUser(adminUserModel).addFileToFavorites(firstFileModel); - restClient.onCoreAPI().usingUser(adminUserModel).addFileToFavorites(secondFileModel); - restClient.onCoreAPI() + restClient.withCoreAPI().usingUser(adminUserModel).addFileToFavorites(firstFileModel); + restClient.withCoreAPI().usingUser(adminUserModel).addFileToFavorites(secondFileModel); + restClient.withCoreAPI() .usingAuthUser().where().targetFileExist().getFavorites() .assertThat().entriesListContains("targetGuid", firstFileModel.getNodeRefWithoutVersion()) .and().entriesListContains("targetGuid", secondFileModel.getNodeRefWithoutVersion()); @@ -94,10 +94,10 @@ public class GetFavoritesSanityTests extends RestTest public void managerIsAbleToRetrieveFavorites() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.onCoreAPI() + restClient.withCoreAPI() .usingAuthUser().addSiteToFavorites(firstSiteModel); - restClient.onCoreAPI().usingAuthUser().addSiteToFavorites(secondSiteModel); - restClient.onCoreAPI() + restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(secondSiteModel); + restClient.withCoreAPI() .usingAuthUser().where().targetSiteExist().getFavorites() .assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) .assertThat().entriesListContains("targetGuid", secondSiteModel.getGuid()); @@ -109,11 +109,11 @@ public class GetFavoritesSanityTests extends RestTest public void collaboratorIsAbleToRetrieveFavorites() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .onCoreAPI() + .withCoreAPI() .usingAuthUser().addSiteToFavorites(firstSiteModel); - restClient.onCoreAPI() + restClient.withCoreAPI() .usingAuthUser().addSiteToFavorites(secondSiteModel); - restClient.onCoreAPI() + restClient.withCoreAPI() .usingAuthUser().where().targetSiteExist().getFavorites() .assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) .and().entriesListContains("targetGuid", secondSiteModel.getGuid()); @@ -125,10 +125,10 @@ public class GetFavoritesSanityTests extends RestTest public void contributorIsAbleToRetrieveFavorites() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) - .onCoreAPI() + .withCoreAPI() .usingAuthUser().addSiteToFavorites(firstSiteModel); - restClient.onCoreAPI().usingAuthUser().addSiteToFavorites(secondSiteModel); - restClient.onCoreAPI() + restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(secondSiteModel); + restClient.withCoreAPI() .usingAuthUser().where().targetSiteExist().getFavorites() .assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()).and() .entriesListContains("targetGuid", secondSiteModel.getGuid()); @@ -140,10 +140,10 @@ public class GetFavoritesSanityTests extends RestTest public void consumerIsAbleToRetrieveFavorites() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .onCoreAPI() + .withCoreAPI() .usingAuthUser().addSiteToFavorites(firstSiteModel); - restClient.onCoreAPI().usingAuthUser().addSiteToFavorites(secondSiteModel); - restClient.onCoreAPI() + restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(secondSiteModel); + restClient.withCoreAPI() .usingAuthUser().where().targetSiteExist().getFavorites() .assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) .assertThat().entriesListContains("targetGuid", secondSiteModel.getGuid()); @@ -155,7 +155,7 @@ public class GetFavoritesSanityTests extends RestTest public void userIsNotAbleToRetrieveFavoritesOfAnotherUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .onCoreAPI() + .withCoreAPI() .usingAuthUser().where().targetSiteExist().getFavorites(); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator).getUsername())); @@ -166,7 +166,7 @@ public class GetFavoritesSanityTests extends RestTest public void userIsNotAbleToRetrieveFavoritesOfAdminUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .onCoreAPI() + .withCoreAPI() .usingAuthUser().where().targetSiteExist().getFavorites(); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, adminUserModel.getUsername())); @@ -177,7 +177,7 @@ public class GetFavoritesSanityTests extends RestTest public void adminIsNotAbleToRetrieveFavoritesOfAnotherUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel) - .onCoreAPI() + .withCoreAPI() .usingAuthUser().where().targetSiteExist().getFavorites(); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator).getUsername())); @@ -191,9 +191,9 @@ public class GetFavoritesSanityTests extends RestTest UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); siteManager.setPassword("wrongPassword"); restClient.authenticateUser(siteManager) - .onCoreAPI() + .withCoreAPI() .usingAuthUser().addSiteToFavorites(firstSiteModel); - restClient.onCoreAPI().usingAuthUser().addSiteToFavorites(secondSiteModel); + restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(secondSiteModel); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java index 9d2abf403..9d8d40ebd 100644 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java @@ -36,7 +36,7 @@ public class RestGetNetworkForPersonSanityTests extends RestTest UserModel tenantUser = new UserModel("nonexisting", "password"); tenantUser.setDomain(adminTenantUser.getDomain()); restClient.authenticateUser(tenantUser); - restClient.onCoreAPI().usingUser(tenantUser).getNetwork(adminTenantUser); + restClient.withCoreAPI().usingUser(tenantUser).getNetwork(adminTenantUser); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } @@ -47,7 +47,7 @@ public class RestGetNetworkForPersonSanityTests extends RestTest public void adminTenantChecksIfNetworkIsPresent() throws Exception { restClient.authenticateUser(adminTenantUser); - restClient.onCoreAPI().usingUser(adminTenantUser).getNetwork(); + restClient.withCoreAPI().usingUser(adminTenantUser).getNetwork(); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -58,7 +58,7 @@ public class RestGetNetworkForPersonSanityTests extends RestTest public void tenantUserIsNotAuthorizedToCheckNetworkOfAdminUser() throws Exception { restClient.authenticateUser(tenantUser); - restClient.onCoreAPI().usingUser(tenantUser).getNetwork(adminTenantUser); + restClient.withCoreAPI().usingUser(tenantUser).getNetwork(adminTenantUser); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); } @@ -72,7 +72,7 @@ public class RestGetNetworkForPersonSanityTests extends RestTest restClient.usingTenant().createTenant(secondAdminTenantUser); UserModel secondTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("anotherTenant"); restClient.authenticateUser(adminTenantUser); - restClient.onCoreAPI().usingUser(adminTenantUser).getNetwork(secondTenantUser); + restClient.withCoreAPI().usingUser(adminTenantUser).getNetwork(secondTenantUser); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); } } diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkTest.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkTest.java index 23ef6c5b9..bc658edc0 100644 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkTest.java +++ b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkTest.java @@ -46,7 +46,7 @@ public class RestGetNetworkTest extends RestTest UserModel tenantUser = new UserModel("nonexisting", "password"); tenantUser.setDomain(adminTenantUser.getDomain()); restClient.authenticateUser(tenantUser); - restClient.onCoreAPI().usingNetworks().getNetwork(adminTenantUser); + restClient.withCoreAPI().usingNetworks().getNetwork(adminTenantUser); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } @@ -56,7 +56,7 @@ public class RestGetNetworkTest extends RestTest public void adminTenantChecksIfNetworkIsPresent() throws Exception { restClient.authenticateUser(adminTenantUser); - restClient.onCoreAPI().usingNetworks().getNetwork(); + restClient.withCoreAPI().usingNetworks().getNetwork(); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -65,7 +65,7 @@ public class RestGetNetworkTest extends RestTest public void adminTenantChecksNetworkParamsAreCorrect() throws Exception { restClient.authenticateUser(adminTenantUser); - restClient.onCoreAPI().usingNetworks().getNetwork().assertNetworkHasName(adminTenantUser).assertNetworkIsEnabled(); + restClient.withCoreAPI().usingNetworks().getNetwork().assertNetworkHasName(adminTenantUser).assertNetworkIsEnabled(); } @TestRail(section = { TestGroup.REST_API, @@ -73,7 +73,7 @@ public class RestGetNetworkTest extends RestTest public void adminTenantChecksIfNonExistingNetworkIsNotFound() throws Exception { restClient.authenticateUser(adminTenantUser); - restClient.onCoreAPI().usingNetworks().getNetwork(UserModel.getRandomTenantUser()); + restClient.withCoreAPI().usingNetworks().getNetwork(UserModel.getRandomTenantUser()); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); } @@ -82,7 +82,7 @@ public class RestGetNetworkTest extends RestTest public void adminTenantChecksIfAnotherExistingNetworkIsForbidden() throws Exception { restClient.authenticateUser(adminTenantUser); - restClient.onCoreAPI().usingNetworks().getNetwork(adminAnotherTenantUser); + restClient.withCoreAPI().usingNetworks().getNetwork(adminAnotherTenantUser); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); } @@ -90,7 +90,7 @@ public class RestGetNetworkTest extends RestTest public void userTenantChecksIfNetworkIsPresent() throws Exception { restClient.authenticateUser(tenantUser); - restClient.onCoreAPI().usingNetworks().getNetwork(adminTenantUser); + restClient.withCoreAPI().usingNetworks().getNetwork(adminTenantUser); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -99,7 +99,7 @@ public class RestGetNetworkTest extends RestTest public void userTenantChecksNetworkParamsAreCorrect() throws Exception { restClient.authenticateUser(tenantUser); - restClient.onCoreAPI().usingNetworks().getNetwork(adminTenantUser).assertNetworkHasName(adminTenantUser).assertNetworkIsEnabled(); + restClient.withCoreAPI().usingNetworks().getNetwork(adminTenantUser).assertNetworkHasName(adminTenantUser).assertNetworkIsEnabled(); } @TestRail(section = { TestGroup.REST_API, @@ -107,7 +107,7 @@ public class RestGetNetworkTest extends RestTest public void userTenantChecksIfNonExistingNetworkIsNotFound() throws Exception { restClient.authenticateUser(tenantUser); - restClient.onCoreAPI().usingNetworks().getNetwork(UserModel.getRandomTenantUser()); + restClient.withCoreAPI().usingNetworks().getNetwork(UserModel.getRandomTenantUser()); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); } @@ -117,7 +117,7 @@ public class RestGetNetworkTest extends RestTest public void userTenantChecksIfAnotherExistingNetworkIsForbidden() throws Exception { restClient.authenticateUser(tenantUser); - restClient.onCoreAPI().usingNetworks().getNetwork(adminAnotherTenantUser); + restClient.withCoreAPI().usingNetworks().getNetwork(adminAnotherTenantUser); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); } @@ -130,7 +130,7 @@ public class RestGetNetworkTest extends RestTest dataUser.usingUser(adminTenantUser).addUserToSite(managerTenantUser, site, UserRole.SiteManager); restClient.authenticateUser(managerTenantUser); - restClient.onCoreAPI().usingNetworks().getNetwork(adminTenantUser); + restClient.withCoreAPI().usingNetworks().getNetwork(adminTenantUser); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -143,7 +143,7 @@ public class RestGetNetworkTest extends RestTest dataUser.usingUser(adminTenantUser).addUserToSite(collaboratorTenantUser, site, UserRole.SiteCollaborator); restClient.authenticateUser(collaboratorTenantUser); - restClient.onCoreAPI().usingNetworks().getNetwork(adminTenantUser); + restClient.withCoreAPI().usingNetworks().getNetwork(adminTenantUser); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -156,7 +156,7 @@ public class RestGetNetworkTest extends RestTest dataUser.usingUser(adminTenantUser).addUserToSite(consumerTenantUser, site, UserRole.SiteConsumer); restClient.authenticateUser(consumerTenantUser); - restClient.onCoreAPI().usingNetworks().getNetwork(adminTenantUser); + restClient.withCoreAPI().usingNetworks().getNetwork(adminTenantUser); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -169,7 +169,7 @@ public class RestGetNetworkTest extends RestTest dataUser.usingUser(adminTenantUser).addUserToSite(contributorTenantUser, site, UserRole.SiteContributor); restClient.authenticateUser(contributorTenantUser); - restClient.onCoreAPI().usingNetworks().getNetwork(adminTenantUser); + restClient.withCoreAPI().usingNetworks().getNetwork(adminTenantUser); restClient.assertStatusCodeIs(HttpStatus.OK); } } diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonSanityTests.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonSanityTests.java index 539d5d13b..267c5fa11 100644 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonSanityTests.java @@ -37,7 +37,7 @@ public class RestGetNetworksForPersonSanityTests extends RestTest UserModel tenantUser = new UserModel("nonexisting", "password"); tenantUser.setDomain(adminTenantUser.getDomain()); restClient.authenticateUser(tenantUser); - restClient.onCoreAPI().usingUser(tenantUser).getNetworks(adminTenantUser); + restClient.withCoreAPI().usingUser(tenantUser).getNetworks(adminTenantUser); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } @@ -48,7 +48,7 @@ public class RestGetNetworksForPersonSanityTests extends RestTest public void adminTenantChecksIfNetworkIsPresent() throws Exception { restClient.authenticateUser(adminTenantUser); - restClient.onCoreAPI().usingUser(adminTenantUser).getNetworks(); + restClient.withCoreAPI().usingUser(adminTenantUser).getNetworks(); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -59,7 +59,7 @@ public class RestGetNetworksForPersonSanityTests extends RestTest public void tenantUserIsNotAuthorizedToCheckNetworkOfAdminUser() throws Exception { restClient.authenticateUser(tenantUser); - restClient.onCoreAPI().usingUser(tenantUser).getNetworks(adminTenantUser); + restClient.withCoreAPI().usingUser(tenantUser).getNetworks(adminTenantUser); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); } @@ -73,7 +73,7 @@ public class RestGetNetworksForPersonSanityTests extends RestTest restClient.usingTenant().createTenant(secondAdminTenantUser); UserModel secondTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("anotherTenant"); restClient.authenticateUser(secondAdminTenantUser); - restClient.onCoreAPI().usingUser(secondAdminTenantUser).getNetworks(secondTenantUser); + restClient.withCoreAPI().usingUser(secondAdminTenantUser).getNetworks(secondTenantUser); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); } } diff --git a/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteSanityTests.java index 6ec92508a..407eddb34 100644 --- a/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteSanityTests.java @@ -33,13 +33,13 @@ public class AddFavoriteSiteSanityTests extends RestTest dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); restClient.authenticateUser(managerUser) - .onCoreAPI() + .withCoreAPI() .usingUser(managerUser) .addFavoriteSite(siteModel) .assertThat().field("id").is(siteModel.getId()); restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.onCoreAPI().usingUser(managerUser).addFavoriteSite(siteModel); + restClient.withCoreAPI().usingUser(managerUser).addFavoriteSite(siteModel); restClient.assertStatusCodeIs(HttpStatus.CONFLICT); restClient.assertLastError().containsSummary(String.format("%s is already a favourite site", siteModel.getId())); } @@ -51,7 +51,7 @@ public class AddFavoriteSiteSanityTests extends RestTest dataUser.usingUser(userModel).addUserToSite(collaboratorUser, siteModel, UserRole.SiteCollaborator); restClient.authenticateUser(collaboratorUser) - .onCoreAPI() + .withCoreAPI() .usingAuthUser() .addFavoriteSite(siteModel) .assertThat().field("id").is(siteModel.getId()); @@ -65,7 +65,7 @@ public class AddFavoriteSiteSanityTests extends RestTest dataUser.usingUser(userModel).addUserToSite(contributorUser, siteModel, UserRole.SiteContributor); restClient.authenticateUser(contributorUser) - .onCoreAPI() + .withCoreAPI() .usingAuthUser() .addFavoriteSite(siteModel) .assertThat().field("id").is(siteModel.getId()); @@ -79,7 +79,7 @@ public class AddFavoriteSiteSanityTests extends RestTest dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel, UserRole.SiteConsumer); restClient.authenticateUser(consumerUser) - .onCoreAPI() + .withCoreAPI() .usingAuthUser() .addFavoriteSite(siteModel) .assertThat().field("id").is(siteModel.getId()); @@ -92,7 +92,7 @@ public class AddFavoriteSiteSanityTests extends RestTest UserModel adminUser = dataUser.getAdminUser(); restClient.authenticateUser(adminUser) - .onCoreAPI() + .withCoreAPI() .usingAuthUser() .addFavoriteSite(siteModel) .assertThat().field("id").is(siteModel.getId()); @@ -108,7 +108,7 @@ public class AddFavoriteSiteSanityTests extends RestTest managerUser.setPassword("newpassword"); restClient.authenticateUser(managerUser) - .onCoreAPI() + .withCoreAPI() .usingAuthUser() .addFavoriteSite(siteModel); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); diff --git a/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java index 98c29394f..0478dd9be 100644 --- a/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java @@ -48,7 +48,7 @@ public class AddSiteMembershipRequestSanityTests extends RestTest { UserModel newMember = dataUser.createRandomTestUser(); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .onCoreAPI() + .withCoreAPI() .usingUser(newMember).addSiteMembershipRequest(siteModel) .assertThat().field("id").isNotEmpty() .assertThat().field("site").isNotEmpty(); @@ -63,7 +63,7 @@ public class AddSiteMembershipRequestSanityTests extends RestTest { UserModel newMember = dataUser.createRandomTestUser(); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .onCoreAPI() + .withCoreAPI() .usingUser(newMember).addSiteMembershipRequest(siteModel) .assertThat().field("id").isNotEmpty() .assertThat().field("site").isNotEmpty(); @@ -78,7 +78,7 @@ public class AddSiteMembershipRequestSanityTests extends RestTest { UserModel newMember = dataUser.createRandomTestUser(); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) - .onCoreAPI() + .withCoreAPI() .usingUser(newMember).addSiteMembershipRequest(siteModel) .assertThat().field("id").isNotEmpty() .assertThat().field("site").isNotEmpty(); @@ -93,7 +93,7 @@ public class AddSiteMembershipRequestSanityTests extends RestTest { UserModel newMember = dataUser.createRandomTestUser(); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .onCoreAPI() + .withCoreAPI() .usingUser(newMember).addSiteMembershipRequest(siteModel) .assertThat().field("id").isNotEmpty() .assertThat().field("site").isNotEmpty(); @@ -108,7 +108,7 @@ public class AddSiteMembershipRequestSanityTests extends RestTest { UserModel newMember = dataUser.createRandomTestUser(); restClient.authenticateUser(adminUser) - .onCoreAPI() + .withCoreAPI() .usingUser(newMember).addSiteMembershipRequest(siteModel) .assertThat().field("id").isNotEmpty() .assertThat().field("site").isNotEmpty(); @@ -123,7 +123,7 @@ public class AddSiteMembershipRequestSanityTests extends RestTest { UserModel newMember = dataUser.createRandomTestUser(); restClient.authenticateUser(new UserModel("random user", "random password")) - .onCoreAPI() + .withCoreAPI() .usingUser(newMember).addSiteMembershipRequest(siteModel) .assertThat().field("id").isNotEmpty() .assertThat().field("site").isNotEmpty(); diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java index 263cbc7b2..611ab31eb 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java @@ -42,7 +42,7 @@ public class DeleteFavoriteSiteSanityTests extends RestTest dataSite.usingUser(managerUser).usingSite(siteModel2).addSiteToFavorites(); restClient.authenticateUser(managerUser) - .onCoreAPI() + .withCoreAPI() .usingAuthUser().removeFavoriteSite(siteModel1); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); @@ -59,7 +59,7 @@ public class DeleteFavoriteSiteSanityTests extends RestTest dataSite.usingUser(collaboratorUser).usingSite(siteModel2).addSiteToFavorites(); restClient.authenticateUser(collaboratorUser) - .onCoreAPI() + .withCoreAPI() .usingAuthUser().removeFavoriteSite(siteModel1); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } @@ -75,7 +75,7 @@ public class DeleteFavoriteSiteSanityTests extends RestTest dataSite.usingUser(contributorUser).usingSite(siteModel2).addSiteToFavorites(); restClient.authenticateUser(contributorUser) - .onCoreAPI() + .withCoreAPI() .usingAuthUser().removeFavoriteSite(siteModel1); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } @@ -91,7 +91,7 @@ public class DeleteFavoriteSiteSanityTests extends RestTest dataSite.usingUser(consumerUser).usingSite(siteModel2).addSiteToFavorites(); restClient.authenticateUser(consumerUser) - .onCoreAPI() + .withCoreAPI() .usingAuthUser().removeFavoriteSite(siteModel1); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } @@ -107,7 +107,7 @@ public class DeleteFavoriteSiteSanityTests extends RestTest dataSite.usingUser(anyUser).usingSite(siteModel2).addSiteToFavorites(); restClient.authenticateUser(adminUser) - .onCoreAPI() + .withCoreAPI() .usingAuthUser().removeFavoriteSite(siteModel1); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } @@ -123,7 +123,7 @@ public class DeleteFavoriteSiteSanityTests extends RestTest dataSite.usingUser(anotherUser).usingSite(siteModel2).addSiteToFavorites(); restClient.authenticateUser(userAuth) - .onCoreAPI() + .withCoreAPI() .usingUser(anotherUser).removeFavoriteSite(siteModel1); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); @@ -141,7 +141,7 @@ public class DeleteFavoriteSiteSanityTests extends RestTest managerUser.setPassword("newpassword"); restClient.authenticateUser(managerUser) - .onCoreAPI() + .withCoreAPI() .usingAuthUser().removeFavoriteSite(siteModel1); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java index 53a575224..5ad27944f 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java @@ -44,10 +44,10 @@ public class DeleteSiteMemberSanityTests extends RestTest UserModel newUser = dataUser.createRandomTestUser("testUser"); newUser.setUserRole(UserRole.SiteCollaborator); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .onCoreAPI() + .withCoreAPI() .usingSite(siteModel).addPerson(newUser); - restClient.onCoreAPI().usingUser(newUser).deleteSiteMember(siteModel); + restClient.withCoreAPI().usingUser(newUser).deleteSiteMember(siteModel); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } @@ -59,10 +59,10 @@ public class DeleteSiteMemberSanityTests extends RestTest UserModel newUser = dataUser.createRandomTestUser("testUser"); newUser.setUserRole(UserRole.SiteCollaborator); restClient.authenticateUser(adminUser) - .onCoreAPI() + .withCoreAPI() .usingSite(siteModel).addPerson(newUser); - restClient.onCoreAPI().usingUser(newUser).deleteSiteMember(siteModel); + restClient.withCoreAPI().usingUser(newUser).deleteSiteMember(siteModel); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } @@ -75,11 +75,11 @@ public class DeleteSiteMemberSanityTests extends RestTest UserModel newUser = dataUser.createRandomTestUser("testUser"); newUser.setUserRole(UserRole.SiteCollaborator); restClient.authenticateUser(adminUser) - .onCoreAPI() + .withCoreAPI() .usingSite(siteModel).addPerson(newUser); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.onCoreAPI().usingUser(newUser).deleteSiteMember(siteModel); + restClient.withCoreAPI().usingUser(newUser).deleteSiteMember(siteModel); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @@ -93,11 +93,11 @@ public class DeleteSiteMemberSanityTests extends RestTest UserModel newUser = dataUser.createRandomTestUser("testUser"); newUser.setUserRole(UserRole.SiteCollaborator); restClient.authenticateUser(adminUser) - .onCoreAPI() + .withCoreAPI() .usingSite(siteModel).addPerson(newUser); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - restClient.onCoreAPI().usingUser(newUser).deleteSiteMember(siteModel); + restClient.withCoreAPI().usingUser(newUser).deleteSiteMember(siteModel); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @@ -111,11 +111,11 @@ public class DeleteSiteMemberSanityTests extends RestTest UserModel newUser = dataUser.createRandomTestUser("testUser"); newUser.setUserRole(UserRole.SiteCollaborator); restClient.authenticateUser(adminUser) - .onCoreAPI() + .withCoreAPI() .usingSite(siteModel).addPerson(newUser); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.onCoreAPI().usingUser(newUser).deleteSiteMember(siteModel); + restClient.withCoreAPI().usingUser(newUser).deleteSiteMember(siteModel); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @@ -127,7 +127,7 @@ public class DeleteSiteMemberSanityTests extends RestTest { restClient.authenticateUser(new UserModel("random user", "random password")); - restClient.onCoreAPI().usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).deleteSiteMember(siteModel); + restClient.withCoreAPI().usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).deleteSiteMember(siteModel); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java index 1aad5da63..ee0142301 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java @@ -47,11 +47,11 @@ public class DeleteSiteMembershipRequestSanityTests extends RestTest { siteMember = dataUser.createRandomTestUser(); restClient.authenticateUser(siteMember) - .onCoreAPI() + .withCoreAPI() .usingAuthUser().addSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .onCoreAPI() + .withCoreAPI() .usingUser(siteMember).deleteSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } @@ -64,10 +64,10 @@ public class DeleteSiteMembershipRequestSanityTests extends RestTest { siteMember = dataUser.createRandomTestUser(); restClient.authenticateUser(siteMember) - .onCoreAPI() + .withCoreAPI() .usingUser(siteMember).addSiteMembershipRequest(siteModel); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .onCoreAPI() + .withCoreAPI() .usingAuthUser().deleteSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } @@ -80,12 +80,12 @@ public class DeleteSiteMembershipRequestSanityTests extends RestTest { siteMember = dataUser.createRandomTestUser(); restClient.authenticateUser(siteMember) - .onCoreAPI() + .withCoreAPI() .usingAuthUser().addSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); restClient.authenticateUser(dataUser.getAdminUser()) - .onCoreAPI() + .withCoreAPI() .usingAuthUser().deleteSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } @@ -98,10 +98,10 @@ public class DeleteSiteMembershipRequestSanityTests extends RestTest { siteMember = dataUser.createRandomTestUser(); restClient.authenticateUser(siteMember) - .onCoreAPI() + .withCoreAPI() .usingAuthUser().addSiteMembershipRequest(siteModel); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .onCoreAPI() + .withCoreAPI() .usingAuthUser().deleteSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @@ -114,11 +114,11 @@ public class DeleteSiteMembershipRequestSanityTests extends RestTest { siteMember = dataUser.createRandomTestUser(); restClient.authenticateUser(siteMember) - .onCoreAPI() + .withCoreAPI() .usingAuthUser().addSiteMembershipRequest(siteModel); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) - .onCoreAPI() + .withCoreAPI() .usingAuthUser().deleteSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); @@ -132,10 +132,10 @@ public class DeleteSiteMembershipRequestSanityTests extends RestTest { siteMember = dataUser.createRandomTestUser(); restClient.authenticateUser(siteMember) - .onCoreAPI() + .withCoreAPI() .usingAuthUser().addSiteMembershipRequest(siteModel); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .onCoreAPI() + .withCoreAPI() .usingAuthUser().deleteSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); @@ -148,11 +148,11 @@ public class DeleteSiteMembershipRequestSanityTests extends RestTest public void randomUserCanDeleteSiteMembershipRequest() throws JsonToModelConversionException, DataPreparationException, Exception { restClient.authenticateUser(dataUser.createRandomTestUser()) - .onCoreAPI() + .withCoreAPI() .usingAuthUser().addSiteMembershipRequest(siteModel); restClient.authenticateUser(dataUser.createRandomTestUser()) - .onCoreAPI() + .withCoreAPI() .usingAuthUser().deleteSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); @@ -164,11 +164,11 @@ public class DeleteSiteMembershipRequestSanityTests extends RestTest public void unauthenticatedUserIsNotAuthorizedToDeleteSiteMmebershipRequest() throws JsonToModelConversionException, Exception { restClient.authenticateUser(dataUser.createRandomTestUser()) - .onCoreAPI() + .withCoreAPI() .usingAuthUser().addSiteMembershipRequest(siteModel); UserModel inexistentUser = new UserModel("inexistent user", "inexistent password"); restClient.authenticateUser(inexistentUser) - .onCoreAPI() + .withCoreAPI() .usingAuthUser().deleteSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } diff --git a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java index 0bcdb34b6..c3506f6d8 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java @@ -46,7 +46,7 @@ public class GetFavoriteSiteSanityTests extends RestTest dataSite.usingUser(managerUser).usingSite(siteModel2).addSiteToFavorites(); restClient.authenticateUser(managerUser) - .onCoreAPI() + .withCoreAPI() .usingAuthUser().getFavoriteSite(siteModel1) .assertThat().field("id").is(siteModel1.getId()) .and().field("title").isNotNull(); @@ -64,7 +64,7 @@ public class GetFavoriteSiteSanityTests extends RestTest dataSite.usingUser(collaboratorUser).usingSite(siteModel2).addSiteToFavorites(); restClient.authenticateUser(collaboratorUser) - .onCoreAPI() + .withCoreAPI() .usingAuthUser().getFavoriteSite(siteModel1) .assertThat().field("id").is(siteModel1.getId()) .and().field("title").isNotNull(); @@ -82,7 +82,7 @@ public class GetFavoriteSiteSanityTests extends RestTest dataSite.usingUser(contributorUser).usingSite(siteModel2).addSiteToFavorites(); restClient.authenticateUser(contributorUser) - .onCoreAPI() + .withCoreAPI() .usingAuthUser().getFavoriteSite(siteModel1) .assertThat().field("id").is(siteModel1.getId()) .and().field("title").isNotNull(); @@ -100,7 +100,7 @@ public class GetFavoriteSiteSanityTests extends RestTest dataSite.usingUser(consumerUser).usingSite(siteModel2).addSiteToFavorites(); restClient.authenticateUser(consumerUser) - .onCoreAPI() + .withCoreAPI() .usingAuthUser().getFavoriteSite(siteModel1) .assertThat().field("id").is(siteModel1.getId()) .and().field("title").isNotNull(); @@ -118,7 +118,7 @@ public class GetFavoriteSiteSanityTests extends RestTest dataSite.usingUser(anyUser).usingSite(siteModel2).addSiteToFavorites(); restClient.authenticateUser(adminUset) - .onCoreAPI() + .withCoreAPI() .usingAuthUser().getFavoriteSite(siteModel1) .assertThat().field("id").is(siteModel1.getId()) .and().field("title").isNotNull(); @@ -136,7 +136,7 @@ public class GetFavoriteSiteSanityTests extends RestTest dataSite.usingUser(managerUser).usingSite(siteModel2).addSiteToFavorites(); restClient.authenticateUser(managerUser) - .onCoreAPI() + .withCoreAPI() .usingUser(userModel).getFavoriteSite(siteModel1); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @@ -154,7 +154,7 @@ public class GetFavoriteSiteSanityTests extends RestTest managerUser.setPassword("newpassword"); restClient.authenticateUser(managerUser) - .onCoreAPI() + .withCoreAPI() .usingAuthUser().getFavoriteSite(siteModel1); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } diff --git a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java index 1e1bbafc2..7a7affa26 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java @@ -38,7 +38,7 @@ public class GetFavoriteSitesSanityTests extends RestTest dataSite.usingUser(anotherUser).usingSite(siteModel).addSiteToFavorites(); restClient.authenticateUser(managerUser) - .onCoreAPI() + .withCoreAPI() .usingUser(anotherUser).getFavoriteSites(); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @@ -55,7 +55,7 @@ public class GetFavoriteSitesSanityTests extends RestTest dataSite.usingUser(contributorUser).usingSite(siteModel).addSiteToFavorites(); restClient.authenticateUser(collaboratorUser) - .onCoreAPI() + .withCoreAPI() .usingUser(contributorUser).getFavoriteSites(); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @@ -72,7 +72,7 @@ public class GetFavoriteSitesSanityTests extends RestTest dataSite.usingUser(contributorUser2).usingSite(siteModel).addSiteToFavorites(); restClient.authenticateUser(contributorUser) - .onCoreAPI() + .withCoreAPI() .usingUser(contributorUser2).getFavoriteSites(); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @@ -89,7 +89,7 @@ public class GetFavoriteSitesSanityTests extends RestTest dataSite.usingUser(collaboratorUser).usingSite(siteModel).addSiteToFavorites(); restClient.authenticateUser(consumerUser) - .onCoreAPI() + .withCoreAPI() .usingUser(collaboratorUser).getFavoriteSites(); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @@ -104,7 +104,7 @@ public class GetFavoriteSitesSanityTests extends RestTest dataSite.usingUser(anotherUser).usingSite(siteModel).addSiteToFavorites(); restClient.authenticateUser(adminUser) - .onCoreAPI() + .withCoreAPI() .usingUser(anotherUser).getFavoriteSites() .assertThat().entriesListIsNotEmpty() .and().paginationExist() @@ -121,7 +121,7 @@ public class GetFavoriteSitesSanityTests extends RestTest dataSite.usingUser(anyUser).usingSite(siteModel).addSiteToFavorites(); restClient.authenticateUser(anyUser) - .onCoreAPI() + .withCoreAPI() .usingAuthUser().getFavoriteSites() .assertThat().entriesListIsNotEmpty() .and().entriesListContains("id", siteModel.getId()) @@ -140,7 +140,7 @@ public class GetFavoriteSitesSanityTests extends RestTest anyUser.setPassword("newpassword"); restClient.authenticateUser(anyUser) - .onCoreAPI() + .withCoreAPI() .usingAuthUser().getFavoriteSites(); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java index 444c90486..08ec9333d 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java @@ -44,7 +44,7 @@ public class GetPeopleActivitiesSanityTests extends RestTest dataContent.usingUser(managerUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); restClient.authenticateUser(managerUser) - .onCoreAPI() + .withCoreAPI() .usingAuthUser().getPersonActivities() .assertThat().entriesListIsNotEmpty() .and().entriesListContains("siteId", siteModel.getId()) @@ -62,7 +62,7 @@ public class GetPeopleActivitiesSanityTests extends RestTest dataContent.usingUser(collaboratorUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); restClient.authenticateUser(collaboratorUser) - .onCoreAPI() + .withCoreAPI() .usingAuthUser().getPersonActivities() .assertThat().entriesListIsNotEmpty() .and().entriesListContains("siteId", siteModel.getId()) @@ -80,7 +80,7 @@ public class GetPeopleActivitiesSanityTests extends RestTest dataContent.usingUser(contributorUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); restClient.authenticateUser(contributorUser) - .onCoreAPI() + .withCoreAPI() .usingAuthUser().getPersonActivities() .assertThat().entriesListIsNotEmpty() .and().entriesListContains("siteId", siteModel.getId()) @@ -97,7 +97,7 @@ public class GetPeopleActivitiesSanityTests extends RestTest dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel, UserRole.SiteConsumer); restClient.authenticateUser(consumerUser) - .onCoreAPI() + .withCoreAPI() .usingAuthUser().getPersonActivities() .assertThat().entriesListIsNotEmpty() .and().entriesListContains("siteId", siteModel.getId()) @@ -111,7 +111,7 @@ public class GetPeopleActivitiesSanityTests extends RestTest public void adminUserShouldGetPeopleActivitiesList() throws Exception { restClient.authenticateUser(dataUser.getAdminUser()) - .onCoreAPI() + .withCoreAPI() .usingUser(userModel).getPersonActivities() .assertThat().entriesListIsNotEmpty() .and().entriesListContains("siteId", siteModel.getId()) @@ -130,7 +130,7 @@ public class GetPeopleActivitiesSanityTests extends RestTest managerUser.setPassword("newpassword"); restClient.authenticateUser(managerUser) - .onCoreAPI() + .withCoreAPI() .usingUser(userModel).getPersonActivities(); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceSanityTests.java index 3384c610f..62fbb93f8 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceSanityTests.java @@ -40,7 +40,7 @@ public class GetPeoplePreferenceSanityTests extends RestTest dataSite.usingUser(managerUser).usingSite(siteModel).addSiteToFavorites(); restClient.authenticateUser(managerUser) - .onCoreAPI().usingAuthUser().getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) + .withCoreAPI().usingAuthUser().getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) .assertThat().field("id").is( PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) .and().field("value").is("true"); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -54,7 +54,7 @@ public class GetPeoplePreferenceSanityTests extends RestTest dataSite.usingUser(collaboratorUser).usingSite(siteModel).addSiteToFavorites(); restClient.authenticateUser(collaboratorUser) - .onCoreAPI().usingAuthUser().getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) + .withCoreAPI().usingAuthUser().getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) .assertThat().field("id").is(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) .and().field("value").is("true"); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -68,7 +68,7 @@ public class GetPeoplePreferenceSanityTests extends RestTest dataSite.usingUser(contributorUser).usingSite(siteModel).addSiteToFavorites(); restClient.authenticateUser(contributorUser) - .onCoreAPI().usingAuthUser().getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) + .withCoreAPI().usingAuthUser().getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) .assertThat().field("id").is(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) .and().field("value").is("true"); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -82,7 +82,7 @@ public class GetPeoplePreferenceSanityTests extends RestTest dataSite.usingUser(consumerUser).usingSite(siteModel).addSiteToFavorites(); restClient.authenticateUser(consumerUser) - .onCoreAPI().usingAuthUser().getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) + .withCoreAPI().usingAuthUser().getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) .assertThat().field("id").is(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) .and().field("value").is("true"); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -95,7 +95,7 @@ public class GetPeoplePreferenceSanityTests extends RestTest dataSite.usingUser(adminUser).usingSite(siteModel).addSiteToFavorites(); restClient.authenticateUser(adminUser) - .onCoreAPI().usingAuthUser().getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) + .withCoreAPI().usingAuthUser().getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) .assertThat().field("id").is(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) .and().field("value").is("true"); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -111,7 +111,7 @@ public class GetPeoplePreferenceSanityTests extends RestTest managerUser.setPassword("newpassword"); restClient.authenticateUser(managerUser) - .onCoreAPI().usingAuthUser().getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); + .withCoreAPI().usingAuthUser().getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesSanityTests.java index 4f18d0f51..5e3377a15 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesSanityTests.java @@ -42,7 +42,7 @@ public class GetPeoplePreferencesSanityTests extends RestTest dataSite.usingUser(managerUser).usingSite(siteModel).addSiteToFavorites(); restClient.authenticateUser(managerUser) - .onCoreAPI() + .withCoreAPI() .usingAuthUser() .getPersonPreferences().assertThat().entriesListIsNotEmpty() .assertThat().paginationExist() @@ -60,7 +60,7 @@ public class GetPeoplePreferencesSanityTests extends RestTest dataSite.usingUser(collaboratorUser).usingSite(siteModel).addSiteToFavorites(); restClient.authenticateUser(collaboratorUser) - .onCoreAPI() + .withCoreAPI() .usingAuthUser().getPersonPreferences().assertThat().entriesListIsNotEmpty() .assertThat().paginationExist() .and().entriesListContains("id", PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); @@ -77,7 +77,7 @@ public class GetPeoplePreferencesSanityTests extends RestTest dataSite.usingUser(contributorUser).usingSite(siteModel).addSiteToFavorites(); restClient.authenticateUser(contributorUser) - .onCoreAPI() + .withCoreAPI() .usingAuthUser().getPersonPreferences().assertThat().entriesListIsNotEmpty() .assertThat().paginationExist() .and().entriesListContains("id", PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); @@ -94,7 +94,7 @@ public class GetPeoplePreferencesSanityTests extends RestTest dataSite.usingUser(consumerUser).usingSite(siteModel).addSiteToFavorites(); restClient.authenticateUser(consumerUser) - .onCoreAPI() + .withCoreAPI() .usingAuthUser().getPersonPreferences().assertThat().entriesListIsNotEmpty() .assertThat().paginationExist() .and().entriesListContains("id", PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); @@ -112,7 +112,7 @@ public class GetPeoplePreferencesSanityTests extends RestTest UserModel adminUser = dataUser.getAdminUser(); restClient.authenticateUser(adminUser) - .onCoreAPI() + .withCoreAPI() .usingUser(managerUser).getPersonPreferences().assertThat().entriesListIsNotEmpty() .assertThat().paginationExist() .and().entriesListContains("id", PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); @@ -131,7 +131,7 @@ public class GetPeoplePreferencesSanityTests extends RestTest managerUser.setPassword("newpassword"); restClient.authenticateUser(managerUser) - .onCoreAPI() + .withCoreAPI() .usingAuthUser() .getPersonPreferences(); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleSanityTests.java index c8e9c4603..f2e22ccfb 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleSanityTests.java @@ -38,7 +38,7 @@ public class GetPeopleSanityTests extends RestTest dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); restClient.authenticateUser(managerUser) - .onCoreAPI() + .withCoreAPI() .usingUser(searchedUser) .getPerson() .assertThat().field("id").is(searchedUser.getUsername()) @@ -57,7 +57,7 @@ public class GetPeopleSanityTests extends RestTest dataUser.usingUser(userModel).addUserToSite(collaboratorUser, siteModel, UserRole.SiteCollaborator); restClient.authenticateUser(collaboratorUser) - .onCoreAPI() + .withCoreAPI() .usingUser(searchedUser) .getPerson() .assertThat().field("id").is(searchedUser.getUsername()) @@ -77,7 +77,7 @@ public class GetPeopleSanityTests extends RestTest dataUser.usingUser(userModel).addUserToSite(contributorUser, siteModel, UserRole.SiteContributor); restClient.authenticateUser(contributorUser) - .onCoreAPI() + .withCoreAPI() .usingUser(searchedUser) .getPerson() .assertThat().field("id").is(searchedUser.getUsername()) @@ -96,7 +96,7 @@ public class GetPeopleSanityTests extends RestTest dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel, UserRole.SiteConsumer); restClient.authenticateUser(consumerUser) - .onCoreAPI() + .withCoreAPI() .usingUser(searchedUser) .getPerson() .assertThat().field("id").is(searchedUser.getUsername()) @@ -114,7 +114,7 @@ public class GetPeopleSanityTests extends RestTest UserModel adminUser = dataUser.getAdminUser(); restClient.authenticateUser(adminUser) - .onCoreAPI() + .withCoreAPI() .usingUser(searchedUser) .getPerson() .assertThat().field("id").is(searchedUser.getUsername()) @@ -134,7 +134,7 @@ public class GetPeopleSanityTests extends RestTest UserModel searchedNonUser = new UserModel("nonexistinguser", DataUser.PASSWORD); restClient.authenticateUser(managerUser) - .onCoreAPI() + .withCoreAPI() .usingUser(searchedNonUser) .getPerson(); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestSanityTests.java index 7a35afa96..de1a9f953 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestSanityTests.java @@ -48,11 +48,11 @@ public class GetSiteMembershipRequestSanityTests extends RestTest { UserModel newMember = dataUser.createRandomTestUser(); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .onCoreAPI() + .withCoreAPI() .usingUser(newMember) .addSiteMembershipRequest(siteModel); - restClient.onCoreAPI().usingUser(newMember).getSiteMembershipRequest(siteModel); + restClient.withCoreAPI().usingUser(newMember).getSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -63,11 +63,11 @@ public class GetSiteMembershipRequestSanityTests extends RestTest { UserModel newMember = dataUser.createRandomTestUser(); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .onCoreAPI() + .withCoreAPI() .usingUser(newMember) .addSiteMembershipRequest(siteModel); - restClient.onCoreAPI().usingUser(newMember).getSiteMembershipRequest(siteModel); + restClient.withCoreAPI().usingUser(newMember).getSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -78,11 +78,11 @@ public class GetSiteMembershipRequestSanityTests extends RestTest { UserModel newMember = dataUser.createRandomTestUser(); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) - .onCoreAPI() + .withCoreAPI() .usingUser(newMember) .addSiteMembershipRequest(siteModel); - restClient.onCoreAPI().usingUser(newMember).getSiteMembershipRequest(siteModel); + restClient.withCoreAPI().usingUser(newMember).getSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -93,11 +93,11 @@ public class GetSiteMembershipRequestSanityTests extends RestTest { UserModel newMember = dataUser.createRandomTestUser(); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .onCoreAPI() + .withCoreAPI() .usingUser(newMember) .addSiteMembershipRequest(siteModel); - restClient.onCoreAPI().usingUser(newMember).getSiteMembershipRequest(siteModel); + restClient.withCoreAPI().usingUser(newMember).getSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -108,11 +108,11 @@ public class GetSiteMembershipRequestSanityTests extends RestTest { UserModel newMember = dataUser.createRandomTestUser(); restClient.authenticateUser(adminUser) - .onCoreAPI() + .withCoreAPI() .usingUser(newMember) .addSiteMembershipRequest(siteModel); - restClient.onCoreAPI().usingUser(newMember).getSiteMembershipRequest(siteModel); + restClient.withCoreAPI().usingUser(newMember).getSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -123,11 +123,11 @@ public class GetSiteMembershipRequestSanityTests extends RestTest { UserModel newMember = dataUser.createRandomTestUser(); restClient.authenticateUser(new UserModel("random user", "random password")) - .onCoreAPI() + .withCoreAPI() .usingUser(newMember) .addSiteMembershipRequest(siteModel); - restClient.onCoreAPI().usingUser(newMember).getSiteMembershipRequest(siteModel); + restClient.withCoreAPI().usingUser(newMember).getSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java index cebf576d4..0ba7a0fdc 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java @@ -35,7 +35,7 @@ public class GetSiteMembershipRequestsSanityTests extends RestTest newMember = dataUser.createRandomTestUser(); restClient.authenticateUser(newMember) - .onCoreAPI() + .withCoreAPI() .usingAuthUser().addSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); @@ -52,7 +52,7 @@ public class GetSiteMembershipRequestsSanityTests extends RestTest dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); restClient.authenticateUser(managerUser) - .onCoreAPI() + .withCoreAPI() .usingUser(newMember).getSiteMembershipRequests().assertThat().entriesListIsNotEmpty(); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -67,7 +67,7 @@ public class GetSiteMembershipRequestsSanityTests extends RestTest dataUser.usingUser(userModel).addUserToSite(collaboratorUser, siteModel, UserRole.SiteCollaborator); restClient.authenticateUser(collaboratorUser) - .onCoreAPI() + .withCoreAPI() .usingUser(newMember).getSiteMembershipRequests(); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); } @@ -82,7 +82,7 @@ public class GetSiteMembershipRequestsSanityTests extends RestTest dataUser.usingUser(userModel).addUserToSite(contributorUser, siteModel, UserRole.SiteContributor); restClient.authenticateUser(contributorUser) - .onCoreAPI() + .withCoreAPI() .usingUser(newMember).getSiteMembershipRequests(); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); } @@ -97,7 +97,7 @@ public class GetSiteMembershipRequestsSanityTests extends RestTest dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel, UserRole.SiteConsumer); restClient.authenticateUser(consumerUser) - .onCoreAPI() + .withCoreAPI() .usingUser(newMember).getSiteMembershipRequests(); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); } @@ -111,7 +111,7 @@ public class GetSiteMembershipRequestsSanityTests extends RestTest UserModel adminUser = dataUser.getAdminUser(); restClient.authenticateUser(adminUser) - .onCoreAPI() + .withCoreAPI() .usingUser(newMember).getSiteMembershipRequests().assertThat().entriesListIsNotEmpty(); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -127,7 +127,7 @@ public class GetSiteMembershipRequestsSanityTests extends RestTest managerUser.setPassword("newpassword"); restClient.authenticateUser(managerUser) - .onCoreAPI() + .withCoreAPI() .usingUser(newMember).getSiteMembershipRequests(); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -138,7 +138,7 @@ public class GetSiteMembershipRequestsSanityTests extends RestTest public void oneUserGetsItsOwnSiteMembershipRequestsWithSuccess() throws Exception { restClient.authenticateUser(newMember) - .onCoreAPI() + .withCoreAPI() .usingUser(newMember).getSiteMembershipRequests().assertThat().entriesListIsNotEmpty(); restClient.assertStatusCodeIs(HttpStatus.OK); } diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java index bbf110d06..48624edfb 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java @@ -38,7 +38,7 @@ public class GetSiteMembershipSanityTests extends RestTest public void siteManagerCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .onCoreAPI() + .withCoreAPI() .usingUser(adminUser) .getSiteMembership(siteModel) .assertThat().field("role").is(UserRole.SiteManager) @@ -53,7 +53,7 @@ public class GetSiteMembershipSanityTests extends RestTest public void siteCollaboratorCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .onCoreAPI() + .withCoreAPI() .usingUser(adminUser) .getSiteMembership(siteModel) .onSite() @@ -68,7 +68,7 @@ public class GetSiteMembershipSanityTests extends RestTest public void siteContributorCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) - .onCoreAPI() + .withCoreAPI() .usingUser(adminUser) .getSiteMembership(siteModel) .assertThat().field("role").is(UserRole.SiteManager) @@ -81,7 +81,7 @@ public class GetSiteMembershipSanityTests extends RestTest public void siteConsumerCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .onCoreAPI() + .withCoreAPI() .usingUser(adminUser) .getSiteMembership(siteModel) .assertThat().field("role").is(UserRole.SiteManager) @@ -96,7 +96,7 @@ public class GetSiteMembershipSanityTests extends RestTest public void adminCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUser) - .onCoreAPI() + .withCoreAPI() .usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) .getSiteMembership(siteModel) .assertThat().field("role").is(UserRole.SiteManager) @@ -112,7 +112,7 @@ public class GetSiteMembershipSanityTests extends RestTest public void unauthenticatedUserCannotRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception { restClient.authenticateUser(new UserModel("random user", "random password")) - .onCoreAPI() + .withCoreAPI() .usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) .getSiteMembership(siteModel); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); diff --git a/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java index 99c6e09e8..a401110eb 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java @@ -36,7 +36,7 @@ public class GetSitesMembershipInformationSanityTests extends RestTest public void siteManagerIsAbleToRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .onCoreAPI() + .withCoreAPI() .usingUser(adminUser) .getSitesMembershipInformation() .assertThat().entriesListIsNotEmpty() @@ -51,7 +51,7 @@ public class GetSitesMembershipInformationSanityTests extends RestTest public void siteCollaboratorIsAbleToRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .onCoreAPI() + .withCoreAPI() .usingUser(adminUser) .getSitesMembershipInformation() .assertThat().entriesListIsNotEmpty() @@ -66,7 +66,7 @@ public class GetSitesMembershipInformationSanityTests extends RestTest public void siteContributorIsAbleToRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) - .onCoreAPI() + .withCoreAPI() .usingUser(adminUser) .getSitesMembershipInformation() .assertThat().entriesListIsNotEmpty() @@ -81,7 +81,7 @@ public class GetSitesMembershipInformationSanityTests extends RestTest public void siteConsumerIsAbleToRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .onCoreAPI() + .withCoreAPI() .usingUser(adminUser) .getSitesMembershipInformation() .assertThat().entriesListIsNotEmpty() @@ -96,7 +96,7 @@ public class GetSitesMembershipInformationSanityTests extends RestTest public void siteAdminIsAbleToRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUser) - .onCoreAPI() + .withCoreAPI() .usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) .getSitesMembershipInformation() .assertThat().entriesListIsNotEmpty() @@ -113,7 +113,7 @@ public class GetSitesMembershipInformationSanityTests extends RestTest { UserModel inexistentUser = new UserModel("inexistent user", "wrong password"); restClient.authenticateUser(inexistentUser) - .onCoreAPI() + .withCoreAPI() .usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) .getSitesMembershipInformation(); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); diff --git a/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestSanityTests.java index 8591c4167..84133c073 100644 --- a/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestSanityTests.java @@ -53,10 +53,10 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest UserModel newMember = dataUser.createRandomTestUser(); restClient.authenticateUser(newMember) - .onCoreAPI() + .withCoreAPI() .usingAuthUser() .addSiteMembershipRequest(siteModel); - restClient.onCoreAPI().usingUser(newMember).updateSiteMembershipRequest(siteModel, updatedMessage) + restClient.withCoreAPI().usingUser(newMember).updateSiteMembershipRequest(siteModel, updatedMessage) .assertMembershipRequestMessageIs(updatedMessage) .and().field("id").is(siteModel.getId()) .and().field("modifiedAt").isNotEmpty(); @@ -71,12 +71,12 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest UserModel newMember = dataUser.createRandomTestUser(); restClient.authenticateUser(newMember) - .onCoreAPI() + .withCoreAPI() .usingAuthUser() .addSiteMembershipRequest(siteModel); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .onCoreAPI() + .withCoreAPI() .usingUser(newMember).updateSiteMembershipRequest(siteModel, updatedMessage); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) @@ -91,12 +91,12 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest UserModel newMember = dataUser.createRandomTestUser(); restClient.authenticateUser(newMember) - .onCoreAPI() + .withCoreAPI() .usingAuthUser() .addSiteMembershipRequest(siteModel); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .onCoreAPI() + .withCoreAPI() .usingUser(newMember) .updateSiteMembershipRequest(siteModel, updatedMessage); @@ -112,11 +112,11 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest UserModel newMember = dataUser.createRandomTestUser(); restClient.authenticateUser(newMember) - .onCoreAPI() + .withCoreAPI() .usingAuthUser().addSiteMembershipRequest(siteModel); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) - .onCoreAPI() + .withCoreAPI() .usingUser(newMember).updateSiteMembershipRequest(siteModel, updatedMessage); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) @@ -131,12 +131,12 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest UserModel newMember = dataUser.createRandomTestUser(); restClient.authenticateUser(newMember) - .onCoreAPI() + .withCoreAPI() .usingAuthUser() .addSiteMembershipRequest(siteModel); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .onCoreAPI() + .withCoreAPI() .usingUser(newMember) .updateSiteMembershipRequest(siteModel, updatedMessage); @@ -153,12 +153,12 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest UserModel otherMember = dataUser.createRandomTestUser(); restClient.authenticateUser(newMember) - .onCoreAPI() + .withCoreAPI() .usingAuthUser() .addSiteMembershipRequest(siteModel); restClient.authenticateUser(otherMember) - .onCoreAPI() + .withCoreAPI() .usingUser(newMember) .updateSiteMembershipRequest(siteModel, updatedMessage); @@ -174,12 +174,12 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest UserModel newMember = dataUser.createRandomTestUser(); restClient.authenticateUser(newMember) - .onCoreAPI() + .withCoreAPI() .usingAuthUser() .addSiteMembershipRequest(siteModel); restClient.authenticateUser(adminUser) - .onCoreAPI() + .withCoreAPI() .usingUser(newMember) .updateSiteMembershipRequest(siteModel, updatedMessage); diff --git a/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java index aad8bed11..777dd778c 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java @@ -54,7 +54,7 @@ public class AddRatingSanityTests extends RestTest public void managerIsAbleToLikeDocument() throws Exception { returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .onCoreAPI().usingResource(document).likeDocument(); + .withCoreAPI().usingResource(document).likeDocument(); restClient.assertStatusCodeIs(HttpStatus.CREATED); returnedRatingModel.assertThat().field("myRating").is("true") @@ -67,7 +67,7 @@ public class AddRatingSanityTests extends RestTest public void collaboratorIsAbleToLikeDocument() throws Exception { returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .onCoreAPI().usingResource(document).likeDocument(); + .withCoreAPI().usingResource(document).likeDocument(); restClient.assertStatusCodeIs(HttpStatus.CREATED); returnedRatingModel.assertThat().field("myRating").is("true") @@ -79,7 +79,7 @@ public class AddRatingSanityTests extends RestTest TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Contributor role is able to post like rating to a document") public void contributorIsAbleToLikeDocument() throws Exception { - returnedRatingModel =restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).onCoreAPI().usingResource(document).likeDocument(); + returnedRatingModel =restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingResource(document).likeDocument(); restClient.assertStatusCodeIs(HttpStatus.CREATED); returnedRatingModel.assertThat().field("myRating").is("true") @@ -91,7 +91,7 @@ public class AddRatingSanityTests extends RestTest TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role is able to post like rating to a document") public void consumerIsAbleToLikeDocument() throws Exception { - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).onCoreAPI().usingResource(document).likeDocument(); + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingResource(document).likeDocument(); restClient.assertStatusCodeIs(HttpStatus.CREATED); returnedRatingModel.assertThat().field("myRating").is("true") @@ -103,7 +103,7 @@ public class AddRatingSanityTests extends RestTest TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify admin user is able to post like rating to a document") public void adminIsAbleToLikeDocument() throws Exception { - returnedRatingModel = restClient.authenticateUser(adminUser).onCoreAPI().usingResource(document).likeDocument(); + returnedRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); restClient.assertStatusCodeIs(HttpStatus.CREATED); returnedRatingModel.assertThat().field("myRating").is("true") @@ -116,7 +116,7 @@ public class AddRatingSanityTests extends RestTest @Bug(id = "MNT-16904") public void unauthenticatedUserIsNotAbleToLikeDocument() throws Exception { - restClient.authenticateUser(new UserModel("random user", "random password")).onCoreAPI().usingResource(document).likeDocument(); + restClient.authenticateUser(new UserModel("random user", "random password")).withCoreAPI().usingResource(document).likeDocument(); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } @@ -124,7 +124,7 @@ public class AddRatingSanityTests extends RestTest TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role is able to post stars rating to a document") public void managerIsAbleToAddStarsToDocument() throws Exception { - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).onCoreAPI().usingResource(document).rateStarsToDocument(5); + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(document).rateStarsToDocument(5); restClient.assertStatusCodeIs(HttpStatus.CREATED); returnedRatingModel.assertThat().field("myRating").is("5") .and().field("id").is("fiveStar") @@ -135,7 +135,7 @@ public class AddRatingSanityTests extends RestTest TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Collaborator role is able to post stars rating to a document") public void collaboratorIsAbleToAddStarsToDocument() throws Exception { - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).onCoreAPI().usingResource(document).rateStarsToDocument(5); + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(document).rateStarsToDocument(5); restClient.assertStatusCodeIs(HttpStatus.CREATED); returnedRatingModel.assertThat().field("myRating").is("5") .and().field("id").is("fiveStar") @@ -147,7 +147,7 @@ public class AddRatingSanityTests extends RestTest TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Contributor role is able to post stars rating to a document") public void contributorIsAbleToAddStarsToDocument() throws Exception { - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).onCoreAPI().usingResource(document).rateStarsToDocument(5); + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingResource(document).rateStarsToDocument(5); restClient.assertStatusCodeIs(HttpStatus.CREATED); returnedRatingModel.assertThat().field("myRating").is("5") .and().field("id").is("fiveStar") @@ -158,7 +158,7 @@ public class AddRatingSanityTests extends RestTest TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role is able to post stars rating to a document") public void consumerIsAbleToAddStarsToDocument() throws Exception { - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).onCoreAPI().usingResource(document).rateStarsToDocument(5); + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingResource(document).rateStarsToDocument(5); restClient.assertStatusCodeIs(HttpStatus.CREATED); returnedRatingModel.assertThat().field("myRating").is("5") .and().field("id").is("fiveStar") @@ -169,7 +169,7 @@ public class AddRatingSanityTests extends RestTest TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify admin user is able to post stars rating to a document") public void adminIsAbleToAddStarsToDocument() throws Exception { - returnedRatingModel = restClient.authenticateUser(adminUser).onCoreAPI().usingResource(document).rateStarsToDocument(3); + returnedRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).rateStarsToDocument(3); restClient.assertStatusCodeIs(HttpStatus.CREATED); returnedRatingModel.assertThat().field("myRating").is(String.valueOf(3)) .and().field("id").is("fiveStar") @@ -181,7 +181,7 @@ public class AddRatingSanityTests extends RestTest @Bug(id = "MNT-16904") public void unauthenticatedUserIsNotAbleToRateStarsToDocument() throws Exception { - restClient.authenticateUser(new UserModel("random user", "random password")).onCoreAPI().usingResource(document).rateStarsToDocument(5); + restClient.authenticateUser(new UserModel("random user", "random password")).withCoreAPI().usingResource(document).rateStarsToDocument(5); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java index ae89140d8..5b21b39fb 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java @@ -51,16 +51,16 @@ public class DeleteRatingSanityTests extends RestTest public void managerIsAbleToDeleteItsOwnRatings() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.onCoreAPI().usingResource(document).likeDocument(); - restClient.onCoreAPI().usingResource(document).rateStarsToDocument(5); + restClient.withCoreAPI().usingResource(document).likeDocument(); + restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - restClient.onCoreAPI().usingResource(document).deleteLikeRating(); + restClient.withCoreAPI().usingResource(document).deleteLikeRating(); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.onCoreAPI().usingResource(document).deleteFiveStarRating(); + restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - returnedRatingModelCollection = restClient.onCoreAPI().usingResource(document).getRatings(); + returnedRatingModelCollection = restClient.withCoreAPI().usingResource(document).getRatings(); restClient.assertStatusCodeIs(HttpStatus.OK); returnedRatingModelCollection.assertNodeIsNotLiked() .assertNodeHasNoFiveStarRating() @@ -74,16 +74,16 @@ public class DeleteRatingSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.onCoreAPI().usingResource(document).likeDocument(); - restClient.onCoreAPI().usingResource(document).rateStarsToDocument(5); + restClient.withCoreAPI().usingResource(document).likeDocument(); + restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - restClient.onCoreAPI().usingResource(document).deleteLikeRating(); + restClient.withCoreAPI().usingResource(document).deleteLikeRating(); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.onCoreAPI().usingResource(document).deleteFiveStarRating(); + restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - returnedRatingModelCollection = restClient.onCoreAPI().usingResource(document).getRatings(); + returnedRatingModelCollection = restClient.withCoreAPI().usingResource(document).getRatings(); restClient.assertStatusCodeIs(HttpStatus.OK); returnedRatingModelCollection.assertNodeIsNotLiked() .assertNodeHasNoFiveStarRating() @@ -97,16 +97,16 @@ public class DeleteRatingSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - restClient.onCoreAPI().usingResource(document).likeDocument(); - restClient.onCoreAPI().usingResource(document).rateStarsToDocument(5); + restClient.withCoreAPI().usingResource(document).likeDocument(); + restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - restClient.onCoreAPI().usingResource(document).deleteLikeRating(); + restClient.withCoreAPI().usingResource(document).deleteLikeRating(); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.onCoreAPI().usingResource(document).deleteFiveStarRating(); + restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - returnedRatingModelCollection = restClient.onCoreAPI().usingResource(document).getRatings(); + returnedRatingModelCollection = restClient.withCoreAPI().usingResource(document).getRatings(); restClient.assertStatusCodeIs(HttpStatus.OK); returnedRatingModelCollection.assertNodeIsNotLiked() .assertNodeHasNoFiveStarRating() @@ -120,16 +120,16 @@ public class DeleteRatingSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.onCoreAPI().usingResource(document).likeDocument(); - restClient.onCoreAPI().usingResource(document).rateStarsToDocument(5); + restClient.withCoreAPI().usingResource(document).likeDocument(); + restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - restClient.onCoreAPI().usingResource(document).deleteLikeRating(); + restClient.withCoreAPI().usingResource(document).deleteLikeRating(); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.onCoreAPI().usingResource(document).deleteFiveStarRating(); + restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - returnedRatingModelCollection = restClient.onCoreAPI().usingResource(document).getRatings(); + returnedRatingModelCollection = restClient.withCoreAPI().usingResource(document).getRatings(); restClient.assertStatusCodeIs(HttpStatus.OK); returnedRatingModelCollection.assertNodeIsNotLiked() .assertNodeHasNoFiveStarRating() @@ -145,16 +145,16 @@ public class DeleteRatingSanityTests extends RestTest restClient.authenticateUser(adminUser); - restClient.onCoreAPI().usingResource(document).likeDocument(); - restClient.onCoreAPI().usingResource(document).rateStarsToDocument(5); + restClient.withCoreAPI().usingResource(document).likeDocument(); + restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - restClient.onCoreAPI().usingResource(document).deleteLikeRating(); + restClient.withCoreAPI().usingResource(document).deleteLikeRating(); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.onCoreAPI().usingResource(document).deleteFiveStarRating(); + restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - returnedRatingModelCollection = restClient.onCoreAPI().usingResource(document).getRatings(); + returnedRatingModelCollection = restClient.withCoreAPI().usingResource(document).getRatings(); restClient.assertStatusCodeIs(HttpStatus.OK); returnedRatingModelCollection.assertNodeIsNotLiked() .assertNodeHasNoFiveStarRating() @@ -169,15 +169,15 @@ public class DeleteRatingSanityTests extends RestTest document = dataContent.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); restClient.authenticateUser(adminUser); - restClient.onCoreAPI().usingResource(document).likeDocument(); - restClient.onCoreAPI().usingResource(document).rateStarsToDocument(5); + restClient.withCoreAPI().usingResource(document).likeDocument(); + restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); restClient.authenticateUser(new UserModel("random user", "random password")); - restClient.onCoreAPI().usingResource(document).deleteLikeRating(); + restClient.withCoreAPI().usingResource(document).deleteLikeRating(); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); - restClient.onCoreAPI().usingResource(document).deleteFiveStarRating(); + restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } @@ -191,15 +191,15 @@ public class DeleteRatingSanityTests extends RestTest restClient.authenticateUser(userA); - restClient.onCoreAPI().usingResource(document).likeDocument(); - restClient.onCoreAPI().usingResource(document).rateStarsToDocument(5); + restClient.withCoreAPI().usingResource(document).likeDocument(); + restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); restClient.authenticateUser(userB); - restClient.authenticateUser(userB).onCoreAPI().usingResource(document).deleteLikeRating(); + restClient.authenticateUser(userB).withCoreAPI().usingResource(document).deleteLikeRating(); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); - restClient.onCoreAPI().usingResource(document).deleteFiveStarRating(); + restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java index ee1ee5026..1529d25f5 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java @@ -53,14 +53,14 @@ public class GetRatingSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.onCoreAPI().usingResource(document).likeDocument(); - restClient.onCoreAPI().usingResource(document).rateStarsToDocument(5); + restClient.withCoreAPI().usingResource(document).likeDocument(); + restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - restRatingModel = restClient.onCoreAPI().usingResource(document).getLikeRating(); + restRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating(); restClient.assertStatusCodeIs(HttpStatus.OK); restRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); - restRatingModel = restClient.onCoreAPI().usingResource(document).getFiveStarRating(); + restRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); restClient.assertStatusCodeIs(HttpStatus.OK); restRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").is("5"); } @@ -71,14 +71,14 @@ public class GetRatingSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.onCoreAPI().usingResource(document).likeDocument(); - restClient.onCoreAPI().usingResource(document).rateStarsToDocument(5); + restClient.withCoreAPI().usingResource(document).likeDocument(); + restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - restRatingModel = restClient.onCoreAPI().usingResource(document).getLikeRating(); + restRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating(); restClient.assertStatusCodeIs(HttpStatus.OK); restRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); - restRatingModel = restClient.onCoreAPI().usingResource(document).getFiveStarRating(); + restRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); restClient.assertStatusCodeIs(HttpStatus.OK); restRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").is("5"); } @@ -89,14 +89,14 @@ public class GetRatingSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - restClient.onCoreAPI().usingResource(document).likeDocument(); - restClient.onCoreAPI().usingResource(document).rateStarsToDocument(5); + restClient.withCoreAPI().usingResource(document).likeDocument(); + restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - restRatingModel = restClient.onCoreAPI().usingResource(document).getLikeRating(); + restRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating(); restClient.assertStatusCodeIs(HttpStatus.OK); restRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); - restRatingModel = restClient.onCoreAPI().usingResource(document).getFiveStarRating(); + restRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); restClient.assertStatusCodeIs(HttpStatus.OK); restRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").is("5"); } @@ -107,14 +107,14 @@ public class GetRatingSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.onCoreAPI().usingResource(document).likeDocument(); - restClient.onCoreAPI().usingResource(document).rateStarsToDocument(5); + restClient.withCoreAPI().usingResource(document).likeDocument(); + restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - restRatingModel = restClient.onCoreAPI().usingResource(document).getLikeRating(); + restRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating(); restClient.assertStatusCodeIs(HttpStatus.OK); restRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); - restRatingModel = restClient.onCoreAPI().usingResource(document).getFiveStarRating(); + restRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); restClient.assertStatusCodeIs(HttpStatus.OK); restRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").is("5"); } @@ -126,14 +126,14 @@ public class GetRatingSanityTests extends RestTest document = dataContent.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); restClient.authenticateUser(adminUser); - restClient.onCoreAPI().usingResource(document).likeDocument(); - restClient.onCoreAPI().usingResource(document).rateStarsToDocument(5); + restClient.withCoreAPI().usingResource(document).likeDocument(); + restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - restRatingModel = restClient.onCoreAPI().usingResource(document).getLikeRating(); + restRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating(); restClient.assertStatusCodeIs(HttpStatus.OK); restRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); - restRatingModel = restClient.onCoreAPI().usingResource(document).getFiveStarRating(); + restRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); restClient.assertStatusCodeIs(HttpStatus.OK); restRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").is("5"); } @@ -144,15 +144,15 @@ public class GetRatingSanityTests extends RestTest public void unauthenticatedUserIsNotAbleToRetrieveRating() throws Exception { restClient.authenticateUser(adminUser); - restClient.onCoreAPI().usingResource(document).likeDocument(); - restClient.onCoreAPI().usingResource(document).rateStarsToDocument(5); + restClient.withCoreAPI().usingResource(document).likeDocument(); + restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); restClient.authenticateUser(new UserModel("random user", "random password")); - restClient.onCoreAPI().usingResource(document).getLikeRating(); + restClient.withCoreAPI().usingResource(document).getLikeRating(); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(ErrorModel.AUTHENTICATION_FAILED); - restClient.onCoreAPI().usingResource(document).getFiveStarRating(); + restClient.withCoreAPI().usingResource(document).getFiveStarRating(); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(ErrorModel.AUTHENTICATION_FAILED); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java index 0d399f2a9..62c24caff 100644 --- a/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java @@ -40,7 +40,7 @@ public class AddSiteMemberSanityTests extends RestTest UserModel testUser = dataUser.createRandomTestUser("testUser"); testUser.setUserRole(UserRole.SiteConsumer); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.onCoreAPI().usingSite(siteModel).addPerson(testUser) + restClient.withCoreAPI().usingSite(siteModel).addPerson(testUser) .assertThat().field("id").is(testUser.getUsername()) .and().field("role").is(testUser.getUserRole()); restClient.assertStatusCodeIs(HttpStatus.CREATED); @@ -53,7 +53,7 @@ public class AddSiteMemberSanityTests extends RestTest UserModel testUser = dataUser.createRandomTestUser("testUser"); testUser.setUserRole(UserRole.SiteConsumer); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .onCoreAPI().usingSite(siteModel).addPerson(testUser); + .withCoreAPI().usingSite(siteModel).addPerson(testUser); restClient.assertLastError().containsSummary("Permission was denied"); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); @@ -66,7 +66,7 @@ public class AddSiteMemberSanityTests extends RestTest UserModel testUser = dataUser.createRandomTestUser("testUser"); testUser.setUserRole(UserRole.SiteConsumer); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) - .onCoreAPI().usingSite(siteModel).addPerson(testUser); + .withCoreAPI().usingSite(siteModel).addPerson(testUser); restClient.assertLastError().containsSummary("Permission was denied"); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); } @@ -78,7 +78,7 @@ public class AddSiteMemberSanityTests extends RestTest UserModel testUser = dataUser.createRandomTestUser("testUser"); testUser.setUserRole(UserRole.SiteConsumer); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .onCoreAPI().usingSite(siteModel).addPerson(testUser); + .withCoreAPI().usingSite(siteModel).addPerson(testUser); restClient.assertLastError().containsSummary("Permission was denied"); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); } @@ -90,7 +90,7 @@ public class AddSiteMemberSanityTests extends RestTest UserModel testUser = dataUser.createRandomTestUser("testUser"); testUser.setUserRole(UserRole.SiteConsumer); restClient.authenticateUser(adminUserModel) - .onCoreAPI().usingSite(siteModel).addPerson(testUser) + .withCoreAPI().usingSite(siteModel).addPerson(testUser) .and().field("id").is(testUser.getUsername()) .and().field("role").is(testUser.getUserRole()); restClient.assertStatusCodeIs(HttpStatus.CREATED); @@ -104,7 +104,7 @@ public class AddSiteMemberSanityTests extends RestTest testUser.setUserRole(UserRole.SiteConsumer); UserModel inexistentUser = new UserModel("inexistent user", "inexistent password"); restClient.authenticateUser(inexistentUser) - .onCoreAPI().usingSite(siteModel).addPerson(testUser); + .withCoreAPI().usingSite(siteModel).addPerson(testUser); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java index da6df431b..45478751d 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java @@ -40,8 +40,8 @@ public class GetSiteContainerSanityTests extends RestTest public void getSiteContainerWithManagerRole() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - siteContainerModel = restClient.onCoreAPI().usingSite(siteModel).getSiteContainers().getOneRandomEntry(); - restClient.onCoreAPI().usingSite(siteModel).getSiteContainer(siteContainerModel.onModel()) + siteContainerModel = restClient.withCoreAPI().usingSite(siteModel).getSiteContainers().getOneRandomEntry(); + restClient.withCoreAPI().usingSite(siteModel).getSiteContainer(siteContainerModel.onModel()) .assertThat().field("id").is(siteContainerModel.onModel().getId()) .and().field("folderId").is(siteContainerModel.onModel().getFolderId()); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -52,8 +52,8 @@ public class GetSiteContainerSanityTests extends RestTest public void getSiteContainerWithCollaboratorRole() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - siteContainerModel = restClient.onCoreAPI().usingSite(siteModel).getSiteContainers().getOneRandomEntry(); - restClient.onCoreAPI().usingSite(siteModel).getSiteContainer(siteContainerModel.onModel()) + siteContainerModel = restClient.withCoreAPI().usingSite(siteModel).getSiteContainers().getOneRandomEntry(); + restClient.withCoreAPI().usingSite(siteModel).getSiteContainer(siteContainerModel.onModel()) .and().field("id").is(siteContainerModel.onModel().getId()) .and().field("folderId").is(siteContainerModel.onModel().getFolderId()); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -64,8 +64,8 @@ public class GetSiteContainerSanityTests extends RestTest public void getSiteContainerWithContributorRole() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - siteContainerModel = restClient.onCoreAPI().usingSite(siteModel).getSiteContainers().getOneRandomEntry(); - restClient.onCoreAPI().usingSite(siteModel).getSiteContainer(siteContainerModel.onModel()) + siteContainerModel = restClient.withCoreAPI().usingSite(siteModel).getSiteContainers().getOneRandomEntry(); + restClient.withCoreAPI().usingSite(siteModel).getSiteContainer(siteContainerModel.onModel()) .assertThat().field("id").is(siteContainerModel.onModel().getId()) .and().field("folderId").is(siteContainerModel.onModel().getFolderId()); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -76,8 +76,8 @@ public class GetSiteContainerSanityTests extends RestTest public void getSiteContainerWithConsumerRole() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - siteContainerModel = restClient.onCoreAPI().usingSite(siteModel).getSiteContainers().getOneRandomEntry(); - restClient.onCoreAPI().usingSite(siteModel).getSiteContainer(siteContainerModel.onModel()) + siteContainerModel = restClient.withCoreAPI().usingSite(siteModel).getSiteContainers().getOneRandomEntry(); + restClient.withCoreAPI().usingSite(siteModel).getSiteContainer(siteContainerModel.onModel()) .assertThat().field("id").is(siteContainerModel.onModel().getId()) .and().field("folderId").is(siteContainerModel.onModel().getFolderId()); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -88,8 +88,8 @@ public class GetSiteContainerSanityTests extends RestTest public void getSiteContainerWithAdminUser() throws Exception { restClient.authenticateUser(adminUserModel); - siteContainerModel = restClient.onCoreAPI().usingSite(siteModel).getSiteContainers().getOneRandomEntry(); - restClient.onCoreAPI().usingSite(siteModel).getSiteContainer(siteContainerModel.onModel()) + siteContainerModel = restClient.withCoreAPI().usingSite(siteModel).getSiteContainers().getOneRandomEntry(); + restClient.withCoreAPI().usingSite(siteModel).getSiteContainer(siteContainerModel.onModel()) .assertThat().field("id").is(siteContainerModel.onModel().getId()) .and().field("folderId").is(siteContainerModel.onModel().getFolderId()); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -102,12 +102,12 @@ public class GetSiteContainerSanityTests extends RestTest public void unauthenticatedUserIsNotAuthorizedToRetrieveSiteContainer() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - siteContainerModel = restClient.onCoreAPI().usingSite(siteModel).getSiteContainers().getOneRandomEntry(); + siteContainerModel = restClient.withCoreAPI().usingSite(siteModel).getSiteContainers().getOneRandomEntry(); userModel = dataUser.createRandomTestUser(); userModel.setPassword("user wrong password"); dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); restClient.authenticateUser(userModel) - .onCoreAPI().usingSite(siteModel).getSiteContainer(siteContainerModel.onModel()); + .withCoreAPI().usingSite(siteModel).getSiteContainer(siteContainerModel.onModel()); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java index 9640b97a2..a4b7cddb1 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java @@ -47,7 +47,7 @@ public class GetSiteContainersSanityTests extends RestTest public void getSiteContainersWithManagerRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.onCoreAPI().usingSite(siteModel).getSiteContainers() + restClient.withCoreAPI().usingSite(siteModel).getSiteContainers() .assertThat().entriesListIsNotEmpty() .assertThat().paginationExist() .and().paginationField("count").isNot("0"); @@ -59,7 +59,7 @@ public class GetSiteContainersSanityTests extends RestTest public void getSiteContainersWithCollaboratorRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.onCoreAPI().usingSite(siteModel).getSiteContainers() + restClient.withCoreAPI().usingSite(siteModel).getSiteContainers() .assertThat().entriesListIsNotEmpty() .assertThat().paginationExist() .and().paginationField("count").isNot("0"); @@ -71,7 +71,7 @@ public class GetSiteContainersSanityTests extends RestTest public void getSiteContainersWithContributorRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - restClient.onCoreAPI().usingSite(siteModel).getSiteContainers() + restClient.withCoreAPI().usingSite(siteModel).getSiteContainers() .assertThat().entriesListIsNotEmpty() .assertThat().paginationExist() .and().paginationField("count").isNot("0"); @@ -83,7 +83,7 @@ public class GetSiteContainersSanityTests extends RestTest public void getSiteContainersWithConsumerRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.onCoreAPI().usingSite(siteModel).getSiteContainers() + restClient.withCoreAPI().usingSite(siteModel).getSiteContainers() .assertThat().entriesListIsNotEmpty() .assertThat().paginationExist() .and().paginationField("count").isNot("0"); @@ -95,7 +95,7 @@ public class GetSiteContainersSanityTests extends RestTest public void getSiteContainersWithAdminUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); - restClient.onCoreAPI().usingSite(siteModel).getSiteContainers() + restClient.withCoreAPI().usingSite(siteModel).getSiteContainers() .assertThat().entriesListIsNotEmpty() .assertThat().paginationExist() .and().paginationField("count").isNot("0"); @@ -111,7 +111,7 @@ public class GetSiteContainersSanityTests extends RestTest userModel.setPassword("user wrong password"); dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); restClient.authenticateUser(userModel) - .onCoreAPI().usingSite(siteModel).getSiteContainers(); + .withCoreAPI().usingSite(siteModel).getSiteContainers(); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java index c9fdb171c..719950e32 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java @@ -42,7 +42,7 @@ public class GetSiteMemberSanityTests extends RestTest public void getSiteMemberWithManagerRole() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.onCoreAPI().usingSite(siteModel).getSiteMember(userModel) + restClient.withCoreAPI().usingSite(siteModel).getSiteMember(userModel) .assertThat().field("id").is(userModel.getUsername()) .and().field("role").is(userModel.getUserRole()); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -53,7 +53,7 @@ public class GetSiteMemberSanityTests extends RestTest public void getSiteMemberWithCollaboratorRole() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.onCoreAPI().usingSite(siteModel).getSiteMember(userModel) + restClient.withCoreAPI().usingSite(siteModel).getSiteMember(userModel) .and().field("id").is(userModel.getUsername()) .and().field("role").is(userModel.getUserRole()); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -64,7 +64,7 @@ public class GetSiteMemberSanityTests extends RestTest public void getSiteMemberWithContributorRole() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - restClient.onCoreAPI().usingSite(siteModel).getSiteMember(userModel) + restClient.withCoreAPI().usingSite(siteModel).getSiteMember(userModel) .and().field("id").is(userModel.getUsername()) .and().field("role").is(userModel.getUserRole()); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -75,7 +75,7 @@ public class GetSiteMemberSanityTests extends RestTest public void getSiteMemberWithConsumerRole() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.onCoreAPI().usingSite(siteModel).getSiteMember(userModel) + restClient.withCoreAPI().usingSite(siteModel).getSiteMember(userModel) .and().field("id").is(userModel.getUsername()) .and().field("role").is(userModel.getUserRole()); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -86,7 +86,7 @@ public class GetSiteMemberSanityTests extends RestTest public void getSiteMemberWithAdminUser() throws Exception { restClient.authenticateUser(adminUser); - restClient.onCoreAPI().usingSite(siteModel).getSiteMember(userModel) + restClient.withCoreAPI().usingSite(siteModel).getSiteMember(userModel) .and().field("id").is(userModel.getUsername()) .and().field("role").is(userModel.getUserRole()); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -99,7 +99,7 @@ public class GetSiteMemberSanityTests extends RestTest { UserModel inexistentUser = new UserModel("inexistent user", "inexistent password"); restClient.authenticateUser(inexistentUser); - restClient.onCoreAPI().usingSite(siteModel).getSiteMember(userModel); + restClient.withCoreAPI().usingSite(siteModel).getSiteMember(userModel); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java index 6d8290986..acf806253 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java @@ -48,7 +48,7 @@ public class GetSiteMembersSanityTests extends RestTest public void getSiteMembersWithManagerRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .onCoreAPI().usingSite(siteModel).getSiteMembers().assertThat().entriesListIsNotEmpty() + .withCoreAPI().usingSite(siteModel).getSiteMembers().assertThat().entriesListIsNotEmpty() .and().entriesListContains("id", usersWithRoles.getOneUserWithRole(UserRole.SiteManager).getUsername()) .and().entriesListContains("role", usersWithRoles.getOneUserWithRole(UserRole.SiteManager).getUserRole().toString()); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -59,7 +59,7 @@ public class GetSiteMembersSanityTests extends RestTest public void getSiteMembersWithCollaboratorRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .onCoreAPI().usingSite(siteModel).getSiteMembers().assertThat().entriesListIsNotEmpty().assertThat() + .withCoreAPI().usingSite(siteModel).getSiteMembers().assertThat().entriesListIsNotEmpty().assertThat() .entriesListContains("id", usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator).getUsername()).and() .entriesListContains("role", usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator).getUserRole().toString()); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -70,7 +70,7 @@ public class GetSiteMembersSanityTests extends RestTest public void getSiteMembersWithContributorRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) - .onCoreAPI().usingSite(siteModel).getSiteMembers().assertThat().entriesListIsNotEmpty() + .withCoreAPI().usingSite(siteModel).getSiteMembers().assertThat().entriesListIsNotEmpty() .and().entriesListContains("id", usersWithRoles.getOneUserWithRole(UserRole.SiteContributor).getUsername()) .and().entriesListContains("role", usersWithRoles.getOneUserWithRole(UserRole.SiteContributor).getUserRole().toString()); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -81,7 +81,7 @@ public class GetSiteMembersSanityTests extends RestTest public void getSiteMembersWithConsumerRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .onCoreAPI().usingSite(siteModel).getSiteMembers().assertThat().entriesListIsNotEmpty() + .withCoreAPI().usingSite(siteModel).getSiteMembers().assertThat().entriesListIsNotEmpty() .and().entriesListContains("id", usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer).getUsername()) .and().entriesListContains("role", usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer).getUserRole().toString()); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -92,7 +92,7 @@ public class GetSiteMembersSanityTests extends RestTest public void getSiteMembersWithAdminUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUser) - .onCoreAPI().usingSite(siteModel).getSiteMembers().assertThat().entriesListIsNotEmpty() + .withCoreAPI().usingSite(siteModel).getSiteMembers().assertThat().entriesListIsNotEmpty() .and().entriesListContains("id", adminUser.getUsername()) .when().assertThat().entriesListContains("role", "SiteManager"); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -107,7 +107,7 @@ public class GetSiteMembersSanityTests extends RestTest userModel.setPassword("user wrong password"); dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); restClient.authenticateUser(userModel) - .onCoreAPI().usingSite(siteModel).getSiteMembers(); + .withCoreAPI().usingSite(siteModel).getSiteMembers(); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteSanityTests.java index 0db1549e9..e3afe1129 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteSanityTests.java @@ -50,7 +50,7 @@ public class GetSiteSanityTests extends RestTest public void getSiteWithManagerRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .onCoreAPI().usingSite(siteModel) + .withCoreAPI().usingSite(siteModel) .getSite() .and().field("id").is(siteModel.getId()) .and().field("title").is(siteModel.getTitle()); @@ -63,7 +63,7 @@ public class GetSiteSanityTests extends RestTest public void getSiteWithCollaboratorRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .onCoreAPI().usingSite(siteModel) + .withCoreAPI().usingSite(siteModel) .getSite() .and().field("id").is(siteModel.getId()) .and().field("title").is(siteModel.getTitle()); @@ -75,7 +75,7 @@ public class GetSiteSanityTests extends RestTest public void getSiteWithContributorRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) - .onCoreAPI().usingSite(siteModel) + .withCoreAPI().usingSite(siteModel) .getSite() .and().field("id").is(siteModel.getId()) .and().field("title").is(siteModel.getTitle()); @@ -87,7 +87,7 @@ public class GetSiteSanityTests extends RestTest public void getSiteWithConsumerRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .onCoreAPI().usingSite(siteModel) + .withCoreAPI().usingSite(siteModel) .getSite() .and().field("id").is(siteModel.getId()) .and().field("title").is(siteModel.getTitle()); @@ -99,7 +99,7 @@ public class GetSiteSanityTests extends RestTest public void getSiteWithAdminRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel) - .onCoreAPI().usingSite(siteModel) + .withCoreAPI().usingSite(siteModel) .getSite() .and().field("id").is(siteModel.getId()) .and().field("title").is(siteModel.getTitle()); @@ -115,7 +115,7 @@ public class GetSiteSanityTests extends RestTest userModel.setPassword("user wrong password"); dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); restClient.authenticateUser(userModel).withParams("maxItems=10000") - .onCoreAPI() + .withCoreAPI() .getSites(); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java index 6b89c4515..3414c662c 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java @@ -48,7 +48,7 @@ public class GetSitesSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .onCoreAPI().getSites() + .withCoreAPI().getSites() .assertThat().entriesListIsNotEmpty() .assertThat().entriesListContains("id", siteModel.getId()) .and().paginationExist(); @@ -60,7 +60,7 @@ public class GetSitesSanityTests extends RestTest public void collaboratorIsAbleToRetrieveSites() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .onCoreAPI().getSites().assertThat().entriesListIsNotEmpty() + .withCoreAPI().getSites().assertThat().entriesListIsNotEmpty() .assertThat().entriesListContains("id", siteModel.getId()) .and().paginationExist(); @@ -73,7 +73,7 @@ public class GetSitesSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) - .onCoreAPI().getSites() + .withCoreAPI().getSites() .assertThat().entriesListIsNotEmpty() .assertThat().entriesListContains("id", siteModel.getId()) .and().paginationExist(); @@ -86,7 +86,7 @@ public class GetSitesSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .onCoreAPI().getSites() + .withCoreAPI().getSites() .assertThat().entriesListIsNotEmpty() .assertThat().entriesListContains("id", siteModel.getId()) .and().paginationExist(); @@ -98,7 +98,7 @@ public class GetSitesSanityTests extends RestTest public void adminUserIsAbleToRetrieveSites() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel) - .onCoreAPI().getSites() + .withCoreAPI().getSites() .assertThat().entriesListIsNotEmpty() .assertThat().entriesListContains("id", siteModel.getId()) .and().paginationExist(); @@ -115,7 +115,7 @@ public class GetSitesSanityTests extends RestTest userModel.setPassword("user wrong password"); dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); restClient.authenticateUser(userModel) - .onCoreAPI().getSites(); + .withCoreAPI().getSites(); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java index 27942c321..f0f5df579 100644 --- a/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java @@ -49,9 +49,9 @@ public class RemoveSiteMemberSanityTests extends RestTest description = "Verify that site manager can delete site member and gets status code 204, 'No Content'") public void siteManagerIsAbleToDeleteSiteMember() throws Exception{ restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.onCoreAPI().usingSite(siteModel).deleteSiteMember(testUserModel); + restClient.withCoreAPI().usingSite(siteModel).deleteSiteMember(testUserModel); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.onCoreAPI().getSites().assertThat().entriesListDoesNotContain("id", testUserModel.getUsername()); + restClient.withCoreAPI().getSites().assertThat().entriesListDoesNotContain("id", testUserModel.getUsername()); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -60,10 +60,10 @@ public class RemoveSiteMemberSanityTests extends RestTest description = "Verify that site collaborator cannot delete site member and gets status code 403, 'Forbidden'") public void siteCollaboratorIsNotAbleToDeleteSiteMember() throws Exception{ restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.onCoreAPI().usingSite(siteModel).deleteSiteMember(testUserModel); + restClient.withCoreAPI().usingSite(siteModel).deleteSiteMember(testUserModel); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - restClient.onCoreAPI().getSites().assertThat().entriesListContains("id", testUserModel.getUsername()); + restClient.withCoreAPI().getSites().assertThat().entriesListContains("id", testUserModel.getUsername()); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -72,10 +72,10 @@ public class RemoveSiteMemberSanityTests extends RestTest description = "Verify that site contributor cannot delete site member and gets status code 403, 'Forbidden'") public void siteContributorIsNotAbleToDeleteSiteMember() throws Exception{ restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - restClient.onCoreAPI().usingSite(siteModel).deleteSiteMember(testUserModel); + restClient.withCoreAPI().usingSite(siteModel).deleteSiteMember(testUserModel); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - restClient.onCoreAPI().getSites().assertThat().entriesListContains("id", testUserModel.getUsername()); + restClient.withCoreAPI().getSites().assertThat().entriesListContains("id", testUserModel.getUsername()); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -84,10 +84,10 @@ public class RemoveSiteMemberSanityTests extends RestTest description = "Verify that site consumer cannot delete site member and gets status code 403, 'Forbidden'") public void siteConsumerIsNotAbleToDeleteSiteMember() throws Exception{ restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .onCoreAPI().usingSite(siteModel).deleteSiteMember(testUserModel); + .withCoreAPI().usingSite(siteModel).deleteSiteMember(testUserModel); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - restClient.onCoreAPI().getSites().assertThat().entriesListContains("id", testUserModel.getUsername()); + restClient.withCoreAPI().getSites().assertThat().entriesListContains("id", testUserModel.getUsername()); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -95,10 +95,10 @@ public class RemoveSiteMemberSanityTests extends RestTest description = "Verify that admin user can delete site member and gets status code 204, 'No Content'") public void adminUserIsAbleToDeleteSiteMember() throws Exception{ restClient.authenticateUser(adminUserModel) - .onCoreAPI().usingSite(siteModel).deleteSiteMember(testUserModel); + .withCoreAPI().usingSite(siteModel).deleteSiteMember(testUserModel); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.onCoreAPI().getSites().assertThat().entriesListDoesNotContain("id", testUserModel.getUsername()); + restClient.withCoreAPI().getSites().assertThat().entriesListDoesNotContain("id", testUserModel.getUsername()); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -107,7 +107,7 @@ public class RemoveSiteMemberSanityTests extends RestTest public void unauthenticatedUserIsNotAuthorizedToDeleteSiteMember() throws Exception{ UserModel inexistentUser = new UserModel("inexistent user", "inexistent password"); restClient.authenticateUser(inexistentUser) - .onCoreAPI().usingSite(siteModel).deleteSiteMember(testUserModel); + .withCoreAPI().usingSite(siteModel).deleteSiteMember(testUserModel); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } diff --git a/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java index 297155c7e..e1dbdb1a8 100644 --- a/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java @@ -38,7 +38,7 @@ public class UpdateSiteMemberSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); testUserModel.setUserRole(UserRole.SiteConsumer); - restClient.onCoreAPI().usingSite(siteModel).updateSiteMember(testUserModel) + restClient.withCoreAPI().usingSite(siteModel).updateSiteMember(testUserModel) .assertThat().field("id").is(testUserModel.getUsername()) .and().field("role").is(testUserModel.getUserRole()); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -51,7 +51,7 @@ public class UpdateSiteMemberSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); testUserModel.setUserRole(UserRole.SiteCollaborator); - restClient.onCoreAPI().usingSite(siteModel).updateSiteMember(testUserModel); + restClient.withCoreAPI().usingSite(siteModel).updateSiteMember(testUserModel); restClient.assertLastError() .containsSummary(String.format("The current user does not have permissions to modify the membership details of the site %s.", siteModel.getTitle())); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); @@ -64,7 +64,7 @@ public class UpdateSiteMemberSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); testUserModel.setUserRole(UserRole.SiteCollaborator); - restClient.onCoreAPI().usingSite(siteModel).updateSiteMember(testUserModel); + restClient.withCoreAPI().usingSite(siteModel).updateSiteMember(testUserModel); restClient.assertLastError() .containsSummary(String.format("The current user does not have permissions to modify the membership details of the site %s.", siteModel.getTitle())); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); @@ -77,7 +77,7 @@ public class UpdateSiteMemberSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); testUserModel.setUserRole(UserRole.SiteCollaborator); - restClient.onCoreAPI().usingSite(siteModel).updateSiteMember(testUserModel); + restClient.withCoreAPI().usingSite(siteModel).updateSiteMember(testUserModel); restClient.assertLastError() .containsSummary(String.format("The current user does not have permissions to modify the membership details of the site %s.", siteModel.getTitle())); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); @@ -89,7 +89,7 @@ public class UpdateSiteMemberSanityTests extends RestTest { restClient.authenticateUser(adminUserModel); testUserModel.setUserRole(UserRole.SiteCollaborator); - restClient.onCoreAPI().usingSite(siteModel).updateSiteMember(testUserModel) + restClient.withCoreAPI().usingSite(siteModel).updateSiteMember(testUserModel) .assertThat().field("id").is(testUserModel.getUsername()) .and().field("role").is(testUserModel.getUserRole()); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -102,7 +102,7 @@ public class UpdateSiteMemberSanityTests extends RestTest UserModel inexistentUser = new UserModel("inexistent user", "inexistent password"); restClient.authenticateUser(inexistentUser); testUserModel.setUserRole(UserRole.SiteCollaborator); - restClient.onCoreAPI().usingSite(siteModel).updateSiteMember(testUserModel); + restClient.withCoreAPI().usingSite(siteModel).updateSiteMember(testUserModel); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java index c5acd11dd..88ef91bc9 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java @@ -29,14 +29,14 @@ public class GetProcessDefinitionImageSanityTests extends RestWorkflowTest { testUser = dataUser.createRandomTestUser(); restClient.authenticateUser(dataUser.getAdminUser()); - randomProcessDefinition = restClient.onWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry(); + randomProcessDefinition = restClient.withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry(); } @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.SANITY, description = "Verify Any user gets a specific process definition image for non-network deployments using REST API and status code is OK (200)") public void anyUserGetsProcessDefinitionImage() throws Exception { restClient.authenticateUser(testUser); - restClient.onWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionImage() + restClient.withWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionImage() .assertResponseContainsImage(); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -44,7 +44,7 @@ public class GetProcessDefinitionImageSanityTests extends RestWorkflowTest @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets a specific process definition image for non-network deployments using REST API and status code is OK (200)") public void adminGetsProcessDefinitionImage() throws Exception { - restClient.onWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionImage() + restClient.withWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionImage() .assertResponseContainsImage(); restClient.assertStatusCodeIs(HttpStatus.OK); } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java index 31ec535c9..308a2d92b 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java @@ -28,7 +28,7 @@ public class GetProcessDefinitionSanityTests extends RestWorkflowTest { testUser = dataUser.createRandomTestUser(); restClient.authenticateUser(dataUser.getAdminUser()); - randomProcessDefinition = restClient.onWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry(); + randomProcessDefinition = restClient.withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry(); } @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, @@ -36,9 +36,9 @@ public class GetProcessDefinitionSanityTests extends RestWorkflowTest description = "Verify Admin user gets a specific process definition for non-network deployments using REST API and status code is OK (200)") public void adminGetsProcessDefinition() throws Exception { - restClient.onWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinition(). + restClient.withWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinition(). assertThat().field("name").is(randomProcessDefinition.onModel().getName()); - restClient.onWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinition().assertThat().field("name") + restClient.withWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinition().assertThat().field("name") .is(randomProcessDefinition.onModel().getName()); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -49,7 +49,7 @@ public class GetProcessDefinitionSanityTests extends RestWorkflowTest public void anyUserGetsProcessDefinition() throws Exception { restClient.authenticateUser(testUser); - restClient.onWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinition().assertThat().field("name") + restClient.withWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinition().assertThat().field("name") .is(randomProcessDefinition.onModel().getName()); restClient.assertStatusCodeIs(HttpStatus.OK); } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java index 8365ce963..1fa8ff3b9 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java @@ -37,8 +37,8 @@ public class GetProcessDefinitionStartFormModelSanityTests extends RestWorkflowT description = "Verify Admin gets a model of the start form type definition for non-network deployments using REST API and status code is OK (200)") public void nonNetworkAdminGetsStartFormModel() throws Exception { - randomProcessDefinition = restClient.onWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry(); - restClient.onWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionStartFormModel().assertThat().entriesListIsNotEmpty(); + randomProcessDefinition = restClient.withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry(); + restClient.withWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionStartFormModel().assertThat().entriesListIsNotEmpty(); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -50,8 +50,8 @@ public class GetProcessDefinitionStartFormModelSanityTests extends RestWorkflowT { restClient.usingTenant().createTenant(adminTenantUser); restClient.authenticateUser(adminTenantUser); - randomProcessDefinition = restClient.onWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry(); - restClient.onWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionStartFormModel().assertThat().entriesListIsNotEmpty(); + randomProcessDefinition = restClient.withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry(); + restClient.withWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionStartFormModel().assertThat().entriesListIsNotEmpty(); restClient.assertStatusCodeIs(HttpStatus.OK); } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemSanityTests.java index 1c049439c..0bd9995ce 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemSanityTests.java @@ -47,8 +47,8 @@ public class AddProcessItemSanityTests extends RestWorkflowTest document2 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file content"); dataContent.usingSite(siteModel).createContent(document2); - processModel = restClient.authenticateUser(adminUser).onWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - processItem = restClient.onWorkflowAPI().usingProcess(processModel).addProcessItem(document2); + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document2); restClient.assertStatusCodeIs(HttpStatus.CREATED); processItem.assertThat().field("createdAt").isNotEmpty() .and().field("size").is(document2.getContent().length()) @@ -59,7 +59,7 @@ public class AddProcessItemSanityTests extends RestWorkflowTest .and().field("id").isNotEmpty() .and().field("mimeType").is(document2.getFileType().mimeType); - restClient.onWorkflowAPI().usingProcess(processModel).getProcessItems() + restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems() .assertThat().entriesListContains("id", processItem.getId()); } @@ -70,8 +70,8 @@ public class AddProcessItemSanityTests extends RestWorkflowTest { document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - processModel = restClient.authenticateUser(adminUser).onWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - processItem = restClient.onWorkflowAPI().usingProcess(processModel).addProcessItem(document2); + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document2); restClient.assertStatusCodeIs(HttpStatus.CREATED); processItem.assertThat().field("createdAt").isNotEmpty() .and().field("size").is("19") @@ -82,10 +82,10 @@ public class AddProcessItemSanityTests extends RestWorkflowTest .and().field("id").isNotEmpty() .and().field("mimeType").is(document2.getFileType().mimeType); - restClient.onWorkflowAPI().usingProcess(processModel).getProcessItems() + restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems() .assertThat().entriesListContains("id", processItem.getId()) .and().entriesListContains("name", document2.getName()); - restClient.onWorkflowAPI().usingProcess(processModel).addProcessItem(document2); + restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document2); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessSanityTests.java index 8538292a7..f2d2a8d03 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessSanityTests.java @@ -30,12 +30,12 @@ public class AddProcessSanityTests extends RestWorkflowTest userWhoStartsProcess = dataUser.createRandomTestUser(); assignee = dataUser.createRandomTestUser(); - addedProcess = restClient.authenticateUser(userWhoStartsProcess).onWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); + addedProcess = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); restClient.assertStatusCodeIs(HttpStatus.CREATED); addedProcess.assertThat().field("id").is(addedProcess.getId()) .and().field("startUserId").is(addedProcess.getStartUserId()); - processes = restClient.onWorkflowAPI().getProcesses(); + processes = restClient.withWorkflowAPI().getProcesses(); restClient.assertStatusCodeIs(HttpStatus.OK); processes.assertThat().entriesListContains("id", addedProcess.getId()); } @@ -51,12 +51,12 @@ public class AddProcessSanityTests extends RestWorkflowTest tenantUserWhoStartsProcess = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); tenantAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("u2Tenant"); - addedProcess = restClient.authenticateUser(tenantUserWhoStartsProcess).onWorkflowAPI().addProcess("activitiAdhoc", tenantAssignee, false, Priority.Normal); + addedProcess = restClient.authenticateUser(tenantUserWhoStartsProcess).withWorkflowAPI().addProcess("activitiAdhoc", tenantAssignee, false, Priority.Normal); restClient.assertStatusCodeIs(HttpStatus.CREATED); addedProcess.assertThat().field("id").is(addedProcess.getId()) .and().field("startUserId").is(addedProcess.getStartUserId()); - processes = restClient.onWorkflowAPI().getProcesses(); + processes = restClient.withWorkflowAPI().getProcesses(); restClient.assertStatusCodeIs(HttpStatus.OK); processes.assertThat().entriesListContains("id", addedProcess.getId()); } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java index 007e4871e..3fee0854c 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java @@ -44,15 +44,15 @@ public class AddProcessVariableSanityTests extends RestWorkflowTest public void addProcessVariable() throws Exception { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(userWhoStartsTask).onWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - processVariable = restClient.onWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); + processVariable = restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); processVariable.assertThat().field("name").is(variableModel.getName()) .and().field("type").is(variableModel.getType()) .and().field("value").is(variableModel.getValue()); - restClient.onWorkflowAPI().usingProcess(processModel).getProcessVariables() + restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() .assertThat().entriesListContains("name", processVariable.getName()); } @@ -61,8 +61,8 @@ public class AddProcessVariableSanityTests extends RestWorkflowTest public void updateExistingProcessVariable() throws Exception { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(userWhoStartsTask).onWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - processVariable = restClient.onWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); + processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processVariable = restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); processVariable.assertThat().field("name").is(variableModel.getName()) .and().field("type").is(variableModel.getType()) @@ -70,7 +70,7 @@ public class AddProcessVariableSanityTests extends RestWorkflowTest String newValue = RandomData.getRandomName("value"); variableModel.setValue(newValue); - processVariable = restClient.onWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); + processVariable = restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); processVariable.assertThat().field("value").is(newValue); } @@ -85,10 +85,10 @@ public class AddProcessVariableSanityTests extends RestWorkflowTest tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); - restClient.authenticateUser(tenantUser).onWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee, false, Priority.Normal); + restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee, false, Priority.Normal); variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(adminTenantUser).onWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - processVariable = restClient.onWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); + processModel = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processVariable = restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); processVariable.assertThat().field("name").is(variableModel.getName()) .and().field("type").is(variableModel.getType()) @@ -100,8 +100,8 @@ public class AddProcessVariableSanityTests extends RestWorkflowTest public void failedAddingProcessVariableIfInvalidBodyIsProvided() throws Exception { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("incorrect type"); - processModel = restClient.authenticateUser(adminUser).onWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - restClient.onWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) .assertLastError().containsSummary("Unsupported type of variable: 'incorrect type'."); } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java index 392a58f27..f75fda99b 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java @@ -32,35 +32,35 @@ public class DeleteProcessSanityTests extends RestWorkflowTest TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify User is able to delete process started by him using REST API and status code is OK (204)") public void deleteProcessByUserWhoStartedProcess() throws Exception { - process = restClient.authenticateUser(userWhoAddsProcess).onWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); + process = restClient.authenticateUser(userWhoAddsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.onWorkflowAPI().usingProcess(process).deleteProcess(); + restClient.withWorkflowAPI().usingProcess(process).deleteProcess(); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.onWorkflowAPI().getProcesses().assertThat().entriesListDoesNotContain("id", process.getId()); + restClient.withWorkflowAPI().getProcesses().assertThat().entriesListDoesNotContain("id", process.getId()); } @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify User is able to delete process assigned to him using REST API and status code is OK (204)") public void deleteProcessByAssignedUser() throws Exception { - process = restClient.authenticateUser(userWhoAddsProcess).onWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); + process = restClient.authenticateUser(userWhoAddsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.authenticateUser(assignee).onWorkflowAPI().usingProcess(process).deleteProcess(); + restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(process).deleteProcess(); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.onWorkflowAPI().getProcesses().assertThat().entriesListDoesNotContain("id", process.getId()); + restClient.withWorkflowAPI().getProcesses().assertThat().entriesListDoesNotContain("id", process.getId()); } @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify User that is not involved in a process is not authorized to delete it using REST API and status code is 403") public void deleteProcessByAnotherUser() throws Exception { - process = restClient.authenticateUser(userWhoAddsProcess).onWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); + process = restClient.authenticateUser(userWhoAddsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.authenticateUser(anotherUser).onWorkflowAPI().usingProcess(process).deleteProcess(); + restClient.authenticateUser(anotherUser).withWorkflowAPI().usingProcess(process).deleteProcess(); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("user is not allowed to access information about process"); } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsSanityTests.java index 2915a47a9..3040af703 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsSanityTests.java @@ -42,8 +42,8 @@ public class GetProcessItemsSanityTests extends RestWorkflowTest description = "Verify that user that started the process gets all process items") public void getProcessItemsUsingTheUserWhoStartedProcess() throws Exception { - processModel = restClient.authenticateUser(userWhoStartsTask).onWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - items = restClient.onWorkflowAPI().usingProcess(processModel).getProcessItems(); + processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + items = restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems(); restClient.assertStatusCodeIs(HttpStatus.OK); items.assertThat().entriesListIsNotEmpty(); } @@ -52,8 +52,8 @@ public class GetProcessItemsSanityTests extends RestWorkflowTest description = "Verify that user that is involved in the process gets all process items") public void getProcessItemsUsingUserInvolvedInProcess() throws Exception { - processModel = restClient.authenticateUser(assignee).onWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - items = restClient.onWorkflowAPI().usingProcess(processModel).getProcessItems(); + processModel = restClient.authenticateUser(assignee).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + items = restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems(); restClient.assertStatusCodeIs(HttpStatus.OK); items.assertThat().entriesListIsNotEmpty(); } @@ -67,10 +67,10 @@ public class GetProcessItemsSanityTests extends RestWorkflowTest restClient.authenticateUser(dataUser.getAdminUser()).usingTenant().createTenant(adminTenantUser); tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); - restClient.authenticateUser(tenantUser).onWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee, false, Priority.Normal); + restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee, false, Priority.Normal); - processModel = restClient.authenticateUser(adminTenantUser).onWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - items = restClient.onWorkflowAPI().usingProcess(processModel).getProcessItems(); + processModel = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + items = restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems(); restClient.assertStatusCodeIs(HttpStatus.OK); items.assertThat().entriesListIsNotEmpty(); } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksSanityTests.java index 62fdb5e6f..a96f0837e 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksSanityTests.java @@ -41,7 +41,7 @@ public class GetProcessTasksSanityTests extends RestWorkflowTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify user who started the process gets all tasks of started process with Rest API and response is successfull (200)") public void userWhoStartedProcessCanGetProcessTasks() throws JsonToModelConversionException, Exception { - processTasks = restClient.authenticateUser(userModel).onWorkflowAPI().usingProcess(process).getProcessTasks(); + processTasks = restClient.authenticateUser(userModel).withWorkflowAPI().usingProcess(process).getProcessTasks(); restClient.assertStatusCodeIs(HttpStatus.OK); processTasks.assertThat() .entriesListIsNotEmpty().and() @@ -53,7 +53,7 @@ public class GetProcessTasksSanityTests extends RestWorkflowTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify any assignee user of the process gets all tasks of the process with Rest API and response is successfull (200)") public void assigneeUserCanGetAllProcessTasks() throws JsonToModelConversionException, Exception { - processTasks = restClient.authenticateUser(assignee1).onWorkflowAPI().usingProcess(process).getProcessTasks(); + processTasks = restClient.authenticateUser(assignee1).withWorkflowAPI().usingProcess(process).getProcessTasks(); restClient.assertStatusCodeIs(HttpStatus.OK); processTasks.assertThat() .entriesListContains("assignee", assignee1.getUsername()).and() @@ -68,7 +68,7 @@ public class GetProcessTasksSanityTests extends RestWorkflowTest .createMoreReviewersWorkflowAndAssignTo(assignee1, assignee2, assignee3); dataWorkflow.usingUser(assignee1).approveTask(process); - processTasks = restClient.authenticateUser(assignee2).onWorkflowAPI().usingProcess(process).getProcessTasks(); + processTasks = restClient.authenticateUser(assignee2).withWorkflowAPI().usingProcess(process).getProcessTasks(); restClient.assertStatusCodeIs(HttpStatus.OK); processTasks.assertThat() .entriesListIsNotEmpty().assertThat() diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesSanityTests.java index 3ebb2cc8e..a23b2875b 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesSanityTests.java @@ -41,8 +41,8 @@ public class GetProcessVariablesSanityTests extends RestWorkflowTest description = "Verify that user that started the process gets all process variables") public void getProcessVariablesUsingTheUserWhoStartedProcess() throws JsonToModelConversionException, Exception { - processModel = restClient.authenticateUser(userWhoStartsTask).onWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - variables = restClient.onWorkflowAPI().usingProcess(processModel).getProcessVariables(); + processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + variables = restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables(); restClient.assertStatusCodeIs(HttpStatus.OK); variables.assertThat().entriesListIsNotEmpty(); } @@ -51,8 +51,8 @@ public class GetProcessVariablesSanityTests extends RestWorkflowTest description = "Verify get all process variables call using a user that is involved in the process") public void getProcessVariablesUsingUserInvolvedInProcess() throws JsonToModelConversionException, Exception { - processModel = restClient.authenticateUser(assignee).onWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - variables = restClient.onWorkflowAPI().usingProcess(processModel).getProcessVariables(); + processModel = restClient.authenticateUser(assignee).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + variables = restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables(); restClient.assertStatusCodeIs(HttpStatus.OK); variables.assertThat().entriesListIsNotEmpty(); } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java index 60c1eac9b..07bb8e5cd 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java @@ -37,7 +37,7 @@ public class GetProcessesSanityTests extends RestWorkflowTest TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify User gets all processes started by him using REST API and status code is OK (200)") public void getProcessesByUserWhoStartedProcess() throws Exception { - allProcesses = restClient.authenticateUser(userWhoStartsTask).onWorkflowAPI().getProcesses(); + allProcesses = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getProcesses(); restClient.assertStatusCodeIs(HttpStatus.OK); allProcesses.assertThat().entriesListContains("id", task.getNodeRef()); } @@ -46,7 +46,7 @@ public class GetProcessesSanityTests extends RestWorkflowTest TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify User gets all processes assigned to him using REST API and status code is OK (200)") public void getProcessesByAssignedUser() throws Exception { - allProcesses = restClient.authenticateUser(assignee).onWorkflowAPI().getProcesses(); + allProcesses = restClient.authenticateUser(assignee).withWorkflowAPI().getProcesses(); restClient.assertStatusCodeIs(HttpStatus.OK); allProcesses.assertThat().entriesListContains("id", task.getNodeRef()); } @@ -55,7 +55,7 @@ public class GetProcessesSanityTests extends RestWorkflowTest TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify User that is not involved in a process can not get that process using REST API and status code is OK (200)") public void getProcessesByAnotherUser() throws Exception { - allProcesses = restClient.authenticateUser(anotherUser).onWorkflowAPI().getProcesses(); + allProcesses = restClient.authenticateUser(anotherUser).withWorkflowAPI().getProcesses(); restClient.assertStatusCodeIs(HttpStatus.OK); allProcesses.assertThat().entriesListDoesNotContain("id", task.getNodeRef()); } @@ -64,7 +64,7 @@ public class GetProcessesSanityTests extends RestWorkflowTest TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify Admin gets all processes, even if he isn't involved in a process, using REST API and status code is OK (200)") public void getProcessesByAdmin() throws Exception { - allProcesses = restClient.authenticateUser(dataUser.getAdminUser()).onWorkflowAPI().getProcesses(); + allProcesses = restClient.authenticateUser(dataUser.getAdminUser()).withWorkflowAPI().getProcesses(); restClient.assertStatusCodeIs(HttpStatus.OK); allProcesses.assertThat().entriesListContains("id", task.getNodeRef()); } From 2cb698c49762147dc7cc76221b7d4177e4413b55 Mon Sep 17 00:00:00 2001 From: cnechifor Date: Wed, 16 Nov 2016 16:15:59 +0200 Subject: [PATCH 0549/1491] updated tags with new DSL --- .../alfresco/rest/tags/AddTagSanityTests.java | 64 ++++++------- .../rest/tags/AddTagsSanityTests.java | 54 +++++------ .../rest/tags/DeleteTagSanityTests.java | 58 ++++++------ .../rest/tags/GetNodeTagsSanityTests.java | 89 +++++++++---------- .../alfresco/rest/tags/GetTagSanityTests.java | 55 ++++++------ .../rest/tags/GetTagsSanityTests.java | 64 ++++++++----- .../rest/tags/UpdateTagSanityTests.java | 34 ++++--- 7 files changed, 203 insertions(+), 215 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java index ae1dbc646..d075ccd38 100644 --- a/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java @@ -3,15 +3,18 @@ package org.alfresco.rest.tags; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.requests.RestTagsApi; +import org.alfresco.rest.model.RestTagModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.*; +import org.alfresco.utility.model.ErrorModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; @@ -23,14 +26,8 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) public class AddTagSanityTests extends RestTest { - @Autowired - private DataUser dataUser; - - @Autowired - private RestTagsApi tagsAPI; - private UserModel adminUserModel, userModel; - private FileModel document, contributorDoc; + private FileModel document; private SiteModel siteModel; private DataUser.ListUserWithRoles usersWithRoles; private String tagValue; @@ -39,12 +36,10 @@ public class AddTagSanityTests extends RestTest public void dataPreparation() throws Exception { adminUserModel = dataUser.getAdminUser(); - restClient.authenticateUser(adminUserModel); siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - tagsAPI.useRestClient(restClient); } @BeforeMethod(alwaysRun = true) @@ -58,11 +53,10 @@ public class AddTagSanityTests extends RestTest public void adminIsAbleToAddTag() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); - tagsAPI.addTag(document, tagValue) - .assertThat().field("tag").is(tagValue) + RestTagModel returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedModel.assertThat().field("tag").is(tagValue) .and().field("id").isNotEmpty(); - tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); - } @TestRail(section = { TestGroup.REST_API, @@ -70,10 +64,10 @@ public class AddTagSanityTests extends RestTest public void managerIsAbleToAddTag() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - tagsAPI.addTag(document, tagValue) - .assertThat().field("id").isNotEmpty() - .and().field("tag").is(tagValue); - tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + RestTagModel returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedModel.assertThat().field("tag").is(tagValue) + .and().field("id").isNotEmpty(); } @TestRail(section = { TestGroup.REST_API, @@ -81,10 +75,10 @@ public class AddTagSanityTests extends RestTest public void collaboratorIsAbleToAddTag() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - tagsAPI.addTag(document, tagValue) - .assertThat().field("id").isNotEmpty() - .and().field("tag").is(tagValue); - tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + RestTagModel returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedModel.assertThat().field("tag").is(tagValue) + .and().field("id").isNotEmpty(); } @TestRail(section = { TestGroup.REST_API, @@ -92,8 +86,8 @@ public class AddTagSanityTests extends RestTest public void contributorIsNotAbleToAddTagToAnotherContent() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - tagsAPI.addTag(document, tagValue); - tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + restClient.withCoreAPI().usingResource(document).addTag(tagValue); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, @@ -102,11 +96,11 @@ public class AddTagSanityTests extends RestTest { userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); restClient.authenticateUser(userModel); - contributorDoc = dataContent.usingSite(siteModel).usingUser(userModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - tagsAPI.addTag(contributorDoc, tagValue) - .assertThat().field("id").isNotEmpty() + FileModel contributorDoc = dataContent.usingSite(siteModel).usingUser(userModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + RestTagModel returnedModel = restClient.withCoreAPI().usingResource(contributorDoc).addTag(tagValue); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedModel.assertThat().field("id").isNotEmpty() .and().field("tag").is(tagValue); - tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } @TestRail(section = { TestGroup.REST_API, @@ -114,8 +108,8 @@ public class AddTagSanityTests extends RestTest public void consumerIsNotAbleToAddTag() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - tagsAPI.addTag(document, tagValue); - tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + restClient.withCoreAPI().usingResource(document).addTag(tagValue); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, @@ -126,7 +120,7 @@ public class AddTagSanityTests extends RestTest UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); siteManager.setPassword("wrongPassword"); restClient.authenticateUser(siteManager); - tagsAPI.addTag(document, "tagUnauthorized"); - tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.withCoreAPI().usingResource(document).addTag("tagUnauthorized"); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(ErrorModel.AUTHENTICATION_FAILED); } -} +} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/tags/AddTagsSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/AddTagsSanityTests.java index 52d40f950..75cb8f6ee 100644 --- a/e2e-test/java/org/alfresco/rest/tags/AddTagsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/AddTagsSanityTests.java @@ -3,10 +3,11 @@ package org.alfresco.rest.tags; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.requests.RestTagsApi; +import org.alfresco.rest.model.RestTagModelsCollection; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.RandomData; +import org.alfresco.utility.model.ErrorModel; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; @@ -14,7 +15,6 @@ import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; @@ -26,12 +26,6 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) public class AddTagsSanityTests extends RestTest { - @Autowired - private DataUser dataUser; - - @Autowired - private RestTagsApi tagsAPI; - private UserModel adminUserModel, userModel; private FileModel document, contributorDoc; private SiteModel siteModel; @@ -42,12 +36,10 @@ public class AddTagsSanityTests extends RestTest public void dataPreparation() throws Exception { adminUserModel = dataUser.getAdminUser(); - restClient.authenticateUser(adminUserModel); siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - tagsAPI.useRestClient(restClient); } @BeforeMethod(alwaysRun = true) @@ -62,11 +54,11 @@ public class AddTagsSanityTests extends RestTest public void adminIsAbleToAddTags() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); - tagsAPI.addTags(document, tag1, tag2) - .assertThat().entriesListContains("tag", tag1) + RestTagModelsCollection returnedCollection = restClient.withCoreAPI().usingResource(document).addTags(tag1, tag2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedCollection.assertThat().entriesListContains("tag", tag1) .and().entriesListContains("tag", tag2); - - tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + } @TestRail(section = { TestGroup.REST_API, @@ -74,11 +66,10 @@ public class AddTagsSanityTests extends RestTest public void managerIsAbleToAddTags() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - tagsAPI.addTags(document, tag1, tag2) - .assertThat().entriesListContains("tag", tag1) + RestTagModelsCollection returnedCollection = restClient.withCoreAPI().usingResource(document).addTags(tag1, tag2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedCollection.assertThat().entriesListContains("tag", tag1) .and().entriesListContains("tag", tag2); - - tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } @TestRail(section = { TestGroup.REST_API, @@ -86,11 +77,10 @@ public class AddTagsSanityTests extends RestTest public void collaboratorIsAbleToAddTags() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - tagsAPI.addTags(document, tag1, tag2) - .assertThat().entriesListContains("tag", tag1) + RestTagModelsCollection returnedCollection = restClient.withCoreAPI().usingResource(document).addTags(tag1, tag2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedCollection.assertThat().entriesListContains("tag", tag1) .and().entriesListContains("tag", tag2); - - tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } @TestRail(section = { TestGroup.REST_API, @@ -98,8 +88,8 @@ public class AddTagsSanityTests extends RestTest public void contributorIsNotAbleToAddTagsToAnotherContent() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - tagsAPI.addTags(document, tag1, tag2); - tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + restClient.withCoreAPI().usingResource(document).addTags(tag1, tag2); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, @@ -109,19 +99,18 @@ public class AddTagsSanityTests extends RestTest userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); restClient.authenticateUser(userModel); contributorDoc = dataContent.usingSite(siteModel).usingUser(userModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - tagsAPI.addTags(contributorDoc, tag1, tag2) - .assertThat().entriesListContains("tag", tag1) + RestTagModelsCollection returnedCollection = restClient.withCoreAPI().usingResource(contributorDoc).addTags(tag1, tag2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedCollection.assertThat().entriesListContains("tag", tag1) .and().entriesListContains("tag", tag2); - tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Consumer user doesn't have permission to add multiple tags with Rest API and status code is 403") public void consumerIsNotAbleToAddTags() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - tagsAPI.addTags(document, tag1, tag2); - tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingResource(document).addTags(tag1, tag2); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, @@ -131,9 +120,8 @@ public class AddTagsSanityTests extends RestTest { UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); siteManager.setPassword("wrongPassword"); - restClient.authenticateUser(siteManager); - tagsAPI.addTags(document, tag1, tag2); - tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.authenticateUser(siteManager).withCoreAPI().usingResource(document).addTags(tag1, tag2); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(ErrorModel.AUTHENTICATION_FAILED); } } diff --git a/e2e-test/java/org/alfresco/rest/tags/DeleteTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/DeleteTagSanityTests.java index 74419e839..66c13c3bc 100644 --- a/e2e-test/java/org/alfresco/rest/tags/DeleteTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/DeleteTagSanityTests.java @@ -4,16 +4,16 @@ import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestTagModel; -import org.alfresco.rest.requests.RestTagsApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.data.RandomData; +import org.alfresco.utility.model.ErrorModel; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -24,12 +24,6 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) public class DeleteTagSanityTests extends RestTest { - @Autowired - private DataUser dataUser; - - @Autowired - private RestTagsApi tagsAPI; - private UserModel adminUserModel, userModel; private SiteModel siteModel; private DataUser.ListUserWithRoles usersWithRoles; @@ -43,7 +37,6 @@ public class DeleteTagSanityTests extends RestTest siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); - tagsAPI.useRestClient(restClient); } @TestRail(section = { TestGroup.REST_API, @@ -51,10 +44,10 @@ public class DeleteTagSanityTests extends RestTest public void adminIsAbleToDeleteTags() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); - tag = tagsAPI.addTag(document, "testtag"); - - tagsAPI.deleteTag(document, tag); - tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); + tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); + + restClient.withCoreAPI().usingResource(document).deleteTag(tag); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } @TestRail(section = { TestGroup.REST_API, @@ -62,11 +55,11 @@ public class DeleteTagSanityTests extends RestTest public void managerIsAbleToDeleteTags() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); - tag = tagsAPI.addTag(document, "testtag"); - + tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - tagsAPI.deleteTag(document, tag); - tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withCoreAPI().usingResource(document).deleteTag(tag); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } @TestRail(section = { TestGroup.REST_API, @@ -74,11 +67,11 @@ public class DeleteTagSanityTests extends RestTest public void collaboratorIsAbleToDeleteTags() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); - tag = tagsAPI.addTag(document, "testtag"); + tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - tagsAPI.deleteTag(document, tag); - tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withCoreAPI().usingResource(document).deleteTag(tag); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, @@ -86,11 +79,11 @@ public class DeleteTagSanityTests extends RestTest public void contributorIsNotAbleToDeleteTagsForAnotherUserContent() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); - tag = tagsAPI.addTag(document, "testtag"); + tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - tagsAPI.deleteTag(document, tag); - tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + restClient.withCoreAPI().usingResource(document).deleteTag(tag); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, @@ -100,9 +93,10 @@ public class DeleteTagSanityTests extends RestTest userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); restClient.authenticateUser(userModel); contributorDoc = dataContent.usingSite(siteModel).usingUser(userModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);; - tag = tagsAPI.addTag(contributorDoc, "contributortag"); - tagsAPI.deleteTag(document, tag); - tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); + tag = restClient.withCoreAPI().usingResource(contributorDoc).addTag(RandomData.getRandomName("tag")); + + restClient.withCoreAPI().usingResource(document).deleteTag(tag); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } @TestRail(section = { TestGroup.REST_API, @@ -110,11 +104,11 @@ public class DeleteTagSanityTests extends RestTest public void consumerIsNotAbleToDeleteTags() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); - tag = tagsAPI.addTag(document, "testtag"); + tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - tagsAPI.deleteTag(document, tag); - tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + restClient.withCoreAPI().usingResource(document).deleteTag(tag); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, @@ -122,12 +116,12 @@ public class DeleteTagSanityTests extends RestTest public void managerIsNotAbleToDeleteTagIfAuthenticationFails() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); - tag = tagsAPI.addTag(document, "testtag"); + tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); siteManager.setPassword("wrongPassword"); restClient.authenticateUser(siteManager); - tagsAPI.deleteTag(document, tag); - tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.withCoreAPI().usingResource(document).deleteTag(tag); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(ErrorModel.AUTHENTICATION_FAILED); } } diff --git a/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java index a00c17664..3eb7c18a5 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java @@ -3,16 +3,18 @@ package org.alfresco.rest.tags; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.requests.RestTagsApi; +import org.alfresco.rest.model.RestTagModelsCollection; import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.*; +import org.alfresco.utility.model.ErrorModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -20,18 +22,13 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) public class GetNodeTagsSanityTests extends RestTest { - @Autowired - private DataUser dataUser; - - @Autowired - private RestTagsApi tagsAPI; - private UserModel adminUserModel; private SiteModel siteModel; private ListUserWithRoles usersWithRoles; private FileModel document; private String tagValue; + private String tagValue2; @BeforeClass(alwaysRun=true) public void dataPreparation() throws Exception @@ -41,29 +38,28 @@ public class GetNodeTagsSanityTests extends RestTest siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, - UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); - + UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - tagsAPI.useRestClient(restClient); - tagValue = RandomData.getRandomName("tag"); - tagsAPI.addTag(document, tagValue); + restClient.withCoreAPI().usingResource(document).addTag(tagValue); + + tagValue2 = RandomData.getRandomName("tag"); + restClient.withCoreAPI().usingResource(document).addTag(tagValue2); } @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify site Manager is able to get node tags") public void siteManagerIsAbleToRetrieveNodeTags() throws JsonToModelConversionException, Exception - { + { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - tagsAPI.addTag(document, tagValue); - tagsAPI.getNodeTags(document) - .assertThat() - .entriesListContains("tag", tagValue.toLowerCase()); - - tagsAPI.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.OK); + RestTagModelsCollection returnedCollection = restClient.withCoreAPI().usingResource(document).getNodeTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat() + .entriesListContains("tag", tagValue.toLowerCase()) + .and().entriesListContains("tag", tagValue2.toLowerCase()); + } @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, @@ -71,12 +67,12 @@ public class GetNodeTagsSanityTests extends RestTest public void siteCollaboratorIsAbleToRetrieveNodeTags() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - - - tagsAPI.getNodeTags(document).assertThat().entriesListContains("tag", tagValue.toLowerCase()); - - tagsAPI.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.OK); + + RestTagModelsCollection returnedCollection = restClient.withCoreAPI().usingResource(document).getNodeTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat() + .entriesListContains("tag", tagValue.toLowerCase()) + .and().entriesListContains("tag", tagValue2.toLowerCase()); } @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, @@ -84,10 +80,12 @@ public class GetNodeTagsSanityTests extends RestTest public void siteContributorIsAbleToRetrieveNodeTags() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - tagsAPI.getNodeTags(document).assertThat().entriesListContains("tag", tagValue.toLowerCase()); - - tagsAPI.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.OK); + + RestTagModelsCollection returnedCollection = restClient.withCoreAPI().usingResource(document).getNodeTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat() + .entriesListContains("tag", tagValue.toLowerCase()) + .and().entriesListContains("tag", tagValue2.toLowerCase()); } @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, @@ -95,10 +93,12 @@ public class GetNodeTagsSanityTests extends RestTest public void siteConsumerIsAbleToRetrieveNodeTags() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - tagsAPI.getNodeTags(document).assertThat().entriesListContains("tag", tagValue.toLowerCase()); - - tagsAPI.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.OK); + + RestTagModelsCollection returnedCollection = restClient.withCoreAPI().usingResource(document).getNodeTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat() + .entriesListContains("tag", tagValue.toLowerCase()) + .and().entriesListContains("tag", tagValue2.toLowerCase()); } @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, @@ -106,10 +106,11 @@ public class GetNodeTagsSanityTests extends RestTest public void adminIsAbleToRetrieveNodeTags() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); - tagsAPI.getNodeTags(document).assertThat().entriesListContains("tag", tagValue.toLowerCase()); - - tagsAPI.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.OK); + RestTagModelsCollection returnedCollection = restClient.withCoreAPI().usingResource(document).getNodeTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat() + .entriesListContains("tag", tagValue.toLowerCase()) + .and().entriesListContains("tag", tagValue2.toLowerCase()); } @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, @@ -118,9 +119,7 @@ public class GetNodeTagsSanityTests extends RestTest public void unauthenticatedUserIsNotAbleToRetrieveNodeTags() throws JsonToModelConversionException, Exception { restClient.authenticateUser(new UserModel("random user", "random password")); - tagsAPI.getNodeTags(document); - - tagsAPI.usingRestWrapper() - .assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(ErrorModel.AUTHENTICATION_FAILED); + restClient.withCoreAPI().usingResource(document).getNodeTags(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(ErrorModel.AUTHENTICATION_FAILED); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/tags/GetTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagSanityTests.java index 4027adcbd..c7ac5c44d 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetTagSanityTests.java @@ -4,11 +4,10 @@ import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestTagModel; -import org.alfresco.rest.requests.RestTagsApi; import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.data.RandomData; +import org.alfresco.utility.model.ErrorModel; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; @@ -16,7 +15,6 @@ import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -24,13 +22,6 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) public class GetTagSanityTests extends RestTest { - - @Autowired - private DataUser dataUser; - - @Autowired - private RestTagsApi tagsAPI; - private UserModel adminUserModel; private SiteModel siteModel; private ListUserWithRoles usersWithRoles; @@ -45,7 +36,6 @@ public class GetTagSanityTests extends RestTest usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - tagsAPI.useRestClient(restClient); } @@ -54,10 +44,11 @@ public class GetTagSanityTests extends RestTest { String tagValue = RandomData.getRandomName("tag"); restClient.authenticateUser(adminUserModel); - RestTagModel tag = tagsAPI.addTag(document, tagValue); + RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(tagValue); - tagsAPI.getTag(tag).assertThat().field("tag").is(tagValue.toLowerCase()); - tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + RestTagModel returnedTag = restClient.getTag(tag); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedTag.assertThat().field("tag").is(tagValue.toLowerCase()); } @@ -66,10 +57,11 @@ public class GetTagSanityTests extends RestTest { String tagValue = RandomData.getRandomName("tag"); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - RestTagModel tag = tagsAPI.addTag(document, tagValue); - - tagsAPI.getTag(tag).assertThat().field("tag").is(tagValue.toLowerCase()); - tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(tagValue); + + RestTagModel returnedTag = restClient.getTag(tag); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedTag.assertThat().field("tag").is(tagValue.toLowerCase()); } @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user with Collaborator role gets tag using REST API and status code is OK (200)") @@ -77,10 +69,11 @@ public class GetTagSanityTests extends RestTest { String tagValue = RandomData.getRandomName("tag"); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - RestTagModel tag = tagsAPI.addTag(document, tagValue); + RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(tagValue); - tagsAPI.getTag(tag).assertThat().field("tag").is(tagValue.toLowerCase()); - tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + RestTagModel returnedTag = restClient.getTag(tag); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedTag.assertThat().field("tag").is(tagValue.toLowerCase()); } @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user with Contributor role gets tag using REST API and status code is OK (200)") @@ -88,11 +81,12 @@ public class GetTagSanityTests extends RestTest { String tagValue = RandomData.getRandomName("tag"); restClient.authenticateUser(adminUserModel); - RestTagModel tag = tagsAPI.addTag(document, tagValue); + RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(tagValue); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - tagsAPI.getTag(tag).assertThat().field("tag").is(tagValue.toLowerCase()); - tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + RestTagModel returnedTag = restClient.getTag(tag); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedTag.assertThat().field("tag").is(tagValue.toLowerCase()); } @@ -101,11 +95,12 @@ public class GetTagSanityTests extends RestTest { String tagValue = RandomData.getRandomName("tag"); restClient.authenticateUser(adminUserModel); - RestTagModel tag = tagsAPI.addTag(document, tagValue); + RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(tagValue); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - tagsAPI.getTag(tag).assertThat().field("tag").is(tagValue.toLowerCase()); - tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + RestTagModel returnedTag = restClient.getTag(tag); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedTag.assertThat().field("tag").is(tagValue.toLowerCase()); } @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Manager user gets status code 401 if authentication call fails") @@ -116,12 +111,12 @@ public class GetTagSanityTests extends RestTest UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); dataUser.addUserToSite(managerUser, siteModel, UserRole.SiteManager); restClient.authenticateUser(managerUser); - RestTagModel tag = tagsAPI.addTag(document, tagValue); + RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(tagValue); managerUser.setPassword("wrongPassword"); restClient.authenticateUser(managerUser); - tagsAPI.getTag(tag); - tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.getTag(tag); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(ErrorModel.AUTHENTICATION_FAILED); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java index ed5887ac7..93af00ad5 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java @@ -1,11 +1,15 @@ package org.alfresco.rest.tags; +import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.requests.RestTagsApi; +import org.alfresco.rest.model.RestTagModelsCollection; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.data.RandomData; +import org.alfresco.utility.model.ErrorModel; +import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; @@ -20,17 +24,15 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) public class GetTagsSanityTests extends RestTest { - @Autowired - private DataUser dataUser; - - @Autowired - private RestTagsApi tagsAPI; - private UserModel adminUserModel; private UserModel userModel; private SiteModel siteModel; private ListUserWithRoles usersWithRoles; + private String tagValue; + private String tagValue2; + private FileModel document; + @BeforeClass(alwaysRun=true) public void dataPreparation() throws Exception { @@ -38,7 +40,13 @@ public class GetTagsSanityTests extends RestTest restClient.authenticateUser(adminUserModel); siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); - tagsAPI.useRestClient(restClient); + document = dataContent.usingUser(adminUserModel).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + + tagValue = RandomData.getRandomName("tag"); + restClient.withCoreAPI().usingResource(document).addTag(tagValue); + + tagValue2 = RandomData.getRandomName("tag"); + restClient.withCoreAPI().usingResource(document).addTag(tagValue2); } @@ -46,41 +54,55 @@ public class GetTagsSanityTests extends RestTest public void getTagsWithManagerRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - tagsAPI.getTags(); - tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + RestTagModelsCollection returnedCollection = restClient.getTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat().entriesListIsEmpty() + .and().entriesListContains("tag", tagValue.toLowerCase()) + .and().entriesListContains("tag", tagValue2.toLowerCase()); } @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user with Collaborator role gets tags using REST API and status code is OK (200)") public void getTagsWithCollaboratorRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - tagsAPI.getTags(); - tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + RestTagModelsCollection returnedCollection = restClient.getTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat().entriesListIsEmpty() + .and().entriesListContains("tag", tagValue.toLowerCase()) + .and().entriesListContains("tag", tagValue2.toLowerCase()); } @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user with Contributor role gets tags using REST API and status code is OK (200)") public void getTagsWithContributorRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - tagsAPI.getTags(); - tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + RestTagModelsCollection returnedCollection = restClient.getTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat().entriesListIsEmpty() + .and().entriesListContains("tag", tagValue.toLowerCase()) + .and().entriesListContains("tag", tagValue2.toLowerCase()); } @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role gets tags using REST API and status code is OK (200)") public void getTagsWithConsumerRole() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - tagsAPI.getTags(); - tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + RestTagModelsCollection returnedCollection = restClient.getTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat().entriesListIsEmpty() + .and().entriesListContains("tag", tagValue.toLowerCase()) + .and().entriesListContains("tag", tagValue2.toLowerCase()); } @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets tags using REST API and status code is OK (200)") public void getTagsWithAdminUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); - tagsAPI.getTags(); - tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + RestTagModelsCollection returnedCollection = restClient.getTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat().entriesListIsEmpty() + .and().entriesListContains("tag", tagValue.toLowerCase()) + .and().entriesListContains("tag", tagValue2.toLowerCase()); } @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Failed authentication get tags call returns status code 401 with Manager role") @@ -92,7 +114,7 @@ public class GetTagsSanityTests extends RestTest userModel.setPassword("user wrong password"); dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); restClient.authenticateUser(userModel); - tagsAPI.getTags(); - tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.getTags(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(ErrorModel.AUTHENTICATION_FAILED); } } diff --git a/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java index 7429fef9d..190959f03 100644 --- a/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java @@ -4,10 +4,10 @@ import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestTagModel; -import org.alfresco.rest.requests.RestTagsApi; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.RandomData; +import org.alfresco.utility.model.ErrorModel; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; @@ -15,7 +15,6 @@ import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; @@ -27,9 +26,6 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) public class UpdateTagSanityTests extends RestTest { - @Autowired RestTagsApi tagsAPI; - - @Autowired DataUser dataUser; private UserModel adminUserModel; private FileModel document; @@ -51,8 +47,7 @@ public class UpdateTagSanityTests extends RestTest public void addTagToDocument() throws Exception { restClient.authenticateUser(adminUserModel); - tagsAPI.useRestClient(restClient); - oldTag = tagsAPI.addTag(document, RandomData.getRandomName("old")); + oldTag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("old")); randomTag = RandomData.getRandomName("tag"); } @@ -61,8 +56,9 @@ public class UpdateTagSanityTests extends RestTest public void adminIsAbleToUpdateTags() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); - tagsAPI.updateTag(oldTag, randomTag).assertThat().field("tag").is(randomTag); - tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + RestTagModel returnedModel = restClient.usingTag(oldTag).update(randomTag); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedModel.assertThat().field("tag").is(randomTag); } @TestRail(section = { TestGroup.REST_API, @@ -70,8 +66,8 @@ public class UpdateTagSanityTests extends RestTest public void managerIsNotAbleToUpdateTag() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - tagsAPI.updateTag(oldTag, randomTag); - tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + restClient.usingTag(oldTag).update(randomTag); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, @@ -79,8 +75,8 @@ public class UpdateTagSanityTests extends RestTest public void collaboratorIsNotAbleToUpdateTag() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - tagsAPI.updateTag(oldTag, randomTag); - tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + restClient.usingTag(oldTag).update(randomTag); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, @@ -88,8 +84,8 @@ public class UpdateTagSanityTests extends RestTest public void contributorIsNotAbleToUpdateTag() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - tagsAPI.updateTag(oldTag, randomTag); - tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + restClient.usingTag(oldTag).update(randomTag); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, @@ -97,8 +93,8 @@ public class UpdateTagSanityTests extends RestTest public void consumerIsNotAbleToUpdateTag() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - tagsAPI.updateTag(oldTag, randomTag); - tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN); + restClient.usingTag(oldTag).update(randomTag); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, @@ -109,7 +105,7 @@ public class UpdateTagSanityTests extends RestTest UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); siteManager.setPassword("wrongPassword"); restClient.authenticateUser(siteManager); - tagsAPI.updateTag(oldTag, randomTag); - tagsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.usingTag(oldTag).update(randomTag); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(ErrorModel.AUTHENTICATION_FAILED); } } From 7901f1bb824ca040aaeec2e70e93d8d32be6895d Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 16 Nov 2016 16:36:59 +0200 Subject: [PATCH 0550/1491] update tests based on new refactored DSL --- .../DeleteProcessItemSanityTests.java | 66 ++++++++++++++++ .../processes/GetProcessSanityTests.java | 8 +- .../RemoveProcessItemSanityTests.java | 77 ------------------- 3 files changed, 70 insertions(+), 81 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessItemSanityTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessItemSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessItemSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessItemSanityTests.java new file mode 100644 index 000000000..ff58fa654 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessItemSanityTests.java @@ -0,0 +1,66 @@ +package org.alfresco.rest.workflow.processes; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestWorkflowTest; +import org.alfresco.rest.model.RestItemModel; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.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 + */ +@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) +public class DeleteProcessItemSanityTests extends RestWorkflowTest +{ + private FileModel document, document2; + private SiteModel siteModel; + private UserModel userWhoStartsTask, assignee, adminUser; + private RestProcessModel processModel; + private RestItemModel processItem; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userWhoStartsTask = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Delete existing process item") + public void deleteProcessItem() throws Exception + { + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + document2 = dataContent.usingAdmin().usingSite(siteModel).createContent(DocumentType.MSWORD); + processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.withWorkflowAPI().usingProcess(processModel).deleteProcessItem(processItem); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems() + .assertThat().entriesListDoesNotContain("id", processItem.getId()); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Try to delete existing process item using invalid processId") + public void deleteProcessItemUsingInvalidProcessId() throws Exception + { + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + document2 = dataContent.usingAdmin().usingSite(siteModel).createContent(DocumentType.MSPOWERPOINT); + processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + processModel.setId("incorrectProcessId"); + restClient.withWorkflowAPI().usingProcess(processModel).deleteProcessItem(processItem); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } +} diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessSanityTests.java index 74489edb4..ce1ad31e0 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessSanityTests.java @@ -25,14 +25,14 @@ public class GetProcessSanityTests extends RestWorkflowTest { userWhoStartsProcess = dataUser.createRandomTestUser(); assignee = dataUser.createRandomTestUser(); - addedProcess = restClient.authenticateUser(userWhoStartsProcess).addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.High); + addedProcess = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.High); } @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify user is able to get the process started by him using REST API and status code is OK (200)") public void getProcessByOwner() throws Exception { - process = restClient.authenticateUser(userWhoStartsProcess).usingProcess(addedProcess).getProcess(); + process = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingProcess(addedProcess).getProcess(); restClient.assertStatusCodeIs(HttpStatus.OK); process.assertThat().field("id").is(addedProcess.getId()) .and().field("startUserId").is(addedProcess.getStartUserId()); @@ -42,7 +42,7 @@ public class GetProcessSanityTests extends RestWorkflowTest TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify user is able to get the process assigned to him using REST API and status code is OK (200)") public void getProcessByAssignee() throws Exception { - process = restClient.authenticateUser(assignee).usingProcess(addedProcess).getProcess(); + process = restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(addedProcess).getProcess(); restClient.assertStatusCodeIs(HttpStatus.OK); process.assertThat().field("id").is(addedProcess.getId()) .and().field("startUserId").is(addedProcess.getStartUserId()); @@ -52,7 +52,7 @@ public class GetProcessSanityTests extends RestWorkflowTest TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify admin is able to get any process using REST API and status code is OK (200)") public void getProcessByAdmin() throws Exception { - process = restClient.authenticateUser(dataUser.getAdminUser()).usingProcess(addedProcess).getProcess(); + process = restClient.authenticateUser(dataUser.getAdminUser()).withWorkflowAPI().usingProcess(addedProcess).getProcess(); restClient.assertStatusCodeIs(HttpStatus.OK); process.assertThat().field("id").is(addedProcess.getId()) .and().field("startUserId").is(addedProcess.getStartUserId()); diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessItemSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessItemSanityTests.java deleted file mode 100644 index acd4adf08..000000000 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessItemSanityTests.java +++ /dev/null @@ -1,77 +0,0 @@ -package org.alfresco.rest.workflow.processes; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestWorkflowTest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestItemModel; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.requests.Processes; -import org.alfresco.utility.data.DataUser; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * @author iulia.cojocea - */ -@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) -public class RemoveProcessItemSanityTests extends RestWorkflowTest -{ - @Autowired - private DataUser dataUser; - - @Autowired - private Processes processesApi; - - private FileModel document, document2, document3; - private SiteModel siteModel; - private UserModel userWhoStartsTask, assignee; - private RestProcessModel processModel; - private UserModel adminUser; - private RestItemModel processItem; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userWhoStartsTask = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); - processesApi.useRestClient(restClient); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Delete existing process item") - public void deleteProcessItem() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUser); - processModel = processesApi.getProcesses().getOneRandomEntry(); - document2 = dataContent.usingSite(siteModel).createContent(DocumentType.MSWORD); - processItem = processesApi.addProcessItem(processModel, document2); - processesApi.deleteProcessItem(processModel, processItem); - processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); - processesApi.getProcessesItems(processModel).assertThat().entriesListDoesNotContain("id", processItem.getId()); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Try to delete existing process item using invalid processId") - public void deleteProcessItemUsingInvalidProcessId() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUser); - processModel = processesApi.getProcesses().getOneRandomEntry(); - document3 = dataContent.usingSite(siteModel).createContent(DocumentType.MSPOWERPOINT); - processItem = processesApi.addProcessItem(processModel, document3); - processModel.onModel().setId("incorrectProcessId"); - processesApi.deleteProcessItem(processModel, processItem); - processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); - } -} From 3ae63583de279586f922cc7a762ee36dd785f6e5 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Wed, 16 Nov 2016 16:45:27 +0200 Subject: [PATCH 0551/1491] update rest methods based on new DSL groups --- .../rest/ratings/GetRatingsSanityTests.java | 36 +++++++++---------- .../sites/UpdateSiteMemberSanityTests.java | 8 ++--- .../alfresco/rest/tags/GetTagSanityTests.java | 12 +++---- .../rest/tags/GetTagsSanityTests.java | 14 ++++---- .../rest/tags/UpdateTagSanityTests.java | 12 +++---- .../GetProcessDefinitionsSanityTests.java | 5 ++- 6 files changed, 42 insertions(+), 45 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/ratings/GetRatingsSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/GetRatingsSanityTests.java index 701b9f1ce..da7217d7c 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/GetRatingsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/GetRatingsSanityTests.java @@ -52,10 +52,10 @@ public class GetRatingsSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.usingResource(document).likeDocument(); - restClient.usingResource(document).rateStarsToDocument(5); + restClient.withCoreAPI().usingResource(document).likeDocument(); + restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - restRatingModelsCollection = restClient.usingResource(document).getRatings(); + restRatingModelsCollection = restClient.withCoreAPI().usingResource(document).getRatings(); restClient.assertStatusCodeIs(HttpStatus.OK); restRatingModelsCollection.assertNodeHasFiveStarRating().assertNodeIsLiked(); } @@ -66,10 +66,10 @@ public class GetRatingsSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.usingResource(document).likeDocument(); - restClient.usingResource(document).rateStarsToDocument(5); + restClient.withCoreAPI().usingResource(document).likeDocument(); + restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - restRatingModelsCollection = restClient.usingResource(document).getRatings(); + restRatingModelsCollection = restClient.withCoreAPI().usingResource(document).getRatings(); restClient.assertStatusCodeIs(HttpStatus.OK); restRatingModelsCollection.assertNodeHasFiveStarRating().assertNodeIsLiked(); } @@ -80,10 +80,10 @@ public class GetRatingsSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - restClient.usingResource(document).likeDocument(); - restClient.usingResource(document).rateStarsToDocument(5); + restClient.withCoreAPI().usingResource(document).likeDocument(); + restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - restRatingModelsCollection = restClient.usingResource(document).getRatings(); + restRatingModelsCollection = restClient.withCoreAPI().usingResource(document).getRatings(); restClient.assertStatusCodeIs(HttpStatus.OK); restRatingModelsCollection.assertNodeHasFiveStarRating().assertNodeIsLiked(); } @@ -94,10 +94,10 @@ public class GetRatingsSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.usingResource(document).likeDocument(); - restClient.usingResource(document).rateStarsToDocument(5); + restClient.withCoreAPI().usingResource(document).likeDocument(); + restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - restRatingModelsCollection = restClient.usingResource(document).getRatings(); + restRatingModelsCollection = restClient.withCoreAPI().usingResource(document).getRatings(); restClient.assertStatusCodeIs(HttpStatus.OK); restRatingModelsCollection.assertNodeHasFiveStarRating().assertNodeIsLiked(); } @@ -110,10 +110,10 @@ public class GetRatingsSanityTests extends RestTest .usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); restClient.authenticateUser(adminUser); - restClient.usingResource(document).likeDocument(); - restClient.usingResource(document).rateStarsToDocument(5); + restClient.withCoreAPI().usingResource(document).likeDocument(); + restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - restRatingModelsCollection = restClient.usingResource(document).getRatings(); + restRatingModelsCollection = restClient.withCoreAPI().usingResource(document).getRatings(); restClient.assertStatusCodeIs(HttpStatus.OK); restRatingModelsCollection.assertNodeHasFiveStarRating().assertNodeIsLiked(); } @@ -124,12 +124,12 @@ public class GetRatingsSanityTests extends RestTest public void unauthenticatedUserIsNotAbleToRetrieveRatings() throws Exception { restClient.authenticateUser(adminUser); - restClient.usingResource(document).likeDocument(); - restClient.usingResource(document).rateStarsToDocument(5); + restClient.withCoreAPI().usingResource(document).likeDocument(); + restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); restClient.authenticateUser(new UserModel("random user", "random password")); - restClient.usingResource(document).getRatings(); + restClient.withCoreAPI().usingResource(document).getRatings(); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(ErrorModel.AUTHENTICATION_FAILED); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java index e1dbdb1a8..a64af8a52 100644 --- a/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java @@ -52,9 +52,9 @@ public class UpdateSiteMemberSanityTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); testUserModel.setUserRole(UserRole.SiteCollaborator); restClient.withCoreAPI().usingSite(siteModel).updateSiteMember(testUserModel); - restClient.assertLastError() - .containsSummary(String.format("The current user does not have permissions to modify the membership details of the site %s.", siteModel.getTitle())); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + restClient.assertLastError() + .containsSummary(String.format("The current user does not have permissions to modify the membership details of the site %s.", siteModel.getTitle())); } @Bug(id="ACE-5444") @@ -65,9 +65,9 @@ public class UpdateSiteMemberSanityTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); testUserModel.setUserRole(UserRole.SiteCollaborator); restClient.withCoreAPI().usingSite(siteModel).updateSiteMember(testUserModel); - restClient.assertLastError() - .containsSummary(String.format("The current user does not have permissions to modify the membership details of the site %s.", siteModel.getTitle())); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + restClient.assertLastError() + .containsSummary(String.format("The current user does not have permissions to modify the membership details of the site %s.", siteModel.getTitle())); } @Bug(id="ACE-5444") diff --git a/e2e-test/java/org/alfresco/rest/tags/GetTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagSanityTests.java index c7ac5c44d..082be8203 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetTagSanityTests.java @@ -46,7 +46,7 @@ public class GetTagSanityTests extends RestTest restClient.authenticateUser(adminUserModel); RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(tagValue); - RestTagModel returnedTag = restClient.getTag(tag); + RestTagModel returnedTag = restClient.withCoreAPI().getTag(tag); restClient.assertStatusCodeIs(HttpStatus.OK); returnedTag.assertThat().field("tag").is(tagValue.toLowerCase()); } @@ -59,7 +59,7 @@ public class GetTagSanityTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(tagValue); - RestTagModel returnedTag = restClient.getTag(tag); + RestTagModel returnedTag = restClient.withCoreAPI().getTag(tag); restClient.assertStatusCodeIs(HttpStatus.OK); returnedTag.assertThat().field("tag").is(tagValue.toLowerCase()); } @@ -71,7 +71,7 @@ public class GetTagSanityTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(tagValue); - RestTagModel returnedTag = restClient.getTag(tag); + RestTagModel returnedTag = restClient.withCoreAPI().getTag(tag); restClient.assertStatusCodeIs(HttpStatus.OK); returnedTag.assertThat().field("tag").is(tagValue.toLowerCase()); } @@ -84,7 +84,7 @@ public class GetTagSanityTests extends RestTest RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(tagValue); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - RestTagModel returnedTag = restClient.getTag(tag); + RestTagModel returnedTag = restClient.withCoreAPI().getTag(tag); restClient.assertStatusCodeIs(HttpStatus.OK); returnedTag.assertThat().field("tag").is(tagValue.toLowerCase()); } @@ -98,7 +98,7 @@ public class GetTagSanityTests extends RestTest RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(tagValue); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - RestTagModel returnedTag = restClient.getTag(tag); + RestTagModel returnedTag = restClient.withCoreAPI().getTag(tag); restClient.assertStatusCodeIs(HttpStatus.OK); returnedTag.assertThat().field("tag").is(tagValue.toLowerCase()); } @@ -115,7 +115,7 @@ public class GetTagSanityTests extends RestTest managerUser.setPassword("wrongPassword"); restClient.authenticateUser(managerUser); - restClient.getTag(tag); + restClient.withCoreAPI().getTag(tag); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(ErrorModel.AUTHENTICATION_FAILED); } diff --git a/e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java index 93af00ad5..55e4de242 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java @@ -5,7 +5,6 @@ import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestTagModelsCollection; import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.data.RandomData; import org.alfresco.utility.model.ErrorModel; @@ -16,7 +15,6 @@ import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -54,7 +52,7 @@ public class GetTagsSanityTests extends RestTest public void getTagsWithManagerRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - RestTagModelsCollection returnedCollection = restClient.getTags(); + RestTagModelsCollection returnedCollection = restClient.withCoreAPI().getTags(); restClient.assertStatusCodeIs(HttpStatus.OK); returnedCollection.assertThat().entriesListIsEmpty() .and().entriesListContains("tag", tagValue.toLowerCase()) @@ -65,7 +63,7 @@ public class GetTagsSanityTests extends RestTest public void getTagsWithCollaboratorRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - RestTagModelsCollection returnedCollection = restClient.getTags(); + RestTagModelsCollection returnedCollection = restClient.withCoreAPI().getTags(); restClient.assertStatusCodeIs(HttpStatus.OK); returnedCollection.assertThat().entriesListIsEmpty() .and().entriesListContains("tag", tagValue.toLowerCase()) @@ -76,7 +74,7 @@ public class GetTagsSanityTests extends RestTest public void getTagsWithContributorRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - RestTagModelsCollection returnedCollection = restClient.getTags(); + RestTagModelsCollection returnedCollection = restClient.withCoreAPI().getTags(); restClient.assertStatusCodeIs(HttpStatus.OK); returnedCollection.assertThat().entriesListIsEmpty() .and().entriesListContains("tag", tagValue.toLowerCase()) @@ -87,7 +85,7 @@ public class GetTagsSanityTests extends RestTest public void getTagsWithConsumerRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - RestTagModelsCollection returnedCollection = restClient.getTags(); + RestTagModelsCollection returnedCollection = restClient.withCoreAPI().getTags(); restClient.assertStatusCodeIs(HttpStatus.OK); returnedCollection.assertThat().entriesListIsEmpty() .and().entriesListContains("tag", tagValue.toLowerCase()) @@ -98,7 +96,7 @@ public class GetTagsSanityTests extends RestTest public void getTagsWithAdminUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); - RestTagModelsCollection returnedCollection = restClient.getTags(); + RestTagModelsCollection returnedCollection = restClient.withCoreAPI().getTags(); restClient.assertStatusCodeIs(HttpStatus.OK); returnedCollection.assertThat().entriesListIsEmpty() .and().entriesListContains("tag", tagValue.toLowerCase()) @@ -114,7 +112,7 @@ public class GetTagsSanityTests extends RestTest userModel.setPassword("user wrong password"); dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); restClient.authenticateUser(userModel); - restClient.getTags(); + restClient.withCoreAPI().getTags(); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(ErrorModel.AUTHENTICATION_FAILED); } } diff --git a/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java index 190959f03..e8b8decb9 100644 --- a/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java @@ -56,7 +56,7 @@ public class UpdateTagSanityTests extends RestTest public void adminIsAbleToUpdateTags() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); - RestTagModel returnedModel = restClient.usingTag(oldTag).update(randomTag); + RestTagModel returnedModel = restClient.withCoreAPI().usingTag(oldTag).update(randomTag); restClient.assertStatusCodeIs(HttpStatus.OK); returnedModel.assertThat().field("tag").is(randomTag); } @@ -66,7 +66,7 @@ public class UpdateTagSanityTests extends RestTest public void managerIsNotAbleToUpdateTag() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.usingTag(oldTag).update(randomTag); + restClient.withCoreAPI().usingTag(oldTag).update(randomTag); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @@ -75,7 +75,7 @@ public class UpdateTagSanityTests extends RestTest public void collaboratorIsNotAbleToUpdateTag() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.usingTag(oldTag).update(randomTag); + restClient.withCoreAPI().usingTag(oldTag).update(randomTag); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @@ -84,7 +84,7 @@ public class UpdateTagSanityTests extends RestTest public void contributorIsNotAbleToUpdateTag() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - restClient.usingTag(oldTag).update(randomTag); + restClient.withCoreAPI().usingTag(oldTag).update(randomTag); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @@ -93,7 +93,7 @@ public class UpdateTagSanityTests extends RestTest public void consumerIsNotAbleToUpdateTag() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.usingTag(oldTag).update(randomTag); + restClient.withCoreAPI().usingTag(oldTag).update(randomTag); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @@ -105,7 +105,7 @@ public class UpdateTagSanityTests extends RestTest UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); siteManager.setPassword("wrongPassword"); restClient.authenticateUser(siteManager); - restClient.usingTag(oldTag).update(randomTag); + restClient.withCoreAPI().usingTag(oldTag).update(randomTag); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(ErrorModel.AUTHENTICATION_FAILED); } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java index 4537b15e9..7077f7a72 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java @@ -30,13 +30,12 @@ public class GetProcessDefinitionsSanityTests extends RestWorkflowTest restClient.authenticateUser(adminUserModel); } - // works on docker @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets process definitions for non-network deployments using REST API and status code is OK (200)") public void nonNetworkAdminGetsProcessDefinitions() throws Exception { restClient.authenticateUser(adminUserModel); - restClient.getAllProcessDefinitions().assertThat().entriesListIsNotEmpty(); + restClient.withWorkflowAPI().getAllProcessDefinitions().assertThat().entriesListIsNotEmpty(); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -49,7 +48,7 @@ public class GetProcessDefinitionsSanityTests extends RestWorkflowTest { restClient.usingTenant().createTenant(adminTenantUser); restClient.authenticateUser(adminTenantUser); - restClient.getAllProcessDefinitions().assertThat().entriesListIsNotEmpty(); + restClient.withWorkflowAPI().getAllProcessDefinitions().assertThat().entriesListIsNotEmpty(); restClient.assertStatusCodeIs(HttpStatus.OK); } } From da586d155cb1b169899eca40b5ff7ade65697191 Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 16 Nov 2016 16:49:18 +0200 Subject: [PATCH 0552/1491] update tests based on new refactored DSL --- .../DeleteProcessVariableSanityTests.java | 64 ++++++++++++++++ .../RemoveProcessVariableSanityTests.java | 76 ------------------- 2 files changed, 64 insertions(+), 76 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableSanityTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessVariableSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableSanityTests.java new file mode 100644 index 000000000..066c78352 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableSanityTests.java @@ -0,0 +1,64 @@ +package org.alfresco.rest.workflow.processes; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestWorkflowTest; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestProcessVariableModel; +import org.alfresco.utility.model.*; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * @author iulia.cojocea + */ +@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) +public class DeleteProcessVariableSanityTests extends RestWorkflowTest +{ + private FileModel document; + private SiteModel siteModel; + private UserModel userWhoStartsTask, assignee, adminUser; + private RestProcessModel processModel; + private RestProcessVariableModel variableModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userWhoStartsTask = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Delete existing variable") + public void deleteProcessVariable() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.withWorkflowAPI().usingProcess(processModel).deleteProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() + .assertThat().entriesListDoesNotContain("name", variableModel.getName()); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Try to delete existing variable using invalid processId") + public void deleteProcessVariableUsingInvalidProcessId() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + processModel.setId("incorrectProcessId"); + restClient.withWorkflowAPI().usingProcess(processModel).deleteProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, "incorrectProcessId")); + } +} diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessVariableSanityTests.java deleted file mode 100644 index 3df3546fb..000000000 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/RemoveProcessVariableSanityTests.java +++ /dev/null @@ -1,76 +0,0 @@ -package org.alfresco.rest.workflow.processes; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestWorkflowTest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.model.RestProcessVariableModel; -import org.alfresco.rest.requests.Processes; -import org.alfresco.utility.data.DataUser; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * @author iulia.cojocea - */ -@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) -public class RemoveProcessVariableSanityTests extends RestWorkflowTest -{ - @Autowired - private DataUser dataUser; - - @Autowired - private Processes processesApi; - - private FileModel document; - private SiteModel siteModel; - private UserModel userWhoStartsTask, assignee; - private RestProcessModel processModel; - private UserModel adminUser; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userWhoStartsTask = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); - processesApi.useRestClient(restClient); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Delete existing variable") - public void deleteProcessVariable() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUser); - RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = processesApi.getProcesses().getOneRandomEntry(); - processesApi.addProcessVariable(processModel, variableModel); - processesApi.deleteProcessVariable(processModel, variableModel); - processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); - processesApi.getProcessesVariables(processModel).assertThat().entriesListDoesNotContain("name", variableModel.getName()); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Try to delete existing variable using invalid processId") - public void deleteProcessVariableUsingInvalidProcessId() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUser); - RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = processesApi.getProcesses().getOneRandomEntry(); - processesApi.addProcessVariable(processModel, variableModel); - processModel.onModel().setId("incorrectProcessId"); - processesApi.deleteProcessVariable(processModel, variableModel); - processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); - } -} From e8c3cb6ade2283b3f77945e1728ec972d774cf77 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Wed, 16 Nov 2016 17:07:27 +0200 Subject: [PATCH 0553/1491] Refactor Test: GetTaskSanityTests.java --- .../workflow/tasks/GetTasksSanityTests.java | 46 +++++++++---------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksSanityTests.java index ed8c0b3e3..2326a1959 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksSanityTests.java @@ -1,8 +1,10 @@ + + package org.alfresco.rest.workflow.tasks; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestWorkflowTest; -import org.alfresco.rest.requests.RestTasksApi; +import org.alfresco.rest.model.RestTaskModelsCollection; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.GroupModel; import org.alfresco.utility.model.SiteModel; @@ -12,7 +14,6 @@ import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -20,14 +21,12 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) public class GetTasksSanityTests extends RestWorkflowTest { - @Autowired - RestTasksApi tasksApi; - UserModel userModel; SiteModel siteModel; UserModel candidateUser; FileModel fileModel; UserModel assigneeUser; + RestTaskModelsCollection taskModels; @BeforeClass(alwaysRun=true) public void dataPreparation() throws Exception @@ -37,25 +36,24 @@ public class GetTasksSanityTests extends RestWorkflowTest fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); assigneeUser = dataUser.createRandomTestUser(); dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - - tasksApi.useRestClient(restClient); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify admin user gets all existing tasks with Rest API and response is successfull (200)") public void adminUserGetsAllTasks() throws Exception { UserModel adminUser = dataUser.getAdminUser(); - restClient.authenticateUser(adminUser); - tasksApi.getTasks().assertThat().entriesListIsNotEmpty(); - tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + + taskModels = restClient.authenticateUser(adminUser).withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + taskModels.assertThat().entriesListIsNotEmpty(); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify asignee user gets its existing tasks with Rest API and response is successfull (200)") public void asigneeUserGetsItsTasks() throws Exception { - restClient.authenticateUser(assigneeUser); - tasksApi.getTasks().assertThat().entriesListIsNotEmpty(); - tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + taskModels = restClient.authenticateUser(assigneeUser).withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + taskModels.assertThat().entriesListIsNotEmpty(); } @@ -66,12 +64,13 @@ public class GetTasksSanityTests extends RestWorkflowTest UserModel userModel1 = dataUser.createRandomTestUser(); UserModel userModel2 = dataUser.createRandomTestUser(); GroupModel group = dataGroup.createRandomGroup(); + dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); - restClient.authenticateUser(userModel1); - tasksApi.getTasks().assertThat().entriesListIsNotEmpty(); - tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + taskModels = restClient.authenticateUser(userModel1).withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + taskModels.assertThat().entriesListIsNotEmpty(); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify candidate user that claims the task gets its existing tasks with Rest API and response is successfull (200)") @@ -84,9 +83,9 @@ public class GetTasksSanityTests extends RestWorkflowTest TaskModel taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); dataWorkflow.usingUser(userModel1).claimTask(taskModel); - restClient.authenticateUser(userModel1); - tasksApi.getTasks().assertThat().entriesListIsNotEmpty(); - tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + taskModels = restClient.authenticateUser(userModel1).withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + taskModels.assertThat().entriesListIsNotEmpty(); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify candidate user without claim gets no tasks with Rest API and response is successfull (200)") @@ -95,12 +94,13 @@ public class GetTasksSanityTests extends RestWorkflowTest UserModel userModel1 = dataUser.createRandomTestUser(); UserModel userModel2 = dataUser.createRandomTestUser(); GroupModel group = dataGroup.createRandomGroup(); + dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); TaskModel taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); dataWorkflow.usingUser(userModel1).claimTask(taskModel); - restClient.authenticateUser(userModel2); - tasksApi.getTasks().assertThat().entriesListIsEmpty(); - tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + taskModels = restClient.authenticateUser(userModel2).withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + taskModels.assertThat().entriesListIsEmpty(); } -} +} \ No newline at end of file From 307e77f38ae9e1a3ee927fa807968100ff9d7477 Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 16 Nov 2016 17:15:47 +0200 Subject: [PATCH 0554/1491] update tests based on new refactored DSL --- .../UpdateProcessVariableSanityTests.java | 84 ++++++++----------- 1 file changed, 37 insertions(+), 47 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/UpdateProcessVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/UpdateProcessVariableSanityTests.java index 029bcd9c4..782d61aa9 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/UpdateProcessVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/UpdateProcessVariableSanityTests.java @@ -2,19 +2,13 @@ package org.alfresco.rest.workflow.processes; import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestWorkflowTest; -import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestProcessVariableCollection; import org.alfresco.rest.model.RestProcessVariableModel; -import org.alfresco.rest.requests.Processes; -import org.alfresco.utility.data.DataUser; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.model.*; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -23,19 +17,14 @@ import org.testng.annotations.Test; * @author iulia.cojocea */ @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) -public class UpdateProcessVariableSanityTests extends RestWorkflowTest +public class UpdateProcessVariableSanityTests extends RestTest { - @Autowired - private DataUser dataUser; - - @Autowired - private Processes processesApi; - private FileModel document; private SiteModel siteModel; - private UserModel userWhoStartsTask, assignee; + private UserModel userWhoStartsTask, assignee, adminUser; private RestProcessModel processModel; - private UserModel adminUser; + private RestProcessVariableCollection variables; + private RestProcessVariableModel variableModel, updatedVariable; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception @@ -46,43 +35,44 @@ public class UpdateProcessVariableSanityTests extends RestWorkflowTest siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); - processesApi.useRestClient(restClient); } - - @TestRail(section = {"rest-api", TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Create non-existing variable using put call") - public void addProcessVariable() throws JsonToModelConversionException, Exception + public void addProcessVariable() throws Exception { - restClient.authenticateUser(adminUser); - RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = processesApi.addProcess("activitiAdhoc", adminUser, false, CMISUtil.Priority.Normal); - processesApi.updateProcessVariable(processModel, variableModel); - processesApi.getProcessesVariables(processModel).assertThat().entriesListContains("name", variableModel.getName()); - processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().addProcess("activitiAdhoc", adminUser, false, CMISUtil.Priority.Normal); + restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + variables = restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables(); + restClient.assertStatusCodeIs(HttpStatus.OK); + variables.assertThat().entriesListContains("name", variableModel.getName()); } - - @TestRail(section = {"rest-api", TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Update existing variable using put call") - public void updateProcessVariable() throws JsonToModelConversionException, Exception + public void updateProcessVariable() throws Exception { - restClient.authenticateUser(adminUser); - RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = processesApi.getProcesses().getOneRandomEntry(); - processesApi.addProcessVariable(processModel, variableModel); + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); variableModel.setValue("newValue"); - processesApi.updateProcessVariable(processModel, variableModel).assertThat().field("value").is("newValue"); - processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + updatedVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedVariable.assertThat().field("value").is("newValue"); } - - @TestRail(section = {"rest-api", TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Try to add process variable using an invalid processId") - public void addProcessVariableUsingInvalidProcessId() throws JsonToModelConversionException, Exception + public void addProcessVariableUsingInvalidProcessId() throws Exception { - restClient.authenticateUser(adminUser); - RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = processesApi.getProcesses().getOneRandomEntry(); - processModel.onModel().setId("abc"); - processesApi.updateProcessVariable(processModel, variableModel); - processesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); - } + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processModel.setId("abc"); + restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, "abc")); + } } From 3a3eccf2b0533ca645bca55cee44e54524280b17 Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 16 Nov 2016 17:17:34 +0200 Subject: [PATCH 0555/1491] remove RestWorkflowTest. --- e2e-test/java/org/alfresco/rest/RestTest.java | 8 ++-- .../org/alfresco/rest/RestWorkflowTest.java | 10 ----- .../GetProcessDefinitionImageSanityTests.java | 4 +- .../GetProcessDefinitionSanityTests.java | 4 +- ...ssDefinitionStartFormModelSanityTests.java | 4 +- .../GetProcessDefinitionsSanityTests.java | 4 +- .../processes/AddProcessItemSanityTests.java | 4 +- .../processes/AddProcessSanityTests.java | 4 +- .../AddProcessVariableSanityTests.java | 4 +- .../DeleteProcessItemSanityTests.java | 4 +- .../processes/DeleteProcessSanityTests.java | 4 +- .../DeleteProcessVariableSanityTests.java | 4 +- .../processes/GetProcessItemsSanityTests.java | 4 +- .../processes/GetProcessSanityTests.java | 4 +- .../processes/GetProcessTasksSanityTests.java | 4 +- .../GetProcessVariablesSanityTests.java | 4 +- .../processes/GetProcessesSanityTests.java | 4 +- .../tasks/AddTaskItemSanityTests.java | 30 +++++++-------- .../tasks/AddTaskVariablesSanityTests.java | 24 ++++++------ .../tasks/DeleteTaskVariableSanityTests.java | 14 +++---- .../tasks/GetTaskCandidatesTests.java | 24 ++++++------ .../tasks/GetTaskFormModelSanityTests.java | 16 ++++---- .../tasks/GetTaskItemsSanityTests.java | 24 ++++++------ .../workflow/tasks/GetTaskSanityTests.java | 20 +++++----- .../tasks/GetTaskVariablesSanityTests.java | 22 +++++------ .../workflow/tasks/GetTasksSanityTests.java | 20 +++++----- .../tasks/RemoveTaskItemSanityTests.java | 20 +++++----- .../tasks/UpdateTaskVariableSanityTests.java | 38 +++++++++---------- .../workflow/tasks/UploadTaskSanityTests.java | 20 +++++----- 29 files changed, 170 insertions(+), 180 deletions(-) delete mode 100644 e2e-test/java/org/alfresco/rest/RestWorkflowTest.java diff --git a/e2e-test/java/org/alfresco/rest/RestTest.java b/e2e-test/java/org/alfresco/rest/RestTest.java index 25118ed00..b5544498c 100644 --- a/e2e-test/java/org/alfresco/rest/RestTest.java +++ b/e2e-test/java/org/alfresco/rest/RestTest.java @@ -3,10 +3,7 @@ package org.alfresco.rest; import org.alfresco.rest.core.RestProperties; import org.alfresco.rest.core.RestWrapper; import org.alfresco.utility.TasProperties; -import org.alfresco.utility.data.DataContent; -import org.alfresco.utility.data.DataGroup; -import org.alfresco.utility.data.DataSite; -import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.data.*; import org.alfresco.utility.network.ServerHealth; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; @@ -40,6 +37,9 @@ public abstract class RestTest extends AbstractTestNGSpringContextTests @Autowired protected DataGroup dataGroup; + @Autowired + protected DataWorkflow dataWorkflow; + @BeforeClass(alwaysRun = true) public void checkServerHealth() throws Exception { diff --git a/e2e-test/java/org/alfresco/rest/RestWorkflowTest.java b/e2e-test/java/org/alfresco/rest/RestWorkflowTest.java deleted file mode 100644 index 34d216c9f..000000000 --- a/e2e-test/java/org/alfresco/rest/RestWorkflowTest.java +++ /dev/null @@ -1,10 +0,0 @@ -package org.alfresco.rest; - -import org.alfresco.utility.data.DataWorkflow; -import org.springframework.beans.factory.annotation.Autowired; - -public abstract class RestWorkflowTest extends RestTest -{ - @Autowired - protected DataWorkflow dataWorkflow; -} diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java index 88ef91bc9..bd531a421 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java @@ -1,6 +1,6 @@ package org.alfresco.rest.workflow.processDefinitions; -import org.alfresco.rest.RestWorkflowTest; +import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestProcessDefinitionModel; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.model.TestGroup; @@ -16,7 +16,7 @@ import org.testng.annotations.Test; * Created by Claudia Agache on 10/13/2016. */ @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY }) -public class GetProcessDefinitionImageSanityTests extends RestWorkflowTest +public class GetProcessDefinitionImageSanityTests extends RestTest { @Autowired private DataUser dataUser; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java index 308a2d92b..1a0f6a03b 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java @@ -1,6 +1,6 @@ package org.alfresco.rest.workflow.processDefinitions; -import org.alfresco.rest.RestWorkflowTest; +import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestProcessDefinitionModel; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.model.TestGroup; @@ -16,7 +16,7 @@ import org.testng.annotations.Test; * Created by Claudia Agache on 10/13/2016. */ @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY }) -public class GetProcessDefinitionSanityTests extends RestWorkflowTest +public class GetProcessDefinitionSanityTests extends RestTest { @Autowired private DataUser dataUser; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java index 1fa8ff3b9..9e4e2c3f4 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java @@ -1,6 +1,6 @@ package org.alfresco.rest.workflow.processDefinitions; -import org.alfresco.rest.RestWorkflowTest; +import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestProcessDefinitionModel; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.model.TestGroup; @@ -16,7 +16,7 @@ import org.testng.annotations.Test; * Created by Claudia Agache on 10/18/2016. */ @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY }) -public class GetProcessDefinitionStartFormModelSanityTests extends RestWorkflowTest +public class GetProcessDefinitionStartFormModelSanityTests extends RestTest { @Autowired private DataUser dataUser; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java index 7077f7a72..6db1d8b8a 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java @@ -1,6 +1,6 @@ package org.alfresco.rest.workflow.processDefinitions; -import org.alfresco.rest.RestWorkflowTest; +import org.alfresco.rest.RestTest; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; @@ -15,7 +15,7 @@ import org.testng.annotations.Test; * Created by Claudia Agache on 10/13/2016. */ @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY }) -public class GetProcessDefinitionsSanityTests extends RestWorkflowTest +public class GetProcessDefinitionsSanityTests extends RestTest { @Autowired private DataUser dataUser; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemSanityTests.java index 0bd9995ce..94d4b9d6d 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemSanityTests.java @@ -1,7 +1,7 @@ package org.alfresco.rest.workflow.processes; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestWorkflowTest; +import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestItemModel; import org.alfresco.rest.model.RestProcessModel; @@ -21,7 +21,7 @@ import org.testng.annotations.Test; * @author iulia.cojocea */ @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY}) -public class AddProcessItemSanityTests extends RestWorkflowTest +public class AddProcessItemSanityTests extends RestTest { private FileModel document, document2; private SiteModel siteModel; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessSanityTests.java index f2d2a8d03..75543e943 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessSanityTests.java @@ -1,7 +1,7 @@ package org.alfresco.rest.workflow.processes; import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.rest.RestWorkflowTest; +import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.rest.model.RestProcessModelsCollection; @@ -16,7 +16,7 @@ import org.testng.annotations.Test; * Created by Claudia Agache on 10/18/2016. */ @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) -public class AddProcessSanityTests extends RestWorkflowTest +public class AddProcessSanityTests extends RestTest { private UserModel userWhoStartsProcess, assignee; private UserModel adminTenantUser, tenantUserWhoStartsProcess, tenantAssignee; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java index 3fee0854c..5a33e94fc 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java @@ -2,7 +2,7 @@ package org.alfresco.rest.workflow.processes; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.rest.RestWorkflowTest; +import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.rest.model.RestProcessVariableModel; import org.alfresco.utility.data.RandomData; @@ -20,7 +20,7 @@ import org.testng.annotations.Test; * @author iulia.cojocea */ @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) -public class AddProcessVariableSanityTests extends RestWorkflowTest +public class AddProcessVariableSanityTests extends RestTest { private FileModel document; private SiteModel siteModel; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessItemSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessItemSanityTests.java index ff58fa654..4f86e110c 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessItemSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessItemSanityTests.java @@ -1,7 +1,7 @@ package org.alfresco.rest.workflow.processes; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestWorkflowTest; +import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestItemModel; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.utility.model.FileModel; @@ -18,7 +18,7 @@ import org.testng.annotations.Test; * @author iulia.cojocea */ @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) -public class DeleteProcessItemSanityTests extends RestWorkflowTest +public class DeleteProcessItemSanityTests extends RestTest { private FileModel document, document2; private SiteModel siteModel; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java index f75fda99b..9e6dd3636 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java @@ -1,7 +1,7 @@ package org.alfresco.rest.workflow.processes; import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.rest.RestWorkflowTest; +import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; @@ -15,7 +15,7 @@ import org.testng.annotations.Test; * Created by Claudia Agache on 10/12/2016. */ @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) -public class DeleteProcessSanityTests extends RestWorkflowTest +public class DeleteProcessSanityTests extends RestTest { private UserModel userWhoAddsProcess, assignee, anotherUser; private RestProcessModel process; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableSanityTests.java index 066c78352..9d1499248 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableSanityTests.java @@ -1,7 +1,7 @@ package org.alfresco.rest.workflow.processes; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestWorkflowTest; +import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.rest.model.RestProcessVariableModel; import org.alfresco.utility.model.*; @@ -15,7 +15,7 @@ import org.testng.annotations.Test; * @author iulia.cojocea */ @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) -public class DeleteProcessVariableSanityTests extends RestWorkflowTest +public class DeleteProcessVariableSanityTests extends RestTest { private FileModel document; private SiteModel siteModel; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsSanityTests.java index 3040af703..d580fc78e 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsSanityTests.java @@ -2,7 +2,7 @@ package org.alfresco.rest.workflow.processes; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.rest.RestWorkflowTest; +import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestItemModelsCollection; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.utility.model.FileModel; @@ -20,7 +20,7 @@ import org.testng.annotations.Test; */ @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) -public class GetProcessItemsSanityTests extends RestWorkflowTest +public class GetProcessItemsSanityTests extends RestTest { private FileModel document; private SiteModel siteModel; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessSanityTests.java index ce1ad31e0..713dd6ea2 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessSanityTests.java @@ -1,7 +1,7 @@ package org.alfresco.rest.workflow.processes; import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestWorkflowTest; +import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; @@ -15,7 +15,7 @@ import org.testng.annotations.Test; * Created by Claudia Agache on 10/19/2016. */ @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) -public class GetProcessSanityTests extends RestWorkflowTest +public class GetProcessSanityTests extends RestTest { private UserModel userWhoStartsProcess, assignee; private RestProcessModel addedProcess, process; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksSanityTests.java index a96f0837e..6334b784e 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksSanityTests.java @@ -1,7 +1,7 @@ package org.alfresco.rest.workflow.processes; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestWorkflowTest; +import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestTaskModelsCollection; import org.alfresco.utility.model.*; @@ -17,7 +17,7 @@ import org.testng.annotations.Test; * @author Cristina Axinte */ @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) -public class GetProcessTasksSanityTests extends RestWorkflowTest +public class GetProcessTasksSanityTests extends RestTest { private FileModel document; private SiteModel siteModel; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesSanityTests.java index a23b2875b..fe6dc3851 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesSanityTests.java @@ -1,7 +1,7 @@ package org.alfresco.rest.workflow.processes; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestWorkflowTest; +import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.rest.model.RestProcessVariableCollection; @@ -19,7 +19,7 @@ import org.testng.annotations.Test; * @author iulia.cojocea */ @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) -public class GetProcessVariablesSanityTests extends RestWorkflowTest +public class GetProcessVariablesSanityTests extends RestTest { private FileModel document; private SiteModel siteModel; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java index 07bb8e5cd..82a31470d 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java @@ -1,7 +1,7 @@ package org.alfresco.rest.workflow.processes; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestWorkflowTest; +import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestProcessModelsCollection; import org.alfresco.utility.model.*; import org.alfresco.utility.testrail.ExecutionType; @@ -14,7 +14,7 @@ import org.testng.annotations.Test; * Created by Claudia Agache on 10/11/2016. */ @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) -public class GetProcessesSanityTests extends RestWorkflowTest +public class GetProcessesSanityTests extends RestTest { private FileModel document; private SiteModel siteModel; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemSanityTests.java index ab7ef82ac..a0dfd86c4 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemSanityTests.java @@ -1,7 +1,7 @@ package org.alfresco.rest.workflow.tasks; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestWorkflowTest; +import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestItemModel; import org.alfresco.rest.requests.RestTasksApi; @@ -20,7 +20,7 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) -public class AddTaskItemSanityTests extends RestWorkflowTest +public class AddTaskItemSanityTests extends RestTest { @Autowired RestTasksApi tasksApi; @@ -48,7 +48,7 @@ public class AddTaskItemSanityTests extends RestWorkflowTest tasksApi.useRestClient(restClient); } - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Create non-existing task item") public void createTaskItem() throws Exception { @@ -56,7 +56,7 @@ public class AddTaskItemSanityTests extends RestWorkflowTest restClient.authenticateUser(adminUser); document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); taskItem = tasksApi.addTaskItem(taskModel, document2); - + taskItem.assertThat().field("createdAt").is(taskItem.getCreatedAt()) .assertThat().field("size").is(taskItem.getSize()) .assertThat().field("createdBy").is(taskItem.getCreatedBy()) @@ -67,9 +67,9 @@ public class AddTaskItemSanityTests extends RestWorkflowTest .assertThat().field("mimeType").is(taskItem.getMimeType()); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } - + @Bug(id = "MNT-16966") - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify that in case task item exists request ") public void createTaskItemThatAlreadyExists() throws Exception { @@ -88,27 +88,27 @@ public class AddTaskItemSanityTests extends RestWorkflowTest taskItem = tasksApi.addTaskItem(taskModel, document3); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.BAD_REQUEST); } - + @Test(groups = { TestGroup.NETWORKS }) - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Add task item using admin user from same network") public void addTaskItemByAdminSameNetwork() throws JsonToModelConversionException, Exception { UserModel adminuser = dataUser.getAdminUser(); restClient.authenticateUser(adminuser); - + adminTenantUser = UserModel.getAdminTenantUser(); tenantApi.useRestClient(restClient); tenantApi.createTenant(adminTenantUser); - + tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); - - siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); + + siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); dataWorkflow.usingUser(tenantUser).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(tenantUserAssignee); - + document4 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - taskItem = tasksApi.addTaskItem(taskModel, document4); + taskItem = tasksApi.addTaskItem(taskModel, document4); taskItem.assertThat().field("createdAt").is(taskItem.getCreatedAt()) .and().field("size").is(taskItem.getSize()) .and().field("createdBy").is(taskItem.getCreatedBy()) @@ -116,7 +116,7 @@ public class AddTaskItemSanityTests extends RestWorkflowTest .and().field("name").is(taskItem.getName()) .and().field("modifiedBy").is(taskItem.getModifiedBy()) .and().field("id").is(taskItem.getId()) - .and().field("mimeType").is(taskItem.getMimeType()); + .and().field("mimeType").is(taskItem.getMimeType()); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesSanityTests.java index b91414acc..64ea942bb 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesSanityTests.java @@ -1,7 +1,7 @@ package org.alfresco.rest.workflow.tasks; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestWorkflowTest; +import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestVariableModel; import org.alfresco.rest.requests.RestTasksApi; import org.alfresco.utility.model.FileModel; @@ -20,13 +20,13 @@ import org.testng.annotations.Test; * @author iulia.cojocea */ @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) -public class AddTaskVariablesSanityTests extends RestWorkflowTest +public class AddTaskVariablesSanityTests extends RestTest { @Autowired RestTasksApi tasksApi; - + private UserModel userModel, userWhoStartsTask; - private SiteModel siteModel; + private SiteModel siteModel; private FileModel fileModel; private UserModel assigneeUser; private TaskModel taskModel; @@ -44,7 +44,7 @@ public class AddTaskVariablesSanityTests extends RestWorkflowTest tasksApi.useRestClient(restClient); } - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Create non-existing task variable with admin") public void createTaskVariableWithAdmin() throws Exception { @@ -59,8 +59,8 @@ public class AddTaskVariablesSanityTests extends RestWorkflowTest .and().field("type").is(variableModel.getType()); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Create non-existing task variable with user involved in the process") public void createTaskVariableWithInvolvedUser() throws Exception { @@ -71,11 +71,11 @@ public class AddTaskVariablesSanityTests extends RestWorkflowTest .and().field("name").is(variableModel.getName()) .and().field("value").is(variableModel.getValue()) .and().field("type").is(variableModel.getType()); - tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); + tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); tasksApi.getTaskVariables(taskModel).assertThat().entriesListContains("name", variableModel.getName()); } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Create non-existing task variable with task owner") public void createTaskVariableWithTaskOwner() throws Exception { @@ -88,8 +88,8 @@ public class AddTaskVariablesSanityTests extends RestWorkflowTest .and().field("type").is(variableModel.getType()); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Create non-existing task variable with any user") public void createTaskVariableWithRandomUser() throws Exception { diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/DeleteTaskVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/DeleteTaskVariableSanityTests.java index 45ef401f4..4b8ad77e7 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/DeleteTaskVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/DeleteTaskVariableSanityTests.java @@ -1,7 +1,7 @@ package org.alfresco.rest.workflow.tasks; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestWorkflowTest; +import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestVariableModel; import org.alfresco.rest.requests.RestTasksApi; import org.alfresco.utility.model.FileModel; @@ -20,13 +20,13 @@ import org.testng.annotations.Test; * @author iulia.cojocea */ @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) -public class DeleteTaskVariableSanityTests extends RestWorkflowTest +public class DeleteTaskVariableSanityTests extends RestTest { @Autowired RestTasksApi tasksApi; - + private UserModel userModel, adminUser; - private SiteModel siteModel; + private SiteModel siteModel; private FileModel fileModel; private UserModel assigneeUser; private TaskModel taskModel; @@ -44,7 +44,7 @@ public class DeleteTaskVariableSanityTests extends RestWorkflowTest tasksApi.useRestClient(restClient); } - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Delete existing task variable") public void deleteTaskVariable() throws Exception { @@ -55,8 +55,8 @@ public class DeleteTaskVariableSanityTests extends RestWorkflowTest tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); tasksApi.getTaskVariables(taskModel).assertThat().entriesListDoesNotContain("name", variableModel.getName()); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Try to delete existing task variable using invalid task id") public void tryToDeleteTaskVariableUsingInvalidTaskId() throws Exception { diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCandidatesTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCandidatesTests.java index 236563c2f..8c61cf2f9 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCandidatesTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCandidatesTests.java @@ -1,7 +1,7 @@ package org.alfresco.rest.workflow.tasks; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestWorkflowTest; +import org.alfresco.rest.RestTest; import org.alfresco.rest.requests.RestTasksApi; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.GroupModel; @@ -17,16 +17,16 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; /** - * + * * @author Cristina Axinte * */ @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) -public class GetTaskCandidatesTests extends RestWorkflowTest +public class GetTaskCandidatesTests extends RestTest { @Autowired RestTasksApi tasksApi; - + private UserModel userModel, user, userModel1, userModel2; private SiteModel siteModel; private FileModel fileModel; @@ -48,32 +48,32 @@ public class GetTaskCandidatesTests extends RestWorkflowTest tasksApi.useRestClient(restClient); } - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify that admin gets task candidates") public void getTaskCandidatesByAdmin() throws Exception - { + { restClient.authenticateUser(dataUser.getAdminUser()); tasksApi.getTaskCandidates(taskModel) .assertThat().entriesListContains("candidateType", "group") .and().entriesListContains("candidateId", String.format("GROUP_%s", group.getGroupIdentifier())); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify that user that started the process gets task candidates") public void getTaskCandidatesByUserWhoStartedProcess() throws Exception - { + { restClient.authenticateUser(user); tasksApi.getTaskCandidates(taskModel) .assertThat().entriesListContains("candidateType", "group") .and().entriesListContains("candidateId", String.format("GROUP_%s", group.getGroupIdentifier())); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify that user from the assighed group to the process gets task candidates") public void getTaskCandidatesByCandidateUser() throws Exception - { + { restClient.authenticateUser(userModel1); tasksApi.getTaskCandidates(taskModel) .assertThat().entriesListContains("candidateType", "group") diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelSanityTests.java index 625b06cbb..0db7c300a 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelSanityTests.java @@ -1,7 +1,7 @@ package org.alfresco.rest.workflow.tasks; import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestWorkflowTest; +import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestFormModelsCollection; import org.alfresco.rest.requests.RestTasksApi; import org.alfresco.utility.model.FileModel; @@ -20,7 +20,7 @@ import org.testng.annotations.Test; * Created by Claudia Agache on 10/20/2016. */ @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) -public class GetTaskFormModelSanityTests extends RestWorkflowTest +public class GetTaskFormModelSanityTests extends RestTest { @Autowired RestTasksApi tasksApi; @@ -46,12 +46,12 @@ public class GetTaskFormModelSanityTests extends RestWorkflowTest { restClient.authenticateUser(dataUser.getAdminUser()); RestFormModelsCollection returnedCollection = tasksApi.getTaskFormModel(taskModel); - + tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); returnedCollection.assertThat().entriesListIsNotEmpty(); - + String[] qualifiedNames = { - "{http://www.alfresco.org/model/bpm/1.0}percentComplete", + "{http://www.alfresco.org/model/bpm/1.0}percentComplete", "{http://www.alfresco.org/model/bpm/1.0}context", "{http://www.alfresco.org/model/bpm/1.0}completedItems", "{http://www.alfresco.org/model/content/1.0}name", @@ -62,12 +62,12 @@ public class GetTaskFormModelSanityTests extends RestWorkflowTest "{http://www.alfresco.org/model/bpm/1.0}taskId", "{http://www.alfresco.org/model/bpm/1.0}packageItemActionGroup", "{http://www.alfresco.org/model/bpm/1.0}completionDate"}; - + for(String formQualifiedName : qualifiedNames) { returnedCollection.assertThat().entriesListContains("qualifiedName", formQualifiedName); } - + tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @@ -77,7 +77,7 @@ public class GetTaskFormModelSanityTests extends RestWorkflowTest { restClient.authenticateUser(userModel); RestFormModelsCollection returnedCollection = tasksApi.getTaskFormModel(taskModel); - + returnedCollection.assertThat().entriesListIsNotEmpty(); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); returnedCollection.assertThat().entriesListIsNotEmpty(); diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskItemsSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskItemsSanityTests.java index ab2186e29..42f007849 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskItemsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskItemsSanityTests.java @@ -1,7 +1,7 @@ package org.alfresco.rest.workflow.tasks; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestWorkflowTest; +import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestItemModel; import org.alfresco.rest.requests.RestTasksApi; import org.alfresco.rest.requests.RestTenantApi; @@ -19,14 +19,14 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) -public class GetTaskItemsSanityTests extends RestWorkflowTest +public class GetTaskItemsSanityTests extends RestTest { @Autowired RestTasksApi tasksApi; @Autowired RestTenantApi tenantApi; - + private UserModel userModel, userWhoStartsTask, assignee, adminTenantUser, tenantUser, tenantUserAssignee; private SiteModel siteModel; private FileModel fileModel, document1; @@ -45,7 +45,7 @@ public class GetTaskItemsSanityTests extends RestWorkflowTest tasksApi.useRestClient(restClient); } - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify that user that started the process gets task items") public void getTaskItemsByUserWhoStartedProcess() throws Exception { @@ -60,8 +60,8 @@ public class GetTaskItemsSanityTests extends RestWorkflowTest tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify that involved user in process gets task items") public void getTaskItemsByUserInvolvedInProcess() throws Exception { @@ -74,8 +74,8 @@ public class GetTaskItemsSanityTests extends RestWorkflowTest .entriesListContains("name", document1.getName()); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify that user that started the process gets task items") @Test(groups = { TestGroup.NETWORKS }) public void getTaskItemsByAdminInSameNetwork() throws Exception @@ -86,13 +86,13 @@ public class GetTaskItemsSanityTests extends RestWorkflowTest adminTenantUser = UserModel.getAdminTenantUser(); tenantApi.useRestClient(restClient); tenantApi.createTenant(adminTenantUser); - + tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); - - siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); + + siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); dataWorkflow.usingUser(tenantUser).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(tenantUserAssignee); - + document1 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); taskItem = tasksApi.addTaskItem(taskModel, document1); tasksApi.getTaskItems(taskModel).assertThat() diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskSanityTests.java index 32188daf0..b75dc265f 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskSanityTests.java @@ -1,7 +1,7 @@ package org.alfresco.rest.workflow.tasks; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestWorkflowTest; +import org.alfresco.rest.RestTest; import org.alfresco.rest.requests.RestTasksApi; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.GroupModel; @@ -18,7 +18,7 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) -public class GetTaskSanityTests extends RestWorkflowTest +public class GetTaskSanityTests extends RestTest { @Autowired RestTasksApi tasksApi; @@ -52,7 +52,7 @@ public class GetTaskSanityTests extends RestWorkflowTest .and().field("message").is(taskModel.getMessage()); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify assignee user gets its assigned task with Rest API and response is successfull (200)") public void assigneeUserGetsItsTaskWithSuccess() throws Exception { @@ -62,7 +62,7 @@ public class GetTaskSanityTests extends RestWorkflowTest .and().field("message").is(taskModel.getMessage()); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify user that started the task gets the started task with Rest API and response is successfull (200)") public void starterUserGetsItsTaskWithSuccess() throws Exception { @@ -72,17 +72,17 @@ public class GetTaskSanityTests extends RestWorkflowTest .and().field("message").is(taskModel.getMessage()); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify any user with no relation to task id forbidden to get other task with Rest API (403)") public void anyUserIsForbiddenToGetOtherTask() throws Exception { UserModel anyUser= dataUser.createRandomTestUser(); - + restClient.authenticateUser(anyUser); tasksApi.getTask(taskModel); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); } - + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify candidate user gets its specific task and no other user claimed the task with Rest API and response is successfull (200)") public void candidateUserGetsItsTasks() throws Exception { @@ -91,14 +91,14 @@ public class GetTaskSanityTests extends RestWorkflowTest GroupModel group = dataGroup.createRandomGroup(); dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); TaskModel taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); - + restClient.authenticateUser(userModel1); tasksApi.getTask(taskModel) .assertThat().field("id").is(taskModel.getId()) .and().field("message").is(taskModel.getMessage()); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - + @Bug(id = "MNT-17051") @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify involved user in a task without claim it gets the task with Rest API and response is successfull (200)") public void involvedUserWithoutClaimTaskGetsTask() throws Exception @@ -109,7 +109,7 @@ public class GetTaskSanityTests extends RestWorkflowTest dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); TaskModel taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); dataWorkflow.usingUser(userModel1).claimTask(taskModel); - + restClient.authenticateUser(userModel2); tasksApi.getTask(taskModel) .assertThat().field("id").is(taskModel.getId()) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskVariablesSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskVariablesSanityTests.java index 3135bd1df..1db7f624c 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskVariablesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskVariablesSanityTests.java @@ -1,7 +1,7 @@ package org.alfresco.rest.workflow.tasks; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestWorkflowTest; +import org.alfresco.rest.RestTest; import org.alfresco.rest.requests.RestTasksApi; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; @@ -19,7 +19,7 @@ import org.testng.annotations.Test; * @author iulia.cojocea */ @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) -public class GetTaskVariablesSanityTests extends RestWorkflowTest +public class GetTaskVariablesSanityTests extends RestTest { @Autowired RestTasksApi tasksApi; @@ -42,7 +42,7 @@ public class GetTaskVariablesSanityTests extends RestWorkflowTest tasksApi.useRestClient(restClient); } - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify that user that started the process gets task variables") public void getTaskVariablesByUserWhoStartedProcess() throws Exception { @@ -50,8 +50,8 @@ public class GetTaskVariablesSanityTests extends RestWorkflowTest tasksApi.getTaskVariables(taskModel).assertThat().entriesListIsNotEmpty(); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify that user that is involved in the process gets task variables") public void getTaskVariablesByUserInvolvedInProcess() throws Exception { @@ -59,24 +59,24 @@ public class GetTaskVariablesSanityTests extends RestWorkflowTest tasksApi.getTaskVariables(taskModel).assertThat().entriesListIsNotEmpty(); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify that user that is not involved in the process gets task variables") public void getTaskVariablesUsingAnyUser() throws Exception { UserModel randomUser = dataUser.createRandomTestUser(); - + restClient.authenticateUser(randomUser); tasksApi.getTaskVariables(taskModel); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify that admin gets task variables") public void getTaskVariablesUsingAdmin() throws Exception { UserModel adminUser = dataUser.getAdminUser(); - + restClient.authenticateUser(adminUser); tasksApi.getTaskVariables(taskModel).assertThat().entriesListIsNotEmpty(); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksSanityTests.java index ed8c0b3e3..96f3d713c 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksSanityTests.java @@ -1,7 +1,7 @@ package org.alfresco.rest.workflow.tasks; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestWorkflowTest; +import org.alfresco.rest.RestTest; import org.alfresco.rest.requests.RestTasksApi; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.GroupModel; @@ -18,7 +18,7 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) -public class GetTasksSanityTests extends RestWorkflowTest +public class GetTasksSanityTests extends RestTest { @Autowired RestTasksApi tasksApi; @@ -49,7 +49,7 @@ public class GetTasksSanityTests extends RestWorkflowTest tasksApi.getTasks().assertThat().entriesListIsNotEmpty(); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify asignee user gets its existing tasks with Rest API and response is successfull (200)") public void asigneeUserGetsItsTasks() throws Exception { @@ -57,10 +57,10 @@ public class GetTasksSanityTests extends RestWorkflowTest tasksApi.getTasks().assertThat().entriesListIsNotEmpty(); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify candidate user that claims the task gets its existing tasks with Rest API and response is successfull (200)") - @Bug(id = "MNT-16967") + @Bug(id = "MNT-16967") public void candidateUserGetsItsTasks() throws Exception { UserModel userModel1 = dataUser.createRandomTestUser(); @@ -68,12 +68,12 @@ public class GetTasksSanityTests extends RestWorkflowTest GroupModel group = dataGroup.createRandomGroup(); dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); - + restClient.authenticateUser(userModel1); tasksApi.getTasks().assertThat().entriesListIsNotEmpty(); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify candidate user that claims the task gets its existing tasks with Rest API and response is successfull (200)") public void candidateUserThatClaimsTaskGetsItsTasks() throws Exception { @@ -83,12 +83,12 @@ public class GetTasksSanityTests extends RestWorkflowTest dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); TaskModel taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); dataWorkflow.usingUser(userModel1).claimTask(taskModel); - + restClient.authenticateUser(userModel1); tasksApi.getTasks().assertThat().entriesListIsNotEmpty(); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify candidate user without claim gets no tasks with Rest API and response is successfull (200)") public void candidateUserWithoutClaimTaskGetsNoTasks() throws Exception { @@ -98,7 +98,7 @@ public class GetTasksSanityTests extends RestWorkflowTest dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); TaskModel taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); dataWorkflow.usingUser(userModel1).claimTask(taskModel); - + restClient.authenticateUser(userModel2); tasksApi.getTasks().assertThat().entriesListIsEmpty(); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/RemoveTaskItemSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/RemoveTaskItemSanityTests.java index b0bcaff68..e778ac097 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/RemoveTaskItemSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/RemoveTaskItemSanityTests.java @@ -1,7 +1,7 @@ package org.alfresco.rest.workflow.tasks; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestWorkflowTest; +import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestItemModel; import org.alfresco.rest.requests.RestTasksApi; import org.alfresco.utility.model.FileModel; @@ -20,14 +20,14 @@ import org.testng.annotations.Test; * @author iulia.cojocea */ @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) -public class RemoveTaskItemSanityTests extends RestWorkflowTest +public class RemoveTaskItemSanityTests extends RestTest { @Autowired RestTasksApi tasksApi; - - + + private UserModel adminUser, userModel, userWhoStartsTask, assigneeUser; - private SiteModel siteModel; + private SiteModel siteModel; private FileModel fileModel, document2; private TaskModel taskModel; @@ -47,7 +47,7 @@ public class RemoveTaskItemSanityTests extends RestWorkflowTest tasksApi.useRestClient(restClient); } - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Delete existing task item") public void deleteTaskItem() throws Exception { @@ -60,8 +60,8 @@ public class RemoveTaskItemSanityTests extends RestWorkflowTest .assertThat().entriesListDoesNotContain("id", taskItem.getId()).and() .entriesListDoesNotContain("name", document2.getName()); } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Try to Delete existing task item using invalid taskId") public void deleteTaskItemUsingInvalidTaskId() throws Exception { @@ -72,8 +72,8 @@ public class RemoveTaskItemSanityTests extends RestWorkflowTest tasksApi.deleteTaskItem(taskModel, taskItem); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Try to Delete existing task item using invalid itemId") public void deleteTaskItemUsingInvalidItemId() throws Exception { diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskVariableSanityTests.java index 0953250e1..0e493a3e4 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskVariableSanityTests.java @@ -1,7 +1,7 @@ package org.alfresco.rest.workflow.tasks; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestWorkflowTest; +import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestVariableModel; import org.alfresco.rest.requests.RestTasksApi; import org.alfresco.rest.requests.RestTenantApi; @@ -21,21 +21,21 @@ import org.testng.annotations.Test; * @author iulia.cojocea */ @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) -public class UpdateTaskVariableSanityTests extends RestWorkflowTest +public class UpdateTaskVariableSanityTests extends RestTest { @Autowired RestTasksApi tasksApi; - + @Autowired RestTenantApi tenantApi; - + private UserModel userModel; - private SiteModel siteModel; + private SiteModel siteModel; private FileModel fileModel; private UserModel assigneeUser; private TaskModel taskModel, tenantTask; - + private UserModel adminTenantUser, tenantUser, tenantUserAssignee; private RestVariableModel taskVariable; @@ -52,7 +52,7 @@ public class UpdateTaskVariableSanityTests extends RestWorkflowTest tasksApi.useRestClient(restClient); } - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Create non-existing task variable") public void createTaskVariable() throws Exception { @@ -66,8 +66,8 @@ public class UpdateTaskVariableSanityTests extends RestWorkflowTest .and().field("value").is(taskVariable.getValue()); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Update existing task variable") public void updateTaskVariable() throws Exception { @@ -83,33 +83,33 @@ public class UpdateTaskVariableSanityTests extends RestWorkflowTest taskVariable = tasksApi.updateTaskVariable(taskModel, variableModel).and().field("value").is("updatedValue"); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - + @Test(groups = {TestGroup.NETWORKS }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Update existing task variable by admin in the same network") public void updateTaskVariableByAdminInSameNetwork() throws Exception { UserModel adminUser = dataUser.getAdminUser(); restClient.authenticateUser(adminUser); - + adminTenantUser = UserModel.getAdminTenantUser(); tenantApi.useRestClient(restClient); tenantApi.createTenant(adminTenantUser); - + tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); - - siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); + + siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); tenantTask = dataWorkflow.usingUser(tenantUser).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(tenantUserAssignee); - + RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); taskVariable = tasksApi.updateTaskVariable(tenantTask, variableModel); - + taskVariable.assertThat().field("scope").is(taskVariable.getScope()) .and().field("name").is(taskVariable.getName()) .and().field("type").is(taskVariable.getType()) - .and().field("value").is(taskVariable.getValue()); - + .and().field("value").is(taskVariable.getValue()); + variableModel.setValue("updatedValue"); taskVariable = tasksApi.updateTaskVariable(taskModel, variableModel).and().field("value").is("updatedValue"); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UploadTaskSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UploadTaskSanityTests.java index 7452c4e86..24d140442 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/UploadTaskSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/UploadTaskSanityTests.java @@ -1,7 +1,7 @@ package org.alfresco.rest.workflow.tasks; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestWorkflowTest; +import org.alfresco.rest.RestTest; import org.alfresco.rest.requests.RestTasksApi; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.GroupModel; @@ -17,7 +17,7 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) -public class UploadTaskSanityTests extends RestWorkflowTest +public class UploadTaskSanityTests extends RestTest { @Autowired RestTasksApi tasksApi; @@ -28,7 +28,7 @@ public class UploadTaskSanityTests extends RestWorkflowTest FileModel fileModel; UserModel assigneeUser; TaskModel taskModel; - + @BeforeClass(alwaysRun=true) public void dataPreparation() throws Exception { @@ -40,7 +40,7 @@ public class UploadTaskSanityTests extends RestWorkflowTest tasksApi.useRestClient(restClient); } - + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify admin user updates task with Rest API and response is successfull (200)") public void adminUserUpdatesAnyTaskWithSuccess() throws Exception { @@ -51,7 +51,7 @@ public class UploadTaskSanityTests extends RestWorkflowTest .and().field("message").is(taskModel.getMessage()); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify assignee user updates its assigned task with Rest API and response is successfull (200)") public void assigneeUserUpdatesItsTaskWithSuccess() throws Exception { @@ -61,7 +61,7 @@ public class UploadTaskSanityTests extends RestWorkflowTest .and().field("message").is(taskModel.getMessage()); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify user that started the task updates the started task with Rest API and response is successfull (200)") public void starterUserUpdatesItsTaskWithSuccess() throws Exception { @@ -69,17 +69,17 @@ public class UploadTaskSanityTests extends RestWorkflowTest tasksApi.updateTask(taskModel); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } - + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify any user with no relation to task is forbidden to update other task with Rest API (403)") public void anyUserIsForbiddenToUpdateOtherTask() throws Exception { UserModel anyUser= dataUser.createRandomTestUser(); - + restClient.authenticateUser(anyUser); tasksApi.updateTask(taskModel); tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); } - + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify candidate user updates its specific task and no other user claimed the task with Rest API and response is successfull (200)") public void candidateUserUpdatesItsTasks() throws Exception { @@ -88,7 +88,7 @@ public class UploadTaskSanityTests extends RestWorkflowTest GroupModel group = dataGroup.createRandomGroup(); dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); TaskModel taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); - + restClient.authenticateUser(userModel1); tasksApi.updateTask(taskModel) .assertThat().field("id").is(taskModel.getId()) From 10c98fc80d3759d099da5a5c2ef3e4456b729219 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Wed, 16 Nov 2016 17:31:11 +0200 Subject: [PATCH 0556/1491] Refactor Test: GetTaskSanityTests.java --- .../workflow/tasks/GetTaskSanityTests.java | 54 ++++++++----------- 1 file changed, 23 insertions(+), 31 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskSanityTests.java index 32188daf0..e6f31f10c 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskSanityTests.java @@ -2,7 +2,7 @@ package org.alfresco.rest.workflow.tasks; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestWorkflowTest; -import org.alfresco.rest.requests.RestTasksApi; +import org.alfresco.rest.model.RestTaskModel; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.GroupModel; import org.alfresco.utility.model.SiteModel; @@ -12,7 +12,6 @@ import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -20,15 +19,13 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) public class GetTaskSanityTests extends RestWorkflowTest { - @Autowired - RestTasksApi tasksApi; - UserModel userModel; SiteModel siteModel; UserModel candidateUser; FileModel fileModel; UserModel assigneeUser; TaskModel taskModel; + RestTaskModel restTaskModel; @BeforeClass(alwaysRun=true) public void dataPreparation() throws Exception @@ -38,39 +35,36 @@ public class GetTaskSanityTests extends RestWorkflowTest fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); assigneeUser = dataUser.createRandomTestUser(); taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - - tasksApi.useRestClient(restClient); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify admin user gets any existing task with Rest API and response is successfull (200)") public void adminUserGetsAnyTaskWithSuccess() throws Exception { UserModel adminUser = dataUser.getAdminUser(); - restClient.authenticateUser(adminUser); - tasksApi.getTask(taskModel) - .assertThat().field("id").is(taskModel.getId()) + + restTaskModel = restClient.authenticateUser(adminUser).withWorkflowAPI().usingTask(taskModel).getTask(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) .and().field("message").is(taskModel.getMessage()); - tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify assignee user gets its assigned task with Rest API and response is successfull (200)") public void assigneeUserGetsItsTaskWithSuccess() throws Exception { - restClient.authenticateUser(assigneeUser); - tasksApi.getTask(taskModel) - .assertThat().field("id").is(taskModel.getId()) + restTaskModel = restClient.authenticateUser(assigneeUser).withWorkflowAPI().usingTask(taskModel).getTask(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) .and().field("message").is(taskModel.getMessage()); - tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify user that started the task gets the started task with Rest API and response is successfull (200)") public void starterUserGetsItsTaskWithSuccess() throws Exception { - restClient.authenticateUser(userModel); - tasksApi.getTask(taskModel) - .assertThat().field("id").is(taskModel.getId()) + restTaskModel = restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).getTask(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) .and().field("message").is(taskModel.getMessage()); - tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify any user with no relation to task id forbidden to get other task with Rest API (403)") @@ -78,9 +72,8 @@ public class GetTaskSanityTests extends RestWorkflowTest { UserModel anyUser= dataUser.createRandomTestUser(); - restClient.authenticateUser(anyUser); - tasksApi.getTask(taskModel); - tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); + restTaskModel = restClient.authenticateUser(anyUser).withWorkflowAPI().usingTask(taskModel).getTask(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify candidate user gets its specific task and no other user claimed the task with Rest API and response is successfull (200)") @@ -92,11 +85,11 @@ public class GetTaskSanityTests extends RestWorkflowTest dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); TaskModel taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); - restClient.authenticateUser(userModel1); - tasksApi.getTask(taskModel) - .assertThat().field("id").is(taskModel.getId()) + restTaskModel = restClient.authenticateUser(userModel1).withWorkflowAPI().usingTask(taskModel).getTask(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) .and().field("message").is(taskModel.getMessage()); - tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + } @Bug(id = "MNT-17051") @@ -110,10 +103,9 @@ public class GetTaskSanityTests extends RestWorkflowTest TaskModel taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); dataWorkflow.usingUser(userModel1).claimTask(taskModel); - restClient.authenticateUser(userModel2); - tasksApi.getTask(taskModel) - .assertThat().field("id").is(taskModel.getId()) + restTaskModel = restClient.authenticateUser(userModel2).withWorkflowAPI().usingTask(taskModel).getTask(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) .and().field("message").is(taskModel.getMessage()); - tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } -} +} \ No newline at end of file From 2f13480083c981502a54b27a99fc6eb22f6f64c6 Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 16 Nov 2016 17:47:07 +0200 Subject: [PATCH 0557/1491] update tests based on new refactored DSL --- .../DeleteDeploymentSanityTests.java | 56 +++++++++---------- 1 file changed, 25 insertions(+), 31 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java index c099745b0..48fa98492 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java @@ -1,15 +1,14 @@ package org.alfresco.rest.workflow.deployments; -import org.alfresco.rest.RestWorkflowTest; -import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestDeploymentModel; -import org.alfresco.rest.requests.RestDeploymentsApi; +import org.alfresco.rest.model.RestDeploymentModelsCollection; +import org.alfresco.utility.model.ErrorModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -23,11 +22,8 @@ import org.testng.annotations.Test; */ @Test(groups = { TestGroup.REST_API, TestGroup.DEPLOYMENTS, TestGroup.SANITY, TestGroup.WORKFLOW }, priority = 100) -public class DeleteDeploymentSanityTests extends RestWorkflowTest +public class DeleteDeploymentSanityTests extends RestTest { - @Autowired - private RestDeploymentsApi deploymentsApi; - private UserModel adminUser; private RestDeploymentModel deployment; @@ -35,35 +31,33 @@ public class DeleteDeploymentSanityTests extends RestWorkflowTest public void dataPreparation() throws Exception { adminUser = dataUser.getAdminUser(); - deploymentsApi.useRestClient(restClient); } - @Bug(id = "MNT-16996") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, + @Bug(id = "MNT-16996") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.SANITY, description = "Verify admin user deletes a specific deployment using REST API and status code is successful (204)") - public void adminDeletesDeploymentWithSuccess() throws JsonToModelConversionException, Exception + public void adminDeletesDeploymentWithSuccess() throws Exception { dataContent.assertExtensionAmpExists("alfresco-workflow-extension"); - restClient.authenticateUser(adminUser); // The deployment with name "customWorkflowExtentionForRest.bpmn" is created by Workflow Extention Point - deploymentsApi.getDeployments().assertThat() - .entriesListContains("name", "customWorkflowExtentionForRest.bpmn"); - - deployment = deploymentsApi.getDeployments().getDeploymentByName("customWorkflowExtentionForRest.bpmn"); - deploymentsApi.deleteDeployment(deployment); - deploymentsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @Bug(id = "MNT-16996") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, - executionType = ExecutionType.SANITY, description = "Verify admin user cannot delete an inexistent deployment using REST API and status code is successful (204)") - public void adminCannotDeleteInexistentDeployment() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUser); - deployment = deploymentsApi.getDeployments().getOneRandomEntry(); - deployment.onModel().setId(String.valueOf(1000)); + RestDeploymentModelsCollection allDeployments = restClient.authenticateUser(adminUser).withWorkflowAPI().getDeployments(); + allDeployments.assertThat().entriesListContains("name", "customWorkflowExtentionForRest.bpmn"); + deployment = allDeployments.getDeploymentByName("customWorkflowExtentionForRest.bpmn"); - deploymentsApi.deleteDeployment(deployment); - deploymentsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); + restClient.withWorkflowAPI().usingDeployment(deployment).deleteDeployment(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @Bug(id = "MNT-16996") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, + executionType = ExecutionType.SANITY, description = "Verify admin user cannot delete an inexistent deployment using REST API and status code is successful (204)") + public void adminCannotDeleteInexistentDeployment() throws Exception + { + deployment = restClient.authenticateUser(adminUser).withWorkflowAPI().getDeployments().getOneRandomEntry().onModel(); + deployment.setId(String.valueOf(1000)); + + restClient.withWorkflowAPI().usingDeployment(deployment).deleteDeployment(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, "1000")); } } From 0db4ce4bbaca152f0ae90c84498cc73842a9893e Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Wed, 16 Nov 2016 17:50:24 +0200 Subject: [PATCH 0558/1491] Refactor Test: UploadTaskSanityTests.java --- .../workflow/tasks/UploadTaskSanityTests.java | 43 ++++++++----------- 1 file changed, 17 insertions(+), 26 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UploadTaskSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UploadTaskSanityTests.java index 24d140442..58df7cb1c 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/UploadTaskSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/UploadTaskSanityTests.java @@ -2,7 +2,7 @@ package org.alfresco.rest.workflow.tasks; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; -import org.alfresco.rest.requests.RestTasksApi; +import org.alfresco.rest.model.RestTaskModel; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.GroupModel; import org.alfresco.utility.model.SiteModel; @@ -11,7 +11,6 @@ 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.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -19,15 +18,13 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) public class UploadTaskSanityTests extends RestTest { - @Autowired - RestTasksApi tasksApi; - UserModel userModel; SiteModel siteModel; UserModel candidateUser; FileModel fileModel; UserModel assigneeUser; TaskModel taskModel; + RestTaskModel restTaskModel; @BeforeClass(alwaysRun=true) public void dataPreparation() throws Exception @@ -37,37 +34,33 @@ public class UploadTaskSanityTests extends RestTest fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); assigneeUser = dataUser.createRandomTestUser(); taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - - tasksApi.useRestClient(restClient); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify admin user updates task with Rest API and response is successfull (200)") public void adminUserUpdatesAnyTaskWithSuccess() throws Exception { UserModel adminUser = dataUser.getAdminUser(); - restClient.authenticateUser(adminUser); - tasksApi.updateTask(taskModel) - .assertThat().field("id").is(taskModel.getId()) + + restTaskModel = restClient.authenticateUser(adminUser).withWorkflowAPI().usingTask(taskModel).updateTask(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) .and().field("message").is(taskModel.getMessage()); - tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify assignee user updates its assigned task with Rest API and response is successfull (200)") public void assigneeUserUpdatesItsTaskWithSuccess() throws Exception { - restClient.authenticateUser(assigneeUser); - tasksApi.updateTask(taskModel) - .assertThat().field("id").is(taskModel.getId()) + restTaskModel = restClient.authenticateUser(assigneeUser).withWorkflowAPI().usingTask(taskModel).updateTask(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) .and().field("message").is(taskModel.getMessage()); - tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify user that started the task updates the started task with Rest API and response is successfull (200)") public void starterUserUpdatesItsTaskWithSuccess() throws Exception { - restClient.authenticateUser(userModel); - tasksApi.updateTask(taskModel); - tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restTaskModel = restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).updateTask(); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify any user with no relation to task is forbidden to update other task with Rest API (403)") @@ -75,9 +68,8 @@ public class UploadTaskSanityTests extends RestTest { UserModel anyUser= dataUser.createRandomTestUser(); - restClient.authenticateUser(anyUser); - tasksApi.updateTask(taskModel); - tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); + restTaskModel = restClient.authenticateUser(anyUser).withWorkflowAPI().usingTask(taskModel).updateTask(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify candidate user updates its specific task and no other user claimed the task with Rest API and response is successfull (200)") @@ -89,10 +81,9 @@ public class UploadTaskSanityTests extends RestTest dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); TaskModel taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); - restClient.authenticateUser(userModel1); - tasksApi.updateTask(taskModel) - .assertThat().field("id").is(taskModel.getId()) + restTaskModel = restClient.authenticateUser(userModel1).withWorkflowAPI().usingTask(taskModel).updateTask(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) .and().field("message").is(taskModel.getMessage()); - tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } -} +} \ No newline at end of file From 74ec5c59a1717c2a2e92d8fe5b474f62f4ae9c19 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Wed, 16 Nov 2016 18:13:27 +0200 Subject: [PATCH 0559/1491] Refactor Test: GetTaskCandidatesTests.java --- .../tasks/GetTaskCandidatesTests.java | 31 +++++++------------ 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCandidatesTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCandidatesTests.java index 8c61cf2f9..9832f5818 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCandidatesTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCandidatesTests.java @@ -2,7 +2,7 @@ package org.alfresco.rest.workflow.tasks; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; -import org.alfresco.rest.requests.RestTasksApi; +import org.alfresco.rest.model.RestCandidateModelsCollection; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.GroupModel; import org.alfresco.utility.model.SiteModel; @@ -11,7 +11,6 @@ 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.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -24,14 +23,12 @@ import org.testng.annotations.Test; @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) public class GetTaskCandidatesTests extends RestTest { - @Autowired - RestTasksApi tasksApi; - private UserModel userModel, user, userModel1, userModel2; private SiteModel siteModel; private FileModel fileModel; private TaskModel taskModel; private GroupModel group; + private RestCandidateModelsCollection candidateModels; @BeforeClass(alwaysRun=true) public void dataPreparation() throws Exception @@ -45,39 +42,35 @@ public class GetTaskCandidatesTests extends RestTest group = dataGroup.createRandomGroup(); dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); taskModel = dataWorkflow.usingUser(user).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); - tasksApi.useRestClient(restClient); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify that admin gets task candidates") public void getTaskCandidatesByAdmin() throws Exception { - restClient.authenticateUser(dataUser.getAdminUser()); - tasksApi.getTaskCandidates(taskModel) - .assertThat().entriesListContains("candidateType", "group") + candidateModels = restClient.authenticateUser(dataUser.getAdminUser()).withWorkflowAPI().usingTask(taskModel).getTaskCandidates(); + restClient.assertStatusCodeIs(HttpStatus.OK); + candidateModels.assertThat().entriesListContains("candidateType", "group") .and().entriesListContains("candidateId", String.format("GROUP_%s", group.getGroupIdentifier())); - tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify that user that started the process gets task candidates") public void getTaskCandidatesByUserWhoStartedProcess() throws Exception { - restClient.authenticateUser(user); - tasksApi.getTaskCandidates(taskModel) - .assertThat().entriesListContains("candidateType", "group") + candidateModels = restClient.authenticateUser(user).withWorkflowAPI().usingTask(taskModel).getTaskCandidates(); + restClient.assertStatusCodeIs(HttpStatus.OK); + candidateModels.assertThat().entriesListContains("candidateType", "group") .and().entriesListContains("candidateId", String.format("GROUP_%s", group.getGroupIdentifier())); - tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify that user from the assighed group to the process gets task candidates") public void getTaskCandidatesByCandidateUser() throws Exception { - restClient.authenticateUser(userModel1); - tasksApi.getTaskCandidates(taskModel) - .assertThat().entriesListContains("candidateType", "group") + candidateModels = restClient.authenticateUser(userModel1).withWorkflowAPI().usingTask(taskModel).getTaskCandidates(); + restClient.assertStatusCodeIs(HttpStatus.OK); + candidateModels.assertThat().entriesListContains("candidateType", "group") .and().entriesListContains("candidateId", String.format("GROUP_%s", group.getGroupIdentifier())); - tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } -} +} \ No newline at end of file From 7723d8b9df6ff687d21c6d6cd371c7dd869412e0 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Wed, 16 Nov 2016 18:23:10 +0200 Subject: [PATCH 0560/1491] Refactor Test: GetTaskItemsSanityTests.java --- .../tasks/GetTaskItemsSanityTests.java | 61 +++++++++---------- 1 file changed, 29 insertions(+), 32 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskItemsSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskItemsSanityTests.java index 42f007849..3cd75aaa3 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskItemsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskItemsSanityTests.java @@ -3,8 +3,7 @@ package org.alfresco.rest.workflow.tasks; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestItemModel; -import org.alfresco.rest.requests.RestTasksApi; -import org.alfresco.rest.requests.RestTenantApi; +import org.alfresco.rest.model.RestItemModelsCollection; import org.alfresco.utility.Utility; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; @@ -13,7 +12,6 @@ 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.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -21,17 +19,12 @@ import org.testng.annotations.Test; @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) public class GetTaskItemsSanityTests extends RestTest { - @Autowired - RestTasksApi tasksApi; - - @Autowired - RestTenantApi tenantApi; - private UserModel userModel, userWhoStartsTask, assignee, adminTenantUser, tenantUser, tenantUserAssignee; private SiteModel siteModel; private FileModel fileModel, document1; private TaskModel taskModel; private RestItemModel taskItem; + private RestItemModelsCollection itemModels; @BeforeClass(alwaysRun=true) public void dataPreparation() throws Exception @@ -42,7 +35,6 @@ public class GetTaskItemsSanityTests extends RestTest userWhoStartsTask = dataUser.createRandomTestUser(); assignee = dataUser.createRandomTestUser(); taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); - tasksApi.useRestClient(restClient); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, @@ -51,14 +43,15 @@ public class GetTaskItemsSanityTests extends RestTest { restClient.authenticateUser(userWhoStartsTask); document1 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - taskItem = tasksApi.addTaskItem(taskModel, document1); + taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document1); Utility.checkObjectIsInitialized(taskItem, "taskItem"); - tasksApi.getTaskItems(taskModel).assertThat() - .entriesListIsNotEmpty().and() - .entriesListContains("id", taskItem.getId()).and() - .entriesListContains("name", document1.getName()); - - tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + + itemModels = restClient.withWorkflowAPI().usingTask(taskModel).getTaskItems(); + restClient.assertStatusCodeIs(HttpStatus.OK); + itemModels.assertThat() + .entriesListIsNotEmpty().and() + .entriesListContains("id", taskItem.getId()).and() + .entriesListContains("name", document1.getName()); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, @@ -67,12 +60,15 @@ public class GetTaskItemsSanityTests extends RestTest { restClient.authenticateUser(assignee); document1 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - taskItem = tasksApi.addTaskItem(taskModel, document1); - tasksApi.getTaskItems(taskModel).assertThat() - .entriesListIsNotEmpty().and() - .entriesListContains("id", taskItem.getId()).and() - .entriesListContains("name", document1.getName()); - tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document1); + + itemModels = restClient.withWorkflowAPI().usingTask(taskModel).getTaskItems(); + restClient.assertStatusCodeIs(HttpStatus.OK); + itemModels.assertThat() + .entriesListIsNotEmpty().and() + .entriesListContains("id", taskItem.getId()).and() + .entriesListContains("name", document1.getName()); + } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, @@ -84,8 +80,7 @@ public class GetTaskItemsSanityTests extends RestTest restClient.authenticateUser(adminuser); adminTenantUser = UserModel.getAdminTenantUser(); - tenantApi.useRestClient(restClient); - tenantApi.createTenant(adminTenantUser); + restClient.usingTenant().createTenant(adminTenantUser); tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); @@ -94,11 +89,13 @@ public class GetTaskItemsSanityTests extends RestTest dataWorkflow.usingUser(tenantUser).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(tenantUserAssignee); document1 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - taskItem = tasksApi.addTaskItem(taskModel, document1); - tasksApi.getTaskItems(taskModel).assertThat() - .entriesListIsNotEmpty().and() - .entriesListContains("id", taskItem.getId()).and() - .entriesListContains("name", document1.getName()); - tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document1); + + itemModels = restClient.withWorkflowAPI().usingTask(taskModel).getTaskItems(); + restClient.assertStatusCodeIs(HttpStatus.OK); + itemModels.assertThat() + .entriesListIsNotEmpty().and() + .entriesListContains("id", taskItem.getId()).and() + .entriesListContains("name", document1.getName()); } -} +} \ No newline at end of file From 11a8ffaf0c00c4ce91ff12921f8c5a40bcfc3162 Mon Sep 17 00:00:00 2001 From: cagache Date: Thu, 17 Nov 2016 09:46:06 +0200 Subject: [PATCH 0561/1491] update tests based on new refactored DSL --- .../deployments/GetDeploymentSanityTests.java | 43 ++++++++----------- 1 file changed, 17 insertions(+), 26 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentSanityTests.java index da372a6f9..907bc7361 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentSanityTests.java @@ -1,65 +1,56 @@ package org.alfresco.rest.workflow.deployments; -import org.alfresco.rest.RestWorkflowTest; +import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestDeploymentModel; -import org.alfresco.rest.requests.RestDeploymentsApi; import org.alfresco.utility.model.ErrorModel; 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.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; /** * Tests for REST API call GET "/deployments/{deploymentId}" - * + * * @author Cristina Axinte * */ @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.SANITY }) -public class GetDeploymentSanityTests extends RestWorkflowTest +public class GetDeploymentSanityTests extends RestTest { - @Autowired - private RestDeploymentsApi deploymentsApi; - private UserModel adminUser; private UserModel anotherUser; - private RestDeploymentModel deployment; + private RestDeploymentModel expectedDeployment, actualDeployment; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception { adminUser = dataUser.getAdminUser(); anotherUser = dataUser.createRandomTestUser(); - - deploymentsApi.useRestClient(restClient); - restClient.authenticateUser(adminUser); - deployment = deploymentsApi.getDeployments().getOneRandomEntry().onModel(); + + expectedDeployment = restClient.authenticateUser(adminUser).withWorkflowAPI().getDeployments().getOneRandomEntry().onModel(); } - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.SANITY, description = "Verify admin user gets a non-network deployment using REST API and status code is OK (200)") public void adminGetsNonNetworkDeploymentWithSuccess() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(adminUser); - deploymentsApi.getDeployment(deployment) - .assertThat().field("deployedAt").isNotEmpty() - .and().field("name").is(deployment.getName()) - .and().field("id").equals(deployment.getId()); - deploymentsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + actualDeployment = restClient.authenticateUser(adminUser).withWorkflowAPI().usingDeployment(expectedDeployment).getDeployment(); + restClient.assertStatusCodeIs(HttpStatus.OK); + actualDeployment.assertThat().field("deployedAt").isNotEmpty() + .and().field("name").is(expectedDeployment.getName()) + .and().field("id").equals(expectedDeployment.getId()); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.SANITY, description = "Verify non admin user is forbidden to get a non-network deployment using REST API (403)") public void nonAdminIsForbiddenToGetNonNetworkDeployment() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(anotherUser); - deploymentsApi.getDeployment(deployment); - deploymentsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN) + { + restClient.authenticateUser(anotherUser).withWorkflowAPI().usingDeployment(expectedDeployment).getDeployment(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } } From 45ebd4ef3f8908285017eebe5c0c043a2fb44d0e Mon Sep 17 00:00:00 2001 From: cagache Date: Thu, 17 Nov 2016 10:26:21 +0200 Subject: [PATCH 0562/1491] update tests based on new refactored DSL --- .../GetDeploymentsSanityTests.java | 33 +++++++------------ 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsSanityTests.java index cf6147f64..ca63d4b78 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsSanityTests.java @@ -1,15 +1,12 @@ package org.alfresco.rest.workflow.deployments; -import org.alfresco.rest.RestWorkflowTest; +import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.requests.RestDeploymentsApi; -import org.alfresco.rest.requests.RestTenantApi; -import org.alfresco.utility.data.DataUser; +import org.alfresco.rest.model.RestDeploymentModelsCollection; 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.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -18,16 +15,10 @@ import org.testng.annotations.Test; * Created by Claudia Agache on 10/4/2016. */ @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.SANITY}) -public class GetDeploymentsSanityTests extends RestWorkflowTest +public class GetDeploymentsSanityTests extends RestTest { - @Autowired - RestTenantApi tenantApi; - @Autowired - private DataUser dataUser; - @Autowired - private RestDeploymentsApi deploymentsApi; - private UserModel adminUserModel, adminTenantUser; + private RestDeploymentModelsCollection deployments; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception @@ -35,16 +26,15 @@ public class GetDeploymentsSanityTests extends RestWorkflowTest adminUserModel = dataUser.getAdminUser(); adminTenantUser = UserModel.getAdminTenantUser(); restClient.authenticateUser(adminUserModel); - deploymentsApi.useRestClient(restClient); } @TestRail(section = { TestGroup.REST_API, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets non-network deployments using REST API and status code is OK (200)") public void getNonNetworkDeploymentsWithAdmin() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(adminUserModel); - deploymentsApi.getDeployments().assertThat().entriesListIsNotEmpty(); - deploymentsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + deployments = restClient.authenticateUser(adminUserModel).withWorkflowAPI().getDeployments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + deployments.assertThat().entriesListIsNotEmpty(); } @TestRail(section = { TestGroup.REST_API, @@ -52,10 +42,9 @@ public class GetDeploymentsSanityTests extends RestWorkflowTest @Test(groups = { TestGroup.NETWORKS }) public void getNetworkDeploymentsWithAdmin() throws JsonToModelConversionException, Exception { - tenantApi.useRestClient(restClient); - tenantApi.createTenant(adminTenantUser); - restClient.authenticateUser(adminTenantUser); - deploymentsApi.getDeployments().assertThat().entriesListIsNotEmpty(); - deploymentsApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.usingTenant().createTenant(adminTenantUser); + deployments = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getDeployments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + deployments.assertThat().entriesListIsNotEmpty(); } } From 549f4773915383d9c9ee8ff561cd898257f4d808 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Thu, 17 Nov 2016 10:46:45 +0200 Subject: [PATCH 0563/1491] Refactor Test: GetFavoriteSanityTests --- .../favorites/GetFavoriteSanityTests.java | 59 +++++++++++-------- 1 file changed, 36 insertions(+), 23 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java index 1612c41cd..bd03cc2b5 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java @@ -3,6 +3,9 @@ package org.alfresco.rest.favorites; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestPersonFavoritesModel; +import org.alfresco.rest.model.RestPersonFavoritesModelsCollection; +import org.alfresco.rest.model.RestSiteModelsCollection; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.ErrorModel; @@ -26,6 +29,8 @@ public class GetFavoriteSanityTests extends RestTest private FolderModel folderModel; private FileModel fileModel; private ListUserWithRoles usersWithRoles; + private RestSiteModelsCollection restSiteModelsCollection; + private RestPersonFavoritesModelsCollection restPersonFavoritesModelsCollection; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception @@ -47,27 +52,34 @@ public class GetFavoriteSanityTests extends RestTest TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets favorite site with Rest API and status code is 200") public void adminIsAbleToRetrieveFavoritesSite() throws JsonToModelConversionException, Exception { - restClient.withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel).and().field("targetGuid").is(siteModel.getGuid()); - restClient.withCoreAPI().usingUser(adminUserModel).getFavoriteSites().and().entriesListContains("guid",siteModel.getGuid()); + restClient.withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); + + restSiteModelsCollection = restClient.withCoreAPI().usingUser(adminUserModel).getFavoriteSites(); restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteModelsCollection.and().entriesListContains("guid",siteModel.getGuid()); } @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets favorite folder with Rest API and status code is 200") public void adminIsAbleToRetrieveFavoritesFolder() throws JsonToModelConversionException, Exception { - restClient.withCoreAPI().usingUser(adminUserModel).addFolderToFavorites(folderModel).and().field("targetGuid").is(folderModel.getNodeRef()); - restClient.withCoreAPI().usingUser(adminUserModel).getFavorites().and().entriesListContains("targetGuid", folderModel.getNodeRef()); + restClient.withCoreAPI().usingUser(adminUserModel).addFolderToFavorites(folderModel); + + restPersonFavoritesModelsCollection = restClient.withCoreAPI().usingUser(adminUserModel).getFavorites(); restClient.assertStatusCodeIs(HttpStatus.OK); + restPersonFavoritesModelsCollection.and().entriesListContains("targetGuid", folderModel.getNodeRef()); + } @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets favorite file with Rest API and status code is 200") public void adminIsAbleToRetrieveFavoritesFile() throws JsonToModelConversionException, Exception - { + { restClient.withCoreAPI().usingUser(adminUserModel).addFileToFavorites(fileModel); - restClient.withCoreAPI().usingUser(adminUserModel).getFavorites().and().entriesListContains("targetGuid", fileModel.getNodeRef()); + + restPersonFavoritesModelsCollection = restClient.withCoreAPI().usingUser(adminUserModel).getFavorites(); restClient.assertStatusCodeIs(HttpStatus.OK); + restPersonFavoritesModelsCollection.and().entriesListContains("targetGuid", fileModel.getNodeRefWithoutVersion()); } @TestRail(section = { TestGroup.REST_API, @@ -76,8 +88,10 @@ public class GetFavoriteSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - restClient.withCoreAPI().usingAuthUser().getFavoriteSites().and().entriesListContains("guid",siteModel.getGuid()); + + restSiteModelsCollection = restClient.withCoreAPI().usingAuthUser().getFavoriteSites(); restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteModelsCollection.and().entriesListContains("guid",siteModel.getGuid()); } @TestRail(section = { TestGroup.REST_API, @@ -85,10 +99,11 @@ public class GetFavoriteSanityTests extends RestTest public void collaboratorIsAbleToRetrieveFavorites() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI() - .usingAuthUser().addSiteToFavorites(siteModel); - restClient.withCoreAPI().usingAuthUser().getFavoriteSites().and().entriesListContains("guid",siteModel.getGuid()); + .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + + restSiteModelsCollection = restClient.withCoreAPI().usingAuthUser().getFavoriteSites(); restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteModelsCollection.and().entriesListContains("guid",siteModel.getGuid()); } @TestRail(section = { TestGroup.REST_API, @@ -97,8 +112,10 @@ public class GetFavoriteSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - restClient.withCoreAPI().usingAuthUser().getFavoriteSites().and().entriesListContains("guid",siteModel.getGuid()); + + restSiteModelsCollection = restClient.withCoreAPI().usingAuthUser().getFavoriteSites(); restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteModelsCollection.and().entriesListContains("guid",siteModel.getGuid()); } @TestRail(section = { TestGroup.REST_API, @@ -107,8 +124,10 @@ public class GetFavoriteSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - restClient.withCoreAPI().usingAuthUser().getFavoriteSites().and().entriesListContains("guid",siteModel.getGuid()); + + restSiteModelsCollection = restClient.withCoreAPI().usingAuthUser().getFavoriteSites(); restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteModelsCollection.and().entriesListContains("guid",siteModel.getGuid()); } @TestRail(section = { TestGroup.REST_API, @@ -128,9 +147,7 @@ public class GetFavoriteSanityTests extends RestTest public void userIsNotAbleToRetrieveFavoritesOfAdminUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .withCoreAPI() - .usingUser(adminUserModel) - .getFavorite(siteModel.getGuid()); + .withCoreAPI().usingUser(adminUserModel).getFavorite(siteModel.getGuid()); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, adminUserModel.getUsername())); @@ -140,10 +157,8 @@ public class GetFavoriteSanityTests extends RestTest TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify admin user doesn't get favorite site of another user with Rest API and status code is 404") public void adminIsNotAbleToRetrieveFavoritesOfAnotherUser() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(adminUserModel) - .withCoreAPI() - .usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .getFavorite(siteModel.getGuid()); + restClient.authenticateUser(adminUserModel).withCoreAPI() + .usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).getFavorite(siteModel.getGuid()); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator).getUsername())); @@ -156,10 +171,8 @@ public class GetFavoriteSanityTests extends RestTest { UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); siteManager.setPassword("wrongPassword"); - restClient.authenticateUser(siteManager) - .withCoreAPI() - .usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .getFavorite(siteModel.getGuid()); + restClient.authenticateUser(siteManager).withCoreAPI() + .usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).getFavorite(siteModel.getGuid()); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } From b57a2e4bb9b295a9dd53df2d8da59dd6fe5fcb82 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Thu, 17 Nov 2016 10:49:46 +0200 Subject: [PATCH 0564/1491] Deleted import --- .../java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java | 1 - 1 file changed, 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java index bd03cc2b5..3bd440fd2 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java @@ -3,7 +3,6 @@ package org.alfresco.rest.favorites; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestPersonFavoritesModel; import org.alfresco.rest.model.RestPersonFavoritesModelsCollection; import org.alfresco.rest.model.RestSiteModelsCollection; import org.alfresco.utility.constants.UserRole; From 190ec662413f51060b7860222d7b8417ad78b560 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Thu, 17 Nov 2016 11:02:40 +0200 Subject: [PATCH 0565/1491] Refactor Test: tasAddTaskItemSanityTests.java --- .../tasks/AddTaskItemSanityTests.java | 38 ++++++++----------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemSanityTests.java index a0dfd86c4..c76e94c26 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemSanityTests.java @@ -4,8 +4,6 @@ import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestItemModel; -import org.alfresco.rest.requests.RestTasksApi; -import org.alfresco.rest.requests.RestTenantApi; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TaskModel; @@ -14,7 +12,6 @@ import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -22,12 +19,6 @@ import org.testng.annotations.Test; @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) public class AddTaskItemSanityTests extends RestTest { - @Autowired - RestTasksApi tasksApi; - - @Autowired - RestTenantApi tenantApi; - private UserModel userModel, userWhoStartsTask, assigneeUser, adminTenantUser, tenantUser, tenantUserAssignee;; private SiteModel siteModel; private FileModel fileModel, document2, document3, document4; @@ -44,8 +35,6 @@ public class AddTaskItemSanityTests extends RestTest userWhoStartsTask = dataUser.createRandomTestUser(); assigneeUser = dataUser.createRandomTestUser(); taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - - tasksApi.useRestClient(restClient); } @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, @@ -55,7 +44,9 @@ public class AddTaskItemSanityTests extends RestTest UserModel adminUser = dataUser.getAdminUser(); restClient.authenticateUser(adminUser); document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - taskItem = tasksApi.addTaskItem(taskModel, document2); + + taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); taskItem.assertThat().field("createdAt").is(taskItem.getCreatedAt()) .assertThat().field("size").is(taskItem.getSize()) @@ -65,18 +56,20 @@ public class AddTaskItemSanityTests extends RestTest .assertThat().field("modifiedBy").is(taskItem.getModifiedBy()) .assertThat().field("id").is(taskItem.getId()) .assertThat().field("mimeType").is(taskItem.getMimeType()); - tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } @Bug(id = "MNT-16966") @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, - description = "Verify that in case task item exists request ") + description = "Verify that in case task item exists the request fails") public void createTaskItemThatAlreadyExists() throws Exception { UserModel adminUser = dataUser.getAdminUser(); restClient.authenticateUser(adminUser); document3 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - taskItem = tasksApi.addTaskItem(taskModel, document3); + + taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document3); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + taskItem.assertThat().field("createdAt").is(taskItem.getCreatedAt()) .assertThat().field("size").is(taskItem.getSize()) .and().field("createdBy").is(taskItem.getCreatedBy()) @@ -85,8 +78,9 @@ public class AddTaskItemSanityTests extends RestTest .and().field("modifiedBy").is(taskItem.getModifiedBy()) .and().field("id").is(taskItem.getId()) .and().field("mimeType").is(taskItem.getMimeType()); - taskItem = tasksApi.addTaskItem(taskModel, document3); - tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.BAD_REQUEST); + + taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document3); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); } @Test(groups = { TestGroup.NETWORKS }) @@ -98,8 +92,7 @@ public class AddTaskItemSanityTests extends RestTest restClient.authenticateUser(adminuser); adminTenantUser = UserModel.getAdminTenantUser(); - tenantApi.useRestClient(restClient); - tenantApi.createTenant(adminTenantUser); + restClient.usingTenant().createTenant(adminTenantUser); tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); @@ -108,7 +101,9 @@ public class AddTaskItemSanityTests extends RestTest dataWorkflow.usingUser(tenantUser).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(tenantUserAssignee); document4 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - taskItem = tasksApi.addTaskItem(taskModel, document4); + + taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document4); + restClient.assertStatusCodeIs(HttpStatus.CREATED); taskItem.assertThat().field("createdAt").is(taskItem.getCreatedAt()) .and().field("size").is(taskItem.getSize()) .and().field("createdBy").is(taskItem.getCreatedBy()) @@ -117,6 +112,5 @@ public class AddTaskItemSanityTests extends RestTest .and().field("modifiedBy").is(taskItem.getModifiedBy()) .and().field("id").is(taskItem.getId()) .and().field("mimeType").is(taskItem.getMimeType()); - tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } -} +} \ No newline at end of file From 52eb4a7e685f17b175eb0269b12a862b8d01fe07 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Thu, 17 Nov 2016 11:11:24 +0200 Subject: [PATCH 0566/1491] Refactor Test: AddTaskVariablesSanityTests.java --- .../tasks/AddTaskVariablesSanityTests.java | 37 +++++++++---------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesSanityTests.java index 64ea942bb..e607b62a8 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesSanityTests.java @@ -3,7 +3,6 @@ package org.alfresco.rest.workflow.tasks; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestVariableModel; -import org.alfresco.rest.requests.RestTasksApi; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TaskModel; @@ -11,7 +10,6 @@ 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.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -22,14 +20,12 @@ import org.testng.annotations.Test; @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) public class AddTaskVariablesSanityTests extends RestTest { - @Autowired - RestTasksApi tasksApi; - private UserModel userModel, userWhoStartsTask; private SiteModel siteModel; private FileModel fileModel; private UserModel assigneeUser; private TaskModel taskModel; + private RestVariableModel restVariablemodel; @BeforeClass(alwaysRun=true) public void dataPreparation() throws Exception @@ -40,8 +36,6 @@ public class AddTaskVariablesSanityTests extends RestTest userWhoStartsTask = dataUser.createRandomTestUser(); assigneeUser = dataUser.createRandomTestUser(); taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - - tasksApi.useRestClient(restClient); } @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, @@ -51,13 +45,14 @@ public class AddTaskVariablesSanityTests extends RestTest UserModel adminUser = dataUser.getAdminUser(); restClient.authenticateUser(adminUser); RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - tasksApi.addTaskVariable(taskModel, variableModel) - .assertThat() + + restVariablemodel = restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restVariablemodel.assertThat() .field("scope").is(variableModel.getScope()) .and().field("name").is(variableModel.getName()) .and().field("value").is(variableModel.getValue()) .and().field("type").is(variableModel.getType()); - tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, @@ -66,13 +61,15 @@ public class AddTaskVariablesSanityTests extends RestTest { restClient.authenticateUser(assigneeUser); RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - tasksApi.addTaskVariable(taskModel, variableModel) - .assertThat().field("scope").is(variableModel.getScope()) + + restVariablemodel = restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restVariablemodel.assertThat().field("scope").is(variableModel.getScope()) .and().field("name").is(variableModel.getName()) .and().field("value").is(variableModel.getValue()) .and().field("type").is(variableModel.getType()); - tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); - tasksApi.getTaskVariables(taskModel).assertThat().entriesListContains("name", variableModel.getName()); + + restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables().assertThat().entriesListContains("name", variableModel.getName()); } @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, @@ -81,12 +78,13 @@ public class AddTaskVariablesSanityTests extends RestTest { restClient.authenticateUser(userWhoStartsTask); RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - tasksApi.addTaskVariable(taskModel, variableModel) - .assertThat().field("scope").is(variableModel.getScope()) + + restVariablemodel = restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restVariablemodel.assertThat().field("scope").is(variableModel.getScope()) .and().field("name").is(variableModel.getName()) .and().field("value").is(variableModel.getValue()) .and().field("type").is(variableModel.getType()); - tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED); } @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, @@ -96,7 +94,8 @@ public class AddTaskVariablesSanityTests extends RestTest userModel = dataUser.createRandomTestUser(); restClient.authenticateUser(userModel); RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - tasksApi.addTaskVariable(taskModel, variableModel); - tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); + + restVariablemodel = restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); } } From 1bcd04b001ab83b9494d3a9a0c84a3c01a71f52e Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Thu, 17 Nov 2016 11:56:01 +0200 Subject: [PATCH 0567/1491] Refactor test: GetFavoritesSanityTests --- .../favorites/GetFavoritesSanityTests.java | 92 +++++++++---------- 1 file changed, 42 insertions(+), 50 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java index cf64d0956..fccb89730 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java @@ -3,6 +3,7 @@ package org.alfresco.rest.favorites; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestPersonFavoritesModelsCollection; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.ErrorModel; @@ -29,6 +30,7 @@ public class GetFavoritesSanityTests extends RestTest private FolderModel firstFolderModel; private FolderModel secondFolderModel; private ListUserWithRoles usersWithRoles; + private RestPersonFavoritesModelsCollection restPersonFavoritesModelsCollection; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception @@ -41,7 +43,6 @@ public class GetFavoritesSanityTests extends RestTest secondFolderModel = dataContent.usingUser(adminUserModel).usingSite(firstSiteModel).createFolder(); firstFileModel = dataContent.usingUser(adminUserModel).usingResource(firstFolderModel).createContent(DocumentType.TEXT_PLAIN); secondFileModel = dataContent.usingUser(adminUserModel).usingResource(firstFolderModel).createContent(DocumentType.TEXT_PLAIN); - firstSiteModel.setGuid(restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(firstSiteModel).getSite().getGuidWithoutVersion()); secondSiteModel.setGuid(restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(secondSiteModel).getSite().getGuidWithoutVersion()); @@ -56,11 +57,11 @@ public class GetFavoritesSanityTests extends RestTest { restClient.withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(firstSiteModel); restClient.withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(secondSiteModel); - restClient.withCoreAPI() - .usingAuthUser().where().targetSiteExist().getFavorites() - .assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) - .and().entriesListContains("targetGuid", secondSiteModel.getGuid()); + + restPersonFavoritesModelsCollection = restClient.withCoreAPI().usingAuthUser().where().targetSiteExist().getFavorites(); restClient.assertStatusCodeIs(HttpStatus.OK); + restPersonFavoritesModelsCollection.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) + .and().entriesListContains("targetGuid", secondSiteModel.getGuid()); } @TestRail(section = { TestGroup.REST_API, @@ -69,11 +70,11 @@ public class GetFavoritesSanityTests extends RestTest { restClient.withCoreAPI().usingUser(adminUserModel).addFolderToFavorites(firstFolderModel); restClient.withCoreAPI().usingUser(adminUserModel).addFolderToFavorites(secondFolderModel); - restClient.withCoreAPI() - .usingAuthUser().where().targetFolderExist().getFavorites() - .assertThat().entriesListContains("targetGuid", firstFolderModel.getNodeRef()) - .and().entriesListContains("targetGuid", secondFolderModel.getNodeRef()); + + restPersonFavoritesModelsCollection = restClient.withCoreAPI().usingAuthUser().where().targetFolderExist().getFavorites(); restClient.assertStatusCodeIs(HttpStatus.OK); + restPersonFavoritesModelsCollection.assertThat().entriesListContains("targetGuid", firstFolderModel.getNodeRef()) + .and().entriesListContains("targetGuid", secondFolderModel.getNodeRef()); } @TestRail(section = { TestGroup.REST_API, @@ -82,11 +83,11 @@ public class GetFavoritesSanityTests extends RestTest { restClient.withCoreAPI().usingUser(adminUserModel).addFileToFavorites(firstFileModel); restClient.withCoreAPI().usingUser(adminUserModel).addFileToFavorites(secondFileModel); - restClient.withCoreAPI() - .usingAuthUser().where().targetFileExist().getFavorites() - .assertThat().entriesListContains("targetGuid", firstFileModel.getNodeRefWithoutVersion()) - .and().entriesListContains("targetGuid", secondFileModel.getNodeRefWithoutVersion()); + + restPersonFavoritesModelsCollection = restClient.withCoreAPI().usingAuthUser().where().targetFileExist().getFavorites(); restClient.assertStatusCodeIs(HttpStatus.OK); + restPersonFavoritesModelsCollection.assertThat().entriesListContains("targetGuid", firstFileModel.getNodeRefWithoutVersion()) + .and().entriesListContains("targetGuid", secondFileModel.getNodeRefWithoutVersion()); } @TestRail(section = { TestGroup.REST_API, @@ -94,14 +95,13 @@ public class GetFavoritesSanityTests extends RestTest public void managerIsAbleToRetrieveFavorites() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI() - .usingAuthUser().addSiteToFavorites(firstSiteModel); + restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(secondSiteModel); - restClient.withCoreAPI() - .usingAuthUser().where().targetSiteExist().getFavorites() - .assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) - .assertThat().entriesListContains("targetGuid", secondSiteModel.getGuid()); + + restPersonFavoritesModelsCollection = restClient.withCoreAPI().usingAuthUser().where().targetSiteExist().getFavorites(); restClient.assertStatusCodeIs(HttpStatus.OK); + restPersonFavoritesModelsCollection.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) + .assertThat().entriesListContains("targetGuid", secondSiteModel.getGuid()); } @TestRail(section = { TestGroup.REST_API, @@ -109,15 +109,13 @@ public class GetFavoritesSanityTests extends RestTest public void collaboratorIsAbleToRetrieveFavorites() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI() - .usingAuthUser().addSiteToFavorites(firstSiteModel); - restClient.withCoreAPI() - .usingAuthUser().addSiteToFavorites(secondSiteModel); - restClient.withCoreAPI() - .usingAuthUser().where().targetSiteExist().getFavorites() - .assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) - .and().entriesListContains("targetGuid", secondSiteModel.getGuid()); + .withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); + restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(secondSiteModel); + + restPersonFavoritesModelsCollection = restClient.withCoreAPI().usingAuthUser().where().targetSiteExist().getFavorites(); restClient.assertStatusCodeIs(HttpStatus.OK); + restPersonFavoritesModelsCollection.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) + .and().entriesListContains("targetGuid", secondSiteModel.getGuid()); } @TestRail(section = { TestGroup.REST_API, @@ -125,14 +123,13 @@ public class GetFavoritesSanityTests extends RestTest public void contributorIsAbleToRetrieveFavorites() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) - .withCoreAPI() - .usingAuthUser().addSiteToFavorites(firstSiteModel); + .withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(secondSiteModel); - restClient.withCoreAPI() - .usingAuthUser().where().targetSiteExist().getFavorites() - .assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()).and() - .entriesListContains("targetGuid", secondSiteModel.getGuid()); + + restPersonFavoritesModelsCollection = restClient.withCoreAPI().usingAuthUser().where().targetSiteExist().getFavorites(); restClient.assertStatusCodeIs(HttpStatus.OK); + restPersonFavoritesModelsCollection.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()).and() + .entriesListContains("targetGuid", secondSiteModel.getGuid()); } @TestRail(section = { TestGroup.REST_API, @@ -140,14 +137,13 @@ public class GetFavoritesSanityTests extends RestTest public void consumerIsAbleToRetrieveFavorites() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .withCoreAPI() - .usingAuthUser().addSiteToFavorites(firstSiteModel); + .withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(secondSiteModel); - restClient.withCoreAPI() - .usingAuthUser().where().targetSiteExist().getFavorites() - .assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) - .assertThat().entriesListContains("targetGuid", secondSiteModel.getGuid()); + + restPersonFavoritesModelsCollection = restClient.withCoreAPI().usingAuthUser().where().targetSiteExist().getFavorites(); restClient.assertStatusCodeIs(HttpStatus.OK); + restPersonFavoritesModelsCollection.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) + .assertThat().entriesListContains("targetGuid", secondSiteModel.getGuid()); } @TestRail(section = { TestGroup.REST_API, @@ -155,8 +151,8 @@ public class GetFavoritesSanityTests extends RestTest public void userIsNotAbleToRetrieveFavoritesOfAnotherUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .withCoreAPI() - .usingAuthUser().where().targetSiteExist().getFavorites(); + .withCoreAPI().usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).where() + .targetSiteExist().getFavorites(); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator).getUsername())); } @@ -165,9 +161,8 @@ public class GetFavoritesSanityTests extends RestTest TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify user doesn't have permission to get favorites of admin user with Rest API and status code is 200") public void userIsNotAbleToRetrieveFavoritesOfAdminUser() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .withCoreAPI() - .usingAuthUser().where().targetSiteExist().getFavorites(); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI() + .usingUser(adminUserModel).where().targetSiteExist().getFavorites(); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, adminUserModel.getUsername())); } @@ -176,9 +171,8 @@ public class GetFavoritesSanityTests extends RestTest TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify admin user doesn't have permission to get favorites of another user with Rest API and status code is 200") public void adminIsNotAbleToRetrieveFavoritesOfAnotherUser() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(adminUserModel) - .withCoreAPI() - .usingAuthUser().where().targetSiteExist().getFavorites(); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .where().targetSiteExist().getFavorites(); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator).getUsername())); } @@ -190,9 +184,7 @@ public class GetFavoritesSanityTests extends RestTest { UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); siteManager.setPassword("wrongPassword"); - restClient.authenticateUser(siteManager) - .withCoreAPI() - .usingAuthUser().addSiteToFavorites(firstSiteModel); + restClient.authenticateUser(siteManager).withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(secondSiteModel); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } From ee8a0d3b20ee1769c1f07a0856b88c3b9e9429d1 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Thu, 17 Nov 2016 11:56:53 +0200 Subject: [PATCH 0568/1491] Refactor Test: DeleteTaskVariableSanityTests.java --- .../tasks/DeleteTaskVariableSanityTests.java | 24 ++++++++----------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/DeleteTaskVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/DeleteTaskVariableSanityTests.java index 4b8ad77e7..8ef87934f 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/DeleteTaskVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/DeleteTaskVariableSanityTests.java @@ -3,7 +3,6 @@ package org.alfresco.rest.workflow.tasks; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestVariableModel; -import org.alfresco.rest.requests.RestTasksApi; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TaskModel; @@ -11,7 +10,6 @@ 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.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -22,9 +20,6 @@ import org.testng.annotations.Test; @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) public class DeleteTaskVariableSanityTests extends RestTest { - @Autowired - RestTasksApi tasksApi; - private UserModel userModel, adminUser; private SiteModel siteModel; private FileModel fileModel; @@ -40,8 +35,6 @@ public class DeleteTaskVariableSanityTests extends RestTest fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); assigneeUser = dataUser.createRandomTestUser(); taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - - tasksApi.useRestClient(restClient); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, @@ -50,10 +43,12 @@ public class DeleteTaskVariableSanityTests extends RestTest { restClient.authenticateUser(adminUser); RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - tasksApi.addTaskVariable(taskModel, variableModel); - tasksApi.deleteTaskVariable(taskModel, variableModel); - tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); - tasksApi.getTaskVariables(taskModel).assertThat().entriesListDoesNotContain("name", variableModel.getName()); + + restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables() + .assertThat().entriesListDoesNotContain("name", variableModel.getName()); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, @@ -62,9 +57,10 @@ public class DeleteTaskVariableSanityTests extends RestTest { restClient.authenticateUser(adminUser); RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - tasksApi.updateTaskVariable(taskModel, variableModel); + + restClient.withWorkflowAPI().usingTask(taskModel).updateTaskVariable(variableModel); taskModel.setId("incorrectTaskId"); - tasksApi.deleteTaskVariable(taskModel, variableModel); - tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); } } From ea1279c9647ca8f8f80579504d84712e36097095 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Thu, 17 Nov 2016 13:28:30 +0200 Subject: [PATCH 0569/1491] Refactor test: AddFavoritesSanityTests --- .../favorites/AddFavoritesSanityTests.java | 36 +++++++++---------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesSanityTests.java index 3ef0648b8..b6a547ccf 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesSanityTests.java @@ -2,6 +2,7 @@ package org.alfresco.rest.favorites; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestPersonFavoritesModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.DataUser.ListUserWithRoles; @@ -25,6 +26,7 @@ public class AddFavoritesSanityTests extends RestTest private UserModel adminUserModel; private SiteModel siteModel; private ListUserWithRoles usersWithRoles; + private RestPersonFavoritesModel restPersonFavoritesModel; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception @@ -42,10 +44,9 @@ public class AddFavoritesSanityTests extends RestTest description = "Verify Admin user add site to favorites with Rest API and status code is 201") public void adminIsAbleToAddToFavorites() throws Exception { - restClient.withCoreAPI().usingAuthUser() - .addSiteToFavorites(siteModel) - .assertThat().field("targetGuid").is(siteModel.getGuid()); + restPersonFavoritesModel = restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); + restPersonFavoritesModel.assertThat().field("targetGuid").is(siteModel.getGuid()); } @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, @@ -53,11 +54,10 @@ public class AddFavoritesSanityTests extends RestTest description = "Verify Manager user add site to favorites with Rest API and status code is 201") public void managerIsAbleToAddToFavorites() throws Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingAuthUser() - .addSiteToFavorites(siteModel) - .assertThat().field("targetGuid").is(siteModel.getGuid()); + restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI() + .usingAuthUser().addSiteToFavorites(siteModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); + restPersonFavoritesModel.assertThat().field("targetGuid").is(siteModel.getGuid()); } @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, @@ -65,10 +65,10 @@ public class AddFavoritesSanityTests extends RestTest description = "Verify Collaborator user add site to favorites with Rest API and status code is 201") public void collaboratorIsAbleToAddToFavorites() throws Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingAuthUser() - .addSiteToFavorites(siteModel).and().field("targetGuid").is(siteModel.getGuid()); + restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); + restPersonFavoritesModel.and().field("targetGuid").is(siteModel.getGuid()); } @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, @@ -76,10 +76,10 @@ public class AddFavoritesSanityTests extends RestTest description = "Verify Contributor user add site to favorites with Rest API and status code is 201") public void contributorIsAbleToAddToFavorites() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) - .withCoreAPI().usingAuthUser() - .addSiteToFavorites(siteModel).and().field("targetGuid").is(siteModel.getGuid()); + restPersonFavoritesModel= restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) + .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); + restPersonFavoritesModel.and().field("targetGuid").is(siteModel.getGuid()); } @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, @@ -87,10 +87,10 @@ public class AddFavoritesSanityTests extends RestTest description = "Verify Consumer user add site to favorites with Rest API and status code is 201") public void consumerIsAbleToAddToFavorites() throws Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .withCoreAPI().usingAuthUser() - .addSiteToFavorites(siteModel).and().field("targetGuid").is(siteModel.getGuid()); + restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); + restPersonFavoritesModel.and().field("targetGuid").is(siteModel.getGuid()); } @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, @@ -101,9 +101,7 @@ public class AddFavoritesSanityTests extends RestTest { UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); siteManager.setPassword("wrongPassword"); - restClient.authenticateUser(siteManager) - .withCoreAPI().usingAuthUser() - .addSiteToFavorites(siteModel); + restClient.authenticateUser(siteManager).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } From 0b43968d9a25f7811a07a12b8123c5cdc4c14944 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Thu, 17 Nov 2016 13:35:20 +0200 Subject: [PATCH 0570/1491] Refactor Test: GetTaskVariablesSanityTests.java --- .../tasks/GetTaskVariablesSanityTests.java | 34 +++++++++---------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskVariablesSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskVariablesSanityTests.java index 1db7f624c..33aabaffc 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskVariablesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskVariablesSanityTests.java @@ -2,7 +2,7 @@ package org.alfresco.rest.workflow.tasks; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; -import org.alfresco.rest.requests.RestTasksApi; +import org.alfresco.rest.model.RestVariableModelsCollection; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TaskModel; @@ -10,7 +10,6 @@ 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.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -21,14 +20,12 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) public class GetTaskVariablesSanityTests extends RestTest { - @Autowired - RestTasksApi tasksApi; - private UserModel userModel, userWhoStartsTask, assignee; private SiteModel siteModel; private FileModel fileModel; private TaskModel taskModel; - + private RestVariableModelsCollection variableModels; + @BeforeClass(alwaysRun=true) public void dataPreparation() throws Exception { @@ -38,8 +35,6 @@ public class GetTaskVariablesSanityTests extends RestTest userWhoStartsTask = dataUser.createRandomTestUser(); assignee = dataUser.createRandomTestUser(); taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); - - tasksApi.useRestClient(restClient); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, @@ -47,8 +42,9 @@ public class GetTaskVariablesSanityTests extends RestTest public void getTaskVariablesByUserWhoStartedProcess() throws Exception { restClient.authenticateUser(userWhoStartsTask); - tasksApi.getTaskVariables(taskModel).assertThat().entriesListIsNotEmpty(); - tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + variableModels = restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables(); + restClient.assertStatusCodeIs(HttpStatus.OK); + variableModels.assertThat().entriesListIsNotEmpty(); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, @@ -56,8 +52,9 @@ public class GetTaskVariablesSanityTests extends RestTest public void getTaskVariablesByUserInvolvedInProcess() throws Exception { restClient.authenticateUser(assignee); - tasksApi.getTaskVariables(taskModel).assertThat().entriesListIsNotEmpty(); - tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + variableModels = restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables(); + restClient.assertStatusCodeIs(HttpStatus.OK); + variableModels.assertThat().entriesListIsNotEmpty(); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, @@ -67,18 +64,19 @@ public class GetTaskVariablesSanityTests extends RestTest UserModel randomUser = dataUser.createRandomTestUser(); restClient.authenticateUser(randomUser); - tasksApi.getTaskVariables(taskModel); - tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); + restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, - description = "Verify that admin gets task variables") + description = "Verify that admin is able to task variables") public void getTaskVariablesUsingAdmin() throws Exception { UserModel adminUser = dataUser.getAdminUser(); restClient.authenticateUser(adminUser); - tasksApi.getTaskVariables(taskModel).assertThat().entriesListIsNotEmpty(); - tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + variableModels = restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables(); + restClient.assertStatusCodeIs(HttpStatus.OK); + variableModels.assertThat().entriesListIsNotEmpty(); } -} +} \ No newline at end of file From 4435e2c2479689b19a1113816ea56de0457367ab Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Thu, 17 Nov 2016 13:50:24 +0200 Subject: [PATCH 0571/1491] Refactor Test: RemoveTaskItemSanityTests.java --- .../tasks/RemoveTaskItemSanityTests.java | 32 ++++++++----------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/RemoveTaskItemSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/RemoveTaskItemSanityTests.java index e778ac097..fd5c62223 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/RemoveTaskItemSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/RemoveTaskItemSanityTests.java @@ -3,7 +3,6 @@ package org.alfresco.rest.workflow.tasks; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestItemModel; -import org.alfresco.rest.requests.RestTasksApi; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TaskModel; @@ -11,7 +10,6 @@ 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.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -22,10 +20,6 @@ import org.testng.annotations.Test; @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) public class RemoveTaskItemSanityTests extends RestTest { - @Autowired - RestTasksApi tasksApi; - - private UserModel adminUser, userModel, userWhoStartsTask, assigneeUser; private SiteModel siteModel; private FileModel fileModel, document2; @@ -43,8 +37,6 @@ public class RemoveTaskItemSanityTests extends RestTest userWhoStartsTask = dataUser.createRandomTestUser(); assigneeUser = dataUser.createRandomTestUser(); taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - - tasksApi.useRestClient(restClient); } @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, @@ -53,10 +45,11 @@ public class RemoveTaskItemSanityTests extends RestTest { restClient.authenticateUser(adminUser); document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - taskItem = tasksApi.addTaskItem(taskModel, document2); - tasksApi.deleteTaskItem(taskModel, taskItem); - tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT); - tasksApi.getTaskItems(taskModel) + + taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingTask(taskModel).getTaskItems() .assertThat().entriesListDoesNotContain("id", taskItem.getId()).and() .entriesListDoesNotContain("name", document2.getName()); } @@ -67,10 +60,11 @@ public class RemoveTaskItemSanityTests extends RestTest { restClient.authenticateUser(adminUser); document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - taskItem = tasksApi.addTaskItem(taskModel, document2); + + taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); taskModel.setId("invalidTaskId"); - tasksApi.deleteTaskItem(taskModel, taskItem); - tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); } @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, @@ -79,9 +73,9 @@ public class RemoveTaskItemSanityTests extends RestTest { restClient.authenticateUser(adminUser); document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - taskItem = tasksApi.addTaskItem(taskModel, document2); + taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); taskItem.setId("incorrectItemId"); - tasksApi.deleteTaskItem(taskModel, taskItem); - tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND); + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); } -} +} \ No newline at end of file From 3cd885f206709a0741aff9290c20740c413f5a38 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Thu, 17 Nov 2016 14:19:42 +0200 Subject: [PATCH 0572/1491] Refactor test: DeleteFavoritesSanityTests --- .../favorites/DeleteFavoritesSanityTests.java | 74 +++++-------------- 1 file changed, 19 insertions(+), 55 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoritesSanityTests.java index d1efa1042..29ec22bf1 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoritesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoritesSanityTests.java @@ -38,11 +38,9 @@ public class DeleteFavoritesSanityTests extends RestTest TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Admin user deletes site from favorites with Rest API and status code is 204") public void adminIsAbleToDeleteFavorites() throws JsonToModelConversionException, Exception { - restClient.withCoreAPI().usingUser(adminUserModel) - .addSiteToFavorites(siteModel).assertThat().field("targetGuid").is(siteModel.getGuid()); + restClient.withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); - restClient.withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel) - .assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel).assertStatusCodeIs(HttpStatus.NO_CONTENT); restClient.withCoreAPI().usingAuthUser().getFavorites().assertThat().entriesListDoesNotContain("targetGuid", siteModel.getGuid()); } @@ -51,14 +49,9 @@ public class DeleteFavoritesSanityTests extends RestTest public void managerIsAbleToDeleteFavorites() throws JsonToModelConversionException, Exception { UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); - restClient.authenticateUser(siteManager) - .withCoreAPI() - .usingAuthUser() - .addSiteToFavorites(siteModel).and().field("targetGuid").is(siteModel.getGuid()); + restClient.authenticateUser(siteManager).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - restClient.withCoreAPI().usingAuthUser() - .deleteSiteFromFavorites(siteModel) - .assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel).assertStatusCodeIs(HttpStatus.NO_CONTENT); restClient.withCoreAPI().usingAuthUser().getFavorites().assertThat().entriesListDoesNotContain("targetGuid", siteModel.getGuid()); } @@ -67,13 +60,9 @@ public class DeleteFavoritesSanityTests extends RestTest public void collaboratorIsAbleToDeleteFavorites() throws JsonToModelConversionException, Exception { UserModel siteCollaborator = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); - restClient.authenticateUser(siteCollaborator) - .withCoreAPI() - .usingAuthUser() - .addSiteToFavorites(siteModel).and().field("targetGuid").is(siteModel.getGuid()); - restClient.withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel) - .assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.authenticateUser(siteCollaborator).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + restClient.withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel).assertStatusCodeIs(HttpStatus.NO_CONTENT); restClient.withCoreAPI().usingAuthUser().getFavorites().assertThat().entriesListDoesNotContain("targetGuid", siteModel.getGuid()); } @@ -82,13 +71,9 @@ public class DeleteFavoritesSanityTests extends RestTest public void contributorIsAbleToDeleteFavorites() throws JsonToModelConversionException, Exception { UserModel siteContributor = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); - restClient.authenticateUser(siteContributor) - .withCoreAPI() - .usingAuthUser() - .addSiteToFavorites(siteModel).and().field("targetGuid").is(siteModel.getGuid()); - restClient.withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel) - .assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.authenticateUser(siteContributor).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + restClient.withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel).assertStatusCodeIs(HttpStatus.NO_CONTENT); restClient.withCoreAPI().usingAuthUser().getFavorites().assertThat().entriesListDoesNotContain("targetGuid", siteModel.getGuid()); } @@ -97,12 +82,9 @@ public class DeleteFavoritesSanityTests extends RestTest public void consumerIsAbleToDeleteFavorites() throws JsonToModelConversionException, Exception { UserModel siteConsumer = usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer); - restClient.authenticateUser(siteConsumer) - .withCoreAPI() - .usingAuthUser() - .addSiteToFavorites(siteModel).and().field("targetGuid").is(siteModel.getGuid()); - restClient.withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel).assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.authenticateUser(siteConsumer).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + restClient.withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel).assertStatusCodeIs(HttpStatus.NO_CONTENT); restClient.withCoreAPI().usingAuthUser().getFavorites().assertThat().entriesListDoesNotContain("targetGuid", siteModel.getGuid()); } @@ -112,14 +94,9 @@ public class DeleteFavoritesSanityTests extends RestTest public void userIsNotAbleToDeleteFavoritesOfAnotherUser() throws JsonToModelConversionException, Exception { UserModel siteCollaborator = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); - restClient.authenticateUser(siteCollaborator) - .withCoreAPI() - .usingAuthUser() - .addSiteToFavorites(siteModel).and().field("targetGuid").is(siteModel.getGuid()); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .withCoreAPI() - .usingAuthUser() - .deleteSiteFromFavorites(siteModel) + restClient.authenticateUser(siteCollaborator).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI() + .usingAuthUser().deleteSiteFromFavorites(siteModel) .assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @@ -127,16 +104,10 @@ public class DeleteFavoritesSanityTests extends RestTest @Bug(id="MNT-16557") public void userIsNotAbleToDeleteFavoritesOfAdminUser() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(adminUserModel) - .withCoreAPI() - .usingAuthUser() - .addSiteToFavorites(siteModel) - .and().field("targetGuid").is(siteModel.getGuid()); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .withCoreAPI() - .usingAuthUser() - .deleteSiteFromFavorites(siteModel) + .withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel) .assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @@ -145,14 +116,10 @@ public class DeleteFavoritesSanityTests extends RestTest public void adminIsNotAbleToDeleteFavoritesOfAnotherUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI() - .usingAuthUser() - .addSiteToFavorites(siteModel).and().field("targetGuid").is(siteModel.getGuid()); + .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); restClient.authenticateUser(adminUserModel) - .withCoreAPI() - .usingAuthUser() - .deleteSiteFromFavorites(siteModel) + .withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel) .assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @@ -162,10 +129,7 @@ public class DeleteFavoritesSanityTests extends RestTest { UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); siteManager.setPassword("wrongPassword"); - restClient.authenticateUser(siteManager) - .withCoreAPI() - .usingAuthUser() - .deleteSiteFromFavorites(siteModel) - .assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.authenticateUser(siteManager).withCoreAPI().usingAuthUser() + .deleteSiteFromFavorites(siteModel).assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } From bf31b2a5158c60997de782376fe8de5825e769e3 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Thu, 17 Nov 2016 14:28:43 +0200 Subject: [PATCH 0573/1491] Refactor Test: GetTaskFormModelSanityTests.java --- .../tasks/GetTaskFormModelSanityTests.java | 24 +++++++------------ 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelSanityTests.java index 0db7c300a..6735f7f40 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelSanityTests.java @@ -3,7 +3,6 @@ package org.alfresco.rest.workflow.tasks; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestFormModelsCollection; -import org.alfresco.rest.requests.RestTasksApi; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TaskModel; @@ -11,7 +10,6 @@ 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.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -22,13 +20,12 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) public class GetTaskFormModelSanityTests extends RestTest { - @Autowired RestTasksApi tasksApi; - UserModel userModel; SiteModel siteModel; FileModel fileModel; TaskModel taskModel; - + RestFormModelsCollection returnedCollection; + @BeforeClass(alwaysRun=true) public void dataPreparation() throws Exception { @@ -36,8 +33,6 @@ public class GetTaskFormModelSanityTests extends RestTest siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); fileModel = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(userModel); - - tasksApi.useRestClient(restClient); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, @@ -45,9 +40,8 @@ public class GetTaskFormModelSanityTests extends RestTest public void adminGetsTaskFormModels() throws Exception { restClient.authenticateUser(dataUser.getAdminUser()); - RestFormModelsCollection returnedCollection = tasksApi.getTaskFormModel(taskModel); - - tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + returnedCollection = restClient.withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); + restClient.assertStatusCodeIs(HttpStatus.OK); returnedCollection.assertThat().entriesListIsNotEmpty(); String[] qualifiedNames = { @@ -68,7 +62,7 @@ public class GetTaskFormModelSanityTests extends RestTest returnedCollection.assertThat().entriesListContains("qualifiedName", formQualifiedName); } - tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, @@ -76,10 +70,8 @@ public class GetTaskFormModelSanityTests extends RestTest public void involvedUserGetsTaskFormModels() throws Exception { restClient.authenticateUser(userModel); - RestFormModelsCollection returnedCollection = tasksApi.getTaskFormModel(taskModel); - - returnedCollection.assertThat().entriesListIsNotEmpty(); - tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + returnedCollection = restClient.withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); + restClient.assertStatusCodeIs(HttpStatus.OK); returnedCollection.assertThat().entriesListIsNotEmpty(); } -} +} \ No newline at end of file From 6cdf1c64a43e82867b496c12100cf11a59243c0b Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Thu, 17 Nov 2016 14:41:31 +0200 Subject: [PATCH 0574/1491] Refactor Test: UpdateTaskVariableSanityTests.java --- .../tasks/UpdateTaskVariableSanityTests.java | 54 ++++++++----------- 1 file changed, 23 insertions(+), 31 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskVariableSanityTests.java index 0e493a3e4..35d09eb6a 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskVariableSanityTests.java @@ -3,8 +3,6 @@ package org.alfresco.rest.workflow.tasks; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestVariableModel; -import org.alfresco.rest.requests.RestTasksApi; -import org.alfresco.rest.requests.RestTenantApi; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TaskModel; @@ -12,7 +10,6 @@ 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.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -23,65 +20,62 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) public class UpdateTaskVariableSanityTests extends RestTest { - @Autowired - RestTasksApi tasksApi; - - @Autowired - RestTenantApi tenantApi; - private UserModel userModel; + private UserModel adminUser; private SiteModel siteModel; private FileModel fileModel; private UserModel assigneeUser; private TaskModel taskModel, tenantTask; - private UserModel adminTenantUser, tenantUser, tenantUserAssignee; private RestVariableModel taskVariable; + private RestVariableModel variableModel; @BeforeClass(alwaysRun=true) public void dataPreparation() throws Exception { + adminUser = dataUser.getAdminUser(); userModel = dataUser.createRandomTestUser(); siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); assigneeUser = dataUser.createRandomTestUser(); taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - - tasksApi.useRestClient(restClient); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Create non-existing task variable") public void createTaskVariable() throws Exception { - UserModel adminUser = dataUser.getAdminUser(); restClient.authenticateUser(adminUser); - RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - taskVariable = tasksApi.updateTaskVariable(taskModel, variableModel); + variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + + taskVariable = restClient.withWorkflowAPI().usingTask(taskModel).updateTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.OK); taskVariable.assertThat().field("scope").is(taskVariable.getScope()) .and().field("name").is(taskVariable.getName()) .and().field("type").is(taskVariable.getType()) .and().field("value").is(taskVariable.getValue()); - tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Update existing task variable") - public void updateTaskVariable() throws Exception + public void updateExistingTaskVariable() throws Exception { - UserModel adminUser = dataUser.getAdminUser(); restClient.authenticateUser(adminUser); - RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - taskVariable = tasksApi.updateTaskVariable(taskModel, variableModel); - taskVariable.and().field("scope").is(taskVariable.getScope()) + variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + + taskVariable = restClient.withWorkflowAPI().usingTask(taskModel).updateTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + taskVariable.assertThat().field("scope").is(taskVariable.getScope()) .and().field("name").is(taskVariable.getName()) .and().field("type").is(taskVariable.getType()) .and().field("value").is(taskVariable.getValue()); + variableModel.setValue("updatedValue"); - taskVariable = tasksApi.updateTaskVariable(taskModel, variableModel).and().field("value").is("updatedValue"); - tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + taskVariable = restClient.withWorkflowAPI().usingTask(taskModel).updateTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + taskVariable.assertThat().field("value").is("updatedValue"); } @Test(groups = {TestGroup.NETWORKS }) @@ -89,12 +83,10 @@ public class UpdateTaskVariableSanityTests extends RestTest description = "Update existing task variable by admin in the same network") public void updateTaskVariableByAdminInSameNetwork() throws Exception { - UserModel adminUser = dataUser.getAdminUser(); restClient.authenticateUser(adminUser); adminTenantUser = UserModel.getAdminTenantUser(); - tenantApi.useRestClient(restClient); - tenantApi.createTenant(adminTenantUser); + restClient.usingTenant().createTenant(adminTenantUser); tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); @@ -102,16 +94,16 @@ public class UpdateTaskVariableSanityTests extends RestTest siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); tenantTask = dataWorkflow.usingUser(tenantUser).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(tenantUserAssignee); - RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - taskVariable = tasksApi.updateTaskVariable(tenantTask, variableModel); - + variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + taskVariable = restClient.withWorkflowAPI().usingTask(tenantTask).updateTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.OK); taskVariable.assertThat().field("scope").is(taskVariable.getScope()) .and().field("name").is(taskVariable.getName()) .and().field("type").is(taskVariable.getType()) .and().field("value").is(taskVariable.getValue()); variableModel.setValue("updatedValue"); - taskVariable = tasksApi.updateTaskVariable(taskModel, variableModel).and().field("value").is("updatedValue"); - tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK); + taskVariable = restClient.withWorkflowAPI().usingTask(taskModel).updateTaskVariable(variableModel).and().field("value").is("updatedValue"); + restClient.assertStatusCodeIs(HttpStatus.OK); } } \ No newline at end of file From 8f4dfa09b984579ba13a04cab044732a3c734a18 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Thu, 17 Nov 2016 14:42:43 +0200 Subject: [PATCH 0575/1491] Refactor Test: AddFavoriteSiteSanityTests --- .../people/AddFavoriteSiteSanityTests.java | 42 ++++++------------- 1 file changed, 13 insertions(+), 29 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteSanityTests.java index 407eddb34..f0fe52649 100644 --- a/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteSanityTests.java @@ -1,6 +1,7 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestFavoriteSiteModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; @@ -18,6 +19,7 @@ public class AddFavoriteSiteSanityTests extends RestTest UserModel userModel; SiteModel siteModel; UserModel searchedUser; + private RestFavoriteSiteModel restFavoriteSiteModel; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception @@ -32,12 +34,9 @@ public class AddFavoriteSiteSanityTests extends RestTest UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); - restClient.authenticateUser(managerUser) - .withCoreAPI() - .usingUser(managerUser) - .addFavoriteSite(siteModel) - .assertThat().field("id").is(siteModel.getId()); + restFavoriteSiteModel = restClient.authenticateUser(managerUser).withCoreAPI().usingUser(managerUser).addFavoriteSite(siteModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); + restFavoriteSiteModel.assertThat().field("id").is(siteModel.getId()); restClient.withCoreAPI().usingUser(managerUser).addFavoriteSite(siteModel); restClient.assertStatusCodeIs(HttpStatus.CONFLICT); @@ -50,12 +49,9 @@ public class AddFavoriteSiteSanityTests extends RestTest UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(collaboratorUser, siteModel, UserRole.SiteCollaborator); - restClient.authenticateUser(collaboratorUser) - .withCoreAPI() - .usingAuthUser() - .addFavoriteSite(siteModel) - .assertThat().field("id").is(siteModel.getId()); + restFavoriteSiteModel = restClient.authenticateUser(collaboratorUser).withCoreAPI().usingAuthUser().addFavoriteSite(siteModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); + restFavoriteSiteModel.assertThat().field("id").is(siteModel.getId()); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify contributor user add a favorite site with Rest API and response is successful (201)") @@ -64,12 +60,9 @@ public class AddFavoriteSiteSanityTests extends RestTest UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(contributorUser, siteModel, UserRole.SiteContributor); - restClient.authenticateUser(contributorUser) - .withCoreAPI() - .usingAuthUser() - .addFavoriteSite(siteModel) - .assertThat().field("id").is(siteModel.getId()); + restFavoriteSiteModel = restClient.authenticateUser(contributorUser).withCoreAPI().usingAuthUser().addFavoriteSite(siteModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); + restFavoriteSiteModel.assertThat().field("id").is(siteModel.getId()); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify consumer user add a favorite site with Rest API and response is successful (201)") @@ -78,12 +71,9 @@ public class AddFavoriteSiteSanityTests extends RestTest UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel, UserRole.SiteConsumer); - restClient.authenticateUser(consumerUser) - .withCoreAPI() - .usingAuthUser() - .addFavoriteSite(siteModel) - .assertThat().field("id").is(siteModel.getId()); + restFavoriteSiteModel = restClient.authenticateUser(consumerUser).withCoreAPI().usingAuthUser().addFavoriteSite(siteModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); + restFavoriteSiteModel.assertThat().field("id").is(siteModel.getId()); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify admin user add a favorite site with Rest API and response is successful (201)") @@ -91,12 +81,9 @@ public class AddFavoriteSiteSanityTests extends RestTest { UserModel adminUser = dataUser.getAdminUser(); - restClient.authenticateUser(adminUser) - .withCoreAPI() - .usingAuthUser() - .addFavoriteSite(siteModel) - .assertThat().field("id").is(siteModel.getId()); + restFavoriteSiteModel = restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().addFavoriteSite(siteModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); + restFavoriteSiteModel.assertThat().field("id").is(siteModel.getId()); } @Bug(id = "MNT-16904") @@ -107,10 +94,7 @@ public class AddFavoriteSiteSanityTests extends RestTest dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); managerUser.setPassword("newpassword"); - restClient.authenticateUser(managerUser) - .withCoreAPI() - .usingAuthUser() - .addFavoriteSite(siteModel); + restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().addFavoriteSite(siteModel); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } From a4c527bcac42d6a626ed193539782e57abd92cdd Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Thu, 17 Nov 2016 14:57:04 +0200 Subject: [PATCH 0576/1491] Refactor Test: GetFavoriteSiteSanityTests --- .../people/GetFavoriteSiteSanityTests.java | 45 ++++++------------- 1 file changed, 14 insertions(+), 31 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java index c3506f6d8..36e899141 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java @@ -1,6 +1,7 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestSiteModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.model.ErrorModel; import org.alfresco.utility.model.SiteModel; @@ -26,6 +27,7 @@ public class GetFavoriteSiteSanityTests extends RestTest SiteModel siteModel1; SiteModel siteModel2; UserModel searchedUser; + private RestSiteModel restSiteModel; @BeforeClass(alwaysRun=true) public void dataPreparation() throws Exception @@ -45,12 +47,9 @@ public class GetFavoriteSiteSanityTests extends RestTest dataSite.usingUser(managerUser).usingSite(siteModel1).addSiteToFavorites(); dataSite.usingUser(managerUser).usingSite(siteModel2).addSiteToFavorites(); - restClient.authenticateUser(managerUser) - .withCoreAPI() - .usingAuthUser().getFavoriteSite(siteModel1) - .assertThat().field("id").is(siteModel1.getId()) - .and().field("title").isNotNull(); + restSiteModel = restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().getFavoriteSite(siteModel1); restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteModel.assertThat().field("id").is(siteModel1.getId()).and().field("title").isNotNull(); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -63,12 +62,9 @@ public class GetFavoriteSiteSanityTests extends RestTest dataSite.usingUser(collaboratorUser).usingSite(siteModel1).addSiteToFavorites(); dataSite.usingUser(collaboratorUser).usingSite(siteModel2).addSiteToFavorites(); - restClient.authenticateUser(collaboratorUser) - .withCoreAPI() - .usingAuthUser().getFavoriteSite(siteModel1) - .assertThat().field("id").is(siteModel1.getId()) - .and().field("title").isNotNull(); + restSiteModel = restClient.authenticateUser(collaboratorUser).withCoreAPI().usingAuthUser().getFavoriteSite(siteModel1); restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteModel.assertThat().field("id").is(siteModel1.getId()).and().field("title").isNotNull(); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -81,12 +77,9 @@ public class GetFavoriteSiteSanityTests extends RestTest dataSite.usingUser(contributorUser).usingSite(siteModel1).addSiteToFavorites(); dataSite.usingUser(contributorUser).usingSite(siteModel2).addSiteToFavorites(); - restClient.authenticateUser(contributorUser) - .withCoreAPI() - .usingAuthUser().getFavoriteSite(siteModel1) - .assertThat().field("id").is(siteModel1.getId()) - .and().field("title").isNotNull(); + restSiteModel = restClient.authenticateUser(contributorUser).withCoreAPI().usingAuthUser().getFavoriteSite(siteModel1); restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteModel.assertThat().field("id").is(siteModel1.getId()).and().field("title").isNotNull(); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -99,12 +92,9 @@ public class GetFavoriteSiteSanityTests extends RestTest dataSite.usingUser(consumerUser).usingSite(siteModel1).addSiteToFavorites(); dataSite.usingUser(consumerUser).usingSite(siteModel2).addSiteToFavorites(); - restClient.authenticateUser(consumerUser) - .withCoreAPI() - .usingAuthUser().getFavoriteSite(siteModel1) - .assertThat().field("id").is(siteModel1.getId()) - .and().field("title").isNotNull(); + restSiteModel = restClient.authenticateUser(consumerUser).withCoreAPI().usingAuthUser().getFavoriteSite(siteModel1); restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteModel.assertThat().field("id").is(siteModel1.getId()).and().field("title").isNotNull(); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -117,12 +107,9 @@ public class GetFavoriteSiteSanityTests extends RestTest dataSite.usingUser(anyUser).usingSite(siteModel1).addSiteToFavorites(); dataSite.usingUser(anyUser).usingSite(siteModel2).addSiteToFavorites(); - restClient.authenticateUser(adminUset) - .withCoreAPI() - .usingAuthUser().getFavoriteSite(siteModel1) - .assertThat().field("id").is(siteModel1.getId()) - .and().field("title").isNotNull(); + restSiteModel = restClient.authenticateUser(adminUset).withCoreAPI().usingUser(anyUser).getFavoriteSite(siteModel1); restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteModel.assertThat().field("id").is(siteModel1.getId()).and().field("title").isNotNull(); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -135,9 +122,7 @@ public class GetFavoriteSiteSanityTests extends RestTest dataSite.usingUser(managerUser).usingSite(siteModel1).addSiteToFavorites(); dataSite.usingUser(managerUser).usingSite(siteModel2).addSiteToFavorites(); - restClient.authenticateUser(managerUser) - .withCoreAPI() - .usingUser(userModel).getFavoriteSite(siteModel1); + restClient.authenticateUser(managerUser).withCoreAPI().usingUser(userModel).getFavoriteSite(siteModel1); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @@ -153,9 +138,7 @@ public class GetFavoriteSiteSanityTests extends RestTest dataSite.usingUser(managerUser).usingSite(siteModel2).addSiteToFavorites(); managerUser.setPassword("newpassword"); - restClient.authenticateUser(managerUser) - .withCoreAPI() - .usingAuthUser().getFavoriteSite(siteModel1); + restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().getFavoriteSite(siteModel1); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } From 3bf8a6a6aed1e93e19505d01520f1877ba92a464 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Thu, 17 Nov 2016 15:02:47 +0200 Subject: [PATCH 0577/1491] Refactor Test: DeleteFavoriteSiteSanityTests --- .../people/DeleteFavoriteSiteSanityTests.java | 32 +++++-------------- 1 file changed, 8 insertions(+), 24 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java index 611ab31eb..bdacbb87a 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java @@ -41,10 +41,7 @@ public class DeleteFavoriteSiteSanityTests extends RestTest dataSite.usingUser(managerUser).usingSite(siteModel1).addSiteToFavorites(); dataSite.usingUser(managerUser).usingSite(siteModel2).addSiteToFavorites(); - restClient.authenticateUser(managerUser) - .withCoreAPI() - .usingAuthUser().removeFavoriteSite(siteModel1); - + restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel1); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } @@ -58,9 +55,7 @@ public class DeleteFavoriteSiteSanityTests extends RestTest dataSite.usingUser(collaboratorUser).usingSite(siteModel1).addSiteToFavorites(); dataSite.usingUser(collaboratorUser).usingSite(siteModel2).addSiteToFavorites(); - restClient.authenticateUser(collaboratorUser) - .withCoreAPI() - .usingAuthUser().removeFavoriteSite(siteModel1); + restClient.authenticateUser(collaboratorUser).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel1); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } @@ -74,9 +69,7 @@ public class DeleteFavoriteSiteSanityTests extends RestTest dataSite.usingUser(contributorUser).usingSite(siteModel1).addSiteToFavorites(); dataSite.usingUser(contributorUser).usingSite(siteModel2).addSiteToFavorites(); - restClient.authenticateUser(contributorUser) - .withCoreAPI() - .usingAuthUser().removeFavoriteSite(siteModel1); + restClient.authenticateUser(contributorUser).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel1); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } @@ -90,9 +83,7 @@ public class DeleteFavoriteSiteSanityTests extends RestTest dataSite.usingUser(consumerUser).usingSite(siteModel1).addSiteToFavorites(); dataSite.usingUser(consumerUser).usingSite(siteModel2).addSiteToFavorites(); - restClient.authenticateUser(consumerUser) - .withCoreAPI() - .usingAuthUser().removeFavoriteSite(siteModel1); + restClient.authenticateUser(consumerUser).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel1); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } @@ -106,9 +97,7 @@ public class DeleteFavoriteSiteSanityTests extends RestTest dataSite.usingUser(anyUser).usingSite(siteModel1).addSiteToFavorites(); dataSite.usingUser(anyUser).usingSite(siteModel2).addSiteToFavorites(); - restClient.authenticateUser(adminUser) - .withCoreAPI() - .usingAuthUser().removeFavoriteSite(siteModel1); + restClient.authenticateUser(adminUser).withCoreAPI().usingUser(anyUser).removeFavoriteSite(siteModel1); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } @@ -122,11 +111,8 @@ public class DeleteFavoriteSiteSanityTests extends RestTest dataSite.usingUser(anotherUser).usingSite(siteModel1).addSiteToFavorites(); dataSite.usingUser(anotherUser).usingSite(siteModel2).addSiteToFavorites(); - restClient.authenticateUser(userAuth) - .withCoreAPI() - .usingUser(anotherUser).removeFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + restClient.authenticateUser(userAuth).withCoreAPI().usingUser(anotherUser).removeFavoriteSite(siteModel1); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -140,9 +126,7 @@ public class DeleteFavoriteSiteSanityTests extends RestTest dataSite.usingUser(managerUser).usingSite(siteModel2).addSiteToFavorites(); managerUser.setPassword("newpassword"); - restClient.authenticateUser(managerUser) - .withCoreAPI() - .usingAuthUser().removeFavoriteSite(siteModel1); + restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel1); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } From ba8325d6f76ab91ade2b9f644f19d6a221c4c638 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Thu, 17 Nov 2016 15:05:15 +0200 Subject: [PATCH 0578/1491] Refactor Test: AddTagSanityTests.java --- .../alfresco/rest/tags/AddTagSanityTests.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java index d075ccd38..fb0d65ac8 100644 --- a/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java @@ -10,6 +10,7 @@ import org.alfresco.utility.data.RandomData; import org.alfresco.utility.model.ErrorModel; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; @@ -31,6 +32,7 @@ public class AddTagSanityTests extends RestTest private SiteModel siteModel; private DataUser.ListUserWithRoles usersWithRoles; private String tagValue; + private RestTagModel returnedModel; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception @@ -53,7 +55,7 @@ public class AddTagSanityTests extends RestTest public void adminIsAbleToAddTag() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); - RestTagModel returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue); + returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue); restClient.assertStatusCodeIs(HttpStatus.CREATED); returnedModel.assertThat().field("tag").is(tagValue) .and().field("id").isNotEmpty(); @@ -64,7 +66,7 @@ public class AddTagSanityTests extends RestTest public void managerIsAbleToAddTag() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - RestTagModel returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue); + returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue); restClient.assertStatusCodeIs(HttpStatus.CREATED); returnedModel.assertThat().field("tag").is(tagValue) .and().field("id").isNotEmpty(); @@ -75,7 +77,7 @@ public class AddTagSanityTests extends RestTest public void collaboratorIsAbleToAddTag() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - RestTagModel returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue); + returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue); restClient.assertStatusCodeIs(HttpStatus.CREATED); returnedModel.assertThat().field("tag").is(tagValue) .and().field("id").isNotEmpty(); @@ -97,7 +99,7 @@ public class AddTagSanityTests extends RestTest userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); restClient.authenticateUser(userModel); FileModel contributorDoc = dataContent.usingSite(siteModel).usingUser(userModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - RestTagModel returnedModel = restClient.withCoreAPI().usingResource(contributorDoc).addTag(tagValue); + returnedModel = restClient.withCoreAPI().usingResource(contributorDoc).addTag(tagValue); restClient.assertStatusCodeIs(HttpStatus.CREATED); returnedModel.assertThat().field("id").isNotEmpty() .and().field("tag").is(tagValue); @@ -113,14 +115,14 @@ public class AddTagSanityTests extends RestTest } @TestRail(section = { TestGroup.REST_API, - TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Manager user gets status code 401 if authentication call fails") + TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user gets status code 401 if authentication call fails") @Bug(id="MNT-16904") - public void managerIsNotAbleToAddTagIfAuthenticationFails() throws JsonToModelConversionException, Exception + public void userIsNotAbleToAddTagIfAuthenticationFails() throws JsonToModelConversionException, Exception { UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); siteManager.setPassword("wrongPassword"); restClient.authenticateUser(siteManager); restClient.withCoreAPI().usingResource(document).addTag("tagUnauthorized"); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(ErrorModel.AUTHENTICATION_FAILED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); } } \ No newline at end of file From efa5b281fe2ab717d8435372ad2f1b41394ea82c Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Thu, 17 Nov 2016 15:11:39 +0200 Subject: [PATCH 0579/1491] Refactor test: GetFavoriteSitesSanityTests --- .../people/GetFavoriteSitesSanityTests.java | 40 ++++++------------- 1 file changed, 13 insertions(+), 27 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java index 7a7affa26..b5d2412ac 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java @@ -1,6 +1,7 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestSiteModelsCollection; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.model.ErrorModel; import org.alfresco.utility.model.SiteModel; @@ -19,6 +20,7 @@ public class GetFavoriteSitesSanityTests extends RestTest UserModel userModel; SiteModel siteModel; UserModel searchedUser; + private RestSiteModelsCollection restSiteModelsCollection; @BeforeClass(alwaysRun=true) public void dataPreparation() throws Exception @@ -37,9 +39,7 @@ public class GetFavoriteSitesSanityTests extends RestTest UserModel anotherUser = dataUser.usingAdmin().createRandomTestUser(); dataSite.usingUser(anotherUser).usingSite(siteModel).addSiteToFavorites(); - restClient.authenticateUser(managerUser) - .withCoreAPI() - .usingUser(anotherUser).getFavoriteSites(); + restClient.authenticateUser(managerUser).withCoreAPI().usingUser(anotherUser).getFavoriteSites(); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @@ -54,9 +54,7 @@ public class GetFavoriteSitesSanityTests extends RestTest dataUser.usingUser(userModel).addUserToSite(contributorUser, siteModel, UserRole.SiteContributor); dataSite.usingUser(contributorUser).usingSite(siteModel).addSiteToFavorites(); - restClient.authenticateUser(collaboratorUser) - .withCoreAPI() - .usingUser(contributorUser).getFavoriteSites(); + restClient.authenticateUser(collaboratorUser).withCoreAPI().usingUser(contributorUser).getFavoriteSites(); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @@ -71,9 +69,7 @@ public class GetFavoriteSitesSanityTests extends RestTest dataUser.usingUser(userModel).addUserToSite(contributorUser2, siteModel, UserRole.SiteContributor); dataSite.usingUser(contributorUser2).usingSite(siteModel).addSiteToFavorites(); - restClient.authenticateUser(contributorUser) - .withCoreAPI() - .usingUser(contributorUser2).getFavoriteSites(); + restClient.authenticateUser(contributorUser).withCoreAPI().usingUser(contributorUser2).getFavoriteSites(); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @@ -88,9 +84,7 @@ public class GetFavoriteSitesSanityTests extends RestTest dataUser.usingUser(collaboratorUser).addUserToSite(collaboratorUser, siteModel, UserRole.SiteCollaborator); dataSite.usingUser(collaboratorUser).usingSite(siteModel).addSiteToFavorites(); - restClient.authenticateUser(consumerUser) - .withCoreAPI() - .usingUser(collaboratorUser).getFavoriteSites(); + restClient.authenticateUser(consumerUser).withCoreAPI().usingUser(collaboratorUser).getFavoriteSites(); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @@ -103,13 +97,10 @@ public class GetFavoriteSitesSanityTests extends RestTest UserModel anotherUser = dataUser.usingAdmin().createRandomTestUser(); dataSite.usingUser(anotherUser).usingSite(siteModel).addSiteToFavorites(); - restClient.authenticateUser(adminUser) - .withCoreAPI() - .usingUser(anotherUser).getFavoriteSites() - .assertThat().entriesListIsNotEmpty() - .and().paginationExist() - .and().entriesListContains("id", siteModel.getId()); + restSiteModelsCollection = restClient.authenticateUser(adminUser).withCoreAPI().usingUser(anotherUser).getFavoriteSites(); restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteModelsCollection.assertThat().entriesListIsNotEmpty().and().paginationExist() + .and().entriesListContains("id", siteModel.getId()); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -120,13 +111,10 @@ public class GetFavoriteSitesSanityTests extends RestTest UserModel anyUser = dataUser.usingAdmin().createRandomTestUser(); dataSite.usingUser(anyUser).usingSite(siteModel).addSiteToFavorites(); - restClient.authenticateUser(anyUser) - .withCoreAPI() - .usingAuthUser().getFavoriteSites() - .assertThat().entriesListIsNotEmpty() - .and().entriesListContains("id", siteModel.getId()) - .and().paginationExist(); + restSiteModelsCollection = restClient.authenticateUser(anyUser).withCoreAPI().usingAuthUser().getFavoriteSites(); restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteModelsCollection.assertThat().entriesListIsNotEmpty().and().entriesListContains("id", siteModel.getId()) + .and().paginationExist(); } @Bug(id = "MNT-16904") @@ -139,9 +127,7 @@ public class GetFavoriteSitesSanityTests extends RestTest dataSite.usingUser(anyUser).usingSite(siteModel).addSiteToFavorites(); anyUser.setPassword("newpassword"); - restClient.authenticateUser(anyUser) - .withCoreAPI() - .usingAuthUser().getFavoriteSites(); + restClient.authenticateUser(anyUser).withCoreAPI().usingAuthUser().getFavoriteSites(); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } From 8b7635dc37c828fa4660f06b1955c9547fffa138 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Thu, 17 Nov 2016 15:13:18 +0200 Subject: [PATCH 0580/1491] Refactor Test: AddTagsSanityTests.java --- .../rest/tags/AddTagsSanityTests.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/tags/AddTagsSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/AddTagsSanityTests.java index 75cb8f6ee..f7a99943f 100644 --- a/e2e-test/java/org/alfresco/rest/tags/AddTagsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/AddTagsSanityTests.java @@ -10,6 +10,7 @@ import org.alfresco.utility.data.RandomData; import org.alfresco.utility.model.ErrorModel; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; @@ -31,6 +32,7 @@ public class AddTagsSanityTests extends RestTest private SiteModel siteModel; private DataUser.ListUserWithRoles usersWithRoles; private String tag1, tag2; + private RestTagModelsCollection returnedCollection; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception @@ -54,11 +56,10 @@ public class AddTagsSanityTests extends RestTest public void adminIsAbleToAddTags() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); - RestTagModelsCollection returnedCollection = restClient.withCoreAPI().usingResource(document).addTags(tag1, tag2); + returnedCollection = restClient.withCoreAPI().usingResource(document).addTags(tag1, tag2); restClient.assertStatusCodeIs(HttpStatus.CREATED); returnedCollection.assertThat().entriesListContains("tag", tag1) .and().entriesListContains("tag", tag2); - } @TestRail(section = { TestGroup.REST_API, @@ -66,7 +67,7 @@ public class AddTagsSanityTests extends RestTest public void managerIsAbleToAddTags() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - RestTagModelsCollection returnedCollection = restClient.withCoreAPI().usingResource(document).addTags(tag1, tag2); + returnedCollection = restClient.withCoreAPI().usingResource(document).addTags(tag1, tag2); restClient.assertStatusCodeIs(HttpStatus.CREATED); returnedCollection.assertThat().entriesListContains("tag", tag1) .and().entriesListContains("tag", tag2); @@ -77,7 +78,7 @@ public class AddTagsSanityTests extends RestTest public void collaboratorIsAbleToAddTags() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - RestTagModelsCollection returnedCollection = restClient.withCoreAPI().usingResource(document).addTags(tag1, tag2); + returnedCollection = restClient.withCoreAPI().usingResource(document).addTags(tag1, tag2); restClient.assertStatusCodeIs(HttpStatus.CREATED); returnedCollection.assertThat().entriesListContains("tag", tag1) .and().entriesListContains("tag", tag2); @@ -99,7 +100,7 @@ public class AddTagsSanityTests extends RestTest userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); restClient.authenticateUser(userModel); contributorDoc = dataContent.usingSite(siteModel).usingUser(userModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - RestTagModelsCollection returnedCollection = restClient.withCoreAPI().usingResource(contributorDoc).addTags(tag1, tag2); + returnedCollection = restClient.withCoreAPI().usingResource(contributorDoc).addTags(tag1, tag2); restClient.assertStatusCodeIs(HttpStatus.CREATED); returnedCollection.assertThat().entriesListContains("tag", tag1) .and().entriesListContains("tag", tag2); @@ -114,14 +115,13 @@ public class AddTagsSanityTests extends RestTest } @TestRail(section = { TestGroup.REST_API, - TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Manager user gets status code 401 if authentication call fails") + TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user gets status code 401 if authentication call fails") @Bug(id="MNT-16904") - public void managerIsNotAbleToAddTagsIfAuthenticationFails() throws JsonToModelConversionException, Exception + public void userIsNotAbleToAddTagsIfAuthenticationFails() throws JsonToModelConversionException, Exception { UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); siteManager.setPassword("wrongPassword"); restClient.authenticateUser(siteManager).withCoreAPI().usingResource(document).addTags(tag1, tag2); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(ErrorModel.AUTHENTICATION_FAILED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); } -} - +} \ No newline at end of file From 2246c7c0787d4fb9414f5dcee60582034e6fb00d Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Thu, 17 Nov 2016 15:20:30 +0200 Subject: [PATCH 0581/1491] Refactor Test: DeleteTagSanityTests.java --- .../org/alfresco/rest/tags/DeleteTagSanityTests.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/tags/DeleteTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/DeleteTagSanityTests.java index 66c13c3bc..8d55a4699 100644 --- a/e2e-test/java/org/alfresco/rest/tags/DeleteTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/DeleteTagSanityTests.java @@ -10,6 +10,7 @@ import org.alfresco.utility.data.RandomData; import org.alfresco.utility.model.ErrorModel; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; @@ -112,8 +113,8 @@ public class DeleteTagSanityTests extends RestTest } @TestRail(section = { TestGroup.REST_API, - TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Manager user gets status code 401 if authentication call fails") - public void managerIsNotAbleToDeleteTagIfAuthenticationFails() throws JsonToModelConversionException, Exception + TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user gets status code 401 if authentication call fails") + public void userIsNotAbleToDeleteTagIfAuthenticationFails() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); @@ -122,6 +123,6 @@ public class DeleteTagSanityTests extends RestTest siteManager.setPassword("wrongPassword"); restClient.authenticateUser(siteManager); restClient.withCoreAPI().usingResource(document).deleteTag(tag); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(ErrorModel.AUTHENTICATION_FAILED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); } -} +} \ No newline at end of file From 9620655d18e90b79e8d5e22237b9dbe18ec84a90 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Thu, 17 Nov 2016 15:56:09 +0200 Subject: [PATCH 0582/1491] Refactor test: GetPeopleActivitiesSanityTests --- .../GetPeopleActivitiesSanityTests.java | 51 +++++++------------ 1 file changed, 18 insertions(+), 33 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java index 08ec9333d..1b10b5ec8 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java @@ -2,6 +2,7 @@ package org.alfresco.rest.people; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestActivityModelsCollection; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; @@ -25,6 +26,7 @@ public class GetPeopleActivitiesSanityTests extends RestTest UserModel userModel; SiteModel siteModel; UserModel searchedUser; + private RestActivityModelsCollection restActivityModelsCollection; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception @@ -43,13 +45,10 @@ public class GetPeopleActivitiesSanityTests extends RestTest dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); dataContent.usingUser(managerUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(managerUser) - .withCoreAPI() - .usingAuthUser().getPersonActivities() - .assertThat().entriesListIsNotEmpty() - .and().entriesListContains("siteId", siteModel.getId()) - .and().paginationExist(); + restActivityModelsCollection = restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().getPersonActivities(); restClient.assertStatusCodeIs(HttpStatus.OK); + restActivityModelsCollection.assertThat().entriesListIsNotEmpty().and().entriesListContains("siteId", siteModel.getId()) + .and().paginationExist(); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, @@ -61,13 +60,10 @@ public class GetPeopleActivitiesSanityTests extends RestTest dataUser.usingUser(userModel).addUserToSite(collaboratorUser, siteModel, UserRole.SiteCollaborator); dataContent.usingUser(collaboratorUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(collaboratorUser) - .withCoreAPI() - .usingAuthUser().getPersonActivities() - .assertThat().entriesListIsNotEmpty() - .and().entriesListContains("siteId", siteModel.getId()) - .and().paginationExist(); + restActivityModelsCollection = restClient.authenticateUser(collaboratorUser).withCoreAPI().usingAuthUser().getPersonActivities(); restClient.assertStatusCodeIs(HttpStatus.OK); + restActivityModelsCollection.assertThat().entriesListIsNotEmpty().and().entriesListContains("siteId", siteModel.getId()) + .and().paginationExist(); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, @@ -79,13 +75,10 @@ public class GetPeopleActivitiesSanityTests extends RestTest dataUser.usingUser(userModel).addUserToSite(contributorUser, siteModel, UserRole.SiteContributor); dataContent.usingUser(contributorUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(contributorUser) - .withCoreAPI() - .usingAuthUser().getPersonActivities() - .assertThat().entriesListIsNotEmpty() - .and().entriesListContains("siteId", siteModel.getId()) - .and().paginationExist(); + restActivityModelsCollection = restClient.authenticateUser(contributorUser).withCoreAPI().usingAuthUser().getPersonActivities(); restClient.assertStatusCodeIs(HttpStatus.OK); + restActivityModelsCollection.assertThat().entriesListIsNotEmpty().and().entriesListContains("siteId", siteModel.getId()) + .and().paginationExist(); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, @@ -96,13 +89,10 @@ public class GetPeopleActivitiesSanityTests extends RestTest UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel, UserRole.SiteConsumer); - restClient.authenticateUser(consumerUser) - .withCoreAPI() - .usingAuthUser().getPersonActivities() - .assertThat().entriesListIsNotEmpty() - .and().entriesListContains("siteId", siteModel.getId()) - .and().paginationExist(); + restActivityModelsCollection = restClient.authenticateUser(consumerUser).withCoreAPI().usingAuthUser().getPersonActivities(); restClient.assertStatusCodeIs(HttpStatus.OK); + restActivityModelsCollection.assertThat().entriesListIsNotEmpty().and().entriesListContains("siteId", siteModel.getId()) + .and().paginationExist(); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, @@ -110,13 +100,10 @@ public class GetPeopleActivitiesSanityTests extends RestTest description = "Verify admin user gets another user activities with Rest API and response is successful") public void adminUserShouldGetPeopleActivitiesList() throws Exception { - restClient.authenticateUser(dataUser.getAdminUser()) - .withCoreAPI() - .usingUser(userModel).getPersonActivities() - .assertThat().entriesListIsNotEmpty() - .and().entriesListContains("siteId", siteModel.getId()) - .and().paginationExist(); + restActivityModelsCollection = restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingUser(userModel).getPersonActivities(); restClient.assertStatusCodeIs(HttpStatus.OK); + restActivityModelsCollection.assertThat().entriesListIsNotEmpty().and().entriesListContains("siteId", siteModel.getId()) + .and().paginationExist(); } @Bug(id = "MNT-16904") @@ -129,9 +116,7 @@ public class GetPeopleActivitiesSanityTests extends RestTest dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); managerUser.setPassword("newpassword"); - restClient.authenticateUser(managerUser) - .withCoreAPI() - .usingUser(userModel).getPersonActivities(); + restClient.authenticateUser(managerUser).withCoreAPI().usingUser(userModel).getPersonActivities(); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } From 4e42160c85cc9f72b0cb6226bbeebd62b2883b9d Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Thu, 17 Nov 2016 16:08:17 +0200 Subject: [PATCH 0583/1491] Refactor Test: GetNodeTagsSanityTests.java --- .../rest/tags/GetNodeTagsSanityTests.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java index 3eb7c18a5..7b211cd3e 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java @@ -7,9 +7,9 @@ import org.alfresco.rest.model.RestTagModelsCollection; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.ErrorModel; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; @@ -26,7 +26,7 @@ public class GetNodeTagsSanityTests extends RestTest private SiteModel siteModel; private ListUserWithRoles usersWithRoles; private FileModel document; - + private RestTagModelsCollection returnedCollection; private String tagValue; private String tagValue2; @@ -54,7 +54,7 @@ public class GetNodeTagsSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - RestTagModelsCollection returnedCollection = restClient.withCoreAPI().usingResource(document).getNodeTags(); + returnedCollection = restClient.withCoreAPI().usingResource(document).getNodeTags(); restClient.assertStatusCodeIs(HttpStatus.OK); returnedCollection.assertThat() .entriesListContains("tag", tagValue.toLowerCase()) @@ -68,7 +68,7 @@ public class GetNodeTagsSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - RestTagModelsCollection returnedCollection = restClient.withCoreAPI().usingResource(document).getNodeTags(); + returnedCollection = restClient.withCoreAPI().usingResource(document).getNodeTags(); restClient.assertStatusCodeIs(HttpStatus.OK); returnedCollection.assertThat() .entriesListContains("tag", tagValue.toLowerCase()) @@ -81,7 +81,7 @@ public class GetNodeTagsSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - RestTagModelsCollection returnedCollection = restClient.withCoreAPI().usingResource(document).getNodeTags(); + returnedCollection = restClient.withCoreAPI().usingResource(document).getNodeTags(); restClient.assertStatusCodeIs(HttpStatus.OK); returnedCollection.assertThat() .entriesListContains("tag", tagValue.toLowerCase()) @@ -94,7 +94,7 @@ public class GetNodeTagsSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - RestTagModelsCollection returnedCollection = restClient.withCoreAPI().usingResource(document).getNodeTags(); + returnedCollection = restClient.withCoreAPI().usingResource(document).getNodeTags(); restClient.assertStatusCodeIs(HttpStatus.OK); returnedCollection.assertThat() .entriesListContains("tag", tagValue.toLowerCase()) @@ -106,7 +106,7 @@ public class GetNodeTagsSanityTests extends RestTest public void adminIsAbleToRetrieveNodeTags() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); - RestTagModelsCollection returnedCollection = restClient.withCoreAPI().usingResource(document).getNodeTags(); + returnedCollection = restClient.withCoreAPI().usingResource(document).getNodeTags(); restClient.assertStatusCodeIs(HttpStatus.OK); returnedCollection.assertThat() .entriesListContains("tag", tagValue.toLowerCase()) @@ -120,6 +120,6 @@ public class GetNodeTagsSanityTests extends RestTest { restClient.authenticateUser(new UserModel("random user", "random password")); restClient.withCoreAPI().usingResource(document).getNodeTags(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(ErrorModel.AUTHENTICATION_FAILED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); } } \ No newline at end of file From 8e2504046a9087907834ca0d0a86a6facb2c7e68 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Thu, 17 Nov 2016 16:16:04 +0200 Subject: [PATCH 0584/1491] Refactor Test: UpdateTagSanityTests.java --- .../alfresco/rest/tags/UpdateTagSanityTests.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java index e8b8decb9..cc0e69d12 100644 --- a/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java @@ -10,6 +10,7 @@ import org.alfresco.utility.data.RandomData; import org.alfresco.utility.model.ErrorModel; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; @@ -32,7 +33,8 @@ public class UpdateTagSanityTests extends RestTest private SiteModel siteModel; private RestTagModel oldTag; private DataUser.ListUserWithRoles usersWithRoles; - String randomTag = ""; + private String randomTag = ""; + private RestTagModel returnedModel; @BeforeClass(alwaysRun=true) public void dataPreparation() throws Exception @@ -56,7 +58,7 @@ public class UpdateTagSanityTests extends RestTest public void adminIsAbleToUpdateTags() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); - RestTagModel returnedModel = restClient.withCoreAPI().usingTag(oldTag).update(randomTag); + returnedModel = restClient.withCoreAPI().usingTag(oldTag).update(randomTag); restClient.assertStatusCodeIs(HttpStatus.OK); returnedModel.assertThat().field("tag").is(randomTag); } @@ -98,14 +100,14 @@ public class UpdateTagSanityTests extends RestTest } @TestRail(section = { TestGroup.REST_API, - TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Manager user gets status code 401 if authentication call fails") + TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user gets status code 401 if authentication call fails") @Bug(id="MNT-16904") - public void managerIsNotAbleToUpdateTagIfAuthenticationFails() throws JsonToModelConversionException, Exception + public void userIsNotAbleToUpdateTagIfAuthenticationFails() throws JsonToModelConversionException, Exception { UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); siteManager.setPassword("wrongPassword"); restClient.authenticateUser(siteManager); restClient.withCoreAPI().usingTag(oldTag).update(randomTag); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(ErrorModel.AUTHENTICATION_FAILED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); } -} +} \ No newline at end of file From 106d731cff91b8754f85eed2ce6cdd5e277e8a65 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Thu, 17 Nov 2016 16:22:51 +0200 Subject: [PATCH 0585/1491] Refactor test: GetPeoplePreferenceSanityTests --- .../GetPeoplePreferenceSanityTests.java | 42 ++++++++++--------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceSanityTests.java index 62fbb93f8..504f42e02 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceSanityTests.java @@ -1,6 +1,7 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestPreferenceModel; import org.alfresco.utility.constants.PreferenceName; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.model.SiteModel; @@ -24,6 +25,7 @@ public class GetPeoplePreferenceSanityTests extends RestTest { UserModel userModel; SiteModel siteModel; + private RestPreferenceModel restPreferenceModel; @BeforeClass(alwaysRun=true) public void dataPreparation() throws Exception @@ -39,11 +41,11 @@ public class GetPeoplePreferenceSanityTests extends RestTest dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); dataSite.usingUser(managerUser).usingSite(siteModel).addSiteToFavorites(); - restClient.authenticateUser(managerUser) - .withCoreAPI().usingAuthUser().getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) - .assertThat().field("id").is( PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) - .and().field("value").is("true"); + restPreferenceModel = restClient.authenticateUser(managerUser) + .withCoreAPI().usingAuthUser().getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); restClient.assertStatusCodeIs(HttpStatus.OK); + restPreferenceModel.assertThat().field("id").is( PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) + .and().field("value").is("true"); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify collaborator user gets a specific preference with Rest API and response is successful (200)") @@ -53,11 +55,11 @@ public class GetPeoplePreferenceSanityTests extends RestTest dataUser.usingUser(userModel).addUserToSite(collaboratorUser, siteModel, UserRole.SiteCollaborator); dataSite.usingUser(collaboratorUser).usingSite(siteModel).addSiteToFavorites(); - restClient.authenticateUser(collaboratorUser) - .withCoreAPI().usingAuthUser().getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) - .assertThat().field("id").is(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) - .and().field("value").is("true"); + restPreferenceModel = restClient.authenticateUser(collaboratorUser) + .withCoreAPI().usingAuthUser().getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); restClient.assertStatusCodeIs(HttpStatus.OK); + restPreferenceModel.assertThat().field("id").is(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) + .and().field("value").is("true"); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify contributor user gets a specific preference with Rest API and response is successful (200)") @@ -67,11 +69,11 @@ public class GetPeoplePreferenceSanityTests extends RestTest dataUser.usingUser(userModel).addUserToSite(contributorUser, siteModel, UserRole.SiteContributor); dataSite.usingUser(contributorUser).usingSite(siteModel).addSiteToFavorites(); - restClient.authenticateUser(contributorUser) - .withCoreAPI().usingAuthUser().getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) - .assertThat().field("id").is(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) - .and().field("value").is("true"); + restPreferenceModel = restClient.authenticateUser(contributorUser) + .withCoreAPI().usingAuthUser().getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); restClient.assertStatusCodeIs(HttpStatus.OK); + restPreferenceModel.assertThat().field("id").is(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) + .and().field("value").is("true"); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify consumer user gets a specific preference with Rest API and response is successful (200)") @@ -81,11 +83,11 @@ public class GetPeoplePreferenceSanityTests extends RestTest dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel, UserRole.SiteConsumer); dataSite.usingUser(consumerUser).usingSite(siteModel).addSiteToFavorites(); - restClient.authenticateUser(consumerUser) - .withCoreAPI().usingAuthUser().getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) - .assertThat().field("id").is(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) - .and().field("value").is("true"); + restPreferenceModel = restClient.authenticateUser(consumerUser) + .withCoreAPI().usingAuthUser().getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); restClient.assertStatusCodeIs(HttpStatus.OK); + restPreferenceModel.assertThat().field("id").is(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) + .and().field("value").is("true"); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify admin user gets a specific preference with Rest API and response is successful (200)") @@ -94,11 +96,11 @@ public class GetPeoplePreferenceSanityTests extends RestTest UserModel adminUser = dataUser.getAdminUser(); dataSite.usingUser(adminUser).usingSite(siteModel).addSiteToFavorites(); - restClient.authenticateUser(adminUser) - .withCoreAPI().usingAuthUser().getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) - .assertThat().field("id").is(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) - .and().field("value").is("true"); + restPreferenceModel = restClient.authenticateUser(adminUser) + .withCoreAPI().usingAuthUser().getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); restClient.assertStatusCodeIs(HttpStatus.OK); + restPreferenceModel.assertThat().field("id").is(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) + .and().field("value").is("true"); } @Bug(id = "MNT-16904") From 2428f83f894a0f6fe5032bbbb888bf7516e399be Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Thu, 17 Nov 2016 16:23:10 +0200 Subject: [PATCH 0586/1491] Refactor Test: AddSiteMembershipRequestSanityTests.java --- .../AddSiteMembershipRequestSanityTests.java | 67 +++++++++---------- 1 file changed, 33 insertions(+), 34 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java index 0478dd9be..637aac2b5 100644 --- a/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java @@ -2,6 +2,7 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestSiteMembershipRequestModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataSite; import org.alfresco.utility.data.DataUser; @@ -16,6 +17,7 @@ import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) @@ -32,6 +34,8 @@ public class AddSiteMembershipRequestSanityTests extends RestTest private ListUserWithRoles usersWithRoles; private UserModel adminUser; + private UserModel newMember; + private RestSiteMembershipRequestModel requestModel; @BeforeClass(alwaysRun=true) public void dataPreparation() throws DataPreparationException @@ -41,18 +45,21 @@ public class AddSiteMembershipRequestSanityTests extends RestTest usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); } + @BeforeMethod + public void setUp() throws DataPreparationException { + newMember = dataUser.createRandomTestUser(); + } + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site manager is able to create new site membership request") @Bug(id="MNT-16557") public void siteManagerIsAbleToCreateSiteMembershipRequest() throws JsonToModelConversionException, Exception { - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI() - .usingUser(newMember).addSiteMembershipRequest(siteModel) - .assertThat().field("id").isNotEmpty() - .assertThat().field("site").isNotEmpty(); + requestModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingUser(newMember).addSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); + requestModel.assertThat().field("id").isNotEmpty() + .assertThat().field("site").isNotEmpty(); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -61,13 +68,11 @@ public class AddSiteMembershipRequestSanityTests extends RestTest @Bug(id = "MNT-16557") public void siteCollaboatorIsAbleToCreateSiteMembershipRequest() throws JsonToModelConversionException, Exception { - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI() - .usingUser(newMember).addSiteMembershipRequest(siteModel) - .assertThat().field("id").isNotEmpty() - .assertThat().field("site").isNotEmpty(); + requestModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingUser(newMember).addSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); + requestModel.assertThat().field("id").isNotEmpty() + .assertThat().field("site").isNotEmpty(); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -76,13 +81,11 @@ public class AddSiteMembershipRequestSanityTests extends RestTest @Bug(id = "MNT-16557") public void siteContributorIsAbleToCreateSiteMembershipRequest() throws JsonToModelConversionException, Exception { - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) - .withCoreAPI() - .usingUser(newMember).addSiteMembershipRequest(siteModel) - .assertThat().field("id").isNotEmpty() + requestModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) + .withCoreAPI().usingUser(newMember).addSiteMembershipRequest(siteModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + requestModel.assertThat().field("id").isNotEmpty() .assertThat().field("site").isNotEmpty(); - restClient.assertStatusCodeIs(HttpStatus.CREATED); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -91,13 +94,11 @@ public class AddSiteMembershipRequestSanityTests extends RestTest @Bug(id = "MNT-16557") public void siteConsumerIsAbleToCreateSiteMembershipRequest() throws JsonToModelConversionException, Exception { - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .withCoreAPI() - .usingUser(newMember).addSiteMembershipRequest(siteModel) - .assertThat().field("id").isNotEmpty() - .assertThat().field("site").isNotEmpty(); + requestModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + .withCoreAPI().usingUser(newMember).addSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); + requestModel.assertThat().field("id").isNotEmpty() + .assertThat().field("site").isNotEmpty(); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -106,13 +107,12 @@ public class AddSiteMembershipRequestSanityTests extends RestTest @Bug(id = "MNT-16557") public void adminUserIsAbleToCreateSiteMembershipRequest() throws JsonToModelConversionException, Exception { - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(adminUser) + requestModel = restClient.authenticateUser(adminUser) .withCoreAPI() - .usingUser(newMember).addSiteMembershipRequest(siteModel) - .assertThat().field("id").isNotEmpty() - .assertThat().field("site").isNotEmpty(); + .usingUser(newMember).addSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); + requestModel.assertThat().field("id").isNotEmpty() + .assertThat().field("site").isNotEmpty(); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -121,12 +121,11 @@ public class AddSiteMembershipRequestSanityTests extends RestTest @Bug(id = "MNT-16557") public void unauthenticatedUserIsNotAbleToCreateSiteMembershipRequest() throws JsonToModelConversionException, Exception { - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(new UserModel("random user", "random password")) + requestModel = restClient.authenticateUser(new UserModel("random user", "random password")) .withCoreAPI() - .usingUser(newMember).addSiteMembershipRequest(siteModel) - .assertThat().field("id").isNotEmpty() - .assertThat().field("site").isNotEmpty(); + .usingUser(newMember).addSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + requestModel.assertThat().field("id").isNotEmpty() + .assertThat().field("site").isNotEmpty(); } } \ No newline at end of file From c7aec116656bb6ea860e29c0cdb118351a0befb0 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Thu, 17 Nov 2016 16:29:40 +0200 Subject: [PATCH 0587/1491] Refactor test: GetPeoplePreferencesSanityTests --- .../GetPeoplePreferencesSanityTests.java | 48 +++++++------------ 1 file changed, 18 insertions(+), 30 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesSanityTests.java index 5e3377a15..394381427 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesSanityTests.java @@ -1,6 +1,7 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestPreferenceModelsCollection; import org.alfresco.utility.constants.PreferenceName; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.model.SiteModel; @@ -24,6 +25,7 @@ public class GetPeoplePreferencesSanityTests extends RestTest { UserModel userModel; SiteModel siteModel; + private RestPreferenceModelsCollection restPreferenceModelsCollection; @BeforeClass(alwaysRun=true) public void dataPreparation() throws Exception @@ -41,13 +43,10 @@ public class GetPeoplePreferencesSanityTests extends RestTest dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); dataSite.usingUser(managerUser).usingSite(siteModel).addSiteToFavorites(); - restClient.authenticateUser(managerUser) - .withCoreAPI() - .usingAuthUser() - .getPersonPreferences().assertThat().entriesListIsNotEmpty() - .assertThat().paginationExist() - .and().entriesListContains("id", PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); + restPreferenceModelsCollection = restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().getPersonPreferences(); restClient.assertStatusCodeIs(HttpStatus.OK); + restPreferenceModelsCollection.assertThat().entriesListIsNotEmpty().assertThat().paginationExist() + .and().entriesListContains("id", PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, @@ -59,12 +58,10 @@ public class GetPeoplePreferencesSanityTests extends RestTest dataUser.usingUser(userModel).addUserToSite(collaboratorUser, siteModel, UserRole.SiteCollaborator); dataSite.usingUser(collaboratorUser).usingSite(siteModel).addSiteToFavorites(); - restClient.authenticateUser(collaboratorUser) - .withCoreAPI() - .usingAuthUser().getPersonPreferences().assertThat().entriesListIsNotEmpty() - .assertThat().paginationExist() - .and().entriesListContains("id", PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); + restPreferenceModelsCollection = restClient.authenticateUser(collaboratorUser).withCoreAPI().usingAuthUser().getPersonPreferences(); restClient.assertStatusCodeIs(HttpStatus.OK); + restPreferenceModelsCollection.assertThat().entriesListIsNotEmpty().assertThat().paginationExist() + .and().entriesListContains("id", PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, @@ -76,12 +73,10 @@ public class GetPeoplePreferencesSanityTests extends RestTest dataUser.usingUser(userModel).addUserToSite(contributorUser, siteModel, UserRole.SiteContributor); dataSite.usingUser(contributorUser).usingSite(siteModel).addSiteToFavorites(); - restClient.authenticateUser(contributorUser) - .withCoreAPI() - .usingAuthUser().getPersonPreferences().assertThat().entriesListIsNotEmpty() - .assertThat().paginationExist() - .and().entriesListContains("id", PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); + restPreferenceModelsCollection = restClient.authenticateUser(contributorUser).withCoreAPI().usingAuthUser().getPersonPreferences(); restClient.assertStatusCodeIs(HttpStatus.OK); + restPreferenceModelsCollection.assertThat().entriesListIsNotEmpty().assertThat().paginationExist() + .and().entriesListContains("id", PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, @@ -93,12 +88,10 @@ public class GetPeoplePreferencesSanityTests extends RestTest dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel, UserRole.SiteConsumer); dataSite.usingUser(consumerUser).usingSite(siteModel).addSiteToFavorites(); - restClient.authenticateUser(consumerUser) - .withCoreAPI() - .usingAuthUser().getPersonPreferences().assertThat().entriesListIsNotEmpty() - .assertThat().paginationExist() - .and().entriesListContains("id", PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); + restPreferenceModelsCollection = restClient.authenticateUser(consumerUser).withCoreAPI().usingAuthUser().getPersonPreferences(); restClient.assertStatusCodeIs(HttpStatus.OK); + restPreferenceModelsCollection.assertThat().entriesListIsNotEmpty().assertThat().paginationExist() + .and().entriesListContains("id", PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, @@ -111,12 +104,10 @@ public class GetPeoplePreferencesSanityTests extends RestTest dataSite.usingUser(managerUser).usingSite(siteModel).addSiteToFavorites(); UserModel adminUser = dataUser.getAdminUser(); - restClient.authenticateUser(adminUser) - .withCoreAPI() - .usingUser(managerUser).getPersonPreferences().assertThat().entriesListIsNotEmpty() - .assertThat().paginationExist() - .and().entriesListContains("id", PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); + restPreferenceModelsCollection = restClient.authenticateUser(adminUser).withCoreAPI().usingUser(managerUser).getPersonPreferences(); restClient.assertStatusCodeIs(HttpStatus.OK); + restPreferenceModelsCollection.assertThat().entriesListIsNotEmpty().assertThat().paginationExist() + .and().entriesListContains("id", PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); } @Bug(id = "MNT-16904") @@ -130,10 +121,7 @@ public class GetPeoplePreferencesSanityTests extends RestTest dataSite.usingUser(managerUser).usingSite(siteModel).addSiteToFavorites(); managerUser.setPassword("newpassword"); - restClient.authenticateUser(managerUser) - .withCoreAPI() - .usingAuthUser() - .getPersonPreferences(); + restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().getPersonPreferences(); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } From 91a83b5ec600ac938cff1f2f4b22d668975bf4f9 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Thu, 17 Nov 2016 16:30:24 +0200 Subject: [PATCH 0588/1491] Refactor Test: DeleteSiteMemberSanityTests.java --- .../people/DeleteSiteMemberSanityTests.java | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java index 5ad27944f..f93657375 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java @@ -7,6 +7,7 @@ import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.ErrorModel; import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; @@ -44,8 +45,7 @@ public class DeleteSiteMemberSanityTests extends RestTest UserModel newUser = dataUser.createRandomTestUser("testUser"); newUser.setUserRole(UserRole.SiteCollaborator); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI() - .usingSite(siteModel).addPerson(newUser); + .withCoreAPI().usingSite(siteModel).addPerson(newUser); restClient.withCoreAPI().usingUser(newUser).deleteSiteMember(siteModel); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); @@ -59,8 +59,7 @@ public class DeleteSiteMemberSanityTests extends RestTest UserModel newUser = dataUser.createRandomTestUser("testUser"); newUser.setUserRole(UserRole.SiteCollaborator); restClient.authenticateUser(adminUser) - .withCoreAPI() - .usingSite(siteModel).addPerson(newUser); + .withCoreAPI().usingSite(siteModel).addPerson(newUser); restClient.withCoreAPI().usingUser(newUser).deleteSiteMember(siteModel); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); @@ -75,8 +74,7 @@ public class DeleteSiteMemberSanityTests extends RestTest UserModel newUser = dataUser.createRandomTestUser("testUser"); newUser.setUserRole(UserRole.SiteCollaborator); restClient.authenticateUser(adminUser) - .withCoreAPI() - .usingSite(siteModel).addPerson(newUser); + .withCoreAPI().usingSite(siteModel).addPerson(newUser); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); restClient.withCoreAPI().usingUser(newUser).deleteSiteMember(siteModel); @@ -93,8 +91,7 @@ public class DeleteSiteMemberSanityTests extends RestTest UserModel newUser = dataUser.createRandomTestUser("testUser"); newUser.setUserRole(UserRole.SiteCollaborator); restClient.authenticateUser(adminUser) - .withCoreAPI() - .usingSite(siteModel).addPerson(newUser); + .withCoreAPI().usingSite(siteModel).addPerson(newUser); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); restClient.withCoreAPI().usingUser(newUser).deleteSiteMember(siteModel); @@ -111,8 +108,7 @@ public class DeleteSiteMemberSanityTests extends RestTest UserModel newUser = dataUser.createRandomTestUser("testUser"); newUser.setUserRole(UserRole.SiteCollaborator); restClient.authenticateUser(adminUser) - .withCoreAPI() - .usingSite(siteModel).addPerson(newUser); + .withCoreAPI().usingSite(siteModel).addPerson(newUser); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); restClient.withCoreAPI().usingUser(newUser).deleteSiteMember(siteModel); @@ -128,6 +124,6 @@ public class DeleteSiteMemberSanityTests extends RestTest restClient.authenticateUser(new UserModel("random user", "random password")); restClient.withCoreAPI().usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).deleteSiteMember(siteModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); } } \ No newline at end of file From 95ce188ecd47a844574f61f81f9a55c4490b941d Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Thu, 17 Nov 2016 16:38:59 +0200 Subject: [PATCH 0589/1491] Refactor Test: GetTagSanityTests --- e2e-test/java/org/alfresco/rest/tags/GetTagSanityTests.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/tags/GetTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagSanityTests.java index 082be8203..bd2a709db 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetTagSanityTests.java @@ -7,9 +7,9 @@ import org.alfresco.rest.model.RestTagModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.ErrorModel; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; @@ -116,7 +116,7 @@ public class GetTagSanityTests extends RestTest managerUser.setPassword("wrongPassword"); restClient.authenticateUser(managerUser); restClient.withCoreAPI().getTag(tag); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(ErrorModel.AUTHENTICATION_FAILED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); } } \ No newline at end of file From 927ecdd56d7cd48e1d7486ff369b201b106c7aef Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Thu, 17 Nov 2016 16:40:36 +0200 Subject: [PATCH 0590/1491] Refactor Test: GetPeopleSanityTests.java --- .../rest/people/GetPeopleSanityTests.java | 52 ++++++++++--------- 1 file changed, 27 insertions(+), 25 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleSanityTests.java index f2e22ccfb..eda1a1526 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleSanityTests.java @@ -1,8 +1,10 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestPersonModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.model.ErrorModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; @@ -18,12 +20,14 @@ public class GetPeopleSanityTests extends RestTest UserModel userModel; SiteModel siteModel; UserModel searchedUser; - + UserModel adminUser; + private RestPersonModel personModel; private String domain = "@tas-automation.org"; @BeforeClass(alwaysRun=true) public void dataPreparation() throws Exception { + adminUser = dataUser.getAdminUser(); userModel = dataUser.createRandomTestUser(); siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); searchedUser = dataUser.createRandomTestUser(); @@ -37,15 +41,15 @@ public class GetPeopleSanityTests extends RestTest UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); - restClient.authenticateUser(managerUser) + personModel = restClient.authenticateUser(managerUser) .withCoreAPI() .usingUser(searchedUser) - .getPerson() - .assertThat().field("id").is(searchedUser.getUsername()) + .getPerson(); + restClient.assertStatusCodeIs(HttpStatus.OK); + personModel.assertThat().field("id").is(searchedUser.getUsername()) .assertThat().field("firstName").is(searchedUser.getUsername()+" FirstName") .and().field("email").is(searchedUser.getUsername()+ domain) .and().field("emailNotificationsEnabled").is("true"); - restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -56,15 +60,15 @@ public class GetPeopleSanityTests extends RestTest UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(collaboratorUser, siteModel, UserRole.SiteCollaborator); - restClient.authenticateUser(collaboratorUser) + personModel = restClient.authenticateUser(collaboratorUser) .withCoreAPI() .usingUser(searchedUser) - .getPerson() - .assertThat().field("id").is(searchedUser.getUsername()) + .getPerson(); + restClient.assertStatusCodeIs(HttpStatus.OK); + personModel.assertThat().field("id").is(searchedUser.getUsername()) .assertThat().field("firstName").is(searchedUser.getUsername()+" FirstName") .and().field("email").is(searchedUser.getUsername()+ domain) .and().field("emailNotificationsEnabled").is("true"); - restClient.assertStatusCodeIs(HttpStatus.OK); } @Test(groups = TestGroup.COMMENTS) @@ -76,15 +80,15 @@ public class GetPeopleSanityTests extends RestTest UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(contributorUser, siteModel, UserRole.SiteContributor); - restClient.authenticateUser(contributorUser) + personModel = restClient.authenticateUser(contributorUser) .withCoreAPI() .usingUser(searchedUser) - .getPerson() - .assertThat().field("id").is(searchedUser.getUsername()) + .getPerson(); + restClient.assertStatusCodeIs(HttpStatus.OK); + personModel.assertThat().field("id").is(searchedUser.getUsername()) .assertThat().field("firstName").is(searchedUser.getUsername()+" FirstName") .and().field("email").is(searchedUser.getUsername()+ domain) .and().field("emailNotificationsEnabled").is("true");; - restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -95,15 +99,15 @@ public class GetPeopleSanityTests extends RestTest UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel, UserRole.SiteConsumer); - restClient.authenticateUser(consumerUser) + personModel = restClient.authenticateUser(consumerUser) .withCoreAPI() .usingUser(searchedUser) - .getPerson() - .assertThat().field("id").is(searchedUser.getUsername()) + .getPerson(); + restClient.assertStatusCodeIs(HttpStatus.OK); + personModel.assertThat().field("id").is(searchedUser.getUsername()) .assertThat().field("firstName").is(searchedUser.getUsername()+" FirstName") .and().field("email").is(searchedUser.getUsername()+ domain) .and().field("emailNotificationsEnabled").is("true");; - restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -111,17 +115,15 @@ public class GetPeopleSanityTests extends RestTest description = "Verify admin user gets a person with Rest API and response is successful") public void adminUserChecksIfPersonIsPresent() throws Exception { - UserModel adminUser = dataUser.getAdminUser(); - - restClient.authenticateUser(adminUser) + personModel = restClient.authenticateUser(adminUser) .withCoreAPI() .usingUser(searchedUser) - .getPerson() - .assertThat().field("id").is(searchedUser.getUsername()) + .getPerson(); + restClient.assertStatusCodeIs(HttpStatus.OK); + personModel.assertThat().field("id").is(searchedUser.getUsername()) .assertThat().field("firstName").is(searchedUser.getUsername()+" FirstName") .and().field("email").is(searchedUser.getUsername()+ domain) .and().field("emailNotificationsEnabled").is("true");; - restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -137,6 +139,6 @@ public class GetPeopleSanityTests extends RestTest .withCoreAPI() .usingUser(searchedNonUser) .getPerson(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, "")); } -} +} \ No newline at end of file From 71eadf3fea8e10c1f0d6d4a640d41ff357fcd51a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alecsandru=20Prun=C4=83?= Date: Thu, 17 Nov 2016 17:00:15 +0200 Subject: [PATCH 0591/1491] TAS-1888 Fix for getNetwork --- .../rest/networks/RestGetNetworkForPersonSanityTests.java | 6 +++--- .../networks/RestGetNetworksForPersonSanityTests.java | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java index 9d8d40ebd..e87bf2563 100644 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java @@ -36,7 +36,7 @@ public class RestGetNetworkForPersonSanityTests extends RestTest UserModel tenantUser = new UserModel("nonexisting", "password"); tenantUser.setDomain(adminTenantUser.getDomain()); restClient.authenticateUser(tenantUser); - restClient.withCoreAPI().usingUser(tenantUser).getNetwork(adminTenantUser); + restClient.withCoreAPI().usingAuthUser().getNetwork(adminTenantUser); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } @@ -58,7 +58,7 @@ public class RestGetNetworkForPersonSanityTests extends RestTest public void tenantUserIsNotAuthorizedToCheckNetworkOfAdminUser() throws Exception { restClient.authenticateUser(tenantUser); - restClient.withCoreAPI().usingUser(tenantUser).getNetwork(adminTenantUser); + restClient.withCoreAPI().usingAuthUser().getNetwork(adminTenantUser); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); } @@ -72,7 +72,7 @@ public class RestGetNetworkForPersonSanityTests extends RestTest restClient.usingTenant().createTenant(secondAdminTenantUser); UserModel secondTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("anotherTenant"); restClient.authenticateUser(adminTenantUser); - restClient.withCoreAPI().usingUser(adminTenantUser).getNetwork(secondTenantUser); + restClient.withCoreAPI().usingAuthUser().getNetwork(secondTenantUser); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); } } diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonSanityTests.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonSanityTests.java index 267c5fa11..bb75fb85e 100644 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonSanityTests.java @@ -37,7 +37,7 @@ public class RestGetNetworksForPersonSanityTests extends RestTest UserModel tenantUser = new UserModel("nonexisting", "password"); tenantUser.setDomain(adminTenantUser.getDomain()); restClient.authenticateUser(tenantUser); - restClient.withCoreAPI().usingUser(tenantUser).getNetworks(adminTenantUser); + restClient.withCoreAPI().usingAuthUser().getNetworks(adminTenantUser); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } @@ -48,7 +48,7 @@ public class RestGetNetworksForPersonSanityTests extends RestTest public void adminTenantChecksIfNetworkIsPresent() throws Exception { restClient.authenticateUser(adminTenantUser); - restClient.withCoreAPI().usingUser(adminTenantUser).getNetworks(); + restClient.withCoreAPI().usingAuthUser().getNetworks(); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -59,7 +59,7 @@ public class RestGetNetworksForPersonSanityTests extends RestTest public void tenantUserIsNotAuthorizedToCheckNetworkOfAdminUser() throws Exception { restClient.authenticateUser(tenantUser); - restClient.withCoreAPI().usingUser(tenantUser).getNetworks(adminTenantUser); + restClient.withCoreAPI().usingAuthUser().getNetworks(adminTenantUser); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); } @@ -73,7 +73,7 @@ public class RestGetNetworksForPersonSanityTests extends RestTest restClient.usingTenant().createTenant(secondAdminTenantUser); UserModel secondTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("anotherTenant"); restClient.authenticateUser(secondAdminTenantUser); - restClient.withCoreAPI().usingUser(secondAdminTenantUser).getNetworks(secondTenantUser); + restClient.withCoreAPI().usingAuthUser().getNetworks(secondTenantUser); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); } } From 8476309e00c1d119e907c784e415f46dc3681ee1 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Thu, 17 Nov 2016 17:36:00 +0200 Subject: [PATCH 0592/1491] added test info --- e2e-test/java/org/alfresco/rest/RestTest.java | 26 ++++++++++++++++++- .../comments/UpdateCommentsSanityTests.java | 4 +-- .../GetSiteMembershipRequestsSanityTests.java | 1 - 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/RestTest.java b/e2e-test/java/org/alfresco/rest/RestTest.java index b5544498c..3691bae3c 100644 --- a/e2e-test/java/org/alfresco/rest/RestTest.java +++ b/e2e-test/java/org/alfresco/rest/RestTest.java @@ -1,18 +1,30 @@ package org.alfresco.rest; +import java.lang.reflect.Method; + import org.alfresco.rest.core.RestProperties; import org.alfresco.rest.core.RestWrapper; +import org.alfresco.utility.LogFactory; import org.alfresco.utility.TasProperties; -import org.alfresco.utility.data.*; +import org.alfresco.utility.data.DataContent; +import org.alfresco.utility.data.DataGroup; +import org.alfresco.utility.data.DataSite; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.data.DataWorkflow; import org.alfresco.utility.network.ServerHealth; +import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; +import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; @ContextConfiguration("classpath:alfresco-restapi-context.xml") public abstract class RestTest extends AbstractTestNGSpringContextTests { + private static Logger LOG = LogFactory.getLogger(); + @Autowired protected RestProperties restProperties; @@ -45,4 +57,16 @@ public abstract class RestTest extends AbstractTestNGSpringContextTests { serverHealth.assertServerIsOnline(); } + + @BeforeMethod(alwaysRun=true) + public void showStartTestInfo(Method method) + { + LOG.info(String.format("*** STARTING Test: [%s] ***",method.getName())); + } + + @AfterMethod(alwaysRun=true) + public void showEndTestInfo(Method method) + { + LOG.info(String.format("*** ENDING Test: [%s] ***", method.getName())); + } } diff --git a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java index 85f70a03e..2e65953ff 100644 --- a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java @@ -116,7 +116,7 @@ public class UpdateCommentsSanityTests extends RestTest content.setNodeRef("node ref that does not exist"); restClient.withCoreAPI().usingResource(content).updateComment(commentModel, "This is the updated comment."); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary("node ref that does not exist was not found"); + .assertLastError().containsSummary("node ref that does not exist was not found"); } @TestRail(section = { TestGroup.REST_API, TestGroup.SANITY }, executionType = ExecutionType.SANITY, description = "Verify if commentId is not set the status code is 404") @@ -129,7 +129,7 @@ public class UpdateCommentsSanityTests extends RestTest comment.setId(id); restClient.withCoreAPI().usingResource(document).updateComment(comment, "This is the updated comment."); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, id)); + .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, id)); } } diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java index 0ba7a0fdc..d8360b4af 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java @@ -39,7 +39,6 @@ public class GetSiteMembershipRequestsSanityTests extends RestTest .usingAuthUser().addSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); - } @Bug(id = "MNT-16557") From 6caf67018463c07c2879e13f98d2c9c99847c712 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Thu, 17 Nov 2016 17:46:52 +0200 Subject: [PATCH 0593/1491] Refactor test: GetTagsSanityTests --- .../alfresco/rest/tags/GetTagsSanityTests.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java index 55e4de242..0adb153dd 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java @@ -4,12 +4,13 @@ import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestTagModelsCollection; +import org.alfresco.utility.Utility; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.ErrorModel; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; @@ -45,6 +46,8 @@ public class GetTagsSanityTests extends RestTest tagValue2 = RandomData.getRandomName("tag"); restClient.withCoreAPI().usingResource(document).addTag(tagValue2); + + Utility.waitToLoopTime(5); } @@ -54,7 +57,7 @@ public class GetTagsSanityTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); RestTagModelsCollection returnedCollection = restClient.withCoreAPI().getTags(); restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat().entriesListIsEmpty() + returnedCollection.assertThat().entriesListIsNotEmpty() .and().entriesListContains("tag", tagValue.toLowerCase()) .and().entriesListContains("tag", tagValue2.toLowerCase()); } @@ -65,7 +68,7 @@ public class GetTagsSanityTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); RestTagModelsCollection returnedCollection = restClient.withCoreAPI().getTags(); restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat().entriesListIsEmpty() + returnedCollection.assertThat().entriesListIsNotEmpty() .and().entriesListContains("tag", tagValue.toLowerCase()) .and().entriesListContains("tag", tagValue2.toLowerCase()); } @@ -76,7 +79,7 @@ public class GetTagsSanityTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); RestTagModelsCollection returnedCollection = restClient.withCoreAPI().getTags(); restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat().entriesListIsEmpty() + returnedCollection.assertThat().entriesListIsNotEmpty() .and().entriesListContains("tag", tagValue.toLowerCase()) .and().entriesListContains("tag", tagValue2.toLowerCase()); } @@ -87,7 +90,7 @@ public class GetTagsSanityTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); RestTagModelsCollection returnedCollection = restClient.withCoreAPI().getTags(); restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat().entriesListIsEmpty() + returnedCollection.assertThat().entriesListIsNotEmpty() .and().entriesListContains("tag", tagValue.toLowerCase()) .and().entriesListContains("tag", tagValue2.toLowerCase()); } @@ -98,7 +101,7 @@ public class GetTagsSanityTests extends RestTest restClient.authenticateUser(adminUserModel); RestTagModelsCollection returnedCollection = restClient.withCoreAPI().getTags(); restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat().entriesListIsEmpty() + returnedCollection.assertThat().entriesListIsNotEmpty() .and().entriesListContains("tag", tagValue.toLowerCase()) .and().entriesListContains("tag", tagValue2.toLowerCase()); } @@ -113,6 +116,6 @@ public class GetTagsSanityTests extends RestTest dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); restClient.authenticateUser(userModel); restClient.withCoreAPI().getTags(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(ErrorModel.AUTHENTICATION_FAILED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); } } From 9f4d0ea287b88c28569764bdbedc3601fddc628b Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Fri, 18 Nov 2016 17:45:52 +0200 Subject: [PATCH 0594/1491] CORE REST API: deleteComment --- .../comments/DeleteCommentsCoreTests.java | 97 +++++++++++++++++++ .../comments/DeleteCommentsSanityTests.java | 42 +++----- 2 files changed, 110 insertions(+), 29 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/comments/DeleteCommentsCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsCoreTests.java b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsCoreTests.java new file mode 100644 index 000000000..5f58d9e9b --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsCoreTests.java @@ -0,0 +1,97 @@ +package org.alfresco.rest.comments; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestCommentModel; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.model.ErrorModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) +public class DeleteCommentsCoreTests extends RestTest +{ + private UserModel adminUserModel; + + private FileModel document; + private SiteModel siteModel; + private RestCommentModel comment; + private ListUserWithRoles usersWithRoles; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + restClient.authenticateUser(adminUserModel); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteConsumer); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Consumer user can't delete comments created by admin user and status code is 403") + public void consumerIsNotAbleToDeleteComments() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel); + comment = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment"); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + restClient.withCoreAPI().usingResource(document).deleteComment(comment); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Manager user deletes comments created by admin and status code is 204") + public void managerIsAbleToDeleteComments() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel); + comment = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment"); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + restClient.withCoreAPI().usingResource(document).deleteComment(comment); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Admin user can't delete comments with inexistent ID and status code is 404") + public void userIsNotAbleToDeleteInexistentComment() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel); + comment = new RestCommentModel(); + comment.setId("inexistent"); + restClient.withCoreAPI().usingResource(document).deleteComment(comment); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Admin user can't delete comments with inexistend NodeId and status code is 404") + public void userIsNotAbleToDeleteCommentWithInexistentNodeId() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel); + comment = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment"); + FileModel inexistentDocument = new FileModel(); + inexistentDocument.setNodeRef("inexistent"); + restClient.withCoreAPI().usingResource(inexistentDocument).deleteComment(comment); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Admin user can't delete deleted comments and status code is 404") + public void userIsNotAbleToDeleteDeletedComment() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel); + comment = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment"); + restClient.withCoreAPI().usingResource(document).deleteComment(comment); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withCoreAPI().usingResource(document).deleteComment(comment); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } +} diff --git a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java index 464525fa9..cce059c56 100644 --- a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java @@ -6,7 +6,6 @@ import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestCommentModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.model.ErrorModel; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; @@ -15,7 +14,6 @@ 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.BeforeMethod; import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) @@ -38,59 +36,44 @@ public class DeleteCommentsSanityTests extends RestTest usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); } - @BeforeMethod(alwaysRun=true) - public void addCommentToDocument() throws Exception - { - restClient.authenticateUser(adminUserModel); - comment = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment"); - } - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Admin user delete comments with Rest API and status code is 204") + TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Admin user deletes comments with Rest API and status code is 204") public void adminIsAbleToDeleteComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); + comment = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment"); restClient.withCoreAPI().usingResource(document).deleteComment(comment); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Manager user delete comments created by admin user with Rest API and status code is 204") + TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Manager user deletes own comments and status code is 204") public void managerIsAbleToDeleteComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + comment = restClient.withCoreAPI().usingResource(document).addComment("New comment added by Manager"); restClient.withCoreAPI().usingResource(document).deleteComment(comment); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user can't delete comments created by admin user with Rest API and status code is 403") - public void collaboratorIsNotAbleToDeleteComments() throws JsonToModelConversionException, Exception + TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user deletes own comments and status code is 204") + public void collaboratorIsAbleToDeleteComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + comment = restClient.withCoreAPI().usingResource(document).addComment("New comment added by Collaborator"); restClient.withCoreAPI().usingResource(document).deleteComment(comment); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Contributor user can't delete comments created by admin user with Rest API and status code is 403") - public void contributorIsNotAbleToDeleteComments() throws JsonToModelConversionException, Exception + TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Contributor user deletes own comments and status code is 204") + public void contributorIsAbleToDeleteComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + comment = restClient.withCoreAPI().usingResource(document).addComment("New comment added by Contributor"); restClient.withCoreAPI().usingResource(document).deleteComment(comment); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Consumer user can't delete comments created by admin user with Rest API and status code is 403") - public void consumerIsNotAbleToDeleteComments() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.withCoreAPI().usingResource(document).deleteComment(comment); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } @TestRail(section = { TestGroup.REST_API, @@ -99,6 +82,7 @@ public class DeleteCommentsSanityTests extends RestTest { UserModel nonexistentModel = new UserModel("nonexistentUser", "nonexistentPassword"); restClient.authenticateUser(nonexistentModel); + comment = restClient.withCoreAPI().usingResource(document).addComment("New comment addded by Manager"); restClient.withCoreAPI().usingResource(document).deleteComment(comment); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } From 1b3f42896cc6c1574030b0911939f6491f44a478 Mon Sep 17 00:00:00 2001 From: cagache Date: Mon, 21 Nov 2016 09:49:31 +0200 Subject: [PATCH 0595/1491] Created getComments core scenarios --- e2e-test/java/org/alfresco/rest/RestTest.java | 9 +- .../rest/comments/GetCommentsCoreTests.java | 123 ++++++++++++++++++ 2 files changed, 127 insertions(+), 5 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/comments/GetCommentsCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/RestTest.java b/e2e-test/java/org/alfresco/rest/RestTest.java index 3691bae3c..ed8813179 100644 --- a/e2e-test/java/org/alfresco/rest/RestTest.java +++ b/e2e-test/java/org/alfresco/rest/RestTest.java @@ -6,11 +6,7 @@ import org.alfresco.rest.core.RestProperties; import org.alfresco.rest.core.RestWrapper; import org.alfresco.utility.LogFactory; import org.alfresco.utility.TasProperties; -import org.alfresco.utility.data.DataContent; -import org.alfresco.utility.data.DataGroup; -import org.alfresco.utility.data.DataSite; -import org.alfresco.utility.data.DataUser; -import org.alfresco.utility.data.DataWorkflow; +import org.alfresco.utility.data.*; import org.alfresco.utility.network.ServerHealth; import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; @@ -52,6 +48,9 @@ public abstract class RestTest extends AbstractTestNGSpringContextTests @Autowired protected DataWorkflow dataWorkflow; + @Autowired + protected DataLink dataLink; + @BeforeClass(alwaysRun = true) public void checkServerHealth() throws Exception { diff --git a/e2e-test/java/org/alfresco/rest/comments/GetCommentsCoreTests.java b/e2e-test/java/org/alfresco/rest/comments/GetCommentsCoreTests.java new file mode 100644 index 000000000..3e8dfad39 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/comments/GetCommentsCoreTests.java @@ -0,0 +1,123 @@ +package org.alfresco.rest.comments; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestCommentModelsCollection; +import org.alfresco.utility.model.*; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Created by Claudia Agache on 11/18/2016. + */ +@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) +public class GetCommentsCoreTests extends RestTest +{ + private UserModel adminUserModel, userModel; + private FileModel document; + private SiteModel siteModel; + private String comment = "This is a new comment"; + private String comment2 = "This is a 2nd comment"; + private String comment3 = "This is a 3rd comment"; + private RestCommentModelsCollection comments; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(adminUserModel).createPrivateRandomSite(); + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + restClient.authenticateUser(adminUserModel).withCoreAPI() + .usingResource(document).addComment(comment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.withCoreAPI().usingResource(document).addComment(comment2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.withCoreAPI().usingResource(document).addComment(comment3); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify invalid request returns status code 400 for invalid maxItems or skipCount") + public void checkStatusCodeForInvalidMaxItems() throws Exception + { + restClient.authenticateUser(adminUserModel).withParams("maxItems=0") + .withCoreAPI().usingResource(document).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(ErrorModel.INVALID_ARGUMENT); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify User can't get comments for node with ID that does not exist and status code is 404") + public void userCanNotGetCommentsOnNonexistentFile() throws Exception + { + FileModel nonexistentFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); + nonexistentFile.setNodeRef("ABC"); + restClient.authenticateUser(adminUserModel).withCoreAPI() + .usingResource(nonexistentFile).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, nonexistentFile.getNodeRef())); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify User can't get comments for node that exists but is not a document or a folder and status code is 400") + @Bug(id = "MNT-16904") + public void userCanNotGetCommentsOnLink() throws Exception + { + LinkModel link = dataLink.usingAdmin().usingSite(siteModel).createRandomLink(); + FileModel fileWithNodeRefFromLink = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); + fileWithNodeRefFromLink.setNodeRef(link.getNodeRef()); + restClient.authenticateUser(adminUserModel).withCoreAPI() + .usingResource(fileWithNodeRefFromLink).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(ErrorModel.UNABLE_TO_LOCATE); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify request returns status 403 if the user does not have permission read comments on the node") + public void uninvitedUserCanNotGetCommentsFromPrivateSite() throws Exception + { + restClient.authenticateUser(userModel).withCoreAPI() + .usingResource(document).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify user gets comments without the first 2 and status code is 200") + public void skipFirst2Comments() throws Exception + { + comments = restClient.authenticateUser(adminUserModel).withParams("skipCount=2") + .withCoreAPI().usingResource(document).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", comment) + .and().paginationField("count").is("1"); + comments.assertThat().paginationField("skipCount").is("2"); + comments.assertThat().paginationField("totalItems").is("3"); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify get comments from node with invalid network id returns status code 401") + @Bug(id = "MNT-16904") + public void getCommentsWithInvalidNetwork() throws Exception + { + userModel.setDomain("invalidNetwork"); + restClient.authenticateUser(userModel).withCoreAPI().usingResource(document).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify get comments from node with empty network id returns status code 401") + @Bug(id = "MNT-16904") + public void getCommentsWithEmptyNetwork() throws Exception + { + userModel.setDomain(""); + restClient.authenticateUser(userModel).withCoreAPI().usingResource(document).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + } + +} From 0f7e2afea7101c625fc14837ab880e87efa3c83d Mon Sep 17 00:00:00 2001 From: cagache Date: Mon, 21 Nov 2016 09:49:51 +0200 Subject: [PATCH 0596/1491] updated tests to verify first status code --- .../rest/comments/GetCommentsSanityTests.java | 76 +++++++++---------- 1 file changed, 37 insertions(+), 39 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java index 4c6d435eb..6265d073c 100644 --- a/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java @@ -3,12 +3,10 @@ package org.alfresco.rest.comments; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestCommentModelsCollection; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.model.*; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; @@ -25,17 +23,17 @@ public class GetCommentsSanityTests extends RestTest private SiteModel siteModel; private UserModel userModel; private ListUserWithRoles usersWithRoles; - private String content; + private String content = "This is a new comment"; + private RestCommentModelsCollection comments; @BeforeClass(alwaysRun=true) public void dataPreparation() throws Exception { adminUserModel = dataUser.getAdminUser(); - restClient.authenticateUser(adminUserModel); siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - content = "This is a new comment"; - restClient.withCoreAPI().usingResource(document).addComment(content); + restClient.authenticateUser(adminUserModel).withCoreAPI() + .usingResource(document).addComment(content); usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); } @@ -44,51 +42,50 @@ public class GetCommentsSanityTests extends RestTest description= "Verify Admin user gets comments with Rest API and status code is 200") public void adminIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(adminUserModel); - restClient.withCoreAPI().usingResource(document).getNodeComments(); + comments = restClient.authenticateUser(adminUserModel).withCoreAPI() + .usingResource(document).getNodeComments(); restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", content); } @TestRail(section={TestGroup.REST_API, TestGroup.SANITY}, executionType= ExecutionType.SANITY, description= "Verify Manager user gets comments created by admin user with Rest API and status code is 200") public void managerIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingResource(document).getNodeComments() - .assertThat().entriesListContains("content", content); - + comments = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI() + .usingResource(document).getNodeComments(); restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", content); } @TestRail(section={TestGroup.REST_API, TestGroup.SANITY}, executionType= ExecutionType.SANITY, description= "Verify Contributor user gets comments created by admin user with Rest API and status code is 200") public void contributorIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - restClient.withCoreAPI().usingResource(document).getNodeComments() - .assertThat().entriesListContains("content", content); - + comments = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI() + .usingResource(document).getNodeComments(); restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", content); } @TestRail(section={TestGroup.REST_API, TestGroup.SANITY}, executionType= ExecutionType.SANITY, description= "Verify Collaborator user gets comments created by admin user with Rest API and status code is 200") public void collaboratorIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.withCoreAPI().usingResource(document).getNodeComments() - .assertThat().entriesListContains("content", content); + comments = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI() + .usingResource(document).getNodeComments(); restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", content); } @TestRail(section={TestGroup.REST_API, TestGroup.SANITY}, executionType= ExecutionType.SANITY, description= "Verify Consumer user gets comments created by admin user with Rest API and status code is 200") public void consumerIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.withCoreAPI().usingResource(document).getNodeComments() - .assertThat().entriesListContains("content", content); + comments = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI() + .usingResource(document).getNodeComments(); restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", content); } @TestRail(section={TestGroup.REST_API, TestGroup.SANITY}, executionType= ExecutionType.SANITY, @@ -97,9 +94,10 @@ public class GetCommentsSanityTests extends RestTest public void managerIsNotAbleToRetrieveCommentIfAuthenticationFails() throws JsonToModelConversionException, Exception { UserModel nonexistentModel = new UserModel("nonexistentUser", "nonexistentPassword"); - restClient.authenticateUser(nonexistentModel); - restClient.withCoreAPI().usingResource(document).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.authenticateUser(nonexistentModel).withCoreAPI() + .usingResource(document).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastException().hasName(StatusModel.UNAUTHORIZED); } @TestRail(section={TestGroup.REST_API, TestGroup.SANITY}, executionType= ExecutionType.SANITY, @@ -107,15 +105,15 @@ public class GetCommentsSanityTests extends RestTest public void managerIsAbleToRetrieveCommentsCreatedByAnotherUser() throws JsonToModelConversionException, Exception { userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); - restClient.authenticateUser(userModel); String contentManager = "This is a new comment added by " + userModel.getUsername(); - restClient.withCoreAPI().usingResource(document).addComment(contentManager); + restClient.authenticateUser(userModel).withCoreAPI() + .usingResource(document).addComment(contentManager); restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingResource(document).getNodeComments() - .assertThat().entriesListContains("content", contentManager); - + comments = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI() + .usingResource(document).getNodeComments(); restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", contentManager) + .and().entriesListContains("content", content); } @TestRail(section={TestGroup.REST_API, TestGroup.SANITY}, executionType= ExecutionType.SANITY, @@ -123,14 +121,14 @@ public class GetCommentsSanityTests extends RestTest public void adminIsAbleToRetrieveCommentsCreatedByAnotherUser() throws JsonToModelConversionException, Exception { userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); - restClient.authenticateUser(userModel); String contentCollaborator = "This is a new comment added by " + userModel.getUsername(); - restClient.withCoreAPI().usingResource(document).addComment(contentCollaborator); + restClient.authenticateUser(userModel).withCoreAPI() + .usingResource(document).addComment(contentCollaborator); restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.authenticateUser(adminUserModel); - restClient.withCoreAPI().usingResource(document).getNodeComments() - .assertThat().entriesListContains("content", contentCollaborator); - + comments = restClient.authenticateUser(adminUserModel).withCoreAPI() + .usingResource(document).getNodeComments(); restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", contentCollaborator) + .and().entriesListContains("content", content); } } From d92378a8ba265a8818b751cb41ac3f3af50814bb Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Mon, 21 Nov 2016 15:56:39 +0200 Subject: [PATCH 0597/1491] Added Core-REST API tests: updateComment --- .../comments/UpdateCommentsCoreTests.java | 107 ++++++++++++++++++ .../comments/UpdateCommentsSanityTests.java | 22 ++-- 2 files changed, 120 insertions(+), 9 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/comments/UpdateCommentsCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsCoreTests.java b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsCoreTests.java new file mode 100644 index 000000000..a314e0502 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsCoreTests.java @@ -0,0 +1,107 @@ +package org.alfresco.rest.comments; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestCommentModel; +import org.alfresco.rest.model.RestCommentModelsCollection; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FileType; +import org.alfresco.utility.model.LinkModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) +public class UpdateCommentsCoreTests extends RestTest +{ + private UserModel adminUserModel; + private FileModel document; + private SiteModel siteModel; + private RestCommentModel commentModel; + private ListUserWithRoles usersWithRoles; + private RestCommentModelsCollection comments; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + restClient.authenticateUser(adminUserModel); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.SANITY }, executionType = ExecutionType.SANITY, description = "Verify can not update comment if NodeId is neither document or folder and returns status code 405") + @Bug(id="MNT-16904") + public void canNotUpdateCommentIfNodeIdIsNeitherDoumentOrFolder() throws JsonToModelConversionException, Exception + { + FileModel content = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); + content = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(adminUserModel); + commentModel = restClient.withCoreAPI().usingResource(content).addComment("This is a new comment"); + + LinkModel link = dataLink.usingAdmin().usingSite(siteModel).createRandomLink(); + content.setNodeRef(link.getNodeRef()); + + restClient.withCoreAPI().usingResource(content).updateComment(commentModel, "This is the updated comment."); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) + .assertLastError().containsSummary("node ref that does not exist was not found"); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Admin user is not able to update with empty comment body and status code is 400") + public void adminIsNotAbleToUpdateWithEptyCommentBody() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel); + commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by admin"); + restClient.withCoreAPI().usingResource(document).updateComment(commentModel, ""); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary("An invalid argument was received"); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify updated comment by Manager is listed when calling getComments and status code is 200") + @Bug(id="REPO-1011") + public void updatedCommentByManagerIsListed() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by collaborator"); + restClient.withCoreAPI().usingResource(document).updateComment(commentModel, "This is the updated comment with Collaborator user"); + comments = restClient.withCoreAPI().usingResource(document).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", "This is the updated comment with Collaborator user"); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user can update comments of another user and status code is 200") + public void collaboratorIsAbleToUpdateCommentOfAnotherUser() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel); + commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by admin"); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + restClient.withCoreAPI().usingResource(document).updateComment(commentModel, "This is the updated comment with Collaborator user"); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify entry content in response") + public void checkEntryContentInResponse() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel); + commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by admin"); + commentModel = restClient.withCoreAPI().usingResource(document).updateComment(commentModel, "This is the updated comment with admin user"); + restClient.assertStatusCodeIs(HttpStatus.OK); + commentModel.assertThat().field("content").is("This is the updated comment with admin user"); + } +} diff --git a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java index 2e65953ff..3c762ba94 100644 --- a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java @@ -36,8 +36,6 @@ public class UpdateCommentsSanityTests extends RestTest siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment"); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); } @@ -46,6 +44,7 @@ public class UpdateCommentsSanityTests extends RestTest public void adminIsAbleToUpdateComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); + commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by admin"); String updatedContent = "This is the updated comment with admin user"; restClient.withCoreAPI().usingResource(document).updateComment(commentModel, updatedContent) .assertThat().field("content").isNotEmpty() @@ -58,6 +57,7 @@ public class UpdateCommentsSanityTests extends RestTest public void managerIsAbleToUpdateComment() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by manager"); restClient.withCoreAPI().usingResource(document).updateComment(commentModel, "This is the updated comment with Manager user") .and().field("content").is("This is the updated comment with Manager user") .and().field("canEdit").is(true) @@ -66,20 +66,22 @@ public class UpdateCommentsSanityTests extends RestTest } @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Contributor user can not update comments created by admin user and status code is 403") - public void contributorIsNotAbleToUpdateComment() throws JsonToModelConversionException, Exception + TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Contributor user can update his own comment and status code is 200") + public void contributorIsAbleToUpdateComment() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by contributor"); String updatedContent = "This is the updated comment with Contributor user"; restClient.withCoreAPI().usingResource(document).updateComment(commentModel, updatedContent); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Consumer user can not update comments created by admin user and status code is 403") public void consumerIsNotAbleToUpdateComment() throws JsonToModelConversionException, Exception { + restClient.authenticateUser(adminUserModel); + commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by admin"); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); restClient.withCoreAPI().usingResource(document).updateComment(commentModel, "This is the updated comment with Consumer user"); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) @@ -87,13 +89,14 @@ public class UpdateCommentsSanityTests extends RestTest } @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user can not update comment created by admin user and status code is 403") + TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user can update his own comment and status code is 200") @Bug(id="REPO-1011") - public void collaboratorIsNotAbleToUpdateComment() throws JsonToModelConversionException, Exception + public void collaboratorIsAbleToUpdateComment() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by collaborator"); restClient.withCoreAPI().usingResource(document).updateComment(commentModel, "This is the updated comment with Collaborator user"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, @@ -114,6 +117,7 @@ public class UpdateCommentsSanityTests extends RestTest FolderModel content = FolderModel.getRandomFolderModel(); content.setNodeRef("node ref that does not exist"); + commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment"); restClient.withCoreAPI().usingResource(content).updateComment(commentModel, "This is the updated comment."); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) .assertLastError().containsSummary("node ref that does not exist was not found"); From ad6b0cc9d4f22ca13ac280a08bccc3efd779aad9 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Mon, 21 Nov 2016 16:02:31 +0200 Subject: [PATCH 0598/1491] CORE-REST API: postComments --- .../rest/comments/AddCommentCoreTests.java | 176 ++++++++++++++++++ 1 file changed, 176 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/comments/AddCommentCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentCoreTests.java b/e2e-test/java/org/alfresco/rest/comments/AddCommentCoreTests.java new file mode 100644 index 000000000..00d624fab --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/comments/AddCommentCoreTests.java @@ -0,0 +1,176 @@ +package org.alfresco.rest.comments; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestCommentModel; +import org.alfresco.rest.model.RestCommentModelsCollection; +import org.alfresco.rest.model.RestTagModel; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.data.RandomData; +import org.alfresco.utility.model.ErrorModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FileType; +import org.alfresco.utility.model.LinkModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.apache.commons.lang.RandomStringUtils; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) +public class AddCommentCoreTests extends RestTest +{ + private UserModel adminUserModel; + private FileModel document; + private SiteModel siteModel; + private DataUser.ListUserWithRoles usersWithRoles; + private String comment; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + restClient.authenticateUser(adminUserModel); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, + UserRole.SiteConsumer, UserRole.SiteContributor); + } + + @BeforeMethod(alwaysRun = true) + public void setUp() + { + comment = RandomData.getRandomName("comment1"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, + description = "Verify that invalid request returns status code 404 for nodeId that does not exist") + public void addCommentUsingInvalidNodeId() throws JsonToModelConversionException, Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + file.setNodeRef(RandomStringUtils.randomAlphanumeric(20)); + + restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingResource(file).addComment(comment); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, file.getNodeRef())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, + description = "Verify that request using nodeId that is neither document or folder returns 405") + @Bug(id = "MNT-16904") + public void addCommentUsingResourceThatIsNotFileOrFolder() throws JsonToModelConversionException, Exception + { + LinkModel link = dataLink.usingAdmin().usingSite(siteModel).createRandomLink(); + FileModel fileWithNodeRefFromLink = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); + fileWithNodeRefFromLink = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + fileWithNodeRefFromLink.setNodeRef(link.getNodeRef()); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(fileWithNodeRefFromLink).addComment(comment); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, + description = "Verify that adding comment using empty content returns 400 status code") + public void addCommentUsingEmptyContent() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingResource(document).addComment(""); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(ErrorModel.NULL_ARGUMENT, "comment")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, + description = "Verify adding comment with the same content as one existing comment") + public void addCommentTwice() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingResource(document).addComment(comment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingResource(document).addComment(comment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.withCoreAPI().usingResource(document).getNodeComments() + .assertThat().entriesListContains("content", comment); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, + description = "Verify that comment can be retrieved after it is added") + public void addCommentThenRetrieveComment() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingResource(document).addComment(comment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestCommentModelsCollection comments = restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingResource(document).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + comments.assertThat().entriesListContains("content", comment); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, + description = "Verify comment cannot be added if user is not member of private site") + public void addCommentWithNonMemberOfPrivateSite() throws JsonToModelConversionException, Exception + { + UserModel member = dataUser.createRandomTestUser(); + SiteModel privateSite = dataSite.usingUser(adminUserModel).createPrivateRandomSite(); + FileModel file = dataContent.usingSite(privateSite).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(member) + .withCoreAPI().usingResource(file).addComment(comment); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, + description = "Verify comment cannot be added if empty network ID is provided") + @Bug(id = "MNT-16904") + public void addCommentUsingEmptyNetworkId() throws JsonToModelConversionException, Exception + { + UserModel member = dataUser.createRandomTestUser(); + member.setDomain(""); + + restClient.authenticateUser(member) + .withCoreAPI().usingResource(document).addComment(comment); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, + description = "Verify that comment cannot be added to another comment") + public void addCommentToAComment() throws JsonToModelConversionException, Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + RestCommentModel commentEntry = restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingResource(file).addComment(comment); + file.setNodeRef(commentEntry.getId()); + + restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingResource(file).addComment(comment); + + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(ErrorModel.CANNOT_COMMENT); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, + description = "Verify that comment cannot be added to a tag") + public void addCommentToATag() throws JsonToModelConversionException, Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag("randomTag"); + + file.setNodeRef(tag.getId()); + + restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingResource(file).addComment(comment); + + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(ErrorModel.CANNOT_COMMENT); + } +} \ No newline at end of file From fe97dcc961a5e166e80bdbb1709218d45f472407 Mon Sep 17 00:00:00 2001 From: cagache Date: Mon, 21 Nov 2016 16:28:08 +0200 Subject: [PATCH 0599/1491] added core tests for getFavorites call --- .../rest/comments/GetCommentsCoreTests.java | 2 +- .../rest/favorites/GetFavoritesCoreTests.java | 242 ++++++++++++++++++ .../favorites/GetFavoritesSanityTests.java | 18 +- 3 files changed, 251 insertions(+), 11 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/favorites/GetFavoritesCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/comments/GetCommentsCoreTests.java b/e2e-test/java/org/alfresco/rest/comments/GetCommentsCoreTests.java index 3e8dfad39..b0ff5e71c 100644 --- a/e2e-test/java/org/alfresco/rest/comments/GetCommentsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/GetCommentsCoreTests.java @@ -48,7 +48,7 @@ public class GetCommentsCoreTests extends RestTest restClient.authenticateUser(adminUserModel).withParams("maxItems=0") .withCoreAPI().usingResource(document).getNodeComments(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(ErrorModel.INVALID_ARGUMENT); + .assertLastError().containsSummary(String.format(ErrorModel.INVALID_ARGUMENT, "argument")); } @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesCoreTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesCoreTests.java new file mode 100644 index 000000000..a57e6b186 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesCoreTests.java @@ -0,0 +1,242 @@ +package org.alfresco.rest.favorites; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestPersonFavoritesModelsCollection; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.model.*; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Created by Claudia Agache on 11/21/2016. + */ +@Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) +public class GetFavoritesCoreTests extends RestTest +{ + private UserModel adminUserModel; + private SiteModel firstSiteModel, secondSiteModel; + private FileModel firstFileModel, secondFileModel; + private FolderModel firstFolderModel, secondFolderModel; + private DataUser.ListUserWithRoles usersWithRoles; + private RestPersonFavoritesModelsCollection userFavorites; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + restClient.authenticateUser(adminUserModel); + firstSiteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + secondSiteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + firstFolderModel = dataContent.usingUser(adminUserModel).usingSite(firstSiteModel).createFolder(); + secondFolderModel = dataContent.usingUser(adminUserModel).usingSite(firstSiteModel).createFolder(); + firstFileModel = dataContent.usingUser(adminUserModel).usingResource(firstFolderModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + secondFileModel = dataContent.usingUser(adminUserModel).usingResource(firstFolderModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + + firstSiteModel.setGuid(restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(firstSiteModel).getSite().getGuid()); + secondSiteModel.setGuid(restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(secondSiteModel).getSite().getGuid()); + + usersWithRoles = dataUser.addUsersWithRolesToSite(firstSiteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify User gets only favorites sites with Rest API and status code is 200") + public void userIsAbleToRetrieveOnlyFavoritesSites() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); + restClient.withCoreAPI().usingAuthUser().addFileToFavorites(firstFileModel); + restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(firstFolderModel); + + userFavorites = restClient.withCoreAPI().usingAuthUser().where().targetSiteExist().getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + userFavorites.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) + .and().entriesListDoesNotContain("targetGuid", secondSiteModel.getGuid()) + .and().entriesListDoesNotContain("targetGuid", firstFileModel.getNodeRefWithoutVersion()) + .and().entriesListDoesNotContain("targetGuid", firstFolderModel.getNodeRef()); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify User gets only favorites files with Rest API and status code is 200") + public void userIsAbleToRetrieveOnlyFavoritesFiles() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); + restClient.withCoreAPI().usingAuthUser().addFileToFavorites(firstFileModel); + restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(firstFolderModel); + + userFavorites = restClient.withCoreAPI().usingAuthUser().where().targetFileExist().getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + userFavorites.assertThat().entriesListContains("targetGuid", firstFileModel.getNodeRefWithoutVersion()) + .and().entriesListDoesNotContain("targetGuid", secondFileModel.getNodeRefWithoutVersion()) + .and().entriesListDoesNotContain("targetGuid", firstSiteModel.getGuid()) + .and().entriesListDoesNotContain("targetGuid", firstFolderModel.getNodeRef()); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify User gets only favorites folders with Rest API and status code is 200") + public void userIsAbleToRetrieveOnlyFavoritesFolders() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); + restClient.withCoreAPI().usingAuthUser().addFileToFavorites(firstFileModel); + restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(firstFolderModel); + + userFavorites = restClient.withCoreAPI().usingAuthUser().where().targetFolderExist().getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + userFavorites.assertThat().entriesListContains("targetGuid", firstFolderModel.getNodeRef()) + .and().entriesListDoesNotContain("targetGuid", secondFolderModel.getNodeRef()) + .and().entriesListDoesNotContain("targetGuid", firstSiteModel.getGuid()) + .and().entriesListDoesNotContain("targetGuid", firstFileModel.getNodeRefWithoutVersion()); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify User gets only favorites files or folders with Rest API and status code is 200") + public void userIsAbleToRetrieveFavoritesFilesOrFolders() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); + restClient.withCoreAPI().usingAuthUser().addFileToFavorites(firstFileModel); + restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(firstFolderModel); + + userFavorites = restClient.withCoreAPI().usingAuthUser() + .where().targetFolderExist().or().targetFileExist() + .getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + userFavorites.assertThat().entriesListContains("targetGuid", firstFolderModel.getNodeRef()) + .and().entriesListContains("targetGuid", firstFileModel.getNodeRefWithoutVersion()) + .and().entriesListDoesNotContain("targetGuid", secondFolderModel.getNodeRef()) + .and().entriesListDoesNotContain("targetGuid", secondFileModel.getNodeRefWithoutVersion()) + .and().entriesListDoesNotContain("targetGuid", firstSiteModel.getGuid()); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify User gets only favorites files or sites with Rest API and status code is 200") + public void userIsAbleToRetrieveFavoritesFilesOrSites() throws Exception + { + restClient.authenticateUser(adminUserModel); + restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); + restClient.withCoreAPI().usingAuthUser().addFileToFavorites(firstFileModel); + restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(firstFolderModel); + + userFavorites = restClient.withCoreAPI().usingAuthUser() + .where().targetSiteExist().or().targetFileExist() + .getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + userFavorites.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) + .and().entriesListContains("targetGuid", firstFileModel.getNodeRefWithoutVersion()) + .and().entriesListDoesNotContain("targetGuid", secondSiteModel.getGuid()) + .and().entriesListDoesNotContain("targetGuid", secondFileModel.getNodeRefWithoutVersion()) + .and().entriesListDoesNotContain("targetGuid", firstFolderModel.getNodeRef()); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify User gets only favorites folders or sites with Rest API and status code is 200") + public void userIsAbleToRetrieveFavoritesFoldersOrSites() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); + restClient.withCoreAPI().usingAuthUser().addFileToFavorites(firstFileModel); + restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(firstFolderModel); + + userFavorites = restClient.withCoreAPI().usingAuthUser() + .where().targetSiteExist().or().targetFolderExist() + .getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + userFavorites.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) + .and().entriesListContains("targetGuid", firstFolderModel.getNodeRef()) + .and().entriesListDoesNotContain("targetGuid", secondSiteModel.getGuid()) + .and().entriesListDoesNotContain("targetGuid", secondFolderModel.getNodeRef()) + .and().entriesListDoesNotContain("targetGuid", firstFileModel.getNodeRefWithoutVersion()); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify User gets all favorites with Rest API and status code is 200") + public void userIsAbleToRetrieveAllFavorites() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); + restClient.withCoreAPI().usingAuthUser().addFileToFavorites(firstFileModel); + restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(firstFolderModel); + + userFavorites = restClient.withCoreAPI().usingAuthUser() + .where().targetSiteExist().or().targetFolderExist().or().targetFileExist() + .getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + userFavorites.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) + .and().entriesListContains("targetGuid", firstFolderModel.getNodeRef()) + .and().entriesListContains("targetGuid", firstFileModel.getNodeRefWithoutVersion()) + .and().entriesListDoesNotContain("targetGuid", secondSiteModel.getGuid()) + .and().entriesListDoesNotContain("targetGuid", secondFolderModel.getNodeRef()) + .and().entriesListDoesNotContain("targetGuid", secondFileModel.getNodeRefWithoutVersion()); + + userFavorites = restClient.withCoreAPI().usingAuthUser().getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + userFavorites.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) + .and().entriesListContains("targetGuid", firstFolderModel.getNodeRef()) + .and().entriesListContains("targetGuid", firstFileModel.getNodeRefWithoutVersion()) + .and().entriesListDoesNotContain("targetGuid", secondSiteModel.getGuid()) + .and().entriesListDoesNotContain("targetGuid", secondFolderModel.getNodeRef()) + .and().entriesListDoesNotContain("targetGuid", secondFileModel.getNodeRefWithoutVersion()); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify request using invalid where parameter returns status 400") + public void getFavoritesUsingInvalidWhereParameter() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); + restClient.withCoreAPI().usingAuthUser().addFileToFavorites(firstFileModel); + restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(firstFolderModel); + + userFavorites = restClient.withCoreAPI().usingAuthUser() + .where().or().getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(ErrorModel.INVALID_ARGUMENT, "WHERE query")); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify request for a user with no favorites returns status 200") + public void userHasNoFavorites() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + + userFavorites = restClient.withCoreAPI().usingAuthUser().getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + userFavorites.assertThat().entriesListIsEmpty().and().paginationField("totalItems").is("0"); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify User gets correct favorites after deleting a favorite") + public void checkFavoriteFolderIsRemoved() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); + restClient.withCoreAPI().usingAuthUser().addFileToFavorites(firstFileModel); + restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(firstFolderModel); + + restClient.withCoreAPI().usingAuthUser().deleteFolderFromFavorites(firstFolderModel); + + userFavorites = restClient.withCoreAPI().usingAuthUser().getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + userFavorites.assertThat().entriesListDoesNotContain("targetGuid", firstFolderModel.getNodeRef()) + .and().paginationField("totalItems").is("2"); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify request using personId that does not exist returns status 404") + public void checkFavoritesWhenPersonIdDoesNotExist() throws Exception + { + UserModel someUser = new UserModel("someUser", "somePass"); + + restClient.authenticateUser(adminUserModel).withCoreAPI() + .usingUser(someUser).getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, "personId is null.")); + } +} diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java index fccb89730..0eeab7df4 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java @@ -98,7 +98,7 @@ public class GetFavoritesSanityTests extends RestTest restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(secondSiteModel); - restPersonFavoritesModelsCollection = restClient.withCoreAPI().usingAuthUser().where().targetSiteExist().getFavorites(); + restPersonFavoritesModelsCollection = restClient.withCoreAPI().usingAuthUser().getFavorites(); restClient.assertStatusCodeIs(HttpStatus.OK); restPersonFavoritesModelsCollection.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) .assertThat().entriesListContains("targetGuid", secondSiteModel.getGuid()); @@ -112,7 +112,7 @@ public class GetFavoritesSanityTests extends RestTest .withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(secondSiteModel); - restPersonFavoritesModelsCollection = restClient.withCoreAPI().usingAuthUser().where().targetSiteExist().getFavorites(); + restPersonFavoritesModelsCollection = restClient.withCoreAPI().usingAuthUser().getFavorites(); restClient.assertStatusCodeIs(HttpStatus.OK); restPersonFavoritesModelsCollection.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) .and().entriesListContains("targetGuid", secondSiteModel.getGuid()); @@ -126,7 +126,7 @@ public class GetFavoritesSanityTests extends RestTest .withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(secondSiteModel); - restPersonFavoritesModelsCollection = restClient.withCoreAPI().usingAuthUser().where().targetSiteExist().getFavorites(); + restPersonFavoritesModelsCollection = restClient.withCoreAPI().usingAuthUser().getFavorites(); restClient.assertStatusCodeIs(HttpStatus.OK); restPersonFavoritesModelsCollection.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()).and() .entriesListContains("targetGuid", secondSiteModel.getGuid()); @@ -140,7 +140,7 @@ public class GetFavoritesSanityTests extends RestTest .withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(secondSiteModel); - restPersonFavoritesModelsCollection = restClient.withCoreAPI().usingAuthUser().where().targetSiteExist().getFavorites(); + restPersonFavoritesModelsCollection = restClient.withCoreAPI().usingAuthUser().getFavorites(); restClient.assertStatusCodeIs(HttpStatus.OK); restPersonFavoritesModelsCollection.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) .assertThat().entriesListContains("targetGuid", secondSiteModel.getGuid()); @@ -151,8 +151,7 @@ public class GetFavoritesSanityTests extends RestTest public void userIsNotAbleToRetrieveFavoritesOfAnotherUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .withCoreAPI().usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).where() - .targetSiteExist().getFavorites(); + .withCoreAPI().usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).getFavorites(); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator).getUsername())); } @@ -162,7 +161,7 @@ public class GetFavoritesSanityTests extends RestTest public void userIsNotAbleToRetrieveFavoritesOfAdminUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI() - .usingUser(adminUserModel).where().targetSiteExist().getFavorites(); + .usingUser(adminUserModel).getFavorites(); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, adminUserModel.getUsername())); } @@ -172,7 +171,7 @@ public class GetFavoritesSanityTests extends RestTest public void adminIsNotAbleToRetrieveFavoritesOfAnotherUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .where().targetSiteExist().getFavorites(); + .getFavorites(); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator).getUsername())); } @@ -184,8 +183,7 @@ public class GetFavoritesSanityTests extends RestTest { UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); siteManager.setPassword("wrongPassword"); - restClient.authenticateUser(siteManager).withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); - restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(secondSiteModel); + restClient.authenticateUser(siteManager).withCoreAPI().usingAuthUser().getFavorites(); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } From 4d009e71c95c2e8971811433c45bc95b3a906c1f Mon Sep 17 00:00:00 2001 From: cagache Date: Tue, 22 Nov 2016 13:24:45 +0200 Subject: [PATCH 0600/1491] added core tests for getFavoriteSite --- .../rest/people/GetFavoriteSiteCoreTests.java | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteCoreTests.java b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteCoreTests.java new file mode 100644 index 000000000..06530bd58 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteCoreTests.java @@ -0,0 +1,67 @@ +package org.alfresco.rest.people; + +import org.alfresco.rest.RestTest; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.model.ErrorModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Created by Claudia Agache on 11/22/2016. + */ +@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) +public class GetFavoriteSiteCoreTests extends RestTest +{ + UserModel userModel; + SiteModel site1; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + site1 = dataSite.usingUser(userModel).createPublicRandomSite(); + dataSite.usingUser(userModel).usingSite(site1).addSiteToFavorites(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, + description = "Verify invalid request returns status 404 when personId does not exist") + public void getFavoriteSiteWithNonExistentPersonId() throws Exception + { + UserModel someUser = new UserModel("someUser", DataUser.PASSWORD); + + restClient.authenticateUser(userModel).withCoreAPI().usingUser(someUser).getFavoriteSite(site1); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, "someUser")); + } + + @Bug(id="MNT-17146") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, + description = "Verify invalid request returns status 404 when siteId does not exist") + public void getFavoriteSiteWithNonExistentSiteId() throws Exception + { + SiteModel nonExistentSite = new SiteModel("nonExistentSite"); + + restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().getFavoriteSite(nonExistentSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(ErrorModel.RELATIONSHIP_NOT_FOUND, userModel.getUsername(), nonExistentSite.getId())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, + description = "Verify User fails to get specific favorite site of admin with Rest API and response is 403") + public void userFailsToGetFavoriteSiteOfAdmin() throws Exception + { + restClient.authenticateUser(userModel).withCoreAPI().usingUser(dataUser.getAdminUser()).getFavoriteSite(site1); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + } +} From 275cb3912ac3472f59f55c4b42bb4b887fea976b Mon Sep 17 00:00:00 2001 From: cagache Date: Tue, 22 Nov 2016 13:25:07 +0200 Subject: [PATCH 0601/1491] added bug annotation --- .../org/alfresco/rest/favorites/GetFavoritesCoreTests.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesCoreTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesCoreTests.java index a57e6b186..52e8f7e43 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesCoreTests.java @@ -6,6 +6,7 @@ import org.alfresco.rest.model.RestPersonFavoritesModelsCollection; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.model.*; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -228,15 +229,16 @@ public class GetFavoritesCoreTests extends RestTest .and().paginationField("totalItems").is("2"); } + @Bug(id="MNT-17146") @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify request using personId that does not exist returns status 404") public void checkFavoritesWhenPersonIdDoesNotExist() throws Exception { - UserModel someUser = new UserModel("someUser", "somePass"); + UserModel someUser = new UserModel("someUser", DataUser.PASSWORD); restClient.authenticateUser(adminUserModel).withCoreAPI() .usingUser(someUser).getFavorites(); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, "personId is null.")); + .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, "someUser")); } } From 5266b063ebde1f96155af7f85a79ca386313babd Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Tue, 22 Nov 2016 16:29:52 +0200 Subject: [PATCH 0602/1491] Added Core tests: deleteFavoriteSite --- .../people/DeleteFavoriteSiteCoreTests.java | 132 ++++++++++++++++++ 1 file changed, 132 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteCoreTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteCoreTests.java new file mode 100644 index 000000000..7aa1d952a --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteCoreTests.java @@ -0,0 +1,132 @@ +package org.alfresco.rest.people; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestSiteModel; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.model.ErrorModel; +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; + +@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) +public class DeleteFavoriteSiteCoreTests extends RestTest +{ + UserModel userModel; + SiteModel siteModel; + UserModel adminUserModel; + RestSiteModel restSiteModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + adminUserModel = dataUser.getAdminUser(); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify user removes a site from favorites using '-me-' in place of personId with Rest API and response is successful (204)") + public void removeFavoriteSiteWithSuccessUsingMeAsPersonId() throws Exception + { + restClient.authenticateUser(adminUserModel); + dataSite.usingUser(adminUserModel).usingSite(siteModel).addSiteToFavorites(); + + restClient.withCoreAPI().usingMe().removeFavoriteSite(siteModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify inexistent user is not able to remove a site from favorites and response is 404") + public void inexistentUserIsNotAbleToRemoveFavoriteSite() throws Exception + { + restClient.authenticateUser(adminUserModel); + dataSite.usingUser(adminUserModel).usingSite(siteModel).addSiteToFavorites(); + + UserModel inexistentUser = new UserModel("inexistenUser", "password"); + restClient.withCoreAPI().usingUser(inexistentUser).removeFavoriteSite(siteModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, "inexistenUser")); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify user is not able to remove from favorites a site with inexistent id and response is 404") + public void userIsNotAbleToRemoveFavoriteSiteWithInexistentId() throws Exception + { + restClient.authenticateUser(adminUserModel); + dataSite.usingUser(adminUserModel).usingSite(siteModel).addSiteToFavorites(); + + SiteModel inexistentSite = new SiteModel("inexistentSite"); + restClient.withCoreAPI().usingUser(adminUserModel).removeFavoriteSite(inexistentSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(ErrorModel.RELATIONSHIP_NOT_FOUND, adminUserModel.getUsername(), inexistentSite.getTitle())); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user removes a site from its favorites abd add it again and response is successful (204)") + public void managerUserRemovesFavoriteSiteAndAddItAgain() throws Exception + { + UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); + dataSite.usingUser(managerUser).usingSite(siteModel).addSiteToFavorites(); + + restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withCoreAPI().usingUser(managerUser).addFavoriteSite(siteModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user removes a site from its favorite sites list with Rest API and response is successful (204)") + public void managerUserRemovesFavoriteSiteWithSuccess() throws Exception + { + UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); + dataSite.usingUser(managerUser).usingSite(siteModel).addSiteToFavorites(); + + restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withCoreAPI().usingAuthUser().getFavorites().assertThat().entriesListDoesNotContain("id", siteModel.getId()); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify uninvited user can delete favorite public site and response is 204") + public void uninvitedUserCanDeleteFavoritePublicSite() throws Exception + { + SiteModel publicSiteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + restClient.authenticateUser(userModel).withCoreAPI().usingUser(userModel).addFavoriteSite(publicSiteModel); + + restClient.withCoreAPI().usingAuthUser().removeFavoriteSite(publicSiteModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withCoreAPI().usingAuthUser().getFavoriteSites().assertThat().entriesListDoesNotContain("id", publicSiteModel.getId()); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify uninvited user can delete favorite moderated site and response is 204") + public void uninvitedUserCanDeleteFavoriteModeratedSite() throws Exception + { + SiteModel moderatedSiteModel = dataSite.usingUser(adminUserModel).createModeratedRandomSite(); + restClient.authenticateUser(userModel).withCoreAPI().usingUser(userModel).addFavoriteSite(moderatedSiteModel); + + restClient.withCoreAPI().usingAuthUser().removeFavoriteSite(moderatedSiteModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withCoreAPI().usingAuthUser().getFavoriteSites().assertThat().entriesListDoesNotContain("id", moderatedSiteModel.getId()); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify user can delete favorite private site and response is 204") + public void userCanDeleteFavoritePrivateSite() throws Exception + { + SiteModel privateSiteModel = dataSite.usingUser(userModel).createPrivateRandomSite(); + restClient.authenticateUser(userModel).withCoreAPI().usingUser(userModel).addFavoriteSite(privateSiteModel); + + restClient.withCoreAPI().usingAuthUser().removeFavoriteSite(privateSiteModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withCoreAPI().usingAuthUser().getFavoriteSites().assertThat().entriesListDoesNotContain("id", privateSiteModel.getId()); + } + +} From a52bddb3d865cd7ce4b786b06bfe8bb644ce7170 Mon Sep 17 00:00:00 2001 From: cagache Date: Tue, 22 Nov 2016 17:22:49 +0200 Subject: [PATCH 0603/1491] added core tests for getSites --- .../rest/sites/GetSitesCoreTests.java | 130 ++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java new file mode 100644 index 000000000..cba567e89 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java @@ -0,0 +1,130 @@ +package org.alfresco.rest.sites; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestSiteModel; +import org.alfresco.rest.model.RestSiteModelsCollection; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.RandomData; +import org.alfresco.utility.model.ErrorModel; +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.springframework.social.alfresco.api.entities.Site.Visibility; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import java.util.List; + +/** + * Created by Claudia Agache on 11/22/2016. + */ +@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) +public class GetSitesCoreTests extends RestTest +{ + private UserModel userModel, privateSiteManager, privateSiteConsumer; + private SiteModel publicSite, privateSite, moderatedSite, deletedSite; + private RestSiteModelsCollection sites; + private SiteModel siteModel; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + privateSiteManager = dataUser.createRandomTestUser(); + privateSiteConsumer = dataUser.createRandomTestUser(); + siteModel = new SiteModel(RandomData.getRandomName("0-PublicSite")); + publicSite = dataSite.usingAdmin().createSite(siteModel); + siteModel = new SiteModel(RandomData.getRandomName("0-PrivateSite"), Visibility.PRIVATE); + privateSite = dataSite.usingAdmin().createSite(siteModel); + siteModel = new SiteModel(RandomData.getRandomName("0-ModeratedSite"), Visibility.MODERATED); + moderatedSite = dataSite.usingAdmin().createSite(siteModel); + dataUser.addUserToSite(privateSiteManager, privateSite, UserRole.SiteManager); + dataUser.addUserToSite(privateSiteConsumer, privateSite, UserRole.SiteConsumer); + deletedSite = dataSite.usingAdmin().createPublicRandomSite(); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify invalid request returns status code 400 for invalid maxItems") + public void checkStatusCodeForInvalidMaxItems() throws Exception + { + restClient.authenticateUser(userModel).withParams("maxItems=0") + .withCoreAPI().getSites(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(ErrorModel.INVALID_ARGUMENT, "argument")); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify invalid request returns status code 400 for invalid skipCount") + public void checkStatusCodeForInvalidSkipCount() throws Exception + { + restClient.authenticateUser(userModel).withParams("skipCount=A") + .withCoreAPI().getSites(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(ErrorModel.INVALID_ARGUMENT, "argument")); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify User gets sites ordered by name ascendant and status code is 200") + public void getSitesOrderedByNameASC() throws Exception + { + sites = restClient.authenticateUser(privateSiteManager).withParams("orderBy=name ASC") + .withCoreAPI().getSites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + sites.assertThat().entriesListIsNotEmpty(); + List sitesList = sites.getEntries(); + sitesList.get(0).onModel().assertThat().field("title").is(moderatedSite.getTitle()); + sitesList.get(1).onModel().assertThat().field("title").is(privateSite.getTitle()); + sitesList.get(2).onModel().assertThat().field("title").is(publicSite.getTitle()); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if any user gets all public and moderated sites and status code is 200") + public void userGetsOnlyPublicAndModeratedSites() throws Exception + { + sites = restClient.authenticateUser(userModel).withParams("maxItems=5000") + .withCoreAPI().getSites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + sites.assertThat().entriesListContains("title", publicSite.getTitle()) + .and().entriesListContains("title", moderatedSite.getTitle()) + .and().entriesListDoesNotContain("title", privateSite.getTitle()); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if a member of a private site gets the private site, all public sites and all moderated sites. Verify if status code is 200") + public void userGetsSitesVisibleForHim() throws Exception + { + sites = restClient.authenticateUser(privateSiteConsumer).withParams("maxItems=5000") + .withCoreAPI().getSites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + sites.assertThat().entriesListContains("title", publicSite.getTitle()) + .and().entriesListContains("title", moderatedSite.getTitle()) + .and().entriesListContains("title", privateSite.getTitle()); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if a site is not retrieved anymore after deletion and status code is 200") + public void checkDeletedSiteIsNotRetrieved() throws Exception + { + sites = restClient.authenticateUser(userModel).withParams("maxItems=5000").withCoreAPI().getSites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + sites.assertThat().entriesListContains("title", deletedSite.getTitle()); + + dataSite.usingAdmin().deleteSite(deletedSite); + + sites = restClient.withParams("maxItems=5000").withCoreAPI().getSites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + sites.assertThat().entriesListDoesNotContain("title", deletedSite.getTitle()); + } + + @AfterClass(alwaysRun=true) + public void cleanup() throws Exception + { + dataSite.usingAdmin().deleteSite(moderatedSite); + dataSite.usingAdmin().deleteSite(privateSite); + dataSite.usingAdmin().deleteSite(publicSite); + } +} From 8595fb31741bd70e33efb55d21e25ae5bbbe1dc0 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Tue, 22 Nov 2016 17:25:56 +0200 Subject: [PATCH 0604/1491] CORE-REST API: postFavorites --- .../rest/favorites/AddFavoritesCoreTests.java | 219 ++++++++++++++++++ 1 file changed, 219 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/favorites/AddFavoritesCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesCoreTests.java b/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesCoreTests.java new file mode 100644 index 000000000..1bd799d4a --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesCoreTests.java @@ -0,0 +1,219 @@ +package org.alfresco.rest.favorites; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestCommentModel; +import org.alfresco.rest.model.RestPersonFavoritesModel; +import org.alfresco.rest.model.RestTagModel; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.model.ErrorModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.LinkModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +@Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) +public class AddFavoritesCoreTests extends RestTest +{ + @Autowired + DataUser dataUser; + + private UserModel adminUserModel; + private SiteModel siteModel; + private ListUserWithRoles usersWithRoles; + private RestPersonFavoritesModel restPersonFavoritesModel; + + FileModel document; + FolderModel folder; + + private RestCommentModel comment; + + private RestTagModel returnedModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + siteModel.setGuid(restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(siteModel).getSite().getGuid()); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + folder = dataContent.usingSite(siteModel).usingUser(adminUserModel).createFolder(); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Check that if target guid does not describe a site, file, or folder status code is 400") + public void addFavoriteUsingInvalidGuid() throws Exception + { + LinkModel link = dataLink.usingAdmin().usingSite(siteModel).createRandomLink(); + SiteModel site = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + site.setGuid(link.getNodeRef()); + + restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(site); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, site.getGuid().split("/")[3])); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Check that if personId does not exist, status code is 404") + public void addFavoriteUsingInexistentUser() throws Exception + { + restClient.withCoreAPI().usingUser(new UserModel("random_user", "random_password")).addSiteToFavorites(siteModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, "random_user")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Check that if target guid does not exist, status code is 404") + public void addFavoriteUsingInexistentGuid() throws Exception + { + SiteModel site = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + site.setGuid("random_guid"); + + restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(site); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, "random_guid")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Check that if a favorite already exists with the specified id status code is 404") + @Bug(id = "MNT-17157") + public void addFavoriteTwice() throws Exception + { + restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + restClient.assertStatusCodeIs(HttpStatus.CONFLICT); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Check that if user provides file in target but guid is of a folder status code is 404") + public void addFileToFavoritesUsingFolderGuid() throws Exception + { + String nodeRef = document.getNodeRef(); + document.setNodeRef(folder.getNodeRef()); + + restClient.withCoreAPI().usingAuthUser().addFileToFavorites(document); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(ErrorModel.RELATIONSHIP_NOT_FOUND, + adminUserModel.getUsername(), folder.getNodeRefWithoutVersion())); + + document.setNodeRef(nodeRef); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Add to favorites a file for a Manager, check it was added") + public void managerIsAbleToAddFileToFavorites() throws Exception + { + restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingAuthUser().addFileToFavorites(document); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restPersonFavoritesModel.assertThat().field("targetGuid").is(document.getNodeRefWithoutVersion()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify add favorite, perform getFavorites call, check value is updated") + public void verifyGetFavoritesAfterFavoritingSite() throws Exception + { + restPersonFavoritesModel = restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.withCoreAPI().usingAuthUser().getFavoriteSites().assertThat().entriesListContains("guid", siteModel.getGuid()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Add to favorites a folder for a Manager, check it was added") + public void managerIsAbleToAddFolderToFavorites() throws Exception + { + restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingAuthUser().addFolderToFavorites(folder); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restPersonFavoritesModel.assertThat().field("targetGuid").is(folder.getNodeRefWithoutVersion()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Add to favorites a site for a Manager, check it was added") + public void managerIsAbleToAddSiteToFavorites() throws Exception + { + restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restPersonFavoritesModel.assertThat().field("targetGuid").is(siteModel.getGuid()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify add favorite specifying -me- string in place of for request") + public void userIsAbleToAddFavoriteWhenUsingMeAsUsername() throws Exception + { + restPersonFavoritesModel = restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingMe().addSiteToFavorites(siteModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restPersonFavoritesModel.assertThat().field("targetGuid").is(siteModel.getGuid()); + + restClient.withCoreAPI().usingAuthUser().getFavoriteSites().assertThat().entriesListContains("guid", siteModel.getGuid()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify add file favorite with comment id returns status code 404") + @Bug(id = "MNT-17158") + public void addFileFavoriteUsingCommentId() throws Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + comment = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment("This is a comment"); + file.setNodeRef(comment.getId()); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFileToFavorites(file); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify add file favorite with tag id returns status code 404") + public void addFileFavoriteUsingTagId() throws Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + returnedModel = restClient.withCoreAPI().usingResource(document).addTag("random_tag"); + file.setNodeRef(returnedModel.getId()); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFileToFavorites(file); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(ErrorModel.RELATIONSHIP_NOT_FOUND, + adminUserModel.getUsername(), returnedModel.getId())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Check that if user provides site in target but id is of a file status code is 404") + public void addSiteToFavoritesUsingFileId() throws Exception + { + String guid = siteModel.getGuid(); + siteModel.setGuid(document.getNodeRefWithoutVersion()); + + restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, document.getNodeRefWithoutVersion())); + + siteModel.setGuid(guid); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Check that if user provides folder in target but guid is of a file status code is 404") + public void addFolderToFavoritesUsingFileGuid() throws Exception + { + String nodeRef = folder.getNodeRef(); + folder.setNodeRef(document.getNodeRef()); + + restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(folder); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, document.getNodeRef())); + + folder.setNodeRef(nodeRef); + } +} \ No newline at end of file From 8f0cbdc155f0e61fb3db7d88434faa60205bd099 Mon Sep 17 00:00:00 2001 From: Andrei Rusu Date: Wed, 23 Nov 2016 10:45:54 +0200 Subject: [PATCH 0605/1491] Added tests for GetRatingsCoreTests --- .../rest/ratings/GetRatingsCoreTests.java | 95 +++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/ratings/GetRatingsCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/ratings/GetRatingsCoreTests.java b/e2e-test/java/org/alfresco/rest/ratings/GetRatingsCoreTests.java new file mode 100644 index 000000000..916504147 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/ratings/GetRatingsCoreTests.java @@ -0,0 +1,95 @@ +package org.alfresco.rest.ratings; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestRatingModel; +import org.alfresco.utility.exception.DataPreparationException; +import org.alfresco.utility.model.ErrorModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.apache.commons.lang.RandomStringUtils; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) +public class GetRatingsCoreTests extends RestTest { + private SiteModel siteModel; + private UserModel adminUserModel, userModel; + private FileModel document; + private RestRatingModel returnedRatingModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws DataPreparationException { + adminUserModel = dataUser.getAdminUser(); + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingAdmin().createPublicRandomSite(); + } + + @BeforeMethod(alwaysRun = true) + public void setUp() throws DataPreparationException, Exception { + document = dataContent.usingSite(siteModel).usingAdmin() + .createContent(CMISUtil.DocumentType.TEXT_PLAIN); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Check that rating for invalid maxItems status code is 400") + public void checkInvalidMaxItemsStatusCode() throws Exception { + + restClient.authenticateUser(adminUserModel).withParams("maxItems=0").withCoreAPI().usingResource(document) + .getLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(ErrorModel.INVALID_ARGUMENT, "argument")); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Check that rating for invalid skipCount status code is 400") + public void checkInvalidSkipCountStatusCode() throws Exception { + + restClient.authenticateUser(adminUserModel).withParams("skipCount=AB").withCoreAPI().usingResource(document) + .getLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(ErrorModel.INVALID_ARGUMENT, "argument")); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "If nodeId does not exist status code is 404 when a document is liked") + public void addLikeUsingInvalidNodeId() throws Exception { + + document.setNodeRef(RandomStringUtils.randomAlphanumeric(20)); + returnedRatingModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document) + .likeDocument(); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, document.getNodeRef())); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Check that rating value is TRUE for a like rating") + public void checkRatingValueIsTrueForLikedDoc() throws Exception { + + returnedRatingModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document) + .likeDocument(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes"); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Check that rating value is an INTEGER value for stars rating") + public void checkRatingValueIsIntegerForStarsRating() throws Exception { + + returnedRatingModel = restClient.authenticateUser(userModel).withCoreAPI().usingResource(document) + .rateStarsToDocument(5); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar") + .and().field("aggregate").isNotEmpty(); + } + +} From 2489da05d9ca3c1013c798735baee98faad8d0d5 Mon Sep 17 00:00:00 2001 From: Andrei Rusu Date: Wed, 23 Nov 2016 10:45:54 +0200 Subject: [PATCH 0606/1491] Added tests for GetRatingsCoreTests (cherry picked from commit 4f2dda5) --- .../rest/ratings/GetRatingsCoreTests.java | 95 +++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/ratings/GetRatingsCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/ratings/GetRatingsCoreTests.java b/e2e-test/java/org/alfresco/rest/ratings/GetRatingsCoreTests.java new file mode 100644 index 000000000..916504147 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/ratings/GetRatingsCoreTests.java @@ -0,0 +1,95 @@ +package org.alfresco.rest.ratings; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestRatingModel; +import org.alfresco.utility.exception.DataPreparationException; +import org.alfresco.utility.model.ErrorModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.apache.commons.lang.RandomStringUtils; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) +public class GetRatingsCoreTests extends RestTest { + private SiteModel siteModel; + private UserModel adminUserModel, userModel; + private FileModel document; + private RestRatingModel returnedRatingModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws DataPreparationException { + adminUserModel = dataUser.getAdminUser(); + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingAdmin().createPublicRandomSite(); + } + + @BeforeMethod(alwaysRun = true) + public void setUp() throws DataPreparationException, Exception { + document = dataContent.usingSite(siteModel).usingAdmin() + .createContent(CMISUtil.DocumentType.TEXT_PLAIN); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Check that rating for invalid maxItems status code is 400") + public void checkInvalidMaxItemsStatusCode() throws Exception { + + restClient.authenticateUser(adminUserModel).withParams("maxItems=0").withCoreAPI().usingResource(document) + .getLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(ErrorModel.INVALID_ARGUMENT, "argument")); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Check that rating for invalid skipCount status code is 400") + public void checkInvalidSkipCountStatusCode() throws Exception { + + restClient.authenticateUser(adminUserModel).withParams("skipCount=AB").withCoreAPI().usingResource(document) + .getLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(ErrorModel.INVALID_ARGUMENT, "argument")); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "If nodeId does not exist status code is 404 when a document is liked") + public void addLikeUsingInvalidNodeId() throws Exception { + + document.setNodeRef(RandomStringUtils.randomAlphanumeric(20)); + returnedRatingModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document) + .likeDocument(); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, document.getNodeRef())); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Check that rating value is TRUE for a like rating") + public void checkRatingValueIsTrueForLikedDoc() throws Exception { + + returnedRatingModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document) + .likeDocument(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes"); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Check that rating value is an INTEGER value for stars rating") + public void checkRatingValueIsIntegerForStarsRating() throws Exception { + + returnedRatingModel = restClient.authenticateUser(userModel).withCoreAPI().usingResource(document) + .rateStarsToDocument(5); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar") + .and().field("aggregate").isNotEmpty(); + } + +} From 6fdb3ef1cf9882ea664bba6d299ed8e693052dca Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 23 Nov 2016 11:26:20 +0200 Subject: [PATCH 0607/1491] added core tests for getSite --- .../alfresco/rest/sites/GetSiteCoreTests.java | 113 ++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/sites/GetSiteCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteCoreTests.java new file mode 100644 index 000000000..abebddf95 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteCoreTests.java @@ -0,0 +1,113 @@ +package org.alfresco.rest.sites; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.model.RestSiteModel; +import org.alfresco.rest.model.RestSiteModelsCollection; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.model.ErrorModel; +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; + +/** + * Created by Claudia Agache on 11/23/2016. + */ +@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) +public class GetSiteCoreTests extends RestTest +{ + private UserModel userModel, privateSiteConsumer; + private SiteModel publicSite, privateSite, moderatedSite; + private RestSiteModel restSiteModel; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + privateSiteConsumer = dataUser.createRandomTestUser(); + publicSite = dataSite.usingAdmin().createPublicRandomSite(); + privateSite = dataSite.usingAdmin().createPrivateRandomSite(); + moderatedSite = dataSite.usingAdmin().createModeratedRandomSite(); + dataUser.addUserToSite(privateSiteConsumer, privateSite, UserRole.SiteConsumer); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify invalid request returns status code 404 if siteId does not exist") + public void checkStatusCodeForNonExistentSiteId() throws Exception + { + restClient.authenticateUser(userModel).withCoreAPI() + .usingSite("NonExistentSiteId").getSite(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, "NonExistentSiteId")); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify user gets all public and moderated sites if an empty siteId is provided") + public void checkStatusCodeForEmptySiteId() throws Exception + { + restClient.authenticateUser(userModel).withCoreAPI(); + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "sites/{siteId}", ""); + RestSiteModelsCollection sites = restClient.processModels(RestSiteModelsCollection.class, request); + restClient.assertStatusCodeIs(HttpStatus.OK); + sites.assertThat().entriesListIsNotEmpty(); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if any user gets public site details and status code is 200") + public void getPublicSite() throws Exception + { + restSiteModel = restClient.authenticateUser(userModel).withCoreAPI() + .usingSite(publicSite).getSite(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteModel.assertThat().field("visibility").is(publicSite.getVisibility()) + .and().field("id").is(publicSite.getId()) + .and().field("description").is(publicSite.getDescription()) + .and().field("title").is(publicSite.getTitle()) + .and().field("guid").isNotEmpty(); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if any user gets moderated site details and status code is 200") + public void getModeratedSite() throws Exception + { + restSiteModel = restClient.authenticateUser(userModel).withCoreAPI() + .usingSite(moderatedSite).getSite(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteModel.assertThat().field("visibility").is(moderatedSite.getVisibility()) + .and().field("id").is(moderatedSite.getId()) + .and().field("description").is(moderatedSite.getDescription()) + .and().field("title").is(moderatedSite.getTitle()) + .and().field("guid").isNotEmpty(); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if member of a private site gets that site details and status code is 200") + public void getPrivateSiteBySiteMember() throws Exception + { + restSiteModel = restClient.authenticateUser(privateSiteConsumer).withCoreAPI() + .usingSite(privateSite).getSite(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteModel.assertThat().field("visibility").is(privateSite.getVisibility()) + .and().field("id").is(privateSite.getId()) + .and().field("description").is(privateSite.getDescription()) + .and().field("title").is(privateSite.getTitle()) + .and().field("guid").isNotEmpty(); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if user that is not member of a private site does not get that site details and status code is 200") + public void getPrivateSiteByNotASiteMember() throws Exception + { + restSiteModel = restClient.authenticateUser(userModel).withCoreAPI() + .usingSite(privateSite).getSite(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, privateSite.getTitle())); + } + +} From 239366e539773336f058ed91bca7a60ec41cc7b5 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Wed, 23 Nov 2016 12:21:29 +0200 Subject: [PATCH 0608/1491] CORE-REST API: rate (post /nodes/{nodeId}/ratings) --- .../rest/ratings/AddRatingCoreTests.java | 217 ++++++++++++++++++ 1 file changed, 217 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/ratings/AddRatingCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/ratings/AddRatingCoreTests.java b/e2e-test/java/org/alfresco/rest/ratings/AddRatingCoreTests.java new file mode 100644 index 000000000..fe2a5e1c7 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/ratings/AddRatingCoreTests.java @@ -0,0 +1,217 @@ +package org.alfresco.rest.ratings; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestCommentModel; +import org.alfresco.rest.model.RestRatingModel; +import org.alfresco.rest.model.RestTagModel; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.exception.DataPreparationException; +import org.alfresco.utility.model.ErrorModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.LinkModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.apache.commons.lang3.RandomStringUtils; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) +public class AddRatingCoreTests extends RestTest +{ + private UserModel userModel; + private SiteModel siteModel; + private UserModel adminUser; + private FolderModel folderModel; + private FileModel document; + private ListUserWithRoles usersWithRoles; + private RestRatingModel returnedRatingModel; //placeholder for returned model + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws DataPreparationException + { + userModel = dataUser.createUser(RandomStringUtils.randomAlphanumeric(20)); + adminUser = dataUser.getAdminUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + } + + @BeforeMethod + public void setUp() throws Exception + { + folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that if unknown rating scheme is provided status code is 400") + public void unknownRatingSchemeReturnsBadRequest() throws Exception + { + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"invalidRate\"}"); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(ErrorModel.INVALID_RATING, "invalidRate")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that if nodeId does not exist status code 404 is returned") + public void invalidNodeIdReturnsNotFound() throws Exception + { + document.setNodeRef(RandomStringUtils.randomAlphanumeric(10)); + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, document.getNodeRef())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that if nodeId provided cannot be rated 405 status code is returned") + @Bug(id = "MNT-16904") + public void likeResourceThatCannotBeRated() throws Exception + { + LinkModel link = dataLink.usingAdmin().usingSite(siteModel).createRandomLink(); + document.setNodeRef(link.getNodeRef()); + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that manager is able to like a file") + public void managerIsAbleToLikeAFile() throws Exception + { + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(document).likeDocument(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("true") + .and().field("id").is("likes") + .and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that manager is able to like a folder") + public void managerIsAbleToLikeAFolder() throws Exception + { + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(folderModel).likeDocument(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("true") + .and().field("id").is("likes") + .and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that manager is able to rate a folder") + public void managerIsAbleToRateAFolder() throws Exception + { + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(folderModel).rateStarsToDocument(5); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("5") + .and().field("id").is("fiveStar") + .and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that manager is able to rate a file") + public void managerIsAbleToRateAFile() throws Exception + { + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(document).rateStarsToDocument(5); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("5") + .and().field("id").is("fiveStar") + .and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that adding like again has no effect on a file") + public void fileCanBeLikedTwice() throws Exception + { + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("true") + .and().field("id").is("likes") + .and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that adding rate again has no effect on a file") + public void fileCanBeRatedTwice() throws Exception + { + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).rateStarsToDocument(5); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).rateStarsToDocument(5); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("5") + .and().field("id").is("fiveStar") + .and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that rate is not added if empty rating object is provided") + public void addRateUsingEmptyRatingObject() throws Exception + { + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating(""); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(ErrorModel.NO_CONTENT, + "No content to map to Object due to end of input")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that if empty rate id is provided status code is 400") + public void addRateUsingEmptyValueForId() throws Exception + { + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"\"}"); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(ErrorModel.NO_CONTENT, + "N/A (through reference chain: org.alfresco.rest.api.model.NodeRating[\"id\"])")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that if empty rating is provided status code is 400") + public void addRateUsingEmptyValueForMyRating() throws Exception + { + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"likes\", \"myRating\":\"\"}"); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(ErrorModel.NULL_LIKE_RATING)); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"fiveStar\", \"myRating\":\"\"}"); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(ErrorModel.NULL_FIVESTAR_RATING)); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that user is not able to rate a comment") + public void addRatingToAComment() throws Exception + { + RestCommentModel comment = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addComment("This is a comment"); + document.setNodeRef(comment.getId()); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(String.format(ErrorModel.CANNOT_RATE)); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).rateStarsToDocument(5); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(String.format(ErrorModel.CANNOT_RATE)); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that user is not able to rate a tag") + public void addRatingToATag() throws Exception + { + RestTagModel tag = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addTag("randomTag"); + document.setNodeRef(tag.getId()); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(String.format(ErrorModel.CANNOT_RATE)); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).rateStarsToDocument(5); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(String.format(ErrorModel.CANNOT_RATE)); + } + +} \ No newline at end of file From ce99c122d3edebd53770924016b5e5ae36f6d2ac Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 23 Nov 2016 14:27:09 +0200 Subject: [PATCH 0609/1491] added bug annotation --- .../rest/comments/DeleteCommentsSanityTests.java | 16 ++++++++-------- .../rest/people/DeleteSiteMemberSanityTests.java | 3 ++- .../rest/sites/GetSiteMembersSanityTests.java | 3 ++- .../alfresco/rest/tags/DeleteTagSanityTests.java | 2 ++ 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java index cce059c56..359a3f27d 100644 --- a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java @@ -6,10 +6,8 @@ import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestCommentModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.model.*; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -76,14 +74,16 @@ public class DeleteCommentsSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } + @Bug(id="MNT-16904") @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Manager user gets status code 401 if authentication call fails") - public void managerIsNotAbleToDeleteCommentIfAuthenticationFails() throws JsonToModelConversionException, Exception + TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify User gets status code 401 if authentication call fails") + public void userIsNotAbleToDeleteCommentIfAuthenticationFails() throws JsonToModelConversionException, Exception { + restClient.authenticateUser(adminUserModel); + comment = restClient.withCoreAPI().usingResource(document).addComment("New comment addded by admin"); UserModel nonexistentModel = new UserModel("nonexistentUser", "nonexistentPassword"); restClient.authenticateUser(nonexistentModel); - comment = restClient.withCoreAPI().usingResource(document).addComment("New comment addded by Manager"); restClient.withCoreAPI().usingResource(document).deleteComment(comment); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java index f93657375..48540caac 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java @@ -115,7 +115,8 @@ public class DeleteSiteMemberSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } - + + @Bug(id="MNT-16904") @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to delete another member of the site") diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java index acf806253..752cfa6f4 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java @@ -8,6 +8,7 @@ import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; @@ -108,6 +109,6 @@ public class GetSiteMembersSanityTests extends RestTest dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); restClient.authenticateUser(userModel) .withCoreAPI().usingSite(siteModel).getSiteMembers(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/tags/DeleteTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/DeleteTagSanityTests.java index 8d55a4699..97a23746a 100644 --- a/e2e-test/java/org/alfresco/rest/tags/DeleteTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/DeleteTagSanityTests.java @@ -13,6 +13,7 @@ import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -112,6 +113,7 @@ public class DeleteTagSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } + @Bug(id="MNT-16904") @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user gets status code 401 if authentication call fails") public void userIsNotAbleToDeleteTagIfAuthenticationFails() throws JsonToModelConversionException, Exception From 7376e179e6d7060be85c58d71cac0f1e02d79577 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Wed, 23 Nov 2016 16:30:43 +0200 Subject: [PATCH 0610/1491] mark tests for network --- .../networks/RestGetNetworksForPersonSanityTests.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonSanityTests.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonSanityTests.java index bb75fb85e..c19dbe4c9 100644 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonSanityTests.java @@ -28,7 +28,7 @@ public class RestGetNetworksForPersonSanityTests extends RestTest } @Bug(id = "MNT-16904") - @Test(groups = TestGroup.COMMENTS) + @Test(groups = {TestGroup.COMMENTS, TestGroup.NETWORKS}) @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify non existing user gets another exisiting network with Rest API and checks the forbidden status") @@ -41,7 +41,7 @@ public class RestGetNetworksForPersonSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } - @Test(groups = TestGroup.COMMENTS) + @Test(groups = {TestGroup.COMMENTS, TestGroup.NETWORKS}) @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify tenant admin user gets specific network with Rest API and response is not empty") @@ -52,7 +52,7 @@ public class RestGetNetworksForPersonSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); } - @Test(groups = TestGroup.COMMENTS) + @Test(groups = {TestGroup.COMMENTS, TestGroup.NETWORKS}) @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify tenant user is not authorized to check network of admin user with Rest API and checks the forbidden status") @@ -63,8 +63,8 @@ public class RestGetNetworksForPersonSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); } - @Test(groups = TestGroup.COMMENTS) - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, + @Test(groups = {TestGroup.COMMENTS, TestGroup.NETWORKS}) + @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify admin tenant user is not authorized to check network of another user with Rest API and checks the forbidden status") public void adminTenantUserIsNotAuthorizedToCheckNetworkOfAnotherUser() throws Exception From 82c7844ce1251937793e4fc96fe1b77155ad06ef Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 23 Nov 2016 16:54:35 +0200 Subject: [PATCH 0611/1491] fix error summary for 5.2 --- .../org/alfresco/rest/comments/GetCommentsCoreTests.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/comments/GetCommentsCoreTests.java b/e2e-test/java/org/alfresco/rest/comments/GetCommentsCoreTests.java index b0ff5e71c..d2325405b 100644 --- a/e2e-test/java/org/alfresco/rest/comments/GetCommentsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/GetCommentsCoreTests.java @@ -17,7 +17,7 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) public class GetCommentsCoreTests extends RestTest { - private UserModel adminUserModel, userModel; + private UserModel adminUserModel, userModel, networkUserModel; private FileModel document; private SiteModel siteModel; private String comment = "This is a new comment"; @@ -30,6 +30,7 @@ public class GetCommentsCoreTests extends RestTest { adminUserModel = dataUser.getAdminUser(); userModel = dataUser.createRandomTestUser(); + networkUserModel = dataUser.createRandomTestUser(); siteModel = dataSite.usingUser(adminUserModel).createPrivateRandomSite(); document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); restClient.authenticateUser(adminUserModel).withCoreAPI() @@ -48,7 +49,7 @@ public class GetCommentsCoreTests extends RestTest restClient.authenticateUser(adminUserModel).withParams("maxItems=0") .withCoreAPI().usingResource(document).getNodeComments(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(ErrorModel.INVALID_ARGUMENT, "argument")); + .assertLastError().containsSummary("Only positive values supported for maxItems"); } @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, @@ -105,7 +106,7 @@ public class GetCommentsCoreTests extends RestTest @Bug(id = "MNT-16904") public void getCommentsWithInvalidNetwork() throws Exception { - userModel.setDomain("invalidNetwork"); + networkUserModel.setDomain("invalidNetwork"); restClient.authenticateUser(userModel).withCoreAPI().usingResource(document).getNodeComments(); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } @@ -115,7 +116,7 @@ public class GetCommentsCoreTests extends RestTest @Bug(id = "MNT-16904") public void getCommentsWithEmptyNetwork() throws Exception { - userModel.setDomain(""); + networkUserModel.setDomain(""); restClient.authenticateUser(userModel).withCoreAPI().usingResource(document).getNodeComments(); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } From 8a711d84fe82e5504d37d830df6099642cad2072 Mon Sep 17 00:00:00 2001 From: Andreea Nechifor Date: Wed, 23 Nov 2016 16:58:51 +0200 Subject: [PATCH 0612/1491] update testRail --- e2e-test/resources/default.properties | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/e2e-test/resources/default.properties b/e2e-test/resources/default.properties index 9f87e0902..ca02e1224 100644 --- a/e2e-test/resources/default.properties +++ b/e2e-test/resources/default.properties @@ -29,9 +29,10 @@ rest.workflowPath=alfresco/api/-default-/public/workflow/versions/1 testManagement.endPoint=https://alfresco.testrail.com/ testManagement.username=tas.alfresco@gmail.com testManagement.apiKey=EYpY7.fV0AoMGWbmyuVC-k5u.nzwHy6a.QWzJq8.S -testManagement.project=7 +testManagement.project=1 testManagement.testRun=Automation testManagement.justUploadTest=false +testManagement.suiteId=1 # The location of the reports path reports.path=./target/reports From a0dd95422e2f6a7d113e6b52da2ed8044524f076 Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 23 Nov 2016 17:11:55 +0200 Subject: [PATCH 0613/1491] fix error summary for 5.2 --- .../java/org/alfresco/rest/ratings/GetRatingsCoreTests.java | 4 ++-- e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/ratings/GetRatingsCoreTests.java b/e2e-test/java/org/alfresco/rest/ratings/GetRatingsCoreTests.java index 916504147..b41e2c7fa 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/GetRatingsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/GetRatingsCoreTests.java @@ -44,7 +44,7 @@ public class GetRatingsCoreTests extends RestTest { restClient.authenticateUser(adminUserModel).withParams("maxItems=0").withCoreAPI().usingResource(document) .getLikeRating(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(ErrorModel.INVALID_ARGUMENT, "argument")); + .containsSummary("Only positive values supported for maxItems"); } @TestRail(section = { TestGroup.REST_API, @@ -54,7 +54,7 @@ public class GetRatingsCoreTests extends RestTest { restClient.authenticateUser(adminUserModel).withParams("skipCount=AB").withCoreAPI().usingResource(document) .getLikeRating(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(ErrorModel.INVALID_ARGUMENT, "argument")); + .containsSummary("Invalid paging parameter skipCount:AB"); } @TestRail(section = { TestGroup.REST_API, diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java index cba567e89..8a1b5914c 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java @@ -54,7 +54,7 @@ public class GetSitesCoreTests extends RestTest restClient.authenticateUser(userModel).withParams("maxItems=0") .withCoreAPI().getSites(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(ErrorModel.INVALID_ARGUMENT, "argument")); + .assertLastError().containsSummary("Only positive values supported for maxItems"); } @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, @@ -64,7 +64,7 @@ public class GetSitesCoreTests extends RestTest restClient.authenticateUser(userModel).withParams("skipCount=A") .withCoreAPI().getSites(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(ErrorModel.INVALID_ARGUMENT, "argument")); + .assertLastError().containsSummary("Invalid paging parameter skipCount:A"); } @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, From 140d83fd5848b9a596c954231143930a14a5d037 Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 23 Nov 2016 17:22:08 +0200 Subject: [PATCH 0614/1491] updated scenario for 5.2 --- e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java index 8a1b5914c..c4766c1cb 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java @@ -71,7 +71,7 @@ public class GetSitesCoreTests extends RestTest description= "Verify User gets sites ordered by name ascendant and status code is 200") public void getSitesOrderedByNameASC() throws Exception { - sites = restClient.authenticateUser(privateSiteManager).withParams("orderBy=name ASC") + sites = restClient.authenticateUser(privateSiteManager).withParams("orderBy=title ASC") .withCoreAPI().getSites(); restClient.assertStatusCodeIs(HttpStatus.OK); sites.assertThat().entriesListIsNotEmpty(); From 50bf1ea8d44ba1129edaf5f9939ec8a0789ea28e Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 23 Nov 2016 17:22:27 +0200 Subject: [PATCH 0615/1491] added bug annotation --- .../org/alfresco/rest/comments/UpdateCommentsCoreTests.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsCoreTests.java b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsCoreTests.java index a314e0502..16a30be53 100644 --- a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsCoreTests.java @@ -82,7 +82,8 @@ public class UpdateCommentsCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); comments.assertThat().entriesListContains("content", "This is the updated comment with Collaborator user"); } - + + @Bug(id="") @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user can update comments of another user and status code is 200") public void collaboratorIsAbleToUpdateCommentOfAnotherUser() throws JsonToModelConversionException, Exception From 439a18442a859f72583cdc9e46acbfd5d53b2fa1 Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 23 Nov 2016 17:39:32 +0200 Subject: [PATCH 0616/1491] call getSites using maxItems parameter --- .../rest/sites/GetSitesSanityTests.java | 20 ++++++------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java index 3414c662c..3e0353f01 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java @@ -23,12 +23,6 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) public class GetSitesSanityTests extends RestTest { - @Autowired - DataUser dataUser; - - @Autowired - DataSite dataSite; - private UserModel adminUserModel; private UserModel userModel; private ListUserWithRoles usersWithRoles; @@ -38,7 +32,6 @@ public class GetSitesSanityTests extends RestTest public void dataPreparation() throws Exception { adminUserModel = dataUser.getAdminUser(); - restClient.authenticateUser(adminUserModel); siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); } @@ -46,8 +39,7 @@ public class GetSitesSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role gets sites information and gets status code OK (200)") public void managerIsAbleToRetrieveSites() throws JsonToModelConversionException, Exception { - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withParams("maxItems=1000") .withCoreAPI().getSites() .assertThat().entriesListIsNotEmpty() .assertThat().entriesListContains("id", siteModel.getId()) @@ -59,7 +51,7 @@ public class GetSitesSanityTests extends RestTest description = "Verify user with Collaborator role gets sites information and gets status code OK (200)") public void collaboratorIsAbleToRetrieveSites() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withParams("maxItems=1000") .withCoreAPI().getSites().assertThat().entriesListIsNotEmpty() .assertThat().entriesListContains("id", siteModel.getId()) .and().paginationExist(); @@ -72,7 +64,7 @@ public class GetSitesSanityTests extends RestTest public void contributorIsAbleToRetrieveSites() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withParams("maxItems=1000") .withCoreAPI().getSites() .assertThat().entriesListIsNotEmpty() .assertThat().entriesListContains("id", siteModel.getId()) @@ -85,7 +77,7 @@ public class GetSitesSanityTests extends RestTest public void consumerIsAbleToRetrieveSites() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withParams("maxItems=1000") .withCoreAPI().getSites() .assertThat().entriesListIsNotEmpty() .assertThat().entriesListContains("id", siteModel.getId()) @@ -97,7 +89,7 @@ public class GetSitesSanityTests extends RestTest description = "Verify user with Admin user gets sites information and gets status code OK (200)") public void adminUserIsAbleToRetrieveSites() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(adminUserModel) + restClient.authenticateUser(adminUserModel).withParams("maxItems=1000") .withCoreAPI().getSites() .assertThat().entriesListIsNotEmpty() .assertThat().entriesListContains("id", siteModel.getId()) @@ -114,7 +106,7 @@ public class GetSitesSanityTests extends RestTest userModel = dataUser.createRandomTestUser(); userModel.setPassword("user wrong password"); dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); - restClient.authenticateUser(userModel) + restClient.authenticateUser(userModel).withParams("maxItems=1000") .withCoreAPI().getSites(); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } From 71627b53370a1c225856a85ed52ff062d198c363 Mon Sep 17 00:00:00 2001 From: cagache Date: Thu, 24 Nov 2016 10:09:10 +0200 Subject: [PATCH 0617/1491] try to fix tests --- .../rest/tags/GetTagsSanityTests.java | 22 +++++++------------ 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java index 0adb153dd..d9f05070e 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java @@ -8,11 +8,7 @@ import org.alfresco.utility.Utility; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.StatusModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.model.*; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; @@ -42,12 +38,10 @@ public class GetTagsSanityTests extends RestTest document = dataContent.usingUser(adminUserModel).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); tagValue = RandomData.getRandomName("tag"); - restClient.withCoreAPI().usingResource(document).addTag(tagValue); - tagValue2 = RandomData.getRandomName("tag"); - restClient.withCoreAPI().usingResource(document).addTag(tagValue2); + restClient.withCoreAPI().usingResource(document).addTags(tagValue, tagValue2); - Utility.waitToLoopTime(5); + Utility.waitToLoopTime(60); } @@ -55,7 +49,7 @@ public class GetTagsSanityTests extends RestTest public void getTagsWithManagerRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - RestTagModelsCollection returnedCollection = restClient.withCoreAPI().getTags(); + RestTagModelsCollection returnedCollection = restClient.withParams("maxItems=500").withCoreAPI().getTags(); restClient.assertStatusCodeIs(HttpStatus.OK); returnedCollection.assertThat().entriesListIsNotEmpty() .and().entriesListContains("tag", tagValue.toLowerCase()) @@ -66,7 +60,7 @@ public class GetTagsSanityTests extends RestTest public void getTagsWithCollaboratorRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - RestTagModelsCollection returnedCollection = restClient.withCoreAPI().getTags(); + RestTagModelsCollection returnedCollection = restClient.withParams("maxItems=500").withCoreAPI().getTags(); restClient.assertStatusCodeIs(HttpStatus.OK); returnedCollection.assertThat().entriesListIsNotEmpty() .and().entriesListContains("tag", tagValue.toLowerCase()) @@ -77,7 +71,7 @@ public class GetTagsSanityTests extends RestTest public void getTagsWithContributorRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - RestTagModelsCollection returnedCollection = restClient.withCoreAPI().getTags(); + RestTagModelsCollection returnedCollection = restClient.withParams("maxItems=500").withCoreAPI().getTags(); restClient.assertStatusCodeIs(HttpStatus.OK); returnedCollection.assertThat().entriesListIsNotEmpty() .and().entriesListContains("tag", tagValue.toLowerCase()) @@ -88,7 +82,7 @@ public class GetTagsSanityTests extends RestTest public void getTagsWithConsumerRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - RestTagModelsCollection returnedCollection = restClient.withCoreAPI().getTags(); + RestTagModelsCollection returnedCollection = restClient.withParams("maxItems=500").withCoreAPI().getTags(); restClient.assertStatusCodeIs(HttpStatus.OK); returnedCollection.assertThat().entriesListIsNotEmpty() .and().entriesListContains("tag", tagValue.toLowerCase()) @@ -99,7 +93,7 @@ public class GetTagsSanityTests extends RestTest public void getTagsWithAdminUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); - RestTagModelsCollection returnedCollection = restClient.withCoreAPI().getTags(); + RestTagModelsCollection returnedCollection = restClient.withParams("maxItems=500").withCoreAPI().getTags(); restClient.assertStatusCodeIs(HttpStatus.OK); returnedCollection.assertThat().entriesListIsNotEmpty() .and().entriesListContains("tag", tagValue.toLowerCase()) From a2bf38163893b04516b7a0c839db6018fafb186c Mon Sep 17 00:00:00 2001 From: cagache Date: Thu, 24 Nov 2016 10:46:10 +0200 Subject: [PATCH 0618/1491] removed bug annotation --- .../java/org/alfresco/rest/favorites/GetFavoritesCoreTests.java | 1 - .../java/org/alfresco/rest/people/GetFavoriteSiteCoreTests.java | 1 - 2 files changed, 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesCoreTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesCoreTests.java index 52e8f7e43..468a752a6 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesCoreTests.java @@ -229,7 +229,6 @@ public class GetFavoritesCoreTests extends RestTest .and().paginationField("totalItems").is("2"); } - @Bug(id="MNT-17146") @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify request using personId that does not exist returns status 404") public void checkFavoritesWhenPersonIdDoesNotExist() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteCoreTests.java b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteCoreTests.java index 06530bd58..26001e020 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteCoreTests.java @@ -42,7 +42,6 @@ public class GetFavoriteSiteCoreTests extends RestTest .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, "someUser")); } - @Bug(id="MNT-17146") @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify invalid request returns status 404 when siteId does not exist") From 35fb448929769be5edf84780b830532d0541a48d Mon Sep 17 00:00:00 2001 From: cagache Date: Thu, 24 Nov 2016 11:11:40 +0200 Subject: [PATCH 0619/1491] fix tests --- .../rest/comments/UpdateCommentsCoreTests.java | 18 ++++++------------ .../comments/UpdateCommentsSanityTests.java | 12 +++++++----- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsCoreTests.java b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsCoreTests.java index 16a30be53..32465a959 100644 --- a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsCoreTests.java @@ -7,12 +7,7 @@ import org.alfresco.rest.model.RestCommentModel; import org.alfresco.rest.model.RestCommentModelsCollection; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FileType; -import org.alfresco.utility.model.LinkModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.model.*; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; @@ -43,7 +38,7 @@ public class UpdateCommentsCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.SANITY }, executionType = ExecutionType.SANITY, description = "Verify can not update comment if NodeId is neither document or folder and returns status code 405") @Bug(id="MNT-16904") - public void canNotUpdateCommentIfNodeIdIsNeitherDoumentOrFolder() throws JsonToModelConversionException, Exception + public void canNotUpdateCommentIfNodeIdIsNeitherDocumentOrFolder() throws JsonToModelConversionException, Exception { FileModel content = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); content = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); @@ -61,7 +56,7 @@ public class UpdateCommentsCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Admin user is not able to update with empty comment body and status code is 400") - public void adminIsNotAbleToUpdateWithEptyCommentBody() throws JsonToModelConversionException, Exception + public void adminIsNotAbleToUpdateWithEmptyCommentBody() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by admin"); @@ -83,16 +78,15 @@ public class UpdateCommentsCoreTests extends RestTest comments.assertThat().entriesListContains("content", "This is the updated comment with Collaborator user"); } - @Bug(id="") @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user can update comments of another user and status code is 200") - public void collaboratorIsAbleToUpdateCommentOfAnotherUser() throws JsonToModelConversionException, Exception + TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user can not update comments of another user and status code is 200") + public void collaboratorIsNotAbleToUpdateCommentOfAnotherUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by admin"); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); restClient.withCoreAPI().usingResource(document).updateComment(commentModel, "This is the updated comment with Collaborator user"); - restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, diff --git a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java index 3c762ba94..fe30b9575 100644 --- a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java @@ -41,7 +41,7 @@ public class UpdateCommentsSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Admin user updates comments and status code is 200") - public void adminIsAbleToUpdateComments() throws JsonToModelConversionException, Exception + public void adminIsAbleToUpdateHisComment() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by admin"); @@ -54,7 +54,7 @@ public class UpdateCommentsSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Manager user updates comments created by admin user and status code is 200") - public void managerIsAbleToUpdateComment() throws JsonToModelConversionException, Exception + public void managerIsAbleToUpdateHisComment() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by manager"); @@ -67,7 +67,7 @@ public class UpdateCommentsSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Contributor user can update his own comment and status code is 200") - public void contributorIsAbleToUpdateComment() throws JsonToModelConversionException, Exception + public void contributorIsAbleToUpdateHisComment() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by contributor"); @@ -91,7 +91,7 @@ public class UpdateCommentsSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user can update his own comment and status code is 200") @Bug(id="REPO-1011") - public void collaboratorIsAbleToUpdateComment() throws JsonToModelConversionException, Exception + public void collaboratorIsAbleToUpdateHisComment() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by collaborator"); @@ -104,9 +104,11 @@ public class UpdateCommentsSanityTests extends RestTest @Bug(id="MNT-16904") public void unauthenticatedUserIsNotAbleToUpdateComment() throws JsonToModelConversionException, Exception { + restClient.authenticateUser(adminUserModel); + commentModel = restClient.withCoreAPI().usingResource(document).addComment("To be updated by unauthenticated user."); UserModel incorrectUserModel = new UserModel("userName", "password"); restClient.authenticateUser(incorrectUserModel) - .withCoreAPI().usingResource(document).getNodeComments(); + .withCoreAPI().usingResource(document).updateComment(commentModel, "try to update"); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } From 1cb8bc7de954651bab28705e19891aeded1ddbc3 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Thu, 24 Nov 2016 14:31:28 +0200 Subject: [PATCH 0620/1491] Core-REST API: removeMemberFromSIte tests --- .../people/DeleteFavoriteSiteCoreTests.java | 15 +- .../people/DeleteSiteMemberCoreTests.java | 254 ++++++++++++++++++ 2 files changed, 258 insertions(+), 11 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteCoreTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteCoreTests.java index 7aa1d952a..2877c6bef 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteCoreTests.java @@ -42,26 +42,19 @@ public class DeleteFavoriteSiteCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify inexistent user is not able to remove a site from favorites and response is 404") - public void inexistentUserIsNotAbleToRemoveFavoriteSite() throws Exception + public void userIsNotAbleToRemoveFavoriteSiteOfInexistentUser() throws Exception { - restClient.authenticateUser(adminUserModel); - dataSite.usingUser(adminUserModel).usingSite(siteModel).addSiteToFavorites(); - UserModel inexistentUser = new UserModel("inexistenUser", "password"); - restClient.withCoreAPI().usingUser(inexistentUser).removeFavoriteSite(siteModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, "inexistenUser")); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(inexistentUser).removeFavoriteSite(siteModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, "inexistenUser")); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify user is not able to remove from favorites a site with inexistent id and response is 404") public void userIsNotAbleToRemoveFavoriteSiteWithInexistentId() throws Exception { - restClient.authenticateUser(adminUserModel); - dataSite.usingUser(adminUserModel).usingSite(siteModel).addSiteToFavorites(); - SiteModel inexistentSite = new SiteModel("inexistentSite"); - restClient.withCoreAPI().usingUser(adminUserModel).removeFavoriteSite(inexistentSite); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).removeFavoriteSite(inexistentSite); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() .containsSummary(String.format(ErrorModel.RELATIONSHIP_NOT_FOUND, adminUserModel.getUsername(), inexistentSite.getTitle())); } diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberCoreTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberCoreTests.java new file mode 100644 index 000000000..627997442 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberCoreTests.java @@ -0,0 +1,254 @@ +package org.alfresco.rest.people; + +import org.alfresco.rest.RestTest; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.model.ErrorModel; +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; + +@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) +public class DeleteSiteMemberCoreTests extends RestTest +{ + + private UserModel userModel; + private UserModel managerModel; + private SiteModel publicSiteModel; + private SiteModel moderatedSiteModel; + private SiteModel privateSiteModel; + private UserModel adminUserModel; + private UserModel secondUserModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + secondUserModel = dataUser.createRandomTestUser(); + secondUserModel.setUserRole(UserRole.SiteCollaborator); + userModel = dataUser.createRandomTestUser(); + userModel.setUserRole(UserRole.SiteCollaborator); + managerModel = dataUser.createRandomTestUser(); + managerModel.setUserRole(UserRole.SiteManager); + adminUserModel = dataUser.getAdminUser(); + publicSiteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + moderatedSiteModel = dataSite.usingUser(adminUserModel).createModeratedRandomSite(); + privateSiteModel = dataSite.usingUser(adminUserModel).createPrivateRandomSite(); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user removes a site member using '-me-' in place of personId and response is successful (204)") + public void removeSiteMemberWithSuccessUsingMeAsPersonId() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(userModel); + + restClient.authenticateUser(userModel).withCoreAPI().usingMe().deleteSiteMember(publicSiteModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user can't remove a site membership if doesn't have access to personId and response is 422") + public void notAbleToRemoveSiteMemberWithNoAccessToPersonId() throws Exception + { + UserModel secondManager = dataUser.createRandomTestUser(); + dataSite.usingUser(secondManager).createPublicRandomSite(); + + userModel.setUserRole(UserRole.SiteCollaborator); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(userModel); + + restClient.authenticateUser(secondManager).withCoreAPI().usingUser(userModel).deleteSiteMember(publicSiteModel); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(String.format(ErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user can't remove a site membership of an inexistent uer and response is 404") + public void userIsNotAbleToRemoveSiteMemberOfAnInexistentUser() throws Exception + { + UserModel inexistentUser = new UserModel("inexistenUser", "password"); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(inexistentUser).deleteSiteMember(publicSiteModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, inexistentUser.getUsername())); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove a membership of an inexistent site and response is 404") + public void userIsNotAbleToRemoveMembershipOfInexistentSite() throws Exception + { + SiteModel inexistentSite = new SiteModel("inexistentSite"); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(userModel).deleteSiteMember(inexistentSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(ErrorModel.RELATIONSHIP_NOT_FOUND, userModel.getUsername(), inexistentSite.getId())); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove a membership of an empty site id and response is 404") + public void userIsNotAbleToRemoveMembershipOfEmptySiteId() throws Exception + { + SiteModel inexistentSite = new SiteModel(""); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(userModel).deleteSiteMember(inexistentSite); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(ErrorModel.DELETE_EMPTY_ARGUMENT); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove a membership of another regular user from public site and response is 422") + public void regularUserIsNotAbleToRemoveRegularUserSiteMembershipFromPublicSite() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(secondUserModel); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(userModel); + restClient.authenticateUser(secondUserModel).withCoreAPI().usingUser(userModel).deleteSiteMember(publicSiteModel); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(String.format(ErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove a membership of another regular user from moderated site and response is 422") + public void regularUserIsNotAbleToRemoveRegularUserSiteMembershipFromModeratedSite() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(secondUserModel); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(userModel); + restClient.authenticateUser(secondUserModel).withCoreAPI().usingUser(userModel).deleteSiteMember(moderatedSiteModel); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(String.format(ErrorModel.NOT_SUFFICIENT_PERMISSIONS, moderatedSiteModel.getId())); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove a membership of another regular user from private site and response is 422") + public void regularUserIsNotAbleToRemoveRegularUserSiteMembershipFromPrivateSite() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(userModel); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(secondUserModel); + restClient.authenticateUser(secondUserModel).withCoreAPI().usingUser(userModel).deleteSiteMember(privateSiteModel); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(String.format(ErrorModel.NOT_SUFFICIENT_PERMISSIONS, privateSiteModel.getId())); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove the membership of another regular user from public site and response is 204") + public void adminIsAbleToRemoveRegularUserSiteMembershipFromPublicSite() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(userModel); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(userModel).deleteSiteMember(publicSiteModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove the membership of another regular user from moderated site and response is 204") + public void adminIsAbleToRemoveRegularUserSiteMembershipFromModeratedSite() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(userModel); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(userModel).deleteSiteMember(moderatedSiteModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove the membership of another regular user from private site and response is 204") + public void adminIsAbleToRemoveRegularUserSiteMembershipFromPrivateSite() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(userModel); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(userModel).deleteSiteMember(privateSiteModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove the membership of admin from public site and response is 422") + public void regularUserIsNotAbleToRemoveAdminSiteMembershipFromPublicSite() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(managerModel); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(userModel); + restClient.authenticateUser(userModel).withCoreAPI().usingUser(adminUserModel).deleteSiteMember(publicSiteModel); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(String.format(ErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove the membership of admin from moderated site and response is 422") + public void regularUserIsNotAbleToRemoveAdminSiteMembershipFromModeratedSite() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(managerModel); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(userModel); + restClient.authenticateUser(userModel).withCoreAPI().usingUser(adminUserModel).deleteSiteMember(moderatedSiteModel); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(String.format(ErrorModel.NOT_SUFFICIENT_PERMISSIONS, moderatedSiteModel.getId())); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove the membership of admin from private site and response is 422") + public void regularUserIsNotAbleToRemoveAdminSiteMembershipFromPrivateSite() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(managerModel); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(userModel); + restClient.authenticateUser(userModel).withCoreAPI().usingUser(adminUserModel).deleteSiteMember(privateSiteModel); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(String.format(ErrorModel.NOT_SUFFICIENT_PERMISSIONS, privateSiteModel.getId())); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove the membership of manager of a public site and response is 204") + public void adminIsAbleToRemoveManagerSiteMembershipOfPublicSite() throws Exception + { + UserModel secondManager = dataUser.createRandomTestUser(); + secondManager.setUserRole(UserRole.SiteManager); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(secondManager); + restClient.withCoreAPI().usingSite(publicSiteModel).addPerson(managerModel); + restClient.withCoreAPI().usingUser(managerModel).deleteSiteMember(publicSiteModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove the membership of manager of a moderated site and response is 204") + public void adminIsAbleToRemoveManagerSiteMembershipOfModeratedSite() throws Exception + { + UserModel secondManager = dataUser.createRandomTestUser(); + secondManager.setUserRole(UserRole.SiteManager); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(secondManager); + restClient.withCoreAPI().usingSite(moderatedSiteModel).addPerson(managerModel); + restClient.withCoreAPI().usingUser(managerModel).deleteSiteMember(moderatedSiteModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove the membership of manager of a private site and response is 204") + public void adminIsAbleToRemoveManagerSiteMembershipOfPrivateSite() throws Exception + { + UserModel secondManager = dataUser.createRandomTestUser(); + secondManager.setUserRole(UserRole.SiteManager); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(secondManager); + restClient.withCoreAPI().usingSite(privateSiteModel).addPerson(managerModel); + restClient.withCoreAPI().usingUser(managerModel).deleteSiteMember(privateSiteModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify collaborator is not able to remove the membership of manager of a public site and response is 204") + public void userIsNotAbleToRemoveManagerSiteMembershipOfPublicSite() throws Exception + { + UserModel secondManager = dataUser.createRandomTestUser(); + secondManager.setUserRole(UserRole.SiteManager); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(secondManager); + restClient.withCoreAPI().usingSite(publicSiteModel).addPerson(userModel); + restClient.withCoreAPI().usingSite(publicSiteModel).addPerson(managerModel); + restClient.authenticateUser(userModel).withCoreAPI().usingUser(managerModel).deleteSiteMember(publicSiteModel); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(String.format(ErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify collaborator is not able to remove the membership of manager of a moderated site and response is 204") + public void userIsNotAbleToRemoveManagerSiteMembershipOfModeratedSite() throws Exception + { + UserModel secondManager = dataUser.createRandomTestUser(); + secondManager.setUserRole(UserRole.SiteManager); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(secondManager); + restClient.withCoreAPI().usingSite(publicSiteModel).addPerson(userModel); + restClient.withCoreAPI().usingSite(moderatedSiteModel).addPerson(managerModel); + restClient.authenticateUser(userModel).withCoreAPI().usingUser(managerModel).deleteSiteMember(moderatedSiteModel); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(String.format(ErrorModel.NOT_SUFFICIENT_PERMISSIONS, moderatedSiteModel.getId())); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify collaborator is not able to remove the membership of manager of a private site and response is 204") + public void userIsNotAbleToRemoveManagerSiteMembershipOfPrivateSite() throws Exception + { + UserModel secondManager = dataUser.createRandomTestUser(); + secondManager.setUserRole(UserRole.SiteManager); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(secondManager); + restClient.withCoreAPI().usingSite(privateSiteModel).addPerson(userModel); + restClient.withCoreAPI().usingSite(privateSiteModel).addPerson(managerModel); + restClient.authenticateUser(userModel).withCoreAPI().usingUser(managerModel).deleteSiteMember(privateSiteModel); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(String.format(ErrorModel.NOT_SUFFICIENT_PERMISSIONS, privateSiteModel.getId())); + } +} From b546a1e548a9b18d4354ad8f2355564921096fb5 Mon Sep 17 00:00:00 2001 From: cagache Date: Thu, 24 Nov 2016 15:04:30 +0200 Subject: [PATCH 0621/1491] added network test group --- .../rest/networks/RestGetNetworkForPersonSanityTests.java | 1 + 1 file changed, 1 insertion(+) diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java index e87bf2563..558cfb19d 100644 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java @@ -10,6 +10,7 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +@Test(groups = TestGroup.NETWORKS) public class RestGetNetworkForPersonSanityTests extends RestTest { private UserModel adminUserModel; From 1645ae17755d32a2f5173005d2b4aacefdd887a6 Mon Sep 17 00:00:00 2001 From: cagache Date: Thu, 24 Nov 2016 15:07:27 +0200 Subject: [PATCH 0622/1491] added network test group --- .../rest/networks/RestGetNetworkForPersonSanityTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java index 558cfb19d..28580e5e2 100644 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java @@ -10,7 +10,7 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = TestGroup.NETWORKS) +@Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS }) public class RestGetNetworkForPersonSanityTests extends RestTest { private UserModel adminUserModel; From 2148e6617277a824b4bc084b69caebaec83dd80b Mon Sep 17 00:00:00 2001 From: cagache Date: Thu, 24 Nov 2016 15:37:17 +0200 Subject: [PATCH 0623/1491] added core tests for get site members call --- .../rest/sites/GetSiteMembersCoreTests.java | 139 ++++++++++++++++++ 1 file changed, 139 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/sites/GetSiteMembersCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersCoreTests.java new file mode 100644 index 000000000..f6737a795 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersCoreTests.java @@ -0,0 +1,139 @@ +package org.alfresco.rest.sites; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestSiteMemberModelsCollection; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.model.ErrorModel; +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; + +/** + * Created by Claudia Agache on 11/23/2016. + */ +@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) +public class GetSiteMembersCoreTests extends RestTest +{ + private UserModel userModel, publicSiteContributor, privateSiteConsumer, moderatedSiteManager, admin; + private SiteModel publicSite, privateSite, moderatedSite, moderatedSite2; + private RestSiteMemberModelsCollection siteMembers; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + admin = dataUser.getAdminUser(); + userModel = dataUser.createRandomTestUser(); + publicSiteContributor = dataUser.createRandomTestUser(); + moderatedSiteManager = dataUser.createRandomTestUser(); + privateSiteConsumer = dataUser.createRandomTestUser(); + publicSite = dataSite.usingAdmin().createPublicRandomSite(); + privateSite = dataSite.usingAdmin().createPrivateRandomSite(); + moderatedSite = dataSite.usingAdmin().createModeratedRandomSite(); + moderatedSite2 = dataSite.usingAdmin().createModeratedRandomSite(); + dataUser.addUserToSite(publicSiteContributor, publicSite, UserRole.SiteContributor); + dataUser.addUserToSite(moderatedSiteManager, moderatedSite, UserRole.SiteManager); + dataUser.addUserToSite(privateSiteConsumer, privateSite, UserRole.SiteConsumer); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, 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(publicSiteContributor).withCoreAPI() + .usingSite("NonExistentSiteId").getSiteMembers(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, "NonExistentSiteId")); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, 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(publicSiteContributor).withParams("maxItems=0") + .withCoreAPI().usingSite(publicSite).getSiteMembers(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary("Only positive values supported for maxItems"); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, 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(publicSiteContributor).withParams("skipCount=A") + .withCoreAPI().usingSite(publicSite).getSiteMembers(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary("Invalid paging parameter skipCount:A"); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, 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(userModel).withCoreAPI() + .usingSite(publicSite).getSiteMembers(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembers.assertThat().entriesListContains("id", admin.getUsername()) + .and().entriesListContains("id", publicSiteContributor.getUsername()) + .and().paginationField("count").is("2"); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, 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(userModel).withCoreAPI() + .usingSite(moderatedSite).getSiteMembers(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembers.assertThat().entriesListContains("id", admin.getUsername()) + .and().entriesListContains("id", moderatedSiteManager.getUsername()) + .and().paginationField("count").is("2"); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, 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", admin.getUsername()) + .and().entriesListContains("id", privateSiteConsumer.getUsername()) + .and().paginationField("count").is("2"); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, 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(userModel).withCoreAPI() + .usingSite(privateSite).getSiteMembers(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, privateSite.getTitle())); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, 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(userModel).withCoreAPI() + .usingSite(moderatedSite2).getSiteMembers(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembers.assertThat().entriesListContains("id", admin.getUsername()) + .and().paginationField("count").is("1"); + + restClient.authenticateUser(admin).withCoreAPI().usingSite(moderatedSite2).addPerson(privateSiteConsumer); + + siteMembers = restClient.authenticateUser(userModel).withCoreAPI() + .usingSite(moderatedSite2).getSiteMembers(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembers.assertThat().entriesListContains("id", admin.getUsername()) + .and().entriesListContains("id", privateSiteConsumer.getUsername()) + .and().paginationField("count").is("2"); + } + +} From 235b37e18b1ede74d9a9af7a85bf454edad52f90 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Thu, 24 Nov 2016 16:46:51 +0200 Subject: [PATCH 0624/1491] Fixing DeleteSiteMemberSanityTests --- .../rest/people/DeleteSiteMemberSanityTests.java | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java index 48540caac..e49e3b6f0 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java @@ -68,7 +68,6 @@ public class DeleteSiteMemberSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site collaborator does not have permission to delete another member of the site") - @Bug(id="ACE-5444") public void siteCollaboratorIsNotAbleToDeleteSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception { UserModel newUser = dataUser.createRandomTestUser("testUser"); @@ -78,14 +77,12 @@ public class DeleteSiteMemberSanityTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); restClient.withCoreAPI().usingUser(newUser).deleteSiteMember(siteModel); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(String.format(ErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getId())); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site contributor does not have permission to delete another member of the site") - @Bug(id="ACE-5444") public void siteContributorIsNotAbleToDeleteSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception { UserModel newUser = dataUser.createRandomTestUser("testUser"); @@ -95,14 +92,12 @@ public class DeleteSiteMemberSanityTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); restClient.withCoreAPI().usingUser(newUser).deleteSiteMember(siteModel); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(String.format(ErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getId())); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site consumer does not have permission to delete another member of the site") - @Bug(id="ACE-5444") public void siteConsumerIsNotAbleToDeleteSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception { UserModel newUser = dataUser.createRandomTestUser("testUser"); @@ -112,8 +107,7 @@ public class DeleteSiteMemberSanityTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); restClient.withCoreAPI().usingUser(newUser).deleteSiteMember(siteModel); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(String.format(ErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getId())); } @Bug(id="MNT-16904") From 3b6dd5502fdfcccd98982615dfeb163df9289b4c Mon Sep 17 00:00:00 2001 From: Andrei Rusu Date: Thu, 24 Nov 2016 17:20:42 +0200 Subject: [PATCH 0625/1491] Added tests for getRating CoreTests --- .../rest/ratings/GetRatingCoreTests.java | 161 ++++++++++++++++++ 1 file changed, 161 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/ratings/GetRatingCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/ratings/GetRatingCoreTests.java b/e2e-test/java/org/alfresco/rest/ratings/GetRatingCoreTests.java new file mode 100644 index 000000000..232dced69 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/ratings/GetRatingCoreTests.java @@ -0,0 +1,161 @@ +package org.alfresco.rest.ratings; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.model.RestRatingModel; +import org.alfresco.utility.exception.DataPreparationException; +import org.alfresco.utility.model.ErrorModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.apache.commons.lang.RandomStringUtils; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.testng.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) +public class GetRatingCoreTests extends RestTest { + + private SiteModel siteModel; + private UserModel adminUserModel, userModel; + private FileModel document; + private RestRatingModel returnedRatingModel; + private FolderModel firstFolderModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws DataPreparationException { + adminUserModel = dataUser.getAdminUser(); + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingAdmin().createPublicRandomSite(); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Check that rating for invalid ratingId provided status code is 400.") + public void checkInvalidRatingIdStatusCode() throws Exception { + + document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(adminUserModel).withCoreAPI(); + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "nodes/{nodeId}/ratings/{ratingId}", + document.getNodeRef(), "invalid ratingId"); + restClient.processModel(RestRatingModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary("Invalid ratingSchemeId invalid ratingId"); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Check that rating for nodeId does not exist status code 404 is returned.") + public void getRatingUsingInvalidNodeId() throws Exception { + + document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); + document.setNodeRef(RandomStringUtils.randomAlphanumeric(20)); + returnedRatingModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document) + .getFiveStarRating(); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, document.getNodeRef())); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Get rating of a file that has only likes.") + public void getRatingOfFileThatHasOnlyLikes() throws Exception { + + document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).likeDocument(); + + returnedRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); + Assert.assertEquals(returnedRatingModel.getAggregate().getNumberOfRatings(), 1, + "Node should have 1 like ratings"); + + returnedRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + Assert.assertEquals(returnedRatingModel.getAggregate().getNumberOfRatings(), 0, + "Node should have no five star ratings"); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Get rating of a file that has only stars.") + public void getRatingOfFileThatHasOnlyStars() throws Exception { + + document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); + restClient.authenticateUser(userModel).withCoreAPI().usingResource(document).rateStarsToDocument(5); + + returnedRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and() + .field("aggregate").isNotEmpty(); + Assert.assertEquals(returnedRatingModel.getAggregate().getNumberOfRatings(), 1, + "Node should have 1 five star ratings"); + + returnedRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + Assert.assertEquals(returnedRatingModel.getAggregate().getNumberOfRatings(), 0, + "Node should have no like ratings"); + + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Get rating of a file that has likes and stars.") + public void getRatingOfFileThatHasLikesAndStars() throws Exception { + + document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); + restClient.authenticateUser(userModel).withCoreAPI().usingResource(document).likeDocument(); + restClient.authenticateUser(userModel).withCoreAPI().usingResource(document).rateStarsToDocument(5); + + returnedRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); + Assert.assertEquals(returnedRatingModel.getAggregate().getNumberOfRatings(), 1, + "Node should have 1 like ratings"); + + returnedRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and() + .field("aggregate").isNotEmpty(); + Assert.assertEquals(returnedRatingModel.getAggregate().getNumberOfRatings(), 1, + "Node should have 1 five stars ratings"); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Get rating of a folder that has only likes.") + public void getRatingOfFolderThatHasOnlyLikes() throws Exception { + + firstFolderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(firstFolderModel).likeDocument(); + + returnedRatingModel = restClient.withCoreAPI().usingResource(firstFolderModel).getLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); + Assert.assertEquals(returnedRatingModel.getAggregate().getNumberOfRatings(), 1, + "Node should have 1 like rating"); + + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Get rating of a file that has no ratings.") + public void getRatingOfFileThatHasNoRatings() throws Exception { + + document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); + restClient.authenticateUser(adminUserModel).withCoreAPI(); + + returnedRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + Assert.assertEquals(returnedRatingModel.getAggregate().getNumberOfRatings(), 0, + "Node should have no likes ratings"); + + returnedRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + Assert.assertEquals(returnedRatingModel.getAggregate().getNumberOfRatings(), 0, + "Node should have no five star ratings"); + } + +} From acff481d85a90c46022fe6dcac63958f66d909a6 Mon Sep 17 00:00:00 2001 From: cagache Date: Fri, 25 Nov 2016 11:20:01 +0200 Subject: [PATCH 0626/1491] added assertLastException --- .../rest/comments/AddCommentCoreTests.java | 10 ++-------- .../rest/comments/AddCommentSanityTests.java | 8 ++------ .../comments/UpdateCommentsSanityTests.java | 9 ++------- .../favorites/AddFavoritesSanityTests.java | 3 ++- .../favorites/GetFavoriteSanityTests.java | 9 ++------- .../favorites/GetFavoritesSanityTests.java | 9 ++------- .../people/AddFavoriteSiteSanityTests.java | 3 ++- .../AddSiteMembershipRequestSanityTests.java | 7 +++---- .../people/DeleteFavoriteSiteSanityTests.java | 9 ++++----- ...eleteSiteMembershipRequestSanityTests.java | 10 ++++------ .../people/GetFavoriteSiteSanityTests.java | 7 ++----- .../people/GetFavoriteSitesSanityTests.java | 7 ++----- .../GetPeopleActivitiesSanityTests.java | 3 ++- .../GetPeoplePreferenceSanityTests.java | 3 ++- .../GetPeoplePreferencesSanityTests.java | 5 +++-- .../GetSiteMembershipRequestSanityTests.java | 3 ++- .../people/GetSiteMembershipSanityTests.java | 3 ++- ...SitesMembershipInformationSanityTests.java | 3 ++- .../rest/ratings/AddRatingSanityTests.java | 12 ++++-------- .../rest/ratings/DeleteRatingSanityTests.java | 19 ++++++++----------- .../rest/sites/AddSiteMemberSanityTests.java | 3 ++- .../sites/GetSiteContainerSanityTests.java | 3 ++- .../sites/GetSiteContainersSanityTests.java | 3 ++- .../rest/sites/GetSiteMemberSanityTests.java | 3 ++- .../rest/sites/GetSiteSanityTests.java | 3 ++- .../rest/sites/GetSitesSanityTests.java | 6 ++---- .../sites/RemoveSiteMemberSanityTests.java | 6 ++++-- .../sites/UpdateSiteMemberSanityTests.java | 3 ++- 28 files changed, 72 insertions(+), 100 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentCoreTests.java b/e2e-test/java/org/alfresco/rest/comments/AddCommentCoreTests.java index 00d624fab..cfb3f96c8 100644 --- a/e2e-test/java/org/alfresco/rest/comments/AddCommentCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/AddCommentCoreTests.java @@ -9,13 +9,7 @@ import org.alfresco.rest.model.RestTagModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.ErrorModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FileType; -import org.alfresco.utility.model.LinkModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.model.*; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; @@ -141,7 +135,7 @@ public class AddCommentCoreTests extends RestTest restClient.authenticateUser(member) .withCoreAPI().usingResource(document).addComment(comment); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); } @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java index a10980ce4..f08b0318b 100644 --- a/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java @@ -5,11 +5,7 @@ import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.model.ErrorModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.model.*; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; @@ -97,7 +93,7 @@ public class AddCommentSanityTests extends RestTest { restClient.authenticateUser(new UserModel("random user", "random password")); restClient.withCoreAPI().usingResource(document).addComment("This is a new comment"); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java index fe30b9575..5da722321 100644 --- a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java @@ -6,12 +6,7 @@ import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestCommentModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.model.ErrorModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.model.*; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; @@ -109,7 +104,7 @@ public class UpdateCommentsSanityTests extends RestTest UserModel incorrectUserModel = new UserModel("userName", "password"); restClient.authenticateUser(incorrectUserModel) .withCoreAPI().usingResource(document).updateComment(commentModel, "try to update"); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); } @TestRail(section = { TestGroup.REST_API, TestGroup.SANITY }, executionType = ExecutionType.SANITY, description = "Verify update comment with inexistent nodeId returns status code 404") diff --git a/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesSanityTests.java index b6a547ccf..efd5baff2 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesSanityTests.java @@ -7,6 +7,7 @@ import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; @@ -102,6 +103,6 @@ public class AddFavoritesSanityTests extends RestTest UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); siteManager.setPassword("wrongPassword"); restClient.authenticateUser(siteManager).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java index 3bd440fd2..c6a5e6e1c 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java @@ -7,12 +7,7 @@ import org.alfresco.rest.model.RestPersonFavoritesModelsCollection; import org.alfresco.rest.model.RestSiteModelsCollection; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.model.ErrorModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.model.*; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; @@ -172,7 +167,7 @@ public class GetFavoriteSanityTests extends RestTest siteManager.setPassword("wrongPassword"); restClient.authenticateUser(siteManager).withCoreAPI() .usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).getFavorite(siteModel.getGuid()); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java index 0eeab7df4..e5937ce1c 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java @@ -6,12 +6,7 @@ import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestPersonFavoritesModelsCollection; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.model.ErrorModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.model.*; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; @@ -184,6 +179,6 @@ public class GetFavoritesSanityTests extends RestTest UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); siteManager.setPassword("wrongPassword"); restClient.authenticateUser(siteManager).withCoreAPI().usingAuthUser().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteSanityTests.java index f0fe52649..3cf2d770c 100644 --- a/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteSanityTests.java @@ -4,6 +4,7 @@ import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestFavoriteSiteModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; @@ -95,6 +96,6 @@ public class AddFavoriteSiteSanityTests extends RestTest managerUser.setPassword("newpassword"); restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().addFavoriteSite(siteModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java index 637aac2b5..d392f9ab9 100644 --- a/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java @@ -9,6 +9,7 @@ import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; @@ -121,11 +122,9 @@ public class AddSiteMembershipRequestSanityTests extends RestTest @Bug(id = "MNT-16557") public void unauthenticatedUserIsNotAbleToCreateSiteMembershipRequest() throws JsonToModelConversionException, Exception { - requestModel = restClient.authenticateUser(new UserModel("random user", "random password")) + restClient.authenticateUser(new UserModel("random user", "random password")) .withCoreAPI() .usingUser(newMember).addSiteMembershipRequest(siteModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); - requestModel.assertThat().field("id").isNotEmpty() - .assertThat().field("site").isNotEmpty(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java index bdacbb87a..0f5505ad2 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java @@ -2,10 +2,8 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.model.ErrorModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.model.*; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -115,6 +113,7 @@ public class DeleteFavoriteSiteSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } + @Bug(id = "MNT-16904") @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized to remove a site from its favorite sites list with Rest API when authentication fails (401)") @@ -127,6 +126,6 @@ public class DeleteFavoriteSiteSanityTests extends RestTest managerUser.setPassword("newpassword"); restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java index ee0142301..bf7c89503 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java @@ -6,10 +6,7 @@ import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.data.RandomData; import org.alfresco.utility.exception.DataPreparationException; -import org.alfresco.utility.model.ErrorModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.model.*; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; @@ -157,7 +154,8 @@ public class DeleteSiteMembershipRequestSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } - + + @Bug(id = "MNT-16904") @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Failed authentication get site member call returns status code 401") @@ -170,6 +168,6 @@ public class DeleteSiteMembershipRequestSanityTests extends RestTest restClient.authenticateUser(inexistentUser) .withCoreAPI() .usingAuthUser().deleteSiteMembershipRequest(siteModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java index 36e899141..61f379312 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java @@ -3,10 +3,7 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestSiteModel; import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.model.ErrorModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.model.*; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; @@ -139,6 +136,6 @@ public class GetFavoriteSiteSanityTests extends RestTest managerUser.setPassword("newpassword"); restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().getFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java index b5d2412ac..eebc052c3 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java @@ -3,10 +3,7 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestSiteModelsCollection; import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.model.ErrorModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.model.*; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; @@ -128,6 +125,6 @@ public class GetFavoriteSitesSanityTests extends RestTest anyUser.setPassword("newpassword"); restClient.authenticateUser(anyUser).withCoreAPI().usingAuthUser().getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java index 1b10b5ec8..a9e7dd633 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java @@ -5,6 +5,7 @@ import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestActivityModelsCollection; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; @@ -117,6 +118,6 @@ public class GetPeopleActivitiesSanityTests extends RestTest managerUser.setPassword("newpassword"); restClient.authenticateUser(managerUser).withCoreAPI().usingUser(userModel).getPersonActivities(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceSanityTests.java index 504f42e02..674d7c6b4 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceSanityTests.java @@ -5,6 +5,7 @@ import org.alfresco.rest.model.RestPreferenceModel; import org.alfresco.utility.constants.PreferenceName; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; @@ -114,6 +115,6 @@ public class GetPeoplePreferenceSanityTests extends RestTest restClient.authenticateUser(managerUser) .withCoreAPI().usingAuthUser().getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesSanityTests.java index 394381427..413a2a959 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesSanityTests.java @@ -5,6 +5,7 @@ import org.alfresco.rest.model.RestPreferenceModelsCollection; import org.alfresco.utility.constants.PreferenceName; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; @@ -114,7 +115,7 @@ public class GetPeoplePreferencesSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized to gets its preferences with Rest API when authentication fails(401)") - public void managerUserGetsPeoplePreferencesIsNotAUthorized() throws Exception + public void managerUserGetsPeoplePreferencesIsNotAuthorized() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); @@ -122,6 +123,6 @@ public class GetPeoplePreferencesSanityTests extends RestTest managerUser.setPassword("newpassword"); restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().getPersonPreferences(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestSanityTests.java index de1a9f953..fd5946a50 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestSanityTests.java @@ -8,6 +8,7 @@ import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; @@ -128,6 +129,6 @@ public class GetSiteMembershipRequestSanityTests extends RestTest .addSiteMembershipRequest(siteModel); restClient.withCoreAPI().usingUser(newMember).getSiteMembershipRequest(siteModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java index 48624edfb..86741e5e4 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java @@ -6,6 +6,7 @@ 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.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; @@ -115,6 +116,6 @@ public class GetSiteMembershipSanityTests extends RestTest .withCoreAPI() .usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) .getSiteMembership(siteModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java index a401110eb..eeb6afc63 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java @@ -6,6 +6,7 @@ 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.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; @@ -116,6 +117,6 @@ public class GetSitesMembershipInformationSanityTests extends RestTest .withCoreAPI() .usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) .getSitesMembershipInformation(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java index 777dd778c..5f49db8c7 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java @@ -6,11 +6,7 @@ import org.alfresco.rest.model.RestRatingModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.exception.DataPreparationException; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.model.*; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; @@ -117,7 +113,7 @@ public class AddRatingSanityTests extends RestTest public void unauthenticatedUserIsNotAbleToLikeDocument() throws Exception { restClient.authenticateUser(new UserModel("random user", "random password")).withCoreAPI().usingResource(document).likeDocument(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); } @TestRail(section = { TestGroup.REST_API, @@ -173,7 +169,7 @@ public class AddRatingSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.CREATED); returnedRatingModel.assertThat().field("myRating").is(String.valueOf(3)) .and().field("id").is("fiveStar") - .and().field("aggregate").isNotEmpty();; + .and().field("aggregate").isNotEmpty(); } @TestRail(section = { TestGroup.REST_API, @@ -182,6 +178,6 @@ public class AddRatingSanityTests extends RestTest public void unauthenticatedUserIsNotAbleToRateStarsToDocument() throws Exception { restClient.authenticateUser(new UserModel("random user", "random password")).withCoreAPI().usingResource(document).rateStarsToDocument(5); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java index 5b21b39fb..e028d229e 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java @@ -6,11 +6,7 @@ import org.alfresco.rest.model.RestRatingModelsCollection; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.exception.DataPreparationException; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.model.*; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; @@ -160,8 +156,9 @@ public class DeleteRatingSanityTests extends RestTest .assertNodeHasNoFiveStarRating() .and().entriesListIsNotEmpty() .and().paginationExist(); - } - + } + + @Bug(id = "MNT-16904") @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to remove its own rating of a document") public void unauthenticatedUserIsNotAbleToDeleteRatings() throws Exception @@ -175,10 +172,10 @@ public class DeleteRatingSanityTests extends RestTest restClient.authenticateUser(new UserModel("random user", "random password")); restClient.withCoreAPI().usingResource(document).deleteLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); } @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, @@ -197,9 +194,9 @@ public class DeleteRatingSanityTests extends RestTest restClient.authenticateUser(userB); restClient.authenticateUser(userB).withCoreAPI().usingResource(document).deleteLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java index 62c24caff..7b82ebb5e 100644 --- a/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java @@ -4,6 +4,7 @@ import org.alfresco.rest.RestTest; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; @@ -105,6 +106,6 @@ public class AddSiteMemberSanityTests extends RestTest UserModel inexistentUser = new UserModel("inexistent user", "inexistent password"); restClient.authenticateUser(inexistentUser) .withCoreAPI().usingSite(siteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java index 45478751d..3e8be929b 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java @@ -5,6 +5,7 @@ import org.alfresco.rest.model.RestSiteContainerModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; @@ -108,6 +109,6 @@ public class GetSiteContainerSanityTests extends RestTest dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); restClient.authenticateUser(userModel) .withCoreAPI().usingSite(siteModel).getSiteContainer(siteContainerModel.onModel()); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java index a4b7cddb1..509dfea81 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java @@ -7,6 +7,7 @@ import org.alfresco.utility.data.DataSite; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; @@ -112,6 +113,6 @@ public class GetSiteContainersSanityTests extends RestTest dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); restClient.authenticateUser(userModel) .withCoreAPI().usingSite(siteModel).getSiteContainers(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java index 719950e32..620f73374 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java @@ -6,6 +6,7 @@ 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.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; @@ -100,6 +101,6 @@ public class GetSiteMemberSanityTests extends RestTest UserModel inexistentUser = new UserModel("inexistent user", "inexistent password"); restClient.authenticateUser(inexistentUser); restClient.withCoreAPI().usingSite(siteModel).getSiteMember(userModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteSanityTests.java index e3afe1129..d2f4b28d2 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteSanityTests.java @@ -8,6 +8,7 @@ import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; @@ -117,6 +118,6 @@ public class GetSiteSanityTests extends RestTest restClient.authenticateUser(userModel).withParams("maxItems=10000") .withCoreAPI() .getSites(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java index 3e0353f01..c9e25463d 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java @@ -3,16 +3,14 @@ package org.alfresco.rest.sites; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataSite; -import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -108,6 +106,6 @@ public class GetSitesSanityTests extends RestTest dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); restClient.authenticateUser(userModel).withParams("maxItems=1000") .withCoreAPI().getSites(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java index f0f5df579..17a4daeee 100644 --- a/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java @@ -6,6 +6,7 @@ import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; @@ -101,7 +102,8 @@ public class RemoveSiteMemberSanityTests extends RestTest restClient.withCoreAPI().getSites().assertThat().entriesListDoesNotContain("id", testUserModel.getUsername()); restClient.assertStatusCodeIs(HttpStatus.OK); } - + + @Bug(id="MNT-16904") @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that unauthenticated user is not able to delete site member") public void unauthenticatedUserIsNotAuthorizedToDeleteSiteMember() throws Exception{ @@ -109,6 +111,6 @@ public class RemoveSiteMemberSanityTests extends RestTest restClient.authenticateUser(inexistentUser) .withCoreAPI().usingSite(siteModel).deleteSiteMember(testUserModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java index a64af8a52..29e4703c0 100644 --- a/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java @@ -4,6 +4,7 @@ import org.alfresco.rest.RestTest; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; @@ -103,6 +104,6 @@ public class UpdateSiteMemberSanityTests extends RestTest restClient.authenticateUser(inexistentUser); testUserModel.setUserRole(UserRole.SiteCollaborator); restClient.withCoreAPI().usingSite(siteModel).updateSiteMember(testUserModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); } } From a765d6de04650a030964d4d7c3b0f5cacd32a5a1 Mon Sep 17 00:00:00 2001 From: cagache Date: Fri, 25 Nov 2016 11:21:21 +0200 Subject: [PATCH 0627/1491] updated tests for 5.2 --- .../alfresco/rest/comments/AddCommentsSanityTests.java | 3 +-- .../alfresco/rest/comments/GetCommentsCoreTests.java | 6 ++---- .../alfresco/rest/ratings/GetRatingsSanityTests.java | 1 - .../org/alfresco/rest/tags/GetNodeTagsSanityTests.java | 10 ++-------- 4 files changed, 5 insertions(+), 15 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java index f5afee1ff..3450ac655 100644 --- a/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java @@ -110,11 +110,10 @@ public class AddCommentsSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user gets status code 401 on post multiple comments call") - @Bug(id="MNT-16904") public void unauthenticatedUserIsNotAbleToAddComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(new UserModel("random user", "random password")) .withCoreAPI().usingResource(document).addComments(comment1, comment2); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(ErrorModel.AUTHENTICATION_FAILED); } } diff --git a/e2e-test/java/org/alfresco/rest/comments/GetCommentsCoreTests.java b/e2e-test/java/org/alfresco/rest/comments/GetCommentsCoreTests.java index d2325405b..3436e01df 100644 --- a/e2e-test/java/org/alfresco/rest/comments/GetCommentsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/GetCommentsCoreTests.java @@ -103,22 +103,20 @@ public class GetCommentsCoreTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Verify get comments from node with invalid network id returns status code 401") - @Bug(id = "MNT-16904") public void getCommentsWithInvalidNetwork() throws Exception { networkUserModel.setDomain("invalidNetwork"); restClient.authenticateUser(userModel).withCoreAPI().usingResource(document).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Verify get comments from node with empty network id returns status code 401") - @Bug(id = "MNT-16904") public void getCommentsWithEmptyNetwork() throws Exception { networkUserModel.setDomain(""); restClient.authenticateUser(userModel).withCoreAPI().usingResource(document).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } } diff --git a/e2e-test/java/org/alfresco/rest/ratings/GetRatingsSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/GetRatingsSanityTests.java index da7217d7c..52c90455e 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/GetRatingsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/GetRatingsSanityTests.java @@ -120,7 +120,6 @@ public class GetRatingsSanityTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to retrieve document ratings") - @Bug(id = "MNT-16904") public void unauthenticatedUserIsNotAbleToRetrieveRatings() throws Exception { restClient.authenticateUser(adminUser); diff --git a/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java index 7b211cd3e..71767d2cf 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java @@ -7,12 +7,7 @@ import org.alfresco.rest.model.RestTagModelsCollection; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.StatusModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; +import org.alfresco.utility.model.*; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -115,11 +110,10 @@ public class GetNodeTagsSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to get node tags") - @Bug(id="MNT-16904") public void unauthenticatedUserIsNotAbleToRetrieveNodeTags() throws JsonToModelConversionException, Exception { restClient.authenticateUser(new UserModel("random user", "random password")); restClient.withCoreAPI().usingResource(document).getNodeTags(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(ErrorModel.AUTHENTICATION_FAILED); } } \ No newline at end of file From a1fe9dfba1179e01f03c57b5e268826bf2f59e1e Mon Sep 17 00:00:00 2001 From: cagache Date: Fri, 25 Nov 2016 12:29:11 +0200 Subject: [PATCH 0628/1491] added users to site in dataPreparation --- .../GetPeopleActivitiesSanityTests.java | 26 +++++++------------ 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java index a9e7dd633..8de50d23d 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java @@ -4,10 +4,8 @@ import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestActivityModelsCollection; import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.StatusModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.model.*; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; @@ -26,7 +24,7 @@ public class GetPeopleActivitiesSanityTests extends RestTest { UserModel userModel; SiteModel siteModel; - UserModel searchedUser; + private DataUser.ListUserWithRoles usersWithRoles; private RestActivityModelsCollection restActivityModelsCollection; @BeforeClass(alwaysRun = true) @@ -35,6 +33,7 @@ public class GetPeopleActivitiesSanityTests extends RestTest userModel = dataUser.createRandomTestUser(); siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, @@ -42,8 +41,7 @@ public class GetPeopleActivitiesSanityTests extends RestTest description = "Verify manager user gets its activities with Rest API and response is successful") public void managerUserShouldGetPeopleActivitiesList() throws Exception { - UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); + UserModel managerUser = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); dataContent.usingUser(managerUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); restActivityModelsCollection = restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().getPersonActivities(); @@ -57,8 +55,7 @@ public class GetPeopleActivitiesSanityTests extends RestTest description = "Verify collaborator user gets its activities with Rest API and response is successful") public void collaboratorUserShouldGetPeopleActivitiesList() throws Exception { - UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(collaboratorUser, siteModel, UserRole.SiteCollaborator); + UserModel collaboratorUser = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); dataContent.usingUser(collaboratorUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); restActivityModelsCollection = restClient.authenticateUser(collaboratorUser).withCoreAPI().usingAuthUser().getPersonActivities(); @@ -72,8 +69,7 @@ public class GetPeopleActivitiesSanityTests extends RestTest description = "Verify contributor user gets its activities with Rest API and response is successful") public void contributorUserShouldGetPeopleActivitiesList() throws Exception { - UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(contributorUser, siteModel, UserRole.SiteContributor); + UserModel contributorUser = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); dataContent.usingUser(contributorUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); restActivityModelsCollection = restClient.authenticateUser(contributorUser).withCoreAPI().usingAuthUser().getPersonActivities(); @@ -87,8 +83,7 @@ public class GetPeopleActivitiesSanityTests extends RestTest description = "Verify consumer user gets its activities with Rest API and response is successful") public void consumerUserShouldGetPeopleActivitiesList() throws Exception { - UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel, UserRole.SiteConsumer); + UserModel consumerUser = usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer); restActivityModelsCollection = restClient.authenticateUser(consumerUser).withCoreAPI().usingAuthUser().getPersonActivities(); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -106,8 +101,7 @@ public class GetPeopleActivitiesSanityTests extends RestTest restActivityModelsCollection.assertThat().entriesListIsNotEmpty().and().entriesListContains("siteId", siteModel.getId()) .and().paginationExist(); } - - @Bug(id = "MNT-16904") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized to gets another user activities with Rest API") @@ -118,6 +112,6 @@ public class GetPeopleActivitiesSanityTests extends RestTest managerUser.setPassword("newpassword"); restClient.authenticateUser(managerUser).withCoreAPI().usingUser(userModel).getPersonActivities(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(ErrorModel.AUTHENTICATION_FAILED); } } From aa1dff294e3593aa00615ec1024ce1cac2c0e8c5 Mon Sep 17 00:00:00 2001 From: cagache Date: Fri, 25 Nov 2016 12:41:00 +0200 Subject: [PATCH 0629/1491] create unauthenticatedUser in dataPreparation (cherry picked from commit 80a7442) --- .../people/GetPeopleActivitiesSanityTests.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java index 8de50d23d..75d00db68 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java @@ -22,7 +22,7 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.SANITY }) public class GetPeopleActivitiesSanityTests extends RestTest { - UserModel userModel; + UserModel userModel, unauthenticatedUser; SiteModel siteModel; private DataUser.ListUserWithRoles usersWithRoles; private RestActivityModelsCollection restActivityModelsCollection; @@ -34,6 +34,8 @@ public class GetPeopleActivitiesSanityTests extends RestTest siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + unauthenticatedUser = dataUser.usingAdmin().createRandomTestUser(); + unauthenticatedUser.setPassword("newpassword"); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, @@ -104,14 +106,10 @@ public class GetPeopleActivitiesSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.SANITY, - description = "Verify manager user is NOT Authorized to gets another user activities with Rest API") - public void managerUserShouldGetPeopleActivitiesListIsNotAuthorized() throws Exception + description = "Verify unauthenticated user is NOT Authorized to gets another user activities with Rest API") + public void unauthenticatedUserShouldNotGetPeopleActivitiesList() throws Exception { - UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); - managerUser.setPassword("newpassword"); - - restClient.authenticateUser(managerUser).withCoreAPI().usingUser(userModel).getPersonActivities(); + restClient.authenticateUser(unauthenticatedUser).withCoreAPI().usingUser(userModel).getPersonActivities(); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(ErrorModel.AUTHENTICATION_FAILED); } } From d2f2652aa371ed6b9fdaa996877d654e101a2dac Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Fri, 25 Nov 2016 15:10:29 +0200 Subject: [PATCH 0630/1491] CORE-REST API: removeRating (delete /nodes/{nodeId}/ratings/{ratingId}) --- .../rest/ratings/DeleteRatingCoreTests.java | 140 ++++++++++++++++++ 1 file changed, 140 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/ratings/DeleteRatingCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingCoreTests.java b/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingCoreTests.java new file mode 100644 index 000000000..3596747d6 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingCoreTests.java @@ -0,0 +1,140 @@ +package org.alfresco.rest.ratings; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestRatingModel; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.exception.DataPreparationException; +import org.alfresco.utility.model.ErrorModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +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.BeforeMethod; +import org.testng.annotations.Test; + +@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) +public class DeleteRatingCoreTests extends RestTest +{ + + private SiteModel siteModel; + private UserModel adminUser; + private FolderModel folderModel; + private FileModel document; + private ListUserWithRoles usersWithRoles; + private RestRatingModel returnedRatingModel; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws DataPreparationException + { + adminUser = dataUser.getAdminUser(); + siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); + + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, + UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + } + + @BeforeMethod() + public void setUp() throws DataPreparationException, Exception { + folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that if ratingId provided is unknown status code returned is 400") + public void deleteInvalidRating() throws Exception + { + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).deleteInvalidRating("random_rating"); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(ErrorModel.INVALID_RATING, "random_rating")); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that if nodeId does not exist status code returned is 404") + public void deleteRatingUsingInvalidDocument() throws Exception + { + document.setNodeRef("random_value"); + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).deleteLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, "random_value")); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Delete rating stars for a document that was not rated") + @Bug(id = "MNT-17181") + public void deleteStarsForANotRatedDocument() throws Exception + { + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).deleteFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Delete like rating for a document that was not liked") + @Bug(id = "MNT-17181") + public void deleteLikeForANotLikedDocument() throws Exception + { + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).deleteLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Delete like for a file then add it again") + public void likeDocumentAfterLikeRatingIsDeleted() throws Exception + { + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); + restClient.withCoreAPI().usingResource(document).deleteLikeRating(); + returnedRatingModel = restClient.withCoreAPI().usingResource(document).likeDocument(); + + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("true") + .and().field("id").is("likes") + .and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Delete stars for a file then add them again") + public void addStarsToDocumentAfterRatingIsDeleted() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(document).rateStarsToDocument(5); + restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + returnedRatingModel = restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); + + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("5") + .and().field("id").is("fiveStar") + .and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Delete rating of a document using site manager") + public void deleteDocumentRatingUsingManager() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(document).rateStarsToDocument(5); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(document).likeDocument(); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(document).deleteFiveStarRating(); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(document).deleteLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingResource(document).getRatings().assertNodeIsLiked().assertNodeHasFiveStarRating(); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "One user is not able to delete like of another user") + public void deleteLikeOfAnotherUser() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingResource(document).likeDocument(); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(document).deleteLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withCoreAPI().usingResource(document).getRatings().assertNodeIsLiked(); + } +} \ No newline at end of file From c7b0017145c2fc29b61c99d6ff44a8d9a548c09b Mon Sep 17 00:00:00 2001 From: cagache Date: Mon, 28 Nov 2016 15:54:03 +0200 Subject: [PATCH 0631/1491] test: added core tests for getSiteForMember (get /people/{personId}/sites/{siteId}) --- .../people/GetSiteMembershipCoreTests.java | 159 ++++++++++++++++++ 1 file changed, 159 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/people/GetSiteMembershipCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipCoreTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipCoreTests.java new file mode 100644 index 000000000..ff6078938 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipCoreTests.java @@ -0,0 +1,159 @@ +package org.alfresco.rest.people; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestSiteEntry; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.model.ErrorModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Created by Claudia Agache on 11/28/2016. + */ +@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) +public class GetSiteMembershipCoreTests extends RestTest +{ + UserModel regularUser, publicSiteManager, privateSiteManager, moderatedSiteManager, adminUser; + SiteModel publicSite, privateSite, moderatedSite; + private DataUser.ListUserWithRoles publicSiteUsers; + private RestSiteEntry restSiteEntry; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + regularUser = dataUser.createRandomTestUser(); + privateSiteManager = dataUser.createRandomTestUser(); + moderatedSiteManager = dataUser.createRandomTestUser(); + publicSite = dataSite.usingAdmin().createPublicRandomSite(); + privateSite = dataSite.usingAdmin().createPrivateRandomSite(); + moderatedSite = dataSite.usingAdmin().createModeratedRandomSite(); + + publicSiteUsers = dataUser.addUsersWithRolesToSite(publicSite, + UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + publicSiteManager = publicSiteUsers.getOneUserWithRole(UserRole.SiteManager); + dataUser.usingAdmin().addUserToSite(privateSiteManager, privateSite, UserRole.SiteManager); + dataUser.usingAdmin().addUserToSite(moderatedSiteManager, moderatedSite, UserRole.SiteManager); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, + description = "Verify request using -me- string in place of personId returns site membership information for currently authenticated user.") + public void getSiteMembershipUsingMe() throws Exception + { + restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)); + restSiteEntry = restClient.withCoreAPI().usingMe().getSiteMembership(publicSite); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteEntry.assertThat().field("role").is(UserRole.SiteCollaborator) + .and().field("id").is(publicSite.getId()) + .and().field("site").isNotEmpty(); + } + + @Bug(id="REPO-1642", description = "reproduced on 5.2.1 only, it works on 5.2.0") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, + description = "Verify get site membership for a site returns status 404 when personId does not exist.") + public void getSiteMembershipUsingNonExistentPersonId() throws Exception + { + UserModel someUser = new UserModel("someUser", DataUser.PASSWORD); + + restClient.authenticateUser(regularUser).withCoreAPI().usingUser(someUser).getSiteMembership(publicSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, "someUser")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, + description = "Verify get site membership for a site returns status 404 when siteId does not exist.") + public void getSiteMembershipUsingNonExistentSiteId() throws Exception + { + SiteModel someSite = new SiteModel("someSite"); + + restClient.authenticateUser(regularUser).withCoreAPI().usingAuthUser().getSiteMembership(someSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(ErrorModel.RELATIONSHIP_NOT_FOUND, regularUser.getUsername(), "someSite")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, + description = "Verify get site membership for a site returns status 404 when personId is not a site member.") + public void getSiteMembershipForPersonThatIsNotSiteMember() throws Exception + { + restClient.authenticateUser(publicSiteManager).withCoreAPI() + .usingUser(regularUser).getSiteMembership(publicSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(ErrorModel.RELATIONSHIP_NOT_FOUND, regularUser.getUsername(), publicSite.getTitle())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, + description = "Verify regular user is not able to retrieve site membership information of a private site member.") + public void regularUserIsNotAbleToRetrieveSiteMembershipForPrivateSiteManager() throws Exception + { + restClient.authenticateUser(regularUser).withCoreAPI() + .usingUser(privateSiteManager).getSiteMembership(privateSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(ErrorModel.RELATIONSHIP_NOT_FOUND, privateSiteManager.getUsername(), privateSite.getTitle())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, + description = "Verify regular user is able to retrieve site membership information of a moderated site member.") + public void regularUserGetsSiteMembershipForModeratedSiteMember() throws Exception + { + restSiteEntry = restClient.authenticateUser(regularUser).withCoreAPI() + .usingUser(moderatedSiteManager).getSiteMembership(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteEntry.assertThat().field("role").is(UserRole.SiteManager) + .and().field("id").is(moderatedSite.getId()) + .and().field("site").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, + description = "Verify regular user is able to retrieve site membership information of a public site member.") + public void regularUserGetsSiteMembershipForPublicSiteMember() throws Exception + { + restSiteEntry = restClient.authenticateUser(regularUser).withCoreAPI() + .usingUser(publicSiteManager).getSiteMembership(publicSite); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteEntry.assertThat().field("role").is(UserRole.SiteManager) + .and().field("id").is(publicSite.getId()) + .and().field("site").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, + description = "Verify if Admin user is able to retrieve site membership information of him.") + public void adminGetsSiteMembershipForHim() throws Exception + { + restSiteEntry = restClient.authenticateUser(adminUser).withCoreAPI() + .usingUser(adminUser).getSiteMembership(privateSite); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteEntry.assertThat().field("role").is(UserRole.SiteManager) + .and().field("id").is(privateSite.getId()) + .and().field("site").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, + description = "Verify if Admin user is able to retrieve site membership information of him.") + public void getSiteMembershipAfterRemovingASiteMember() throws Exception + { + UserModel publicSiteConsumer = publicSiteUsers.getOneUserWithRole(UserRole.SiteConsumer); + restClient.authenticateUser(publicSiteManager).withCoreAPI() + .usingSite(publicSite).deleteSiteMember(publicSiteConsumer); + restClient.authenticateUser(publicSiteManager).withCoreAPI() + .usingUser(publicSiteConsumer).getSiteMembership(publicSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(ErrorModel.RELATIONSHIP_NOT_FOUND, publicSiteConsumer.getUsername(), publicSite.getTitle())); + } +} From a8fb917ecc4ee5794e95cf1157cb44bf9620dd88 Mon Sep 17 00:00:00 2001 From: cagache Date: Mon, 28 Nov 2016 16:05:00 +0200 Subject: [PATCH 0632/1491] bug: added bug annotation for 5.2.1 --- .../org/alfresco/rest/favorites/GetFavoritesCoreTests.java | 1 + .../org/alfresco/rest/people/DeleteFavoriteSiteCoreTests.java | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesCoreTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesCoreTests.java index 468a752a6..ea5e5d269 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesCoreTests.java @@ -229,6 +229,7 @@ public class GetFavoritesCoreTests extends RestTest .and().paginationField("totalItems").is("2"); } + @Bug(id="REPO-1642", description = "reproduced on 5.2.1 only, it works on 5.2.0") @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify request using personId that does not exist returns status 404") public void checkFavoritesWhenPersonIdDoesNotExist() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteCoreTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteCoreTests.java index 7aa1d952a..74c7bd877 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteCoreTests.java @@ -7,6 +7,7 @@ import org.alfresco.utility.model.ErrorModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -39,7 +40,8 @@ public class DeleteFavoriteSiteCoreTests extends RestTest restClient.withCoreAPI().usingMe().removeFavoriteSite(siteModel); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } - + + @Bug(id="REPO-1642", description = "reproduced on 5.2.1 only, it works on 5.2.0") @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify inexistent user is not able to remove a site from favorites and response is 404") public void inexistentUserIsNotAbleToRemoveFavoriteSite() throws Exception From 37a799cab8eebec44adffb57e6b0b03f2f2a6afb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alecsandru=20Prun=C4=83?= Date: Mon, 28 Nov 2016 17:36:08 +0200 Subject: [PATCH 0633/1491] test: added GetPeoplePreferencesCoreTests --- .../people/GetPeoplePreferencesCoreTests.java | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesCoreTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesCoreTests.java new file mode 100644 index 000000000..1e302ac36 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesCoreTests.java @@ -0,0 +1,74 @@ +package org.alfresco.rest.people; + +import org.alfresco.rest.RestTest; +import org.alfresco.utility.constants.PreferenceName; +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; + +@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) +public class GetPeoplePreferencesCoreTests extends RestTest +{ + UserModel userModel; + SiteModel siteModel; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + dataSite.usingUser(userModel).usingSite(siteModel).addSiteToFavorites(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, + description = "Verify user is Forbidden to get a specific preference for another user with Rest API and response is 403") + public void userDoesNotHaveAccessToFavoriteSitesOfAnotherUser() throws Exception + { + UserModel secondUser = dataUser.createRandomTestUser(); + restClient.authenticateUser(secondUser).withCoreAPI().usingUser(userModel) + .getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + restClient.assertLastError().containsSummary("Permission was denied"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, + description = "Verify manager fails to get a specific preference for an invalid user with Rest API and response is 404") + public void statusNotFoundIsReturnedForAPersonIDThatDoesNotExist() throws Exception + { + restClient.authenticateUser(userModel).withCoreAPI().usingUser(new UserModel("invalidPersonID", "password")) + .getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + restClient.assertLastError().containsSummary("The entity with id: personId is null. was not found"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, + description = "Verify manager fails to get a specific preference for an invalid preference with Rest API and response is 404") + public void statusNotFoundIsReturnedForAPreferenceNameThatDoesNotExist() throws Exception + { + restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser() + .getPersonPreferenceInformation("invalidPreferenceName"); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + restClient.assertLastError().containsSummary(String.format("The relationship resource was not found for the" + + " entity with id: %s and a relationship id of invalidPreferenceName", userModel.getUsername())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, + description = "Verify manager fails to get a specific preference for an removed preference with Rest API and response is 404") + public void statusNotFoundIsReturnedForAPreferenceNameThatHasBeenRemoved() throws Exception + { + SiteModel preferenceSite = dataSite.usingUser(userModel).createPublicRandomSite(); + dataSite.usingUser(userModel).usingSite(preferenceSite).addSiteToFavorites(); + dataSite.usingUser(userModel).usingSite(preferenceSite).removeSiteFromFavorites(); + restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser() + .getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + preferenceSite.getId()); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + restClient.assertLastError().containsSummary(String.format("The relationship resource was not found for the" + + " entity with id: %s and a relationship id of %s", userModel.getUsername(), + PreferenceName.SITES_FAVORITES_PREFIX + preferenceSite.getId())); + } +} From 1f32dc8d6997d2be502b405048ff45ccf7b039c9 Mon Sep 17 00:00:00 2001 From: Andrei Rusu Date: Mon, 28 Nov 2016 17:36:44 +0200 Subject: [PATCH 0634/1491] Added tests for GetSiteMembershipRequestsCore --- .../GetSiteMembershipRequestsCoreTests.java | 179 ++++++++++++++++++ 1 file changed, 179 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsCoreTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsCoreTests.java new file mode 100644 index 000000000..d2ff8e6f1 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsCoreTests.java @@ -0,0 +1,179 @@ +package org.alfresco.rest.people; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.core.RestWrapper; +import org.alfresco.rest.model.RestSiteMembershipRequestModelsCollection; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.RandomData; +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.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.springframework.social.alfresco.api.entities.Role; +import org.springframework.social.alfresco.api.entities.Site.Visibility; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Tests for getSiteMembershipRequests (get + * /people/{personId}/site-membership-requests) Core-RestAPI call + * + * @author Andrei Rusu + */ + +@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) +public class GetSiteMembershipRequestsCoreTests extends RestTest { + + UserModel userModel, newMember; + SiteModel siteModel, siteModel2; + RestWrapper restWrapper; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception { + + String siteId = RandomData.getRandomName("site"); + siteModel = dataSite.usingUser(userModel) + .createSite(new SiteModel(Visibility.MODERATED, siteId, siteId, siteId, siteId)); + newMember = dataUser.createRandomTestUser(); + + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(siteModel); + + restClient.assertStatusCodeIs(HttpStatus.CREATED); + } + + @Bug(id = "MNT-16557") + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify that for invalid maxItems parameter status code is 400.") + public void checkInvalidMaxItemsStatusCode() throws Exception { + + UserModel adminUser = dataUser.getAdminUser(); + + restClient.authenticateUser(adminUser).withParams("maxItems=AB").withCoreAPI().usingUser(newMember) + .getSiteMembershipRequests().assertThat().entriesListIsNotEmpty(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary("Invalid paging parameter"); + } + + @Bug(id = "MNT-16557") + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify that for invalid skipCount parameter status code is 400.") + public void checkInvalidSkipCountStatusCode() throws Exception { + + UserModel adminUser = dataUser.getAdminUser(); + + restClient.authenticateUser(adminUser).withParams("skipCount=AB").withCoreAPI().usingUser(newMember) + .getSiteMembershipRequests().assertThat().entriesListIsNotEmpty(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary("Invalid paging parameter"); + } + + @Bug(id = "MNT-16557") + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify that if personId does not exist status code is 404.") + public void ifPersonIdDoesNotExist() throws Exception { + + UserModel adminUser = dataUser.getAdminUser(); + + restClient.authenticateUser(adminUser).withCoreAPI(); + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, + "people/{personId}/site-membership-requests?{parameters}", newMember.getUsername(), + restClient.getParameters()); + restClient.processModels(RestSiteMembershipRequestModelsCollection.class, request).assertThat() + .entriesListIsNotEmpty(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary("not found"); + } + + @Bug(id = "MNT-16557") + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Specify -me- string in place of for request.") + public void replacePersonIdWithMeRequest() throws Exception { + + UserModel adminUser = dataUser.getAdminUser(); + + restClient.authenticateUser(adminUser).withCoreAPI(); + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, + "people/{me}/site-membership-requests?{parameters}", newMember.getUsername(), + restClient.getParameters()); + restClient.processModels(RestSiteMembershipRequestModelsCollection.class, request).assertThat() + .entriesListIsNotEmpty(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary("not found"); + } + + @Bug(id = "MNT-16557") + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Use empty personId.") + public void useEmptyPersonId() throws Exception { + + UserModel adminUser = dataUser.getAdminUser(); + + restClient.authenticateUser(adminUser).withCoreAPI(); + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, + "people/{personId}/site-membership-requests?{parameters}", "", restClient.getParameters()); + restClient.processModels(RestSiteMembershipRequestModelsCollection.class, request); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary("not found"); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Get site membership requests to a public site.") + public void getRequestsToPublicSite() throws Exception { + + String siteId2 = RandomData.getRandomName("site"); + siteModel2 = dataSite.usingUser(userModel) + .createSite(new SiteModel(Visibility.PUBLIC, siteId2, siteId2, siteId2, siteId2)); + newMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(siteModel2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + UserModel adminUser = dataUser.getAdminUser(); + + restClient.authenticateUser(adminUser).withCoreAPI().usingUser(newMember).getSiteMembershipRequests() + .assertThat().entriesListIsEmpty(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + } + + @Bug(id = "MNT-16557") + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Get site membership requests to a moderated site.") + public void getRequestsToModeratedSite() throws Exception { + + UserModel adminUser = dataUser.getAdminUser(); + + restClient.authenticateUser(adminUser).withCoreAPI().usingUser(newMember).getSiteMembershipRequests() + .assertThat().entriesListIsNotEmpty(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Bug(id = "MNT-16557") + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Approve request then get requests.") + public void approveRequestThenGetRequests() throws Exception { + + ListUserWithRoles usersWithRoles; + + UserModel adminUser = dataUser.getAdminUser(); + siteModel = dataSite.usingUser(adminUser).createModeratedRandomSite(); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, + UserRole.SiteConsumer, UserRole.SiteContributor); + + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteConsumer); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + restClient.withCoreAPI().usingSite(siteModel).addPerson(testUser).assertThat().field("id") + .is(testUser.getUsername()).and().field("role").is(testUser.getUserRole()); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(testUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(siteModel); + + restClient.authenticateUser(adminUser).withCoreAPI().usingUser(testUser).getSiteMembershipRequests() + .assertThat().entriesListIsNotEmpty(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + +} From 263e7b856da1bf318f89f22ec2740acdf8f43cb2 Mon Sep 17 00:00:00 2001 From: Bogdan Bocancea Date: Mon, 28 Nov 2016 17:49:12 +0200 Subject: [PATCH 0635/1491] TAS-2031: add core tests for getSiteMembershipRequest api call --- .../GetSiteMembershipRequestCoreTests.java | 169 ++++++++++++++++++ .../GetSiteMembershipRequestsSanityTests.java | 4 +- 2 files changed, 171 insertions(+), 2 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestCoreTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestCoreTests.java new file mode 100644 index 000000000..8bea2548e --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestCoreTests.java @@ -0,0 +1,169 @@ +package org.alfresco.rest.people; + +import org.alfresco.rest.RestTest; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.model.ErrorModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Tests for getSiteMembershipRequests (get /people/{personId}/site-membership-requests) RestAPI call + * + * @author Bogdan Bocancea + */ +@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) +public class GetSiteMembershipRequestCoreTests extends RestTest +{ + UserModel userModel; + SiteModel siteModel; + UserModel newMember; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createModeratedRandomSite(); + newMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(newMember) + .withCoreAPI() + .usingAuthUser().addSiteMembershipRequest(siteModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + } + + @Bug(id="MNT-16904") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, + description = "Verify contributor user fails to get all site membership requests of a specific person with Rest API when the authentication fails (401)") + public void unauthorizedContributorUserFailsToGetSiteMembershipRequests() throws Exception + { + UserModel contributor = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(contributor, siteModel, UserRole.SiteContributor); + contributor.setPassword("newpassword"); + restClient.authenticateUser(contributor) + .withCoreAPI() + .usingUser(newMember).getSiteMembershipRequest(siteModel); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + } + + @Bug(id="MNT-16904") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, + description = "Verify collaborator user fails to get all site membership requests of a specific person with Rest API when the authentication fails (401)") + public void unauthorizedCollaboratorUserFailsToGetSiteMembershipRequests() throws Exception + { + UserModel collaborator = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(collaborator, siteModel, UserRole.SiteContributor); + collaborator.setPassword("newpassword"); + restClient.authenticateUser(collaborator) + .withCoreAPI() + .usingUser(newMember).getSiteMembershipRequest(siteModel); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + } + + @Bug(id="MNT-16904") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, + description = "Verify consumer user fails to get all site membership requests of a specific person with Rest API when the authentication fails (401)") + public void unauthorizedConsumerUserFailsToGetSiteMembershipRequests() throws Exception + { + UserModel consumer = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(consumer, siteModel, UserRole.SiteContributor); + consumer.setPassword("newpassword"); + restClient.authenticateUser(consumer) + .withCoreAPI() + .usingUser(newMember).getSiteMembershipRequest(siteModel); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, + description = "Verify a user gets all its own site membership requests using '-me-' with Rest API and response is successful (200)") + public void usingMeGetSiteMembershipRequestsWithSuccess() throws Exception + { + restClient.authenticateUser(newMember) + .withCoreAPI() + .usingMe().getSiteMembershipRequest(siteModel) + .assertThat().field("id").is(siteModel.getId()); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, + description = "Verify site manager can't get site membership requests for inexistent user and response is not found (404)") + public void siteManagerCantGetSiteMembershipRequestsInexistentUser() throws Exception + { + restClient.authenticateUser(newMember) + .withCoreAPI() + .usingUser(UserModel.getRandomUserModel()).getSiteMembershipRequest(siteModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, "")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, + description = "Verify user can get site membership requests on site with no requests and response is successful (200)") + public void userCantGetSiteMembershipRequestsWithNoRequests() throws Exception + { + UserModel noRequestUser = dataUser.createRandomTestUser(); + restClient.authenticateUser(noRequestUser) + .withCoreAPI() + .usingMe().getSiteMembershipRequest(siteModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(ErrorModel.RELATIONSHIP_NOT_FOUND, noRequestUser.getUsername(), siteModel.getId())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, + description = "Verify site manager can't get site membership requests on public site and response is not found (404)") + public void siteManagerCantGetPublicSiteMembershipRequests() throws Exception + { + UserModel publicUser = dataUser.createRandomTestUser(); + SiteModel publicSite = dataSite.usingUser(userModel).createPublicRandomSite(); + restClient.authenticateUser(publicUser) + .withCoreAPI() + .usingAuthUser().addSiteMembershipRequest(publicSite); + restClient.authenticateUser(userModel) + .withCoreAPI() + .usingUser(publicUser).getSiteMembershipRequest(publicSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(ErrorModel.RELATIONSHIP_NOT_FOUND, publicUser.getUsername(), publicSite.getId())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, + description = "Verify site manager can't get site membership requests on private site and response is not found (404)") + public void siteManagerCantGetPrivateSiteMembershipRequests() throws Exception + { + UserModel privateUser = dataUser.createRandomTestUser(); + SiteModel privateSite = dataSite.usingUser(userModel).createPrivateRandomSite(); + restClient.authenticateUser(privateUser) + .withCoreAPI() + .usingAuthUser().addSiteMembershipRequest(privateSite); + restClient.authenticateUser(userModel) + .withCoreAPI() + .usingUser(privateUser).getSiteMembershipRequest(privateSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(ErrorModel.RELATIONSHIP_NOT_FOUND, privateUser.getUsername(), privateSite.getId())); + } + + @Bug(id = "MNT-17183", description = "reproduced only on 5.1.N") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, + description = "Verify site manager can't get site membership requests for inexistent site and response is not found (404)") + public void siteManagerCantGetSiteMembershipRequestsForInexistentSite() throws Exception + { + SiteModel inexistentSite = SiteModel.getRandomSiteModel(); + restClient.authenticateUser(userModel) + .withCoreAPI() + .usingMe().getSiteMembershipRequest(inexistentSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(ErrorModel.RELATIONSHIP_NOT_FOUND, newMember.getUsername(), inexistentSite.getId())); + } +} diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java index d8360b4af..6a59261db 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java @@ -3,6 +3,7 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.RandomData; +import org.alfresco.utility.model.ErrorModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; @@ -124,11 +125,10 @@ public class GetSiteMembershipRequestsSanityTests extends RestTest UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); managerUser.setPassword("newpassword"); - restClient.authenticateUser(managerUser) .withCoreAPI() .usingUser(newMember).getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, From 2d292fce0633735d60d1bc002178a28f95a64a49 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Mon, 28 Nov 2016 18:44:24 +0200 Subject: [PATCH 0636/1491] test: Added 15 core tests for RemoveSiteMember and renamed some sanity tests --- .../rest/sites/RemoveSiteMemberCoreTests.java | 258 ++++++++++++++++++ .../sites/RemoveSiteMemberSanityTests.java | 13 +- 2 files changed, 262 insertions(+), 9 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberCoreTests.java new file mode 100644 index 000000000..a5d75ca7f --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberCoreTests.java @@ -0,0 +1,258 @@ +package org.alfresco.rest.sites; + +import org.alfresco.rest.RestTest; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.exception.DataPreparationException; +import org.alfresco.utility.model.ErrorModel; +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 Cristina Axinte + * + */ +@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) +public class RemoveSiteMemberCoreTests extends RestTest +{ + private SiteModel siteModel; + private UserModel adminUserModel; + private ListUserWithRoles usersWithRoles; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws DataPreparationException + { + adminUserModel = dataUser.getAdminUser(); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, + UserRole.SiteConsumer, UserRole.SiteContributor); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that manager can NOT delete site member for an inexistent user and gets status code 404, 'Not Found'") + public void managerIsNotAbleToDeleteInexistentSiteMember() throws Exception + { + UserModel inexistentUser = new UserModel("inexistentUser", "password"); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + restClient.withCoreAPI().usingSite(siteModel).deleteSiteMember(inexistentUser); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, inexistentUser.getUsername())); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that manager can NOT delete site member for a non site member and gets status code 400, 'Bad Request'") + public void managerIsNotAbleToDeleteNotSiteMember() throws Exception + { + UserModel nonMember = dataUser.createRandomTestUser(); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + restClient.withCoreAPI().usingSite(siteModel).deleteSiteMember(nonMember); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(ErrorModel.INVALID_ARGUMENT, "argument")); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that manager can NOT delete site member for an invalid site and gets status code 404, 'Not Found'") + public void managerIsNotAbleToDeleteSiteMemberOfInvalidSite() throws Exception + { + SiteModel invalidSite = new SiteModel("invalidSite"); + UserModel testUserModel = dataUser.createRandomTestUser(); + dataUser.addUserToSite(testUserModel, siteModel, UserRole.SiteConsumer); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + restClient.withCoreAPI().usingSite(invalidSite).deleteSiteMember(testUserModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(ErrorModel.RELATIONSHIP_NOT_FOUND, testUserModel.getUsername(), invalidSite.getId())); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, + description = "Verify that manager can delete a site member with manager role") + public void siteManagerIsAbleToDeleteSiteMemberWithManagerRole() throws Exception + { + UserModel anothermanager = dataUser.createRandomTestUser(); + dataUser.addUserToSite(anothermanager, siteModel, UserRole.SiteManager); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingSite(siteModel).deleteSiteMember(anothermanager); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingSite(siteModel).getSiteMembers() + .assertThat().entriesListDoesNotContain("id", anothermanager.getUsername()); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that manager can delete site member using \"-me-\" in place of personId") + public void managerIsAbleToDeleteSiteMemberUsingMe() throws Exception + { + UserModel manager = dataUser.createRandomTestUser(); + dataUser.addUserToSite(manager, siteModel, UserRole.SiteManager); + UserModel meUser = new UserModel("-me-", "password"); + + restClient.authenticateUser(manager); + restClient.withCoreAPI().usingSite(siteModel).deleteSiteMember(meUser); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingSite(siteModel).getSiteMembers() + .assertThat().entriesListDoesNotContain("id", manager.getUsername()); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that site collaborator cannot delete a site member with Manager role and gets status code 422") + public void siteCollaboratorIsNotAbleToDeleteSiteMemberWithManagerRole() throws Exception + { + UserModel managerForDelete = dataUser.createRandomTestUser(); + dataUser.addUserToSite(managerForDelete, siteModel, UserRole.SiteManager); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + restClient.withCoreAPI().usingSite(siteModel).deleteSiteMember(managerForDelete); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY) + .assertLastError().containsSummary(String.format(ErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getId())); + + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that site contributor cannot delete site member with Manager role and gets status code 422") + public void siteContributorIsNotAbleToDeleteSiteMemberWithManagerRole() throws Exception + { + UserModel managerForDelete = dataUser.createRandomTestUser(); + dataUser.addUserToSite(managerForDelete, siteModel, UserRole.SiteManager); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + restClient.withCoreAPI().usingSite(siteModel).deleteSiteMember(managerForDelete); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY) + .assertLastError().containsSummary(String.format(ErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getId())); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that site consumer cannot delete site member with Manager role and gets status code 422") + public void siteConsumerIsNotAbleToDeleteSiteMemberWithManagerRole() throws Exception + { + UserModel managerForDelete = dataUser.createRandomTestUser(); + dataUser.addUserToSite(managerForDelete, siteModel, UserRole.SiteManager); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + restClient.withCoreAPI().usingSite(siteModel).deleteSiteMember(managerForDelete); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY) + .assertLastError().containsSummary(String.format(ErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getId())); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that site collaborator cannot delete a site member with Contributor role and gets status code 422") + public void siteCollaboratorIsNotAbleToDeleteSiteMemberWithContributorRole() throws Exception + { + UserModel contributorForDelete = dataUser.createRandomTestUser(); + dataUser.addUserToSite(contributorForDelete, siteModel, UserRole.SiteContributor); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + restClient.withCoreAPI().usingSite(siteModel).deleteSiteMember(contributorForDelete); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY) + .assertLastError().containsSummary(String.format(ErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getId())); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that site contributor cannot delete site member with Contributor role and gets status code 422") + public void siteContributorIsNotAbleToDeleteSiteMemberWithContributorRole() throws Exception + { + UserModel contributorForDelete = dataUser.createRandomTestUser(); + dataUser.addUserToSite(contributorForDelete, siteModel, UserRole.SiteContributor); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + restClient.withCoreAPI().usingSite(siteModel).deleteSiteMember(contributorForDelete); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY) + .assertLastError().containsSummary(String.format(ErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getId())); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that site consumer cannot delete site member with Contributor role and gets status code 422") + public void siteConsumerIsNotAbleToDeleteSiteMemberWithContributorRole() throws Exception + { + UserModel contributorForDelete = dataUser.createRandomTestUser(); + dataUser.addUserToSite(contributorForDelete, siteModel, UserRole.SiteContributor); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + restClient.withCoreAPI().usingSite(siteModel).deleteSiteMember(contributorForDelete); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY) + .assertLastError().containsSummary(String.format(ErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getId())); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that manager can delete a site member with Contributor role") + public void siteManagerIsAbleToDeleteSiteMemberWithContributorRole() throws Exception + { + UserModel contributorForDelete = dataUser.createRandomTestUser(); + dataUser.addUserToSite(contributorForDelete, siteModel, UserRole.SiteContributor); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingSite(siteModel).deleteSiteMember(contributorForDelete); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingSite(siteModel).getSiteMembers() + .assertThat().entriesListDoesNotContain("id", contributorForDelete.getUsername()); + } + +// delete collaborator user by consumer user(2.0) +// delete collaborator user by contributor user(0.5) +// delete collaborator user by collaborator user(0.5) +// delete collaborator user by manager user(2.0) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that site collaborator cannot delete a site member with Collaborator role and gets status code 422") + public void siteCollaboratorIsNotAbleToDeleteSiteMemberWithCollaboratorRole() throws Exception + { + UserModel collaboratorForDelete = dataUser.createRandomTestUser(); + dataUser.addUserToSite(collaboratorForDelete, siteModel, UserRole.SiteCollaborator); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + restClient.withCoreAPI().usingSite(siteModel).deleteSiteMember(collaboratorForDelete); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY) + .assertLastError().containsSummary(String.format(ErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getId())); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that site contributor cannot delete site member with Collaborator role and gets status code 422") + public void siteContributorIsNotAbleToDeleteSiteMemberWithCollaboratorRole() throws Exception + { + UserModel collaboratorForDelete = dataUser.createRandomTestUser(); + dataUser.addUserToSite(collaboratorForDelete, siteModel, UserRole.SiteCollaborator); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + restClient.withCoreAPI().usingSite(siteModel).deleteSiteMember(collaboratorForDelete); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY) + .assertLastError().containsSummary(String.format(ErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getId())); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that site consumer cannot delete site member with Collaborator role and gets status code 422") + public void siteConsumerIsNotAbleToDeleteSiteMemberWithCollaboratorRole() throws Exception + { + UserModel collaboratorForDelete = dataUser.createRandomTestUser(); + dataUser.addUserToSite(collaboratorForDelete, siteModel, UserRole.SiteCollaborator); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + restClient.withCoreAPI().usingSite(siteModel).deleteSiteMember(collaboratorForDelete); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY) + .assertLastError().containsSummary(String.format(ErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getId())); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that manager can delete a site member with Collaborator role") + public void siteManagerIsAbleToDeleteSiteMemberWithCollaboratorRole() throws Exception + { + UserModel collaboratorForDelete = dataUser.createRandomTestUser(); + dataUser.addUserToSite(collaboratorForDelete, siteModel, UserRole.SiteCollaborator); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingSite(siteModel).deleteSiteMember(collaboratorForDelete); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingSite(siteModel).getSiteMembers() + .assertThat().entriesListDoesNotContain("id", collaboratorForDelete.getUsername()); + } +} diff --git a/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java index 17a4daeee..10cd63215 100644 --- a/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java @@ -2,7 +2,6 @@ package org.alfresco.rest.sites; import org.alfresco.rest.RestTest; import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.SiteModel; @@ -12,7 +11,6 @@ import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; @@ -24,9 +22,6 @@ import org.testng.annotations.Test; @Test(groups = {TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY}) public class RemoveSiteMemberSanityTests extends RestTest { - @Autowired - DataUser dataUser; - private SiteModel siteModel; private UserModel adminUserModel; private ListUserWithRoles usersWithRoles; @@ -48,7 +43,7 @@ public class RemoveSiteMemberSanityTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that site manager can delete site member and gets status code 204, 'No Content'") - public void siteManagerIsAbleToDeleteSiteMember() throws Exception{ + public void siteManagerIsAbleToDeleteSiteMemberWithConsumerRole() throws Exception{ restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); restClient.withCoreAPI().usingSite(siteModel).deleteSiteMember(testUserModel); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); @@ -59,7 +54,7 @@ public class RemoveSiteMemberSanityTests extends RestTest @Bug(id="ACE-5444") @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that site collaborator cannot delete site member and gets status code 403, 'Forbidden'") - public void siteCollaboratorIsNotAbleToDeleteSiteMember() throws Exception{ + public void siteCollaboratorIsNotAbleToDeleteSiteMemberWithConsumerRole() throws Exception{ restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); restClient.withCoreAPI().usingSite(siteModel).deleteSiteMember(testUserModel); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); @@ -71,7 +66,7 @@ public class RemoveSiteMemberSanityTests extends RestTest @Bug(id="ACE-5444") @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that site contributor cannot delete site member and gets status code 403, 'Forbidden'") - public void siteContributorIsNotAbleToDeleteSiteMember() throws Exception{ + public void siteContributorIsNotAbleToDeleteSiteMemberWithConsumerRole() throws Exception{ restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); restClient.withCoreAPI().usingSite(siteModel).deleteSiteMember(testUserModel); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); @@ -83,7 +78,7 @@ public class RemoveSiteMemberSanityTests extends RestTest @Bug(id="ACE-5444") @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that site consumer cannot delete site member and gets status code 403, 'Forbidden'") - public void siteConsumerIsNotAbleToDeleteSiteMember() throws Exception{ + public void siteConsumerIsNotAbleToDeleteSiteMemberWithConsumerRole() throws Exception{ restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) .withCoreAPI().usingSite(siteModel).deleteSiteMember(testUserModel); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); From 652ccf0970fd4f97ce1303a45f7c00f18dcccb49 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Mon, 28 Nov 2016 18:45:44 +0200 Subject: [PATCH 0637/1491] test: Updated regression exexutionType of a test --- .../java/org/alfresco/rest/sites/RemoveSiteMemberCoreTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberCoreTests.java index a5d75ca7f..e6f640ce1 100644 --- a/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberCoreTests.java @@ -73,7 +73,7 @@ public class RemoveSiteMemberCoreTests extends RestTest .assertLastError().containsSummary(String.format(ErrorModel.RELATIONSHIP_NOT_FOUND, testUserModel.getUsername(), invalidSite.getId())); } - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Verify that manager can delete a site member with manager role") public void siteManagerIsAbleToDeleteSiteMemberWithManagerRole() throws Exception { From cf45021c75d13619b2bc620b5184cd7923d51412 Mon Sep 17 00:00:00 2001 From: cagache Date: Tue, 29 Nov 2016 10:03:39 +0200 Subject: [PATCH 0638/1491] test: updated tests descriptions --- .../rest/sites/GetSitesCoreTests.java | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java index c4766c1cb..2b6eb1a98 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java @@ -25,7 +25,7 @@ import java.util.List; @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) public class GetSitesCoreTests extends RestTest { - private UserModel userModel, privateSiteManager, privateSiteConsumer; + private UserModel regularUser, privateSiteManager, privateSiteConsumer; private SiteModel publicSite, privateSite, moderatedSite, deletedSite; private RestSiteModelsCollection sites; private SiteModel siteModel; @@ -33,7 +33,7 @@ public class GetSitesCoreTests extends RestTest @BeforeClass(alwaysRun=true) public void dataPreparation() throws Exception { - userModel = dataUser.createRandomTestUser(); + regularUser = dataUser.createRandomTestUser(); privateSiteManager = dataUser.createRandomTestUser(); privateSiteConsumer = dataUser.createRandomTestUser(); siteModel = new SiteModel(RandomData.getRandomName("0-PublicSite")); @@ -48,27 +48,27 @@ public class GetSitesCoreTests extends RestTest } @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify invalid request returns status code 400 for invalid maxItems") - public void checkStatusCodeForInvalidMaxItems() throws Exception + description= "Verify if get sites request returns status code 400 when invalid maxItems parameter is used") + public void getSitesWithInvalidMaxItems() throws Exception { - restClient.authenticateUser(userModel).withParams("maxItems=0") + restClient.authenticateUser(regularUser).withParams("maxItems=0") .withCoreAPI().getSites(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) .assertLastError().containsSummary("Only positive values supported for maxItems"); } @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify invalid request returns status code 400 for invalid skipCount") - public void checkStatusCodeForInvalidSkipCount() throws Exception + description= "Verify if get sites request returns status code 400 when invalid skipCount parameter is used") + public void getSitesWithInvalidSkipCount() throws Exception { - restClient.authenticateUser(userModel).withParams("skipCount=A") + restClient.authenticateUser(regularUser).withParams("skipCount=A") .withCoreAPI().getSites(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) .assertLastError().containsSummary("Invalid paging parameter skipCount:A"); } @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify User gets sites ordered by name ascendant and status code is 200") + description= "Verify if User gets sites ordered by title ascendant and status code is 200") public void getSitesOrderedByNameASC() throws Exception { sites = restClient.authenticateUser(privateSiteManager).withParams("orderBy=title ASC") @@ -82,10 +82,10 @@ public class GetSitesCoreTests extends RestTest } @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if any user gets all public and moderated sites and status code is 200") - public void userGetsOnlyPublicAndModeratedSites() throws Exception + description= "Verify if a regular user gets all public and moderated sites and status code is 200") + public void regularUserGetsOnlyPublicAndModeratedSites() throws Exception { - sites = restClient.authenticateUser(userModel).withParams("maxItems=5000") + sites = restClient.authenticateUser(regularUser).withParams("maxItems=5000") .withCoreAPI().getSites(); restClient.assertStatusCodeIs(HttpStatus.OK); sites.assertThat().entriesListContains("title", publicSite.getTitle()) @@ -95,7 +95,7 @@ public class GetSitesCoreTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if a member of a private site gets the private site, all public sites and all moderated sites. Verify if status code is 200") - public void userGetsSitesVisibleForHim() throws Exception + public void privateSiteMemberGetsSitesVisibleForHim() throws Exception { sites = restClient.authenticateUser(privateSiteConsumer).withParams("maxItems=5000") .withCoreAPI().getSites(); @@ -109,7 +109,7 @@ public class GetSitesCoreTests extends RestTest description= "Verify if a site is not retrieved anymore after deletion and status code is 200") public void checkDeletedSiteIsNotRetrieved() throws Exception { - sites = restClient.authenticateUser(userModel).withParams("maxItems=5000").withCoreAPI().getSites(); + sites = restClient.authenticateUser(regularUser).withParams("maxItems=5000").withCoreAPI().getSites(); restClient.assertStatusCodeIs(HttpStatus.OK); sites.assertThat().entriesListContains("title", deletedSite.getTitle()); From 3d000e359d2bd6bd14d04ccf2be5253526d335ec Mon Sep 17 00:00:00 2001 From: cagache Date: Tue, 29 Nov 2016 10:49:52 +0200 Subject: [PATCH 0639/1491] remove useless comments --- .../org/alfresco/rest/sites/RemoveSiteMemberCoreTests.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberCoreTests.java index e6f640ce1..4ce75655d 100644 --- a/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberCoreTests.java @@ -197,11 +197,7 @@ public class RemoveSiteMemberCoreTests extends RestTest restClient.withCoreAPI().usingSite(siteModel).getSiteMembers() .assertThat().entriesListDoesNotContain("id", contributorForDelete.getUsername()); } - -// delete collaborator user by consumer user(2.0) -// delete collaborator user by contributor user(0.5) -// delete collaborator user by collaborator user(0.5) -// delete collaborator user by manager user(2.0) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Verify that site collaborator cannot delete a site member with Collaborator role and gets status code 422") public void siteCollaboratorIsNotAbleToDeleteSiteMemberWithCollaboratorRole() throws Exception From 34503b70fc57d82cb0d20b51e6ff29d7dbf1371b Mon Sep 17 00:00:00 2001 From: cagache Date: Tue, 29 Nov 2016 11:00:33 +0200 Subject: [PATCH 0640/1491] test: fix description typo --- e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java index 2b6eb1a98..c9f3d59f1 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java @@ -68,7 +68,7 @@ public class GetSitesCoreTests extends RestTest } @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if User gets sites ordered by title ascendant and status code is 200") + description= "Verify if User gets sites ordered by title ascending and status code is 200") public void getSitesOrderedByNameASC() throws Exception { sites = restClient.authenticateUser(privateSiteManager).withParams("orderBy=title ASC") From 70097bfc27ce01f9c12d171836d8cd8a68fa6bc6 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Tue, 29 Nov 2016 11:46:11 +0200 Subject: [PATCH 0641/1491] CORE-REST API: getTag (get /tags/{tagId}) --- .../alfresco/rest/tags/GetTagCoreTests.java | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/tags/GetTagCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/tags/GetTagCoreTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagCoreTests.java new file mode 100644 index 000000000..73d4fed78 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/tags/GetTagCoreTests.java @@ -0,0 +1,71 @@ +package org.alfresco.rest.tags; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestTagModel; +import org.alfresco.utility.data.RandomData; +import org.alfresco.utility.model.ErrorModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) +public class GetTagCoreTests extends RestTest +{ + private UserModel adminUserModel; + private SiteModel siteModel; + private FileModel document; + private String tagValue; + private RestTagModel tag; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + } + + @BeforeMethod + public void setUp() throws Exception { + tagValue = RandomData.getRandomName("tag"); + restClient.authenticateUser(adminUserModel); + tag = restClient.withCoreAPI().usingResource(document).addTag(tagValue); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that if tag id is invalid status code returned is 400") + public void invalidTagIdTest() throws JsonToModelConversionException, Exception + { + tag.setId("random_tag_value"); + restClient.withCoreAPI().getTag(tag); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, "random_tag_value")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Retrieve and validate the id of a tag added to a file") + public void validateTagIdTest() throws JsonToModelConversionException, Exception + { + RestTagModel returnedTag = restClient.authenticateUser(adminUserModel).withCoreAPI().getTag(tag); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedTag.assertThat().field("id").is(tag.getId()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Retrieve and validate the name of a tag added to a file") + public void validateTagNameTest() throws JsonToModelConversionException, Exception + { + RestTagModel returnedTag = restClient.authenticateUser(adminUserModel).withCoreAPI().getTag(tag); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedTag.assertThat().field("tag").is(tagValue.toLowerCase()); + } + +} \ No newline at end of file From 9aeafea91e200b9f4f6b4b9a75ffa01139b7a3b8 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Tue, 29 Nov 2016 11:47:53 +0200 Subject: [PATCH 0642/1491] CORE-REST API: getTags (get /tags) --- .../alfresco/rest/tags/GetTagsCoreTests.java | 89 +++++++++++++++++++ .../rest/tags/GetTagsSanityTests.java | 2 +- 2 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 e2e-test/java/org/alfresco/rest/tags/GetTagsCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/tags/GetTagsCoreTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagsCoreTests.java new file mode 100644 index 000000000..54a141fdd --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/tags/GetTagsCoreTests.java @@ -0,0 +1,89 @@ +package org.alfresco.rest.tags; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestTagModelsCollection; +import org.alfresco.utility.Utility; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.data.RandomData; +import org.alfresco.utility.model.ErrorModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) +public class GetTagsCoreTests extends RestTest +{ + private UserModel adminUserModel; + private SiteModel siteModel; + + private String tagValue; + private String tagValue2; + private FileModel document; + private RestTagModelsCollection returnedCollection; + private FolderModel folder; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + restClient.authenticateUser(adminUserModel); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + document = dataContent.usingUser(adminUserModel).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + folder = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); + + tagValue = RandomData.getRandomName("tag"); + tagValue2 = RandomData.getRandomName("tag"); + restClient.withCoreAPI().usingResource(document).addTags(tagValue); + restClient.withCoreAPI().usingResource(folder).addTags(tagValue2); + + Utility.waitToLoopTime(60); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that if maxItems is invalid status code returned is 400") + public void maxItemsInvalidValueTest() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel).withParams("maxItems=abc").withCoreAPI().getTags(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(ErrorModel.INVALID_MAXITEMS, "abc")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that if skipCount is invalid status code returned is 400") + public void skipCountInvalidValueTest() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel).withParams("skipCount=abc").withCoreAPI().getTags(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(ErrorModel.INVALID_SKIPCOUNT, "abc")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that file tag is retrieved") + public void fileTagIsRetrieved() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel); + returnedCollection = restClient.withParams("maxItems=500").withCoreAPI().getTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat().entriesListIsNotEmpty() + .and().entriesListContains("tag", tagValue.toLowerCase()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that folder tag is retrieved") + public void folderTagIsRetrieved() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel); + returnedCollection = restClient.withParams("maxItems=500").withCoreAPI().getTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat().entriesListIsNotEmpty() + .and().entriesListContains("tag", tagValue2.toLowerCase()); + } +} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java index d9f05070e..e0c9fd788 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java @@ -102,7 +102,7 @@ public class GetTagsSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Failed authentication get tags call returns status code 401 with Manager role") @Bug(id = "MNT-16904") - public void getTagsWithManagerRoleFailedAuth() throws JsonToModelConversionException, Exception + public void failedAuthenticationReturnsUnauthorizedStatus() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); userModel = dataUser.createRandomTestUser(); From da9ba09611e37b32120c8bd3de1f06fbc71eea79 Mon Sep 17 00:00:00 2001 From: cagache Date: Tue, 29 Nov 2016 14:45:36 +0200 Subject: [PATCH 0643/1491] removed admin authentication part from each scenario because admin is already authenticated from beforeMethod --- e2e-test/java/org/alfresco/rest/tags/GetTagCoreTests.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/tags/GetTagCoreTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagCoreTests.java index 73d4fed78..78ce19e79 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetTagCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetTagCoreTests.java @@ -34,7 +34,7 @@ public class GetTagCoreTests extends RestTest document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); } - @BeforeMethod + @BeforeMethod(alwaysRun = true) public void setUp() throws Exception { tagValue = RandomData.getRandomName("tag"); restClient.authenticateUser(adminUserModel); @@ -54,7 +54,7 @@ public class GetTagCoreTests extends RestTest description = "Retrieve and validate the id of a tag added to a file") public void validateTagIdTest() throws JsonToModelConversionException, Exception { - RestTagModel returnedTag = restClient.authenticateUser(adminUserModel).withCoreAPI().getTag(tag); + RestTagModel returnedTag = restClient.withCoreAPI().getTag(tag); restClient.assertStatusCodeIs(HttpStatus.OK); returnedTag.assertThat().field("id").is(tag.getId()); } @@ -63,7 +63,7 @@ public class GetTagCoreTests extends RestTest description = "Retrieve and validate the name of a tag added to a file") public void validateTagNameTest() throws JsonToModelConversionException, Exception { - RestTagModel returnedTag = restClient.authenticateUser(adminUserModel).withCoreAPI().getTag(tag); + RestTagModel returnedTag = restClient.withCoreAPI().getTag(tag); restClient.assertStatusCodeIs(HttpStatus.OK); returnedTag.assertThat().field("tag").is(tagValue.toLowerCase()); } From 87fa9d2f87e24732fe96ecefecc47a1751499e18 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Tue, 29 Nov 2016 16:20:47 +0200 Subject: [PATCH 0644/1491] Added 10 core tests for GetSiteMember --- .../rest/sites/GetSiteMemberCoreTests.java | 166 ++++++++++++++++++ 1 file changed, 166 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/sites/GetSiteMemberCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberCoreTests.java new file mode 100644 index 000000000..c221fe7f2 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberCoreTests.java @@ -0,0 +1,166 @@ +package org.alfresco.rest.sites; + +import org.alfresco.rest.RestTest; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.exception.DataPreparationException; +import org.alfresco.utility.model.ErrorModel; +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 Cristina Axinte + * + */ +@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) +public class GetSiteMemberCoreTests extends RestTest +{ + private UserModel adminUser; + private SiteModel siteModel; + private ListUserWithRoles usersWithRoles; + private UserModel manager, consumer, collaborator, contributor; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws DataPreparationException + { + adminUser = dataUser.getAdminUser(); + siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + consumer = dataUser.createRandomTestUser(); + dataUser.addUserToSite(consumer, siteModel, UserRole.SiteConsumer); + + manager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); + collaborator = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); + contributor = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); + } + + @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(ErrorModel.RELATIONSHIP_NOT_FOUND, consumer.getUsername(), invalidSite.getId())); + } + + @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(siteModel).getSiteMember(nonMember); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(ErrorModel.RELATIONSHIP_NOT_FOUND, nonMember.getUsername(), siteModel.getId())); + } + + @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(siteModel).getSiteMember(inexistentUser); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, inexistentUser.getUsername())); + } + + @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 manager = dataUser.createRandomTestUser(); + dataUser.addUserToSite(manager, siteModel, UserRole.SiteManager); + UserModel meUser = new UserModel("-me-", "password"); + + restClient.authenticateUser(manager); + restClient.withCoreAPI().usingSite(siteModel).getSiteMember(meUser) + .assertThat().field("id").is(manager.getUsername()) + .and().field("role").is(manager.getUserRole()); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @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(ErrorModel.RELATIONSHIP_NOT_FOUND, consumer.getUsername(), emptySite.getId())); + } + + @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, siteModel, UserRole.SiteManager); + + restClient.authenticateUser(manager); + restClient.withCoreAPI().usingSite(siteModel).getSiteMember(anotherManager) + .assertThat().field("id").is(anotherManager.getUsername()) + .and().field("role").is(anotherManager.getUserRole()); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @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(siteModel).getSiteMember(manager) + .assertThat().field("id").is(manager.getUsername()) + .and().field("role").is(manager.getUserRole()); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @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(siteModel).getSiteMember(manager) + .assertThat().field("id").is(manager.getUsername()) + .and().field("role").is(manager.getUserRole()); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @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(siteModel).getSiteMember(manager) + .assertThat().field("id").is(manager.getUsername()) + .and().field("role").is(manager.getUserRole()); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @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(siteModel).getSiteMember(adminUser) + .assertThat().field("id").is(adminUser.getUsername()) + .and().field("role").is(UserRole.SiteManager); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + +} From 0f4252a6d1aa1a0f7a0f0642cc8c8ce1c5a61d1a Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Tue, 29 Nov 2016 16:24:14 +0200 Subject: [PATCH 0645/1491] Minor changes for delete favorite site and delete site member --- .../people/DeleteFavoriteSiteCoreTests.java | 28 +++--- .../people/DeleteSiteMemberCoreTests.java | 91 +++++++++---------- 2 files changed, 59 insertions(+), 60 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteCoreTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteCoreTests.java index 2877c6bef..f5a9f015d 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteCoreTests.java @@ -29,8 +29,8 @@ public class DeleteFavoriteSiteCoreTests extends RestTest adminUserModel = dataUser.getAdminUser(); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify user removes a site from favorites using '-me-' in place of personId with Rest API and response is successful (204)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify user removes a site from favorites using '-me-' in place of personId with Rest API and response is successful (204)") public void removeFavoriteSiteWithSuccessUsingMeAsPersonId() throws Exception { restClient.authenticateUser(adminUserModel); @@ -40,8 +40,8 @@ public class DeleteFavoriteSiteCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify inexistent user is not able to remove a site from favorites and response is 404") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify inexistent user is not able to remove a site from favorites and response is 404") public void userIsNotAbleToRemoveFavoriteSiteOfInexistentUser() throws Exception { UserModel inexistentUser = new UserModel("inexistenUser", "password"); @@ -49,8 +49,8 @@ public class DeleteFavoriteSiteCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, "inexistenUser")); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify user is not able to remove from favorites a site with inexistent id and response is 404") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify user is not able to remove from favorites a site with inexistent id and response is 404") public void userIsNotAbleToRemoveFavoriteSiteWithInexistentId() throws Exception { SiteModel inexistentSite = new SiteModel("inexistentSite"); @@ -59,8 +59,8 @@ public class DeleteFavoriteSiteCoreTests extends RestTest .containsSummary(String.format(ErrorModel.RELATIONSHIP_NOT_FOUND, adminUserModel.getUsername(), inexistentSite.getTitle())); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user removes a site from its favorites abd add it again and response is successful (204)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify manager user removes a site from its favorites and adds it again and response is successful (204)") public void managerUserRemovesFavoriteSiteAndAddItAgain() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -73,8 +73,8 @@ public class DeleteFavoriteSiteCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.CREATED); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user removes a site from its favorite sites list with Rest API and response is successful (204)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify manager user removes a site from its favorite sites list with Rest API and response is successful (204)") public void managerUserRemovesFavoriteSiteWithSuccess() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -86,7 +86,7 @@ public class DeleteFavoriteSiteCoreTests extends RestTest restClient.withCoreAPI().usingAuthUser().getFavorites().assertThat().entriesListDoesNotContain("id", siteModel.getId()); } - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.PEOPLE}, executionType= ExecutionType.REGRESSION, description= "Verify uninvited user can delete favorite public site and response is 204") public void uninvitedUserCanDeleteFavoritePublicSite() throws Exception { @@ -98,7 +98,7 @@ public class DeleteFavoriteSiteCoreTests extends RestTest restClient.withCoreAPI().usingAuthUser().getFavoriteSites().assertThat().entriesListDoesNotContain("id", publicSiteModel.getId()); } - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.PEOPLE}, executionType= ExecutionType.REGRESSION, description= "Verify uninvited user can delete favorite moderated site and response is 204") public void uninvitedUserCanDeleteFavoriteModeratedSite() throws Exception { @@ -110,7 +110,7 @@ public class DeleteFavoriteSiteCoreTests extends RestTest restClient.withCoreAPI().usingAuthUser().getFavoriteSites().assertThat().entriesListDoesNotContain("id", moderatedSiteModel.getId()); } - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.PEOPLE}, executionType= ExecutionType.REGRESSION, description= "Verify user can delete favorite private site and response is 204") public void userCanDeleteFavoritePrivateSite() throws Exception { @@ -122,4 +122,4 @@ public class DeleteFavoriteSiteCoreTests extends RestTest restClient.withCoreAPI().usingAuthUser().getFavoriteSites().assertThat().entriesListDoesNotContain("id", privateSiteModel.getId()); } -} +} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberCoreTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberCoreTests.java index 627997442..2c9807cfc 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberCoreTests.java @@ -15,7 +15,6 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) public class DeleteSiteMemberCoreTests extends RestTest { - private UserModel userModel; private UserModel managerModel; private SiteModel publicSiteModel; @@ -39,8 +38,8 @@ public class DeleteSiteMemberCoreTests extends RestTest privateSiteModel = dataSite.usingUser(adminUserModel).createPrivateRandomSite(); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user removes a site member using '-me-' in place of personId and response is successful (204)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify user removes a site member using '-me-' in place of personId and response is successful (204)") public void removeSiteMemberWithSuccessUsingMeAsPersonId() throws Exception { restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(userModel); @@ -49,31 +48,31 @@ public class DeleteSiteMemberCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user can't remove a site membership if doesn't have access to personId and response is 422") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify user can't remove a site membership if doesn't have access to personId and response is 422") public void notAbleToRemoveSiteMemberWithNoAccessToPersonId() throws Exception { - UserModel secondManager = dataUser.createRandomTestUser(); - dataSite.usingUser(secondManager).createPublicRandomSite(); + UserModel user = dataUser.createRandomTestUser(); + dataSite.usingUser(user).createPublicRandomSite(); userModel.setUserRole(UserRole.SiteCollaborator); restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(userModel); - restClient.authenticateUser(secondManager).withCoreAPI().usingUser(userModel).deleteSiteMember(publicSiteModel); + restClient.authenticateUser(user).withCoreAPI().usingUser(userModel).deleteSiteMember(publicSiteModel); restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(String.format(ErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user can't remove a site membership of an inexistent uer and response is 404") - public void userIsNotAbleToRemoveSiteMemberOfAnInexistentUser() throws Exception + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify user can't remove a site membership of an inexistent uer and response is 404") + public void userIsNotAbleToRemoveInexistentSiteMember() throws Exception { UserModel inexistentUser = new UserModel("inexistenUser", "password"); restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(inexistentUser).deleteSiteMember(publicSiteModel); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, inexistentUser.getUsername())); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove a membership of an inexistent site and response is 404") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify user is not able to remove a member of an inexistent site and response is 404") public void userIsNotAbleToRemoveMembershipOfInexistentSite() throws Exception { SiteModel inexistentSite = new SiteModel("inexistentSite"); @@ -81,8 +80,8 @@ public class DeleteSiteMemberCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(ErrorModel.RELATIONSHIP_NOT_FOUND, userModel.getUsername(), inexistentSite.getId())); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove a membership of an empty site id and response is 404") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify user is not able to remove a member of an empty site id and response is 404") public void userIsNotAbleToRemoveMembershipOfEmptySiteId() throws Exception { SiteModel inexistentSite = new SiteModel(""); @@ -90,8 +89,8 @@ public class DeleteSiteMemberCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(ErrorModel.DELETE_EMPTY_ARGUMENT); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove a membership of another regular user from public site and response is 422") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify user is not able to remove a regular member of a public site and response is 422") public void regularUserIsNotAbleToRemoveRegularUserSiteMembershipFromPublicSite() throws Exception { restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(secondUserModel); @@ -100,8 +99,8 @@ public class DeleteSiteMemberCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(String.format(ErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove a membership of another regular user from moderated site and response is 422") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify user is not able to remove a regular member a moderated site and response is 422") public void regularUserIsNotAbleToRemoveRegularUserSiteMembershipFromModeratedSite() throws Exception { restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(secondUserModel); @@ -110,8 +109,8 @@ public class DeleteSiteMemberCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(String.format(ErrorModel.NOT_SUFFICIENT_PERMISSIONS, moderatedSiteModel.getId())); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove a membership of another regular user from private site and response is 422") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify user is not able to remove a regular member of a private site and response is 422") public void regularUserIsNotAbleToRemoveRegularUserSiteMembershipFromPrivateSite() throws Exception { restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(userModel); @@ -120,8 +119,8 @@ public class DeleteSiteMemberCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(String.format(ErrorModel.NOT_SUFFICIENT_PERMISSIONS, privateSiteModel.getId())); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove the membership of another regular user from public site and response is 204") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify admin is able to remove a regular member of a public site and response is 204") public void adminIsAbleToRemoveRegularUserSiteMembershipFromPublicSite() throws Exception { restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(userModel); @@ -129,8 +128,8 @@ public class DeleteSiteMemberCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove the membership of another regular user from moderated site and response is 204") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify admin is able to remove a regular member of a moderated site and response is 204") public void adminIsAbleToRemoveRegularUserSiteMembershipFromModeratedSite() throws Exception { restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(userModel); @@ -138,8 +137,8 @@ public class DeleteSiteMemberCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove the membership of another regular user from private site and response is 204") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify admin is able to remove a regular member of a private site and response is 204") public void adminIsAbleToRemoveRegularUserSiteMembershipFromPrivateSite() throws Exception { restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(userModel); @@ -147,8 +146,8 @@ public class DeleteSiteMemberCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove the membership of admin from public site and response is 422") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify user is not able to remove admin membership from public site and response is 422") public void regularUserIsNotAbleToRemoveAdminSiteMembershipFromPublicSite() throws Exception { restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(managerModel); @@ -157,8 +156,8 @@ public class DeleteSiteMemberCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(String.format(ErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove the membership of admin from moderated site and response is 422") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify user is not able to remove admin membership from moderated site and response is 422") public void regularUserIsNotAbleToRemoveAdminSiteMembershipFromModeratedSite() throws Exception { restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(managerModel); @@ -167,8 +166,8 @@ public class DeleteSiteMemberCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(String.format(ErrorModel.NOT_SUFFICIENT_PERMISSIONS, moderatedSiteModel.getId())); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove the membership of admin from private site and response is 422") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify user is not able to remove admin membership from private site and response is 422") public void regularUserIsNotAbleToRemoveAdminSiteMembershipFromPrivateSite() throws Exception { restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(managerModel); @@ -177,8 +176,8 @@ public class DeleteSiteMemberCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(String.format(ErrorModel.NOT_SUFFICIENT_PERMISSIONS, privateSiteModel.getId())); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove the membership of manager of a public site and response is 204") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify admin is able to remove the membership of a manager from a public site and response is 204") public void adminIsAbleToRemoveManagerSiteMembershipOfPublicSite() throws Exception { UserModel secondManager = dataUser.createRandomTestUser(); @@ -189,8 +188,8 @@ public class DeleteSiteMemberCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove the membership of manager of a moderated site and response is 204") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify admin is able to remove the membership of a manager from a moderated site and response is 204") public void adminIsAbleToRemoveManagerSiteMembershipOfModeratedSite() throws Exception { UserModel secondManager = dataUser.createRandomTestUser(); @@ -201,8 +200,8 @@ public class DeleteSiteMemberCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove the membership of manager of a private site and response is 204") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify admin is able to remove the membership of a manager from a private site and response is 204") public void adminIsAbleToRemoveManagerSiteMembershipOfPrivateSite() throws Exception { UserModel secondManager = dataUser.createRandomTestUser(); @@ -213,8 +212,8 @@ public class DeleteSiteMemberCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify collaborator is not able to remove the membership of manager of a public site and response is 204") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify collaborator is not able to remove the membership of a manager from a public site and response is 204") public void userIsNotAbleToRemoveManagerSiteMembershipOfPublicSite() throws Exception { UserModel secondManager = dataUser.createRandomTestUser(); @@ -226,8 +225,8 @@ public class DeleteSiteMemberCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(String.format(ErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify collaborator is not able to remove the membership of manager of a moderated site and response is 204") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify collaborator is not able to remove the membership of a manager from a moderated site and response is 204") public void userIsNotAbleToRemoveManagerSiteMembershipOfModeratedSite() throws Exception { UserModel secondManager = dataUser.createRandomTestUser(); @@ -239,8 +238,8 @@ public class DeleteSiteMemberCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(String.format(ErrorModel.NOT_SUFFICIENT_PERMISSIONS, moderatedSiteModel.getId())); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify collaborator is not able to remove the membership of manager of a private site and response is 204") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify collaborator is not able to remove the membership of a manager from a private site and response is 204") public void userIsNotAbleToRemoveManagerSiteMembershipOfPrivateSite() throws Exception { UserModel secondManager = dataUser.createRandomTestUser(); @@ -251,4 +250,4 @@ public class DeleteSiteMemberCoreTests extends RestTest restClient.authenticateUser(userModel).withCoreAPI().usingUser(managerModel).deleteSiteMember(privateSiteModel); restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(String.format(ErrorModel.NOT_SUFFICIENT_PERMISSIONS, privateSiteModel.getId())); } -} +} \ No newline at end of file From 46270b72d2b2df131d690271dba4ce66bfb678c1 Mon Sep 17 00:00:00 2001 From: Bogdan Bocancea Date: Tue, 29 Nov 2016 16:45:47 +0200 Subject: [PATCH 0646/1491] TAS-2054: add core tests to update tag --- .../rest/tags/UpdateTagCoreTests.java | 150 ++++++++++++++++++ .../rest/tags/UpdateTagSanityTests.java | 5 +- 2 files changed, 152 insertions(+), 3 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/tags/UpdateTagCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/tags/UpdateTagCoreTests.java b/e2e-test/java/org/alfresco/rest/tags/UpdateTagCoreTests.java new file mode 100644 index 000000000..a1419c732 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/tags/UpdateTagCoreTests.java @@ -0,0 +1,150 @@ +package org.alfresco.rest.tags; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestTagModel; +import org.alfresco.utility.Utility; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.data.RandomData; +import org.alfresco.utility.model.ErrorModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Created by Bogdan Bocancea + */ +@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) +public class UpdateTagCoreTests extends RestTest +{ + private UserModel managerUser; + private FileModel document; + private SiteModel siteModel; + private DataUser.ListUserWithRoles usersWithRoles; + private RestTagModel oldTag; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + managerUser = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(managerUser).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).usingUser(managerUser).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + + restClient.authenticateUser(managerUser); + oldTag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("old")); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify contributor user gets status code 401 if authentication call fails") + @Bug(id="MNT-16904", description = "Reproduced only on 5.1.N") + public void contributorIsNotAbleToUpdateTagIfAuthenticationFails() throws JsonToModelConversionException, Exception + { + UserModel siteContributor = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); + siteContributor.setPassword("wrongPassword"); + restClient.authenticateUser(siteContributor); + restClient.withCoreAPI().usingTag(oldTag).update(RandomData.getRandomName("tag")); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError().containsSummary(ErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify collaborator user gets status code 401 if authentication call fails") + @Bug(id="MNT-16904", description = "Reproduced only on 5.1.N") + public void collaboratorIsNotAbleToUpdateTagIfAuthenticationFails() throws JsonToModelConversionException, Exception + { + UserModel siteCollaborator = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); + siteCollaborator.setPassword("wrongPassword"); + restClient.authenticateUser(siteCollaborator); + restClient.withCoreAPI().usingTag(oldTag).update(RandomData.getRandomName("tag")); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError().containsSummary(ErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify consumer user gets status code 401 if authentication call fails") + @Bug(id="MNT-16904", description = "Reproduced only on 5.1.N") + public void consumerIsNotAbleToUpdateTagIfAuthenticationFails() throws JsonToModelConversionException, Exception + { + UserModel siteConsumer = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); + siteConsumer.setPassword("wrongPassword"); + restClient.authenticateUser(siteConsumer); + restClient.withCoreAPI().usingTag(oldTag).update(RandomData.getRandomName("tag")); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError().containsSummary(ErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify site manager is not able to update tag with invalid id") + public void managerIsNotAbleToUpdateTagWithInvalidId() throws JsonToModelConversionException, Exception + { + String invalidTagId = "invalid-id"; + restClient.authenticateUser(managerUser); + RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); + tag.setId(invalidTagId); + restClient.withCoreAPI().usingTag(tag).update(RandomData.getRandomName("tag")); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, invalidTagId)); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify site manager is not able to update tag with empty id") + public void managerIsNotAbleToUpdateTagWithEmptyId() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(managerUser); + RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); + tag.setId(""); + restClient.withCoreAPI().usingTag(tag).update(RandomData.getRandomName("tag")); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify site manager is not able to update tag with invalid body") + public void managerIsNotAbleToUpdateTagWithEmptyBody() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(managerUser); + RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); + restClient.withCoreAPI().usingTag(tag).update(""); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(ErrorModel.EMPTY_TAG); + } + + @Bug(id="ACE-5629") + @TestRail(section = { TestGroup.REST_API, + TestGroup.TAGS }, executionType = ExecutionType.SANITY, + description = "Verify site manager is not able to update tag with invalid body containing '|' symbol") + public void managerIsNotAbleToUpdateTagWithInvalidBodyScenario1() throws JsonToModelConversionException, Exception + { + String invalidTagBody = "|.\"/<>*"; + restClient.authenticateUser(managerUser); + RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); + Utility.waitToLoopTime(20); + restClient.withCoreAPI().usingTag(tag).update(invalidTagBody); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(ErrorModel.INVALID_TAG, invalidTagBody)); + } + + @Bug(id="ACE-5629") + @TestRail(section = { TestGroup.REST_API, + TestGroup.TAGS }, executionType = ExecutionType.SANITY, + description = "Verify site manager is not able to update tag with invalid body without '|' symbol") + public void managerIsNotAbleToUpdateTagWithInvalidBodyScenario2() throws JsonToModelConversionException, Exception + { + String invalidTagBody = ".\"/<>*"; + restClient.authenticateUser(managerUser); + RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); + Utility.waitToLoopTime(20); + restClient.withCoreAPI().usingTag(tag).update(invalidTagBody); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(ErrorModel.INVALID_TAG, invalidTagBody)); + } +} diff --git a/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java index cc0e69d12..be11c0477 100644 --- a/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java @@ -10,7 +10,6 @@ import org.alfresco.utility.data.RandomData; import org.alfresco.utility.model.ErrorModel; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; @@ -27,7 +26,6 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) public class UpdateTagSanityTests extends RestTest { - private UserModel adminUserModel; private FileModel document; private SiteModel siteModel; @@ -108,6 +106,7 @@ public class UpdateTagSanityTests extends RestTest siteManager.setPassword("wrongPassword"); restClient.authenticateUser(siteManager); restClient.withCoreAPI().usingTag(oldTag).update(randomTag); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError().containsSummary(ErrorModel.AUTHENTICATION_FAILED); } } \ No newline at end of file From 337190147540646e55d1401bebea078baf0a9855 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Tue, 29 Nov 2016 17:15:30 +0200 Subject: [PATCH 0647/1491] Removed @Bug for 5.2.N tests. --- .../rest/people/GetSiteMembershipRequestCoreTests.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestCoreTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestCoreTests.java index 8bea2548e..b5d4100b6 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestCoreTests.java @@ -6,7 +6,6 @@ import org.alfresco.utility.model.ErrorModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -37,7 +36,7 @@ public class GetSiteMembershipRequestCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.CREATED); } - @Bug(id="MNT-16904") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify contributor user fails to get all site membership requests of a specific person with Rest API when the authentication fails (401)") @@ -52,7 +51,6 @@ public class GetSiteMembershipRequestCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } - @Bug(id="MNT-16904") @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify collaborator user fails to get all site membership requests of a specific person with Rest API when the authentication fails (401)") @@ -67,7 +65,6 @@ public class GetSiteMembershipRequestCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } - @Bug(id="MNT-16904") @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify consumer user fails to get all site membership requests of a specific person with Rest API when the authentication fails (401)") @@ -152,8 +149,7 @@ public class GetSiteMembershipRequestCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) .assertLastError().containsSummary(String.format(ErrorModel.RELATIONSHIP_NOT_FOUND, privateUser.getUsername(), privateSite.getId())); } - - @Bug(id = "MNT-17183", description = "reproduced only on 5.1.N") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site manager can't get site membership requests for inexistent site and response is not found (404)") @@ -164,6 +160,6 @@ public class GetSiteMembershipRequestCoreTests extends RestTest .withCoreAPI() .usingMe().getSiteMembershipRequest(inexistentSite); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(ErrorModel.RELATIONSHIP_NOT_FOUND, newMember.getUsername(), inexistentSite.getId())); + .assertLastError().containsSummary(String.format(ErrorModel.RELATIONSHIP_NOT_FOUND, userModel.getUsername(), inexistentSite.getId())); } } From b887083dd99cf6c7cf4b85a8e1ef3f1565b8bda3 Mon Sep 17 00:00:00 2001 From: cagache Date: Tue, 29 Nov 2016 17:28:21 +0200 Subject: [PATCH 0648/1491] removed irrelevant scenarios (failed authentication scenarios); removed authentication part from scenarios because managerUser is already authenticated in BeforeClass; added assertion in managerIsNotAbleToUpdateTagWithEmptyId --- .../rest/tags/UpdateTagCoreTests.java | 52 ++----------------- 1 file changed, 4 insertions(+), 48 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/tags/UpdateTagCoreTests.java b/e2e-test/java/org/alfresco/rest/tags/UpdateTagCoreTests.java index a1419c732..454076add 100644 --- a/e2e-test/java/org/alfresco/rest/tags/UpdateTagCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/UpdateTagCoreTests.java @@ -39,56 +39,15 @@ public class UpdateTagCoreTests extends RestTest siteModel = dataSite.usingUser(managerUser).createPublicRandomSite(); document = dataContent.usingSite(siteModel).usingUser(managerUser).createContent(CMISUtil.DocumentType.TEXT_PLAIN); usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); - - restClient.authenticateUser(managerUser); - oldTag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("old")); + + oldTag = restClient.authenticateUser(managerUser).withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("old")); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify contributor user gets status code 401 if authentication call fails") - @Bug(id="MNT-16904", description = "Reproduced only on 5.1.N") - public void contributorIsNotAbleToUpdateTagIfAuthenticationFails() throws JsonToModelConversionException, Exception - { - UserModel siteContributor = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); - siteContributor.setPassword("wrongPassword"); - restClient.authenticateUser(siteContributor); - restClient.withCoreAPI().usingTag(oldTag).update(RandomData.getRandomName("tag")); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError().containsSummary(ErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify collaborator user gets status code 401 if authentication call fails") - @Bug(id="MNT-16904", description = "Reproduced only on 5.1.N") - public void collaboratorIsNotAbleToUpdateTagIfAuthenticationFails() throws JsonToModelConversionException, Exception - { - UserModel siteCollaborator = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); - siteCollaborator.setPassword("wrongPassword"); - restClient.authenticateUser(siteCollaborator); - restClient.withCoreAPI().usingTag(oldTag).update(RandomData.getRandomName("tag")); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError().containsSummary(ErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify consumer user gets status code 401 if authentication call fails") - @Bug(id="MNT-16904", description = "Reproduced only on 5.1.N") - public void consumerIsNotAbleToUpdateTagIfAuthenticationFails() throws JsonToModelConversionException, Exception - { - UserModel siteConsumer = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); - siteConsumer.setPassword("wrongPassword"); - restClient.authenticateUser(siteConsumer); - restClient.withCoreAPI().usingTag(oldTag).update(RandomData.getRandomName("tag")); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError().containsSummary(ErrorModel.AUTHENTICATION_FAILED); - } - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify site manager is not able to update tag with invalid id") public void managerIsNotAbleToUpdateTagWithInvalidId() throws JsonToModelConversionException, Exception { String invalidTagId = "invalid-id"; - restClient.authenticateUser(managerUser); RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); tag.setId(invalidTagId); restClient.withCoreAPI().usingTag(tag).update(RandomData.getRandomName("tag")); @@ -100,18 +59,17 @@ public class UpdateTagCoreTests extends RestTest TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify site manager is not able to update tag with empty id") public void managerIsNotAbleToUpdateTagWithEmptyId() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(managerUser); RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); tag.setId(""); restClient.withCoreAPI().usingTag(tag).update(RandomData.getRandomName("tag")); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) + .assertLastError().containsSummary(ErrorModel.PUT_EMPTY_ARGUMENT); } @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify site manager is not able to update tag with invalid body") public void managerIsNotAbleToUpdateTagWithEmptyBody() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(managerUser); RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); restClient.withCoreAPI().usingTag(tag).update(""); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) @@ -125,7 +83,6 @@ public class UpdateTagCoreTests extends RestTest public void managerIsNotAbleToUpdateTagWithInvalidBodyScenario1() throws JsonToModelConversionException, Exception { String invalidTagBody = "|.\"/<>*"; - restClient.authenticateUser(managerUser); RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); Utility.waitToLoopTime(20); restClient.withCoreAPI().usingTag(tag).update(invalidTagBody); @@ -140,7 +97,6 @@ public class UpdateTagCoreTests extends RestTest public void managerIsNotAbleToUpdateTagWithInvalidBodyScenario2() throws JsonToModelConversionException, Exception { String invalidTagBody = ".\"/<>*"; - restClient.authenticateUser(managerUser); RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); Utility.waitToLoopTime(20); restClient.withCoreAPI().usingTag(tag).update(invalidTagBody); From 3b0ed965c1a562a2ad7ae8ca0f2ea53a17ed5bfb Mon Sep 17 00:00:00 2001 From: cagache Date: Mon, 5 Dec 2016 11:07:46 +0200 Subject: [PATCH 0649/1491] test: added core scenarios for updateSiteMember (put /sites/{siteId}/members/{personId}) --- .../rest/sites/UpdateSiteMemberCoreTests.java | 199 ++++++++++++++++++ 1 file changed, 199 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberCoreTests.java new file mode 100644 index 000000000..b0b208f57 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberCoreTests.java @@ -0,0 +1,199 @@ +package org.alfresco.rest.sites; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.JsonBodyGenerator; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.model.RestSiteMemberModel; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.model.ErrorModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Created by Claudia Agache on 11/29/2016. + */ +@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) +public class UpdateSiteMemberCoreTests extends RestTest +{ + private UserModel adminUser, regularUser, anotherManager; + private SiteModel publicSite; + private ListUserWithRoles publicSiteUsers; + private RestSiteMemberModel updatedMember; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + publicSite = dataSite.usingUser(adminUser).createPublicRandomSite(); + publicSiteUsers = dataUser.addUsersWithRolesToSite(publicSite, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + anotherManager = dataUser.createRandomTestUser(); + dataUser.addUserToSite(anotherManager, publicSite, UserRole.SiteManager); + regularUser = dataUser.createRandomTestUser(); + regularUser.setUserRole(UserRole.SiteConsumer); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if update site member request returns status code 404 when nonexistent siteId is used") + public void updateSiteMemberOfNonexistentSite() throws Exception + { + SiteModel deletedSite = dataSite.usingUser(adminUser).createPublicRandomSite(); + dataUser.addUserToSite(regularUser, deletedSite, UserRole.SiteConsumer); + dataSite.deleteSite(deletedSite); + + restClient.authenticateUser(adminUser).withCoreAPI() + .usingSite(deletedSite).updateSiteMember(regularUser); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, deletedSite.getId())); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if update site member request returns status code 400 when personId is not member of the site") + public void updateNotASiteMember() throws Exception + { + restClient.authenticateUser(adminUser).withCoreAPI() + .usingSite(publicSite).updateSiteMember(regularUser); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary("User is not a member of the site"); + } + + @Bug(id="REPO-1642", description = "reproduced on 5.2.1 only, it works on 5.2.0") + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if update site member request returns status code 404 when personId does not exist") + public void updateNonexistentSiteMember() throws Exception + { + UserModel nonexistentUser = new UserModel("nonexistentUser", DataUser.PASSWORD); + nonexistentUser.setUserRole(UserRole.SiteContributor); + restClient.authenticateUser(adminUser).withCoreAPI() + .usingSite(publicSite).updateSiteMember(nonexistentUser); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, nonexistentUser.getUsername())); + } + + @Bug(id="REPO-1660") + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if a manager is able to downgrade to contributor using -me- string in place of personId.") + public void updateSiteManagerToSiteContributorUsingMe() throws Exception + { + UserModel meManager = dataUser.createRandomTestUser(); + dataUser.addUserToSite(meManager, publicSite, UserRole.SiteManager); + UserModel meUser = new UserModel("-me-", "password"); + meUser.setUserRole(UserRole.SiteContributor); + updatedMember = restClient.authenticateUser(meManager).withCoreAPI() + .usingSite(publicSite).updateSiteMember(meUser); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedMember.assertThat().field("id").is(meManager.getUsername()) + .and().field("role").is(meUser.getUserRole()); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if update site member request returns status code 404 when empty siteId is used") + public void updateSiteMemberUsingEmptySiteId() throws Exception + { + restClient.authenticateUser(adminUser).withCoreAPI() + .usingSite("").updateSiteMember(regularUser); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, "")); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if update site member request returns status code 405 when empty personId is used") + public void updateSiteMemberUsingEmptyPersonId() throws Exception + { + UserModel emptyUser = new UserModel("", DataUser.PASSWORD); + emptyUser.setUserRole(UserRole.SiteCollaborator); + restClient.authenticateUser(adminUser).withCoreAPI() + .usingSite(publicSite).updateSiteMember(emptyUser); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) + .assertLastError().containsSummary(ErrorModel.PUT_EMPTY_ARGUMENT); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if update site member request returns status code 400 when invalid role is used") + public void updateSiteMemberUsingInvalidRole() throws Exception + { + restClient.authenticateUser(anotherManager).withCoreAPI(); + UserModel siteConsumer = publicSiteUsers.getOneUserWithRole(UserRole.SiteConsumer); + String json = JsonBodyGenerator.keyValueJson("role","invalidRole"); + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, json, "sites/{siteId}/members/{personId}", publicSite.getId(), siteConsumer.getUsername()); + restClient.processModel(RestSiteMemberModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(ErrorModel.UNKNOWN_ROLE, "invalidRole")); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if manager is able to update another site manager to site collaborator") + public void managerUpdateSiteManagerToSiteCollaborator() throws Exception + { + UserModel siteManager = publicSiteUsers.getOneUserWithRole(UserRole.SiteManager); + siteManager.setUserRole(UserRole.SiteCollaborator); + updatedMember = restClient.authenticateUser(anotherManager).withCoreAPI() + .usingSite(publicSite).updateSiteMember(siteManager); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedMember.assertThat().field("id").is(siteManager.getUsername()) + .and().field("role").is(siteManager.getUserRole()); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if manager is able to update site contributor to site manager") + public void managerUpdateSiteContributorToSiteManager() throws Exception + { + UserModel siteContributor = publicSiteUsers.getOneUserWithRole(UserRole.SiteContributor); + siteContributor.setUserRole(UserRole.SiteManager); + updatedMember = restClient.authenticateUser(anotherManager).withCoreAPI() + .usingSite(publicSite).updateSiteMember(siteContributor); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedMember.assertThat().field("id").is(siteContributor.getUsername()) + .and().field("role").is(siteContributor.getUserRole()); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if manager is able to update site collaborator to site manager") + public void managerUpdateSiteCollaboratorToSiteManager() throws Exception + { + UserModel siteCollaborator = publicSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator); + siteCollaborator.setUserRole(UserRole.SiteManager); + updatedMember = restClient.authenticateUser(anotherManager).withCoreAPI() + .usingSite(publicSite).updateSiteMember(siteCollaborator); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedMember.assertThat().field("id").is(siteCollaborator.getUsername()) + .and().field("role").is(siteCollaborator.getUserRole()); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if manager is able to update site consumer to site manager") + public void managerUpdateSiteConsumerToSiteManager() throws Exception + { + UserModel siteConsumer = publicSiteUsers.getOneUserWithRole(UserRole.SiteConsumer); + siteConsumer.setUserRole(UserRole.SiteManager); + updatedMember = restClient.authenticateUser(anotherManager).withCoreAPI() + .usingSite(publicSite).updateSiteMember(siteConsumer); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedMember.assertThat().field("id").is(siteConsumer.getUsername()) + .and().field("role").is(siteConsumer.getUserRole()); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if manager is able to downgrade himself to site consumer") + public void managerDowngradeHimselfToSiteConsumer() throws Exception + { + UserModel siteManager = publicSiteUsers.getOneUserWithRole(UserRole.SiteManager); + siteManager.setUserRole(UserRole.SiteConsumer); + updatedMember = restClient.authenticateUser(siteManager).withCoreAPI() + .usingSite(publicSite).updateSiteMember(siteManager); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedMember.assertThat().field("id").is(siteManager.getUsername()) + .and().field("role").is(siteManager.getUserRole()); + } + +} From 492a44ccd65356ffa61c4b98c2e9cb69589e4d00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alecsandru=20Prun=C4=83?= Date: Mon, 5 Dec 2016 11:12:14 +0200 Subject: [PATCH 0650/1491] test: Added GetSiteMembershipInformationCoreTests --- ...GetSiteMembershipInformationCoreTests.java | 135 ++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/people/GetSiteMembershipInformationCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipInformationCoreTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipInformationCoreTests.java new file mode 100644 index 000000000..4a755125a --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipInformationCoreTests.java @@ -0,0 +1,135 @@ +package org.alfresco.rest.people; + +import org.alfresco.rest.RestTest; +import org.alfresco.utility.constants.UserRole; +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; + +@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) +public class GetSiteMembershipInformationCoreTests extends RestTest +{ + private SiteModel publicSiteModel; + private SiteModel moderatedSiteModel; + private SiteModel privateSiteModel; + private UserModel userModel; + UserModel leaveSiteUserModel; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws DataPreparationException + { + userModel = dataUser.createRandomTestUser(); + leaveSiteUserModel = dataUser.createRandomTestUser(); + publicSiteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + moderatedSiteModel = dataSite.usingUser(userModel).createModeratedRandomSite(); + privateSiteModel = dataSite.usingUser(userModel).createPrivateRandomSite(); + dataUser.addUserToSite(leaveSiteUserModel, publicSiteModel, UserRole.SiteCollaborator); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify site manager is able to retrieve site membership information with -me- as personId") + public void siteManagerCanRetrieveSiteMembershipInformationWithMeAsPersonId() throws Exception + { + restClient.authenticateUser(userModel) + .withCoreAPI() + .usingMe() + .getSitesMembershipInformation() + .assertThat().entriesListIsNotEmpty() + .and().paginationExist() + .and().paginationField("count").isNot("0"); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify site manager is not able to retrieve site membership information for a personId that does not exist") + public void siteManagerCantRetrieveSiteMembershipInformationForAPersonIdThatDoesNotExist() throws Exception + { + restClient.authenticateUser(userModel) + .withCoreAPI() + .usingUser(new UserModel("invalidPersonId", "password")) + .getSitesMembershipInformation() + .assertThat().entriesListIsEmpty(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify if get site membership information request returns status code 400 when invalid maxItems parameter is used") + public void getSiteMembershipInformationRequestReturns400ForInvalidMaxItemsParameter() throws Exception + { + restClient.authenticateUser(userModel) + .withParams("maxItems=0") + .withCoreAPI() + .usingAuthUser() + .getSitesMembershipInformation() + .assertThat().entriesListIsEmpty(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify if get site membership information request returns status code 400 when invalid skipCount parameter is used") + public void getSiteMembershipInformationRequestReturns400ForInvalidSkipCountParameter() throws Exception + { + restClient.authenticateUser(userModel) + .withParams("skipCount=-1") + .withCoreAPI() + .usingAuthUser() + .getSitesMembershipInformation() + .assertThat().entriesListIsEmpty(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify site manager is able to retrieve public sites") + public void siteManagerCheckThatPublicSitesAreRetrieved() throws Exception + { + restClient.authenticateUser(userModel) + .withCoreAPI() + .usingAuthUser() + .getSitesMembershipInformation() + .assertThat().entriesListContains("id", publicSiteModel.getId()); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify site manager is able to retrieve moderated sites") + public void siteManagerCheckThatModeratedSitesAreRetrieved() throws Exception + { + restClient.authenticateUser(userModel) + .withCoreAPI() + .usingAuthUser() + .getSitesMembershipInformation() + .assertThat().entriesListContains("id", moderatedSiteModel.getId()); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify site manager is able to retrieve private sites") + public void siteManagerCheckThatPrivateSitesAreRetrieved() throws Exception + { + restClient.authenticateUser(userModel) + .withCoreAPI() + .usingAuthUser() + .getSitesMembershipInformation() + .assertThat().entriesListContains("id", privateSiteModel.getId()); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify site member is able to leave site") + public void siteMemberIsAbleToLeaveSite() throws Exception + { + restClient.authenticateUser(leaveSiteUserModel).withCoreAPI().usingAuthUser().deleteSiteMember(publicSiteModel); + restClient.authenticateUser(leaveSiteUserModel) + .withCoreAPI() + .usingAuthUser() + .getSitesMembershipInformation() + .assertThat().entriesListIsEmpty(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } +} From 0c0e8c09042f20f4eda8902b058ff54cd80b9289 Mon Sep 17 00:00:00 2001 From: Bogdan Bocancea Date: Mon, 5 Dec 2016 15:05:36 +0200 Subject: [PATCH 0651/1491] TAS-2032: add core tests for updateSiteMembership request --- .../UpdateSiteMembershipRequestCoreTests.java | 174 ++++++++++++++++++ 1 file changed, 174 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestCoreTests.java b/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestCoreTests.java new file mode 100644 index 000000000..6ac58271e --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestCoreTests.java @@ -0,0 +1,174 @@ +package org.alfresco.rest.people; + +import org.alfresco.rest.RestTest; +import org.alfresco.utility.data.DataSite; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.exception.DataPreparationException; +import org.alfresco.utility.model.ErrorModel; +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.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) +public class UpdateSiteMembershipRequestCoreTests extends RestTest +{ + @Autowired + DataUser dataUser; + + @Autowired + DataSite dataSite; + + private SiteModel siteModel; + private UserModel managerUser; + private String updatedMessage; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws DataPreparationException + { + managerUser = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(managerUser).createModeratedRandomSite(); + updatedMessage = "Please review my request"; + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, description = "Verify unauthorized user is not able to update user site membership request") + public void unauthorizedUserIsNotAbleToUpdateSiteMembershipRequest() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(newMember) + .withCoreAPI() + .usingAuthUser() + .addSiteMembershipRequest(siteModel); + newMember.setPassword("fakePass"); + restClient.withCoreAPI() + .usingUser(newMember).updateSiteMembershipRequest(siteModel, updatedMessage); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError().containsSummary(ErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, description = "Verify user is able to update its own site membership request using -me-") + public void usingMeUpdateSiteMembershipRequest() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(newMember) + .withCoreAPI() + .usingAuthUser() + .addSiteMembershipRequest(siteModel); + restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(siteModel, updatedMessage) + .assertMembershipRequestMessageIs(updatedMessage) + .and().field("id").is(siteModel.getId()) + .and().field("modifiedAt").isNotEmpty(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, description = "Verify inexistent user is not able to update its own site membership request") + public void inexistentUserCannotUpdateSiteMembershipRequest() throws Exception + { + UserModel inexistentUser = UserModel.getRandomUserModel(); + restClient.authenticateUser(managerUser) + .withCoreAPI().usingUser(inexistentUser) + .updateSiteMembershipRequest(siteModel, updatedMessage); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, inexistentUser.getUsername())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, description = "Verify user is not able to update its own site membership request for inexistent site") + public void userCannotUpdateSiteMembershipRequestForInexistentSite() throws Exception + { + SiteModel randomSite = SiteModel.getRandomSiteModel(); + UserModel newMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(newMember).withCoreAPI() + .usingMe() + .updateSiteMembershipRequest(randomSite, updatedMessage); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(ErrorModel.RELATIONSHIP_NOT_FOUND, newMember.getUsername(), randomSite.getId())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, description = "Verify user is able not to update its own site membership request for public site") + public void userCannotUpdateSiteMembershipRequestForPublicSite() throws Exception + { + SiteModel publicSite = dataSite.usingUser(managerUser).createPublicRandomSite(); + UserModel newMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(newMember) + .withCoreAPI() + .usingAuthUser() + .addSiteMembershipRequest(publicSite); + restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(publicSite, updatedMessage); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(ErrorModel.RELATIONSHIP_NOT_FOUND, newMember.getUsername(), publicSite.getId())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, description = "Verify user is not able to update its own site membership request for private site") + public void userCannotUpdateSiteMembershipRequestForPrivateSite() throws Exception + { + SiteModel privateSite = dataSite.usingUser(managerUser).createPrivateRandomSite(); + UserModel newMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(newMember) + .withCoreAPI() + .usingAuthUser() + .addSiteMembershipRequest(privateSite); + restClient.withCoreAPI().usingMe() + .updateSiteMembershipRequest(privateSite, updatedMessage); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(ErrorModel.RELATIONSHIP_NOT_FOUND, newMember.getUsername(), privateSite.getId())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, description = "Verify user is able to update its own site membership request with initial message") + public void userCanUpdateSiteMembershipRequestWithInitialMessage() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(newMember) + .withCoreAPI() + .usingAuthUser() + .addSiteMembershipRequest(siteModel, updatedMessage); + restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(siteModel, updatedMessage) + .assertMembershipRequestMessageIs(updatedMessage) + .and().field("id").is(siteModel.getId()) + .and().field("modifiedAt").isNotEmpty(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, description = "Verify user is able to update its own site membership request with different message") + public void userCanUpdateSiteMembershipRequestWithDifferentMessage() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(newMember) + .withCoreAPI() + .usingAuthUser() + .addSiteMembershipRequest(siteModel, ""); + restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(siteModel, updatedMessage) + .assertMembershipRequestMessageIs(updatedMessage) + .and().field("id").is(siteModel.getId()) + .and().field("modifiedAt").isNotEmpty(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, description = "Verify modifiedAt field for update siteMembership request call") + public void verifyModifiedAtForUpdateSiteMembershipRequest() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(newMember) + .withCoreAPI() + .usingAuthUser() + .addSiteMembershipRequest(siteModel); + String firstModifiedAt = restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(siteModel, "first message").getModifiedAt(); + String secondModifiedAt = restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(siteModel, "second message").getModifiedAt(); + Assert.assertNotEquals(firstModifiedAt, secondModifiedAt); + restClient.assertStatusCodeIs(HttpStatus.OK); + } +} \ No newline at end of file From 500558671e4bf9b90c7172b72ea1b8fe8851d7fd Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Mon, 5 Dec 2016 15:07:32 +0200 Subject: [PATCH 0652/1491] core: move ErrorModel from utility to RestAPI project --- .../rest/comments/AddCommentCoreTests.java | 11 ++++---- .../rest/comments/AddCommentSanityTests.java | 3 +- .../rest/comments/AddCommentsSanityTests.java | 6 ++-- .../comments/DeleteCommentsCoreTests.java | 4 +-- .../rest/comments/GetCommentsCoreTests.java | 11 ++++---- .../comments/UpdateCommentsCoreTests.java | 3 +- .../comments/UpdateCommentsSanityTests.java | 5 ++-- .../rest/favorites/AddFavoritesCoreTests.java | 16 +++++------ .../favorites/DeleteFavoritesSanityTests.java | 8 +++--- .../favorites/GetFavoriteSanityTests.java | 7 +++-- .../rest/favorites/GetFavoritesCoreTests.java | 5 ++-- .../favorites/GetFavoritesSanityTests.java | 7 +++-- .../people/DeleteFavoriteSiteCoreTests.java | 6 ++-- .../people/DeleteFavoriteSiteSanityTests.java | 3 +- .../people/DeleteSiteMemberCoreTests.java | 28 +++++++++---------- .../people/DeleteSiteMemberSanityTests.java | 8 +++--- ...eleteSiteMembershipRequestSanityTests.java | 9 +++--- .../rest/people/GetFavoriteSiteCoreTests.java | 8 +++--- .../people/GetFavoriteSiteSanityTests.java | 3 +- .../people/GetFavoriteSitesSanityTests.java | 9 +++--- .../GetPeopleActivitiesSanityTests.java | 3 +- .../rest/people/GetPeopleSanityTests.java | 4 +-- .../people/GetSiteMembershipCoreTests.java | 12 ++++---- .../GetSiteMembershipRequestCoreTests.java | 12 ++++---- .../GetSiteMembershipRequestsSanityTests.java | 2 +- ...pdateSiteMembershipRequestSanityTests.java | 14 +++++----- .../rest/ratings/AddRatingCoreTests.java | 22 +++++++-------- .../rest/ratings/DeleteRatingCoreTests.java | 6 ++-- .../rest/ratings/GetRatingSanityTests.java | 6 ++-- .../rest/ratings/GetRatingsCoreTests.java | 4 +-- .../rest/ratings/GetRatingsSanityTests.java | 4 +-- .../alfresco/rest/sites/GetSiteCoreTests.java | 6 ++-- .../rest/sites/GetSiteMemberCoreTests.java | 10 +++---- .../rest/sites/GetSiteMembersCoreTests.java | 6 ++-- .../rest/sites/GetSitesCoreTests.java | 2 +- .../rest/sites/RemoveSiteMemberCoreTests.java | 26 ++++++++--------- .../rest/sites/UpdateSiteMemberCoreTests.java | 12 ++++---- .../alfresco/rest/tags/AddTagSanityTests.java | 6 ++-- .../rest/tags/AddTagsSanityTests.java | 6 ++-- .../rest/tags/DeleteTagSanityTests.java | 6 ++-- .../rest/tags/GetNodeTagsSanityTests.java | 3 +- .../alfresco/rest/tags/GetTagCoreTests.java | 4 +-- .../alfresco/rest/tags/GetTagsCoreTests.java | 6 ++-- .../rest/tags/UpdateTagCoreTests.java | 12 ++++---- .../rest/tags/UpdateTagSanityTests.java | 12 ++++---- .../DeleteDeploymentSanityTests.java | 4 +-- .../deployments/GetDeploymentSanityTests.java | 4 +-- .../DeleteProcessVariableSanityTests.java | 3 +- .../UpdateProcessVariableSanityTests.java | 3 +- 49 files changed, 198 insertions(+), 182 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentCoreTests.java b/e2e-test/java/org/alfresco/rest/comments/AddCommentCoreTests.java index cfb3f96c8..d799bd408 100644 --- a/e2e-test/java/org/alfresco/rest/comments/AddCommentCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/AddCommentCoreTests.java @@ -5,6 +5,7 @@ import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestCommentModel; import org.alfresco.rest.model.RestCommentModelsCollection; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestTagModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; @@ -55,7 +56,7 @@ public class AddCommentCoreTests extends RestTest restClient.authenticateUser(adminUserModel) .withCoreAPI().usingResource(file).addComment(comment); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, file.getNodeRef())); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, file.getNodeRef())); } @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, @@ -79,7 +80,7 @@ public class AddCommentCoreTests extends RestTest { restClient.authenticateUser(adminUserModel) .withCoreAPI().usingResource(document).addComment(""); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(ErrorModel.NULL_ARGUMENT, "comment")); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.NULL_ARGUMENT, "comment")); } @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, @@ -122,7 +123,7 @@ public class AddCommentCoreTests extends RestTest restClient.authenticateUser(member) .withCoreAPI().usingResource(file).addComment(comment); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, @@ -150,7 +151,7 @@ public class AddCommentCoreTests extends RestTest restClient.authenticateUser(adminUserModel) .withCoreAPI().usingResource(file).addComment(comment); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(ErrorModel.CANNOT_COMMENT); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.CANNOT_COMMENT); } @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, @@ -165,6 +166,6 @@ public class AddCommentCoreTests extends RestTest restClient.authenticateUser(adminUserModel) .withCoreAPI().usingResource(file).addComment(comment); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(ErrorModel.CANNOT_COMMENT); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.CANNOT_COMMENT); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java index f08b0318b..5743f156b 100644 --- a/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java @@ -3,6 +3,7 @@ package org.alfresco.rest.comments; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.*; @@ -84,7 +85,7 @@ public class AddCommentSanityTests extends RestTest restClient.withCoreAPI().usingResource(document).addComment(contentSiteConsumer); restClient .assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user gets status code 401 on post comments call") diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java index 3450ac655..ae50540e0 100644 --- a/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java @@ -3,10 +3,10 @@ package org.alfresco.rest.comments; import org.alfresco.dataprep.CMISUtil; 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; import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.ErrorModel; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; @@ -105,7 +105,7 @@ public class AddCommentsSanityTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) .withCoreAPI().usingResource(document).addComments(comment1, comment2); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, @@ -114,6 +114,6 @@ public class AddCommentsSanityTests extends RestTest { restClient.authenticateUser(new UserModel("random user", "random password")) .withCoreAPI().usingResource(document).addComments(comment1, comment2); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(ErrorModel.AUTHENTICATION_FAILED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } } diff --git a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsCoreTests.java b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsCoreTests.java index 5f58d9e9b..babe3a595 100644 --- a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsCoreTests.java @@ -4,9 +4,9 @@ import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestCommentModel; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.model.ErrorModel; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; @@ -46,7 +46,7 @@ public class DeleteCommentsCoreTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); restClient.withCoreAPI().usingResource(document).deleteComment(comment); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, diff --git a/e2e-test/java/org/alfresco/rest/comments/GetCommentsCoreTests.java b/e2e-test/java/org/alfresco/rest/comments/GetCommentsCoreTests.java index 3436e01df..d7fd1e7bc 100644 --- a/e2e-test/java/org/alfresco/rest/comments/GetCommentsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/GetCommentsCoreTests.java @@ -3,6 +3,7 @@ package org.alfresco.rest.comments; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestCommentModelsCollection; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.model.*; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; @@ -61,7 +62,7 @@ public class GetCommentsCoreTests extends RestTest restClient.authenticateUser(adminUserModel).withCoreAPI() .usingResource(nonexistentFile).getNodeComments(); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, nonexistentFile.getNodeRef())); + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, nonexistentFile.getNodeRef())); } @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, @@ -75,7 +76,7 @@ public class GetCommentsCoreTests extends RestTest restClient.authenticateUser(adminUserModel).withCoreAPI() .usingResource(fileWithNodeRefFromLink).getNodeComments(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(ErrorModel.UNABLE_TO_LOCATE); + .assertLastError().containsSummary(RestErrorModel.UNABLE_TO_LOCATE); } @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, @@ -85,7 +86,7 @@ public class GetCommentsCoreTests extends RestTest restClient.authenticateUser(userModel).withCoreAPI() .usingResource(document).getNodeComments(); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, @@ -107,7 +108,7 @@ public class GetCommentsCoreTests extends RestTest { networkUserModel.setDomain("invalidNetwork"); restClient.authenticateUser(userModel).withCoreAPI().usingResource(document).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, @@ -116,7 +117,7 @@ public class GetCommentsCoreTests extends RestTest { networkUserModel.setDomain(""); restClient.authenticateUser(userModel).withCoreAPI().usingResource(document).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } } diff --git a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsCoreTests.java b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsCoreTests.java index 32465a959..5376c3b9c 100644 --- a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsCoreTests.java @@ -5,6 +5,7 @@ import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestCommentModel; import org.alfresco.rest.model.RestCommentModelsCollection; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.*; @@ -86,7 +87,7 @@ public class UpdateCommentsCoreTests extends RestTest commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by admin"); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); restClient.withCoreAPI().usingResource(document).updateComment(commentModel, "This is the updated comment with Collaborator user"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, diff --git a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java index 5da722321..830a92fb0 100644 --- a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java @@ -4,6 +4,7 @@ import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestCommentModel; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.*; @@ -80,7 +81,7 @@ public class UpdateCommentsSanityTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); restClient.withCoreAPI().usingResource(document).updateComment(commentModel, "This is the updated comment with Consumer user"); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, @@ -130,7 +131,7 @@ public class UpdateCommentsSanityTests extends RestTest comment.setId(id); restClient.withCoreAPI().usingResource(document).updateComment(comment, "This is the updated comment."); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, id)); + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, id)); } } diff --git a/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesCoreTests.java b/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesCoreTests.java index 1bd799d4a..d5d84fc33 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesCoreTests.java @@ -3,12 +3,12 @@ package org.alfresco.rest.favorites; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestCommentModel; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestPersonFavoritesModel; import org.alfresco.rest.model.RestTagModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.model.ErrorModel; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.LinkModel; @@ -63,7 +63,7 @@ public class AddFavoritesCoreTests extends RestTest site.setGuid(link.getNodeRef()); restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(site); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, site.getGuid().split("/")[3])); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, site.getGuid().split("/")[3])); } @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, @@ -72,7 +72,7 @@ public class AddFavoritesCoreTests extends RestTest { restClient.withCoreAPI().usingUser(new UserModel("random_user", "random_password")).addSiteToFavorites(siteModel); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, "random_user")); + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "random_user")); } @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, @@ -84,7 +84,7 @@ public class AddFavoritesCoreTests extends RestTest restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(site); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, "random_guid")); + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "random_guid")); } @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, @@ -106,7 +106,7 @@ public class AddFavoritesCoreTests extends RestTest document.setNodeRef(folder.getNodeRef()); restClient.withCoreAPI().usingAuthUser().addFileToFavorites(document); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(ErrorModel.RELATIONSHIP_NOT_FOUND, + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, adminUserModel.getUsername(), folder.getNodeRefWithoutVersion())); document.setNodeRef(nodeRef); @@ -187,7 +187,7 @@ public class AddFavoritesCoreTests extends RestTest file.setNodeRef(returnedModel.getId()); restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFileToFavorites(file); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(ErrorModel.RELATIONSHIP_NOT_FOUND, + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, adminUserModel.getUsername(), returnedModel.getId())); } @@ -199,7 +199,7 @@ public class AddFavoritesCoreTests extends RestTest siteModel.setGuid(document.getNodeRefWithoutVersion()); restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, document.getNodeRefWithoutVersion())); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, document.getNodeRefWithoutVersion())); siteModel.setGuid(guid); } @@ -212,7 +212,7 @@ public class AddFavoritesCoreTests extends RestTest folder.setNodeRef(document.getNodeRef()); restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(folder); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, document.getNodeRef())); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, document.getNodeRef())); folder.setNodeRef(nodeRef); } diff --git a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoritesSanityTests.java index 29ec22bf1..2ad3db617 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoritesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoritesSanityTests.java @@ -2,9 +2,9 @@ package org.alfresco.rest.favorites; 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.model.ErrorModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; @@ -97,7 +97,7 @@ public class DeleteFavoritesSanityTests extends RestTest restClient.authenticateUser(siteCollaborator).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI() .usingAuthUser().deleteSiteFromFavorites(siteModel) - .assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + .assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify user doesn't have permission to delete favorites of admin user with Rest API and status code is 404") @@ -108,7 +108,7 @@ public class DeleteFavoritesSanityTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) .withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel) - .assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + .assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify admin user doesn't have permission to delete favorites of another user with Rest API and status code is 404") @@ -120,7 +120,7 @@ public class DeleteFavoritesSanityTests extends RestTest restClient.authenticateUser(adminUserModel) .withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel) - .assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + .assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify user gets status code 401 if authentication call fails") diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java index c6a5e6e1c..a9218e551 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java @@ -3,6 +3,7 @@ package org.alfresco.rest.favorites; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestPersonFavoritesModelsCollection; import org.alfresco.rest.model.RestSiteModelsCollection; import org.alfresco.utility.constants.UserRole; @@ -133,7 +134,7 @@ public class GetFavoriteSanityTests extends RestTest .getFavorite(siteModel.getGuid()); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator).getUsername())); + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator).getUsername())); } @TestRail(section = { TestGroup.REST_API, @@ -144,7 +145,7 @@ public class GetFavoriteSanityTests extends RestTest .withCoreAPI().usingUser(adminUserModel).getFavorite(siteModel.getGuid()); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, adminUserModel.getUsername())); + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, adminUserModel.getUsername())); } @TestRail(section = { TestGroup.REST_API, @@ -155,7 +156,7 @@ public class GetFavoriteSanityTests extends RestTest .usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).getFavorite(siteModel.getGuid()); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator).getUsername())); + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator).getUsername())); } @TestRail(section = { TestGroup.REST_API, diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesCoreTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesCoreTests.java index ea5e5d269..7fca8f547 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesCoreTests.java @@ -2,6 +2,7 @@ package org.alfresco.rest.favorites; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestPersonFavoritesModelsCollection; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; @@ -198,7 +199,7 @@ public class GetFavoritesCoreTests extends RestTest userFavorites = restClient.withCoreAPI().usingAuthUser() .where().or().getFavorites(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(ErrorModel.INVALID_ARGUMENT, "WHERE query")); + .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_ARGUMENT, "WHERE query")); } @TestRail(section = { TestGroup.REST_API, @@ -239,6 +240,6 @@ public class GetFavoritesCoreTests extends RestTest restClient.authenticateUser(adminUserModel).withCoreAPI() .usingUser(someUser).getFavorites(); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, "someUser")); + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "someUser")); } } diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java index e5937ce1c..7fef66075 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java @@ -3,6 +3,7 @@ package org.alfresco.rest.favorites; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestPersonFavoritesModelsCollection; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; @@ -148,7 +149,7 @@ public class GetFavoritesSanityTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) .withCoreAPI().usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).getFavorites(); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator).getUsername())); + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator).getUsername())); } @TestRail(section = { TestGroup.REST_API, @@ -158,7 +159,7 @@ public class GetFavoritesSanityTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI() .usingUser(adminUserModel).getFavorites(); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, adminUserModel.getUsername())); + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, adminUserModel.getUsername())); } @TestRail(section = { TestGroup.REST_API, @@ -168,7 +169,7 @@ public class GetFavoritesSanityTests extends RestTest restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) .getFavorites(); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator).getUsername())); + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator).getUsername())); } @TestRail(section = { TestGroup.REST_API, diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteCoreTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteCoreTests.java index d5c681e18..00add0c98 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteCoreTests.java @@ -1,9 +1,9 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestSiteModel; import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.model.ErrorModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; @@ -48,7 +48,7 @@ public class DeleteFavoriteSiteCoreTests extends RestTest { UserModel inexistentUser = new UserModel("inexistenUser", "password"); restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(inexistentUser).removeFavoriteSite(siteModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, "inexistenUser")); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "inexistenUser")); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, @@ -58,7 +58,7 @@ public class DeleteFavoriteSiteCoreTests extends RestTest SiteModel inexistentSite = new SiteModel("inexistentSite"); restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).removeFavoriteSite(inexistentSite); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(ErrorModel.RELATIONSHIP_NOT_FOUND, adminUserModel.getUsername(), inexistentSite.getTitle())); + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, adminUserModel.getUsername(), inexistentSite.getTitle())); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java index 0f5505ad2..04380df48 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java @@ -1,6 +1,7 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.model.*; import org.alfresco.utility.report.Bug; @@ -110,7 +111,7 @@ public class DeleteFavoriteSiteSanityTests extends RestTest dataSite.usingUser(anotherUser).usingSite(siteModel2).addSiteToFavorites(); restClient.authenticateUser(userAuth).withCoreAPI().usingUser(anotherUser).removeFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } @Bug(id = "MNT-16904") diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberCoreTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberCoreTests.java index 2c9807cfc..397dfdcd2 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberCoreTests.java @@ -1,8 +1,8 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.model.ErrorModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; @@ -59,7 +59,7 @@ public class DeleteSiteMemberCoreTests extends RestTest restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(userModel); restClient.authenticateUser(user).withCoreAPI().usingUser(userModel).deleteSiteMember(publicSiteModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(String.format(ErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, @@ -68,7 +68,7 @@ public class DeleteSiteMemberCoreTests extends RestTest { UserModel inexistentUser = new UserModel("inexistenUser", "password"); restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(inexistentUser).deleteSiteMember(publicSiteModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, inexistentUser.getUsername())); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, inexistentUser.getUsername())); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, @@ -77,7 +77,7 @@ public class DeleteSiteMemberCoreTests extends RestTest { SiteModel inexistentSite = new SiteModel("inexistentSite"); restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(userModel).deleteSiteMember(inexistentSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(ErrorModel.RELATIONSHIP_NOT_FOUND, userModel.getUsername(), inexistentSite.getId())); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, userModel.getUsername(), inexistentSite.getId())); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, @@ -86,7 +86,7 @@ public class DeleteSiteMemberCoreTests extends RestTest { SiteModel inexistentSite = new SiteModel(""); restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(userModel).deleteSiteMember(inexistentSite); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(ErrorModel.DELETE_EMPTY_ARGUMENT); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.DELETE_EMPTY_ARGUMENT); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, @@ -96,7 +96,7 @@ public class DeleteSiteMemberCoreTests extends RestTest restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(secondUserModel); restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(userModel); restClient.authenticateUser(secondUserModel).withCoreAPI().usingUser(userModel).deleteSiteMember(publicSiteModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(String.format(ErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, @@ -106,7 +106,7 @@ public class DeleteSiteMemberCoreTests extends RestTest restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(secondUserModel); restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(userModel); restClient.authenticateUser(secondUserModel).withCoreAPI().usingUser(userModel).deleteSiteMember(moderatedSiteModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(String.format(ErrorModel.NOT_SUFFICIENT_PERMISSIONS, moderatedSiteModel.getId())); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, moderatedSiteModel.getId())); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, @@ -116,7 +116,7 @@ public class DeleteSiteMemberCoreTests extends RestTest restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(userModel); restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(secondUserModel); restClient.authenticateUser(secondUserModel).withCoreAPI().usingUser(userModel).deleteSiteMember(privateSiteModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(String.format(ErrorModel.NOT_SUFFICIENT_PERMISSIONS, privateSiteModel.getId())); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, privateSiteModel.getId())); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, @@ -153,7 +153,7 @@ public class DeleteSiteMemberCoreTests extends RestTest restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(managerModel); restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(userModel); restClient.authenticateUser(userModel).withCoreAPI().usingUser(adminUserModel).deleteSiteMember(publicSiteModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(String.format(ErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, @@ -163,7 +163,7 @@ public class DeleteSiteMemberCoreTests extends RestTest restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(managerModel); restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(userModel); restClient.authenticateUser(userModel).withCoreAPI().usingUser(adminUserModel).deleteSiteMember(moderatedSiteModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(String.format(ErrorModel.NOT_SUFFICIENT_PERMISSIONS, moderatedSiteModel.getId())); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, moderatedSiteModel.getId())); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, @@ -173,7 +173,7 @@ public class DeleteSiteMemberCoreTests extends RestTest restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(managerModel); restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(userModel); restClient.authenticateUser(userModel).withCoreAPI().usingUser(adminUserModel).deleteSiteMember(privateSiteModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(String.format(ErrorModel.NOT_SUFFICIENT_PERMISSIONS, privateSiteModel.getId())); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, privateSiteModel.getId())); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, @@ -222,7 +222,7 @@ public class DeleteSiteMemberCoreTests extends RestTest restClient.withCoreAPI().usingSite(publicSiteModel).addPerson(userModel); restClient.withCoreAPI().usingSite(publicSiteModel).addPerson(managerModel); restClient.authenticateUser(userModel).withCoreAPI().usingUser(managerModel).deleteSiteMember(publicSiteModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(String.format(ErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, @@ -235,7 +235,7 @@ public class DeleteSiteMemberCoreTests extends RestTest restClient.withCoreAPI().usingSite(publicSiteModel).addPerson(userModel); restClient.withCoreAPI().usingSite(moderatedSiteModel).addPerson(managerModel); restClient.authenticateUser(userModel).withCoreAPI().usingUser(managerModel).deleteSiteMember(moderatedSiteModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(String.format(ErrorModel.NOT_SUFFICIENT_PERMISSIONS, moderatedSiteModel.getId())); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, moderatedSiteModel.getId())); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, @@ -248,6 +248,6 @@ public class DeleteSiteMemberCoreTests extends RestTest restClient.withCoreAPI().usingSite(privateSiteModel).addPerson(userModel); restClient.withCoreAPI().usingSite(privateSiteModel).addPerson(managerModel); restClient.authenticateUser(userModel).withCoreAPI().usingUser(managerModel).deleteSiteMember(privateSiteModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(String.format(ErrorModel.NOT_SUFFICIENT_PERMISSIONS, privateSiteModel.getId())); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, privateSiteModel.getId())); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java index e49e3b6f0..b6fb3429f 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java @@ -2,10 +2,10 @@ package org.alfresco.rest.people; 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.ErrorModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; @@ -77,7 +77,7 @@ public class DeleteSiteMemberSanityTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); restClient.withCoreAPI().usingUser(newUser).deleteSiteMember(siteModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(String.format(ErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getId())); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getId())); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -92,7 +92,7 @@ public class DeleteSiteMemberSanityTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); restClient.withCoreAPI().usingUser(newUser).deleteSiteMember(siteModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(String.format(ErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getId())); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getId())); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -107,7 +107,7 @@ public class DeleteSiteMemberSanityTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); restClient.withCoreAPI().usingUser(newUser).deleteSiteMember(siteModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(String.format(ErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getId())); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getId())); } @Bug(id="MNT-16904") diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java index bf7c89503..4a95680dd 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java @@ -2,6 +2,7 @@ package org.alfresco.rest.people; 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.data.RandomData; @@ -100,7 +101,7 @@ public class DeleteSiteMembershipRequestSanityTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) .withCoreAPI() .usingAuthUser().deleteSiteMembershipRequest(siteModel); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } @Bug(id="MNT-16916") @@ -118,7 +119,7 @@ public class DeleteSiteMembershipRequestSanityTests extends RestTest .withCoreAPI() .usingAuthUser().deleteSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } @Bug(id="MNT-16916") @@ -135,7 +136,7 @@ public class DeleteSiteMembershipRequestSanityTests extends RestTest .withCoreAPI() .usingAuthUser().deleteSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } @Bug(id="MNT-16916") @@ -152,7 +153,7 @@ public class DeleteSiteMembershipRequestSanityTests extends RestTest .withCoreAPI() .usingAuthUser().deleteSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } @Bug(id = "MNT-16904") diff --git a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteCoreTests.java b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteCoreTests.java index 26001e020..022995862 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteCoreTests.java @@ -1,8 +1,8 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.data.DataUser; -import org.alfresco.utility.model.ErrorModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; @@ -39,7 +39,7 @@ public class GetFavoriteSiteCoreTests extends RestTest restClient.authenticateUser(userModel).withCoreAPI().usingUser(someUser).getFavoriteSite(site1); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, "someUser")); + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "someUser")); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -51,7 +51,7 @@ public class GetFavoriteSiteCoreTests extends RestTest restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().getFavoriteSite(nonExistentSite); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(ErrorModel.RELATIONSHIP_NOT_FOUND, userModel.getUsername(), nonExistentSite.getId())); + .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, userModel.getUsername(), nonExistentSite.getId())); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -61,6 +61,6 @@ public class GetFavoriteSiteCoreTests extends RestTest { restClient.authenticateUser(userModel).withCoreAPI().usingUser(dataUser.getAdminUser()).getFavoriteSite(site1); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } } diff --git a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java index 61f379312..e344d3caa 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java @@ -1,6 +1,7 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestSiteModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.model.*; @@ -120,7 +121,7 @@ public class GetFavoriteSiteSanityTests extends RestTest dataSite.usingUser(managerUser).usingSite(siteModel2).addSiteToFavorites(); restClient.authenticateUser(managerUser).withCoreAPI().usingUser(userModel).getFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } @Bug(id = "MNT-16904") diff --git a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java index eebc052c3..565a50673 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java @@ -1,6 +1,7 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestSiteModelsCollection; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.model.*; @@ -37,7 +38,7 @@ public class GetFavoriteSitesSanityTests extends RestTest dataSite.usingUser(anotherUser).usingSite(siteModel).addSiteToFavorites(); restClient.authenticateUser(managerUser).withCoreAPI().usingUser(anotherUser).getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -52,7 +53,7 @@ public class GetFavoriteSitesSanityTests extends RestTest dataSite.usingUser(contributorUser).usingSite(siteModel).addSiteToFavorites(); restClient.authenticateUser(collaboratorUser).withCoreAPI().usingUser(contributorUser).getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -67,7 +68,7 @@ public class GetFavoriteSitesSanityTests extends RestTest dataSite.usingUser(contributorUser2).usingSite(siteModel).addSiteToFavorites(); restClient.authenticateUser(contributorUser).withCoreAPI().usingUser(contributorUser2).getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -82,7 +83,7 @@ public class GetFavoriteSitesSanityTests extends RestTest dataSite.usingUser(collaboratorUser).usingSite(siteModel).addSiteToFavorites(); restClient.authenticateUser(consumerUser).withCoreAPI().usingUser(collaboratorUser).getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java index 75d00db68..6825474ee 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java @@ -3,6 +3,7 @@ package org.alfresco.rest.people; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestActivityModelsCollection; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.model.*; @@ -110,6 +111,6 @@ public class GetPeopleActivitiesSanityTests extends RestTest public void unauthenticatedUserShouldNotGetPeopleActivitiesList() throws Exception { restClient.authenticateUser(unauthenticatedUser).withCoreAPI().usingUser(userModel).getPersonActivities(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(ErrorModel.AUTHENTICATION_FAILED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } } diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleSanityTests.java index eda1a1526..cf34bfe4c 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleSanityTests.java @@ -1,10 +1,10 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestPersonModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; -import org.alfresco.utility.model.ErrorModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; @@ -139,6 +139,6 @@ public class GetPeopleSanityTests extends RestTest .withCoreAPI() .usingUser(searchedNonUser) .getPerson(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, "")); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipCoreTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipCoreTests.java index ff6078938..7303d4066 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipCoreTests.java @@ -1,10 +1,10 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestSiteEntry; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; -import org.alfresco.utility.model.ErrorModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; @@ -67,7 +67,7 @@ public class GetSiteMembershipCoreTests extends RestTest restClient.authenticateUser(regularUser).withCoreAPI().usingUser(someUser).getSiteMembership(publicSite); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, "someUser")); + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "someUser")); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -79,7 +79,7 @@ public class GetSiteMembershipCoreTests extends RestTest restClient.authenticateUser(regularUser).withCoreAPI().usingAuthUser().getSiteMembership(someSite); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(ErrorModel.RELATIONSHIP_NOT_FOUND, regularUser.getUsername(), "someSite")); + .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, regularUser.getUsername(), "someSite")); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -90,7 +90,7 @@ public class GetSiteMembershipCoreTests extends RestTest restClient.authenticateUser(publicSiteManager).withCoreAPI() .usingUser(regularUser).getSiteMembership(publicSite); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(ErrorModel.RELATIONSHIP_NOT_FOUND, regularUser.getUsername(), publicSite.getTitle())); + .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, regularUser.getUsername(), publicSite.getTitle())); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -101,7 +101,7 @@ public class GetSiteMembershipCoreTests extends RestTest restClient.authenticateUser(regularUser).withCoreAPI() .usingUser(privateSiteManager).getSiteMembership(privateSite); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(ErrorModel.RELATIONSHIP_NOT_FOUND, privateSiteManager.getUsername(), privateSite.getTitle())); + .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, privateSiteManager.getUsername(), privateSite.getTitle())); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -154,6 +154,6 @@ public class GetSiteMembershipCoreTests extends RestTest restClient.authenticateUser(publicSiteManager).withCoreAPI() .usingUser(publicSiteConsumer).getSiteMembership(publicSite); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(ErrorModel.RELATIONSHIP_NOT_FOUND, publicSiteConsumer.getUsername(), publicSite.getTitle())); + .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, publicSiteConsumer.getUsername(), publicSite.getTitle())); } } diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestCoreTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestCoreTests.java index b5d4100b6..dfc80a7c7 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestCoreTests.java @@ -1,8 +1,8 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.model.ErrorModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; @@ -100,7 +100,7 @@ public class GetSiteMembershipRequestCoreTests extends RestTest .withCoreAPI() .usingUser(UserModel.getRandomUserModel()).getSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, "")); + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -113,7 +113,7 @@ public class GetSiteMembershipRequestCoreTests extends RestTest .withCoreAPI() .usingMe().getSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(ErrorModel.RELATIONSHIP_NOT_FOUND, noRequestUser.getUsername(), siteModel.getId())); + .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, noRequestUser.getUsername(), siteModel.getId())); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -130,7 +130,7 @@ public class GetSiteMembershipRequestCoreTests extends RestTest .withCoreAPI() .usingUser(publicUser).getSiteMembershipRequest(publicSite); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(ErrorModel.RELATIONSHIP_NOT_FOUND, publicUser.getUsername(), publicSite.getId())); + .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, publicUser.getUsername(), publicSite.getId())); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -147,7 +147,7 @@ public class GetSiteMembershipRequestCoreTests extends RestTest .withCoreAPI() .usingUser(privateUser).getSiteMembershipRequest(privateSite); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(ErrorModel.RELATIONSHIP_NOT_FOUND, privateUser.getUsername(), privateSite.getId())); + .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, privateUser.getUsername(), privateSite.getId())); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -160,6 +160,6 @@ public class GetSiteMembershipRequestCoreTests extends RestTest .withCoreAPI() .usingMe().getSiteMembershipRequest(inexistentSite); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(ErrorModel.RELATIONSHIP_NOT_FOUND, userModel.getUsername(), inexistentSite.getId())); + .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, userModel.getUsername(), inexistentSite.getId())); } } diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java index 6a59261db..f8b807fe8 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java @@ -1,9 +1,9 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.ErrorModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; diff --git a/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestSanityTests.java index 84133c073..b5cba7f2a 100644 --- a/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestSanityTests.java @@ -2,13 +2,13 @@ package org.alfresco.rest.people; 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.DataSite; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.data.RandomData; import org.alfresco.utility.exception.DataPreparationException; -import org.alfresco.utility.model.ErrorModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; @@ -80,7 +80,7 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest .usingUser(newMember).updateSiteMembershipRequest(siteModel, updatedMessage); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -101,7 +101,7 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest .updateSiteMembershipRequest(siteModel, updatedMessage); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -120,7 +120,7 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest .usingUser(newMember).updateSiteMembershipRequest(siteModel, updatedMessage); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -141,7 +141,7 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest .updateSiteMembershipRequest(siteModel, updatedMessage); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -163,7 +163,7 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest .updateSiteMembershipRequest(siteModel, updatedMessage); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -184,6 +184,6 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest .updateSiteMembershipRequest(siteModel, updatedMessage); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/ratings/AddRatingCoreTests.java b/e2e-test/java/org/alfresco/rest/ratings/AddRatingCoreTests.java index fe2a5e1c7..408e5f140 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/AddRatingCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/AddRatingCoreTests.java @@ -3,12 +3,12 @@ package org.alfresco.rest.ratings; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestCommentModel; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestRatingModel; import org.alfresco.rest.model.RestTagModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.exception.DataPreparationException; -import org.alfresco.utility.model.ErrorModel; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.LinkModel; @@ -58,7 +58,7 @@ public class AddRatingCoreTests extends RestTest public void unknownRatingSchemeReturnsBadRequest() throws Exception { restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"invalidRate\"}"); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(ErrorModel.INVALID_RATING, "invalidRate")); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_RATING, "invalidRate")); } @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, @@ -67,7 +67,7 @@ public class AddRatingCoreTests extends RestTest { document.setNodeRef(RandomStringUtils.randomAlphanumeric(10)); restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, document.getNodeRef())); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, document.getNodeRef())); } @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, @@ -162,7 +162,7 @@ public class AddRatingCoreTests extends RestTest public void addRateUsingEmptyRatingObject() throws Exception { restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating(""); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(ErrorModel.NO_CONTENT, + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.NO_CONTENT, "No content to map to Object due to end of input")); } @@ -171,7 +171,7 @@ public class AddRatingCoreTests extends RestTest public void addRateUsingEmptyValueForId() throws Exception { restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"\"}"); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(ErrorModel.NO_CONTENT, + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.NO_CONTENT, "N/A (through reference chain: org.alfresco.rest.api.model.NodeRating[\"id\"])")); } @@ -180,10 +180,10 @@ public class AddRatingCoreTests extends RestTest public void addRateUsingEmptyValueForMyRating() throws Exception { restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"likes\", \"myRating\":\"\"}"); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(ErrorModel.NULL_LIKE_RATING)); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.NULL_LIKE_RATING)); restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"fiveStar\", \"myRating\":\"\"}"); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(ErrorModel.NULL_FIVESTAR_RATING)); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.NULL_FIVESTAR_RATING)); } @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, @@ -194,10 +194,10 @@ public class AddRatingCoreTests extends RestTest document.setNodeRef(comment.getId()); restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(String.format(ErrorModel.CANNOT_RATE)); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(String.format(RestErrorModel.CANNOT_RATE)); restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).rateStarsToDocument(5); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(String.format(ErrorModel.CANNOT_RATE)); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(String.format(RestErrorModel.CANNOT_RATE)); } @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, @@ -208,10 +208,10 @@ public class AddRatingCoreTests extends RestTest document.setNodeRef(tag.getId()); restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(String.format(ErrorModel.CANNOT_RATE)); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(String.format(RestErrorModel.CANNOT_RATE)); restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).rateStarsToDocument(5); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(String.format(ErrorModel.CANNOT_RATE)); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(String.format(RestErrorModel.CANNOT_RATE)); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingCoreTests.java b/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingCoreTests.java index 3596747d6..313bde263 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingCoreTests.java @@ -2,11 +2,11 @@ package org.alfresco.rest.ratings; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestRatingModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.exception.DataPreparationException; -import org.alfresco.utility.model.ErrorModel; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; @@ -52,7 +52,7 @@ public class DeleteRatingCoreTests extends RestTest public void deleteInvalidRating() throws Exception { restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).deleteInvalidRating("random_rating"); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(ErrorModel.INVALID_RATING, "random_rating")); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_RATING, "random_rating")); } @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, @@ -61,7 +61,7 @@ public class DeleteRatingCoreTests extends RestTest { document.setNodeRef("random_value"); restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).deleteLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, "random_value")); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "random_value")); } @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, diff --git a/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java index 1529d25f5..4b6a744b2 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java @@ -2,11 +2,11 @@ package org.alfresco.rest.ratings; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestRatingModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.exception.DataPreparationException; -import org.alfresco.utility.model.ErrorModel; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; @@ -150,9 +150,9 @@ public class GetRatingSanityTests extends RestTest restClient.authenticateUser(new UserModel("random user", "random password")); restClient.withCoreAPI().usingResource(document).getLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(ErrorModel.AUTHENTICATION_FAILED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); restClient.withCoreAPI().usingResource(document).getFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(ErrorModel.AUTHENTICATION_FAILED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/ratings/GetRatingsCoreTests.java b/e2e-test/java/org/alfresco/rest/ratings/GetRatingsCoreTests.java index b41e2c7fa..93f924e67 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/GetRatingsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/GetRatingsCoreTests.java @@ -2,9 +2,9 @@ package org.alfresco.rest.ratings; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestRatingModel; import org.alfresco.utility.exception.DataPreparationException; -import org.alfresco.utility.model.ErrorModel; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; @@ -66,7 +66,7 @@ public class GetRatingsCoreTests extends RestTest { .likeDocument(); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, document.getNodeRef())); + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, document.getNodeRef())); } @TestRail(section = { TestGroup.REST_API, diff --git a/e2e-test/java/org/alfresco/rest/ratings/GetRatingsSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/GetRatingsSanityTests.java index 52c90455e..5bf4b1127 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/GetRatingsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/GetRatingsSanityTests.java @@ -2,11 +2,11 @@ package org.alfresco.rest.ratings; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestRatingModelsCollection; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.exception.DataPreparationException; -import org.alfresco.utility.model.ErrorModel; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; @@ -129,6 +129,6 @@ public class GetRatingsSanityTests extends RestTest restClient.authenticateUser(new UserModel("random user", "random password")); restClient.withCoreAPI().usingResource(document).getRatings(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(ErrorModel.AUTHENTICATION_FAILED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteCoreTests.java index abebddf95..206dc6e72 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteCoreTests.java @@ -2,10 +2,10 @@ package org.alfresco.rest.sites; import org.alfresco.rest.RestTest; import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestSiteModel; import org.alfresco.rest.model.RestSiteModelsCollection; import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.model.ErrorModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; @@ -44,7 +44,7 @@ public class GetSiteCoreTests extends RestTest restClient.authenticateUser(userModel).withCoreAPI() .usingSite("NonExistentSiteId").getSite(); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, "NonExistentSiteId")); + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "NonExistentSiteId")); } @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, @@ -107,7 +107,7 @@ public class GetSiteCoreTests extends RestTest restSiteModel = restClient.authenticateUser(userModel).withCoreAPI() .usingSite(privateSite).getSite(); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, privateSite.getTitle())); + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, privateSite.getTitle())); } } diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberCoreTests.java index c221fe7f2..4ad48b49d 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberCoreTests.java @@ -1,10 +1,10 @@ package org.alfresco.rest.sites; import org.alfresco.rest.RestTest; +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.ErrorModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; @@ -51,7 +51,7 @@ public class GetSiteMemberCoreTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); restClient.withCoreAPI().usingSite(invalidSite).getSiteMember(consumer); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(ErrorModel.RELATIONSHIP_NOT_FOUND, consumer.getUsername(), invalidSite.getId())); + .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, consumer.getUsername(), invalidSite.getId())); } @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, @@ -63,7 +63,7 @@ public class GetSiteMemberCoreTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); restClient.withCoreAPI().usingSite(siteModel).getSiteMember(nonMember); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(ErrorModel.RELATIONSHIP_NOT_FOUND, nonMember.getUsername(), siteModel.getId())); + .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, nonMember.getUsername(), siteModel.getId())); } @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, @@ -75,7 +75,7 @@ public class GetSiteMemberCoreTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); restClient.withCoreAPI().usingSite(siteModel).getSiteMember(inexistentUser); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, inexistentUser.getUsername())); + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, inexistentUser.getUsername())); } @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, @@ -102,7 +102,7 @@ public class GetSiteMemberCoreTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); restClient.withCoreAPI().usingSite(emptySite).getSiteMember(consumer); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(ErrorModel.RELATIONSHIP_NOT_FOUND, consumer.getUsername(), emptySite.getId())); + .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, consumer.getUsername(), emptySite.getId())); } @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersCoreTests.java index f6737a795..53318f7c5 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersCoreTests.java @@ -1,9 +1,9 @@ package org.alfresco.rest.sites; import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestSiteMemberModelsCollection; import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.model.ErrorModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; @@ -47,7 +47,7 @@ public class GetSiteMembersCoreTests extends RestTest restClient.authenticateUser(publicSiteContributor).withCoreAPI() .usingSite("NonExistentSiteId").getSiteMembers(); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, "NonExistentSiteId")); + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "NonExistentSiteId")); } @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, @@ -113,7 +113,7 @@ public class GetSiteMembersCoreTests extends RestTest restClient.authenticateUser(userModel).withCoreAPI() .usingSite(privateSite).getSiteMembers(); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, privateSite.getTitle())); + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, privateSite.getTitle())); } @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java index c9f3d59f1..7c119c1d8 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java @@ -1,11 +1,11 @@ package org.alfresco.rest.sites; import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestSiteModel; import org.alfresco.rest.model.RestSiteModelsCollection; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.ErrorModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; diff --git a/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberCoreTests.java index 4ce75655d..936cd2625 100644 --- a/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberCoreTests.java @@ -1,10 +1,10 @@ package org.alfresco.rest.sites; import org.alfresco.rest.RestTest; +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.ErrorModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; @@ -44,7 +44,7 @@ public class RemoveSiteMemberCoreTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); restClient.withCoreAPI().usingSite(siteModel).deleteSiteMember(inexistentUser); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, inexistentUser.getUsername())); + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, inexistentUser.getUsername())); } @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, @@ -56,7 +56,7 @@ public class RemoveSiteMemberCoreTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); restClient.withCoreAPI().usingSite(siteModel).deleteSiteMember(nonMember); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(ErrorModel.INVALID_ARGUMENT, "argument")); + .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_ARGUMENT, "argument")); } @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, @@ -70,7 +70,7 @@ public class RemoveSiteMemberCoreTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); restClient.withCoreAPI().usingSite(invalidSite).deleteSiteMember(testUserModel); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(ErrorModel.RELATIONSHIP_NOT_FOUND, testUserModel.getUsername(), invalidSite.getId())); + .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, testUserModel.getUsername(), invalidSite.getId())); } @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, @@ -114,7 +114,7 @@ public class RemoveSiteMemberCoreTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); restClient.withCoreAPI().usingSite(siteModel).deleteSiteMember(managerForDelete); restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY) - .assertLastError().containsSummary(String.format(ErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getId())); + .assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getId())); } @@ -128,7 +128,7 @@ public class RemoveSiteMemberCoreTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); restClient.withCoreAPI().usingSite(siteModel).deleteSiteMember(managerForDelete); restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY) - .assertLastError().containsSummary(String.format(ErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getId())); + .assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getId())); } @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, @@ -141,7 +141,7 @@ public class RemoveSiteMemberCoreTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); restClient.withCoreAPI().usingSite(siteModel).deleteSiteMember(managerForDelete); restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY) - .assertLastError().containsSummary(String.format(ErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getId())); + .assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getId())); } @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, @@ -154,7 +154,7 @@ public class RemoveSiteMemberCoreTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); restClient.withCoreAPI().usingSite(siteModel).deleteSiteMember(contributorForDelete); restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY) - .assertLastError().containsSummary(String.format(ErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getId())); + .assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getId())); } @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, @@ -167,7 +167,7 @@ public class RemoveSiteMemberCoreTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); restClient.withCoreAPI().usingSite(siteModel).deleteSiteMember(contributorForDelete); restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY) - .assertLastError().containsSummary(String.format(ErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getId())); + .assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getId())); } @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, @@ -180,7 +180,7 @@ public class RemoveSiteMemberCoreTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); restClient.withCoreAPI().usingSite(siteModel).deleteSiteMember(contributorForDelete); restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY) - .assertLastError().containsSummary(String.format(ErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getId())); + .assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getId())); } @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, @@ -208,7 +208,7 @@ public class RemoveSiteMemberCoreTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); restClient.withCoreAPI().usingSite(siteModel).deleteSiteMember(collaboratorForDelete); restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY) - .assertLastError().containsSummary(String.format(ErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getId())); + .assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getId())); } @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, @@ -221,7 +221,7 @@ public class RemoveSiteMemberCoreTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); restClient.withCoreAPI().usingSite(siteModel).deleteSiteMember(collaboratorForDelete); restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY) - .assertLastError().containsSummary(String.format(ErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getId())); + .assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getId())); } @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, @@ -234,7 +234,7 @@ public class RemoveSiteMemberCoreTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); restClient.withCoreAPI().usingSite(siteModel).deleteSiteMember(collaboratorForDelete); restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY) - .assertLastError().containsSummary(String.format(ErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getId())); + .assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getId())); } @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, diff --git a/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberCoreTests.java index b0b208f57..9c1482950 100644 --- a/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberCoreTests.java @@ -3,11 +3,11 @@ package org.alfresco.rest.sites; import org.alfresco.rest.RestTest; import org.alfresco.rest.core.JsonBodyGenerator; import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestSiteMemberModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.model.ErrorModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; @@ -54,7 +54,7 @@ public class UpdateSiteMemberCoreTests extends RestTest restClient.authenticateUser(adminUser).withCoreAPI() .usingSite(deletedSite).updateSiteMember(regularUser); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, deletedSite.getId())); + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, deletedSite.getId())); } @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, @@ -77,7 +77,7 @@ public class UpdateSiteMemberCoreTests extends RestTest restClient.authenticateUser(adminUser).withCoreAPI() .usingSite(publicSite).updateSiteMember(nonexistentUser); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, nonexistentUser.getUsername())); + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, nonexistentUser.getUsername())); } @Bug(id="REPO-1660") @@ -103,7 +103,7 @@ public class UpdateSiteMemberCoreTests extends RestTest restClient.authenticateUser(adminUser).withCoreAPI() .usingSite("").updateSiteMember(regularUser); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, "")); + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); } @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, @@ -115,7 +115,7 @@ public class UpdateSiteMemberCoreTests extends RestTest restClient.authenticateUser(adminUser).withCoreAPI() .usingSite(publicSite).updateSiteMember(emptyUser); restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) - .assertLastError().containsSummary(ErrorModel.PUT_EMPTY_ARGUMENT); + .assertLastError().containsSummary(RestErrorModel.PUT_EMPTY_ARGUMENT); } @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, @@ -128,7 +128,7 @@ public class UpdateSiteMemberCoreTests extends RestTest RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, json, "sites/{siteId}/members/{personId}", publicSite.getId(), siteConsumer.getUsername()); restClient.processModel(RestSiteMemberModel.class, request); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(ErrorModel.UNKNOWN_ROLE, "invalidRole")); + .assertLastError().containsSummary(String.format(RestErrorModel.UNKNOWN_ROLE, "invalidRole")); } @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, diff --git a/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java index fb0d65ac8..516ca3086 100644 --- a/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java @@ -3,11 +3,11 @@ package org.alfresco.rest.tags; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestTagModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.ErrorModel; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.StatusModel; @@ -89,7 +89,7 @@ public class AddTagSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); restClient.withCoreAPI().usingResource(document).addTag(tagValue); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, @@ -111,7 +111,7 @@ public class AddTagSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); restClient.withCoreAPI().usingResource(document).addTag(tagValue); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, diff --git a/e2e-test/java/org/alfresco/rest/tags/AddTagsSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/AddTagsSanityTests.java index f7a99943f..12dc8c676 100644 --- a/e2e-test/java/org/alfresco/rest/tags/AddTagsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/AddTagsSanityTests.java @@ -3,11 +3,11 @@ package org.alfresco.rest.tags; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestTagModelsCollection; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.ErrorModel; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.StatusModel; @@ -90,7 +90,7 @@ public class AddTagsSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); restClient.withCoreAPI().usingResource(document).addTags(tag1, tag2); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, @@ -111,7 +111,7 @@ public class AddTagsSanityTests extends RestTest public void consumerIsNotAbleToAddTags() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingResource(document).addTags(tag1, tag2); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, diff --git a/e2e-test/java/org/alfresco/rest/tags/DeleteTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/DeleteTagSanityTests.java index 97a23746a..c3f95419f 100644 --- a/e2e-test/java/org/alfresco/rest/tags/DeleteTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/DeleteTagSanityTests.java @@ -3,11 +3,11 @@ package org.alfresco.rest.tags; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestTagModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.ErrorModel; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.StatusModel; @@ -85,7 +85,7 @@ public class DeleteTagSanityTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); restClient.withCoreAPI().usingResource(document).deleteTag(tag); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, @@ -110,7 +110,7 @@ public class DeleteTagSanityTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); restClient.withCoreAPI().usingResource(document).deleteTag(tag); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } @Bug(id="MNT-16904") diff --git a/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java index 71767d2cf..b9147a32e 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java @@ -3,6 +3,7 @@ package org.alfresco.rest.tags; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestTagModelsCollection; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; @@ -114,6 +115,6 @@ public class GetNodeTagsSanityTests extends RestTest { restClient.authenticateUser(new UserModel("random user", "random password")); restClient.withCoreAPI().usingResource(document).getNodeTags(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(ErrorModel.AUTHENTICATION_FAILED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/tags/GetTagCoreTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagCoreTests.java index 78ce19e79..c78f81237 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetTagCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetTagCoreTests.java @@ -3,9 +3,9 @@ package org.alfresco.rest.tags; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestTagModel; import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.ErrorModel; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; @@ -47,7 +47,7 @@ public class GetTagCoreTests extends RestTest { tag.setId("random_tag_value"); restClient.withCoreAPI().getTag(tag); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, "random_tag_value")); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "random_tag_value")); } @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, diff --git a/e2e-test/java/org/alfresco/rest/tags/GetTagsCoreTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagsCoreTests.java index 54a141fdd..55c55b105 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetTagsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetTagsCoreTests.java @@ -3,12 +3,12 @@ package org.alfresco.rest.tags; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestTagModelsCollection; import org.alfresco.utility.Utility; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.ErrorModel; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; @@ -54,7 +54,7 @@ public class GetTagsCoreTests extends RestTest public void maxItemsInvalidValueTest() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel).withParams("maxItems=abc").withCoreAPI().getTags(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(ErrorModel.INVALID_MAXITEMS, "abc")); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "abc")); } @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, @@ -62,7 +62,7 @@ public class GetTagsCoreTests extends RestTest public void skipCountInvalidValueTest() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel).withParams("skipCount=abc").withCoreAPI().getTags(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(ErrorModel.INVALID_SKIPCOUNT, "abc")); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "abc")); } @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, diff --git a/e2e-test/java/org/alfresco/rest/tags/UpdateTagCoreTests.java b/e2e-test/java/org/alfresco/rest/tags/UpdateTagCoreTests.java index 454076add..1e1e31b03 100644 --- a/e2e-test/java/org/alfresco/rest/tags/UpdateTagCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/UpdateTagCoreTests.java @@ -3,12 +3,12 @@ package org.alfresco.rest.tags; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestTagModel; import org.alfresco.utility.Utility; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.ErrorModel; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; @@ -52,7 +52,7 @@ public class UpdateTagCoreTests extends RestTest tag.setId(invalidTagId); restClient.withCoreAPI().usingTag(tag).update(RandomData.getRandomName("tag")); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, invalidTagId)); + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, invalidTagId)); } @TestRail(section = { TestGroup.REST_API, @@ -63,7 +63,7 @@ public class UpdateTagCoreTests extends RestTest tag.setId(""); restClient.withCoreAPI().usingTag(tag).update(RandomData.getRandomName("tag")); restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) - .assertLastError().containsSummary(ErrorModel.PUT_EMPTY_ARGUMENT); + .assertLastError().containsSummary(RestErrorModel.PUT_EMPTY_ARGUMENT); } @TestRail(section = { TestGroup.REST_API, @@ -73,7 +73,7 @@ public class UpdateTagCoreTests extends RestTest RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); restClient.withCoreAPI().usingTag(tag).update(""); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(ErrorModel.EMPTY_TAG); + .assertLastError().containsSummary(RestErrorModel.EMPTY_TAG); } @Bug(id="ACE-5629") @@ -87,7 +87,7 @@ public class UpdateTagCoreTests extends RestTest Utility.waitToLoopTime(20); restClient.withCoreAPI().usingTag(tag).update(invalidTagBody); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(ErrorModel.INVALID_TAG, invalidTagBody)); + .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_TAG, invalidTagBody)); } @Bug(id="ACE-5629") @@ -101,6 +101,6 @@ public class UpdateTagCoreTests extends RestTest Utility.waitToLoopTime(20); restClient.withCoreAPI().usingTag(tag).update(invalidTagBody); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(ErrorModel.INVALID_TAG, invalidTagBody)); + .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_TAG, invalidTagBody)); } } diff --git a/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java index be11c0477..a3d5b92ec 100644 --- a/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java @@ -3,11 +3,11 @@ package org.alfresco.rest.tags; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestTagModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.ErrorModel; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; @@ -67,7 +67,7 @@ public class UpdateTagSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); restClient.withCoreAPI().usingTag(oldTag).update(randomTag); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, @@ -76,7 +76,7 @@ public class UpdateTagSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); restClient.withCoreAPI().usingTag(oldTag).update(randomTag); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, @@ -85,7 +85,7 @@ public class UpdateTagSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); restClient.withCoreAPI().usingTag(oldTag).update(randomTag); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, @@ -94,7 +94,7 @@ public class UpdateTagSanityTests extends RestTest { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); restClient.withCoreAPI().usingTag(oldTag).update(randomTag); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, @@ -107,6 +107,6 @@ public class UpdateTagSanityTests extends RestTest restClient.authenticateUser(siteManager); restClient.withCoreAPI().usingTag(oldTag).update(randomTag); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError().containsSummary(ErrorModel.AUTHENTICATION_FAILED); + .assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java index 48fa98492..ad0e5843b 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java @@ -3,7 +3,7 @@ package org.alfresco.rest.workflow.deployments; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestDeploymentModel; import org.alfresco.rest.model.RestDeploymentModelsCollection; -import org.alfresco.utility.model.ErrorModel; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; @@ -58,6 +58,6 @@ public class DeleteDeploymentSanityTests extends RestTest restClient.withWorkflowAPI().usingDeployment(deployment).deleteDeployment(); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, "1000")); + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "1000")); } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentSanityTests.java index 907bc7361..d25584515 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentSanityTests.java @@ -3,7 +3,7 @@ package org.alfresco.rest.workflow.deployments; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestDeploymentModel; -import org.alfresco.utility.model.ErrorModel; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; @@ -51,6 +51,6 @@ public class GetDeploymentSanityTests extends RestTest { restClient.authenticateUser(anotherUser).withWorkflowAPI().usingDeployment(expectedDeployment).getDeployment(); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableSanityTests.java index 9d1499248..f34837ce1 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableSanityTests.java @@ -2,6 +2,7 @@ package org.alfresco.rest.workflow.processes; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.rest.model.RestProcessVariableModel; import org.alfresco.utility.model.*; @@ -59,6 +60,6 @@ public class DeleteProcessVariableSanityTests extends RestTest processModel.setId("incorrectProcessId"); restClient.withWorkflowAPI().usingProcess(processModel).deleteProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, "incorrectProcessId")); + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "incorrectProcessId")); } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/UpdateProcessVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/UpdateProcessVariableSanityTests.java index 782d61aa9..af64af9f6 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/UpdateProcessVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/UpdateProcessVariableSanityTests.java @@ -3,6 +3,7 @@ package org.alfresco.rest.workflow.processes; import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.rest.model.RestProcessVariableCollection; import org.alfresco.rest.model.RestProcessVariableModel; @@ -73,6 +74,6 @@ public class UpdateProcessVariableSanityTests extends RestTest processModel.setId("abc"); restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, "abc")); + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "abc")); } } From b6af139a911cf10c52d281c1f83768f5bc547478 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Mon, 5 Dec 2016 15:09:18 +0200 Subject: [PATCH 0653/1491] fix: remove unused imports --- .../org/alfresco/rest/comments/AddCommentsSanityTests.java | 1 - .../org/alfresco/rest/people/GetFavoriteSiteCoreTests.java | 1 - .../alfresco/rest/people/GetPeopleActivitiesSanityTests.java | 5 +++-- .../rest/people/GetSiteMembershipRequestsSanityTests.java | 1 - .../org/alfresco/rest/ratings/GetRatingsSanityTests.java | 1 - e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java | 5 ++--- e2e-test/java/org/alfresco/rest/tags/GetTagsCoreTests.java | 2 -- e2e-test/java/org/alfresco/rest/tags/UpdateTagCoreTests.java | 2 ++ 8 files changed, 7 insertions(+), 11 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java index ae50540e0..2debbf53f 100644 --- a/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java @@ -11,7 +11,6 @@ import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; diff --git a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteCoreTests.java b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteCoreTests.java index 022995862..ce8af1b22 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteCoreTests.java @@ -6,7 +6,6 @@ import org.alfresco.utility.data.DataUser; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java index 6825474ee..e7035b153 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java @@ -6,8 +6,9 @@ import org.alfresco.rest.model.RestActivityModelsCollection; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; -import org.alfresco.utility.model.*; -import org.alfresco.utility.report.Bug; +import org.alfresco.utility.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; diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java index f8b807fe8..f338ec1d8 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java @@ -1,7 +1,6 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.RandomData; import org.alfresco.utility.model.SiteModel; diff --git a/e2e-test/java/org/alfresco/rest/ratings/GetRatingsSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/GetRatingsSanityTests.java index 5bf4b1127..97f1e8d30 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/GetRatingsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/GetRatingsSanityTests.java @@ -12,7 +12,6 @@ import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java index 7c119c1d8..bb52a0bdf 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java @@ -1,7 +1,8 @@ package org.alfresco.rest.sites; +import java.util.List; + import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestSiteModel; import org.alfresco.rest.model.RestSiteModelsCollection; import org.alfresco.utility.constants.UserRole; @@ -17,8 +18,6 @@ import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import java.util.List; - /** * Created by Claudia Agache on 11/22/2016. */ diff --git a/e2e-test/java/org/alfresco/rest/tags/GetTagsCoreTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagsCoreTests.java index 55c55b105..d2123813f 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetTagsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetTagsCoreTests.java @@ -6,8 +6,6 @@ import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestTagModelsCollection; import org.alfresco.utility.Utility; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.data.RandomData; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FolderModel; diff --git a/e2e-test/java/org/alfresco/rest/tags/UpdateTagCoreTests.java b/e2e-test/java/org/alfresco/rest/tags/UpdateTagCoreTests.java index 1e1e31b03..a0353bd71 100644 --- a/e2e-test/java/org/alfresco/rest/tags/UpdateTagCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/UpdateTagCoreTests.java @@ -29,7 +29,9 @@ public class UpdateTagCoreTests extends RestTest private UserModel managerUser; private FileModel document; private SiteModel siteModel; + @SuppressWarnings("unused") private DataUser.ListUserWithRoles usersWithRoles; + @SuppressWarnings("unused") private RestTagModel oldTag; @BeforeClass(alwaysRun=true) From 9c7aa40edc2efa5d353a87dff586a9906d58e26c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alecsandru=20Prun=C4=83?= Date: Mon, 5 Dec 2016 15:10:40 +0200 Subject: [PATCH 0654/1491] test: TAS-2029 Added AddSiteMembershipRequestCoreTests --- .../AddSiteMembershipRequestCoreTests.java | 97 +++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestCoreTests.java b/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestCoreTests.java new file mode 100644 index 000000000..f27718f90 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestCoreTests.java @@ -0,0 +1,97 @@ +package org.alfresco.rest.people; + +import org.alfresco.rest.RestTest; +import org.alfresco.utility.constants.UserRole; +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.BeforeMethod; +import org.testng.annotations.Test; + +@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) +public class AddSiteMembershipRequestCoreTests extends RestTest +{ + private UserModel adminUser; + private UserModel newMember; + private SiteModel siteModel; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws DataPreparationException + { + adminUser = dataUser.getAdminUser(); + siteModel = dataSite.usingUser(adminUser).createModeratedRandomSite(); + } + + @BeforeMethod + public void setUp() throws DataPreparationException + { + newMember = dataUser.createRandomTestUser(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify addSiteMembershipRequest Rest API status code is 400 for a user that has already been invited") + public void addSiteMembershipRequestStatusCodeIs400ReceivedForAUserThatIsAlreadyInvited() throws Exception + { + dataUser.addUserToSite(newMember, siteModel, UserRole.SiteContributor); + restClient.authenticateUser(newMember) + .withCoreAPI() + .usingMe() + .addSiteMembershipRequest(siteModel); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify addSiteMembershipRequest Rest API status code is 404 for a user that does not exist") + public void addSiteMembershipRequestStatusCodeIs404ReceivedForAUserThatDoesNotExist() throws Exception + { + restClient.authenticateUser(newMember) + .withCoreAPI() + .usingUser(new UserModel("invalidUser", "password")).addSiteMembershipRequest(siteModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify addSiteMembershipRequest Rest API status code is 404 for a site that does not exist") + public void addSiteMembershipRequestStatusCodeIs404ReceivedForASiteThatDoesNotExist() throws Exception + { + restClient.authenticateUser(newMember) + .withCoreAPI() + .usingMe().addSiteMembershipRequest(new SiteModel("invalidSiteID")); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify addSiteMembershipRequest Rest API status code is 400 for empty request body") + public void addSiteMembershipRequestStatusCodeIs400ForEmptyRequestBody() throws Exception + { + restClient.authenticateUser(newMember) + .withCoreAPI() + .usingMe().addSiteMembershipRequest(""); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify addSiteMembershipRequest Rest API status code is 201 for request with empty message") + public void addSiteMembershipRequestStatusCodeIs201ForRequestWithEmptyMessage() throws Exception + { + restClient.authenticateUser(newMember) + .withCoreAPI() + .usingMe().addSiteMembershipRequest("", siteModel, "New request"); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify addSiteMembershipRequest Rest API status code is 201 for request with empty title") + public void addSiteMembershipRequestStatusCodeIs201ForRequestWithEmptyTitle() throws Exception + { + restClient.authenticateUser(newMember) + .withCoreAPI() + .usingMe().addSiteMembershipRequest("Please accept me", siteModel, ""); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + } +} From 07b329c9ba8b0fef35825002e5e035d13c373b9d Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Mon, 5 Dec 2016 15:39:22 +0200 Subject: [PATCH 0655/1491] CORE-REST API: addTag (post /nodes/{nodeId}/tags) --- .../alfresco/rest/tags/AddTagCoreTests.java | 150 ++++++++++++++++++ 1 file changed, 150 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/tags/AddTagCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/tags/AddTagCoreTests.java b/e2e-test/java/org/alfresco/rest/tags/AddTagCoreTests.java new file mode 100644 index 000000000..dc3c9806f --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/tags/AddTagCoreTests.java @@ -0,0 +1,150 @@ +package org.alfresco.rest.tags; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestTagModel; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.data.RandomData; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.apache.commons.lang.RandomStringUtils; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) +public class AddTagCoreTests extends RestTest +{ + private UserModel adminUserModel; + private UserModel testUser; + private FileModel document; + private SiteModel siteModel; + private ListUserWithRoles usersWithRoles; + private String tagValue; + private RestTagModel returnedModel; + private FolderModel folderModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + testUser = dataUser.createRandomTestUser(); + adminUserModel = dataUser.getAdminUser(); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); + } + + @BeforeMethod(alwaysRun = true) + public void generateRandomTag() + { + tagValue = RandomData.getRandomName("tag"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that adding empty tag returns status code 400") + public void emptyTagTest() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel); + returnedModel = restClient.withCoreAPI().usingResource(document).addTag(""); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.NULL_ARGUMENT, "tag")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that adding tag with user that has no permissions returns status code 403") + public void addTagWithUserThatDoesNotHavePermissions() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(testUser); + returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that adding tag to a node that does not exist returns status code 404") + public void addTagToInexistentNode() throws JsonToModelConversionException, Exception + { + FileModel document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + + String nodeRef = RandomStringUtils.randomAlphanumeric(10); + document.setNodeRef(nodeRef); + + restClient.authenticateUser(adminUserModel); + returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, nodeRef)); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that adding tag to a node that does not accepts tags returns status code 405") + public void addTagToANodeThatDoesNotAcceptsTags() throws JsonToModelConversionException, Exception + { + FileModel document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(adminUserModel); + returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue); + document.setNodeRef(returnedModel.getId()); + restClient.withCoreAPI().usingResource(document).addTag(tagValue); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.CANNOT_TAG); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that manager is able to tag a file") + public void managerIsAbleToTagAFile() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedModel.assertThat().field("tag").is(tagValue).and().field("id").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that manager is able to tag a folder") + public void managerIsAbleToTagAFolder() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + returnedModel = restClient.withCoreAPI().usingResource(folderModel).addTag(tagValue); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedModel.assertThat().field("tag").is(tagValue).and().field("id").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that tagged file can be tagged again") + public void addTagToATaggedFile() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel); + + returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedModel.assertThat().field("tag").is(tagValue).and().field("id").isNotEmpty(); + + returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedModel.assertThat().field("tag").is(tagValue).and().field("id").isNotEmpty(); + + returnedModel = restClient.withCoreAPI().usingResource(document).addTag("random_tag_value"); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedModel.assertThat().field("tag").is("random_tag_value").and().field("id").isNotEmpty(); + + restClient.withCoreAPI().usingResource(document).getNodeTags().assertThat() + .entriesListContains("tag", tagValue.toLowerCase()) + .and().entriesListContains("tag", "random_tag_value"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that user cannot add invalid tag") + public void addInvalidTag() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel); + returnedModel = restClient.withCoreAPI().usingResource(document).addTag("-1~!|@#$%^&*()_="); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_TAG, "|")); + } +} \ No newline at end of file From aa435541b864563e5629e45379e06a6458890e6d Mon Sep 17 00:00:00 2001 From: cagache Date: Mon, 5 Dec 2016 16:26:46 +0200 Subject: [PATCH 0656/1491] test: removed variable declaration, changed ErrorModel with RestErrorModel, assertStatusCodeIs first --- .../UpdateSiteMembershipRequestCoreTests.java | 41 ++++++++----------- 1 file changed, 17 insertions(+), 24 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestCoreTests.java b/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestCoreTests.java index 6ac58271e..ce43b7789 100644 --- a/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestCoreTests.java @@ -1,16 +1,14 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; -import org.alfresco.utility.data.DataSite; -import org.alfresco.utility.data.DataUser; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestSiteMembershipRequestModel; import org.alfresco.utility.exception.DataPreparationException; -import org.alfresco.utility.model.ErrorModel; 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.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.Assert; import org.testng.annotations.BeforeClass; @@ -19,15 +17,10 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) public class UpdateSiteMembershipRequestCoreTests extends RestTest { - @Autowired - DataUser dataUser; - - @Autowired - DataSite dataSite; - private SiteModel siteModel; private UserModel managerUser; private String updatedMessage; + private RestSiteMembershipRequestModel returnedResponse; @BeforeClass(alwaysRun=true) public void dataPreparation() throws DataPreparationException @@ -50,7 +43,7 @@ public class UpdateSiteMembershipRequestCoreTests extends RestTest restClient.withCoreAPI() .usingUser(newMember).updateSiteMembershipRequest(siteModel, updatedMessage); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError().containsSummary(ErrorModel.AUTHENTICATION_FAILED); + .assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -62,11 +55,11 @@ public class UpdateSiteMembershipRequestCoreTests extends RestTest .withCoreAPI() .usingAuthUser() .addSiteMembershipRequest(siteModel); - restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(siteModel, updatedMessage) - .assertMembershipRequestMessageIs(updatedMessage) + returnedResponse = restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(siteModel, updatedMessage); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedResponse.assertMembershipRequestMessageIs(updatedMessage) .and().field("id").is(siteModel.getId()) .and().field("modifiedAt").isNotEmpty(); - restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -78,7 +71,7 @@ public class UpdateSiteMembershipRequestCoreTests extends RestTest .withCoreAPI().usingUser(inexistentUser) .updateSiteMembershipRequest(siteModel, updatedMessage); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, inexistentUser.getUsername())); + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, inexistentUser.getUsername())); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -91,7 +84,7 @@ public class UpdateSiteMembershipRequestCoreTests extends RestTest .usingMe() .updateSiteMembershipRequest(randomSite, updatedMessage); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(ErrorModel.RELATIONSHIP_NOT_FOUND, newMember.getUsername(), randomSite.getId())); + .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, newMember.getUsername(), randomSite.getId())); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -106,7 +99,7 @@ public class UpdateSiteMembershipRequestCoreTests extends RestTest .addSiteMembershipRequest(publicSite); restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(publicSite, updatedMessage); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(ErrorModel.RELATIONSHIP_NOT_FOUND, newMember.getUsername(), publicSite.getId())); + .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, newMember.getUsername(), publicSite.getId())); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -122,7 +115,7 @@ public class UpdateSiteMembershipRequestCoreTests extends RestTest restClient.withCoreAPI().usingMe() .updateSiteMembershipRequest(privateSite, updatedMessage); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(ErrorModel.RELATIONSHIP_NOT_FOUND, newMember.getUsername(), privateSite.getId())); + .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, newMember.getUsername(), privateSite.getId())); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -134,11 +127,11 @@ public class UpdateSiteMembershipRequestCoreTests extends RestTest .withCoreAPI() .usingAuthUser() .addSiteMembershipRequest(siteModel, updatedMessage); - restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(siteModel, updatedMessage) - .assertMembershipRequestMessageIs(updatedMessage) + returnedResponse = restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(siteModel, updatedMessage); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedResponse.assertMembershipRequestMessageIs(updatedMessage) .and().field("id").is(siteModel.getId()) .and().field("modifiedAt").isNotEmpty(); - restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, @@ -150,11 +143,11 @@ public class UpdateSiteMembershipRequestCoreTests extends RestTest .withCoreAPI() .usingAuthUser() .addSiteMembershipRequest(siteModel, ""); - restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(siteModel, updatedMessage) - .assertMembershipRequestMessageIs(updatedMessage) + returnedResponse = restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(siteModel, updatedMessage); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedResponse.assertMembershipRequestMessageIs(updatedMessage) .and().field("id").is(siteModel.getId()) .and().field("modifiedAt").isNotEmpty(); - restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, From 6769d6c058ec9d7640912b4b7b561f418859c49d Mon Sep 17 00:00:00 2001 From: cagache Date: Mon, 5 Dec 2016 16:32:20 +0200 Subject: [PATCH 0657/1491] test: implemented get process definition core scenarios --- .../GetProcessDefinitionCoreTests.java | 80 +++++++++++++++++++ .../GetProcessDefinitionSanityTests.java | 18 ++--- 2 files changed, 86 insertions(+), 12 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionCoreTests.java new file mode 100644 index 000000000..0ee7933fb --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionCoreTests.java @@ -0,0 +1,80 @@ +package org.alfresco.rest.workflow.processDefinitions; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestProcessDefinitionModel; +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; + +/** + * Created by Claudia Agache on 12/5/2016. + */ +@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.CORE }) +public class GetProcessDefinitionCoreTests extends RestTest +{ + private UserModel adminUser, adminTenantUser; + private RestProcessDefinitionModel randomProcessDefinition, returnedProcessDefinition; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, + executionType = ExecutionType.REGRESSION, + description = "Verify if get process definition returns status code 404 when invalid processDefinitionId is used") + public void getProcessDefinitionUsingInvalidProcessDefinitionId() throws Exception + { + restClient.authenticateUser(adminUser); + randomProcessDefinition = restClient.withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry().onModel(); + randomProcessDefinition.setId("invalidID"); + + restClient.withWorkflowAPI() + .usingProcessDefinitions(randomProcessDefinition).getProcessDefinition(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidID")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, + executionType = ExecutionType.REGRESSION, + description = "Verify network admin is able to get a process definition using REST API and status code is OK (200)") + @Test(groups = { TestGroup.NETWORKS }) + public void networkAdminGetProcessDefinition() throws Exception + { + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser) + .usingTenant().createTenant(adminTenantUser); + + randomProcessDefinition = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry().onModel(); + returnedProcessDefinition = restClient.withWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinition(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedProcessDefinition.assertThat().field("name").is(randomProcessDefinition.getName()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, + executionType = ExecutionType.REGRESSION, + description = "Verify network user is able to get a process definition using REST API and status code is OK (200)") + @Test(groups = { TestGroup.NETWORKS }) + public void networkUserGetProcessDefinition() throws Exception + { + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser) + .usingTenant().createTenant(adminTenantUser); + + UserModel tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + + randomProcessDefinition = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() + .getAllProcessDefinitions().getOneRandomEntry().onModel(); + returnedProcessDefinition = restClient.authenticateUser(tenantUser).withWorkflowAPI() + .usingProcessDefinitions(randomProcessDefinition).getProcessDefinition(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedProcessDefinition.assertThat().field("name").is(randomProcessDefinition.getName()); + } + +} diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java index 1a0f6a03b..da8aaf7c0 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java @@ -2,12 +2,10 @@ package org.alfresco.rest.workflow.processDefinitions; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestProcessDefinitionModel; -import org.alfresco.utility.data.DataUser; 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.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -18,17 +16,15 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY }) public class GetProcessDefinitionSanityTests extends RestTest { - @Autowired - private DataUser dataUser; private UserModel testUser; - private RestProcessDefinitionModel randomProcessDefinition; + private RestProcessDefinitionModel randomProcessDefinition, returnedProcessDefinition; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception { testUser = dataUser.createRandomTestUser(); restClient.authenticateUser(dataUser.getAdminUser()); - randomProcessDefinition = restClient.withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry(); + randomProcessDefinition = restClient.withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry().onModel(); } @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, @@ -36,11 +32,9 @@ public class GetProcessDefinitionSanityTests extends RestTest description = "Verify Admin user gets a specific process definition for non-network deployments using REST API and status code is OK (200)") public void adminGetsProcessDefinition() throws Exception { - restClient.withWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinition(). - assertThat().field("name").is(randomProcessDefinition.onModel().getName()); - restClient.withWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinition().assertThat().field("name") - .is(randomProcessDefinition.onModel().getName()); + returnedProcessDefinition = restClient.withWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinition(); restClient.assertStatusCodeIs(HttpStatus.OK); + returnedProcessDefinition.assertThat().field("name").is(randomProcessDefinition.getName()); } @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, @@ -49,8 +43,8 @@ public class GetProcessDefinitionSanityTests extends RestTest public void anyUserGetsProcessDefinition() throws Exception { restClient.authenticateUser(testUser); - restClient.withWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinition().assertThat().field("name") - .is(randomProcessDefinition.onModel().getName()); + returnedProcessDefinition = restClient.withWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinition(); restClient.assertStatusCodeIs(HttpStatus.OK); + returnedProcessDefinition.assertThat().field("name").is(randomProcessDefinition.getName()); } } From 3f72f50a5b6b2c85ef5b4c58275387f139245901 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Mon, 5 Dec 2016 16:55:35 +0200 Subject: [PATCH 0658/1491] CORE-REST API: removeTag (delete /nodes/{nodeId}/tags/{tagId}) --- .../rest/tags/DeleteTagCoreTests.java | 104 ++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/tags/DeleteTagCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/tags/DeleteTagCoreTests.java b/e2e-test/java/org/alfresco/rest/tags/DeleteTagCoreTests.java new file mode 100644 index 000000000..fd3edb3c2 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/tags/DeleteTagCoreTests.java @@ -0,0 +1,104 @@ +package org.alfresco.rest.tags; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestTagModel; +import org.alfresco.utility.data.RandomData; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.apache.commons.lang3.RandomStringUtils; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) +public class DeleteTagCoreTests extends RestTest +{ + private UserModel adminUserModel, userModel; + private SiteModel siteModel; + private RestTagModel tag; + private FileModel document; + private FolderModel folderModel; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + adminUserModel = dataUser.getAdminUser(); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); + } + + @BeforeMethod + public void setUp() throws Exception { + restClient.authenticateUser(adminUserModel); + tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that if user has no permission to remove tag returned status code is 403") + public void deleteTagWithUserWithoutPermission() throws Exception + { + restClient.authenticateUser(userModel); + restClient.withCoreAPI().usingResource(document).deleteTag(tag); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that if node does not exist returned status code is 404") + public void deleteTagForAnInexistentNode() throws Exception + { + FileModel document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + String nodeRef = RandomStringUtils.randomAlphanumeric(10); + document.setNodeRef(nodeRef); + restClient.withCoreAPI().usingResource(document).deleteTag(tag); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, nodeRef)); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that if tag does not exist returned status code is 404") + public void deleteTagThatDoesNotExist() throws Exception + { + tag.setId("abc"); + restClient.withCoreAPI().usingResource(document).deleteTag(tag); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "abc")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that if tag id is empty returned status code is 405") + public void deleteTagWithEmptyId() throws Exception + { + tag.setId(""); + restClient.withCoreAPI().usingResource(document).deleteTag(tag); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.DELETE_EMPTY_ARGUMENT); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that file tag can be deleted") + public void deleteFileTag() throws Exception + { + restClient.withCoreAPI().usingResource(document).deleteTag(tag); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withCoreAPI().usingResource(document).getNodeTags() + .assertThat().entriesListDoesNotContain("tag", tag.getTag()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that folder tag can be deleted") + public void deleteFolderTag() throws Exception + { + tag = restClient.withCoreAPI().usingResource(folderModel).addTag(RandomData.getRandomName("tag")); + restClient.withCoreAPI().usingResource(folderModel).deleteTag(tag); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withCoreAPI().usingResource(folderModel).getNodeTags() + .assertThat().entriesListDoesNotContain("tag", tag.getTag()); + } +} \ No newline at end of file From 67f479a61c73993cd1a849422642c0a34867a332 Mon Sep 17 00:00:00 2001 From: cagache Date: Mon, 5 Dec 2016 17:25:28 +0200 Subject: [PATCH 0659/1491] bug: fix title --- .../rest/people/UpdateSiteMembershipRequestCoreTests.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestCoreTests.java b/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestCoreTests.java index ce43b7789..eb523fd29 100644 --- a/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestCoreTests.java @@ -126,7 +126,7 @@ public class UpdateSiteMembershipRequestCoreTests extends RestTest restClient.authenticateUser(newMember) .withCoreAPI() .usingAuthUser() - .addSiteMembershipRequest(siteModel, updatedMessage); + .addSiteMembershipRequest(updatedMessage, siteModel, "Accept me"); returnedResponse = restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(siteModel, updatedMessage); restClient.assertStatusCodeIs(HttpStatus.OK); returnedResponse.assertMembershipRequestMessageIs(updatedMessage) @@ -142,7 +142,7 @@ public class UpdateSiteMembershipRequestCoreTests extends RestTest restClient.authenticateUser(newMember) .withCoreAPI() .usingAuthUser() - .addSiteMembershipRequest(siteModel, ""); + .addSiteMembershipRequest("", siteModel, "Accept me"); returnedResponse = restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(siteModel, updatedMessage); restClient.assertStatusCodeIs(HttpStatus.OK); returnedResponse.assertMembershipRequestMessageIs(updatedMessage) From 08ea124a2bb986bbe442098922d461474f8d063a Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Mon, 5 Dec 2016 18:58:47 +0200 Subject: [PATCH 0660/1491] CORE-REST API: getNodeTags (get /nodes/{nodeId}/tags) --- .../rest/tags/GetNodeTagsCoreTests.java | 130 ++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/tags/GetNodeTagsCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsCoreTests.java b/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsCoreTests.java new file mode 100644 index 000000000..295e37c9b --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsCoreTests.java @@ -0,0 +1,130 @@ +package org.alfresco.rest.tags; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.utility.data.RandomData; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.apache.commons.lang.RandomStringUtils; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) +public class GetNodeTagsCoreTests extends RestTest +{ + private UserModel adminUserModel, userModel; + private SiteModel siteModel; + private FileModel document; + private String tagValue; + private String tagValue2; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + adminUserModel = dataUser.getAdminUser(); + restClient.authenticateUser(adminUserModel); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + + tagValue = RandomData.getRandomName("tag"); + restClient.withCoreAPI().usingResource(document).addTag(tagValue); + + tagValue2 = RandomData.getRandomName("tag"); + restClient.withCoreAPI().usingResource(document).addTag(tagValue2); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that using invalid value for skipCount parameter returns status code 400") + public void invalidSkipCountTest() throws JsonToModelConversionException, Exception + { + restClient.withParams("skipCount=abc").withCoreAPI().usingResource(document).getNodeTags(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "abc")); + + restClient.withParams("skipCount=-1").withCoreAPI().usingResource(document).getNodeTags(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.NEGATIVE_VALUE, "skipCount")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that using invalid value for maxItems parameter returns status code 400") + public void invalidMaxItemsTest() throws JsonToModelConversionException, Exception + { + restClient.withParams("maxItems=abc").withCoreAPI().usingResource(document).getNodeTags(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "abc")); + + restClient.withParams("maxItems=-1").withCoreAPI().usingResource(document).getNodeTags(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.POSITIVE_VALUES, "maxItems")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that user without permissions returns status code 403") + public void userWithoutPermissionsTest() throws JsonToModelConversionException, Exception + { + SiteModel site = dataSite.usingUser(adminUserModel).createModeratedRandomSite(); + FileModel document = dataContent.usingSite(site).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + String tagValue = RandomData.getRandomName("tag"); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).addTag(tagValue); + + restClient.authenticateUser(userModel).withCoreAPI().usingResource(document).getNodeTags(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that if node does not exist returns status code 403") + public void inexistentNodeTest() throws JsonToModelConversionException, Exception + { + FileModel document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + String nodeRef = RandomStringUtils.randomAlphanumeric(10); + document.setNodeRef(nodeRef); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getNodeTags(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, nodeRef)); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that if node id is empty returns status code 403") + public void emptyNodeIdTest() throws JsonToModelConversionException, Exception + { + FileModel document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + document.setNodeRef(""); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getNodeTags(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify file tags") + public void fileTagsTest() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getNodeTags() + .assertThat() + .entriesListContains("tag", tagValue.toLowerCase()) + .and().entriesListContains("tag", tagValue2.toLowerCase()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify folder tags") + public void folderTagsTest() throws JsonToModelConversionException, Exception + { + FolderModel folder = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); + + tagValue = RandomData.getRandomName("tag"); + restClient.withCoreAPI().usingResource(folder).addTag(tagValue); + tagValue2 = RandomData.getRandomName("tag"); + restClient.withCoreAPI().usingResource(folder).addTag(tagValue2); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(folder).getNodeTags() + .assertThat() + .entriesListContains("tag", tagValue.toLowerCase()) + .and().entriesListContains("tag", tagValue2.toLowerCase()); + } +} \ No newline at end of file From 0c1419af51be68229346492136ac8a27d7bcb5db Mon Sep 17 00:00:00 2001 From: Andrei Rusu Date: Tue, 6 Dec 2016 10:23:57 +0200 Subject: [PATCH 0661/1491] Changes for getRatingCoreTests --- .../rest/ratings/GetRatingCoreTests.java | 220 ++++++++---------- 1 file changed, 102 insertions(+), 118 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/ratings/GetRatingCoreTests.java b/e2e-test/java/org/alfresco/rest/ratings/GetRatingCoreTests.java index 232dced69..6cbef9d9e 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/GetRatingCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/GetRatingCoreTests.java @@ -1,6 +1,7 @@ package org.alfresco.rest.ratings; import org.alfresco.dataprep.CMISUtil; +import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.model.RestRatingModel; @@ -18,144 +19,127 @@ import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.testng.Assert; import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) -public class GetRatingCoreTests extends RestTest { +public class GetRatingCoreTests extends RestTest +{ + private SiteModel siteModel; + private UserModel adminUserModel, userModel; + private FileModel document; + private RestRatingModel returnedRatingModel; + private FolderModel firstFolderModel; - private SiteModel siteModel; - private UserModel adminUserModel, userModel; - private FileModel document; - private RestRatingModel returnedRatingModel; - private FolderModel firstFolderModel; + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws DataPreparationException + { + adminUserModel = dataUser.getAdminUser(); + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingAdmin().createPublicRandomSite(); + } - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws DataPreparationException { - adminUserModel = dataUser.getAdminUser(); - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingAdmin().createPublicRandomSite(); - } + @BeforeMethod(alwaysRun = true) + public void setUp() throws DataPreparationException, Exception + { + document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); + } - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Check that rating for invalid ratingId provided status code is 400.") - public void checkInvalidRatingIdStatusCode() throws Exception { + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Check that using invalid ratingId for get rating call returns status code 400.") + public void checkInvalidRatingIdStatusCode() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI(); + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "nodes/{nodeId}/ratings/{ratingId}", document.getNodeRef(), "invalid ratingId"); + restClient.processModel(RestRatingModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("invalid ratingId"); + } - document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Check that using invalid node ID for get rating call returns status code 404.") + public void getRatingUsingInvalidNodeId() throws Exception + { + document.setNodeRef(RandomStringUtils.randomAlphanumeric(20)); + returnedRatingModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getFiveStarRating(); - restClient.authenticateUser(adminUserModel).withCoreAPI(); - RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "nodes/{nodeId}/ratings/{ratingId}", - document.getNodeRef(), "invalid ratingId"); - restClient.processModel(RestRatingModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary("Invalid ratingSchemeId invalid ratingId"); - } + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, document.getNodeRef())); + } - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Check that rating for nodeId does not exist status code 404 is returned.") - public void getRatingUsingInvalidNodeId() throws Exception { + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Get rating of a file that has only likes.") + public void getRatingOfFileThatHasOnlyLikes() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).likeDocument(); - document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); - document.setNodeRef(RandomStringUtils.randomAlphanumeric(20)); - returnedRatingModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document) - .getFiveStarRating(); + returnedRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); + returnedRatingModel.getAggregate().assertThat().field("numberOfRatings").is("1"); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, document.getNodeRef())); - } + returnedRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedRatingModel.getAggregate().assertThat().field("numberOfRatings").is("0"); + } - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Get rating of a file that has only likes.") - public void getRatingOfFileThatHasOnlyLikes() throws Exception { + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Get rating of a file that has only stars.") + public void getRatingOfFileThatHasOnlyStars() throws Exception + { + restClient.authenticateUser(userModel).withCoreAPI().usingResource(document).rateStarsToDocument(5); - document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).likeDocument(); + returnedRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); + returnedRatingModel.getAggregate().assertThat().field("numberOfRatings").is("1"); - returnedRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); - Assert.assertEquals(returnedRatingModel.getAggregate().getNumberOfRatings(), 1, - "Node should have 1 like ratings"); + returnedRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedRatingModel.getAggregate().assertThat().field("numberOfRatings").is("0"); + } - returnedRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - Assert.assertEquals(returnedRatingModel.getAggregate().getNumberOfRatings(), 0, - "Node should have no five star ratings"); - } + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Get rating of a file that has likes and stars.") + public void getRatingOfFileThatHasLikesAndStars() throws Exception + { + restClient.authenticateUser(userModel).withCoreAPI().usingResource(document).likeDocument(); + restClient.authenticateUser(userModel).withCoreAPI().usingResource(document).rateStarsToDocument(5); - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Get rating of a file that has only stars.") - public void getRatingOfFileThatHasOnlyStars() throws Exception { + returnedRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); + returnedRatingModel.getAggregate().assertThat().field("numberOfRatings").is("1"); - document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); - restClient.authenticateUser(userModel).withCoreAPI().usingResource(document).rateStarsToDocument(5); + returnedRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); + returnedRatingModel.getAggregate().assertThat().field("numberOfRatings").is("1"); + } - returnedRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and() - .field("aggregate").isNotEmpty(); - Assert.assertEquals(returnedRatingModel.getAggregate().getNumberOfRatings(), 1, - "Node should have 1 five star ratings"); + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Get rating of a folder that has only likes.") + public void getRatingOfFolderThatHasOnlyLikes() throws Exception + { + firstFolderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(firstFolderModel).likeDocument(); - returnedRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - Assert.assertEquals(returnedRatingModel.getAggregate().getNumberOfRatings(), 0, - "Node should have no like ratings"); + returnedRatingModel = restClient.withCoreAPI().usingResource(firstFolderModel).getLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); + returnedRatingModel.getAggregate().assertThat().field("numberOfRatings").is("1"); + } - } + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Get rating of a file that has no ratings.") + public void getRatingOfFileThatHasNoRatings() throws Exception + { + returnedRatingModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedRatingModel.getAggregate().assertThat().field("numberOfRatings").is("0"); - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Get rating of a file that has likes and stars.") - public void getRatingOfFileThatHasLikesAndStars() throws Exception { - - document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); - restClient.authenticateUser(userModel).withCoreAPI().usingResource(document).likeDocument(); - restClient.authenticateUser(userModel).withCoreAPI().usingResource(document).rateStarsToDocument(5); - - returnedRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); - Assert.assertEquals(returnedRatingModel.getAggregate().getNumberOfRatings(), 1, - "Node should have 1 like ratings"); - - returnedRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and() - .field("aggregate").isNotEmpty(); - Assert.assertEquals(returnedRatingModel.getAggregate().getNumberOfRatings(), 1, - "Node should have 1 five stars ratings"); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Get rating of a folder that has only likes.") - public void getRatingOfFolderThatHasOnlyLikes() throws Exception { - - firstFolderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(firstFolderModel).likeDocument(); - - returnedRatingModel = restClient.withCoreAPI().usingResource(firstFolderModel).getLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); - Assert.assertEquals(returnedRatingModel.getAggregate().getNumberOfRatings(), 1, - "Node should have 1 like rating"); - - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Get rating of a file that has no ratings.") - public void getRatingOfFileThatHasNoRatings() throws Exception { - - document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); - restClient.authenticateUser(adminUserModel).withCoreAPI(); - - returnedRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - Assert.assertEquals(returnedRatingModel.getAggregate().getNumberOfRatings(), 0, - "Node should have no likes ratings"); - - returnedRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - Assert.assertEquals(returnedRatingModel.getAggregate().getNumberOfRatings(), 0, - "Node should have no five star ratings"); - } + returnedRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedRatingModel.getAggregate().assertThat().field("numberOfRatings").is("0"); + } } From c2f893dffd2ba4336dbd2e9a8277b6755b87a7e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alecsandru=20Prun=C4=83?= Date: Tue, 6 Dec 2016 10:41:39 +0200 Subject: [PATCH 0662/1491] test: Added valid values for skipCount and maxItems --- .../AddSiteMembershipRequestCoreTests.java | 4 ++ ...GetSiteMembershipInformationCoreTests.java | 55 +++++++++++++++++++ 2 files changed, 59 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestCoreTests.java b/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestCoreTests.java index f27718f90..127075d19 100644 --- a/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestCoreTests.java @@ -43,6 +43,7 @@ public class AddSiteMembershipRequestCoreTests extends RestTest .usingMe() .addSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + restClient.assertLastError().containsSummary(String.format("%s is already a member of site %s", newMember.getUsername(), siteModel.getId())); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, @@ -53,6 +54,7 @@ public class AddSiteMembershipRequestCoreTests extends RestTest .withCoreAPI() .usingUser(new UserModel("invalidUser", "password")).addSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + restClient.assertLastError().containsSummary("The entity with id: invalidUser was not found"); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, @@ -63,6 +65,8 @@ public class AddSiteMembershipRequestCoreTests extends RestTest .withCoreAPI() .usingMe().addSiteMembershipRequest(new SiteModel("invalidSiteID")); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + restClient.assertLastError().containsSummary(String.format("The relationship resource was not found for" + + " the entity with id: %s and a relationship id of invalidSiteID", newMember.getUsername())); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipInformationCoreTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipInformationCoreTests.java index 4a755125a..07745dca6 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipInformationCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipInformationCoreTests.java @@ -56,6 +56,7 @@ public class GetSiteMembershipInformationCoreTests extends RestTest .getSitesMembershipInformation() .assertThat().entriesListIsEmpty(); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + restClient.assertLastError().containsSummary("The entity with id: invalidPersonId was not found"); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, @@ -69,6 +70,37 @@ public class GetSiteMembershipInformationCoreTests extends RestTest .getSitesMembershipInformation() .assertThat().entriesListIsEmpty(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + restClient.assertLastError().containsSummary("Only positive values supported for maxItems"); + + restClient.withParams("maxItems=-1") + .withCoreAPI() + .usingAuthUser() + .getSitesMembershipInformation() + .assertThat().entriesListIsEmpty(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + restClient.assertLastError().containsSummary("Only positive values supported for maxItems"); + + restClient.withParams("maxItems=test") + .withCoreAPI() + .usingAuthUser() + .getSitesMembershipInformation() + .assertThat().entriesListIsEmpty(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + restClient.assertLastError().containsSummary("Invalid paging parameter maxItems:test"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify if get site membership information request returns status code 200 for valid maxItems parameter") + public void getSiteMembershipInformationRequestReturns200ForValidMaxItemsParameter() throws Exception + { + restClient.authenticateUser(userModel) + .withParams("maxItems=5") + .withCoreAPI() + .usingAuthUser() + .getSitesMembershipInformation() + .assertThat().entriesListIsNotEmpty() + .getPagination().assertThat().field("maxItems").is("5"); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, @@ -82,6 +114,29 @@ public class GetSiteMembershipInformationCoreTests extends RestTest .getSitesMembershipInformation() .assertThat().entriesListIsEmpty(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + restClient.assertLastError().containsSummary("Negative values not supported for skipCount"); + + restClient.withParams("skipCount=test") + .withCoreAPI() + .usingAuthUser() + .getSitesMembershipInformation() + .assertThat().entriesListIsEmpty(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + restClient.assertLastError().containsSummary("Invalid paging parameter skipCount:test"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify if get site membership information request returns status code 200 for valid skipCount parameter") + public void getSiteMembershipInformationRequestReturns200ForValidSkipCountParameter() throws Exception + { + restClient.authenticateUser(userModel) + .withParams("skipCount=1") + .withCoreAPI() + .usingAuthUser() + .getSitesMembershipInformation() + .assertThat().entriesListIsNotEmpty() + .getPagination().assertThat().field("skipCount").is("1"); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, From dc51515ec3e86fe5dbaaf66c5bd6daed4da9f739 Mon Sep 17 00:00:00 2001 From: Andrei Rusu Date: Tue, 6 Dec 2016 11:17:14 +0200 Subject: [PATCH 0663/1491] Added changes to getSiteMembershipRequestsCoreTests --- .../GetSiteMembershipRequestsCoreTests.java | 241 +++++++----------- 1 file changed, 99 insertions(+), 142 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsCoreTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsCoreTests.java index d2ff8e6f1..1ae77d1a1 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsCoreTests.java @@ -1,22 +1,14 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; -import org.alfresco.rest.core.RestRequest; -import org.alfresco.rest.core.RestWrapper; import org.alfresco.rest.model.RestSiteMembershipRequestModelsCollection; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.model.ErrorModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; -import org.springframework.social.alfresco.api.entities.Role; -import org.springframework.social.alfresco.api.entities.Site.Visibility; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -27,153 +19,118 @@ import org.testng.annotations.Test; * @author Andrei Rusu */ -@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) -public class GetSiteMembershipRequestsCoreTests extends RestTest { +public class GetSiteMembershipRequestsCoreTests extends RestTest +{ + UserModel newMember, adminUser; + SiteModel moderatedSite, publicSite; + RestSiteMembershipRequestModelsCollection returnedCollection; - UserModel userModel, newMember; - SiteModel siteModel, siteModel2; - RestWrapper restWrapper; + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + moderatedSite = dataSite.usingAdmin().createModeratedRandomSite(); + publicSite = dataSite.usingAdmin().createPublicRandomSite(); + newMember = dataUser.createRandomTestUser(); - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception { + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - String siteId = RandomData.getRandomName("site"); - siteModel = dataSite.usingUser(userModel) - .createSite(new SiteModel(Visibility.MODERATED, siteId, siteId, siteId, siteId)); - newMember = dataUser.createRandomTestUser(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + } - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(siteModel); + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify that for invalid maxItems parameter status code returned is 400.") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + public void checkInvalidMaxItemsStatusCode() throws Exception + { + restClient.authenticateUser(adminUser).withParams("maxItems=AB").withCoreAPI().usingUser(newMember).getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Invalid paging parameter"); + } - restClient.assertStatusCodeIs(HttpStatus.CREATED); - } + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify that for invalid skipCount parameter status code returned is 400.") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + public void checkInvalidSkipCountStatusCode() throws Exception + { + restClient.authenticateUser(adminUser).withParams("skipCount=AB").withCoreAPI().usingUser(newMember).getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Invalid paging parameter"); + } - @Bug(id = "MNT-16557") - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify that for invalid maxItems parameter status code is 400.") - public void checkInvalidMaxItemsStatusCode() throws Exception { + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify that if personId does not exist status code returned is 404.") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + public void ifPersonIdDoesNotExist() throws Exception + { + UserModel nonexistentUser = dataUser.createRandomTestUser(); + nonexistentUser.setUsername("nonexistent"); + + restClient.authenticateUser(adminUser).withCoreAPI().usingUser(nonexistentUser).getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, "nonexistent")); + } - UserModel adminUser = dataUser.getAdminUser(); + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Specify -me- string in place of for request.") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + public void replacePersonIdWithMeRequest() throws Exception + { + returnedCollection = restClient.authenticateUser(newMember).withCoreAPI().usingMe().getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat().entriesListContains("id", moderatedSite.getId()); + } - restClient.authenticateUser(adminUser).withParams("maxItems=AB").withCoreAPI().usingUser(newMember) - .getSiteMembershipRequests().assertThat().entriesListIsNotEmpty(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary("Invalid paging parameter"); - } + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify that if empty personId is used status code returned is 404.") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + public void useEmptyPersonId() throws Exception + { + UserModel emptyNameMember = dataUser.createRandomTestUser(); + emptyNameMember.setUsername(" "); + + restClient.authenticateUser(adminUser).withCoreAPI().usingUser(emptyNameMember).getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary("The entity with id: " + emptyNameMember.getUsername() + " was not found"); + } - @Bug(id = "MNT-16557") - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify that for invalid skipCount parameter status code is 400.") - public void checkInvalidSkipCountStatusCode() throws Exception { + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Get site membership requests to a public site.") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + public void getRequestsToPublicSite() throws Exception + { + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(publicSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); - UserModel adminUser = dataUser.getAdminUser(); + returnedCollection = restClient.withCoreAPI().usingAuthUser().getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat().entriesListDoesNotContain("id", publicSite.getId()); + } - restClient.authenticateUser(adminUser).withParams("skipCount=AB").withCoreAPI().usingUser(newMember) - .getSiteMembershipRequests().assertThat().entriesListIsNotEmpty(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary("Invalid paging parameter"); - } + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Get site membership requests to a moderated site.") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + public void getRequestsToModeratedSite() throws Exception + { + returnedCollection = restClient.authenticateUser(newMember).withCoreAPI().usingUser(newMember).getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat().entriesListContains("id", moderatedSite.getId()); + } - @Bug(id = "MNT-16557") - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify that if personId does not exist status code is 404.") - public void ifPersonIdDoesNotExist() throws Exception { + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Approve request then get requests.") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + public void approveRequestThenGetRequests() throws Exception + { + UserModel siteManager = dataUser.createRandomTestUser(); - UserModel adminUser = dataUser.getAdminUser(); + moderatedSite = dataSite.usingUser(siteManager).createModeratedRandomSite(); + restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.authenticateUser(adminUser).withCoreAPI(); - RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, - "people/{personId}/site-membership-requests?{parameters}", newMember.getUsername(), - restClient.getParameters()); - restClient.processModels(RestSiteMembershipRequestModelsCollection.class, request).assertThat() - .entriesListIsNotEmpty(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary("not found"); - } + //TODO approve request + /* newMember.setUserRole(UserRole.SiteConsumer); + restClient.authenticateUser(siteManager).withCoreAPI().usingSite(siteModel).addPerson(newMember).assertThat().field("id").is(newMember.getUsername()) + .and().field("role").is(newMember.getUserRole()); + restClient.assertStatusCodeIs(HttpStatus.CREATED);*/ - @Bug(id = "MNT-16557") - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Specify -me- string in place of for request.") - public void replacePersonIdWithMeRequest() throws Exception { - - UserModel adminUser = dataUser.getAdminUser(); - - restClient.authenticateUser(adminUser).withCoreAPI(); - RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, - "people/{me}/site-membership-requests?{parameters}", newMember.getUsername(), - restClient.getParameters()); - restClient.processModels(RestSiteMembershipRequestModelsCollection.class, request).assertThat() - .entriesListIsNotEmpty(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary("not found"); - } - - @Bug(id = "MNT-16557") - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Use empty personId.") - public void useEmptyPersonId() throws Exception { - - UserModel adminUser = dataUser.getAdminUser(); - - restClient.authenticateUser(adminUser).withCoreAPI(); - RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, - "people/{personId}/site-membership-requests?{parameters}", "", restClient.getParameters()); - restClient.processModels(RestSiteMembershipRequestModelsCollection.class, request); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary("not found"); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Get site membership requests to a public site.") - public void getRequestsToPublicSite() throws Exception { - - String siteId2 = RandomData.getRandomName("site"); - siteModel2 = dataSite.usingUser(userModel) - .createSite(new SiteModel(Visibility.PUBLIC, siteId2, siteId2, siteId2, siteId2)); - newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(siteModel2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - UserModel adminUser = dataUser.getAdminUser(); - - restClient.authenticateUser(adminUser).withCoreAPI().usingUser(newMember).getSiteMembershipRequests() - .assertThat().entriesListIsEmpty(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - } - - @Bug(id = "MNT-16557") - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Get site membership requests to a moderated site.") - public void getRequestsToModeratedSite() throws Exception { - - UserModel adminUser = dataUser.getAdminUser(); - - restClient.authenticateUser(adminUser).withCoreAPI().usingUser(newMember).getSiteMembershipRequests() - .assertThat().entriesListIsNotEmpty(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Bug(id = "MNT-16557") - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Approve request then get requests.") - public void approveRequestThenGetRequests() throws Exception { - - ListUserWithRoles usersWithRoles; - - UserModel adminUser = dataUser.getAdminUser(); - siteModel = dataSite.usingUser(adminUser).createModeratedRandomSite(); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, - UserRole.SiteConsumer, UserRole.SiteContributor); - - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteConsumer); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingSite(siteModel).addPerson(testUser).assertThat().field("id") - .is(testUser.getUsername()).and().field("role").is(testUser.getUserRole()); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(testUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(siteModel); - - restClient.authenticateUser(adminUser).withCoreAPI().usingUser(testUser).getSiteMembershipRequests() - .assertThat().entriesListIsNotEmpty(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } + returnedCollection = restClient.authenticateUser(newMember).withCoreAPI().usingMe().getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat().entriesListDoesNotContain("id", moderatedSite.getId()); + } } From 601d9a20f7011f432f595e0b41a4e0144a2a2f3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alecsandru=20Prun=C4=83?= Date: Tue, 6 Dec 2016 11:27:12 +0200 Subject: [PATCH 0664/1491] test: Replaced hard coded values with RestErrorModel --- .../people/AddSiteMembershipRequestCoreTests.java | 8 ++++---- .../GetSiteMembershipInformationCoreTests.java | 13 +++++++------ 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestCoreTests.java b/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestCoreTests.java index 127075d19..ace45b340 100644 --- a/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestCoreTests.java @@ -1,6 +1,7 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.SiteModel; @@ -43,7 +44,7 @@ public class AddSiteMembershipRequestCoreTests extends RestTest .usingMe() .addSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - restClient.assertLastError().containsSummary(String.format("%s is already a member of site %s", newMember.getUsername(), siteModel.getId())); + restClient.assertLastError().containsSummary(String.format(RestErrorModel.ALREADY_Site_MEMBER, newMember.getUsername(), siteModel.getId())); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, @@ -54,7 +55,7 @@ public class AddSiteMembershipRequestCoreTests extends RestTest .withCoreAPI() .usingUser(new UserModel("invalidUser", "password")).addSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - restClient.assertLastError().containsSummary("The entity with id: invalidUser was not found"); + restClient.assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidUser")); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, @@ -65,8 +66,7 @@ public class AddSiteMembershipRequestCoreTests extends RestTest .withCoreAPI() .usingMe().addSiteMembershipRequest(new SiteModel("invalidSiteID")); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - restClient.assertLastError().containsSummary(String.format("The relationship resource was not found for" + - " the entity with id: %s and a relationship id of invalidSiteID", newMember.getUsername())); + restClient.assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, newMember.getUsername(), "invalidSiteID")); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipInformationCoreTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipInformationCoreTests.java index 07745dca6..8dbc2f6ca 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipInformationCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipInformationCoreTests.java @@ -1,6 +1,7 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.SiteModel; @@ -56,7 +57,7 @@ public class GetSiteMembershipInformationCoreTests extends RestTest .getSitesMembershipInformation() .assertThat().entriesListIsEmpty(); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - restClient.assertLastError().containsSummary("The entity with id: invalidPersonId was not found"); + restClient.assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidPersonId")); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, @@ -70,7 +71,7 @@ public class GetSiteMembershipInformationCoreTests extends RestTest .getSitesMembershipInformation() .assertThat().entriesListIsEmpty(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - restClient.assertLastError().containsSummary("Only positive values supported for maxItems"); + restClient.assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); restClient.withParams("maxItems=-1") .withCoreAPI() @@ -78,7 +79,7 @@ public class GetSiteMembershipInformationCoreTests extends RestTest .getSitesMembershipInformation() .assertThat().entriesListIsEmpty(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - restClient.assertLastError().containsSummary("Only positive values supported for maxItems"); + restClient.assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); restClient.withParams("maxItems=test") .withCoreAPI() @@ -86,7 +87,7 @@ public class GetSiteMembershipInformationCoreTests extends RestTest .getSitesMembershipInformation() .assertThat().entriesListIsEmpty(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - restClient.assertLastError().containsSummary("Invalid paging parameter maxItems:test"); + restClient.assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "test")); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, @@ -114,7 +115,7 @@ public class GetSiteMembershipInformationCoreTests extends RestTest .getSitesMembershipInformation() .assertThat().entriesListIsEmpty(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - restClient.assertLastError().containsSummary("Negative values not supported for skipCount"); + restClient.assertLastError().containsSummary(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT); restClient.withParams("skipCount=test") .withCoreAPI() @@ -122,7 +123,7 @@ public class GetSiteMembershipInformationCoreTests extends RestTest .getSitesMembershipInformation() .assertThat().entriesListIsEmpty(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - restClient.assertLastError().containsSummary("Invalid paging parameter skipCount:test"); + restClient.assertLastError().containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "test")); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, From 55f909faa0bf475a22f7df01f33e719daefcd141 Mon Sep 17 00:00:00 2001 From: Bogdan Bocancea Date: Tue, 6 Dec 2016 11:43:21 +0200 Subject: [PATCH 0665/1491] TAS-2064: add core tests for 'delete /processes/{processId}' request --- .../processes/DeleteProcessCoreTests.java | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessCoreTests.java new file mode 100644 index 000000000..110acf878 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessCoreTests.java @@ -0,0 +1,67 @@ +package org.alfresco.rest.workflow.processes; + +import org.alfresco.dataprep.CMISUtil.Priority; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestProcessModel; +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; + +@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) +public class DeleteProcessCoreTests extends RestTest +{ + private UserModel userWhoAddsProcess, assignee; + private RestProcessModel process; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + userWhoAddsProcess = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify admin user is able to delete a process started by another user.") + public void deleteProcessByAdminUser() throws Exception + { + process = restClient.authenticateUser(userWhoAddsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.authenticateUser(dataUser.getAdminUser()) + .withWorkflowAPI().usingProcess(process).deleteProcess(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().getProcesses() + .assertThat().entriesListDoesNotContain("id", process.getId()); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify User is not able to delete process with invalid id") + public void deleteProcessWithInvalidId() throws Exception + { + process = restClient.authenticateUser(userWhoAddsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + process.setId("00001"); + restClient.withWorkflowAPI().usingProcess(process).deleteProcess(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "00001")); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify User is not able to delete process with empty id") + public void deleteProcessWithEmptyId() throws Exception + { + process = restClient.authenticateUser(userWhoAddsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + process.setId(""); + restClient.withWorkflowAPI().usingProcess(process).deleteProcess(); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) + .assertLastError().containsSummary(RestErrorModel.DELETE_EMPTY_ARGUMENT); + } +} From 3370e3062c3a0eb659bf869477dfded69a28899b Mon Sep 17 00:00:00 2001 From: cagache Date: Tue, 6 Dec 2016 12:26:39 +0200 Subject: [PATCH 0666/1491] test: added core scenarios for getProcessDefinitionImage (get /process-definitions/{processDefinitionId}/image) --- .../GetProcessDefinitionImageCoreTests.java | 80 +++++++++++++++++++ .../GetProcessDefinitionImageSanityTests.java | 3 - 2 files changed, 80 insertions(+), 3 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageCoreTests.java new file mode 100644 index 000000000..2314eb85d --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageCoreTests.java @@ -0,0 +1,80 @@ +package org.alfresco.rest.workflow.processDefinitions; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestProcessDefinitionModel; +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; + +/** + * Created by Claudia Agache on 12/6/2016. + */ +@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.CORE }) +public class GetProcessDefinitionImageCoreTests extends RestTest +{ + private UserModel adminUser, adminTenantUser; + private RestProcessDefinitionModel randomProcessDefinition; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, + executionType = ExecutionType.REGRESSION, + description = "Verify if get process definition image returns status code 404 when invalid processDefinitionId is used") + public void getProcessDefinitionImageUsingInvalidProcessDefinitionId() throws Exception + { + restClient.authenticateUser(adminUser); + randomProcessDefinition = restClient.withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry(); + randomProcessDefinition.onModel().setId("invalidID"); + + restClient.withWorkflowAPI() + .usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionImage(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidID")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, + executionType = ExecutionType.REGRESSION, + description = "Verify network admin is able to get a process definition image using REST API and status code is OK (200)") + @Test(groups = { TestGroup.NETWORKS }) + public void networkAdminGetProcessDefinitionImage() throws Exception + { + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser) + .usingTenant().createTenant(adminTenantUser); + + randomProcessDefinition = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry(); + restClient.withWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionImage() + .assertResponseContainsImage(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, + executionType = ExecutionType.REGRESSION, + description = "Verify network user is able to get a process definition image using REST API and status code is OK (200)") + @Test(groups = { TestGroup.NETWORKS }) + public void networkUserGetProcessDefinitionImage() throws Exception + { + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser) + .usingTenant().createTenant(adminTenantUser); + + UserModel tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + + randomProcessDefinition = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() + .getAllProcessDefinitions().getOneRandomEntry(); + restClient.authenticateUser(tenantUser).withWorkflowAPI() + .usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionImage() + .assertResponseContainsImage(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + +} diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java index bd531a421..d36d2b108 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java @@ -18,9 +18,6 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY }) public class GetProcessDefinitionImageSanityTests extends RestTest { - @Autowired - private DataUser dataUser; - private UserModel testUser; private RestProcessDefinitionModel randomProcessDefinition; From 0775dc8b78b1421887603110096608f89673560a Mon Sep 17 00:00:00 2001 From: Bogdan Bocancea Date: Tue, 6 Dec 2016 15:31:11 +0200 Subject: [PATCH 0667/1491] TAS-2072: add core tests for delete /processes/{processId}/items/{itemId} request. Fix getProcessModelByProcessDefId(String processDefinitionId) from RestProcessModelsCollection --- .../processes/DeleteProcessItemCoreTests.java | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessItemCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessItemCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessItemCoreTests.java new file mode 100644 index 000000000..dfe37b9ad --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessItemCoreTests.java @@ -0,0 +1,83 @@ +package org.alfresco.rest.workflow.processes; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestItemModel; +import org.alfresco.rest.model.RestItemModelsCollection; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.ProcessModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) +public class DeleteProcessItemCoreTests extends RestTest +{ + private FileModel document, secondDoc; + private SiteModel siteModel; + private UserModel userWhoStartsTask, assignee; + private RestProcessModel restProcessModel; + private ProcessModel processModel; + private RestItemModelsCollection items; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + userWhoStartsTask = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + processModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document) + .createSingleReviewerTaskAndAssignTo(assignee); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Delete process item with invalid id") + public void deleteProcessItemWithInvalidItemId() throws Exception + { + restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() + .getProcesses().getProcessModelByProcessDefId(processModel.getId()); + secondDoc = dataContent.usingUser(userWhoStartsTask).usingSite(siteModel).createContent(DocumentType.MSWORD); + RestItemModel processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(secondDoc); + processItem.setId("invalid-id"); + restClient.withWorkflowAPI().usingProcess(processModel).deleteProcessItem(processItem); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.PROCESS_ENTITY_NOT_FOUND, "invalid-id")); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Delete process item with empty id") + public void deleteProcessItemWithEmptyItemId() throws Exception + { + restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() + .getProcesses().getProcessModelByProcessDefId(processModel.getId()); + secondDoc = dataContent.usingUser(userWhoStartsTask).usingSite(siteModel).createContent(DocumentType.MSWORD); + RestItemModel processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(secondDoc); + processItem.setId(""); + restClient.withWorkflowAPI().usingProcess(processModel).deleteProcessItem(processItem); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) + .assertLastError().containsSummary(String.format(RestErrorModel.DELETE_EMPTY_ARGUMENT)); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Delete process item twice") + public void deleteProcessItemTwice() throws Exception + { + restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() + .getProcesses().getProcessModelByProcessDefId(processModel.getId()); + items = restClient.withWorkflowAPI().usingProcess(restProcessModel).getProcessItems(); + RestItemModel processItem = items.getEntries().get(0); + restClient.withWorkflowAPI().usingProcess(processModel).deleteProcessItem(processItem.onModel()); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingProcess(processModel).deleteProcessItem(processItem.onModel()); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.PROCESS_ENTITY_NOT_FOUND, processItem.onModel().getId())); + } +} From a481510236b27e4107ebbf59d97508b639ab2bcc Mon Sep 17 00:00:00 2001 From: cagache Date: Tue, 6 Dec 2016 17:17:42 +0200 Subject: [PATCH 0668/1491] test: added core scenarios for getProcessDefinitionStartFormModel (get /process-definitions/{processDefinitionId}/start-form-model) --- ...cessDefinitionStartFormModelCoreTests.java | 96 +++++++++++++++++++ ...ssDefinitionStartFormModelSanityTests.java | 3 - 2 files changed, 96 insertions(+), 3 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java new file mode 100644 index 000000000..cf00f2fcd --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java @@ -0,0 +1,96 @@ +package org.alfresco.rest.workflow.processDefinitions; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestProcessDefinitionModel; +import org.alfresco.rest.model.RestProcessDefinitionModelsCollection; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Created by Claudia Agache on 12/6/2016. + */ +@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.CORE }) +public class GetProcessDefinitionStartFormModelCoreTests extends RestTest +{ + private UserModel adminUser, adminTenantUser; + private RestProcessDefinitionModel randomProcessDefinition, returnedProcessDefinition; + private RestProcessDefinitionModelsCollection allProcessDefinitions; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + allProcessDefinitions = restClient.authenticateUser(adminUser).withWorkflowAPI().getAllProcessDefinitions(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, + executionType = ExecutionType.REGRESSION, + description = "Verify any user gets a model of the start form type definition for non-network deployments using REST API and status code is OK (200)") + public void nonNetworkUserGetsStartFormModel() throws Exception + { + UserModel nonNetworkUser = dataUser.createRandomTestUser(); + + randomProcessDefinition = allProcessDefinitions.getOneRandomEntry(); + restClient.authenticateUser(nonNetworkUser).withWorkflowAPI() + .usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionStartFormModel() + .assertThat().entriesListIsNotEmpty(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Bug(id = "ALF-20187") + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, + executionType = ExecutionType.REGRESSION, + description = "Verify if get request returns status code 404 when invalid processDefinitionId is used") + public void getStartFormModelUsingInvalidProcessDefinitionId() throws Exception + { + randomProcessDefinition = allProcessDefinitions.getOneRandomEntry(); + randomProcessDefinition.onModel().setId("invalidID"); + + restClient.authenticateUser(adminUser).withWorkflowAPI() + .usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionStartFormModel(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidID")); + } + + @Bug(id = "ALF-20187") + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, + executionType = ExecutionType.REGRESSION, + description = "Verify if get request returns status code 404 when empty processDefinitionId is used") + public void getStartFormModelUsingEmptyProcessDefinitionId() throws Exception + { + randomProcessDefinition = allProcessDefinitions.getOneRandomEntry(); + randomProcessDefinition.onModel().setId(""); + + restClient.authenticateUser(adminUser).withWorkflowAPI() + .usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionStartFormModel(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, + executionType = ExecutionType.REGRESSION, + description = "Verify Tenant User gets a model of the start form type definition for network deployments using REST API and status code is OK (200)") + @Test(groups = { TestGroup.NETWORKS }) + public void networkUserGetsStartFormModel() throws Exception + { + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser) + .usingTenant().createTenant(adminTenantUser); + + UserModel tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + + randomProcessDefinition = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() + .getAllProcessDefinitions().getOneRandomEntry(); + restClient.authenticateUser(tenantUser).withWorkflowAPI() + .usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionStartFormModel() + .assertThat().entriesListIsNotEmpty(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } +} diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java index 9e4e2c3f4..229a5c8e0 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java @@ -18,9 +18,6 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY }) public class GetProcessDefinitionStartFormModelSanityTests extends RestTest { - @Autowired - private DataUser dataUser; - private UserModel adminUserModel, adminTenantUser; private RestProcessDefinitionModel randomProcessDefinition; From 7f98b3a51cb5bcf39aa6b5659b2e8e03ef70d221 Mon Sep 17 00:00:00 2001 From: cagache Date: Tue, 6 Dec 2016 17:19:42 +0200 Subject: [PATCH 0669/1491] test: removed variable declaration --- .../GetProcessDefinitionStartFormModelCoreTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java index cf00f2fcd..e8a56fcae 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java @@ -20,7 +20,7 @@ import org.testng.annotations.Test; public class GetProcessDefinitionStartFormModelCoreTests extends RestTest { private UserModel adminUser, adminTenantUser; - private RestProcessDefinitionModel randomProcessDefinition, returnedProcessDefinition; + private RestProcessDefinitionModel randomProcessDefinition; private RestProcessDefinitionModelsCollection allProcessDefinitions; @BeforeClass(alwaysRun = true) From 8259b6464efef763ee5f1584cc72f87b45e6ef82 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Wed, 7 Dec 2016 10:33:55 +0200 Subject: [PATCH 0670/1491] Added core tests for GetProcesses --- .../processes/GetProcessesCoreTests.java | 92 +++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesCoreTests.java new file mode 100644 index 000000000..637b4c72f --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesCoreTests.java @@ -0,0 +1,92 @@ +package org.alfresco.rest.workflow.processes; + +import java.util.List; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.dataprep.CMISUtil.Priority; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestProcessModelsCollection; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.ProcessModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TaskModel; +import org.alfresco.utility.model.TestGroup; +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 Cristina Axinte + * + */ +@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) +public class GetProcessesCoreTests extends RestTest +{ + private FileModel document; + private SiteModel siteModel; + private UserModel adminUser, userWhoStartsTask, assignee, adminTenantUser; + private TaskModel task1, task2; + private ProcessModel process3; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userWhoStartsTask = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + task1 = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); + task2 = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(adminUser); + process3 = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createSingleReviewerTaskAndAssignTo(assignee); + } + + @Test(groups = { TestGroup.NETWORKS }) + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify admin gets all processes from same network") + public void getProcessFromSameNetworkUsingAdmin() throws Exception + { + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser); + UserModel tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + UserModel tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); + RestProcessModel process = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee, false, Priority.Normal); + + RestProcessModelsCollection tenantProcesses = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getProcesses(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + tenantProcesses.assertThat().entriesListContains("id", process.getId()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify user gets all processes started by him ordered descending by id") + public void getProcessesOrderedByIdDESC() throws Exception + { + RestProcessModelsCollection processes = restClient.authenticateUser(userWhoStartsTask).withParams("orderBy=id DESC") + .withWorkflowAPI().getProcesses(); + restClient.assertStatusCodeIs(HttpStatus.OK); + processes.assertThat().entriesListIsNotEmpty(); + List processesList = processes.getEntries(); + processesList.get(0).onModel().assertThat().field("id").is(process3.getId()); + processesList.get(1).onModel().assertThat().field("id").is(task2.getNodeRef()); + processesList.get(2).onModel().assertThat().field("id").is(task1.getNodeRef()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify user gets processes that matches a where clause") + public void getProcessesWithWhereClauseAsParameter() throws JsonToModelConversionException, Exception + { + RestProcessModelsCollection processes = restClient.authenticateUser(userWhoStartsTask).where("processDefinitionKey='activitiReview'") + .withWorkflowAPI().getProcesses(); + restClient.assertStatusCodeIs(HttpStatus.OK); + processes.assertThat().entriesListIsNotEmpty().and().entriesListContains("processDefinitionId", "activitiReview:1:8") + .and().entriesListDoesNotContain("processDefinitionId", "activitiAdhoc:1:4"); + } +} From c9cdaa7284dc08bb497a82752406e2af9fd440c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alecsandru=20Prun=C4=83?= Date: Wed, 7 Dec 2016 11:05:53 +0200 Subject: [PATCH 0671/1491] test: Added DeleteDeploymentCoreTests --- .../DeleteDeploymentCoreTests.java | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentCoreTests.java new file mode 100644 index 000000000..501bfa1ec --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentCoreTests.java @@ -0,0 +1,51 @@ +package org.alfresco.rest.workflow.deployments; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestDeploymentModel; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +@Test(groups = { TestGroup.REST_API, TestGroup.DEPLOYMENTS, TestGroup.CORE, TestGroup.WORKFLOW }) +public class DeleteDeploymentCoreTests extends RestTest +{ + private UserModel adminUser; + private UserModel userModel; + private RestDeploymentModel deployment; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userModel = dataUser.createRandomTestUser(); + } + + @Bug(id = "MNT-16996") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, + description = "Verify deleteDeployment is unsupported for empty deployment id with REST API and status code is 404") + public void deleteDeploymentIsUnsupportedForEmptyId() throws Exception + { + deployment = restClient.authenticateUser(adminUser).withWorkflowAPI().getDeployments().getOneRandomEntry().onModel(); + deployment.setId(""); + restClient.withWorkflowAPI().usingDeployment(deployment).deleteDeployment(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); + } + + @Bug(id = "MNT-16996") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, + description = "Verify deleteDeployment is forbidden using non admin user or different user than creator with REST API and status code is 403") + public void deleteDeploymentUsingNonAdminUser() throws Exception + { + deployment = restClient.authenticateUser(adminUser).withWorkflowAPI().getDeployments().getOneRandomEntry().onModel(); + restClient.authenticateUser(userModel).withWorkflowAPI().usingDeployment(deployment).deleteDeployment(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } +} From df390fb876300f1fdeca4590447dbd544324229e Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Wed, 7 Dec 2016 11:07:39 +0200 Subject: [PATCH 0672/1491] Remove unused imports --- .../alfresco/rest/workflow/processes/GetProcessesCoreTests.java | 1 - 1 file changed, 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesCoreTests.java index 637b4c72f..1459cc2ee 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesCoreTests.java @@ -8,7 +8,6 @@ import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.rest.model.RestProcessModelsCollection; -import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.ProcessModel; import org.alfresco.utility.model.SiteModel; From 1d970a3a97fd5a34613aaaac088edd4767859f3b Mon Sep 17 00:00:00 2001 From: Bogdan Bocancea Date: Wed, 7 Dec 2016 11:12:17 +0200 Subject: [PATCH 0673/1491] TAS-2068: add core tests for 'delete /processes/{processId}/variables/{variableName}' request --- .../DeleteProcessVariableCoreTests.java | 84 +++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableCoreTests.java new file mode 100644 index 000000000..e06514ffc --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableCoreTests.java @@ -0,0 +1,84 @@ +package org.alfresco.rest.workflow.processes; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestProcessVariableModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.ProcessModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * + * @author bogdan.bocancea + * + */ +@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) +public class DeleteProcessVariableCoreTests extends RestTest +{ + private FileModel document; + private SiteModel siteModel; + private UserModel userWhoStartsTask, assignee; + private RestProcessModel restProcessModel; + private ProcessModel processModel; + private RestProcessVariableModel variableModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + userWhoStartsTask = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + processModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document) + .createSingleReviewerTaskAndAssignTo(assignee); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Delete invalid process variable") + public void deleteInvalidProcessVariable() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("x:InvalidVar"); + restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() + .getProcesses().getProcessModelByProcessDefId(processModel.getId()); + restClient.withWorkflowAPI().usingProcess(restProcessModel).deleteProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, variableModel.getName())); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Delete empty process variable") + public void deleteEmptyProcessVariable() throws Exception + { + variableModel = new RestProcessVariableModel("","", "d:text"); + restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() + .getProcesses().getProcessModelByProcessDefId(processModel.getId()); + restClient.withWorkflowAPI().usingProcess(restProcessModel).deleteProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) + .assertLastError().containsSummary(RestErrorModel.DELETE_EMPTY_ARGUMENT); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Delete process variable twice") + public void deleteProcessVariableTwice() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() + .getProcesses().getProcessModelByProcessDefId(processModel.getId()); + restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.withWorkflowAPI().usingProcess(restProcessModel).deleteProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingProcess(restProcessModel).deleteProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, variableModel.getName())); + } +} From 3a78d9180f1f1c66200cf094b70dfd1b566b3777 Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 7 Dec 2016 11:29:01 +0200 Subject: [PATCH 0674/1491] TAS-2055: add core tests for getDeployments (get /deployments) --- .../deployments/GetDeploymentsCoreTests.java | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsCoreTests.java new file mode 100644 index 000000000..07aa4680e --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsCoreTests.java @@ -0,0 +1,80 @@ +package org.alfresco.rest.workflow.deployments; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestDeploymentModel; +import org.alfresco.rest.model.RestDeploymentModelsCollection; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import java.util.List; + +/** + * Created by Claudia Agache on 12/7/2016. + */ +@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.CORE}) +public class GetDeploymentsCoreTests extends RestTest +{ + private UserModel adminUser, adminTenantUser; + private RestDeploymentModelsCollection deployments; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.DEPLOYMENTS }, + executionType = ExecutionType.REGRESSION, description = "Verify non admin user is not able to get non-network deployments using REST API and status code is Forbidden") + public void nonAdminUserCanNotGetNonNetworkDeployments() throws Exception + { + UserModel userModel = dataUser.createRandomTestUser(); + restClient.authenticateUser(userModel).withWorkflowAPI().getDeployments(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.DEPLOYMENTS }, + executionType = ExecutionType.REGRESSION, description = "Verify non admin user is not able to get network deployments using REST API and status code is Forbidden") + @Test(groups = { TestGroup.NETWORKS }) + public void nonAdminUserCanNotGetNetworkDeployments() throws Exception + { + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser) + .usingTenant().createTenant(adminTenantUser); + + UserModel tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + restClient.authenticateUser(tenantUser).withWorkflowAPI().getDeployments(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Bug(id = "MNT-16996") + @TestRail(section = { TestGroup.REST_API, TestGroup.DEPLOYMENTS }, + executionType = ExecutionType.REGRESSION, description = "Verify get deployments returns an empty list after deleting all network deployments.") + @Test(groups = { TestGroup.NETWORKS }) + public void getNetworkDeploymentsAfterDeletingAllNetworkDeployments() throws Exception + { + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser) + .usingTenant().createTenant(adminTenantUser); + + List networkDeployments = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getDeployments().getEntries(); + for (RestDeploymentModel networkDeployment: networkDeployments) + { + restClient.withWorkflowAPI().usingDeployment(networkDeployment.onModel()).deleteDeployment(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + deployments = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getDeployments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + deployments.assertThat().entriesListIsEmpty(); + } + +} From 535da8c547611995a6bcf8ff2e8e616ce6af174b Mon Sep 17 00:00:00 2001 From: cnechifor Date: Wed, 7 Dec 2016 14:32:58 +0200 Subject: [PATCH 0675/1491] TAS-2042 --- e2e-test/java/org/alfresco/rest/RestTest.java | 3 + .../sites/GetSiteContainersCoreTests.java | 220 ++++++++++++++++++ .../rest/sites/GetSitesCoreTests.java | 2 +- 3 files changed, 224 insertions(+), 1 deletion(-) create mode 100644 e2e-test/java/org/alfresco/rest/sites/GetSiteContainersCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/RestTest.java b/e2e-test/java/org/alfresco/rest/RestTest.java index ed8813179..a7540549d 100644 --- a/e2e-test/java/org/alfresco/rest/RestTest.java +++ b/e2e-test/java/org/alfresco/rest/RestTest.java @@ -50,6 +50,9 @@ public abstract class RestTest extends AbstractTestNGSpringContextTests @Autowired protected DataLink dataLink; + + @Autowired + protected DataDiscussion dataDiscussion; @BeforeClass(alwaysRun = true) public void checkServerHealth() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersCoreTests.java new file mode 100644 index 000000000..65d39c2fd --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersCoreTests.java @@ -0,0 +1,220 @@ +package org.alfresco.rest.sites; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.utility.constants.ContainerName; +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; + +@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) +public class GetSiteContainersCoreTests extends RestTest +{ + + private UserModel adminUserModel; + private SiteModel siteModel, siteModel1; + private SiteModel moderatedSiteModel, privateSiteModel; + private ListUserWithRoles usersWithRoles; + private ListUserWithRoles usersWithRoles1; + + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + siteModel1 = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + moderatedSiteModel = dataSite.usingUser(adminUserModel).createModeratedRandomSite(); + privateSiteModel = dataSite.usingUser(adminUserModel).createPrivateRandomSite(); + + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + + usersWithRoles1 = dataUser.addUsersWithRolesToSite(siteModel1, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + + dataLink.usingAdmin().usingSite(siteModel1).createRandomLink(); + dataDiscussion.usingAdmin().usingSite(siteModel1).createRandomDiscussion(); + + dataLink.usingAdmin().usingSite(moderatedSiteModel).createRandomLink(); + dataDiscussion.usingAdmin().usingSite(moderatedSiteModel).createRandomDiscussion(); + + dataLink.usingAdmin().usingSite(privateSiteModel).createRandomLink(); + dataDiscussion.usingAdmin().usingSite(privateSiteModel).createRandomDiscussion(); +} + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if get site container request returns status code 200 with valid maxItems parameter") + public void getContainersWithMaxItems() throws Exception + { + restClient.authenticateUser(usersWithRoles1.getOneUserWithRole(UserRole.SiteManager)) + .withParams("maxItems=5") + .withCoreAPI().usingSite(siteModel1).getSiteContainers() + .assertThat().entriesListCountIs(3) + .and().entriesListContains("folderId" ,ContainerName.documentLibrary.toString()) + .and().entriesListContains("folderId", ContainerName.links.toString()) + .and().entriesListContains("folderId", ContainerName.discussions.toString()); + restClient.assertStatusCodeIs(HttpStatus.OK); + + restClient.withParams("maxItems=1") + .withCoreAPI().usingSite(siteModel1).getSiteContainers() + .assertThat().entriesListCountIs(1); + + restClient.withParams("maxItems=3") + .withCoreAPI().usingSite(siteModel).getSiteContainers() + .assertThat().entriesListCountIs(1) + .and().entriesListContains("folderId", ContainerName.documentLibrary.toString()); + restClient.assertStatusCodeIs(HttpStatus.OK); + + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if get site container request returns status code 400 when invalid maxItems parameter is used") + public void getContainersWithMaxItemsZero () throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withParams("maxItems=0") + .withCoreAPI().usingSite(siteModel).getSiteContainers(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary("Only positive values supported for maxItems"); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if get site container request returns status code 400 when invalid maxItems parameter is used") + public void getContainersWithMaxItemsCharacter () throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withParams("maxItems=test") + .withCoreAPI().usingSite(siteModel).getSiteContainers(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "test")); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if get site container request returns status code 400 when invalid maxItems parameter is used") + public void getContainersWithMaxItemsMultipleZero () throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withParams("maxItems=000007") + .withCoreAPI().usingSite(siteModel1).getSiteContainers() + .assertThat().entriesListCountIs(3); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if get site container request returns status code 200 when valid skipCount parameter is used") + public void getSitesWithValidSkipCount() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withParams("skipCount=1") + .withCoreAPI().usingSite(siteModel).getSiteContainers() + .assertThat().entriesListCountIs(0); + restClient.assertStatusCodeIs(HttpStatus.OK); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withParams("skipCount=1") + .withCoreAPI().usingSite(siteModel1).getSiteContainers() + .assertThat().entriesListCountIs(2); + restClient.assertStatusCodeIs(HttpStatus.OK); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withParams("skipCount=2") + .withCoreAPI().usingSite(siteModel1).getSiteContainers() + .assertThat().entriesListCountIs(1); + restClient.assertStatusCodeIs(HttpStatus.OK); + + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withParams("skipCount=0") + .withCoreAPI().usingSite(siteModel1).getSiteContainers() + .assertThat().entriesListCountIs(3); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if get site container request returns status code 400 when invalid skipCount parameter is used") + public void getSitesWithSkipCountCharacter() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withParams("skipCount=abc") + .withCoreAPI().usingSite(siteModel).getSiteContainers(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "abc")); + } + + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if get site container request returns status code 400 when invalid skipCount parameter is used") + public void getSitesWithSkipCountZero() throws Exception + { + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if get site container request returns status code 400 when invalid skipCount parameter is used") + public void getSitesWithSkipCountMultipleZero() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withParams("skipCount=00002") + .withCoreAPI().usingSite(siteModel1).getSiteContainers() + .assertThat().entriesListCountIs(1); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if get site container request returns status code 400 when invalid skipCount parameter is used") + public void getSiteContainerWithNonExistentSite() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingSite("NonExistentSiteId").getSiteContainers(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "NonExistentSiteId")); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify get site container request resturns status 200 for private site") + public void getSiteContainerForPrivateSite() throws Exception + { + restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingSite(privateSiteModel).getSiteContainers() + .assertThat().entriesListCountIs(3); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify get site container request resturns status 200 for moderated site") + public void getSiteContainerForModeratedSite() throws Exception + { + restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingSite(moderatedSiteModel).getSiteContainers() + .assertThat().entriesListCountIs(3); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify get site container request resturns status 200 for several container") + public void getSiteContainerForSeveralItems() throws Exception + { + restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingSite(siteModel1).getSiteContainers() + .assertThat().entriesListCountIs(3) + .and().entriesListContains("folderId" ,ContainerName.documentLibrary.toString()) + .and().entriesListContains("folderId", ContainerName.links.toString()) + .and().entriesListContains("folderId", ContainerName.discussions.toString()); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify get site container request resturns status 200 for one container") + public void getSiteContainerWithOneItem() throws Exception + { + restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingSite(siteModel).getSiteContainers() + .assertThat().entriesListCountIs(1) + .and().entriesListContains("folderId" ,ContainerName.documentLibrary.toString()); + restClient.assertStatusCodeIs(HttpStatus.OK); + } +} diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java index bb52a0bdf..cc603a473 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java @@ -50,7 +50,7 @@ public class GetSitesCoreTests extends RestTest description= "Verify if get sites request returns status code 400 when invalid maxItems parameter is used") public void getSitesWithInvalidMaxItems() throws Exception { - restClient.authenticateUser(regularUser).withParams("maxItems=0") + restClient.authenticateUser(regularUser).withParams("maxItems=0=09") .withCoreAPI().getSites(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) .assertLastError().containsSummary("Only positive values supported for maxItems"); From 7a6035b002b6d08ec57a807d957914f9430e4397 Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 7 Dec 2016 14:36:05 +0200 Subject: [PATCH 0676/1491] TAS-2057: add core tests for getDeployment (get /deployments/{deploymentId}) --- .../deployments/GetDeploymentCoreTests.java | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentCoreTests.java new file mode 100644 index 000000000..34fbcc70e --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentCoreTests.java @@ -0,0 +1,73 @@ +package org.alfresco.rest.workflow.deployments; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestDeploymentModel; +import org.alfresco.rest.model.RestErrorModel; +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; + +/** + * Created by Claudia Agache on 12/7/2016. + */ +@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.CORE }) +public class GetDeploymentCoreTests extends RestTest +{ + private UserModel adminUser, adminTenantUser; + private RestDeploymentModel expectedDeployment, actualDeployment; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, + executionType = ExecutionType.REGRESSION, description = "Verify if get deployment request returns status code 404 when invalid deploymentId is used.") + public void getNonNetworkDeploymentUsingInvalidDeploymentId() throws Exception + { + expectedDeployment = restClient.authenticateUser(adminUser).withWorkflowAPI().getDeployments().getOneRandomEntry().onModel(); + expectedDeployment.setId("invalidId"); + + restClient.withWorkflowAPI().usingDeployment(expectedDeployment).getDeployment(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidId")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, + executionType = ExecutionType.REGRESSION, description = "Verify if network admin user gets a network deployment using REST API and status code is OK (200)") + @Test(groups = { TestGroup.NETWORKS }) + public void adminGetsNetworkDeploymentWithSuccess() throws Exception + { + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser) + .usingTenant().createTenant(adminTenantUser); + + expectedDeployment = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getDeployments().getOneRandomEntry().onModel(); + actualDeployment = restClient.withWorkflowAPI().usingDeployment(expectedDeployment).getDeployment(); + restClient.assertStatusCodeIs(HttpStatus.OK); + actualDeployment.assertThat().field("deployedAt").isNotEmpty() + .and().field("name").is(expectedDeployment.getName()) + .and().field("id").equals(expectedDeployment.getId()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, + executionType = ExecutionType.REGRESSION, description = "Verify non admin user is forbidden to get a network deployment using REST API (403)") + @Test(groups = { TestGroup.NETWORKS }) + public void nonAdminUserIsForbiddenToGetNetworkDeployment() throws Exception + { + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser) + .usingTenant().createTenant(adminTenantUser); + expectedDeployment = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getDeployments().getOneRandomEntry().onModel(); + UserModel tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + + restClient.authenticateUser(tenantUser).withWorkflowAPI().usingDeployment(expectedDeployment).getDeployment(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } +} From 6d7cd09f66a5075ad9505ecb5443e4a59c0a7dfe Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 7 Dec 2016 15:01:01 +0200 Subject: [PATCH 0677/1491] test: renamed variables --- .../sites/GetSiteContainersCoreTests.java | 117 ++++++++---------- 1 file changed, 53 insertions(+), 64 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersCoreTests.java index 65d39c2fd..00ceb0d2d 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersCoreTests.java @@ -17,47 +17,46 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) public class GetSiteContainersCoreTests extends RestTest { - private UserModel adminUserModel; - private SiteModel siteModel, siteModel1; + private SiteModel publicSiteModel, publicSiteWithContainers; private SiteModel moderatedSiteModel, privateSiteModel; - private ListUserWithRoles usersWithRoles; - private ListUserWithRoles usersWithRoles1; - + private ListUserWithRoles publicSiteUsers; + private ListUserWithRoles publicSiteWithContainersUsers; @BeforeClass(alwaysRun=true) public void dataPreparation() throws Exception { adminUserModel = dataUser.getAdminUser(); - - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - siteModel1 = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - moderatedSiteModel = dataSite.usingUser(adminUserModel).createModeratedRandomSite(); - privateSiteModel = dataSite.usingUser(adminUserModel).createPrivateRandomSite(); - - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - - usersWithRoles1 = dataUser.addUsersWithRolesToSite(siteModel1, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - - dataLink.usingAdmin().usingSite(siteModel1).createRandomLink(); - dataDiscussion.usingAdmin().usingSite(siteModel1).createRandomDiscussion(); - + + publicSiteModel = dataSite.usingAdmin().createPublicRandomSite(); + publicSiteWithContainers = dataSite.usingAdmin().createPublicRandomSite(); + moderatedSiteModel = dataSite.usingAdmin().createModeratedRandomSite(); + privateSiteModel = dataSite.usingAdmin().createPrivateRandomSite(); + + publicSiteUsers = dataUser + .addUsersWithRolesToSite(publicSiteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + + publicSiteWithContainersUsers = dataUser + .addUsersWithRolesToSite(publicSiteWithContainers, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + + dataLink.usingAdmin().usingSite(publicSiteWithContainers).createRandomLink(); + dataDiscussion.usingAdmin().usingSite(publicSiteWithContainers).createRandomDiscussion(); + dataLink.usingAdmin().usingSite(moderatedSiteModel).createRandomLink(); dataDiscussion.usingAdmin().usingSite(moderatedSiteModel).createRandomDiscussion(); - + dataLink.usingAdmin().usingSite(privateSiteModel).createRandomLink(); dataDiscussion.usingAdmin().usingSite(privateSiteModel).createRandomDiscussion(); } @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if get site container request returns status code 200 with valid maxItems parameter") - public void getContainersWithMaxItems() throws Exception + public void getContainersWithValidMaxItems() throws Exception { - restClient.authenticateUser(usersWithRoles1.getOneUserWithRole(UserRole.SiteManager)) + restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteManager)) .withParams("maxItems=5") - .withCoreAPI().usingSite(siteModel1).getSiteContainers() + .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() .assertThat().entriesListCountIs(3) .and().entriesListContains("folderId" ,ContainerName.documentLibrary.toString()) .and().entriesListContains("folderId", ContainerName.links.toString()) @@ -65,24 +64,23 @@ public class GetSiteContainersCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); restClient.withParams("maxItems=1") - .withCoreAPI().usingSite(siteModel1).getSiteContainers() + .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() .assertThat().entriesListCountIs(1); restClient.withParams("maxItems=3") - .withCoreAPI().usingSite(siteModel).getSiteContainers() + .withCoreAPI().usingSite(publicSiteModel).getSiteContainers() .assertThat().entriesListCountIs(1) .and().entriesListContains("folderId", ContainerName.documentLibrary.toString()); restClient.assertStatusCodeIs(HttpStatus.OK); - } @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if get site container request returns status code 400 when invalid maxItems parameter is used") public void getContainersWithMaxItemsZero () throws Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteManager)) .withParams("maxItems=0") - .withCoreAPI().usingSite(siteModel).getSiteContainers(); + .withCoreAPI().usingSite(publicSiteModel).getSiteContainers(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) .assertLastError().containsSummary("Only positive values supported for maxItems"); } @@ -91,20 +89,20 @@ public class GetSiteContainersCoreTests extends RestTest description= "Verify if get site container request returns status code 400 when invalid maxItems parameter is used") public void getContainersWithMaxItemsCharacter () throws Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)) .withParams("maxItems=test") - .withCoreAPI().usingSite(siteModel).getSiteContainers(); + .withCoreAPI().usingSite(publicSiteModel).getSiteContainers(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "test")); } @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if get site container request returns status code 400 when invalid maxItems parameter is used") + description= "Verify if get site container request returns status code 200 when maxItems parameter starts with multiple zero") public void getContainersWithMaxItemsMultipleZero () throws Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteCollaborator)) .withParams("maxItems=000007") - .withCoreAPI().usingSite(siteModel1).getSiteContainers() + .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() .assertThat().entriesListCountIs(3); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -113,52 +111,43 @@ public class GetSiteContainersCoreTests extends RestTest description= "Verify if get site container request returns status code 200 when valid skipCount parameter is used") public void getSitesWithValidSkipCount() throws Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withParams("skipCount=1") - .withCoreAPI().usingSite(siteModel).getSiteContainers() + restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteManager)).withParams("skipCount=1") + .withCoreAPI().usingSite(publicSiteModel).getSiteContainers() .assertThat().entriesListCountIs(0); restClient.assertStatusCodeIs(HttpStatus.OK); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withParams("skipCount=1") - .withCoreAPI().usingSite(siteModel1).getSiteContainers() + restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteCollaborator)).withParams("skipCount=1") + .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() .assertThat().entriesListCountIs(2); restClient.assertStatusCodeIs(HttpStatus.OK); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withParams("skipCount=2") - .withCoreAPI().usingSite(siteModel1).getSiteContainers() + restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteConsumer)).withParams("skipCount=2") + .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() .assertThat().entriesListCountIs(1); restClient.assertStatusCodeIs(HttpStatus.OK); - - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withParams("skipCount=0") - .withCoreAPI().usingSite(siteModel1).getSiteContainers() + + restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteCollaborator)).withParams("skipCount=0") + .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() .assertThat().entriesListCountIs(3); restClient.assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if get site container request returns status code 400 when invalid skipCount parameter is used") public void getSitesWithSkipCountCharacter() throws Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withParams("skipCount=abc") - .withCoreAPI().usingSite(siteModel).getSiteContainers(); + restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)).withParams("skipCount=abc") + .withCoreAPI().usingSite(publicSiteModel).getSiteContainers(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "abc")); } - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if get site container request returns status code 400 when invalid skipCount parameter is used") - public void getSitesWithSkipCountZero() throws Exception - { - } - - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if get site container request returns status code 400 when invalid skipCount parameter is used") + description= "Verify if get site container request returns status code 200 when skipCount parameter starts with multiple zero") public void getSitesWithSkipCountMultipleZero() throws Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withParams("skipCount=00002") - .withCoreAPI().usingSite(siteModel1).getSiteContainers() + restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)).withParams("skipCount=00002") + .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() .assertThat().entriesListCountIs(1); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -168,14 +157,14 @@ public class GetSiteContainersCoreTests extends RestTest description= "Verify if get site container request returns status code 400 when invalid skipCount parameter is used") public void getSiteContainerWithNonExistentSite() throws Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)) .withCoreAPI().usingSite("NonExistentSiteId").getSiteContainers(); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "NonExistentSiteId")); } @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify get site container request resturns status 200 for private site") + description= "Verify get site container request returns status 200 for private site") public void getSiteContainerForPrivateSite() throws Exception { restClient.authenticateUser(adminUserModel) @@ -185,7 +174,7 @@ public class GetSiteContainersCoreTests extends RestTest } @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify get site container request resturns status 200 for moderated site") + description= "Verify get site container request returns status 200 for moderated site") public void getSiteContainerForModeratedSite() throws Exception { restClient.authenticateUser(adminUserModel) @@ -195,11 +184,11 @@ public class GetSiteContainersCoreTests extends RestTest } @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify get site container request resturns status 200 for several container") + description= "Verify get site container request returns status 200 for several containers") public void getSiteContainerForSeveralItems() throws Exception { restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingSite(siteModel1).getSiteContainers() + .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() .assertThat().entriesListCountIs(3) .and().entriesListContains("folderId" ,ContainerName.documentLibrary.toString()) .and().entriesListContains("folderId", ContainerName.links.toString()) @@ -208,11 +197,11 @@ public class GetSiteContainersCoreTests extends RestTest } @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify get site container request resturns status 200 for one container") + description= "Verify get site container request returns status 200 for one container") public void getSiteContainerWithOneItem() throws Exception { restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingSite(siteModel).getSiteContainers() + .withCoreAPI().usingSite(publicSiteModel).getSiteContainers() .assertThat().entriesListCountIs(1) .and().entriesListContains("folderId" ,ContainerName.documentLibrary.toString()); restClient.assertStatusCodeIs(HttpStatus.OK); From 5a0d3a088522824edd104b98c87070ad6bd08a76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alecsandru=20Prun=C4=83?= Date: Wed, 7 Dec 2016 14:41:16 +0200 Subject: [PATCH 0678/1491] test: Added GetProcessDefinitionsCoreTests --- .../GetProcessDefinitionsCoreTests.java | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsCoreTests.java new file mode 100644 index 000000000..8655c177b --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsCoreTests.java @@ -0,0 +1,80 @@ +package org.alfresco.rest.workflow.processDefinitions; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.CORE }) +public class GetProcessDefinitionsCoreTests extends RestTest +{ + private UserModel adminUserModel; + private UserModel userModel; + private UserModel adminTenantUser; + private UserModel tenantUser; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + userModel = dataUser.createRandomTestUser(); + adminTenantUser = UserModel.getAdminTenantUser(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, + description = "Verify any user gets process definitions for non-network deployments using REST API and status code is OK (200)") + public void nonNetworkUserGetsProcessDefinitions() throws Exception + { + restClient.authenticateUser(userModel) + .withWorkflowAPI() + .getAllProcessDefinitions() + .assertThat().entriesListIsNotEmpty(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, + description = "Verify get process definitions using any network user for network enabled deployments with REST API status code is OK (200)") + @Test(groups = { TestGroup.NETWORKS }) + public void networkUserGetsProcessDefinitions() throws Exception + { + restClient.authenticateUser(adminUserModel).usingTenant().createTenant(adminTenantUser); + tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + restClient.authenticateUser(tenantUser) + .withWorkflowAPI() + .getAllProcessDefinitions() + .assertThat().entriesListIsNotEmpty(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, + description = "Verify call to get process definitions with invalid orderBy parameter with REST API and status code is BAD_REQUEST (400)") + public void userGetProcessDefinitionsWithInvalidOrderBy() throws Exception + { + restClient.authenticateUser(userModel) + .withParams("orderBy=test") + .withWorkflowAPI() + .getAllProcessDefinitions() + .assertThat().entriesListIsEmpty(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.PROCESS_DEFINITIONS_INVALID_ORDERBY, "test")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, + description = "Verify call to get process definitions with invalid where parameter with REST API and status code is BAD_REQUEST (400)") + public void userGetProcessDefinitionsWithInvalidWhere() throws Exception + { + restClient.authenticateUser(userModel) + .withParams("where=test") + .withWorkflowAPI() + .getAllProcessDefinitions() + .assertThat().entriesListIsEmpty(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.PROCESS_DEFINITIONS_INVALID_WHERE, "test")); + } +} From dea4820a56141d543895d15dc62419cc2532c126 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Wed, 7 Dec 2016 16:22:37 +0200 Subject: [PATCH 0679/1491] test: added core tests for AddProcess --- .../processes/AddProcessCoreTests.java | 122 ++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessCoreTests.java new file mode 100644 index 000000000..548ab78d2 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessCoreTests.java @@ -0,0 +1,122 @@ +package org.alfresco.rest.workflow.processes; + +import org.alfresco.dataprep.CMISUtil.Priority; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestProcessModelsCollection; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.testng.annotations.Test; + +/** + * + * @author Cristina Axinte + * + */ +@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) +public class AddProcessCoreTests extends RestTest +{ + private UserModel assignee, adminUser; + private RestProcessModel addedProcess; + private RestProcessModelsCollection processes; + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, + executionType = ExecutionType.REGRESSION, description = "Verify non network admin is able to start new process using REST API and status code is OK (200)") + public void nonNetworkAdminUserStartsNewProcess() throws JsonToModelConversionException, Exception + { + adminUser = dataUser.getAdminUser(); + assignee = dataUser.createRandomTestUser(); + + addedProcess = restClient.authenticateUser(adminUser).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + addedProcess.assertThat().field("id").is(addedProcess.getId()) + .and().field("startUserId").is(adminUser.getUsername()); + + processes = restClient.withWorkflowAPI().getProcesses(); + restClient.assertStatusCodeIs(HttpStatus.OK); + processes.assertThat().entriesListContains("id", addedProcess.getId()) + .assertThat().entriesListContains("processDefinitionId", "activitiAdhoc:1:4") + .assertThat().entriesListContains("startUserId", adminUser.getUsername()) + .assertThat().entriesListContains("startActivityId", "start") + .assertThat().entriesListContains("completed", "false") + .assertThat().entriesListContains("processDefinitionKey", "activitiAdhoc"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, + executionType = ExecutionType.REGRESSION, description = "Verify start new process with empty request body using REST API returns status code is Bad Request (400)") + public void startNewProcessWithEmptyProcessBody() throws JsonToModelConversionException, Exception + { + adminUser = dataUser.getAdminUser(); + assignee = dataUser.createRandomTestUser(); + + restClient.authenticateUser(adminUser).withWorkflowAPI(); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "", "processes"); + restClient.processModel(RestProcessModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.NO_CONTENT, "No content to map to Object due to end of input")); + } + + @Bug(id = "ACE-5671") + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, + executionType = ExecutionType.REGRESSION, description = "Verify start new process with invalid request body using REST API returns status code is Bad Request (400)") + public void startNewProcessWithInvalidProcessDefInProcessBody() throws JsonToModelConversionException, Exception + { + adminUser = dataUser.getAdminUser(); + assignee = dataUser.createRandomTestUser(); + + restClient.authenticateUser(adminUser).withWorkflowAPI(); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{\"processDefinitionKey\":\"activitiAdhoc\"}", "processes"); + restClient.processModel(RestProcessModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, + executionType = ExecutionType.REGRESSION, description = "Verify start new process with invalid request body using REST API returns status code is Bad Request (400)") + public void startNewProcessWithInvalidVariablesInProcessBody1() throws JsonToModelConversionException, Exception + { + adminUser = dataUser.getAdminUser(); + assignee = dataUser.createRandomTestUser(); + + restClient.authenticateUser(adminUser).withWorkflowAPI(); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{\"variables\":{\"bpm_sendEMailNotifications\":false}}", "processes"); + restClient.processModel(RestProcessModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format("Either processDefinitionId or processDefinitionKey is required")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, + executionType = ExecutionType.REGRESSION, description = "Verify start new process with invalid request body using REST API returns status code is Bad Request (400)") + public void startNewProcessWithInvalidVariablesInProcessBody2() throws JsonToModelConversionException, Exception + { + adminUser = dataUser.getAdminUser(); + assignee = dataUser.createRandomTestUser(); + + restClient.authenticateUser(adminUser).withWorkflowAPI(); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{\"variables\":{\"bpm_assignee\":\"admin\"}}", "processes"); + restClient.processModel(RestProcessModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format("Either processDefinitionId or processDefinitionKey is required")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, + executionType = ExecutionType.REGRESSION, description = "Verify start new process with invalid request body using REST API returns status code is Bad Request (400)") + public void startNewProcessWithInvalidVariablesInProcessBody3() throws JsonToModelConversionException, Exception + { + adminUser = dataUser.getAdminUser(); + assignee = dataUser.createRandomTestUser(); + + restClient.authenticateUser(adminUser).withWorkflowAPI(); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{\"variables\":{\"bpm_workflowPriority\":2}}", "processes"); + restClient.processModel(RestProcessModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format("Either processDefinitionId or processDefinitionKey is required")); + } +} From 4925c3410f7e108389de110f19ebbb9495e50bdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alecsandru=20Prun=C4=83?= Date: Wed, 7 Dec 2016 16:31:20 +0200 Subject: [PATCH 0680/1491] test: Removed redundant String.format from AddProcessCoreTests --- .../rest/workflow/processes/AddProcessCoreTests.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessCoreTests.java index 548ab78d2..676741b11 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessCoreTests.java @@ -89,7 +89,7 @@ public class AddProcessCoreTests extends RestTest RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{\"variables\":{\"bpm_sendEMailNotifications\":false}}", "processes"); restClient.processModel(RestProcessModel.class, request); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format("Either processDefinitionId or processDefinitionKey is required")); + .assertLastError().containsSummary("Either processDefinitionId or processDefinitionKey is required"); } @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, @@ -103,7 +103,7 @@ public class AddProcessCoreTests extends RestTest RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{\"variables\":{\"bpm_assignee\":\"admin\"}}", "processes"); restClient.processModel(RestProcessModel.class, request); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format("Either processDefinitionId or processDefinitionKey is required")); + .assertLastError().containsSummary("Either processDefinitionId or processDefinitionKey is required"); } @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, @@ -117,6 +117,6 @@ public class AddProcessCoreTests extends RestTest RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{\"variables\":{\"bpm_workflowPriority\":2}}", "processes"); restClient.processModel(RestProcessModel.class, request); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format("Either processDefinitionId or processDefinitionKey is required")); + .assertLastError().containsSummary("Either processDefinitionId or processDefinitionKey is required"); } } From ee926d81cd857d7b58d98567c12f240337be1a0d Mon Sep 17 00:00:00 2001 From: "NESS\\P3700299" Date: Wed, 7 Dec 2016 16:38:14 +0200 Subject: [PATCH 0681/1491] TAS-2043 --- .../rest/sites/GetSiteContainerCoreTests.java | 106 ++++++++++++++++++ .../sites/GetSiteContainersCoreTests.java | 8 +- 2 files changed, 110 insertions(+), 4 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/sites/GetSiteContainerCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerCoreTests.java new file mode 100644 index 000000000..e4062c749 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerCoreTests.java @@ -0,0 +1,106 @@ +package org.alfresco.rest.sites; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.utility.constants.ContainerName; +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; + +@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) +public class GetSiteContainerCoreTests extends RestTest{ + + private UserModel adminUserModel, testUserModel; + private SiteModel publicSiteWithContainers; + private SiteModel moderatedSiteModel, privateSiteModel; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + testUserModel = dataUser.createRandomTestUser(); + publicSiteWithContainers = dataSite.usingAdmin().createPublicRandomSite(); + moderatedSiteModel = dataSite.usingAdmin().createModeratedRandomSite(); + privateSiteModel = dataSite.usingAdmin().createPrivateRandomSite(); + + dataLink.usingAdmin().usingSite(publicSiteWithContainers).createRandomLink(); + dataDiscussion.usingAdmin().usingSite(publicSiteWithContainers).createRandomDiscussion(); + + dataLink.usingAdmin().usingSite(moderatedSiteModel).createRandomLink(); + dataDiscussion.usingAdmin().usingSite(moderatedSiteModel).createRandomDiscussion(); + + dataLink.usingAdmin().usingSite(privateSiteModel).createRandomLink(); + dataDiscussion.usingAdmin().usingSite(privateSiteModel).createRandomDiscussion(); + } + + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if get container request returns status code 400 when site doesn't exist") + public void getContainerWithNonExistentSite() throws Exception + { + restClient.authenticateUser(testUserModel) + .withCoreAPI().usingSite("NonExistentSiteId").getSiteContainer(ContainerName.discussions.toString()); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, "NonExistentSiteId", ContainerName.discussions.toString())); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if get container request returns status code 400 when container item doesn't exist") + public void getContainerWithNonExistentItem() throws Exception + { + restClient.authenticateUser(testUserModel) + .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainer("NonExistentFolder"); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, publicSiteWithContainers.getId(), "NonExistentFolder")); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify get container request returns status 200 for public site") + public void getContainerForPublicSite() throws Exception + { + restClient.authenticateUser(testUserModel) + .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainer(ContainerName.discussions.toString()) + .assertThat().field("folderId").is(ContainerName.discussions.toString()); + restClient.assertStatusCodeIs(HttpStatus.OK); + + restClient.authenticateUser(testUserModel) + .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainer(ContainerName.links.toString()) + .assertThat().field("folderId").is(ContainerName.links.toString()); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify get container request returns status 200 for private site") + public void getContainerForPrivateSite() throws Exception + { + restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingSite(privateSiteModel).getSiteContainer(ContainerName.discussions.toString()) + .assertThat().field("folderId").is(ContainerName.discussions.toString()); + restClient.assertStatusCodeIs(HttpStatus.OK); + + restClient.withCoreAPI().usingSite(privateSiteModel).getSiteContainer(ContainerName.links.toString()) + .assertThat().field("folderId").is(ContainerName.links.toString()); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify get container request returns status 200 for moderated site") + public void getContainerForModeratedSite() throws Exception + { + restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingSite(moderatedSiteModel).getSiteContainer(ContainerName.discussions.toString()) + .assertThat().field("folderId").is(ContainerName.discussions.toString()); + restClient.assertStatusCodeIs(HttpStatus.OK); + + restClient.withCoreAPI().usingSite(moderatedSiteModel).getSiteContainer(ContainerName.links.toString()) + .assertThat().field("folderId").is(ContainerName.links.toString()); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + +} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersCoreTests.java index 00ceb0d2d..17e15ae42 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersCoreTests.java @@ -109,7 +109,7 @@ public class GetSiteContainersCoreTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if get site container request returns status code 200 when valid skipCount parameter is used") - public void getSitesWithValidSkipCount() throws Exception + public void getSiteContainerWithValidSkipCount() throws Exception { restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteManager)).withParams("skipCount=1") .withCoreAPI().usingSite(publicSiteModel).getSiteContainers() @@ -134,7 +134,7 @@ public class GetSiteContainersCoreTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if get site container request returns status code 400 when invalid skipCount parameter is used") - public void getSitesWithSkipCountCharacter() throws Exception + public void getSiteContainerWithSkipCountCharacter() throws Exception { restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)).withParams("skipCount=abc") .withCoreAPI().usingSite(publicSiteModel).getSiteContainers(); @@ -144,7 +144,7 @@ public class GetSiteContainersCoreTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if get site container request returns status code 200 when skipCount parameter starts with multiple zero") - public void getSitesWithSkipCountMultipleZero() throws Exception + public void getSiteContainerWithSkipCountMultipleZero() throws Exception { restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)).withParams("skipCount=00002") .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() @@ -154,7 +154,7 @@ public class GetSiteContainersCoreTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if get site container request returns status code 400 when invalid skipCount parameter is used") + description= "Verify if get site container request returns status code 400 when site doesn't exist") public void getSiteContainerWithNonExistentSite() throws Exception { restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)) From 355084a3b8ca9a78e6ec211f97f606a2f75c8f39 Mon Sep 17 00:00:00 2001 From: Bogdan Bocancea Date: Wed, 7 Dec 2016 16:56:03 +0200 Subject: [PATCH 0682/1491] TAS-2077: add core tests for get '/tasks/{taskId}/task-form-model' request --- .../tasks/GetTaskFormModelCoreTests.java | 101 ++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelCoreTests.java new file mode 100644 index 000000000..479789cff --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelCoreTests.java @@ -0,0 +1,101 @@ +package org.alfresco.rest.workflow.tasks; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestFormModelsCollection; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TaskModel; +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 bogdan.bocancea + * + */ +@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) +public class GetTaskFormModelCoreTests extends RestTest +{ + UserModel userModel; + SiteModel siteModel; + FileModel fileModel; + TaskModel taskModel; + RestFormModelsCollection returnedCollection; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + fileModel = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, + executionType = ExecutionType.REGRESSION, + description = "Verify that non involved user in task cannot get form models with Rest API and response is FORBIDDEN (403)") + public void nonInvolvedUserCannotGetTaskFormModels() throws Exception + { + taskModel = dataWorkflow.usingUser(userModel) + .usingSite(siteModel) + .usingResource(fileModel).createNewTaskAndAssignTo(userModel); + UserModel nonInvolvedUser = dataUser.createRandomTestUser(); + restClient.authenticateUser(nonInvolvedUser); + restClient.withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, + executionType = ExecutionType.REGRESSION, + description = "Verify user involved in task cannot get task form models with invalid task id") + public void getTaskFormModelsInvalidTaskId() throws Exception + { + taskModel = dataWorkflow.usingUser(userModel) + .usingSite(siteModel) + .usingResource(fileModel).createNewTaskAndAssignTo(userModel); + taskModel.setId("0000"); + restClient.authenticateUser(userModel); + restClient.withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "0000")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, + executionType = ExecutionType.REGRESSION, + description = "Verify user involved in task cannot get task form models with invalid task id") + public void getTaskFormModelsEmptyTaskId() throws Exception + { + taskModel = dataWorkflow.usingUser(userModel) + .usingSite(siteModel) + .usingResource(fileModel).createNewTaskAndAssignTo(userModel); + taskModel.setId(""); + restClient.authenticateUser(userModel); + restClient.withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, + executionType = ExecutionType.REGRESSION, + description = "Verify user involved in task cannot get completed task form models") + public void getTaskFormModelsForCompletedTask() throws Exception + { + UserModel assignedUser = dataUser.createRandomTestUser(); + taskModel = dataWorkflow.usingUser(userModel) + .usingSite(siteModel) + .usingResource(fileModel).createNewTaskAndAssignTo(assignedUser); + dataWorkflow.usingUser(assignedUser).taskDone(taskModel); + dataWorkflow.usingUser(userModel).taskDone(taskModel); + restClient.authenticateUser(userModel); + returnedCollection = restClient.withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat().entriesListIsNotEmpty(); + } +} \ No newline at end of file From b887a6fcff1725141cc09a0aadc66cdd16e69dc5 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Wed, 7 Dec 2016 17:18:57 +0200 Subject: [PATCH 0683/1491] Merge master into TAS-2039 --- .../alfresco/rest/ratings/GetRatingCoreTests.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/ratings/GetRatingCoreTests.java b/e2e-test/java/org/alfresco/rest/ratings/GetRatingCoreTests.java index 6cbef9d9e..38c120997 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/GetRatingCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/GetRatingCoreTests.java @@ -1,12 +1,11 @@ package org.alfresco.rest.ratings; -import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestRatingModel; import org.alfresco.utility.exception.DataPreparationException; -import org.alfresco.utility.model.ErrorModel; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; @@ -17,7 +16,6 @@ import org.alfresco.utility.testrail.annotation.TestRail; import org.apache.commons.lang.RandomStringUtils; import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; -import org.testng.Assert; import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -42,7 +40,7 @@ public class GetRatingCoreTests extends RestTest @BeforeMethod(alwaysRun = true) public void setUp() throws DataPreparationException, Exception { - document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); + document = dataContent.usingSite(siteModel).usingAdmin().createContent(DocumentType.TEXT_PLAIN); } @TestRail(section = { TestGroup.REST_API, @@ -52,7 +50,7 @@ public class GetRatingCoreTests extends RestTest restClient.authenticateUser(adminUserModel).withCoreAPI(); RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "nodes/{nodeId}/ratings/{ratingId}", document.getNodeRef(), "invalid ratingId"); restClient.processModel(RestRatingModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("invalid ratingId"); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_RATING, "invalid ratingId")); } @TestRail(section = { TestGroup.REST_API, @@ -63,7 +61,7 @@ public class GetRatingCoreTests extends RestTest returnedRatingModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getFiveStarRating(); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, document.getNodeRef())); + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, document.getNodeRef())); } @TestRail(section = { TestGroup.REST_API, @@ -142,4 +140,4 @@ public class GetRatingCoreTests extends RestTest returnedRatingModel.getAggregate().assertThat().field("numberOfRatings").is("0"); } -} +} \ No newline at end of file From f73147d4c294197b09423e6a51d94b352bbfb7ba Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 7 Dec 2016 17:35:53 +0200 Subject: [PATCH 0684/1491] TAS-2068: add core tests for getTaskVariables (get /tasks/{taskId}/variables) --- .../tasks/GetTaskVariablesCoreTests.java | 107 ++++++++++++++++++ .../tasks/GetTaskVariablesSanityTests.java | 3 +- 2 files changed, 109 insertions(+), 1 deletion(-) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskVariablesCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskVariablesCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskVariablesCoreTests.java new file mode 100644 index 000000000..d10abe588 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskVariablesCoreTests.java @@ -0,0 +1,107 @@ +package org.alfresco.rest.workflow.tasks; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestTaskModel; +import org.alfresco.rest.model.RestVariableModelsCollection; +import org.alfresco.utility.model.*; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Created by Claudia Agache on 12/7/2016. + */ +@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) +public class GetTaskVariablesCoreTests extends RestTest +{ + private UserModel userWhoStartsTask, assignee; + private SiteModel siteModel; + private FileModel fileModel; + private TaskModel taskModel; + private RestVariableModelsCollection variableModels; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + userWhoStartsTask = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); + fileModel = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify if get task variables request returns status code 404 when invalid taskId is used") + public void getTaskVariablesUsingInvalidTaskId() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); + taskModel.setId("invalidId"); + + restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingTask(taskModel).getTaskVariables(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidId")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify if get task variables request returns status code 404 when empty taskId is used") + public void getTaskVariablesUsingEmptyTaskId() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); + taskModel.setId(""); + + restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingTask(taskModel).getTaskVariables(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify if get task variables request returns status code 200 after the task is finished.") + public void getTaskVariablesAfterFinishingTask() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); + dataWorkflow.usingUser(assignee).taskDone(taskModel); + + variableModels = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingTask(taskModel).getTaskVariables(); + restClient.assertStatusCodeIs(HttpStatus.OK); + variableModels.assertThat().entriesListIsNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify if get task variables request returns status code 200 after the process is deleted (Task state is now completed.)") + public void getTaskVariablesAfterDeletingProcess() throws Exception + { + RestProcessModel addedProcess = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.Normal); + RestTaskModel addedTask = restClient.withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess); + restClient.withWorkflowAPI().usingProcess(addedProcess).deleteProcess(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + variableModels = restClient.withWorkflowAPI().usingTask(addedTask).getTaskVariables(); + restClient.assertStatusCodeIs(HttpStatus.OK); + variableModels.assertThat().entriesListIsNotEmpty(); + } + + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify user gets task variables that matches a where clause.") + public void getTaskVariablesWithWhereClauseAsParameter() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); + variableModels = restClient.authenticateUser(userWhoStartsTask).where("scope='local'") + .withWorkflowAPI().usingTask(taskModel).getTaskVariables(); + restClient.assertStatusCodeIs(HttpStatus.OK); + variableModels.assertThat().entriesListIsNotEmpty() + .and().entriesListDoesNotContain("scope", "global") + .and().paginationField("totalItems").is("8"); + + variableModels = restClient.authenticateUser(userWhoStartsTask) + .withWorkflowAPI().usingTask(taskModel).getTaskVariables(); + restClient.assertStatusCodeIs(HttpStatus.OK); + variableModels.assertThat().entriesListContains("scope", "global") + .and().paginationField("totalItems").is("30"); + } + +} diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskVariablesSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskVariablesSanityTests.java index 33aabaffc..542e1da12 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskVariablesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskVariablesSanityTests.java @@ -2,6 +2,7 @@ package org.alfresco.rest.workflow.tasks; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestVariableModelsCollection; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; @@ -65,7 +66,7 @@ public class GetTaskVariablesSanityTests extends RestTest restClient.authenticateUser(randomUser); restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, From cba1f602a7bb92b010ba2d2cc3a93953bcd5fa38 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Wed, 7 Dec 2016 17:58:10 +0200 Subject: [PATCH 0685/1491] Added addSiteMember Core Tests --- .../rest/sites/AddSiteMemberCoreTests.java | 289 ++++++++++++++++++ 1 file changed, 289 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/sites/AddSiteMemberCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberCoreTests.java new file mode 100644 index 000000000..dc743c453 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberCoreTests.java @@ -0,0 +1,289 @@ +package org.alfresco.rest.sites; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.JsonBodyGenerator; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestSiteMemberModel; +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.HttpMethod; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) +public class AddSiteMemberCoreTests extends RestTest +{ + private UserModel adminUserModel; + private SiteModel publicSiteModel; + private SiteModel moderatedSiteModel; + private SiteModel privateSiteModel; + private ListUserWithRoles usersWithRolesToMoedratedSite; + private ListUserWithRoles usersWithRolesToPrivateSite; + private String addMembersJson; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + publicSiteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + moderatedSiteModel = dataSite.usingUser(adminUserModel).createModeratedRandomSite(); + privateSiteModel = dataSite.usingUser(adminUserModel).createPrivateRandomSite(); + usersWithRolesToMoedratedSite = dataUser.addUsersWithRolesToSite(moderatedSiteModel, UserRole.SiteManager, UserRole.SiteCollaborator, + UserRole.SiteConsumer,UserRole.SiteContributor); + usersWithRolesToPrivateSite = dataUser.addUsersWithRolesToSite(privateSiteModel, UserRole.SiteManager, UserRole.SiteCollaborator, + UserRole.SiteConsumer,UserRole.SiteContributor); + addMembersJson = "{\"role\":\"%s\",\"id\":\"%s\"}, {\"role\":\"%s\",\"id\":\"%s\"}"; + + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that manager can add another user as manager to a public site and gets status code CREATED (201)") + public void addManagerToPublicSite() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteManager); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(testUser) + .assertThat().field("id").is(testUser.getUsername()) + .and().field("role").is(testUser.getUserRole()); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that manager can add another user as manager to a moderated site and gets status code CREATED (201)") + public void addManagerToModeratedSite() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteManager); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(testUser) + .assertThat().field("id").is(testUser.getUsername()) + .and().field("role").is(testUser.getUserRole()); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that manager can add another user as manager to a private site and gets status code CREATED (201)") + public void addManagerToPrivateSite() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteManager); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(testUser) + .assertThat().field("id").is(testUser.getUsername()) + .and().field("role").is(testUser.getUserRole()); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that consumer role is not able to add another user to a moderated site and gets status code 403") + public void addUserByConsumerToModeratedSite() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteConsumer); + restClient.authenticateUser(usersWithRolesToMoedratedSite.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingSite(moderatedSiteModel).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that consumer role is not able to add another user to a private site and gets status code 403") + public void addUserByConsumerToPrivateSite() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteConsumer); + restClient.authenticateUser(usersWithRolesToPrivateSite.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingSite(privateSiteModel).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that collaborator role is not able to add another user to a moderated site and gets status code 403") + public void addUserByCollaboratorToModeratedSite() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteConsumer); + restClient.authenticateUser(usersWithRolesToMoedratedSite.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingSite(moderatedSiteModel).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that collaborator role is not able to add another user to a private site and gets status code 403") + public void addUserByCollaboratorToPrivateSite() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteConsumer); + restClient.authenticateUser(usersWithRolesToPrivateSite.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingSite(privateSiteModel).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that contributor role is not able to add another user to a moderated site and gets status code 403") + public void addUserByContributorToModeratedSite() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteConsumer); + restClient.authenticateUser(usersWithRolesToMoedratedSite.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingSite(moderatedSiteModel).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that contributor role is not able to add another user to a private site and gets status code 403") + public void addUserByContributorToPrivateSite() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteConsumer); + restClient.authenticateUser(usersWithRolesToPrivateSite.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingSite(privateSiteModel).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that a user without specified role can not be added to a site and gets status code 400") + public void canNotAddUserWithoutSpecifyingRoleToSite() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + restClient.authenticateUser(adminUserModel).withCoreAPI(); + String json = JsonBodyGenerator.keyValueJson("id",testUser.getUsername()); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, json, "sites/{siteId}/members?{parameters}", publicSiteModel.getId(), restClient.getParameters()); + restClient.processModel(RestSiteMemberModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(RestErrorModel.MUST_PROVIDE_ROLE); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that a user with inexistent role can not be added to a site and gets status code 400") + public void canNotAddUserWithInexistentRoleToSite() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + restClient.authenticateUser(adminUserModel).withCoreAPI(); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, String.format("{\"role\":\"inexistentRole\",\"id\":\"%s\"}", testUser.getUsername()), "sites/{siteId}/members?{parameters}", publicSiteModel.getId(), restClient.getParameters()); + restClient.processModel(RestSiteMemberModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.UNKNOWN_ROLE, "inexistentRole")); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that user can not add himself as a manager to a public site and gets status code 403") + public void userAddHimselfToPublicSite() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteManager); + restClient.authenticateUser(testUser).withCoreAPI().usingSite(publicSiteModel).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that user can not add himself as a manager to a moderated site and gets status code 403") + public void userAddHimselfToModeratedSite() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteManager); + restClient.authenticateUser(testUser).withCoreAPI().usingSite(moderatedSiteModel).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that user can not add himself as a manager to a private site and gets status code 404") + public void userAddHimselfToPrivateSite() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteManager); + restClient.authenticateUser(testUser).withCoreAPI().usingSite(privateSiteModel).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, privateSiteModel.getId())); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that user can not be added to an inexistent site and gets status code 404") + public void userIsNotAbleToAddUserToAnInexistentSite() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteManager); + SiteModel inexistentSite = new SiteModel("inexistentSite"); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(inexistentSite).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, inexistentSite.getId())); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that user can not be added to an empty site id and gets status code 404") + public void userIsNotAbleToAddUserToEmptySiteId() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteManager); + SiteModel inexistentSite = new SiteModel(""); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(inexistentSite).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, inexistentSite.getId())); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that inexistent user can not be added to site and gets status code 404") + public void userIsNotAbleToAddInexistentUserToSite() throws Exception + { + UserModel testUser = new UserModel("inexistentUser", "password"); + testUser.setUserRole(UserRole.SiteManager); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, testUser.getUsername())); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that inexistet user can not be added to site and gets status code 400") + public void userIsNotAbleToAddEmptyUserIdToSite() throws Exception + { + UserModel testUser = new UserModel("", "password"); + testUser.setUserRole(UserRole.SiteManager); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.NO_CONTENT, testUser.getUsername())); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that user can not add another user that is already a memeber and gets status code 409") + public void userIsNotAbleToAddUserThatIsAlreadyAMember() throws Exception + { + UserModel collaborator = usersWithRolesToMoedratedSite.getOneUserWithRole(UserRole.SiteCollaborator); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(collaborator); + restClient.assertStatusCodeIs(HttpStatus.CONFLICT).assertLastError().containsSummary(String.format(RestErrorModel.ALREADY_Site_MEMBER, collaborator.getUsername(), moderatedSiteModel.getId())); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that several users with different roles can be added once in a row to a site and gets status code 201") + public void addSeveralUsersWithDifferentRolesToASite() throws Exception + { + UserModel firstUser = dataUser.createRandomTestUser("testUser"); + firstUser.setUserRole(UserRole.SiteContributor); + UserModel secondUser = dataUser.createRandomTestUser("testUser"); + secondUser.setUserRole(UserRole.SiteCollaborator); + restClient.authenticateUser(adminUserModel).withCoreAPI(); + String json = String.format(addMembersJson, firstUser.getUserRole(), firstUser.getUsername(), secondUser.getUserRole(), secondUser.getUsername()); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, json, "sites/{siteId}/members?{parameters}", publicSiteModel.getId(), restClient.getParameters()); + restClient.processModel(RestSiteMemberModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that several users with same roles can be added once in a row to a site and gets status code 201") + public void addSeveralUsersWithSameRolesToASite() throws Exception + { + UserModel firstUser = dataUser.createRandomTestUser("testUser"); + firstUser.setUserRole(UserRole.SiteCollaborator); + UserModel secondUser = dataUser.createRandomTestUser("testUser"); + secondUser.setUserRole(UserRole.SiteCollaborator); + restClient.authenticateUser(adminUserModel).withCoreAPI(); + String json = String.format(addMembersJson, firstUser.getUserRole(), firstUser.getUsername(), secondUser.getUserRole(), secondUser.getUsername()); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, json, "sites/{siteId}/members?{parameters}", publicSiteModel.getId(), restClient.getParameters()); + restClient.processModel(RestSiteMemberModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that several users that are already added to the site can not be added once in a row and gets status code 400") + public void addSeveralUsersThatAreAlreadyAddedToASite() throws Exception + { + UserModel collaborator = usersWithRolesToMoedratedSite.getOneUserWithRole(UserRole.SiteCollaborator); + UserModel consumer = usersWithRolesToMoedratedSite.getOneUserWithRole(UserRole.SiteConsumer); + restClient.authenticateUser(adminUserModel).withCoreAPI(); + String json = String.format(addMembersJson, collaborator.getUserRole(), collaborator.getUsername(), consumer.getUserRole(), consumer.getUsername()); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, json, "sites/{siteId}/members?{parameters}", moderatedSiteModel.getId(), restClient.getParameters()); + restClient.processModel(RestSiteMemberModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.CONFLICT).assertLastError().containsSummary(String.format(RestErrorModel.ALREADY_Site_MEMBER, collaborator.getUsername(), moderatedSiteModel.getId())); + } + +} From 8c281011a51f95537bc22cc0450952a7f2d0bd30 Mon Sep 17 00:00:00 2001 From: cagache Date: Thu, 8 Dec 2016 09:36:18 +0200 Subject: [PATCH 0686/1491] test: changed TestGroup and renamed a variable --- .../rest/sites/GetSiteContainerCoreTests.java | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerCoreTests.java index e4062c749..fcffac5d4 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerCoreTests.java @@ -12,24 +12,23 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) +@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) public class GetSiteContainerCoreTests extends RestTest{ private UserModel adminUserModel, testUserModel; - private SiteModel publicSiteWithContainers; - private SiteModel moderatedSiteModel, privateSiteModel; + private SiteModel publicSiteModel, moderatedSiteModel, privateSiteModel; @BeforeClass(alwaysRun=true) public void dataPreparation() throws Exception { adminUserModel = dataUser.getAdminUser(); testUserModel = dataUser.createRandomTestUser(); - publicSiteWithContainers = dataSite.usingAdmin().createPublicRandomSite(); + publicSiteModel = dataSite.usingAdmin().createPublicRandomSite(); moderatedSiteModel = dataSite.usingAdmin().createModeratedRandomSite(); privateSiteModel = dataSite.usingAdmin().createPrivateRandomSite(); - dataLink.usingAdmin().usingSite(publicSiteWithContainers).createRandomLink(); - dataDiscussion.usingAdmin().usingSite(publicSiteWithContainers).createRandomDiscussion(); + dataLink.usingAdmin().usingSite(publicSiteModel).createRandomLink(); + dataDiscussion.usingAdmin().usingSite(publicSiteModel).createRandomDiscussion(); dataLink.usingAdmin().usingSite(moderatedSiteModel).createRandomLink(); dataDiscussion.usingAdmin().usingSite(moderatedSiteModel).createRandomDiscussion(); @@ -54,9 +53,9 @@ public class GetSiteContainerCoreTests extends RestTest{ public void getContainerWithNonExistentItem() throws Exception { restClient.authenticateUser(testUserModel) - .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainer("NonExistentFolder"); + .withCoreAPI().usingSite(publicSiteModel).getSiteContainer("NonExistentFolder"); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, publicSiteWithContainers.getId(), "NonExistentFolder")); + .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, publicSiteModel.getId(), "NonExistentFolder")); } @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, @@ -64,12 +63,12 @@ public class GetSiteContainerCoreTests extends RestTest{ public void getContainerForPublicSite() throws Exception { restClient.authenticateUser(testUserModel) - .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainer(ContainerName.discussions.toString()) + .withCoreAPI().usingSite(publicSiteModel).getSiteContainer(ContainerName.discussions.toString()) .assertThat().field("folderId").is(ContainerName.discussions.toString()); restClient.assertStatusCodeIs(HttpStatus.OK); restClient.authenticateUser(testUserModel) - .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainer(ContainerName.links.toString()) + .withCoreAPI().usingSite(publicSiteModel).getSiteContainer(ContainerName.links.toString()) .assertThat().field("folderId").is(ContainerName.links.toString()); restClient.assertStatusCodeIs(HttpStatus.OK); } From 2f1f46c5c7c112466fa17602786272c04a27bb6d Mon Sep 17 00:00:00 2001 From: cagache Date: Thu, 8 Dec 2016 09:40:24 +0200 Subject: [PATCH 0687/1491] test: renamed tests --- .../sites/GetSiteContainersCoreTests.java | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersCoreTests.java index 17e15ae42..aeac1f680 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersCoreTests.java @@ -108,8 +108,8 @@ public class GetSiteContainersCoreTests extends RestTest } @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if get site container request returns status code 200 when valid skipCount parameter is used") - public void getSiteContainerWithValidSkipCount() throws Exception + description= "Verify if get site containers request returns status code 200 when valid skipCount parameter is used") + public void getSiteContainersWithValidSkipCount() throws Exception { restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteManager)).withParams("skipCount=1") .withCoreAPI().usingSite(publicSiteModel).getSiteContainers() @@ -133,8 +133,8 @@ public class GetSiteContainersCoreTests extends RestTest } @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if get site container request returns status code 400 when invalid skipCount parameter is used") - public void getSiteContainerWithSkipCountCharacter() throws Exception + description= "Verify if get site containers request returns status code 400 when invalid skipCount parameter is used") + public void getSiteContainersWithSkipCountCharacter() throws Exception { restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)).withParams("skipCount=abc") .withCoreAPI().usingSite(publicSiteModel).getSiteContainers(); @@ -143,8 +143,8 @@ public class GetSiteContainersCoreTests extends RestTest } @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if get site container request returns status code 200 when skipCount parameter starts with multiple zero") - public void getSiteContainerWithSkipCountMultipleZero() throws Exception + description= "Verify if get site containers request returns status code 200 when skipCount parameter starts with multiple zero") + public void getSiteContainersWithSkipCountMultipleZero() throws Exception { restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)).withParams("skipCount=00002") .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() @@ -154,8 +154,8 @@ public class GetSiteContainersCoreTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if get site container request returns status code 400 when site doesn't exist") - public void getSiteContainerWithNonExistentSite() throws Exception + description= "Verify if get site containers request returns status code 400 when site doesn't exist") + public void getSiteContainersWithNonExistentSite() throws Exception { restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)) .withCoreAPI().usingSite("NonExistentSiteId").getSiteContainers(); @@ -164,8 +164,8 @@ public class GetSiteContainersCoreTests extends RestTest } @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify get site container request returns status 200 for private site") - public void getSiteContainerForPrivateSite() throws Exception + description= "Verify get site containers request returns status 200 for private site") + public void getSiteContainersForPrivateSite() throws Exception { restClient.authenticateUser(adminUserModel) .withCoreAPI().usingSite(privateSiteModel).getSiteContainers() @@ -174,8 +174,8 @@ public class GetSiteContainersCoreTests extends RestTest } @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify get site container request returns status 200 for moderated site") - public void getSiteContainerForModeratedSite() throws Exception + description= "Verify get site containers request returns status 200 for moderated site") + public void getSiteContainersForModeratedSite() throws Exception { restClient.authenticateUser(adminUserModel) .withCoreAPI().usingSite(moderatedSiteModel).getSiteContainers() @@ -184,8 +184,8 @@ public class GetSiteContainersCoreTests extends RestTest } @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify get site container request returns status 200 for several containers") - public void getSiteContainerForSeveralItems() throws Exception + description= "Verify get site containers request returns status 200 for several containers") + public void getSiteContainersForSeveralItems() throws Exception { restClient.authenticateUser(adminUserModel) .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() @@ -197,8 +197,8 @@ public class GetSiteContainersCoreTests extends RestTest } @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify get site container request returns status 200 for one container") - public void getSiteContainerWithOneItem() throws Exception + description= "Verify get site containers request returns status 200 for one container") + public void getSiteContainersWithOneItem() throws Exception { restClient.authenticateUser(adminUserModel) .withCoreAPI().usingSite(publicSiteModel).getSiteContainers() From 70e17052d37afcc8e1422ede87b886286d00d8fe Mon Sep 17 00:00:00 2001 From: Bogdan Bocancea Date: Thu, 8 Dec 2016 10:23:27 +0200 Subject: [PATCH 0688/1491] TAS-2085: add core tests for 'get /tasks/{taskId}/candidates' request. Rename GetTaskCandidatesTests to GetTaskCandidatesSanityTests --- .../tasks/GetTaskCandidatesCoreTests.java | 104 ++++++++++++++++++ ...java => GetTaskCandidatesSanityTests.java} | 2 +- 2 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCandidatesCoreTests.java rename e2e-test/java/org/alfresco/rest/workflow/tasks/{GetTaskCandidatesTests.java => GetTaskCandidatesSanityTests.java} (98%) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCandidatesCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCandidatesCoreTests.java new file mode 100644 index 000000000..04251ad60 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCandidatesCoreTests.java @@ -0,0 +1,104 @@ +package org.alfresco.rest.workflow.tasks; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.GroupModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TaskModel; +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 bogdan.bocancea + * + */ +@Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) +public class GetTaskCandidatesCoreTests extends RestTest +{ + private UserModel userModel, userModel1, userModel2; + private SiteModel siteModel; + private FileModel fileModel; + private TaskModel taskModel; + private GroupModel group; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + userModel1 = dataUser.createRandomTestUser(); + userModel2 = dataUser.createRandomTestUser(); + group = dataGroup.createRandomGroup(); + dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify get task candidates with invalid task id") + public void getTaskCandidatesWithInvalidTaskId() throws Exception + { + taskModel = dataWorkflow.usingUser(userModel) + .usingSite(siteModel) + .usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); + taskModel.setId("invalid-id"); + restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).getTaskCandidates(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalid-id")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify get task candidates with empty task id") + public void getTaskCandidatesWithEmptyTaskId() throws Exception + { + taskModel = dataWorkflow.usingUser(userModel) + .usingSite(siteModel) + .usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); + taskModel.setId(""); + restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).getTaskCandidates(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify get task candidates for completed task") + public void getTaskCandidatesForCompletedTask() throws Exception + { + taskModel = dataWorkflow.usingUser(userModel) + .usingSite(siteModel) + .usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); + + restClient.authenticateUser(userModel1).withWorkflowAPI().usingTask(taskModel).getTaskCandidates(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + dataWorkflow.usingUser(userModel1).taskDone(taskModel); + + restClient.authenticateUser(userModel1).withWorkflowAPI().usingTask(taskModel).getTaskCandidates(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, taskModel.getId())); + + restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).getTaskCandidates(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, taskModel.getId())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify get task candidates by non candidate user") + public void getTaskCandidatesByNonCandidateUser() throws Exception + { + UserModel outsider = dataUser.createRandomTestUser(); + taskModel = dataWorkflow.usingUser(userModel) + .usingSite(siteModel) + .usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); + restClient.authenticateUser(outsider).withWorkflowAPI().usingTask(taskModel).getTaskCandidates(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } +} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCandidatesTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCandidatesSanityTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCandidatesTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCandidatesSanityTests.java index 9832f5818..8dd4f7095 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCandidatesTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCandidatesSanityTests.java @@ -21,7 +21,7 @@ import org.testng.annotations.Test; * */ @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) -public class GetTaskCandidatesTests extends RestTest +public class GetTaskCandidatesSanityTests extends RestTest { private UserModel userModel, user, userModel1, userModel2; private SiteModel siteModel; From d58bd126866ec13304923e30ae482de4fedbd761 Mon Sep 17 00:00:00 2001 From: cagache Date: Thu, 8 Dec 2016 10:30:39 +0200 Subject: [PATCH 0689/1491] test: added bug annotation --- .../GetProcessDefinitionImageCoreTests.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageCoreTests.java index 2314eb85d..782030919 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageCoreTests.java @@ -5,6 +5,7 @@ import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessDefinitionModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -45,6 +46,7 @@ public class GetProcessDefinitionImageCoreTests extends RestTest executionType = ExecutionType.REGRESSION, description = "Verify network admin is able to get a process definition image using REST API and status code is OK (200)") @Test(groups = { TestGroup.NETWORKS }) + @Bug(id = "MNT-17243") public void networkAdminGetProcessDefinitionImage() throws Exception { adminTenantUser = UserModel.getAdminTenantUser(); @@ -61,6 +63,7 @@ public class GetProcessDefinitionImageCoreTests extends RestTest executionType = ExecutionType.REGRESSION, description = "Verify network user is able to get a process definition image using REST API and status code is OK (200)") @Test(groups = { TestGroup.NETWORKS }) + @Bug(id = "MNT-17243") public void networkUserGetProcessDefinitionImage() throws Exception { adminTenantUser = UserModel.getAdminTenantUser(); @@ -76,5 +79,4 @@ public class GetProcessDefinitionImageCoreTests extends RestTest .assertResponseContainsImage(); restClient.assertStatusCodeIs(HttpStatus.OK); } - } From fe40f214fc0b2780a8f3a17d3218ea5ac5a6bdc8 Mon Sep 17 00:00:00 2001 From: mionescu Date: Thu, 8 Dec 2016 11:03:08 +0200 Subject: [PATCH 0690/1491] test added: AddTaskItemCoreTests --- .../workflow/tasks/AddTaskItemCoreTests.java | 114 ++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemCoreTests.java new file mode 100644 index 000000000..33a400262 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemCoreTests.java @@ -0,0 +1,114 @@ +package org.alfresco.rest.workflow.tasks; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestItemModel; +import org.alfresco.rest.model.RestVariableModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TaskModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) +public class AddTaskItemCoreTests extends RestTest +{ + private UserModel userModel, assigneeUser; + private SiteModel siteModel; + private FileModel fileModel, document2, document3, document4, document5; + private TaskModel taskModel; + private RestItemModel taskItem; + + private UserModel adminUser; + private String taskId; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + assigneeUser = dataUser.createRandomTestUser(); + taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + + adminUser = dataUser.getAdminUser(); + taskId = taskModel.getId(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Add task item using admin user from same network") + public void addTaskItemByRandomUser() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(userModel); + document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + + taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + taskItem.assertThat().field("createdAt").is(taskItem.getCreatedAt()).assertThat().field("size").is(taskItem.getSize()).and().field("createdBy") + .is(taskItem.getCreatedBy()).and().field("modifiedAt").is(taskItem.getModifiedAt()).and().field("name").is(taskItem.getName()).and() + .field("modifiedBy").is(taskItem.getModifiedBy()).and().field("id").is(taskItem.getId()).and().field("mimeType").is(taskItem.getMimeType()); + + taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task item, is falling in case invalid itemBody is provided") + public void failedAddingTaskItemIfInvalidItemBodyIsProvided() throws Exception + { + restClient.authenticateUser(adminUser); + document3 = dataContent.usingSite(siteModel).createContent(DocumentType.HTML); + document3.setNodeRef("invalidNodeRef"); + + taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document3); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary("The entity with id: item with id workspace://SpacesStore/invalidNodeRef not found was not found"); + + } + + @Bug(id = "ACE-5675") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task item is falling in case empty item body is provided") + public void failedAddingTaskItemIfEmptyItemBodyIsProvided() throws Exception + { + restClient.authenticateUser(adminUser); + document4 = dataContent.usingSite(siteModel).createContent(DocumentType.PDF); + document4.setNodeRef(""); + + taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document4); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task item is falling in case invalid task id is provided") + public void failedAddingTaskItemIfInvalidTaskIdIsProvided() throws Exception + { + restClient.authenticateUser(adminUser); + document5 = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + taskModel.setId("invalidTaskId"); + + taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document5); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary("The entity with id: invalidTaskId was not found"); + } + + @Bug(id = "ACE-5675") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task item is falling in case incomplete body type is provided") + public void failedAddingTaskVariableIfIncompleteBodyIsProvided() throws Exception + { + restClient.authenticateUser(adminUser); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{}", "tasks/{taskId}/items", taskId); + restClient.processModel(RestVariableModel.class, request); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + } + +} From 7d7e4c04ec5e2090887faa166e45f10b2607bf18 Mon Sep 17 00:00:00 2001 From: mionescu Date: Thu, 8 Dec 2016 11:05:12 +0200 Subject: [PATCH 0691/1491] test added: AddTaskVariablesCoreTests --- .../tasks/AddTaskVariablesCoreTests.java | 164 ++++++++++++++++++ 1 file changed, 164 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesCoreTests.java new file mode 100644 index 000000000..8b7d843aa --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesCoreTests.java @@ -0,0 +1,164 @@ +package org.alfresco.rest.workflow.tasks; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.model.RestVariableModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TaskModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) +public class AddTaskVariablesCoreTests extends RestTest +{ + private UserModel userModel, userWhoStartsTask; + private SiteModel siteModel; + private FileModel fileModel; + private UserModel assigneeUser; + private TaskModel taskModel; + private RestVariableModel restVariablemodel; + + private UserModel adminUser; + private String taskId; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + + fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + userWhoStartsTask = dataUser.createRandomTestUser(); + assigneeUser = dataUser.createRandomTestUser(); + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + + adminUser = dataUser.getAdminUser(); + taskId = taskModel.getId(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case invalid variableBody is provided") + public void failedAddingTaskVariableIfInvalidBodyIsProvided() throws Exception + { + restClient.authenticateUser(adminUser); + + RestVariableModel invalidVariableModel = RestVariableModel.getRandomTaskVariableModel("instance", "d:char"); + restVariablemodel = restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(invalidVariableModel); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Illegal value for variable scope: 'instance'."); + + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case empty body type is provided") + public void failedAddingTaskVariableIfEmptyBodyIsProvided() throws Exception + { + restClient.authenticateUser(adminUser); + + RestVariableModel invalidVariableModel = RestVariableModel.getRandomTaskVariableModel("", ""); + restVariablemodel = restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(invalidVariableModel); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary("Variable scope is required and can only be 'local' or 'global'."); + + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case incomplete body type is provided") + public void failedAddingTaskVariableIfIncompleteBodyIsProvided() throws Exception + { + restClient.authenticateUser(adminUser); + + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{\"name\": \"missingVariableScope\",\"value\": \"test\",\"type\": \"d:text\"}", + "tasks/{taskId}/variables", taskId); + restClient.processModel(RestVariableModel.class, request); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary("Variable scope is required and can only be 'local' or 'global'."); + + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case incomplete body - missing required: name type is provided") + public void failedAddingTaskVariableIfIncompleteRequiredBodyIsProvided() throws Exception + { + restClient.authenticateUser(adminUser); + + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{\"scope\": \"local\",\"value\": \"missingVariableName\",\"type\": \"d:text\"}", + "tasks/{taskId}/variables", taskId); + restClient.processModel(RestVariableModel.class, request); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Variable name is required."); + + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case invalid type is provided") + public void failedAddingTaskVariableIfInvalidTypeIsProvided() throws Exception + { + restClient.authenticateUser(adminUser); + + RestVariableModel invalidVariableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:char"); + taskModel.setId(taskId); + restVariablemodel = restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(invalidVariableModel); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Unsupported type of variable: 'd:char'."); + + } + + @Bug(id = "ACE-5674") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case invalid type prefix is provided") + public void failedAddingTaskVariableIfInvalidTypePrefixIsProvided() throws Exception + { + restClient.authenticateUser(adminUser); + + RestVariableModel invalidVariableModel = RestVariableModel.getRandomTaskVariableModel("local", "ddm:text"); + restVariablemodel = restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(invalidVariableModel); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Namespace prefix ddm is not mapped to a namespace URI"); + + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case invalid scope is provided") + public void failedAddingTaskVariableIfInvalidScopeIsProvided() throws Exception + { + restClient.authenticateUser(adminUser); + + RestVariableModel invalidVariableModel = RestVariableModel.getRandomTaskVariableModel("instance", "d:text"); + restVariablemodel = restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(invalidVariableModel); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Illegal value for variable scope: 'instance'."); + + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case invalid task id is provided") + public void failedAddingTaskVariableIfInvalidTaskIdIsProvided() throws Exception + { + restClient.authenticateUser(adminUser); + + RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + taskModel.setId(taskModel.getId() + "TEST"); + restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary("The entity with id: " + taskModel.getId() + " was not found"); + + } + + @Bug(id = "ACE-5673") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case invalid task id is provided") + public void failedAddingTaskVariableIfInvalidValueIsProvided() throws Exception + { + restClient.authenticateUser(adminUser); + + RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:int"); + variableModel.setValue("invalidValue"); + + restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("For input string: \"invalidValue\""); + } +} From dc0fb51eb4a693d92ef914fbe06bfbd3151302a3 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Thu, 8 Dec 2016 12:27:12 +0200 Subject: [PATCH 0692/1491] fix: for 5.2.N removing the @Bug for test managerIsNotAbleToRetrieveCommentIfAuthenticationFails --- .../org/alfresco/rest/comments/GetCommentsSanityTests.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java index 6265d073c..260811444 100644 --- a/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java @@ -4,10 +4,10 @@ import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestCommentModelsCollection; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.*; -import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -90,14 +90,13 @@ public class GetCommentsSanityTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.SANITY}, executionType= ExecutionType.SANITY, description= "Verify Manager user gets status code 401 if authentication call fails") - @Bug(id="MNT-16904") public void managerIsNotAbleToRetrieveCommentIfAuthenticationFails() throws JsonToModelConversionException, Exception { UserModel nonexistentModel = new UserModel("nonexistentUser", "nonexistentPassword"); restClient.authenticateUser(nonexistentModel).withCoreAPI() .usingResource(document).getNodeComments(); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastException().hasName(StatusModel.UNAUTHORIZED); + .assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } @TestRail(section={TestGroup.REST_API, TestGroup.SANITY}, executionType= ExecutionType.SANITY, From 2ce29a3abbce43733d063da63f69aaa039d0637c Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Thu, 8 Dec 2016 12:46:03 +0200 Subject: [PATCH 0693/1491] core: update JsonBodyGenerator, remove rest properties of API paths, update assertion --- .../org/alfresco/rest/demo/RMDemoTest.java | 80 ------------------- e2e-test/resources/default.properties | 9 +-- 2 files changed, 2 insertions(+), 87 deletions(-) delete mode 100644 e2e-test/java/org/alfresco/rest/demo/RMDemoTest.java diff --git a/e2e-test/java/org/alfresco/rest/demo/RMDemoTest.java b/e2e-test/java/org/alfresco/rest/demo/RMDemoTest.java deleted file mode 100644 index 9369ac754..000000000 --- a/e2e-test/java/org/alfresco/rest/demo/RMDemoTest.java +++ /dev/null @@ -1,80 +0,0 @@ -//package org.alfresco.rest.demo; -// -//import org.alfresco.rest.RestTest; -//import org.alfresco.rest.exception.JsonToModelConversionException; -//import org.alfresco.rest.requests.RestSitesApi; -//import org.alfresco.utility.exception.DataPreparationException; -//import org.alfresco.utility.exception.TestConfigurationException; -//import org.alfresco.utility.model.SiteModel; -//import org.springframework.beans.factory.annotation.Autowired; -//import org.springframework.social.alfresco.api.entities.Site.Visibility; -//import org.testng.annotations.BeforeClass; -//import org.testng.annotations.Test; -// -//@Test(groups = { "demo" }) -//public class RMDemoTest extends RestTest { -// @Autowired -// RestSitesApi sitesApi; -// -// private SiteModel siteModel; -// -// @BeforeClass(alwaysRun = true) -// public void dataPreparation() throws DataPreparationException { -// siteModel = dataSite.usingAdmin().createPublicRandomSite(); -// restClient.authenticateUser(dataUser.getAdminUser()); -// -// sitesApi.useRestClient(restClient); -// } -// -// @Test -// public void adminCanSeeDetailsOfARandomSiteCreated() throws JsonToModelConversionException, Exception -// { -// restClient.usingSite(siteModel).getSite() -// .assertThat().field("id").isNotNull() -// .and().field("description").is(siteModel.getDescription()) -// .and().field("title").is(siteModel.getTitle()); -// } -// -// @Test -// public void adminCanSeeSiteDetailsOfCustomSite() throws JsonToModelConversionException, Exception -// { -// siteModel = dataSite.usingAdmin().createPublicRandomSite(); -// siteModel.setDescription("my description"); -// siteModel.setVisibility(Visibility.PUBLIC); -// -// // here we create the custom siteModel defined above -// dataSite.usingAdmin().createSite(siteModel); -// -// siteModel -// .assertThat().field("id").isNotNull() -// .and().field("description").is("my description") -// .and().field("title").is("MyTitle") -// .and().field("visibility").is(Visibility.PUBLIC); -// } -// -// /** -// * This will throw this error message: -// * "You missed some configuration settings in your tests: You try to assert field [fieldA] that -// * doesn't exist in class: [org.alfresco.rest.model.RestSiteModel]. Please check your code!" -// */ -// @Test(expectedExceptions = TestConfigurationException.class) -// public void assertingWithFieldsThatDoesNotExist() throws JsonToModelConversionException, Exception { -// siteModel = dataSite.createPublicRandomSite(); -// -// sitesApi.getSite(siteModel).assertThat().field("fieldA").isNotNull(); -// } -// -// @Test -// public void assertingPaginationAndUsingParameters() throws Exception -// { -// /* -// * ~ each API has the possibility to pass parameters to httpMethod call -// * you can use withParams(String... parameters) method before calling the http method. -// */ -// sitesApi.withParams("maxItems=2", "orderyBy=name").getSites() -// .assertThat().paginationExist(); -//// .and().paginationField("maxItems").is("2"); -// -// } -// -//} \ No newline at end of file diff --git a/e2e-test/resources/default.properties b/e2e-test/resources/default.properties index ca02e1224..beeaddbc1 100644 --- a/e2e-test/resources/default.properties +++ b/e2e-test/resources/default.properties @@ -1,17 +1,12 @@ # dataprep related alfresco.scheme=http -alfresco.server=172.29.100.215 -alfresco.port=8080 +alfresco.server=vsphered3.qa.internal.alfresco.com +alfresco.port=8070 # credentials admin.user=admin admin.password=admin -# rest related -rest.basePath=alfresco/api/-default-/public/alfresco/versions/1 -rest.workflowPath=alfresco/api/-default-/public/workflow/versions/1 - - # TEST MANAGEMENT SECTION - Test Rail # # (currently supporting Test Rail v5.2.1.3472 integration) From 02c268a0efa060e47b31dda18088ead49f74d064 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Thu, 8 Dec 2016 14:14:13 +0200 Subject: [PATCH 0694/1491] fix: imports --- .../GetProcessDefinitionImageSanityTests.java | 2 -- .../GetProcessDefinitionStartFormModelSanityTests.java | 2 -- .../processDefinitions/GetProcessDefinitionsCoreTests.java | 1 - 3 files changed, 5 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java index d36d2b108..ce1ab2d56 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java @@ -2,12 +2,10 @@ package org.alfresco.rest.workflow.processDefinitions; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestProcessDefinitionModel; -import org.alfresco.utility.data.DataUser; 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.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java index 229a5c8e0..bef2437df 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java @@ -2,12 +2,10 @@ package org.alfresco.rest.workflow.processDefinitions; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestProcessDefinitionModel; -import org.alfresco.utility.data.DataUser; 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.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsCoreTests.java index 8655c177b..072bf0c55 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsCoreTests.java @@ -4,7 +4,6 @@ import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; From f5583776e0e3dd01b7b67034a1e925cb6160bb6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alecsandru=20Prun=C4=83?= Date: Thu, 8 Dec 2016 14:34:45 +0200 Subject: [PATCH 0695/1491] test: Added AddProcessVariableCoreTests --- .../AddProcessVariableCoreTests.java | 101 ++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableCoreTests.java new file mode 100644 index 000000000..e1f7ff536 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableCoreTests.java @@ -0,0 +1,101 @@ +package org.alfresco.rest.workflow.processes; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestProcessVariableModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) +public class AddProcessVariableCoreTests extends RestTest +{ + private FileModel document; + private SiteModel siteModel; + private UserModel userWhoStartsTask, assignee, adminUser, adminTenantUser, secondAdminTenantUser, tenantUser; + private RestProcessModel processModel; + private RestProcessVariableModel variableModel, processVariable; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userWhoStartsTask = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify addProcessVariable by admin in other network with REST API and status code is FORBIDDEN (403)") + @Test(groups = { TestGroup.NETWORKS }) + public void addProcessVariableByAdminInOtherNetworkIsForbidden() throws Exception + { + adminTenantUser = UserModel.getAdminTenantUser(); + secondAdminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser); + restClient.authenticateUser(adminUser).usingTenant().createTenant(secondAdminTenantUser); + tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + + restClient.authenticateUser(adminTenantUser).withWorkflowAPI() + .addProcess("activitiAdhoc", tenantUser, false, CMISUtil.Priority.Normal); + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + + restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify addProcessVariable by any user with REST API and status code is CREATED (201)") + public void addProcessVariableByAnyUser() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + + processVariable = restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + processVariable.assertThat().field("name").is(variableModel.getName()) + .and().field("type").is(variableModel.getType()) + .and().field("value").is(variableModel.getValue()); + + restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() + .assertThat().entriesListContains("name", processVariable.getName()); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify addProcessVariable by any user for invalid processID with REST API and status code is NOT_FOUND (404)") + public void addProcessVariableForInvalidProcessIdIsNotFound() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processModel.setId("invalidProcessID"); + + processVariable = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidProcessID")); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify addProcessVariable by any user for empty processID with REST API and status code is NOT_FOUND (404)") + public void addProcessVariableForInvalidProcessIdIsEmpty() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processModel.setId(""); + + processVariable = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); + } +} From 2d8f6a1bf69ac06371dae2aece9f0d079126391e Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Thu, 8 Dec 2016 15:04:47 +0200 Subject: [PATCH 0696/1491] test: add auth sample test --- .../org/alfresco/rest/auth/AuthTests.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/auth/AuthTests.java diff --git a/e2e-test/java/org/alfresco/rest/auth/AuthTests.java b/e2e-test/java/org/alfresco/rest/auth/AuthTests.java new file mode 100644 index 000000000..255ad3b39 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/auth/AuthTests.java @@ -0,0 +1,29 @@ +package org.alfresco.rest.auth; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestTicketBodyModel; +import org.alfresco.rest.model.RestTicketModel; +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; + +public class AuthTests extends RestTest +{ + @TestRail(section = { TestGroup.REST_API }, executionType = ExecutionType.SANITY, description = "Verify TICKET is returned on admin user") + @Test + public void adminShouldGetTicketBody() throws JsonToModelConversionException, Exception + { + RestTicketBodyModel ticketBody = new RestTicketBodyModel(); + ticketBody.setUserId("admin"); + ticketBody.setPassword("admin"); + + RestTicketModel ticketReturned = restClient.withAuthAPI().createTicket(ticketBody); + + restClient.assertStatusCodeIs(HttpStatus.CREATED); + ticketReturned.assertThat().field("id").contains("TICKET_"); + } + +} \ No newline at end of file From b281fdfca0e0b9873e377b534c04940193ee8c37 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Thu, 8 Dec 2016 15:28:17 +0200 Subject: [PATCH 0697/1491] CORE-REST API: getProcess (get /processes/{processId}) --- .../processes/GetProcessCoreTests.java | 96 +++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessCoreTests.java new file mode 100644 index 000000000..a308651f9 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessCoreTests.java @@ -0,0 +1,96 @@ +package org.alfresco.rest.workflow.processes; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.apache.commons.lang.RandomStringUtils; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class GetProcessCoreTests extends RestTest +{ + private UserModel userWhoStartsProcess, assignee, adminUser; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userWhoStartsProcess = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify that using invalid process ID returns status code 404") + @Test(groups = { TestGroup.WORKFLOW, TestGroup.CORE }) + public void invalidProcessIdTest() throws Exception + { + RestProcessModel newProcess = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.High); + String processId = RandomStringUtils.randomAlphanumeric(10); + newProcess.setId(processId); + restClient.authenticateUser(dataUser.getAdminUser()) + .withWorkflowAPI().usingProcess(newProcess).getProcess(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, processId)); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES, TestGroup.NETWORKS}, executionType = ExecutionType.REGRESSION, + description = "Verify that tenant user cannot get process from another network") + @Test(groups = { TestGroup.WORKFLOW, TestGroup.CORE }) + @Bug(id = "MNT-17238") + public void tenantUserCannotGetProcessFromAnotherNetwork() throws Exception + { + UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser1); + + UserModel adminTenantUser2 = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser2); + + UserModel tenantUser1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenant1"); + UserModel tenantUser2 = dataUser.usingUser(adminTenantUser2).createUserWithTenant("uTenant2"); + + RestProcessModel networkProcess1 = restClient.authenticateUser(adminTenantUser1).withWorkflowAPI().addProcess("activitiReview", tenantUser1, false, CMISUtil.Priority.High); + + restClient.authenticateUser(tenantUser2).withWorkflowAPI().usingProcess(networkProcess1).getProcess(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES, TestGroup.NETWORKS}, executionType = ExecutionType.REGRESSION, + description = "Verify that tenant user can get process from the same network") + @Test(groups = { TestGroup.WORKFLOW, TestGroup.CORE }) + public void tenantUserCanGetProcessFromTheSameNetwork() throws Exception + { + UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser1); + UserModel tenantUser1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenant1"); + + RestProcessModel networkProcess1 = restClient.authenticateUser(adminTenantUser1).withWorkflowAPI().addProcess("activitiReview", tenantUser1, false, CMISUtil.Priority.High); + + restClient.authenticateUser(tenantUser1).withWorkflowAPI().usingProcess(networkProcess1).getProcess(); + restClient.assertStatusCodeIs(HttpStatus.OK); + networkProcess1.assertThat().field("id").is(networkProcess1.getId()) + .and().field("startUserId").is(networkProcess1.getStartUserId());; + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES, TestGroup.NETWORKS}, executionType = ExecutionType.REGRESSION, + description = "Verify that non network user cannot get process from a network") + @Test(groups = { TestGroup.WORKFLOW, TestGroup.CORE }) + @Bug(id = "MNT-17238") + public void nonNetworkUserCannotAccessNetworkprocess() throws Exception + { + UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser1); + UserModel tenantUser1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenant1"); + + RestProcessModel networkProcess1 = restClient.authenticateUser(adminTenantUser1).withWorkflowAPI().addProcess("activitiReview", tenantUser1, false, CMISUtil.Priority.High); + + restClient.authenticateUser(adminUser).withWorkflowAPI().usingProcess(networkProcess1).getProcess(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + } + +} \ No newline at end of file From 14ee7b84246f9030bcb3ea4ef51943fa2c78c621 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Thu, 8 Dec 2016 15:45:03 +0200 Subject: [PATCH 0698/1491] Add networks group for tests --- .../rest/workflow/processes/GetProcessCoreTests.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessCoreTests.java index a308651f9..53e6131cc 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessCoreTests.java @@ -28,7 +28,7 @@ public class GetProcessCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify that using invalid process ID returns status code 404") - @Test(groups = { TestGroup.WORKFLOW, TestGroup.CORE }) + @Test(groups = { TestGroup.WORKFLOW, TestGroup.CORE, TestGroup.NETWORKS }) public void invalidProcessIdTest() throws Exception { RestProcessModel newProcess = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.High); @@ -41,7 +41,7 @@ public class GetProcessCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES, TestGroup.NETWORKS}, executionType = ExecutionType.REGRESSION, description = "Verify that tenant user cannot get process from another network") - @Test(groups = { TestGroup.WORKFLOW, TestGroup.CORE }) + @Test(groups = { TestGroup.WORKFLOW, TestGroup.CORE, TestGroup.NETWORKS }) @Bug(id = "MNT-17238") public void tenantUserCannotGetProcessFromAnotherNetwork() throws Exception { @@ -60,9 +60,9 @@ public class GetProcessCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES, TestGroup.NETWORKS}, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify that tenant user can get process from the same network") - @Test(groups = { TestGroup.WORKFLOW, TestGroup.CORE }) + @Test(groups = { TestGroup.WORKFLOW, TestGroup.CORE, TestGroup.NETWORKS }) public void tenantUserCanGetProcessFromTheSameNetwork() throws Exception { UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); @@ -79,7 +79,7 @@ public class GetProcessCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES, TestGroup.NETWORKS}, executionType = ExecutionType.REGRESSION, description = "Verify that non network user cannot get process from a network") - @Test(groups = { TestGroup.WORKFLOW, TestGroup.CORE }) + @Test(groups = { TestGroup.WORKFLOW, TestGroup.CORE, TestGroup.NETWORKS }) @Bug(id = "MNT-17238") public void nonNetworkUserCannotAccessNetworkprocess() throws Exception { From 8b857009042238790dbd9b70d84ac8c944fc2fce Mon Sep 17 00:00:00 2001 From: cagache Date: Thu, 8 Dec 2016 16:00:28 +0200 Subject: [PATCH 0699/1491] removed network group from invalidProcessIdTest --- .../alfresco/rest/workflow/processes/GetProcessCoreTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessCoreTests.java index 53e6131cc..1a35cd25b 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessCoreTests.java @@ -28,7 +28,7 @@ public class GetProcessCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify that using invalid process ID returns status code 404") - @Test(groups = { TestGroup.WORKFLOW, TestGroup.CORE, TestGroup.NETWORKS }) + @Test(groups = { TestGroup.WORKFLOW, TestGroup.CORE}) public void invalidProcessIdTest() throws Exception { RestProcessModel newProcess = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.High); From 69764a78319d52ef2c5182571828bd0ffc31d937 Mon Sep 17 00:00:00 2001 From: mionescu Date: Thu, 8 Dec 2016 16:02:35 +0200 Subject: [PATCH 0700/1491] updated test after review: AddTaskVariablesCoreTests --- .../tasks/AddTaskVariablesCoreTests.java | 50 ++++++------------- 1 file changed, 16 insertions(+), 34 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesCoreTests.java index 8b7d843aa..93f4e8c5d 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesCoreTests.java @@ -3,6 +3,7 @@ package org.alfresco.rest.workflow.tasks; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestVariableModel; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; @@ -20,38 +21,33 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) public class AddTaskVariablesCoreTests extends RestTest { - private UserModel userModel, userWhoStartsTask; + private UserModel userWhoStartsTask, adminUser; private SiteModel siteModel; private FileModel fileModel; private UserModel assigneeUser; private TaskModel taskModel; - private RestVariableModel restVariablemodel; - private UserModel adminUser; private String taskId; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception { - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + adminUser = dataUser.getAdminUser(); userWhoStartsTask = dataUser.createRandomTestUser(); assigneeUser = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); + fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - adminUser = dataUser.getAdminUser(); taskId = taskModel.getId(); + restClient.authenticateUser(adminUser); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case invalid variableBody is provided") public void failedAddingTaskVariableIfInvalidBodyIsProvided() throws Exception { - restClient.authenticateUser(adminUser); - RestVariableModel invalidVariableModel = RestVariableModel.getRandomTaskVariableModel("instance", "d:char"); - restVariablemodel = restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(invalidVariableModel); + restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(invalidVariableModel); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Illegal value for variable scope: 'instance'."); @@ -60,10 +56,8 @@ public class AddTaskVariablesCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case empty body type is provided") public void failedAddingTaskVariableIfEmptyBodyIsProvided() throws Exception { - restClient.authenticateUser(adminUser); - RestVariableModel invalidVariableModel = RestVariableModel.getRandomTaskVariableModel("", ""); - restVariablemodel = restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(invalidVariableModel); + restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(invalidVariableModel); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() .containsSummary("Variable scope is required and can only be 'local' or 'global'."); @@ -73,8 +67,6 @@ public class AddTaskVariablesCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case incomplete body type is provided") public void failedAddingTaskVariableIfIncompleteBodyIsProvided() throws Exception { - restClient.authenticateUser(adminUser); - RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{\"name\": \"missingVariableScope\",\"value\": \"test\",\"type\": \"d:text\"}", "tasks/{taskId}/variables", taskId); restClient.processModel(RestVariableModel.class, request); @@ -87,8 +79,6 @@ public class AddTaskVariablesCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case incomplete body - missing required: name type is provided") public void failedAddingTaskVariableIfIncompleteRequiredBodyIsProvided() throws Exception { - restClient.authenticateUser(adminUser); - RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{\"scope\": \"local\",\"value\": \"missingVariableName\",\"type\": \"d:text\"}", "tasks/{taskId}/variables", taskId); restClient.processModel(RestVariableModel.class, request); @@ -100,11 +90,9 @@ public class AddTaskVariablesCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case invalid type is provided") public void failedAddingTaskVariableIfInvalidTypeIsProvided() throws Exception { - restClient.authenticateUser(adminUser); - RestVariableModel invalidVariableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:char"); taskModel.setId(taskId); - restVariablemodel = restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(invalidVariableModel); + restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(invalidVariableModel); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Unsupported type of variable: 'd:char'."); @@ -114,22 +102,20 @@ public class AddTaskVariablesCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case invalid type prefix is provided") public void failedAddingTaskVariableIfInvalidTypePrefixIsProvided() throws Exception { - restClient.authenticateUser(adminUser); - RestVariableModel invalidVariableModel = RestVariableModel.getRandomTaskVariableModel("local", "ddm:text"); - restVariablemodel = restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(invalidVariableModel); + taskModel.setId(taskId); + restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(invalidVariableModel); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Namespace prefix ddm is not mapped to a namespace URI"); } - + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case invalid scope is provided") public void failedAddingTaskVariableIfInvalidScopeIsProvided() throws Exception { - restClient.authenticateUser(adminUser); - RestVariableModel invalidVariableModel = RestVariableModel.getRandomTaskVariableModel("instance", "d:text"); - restVariablemodel = restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(invalidVariableModel); + taskModel.setId(taskId); + restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(invalidVariableModel); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Illegal value for variable scope: 'instance'."); @@ -138,22 +124,18 @@ public class AddTaskVariablesCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case invalid task id is provided") public void failedAddingTaskVariableIfInvalidTaskIdIsProvided() throws Exception { - restClient.authenticateUser(adminUser); - RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); taskModel.setId(taskModel.getId() + "TEST"); restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary("The entity with id: " + taskModel.getId() + " was not found"); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, taskModel.getId())); } - @Bug(id = "ACE-5673") @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case invalid task id is provided") public void failedAddingTaskVariableIfInvalidValueIsProvided() throws Exception { - restClient.authenticateUser(adminUser); - RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:int"); variableModel.setValue("invalidValue"); From b2727de5af645448e0232c2407b626eddb92b4da Mon Sep 17 00:00:00 2001 From: mionescu Date: Thu, 8 Dec 2016 16:11:01 +0200 Subject: [PATCH 0701/1491] test added: AddProcessVariableCoreTests --- .../AddProcessVariableCoreTests.java | 159 ++++++++++++++++++ 1 file changed, 159 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableCoreTests.java new file mode 100644 index 000000000..c16dafe72 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableCoreTests.java @@ -0,0 +1,159 @@ +package org.alfresco.rest.workflow.processes; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.dataprep.CMISUtil.Priority; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestProcessVariableModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) +public class AddProcessVariableCoreTests extends RestTest +{ + private FileModel document; + private SiteModel siteModel; + private UserModel userWhoStartsProcess, assignee, adminUser, anotherUser, adminTenantUser, adminTenantUser2, tenantUserAssignee; + private RestProcessModel processModel; + private RestProcessVariableModel variableModel, processVariable; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userWhoStartsProcess = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userWhoStartsProcess).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); + anotherUser = dataUser.createRandomTestUser(); + + adminUser = dataUser.getAdminUser(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Add process variable using by the user who started the process.") + public void addProcessVariableByUserThatStartedTheProcess() throws Exception + { + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + + processVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + processVariable.assertThat().field("name").is(variableModel.getName()).and().field("type").is(variableModel.getType()).and().field("value") + .is(variableModel.getValue()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Add process variable using by a random user.") + public void addProcessVariableByAnyUser() throws Exception + { + processModel = restClient.authenticateUser(anotherUser).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + + processVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + processVariable.assertThat().field("name").is(variableModel.getName()).and().field("type").is(variableModel.getType()).and().field("value") + .is(variableModel.getValue()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Add process variable using by admin in other network.") + public void addProcessVariableByAdminInOtherNetwork() throws Exception + { + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser); + tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); + + adminTenantUser2 = UserModel.getAdminTenantUser(); + restClient.usingTenant().createTenant(adminTenantUser2); + + processModel = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee, false, Priority.Normal); + + restClient.authenticateUser(adminTenantUser2); + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Process is running in another tenant"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process variable is falling in case invalid type is provided") + public void failedAddingProcessVariableIfInvalidTypeIsProvided() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:textarea"); + + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Unsupported type of variable: 'd:textarea'."); + } + + @Bug(id = "ACE-5674") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process variable is falling in case invalid type prefix is provided") + public void failedAddingProcessVariableIfInvalidTypePrefixIsProvided() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("ddt:text"); + + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Namespace prefix ddt is not mapped to a namespace URI"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process variable is falling in case invalid value is provided") + public void failedAddingProcessVariableIfInvalidValueIsProvided() throws Exception + { + RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:int"); + variableModel.setValue("invalidValue"); + + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("For input string: \"invalidValue\""); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process variable is falling in case missing required variable body (name) is provided") + public void failedAddingProcessVariableIfMissingRequiredVariableBodyIsProvided() throws Exception + { + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"value\": \"missingVariableName\",\"type\": \"d:text\"}", + "processes/{processId}/variables/{variableName}", processModel.getId(), variableModel.getName()); + restClient.processModel(RestProcessVariableModel.class, request); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Variable name is required."); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process variable is falling in case invalid variableBody (adding extra parameter in body) is provided") + public void failedAddingProcessVariableIfInvalidBodyIsProvided() throws Exception + { + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"scope\": \"local\",\"value\": \"testing\",\"type\": \"d:text\"}", + "processes/{processId}/variables/{variableName}", processModel.getId(), variableModel.getName()); + restClient.processModel(RestProcessVariableModel.class, request); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary("Could not read content from HTTP request body: Unrecognized field \"scope\""); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process variable is falling in case empty name is provided") + public void failedAddingProcessVariableIfEmptyNameIsProvided() throws Exception + { + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); + RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + variableModel.setName(""); + + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); + + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary("PUT is executed against the instance URL"); + } + +} From 57f65ee739ec07cbc0a03204b9d3136c5ad0d807 Mon Sep 17 00:00:00 2001 From: mionescu Date: Thu, 8 Dec 2016 16:35:37 +0200 Subject: [PATCH 0702/1491] updated tests --- .../workflow/tasks/AddTaskItemCoreTests.java | 36 +++++++++---------- e2e-test/resources/default.properties | 6 ++-- 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemCoreTests.java index 33a400262..1474aa5dc 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemCoreTests.java @@ -24,7 +24,7 @@ public class AddTaskItemCoreTests extends RestTest { private UserModel userModel, assigneeUser; private SiteModel siteModel; - private FileModel fileModel, document2, document3, document4, document5; + private FileModel fileModel, document; private TaskModel taskModel; private RestItemModel taskItem; @@ -34,40 +34,38 @@ public class AddTaskItemCoreTests extends RestTest @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception { + adminUser = dataUser.getAdminUser(); userModel = dataUser.createRandomTestUser(); siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); assigneeUser = dataUser.createRandomTestUser(); taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - adminUser = dataUser.getAdminUser(); taskId = taskModel.getId(); + restClient.authenticateUser(userModel); } - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Add task item using admin user from same network") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Add task item using random user.") public void addTaskItemByRandomUser() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(userModel); - document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + document = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); + taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document); restClient.assertStatusCodeIs(HttpStatus.CREATED); taskItem.assertThat().field("createdAt").is(taskItem.getCreatedAt()).assertThat().field("size").is(taskItem.getSize()).and().field("createdBy") .is(taskItem.getCreatedBy()).and().field("modifiedAt").is(taskItem.getModifiedAt()).and().field("name").is(taskItem.getName()).and() .field("modifiedBy").is(taskItem.getModifiedBy()).and().field("id").is(taskItem.getId()).and().field("mimeType").is(taskItem.getMimeType()); - taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task item, is falling in case invalid itemBody is provided") public void failedAddingTaskItemIfInvalidItemBodyIsProvided() throws Exception { - restClient.authenticateUser(adminUser); - document3 = dataContent.usingSite(siteModel).createContent(DocumentType.HTML); - document3.setNodeRef("invalidNodeRef"); + // document3 = dataContent.usingSite(siteModel).createContent(DocumentType.HTML); + document.setNodeRef("invalidNodeRef"); - taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document3); + taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() .containsSummary("The entity with id: item with id workspace://SpacesStore/invalidNodeRef not found was not found"); @@ -78,11 +76,11 @@ public class AddTaskItemCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task item is falling in case empty item body is provided") public void failedAddingTaskItemIfEmptyItemBodyIsProvided() throws Exception { - restClient.authenticateUser(adminUser); - document4 = dataContent.usingSite(siteModel).createContent(DocumentType.PDF); - document4.setNodeRef(""); - taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document4); + // document4 = dataContent.usingSite(siteModel).createContent(DocumentType.PDF); + document.setNodeRef(""); + + taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); @@ -91,11 +89,11 @@ public class AddTaskItemCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task item is falling in case invalid task id is provided") public void failedAddingTaskItemIfInvalidTaskIdIsProvided() throws Exception { - restClient.authenticateUser(adminUser); - document5 = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + // restClient.authenticateUser(adminUser); + // document5 = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); taskModel.setId("invalidTaskId"); - taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document5); + taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary("The entity with id: invalidTaskId was not found"); } @@ -104,7 +102,7 @@ public class AddTaskItemCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task item is falling in case incomplete body type is provided") public void failedAddingTaskVariableIfIncompleteBodyIsProvided() throws Exception { - restClient.authenticateUser(adminUser); + // restClient.authenticateUser(adminUser); RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{}", "tasks/{taskId}/items", taskId); restClient.processModel(RestVariableModel.class, request); diff --git a/e2e-test/resources/default.properties b/e2e-test/resources/default.properties index ca02e1224..0c7fbe28f 100644 --- a/e2e-test/resources/default.properties +++ b/e2e-test/resources/default.properties @@ -1,7 +1,7 @@ # dataprep related alfresco.scheme=http -alfresco.server=172.29.100.215 -alfresco.port=8080 +alfresco.server=http://vsphered3.qa.internal.alfresco.com/ +alfresco.port=8070 # credentials admin.user=admin @@ -39,7 +39,7 @@ reports.path=./target/reports # in containers we cannot access directly JMX, so we will use http://jolokia.org agent # disabling this we will use direct JMX calls to server -jmx.useJolokiaAgent=false +jmx.useJolokiaAgent=true # # Database Section From 4ca2d4b581f51508eae39b95905b135bbf64155e Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Thu, 8 Dec 2016 16:52:48 +0200 Subject: [PATCH 0703/1491] fix: updateCommentsCoreTests - add @Bug, move groups to method level --- .../rest/comments/UpdateCommentsCoreTests.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsCoreTests.java b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsCoreTests.java index 5376c3b9c..4d0f31bf2 100644 --- a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsCoreTests.java @@ -8,7 +8,12 @@ import org.alfresco.rest.model.RestCommentModelsCollection; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.model.*; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FileType; +import org.alfresco.utility.model.LinkModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; @@ -16,7 +21,6 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) public class UpdateCommentsCoreTests extends RestTest { private UserModel adminUserModel; @@ -39,6 +43,7 @@ public class UpdateCommentsCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.SANITY }, executionType = ExecutionType.SANITY, description = "Verify can not update comment if NodeId is neither document or folder and returns status code 405") @Bug(id="MNT-16904") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) public void canNotUpdateCommentIfNodeIdIsNeitherDocumentOrFolder() throws JsonToModelConversionException, Exception { FileModel content = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); @@ -57,6 +62,7 @@ public class UpdateCommentsCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Admin user is not able to update with empty comment body and status code is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) public void adminIsNotAbleToUpdateWithEmptyCommentBody() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); @@ -69,6 +75,7 @@ public class UpdateCommentsCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify updated comment by Manager is listed when calling getComments and status code is 200") @Bug(id="REPO-1011") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) public void updatedCommentByManagerIsListed() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); @@ -81,17 +88,20 @@ public class UpdateCommentsCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user can not update comments of another user and status code is 200") + @Bug(id="MNT-2502",description="seems it's one old issue: also logged as MNT-2502, MNT-2346") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) public void collaboratorIsNotAbleToUpdateCommentOfAnotherUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by admin"); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.withCoreAPI().usingResource(document).updateComment(commentModel, "This is the updated comment with Collaborator user"); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingResource(document).updateComment(commentModel, "This is the updated comment with Collaborator user"); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify entry content in response") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) public void checkEntryContentInResponse() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); From 368147b2d2a9df5787e9762d4fe797dd80f21515 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Thu, 8 Dec 2016 16:58:09 +0200 Subject: [PATCH 0704/1491] fix: removeSiteMemberCoreTest: update groups at method level --- .../rest/sites/RemoveSiteMemberCoreTests.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberCoreTests.java index 936cd2625..f0fb15ec6 100644 --- a/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberCoreTests.java @@ -19,7 +19,6 @@ import org.testng.annotations.Test; * @author Cristina Axinte * */ -@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) public class RemoveSiteMemberCoreTests extends RestTest { private SiteModel siteModel; @@ -37,6 +36,7 @@ public class RemoveSiteMemberCoreTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Verify that manager can NOT delete site member for an inexistent user and gets status code 404, 'Not Found'") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) public void managerIsNotAbleToDeleteInexistentSiteMember() throws Exception { UserModel inexistentUser = new UserModel("inexistentUser", "password"); @@ -49,6 +49,7 @@ public class RemoveSiteMemberCoreTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Verify that manager can NOT delete site member for a non site member and gets status code 400, 'Bad Request'") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) public void managerIsNotAbleToDeleteNotSiteMember() throws Exception { UserModel nonMember = dataUser.createRandomTestUser(); @@ -61,6 +62,7 @@ public class RemoveSiteMemberCoreTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Verify that manager can NOT delete site member for an invalid site and gets status code 404, 'Not Found'") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) public void managerIsNotAbleToDeleteSiteMemberOfInvalidSite() throws Exception { SiteModel invalidSite = new SiteModel("invalidSite"); @@ -75,6 +77,7 @@ public class RemoveSiteMemberCoreTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Verify that manager can delete a site member with manager role") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) public void siteManagerIsAbleToDeleteSiteMemberWithManagerRole() throws Exception { UserModel anothermanager = dataUser.createRandomTestUser(); @@ -90,6 +93,7 @@ public class RemoveSiteMemberCoreTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Verify that manager can delete site member using \"-me-\" in place of personId") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) public void managerIsAbleToDeleteSiteMemberUsingMe() throws Exception { UserModel manager = dataUser.createRandomTestUser(); @@ -106,6 +110,7 @@ public class RemoveSiteMemberCoreTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Verify that site collaborator cannot delete a site member with Manager role and gets status code 422") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) public void siteCollaboratorIsNotAbleToDeleteSiteMemberWithManagerRole() throws Exception { UserModel managerForDelete = dataUser.createRandomTestUser(); @@ -120,6 +125,7 @@ public class RemoveSiteMemberCoreTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Verify that site contributor cannot delete site member with Manager role and gets status code 422") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) public void siteContributorIsNotAbleToDeleteSiteMemberWithManagerRole() throws Exception { UserModel managerForDelete = dataUser.createRandomTestUser(); @@ -133,6 +139,7 @@ public class RemoveSiteMemberCoreTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Verify that site consumer cannot delete site member with Manager role and gets status code 422") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) public void siteConsumerIsNotAbleToDeleteSiteMemberWithManagerRole() throws Exception { UserModel managerForDelete = dataUser.createRandomTestUser(); @@ -146,6 +153,7 @@ public class RemoveSiteMemberCoreTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Verify that site collaborator cannot delete a site member with Contributor role and gets status code 422") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) public void siteCollaboratorIsNotAbleToDeleteSiteMemberWithContributorRole() throws Exception { UserModel contributorForDelete = dataUser.createRandomTestUser(); @@ -159,6 +167,7 @@ public class RemoveSiteMemberCoreTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Verify that site contributor cannot delete site member with Contributor role and gets status code 422") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) public void siteContributorIsNotAbleToDeleteSiteMemberWithContributorRole() throws Exception { UserModel contributorForDelete = dataUser.createRandomTestUser(); @@ -172,6 +181,7 @@ public class RemoveSiteMemberCoreTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Verify that site consumer cannot delete site member with Contributor role and gets status code 422") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) public void siteConsumerIsNotAbleToDeleteSiteMemberWithContributorRole() throws Exception { UserModel contributorForDelete = dataUser.createRandomTestUser(); @@ -185,6 +195,7 @@ public class RemoveSiteMemberCoreTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Verify that manager can delete a site member with Contributor role") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) public void siteManagerIsAbleToDeleteSiteMemberWithContributorRole() throws Exception { UserModel contributorForDelete = dataUser.createRandomTestUser(); @@ -200,6 +211,7 @@ public class RemoveSiteMemberCoreTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Verify that site collaborator cannot delete a site member with Collaborator role and gets status code 422") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) public void siteCollaboratorIsNotAbleToDeleteSiteMemberWithCollaboratorRole() throws Exception { UserModel collaboratorForDelete = dataUser.createRandomTestUser(); @@ -213,6 +225,7 @@ public class RemoveSiteMemberCoreTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Verify that site contributor cannot delete site member with Collaborator role and gets status code 422") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) public void siteContributorIsNotAbleToDeleteSiteMemberWithCollaboratorRole() throws Exception { UserModel collaboratorForDelete = dataUser.createRandomTestUser(); @@ -226,6 +239,7 @@ public class RemoveSiteMemberCoreTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Verify that site consumer cannot delete site member with Collaborator role and gets status code 422") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) public void siteConsumerIsNotAbleToDeleteSiteMemberWithCollaboratorRole() throws Exception { UserModel collaboratorForDelete = dataUser.createRandomTestUser(); @@ -239,6 +253,7 @@ public class RemoveSiteMemberCoreTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Verify that manager can delete a site member with Collaborator role") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) public void siteManagerIsAbleToDeleteSiteMemberWithCollaboratorRole() throws Exception { UserModel collaboratorForDelete = dataUser.createRandomTestUser(); From 402187a106f52f2554768d0675954f4066cfda57 Mon Sep 17 00:00:00 2001 From: Andrei Rusu Date: Thu, 8 Dec 2016 17:03:02 +0200 Subject: [PATCH 0705/1491] added tests for GetTasksCoreTests --- .../workflow/tasks/GetTasksCoreTests.java | 108 ++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksCoreTests.java new file mode 100644 index 000000000..8f5bdc7ff --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksCoreTests.java @@ -0,0 +1,108 @@ +package org.alfresco.rest.workflow.tasks; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.dataprep.CMISUtil.Priority; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestTaskModelsCollection; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class GetTasksCoreTests extends RestTest +{ + UserModel userModel, userNotInvolved, candidateUser, assigneeUser, adminUser; + UserModel adminTenantUser, tenantUser, tenantUserAssignee; + SiteModel siteModel, tenantSiteModel; + FileModel fileModel, tenantFileModel; + RestTaskModelsCollection taskModels, tenantTask; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userModel = dataUser.createRandomTestUser(); + userNotInvolved = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + + assigneeUser = dataUser.createRandomTestUser(); + dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify the request is valid for auth user which is asignee.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + public void validRequestAuthUser() throws Exception + { + taskModels = restClient.authenticateUser(assigneeUser).withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + taskModels.assertThat().entriesListIsNotEmpty().and().entriesListCountIs(1).and().entriesListContains("assignee", assigneeUser.getUsername()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify the request in case of any user which is not involved.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + public void requestWithUserNotInvolved() throws Exception + { + taskModels = restClient.authenticateUser(userNotInvolved).withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + taskModels.assertThat().entriesListIsEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check that orderBy parameter is applied and use several filters.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + public void orderByParameterApplied() throws Exception + { + taskModels = restClient.authenticateUser(dataUser.getAdminUser()).withParams("orderBy=processId").withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + taskModels.assertThat().entriesListIsNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check that where parameter is applied.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + public void whereParameterApplied() throws Exception + { + taskModels = restClient.authenticateUser(dataUser.getAdminUser()).withParams("where=(assignee='" + assigneeUser.getUsername() + "')").withWorkflowAPI() + .getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + taskModels.assertThat().entriesListIsNotEmpty().and().entriesListContains("assignee", assigneeUser.getUsername()).and().entriesListCountIs(1); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check that invalid orderBy parameter applied returns 400 status code.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + public void invalidOrderByParameterApplied() throws Exception + { + taskModels = restClient.authenticateUser(dataUser.getAdminUser()).withParams("orderBy=invalidParameter").withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("invalidParameter is not supported"); + taskModels.assertThat().entriesListIsEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check that for network enabled only that network tasks are returned.") + @Test(groups = { TestGroup.NETWORKS }) + public void networkEnabledTasksReturned() throws Exception + { + restClient.authenticateUser(adminUser); + + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.usingTenant().createTenant(adminTenantUser); + + tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("userTenant"); + tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("userTenantAssignee"); + + restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee, false, Priority.Normal); + + tenantTask = restClient.authenticateUser(tenantUserAssignee).withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + tenantTask.assertThat().entriesListIsNotEmpty().and().entriesListCountIs(1).and().entriesListContains("assignee", tenantUserAssignee.getUsername()); + } +} From e5587b4398f445bea8092b07411848fcc791078f Mon Sep 17 00:00:00 2001 From: Andrei Rusu Date: Thu, 8 Dec 2016 17:09:15 +0200 Subject: [PATCH 0706/1491] added tests for GetTaskCoreTests --- .../rest/workflow/tasks/GetTaskCoreTests.java | 84 +++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCoreTests.java new file mode 100644 index 000000000..2e23af74b --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCoreTests.java @@ -0,0 +1,84 @@ +package org.alfresco.rest.workflow.tasks; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.dataprep.CMISUtil.Priority; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestTaskModel; +import org.alfresco.utility.model.RestErrorModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TaskModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.apache.commons.lang.RandomStringUtils; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class GetTaskCoreTests extends RestTest +{ + UserModel userModel, candidateUser, assigneeUser; + UserModel adminTenantUser, tenantUser, tenantUserAssignee, adminUser; + SiteModel siteModel; + FileModel fileModel; + TaskModel taskModel; + RestTaskModel restTaskModel, tenantTask; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + assigneeUser = dataUser.createRandomTestUser(); + taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify valid request for auth user which is asignee.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + public void validRequestWithAuthUser() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser).withWorkflowAPI().usingTask(taskModel).getTask(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("message").is(taskModel.getMessage()).and().field("assignee") + .is(assigneeUser.getUsername()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify if using invalid taskId status code 404 is returned.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + public void invalidTaskId() throws Exception + { + taskModel.setId(RandomStringUtils.randomAlphanumeric(20)); + restTaskModel = restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).getTask(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, taskModel.getId())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify that in a network only tasks inside network are returned.") + @Test(groups = { TestGroup.NETWORKS }) + public void tasksInsideNetworkReturned() throws Exception + { + restClient.authenticateUser(adminUser); + + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.usingTenant().createTenant(adminTenantUser); + + tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("userTenant"); + tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("userTenantAssignee"); + + RestProcessModel addedProcess = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee, false, + Priority.Normal); + taskModel = restClient.withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess); + tenantTask = restClient.authenticateUser(tenantUserAssignee).withWorkflowAPI().usingTask(taskModel).getTask(); + restClient.assertStatusCodeIs(HttpStatus.OK); + tenantTask.assertThat().field("assignee").is(tenantUserAssignee.getUsername()).and().field("processId").is(addedProcess.getId()); + } + +} From 610204aabbc0f4a81d0eb92a3f8a8b70d1a56eca Mon Sep 17 00:00:00 2001 From: Bogdan Bocancea Date: Thu, 8 Dec 2016 17:18:22 +0200 Subject: [PATCH 0707/1491] TAS-2080: add core tests for 'delete /tasks/{taskId}/variables/{variableName}' request TAS-2081: add core tests for 'put /tasks/{taskId}/variables/{variableName}' request --- .../tasks/DeleteTaskVariableCoreTests.java | 118 +++++++++++++ .../tasks/GetTaskFormModelCoreTests.java | 2 +- .../tasks/UpdateTaskVariableCoreTests.java | 164 ++++++++++++++++++ 3 files changed, 283 insertions(+), 1 deletion(-) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/tasks/DeleteTaskVariableCoreTests.java create mode 100644 e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskVariableCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/DeleteTaskVariableCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/DeleteTaskVariableCoreTests.java new file mode 100644 index 000000000..824f80379 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/DeleteTaskVariableCoreTests.java @@ -0,0 +1,118 @@ +package org.alfresco.rest.workflow.tasks; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestVariableModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TaskModel; +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 bogdan.bocancea + */ +@Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) +public class DeleteTaskVariableCoreTests extends RestTest +{ + private UserModel userModel; + private SiteModel siteModel; + private FileModel fileModel; + private TaskModel taskModel; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(userModel); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Delete task variable with any user") + public void deleteTaskVarialbleByAnyUser() throws Exception + { + restClient.authenticateUser(userModel); + RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + + restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables() + .assertThat().entriesListDoesNotContain("name", variableModel.getName()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Delete task variable with invalid type") + public void deleteTaskVariableInvalidType() throws Exception + { + restClient.authenticateUser(userModel); + RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); + variableModel.setType("invalid-type"); + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables() + . assertThat().entriesListDoesNotContain("name", variableModel.getName()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Delete task variable with invalid name") + public void deleteTaskVariableInvalidName() throws Exception + { + restClient.authenticateUser(userModel); + RestVariableModel variableModel = new RestVariableModel("local", "<>.,;/|-+=%", "d:text", "invalid name"); + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Create, update, delete task variable with any user") + public void createUpdateDeleteTaskVarialbleByAnyUser() throws Exception + { + restClient.authenticateUser(userModel); + RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + + restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); + variableModel.setName("new-variable"); + restClient.withWorkflowAPI().usingTask(taskModel).updateTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables() + .assertThat().entriesListDoesNotContain("name", variableModel.getName()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Delete task variable by non assigned user") + public void deleteTaskVarialbleByNonAssignedUser() throws Exception + { + UserModel nonAssigned = dataUser.createRandomTestUser(); + RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + + restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); + restClient.authenticateUser(nonAssigned).withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Delete task variable by inexistent user") + public void deleteTaskVarialbleByInexistentUser() throws Exception + { + RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); + restClient.authenticateUser(UserModel.getRandomUserModel()) + .withWorkflowAPI() + .usingTask(taskModel) + .deleteTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + } +} diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelCoreTests.java index 479789cff..1e507afef 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelCoreTests.java @@ -84,7 +84,7 @@ public class GetTaskFormModelCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify user involved in task cannot get completed task form models") + description = "Verify user involved in task can get completed task form models") public void getTaskFormModelsForCompletedTask() throws Exception { UserModel assignedUser = dataUser.createRandomTestUser(); diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskVariableCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskVariableCoreTests.java new file mode 100644 index 000000000..0887b9ee4 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskVariableCoreTests.java @@ -0,0 +1,164 @@ +package org.alfresco.rest.workflow.tasks; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestVariableModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TaskModel; +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 bogdan.bocancea + */ +@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) +public class UpdateTaskVariableCoreTests extends RestTest +{ + private UserModel userModel; + private SiteModel siteModel; + private FileModel fileModel; + private UserModel assigneeUser; + private TaskModel taskModel; + private RestVariableModel taskVariable; + private RestVariableModel variableModel; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + assigneeUser = dataUser.createRandomTestUser(); + taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Update task variable by user who started the process") + public void updateTaskVariableByUserWhoStartedProcess() throws Exception + { + variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + taskVariable = restClient.authenticateUser(userModel) + .withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + variableModel.setValue("new-value"); + variableModel.setName("new-name"); + taskVariable = restClient.authenticateUser(userModel). + withWorkflowAPI().usingTask(taskModel).updateTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + taskVariable.assertThat().field("value").is("new-value") + .and().field("name").is("new-name"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Update task variable with symbols in name") + public void updateTaskVariableWithSymbolsInName() throws Exception + { + String symbolName = "<>.,;-'+=%|[]#*&-+"; + variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + taskVariable = restClient.authenticateUser(userModel) + .withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + variableModel.setName(symbolName); + taskVariable = restClient.authenticateUser(userModel). + withWorkflowAPI().usingTask(taskModel).updateTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + taskVariable.assertThat().field("name").is(symbolName); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Update task variable with invalid task id") + public void updateTaskVariableWithInvalidTaskId() throws Exception + { + TaskModel invalidTask = new TaskModel(userModel.getUsername()); + invalidTask.setId("invalid-task-id"); + taskVariable = restClient.authenticateUser(userModel). + withWorkflowAPI().usingTask(invalidTask) + .updateTaskVariable(RestVariableModel.getRandomTaskVariableModel("local", "d:text")); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, invalidTask.getId())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Update task variable with invalid scope") + public void updateTaskVariableWithInvalidScope() throws Exception + { + variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + taskVariable = restClient.authenticateUser(userModel) + .withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + variableModel.setScope("invalid-scope"); + taskVariable = restClient.authenticateUser(userModel). + withWorkflowAPI().usingTask(taskModel).updateTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.ILLEGAL_SCOPE, "invalid-scope")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Update task variable with invalid type") + public void updateTaskVariableWithInvalidType() throws Exception + { + variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + taskVariable = restClient.authenticateUser(userModel) + .withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + variableModel.setType("d:invalidType"); + taskVariable = restClient.authenticateUser(userModel). + withWorkflowAPI().usingTask(taskModel).updateTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.UNSUPPORTED_TYPE, "d:invalidType")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Update task variable with symbols in value") + public void updateTaskVariableWithSymbolsInValue() throws Exception + { + String symbolValue = "<>.,;-'+=%|[]#*&-+/\\#!@"; + variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + taskVariable = restClient.authenticateUser(userModel) + .withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + variableModel.setValue(symbolValue); + taskVariable = restClient.authenticateUser(userModel). + withWorkflowAPI().usingTask(taskModel).updateTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + taskVariable.assertThat().field("value").is(symbolValue); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Update task variable by non assigned user") + public void updateTaskVariableByNonAssignedUser() throws Exception + { + UserModel nonAssigned = dataUser.createRandomTestUser(); + variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + taskVariable = restClient.authenticateUser(userModel) + .withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + variableModel.setName("new-name"); + taskVariable = restClient.authenticateUser(nonAssigned) + .withWorkflowAPI().usingTask(taskModel).updateTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Update task variable by non assigned user") + public void updateTaskVariableByInexistentser() throws Exception + { + variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + taskVariable = restClient.authenticateUser(userModel) + .withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + variableModel.setName("new-name"); + taskVariable = restClient.authenticateUser(UserModel.getRandomUserModel()) + .withWorkflowAPI().usingTask(taskModel).updateTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + } + +} \ No newline at end of file From c0663bc8f522daf3bc0547c4bcaa7a2972df425c Mon Sep 17 00:00:00 2001 From: mionescu Date: Thu, 8 Dec 2016 17:18:33 +0200 Subject: [PATCH 0708/1491] updated test case --- .../workflow/tasks/AddTaskItemCoreTests.java | 34 ++++++++----------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemCoreTests.java index 1474aa5dc..1c2803d91 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemCoreTests.java @@ -4,6 +4,7 @@ import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestItemModel; import org.alfresco.rest.model.RestVariableModel; import org.alfresco.utility.model.FileModel; @@ -22,13 +23,12 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) public class AddTaskItemCoreTests extends RestTest { - private UserModel userModel, assigneeUser; + private UserModel userModel, assigneeUser, adminUser; private SiteModel siteModel; private FileModel fileModel, document; private TaskModel taskModel; private RestItemModel taskItem; - private UserModel adminUser; private String taskId; @BeforeClass(alwaysRun = true) @@ -53,22 +53,20 @@ public class AddTaskItemCoreTests extends RestTest taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document); restClient.assertStatusCodeIs(HttpStatus.CREATED); - taskItem.assertThat().field("createdAt").is(taskItem.getCreatedAt()).assertThat().field("size").is(taskItem.getSize()).and().field("createdBy") - .is(taskItem.getCreatedBy()).and().field("modifiedAt").is(taskItem.getModifiedAt()).and().field("name").is(taskItem.getName()).and() - .field("modifiedBy").is(taskItem.getModifiedBy()).and().field("id").is(taskItem.getId()).and().field("mimeType").is(taskItem.getMimeType()); + taskItem.assertThat().field("createdAt").isNotEmpty().and().field("size").isNotEmpty().and().field("createdBy").is(adminUser.getUsername()).and() + .field("modifiedAt").isNotEmpty().and().field("name").is(document.getName()).and().field("modifiedBy").is(userModel.getUsername()).and() + .field("id").is(document.getNodeRefWithoutVersion()).and().field("mimeType").is(document.getFileType().mimeType); } + @Bug(id = "ACE-5683") @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task item, is falling in case invalid itemBody is provided") public void failedAddingTaskItemIfInvalidItemBodyIsProvided() throws Exception { - // document3 = dataContent.usingSite(siteModel).createContent(DocumentType.HTML); document.setNodeRef("invalidNodeRef"); - taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary("The entity with id: item with id workspace://SpacesStore/invalidNodeRef not found was not found"); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidNodeRef")); } @@ -76,37 +74,33 @@ public class AddTaskItemCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task item is falling in case empty item body is provided") public void failedAddingTaskItemIfEmptyItemBodyIsProvided() throws Exception { - - // document4 = dataContent.usingSite(siteModel).createContent(DocumentType.PDF); document.setNodeRef(""); - taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - + // TODO - expected error message to be added + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(""); + ; } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task item is falling in case invalid task id is provided") public void failedAddingTaskItemIfInvalidTaskIdIsProvided() throws Exception { - // restClient.authenticateUser(adminUser); - // document5 = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); taskModel.setId("invalidTaskId"); - taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary("The entity with id: invalidTaskId was not found"); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidTaskId")); } @Bug(id = "ACE-5675") @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task item is falling in case incomplete body type is provided") public void failedAddingTaskVariableIfIncompleteBodyIsProvided() throws Exception { - // restClient.authenticateUser(adminUser); RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{}", "tasks/{taskId}/items", taskId); restClient.processModel(RestVariableModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + // TODO - expected error message to be added + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(""); + ; } } From 9f0199878a436e6e248d98ba51da38309815331d Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Thu, 8 Dec 2016 17:33:23 +0200 Subject: [PATCH 0709/1491] fix: GetPeoplePreferencesCoreTests#statusNotFoundIsReturnedForAPersonIDThatDoesNotExist --- .../org/alfresco/rest/people/GetPeoplePreferencesCoreTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesCoreTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesCoreTests.java index 1e302ac36..65e6490d3 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesCoreTests.java @@ -43,7 +43,7 @@ public class GetPeoplePreferencesCoreTests extends RestTest restClient.authenticateUser(userModel).withCoreAPI().usingUser(new UserModel("invalidPersonID", "password")) .getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - restClient.assertLastError().containsSummary("The entity with id: personId is null. was not found"); + restClient.assertLastError().containsSummary("The entity with id: invalidPersonID was not found"); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, From 552559148ff1a020de74399030fd63fc054f0905 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alecsandru=20Prun=C4=83?= Date: Thu, 8 Dec 2016 17:34:14 +0200 Subject: [PATCH 0710/1491] test: Added GetProcessItemsCoreTests --- .../processes/GetProcessItemsCoreTests.java | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsCoreTests.java new file mode 100644 index 000000000..5d13f3599 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsCoreTests.java @@ -0,0 +1,68 @@ +package org.alfresco.rest.workflow.processes; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class GetProcessItemsCoreTests extends RestTest +{ + private FileModel document; + private SiteModel siteModel; + private UserModel adminUser, userWhoStartsTask, assignee; + private RestProcessModel processModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userWhoStartsTask = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin calling getProcessItems can see anything with REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + public void getProcessItemsAsAdminReturnsAnything() throws Exception + { + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems().assertThat().entriesListIsNotEmpty(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify getProcessItems for invalid processId with REST API and status code is NOT_FOUND (404)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + public void getProcessItemsForInvalidProcessId() throws Exception + { + processModel = restClient.authenticateUser(assignee).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processModel.setId("invalidProcessId"); + restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems().assertThat().entriesListIsEmpty(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidProcessId")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify getProcessItems for empty processId with REST API and status code is NOT_FOUND (404)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + public void getProcessItemsForEmptyProcessId() throws Exception + { + processModel = restClient.authenticateUser(assignee).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processModel.setId(""); + restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems().assertThat().entriesListIsEmpty(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); + } +} From 71b204447064425c0157f2b91653ca25bf85b287 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Thu, 8 Dec 2016 17:36:05 +0200 Subject: [PATCH 0711/1491] fix: GetSitesCoreTests#getSitesWithInvalidMaxItems --- e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java index cc603a473..8751b0018 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java @@ -53,7 +53,7 @@ public class GetSitesCoreTests extends RestTest restClient.authenticateUser(regularUser).withParams("maxItems=0=09") .withCoreAPI().getSites(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary("Only positive values supported for maxItems"); + .assertLastError().containsSummary("Invalid paging parameter maxItems:0=09"); } @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, From dcb462421fe96d4127a7c1210d1db9d4849c7585 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Thu, 8 Dec 2016 17:41:46 +0200 Subject: [PATCH 0712/1491] Fix test description --- .../rest/workflow/tasks/UpdateTaskVariableCoreTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskVariableCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskVariableCoreTests.java index 0887b9ee4..d4dfcfeeb 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskVariableCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskVariableCoreTests.java @@ -148,7 +148,7 @@ public class UpdateTaskVariableCoreTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Update task variable by non assigned user") + description = "Update task variable by inexistent user") public void updateTaskVariableByInexistentser() throws Exception { variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); From b0e37a2d32b9b175228d18182fc6bcca232b2723 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Thu, 8 Dec 2016 17:47:37 +0200 Subject: [PATCH 0713/1491] fix: AddCommentSanityTests (annotate one bug) --- .../rest/comments/AddCommentSanityTests.java | 29 ++++++++++++++----- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java index 5743f156b..00fb52d8b 100644 --- a/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java @@ -3,10 +3,15 @@ package org.alfresco.rest.comments; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestCommentModel; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.model.*; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.StatusModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; @@ -14,7 +19,6 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) public class AddCommentSanityTests extends RestTest { private UserModel adminUserModel; @@ -34,6 +38,7 @@ public class AddCommentSanityTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify admin user adds comments with Rest API and status code is 201") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) public void adminIsAbleToAddComment() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); @@ -45,28 +50,34 @@ public class AddCommentSanityTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Manager user adds comments with Rest API and status code is 201") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) public void managerIsAbleToAddComment() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); String contentSiteManger = "This is a new comment added by user with role: " + UserRole.SiteManager; - restClient.withCoreAPI().usingResource(document).addComment(contentSiteManger) - .assertThat().field("content").isNotEmpty() - .and().field("content").is(contentSiteManger); + RestCommentModel createdComment = restClient.withCoreAPI().usingResource(document).addComment(contentSiteManger); restClient.assertStatusCodeIs(HttpStatus.CREATED); + createdComment.assertThat().field("content").isNotEmpty() + .and().field("content").is(contentSiteManger); + } @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Contributor user adds comments with Rest API and status code is 201") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) + @Bug(id="ACE-4614") public void contributorIsAbleToAddComment() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); String contentSiteContributor = "This is a new comment added by user with role" + UserRole.SiteContributor; - restClient.withCoreAPI().usingResource(document).addComment(contentSiteContributor) - .assertThat().field("content").isNotEmpty() - .and().field("content").is(contentSiteContributor); + RestCommentModel createdComment = restClient.withCoreAPI().usingResource(document).addComment(contentSiteContributor); restClient.assertStatusCodeIs(HttpStatus.CREATED); + createdComment.assertThat().field("content").isNotEmpty() + .and().field("content").is(contentSiteContributor); + } @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user adds comments with Rest API and status code is 201") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) public void collaboratorIsAbleToAddComment() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); @@ -78,6 +89,7 @@ public class AddCommentSanityTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Consumer user can't add comments with Rest API and status code is 403") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) public void consumerIsNotAbleToAddComment() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); @@ -89,6 +101,7 @@ public class AddCommentSanityTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user gets status code 401 on post comments call") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) @Bug(id = "MNT-16904") public void unauthenticatedUserIsNotAbleToAddComment() throws JsonToModelConversionException, Exception { From b4eba40e43d49b2d6d3bbeb618e39d178e8b3439 Mon Sep 17 00:00:00 2001 From: mionescu Date: Thu, 8 Dec 2016 18:15:48 +0200 Subject: [PATCH 0714/1491] test:added AddProcessVariableCoreTests --- .../AddProcessVariableCoreTests.java | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableCoreTests.java index c16dafe72..5d45710d2 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableCoreTests.java @@ -31,41 +31,40 @@ public class AddProcessVariableCoreTests extends RestTest public void dataPreparation() throws Exception { adminUser = dataUser.getAdminUser(); + anotherUser = dataUser.createRandomTestUser(); userWhoStartsProcess = dataUser.createRandomTestUser(); assignee = dataUser.createRandomTestUser(); siteModel = dataSite.usingUser(userWhoStartsProcess).createPublicRandomSite(); document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); - anotherUser = dataUser.createRandomTestUser(); - - adminUser = dataUser.getAdminUser(); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Add process variable using by the user who started the process.") + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add process variable using by the user who started the process.") public void addProcessVariableByUserThatStartedTheProcess() throws Exception { - processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); processVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.OK); - processVariable.assertThat().field("name").is(variableModel.getName()).and().field("type").is(variableModel.getType()).and().field("value") - .is(variableModel.getValue()); + processVariable.assertThat().field("name").is(processVariable.getName()).and().field("type").is(processVariable.getType()).and().field("value") + .is(processVariable.getValue()); + } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Add process variable using by a random user.") + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add process variable using by a random user.") public void addProcessVariableByAnyUser() throws Exception { - processModel = restClient.authenticateUser(anotherUser).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(anotherUser).withWorkflowAPI().addProcess("activitiAdhoc", anotherUser, false, Priority.Normal); processVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.OK); - processVariable.assertThat().field("name").is(variableModel.getName()).and().field("type").is(variableModel.getType()).and().field("value") - .is(variableModel.getValue()); + processVariable.assertThat().field("name").is(processVariable.getName()).and().field("type").is(processVariable.getType()).and().field("value") + .is(processVariable.getValue()); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Add process variable using by admin in other network.") + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add process variable using by admin in other network.") public void addProcessVariableByAdminInOtherNetwork() throws Exception { adminTenantUser = UserModel.getAdminTenantUser(); From f7966d77ac73e89aba260f7e7b91d971559fbd8d Mon Sep 17 00:00:00 2001 From: cagache Date: Fri, 9 Dec 2016 08:36:49 +0200 Subject: [PATCH 0715/1491] test: added Test annotation on test level --- .../rest/workflow/tasks/AddTaskItemCoreTests.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemCoreTests.java index 1c2803d91..f67e7771c 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemCoreTests.java @@ -20,7 +20,6 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) public class AddTaskItemCoreTests extends RestTest { private UserModel userModel, assigneeUser, adminUser; @@ -45,6 +44,7 @@ public class AddTaskItemCoreTests extends RestTest restClient.authenticateUser(userModel); } + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Add task item using random user.") public void addTaskItemByRandomUser() throws JsonToModelConversionException, Exception { @@ -56,10 +56,10 @@ public class AddTaskItemCoreTests extends RestTest taskItem.assertThat().field("createdAt").isNotEmpty().and().field("size").isNotEmpty().and().field("createdBy").is(adminUser.getUsername()).and() .field("modifiedAt").isNotEmpty().and().field("name").is(document.getName()).and().field("modifiedBy").is(userModel.getUsername()).and() .field("id").is(document.getNodeRefWithoutVersion()).and().field("mimeType").is(document.getFileType().mimeType); - } @Bug(id = "ACE-5683") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task item, is falling in case invalid itemBody is provided") public void failedAddingTaskItemIfInvalidItemBodyIsProvided() throws Exception { @@ -67,10 +67,10 @@ public class AddTaskItemCoreTests extends RestTest taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidNodeRef")); - } @Bug(id = "ACE-5675") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task item is falling in case empty item body is provided") public void failedAddingTaskItemIfEmptyItemBodyIsProvided() throws Exception { @@ -79,9 +79,9 @@ public class AddTaskItemCoreTests extends RestTest // TODO - expected error message to be added restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(""); - ; } + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task item is falling in case invalid task id is provided") public void failedAddingTaskItemIfInvalidTaskIdIsProvided() throws Exception { @@ -92,6 +92,7 @@ public class AddTaskItemCoreTests extends RestTest } @Bug(id = "ACE-5675") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task item is falling in case incomplete body type is provided") public void failedAddingTaskVariableIfIncompleteBodyIsProvided() throws Exception { @@ -100,7 +101,5 @@ public class AddTaskItemCoreTests extends RestTest // TODO - expected error message to be added restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(""); - ; } - } From 7a801aff48f1284f58e47e3667c7fb0d2903e8a9 Mon Sep 17 00:00:00 2001 From: cagache Date: Fri, 9 Dec 2016 08:45:25 +0200 Subject: [PATCH 0716/1491] test: add core tests for getTaskItems (get /tasks/{taskId}/items) --- .../workflow/tasks/GetTaskItemsCoreTests.java | 86 +++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskItemsCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskItemsCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskItemsCoreTests.java new file mode 100644 index 000000000..88a8ec16f --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskItemsCoreTests.java @@ -0,0 +1,86 @@ +package org.alfresco.rest.workflow.tasks; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.*; +import org.alfresco.utility.model.*; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Created by Claudia Agache on 12/8/2016. + */ +public class GetTaskItemsCoreTests extends RestTest +{ + private UserModel userWhoStartsTask, assignee, adminTenantUser, tenantUser, tenantUserAssignee; + private SiteModel siteModel; + private FileModel fileModel; + private TaskModel taskModel; + private RestItemModel taskItem; + private RestItemModelsCollection itemModels; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + userWhoStartsTask = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); + fileModel = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify if get task items call return status code 404 when invalid taskId is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + public void getTaskItemsUsingInvalidTaskId() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); + taskModel.setId("invalidId"); + + restClient.authenticateUser(assignee).withWorkflowAPI() + .usingTask(taskModel).getTaskItems(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidId")); + + taskModel.setId(""); + + restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() + .usingTask(taskModel).getTaskItems(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, + executionType = ExecutionType.REGRESSION, + description = "Verify if get task items request returns status code 200 after the task is finished.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + public void getTaskItemsAfterFinishingTask() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); + dataWorkflow.usingUser(assignee).taskDone(taskModel); + restClient.authenticateUser(userWhoStartsTask); + itemModels = restClient.withWorkflowAPI().usingTask(taskModel).getTaskItems(); + restClient.assertStatusCodeIs(HttpStatus.OK); + itemModels.assertThat().entriesListIsNotEmpty().and().entriesListContains("name", fileModel.getName()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, + executionType = ExecutionType.REGRESSION, + description = "Verify if get task items request returns status code 200 after the process is deleted (Task state is now completed.)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + public void getTaskItemsAfterDeletingProcess() throws Exception + { + RestProcessModel addedProcess = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.Normal); + RestTaskModel addedTask = restClient.withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess); + restClient.withWorkflowAPI().usingTask(addedTask).addTaskItem(fileModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.withWorkflowAPI().usingProcess(addedProcess).deleteProcess(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + itemModels = restClient.withWorkflowAPI().usingTask(addedTask).getTaskItems(); + restClient.assertStatusCodeIs(HttpStatus.OK); + itemModels.assertThat().entriesListIsNotEmpty().and().entriesListContains("name", fileModel.getName()); + } +} From bbcf21d175f912bade3aa9a5c22804a6df1a3094 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alecsandru=20Prun=C4=83?= Date: Fri, 9 Dec 2016 09:10:32 +0200 Subject: [PATCH 0717/1491] test: Renamed AddProcessVariableCoreTests to AddProcessVariablesCoreTests --- ...leCoreTests.java => AddProcessVariablesCoreTests.java} | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) rename e2e-test/java/org/alfresco/rest/workflow/processes/{AddProcessVariableCoreTests.java => AddProcessVariablesCoreTests.java} (92%) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesCoreTests.java similarity index 92% rename from e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableCoreTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesCoreTests.java index e1f7ff536..02976af0b 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesCoreTests.java @@ -15,8 +15,7 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) -public class AddProcessVariableCoreTests extends RestTest +public class AddProcessVariablesCoreTests extends RestTest { private FileModel document; private SiteModel siteModel; @@ -37,7 +36,7 @@ public class AddProcessVariableCoreTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify addProcessVariable by admin in other network with REST API and status code is FORBIDDEN (403)") - @Test(groups = { TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY, TestGroup.NETWORKS }) public void addProcessVariableByAdminInOtherNetworkIsForbidden() throws Exception { adminTenantUser = UserModel.getAdminTenantUser(); @@ -58,6 +57,7 @@ public class AddProcessVariableCoreTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify addProcessVariable by any user with REST API and status code is CREATED (201)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public void addProcessVariableByAnyUser() throws Exception { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); @@ -75,6 +75,7 @@ public class AddProcessVariableCoreTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify addProcessVariable by any user for invalid processID with REST API and status code is NOT_FOUND (404)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public void addProcessVariableForInvalidProcessIdIsNotFound() throws Exception { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); @@ -88,6 +89,7 @@ public class AddProcessVariableCoreTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify addProcessVariable by any user for empty processID with REST API and status code is NOT_FOUND (404)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public void addProcessVariableForInvalidProcessIdIsEmpty() throws Exception { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); From e140de25eae588a0e9973fded42a63f2f69249cd Mon Sep 17 00:00:00 2001 From: Andrei Rusu Date: Fri, 9 Dec 2016 11:34:04 +0200 Subject: [PATCH 0718/1491] made the changes according to review comments --- .../rest/workflow/tasks/GetTaskCoreTests.java | 35 +++++++++++-------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCoreTests.java index 2e23af74b..ef814a29e 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCoreTests.java @@ -3,9 +3,11 @@ package org.alfresco.rest.workflow.tasks; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.CMISUtil.Priority; import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.rest.model.RestTaskModel; -import org.alfresco.utility.model.RestErrorModel; +import org.alfresco.rest.model.RestTaskModelsCollection; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TaskModel; @@ -14,13 +16,14 @@ import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.apache.commons.lang.RandomStringUtils; +import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; public class GetTaskCoreTests extends RestTest { - UserModel userModel, candidateUser, assigneeUser; + UserModel userModel, assigneeUser; UserModel adminTenantUser, tenantUser, tenantUserAssignee, adminUser; SiteModel siteModel; FileModel fileModel; @@ -38,17 +41,6 @@ public class GetTaskCoreTests extends RestTest taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); } - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify valid request for auth user which is asignee.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void validRequestWithAuthUser() throws Exception - { - restTaskModel = restClient.authenticateUser(assigneeUser).withWorkflowAPI().usingTask(taskModel).getTask(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("message").is(taskModel.getMessage()).and().field("assignee") - .is(assigneeUser.getUsername()); - } - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify if using invalid taskId status code 404 is returned.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) @@ -60,6 +52,18 @@ public class GetTaskCoreTests extends RestTest .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, taskModel.getId())); } + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify if using empty taskId status code 404 is returned.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + public void emptyTaskId() throws Exception + { + restClient.authenticateUser(userModel).withCoreAPI(); + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "tasks/{taskId}?{parameters}", "", restClient.getParameters()); + restClient.processModels(RestTaskModelsCollection.class, request); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.UNABLE_TO_LOCATE, taskModel.getId())); + } + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify that in a network only tasks inside network are returned.") @Test(groups = { TestGroup.NETWORKS }) @@ -75,10 +79,11 @@ public class GetTaskCoreTests extends RestTest RestProcessModel addedProcess = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee, false, Priority.Normal); + restClient.assertStatusCodeIs(HttpStatus.CREATED); taskModel = restClient.withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess); tenantTask = restClient.authenticateUser(tenantUserAssignee).withWorkflowAPI().usingTask(taskModel).getTask(); restClient.assertStatusCodeIs(HttpStatus.OK); - tenantTask.assertThat().field("assignee").is(tenantUserAssignee.getUsername()).and().field("processId").is(addedProcess.getId()); + tenantTask.assertThat().field("assignee").is(String.format("userTenantAssignee@%s", tenantUserAssignee.getDomain().toLowerCase())).and() + .field("processId").is(addedProcess.getId()); } - } From a12731480f093f8f6ab4edb022b281e47a3aa661 Mon Sep 17 00:00:00 2001 From: Andrei Rusu Date: Fri, 9 Dec 2016 11:38:34 +0200 Subject: [PATCH 0719/1491] added changes to assigneeUserGetsItsTaskWithSuccess() test. --- .../workflow/tasks/GetTaskSanityTests.java | 61 ++++++++++--------- 1 file changed, 31 insertions(+), 30 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskSanityTests.java index e7598ab35..5b968ecc6 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskSanityTests.java @@ -1,5 +1,4 @@ - package org.alfresco.rest.workflow.tasks; import org.alfresco.dataprep.CMISUtil.DocumentType; @@ -29,7 +28,7 @@ public class GetTaskSanityTests extends RestTest TaskModel taskModel; RestTaskModel restTaskModel; - @BeforeClass(alwaysRun=true) + @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception { userModel = dataUser.createRandomTestUser(); @@ -39,46 +38,49 @@ public class GetTaskSanityTests extends RestTest taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); } - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify admin user gets any existing task with Rest API and response is successfull (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify admin user gets any existing task with Rest API and response is successfull (200)") public void adminUserGetsAnyTaskWithSuccess() throws Exception { UserModel adminUser = dataUser.getAdminUser(); - + restTaskModel = restClient.authenticateUser(adminUser).withWorkflowAPI().usingTask(taskModel).getTask(); restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("message").is(taskModel.getMessage()); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("message").is(taskModel.getMessage()); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify assignee user gets its assigned task with Rest API and response is successfull (200)") + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify assignee user gets its assigned task with Rest API and response is successfull (200)") public void assigneeUserGetsItsTaskWithSuccess() throws Exception { restTaskModel = restClient.authenticateUser(assigneeUser).withWorkflowAPI().usingTask(taskModel).getTask(); restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("message").is(taskModel.getMessage()); - + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("message").is(taskModel.getMessage()).and().field("assignee") + .is(assigneeUser.getUsername()); + } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify user that started the task gets the started task with Rest API and response is successfull (200)") + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify user that started the task gets the started task with Rest API and response is successfull (200)") public void starterUserGetsItsTaskWithSuccess() throws Exception { restTaskModel = restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).getTask(); restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("message").is(taskModel.getMessage()); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("message").is(taskModel.getMessage()); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify any user with no relation to task id forbidden to get other task with Rest API (403)") + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify any user with no relation to task id forbidden to get other task with Rest API (403)") public void anyUserIsForbiddenToGetOtherTask() throws Exception { - UserModel anyUser= dataUser.createRandomTestUser(); - + UserModel anyUser = dataUser.createRandomTestUser(); + restTaskModel = restClient.authenticateUser(anyUser).withWorkflowAPI().usingTask(taskModel).getTask(); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify candidate user gets its specific task and no other user claimed the task with Rest API and response is successfull (200)") + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify candidate user gets its specific task and no other user claimed the task with Rest API and response is successfull (200)") public void candidateUserGetsItsTasks() throws Exception { UserModel userModel1 = dataUser.createRandomTestUser(); @@ -86,16 +88,16 @@ public class GetTaskSanityTests extends RestTest GroupModel group = dataGroup.createRandomGroup(); dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); TaskModel taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); - + restTaskModel = restClient.authenticateUser(userModel1).withWorkflowAPI().usingTask(taskModel).getTask(); restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("message").is(taskModel.getMessage()); - + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("message").is(taskModel.getMessage()); + } - + @Bug(id = "MNT-17051") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify involved user in a task without claim it gets the task with Rest API and response is successfull (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify involved user in a task without claim it gets the task with Rest API and response is successfull (200)") public void involvedUserWithoutClaimTaskGetsTask() throws Exception { UserModel userModel1 = dataUser.createRandomTestUser(); @@ -104,10 +106,9 @@ public class GetTaskSanityTests extends RestTest dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); TaskModel taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); dataWorkflow.usingUser(userModel1).claimTask(taskModel); - + restTaskModel = restClient.authenticateUser(userModel2).withWorkflowAPI().usingTask(taskModel).getTask(); restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("message").is(taskModel.getMessage()); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("message").is(taskModel.getMessage()); } } \ No newline at end of file From 08ebf24cc9513262f299c28f235152a8edc0294d Mon Sep 17 00:00:00 2001 From: mionescu Date: Fri, 9 Dec 2016 11:41:01 +0200 Subject: [PATCH 0720/1491] test:added AddProcessItemCoreTests.java --- .../processes/AddProcessItemCoreTests.java | 159 ++++++++++++++++++ 1 file changed, 159 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemCoreTests.java new file mode 100644 index 000000000..735c039de --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemCoreTests.java @@ -0,0 +1,159 @@ +package org.alfresco.rest.workflow.processes; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestItemModel; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class AddProcessItemCoreTests extends RestTest +{ + private FileModel document; + private SiteModel siteModel; + private UserModel userWhoStartsProcess, assignee, adminUser, adminTenantUser, tenantUserAssignee, adminTenantUser2, tenantUser; + private RestProcessModel processModel; + private RestItemModel processItem; + + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userWhoStartsProcess = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add process item using by the user who started the process.") + public void addProcessItemByUserThatStartedTheProcess() throws Exception + { + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + // document = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); + + restClient.assertStatusCodeIs(HttpStatus.CREATED); + processItem.assertThat().field("createdAt").isNotEmpty().and().field("size").is("19").and().field("createdBy").is(adminUser.getUsername()).and() + .field("modifiedAt").isNotEmpty().and().field("name").is(document.getName()).and().field("modifiedBy").is(userWhoStartsProcess.getUsername()) + .and().field("id").isNotEmpty().and().field("mimeType").is(document.getFileType().mimeType); + + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add process item by a random user.") + public void addProcessItemByAnyUser() throws Exception + { + processModel = restClient.authenticateUser(assignee).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); + + restClient.assertStatusCodeIs(HttpStatus.CREATED); + processItem.assertThat().field("createdAt").isNotEmpty().and().field("size").is("19").and().field("createdBy").is(adminUser.getUsername()).and() + .field("modifiedAt").isNotEmpty().and().field("name").is(document.getName()).and().field("modifiedBy").is(assignee.getUsername()).and() + .field("id").isNotEmpty().and().field("mimeType").is(document.getFileType().mimeType); + + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, description = "Add process item using by the admin in same network.") + public void addProcessItemByAdminSameNetwork() throws Exception + { + restClient.authenticateUser(adminUser); + + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.usingTenant().createTenant(adminTenantUser); + + tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); + + siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); + dataWorkflow.usingUser(tenantUser).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(tenantUserAssignee); + + processModel = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); + + restClient.assertStatusCodeIs(HttpStatus.CREATED); + processItem.assertThat().field("createdAt").isNotEmpty().and().field("size").is("19").and().field("createdBy").is(adminTenantUser.getUsername()).and() + .field("modifiedAt").isNotEmpty().and().field("name").is(document.getName()).and().field("modifiedBy").is(adminTenantUser.getUsername()).and() + .field("id").isNotEmpty().and().field("mimeType").is(document.getFileType().mimeType); + + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES, TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Add process item using by admin in other network.") + public void addProcessItemByAdminInOtherNetwork() throws Exception + { + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser); + tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); + + adminTenantUser2 = UserModel.getAdminTenantUser(); + restClient.usingTenant().createTenant(adminTenantUser2); + + processModel = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + restClient.authenticateUser(adminTenantUser2); + processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process item is falling in case of invalid process id is provided") + public void failedAddingProcessItemIfInvalidProcessIdIsProvided() throws Exception + { + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processModel.setId("invalidProcessId"); + processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidProcessId")); + } + + @Bug(id = "ACE-5683") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process item is falling in case of invalid body item is provided") + public void failedAddingProcessItemIfInvalidItemBodyIsProvided() throws Exception + { + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{\"id\":\"invalidId\"}", "processes/{processId}/items", processModel.getId()); + restClient.processModel(RestItemModel.class, request); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidId")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process item is falling in case of empty body item value is provided") + public void failedAddingProcessItemIfEmptyItemBodyIsProvided() throws Exception + { + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{\"id\":\"\"}", "processes/{processId}/items", processModel.getId()); + restClient.processModel(RestItemModel.class, request); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("itemId is required to add an attached item"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process item is falling in case of incomplete body (empty) is provided") + public void failedAddingProcessItemIfIncompleteBodyIsProvided() throws Exception + { + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{}", "processes/{processId}/items", processModel.getId()); + restClient.processModel(RestItemModel.class, request); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("itemId is required to add an attached item"); + } + +} From d7c10d4658cb5e289a28a2572fb950c3f97d2f83 Mon Sep 17 00:00:00 2001 From: cagache Date: Fri, 9 Dec 2016 11:46:40 +0200 Subject: [PATCH 0721/1491] test: add core tests for getTaskItems (get /tasks/{taskId}/items) --- .../workflow/tasks/GetTaskItemsCoreTests.java | 77 +++++++++++++++++-- 1 file changed, 71 insertions(+), 6 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskItemsCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskItemsCoreTests.java index 88a8ec16f..916c52283 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskItemsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskItemsCoreTests.java @@ -1,6 +1,6 @@ package org.alfresco.rest.workflow.tasks; -import org.alfresco.dataprep.CMISUtil; +import org.alfresco.dataprep.CMISUtil.*; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.*; import org.alfresco.utility.model.*; @@ -15,12 +15,13 @@ import org.testng.annotations.Test; */ public class GetTaskItemsCoreTests extends RestTest { - private UserModel userWhoStartsTask, assignee, adminTenantUser, tenantUser, tenantUserAssignee; + private UserModel adminUser, userWhoStartsTask, assignee; private SiteModel siteModel; private FileModel fileModel; private TaskModel taskModel; - private RestItemModel taskItem; private RestItemModelsCollection itemModels; + private RestProcessModel addedProcess; + private RestTaskModel addedTask; @BeforeClass(alwaysRun=true) public void dataPreparation() throws Exception @@ -28,7 +29,8 @@ public class GetTaskItemsCoreTests extends RestTest userWhoStartsTask = dataUser.createRandomTestUser(); assignee = dataUser.createRandomTestUser(); siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + adminUser = dataUser.getAdminUser(); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, @@ -72,8 +74,8 @@ public class GetTaskItemsCoreTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) public void getTaskItemsAfterDeletingProcess() throws Exception { - RestProcessModel addedProcess = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.Normal); - RestTaskModel addedTask = restClient.withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess); + addedProcess = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); + addedTask = restClient.withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess); restClient.withWorkflowAPI().usingTask(addedTask).addTaskItem(fileModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); restClient.withWorkflowAPI().usingProcess(addedProcess).deleteProcess(); @@ -83,4 +85,67 @@ public class GetTaskItemsCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); itemModels.assertThat().entriesListIsNotEmpty().and().entriesListContains("name", fileModel.getName()); } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify gets task items call with admin from different network") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE, TestGroup.NETWORKS }) + public void getTaskItemsByAdminFromAnotherNetwork() throws Exception + { + UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); + UserModel adminTenantUser2 = UserModel.getAdminTenantUser(); + + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser1); + restClient.usingTenant().createTenant(adminTenantUser2); + + UserModel tenantUser1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenant"); + UserModel tenantUserAssignee1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenantAssignee"); + + siteModel = dataSite.usingUser(adminTenantUser1).createPublicRandomSite(); + fileModel = dataContent.usingUser(adminTenantUser1).usingSite(siteModel).createContent(DocumentType.XML); + addedProcess = restClient.authenticateUser(tenantUser1).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee1, false, Priority.Normal); + addedTask = restClient.withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess); + restClient.withWorkflowAPI().usingTask(addedTask).addTaskItem(fileModel); + + restClient.authenticateUser(adminTenantUser2).withWorkflowAPI().usingTask(addedTask).getTaskItems(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify gets task items call returns only task items inside network") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE, TestGroup.NETWORKS }) + public void getTaskItemsReturnsOnlyItemsFromThatNetwork() throws Exception + { + UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); + UserModel adminTenantUser2 = UserModel.getAdminTenantUser(); + + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser1); + restClient.usingTenant().createTenant(adminTenantUser2); + + UserModel tenantUser1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenant1"); + UserModel tenantUser2 = dataUser.usingUser(adminTenantUser2).createUserWithTenant("uTenant2"); + + SiteModel siteModel1 = dataSite.usingUser(adminTenantUser1).createPublicRandomSite(); + FileModel fileModel1 = dataContent.usingUser(adminTenantUser1).usingSite(siteModel1).createContent(DocumentType.XML); + + RestProcessModel addedProcess1 = restClient.authenticateUser(adminTenantUser1).withWorkflowAPI().addProcess("activitiAdhoc", tenantUser1, false, Priority.Normal); + RestTaskModel addedTask1 = restClient.withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess1); + RestItemModel taskItem1 = restClient.withWorkflowAPI().usingTask(addedTask1).addTaskItem(fileModel1); + + SiteModel siteModel2 = dataSite.usingUser(adminTenantUser2).createPublicRandomSite(); + FileModel fileModel2 = dataContent.usingUser(adminTenantUser2).usingSite(siteModel2).createContent(DocumentType.XML); + + RestProcessModel addedProcess2 = restClient.authenticateUser(adminTenantUser2).withWorkflowAPI().addProcess("activitiAdhoc", tenantUser2, false, Priority.Normal); + RestTaskModel addedTask2 = restClient.withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess2); + RestItemModel taskItem2 = restClient.withWorkflowAPI().usingTask(addedTask2).addTaskItem(fileModel2); + + itemModels = restClient.withWorkflowAPI().usingTask(addedTask2).getTaskItems(); + restClient.assertStatusCodeIs(HttpStatus.OK); + itemModels.assertThat() + .entriesListIsNotEmpty().and() + .entriesListContains("id", taskItem2.getId()).and() + .entriesListContains("name", fileModel2.getName()).and() + .entriesListDoesNotContain("id", taskItem1.getId()).and() + .entriesListDoesNotContain("name", fileModel1.getName()); + } } From 47754491b035069272cc2f61b90a46a040c7cadf Mon Sep 17 00:00:00 2001 From: mionescu Date: Fri, 9 Dec 2016 11:49:32 +0200 Subject: [PATCH 0722/1491] test: updated after review AddProcessVariableCoreTests.java --- .../processes/AddProcessVariableCoreTests.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableCoreTests.java index 5d45710d2..fe00d57bb 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableCoreTests.java @@ -4,6 +4,7 @@ import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.CMISUtil.Priority; import org.alfresco.rest.RestTest; import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.rest.model.RestProcessVariableModel; import org.alfresco.utility.model.FileModel; @@ -18,7 +19,6 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) public class AddProcessVariableCoreTests extends RestTest { private FileModel document; @@ -39,6 +39,7 @@ public class AddProcessVariableCoreTests extends RestTest dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); } + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add process variable using by the user who started the process.") public void addProcessVariableByUserThatStartedTheProcess() throws Exception { @@ -49,9 +50,9 @@ public class AddProcessVariableCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); processVariable.assertThat().field("name").is(processVariable.getName()).and().field("type").is(processVariable.getType()).and().field("value") .is(processVariable.getValue()); - } + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add process variable using by a random user.") public void addProcessVariableByAnyUser() throws Exception { @@ -64,7 +65,8 @@ public class AddProcessVariableCoreTests extends RestTest .is(processVariable.getValue()); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add process variable using by admin in other network.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, description = "Add process variable using by admin in other network.") public void addProcessVariableByAdminInOtherNetwork() throws Exception { adminTenantUser = UserModel.getAdminTenantUser(); @@ -82,6 +84,7 @@ public class AddProcessVariableCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Process is running in another tenant"); } + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process variable is falling in case invalid type is provided") public void failedAddingProcessVariableIfInvalidTypeIsProvided() throws Exception { @@ -93,6 +96,7 @@ public class AddProcessVariableCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Unsupported type of variable: 'd:textarea'."); } + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) @Bug(id = "ACE-5674") @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process variable is falling in case invalid type prefix is provided") public void failedAddingProcessVariableIfInvalidTypePrefixIsProvided() throws Exception @@ -105,6 +109,7 @@ public class AddProcessVariableCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Namespace prefix ddt is not mapped to a namespace URI"); } + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process variable is falling in case invalid value is provided") public void failedAddingProcessVariableIfInvalidValueIsProvided() throws Exception { @@ -117,6 +122,7 @@ public class AddProcessVariableCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("For input string: \"invalidValue\""); } + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process variable is falling in case missing required variable body (name) is provided") public void failedAddingProcessVariableIfMissingRequiredVariableBodyIsProvided() throws Exception { @@ -129,6 +135,7 @@ public class AddProcessVariableCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Variable name is required."); } + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process variable is falling in case invalid variableBody (adding extra parameter in body) is provided") public void failedAddingProcessVariableIfInvalidBodyIsProvided() throws Exception { @@ -142,6 +149,7 @@ public class AddProcessVariableCoreTests extends RestTest .containsSummary("Could not read content from HTTP request body: Unrecognized field \"scope\""); } + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process variable is falling in case empty name is provided") public void failedAddingProcessVariableIfEmptyNameIsProvided() throws Exception { @@ -152,7 +160,7 @@ public class AddProcessVariableCoreTests extends RestTest processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary("PUT is executed against the instance URL"); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.PUT_EMPTY_ARGUMENT); } } From b0aa139cf130229656ae5c7bee6dc6bbaa9ee935 Mon Sep 17 00:00:00 2001 From: mionescu Date: Fri, 9 Dec 2016 12:29:49 +0200 Subject: [PATCH 0723/1491] test: added - AddProcessItemCoreTests.java core: added new error message: RestErrorModel.java --- .../processes/AddProcessItemCoreTests.java | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemCoreTests.java index 735c039de..413031203 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemCoreTests.java @@ -1,6 +1,7 @@ package org.alfresco.rest.workflow.processes; import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.dataprep.CMISUtil.Priority; import org.alfresco.rest.RestTest; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.model.RestErrorModel; @@ -26,7 +27,6 @@ public class AddProcessItemCoreTests extends RestTest private RestProcessModel processModel; private RestItemModel processItem; - @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception { @@ -43,7 +43,6 @@ public class AddProcessItemCoreTests extends RestTest public void addProcessItemByUserThatStartedTheProcess() throws Exception { processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - // document = dataContent.usingSite(siteModel).createContent(DocumentType.XML); processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); restClient.assertStatusCodeIs(HttpStatus.CREATED); @@ -67,12 +66,11 @@ public class AddProcessItemCoreTests extends RestTest } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, description = "Add process item using by the admin in same network.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE, TestGroup.NETWORKS }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add process item using by the admin in same network.") public void addProcessItemByAdminSameNetwork() throws Exception { restClient.authenticateUser(adminUser); - adminTenantUser = UserModel.getAdminTenantUser(); restClient.usingTenant().createTenant(adminTenantUser); @@ -82,18 +80,18 @@ public class AddProcessItemCoreTests extends RestTest siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); dataWorkflow.usingUser(tenantUser).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(tenantUserAssignee); - processModel = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processModel = restClient.withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); restClient.assertStatusCodeIs(HttpStatus.CREATED); - processItem.assertThat().field("createdAt").isNotEmpty().and().field("size").is("19").and().field("createdBy").is(adminTenantUser.getUsername()).and() - .field("modifiedAt").isNotEmpty().and().field("name").is(document.getName()).and().field("modifiedBy").is(adminTenantUser.getUsername()).and() + processItem.assertThat().field("createdAt").isNotEmpty().and().field("size").is("19").and().field("createdBy").is(adminUser.getUsername()).and() + .field("modifiedAt").isNotEmpty().and().field("name").is(document.getName()).and().field("modifiedBy").is(adminUser.getUsername()).and() .field("id").isNotEmpty().and().field("mimeType").is(document.getFileType().mimeType); } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES, TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Add process item using by admin in other network.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE, TestGroup.NETWORKS }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Add process item using by admin in other network.") public void addProcessItemByAdminInOtherNetwork() throws Exception { adminTenantUser = UserModel.getAdminTenantUser(); @@ -103,7 +101,7 @@ public class AddProcessItemCoreTests extends RestTest adminTenantUser2 = UserModel.getAdminTenantUser(); restClient.usingTenant().createTenant(adminTenantUser2); - processModel = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processModel = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee, false, Priority.Normal); restClient.authenticateUser(adminTenantUser2); processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT); @@ -141,7 +139,7 @@ public class AddProcessItemCoreTests extends RestTest RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{\"id\":\"\"}", "processes/{processId}/items", processModel.getId()); restClient.processModel(RestItemModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("itemId is required to add an attached item"); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.REQUIRED_TO_ADD, "itemId")); } @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) @@ -153,7 +151,7 @@ public class AddProcessItemCoreTests extends RestTest RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{}", "processes/{processId}/items", processModel.getId()); restClient.processModel(RestItemModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("itemId is required to add an attached item"); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.REQUIRED_TO_ADD, "itemId")); } } From c6758546e52bb0d4684bb5eec353576888974d3b Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Fri, 9 Dec 2016 13:39:48 +0200 Subject: [PATCH 0724/1491] added DeleteSiteMembershipRequestCoreTests --- .../DeleteSiteMembershipRequestCoreTests.java | 147 ++++++++++++++++++ 1 file changed, 147 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestCoreTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestCoreTests.java new file mode 100644 index 000000000..9e1df0cf6 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestCoreTests.java @@ -0,0 +1,147 @@ +package org.alfresco.rest.people; + +import org.alfresco.dataprep.WorkflowService; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestTaskModel; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.exception.DataPreparationException; +import org.alfresco.rest.model.RestErrorModel; +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.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +public class DeleteSiteMembershipRequestCoreTests extends RestTest +{ + SiteModel moderatedSite; + UserModel adminUserModel; + UserModel siteMember; + UserModel secondSiteMember; + SiteModel secondModeratedSite; + @Autowired WorkflowService workflow; + + @BeforeMethod(alwaysRun = true) + public void dataPreparation() throws Exception + { + moderatedSite = dataSite.usingUser(adminUserModel).createModeratedRandomSite(); + adminUserModel = dataUser.getAdminUser(); + siteMember = dataUser.createRandomTestUser(); + secondSiteMember = dataUser.createRandomTestUser(); + secondModeratedSite = dataSite.usingUser(siteMember).createModeratedRandomSite(); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is able to remove his own site memebership request using '-me-' in place of personId and response is successful (204)") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + public void userCanDeleteHisOwnSiteMembershipRequestUsingMeAsPersonId() throws JsonToModelConversionException, DataPreparationException, Exception + { + restClient.authenticateUser(siteMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + restClient.withCoreAPI().usingMe().deleteSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove site memebership request if doesn't have access to personI and response is 403") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + public void userIsNotAbleToDeleteSiteMembershipRequestWithNoAccessToPersonId() throws JsonToModelConversionException, DataPreparationException, Exception + { + restClient.authenticateUser(secondSiteMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + restClient.authenticateUser(siteMember).withCoreAPI().usingUser(secondSiteMember).deleteSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, secondSiteMember.getUsername(), moderatedSite.getId())); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove a site memebership request of an inexistent user and response is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + public void userIsNotAbleToDeleteSiteMembershipRequestOfAnInexistentUser() throws JsonToModelConversionException, DataPreparationException, Exception + { + UserModel inexistentUser = new UserModel("inexistenUser", "password"); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(inexistentUser).deleteSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, inexistentUser.getUsername())); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove a site memebership request to an inexistent site and response is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + public void userIsNotAbleToDeleteSiteMembershipRequestToAnInexistentSite() throws JsonToModelConversionException, DataPreparationException, Exception + { + SiteModel inexistentSite = new SiteModel("inexistentSite"); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).deleteSiteMembershipRequest(inexistentSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, adminUserModel.getUsername(), inexistentSite.getId())); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove a site memebership request to an empty site id and response is 405") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + public void userIsNotAbleToDeleteSiteMembershipRequestWithEmptySiteId() throws JsonToModelConversionException, DataPreparationException, Exception + { + SiteModel inexistentSite = new SiteModel(""); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).deleteSiteMembershipRequest(inexistentSite); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.DELETE_EMPTY_ARGUMENT); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove a site memebership request of another regular user from moderated site and response is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + public void regularUserIsNotAbleToDeleteSiteMembershipRequestOfAnotherRegularUserToAModeratedSite() throws JsonToModelConversionException, DataPreparationException, Exception + { + siteMember.setUserRole(UserRole.SiteCollaborator); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSite).addPerson(siteMember); + restClient.authenticateUser(secondSiteMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + restClient.authenticateUser(siteMember).withCoreAPI().usingUser(secondSiteMember).deleteSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, secondSiteMember.getUsername(), moderatedSite.getId())); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove a site memebership request of admin to a moderated site and response is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + public void regularUserIsNotAbleToDeleteSiteMembershipRequestOfAdminToAModeratedSite() throws JsonToModelConversionException, DataPreparationException, Exception + { + UserModel collaboratorUser = dataUser.createRandomTestUser(); + collaboratorUser.setUserRole(UserRole.SiteCollaborator); + restClient.authenticateUser(siteMember).withCoreAPI().usingSite(secondModeratedSite).addPerson(collaboratorUser); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteMembershipRequest(secondModeratedSite); + restClient.authenticateUser(collaboratorUser).withCoreAPI().usingUser(adminUserModel).deleteSiteMembershipRequest(secondModeratedSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, adminUserModel.getUsername(), secondModeratedSite.getId())); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify manager is able to remove a site memebership request of admin to a moderated site and response is 204") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + public void managerUserIsAbleToDeleteSiteMembershipRequestOfAdminToAModeratedSite() throws JsonToModelConversionException, DataPreparationException, Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteMembershipRequest(secondModeratedSite); + restClient.authenticateUser(siteMember).withCoreAPI().usingUser(adminUserModel).deleteSiteMembershipRequest(secondModeratedSite); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify manager is not able to remove a site memebership request if it was already approved and response is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + public void managerUserIsNotAbleToDeleteASiteMembershipRequestIfItWasAlreadyApproved() throws JsonToModelConversionException, DataPreparationException, Exception + { + secondSiteMember.setUserRole(UserRole.SiteCollaborator); + restClient.authenticateUser(secondSiteMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(secondModeratedSite); + RestTaskModel taskModel = restClient.authenticateUser(secondSiteMember).withWorkflowAPI().getTasks().getTaskModelByDescription(secondModeratedSite); + workflow.approveSiteMembershipRequest(siteMember.getUsername(), siteMember.getPassword(), taskModel.getId(), true, "Approve"); + + restClient.authenticateUser(siteMember).withCoreAPI().usingUser(secondSiteMember).deleteSiteMembershipRequest(secondModeratedSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, secondSiteMember.getUsername(), secondModeratedSite.getId())); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify manager is not able to remove an inexitent site memebership request and response is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + public void managerUserIsNotAbleToDeleteAnInexistentSiteMembershipRequest() throws JsonToModelConversionException, DataPreparationException, Exception + { + restClient.authenticateUser(siteMember).withCoreAPI().usingUser(adminUserModel).deleteSiteMembershipRequest(secondModeratedSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, adminUserModel.getUsername(), secondModeratedSite.getId())); + } +} From d3bbc0f82d8f7d76a558e226e5449e9433eec90c Mon Sep 17 00:00:00 2001 From: mionescu Date: Fri, 9 Dec 2016 13:44:16 +0200 Subject: [PATCH 0725/1491] test: updated --- .../workflow/processes/AddProcessItemCoreTests.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemCoreTests.java index 413031203..7b25adcff 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemCoreTests.java @@ -124,9 +124,8 @@ public class AddProcessItemCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process item is falling in case of invalid body item is provided") public void failedAddingProcessItemIfInvalidItemBodyIsProvided() throws Exception { - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{\"id\":\"invalidId\"}", "processes/{processId}/items", processModel.getId()); - restClient.processModel(RestItemModel.class, request); + document.setNodeRef("invalidNodeRef"); + processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidId")); } @@ -135,9 +134,8 @@ public class AddProcessItemCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process item is falling in case of empty body item value is provided") public void failedAddingProcessItemIfEmptyItemBodyIsProvided() throws Exception { - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{\"id\":\"\"}", "processes/{processId}/items", processModel.getId()); - restClient.processModel(RestItemModel.class, request); + document.setNodeRef(""); + processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.REQUIRED_TO_ADD, "itemId")); } From 861ae4fd22650ca5dd134daccf908a0f05ac6172 Mon Sep 17 00:00:00 2001 From: cagache Date: Fri, 9 Dec 2016 13:55:48 +0200 Subject: [PATCH 0726/1491] moved network group --- .../AddProcessVariableCoreTests.java | 166 ++++++++++++++++++ 1 file changed, 166 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableCoreTests.java new file mode 100644 index 000000000..4e89726d0 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableCoreTests.java @@ -0,0 +1,166 @@ +package org.alfresco.rest.workflow.processes; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.dataprep.CMISUtil.Priority; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestProcessVariableModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class AddProcessVariableCoreTests extends RestTest +{ + private FileModel document; + private SiteModel siteModel; + private UserModel userWhoStartsProcess, assignee, adminUser, anotherUser, adminTenantUser, adminTenantUser2, tenantUserAssignee; + private RestProcessModel processModel; + private RestProcessVariableModel variableModel, processVariable; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + anotherUser = dataUser.createRandomTestUser(); + userWhoStartsProcess = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userWhoStartsProcess).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add process variable using by the user who started the process.") + public void addProcessVariableByUserThatStartedTheProcess() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); + + processVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + processVariable.assertThat().field("name").is(processVariable.getName()).and().field("type").is(processVariable.getType()).and().field("value") + .is(processVariable.getValue()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add process variable using by a random user.") + public void addProcessVariableByAnyUser() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(anotherUser).withWorkflowAPI().addProcess("activitiAdhoc", anotherUser, false, Priority.Normal); + + processVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + processVariable.assertThat().field("name").is(processVariable.getName()).and().field("type").is(processVariable.getType()).and().field("value") + .is(processVariable.getValue()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE, TestGroup.NETWORKS }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add process variable using by admin in other network.") + public void addProcessVariableByAdminInOtherNetwork() throws Exception + { + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser); + tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); + + adminTenantUser2 = UserModel.getAdminTenantUser(); + restClient.usingTenant().createTenant(adminTenantUser2); + + processModel = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee, false, Priority.Normal); + + restClient.authenticateUser(adminTenantUser2); + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process variable is falling in case invalid type is provided") + public void failedAddingProcessVariableIfInvalidTypeIsProvided() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:textarea"); + + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Unsupported type of variable: 'd:textarea'."); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + @Bug(id = "ACE-5674") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process variable is falling in case invalid type prefix is provided") + public void failedAddingProcessVariableIfInvalidTypePrefixIsProvided() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("ddt:text"); + + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Namespace prefix ddt is not mapped to a namespace URI"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process variable is falling in case invalid value is provided") + public void failedAddingProcessVariableIfInvalidValueIsProvided() throws Exception + { + RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:int"); + variableModel.setValue("invalidValue"); + + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("For input string: \"invalidValue\""); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process variable is falling in case missing required variable body (name) is provided") + public void failedAddingProcessVariableIfMissingRequiredVariableBodyIsProvided() throws Exception + { + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"value\": \"missingVariableName\",\"type\": \"d:text\"}", + "processes/{processId}/variables/{variableName}", processModel.getId(), variableModel.getName()); + restClient.processModel(RestProcessVariableModel.class, request); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Variable name is required."); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process variable is falling in case invalid variableBody (adding extra parameter in body) is provided") + public void failedAddingProcessVariableIfInvalidBodyIsProvided() throws Exception + { + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"scope\": \"local\",\"value\": \"testing\",\"type\": \"d:text\"}", + "processes/{processId}/variables/{variableName}", processModel.getId(), variableModel.getName()); + restClient.processModel(RestProcessVariableModel.class, request); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary("Could not read content from HTTP request body: Unrecognized field \"scope\""); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process variable is falling in case empty name is provided") + public void failedAddingProcessVariableIfEmptyNameIsProvided() throws Exception + { + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); + RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + variableModel.setName(""); + + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); + + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.PUT_EMPTY_ARGUMENT); + } + +} From 15ad461d5cee44e0c59bd64f18460117c11afcd1 Mon Sep 17 00:00:00 2001 From: Andrei Rusu Date: Fri, 9 Dec 2016 14:25:46 +0200 Subject: [PATCH 0727/1491] added changes to getTaskCoreTests according to comments --- .../org/alfresco/rest/workflow/tasks/GetTaskCoreTests.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCoreTests.java index ef814a29e..11912deb1 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCoreTests.java @@ -57,11 +57,10 @@ public class GetTaskCoreTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) public void emptyTaskId() throws Exception { - restClient.authenticateUser(userModel).withCoreAPI(); - RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "tasks/{taskId}?{parameters}", "", restClient.getParameters()); + restClient.authenticateUser(userModel).withWorkflowAPI(); + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "tasks/{taskId}", ""); restClient.processModels(RestTaskModelsCollection.class, request); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.UNABLE_TO_LOCATE, taskModel.getId())); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, From 8c288b5532c8b7c7ae2a0b0bbc96530deef83e8d Mon Sep 17 00:00:00 2001 From: Bogdan Bocancea Date: Fri, 9 Dec 2016 14:33:17 +0200 Subject: [PATCH 0728/1491] TAS-2084: add core tests for 'delete /tasks/{taskId}/items/{itemId}' request --- .../tasks/DeleteTaskVariableCoreTests.java | 7 +- .../tasks/DeleteTaskVariableSanityTests.java | 3 +- .../tasks/GetTaskFormModelCoreTests.java | 5 +- .../tasks/RemoveTaskItemCoreTests.java | 151 ++++++++++++++++++ .../tasks/RemoveTaskItemSanityTests.java | 11 +- .../tasks/UpdateTaskVariableCoreTests.java | 9 +- .../tasks/UpdateTaskVariableSanityTests.java | 6 +- 7 files changed, 183 insertions(+), 9 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/tasks/RemoveTaskItemCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/DeleteTaskVariableCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/DeleteTaskVariableCoreTests.java index 824f80379..c2d464709 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/DeleteTaskVariableCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/DeleteTaskVariableCoreTests.java @@ -18,7 +18,6 @@ import org.testng.annotations.Test; /** * @author bogdan.bocancea */ -@Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) public class DeleteTaskVariableCoreTests extends RestTest { private UserModel userModel; @@ -37,6 +36,7 @@ public class DeleteTaskVariableCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Delete task variable with any user") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) public void deleteTaskVarialbleByAnyUser() throws Exception { restClient.authenticateUser(userModel); @@ -51,6 +51,7 @@ public class DeleteTaskVariableCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Delete task variable with invalid type") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) public void deleteTaskVariableInvalidType() throws Exception { restClient.authenticateUser(userModel); @@ -65,6 +66,7 @@ public class DeleteTaskVariableCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Delete task variable with invalid name") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) public void deleteTaskVariableInvalidName() throws Exception { restClient.authenticateUser(userModel); @@ -75,6 +77,7 @@ public class DeleteTaskVariableCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Create, update, delete task variable with any user") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) public void createUpdateDeleteTaskVarialbleByAnyUser() throws Exception { restClient.authenticateUser(userModel); @@ -92,6 +95,7 @@ public class DeleteTaskVariableCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Delete task variable by non assigned user") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) public void deleteTaskVarialbleByNonAssignedUser() throws Exception { UserModel nonAssigned = dataUser.createRandomTestUser(); @@ -105,6 +109,7 @@ public class DeleteTaskVariableCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Delete task variable by inexistent user") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) public void deleteTaskVarialbleByInexistentUser() throws Exception { RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/DeleteTaskVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/DeleteTaskVariableSanityTests.java index 8ef87934f..ccd18b85f 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/DeleteTaskVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/DeleteTaskVariableSanityTests.java @@ -17,7 +17,6 @@ import org.testng.annotations.Test; /** * @author iulia.cojocea */ -@Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) public class DeleteTaskVariableSanityTests extends RestTest { private UserModel userModel, adminUser; @@ -39,6 +38,7 @@ public class DeleteTaskVariableSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Delete existing task variable") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) public void deleteTaskVariable() throws Exception { restClient.authenticateUser(adminUser); @@ -53,6 +53,7 @@ public class DeleteTaskVariableSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Try to delete existing task variable using invalid task id") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) public void tryToDeleteTaskVariableUsingInvalidTaskId() throws Exception { restClient.authenticateUser(adminUser); diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelCoreTests.java index 1e507afef..366a60ead 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelCoreTests.java @@ -20,7 +20,6 @@ import org.testng.annotations.Test; * @author bogdan.bocancea * */ -@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) public class GetTaskFormModelCoreTests extends RestTest { UserModel userModel; @@ -40,6 +39,7 @@ public class GetTaskFormModelCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify that non involved user in task cannot get form models with Rest API and response is FORBIDDEN (403)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) public void nonInvolvedUserCannotGetTaskFormModels() throws Exception { taskModel = dataWorkflow.usingUser(userModel) @@ -55,6 +55,7 @@ public class GetTaskFormModelCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify user involved in task cannot get task form models with invalid task id") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) public void getTaskFormModelsInvalidTaskId() throws Exception { taskModel = dataWorkflow.usingUser(userModel) @@ -70,6 +71,7 @@ public class GetTaskFormModelCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify user involved in task cannot get task form models with invalid task id") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) public void getTaskFormModelsEmptyTaskId() throws Exception { taskModel = dataWorkflow.usingUser(userModel) @@ -85,6 +87,7 @@ public class GetTaskFormModelCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify user involved in task can get completed task form models") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) public void getTaskFormModelsForCompletedTask() throws Exception { UserModel assignedUser = dataUser.createRandomTestUser(); diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/RemoveTaskItemCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/RemoveTaskItemCoreTests.java new file mode 100644 index 000000000..8544a4576 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/RemoveTaskItemCoreTests.java @@ -0,0 +1,151 @@ +package org.alfresco.rest.workflow.tasks; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestItemModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.GroupModel; +import org.alfresco.utility.model.ProcessModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TaskModel; +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 bogdan.bocancea + */ +public class RemoveTaskItemCoreTests extends RestTest +{ + private UserModel userWhoStartsTask, assigneeUser; + private SiteModel siteModel; + private FileModel fileModel, document2; + private TaskModel taskModel; + private RestItemModel taskItem; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + userWhoStartsTask = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); + fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + assigneeUser = dataUser.createRandomTestUser(); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Delete existing task item with empty task id") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + public void deleteTaskItemEmptyTaskId() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + restClient.authenticateUser(userWhoStartsTask); + document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); + taskModel.setId(""); + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Delete existing task item with empty item id") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + public void deleteTaskItemEmptyItemId() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + restClient.authenticateUser(userWhoStartsTask); + document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); + taskItem.setId(""); + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) + .assertLastError().containsSummary(RestErrorModel.DELETE_EMPTY_ARGUMENT); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Delete existing task item for completed task") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + public void deleteTaskItemForCompletedTask() throws Exception + { + TaskModel completedTask = dataWorkflow.usingUser(userWhoStartsTask) + .usingSite(siteModel) + .usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + restClient.authenticateUser(userWhoStartsTask); + document2 = dataContent.usingUser(userWhoStartsTask).usingSite(siteModel).createContent(DocumentType.XML); + taskItem = restClient.withWorkflowAPI().usingTask(completedTask).addTaskItem(document2); + dataWorkflow.usingUser(assigneeUser).taskDone(completedTask); + dataWorkflow.usingUser(userWhoStartsTask).taskDone(completedTask); + restClient.withWorkflowAPI().usingTask(completedTask).deleteTaskItem(taskItem); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, completedTask.getId())); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Delete existing task item with candidate user") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + public void deleteTaskItemWithCandidateUser() throws Exception + { + GroupModel group = dataGroup.createRandomGroup(); + dataGroup.addListOfUsersToGroup(group, assigneeUser); + TaskModel groupTask = dataWorkflow.usingUser(userWhoStartsTask) + .usingSite(siteModel) + .usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); + + restClient.authenticateUser(userWhoStartsTask); + document2 = dataContent.usingUser(userWhoStartsTask).usingSite(siteModel).createContent(DocumentType.XML); + taskItem = restClient.withWorkflowAPI().usingTask(groupTask).addTaskItem(document2); + restClient.authenticateUser(assigneeUser) + .withWorkflowAPI().usingTask(groupTask).deleteTaskItem(taskItem); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Delete existing task item with unauthorized user") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + public void deleteTaskItemWithUnauthorizedUser() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + UserModel unauthorizedUser = dataUser.createRandomTestUser(); + document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + taskItem = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); + restClient.authenticateUser(unauthorizedUser).withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Delete existing task item with inexistent user") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + public void deleteTaskItemWithInexistentUser() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + taskItem = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); + restClient.authenticateUser(UserModel.getRandomUserModel()).withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Delete existing task item for deleted task") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + public void deleteTaskItemFromDeletedProcess() throws Exception + { + ProcessModel deletedProcess = dataWorkflow.usingUser(userWhoStartsTask) + .usingSite(siteModel) + .usingResource(fileModel).createMoreReviewersWorkflowAndAssignTo(assigneeUser); + TaskModel task = restClient.authenticateUser(userWhoStartsTask) + .withWorkflowAPI().usingProcess(deletedProcess).getProcessTasks().getEntries().get(0).onModel(); + + document2 = dataContent.usingUser(userWhoStartsTask).usingSite(siteModel).createContent(DocumentType.XML); + taskItem = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingTask(task).addTaskItem(document2); + dataWorkflow.usingUser(userWhoStartsTask).deleteProcess(deletedProcess); + restClient.withWorkflowAPI().usingTask(task).deleteTaskItem(taskItem); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, task.getId())); + } +} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/RemoveTaskItemSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/RemoveTaskItemSanityTests.java index fd5c62223..b98c28042 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/RemoveTaskItemSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/RemoveTaskItemSanityTests.java @@ -2,6 +2,7 @@ package org.alfresco.rest.workflow.tasks; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestItemModel; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; @@ -17,7 +18,6 @@ import org.testng.annotations.Test; /** * @author iulia.cojocea */ -@Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) public class RemoveTaskItemSanityTests extends RestTest { private UserModel adminUser, userModel, userWhoStartsTask, assigneeUser; @@ -41,6 +41,7 @@ public class RemoveTaskItemSanityTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Delete existing task item") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) public void deleteTaskItem() throws Exception { restClient.authenticateUser(adminUser); @@ -56,6 +57,7 @@ public class RemoveTaskItemSanityTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Try to Delete existing task item using invalid taskId") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) public void deleteTaskItemUsingInvalidTaskId() throws Exception { restClient.authenticateUser(adminUser); @@ -64,11 +66,13 @@ public class RemoveTaskItemSanityTests extends RestTest taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); taskModel.setId("invalidTaskId"); restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidTaskId")); } @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Try to Delete existing task item using invalid itemId") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) public void deleteTaskItemUsingInvalidItemId() throws Exception { restClient.authenticateUser(adminUser); @@ -76,6 +80,7 @@ public class RemoveTaskItemSanityTests extends RestTest taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); taskItem.setId("incorrectItemId"); restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.PROCESS_ENTITY_NOT_FOUND, "incorrectItemId")); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskVariableCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskVariableCoreTests.java index d4dfcfeeb..97b1dcc70 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskVariableCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskVariableCoreTests.java @@ -18,7 +18,6 @@ import org.testng.annotations.Test; /** * @author bogdan.bocancea */ -@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) public class UpdateTaskVariableCoreTests extends RestTest { private UserModel userModel; @@ -41,6 +40,7 @@ public class UpdateTaskVariableCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Update task variable by user who started the process") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) public void updateTaskVariableByUserWhoStartedProcess() throws Exception { variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); @@ -58,6 +58,7 @@ public class UpdateTaskVariableCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Update task variable with symbols in name") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) public void updateTaskVariableWithSymbolsInName() throws Exception { String symbolName = "<>.,;-'+=%|[]#*&-+"; @@ -74,6 +75,7 @@ public class UpdateTaskVariableCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Update task variable with invalid task id") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) public void updateTaskVariableWithInvalidTaskId() throws Exception { TaskModel invalidTask = new TaskModel(userModel.getUsername()); @@ -87,6 +89,7 @@ public class UpdateTaskVariableCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Update task variable with invalid scope") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) public void updateTaskVariableWithInvalidScope() throws Exception { variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); @@ -102,6 +105,7 @@ public class UpdateTaskVariableCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Update task variable with invalid type") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) public void updateTaskVariableWithInvalidType() throws Exception { variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); @@ -117,6 +121,7 @@ public class UpdateTaskVariableCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Update task variable with symbols in value") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) public void updateTaskVariableWithSymbolsInValue() throws Exception { String symbolValue = "<>.,;-'+=%|[]#*&-+/\\#!@"; @@ -133,6 +138,7 @@ public class UpdateTaskVariableCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Update task variable by non assigned user") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) public void updateTaskVariableByNonAssignedUser() throws Exception { UserModel nonAssigned = dataUser.createRandomTestUser(); @@ -149,6 +155,7 @@ public class UpdateTaskVariableCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Update task variable by inexistent user") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) public void updateTaskVariableByInexistentser() throws Exception { variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskVariableSanityTests.java index 35d09eb6a..fd1419c4e 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskVariableSanityTests.java @@ -17,7 +17,6 @@ import org.testng.annotations.Test; /** * @author iulia.cojocea */ -@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) public class UpdateTaskVariableSanityTests extends RestTest { private UserModel userModel; @@ -45,6 +44,7 @@ public class UpdateTaskVariableSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Create non-existing task variable") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) public void createTaskVariable() throws Exception { restClient.authenticateUser(adminUser); @@ -60,6 +60,7 @@ public class UpdateTaskVariableSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Update existing task variable") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) public void updateExistingTaskVariable() throws Exception { restClient.authenticateUser(adminUser); @@ -78,9 +79,10 @@ public class UpdateTaskVariableSanityTests extends RestTest taskVariable.assertThat().field("value").is("updatedValue"); } - @Test(groups = {TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY, TestGroup.NETWORKS}) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Update existing task variable by admin in the same network") + public void updateTaskVariableByAdminInSameNetwork() throws Exception { restClient.authenticateUser(adminUser); From 003edc581116ccb6a5915b2da493516228721479 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Fri, 9 Dec 2016 15:08:19 +0200 Subject: [PATCH 0729/1491] test: add core tests for UpdateTask and rename UpdateTaskSanityTests and some updates --- .../tasks/UpdateTaskCoreTestsBulk2.java | 191 ++++++++++++++++++ ...yTests.java => UpdateTaskSanityTests.java} | 176 ++++++++-------- 2 files changed, 279 insertions(+), 88 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTestsBulk2.java rename e2e-test/java/org/alfresco/rest/workflow/tasks/{UploadTaskSanityTests.java => UpdateTaskSanityTests.java} (92%) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTestsBulk2.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTestsBulk2.java new file mode 100644 index 000000000..07a033297 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTestsBulk2.java @@ -0,0 +1,191 @@ +package org.alfresco.rest.workflow.tasks; + +import java.util.HashMap; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.JsonBodyGenerator; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestTaskModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TaskModel; +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; + +/** + * + * @author Cristina Axinte + * + */ +@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) +public class UpdateTaskCoreTestsBulk2 extends RestTest +{ + UserModel owner; + SiteModel siteModel; + UserModel candidateUser; + FileModel fileModel; + UserModel assigneeUser; + TaskModel taskModel; + RestTaskModel restTaskModel; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + owner = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(owner).createPublicRandomSite(); + fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + assigneeUser = dataUser.createRandomTestUser(); + taskModel = dataWorkflow.usingUser(owner).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task owner can update twice task with status resolve successfully (200)") + public void taskOwnerCanUpdateTaskWithResolveStateTwice() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("resolved"); + + restClient.authenticateUser(owner) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restClient.assertStatusCodeIs(HttpStatus.OK); + + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task asignee cannot update twice task with status resolve - Forbidden (403)") + public void taskAssigneeCanNotUpdateTaskWithResolveStateTwice() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("resolved"); + + restClient.authenticateUser(assigneeUser) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task cannot be update using a invalid json body property - Bad Request (400)") + public void taskCanNotBeUpdatedWithInvalidJsonBodyProperty() throws Exception + { + String invalidJsonProperty= "states"; + restClient.authenticateUser(assigneeUser) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel); + String postBody = JsonBodyGenerator.keyValueJson(invalidJsonProperty, "completed"); + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); + restClient.processModel(RestTaskModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.NO_CONTENT, "Unrecognized field \""+invalidJsonProperty+"\"")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task cannot be update using a invalid state - Bad Request (400)") + public void taskCanNotBeUpdatedWithInvalidState() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("continued"); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_VALUE, "task state", "continued")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task cannot be update using a invalid property - Bad Request (400)") + public void taskCanNotBeUpdatedWithInvalidSelectProperty() throws Exception + { + String invalidProperty= "states"; + restClient.authenticateUser(assigneeUser) + .withParams("select=" + invalidProperty).withWorkflowAPI().usingTask(taskModel); + String postBody = JsonBodyGenerator.keyValueJson("state", "completed"); + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); + restClient.processModel(RestTaskModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.PROPERTY_DOES_NOT_EXIST, invalidProperty)); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task can be update using multiple select values successfully (200)") + public void taskCanBeUpdatedWithMultipleSelectValues() throws Exception + { + restClient.authenticateUser(assigneeUser) + .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel);//.updateTask("completed"); + HashMap body = new HashMap(); + body.put("state", "resolved"); + body.put("assignee", "admin"); + String postBody = JsonBodyGenerator.keyValueJson(body); + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); + restTaskModel =restClient.processModel(RestTaskModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("resolved"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task assignee can complete task successfully (200)") + public void taskAssigneeCanCompleteTask() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("completed"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task owner can complete task successfully (200))") + public void taskOwnerCanCompleteTask() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("completed"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify any user cannot complete task - Forbidden (403))") + public void anyUserCannotCompleteTask() throws Exception + { + UserModel anyUser = dataUser.createRandomTestUser(); + + restTaskModel = restClient.authenticateUser(anyUser) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task owner cannot complete task with invalid name - (200))") + public void taskOwnerCannotCompleteTaskWithInvalidName() throws Exception + { + restClient.authenticateUser(assigneeUser) + .withParams("select=state,variables").withWorkflowAPI().usingTask(taskModel); + String postBody = "{\"state\" : \"completed\", \"variables\" : [{\"name\" : \"bpm_priorityx\",\"type\" : \"d_int\",\"value\" : 1,\"scope\" : \"global\"}]}"; + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); + restTaskModel =restClient.processModel(RestTaskModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.UNSUPPORTED_TYPE,"bpm_priorityx")); + } +// provide invalid type(0.5) +// provide invalid value(0.5) +// provide invalid scope(0.5) +// claim a task as asignee - 200(0.5) +// unclaim a task as current asignee - 200(0.5) +// delegate a task as asignee - 200(0.5) +// "delegate a task as owner - provide the same user as asignee"(0.5) +// provide invalid asignee value(0.5) +} diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UploadTaskSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskSanityTests.java similarity index 92% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/UploadTaskSanityTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskSanityTests.java index 58df7cb1c..4e0de875d 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/UploadTaskSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskSanityTests.java @@ -1,89 +1,89 @@ -package org.alfresco.rest.workflow.tasks; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestTaskModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.GroupModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TaskModel; -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; - -@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) -public class UploadTaskSanityTests extends RestTest -{ - UserModel userModel; - SiteModel siteModel; - UserModel candidateUser; - FileModel fileModel; - UserModel assigneeUser; - TaskModel taskModel; - RestTaskModel restTaskModel; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - assigneeUser = dataUser.createRandomTestUser(); - taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify admin user updates task with Rest API and response is successfull (200)") - public void adminUserUpdatesAnyTaskWithSuccess() throws Exception - { - UserModel adminUser = dataUser.getAdminUser(); - - restTaskModel = restClient.authenticateUser(adminUser).withWorkflowAPI().usingTask(taskModel).updateTask(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("message").is(taskModel.getMessage()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify assignee user updates its assigned task with Rest API and response is successfull (200)") - public void assigneeUserUpdatesItsTaskWithSuccess() throws Exception - { - restTaskModel = restClient.authenticateUser(assigneeUser).withWorkflowAPI().usingTask(taskModel).updateTask(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("message").is(taskModel.getMessage()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify user that started the task updates the started task with Rest API and response is successfull (200)") - public void starterUserUpdatesItsTaskWithSuccess() throws Exception - { - restTaskModel = restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).updateTask(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify any user with no relation to task is forbidden to update other task with Rest API (403)") - public void anyUserIsForbiddenToUpdateOtherTask() throws Exception - { - UserModel anyUser= dataUser.createRandomTestUser(); - - restTaskModel = restClient.authenticateUser(anyUser).withWorkflowAPI().usingTask(taskModel).updateTask(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify candidate user updates its specific task and no other user claimed the task with Rest API and response is successfull (200)") - public void candidateUserUpdatesItsTasks() throws Exception - { - UserModel userModel1 = dataUser.createRandomTestUser(); - UserModel userModel2 = dataUser.createRandomTestUser(); - GroupModel group = dataGroup.createRandomGroup(); - dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); - TaskModel taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); - - restTaskModel = restClient.authenticateUser(userModel1).withWorkflowAPI().usingTask(taskModel).updateTask(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("message").is(taskModel.getMessage()); - } +package org.alfresco.rest.workflow.tasks; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestTaskModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.GroupModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TaskModel; +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; + +@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) +public class UpdateTaskSanityTests extends RestTest +{ + UserModel userModel; + SiteModel siteModel; + UserModel candidateUser; + FileModel fileModel; + UserModel assigneeUser; + TaskModel taskModel; + RestTaskModel restTaskModel; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + assigneeUser = dataUser.createRandomTestUser(); + taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify admin user updates task with Rest API and response is successfull (200)") + public void adminUserUpdatesAnyTaskWithSuccess() throws Exception + { + UserModel adminUser = dataUser.getAdminUser(); + + restTaskModel = restClient.authenticateUser(adminUser).withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("message").is(taskModel.getMessage()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify assignee user updates its assigned task with Rest API and response is successfull (200)") + public void assigneeUserUpdatesItsTaskWithSuccess() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser).withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("message").is(taskModel.getMessage()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify user that started the task updates the started task with Rest API and response is successfull (200)") + public void starterUserUpdatesItsTaskWithSuccess() throws Exception + { + restTaskModel = restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify any user with no relation to task is forbidden to update other task with Rest API (403)") + public void anyUserIsForbiddenToUpdateOtherTask() throws Exception + { + UserModel anyUser= dataUser.createRandomTestUser(); + + restTaskModel = restClient.authenticateUser(anyUser).withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify candidate user updates its specific task and no other user claimed the task with Rest API and response is successfull (200)") + public void candidateUserUpdatesItsTasks() throws Exception + { + UserModel userModel1 = dataUser.createRandomTestUser(); + UserModel userModel2 = dataUser.createRandomTestUser(); + GroupModel group = dataGroup.createRandomGroup(); + dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); + TaskModel taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); + + restTaskModel = restClient.authenticateUser(userModel1).withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("message").is(taskModel.getMessage()); + } } \ No newline at end of file From f2e49385d14e87ab0c62c957f96d5936fd78ed54 Mon Sep 17 00:00:00 2001 From: Andrei Rusu Date: Fri, 9 Dec 2016 15:11:29 +0200 Subject: [PATCH 0730/1491] added changes to test emptyTaskId --- .../org/alfresco/rest/workflow/tasks/GetTaskCoreTests.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCoreTests.java index 11912deb1..ccbfeee1f 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCoreTests.java @@ -29,6 +29,7 @@ public class GetTaskCoreTests extends RestTest FileModel fileModel; TaskModel taskModel; RestTaskModel restTaskModel, tenantTask; + RestTaskModelsCollection taskModels; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception @@ -53,14 +54,15 @@ public class GetTaskCoreTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify if using empty taskId status code 404 is returned.") + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify if using empty taskId status code 200 is returned.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) public void emptyTaskId() throws Exception { restClient.authenticateUser(userModel).withWorkflowAPI(); RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "tasks/{taskId}", ""); - restClient.processModels(RestTaskModelsCollection.class, request); + taskModels = restClient.processModels(RestTaskModelsCollection.class, request); restClient.assertStatusCodeIs(HttpStatus.OK); + taskModels.assertThat().entriesListIsNotEmpty(); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, From f47841a5c4196a41477efb7aa45f4de8169f412c Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Fri, 9 Dec 2016 15:14:07 +0200 Subject: [PATCH 0731/1491] TAS-2066 - CORE-REST API: getProcessVariables (get /processes/{processId}/variables) --- .../GetProcessVariablesCoreTests.java | 114 ++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesCoreTests.java new file mode 100644 index 000000000..95b3f47a4 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesCoreTests.java @@ -0,0 +1,114 @@ +package org.alfresco.rest.workflow.processes; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestProcessVariableCollection; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.apache.commons.lang.RandomStringUtils; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class GetProcessVariablesCoreTests extends RestTest +{ + private FileModel document; + private SiteModel siteModel; + private UserModel userWhoStartsTask, assignee, admin; + private RestProcessModel processModel; + private RestProcessVariableCollection variables; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + admin = dataUser.getAdminUser(); + userWhoStartsTask = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin from the same network is able to retrieve network process variables") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE, TestGroup.NETWORKS }) + public void getProcessVariablesWithAdminFromSameNetwork() throws JsonToModelConversionException, Exception + { + UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); + restClient.authenticateUser(admin).usingTenant().createTenant(adminTenantUser1); + UserModel tenantUser1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenant1"); + + RestProcessModel networkProcess1 = restClient.authenticateUser(adminTenantUser1).withWorkflowAPI() + .addProcess("activitiReview", tenantUser1, false, CMISUtil.Priority.High); + processModel = restClient.authenticateUser(adminTenantUser1).withWorkflowAPI().usingProcess(networkProcess1).getProcess(); + + variables = restClient.authenticateUser(adminTenantUser1).withWorkflowAPI().usingProcess(processModel).getProcessVariables(); + restClient.assertStatusCodeIs(HttpStatus.OK); + variables.assertThat().entriesListIsNotEmpty(); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin from different network is not able to retrieve network process variables") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE, TestGroup.NETWORKS }) + public void getProcessVariablesWithAdminFromDifferentNetwork() throws JsonToModelConversionException, Exception + { + UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); + restClient.authenticateUser(admin).usingTenant().createTenant(adminTenantUser1); + UserModel tenantUser1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenant1"); + + RestProcessModel networkProcess1 = restClient.authenticateUser(adminTenantUser1).withWorkflowAPI() + .addProcess("activitiReview", tenantUser1, false, CMISUtil.Priority.High); + processModel = restClient.authenticateUser(adminTenantUser1).withWorkflowAPI().usingProcess(networkProcess1).getProcess(); + + variables = restClient.authenticateUser(admin).withWorkflowAPI().usingProcess(processModel).getProcessVariables(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Get process variables using invalid process ID") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + public void getProcessVariablesUsingInvalidProcessId() throws JsonToModelConversionException, Exception + { + processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + String id = RandomStringUtils.randomAlphanumeric(10); + processModel.setId(id); + variables = restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, id)); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Get process variables using empty process ID") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + public void getProcessVariablesUsingEmptyProcessId() throws JsonToModelConversionException, Exception + { + processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processModel.setId(" "); + variables = restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, " ")); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Delete process then get process variables, status OK should be returned") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + public void getProcessVariablesForADeletedProcess() throws JsonToModelConversionException, Exception + { + processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + restClient.authenticateUser(admin).withWorkflowAPI().usingProcess(processModel).deleteProcess(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.authenticateUser(admin).withWorkflowAPI().usingProcess(processModel).getProcess(); + + variables = restClient.authenticateUser(admin).withWorkflowAPI().usingProcess(processModel).getProcessVariables(); + restClient.assertStatusCodeIs(HttpStatus.OK); + variables.assertThat().entriesListIsNotEmpty(); + } + +} \ No newline at end of file From 30430e3f627856671c439db7fb30a6687d2a3ec1 Mon Sep 17 00:00:00 2001 From: mionescu Date: Fri, 9 Dec 2016 15:27:15 +0200 Subject: [PATCH 0732/1491] test: updated tests after review: AddProcessItemCoreTests.java, AddTaskItemCoreTests.java --- .../processes/AddProcessItemCoreTests.java | 15 ++++++----- .../workflow/tasks/AddTaskItemCoreTests.java | 26 +++++++++++-------- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemCoreTests.java index 7b25adcff..4f37440fc 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemCoreTests.java @@ -21,9 +21,9 @@ import org.testng.annotations.Test; public class AddProcessItemCoreTests extends RestTest { - private FileModel document; + private FileModel document, document2; private SiteModel siteModel; - private UserModel userWhoStartsProcess, assignee, adminUser, adminTenantUser, tenantUserAssignee, adminTenantUser2, tenantUser; + private UserModel userWhoStartsProcess, assignee, adminUser, anotherUser, adminTenantUser, tenantUserAssignee, adminTenantUser2, tenantUser; private RestProcessModel processModel; private RestItemModel processItem; @@ -56,13 +56,16 @@ public class AddProcessItemCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add process item by a random user.") public void addProcessItemByAnyUser() throws Exception { - processModel = restClient.authenticateUser(assignee).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); + anotherUser = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(anotherUser).createPublicRandomSite(); + processModel = restClient.authenticateUser(anotherUser).withWorkflowAPI().addProcess("activitiAdhoc", anotherUser, false, Priority.Normal); + document2 = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document2); restClient.assertStatusCodeIs(HttpStatus.CREATED); processItem.assertThat().field("createdAt").isNotEmpty().and().field("size").is("19").and().field("createdBy").is(adminUser.getUsername()).and() - .field("modifiedAt").isNotEmpty().and().field("name").is(document.getName()).and().field("modifiedBy").is(assignee.getUsername()).and() - .field("id").isNotEmpty().and().field("mimeType").is(document.getFileType().mimeType); + .field("modifiedAt").isNotEmpty().and().field("name").is(document2.getName()).and().field("modifiedBy").is(anotherUser.getUsername()).and() + .field("id").is(document2.getNodeRefWithoutVersion()).and().field("mimeType").is(document2.getFileType().mimeType); } diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemCoreTests.java index f67e7771c..517b41f60 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemCoreTests.java @@ -22,7 +22,7 @@ import org.testng.annotations.Test; public class AddTaskItemCoreTests extends RestTest { - private UserModel userModel, assigneeUser, adminUser; + private UserModel userModel, assigneeUser, adminUser, anotherUser; private SiteModel siteModel; private FileModel fileModel, document; private TaskModel taskModel; @@ -40,21 +40,25 @@ public class AddTaskItemCoreTests extends RestTest assigneeUser = dataUser.createRandomTestUser(); taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - taskId = taskModel.getId(); - restClient.authenticateUser(userModel); + taskId = taskModel.getId(); } @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Add task item using random user.") public void addTaskItemByRandomUser() throws JsonToModelConversionException, Exception { + anotherUser = dataUser.createRandomTestUser(); + restClient.authenticateUser(anotherUser); + + siteModel = dataSite.usingUser(anotherUser).createPublicRandomSite(); document = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - + taskModel = dataWorkflow.usingUser(anotherUser).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(anotherUser); + taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document); restClient.assertStatusCodeIs(HttpStatus.CREATED); taskItem.assertThat().field("createdAt").isNotEmpty().and().field("size").isNotEmpty().and().field("createdBy").is(adminUser.getUsername()).and() - .field("modifiedAt").isNotEmpty().and().field("name").is(document.getName()).and().field("modifiedBy").is(userModel.getUsername()).and() + .field("modifiedAt").isNotEmpty().and().field("name").is(document.getName()).and().field("modifiedBy").is(anotherUser.getUsername()).and() .field("id").is(document.getNodeRefWithoutVersion()).and().field("mimeType").is(document.getFileType().mimeType); } @@ -63,8 +67,8 @@ public class AddTaskItemCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task item, is falling in case invalid itemBody is provided") public void failedAddingTaskItemIfInvalidItemBodyIsProvided() throws Exception { - document.setNodeRef("invalidNodeRef"); - taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document); + fileModel.setNodeRef("invalidNodeRef"); + taskItem = restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).addTaskItem(fileModel); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidNodeRef")); } @@ -73,9 +77,9 @@ public class AddTaskItemCoreTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task item is falling in case empty item body is provided") public void failedAddingTaskItemIfEmptyItemBodyIsProvided() throws Exception - { - document.setNodeRef(""); - taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document); + { + fileModel.setNodeRef(""); + taskItem = restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).addTaskItem(fileModel); // TODO - expected error message to be added restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(""); @@ -86,7 +90,7 @@ public class AddTaskItemCoreTests extends RestTest public void failedAddingTaskItemIfInvalidTaskIdIsProvided() throws Exception { taskModel.setId("invalidTaskId"); - taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document); + taskItem = restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).addTaskItem(fileModel); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidTaskId")); } From 08aaf4ea35046700e9d63e3a7d220bf90d60f5cf Mon Sep 17 00:00:00 2001 From: mionescu Date: Fri, 9 Dec 2016 15:56:23 +0200 Subject: [PATCH 0733/1491] test: updates after review core: added new error message in rest/model/RestErrorModel.java --- .../processes/AddProcessItemCoreTests.java | 13 +++++-------- .../workflow/tasks/AddTaskItemCoreTests.java | 17 ++++------------- 2 files changed, 9 insertions(+), 21 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemCoreTests.java index 4f37440fc..1ca0e1709 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemCoreTests.java @@ -57,16 +57,13 @@ public class AddProcessItemCoreTests extends RestTest public void addProcessItemByAnyUser() throws Exception { anotherUser = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(anotherUser).createPublicRandomSite(); - processModel = restClient.authenticateUser(anotherUser).withWorkflowAPI().addProcess("activitiAdhoc", anotherUser, false, Priority.Normal); + document2 = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document2); - - restClient.assertStatusCodeIs(HttpStatus.CREATED); - processItem.assertThat().field("createdAt").isNotEmpty().and().field("size").is("19").and().field("createdBy").is(adminUser.getUsername()).and() - .field("modifiedAt").isNotEmpty().and().field("name").is(document2.getName()).and().field("modifiedBy").is(anotherUser.getUsername()).and() - .field("id").is(document2.getNodeRefWithoutVersion()).and().field("mimeType").is(document2.getFileType().mimeType); + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processItem = restClient.authenticateUser(anotherUser).withWorkflowAPI().usingProcess(processModel).addProcessItem(document2); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsSummary(String.format(RestErrorModel.ACCESS_INFORMATION_NOT_ALLOWED, processModel.getId())); } @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE, TestGroup.NETWORKS }) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemCoreTests.java index 517b41f60..d76138aab 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemCoreTests.java @@ -40,7 +40,7 @@ public class AddTaskItemCoreTests extends RestTest assigneeUser = dataUser.createRandomTestUser(); taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - taskId = taskModel.getId(); + taskId = taskModel.getId(); } @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) @@ -48,18 +48,9 @@ public class AddTaskItemCoreTests extends RestTest public void addTaskItemByRandomUser() throws JsonToModelConversionException, Exception { anotherUser = dataUser.createRandomTestUser(); - restClient.authenticateUser(anotherUser); - - siteModel = dataSite.usingUser(anotherUser).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - taskModel = dataWorkflow.usingUser(anotherUser).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(anotherUser); - - taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document); - restClient.assertStatusCodeIs(HttpStatus.CREATED); + taskItem = restClient.authenticateUser(anotherUser).withWorkflowAPI().usingTask(taskModel).addTaskItem(fileModel); - taskItem.assertThat().field("createdAt").isNotEmpty().and().field("size").isNotEmpty().and().field("createdBy").is(adminUser.getUsername()).and() - .field("modifiedAt").isNotEmpty().and().field("name").is(document.getName()).and().field("modifiedBy").is(anotherUser.getUsername()).and() - .field("id").is(document.getNodeRefWithoutVersion()).and().field("mimeType").is(document.getFileType().mimeType); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } @Bug(id = "ACE-5683") @@ -77,7 +68,7 @@ public class AddTaskItemCoreTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task item is falling in case empty item body is provided") public void failedAddingTaskItemIfEmptyItemBodyIsProvided() throws Exception - { + { fileModel.setNodeRef(""); taskItem = restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).addTaskItem(fileModel); From e865021920f89b90c288761dda7174fa305aea17 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Fri, 9 Dec 2016 16:13:35 +0200 Subject: [PATCH 0734/1491] Added 9 more core tests --- .../tasks/UpdateTaskCoreTestsBulk2.java | 189 ++++++++++++++++-- 1 file changed, 172 insertions(+), 17 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTestsBulk2.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTestsBulk2.java index 07a033297..98a22e34c 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTestsBulk2.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTestsBulk2.java @@ -13,11 +13,13 @@ import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TaskModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; /** @@ -25,7 +27,6 @@ import org.testng.annotations.Test; * @author Cristina Axinte * */ -@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) public class UpdateTaskCoreTestsBulk2 extends RestTest { UserModel owner; @@ -46,10 +47,17 @@ public class UpdateTaskCoreTestsBulk2 extends RestTest taskModel = dataWorkflow.usingUser(owner).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); } + @BeforeMethod(alwaysRun=true) + public void createTask() throws Exception + { + taskModel = dataWorkflow.usingUser(owner).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify task owner can update twice task with status resolve successfully (200)") public void taskOwnerCanUpdateTaskWithResolveStateTwice() throws Exception - { + { restTaskModel = restClient.authenticateUser(assigneeUser) .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -62,10 +70,11 @@ public class UpdateTaskCoreTestsBulk2 extends RestTest } + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify task asignee cannot update twice task with status resolve - Forbidden (403)") public void taskAssigneeCanNotUpdateTaskWithResolveStateTwice() throws Exception - { + { restTaskModel = restClient.authenticateUser(assigneeUser) .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -79,6 +88,7 @@ public class UpdateTaskCoreTestsBulk2 extends RestTest } + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify task cannot be update using a invalid json body property - Bad Request (400)") public void taskCanNotBeUpdatedWithInvalidJsonBodyProperty() throws Exception @@ -93,6 +103,7 @@ public class UpdateTaskCoreTestsBulk2 extends RestTest .assertLastError().containsSummary(String.format(RestErrorModel.NO_CONTENT, "Unrecognized field \""+invalidJsonProperty+"\"")); } + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify task cannot be update using a invalid state - Bad Request (400)") public void taskCanNotBeUpdatedWithInvalidState() throws Exception @@ -103,10 +114,11 @@ public class UpdateTaskCoreTestsBulk2 extends RestTest .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_VALUE, "task state", "continued")); } + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify task cannot be update using a invalid property - Bad Request (400)") public void taskCanNotBeUpdatedWithInvalidSelectProperty() throws Exception - { + { String invalidProperty= "states"; restClient.authenticateUser(assigneeUser) .withParams("select=" + invalidProperty).withWorkflowAPI().usingTask(taskModel); @@ -117,12 +129,13 @@ public class UpdateTaskCoreTestsBulk2 extends RestTest .assertLastError().containsSummary(String.format(RestErrorModel.PROPERTY_DOES_NOT_EXIST, invalidProperty)); } + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify task can be update using multiple select values successfully (200)") public void taskCanBeUpdatedWithMultipleSelectValues() throws Exception - { + { restClient.authenticateUser(assigneeUser) - .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel);//.updateTask("completed"); + .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel); HashMap body = new HashMap(); body.put("state", "resolved"); body.put("assignee", "admin"); @@ -134,10 +147,11 @@ public class UpdateTaskCoreTestsBulk2 extends RestTest .and().field("state").is("resolved"); } + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify task assignee can complete task successfully (200)") public void taskAssigneeCanCompleteTask() throws Exception - { + { restTaskModel = restClient.authenticateUser(assigneeUser) .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -145,6 +159,7 @@ public class UpdateTaskCoreTestsBulk2 extends RestTest .and().field("state").is("completed"); } + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify task owner can complete task successfully (200))") public void taskOwnerCanCompleteTask() throws Exception @@ -156,6 +171,7 @@ public class UpdateTaskCoreTestsBulk2 extends RestTest .and().field("state").is("completed"); } + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify any user cannot complete task - Forbidden (403))") public void anyUserCannotCompleteTask() throws Exception @@ -168,24 +184,163 @@ public class UpdateTaskCoreTestsBulk2 extends RestTest .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Bug(id = "TBD") @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify task owner cannot complete task with invalid name - (200))") public void taskOwnerCannotCompleteTaskWithInvalidName() throws Exception { - restClient.authenticateUser(assigneeUser) + restClient.authenticateUser(owner) .withParams("select=state,variables").withWorkflowAPI().usingTask(taskModel); - String postBody = "{\"state\" : \"completed\", \"variables\" : [{\"name\" : \"bpm_priorityx\",\"type\" : \"d_int\",\"value\" : 1,\"scope\" : \"global\"}]}"; + String postBody = "{\"state\" : \"completed\", \"variables\" : [{\"name\" : \"bpmx_priorityx\",\"type\" : \"d:int\",\"value\" : 1,\"scope\" : \"global\"}]}"; RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); restTaskModel =restClient.processModel(RestTaskModel.class, request); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) .assertLastError().containsSummary(String.format(RestErrorModel.UNSUPPORTED_TYPE,"bpm_priorityx")); } -// provide invalid type(0.5) -// provide invalid value(0.5) -// provide invalid scope(0.5) -// claim a task as asignee - 200(0.5) -// unclaim a task as current asignee - 200(0.5) -// delegate a task as asignee - 200(0.5) -// "delegate a task as owner - provide the same user as asignee"(0.5) -// provide invalid asignee value(0.5) + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Bug(id = "TBD") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task owner cannot complete task with invalid Type - Bad Request(400))") + public void taskOwnerCannotCompleteTaskWithInvalidType() throws Exception + { + restClient.authenticateUser(owner) + .withParams("select=state,variables").withWorkflowAPI().usingTask(taskModel); + String postBody = "{\"state\" : \"completed\", \"variables\" : [{\"name\" : \"bpm_priority\",\"type\" : \"d_int\",\"value\" : 1,\"scope\" : \"global\"}]}"; + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); + restTaskModel =restClient.processModel(RestTaskModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.UNSUPPORTED_TYPE,"d_int")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Bug(id = "TBD") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task owner cannot complete task with invalid value - Bad Request(400))") + public void taskOwnerCannotCompleteTaskWithInvalidValue() throws Exception + { + restClient.authenticateUser(owner) + .withParams("select=state,variables").withWorkflowAPI().usingTask(taskModel); + String postBody = "{\"state\" : \"completed\", \"variables\" : [{\"name\" : \"bpm_priority\",\"type\" : \"d:int\",\"value\" : \"text\",\"scope\" : \"global\"}]}"; + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); + restTaskModel =restClient.processModel(RestTaskModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.UNSUPPORTED_TYPE, "text")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task owner cannot complete task with invalid scope - Bad Request(400))") + public void taskOwnerCannotCompleteTaskWithInvalidScope() throws Exception + { + restClient.authenticateUser(owner) + .withParams("select=state,variables").withWorkflowAPI().usingTask(taskModel); + String postBody = "{\"state\" : \"completed\", \"variables\" : [{\"name\" : \"bpm_priority\",\"type\" : \"d:int\",\"value\" : 1,\"scope\" : \"globalscope\"}]}"; + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); + restTaskModel =restClient.processModel(RestTaskModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.ILLEGAL_SCOPE, "globalscope")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task assignee can claim task successfully (200)") + public void taskAssigneeCanClaimTask() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("claimed"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task assignee can unclaim task successfully (200)") + public void taskAssigneeCanUnclaimTask() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("unclaimed"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task assignee can delegate task successfully (200)") + public void taskAssigneeCanDelegateTask() throws Exception + { + UserModel delagateToUser = dataUser.createRandomTestUser(); + + restClient.authenticateUser(assigneeUser) + .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel); + HashMap body = new HashMap(); + body.put("state", "delegated"); + body.put("assignee", delagateToUser.getUsername()); + String postBody = JsonBodyGenerator.keyValueJson(body); + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); + restTaskModel =restClient.processModel(RestTaskModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("delegated") + .and().field("assignee").is(delagateToUser.getUsername()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task owner can delegate task to same assignee successfully (200)") + public void taskOwnerCanDelegateTaskToSameAssignee() throws Exception + { + restClient.authenticateUser(owner) + .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel); + HashMap body = new HashMap(); + body.put("state", "delegated"); + body.put("assignee", assigneeUser.getUsername()); + String postBody = JsonBodyGenerator.keyValueJson(body); + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); + restTaskModel =restClient.processModel(RestTaskModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("delegated") + .and().field("assignee").is(assigneeUser.getUsername()); + } + + + @Bug(id = "TBD") //as per api-explorer: should not have OK status + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task assignee cannot delegate task to task owner - (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + public void taskAssigneeCannotDelegateTaskToTaskOwner() throws Exception + { + restClient.authenticateUser(owner) + .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel); + HashMap body = new HashMap(); + body.put("state", "delegated"); + body.put("assignee", owner.getUsername()); + String postBody = JsonBodyGenerator.keyValueJson(body); + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); + restTaskModel =restClient.processModel(RestTaskModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Bug(id = "TBD") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task owner cannot delegate task to invalid assignee - (200)") + public void taskOwnerCannotDelegateTaskToInvalidAssignee() throws Exception + { + UserModel invalidAssignee = new UserModel("invalidAssignee", "password"); + + restClient.authenticateUser(owner) + .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel); + HashMap body = new HashMap(); + body.put("state", "delegated"); + body.put("assignee", invalidAssignee.getUsername()); + String postBody = JsonBodyGenerator.keyValueJson(body); + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); + restTaskModel =restClient.processModel(RestTaskModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + } } From 46b6abbe65652a1d59f9eee4968eaa2a198c7e17 Mon Sep 17 00:00:00 2001 From: cagache Date: Fri, 9 Dec 2016 16:15:47 +0200 Subject: [PATCH 0735/1491] added some tests from TAS-2087 --- .../tasks/UpdateTaskCoreTestsBulk3.java | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTestsBulk3.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTestsBulk3.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTestsBulk3.java new file mode 100644 index 000000000..629c18816 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTestsBulk3.java @@ -0,0 +1,73 @@ +package org.alfresco.rest.workflow.tasks; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestTaskModel; +import org.alfresco.utility.model.*; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Created by Claudia Agache on 12/9/2016. + */ +public class UpdateTaskCoreTestsBulk3 extends RestTest +{ + UserModel owner; + SiteModel siteModel; + UserModel candidateUser; + FileModel fileModel; + UserModel assigneeUser; + TaskModel taskModel; + RestTaskModel restTaskModel; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + owner = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(owner).createPublicRandomSite(); + fileModel = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + assigneeUser = dataUser.createRandomTestUser(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task assignee can update task with status resolve") + public void resolveTaskAsCurrentAssignee() throws Exception + { + taskModel = dataWorkflow.usingUser(owner).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + restTaskModel = restClient.authenticateUser(assigneeUser) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("resolved"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify update task using invalid taskId") + public void updateTaskUsingInvalidTaskId() throws Exception + { + taskModel = dataWorkflow.usingUser(owner).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + taskModel.setId("invalidId"); + + restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidId")); + } + +// @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) +// @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, +// description = "Verify update task using another priority") +// public void updateTaskUsingAnotherPriority() throws Exception +// { +// taskModel = dataWorkflow.usingUser(owner).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); +// +// restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).updateTask("2"); +// restClient.assertStatusCodeIs(HttpStatus.OK); +// restTaskModel.assertThat().field("priority").is(CMISUtil.Priority.Low); +// } +} From ba9eff655fb4aa54b4d6616311b798f1aca61e43 Mon Sep 17 00:00:00 2001 From: Andrei Rusu Date: Fri, 9 Dec 2016 16:25:02 +0200 Subject: [PATCH 0736/1491] added changes to getTasksCoreTests and GetTasksSanityTests --- .../workflow/tasks/GetTasksCoreTests.java | 52 +++++++++++++------ .../workflow/tasks/GetTasksSanityTests.java | 3 +- 2 files changed, 36 insertions(+), 19 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksCoreTests.java index 8f5bdc7ff..a02303618 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksCoreTests.java @@ -1,8 +1,14 @@ package org.alfresco.rest.workflow.tasks; +import java.util.ArrayList; +import java.util.List; + import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.CMISUtil.Priority; import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestSiteModel; +import org.alfresco.rest.model.RestTaskModel; import org.alfresco.rest.model.RestTaskModelsCollection; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; @@ -11,15 +17,18 @@ import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; +import org.testng.Assert; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import com.google.common.collect.Ordering; + public class GetTasksCoreTests extends RestTest { UserModel userModel, userNotInvolved, candidateUser, assigneeUser, adminUser; UserModel adminTenantUser, tenantUser, tenantUserAssignee; - SiteModel siteModel, tenantSiteModel; - FileModel fileModel, tenantFileModel; + SiteModel siteModel; + FileModel fileModel; RestTaskModelsCollection taskModels, tenantTask; @BeforeClass(alwaysRun = true) @@ -35,16 +44,6 @@ public class GetTasksCoreTests extends RestTest dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); } - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify the request is valid for auth user which is asignee.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void validRequestAuthUser() throws Exception - { - taskModels = restClient.authenticateUser(assigneeUser).withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - taskModels.assertThat().entriesListIsNotEmpty().and().entriesListCountIs(1).and().entriesListContains("assignee", assigneeUser.getUsername()); - } - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify the request in case of any user which is not involved.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) @@ -56,13 +55,31 @@ public class GetTasksCoreTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check that orderBy parameter is applied and use several filters.") + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check that orderBy parameter is applied.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) public void orderByParameterApplied() throws Exception { - taskModels = restClient.authenticateUser(dataUser.getAdminUser()).withParams("orderBy=processId").withWorkflowAPI().getTasks(); + taskModels = restClient.authenticateUser(dataUser.getAdminUser()).withParams("orderBy=id").withWorkflowAPI().getTasks(); restClient.assertStatusCodeIs(HttpStatus.OK); taskModels.assertThat().entriesListIsNotEmpty(); + List tasksList = taskModels.getEntries(); + List taskIds = new ArrayList(); + for(RestTaskModel task: tasksList) + { + taskIds.add(task.onModel().getId()); + } + boolean sorted = Ordering.natural().isOrdered(taskIds); + Assert.assertTrue(sorted, "Tasks list should be ordered ascendent after id"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check that orderBy parameter is applied and supports only one parameter.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + public void orderByParameterSupportsOnlyOneParameter() throws Exception + { + taskModels = restClient.authenticateUser(dataUser.getAdminUser()).withParams("orderBy=id,processDefinitionId").withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Only one order by parameter is supported"); + taskModels.assertThat().entriesListIsEmpty(); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, @@ -81,9 +98,8 @@ public class GetTasksCoreTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) public void invalidOrderByParameterApplied() throws Exception { - taskModels = restClient.authenticateUser(dataUser.getAdminUser()).withParams("orderBy=invalidParameter").withWorkflowAPI().getTasks(); + restClient.authenticateUser(dataUser.getAdminUser()).withParams("orderBy=invalidParameter").withWorkflowAPI().getTasks(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("invalidParameter is not supported"); - taskModels.assertThat().entriesListIsEmpty(); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, @@ -103,6 +119,8 @@ public class GetTasksCoreTests extends RestTest tenantTask = restClient.authenticateUser(tenantUserAssignee).withWorkflowAPI().getTasks(); restClient.assertStatusCodeIs(HttpStatus.OK); - tenantTask.assertThat().entriesListIsNotEmpty().and().entriesListCountIs(1).and().entriesListContains("assignee", tenantUserAssignee.getUsername()); + tenantTask.assertThat().entriesListIsNotEmpty().and().entriesListCountIs(1).and().entriesListContains("assignee", + String.format("userTenantAssignee@%s", tenantUserAssignee.getDomain().toLowerCase())); + } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksSanityTests.java index 11b115b78..6c77aece6 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksSanityTests.java @@ -53,9 +53,8 @@ public class GetTasksSanityTests extends RestTest { taskModels = restClient.authenticateUser(assigneeUser).withWorkflowAPI().getTasks(); restClient.assertStatusCodeIs(HttpStatus.OK); - taskModels.assertThat().entriesListIsNotEmpty(); + taskModels.assertThat().entriesListIsNotEmpty().and().entriesListCountIs(1).and().entriesListContains("assignee", assigneeUser.getUsername()); } - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify candidate user that claims the task gets its existing tasks with Rest API and response is successfull (200)") @Bug(id = "MNT-16967") From 233b173c3044bbb11fcd203fa21abe6e045bc95e Mon Sep 17 00:00:00 2001 From: cagache Date: Fri, 9 Dec 2016 16:42:56 +0200 Subject: [PATCH 0737/1491] test: implemented TODO approve request --- .../rest/people/GetSiteMembershipRequestsCoreTests.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsCoreTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsCoreTests.java index 1ae77d1a1..cc02ca901 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsCoreTests.java @@ -2,6 +2,7 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestSiteMembershipRequestModelsCollection; +import org.alfresco.rest.model.RestTaskModel; import org.alfresco.utility.model.ErrorModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; @@ -122,11 +123,8 @@ public class GetSiteMembershipRequestsCoreTests extends RestTest restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest(moderatedSite); restClient.assertStatusCodeIs(HttpStatus.CREATED); - //TODO approve request - /* newMember.setUserRole(UserRole.SiteConsumer); - restClient.authenticateUser(siteManager).withCoreAPI().usingSite(siteModel).addPerson(newMember).assertThat().field("id").is(newMember.getUsername()) - .and().field("role").is(newMember.getUserRole()); - restClient.assertStatusCodeIs(HttpStatus.CREATED);*/ + RestTaskModel taskModel = restClient.authenticateUser(newMember).withWorkflowAPI().getTasks().getTaskModelByDescription(moderatedSite); + workflow.approveSiteMembershipRequest(siteManager.getUsername(), siteManager.getPassword(), taskModel.getId(), true, "Approve"); returnedCollection = restClient.authenticateUser(newMember).withCoreAPI().usingMe().getSiteMembershipRequests(); restClient.assertStatusCodeIs(HttpStatus.OK); From ba50e065d17b3f4554d79a4a44a0e74104374485 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alecsandru=20Prun=C4=83?= Date: Fri, 9 Dec 2016 16:47:14 +0200 Subject: [PATCH 0738/1491] test: Added GetProcessTasksCoreTests --- .../processes/GetProcessTasksCoreTests.java | 140 ++++++++++++++++++ 1 file changed, 140 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksCoreTests.java new file mode 100644 index 000000000..ad8b6419d --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksCoreTests.java @@ -0,0 +1,140 @@ +package org.alfresco.rest.workflow.processes; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestTaskModel; +import org.alfresco.utility.model.*; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class GetProcessTasksCoreTests extends RestTest +{ + private FileModel document, document1, document2, document3; + private SiteModel siteModel; + private UserModel adminUser, userModel, userModel1, userModel2, assignee; + private ProcessModel process; + private GroupModel group; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userModel = dataUser.createRandomTestUser(); + userModel1 = dataUser.createRandomTestUser(); + userModel2 = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + document1 = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + document2 = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + process = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(document) + .createSingleReviewerTaskAndAssignTo(assignee); + group = dataGroup.createRandomGroup(); + dataGroup.addListOfUsersToGroup(group, userModel1); + } + + @Bug(id = "TBD") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "getProcessTaks with user that is candidate with REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + public void getProcessTasksWithUserThatIsCandidate() throws Exception + { + ProcessModel processModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(document1) + .createGroupReviewTaskAndAssignTo(group); + + restClient.authenticateUser(assignee).withWorkflowAPI() + .usingProcess(processModel).getProcessTasks().assertThat().entriesListIsNotEmpty() + .and().entriesListContains("assignee", assignee.getUsername()); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Bug(id = "TBD") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify getProcessTasks using admin from same network with REST API and status code is FORBIDDEN (403)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE, TestGroup.NETWORKS }) + public void getProcessTasksWithAdminFromSameNetwork() throws Exception + { + UserModel adminTenant, tenantAssignee; + adminTenant = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenant); + SiteModel siteModel = dataSite.usingUser(adminTenant).createPublicRandomSite(); + tenantAssignee = dataUser.usingUser(adminTenant).createUserWithTenant("uTenant"); + document3 = dataContent.usingUser(adminTenant).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + + ProcessModel processModel = dataWorkflow.usingUser(adminTenant).usingSite(siteModel).usingResource(document3) + .createSingleReviewerTaskAndAssignTo(tenantAssignee); + + restClient.withWorkflowAPI() + .usingProcess(processModel).getProcessTasks().assertThat().entriesListIsNotEmpty(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Bug(id = "TBD") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify getProcessTasks using admin from different network with REST API and status code is FORBIDDEN (403)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE, TestGroup.NETWORKS }) + public void getProcessTasksWithAdminFromDifferentNetwork() throws Exception + { + UserModel adminTenant, secondAdminTenant, tenantAssignee; + adminTenant = UserModel.getAdminTenantUser(); + secondAdminTenant = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenant); + + SiteModel siteModel = dataSite.usingUser(adminTenant).createPublicRandomSite(); + document3 = dataContent.usingUser(adminTenant).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + tenantAssignee = dataUser.usingUser(adminTenant).createUserWithTenant("uTenant"); + ProcessModel processModel = dataWorkflow.usingUser(adminTenant).usingSite(siteModel).usingResource(document3) + .createSingleReviewerTaskAndAssignTo(tenantAssignee); + + restClient.authenticateUser(adminUser).usingTenant().createTenant(secondAdminTenant); + restClient.authenticateUser(secondAdminTenant).withWorkflowAPI() + .usingProcess(processModel).getProcessTasks().assertThat().entriesListIsEmpty(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "getProcessTasks for invalid processId with REST API and status code is NOT_FOUND (404)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + public void getProcessTasksUsingInvalidProcessId() throws Exception + { + ProcessModel processModel = process; + processModel.setId("invalidProcessId"); + restClient.authenticateUser(userModel).withWorkflowAPI() + .usingProcess(processModel).getProcessTasks().assertThat().entriesListIsEmpty(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "getProcessTasks for empty processId with REST API and status code is NOT_FOUND (404)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + public void getProcessTasksUsingEmptyProcessId() throws Exception + { + ProcessModel processModel = process; + processModel.setId(""); + restClient.authenticateUser(userModel).withWorkflowAPI() + .usingProcess(processModel).getProcessTasks().assertThat().entriesListIsEmpty(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "User completes task then getProcessTasks with REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + public void completeTaskThenGetProcessTasks() throws Exception + { + ProcessModel processModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(document2) + .createMoreReviewersWorkflowAndAssignTo(userModel2); + RestTaskModel restTaskModel = restClient.authenticateUser(userModel2).withWorkflowAPI() + .usingProcess(processModel).getProcessTasks().assertThat().entriesListIsNotEmpty().getOneRandomEntry().onModel(); + restClient.withWorkflowAPI().usingTask(restTaskModel).updateTask(); + restClient.withWorkflowAPI().getTasks().assertThat().entriesListIsNotEmpty(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } +} From b60cf0e1dc4b85044e209a00334dbc05fb7ce008 Mon Sep 17 00:00:00 2001 From: cagache Date: Fri, 9 Dec 2016 16:47:25 +0200 Subject: [PATCH 0739/1491] added @Autowired WorkflowService workflow; --- e2e-test/java/org/alfresco/rest/RestTest.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/RestTest.java b/e2e-test/java/org/alfresco/rest/RestTest.java index a7540549d..09ecbe5e0 100644 --- a/e2e-test/java/org/alfresco/rest/RestTest.java +++ b/e2e-test/java/org/alfresco/rest/RestTest.java @@ -2,6 +2,7 @@ package org.alfresco.rest; import java.lang.reflect.Method; +import org.alfresco.dataprep.WorkflowService; import org.alfresco.rest.core.RestProperties; import org.alfresco.rest.core.RestWrapper; import org.alfresco.utility.LogFactory; @@ -53,6 +54,8 @@ public abstract class RestTest extends AbstractTestNGSpringContextTests @Autowired protected DataDiscussion dataDiscussion; + @Autowired + protected WorkflowService workflow; @BeforeClass(alwaysRun = true) public void checkServerHealth() throws Exception From 422c291ac250e0836a0a76a7819ea08c913ac277 Mon Sep 17 00:00:00 2001 From: cagache Date: Fri, 9 Dec 2016 16:48:10 +0200 Subject: [PATCH 0740/1491] fix error --- .../rest/people/GetSiteMembershipRequestsCoreTests.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsCoreTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsCoreTests.java index cc02ca901..60db43cdd 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsCoreTests.java @@ -1,9 +1,9 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestSiteMembershipRequestModelsCollection; import org.alfresco.rest.model.RestTaskModel; -import org.alfresco.utility.model.ErrorModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; @@ -66,7 +66,7 @@ public class GetSiteMembershipRequestsCoreTests extends RestTest nonexistentUser.setUsername("nonexistent"); restClient.authenticateUser(adminUser).withCoreAPI().usingUser(nonexistentUser).getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, "nonexistent")); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "nonexistent")); } @TestRail(section = { TestGroup.REST_API, From 4210cd4636f5869794ef0c516bd98c01d1bbc58d Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Fri, 9 Dec 2016 16:49:07 +0200 Subject: [PATCH 0741/1491] test: added 4 new core tests in Bulk3 --- .../tasks/UpdateTaskCoreTestsBulk3.java | 79 ++++++++++++++++--- 1 file changed, 67 insertions(+), 12 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTestsBulk3.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTestsBulk3.java index 629c18816..217acf38c 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTestsBulk3.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTestsBulk3.java @@ -2,11 +2,17 @@ package org.alfresco.rest.workflow.tasks; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestTaskModel; -import org.alfresco.utility.model.*; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TaskModel; +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; @@ -58,16 +64,65 @@ public class UpdateTaskCoreTestsBulk3 extends RestTest restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidId")); } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify update task using another name") + public void updateTaskUsingAnotherName() throws Exception + { + taskModel = dataWorkflow.usingUser(owner).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); -// @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) -// @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, -// description = "Verify update task using another priority") -// public void updateTaskUsingAnotherPriority() throws Exception -// { -// taskModel = dataWorkflow.usingUser(owner).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); -// -// restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).updateTask("2"); -// restClient.assertStatusCodeIs(HttpStatus.OK); -// restTaskModel.assertThat().field("priority").is(CMISUtil.Priority.Low); -// } + restClient.authenticateUser(owner).withParams("select=name").withWorkflowAPI().usingTask(taskModel); + String postBody = "{\"name\":\"newNameTask\"}"; + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); + restTaskModel = restClient.processModel(RestTaskModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("name").is("newNameTask"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify update task using another description") + public void updateTaskUsingAnotherDescription() throws Exception + { + taskModel = dataWorkflow.usingUser(owner).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + + restClient.authenticateUser(owner).withParams("select=description").withWorkflowAPI().usingTask(taskModel); + String postBody = "{\"description\":\"newDescription\"}"; + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); + restTaskModel = restClient.processModel(RestTaskModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("description").is("newDescription"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify update task using another priority") + public void updateTaskUsingAnotherPriority() throws Exception + { + taskModel = dataWorkflow.usingUser(owner).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + + restClient.authenticateUser(owner).withParams("select=priority").withWorkflowAPI().usingTask(taskModel); + String postBody = "{\"priority\":3}"; + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); + restTaskModel = restClient.processModel(RestTaskModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("priorityTask").is(CMISUtil.Priority.Low.getLevel()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify update task using another priority") + public void updateTaskUsingAnotherOwner() throws Exception + { + taskModel = dataWorkflow.usingUser(owner).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + UserModel newOwner = dataUser.createRandomTestUser(); + + restClient.authenticateUser(owner).withParams("select=owner").withWorkflowAPI().usingTask(taskModel); + String postBody = "{\"owner\":\""+newOwner.getUsername()+"\"}"; + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); + restTaskModel = restClient.processModel(RestTaskModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("owner").is(newOwner.getUsername()); + } } From 44729b363769f39aa484eeb9ac5396f784e46828 Mon Sep 17 00:00:00 2001 From: cagache Date: Fri, 9 Dec 2016 17:06:41 +0200 Subject: [PATCH 0742/1491] fix failing scenarios --- .../people/GetSiteMembershipRequestsCoreTests.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsCoreTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsCoreTests.java index 60db43cdd..b4710d63d 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsCoreTests.java @@ -22,7 +22,7 @@ import org.testng.annotations.Test; public class GetSiteMembershipRequestsCoreTests extends RestTest { - UserModel newMember, adminUser; + UserModel newMember, newMember1, meUser, adminUser; SiteModel moderatedSite, publicSite; RestSiteMembershipRequestModelsCollection returnedCollection; @@ -74,7 +74,9 @@ public class GetSiteMembershipRequestsCoreTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) public void replacePersonIdWithMeRequest() throws Exception { - returnedCollection = restClient.authenticateUser(newMember).withCoreAPI().usingMe().getSiteMembershipRequests(); + meUser = dataUser.createRandomTestUser(); + restClient.authenticateUser(meUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + returnedCollection = restClient.authenticateUser(meUser).withCoreAPI().usingMe().getSiteMembershipRequests(); restClient.assertStatusCodeIs(HttpStatus.OK); returnedCollection.assertThat().entriesListContains("id", moderatedSite.getId()); } @@ -108,7 +110,9 @@ public class GetSiteMembershipRequestsCoreTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) public void getRequestsToModeratedSite() throws Exception { - returnedCollection = restClient.authenticateUser(newMember).withCoreAPI().usingUser(newMember).getSiteMembershipRequests(); + newMember1 = dataUser.createRandomTestUser(); + restClient.authenticateUser(newMember1).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + returnedCollection = restClient.authenticateUser(newMember1).withCoreAPI().usingUser(newMember1).getSiteMembershipRequests(); restClient.assertStatusCodeIs(HttpStatus.OK); returnedCollection.assertThat().entriesListContains("id", moderatedSite.getId()); } From 948ceb6c40081c1a7a8b23aa7cbf8d488a0d71d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alecsandru=20Prun=C4=83?= Date: Fri, 9 Dec 2016 17:13:15 +0200 Subject: [PATCH 0743/1491] test: updated completeTaskThenGetProcessTasks --- .../rest/workflow/processes/GetProcessTasksCoreTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksCoreTests.java index ad8b6419d..e59f344ee 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksCoreTests.java @@ -133,7 +133,7 @@ public class GetProcessTasksCoreTests extends RestTest .createMoreReviewersWorkflowAndAssignTo(userModel2); RestTaskModel restTaskModel = restClient.authenticateUser(userModel2).withWorkflowAPI() .usingProcess(processModel).getProcessTasks().assertThat().entriesListIsNotEmpty().getOneRandomEntry().onModel(); - restClient.withWorkflowAPI().usingTask(restTaskModel).updateTask(); + restClient.withWorkflowAPI().usingTask(restTaskModel).updateTask("completed"); restClient.withWorkflowAPI().getTasks().assertThat().entriesListIsNotEmpty(); restClient.assertStatusCodeIs(HttpStatus.OK); } From 5cf1d13f9547948f0245c470629b9eb2e8cbd582 Mon Sep 17 00:00:00 2001 From: cagache Date: Fri, 9 Dec 2016 17:52:53 +0200 Subject: [PATCH 0744/1491] fix GetTaskSanityTests (changed 'message' with new field 'description') --- .../rest/workflow/tasks/GetTaskSanityTests.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskSanityTests.java index 5b968ecc6..0413c6617 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskSanityTests.java @@ -46,7 +46,7 @@ public class GetTaskSanityTests extends RestTest restTaskModel = restClient.authenticateUser(adminUser).withWorkflowAPI().usingTask(taskModel).getTask(); restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("message").is(taskModel.getMessage()); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("description").is(taskModel.getMessage()); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, @@ -55,7 +55,7 @@ public class GetTaskSanityTests extends RestTest { restTaskModel = restClient.authenticateUser(assigneeUser).withWorkflowAPI().usingTask(taskModel).getTask(); restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("message").is(taskModel.getMessage()).and().field("assignee") + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("description").is(taskModel.getMessage()).and().field("assignee") .is(assigneeUser.getUsername()); } @@ -66,7 +66,7 @@ public class GetTaskSanityTests extends RestTest { restTaskModel = restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).getTask(); restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("message").is(taskModel.getMessage()); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("description").is(taskModel.getMessage()); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, @@ -91,7 +91,7 @@ public class GetTaskSanityTests extends RestTest restTaskModel = restClient.authenticateUser(userModel1).withWorkflowAPI().usingTask(taskModel).getTask(); restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("message").is(taskModel.getMessage()); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("description").is(taskModel.getMessage()); } @@ -109,6 +109,6 @@ public class GetTaskSanityTests extends RestTest restTaskModel = restClient.authenticateUser(userModel2).withWorkflowAPI().usingTask(taskModel).getTask(); restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("message").is(taskModel.getMessage()); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("description").is(taskModel.getMessage()); } } \ No newline at end of file From f8f306202f802d6fe452f2f340194b9526fc742a Mon Sep 17 00:00:00 2001 From: cagache Date: Fri, 9 Dec 2016 17:56:01 +0200 Subject: [PATCH 0745/1491] fix UpdateTaskSanityTests (changed 'message' with new field 'description') --- .../alfresco/rest/workflow/tasks/UpdateTaskSanityTests.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskSanityTests.java index 4e0de875d..68ee25b07 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskSanityTests.java @@ -44,7 +44,7 @@ public class UpdateTaskSanityTests extends RestTest restTaskModel = restClient.authenticateUser(adminUser).withWorkflowAPI().usingTask(taskModel).updateTask("completed"); restClient.assertStatusCodeIs(HttpStatus.OK); restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("message").is(taskModel.getMessage()); + .and().field("description").is(taskModel.getMessage()); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify assignee user updates its assigned task with Rest API and response is successfull (200)") @@ -53,7 +53,7 @@ public class UpdateTaskSanityTests extends RestTest restTaskModel = restClient.authenticateUser(assigneeUser).withWorkflowAPI().usingTask(taskModel).updateTask("completed"); restClient.assertStatusCodeIs(HttpStatus.OK); restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("message").is(taskModel.getMessage()); + .and().field("description").is(taskModel.getMessage()); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify user that started the task updates the started task with Rest API and response is successfull (200)") @@ -84,6 +84,6 @@ public class UpdateTaskSanityTests extends RestTest restTaskModel = restClient.authenticateUser(userModel1).withWorkflowAPI().usingTask(taskModel).updateTask("completed"); restClient.assertStatusCodeIs(HttpStatus.OK); restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("message").is(taskModel.getMessage()); + .and().field("description").is(taskModel.getMessage()); } } \ No newline at end of file From 7054b76729bdc2e7e362512e5a4073967cfb8630 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Fri, 9 Dec 2016 19:33:38 +0200 Subject: [PATCH 0746/1491] Added UpdateTaskCoreTests --- .../processes/GetProcessTasksCoreTests.java | 5 +- .../workflow/tasks/UpdateTaskCoreTests.java | 203 ++++++++++++++++++ 2 files changed, 206 insertions(+), 2 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksCoreTests.java index e59f344ee..4b5e207f8 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksCoreTests.java @@ -133,8 +133,9 @@ public class GetProcessTasksCoreTests extends RestTest .createMoreReviewersWorkflowAndAssignTo(userModel2); RestTaskModel restTaskModel = restClient.authenticateUser(userModel2).withWorkflowAPI() .usingProcess(processModel).getProcessTasks().assertThat().entriesListIsNotEmpty().getOneRandomEntry().onModel(); - restClient.withWorkflowAPI().usingTask(restTaskModel).updateTask("completed"); - restClient.withWorkflowAPI().getTasks().assertThat().entriesListIsNotEmpty(); + restTaskModel = restClient.withParams("select=state").withWorkflowAPI().usingTask(restTaskModel).updateTask("completed"); + restClient.withWorkflowAPI().getTasks().assertThat().entriesListIsEmpty(); restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(restTaskModel.getId()).and().field("state").is("completed"); } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTests.java new file mode 100644 index 000000000..bebb9ac36 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTests.java @@ -0,0 +1,203 @@ +package org.alfresco.rest.workflow.tasks; + +import java.util.HashMap; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.JsonBodyGenerator; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestTaskModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TaskModel; +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.BeforeMethod; +import org.testng.annotations.Test; + +public class UpdateTaskCoreTests extends RestTest +{ + UserModel userModel; + SiteModel siteModel; + SiteModel tenantSiteModel; + UserModel candidateUser; + FileModel fileModel; + UserModel assigneeUser; + TaskModel taskModel; + TaskModel tenantTask; + RestTaskModel restTaskModel; + UserModel adminUser; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); + fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + + assigneeUser = dataUser.createRandomTestUser(); + } + + @BeforeMethod(alwaysRun = true) + public void createTask() throws Exception + { + taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can not update task from completed to claimed and response is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + public void taskOwnerCanNotUpdateTaskFromCompletedToClaimed() throws Exception + { + restTaskModel = restClient.authenticateUser(userModel).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("completed"); + restTaskModel = restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() + .containsSummary(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can not update task from completed to unclaimed and response is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + public void taskOwnerCanNotUpdateTaskFromCompletedToUnclaimed() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("completed"); + restTaskModel = restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() + .containsSummary(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can not update task from completed to completed and response is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + public void taskOwnerCanNotUpdateTaskWithCompleteStateTwice() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("completed"); + restClient.authenticateUser(userModel).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() + .containsSummary(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can update task from claimed to completed and response is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + public void taskOwnerCanUpdateTaskFromClaimedToCompleted() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("claimed"); + restTaskModel = restClient.authenticateUser(userModel).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("completed"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify user can update task from claimed to claimed and response is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + public void userCanUpdateTaskWithClaimedStateTwice() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("claimed"); + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("claimed"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can update task from unclaimed to completed and response is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + public void taskOwnerCanUpdateTaskFromUnclaimedToCompleted() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); + restTaskModel = restClient.authenticateUser(userModel).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("completed"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can not update task from unclaimed to unclaimed and response is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + public void taskOwnerCanNotUpdateTaskWithUnclaimedStateTwice() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); + restTaskModel = restClient.authenticateUser(userModel).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can not update task from delegated to completed and response is 500") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + public void taskOwnerCanNotUpdateTaskFromDelegatedToCompleted() throws Exception + { + restClient.authenticateUser(userModel).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel); + HashMap body = new HashMap(); + body.put("state", "delegated"); + body.put("assignee", assigneeUser.getUsername()); + String postBody = JsonBodyGenerator.keyValueJson(body); + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), + restClient.getParameters()); + restTaskModel = restClient.processModel(RestTaskModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated").and().field("assignee") + .is(assigneeUser.getUsername()); + + restTaskModel = restClient.authenticateUser(userModel).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.INTERNAL_SERVER_ERROR).assertLastError().containsSummary(RestErrorModel.DELEGATED_TASK_CAN_NOT_BE_COMPLETED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can not update task from delegated to delegated and response is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + public void taskOwnerCanNotUpdateTaskWithDelegatedStateTwice() throws Exception + { + restClient.authenticateUser(userModel).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel); + HashMap body = new HashMap(); + body.put("state", "delegated"); + body.put("assignee", assigneeUser.getUsername()); + String postBody = JsonBodyGenerator.keyValueJson(body); + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), + restClient.getParameters()); + restTaskModel = restClient.processModel(RestTaskModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated").and().field("assignee") + .is(assigneeUser.getUsername()); + + request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); + restTaskModel = restClient.processModel(RestTaskModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated").and().field("assignee") + .is(assigneeUser.getUsername()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can update task from resolved to completed and response is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + public void taskOwnerCanUpdateTaskFromResolvedToCompleted() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("resolved"); + + restTaskModel = restClient.authenticateUser(userModel).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("completed"); + } +} From 1098c57bb0d55e060d727ef4a0292d7af2138d2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alecsandru=20Prun=C4=83?= Date: Fri, 9 Dec 2016 19:40:59 +0200 Subject: [PATCH 0747/1491] test: Updated completeTaskThenGetProcessTasks test --- .../rest/workflow/processes/GetProcessTasksCoreTests.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksCoreTests.java index e59f344ee..2528a0e88 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksCoreTests.java @@ -133,8 +133,9 @@ public class GetProcessTasksCoreTests extends RestTest .createMoreReviewersWorkflowAndAssignTo(userModel2); RestTaskModel restTaskModel = restClient.authenticateUser(userModel2).withWorkflowAPI() .usingProcess(processModel).getProcessTasks().assertThat().entriesListIsNotEmpty().getOneRandomEntry().onModel(); - restClient.withWorkflowAPI().usingTask(restTaskModel).updateTask("completed"); - restClient.withWorkflowAPI().getTasks().assertThat().entriesListIsNotEmpty(); + restTaskModel = restClient.withParams("select=state").withWorkflowAPI().usingTask(restTaskModel).updateTask("completed"); + restTaskModel.assertThat().field("id").is(restTaskModel.getId()).and().field("state").is("completed"); + restClient.withWorkflowAPI().getTasks().assertThat().entriesListIsEmpty(); restClient.assertStatusCodeIs(HttpStatus.OK); } } From 0868b4c8bd64dfce92acd3c613a049c0a1b8f0fd Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Sun, 11 Dec 2016 16:19:40 +0200 Subject: [PATCH 0748/1491] added TODO --- .../rest/people/DeleteSiteMembershipRequestCoreTests.java | 4 +++- .../rest/people/GetSiteMembershipRequestsCoreTests.java | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestCoreTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestCoreTests.java index 9e1df0cf6..509d80953 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestCoreTests.java @@ -3,13 +3,14 @@ package org.alfresco.rest.people; import org.alfresco.dataprep.WorkflowService; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestTaskModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.exception.DataPreparationException; -import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.beans.factory.annotation.Autowired; @@ -125,6 +126,7 @@ public class DeleteSiteMembershipRequestCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify manager is not able to remove a site memebership request if it was already approved and response is 404") @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @Bug(id="TODO", description="TODO @cjalba please fix this NPE automated issue") //TODO @cjalba please fix this NPE automated issue public void managerUserIsNotAbleToDeleteASiteMembershipRequestIfItWasAlreadyApproved() throws JsonToModelConversionException, DataPreparationException, Exception { secondSiteMember.setUserRole(UserRole.SiteCollaborator); diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsCoreTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsCoreTests.java index b4710d63d..b0759398e 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsCoreTests.java @@ -7,6 +7,7 @@ import org.alfresco.rest.model.RestTaskModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -119,6 +120,7 @@ public class GetSiteMembershipRequestsCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Approve request then get requests.") @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @Bug(id="TODO", description="TODO @arusu please fix this NPE automated issue") //TODO @arusu please fix this NPE automated issue public void approveRequestThenGetRequests() throws Exception { UserModel siteManager = dataUser.createRandomTestUser(); From cda83aa928fd4262b8e13dbfd2906a7959f9868e Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Sun, 11 Dec 2016 16:21:52 +0200 Subject: [PATCH 0749/1491] test: added withParams("maxItems=2") to limit the returned results --- .../workflow/processes/AddProcessItemCoreTests.java | 4 ++-- .../workflow/processes/GetProcessItemsCoreTests.java | 2 +- .../processes/GetProcessVariablesCoreTests.java | 10 +++++----- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemCoreTests.java index 1ca0e1709..f7b83d8f2 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemCoreTests.java @@ -59,7 +59,7 @@ public class AddProcessItemCoreTests extends RestTest anotherUser = dataUser.createRandomTestUser(); document2 = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processModel = restClient.authenticateUser(adminUser).withParams("maxItems=1").withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); processItem = restClient.authenticateUser(anotherUser).withWorkflowAPI().usingProcess(processModel).addProcessItem(document2); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() @@ -111,7 +111,7 @@ public class AddProcessItemCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process item is falling in case of invalid process id is provided") public void failedAddingProcessItemIfInvalidProcessIdIsProvided() throws Exception { - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processModel = restClient.authenticateUser(adminUser).withParams("maxItems=1").withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); processModel.setId("invalidProcessId"); processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsCoreTests.java index 5d13f3599..cb3c2a870 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsCoreTests.java @@ -37,7 +37,7 @@ public class GetProcessItemsCoreTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) public void getProcessItemsAsAdminReturnsAnything() throws Exception { - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processModel = restClient.authenticateUser(adminUser).withParams("maxItems=2").withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems().assertThat().entriesListIsNotEmpty(); restClient.assertStatusCodeIs(HttpStatus.OK); } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesCoreTests.java index 95b3f47a4..52cd1fedc 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesCoreTests.java @@ -77,10 +77,10 @@ public class GetProcessVariablesCoreTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) public void getProcessVariablesUsingInvalidProcessId() throws JsonToModelConversionException, Exception { - processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processModel = restClient.authenticateUser(userWhoStartsTask).withParams("maxItems=2").withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); String id = RandomStringUtils.randomAlphanumeric(10); processModel.setId(id); - variables = restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables(); + variables = restClient.withParams("maxItems=2").withWorkflowAPI().usingProcess(processModel).getProcessVariables(); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, id)); } @@ -89,7 +89,7 @@ public class GetProcessVariablesCoreTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) public void getProcessVariablesUsingEmptyProcessId() throws JsonToModelConversionException, Exception { - processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processModel = restClient.authenticateUser(userWhoStartsTask).withParams("maxItems=2").withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); processModel.setId(" "); variables = restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables(); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, " ")); @@ -100,11 +100,11 @@ public class GetProcessVariablesCoreTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) public void getProcessVariablesForADeletedProcess() throws JsonToModelConversionException, Exception { - processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processModel = restClient.authenticateUser(userWhoStartsTask).withParams("maxItems=2").withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); restClient.authenticateUser(admin).withWorkflowAPI().usingProcess(processModel).deleteProcess(); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.authenticateUser(admin).withWorkflowAPI().usingProcess(processModel).getProcess(); + restClient.authenticateUser(admin).withParams("maxItems=2").withWorkflowAPI().usingProcess(processModel).getProcess(); variables = restClient.authenticateUser(admin).withWorkflowAPI().usingProcess(processModel).getProcessVariables(); restClient.assertStatusCodeIs(HttpStatus.OK); From 37699ac9fd56c98998b97af2bf4276ada8d00123 Mon Sep 17 00:00:00 2001 From: cagache Date: Mon, 12 Dec 2016 10:17:31 +0200 Subject: [PATCH 0750/1491] fix NPE in getTaskModelByDescription --- .../rest/people/DeleteSiteMembershipRequestCoreTests.java | 1 - .../alfresco/rest/people/GetSiteMembershipRequestsCoreTests.java | 1 - 2 files changed, 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestCoreTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestCoreTests.java index 509d80953..34d206cda 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestCoreTests.java @@ -126,7 +126,6 @@ public class DeleteSiteMembershipRequestCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify manager is not able to remove a site memebership request if it was already approved and response is 404") @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @Bug(id="TODO", description="TODO @cjalba please fix this NPE automated issue") //TODO @cjalba please fix this NPE automated issue public void managerUserIsNotAbleToDeleteASiteMembershipRequestIfItWasAlreadyApproved() throws JsonToModelConversionException, DataPreparationException, Exception { secondSiteMember.setUserRole(UserRole.SiteCollaborator); diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsCoreTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsCoreTests.java index b0759398e..fb0e9ce02 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsCoreTests.java @@ -120,7 +120,6 @@ public class GetSiteMembershipRequestsCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Approve request then get requests.") @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @Bug(id="TODO", description="TODO @arusu please fix this NPE automated issue") //TODO @arusu please fix this NPE automated issue public void approveRequestThenGetRequests() throws Exception { UserModel siteManager = dataUser.createRandomTestUser(); From 41419677d4bbdaedadf965301c601fd693f036c2 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Mon, 12 Dec 2016 10:21:41 +0200 Subject: [PATCH 0751/1491] fix: mode@Test annotation to test level for comments and tags packages --- .../alfresco/rest/comments/AddCommentCoreTests.java | 10 +++++++++- .../alfresco/rest/comments/AddCommentsSanityTests.java | 7 ++++++- .../rest/comments/DeleteCommentsCoreTests.java | 5 ++++- .../rest/comments/DeleteCommentsSanityTests.java | 6 +++++- .../alfresco/rest/comments/GetCommentsCoreTests.java | 8 +++++++- .../alfresco/rest/comments/GetCommentsSanityTests.java | 9 ++++++++- .../rest/comments/UpdateCommentsSanityTests.java | 9 ++++++++- .../java/org/alfresco/rest/tags/AddTagCoreTests.java | 9 ++++++++- .../java/org/alfresco/rest/tags/AddTagSanityTests.java | 8 +++++++- .../org/alfresco/rest/tags/AddTagsSanityTests.java | 8 +++++++- .../org/alfresco/rest/tags/DeleteTagCoreTests.java | 7 ++++++- .../org/alfresco/rest/tags/DeleteTagSanityTests.java | 8 +++++++- .../org/alfresco/rest/tags/GetNodeTagsCoreTests.java | 8 +++++++- .../org/alfresco/rest/tags/GetNodeTagsSanityTests.java | 7 ++++++- .../java/org/alfresco/rest/tags/GetTagCoreTests.java | 4 +++- .../java/org/alfresco/rest/tags/GetTagSanityTests.java | 7 ++++++- .../java/org/alfresco/rest/tags/GetTagsCoreTests.java | 5 ++++- .../org/alfresco/rest/tags/GetTagsSanityTests.java | 7 ++++++- .../org/alfresco/rest/tags/UpdateTagCoreTests.java | 6 +++++- .../org/alfresco/rest/tags/UpdateTagSanityTests.java | 7 ++++++- 20 files changed, 125 insertions(+), 20 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentCoreTests.java b/e2e-test/java/org/alfresco/rest/comments/AddCommentCoreTests.java index d799bd408..690c6fe0f 100644 --- a/e2e-test/java/org/alfresco/rest/comments/AddCommentCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/AddCommentCoreTests.java @@ -20,7 +20,6 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) public class AddCommentCoreTests extends RestTest { private UserModel adminUserModel; @@ -49,6 +48,7 @@ public class AddCommentCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify that invalid request returns status code 404 for nodeId that does not exist") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) public void addCommentUsingInvalidNodeId() throws JsonToModelConversionException, Exception { FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); @@ -62,6 +62,7 @@ public class AddCommentCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify that request using nodeId that is neither document or folder returns 405") @Bug(id = "MNT-16904") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) public void addCommentUsingResourceThatIsNotFileOrFolder() throws JsonToModelConversionException, Exception { LinkModel link = dataLink.usingAdmin().usingSite(siteModel).createRandomLink(); @@ -76,6 +77,7 @@ public class AddCommentCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify that adding comment using empty content returns 400 status code") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) public void addCommentUsingEmptyContent() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel) @@ -85,6 +87,7 @@ public class AddCommentCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify adding comment with the same content as one existing comment") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) public void addCommentTwice() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel) @@ -100,6 +103,7 @@ public class AddCommentCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify that comment can be retrieved after it is added") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) public void addCommentThenRetrieveComment() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel) @@ -115,6 +119,7 @@ public class AddCommentCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify comment cannot be added if user is not member of private site") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) public void addCommentWithNonMemberOfPrivateSite() throws JsonToModelConversionException, Exception { UserModel member = dataUser.createRandomTestUser(); @@ -129,6 +134,7 @@ public class AddCommentCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify comment cannot be added if empty network ID is provided") @Bug(id = "MNT-16904") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) public void addCommentUsingEmptyNetworkId() throws JsonToModelConversionException, Exception { UserModel member = dataUser.createRandomTestUser(); @@ -141,6 +147,7 @@ public class AddCommentCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify that comment cannot be added to another comment") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) public void addCommentToAComment() throws JsonToModelConversionException, Exception { FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); @@ -156,6 +163,7 @@ public class AddCommentCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify that comment cannot be added to a tag") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) public void addCommentToATag() throws JsonToModelConversionException, Exception { FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java index 2debbf53f..f24f13807 100644 --- a/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java @@ -21,7 +21,6 @@ import org.testng.annotations.Test; /** * Created by Claudia Agache on 10/10/2016. */ -@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) public class AddCommentsSanityTests extends RestTest { private UserModel adminUserModel; @@ -50,6 +49,7 @@ public class AddCommentsSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify admin user adds multiple comments with Rest API and status code is 201") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) public void adminIsAbleToAddComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel) @@ -62,6 +62,7 @@ public class AddCommentsSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Manager user adds multiple comments with Rest API and status code is 201") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) public void managerIsAbleToAddComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) @@ -74,6 +75,7 @@ public class AddCommentsSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Contributor user adds multiple comments with Rest API and status code is 201") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) public void contributorIsAbleToAddComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) @@ -86,6 +88,7 @@ public class AddCommentsSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user adds multiple comments with Rest API and status code is 201") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) public void collaboratorIsAbleToAddComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) @@ -99,6 +102,7 @@ public class AddCommentsSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Consumer user adds multiple comments with Rest API and status code is 201") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) public void consumerIsAbleToAddComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) @@ -109,6 +113,7 @@ public class AddCommentsSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user gets status code 401 on post multiple comments call") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) public void unauthenticatedUserIsNotAbleToAddComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(new UserModel("random user", "random password")) diff --git a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsCoreTests.java b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsCoreTests.java index babe3a595..cefe84996 100644 --- a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsCoreTests.java @@ -17,7 +17,6 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) public class DeleteCommentsCoreTests extends RestTest { private UserModel adminUserModel; @@ -51,6 +50,7 @@ public class DeleteCommentsCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Manager user deletes comments created by admin and status code is 204") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) public void managerIsAbleToDeleteComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); @@ -62,6 +62,7 @@ public class DeleteCommentsCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Admin user can't delete comments with inexistent ID and status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) public void userIsNotAbleToDeleteInexistentComment() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); @@ -73,6 +74,7 @@ public class DeleteCommentsCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Admin user can't delete comments with inexistend NodeId and status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) public void userIsNotAbleToDeleteCommentWithInexistentNodeId() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); @@ -85,6 +87,7 @@ public class DeleteCommentsCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Admin user can't delete deleted comments and status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) public void userIsNotAbleToDeleteDeletedComment() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); diff --git a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java index 359a3f27d..ed318b2a2 100644 --- a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java @@ -14,7 +14,6 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) public class DeleteCommentsSanityTests extends RestTest { private UserModel adminUserModel; @@ -36,6 +35,7 @@ public class DeleteCommentsSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Admin user deletes comments with Rest API and status code is 204") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) public void adminIsAbleToDeleteComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); @@ -46,6 +46,7 @@ public class DeleteCommentsSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Manager user deletes own comments and status code is 204") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) public void managerIsAbleToDeleteComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); @@ -56,6 +57,7 @@ public class DeleteCommentsSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user deletes own comments and status code is 204") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) public void collaboratorIsAbleToDeleteComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); @@ -66,6 +68,7 @@ public class DeleteCommentsSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Contributor user deletes own comments and status code is 204") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) public void contributorIsAbleToDeleteComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); @@ -77,6 +80,7 @@ public class DeleteCommentsSanityTests extends RestTest @Bug(id="MNT-16904") @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify User gets status code 401 if authentication call fails") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) public void userIsNotAbleToDeleteCommentIfAuthenticationFails() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); diff --git a/e2e-test/java/org/alfresco/rest/comments/GetCommentsCoreTests.java b/e2e-test/java/org/alfresco/rest/comments/GetCommentsCoreTests.java index d7fd1e7bc..8345fae21 100644 --- a/e2e-test/java/org/alfresco/rest/comments/GetCommentsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/GetCommentsCoreTests.java @@ -15,7 +15,6 @@ import org.testng.annotations.Test; /** * Created by Claudia Agache on 11/18/2016. */ -@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) public class GetCommentsCoreTests extends RestTest { private UserModel adminUserModel, userModel, networkUserModel; @@ -45,6 +44,7 @@ public class GetCommentsCoreTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Verify invalid request returns status code 400 for invalid maxItems or skipCount") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) public void checkStatusCodeForInvalidMaxItems() throws Exception { restClient.authenticateUser(adminUserModel).withParams("maxItems=0") @@ -55,6 +55,7 @@ public class GetCommentsCoreTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Verify User can't get comments for node with ID that does not exist and status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) public void userCanNotGetCommentsOnNonexistentFile() throws Exception { FileModel nonexistentFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); @@ -67,6 +68,7 @@ public class GetCommentsCoreTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Verify User can't get comments for node that exists but is not a document or a folder and status code is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) @Bug(id = "MNT-16904") public void userCanNotGetCommentsOnLink() throws Exception { @@ -81,6 +83,7 @@ public class GetCommentsCoreTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Verify request returns status 403 if the user does not have permission read comments on the node") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) public void uninvitedUserCanNotGetCommentsFromPrivateSite() throws Exception { restClient.authenticateUser(userModel).withCoreAPI() @@ -91,6 +94,7 @@ public class GetCommentsCoreTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Verify user gets comments without the first 2 and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) public void skipFirst2Comments() throws Exception { comments = restClient.authenticateUser(adminUserModel).withParams("skipCount=2") @@ -104,6 +108,7 @@ public class GetCommentsCoreTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Verify get comments from node with invalid network id returns status code 401") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) public void getCommentsWithInvalidNetwork() throws Exception { networkUserModel.setDomain("invalidNetwork"); @@ -113,6 +118,7 @@ public class GetCommentsCoreTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Verify get comments from node with empty network id returns status code 401") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) public void getCommentsWithEmptyNetwork() throws Exception { networkUserModel.setDomain(""); diff --git a/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java index 260811444..d6797f9ac 100644 --- a/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java @@ -14,7 +14,6 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) public class GetCommentsSanityTests extends RestTest { private UserModel adminUserModel; @@ -40,6 +39,7 @@ public class GetCommentsSanityTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.SANITY}, executionType= ExecutionType.SANITY, description= "Verify Admin user gets comments with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) public void adminIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception { comments = restClient.authenticateUser(adminUserModel).withCoreAPI() @@ -50,6 +50,7 @@ public class GetCommentsSanityTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.SANITY}, executionType= ExecutionType.SANITY, description= "Verify Manager user gets comments created by admin user with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) public void managerIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception { comments = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI() @@ -60,6 +61,7 @@ public class GetCommentsSanityTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.SANITY}, executionType= ExecutionType.SANITY, description= "Verify Contributor user gets comments created by admin user with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) public void contributorIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception { comments = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI() @@ -70,6 +72,7 @@ public class GetCommentsSanityTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.SANITY}, executionType= ExecutionType.SANITY, description= "Verify Collaborator user gets comments created by admin user with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) public void collaboratorIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception { comments = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI() @@ -80,6 +83,7 @@ public class GetCommentsSanityTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.SANITY}, executionType= ExecutionType.SANITY, description= "Verify Consumer user gets comments created by admin user with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) public void consumerIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception { comments = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI() @@ -90,6 +94,7 @@ public class GetCommentsSanityTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.SANITY}, executionType= ExecutionType.SANITY, description= "Verify Manager user gets status code 401 if authentication call fails") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) public void managerIsNotAbleToRetrieveCommentIfAuthenticationFails() throws JsonToModelConversionException, Exception { UserModel nonexistentModel = new UserModel("nonexistentUser", "nonexistentPassword"); @@ -101,6 +106,7 @@ public class GetCommentsSanityTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.SANITY}, executionType= ExecutionType.SANITY, description= "Verify Manager user gets comments created by another user and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) public void managerIsAbleToRetrieveCommentsCreatedByAnotherUser() throws JsonToModelConversionException, Exception { userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); @@ -117,6 +123,7 @@ public class GetCommentsSanityTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.SANITY}, executionType= ExecutionType.SANITY, description= "Verify admin user gets comments created by another user and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) public void adminIsAbleToRetrieveCommentsCreatedByAnotherUser() throws JsonToModelConversionException, Exception { userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); diff --git a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java index 830a92fb0..8e7978d3d 100644 --- a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java @@ -15,7 +15,6 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) public class UpdateCommentsSanityTests extends RestTest { private UserModel adminUserModel; @@ -37,6 +36,7 @@ public class UpdateCommentsSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Admin user updates comments and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) public void adminIsAbleToUpdateHisComment() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); @@ -50,6 +50,7 @@ public class UpdateCommentsSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Manager user updates comments created by admin user and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) public void managerIsAbleToUpdateHisComment() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); @@ -63,6 +64,7 @@ public class UpdateCommentsSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Contributor user can update his own comment and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) public void contributorIsAbleToUpdateHisComment() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); @@ -74,6 +76,7 @@ public class UpdateCommentsSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Consumer user can not update comments created by admin user and status code is 403") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) public void consumerIsNotAbleToUpdateComment() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); @@ -87,6 +90,7 @@ public class UpdateCommentsSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user can update his own comment and status code is 200") @Bug(id="REPO-1011") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) public void collaboratorIsAbleToUpdateHisComment() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); @@ -98,6 +102,7 @@ public class UpdateCommentsSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user gets status code 401 on update comment call") @Bug(id="MNT-16904") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) public void unauthenticatedUserIsNotAbleToUpdateComment() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); @@ -109,6 +114,7 @@ public class UpdateCommentsSanityTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.SANITY }, executionType = ExecutionType.SANITY, description = "Verify update comment with inexistent nodeId returns status code 404") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) public void canNotUpdateCommentIfNodeIdIsNotSet() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); @@ -122,6 +128,7 @@ public class UpdateCommentsSanityTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.SANITY }, executionType = ExecutionType.SANITY, description = "Verify if commentId is not set the status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) public void canNotUpdateCommentIfCommentIdIsNotSet() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); diff --git a/e2e-test/java/org/alfresco/rest/tags/AddTagCoreTests.java b/e2e-test/java/org/alfresco/rest/tags/AddTagCoreTests.java index dc3c9806f..e6779db48 100644 --- a/e2e-test/java/org/alfresco/rest/tags/AddTagCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/AddTagCoreTests.java @@ -21,7 +21,6 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) public class AddTagCoreTests extends RestTest { private UserModel adminUserModel; @@ -53,6 +52,7 @@ public class AddTagCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify that adding empty tag returns status code 400") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) public void emptyTagTest() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); @@ -62,6 +62,7 @@ public class AddTagCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify that adding tag with user that has no permissions returns status code 403") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) public void addTagWithUserThatDoesNotHavePermissions() throws JsonToModelConversionException, Exception { restClient.authenticateUser(testUser); @@ -71,6 +72,7 @@ public class AddTagCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify that adding tag to a node that does not exist returns status code 404") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) public void addTagToInexistentNode() throws JsonToModelConversionException, Exception { FileModel document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); @@ -85,6 +87,7 @@ public class AddTagCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify that adding tag to a node that does not accepts tags returns status code 405") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) public void addTagToANodeThatDoesNotAcceptsTags() throws JsonToModelConversionException, Exception { FileModel document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); @@ -98,6 +101,7 @@ public class AddTagCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify that manager is able to tag a file") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) public void managerIsAbleToTagAFile() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); @@ -108,6 +112,7 @@ public class AddTagCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify that manager is able to tag a folder") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) public void managerIsAbleToTagAFolder() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); @@ -118,6 +123,7 @@ public class AddTagCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify that tagged file can be tagged again") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) public void addTagToATaggedFile() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); @@ -141,6 +147,7 @@ public class AddTagCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify that user cannot add invalid tag") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) public void addInvalidTag() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); diff --git a/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java index 516ca3086..9c67ddde9 100644 --- a/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java @@ -24,7 +24,6 @@ import org.testng.annotations.Test; /** * Created by Claudia Agache on 10/3/2016. */ -@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) public class AddTagSanityTests extends RestTest { private UserModel adminUserModel, userModel; @@ -52,6 +51,7 @@ public class AddTagSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify admin user adds tags with Rest API and status code is 201") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) public void adminIsAbleToAddTag() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); @@ -63,6 +63,7 @@ public class AddTagSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Manager user adds tags with Rest API and status code is 201") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) public void managerIsAbleToAddTag() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); @@ -74,6 +75,7 @@ public class AddTagSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user adds tags with Rest API and status code is 201") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) public void collaboratorIsAbleToAddTag() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); @@ -85,6 +87,7 @@ public class AddTagSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Contributor user doesn't have permission to add tags with Rest API and status code is 403") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) public void contributorIsNotAbleToAddTagToAnotherContent() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); @@ -94,6 +97,7 @@ public class AddTagSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Contributor user adds tags to his content with Rest API and status code is 201") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) public void contributorIsAbleToAddTagToHisContent() throws JsonToModelConversionException, Exception { userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); @@ -107,6 +111,7 @@ public class AddTagSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Consumer user doesn't have permission to add tags with Rest API and status code is 403") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) public void consumerIsNotAbleToAddTag() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); @@ -117,6 +122,7 @@ public class AddTagSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user gets status code 401 if authentication call fails") @Bug(id="MNT-16904") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) public void userIsNotAbleToAddTagIfAuthenticationFails() throws JsonToModelConversionException, Exception { UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); diff --git a/e2e-test/java/org/alfresco/rest/tags/AddTagsSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/AddTagsSanityTests.java index 12dc8c676..1c0f5458f 100644 --- a/e2e-test/java/org/alfresco/rest/tags/AddTagsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/AddTagsSanityTests.java @@ -24,7 +24,6 @@ import org.testng.annotations.Test; /** * Created by Claudia Agache on 10/7/2016. */ -@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) public class AddTagsSanityTests extends RestTest { private UserModel adminUserModel, userModel; @@ -53,6 +52,7 @@ public class AddTagsSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify admin user adds multiple tags with Rest API and status code is 201") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) public void adminIsAbleToAddTags() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); @@ -64,6 +64,7 @@ public class AddTagsSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Manager user adds multiple tags with Rest API and status code is 201") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) public void managerIsAbleToAddTags() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); @@ -75,6 +76,7 @@ public class AddTagsSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user adds multiple tags with Rest API and status code is 201") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) public void collaboratorIsAbleToAddTags() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); @@ -86,6 +88,7 @@ public class AddTagsSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Contributor user doesn't have permission to add multiple tags with Rest API and status code is 403") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) public void contributorIsNotAbleToAddTagsToAnotherContent() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); @@ -95,6 +98,7 @@ public class AddTagsSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Contributor user adds multiple tags to his content with Rest API and status code is 201") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) public void contributorIsAbleToAddTagsToHisContent() throws JsonToModelConversionException, Exception { userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); @@ -108,6 +112,7 @@ public class AddTagsSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Consumer user doesn't have permission to add multiple tags with Rest API and status code is 403") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) public void consumerIsNotAbleToAddTags() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingResource(document).addTags(tag1, tag2); @@ -117,6 +122,7 @@ public class AddTagsSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user gets status code 401 if authentication call fails") @Bug(id="MNT-16904") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) public void userIsNotAbleToAddTagsIfAuthenticationFails() throws JsonToModelConversionException, Exception { UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); diff --git a/e2e-test/java/org/alfresco/rest/tags/DeleteTagCoreTests.java b/e2e-test/java/org/alfresco/rest/tags/DeleteTagCoreTests.java index fd3edb3c2..0d909bf90 100644 --- a/e2e-test/java/org/alfresco/rest/tags/DeleteTagCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/DeleteTagCoreTests.java @@ -18,7 +18,6 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) public class DeleteTagCoreTests extends RestTest { private UserModel adminUserModel, userModel; @@ -45,6 +44,7 @@ public class DeleteTagCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify that if user has no permission to remove tag returned status code is 403") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) public void deleteTagWithUserWithoutPermission() throws Exception { restClient.authenticateUser(userModel); @@ -54,6 +54,7 @@ public class DeleteTagCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify that if node does not exist returned status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) public void deleteTagForAnInexistentNode() throws Exception { FileModel document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); @@ -65,6 +66,7 @@ public class DeleteTagCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify that if tag does not exist returned status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) public void deleteTagThatDoesNotExist() throws Exception { tag.setId("abc"); @@ -74,6 +76,7 @@ public class DeleteTagCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify that if tag id is empty returned status code is 405") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) public void deleteTagWithEmptyId() throws Exception { tag.setId(""); @@ -83,6 +86,7 @@ public class DeleteTagCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify that file tag can be deleted") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) public void deleteFileTag() throws Exception { restClient.withCoreAPI().usingResource(document).deleteTag(tag); @@ -93,6 +97,7 @@ public class DeleteTagCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify that folder tag can be deleted") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) public void deleteFolderTag() throws Exception { tag = restClient.withCoreAPI().usingResource(folderModel).addTag(RandomData.getRandomName("tag")); diff --git a/e2e-test/java/org/alfresco/rest/tags/DeleteTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/DeleteTagSanityTests.java index c3f95419f..cd9183f27 100644 --- a/e2e-test/java/org/alfresco/rest/tags/DeleteTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/DeleteTagSanityTests.java @@ -23,7 +23,6 @@ import org.testng.annotations.Test; /** * Created by Claudia Agache on 10/4/2016. */ -@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) public class DeleteTagSanityTests extends RestTest { private UserModel adminUserModel, userModel; @@ -43,6 +42,7 @@ public class DeleteTagSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Admin user deletes tags with Rest API and status code is 204") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) public void adminIsAbleToDeleteTags() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); @@ -54,6 +54,7 @@ public class DeleteTagSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Manager user deletes tags created by admin user with Rest API and status code is 204") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) public void managerIsAbleToDeleteTags() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); @@ -66,6 +67,7 @@ public class DeleteTagSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user deletes tags created by admin user with Rest API and status code is 204") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) public void collaboratorIsAbleToDeleteTags() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); @@ -78,6 +80,7 @@ public class DeleteTagSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Contributor user can't delete tags created by admin user with Rest API and status code is 403") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) public void contributorIsNotAbleToDeleteTagsForAnotherUserContent() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); @@ -90,6 +93,7 @@ public class DeleteTagSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Contributor user deletes tags created by him with Rest API and status code is 204") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) public void contributorIsAbleToDeleteTagsForHisContent() throws JsonToModelConversionException, Exception { userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); @@ -103,6 +107,7 @@ public class DeleteTagSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Consumer user can't delete tags created by admin user with Rest API and status code is 403") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) public void consumerIsNotAbleToDeleteTags() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); @@ -116,6 +121,7 @@ public class DeleteTagSanityTests extends RestTest @Bug(id="MNT-16904") @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user gets status code 401 if authentication call fails") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) public void userIsNotAbleToDeleteTagIfAuthenticationFails() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); diff --git a/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsCoreTests.java b/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsCoreTests.java index 3e494e552..5cf50cbb1 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsCoreTests.java @@ -17,7 +17,6 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) public class GetNodeTagsCoreTests extends RestTest { private UserModel adminUserModel, userModel; @@ -45,6 +44,7 @@ public class GetNodeTagsCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify that using invalid value for skipCount parameter returns status code 400") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) public void invalidSkipCountTest() throws JsonToModelConversionException, Exception { restClient.withParams("skipCount=abc").withCoreAPI().usingResource(document).getNodeTags(); @@ -56,6 +56,7 @@ public class GetNodeTagsCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify that using invalid value for maxItems parameter returns status code 400") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) public void invalidMaxItemsTest() throws JsonToModelConversionException, Exception { restClient.withParams("maxItems=abc").withCoreAPI().usingResource(document).getNodeTags(); @@ -67,6 +68,7 @@ public class GetNodeTagsCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify that user without permissions returns status code 403") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) public void userWithoutPermissionsTest() throws JsonToModelConversionException, Exception { SiteModel site = dataSite.usingUser(adminUserModel).createModeratedRandomSite(); @@ -80,6 +82,7 @@ public class GetNodeTagsCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify that if node does not exist returns status code 403") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) public void inexistentNodeTest() throws JsonToModelConversionException, Exception { FileModel document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); @@ -92,6 +95,7 @@ public class GetNodeTagsCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify that if node id is empty returns status code 403") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) public void emptyNodeIdTest() throws JsonToModelConversionException, Exception { FileModel document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); @@ -103,6 +107,7 @@ public class GetNodeTagsCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify file tags") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) public void fileTagsTest() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getNodeTags() @@ -113,6 +118,7 @@ public class GetNodeTagsCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify folder tags") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) public void folderTagsTest() throws JsonToModelConversionException, Exception { FolderModel folder = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); diff --git a/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java index b9147a32e..85e7b0235 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java @@ -15,7 +15,6 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) public class GetNodeTagsSanityTests extends RestTest { private UserModel adminUserModel; @@ -46,6 +45,7 @@ public class GetNodeTagsSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify site Manager is able to get node tags") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) public void siteManagerIsAbleToRetrieveNodeTags() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); @@ -60,6 +60,7 @@ public class GetNodeTagsSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify site Collaborator is able to get node tags") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) public void siteCollaboratorIsAbleToRetrieveNodeTags() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); @@ -73,6 +74,7 @@ public class GetNodeTagsSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify site Contributor is able to get node tags") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) public void siteContributorIsAbleToRetrieveNodeTags() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); @@ -86,6 +88,7 @@ public class GetNodeTagsSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify site Consumer is able to get node tags") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) public void siteConsumerIsAbleToRetrieveNodeTags() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); @@ -99,6 +102,7 @@ public class GetNodeTagsSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify admin is able to get node tags") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) public void adminIsAbleToRetrieveNodeTags() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); @@ -111,6 +115,7 @@ public class GetNodeTagsSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to get node tags") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) public void unauthenticatedUserIsNotAbleToRetrieveNodeTags() throws JsonToModelConversionException, Exception { restClient.authenticateUser(new UserModel("random user", "random password")); diff --git a/e2e-test/java/org/alfresco/rest/tags/GetTagCoreTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagCoreTests.java index c78f81237..dc1b8c62f 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetTagCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetTagCoreTests.java @@ -17,7 +17,6 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) public class GetTagCoreTests extends RestTest { private UserModel adminUserModel; @@ -43,6 +42,7 @@ public class GetTagCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify that if tag id is invalid status code returned is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) public void invalidTagIdTest() throws JsonToModelConversionException, Exception { tag.setId("random_tag_value"); @@ -52,6 +52,7 @@ public class GetTagCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Retrieve and validate the id of a tag added to a file") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) public void validateTagIdTest() throws JsonToModelConversionException, Exception { RestTagModel returnedTag = restClient.withCoreAPI().getTag(tag); @@ -61,6 +62,7 @@ public class GetTagCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Retrieve and validate the name of a tag added to a file") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) public void validateTagNameTest() throws JsonToModelConversionException, Exception { RestTagModel returnedTag = restClient.withCoreAPI().getTag(tag); diff --git a/e2e-test/java/org/alfresco/rest/tags/GetTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagSanityTests.java index bd2a709db..b273f99f2 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetTagSanityTests.java @@ -19,7 +19,6 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) public class GetTagSanityTests extends RestTest { private UserModel adminUserModel; @@ -40,6 +39,7 @@ public class GetTagSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify admin user gets tag using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) public void userWithAdminIsAbletoGetTag() throws JsonToModelConversionException, Exception { String tagValue = RandomData.getRandomName("tag"); @@ -53,6 +53,7 @@ public class GetTagSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role gets tag using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) public void userWithManagerRoleIsAbletoGetTag() throws JsonToModelConversionException, Exception { String tagValue = RandomData.getRandomName("tag"); @@ -65,6 +66,7 @@ public class GetTagSanityTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user with Collaborator role gets tag using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) public void userWithCollaboratorRoleIsAbletoGetTag() throws JsonToModelConversionException, Exception { String tagValue = RandomData.getRandomName("tag"); @@ -77,6 +79,7 @@ public class GetTagSanityTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user with Contributor role gets tag using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) public void userWithContributorRoleIsAbletoGetTag() throws JsonToModelConversionException, Exception { String tagValue = RandomData.getRandomName("tag"); @@ -91,6 +94,7 @@ public class GetTagSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role gets tag using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) public void userWithConsumerRoleIsAbletoGetTag() throws JsonToModelConversionException, Exception { String tagValue = RandomData.getRandomName("tag"); @@ -105,6 +109,7 @@ public class GetTagSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Manager user gets status code 401 if authentication call fails") @Bug(id = "MNT-16904") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) public void managerIsNotAbleToGetTagIfAuthenticationFails() throws JsonToModelConversionException, Exception { String tagValue = RandomData.getRandomName("tag"); diff --git a/e2e-test/java/org/alfresco/rest/tags/GetTagsCoreTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagsCoreTests.java index d2123813f..92f006e77 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetTagsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetTagsCoreTests.java @@ -18,7 +18,6 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) public class GetTagsCoreTests extends RestTest { private UserModel adminUserModel; @@ -49,6 +48,7 @@ public class GetTagsCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify that if maxItems is invalid status code returned is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) public void maxItemsInvalidValueTest() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel).withParams("maxItems=abc").withCoreAPI().getTags(); @@ -57,6 +57,7 @@ public class GetTagsCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify that if skipCount is invalid status code returned is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) public void skipCountInvalidValueTest() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel).withParams("skipCount=abc").withCoreAPI().getTags(); @@ -65,6 +66,7 @@ public class GetTagsCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify that file tag is retrieved") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) public void fileTagIsRetrieved() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); @@ -76,6 +78,7 @@ public class GetTagsCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify that folder tag is retrieved") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) public void folderTagIsRetrieved() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); diff --git a/e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java index e0c9fd788..e20e4e9e4 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java @@ -16,7 +16,6 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) public class GetTagsSanityTests extends RestTest { private UserModel adminUserModel; @@ -46,6 +45,7 @@ public class GetTagsSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role gets tags using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) public void getTagsWithManagerRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); @@ -57,6 +57,7 @@ public class GetTagsSanityTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user with Collaborator role gets tags using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) public void getTagsWithCollaboratorRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); @@ -68,6 +69,7 @@ public class GetTagsSanityTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user with Contributor role gets tags using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) public void getTagsWithContributorRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); @@ -79,6 +81,7 @@ public class GetTagsSanityTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role gets tags using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) public void getTagsWithConsumerRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); @@ -90,6 +93,7 @@ public class GetTagsSanityTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets tags using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) public void getTagsWithAdminUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); @@ -102,6 +106,7 @@ public class GetTagsSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Failed authentication get tags call returns status code 401 with Manager role") @Bug(id = "MNT-16904") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) public void failedAuthenticationReturnsUnauthorizedStatus() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); diff --git a/e2e-test/java/org/alfresco/rest/tags/UpdateTagCoreTests.java b/e2e-test/java/org/alfresco/rest/tags/UpdateTagCoreTests.java index a0353bd71..81f69eb91 100644 --- a/e2e-test/java/org/alfresco/rest/tags/UpdateTagCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/UpdateTagCoreTests.java @@ -23,7 +23,6 @@ import org.testng.annotations.Test; /** * Created by Bogdan Bocancea */ -@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) public class UpdateTagCoreTests extends RestTest { private UserModel managerUser; @@ -47,6 +46,7 @@ public class UpdateTagCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify site manager is not able to update tag with invalid id") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) public void managerIsNotAbleToUpdateTagWithInvalidId() throws JsonToModelConversionException, Exception { String invalidTagId = "invalid-id"; @@ -59,6 +59,7 @@ public class UpdateTagCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify site manager is not able to update tag with empty id") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) public void managerIsNotAbleToUpdateTagWithEmptyId() throws JsonToModelConversionException, Exception { RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); @@ -70,6 +71,7 @@ public class UpdateTagCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify site manager is not able to update tag with invalid body") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) public void managerIsNotAbleToUpdateTagWithEmptyBody() throws JsonToModelConversionException, Exception { RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); @@ -82,6 +84,7 @@ public class UpdateTagCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify site manager is not able to update tag with invalid body containing '|' symbol") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) public void managerIsNotAbleToUpdateTagWithInvalidBodyScenario1() throws JsonToModelConversionException, Exception { String invalidTagBody = "|.\"/<>*"; @@ -96,6 +99,7 @@ public class UpdateTagCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify site manager is not able to update tag with invalid body without '|' symbol") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) public void managerIsNotAbleToUpdateTagWithInvalidBodyScenario2() throws JsonToModelConversionException, Exception { String invalidTagBody = ".\"/<>*"; diff --git a/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java index a3d5b92ec..d96e90c1f 100644 --- a/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java @@ -23,7 +23,6 @@ import org.testng.annotations.Test; /** * Created by Claudia Agache on 10/4/2016. */ -@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) public class UpdateTagSanityTests extends RestTest { private UserModel adminUserModel; @@ -53,6 +52,7 @@ public class UpdateTagSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Admin user updates tags and status code is 200") @Bug(id="MNT-16917") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) public void adminIsAbleToUpdateTags() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); @@ -63,6 +63,7 @@ public class UpdateTagSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Manager user can't update tags with Rest API and status code is 403") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) public void managerIsNotAbleToUpdateTag() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); @@ -72,6 +73,7 @@ public class UpdateTagSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user can't update tags with Rest API and status code is 403") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) public void collaboratorIsNotAbleToUpdateTag() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); @@ -81,6 +83,7 @@ public class UpdateTagSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Contributor user can't update tags with Rest API and status code is 403") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) public void contributorIsNotAbleToUpdateTag() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); @@ -90,6 +93,7 @@ public class UpdateTagSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Consumer user can't update tags with Rest API and status code is 403") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) public void consumerIsNotAbleToUpdateTag() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); @@ -100,6 +104,7 @@ public class UpdateTagSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user gets status code 401 if authentication call fails") @Bug(id="MNT-16904") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) public void userIsNotAbleToUpdateTagIfAuthenticationFails() throws JsonToModelConversionException, Exception { UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); From 963e405e586187613028149e7abaa0bf1bd947ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alecsandru=20Prun=C4=83?= Date: Mon, 12 Dec 2016 10:29:59 +0200 Subject: [PATCH 0752/1491] test: Moved @Test from class level to method level --- .../rest/favorites/AddFavoritesCoreTests.java | 47 +++++++----- .../favorites/AddFavoritesSanityTests.java | 27 ++++--- .../favorites/DeleteFavoritesSanityTests.java | 43 ++++++----- .../favorites/GetFavoriteSanityTests.java | 57 ++++++++------- .../rest/favorites/GetFavoritesCoreTests.java | 56 +++++++++------ .../favorites/GetFavoritesSanityTests.java | 56 +++++++++------ .../RestGetNetworkForPersonSanityTests.java | 33 ++++----- .../rest/networks/RestGetNetworkTest.java | 72 ++++++++++--------- .../RestGetNetworksForPersonSanityTests.java | 33 ++++----- 9 files changed, 233 insertions(+), 191 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesCoreTests.java b/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesCoreTests.java index d5d84fc33..e5e5638c2 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesCoreTests.java @@ -23,12 +23,8 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) public class AddFavoritesCoreTests extends RestTest { - @Autowired - DataUser dataUser; - private UserModel adminUserModel; private SiteModel siteModel; private ListUserWithRoles usersWithRoles; @@ -38,7 +34,6 @@ public class AddFavoritesCoreTests extends RestTest FolderModel folder; private RestCommentModel comment; - private RestTagModel returnedModel; @BeforeClass(alwaysRun = true) @@ -56,6 +51,7 @@ public class AddFavoritesCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Check that if target guid does not describe a site, file, or folder status code is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) public void addFavoriteUsingInvalidGuid() throws Exception { LinkModel link = dataLink.usingAdmin().usingSite(siteModel).createRandomLink(); @@ -65,18 +61,20 @@ public class AddFavoritesCoreTests extends RestTest restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(site); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, site.getGuid().split("/")[3])); } - + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Check that if personId does not exist, status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) public void addFavoriteUsingInexistentUser() throws Exception { restClient.withCoreAPI().usingUser(new UserModel("random_user", "random_password")).addSiteToFavorites(siteModel); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "random_user")); } - + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Check that if target guid does not exist, status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) public void addFavoriteUsingInexistentGuid() throws Exception { SiteModel site = dataSite.usingUser(adminUserModel).createPublicRandomSite(); @@ -86,10 +84,11 @@ public class AddFavoritesCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "random_guid")); } - + + @Bug(id = "MNT-17157") @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Check that if a favorite already exists with the specified id status code is 404") - @Bug(id = "MNT-17157") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) public void addFavoriteTwice() throws Exception { restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); @@ -97,9 +96,10 @@ public class AddFavoritesCoreTests extends RestTest restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); restClient.assertStatusCodeIs(HttpStatus.CONFLICT); } - + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Check that if user provides file in target but guid is of a folder status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) public void addFileToFavoritesUsingFolderGuid() throws Exception { String nodeRef = document.getNodeRef(); @@ -111,9 +111,10 @@ public class AddFavoritesCoreTests extends RestTest document.setNodeRef(nodeRef); } - + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Add to favorites a file for a Manager, check it was added") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) public void managerIsAbleToAddFileToFavorites() throws Exception { restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) @@ -124,6 +125,7 @@ public class AddFavoritesCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify add favorite, perform getFavorites call, check value is updated") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) public void verifyGetFavoritesAfterFavoritingSite() throws Exception { restPersonFavoritesModel = restClient.authenticateUser(adminUserModel) @@ -135,6 +137,7 @@ public class AddFavoritesCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Add to favorites a folder for a Manager, check it was added") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) public void managerIsAbleToAddFolderToFavorites() throws Exception { restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) @@ -142,9 +145,10 @@ public class AddFavoritesCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.CREATED); restPersonFavoritesModel.assertThat().field("targetGuid").is(folder.getNodeRefWithoutVersion()); } - + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Add to favorites a site for a Manager, check it was added") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) public void managerIsAbleToAddSiteToFavorites() throws Exception { restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) @@ -152,9 +156,10 @@ public class AddFavoritesCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.CREATED); restPersonFavoritesModel.assertThat().field("targetGuid").is(siteModel.getGuid()); } - + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify add favorite specifying -me- string in place of for request") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) public void userIsAbleToAddFavoriteWhenUsingMeAsUsername() throws Exception { restPersonFavoritesModel = restClient.authenticateUser(adminUserModel) @@ -164,10 +169,11 @@ public class AddFavoritesCoreTests extends RestTest restClient.withCoreAPI().usingAuthUser().getFavoriteSites().assertThat().entriesListContains("guid", siteModel.getGuid()); } - + + @Bug(id = "MNT-17158") @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify add file favorite with comment id returns status code 404") - @Bug(id = "MNT-17158") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) public void addFileFavoriteUsingCommentId() throws Exception { FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); @@ -177,9 +183,10 @@ public class AddFavoritesCoreTests extends RestTest restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFileToFavorites(file); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); } - + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify add file favorite with tag id returns status code 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) public void addFileFavoriteUsingTagId() throws Exception { FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); @@ -190,9 +197,10 @@ public class AddFavoritesCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, adminUserModel.getUsername(), returnedModel.getId())); } - + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Check that if user provides site in target but id is of a file status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) public void addSiteToFavoritesUsingFileId() throws Exception { String guid = siteModel.getGuid(); @@ -203,9 +211,10 @@ public class AddFavoritesCoreTests extends RestTest siteModel.setGuid(guid); } - + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Check that if user provides folder in target but guid is of a file status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) public void addFolderToFavoritesUsingFileGuid() throws Exception { String nodeRef = folder.getNodeRef(); @@ -216,4 +225,4 @@ public class AddFavoritesCoreTests extends RestTest folder.setNodeRef(nodeRef); } -} \ No newline at end of file +} diff --git a/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesSanityTests.java index efd5baff2..806ef5d72 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesSanityTests.java @@ -18,12 +18,8 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) public class AddFavoritesSanityTests extends RestTest { - @Autowired - DataUser dataUser; - private UserModel adminUserModel; private SiteModel siteModel; private ListUserWithRoles usersWithRoles; @@ -40,9 +36,9 @@ public class AddFavoritesSanityTests extends RestTest UserRole.SiteContributor); } - @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, - executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Admin user add site to favorites with Rest API and status code is 201") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) public void adminIsAbleToAddToFavorites() throws Exception { restPersonFavoritesModel = restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); @@ -53,6 +49,7 @@ public class AddFavoritesSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Manager user add site to favorites with Rest API and status code is 201") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) public void managerIsAbleToAddToFavorites() throws Exception { restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI() @@ -61,9 +58,9 @@ public class AddFavoritesSanityTests extends RestTest restPersonFavoritesModel.assertThat().field("targetGuid").is(siteModel.getGuid()); } - @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, - executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user add site to favorites with Rest API and status code is 201") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) public void collaboratorIsAbleToAddToFavorites() throws Exception { restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) @@ -72,9 +69,9 @@ public class AddFavoritesSanityTests extends RestTest restPersonFavoritesModel.and().field("targetGuid").is(siteModel.getGuid()); } - @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, - executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Contributor user add site to favorites with Rest API and status code is 201") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) public void contributorIsAbleToAddToFavorites() throws JsonToModelConversionException, Exception { restPersonFavoritesModel= restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) @@ -83,9 +80,9 @@ public class AddFavoritesSanityTests extends RestTest restPersonFavoritesModel.and().field("targetGuid").is(siteModel.getGuid()); } - @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, - executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Consumer user add site to favorites with Rest API and status code is 201") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) public void consumerIsAbleToAddToFavorites() throws Exception { restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) @@ -94,10 +91,10 @@ public class AddFavoritesSanityTests extends RestTest restPersonFavoritesModel.and().field("targetGuid").is(siteModel.getGuid()); } - @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, - executionType = ExecutionType.SANITY, - description = "Verify Manager user gets status code 401 if authentication call fails") @Bug(id="MNT-16904") + @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, + description = "Verify Manager user gets status code 401 if authentication call fails") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) public void managerIsNotAbleToAddToFavoritesIfAuthenticationFails() throws Exception { UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); diff --git a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoritesSanityTests.java index 2ad3db617..2503d7c7a 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoritesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoritesSanityTests.java @@ -15,7 +15,6 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) public class DeleteFavoritesSanityTests extends RestTest { private UserModel adminUserModel; @@ -34,8 +33,9 @@ public class DeleteFavoritesSanityTests extends RestTest UserRole.SiteContributor); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Admin user deletes site from favorites with Rest API and status code is 204") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, + description = "Verify Admin user deletes site from favorites with Rest API and status code is 204") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) public void adminIsAbleToDeleteFavorites() throws JsonToModelConversionException, Exception { restClient.withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); @@ -44,8 +44,9 @@ public class DeleteFavoritesSanityTests extends RestTest restClient.withCoreAPI().usingAuthUser().getFavorites().assertThat().entriesListDoesNotContain("targetGuid", siteModel.getGuid()); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Manager user deletes site from favorites with Rest API and status code is 204") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, + description = "Verify Manager user deletes site from favorites with Rest API and status code is 204") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) public void managerIsAbleToDeleteFavorites() throws JsonToModelConversionException, Exception { UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); @@ -55,8 +56,9 @@ public class DeleteFavoritesSanityTests extends RestTest restClient.withCoreAPI().usingAuthUser().getFavorites().assertThat().entriesListDoesNotContain("targetGuid", siteModel.getGuid()); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user deletes site from favorites with Rest API and status code is 204") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, + description = "Verify Collaborator user deletes site from favorites with Rest API and status code is 204") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) public void collaboratorIsAbleToDeleteFavorites() throws JsonToModelConversionException, Exception { UserModel siteCollaborator = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); @@ -66,8 +68,9 @@ public class DeleteFavoritesSanityTests extends RestTest restClient.withCoreAPI().usingAuthUser().getFavorites().assertThat().entriesListDoesNotContain("targetGuid", siteModel.getGuid()); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Contributor user deletes site from favorites with Rest API and status code is 204") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, + description = "Verify Contributor user deletes site from favorites with Rest API and status code is 204") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) public void contributorIsAbleToDeleteFavorites() throws JsonToModelConversionException, Exception { UserModel siteContributor = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); @@ -77,8 +80,9 @@ public class DeleteFavoritesSanityTests extends RestTest restClient.withCoreAPI().usingAuthUser().getFavorites().assertThat().entriesListDoesNotContain("targetGuid", siteModel.getGuid()); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Consumer user delets site from favorites with Rest API and status code is 204") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, + description = "Verify Consumer user delets site from favorites with Rest API and status code is 204") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) public void consumerIsAbleToDeleteFavorites() throws JsonToModelConversionException, Exception { UserModel siteConsumer = usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer); @@ -88,9 +92,10 @@ public class DeleteFavoritesSanityTests extends RestTest restClient.withCoreAPI().usingAuthUser().getFavorites().assertThat().entriesListDoesNotContain("targetGuid", siteModel.getGuid()); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify user doesn't have permission to delete favorites of another user with Rest API and status code is 404") @Bug(id="MNT-16557") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, + description = "Verify user doesn't have permission to delete favorites of another user with Rest API and status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) public void userIsNotAbleToDeleteFavoritesOfAnotherUser() throws JsonToModelConversionException, Exception { UserModel siteCollaborator = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); @@ -100,8 +105,10 @@ public class DeleteFavoritesSanityTests extends RestTest .assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } - @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify user doesn't have permission to delete favorites of admin user with Rest API and status code is 404") @Bug(id="MNT-16557") + @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, + description = "Verify user doesn't have permission to delete favorites of admin user with Rest API and status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) public void userIsNotAbleToDeleteFavoritesOfAdminUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); @@ -111,8 +118,10 @@ public class DeleteFavoritesSanityTests extends RestTest .assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } - @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify admin user doesn't have permission to delete favorites of another user with Rest API and status code is 404") @Bug(id="MNT-16557") + @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, + description = "Verify admin user doesn't have permission to delete favorites of another user with Rest API and status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) public void adminIsNotAbleToDeleteFavoritesOfAnotherUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) @@ -123,8 +132,10 @@ public class DeleteFavoritesSanityTests extends RestTest .assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify user gets status code 401 if authentication call fails") @Bug(id = "MNT-16904") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, + description = "Verify user gets status code 401 if authentication call fails") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) public void userIsNotAbleToDeleteFavoritesIfAuthenticationFails() throws JsonToModelConversionException, Exception { UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java index a9218e551..968453342 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java @@ -16,7 +16,6 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) public class GetFavoriteSanityTests extends RestTest { private UserModel adminUserModel; @@ -43,8 +42,9 @@ public class GetFavoriteSanityTests extends RestTest UserRole.SiteContributor); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets favorite site with Rest API and status code is 200") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, + description = "Verify Admin user gets favorite site with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) public void adminIsAbleToRetrieveFavoritesSite() throws JsonToModelConversionException, Exception { restClient.withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); @@ -54,8 +54,9 @@ public class GetFavoriteSanityTests extends RestTest restSiteModelsCollection.and().entriesListContains("guid",siteModel.getGuid()); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets favorite folder with Rest API and status code is 200") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, + description = "Verify Admin user gets favorite folder with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) public void adminIsAbleToRetrieveFavoritesFolder() throws JsonToModelConversionException, Exception { restClient.withCoreAPI().usingUser(adminUserModel).addFolderToFavorites(folderModel); @@ -66,8 +67,9 @@ public class GetFavoriteSanityTests extends RestTest } - @TestRail(section = { TestGroup.REST_API, - TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets favorite file with Rest API and status code is 200") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, + description = "Verify Admin user gets favorite file with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) public void adminIsAbleToRetrieveFavoritesFile() throws JsonToModelConversionException, Exception { restClient.withCoreAPI().usingUser(adminUserModel).addFileToFavorites(fileModel); @@ -77,8 +79,9 @@ public class GetFavoriteSanityTests extends RestTest restPersonFavoritesModelsCollection.and().entriesListContains("targetGuid", fileModel.getNodeRefWithoutVersion()); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Manager user gets favorite site with Rest API and status code is 200") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, + description = "Verify Manager user gets favorite site with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) public void managerIsAbleToRetrieveFavorite() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); @@ -89,8 +92,9 @@ public class GetFavoriteSanityTests extends RestTest restSiteModelsCollection.and().entriesListContains("guid",siteModel.getGuid()); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user gets favorite site with Rest API and status code is 200") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, + description = "Verify Collaborator user gets favorite site with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) public void collaboratorIsAbleToRetrieveFavorites() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) @@ -101,8 +105,9 @@ public class GetFavoriteSanityTests extends RestTest restSiteModelsCollection.and().entriesListContains("guid",siteModel.getGuid()); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Contributor user gets favorite site with Rest API and status code is 200") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, + description = "Verify Contributor user gets favorite site with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) public void contributorIsAbleToRetrieveFavorite() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); @@ -113,8 +118,9 @@ public class GetFavoriteSanityTests extends RestTest restSiteModelsCollection.and().entriesListContains("guid",siteModel.getGuid()); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Consumer user gets favorite site with Rest API and status code is 200") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, + description = "Verify Consumer user gets favorite site with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) public void consumerIsAbleToRetrieveFavorites() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); @@ -125,8 +131,9 @@ public class GetFavoriteSanityTests extends RestTest restSiteModelsCollection.and().entriesListContains("guid",siteModel.getGuid()); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify user doesn't get favorite site of another user with Rest API and status code is 404") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, + description = "Verify user doesn't get favorite site of another user with Rest API and status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) public void userIsNotAbleToRetrieveFavoriteSiteOfAnotherUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); @@ -137,8 +144,9 @@ public class GetFavoriteSanityTests extends RestTest .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator).getUsername())); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify user doesn't get favorite site of admin user with Rest API and status code is 404") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, + description = "Verify user doesn't get favorite site of admin user with Rest API and status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) public void userIsNotAbleToRetrieveFavoritesOfAdminUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) @@ -148,8 +156,9 @@ public class GetFavoriteSanityTests extends RestTest .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, adminUserModel.getUsername())); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify admin user doesn't get favorite site of another user with Rest API and status code is 404") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, + description = "Verify admin user doesn't get favorite site of another user with Rest API and status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) public void adminIsNotAbleToRetrieveFavoritesOfAnotherUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel).withCoreAPI() @@ -159,9 +168,10 @@ public class GetFavoriteSanityTests extends RestTest .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator).getUsername())); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify user gets status code 401 if authentication call fails") @Bug(id="MNT-16904") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, + description = "Verify user gets status code 401 if authentication call fails") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) public void userIsNotAbleToRetrieveFavoritesIfAuthenticationFails() throws JsonToModelConversionException, Exception { UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); @@ -170,5 +180,4 @@ public class GetFavoriteSanityTests extends RestTest .usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).getFavorite(siteModel.getGuid()); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); } - } diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesCoreTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesCoreTests.java index 7fca8f547..c75947d8c 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesCoreTests.java @@ -17,7 +17,6 @@ import org.testng.annotations.Test; /** * Created by Claudia Agache on 11/21/2016. */ -@Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) public class GetFavoritesCoreTests extends RestTest { private UserModel adminUserModel; @@ -46,8 +45,9 @@ public class GetFavoritesCoreTests extends RestTest UserRole.SiteContributor); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify User gets only favorites sites with Rest API and status code is 200") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify User gets only favorites sites with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) public void userIsAbleToRetrieveOnlyFavoritesSites() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); @@ -63,8 +63,9 @@ public class GetFavoritesCoreTests extends RestTest .and().entriesListDoesNotContain("targetGuid", firstFolderModel.getNodeRef()); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify User gets only favorites files with Rest API and status code is 200") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify User gets only favorites files with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) public void userIsAbleToRetrieveOnlyFavoritesFiles() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); @@ -80,8 +81,9 @@ public class GetFavoritesCoreTests extends RestTest .and().entriesListDoesNotContain("targetGuid", firstFolderModel.getNodeRef()); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify User gets only favorites folders with Rest API and status code is 200") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify User gets only favorites folders with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) public void userIsAbleToRetrieveOnlyFavoritesFolders() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); @@ -97,8 +99,9 @@ public class GetFavoritesCoreTests extends RestTest .and().entriesListDoesNotContain("targetGuid", firstFileModel.getNodeRefWithoutVersion()); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify User gets only favorites files or folders with Rest API and status code is 200") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify User gets only favorites files or folders with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) public void userIsAbleToRetrieveFavoritesFilesOrFolders() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); @@ -117,8 +120,9 @@ public class GetFavoritesCoreTests extends RestTest .and().entriesListDoesNotContain("targetGuid", firstSiteModel.getGuid()); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify User gets only favorites files or sites with Rest API and status code is 200") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify User gets only favorites files or sites with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) public void userIsAbleToRetrieveFavoritesFilesOrSites() throws Exception { restClient.authenticateUser(adminUserModel); @@ -137,8 +141,9 @@ public class GetFavoritesCoreTests extends RestTest .and().entriesListDoesNotContain("targetGuid", firstFolderModel.getNodeRef()); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify User gets only favorites folders or sites with Rest API and status code is 200") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify User gets only favorites folders or sites with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) public void userIsAbleToRetrieveFavoritesFoldersOrSites() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); @@ -157,8 +162,9 @@ public class GetFavoritesCoreTests extends RestTest .and().entriesListDoesNotContain("targetGuid", firstFileModel.getNodeRefWithoutVersion()); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify User gets all favorites with Rest API and status code is 200") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify User gets all favorites with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) public void userIsAbleToRetrieveAllFavorites() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); @@ -187,8 +193,9 @@ public class GetFavoritesCoreTests extends RestTest .and().entriesListDoesNotContain("targetGuid", secondFileModel.getNodeRefWithoutVersion()); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify request using invalid where parameter returns status 400") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify request using invalid where parameter returns status 400") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) public void getFavoritesUsingInvalidWhereParameter() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); @@ -202,8 +209,9 @@ public class GetFavoritesCoreTests extends RestTest .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_ARGUMENT, "WHERE query")); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify request for a user with no favorites returns status 200") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify request for a user with no favorites returns status 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) public void userHasNoFavorites() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); @@ -213,8 +221,9 @@ public class GetFavoritesCoreTests extends RestTest userFavorites.assertThat().entriesListIsEmpty().and().paginationField("totalItems").is("0"); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify User gets correct favorites after deleting a favorite") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify User gets correct favorites after deleting a favorite") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) public void checkFavoriteFolderIsRemoved() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); @@ -231,8 +240,9 @@ public class GetFavoritesCoreTests extends RestTest } @Bug(id="REPO-1642", description = "reproduced on 5.2.1 only, it works on 5.2.0") - @TestRail(section = { TestGroup.REST_API, - TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify request using personId that does not exist returns status 404") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify request using personId that does not exist returns status 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) public void checkFavoritesWhenPersonIdDoesNotExist() throws Exception { UserModel someUser = new UserModel("someUser", DataUser.PASSWORD); diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java index 7fef66075..0cf07c308 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java @@ -15,7 +15,6 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) public class GetFavoritesSanityTests extends RestTest { private UserModel adminUserModel; @@ -47,8 +46,9 @@ public class GetFavoritesSanityTests extends RestTest UserRole.SiteContributor); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets favorites sites with Rest API and status code is 200") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, + description = "Verify Admin user gets favorites sites with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) public void adminIsAbleToRetrieveFavoritesSites() throws JsonToModelConversionException, Exception { restClient.withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(firstSiteModel); @@ -60,8 +60,9 @@ public class GetFavoritesSanityTests extends RestTest .and().entriesListContains("targetGuid", secondSiteModel.getGuid()); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets favorites folders with Rest API and status code is 200") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, + description = "Verify Admin user gets favorites folders with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) public void adminIsAbleToRetrieveFavoritesFolders() throws JsonToModelConversionException, Exception { restClient.withCoreAPI().usingUser(adminUserModel).addFolderToFavorites(firstFolderModel); @@ -73,8 +74,9 @@ public class GetFavoritesSanityTests extends RestTest .and().entriesListContains("targetGuid", secondFolderModel.getNodeRef()); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets favorites files with Rest API and status code is 200") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, + description = "Verify Admin user gets favorites files with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) public void adminIsAbleToRetrieveFavoritesFiles() throws JsonToModelConversionException, Exception { restClient.withCoreAPI().usingUser(adminUserModel).addFileToFavorites(firstFileModel); @@ -86,8 +88,9 @@ public class GetFavoritesSanityTests extends RestTest .and().entriesListContains("targetGuid", secondFileModel.getNodeRefWithoutVersion()); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Manager user gets favorites with Rest API and status code is 200") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, + description = "Verify Manager user gets favorites with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) public void managerIsAbleToRetrieveFavorites() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); @@ -100,8 +103,9 @@ public class GetFavoritesSanityTests extends RestTest .assertThat().entriesListContains("targetGuid", secondSiteModel.getGuid()); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user gets favorites with Rest API and status code is 200") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, + description = "Verify Collaborator user gets favorites with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) public void collaboratorIsAbleToRetrieveFavorites() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) @@ -114,8 +118,9 @@ public class GetFavoritesSanityTests extends RestTest .and().entriesListContains("targetGuid", secondSiteModel.getGuid()); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Contributor user gets favorites with Rest API and status code is 200") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, + description = "Verify Contributor user gets favorites with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) public void contributorIsAbleToRetrieveFavorites() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) @@ -128,8 +133,9 @@ public class GetFavoritesSanityTests extends RestTest .entriesListContains("targetGuid", secondSiteModel.getGuid()); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Consumer user gets favorites with Rest API and status code is 200") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, + description = "Verify Consumer user gets favorites with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) public void consumerIsAbleToRetrieveFavorites() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) @@ -142,8 +148,9 @@ public class GetFavoritesSanityTests extends RestTest .assertThat().entriesListContains("targetGuid", secondSiteModel.getGuid()); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify user doesn't have permission to get favorites of another user with Rest API and status code is 404") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, + description = "Verify user doesn't have permission to get favorites of another user with Rest API and status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) public void userIsNotAbleToRetrieveFavoritesOfAnotherUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) @@ -152,8 +159,9 @@ public class GetFavoritesSanityTests extends RestTest .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator).getUsername())); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify user doesn't have permission to get favorites of admin user with Rest API and status code is 200") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, + description = "Verify user doesn't have permission to get favorites of admin user with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) public void userIsNotAbleToRetrieveFavoritesOfAdminUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI() @@ -162,8 +170,9 @@ public class GetFavoritesSanityTests extends RestTest .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, adminUserModel.getUsername())); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify admin user doesn't have permission to get favorites of another user with Rest API and status code is 200") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, + description = "Verify admin user doesn't have permission to get favorites of another user with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) public void adminIsNotAbleToRetrieveFavoritesOfAnotherUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) @@ -172,9 +181,10 @@ public class GetFavoritesSanityTests extends RestTest .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator).getUsername())); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify user gets status code 401 if authentication call fails") @Bug(id="MNT-16904") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, + description = "Verify user gets status code 401 if authentication call fails") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) public void userIsNotAbleToRetrieveFavoritesIfAuthenticationFails() throws JsonToModelConversionException, Exception { UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java index 28580e5e2..b7ffab041 100644 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java @@ -10,7 +10,6 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS }) public class RestGetNetworkForPersonSanityTests extends RestTest { private UserModel adminUserModel; @@ -28,10 +27,9 @@ public class RestGetNetworkForPersonSanityTests extends RestTest } @Bug(id = "MNT-16904") - @Test(groups = TestGroup.COMMENTS) - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, - executionType = ExecutionType.SANITY, - description = "Verify non existing user gets another exisiting network with Rest API and checks the forbidden status") + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, + description = "Verify non existing user gets another exisiting network with Rest API and checks the forbidden status") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.COMMENTS }) public void nonExistingTenantUserIsNotAuthorizedToRequest() throws Exception { UserModel tenantUser = new UserModel("nonexisting", "password"); @@ -41,32 +39,29 @@ public class RestGetNetworkForPersonSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } - @Test(groups = TestGroup.COMMENTS) - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, - executionType = ExecutionType.SANITY, - description = "Verify tenant admin user gets specific network with Rest API and response is not empty") + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, + description = "Verify tenant admin user gets specific network with Rest API and response is not empty") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.COMMENTS }) public void adminTenantChecksIfNetworkIsPresent() throws Exception { restClient.authenticateUser(adminTenantUser); restClient.withCoreAPI().usingUser(adminTenantUser).getNetwork(); restClient.assertStatusCodeIs(HttpStatus.OK); } - - @Test(groups = TestGroup.COMMENTS) - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, - executionType = ExecutionType.SANITY, - description = "Verify tenant user is not authorized to check network of admin user with Rest API and checks the forbidden status") + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, + description = "Verify tenant user is not authorized to check network of admin user with Rest API and checks the forbidden status") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.COMMENTS }) public void tenantUserIsNotAuthorizedToCheckNetworkOfAdminUser() throws Exception { restClient.authenticateUser(tenantUser); restClient.withCoreAPI().usingAuthUser().getNetwork(adminTenantUser); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); } - - @Test(groups = TestGroup.COMMENTS) - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, - executionType = ExecutionType.SANITY, - description = "Verify admin tenant user is not authorized to check network of another user with Rest API and checks the forbidden status") + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, + description = "Verify admin tenant user is not authorized to check network of another user with Rest API and checks the forbidden status") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.COMMENTS }) public void adminTenantUserIsNotAuthorizedToCheckNetworkOfAnotherUser() throws Exception { UserModel secondAdminTenantUser = UserModel.getAdminTenantUser(); diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkTest.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkTest.java index bc658edc0..ec00565fa 100644 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkTest.java +++ b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkTest.java @@ -15,7 +15,6 @@ import org.testng.annotations.Test; /** * Created by Cristina Axinte on 9/26/2016. */ -@Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS }) public class RestGetNetworkTest extends RestTest { UserModel adminTenantUser; @@ -38,9 +37,9 @@ public class RestGetNetworkTest extends RestTest } @Bug(id = "MNT-16904") - @Test(groups = TestGroup.COMMENTS) - @TestRail(section = { TestGroup.REST_API, - TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify non existing user gets another exisiting network with Rest API and checks the forbidden status") + @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, + description = "Verify non existing user gets another exisiting network with Rest API and checks the forbidden status") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.COMMENTS}) public void nonExistingTenantUserIsNotAuthorizedToRequest() throws Exception { UserModel tenantUser = new UserModel("nonexisting", "password"); @@ -50,9 +49,9 @@ public class RestGetNetworkTest extends RestTest restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } - @Test(groups = TestGroup.COMMENTS) - @TestRail(section = { TestGroup.REST_API, - TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify tenant admin user gets specific network with Rest API and response is not empty") + @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, + description = "Verify tenant admin user gets specific network with Rest API and response is not empty") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.COMMENTS }) public void adminTenantChecksIfNetworkIsPresent() throws Exception { restClient.authenticateUser(adminTenantUser); @@ -60,16 +59,18 @@ public class RestGetNetworkTest extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.NETWORKS }, description = "Verify tenant admin user gets specific network with Rest API and checks response parameters are correct") + @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, + description = "Verify tenant admin user gets specific network with Rest API and checks response parameters are correct") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS }) public void adminTenantChecksNetworkParamsAreCorrect() throws Exception { restClient.authenticateUser(adminTenantUser); restClient.withCoreAPI().usingNetworks().getNetwork().assertNetworkHasName(adminTenantUser).assertNetworkIsEnabled(); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.NETWORKS }, description = "Verify tenant admin user gets non exisiting network with Rest API and checks the not found status") + @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, + description = "Verify tenant admin user gets non existing network with Rest API and checks the not found status") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS }) public void adminTenantChecksIfNonExistingNetworkIsNotFound() throws Exception { restClient.authenticateUser(adminTenantUser); @@ -77,8 +78,9 @@ public class RestGetNetworkTest extends RestTest restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.NETWORKS }, description = "Verify tenant admin user gets another exisiting network with Rest API and checks the forbidden status") + @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, + description = "Verify tenant admin user gets another existing network with Rest API and checks the forbidden status") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS }) public void adminTenantChecksIfAnotherExistingNetworkIsForbidden() throws Exception { restClient.authenticateUser(adminTenantUser); @@ -86,7 +88,9 @@ public class RestGetNetworkTest extends RestTest restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); } - @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, description = "Verify any tenant user gets its network with Rest API and response is not empty") + @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, + description = "Verify any tenant user gets its network with Rest API and response is not empty") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS }) public void userTenantChecksIfNetworkIsPresent() throws Exception { restClient.authenticateUser(tenantUser); @@ -94,16 +98,18 @@ public class RestGetNetworkTest extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.NETWORKS }, description = "Verify any tenant user gets specific network with Rest API and checks response parameters are correct") + @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, + description = "Verify any tenant user gets specific network with Rest API and checks response parameters are correct") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS }) public void userTenantChecksNetworkParamsAreCorrect() throws Exception { restClient.authenticateUser(tenantUser); restClient.withCoreAPI().usingNetworks().getNetwork(adminTenantUser).assertNetworkHasName(adminTenantUser).assertNetworkIsEnabled(); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.NETWORKS }, description = "Verify any tenant user gets non exisiting network with Rest API and checks the not found status") + @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, + description = "Verify any tenant user gets non existing network with Rest API and checks the not found status") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS }) public void userTenantChecksIfNonExistingNetworkIsNotFound() throws Exception { restClient.authenticateUser(tenantUser); @@ -111,9 +117,9 @@ public class RestGetNetworkTest extends RestTest restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); } - @Test(groups = TestGroup.COMMENTS) - @TestRail(section = { TestGroup.REST_API, - TestGroup.NETWORKS }, description = "Verify any tenant user gets another exisiting network with Rest API and checks the forbidden status") + @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, + description = "Verify any tenant user gets another existing network with Rest API and checks the forbidden status") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.COMMENTS }) public void userTenantChecksIfAnotherExistingNetworkIsForbidden() throws Exception { restClient.authenticateUser(tenantUser); @@ -121,9 +127,9 @@ public class RestGetNetworkTest extends RestTest restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); } - @Test(groups = TestGroup.COMMENTS) - @TestRail(section = { TestGroup.REST_API, - TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify manager tenant user gets its network with Rest API and response is not empty") + @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, + description = "Verify manager tenant user gets its network with Rest API and response is not empty") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.COMMENTS }) public void tenantManagerUserChecksIfNetworkIsPresent() throws Exception { UserModel managerTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("manTenant"); @@ -134,9 +140,9 @@ public class RestGetNetworkTest extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); } - @Test(groups = TestGroup.COMMENTS) - @TestRail(section = { TestGroup.REST_API, - TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify collaborator tenant user gets its network with Rest API and response is not empty") + @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, + description = "Verify collaborator tenant user gets its network with Rest API and response is not empty") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.COMMENTS }) public void tenantCollaboratorUserChecksIfNetworkIsPresent() throws Exception { UserModel collaboratorTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("colTenant"); @@ -147,9 +153,9 @@ public class RestGetNetworkTest extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); } - @Test(groups = TestGroup.COMMENTS) - @TestRail(section = { TestGroup.REST_API, - TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify consumer tenant user gets its network with Rest API and response is not empty") + @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, + description = "Verify consumer tenant user gets its network with Rest API and response is not empty") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.COMMENTS }) public void tenantConsumerUserChecksIfNetworkIsPresent() throws Exception { UserModel consumerTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("consTenant"); @@ -160,9 +166,9 @@ public class RestGetNetworkTest extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); } - @Test(groups = TestGroup.COMMENTS) - @TestRail(section = { TestGroup.REST_API, - TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify contributor tenant user gets its network with Rest API and response is not empty") + @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, + description = "Verify contributor tenant user gets its network with Rest API and response is not empty") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.COMMENTS }) public void tenantContributorUserChecksIfItsNetworkIsPresent() throws Exception { UserModel contributorTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("contTenant"); diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonSanityTests.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonSanityTests.java index c19dbe4c9..c22cf8901 100644 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonSanityTests.java @@ -10,7 +10,6 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) public class RestGetNetworksForPersonSanityTests extends RestTest { private UserModel adminUserModel; @@ -28,10 +27,9 @@ public class RestGetNetworksForPersonSanityTests extends RestTest } @Bug(id = "MNT-16904") - @Test(groups = {TestGroup.COMMENTS, TestGroup.NETWORKS}) - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, - executionType = ExecutionType.SANITY, - description = "Verify non existing user gets another exisiting network with Rest API and checks the forbidden status") + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, + description = "Verify non existing user gets another exisiting network with Rest API and checks the forbidden status") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY, TestGroup.COMMENTS, TestGroup.NETWORKS }) public void nonExistingTenantUserIsNotAuthorizedToRequest() throws Exception { UserModel tenantUser = new UserModel("nonexisting", "password"); @@ -41,32 +39,29 @@ public class RestGetNetworksForPersonSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } - @Test(groups = {TestGroup.COMMENTS, TestGroup.NETWORKS}) - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, - executionType = ExecutionType.SANITY, - description = "Verify tenant admin user gets specific network with Rest API and response is not empty") + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, + description = "Verify tenant admin user gets specific network with Rest API and response is not empty") + @Test(groups = {TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY, TestGroup.COMMENTS, TestGroup.NETWORKS }) public void adminTenantChecksIfNetworkIsPresent() throws Exception { restClient.authenticateUser(adminTenantUser); restClient.withCoreAPI().usingAuthUser().getNetworks(); restClient.assertStatusCodeIs(HttpStatus.OK); } - - @Test(groups = {TestGroup.COMMENTS, TestGroup.NETWORKS}) - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, - executionType = ExecutionType.SANITY, - description = "Verify tenant user is not authorized to check network of admin user with Rest API and checks the forbidden status") + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, + description = "Verify tenant user is not authorized to check network of admin user with Rest API and checks the forbidden status") + @Test(groups = {TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY, TestGroup.COMMENTS, TestGroup.NETWORKS }) public void tenantUserIsNotAuthorizedToCheckNetworkOfAdminUser() throws Exception { restClient.authenticateUser(tenantUser); restClient.withCoreAPI().usingAuthUser().getNetworks(adminTenantUser); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); } - - @Test(groups = {TestGroup.COMMENTS, TestGroup.NETWORKS}) - @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, - executionType = ExecutionType.SANITY, - description = "Verify admin tenant user is not authorized to check network of another user with Rest API and checks the forbidden status") + + @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, + description = "Verify admin tenant user is not authorized to check network of another user with Rest API and checks the forbidden status") + @Test(groups = {TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY, TestGroup.COMMENTS, TestGroup.NETWORKS }) public void adminTenantUserIsNotAuthorizedToCheckNetworkOfAnotherUser() throws Exception { UserModel secondAdminTenantUser = UserModel.getAdminTenantUser(); From e2cbe60bbe1c3c875bb19df97c7475363bbf56f9 Mon Sep 17 00:00:00 2001 From: mionescu Date: Mon, 12 Dec 2016 10:34:57 +0200 Subject: [PATCH 0753/1491] test: updated tests from 'people' package (@Test) --- .../people/AddFavoriteSiteSanityTests.java | 17 +- .../AddSiteMembershipRequestCoreTests.java | 52 ++---- .../AddSiteMembershipRequestSanityTests.java | 93 +++++----- .../people/DeleteFavoriteSiteCoreTests.java | 61 ++++--- .../people/DeleteFavoriteSiteSanityTests.java | 37 ++-- .../people/DeleteSiteMemberCoreTests.java | 165 +++++++++-------- .../people/DeleteSiteMemberSanityTests.java | 82 ++++----- .../DeleteSiteMembershipRequestCoreTests.java | 82 ++++----- ...eleteSiteMembershipRequestSanityTests.java | 168 +++++++----------- .../rest/people/GetFavoriteSiteCoreTests.java | 29 ++- .../people/GetFavoriteSiteSanityTests.java | 60 +++---- .../people/GetFavoriteSitesSanityTests.java | 66 +++---- .../GetPeopleActivitiesSanityTests.java | 64 +++---- .../GetPeoplePreferenceSanityTests.java | 64 +++---- .../people/GetPeoplePreferencesCoreTests.java | 35 ++-- .../GetPeoplePreferencesSanityTests.java | 69 ++++--- .../rest/people/GetPeopleSanityTests.java | 101 ++++------- .../people/GetSiteMembershipCoreTests.java | 111 +++++------- ...GetSiteMembershipInformationCoreTests.java | 136 +++++--------- .../GetSiteMembershipRequestCoreTests.java | 130 +++++--------- .../GetSiteMembershipRequestSanityTests.java | 80 ++++----- .../GetSiteMembershipRequestsCoreTests.java | 32 ++-- .../GetSiteMembershipRequestsSanityTests.java | 93 ++++------ .../people/GetSiteMembershipSanityTests.java | 99 ++++------- ...SitesMembershipInformationSanityTests.java | 95 ++++------ .../UpdateSiteMembershipRequestCoreTests.java | 135 ++++++-------- ...pdateSiteMembershipRequestSanityTests.java | 136 +++++--------- 27 files changed, 927 insertions(+), 1365 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteSanityTests.java index 3cf2d770c..7fb4c5086 100644 --- a/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteSanityTests.java @@ -14,7 +14,6 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) public class AddFavoriteSiteSanityTests extends RestTest { UserModel userModel; @@ -26,9 +25,10 @@ public class AddFavoriteSiteSanityTests extends RestTest public void dataPreparation() throws Exception { userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); } + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user add a favorite site with Rest API and response is successful (201)") public void managerUserAddFavoriteSiteWithSuccess() throws Exception { @@ -38,12 +38,13 @@ public class AddFavoriteSiteSanityTests extends RestTest restFavoriteSiteModel = restClient.authenticateUser(managerUser).withCoreAPI().usingUser(managerUser).addFavoriteSite(siteModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); restFavoriteSiteModel.assertThat().field("id").is(siteModel.getId()); - + restClient.withCoreAPI().usingUser(managerUser).addFavoriteSite(siteModel); - restClient.assertStatusCodeIs(HttpStatus.CONFLICT); - restClient.assertLastError().containsSummary(String.format("%s is already a favourite site", siteModel.getId())); + restClient.assertStatusCodeIs(HttpStatus.CONFLICT); + restClient.assertLastError().containsSummary(String.format("%s is already a favourite site", siteModel.getId())); } + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify collaborator user add a favorite site with Rest API and response is successful (201)") public void collaboratorUserAddFavoriteSiteWithSuccess() throws Exception { @@ -55,17 +56,19 @@ public class AddFavoriteSiteSanityTests extends RestTest restFavoriteSiteModel.assertThat().field("id").is(siteModel.getId()); } + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify contributor user add a favorite site with Rest API and response is successful (201)") public void contributorUserAddFavoriteSiteWithSuccess() throws Exception { UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(contributorUser, siteModel, UserRole.SiteContributor); - restFavoriteSiteModel = restClient.authenticateUser(contributorUser).withCoreAPI().usingAuthUser().addFavoriteSite(siteModel); + restFavoriteSiteModel = restClient.authenticateUser(contributorUser).withCoreAPI().usingAuthUser().addFavoriteSite(siteModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); restFavoriteSiteModel.assertThat().field("id").is(siteModel.getId()); } + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify consumer user add a favorite site with Rest API and response is successful (201)") public void consumerUserAddFavoriteSiteWithSuccess() throws Exception { @@ -77,6 +80,7 @@ public class AddFavoriteSiteSanityTests extends RestTest restFavoriteSiteModel.assertThat().field("id").is(siteModel.getId()); } + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify admin user add a favorite site with Rest API and response is successful (201)") public void adminUserAddFavoriteSiteWithSuccess() throws Exception { @@ -87,6 +91,7 @@ public class AddFavoriteSiteSanityTests extends RestTest restFavoriteSiteModel.assertThat().field("id").is(siteModel.getId()); } + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) @Bug(id = "MNT-16904") @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify a manager user is NOT Authorized to add a favorite site with Rest API when authentication fails (401)") public void managerUserNotAuthorizedFailsToAddFavoriteSite() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestCoreTests.java b/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestCoreTests.java index ace45b340..c0fa212c0 100644 --- a/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestCoreTests.java @@ -14,14 +14,13 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) public class AddSiteMembershipRequestCoreTests extends RestTest { private UserModel adminUser; private UserModel newMember; private SiteModel siteModel; - @BeforeClass(alwaysRun=true) + @BeforeClass(alwaysRun = true) public void dataPreparation() throws DataPreparationException { adminUser = dataUser.getAdminUser(); @@ -34,68 +33,55 @@ public class AddSiteMembershipRequestCoreTests extends RestTest newMember = dataUser.createRandomTestUser(); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify addSiteMembershipRequest Rest API status code is 400 for a user that has already been invited") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify addSiteMembershipRequest Rest API status code is 400 for a user that has already been invited") public void addSiteMembershipRequestStatusCodeIs400ReceivedForAUserThatIsAlreadyInvited() throws Exception { dataUser.addUserToSite(newMember, siteModel, UserRole.SiteContributor); - restClient.authenticateUser(newMember) - .withCoreAPI() - .usingMe() - .addSiteMembershipRequest(siteModel); + restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); restClient.assertLastError().containsSummary(String.format(RestErrorModel.ALREADY_Site_MEMBER, newMember.getUsername(), siteModel.getId())); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify addSiteMembershipRequest Rest API status code is 404 for a user that does not exist") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify addSiteMembershipRequest Rest API status code is 404 for a user that does not exist") public void addSiteMembershipRequestStatusCodeIs404ReceivedForAUserThatDoesNotExist() throws Exception { - restClient.authenticateUser(newMember) - .withCoreAPI() - .usingUser(new UserModel("invalidUser", "password")).addSiteMembershipRequest(siteModel); + restClient.authenticateUser(newMember).withCoreAPI().usingUser(new UserModel("invalidUser", "password")).addSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); restClient.assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidUser")); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify addSiteMembershipRequest Rest API status code is 404 for a site that does not exist") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify addSiteMembershipRequest Rest API status code is 404 for a site that does not exist") public void addSiteMembershipRequestStatusCodeIs404ReceivedForASiteThatDoesNotExist() throws Exception { - restClient.authenticateUser(newMember) - .withCoreAPI() - .usingMe().addSiteMembershipRequest(new SiteModel("invalidSiteID")); + restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest(new SiteModel("invalidSiteID")); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); restClient.assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, newMember.getUsername(), "invalidSiteID")); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify addSiteMembershipRequest Rest API status code is 400 for empty request body") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify addSiteMembershipRequest Rest API status code is 400 for empty request body") public void addSiteMembershipRequestStatusCodeIs400ForEmptyRequestBody() throws Exception { - restClient.authenticateUser(newMember) - .withCoreAPI() - .usingMe().addSiteMembershipRequest(""); + restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest(""); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify addSiteMembershipRequest Rest API status code is 201 for request with empty message") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify addSiteMembershipRequest Rest API status code is 201 for request with empty message") public void addSiteMembershipRequestStatusCodeIs201ForRequestWithEmptyMessage() throws Exception { - restClient.authenticateUser(newMember) - .withCoreAPI() - .usingMe().addSiteMembershipRequest("", siteModel, "New request"); + restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest("", siteModel, "New request"); restClient.assertStatusCodeIs(HttpStatus.CREATED); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify addSiteMembershipRequest Rest API status code is 201 for request with empty title") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify addSiteMembershipRequest Rest API status code is 201 for request with empty title") public void addSiteMembershipRequestStatusCodeIs201ForRequestWithEmptyTitle() throws Exception { - restClient.authenticateUser(newMember) - .withCoreAPI() - .usingMe().addSiteMembershipRequest("Please accept me", siteModel, ""); + restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest("Please accept me", siteModel, ""); restClient.assertStatusCodeIs(HttpStatus.CREATED); } } diff --git a/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java index d392f9ab9..582e9c27d 100644 --- a/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java @@ -21,9 +21,8 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) public class AddSiteMembershipRequestSanityTests extends RestTest -{ +{ @Autowired DataUser dataUser; @@ -38,93 +37,81 @@ public class AddSiteMembershipRequestSanityTests extends RestTest private UserModel newMember; private RestSiteMembershipRequestModel requestModel; - @BeforeClass(alwaysRun=true) + @BeforeClass(alwaysRun = true) public void dataPreparation() throws DataPreparationException { adminUser = dataUser.getAdminUser(); siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); } @BeforeMethod - public void setUp() throws DataPreparationException { + public void setUp() throws DataPreparationException + { newMember = dataUser.createRandomTestUser(); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, description = "Verify site manager is able to create new site membership request") - @Bug(id="MNT-16557") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site manager is able to create new site membership request") + @Bug(id = "MNT-16557") public void siteManagerIsAbleToCreateSiteMembershipRequest() throws JsonToModelConversionException, Exception { - requestModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingUser(newMember).addSiteMembershipRequest(siteModel); + requestModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingUser(newMember) + .addSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); - requestModel.assertThat().field("id").isNotEmpty() - .assertThat().field("site").isNotEmpty(); + requestModel.assertThat().field("id").isNotEmpty().assertThat().field("site").isNotEmpty(); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify site collaborator is able to create new site membership request") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site collaborator is able to create new site membership request") @Bug(id = "MNT-16557") public void siteCollaboatorIsAbleToCreateSiteMembershipRequest() throws JsonToModelConversionException, Exception { - requestModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingUser(newMember).addSiteMembershipRequest(siteModel); + requestModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingUser(newMember) + .addSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); - requestModel.assertThat().field("id").isNotEmpty() - .assertThat().field("site").isNotEmpty(); + requestModel.assertThat().field("id").isNotEmpty().assertThat().field("site").isNotEmpty(); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify site contributor is able to create new site membership request") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site contributor is able to create new site membership request") @Bug(id = "MNT-16557") public void siteContributorIsAbleToCreateSiteMembershipRequest() throws JsonToModelConversionException, Exception { - requestModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) - .withCoreAPI().usingUser(newMember).addSiteMembershipRequest(siteModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - requestModel.assertThat().field("id").isNotEmpty() - .assertThat().field("site").isNotEmpty(); + requestModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingUser(newMember) + .addSiteMembershipRequest(siteModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + requestModel.assertThat().field("id").isNotEmpty().assertThat().field("site").isNotEmpty(); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify site consumer is able to create new site membership request") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site consumer is able to create new site membership request") @Bug(id = "MNT-16557") public void siteConsumerIsAbleToCreateSiteMembershipRequest() throws JsonToModelConversionException, Exception { - requestModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .withCoreAPI().usingUser(newMember).addSiteMembershipRequest(siteModel); + requestModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingUser(newMember) + .addSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); - requestModel.assertThat().field("id").isNotEmpty() - .assertThat().field("site").isNotEmpty(); + requestModel.assertThat().field("id").isNotEmpty().assertThat().field("site").isNotEmpty(); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify admin user is able to create new site membership request") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify admin user is able to create new site membership request") @Bug(id = "MNT-16557") public void adminUserIsAbleToCreateSiteMembershipRequest() throws JsonToModelConversionException, Exception { - requestModel = restClient.authenticateUser(adminUser) - .withCoreAPI() - .usingUser(newMember).addSiteMembershipRequest(siteModel); + requestModel = restClient.authenticateUser(adminUser).withCoreAPI().usingUser(newMember).addSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); - requestModel.assertThat().field("id").isNotEmpty() - .assertThat().field("site").isNotEmpty(); + requestModel.assertThat().field("id").isNotEmpty().assertThat().field("site").isNotEmpty(); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify unauthenticated user is not able to create new site membership request") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to create new site membership request") @Bug(id = "MNT-16557") public void unauthenticatedUserIsNotAbleToCreateSiteMembershipRequest() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(new UserModel("random user", "random password")) - .withCoreAPI() - .usingUser(newMember).addSiteMembershipRequest(siteModel); + restClient.authenticateUser(new UserModel("random user", "random password")).withCoreAPI().usingUser(newMember).addSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteCoreTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteCoreTests.java index 00add0c98..bf9b1ba23 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteCoreTests.java @@ -14,7 +14,6 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) public class DeleteFavoriteSiteCoreTests extends RestTest { UserModel userModel; @@ -29,9 +28,9 @@ public class DeleteFavoriteSiteCoreTests extends RestTest siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); adminUserModel = dataUser.getAdminUser(); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify user removes a site from favorites using '-me-' in place of personId with Rest API and response is successful (204)") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user removes a site from favorites using '-me-' in place of personId with Rest API and response is successful (204)") public void removeFavoriteSiteWithSuccessUsingMeAsPersonId() throws Exception { restClient.authenticateUser(adminUserModel); @@ -41,18 +40,18 @@ public class DeleteFavoriteSiteCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } - @Bug(id="REPO-1642", description = "reproduced on 5.2.1 only, it works on 5.2.0") - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify inexistent user is not able to remove a site from favorites and response is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @Bug(id = "REPO-1642", description = "reproduced on 5.2.1 only, it works on 5.2.0") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify inexistent user is not able to remove a site from favorites and response is 404") public void inexistentUserIsNotAbleToRemoveFavoriteSite() throws Exception { UserModel inexistentUser = new UserModel("inexistenUser", "password"); restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(inexistentUser).removeFavoriteSite(siteModel); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "inexistenUser")); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify user is not able to remove from favorites a site with inexistent id and response is 404") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove from favorites a site with inexistent id and response is 404") public void userIsNotAbleToRemoveFavoriteSiteWithInexistentId() throws Exception { SiteModel inexistentSite = new SiteModel("inexistentSite"); @@ -60,9 +59,9 @@ public class DeleteFavoriteSiteCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, adminUserModel.getUsername(), inexistentSite.getTitle())); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify manager user removes a site from its favorites and adds it again and response is successful (204)") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify manager user removes a site from its favorites and adds it again and response is successful (204)") public void managerUserRemovesFavoriteSiteAndAddItAgain() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -74,9 +73,9 @@ public class DeleteFavoriteSiteCoreTests extends RestTest restClient.withCoreAPI().usingUser(managerUser).addFavoriteSite(siteModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify manager user removes a site from its favorite sites list with Rest API and response is successful (204)") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify manager user removes a site from its favorite sites list with Rest API and response is successful (204)") public void managerUserRemovesFavoriteSiteWithSuccess() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -87,41 +86,41 @@ public class DeleteFavoriteSiteCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); restClient.withCoreAPI().usingAuthUser().getFavorites().assertThat().entriesListDoesNotContain("id", siteModel.getId()); } - - @TestRail(section={TestGroup.REST_API, TestGroup.PEOPLE}, executionType= ExecutionType.REGRESSION, - description= "Verify uninvited user can delete favorite public site and response is 204") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify uninvited user can delete favorite public site and response is 204") public void uninvitedUserCanDeleteFavoritePublicSite() throws Exception - { + { SiteModel publicSiteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); restClient.authenticateUser(userModel).withCoreAPI().usingUser(userModel).addFavoriteSite(publicSiteModel); - + restClient.withCoreAPI().usingAuthUser().removeFavoriteSite(publicSiteModel); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); restClient.withCoreAPI().usingAuthUser().getFavoriteSites().assertThat().entriesListDoesNotContain("id", publicSiteModel.getId()); } - - @TestRail(section={TestGroup.REST_API, TestGroup.PEOPLE}, executionType= ExecutionType.REGRESSION, - description= "Verify uninvited user can delete favorite moderated site and response is 204") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify uninvited user can delete favorite moderated site and response is 204") public void uninvitedUserCanDeleteFavoriteModeratedSite() throws Exception - { + { SiteModel moderatedSiteModel = dataSite.usingUser(adminUserModel).createModeratedRandomSite(); restClient.authenticateUser(userModel).withCoreAPI().usingUser(userModel).addFavoriteSite(moderatedSiteModel); - + restClient.withCoreAPI().usingAuthUser().removeFavoriteSite(moderatedSiteModel); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); restClient.withCoreAPI().usingAuthUser().getFavoriteSites().assertThat().entriesListDoesNotContain("id", moderatedSiteModel.getId()); } - - @TestRail(section={TestGroup.REST_API, TestGroup.PEOPLE}, executionType= ExecutionType.REGRESSION, - description= "Verify user can delete favorite private site and response is 204") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user can delete favorite private site and response is 204") public void userCanDeleteFavoritePrivateSite() throws Exception { SiteModel privateSiteModel = dataSite.usingUser(userModel).createPrivateRandomSite(); restClient.authenticateUser(userModel).withCoreAPI().usingUser(userModel).addFavoriteSite(privateSiteModel); - + restClient.withCoreAPI().usingAuthUser().removeFavoriteSite(privateSiteModel); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); restClient.withCoreAPI().usingAuthUser().getFavoriteSites().assertThat().entriesListDoesNotContain("id", privateSiteModel.getId()); } - + } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java index 04380df48..538e40443 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java @@ -14,7 +14,7 @@ import org.testng.annotations.Test; /** * @author Cristina Axinte */ -@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + public class DeleteFavoriteSiteSanityTests extends RestTest { UserModel userModel; @@ -30,9 +30,8 @@ public class DeleteFavoriteSiteSanityTests extends RestTest siteModel2 = dataSite.usingUser(userModel).createPublicRandomSite(); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify manager user removes a site from its favorite sites list with Rest API and response is successful (204)") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user removes a site from its favorite sites list with Rest API and response is successful (204)") public void managerUserRemovesFavoriteSiteWithSuccess() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -44,9 +43,8 @@ public class DeleteFavoriteSiteSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify collaborator user removes a site from its favorite sites list with Rest API and response is successful (204)") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify collaborator user removes a site from its favorite sites list with Rest API and response is successful (204)") public void collaboratorUserRemovesFavoriteSiteWithSuccess() throws Exception { UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); @@ -58,9 +56,8 @@ public class DeleteFavoriteSiteSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify contributor user removes a site from its favorite sites list with Rest API and response is successful (204)") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify contributor user removes a site from its favorite sites list with Rest API and response is successful (204)") public void contributorUserRemovesFavoriteSiteWithSuccess() throws Exception { UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); @@ -72,9 +69,8 @@ public class DeleteFavoriteSiteSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify consumer user removes a site from its favorite sites list with Rest API and response is successful (204)") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify consumer user removes a site from its favorite sites list with Rest API and response is successful (204)") public void consumerUserRemovesFavoriteSiteWithSuccess() throws Exception { UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -86,9 +82,8 @@ public class DeleteFavoriteSiteSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify admin user removes a site from any user's favorite sites list with Rest API and response is successful (204)") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify admin user removes a site from any user's favorite sites list with Rest API and response is successful (204)") public void adminUserRemovesAnyFavoriteSiteWithSuccess() throws Exception { UserModel adminUser = dataUser.getAdminUser(); @@ -100,9 +95,8 @@ public class DeleteFavoriteSiteSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify a user removes a site from another user's favorite sites list with Rest API and response is permission denied (403)") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify a user removes a site from another user's favorite sites list with Rest API and response is permission denied (403)") public void userUserRemovesAnotherUserFavoriteSiteWithSuccess() throws Exception { UserModel userAuth = dataUser.usingAdmin().createRandomTestUser(); @@ -114,10 +108,9 @@ public class DeleteFavoriteSiteSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) @Bug(id = "MNT-16904") - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify manager user is NOT Authorized to remove a site from its favorite sites list with Rest API when authentication fails (401)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized to remove a site from its favorite sites list with Rest API when authentication fails (401)") public void managerUserNotAuthorizedFailsToRemoveFavoriteSite() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberCoreTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberCoreTests.java index 397dfdcd2..536dd36b3 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberCoreTests.java @@ -12,7 +12,6 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) public class DeleteSiteMemberCoreTests extends RestTest { private UserModel userModel; @@ -37,147 +36,156 @@ public class DeleteSiteMemberCoreTests extends RestTest moderatedSiteModel = dataSite.usingUser(adminUserModel).createModeratedRandomSite(); privateSiteModel = dataSite.usingUser(adminUserModel).createPrivateRandomSite(); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify user removes a site member using '-me-' in place of personId and response is successful (204)") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user removes a site member using '-me-' in place of personId and response is successful (204)") public void removeSiteMemberWithSuccessUsingMeAsPersonId() throws Exception - { + { restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(userModel); restClient.authenticateUser(userModel).withCoreAPI().usingMe().deleteSiteMember(publicSiteModel); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify user can't remove a site membership if doesn't have access to personId and response is 422") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user can't remove a site membership if doesn't have access to personId and response is 422") public void notAbleToRemoveSiteMemberWithNoAccessToPersonId() throws Exception - { + { UserModel user = dataUser.createRandomTestUser(); dataSite.usingUser(user).createPublicRandomSite(); - + userModel.setUserRole(UserRole.SiteCollaborator); restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(userModel); restClient.authenticateUser(user).withCoreAPI().usingUser(userModel).deleteSiteMember(publicSiteModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() + .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify user can't remove a site membership of an inexistent uer and response is 404") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user can't remove a site membership of an inexistent uer and response is 404") public void userIsNotAbleToRemoveInexistentSiteMember() throws Exception - { + { UserModel inexistentUser = new UserModel("inexistenUser", "password"); restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(inexistentUser).deleteSiteMember(publicSiteModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, inexistentUser.getUsername())); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, inexistentUser.getUsername())); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify user is not able to remove a member of an inexistent site and response is 404") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove a member of an inexistent site and response is 404") public void userIsNotAbleToRemoveMembershipOfInexistentSite() throws Exception { SiteModel inexistentSite = new SiteModel("inexistentSite"); restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(userModel).deleteSiteMember(inexistentSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, userModel.getUsername(), inexistentSite.getId())); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, userModel.getUsername(), inexistentSite.getId())); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify user is not able to remove a member of an empty site id and response is 404") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove a member of an empty site id and response is 404") public void userIsNotAbleToRemoveMembershipOfEmptySiteId() throws Exception { SiteModel inexistentSite = new SiteModel(""); restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(userModel).deleteSiteMember(inexistentSite); restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.DELETE_EMPTY_ARGUMENT); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify user is not able to remove a regular member of a public site and response is 422") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove a regular member of a public site and response is 422") public void regularUserIsNotAbleToRemoveRegularUserSiteMembershipFromPublicSite() throws Exception { restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(secondUserModel); restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(userModel); restClient.authenticateUser(secondUserModel).withCoreAPI().usingUser(userModel).deleteSiteMember(publicSiteModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() + .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify user is not able to remove a regular member a moderated site and response is 422") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove a regular member a moderated site and response is 422") public void regularUserIsNotAbleToRemoveRegularUserSiteMembershipFromModeratedSite() throws Exception { restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(secondUserModel); restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(userModel); restClient.authenticateUser(secondUserModel).withCoreAPI().usingUser(userModel).deleteSiteMember(moderatedSiteModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, moderatedSiteModel.getId())); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() + .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, moderatedSiteModel.getId())); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify user is not able to remove a regular member of a private site and response is 422") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove a regular member of a private site and response is 422") public void regularUserIsNotAbleToRemoveRegularUserSiteMembershipFromPrivateSite() throws Exception { restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(userModel); restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(secondUserModel); restClient.authenticateUser(secondUserModel).withCoreAPI().usingUser(userModel).deleteSiteMember(privateSiteModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, privateSiteModel.getId())); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() + .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, privateSiteModel.getId())); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify admin is able to remove a regular member of a public site and response is 204") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove a regular member of a public site and response is 204") public void adminIsAbleToRemoveRegularUserSiteMembershipFromPublicSite() throws Exception { restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(userModel); restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(userModel).deleteSiteMember(publicSiteModel); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify admin is able to remove a regular member of a moderated site and response is 204") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove a regular member of a moderated site and response is 204") public void adminIsAbleToRemoveRegularUserSiteMembershipFromModeratedSite() throws Exception { restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(userModel); restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(userModel).deleteSiteMember(moderatedSiteModel); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify admin is able to remove a regular member of a private site and response is 204") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove a regular member of a private site and response is 204") public void adminIsAbleToRemoveRegularUserSiteMembershipFromPrivateSite() throws Exception { restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(userModel); restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(userModel).deleteSiteMember(privateSiteModel); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify user is not able to remove admin membership from public site and response is 422") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove admin membership from public site and response is 422") public void regularUserIsNotAbleToRemoveAdminSiteMembershipFromPublicSite() throws Exception { restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(managerModel); restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(userModel); restClient.authenticateUser(userModel).withCoreAPI().usingUser(adminUserModel).deleteSiteMember(publicSiteModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() + .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify user is not able to remove admin membership from moderated site and response is 422") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove admin membership from moderated site and response is 422") public void regularUserIsNotAbleToRemoveAdminSiteMembershipFromModeratedSite() throws Exception { restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(managerModel); restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(userModel); restClient.authenticateUser(userModel).withCoreAPI().usingUser(adminUserModel).deleteSiteMember(moderatedSiteModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, moderatedSiteModel.getId())); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() + .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, moderatedSiteModel.getId())); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify user is not able to remove admin membership from private site and response is 422") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove admin membership from private site and response is 422") public void regularUserIsNotAbleToRemoveAdminSiteMembershipFromPrivateSite() throws Exception { restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(managerModel); restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(userModel); restClient.authenticateUser(userModel).withCoreAPI().usingUser(adminUserModel).deleteSiteMember(privateSiteModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, privateSiteModel.getId())); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() + .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, privateSiteModel.getId())); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify admin is able to remove the membership of a manager from a public site and response is 204") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove the membership of a manager from a public site and response is 204") public void adminIsAbleToRemoveManagerSiteMembershipOfPublicSite() throws Exception { UserModel secondManager = dataUser.createRandomTestUser(); @@ -187,9 +195,9 @@ public class DeleteSiteMemberCoreTests extends RestTest restClient.withCoreAPI().usingUser(managerModel).deleteSiteMember(publicSiteModel); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify admin is able to remove the membership of a manager from a moderated site and response is 204") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove the membership of a manager from a moderated site and response is 204") public void adminIsAbleToRemoveManagerSiteMembershipOfModeratedSite() throws Exception { UserModel secondManager = dataUser.createRandomTestUser(); @@ -199,9 +207,9 @@ public class DeleteSiteMemberCoreTests extends RestTest restClient.withCoreAPI().usingUser(managerModel).deleteSiteMember(moderatedSiteModel); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify admin is able to remove the membership of a manager from a private site and response is 204") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove the membership of a manager from a private site and response is 204") public void adminIsAbleToRemoveManagerSiteMembershipOfPrivateSite() throws Exception { UserModel secondManager = dataUser.createRandomTestUser(); @@ -211,9 +219,9 @@ public class DeleteSiteMemberCoreTests extends RestTest restClient.withCoreAPI().usingUser(managerModel).deleteSiteMember(privateSiteModel); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify collaborator is not able to remove the membership of a manager from a public site and response is 204") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify collaborator is not able to remove the membership of a manager from a public site and response is 204") public void userIsNotAbleToRemoveManagerSiteMembershipOfPublicSite() throws Exception { UserModel secondManager = dataUser.createRandomTestUser(); @@ -222,11 +230,12 @@ public class DeleteSiteMemberCoreTests extends RestTest restClient.withCoreAPI().usingSite(publicSiteModel).addPerson(userModel); restClient.withCoreAPI().usingSite(publicSiteModel).addPerson(managerModel); restClient.authenticateUser(userModel).withCoreAPI().usingUser(managerModel).deleteSiteMember(publicSiteModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() + .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify collaborator is not able to remove the membership of a manager from a moderated site and response is 204") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify collaborator is not able to remove the membership of a manager from a moderated site and response is 204") public void userIsNotAbleToRemoveManagerSiteMembershipOfModeratedSite() throws Exception { UserModel secondManager = dataUser.createRandomTestUser(); @@ -235,11 +244,12 @@ public class DeleteSiteMemberCoreTests extends RestTest restClient.withCoreAPI().usingSite(publicSiteModel).addPerson(userModel); restClient.withCoreAPI().usingSite(moderatedSiteModel).addPerson(managerModel); restClient.authenticateUser(userModel).withCoreAPI().usingUser(managerModel).deleteSiteMember(moderatedSiteModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, moderatedSiteModel.getId())); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() + .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, moderatedSiteModel.getId())); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify collaborator is not able to remove the membership of a manager from a private site and response is 204") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify collaborator is not able to remove the membership of a manager from a private site and response is 204") public void userIsNotAbleToRemoveManagerSiteMembershipOfPrivateSite() throws Exception { UserModel secondManager = dataUser.createRandomTestUser(); @@ -248,6 +258,7 @@ public class DeleteSiteMemberCoreTests extends RestTest restClient.withCoreAPI().usingSite(privateSiteModel).addPerson(userModel); restClient.withCoreAPI().usingSite(privateSiteModel).addPerson(managerModel); restClient.authenticateUser(userModel).withCoreAPI().usingUser(managerModel).deleteSiteMember(privateSiteModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, privateSiteModel.getId())); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() + .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, privateSiteModel.getId())); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java index b6fb3429f..6b58f0489 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java @@ -17,103 +17,91 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) public class DeleteSiteMemberSanityTests extends RestTest -{ +{ private SiteModel siteModel; private UserModel adminUser; private ListUserWithRoles usersWithRoles; - @BeforeClass(alwaysRun=true) + @BeforeClass(alwaysRun = true) public void dataPreparation() throws DataPreparationException { adminUser = dataUser.getAdminUser(); siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); - - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, - UserRole.SiteManager, - UserRole.SiteCollaborator, - UserRole.SiteConsumer, - UserRole.SiteContributor); + + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify site manager is able to delete another member of the site") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site manager is able to delete another member of the site") public void siteManagerCanDeleteSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception { UserModel newUser = dataUser.createRandomTestUser("testUser"); newUser.setUserRole(UserRole.SiteCollaborator); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingSite(siteModel).addPerson(newUser); - + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingSite(siteModel).addPerson(newUser); + restClient.withCoreAPI().usingUser(newUser).deleteSiteMember(siteModel); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify admin user is able to delete another member of the site") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify admin user is able to delete another member of the site") public void adminIsAbleToDeleteSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception { UserModel newUser = dataUser.createRandomTestUser("testUser"); newUser.setUserRole(UserRole.SiteCollaborator); - restClient.authenticateUser(adminUser) - .withCoreAPI().usingSite(siteModel).addPerson(newUser); - + restClient.authenticateUser(adminUser).withCoreAPI().usingSite(siteModel).addPerson(newUser); + restClient.withCoreAPI().usingUser(newUser).deleteSiteMember(siteModel); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify site collaborator does not have permission to delete another member of the site") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site collaborator does not have permission to delete another member of the site") public void siteCollaboratorIsNotAbleToDeleteSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception { UserModel newUser = dataUser.createRandomTestUser("testUser"); newUser.setUserRole(UserRole.SiteCollaborator); - restClient.authenticateUser(adminUser) - .withCoreAPI().usingSite(siteModel).addPerson(newUser); + restClient.authenticateUser(adminUser).withCoreAPI().usingSite(siteModel).addPerson(newUser); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); restClient.withCoreAPI().usingUser(newUser).deleteSiteMember(siteModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getId())); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() + .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getId())); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify site contributor does not have permission to delete another member of the site") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site contributor does not have permission to delete another member of the site") public void siteContributorIsNotAbleToDeleteSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception { UserModel newUser = dataUser.createRandomTestUser("testUser"); newUser.setUserRole(UserRole.SiteCollaborator); - restClient.authenticateUser(adminUser) - .withCoreAPI().usingSite(siteModel).addPerson(newUser); + restClient.authenticateUser(adminUser).withCoreAPI().usingSite(siteModel).addPerson(newUser); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); restClient.withCoreAPI().usingUser(newUser).deleteSiteMember(siteModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getId())); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() + .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getId())); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify site consumer does not have permission to delete another member of the site") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site consumer does not have permission to delete another member of the site") public void siteConsumerIsNotAbleToDeleteSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception { UserModel newUser = dataUser.createRandomTestUser("testUser"); newUser.setUserRole(UserRole.SiteCollaborator); - restClient.authenticateUser(adminUser) - .withCoreAPI().usingSite(siteModel).addPerson(newUser); + restClient.authenticateUser(adminUser).withCoreAPI().usingSite(siteModel).addPerson(newUser); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); restClient.withCoreAPI().usingUser(newUser).deleteSiteMember(siteModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getId())); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() + .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getId())); } - @Bug(id="MNT-16904") - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify unauthenticated user is not able to delete another member of the site") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @Bug(id = "MNT-16904") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to delete another member of the site") public void unauthenticatedUserIsNotAbleToDeleteSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception { restClient.authenticateUser(new UserModel("random user", "random password")); diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestCoreTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestCoreTests.java index 509d80953..428e0f239 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestCoreTests.java @@ -25,7 +25,8 @@ public class DeleteSiteMembershipRequestCoreTests extends RestTest UserModel siteMember; UserModel secondSiteMember; SiteModel secondModeratedSite; - @Autowired WorkflowService workflow; + @Autowired + WorkflowService workflow; @BeforeMethod(alwaysRun = true) public void dataPreparation() throws Exception @@ -37,9 +38,8 @@ public class DeleteSiteMembershipRequestCoreTests extends RestTest secondModeratedSite = dataSite.usingUser(siteMember).createModeratedRandomSite(); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is able to remove his own site memebership request using '-me-' in place of personId and response is successful (204)") @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is able to remove his own site memebership request using '-me-' in place of personId and response is successful (204)") public void userCanDeleteHisOwnSiteMembershipRequestUsingMeAsPersonId() throws JsonToModelConversionException, DataPreparationException, Exception { restClient.authenticateUser(siteMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); @@ -47,19 +47,18 @@ public class DeleteSiteMembershipRequestCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove site memebership request if doesn't have access to personI and response is 403") @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove site memebership request if doesn't have access to personI and response is 403") public void userIsNotAbleToDeleteSiteMembershipRequestWithNoAccessToPersonId() throws JsonToModelConversionException, DataPreparationException, Exception { restClient.authenticateUser(secondSiteMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); restClient.authenticateUser(siteMember).withCoreAPI().usingUser(secondSiteMember).deleteSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, secondSiteMember.getUsername(), moderatedSite.getId())); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, secondSiteMember.getUsername(), moderatedSite.getId())); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove a site memebership request of an inexistent user and response is 404") @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove a site memebership request of an inexistent user and response is 404") public void userIsNotAbleToDeleteSiteMembershipRequestOfAnInexistentUser() throws JsonToModelConversionException, DataPreparationException, Exception { UserModel inexistentUser = new UserModel("inexistenUser", "password"); @@ -67,83 +66,86 @@ public class DeleteSiteMembershipRequestCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, inexistentUser.getUsername())); } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove a site memebership request to an inexistent site and response is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove a site memebership request to an inexistent site and response is 404") public void userIsNotAbleToDeleteSiteMembershipRequestToAnInexistentSite() throws JsonToModelConversionException, DataPreparationException, Exception { SiteModel inexistentSite = new SiteModel("inexistentSite"); restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).deleteSiteMembershipRequest(inexistentSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, adminUserModel.getUsername(), inexistentSite.getId())); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, adminUserModel.getUsername(), inexistentSite.getId())); } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove a site memebership request to an empty site id and response is 405") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove a site memebership request to an empty site id and response is 405") public void userIsNotAbleToDeleteSiteMembershipRequestWithEmptySiteId() throws JsonToModelConversionException, DataPreparationException, Exception { SiteModel inexistentSite = new SiteModel(""); restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).deleteSiteMembershipRequest(inexistentSite); restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.DELETE_EMPTY_ARGUMENT); } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove a site memebership request of another regular user from moderated site and response is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - public void regularUserIsNotAbleToDeleteSiteMembershipRequestOfAnotherRegularUserToAModeratedSite() throws JsonToModelConversionException, DataPreparationException, Exception + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove a site memebership request of another regular user from moderated site and response is 404") + public void regularUserIsNotAbleToDeleteSiteMembershipRequestOfAnotherRegularUserToAModeratedSite() throws JsonToModelConversionException, + DataPreparationException, Exception { siteMember.setUserRole(UserRole.SiteCollaborator); restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSite).addPerson(siteMember); restClient.authenticateUser(secondSiteMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); restClient.authenticateUser(siteMember).withCoreAPI().usingUser(secondSiteMember).deleteSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, secondSiteMember.getUsername(), moderatedSite.getId())); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, secondSiteMember.getUsername(), moderatedSite.getId())); } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove a site memebership request of admin to a moderated site and response is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - public void regularUserIsNotAbleToDeleteSiteMembershipRequestOfAdminToAModeratedSite() throws JsonToModelConversionException, DataPreparationException, Exception + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove a site memebership request of admin to a moderated site and response is 404") + public void regularUserIsNotAbleToDeleteSiteMembershipRequestOfAdminToAModeratedSite() throws JsonToModelConversionException, DataPreparationException, + Exception { UserModel collaboratorUser = dataUser.createRandomTestUser(); collaboratorUser.setUserRole(UserRole.SiteCollaborator); restClient.authenticateUser(siteMember).withCoreAPI().usingSite(secondModeratedSite).addPerson(collaboratorUser); restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteMembershipRequest(secondModeratedSite); restClient.authenticateUser(collaboratorUser).withCoreAPI().usingUser(adminUserModel).deleteSiteMembershipRequest(secondModeratedSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, adminUserModel.getUsername(), secondModeratedSite.getId())); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, adminUserModel.getUsername(), secondModeratedSite.getId())); } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify manager is able to remove a site memebership request of admin to a moderated site and response is 204") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - public void managerUserIsAbleToDeleteSiteMembershipRequestOfAdminToAModeratedSite() throws JsonToModelConversionException, DataPreparationException, Exception + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify manager is able to remove a site memebership request of admin to a moderated site and response is 204") + public void managerUserIsAbleToDeleteSiteMembershipRequestOfAdminToAModeratedSite() throws JsonToModelConversionException, DataPreparationException, + Exception { restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteMembershipRequest(secondModeratedSite); restClient.authenticateUser(siteMember).withCoreAPI().usingUser(adminUserModel).deleteSiteMembershipRequest(secondModeratedSite); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify manager is not able to remove a site memebership request if it was already approved and response is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @Bug(id="TODO", description="TODO @cjalba please fix this NPE automated issue") //TODO @cjalba please fix this NPE automated issue - public void managerUserIsNotAbleToDeleteASiteMembershipRequestIfItWasAlreadyApproved() throws JsonToModelConversionException, DataPreparationException, Exception + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify manager is not able to remove a site memebership request if it was already approved and response is 404") + @Bug(id = "TODO", description = "TODO @cjalba please fix this NPE automated issue") + // TODO @cjalba please fix this NPE automated issue + public void managerUserIsNotAbleToDeleteASiteMembershipRequestIfItWasAlreadyApproved() throws JsonToModelConversionException, DataPreparationException, + Exception { secondSiteMember.setUserRole(UserRole.SiteCollaborator); restClient.authenticateUser(secondSiteMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(secondModeratedSite); RestTaskModel taskModel = restClient.authenticateUser(secondSiteMember).withWorkflowAPI().getTasks().getTaskModelByDescription(secondModeratedSite); workflow.approveSiteMembershipRequest(siteMember.getUsername(), siteMember.getPassword(), taskModel.getId(), true, "Approve"); - + restClient.authenticateUser(siteMember).withCoreAPI().usingUser(secondSiteMember).deleteSiteMembershipRequest(secondModeratedSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, secondSiteMember.getUsername(), secondModeratedSite.getId())); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, secondSiteMember.getUsername(), secondModeratedSite.getId())); } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify manager is not able to remove an inexitent site memebership request and response is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify manager is not able to remove an inexitent site memebership request and response is 404") public void managerUserIsNotAbleToDeleteAnInexistentSiteMembershipRequest() throws JsonToModelConversionException, DataPreparationException, Exception { restClient.authenticateUser(siteMember).withCoreAPI().usingUser(adminUserModel).deleteSiteMembershipRequest(secondModeratedSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, adminUserModel.getUsername(), secondModeratedSite.getId())); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, adminUserModel.getUsername(), secondModeratedSite.getId())); } } diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java index 4a95680dd..4125ecad7 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java @@ -19,156 +19,116 @@ import org.testng.annotations.Test; /** * @author iulia.cojocea */ -@Test(groups = {TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + public class DeleteSiteMembershipRequestSanityTests extends RestTest -{ +{ UserModel userModel; UserModel siteMember; SiteModel siteModel; private ListUserWithRoles usersWithRoles; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception{ + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { String siteId = RandomData.getRandomName("site"); siteModel = dataSite.usingUser(userModel).createSite(new SiteModel(Visibility.MODERATED, siteId, siteId, siteId, siteId)); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, - UserRole.SiteManager, - UserRole.SiteCollaborator, - UserRole.SiteConsumer, - UserRole.SiteContributor); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); } - @TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify one user is able to delete his one site memebership request") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify one user is able to delete his one site memebership request") public void userCanDeleteHisOwnSiteMembershipRequest() throws JsonToModelConversionException, DataPreparationException, Exception { siteMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(siteMember) - .withCoreAPI() - .usingAuthUser().addSiteMembershipRequest(siteModel); + restClient.authenticateUser(siteMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI() - .usingUser(siteMember).deleteSiteMembershipRequest(siteModel); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingUser(siteMember) + .deleteSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } - - @Bug(id="MNT-16916") - @TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify site manager is able to delete site membership request") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @Bug(id = "MNT-16916") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site manager is able to delete site membership request") public void siteManagerCanDeleteSiteMembershipRequest() throws JsonToModelConversionException, DataPreparationException, Exception { siteMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(siteMember) - .withCoreAPI() - .usingUser(siteMember).addSiteMembershipRequest(siteModel); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI() - .usingAuthUser().deleteSiteMembershipRequest(siteModel); + restClient.authenticateUser(siteMember).withCoreAPI().usingUser(siteMember).addSiteMembershipRequest(siteModel); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingAuthUser() + .deleteSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } - - @Bug(id="MNT-16916") - @TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify admin user is able to delete site memebership request") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @Bug(id = "MNT-16916") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify admin user is able to delete site memebership request") public void adminUserCanDeleteSiteMembershipRequest() throws JsonToModelConversionException, DataPreparationException, Exception { siteMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(siteMember) - .withCoreAPI() - .usingAuthUser().addSiteMembershipRequest(siteModel); + restClient.authenticateUser(siteMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(dataUser.getAdminUser()) - .withCoreAPI() - .usingAuthUser().deleteSiteMembershipRequest(siteModel); + + restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingAuthUser().deleteSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } - - @Bug(id="MNT-16916") - @TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify collaborator user is not able to delete site memebership request") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @Bug(id = "MNT-16916") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify collaborator user is not able to delete site memebership request") public void collaboratorCannotDeleteSiteMembershipRequest() throws JsonToModelConversionException, DataPreparationException, Exception { siteMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(siteMember) - .withCoreAPI() - .usingAuthUser().addSiteMembershipRequest(siteModel); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI() - .usingAuthUser().deleteSiteMembershipRequest(siteModel); + restClient.authenticateUser(siteMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(siteModel); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingAuthUser() + .deleteSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } - - @Bug(id="MNT-16916") - @TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify contributor user is not able to delete site memebership request") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @Bug(id = "MNT-16916") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify contributor user is not able to delete site memebership request") public void contributorCannotDeleteSiteMembershipRequest() throws JsonToModelConversionException, DataPreparationException, Exception { siteMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(siteMember) - .withCoreAPI() - .usingAuthUser().addSiteMembershipRequest(siteModel); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) - .withCoreAPI() - .usingAuthUser().deleteSiteMembershipRequest(siteModel); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + restClient.authenticateUser(siteMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(siteModel); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingAuthUser() + .deleteSiteMembershipRequest(siteModel); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } - - @Bug(id="MNT-16916") - @TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify consumer user is not able to delete site memebership request") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @Bug(id = "MNT-16916") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify consumer user is not able to delete site memebership request") public void consumerCannotDeleteSiteMembershipRequest() throws JsonToModelConversionException, DataPreparationException, Exception { siteMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(siteMember) - .withCoreAPI() - .usingAuthUser().addSiteMembershipRequest(siteModel); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .withCoreAPI() - .usingAuthUser().deleteSiteMembershipRequest(siteModel); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + restClient.authenticateUser(siteMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(siteModel); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingAuthUser() + .deleteSiteMembershipRequest(siteModel); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } - - @Bug(id="MNT-16916") - @TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify random user is not able to delete site memebership request") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @Bug(id = "MNT-16916") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify random user is not able to delete site memebership request") public void randomUserCanDeleteSiteMembershipRequest() throws JsonToModelConversionException, DataPreparationException, Exception - { - restClient.authenticateUser(dataUser.createRandomTestUser()) - .withCoreAPI() - .usingAuthUser().addSiteMembershipRequest(siteModel); + { + restClient.authenticateUser(dataUser.createRandomTestUser()).withCoreAPI().usingAuthUser().addSiteMembershipRequest(siteModel); - restClient.authenticateUser(dataUser.createRandomTestUser()) - .withCoreAPI() - .usingAuthUser().deleteSiteMembershipRequest(siteModel); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + restClient.authenticateUser(dataUser.createRandomTestUser()).withCoreAPI().usingAuthUser().deleteSiteMembershipRequest(siteModel); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) @Bug(id = "MNT-16904") - @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, - executionType = ExecutionType.SANITY, - description = "Failed authentication get site member call returns status code 401") + @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Failed authentication get site member call returns status code 401") public void unauthenticatedUserIsNotAuthorizedToDeleteSiteMmebershipRequest() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(dataUser.createRandomTestUser()) - .withCoreAPI() - .usingAuthUser().addSiteMembershipRequest(siteModel); + { + restClient.authenticateUser(dataUser.createRandomTestUser()).withCoreAPI().usingAuthUser().addSiteMembershipRequest(siteModel); UserModel inexistentUser = new UserModel("inexistent user", "inexistent password"); - restClient.authenticateUser(inexistentUser) - .withCoreAPI() - .usingAuthUser().deleteSiteMembershipRequest(siteModel); + restClient.authenticateUser(inexistentUser).withCoreAPI().usingAuthUser().deleteSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteCoreTests.java b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteCoreTests.java index ce8af1b22..6f1dd7e50 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteCoreTests.java @@ -15,13 +15,13 @@ import org.testng.annotations.Test; /** * Created by Claudia Agache on 11/22/2016. */ -@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + public class GetFavoriteSiteCoreTests extends RestTest { UserModel userModel; SiteModel site1; - @BeforeClass(alwaysRun=true) + @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception { userModel = dataUser.createRandomTestUser(); @@ -29,37 +29,32 @@ public class GetFavoriteSiteCoreTests extends RestTest dataSite.usingUser(userModel).usingSite(site1).addSiteToFavorites(); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, - description = "Verify invalid request returns status 404 when personId does not exist") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify invalid request returns status 404 when personId does not exist") public void getFavoriteSiteWithNonExistentPersonId() throws Exception { UserModel someUser = new UserModel("someUser", DataUser.PASSWORD); restClient.authenticateUser(userModel).withCoreAPI().usingUser(someUser).getFavoriteSite(site1); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "someUser")); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "someUser")); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, - description = "Verify invalid request returns status 404 when siteId does not exist") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify invalid request returns status 404 when siteId does not exist") public void getFavoriteSiteWithNonExistentSiteId() throws Exception { SiteModel nonExistentSite = new SiteModel("nonExistentSite"); restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().getFavoriteSite(nonExistentSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, userModel.getUsername(), nonExistentSite.getId())); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, userModel.getUsername(), nonExistentSite.getId())); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, - description = "Verify User fails to get specific favorite site of admin with Rest API and response is 403") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify User fails to get specific favorite site of admin with Rest API and response is 403") public void userFailsToGetFavoriteSiteOfAdmin() throws Exception { restClient.authenticateUser(userModel).withCoreAPI().usingUser(dataUser.getAdminUser()).getFavoriteSite(site1); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } } diff --git a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java index e344d3caa..1b54ac797 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java @@ -14,11 +14,10 @@ import org.testng.annotations.Test; /** * Tests for Get Favorite Sites (/people/{personId}/preferences) RestAPI call - * + * * @author Cristina Axinte - * */ -@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + public class GetFavoriteSiteSanityTests extends RestTest { UserModel userModel; @@ -27,17 +26,16 @@ public class GetFavoriteSiteSanityTests extends RestTest UserModel searchedUser; private RestSiteModel restSiteModel; - @BeforeClass(alwaysRun=true) + @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception { - userModel = dataUser.createRandomTestUser(); - siteModel1 = dataSite.usingUser(userModel).createPublicRandomSite(); - siteModel2 = dataSite.usingUser(userModel).createPublicRandomSite(); + userModel = dataUser.createRandomTestUser(); + siteModel1 = dataSite.usingUser(userModel).createPublicRandomSite(); + siteModel2 = dataSite.usingUser(userModel).createPublicRandomSite(); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify manager user gets its specific favorite site with Rest API and response is successful (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user gets its specific favorite site with Rest API and response is successful (200)") public void managerUserGetsFavoriteSiteWithSuccess() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -49,10 +47,9 @@ public class GetFavoriteSiteSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); restSiteModel.assertThat().field("id").is(siteModel1.getId()).and().field("title").isNotNull(); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify collaborator user gets its specific favorite site with Rest API and response is successful (200)") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify collaborator user gets its specific favorite site with Rest API and response is successful (200)") public void collaboratorUserGetsFavoriteSiteWithSuccess() throws Exception { UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); @@ -64,10 +61,9 @@ public class GetFavoriteSiteSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); restSiteModel.assertThat().field("id").is(siteModel1.getId()).and().field("title").isNotNull(); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify contributor user gets its specific favorite site with Rest API and response is successful (200)") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify contributor user gets its specific favorite site with Rest API and response is successful (200)") public void contributorUserGetsFavoriteSiteWithSuccess() throws Exception { UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); @@ -79,10 +75,9 @@ public class GetFavoriteSiteSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); restSiteModel.assertThat().field("id").is(siteModel1.getId()).and().field("title").isNotNull(); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify consumer user gets its specific favorite site with Rest API and response is successful (200)") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify consumer user gets its specific favorite site with Rest API and response is successful (200)") public void consumerUserGetsFavoriteSiteWithSuccess() throws Exception { UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -94,10 +89,9 @@ public class GetFavoriteSiteSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); restSiteModel.assertThat().field("id").is(siteModel1.getId()).and().field("title").isNotNull(); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify admin user gets specific favorite site of any user with Rest API and response is successful (200)") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify admin user gets specific favorite site of any user with Rest API and response is successful (200)") public void adminUserGetsAnyFavoriteSiteWithSuccess() throws Exception { UserModel adminUset = dataUser.getAdminUser(); @@ -109,10 +103,9 @@ public class GetFavoriteSiteSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); restSiteModel.assertThat().field("id").is(siteModel1.getId()).and().field("title").isNotNull(); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify manager user fails to get specific favorite site of another user with Rest API and response is successful (403)") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user fails to get specific favorite site of another user with Rest API and response is successful (403)") public void managerUserFailsToGetFavoriteSiteOfAnotherUser() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -123,11 +116,10 @@ public class GetFavoriteSiteSanityTests extends RestTest restClient.authenticateUser(managerUser).withCoreAPI().usingUser(userModel).getFavoriteSite(siteModel1); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } - + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) @Bug(id = "MNT-16904") - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify manager user is NOT Authorized gets its specific favorite site with Rest API when authentication fails (401)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized gets its specific favorite site with Rest API when authentication fails (401)") public void managerUserNotAuthorizedFailsToGetFavoriteSite() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); diff --git a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java index 565a50673..d1f6adf03 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java @@ -12,7 +12,6 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) public class GetFavoriteSitesSanityTests extends RestTest { UserModel userModel; @@ -20,45 +19,42 @@ public class GetFavoriteSitesSanityTests extends RestTest UserModel searchedUser; private RestSiteModelsCollection restSiteModelsCollection; - @BeforeClass(alwaysRun=true) + @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception { userModel = dataUser.createRandomTestUser(); siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify manager user fails to get an user favorite sites with Rest API (403)") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user fails to get an user favorite sites with Rest API (403)") public void managerUserFailsToGetAnUserFavoriteSites() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); - UserModel anotherUser = dataUser.usingAdmin().createRandomTestUser(); + UserModel anotherUser = dataUser.usingAdmin().createRandomTestUser(); dataSite.usingUser(anotherUser).usingSite(siteModel).addSiteToFavorites(); restClient.authenticateUser(managerUser).withCoreAPI().usingUser(anotherUser).getFavoriteSites(); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify collaborator user fails to get an user favorite sites with Rest API (403)") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify collaborator user fails to get an user favorite sites with Rest API (403)") public void collaboratorUserFailsToGetAnUserFavoriteSites() throws Exception { UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(collaboratorUser, siteModel, UserRole.SiteCollaborator); UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(contributorUser, siteModel, UserRole.SiteContributor); + dataUser.usingUser(userModel).addUserToSite(contributorUser, siteModel, UserRole.SiteContributor); dataSite.usingUser(contributorUser).usingSite(siteModel).addSiteToFavorites(); - restClient.authenticateUser(collaboratorUser).withCoreAPI().usingUser(contributorUser).getFavoriteSites(); + restClient.authenticateUser(collaboratorUser).withCoreAPI().usingUser(contributorUser).getFavoriteSites(); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify contributor user fails to get an user favorite sites with Rest API (403)") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify contributor user fails to get an user favorite sites with Rest API (403)") public void contributorUserFailsToGetAnUserFavoriteSites() throws Exception { UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); @@ -70,10 +66,9 @@ public class GetFavoriteSitesSanityTests extends RestTest restClient.authenticateUser(contributorUser).withCoreAPI().usingUser(contributorUser2).getFavoriteSites(); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify consumer user fails to get an user favorite sites with Rest API (403)") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify consumer user fails to get an user favorite sites with Rest API (403)") public void consumerUserFailsToGetAnUserFavoriteSites() throws Exception { UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -85,10 +80,9 @@ public class GetFavoriteSitesSanityTests extends RestTest restClient.authenticateUser(consumerUser).withCoreAPI().usingUser(collaboratorUser).getFavoriteSites(); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify admin user gets its favorite sites with Rest API and response is successful (200)") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify admin user gets its favorite sites with Rest API and response is successful (200)") public void adminUserGetsFavoriteSitesWithSuccess() throws Exception { UserModel adminUser = dataUser.getAdminUser(); @@ -97,31 +91,27 @@ public class GetFavoriteSitesSanityTests extends RestTest restSiteModelsCollection = restClient.authenticateUser(adminUser).withCoreAPI().usingUser(anotherUser).getFavoriteSites(); restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModelsCollection.assertThat().entriesListIsNotEmpty().and().paginationExist() - .and().entriesListContains("id", siteModel.getId()); + restSiteModelsCollection.assertThat().entriesListIsNotEmpty().and().paginationExist().and().entriesListContains("id", siteModel.getId()); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify any user gets its own user favorite sites with Rest API and response is successful (200)") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify any user gets its own user favorite sites with Rest API and response is successful (200)") public void anyUserGetsItsUserFavoriteSites() throws Exception { - UserModel anyUser = dataUser.usingAdmin().createRandomTestUser(); + UserModel anyUser = dataUser.usingAdmin().createRandomTestUser(); dataSite.usingUser(anyUser).usingSite(siteModel).addSiteToFavorites(); restSiteModelsCollection = restClient.authenticateUser(anyUser).withCoreAPI().usingAuthUser().getFavoriteSites(); restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModelsCollection.assertThat().entriesListIsNotEmpty().and().entriesListContains("id", siteModel.getId()) - .and().paginationExist(); + restSiteModelsCollection.assertThat().entriesListIsNotEmpty().and().entriesListContains("id", siteModel.getId()).and().paginationExist(); } - + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) @Bug(id = "MNT-16904") - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify any user is NOT Authorized to get its favorite sites with Rest API when authentication fails (401)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify any user is NOT Authorized to get its favorite sites with Rest API when authentication fails (401)") public void anyUserNotAuthenticatedIsNotAuthorizedToGetFavoriteSites() throws Exception { - UserModel anyUser = dataUser.usingAdmin().createRandomTestUser(); + UserModel anyUser = dataUser.usingAdmin().createRandomTestUser(); dataSite.usingUser(anyUser).usingSite(siteModel).addSiteToFavorites(); anyUser.setPassword("newpassword"); diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java index e7035b153..b2b28a806 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java @@ -17,11 +17,9 @@ import org.testng.annotations.Test; /** * @author Cristina Axinte - * - * Tests for getActivities (/people/{personId}/activities) RestAPI call - * + * Tests for getActivities (/people/{personId}/activities) RestAPI call */ -@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.SANITY }) + public class GetPeopleActivitiesSanityTests extends RestTest { UserModel userModel, unauthenticatedUser; @@ -35,14 +33,14 @@ public class GetPeopleActivitiesSanityTests extends RestTest userModel = dataUser.createRandomTestUser(); siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); unauthenticatedUser = dataUser.usingAdmin().createRandomTestUser(); unauthenticatedUser.setPassword("newpassword"); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, - executionType = ExecutionType.SANITY, - description = "Verify manager user gets its activities with Rest API and response is successful") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.SANITY, description = "Verify manager user gets its activities with Rest API and response is successful") public void managerUserShouldGetPeopleActivitiesList() throws Exception { UserModel managerUser = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); @@ -50,13 +48,11 @@ public class GetPeopleActivitiesSanityTests extends RestTest restActivityModelsCollection = restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().getPersonActivities(); restClient.assertStatusCodeIs(HttpStatus.OK); - restActivityModelsCollection.assertThat().entriesListIsNotEmpty().and().entriesListContains("siteId", siteModel.getId()) - .and().paginationExist(); + restActivityModelsCollection.assertThat().entriesListIsNotEmpty().and().entriesListContains("siteId", siteModel.getId()).and().paginationExist(); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, - executionType = ExecutionType.SANITY, - description = "Verify collaborator user gets its activities with Rest API and response is successful") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.SANITY, description = "Verify collaborator user gets its activities with Rest API and response is successful") public void collaboratorUserShouldGetPeopleActivitiesList() throws Exception { UserModel collaboratorUser = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); @@ -64,13 +60,11 @@ public class GetPeopleActivitiesSanityTests extends RestTest restActivityModelsCollection = restClient.authenticateUser(collaboratorUser).withCoreAPI().usingAuthUser().getPersonActivities(); restClient.assertStatusCodeIs(HttpStatus.OK); - restActivityModelsCollection.assertThat().entriesListIsNotEmpty().and().entriesListContains("siteId", siteModel.getId()) - .and().paginationExist(); + restActivityModelsCollection.assertThat().entriesListIsNotEmpty().and().entriesListContains("siteId", siteModel.getId()).and().paginationExist(); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, - executionType = ExecutionType.SANITY, - description = "Verify contributor user gets its activities with Rest API and response is successful") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.SANITY, description = "Verify contributor user gets its activities with Rest API and response is successful") public void contributorUserShouldGetPeopleActivitiesList() throws Exception { UserModel contributorUser = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); @@ -78,37 +72,31 @@ public class GetPeopleActivitiesSanityTests extends RestTest restActivityModelsCollection = restClient.authenticateUser(contributorUser).withCoreAPI().usingAuthUser().getPersonActivities(); restClient.assertStatusCodeIs(HttpStatus.OK); - restActivityModelsCollection.assertThat().entriesListIsNotEmpty().and().entriesListContains("siteId", siteModel.getId()) - .and().paginationExist(); + restActivityModelsCollection.assertThat().entriesListIsNotEmpty().and().entriesListContains("siteId", siteModel.getId()).and().paginationExist(); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, - executionType = ExecutionType.SANITY, - description = "Verify consumer user gets its activities with Rest API and response is successful") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.SANITY, description = "Verify consumer user gets its activities with Rest API and response is successful") public void consumerUserShouldGetPeopleActivitiesList() throws Exception { UserModel consumerUser = usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer); - + restActivityModelsCollection = restClient.authenticateUser(consumerUser).withCoreAPI().usingAuthUser().getPersonActivities(); restClient.assertStatusCodeIs(HttpStatus.OK); - restActivityModelsCollection.assertThat().entriesListIsNotEmpty().and().entriesListContains("siteId", siteModel.getId()) - .and().paginationExist(); + restActivityModelsCollection.assertThat().entriesListIsNotEmpty().and().entriesListContains("siteId", siteModel.getId()).and().paginationExist(); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, - executionType = ExecutionType.SANITY, - description = "Verify admin user gets another user activities with Rest API and response is successful") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.SANITY, description = "Verify admin user gets another user activities with Rest API and response is successful") public void adminUserShouldGetPeopleActivitiesList() throws Exception { restActivityModelsCollection = restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingUser(userModel).getPersonActivities(); restClient.assertStatusCodeIs(HttpStatus.OK); - restActivityModelsCollection.assertThat().entriesListIsNotEmpty().and().entriesListContains("siteId", siteModel.getId()) - .and().paginationExist(); + restActivityModelsCollection.assertThat().entriesListIsNotEmpty().and().entriesListContains("siteId", siteModel.getId()).and().paginationExist(); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, - executionType = ExecutionType.SANITY, - description = "Verify unauthenticated user is NOT Authorized to gets another user activities with Rest API") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is NOT Authorized to gets another user activities with Rest API") public void unauthenticatedUserShouldNotGetPeopleActivitiesList() throws Exception { restClient.authenticateUser(unauthenticatedUser).withCoreAPI().usingUser(userModel).getPersonActivities(); diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceSanityTests.java index 674d7c6b4..5856ff104 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceSanityTests.java @@ -19,22 +19,22 @@ import org.testng.annotations.Test; * Tests for Get a Peference (/people/{personId}/preferences/{preferenceName}) RestAPI call * * @author Cristina Axinte - * */ -@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) + public class GetPeoplePreferenceSanityTests extends RestTest { UserModel userModel; SiteModel siteModel; private RestPreferenceModel restPreferenceModel; - - @BeforeClass(alwaysRun=true) + + @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception { userModel = dataUser.createRandomTestUser(); siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); } - + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify manager user gets a specific preference with Rest API and response is successful (200)") public void managerUserGetsAPreferenceWithSuccess() throws Exception { @@ -42,13 +42,13 @@ public class GetPeoplePreferenceSanityTests extends RestTest dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); dataSite.usingUser(managerUser).usingSite(siteModel).addSiteToFavorites(); - restPreferenceModel = restClient.authenticateUser(managerUser) - .withCoreAPI().usingAuthUser().getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); + restPreferenceModel = restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser() + .getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); restClient.assertStatusCodeIs(HttpStatus.OK); - restPreferenceModel.assertThat().field("id").is( PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) - .and().field("value").is("true"); + restPreferenceModel.assertThat().field("id").is(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()).and().field("value").is("true"); } - + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify collaborator user gets a specific preference with Rest API and response is successful (200)") public void collaboratorUserGetsAPreferenceWithSuccess() throws Exception { @@ -56,13 +56,13 @@ public class GetPeoplePreferenceSanityTests extends RestTest dataUser.usingUser(userModel).addUserToSite(collaboratorUser, siteModel, UserRole.SiteCollaborator); dataSite.usingUser(collaboratorUser).usingSite(siteModel).addSiteToFavorites(); - restPreferenceModel = restClient.authenticateUser(collaboratorUser) - .withCoreAPI().usingAuthUser().getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); + restPreferenceModel = restClient.authenticateUser(collaboratorUser).withCoreAPI().usingAuthUser() + .getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); restClient.assertStatusCodeIs(HttpStatus.OK); - restPreferenceModel.assertThat().field("id").is(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) - .and().field("value").is("true"); + restPreferenceModel.assertThat().field("id").is(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()).and().field("value").is("true"); } - + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify contributor user gets a specific preference with Rest API and response is successful (200)") public void contributorUserGetsAPreferenceWithSuccess() throws Exception { @@ -70,13 +70,13 @@ public class GetPeoplePreferenceSanityTests extends RestTest dataUser.usingUser(userModel).addUserToSite(contributorUser, siteModel, UserRole.SiteContributor); dataSite.usingUser(contributorUser).usingSite(siteModel).addSiteToFavorites(); - restPreferenceModel = restClient.authenticateUser(contributorUser) - .withCoreAPI().usingAuthUser().getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); + restPreferenceModel = restClient.authenticateUser(contributorUser).withCoreAPI().usingAuthUser() + .getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); restClient.assertStatusCodeIs(HttpStatus.OK); - restPreferenceModel.assertThat().field("id").is(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) - .and().field("value").is("true"); + restPreferenceModel.assertThat().field("id").is(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()).and().field("value").is("true"); } - + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify consumer user gets a specific preference with Rest API and response is successful (200)") public void consumerUserGetsAPreferenceWithSuccess() throws Exception { @@ -84,26 +84,26 @@ public class GetPeoplePreferenceSanityTests extends RestTest dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel, UserRole.SiteConsumer); dataSite.usingUser(consumerUser).usingSite(siteModel).addSiteToFavorites(); - restPreferenceModel = restClient.authenticateUser(consumerUser) - .withCoreAPI().usingAuthUser().getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); + restPreferenceModel = restClient.authenticateUser(consumerUser).withCoreAPI().usingAuthUser() + .getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); restClient.assertStatusCodeIs(HttpStatus.OK); - restPreferenceModel.assertThat().field("id").is(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) - .and().field("value").is("true"); + restPreferenceModel.assertThat().field("id").is(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()).and().field("value").is("true"); } - + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify admin user gets a specific preference with Rest API and response is successful (200)") public void adminUserGetsAPreferenceWithSuccess() throws Exception { UserModel adminUser = dataUser.getAdminUser(); dataSite.usingUser(adminUser).usingSite(siteModel).addSiteToFavorites(); - restPreferenceModel = restClient.authenticateUser(adminUser) - .withCoreAPI().usingAuthUser().getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); + restPreferenceModel = restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser() + .getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); restClient.assertStatusCodeIs(HttpStatus.OK); - restPreferenceModel.assertThat().field("id").is(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) - .and().field("value").is("true"); + restPreferenceModel.assertThat().field("id").is(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()).and().field("value").is("true"); } - + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) @Bug(id = "MNT-16904") @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized to get a specific preference with Rest API when authentication fails (401)") public void managerUserNotAuthorizedFailsToGetsAPreference() throws Exception @@ -113,8 +113,8 @@ public class GetPeoplePreferenceSanityTests extends RestTest dataSite.usingUser(managerUser).usingSite(siteModel).addSiteToFavorites(); managerUser.setPassword("newpassword"); - restClient.authenticateUser(managerUser) - .withCoreAPI().usingAuthUser().getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); + restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser() + .getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesCoreTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesCoreTests.java index 65e6490d3..767de94b2 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesCoreTests.java @@ -11,13 +11,12 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) -public class GetPeoplePreferencesCoreTests extends RestTest +public class GetPeoplePreferencesCoreTests extends RestTest { UserModel userModel; SiteModel siteModel; - @BeforeClass(alwaysRun=true) + @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception { userModel = dataUser.createRandomTestUser(); @@ -25,8 +24,8 @@ public class GetPeoplePreferencesCoreTests extends RestTest dataSite.usingUser(userModel).usingSite(siteModel).addSiteToFavorites(); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, - description = "Verify user is Forbidden to get a specific preference for another user with Rest API and response is 403") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user is Forbidden to get a specific preference for another user with Rest API and response is 403") public void userDoesNotHaveAccessToFavoriteSitesOfAnotherUser() throws Exception { UserModel secondUser = dataUser.createRandomTestUser(); @@ -36,8 +35,8 @@ public class GetPeoplePreferencesCoreTests extends RestTest restClient.assertLastError().containsSummary("Permission was denied"); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, - description = "Verify manager fails to get a specific preference for an invalid user with Rest API and response is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify manager fails to get a specific preference for an invalid user with Rest API and response is 404") public void statusNotFoundIsReturnedForAPersonIDThatDoesNotExist() throws Exception { restClient.authenticateUser(userModel).withCoreAPI().usingUser(new UserModel("invalidPersonID", "password")) @@ -46,19 +45,19 @@ public class GetPeoplePreferencesCoreTests extends RestTest restClient.assertLastError().containsSummary("The entity with id: invalidPersonID was not found"); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, - description = "Verify manager fails to get a specific preference for an invalid preference with Rest API and response is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify manager fails to get a specific preference for an invalid preference with Rest API and response is 404") public void statusNotFoundIsReturnedForAPreferenceNameThatDoesNotExist() throws Exception { - restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser() - .getPersonPreferenceInformation("invalidPreferenceName"); + restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().getPersonPreferenceInformation("invalidPreferenceName"); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - restClient.assertLastError().containsSummary(String.format("The relationship resource was not found for the" + - " entity with id: %s and a relationship id of invalidPreferenceName", userModel.getUsername())); + restClient.assertLastError().containsSummary( + String.format("The relationship resource was not found for the" + " entity with id: %s and a relationship id of invalidPreferenceName", + userModel.getUsername())); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, - description = "Verify manager fails to get a specific preference for an removed preference with Rest API and response is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify manager fails to get a specific preference for an removed preference with Rest API and response is 404") public void statusNotFoundIsReturnedForAPreferenceNameThatHasBeenRemoved() throws Exception { SiteModel preferenceSite = dataSite.usingUser(userModel).createPublicRandomSite(); @@ -67,8 +66,8 @@ public class GetPeoplePreferencesCoreTests extends RestTest restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser() .getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + preferenceSite.getId()); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - restClient.assertLastError().containsSummary(String.format("The relationship resource was not found for the" + - " entity with id: %s and a relationship id of %s", userModel.getUsername(), - PreferenceName.SITES_FAVORITES_PREFIX + preferenceSite.getId())); + restClient.assertLastError().containsSummary( + String.format("The relationship resource was not found for the" + " entity with id: %s and a relationship id of %s", userModel.getUsername(), + PreferenceName.SITES_FAVORITES_PREFIX + preferenceSite.getId())); } } diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesSanityTests.java index 413a2a959..612d209af 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesSanityTests.java @@ -19,25 +19,23 @@ import org.testng.annotations.Test; * Tests for Get Peferences (/people/{personId}/preferences) RestAPI call * * @author Cristina Axinte - * */ -@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) + public class GetPeoplePreferencesSanityTests extends RestTest { UserModel userModel; SiteModel siteModel; - private RestPreferenceModelsCollection restPreferenceModelsCollection; + private RestPreferenceModelsCollection restPreferenceModelsCollection; - @BeforeClass(alwaysRun=true) + @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception { userModel = dataUser.createRandomTestUser(); siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, - executionType = ExecutionType.SANITY, - description = "Verify manager user gets its preferences with Rest API and response is successful (200)") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify manager user gets its preferences with Rest API and response is successful (200)") public void managerUserGetsPeoplePreferencesWithSuccess() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -46,13 +44,12 @@ public class GetPeoplePreferencesSanityTests extends RestTest restPreferenceModelsCollection = restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().getPersonPreferences(); restClient.assertStatusCodeIs(HttpStatus.OK); - restPreferenceModelsCollection.assertThat().entriesListIsNotEmpty().assertThat().paginationExist() - .and().entriesListContains("id", PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); + restPreferenceModelsCollection.assertThat().entriesListIsNotEmpty().assertThat().paginationExist().and() + .entriesListContains("id", PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, - executionType = ExecutionType.SANITY, - description = "Verify collaborator user gets its preferences with Rest API and response is successful (200)") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify collaborator user gets its preferences with Rest API and response is successful (200)") public void collaboratorUserGetsPeoplePreferencesWithSuccess() throws Exception { UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); @@ -61,13 +58,12 @@ public class GetPeoplePreferencesSanityTests extends RestTest restPreferenceModelsCollection = restClient.authenticateUser(collaboratorUser).withCoreAPI().usingAuthUser().getPersonPreferences(); restClient.assertStatusCodeIs(HttpStatus.OK); - restPreferenceModelsCollection.assertThat().entriesListIsNotEmpty().assertThat().paginationExist() - .and().entriesListContains("id", PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); + restPreferenceModelsCollection.assertThat().entriesListIsNotEmpty().assertThat().paginationExist().and() + .entriesListContains("id", PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, - executionType = ExecutionType.SANITY, - description = "Verify contributor user gets its preferences with Rest API and response is successful (200)") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify contributor user gets its preferences with Rest API and response is successful (200)") public void contributorUserGetsPeoplePreferencesWithSuccess() throws Exception { UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); @@ -76,13 +72,12 @@ public class GetPeoplePreferencesSanityTests extends RestTest restPreferenceModelsCollection = restClient.authenticateUser(contributorUser).withCoreAPI().usingAuthUser().getPersonPreferences(); restClient.assertStatusCodeIs(HttpStatus.OK); - restPreferenceModelsCollection.assertThat().entriesListIsNotEmpty().assertThat().paginationExist() - .and().entriesListContains("id", PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); + restPreferenceModelsCollection.assertThat().entriesListIsNotEmpty().assertThat().paginationExist().and() + .entriesListContains("id", PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, - executionType = ExecutionType.SANITY, - description = "Verify consumer user gets its preferences with Rest API and response is successful (200)") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify consumer user gets its preferences with Rest API and response is successful (200)") public void consumerUserGetsPeoplePreferencesWithSuccess() throws Exception { UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -91,13 +86,12 @@ public class GetPeoplePreferencesSanityTests extends RestTest restPreferenceModelsCollection = restClient.authenticateUser(consumerUser).withCoreAPI().usingAuthUser().getPersonPreferences(); restClient.assertStatusCodeIs(HttpStatus.OK); - restPreferenceModelsCollection.assertThat().entriesListIsNotEmpty().assertThat().paginationExist() - .and().entriesListContains("id", PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); + restPreferenceModelsCollection.assertThat().entriesListIsNotEmpty().assertThat().paginationExist().and() + .entriesListContains("id", PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, - executionType = ExecutionType.SANITY, - description = "Verify admin user gets another user preferences with Rest API and response is successful (200)") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify admin user gets another user preferences with Rest API and response is successful (200)") public void adminUserGetsPeoplePreferencesWithSuccess() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -107,14 +101,13 @@ public class GetPeoplePreferencesSanityTests extends RestTest restPreferenceModelsCollection = restClient.authenticateUser(adminUser).withCoreAPI().usingUser(managerUser).getPersonPreferences(); restClient.assertStatusCodeIs(HttpStatus.OK); - restPreferenceModelsCollection.assertThat().entriesListIsNotEmpty().assertThat().paginationExist() - .and().entriesListContains("id", PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); + restPreferenceModelsCollection.assertThat().entriesListIsNotEmpty().assertThat().paginationExist().and() + .entriesListContains("id", PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); } - + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) @Bug(id = "MNT-16904") - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, - executionType = ExecutionType.SANITY, - description = "Verify manager user is NOT Authorized to gets its preferences with Rest API when authentication fails(401)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized to gets its preferences with Rest API when authentication fails(401)") public void managerUserGetsPeoplePreferencesIsNotAuthorized() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleSanityTests.java index cf34bfe4c..2c0479261 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleSanityTests.java @@ -14,7 +14,6 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) public class GetPeopleSanityTests extends RestTest { UserModel userModel; @@ -24,7 +23,7 @@ public class GetPeopleSanityTests extends RestTest private RestPersonModel personModel; private String domain = "@tas-automation.org"; - @BeforeClass(alwaysRun=true) + @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception { adminUser = dataUser.getAdminUser(); @@ -33,112 +32,80 @@ public class GetPeopleSanityTests extends RestTest searchedUser = dataUser.createRandomTestUser(); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify manager user gets a person with Rest API and response is successful") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user gets a person with Rest API and response is successful") public void managerUserChecksIfPersonIsPresent() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); - personModel = restClient.authenticateUser(managerUser) - .withCoreAPI() - .usingUser(searchedUser) - .getPerson(); + personModel = restClient.authenticateUser(managerUser).withCoreAPI().usingUser(searchedUser).getPerson(); restClient.assertStatusCodeIs(HttpStatus.OK); - personModel.assertThat().field("id").is(searchedUser.getUsername()) - .assertThat().field("firstName").is(searchedUser.getUsername()+" FirstName") - .and().field("email").is(searchedUser.getUsername()+ domain) - .and().field("emailNotificationsEnabled").is("true"); + personModel.assertThat().field("id").is(searchedUser.getUsername()).assertThat().field("firstName").is(searchedUser.getUsername() + " FirstName").and() + .field("email").is(searchedUser.getUsername() + domain).and().field("emailNotificationsEnabled").is("true"); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify collaborator user gets a person with Rest API and response is successful") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify collaborator user gets a person with Rest API and response is successful") public void collaboratorUserChecksIfPersonIsPresent() throws Exception { UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(collaboratorUser, siteModel, UserRole.SiteCollaborator); - personModel = restClient.authenticateUser(collaboratorUser) - .withCoreAPI() - .usingUser(searchedUser) - .getPerson(); + personModel = restClient.authenticateUser(collaboratorUser).withCoreAPI().usingUser(searchedUser).getPerson(); restClient.assertStatusCodeIs(HttpStatus.OK); - personModel.assertThat().field("id").is(searchedUser.getUsername()) - .assertThat().field("firstName").is(searchedUser.getUsername()+" FirstName") - .and().field("email").is(searchedUser.getUsername()+ domain) - .and().field("emailNotificationsEnabled").is("true"); + personModel.assertThat().field("id").is(searchedUser.getUsername()).assertThat().field("firstName").is(searchedUser.getUsername() + " FirstName").and() + .field("email").is(searchedUser.getUsername() + domain).and().field("emailNotificationsEnabled").is("true"); } - @Test(groups = TestGroup.COMMENTS) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify contributor user gets a person with Rest API and response is successful") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.COMMENTS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify contributor user gets a person with Rest API and response is successful") public void contributorUserChecksIfPersonIsPresent() throws Exception { UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(contributorUser, siteModel, UserRole.SiteContributor); - personModel = restClient.authenticateUser(contributorUser) - .withCoreAPI() - .usingUser(searchedUser) - .getPerson(); + personModel = restClient.authenticateUser(contributorUser).withCoreAPI().usingUser(searchedUser).getPerson(); restClient.assertStatusCodeIs(HttpStatus.OK); - personModel.assertThat().field("id").is(searchedUser.getUsername()) - .assertThat().field("firstName").is(searchedUser.getUsername()+" FirstName") - .and().field("email").is(searchedUser.getUsername()+ domain) - .and().field("emailNotificationsEnabled").is("true");; + personModel.assertThat().field("id").is(searchedUser.getUsername()).assertThat().field("firstName").is(searchedUser.getUsername() + " FirstName").and() + .field("email").is(searchedUser.getUsername() + domain).and().field("emailNotificationsEnabled").is("true"); + ; } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify consumer user gets a person with Rest API and response is successful") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify consumer user gets a person with Rest API and response is successful") public void consumerUserChecksIfPersonIsPresent() throws Exception { UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel, UserRole.SiteConsumer); - personModel = restClient.authenticateUser(consumerUser) - .withCoreAPI() - .usingUser(searchedUser) - .getPerson(); + personModel = restClient.authenticateUser(consumerUser).withCoreAPI().usingUser(searchedUser).getPerson(); restClient.assertStatusCodeIs(HttpStatus.OK); - personModel.assertThat().field("id").is(searchedUser.getUsername()) - .assertThat().field("firstName").is(searchedUser.getUsername()+" FirstName") - .and().field("email").is(searchedUser.getUsername()+ domain) - .and().field("emailNotificationsEnabled").is("true");; + personModel.assertThat().field("id").is(searchedUser.getUsername()).assertThat().field("firstName").is(searchedUser.getUsername() + " FirstName").and() + .field("email").is(searchedUser.getUsername() + domain).and().field("emailNotificationsEnabled").is("true"); + ; } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify admin user gets a person with Rest API and response is successful") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify admin user gets a person with Rest API and response is successful") public void adminUserChecksIfPersonIsPresent() throws Exception { - personModel = restClient.authenticateUser(adminUser) - .withCoreAPI() - .usingUser(searchedUser) - .getPerson(); + personModel = restClient.authenticateUser(adminUser).withCoreAPI().usingUser(searchedUser).getPerson(); restClient.assertStatusCodeIs(HttpStatus.OK); - personModel.assertThat().field("id").is(searchedUser.getUsername()) - .assertThat().field("firstName").is(searchedUser.getUsername()+" FirstName") - .and().field("email").is(searchedUser.getUsername()+ domain) - .and().field("emailNotificationsEnabled").is("true");; + personModel.assertThat().field("id").is(searchedUser.getUsername()).assertThat().field("firstName").is(searchedUser.getUsername() + " FirstName").and() + .field("email").is(searchedUser.getUsername() + domain).and().field("emailNotificationsEnabled").is("true"); + ; } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify manager user gets a non existing person with Rest API and person is not found") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user gets a non existing person with Rest API and person is not found") public void managerUserChecksIfNonExistingPersonIsPresent() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); UserModel searchedNonUser = new UserModel("nonexistinguser", DataUser.PASSWORD); - restClient.authenticateUser(managerUser) - .withCoreAPI() - .usingUser(searchedNonUser) - .getPerson(); + restClient.authenticateUser(managerUser).withCoreAPI().usingUser(searchedNonUser).getPerson(); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipCoreTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipCoreTests.java index 7303d4066..66670c3f9 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipCoreTests.java @@ -18,7 +18,7 @@ import org.testng.annotations.Test; /** * Created by Claudia Agache on 11/28/2016. */ -@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + public class GetSiteMembershipCoreTests extends RestTest { UserModel regularUser, publicSiteManager, privateSiteManager, moderatedSiteManager, adminUser; @@ -26,7 +26,7 @@ public class GetSiteMembershipCoreTests extends RestTest private DataUser.ListUserWithRoles publicSiteUsers; private RestSiteEntry restSiteEntry; - @BeforeClass(alwaysRun=true) + @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception { adminUser = dataUser.getAdminUser(); @@ -37,123 +37,98 @@ public class GetSiteMembershipCoreTests extends RestTest privateSite = dataSite.usingAdmin().createPrivateRandomSite(); moderatedSite = dataSite.usingAdmin().createModeratedRandomSite(); - publicSiteUsers = dataUser.addUsersWithRolesToSite(publicSite, - UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + publicSiteUsers = dataUser.addUsersWithRolesToSite(publicSite, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); publicSiteManager = publicSiteUsers.getOneUserWithRole(UserRole.SiteManager); dataUser.usingAdmin().addUserToSite(privateSiteManager, privateSite, UserRole.SiteManager); dataUser.usingAdmin().addUserToSite(moderatedSiteManager, moderatedSite, UserRole.SiteManager); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, - description = "Verify request using -me- string in place of personId returns site membership information for currently authenticated user.") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify request using -me- string in place of personId returns site membership information for currently authenticated user.") public void getSiteMembershipUsingMe() throws Exception { restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)); restSiteEntry = restClient.withCoreAPI().usingMe().getSiteMembership(publicSite); restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteEntry.assertThat().field("role").is(UserRole.SiteCollaborator) - .and().field("id").is(publicSite.getId()) - .and().field("site").isNotEmpty(); + restSiteEntry.assertThat().field("role").is(UserRole.SiteCollaborator).and().field("id").is(publicSite.getId()).and().field("site").isNotEmpty(); } - @Bug(id="REPO-1642", description = "reproduced on 5.2.1 only, it works on 5.2.0") - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, - description = "Verify get site membership for a site returns status 404 when personId does not exist.") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @Bug(id = "REPO-1642", description = "reproduced on 5.2.1 only, it works on 5.2.0") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify get site membership for a site returns status 404 when personId does not exist.") public void getSiteMembershipUsingNonExistentPersonId() throws Exception { UserModel someUser = new UserModel("someUser", DataUser.PASSWORD); restClient.authenticateUser(regularUser).withCoreAPI().usingUser(someUser).getSiteMembership(publicSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "someUser")); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "someUser")); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, - description = "Verify get site membership for a site returns status 404 when siteId does not exist.") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify get site membership for a site returns status 404 when siteId does not exist.") public void getSiteMembershipUsingNonExistentSiteId() throws Exception { SiteModel someSite = new SiteModel("someSite"); restClient.authenticateUser(regularUser).withCoreAPI().usingAuthUser().getSiteMembership(someSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, regularUser.getUsername(), "someSite")); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, regularUser.getUsername(), "someSite")); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, - description = "Verify get site membership for a site returns status 404 when personId is not a site member.") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify get site membership for a site returns status 404 when personId is not a site member.") public void getSiteMembershipForPersonThatIsNotSiteMember() throws Exception { - restClient.authenticateUser(publicSiteManager).withCoreAPI() - .usingUser(regularUser).getSiteMembership(publicSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, regularUser.getUsername(), publicSite.getTitle())); + restClient.authenticateUser(publicSiteManager).withCoreAPI().usingUser(regularUser).getSiteMembership(publicSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, regularUser.getUsername(), publicSite.getTitle())); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, - description = "Verify regular user is not able to retrieve site membership information of a private site member.") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify regular user is not able to retrieve site membership information of a private site member.") public void regularUserIsNotAbleToRetrieveSiteMembershipForPrivateSiteManager() throws Exception { - restClient.authenticateUser(regularUser).withCoreAPI() - .usingUser(privateSiteManager).getSiteMembership(privateSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, privateSiteManager.getUsername(), privateSite.getTitle())); + restClient.authenticateUser(regularUser).withCoreAPI().usingUser(privateSiteManager).getSiteMembership(privateSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, privateSiteManager.getUsername(), privateSite.getTitle())); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, - description = "Verify regular user is able to retrieve site membership information of a moderated site member.") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify regular user is able to retrieve site membership information of a moderated site member.") public void regularUserGetsSiteMembershipForModeratedSiteMember() throws Exception { - restSiteEntry = restClient.authenticateUser(regularUser).withCoreAPI() - .usingUser(moderatedSiteManager).getSiteMembership(moderatedSite); + restSiteEntry = restClient.authenticateUser(regularUser).withCoreAPI().usingUser(moderatedSiteManager).getSiteMembership(moderatedSite); restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteEntry.assertThat().field("role").is(UserRole.SiteManager) - .and().field("id").is(moderatedSite.getId()) - .and().field("site").isNotEmpty(); + restSiteEntry.assertThat().field("role").is(UserRole.SiteManager).and().field("id").is(moderatedSite.getId()).and().field("site").isNotEmpty(); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, - description = "Verify regular user is able to retrieve site membership information of a public site member.") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify regular user is able to retrieve site membership information of a public site member.") public void regularUserGetsSiteMembershipForPublicSiteMember() throws Exception { - restSiteEntry = restClient.authenticateUser(regularUser).withCoreAPI() - .usingUser(publicSiteManager).getSiteMembership(publicSite); + restSiteEntry = restClient.authenticateUser(regularUser).withCoreAPI().usingUser(publicSiteManager).getSiteMembership(publicSite); restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteEntry.assertThat().field("role").is(UserRole.SiteManager) - .and().field("id").is(publicSite.getId()) - .and().field("site").isNotEmpty(); + restSiteEntry.assertThat().field("role").is(UserRole.SiteManager).and().field("id").is(publicSite.getId()).and().field("site").isNotEmpty(); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, - description = "Verify if Admin user is able to retrieve site membership information of him.") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify if Admin user is able to retrieve site membership information of him.") public void adminGetsSiteMembershipForHim() throws Exception { - restSiteEntry = restClient.authenticateUser(adminUser).withCoreAPI() - .usingUser(adminUser).getSiteMembership(privateSite); + restSiteEntry = restClient.authenticateUser(adminUser).withCoreAPI().usingUser(adminUser).getSiteMembership(privateSite); restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteEntry.assertThat().field("role").is(UserRole.SiteManager) - .and().field("id").is(privateSite.getId()) - .and().field("site").isNotEmpty(); + restSiteEntry.assertThat().field("role").is(UserRole.SiteManager).and().field("id").is(privateSite.getId()).and().field("site").isNotEmpty(); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, - description = "Verify if Admin user is able to retrieve site membership information of him.") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify if Admin user is able to retrieve site membership information of him.") public void getSiteMembershipAfterRemovingASiteMember() throws Exception { UserModel publicSiteConsumer = publicSiteUsers.getOneUserWithRole(UserRole.SiteConsumer); - restClient.authenticateUser(publicSiteManager).withCoreAPI() - .usingSite(publicSite).deleteSiteMember(publicSiteConsumer); - restClient.authenticateUser(publicSiteManager).withCoreAPI() - .usingUser(publicSiteConsumer).getSiteMembership(publicSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, publicSiteConsumer.getUsername(), publicSite.getTitle())); + restClient.authenticateUser(publicSiteManager).withCoreAPI().usingSite(publicSite).deleteSiteMember(publicSiteConsumer); + restClient.authenticateUser(publicSiteManager).withCoreAPI().usingUser(publicSiteConsumer).getSiteMembership(publicSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, publicSiteConsumer.getUsername(), publicSite.getTitle())); } } diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipInformationCoreTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipInformationCoreTests.java index 8dbc2f6ca..c315b3424 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipInformationCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipInformationCoreTests.java @@ -13,7 +13,6 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) public class GetSiteMembershipInformationCoreTests extends RestTest { private SiteModel publicSiteModel; @@ -22,7 +21,7 @@ public class GetSiteMembershipInformationCoreTests extends RestTest private UserModel userModel; UserModel leaveSiteUserModel; - @BeforeClass(alwaysRun=true) + @BeforeClass(alwaysRun = true) public void dataPreparation() throws DataPreparationException { userModel = dataUser.createRandomTestUser(); @@ -33,159 +32,108 @@ public class GetSiteMembershipInformationCoreTests extends RestTest dataUser.addUserToSite(leaveSiteUserModel, publicSiteModel, UserRole.SiteCollaborator); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify site manager is able to retrieve site membership information with -me- as personId") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site manager is able to retrieve site membership information with -me- as personId") public void siteManagerCanRetrieveSiteMembershipInformationWithMeAsPersonId() throws Exception { - restClient.authenticateUser(userModel) - .withCoreAPI() - .usingMe() - .getSitesMembershipInformation() - .assertThat().entriesListIsNotEmpty() - .and().paginationExist() - .and().paginationField("count").isNot("0"); + restClient.authenticateUser(userModel).withCoreAPI().usingMe().getSitesMembershipInformation().assertThat().entriesListIsNotEmpty().and() + .paginationExist().and().paginationField("count").isNot("0"); restClient.assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify site manager is not able to retrieve site membership information for a personId that does not exist") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site manager is not able to retrieve site membership information for a personId that does not exist") public void siteManagerCantRetrieveSiteMembershipInformationForAPersonIdThatDoesNotExist() throws Exception { - restClient.authenticateUser(userModel) - .withCoreAPI() - .usingUser(new UserModel("invalidPersonId", "password")) - .getSitesMembershipInformation() + restClient.authenticateUser(userModel).withCoreAPI().usingUser(new UserModel("invalidPersonId", "password")).getSitesMembershipInformation() .assertThat().entriesListIsEmpty(); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); restClient.assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidPersonId")); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify if get site membership information request returns status code 400 when invalid maxItems parameter is used") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify if get site membership information request returns status code 400 when invalid maxItems parameter is used") public void getSiteMembershipInformationRequestReturns400ForInvalidMaxItemsParameter() throws Exception { - restClient.authenticateUser(userModel) - .withParams("maxItems=0") - .withCoreAPI() - .usingAuthUser() - .getSitesMembershipInformation() - .assertThat().entriesListIsEmpty(); + restClient.authenticateUser(userModel).withParams("maxItems=0").withCoreAPI().usingAuthUser().getSitesMembershipInformation().assertThat() + .entriesListIsEmpty(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); restClient.assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); - restClient.withParams("maxItems=-1") - .withCoreAPI() - .usingAuthUser() - .getSitesMembershipInformation() - .assertThat().entriesListIsEmpty(); + restClient.withParams("maxItems=-1").withCoreAPI().usingAuthUser().getSitesMembershipInformation().assertThat().entriesListIsEmpty(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); restClient.assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); - restClient.withParams("maxItems=test") - .withCoreAPI() - .usingAuthUser() - .getSitesMembershipInformation() - .assertThat().entriesListIsEmpty(); + restClient.withParams("maxItems=test").withCoreAPI().usingAuthUser().getSitesMembershipInformation().assertThat().entriesListIsEmpty(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); restClient.assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "test")); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify if get site membership information request returns status code 200 for valid maxItems parameter") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify if get site membership information request returns status code 200 for valid maxItems parameter") public void getSiteMembershipInformationRequestReturns200ForValidMaxItemsParameter() throws Exception { - restClient.authenticateUser(userModel) - .withParams("maxItems=5") - .withCoreAPI() - .usingAuthUser() - .getSitesMembershipInformation() - .assertThat().entriesListIsNotEmpty() - .getPagination().assertThat().field("maxItems").is("5"); + restClient.authenticateUser(userModel).withParams("maxItems=5").withCoreAPI().usingAuthUser().getSitesMembershipInformation().assertThat() + .entriesListIsNotEmpty().getPagination().assertThat().field("maxItems").is("5"); restClient.assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify if get site membership information request returns status code 400 when invalid skipCount parameter is used") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify if get site membership information request returns status code 400 when invalid skipCount parameter is used") public void getSiteMembershipInformationRequestReturns400ForInvalidSkipCountParameter() throws Exception { - restClient.authenticateUser(userModel) - .withParams("skipCount=-1") - .withCoreAPI() - .usingAuthUser() - .getSitesMembershipInformation() - .assertThat().entriesListIsEmpty(); + restClient.authenticateUser(userModel).withParams("skipCount=-1").withCoreAPI().usingAuthUser().getSitesMembershipInformation().assertThat() + .entriesListIsEmpty(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); restClient.assertLastError().containsSummary(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT); - restClient.withParams("skipCount=test") - .withCoreAPI() - .usingAuthUser() - .getSitesMembershipInformation() - .assertThat().entriesListIsEmpty(); + restClient.withParams("skipCount=test").withCoreAPI().usingAuthUser().getSitesMembershipInformation().assertThat().entriesListIsEmpty(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); restClient.assertLastError().containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "test")); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify if get site membership information request returns status code 200 for valid skipCount parameter") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify if get site membership information request returns status code 200 for valid skipCount parameter") public void getSiteMembershipInformationRequestReturns200ForValidSkipCountParameter() throws Exception { - restClient.authenticateUser(userModel) - .withParams("skipCount=1") - .withCoreAPI() - .usingAuthUser() - .getSitesMembershipInformation() - .assertThat().entriesListIsNotEmpty() - .getPagination().assertThat().field("skipCount").is("1"); + restClient.authenticateUser(userModel).withParams("skipCount=1").withCoreAPI().usingAuthUser().getSitesMembershipInformation().assertThat() + .entriesListIsNotEmpty().getPagination().assertThat().field("skipCount").is("1"); restClient.assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify site manager is able to retrieve public sites") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site manager is able to retrieve public sites") public void siteManagerCheckThatPublicSitesAreRetrieved() throws Exception { - restClient.authenticateUser(userModel) - .withCoreAPI() - .usingAuthUser() - .getSitesMembershipInformation() - .assertThat().entriesListContains("id", publicSiteModel.getId()); + restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().getSitesMembershipInformation().assertThat() + .entriesListContains("id", publicSiteModel.getId()); restClient.assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify site manager is able to retrieve moderated sites") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site manager is able to retrieve moderated sites") public void siteManagerCheckThatModeratedSitesAreRetrieved() throws Exception { - restClient.authenticateUser(userModel) - .withCoreAPI() - .usingAuthUser() - .getSitesMembershipInformation() - .assertThat().entriesListContains("id", moderatedSiteModel.getId()); + restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().getSitesMembershipInformation().assertThat() + .entriesListContains("id", moderatedSiteModel.getId()); restClient.assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify site manager is able to retrieve private sites") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site manager is able to retrieve private sites") public void siteManagerCheckThatPrivateSitesAreRetrieved() throws Exception { - restClient.authenticateUser(userModel) - .withCoreAPI() - .usingAuthUser() - .getSitesMembershipInformation() - .assertThat().entriesListContains("id", privateSiteModel.getId()); + restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().getSitesMembershipInformation().assertThat() + .entriesListContains("id", privateSiteModel.getId()); restClient.assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify site member is able to leave site") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site member is able to leave site") public void siteMemberIsAbleToLeaveSite() throws Exception { restClient.authenticateUser(leaveSiteUserModel).withCoreAPI().usingAuthUser().deleteSiteMember(publicSiteModel); - restClient.authenticateUser(leaveSiteUserModel) - .withCoreAPI() - .usingAuthUser() - .getSitesMembershipInformation() - .assertThat().entriesListIsEmpty(); + restClient.authenticateUser(leaveSiteUserModel).withCoreAPI().usingAuthUser().getSitesMembershipInformation().assertThat().entriesListIsEmpty(); restClient.assertStatusCodeIs(HttpStatus.OK); } } diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestCoreTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestCoreTests.java index dfc80a7c7..b34aa4a48 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestCoreTests.java @@ -17,7 +17,7 @@ import org.testng.annotations.Test; * * @author Bogdan Bocancea */ -@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + public class GetSiteMembershipRequestCoreTests extends RestTest { UserModel userModel; @@ -30,136 +30,100 @@ public class GetSiteMembershipRequestCoreTests extends RestTest userModel = dataUser.createRandomTestUser(); siteModel = dataSite.usingUser(userModel).createModeratedRandomSite(); newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember) - .withCoreAPI() - .usingAuthUser().addSiteMembershipRequest(siteModel); + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, - description = "Verify contributor user fails to get all site membership requests of a specific person with Rest API when the authentication fails (401)") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify contributor user fails to get all site membership requests of a specific person with Rest API when the authentication fails (401)") public void unauthorizedContributorUserFailsToGetSiteMembershipRequests() throws Exception { UserModel contributor = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(contributor, siteModel, UserRole.SiteContributor); contributor.setPassword("newpassword"); - restClient.authenticateUser(contributor) - .withCoreAPI() - .usingUser(newMember).getSiteMembershipRequest(siteModel); + restClient.authenticateUser(contributor).withCoreAPI().usingUser(newMember).getSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, - description = "Verify collaborator user fails to get all site membership requests of a specific person with Rest API when the authentication fails (401)") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify collaborator user fails to get all site membership requests of a specific person with Rest API when the authentication fails (401)") public void unauthorizedCollaboratorUserFailsToGetSiteMembershipRequests() throws Exception { UserModel collaborator = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(collaborator, siteModel, UserRole.SiteContributor); collaborator.setPassword("newpassword"); - restClient.authenticateUser(collaborator) - .withCoreAPI() - .usingUser(newMember).getSiteMembershipRequest(siteModel); + restClient.authenticateUser(collaborator).withCoreAPI().usingUser(newMember).getSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, - description = "Verify consumer user fails to get all site membership requests of a specific person with Rest API when the authentication fails (401)") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify consumer user fails to get all site membership requests of a specific person with Rest API when the authentication fails (401)") public void unauthorizedConsumerUserFailsToGetSiteMembershipRequests() throws Exception { UserModel consumer = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(consumer, siteModel, UserRole.SiteContributor); consumer.setPassword("newpassword"); - restClient.authenticateUser(consumer) - .withCoreAPI() - .usingUser(newMember).getSiteMembershipRequest(siteModel); + restClient.authenticateUser(consumer).withCoreAPI().usingUser(newMember).getSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, - description = "Verify a user gets all its own site membership requests using '-me-' with Rest API and response is successful (200)") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify a user gets all its own site membership requests using '-me-' with Rest API and response is successful (200)") public void usingMeGetSiteMembershipRequestsWithSuccess() throws Exception { - restClient.authenticateUser(newMember) - .withCoreAPI() - .usingMe().getSiteMembershipRequest(siteModel) - .assertThat().field("id").is(siteModel.getId()); + restClient.authenticateUser(newMember).withCoreAPI().usingMe().getSiteMembershipRequest(siteModel).assertThat().field("id").is(siteModel.getId()); restClient.assertStatusCodeIs(HttpStatus.OK); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, - description = "Verify site manager can't get site membership requests for inexistent user and response is not found (404)") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site manager can't get site membership requests for inexistent user and response is not found (404)") public void siteManagerCantGetSiteMembershipRequestsInexistentUser() throws Exception { - restClient.authenticateUser(newMember) - .withCoreAPI() - .usingUser(UserModel.getRandomUserModel()).getSiteMembershipRequest(siteModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); + restClient.authenticateUser(newMember).withCoreAPI().usingUser(UserModel.getRandomUserModel()).getSiteMembershipRequest(siteModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, - description = "Verify user can get site membership requests on site with no requests and response is successful (200)") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user can get site membership requests on site with no requests and response is successful (200)") public void userCantGetSiteMembershipRequestsWithNoRequests() throws Exception { UserModel noRequestUser = dataUser.createRandomTestUser(); - restClient.authenticateUser(noRequestUser) - .withCoreAPI() - .usingMe().getSiteMembershipRequest(siteModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, noRequestUser.getUsername(), siteModel.getId())); + restClient.authenticateUser(noRequestUser).withCoreAPI().usingMe().getSiteMembershipRequest(siteModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, noRequestUser.getUsername(), siteModel.getId())); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, - description = "Verify site manager can't get site membership requests on public site and response is not found (404)") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site manager can't get site membership requests on public site and response is not found (404)") public void siteManagerCantGetPublicSiteMembershipRequests() throws Exception { UserModel publicUser = dataUser.createRandomTestUser(); SiteModel publicSite = dataSite.usingUser(userModel).createPublicRandomSite(); - restClient.authenticateUser(publicUser) - .withCoreAPI() - .usingAuthUser().addSiteMembershipRequest(publicSite); - restClient.authenticateUser(userModel) - .withCoreAPI() - .usingUser(publicUser).getSiteMembershipRequest(publicSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, publicUser.getUsername(), publicSite.getId())); + restClient.authenticateUser(publicUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(publicSite); + restClient.authenticateUser(userModel).withCoreAPI().usingUser(publicUser).getSiteMembershipRequest(publicSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, publicUser.getUsername(), publicSite.getId())); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, - description = "Verify site manager can't get site membership requests on private site and response is not found (404)") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site manager can't get site membership requests on private site and response is not found (404)") public void siteManagerCantGetPrivateSiteMembershipRequests() throws Exception { UserModel privateUser = dataUser.createRandomTestUser(); SiteModel privateSite = dataSite.usingUser(userModel).createPrivateRandomSite(); - restClient.authenticateUser(privateUser) - .withCoreAPI() - .usingAuthUser().addSiteMembershipRequest(privateSite); - restClient.authenticateUser(userModel) - .withCoreAPI() - .usingUser(privateUser).getSiteMembershipRequest(privateSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, privateUser.getUsername(), privateSite.getId())); + restClient.authenticateUser(privateUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(privateSite); + restClient.authenticateUser(userModel).withCoreAPI().usingUser(privateUser).getSiteMembershipRequest(privateSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, privateUser.getUsername(), privateSite.getId())); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, - description = "Verify site manager can't get site membership requests for inexistent site and response is not found (404)") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site manager can't get site membership requests for inexistent site and response is not found (404)") public void siteManagerCantGetSiteMembershipRequestsForInexistentSite() throws Exception { SiteModel inexistentSite = SiteModel.getRandomSiteModel(); - restClient.authenticateUser(userModel) - .withCoreAPI() - .usingMe().getSiteMembershipRequest(inexistentSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, userModel.getUsername(), inexistentSite.getId())); + restClient.authenticateUser(userModel).withCoreAPI().usingMe().getSiteMembershipRequest(inexistentSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, userModel.getUsername(), inexistentSite.getId())); } } diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestSanityTests.java index fd5946a50..0bea62243 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestSanityTests.java @@ -19,7 +19,6 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) public class GetSiteMembershipRequestSanityTests extends RestTest { @Autowired @@ -34,101 +33,88 @@ public class GetSiteMembershipRequestSanityTests extends RestTest private UserModel adminUser; - @BeforeClass(alwaysRun=true) + @BeforeClass(alwaysRun = true) public void dataPreparation() throws DataPreparationException { adminUser = dataUser.getAdminUser(); siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); } - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, description = "Verify site manager is able to retrieve site membership request") - @Bug(id="MNT-16557") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site manager is able to retrieve site membership request") + @Bug(id = "MNT-16557") public void siteManagerIsAbleToRetrieveSiteMembershipRequest() throws JsonToModelConversionException, Exception { UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI() - .usingUser(newMember) - .addSiteMembershipRequest(siteModel); - + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingUser(newMember) + .addSiteMembershipRequest(siteModel); + restClient.withCoreAPI().usingUser(newMember).getSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.OK); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, description = "Verify site collaborator is able to retrieve site membership request") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site collaborator is able to retrieve site membership request") @Bug(id = "MNT-16557") public void siteCollaboratorIsAbleToRetrieveSiteMembershipRequest() throws JsonToModelConversionException, Exception { UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI() - .usingUser(newMember) - .addSiteMembershipRequest(siteModel); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingUser(newMember) + .addSiteMembershipRequest(siteModel); restClient.withCoreAPI().usingUser(newMember).getSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.OK); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, description = "Verify site contributor is able to retrieve site membership request") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site contributor is able to retrieve site membership request") @Bug(id = "MNT-16557") public void siteContributorIsAbleToRetrieveSiteMembershipRequest() throws JsonToModelConversionException, Exception { UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) - .withCoreAPI() - .usingUser(newMember) - .addSiteMembershipRequest(siteModel); - + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingUser(newMember) + .addSiteMembershipRequest(siteModel); + restClient.withCoreAPI().usingUser(newMember).getSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.OK); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, description = "Verify site consumer is able to retrieve site membership request") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site consumer is able to retrieve site membership request") @Bug(id = "MNT-16557") public void siteConsumerIsAbleToRetrieveSiteMembershipRequest() throws JsonToModelConversionException, Exception { UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .withCoreAPI() - .usingUser(newMember) - .addSiteMembershipRequest(siteModel); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingUser(newMember) + .addSiteMembershipRequest(siteModel); restClient.withCoreAPI().usingUser(newMember).getSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.OK); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, description = "Verify admin user is able to retrieve site membership request") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify admin user is able to retrieve site membership request") @Bug(id = "MNT-16557") public void adminIsAbleToRetrieveSiteMembershipRequest() throws JsonToModelConversionException, Exception { UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(adminUser) - .withCoreAPI() - .usingUser(newMember) - .addSiteMembershipRequest(siteModel); + restClient.authenticateUser(adminUser).withCoreAPI().usingUser(newMember).addSiteMembershipRequest(siteModel); restClient.withCoreAPI().usingUser(newMember).getSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to retrieve site membership request") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to retrieve site membership request") @Bug(id = "MNT-16557") public void unauthenticatedUserIsNotAbleToRetrieveSiteMembershipRequest() throws JsonToModelConversionException, Exception { UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(new UserModel("random user", "random password")) - .withCoreAPI() - .usingUser(newMember) - .addSiteMembershipRequest(siteModel); + restClient.authenticateUser(new UserModel("random user", "random password")).withCoreAPI().usingUser(newMember).addSiteMembershipRequest(siteModel); restClient.withCoreAPI().usingUser(newMember).getSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); - } + } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsCoreTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsCoreTests.java index b0759398e..cea7ad1c7 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsCoreTests.java @@ -40,39 +40,35 @@ public class GetSiteMembershipRequestsCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.CREATED); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify that for invalid maxItems parameter status code returned is 400.") @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify that for invalid maxItems parameter status code returned is 400.") public void checkInvalidMaxItemsStatusCode() throws Exception { restClient.authenticateUser(adminUser).withParams("maxItems=AB").withCoreAPI().usingUser(newMember).getSiteMembershipRequests(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Invalid paging parameter"); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify that for invalid skipCount parameter status code returned is 400.") @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify that for invalid skipCount parameter status code returned is 400.") public void checkInvalidSkipCountStatusCode() throws Exception { restClient.authenticateUser(adminUser).withParams("skipCount=AB").withCoreAPI().usingUser(newMember).getSiteMembershipRequests(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Invalid paging parameter"); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify that if personId does not exist status code returned is 404.") @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify that if personId does not exist status code returned is 404.") public void ifPersonIdDoesNotExist() throws Exception { UserModel nonexistentUser = dataUser.createRandomTestUser(); nonexistentUser.setUsername("nonexistent"); - + restClient.authenticateUser(adminUser).withCoreAPI().usingUser(nonexistentUser).getSiteMembershipRequests(); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "nonexistent")); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Specify -me- string in place of for request.") @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Specify -me- string in place of for request.") public void replacePersonIdWithMeRequest() throws Exception { meUser = dataUser.createRandomTestUser(); @@ -82,20 +78,20 @@ public class GetSiteMembershipRequestsCoreTests extends RestTest returnedCollection.assertThat().entriesListContains("id", moderatedSite.getId()); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify that if empty personId is used status code returned is 404.") @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify that if empty personId is used status code returned is 404.") public void useEmptyPersonId() throws Exception { UserModel emptyNameMember = dataUser.createRandomTestUser(); emptyNameMember.setUsername(" "); - + restClient.authenticateUser(adminUser).withCoreAPI().usingUser(emptyNameMember).getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary("The entity with id: " + emptyNameMember.getUsername() + " was not found"); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary("The entity with id: " + emptyNameMember.getUsername() + " was not found"); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Get site membership requests to a public site.") @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Get site membership requests to a public site.") public void getRequestsToPublicSite() throws Exception { restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(publicSite); @@ -106,9 +102,8 @@ public class GetSiteMembershipRequestsCoreTests extends RestTest returnedCollection.assertThat().entriesListDoesNotContain("id", publicSite.getId()); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Get site membership requests to a moderated site.") @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Get site membership requests to a moderated site.") public void getRequestsToModeratedSite() throws Exception { newMember1 = dataUser.createRandomTestUser(); @@ -118,9 +113,10 @@ public class GetSiteMembershipRequestsCoreTests extends RestTest returnedCollection.assertThat().entriesListContains("id", moderatedSite.getId()); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Approve request then get requests.") @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @Bug(id="TODO", description="TODO @arusu please fix this NPE automated issue") //TODO @arusu please fix this NPE automated issue + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Approve request then get requests.") + @Bug(id = "TODO", description = "TODO @arusu please fix this NPE automated issue") + // TODO @arusu please fix this NPE automated issue public void approveRequestThenGetRequests() throws Exception { UserModel siteManager = dataUser.createRandomTestUser(); diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java index f338ec1d8..34990bddd 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java @@ -19,7 +19,7 @@ import org.testng.annotations.Test; * * @author Cristina Axinte */ -@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + public class GetSiteMembershipRequestsSanityTests extends RestTest { UserModel userModel; @@ -33,111 +33,88 @@ public class GetSiteMembershipRequestsSanityTests extends RestTest String siteId = RandomData.getRandomName("site"); siteModel = dataSite.usingUser(userModel).createSite(new SiteModel(Visibility.MODERATED, siteId, siteId, siteId, siteId)); newMember = dataUser.createRandomTestUser(); - - restClient.authenticateUser(newMember) - .withCoreAPI() - .usingAuthUser().addSiteMembershipRequest(siteModel); + + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); } + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) @Bug(id = "MNT-16557") - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify manager user gets all site membership requests of a specific person with Rest API and response is successful (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user gets all site membership requests of a specific person with Rest API and response is successful (200)") public void managerUserGetsSiteMembershipRequestsWithSuccess() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); - - restClient.authenticateUser(managerUser) - .withCoreAPI() - .usingUser(newMember).getSiteMembershipRequests().assertThat().entriesListIsNotEmpty(); + + restClient.authenticateUser(managerUser).withCoreAPI().usingUser(newMember).getSiteMembershipRequests().assertThat().entriesListIsNotEmpty(); restClient.assertStatusCodeIs(HttpStatus.OK); } - + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) @Bug(id = "MNT-16557") - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify collaborator user fails to get all site membership requests of another user with Rest API (403)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify collaborator user fails to get all site membership requests of another user with Rest API (403)") public void collaboratorUserFailsToGetSiteMembershipRequestsOfAnotherUser() throws Exception { UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(collaboratorUser, siteModel, UserRole.SiteCollaborator); - - restClient.authenticateUser(collaboratorUser) - .withCoreAPI() - .usingUser(newMember).getSiteMembershipRequests(); + + restClient.authenticateUser(collaboratorUser).withCoreAPI().usingUser(newMember).getSiteMembershipRequests(); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); } - + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) @Bug(id = "MNT-16557") - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify contributor user fails to get all site membership requests of another user with Rest API (403)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify contributor user fails to get all site membership requests of another user with Rest API (403)") public void contributorUserFailsToGetSiteMembershipRequestsOfAnotherUser() throws Exception { UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(contributorUser, siteModel, UserRole.SiteContributor); - - restClient.authenticateUser(contributorUser) - .withCoreAPI() - .usingUser(newMember).getSiteMembershipRequests(); + + restClient.authenticateUser(contributorUser).withCoreAPI().usingUser(newMember).getSiteMembershipRequests(); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); } - + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) @Bug(id = "MNT-16557") - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify consumer user fails to get all site membership requests of another user with Rest API (403)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify consumer user fails to get all site membership requests of another user with Rest API (403)") public void consumerUserFailsToGetSiteMembershipRequestsOfAnotherUser() throws Exception { UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel, UserRole.SiteConsumer); - - restClient.authenticateUser(consumerUser) - .withCoreAPI() - .usingUser(newMember).getSiteMembershipRequests(); + + restClient.authenticateUser(consumerUser).withCoreAPI().usingUser(newMember).getSiteMembershipRequests(); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); } - + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) @Bug(id = "MNT-16557") - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify admin user gets all site membership requests of a specific person with Rest API and response is successful (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify admin user gets all site membership requests of a specific person with Rest API and response is successful (200)") public void adminUserGetsSiteMembershipRequestsWithSuccess() throws Exception { UserModel adminUser = dataUser.getAdminUser(); - - restClient.authenticateUser(adminUser) - .withCoreAPI() - .usingUser(newMember).getSiteMembershipRequests().assertThat().entriesListIsNotEmpty(); + + restClient.authenticateUser(adminUser).withCoreAPI().usingUser(newMember).getSiteMembershipRequests().assertThat().entriesListIsNotEmpty(); restClient.assertStatusCodeIs(HttpStatus.OK); } - + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) @Bug(id = "MNT-16904") - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify manager user fails to get all site membership requests of a specific person with Rest API when the authentication fails (401)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user fails to get all site membership requests of a specific person with Rest API when the authentication fails (401)") public void managerUserNotAuthorizedFailsToGetSiteMembershipRequests() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); managerUser.setPassword("newpassword"); - restClient.authenticateUser(managerUser) - .withCoreAPI() - .usingUser(newMember).getSiteMembershipRequests(); + restClient.authenticateUser(managerUser).withCoreAPI().usingUser(newMember).getSiteMembershipRequests(); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify a user gets all its own site membership requests with Rest API and response is successful (200)") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify a user gets all its own site membership requests with Rest API and response is successful (200)") public void oneUserGetsItsOwnSiteMembershipRequestsWithSuccess() throws Exception { - restClient.authenticateUser(newMember) - .withCoreAPI() - .usingUser(newMember).getSiteMembershipRequests().assertThat().entriesListIsNotEmpty(); + restClient.authenticateUser(newMember).withCoreAPI().usingUser(newMember).getSiteMembershipRequests().assertThat().entriesListIsNotEmpty(); restClient.assertStatusCodeIs(HttpStatus.OK); } } diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java index 86741e5e4..9536bf658 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java @@ -16,106 +16,75 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) public class GetSiteMembershipSanityTests extends RestTest { private SiteModel siteModel; private UserModel adminUser; private ListUserWithRoles usersWithRoles; - @BeforeClass(alwaysRun=true) + @BeforeClass(alwaysRun = true) public void dataPreparation() throws DataPreparationException { adminUser = dataUser.getAdminUser(); siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); - - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, - UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify site manager is able to retrieve site membership information of another user") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site manager is able to retrieve site membership information of another user") public void siteManagerCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI() - .usingUser(adminUser) - .getSiteMembership(siteModel) - .assertThat().field("role").is(UserRole.SiteManager) - .and().field("id").is(siteModel.getId()) - .and().field("site").isNotEmpty(); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingUser(adminUser).getSiteMembership(siteModel) + .assertThat().field("role").is(UserRole.SiteManager).and().field("id").is(siteModel.getId()).and().field("site").isNotEmpty(); restClient.assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify site collaborator is able to retrieve site membership information of another user") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site collaborator is able to retrieve site membership information of another user") public void siteCollaboratorCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI() - .usingUser(adminUser) - .getSiteMembership(siteModel) - .onSite() - .assertThat().field("role").is(UserRole.SiteCollaborator) - .and().field("id").is(siteModel.getId()); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingUser(adminUser) + .getSiteMembership(siteModel).onSite().assertThat().field("role").is(UserRole.SiteCollaborator).and().field("id").is(siteModel.getId()); restClient.assertStatusCodeIs(HttpStatus.OK); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify site contributor is able to retrieve site membership information of another user") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site contributor is able to retrieve site membership information of another user") public void siteContributorCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) - .withCoreAPI() - .usingUser(adminUser) - .getSiteMembership(siteModel) - .assertThat().field("role").is(UserRole.SiteManager) - .and().field("id").is(siteModel.getId()) - .and().field("site").isNotEmpty(); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingUser(adminUser) + .getSiteMembership(siteModel).assertThat().field("role").is(UserRole.SiteManager).and().field("id").is(siteModel.getId()).and().field("site") + .isNotEmpty(); restClient.assertStatusCodeIs(HttpStatus.OK); } - - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site consumer is able to retrieve site membership information of another user") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site consumer is able to retrieve site membership information of another user") public void siteConsumerCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .withCoreAPI() - .usingUser(adminUser) - .getSiteMembership(siteModel) - .assertThat().field("role").is(UserRole.SiteManager) - .and().field("id").is(siteModel.getId()) - .and().field("site").isNotEmpty(); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingUser(adminUser).getSiteMembership(siteModel) + .assertThat().field("role").is(UserRole.SiteManager).and().field("id").is(siteModel.getId()).and().field("site").isNotEmpty(); restClient.assertStatusCodeIs(HttpStatus.OK); } - - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify admin user is able to retrieve site membership information of another user") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify admin user is able to retrieve site membership information of another user") public void adminCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(adminUser) - .withCoreAPI() - .usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .getSiteMembership(siteModel) - .assertThat().field("role").is(UserRole.SiteManager) - .and().field("id").is(siteModel.getId()) - .and().field("site").isNotEmpty(); + restClient.authenticateUser(adminUser).withCoreAPI().usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).getSiteMembership(siteModel) + .assertThat().field("role").is(UserRole.SiteManager).and().field("id").is(siteModel.getId()).and().field("site").isNotEmpty(); restClient.assertStatusCodeIs(HttpStatus.OK); } - - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify unauthenticated user is not able to retrieve site membership information of another user") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to retrieve site membership information of another user") @Bug(id = "MNT-16904") public void unauthenticatedUserCannotRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(new UserModel("random user", "random password")) - .withCoreAPI() - .usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .getSiteMembership(siteModel); + restClient.authenticateUser(new UserModel("random user", "random password")).withCoreAPI() + .usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).getSiteMembership(siteModel); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); - } + } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java index eeb6afc63..a23bb070e 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java @@ -16,107 +16,74 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) public class GetSitesMembershipInformationSanityTests extends RestTest { private SiteModel siteModel; private UserModel adminUser; private ListUserWithRoles usersWithRoles; - @BeforeClass(alwaysRun=true) + @BeforeClass(alwaysRun = true) public void dataPreparation() throws DataPreparationException { adminUser = dataUser.getAdminUser(); siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify site manager is able to retrieve sites membership information of another user") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site manager is able to retrieve sites membership information of another user") public void siteManagerIsAbleToRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI() - .usingUser(adminUser) - .getSitesMembershipInformation() - .assertThat().entriesListIsNotEmpty() - .and().paginationExist() - .and().paginationField("count").isNot("0"); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingUser(adminUser).getSitesMembershipInformation() + .assertThat().entriesListIsNotEmpty().and().paginationExist().and().paginationField("count").isNot("0"); restClient.assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify site collaborator is able to retrieve sites membership information of another user") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site collaborator is able to retrieve sites membership information of another user") public void siteCollaboratorIsAbleToRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI() - .usingUser(adminUser) - .getSitesMembershipInformation() - .assertThat().entriesListIsNotEmpty() - .and().paginationExist() - .and().paginationField("count").isNot("0"); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingUser(adminUser) + .getSitesMembershipInformation().assertThat().entriesListIsNotEmpty().and().paginationExist().and().paginationField("count").isNot("0"); restClient.assertStatusCodeIs(HttpStatus.OK); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify site contributor is able to retrieve sites membership information of another user") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site contributor is able to retrieve sites membership information of another user") public void siteContributorIsAbleToRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) - .withCoreAPI() - .usingUser(adminUser) - .getSitesMembershipInformation() - .assertThat().entriesListIsNotEmpty() - .and().paginationExist() - .and().paginationField("count").isNot("0"); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingUser(adminUser) + .getSitesMembershipInformation().assertThat().entriesListIsNotEmpty().and().paginationExist().and().paginationField("count").isNot("0"); restClient.assertStatusCodeIs(HttpStatus.OK); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify site consumer is able to retrieve sites membership information of another user") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site consumer is able to retrieve sites membership information of another user") public void siteConsumerIsAbleToRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .withCoreAPI() - .usingUser(adminUser) - .getSitesMembershipInformation() - .assertThat().entriesListIsNotEmpty() - .and().paginationExist() - .and().paginationField("count").isNot("0"); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingUser(adminUser) + .getSitesMembershipInformation().assertThat().entriesListIsNotEmpty().and().paginationExist().and().paginationField("count").isNot("0"); restClient.assertStatusCodeIs(HttpStatus.OK); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify admin is able to retrieve sites membership information of another user") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify admin is able to retrieve sites membership information of another user") public void siteAdminIsAbleToRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(adminUser) - .withCoreAPI() - .usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .getSitesMembershipInformation() - .assertThat().entriesListIsNotEmpty() - .and().paginationExist() - .and().paginationField("count").isNot("0"); + restClient.authenticateUser(adminUser).withCoreAPI().usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).getSitesMembershipInformation() + .assertThat().entriesListIsNotEmpty().and().paginationExist().and().paginationField("count").isNot("0"); restClient.assertStatusCodeIs(HttpStatus.OK); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, - description = "Verify that unauthenticated user is not able to retrieve sites membership information") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify that unauthenticated user is not able to retrieve sites membership information") @Bug(id = "MNT-16904") public void unauthenticatedUserCannotRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception { UserModel inexistentUser = new UserModel("inexistent user", "wrong password"); - restClient.authenticateUser(inexistentUser) - .withCoreAPI() - .usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .getSitesMembershipInformation(); + restClient.authenticateUser(inexistentUser).withCoreAPI().usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .getSitesMembershipInformation(); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestCoreTests.java b/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestCoreTests.java index eb523fd29..90ab8b2dd 100644 --- a/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestCoreTests.java @@ -14,7 +14,6 @@ import org.testng.Assert; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) public class UpdateSiteMembershipRequestCoreTests extends RestTest { private SiteModel siteModel; @@ -22,7 +21,7 @@ public class UpdateSiteMembershipRequestCoreTests extends RestTest private String updatedMessage; private RestSiteMembershipRequestModel returnedResponse; - @BeforeClass(alwaysRun=true) + @BeforeClass(alwaysRun = true) public void dataPreparation() throws DataPreparationException { managerUser = dataUser.createRandomTestUser(); @@ -30,135 +29,101 @@ public class UpdateSiteMembershipRequestCoreTests extends RestTest updatedMessage = "Please review my request"; } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, description = "Verify unauthorized user is not able to update user site membership request") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify unauthorized user is not able to update user site membership request") public void unauthorizedUserIsNotAbleToUpdateSiteMembershipRequest() throws Exception { UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember) - .withCoreAPI() - .usingAuthUser() - .addSiteMembershipRequest(siteModel); + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(siteModel); newMember.setPassword("fakePass"); - restClient.withCoreAPI() - .usingUser(newMember).updateSiteMembershipRequest(siteModel, updatedMessage); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + restClient.withCoreAPI().usingUser(newMember).updateSiteMembershipRequest(siteModel, updatedMessage); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, description = "Verify user is able to update its own site membership request using -me-") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is able to update its own site membership request using -me-") public void usingMeUpdateSiteMembershipRequest() throws Exception { UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember) - .withCoreAPI() - .usingAuthUser() - .addSiteMembershipRequest(siteModel); + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(siteModel); returnedResponse = restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(siteModel, updatedMessage); restClient.assertStatusCodeIs(HttpStatus.OK); - returnedResponse.assertMembershipRequestMessageIs(updatedMessage) - .and().field("id").is(siteModel.getId()) - .and().field("modifiedAt").isNotEmpty(); + returnedResponse.assertMembershipRequestMessageIs(updatedMessage).and().field("id").is(siteModel.getId()).and().field("modifiedAt").isNotEmpty(); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, description = "Verify inexistent user is not able to update its own site membership request") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify inexistent user is not able to update its own site membership request") public void inexistentUserCannotUpdateSiteMembershipRequest() throws Exception { UserModel inexistentUser = UserModel.getRandomUserModel(); - restClient.authenticateUser(managerUser) - .withCoreAPI().usingUser(inexistentUser) - .updateSiteMembershipRequest(siteModel, updatedMessage); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, inexistentUser.getUsername())); + restClient.authenticateUser(managerUser).withCoreAPI().usingUser(inexistentUser).updateSiteMembershipRequest(siteModel, updatedMessage); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, inexistentUser.getUsername())); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, description = "Verify user is not able to update its own site membership request for inexistent site") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to update its own site membership request for inexistent site") public void userCannotUpdateSiteMembershipRequestForInexistentSite() throws Exception { SiteModel randomSite = SiteModel.getRandomSiteModel(); UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI() - .usingMe() - .updateSiteMembershipRequest(randomSite, updatedMessage); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, newMember.getUsername(), randomSite.getId())); + restClient.authenticateUser(newMember).withCoreAPI().usingMe().updateSiteMembershipRequest(randomSite, updatedMessage); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, newMember.getUsername(), randomSite.getId())); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, description = "Verify user is able not to update its own site membership request for public site") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is able not to update its own site membership request for public site") public void userCannotUpdateSiteMembershipRequestForPublicSite() throws Exception { SiteModel publicSite = dataSite.usingUser(managerUser).createPublicRandomSite(); UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember) - .withCoreAPI() - .usingAuthUser() - .addSiteMembershipRequest(publicSite); + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(publicSite); restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(publicSite, updatedMessage); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, newMember.getUsername(), publicSite.getId())); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, newMember.getUsername(), publicSite.getId())); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, description = "Verify user is not able to update its own site membership request for private site") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to update its own site membership request for private site") public void userCannotUpdateSiteMembershipRequestForPrivateSite() throws Exception { SiteModel privateSite = dataSite.usingUser(managerUser).createPrivateRandomSite(); UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember) - .withCoreAPI() - .usingAuthUser() - .addSiteMembershipRequest(privateSite); - restClient.withCoreAPI().usingMe() - .updateSiteMembershipRequest(privateSite, updatedMessage); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, newMember.getUsername(), privateSite.getId())); + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(privateSite); + restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(privateSite, updatedMessage); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, newMember.getUsername(), privateSite.getId())); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, description = "Verify user is able to update its own site membership request with initial message") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is able to update its own site membership request with initial message") public void userCanUpdateSiteMembershipRequestWithInitialMessage() throws Exception { UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember) - .withCoreAPI() - .usingAuthUser() - .addSiteMembershipRequest(updatedMessage, siteModel, "Accept me"); + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(updatedMessage, siteModel, "Accept me"); returnedResponse = restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(siteModel, updatedMessage); restClient.assertStatusCodeIs(HttpStatus.OK); - returnedResponse.assertMembershipRequestMessageIs(updatedMessage) - .and().field("id").is(siteModel.getId()) - .and().field("modifiedAt").isNotEmpty(); + returnedResponse.assertMembershipRequestMessageIs(updatedMessage).and().field("id").is(siteModel.getId()).and().field("modifiedAt").isNotEmpty(); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, description = "Verify user is able to update its own site membership request with different message") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is able to update its own site membership request with different message") public void userCanUpdateSiteMembershipRequestWithDifferentMessage() throws Exception { UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember) - .withCoreAPI() - .usingAuthUser() - .addSiteMembershipRequest("", siteModel, "Accept me"); + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest("", siteModel, "Accept me"); returnedResponse = restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(siteModel, updatedMessage); restClient.assertStatusCodeIs(HttpStatus.OK); - returnedResponse.assertMembershipRequestMessageIs(updatedMessage) - .and().field("id").is(siteModel.getId()) - .and().field("modifiedAt").isNotEmpty(); + returnedResponse.assertMembershipRequestMessageIs(updatedMessage).and().field("id").is(siteModel.getId()).and().field("modifiedAt").isNotEmpty(); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, description = "Verify modifiedAt field for update siteMembership request call") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify modifiedAt field for update siteMembership request call") public void verifyModifiedAtForUpdateSiteMembershipRequest() throws Exception { UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember) - .withCoreAPI() - .usingAuthUser() - .addSiteMembershipRequest(siteModel); + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(siteModel); String firstModifiedAt = restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(siteModel, "first message").getModifiedAt(); String secondModifiedAt = restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(siteModel, "second message").getModifiedAt(); Assert.assertNotEquals(firstModifiedAt, secondModifiedAt); diff --git a/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestSanityTests.java index b5cba7f2a..c62d58e12 100644 --- a/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestSanityTests.java @@ -21,7 +21,6 @@ import org.springframework.social.alfresco.api.entities.Site.Visibility; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) public class UpdateSiteMembershipRequestSanityTests extends RestTest { @Autowired @@ -35,155 +34,116 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest private UserModel adminUser; private String updatedMessage; - @BeforeClass(alwaysRun=true) + @BeforeClass(alwaysRun = true) public void dataPreparation() throws DataPreparationException { adminUser = dataUser.getAdminUser(); String siteId = RandomData.getRandomName("site"); siteModel = dataSite.usingUser(adminUser).createSite(new SiteModel(Visibility.MODERATED, siteId, siteId, siteId, siteId)); - - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); updatedMessage = "Please review my request"; } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, description = "Verify user is able to update its own site membership request") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify user is able to update its own site membership request") public void userIsAbleToUpdateItsOwnSiteMembershipRequest() throws JsonToModelConversionException, Exception { UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember) - .withCoreAPI() - .usingAuthUser() - .addSiteMembershipRequest(siteModel); - restClient.withCoreAPI().usingUser(newMember).updateSiteMembershipRequest(siteModel, updatedMessage) - .assertMembershipRequestMessageIs(updatedMessage) - .and().field("id").is(siteModel.getId()) - .and().field("modifiedAt").isNotEmpty(); + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(siteModel); + restClient.withCoreAPI().usingUser(newMember).updateSiteMembershipRequest(siteModel, updatedMessage).assertMembershipRequestMessageIs(updatedMessage) + .and().field("id").is(siteModel.getId()).and().field("modifiedAt").isNotEmpty(); restClient.assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, description = "Verify site manager is not able to update membership request of another user") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site manager is not able to update membership request of another user") @Bug(id = "MNT-16919") public void siteManagerIsNotAbleToUpdateSiteMembershipRequestOfAnotherUser() throws JsonToModelConversionException, Exception { UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember) - .withCoreAPI() - .usingAuthUser() - .addSiteMembershipRequest(siteModel); + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(siteModel); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI() - .usingUser(newMember).updateSiteMembershipRequest(siteModel, updatedMessage); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingUser(newMember) + .updateSiteMembershipRequest(siteModel, updatedMessage); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, description = "Verify site collaborator is not able to update membership request of another user") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site collaborator is not able to update membership request of another user") @Bug(id = "MNT-16919") public void siteCollaboratorIsNotAbleToUpdateSiteMembershipRequestOfAnotherUser() throws JsonToModelConversionException, Exception { UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember) - .withCoreAPI() - .usingAuthUser() - .addSiteMembershipRequest(siteModel); + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(siteModel); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI() - .usingUser(newMember) - .updateSiteMembershipRequest(siteModel, updatedMessage); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingUser(newMember) + .updateSiteMembershipRequest(siteModel, updatedMessage); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, description = "Verify site contributor is not able to update membership request of another user") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site contributor is not able to update membership request of another user") @Bug(id = "MNT-16919") public void siteContributorIsNotAbleToUpdateSiteMembershipRequestOfAnotherUser() throws JsonToModelConversionException, Exception { UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember) - .withCoreAPI() - .usingAuthUser().addSiteMembershipRequest(siteModel); + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(siteModel); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) - .withCoreAPI() - .usingUser(newMember).updateSiteMembershipRequest(siteModel, updatedMessage); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingUser(newMember) + .updateSiteMembershipRequest(siteModel, updatedMessage); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, description = "Verify site consumer is not able to update membership request of another user") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site consumer is not able to update membership request of another user") @Bug(id = "MNT-16919") public void siteConsumerIsNotAbleToUpdateSiteMembershipRequestOfAnotherUser() throws JsonToModelConversionException, Exception { UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember) - .withCoreAPI() - .usingAuthUser() - .addSiteMembershipRequest(siteModel); + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(siteModel); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .withCoreAPI() - .usingUser(newMember) - .updateSiteMembershipRequest(siteModel, updatedMessage); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingUser(newMember) + .updateSiteMembershipRequest(siteModel, updatedMessage); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, description = "Verify one user is not able to update membership request of another user") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify one user is not able to update membership request of another user") @Bug(id = "MNT-16919") public void oneUserIsNotAbleToUpdateSiteMembershipRequestOfAnotherUser() throws JsonToModelConversionException, Exception { UserModel newMember = dataUser.createRandomTestUser(); UserModel otherMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember) - .withCoreAPI() - .usingAuthUser() - .addSiteMembershipRequest(siteModel); + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(siteModel); - restClient.authenticateUser(otherMember) - .withCoreAPI() - .usingUser(newMember) - .updateSiteMembershipRequest(siteModel, updatedMessage); + restClient.authenticateUser(otherMember).withCoreAPI().usingUser(newMember).updateSiteMembershipRequest(siteModel, updatedMessage); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.SANITY, description = "Verify admin is not able to update membership request of another user") + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify admin is not able to update membership request of another user") @Bug(id = "MNT-16919") public void adminIsNotAbleToUpdateSiteMembershipRequestOfAnotherUser() throws JsonToModelConversionException, Exception { UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember) - .withCoreAPI() - .usingAuthUser() - .addSiteMembershipRequest(siteModel); + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(siteModel); - restClient.authenticateUser(adminUser) - .withCoreAPI() - .usingUser(newMember) - .updateSiteMembershipRequest(siteModel, updatedMessage); + restClient.authenticateUser(adminUser).withCoreAPI().usingUser(newMember).updateSiteMembershipRequest(siteModel, updatedMessage); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } } \ No newline at end of file From 3c195fad8330407cf176d7e4f8d46276930ec6f3 Mon Sep 17 00:00:00 2001 From: Andrei Rusu Date: Mon, 12 Dec 2016 10:36:25 +0200 Subject: [PATCH 0754/1491] Added annotations @Test to each test/method for ratings --- .../rest/ratings/AddRatingCoreTests.java | 168 +++++++++--------- .../rest/ratings/AddRatingSanityTests.java | 99 +++++------ .../rest/ratings/DeleteRatingCoreTests.java | 94 +++++----- .../rest/ratings/DeleteRatingSanityTests.java | 150 ++++++++-------- .../rest/ratings/GetRatingCoreTests.java | 11 +- .../rest/ratings/GetRatingSanityTests.java | 95 +++++----- .../rest/ratings/GetRatingsCoreTests.java | 121 +++++++------ .../rest/ratings/GetRatingsSanityTests.java | 84 +++++---- 8 files changed, 423 insertions(+), 399 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/ratings/AddRatingCoreTests.java b/e2e-test/java/org/alfresco/rest/ratings/AddRatingCoreTests.java index 408e5f140..e4744cf90 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/AddRatingCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/AddRatingCoreTests.java @@ -24,7 +24,6 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) public class AddRatingCoreTests extends RestTest { private UserModel userModel; @@ -33,7 +32,7 @@ public class AddRatingCoreTests extends RestTest private FolderModel folderModel; private FileModel document; private ListUserWithRoles usersWithRoles; - private RestRatingModel returnedRatingModel; //placeholder for returned model + private RestRatingModel returnedRatingModel; // placeholder for returned model @BeforeClass(alwaysRun = true) public void dataPreparation() throws DataPreparationException @@ -53,25 +52,29 @@ public class AddRatingCoreTests extends RestTest document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); } - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that if unknown rating scheme is provided status code is 400") + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Verify that if unknown rating scheme is provided status code is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) public void unknownRatingSchemeReturnsBadRequest() throws Exception { restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"invalidRate\"}"); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_RATING, "invalidRate")); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that if nodeId does not exist status code 404 is returned") + + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Verify that if nodeId does not exist status code 404 is returned") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) public void invalidNodeIdReturnsNotFound() throws Exception { document.setNodeRef(RandomStringUtils.randomAlphanumeric(10)); restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, document.getNodeRef())); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, document.getNodeRef())); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that if nodeId provided cannot be rated 405 status code is returned") + + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Verify that if nodeId provided cannot be rated 405 status code is returned") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) @Bug(id = "MNT-16904") public void likeResourceThatCannotBeRated() throws Exception { @@ -80,138 +83,141 @@ public class AddRatingCoreTests extends RestTest restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that manager is able to like a file") + + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Verify that manager is able to like a file") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) public void managerIsAbleToLikeAFile() throws Exception { - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(document).likeDocument(); + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(document) + .likeDocument(); restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("true") - .and().field("id").is("likes") - .and().field("aggregate").isNotEmpty(); + + returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty(); } - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that manager is able to like a folder") + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Verify that manager is able to like a folder") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) public void managerIsAbleToLikeAFolder() throws Exception { - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(folderModel).likeDocument(); + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(folderModel) + .likeDocument(); restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("true") - .and().field("id").is("likes") - .and().field("aggregate").isNotEmpty(); + + returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty(); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that manager is able to rate a folder") + + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Verify that manager is able to rate a folder") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) public void managerIsAbleToRateAFolder() throws Exception { - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(folderModel).rateStarsToDocument(5); + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(folderModel) + .rateStarsToDocument(5); restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("5") - .and().field("id").is("fiveStar") - .and().field("aggregate").isNotEmpty(); + + returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that manager is able to rate a file") + + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Verify that manager is able to rate a file") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) public void managerIsAbleToRateAFile() throws Exception { - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(document).rateStarsToDocument(5); + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(document) + .rateStarsToDocument(5); restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("5") - .and().field("id").is("fiveStar") - .and().field("aggregate").isNotEmpty(); + + returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that adding like again has no effect on a file") + + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Verify that adding like again has no effect on a file") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) public void fileCanBeLikedTwice() throws Exception { restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); restClient.assertStatusCodeIs(HttpStatus.CREATED); returnedRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("true") - .and().field("id").is("likes") - .and().field("aggregate").isNotEmpty(); + + returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty(); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that adding rate again has no effect on a file") + + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Verify that adding rate again has no effect on a file") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) public void fileCanBeRatedTwice() throws Exception { restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).rateStarsToDocument(5); restClient.assertStatusCodeIs(HttpStatus.CREATED); returnedRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).rateStarsToDocument(5); restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("5") - .and().field("id").is("fiveStar") - .and().field("aggregate").isNotEmpty(); + + returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that rate is not added if empty rating object is provided") + + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Verify that rate is not added if empty rating object is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) public void addRateUsingEmptyRatingObject() throws Exception { restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating(""); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.NO_CONTENT, - "No content to map to Object due to end of input")); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.NO_CONTENT, "No content to map to Object due to end of input")); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that if empty rate id is provided status code is 400") + + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Verify that if empty rate id is provided status code is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) public void addRateUsingEmptyValueForId() throws Exception { restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"\"}"); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.NO_CONTENT, - "N/A (through reference chain: org.alfresco.rest.api.model.NodeRating[\"id\"])")); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.NO_CONTENT, "N/A (through reference chain: org.alfresco.rest.api.model.NodeRating[\"id\"])")); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that if empty rating is provided status code is 400") + + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Verify that if empty rating is provided status code is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) public void addRateUsingEmptyValueForMyRating() throws Exception { restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"likes\", \"myRating\":\"\"}"); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.NULL_LIKE_RATING)); - + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"fiveStar\", \"myRating\":\"\"}"); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.NULL_FIVESTAR_RATING)); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that user is not able to rate a comment") + + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Verify that user is not able to rate a comment") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) public void addRatingToAComment() throws Exception { RestCommentModel comment = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addComment("This is a comment"); document.setNodeRef(comment.getId()); - + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(String.format(RestErrorModel.CANNOT_RATE)); - + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).rateStarsToDocument(5); restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(String.format(RestErrorModel.CANNOT_RATE)); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that user is not able to rate a tag") + + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Verify that user is not able to rate a tag") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) public void addRatingToATag() throws Exception { RestTagModel tag = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addTag("randomTag"); document.setNodeRef(tag.getId()); - + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(String.format(RestErrorModel.CANNOT_RATE)); - + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).rateStarsToDocument(5); restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(String.format(RestErrorModel.CANNOT_RATE)); } - + } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java index 5f49db8c7..3bf0198ed 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java @@ -16,7 +16,6 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) public class AddRatingSanityTests extends RestTest { private UserModel userModel; @@ -25,7 +24,7 @@ public class AddRatingSanityTests extends RestTest private FolderModel folderModel; private FileModel document; private ListUserWithRoles usersWithRoles; - private RestRatingModel returnedRatingModel; //placeholder for returned model + private RestRatingModel returnedRatingModel; // placeholder for returned model @BeforeClass(alwaysRun = true) public void dataPreparation() throws DataPreparationException @@ -47,68 +46,66 @@ public class AddRatingSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role is able to post like rating to a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) public void managerIsAbleToLikeDocument() throws Exception { - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(document).likeDocument(); + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(document) + .likeDocument(); restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("true") - .and().field("id").is("likes") - .and().field("aggregate").isNotEmpty(); + + returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty(); } @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Collaborator role is able to post like rating to a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) public void collaboratorIsAbleToLikeDocument() throws Exception { - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingResource(document).likeDocument(); + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(document) + .likeDocument(); restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("true") - .and().field("id").is("likes") - .and().field("aggregate").isNotEmpty(); + + returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty(); } @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Contributor role is able to post like rating to a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) public void contributorIsAbleToLikeDocument() throws Exception { - returnedRatingModel =restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingResource(document).likeDocument(); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("true") - .and().field("id").is("likes") - .and().field("aggregate").isNotEmpty(); + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingResource(document) + .likeDocument(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty(); } @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role is able to post like rating to a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) public void consumerIsAbleToLikeDocument() throws Exception { - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingResource(document).likeDocument(); + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingResource(document) + .likeDocument(); restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("true") - .and().field("id").is("likes") - .and().field("aggregate").isNotEmpty(); + + returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty(); } @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify admin user is able to post like rating to a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) public void adminIsAbleToLikeDocument() throws Exception { returnedRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("true") - .and().field("id").is("likes") - .and().field("aggregate").isNotEmpty(); + + returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty(); } @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to post like rating to a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) @Bug(id = "MNT-16904") public void unauthenticatedUserIsNotAbleToLikeDocument() throws Exception { @@ -118,62 +115,62 @@ public class AddRatingSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role is able to post stars rating to a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) public void managerIsAbleToAddStarsToDocument() throws Exception { - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(document).rateStarsToDocument(5); + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(document) + .rateStarsToDocument(5); restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedRatingModel.assertThat().field("myRating").is("5") - .and().field("id").is("fiveStar") - .and().field("aggregate").isNotEmpty(); + returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); } @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Collaborator role is able to post stars rating to a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) public void collaboratorIsAbleToAddStarsToDocument() throws Exception { - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(document).rateStarsToDocument(5); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedRatingModel.assertThat().field("myRating").is("5") - .and().field("id").is("fiveStar") - .and().field("aggregate").isNotEmpty(); - + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(document) + .rateStarsToDocument(5); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); + } @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Contributor role is able to post stars rating to a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) public void contributorIsAbleToAddStarsToDocument() throws Exception { - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingResource(document).rateStarsToDocument(5); + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingResource(document) + .rateStarsToDocument(5); restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedRatingModel.assertThat().field("myRating").is("5") - .and().field("id").is("fiveStar") - .and().field("aggregate").isNotEmpty(); + returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); } @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role is able to post stars rating to a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) public void consumerIsAbleToAddStarsToDocument() throws Exception { - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingResource(document).rateStarsToDocument(5); + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingResource(document) + .rateStarsToDocument(5); restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedRatingModel.assertThat().field("myRating").is("5") - .and().field("id").is("fiveStar") - .and().field("aggregate").isNotEmpty(); + returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); } @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify admin user is able to post stars rating to a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) public void adminIsAbleToAddStarsToDocument() throws Exception - { + { returnedRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).rateStarsToDocument(3); restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedRatingModel.assertThat().field("myRating").is(String.valueOf(3)) - .and().field("id").is("fiveStar") - .and().field("aggregate").isNotEmpty(); + returnedRatingModel.assertThat().field("myRating").is(String.valueOf(3)).and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); } @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to post stars rating to a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) @Bug(id = "MNT-16904") public void unauthenticatedUserIsNotAbleToRateStarsToDocument() throws Exception { diff --git a/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingCoreTests.java b/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingCoreTests.java index 313bde263..00b688664 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingCoreTests.java @@ -20,7 +20,6 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) public class DeleteRatingCoreTests extends RestTest { @@ -31,74 +30,79 @@ public class DeleteRatingCoreTests extends RestTest private ListUserWithRoles usersWithRoles; private RestRatingModel returnedRatingModel; - @BeforeClass(alwaysRun=true) + @BeforeClass(alwaysRun = true) public void dataPreparation() throws DataPreparationException { adminUser = dataUser.getAdminUser(); siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); - - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, - UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); } - + @BeforeMethod() - public void setUp() throws DataPreparationException, Exception { + public void setUp() throws DataPreparationException, Exception + { folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); } - @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that if ratingId provided is unknown status code returned is 400") + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Verify that if ratingId provided is unknown status code returned is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) public void deleteInvalidRating() throws Exception { restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).deleteInvalidRating("random_rating"); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_RATING, "random_rating")); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that if nodeId does not exist status code returned is 404") + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Verify that if nodeId does not exist status code returned is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) public void deleteRatingUsingInvalidDocument() throws Exception { document.setNodeRef("random_value"); restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).deleteLikeRating(); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "random_value")); } - - @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Delete rating stars for a document that was not rated") + + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Delete rating stars for a document that was not rated") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) @Bug(id = "MNT-17181") public void deleteStarsForANotRatedDocument() throws Exception { restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).deleteFiveStarRating(); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); } - - @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Delete like rating for a document that was not liked") + + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Delete like rating for a document that was not liked") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) @Bug(id = "MNT-17181") public void deleteLikeForANotLikedDocument() throws Exception { restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).deleteLikeRating(); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Delete like for a file then add it again") + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Delete like for a file then add it again") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) public void likeDocumentAfterLikeRatingIsDeleted() throws Exception { restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); restClient.withCoreAPI().usingResource(document).deleteLikeRating(); returnedRatingModel = restClient.withCoreAPI().usingResource(document).likeDocument(); - + restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("true") - .and().field("id").is("likes") - .and().field("aggregate").isNotEmpty(); + + returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty(); } - - @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Delete stars for a file then add them again") + + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Delete stars for a file then add them again") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) public void addStarsToDocumentAfterRatingIsDeleted() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(document).rateStarsToDocument(5); @@ -106,16 +110,15 @@ public class DeleteRatingCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); returnedRatingModel = restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - + restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("5") - .and().field("id").is("fiveStar") - .and().field("aggregate").isNotEmpty(); + + returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); } - - @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Delete rating of a document using site manager") + + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Delete rating of a document using site manager") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) public void deleteDocumentRatingUsingManager() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(document).rateStarsToDocument(5); @@ -124,17 +127,18 @@ public class DeleteRatingCoreTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(document).deleteFiveStarRating(); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(document).deleteLikeRating(); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingResource(document).getRatings().assertNodeIsLiked().assertNodeHasFiveStarRating(); + + restClient.withCoreAPI().usingResource(document).getRatings().assertNodeIsLiked().assertNodeHasFiveStarRating(); } - - @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "One user is not able to delete like of another user") + + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "One user is not able to delete like of another user") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) public void deleteLikeOfAnotherUser() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingResource(document).likeDocument(); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(document).deleteLikeRating(); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingResource(document).getRatings().assertNodeIsLiked(); + restClient.withCoreAPI().usingResource(document).getRatings().assertNodeIsLiked(); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java index e028d229e..a9bbe9f5b 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java @@ -15,7 +15,6 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) public class DeleteRatingSanityTests extends RestTest { @@ -26,177 +25,172 @@ public class DeleteRatingSanityTests extends RestTest private ListUserWithRoles usersWithRoles; private RestRatingModelsCollection returnedRatingModelCollection; - @BeforeClass(alwaysRun=true) + @BeforeClass(alwaysRun = true) public void dataPreparation() throws DataPreparationException { adminUser = dataUser.getAdminUser(); siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); - - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, - UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); } - + @BeforeMethod() - public void setUp() throws DataPreparationException, Exception { + public void setUp() throws DataPreparationException, Exception + { folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); } - @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, - description = "Verify user with Manager role is able to remove its own rating of a document") + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role is able to remove its own rating of a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) public void managerIsAbleToDeleteItsOwnRatings() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); restClient.withCoreAPI().usingResource(document).likeDocument(); restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - + restClient.withCoreAPI().usingResource(document).deleteLikeRating(); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - + restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - + returnedRatingModelCollection = restClient.withCoreAPI().usingResource(document).getRatings(); restClient.assertStatusCodeIs(HttpStatus.OK); - returnedRatingModelCollection.assertNodeIsNotLiked() - .assertNodeHasNoFiveStarRating() - .and().entriesListIsNotEmpty() - .and().paginationExist(); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, - description = "Verify user with Collaborator role is able to remove its own rating of a document") + returnedRatingModelCollection.assertNodeIsNotLiked().assertNodeHasNoFiveStarRating().and().entriesListIsNotEmpty().and().paginationExist(); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Collaborator role is able to remove its own rating of a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) public void collaboratorIsAbleToDeleteItsOwnRatings() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); restClient.withCoreAPI().usingResource(document).likeDocument(); restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - + restClient.withCoreAPI().usingResource(document).deleteLikeRating(); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - + restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - + returnedRatingModelCollection = restClient.withCoreAPI().usingResource(document).getRatings(); restClient.assertStatusCodeIs(HttpStatus.OK); - returnedRatingModelCollection.assertNodeIsNotLiked() - .assertNodeHasNoFiveStarRating() - .and().entriesListIsNotEmpty() - .and().paginationExist(); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, - description = "Verify user with Contributor role is able to remove its own rating of a document") + returnedRatingModelCollection.assertNodeIsNotLiked().assertNodeHasNoFiveStarRating().and().entriesListIsNotEmpty().and().paginationExist(); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Contributor role is able to remove its own rating of a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) public void contributorIsAbleToDeleteItsOwnRatings() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); restClient.withCoreAPI().usingResource(document).likeDocument(); restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - + restClient.withCoreAPI().usingResource(document).deleteLikeRating(); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - + restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - + returnedRatingModelCollection = restClient.withCoreAPI().usingResource(document).getRatings(); restClient.assertStatusCodeIs(HttpStatus.OK); - returnedRatingModelCollection.assertNodeIsNotLiked() - .assertNodeHasNoFiveStarRating() - .and().entriesListIsNotEmpty() - .and().paginationExist(); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, - description = "Verify user with Consumer role is able to remove its own rating of a document") + returnedRatingModelCollection.assertNodeIsNotLiked().assertNodeHasNoFiveStarRating().and().entriesListIsNotEmpty().and().paginationExist(); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role is able to remove its own rating of a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) public void consumerIsAbleToDeleteItsOwnRatings() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); restClient.withCoreAPI().usingResource(document).likeDocument(); restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - + restClient.withCoreAPI().usingResource(document).deleteLikeRating(); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - + restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - + returnedRatingModelCollection = restClient.withCoreAPI().usingResource(document).getRatings(); restClient.assertStatusCodeIs(HttpStatus.OK); - returnedRatingModelCollection.assertNodeIsNotLiked() - .assertNodeHasNoFiveStarRating() - .and().entriesListIsNotEmpty() - .and().paginationExist(); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, - description = "Verify admin user is able to remove its own rating of a document") + returnedRatingModelCollection.assertNodeIsNotLiked().assertNodeHasNoFiveStarRating().and().entriesListIsNotEmpty().and().paginationExist(); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify admin user is able to remove its own rating of a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) public void adminIsAbleToDeleteItsOwnRatings() throws Exception { - document = dataContent.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + document = dataContent.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).usingResource(folderModel) + .createContent(DocumentType.TEXT_PLAIN); restClient.authenticateUser(adminUser); restClient.withCoreAPI().usingResource(document).likeDocument(); restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - + restClient.withCoreAPI().usingResource(document).deleteLikeRating(); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - + restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - + returnedRatingModelCollection = restClient.withCoreAPI().usingResource(document).getRatings(); restClient.assertStatusCodeIs(HttpStatus.OK); - returnedRatingModelCollection.assertNodeIsNotLiked() - .assertNodeHasNoFiveStarRating() - .and().entriesListIsNotEmpty() - .and().paginationExist(); + returnedRatingModelCollection.assertNodeIsNotLiked().assertNodeHasNoFiveStarRating().and().entriesListIsNotEmpty().and().paginationExist(); } @Bug(id = "MNT-16904") - @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, - description = "Verify unauthenticated user is not able to remove its own rating of a document") + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to remove its own rating of a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) public void unauthenticatedUserIsNotAbleToDeleteRatings() throws Exception { - document = dataContent.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + document = dataContent.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).usingResource(folderModel) + .createContent(DocumentType.TEXT_PLAIN); restClient.authenticateUser(adminUser); - + restClient.withCoreAPI().usingResource(document).likeDocument(); restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - + restClient.authenticateUser(new UserModel("random user", "random password")); - + restClient.withCoreAPI().usingResource(document).deleteLikeRating(); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); - + restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, - description = "Verify one user is not able to remove rating added by another user") + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify one user is not able to remove rating added by another user") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) @Bug(id = "ACE-5459") public void oneUserIsNotAbleToDeleteRatingsOfAnotherUser() throws Exception { UserModel userA = dataUser.createRandomTestUser(); UserModel userB = dataUser.createRandomTestUser(); - + restClient.authenticateUser(userA); - + restClient.withCoreAPI().usingResource(document).likeDocument(); restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - + restClient.authenticateUser(userB); - + restClient.authenticateUser(userB).withCoreAPI().usingResource(document).deleteLikeRating(); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); - + restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); - } + } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/ratings/GetRatingCoreTests.java b/e2e-test/java/org/alfresco/rest/ratings/GetRatingCoreTests.java index 38c120997..5b17497de 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/GetRatingCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/GetRatingCoreTests.java @@ -20,7 +20,6 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) public class GetRatingCoreTests extends RestTest { private SiteModel siteModel; @@ -45,16 +44,19 @@ public class GetRatingCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Check that using invalid ratingId for get rating call returns status code 400.") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) public void checkInvalidRatingIdStatusCode() throws Exception { restClient.authenticateUser(adminUserModel).withCoreAPI(); RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "nodes/{nodeId}/ratings/{ratingId}", document.getNodeRef(), "invalid ratingId"); restClient.processModel(RestRatingModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_RATING, "invalid ratingId")); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.INVALID_RATING, "invalid ratingId")); } @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Check that using invalid node ID for get rating call returns status code 404.") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) public void getRatingUsingInvalidNodeId() throws Exception { document.setNodeRef(RandomStringUtils.randomAlphanumeric(20)); @@ -66,6 +68,7 @@ public class GetRatingCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Get rating of a file that has only likes.") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) public void getRatingOfFileThatHasOnlyLikes() throws Exception { restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).likeDocument(); @@ -82,6 +85,7 @@ public class GetRatingCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Get rating of a file that has only stars.") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) public void getRatingOfFileThatHasOnlyStars() throws Exception { restClient.authenticateUser(userModel).withCoreAPI().usingResource(document).rateStarsToDocument(5); @@ -98,6 +102,7 @@ public class GetRatingCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Get rating of a file that has likes and stars.") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) public void getRatingOfFileThatHasLikesAndStars() throws Exception { restClient.authenticateUser(userModel).withCoreAPI().usingResource(document).likeDocument(); @@ -116,6 +121,7 @@ public class GetRatingCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Get rating of a folder that has only likes.") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) public void getRatingOfFolderThatHasOnlyLikes() throws Exception { firstFolderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); @@ -129,6 +135,7 @@ public class GetRatingCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Get rating of a file that has no ratings.") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) public void getRatingOfFileThatHasNoRatings() throws Exception { returnedRatingModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getLikeRating(); diff --git a/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java index 4b6a744b2..a67460be9 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java @@ -20,110 +20,116 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) public class GetRatingSanityTests extends RestTest { private SiteModel siteModel; private UserModel adminUser; private FolderModel folderModel; - private FileModel document; + private FileModel document; private ListUserWithRoles usersWithRoles; private RestRatingModel restRatingModel; - - @BeforeClass(alwaysRun=true) + + @BeforeClass(alwaysRun = true) public void dataPreparation() throws DataPreparationException { adminUser = dataUser.getAdminUser(); siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); - - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, - UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); } - + @BeforeMethod() - public void setUp() throws DataPreparationException, Exception { + public void setUp() throws DataPreparationException, Exception + { folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); } - @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, - description = "Verify user with Manager role is able to retrieve rating of a document") + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role is able to retrieve rating of a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) public void managerIsAbleToRetrieveRating() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); restClient.withCoreAPI().usingResource(document).likeDocument(); restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - + restRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating(); restClient.assertStatusCodeIs(HttpStatus.OK); restRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); - + restRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); restClient.assertStatusCodeIs(HttpStatus.OK); restRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").is("5"); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, - description = "Verify user with Collaborator role is able to retrieve rating of a document") + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Collaborator role is able to retrieve rating of a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) public void collaboratorIsAbleToRetrieveRating() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); restClient.withCoreAPI().usingResource(document).likeDocument(); restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - + restRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating(); restClient.assertStatusCodeIs(HttpStatus.OK); restRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); - + restRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); restClient.assertStatusCodeIs(HttpStatus.OK); restRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").is("5"); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, - description = "Verify user with Contributor role is able to retrieve rating of a document") + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Contributor role is able to retrieve rating of a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) public void contributorIsAbleToRetrieveRating() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); restClient.withCoreAPI().usingResource(document).likeDocument(); restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - + restRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating(); restClient.assertStatusCodeIs(HttpStatus.OK); restRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); - + restRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); restClient.assertStatusCodeIs(HttpStatus.OK); restRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").is("5"); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, - description = "Verify user with Consumer role is able to retrieve rating of a document") + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role is able to retrieve rating of a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) public void consumerIsAbleToRetrieveRating() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); restClient.withCoreAPI().usingResource(document).likeDocument(); restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - + restRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating(); restClient.assertStatusCodeIs(HttpStatus.OK); restRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); - + restRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); restClient.assertStatusCodeIs(HttpStatus.OK); restRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").is("5"); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, - description = "Verify admin user is able to retrieve rating of a document") + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify admin user is able to retrieve rating of a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) public void adminIsAbleToRetrieveRating() throws Exception { - document = dataContent.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + document = dataContent.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingResource(folderModel) + .createContent(DocumentType.TEXT_PLAIN); restClient.authenticateUser(adminUser); restClient.withCoreAPI().usingResource(document).likeDocument(); @@ -132,14 +138,15 @@ public class GetRatingSanityTests extends RestTest restRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating(); restClient.assertStatusCodeIs(HttpStatus.OK); restRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); - + restRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); restClient.assertStatusCodeIs(HttpStatus.OK); restRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").is("5"); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, - description = "Verify unauthenticated user is not able to retrieve rating of a document") + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to retrieve rating of a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) @Bug(id = "MNT-16904") public void unauthenticatedUserIsNotAbleToRetrieveRating() throws Exception { @@ -148,11 +155,11 @@ public class GetRatingSanityTests extends RestTest restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); restClient.authenticateUser(new UserModel("random user", "random password")); - + restClient.withCoreAPI().usingResource(document).getLikeRating(); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - + restClient.withCoreAPI().usingResource(document).getFiveStarRating(); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } + } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/ratings/GetRatingsCoreTests.java b/e2e-test/java/org/alfresco/rest/ratings/GetRatingsCoreTests.java index 93f924e67..54d0da2b4 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/GetRatingsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/GetRatingsCoreTests.java @@ -17,79 +17,82 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) -public class GetRatingsCoreTests extends RestTest { - private SiteModel siteModel; - private UserModel adminUserModel, userModel; - private FileModel document; - private RestRatingModel returnedRatingModel; +public class GetRatingsCoreTests extends RestTest +{ + private SiteModel siteModel; + private UserModel adminUserModel, userModel; + private FileModel document; + private RestRatingModel returnedRatingModel; - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws DataPreparationException { - adminUserModel = dataUser.getAdminUser(); - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingAdmin().createPublicRandomSite(); - } + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws DataPreparationException + { + adminUserModel = dataUser.getAdminUser(); + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingAdmin().createPublicRandomSite(); + } - @BeforeMethod(alwaysRun = true) - public void setUp() throws DataPreparationException, Exception { - document = dataContent.usingSite(siteModel).usingAdmin() - .createContent(CMISUtil.DocumentType.TEXT_PLAIN); - } + @BeforeMethod(alwaysRun = true) + public void setUp() throws DataPreparationException, Exception + { + document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); + } - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Check that rating for invalid maxItems status code is 400") - public void checkInvalidMaxItemsStatusCode() throws Exception { + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Check that rating for invalid maxItems status code is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) + public void checkInvalidMaxItemsStatusCode() throws Exception + { - restClient.authenticateUser(adminUserModel).withParams("maxItems=0").withCoreAPI().usingResource(document) - .getLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary("Only positive values supported for maxItems"); - } + restClient.authenticateUser(adminUserModel).withParams("maxItems=0").withCoreAPI().usingResource(document).getLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Only positive values supported for maxItems"); + } - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Check that rating for invalid skipCount status code is 400") - public void checkInvalidSkipCountStatusCode() throws Exception { + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Check that rating for invalid skipCount status code is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) + public void checkInvalidSkipCountStatusCode() throws Exception + { - restClient.authenticateUser(adminUserModel).withParams("skipCount=AB").withCoreAPI().usingResource(document) - .getLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary("Invalid paging parameter skipCount:AB"); - } + restClient.authenticateUser(adminUserModel).withParams("skipCount=AB").withCoreAPI().usingResource(document).getLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Invalid paging parameter skipCount:AB"); + } - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "If nodeId does not exist status code is 404 when a document is liked") - public void addLikeUsingInvalidNodeId() throws Exception { + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "If nodeId does not exist status code is 404 when a document is liked") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) + public void addLikeUsingInvalidNodeId() throws Exception + { - document.setNodeRef(RandomStringUtils.randomAlphanumeric(20)); - returnedRatingModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document) - .likeDocument(); + document.setNodeRef(RandomStringUtils.randomAlphanumeric(20)); + returnedRatingModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).likeDocument(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, document.getNodeRef())); - } + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, document.getNodeRef())); + } - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Check that rating value is TRUE for a like rating") - public void checkRatingValueIsTrueForLikedDoc() throws Exception { + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Check that rating value is TRUE for a like rating") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) + public void checkRatingValueIsTrueForLikedDoc() throws Exception + { - returnedRatingModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document) - .likeDocument(); - restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedRatingModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).likeDocument(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes"); - } + returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes"); + } - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Check that rating value is an INTEGER value for stars rating") - public void checkRatingValueIsIntegerForStarsRating() throws Exception { + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Check that rating value is an INTEGER value for stars rating") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) + public void checkRatingValueIsIntegerForStarsRating() throws Exception + { - returnedRatingModel = restClient.authenticateUser(userModel).withCoreAPI().usingResource(document) - .rateStarsToDocument(5); - restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedRatingModel = restClient.authenticateUser(userModel).withCoreAPI().usingResource(document).rateStarsToDocument(5); + restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar") - .and().field("aggregate").isNotEmpty(); - } + returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); + } } diff --git a/e2e-test/java/org/alfresco/rest/ratings/GetRatingsSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/GetRatingsSanityTests.java index 97f1e8d30..b5c809f4e 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/GetRatingsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/GetRatingsSanityTests.java @@ -19,94 +19,99 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) public class GetRatingsSanityTests extends RestTest { private SiteModel siteModel; private UserModel adminUser; private FolderModel folderModel; - private FileModel document; + private FileModel document; private ListUserWithRoles usersWithRoles; private RestRatingModelsCollection restRatingModelsCollection; - - @BeforeClass(alwaysRun=true) + + @BeforeClass(alwaysRun = true) public void dataPreparation() throws DataPreparationException { adminUser = dataUser.getAdminUser(); siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); - - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, - UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); } - + @BeforeMethod() - public void setUp() throws DataPreparationException, Exception { + public void setUp() throws DataPreparationException, Exception + { folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); } - @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, - description = "Manager is able to retrieve document ratings") + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Manager is able to retrieve document ratings") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) public void managerIsAbleToRetrieveDocumentRatings() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); restClient.withCoreAPI().usingResource(document).likeDocument(); restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - + restRatingModelsCollection = restClient.withCoreAPI().usingResource(document).getRatings(); restClient.assertStatusCodeIs(HttpStatus.OK); restRatingModelsCollection.assertNodeHasFiveStarRating().assertNodeIsLiked(); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, - description = "Collaborator is able to retrieve document ratings") + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Collaborator is able to retrieve document ratings") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) public void collaboratorIsAbleToRetrieveDocumentRatings() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); restClient.withCoreAPI().usingResource(document).likeDocument(); restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - + restRatingModelsCollection = restClient.withCoreAPI().usingResource(document).getRatings(); restClient.assertStatusCodeIs(HttpStatus.OK); restRatingModelsCollection.assertNodeHasFiveStarRating().assertNodeIsLiked(); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, - description = "Contributor is able to retrieve document ratings") + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Contributor is able to retrieve document ratings") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) public void contributorIsAbleToRetrieveDocumentRatings() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); restClient.withCoreAPI().usingResource(document).likeDocument(); restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - + restRatingModelsCollection = restClient.withCoreAPI().usingResource(document).getRatings(); restClient.assertStatusCodeIs(HttpStatus.OK); restRatingModelsCollection.assertNodeHasFiveStarRating().assertNodeIsLiked(); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, - description = "Consumer is able to retrieve document ratings") + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Consumer is able to retrieve document ratings") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) public void consumerIsAbleToRetrieveDocumentRatings() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); restClient.withCoreAPI().usingResource(document).likeDocument(); restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - + restRatingModelsCollection = restClient.withCoreAPI().usingResource(document).getRatings(); restClient.assertStatusCodeIs(HttpStatus.OK); restRatingModelsCollection.assertNodeHasFiveStarRating().assertNodeIsLiked(); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, - description = "Admin user is able to retrieve document ratings") + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Admin user is able to retrieve document ratings") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) public void adminIsAbleToRetrieveDocumentRatings() throws Exception { - document = dataContent.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) - .usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + document = dataContent.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingResource(folderModel) + .createContent(DocumentType.TEXT_PLAIN); restClient.authenticateUser(adminUser); restClient.withCoreAPI().usingResource(document).likeDocument(); @@ -115,10 +120,11 @@ public class GetRatingsSanityTests extends RestTest restRatingModelsCollection = restClient.withCoreAPI().usingResource(document).getRatings(); restClient.assertStatusCodeIs(HttpStatus.OK); restRatingModelsCollection.assertNodeHasFiveStarRating().assertNodeIsLiked(); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, - description = "Verify unauthenticated user is not able to retrieve document ratings") + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to retrieve document ratings") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) public void unauthenticatedUserIsNotAbleToRetrieveRatings() throws Exception { restClient.authenticateUser(adminUser); @@ -126,8 +132,8 @@ public class GetRatingsSanityTests extends RestTest restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); restClient.authenticateUser(new UserModel("random user", "random password")); - + restClient.withCoreAPI().usingResource(document).getRatings(); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } + } } \ No newline at end of file From be792c4d78bdbb3a7ff1edee401603b842f242b5 Mon Sep 17 00:00:00 2001 From: Andreea Nechifor Date: Mon, 12 Dec 2016 10:42:43 +0200 Subject: [PATCH 0755/1491] Added @Test annotation --- .../rest/workflow/tasks/AddTaskItemSanityTests.java | 9 ++++++--- .../rest/workflow/tasks/AddTaskVariablesCoreTests.java | 9 ++++++++- .../rest/workflow/tasks/AddTaskVariablesSanityTests.java | 6 +++++- .../rest/workflow/tasks/GetTaskCandidatesCoreTests.java | 6 +++++- .../workflow/tasks/GetTaskCandidatesSanityTests.java | 5 ++++- .../rest/workflow/tasks/GetTaskFormModelSanityTests.java | 4 +++- .../rest/workflow/tasks/GetTaskItemsSanityTests.java | 6 ++++-- .../alfresco/rest/workflow/tasks/GetTaskSanityTests.java | 8 +++++++- .../rest/workflow/tasks/GetTaskVariablesCoreTests.java | 7 ++++++- .../rest/workflow/tasks/GetTaskVariablesSanityTests.java | 6 +++++- .../rest/workflow/tasks/GetTasksSanityTests.java | 7 ++++++- .../rest/workflow/tasks/UpdateTaskSanityTests.java | 7 ++++++- 12 files changed, 65 insertions(+), 15 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemSanityTests.java index c76e94c26..c6b95b0e2 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemSanityTests.java @@ -16,7 +16,7 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + public class AddTaskItemSanityTests extends RestTest { private UserModel userModel, userWhoStartsTask, assigneeUser, adminTenantUser, tenantUser, tenantUserAssignee;; @@ -37,6 +37,7 @@ public class AddTaskItemSanityTests extends RestTest taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); } + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Create non-existing task item") public void createTaskItem() throws Exception @@ -56,8 +57,10 @@ public class AddTaskItemSanityTests extends RestTest .assertThat().field("modifiedBy").is(taskItem.getModifiedBy()) .assertThat().field("id").is(taskItem.getId()) .assertThat().field("mimeType").is(taskItem.getMimeType()); - } + + } + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) @Bug(id = "MNT-16966") @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify that in case task item exists the request fails") @@ -83,7 +86,7 @@ public class AddTaskItemSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); } - @Test(groups = { TestGroup.NETWORKS }) + @Test(groups = { TestGroup.NETWORKS,TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Add task item using admin user from same network") public void addTaskItemByAdminSameNetwork() throws JsonToModelConversionException, Exception diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesCoreTests.java index 93f4e8c5d..946f6028e 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesCoreTests.java @@ -18,7 +18,7 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + public class AddTaskVariablesCoreTests extends RestTest { private UserModel userWhoStartsTask, adminUser; @@ -43,6 +43,7 @@ public class AddTaskVariablesCoreTests extends RestTest restClient.authenticateUser(adminUser); } + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case invalid variableBody is provided") public void failedAddingTaskVariableIfInvalidBodyIsProvided() throws Exception { @@ -53,6 +54,7 @@ public class AddTaskVariablesCoreTests extends RestTest } + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case empty body type is provided") public void failedAddingTaskVariableIfEmptyBodyIsProvided() throws Exception { @@ -64,6 +66,7 @@ public class AddTaskVariablesCoreTests extends RestTest } + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case incomplete body type is provided") public void failedAddingTaskVariableIfIncompleteBodyIsProvided() throws Exception { @@ -87,6 +90,7 @@ public class AddTaskVariablesCoreTests extends RestTest } + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case invalid type is provided") public void failedAddingTaskVariableIfInvalidTypeIsProvided() throws Exception { @@ -110,6 +114,7 @@ public class AddTaskVariablesCoreTests extends RestTest } + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case invalid scope is provided") public void failedAddingTaskVariableIfInvalidScopeIsProvided() throws Exception { @@ -121,6 +126,7 @@ public class AddTaskVariablesCoreTests extends RestTest } + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case invalid task id is provided") public void failedAddingTaskVariableIfInvalidTaskIdIsProvided() throws Exception { @@ -133,6 +139,7 @@ public class AddTaskVariablesCoreTests extends RestTest } + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case invalid task id is provided") public void failedAddingTaskVariableIfInvalidValueIsProvided() throws Exception { diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesSanityTests.java index e607b62a8..e4df01a99 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesSanityTests.java @@ -17,7 +17,7 @@ import org.testng.annotations.Test; /** * @author iulia.cojocea */ -@Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + public class AddTaskVariablesSanityTests extends RestTest { private UserModel userModel, userWhoStartsTask; @@ -38,6 +38,7 @@ public class AddTaskVariablesSanityTests extends RestTest taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); } + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Create non-existing task variable with admin") public void createTaskVariableWithAdmin() throws Exception @@ -55,6 +56,7 @@ public class AddTaskVariablesSanityTests extends RestTest .and().field("type").is(variableModel.getType()); } + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Create non-existing task variable with user involved in the process") public void createTaskVariableWithInvolvedUser() throws Exception @@ -72,6 +74,7 @@ public class AddTaskVariablesSanityTests extends RestTest restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables().assertThat().entriesListContains("name", variableModel.getName()); } + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Create non-existing task variable with task owner") public void createTaskVariableWithTaskOwner() throws Exception @@ -87,6 +90,7 @@ public class AddTaskVariablesSanityTests extends RestTest .and().field("type").is(variableModel.getType()); } + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Create non-existing task variable with any user") public void createTaskVariableWithRandomUser() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCandidatesCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCandidatesCoreTests.java index 04251ad60..f8831a252 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCandidatesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCandidatesCoreTests.java @@ -20,7 +20,7 @@ import org.testng.annotations.Test; * @author bogdan.bocancea * */ -@Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + public class GetTaskCandidatesCoreTests extends RestTest { private UserModel userModel, userModel1, userModel2; @@ -41,6 +41,7 @@ public class GetTaskCandidatesCoreTests extends RestTest dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); } + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify get task candidates with invalid task id") public void getTaskCandidatesWithInvalidTaskId() throws Exception @@ -54,6 +55,7 @@ public class GetTaskCandidatesCoreTests extends RestTest .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalid-id")); } + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify get task candidates with empty task id") public void getTaskCandidatesWithEmptyTaskId() throws Exception @@ -67,6 +69,7 @@ public class GetTaskCandidatesCoreTests extends RestTest .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); } + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify get task candidates for completed task") public void getTaskCandidatesForCompletedTask() throws Exception @@ -89,6 +92,7 @@ public class GetTaskCandidatesCoreTests extends RestTest .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, taskModel.getId())); } + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify get task candidates by non candidate user") public void getTaskCandidatesByNonCandidateUser() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCandidatesSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCandidatesSanityTests.java index 8dd4f7095..f6b7651fc 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCandidatesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCandidatesSanityTests.java @@ -20,7 +20,7 @@ import org.testng.annotations.Test; * @author Cristina Axinte * */ -@Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + public class GetTaskCandidatesSanityTests extends RestTest { private UserModel userModel, user, userModel1, userModel2; @@ -44,6 +44,7 @@ public class GetTaskCandidatesSanityTests extends RestTest taskModel = dataWorkflow.usingUser(user).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); } + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify that admin gets task candidates") public void getTaskCandidatesByAdmin() throws Exception @@ -54,6 +55,7 @@ public class GetTaskCandidatesSanityTests extends RestTest .and().entriesListContains("candidateId", String.format("GROUP_%s", group.getGroupIdentifier())); } + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify that user that started the process gets task candidates") public void getTaskCandidatesByUserWhoStartedProcess() throws Exception @@ -64,6 +66,7 @@ public class GetTaskCandidatesSanityTests extends RestTest .and().entriesListContains("candidateId", String.format("GROUP_%s", group.getGroupIdentifier())); } + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify that user from the assighed group to the process gets task candidates") public void getTaskCandidatesByCandidateUser() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelSanityTests.java index 6735f7f40..0bb678207 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelSanityTests.java @@ -17,7 +17,7 @@ import org.testng.annotations.Test; /** * Created by Claudia Agache on 10/20/2016. */ -@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + public class GetTaskFormModelSanityTests extends RestTest { UserModel userModel; @@ -35,6 +35,7 @@ public class GetTaskFormModelSanityTests extends RestTest taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(userModel); } + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify admin user gets all task form models with Rest API and response is successful (200)") public void adminGetsTaskFormModels() throws Exception @@ -65,6 +66,7 @@ public class GetTaskFormModelSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); } + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify user involved in task gets all the task form models with Rest API and response is successful (200)") public void involvedUserGetsTaskFormModels() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskItemsSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskItemsSanityTests.java index 3cd75aaa3..71ed12c34 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskItemsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskItemsSanityTests.java @@ -16,7 +16,7 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + public class GetTaskItemsSanityTests extends RestTest { private UserModel userModel, userWhoStartsTask, assignee, adminTenantUser, tenantUser, tenantUserAssignee; @@ -37,6 +37,7 @@ public class GetTaskItemsSanityTests extends RestTest taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); } + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify that user that started the process gets task items") public void getTaskItemsByUserWhoStartedProcess() throws Exception @@ -54,6 +55,7 @@ public class GetTaskItemsSanityTests extends RestTest .entriesListContains("name", document1.getName()); } + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify that involved user in process gets task items") public void getTaskItemsByUserInvolvedInProcess() throws Exception @@ -73,7 +75,7 @@ public class GetTaskItemsSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify that user that started the process gets task items") - @Test(groups = { TestGroup.NETWORKS }) + @Test(groups = { TestGroup.NETWORKS,TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY}) public void getTaskItemsByAdminInSameNetwork() throws Exception { UserModel adminuser = dataUser.getAdminUser(); diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskSanityTests.java index 0413c6617..9f7f638bd 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskSanityTests.java @@ -17,7 +17,7 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + public class GetTaskSanityTests extends RestTest { UserModel userModel; @@ -38,6 +38,7 @@ public class GetTaskSanityTests extends RestTest taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); } + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify admin user gets any existing task with Rest API and response is successfull (200)") public void adminUserGetsAnyTaskWithSuccess() throws Exception @@ -49,6 +50,7 @@ public class GetTaskSanityTests extends RestTest restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("description").is(taskModel.getMessage()); } + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify assignee user gets its assigned task with Rest API and response is successfull (200)") public void assigneeUserGetsItsTaskWithSuccess() throws Exception @@ -60,6 +62,7 @@ public class GetTaskSanityTests extends RestTest } + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify user that started the task gets the started task with Rest API and response is successfull (200)") public void starterUserGetsItsTaskWithSuccess() throws Exception @@ -69,6 +72,7 @@ public class GetTaskSanityTests extends RestTest restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("description").is(taskModel.getMessage()); } + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify any user with no relation to task id forbidden to get other task with Rest API (403)") public void anyUserIsForbiddenToGetOtherTask() throws Exception @@ -79,6 +83,7 @@ public class GetTaskSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); } + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify candidate user gets its specific task and no other user claimed the task with Rest API and response is successfull (200)") public void candidateUserGetsItsTasks() throws Exception @@ -95,6 +100,7 @@ public class GetTaskSanityTests extends RestTest } + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) @Bug(id = "MNT-17051") @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify involved user in a task without claim it gets the task with Rest API and response is successfull (200)") diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskVariablesCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskVariablesCoreTests.java index d10abe588..a3c76115e 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskVariablesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskVariablesCoreTests.java @@ -16,7 +16,7 @@ import org.testng.annotations.Test; /** * Created by Claudia Agache on 12/7/2016. */ -@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + public class GetTaskVariablesCoreTests extends RestTest { private UserModel userWhoStartsTask, assignee; @@ -34,6 +34,7 @@ public class GetTaskVariablesCoreTests extends RestTest fileModel = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); } + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify if get task variables request returns status code 404 when invalid taskId is used") public void getTaskVariablesUsingInvalidTaskId() throws Exception @@ -46,6 +47,7 @@ public class GetTaskVariablesCoreTests extends RestTest .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidId")); } + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify if get task variables request returns status code 404 when empty taskId is used") public void getTaskVariablesUsingEmptyTaskId() throws Exception @@ -58,6 +60,7 @@ public class GetTaskVariablesCoreTests extends RestTest .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); } + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify if get task variables request returns status code 200 after the task is finished.") public void getTaskVariablesAfterFinishingTask() throws Exception @@ -70,6 +73,7 @@ public class GetTaskVariablesCoreTests extends RestTest variableModels.assertThat().entriesListIsNotEmpty(); } + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify if get task variables request returns status code 200 after the process is deleted (Task state is now completed.)") public void getTaskVariablesAfterDeletingProcess() throws Exception @@ -85,6 +89,7 @@ public class GetTaskVariablesCoreTests extends RestTest } + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify user gets task variables that matches a where clause.") public void getTaskVariablesWithWhereClauseAsParameter() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskVariablesSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskVariablesSanityTests.java index 542e1da12..d5d057cdd 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskVariablesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskVariablesSanityTests.java @@ -18,7 +18,7 @@ import org.testng.annotations.Test; /** * @author iulia.cojocea */ -@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + public class GetTaskVariablesSanityTests extends RestTest { private UserModel userModel, userWhoStartsTask, assignee; @@ -38,6 +38,7 @@ public class GetTaskVariablesSanityTests extends RestTest taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); } + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify that user that started the process gets task variables") public void getTaskVariablesByUserWhoStartedProcess() throws Exception @@ -48,6 +49,7 @@ public class GetTaskVariablesSanityTests extends RestTest variableModels.assertThat().entriesListIsNotEmpty(); } + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify that user that is involved in the process gets task variables") public void getTaskVariablesByUserInvolvedInProcess() throws Exception @@ -58,6 +60,7 @@ public class GetTaskVariablesSanityTests extends RestTest variableModels.assertThat().entriesListIsNotEmpty(); } + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify that user that is not involved in the process gets task variables") public void getTaskVariablesUsingAnyUser() throws Exception @@ -69,6 +72,7 @@ public class GetTaskVariablesSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify that admin is able to task variables") public void getTaskVariablesUsingAdmin() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksSanityTests.java index 6c77aece6..18f26dc24 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksSanityTests.java @@ -18,7 +18,7 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + public class GetTasksSanityTests extends RestTest { UserModel userModel; @@ -38,6 +38,7 @@ public class GetTasksSanityTests extends RestTest dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); } + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify admin user gets all existing tasks with Rest API and response is successfull (200)") public void adminUserGetsAllTasks() throws Exception { @@ -48,6 +49,7 @@ public class GetTasksSanityTests extends RestTest taskModels.assertThat().entriesListIsNotEmpty(); } + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify asignee user gets its existing tasks with Rest API and response is successfull (200)") public void asigneeUserGetsItsTasks() throws Exception { @@ -56,6 +58,7 @@ public class GetTasksSanityTests extends RestTest taskModels.assertThat().entriesListIsNotEmpty().and().entriesListCountIs(1).and().entriesListContains("assignee", assigneeUser.getUsername()); } + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify candidate user that claims the task gets its existing tasks with Rest API and response is successfull (200)") @Bug(id = "MNT-16967") public void candidateUserGetsItsTasks() throws Exception @@ -72,6 +75,7 @@ public class GetTasksSanityTests extends RestTest taskModels.assertThat().entriesListIsNotEmpty(); } + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify candidate user that claims the task gets its existing tasks with Rest API and response is successfull (200)") public void candidateUserThatClaimsTaskGetsItsTasks() throws Exception { @@ -87,6 +91,7 @@ public class GetTasksSanityTests extends RestTest taskModels.assertThat().entriesListIsNotEmpty(); } + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify candidate user without claim gets no tasks with Rest API and response is successfull (200)") public void candidateUserWithoutClaimTaskGetsNoTasks() throws Exception { diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskSanityTests.java index 68ee25b07..bc5329c55 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskSanityTests.java @@ -15,7 +15,7 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + public class UpdateTaskSanityTests extends RestTest { UserModel userModel; @@ -36,6 +36,7 @@ public class UpdateTaskSanityTests extends RestTest taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); } + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify admin user updates task with Rest API and response is successfull (200)") public void adminUserUpdatesAnyTaskWithSuccess() throws Exception { @@ -47,6 +48,7 @@ public class UpdateTaskSanityTests extends RestTest .and().field("description").is(taskModel.getMessage()); } + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify assignee user updates its assigned task with Rest API and response is successfull (200)") public void assigneeUserUpdatesItsTaskWithSuccess() throws Exception { @@ -56,6 +58,7 @@ public class UpdateTaskSanityTests extends RestTest .and().field("description").is(taskModel.getMessage()); } + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify user that started the task updates the started task with Rest API and response is successfull (200)") public void starterUserUpdatesItsTaskWithSuccess() throws Exception { @@ -63,6 +66,7 @@ public class UpdateTaskSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); } + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify any user with no relation to task is forbidden to update other task with Rest API (403)") public void anyUserIsForbiddenToUpdateOtherTask() throws Exception { @@ -72,6 +76,7 @@ public class UpdateTaskSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); } + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify candidate user updates its specific task and no other user claimed the task with Rest API and response is successfull (200)") public void candidateUserUpdatesItsTasks() throws Exception { From 53c1e3c6a6d8ad9b1661cd15372564a2898ac14f Mon Sep 17 00:00:00 2001 From: cagache Date: Mon, 12 Dec 2016 10:46:15 +0200 Subject: [PATCH 0756/1491] moved @Test annotation --- .../rest/sites/AddSiteMemberCoreTests.java | 65 ++++++++++++------- .../rest/sites/AddSiteMemberSanityTests.java | 15 +++-- .../rest/sites/GetSiteContainerCoreTests.java | 17 +++-- .../sites/GetSiteContainerSanityTests.java | 13 ++-- .../sites/GetSiteContainersCoreTests.java | 40 +++++++----- .../sites/GetSiteContainersSanityTests.java | 23 ++++--- .../alfresco/rest/sites/GetSiteCoreTests.java | 7 +- .../rest/sites/GetSiteMemberCoreTests.java | 23 +++++-- .../rest/sites/GetSiteMemberSanityTests.java | 17 +++-- .../rest/sites/GetSiteMembersCoreTests.java | 23 ++++++- .../rest/sites/GetSiteMembersSanityTests.java | 21 +++--- .../rest/sites/GetSiteSanityTests.java | 21 +++--- .../rest/sites/GetSitesCoreTests.java | 27 +++++++- .../rest/sites/GetSitesSanityTests.java | 7 +- .../sites/RemoveSiteMemberSanityTests.java | 9 ++- .../rest/sites/UpdateSiteMemberCoreTests.java | 14 +++- .../sites/UpdateSiteMemberSanityTests.java | 9 ++- 17 files changed, 237 insertions(+), 114 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberCoreTests.java index 9ffa5aa39..5db2bc437 100644 --- a/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberCoreTests.java @@ -19,7 +19,6 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) public class AddSiteMemberCoreTests extends RestTest { private UserModel adminUserModel; @@ -51,6 +50,7 @@ public class AddSiteMemberCoreTests extends RestTest testUser = dataUser.createRandomTestUser("testUser"); } + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Verify that manager can add another user as manager to a public site and gets status code CREATED (201)") public void addManagerToPublicSite() throws Exception @@ -61,7 +61,8 @@ public class AddSiteMemberCoreTests extends RestTest memberModel.assertThat().field("id").is(testUser.getUsername()) .and().field("role").is(testUser.getUserRole()); } - + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Verify that manager can add another user as manager to a moderated site and gets status code CREATED (201)") public void addManagerToModeratedSite() throws Exception @@ -72,7 +73,8 @@ public class AddSiteMemberCoreTests extends RestTest memberModel.assertThat().field("id").is(testUser.getUsername()) .and().field("role").is(testUser.getUserRole()); } - + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Verify that manager can add another user as manager to a private site and gets status code CREATED (201)") public void addManagerToPrivateSite() throws Exception @@ -83,7 +85,8 @@ public class AddSiteMemberCoreTests extends RestTest memberModel.assertThat().field("id").is(testUser.getUsername()) .and().field("role").is(testUser.getUserRole()); } - + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Verify that consumer role is not able to add another user to a moderated site and gets status code 403") public void addUserByConsumerToModeratedSite() throws Exception @@ -92,7 +95,8 @@ public class AddSiteMemberCoreTests extends RestTest restClient.authenticateUser(usersWithRolesToModeratedSite.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingSite(moderatedSiteModel).addPerson(testUser); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } - + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Verify that consumer role is not able to add another user to a private site and gets status code 403") public void addUserByConsumerToPrivateSite() throws Exception @@ -101,7 +105,8 @@ public class AddSiteMemberCoreTests extends RestTest restClient.authenticateUser(usersWithRolesToPrivateSite.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingSite(privateSiteModel).addPerson(testUser); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } - + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Verify that collaborator role is not able to add another user to a moderated site and gets status code 403") public void addUserByCollaboratorToModeratedSite() throws Exception @@ -110,7 +115,8 @@ public class AddSiteMemberCoreTests extends RestTest restClient.authenticateUser(usersWithRolesToModeratedSite.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingSite(moderatedSiteModel).addPerson(testUser); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } - + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Verify that collaborator role is not able to add another user to a private site and gets status code 403") public void addUserByCollaboratorToPrivateSite() throws Exception @@ -119,7 +125,8 @@ public class AddSiteMemberCoreTests extends RestTest restClient.authenticateUser(usersWithRolesToPrivateSite.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingSite(privateSiteModel).addPerson(testUser); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } - + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Verify that contributor role is not able to add another user to a moderated site and gets status code 403") public void addUserByContributorToModeratedSite() throws Exception @@ -128,7 +135,8 @@ public class AddSiteMemberCoreTests extends RestTest restClient.authenticateUser(usersWithRolesToModeratedSite.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingSite(moderatedSiteModel).addPerson(testUser); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } - + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Verify that contributor role is not able to add another user to a private site and gets status code 403") public void addUserByContributorToPrivateSite() throws Exception @@ -137,7 +145,8 @@ public class AddSiteMemberCoreTests extends RestTest restClient.authenticateUser(usersWithRolesToPrivateSite.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingSite(privateSiteModel).addPerson(testUser); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } - + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Verify that a user without specified role can not be added to a site and gets status code 400") public void canNotAddUserWithoutSpecifyingRoleToSite() throws Exception @@ -148,7 +157,8 @@ public class AddSiteMemberCoreTests extends RestTest restClient.processModel(RestSiteMemberModel.class, request); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(RestErrorModel.MUST_PROVIDE_ROLE); } - + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Verify that a user with inexistent role can not be added to a site and gets status code 400") public void canNotAddUserWithInexistentRoleToSite() throws Exception @@ -158,7 +168,8 @@ public class AddSiteMemberCoreTests extends RestTest restClient.processModel(RestSiteMemberModel.class, request); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.UNKNOWN_ROLE, "inexistentRole")); } - + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Verify that user can not add himself as a manager to a public site and gets status code 403") public void userAddHimselfAsManagerToPublicSite() throws Exception @@ -167,7 +178,8 @@ public class AddSiteMemberCoreTests extends RestTest restClient.authenticateUser(testUser).withCoreAPI().usingSite(publicSiteModel).addPerson(testUser); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } - + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Verify that user can not add himself as a manager to a moderated site and gets status code 403") public void userAddHimselfAsManagerToModeratedSite() throws Exception @@ -176,7 +188,8 @@ public class AddSiteMemberCoreTests extends RestTest restClient.authenticateUser(testUser).withCoreAPI().usingSite(moderatedSiteModel).addPerson(testUser); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } - + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Verify that user can not add himself as a manager to a private site and gets status code 404") public void userAddHimselfAsManagerToPrivateSite() throws Exception @@ -185,7 +198,8 @@ public class AddSiteMemberCoreTests extends RestTest restClient.authenticateUser(testUser).withCoreAPI().usingSite(privateSiteModel).addPerson(testUser); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, privateSiteModel.getId())); } - + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Verify that user can not be added to an inexistent site and gets status code 404") public void userIsNotAbleToAddUserToAnInexistentSite() throws Exception @@ -195,7 +209,8 @@ public class AddSiteMemberCoreTests extends RestTest restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(inexistentSite).addPerson(testUser); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, inexistentSite.getId())); } - + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Verify that user can not be added to a site if an empty site id is provided and gets status code 404") public void userIsNotAbleToAddAnotherUserUsingEmptySiteId() throws Exception @@ -205,7 +220,8 @@ public class AddSiteMemberCoreTests extends RestTest restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(inexistentSite).addPerson(testUser); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, inexistentSite.getId())); } - + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Verify that inexistent user can not be added to site and gets status code 404") public void userIsNotAbleToAddInexistentUserToSite() throws Exception @@ -215,7 +231,8 @@ public class AddSiteMemberCoreTests extends RestTest restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(testUser); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, testUser.getUsername())); } - + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Verify that empty username can not be added to site and gets status code 400") public void userIsNotAbleToAddEmptyUserIdToSite() throws Exception @@ -225,7 +242,8 @@ public class AddSiteMemberCoreTests extends RestTest restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(testUser); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.NO_CONTENT, testUser.getUsername())); } - + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Verify that user can not add another user that is already a memeber and gets status code 409") public void userIsNotAbleToAddUserThatIsAlreadyAMember() throws Exception @@ -234,7 +252,8 @@ public class AddSiteMemberCoreTests extends RestTest restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(collaborator); restClient.assertStatusCodeIs(HttpStatus.CONFLICT).assertLastError().containsSummary(String.format(RestErrorModel.ALREADY_Site_MEMBER, collaborator.getUsername(), moderatedSiteModel.getId())); } - + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Verify that several users with different roles can be added once in a row to a site and gets status code 201") public void addSeveralUsersWithDifferentRolesToASite() throws Exception @@ -249,7 +268,8 @@ public class AddSiteMemberCoreTests extends RestTest restClient.processModel(RestSiteMemberModel.class, request); restClient.assertStatusCodeIs(HttpStatus.CREATED); } - + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Verify that several users with same roles can be added once in a row to a site and gets status code 201") public void addSeveralUsersWithSameRolesToASite() throws Exception @@ -264,7 +284,8 @@ public class AddSiteMemberCoreTests extends RestTest restClient.processModel(RestSiteMemberModel.class, request); restClient.assertStatusCodeIs(HttpStatus.CREATED); } - + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Verify that several users that are already added to the site can not be added once in a row and gets status code 400") public void addSeveralUsersThatAreAlreadyAddedToASite() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java index 7b82ebb5e..dadf2f9a9 100644 --- a/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java @@ -14,7 +14,6 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) public class AddSiteMemberSanityTests extends RestTest { private UserModel adminUserModel; @@ -34,6 +33,7 @@ public class AddSiteMemberSanityTests extends RestTest } + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that manager is able to add site member and gets status code CREATED (201)") public void managerIsAbleToAddSiteMember() throws Exception @@ -46,7 +46,8 @@ public class AddSiteMemberSanityTests extends RestTest .and().field("role").is(testUser.getUserRole()); restClient.assertStatusCodeIs(HttpStatus.CREATED); } - + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that site collaborator is not able to add site member and gets status code FORBIDDEN (403)") public void collaboratorIsNotAbleToAddSiteMember() throws Exception @@ -59,7 +60,8 @@ public class AddSiteMemberSanityTests extends RestTest restClient.assertLastError().containsSummary("Permission was denied"); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); } - + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that site contributor is not able to add site member and gets status code FORBIDDEN (403)") public void contributorIsNotAbleToAddSiteMember() throws Exception @@ -71,7 +73,8 @@ public class AddSiteMemberSanityTests extends RestTest restClient.assertLastError().containsSummary("Permission was denied"); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); } - + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that site consumer is not able to add site member and gets status code FORBIDDEN (403)") public void consumerIsNotAbleToAddSiteMember() throws Exception @@ -83,7 +86,8 @@ public class AddSiteMemberSanityTests extends RestTest restClient.assertLastError().containsSummary("Permission was denied"); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); } - + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that admin user is able to add site member and gets status code CREATED (201)") public void adminIsAbleToAddSiteMember() throws Exception @@ -98,6 +102,7 @@ public class AddSiteMemberSanityTests extends RestTest } @Bug(id="MNT-16904") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that unauthenticated user is not able to add site member") public void unauthenticatedUserIsNotAuthorizedToAddSiteMmeber() throws Exception{ diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerCoreTests.java index fcffac5d4..1c71dcf94 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerCoreTests.java @@ -36,8 +36,8 @@ public class GetSiteContainerCoreTests extends RestTest{ dataLink.usingAdmin().usingSite(privateSiteModel).createRandomLink(); dataDiscussion.usingAdmin().usingSite(privateSiteModel).createRandomDiscussion(); } - - + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if get container request returns status code 400 when site doesn't exist") public void getContainerWithNonExistentSite() throws Exception @@ -47,7 +47,8 @@ public class GetSiteContainerCoreTests extends RestTest{ restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, "NonExistentSiteId", ContainerName.discussions.toString())); } - + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if get container request returns status code 400 when container item doesn't exist") public void getContainerWithNonExistentItem() throws Exception @@ -57,7 +58,8 @@ public class GetSiteContainerCoreTests extends RestTest{ restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, publicSiteModel.getId(), "NonExistentFolder")); } - + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify get container request returns status 200 for public site") public void getContainerForPublicSite() throws Exception @@ -72,8 +74,8 @@ public class GetSiteContainerCoreTests extends RestTest{ .assertThat().field("folderId").is(ContainerName.links.toString()); restClient.assertStatusCodeIs(HttpStatus.OK); } - - + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify get container request returns status 200 for private site") public void getContainerForPrivateSite() throws Exception @@ -87,7 +89,8 @@ public class GetSiteContainerCoreTests extends RestTest{ .assertThat().field("folderId").is(ContainerName.links.toString()); restClient.assertStatusCodeIs(HttpStatus.OK); } - + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify get container request returns status 200 for moderated site") public void getContainerForModeratedSite() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java index 3e8be929b..5ba4a8efa 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java @@ -36,6 +36,7 @@ public class GetSiteContainerSanityTests extends RestTest UserRole.SiteContributor); } + @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 container and gets status code OK (200)") public void getSiteContainerWithManagerRole() throws Exception @@ -48,6 +49,7 @@ public class GetSiteContainerSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); } + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify user with Collaborator role gets site container and gets status code OK (200)") public void getSiteContainerWithCollaboratorRole() throws Exception @@ -60,6 +62,7 @@ public class GetSiteContainerSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); } + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify user with Contributor role gets site container and gets status code OK (200)") public void getSiteContainerWithContributorRole() throws Exception @@ -71,7 +74,8 @@ public class GetSiteContainerSanityTests extends RestTest .and().field("folderId").is(siteContainerModel.onModel().getFolderId()); restClient.assertStatusCodeIs(HttpStatus.OK); } - + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role gets site container and gets status code OK (200)") public void getSiteContainerWithConsumerRole() throws Exception @@ -83,7 +87,8 @@ public class GetSiteContainerSanityTests extends RestTest .and().field("folderId").is(siteContainerModel.onModel().getFolderId()); restClient.assertStatusCodeIs(HttpStatus.OK); } - + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify user with admin user gets site container and gets status code OK (200)") public void getSiteContainerWithAdminUser() throws Exception @@ -95,8 +100,8 @@ public class GetSiteContainerSanityTests extends RestTest .and().field("folderId").is(siteContainerModel.onModel().getFolderId()); 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 container call returns status code 401") @Bug(id="MNT-16904") diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersCoreTests.java index aeac1f680..298b37c78 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersCoreTests.java @@ -14,7 +14,6 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) public class GetSiteContainersCoreTests extends RestTest { private UserModel adminUserModel; @@ -48,8 +47,9 @@ public class GetSiteContainersCoreTests extends RestTest dataLink.usingAdmin().usingSite(privateSiteModel).createRandomLink(); dataDiscussion.usingAdmin().usingSite(privateSiteModel).createRandomDiscussion(); -} + } + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if get site container request returns status code 200 with valid maxItems parameter") public void getContainersWithValidMaxItems() throws Exception @@ -73,7 +73,8 @@ public class GetSiteContainersCoreTests extends RestTest .and().entriesListContains("folderId", ContainerName.documentLibrary.toString()); restClient.assertStatusCodeIs(HttpStatus.OK); } - + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if get site container request returns status code 400 when invalid maxItems parameter is used") public void getContainersWithMaxItemsZero () throws Exception @@ -84,7 +85,8 @@ public class GetSiteContainersCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) .assertLastError().containsSummary("Only positive values supported for maxItems"); } - + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if get site container request returns status code 400 when invalid maxItems parameter is used") public void getContainersWithMaxItemsCharacter () throws Exception @@ -95,7 +97,8 @@ public class GetSiteContainersCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "test")); } - + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if get site container request returns status code 200 when maxItems parameter starts with multiple zero") public void getContainersWithMaxItemsMultipleZero () throws Exception @@ -106,7 +109,8 @@ public class GetSiteContainersCoreTests extends RestTest .assertThat().entriesListCountIs(3); restClient.assertStatusCodeIs(HttpStatus.OK); } - + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if get site containers request returns status code 200 when valid skipCount parameter is used") public void getSiteContainersWithValidSkipCount() throws Exception @@ -131,7 +135,8 @@ public class GetSiteContainersCoreTests extends RestTest .assertThat().entriesListCountIs(3); restClient.assertStatusCodeIs(HttpStatus.OK); } - + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if get site containers request returns status code 400 when invalid skipCount parameter is used") public void getSiteContainersWithSkipCountCharacter() throws Exception @@ -141,7 +146,8 @@ public class GetSiteContainersCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "abc")); } - + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if get site containers request returns status code 200 when skipCount parameter starts with multiple zero") public void getSiteContainersWithSkipCountMultipleZero() throws Exception @@ -151,8 +157,8 @@ public class GetSiteContainersCoreTests extends RestTest .assertThat().entriesListCountIs(1); restClient.assertStatusCodeIs(HttpStatus.OK); } - - + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if get site containers request returns status code 400 when site doesn't exist") public void getSiteContainersWithNonExistentSite() throws Exception @@ -162,7 +168,8 @@ public class GetSiteContainersCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "NonExistentSiteId")); } - + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify get site containers request returns status 200 for private site") public void getSiteContainersForPrivateSite() throws Exception @@ -172,7 +179,8 @@ public class GetSiteContainersCoreTests extends RestTest .assertThat().entriesListCountIs(3); restClient.assertStatusCodeIs(HttpStatus.OK); } - + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify get site containers request returns status 200 for moderated site") public void getSiteContainersForModeratedSite() throws Exception @@ -182,7 +190,8 @@ public class GetSiteContainersCoreTests extends RestTest .assertThat().entriesListCountIs(3); restClient.assertStatusCodeIs(HttpStatus.OK); } - + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify get site containers request returns status 200 for several containers") public void getSiteContainersForSeveralItems() throws Exception @@ -194,8 +203,9 @@ public class GetSiteContainersCoreTests extends RestTest .and().entriesListContains("folderId", ContainerName.links.toString()) .and().entriesListContains("folderId", ContainerName.discussions.toString()); restClient.assertStatusCodeIs(HttpStatus.OK); - } - + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify get site containers request returns status 200 for one container") public void getSiteContainersWithOneItem() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java index 509dfea81..6c79e8314 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java @@ -21,15 +21,8 @@ import org.testng.annotations.Test; /** * @author iulia.cojocea */ -@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) public class GetSiteContainersSanityTests extends RestTest -{ - @Autowired - DataUser dataUser; - - @Autowired - DataSite dataSite; - +{ private UserModel adminUserModel; private SiteModel siteModel; private ListUserWithRoles usersWithRoles; @@ -43,6 +36,7 @@ public class GetSiteContainersSanityTests extends RestTest usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); } + @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 containers and gets status code OK (200)") public void getSiteContainersWithManagerRole() throws JsonToModelConversionException, Exception @@ -54,7 +48,8 @@ public class GetSiteContainersSanityTests extends RestTest .and().paginationField("count").isNot("0"); restClient.assertStatusCodeIs(HttpStatus.OK); } - + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify user with Collaborator role gets site containers and gets status code OK (200)") public void getSiteContainersWithCollaboratorRole() throws JsonToModelConversionException, Exception @@ -66,7 +61,8 @@ public class GetSiteContainersSanityTests extends RestTest .and().paginationField("count").isNot("0"); restClient.assertStatusCodeIs(HttpStatus.OK); } - + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify user with Contributor role gets site containers and gets status code OK (200)") public void getSiteContainersWithContributorRole() throws JsonToModelConversionException, Exception @@ -78,7 +74,8 @@ public class GetSiteContainersSanityTests extends RestTest .and().paginationField("count").isNot("0"); restClient.assertStatusCodeIs(HttpStatus.OK); } - + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role gets site containers and gets status code OK (200)") public void getSiteContainersWithConsumerRole() throws JsonToModelConversionException, Exception @@ -90,7 +87,8 @@ public class GetSiteContainersSanityTests extends RestTest .and().paginationField("count").isNot("0"); restClient.assertStatusCodeIs(HttpStatus.OK); } - + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify user with Admin user gets site containers information and gets status code OK (200)") public void getSiteContainersWithAdminUser() throws JsonToModelConversionException, Exception @@ -104,6 +102,7 @@ public class GetSiteContainersSanityTests extends RestTest } @Bug(id="MNT-16904") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Failed authentication get site containers call returns status code 401 with Manager role") public void unauthenticatedUserIsNotAuthorizedToRetrieveSiteContainers() throws JsonToModelConversionException, Exception diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteCoreTests.java index 206dc6e72..7d03ccf45 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteCoreTests.java @@ -19,7 +19,6 @@ import org.testng.annotations.Test; /** * Created by Claudia Agache on 11/23/2016. */ -@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) public class GetSiteCoreTests extends RestTest { private UserModel userModel, privateSiteConsumer; @@ -37,6 +36,7 @@ public class GetSiteCoreTests extends RestTest dataUser.addUserToSite(privateSiteConsumer, privateSite, UserRole.SiteConsumer); } + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify invalid request returns status code 404 if siteId does not exist") public void checkStatusCodeForNonExistentSiteId() throws Exception @@ -47,6 +47,7 @@ public class GetSiteCoreTests extends RestTest .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "NonExistentSiteId")); } + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify user gets all public and moderated sites if an empty siteId is provided") public void checkStatusCodeForEmptySiteId() throws Exception @@ -58,6 +59,7 @@ public class GetSiteCoreTests extends RestTest sites.assertThat().entriesListIsNotEmpty(); } + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if any user gets public site details and status code is 200") public void getPublicSite() throws Exception @@ -72,6 +74,7 @@ public class GetSiteCoreTests extends RestTest .and().field("guid").isNotEmpty(); } + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if any user gets moderated site details and status code is 200") public void getModeratedSite() throws Exception @@ -86,6 +89,7 @@ public class GetSiteCoreTests extends RestTest .and().field("guid").isNotEmpty(); } + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if member of a private site gets that site details and status code is 200") public void getPrivateSiteBySiteMember() throws Exception @@ -100,6 +104,7 @@ public class GetSiteCoreTests extends RestTest .and().field("guid").isNotEmpty(); } + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if user that is not member of a private site does not get that site details and status code is 200") public void getPrivateSiteByNotASiteMember() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberCoreTests.java index 4ad48b49d..371cac7da 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberCoreTests.java @@ -19,7 +19,6 @@ import org.testng.annotations.Test; * @author Cristina Axinte * */ -@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) public class GetSiteMemberCoreTests extends RestTest { private UserModel adminUser; @@ -42,6 +41,7 @@ public class GetSiteMemberCoreTests extends RestTest contributor = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); } + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @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 @@ -53,7 +53,8 @@ public class GetSiteMemberCoreTests extends RestTest 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.CORE }) @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 @@ -65,7 +66,8 @@ public class GetSiteMemberCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, nonMember.getUsername(), siteModel.getId())); } - + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @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 @@ -77,7 +79,8 @@ public class GetSiteMemberCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, inexistentUser.getUsername())); } - + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @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 @@ -92,7 +95,8 @@ public class GetSiteMemberCoreTests extends RestTest .and().field("role").is(manager.getUserRole()); restClient.assertStatusCodeIs(HttpStatus.OK); } - + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @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 @@ -104,7 +108,8 @@ public class GetSiteMemberCoreTests extends RestTest 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.CORE }) @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 @@ -119,6 +124,7 @@ public class GetSiteMemberCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); } + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @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 @@ -130,6 +136,7 @@ public class GetSiteMemberCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); } + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @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 @@ -141,6 +148,7 @@ public class GetSiteMemberCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); } + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @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 @@ -151,7 +159,8 @@ public class GetSiteMemberCoreTests extends RestTest .and().field("role").is(manager.getUserRole()); restClient.assertStatusCodeIs(HttpStatus.OK); } - + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @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 diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java index 620f73374..c5253dcab 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java @@ -19,7 +19,6 @@ import org.testng.annotations.Test; /** * @author iulia.cojocea */ -@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) public class GetSiteMemberSanityTests extends RestTest { private UserModel adminUser; @@ -38,6 +37,7 @@ public class GetSiteMemberSanityTests extends RestTest dataUser.addUserToSite(userModel, siteModel, UserRole.SiteConsumer); } + @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 @@ -48,7 +48,8 @@ public class GetSiteMemberSanityTests extends RestTest .and().field("role").is(userModel.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 = "Verify user with Collaborator role gets site member and gets status code OK (200)") public void getSiteMemberWithCollaboratorRole() throws Exception @@ -59,7 +60,8 @@ public class GetSiteMemberSanityTests extends RestTest .and().field("role").is(userModel.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 = "Verify user with Contributor role gets site member and gets status code OK (200)") public void getSiteMemberWithContributorRole() throws Exception @@ -70,7 +72,8 @@ public class GetSiteMemberSanityTests extends RestTest .and().field("role").is(userModel.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 = "Verify user with Consumer role gets site member and gets status code OK (200)") public void getSiteMemberWithConsumerRole() throws Exception @@ -81,7 +84,8 @@ public class GetSiteMemberSanityTests extends RestTest .and().field("role").is(userModel.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 = "Verify user with admin user gets site member and gets status code OK (200)") public void getSiteMemberWithAdminUser() throws Exception @@ -92,7 +96,8 @@ public class GetSiteMemberSanityTests extends RestTest .and().field("role").is(userModel.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") diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersCoreTests.java index 53318f7c5..8467854e0 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersCoreTests.java @@ -16,7 +16,6 @@ import org.testng.annotations.Test; /** * Created by Claudia Agache on 11/23/2016. */ -@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) public class GetSiteMembersCoreTests extends RestTest { private UserModel userModel, publicSiteContributor, privateSiteConsumer, moderatedSiteManager, admin; @@ -40,6 +39,7 @@ public class GetSiteMembersCoreTests extends RestTest dataUser.addUserToSite(privateSiteConsumer, privateSite, UserRole.SiteConsumer); } + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @TestRail(section={TestGroup.REST_API, TestGroup.CORE, 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 @@ -50,6 +50,7 @@ public class GetSiteMembersCoreTests extends RestTest .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "NonExistentSiteId")); } + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify get site members call returns status code 400 for invalid maxItems") public void checkStatusCodeForInvalidMaxItems() throws Exception @@ -57,9 +58,15 @@ public class GetSiteMembersCoreTests extends RestTest restClient.authenticateUser(publicSiteContributor).withParams("maxItems=0") .withCoreAPI().usingSite(publicSite).getSiteMembers(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary("Only positive values supported for maxItems"); + .assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); + + restClient.authenticateUser(publicSiteContributor).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.CORE }) @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify get site members call returns status code 400 for invalid skipCount ") public void checkStatusCodeForInvalidSkipCount() throws Exception @@ -67,9 +74,15 @@ public class GetSiteMembersCoreTests extends RestTest restClient.authenticateUser(publicSiteContributor).withParams("skipCount=A") .withCoreAPI().usingSite(publicSite).getSiteMembers(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary("Invalid paging parameter skipCount:A"); + .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "A")); + + restClient.authenticateUser(publicSiteContributor).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.CORE }) @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if any user gets public site members and status code is 200") public void getPublicSiteMembers() throws Exception @@ -82,6 +95,7 @@ public class GetSiteMembersCoreTests extends RestTest .and().paginationField("count").is("2"); } + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if any user gets moderated site members and status code is 200") public void getModeratedSiteMembers() throws Exception @@ -94,6 +108,7 @@ public class GetSiteMembersCoreTests extends RestTest .and().paginationField("count").is("2"); } + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @TestRail(section={TestGroup.REST_API, TestGroup.CORE, 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 @@ -106,6 +121,7 @@ public class GetSiteMembersCoreTests extends RestTest .and().paginationField("count").is("2"); } + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @TestRail(section={TestGroup.REST_API, TestGroup.CORE, 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 @@ -116,6 +132,7 @@ public class GetSiteMembersCoreTests extends RestTest .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, privateSite.getTitle())); } + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @TestRail(section={TestGroup.REST_API, TestGroup.CORE, 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 diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java index 752cfa6f4..d533e6ffc 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java @@ -22,15 +22,8 @@ import org.testng.annotations.Test; /** * @author iulia.cojocea */ -@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) public class GetSiteMembersSanityTests extends RestTest { - @Autowired - DataUser dataUser; - - @Autowired - DataSite dataSite; - private SiteModel siteModel; private UserModel adminUser; private ListUserWithRoles usersWithRoles; @@ -44,6 +37,7 @@ public class GetSiteMembersSanityTests extends RestTest usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); } + @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 JsonToModelConversionException, Exception @@ -54,7 +48,8 @@ public class GetSiteMembersSanityTests extends RestTest .and().entriesListContains("role", usersWithRoles.getOneUserWithRole(UserRole.SiteManager).getUserRole().toString()); restClient.assertStatusCodeIs(HttpStatus.OK); } - + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify user with Collaborator role gets site members and gets status code OK (200)") public void getSiteMembersWithCollaboratorRole() throws JsonToModelConversionException, Exception @@ -65,7 +60,8 @@ public class GetSiteMembersSanityTests extends RestTest .entriesListContains("role", usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator).getUserRole().toString()); restClient.assertStatusCodeIs(HttpStatus.OK); } - + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify user with Contributor role gets site members and gets status code OK (200)") public void getSiteMembersWithContributorRole() throws JsonToModelConversionException, Exception @@ -76,7 +72,8 @@ public class GetSiteMembersSanityTests extends RestTest .and().entriesListContains("role", usersWithRoles.getOneUserWithRole(UserRole.SiteContributor).getUserRole().toString()); restClient.assertStatusCodeIs(HttpStatus.OK); } - + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role gets site members and gets status code OK (200)") public void getSiteMembersWithConsumerRole() throws JsonToModelConversionException, Exception @@ -87,7 +84,8 @@ public class GetSiteMembersSanityTests extends RestTest .and().entriesListContains("role", usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer).getUserRole().toString()); restClient.assertStatusCodeIs(HttpStatus.OK); } - + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify user with admin usere gets site members and gets status code OK (200)") public void getSiteMembersWithAdminUser() throws JsonToModelConversionException, Exception @@ -100,6 +98,7 @@ public class GetSiteMembersSanityTests extends RestTest } @Bug(id="MNT-16904") + @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") public void unauthenticatedUserIsNotAuthorizedToRetrieveSiteMembers() throws JsonToModelConversionException, Exception diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteSanityTests.java index d2f4b28d2..2631fac99 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteSanityTests.java @@ -23,15 +23,8 @@ import org.testng.annotations.Test; * @author iulia.cojocea */ -@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) public class GetSiteSanityTests extends RestTest { - @Autowired - DataUser dataUser; - - @Autowired - DataSite dataSite; - private UserModel adminUserModel; private ListUserWithRoles usersWithRoles; private UserModel userModel; @@ -46,6 +39,7 @@ public class GetSiteSanityTests extends RestTest usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); } + @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 information and gets status code OK (200)") public void getSiteWithManagerRole() throws JsonToModelConversionException, Exception @@ -58,7 +52,8 @@ public class GetSiteSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); } - + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify user with Collaborator role gets site information and gets status code OK (200)") public void getSiteWithCollaboratorRole() throws JsonToModelConversionException, Exception @@ -70,7 +65,8 @@ public class GetSiteSanityTests extends RestTest .and().field("title").is(siteModel.getTitle()); restClient.assertStatusCodeIs(HttpStatus.OK); } - + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify user with Contributor role gets site information and gets status code OK (200)") public void getSiteWithContributorRole() throws JsonToModelConversionException, Exception @@ -82,7 +78,8 @@ public class GetSiteSanityTests extends RestTest .and().field("title").is(siteModel.getTitle()); restClient.assertStatusCodeIs(HttpStatus.OK); } - + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role gets site information and gets status code OK (200)") public void getSiteWithConsumerRole() throws JsonToModelConversionException, Exception @@ -94,7 +91,8 @@ public class GetSiteSanityTests extends RestTest .and().field("title").is(siteModel.getTitle()); restClient.assertStatusCodeIs(HttpStatus.OK); } - + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify user with admin role gets site information and gets status code OK (200)") public void getSiteWithAdminRole() throws JsonToModelConversionException, Exception @@ -108,6 +106,7 @@ public class GetSiteSanityTests extends RestTest } @Bug(id="MNT-16904") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Failed authentication get site call returns status code 401") public void unauthenticatedUserIsNotAuthorizedToRetrieveSite() throws JsonToModelConversionException, Exception diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java index 8751b0018..2da9a46c4 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java @@ -3,6 +3,7 @@ package org.alfresco.rest.sites; import java.util.List; import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestSiteModel; import org.alfresco.rest.model.RestSiteModelsCollection; import org.alfresco.utility.constants.UserRole; @@ -21,7 +22,6 @@ import org.testng.annotations.Test; /** * Created by Claudia Agache on 11/22/2016. */ -@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) public class GetSitesCoreTests extends RestTest { private UserModel regularUser, privateSiteManager, privateSiteConsumer; @@ -46,6 +46,7 @@ public class GetSitesCoreTests extends RestTest deletedSite = dataSite.usingAdmin().createPublicRandomSite(); } + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if get sites request returns status code 400 when invalid maxItems parameter is used") public void getSitesWithInvalidMaxItems() throws Exception @@ -53,9 +54,20 @@ public class GetSitesCoreTests extends RestTest restClient.authenticateUser(regularUser).withParams("maxItems=0=09") .withCoreAPI().getSites(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary("Invalid paging parameter maxItems:0=09"); + .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "0=09")); + + restClient.withParams("maxItems=A") + .withCoreAPI().getSites(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "A")); + + restClient.withParams("maxItems=0") + .withCoreAPI().getSites(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); } + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if get sites request returns status code 400 when invalid skipCount parameter is used") public void getSitesWithInvalidSkipCount() throws Exception @@ -63,9 +75,15 @@ public class GetSitesCoreTests extends RestTest restClient.authenticateUser(regularUser).withParams("skipCount=A") .withCoreAPI().getSites(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary("Invalid paging parameter skipCount:A"); + .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "A")); + + restClient.authenticateUser(regularUser).withParams("skipCount=-1") + .withCoreAPI().getSites(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT); } + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if User gets sites ordered by title ascending and status code is 200") public void getSitesOrderedByNameASC() throws Exception @@ -80,6 +98,7 @@ public class GetSitesCoreTests extends RestTest sitesList.get(2).onModel().assertThat().field("title").is(publicSite.getTitle()); } + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if a regular user gets all public and moderated sites and status code is 200") public void regularUserGetsOnlyPublicAndModeratedSites() throws Exception @@ -92,6 +111,7 @@ public class GetSitesCoreTests extends RestTest .and().entriesListDoesNotContain("title", privateSite.getTitle()); } + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if a member of a private site gets the private site, all public sites and all moderated sites. Verify if status code is 200") public void privateSiteMemberGetsSitesVisibleForHim() throws Exception @@ -104,6 +124,7 @@ public class GetSitesCoreTests extends RestTest .and().entriesListContains("title", privateSite.getTitle()); } + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if a site is not retrieved anymore after deletion and status code is 200") public void checkDeletedSiteIsNotRetrieved() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java index c9e25463d..95a4b04cb 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java @@ -18,7 +18,6 @@ import org.testng.annotations.Test; /** * @author iulia.cojocea */ -@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) public class GetSitesSanityTests extends RestTest { private UserModel adminUserModel; @@ -34,6 +33,7 @@ public class GetSitesSanityTests extends RestTest usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); } + @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 sites information and gets status code OK (200)") public void managerIsAbleToRetrieveSites() throws JsonToModelConversionException, Exception { @@ -45,6 +45,7 @@ public class GetSitesSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); } + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify user with Collaborator role gets sites information and gets status code OK (200)") public void collaboratorIsAbleToRetrieveSites() throws JsonToModelConversionException, Exception @@ -57,6 +58,7 @@ public class GetSitesSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); } + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify user with Contributor role gets sites information and gets status code OK (200)") public void contributorIsAbleToRetrieveSites() throws JsonToModelConversionException, Exception @@ -70,6 +72,7 @@ public class GetSitesSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); } + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role gets sites information and gets status code OK (200)") public void consumerIsAbleToRetrieveSites() throws JsonToModelConversionException, Exception @@ -83,6 +86,7 @@ public class GetSitesSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); } + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify user with Admin user gets sites information and gets status code OK (200)") public void adminUserIsAbleToRetrieveSites() throws JsonToModelConversionException, Exception @@ -96,6 +100,7 @@ public class GetSitesSanityTests extends RestTest } @Bug(id="MNT-16904") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Failed authentication get sites call returns status code 401") public void unauthenticatedUserIsNotAuthorizedToRetrieveSites() throws JsonToModelConversionException, Exception diff --git a/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java index 10cd63215..9b5483dfb 100644 --- a/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java @@ -19,7 +19,6 @@ import org.testng.annotations.Test; /** * @author iulia.cojocea */ -@Test(groups = {TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY}) public class RemoveSiteMemberSanityTests extends RestTest { private SiteModel siteModel; @@ -41,6 +40,7 @@ public class RemoveSiteMemberSanityTests extends RestTest dataUser.addUserToSite(testUserModel, siteModel, UserRole.SiteConsumer); } + @Test(groups = {TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY}) @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that site manager can delete site member and gets status code 204, 'No Content'") public void siteManagerIsAbleToDeleteSiteMemberWithConsumerRole() throws Exception{ @@ -52,6 +52,7 @@ public class RemoveSiteMemberSanityTests extends RestTest } @Bug(id="ACE-5444") + @Test(groups = {TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY}) @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that site collaborator cannot delete site member and gets status code 403, 'Forbidden'") public void siteCollaboratorIsNotAbleToDeleteSiteMemberWithConsumerRole() throws Exception{ @@ -64,6 +65,7 @@ public class RemoveSiteMemberSanityTests extends RestTest } @Bug(id="ACE-5444") + @Test(groups = {TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY}) @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that site contributor cannot delete site member and gets status code 403, 'Forbidden'") public void siteContributorIsNotAbleToDeleteSiteMemberWithConsumerRole() throws Exception{ @@ -76,6 +78,7 @@ public class RemoveSiteMemberSanityTests extends RestTest } @Bug(id="ACE-5444") + @Test(groups = {TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY}) @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that site consumer cannot delete site member and gets status code 403, 'Forbidden'") public void siteConsumerIsNotAbleToDeleteSiteMemberWithConsumerRole() throws Exception{ @@ -86,7 +89,8 @@ public class RemoveSiteMemberSanityTests extends RestTest restClient.withCoreAPI().getSites().assertThat().entriesListContains("id", testUserModel.getUsername()); restClient.assertStatusCodeIs(HttpStatus.OK); } - + + @Test(groups = {TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY}) @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that admin user can delete site member and gets status code 204, 'No Content'") public void adminUserIsAbleToDeleteSiteMember() throws Exception{ @@ -99,6 +103,7 @@ public class RemoveSiteMemberSanityTests extends RestTest } @Bug(id="MNT-16904") + @Test(groups = {TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY}) @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that unauthenticated user is not able to delete site member") public void unauthenticatedUserIsNotAuthorizedToDeleteSiteMember() throws Exception{ diff --git a/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberCoreTests.java index 9c1482950..25ff17c44 100644 --- a/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberCoreTests.java @@ -22,7 +22,6 @@ import org.testng.annotations.Test; /** * Created by Claudia Agache on 11/29/2016. */ -@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) public class UpdateSiteMemberCoreTests extends RestTest { private UserModel adminUser, regularUser, anotherManager; @@ -43,6 +42,7 @@ public class UpdateSiteMemberCoreTests extends RestTest regularUser.setUserRole(UserRole.SiteConsumer); } + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if update site member request returns status code 404 when nonexistent siteId is used") public void updateSiteMemberOfNonexistentSite() throws Exception @@ -57,6 +57,7 @@ public class UpdateSiteMemberCoreTests extends RestTest .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, deletedSite.getId())); } + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if update site member request returns status code 400 when personId is not member of the site") public void updateNotASiteMember() throws Exception @@ -68,6 +69,7 @@ public class UpdateSiteMemberCoreTests extends RestTest } @Bug(id="REPO-1642", description = "reproduced on 5.2.1 only, it works on 5.2.0") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if update site member request returns status code 404 when personId does not exist") public void updateNonexistentSiteMember() throws Exception @@ -81,6 +83,7 @@ public class UpdateSiteMemberCoreTests extends RestTest } @Bug(id="REPO-1660") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if a manager is able to downgrade to contributor using -me- string in place of personId.") public void updateSiteManagerToSiteContributorUsingMe() throws Exception @@ -96,6 +99,7 @@ public class UpdateSiteMemberCoreTests extends RestTest .and().field("role").is(meUser.getUserRole()); } + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if update site member request returns status code 404 when empty siteId is used") public void updateSiteMemberUsingEmptySiteId() throws Exception @@ -106,6 +110,7 @@ public class UpdateSiteMemberCoreTests extends RestTest .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); } + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if update site member request returns status code 405 when empty personId is used") public void updateSiteMemberUsingEmptyPersonId() throws Exception @@ -118,6 +123,7 @@ public class UpdateSiteMemberCoreTests extends RestTest .assertLastError().containsSummary(RestErrorModel.PUT_EMPTY_ARGUMENT); } + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if update site member request returns status code 400 when invalid role is used") public void updateSiteMemberUsingInvalidRole() throws Exception @@ -131,6 +137,7 @@ public class UpdateSiteMemberCoreTests extends RestTest .assertLastError().containsSummary(String.format(RestErrorModel.UNKNOWN_ROLE, "invalidRole")); } + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if manager is able to update another site manager to site collaborator") public void managerUpdateSiteManagerToSiteCollaborator() throws Exception @@ -144,6 +151,7 @@ public class UpdateSiteMemberCoreTests extends RestTest .and().field("role").is(siteManager.getUserRole()); } + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if manager is able to update site contributor to site manager") public void managerUpdateSiteContributorToSiteManager() throws Exception @@ -157,6 +165,7 @@ public class UpdateSiteMemberCoreTests extends RestTest .and().field("role").is(siteContributor.getUserRole()); } + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if manager is able to update site collaborator to site manager") public void managerUpdateSiteCollaboratorToSiteManager() throws Exception @@ -170,6 +179,7 @@ public class UpdateSiteMemberCoreTests extends RestTest .and().field("role").is(siteCollaborator.getUserRole()); } + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if manager is able to update site consumer to site manager") public void managerUpdateSiteConsumerToSiteManager() throws Exception @@ -183,6 +193,7 @@ public class UpdateSiteMemberCoreTests extends RestTest .and().field("role").is(siteConsumer.getUserRole()); } + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if manager is able to downgrade himself to site consumer") public void managerDowngradeHimselfToSiteConsumer() throws Exception @@ -195,5 +206,4 @@ public class UpdateSiteMemberCoreTests extends RestTest updatedMember.assertThat().field("id").is(siteManager.getUsername()) .and().field("role").is(siteManager.getUserRole()); } - } diff --git a/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java index 29e4703c0..9634b6370 100644 --- a/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java @@ -14,7 +14,6 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) public class UpdateSiteMemberSanityTests extends RestTest { private UserModel adminUserModel; @@ -33,6 +32,7 @@ public class UpdateSiteMemberSanityTests extends RestTest dataUser.addUserToSite(testUserModel, siteModel, UserRole.SiteConsumer); } + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that manager is able to update site member and gets status code OK (200)") public void managerIsAbleToUpdateSiteMember() throws Exception @@ -46,6 +46,7 @@ public class UpdateSiteMemberSanityTests extends RestTest } @Bug(id="ACE-5444") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that collaborator is not able to update site member and gets status code FORBIDDEN (403)") public void collaboratorIsNotAbleToUpdateSiteMember() throws Exception @@ -59,6 +60,7 @@ public class UpdateSiteMemberSanityTests extends RestTest } @Bug(id="ACE-5444") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that contributor is not able to update site member and gets status code FORBIDDEN (403)") public void contributorIsNotAbleToUpdateSiteMember() throws Exception @@ -72,6 +74,7 @@ public class UpdateSiteMemberSanityTests extends RestTest } @Bug(id="ACE-5444") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that consumer is not able to update site member and gets status code FORBIDDEN (403)") public void consumerIsNotAbleToUpdateSiteMember() throws Exception @@ -83,7 +86,8 @@ public class UpdateSiteMemberSanityTests extends RestTest .containsSummary(String.format("The current user does not have permissions to modify the membership details of the site %s.", siteModel.getTitle())); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); } - + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that admin is able to update site member and gets status code OK (200)") public void adminIsAbleToUpdateSiteMember() throws Exception @@ -97,6 +101,7 @@ public class UpdateSiteMemberSanityTests extends RestTest } @Bug(id="MNT-16904") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that unauthenticated user is not able to update site member") public void unauthenticatedUserIsNotAuthorizedToUpdateSiteMmeber() throws Exception{ From bdd3f326dd8abd64d3c1caf173a8237547ca47a3 Mon Sep 17 00:00:00 2001 From: Bogdan Bocancea Date: Mon, 12 Dec 2016 10:46:19 +0200 Subject: [PATCH 0757/1491] move @Test annotation from class to method level --- .../DeleteDeploymentCoreTests.java | 3 +- .../DeleteDeploymentSanityTests.java | 4 +-- .../deployments/GetDeploymentCoreTests.java | 15 +++++---- .../deployments/GetDeploymentSanityTests.java | 3 +- .../deployments/GetDeploymentsCoreTests.java | 17 +++++----- .../GetDeploymentsSanityTests.java | 10 +++--- .../GetProcessDefinitionCoreTests.java | 11 ++----- .../GetProcessDefinitionImageCoreTests.java | 10 ++---- .../GetProcessDefinitionImageSanityTests.java | 9 ++++-- .../GetProcessDefinitionSanityTests.java | 3 +- ...cessDefinitionStartFormModelCoreTests.java | 9 +++--- ...ssDefinitionStartFormModelSanityTests.java | 4 +-- .../GetProcessDefinitionsCoreTests.java | 6 ++-- .../GetProcessDefinitionsSanityTests.java | 6 ++-- .../processes/AddProcessCoreTests.java | 7 ++++- .../processes/AddProcessItemCoreTests.java | 31 ++++++++++--------- .../processes/AddProcessItemSanityTests.java | 3 +- .../processes/AddProcessSanityTests.java | 10 +++--- .../AddProcessVariableCoreTests.java | 29 +++++++++++------ .../AddProcessVariableSanityTests.java | 6 ++-- .../processes/DeleteProcessCoreTests.java | 4 ++- .../processes/DeleteProcessItemCoreTests.java | 4 ++- .../DeleteProcessItemSanityTests.java | 3 +- .../processes/DeleteProcessSanityTests.java | 15 +++++---- .../DeleteProcessVariableCoreTests.java | 4 ++- .../DeleteProcessVariableSanityTests.java | 3 +- .../processes/GetProcessItemsSanityTests.java | 6 ++-- .../processes/GetProcessSanityTests.java | 16 +++++----- .../processes/GetProcessTasksSanityTests.java | 13 +++++--- .../GetProcessVariablesSanityTests.java | 3 +- .../processes/GetProcessesCoreTests.java | 9 +++--- .../processes/GetProcessesSanityTests.java | 21 +++++++------ .../UpdateProcessVariableSanityTests.java | 4 ++- 33 files changed, 174 insertions(+), 127 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentCoreTests.java index 501bfa1ec..af521d2f6 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentCoreTests.java @@ -12,7 +12,6 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { TestGroup.REST_API, TestGroup.DEPLOYMENTS, TestGroup.CORE, TestGroup.WORKFLOW }) public class DeleteDeploymentCoreTests extends RestTest { private UserModel adminUser; @@ -29,6 +28,7 @@ public class DeleteDeploymentCoreTests extends RestTest @Bug(id = "MNT-16996") @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify deleteDeployment is unsupported for empty deployment id with REST API and status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.DEPLOYMENTS, TestGroup.CORE, TestGroup.WORKFLOW }) public void deleteDeploymentIsUnsupportedForEmptyId() throws Exception { deployment = restClient.authenticateUser(adminUser).withWorkflowAPI().getDeployments().getOneRandomEntry().onModel(); @@ -41,6 +41,7 @@ public class DeleteDeploymentCoreTests extends RestTest @Bug(id = "MNT-16996") @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify deleteDeployment is forbidden using non admin user or different user than creator with REST API and status code is 403") + @Test(groups = { TestGroup.REST_API, TestGroup.DEPLOYMENTS, TestGroup.CORE, TestGroup.WORKFLOW }) public void deleteDeploymentUsingNonAdminUser() throws Exception { deployment = restClient.authenticateUser(adminUser).withWorkflowAPI().getDeployments().getOneRandomEntry().onModel(); diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java index ad0e5843b..0d7def475 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java @@ -20,8 +20,6 @@ import org.testng.annotations.Test; * @author Cristina Axinte * */ - -@Test(groups = { TestGroup.REST_API, TestGroup.DEPLOYMENTS, TestGroup.SANITY, TestGroup.WORKFLOW }, priority = 100) public class DeleteDeploymentSanityTests extends RestTest { private UserModel adminUser; @@ -36,6 +34,7 @@ public class DeleteDeploymentSanityTests extends RestTest @Bug(id = "MNT-16996") @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.SANITY, description = "Verify admin user deletes a specific deployment using REST API and status code is successful (204)") + @Test(groups = { TestGroup.REST_API, TestGroup.DEPLOYMENTS, TestGroup.SANITY, TestGroup.WORKFLOW }, priority = 100) public void adminDeletesDeploymentWithSuccess() throws Exception { dataContent.assertExtensionAmpExists("alfresco-workflow-extension"); @@ -51,6 +50,7 @@ public class DeleteDeploymentSanityTests extends RestTest @Bug(id = "MNT-16996") @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.SANITY, description = "Verify admin user cannot delete an inexistent deployment using REST API and status code is successful (204)") + @Test(groups = { TestGroup.REST_API, TestGroup.DEPLOYMENTS, TestGroup.SANITY, TestGroup.WORKFLOW }, priority = 100) public void adminCannotDeleteInexistentDeployment() throws Exception { deployment = restClient.authenticateUser(adminUser).withWorkflowAPI().getDeployments().getOneRandomEntry().onModel(); diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentCoreTests.java index 34fbcc70e..0fbad6d14 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentCoreTests.java @@ -14,7 +14,6 @@ import org.testng.annotations.Test; /** * Created by Claudia Agache on 12/7/2016. */ -@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.CORE }) public class GetDeploymentCoreTests extends RestTest { private UserModel adminUser, adminTenantUser; @@ -27,7 +26,9 @@ public class GetDeploymentCoreTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, - executionType = ExecutionType.REGRESSION, description = "Verify if get deployment request returns status code 404 when invalid deploymentId is used.") + executionType = ExecutionType.REGRESSION, + description = "Verify if get deployment request returns status code 404 when invalid deploymentId is used.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.CORE }) public void getNonNetworkDeploymentUsingInvalidDeploymentId() throws Exception { expectedDeployment = restClient.authenticateUser(adminUser).withWorkflowAPI().getDeployments().getOneRandomEntry().onModel(); @@ -39,8 +40,9 @@ public class GetDeploymentCoreTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, - executionType = ExecutionType.REGRESSION, description = "Verify if network admin user gets a network deployment using REST API and status code is OK (200)") - @Test(groups = { TestGroup.NETWORKS }) + executionType = ExecutionType.REGRESSION, + description = "Verify if network admin user gets a network deployment using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.CORE, TestGroup.NETWORKS}) public void adminGetsNetworkDeploymentWithSuccess() throws Exception { adminTenantUser = UserModel.getAdminTenantUser(); @@ -56,8 +58,9 @@ public class GetDeploymentCoreTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, - executionType = ExecutionType.REGRESSION, description = "Verify non admin user is forbidden to get a network deployment using REST API (403)") - @Test(groups = { TestGroup.NETWORKS }) + executionType = ExecutionType.REGRESSION, + description = "Verify non admin user is forbidden to get a network deployment using REST API (403)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.CORE, TestGroup.NETWORKS }) public void nonAdminUserIsForbiddenToGetNetworkDeployment() throws Exception { adminTenantUser = UserModel.getAdminTenantUser(); diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentSanityTests.java index d25584515..3259dbb1c 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentSanityTests.java @@ -18,7 +18,6 @@ import org.testng.annotations.Test; * @author Cristina Axinte * */ -@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.SANITY }) public class GetDeploymentSanityTests extends RestTest { private UserModel adminUser; @@ -36,6 +35,7 @@ public class GetDeploymentSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.SANITY, description = "Verify admin user gets a non-network deployment using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.SANITY }) public void adminGetsNonNetworkDeploymentWithSuccess() throws JsonToModelConversionException, Exception { actualDeployment = restClient.authenticateUser(adminUser).withWorkflowAPI().usingDeployment(expectedDeployment).getDeployment(); @@ -47,6 +47,7 @@ public class GetDeploymentSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.SANITY, description = "Verify non admin user is forbidden to get a non-network deployment using REST API (403)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.SANITY }) public void nonAdminIsForbiddenToGetNonNetworkDeployment() throws JsonToModelConversionException, Exception { restClient.authenticateUser(anotherUser).withWorkflowAPI().usingDeployment(expectedDeployment).getDeployment(); diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsCoreTests.java index 07aa4680e..929709156 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsCoreTests.java @@ -18,7 +18,6 @@ import java.util.List; /** * Created by Claudia Agache on 12/7/2016. */ -@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.CORE}) public class GetDeploymentsCoreTests extends RestTest { private UserModel adminUser, adminTenantUser; @@ -31,7 +30,9 @@ public class GetDeploymentsCoreTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.DEPLOYMENTS }, - executionType = ExecutionType.REGRESSION, description = "Verify non admin user is not able to get non-network deployments using REST API and status code is Forbidden") + executionType = ExecutionType.REGRESSION, + description = "Verify non admin user is not able to get non-network deployments using REST API and status code is Forbidden") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.CORE}) public void nonAdminUserCanNotGetNonNetworkDeployments() throws Exception { UserModel userModel = dataUser.createRandomTestUser(); @@ -41,8 +42,9 @@ public class GetDeploymentsCoreTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.DEPLOYMENTS }, - executionType = ExecutionType.REGRESSION, description = "Verify non admin user is not able to get network deployments using REST API and status code is Forbidden") - @Test(groups = { TestGroup.NETWORKS }) + executionType = ExecutionType.REGRESSION, + description = "Verify non admin user is not able to get network deployments using REST API and status code is Forbidden") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.CORE, TestGroup.NETWORKS}) public void nonAdminUserCanNotGetNetworkDeployments() throws Exception { adminTenantUser = UserModel.getAdminTenantUser(); @@ -57,21 +59,20 @@ public class GetDeploymentsCoreTests extends RestTest @Bug(id = "MNT-16996") @TestRail(section = { TestGroup.REST_API, TestGroup.DEPLOYMENTS }, - executionType = ExecutionType.REGRESSION, description = "Verify get deployments returns an empty list after deleting all network deployments.") - @Test(groups = { TestGroup.NETWORKS }) + executionType = ExecutionType.REGRESSION, + description = "Verify get deployments returns an empty list after deleting all network deployments.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.CORE, TestGroup.NETWORKS}) public void getNetworkDeploymentsAfterDeletingAllNetworkDeployments() throws Exception { adminTenantUser = UserModel.getAdminTenantUser(); restClient.authenticateUser(adminUser) .usingTenant().createTenant(adminTenantUser); - List networkDeployments = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getDeployments().getEntries(); for (RestDeploymentModel networkDeployment: networkDeployments) { restClient.withWorkflowAPI().usingDeployment(networkDeployment.onModel()).deleteDeployment(); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } - deployments = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getDeployments(); restClient.assertStatusCodeIs(HttpStatus.OK); deployments.assertThat().entriesListIsEmpty(); diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsSanityTests.java index ca63d4b78..df66b5e57 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsSanityTests.java @@ -14,7 +14,6 @@ import org.testng.annotations.Test; /** * Created by Claudia Agache on 10/4/2016. */ -@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.SANITY}) public class GetDeploymentsSanityTests extends RestTest { private UserModel adminUserModel, adminTenantUser; @@ -29,7 +28,9 @@ public class GetDeploymentsSanityTests extends RestTest } @TestRail(section = { TestGroup.REST_API, - TestGroup.DEPLOYMENTS }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets non-network deployments using REST API and status code is OK (200)") + TestGroup.DEPLOYMENTS }, executionType = ExecutionType.SANITY, + description = "Verify Admin user gets non-network deployments using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.SANITY}) public void getNonNetworkDeploymentsWithAdmin() throws JsonToModelConversionException, Exception { deployments = restClient.authenticateUser(adminUserModel).withWorkflowAPI().getDeployments(); @@ -38,8 +39,9 @@ public class GetDeploymentsSanityTests extends RestTest } @TestRail(section = { TestGroup.REST_API, - TestGroup.DEPLOYMENTS }, executionType = ExecutionType.SANITY, description = "Verify Tenant Admin user gets network deployments using REST API and status code is OK (200)") - @Test(groups = { TestGroup.NETWORKS }) + TestGroup.DEPLOYMENTS }, executionType = ExecutionType.SANITY, + description = "Verify Tenant Admin user gets network deployments using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.SANITY, TestGroup.NETWORKS}) public void getNetworkDeploymentsWithAdmin() throws JsonToModelConversionException, Exception { restClient.usingTenant().createTenant(adminTenantUser); diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionCoreTests.java index 0ee7933fb..b8bf9cb89 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionCoreTests.java @@ -14,7 +14,6 @@ import org.testng.annotations.Test; /** * Created by Claudia Agache on 12/5/2016. */ -@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.CORE }) public class GetProcessDefinitionCoreTests extends RestTest { private UserModel adminUser, adminTenantUser; @@ -29,12 +28,12 @@ public class GetProcessDefinitionCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify if get process definition returns status code 404 when invalid processDefinitionId is used") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.CORE }) public void getProcessDefinitionUsingInvalidProcessDefinitionId() throws Exception { restClient.authenticateUser(adminUser); randomProcessDefinition = restClient.withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry().onModel(); randomProcessDefinition.setId("invalidID"); - restClient.withWorkflowAPI() .usingProcessDefinitions(randomProcessDefinition).getProcessDefinition(); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) @@ -44,13 +43,12 @@ public class GetProcessDefinitionCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify network admin is able to get a process definition using REST API and status code is OK (200)") - @Test(groups = { TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.CORE, TestGroup.NETWORKS }) public void networkAdminGetProcessDefinition() throws Exception { adminTenantUser = UserModel.getAdminTenantUser(); restClient.authenticateUser(adminUser) .usingTenant().createTenant(adminTenantUser); - randomProcessDefinition = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry().onModel(); returnedProcessDefinition = restClient.withWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinition(); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -60,15 +58,13 @@ public class GetProcessDefinitionCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify network user is able to get a process definition using REST API and status code is OK (200)") - @Test(groups = { TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.CORE, TestGroup.NETWORKS }) public void networkUserGetProcessDefinition() throws Exception { adminTenantUser = UserModel.getAdminTenantUser(); restClient.authenticateUser(adminUser) .usingTenant().createTenant(adminTenantUser); - UserModel tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - randomProcessDefinition = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() .getAllProcessDefinitions().getOneRandomEntry().onModel(); returnedProcessDefinition = restClient.authenticateUser(tenantUser).withWorkflowAPI() @@ -76,5 +72,4 @@ public class GetProcessDefinitionCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); returnedProcessDefinition.assertThat().field("name").is(randomProcessDefinition.getName()); } - } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageCoreTests.java index 782030919..790311f74 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageCoreTests.java @@ -15,7 +15,6 @@ import org.testng.annotations.Test; /** * Created by Claudia Agache on 12/6/2016. */ -@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.CORE }) public class GetProcessDefinitionImageCoreTests extends RestTest { private UserModel adminUser, adminTenantUser; @@ -30,12 +29,12 @@ public class GetProcessDefinitionImageCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify if get process definition image returns status code 404 when invalid processDefinitionId is used") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.CORE }) public void getProcessDefinitionImageUsingInvalidProcessDefinitionId() throws Exception { restClient.authenticateUser(adminUser); randomProcessDefinition = restClient.withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry(); randomProcessDefinition.onModel().setId("invalidID"); - restClient.withWorkflowAPI() .usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionImage(); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) @@ -45,14 +44,13 @@ public class GetProcessDefinitionImageCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify network admin is able to get a process definition image using REST API and status code is OK (200)") - @Test(groups = { TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.CORE, TestGroup.NETWORKS }) @Bug(id = "MNT-17243") public void networkAdminGetProcessDefinitionImage() throws Exception { adminTenantUser = UserModel.getAdminTenantUser(); restClient.authenticateUser(adminUser) .usingTenant().createTenant(adminTenantUser); - randomProcessDefinition = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry(); restClient.withWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionImage() .assertResponseContainsImage(); @@ -62,16 +60,14 @@ public class GetProcessDefinitionImageCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify network user is able to get a process definition image using REST API and status code is OK (200)") - @Test(groups = { TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.CORE, TestGroup.NETWORKS }) @Bug(id = "MNT-17243") public void networkUserGetProcessDefinitionImage() throws Exception { adminTenantUser = UserModel.getAdminTenantUser(); restClient.authenticateUser(adminUser) .usingTenant().createTenant(adminTenantUser); - UserModel tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - randomProcessDefinition = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() .getAllProcessDefinitions().getOneRandomEntry(); restClient.authenticateUser(tenantUser).withWorkflowAPI() diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java index ce1ab2d56..361e1d4e8 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java @@ -13,7 +13,6 @@ import org.testng.annotations.Test; /** * Created by Claudia Agache on 10/13/2016. */ -@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY }) public class GetProcessDefinitionImageSanityTests extends RestTest { private UserModel testUser; @@ -27,7 +26,9 @@ public class GetProcessDefinitionImageSanityTests extends RestTest randomProcessDefinition = restClient.withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry(); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.SANITY, description = "Verify Any user gets a specific process definition image for non-network deployments using REST API and status code is OK (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.SANITY, + description = "Verify Any user gets a specific process definition image for non-network deployments using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY }) public void anyUserGetsProcessDefinitionImage() throws Exception { restClient.authenticateUser(testUser); @@ -36,7 +37,9 @@ public class GetProcessDefinitionImageSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets a specific process definition image for non-network deployments using REST API and status code is OK (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.SANITY, + description = "Verify Admin user gets a specific process definition image for non-network deployments using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY }) public void adminGetsProcessDefinitionImage() throws Exception { restClient.withWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionImage() diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java index da8aaf7c0..ac7d3e9cb 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java @@ -13,7 +13,6 @@ import org.testng.annotations.Test; /** * Created by Claudia Agache on 10/13/2016. */ -@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY }) public class GetProcessDefinitionSanityTests extends RestTest { private UserModel testUser; @@ -30,6 +29,7 @@ public class GetProcessDefinitionSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets a specific process definition for non-network deployments using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY }) public void adminGetsProcessDefinition() throws Exception { returnedProcessDefinition = restClient.withWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinition(); @@ -40,6 +40,7 @@ public class GetProcessDefinitionSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.SANITY, description = "Verify Any user gets a specific process definition for non-network deployments using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY }) public void anyUserGetsProcessDefinition() throws Exception { restClient.authenticateUser(testUser); diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java index e8a56fcae..6ddc232cc 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java @@ -16,7 +16,6 @@ import org.testng.annotations.Test; /** * Created by Claudia Agache on 12/6/2016. */ -@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.CORE }) public class GetProcessDefinitionStartFormModelCoreTests extends RestTest { private UserModel adminUser, adminTenantUser; @@ -33,10 +32,10 @@ public class GetProcessDefinitionStartFormModelCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify any user gets a model of the start form type definition for non-network deployments using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.CORE }) public void nonNetworkUserGetsStartFormModel() throws Exception { UserModel nonNetworkUser = dataUser.createRandomTestUser(); - randomProcessDefinition = allProcessDefinitions.getOneRandomEntry(); restClient.authenticateUser(nonNetworkUser).withWorkflowAPI() .usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionStartFormModel() @@ -48,6 +47,7 @@ public class GetProcessDefinitionStartFormModelCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify if get request returns status code 404 when invalid processDefinitionId is used") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.CORE }) public void getStartFormModelUsingInvalidProcessDefinitionId() throws Exception { randomProcessDefinition = allProcessDefinitions.getOneRandomEntry(); @@ -63,6 +63,7 @@ public class GetProcessDefinitionStartFormModelCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify if get request returns status code 404 when empty processDefinitionId is used") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.CORE }) public void getStartFormModelUsingEmptyProcessDefinitionId() throws Exception { randomProcessDefinition = allProcessDefinitions.getOneRandomEntry(); @@ -77,15 +78,13 @@ public class GetProcessDefinitionStartFormModelCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify Tenant User gets a model of the start form type definition for network deployments using REST API and status code is OK (200)") - @Test(groups = { TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.CORE, TestGroup.NETWORKS }) public void networkUserGetsStartFormModel() throws Exception { adminTenantUser = UserModel.getAdminTenantUser(); restClient.authenticateUser(adminUser) .usingTenant().createTenant(adminTenantUser); - UserModel tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - randomProcessDefinition = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() .getAllProcessDefinitions().getOneRandomEntry(); restClient.authenticateUser(tenantUser).withWorkflowAPI() diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java index bef2437df..7603af737 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java @@ -13,7 +13,6 @@ import org.testng.annotations.Test; /** * Created by Claudia Agache on 10/18/2016. */ -@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY }) public class GetProcessDefinitionStartFormModelSanityTests extends RestTest { private UserModel adminUserModel, adminTenantUser; @@ -30,6 +29,7 @@ public class GetProcessDefinitionStartFormModelSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.SANITY, description = "Verify Admin gets a model of the start form type definition for non-network deployments using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY }) public void nonNetworkAdminGetsStartFormModel() throws Exception { randomProcessDefinition = restClient.withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry(); @@ -40,7 +40,7 @@ public class GetProcessDefinitionStartFormModelSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.SANITY, description = "Verify Tenant Admin gets a model of the start form type definition for network deployments using REST API and status code is OK (200)") - @Test(groups = { TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY, TestGroup.NETWORKS }) public void networkAdminGetsStartFormModel() throws Exception { restClient.usingTenant().createTenant(adminTenantUser); diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsCoreTests.java index 072bf0c55..750feacb7 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsCoreTests.java @@ -10,7 +10,6 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.CORE }) public class GetProcessDefinitionsCoreTests extends RestTest { private UserModel adminUserModel; @@ -28,6 +27,7 @@ public class GetProcessDefinitionsCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify any user gets process definitions for non-network deployments using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.CORE }) public void nonNetworkUserGetsProcessDefinitions() throws Exception { restClient.authenticateUser(userModel) @@ -39,7 +39,7 @@ public class GetProcessDefinitionsCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify get process definitions using any network user for network enabled deployments with REST API status code is OK (200)") - @Test(groups = { TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.CORE, TestGroup.NETWORKS}) public void networkUserGetsProcessDefinitions() throws Exception { restClient.authenticateUser(adminUserModel).usingTenant().createTenant(adminTenantUser); @@ -53,6 +53,7 @@ public class GetProcessDefinitionsCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify call to get process definitions with invalid orderBy parameter with REST API and status code is BAD_REQUEST (400)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.CORE }) public void userGetProcessDefinitionsWithInvalidOrderBy() throws Exception { restClient.authenticateUser(userModel) @@ -66,6 +67,7 @@ public class GetProcessDefinitionsCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify call to get process definitions with invalid where parameter with REST API and status code is BAD_REQUEST (400)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.CORE }) public void userGetProcessDefinitionsWithInvalidWhere() throws Exception { restClient.authenticateUser(userModel) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java index 6db1d8b8a..dbdd1cf7b 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java @@ -14,7 +14,6 @@ import org.testng.annotations.Test; /** * Created by Claudia Agache on 10/13/2016. */ -@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY }) public class GetProcessDefinitionsSanityTests extends RestTest { @Autowired @@ -32,6 +31,7 @@ public class GetProcessDefinitionsSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets process definitions for non-network deployments using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY }) public void nonNetworkAdminGetsProcessDefinitions() throws Exception { restClient.authenticateUser(adminUserModel); @@ -39,11 +39,9 @@ public class GetProcessDefinitionsSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); } - // works on alfresco.server=172.29.100.215 @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.SANITY, description = "Verify Tenant Admin user gets process definitions for network deployments using REST API and status code is OK (200)") - - @Test(groups = { TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY, TestGroup.NETWORKS}) public void networkAdminGetsProcessDefinitions() throws Exception { restClient.usingTenant().createTenant(adminTenantUser); diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessCoreTests.java index 676741b11..12bc5e898 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessCoreTests.java @@ -21,7 +21,6 @@ import org.testng.annotations.Test; * @author Cristina Axinte * */ -@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) public class AddProcessCoreTests extends RestTest { private UserModel assignee, adminUser; @@ -30,6 +29,7 @@ public class AddProcessCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify non network admin is able to start new process using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) public void nonNetworkAdminUserStartsNewProcess() throws JsonToModelConversionException, Exception { adminUser = dataUser.getAdminUser(); @@ -52,6 +52,7 @@ public class AddProcessCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify start new process with empty request body using REST API returns status code is Bad Request (400)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) public void startNewProcessWithEmptyProcessBody() throws JsonToModelConversionException, Exception { adminUser = dataUser.getAdminUser(); @@ -67,6 +68,7 @@ public class AddProcessCoreTests extends RestTest @Bug(id = "ACE-5671") @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify start new process with invalid request body using REST API returns status code is Bad Request (400)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) public void startNewProcessWithInvalidProcessDefInProcessBody() throws JsonToModelConversionException, Exception { adminUser = dataUser.getAdminUser(); @@ -80,6 +82,7 @@ public class AddProcessCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify start new process with invalid request body using REST API returns status code is Bad Request (400)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) public void startNewProcessWithInvalidVariablesInProcessBody1() throws JsonToModelConversionException, Exception { adminUser = dataUser.getAdminUser(); @@ -94,6 +97,7 @@ public class AddProcessCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify start new process with invalid request body using REST API returns status code is Bad Request (400)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) public void startNewProcessWithInvalidVariablesInProcessBody2() throws JsonToModelConversionException, Exception { adminUser = dataUser.getAdminUser(); @@ -108,6 +112,7 @@ public class AddProcessCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify start new process with invalid request body using REST API returns status code is Bad Request (400)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) public void startNewProcessWithInvalidVariablesInProcessBody3() throws JsonToModelConversionException, Exception { adminUser = dataUser.getAdminUser(); diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemCoreTests.java index f7b83d8f2..1d425ba91 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemCoreTests.java @@ -38,8 +38,9 @@ public class AddProcessItemCoreTests extends RestTest dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); } + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Add process item using by the user who started the process.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add process item using by the user who started the process.") public void addProcessItemByUserThatStartedTheProcess() throws Exception { processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); @@ -49,11 +50,11 @@ public class AddProcessItemCoreTests extends RestTest processItem.assertThat().field("createdAt").isNotEmpty().and().field("size").is("19").and().field("createdBy").is(adminUser.getUsername()).and() .field("modifiedAt").isNotEmpty().and().field("name").is(document.getName()).and().field("modifiedBy").is(userWhoStartsProcess.getUsername()) .and().field("id").isNotEmpty().and().field("mimeType").is(document.getFileType().mimeType); - } + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Add process item by a random user.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add process item by a random user.") public void addProcessItemByAnyUser() throws Exception { anotherUser = dataUser.createRandomTestUser(); @@ -66,8 +67,9 @@ public class AddProcessItemCoreTests extends RestTest .containsSummary(String.format(RestErrorModel.ACCESS_INFORMATION_NOT_ALLOWED, processModel.getId())); } + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Add process item using by the admin in same network.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE, TestGroup.NETWORKS }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add process item using by the admin in same network.") public void addProcessItemByAdminSameNetwork() throws Exception { restClient.authenticateUser(adminUser); @@ -87,11 +89,11 @@ public class AddProcessItemCoreTests extends RestTest processItem.assertThat().field("createdAt").isNotEmpty().and().field("size").is("19").and().field("createdBy").is(adminUser.getUsername()).and() .field("modifiedAt").isNotEmpty().and().field("name").is(document.getName()).and().field("modifiedBy").is(adminUser.getUsername()).and() .field("id").isNotEmpty().and().field("mimeType").is(document.getFileType().mimeType); - } + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Add process item using by admin in other network.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE, TestGroup.NETWORKS }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Add process item using by admin in other network.") public void addProcessItemByAdminInOtherNetwork() throws Exception { adminTenantUser = UserModel.getAdminTenantUser(); @@ -107,48 +109,47 @@ public class AddProcessItemCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT); } + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding process item is falling in case of invalid process id is provided") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process item is falling in case of invalid process id is provided") public void failedAddingProcessItemIfInvalidProcessIdIsProvided() throws Exception { processModel = restClient.authenticateUser(adminUser).withParams("maxItems=1").withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); processModel.setId("invalidProcessId"); processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidProcessId")); } @Bug(id = "ACE-5683") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding process item is falling in case of invalid body item is provided") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process item is falling in case of invalid body item is provided") public void failedAddingProcessItemIfInvalidItemBodyIsProvided() throws Exception { document.setNodeRef("invalidNodeRef"); processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidId")); } + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding process item is falling in case of empty body item value is provided") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process item is falling in case of empty body item value is provided") public void failedAddingProcessItemIfEmptyItemBodyIsProvided() throws Exception { document.setNodeRef(""); processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.REQUIRED_TO_ADD, "itemId")); } + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding process item is falling in case of incomplete body (empty) is provided") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process item is falling in case of incomplete body (empty) is provided") public void failedAddingProcessItemIfIncompleteBodyIsProvided() throws Exception { processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{}", "processes/{processId}/items", processModel.getId()); restClient.processModel(RestItemModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.REQUIRED_TO_ADD, "itemId")); } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemSanityTests.java index 94d4b9d6d..a0d7044d2 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemSanityTests.java @@ -20,7 +20,6 @@ import org.testng.annotations.Test; /** * @author iulia.cojocea */ -@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY}) public class AddProcessItemSanityTests extends RestTest { private FileModel document, document2; @@ -42,6 +41,7 @@ public class AddProcessItemSanityTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Create non-existing process item") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY}) public void addProcessItem() throws JsonToModelConversionException, Exception { document2 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file content"); @@ -66,6 +66,7 @@ public class AddProcessItemSanityTests extends RestTest @Bug(id= "MNT-16966") @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Add process item that already exists") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY}) public void addProcessItemThatAlreadyExists() throws JsonToModelConversionException, Exception { document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessSanityTests.java index 75543e943..c1e110d7d 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessSanityTests.java @@ -15,7 +15,6 @@ import org.testng.annotations.Test; /** * Created by Claudia Agache on 10/18/2016. */ -@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public class AddProcessSanityTests extends RestTest { private UserModel userWhoStartsProcess, assignee; @@ -24,7 +23,9 @@ public class AddProcessSanityTests extends RestTest private RestProcessModelsCollection processes; @TestRail(section = { TestGroup.REST_API, - TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify non network user is able to start new process using REST API and status code is OK (200)") + TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Verify non network user is able to start new process using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public void nonNetworkUserStartsNewProcess() throws JsonToModelConversionException, Exception { userWhoStartsProcess = dataUser.createRandomTestUser(); @@ -41,8 +42,9 @@ public class AddProcessSanityTests extends RestTest } @TestRail(section = { TestGroup.REST_API, - TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify network user is able to start new process using REST API and status code is OK (200)") - @Test(groups = { TestGroup.NETWORKS }) + TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Verify network user is able to start new process using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY, TestGroup.NETWORKS }) public void networkUserStartsNewProcess() throws JsonToModelConversionException, Exception { adminTenantUser = UserModel.getAdminTenantUser(); diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableCoreTests.java index 4e89726d0..3df6e4c01 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableCoreTests.java @@ -39,8 +39,9 @@ public class AddProcessVariableCoreTests extends RestTest dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); } + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Add process variable using by the user who started the process.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add process variable using by the user who started the process.") public void addProcessVariableByUserThatStartedTheProcess() throws Exception { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); @@ -52,8 +53,9 @@ public class AddProcessVariableCoreTests extends RestTest .is(processVariable.getValue()); } + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Add process variable using by a random user.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add process variable using by a random user.") public void addProcessVariableByAnyUser() throws Exception { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); @@ -65,8 +67,9 @@ public class AddProcessVariableCoreTests extends RestTest .is(processVariable.getValue()); } + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Add process variable using by admin in other network.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE, TestGroup.NETWORKS }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add process variable using by admin in other network.") public void addProcessVariableByAdminInOtherNetwork() throws Exception { adminTenantUser = UserModel.getAdminTenantUser(); @@ -84,8 +87,9 @@ public class AddProcessVariableCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT); } + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding process variable is falling in case invalid type is provided") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process variable is falling in case invalid type is provided") public void failedAddingProcessVariableIfInvalidTypeIsProvided() throws Exception { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:textarea"); @@ -96,9 +100,10 @@ public class AddProcessVariableCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Unsupported type of variable: 'd:textarea'."); } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) @Bug(id = "ACE-5674") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process variable is falling in case invalid type prefix is provided") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding process variable is falling in case invalid type prefix is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) public void failedAddingProcessVariableIfInvalidTypePrefixIsProvided() throws Exception { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("ddt:text"); @@ -109,8 +114,9 @@ public class AddProcessVariableCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Namespace prefix ddt is not mapped to a namespace URI"); } + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding process variable is falling in case invalid value is provided") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process variable is falling in case invalid value is provided") public void failedAddingProcessVariableIfInvalidValueIsProvided() throws Exception { RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:int"); @@ -122,8 +128,9 @@ public class AddProcessVariableCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("For input string: \"invalidValue\""); } + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding process variable is falling in case missing required variable body (name) is provided") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process variable is falling in case missing required variable body (name) is provided") public void failedAddingProcessVariableIfMissingRequiredVariableBodyIsProvided() throws Exception { processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); @@ -135,8 +142,9 @@ public class AddProcessVariableCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Variable name is required."); } + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding process variable is falling in case invalid variableBody (adding extra parameter in body) is provided") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process variable is falling in case invalid variableBody (adding extra parameter in body) is provided") public void failedAddingProcessVariableIfInvalidBodyIsProvided() throws Exception { processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); @@ -149,8 +157,9 @@ public class AddProcessVariableCoreTests extends RestTest .containsSummary("Could not read content from HTTP request body: Unrecognized field \"scope\""); } + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding process variable is falling in case empty name is provided") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process variable is falling in case empty name is provided") public void failedAddingProcessVariableIfEmptyNameIsProvided() throws Exception { processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java index 5a33e94fc..aa509009b 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java @@ -19,7 +19,6 @@ import org.testng.annotations.Test; /** * @author iulia.cojocea */ -@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public class AddProcessVariableSanityTests extends RestTest { private FileModel document; @@ -41,6 +40,7 @@ public class AddProcessVariableSanityTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Create non-existing variable") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public void addProcessVariable() throws Exception { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); @@ -58,6 +58,7 @@ public class AddProcessVariableSanityTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Update existing variable") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public void updateExistingProcessVariable() throws Exception { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); @@ -75,9 +76,9 @@ public class AddProcessVariableSanityTests extends RestTest processVariable.assertThat().field("value").is(newValue); } - @Test(groups = { TestGroup.NETWORKS }) @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Add process variable using admin user from same network") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY, TestGroup.NETWORKS }) public void addProcessVariableByAdmin() throws Exception { adminTenantUser = UserModel.getAdminTenantUser(); @@ -97,6 +98,7 @@ public class AddProcessVariableSanityTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Adding process variable is falling in case invalid variableBody is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public void failedAddingProcessVariableIfInvalidBodyIsProvided() throws Exception { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("incorrect type"); diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessCoreTests.java index 110acf878..98f6226ec 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessCoreTests.java @@ -12,7 +12,6 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) public class DeleteProcessCoreTests extends RestTest { private UserModel userWhoAddsProcess, assignee; @@ -28,6 +27,7 @@ public class DeleteProcessCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify admin user is able to delete a process started by another user.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) public void deleteProcessByAdminUser() throws Exception { process = restClient.authenticateUser(userWhoAddsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); @@ -42,6 +42,7 @@ public class DeleteProcessCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify User is not able to delete process with invalid id") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) public void deleteProcessWithInvalidId() throws Exception { process = restClient.authenticateUser(userWhoAddsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); @@ -55,6 +56,7 @@ public class DeleteProcessCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify User is not able to delete process with empty id") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) public void deleteProcessWithEmptyId() throws Exception { process = restClient.authenticateUser(userWhoAddsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessItemCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessItemCoreTests.java index dfe37b9ad..71fa125bc 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessItemCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessItemCoreTests.java @@ -17,7 +17,6 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) public class DeleteProcessItemCoreTests extends RestTest { private FileModel document, secondDoc; @@ -40,6 +39,7 @@ public class DeleteProcessItemCoreTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Delete process item with invalid id") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) public void deleteProcessItemWithInvalidItemId() throws Exception { restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() @@ -54,6 +54,7 @@ public class DeleteProcessItemCoreTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Delete process item with empty id") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) public void deleteProcessItemWithEmptyItemId() throws Exception { restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() @@ -68,6 +69,7 @@ public class DeleteProcessItemCoreTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Delete process item twice") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) public void deleteProcessItemTwice() throws Exception { restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessItemSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessItemSanityTests.java index 4f86e110c..f5f9e0170 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessItemSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessItemSanityTests.java @@ -17,7 +17,6 @@ import org.testng.annotations.Test; /** * @author iulia.cojocea */ -@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public class DeleteProcessItemSanityTests extends RestTest { private FileModel document, document2; @@ -39,6 +38,7 @@ public class DeleteProcessItemSanityTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Delete existing process item") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public void deleteProcessItem() throws Exception { processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); @@ -53,6 +53,7 @@ public class DeleteProcessItemSanityTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Try to delete existing process item using invalid processId") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public void deleteProcessItemUsingInvalidProcessId() throws Exception { processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java index 9e6dd3636..720a99870 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java @@ -14,7 +14,6 @@ import org.testng.annotations.Test; /** * Created by Claudia Agache on 10/12/2016. */ -@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public class DeleteProcessSanityTests extends RestTest { private UserModel userWhoAddsProcess, assignee, anotherUser; @@ -28,8 +27,9 @@ public class DeleteProcessSanityTests extends RestTest anotherUser = dataUser.createRandomTestUser(); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify User is able to delete process started by him using REST API and status code is OK (204)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Verify User is able to delete process started by him using REST API and status code is OK (204)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public void deleteProcessByUserWhoStartedProcess() throws Exception { process = restClient.authenticateUser(userWhoAddsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); @@ -41,8 +41,9 @@ public class DeleteProcessSanityTests extends RestTest restClient.withWorkflowAPI().getProcesses().assertThat().entriesListDoesNotContain("id", process.getId()); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify User is able to delete process assigned to him using REST API and status code is OK (204)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Verify User is able to delete process assigned to him using REST API and status code is OK (204)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public void deleteProcessByAssignedUser() throws Exception { process = restClient.authenticateUser(userWhoAddsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); @@ -54,7 +55,9 @@ public class DeleteProcessSanityTests extends RestTest restClient.withWorkflowAPI().getProcesses().assertThat().entriesListDoesNotContain("id", process.getId()); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify User that is not involved in a process is not authorized to delete it using REST API and status code is 403") + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Verify User that is not involved in a process is not authorized to delete it using REST API and status code is 403") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public void deleteProcessByAnotherUser() throws Exception { process = restClient.authenticateUser(userWhoAddsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableCoreTests.java index e06514ffc..aea7b66b4 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableCoreTests.java @@ -21,7 +21,6 @@ import org.testng.annotations.Test; * @author bogdan.bocancea * */ -@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) public class DeleteProcessVariableCoreTests extends RestTest { private FileModel document; @@ -44,6 +43,7 @@ public class DeleteProcessVariableCoreTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Delete invalid process variable") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) public void deleteInvalidProcessVariable() throws Exception { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("x:InvalidVar"); @@ -56,6 +56,7 @@ public class DeleteProcessVariableCoreTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Delete empty process variable") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) public void deleteEmptyProcessVariable() throws Exception { variableModel = new RestProcessVariableModel("","", "d:text"); @@ -68,6 +69,7 @@ public class DeleteProcessVariableCoreTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Delete process variable twice") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) public void deleteProcessVariableTwice() throws Exception { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableSanityTests.java index f34837ce1..11811c17a 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableSanityTests.java @@ -15,7 +15,6 @@ import org.testng.annotations.Test; /** * @author iulia.cojocea */ -@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public class DeleteProcessVariableSanityTests extends RestTest { private FileModel document; @@ -37,6 +36,7 @@ public class DeleteProcessVariableSanityTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Delete existing variable") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public void deleteProcessVariable() throws Exception { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); @@ -51,6 +51,7 @@ public class DeleteProcessVariableSanityTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Try to delete existing variable using invalid processId") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public void deleteProcessVariableUsingInvalidProcessId() throws Exception { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsSanityTests.java index d580fc78e..8e2adf8a7 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsSanityTests.java @@ -18,8 +18,6 @@ import org.testng.annotations.Test; /** * @author iulia.cojocea */ - -@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public class GetProcessItemsSanityTests extends RestTest { private FileModel document; @@ -40,6 +38,7 @@ public class GetProcessItemsSanityTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify that user that started the process gets all process items") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public void getProcessItemsUsingTheUserWhoStartedProcess() throws Exception { processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); @@ -50,6 +49,7 @@ public class GetProcessItemsSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify that user that is involved in the process gets all process items") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public void getProcessItemsUsingUserInvolvedInProcess() throws Exception { processModel = restClient.authenticateUser(assignee).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); @@ -58,9 +58,9 @@ public class GetProcessItemsSanityTests extends RestTest items.assertThat().entriesListIsNotEmpty(); } - @Test(groups = { TestGroup.NETWORKS }) @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Get process items using admin from same network") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY, TestGroup.NETWORKS }) public void getProcessItemsUsingAdminUserFromSameNetwork() throws Exception { adminTenantUser = UserModel.getAdminTenantUser(); diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessSanityTests.java index 713dd6ea2..b4288002a 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessSanityTests.java @@ -14,7 +14,6 @@ import org.testng.annotations.Test; /** * Created by Claudia Agache on 10/19/2016. */ -@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public class GetProcessSanityTests extends RestTest { private UserModel userWhoStartsProcess, assignee; @@ -28,8 +27,9 @@ public class GetProcessSanityTests extends RestTest addedProcess = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.High); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify user is able to get the process started by him using REST API and status code is OK (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Verify user is able to get the process started by him using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public void getProcessByOwner() throws Exception { process = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingProcess(addedProcess).getProcess(); @@ -38,8 +38,9 @@ public class GetProcessSanityTests extends RestTest .and().field("startUserId").is(addedProcess.getStartUserId()); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify user is able to get the process assigned to him using REST API and status code is OK (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Verify user is able to get the process assigned to him using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public void getProcessByAssignee() throws Exception { process = restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(addedProcess).getProcess(); @@ -48,8 +49,9 @@ public class GetProcessSanityTests extends RestTest .and().field("startUserId").is(addedProcess.getStartUserId()); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify admin is able to get any process using REST API and status code is OK (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Verify admin is able to get any process using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public void getProcessByAdmin() throws Exception { process = restClient.authenticateUser(dataUser.getAdminUser()).withWorkflowAPI().usingProcess(addedProcess).getProcess(); diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksSanityTests.java index 6334b784e..d9e161119 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksSanityTests.java @@ -16,7 +16,6 @@ import org.testng.annotations.Test; * * @author Cristina Axinte */ -@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public class GetProcessTasksSanityTests extends RestTest { private FileModel document; @@ -38,7 +37,9 @@ public class GetProcessTasksSanityTests extends RestTest .createMoreReviewersWorkflowAndAssignTo(assignee1, assignee2, assignee3); } - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify user who started the process gets all tasks of started process with Rest API and response is successfull (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Verify user who started the process gets all tasks of started process with Rest API and response is successfull (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public void userWhoStartedProcessCanGetProcessTasks() throws JsonToModelConversionException, Exception { processTasks = restClient.authenticateUser(userModel).withWorkflowAPI().usingProcess(process).getProcessTasks(); @@ -50,7 +51,9 @@ public class GetProcessTasksSanityTests extends RestTest .entriesListContains("assignee", assignee2.getUsername()); } - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify any assignee user of the process gets all tasks of the process with Rest API and response is successfull (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Verify any assignee user of the process gets all tasks of the process with Rest API and response is successfull (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public void assigneeUserCanGetAllProcessTasks() throws JsonToModelConversionException, Exception { processTasks = restClient.authenticateUser(assignee1).withWorkflowAPI().usingProcess(process).getProcessTasks(); @@ -61,7 +64,9 @@ public class GetProcessTasksSanityTests extends RestTest .entriesListContains("assignee", assignee2.getUsername()); } - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify any assignee user of the process gets all tasks of the process with Rest API and response is successfull (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Verify any assignee user of the process gets all tasks of the process with Rest API and response is successfull (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public void involvedUserCanGetAllProcessTasks() throws JsonToModelConversionException, Exception { ProcessModel process = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(document) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesSanityTests.java index fe6dc3851..fbeb3d116 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesSanityTests.java @@ -18,7 +18,6 @@ import org.testng.annotations.Test; /** * @author iulia.cojocea */ -@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public class GetProcessVariablesSanityTests extends RestTest { private FileModel document; @@ -39,6 +38,7 @@ public class GetProcessVariablesSanityTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify that user that started the process gets all process variables") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public void getProcessVariablesUsingTheUserWhoStartedProcess() throws JsonToModelConversionException, Exception { processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); @@ -49,6 +49,7 @@ public class GetProcessVariablesSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify get all process variables call using a user that is involved in the process") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public void getProcessVariablesUsingUserInvolvedInProcess() throws JsonToModelConversionException, Exception { processModel = restClient.authenticateUser(assignee).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesCoreTests.java index 1459cc2ee..95ab411c2 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesCoreTests.java @@ -25,7 +25,6 @@ import org.testng.annotations.Test; * @author Cristina Axinte * */ -@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) public class GetProcessesCoreTests extends RestTest { private FileModel document; @@ -46,10 +45,10 @@ public class GetProcessesCoreTests extends RestTest task2 = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(adminUser); process3 = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createSingleReviewerTaskAndAssignTo(assignee); } - - @Test(groups = { TestGroup.NETWORKS }) + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify admin gets all processes from same network") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE, TestGroup.NETWORKS }) public void getProcessFromSameNetworkUsingAdmin() throws Exception { adminTenantUser = UserModel.getAdminTenantUser(); @@ -63,9 +62,10 @@ public class GetProcessesCoreTests extends RestTest tenantProcesses.assertThat().entriesListContains("id", process.getId()); } - + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets all processes started by him ordered descending by id") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) public void getProcessesOrderedByIdDESC() throws Exception { RestProcessModelsCollection processes = restClient.authenticateUser(userWhoStartsTask).withParams("orderBy=id DESC") @@ -80,6 +80,7 @@ public class GetProcessesCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets processes that matches a where clause") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) public void getProcessesWithWhereClauseAsParameter() throws JsonToModelConversionException, Exception { RestProcessModelsCollection processes = restClient.authenticateUser(userWhoStartsTask).where("processDefinitionKey='activitiReview'") diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java index 82a31470d..2e756b033 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java @@ -13,7 +13,6 @@ import org.testng.annotations.Test; /** * Created by Claudia Agache on 10/11/2016. */ -@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public class GetProcessesSanityTests extends RestTest { private FileModel document; @@ -33,8 +32,9 @@ public class GetProcessesSanityTests extends RestTest task = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify User gets all processes started by him using REST API and status code is OK (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Verify User gets all processes started by him using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public void getProcessesByUserWhoStartedProcess() throws Exception { allProcesses = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getProcesses(); @@ -42,8 +42,9 @@ public class GetProcessesSanityTests extends RestTest allProcesses.assertThat().entriesListContains("id", task.getNodeRef()); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify User gets all processes assigned to him using REST API and status code is OK (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Verify User gets all processes assigned to him using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public void getProcessesByAssignedUser() throws Exception { allProcesses = restClient.authenticateUser(assignee).withWorkflowAPI().getProcesses(); @@ -51,8 +52,9 @@ public class GetProcessesSanityTests extends RestTest allProcesses.assertThat().entriesListContains("id", task.getNodeRef()); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify User that is not involved in a process can not get that process using REST API and status code is OK (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Verify User that is not involved in a process can not get that process using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public void getProcessesByAnotherUser() throws Exception { allProcesses = restClient.authenticateUser(anotherUser).withWorkflowAPI().getProcesses(); @@ -60,8 +62,9 @@ public class GetProcessesSanityTests extends RestTest allProcesses.assertThat().entriesListDoesNotContain("id", task.getNodeRef()); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify Admin gets all processes, even if he isn't involved in a process, using REST API and status code is OK (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Verify Admin gets all processes, even if he isn't involved in a process, using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public void getProcessesByAdmin() throws Exception { allProcesses = restClient.authenticateUser(dataUser.getAdminUser()).withWorkflowAPI().getProcesses(); diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/UpdateProcessVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/UpdateProcessVariableSanityTests.java index af64af9f6..165c11b7c 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/UpdateProcessVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/UpdateProcessVariableSanityTests.java @@ -17,7 +17,6 @@ import org.testng.annotations.Test; /** * @author iulia.cojocea */ -@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public class UpdateProcessVariableSanityTests extends RestTest { private FileModel document; @@ -40,6 +39,7 @@ public class UpdateProcessVariableSanityTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Create non-existing variable using put call") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public void addProcessVariable() throws Exception { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); @@ -53,6 +53,7 @@ public class UpdateProcessVariableSanityTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Update existing variable using put call") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public void updateProcessVariable() throws Exception { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); @@ -67,6 +68,7 @@ public class UpdateProcessVariableSanityTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Try to add process variable using an invalid processId") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public void addProcessVariableUsingInvalidProcessId() throws Exception { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); From 3734af13c6d3bac93bb1f263b47e9b0e64a1ea85 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Mon, 12 Dec 2016 16:04:52 +0200 Subject: [PATCH 0758/1491] fix: adding more info for content type in case of faliure --- .../org/alfresco/rest/favorites/AddFavoritesCoreTests.java | 3 +-- .../org/alfresco/rest/favorites/AddFavoritesSanityTests.java | 2 -- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesCoreTests.java b/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesCoreTests.java index e5e5638c2..04dcbb590 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesCoreTests.java @@ -7,7 +7,6 @@ import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestPersonFavoritesModel; import org.alfresco.rest.model.RestTagModel; import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FolderModel; @@ -18,7 +17,6 @@ import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -184,6 +182,7 @@ public class AddFavoritesCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); } + @Bug(id="MNT-16917") @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify add file favorite with tag id returns status code 404") @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) diff --git a/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesSanityTests.java index 806ef5d72..349cf2947 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesSanityTests.java @@ -4,7 +4,6 @@ import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestPersonFavoritesModel; import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.StatusModel; @@ -13,7 +12,6 @@ import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; From 64593b95a0f6d7f00fee3a954eeec155fe418861 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Mon, 12 Dec 2016 17:46:49 +0200 Subject: [PATCH 0759/1491] Integrating inputJson in updateTask and corresponding tests updates --- .../workflow/tasks/AddTaskItemCoreTests.java | 6 +- .../workflow/tasks/GetTasksCoreTests.java | 2 - .../tasks/UpdateTaskCoreTestsBulk2.java | 150 ++++++++++-------- 3 files changed, 87 insertions(+), 71 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemCoreTests.java index d76138aab..bfc84cf0a 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemCoreTests.java @@ -22,10 +22,11 @@ import org.testng.annotations.Test; public class AddTaskItemCoreTests extends RestTest { - private UserModel userModel, assigneeUser, adminUser, anotherUser; + private UserModel userModel, assigneeUser, anotherUser; private SiteModel siteModel; - private FileModel fileModel, document; + private FileModel fileModel; private TaskModel taskModel; + @SuppressWarnings("unused") private RestItemModel taskItem; private String taskId; @@ -33,7 +34,6 @@ public class AddTaskItemCoreTests extends RestTest @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception { - adminUser = dataUser.getAdminUser(); userModel = dataUser.createRandomTestUser(); siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksCoreTests.java index a02303618..1f6aeead9 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksCoreTests.java @@ -6,8 +6,6 @@ import java.util.List; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.CMISUtil.Priority; import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestSiteModel; import org.alfresco.rest.model.RestTaskModel; import org.alfresco.rest.model.RestTaskModelsCollection; import org.alfresco.utility.model.FileModel; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTestsBulk2.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTestsBulk2.java index 98a22e34c..5cb4aa8a3 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTestsBulk2.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTestsBulk2.java @@ -1,6 +1,6 @@ package org.alfresco.rest.workflow.tasks; -import java.util.HashMap; +import javax.json.JsonObject; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; @@ -134,14 +134,12 @@ public class UpdateTaskCoreTestsBulk2 extends RestTest description = "Verify task can be update using multiple select values successfully (200)") public void taskCanBeUpdatedWithMultipleSelectValues() throws Exception { - restClient.authenticateUser(assigneeUser) - .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel); - HashMap body = new HashMap(); - body.put("state", "resolved"); - body.put("assignee", "admin"); - String postBody = JsonBodyGenerator.keyValueJson(body); - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); - restTaskModel =restClient.processModel(RestTaskModel.class, request); + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("state", "resolved") + .add("assignee", "admin").build(); + + restTaskModel = restClient.authenticateUser(assigneeUser) + .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); restClient.assertStatusCodeIs(HttpStatus.OK); restTaskModel.assertThat().field("id").is(taskModel.getId()) .and().field("state").is("resolved"); @@ -190,11 +188,18 @@ public class UpdateTaskCoreTestsBulk2 extends RestTest description = "Verify task owner cannot complete task with invalid name - (200))") public void taskOwnerCannotCompleteTaskWithInvalidName() throws Exception { - restClient.authenticateUser(owner) - .withParams("select=state,variables").withWorkflowAPI().usingTask(taskModel); - String postBody = "{\"state\" : \"completed\", \"variables\" : [{\"name\" : \"bpmx_priorityx\",\"type\" : \"d:int\",\"value\" : 1,\"scope\" : \"global\"}]}"; - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); - restTaskModel =restClient.processModel(RestTaskModel.class, request); + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("state", "completed") + .add("variables", JsonBodyGenerator.defineJSONArray() + .add(JsonBodyGenerator.defineJSON() + .add("name", "bpmx_priorityx") + .add("type", "d:int") + .add("value", 1) + .add("scope", "global").build()) + ).build(); + + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state,variables").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) .assertLastError().containsSummary(String.format(RestErrorModel.UNSUPPORTED_TYPE,"bpm_priorityx")); } @@ -204,12 +209,19 @@ public class UpdateTaskCoreTestsBulk2 extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify task owner cannot complete task with invalid Type - Bad Request(400))") public void taskOwnerCannotCompleteTaskWithInvalidType() throws Exception - { - restClient.authenticateUser(owner) - .withParams("select=state,variables").withWorkflowAPI().usingTask(taskModel); - String postBody = "{\"state\" : \"completed\", \"variables\" : [{\"name\" : \"bpm_priority\",\"type\" : \"d_int\",\"value\" : 1,\"scope\" : \"global\"}]}"; - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); - restTaskModel =restClient.processModel(RestTaskModel.class, request); + { + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("state", "completed") + .add("variables", JsonBodyGenerator.defineJSONArray() + .add(JsonBodyGenerator.defineJSON() + .add("name", "bpmx_priority") + .add("type", "d_int") + .add("value", 1) + .add("scope", "global").build()) + ).build(); + + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state,variables").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) .assertLastError().containsSummary(String.format(RestErrorModel.UNSUPPORTED_TYPE,"d_int")); } @@ -219,12 +231,19 @@ public class UpdateTaskCoreTestsBulk2 extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify task owner cannot complete task with invalid value - Bad Request(400))") public void taskOwnerCannotCompleteTaskWithInvalidValue() throws Exception - { - restClient.authenticateUser(owner) - .withParams("select=state,variables").withWorkflowAPI().usingTask(taskModel); - String postBody = "{\"state\" : \"completed\", \"variables\" : [{\"name\" : \"bpm_priority\",\"type\" : \"d:int\",\"value\" : \"text\",\"scope\" : \"global\"}]}"; - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); - restTaskModel =restClient.processModel(RestTaskModel.class, request); + { + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("state", "completed") + .add("variables", JsonBodyGenerator.defineJSONArray() + .add(JsonBodyGenerator.defineJSON() + .add("name", "bpmx_priority") + .add("type", "d:int") + .add("value", "text") + .add("scope", "global").build()) + ).build(); + + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state,variables").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) .assertLastError().containsSummary(String.format(RestErrorModel.UNSUPPORTED_TYPE, "text")); } @@ -233,12 +252,19 @@ public class UpdateTaskCoreTestsBulk2 extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify task owner cannot complete task with invalid scope - Bad Request(400))") public void taskOwnerCannotCompleteTaskWithInvalidScope() throws Exception - { - restClient.authenticateUser(owner) - .withParams("select=state,variables").withWorkflowAPI().usingTask(taskModel); - String postBody = "{\"state\" : \"completed\", \"variables\" : [{\"name\" : \"bpm_priority\",\"type\" : \"d:int\",\"value\" : 1,\"scope\" : \"globalscope\"}]}"; - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); - restTaskModel =restClient.processModel(RestTaskModel.class, request); + { + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("state", "completed") + .add("variables", JsonBodyGenerator.defineJSONArray() + .add(JsonBodyGenerator.defineJSON() + .add("name", "bpmx_priority") + .add("type", "d:int") + .add("value", 1) + .add("scope", "globalscope").build()) + ).build(); + + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state,variables").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) .assertLastError().containsSummary(String.format(RestErrorModel.ILLEGAL_SCOPE, "globalscope")); } @@ -273,15 +299,13 @@ public class UpdateTaskCoreTestsBulk2 extends RestTest public void taskAssigneeCanDelegateTask() throws Exception { UserModel delagateToUser = dataUser.createRandomTestUser(); + + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("state", "delegated") + .add("assignee", delagateToUser.getUsername()).build(); - restClient.authenticateUser(assigneeUser) - .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel); - HashMap body = new HashMap(); - body.put("state", "delegated"); - body.put("assignee", delagateToUser.getUsername()); - String postBody = JsonBodyGenerator.keyValueJson(body); - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); - restTaskModel =restClient.processModel(RestTaskModel.class, request); + restTaskModel = restClient.authenticateUser(assigneeUser) + .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); restClient.assertStatusCodeIs(HttpStatus.OK); restTaskModel.assertThat().field("id").is(taskModel.getId()) .and().field("state").is("delegated") @@ -292,15 +316,13 @@ public class UpdateTaskCoreTestsBulk2 extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify task owner can delegate task to same assignee successfully (200)") public void taskOwnerCanDelegateTaskToSameAssignee() throws Exception - { - restClient.authenticateUser(owner) - .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel); - HashMap body = new HashMap(); - body.put("state", "delegated"); - body.put("assignee", assigneeUser.getUsername()); - String postBody = JsonBodyGenerator.keyValueJson(body); - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); - restTaskModel =restClient.processModel(RestTaskModel.class, request); + { + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("state", "delegated") + .add("assignee", assigneeUser.getUsername()).build(); + + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); restClient.assertStatusCodeIs(HttpStatus.OK); restTaskModel.assertThat().field("id").is(taskModel.getId()) .and().field("state").is("delegated") @@ -313,15 +335,13 @@ public class UpdateTaskCoreTestsBulk2 extends RestTest description = "Verify task assignee cannot delegate task to task owner - (200)") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) public void taskAssigneeCannotDelegateTaskToTaskOwner() throws Exception - { - restClient.authenticateUser(owner) - .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel); - HashMap body = new HashMap(); - body.put("state", "delegated"); - body.put("assignee", owner.getUsername()); - String postBody = JsonBodyGenerator.keyValueJson(body); - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); - restTaskModel =restClient.processModel(RestTaskModel.class, request); + { + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("state", "delegated") + .add("assignee", owner.getUsername()).build(); + + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); } @@ -333,14 +353,12 @@ public class UpdateTaskCoreTestsBulk2 extends RestTest { UserModel invalidAssignee = new UserModel("invalidAssignee", "password"); - restClient.authenticateUser(owner) - .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel); - HashMap body = new HashMap(); - body.put("state", "delegated"); - body.put("assignee", invalidAssignee.getUsername()); - String postBody = JsonBodyGenerator.keyValueJson(body); - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); - restTaskModel =restClient.processModel(RestTaskModel.class, request); + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("state", "delegated") + .add("assignee", invalidAssignee.getUsername()).build(); + + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); } } From 373f9befc5f29034a7a0c1efbaf3d004a043ecb5 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Mon, 12 Dec 2016 18:16:06 +0200 Subject: [PATCH 0760/1491] fix: update "core" group --- .../rest/sites/GetSiteContainerCoreTests.java | 11 +++++------ .../processes/AddProcessVariablesCoreTests.java | 8 ++++---- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerCoreTests.java index 1c71dcf94..aa1ff1dd2 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerCoreTests.java @@ -12,7 +12,6 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) public class GetSiteContainerCoreTests extends RestTest{ private UserModel adminUserModel, testUserModel; @@ -37,7 +36,7 @@ public class GetSiteContainerCoreTests extends RestTest{ dataDiscussion.usingAdmin().usingSite(privateSiteModel).createRandomDiscussion(); } - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if get container request returns status code 400 when site doesn't exist") public void getContainerWithNonExistentSite() throws Exception @@ -48,7 +47,7 @@ public class GetSiteContainerCoreTests extends RestTest{ .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, "NonExistentSiteId", ContainerName.discussions.toString())); } - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if get container request returns status code 400 when container item doesn't exist") public void getContainerWithNonExistentItem() throws Exception @@ -59,7 +58,7 @@ public class GetSiteContainerCoreTests extends RestTest{ .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, publicSiteModel.getId(), "NonExistentFolder")); } - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify get container request returns status 200 for public site") public void getContainerForPublicSite() throws Exception @@ -75,7 +74,7 @@ public class GetSiteContainerCoreTests extends RestTest{ restClient.assertStatusCodeIs(HttpStatus.OK); } - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify get container request returns status 200 for private site") public void getContainerForPrivateSite() throws Exception @@ -90,7 +89,7 @@ public class GetSiteContainerCoreTests extends RestTest{ restClient.assertStatusCodeIs(HttpStatus.OK); } - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify get container request returns status 200 for moderated site") public void getContainerForModeratedSite() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesCoreTests.java index 02976af0b..324e74351 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesCoreTests.java @@ -36,7 +36,7 @@ public class AddProcessVariablesCoreTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify addProcessVariable by admin in other network with REST API and status code is FORBIDDEN (403)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY, TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE, TestGroup.NETWORKS }) public void addProcessVariableByAdminInOtherNetworkIsForbidden() throws Exception { adminTenantUser = UserModel.getAdminTenantUser(); @@ -57,7 +57,7 @@ public class AddProcessVariablesCoreTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify addProcessVariable by any user with REST API and status code is CREATED (201)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) public void addProcessVariableByAnyUser() throws Exception { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); @@ -75,7 +75,7 @@ public class AddProcessVariablesCoreTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify addProcessVariable by any user for invalid processID with REST API and status code is NOT_FOUND (404)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) public void addProcessVariableForInvalidProcessIdIsNotFound() throws Exception { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); @@ -89,7 +89,7 @@ public class AddProcessVariablesCoreTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify addProcessVariable by any user for empty processID with REST API and status code is NOT_FOUND (404)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) public void addProcessVariableForInvalidProcessIdIsEmpty() throws Exception { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); From a436b263f2e8de31440a34904648025326c887fc Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Tue, 13 Dec 2016 12:26:07 +0200 Subject: [PATCH 0761/1491] fix: update executionType to REGRESSION for some core tests --- .../rest/comments/UpdateCommentsCoreTests.java | 10 +++++----- .../rest/people/DeleteFavoriteSiteCoreTests.java | 2 +- .../rest/sites/GetSiteContainerSanityTests.java | 1 - .../org/alfresco/rest/tags/UpdateTagCoreTests.java | 10 +++++----- .../workflow/processes/AddProcessItemCoreTests.java | 2 +- .../processes/GetProcessVariablesCoreTests.java | 4 ++-- 6 files changed, 14 insertions(+), 15 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsCoreTests.java b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsCoreTests.java index 4d0f31bf2..43ed657fb 100644 --- a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsCoreTests.java @@ -41,7 +41,7 @@ public class UpdateCommentsCoreTests extends RestTest usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator); } - @TestRail(section = { TestGroup.REST_API, TestGroup.SANITY }, executionType = ExecutionType.SANITY, description = "Verify can not update comment if NodeId is neither document or folder and returns status code 405") + @TestRail(section = { TestGroup.REST_API, TestGroup.SANITY }, executionType = ExecutionType.REGRESSION, description = "Verify can not update comment if NodeId is neither document or folder and returns status code 405") @Bug(id="MNT-16904") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) public void canNotUpdateCommentIfNodeIdIsNeitherDocumentOrFolder() throws JsonToModelConversionException, Exception @@ -61,7 +61,7 @@ public class UpdateCommentsCoreTests extends RestTest } @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Admin user is not able to update with empty comment body and status code is 400") + TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Admin user is not able to update with empty comment body and status code is 400") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) public void adminIsNotAbleToUpdateWithEmptyCommentBody() throws JsonToModelConversionException, Exception { @@ -73,7 +73,7 @@ public class UpdateCommentsCoreTests extends RestTest } @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify updated comment by Manager is listed when calling getComments and status code is 200") + TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify updated comment by Manager is listed when calling getComments and status code is 200") @Bug(id="REPO-1011") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) public void updatedCommentByManagerIsListed() throws JsonToModelConversionException, Exception @@ -87,7 +87,7 @@ public class UpdateCommentsCoreTests extends RestTest } @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user can not update comments of another user and status code is 200") + TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user can not update comments of another user and status code is 200") @Bug(id="MNT-2502",description="seems it's one old issue: also logged as MNT-2502, MNT-2346") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) public void collaboratorIsNotAbleToUpdateCommentOfAnotherUser() throws JsonToModelConversionException, Exception @@ -100,7 +100,7 @@ public class UpdateCommentsCoreTests extends RestTest } @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify entry content in response") + TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify entry content in response") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) public void checkEntryContentInResponse() throws JsonToModelConversionException, Exception { diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteCoreTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteCoreTests.java index bf9b1ba23..d01b95d7c 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteCoreTests.java @@ -42,7 +42,7 @@ public class DeleteFavoriteSiteCoreTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) @Bug(id = "REPO-1642", description = "reproduced on 5.2.1 only, it works on 5.2.0") - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify inexistent user is not able to remove a site from favorites and response is 404") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify inexistent user is not able to remove a site from favorites and response is 404") public void inexistentUserIsNotAbleToRemoveFavoriteSite() throws Exception { UserModel inexistentUser = new UserModel("inexistenUser", "password"); diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java index 5ba4a8efa..3421d64c5 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java @@ -18,7 +18,6 @@ import org.testng.annotations.Test; /** * @author iulia.cojocea */ -@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) public class GetSiteContainerSanityTests extends RestTest { private UserModel adminUserModel; diff --git a/e2e-test/java/org/alfresco/rest/tags/UpdateTagCoreTests.java b/e2e-test/java/org/alfresco/rest/tags/UpdateTagCoreTests.java index 81f69eb91..4904972e6 100644 --- a/e2e-test/java/org/alfresco/rest/tags/UpdateTagCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/UpdateTagCoreTests.java @@ -45,7 +45,7 @@ public class UpdateTagCoreTests extends RestTest } @TestRail(section = { TestGroup.REST_API, - TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify site manager is not able to update tag with invalid id") + TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify site manager is not able to update tag with invalid id") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) public void managerIsNotAbleToUpdateTagWithInvalidId() throws JsonToModelConversionException, Exception { @@ -58,7 +58,7 @@ public class UpdateTagCoreTests extends RestTest } @TestRail(section = { TestGroup.REST_API, - TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify site manager is not able to update tag with empty id") + TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify site manager is not able to update tag with empty id") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) public void managerIsNotAbleToUpdateTagWithEmptyId() throws JsonToModelConversionException, Exception { @@ -70,7 +70,7 @@ public class UpdateTagCoreTests extends RestTest } @TestRail(section = { TestGroup.REST_API, - TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify site manager is not able to update tag with invalid body") + TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify site manager is not able to update tag with invalid body") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) public void managerIsNotAbleToUpdateTagWithEmptyBody() throws JsonToModelConversionException, Exception { @@ -82,7 +82,7 @@ public class UpdateTagCoreTests extends RestTest @Bug(id="ACE-5629") @TestRail(section = { TestGroup.REST_API, - TestGroup.TAGS }, executionType = ExecutionType.SANITY, + TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify site manager is not able to update tag with invalid body containing '|' symbol") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) public void managerIsNotAbleToUpdateTagWithInvalidBodyScenario1() throws JsonToModelConversionException, Exception @@ -97,7 +97,7 @@ public class UpdateTagCoreTests extends RestTest @Bug(id="ACE-5629") @TestRail(section = { TestGroup.REST_API, - TestGroup.TAGS }, executionType = ExecutionType.SANITY, + TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify site manager is not able to update tag with invalid body without '|' symbol") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) public void managerIsNotAbleToUpdateTagWithInvalidBodyScenario2() throws JsonToModelConversionException, Exception diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemCoreTests.java index 1d425ba91..98f7c2663 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemCoreTests.java @@ -91,7 +91,7 @@ public class AddProcessItemCoreTests extends RestTest .field("id").isNotEmpty().and().field("mimeType").is(document.getFileType().mimeType); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add process item using by admin in other network.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE, TestGroup.NETWORKS }) public void addProcessItemByAdminInOtherNetwork() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesCoreTests.java index 52cd1fedc..8e7b3c0d5 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesCoreTests.java @@ -72,7 +72,7 @@ public class GetProcessVariablesCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT); } - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Get process variables using invalid process ID") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) public void getProcessVariablesUsingInvalidProcessId() throws JsonToModelConversionException, Exception @@ -84,7 +84,7 @@ public class GetProcessVariablesCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, id)); } - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Get process variables using empty process ID") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) public void getProcessVariablesUsingEmptyProcessId() throws JsonToModelConversionException, Exception From d78d1ba6453fff425e185d863f8ff99f0b3e97cf Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Tue, 13 Dec 2016 12:49:30 +0200 Subject: [PATCH 0762/1491] fix: update TestGroup and ExecutionType --- .../rest/demo/SampleCommentsTests.java | 9 ++-- .../alfresco/rest/demo/SamplePeopleTests.java | 3 +- .../alfresco/rest/demo/SampleSitesTests.java | 21 ++++------ ...st.java => RestGetNetworkSanityTests.java} | 42 +++++++++---------- 4 files changed, 32 insertions(+), 43 deletions(-) rename e2e-test/java/org/alfresco/rest/networks/{RestGetNetworkTest.java => RestGetNetworkSanityTests.java} (89%) diff --git a/e2e-test/java/org/alfresco/rest/demo/SampleCommentsTests.java b/e2e-test/java/org/alfresco/rest/demo/SampleCommentsTests.java index 71b6b73de..8874a24c4 100644 --- a/e2e-test/java/org/alfresco/rest/demo/SampleCommentsTests.java +++ b/e2e-test/java/org/alfresco/rest/demo/SampleCommentsTests.java @@ -32,24 +32,21 @@ public class SampleCommentsTests extends RestTest document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); } - @TestRail(section={"demo", "sample-section"}, executionType= ExecutionType.SANITY, - description= "Verify admin user adds comments with Rest API and status code is 200") + @Test public void admiShouldAddComment() throws JsonToModelConversionException, Exception { restClient.withCoreAPI().usingResource(document).addComment("This is a new comment"); restClient.assertStatusCodeIs(HttpStatus.CREATED); } - @TestRail(section={"demo", "sample-section"}, executionType= ExecutionType.SANITY, - description= "Verify admin user gets comments with Rest API and status code is 200") + @Test public void admiShouldRetrieveComments() throws Exception { restClient.withCoreAPI().usingResource(document).getNodeComments(); restClient.assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section={"demo", "sample-section"}, executionType= ExecutionType.SANITY, - description= "Verify admin user updates comments with Rest API") + @Test public void adminShouldUpdateComment() throws JsonToModelConversionException, Exception { RestCommentModel commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment"); diff --git a/e2e-test/java/org/alfresco/rest/demo/SamplePeopleTests.java b/e2e-test/java/org/alfresco/rest/demo/SamplePeopleTests.java index 62cb2f8bb..4a6945757 100644 --- a/e2e-test/java/org/alfresco/rest/demo/SamplePeopleTests.java +++ b/e2e-test/java/org/alfresco/rest/demo/SamplePeopleTests.java @@ -24,8 +24,7 @@ public class SamplePeopleTests extends RestTest restClient.authenticateUser(adminUser); } - @TestRail(section={"demo", "sample-section"}, executionType= ExecutionType.SANITY, - description = "Verify admin user gets person with Rest API and response is not empty") + @Test public void adminShouldRetrievePerson() throws Exception { restClient.withCoreAPI().usingUser(userModel).getPerson().assertThat().field("id").isNotEmpty(); diff --git a/e2e-test/java/org/alfresco/rest/demo/SampleSitesTests.java b/e2e-test/java/org/alfresco/rest/demo/SampleSitesTests.java index e5dd071e6..ff5f8c401 100644 --- a/e2e-test/java/org/alfresco/rest/demo/SampleSitesTests.java +++ b/e2e-test/java/org/alfresco/rest/demo/SampleSitesTests.java @@ -26,39 +26,34 @@ public class SampleSitesTests extends RestTest siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); } - @TestRail(section={"demo", "sample-section"}, executionType= ExecutionType.SANITY, - description = "Verify admin user gets site details with Rest API and response is not empty") + @Test public void adminShouldGetSiteDetails() throws JsonToModelConversionException, Exception { restClient.withCoreAPI().usingSite(siteModel).getSite() .assertThat().field("id").isNotNull(); } - @TestRail(section={"demo", "sample-section"}, executionType= ExecutionType.SANITY, - description = "Verify admin user gets site information and gets status code OK (200)") + @Test public void adminShouldGetSites() throws JsonToModelConversionException, Exception { restClient.withCoreAPI().usingSite(siteModel).getSite(); restClient.assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section={"demo", "sample-section"}, executionType= ExecutionType.SANITY, - description = "Verify admin user gets sites with Rest API and the response is not empty") + @Test public void adminShouldAccessSites() throws JsonToModelConversionException, Exception { restClient.withCoreAPI().getSites().assertThat().entriesListIsNotEmpty(); restClient.assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section={"demo", "sample-section"}, executionType= ExecutionType.SANITY, - description = "Verify admin user gets sites with Rest API and status code is 200") + @Test public void adminShouldAccessResponsePagination() throws JsonToModelConversionException, Exception { restClient.withCoreAPI().getSites().assertThat().paginationExist(); } - @TestRail(section={"demo", "sample-section"}, executionType= ExecutionType.SANITY, - description = "Verify admin user adds site member with Rest API and status code is 201") + @Test public void adminShouldAddNewSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception { UserModel testUser = dataUser.createRandomTestUser("testUser"); @@ -67,15 +62,13 @@ public class SampleSitesTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.CREATED); } - @TestRail(section={"demo", "sample-section"}, executionType= ExecutionType.SANITY, - description = "Verify that site exists from get all sites request") + @Test public void adminShouldGetSiteFromSitesList() throws JsonToModelConversionException, Exception { restClient.withCoreAPI().getSites().assertThat().entriesListContains("id", siteModel.getId()); } - @TestRail(section={"demo", "sample-section"}, executionType= ExecutionType.SANITY, - description = "Verify site details: response not empty, description, title, visibility") + @Test public void adminShouldAccessSiteDetails() throws JsonToModelConversionException, Exception { restClient.withCoreAPI().usingSite(siteModel).getSite() diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkTest.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkSanityTests.java similarity index 89% rename from e2e-test/java/org/alfresco/rest/networks/RestGetNetworkTest.java rename to e2e-test/java/org/alfresco/rest/networks/RestGetNetworkSanityTests.java index ec00565fa..27fe6119a 100644 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkTest.java +++ b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkSanityTests.java @@ -15,7 +15,7 @@ import org.testng.annotations.Test; /** * Created by Cristina Axinte on 9/26/2016. */ -public class RestGetNetworkTest extends RestTest +public class RestGetNetworkSanityTests extends RestTest { UserModel adminTenantUser; UserModel adminAnotherTenantUser; @@ -39,7 +39,7 @@ public class RestGetNetworkTest extends RestTest @Bug(id = "MNT-16904") @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify non existing user gets another exisiting network with Rest API and checks the forbidden status") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.COMMENTS}) + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.COMMENTS, TestGroup.SANITY}) public void nonExistingTenantUserIsNotAuthorizedToRequest() throws Exception { UserModel tenantUser = new UserModel("nonexisting", "password"); @@ -51,7 +51,7 @@ public class RestGetNetworkTest extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify tenant admin user gets specific network with Rest API and response is not empty") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.COMMENTS }) + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.COMMENTS, TestGroup.SANITY }) public void adminTenantChecksIfNetworkIsPresent() throws Exception { restClient.authenticateUser(adminTenantUser); @@ -59,18 +59,18 @@ public class RestGetNetworkTest extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, + @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify tenant admin user gets specific network with Rest API and checks response parameters are correct") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) public void adminTenantChecksNetworkParamsAreCorrect() throws Exception { restClient.authenticateUser(adminTenantUser); restClient.withCoreAPI().usingNetworks().getNetwork().assertNetworkHasName(adminTenantUser).assertNetworkIsEnabled(); } - @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, + @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify tenant admin user gets non existing network with Rest API and checks the not found status") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) public void adminTenantChecksIfNonExistingNetworkIsNotFound() throws Exception { restClient.authenticateUser(adminTenantUser); @@ -78,9 +78,9 @@ public class RestGetNetworkTest extends RestTest restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); } - @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, + @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify tenant admin user gets another existing network with Rest API and checks the forbidden status") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) public void adminTenantChecksIfAnotherExistingNetworkIsForbidden() throws Exception { restClient.authenticateUser(adminTenantUser); @@ -88,9 +88,9 @@ public class RestGetNetworkTest extends RestTest restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); } - @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, + @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify any tenant user gets its network with Rest API and response is not empty") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) public void userTenantChecksIfNetworkIsPresent() throws Exception { restClient.authenticateUser(tenantUser); @@ -98,18 +98,18 @@ public class RestGetNetworkTest extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, + @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify any tenant user gets specific network with Rest API and checks response parameters are correct") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) public void userTenantChecksNetworkParamsAreCorrect() throws Exception { restClient.authenticateUser(tenantUser); restClient.withCoreAPI().usingNetworks().getNetwork(adminTenantUser).assertNetworkHasName(adminTenantUser).assertNetworkIsEnabled(); } - @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, + @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify any tenant user gets non existing network with Rest API and checks the not found status") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) public void userTenantChecksIfNonExistingNetworkIsNotFound() throws Exception { restClient.authenticateUser(tenantUser); @@ -117,9 +117,9 @@ public class RestGetNetworkTest extends RestTest restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); } - @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, + @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify any tenant user gets another existing network with Rest API and checks the forbidden status") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.COMMENTS }) + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.COMMENTS, TestGroup.SANITY }) public void userTenantChecksIfAnotherExistingNetworkIsForbidden() throws Exception { restClient.authenticateUser(tenantUser); @@ -129,7 +129,7 @@ public class RestGetNetworkTest extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify manager tenant user gets its network with Rest API and response is not empty") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.COMMENTS }) + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.COMMENTS, TestGroup.SANITY }) public void tenantManagerUserChecksIfNetworkIsPresent() throws Exception { UserModel managerTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("manTenant"); @@ -142,7 +142,7 @@ public class RestGetNetworkTest extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify collaborator tenant user gets its network with Rest API and response is not empty") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.COMMENTS }) + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.COMMENTS, TestGroup.SANITY }) public void tenantCollaboratorUserChecksIfNetworkIsPresent() throws Exception { UserModel collaboratorTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("colTenant"); @@ -155,7 +155,7 @@ public class RestGetNetworkTest extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify consumer tenant user gets its network with Rest API and response is not empty") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.COMMENTS }) + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.COMMENTS, TestGroup.SANITY }) public void tenantConsumerUserChecksIfNetworkIsPresent() throws Exception { UserModel consumerTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("consTenant"); @@ -168,7 +168,7 @@ public class RestGetNetworkTest extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify contributor tenant user gets its network with Rest API and response is not empty") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.COMMENTS }) + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.COMMENTS, TestGroup.SANITY }) public void tenantContributorUserChecksIfItsNetworkIsPresent() throws Exception { UserModel contributorTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("contTenant"); From 96c4864a941bc83a176b76eae3ce1b30b8cc5090 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Tue, 13 Dec 2016 16:18:33 +0200 Subject: [PATCH 0763/1491] core: update utility 1.0.6-snapshot, log4j properties --- e2e-test/resources/default.properties | 4 ++-- e2e-test/resources/log4j.properties | 34 ++++++++++++--------------- 2 files changed, 17 insertions(+), 21 deletions(-) diff --git a/e2e-test/resources/default.properties b/e2e-test/resources/default.properties index 541fc385f..2e312138b 100644 --- a/e2e-test/resources/default.properties +++ b/e2e-test/resources/default.properties @@ -1,7 +1,7 @@ # dataprep related alfresco.scheme=http -alfresco.server=vsphered3.qa.internal.alfresco.com -alfresco.port=8070 +alfresco.server=localhost +alfresco.port=8080 # credentials admin.user=admin diff --git a/e2e-test/resources/log4j.properties b/e2e-test/resources/log4j.properties index 2f7205f81..63d3970dc 100644 --- a/e2e-test/resources/log4j.properties +++ b/e2e-test/resources/log4j.properties @@ -1,19 +1,15 @@ -# Log levels -log4j.rootLogger=INFO,CONSOLE,R -# Appender Configuration -log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender -# Identifies whether the appender honors reassignments of System.out or System.err via System.setOut or System.setErr made after configuration -log4j.appender.CONSOLE.follow=true -# Pattern to output the caller's file name and line number -log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout -log4j.appender.CONSOLE.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n -# Rolling File Appender -log4j.appender.R=org.apache.log4j.RollingFileAppender -# Path and file name to store the log file -log4j.appender.R.File=./target/reports/alfresco-tas.log -# log4j.appender.R.MaxFileSize=200KB -# Number of backup files -log4j.appender.R.MaxBackupIndex=2 -# Layout for Rolling File Appender -log4j.appender.R.layout=org.apache.log4j.PatternLayout -log4j.appender.R.layout.ConversionPattern=%d - %c - %p - %m%n \ No newline at end of file +# Root logger option +log4j.rootLogger=INFO, file, stdout + +# Direct log messages to a log file +log4j.appender.file=org.apache.log4j.RollingFileAppender +log4j.appender.file.File=./target/reports/alfresco-tas.log +log4j.appender.file.MaxBackupIndex=10 +log4j.appender.file.layout=org.apache.log4j.PatternLayout +log4j.appender.file.layout.ConversionPattern=%d{HH:mm:ss} %-5p %c{1}:%L - %m%n + +# Direct log messages to stdout +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.Target=System.out +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=%d{HH:mm:ss} %-5p %c{1}:%L - %m%n \ No newline at end of file From c7ec0786d8a68d7078cbdde79091957fa0810909 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Tue, 13 Dec 2016 23:01:20 +0200 Subject: [PATCH 0764/1491] core: add lastException in wrapper/formatting initialize Node, People test: update test to assert on last error. Remove @Bug annotation tests passed --- .../rest/comments/AddCommentCoreTests.java | 10 ++++++-- .../rest/comments/AddCommentSanityTests.java | 5 ++-- .../comments/DeleteCommentsSanityTests.java | 15 +++++------ .../rest/comments/GetCommentsSanityTests.java | 10 +++++--- .../comments/UpdateCommentsSanityTests.java | 10 +++++--- .../rest/demo/SampleCommentsTests.java | 2 -- .../alfresco/rest/demo/SamplePeopleTests.java | 2 -- .../alfresco/rest/demo/SampleSitesTests.java | 2 -- .../favorites/AddFavoritesSanityTests.java | 2 +- .../favorites/GetFavoriteSanityTests.java | 11 +++++--- .../favorites/GetFavoritesSanityTests.java | 11 +++++--- .../people/AddFavoriteSiteSanityTests.java | 6 ++--- .../AddSiteMembershipRequestSanityTests.java | 7 +++--- .../people/DeleteFavoriteSiteSanityTests.java | 11 ++++---- .../people/DeleteSiteMemberSanityTests.java | 6 ++--- ...eleteSiteMembershipRequestSanityTests.java | 10 +++++--- .../people/GetFavoriteSiteSanityTests.java | 9 ++++--- .../people/GetFavoriteSitesSanityTests.java | 11 ++++---- .../GetPeopleActivitiesSanityTests.java | 4 +-- .../GetPeoplePreferenceSanityTests.java | 4 +-- .../GetPeoplePreferencesSanityTests.java | 4 +-- .../GetSiteMembershipRequestSanityTests.java | 3 +-- .../people/GetSiteMembershipSanityTests.java | 4 +-- ...SitesMembershipInformationSanityTests.java | 4 +-- .../UpdateSiteMembershipRequestCoreTests.java | 3 ++- .../rest/ratings/AddRatingSanityTests.java | 22 +++++++++------- .../rest/ratings/DeleteRatingSanityTests.java | 25 ++++++++++--------- .../rest/ratings/GetRatingsSanityTests.java | 2 +- .../rest/sites/AddSiteMemberSanityTests.java | 5 ++-- .../sites/GetSiteContainerSanityTests.java | 6 ++--- .../sites/GetSiteContainersSanityTests.java | 7 +----- .../rest/sites/GetSiteMemberSanityTests.java | 4 +-- .../rest/sites/GetSiteMembersSanityTests.java | 7 +----- .../rest/sites/GetSiteSanityTests.java | 7 +----- .../rest/sites/GetSitesSanityTests.java | 4 +-- .../sites/RemoveSiteMemberSanityTests.java | 3 +-- .../sites/UpdateSiteMemberSanityTests.java | 3 +-- .../alfresco/rest/tags/AddTagSanityTests.java | 6 ++--- .../rest/tags/AddTagsSanityTests.java | 7 ++---- .../rest/tags/DeleteTagSanityTests.java | 6 ++--- .../rest/tags/GetNodeTagsSanityTests.java | 9 ++++--- .../alfresco/rest/tags/GetTagSanityTests.java | 4 +-- .../rest/tags/GetTagsSanityTests.java | 10 +++++--- .../rest/tags/UpdateTagSanityTests.java | 5 ++-- .../workflow/tasks/GetTasksCoreTests.java | 2 -- 45 files changed, 144 insertions(+), 166 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentCoreTests.java b/e2e-test/java/org/alfresco/rest/comments/AddCommentCoreTests.java index 690c6fe0f..0b06bf42b 100644 --- a/e2e-test/java/org/alfresco/rest/comments/AddCommentCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/AddCommentCoreTests.java @@ -10,7 +10,13 @@ import org.alfresco.rest.model.RestTagModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.*; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FileType; +import org.alfresco.utility.model.LinkModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.StatusModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; @@ -142,7 +148,7 @@ public class AddCommentCoreTests extends RestTest restClient.authenticateUser(member) .withCoreAPI().usingResource(document).addComment(comment); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); } @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java index 00fb52d8b..f5f722439 100644 --- a/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java @@ -101,13 +101,12 @@ public class AddCommentSanityTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user gets status code 401 on post comments call") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) - @Bug(id = "MNT-16904") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) public void unauthenticatedUserIsNotAbleToAddComment() throws JsonToModelConversionException, Exception { restClient.authenticateUser(new UserModel("random user", "random password")); restClient.withCoreAPI().usingResource(document).addComment("This is a new comment"); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java index ed318b2a2..0a16aca68 100644 --- a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java @@ -6,8 +6,11 @@ import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestCommentModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.model.*; -import org.alfresco.utility.report.Bug; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.StatusModel; +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; @@ -76,10 +79,8 @@ public class DeleteCommentsSanityTests extends RestTest restClient.withCoreAPI().usingResource(document).deleteComment(comment); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } - - @Bug(id="MNT-16904") - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify User gets status code 401 if authentication call fails") + + @TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify User gets status code 401 if authentication call fails") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) public void userIsNotAbleToDeleteCommentIfAuthenticationFails() throws JsonToModelConversionException, Exception { @@ -88,6 +89,6 @@ public class DeleteCommentsSanityTests extends RestTest UserModel nonexistentModel = new UserModel("nonexistentUser", "nonexistentPassword"); restClient.authenticateUser(nonexistentModel); restClient.withCoreAPI().usingResource(document).deleteComment(comment); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java index d6797f9ac..a49101e17 100644 --- a/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java @@ -4,10 +4,13 @@ import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestCommentModelsCollection; -import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.model.*; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.StatusModel; +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; @@ -100,8 +103,7 @@ public class GetCommentsSanityTests extends RestTest UserModel nonexistentModel = new UserModel("nonexistentUser", "nonexistentPassword"); restClient.authenticateUser(nonexistentModel).withCoreAPI() .usingResource(document).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); } @TestRail(section={TestGroup.REST_API, TestGroup.SANITY}, executionType= ExecutionType.SANITY, diff --git a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java index 8e7978d3d..397d59df6 100644 --- a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java @@ -7,7 +7,12 @@ import org.alfresco.rest.model.RestCommentModel; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.model.*; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.StatusModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; @@ -101,7 +106,6 @@ public class UpdateCommentsSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user gets status code 401 on update comment call") - @Bug(id="MNT-16904") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) public void unauthenticatedUserIsNotAbleToUpdateComment() throws JsonToModelConversionException, Exception { @@ -110,7 +114,7 @@ public class UpdateCommentsSanityTests extends RestTest UserModel incorrectUserModel = new UserModel("userName", "password"); restClient.authenticateUser(incorrectUserModel) .withCoreAPI().usingResource(document).updateComment(commentModel, "try to update"); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); } @TestRail(section = { TestGroup.REST_API, TestGroup.SANITY }, executionType = ExecutionType.SANITY, description = "Verify update comment with inexistent nodeId returns status code 404") diff --git a/e2e-test/java/org/alfresco/rest/demo/SampleCommentsTests.java b/e2e-test/java/org/alfresco/rest/demo/SampleCommentsTests.java index 8874a24c4..5481ca564 100644 --- a/e2e-test/java/org/alfresco/rest/demo/SampleCommentsTests.java +++ b/e2e-test/java/org/alfresco/rest/demo/SampleCommentsTests.java @@ -8,8 +8,6 @@ import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; 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; diff --git a/e2e-test/java/org/alfresco/rest/demo/SamplePeopleTests.java b/e2e-test/java/org/alfresco/rest/demo/SamplePeopleTests.java index 4a6945757..aa5f91886 100644 --- a/e2e-test/java/org/alfresco/rest/demo/SamplePeopleTests.java +++ b/e2e-test/java/org/alfresco/rest/demo/SamplePeopleTests.java @@ -3,8 +3,6 @@ package org.alfresco.rest.demo; import org.alfresco.rest.RestTest; import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; import org.apache.commons.lang3.RandomStringUtils; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; diff --git a/e2e-test/java/org/alfresco/rest/demo/SampleSitesTests.java b/e2e-test/java/org/alfresco/rest/demo/SampleSitesTests.java index ff5f8c401..6b6beae46 100644 --- a/e2e-test/java/org/alfresco/rest/demo/SampleSitesTests.java +++ b/e2e-test/java/org/alfresco/rest/demo/SampleSitesTests.java @@ -6,8 +6,6 @@ import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.SiteModel; 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; diff --git a/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesSanityTests.java index 349cf2947..ed70bc21d 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesSanityTests.java @@ -98,6 +98,6 @@ public class AddFavoritesSanityTests extends RestTest UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); siteManager.setPassword("wrongPassword"); restClient.authenticateUser(siteManager).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java index 968453342..b69346ab9 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java @@ -8,8 +8,12 @@ import org.alfresco.rest.model.RestPersonFavoritesModelsCollection; import org.alfresco.rest.model.RestSiteModelsCollection; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.model.*; -import org.alfresco.utility.report.Bug; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.StatusModel; +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; @@ -168,7 +172,6 @@ public class GetFavoriteSanityTests extends RestTest .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator).getUsername())); } - @Bug(id="MNT-16904") @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify user gets status code 401 if authentication call fails") @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) @@ -178,6 +181,6 @@ public class GetFavoriteSanityTests extends RestTest siteManager.setPassword("wrongPassword"); restClient.authenticateUser(siteManager).withCoreAPI() .usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).getFavorite(siteModel.getGuid()); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java index 0cf07c308..53908a4a6 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java @@ -7,8 +7,12 @@ import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestPersonFavoritesModelsCollection; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.model.*; -import org.alfresco.utility.report.Bug; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.StatusModel; +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; @@ -181,7 +185,6 @@ public class GetFavoritesSanityTests extends RestTest .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator).getUsername())); } - @Bug(id="MNT-16904") @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify user gets status code 401 if authentication call fails") @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) @@ -190,6 +193,6 @@ public class GetFavoritesSanityTests extends RestTest UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); siteManager.setPassword("wrongPassword"); restClient.authenticateUser(siteManager).withCoreAPI().usingAuthUser().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteSanityTests.java index 7fb4c5086..33e6333c7 100644 --- a/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteSanityTests.java @@ -7,7 +7,6 @@ import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -91,8 +90,7 @@ public class AddFavoriteSiteSanityTests extends RestTest restFavoriteSiteModel.assertThat().field("id").is(siteModel.getId()); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @Bug(id = "MNT-16904") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify a manager user is NOT Authorized to add a favorite site with Rest API when authentication fails (401)") public void managerUserNotAuthorizedFailsToAddFavoriteSite() throws Exception { @@ -101,6 +99,6 @@ public class AddFavoriteSiteSanityTests extends RestTest managerUser.setPassword("newpassword"); restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().addFavoriteSite(siteModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java index 582e9c27d..baba7bdd7 100644 --- a/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java @@ -20,7 +20,7 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; - +@Test(groups="DEV") public class AddSiteMembershipRequestSanityTests extends RestTest { @Autowired @@ -107,11 +107,10 @@ public class AddSiteMembershipRequestSanityTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to create new site membership request") - @Bug(id = "MNT-16557") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to create new site membership request") public void unauthenticatedUserIsNotAbleToCreateSiteMembershipRequest() throws JsonToModelConversionException, Exception { restClient.authenticateUser(new UserModel("random user", "random password")).withCoreAPI().usingUser(newMember).addSiteMembershipRequest(siteModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java index 538e40443..4bd0b20ac 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java @@ -3,8 +3,10 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.model.*; -import org.alfresco.utility.report.Bug; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.StatusModel; +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; @@ -108,8 +110,7 @@ public class DeleteFavoriteSiteSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @Bug(id = "MNT-16904") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized to remove a site from its favorite sites list with Rest API when authentication fails (401)") public void managerUserNotAuthorizedFailsToRemoveFavoriteSite() throws Exception { @@ -120,6 +121,6 @@ public class DeleteFavoriteSiteSanityTests extends RestTest managerUser.setPassword("newpassword"); restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java index 6b58f0489..3a84a3855 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java @@ -10,7 +10,6 @@ import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -99,14 +98,13 @@ public class DeleteSiteMemberSanityTests extends RestTest .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getId())); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @Bug(id = "MNT-16904") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to delete another member of the site") public void unauthenticatedUserIsNotAbleToDeleteSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception { restClient.authenticateUser(new UserModel("random user", "random password")); restClient.withCoreAPI().usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).deleteSiteMember(siteModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java index 4125ecad7..f1b317e7f 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java @@ -7,7 +7,10 @@ import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.data.RandomData; import org.alfresco.utility.exception.DataPreparationException; -import org.alfresco.utility.model.*; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.StatusModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; @@ -121,14 +124,13 @@ public class DeleteSiteMembershipRequestSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @Bug(id = "MNT-16904") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Failed authentication get site member call returns status code 401") public void unauthenticatedUserIsNotAuthorizedToDeleteSiteMmebershipRequest() throws JsonToModelConversionException, Exception { restClient.authenticateUser(dataUser.createRandomTestUser()).withCoreAPI().usingAuthUser().addSiteMembershipRequest(siteModel); UserModel inexistentUser = new UserModel("inexistent user", "inexistent password"); restClient.authenticateUser(inexistentUser).withCoreAPI().usingAuthUser().deleteSiteMembershipRequest(siteModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java index 1b54ac797..6115520ab 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java @@ -4,8 +4,10 @@ import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestSiteModel; import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.model.*; -import org.alfresco.utility.report.Bug; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.StatusModel; +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; @@ -118,7 +120,6 @@ public class GetFavoriteSiteSanityTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @Bug(id = "MNT-16904") @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized gets its specific favorite site with Rest API when authentication fails (401)") public void managerUserNotAuthorizedFailsToGetFavoriteSite() throws Exception { @@ -129,6 +130,6 @@ public class GetFavoriteSiteSanityTests extends RestTest managerUser.setPassword("newpassword"); restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().getFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java index d1f6adf03..fc11a6f52 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java @@ -4,8 +4,10 @@ import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestSiteModelsCollection; import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.model.*; -import org.alfresco.utility.report.Bug; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.StatusModel; +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; @@ -106,8 +108,7 @@ public class GetFavoriteSitesSanityTests extends RestTest restSiteModelsCollection.assertThat().entriesListIsNotEmpty().and().entriesListContains("id", siteModel.getId()).and().paginationExist(); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @Bug(id = "MNT-16904") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify any user is NOT Authorized to get its favorite sites with Rest API when authentication fails (401)") public void anyUserNotAuthenticatedIsNotAuthorizedToGetFavoriteSites() throws Exception { @@ -116,6 +117,6 @@ public class GetFavoriteSitesSanityTests extends RestTest anyUser.setPassword("newpassword"); restClient.authenticateUser(anyUser).withCoreAPI().usingAuthUser().getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java index b2b28a806..a40921d6d 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java @@ -3,10 +3,10 @@ package org.alfresco.rest.people; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestActivityModelsCollection; -import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; @@ -100,6 +100,6 @@ public class GetPeopleActivitiesSanityTests extends RestTest public void unauthenticatedUserShouldNotGetPeopleActivitiesList() throws Exception { restClient.authenticateUser(unauthenticatedUser).withCoreAPI().usingUser(userModel).getPersonActivities(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceSanityTests.java index 5856ff104..9dc291b5b 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceSanityTests.java @@ -8,7 +8,6 @@ import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -104,7 +103,6 @@ public class GetPeoplePreferenceSanityTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) - @Bug(id = "MNT-16904") @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized to get a specific preference with Rest API when authentication fails (401)") public void managerUserNotAuthorizedFailsToGetsAPreference() throws Exception { @@ -115,6 +113,6 @@ public class GetPeoplePreferenceSanityTests extends RestTest restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser() .getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesSanityTests.java index 612d209af..4d5c4f604 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesSanityTests.java @@ -8,7 +8,6 @@ import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -106,7 +105,6 @@ public class GetPeoplePreferencesSanityTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) - @Bug(id = "MNT-16904") @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized to gets its preferences with Rest API when authentication fails(401)") public void managerUserGetsPeoplePreferencesIsNotAuthorized() throws Exception { @@ -116,6 +114,6 @@ public class GetPeoplePreferencesSanityTests extends RestTest managerUser.setPassword("newpassword"); restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().getPersonPreferences(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestSanityTests.java index 0bea62243..6df0001f2 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestSanityTests.java @@ -108,13 +108,12 @@ public class GetSiteMembershipRequestSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to retrieve site membership request") - @Bug(id = "MNT-16557") public void unauthenticatedUserIsNotAbleToRetrieveSiteMembershipRequest() throws JsonToModelConversionException, Exception { UserModel newMember = dataUser.createRandomTestUser(); restClient.authenticateUser(new UserModel("random user", "random password")).withCoreAPI().usingUser(newMember).addSiteMembershipRequest(siteModel); restClient.withCoreAPI().usingUser(newMember).getSiteMembershipRequest(siteModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java index 9536bf658..3fb9caa52 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java @@ -9,7 +9,6 @@ import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -80,11 +79,10 @@ public class GetSiteMembershipSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to retrieve site membership information of another user") - @Bug(id = "MNT-16904") public void unauthenticatedUserCannotRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception { restClient.authenticateUser(new UserModel("random user", "random password")).withCoreAPI() .usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).getSiteMembership(siteModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java index a23bb070e..74ded1f54 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java @@ -9,7 +9,6 @@ import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -78,12 +77,11 @@ public class GetSitesMembershipInformationSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify that unauthenticated user is not able to retrieve sites membership information") - @Bug(id = "MNT-16904") public void unauthenticatedUserCannotRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception { UserModel inexistentUser = new UserModel("inexistent user", "wrong password"); restClient.authenticateUser(inexistentUser).withCoreAPI().usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) .getSitesMembershipInformation(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestCoreTests.java b/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestCoreTests.java index 90ab8b2dd..e1fd855a2 100644 --- a/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestCoreTests.java @@ -5,6 +5,7 @@ import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestSiteMembershipRequestModel; import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; @@ -37,7 +38,7 @@ public class UpdateSiteMembershipRequestCoreTests extends RestTest restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(siteModel); newMember.setPassword("fakePass"); restClient.withCoreAPI().usingUser(newMember).updateSiteMembershipRequest(siteModel, updatedMessage); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) diff --git a/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java index 3bf0198ed..6f6ae6b62 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java @@ -2,12 +2,17 @@ package org.alfresco.rest.ratings; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestRatingModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.exception.DataPreparationException; -import org.alfresco.utility.model.*; -import org.alfresco.utility.report.Bug; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.StatusModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.apache.commons.lang3.RandomStringUtils; @@ -16,6 +21,7 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; +@Test(groups="DEV") public class AddRatingSanityTests extends RestTest { private UserModel userModel; @@ -105,12 +111,11 @@ public class AddRatingSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to post like rating to a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) - @Bug(id = "MNT-16904") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) public void unauthenticatedUserIsNotAbleToLikeDocument() throws Exception { restClient.authenticateUser(new UserModel("random user", "random password")).withCoreAPI().usingResource(document).likeDocument(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(RestErrorModel.AUTHENTICATION_FAILED); } @TestRail(section = { TestGroup.REST_API, @@ -165,16 +170,15 @@ public class AddRatingSanityTests extends RestTest { returnedRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).rateStarsToDocument(3); restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedRatingModel.assertThat().field("myRating").is(String.valueOf(3)).and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); + returnedRatingModel.assertThat().field("myRating").is("3").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); } @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to post stars rating to a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) - @Bug(id = "MNT-16904") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) public void unauthenticatedUserIsNotAbleToRateStarsToDocument() throws Exception { restClient.authenticateUser(new UserModel("random user", "random password")).withCoreAPI().usingResource(document).rateStarsToDocument(5); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java index a9bbe9f5b..751d51ecf 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java @@ -6,8 +6,12 @@ import org.alfresco.rest.model.RestRatingModelsCollection; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.exception.DataPreparationException; -import org.alfresco.utility.model.*; -import org.alfresco.utility.report.Bug; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.StatusModel; +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; @@ -148,8 +152,7 @@ public class DeleteRatingSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); returnedRatingModelCollection.assertNodeIsNotLiked().assertNodeHasNoFiveStarRating().and().entriesListIsNotEmpty().and().paginationExist(); } - - @Bug(id = "MNT-16904") + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to remove its own rating of a document") @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) @@ -165,16 +168,14 @@ public class DeleteRatingSanityTests extends RestTest restClient.authenticateUser(new UserModel("random user", "random password")); restClient.withCoreAPI().usingResource(document).deleteLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify one user is not able to remove rating added by another user") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) - @Bug(id = "ACE-5459") + @TestRail(section = { TestGroup.REST_API,TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify one user is not able to remove rating added by another user") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) public void oneUserIsNotAbleToDeleteRatingsOfAnotherUser() throws Exception { UserModel userA = dataUser.createRandomTestUser(); @@ -188,9 +189,9 @@ public class DeleteRatingSanityTests extends RestTest restClient.authenticateUser(userB); restClient.authenticateUser(userB).withCoreAPI().usingResource(document).deleteLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/ratings/GetRatingsSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/GetRatingsSanityTests.java index b5c809f4e..8c70ad304 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/GetRatingsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/GetRatingsSanityTests.java @@ -134,6 +134,6 @@ public class GetRatingsSanityTests extends RestTest restClient.authenticateUser(new UserModel("random user", "random password")); restClient.withCoreAPI().usingResource(document).getRatings(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(RestErrorModel.AUTHENTICATION_FAILED); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java index dadf2f9a9..46d5c6d7f 100644 --- a/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java @@ -7,7 +7,6 @@ import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -101,7 +100,7 @@ public class AddSiteMemberSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.CREATED); } - @Bug(id="MNT-16904") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that unauthenticated user is not able to add site member") @@ -111,6 +110,6 @@ public class AddSiteMemberSanityTests extends RestTest UserModel inexistentUser = new UserModel("inexistent user", "inexistent password"); restClient.authenticateUser(inexistentUser) .withCoreAPI().usingSite(siteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java index 3421d64c5..257eae112 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java @@ -8,7 +8,6 @@ import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -102,8 +101,7 @@ public class GetSiteContainerSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, - description = "Failed authentication get site container call returns status code 401") - @Bug(id="MNT-16904") + description = "Failed authentication get site container call returns status code 401") public void unauthenticatedUserIsNotAuthorizedToRetrieveSiteContainer() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); @@ -113,6 +111,6 @@ public class GetSiteContainerSanityTests extends RestTest dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); restClient.authenticateUser(userModel) .withCoreAPI().usingSite(siteModel).getSiteContainer(siteContainerModel.onModel()); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java index 6c79e8314..f972f2d59 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java @@ -3,17 +3,13 @@ package org.alfresco.rest.sites; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataSite; -import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -101,7 +97,6 @@ public class GetSiteContainersSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); } - @Bug(id="MNT-16904") @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Failed authentication get site containers call returns status code 401 with Manager role") @@ -112,6 +107,6 @@ public class GetSiteContainersSanityTests extends RestTest dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); restClient.authenticateUser(userModel) .withCoreAPI().usingSite(siteModel).getSiteContainers(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java index c5253dcab..a3501bd56 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java @@ -9,7 +9,6 @@ import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -100,12 +99,11 @@ public class GetSiteMemberSanityTests extends RestTest @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") public void unauthenticatedUserIsNotAuthorizedToRetrieveSiteMember() throws JsonToModelConversionException, Exception { UserModel inexistentUser = new UserModel("inexistent user", "inexistent password"); restClient.authenticateUser(inexistentUser); restClient.withCoreAPI().usingSite(siteModel).getSiteMember(userModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java index d533e6ffc..75a71145a 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java @@ -3,18 +3,14 @@ package org.alfresco.rest.sites; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataSite; -import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -97,7 +93,6 @@ public class GetSiteMembersSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); } - @Bug(id="MNT-16904") @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") @@ -108,6 +103,6 @@ public class GetSiteMembersSanityTests extends RestTest dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); restClient.authenticateUser(userModel) .withCoreAPI().usingSite(siteModel).getSiteMembers(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteSanityTests.java index 2631fac99..96fcd3ec6 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteSanityTests.java @@ -3,18 +3,14 @@ package org.alfresco.rest.sites; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataSite; -import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -105,7 +101,6 @@ public class GetSiteSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); } - @Bug(id="MNT-16904") @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Failed authentication get site call returns status code 401") @@ -117,6 +112,6 @@ public class GetSiteSanityTests extends RestTest restClient.authenticateUser(userModel).withParams("maxItems=10000") .withCoreAPI() .getSites(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java index 95a4b04cb..20d39c9a2 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java @@ -8,7 +8,6 @@ import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -99,7 +98,6 @@ public class GetSitesSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); } - @Bug(id="MNT-16904") @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Failed authentication get sites call returns status code 401") @@ -111,6 +109,6 @@ public class GetSitesSanityTests extends RestTest dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); restClient.authenticateUser(userModel).withParams("maxItems=1000") .withCoreAPI().getSites(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java index 9b5483dfb..c66dd01a9 100644 --- a/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java @@ -102,7 +102,6 @@ public class RemoveSiteMemberSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); } - @Bug(id="MNT-16904") @Test(groups = {TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY}) @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that unauthenticated user is not able to delete site member") @@ -111,6 +110,6 @@ public class RemoveSiteMemberSanityTests extends RestTest restClient.authenticateUser(inexistentUser) .withCoreAPI().usingSite(siteModel).deleteSiteMember(testUserModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java index 9634b6370..ea98d2c7d 100644 --- a/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java @@ -100,7 +100,6 @@ public class UpdateSiteMemberSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); } - @Bug(id="MNT-16904") @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that unauthenticated user is not able to update site member") @@ -109,6 +108,6 @@ public class UpdateSiteMemberSanityTests extends RestTest restClient.authenticateUser(inexistentUser); testUserModel.setUserRole(UserRole.SiteCollaborator); restClient.withCoreAPI().usingSite(siteModel).updateSiteMember(testUserModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java index 9c67ddde9..793986860 100644 --- a/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java @@ -13,7 +13,6 @@ import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -120,8 +119,7 @@ public class AddTagSanityTests extends RestTest } @TestRail(section = { TestGroup.REST_API, - TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user gets status code 401 if authentication call fails") - @Bug(id="MNT-16904") + TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user gets status code 401 if authentication call fails") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) public void userIsNotAbleToAddTagIfAuthenticationFails() throws JsonToModelConversionException, Exception { @@ -129,6 +127,6 @@ public class AddTagSanityTests extends RestTest siteManager.setPassword("wrongPassword"); restClient.authenticateUser(siteManager); restClient.withCoreAPI().usingResource(document).addTag("tagUnauthorized"); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/tags/AddTagsSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/AddTagsSanityTests.java index 1c0f5458f..c719a0764 100644 --- a/e2e-test/java/org/alfresco/rest/tags/AddTagsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/AddTagsSanityTests.java @@ -13,7 +13,6 @@ import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -119,15 +118,13 @@ public class AddTagsSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user gets status code 401 if authentication call fails") - @Bug(id="MNT-16904") + @TestRail(section = { TestGroup.REST_API,TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user gets status code 401 if authentication call fails") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) public void userIsNotAbleToAddTagsIfAuthenticationFails() throws JsonToModelConversionException, Exception { UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); siteManager.setPassword("wrongPassword"); restClient.authenticateUser(siteManager).withCoreAPI().usingResource(document).addTags(tag1, tag2); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/tags/DeleteTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/DeleteTagSanityTests.java index cd9183f27..b2d8f1427 100644 --- a/e2e-test/java/org/alfresco/rest/tags/DeleteTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/DeleteTagSanityTests.java @@ -13,7 +13,6 @@ import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -117,8 +116,7 @@ public class DeleteTagSanityTests extends RestTest restClient.withCoreAPI().usingResource(document).deleteTag(tag); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } - - @Bug(id="MNT-16904") + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user gets status code 401 if authentication call fails") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) @@ -131,6 +129,6 @@ public class DeleteTagSanityTests extends RestTest siteManager.setPassword("wrongPassword"); restClient.authenticateUser(siteManager); restClient.withCoreAPI().usingResource(document).deleteTag(tag); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java index 85e7b0235..58870c97c 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java @@ -3,12 +3,15 @@ package org.alfresco.rest.tags; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestTagModelsCollection; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.*; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.StatusModel; +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; @@ -120,6 +123,6 @@ public class GetNodeTagsSanityTests extends RestTest { restClient.authenticateUser(new UserModel("random user", "random password")); restClient.withCoreAPI().usingResource(document).getNodeTags(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/tags/GetTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagSanityTests.java index b273f99f2..7649fa347 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetTagSanityTests.java @@ -12,7 +12,6 @@ import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -108,7 +107,6 @@ public class GetTagSanityTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Manager user gets status code 401 if authentication call fails") - @Bug(id = "MNT-16904") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) public void managerIsNotAbleToGetTagIfAuthenticationFails() throws JsonToModelConversionException, Exception { @@ -121,7 +119,7 @@ public class GetTagSanityTests extends RestTest managerUser.setPassword("wrongPassword"); restClient.authenticateUser(managerUser); restClient.withCoreAPI().getTag(tag); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java index e20e4e9e4..de694b3b9 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java @@ -8,8 +8,11 @@ import org.alfresco.utility.Utility; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.*; -import org.alfresco.utility.report.Bug; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.StatusModel; +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; @@ -105,7 +108,6 @@ public class GetTagsSanityTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Failed authentication get tags call returns status code 401 with Manager role") - @Bug(id = "MNT-16904") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) public void failedAuthenticationReturnsUnauthorizedStatus() throws JsonToModelConversionException, Exception { @@ -115,6 +117,6 @@ public class GetTagsSanityTests extends RestTest dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); restClient.authenticateUser(userModel); restClient.withCoreAPI().getTags(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java index d96e90c1f..143144982 100644 --- a/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java @@ -10,6 +10,7 @@ import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.RandomData; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; @@ -103,7 +104,6 @@ public class UpdateTagSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user gets status code 401 if authentication call fails") - @Bug(id="MNT-16904") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) public void userIsNotAbleToUpdateTagIfAuthenticationFails() throws JsonToModelConversionException, Exception { @@ -111,7 +111,6 @@ public class UpdateTagSanityTests extends RestTest siteManager.setPassword("wrongPassword"); restClient.authenticateUser(siteManager); restClient.withCoreAPI().usingTag(oldTag).update(randomTag); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksCoreTests.java index a02303618..1f6aeead9 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksCoreTests.java @@ -6,8 +6,6 @@ import java.util.List; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.CMISUtil.Priority; import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestSiteModel; import org.alfresco.rest.model.RestTaskModel; import org.alfresco.rest.model.RestTaskModelsCollection; import org.alfresco.utility.model.FileModel; From de43fef7dc1863d1d0b721570bac7eee929c94ba Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Tue, 13 Dec 2016 23:39:10 +0200 Subject: [PATCH 0765/1491] wip: on NPE tests --- .../AddSiteMembershipRequestSanityTests.java | 16 +++--- .../rest/ratings/AddRatingCoreTests.java | 49 ++++++++++++++----- .../rest/ratings/AddRatingSanityTests.java | 48 +++++++++++++----- .../rest/ratings/DeleteRatingSanityTests.java | 32 +++++++----- 4 files changed, 103 insertions(+), 42 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java index baba7bdd7..2f46dd186 100644 --- a/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java @@ -18,7 +18,6 @@ import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @Test(groups="DEV") public class AddSiteMembershipRequestSanityTests extends RestTest @@ -33,8 +32,7 @@ public class AddSiteMembershipRequestSanityTests extends RestTest private ListUserWithRoles usersWithRoles; - private UserModel adminUser; - private UserModel newMember; + private UserModel adminUser; private RestSiteMembershipRequestModel requestModel; @BeforeClass(alwaysRun = true) @@ -46,17 +44,12 @@ public class AddSiteMembershipRequestSanityTests extends RestTest UserRole.SiteContributor); } - @BeforeMethod - public void setUp() throws DataPreparationException - { - newMember = dataUser.createRandomTestUser(); - } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site manager is able to create new site membership request") @Bug(id = "MNT-16557") public void siteManagerIsAbleToCreateSiteMembershipRequest() throws JsonToModelConversionException, Exception { + UserModel newMember = dataUser.createRandomTestUser(); requestModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingUser(newMember) .addSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); @@ -68,6 +61,7 @@ public class AddSiteMembershipRequestSanityTests extends RestTest @Bug(id = "MNT-16557") public void siteCollaboatorIsAbleToCreateSiteMembershipRequest() throws JsonToModelConversionException, Exception { + UserModel newMember = dataUser.createRandomTestUser(); requestModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingUser(newMember) .addSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); @@ -79,6 +73,7 @@ public class AddSiteMembershipRequestSanityTests extends RestTest @Bug(id = "MNT-16557") public void siteContributorIsAbleToCreateSiteMembershipRequest() throws JsonToModelConversionException, Exception { + UserModel newMember = dataUser.createRandomTestUser(); requestModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingUser(newMember) .addSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); @@ -90,6 +85,7 @@ public class AddSiteMembershipRequestSanityTests extends RestTest @Bug(id = "MNT-16557") public void siteConsumerIsAbleToCreateSiteMembershipRequest() throws JsonToModelConversionException, Exception { + UserModel newMember = dataUser.createRandomTestUser(); requestModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingUser(newMember) .addSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); @@ -101,6 +97,7 @@ public class AddSiteMembershipRequestSanityTests extends RestTest @Bug(id = "MNT-16557") public void adminUserIsAbleToCreateSiteMembershipRequest() throws JsonToModelConversionException, Exception { + UserModel newMember = dataUser.createRandomTestUser(); requestModel = restClient.authenticateUser(adminUser).withCoreAPI().usingUser(newMember).addSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); requestModel.assertThat().field("id").isNotEmpty().assertThat().field("site").isNotEmpty(); @@ -110,6 +107,7 @@ public class AddSiteMembershipRequestSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to create new site membership request") public void unauthenticatedUserIsNotAbleToCreateSiteMembershipRequest() throws JsonToModelConversionException, Exception { + UserModel newMember = dataUser.createRandomTestUser(); restClient.authenticateUser(new UserModel("random user", "random password")).withCoreAPI().usingUser(newMember).addSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); } diff --git a/e2e-test/java/org/alfresco/rest/ratings/AddRatingCoreTests.java b/e2e-test/java/org/alfresco/rest/ratings/AddRatingCoreTests.java index e4744cf90..fcb87765f 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/AddRatingCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/AddRatingCoreTests.java @@ -21,16 +21,13 @@ import org.alfresco.utility.testrail.annotation.TestRail; import org.apache.commons.lang3.RandomStringUtils; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; public class AddRatingCoreTests extends RestTest { private UserModel userModel; private SiteModel siteModel; - private UserModel adminUser; - private FolderModel folderModel; - private FileModel document; + private UserModel adminUser; private ListUserWithRoles usersWithRoles; private RestRatingModel returnedRatingModel; // placeholder for returned model @@ -45,18 +42,13 @@ public class AddRatingCoreTests extends RestTest UserRole.SiteContributor); } - @BeforeMethod - public void setUp() throws Exception - { - folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - } - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Verify that if unknown rating scheme is provided status code is 400") @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) public void unknownRatingSchemeReturnsBadRequest() throws Exception { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"invalidRate\"}"); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_RATING, "invalidRate")); } @@ -66,6 +58,9 @@ public class AddRatingCoreTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) public void invalidNodeIdReturnsNotFound() throws Exception { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + document.setNodeRef(RandomStringUtils.randomAlphanumeric(10)); restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() @@ -78,6 +73,9 @@ public class AddRatingCoreTests extends RestTest @Bug(id = "MNT-16904") public void likeResourceThatCannotBeRated() throws Exception { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + LinkModel link = dataLink.usingAdmin().usingSite(siteModel).createRandomLink(); document.setNodeRef(link.getNodeRef()); restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); @@ -89,6 +87,9 @@ public class AddRatingCoreTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) public void managerIsAbleToLikeAFile() throws Exception { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(document) .likeDocument(); restClient.assertStatusCodeIs(HttpStatus.CREATED); @@ -101,6 +102,8 @@ public class AddRatingCoreTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) public void managerIsAbleToLikeAFolder() throws Exception { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(folderModel) .likeDocument(); restClient.assertStatusCodeIs(HttpStatus.CREATED); @@ -113,6 +116,7 @@ public class AddRatingCoreTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) public void managerIsAbleToRateAFolder() throws Exception { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(folderModel) .rateStarsToDocument(5); restClient.assertStatusCodeIs(HttpStatus.CREATED); @@ -125,6 +129,8 @@ public class AddRatingCoreTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) public void managerIsAbleToRateAFile() throws Exception { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(document) .rateStarsToDocument(5); restClient.assertStatusCodeIs(HttpStatus.CREATED); @@ -137,6 +143,9 @@ public class AddRatingCoreTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) public void fileCanBeLikedTwice() throws Exception { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); restClient.assertStatusCodeIs(HttpStatus.CREATED); returnedRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); @@ -150,6 +159,9 @@ public class AddRatingCoreTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) public void fileCanBeRatedTwice() throws Exception { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).rateStarsToDocument(5); restClient.assertStatusCodeIs(HttpStatus.CREATED); returnedRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).rateStarsToDocument(5); @@ -163,6 +175,9 @@ public class AddRatingCoreTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) public void addRateUsingEmptyRatingObject() throws Exception { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating(""); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() .containsSummary(String.format(RestErrorModel.NO_CONTENT, "No content to map to Object due to end of input")); @@ -173,6 +188,9 @@ public class AddRatingCoreTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) public void addRateUsingEmptyValueForId() throws Exception { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"\"}"); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() .containsSummary(String.format(RestErrorModel.NO_CONTENT, "N/A (through reference chain: org.alfresco.rest.api.model.NodeRating[\"id\"])")); @@ -183,6 +201,9 @@ public class AddRatingCoreTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) public void addRateUsingEmptyValueForMyRating() throws Exception { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"likes\", \"myRating\":\"\"}"); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.NULL_LIKE_RATING)); @@ -195,6 +216,9 @@ public class AddRatingCoreTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) public void addRatingToAComment() throws Exception { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + RestCommentModel comment = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addComment("This is a comment"); document.setNodeRef(comment.getId()); @@ -210,6 +234,9 @@ public class AddRatingCoreTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) public void addRatingToATag() throws Exception { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + RestTagModel tag = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addTag("randomTag"); document.setNodeRef(tag.getId()); diff --git a/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java index 6f6ae6b62..c27bb5062 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java @@ -18,7 +18,6 @@ import org.alfresco.utility.testrail.annotation.TestRail; import org.apache.commons.lang3.RandomStringUtils; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @Test(groups="DEV") @@ -27,8 +26,6 @@ public class AddRatingSanityTests extends RestTest private UserModel userModel; private SiteModel siteModel; private UserModel adminUser; - private FolderModel folderModel; - private FileModel document; private ListUserWithRoles usersWithRoles; private RestRatingModel returnedRatingModel; // placeholder for returned model @@ -42,19 +39,15 @@ public class AddRatingSanityTests extends RestTest usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); } - - @BeforeMethod - public void setUp() throws Exception - { - folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - } - + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role is able to post like rating to a document") @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) public void managerIsAbleToLikeDocument() throws Exception { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(document) .likeDocument(); restClient.assertStatusCodeIs(HttpStatus.CREATED); @@ -67,6 +60,9 @@ public class AddRatingSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) public void collaboratorIsAbleToLikeDocument() throws Exception { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(document) .likeDocument(); restClient.assertStatusCodeIs(HttpStatus.CREATED); @@ -79,6 +75,9 @@ public class AddRatingSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) public void contributorIsAbleToLikeDocument() throws Exception { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingResource(document) .likeDocument(); restClient.assertStatusCodeIs(HttpStatus.CREATED); @@ -91,6 +90,9 @@ public class AddRatingSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) public void consumerIsAbleToLikeDocument() throws Exception { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingResource(document) .likeDocument(); restClient.assertStatusCodeIs(HttpStatus.CREATED); @@ -103,6 +105,9 @@ public class AddRatingSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) public void adminIsAbleToLikeDocument() throws Exception { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + returnedRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); restClient.assertStatusCodeIs(HttpStatus.CREATED); @@ -114,6 +119,9 @@ public class AddRatingSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) public void unauthenticatedUserIsNotAbleToLikeDocument() throws Exception { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(new UserModel("random user", "random password")).withCoreAPI().usingResource(document).likeDocument(); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(RestErrorModel.AUTHENTICATION_FAILED); } @@ -123,6 +131,9 @@ public class AddRatingSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) public void managerIsAbleToAddStarsToDocument() throws Exception { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(document) .rateStarsToDocument(5); restClient.assertStatusCodeIs(HttpStatus.CREATED); @@ -134,6 +145,9 @@ public class AddRatingSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) public void collaboratorIsAbleToAddStarsToDocument() throws Exception { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(document) .rateStarsToDocument(5); restClient.assertStatusCodeIs(HttpStatus.CREATED); @@ -146,6 +160,9 @@ public class AddRatingSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) public void contributorIsAbleToAddStarsToDocument() throws Exception { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingResource(document) .rateStarsToDocument(5); restClient.assertStatusCodeIs(HttpStatus.CREATED); @@ -157,6 +174,9 @@ public class AddRatingSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) public void consumerIsAbleToAddStarsToDocument() throws Exception { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingResource(document) .rateStarsToDocument(5); restClient.assertStatusCodeIs(HttpStatus.CREATED); @@ -168,6 +188,9 @@ public class AddRatingSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) public void adminIsAbleToAddStarsToDocument() throws Exception { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + returnedRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).rateStarsToDocument(3); restClient.assertStatusCodeIs(HttpStatus.CREATED); returnedRatingModel.assertThat().field("myRating").is("3").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); @@ -178,6 +201,9 @@ public class AddRatingSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) public void unauthenticatedUserIsNotAbleToRateStarsToDocument() throws Exception { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(new UserModel("random user", "random password")).withCoreAPI().usingResource(document).rateStarsToDocument(5); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); } diff --git a/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java index 751d51ecf..3b92d1bbb 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java @@ -16,16 +16,12 @@ 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.BeforeMethod; import org.testng.annotations.Test; public class DeleteRatingSanityTests extends RestTest { - private SiteModel siteModel; private UserModel adminUser; - private FolderModel folderModel; - private FileModel document; private ListUserWithRoles usersWithRoles; private RestRatingModelsCollection returnedRatingModelCollection; @@ -39,18 +35,15 @@ public class DeleteRatingSanityTests extends RestTest UserRole.SiteContributor); } - @BeforeMethod() - public void setUp() throws DataPreparationException, Exception - { - folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - } - + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role is able to remove its own rating of a document") @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) public void managerIsAbleToDeleteItsOwnRatings() throws Exception { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); restClient.withCoreAPI().usingResource(document).likeDocument(); restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); @@ -71,6 +64,9 @@ public class DeleteRatingSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) public void collaboratorIsAbleToDeleteItsOwnRatings() throws Exception { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); restClient.withCoreAPI().usingResource(document).likeDocument(); @@ -92,6 +88,9 @@ public class DeleteRatingSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) public void contributorIsAbleToDeleteItsOwnRatings() throws Exception { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); restClient.withCoreAPI().usingResource(document).likeDocument(); @@ -113,6 +112,9 @@ public class DeleteRatingSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) public void consumerIsAbleToDeleteItsOwnRatings() throws Exception { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); restClient.withCoreAPI().usingResource(document).likeDocument(); @@ -134,6 +136,9 @@ public class DeleteRatingSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) public void adminIsAbleToDeleteItsOwnRatings() throws Exception { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + document = dataContent.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).usingResource(folderModel) .createContent(DocumentType.TEXT_PLAIN); @@ -158,6 +163,9 @@ public class DeleteRatingSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) public void unauthenticatedUserIsNotAbleToDeleteRatings() throws Exception { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + document = dataContent.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).usingResource(folderModel) .createContent(DocumentType.TEXT_PLAIN); restClient.authenticateUser(adminUser); @@ -178,6 +186,8 @@ public class DeleteRatingSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) public void oneUserIsNotAbleToDeleteRatingsOfAnotherUser() throws Exception { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); UserModel userA = dataUser.createRandomTestUser(); UserModel userB = dataUser.createRandomTestUser(); From 23bf361238ed10a3b8c1e10f09de2c85381a5670 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Wed, 14 Dec 2016 12:07:48 +0200 Subject: [PATCH 0766/1491] test: mark @bug test for 5.2.N --- .../rest/comments/AddCommentCoreTests.java | 3 +-- .../rest/comments/AddCommentSanityTests.java | 6 +++--- .../rest/comments/DeleteCommentsSanityTests.java | 5 +++-- .../rest/comments/GetCommentsSanityTests.java | 5 +++-- .../rest/comments/UpdateCommentsSanityTests.java | 4 ++-- .../rest/favorites/AddFavoritesSanityTests.java | 3 +-- .../rest/favorites/GetFavoriteSanityTests.java | 5 +++-- .../rest/favorites/GetFavoritesSanityTests.java | 5 +++-- .../rest/people/AddFavoriteSiteSanityTests.java | 5 +++-- .../AddSiteMembershipRequestSanityTests.java | 8 ++++---- .../people/DeleteFavoriteSiteSanityTests.java | 5 +++-- .../rest/people/DeleteSiteMemberSanityTests.java | 5 +++-- .../DeleteSiteMembershipRequestSanityTests.java | 4 ++-- .../rest/people/GetFavoriteSiteSanityTests.java | 5 +++-- .../rest/people/GetFavoriteSitesSanityTests.java | 5 +++-- .../people/GetPeopleActivitiesSanityTests.java | 5 +++-- .../people/GetPeoplePreferenceSanityTests.java | 5 +++-- .../people/GetPeoplePreferencesSanityTests.java | 5 +++-- .../people/GetSiteMembershipRequestCoreTests.java | 4 +++- .../GetSiteMembershipRequestSanityTests.java | 4 ++-- .../rest/people/GetSiteMembershipSanityTests.java | 5 +++-- .../GetSitesMembershipInformationSanityTests.java | 5 +++-- .../UpdateSiteMembershipRequestCoreTests.java | 5 +++-- .../rest/ratings/AddRatingSanityTests.java | 15 ++++++++------- .../rest/ratings/DeleteRatingSanityTests.java | 14 ++++++++------ .../rest/sites/AddSiteMemberSanityTests.java | 5 +++-- .../rest/sites/GetSiteContainerSanityTests.java | 7 ++++--- .../rest/sites/GetSiteContainersSanityTests.java | 5 +++-- .../rest/sites/GetSiteMemberSanityTests.java | 5 +++-- .../rest/sites/GetSiteMembersSanityTests.java | 5 +++-- .../alfresco/rest/sites/GetSiteSanityTests.java | 5 +++-- .../alfresco/rest/sites/GetSitesSanityTests.java | 5 +++-- .../rest/sites/RemoveSiteMemberSanityTests.java | 4 ++-- .../rest/sites/UpdateSiteMemberSanityTests.java | 4 ++-- .../org/alfresco/rest/tags/AddTagSanityTests.java | 5 +++-- .../alfresco/rest/tags/AddTagsSanityTests.java | 5 +++-- .../alfresco/rest/tags/DeleteTagSanityTests.java | 5 +++-- .../rest/tags/GetNodeTagsSanityTests.java | 5 +++-- .../org/alfresco/rest/tags/GetTagSanityTests.java | 5 +++-- .../alfresco/rest/tags/GetTagsSanityTests.java | 5 +++-- .../alfresco/rest/tags/UpdateTagSanityTests.java | 4 ++-- 41 files changed, 125 insertions(+), 94 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentCoreTests.java b/e2e-test/java/org/alfresco/rest/comments/AddCommentCoreTests.java index 0b06bf42b..732fd1a23 100644 --- a/e2e-test/java/org/alfresco/rest/comments/AddCommentCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/AddCommentCoreTests.java @@ -14,7 +14,6 @@ import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FileType; import org.alfresco.utility.model.LinkModel; import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; @@ -148,7 +147,7 @@ public class AddCommentCoreTests extends RestTest restClient.authenticateUser(member) .withCoreAPI().usingResource(document).addComment(comment); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); } @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java index f5f722439..89484e438 100644 --- a/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java @@ -9,7 +9,6 @@ import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; @@ -101,12 +100,13 @@ public class AddCommentSanityTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user gets status code 401 on post comments call") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) + @Bug(id = "MNT-16904") public void unauthenticatedUserIsNotAbleToAddComment() throws JsonToModelConversionException, Exception { restClient.authenticateUser(new UserModel("random user", "random password")); restClient.withCoreAPI().usingResource(document).addComment("This is a new comment"); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); } } diff --git a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java index 0a16aca68..c12260d5e 100644 --- a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java @@ -8,9 +8,9 @@ import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -82,6 +82,7 @@ public class DeleteCommentsSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify User gets status code 401 if authentication call fails") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) + @Bug(id="MNT-16904") public void userIsNotAbleToDeleteCommentIfAuthenticationFails() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); @@ -89,6 +90,6 @@ public class DeleteCommentsSanityTests extends RestTest UserModel nonexistentModel = new UserModel("nonexistentUser", "nonexistentPassword"); restClient.authenticateUser(nonexistentModel); restClient.withCoreAPI().usingResource(document).deleteComment(comment); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); } } diff --git a/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java index a49101e17..cdec30ed3 100644 --- a/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java @@ -8,9 +8,9 @@ import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -98,12 +98,13 @@ public class GetCommentsSanityTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.SANITY}, executionType= ExecutionType.SANITY, description= "Verify Manager user gets status code 401 if authentication call fails") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) + @Bug(id="MNT-16904") public void managerIsNotAbleToRetrieveCommentIfAuthenticationFails() throws JsonToModelConversionException, Exception { UserModel nonexistentModel = new UserModel("nonexistentUser", "nonexistentPassword"); restClient.authenticateUser(nonexistentModel).withCoreAPI() .usingResource(document).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); } @TestRail(section={TestGroup.REST_API, TestGroup.SANITY}, executionType= ExecutionType.SANITY, diff --git a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java index 397d59df6..10f66a968 100644 --- a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java @@ -10,7 +10,6 @@ import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; @@ -107,6 +106,7 @@ public class UpdateCommentsSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user gets status code 401 on update comment call") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) + @Bug(id="MNT-16904") public void unauthenticatedUserIsNotAbleToUpdateComment() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); @@ -114,7 +114,7 @@ public class UpdateCommentsSanityTests extends RestTest UserModel incorrectUserModel = new UserModel("userName", "password"); restClient.authenticateUser(incorrectUserModel) .withCoreAPI().usingResource(document).updateComment(commentModel, "try to update"); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); } @TestRail(section = { TestGroup.REST_API, TestGroup.SANITY }, executionType = ExecutionType.SANITY, description = "Verify update comment with inexistent nodeId returns status code 404") diff --git a/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesSanityTests.java index ed70bc21d..2947d05c1 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesSanityTests.java @@ -6,7 +6,6 @@ import org.alfresco.rest.model.RestPersonFavoritesModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; @@ -98,6 +97,6 @@ public class AddFavoritesSanityTests extends RestTest UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); siteManager.setPassword("wrongPassword"); restClient.authenticateUser(siteManager).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); } } diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java index b69346ab9..8e686f969 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java @@ -11,9 +11,9 @@ import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -175,12 +175,13 @@ public class GetFavoriteSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify user gets status code 401 if authentication call fails") @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) + @Bug(id = "MNT-16904") public void userIsNotAbleToRetrieveFavoritesIfAuthenticationFails() throws JsonToModelConversionException, Exception { UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); siteManager.setPassword("wrongPassword"); restClient.authenticateUser(siteManager).withCoreAPI() .usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).getFavorite(siteModel.getGuid()); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); } } diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java index 53908a4a6..35c671dba 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java @@ -10,9 +10,9 @@ import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -188,11 +188,12 @@ public class GetFavoritesSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify user gets status code 401 if authentication call fails") @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) + @Bug(id="MNT-16904") public void userIsNotAbleToRetrieveFavoritesIfAuthenticationFails() throws JsonToModelConversionException, Exception { UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); siteManager.setPassword("wrongPassword"); restClient.authenticateUser(siteManager).withCoreAPI().usingAuthUser().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); } } diff --git a/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteSanityTests.java index 33e6333c7..8bb41699c 100644 --- a/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteSanityTests.java @@ -4,9 +4,9 @@ import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestFavoriteSiteModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -92,6 +92,7 @@ public class AddFavoriteSiteSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify a manager user is NOT Authorized to add a favorite site with Rest API when authentication fails (401)") + @Bug(id="MNT-16904") public void managerUserNotAuthorizedFailsToAddFavoriteSite() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -99,6 +100,6 @@ public class AddFavoriteSiteSanityTests extends RestTest managerUser.setPassword("newpassword"); restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().addFavoriteSite(siteModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); } } diff --git a/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java index 2f46dd186..8234328a8 100644 --- a/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java @@ -9,7 +9,6 @@ import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; @@ -19,7 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups="DEV") + public class AddSiteMembershipRequestSanityTests extends RestTest { @Autowired @@ -104,11 +103,12 @@ public class AddSiteMembershipRequestSanityTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to create new site membership request") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to create new site membership request") + @Bug(id = "MNT-16557") public void unauthenticatedUserIsNotAbleToCreateSiteMembershipRequest() throws JsonToModelConversionException, Exception { UserModel newMember = dataUser.createRandomTestUser(); restClient.authenticateUser(new UserModel("random user", "random password")).withCoreAPI().usingUser(newMember).addSiteMembershipRequest(siteModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java index 4bd0b20ac..ab56d7b8c 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java @@ -4,9 +4,9 @@ import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -112,6 +112,7 @@ public class DeleteFavoriteSiteSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized to remove a site from its favorite sites list with Rest API when authentication fails (401)") + @Bug(id = "MNT-16904") public void managerUserNotAuthorizedFailsToRemoveFavoriteSite() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -121,6 +122,6 @@ public class DeleteFavoriteSiteSanityTests extends RestTest managerUser.setPassword("newpassword"); restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); } } diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java index 3a84a3855..ec9e8d6b7 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java @@ -7,9 +7,9 @@ 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.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -100,11 +100,12 @@ public class DeleteSiteMemberSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to delete another member of the site") + @Bug(id = "MNT-16904") public void unauthenticatedUserIsNotAbleToDeleteSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception { restClient.authenticateUser(new UserModel("random user", "random password")); restClient.withCoreAPI().usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).deleteSiteMember(siteModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java index f1b317e7f..b41d19224 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java @@ -8,7 +8,6 @@ import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.data.RandomData; import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; @@ -126,11 +125,12 @@ public class DeleteSiteMembershipRequestSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, 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") public void unauthenticatedUserIsNotAuthorizedToDeleteSiteMmebershipRequest() throws JsonToModelConversionException, Exception { restClient.authenticateUser(dataUser.createRandomTestUser()).withCoreAPI().usingAuthUser().addSiteMembershipRequest(siteModel); UserModel inexistentUser = new UserModel("inexistent user", "inexistent password"); restClient.authenticateUser(inexistentUser).withCoreAPI().usingAuthUser().deleteSiteMembershipRequest(siteModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); } } diff --git a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java index 6115520ab..55fb74ea9 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java @@ -5,9 +5,9 @@ import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestSiteModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -121,6 +121,7 @@ public class GetFavoriteSiteSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized gets its specific favorite site with Rest API when authentication fails (401)") + @Bug(id="MNT-16904") public void managerUserNotAuthorizedFailsToGetFavoriteSite() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -130,6 +131,6 @@ public class GetFavoriteSiteSanityTests extends RestTest managerUser.setPassword("newpassword"); restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().getFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); } } diff --git a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java index fc11a6f52..840157a6b 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java @@ -5,9 +5,9 @@ import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestSiteModelsCollection; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -110,6 +110,7 @@ public class GetFavoriteSitesSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify any user is NOT Authorized to get its favorite sites with Rest API when authentication fails (401)") + @Bug(id = "MNT-16904") public void anyUserNotAuthenticatedIsNotAuthorizedToGetFavoriteSites() throws Exception { UserModel anyUser = dataUser.usingAdmin().createRandomTestUser(); @@ -117,6 +118,6 @@ public class GetFavoriteSitesSanityTests extends RestTest anyUser.setPassword("newpassword"); restClient.authenticateUser(anyUser).withCoreAPI().usingAuthUser().getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); } } diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java index a40921d6d..0e3f3cd59 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java @@ -6,9 +6,9 @@ import org.alfresco.rest.model.RestActivityModelsCollection; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -97,9 +97,10 @@ public class GetPeopleActivitiesSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is NOT Authorized to gets another user activities with Rest API") + @Bug(id = "MNT-16904") public void unauthenticatedUserShouldNotGetPeopleActivitiesList() throws Exception { restClient.authenticateUser(unauthenticatedUser).withCoreAPI().usingUser(userModel).getPersonActivities(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); } } diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceSanityTests.java index 9dc291b5b..525a693a5 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceSanityTests.java @@ -5,9 +5,9 @@ import org.alfresco.rest.model.RestPreferenceModel; import org.alfresco.utility.constants.PreferenceName; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -104,6 +104,7 @@ public class GetPeoplePreferenceSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized to get a specific preference with Rest API when authentication fails (401)") + @Bug(id = "MNT-16904") public void managerUserNotAuthorizedFailsToGetsAPreference() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -113,6 +114,6 @@ public class GetPeoplePreferenceSanityTests extends RestTest restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser() .getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); } } diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesSanityTests.java index 4d5c4f604..933ee0ce5 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesSanityTests.java @@ -5,9 +5,9 @@ import org.alfresco.rest.model.RestPreferenceModelsCollection; import org.alfresco.utility.constants.PreferenceName; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -106,6 +106,7 @@ public class GetPeoplePreferencesSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized to gets its preferences with Rest API when authentication fails(401)") + @Bug(id = "MNT-16904") public void managerUserGetsPeoplePreferencesIsNotAuthorized() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -114,6 +115,6 @@ public class GetPeoplePreferencesSanityTests extends RestTest managerUser.setPassword("newpassword"); restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().getPersonPreferences(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); } } diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestCoreTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestCoreTests.java index b34aa4a48..f26ba65be 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestCoreTests.java @@ -6,6 +6,7 @@ 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.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -36,13 +37,14 @@ public class GetSiteMembershipRequestCoreTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify contributor user fails to get all site membership requests of a specific person with Rest API when the authentication fails (401)") + @Bug(id="16904") public void unauthorizedContributorUserFailsToGetSiteMembershipRequests() throws Exception { UserModel contributor = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(contributor, siteModel, UserRole.SiteContributor); contributor.setPassword("newpassword"); restClient.authenticateUser(contributor).withCoreAPI().usingUser(newMember).getSiteMembershipRequest(siteModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestSanityTests.java index 6df0001f2..574300402 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestSanityTests.java @@ -8,7 +8,6 @@ import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; @@ -108,12 +107,13 @@ public class GetSiteMembershipRequestSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to retrieve site membership request") + @Bug(id = "MNT-16557") public void unauthenticatedUserIsNotAbleToRetrieveSiteMembershipRequest() throws JsonToModelConversionException, Exception { UserModel newMember = dataUser.createRandomTestUser(); restClient.authenticateUser(new UserModel("random user", "random password")).withCoreAPI().usingUser(newMember).addSiteMembershipRequest(siteModel); restClient.withCoreAPI().usingUser(newMember).getSiteMembershipRequest(siteModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java index 3fb9caa52..f3ba0e718 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java @@ -6,9 +6,9 @@ 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.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -79,10 +79,11 @@ public class GetSiteMembershipSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to retrieve site membership information of another user") + @Bug(id="MNT-16904") public void unauthenticatedUserCannotRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception { restClient.authenticateUser(new UserModel("random user", "random password")).withCoreAPI() .usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).getSiteMembership(siteModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java index 74ded1f54..59f3c16a7 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java @@ -6,9 +6,9 @@ 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.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -77,11 +77,12 @@ public class GetSitesMembershipInformationSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify that unauthenticated user is not able to retrieve sites membership information") + @Bug(id="MNT-16904") public void unauthenticatedUserCannotRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception { UserModel inexistentUser = new UserModel("inexistent user", "wrong password"); restClient.authenticateUser(inexistentUser).withCoreAPI().usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) .getSitesMembershipInformation(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestCoreTests.java b/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestCoreTests.java index e1fd855a2..2efde507d 100644 --- a/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestCoreTests.java @@ -5,9 +5,9 @@ import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestSiteMembershipRequestModel; import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -32,13 +32,14 @@ public class UpdateSiteMembershipRequestCoreTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify unauthorized user is not able to update user site membership request") + @Bug(id="MNT-16904") public void unauthorizedUserIsNotAbleToUpdateSiteMembershipRequest() throws Exception { UserModel newMember = dataUser.createRandomTestUser(); restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(siteModel); newMember.setPassword("fakePass"); restClient.withCoreAPI().usingUser(newMember).updateSiteMembershipRequest(siteModel, updatedMessage); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) diff --git a/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java index c27bb5062..8f0e2253d 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java @@ -2,7 +2,6 @@ package org.alfresco.rest.ratings; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestRatingModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; @@ -10,9 +9,9 @@ import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.apache.commons.lang3.RandomStringUtils; @@ -20,7 +19,7 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups="DEV") + public class AddRatingSanityTests extends RestTest { private UserModel userModel; @@ -116,14 +115,15 @@ public class AddRatingSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to post like rating to a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) + @Bug(id="MNT-16904") public void unauthenticatedUserIsNotAbleToLikeDocument() throws Exception { FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); restClient.authenticateUser(new UserModel("random user", "random password")).withCoreAPI().usingResource(document).likeDocument(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(RestErrorModel.AUTHENTICATION_FAILED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); } @TestRail(section = { TestGroup.REST_API, @@ -198,13 +198,14 @@ public class AddRatingSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to post stars rating to a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) + @Bug(id="MNT-16904") public void unauthenticatedUserIsNotAbleToRateStarsToDocument() throws Exception { FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); restClient.authenticateUser(new UserModel("random user", "random password")).withCoreAPI().usingResource(document).rateStarsToDocument(5); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java index 3b92d1bbb..aa5caa827 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java @@ -9,9 +9,9 @@ import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -161,6 +161,7 @@ public class DeleteRatingSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to remove its own rating of a document") @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) + @Bug(id="MNT-16904") public void unauthenticatedUserIsNotAbleToDeleteRatings() throws Exception { FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); @@ -176,14 +177,15 @@ public class DeleteRatingSanityTests extends RestTest restClient.authenticateUser(new UserModel("random user", "random password")); restClient.withCoreAPI().usingResource(document).deleteLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); } @TestRail(section = { TestGroup.REST_API,TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify one user is not able to remove rating added by another user") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) + @Bug(id = "ACE-5459") public void oneUserIsNotAbleToDeleteRatingsOfAnotherUser() throws Exception { FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); @@ -199,9 +201,9 @@ public class DeleteRatingSanityTests extends RestTest restClient.authenticateUser(userB); restClient.authenticateUser(userB).withCoreAPI().usingResource(document).deleteLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java index 46d5c6d7f..7a7c5916b 100644 --- a/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java @@ -4,9 +4,9 @@ import org.alfresco.rest.RestTest; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -104,12 +104,13 @@ public class AddSiteMemberSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that unauthenticated user is not able to add site member") + @Bug(id="MNT-16904") public void unauthenticatedUserIsNotAuthorizedToAddSiteMmeber() throws Exception{ UserModel testUser = dataUser.createRandomTestUser("testUser"); testUser.setUserRole(UserRole.SiteConsumer); UserModel inexistentUser = new UserModel("inexistent user", "inexistent password"); restClient.authenticateUser(inexistentUser) .withCoreAPI().usingSite(siteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); } } diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java index 257eae112..3082c299f 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java @@ -5,9 +5,9 @@ import org.alfresco.rest.model.RestSiteContainerModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -101,7 +101,8 @@ public class GetSiteContainerSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, - description = "Failed authentication get site container call returns status code 401") + description = "Failed authentication get site container call returns status code 401") + @Bug(id="MNT-16904") public void unauthenticatedUserIsNotAuthorizedToRetrieveSiteContainer() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); @@ -111,6 +112,6 @@ public class GetSiteContainerSanityTests extends RestTest dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); restClient.authenticateUser(userModel) .withCoreAPI().usingSite(siteModel).getSiteContainer(siteContainerModel.onModel()); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); } } diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java index f972f2d59..492c49495 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java @@ -5,9 +5,9 @@ import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -100,6 +100,7 @@ public class GetSiteContainersSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Failed authentication get site containers call returns status code 401 with Manager role") + @Bug(id="MNT-16904") public void unauthenticatedUserIsNotAuthorizedToRetrieveSiteContainers() throws JsonToModelConversionException, Exception { userModel = dataUser.createRandomTestUser(); @@ -107,6 +108,6 @@ public class GetSiteContainersSanityTests extends RestTest dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); restClient.authenticateUser(userModel) .withCoreAPI().usingSite(siteModel).getSiteContainers(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); } } diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java index a3501bd56..fd320cd8b 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java @@ -6,9 +6,9 @@ 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.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -99,11 +99,12 @@ public class GetSiteMemberSanityTests extends RestTest @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") public void unauthenticatedUserIsNotAuthorizedToRetrieveSiteMember() throws JsonToModelConversionException, Exception { UserModel inexistentUser = new UserModel("inexistent user", "inexistent password"); restClient.authenticateUser(inexistentUser); restClient.withCoreAPI().usingSite(siteModel).getSiteMember(userModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); } } diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java index 75a71145a..af245beb4 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java @@ -6,9 +6,9 @@ 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.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -96,6 +96,7 @@ public class GetSiteMembersSanityTests extends RestTest @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") public void unauthenticatedUserIsNotAuthorizedToRetrieveSiteMembers() throws JsonToModelConversionException, Exception { userModel = dataUser.createRandomTestUser(); @@ -103,6 +104,6 @@ public class GetSiteMembersSanityTests extends RestTest dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); restClient.authenticateUser(userModel) .withCoreAPI().usingSite(siteModel).getSiteMembers(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); } } diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteSanityTests.java index 96fcd3ec6..2f8290df7 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteSanityTests.java @@ -6,9 +6,9 @@ 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.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -104,6 +104,7 @@ public class GetSiteSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Failed authentication get site call returns status code 401") + @Bug(id="MNT-16904") public void unauthenticatedUserIsNotAuthorizedToRetrieveSite() throws JsonToModelConversionException, Exception { userModel = dataUser.createRandomTestUser(); @@ -112,6 +113,6 @@ public class GetSiteSanityTests extends RestTest restClient.authenticateUser(userModel).withParams("maxItems=10000") .withCoreAPI() .getSites(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); } } diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java index 20d39c9a2..e97169646 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java @@ -5,9 +5,9 @@ import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -101,6 +101,7 @@ public class GetSitesSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Failed authentication get sites call returns status code 401") + @Bug(id="MNT-16904") public void unauthenticatedUserIsNotAuthorizedToRetrieveSites() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); @@ -109,6 +110,6 @@ public class GetSitesSanityTests extends RestTest dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); restClient.authenticateUser(userModel).withParams("maxItems=1000") .withCoreAPI().getSites(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); } } diff --git a/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java index c66dd01a9..c6b3aa936 100644 --- a/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java @@ -5,7 +5,6 @@ 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.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; @@ -105,11 +104,12 @@ public class RemoveSiteMemberSanityTests extends RestTest @Test(groups = {TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY}) @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that unauthenticated user is not able to delete site member") + @Bug(id="MNT-16904") public void unauthenticatedUserIsNotAuthorizedToDeleteSiteMember() throws Exception{ UserModel inexistentUser = new UserModel("inexistent user", "inexistent password"); restClient.authenticateUser(inexistentUser) .withCoreAPI().usingSite(siteModel).deleteSiteMember(testUserModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); } } diff --git a/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java index ea98d2c7d..b09c3ddf3 100644 --- a/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java @@ -4,7 +4,6 @@ import org.alfresco.rest.RestTest; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; @@ -103,11 +102,12 @@ public class UpdateSiteMemberSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that unauthenticated user is not able to update site member") + @Bug(id="MNT-16904") public void unauthenticatedUserIsNotAuthorizedToUpdateSiteMmeber() throws Exception{ UserModel inexistentUser = new UserModel("inexistent user", "inexistent password"); restClient.authenticateUser(inexistentUser); testUserModel.setUserRole(UserRole.SiteCollaborator); restClient.withCoreAPI().usingSite(siteModel).updateSiteMember(testUserModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); } } diff --git a/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java index 793986860..d9d08fbcd 100644 --- a/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java @@ -10,9 +10,9 @@ import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.RandomData; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -121,12 +121,13 @@ public class AddTagSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user gets status code 401 if authentication call fails") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) + @Bug(id="MNT-16904") public void userIsNotAbleToAddTagIfAuthenticationFails() throws JsonToModelConversionException, Exception { UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); siteManager.setPassword("wrongPassword"); restClient.authenticateUser(siteManager); restClient.withCoreAPI().usingResource(document).addTag("tagUnauthorized"); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/tags/AddTagsSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/AddTagsSanityTests.java index c719a0764..ca09f76ef 100644 --- a/e2e-test/java/org/alfresco/rest/tags/AddTagsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/AddTagsSanityTests.java @@ -10,9 +10,9 @@ import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.RandomData; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -120,11 +120,12 @@ public class AddTagsSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API,TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user gets status code 401 if authentication call fails") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) + @Bug(id="MNT-16904") public void userIsNotAbleToAddTagsIfAuthenticationFails() throws JsonToModelConversionException, Exception { UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); siteManager.setPassword("wrongPassword"); restClient.authenticateUser(siteManager).withCoreAPI().usingResource(document).addTags(tag1, tag2); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/tags/DeleteTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/DeleteTagSanityTests.java index b2d8f1427..0cba0200b 100644 --- a/e2e-test/java/org/alfresco/rest/tags/DeleteTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/DeleteTagSanityTests.java @@ -10,9 +10,9 @@ import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.RandomData; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -120,6 +120,7 @@ public class DeleteTagSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user gets status code 401 if authentication call fails") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) + @Bug(id="MNT-16904") public void userIsNotAbleToDeleteTagIfAuthenticationFails() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); @@ -129,6 +130,6 @@ public class DeleteTagSanityTests extends RestTest siteManager.setPassword("wrongPassword"); restClient.authenticateUser(siteManager); restClient.withCoreAPI().usingResource(document).deleteTag(tag); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java index 58870c97c..e22ad4e1e 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java @@ -9,9 +9,9 @@ import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.data.RandomData; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -119,10 +119,11 @@ public class GetNodeTagsSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to get node tags") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) + @Bug(id="MNT-16904") public void unauthenticatedUserIsNotAbleToRetrieveNodeTags() throws JsonToModelConversionException, Exception { restClient.authenticateUser(new UserModel("random user", "random password")); restClient.withCoreAPI().usingResource(document).getNodeTags(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/tags/GetTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagSanityTests.java index 7649fa347..192c01e20 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetTagSanityTests.java @@ -9,9 +9,9 @@ import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.data.RandomData; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -108,6 +108,7 @@ public class GetTagSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Manager user gets status code 401 if authentication call fails") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) + @Bug(id="MNT-16904") public void managerIsNotAbleToGetTagIfAuthenticationFails() throws JsonToModelConversionException, Exception { String tagValue = RandomData.getRandomName("tag"); @@ -119,7 +120,7 @@ public class GetTagSanityTests extends RestTest managerUser.setPassword("wrongPassword"); restClient.authenticateUser(managerUser); restClient.withCoreAPI().getTag(tag); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java index de694b3b9..508017a5d 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java @@ -10,9 +10,9 @@ import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.data.RandomData; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -109,6 +109,7 @@ public class GetTagsSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Failed authentication get tags call returns status code 401 with Manager role") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) + @Bug(id="MNT-16904") public void failedAuthenticationReturnsUnauthorizedStatus() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); @@ -117,6 +118,6 @@ public class GetTagsSanityTests extends RestTest dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); restClient.authenticateUser(userModel); restClient.withCoreAPI().getTags(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); } } diff --git a/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java index 143144982..259c01b28 100644 --- a/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java @@ -10,7 +10,6 @@ import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.RandomData; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; @@ -105,12 +104,13 @@ public class UpdateTagSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user gets status code 401 if authentication call fails") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) + @Bug(id="MNT-16904") public void userIsNotAbleToUpdateTagIfAuthenticationFails() throws JsonToModelConversionException, Exception { UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); siteManager.setPassword("wrongPassword"); restClient.authenticateUser(siteManager); restClient.withCoreAPI().usingTag(oldTag).update(randomTag); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastStatus().hasName(StatusModel.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); } } \ No newline at end of file From 9f67e7b2ff45e67e35c3ea521d1ebb07c6f791e2 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Wed, 14 Dec 2016 18:22:50 +0200 Subject: [PATCH 0767/1491] test: mark @bug test for 5.2.N --- .../rest/comments/AddCommentsSanityTests.java | 2 + .../AddSiteMembershipRequestCoreTests.java | 16 +- .../GetSiteMembershipRequestCoreTests.java | 31 ++-- .../rest/ratings/DeleteRatingCoreTests.java | 30 ++-- .../rest/ratings/GetRatingSanityTests.java | 31 ++-- .../rest/ratings/GetRatingsSanityTests.java | 32 ++-- .../rest/sites/AddSiteMemberCoreTests.java | 27 ++-- .../sites/RemoveSiteMemberSanityTests.java | 147 ++++++++++-------- .../rest/tags/DeleteTagCoreTests.java | 31 ++-- .../GetProcessVariablesCoreTests.java | 4 +- .../tasks/DeleteTaskVariableCoreTests.java | 2 + .../tasks/RemoveTaskItemCoreTests.java | 2 + .../tasks/UpdateTaskVariableCoreTests.java | 2 + 13 files changed, 220 insertions(+), 137 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java index f24f13807..da6615e43 100644 --- a/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java @@ -11,6 +11,7 @@ import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -114,6 +115,7 @@ public class AddCommentsSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user gets status code 401 on post multiple comments call") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) + @Bug(id="MNT-16904") public void unauthenticatedUserIsNotAbleToAddComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(new UserModel("random user", "random password")) diff --git a/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestCoreTests.java b/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestCoreTests.java index c0fa212c0..c88a75046 100644 --- a/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestCoreTests.java @@ -11,13 +11,11 @@ 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.BeforeMethod; import org.testng.annotations.Test; public class AddSiteMembershipRequestCoreTests extends RestTest { - private UserModel adminUser; - private UserModel newMember; + private UserModel adminUser; private SiteModel siteModel; @BeforeClass(alwaysRun = true) @@ -27,16 +25,13 @@ public class AddSiteMembershipRequestCoreTests extends RestTest siteModel = dataSite.usingUser(adminUser).createModeratedRandomSite(); } - @BeforeMethod - public void setUp() throws DataPreparationException - { - newMember = dataUser.createRandomTestUser(); - } + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify addSiteMembershipRequest Rest API status code is 400 for a user that has already been invited") public void addSiteMembershipRequestStatusCodeIs400ReceivedForAUserThatIsAlreadyInvited() throws Exception { + UserModel newMember = dataUser.createRandomTestUser(); dataUser.addUserToSite(newMember, siteModel, UserRole.SiteContributor); restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); @@ -47,6 +42,7 @@ public class AddSiteMembershipRequestCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify addSiteMembershipRequest Rest API status code is 404 for a user that does not exist") public void addSiteMembershipRequestStatusCodeIs404ReceivedForAUserThatDoesNotExist() throws Exception { + UserModel newMember = dataUser.createRandomTestUser(); restClient.authenticateUser(newMember).withCoreAPI().usingUser(new UserModel("invalidUser", "password")).addSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); restClient.assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidUser")); @@ -56,6 +52,7 @@ public class AddSiteMembershipRequestCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify addSiteMembershipRequest Rest API status code is 404 for a site that does not exist") public void addSiteMembershipRequestStatusCodeIs404ReceivedForASiteThatDoesNotExist() throws Exception { + UserModel newMember = dataUser.createRandomTestUser(); restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest(new SiteModel("invalidSiteID")); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); restClient.assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, newMember.getUsername(), "invalidSiteID")); @@ -65,6 +62,7 @@ public class AddSiteMembershipRequestCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify addSiteMembershipRequest Rest API status code is 400 for empty request body") public void addSiteMembershipRequestStatusCodeIs400ForEmptyRequestBody() throws Exception { + UserModel newMember = dataUser.createRandomTestUser(); restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest(""); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); } @@ -73,6 +71,7 @@ public class AddSiteMembershipRequestCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify addSiteMembershipRequest Rest API status code is 201 for request with empty message") public void addSiteMembershipRequestStatusCodeIs201ForRequestWithEmptyMessage() throws Exception { + UserModel newMember = dataUser.createRandomTestUser(); restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest("", siteModel, "New request"); restClient.assertStatusCodeIs(HttpStatus.CREATED); } @@ -81,6 +80,7 @@ public class AddSiteMembershipRequestCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify addSiteMembershipRequest Rest API status code is 201 for request with empty title") public void addSiteMembershipRequestStatusCodeIs201ForRequestWithEmptyTitle() throws Exception { + UserModel newMember = dataUser.createRandomTestUser(); restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest("Please accept me", siteModel, ""); restClient.assertStatusCodeIs(HttpStatus.CREATED); } diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestCoreTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestCoreTests.java index f26ba65be..85e9185e4 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestCoreTests.java @@ -36,8 +36,9 @@ public class GetSiteMembershipRequestCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify contributor user fails to get all site membership requests of a specific person with Rest API when the authentication fails (401)") - @Bug(id="16904") + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify contributor user fails to get all site membership requests of a specific person with Rest API when the authentication fails (401)") + @Bug(id = "16904") public void unauthorizedContributorUserFailsToGetSiteMembershipRequests() throws Exception { UserModel contributor = dataUser.usingAdmin().createRandomTestUser(); @@ -48,7 +49,9 @@ public class GetSiteMembershipRequestCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify collaborator user fails to get all site membership requests of a specific person with Rest API when the authentication fails (401)") + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify collaborator user fails to get all site membership requests of a specific person with Rest API when the authentication fails (401)") + @Bug(id="MNT-16904") public void unauthorizedCollaboratorUserFailsToGetSiteMembershipRequests() throws Exception { UserModel collaborator = dataUser.usingAdmin().createRandomTestUser(); @@ -59,7 +62,9 @@ public class GetSiteMembershipRequestCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify consumer user fails to get all site membership requests of a specific person with Rest API when the authentication fails (401)") + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify consumer user fails to get all site membership requests of a specific person with Rest API when the authentication fails (401)") + @Bug(id = "MNT-16904") public void unauthorizedConsumerUserFailsToGetSiteMembershipRequests() throws Exception { UserModel consumer = dataUser.usingAdmin().createRandomTestUser(); @@ -70,7 +75,8 @@ public class GetSiteMembershipRequestCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify a user gets all its own site membership requests using '-me-' with Rest API and response is successful (200)") + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify a user gets all its own site membership requests using '-me-' with Rest API and response is successful (200)") public void usingMeGetSiteMembershipRequestsWithSuccess() throws Exception { restClient.authenticateUser(newMember).withCoreAPI().usingMe().getSiteMembershipRequest(siteModel).assertThat().field("id").is(siteModel.getId()); @@ -78,7 +84,8 @@ public class GetSiteMembershipRequestCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site manager can't get site membership requests for inexistent user and response is not found (404)") + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site manager can't get site membership requests for inexistent user and response is not found (404)") public void siteManagerCantGetSiteMembershipRequestsInexistentUser() throws Exception { restClient.authenticateUser(newMember).withCoreAPI().usingUser(UserModel.getRandomUserModel()).getSiteMembershipRequest(siteModel); @@ -86,7 +93,8 @@ public class GetSiteMembershipRequestCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user can get site membership requests on site with no requests and response is successful (200)") + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user can get site membership requests on site with no requests and response is successful (200)") public void userCantGetSiteMembershipRequestsWithNoRequests() throws Exception { UserModel noRequestUser = dataUser.createRandomTestUser(); @@ -96,7 +104,8 @@ public class GetSiteMembershipRequestCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site manager can't get site membership requests on public site and response is not found (404)") + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site manager can't get site membership requests on public site and response is not found (404)") public void siteManagerCantGetPublicSiteMembershipRequests() throws Exception { UserModel publicUser = dataUser.createRandomTestUser(); @@ -108,7 +117,8 @@ public class GetSiteMembershipRequestCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site manager can't get site membership requests on private site and response is not found (404)") + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site manager can't get site membership requests on private site and response is not found (404)") public void siteManagerCantGetPrivateSiteMembershipRequests() throws Exception { UserModel privateUser = dataUser.createRandomTestUser(); @@ -120,7 +130,8 @@ public class GetSiteMembershipRequestCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site manager can't get site membership requests for inexistent site and response is not found (404)") + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site manager can't get site membership requests for inexistent site and response is not found (404)") public void siteManagerCantGetSiteMembershipRequestsForInexistentSite() throws Exception { SiteModel inexistentSite = SiteModel.getRandomSiteModel(); diff --git a/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingCoreTests.java b/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingCoreTests.java index 00b688664..a3f0b61e9 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingCoreTests.java @@ -17,7 +17,6 @@ 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.BeforeMethod; import org.testng.annotations.Test; public class DeleteRatingCoreTests extends RestTest @@ -25,8 +24,7 @@ public class DeleteRatingCoreTests extends RestTest private SiteModel siteModel; private UserModel adminUser; - private FolderModel folderModel; - private FileModel document; + private ListUserWithRoles usersWithRoles; private RestRatingModel returnedRatingModel; @@ -40,18 +38,13 @@ public class DeleteRatingCoreTests extends RestTest UserRole.SiteContributor); } - @BeforeMethod() - public void setUp() throws DataPreparationException, Exception - { - folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - } - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Verify that if ratingId provided is unknown status code returned is 400") @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) public void deleteInvalidRating() throws Exception { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).deleteInvalidRating("random_rating"); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_RATING, "random_rating")); } @@ -61,6 +54,8 @@ public class DeleteRatingCoreTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) public void deleteRatingUsingInvalidDocument() throws Exception { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); document.setNodeRef("random_value"); restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).deleteLikeRating(); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "random_value")); @@ -72,6 +67,8 @@ public class DeleteRatingCoreTests extends RestTest @Bug(id = "MNT-17181") public void deleteStarsForANotRatedDocument() throws Exception { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).deleteFiveStarRating(); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); } @@ -82,6 +79,8 @@ public class DeleteRatingCoreTests extends RestTest @Bug(id = "MNT-17181") public void deleteLikeForANotLikedDocument() throws Exception { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).deleteLikeRating(); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); } @@ -91,6 +90,8 @@ public class DeleteRatingCoreTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) public void likeDocumentAfterLikeRatingIsDeleted() throws Exception { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); restClient.withCoreAPI().usingResource(document).deleteLikeRating(); returnedRatingModel = restClient.withCoreAPI().usingResource(document).likeDocument(); @@ -105,6 +106,9 @@ public class DeleteRatingCoreTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) public void addStarsToDocumentAfterRatingIsDeleted() throws Exception { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(document).rateStarsToDocument(5); restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); @@ -121,6 +125,9 @@ public class DeleteRatingCoreTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) public void deleteDocumentRatingUsingManager() throws Exception { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(document).rateStarsToDocument(5); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(document).likeDocument(); @@ -136,6 +143,9 @@ public class DeleteRatingCoreTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) public void deleteLikeOfAnotherUser() throws Exception { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingResource(document).likeDocument(); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(document).deleteLikeRating(); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); diff --git a/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java index a67460be9..5ddddd6df 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java @@ -17,16 +17,12 @@ 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.BeforeMethod; import org.testng.annotations.Test; public class GetRatingSanityTests extends RestTest { - private SiteModel siteModel; - private UserModel adminUser; - private FolderModel folderModel; - private FileModel document; + private UserModel adminUser; private ListUserWithRoles usersWithRoles; private RestRatingModel restRatingModel; @@ -40,18 +36,14 @@ public class GetRatingSanityTests extends RestTest UserRole.SiteContributor); } - @BeforeMethod() - public void setUp() throws DataPreparationException, Exception - { - folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - } - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role is able to retrieve rating of a document") @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) public void managerIsAbleToRetrieveRating() throws Exception { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); restClient.withCoreAPI().usingResource(document).likeDocument(); @@ -71,6 +63,9 @@ public class GetRatingSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) public void collaboratorIsAbleToRetrieveRating() throws Exception { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); restClient.withCoreAPI().usingResource(document).likeDocument(); @@ -90,6 +85,9 @@ public class GetRatingSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) public void contributorIsAbleToRetrieveRating() throws Exception { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); restClient.withCoreAPI().usingResource(document).likeDocument(); @@ -109,6 +107,9 @@ public class GetRatingSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) public void consumerIsAbleToRetrieveRating() throws Exception { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); restClient.withCoreAPI().usingResource(document).likeDocument(); @@ -128,6 +129,9 @@ public class GetRatingSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) public void adminIsAbleToRetrieveRating() throws Exception { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + document = dataContent.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingResource(folderModel) .createContent(DocumentType.TEXT_PLAIN); @@ -150,6 +154,9 @@ public class GetRatingSanityTests extends RestTest @Bug(id = "MNT-16904") public void unauthenticatedUserIsNotAbleToRetrieveRating() throws Exception { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(adminUser); restClient.withCoreAPI().usingResource(document).likeDocument(); restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); diff --git a/e2e-test/java/org/alfresco/rest/ratings/GetRatingsSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/GetRatingsSanityTests.java index 8c70ad304..58a0f18a3 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/GetRatingsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/GetRatingsSanityTests.java @@ -12,19 +12,17 @@ import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; public class GetRatingsSanityTests extends RestTest { private SiteModel siteModel; - private UserModel adminUser; - private FolderModel folderModel; - private FileModel document; + private UserModel adminUser; private ListUserWithRoles usersWithRoles; private RestRatingModelsCollection restRatingModelsCollection; @@ -38,18 +36,14 @@ public class GetRatingsSanityTests extends RestTest UserRole.SiteContributor); } - @BeforeMethod() - public void setUp() throws DataPreparationException, Exception - { - folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - } - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Manager is able to retrieve document ratings") @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) public void managerIsAbleToRetrieveDocumentRatings() throws Exception { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); restClient.withCoreAPI().usingResource(document).likeDocument(); @@ -65,6 +59,9 @@ public class GetRatingsSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) public void collaboratorIsAbleToRetrieveDocumentRatings() throws Exception { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); restClient.withCoreAPI().usingResource(document).likeDocument(); @@ -80,6 +77,9 @@ public class GetRatingsSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) public void contributorIsAbleToRetrieveDocumentRatings() throws Exception { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); restClient.withCoreAPI().usingResource(document).likeDocument(); @@ -95,6 +95,9 @@ public class GetRatingsSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) public void consumerIsAbleToRetrieveDocumentRatings() throws Exception { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); restClient.withCoreAPI().usingResource(document).likeDocument(); @@ -110,6 +113,9 @@ public class GetRatingsSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) public void adminIsAbleToRetrieveDocumentRatings() throws Exception { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + document = dataContent.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingResource(folderModel) .createContent(DocumentType.TEXT_PLAIN); @@ -125,8 +131,12 @@ public class GetRatingsSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to retrieve document ratings") @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) + @Bug(id="MNT-16904") public void unauthenticatedUserIsNotAbleToRetrieveRatings() throws Exception { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(adminUser); restClient.withCoreAPI().usingResource(document).likeDocument(); restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); diff --git a/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberCoreTests.java index 5db2bc437..f9bbcfeba 100644 --- a/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberCoreTests.java @@ -7,7 +7,6 @@ import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestSiteMemberModel; 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; @@ -16,13 +15,11 @@ import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; public class AddSiteMemberCoreTests extends RestTest { private UserModel adminUserModel; - private UserModel testUser; private SiteModel publicSiteModel; private SiteModel moderatedSiteModel; private SiteModel privateSiteModel; @@ -45,17 +42,14 @@ public class AddSiteMemberCoreTests extends RestTest addMembersJson = "{\"role\":\"%s\",\"id\":\"%s\"}, {\"role\":\"%s\",\"id\":\"%s\"}"; } - @BeforeMethod - public void setUp() throws DataPreparationException { - testUser = dataUser.createRandomTestUser("testUser"); - } + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Verify that manager can add another user as manager to a public site and gets status code CREATED (201)") public void addManagerToPublicSite() throws Exception { - testUser.setUserRole(UserRole.SiteManager); + UserModel testUser = dataUser.createRandomTestUser("testUser"); memberModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(testUser); restClient.assertStatusCodeIs(HttpStatus.CREATED); memberModel.assertThat().field("id").is(testUser.getUsername()) @@ -67,6 +61,7 @@ public class AddSiteMemberCoreTests extends RestTest description = "Verify that manager can add another user as manager to a moderated site and gets status code CREATED (201)") public void addManagerToModeratedSite() throws Exception { + UserModel testUser = dataUser.createRandomTestUser("testUser"); testUser.setUserRole(UserRole.SiteManager); memberModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(testUser); restClient.assertStatusCodeIs(HttpStatus.CREATED); @@ -79,6 +74,7 @@ public class AddSiteMemberCoreTests extends RestTest description = "Verify that manager can add another user as manager to a private site and gets status code CREATED (201)") public void addManagerToPrivateSite() throws Exception { + UserModel testUser = dataUser.createRandomTestUser("testUser"); testUser.setUserRole(UserRole.SiteManager); memberModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(testUser); restClient.assertStatusCodeIs(HttpStatus.CREATED); @@ -91,6 +87,7 @@ public class AddSiteMemberCoreTests extends RestTest description = "Verify that consumer role is not able to add another user to a moderated site and gets status code 403") public void addUserByConsumerToModeratedSite() throws Exception { + UserModel testUser = dataUser.createRandomTestUser("testUser"); testUser.setUserRole(UserRole.SiteConsumer); restClient.authenticateUser(usersWithRolesToModeratedSite.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingSite(moderatedSiteModel).addPerson(testUser); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); @@ -101,6 +98,7 @@ public class AddSiteMemberCoreTests extends RestTest description = "Verify that consumer role is not able to add another user to a private site and gets status code 403") public void addUserByConsumerToPrivateSite() throws Exception { + UserModel testUser = dataUser.createRandomTestUser("testUser"); testUser.setUserRole(UserRole.SiteConsumer); restClient.authenticateUser(usersWithRolesToPrivateSite.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingSite(privateSiteModel).addPerson(testUser); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); @@ -111,6 +109,7 @@ public class AddSiteMemberCoreTests extends RestTest description = "Verify that collaborator role is not able to add another user to a moderated site and gets status code 403") public void addUserByCollaboratorToModeratedSite() throws Exception { + UserModel testUser = dataUser.createRandomTestUser("testUser"); testUser.setUserRole(UserRole.SiteConsumer); restClient.authenticateUser(usersWithRolesToModeratedSite.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingSite(moderatedSiteModel).addPerson(testUser); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); @@ -121,6 +120,7 @@ public class AddSiteMemberCoreTests extends RestTest description = "Verify that collaborator role is not able to add another user to a private site and gets status code 403") public void addUserByCollaboratorToPrivateSite() throws Exception { + UserModel testUser = dataUser.createRandomTestUser("testUser"); testUser.setUserRole(UserRole.SiteConsumer); restClient.authenticateUser(usersWithRolesToPrivateSite.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingSite(privateSiteModel).addPerson(testUser); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); @@ -131,6 +131,7 @@ public class AddSiteMemberCoreTests extends RestTest description = "Verify that contributor role is not able to add another user to a moderated site and gets status code 403") public void addUserByContributorToModeratedSite() throws Exception { + UserModel testUser = dataUser.createRandomTestUser("testUser"); testUser.setUserRole(UserRole.SiteConsumer); restClient.authenticateUser(usersWithRolesToModeratedSite.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingSite(moderatedSiteModel).addPerson(testUser); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); @@ -140,7 +141,8 @@ public class AddSiteMemberCoreTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Verify that contributor role is not able to add another user to a private site and gets status code 403") public void addUserByContributorToPrivateSite() throws Exception - { + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); testUser.setUserRole(UserRole.SiteConsumer); restClient.authenticateUser(usersWithRolesToPrivateSite.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingSite(privateSiteModel).addPerson(testUser); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); @@ -151,6 +153,7 @@ public class AddSiteMemberCoreTests extends RestTest description = "Verify that a user without specified role can not be added to a site and gets status code 400") public void canNotAddUserWithoutSpecifyingRoleToSite() throws Exception { + UserModel testUser = dataUser.createRandomTestUser("testUser"); restClient.authenticateUser(adminUserModel).withCoreAPI(); String json = JsonBodyGenerator.keyValueJson("id", testUser.getUsername()); RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, json, "sites/{siteId}/members?{parameters}", publicSiteModel.getId(), restClient.getParameters()); @@ -163,6 +166,7 @@ public class AddSiteMemberCoreTests extends RestTest description = "Verify that a user with inexistent role can not be added to a site and gets status code 400") public void canNotAddUserWithInexistentRoleToSite() throws Exception { + UserModel testUser = dataUser.createRandomTestUser("testUser"); restClient.authenticateUser(adminUserModel).withCoreAPI(); RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, String.format("{\"role\":\"inexistentRole\",\"id\":\"%s\"}", testUser.getUsername()), "sites/{siteId}/members?{parameters}", publicSiteModel.getId(), restClient.getParameters()); restClient.processModel(RestSiteMemberModel.class, request); @@ -174,6 +178,7 @@ public class AddSiteMemberCoreTests extends RestTest description = "Verify that user can not add himself as a manager to a public site and gets status code 403") public void userAddHimselfAsManagerToPublicSite() throws Exception { + UserModel testUser = dataUser.createRandomTestUser("testUser"); testUser.setUserRole(UserRole.SiteManager); restClient.authenticateUser(testUser).withCoreAPI().usingSite(publicSiteModel).addPerson(testUser); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); @@ -184,6 +189,7 @@ public class AddSiteMemberCoreTests extends RestTest description = "Verify that user can not add himself as a manager to a moderated site and gets status code 403") public void userAddHimselfAsManagerToModeratedSite() throws Exception { + UserModel testUser = dataUser.createRandomTestUser("testUser"); testUser.setUserRole(UserRole.SiteManager); restClient.authenticateUser(testUser).withCoreAPI().usingSite(moderatedSiteModel).addPerson(testUser); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); @@ -194,6 +200,7 @@ public class AddSiteMemberCoreTests extends RestTest description = "Verify that user can not add himself as a manager to a private site and gets status code 404") public void userAddHimselfAsManagerToPrivateSite() throws Exception { + UserModel testUser = dataUser.createRandomTestUser("testUser"); testUser.setUserRole(UserRole.SiteManager); restClient.authenticateUser(testUser).withCoreAPI().usingSite(privateSiteModel).addPerson(testUser); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, privateSiteModel.getId())); @@ -204,6 +211,7 @@ public class AddSiteMemberCoreTests extends RestTest description = "Verify that user can not be added to an inexistent site and gets status code 404") public void userIsNotAbleToAddUserToAnInexistentSite() throws Exception { + UserModel testUser = dataUser.createRandomTestUser("testUser"); testUser.setUserRole(UserRole.SiteManager); SiteModel inexistentSite = new SiteModel("inexistentSite"); restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(inexistentSite).addPerson(testUser); @@ -215,6 +223,7 @@ public class AddSiteMemberCoreTests extends RestTest description = "Verify that user can not be added to a site if an empty site id is provided and gets status code 404") public void userIsNotAbleToAddAnotherUserUsingEmptySiteId() throws Exception { + UserModel testUser = dataUser.createRandomTestUser("testUser"); testUser.setUserRole(UserRole.SiteManager); SiteModel inexistentSite = new SiteModel(""); restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(inexistentSite).addPerson(testUser); diff --git a/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java index c6b3aa936..c84996bca 100644 --- a/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java @@ -12,104 +12,119 @@ 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.BeforeMethod; import org.testng.annotations.Test; /** * @author iulia.cojocea */ public class RemoveSiteMemberSanityTests extends RestTest -{ +{ private SiteModel siteModel; private UserModel adminUserModel; private ListUserWithRoles usersWithRoles; - private UserModel testUserModel; - + @BeforeClass(alwaysRun = true) - public void dataPreparation() throws DataPreparationException{ + public void dataPreparation() throws DataPreparationException + { adminUserModel = dataUser.getAdminUser(); siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, - UserRole.SiteConsumer, UserRole.SiteContributor); - } - - @BeforeMethod - public void addUserToSite() throws DataPreparationException{ - testUserModel = dataUser.createRandomTestUser(); - dataUser.addUserToSite(testUserModel, siteModel, UserRole.SiteConsumer); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); } - @Test(groups = {TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY}) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, - description = "Verify that site manager can delete site member and gets status code 204, 'No Content'") - public void siteManagerIsAbleToDeleteSiteMemberWithConsumerRole() throws Exception{ + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that site manager can delete site member and gets status code 204, 'No Content'") + public void siteManagerIsAbleToDeleteSiteMemberWithConsumerRole() throws Exception + { + UserModel testUserModel = dataUser.createRandomTestUser(); + dataUser.addUserToSite(testUserModel, siteModel, UserRole.SiteConsumer); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingSite(siteModel).deleteSiteMember(testUserModel); + restClient.withCoreAPI().usingSite(siteModel).deleteSiteMember(testUserModel); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); restClient.withCoreAPI().getSites().assertThat().entriesListDoesNotContain("id", testUserModel.getUsername()); restClient.assertStatusCodeIs(HttpStatus.OK); } - - @Bug(id="ACE-5444") - @Test(groups = {TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY}) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, - description = "Verify that site collaborator cannot delete site member and gets status code 403, 'Forbidden'") - public void siteCollaboratorIsNotAbleToDeleteSiteMemberWithConsumerRole() throws Exception{ + + @Bug(id = "ACE-5444") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that site collaborator cannot delete site member and gets status code 403, 'Forbidden'") + public void siteCollaboratorIsNotAbleToDeleteSiteMemberWithConsumerRole() throws Exception + { + UserModel testUserModel = dataUser.createRandomTestUser(); + dataUser.addUserToSite(testUserModel, siteModel, UserRole.SiteConsumer); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); restClient.withCoreAPI().usingSite(siteModel).deleteSiteMember(testUserModel); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - - restClient.withCoreAPI().getSites().assertThat().entriesListContains("id", testUserModel.getUsername()); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Bug(id="ACE-5444") - @Test(groups = {TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY}) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, - description = "Verify that site contributor cannot delete site member and gets status code 403, 'Forbidden'") - public void siteContributorIsNotAbleToDeleteSiteMemberWithConsumerRole() throws Exception{ - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - restClient.withCoreAPI().usingSite(siteModel).deleteSiteMember(testUserModel); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - - restClient.withCoreAPI().getSites().assertThat().entriesListContains("id", testUserModel.getUsername()); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Bug(id="ACE-5444") - @Test(groups = {TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY}) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, - description = "Verify that site consumer cannot delete site member and gets status code 403, 'Forbidden'") - public void siteConsumerIsNotAbleToDeleteSiteMemberWithConsumerRole() throws Exception{ - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .withCoreAPI().usingSite(siteModel).deleteSiteMember(testUserModel); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - + restClient.withCoreAPI().getSites().assertThat().entriesListContains("id", testUserModel.getUsername()); restClient.assertStatusCodeIs(HttpStatus.OK); } - @Test(groups = {TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY}) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, - description = "Verify that admin user can delete site member and gets status code 204, 'No Content'") - public void adminUserIsAbleToDeleteSiteMember() throws Exception{ - restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingSite(siteModel).deleteSiteMember(testUserModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + @Bug(id = "ACE-5444") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that site contributor cannot delete site member and gets status code 403, 'Forbidden'") + public void siteContributorIsNotAbleToDeleteSiteMemberWithConsumerRole() throws Exception + { + UserModel testUserModel = dataUser.createRandomTestUser(); + dataUser.addUserToSite(testUserModel, siteModel, UserRole.SiteConsumer); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + restClient.withCoreAPI().usingSite(siteModel).deleteSiteMember(testUserModel); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + + restClient.withCoreAPI().getSites().assertThat().entriesListContains("id", testUserModel.getUsername()); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Bug(id = "ACE-5444") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that site consumer cannot delete site member and gets status code 403, 'Forbidden'") + public void siteConsumerIsNotAbleToDeleteSiteMemberWithConsumerRole() throws Exception + { + UserModel testUserModel = dataUser.createRandomTestUser(); + dataUser.addUserToSite(testUserModel, siteModel, UserRole.SiteConsumer); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingSite(siteModel) + .deleteSiteMember(testUserModel); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + + restClient.withCoreAPI().getSites().assertThat().entriesListContains("id", testUserModel.getUsername()); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that admin user can delete site member and gets status code 204, 'No Content'") + public void adminUserIsAbleToDeleteSiteMember() throws Exception + { + UserModel testUserModel = dataUser.createRandomTestUser(); + dataUser.addUserToSite(testUserModel, siteModel, UserRole.SiteConsumer); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(siteModel).deleteSiteMember(testUserModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withCoreAPI().getSites().assertThat().entriesListDoesNotContain("id", testUserModel.getUsername()); restClient.assertStatusCodeIs(HttpStatus.OK); } - @Test(groups = {TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY}) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, - description = "Verify that unauthenticated user is not able to delete site member") - @Bug(id="MNT-16904") - public void unauthenticatedUserIsNotAuthorizedToDeleteSiteMember() throws Exception{ - UserModel inexistentUser = new UserModel("inexistent user", "inexistent password"); - restClient.authenticateUser(inexistentUser) - .withCoreAPI().usingSite(siteModel).deleteSiteMember(testUserModel); + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that unauthenticated user is not able to delete site member") + @Bug(id = "MNT-16904") + public void unauthenticatedUserIsNotAuthorizedToDeleteSiteMember() throws Exception + { + UserModel testUserModel = dataUser.createRandomTestUser(); + dataUser.addUserToSite(testUserModel, siteModel, UserRole.SiteConsumer); + UserModel inexistentUser = new UserModel("inexistent user", "inexistent password"); + restClient.authenticateUser(inexistentUser).withCoreAPI().usingSite(siteModel).deleteSiteMember(testUserModel); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); } } diff --git a/e2e-test/java/org/alfresco/rest/tags/DeleteTagCoreTests.java b/e2e-test/java/org/alfresco/rest/tags/DeleteTagCoreTests.java index 0d909bf90..431573fdc 100644 --- a/e2e-test/java/org/alfresco/rest/tags/DeleteTagCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/DeleteTagCoreTests.java @@ -15,14 +15,13 @@ import org.alfresco.utility.testrail.annotation.TestRail; import org.apache.commons.lang3.RandomStringUtils; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; public class DeleteTagCoreTests extends RestTest { - private UserModel adminUserModel, userModel; - private SiteModel siteModel; - private RestTagModel tag; + private UserModel adminUserModel; + private UserModel userModel; + private SiteModel siteModel; private FileModel document; private FolderModel folderModel; @@ -36,17 +35,14 @@ public class DeleteTagCoreTests extends RestTest folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); } - @BeforeMethod - public void setUp() throws Exception { - restClient.authenticateUser(adminUserModel); - tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); - } - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify that if user has no permission to remove tag returned status code is 403") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) public void deleteTagWithUserWithoutPermission() throws Exception { + restClient.authenticateUser(adminUserModel); + RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); + restClient.authenticateUser(userModel); restClient.withCoreAPI().usingResource(document).deleteTag(tag); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); @@ -57,6 +53,9 @@ public class DeleteTagCoreTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) public void deleteTagForAnInexistentNode() throws Exception { + restClient.authenticateUser(adminUserModel); + RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); + FileModel document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); String nodeRef = RandomStringUtils.randomAlphanumeric(10); document.setNodeRef(nodeRef); @@ -69,6 +68,9 @@ public class DeleteTagCoreTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) public void deleteTagThatDoesNotExist() throws Exception { + restClient.authenticateUser(adminUserModel); + RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); + tag.setId("abc"); restClient.withCoreAPI().usingResource(document).deleteTag(tag); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "abc")); @@ -79,6 +81,9 @@ public class DeleteTagCoreTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) public void deleteTagWithEmptyId() throws Exception { + restClient.authenticateUser(adminUserModel); + RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); + tag.setId(""); restClient.withCoreAPI().usingResource(document).deleteTag(tag); restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.DELETE_EMPTY_ARGUMENT); @@ -89,6 +94,9 @@ public class DeleteTagCoreTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) public void deleteFileTag() throws Exception { + restClient.authenticateUser(adminUserModel); + RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); + restClient.withCoreAPI().usingResource(document).deleteTag(tag); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); restClient.withCoreAPI().usingResource(document).getNodeTags() @@ -100,6 +108,9 @@ public class DeleteTagCoreTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) public void deleteFolderTag() throws Exception { + restClient.authenticateUser(adminUserModel); + RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); + tag = restClient.withCoreAPI().usingResource(folderModel).addTag(RandomData.getRandomName("tag")); restClient.withCoreAPI().usingResource(folderModel).deleteTag(tag); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesCoreTests.java index 8e7b3c0d5..ef037d9ea 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesCoreTests.java @@ -11,6 +11,7 @@ import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.apache.commons.lang.RandomStringUtils; @@ -87,10 +88,11 @@ public class GetProcessVariablesCoreTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Get process variables using empty process ID") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + @Bug(id="AUTOMATION", description="Please fix this automated test") public void getProcessVariablesUsingEmptyProcessId() throws JsonToModelConversionException, Exception { processModel = restClient.authenticateUser(userWhoStartsTask).withParams("maxItems=2").withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - processModel.setId(" "); + processModel.setId(" /"); variables = restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables(); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, " ")); } diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/DeleteTaskVariableCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/DeleteTaskVariableCoreTests.java index c2d464709..893156fea 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/DeleteTaskVariableCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/DeleteTaskVariableCoreTests.java @@ -9,6 +9,7 @@ import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TaskModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -110,6 +111,7 @@ public class DeleteTaskVariableCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Delete task variable by inexistent user") @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Bug(id="MNT-16904") public void deleteTaskVarialbleByInexistentUser() throws Exception { RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/RemoveTaskItemCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/RemoveTaskItemCoreTests.java index 8544a4576..5802f0246 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/RemoveTaskItemCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/RemoveTaskItemCoreTests.java @@ -11,6 +11,7 @@ import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TaskModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -121,6 +122,7 @@ public class RemoveTaskItemCoreTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Delete existing task item with inexistent user") @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Bug(id="MNT-16904") public void deleteTaskItemWithInexistentUser() throws Exception { taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskVariableCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskVariableCoreTests.java index 97b1dcc70..595d696b9 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskVariableCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskVariableCoreTests.java @@ -9,6 +9,7 @@ import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TaskModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -156,6 +157,7 @@ public class UpdateTaskVariableCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Update task variable by inexistent user") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Bug(id="MNT-16904") public void updateTaskVariableByInexistentser() throws Exception { variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); From 90e71607dfec82d059d25a4d38a56fd2df635b70 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Wed, 14 Dec 2016 19:21:53 +0200 Subject: [PATCH 0768/1491] fix: NPE on 3 new tests --- .../org/alfresco/rest/sites/AddSiteMemberCoreTests.java | 1 + .../rest/workflow/processes/AddProcessItemCoreTests.java | 5 ++++- .../workflow/processes/GetProcessVariablesCoreTests.java | 7 +++++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberCoreTests.java index f9bbcfeba..70df50abc 100644 --- a/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberCoreTests.java @@ -50,6 +50,7 @@ public class AddSiteMemberCoreTests extends RestTest public void addManagerToPublicSite() throws Exception { UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteManager); memberModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(testUser); restClient.assertStatusCodeIs(HttpStatus.CREATED); memberModel.assertThat().field("id").is(testUser.getUsername()) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemCoreTests.java index 98f7c2663..f66a4af22 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemCoreTests.java @@ -7,6 +7,7 @@ import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestItemModel; import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestProcessModelsCollection; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; @@ -114,7 +115,9 @@ public class AddProcessItemCoreTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) public void failedAddingProcessItemIfInvalidProcessIdIsProvided() throws Exception { - processModel = restClient.authenticateUser(adminUser).withParams("maxItems=1").withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + RestProcessModelsCollection processes = restClient.authenticateUser(adminUser).withParams("maxItems=1").withWorkflowAPI().getProcesses(); + processModel= processes.assertThat().entriesListIsNotEmpty().when().getOneRandomEntry().onModel(); + processModel.setId("invalidProcessId"); processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesCoreTests.java index ef037d9ea..f2143585e 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesCoreTests.java @@ -6,6 +6,7 @@ import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestProcessModelsCollection; import org.alfresco.rest.model.RestProcessVariableCollection; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; @@ -77,8 +78,10 @@ public class GetProcessVariablesCoreTests extends RestTest description = "Get process variables using invalid process ID") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) public void getProcessVariablesUsingInvalidProcessId() throws JsonToModelConversionException, Exception - { - processModel = restClient.authenticateUser(userWhoStartsTask).withParams("maxItems=2").withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + { + RestProcessModelsCollection processes = restClient.authenticateUser(userWhoStartsTask).withParams("maxItems=2").withWorkflowAPI().getProcesses(); + processModel = processes.assertThat().entriesListIsNotEmpty().when().getOneRandomEntry().onModel(); + String id = RandomStringUtils.randomAlphanumeric(10); processModel.setId(id); variables = restClient.withParams("maxItems=2").withWorkflowAPI().usingProcess(processModel).getProcessVariables(); From a23afd2a8344686ca64416351e8171b6c20589b9 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Wed, 14 Dec 2016 19:47:06 +0200 Subject: [PATCH 0769/1491] test: annotate failedAddingProcessItemIfInvalidProcessIdIsProvided with @bug fix: getProcessVariablesUsingInvalidProcessId (created one process before test) --- .../rest/workflow/processes/AddProcessItemCoreTests.java | 1 + .../rest/workflow/processes/GetProcessVariablesCoreTests.java | 2 ++ 2 files changed, 3 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemCoreTests.java index f66a4af22..2a78e2d40 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemCoreTests.java @@ -113,6 +113,7 @@ public class AddProcessItemCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process item is falling in case of invalid process id is provided") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + @Bug(id="AUTOMATION", description="Please fix this issue. It seems it's failing with 400 or 404 error code on 5.2") public void failedAddingProcessItemIfInvalidProcessIdIsProvided() throws Exception { RestProcessModelsCollection processes = restClient.authenticateUser(adminUser).withParams("maxItems=1").withWorkflowAPI().getProcesses(); diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesCoreTests.java index f2143585e..e99fb2975 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesCoreTests.java @@ -2,6 +2,7 @@ package org.alfresco.rest.workflow.processes; import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.dataprep.CMISUtil.Priority; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestErrorModel; @@ -79,6 +80,7 @@ public class GetProcessVariablesCoreTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) public void getProcessVariablesUsingInvalidProcessId() throws JsonToModelConversionException, Exception { + restClient.authenticateUser(userWhoStartsTask).withParams("maxItems=2").withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); RestProcessModelsCollection processes = restClient.authenticateUser(userWhoStartsTask).withParams("maxItems=2").withWorkflowAPI().getProcesses(); processModel = processes.assertThat().entriesListIsNotEmpty().when().getOneRandomEntry().onModel(); From f6680cfc1909887db90cccdd07a7b25d6849e57f Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Thu, 15 Dec 2016 17:22:58 +0200 Subject: [PATCH 0770/1491] fix: add processes creation before get one --- .../processes/DeleteProcessVariableSanityTests.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableSanityTests.java index 11811c17a..20b71a373 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableSanityTests.java @@ -1,11 +1,15 @@ package org.alfresco.rest.workflow.processes; import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.dataprep.CMISUtil.Priority; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.rest.model.RestProcessVariableModel; -import org.alfresco.utility.model.*; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -40,6 +44,7 @@ public class DeleteProcessVariableSanityTests extends RestTest public void deleteProcessVariable() throws Exception { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + restClient.authenticateUser(adminUser).withWorkflowAPI().addProcess("activitiAdhoc", adminUser, false, Priority.Normal); processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); From 67a505410a07250194468fa8e5843b37c1f71ffb Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Mon, 19 Dec 2016 10:28:57 +0200 Subject: [PATCH 0771/1491] fix: #deleteProcessVariable - check processModel collection is not empty --- .../workflow/processes/DeleteProcessVariableSanityTests.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableSanityTests.java index 20b71a373..8dbc52b16 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableSanityTests.java @@ -5,6 +5,7 @@ import org.alfresco.dataprep.CMISUtil.Priority; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestProcessModelsCollection; import org.alfresco.rest.model.RestProcessVariableModel; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; @@ -45,7 +46,9 @@ public class DeleteProcessVariableSanityTests extends RestTest { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); restClient.authenticateUser(adminUser).withWorkflowAPI().addProcess("activitiAdhoc", adminUser, false, Priority.Normal); - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + RestProcessModelsCollection pmColl = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses(); + processModel = pmColl.assertThat().entriesListIsNotEmpty().when().getOneRandomEntry().onModel(); + restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); restClient.withWorkflowAPI().usingProcess(processModel).deleteProcessVariable(variableModel); From c29e1b9846ffc1201c67cc49dd0f7d67fd513cdc Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Mon, 19 Dec 2016 16:25:22 +0200 Subject: [PATCH 0772/1491] add annotation --- e2e-test/java/org/alfresco/rest/auth/AuthTests.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/auth/AuthTests.java b/e2e-test/java/org/alfresco/rest/auth/AuthTests.java index 255ad3b39..1cc5b8eac 100644 --- a/e2e-test/java/org/alfresco/rest/auth/AuthTests.java +++ b/e2e-test/java/org/alfresco/rest/auth/AuthTests.java @@ -13,17 +13,17 @@ import org.testng.annotations.Test; public class AuthTests extends RestTest { @TestRail(section = { TestGroup.REST_API }, executionType = ExecutionType.SANITY, description = "Verify TICKET is returned on admin user") - @Test + @Test(groups = { TestGroup.REST_API }) public void adminShouldGetTicketBody() throws JsonToModelConversionException, Exception { RestTicketBodyModel ticketBody = new RestTicketBodyModel(); ticketBody.setUserId("admin"); ticketBody.setPassword("admin"); - + RestTicketModel ticketReturned = restClient.withAuthAPI().createTicket(ticketBody); - + restClient.assertStatusCodeIs(HttpStatus.CREATED); - ticketReturned.assertThat().field("id").contains("TICKET_"); + ticketReturned.assertThat().field("id").contains("TICKET_"); } } \ No newline at end of file From 5e0f325313511ef7b0d174b2442bf5e33ae75efa Mon Sep 17 00:00:00 2001 From: "NESS\\P3700299" Date: Wed, 4 Jan 2017 16:21:32 +0200 Subject: [PATCH 0773/1491] added Sanity Group to the tests --- e2e-test/java/org/alfresco/rest/auth/AuthTests.java | 2 +- .../rest/networks/RestGetNetworkForPersonSanityTests.java | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/auth/AuthTests.java b/e2e-test/java/org/alfresco/rest/auth/AuthTests.java index 1cc5b8eac..23a8c0bff 100644 --- a/e2e-test/java/org/alfresco/rest/auth/AuthTests.java +++ b/e2e-test/java/org/alfresco/rest/auth/AuthTests.java @@ -13,7 +13,7 @@ import org.testng.annotations.Test; public class AuthTests extends RestTest { @TestRail(section = { TestGroup.REST_API }, executionType = ExecutionType.SANITY, description = "Verify TICKET is returned on admin user") - @Test(groups = { TestGroup.REST_API }) + @Test(groups = { TestGroup.REST_API, TestGroup.SANITY }) public void adminShouldGetTicketBody() throws JsonToModelConversionException, Exception { RestTicketBodyModel ticketBody = new RestTicketBodyModel(); diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java index b7ffab041..697954a56 100644 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java @@ -29,7 +29,7 @@ public class RestGetNetworkForPersonSanityTests extends RestTest @Bug(id = "MNT-16904") @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify non existing user gets another exisiting network with Rest API and checks the forbidden status") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.COMMENTS }) + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.COMMENTS, TestGroup.SANITY }) public void nonExistingTenantUserIsNotAuthorizedToRequest() throws Exception { UserModel tenantUser = new UserModel("nonexisting", "password"); @@ -41,7 +41,7 @@ public class RestGetNetworkForPersonSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify tenant admin user gets specific network with Rest API and response is not empty") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.COMMENTS }) + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.COMMENTS,TestGroup.SANITY }) public void adminTenantChecksIfNetworkIsPresent() throws Exception { restClient.authenticateUser(adminTenantUser); @@ -51,7 +51,7 @@ public class RestGetNetworkForPersonSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify tenant user is not authorized to check network of admin user with Rest API and checks the forbidden status") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.COMMENTS }) + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.COMMENTS, TestGroup.SANITY }) public void tenantUserIsNotAuthorizedToCheckNetworkOfAdminUser() throws Exception { restClient.authenticateUser(tenantUser); @@ -61,7 +61,7 @@ public class RestGetNetworkForPersonSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify admin tenant user is not authorized to check network of another user with Rest API and checks the forbidden status") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.COMMENTS }) + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.COMMENTS, TestGroup.SANITY }) public void adminTenantUserIsNotAuthorizedToCheckNetworkOfAnotherUser() throws Exception { UserModel secondAdminTenantUser = UserModel.getAdminTenantUser(); From afaf7faf43d091aaf5082818322bcde715ea8e98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alecsandru=20Prun=C4=83?= Date: Wed, 4 Jan 2017 16:53:07 +0200 Subject: [PATCH 0774/1491] Renamed GetPeoplePreferencesCoreTests to GetPeoplePreferenceCoreTests --- ...ferencesCoreTests.java => GetPeoplePreferenceCoreTests.java} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename e2e-test/java/org/alfresco/rest/people/{GetPeoplePreferencesCoreTests.java => GetPeoplePreferenceCoreTests.java} (98%) diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesCoreTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceCoreTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesCoreTests.java rename to e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceCoreTests.java index 767de94b2..759229be7 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceCoreTests.java @@ -11,7 +11,7 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -public class GetPeoplePreferencesCoreTests extends RestTest +public class GetPeoplePreferenceCoreTests extends RestTest { UserModel userModel; SiteModel siteModel; From 81f906779ee0f980573bf10b1c3a6bc7f3d4fa35 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Wed, 4 Jan 2017 20:39:44 +0200 Subject: [PATCH 0775/1491] test: GetSitesSanityTests increase maxItems to 10000 --- .../org/alfresco/rest/sites/GetSitesSanityTests.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java index e97169646..f4b6266fb 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java @@ -36,7 +36,7 @@ public class GetSitesSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role gets sites information and gets status code OK (200)") public void managerIsAbleToRetrieveSites() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withParams("maxItems=1000") + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withParams("maxItems=10000") .withCoreAPI().getSites() .assertThat().entriesListIsNotEmpty() .assertThat().entriesListContains("id", siteModel.getId()) @@ -49,7 +49,7 @@ public class GetSitesSanityTests extends RestTest description = "Verify user with Collaborator role gets sites information and gets status code OK (200)") public void collaboratorIsAbleToRetrieveSites() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withParams("maxItems=1000") + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withParams("maxItems=10000") .withCoreAPI().getSites().assertThat().entriesListIsNotEmpty() .assertThat().entriesListContains("id", siteModel.getId()) .and().paginationExist(); @@ -63,7 +63,7 @@ public class GetSitesSanityTests extends RestTest public void contributorIsAbleToRetrieveSites() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withParams("maxItems=1000") + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withParams("maxItems=10000") .withCoreAPI().getSites() .assertThat().entriesListIsNotEmpty() .assertThat().entriesListContains("id", siteModel.getId()) @@ -77,7 +77,7 @@ public class GetSitesSanityTests extends RestTest public void consumerIsAbleToRetrieveSites() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withParams("maxItems=1000") + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withParams("maxItems=10000") .withCoreAPI().getSites() .assertThat().entriesListIsNotEmpty() .assertThat().entriesListContains("id", siteModel.getId()) @@ -90,7 +90,7 @@ public class GetSitesSanityTests extends RestTest description = "Verify user with Admin user gets sites information and gets status code OK (200)") public void adminUserIsAbleToRetrieveSites() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(adminUserModel).withParams("maxItems=1000") + restClient.authenticateUser(adminUserModel).withParams("maxItems=10000") .withCoreAPI().getSites() .assertThat().entriesListIsNotEmpty() .assertThat().entriesListContains("id", siteModel.getId()) @@ -108,7 +108,7 @@ public class GetSitesSanityTests extends RestTest userModel = dataUser.createRandomTestUser(); userModel.setPassword("user wrong password"); dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); - restClient.authenticateUser(userModel).withParams("maxItems=1000") + restClient.authenticateUser(userModel).withParams("maxItems=1") .withCoreAPI().getSites(); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); } From 83b40da3cb5c9c33e8023bdad31956fc0330d1af Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Thu, 5 Jan 2017 10:46:26 +0200 Subject: [PATCH 0776/1491] TAS-2608 New full test for getPerson using -me- --- .../rest/people/GetPeopleFullTests.java | 48 +++++++++++++++++++ .../rest/people/GetPeopleSanityTests.java | 1 - 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 e2e-test/java/org/alfresco/rest/people/GetPeopleFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleFullTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleFullTests.java new file mode 100644 index 000000000..3f331268d --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleFullTests.java @@ -0,0 +1,48 @@ +package org.alfresco.rest.people; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestPersonModel; +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.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class GetPeopleFullTests extends RestTest +{ + UserModel userModel; + SiteModel siteModel; + UserModel searchedUser; + UserModel adminUser; + private RestPersonModel personModel; + private String domain = "@tas-automation.org"; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + searchedUser = dataUser.createRandomTestUser(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user gets person using '-me-' instead of personId with Rest API and response is successful") + public void checkGetPersonIsSuccessfulForMe() throws Exception + { + UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); + + personModel = restClient.authenticateUser(managerUser).withCoreAPI().usingMe().getPerson(); + restClient.assertStatusCodeIs(HttpStatus.OK); + personModel.assertThat().field("id").is(managerUser.getUsername()) + .and().field("firstName").is(managerUser.getUsername() + " FirstName") + .and().field("email").is(managerUser.getUsername() + domain) + .and().field("emailNotificationsEnabled").is("true"); + + } +} diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleSanityTests.java index 2c0479261..acbc56c40 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleSanityTests.java @@ -69,7 +69,6 @@ public class GetPeopleSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); personModel.assertThat().field("id").is(searchedUser.getUsername()).assertThat().field("firstName").is(searchedUser.getUsername() + " FirstName").and() .field("email").is(searchedUser.getUsername() + domain).and().field("emailNotificationsEnabled").is("true"); - ; } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) From 4334ee217197eed3890622bbbb1ea1f5daa1c6ab Mon Sep 17 00:00:00 2001 From: Andrei Rusu Date: Thu, 5 Jan 2017 11:40:44 +0200 Subject: [PATCH 0777/1491] added tests for postComments updated unauthenticatedUserIsNotAbleToAddComments test from AddCommentsSanityTests --- .../rest/comments/AddCommentsCoreTests.java | 156 ++++++++++++++++++ .../rest/comments/AddCommentsSanityTests.java | 3 +- 2 files changed, 157 insertions(+), 2 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/comments/AddCommentsCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentsCoreTests.java b/e2e-test/java/org/alfresco/rest/comments/AddCommentsCoreTests.java new file mode 100644 index 000000000..f86866213 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/comments/AddCommentsCoreTests.java @@ -0,0 +1,156 @@ +package org.alfresco.rest.comments; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.JsonBodyGenerator; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.model.RestCommentModel; +import org.alfresco.rest.model.RestCommentModelsCollection; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.apache.commons.lang.RandomStringUtils; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Created by Andrei Rusu + */ +public class AddCommentsCoreTests extends RestTest +{ + private UserModel adminUserModel; + private FileModel document; + private SiteModel siteModel; + private DataUser.ListUserWithRoles usersWithRoles; + private String comment = "This is a new comment"; + private String comment2 = "This is the second comment"; + private RestCommentModelsCollection comments; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + restClient.authenticateUser(adminUserModel); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Using Manager user verify that you can provide a large string for one comment") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + public void addLongCommentWithManagerAndCheckThatCommentIsReturned() throws Exception + { + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + String longString = RandomStringUtils.randomAlphanumeric(10000); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(document).addComment(longString); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", longString); + comments.assertThat().paginationField("totalItems").is("1"); + comments.assertThat().paginationField("count").is("1"); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Using Contributor user verify that you can provide a short string for one comment") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + public void addShortCommentWithContributorAndCheckThatCommentIsReturned() throws Exception + { + document = dataContent.usingSite(siteModel).usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).createContent(DocumentType.TEXT_PLAIN); + String shortString = RandomStringUtils.randomAlphanumeric(2); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) + .withCoreAPI().usingResource(document).addComment(shortString); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", shortString); + comments.assertThat().paginationField("totalItems").is("1"); + comments.assertThat().paginationField("count").is("1"); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Using Collaborator user verify that you can provide a string with special characters for one comment") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + public void addCommentWithSpecialCharsWithCollaboratorCheckCommentIsReturned() throws Exception + { + document = dataContent.usingSite(siteModel).usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).createContent(DocumentType.TEXT_PLAIN); + String specialCharsString = "!@#$%^&*()_+♂µΓyádo«√<╡┌6£"; + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingResource(document).addComment(specialCharsString); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", specialCharsString); + comments.assertThat().paginationField("totalItems").is("1"); + comments.assertThat().paginationField("count").is("1"); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Using Manager user verify that you can not provide an empty string for one comment") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + public void addEmptyStringCommentWithManagerCheckCommentIsReturned() throws Exception + { + document = dataContent.usingSite(siteModel).usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).createContent(DocumentType.TEXT_PLAIN); + String emptyString = ""; + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(document).addComment(emptyString); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(RestErrorModel.NON_NULL_COMMENT); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Using Collaborator user verify that you can provide several comments in one request") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + public void addSeveralCommentsWithCollaboratorCheckCommentsAreReturned() throws Exception + { + document = dataContent.usingSite(siteModel).usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).createContent(DocumentType.TEXT_PLAIN); + String charString = RandomStringUtils.randomAlphanumeric(10); + String charString1 = RandomStringUtils.randomAlphanumeric(10); + String charString2 = RandomStringUtils.randomAlphanumeric(10); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingResource(document).addComments(comment, comment2, charString, charString1, charString2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", comment); + comments.assertThat().paginationField("totalItems").is("5"); + comments.assertThat().paginationField("count").is("5"); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Provide invalid request body parameter and check default error model schema") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + public void invalidRequestBodyParamenerCheckErrorModelSchema() throws Exception + { + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(adminUserModel).withCoreAPI(); + String postBody = JsonBodyGenerator.keyValueJson("content2", comment); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, postBody, "nodes/{nodeId}/comments", document.getNodeRef()); + restClient.processModel(RestCommentModel.class, request); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + restClient.assertLastError().getErrorKey().contains("Unrecognized field \"content2\""); + restClient.assertLastError().containsSummary("Unrecognized field \"content2\""); + restClient.assertLastError().getDescriptionURL().contains("https://api-explorer.alfresco.com"); + restClient.assertLastError().getStackTrace().contains("For security reasons the stack trace is no longer displayed, but the property is kept for previous versions"); + } +} diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java index da6615e43..cc6838009 100644 --- a/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java @@ -115,10 +115,9 @@ public class AddCommentsSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user gets status code 401 on post multiple comments call") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) - @Bug(id="MNT-16904") public void unauthenticatedUserIsNotAbleToAddComments() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(new UserModel("random user", "random password")) + restClient.noAuthentication() .withCoreAPI().usingResource(document).addComments(comment1, comment2); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } From 44ae9e0bd882c2c8039bb51748f8e2efba9bbd86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alecsandru=20Prun=C4=83?= Date: Thu, 5 Jan 2017 15:24:24 +0200 Subject: [PATCH 0778/1491] bug: fix getProcessItemsAsAdminReturnsAnything test --- .../rest/workflow/processes/GetProcessItemsCoreTests.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsCoreTests.java index cb3c2a870..eb34615df 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsCoreTests.java @@ -37,8 +37,10 @@ public class GetProcessItemsCoreTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) public void getProcessItemsAsAdminReturnsAnything() throws Exception { - processModel = restClient.authenticateUser(adminUser).withParams("maxItems=2").withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems().assertThat().entriesListIsNotEmpty(); + processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); + + restClient.authenticateUser(adminUser).withWorkflowAPI().usingProcess(processModel).getProcessItems().assertThat().entriesListIsNotEmpty(); restClient.assertStatusCodeIs(HttpStatus.OK); } From 8276ec0512fcdadb62bada9b493737832571b025 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Thu, 5 Jan 2017 15:39:25 +0200 Subject: [PATCH 0779/1491] test: add tests for createNode (file/folder) using JSON and multipart form data (TAS-2320) --- .../rest/nodes/NodesChildrenTests.java | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/nodes/NodesChildrenTests.java diff --git a/e2e-test/java/org/alfresco/rest/nodes/NodesChildrenTests.java b/e2e-test/java/org/alfresco/rest/nodes/NodesChildrenTests.java new file mode 100644 index 000000000..bd46bfe2c --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/nodes/NodesChildrenTests.java @@ -0,0 +1,58 @@ +package org.alfresco.rest.nodes; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestNodeBodyModel; +import org.alfresco.rest.model.RestNodeModel; +import org.alfresco.utility.Utility; +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/children + */ +public class NodesChildrenTests extends RestTest +{ + @TestRail(section = { TestGroup.REST_API,TestGroup.NODES }, executionType = ExecutionType.SANITY, + description = "Verify new folder node is created as children on -my- posting as JSON content type") + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY}) + public void createNewFolderNodeViaJason() throws Exception + { + restClient.authenticateUser(dataContent.getAdminUser()); + + RestNodeBodyModel node = new RestNodeBodyModel(); + node.setName("My Folder"); + node.setNodeType("cm:folder"); + + RestNodeModel newNode = restClient.withParams("autoRename=true").withCoreAPI().usingNode(ContentModel.my()).createNode(node); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + newNode.assertThat().field("aspectNames").contains("cm:auditable") + .assertThat().field("isFolder").is(true) + .assertThat().field("isFile").is(false) + .assertThat().field("name").contains(node.getName()); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NODES }, executionType = ExecutionType.SANITY, + description = "Verify new folder node is created as children on -my- posting as MultiPart content type") + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY}) + public void createNewFolderNodeWithMultiPartForms() throws Exception + { + //configuring multipart form + restClient.authenticateUser(dataContent.getAdminUser()) + .configureRequestSpec() + .addMultiPart("filedata", Utility.getResourceTestDataFile("restapi-resource")) + .addFormParam("renditions", "doclib") + .addFormParam("autoRename", true); + + RestNodeModel newNode = restClient.withCoreAPI().usingNode(ContentModel.my()).createNode(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + newNode.assertThat().field("aspectNames").contains("cm:auditable") + .assertThat().field("isFolder").is(false) + .assertThat().field("isFile").is(true) + .assertThat().field("name").contains("restapi-resource"); + } +} From 5fb7537a453cf821d8af5fcc1e7b4c2c8d9b434c Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Thu, 5 Jan 2017 15:40:16 +0200 Subject: [PATCH 0780/1491] core: update RestAuthAPI to use configureRequestSpec builder --- e2e-test/java/org/alfresco/rest/auth/AuthTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/auth/AuthTests.java b/e2e-test/java/org/alfresco/rest/auth/AuthTests.java index 23a8c0bff..ac7ab3a86 100644 --- a/e2e-test/java/org/alfresco/rest/auth/AuthTests.java +++ b/e2e-test/java/org/alfresco/rest/auth/AuthTests.java @@ -20,7 +20,7 @@ public class AuthTests extends RestTest ticketBody.setUserId("admin"); ticketBody.setPassword("admin"); - RestTicketModel ticketReturned = restClient.withAuthAPI().createTicket(ticketBody); + RestTicketModel ticketReturned = restClient.authenticateUser(dataContent.getAdminUser()).withAuthAPI().createTicket(ticketBody); restClient.assertStatusCodeIs(HttpStatus.CREATED); ticketReturned.assertThat().field("id").contains("TICKET_"); From 465747bdf6b42f3f02596dc444d5c6bc4cd7409d Mon Sep 17 00:00:00 2001 From: "NESS\\P3700299" Date: Thu, 5 Jan 2017 18:00:15 +0200 Subject: [PATCH 0781/1491] fixed the groups for rest-api tests --- .../org/alfresco/rest/demo/RestDemoTests.java | 8 ++++---- .../alfresco/rest/demo/SampleCommentsTests.java | 8 ++++---- .../alfresco/rest/demo/SamplePeopleTests.java | 4 ++-- .../org/alfresco/rest/demo/SampleSitesTests.java | 16 ++++++++-------- .../rest/demo/workshop/RestApiDemoTests.java | 5 +++-- .../rest/demo/workshop/RestApiWorkshopTests.java | 4 ++-- .../workflow/processes/GetProcessCoreTests.java | 8 ++++---- .../rest/workflow/tasks/GetTaskCoreTests.java | 2 +- .../rest/workflow/tasks/GetTasksCoreTests.java | 2 +- 9 files changed, 29 insertions(+), 28 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/demo/RestDemoTests.java b/e2e-test/java/org/alfresco/rest/demo/RestDemoTests.java index e8b59de3d..9bcbcf02d 100644 --- a/e2e-test/java/org/alfresco/rest/demo/RestDemoTests.java +++ b/e2e-test/java/org/alfresco/rest/demo/RestDemoTests.java @@ -15,7 +15,7 @@ import org.springframework.social.alfresco.api.entities.Site.Visibility; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { "demo" }) + public class RestDemoTests extends RestTest { private UserModel userModel; @@ -38,7 +38,7 @@ public class RestDemoTests extends RestTest * @throws JsonToModelConversionException * @throws Exception */ - @Test + @Test(groups = { "demo" }) public void adminRetrievesCorrectSiteDetails() throws JsonToModelConversionException, Exception { restClient.withCoreAPI().getSites().assertThat() @@ -58,7 +58,7 @@ public class RestDemoTests extends RestTest * Update existing comment using PUT call, check that comment content is updated
* @throws Exception */ - @Test + @Test(groups = { "demo" }) public void adminCanPostAndUpdateComments() throws Exception { FileModel fileModel = dataContent.usingUser(userModel) @@ -80,7 +80,7 @@ public class RestDemoTests extends RestTest * @throws DataPreparationException * @throws JsonToModelConversionException */ - @Test + @Test(groups = { "demo" }) public void adminCanAddAndUpdateSiteMemberDetails() throws Exception { UserModel testUser = dataUser.createRandomTestUser("testUser"); diff --git a/e2e-test/java/org/alfresco/rest/demo/SampleCommentsTests.java b/e2e-test/java/org/alfresco/rest/demo/SampleCommentsTests.java index 5481ca564..1151d4c2e 100644 --- a/e2e-test/java/org/alfresco/rest/demo/SampleCommentsTests.java +++ b/e2e-test/java/org/alfresco/rest/demo/SampleCommentsTests.java @@ -12,7 +12,7 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { "demo" }) + public class SampleCommentsTests extends RestTest { private UserModel userModel; @@ -30,21 +30,21 @@ public class SampleCommentsTests extends RestTest document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); } - @Test + @Test(groups = { "demo" }) public void admiShouldAddComment() throws JsonToModelConversionException, Exception { restClient.withCoreAPI().usingResource(document).addComment("This is a new comment"); restClient.assertStatusCodeIs(HttpStatus.CREATED); } - @Test + @Test(groups = { "demo" }) public void admiShouldRetrieveComments() throws Exception { restClient.withCoreAPI().usingResource(document).getNodeComments(); restClient.assertStatusCodeIs(HttpStatus.OK); } - @Test + @Test(groups = { "demo" }) public void adminShouldUpdateComment() throws JsonToModelConversionException, Exception { RestCommentModel commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment"); diff --git a/e2e-test/java/org/alfresco/rest/demo/SamplePeopleTests.java b/e2e-test/java/org/alfresco/rest/demo/SamplePeopleTests.java index aa5f91886..6c0a2ff18 100644 --- a/e2e-test/java/org/alfresco/rest/demo/SamplePeopleTests.java +++ b/e2e-test/java/org/alfresco/rest/demo/SamplePeopleTests.java @@ -8,7 +8,7 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { "demo" }) + public class SamplePeopleTests extends RestTest { private UserModel userModel; @@ -22,7 +22,7 @@ public class SamplePeopleTests extends RestTest restClient.authenticateUser(adminUser); } - @Test + @Test(groups = { "demo" }) public void adminShouldRetrievePerson() throws Exception { restClient.withCoreAPI().usingUser(userModel).getPerson().assertThat().field("id").isNotEmpty(); diff --git a/e2e-test/java/org/alfresco/rest/demo/SampleSitesTests.java b/e2e-test/java/org/alfresco/rest/demo/SampleSitesTests.java index 6b6beae46..f5c59e8a8 100644 --- a/e2e-test/java/org/alfresco/rest/demo/SampleSitesTests.java +++ b/e2e-test/java/org/alfresco/rest/demo/SampleSitesTests.java @@ -10,7 +10,7 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = { "demo" }) + public class SampleSitesTests extends RestTest { private UserModel userModel; @@ -24,34 +24,34 @@ public class SampleSitesTests extends RestTest siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); } - @Test + @Test(groups = { "demo" }) public void adminShouldGetSiteDetails() throws JsonToModelConversionException, Exception { restClient.withCoreAPI().usingSite(siteModel).getSite() .assertThat().field("id").isNotNull(); } - @Test + @Test(groups = { "demo" }) public void adminShouldGetSites() throws JsonToModelConversionException, Exception { restClient.withCoreAPI().usingSite(siteModel).getSite(); restClient.assertStatusCodeIs(HttpStatus.OK); } - @Test + @Test(groups = { "demo" }) public void adminShouldAccessSites() throws JsonToModelConversionException, Exception { restClient.withCoreAPI().getSites().assertThat().entriesListIsNotEmpty(); restClient.assertStatusCodeIs(HttpStatus.OK); } - @Test + @Test(groups = { "demo" }) public void adminShouldAccessResponsePagination() throws JsonToModelConversionException, Exception { restClient.withCoreAPI().getSites().assertThat().paginationExist(); } - @Test + @Test(groups = { "demo" }) public void adminShouldAddNewSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception { UserModel testUser = dataUser.createRandomTestUser("testUser"); @@ -60,13 +60,13 @@ public class SampleSitesTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.CREATED); } - @Test + @Test(groups = { "demo" }) public void adminShouldGetSiteFromSitesList() throws JsonToModelConversionException, Exception { restClient.withCoreAPI().getSites().assertThat().entriesListContains("id", siteModel.getId()); } - @Test + @Test(groups = { "demo" }) public void adminShouldAccessSiteDetails() throws JsonToModelConversionException, Exception { restClient.withCoreAPI().usingSite(siteModel).getSite() diff --git a/e2e-test/java/org/alfresco/rest/demo/workshop/RestApiDemoTests.java b/e2e-test/java/org/alfresco/rest/demo/workshop/RestApiDemoTests.java index 1b07b14cb..7492d8023 100644 --- a/e2e-test/java/org/alfresco/rest/demo/workshop/RestApiDemoTests.java +++ b/e2e-test/java/org/alfresco/rest/demo/workshop/RestApiDemoTests.java @@ -17,7 +17,7 @@ public class RestApiDemoTests extends RestTest * 5. call rest api call " GET sites/{siteId}/members" with first user authenticated * Expected: the response contains the user added as a member to the site */ - @Test + @Test(groups = { "demo" }) public void verifyGetSiteMembersRestApiCall() throws Exception { UserModel user = dataUser.createRandomTestUser(); @@ -38,7 +38,8 @@ public class RestApiDemoTests extends RestTest * 5. call rest api call " GET sites/{siteId}/members/{personId}" with first user authenticated * Expected: the response contains the user added as a member to the site */ - @Test + + @Test(groups = { "demo" }) public void verifyGetASiteMemberApiCall() throws Exception { UserModel user = dataUser.createRandomTestUser(); diff --git a/e2e-test/java/org/alfresco/rest/demo/workshop/RestApiWorkshopTests.java b/e2e-test/java/org/alfresco/rest/demo/workshop/RestApiWorkshopTests.java index f863bddf2..88484bf66 100644 --- a/e2e-test/java/org/alfresco/rest/demo/workshop/RestApiWorkshopTests.java +++ b/e2e-test/java/org/alfresco/rest/demo/workshop/RestApiWorkshopTests.java @@ -10,7 +10,7 @@ import org.testng.annotations.Test; */ public class RestApiWorkshopTests extends RestTest { - @Test + @Test(groups = { "demo" }) public void verifyGetSitesRestApiCall() throws Exception { // creating a random user in repository @@ -23,7 +23,7 @@ public class RestApiWorkshopTests extends RestTest } - @Test + @Test(groups = { "demo" }) public void verifyGetASiteRestApiCall() throws Exception { // creating a random user in repository diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessCoreTests.java index 1a35cd25b..d0ffd695d 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessCoreTests.java @@ -28,7 +28,7 @@ public class GetProcessCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify that using invalid process ID returns status code 404") - @Test(groups = { TestGroup.WORKFLOW, TestGroup.CORE}) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.CORE}) public void invalidProcessIdTest() throws Exception { RestProcessModel newProcess = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.High); @@ -41,7 +41,7 @@ public class GetProcessCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES, TestGroup.NETWORKS}, executionType = ExecutionType.REGRESSION, description = "Verify that tenant user cannot get process from another network") - @Test(groups = { TestGroup.WORKFLOW, TestGroup.CORE, TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.CORE, TestGroup.NETWORKS }) @Bug(id = "MNT-17238") public void tenantUserCannotGetProcessFromAnotherNetwork() throws Exception { @@ -62,7 +62,7 @@ public class GetProcessCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify that tenant user can get process from the same network") - @Test(groups = { TestGroup.WORKFLOW, TestGroup.CORE, TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.CORE, TestGroup.NETWORKS }) public void tenantUserCanGetProcessFromTheSameNetwork() throws Exception { UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); @@ -79,7 +79,7 @@ public class GetProcessCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES, TestGroup.NETWORKS}, executionType = ExecutionType.REGRESSION, description = "Verify that non network user cannot get process from a network") - @Test(groups = { TestGroup.WORKFLOW, TestGroup.CORE, TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.CORE, TestGroup.NETWORKS }) @Bug(id = "MNT-17238") public void nonNetworkUserCannotAccessNetworkprocess() throws Exception { diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCoreTests.java index ccbfeee1f..dd2b8906e 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCoreTests.java @@ -67,7 +67,7 @@ public class GetTaskCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify that in a network only tasks inside network are returned.") - @Test(groups = { TestGroup.NETWORKS }) + @Test(groups = {TestGroup.NETWORKS,TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) public void tasksInsideNetworkReturned() throws Exception { restClient.authenticateUser(adminUser); diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksCoreTests.java index 1f6aeead9..a11d6ed21 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksCoreTests.java @@ -102,7 +102,7 @@ public class GetTasksCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check that for network enabled only that network tasks are returned.") - @Test(groups = { TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.CORE }) public void networkEnabledTasksReturned() throws Exception { restClient.authenticateUser(adminUser); From ce08b286562b4abd3690b3391526a2292afd8411 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Fri, 6 Jan 2017 11:28:14 +0200 Subject: [PATCH 0782/1491] enable TestRail listener fix the info log messages related to Could not instantiate TestExecutionListener [org.springframework.test.context.web.ServletTestExecutionListener] --- e2e-test/java/org/alfresco/rest/auth/AuthTests.java | 2 +- .../deployments/GetDeploymentsCoreTests.java | 10 +++++----- e2e-test/resources/default.properties | 12 +++++++----- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/auth/AuthTests.java b/e2e-test/java/org/alfresco/rest/auth/AuthTests.java index ac7ab3a86..03a8a456a 100644 --- a/e2e-test/java/org/alfresco/rest/auth/AuthTests.java +++ b/e2e-test/java/org/alfresco/rest/auth/AuthTests.java @@ -12,7 +12,7 @@ import org.testng.annotations.Test; public class AuthTests extends RestTest { - @TestRail(section = { TestGroup.REST_API }, executionType = ExecutionType.SANITY, description = "Verify TICKET is returned on admin user") + @TestRail(section = { TestGroup.REST_API, TestGroup.AUTH }, executionType = ExecutionType.SANITY, description = "Verify TICKET is returned on admin user") @Test(groups = { TestGroup.REST_API, TestGroup.SANITY }) public void adminShouldGetTicketBody() throws JsonToModelConversionException, Exception { diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsCoreTests.java index 929709156..d2542f4b9 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsCoreTests.java @@ -1,5 +1,7 @@ package org.alfresco.rest.workflow.deployments; +import java.util.List; + import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestDeploymentModel; import org.alfresco.rest.model.RestDeploymentModelsCollection; @@ -13,8 +15,6 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import java.util.List; - /** * Created by Claudia Agache on 12/7/2016. */ @@ -29,7 +29,7 @@ public class GetDeploymentsCoreTests extends RestTest adminUser = dataUser.getAdminUser(); } - @TestRail(section = { TestGroup.REST_API, TestGroup.DEPLOYMENTS }, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify non admin user is not able to get non-network deployments using REST API and status code is Forbidden") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.CORE}) @@ -41,7 +41,7 @@ public class GetDeploymentsCoreTests extends RestTest .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } - @TestRail(section = { TestGroup.REST_API, TestGroup.DEPLOYMENTS }, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify non admin user is not able to get network deployments using REST API and status code is Forbidden") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.CORE, TestGroup.NETWORKS}) @@ -58,7 +58,7 @@ public class GetDeploymentsCoreTests extends RestTest } @Bug(id = "MNT-16996") - @TestRail(section = { TestGroup.REST_API, TestGroup.DEPLOYMENTS }, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify get deployments returns an empty list after deleting all network deployments.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.CORE, TestGroup.NETWORKS}) diff --git a/e2e-test/resources/default.properties b/e2e-test/resources/default.properties index 2e312138b..c5f9b2139 100644 --- a/e2e-test/resources/default.properties +++ b/e2e-test/resources/default.properties @@ -14,20 +14,22 @@ admin.password=admin # Example of configuration: # ------------------------------------------------------ # testManagement.endPoint=https://alfresco.testrail.com/ +# if testManagement.enabled=true we enabled TestRailExecutorListener (if used in your suite xml file) +# testManagement.updateTestExecutionResultsOnly=true (this will just update the results of a test: no step will be updated - good for performance) # testManagement.username= # testManagement.apiKey= # testManagement.project= -# testManagement.justUploadTest=false -# if testManagement.justUploadTest=false we only update test cases in test rail +# testManagement.suiteId=23 (the id of the Master suite) # ------------------------------------------------------ +testManagement.enabled=true +testManagement.updateTestExecutionResultsOnly=true testManagement.endPoint=https://alfresco.testrail.com/ testManagement.username=tas.alfresco@gmail.com testManagement.apiKey=EYpY7.fV0AoMGWbmyuVC-k5u.nzwHy6a.QWzJq8.S -testManagement.project=1 +testManagement.project=7 testManagement.testRun=Automation -testManagement.justUploadTest=false -testManagement.suiteId=1 +testManagement.suiteId=12 # The location of the reports path reports.path=./target/reports From b35da1e26f4da6d8eed61cb3904bbea984ff36bd Mon Sep 17 00:00:00 2001 From: "NESS\\P3700299" Date: Fri, 6 Jan 2017 19:24:53 +0200 Subject: [PATCH 0783/1491] fixed CORE tests for getFavorites and implemented new tests for FULL phase --- .../rest/favorites/GetFavoriteCoreTests.java | 106 ++++++++++++ .../rest/favorites/GetFavoriteFullTests.java | 67 ++++++++ .../favorites/GetFavoriteSanityTests.java | 153 +++++++++++++++--- 3 files changed, 305 insertions(+), 21 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/favorites/GetFavoriteCoreTests.java create mode 100644 e2e-test/java/org/alfresco/rest/favorites/GetFavoriteFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteCoreTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteCoreTests.java new file mode 100644 index 000000000..c3b3e0668 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteCoreTests.java @@ -0,0 +1,106 @@ +package org.alfresco.rest.favorites; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestPersonFavoritesModel; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class GetFavoriteCoreTests extends RestTest { + private UserModel adminUserModel; + private SiteModel siteModel; + private FolderModel folderModel; + private FileModel fileModel; + private ListUserWithRoles usersWithRoles; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception { + adminUserModel = dataUser.getAdminUser(); + restClient.authenticateUser(adminUserModel); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + + folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); + fileModel = dataContent.usingUser(adminUserModel).usingResource(folderModel) + .createContent(DocumentType.TEXT_PLAIN); + + siteModel.setGuid( + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(siteModel).getSite().getGuid()); + + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, + UserRole.SiteConsumer, UserRole.SiteContributor); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify get favorite site when person id does't exist") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) + public void getFavoriteSiteWhenPersonIdNotExist() throws JsonToModelConversionException, Exception { + + restClient.withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); + UserModel someUser = new UserModel("invalidUser", DataUser.PASSWORD); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(someUser).getFavorite(siteModel.getGuid()); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, someUser.getUsername())) + .statusCodeIs(HttpStatus.NOT_FOUND) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY); + } + + + @TestRail(section = { TestGroup.REST_API, + TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify get favorite site when favorite id does't exist") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) + public void getFavoriteSiteWhenFavoriteIdNotExist() throws JsonToModelConversionException, Exception { + + restClient.withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).getFavorite("invalidId"); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidId")) + .statusCodeIs(HttpStatus.NOT_FOUND) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify get favorite user doesn't have any favorite site, file or folder") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) + public void getFavoriteSiteForUserWithoutAnyFavorites() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + restClient.withCoreAPI().usingAuthUser().getFavorite(siteModel.getGuid()); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, usersWithRoles.getOneUserWithRole(UserRole.SiteManager).getUsername(), siteModel.getGuid())) + .statusCodeIs(HttpStatus.NOT_FOUND) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE) + .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify get favorite site for -me-") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) + public void getFavoriteSiteUsingMe() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + + RestPersonFavoritesModel favoriteSite = restClient.withCoreAPI().usingMe().getFavorite(siteModel.getGuid()); + restClient.assertStatusCodeIs(HttpStatus.OK); + favoriteSite.assertThat().field("targetGuid").equals(siteModel.getGuid()); + } +} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteFullTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteFullTests.java new file mode 100644 index 000000000..05323bb89 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteFullTests.java @@ -0,0 +1,67 @@ +package org.alfresco.rest.favorites; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestPersonFavoritesModel; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class GetFavoriteFullTests extends RestTest { + private UserModel adminUserModel, networkUserModel; + private SiteModel siteModel; + private FolderModel folderModel; + private FileModel fileModel; + private ListUserWithRoles usersWithRoles; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception { + + networkUserModel = dataUser.createRandomTestUser(); + adminUserModel = dataUser.getAdminUser(); + restClient.authenticateUser(adminUserModel); + + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + + folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); + fileModel = dataContent.usingUser(adminUserModel).usingResource(folderModel) + .createContent(DocumentType.TEXT_PLAIN); + + siteModel.setGuid( + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(siteModel).getSite().getGuid()); + + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, + UserRole.SiteConsumer, UserRole.SiteContributor); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify get favorite site when using invalid network id") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) + public void getFavoriteSiteWhenNetworkIdIsInvalid() throws JsonToModelConversionException, Exception + { + networkUserModel.setDomain("invalidNetwork"); + restClient.withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); + UserModel someUser = new UserModel("invalidUser", DataUser.PASSWORD); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(someUser).getFavorite(siteModel.getGuid()); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, someUser.getUsername())) + .statusCodeIs(HttpStatus.NOT_FOUND) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY); + } + +} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java index 8e686f969..688ce6ff5 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java @@ -4,6 +4,7 @@ import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestPersonFavoritesModel; import org.alfresco.rest.model.RestPersonFavoritesModelsCollection; import org.alfresco.rest.model.RestSiteModelsCollection; import org.alfresco.utility.constants.UserRole; @@ -27,8 +28,6 @@ public class GetFavoriteSanityTests extends RestTest private FolderModel folderModel; private FileModel fileModel; private ListUserWithRoles usersWithRoles; - private RestSiteModelsCollection restSiteModelsCollection; - private RestPersonFavoritesModelsCollection restPersonFavoritesModelsCollection; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception @@ -53,9 +52,9 @@ public class GetFavoriteSanityTests extends RestTest { restClient.withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); - restSiteModelsCollection = restClient.withCoreAPI().usingUser(adminUserModel).getFavoriteSites(); + RestPersonFavoritesModel favoriteSite = restClient.withCoreAPI().usingUser(adminUserModel).getFavorite(siteModel.getGuid()); restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModelsCollection.and().entriesListContains("guid",siteModel.getGuid()); + favoriteSite.assertThat().field("targetGuid").equals(siteModel.getGuid()); } @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, @@ -65,10 +64,9 @@ public class GetFavoriteSanityTests extends RestTest { restClient.withCoreAPI().usingUser(adminUserModel).addFolderToFavorites(folderModel); - restPersonFavoritesModelsCollection = restClient.withCoreAPI().usingUser(adminUserModel).getFavorites(); + RestPersonFavoritesModel favoriteFolder = restClient.withCoreAPI().usingUser(adminUserModel).getFavorite(folderModel.getNodeRef()); restClient.assertStatusCodeIs(HttpStatus.OK); - restPersonFavoritesModelsCollection.and().entriesListContains("targetGuid", folderModel.getNodeRef()); - + favoriteFolder.assertThat().field("targetGuid").equals(folderModel.getNodeRef()); } @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, @@ -78,50 +76,135 @@ public class GetFavoriteSanityTests extends RestTest { restClient.withCoreAPI().usingUser(adminUserModel).addFileToFavorites(fileModel); - restPersonFavoritesModelsCollection = restClient.withCoreAPI().usingUser(adminUserModel).getFavorites(); + RestPersonFavoritesModel favoriteFile = restClient.withCoreAPI().usingUser(adminUserModel).getFavorite(fileModel.getNodeRefWithoutVersion()); restClient.assertStatusCodeIs(HttpStatus.OK); - restPersonFavoritesModelsCollection.and().entriesListContains("targetGuid", fileModel.getNodeRefWithoutVersion()); + favoriteFile.assertThat().field("targetGuid").equals(fileModel.getNodeRef()); } @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Manager user gets favorite site with Rest API and status code is 200") @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - public void managerIsAbleToRetrieveFavorite() throws JsonToModelConversionException, Exception + public void managerIsAbleToRetrieveFavoriteSite() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - restSiteModelsCollection = restClient.withCoreAPI().usingAuthUser().getFavoriteSites(); + RestPersonFavoritesModel favSite = restClient.withCoreAPI().usingAuthUser().getFavorite(siteModel.getGuid()); restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModelsCollection.and().entriesListContains("guid",siteModel.getGuid()); + favSite.assertThat().field("targetGuid").equals(siteModel.getGuid()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, + description = "Verify Manager user gets favorite folder with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) + public void managerIsAbleToRetrieveFavoriteFolder() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(folderModel); + + RestPersonFavoritesModel favoriteFolder = restClient.withCoreAPI().usingAuthUser().getFavorite(folderModel.getNodeRef()); + restClient.assertStatusCodeIs(HttpStatus.OK); + favoriteFolder.assertThat().field("targetGuid").equals(folderModel.getNodeRef()); + + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, + description = "Verify Manager user gets favorite file with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) + public void managerIsAbleToRetrieveFavoriteFile() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + restClient.withCoreAPI().usingAuthUser().addFileToFavorites(fileModel); + + RestPersonFavoritesModel favoriteFile = restClient.withCoreAPI().usingAuthUser().getFavorite(fileModel.getNodeRefWithoutVersion()); + restClient.assertStatusCodeIs(HttpStatus.OK); + favoriteFile.assertThat().field("targetGuid").equals(fileModel.getNodeRef()); + } + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user gets favorite site with Rest API and status code is 200") @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - public void collaboratorIsAbleToRetrieveFavorites() throws JsonToModelConversionException, Exception + public void collaboratorIsAbleToRetrieveFavoriteSite() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - restSiteModelsCollection = restClient.withCoreAPI().usingAuthUser().getFavoriteSites(); + RestPersonFavoritesModel favSite = restClient.withCoreAPI().usingAuthUser().getFavorite(siteModel.getGuid()); restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModelsCollection.and().entriesListContains("guid",siteModel.getGuid()); + favSite.assertThat().field("targetGuid").equals(siteModel.getGuid()); } + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, + description = "Verify collaborator user gets favorite folder with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) + public void collaboratorIsAbleToRetrieveFavoriteFolder() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(folderModel); + + RestPersonFavoritesModel favoriteFolder = restClient.withCoreAPI().usingAuthUser().getFavorite(folderModel.getNodeRef()); + restClient.assertStatusCodeIs(HttpStatus.OK); + favoriteFolder.assertThat().field("targetGuid").equals(folderModel.getNodeRef()); + + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, + description = "Verify collaborator user gets favorite file with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) + public void collaboratorIsAbleToRetrieveFavoriteFile() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + restClient.withCoreAPI().usingAuthUser().addFileToFavorites(fileModel); + + RestPersonFavoritesModel favoriteFile = restClient.withCoreAPI().usingAuthUser().getFavorite(fileModel.getNodeRefWithoutVersion()); + restClient.assertStatusCodeIs(HttpStatus.OK); + favoriteFile.assertThat().field("targetGuid").equals(fileModel.getNodeRef()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Contributor user gets favorite site with Rest API and status code is 200") @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - public void contributorIsAbleToRetrieveFavorite() throws JsonToModelConversionException, Exception + public void contributorIsAbleToRetrieveFavoriteSite() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - restSiteModelsCollection = restClient.withCoreAPI().usingAuthUser().getFavoriteSites(); + RestPersonFavoritesModel favSite = restClient.withCoreAPI().usingAuthUser().getFavorite(siteModel.getGuid()); restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModelsCollection.and().entriesListContains("guid",siteModel.getGuid()); + favSite.assertThat().field("targetGuid").equals(siteModel.getGuid()); ; } + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, + description = "Verify contributor user gets favorite folder with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) + public void contributorIsAbleToRetrieveFavoriteFolder() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(folderModel); + + RestPersonFavoritesModel favoriteFolder = restClient.withCoreAPI().usingAuthUser().getFavorite(folderModel.getNodeRef()); + restClient.assertStatusCodeIs(HttpStatus.OK); + favoriteFolder.assertThat().field("targetGuid").equals(folderModel.getNodeRef()); + + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, + description = "Verify contributor user gets favorite file with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) + public void contributorIsAbleToRetrieveFavoriteFile() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + restClient.withCoreAPI().usingAuthUser().addFileToFavorites(fileModel); + + RestPersonFavoritesModel favoriteFile = restClient.withCoreAPI().usingAuthUser().getFavorite(fileModel.getNodeRefWithoutVersion()); + restClient.assertStatusCodeIs(HttpStatus.OK); + favoriteFile.assertThat().field("targetGuid").equals(fileModel.getNodeRef()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Consumer user gets favorite site with Rest API and status code is 200") @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) @@ -130,11 +213,38 @@ public class GetFavoriteSanityTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - restSiteModelsCollection = restClient.withCoreAPI().usingAuthUser().getFavoriteSites(); + RestPersonFavoritesModel favSite = restClient.withCoreAPI().usingAuthUser().getFavorite(siteModel.getGuid()); restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModelsCollection.and().entriesListContains("guid",siteModel.getGuid()); + favSite.assertThat().field("targetGuid").equals(siteModel.getGuid()); } + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, + description = "Verify consumer user gets favorite folder with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) + public void consumerIsAbleToRetrieveFavoriteFolder() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(folderModel); + + RestPersonFavoritesModel favoriteFolder = restClient.withCoreAPI().usingAuthUser().getFavorite(folderModel.getNodeRef()); + restClient.assertStatusCodeIs(HttpStatus.OK); + favoriteFolder.assertThat().field("targetGuid").equals(folderModel.getNodeRef()); + + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, + description = "Verify consumer user gets favorite file with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) + public void consumerIsAbleToRetrieveFavoriteFile() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + restClient.withCoreAPI().usingAuthUser().addFileToFavorites(fileModel); + + RestPersonFavoritesModel favoriteFile = restClient.withCoreAPI().usingAuthUser().getFavorite(fileModel.getNodeRefWithoutVersion()); + restClient.assertStatusCodeIs(HttpStatus.OK); + favoriteFile.assertThat().field("targetGuid").equals(fileModel.getNodeRef()); + } + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify user doesn't get favorite site of another user with Rest API and status code is 404") @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) @@ -181,7 +291,8 @@ public class GetFavoriteSanityTests extends RestTest UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); siteManager.setPassword("wrongPassword"); restClient.authenticateUser(siteManager).withCoreAPI() - .usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).getFavorite(siteModel.getGuid()); + .usingUser(siteManager).getFavorite(siteModel.getGuid()); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); } + } From 1ecb3ce9d2a1240908b8424c81b64dcaff9d795c Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Mon, 9 Jan 2017 11:29:04 +0200 Subject: [PATCH 0784/1491] added 2 methods for verify entries order and added one full test for getPeople --- .../rest/people/GetPeopleFullTests.java | 27 +++++++++++++++++++ .../workflow/tasks/GetTasksCoreTests.java | 7 +++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleFullTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleFullTests.java index 3f331268d..567f18584 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleFullTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleFullTests.java @@ -43,6 +43,33 @@ public class GetPeopleFullTests extends RestTest .and().field("firstName").is(managerUser.getUsername() + " FirstName") .and().field("email").is(managerUser.getUsername() + domain) .and().field("emailNotificationsEnabled").is("true"); + } + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @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"); + 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()); } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksCoreTests.java index a11d6ed21..c8136c971 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksCoreTests.java @@ -57,9 +57,12 @@ public class GetTasksCoreTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) public void orderByParameterApplied() throws Exception { - taskModels = restClient.authenticateUser(dataUser.getAdminUser()).withParams("orderBy=id").withWorkflowAPI().getTasks(); + + + taskModels = restClient.authenticateUser(dataUser.getAdminUser()).withParams("orderBy=id DESC").withWorkflowAPI().getTasks(); restClient.assertStatusCodeIs(HttpStatus.OK); - taskModels.assertThat().entriesListIsNotEmpty(); + taskModels.assertThat().entriesListIsNotEmpty(). + and().entriesListIsSortedAscBy("id"); List tasksList = taskModels.getEntries(); List taskIds = new ArrayList(); for(RestTaskModel task: tasksList) From f4e597a7e5c393c5f19b75098e68057d4e3227cd Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Mon, 9 Jan 2017 12:40:49 +0200 Subject: [PATCH 0785/1491] add server health section: show tenants --- e2e-test/resources/default.properties | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/e2e-test/resources/default.properties b/e2e-test/resources/default.properties index c5f9b2139..39bdb7894 100644 --- a/e2e-test/resources/default.properties +++ b/e2e-test/resources/default.properties @@ -60,3 +60,8 @@ jmx.useJolokiaAgent=true db.url = jdbc:mysql://${alfresco.server}:3306/alfresco db.username = alfresco db.password = alfresco + +# Server Health section +# in ServerHealth#isServerReachable() - could also be shown. +# enable this option to view if on server there are tenants or not +serverHealth.showTenants=true From 66138a417ec6b03117acb670f770702e70c1dc18 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Mon, 9 Jan 2017 12:48:16 +0200 Subject: [PATCH 0786/1491] TAS-2610 new full test --- .../rest/people/GetPeopleFullTests.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleFullTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleFullTests.java index 567f18584..8cdaada10 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleFullTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleFullTests.java @@ -1,13 +1,16 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestPersonModel; import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.RandomData; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; +import org.apache.commons.lang3.RandomStringUtils; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -72,4 +75,20 @@ public class GetPeopleFullTests extends RestTest .and().field("enabled").is(newUser.getEnabled()) .and().field("emailNotificationsEnabled").is(newUser.getEmailNotificationsEnabled()); } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user get a person with special chars in username with Rest API and response is not found") + public void userChecksIfPersonWithSpecilCharsInUsernameIsNotFound() throws Exception + { + UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); + + UserModel userSpecialChars = dataUser.usingAdmin().createUser(RandomStringUtils.randomAlphabetic(2) + "~!@#$%^&*()_+[]{}|\\;':\",./<>", "password"); + //setting the encoded text for username + userSpecialChars.setUsername(RandomStringUtils.randomAlphabetic(2) + "~!%40%23%24%25%5E%26*()_%2B%5B%5D%7B%7D%7C%5C%3B%27%3A%22%2C.%2F%3C%3E"); + + personModel = restClient.authenticateUser(managerUser).withCoreAPI().usingUser(userSpecialChars).getPerson(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, userSpecialChars.getUsername())); + } } From 10967424d941a872ebf426dca8b219458a57bac1 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Mon, 9 Jan 2017 13:35:34 +0200 Subject: [PATCH 0787/1491] disabled testMangement by default --- e2e-test/resources/default.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/resources/default.properties b/e2e-test/resources/default.properties index 39bdb7894..f5733caf1 100644 --- a/e2e-test/resources/default.properties +++ b/e2e-test/resources/default.properties @@ -22,7 +22,7 @@ admin.password=admin # testManagement.testRun= # testManagement.suiteId=23 (the id of the Master suite) # ------------------------------------------------------ -testManagement.enabled=true +testManagement.enabled=false testManagement.updateTestExecutionResultsOnly=true testManagement.endPoint=https://alfresco.testrail.com/ testManagement.username=tas.alfresco@gmail.com From 199604f81ed5dae2fac66fc8de228fdafaa7dc27 Mon Sep 17 00:00:00 2001 From: mionescu Date: Mon, 9 Jan 2017 15:50:17 +0200 Subject: [PATCH 0788/1491] test - updated tests from class: DeleteFavoriteSanityTests --- ...ts.java => DeleteFavoriteSanityTests.java} | 129 +++++++----------- 1 file changed, 53 insertions(+), 76 deletions(-) rename e2e-test/java/org/alfresco/rest/favorites/{DeleteFavoritesSanityTests.java => DeleteFavoriteSanityTests.java} (67%) diff --git a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteSanityTests.java similarity index 67% rename from e2e-test/java/org/alfresco/rest/favorites/DeleteFavoritesSanityTests.java rename to e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteSanityTests.java index 2503d7c7a..dc6e83ae2 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoritesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteSanityTests.java @@ -15,7 +15,7 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -public class DeleteFavoritesSanityTests extends RestTest +public class DeleteFavoriteSanityTests extends RestTest { private UserModel adminUserModel; private SiteModel siteModel; @@ -28,7 +28,7 @@ public class DeleteFavoritesSanityTests extends RestTest siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); siteModel.setGuid(restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(siteModel).getSite().getGuid()); - + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); } @@ -36,54 +36,58 @@ public class DeleteFavoritesSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Admin user deletes site from favorites with Rest API and status code is 204") @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - public void adminIsAbleToDeleteFavorites() throws JsonToModelConversionException, Exception + public void adminIsAbleToDeleteFavorite() throws JsonToModelConversionException, Exception { restClient.withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); restClient.withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel).assertStatusCodeIs(HttpStatus.NO_CONTENT); restClient.withCoreAPI().usingAuthUser().getFavorites().assertThat().entriesListDoesNotContain("targetGuid", siteModel.getGuid()); + } + + @Bug(id="MNT-16557") + @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, + description = "Verify user doesn't have permission to delete favorites of admin user with Rest API and status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) + public void userIsNotAbleToDeleteFavoriteOfAdminUser() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + .withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel) + .assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError() + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, + description = "Verify manager user gets status code 401 if authentication call fails") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) + public void managerIsNotAbleToDeleteFavoriteIfAuthenticationFails() throws JsonToModelConversionException, Exception + { + UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); + siteManager.setPassword("wrongPassword"); + restClient.authenticateUser(siteManager).withCoreAPI().usingAuthUser() + .deleteSiteFromFavorites(siteModel).assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Manager user deletes site from favorites with Rest API and status code is 204") @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - public void managerIsAbleToDeleteFavorites() throws JsonToModelConversionException, Exception + public void managerIsAbleToDeleteFavorite() throws JsonToModelConversionException, Exception { UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); restClient.authenticateUser(siteManager).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); restClient.withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel).assertStatusCodeIs(HttpStatus.NO_CONTENT); restClient.withCoreAPI().usingAuthUser().getFavorites().assertThat().entriesListDoesNotContain("targetGuid", siteModel.getGuid()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Verify Collaborator user deletes site from favorites with Rest API and status code is 204") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - public void collaboratorIsAbleToDeleteFavorites() throws JsonToModelConversionException, Exception - { - UserModel siteCollaborator = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); - restClient.authenticateUser(siteCollaborator).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - - restClient.withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel).assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingAuthUser().getFavorites().assertThat().entriesListDoesNotContain("targetGuid", siteModel.getGuid()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Verify Contributor user deletes site from favorites with Rest API and status code is 204") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - public void contributorIsAbleToDeleteFavorites() throws JsonToModelConversionException, Exception - { - UserModel siteContributor = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); - restClient.authenticateUser(siteContributor).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - - restClient.withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel).assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingAuthUser().getFavorites().assertThat().entriesListDoesNotContain("targetGuid", siteModel.getGuid()); - } - + } + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Consumer user delets site from favorites with Rest API and status code is 204") @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - public void consumerIsAbleToDeleteFavorites() throws JsonToModelConversionException, Exception + public void consumerIsAbleToDeleteFavorite() throws JsonToModelConversionException, Exception { UserModel siteConsumer = usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer); restClient.authenticateUser(siteConsumer).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); @@ -91,56 +95,29 @@ public class DeleteFavoritesSanityTests extends RestTest restClient.withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel).assertStatusCodeIs(HttpStatus.NO_CONTENT); restClient.withCoreAPI().usingAuthUser().getFavorites().assertThat().entriesListDoesNotContain("targetGuid", siteModel.getGuid()); } - - @Bug(id="MNT-16557") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Verify user doesn't have permission to delete favorites of another user with Rest API and status code is 404") + description = "Verify Contributor user deletes site from favorites with Rest API and status code is 204") @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - public void userIsNotAbleToDeleteFavoritesOfAnotherUser() throws JsonToModelConversionException, Exception + public void contributorIsAbleToDeleteFavorite() throws JsonToModelConversionException, Exception + { + UserModel siteContributor = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); + restClient.authenticateUser(siteContributor).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + + restClient.withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel).assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withCoreAPI().usingAuthUser().getFavorites().assertThat().entriesListDoesNotContain("targetGuid", siteModel.getGuid()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, + description = "Verify Collaborator user deletes site from favorites with Rest API and status code is 204") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) + public void collaboratorIsAbleToDeleteFavorite() throws JsonToModelConversionException, Exception { UserModel siteCollaborator = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); restClient.authenticateUser(siteCollaborator).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI() - .usingAuthUser().deleteSiteFromFavorites(siteModel) - .assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Bug(id="MNT-16557") - @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Verify user doesn't have permission to delete favorites of admin user with Rest API and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - public void userIsNotAbleToDeleteFavoritesOfAdminUser() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel) - .assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Bug(id="MNT-16557") - @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Verify admin user doesn't have permission to delete favorites of another user with Rest API and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - public void adminIsNotAbleToDeleteFavoritesOfAnotherUser() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - - restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel) - .assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Bug(id = "MNT-16904") - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Verify user gets status code 401 if authentication call fails") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - public void userIsNotAbleToDeleteFavoritesIfAuthenticationFails() throws JsonToModelConversionException, Exception - { - UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); - siteManager.setPassword("wrongPassword"); - restClient.authenticateUser(siteManager).withCoreAPI().usingAuthUser() - .deleteSiteFromFavorites(siteModel).assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel).assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withCoreAPI().usingAuthUser().getFavorites().assertThat().entriesListDoesNotContain("targetGuid", siteModel.getGuid()); } + } From 35ed0e04afc193ec4f93b6c7b0c08141ad49bd3d Mon Sep 17 00:00:00 2001 From: mionescu Date: Mon, 9 Jan 2017 15:55:43 +0200 Subject: [PATCH 0789/1491] test- added new test cases - deleteFavorite- CORE --- .../favorites/DeleteFavoriteCoreTests.java | 161 ++++++++++++++++++ 1 file changed, 161 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteCoreTests.java b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteCoreTests.java new file mode 100644 index 000000000..3c61a76a6 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteCoreTests.java @@ -0,0 +1,161 @@ +package org.alfresco.rest.favorites; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class DeleteFavoriteCoreTests extends RestTest +{ + private UserModel adminUserModel; + private SiteModel siteModel; + private ListUserWithRoles usersWithRoles; + private FileModel fileModel; + private FolderModel folderModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + siteModel.setGuid(restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(siteModel).getSite().getGuid()); + + fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + folderModel = dataContent.usingSite(siteModel).usingUser(adminUserModel).createFolder(); + + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that status code is 404 if PersonID is incorrect - favorite file.") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE}) + public void deleteFavoriteIfPersonIdNotExists() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); + restClient.withCoreAPI().usingAuthUser().addFileToFavorites(fileModel); + + restClient.withCoreAPI().usingUser(new UserModel("inexistent", "inexistent")) + .deleteFileFromFavorites(fileModel).assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "inexistent")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that status code is 404 if FavoriteID is incorrect - favorite file.") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE}) + public void deleteFavoriteFileIfFavoriteIdIsIncorrect() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFileToFavorites(fileModel); + + fileModel.setNodeRef("wrongFavoriteId"); + restClient.withCoreAPI().usingAuthUser() + .deleteFileFromFavorites(fileModel).assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "wrongFavoriteId")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that status code is 404 if FavoriteID is incorrect - favorite file.") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE}) + public void deleteFavoriteFileIfFavoriteIdNotExists() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFileToFavorites(fileModel); + FileModel inexistentDocument = new FileModel(); + inexistentDocument.setNodeRef("inexistent"); + + restClient.withCoreAPI().usingAuthUser() + .deleteFileFromFavorites(inexistentDocument).assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "inexistent")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that status code is 404 if FavoriteID is incorrect - favorite site.") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE}) + public void deleteFavoriteIfFavoriteIdNotExists() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); + siteModel.setGuid("wrongFavoriteId"); + + restClient.withCoreAPI().usingAuthUser() + .deleteSiteFromFavorites(siteModel).assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "wrongFavoriteId")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that status code is 404 if FavoriteID is incorrect - favorite folder.") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE}) + public void deleteFavoriteFolderIfFavoriteIdNotExists() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); + restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(folderModel); + + folderModel.setNodeRef("wrongFavoriteId"); + restClient.withCoreAPI().usingAuthUser() + .deleteFolderFromFavorites(folderModel).assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "wrongFavoriteId")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify user removes a site from favorites using '-me-' in place of personId with Rest API and response is successful (204)") + public void deleteFavoriteSiteWithSuccessUsingMeAsPersonId() throws Exception + { + siteModel.setGuid(restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(siteModel).getSite().getGuid()); + restClient.withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); + + restClient.withCoreAPI().usingMe().deleteSiteFromFavorites(siteModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @Bug(id="MNT-16557") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify user doesn't have permission to delete favorites of another user with Rest API and status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) + public void collaboratorIsNotAbleToDeleteFavoriteOfAnotherUser() throws JsonToModelConversionException, Exception + { + UserModel siteCollaborator = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); + restClient.authenticateUser(siteCollaborator).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI() + .usingAuthUser().deleteSiteFromFavorites(siteModel) + .assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError() + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Bug(id="MNT-16557") + @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify admin user doesn't have permission to delete favorites of another user with Rest API and status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) + public void adminIsNotAbleToDeleteFavoriteOfAnotherUser() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + + restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel) + .assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError() + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + + +} From 8d9e43d92c64f39f9004343e87e926d1ed2ec7d2 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Mon, 9 Jan 2017 16:37:39 +0200 Subject: [PATCH 0790/1491] TAS-2611, TAS-2612 added new full tests --- .../rest/people/GetPeopleFullTests.java | 42 ++++++++++++++----- 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleFullTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleFullTests.java index 8cdaada10..d365ebf42 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleFullTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleFullTests.java @@ -1,16 +1,18 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestPersonModel; +import org.alfresco.rest.model.RestPersonModelsCollection; import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.RandomData; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.apache.commons.lang3.RandomStringUtils; +import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -19,7 +21,7 @@ public class GetPeopleFullTests extends RestTest { UserModel userModel; SiteModel siteModel; - UserModel searchedUser; + UserModel searchedUser, managerUser; UserModel adminUser; private RestPersonModel personModel; private String domain = "@tas-automation.org"; @@ -31,15 +33,14 @@ public class GetPeopleFullTests extends RestTest 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.FULL }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user gets person using '-me-' instead of personId with Rest API and response is successful") public void checkGetPersonIsSuccessfulForMe() throws Exception { - UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); - personModel = restClient.authenticateUser(managerUser).withCoreAPI().usingMe().getPerson(); restClient.assertStatusCodeIs(HttpStatus.OK); personModel.assertThat().field("id").is(managerUser.getUsername()) @@ -77,12 +78,9 @@ public class GetPeopleFullTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user get a person with special chars in username with Rest API and response is not found") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user gets a person with special chars in username with Rest API and response is not found") public void userChecksIfPersonWithSpecilCharsInUsernameIsNotFound() throws Exception - { - UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); - + { UserModel userSpecialChars = dataUser.usingAdmin().createUser(RandomStringUtils.randomAlphabetic(2) + "~!@#$%^&*()_+[]{}|\\;':\",./<>", "password"); //setting the encoded text for username userSpecialChars.setUsername(RandomStringUtils.randomAlphabetic(2) + "~!%40%23%24%25%5E%26*()_%2B%5B%5D%7B%7D%7C%5C%3B%27%3A%22%2C.%2F%3C%3E"); @@ -91,4 +89,28 @@ public class GetPeopleFullTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, userSpecialChars.getUsername())); } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @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.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user gets a person with Rest API and response is successful") + public void managerUserChecksIfPersonIsPresent() 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"); + } } From 7b800f1b8fcbd8423209c14e051d94e5da75a380 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Mon, 9 Jan 2017 16:54:22 +0200 Subject: [PATCH 0791/1491] updates on existing tests --- .../org/alfresco/rest/people/GetPeopleFullTests.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleFullTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleFullTests.java index d365ebf42..411260b41 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleFullTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleFullTests.java @@ -87,7 +87,10 @@ public class GetPeopleFullTests extends RestTest personModel = restClient.authenticateUser(managerUser).withCoreAPI().usingUser(userSpecialChars).getPerson(); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, userSpecialChars.getUsername())); + .assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, userSpecialChars.getUsername())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) @@ -101,9 +104,9 @@ public class GetPeopleFullTests extends RestTest persons.assertThat().entriesListIsNotEmpty(); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user gets a person with Rest API and response is successful") - public void managerUserChecksIfPersonIsPresent() throws Exception + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @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); From 9e3d50128608b75f282efd9aed0f6ec49369972b Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Mon, 9 Jan 2017 17:27:58 +0200 Subject: [PATCH 0792/1491] TAS-2745 added core tests for GetPeople --- .../rest/people/GetPeopleCoreTests.java | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/people/GetPeopleCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleCoreTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleCoreTests.java new file mode 100644 index 000000000..c1ef69a85 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleCoreTests.java @@ -0,0 +1,58 @@ +package org.alfresco.rest.people; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestPersonModel; +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.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * + * @author Cristina Axinte + * + */ +public class GetPeopleCoreTests extends RestTest +{ + UserModel userModel; + SiteModel siteModel; + UserModel searchedUser; + UserModel adminUser, managerUser; + UserModel inexistentUser; + + @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); + inexistentUser = new UserModel("inexistentUser", "password"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify inexistent user cannot get a person with Rest API and response is 401") + public void inexistentUserIsUnauthorizedToGetPerson() throws Exception + { + restClient.authenticateUser(inexistentUser).withCoreAPI().usingUser(searchedUser).getPerson(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot get a person that doesn't exists with Rest API and response is 404") + public void userCannotGetInexistentPerson() throws Exception + { + restClient.authenticateUser(managerUser).withCoreAPI().usingUser(inexistentUser).getPerson(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + restClient.assertLastError().containsSummary(String.format(inexistentUser.getUsername(), RestErrorModel.ENTITY_NOT_FOUND)); + } +} From 615caf5a6501d9316c61e416d15cac411a7836ad Mon Sep 17 00:00:00 2001 From: cagache Date: Mon, 9 Jan 2017 17:30:26 +0200 Subject: [PATCH 0793/1491] addSiteMembershipRequest full tests --- .../AddSiteMembershipRequestCoreTests.java | 25 +- .../AddSiteMembershipRequestFullTests.java | 251 ++++++++++++++++++ .../AddSiteMembershipRequestSanityTests.java | 90 +++---- 3 files changed, 301 insertions(+), 65 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestCoreTests.java b/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestCoreTests.java index c88a75046..6d3e9be45 100644 --- a/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestCoreTests.java @@ -2,6 +2,7 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestSiteMembershipRequestModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.SiteModel; @@ -16,26 +17,25 @@ import org.testng.annotations.Test; public class AddSiteMembershipRequestCoreTests extends RestTest { private UserModel adminUser; - private SiteModel siteModel; + private SiteModel moderatedSite; + private RestSiteMembershipRequestModel requestModel; @BeforeClass(alwaysRun = true) public void dataPreparation() throws DataPreparationException { adminUser = dataUser.getAdminUser(); - siteModel = dataSite.usingUser(adminUser).createModeratedRandomSite(); + moderatedSite = dataSite.usingUser(adminUser).createModeratedRandomSite(); } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify addSiteMembershipRequest Rest API status code is 400 for a user that has already been invited") public void addSiteMembershipRequestStatusCodeIs400ReceivedForAUserThatIsAlreadyInvited() throws Exception { UserModel newMember = dataUser.createRandomTestUser(); - dataUser.addUserToSite(newMember, siteModel, UserRole.SiteContributor); - restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest(siteModel); + dataUser.addUserToSite(newMember, moderatedSite, UserRole.SiteContributor); + restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest(moderatedSite); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - restClient.assertLastError().containsSummary(String.format(RestErrorModel.ALREADY_Site_MEMBER, newMember.getUsername(), siteModel.getId())); + restClient.assertLastError().containsSummary(String.format(RestErrorModel.ALREADY_Site_MEMBER, newMember.getUsername(), moderatedSite.getId())); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) @@ -43,7 +43,7 @@ public class AddSiteMembershipRequestCoreTests extends RestTest public void addSiteMembershipRequestStatusCodeIs404ReceivedForAUserThatDoesNotExist() throws Exception { UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingUser(new UserModel("invalidUser", "password")).addSiteMembershipRequest(siteModel); + restClient.authenticateUser(newMember).withCoreAPI().usingUser(new UserModel("invalidUser", "password")).addSiteMembershipRequest(moderatedSite); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); restClient.assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidUser")); } @@ -64,7 +64,8 @@ public class AddSiteMembershipRequestCoreTests extends RestTest { UserModel newMember = dataUser.createRandomTestUser(); restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest(""); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.NO_CONTENT, "No content to map to Object due to end of input")); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) @@ -72,8 +73,9 @@ public class AddSiteMembershipRequestCoreTests extends RestTest public void addSiteMembershipRequestStatusCodeIs201ForRequestWithEmptyMessage() throws Exception { UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest("", siteModel, "New request"); + requestModel = restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest("", moderatedSite, "New request"); restClient.assertStatusCodeIs(HttpStatus.CREATED); + requestModel.assertThat().field("id").is(moderatedSite.getId()).assertThat().field("site").isNotEmpty(); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) @@ -81,7 +83,8 @@ public class AddSiteMembershipRequestCoreTests extends RestTest public void addSiteMembershipRequestStatusCodeIs201ForRequestWithEmptyTitle() throws Exception { UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest("Please accept me", siteModel, ""); + requestModel = restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest("Please accept me", moderatedSite, ""); restClient.assertStatusCodeIs(HttpStatus.CREATED); + requestModel.assertThat().field("id").is(moderatedSite.getId()).assertThat().field("site").isNotEmpty(); } } diff --git a/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestFullTests.java b/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestFullTests.java new file mode 100644 index 000000000..6c25534c2 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestFullTests.java @@ -0,0 +1,251 @@ +package org.alfresco.rest.people; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestSiteEntry; +import org.alfresco.rest.model.RestSiteMembershipRequestModel; +import org.alfresco.rest.model.RestSiteMembershipRequestModelsCollection; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser; +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.report.Bug; +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; + +/** + * Created by Claudia Agache on 1/9/2017. + */ +public class AddSiteMembershipRequestFullTests extends RestTest +{ + private SiteModel publicSite, privateSite, moderatedSite; + private DataUser.ListUserWithRoles usersWithRoles; + private UserModel adminUser, newMember, regularUser; + private RestSiteMembershipRequestModel siteMembershipRequest; + private RestSiteMembershipRequestModelsCollection siteMembershipRequests; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws DataPreparationException + { + adminUser = dataUser.getAdminUser(); + publicSite = dataSite.usingUser(adminUser).createPublicRandomSite(); + privateSite = dataSite.usingUser(adminUser).createPrivateRandomSite(); + moderatedSite = dataSite.usingUser(adminUser).createModeratedRandomSite(); + usersWithRoles = dataUser.addUsersWithRolesToSite(publicSite, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + newMember = dataUser.createRandomTestUser(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site manager is not able to create new site membership request for other user") + public void managerIsNotAbleToCreateSiteMembershipRequestForOtherUser() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingUser(newMember) + .addSiteMembershipRequest(publicSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site collaborator is not able to create new site membership request for other user") + public void collaboratorIsNotAbleToCreateSiteMembershipRequestForOtherUser() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingUser(newMember) + .addSiteMembershipRequest(publicSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site contributor is not able to create new site membership request for other user") + public void contributorIsNotAbleToCreateSiteMembershipRequestForOtherUser() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingUser(newMember) + .addSiteMembershipRequest(publicSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site consumer is not able to create new site membership request for other user") + public void consumerIsNotAbleToCreateSiteMembershipRequestForOtherUser() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingUser(newMember) + .addSiteMembershipRequest(publicSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin user is not able to create new site membership request for other user") + public void adminIsNotAbleToCreateSiteMembershipRequestForOtherUser() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUser).withCoreAPI().usingUser(newMember).addSiteMembershipRequest(publicSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); + + restClient.withCoreAPI().usingUser(newMember).addSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); + + restClient.withCoreAPI().usingUser(newMember).addSiteMembershipRequest(privateSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); + } + + @Bug(id="ACE-2413") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify addSiteMembershipRequest Rest API status code is 400 for an invalid user id") + public void addSiteMembershipRequestReturns400ForEmptyUserId() throws Exception + { + restClient.authenticateUser(adminUser).withCoreAPI() + .usingUser(new UserModel("", "password")).addSiteMembershipRequest(publicSite); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify regular user is able to create new public site membership request for himself. Check that user joins immediately as consumer.") + public void userIsAbleToRequestMembershipOfPublicSite() throws Exception + { + regularUser = dataUser.createRandomTestUser(); + siteMembershipRequest = restClient.authenticateUser(regularUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(publicSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + siteMembershipRequest.assertThat().field("id").is(publicSite.getId()) + .assertThat().field("site").isNotEmpty(); + RestSiteEntry siteEntry = restClient.withCoreAPI().usingAuthUser().getSiteMembership(publicSite); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteEntry.assertThat().field("role").is(UserRole.SiteConsumer) + .and().field("id").is(publicSite.getId()); + siteMembershipRequests = restClient.withCoreAPI().usingAuthUser().getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembershipRequests.assertThat().entriesListIsEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify regular user is able to create new moderated site membership request for himself. Check that the request is added to the site membership request list.") + public void userIsAbleToRequestMembershipOfModeratedSite() throws Exception + { + regularUser = dataUser.createRandomTestUser(); + siteMembershipRequest = restClient.authenticateUser(regularUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + siteMembershipRequest.assertThat().field("id").is(moderatedSite.getId()) + .assertThat().field("site").isNotEmpty(); + siteMembershipRequests = restClient.withCoreAPI().usingAuthUser().getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembershipRequests.assertThat().entriesListContains("id", moderatedSite.getId()) + .assertThat().entriesListCountIs(1); + + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify regular user is not able to request membership of a private site.") + public void userIsNotAbleToRequestMembershipOfPrivateSite() throws Exception + { + regularUser = dataUser.createRandomTestUser(); + restClient.authenticateUser(regularUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(privateSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, regularUser.getUsername(), privateSite.getId())); + siteMembershipRequests = restClient.withCoreAPI().usingAuthUser().getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembershipRequests.assertThat().entriesListIsEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify regular user is not able to create new site membership request for other user") + public void regularUserIsNotAbleToCreateSiteMembershipRequestForOtherUser() throws JsonToModelConversionException, Exception + { + regularUser = dataUser.createRandomTestUser(); + restClient.authenticateUser(regularUser).withCoreAPI().usingUser(newMember) + .addSiteMembershipRequest(publicSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); + + restClient.withCoreAPI().usingUser(newMember).addSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); + + restClient.withCoreAPI().usingUser(newMember).addSiteMembershipRequest(privateSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify create public site membership request returns status code 400 when the request is made twice") + public void userRequestsTwiceMembershipOfPublicSite() throws Exception + { + regularUser = dataUser.createRandomTestUser(); + siteMembershipRequest = restClient.authenticateUser(regularUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(publicSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + siteMembershipRequest.assertThat().field("id").is(publicSite.getId()) + .assertThat().field("site").isNotEmpty(); + restClient.withCoreAPI().usingAuthUser().addSiteMembershipRequest(publicSite); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + restClient.assertLastError().containsSummary(String.format(RestErrorModel.ALREADY_Site_MEMBER, regularUser.getUsername(), publicSite.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify create moderated site membership request returns status code 400 when the request is made twice") + public void userRequestsTwiceMembershipOfModeratedSite() throws Exception + { + regularUser = dataUser.createRandomTestUser(); + siteMembershipRequest = restClient.authenticateUser(regularUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + siteMembershipRequest.assertThat().field("id").is(moderatedSite.getId()) + .assertThat().field("site").isNotEmpty(); + restClient.withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + restClient.assertLastError().containsSummary(String.format(RestErrorModel.ALREADY_INVITED, regularUser.getUsername(), moderatedSite.getId())); + + siteMembershipRequests = restClient.withCoreAPI().usingAuthUser().getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembershipRequests.assertThat().entriesListContains("id", moderatedSite.getId()) + .assertThat().entriesListCountIs(1); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify create private site membership request returns status code 404 when request is made with the user who created the site") + public void siteCreatorRequestsMembershipOfHisPrivateSite() throws Exception + { + restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(privateSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, adminUser.getUsername(), privateSite.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify create moderated site membership request returns status code 400 when request is made with the user who created the site") + public void siteCreatorRequestsMembershipOfHisModeratedSite() throws Exception + { + restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.ALREADY_Site_MEMBER, adminUser.getUsername(), moderatedSite.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify admin is able to create new moderated site membership request for himself. Check that the request is added to the site membership request list.") + public void adminIsAbleToRequestMembershipOfModeratedSite() throws Exception + { + regularUser = dataUser.createRandomTestUser(); + SiteModel anotherModeratedSite = dataSite.usingUser(regularUser).createModeratedRandomSite(); + siteMembershipRequest = restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(anotherModeratedSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + siteMembershipRequest.assertThat().field("id").is(anotherModeratedSite.getId()) + .assertThat().field("site").isNotEmpty(); + siteMembershipRequests = restClient.withCoreAPI().usingAuthUser().getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembershipRequests.assertThat().entriesListContains("id", anotherModeratedSite.getId()); + } +} diff --git a/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java index 8234328a8..91f59b4ef 100644 --- a/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java @@ -2,113 +2,95 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestSiteMembershipRequestModel; import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataSite; import org.alfresco.utility.data.DataUser; 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.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; public class AddSiteMembershipRequestSanityTests extends RestTest { - @Autowired - DataUser dataUser; - - @Autowired - DataSite dataSite; - - private SiteModel siteModel; - - private ListUserWithRoles usersWithRoles; - - private UserModel adminUser; + private SiteModel publicSite, anotherPublicSite; + private DataUser.ListUserWithRoles usersWithRoles; + private UserModel adminUser, siteManager; private RestSiteMembershipRequestModel requestModel; @BeforeClass(alwaysRun = true) public void dataPreparation() throws DataPreparationException { adminUser = dataUser.getAdminUser(); - siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + publicSite = dataSite.usingUser(adminUser).createPublicRandomSite(); + usersWithRoles = dataUser.addUsersWithRolesToSite(publicSite, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + + siteManager = dataUser.createRandomTestUser(); + anotherPublicSite = dataSite.usingUser(siteManager).createPublicRandomSite(); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site manager is able to create new site membership request") - @Bug(id = "MNT-16557") - public void siteManagerIsAbleToCreateSiteMembershipRequest() throws JsonToModelConversionException, Exception + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site manager is able to create new site membership request for himself and status code is 201") + public void managerCreatesNewSiteMembershipRequestForSelf() throws Exception { - UserModel newMember = dataUser.createRandomTestUser(); - requestModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingUser(newMember) - .addSiteMembershipRequest(siteModel); + requestModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingAuthUser().addSiteMembershipRequest(anotherPublicSite); restClient.assertStatusCodeIs(HttpStatus.CREATED); - requestModel.assertThat().field("id").isNotEmpty().assertThat().field("site").isNotEmpty(); + requestModel.assertThat().field("id").is(anotherPublicSite.getId()) + .assertThat().field("site").isNotEmpty(); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site collaborator is able to create new site membership request") - @Bug(id = "MNT-16557") - public void siteCollaboatorIsAbleToCreateSiteMembershipRequest() throws JsonToModelConversionException, Exception + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site contributor is able to create new site membership request for himself and status code is 201") + public void contributorCreatesNewSiteMembershipRequestForSelf() throws Exception { - UserModel newMember = dataUser.createRandomTestUser(); - requestModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingUser(newMember) - .addSiteMembershipRequest(siteModel); + requestModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingAuthUser().addSiteMembershipRequest(anotherPublicSite); restClient.assertStatusCodeIs(HttpStatus.CREATED); - requestModel.assertThat().field("id").isNotEmpty().assertThat().field("site").isNotEmpty(); + requestModel.assertThat().field("id").is(anotherPublicSite.getId()) + .assertThat().field("site").isNotEmpty(); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site contributor is able to create new site membership request") - @Bug(id = "MNT-16557") - public void siteContributorIsAbleToCreateSiteMembershipRequest() throws JsonToModelConversionException, Exception + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site collaborator is able to create new site membership request for himself and status code is 201") + public void collaboratorCreatesNewSiteMembershipRequestForSelf() throws Exception { - UserModel newMember = dataUser.createRandomTestUser(); - requestModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingUser(newMember) - .addSiteMembershipRequest(siteModel); + requestModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingAuthUser().addSiteMembershipRequest(anotherPublicSite); restClient.assertStatusCodeIs(HttpStatus.CREATED); - requestModel.assertThat().field("id").isNotEmpty().assertThat().field("site").isNotEmpty(); + requestModel.assertThat().field("id").is(anotherPublicSite.getId()) + .assertThat().field("site").isNotEmpty(); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site consumer is able to create new site membership request") - @Bug(id = "MNT-16557") - public void siteConsumerIsAbleToCreateSiteMembershipRequest() throws JsonToModelConversionException, Exception + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site consumer is able to create new site membership request for himself and status code is 201") + public void consumerCreatesNewSiteMembershipRequestForSelf() throws Exception { - UserModel newMember = dataUser.createRandomTestUser(); - requestModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingUser(newMember) - .addSiteMembershipRequest(siteModel); + requestModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingAuthUser().addSiteMembershipRequest(anotherPublicSite); restClient.assertStatusCodeIs(HttpStatus.CREATED); - requestModel.assertThat().field("id").isNotEmpty().assertThat().field("site").isNotEmpty(); + requestModel.assertThat().field("id").is(anotherPublicSite.getId()) + .assertThat().field("site").isNotEmpty(); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify admin user is able to create new site membership request") - @Bug(id = "MNT-16557") - public void adminUserIsAbleToCreateSiteMembershipRequest() throws JsonToModelConversionException, Exception + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify admin is able to create new site membership request for himself and status code is 201") + public void adminCreatesNewSiteMembershipRequestForSelf() throws Exception { - UserModel newMember = dataUser.createRandomTestUser(); - requestModel = restClient.authenticateUser(adminUser).withCoreAPI().usingUser(newMember).addSiteMembershipRequest(siteModel); + requestModel = restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(anotherPublicSite); restClient.assertStatusCodeIs(HttpStatus.CREATED); - requestModel.assertThat().field("id").isNotEmpty().assertThat().field("site").isNotEmpty(); + requestModel.assertThat().field("id").is(anotherPublicSite.getId()) + .assertThat().field("site").isNotEmpty(); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to create new site membership request") - @Bug(id = "MNT-16557") public void unauthenticatedUserIsNotAbleToCreateSiteMembershipRequest() throws JsonToModelConversionException, Exception { - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(new UserModel("random user", "random password")).withCoreAPI().usingUser(newMember).addSiteMembershipRequest(siteModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); + restClient.authenticateUser(new UserModel("random user", "random password")).withCoreAPI().usingAuthUser().addSiteMembershipRequest(publicSite); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } } \ No newline at end of file From 0444372514987ae8805c9c9db7a4be5f4633f7d2 Mon Sep 17 00:00:00 2001 From: Andrei Rusu Date: Mon, 9 Jan 2017 18:22:18 +0200 Subject: [PATCH 0794/1491] made changes to AddCommentsFullTests --- ...reTests.java => AddCommentsFullTests.java} | 45 +++++++++---------- 1 file changed, 22 insertions(+), 23 deletions(-) rename e2e-test/java/org/alfresco/rest/comments/{AddCommentsCoreTests.java => AddCommentsFullTests.java} (83%) diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentsCoreTests.java b/e2e-test/java/org/alfresco/rest/comments/AddCommentsFullTests.java similarity index 83% rename from e2e-test/java/org/alfresco/rest/comments/AddCommentsCoreTests.java rename to e2e-test/java/org/alfresco/rest/comments/AddCommentsFullTests.java index f86866213..c85085850 100644 --- a/e2e-test/java/org/alfresco/rest/comments/AddCommentsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/AddCommentsFullTests.java @@ -24,7 +24,7 @@ import org.testng.annotations.Test; /** * Created by Andrei Rusu */ -public class AddCommentsCoreTests extends RestTest +public class AddCommentsFullTests extends RestTest { private UserModel adminUserModel; private FileModel document; @@ -39,14 +39,13 @@ public class AddCommentsCoreTests extends RestTest { adminUserModel = dataUser.getAdminUser(); restClient.authenticateUser(adminUserModel); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - + siteModel = dataSite.usingUser(adminUserModel).createPrivateRandomSite(); usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); } - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.FULL, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Using Manager user verify that you can provide a large string for one comment") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) public void addLongCommentWithManagerAndCheckThatCommentIsReturned() throws Exception { document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); @@ -63,15 +62,15 @@ public class AddCommentsCoreTests extends RestTest comments.assertThat().paginationField("count").is("1"); } - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Using Contributor user verify that you can provide a short string for one comment") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) - public void addShortCommentWithContributorAndCheckThatCommentIsReturned() throws Exception + @TestRail(section={TestGroup.REST_API, TestGroup.FULL, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Using Manager user verify that you can provide a short string for one comment") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void addShortCommentWithManagerAndCheckThatCommentIsReturned() throws Exception { - document = dataContent.usingSite(siteModel).usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).createContent(DocumentType.TEXT_PLAIN); + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); String shortString = RandomStringUtils.randomAlphanumeric(2); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) .withCoreAPI().usingResource(document).addComment(shortString); restClient.assertStatusCodeIs(HttpStatus.CREATED); @@ -82,12 +81,12 @@ public class AddCommentsCoreTests extends RestTest comments.assertThat().paginationField("count").is("1"); } - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.FULL, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Using Collaborator user verify that you can provide a string with special characters for one comment") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) public void addCommentWithSpecialCharsWithCollaboratorCheckCommentIsReturned() throws Exception { - document = dataContent.usingSite(siteModel).usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).createContent(DocumentType.TEXT_PLAIN); + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); String specialCharsString = "!@#$%^&*()_+♂µΓyádo«√<╡┌6£"; restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) @@ -101,12 +100,12 @@ public class AddCommentsCoreTests extends RestTest comments.assertThat().paginationField("count").is("1"); } - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.FULL, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Using Manager user verify that you can not provide an empty string for one comment") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) public void addEmptyStringCommentWithManagerCheckCommentIsReturned() throws Exception { - document = dataContent.usingSite(siteModel).usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).createContent(DocumentType.TEXT_PLAIN); + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); String emptyString = ""; restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) @@ -114,12 +113,12 @@ public class AddCommentsCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(RestErrorModel.NON_NULL_COMMENT); } - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.FULL, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Using Collaborator user verify that you can provide several comments in one request") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) public void addSeveralCommentsWithCollaboratorCheckCommentsAreReturned() throws Exception { - document = dataContent.usingSite(siteModel).usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).createContent(DocumentType.TEXT_PLAIN); + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); String charString = RandomStringUtils.randomAlphanumeric(10); String charString1 = RandomStringUtils.randomAlphanumeric(10); String charString2 = RandomStringUtils.randomAlphanumeric(10); @@ -135,10 +134,10 @@ public class AddCommentsCoreTests extends RestTest comments.assertThat().paginationField("count").is("5"); } - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.FULL, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Provide invalid request body parameter and check default error model schema") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) - public void invalidRequestBodyParamenerCheckErrorModelSchema() throws Exception + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void invalidRequestBodyParameterCheckErrorModelSchema() throws Exception { document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); From 91f01d21891548ad5434574143091eaf2da1c6c8 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Mon, 9 Jan 2017 19:30:47 +0200 Subject: [PATCH 0795/1491] TAS-2613 TAS-2623 added full tests for GetPeopleActivities --- .../people/GetPeopleActivitiesFullTests.java | 71 +++++++++++++++++++ .../rest/people/GetPeopleCoreTests.java | 1 - 2 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesFullTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesFullTests.java new file mode 100644 index 000000000..a19c049d1 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesFullTests.java @@ -0,0 +1,71 @@ +package org.alfresco.rest.people; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestActivityModelsCollection; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestSiteModelsCollection; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * + * @author Cristina Axinte + * + */ +public class GetPeopleActivitiesFullTests extends RestTest +{ + UserModel userModel, managerUser; + SiteModel siteModel1, siteModel2; + FileModel fileInSite1, fileInSite2; + FolderModel folderInSite2; + private RestActivityModelsCollection restActivityModelsCollection; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + siteModel1 = dataSite.usingUser(userModel).createPublicRandomSite(); + fileInSite1 = dataContent.usingUser(userModel).usingSite(siteModel1).createContent(DocumentType.TEXT_PLAIN); + + siteModel2 = dataSite.usingUser(userModel).createPublicRandomSite(); + folderInSite2 = dataContent.usingUser(userModel).usingSite(siteModel2).createFolder(); + fileInSite2 = dataContent.usingAdmin().usingSite(siteModel2).createContent(DocumentType.TEXT_PLAIN); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its activities using me with Rest API and response is successful") + public void userShouldGetItsPeopleActivitiesUsingMe() throws Exception + { + restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingMe().getPersonActivities(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restActivityModelsCollection.assertThat().paginationField("count").is("3"); + restActivityModelsCollection.assertThat().entriesListContains("title", fileInSite1.getName()) + .and().entriesListContains("title", folderInSite2.getName()) + .and().entriesListContains("title", fileInSite2.getName()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot get activities for empty user with Rest API and response is 404") + public void userCannotGetPeopleActivitiesForEmptyPersonId() throws Exception + { + UserModel emptyUserName = new UserModel("", "password"); + + restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingUser(emptyUserName).getPersonActivities(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .containsSummary(RestErrorModel.LOCAL_NAME_CONSISTANCE) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } +} diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleCoreTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleCoreTests.java index c1ef69a85..3d814d594 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleCoreTests.java @@ -2,7 +2,6 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestPersonModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; From 0ca2203d5f58ca83476a7a8aa6ba8ee97b1875c4 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Tue, 10 Jan 2017 10:07:10 +0200 Subject: [PATCH 0796/1491] TAS-2617, TAS-2618, TAS-2620 Added new full tests for GetPeopleActivities --- .../people/GetPeopleActivitiesFullTests.java | 40 ++++++++++++++++--- 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesFullTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesFullTests.java index a19c049d1..7d2c30ffb 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesFullTests.java @@ -4,9 +4,8 @@ import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestActivityModelsCollection; import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestSiteModelsCollection; +import org.alfresco.utility.constants.ActivityType; import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; @@ -25,7 +24,7 @@ import org.testng.annotations.Test; */ public class GetPeopleActivitiesFullTests extends RestTest { - UserModel userModel, managerUser; + UserModel userModel, adminUser, managerUser; SiteModel siteModel1, siteModel2; FileModel fileInSite1, fileInSite2; FolderModel folderInSite2; @@ -34,6 +33,7 @@ public class GetPeopleActivitiesFullTests extends RestTest @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception { + adminUser = dataUser.getAdminUser(); userModel = dataUser.createRandomTestUser(); siteModel1 = dataSite.usingUser(userModel).createPublicRandomSite(); fileInSite1 = dataContent.usingUser(userModel).usingSite(siteModel1).createContent(DocumentType.TEXT_PLAIN); @@ -41,18 +41,23 @@ public class GetPeopleActivitiesFullTests extends RestTest siteModel2 = dataSite.usingUser(userModel).createPublicRandomSite(); folderInSite2 = dataContent.usingUser(userModel).usingSite(siteModel2).createFolder(); fileInSite2 = dataContent.usingAdmin().usingSite(siteModel2).createContent(DocumentType.TEXT_PLAIN); + + managerUser = dataUser.createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel2, UserRole.SiteManager); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.FULL }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its activities using me with Rest API and response is successful") - public void userShouldGetItsPeopleActivitiesUsingMe() throws Exception + public void userGetsItsPeopleActivitiesUsingMe() throws Exception { restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingMe().getPersonActivities(); restClient.assertStatusCodeIs(HttpStatus.OK); - restActivityModelsCollection.assertThat().paginationField("count").is("3"); + restActivityModelsCollection.assertThat().paginationField("count").is("4"); restActivityModelsCollection.assertThat().entriesListContains("title", fileInSite1.getName()) .and().entriesListContains("title", folderInSite2.getName()) - .and().entriesListContains("title", fileInSite2.getName()); + .and().entriesListContains("title", fileInSite2.getName()) + .and().entriesListContains("title", fileInSite2.getName()) + .and().entriesListContains("activityType", ActivityType.USER_JOINED.toString()); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.FULL }) @@ -68,4 +73,27 @@ public class GetPeopleActivitiesFullTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE) .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities successfully using parameter 'who' with 'me'vale with Rest API") + public void userGetsPeopleActivitiesUsingMeForWhoParameter() throws Exception + { + restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingUser(userModel).usingParams("who=me").getPersonActivities(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restActivityModelsCollection.assertThat().paginationField("count").is("2"); + restActivityModelsCollection.assertThat().entriesListContains("postPersonId", userModel.getUsername().toLowerCase()) + .and().entriesListDoesNotContain("postPersonId", adminUser.getUsername().toLowerCase()) + .and().entriesListDoesNotContain("postPersonId", managerUser.getUsername().toLowerCase()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its activities for siteId specified in siteId parameter using me with Rest API and response is successful") + public void userGetItsPeopleActivitiesForASpecificSite() throws Exception + { + restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingUser(userModel).usingParams(String.format("siteId=%s", siteModel1.getId())).getPersonActivities(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restActivityModelsCollection.assertThat().paginationField("count").is("1"); + restActivityModelsCollection.assertThat().entriesListContains("siteId", siteModel1.getId()) + .and().entriesListDoesNotContain("siteId", siteModel2.getId()); + } } From 152b99590f53d12ba7f56c59b3df0df7889983f4 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Tue, 10 Jan 2017 11:06:25 +0200 Subject: [PATCH 0797/1491] TAS-2621 new full test --- .../people/GetPeopleActivitiesFullTests.java | 47 +++++++++++++++++-- 1 file changed, 42 insertions(+), 5 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesFullTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesFullTests.java index 7d2c30ffb..facd8cfed 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesFullTests.java @@ -1,8 +1,13 @@ package org.alfresco.rest.people; +import java.util.ArrayList; +import java.util.List; + import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestActivityModel; import org.alfresco.rest.model.RestActivityModelsCollection; +import org.alfresco.rest.model.RestActivitySummaryModel; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.constants.ActivityType; import org.alfresco.utility.constants.UserRole; @@ -14,6 +19,7 @@ import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; +import org.testng.Assert; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -53,11 +59,17 @@ public class GetPeopleActivitiesFullTests extends RestTest restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingMe().getPersonActivities(); restClient.assertStatusCodeIs(HttpStatus.OK); restActivityModelsCollection.assertThat().paginationField("count").is("4"); - restActivityModelsCollection.assertThat().entriesListContains("title", fileInSite1.getName()) - .and().entriesListContains("title", folderInSite2.getName()) - .and().entriesListContains("title", fileInSite2.getName()) - .and().entriesListContains("title", fileInSite2.getName()) - .and().entriesListContains("activityType", ActivityType.USER_JOINED.toString()); + + List allActivitySummary = new ArrayList(); + for (RestActivityModel activityModel: restActivityModelsCollection.getEntries()) + { + allActivitySummary.add(activityModel.onModel().getActivitySummary()); + } + + assertActivitySummaryTitleIsPresent(allActivitySummary, fileInSite1.getName()); + assertActivitySummaryTitleIsPresent(allActivitySummary, folderInSite2.getName()); + assertActivitySummaryTitleIsPresent(allActivitySummary, fileInSite2.getName()); + restActivityModelsCollection.assertThat().entriesListContains("activityType", ActivityType.USER_JOINED.toString()); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.FULL }) @@ -96,4 +108,29 @@ public class GetPeopleActivitiesFullTests extends RestTest restActivityModelsCollection.assertThat().entriesListContains("siteId", siteModel1.getId()) .and().entriesListDoesNotContain("siteId", siteModel2.getId()); } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities for user with no activities with Rest API and response is successful") + public void userGetPeopleActivitiesForUserWithNoActivities() throws Exception + { + UserModel userNoActivities = dataUser.createRandomTestUser(); + dataSite.usingUser(userNoActivities).createPublicRandomSite(); + + restActivityModelsCollection = restClient.authenticateUser(adminUser).withCoreAPI().usingUser(userNoActivities).getPersonActivities(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restActivityModelsCollection.assertThat().paginationField("count").is("0"); + restActivityModelsCollection.assertThat().entriesListIsEmpty(); + } + + private void assertActivitySummaryTitleIsPresent(List allActivitySummary, String title) + { + for (RestActivitySummaryModel activitySummary: allActivitySummary) + { + if (activitySummary.getTitle().equals(title)) + { + Assert.assertEquals(activitySummary.getTitle(), title, String.format("%s title was not found in Activity Summary", title)); + break; + } + } + } } From 748458e2e869300ba68a5db9e2b8d5b397561033 Mon Sep 17 00:00:00 2001 From: Andrei Rusu Date: Tue, 10 Jan 2017 11:33:36 +0200 Subject: [PATCH 0798/1491] Added tests for AddCommentsCoreTests --- .../rest/comments/AddCommentsCoreTests.java | 168 ++++++++++++++++++ 1 file changed, 168 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/comments/AddCommentsCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentsCoreTests.java b/e2e-test/java/org/alfresco/rest/comments/AddCommentsCoreTests.java new file mode 100644 index 000000000..e4da2c957 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/comments/AddCommentsCoreTests.java @@ -0,0 +1,168 @@ +package org.alfresco.rest.comments; + +import java.util.List; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestCommentModel; +import org.alfresco.rest.model.RestCommentModelsCollection; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestTagModel; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FileType; +import org.alfresco.utility.model.LinkModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class AddCommentsCoreTests extends RestTest +{ + private UserModel adminUserModel, networkUserModel; + private SiteModel siteModel; + private DataUser.ListUserWithRoles usersWithRoles; + private RestCommentModelsCollection comments; + private String comment = "This is a new comment"; + private String comment2 = "This is the second comment"; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + networkUserModel = dataUser.createRandomTestUser(); + restClient.authenticateUser(adminUserModel); + siteModel = dataSite.usingUser(adminUserModel).createPrivateRandomSite(); + + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify User can't add comments to a node with ID that does not exist and status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + public void userCanNotAddCommentsOnNonexistentFile() throws Exception + { + FileModel nonexistentFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); + + nonexistentFile.setNodeRef("ABC"); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(nonexistentFile).addComments(comment,comment2); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, nonexistentFile.getNodeRef())); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify User can't add comments to a node that exists but is not a document or a folder and status code is 405") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + @Bug(id = "MNT-16904") + public void userCanNotAddCommentsOnLink() throws Exception + { + LinkModel link = dataLink.usingAdmin().usingSite(siteModel).createRandomLink(); + FileModel fileWithNodeRefFromLink = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); + fileWithNodeRefFromLink.setNodeRef(link.getNodeRef()); + + restClient.authenticateUser(adminUserModel).withCoreAPI() + .usingResource(fileWithNodeRefFromLink).addComments(comment,comment2); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(RestErrorModel.UNABLE_TO_LOCATE); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify User can add comments with the same content as one existing comment") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + public void userCanAddCommentWithTheSameContentAsExistingOne() throws Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + String sameComment = comment; + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(file).addComments(comment, sameComment) + .assertThat().paginationExist().and().entriesListIsNotEmpty() + .and().entriesListContains("content", comment) + .and().entriesListContains("content", sameComment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + comments = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI() + .usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListIsNotEmpty(); + List commentsList = comments.getEntries(); + commentsList.get(0).onModel().assertThat().field("content").is(comment); + commentsList.get(1).onModel().assertThat().field("content").is(sameComment); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify User can not add comments to a not joined private site. Status code returned is 403") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + public void userCanNotAddCommentsToANotJoinedPrivateSite() throws Exception + { + SiteModel sitePrivateNotJoined = dataSite.createPrivateRandomSite(); + FileModel file = dataContent.usingSite(sitePrivateNotJoined).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(file).addComments(comment, comment2); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify add comments from node with invalid network id returns status code 401") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + public void addCommentsWithInvalidNetworkId() throws Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + + networkUserModel.setDomain("invalidNetwork"); + restClient.authenticateUser(networkUserModel).withCoreAPI().usingResource(file).addComments(comment,comment2); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify add comments from node with empty network id returns status code 401") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + public void addCommentsWithEmptyNetworkId() throws Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + + networkUserModel.setDomain(""); + restClient.authenticateUser(networkUserModel).withCoreAPI().usingResource(file).addComments(comment,comment2); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, + description = "Verify that comments cannot be added to another comment") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + public void addCommentsToAComment() throws JsonToModelConversionException, Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + RestCommentModel commentEntry = restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingResource(file).addComment(comment); + file.setNodeRef(commentEntry.getId()); + + restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingResource(file).addComments(comment, comment2); + + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.CANNOT_COMMENT); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, + description = "Verify that comments cannot be added to a tag") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + public void addCommentsToATag() throws JsonToModelConversionException, Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + RestTagModel tag = restClient.withCoreAPI().usingResource(file).addTag("randomTag"); + + file.setNodeRef(tag.getId()); + + restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingResource(file).addComments(comment, comment2); + + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.CANNOT_COMMENT); + } +} From b16db5c37ed7c1aa6f1d2149a6403269c80cb04f Mon Sep 17 00:00:00 2001 From: Andrei Rusu Date: Tue, 10 Jan 2017 11:44:50 +0200 Subject: [PATCH 0799/1491] updated accordingly to addComments --- .../rest/comments/AddCommentsFullTests.java | 37 +++++++++++-------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentsFullTests.java b/e2e-test/java/org/alfresco/rest/comments/AddCommentsFullTests.java index c85085850..23a46bacd 100644 --- a/e2e-test/java/org/alfresco/rest/comments/AddCommentsFullTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/AddCommentsFullTests.java @@ -46,70 +46,77 @@ public class AddCommentsFullTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.FULL, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Using Manager user verify that you can provide a large string for one comment") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void addLongCommentWithManagerAndCheckThatCommentIsReturned() throws Exception + public void addLongCommentsWithManagerAndCheckThatCommentIsReturned() throws Exception { document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); String longString = RandomStringUtils.randomAlphanumeric(10000); + String longString1 = RandomStringUtils.randomAlphanumeric(90000); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(document).addComment(longString); + .withCoreAPI().usingResource(document).addComments(longString, longString1); restClient.assertStatusCodeIs(HttpStatus.CREATED); comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getNodeComments(); restClient.assertStatusCodeIs(HttpStatus.OK); comments.assertThat().entriesListContains("content", longString); - comments.assertThat().paginationField("totalItems").is("1"); - comments.assertThat().paginationField("count").is("1"); + comments.assertThat().entriesListContains("content", longString1); + comments.assertThat().paginationField("totalItems").is("2"); + comments.assertThat().paginationField("count").is("2"); } @TestRail(section={TestGroup.REST_API, TestGroup.FULL, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Using Manager user verify that you can provide a short string for one comment") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void addShortCommentWithManagerAndCheckThatCommentIsReturned() throws Exception + public void addShortCommentsWithManagerAndCheckThatCommentIsReturned() throws Exception { document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); String shortString = RandomStringUtils.randomAlphanumeric(2); + String shortString1 = RandomStringUtils.randomAlphanumeric(1); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(document).addComment(shortString); + .withCoreAPI().usingResource(document).addComments(shortString, shortString1); restClient.assertStatusCodeIs(HttpStatus.CREATED); comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getNodeComments(); restClient.assertStatusCodeIs(HttpStatus.OK); comments.assertThat().entriesListContains("content", shortString); - comments.assertThat().paginationField("totalItems").is("1"); - comments.assertThat().paginationField("count").is("1"); + comments.assertThat().entriesListContains("content", shortString1); + comments.assertThat().paginationField("totalItems").is("2"); + comments.assertThat().paginationField("count").is("2"); } @TestRail(section={TestGroup.REST_API, TestGroup.FULL, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Using Collaborator user verify that you can provide a string with special characters for one comment") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void addCommentWithSpecialCharsWithCollaboratorCheckCommentIsReturned() throws Exception + public void addCommentsWithSpecialCharsWithCollaboratorCheckCommentIsReturned() throws Exception { document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); String specialCharsString = "!@#$%^&*()_+♂µΓyádo«√<╡┌6£"; + String shortString = RandomStringUtils.randomAlphanumeric(2); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingResource(document).addComment(specialCharsString); + .withCoreAPI().usingResource(document).addComments(specialCharsString, shortString); restClient.assertStatusCodeIs(HttpStatus.CREATED); comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getNodeComments(); restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", specialCharsString); - comments.assertThat().paginationField("totalItems").is("1"); - comments.assertThat().paginationField("count").is("1"); + comments.assertThat().entriesListContains("content", specialCharsString); + comments.assertThat().entriesListContains("content", shortString); + comments.assertThat().paginationField("totalItems").is("2"); + comments.assertThat().paginationField("count").is("2"); } @TestRail(section={TestGroup.REST_API, TestGroup.FULL, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Using Manager user verify that you can not provide an empty string for one comment") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void addEmptyStringCommentWithManagerCheckCommentIsReturned() throws Exception + public void addEmptyStringCommentsWithManagerCheckCommentIsReturned() throws Exception { document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); String emptyString = ""; + String spaceString = " "; restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(document).addComment(emptyString); + .withCoreAPI().usingResource(document).addComments(emptyString, spaceString); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(RestErrorModel.NON_NULL_COMMENT); } From a8803c64b312046849a01e3c842a26cc342da0b6 Mon Sep 17 00:00:00 2001 From: cagache Date: Tue, 10 Jan 2017 11:48:38 +0200 Subject: [PATCH 0800/1491] TAS-2731 addSiteMembershipRequest full tests --- .../AddSiteMembershipRequestFullTests.java | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestFullTests.java b/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestFullTests.java index 6c25534c2..6688dff09 100644 --- a/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestFullTests.java +++ b/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestFullTests.java @@ -16,6 +16,7 @@ import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; +import org.springframework.social.alfresco.api.entities.Site; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -49,7 +50,11 @@ public class AddSiteMembershipRequestFullTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingUser(newMember) .addSiteMembershipRequest(publicSite); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())) + .statusCodeIs(HttpStatus.NOT_FOUND) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) @@ -248,4 +253,17 @@ public class AddSiteMembershipRequestFullTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); siteMembershipRequests.assertThat().entriesListContains("id", anotherModeratedSite.getId()); } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL, TestGroup.NETWORKS }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify create site membership request returns status code 404 when personId is not member of the domain.") + public void addSiteMembershipRequestWhenPersonIdIsNotInTheDomain() throws Exception + { + UserModel adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser) + .usingTenant().createTenant(adminTenantUser); + restClient.authenticateUser(adminTenantUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(publicSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, adminTenantUser.getUsername().toLowerCase(), publicSite.getId())); + } } From c752ed817335d6c71fcb42c10c2e017dfd47c1ef Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Tue, 10 Jan 2017 12:12:25 +0200 Subject: [PATCH 0801/1491] TAS-2623, TAS-2624 added 2 full tests --- .../people/GetPeopleActivitiesFullTests.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesFullTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesFullTests.java index facd8cfed..5e01bb755 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesFullTests.java @@ -133,4 +133,24 @@ public class GetPeopleActivitiesFullTests extends RestTest } } } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot get activities for siteId that user doesn't have access to with Rest API and response is not found") + public void userGetPeopleActivitiesForASiteWithNoAccess() throws Exception + { + SiteModel siteNoAccess = dataSite.usingUser(managerUser).createPrivateRandomSite(); + + restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingUser(userModel).usingParams(String.format("siteId=%s", siteNoAccess.getId())).getPersonActivities(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + restClient.assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, siteNoAccess.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot get activities for another user with Rest API and response is successful") + public void userGetPeopleActivitiesForAnotherUser() throws Exception + { + restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingUser(managerUser).getPersonActivities(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + restClient.assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } } From 971a913776d4a37a755e6a53f4f28f6328069d82 Mon Sep 17 00:00:00 2001 From: mionescu Date: Tue, 10 Jan 2017 12:12:51 +0200 Subject: [PATCH 0802/1491] test - added test for DeleteFavoriteFull suite core- added new enum - API_DEFAULT_ERRORKEY --- .../favorites/DeleteFavoriteFullTests.java | 246 ++++++++++++++++++ 1 file changed, 246 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteFullTests.java b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteFullTests.java new file mode 100644 index 000000000..f79958390 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteFullTests.java @@ -0,0 +1,246 @@ +package org.alfresco.rest.favorites; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class DeleteFavoriteFullTests extends RestTest +{ + private UserModel adminUserModel, tenantUser, adminTenantUser; + private SiteModel siteModel; + private ListUserWithRoles usersWithRoles; + private FileModel fileModel; + private FolderModel folderModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + siteModel.setGuid(restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(siteModel).getSite().getGuid()); + + fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + folderModel = dataContent.usingSite(siteModel).usingUser(adminUserModel).createFolder(); + + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify admin deletes files from favorites with Rest API and status code is (204)") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) + public void adminIsAbleToDeleteFavoriteFile() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFileToFavorites(fileModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.withCoreAPI().usingAuthUser().deleteFileFromFavorites(fileModel).assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withCoreAPI().usingAuthUser().getFavorites() + .assertThat() + .entriesListDoesNotContain("targetGuid", fileModel.getNodeRefWithoutVersion()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify admin deletes folder from favorites with Rest API and status code is (204)") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) + public void adminIsAbleToDeleteFavoriteFolder() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFolderToFavorites(folderModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.withCoreAPI().usingAuthUser().deleteFolderFromFavorites(folderModel) + .assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withCoreAPI().usingAuthUser().getFavorites() + .assertThat() + .entriesListDoesNotContain("targetGuid", fileModel.getNodeRefWithoutVersion()); + } + + @Bug(id="MNT-16557") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify consumer user doesn't have permission to delete favorites of another user with Rest API and status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) + public void consumerIsNotAbleToDeleteFavoriteOfAnotherUser() throws JsonToModelConversionException, Exception + { + UserModel siteConsumer = usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer); + restClient.authenticateUser(siteConsumer).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI() + .usingAuthUser().deleteSiteFromFavorites(siteModel) + .assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError() + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Bug(id="MNT-16557") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify contributor user doesn't have permission to delete favorites of another user with Rest API and status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) + public void contributorIsNotAbleToDeleteFavoriteOfAnotherUser() throws JsonToModelConversionException, Exception + { + UserModel siteContributor = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); + restClient.authenticateUser(siteContributor).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI() + .usingAuthUser().deleteSiteFromFavorites(siteModel) + .assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError() + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Bug(id="MNT-16557") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify contributor user doesn't have permission to delete favorites of another user with Rest API and status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) + public void adminIsNotAbleToDeleteFavoriteOfAnotherUser() throws JsonToModelConversionException, Exception + { + UserModel user = dataUser.createRandomTestUser(); + restClient.authenticateUser(user).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + + restClient.authenticateUser(adminUserModel).withCoreAPI() + .usingAuthUser().deleteSiteFromFavorites(siteModel) + .assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError() + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify admin is not able to deletes files from favorites that were already deleted with Rest API and status code is (404)") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) + public void adminIsNotAbleToDeletesADeletedFavoriteFile() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFileToFavorites(fileModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.withCoreAPI().usingAuthUser().deleteFileFromFavorites(fileModel).assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withCoreAPI().usingAuthUser().getFavorites() + .assertThat() + .entriesListDoesNotContain("targetGuid", fileModel.getNodeRefWithoutVersion()); + + restClient.withCoreAPI().usingAuthUser().deleteFileFromFavorites(fileModel) + .assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, + adminUserModel.getUsername(), fileModel.getNodeRef())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify user can't delete favorites using an invalid network ID.") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) + public void userIsNotAbleToDeleteFavoriteSiteWithInvalidNetworkID() throws JsonToModelConversionException, Exception + { + UserModel networkUserModel = dataUser.createRandomTestUser(); + restClient.authenticateUser(networkUserModel).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + networkUserModel.setDomain("invalidNetwork"); + + restClient.withCoreAPI() + .usingAuthUser().deleteSiteFromFavorites(siteModel) + .assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) + .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify contributor user doesn't have permission to delete favorites of another user with Rest API and status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) + public void adminDeletesFavoriteForNotFavouriteFile() throws JsonToModelConversionException, Exception + { + fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser() + .deleteFileFromFavorites(fileModel) + .assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, + adminUserModel.getUsername(), fileModel.getNodeRef())) + .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Bug(id="MNT-16904") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify tenant user is not able to delete favorites using an invalid network ID") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES,TestGroup.NETWORKS, TestGroup.FULL }) + public void tenantIsNotAbleToDeleteFavoriteSiteWithInvalidNetworkID() throws JsonToModelConversionException, Exception + { + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUserModel).usingTenant().createTenant(adminTenantUser); + tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + siteModel = dataSite.usingUser(tenantUser).createPublicRandomSite(); + siteModel.setGuid(restClient.authenticateUser(tenantUser).withCoreAPI().usingSite(siteModel).getSite().getGuid()); + restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + tenantUser.setDomain("invalidNetwork"); + + restClient.withCoreAPI() + .usingAuthUser().deleteSiteFromFavorites(siteModel) + .assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify tenant user deletes favorites site and status code is (204)") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES,TestGroup.NETWORKS, TestGroup.FULL }) + public void tenantDeleteFavoriteSiteValidNetwork() throws JsonToModelConversionException, Exception + { + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUserModel).usingTenant().createTenant(adminTenantUser); + tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + siteModel = dataSite.usingUser(tenantUser).createPublicRandomSite(); + siteModel.setGuid(restClient.authenticateUser(tenantUser).withCoreAPI().usingSite(siteModel).getSite().getGuid()); + restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + tenantUser.setDomain(tenantUser.getDomain()); + + restClient.withCoreAPI() + .usingAuthUser().deleteSiteFromFavorites(siteModel) + .assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingAuthUser().getFavorites() + .assertThat() + .entriesListDoesNotContain("targetGuid", fileModel.getNodeRefWithoutVersion()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify tenant user deletes favorites site created by admin tenant - same network and status code is (204)") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES,TestGroup.NETWORKS, TestGroup.FULL }) + public void tenantUserIsAbleToDeleteFavoriteSiteAddedByAdminSameNetwork() throws JsonToModelConversionException, Exception + { + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUserModel).usingTenant().createTenant(adminTenantUser); + tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); + siteModel.setGuid(restClient.authenticateUser(adminTenantUser).withCoreAPI().usingSite(siteModel).getSite().getGuid()); + restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + tenantUser.setDomain(adminTenantUser.getDomain()); + + restClient.withCoreAPI() + .usingAuthUser().deleteSiteFromFavorites(siteModel) + .assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingAuthUser().getFavorites() + .assertThat() + .entriesListDoesNotContain("targetGuid", fileModel.getNodeRefWithoutVersion()); + } + +} From cd5ae232824b2acc057240a372282a6c26e446c9 Mon Sep 17 00:00:00 2001 From: cagache Date: Tue, 10 Jan 2017 14:18:29 +0200 Subject: [PATCH 0803/1491] TAS-2719 addSiteMembershipRequest full tests --- .../AddSiteMembershipRequestFullTests.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestFullTests.java b/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestFullTests.java index 6688dff09..1e60b408a 100644 --- a/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestFullTests.java +++ b/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestFullTests.java @@ -266,4 +266,23 @@ public class AddSiteMembershipRequestFullTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, adminTenantUser.getUsername().toLowerCase(), publicSite.getId())); } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify site membership request is automatically rejected when a site is switched from moderated to private") + public void siteMembershipRequestIsRejectedWhenSiteIsSwitchedFromModeratedToPrivate() throws Exception + { + regularUser = dataUser.createRandomTestUser(); + SiteModel moderatedThenPrivateSite = dataSite.usingUser(adminUser).createModeratedRandomSite(); + siteMembershipRequest = restClient.authenticateUser(regularUser).withCoreAPI().usingMe().addSiteMembershipRequest(moderatedThenPrivateSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + siteMembershipRequest.assertThat().field("id").is(moderatedThenPrivateSite.getId()) + .assertThat().field("site").isNotEmpty(); + + dataSite.usingUser(adminUser).updateSiteVisibility(moderatedThenPrivateSite, Site.Visibility.PRIVATE); + + siteMembershipRequests = restClient.withCoreAPI().usingAuthUser().getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembershipRequests.assertThat().entriesListIsEmpty(); + } } From 04d5e38f10b7cb786f59cc9d16c4709512afe2cc Mon Sep 17 00:00:00 2001 From: Andrei Rusu Date: Tue, 10 Jan 2017 15:36:31 +0200 Subject: [PATCH 0804/1491] added tests for getCommentsFullTests added changes to network tests getCommentsCoreTests --- .../rest/comments/GetCommentsCoreTests.java | 8 +- .../rest/comments/GetCommentsFullTests.java | 247 ++++++++++++++++++ 2 files changed, 251 insertions(+), 4 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/comments/GetCommentsFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/comments/GetCommentsCoreTests.java b/e2e-test/java/org/alfresco/rest/comments/GetCommentsCoreTests.java index 8345fae21..c018b1f87 100644 --- a/e2e-test/java/org/alfresco/rest/comments/GetCommentsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/GetCommentsCoreTests.java @@ -112,8 +112,8 @@ public class GetCommentsCoreTests extends RestTest public void getCommentsWithInvalidNetwork() throws Exception { networkUserModel.setDomain("invalidNetwork"); - restClient.authenticateUser(userModel).withCoreAPI().usingResource(document).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + restClient.authenticateUser(networkUserModel).withCoreAPI().usingResource(document).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, @@ -122,8 +122,8 @@ public class GetCommentsCoreTests extends RestTest public void getCommentsWithEmptyNetwork() throws Exception { networkUserModel.setDomain(""); - restClient.authenticateUser(userModel).withCoreAPI().usingResource(document).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + restClient.authenticateUser(networkUserModel).withCoreAPI().usingResource(document).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } } diff --git a/e2e-test/java/org/alfresco/rest/comments/GetCommentsFullTests.java b/e2e-test/java/org/alfresco/rest/comments/GetCommentsFullTests.java new file mode 100644 index 000000000..6d8425bdb --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/comments/GetCommentsFullTests.java @@ -0,0 +1,247 @@ +package org.alfresco.rest.comments; + +import java.util.List; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestCommentModel; +import org.alfresco.rest.model.RestCommentModelsCollection; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class GetCommentsFullTests extends RestTest +{ + private UserModel adminUserModel; + private SiteModel siteModel; + private String comment = "This is a new comment"; + private String comment2 = "This is the second comment"; + private RestCommentModelsCollection comments; + private DataUser.ListUserWithRoles usersWithRoles; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + siteModel = dataSite.usingUser(adminUserModel).createPrivateRandomSite(); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, + UserRole.SiteContributor, UserRole.SiteConsumer); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.FULL, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify that if manager adds one comment, it will be returned in getComments response") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void addCommentWithManagerAndCheckThatCommentIsReturned() throws Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(file).addComment(comment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", comment); + comments.assertThat().paginationField("totalItems").is("1"); + comments.assertThat().paginationField("count").is("1"); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.FULL, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify that if collaborator adds one comment, it will be returned in getComments response") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void addCommentWithCollaboratorAndCheckThatCommentIsReturned() throws Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingResource(file).addComment(comment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", comment); + comments.assertThat().paginationField("totalItems").is("1"); + comments.assertThat().paginationField("count").is("1"); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.FULL, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify that if contributor adds one comment, it will be returned in getComments response") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + @Bug(id = "ACE-4614") + public void addCommentWithContributorAndCheckThatCommentIsReturned() throws Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) + .withCoreAPI().usingResource(file).addComment(comment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", comment); + comments.assertThat().paginationField("totalItems").is("1"); + comments.assertThat().paginationField("count").is("1"); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.FULL, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify that consumer cannot add a comment and no comments will be returned in getComments response") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void addCommentWithConsumerAndCheckThatCommentIsNotReturned() throws Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + .withCoreAPI().usingResource(file).addComment(comment); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + + comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().paginationField("totalItems").is("0"); + comments.assertThat().paginationField("count").is("0"); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.FULL, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Add one comment with Manager and check that returned person is the right one") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void addCommentWithManagerCheckReturnedPersonIsTheRightOne() throws Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + UserModel user1 = dataUser.createRandomTestUser(); + dataUser.addUserToSite(user1, siteModel, UserRole.SiteManager); + + restClient.authenticateUser(user1).withCoreAPI().usingResource(file).addComment(comment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListIsNotEmpty(); + List commentsList = comments.getEntries(); + commentsList.get(0).onModel().getCreatedBy().assertThat().field("firstName").is(user1.getUsername() + " FirstName") + .assertThat().field("lastName").is("LN-" + user1.getUsername()); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.FULL, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Add one comment with Collaborator and check that returned company details are correct") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void addCommentWithCollaboratorCheckReturnedCompanyDetails() throws Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(file).addComment(comment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListIsNotEmpty(); + List commentsList = comments.getEntries(); + commentsList.get(0).onModel().getCreatedBy().getCompany() + .assertThat().field("organization").isNull() + .assertThat().field("address1").isNull() + .assertThat().field("address2").isNull() + .assertThat().field("address3").isNull() + .assertThat().field("postcode").isNull() + .assertThat().field("telephone").isNull() + .assertThat().field("fax").isNull() + .assertThat().field("email").isNull(); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.FULL, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Add 2 comments with Manager and Collaborator users and verify valid request using skipCount. Check that param is applied") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void addTwoCommentsWithManagerCollaboratorVerifySkipCountParamIsApplied() throws Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(file).addComment(comment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(file).addComment(comment2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + comments = restClient.authenticateUser(adminUserModel).withParams("skipCount=1") + .withCoreAPI().usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", comment) + .and().paginationField("count").is("1"); + comments.assertThat().paginationField("skipCount").is("1"); + comments.assertThat().paginationField("totalItems").is("2"); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.FULL, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Add 2 comments with Admin and Collaborator users and verify valid request using maxItems. Check that param is applied") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void addTwoCommentsWithAdminCollaboratorVerifyMaxItemsParamIsApplied() throws Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(comment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(file).addComment(comment2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + comments = restClient.authenticateUser(adminUserModel).withParams("maxItems=1") + .withCoreAPI().usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", comment2) + .and().paginationField("count").is("1"); + comments.assertThat().paginationField("totalItems").is("2"); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.FULL, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Add 2 comments with Manager and Admin users and verify valid request using properties. Check that param is applied") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void addTwoCommentsWithAdminManagerVerifyPropertiesParamIsApplied() throws Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(comment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(file).addComment(comment2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + comments = restClient.authenticateUser(adminUserModel).withParams("properties=createdBy,modifiedBy") + .withCoreAPI().usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListIsNotEmpty() + .and().paginationField("count").is("2"); + comments.assertThat().paginationField("totalItems").is("2"); + + List commentsList = comments.getEntries(); + + commentsList.get(0).onModel().getCreatedBy() + .assertThat().field("firstName").is(usersWithRoles.getOneUserWithRole(UserRole.SiteManager).getUsername() + " FirstName") + .assertThat().field("lastName").is("LN-" + usersWithRoles.getOneUserWithRole(UserRole.SiteManager).getUsername()); + + commentsList.get(1).onModel().getCreatedBy() + .assertThat().field("firstName").is("Administrator") + .assertThat().field("id").is("admin"); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.FULL, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Check default error model schema") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void addTwoCommentsWithManagerCheckDefaultErrorModelSchema() throws Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(file).addComments(comment, comment2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).usingParams("maxItems=0").getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); + restClient.assertLastError().getErrorKey().contains("Only positive values supported for maxItems."); + restClient.assertLastError().containsSummary("Only positive values supported for maxItems."); + restClient.assertLastError().getDescriptionURL().contains("https://api-explorer.alfresco.com"); + restClient.assertLastError().getStackTrace().contains("For security reasons the stack trace is no longer displayed, but the property is kept for previous versions"); + } +} \ No newline at end of file From 07c11eb883fa54976aaefdf24938ddb38859af79 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Tue, 10 Jan 2017 15:50:20 +0200 Subject: [PATCH 0805/1491] added log4j properties for testRail --- e2e-test/resources/log4j.properties | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/e2e-test/resources/log4j.properties b/e2e-test/resources/log4j.properties index 63d3970dc..ede92a004 100644 --- a/e2e-test/resources/log4j.properties +++ b/e2e-test/resources/log4j.properties @@ -12,4 +12,15 @@ log4j.appender.file.layout.ConversionPattern=%d{HH:mm:ss} %-5p %c{1}:%L - %m%n log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.Target=System.out log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=%d{HH:mm:ss} %-5p %c{1}:%L - %m%n \ No newline at end of file +log4j.appender.stdout.layout.ConversionPattern=%d{HH:mm:ss} %-5p %c{1}:%L - %m%n + +# TestRail particular log file +# Direct log messages to a log file +log4j.appender.testrailLog=org.apache.log4j.RollingFileAppender +log4j.appender.testrailLog.File=./target/reports/alfresco-testrail.log +log4j.appender.testrailLog.MaxBackupIndex=10 +log4j.appender.testrailLog.layout=org.apache.log4j.PatternLayout +log4j.appender.testrailLog.layout.ConversionPattern=%d{HH:mm:ss} %-5p %c{1}:%L - %m%n + +log4j.category.testrail=INFO, testrailLog +log4j.additivity.testrail=false \ No newline at end of file From 16409e8c983dacb7a50e12133e8afcbfb8c5f1e5 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Tue, 10 Jan 2017 15:51:15 +0200 Subject: [PATCH 0806/1491] move jmx.useJolokiaAgent on top --- e2e-test/resources/default.properties | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/e2e-test/resources/default.properties b/e2e-test/resources/default.properties index f5733caf1..6d12861d7 100644 --- a/e2e-test/resources/default.properties +++ b/e2e-test/resources/default.properties @@ -3,6 +3,10 @@ alfresco.scheme=http alfresco.server=localhost alfresco.port=8080 +# in containers we cannot access directly JMX, so we will use http://jolokia.org agent +# disabling this we will use direct JMX calls to server +jmx.useJolokiaAgent=false + # credentials admin.user=admin admin.password=admin @@ -34,10 +38,6 @@ testManagement.suiteId=12 # The location of the reports path reports.path=./target/reports -# in containers we cannot access directly JMX, so we will use http://jolokia.org agent -# disabling this we will use direct JMX calls to server -jmx.useJolokiaAgent=true - # # Database Section # You should provide here the database URL, that can be a differed server as alfresco. From cc84692d3392f4d1d558fc27115ca7c67dbf2c28 Mon Sep 17 00:00:00 2001 From: mionescu Date: Tue, 10 Jan 2017 15:52:38 +0200 Subject: [PATCH 0807/1491] test - updated tests from Core and Sanity --- .../people/DeleteFavoriteSiteCoreTests.java | 33 ++++++--- .../people/DeleteFavoriteSiteSanityTests.java | 69 ++++++++++++++++--- 2 files changed, 82 insertions(+), 20 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteCoreTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteCoreTests.java index d01b95d7c..cb1c898da 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteCoreTests.java @@ -30,7 +30,8 @@ public class DeleteFavoriteSiteCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user removes a site from favorites using '-me-' in place of personId with Rest API and response is successful (204)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify user removes a site from favorites using '-me-' in place of personId with Rest API and response is successful (204)") public void removeFavoriteSiteWithSuccessUsingMeAsPersonId() throws Exception { restClient.authenticateUser(adminUserModel); @@ -42,7 +43,8 @@ public class DeleteFavoriteSiteCoreTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) @Bug(id = "REPO-1642", description = "reproduced on 5.2.1 only, it works on 5.2.0") - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify inexistent user is not able to remove a site from favorites and response is 404") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify inexistent user is not able to remove a site from favorites and response is 404") public void inexistentUserIsNotAbleToRemoveFavoriteSite() throws Exception { UserModel inexistentUser = new UserModel("inexistenUser", "password"); @@ -51,17 +53,24 @@ public class DeleteFavoriteSiteCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove from favorites a site with inexistent id and response is 404") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify user is not able to remove from favorites a site with inexistent id and response is 404") public void userIsNotAbleToRemoveFavoriteSiteWithInexistentId() throws Exception { SiteModel inexistentSite = new SiteModel("inexistentSite"); restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).removeFavoriteSite(inexistentSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, adminUserModel.getUsername(), inexistentSite.getTitle())); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, + adminUserModel.getUsername(), inexistentSite.getTitle())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE) + .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify manager user removes a site from its favorites and adds it again and response is successful (204)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify manager user removes a site from its favorites and adds it again and response is successful (204)") public void managerUserRemovesFavoriteSiteAndAddItAgain() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -75,7 +84,8 @@ public class DeleteFavoriteSiteCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify manager user removes a site from its favorite sites list with Rest API and response is successful (204)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify manager user removes a site from its favorite sites list with Rest API and response is successful (204)") public void managerUserRemovesFavoriteSiteWithSuccess() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -88,7 +98,8 @@ public class DeleteFavoriteSiteCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify uninvited user can delete favorite public site and response is 204") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify uninvited user can delete favorite public site and response is 204") public void uninvitedUserCanDeleteFavoritePublicSite() throws Exception { SiteModel publicSiteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); @@ -100,7 +111,8 @@ public class DeleteFavoriteSiteCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify uninvited user can delete favorite moderated site and response is 204") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify uninvited user can delete favorite moderated site and response is 204") public void uninvitedUserCanDeleteFavoriteModeratedSite() throws Exception { SiteModel moderatedSiteModel = dataSite.usingUser(adminUserModel).createModeratedRandomSite(); @@ -112,7 +124,8 @@ public class DeleteFavoriteSiteCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user can delete favorite private site and response is 204") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify user can delete favorite private site and response is 204") public void userCanDeleteFavoritePrivateSite() throws Exception { SiteModel privateSiteModel = dataSite.usingUser(userModel).createPrivateRandomSite(); diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java index ab56d7b8c..2e91ed8e2 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java @@ -33,7 +33,8 @@ public class DeleteFavoriteSiteSanityTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user removes a site from its favorite sites list with Rest API and response is successful (204)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, + description = "Verify manager user removes a site from its favorite sites list with Rest API and response is successful (204)") public void managerUserRemovesFavoriteSiteWithSuccess() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -43,10 +44,19 @@ public class DeleteFavoriteSiteSanityTests extends RestTest restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel1); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingAuthUser().getFavorites() + .assertThat() + .entriesListDoesNotContain("targetGuid", siteModel1.getGuid()) + .and().entriesListDoesNotContain("id", siteModel1.getId()) + .and().entriesListDoesNotContain("description", siteModel1.getDescription()) + .and().entriesListDoesNotContain("visibility", siteModel1.getVisibility().toString()) + .and().entriesListDoesNotContain("title", siteModel1.getTitle()); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify collaborator user removes a site from its favorite sites list with Rest API and response is successful (204)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, + description = "Verify collaborator user removes a site from its favorite sites list with Rest API and response is successful (204)") public void collaboratorUserRemovesFavoriteSiteWithSuccess() throws Exception { UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); @@ -56,10 +66,19 @@ public class DeleteFavoriteSiteSanityTests extends RestTest restClient.authenticateUser(collaboratorUser).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel1); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingAuthUser().getFavorites() + .assertThat() + .entriesListDoesNotContain("targetGuid", siteModel1.getGuid()) + .and().entriesListDoesNotContain("id", siteModel1.getId()) + .and().entriesListDoesNotContain("description", siteModel1.getDescription()) + .and().entriesListDoesNotContain("visibility", siteModel1.getVisibility().toString()) + .and().entriesListDoesNotContain("title", siteModel1.getTitle()); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify contributor user removes a site from its favorite sites list with Rest API and response is successful (204)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, + description = "Verify contributor user removes a site from its favorite sites list with Rest API and response is successful (204)") public void contributorUserRemovesFavoriteSiteWithSuccess() throws Exception { UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); @@ -69,10 +88,19 @@ public class DeleteFavoriteSiteSanityTests extends RestTest restClient.authenticateUser(contributorUser).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel1); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingAuthUser().getFavorites() + .assertThat() + .entriesListDoesNotContain("targetGuid", siteModel1.getGuid()) + .and().entriesListDoesNotContain("id", siteModel1.getId()) + .and().entriesListDoesNotContain("description", siteModel1.getDescription()) + .and().entriesListDoesNotContain("visibility", siteModel1.getVisibility().toString()) + .and().entriesListDoesNotContain("title", siteModel1.getTitle()); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify consumer user removes a site from its favorite sites list with Rest API and response is successful (204)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, + description = "Verify consumer user removes a site from its favorite sites list with Rest API and response is successful (204)") public void consumerUserRemovesFavoriteSiteWithSuccess() throws Exception { UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -82,10 +110,19 @@ public class DeleteFavoriteSiteSanityTests extends RestTest restClient.authenticateUser(consumerUser).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel1); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingAuthUser().getFavorites() + .assertThat() + .entriesListDoesNotContain("targetGuid", siteModel1.getGuid()) + .and().entriesListDoesNotContain("id", siteModel1.getId()) + .and().entriesListDoesNotContain("description", siteModel1.getDescription()) + .and().entriesListDoesNotContain("visibility", siteModel1.getVisibility().toString()) + .and().entriesListDoesNotContain("title", siteModel1.getTitle()); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify admin user removes a site from any user's favorite sites list with Rest API and response is successful (204)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, + description = "Verify admin user removes a site from any user's favorite sites list with Rest API and response is successful (204)") public void adminUserRemovesAnyFavoriteSiteWithSuccess() throws Exception { UserModel adminUser = dataUser.getAdminUser(); @@ -98,8 +135,9 @@ public class DeleteFavoriteSiteSanityTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify a user removes a site from another user's favorite sites list with Rest API and response is permission denied (403)") - public void userUserRemovesAnotherUserFavoriteSiteWithSuccess() throws Exception + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, + description = "Verify a user removes a site from another user's favorite sites list with Rest API and response is permission denied (403)") + public void userRemovesAnotherUserFavoriteSiteWithSuccess() throws Exception { UserModel userAuth = dataUser.usingAdmin().createRandomTestUser(); UserModel anotherUser = dataUser.usingAdmin().createRandomTestUser(); @@ -107,11 +145,17 @@ public class DeleteFavoriteSiteSanityTests extends RestTest dataSite.usingUser(anotherUser).usingSite(siteModel2).addSiteToFavorites(); restClient.authenticateUser(userAuth).withCoreAPI().usingUser(anotherUser).removeFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError() + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE) + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized to remove a site from its favorite sites list with Rest API when authentication fails (401)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, + description = "Verify manager user is NOT Authorized to remove a site from its favorite sites list with Rest API when authentication fails (401)") @Bug(id = "MNT-16904") public void managerUserNotAuthorizedFailsToRemoveFavoriteSite() throws Exception { @@ -122,6 +166,11 @@ public class DeleteFavoriteSiteSanityTests extends RestTest managerUser.setPassword("newpassword"); restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE) + .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY); } } From 1569321c12183e25601920c4a42b560ff0cd187d Mon Sep 17 00:00:00 2001 From: mionescu Date: Tue, 10 Jan 2017 15:54:21 +0200 Subject: [PATCH 0808/1491] test - added new tests for deleteFavoriteSite - full suite core - added new enums: PERMISSION_DENIED_ERRORKEY, NOT_FAVOURITE_SITE --- .../favorites/DeleteFavoritesSanityTests.java | 33 ++++++++++++++++--- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoritesSanityTests.java index 2503d7c7a..81264ab76 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoritesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoritesSanityTests.java @@ -53,7 +53,13 @@ public class DeleteFavoritesSanityTests extends RestTest restClient.authenticateUser(siteManager).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); restClient.withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel).assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingAuthUser().getFavorites().assertThat().entriesListDoesNotContain("targetGuid", siteModel.getGuid()); + restClient.withCoreAPI().usingAuthUser().getFavorites() + .assertThat() + .entriesListDoesNotContain("targetGuid", siteModel.getGuid()) + .and().entriesListDoesNotContain("id", siteModel.getId()) + .and().entriesListDoesNotContain("description", siteModel.getDescription()) + .and().entriesListDoesNotContain("visibility", siteModel.getVisibility().toString()) + .and().entriesListDoesNotContain("title", siteModel.getTitle()); } @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, @@ -65,7 +71,13 @@ public class DeleteFavoritesSanityTests extends RestTest restClient.authenticateUser(siteCollaborator).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); restClient.withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel).assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingAuthUser().getFavorites().assertThat().entriesListDoesNotContain("targetGuid", siteModel.getGuid()); + restClient.withCoreAPI().usingAuthUser().getFavorites() + .assertThat() + .entriesListDoesNotContain("targetGuid", siteModel.getGuid()) + .and().entriesListDoesNotContain("id", siteModel.getId()) + .and().entriesListDoesNotContain("description", siteModel.getDescription()) + .and().entriesListDoesNotContain("visibility", siteModel.getVisibility().toString()) + .and().entriesListDoesNotContain("title", siteModel.getTitle()); } @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, @@ -77,7 +89,13 @@ public class DeleteFavoritesSanityTests extends RestTest restClient.authenticateUser(siteContributor).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); restClient.withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel).assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingAuthUser().getFavorites().assertThat().entriesListDoesNotContain("targetGuid", siteModel.getGuid()); + restClient.withCoreAPI().usingAuthUser().getFavorites() + .assertThat() + .entriesListDoesNotContain("targetGuid", siteModel.getGuid()) + .and().entriesListDoesNotContain("id", siteModel.getId()) + .and().entriesListDoesNotContain("description", siteModel.getDescription()) + .and().entriesListDoesNotContain("visibility", siteModel.getVisibility().toString()) + .and().entriesListDoesNotContain("title", siteModel.getTitle()); } @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, @@ -89,7 +107,13 @@ public class DeleteFavoritesSanityTests extends RestTest restClient.authenticateUser(siteConsumer).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); restClient.withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel).assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingAuthUser().getFavorites().assertThat().entriesListDoesNotContain("targetGuid", siteModel.getGuid()); + restClient.withCoreAPI().usingAuthUser().getFavorites() + .assertThat() + .entriesListDoesNotContain("targetGuid", siteModel.getGuid()) + .and().entriesListDoesNotContain("id", siteModel.getId()) + .and().entriesListDoesNotContain("description", siteModel.getDescription()) + .and().entriesListDoesNotContain("visibility", siteModel.getVisibility().toString()) + .and().entriesListDoesNotContain("title", siteModel.getTitle()); } @Bug(id="MNT-16557") @@ -100,6 +124,7 @@ public class DeleteFavoritesSanityTests extends RestTest { UserModel siteCollaborator = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); restClient.authenticateUser(siteCollaborator).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI() .usingAuthUser().deleteSiteFromFavorites(siteModel) .assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); From fbdda1c6a8029d59960b9477d04903b2d909c76c Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Tue, 10 Jan 2017 15:59:37 +0200 Subject: [PATCH 0809/1491] TAS-2626, TAS-2627, TAS-2628 added new full tests and method to assed field is not present in entries --- .../people/GetPeopleActivitiesFullTests.java | 46 ++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesFullTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesFullTests.java index 5e01bb755..8950cd654 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesFullTests.java @@ -146,11 +146,55 @@ public class GetPeopleActivitiesFullTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot get activities for another user with Rest API and response is successful") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot get activities for another user with Rest API and response is permission denied") public void userGetPeopleActivitiesForAnotherUser() throws Exception { restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingUser(managerUser).getPersonActivities(); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); restClient.assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities with properties parameter applied with Rest API and response is successful") + public void userGetPeopleActivitiesUsingPropertiesParameter() throws Exception + { + restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingMe().usingParams("properties=postPersonId").getPersonActivities(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restActivityModelsCollection.assertThat().paginationField("count").is("4"); + restActivityModelsCollection.assertThat().entriesListContains("postPersonId", userModel.getUsername().toLowerCase()) + .and().entriesListContains("postPersonId", adminUser.getUsername().toLowerCase()) + .and().entriesListContains("postPersonId", managerUser.getUsername().toLowerCase()) + .and().entriesListDoesNotContain("postedAt") + .and().entriesListDoesNotContain("feedPersonId") + .and().entriesListDoesNotContain("siteId") + .and().entriesListDoesNotContain("activitySummary") + .and().entriesListDoesNotContain("id") + .and().entriesListDoesNotContain("activityType"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities with skipCount parameter applied with Rest API and response is successful") + public void userGetPeopleActivitiesUsingSkipCountParameter() throws Exception + { + restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingMe().usingParams("skipCount=2").getPersonActivities(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restActivityModelsCollection.assertThat().paginationField("count").is("2"); + restActivityModelsCollection.getEntries().get(0).onModel().assertThat().field("postPersonId").is(userModel.getUsername().toLowerCase()) + .and().field("activityType").is(ActivityType.FOLDER_ADDED.toString()); + restActivityModelsCollection.getEntries().get(1).onModel().assertThat().field("postPersonId").is(userModel.getUsername().toLowerCase()) + .and().field("activityType").is(ActivityType.FILE_ADDED.toString()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities with maxItems parameter applied with Rest API and response is successful") + public void userGetPeopleActivitiesUsingMaxItemsParameter() throws Exception + { + restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingMe().usingParams("maxItems=2").getPersonActivities(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restActivityModelsCollection.assertThat().paginationField("count").is("2"); + restActivityModelsCollection.getEntries().get(0).onModel().assertThat().field("postPersonId").is(managerUser.getUsername().toLowerCase()) + .and().field("activityType").is(ActivityType.USER_JOINED.toString()); + restActivityModelsCollection.getEntries().get(1).onModel().assertThat().field("postPersonId").is(adminUser.getUsername().toLowerCase()) + .and().field("activityType").is(ActivityType.FILE_ADDED.toString()); + } } From 476dd9ccd4739d84f024b49ff966523e51c04276 Mon Sep 17 00:00:00 2001 From: cagache Date: Tue, 10 Jan 2017 16:20:41 +0200 Subject: [PATCH 0810/1491] removed site setGuid --- .../alfresco/rest/favorites/AddFavoritesCoreTests.java | 3 +-- .../alfresco/rest/favorites/AddFavoritesSanityTests.java | 4 +--- .../rest/favorites/DeleteFavoritesSanityTests.java | 6 ++---- .../org/alfresco/rest/favorites/GetFavoriteCoreTests.java | 3 --- .../org/alfresco/rest/favorites/GetFavoriteFullTests.java | 3 --- .../alfresco/rest/favorites/GetFavoriteSanityTests.java | 8 +++----- .../alfresco/rest/favorites/GetFavoritesCoreTests.java | 4 ---- .../alfresco/rest/favorites/GetFavoritesSanityTests.java | 8 +++----- 8 files changed, 10 insertions(+), 29 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesCoreTests.java b/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesCoreTests.java index 04dcbb590..2c09b2b53 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesCoreTests.java @@ -38,8 +38,7 @@ public class AddFavoritesCoreTests extends RestTest public void dataPreparation() throws Exception { adminUserModel = dataUser.getAdminUser(); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - siteModel.setGuid(restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(siteModel).getSite().getGuid()); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); diff --git a/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesSanityTests.java index 2947d05c1..91fb77a7e 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesSanityTests.java @@ -26,9 +26,7 @@ public class AddFavoritesSanityTests extends RestTest public void dataPreparation() throws Exception { adminUserModel = dataUser.getAdminUser(); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - siteModel.setGuid(restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(siteModel).getSite().getGuid()); - + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); } diff --git a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoritesSanityTests.java index 2503d7c7a..52beb6783 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoritesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoritesSanityTests.java @@ -27,8 +27,6 @@ public class DeleteFavoritesSanityTests extends RestTest adminUserModel = dataUser.getAdminUser(); siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - siteModel.setGuid(restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(siteModel).getSite().getGuid()); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); } @@ -38,7 +36,7 @@ public class DeleteFavoritesSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) public void adminIsAbleToDeleteFavorites() throws JsonToModelConversionException, Exception { - restClient.withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); restClient.withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel).assertStatusCodeIs(HttpStatus.NO_CONTENT); restClient.withCoreAPI().usingAuthUser().getFavorites().assertThat().entriesListDoesNotContain("targetGuid", siteModel.getGuid()); @@ -132,7 +130,7 @@ public class DeleteFavoritesSanityTests extends RestTest .assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } - @Bug(id = "MNT-16904") + @Bug(id = "MNT-16904", description = "fails only on environment with tenants") @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify user gets status code 401 if authentication call fails") @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteCoreTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteCoreTests.java index c3b3e0668..ed87b7691 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteCoreTests.java @@ -36,9 +36,6 @@ public class GetFavoriteCoreTests extends RestTest { fileModel = dataContent.usingUser(adminUserModel).usingResource(folderModel) .createContent(DocumentType.TEXT_PLAIN); - siteModel.setGuid( - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(siteModel).getSite().getGuid()); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); } diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteFullTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteFullTests.java index 05323bb89..1ce47b42e 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteFullTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteFullTests.java @@ -39,9 +39,6 @@ public class GetFavoriteFullTests extends RestTest { fileModel = dataContent.usingUser(adminUserModel).usingResource(folderModel) .createContent(DocumentType.TEXT_PLAIN); - siteModel.setGuid( - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(siteModel).getSite().getGuid()); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); } diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java index 688ce6ff5..8a02c44f0 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java @@ -38,9 +38,6 @@ public class GetFavoriteSanityTests extends RestTest folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); fileModel = dataContent.usingUser(adminUserModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - siteModel.setGuid(restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(siteModel).getSite().getGuid()); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); } @@ -285,14 +282,15 @@ public class GetFavoriteSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify user gets status code 401 if authentication call fails") @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - @Bug(id = "MNT-16904") + @Bug(id = "MNT-16904", description = "fails only on environment with tenants") public void userIsNotAbleToRetrieveFavoritesIfAuthenticationFails() throws JsonToModelConversionException, Exception { UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); siteManager.setPassword("wrongPassword"); restClient.authenticateUser(siteManager).withCoreAPI() .usingUser(siteManager).getFavorite(siteModel.getGuid()); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } } diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesCoreTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesCoreTests.java index c75947d8c..94c4175f9 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesCoreTests.java @@ -37,10 +37,6 @@ public class GetFavoritesCoreTests extends RestTest secondFolderModel = dataContent.usingUser(adminUserModel).usingSite(firstSiteModel).createFolder(); firstFileModel = dataContent.usingUser(adminUserModel).usingResource(firstFolderModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); secondFileModel = dataContent.usingUser(adminUserModel).usingResource(firstFolderModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - - firstSiteModel.setGuid(restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(firstSiteModel).getSite().getGuid()); - secondSiteModel.setGuid(restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(secondSiteModel).getSite().getGuid()); - usersWithRoles = dataUser.addUsersWithRolesToSite(firstSiteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); } diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java index 35c671dba..38c0789f1 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java @@ -42,9 +42,6 @@ public class GetFavoritesSanityTests extends RestTest secondFolderModel = dataContent.usingUser(adminUserModel).usingSite(firstSiteModel).createFolder(); firstFileModel = dataContent.usingUser(adminUserModel).usingResource(firstFolderModel).createContent(DocumentType.TEXT_PLAIN); secondFileModel = dataContent.usingUser(adminUserModel).usingResource(firstFolderModel).createContent(DocumentType.TEXT_PLAIN); - - firstSiteModel.setGuid(restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(firstSiteModel).getSite().getGuidWithoutVersion()); - secondSiteModel.setGuid(restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(secondSiteModel).getSite().getGuidWithoutVersion()); usersWithRoles = dataUser.addUsersWithRolesToSite(firstSiteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); @@ -188,12 +185,13 @@ public class GetFavoritesSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify user gets status code 401 if authentication call fails") @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - @Bug(id="MNT-16904") + @Bug(id = "MNT-16904", description = "fails only on environment with tenants") public void userIsNotAbleToRetrieveFavoritesIfAuthenticationFails() throws JsonToModelConversionException, Exception { UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); siteManager.setPassword("wrongPassword"); restClient.authenticateUser(siteManager).withCoreAPI().usingAuthUser().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } } From 8bbe4754db576885fe87364be4718c2a6c775890 Mon Sep 17 00:00:00 2001 From: mionescu Date: Tue, 10 Jan 2017 16:36:59 +0200 Subject: [PATCH 0811/1491] test - added tenant tests --- .../people/DeleteFavoriteSiteFullTests.java | 185 ++++++++++++++++++ 1 file changed, 185 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteFullTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteFullTests.java new file mode 100644 index 000000000..16d74659b --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteFullTests.java @@ -0,0 +1,185 @@ +package org.alfresco.rest.people; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestSiteModel; +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.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class DeleteFavoriteSiteFullTests extends RestTest +{ + UserModel userModel; + SiteModel siteModel, siteModel1; + UserModel adminUserModel, adminTenantUser, tenantUser; + RestSiteModel restSiteModel; + ListUserWithRoles usersWithRoles; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + adminUserModel = dataUser.getAdminUser(); + + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }, executionType = ExecutionType.REGRESSION, + description = "User is not able to remove a favorite site of admin user") + public void userIsNotAbleToDeleteFavoritesOfAdmin() throws Exception + { + UserModel contributor = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); + dataSite.usingUser(contributor).usingSite(siteModel).addSiteToFavorites(); + + restClient.authenticateUser(contributor) + .withCoreAPI().usingUser(adminUserModel).removeFavoriteSite(siteModel); + + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError() + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }, executionType = ExecutionType.REGRESSION, + description = "Users removed twice from favorites same site.") + public void managerUserRemovesDeletedFavoriteSite() throws Exception + { + UserModel managerUser = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); + dataSite.usingUser(managerUser).usingSite(siteModel).addSiteToFavorites(); + + restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel); + restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.NOT_FAVOURITE_SITE, siteModel.getTitle())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }, executionType = ExecutionType.REGRESSION, + description = "Users removes from favorite a site that is already deleted.") + public void consumerUserRemovesDeletedFavoriteSite() throws Exception + { + siteModel1 = dataSite.usingUser(userModel).createPublicRandomSite(); + UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel1, UserRole.SiteConsumer); + dataSite.usingUser(consumerUser).usingSite(siteModel1).addSiteToFavorites(); + + dataSite.usingAdmin().deleteSite(siteModel1); + restClient.authenticateUser(consumerUser).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel1); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, + consumerUser.getUsername(), siteModel1.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }, executionType = ExecutionType.REGRESSION, + description = "Delete favorite site that is NOT favorite.") + public void adminUserRemovesDeletedFavoriteSiteThatIsNotFavorite() throws Exception + { + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.NOT_FAVOURITE_SITE, siteModel.getTitle())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify user doesn't have permission to delete favorites of another user with Rest API and status code is 403") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + public void userIsNotAbleToDeleteFavoritesOfAnotherUser() throws JsonToModelConversionException, Exception + { + UserModel siteCollaborator = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); + dataSite.usingUser(siteCollaborator).usingSite(siteModel).addSiteToFavorites(); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + .withCoreAPI() + .usingUser(siteCollaborator) + .removeFavoriteSite(siteModel); + + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError() + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Bug(id="MNT-16904") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify tenant user is not able to delete favorites using an invalid network ID") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.NETWORKS, TestGroup.FULL }) + public void tenantIsNotAbleToDeleteFavoriteSiteWithInvalidNetworkID() throws JsonToModelConversionException, Exception + { + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUserModel).usingTenant().createTenant(adminTenantUser); + tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + siteModel = dataSite.usingUser(tenantUser).createPublicRandomSite(); + siteModel.setGuid(restClient.authenticateUser(tenantUser).withCoreAPI().usingSite(siteModel).getSite().getGuid()); + restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + tenantUser.setDomain("invalidNetwork"); + + restClient.withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify tenant user deletes favorites site and status code is (204)") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.NETWORKS, TestGroup.FULL }) + public void tenantDeleteFavoriteSiteValidNetwork() throws JsonToModelConversionException, Exception + { + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUserModel).usingTenant().createTenant(adminTenantUser); + tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + siteModel = dataSite.usingUser(tenantUser).createPublicRandomSite(); + siteModel.setGuid(restClient.authenticateUser(tenantUser).withCoreAPI().usingSite(siteModel).getSite().getGuid()); + restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + tenantUser.setDomain(tenantUser.getDomain()); + + restClient.withCoreAPI() + .usingAuthUser().removeFavoriteSite(siteModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingAuthUser().getFavorites() + .assertThat() + .entriesListDoesNotContain("targetGuid", siteModel.getGuidWithoutVersion()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify tenant user deletes favorites site created by admin tenant - same network and status code is (204)") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.NETWORKS, TestGroup.FULL }) + public void tenantUserIsAbleToDeleteFavoriteSiteAddedByAdminSameNetwork() throws JsonToModelConversionException, Exception + { + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUserModel).usingTenant().createTenant(adminTenantUser); + tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); + siteModel.setGuid(restClient.authenticateUser(adminTenantUser).withCoreAPI().usingSite(siteModel).getSite().getGuid()); + restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + tenantUser.setDomain(adminTenantUser.getDomain()); + + restClient.withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingAuthUser().getFavorites() + .assertThat() + .entriesListDoesNotContain("targetGuid", siteModel.getGuidWithoutVersion()); + } + +} From bf07742569512ae9c035161cbdb25501781a8f77 Mon Sep 17 00:00:00 2001 From: mionescu Date: Tue, 10 Jan 2017 16:38:29 +0200 Subject: [PATCH 0812/1491] updated tenant tests --- .../org/alfresco/rest/favorites/DeleteFavoriteFullTests.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteFullTests.java b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteFullTests.java index f79958390..7efeca5e9 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteFullTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteFullTests.java @@ -218,7 +218,7 @@ public class DeleteFavoriteFullTests extends RestTest restClient.withCoreAPI().usingAuthUser().getFavorites() .assertThat() - .entriesListDoesNotContain("targetGuid", fileModel.getNodeRefWithoutVersion()); + .entriesListDoesNotContain("targetGuid", siteModel.getGuidWithoutVersion()); } @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, @@ -240,7 +240,7 @@ public class DeleteFavoriteFullTests extends RestTest restClient.withCoreAPI().usingAuthUser().getFavorites() .assertThat() - .entriesListDoesNotContain("targetGuid", fileModel.getNodeRefWithoutVersion()); + .entriesListDoesNotContain("targetGuid", siteModel.getGuidWithoutVersion()); } } From 2985490aedb2da49fd24c23b5e342ae904228be6 Mon Sep 17 00:00:00 2001 From: cagache Date: Tue, 10 Jan 2017 16:59:01 +0200 Subject: [PATCH 0813/1491] addSiteMembershipRequest test with tenant --- .../AddSiteMembershipRequestFullTests.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestFullTests.java b/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestFullTests.java index 1e60b408a..dd418e472 100644 --- a/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestFullTests.java +++ b/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestFullTests.java @@ -142,7 +142,15 @@ public class AddSiteMembershipRequestFullTests extends RestTest siteMembershipRequest = restClient.authenticateUser(regularUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); restClient.assertStatusCodeIs(HttpStatus.CREATED); siteMembershipRequest.assertThat().field("id").is(moderatedSite.getId()) + .assertThat().field("message").is("Please accept me") .assertThat().field("site").isNotEmpty(); + siteMembershipRequest.getSite() + .assertThat().field("visibility").is(moderatedSite.getVisibility()) + .assertThat().field("guid").is(moderatedSite.getGuid()) + .assertThat().field("description").is(moderatedSite.getDescription()) + .assertThat().field("id").is(moderatedSite.getId()) + .assertThat().field("title").is(moderatedSite.getTitle()); + siteMembershipRequests = restClient.withCoreAPI().usingAuthUser().getSiteMembershipRequests(); restClient.assertStatusCodeIs(HttpStatus.OK); siteMembershipRequests.assertThat().entriesListContains("id", moderatedSite.getId()) @@ -267,6 +275,23 @@ public class AddSiteMembershipRequestFullTests extends RestTest .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, adminTenantUser.getUsername().toLowerCase(), publicSite.getId())); } + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL, TestGroup.NETWORKS }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify create site membership request returns status code 200 with tenant.") + public void addSiteMembershipRequestWithTenant() throws Exception + { + UserModel adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser) + .usingTenant().createTenant(adminTenantUser); + UserModel tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + + SiteModel tenantPublicSite = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); + siteMembershipRequest = restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(tenantPublicSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + siteMembershipRequest.assertThat().field("id").is(tenantPublicSite.getId()) + .assertThat().field("site").isNotEmpty(); + } + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site membership request is automatically rejected when a site is switched from moderated to private") From 0a749e340e56003f625c6d4506876aaf7ece68ed Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Tue, 10 Jan 2017 16:59:33 +0200 Subject: [PATCH 0814/1491] TAS-2616 added new full test, added new method for get activity list without retry --- .../people/GetPeopleActivitiesFullTests.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesFullTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesFullTests.java index 8950cd654..df5246458 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesFullTests.java @@ -16,6 +16,7 @@ import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -50,6 +51,11 @@ public class GetPeopleActivitiesFullTests extends RestTest managerUser = dataUser.createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel2, UserRole.SiteManager); + + // only once the activity list is checked with retry in order not to wait the entire list in each test + restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingMe().getPersonActivitiesWithRetry(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restActivityModelsCollection.assertThat().paginationField("count").is("4"); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.FULL }) @@ -72,6 +78,24 @@ public class GetPeopleActivitiesFullTests extends RestTest restActivityModelsCollection.assertThat().entriesListContains("activityType", ActivityType.USER_JOINED.toString()); } + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify activity summary from user gets activities response with Rest API") + public void userGetPeopleActivitiesWithActivitySummaryCheck() throws Exception + { + restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingMe().getPersonActivities(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restActivityModelsCollection.assertThat().paginationField("count").is("4"); + RestActivitySummaryModel summary = restActivityModelsCollection.getEntries().get(0).onModel().getActivitySummary(); + summary.assertThat().field("firstName").is(managerUser.getUsername() + " FirstName") + .and().field("lastName").is("LN-" + managerUser.getUsername()) + .and().field("memberFirstName").is(managerUser.getUsername() + " FirstName") + .and().field("role").is(managerUser.getUserRole()) + .and().field("memberLastName").is("LN-" + managerUser.getUsername()) + .and().field("title").is(String.format("%s FirstName LN-%s (%s)", managerUser.getUsername(), managerUser.getUsername(), managerUser.getUsername())) + .and().field("memberPersonId").is(managerUser.getUsername()); + } + + @Bug(id = "ACE-5460") @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.FULL }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot get activities for empty user with Rest API and response is 404") public void userCannotGetPeopleActivitiesForEmptyPersonId() throws Exception From 43c8011d92e63efe25fa4bb8a9fcaa53828b7568 Mon Sep 17 00:00:00 2001 From: mionescu Date: Tue, 10 Jan 2017 17:01:14 +0200 Subject: [PATCH 0815/1491] test- added - deleteFavoriteIfPersonIdIsEmpty --- .../rest/favorites/DeleteFavoriteCoreTests.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteCoreTests.java b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteCoreTests.java index 3c61a76a6..bd49c254a 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteCoreTests.java @@ -55,6 +55,18 @@ public class DeleteFavoriteCoreTests extends RestTest .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "inexistent")); } + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that status code is 404 if PersonID is empty - favorite file.") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE}) + public void deleteFavoriteIfPersonIdIsEmpty() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); + restClient.withCoreAPI().usingAuthUser().addFileToFavorites(fileModel); + + restClient.withCoreAPI().usingUser(new UserModel ("", "")) + .deleteFileFromFavorites(fileModel).assertStatusCodeIs(HttpStatus.BAD_REQUEST); + } + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify that status code is 404 if FavoriteID is incorrect - favorite file.") @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE}) From 903565ff19ae85af8275af4609d2bc87a6ef349f Mon Sep 17 00:00:00 2001 From: mionescu Date: Tue, 10 Jan 2017 17:03:47 +0200 Subject: [PATCH 0816/1491] updated test (deleteFavoriteIfPersonIdIsEmpty)- added bugID --- .../org/alfresco/rest/favorites/DeleteFavoriteCoreTests.java | 1 + 1 file changed, 1 insertion(+) diff --git a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteCoreTests.java b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteCoreTests.java index bd49c254a..15c954a6f 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteCoreTests.java @@ -55,6 +55,7 @@ public class DeleteFavoriteCoreTests extends RestTest .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "inexistent")); } + @Bug(id="ACE-2413") @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify that status code is 404 if PersonID is empty - favorite file.") @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE}) From 789f6afabdbc39d62758da0823d2abccb5624bc4 Mon Sep 17 00:00:00 2001 From: cagache Date: Tue, 10 Jan 2017 17:12:55 +0200 Subject: [PATCH 0817/1491] TAS-2707 getSiteMembershipRequest test "valid request (0.0) -> json schema validation to be done" --- .../GetSiteMembershipRequestsSanityTests.java | 73 ++++++++++--------- 1 file changed, 38 insertions(+), 35 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java index 34990bddd..78a08b88e 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java @@ -1,7 +1,10 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestSiteMembershipRequestModelsCollection; import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.RandomData; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; @@ -22,21 +25,21 @@ import org.testng.annotations.Test; public class GetSiteMembershipRequestsSanityTests extends RestTest { - UserModel userModel; - SiteModel siteModel; - UserModel newMember; + UserModel siteManager, newMember; + DataUser.ListUserWithRoles usersWithRoles; + SiteModel moderatedSite; + RestSiteMembershipRequestModelsCollection siteMembershipRequests; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception { - userModel = dataUser.createRandomTestUser(); - String siteId = RandomData.getRandomName("site"); - siteModel = dataSite.usingUser(userModel).createSite(new SiteModel(Visibility.MODERATED, siteId, siteId, siteId, siteId)); + siteManager = dataUser.createRandomTestUser(); + moderatedSite = dataSite.usingUser(siteManager).createModeratedRandomSite(); newMember = dataUser.createRandomTestUser(); - - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(siteModel); - + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); restClient.assertStatusCodeIs(HttpStatus.CREATED); + usersWithRoles = dataUser.addUsersWithRolesToSite(moderatedSite, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) @@ -44,11 +47,10 @@ public class GetSiteMembershipRequestsSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user gets all site membership requests of a specific person with Rest API and response is successful (200)") public void managerUserGetsSiteMembershipRequestsWithSuccess() throws Exception { - UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); - - restClient.authenticateUser(managerUser).withCoreAPI().usingUser(newMember).getSiteMembershipRequests().assertThat().entriesListIsNotEmpty(); + siteMembershipRequests = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI() + .usingUser(newMember).getSiteMembershipRequests(); restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembershipRequests.assertThat().entriesListIsNotEmpty(); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) @@ -56,10 +58,8 @@ public class GetSiteMembershipRequestsSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify collaborator user fails to get all site membership requests of another user with Rest API (403)") public void collaboratorUserFailsToGetSiteMembershipRequestsOfAnotherUser() throws Exception { - UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(collaboratorUser, siteModel, UserRole.SiteCollaborator); - - restClient.authenticateUser(collaboratorUser).withCoreAPI().usingUser(newMember).getSiteMembershipRequests(); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI() + .usingUser(newMember).getSiteMembershipRequests(); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); } @@ -68,10 +68,8 @@ public class GetSiteMembershipRequestsSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify contributor user fails to get all site membership requests of another user with Rest API (403)") public void contributorUserFailsToGetSiteMembershipRequestsOfAnotherUser() throws Exception { - UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(contributorUser, siteModel, UserRole.SiteContributor); - - restClient.authenticateUser(contributorUser).withCoreAPI().usingUser(newMember).getSiteMembershipRequests(); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI() + .usingUser(newMember).getSiteMembershipRequests(); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); } @@ -80,10 +78,7 @@ public class GetSiteMembershipRequestsSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify consumer user fails to get all site membership requests of another user with Rest API (403)") public void consumerUserFailsToGetSiteMembershipRequestsOfAnotherUser() throws Exception { - UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel, UserRole.SiteConsumer); - - restClient.authenticateUser(consumerUser).withCoreAPI().usingUser(newMember).getSiteMembershipRequests(); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingUser(newMember).getSiteMembershipRequests(); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); } @@ -92,29 +87,37 @@ public class GetSiteMembershipRequestsSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify admin user gets all site membership requests of a specific person with Rest API and response is successful (200)") public void adminUserGetsSiteMembershipRequestsWithSuccess() throws Exception { - UserModel adminUser = dataUser.getAdminUser(); - - restClient.authenticateUser(adminUser).withCoreAPI().usingUser(newMember).getSiteMembershipRequests().assertThat().entriesListIsNotEmpty(); + siteMembershipRequests = restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI() + .usingUser(newMember).getSiteMembershipRequests(); restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembershipRequests.assertThat().entriesListIsNotEmpty(); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) @Bug(id = "MNT-16904") @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user fails to get all site membership requests of a specific person with Rest API when the authentication fails (401)") - public void managerUserNotAuthorizedFailsToGetSiteMembershipRequests() throws Exception + public void unauthorizedUserFailsToGetSiteMembershipRequests() throws Exception { - UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); - managerUser.setPassword("newpassword"); - restClient.authenticateUser(managerUser).withCoreAPI().usingUser(newMember).getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.authenticateUser(new UserModel("random user", "random password")).withCoreAPI() + .usingAuthUser().getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify a user gets all its own site membership requests with Rest API and response is successful (200)") public void oneUserGetsItsOwnSiteMembershipRequestsWithSuccess() throws Exception { - restClient.authenticateUser(newMember).withCoreAPI().usingUser(newMember).getSiteMembershipRequests().assertThat().entriesListIsNotEmpty(); + siteMembershipRequests = restClient.authenticateUser(newMember).withCoreAPI().usingUser(newMember).getSiteMembershipRequests(); restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembershipRequests.assertThat().entriesListContains("id", moderatedSite.getId()) + .assertThat().entriesListContains("message", "Please accept me") + .assertThat().entriesListCountIs(1); + siteMembershipRequests.getEntries().get(0).onModel().getSite() + .assertThat().field("visibility").is(moderatedSite.getVisibility()) + .assertThat().field("guid").is(moderatedSite.getGuid()) + .assertThat().field("description").is(moderatedSite.getDescription()) + .assertThat().field("id").is(moderatedSite.getId()) + .assertThat().field("title").is(moderatedSite.getTitle()); } } From 722d062b716c86f1a4396754f6c4f7cd013a1df0 Mon Sep 17 00:00:00 2001 From: cagache Date: Tue, 10 Jan 2017 17:15:13 +0200 Subject: [PATCH 0818/1491] TAS-2705 getSiteMembershipRequest test "check default error schema" --- .../GetSiteMembershipRequestsCoreTests.java | 71 +++++++++++++------ 1 file changed, 50 insertions(+), 21 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsCoreTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsCoreTests.java index dae11e055..b82ea8998 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsCoreTests.java @@ -35,30 +35,46 @@ public class GetSiteMembershipRequestsCoreTests extends RestTest newMember = dataUser.createRandomTestUser(); restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify that for invalid maxItems parameter status code returned is 400.") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, + description = "Verify that for invalid maxItems parameter status code returned is 400.") @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) public void checkInvalidMaxItemsStatusCode() throws Exception { - restClient.authenticateUser(adminUser).withParams("maxItems=AB").withCoreAPI().usingUser(newMember).getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Invalid paging parameter"); + restClient.authenticateUser(adminUser).withParams("maxItems=AB") + .withCoreAPI().usingUser(newMember).getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "AB")); + + restClient.authenticateUser(adminUser).withParams("maxItems=0") + .withCoreAPI().usingUser(newMember).getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify that for invalid skipCount parameter status code returned is 400.") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, + description = "Verify that for invalid skipCount parameter status code returned is 400.") @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) public void checkInvalidSkipCountStatusCode() throws Exception { - restClient.authenticateUser(adminUser).withParams("skipCount=AB").withCoreAPI().usingUser(newMember).getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Invalid paging parameter"); + restClient.authenticateUser(adminUser).withParams("skipCount=AB") + .withCoreAPI().usingUser(newMember).getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "AB")); + + restClient.authenticateUser(adminUser).withParams("skipCount=-1") + .withCoreAPI().usingUser(newMember).getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify that if personId does not exist status code returned is 404.") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, + description = "Verify that if personId does not exist status code returned is 404.") @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) public void ifPersonIdDoesNotExist() throws Exception { @@ -66,11 +82,17 @@ public class GetSiteMembershipRequestsCoreTests extends RestTest nonexistentUser.setUsername("nonexistent"); restClient.authenticateUser(adminUser).withCoreAPI().usingUser(nonexistentUser).getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "nonexistent")); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "nonexistent")) + .statusCodeIs(HttpStatus.NOT_FOUND) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Specify -me- string in place of for request.") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, + description = "Specify -me- string in place of for request.") @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) public void replacePersonIdWithMeRequest() throws Exception { @@ -81,7 +103,9 @@ public class GetSiteMembershipRequestsCoreTests extends RestTest returnedCollection.assertThat().entriesListContains("id", moderatedSite.getId()); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify that if empty personId is used status code returned is 404.") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, + description = "Verify that if empty personId is used status code returned is 404.") @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) public void useEmptyPersonId() throws Exception { @@ -89,11 +113,13 @@ public class GetSiteMembershipRequestsCoreTests extends RestTest emptyNameMember.setUsername(" "); restClient.authenticateUser(adminUser).withCoreAPI().usingUser(emptyNameMember).getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary("The entity with id: " + emptyNameMember.getUsername() + " was not found"); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, emptyNameMember.getUsername())); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Get site membership requests to a public site.") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, + description = "Get site membership requests to a public site.") @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) public void getRequestsToPublicSite() throws Exception { @@ -105,8 +131,9 @@ public class GetSiteMembershipRequestsCoreTests extends RestTest returnedCollection.assertThat().entriesListDoesNotContain("id", publicSite.getId()); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Get site membership requests to a moderated site.") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, + description = "Get site membership requests to a moderated site.") @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) public void getRequestsToModeratedSite() throws Exception { @@ -117,7 +144,9 @@ public class GetSiteMembershipRequestsCoreTests extends RestTest returnedCollection.assertThat().entriesListContains("id", moderatedSite.getId()); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Approve request then get requests.") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, + description = "Approve request then get requests.") @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) public void approveRequestThenGetRequests() throws Exception { From 955ad87826ee8174d0d5ec39ed56693b3806c4b2 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Tue, 10 Jan 2017 17:39:43 +0200 Subject: [PATCH 0819/1491] update log4j to include threads --- e2e-test/resources/log4j.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e-test/resources/log4j.properties b/e2e-test/resources/log4j.properties index ede92a004..00e9b5a11 100644 --- a/e2e-test/resources/log4j.properties +++ b/e2e-test/resources/log4j.properties @@ -6,13 +6,13 @@ log4j.appender.file=org.apache.log4j.RollingFileAppender log4j.appender.file.File=./target/reports/alfresco-tas.log log4j.appender.file.MaxBackupIndex=10 log4j.appender.file.layout=org.apache.log4j.PatternLayout -log4j.appender.file.layout.ConversionPattern=%d{HH:mm:ss} %-5p %c{1}:%L - %m%n +log4j.appender.file.layout.ConversionPattern=[%t] %d{HH:mm:ss} %-5p %c{1}:%L - %m%n # Direct log messages to stdout log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.Target=System.out log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=%d{HH:mm:ss} %-5p %c{1}:%L - %m%n +log4j.appender.stdout.layout.ConversionPattern=[%t] %d{HH:mm:ss} %-5p %c{1}:%L - %m%n # TestRail particular log file # Direct log messages to a log file From 70894b1ce7ecbe1d69f1db90701290986f569a1e Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Tue, 10 Jan 2017 17:42:23 +0200 Subject: [PATCH 0820/1491] added core tests for GetPeopleActivities --- .../people/GetPeopleActivitiesCoreTests.java | 127 ++++++++++++++++++ .../people/GetPeopleActivitiesFullTests.java | 6 +- .../GetPeopleActivitiesSanityTests.java | 5 + 3 files changed, 135 insertions(+), 3 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesCoreTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesCoreTests.java new file mode 100644 index 000000000..1ecc70160 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesCoreTests.java @@ -0,0 +1,127 @@ +package org.alfresco.rest.people; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestActivityModelsCollection; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.utility.constants.ActivityType; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * + * @author Cristina Axinte + * + */ +public class GetPeopleActivitiesCoreTests extends RestTest +{ + UserModel userModel, adminUser, managerUser; + SiteModel siteModel1, siteModel2; + FileModel fileInSite1, fileInSite2; + FolderModel folderInSite2; + private RestActivityModelsCollection restActivityModelsCollection; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userModel = dataUser.createRandomTestUser(); + siteModel1 = dataSite.usingUser(userModel).createPublicRandomSite(); + fileInSite1 = dataContent.usingUser(userModel).usingSite(siteModel1).createContent(DocumentType.TEXT_PLAIN); + + siteModel2 = dataSite.usingUser(userModel).createPublicRandomSite(); + folderInSite2 = dataContent.usingUser(userModel).usingSite(siteModel2).createFolder(); + fileInSite2 = dataContent.usingAdmin().usingSite(siteModel2).createContent(DocumentType.TEXT_PLAIN); + + managerUser = dataUser.createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel2, UserRole.SiteManager); + + // only once the activity list is checked with retry in order not to wait the entire list in each test + restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingMe().getPersonActivitiesWithRetry(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restActivityModelsCollection.assertThat().paginationField("count").is("4"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot get activities for inexistent user with Rest API and response is 404") + public void userCannotGetPeopleActivitiesForInexistentPersonId() throws Exception + { + UserModel inexistentUserName = new UserModel("inexistent", "password"); + + restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingUser(inexistentUserName).getPersonActivities(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, inexistentUserName.getUsername())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its activities for inexistent siteId with Rest API and response is 404") + public void userGetItsPeopleActivitiesForInexistentSite() throws Exception + { + restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingUser(userModel).usingParams(String.format("siteId=inexistent")).getPersonActivities(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "inexistent")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities with invald skipCount parameter with Rest API and response is 400") + public void userGetPeopleActivitiesUsingSkipCountParameter() throws Exception + { + restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingMe().usingParams("skipCount=-1").getPersonActivities(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsErrorKey(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT) + .containsSummary(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities with invalid maxItems parameter with Rest API and response is 400") + public void userGetPeopleActivitiesUsingMaxItemsParameter() throws Exception + { + restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingMe().usingParams("maxItems=0").getPersonActivities(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsErrorKey(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) + .containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities using invalid value for parameter 'who'with Rest API and response is 400") + public void userGetsPeopleActivitiesUsingMeForWhoParameter() throws Exception + { + restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingUser(userModel).usingParams("who=mee").getPersonActivities(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsErrorKey(RestErrorModel.INVALID_PARAMETER_WHO) + .containsSummary(RestErrorModel.INVALID_PARAMETER_WHO) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities successfully using parameter 'who' with 'others' value with Rest API") + public void userGetsPeopleActivitiesUsingOthersForWhoParameter() throws Exception + { + restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingUser(userModel).usingParams("who=others").getPersonActivities(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restActivityModelsCollection.assertThat().paginationField("count").is("2"); + restActivityModelsCollection.assertThat().entriesListDoesNotContain("postPersonId", userModel.getUsername().toLowerCase()) + .and().entriesListContains("postPersonId", adminUser.getUsername().toLowerCase()) + .and().entriesListContains("postPersonId", managerUser.getUsername().toLowerCase()); + } +} diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesFullTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesFullTests.java index df5246458..f6536c095 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesFullTests.java @@ -97,13 +97,13 @@ public class GetPeopleActivitiesFullTests extends RestTest @Bug(id = "ACE-5460") @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot get activities for empty user with Rest API and response is 404") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot get activities for empty user with Rest API and response is 400") public void userCannotGetPeopleActivitiesForEmptyPersonId() throws Exception { UserModel emptyUserName = new UserModel("", "password"); restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingUser(emptyUserName).getPersonActivities(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) .assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) .containsSummary(RestErrorModel.LOCAL_NAME_CONSISTANCE) .stackTraceIs(RestErrorModel.STACKTRACE) @@ -111,7 +111,7 @@ public class GetPeopleActivitiesFullTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities successfully using parameter 'who' with 'me'vale with Rest API") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities successfully using parameter 'who' with 'me' value with Rest API") public void userGetsPeopleActivitiesUsingMeForWhoParameter() throws Exception { restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingUser(userModel).usingParams("who=me").getPersonActivities(); diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java index 0e3f3cd59..96fb63082 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java @@ -37,6 +37,11 @@ public class GetPeopleActivitiesSanityTests extends RestTest UserRole.SiteContributor); unauthenticatedUser = dataUser.usingAdmin().createRandomTestUser(); unauthenticatedUser.setPassword("newpassword"); + + // only once the activity list is checked with retry in order not to wait the entire list in each test + restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().getPersonActivitiesWithRetry(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restActivityModelsCollection.assertThat().entriesListIsNotEmpty(); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.SANITY }) From f99172d611c096ca4d770b814aa81f452a5d271f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alecsandru=20Prun=C4=83?= Date: Tue, 10 Jan 2017 16:34:31 +0200 Subject: [PATCH 0821/1491] test: Added GET people/{personId}/favorite-sites core and full tests --- .../people/GetFavoriteSitesCoreTests.java | 131 +++++++++++++++ .../people/GetFavoriteSitesFullTests.java | 150 ++++++++++++++++++ .../people/GetFavoriteSitesSanityTests.java | 1 - 3 files changed, 281 insertions(+), 1 deletion(-) create mode 100644 e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesCoreTests.java create mode 100644 e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesCoreTests.java b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesCoreTests.java new file mode 100644 index 000000000..5d2faab27 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesCoreTests.java @@ -0,0 +1,131 @@ +package org.alfresco.rest.people; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestSiteModelsCollection; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.data.RandomData; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class GetFavoriteSitesCoreTests extends RestTest +{ + UserModel userModel; + UserModel testUser1; + SiteModel siteModel; + private RestSiteModelsCollection restSiteModelsCollection; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + testUser1 = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + dataSite.usingUser(userModel).usingSite(siteModel).addSiteToFavorites(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify that getFavoriteSites request status code is 404 for a personId that does not exist") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + public void getFavoriteSitesReturns404ForAPersonIdThatDoesNotExist() throws Exception + { + UserModel invalidUser = new UserModel(RandomData.getRandomName("User"), DataUser.PASSWORD); + + restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingUser(invalidUser).getFavoriteSites(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, invalidUser.getUsername())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify that getFavoriteSites request status code is 403 if the user doesn't have access to the person favorite sites") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + public void userCannotGetFavoriteSitesForAnotherUser() throws Exception + { + restClient.authenticateUser(userModel).withCoreAPI().usingUser(testUser1).getFavoriteSites(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsErrorKey(RestErrorModel.PERMISION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin has access to regular user site favorites") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + public void adminCanGetFavoriteSitesForARegularUser() throws Exception + { + restSiteModelsCollection = restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingUser(userModel).getFavoriteSites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteModelsCollection.assertThat().entriesListIsNotEmpty() + .assertThat().entriesListContains("id", siteModel.getId()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify that regular user can not see admin user site favorites") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + public void regularUserCannotGetFavoriteSitesForAdminUser() throws Exception + { + restClient.authenticateUser(testUser1).withCoreAPI().usingUser(dataUser.getAdminUser()).getFavoriteSites(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsErrorKey(RestErrorModel.PERMISION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify that favorite site can be removed") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + public void verifyThatFavoriteSiteCanBeRemoved() throws Exception + { + UserModel randomTestUser = dataUser.createRandomTestUser(); + dataSite.usingUser(randomTestUser).usingSite(siteModel).addSiteToFavorites(); + + restSiteModelsCollection = restClient.authenticateUser(randomTestUser).withCoreAPI().usingAuthUser().getFavoriteSites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteModelsCollection.assertThat().entriesListIsNotEmpty() + .assertThat().entriesListContains("id", siteModel.getId()); + + dataSite.usingUser(randomTestUser).usingSite(siteModel).removeSiteFromFavorites(); + restSiteModelsCollection = restClient.withCoreAPI().usingAuthUser().getFavoriteSites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteModelsCollection.assertThat().entriesListIsEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify that if maxItems param is invalid status code returned is BAD_REQUEST (400)") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + public void getFavoriteSitesMaxItemsInvalidValueTest() throws Exception + { + restClient.authenticateUser(userModel).withParams("maxItems=-1").withCoreAPI().usingAuthUser().getFavoriteSites(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); + + restClient.authenticateUser(userModel).withParams("maxItems=abc").withCoreAPI().usingAuthUser().getFavoriteSites(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "abc")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify that if skipCount param is invalid status code returned is BAD_REQUEST (400)") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + public void getFavoriteSitesSkipCountInvalidValueTest() throws Exception + { + restClient.authenticateUser(userModel).withParams("skipCount=-1").withCoreAPI().usingAuthUser().getFavoriteSites(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT); + + restClient.authenticateUser(userModel).withParams("skipCount=abc").withCoreAPI().usingAuthUser().getFavoriteSites(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "abc")); + } +} diff --git a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesFullTests.java b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesFullTests.java new file mode 100644 index 000000000..3c585f3de --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesFullTests.java @@ -0,0 +1,150 @@ +package org.alfresco.rest.people; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestSiteModel; +import org.alfresco.rest.model.RestSiteModelsCollection; +import org.alfresco.utility.data.RandomData; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class GetFavoriteSitesFullTests extends RestTest +{ + UserModel userModel; + SiteModel siteModel; + SiteModel testSite1; + SiteModel testSite2; + private RestSiteModelsCollection restSiteModelsCollection; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + testSite1 = dataSite.usingUser(userModel).createPublicRandomSite(); + testSite2 = dataSite.usingUser(userModel).createPublicRandomSite(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify that getFavoriteSites request response status using -me- string in place of personId is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + public void userGetsFavoriteSiteWithSuccessUsingMEForRequest() throws Exception + { + UserModel randomTestUser = dataUser.createRandomTestUser(); + dataSite.usingUser(randomTestUser).usingSite(siteModel).addSiteToFavorites(); + + restSiteModelsCollection = restClient.authenticateUser(randomTestUser).withCoreAPI().usingMe().getFavoriteSites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteModelsCollection.assertThat().entriesListIsNotEmpty() + .and().entriesListContains("id", siteModel.getId()) + .and().paginationExist(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify that getFavoriteSites request response status for a user that has no favorite sites is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + public void getFavoriteSiteRequestForUserWithNoFavoriteSitesIsSuccessful() throws Exception + { + UserModel randomTestUser = dataUser.createRandomTestUser(); + + restSiteModelsCollection = restClient.authenticateUser(randomTestUser).withCoreAPI().usingMe().getFavoriteSites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteModelsCollection.assertThat().entriesListIsEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify that getFavoriteSites request response status for a user with several favorite sites is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + public void getFavoriteSiteRequestForUserWithSeveralFavoriteSitesIsSuccessful() throws Exception + { + UserModel randomTestUser = dataUser.createRandomTestUser(); + dataSite.usingUser(randomTestUser).usingSite(siteModel).addSiteToFavorites(); + dataSite.usingUser(randomTestUser).usingSite(testSite1).addSiteToFavorites(); + dataSite.usingUser(randomTestUser).usingSite(testSite2).addSiteToFavorites(); + + restSiteModelsCollection = restClient.authenticateUser(randomTestUser).withCoreAPI().usingAuthUser().getFavoriteSites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteModelsCollection.assertThat().entriesListIsNotEmpty() + .and().entriesListContains("id", siteModel.getId()) + .and().entriesListContains("id", testSite1.getId()) + .and().entriesListContains("id", testSite2.getId()) + .and().paginationExist(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify that getFavoriteSites request can only be called with a positive maxItems param") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + public void userCanNotGetFavoriteSitesWith0MaxItems() throws Exception + { + restClient.authenticateUser(userModel).withParams("maxItems=0").withCoreAPI().usingAuthUser().getFavoriteSites(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsErrorKey(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) + .containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify that getFavoriteSites request response status code for a high skipCount param is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + public void userCanGetFavoriteSitesWithHighSkipCount() throws Exception + { + restSiteModelsCollection = restClient.authenticateUser(userModel).withParams("skipCount=999999999").withCoreAPI().usingAuthUser().getFavoriteSites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteModelsCollection.assertThat().entriesListIsEmpty() + .assertThat().paginationField("skipCount").is("999999999"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify admin gets favorite sites for username with special chars with Rest API and response status is NOT_FOUND (404)") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + public void getFavoriteSitesRequestForPersonIDWithSpecialCharacters() throws Exception + { + String randomData = RandomData.getRandomAlphanumeric(); + UserModel userSpecialChars = dataUser.usingAdmin().createUser(randomData + "~!@#$%^&[]{}|\\;':\",./<>", "password"); + //setting the encoded text for username + userSpecialChars.setUsername(randomData + "~!%40%23%24%25%5E%26%5B%5D%7B%7D%7C%5C%3B%27%3A%22%2C.%2F%3C%3E"); + + restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingUser(userSpecialChars).getFavoriteSites(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, randomData + "~!%40%23%24%25%5E%26%5B%5D%7B%7D%7C%5C%3B%27%3A%22%2C.%2F%3C%3E")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify that getFavoriteSites request applies valid properties param") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + public void getFavoriteSitesRequestWithValidPropertiesParam() throws Exception + { + UserModel randomTestUser = dataUser.createRandomTestUser(); + dataSite.usingUser(randomTestUser).usingSite(siteModel).addSiteToFavorites(); + + RestSiteModel restSiteModel = restClient.authenticateUser(randomTestUser).withParams("properties=title") + .withCoreAPI().usingAuthUser().getFavoriteSites().getOneRandomEntry().onModel(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteModel.assertThat().fieldCount().is(0) + .assertThat().field("title").is(siteModel.getTitle()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify that getFavoriteSites request applies invalid properties param") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + public void getFavoriteSitesRequestWithInvalidPropertiesParam() throws Exception + { + UserModel randomTestUser = dataUser.createRandomTestUser(); + dataSite.usingUser(randomTestUser).usingSite(siteModel).addSiteToFavorites(); + + restClient.authenticateUser(randomTestUser).withParams("properties=tas").withCoreAPI().usingAuthUser() + .getFavoriteSites().getOneRandomEntry().onModel().assertThat().fieldCount().is(0); + restClient.assertStatusCodeIs(HttpStatus.OK); + } +} diff --git a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java index 840157a6b..9f6845b8b 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java @@ -18,7 +18,6 @@ public class GetFavoriteSitesSanityTests extends RestTest { UserModel userModel; SiteModel siteModel; - UserModel searchedUser; private RestSiteModelsCollection restSiteModelsCollection; @BeforeClass(alwaysRun = true) From d6abf80d7ad55ba83bd944171d89ac375405ca3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alecsandru=20Prun=C4=83?= Date: Wed, 11 Jan 2017 09:45:57 +0200 Subject: [PATCH 0822/1491] Reused userModel in tests --- .../people/GetFavoriteSitesFullTests.java | 55 +++++++++++-------- 1 file changed, 32 insertions(+), 23 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesFullTests.java b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesFullTests.java index 3c585f3de..6c0f816fd 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesFullTests.java @@ -26,9 +26,18 @@ public class GetFavoriteSitesFullTests extends RestTest public void dataPreparation() throws Exception { userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - testSite1 = dataSite.usingUser(userModel).createPublicRandomSite(); - testSite2 = dataSite.usingUser(userModel).createPublicRandomSite(); + + siteModel = new SiteModel("A-" + RandomData.getRandomAlphanumeric()); + testSite1 = new SiteModel("B-" + RandomData.getRandomAlphanumeric()); + testSite2 = new SiteModel("C-" + RandomData.getRandomAlphanumeric()); + + dataSite.usingUser(userModel).createSite(siteModel); + dataSite.usingUser(userModel).createSite(testSite1); + dataSite.usingUser(userModel).createSite(testSite2); + + dataSite.usingUser(userModel).usingSite(testSite2).addSiteToFavorites(); + dataSite.usingUser(userModel).usingSite(testSite1).addSiteToFavorites(); + dataSite.usingUser(userModel).usingSite(siteModel).addSiteToFavorites(); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, @@ -36,10 +45,7 @@ public class GetFavoriteSitesFullTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) public void userGetsFavoriteSiteWithSuccessUsingMEForRequest() throws Exception { - UserModel randomTestUser = dataUser.createRandomTestUser(); - dataSite.usingUser(randomTestUser).usingSite(siteModel).addSiteToFavorites(); - - restSiteModelsCollection = restClient.authenticateUser(randomTestUser).withCoreAPI().usingMe().getFavoriteSites(); + restSiteModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingMe().getFavoriteSites(); restClient.assertStatusCodeIs(HttpStatus.OK); restSiteModelsCollection.assertThat().entriesListIsNotEmpty() .and().entriesListContains("id", siteModel.getId()) @@ -63,12 +69,7 @@ public class GetFavoriteSitesFullTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) public void getFavoriteSiteRequestForUserWithSeveralFavoriteSitesIsSuccessful() throws Exception { - UserModel randomTestUser = dataUser.createRandomTestUser(); - dataSite.usingUser(randomTestUser).usingSite(siteModel).addSiteToFavorites(); - dataSite.usingUser(randomTestUser).usingSite(testSite1).addSiteToFavorites(); - dataSite.usingUser(randomTestUser).usingSite(testSite2).addSiteToFavorites(); - - restSiteModelsCollection = restClient.authenticateUser(randomTestUser).withCoreAPI().usingAuthUser().getFavoriteSites(); + restSiteModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().getFavoriteSites(); restClient.assertStatusCodeIs(HttpStatus.OK); restSiteModelsCollection.assertThat().entriesListIsNotEmpty() .and().entriesListContains("id", siteModel.getId()) @@ -120,18 +121,29 @@ public class GetFavoriteSitesFullTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE); } + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify that user can retrieve the last 2 favorite sites") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + public void userCanRetrieveLast2FavoriteSites() throws Exception + { + restSiteModelsCollection = restClient.authenticateUser(userModel).withParams("skipCount=1&maxCount=2"). + withCoreAPI().usingAuthUser().getFavoriteSites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteModelsCollection.assertThat().entriesListIsNotEmpty() + .assertThat().entriesListCountIs(2) + .assertThat().entriesListContains("id", testSite1.getId()) + .assertThat().entriesListContains("id", testSite2.getId()); + } + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify that getFavoriteSites request applies valid properties param") @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) public void getFavoriteSitesRequestWithValidPropertiesParam() throws Exception { - UserModel randomTestUser = dataUser.createRandomTestUser(); - dataSite.usingUser(randomTestUser).usingSite(siteModel).addSiteToFavorites(); - - RestSiteModel restSiteModel = restClient.authenticateUser(randomTestUser).withParams("properties=title") + RestSiteModel restSiteModel = restClient.authenticateUser(userModel).withParams("properties=title") .withCoreAPI().usingAuthUser().getFavoriteSites().getOneRandomEntry().onModel(); restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModel.assertThat().fieldCount().is(0) + restSiteModel//.assertThat().fieldCount().is(0) .assertThat().field("title").is(siteModel.getTitle()); } @@ -140,11 +152,8 @@ public class GetFavoriteSitesFullTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) public void getFavoriteSitesRequestWithInvalidPropertiesParam() throws Exception { - UserModel randomTestUser = dataUser.createRandomTestUser(); - dataSite.usingUser(randomTestUser).usingSite(siteModel).addSiteToFavorites(); - - restClient.authenticateUser(randomTestUser).withParams("properties=tas").withCoreAPI().usingAuthUser() - .getFavoriteSites().getOneRandomEntry().onModel().assertThat().fieldCount().is(0); + restClient.authenticateUser(userModel).withParams("properties=tas").withCoreAPI().usingAuthUser() + .getFavoriteSites().getOneRandomEntry().onModel();//.assertThat().fieldCount().is(0); restClient.assertStatusCodeIs(HttpStatus.OK); } } From 93f831c0a9e850a5fb1214be3429072720547402 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alecsandru=20Prun=C4=83?= Date: Wed, 11 Jan 2017 11:03:39 +0200 Subject: [PATCH 0823/1491] Fixed tests asserts --- .../org/alfresco/rest/people/GetFavoriteSitesFullTests.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesFullTests.java b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesFullTests.java index 6c0f816fd..1d0789867 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesFullTests.java @@ -143,7 +143,7 @@ public class GetFavoriteSitesFullTests extends RestTest RestSiteModel restSiteModel = restClient.authenticateUser(userModel).withParams("properties=title") .withCoreAPI().usingAuthUser().getFavoriteSites().getOneRandomEntry().onModel(); restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModel//.assertThat().fieldCount().is(0) + restSiteModel.assertThat().fieldCount().is(1) .assertThat().field("title").is(siteModel.getTitle()); } @@ -153,7 +153,7 @@ public class GetFavoriteSitesFullTests extends RestTest public void getFavoriteSitesRequestWithInvalidPropertiesParam() throws Exception { restClient.authenticateUser(userModel).withParams("properties=tas").withCoreAPI().usingAuthUser() - .getFavoriteSites().getOneRandomEntry().onModel();//.assertThat().fieldCount().is(0); + .getFavoriteSites().getOneRandomEntry().onModel().assertThat().fieldCount().is(0); restClient.assertStatusCodeIs(HttpStatus.OK); } } From ed0944575adf7d7203ebc3270ff6416fa6aee1cb Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Wed, 11 Jan 2017 11:11:24 +0200 Subject: [PATCH 0824/1491] added full tests for GetPeoplePreferences for tasks from TAS-2629 to TAS-2640 --- .../people/GetPeopleActivitiesCoreTests.java | 1 - .../people/GetPeoplePreferencesFullTests.java | 130 ++++++++++++++++++ 2 files changed, 130 insertions(+), 1 deletion(-) create mode 100644 e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesCoreTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesCoreTests.java index 1ecc70160..a7549c9c0 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesCoreTests.java @@ -4,7 +4,6 @@ import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestActivityModelsCollection; import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.utility.constants.ActivityType; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FolderModel; diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesFullTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesFullTests.java new file mode 100644 index 000000000..8eda8ca1f --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesFullTests.java @@ -0,0 +1,130 @@ +package org.alfresco.rest.people; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestPreferenceModelsCollection; +import org.alfresco.utility.constants.PreferenceName; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * + * @author Cristina Axinte + * + */ +public class GetPeoplePreferencesFullTests extends RestTest +{ + UserModel userModel, user1, user2, adminUser; + SiteModel siteModel; + FolderModel folderModel; + private RestPreferenceModelsCollection restPreferenceModelsCollection; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + + user1 = dataUser.createRandomTestUser(); + dataSite.usingUser(user1).usingSite(siteModel).addSiteToFavorites(); + dataContent.usingUser(user1).usingSite(siteModel).addFolderToFavorites(folderModel); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its preferences using me with Rest API and response is successful") + public void userGetsItsPeoplePreferencesUsingMe() throws Exception + { + restPreferenceModelsCollection = restClient.authenticateUser(user1).withCoreAPI().usingMe().getPersonPreferences(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restPreferenceModelsCollection.assertThat().paginationField("count").is("4"); + restPreferenceModelsCollection.assertThat().entriesListIsNotEmpty() + .and().entriesListContains("id", String.format(PreferenceName.EXT_FOLDERS_FAVORITES_PREFIX.toString(), "workspace://SpacesStore/" + folderModel.getNodeRef())) + .and().entriesListContains("id", String.format(PreferenceName.EXT_SITES_FAVORITES_PREFIX.toString(), siteModel.getId())) + .and().entriesListContains("id", PreferenceName.FOLDERS_FAVORITES_PREFIX.toString()) + .and().entriesListContains("value", "workspace://SpacesStore/" + folderModel.getNodeRef()) + .and().entriesListContains("id", String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())) + .and().entriesListContains("value", "true"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its preferences with skipCount parameter applied with Rest API and response is successful") + public void userGetsItsPeoplePreferencesUsingSkipCountParameter() throws Exception + { + restPreferenceModelsCollection = restClient.authenticateUser(user1).withCoreAPI().usingMe().usingParams("skipCount=2").getPersonPreferences(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restPreferenceModelsCollection.assertThat().paginationField("count").is("2"); + restPreferenceModelsCollection.assertThat().paginationField("skipCount").is("2"); + restPreferenceModelsCollection.assertThat().entriesListIsNotEmpty() + .and().entriesListDoesNotContain("id", String.format(PreferenceName.EXT_FOLDERS_FAVORITES_PREFIX.toString(), "workspace://SpacesStore/" + folderModel.getNodeRef())) + .and().entriesListDoesNotContain("id", String.format(PreferenceName.EXT_SITES_FAVORITES_PREFIX.toString(), siteModel.getId())) + .and().entriesListContains("id", PreferenceName.FOLDERS_FAVORITES_PREFIX.toString()) + .and().entriesListContains("value", "workspace://SpacesStore/" + folderModel.getNodeRef()) + .and().entriesListContains("id", String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())) + .and().entriesListContains("value", "true"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its preferences with maxItems parameter applied with Rest API and response is successful") + public void userGetsItsPeoplePreferencesUsingMaxItemsParameter() throws Exception + { + restPreferenceModelsCollection = restClient.authenticateUser(user1).withCoreAPI().usingMe().usingParams("maxItems=1").getPersonPreferences(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restPreferenceModelsCollection.assertThat().paginationField("count").is("1"); + restPreferenceModelsCollection.assertThat().paginationField("maxItems").is("1"); + restPreferenceModelsCollection.assertThat().entriesListIsNotEmpty() + .and().entriesListContains("id", String.format(PreferenceName.EXT_FOLDERS_FAVORITES_PREFIX.toString(), "workspace://SpacesStore/" + folderModel.getNodeRef())) + .and().entriesListDoesNotContain("id", String.format(PreferenceName.EXT_SITES_FAVORITES_PREFIX.toString(), siteModel.getId())) + .and().entriesListDoesNotContain("id", PreferenceName.FOLDERS_FAVORITES_PREFIX.toString()) + .and().entriesListDoesNotContain("value", "workspace://SpacesStore/" + folderModel.getNodeRef()) + .and().entriesListDoesNotContain("id", String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())) + .and().entriesListDoesNotContain("value", "true"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets admin preferences with Rest API and response is permission denied") + public void userIsForbiddenToGetAdminPreferences() throws Exception + { + restPreferenceModelsCollection = restClient.authenticateUser(user1).withCoreAPI().usingUser(adminUser).getPersonPreferences(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + restClient.assertLastError().containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its preferences with skipCount parameter higher then no of entries with Rest API and response is empty") + public void userGetsItsPeoplePreferencesUsingHighSkipCount() throws Exception + { + restPreferenceModelsCollection = restClient.authenticateUser(user1).withCoreAPI().usingMe().usingParams("skipCount=100").getPersonPreferences(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restPreferenceModelsCollection.assertThat().paginationField("count").is("0"); + restPreferenceModelsCollection.assertThat().paginationField("skipCount").is("100"); + restPreferenceModelsCollection.assertThat().entriesListIsEmpty(); + } + + @Bug(id = "ACE-5460") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot get preferences for empty user with Rest API and response is 400") + public void userGetsItsPeoplePreferencesForEmptyPersonId() throws Exception + { + UserModel emptyUserName = new UserModel("", "password"); + + restPreferenceModelsCollection = restClient.authenticateUser(user1).withCoreAPI().usingUser(emptyUserName).getPersonPreferences(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .containsSummary(RestErrorModel.LOCAL_NAME_CONSISTANCE) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } +} From 6522376f0230770aa55ff4634f2352f936a1af60 Mon Sep 17 00:00:00 2001 From: "NESS\\P3700299" Date: Wed, 11 Jan 2017 11:35:36 +0200 Subject: [PATCH 0825/1491] added Core tests for sanity and fieldCount assertion --- .../rest/favorites/GetFavoriteCoreTests.java | 29 +++++ .../rest/favorites/GetFavoriteFullTests.java | 101 +++++++++++++++--- .../favorites/GetFavoriteSanityTests.java | 3 - 3 files changed, 113 insertions(+), 20 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteCoreTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteCoreTests.java index c3b3e0668..60dab9670 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteCoreTests.java @@ -13,6 +13,7 @@ import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -60,6 +61,22 @@ public class GetFavoriteCoreTests extends RestTest { .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY); } + @Bug(id = "ACE-2413") + @TestRail(section = { TestGroup.REST_API, + TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify get favorite site when person id is empty") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) + public void getFavoriteSiteWithEmptyUserId() throws JsonToModelConversionException, Exception { + + restClient.withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); + UserModel someUser = new UserModel("", DataUser.PASSWORD); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(someUser).getFavorite(siteModel.getGuid()); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, someUser.getUsername())) + .statusCodeIs(HttpStatus.BAD_REQUEST); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify get favorite site when favorite id does't exist") @@ -103,4 +120,16 @@ public class GetFavoriteCoreTests extends RestTest { restClient.assertStatusCodeIs(HttpStatus.OK); favoriteSite.assertThat().field("targetGuid").equals(siteModel.getGuid()); } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify get favorite site for -me-") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) + public void getFavoriteFileUsingMe() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + + RestPersonFavoritesModel favoriteFile = restClient.withCoreAPI().usingMe().getFavorite(fileModel.getNodeRefWithoutVersion()); + restClient.assertStatusCodeIs(HttpStatus.OK); + favoriteFile.assertThat().field("targetGuid").equals(fileModel.getNodeRef()); + } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteFullTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteFullTests.java index 05323bb89..6da5b188a 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteFullTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteFullTests.java @@ -6,13 +6,13 @@ import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestPersonFavoritesModel; import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -20,7 +20,7 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; public class GetFavoriteFullTests extends RestTest { - private UserModel adminUserModel, networkUserModel; + private UserModel adminUserModel; private SiteModel siteModel; private FolderModel folderModel; private FileModel fileModel; @@ -29,7 +29,6 @@ public class GetFavoriteFullTests extends RestTest { @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception { - networkUserModel = dataUser.createRandomTestUser(); adminUserModel = dataUser.getAdminUser(); restClient.authenticateUser(adminUserModel); @@ -46,22 +45,90 @@ public class GetFavoriteFullTests extends RestTest { UserRole.SiteConsumer, UserRole.SiteContributor); } + + @Bug(id = "MNT-16904") @TestRail(section = { TestGroup.REST_API, - TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify get favorite site when using invalid network id") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) - public void getFavoriteSiteWhenNetworkIdIsInvalid() throws JsonToModelConversionException, Exception + TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify the get favorite request for invalid network id") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL, TestGroup.NETWORKS }) + public void getFavoriteSiteWithInvalidNetworkId() throws Exception { - networkUserModel.setDomain("invalidNetwork"); - restClient.withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); - UserModel someUser = new UserModel("invalidUser", DataUser.PASSWORD); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(someUser).getFavorite(siteModel.getGuid()); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, someUser.getUsername())) - .statusCodeIs(HttpStatus.NOT_FOUND) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY); + UserModel adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUserModel); + restClient.usingTenant().createTenant(adminTenantUser); + UserModel tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + + siteModel = dataSite.usingUser(tenantUser).createPublicRandomSite(); + restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + + tenantUser.setDomain("invalidNetwork"); + restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().getFavorite(siteModel.getGuid()); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify the get favorite request with tenant user") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL, TestGroup.NETWORKS }) + public void getFavoriteSiteWithTenantUser() throws Exception + { + UserModel adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUserModel).usingTenant().createTenant(adminTenantUser); + UserModel tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + + siteModel = dataSite.usingUser(tenantUser).createPublicRandomSite(); + restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + + restClient.withCoreAPI().usingAuthUser().getFavorite(siteModel.getGuid()); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify Admin user gets favorite site with Rest API and validate details") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) + public void verifyRequestforGetFavoriteSite() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel); + restClient.withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); + + RestPersonFavoritesModel favoriteSite = restClient.withCoreAPI().usingUser(adminUserModel).getFavorite(siteModel.getGuid()); + restClient.assertStatusCodeIs(HttpStatus.OK); + favoriteSite.assertThat().field("targetGuid").equals(siteModel.getGuid()); + favoriteSite.getTarget().getSite() + .assertThat().field("guid").equals(siteModel.getGuid()); + } + + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify Admin user gets favorite site with properties filter") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) + public void verifyRequestforGetFavoriteSiteWithProperties() throws JsonToModelConversionException, Exception + { + UserModel manager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); + restClient.authenticateUser(manager); + restClient.withCoreAPI().usingUser(manager).addSiteToFavorites(siteModel); + + RestPersonFavoritesModel favoriteSite = restClient.authenticateUser(manager).withParams("properties=targetGuid") + .withCoreAPI().usingAuthUser().getFavorite(siteModel.getGuid()); + restClient.assertStatusCodeIs(HttpStatus.OK); + favoriteSite.assertThat().field("targetGuid").equals(siteModel.getGuid()); + favoriteSite.assertThat().fieldsCount().is(1); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify Admin user gets favorite site with inccorect properties filter") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) + public void verifyRequestforGetFavoriteSiteWithInccorectProperties() throws JsonToModelConversionException, Exception + { + UserModel collaborator = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); + restClient.authenticateUser(collaborator); + restClient.withCoreAPI().usingUser(collaborator).addSiteToFavorites(siteModel); + + RestPersonFavoritesModel favoriteSite = restClient.authenticateUser(collaborator).withParams("properties=tas") + .withCoreAPI().usingAuthUser().getFavorite(fileModel.getNodeRefWithoutVersion()); + restClient.assertStatusCodeIs(HttpStatus.OK); + favoriteSite.assertThat().fieldsCount().is(0); + } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java index 688ce6ff5..ffd2cdb71 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java @@ -5,8 +5,6 @@ import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestPersonFavoritesModel; -import org.alfresco.rest.model.RestPersonFavoritesModelsCollection; -import org.alfresco.rest.model.RestSiteModelsCollection; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.FileModel; @@ -294,5 +292,4 @@ public class GetFavoriteSanityTests extends RestTest .usingUser(siteManager).getFavorite(siteModel.getGuid()); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); } - } From df05293a5a1a6f3f75bdabb0b49479cbaf985387 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Wed, 11 Jan 2017 11:41:30 +0200 Subject: [PATCH 0826/1491] Added tests for getPreference REST API call --- .../people/GetPeoplePreferenceFullTests.java | 222 ++++++++++++++++++ 1 file changed, 222 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceFullTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceFullTests.java new file mode 100644 index 000000000..4cc9a45cb --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceFullTests.java @@ -0,0 +1,222 @@ +package org.alfresco.rest.people; + +import java.nio.file.Paths; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestPreferenceModel; +import org.alfresco.utility.Utility; +import org.alfresco.utility.constants.PreferenceName; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FileType; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class GetPeoplePreferenceFullTests extends RestTest +{ + private UserModel userModel; + private SiteModel siteModel; + private RestPreferenceModel restPreferenceModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + dataSite.usingUser(userModel).usingSite(siteModel).addSiteToFavorites(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, + description = "Check default error schema in case of failure") + public void checkDefaultErrorSchema() throws Exception + { + restClient.authenticateUser(userModel).withCoreAPI().usingUser(new UserModel("invalidPersonID", "password")) + .getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidPersonID")) + .statusCodeIs(HttpStatus.NOT_FOUND) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, + description = "Specify -me- string in place of for request") + public void preferenceIsReturnedWhenUsingMeAsPersonId() throws Exception + { + restPreferenceModel = restClient.authenticateUser(userModel).withCoreAPI().usingMe() + .getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); + + restClient.assertStatusCodeIs(HttpStatus.OK); + restPreferenceModel.assertThat().field("id").is(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) + .and().field("value").is("true"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, + description = "Check that properties parameter is applied") + public void propertiesParameterIsAppliedWhenRetrievingPreference() throws Exception + { + restPreferenceModel = restClient.authenticateUser(userModel).withParams("properties=id").withCoreAPI().usingUser(userModel) + .getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); + restClient.assertStatusCodeIs(HttpStatus.OK); + restPreferenceModel.assertThat().field("id").is(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) + .and().field("value").isNull(); + + restPreferenceModel = restClient.authenticateUser(userModel).withParams("properties=id,value").withCoreAPI().usingUser(userModel) + .getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); + restClient.assertStatusCodeIs(HttpStatus.OK); + restPreferenceModel.assertThat().field("id").is(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) + .and().field("value").is("true"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, + description = "Validate ID element in get site preference response") + public void validateIdElementInGetSitePreferenceResponse() throws Exception + { + restPreferenceModel = restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser() + .getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); + restPreferenceModel.assertThat().field("id").is(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) + .and().field("value").is("true"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, + description = "Validate ID element in get folder preference response") + public void validateIdElementInGetFolderPreferenceResponse() throws Exception + { + FolderModel folderFavorite = new FolderModel("favoriteFolder"); + folderFavorite = dataContent.usingSite(siteModel).createFolder(folderFavorite); + dataContent.getContentActions().setFolderAsFavorite(userModel.getUsername(), userModel.getPassword(), siteModel.getId(), folderFavorite.getName()); + + restPreferenceModel = restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser() + .getPersonPreferenceInformation(PreferenceName.FOLDERS_FAVORITES_PREFIX.toString()); + restPreferenceModel.assertThat().field("id").is(PreferenceName.FOLDERS_FAVORITES_PREFIX) + .and().field("value").is(Utility.removeLastSlash(Utility.buildPath("workspace://SpacesStore", folderFavorite.getNodeRef()))); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, + description = "Validate ID element in get file preference response") + public void validateIdElementInGetFilePreferenceResponse() throws Exception + { + FileModel fileFavorite = new FileModel("favoriteFile", FileType.TEXT_PLAIN); + fileFavorite = dataContent.usingSite(siteModel).createContent(fileFavorite); + dataContent.getContentActions().setFileAsFavorite(userModel.getUsername(), userModel.getPassword(), siteModel.getId(), String.format("%s.%s", fileFavorite.getName(), fileFavorite.getFileType().extention)); + + restPreferenceModel = restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser() + .getPersonPreferenceInformation(PreferenceName.DOCUMENTS_FAVORITES_PREFIX.toString()); + restPreferenceModel.assertThat().field("id").is(PreferenceName.DOCUMENTS_FAVORITES_PREFIX) + .and().field("value").is(Utility.removeLastSlash(Utility.buildPath("workspace://SpacesStore", fileFavorite.getNodeRefWithoutVersion()))); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, + description = "Get preference of an user that has no preferences") + public void getPreferenceForUserWithoutPreferences() throws Exception + { + UserModel newUser = dataUser.createRandomTestUser(); + + restPreferenceModel = restClient.authenticateUser(newUser).withCoreAPI().usingAuthUser() + .getPersonPreferenceInformation(PreferenceName.DOCUMENTS_FAVORITES_PREFIX.toString()); + restClient.assertLastError().containsSummary( + String.format("The relationship resource was not found for the" + " entity with id: %s and a relationship id of %s", newUser.getUsername(), + PreferenceName.DOCUMENTS_FAVORITES_PREFIX.toString())); + + restPreferenceModel = restClient.authenticateUser(newUser).withCoreAPI().usingAuthUser() + .getPersonPreferenceInformation(PreferenceName.FOLDERS_FAVORITES_PREFIX.toString()); + restClient.assertLastError().containsSummary( + String.format("The relationship resource was not found for the" + " entity with id: %s and a relationship id of %s", newUser.getUsername(), + PreferenceName.FOLDERS_FAVORITES_PREFIX.toString())); + + restPreferenceModel = restClient.authenticateUser(newUser).withCoreAPI().usingAuthUser() + .getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX.toString()); + restClient.assertLastError().containsSummary( + String.format("The relationship resource was not found for the" + " entity with id: %s and a relationship id of %s", newUser.getUsername(), + PreferenceName.SITES_FAVORITES_PREFIX.toString())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, + description = "Change one preference for an user then perform get call") + @Bug(id = "ACE-5736") + public void changePreferenceThenPerformGetPreferenceCall() throws Exception + { + UserModel newUser = dataUser.createRandomTestUser(); + SiteModel site = dataSite.usingUser(newUser).createPublicRandomSite(); + + dataSite.usingUser(newUser).usingSite(site).addSiteToFavorites(); + + FileModel fileFavorite = new FileModel("favoriteFile", FileType.TEXT_PLAIN); + fileFavorite = dataContent.usingSite(site).createContent(fileFavorite); + dataContent.getContentActions().setFileAsFavorite(newUser.getUsername(), newUser.getPassword(), site.getId(), String.format("%s.%s", fileFavorite.getName(), fileFavorite.getFileType().extention)); + + FolderModel folderFavorite = new FolderModel("favoriteFolder"); + folderFavorite = dataContent.usingSite(site).createFolder(folderFavorite); + dataContent.getContentActions().setFolderAsFavorite(newUser.getUsername(), newUser.getPassword(), site.getId(), folderFavorite.getName()); + + dataSite.usingUser(newUser).usingSite(site).removeSiteFromFavorites(); + dataContent.getContentActions().removeFavorite(newUser.getUsername(), newUser.getPassword(), site.getId(), folderFavorite.getName()); + dataContent.getContentActions().removeFavorite(newUser.getUsername(), newUser.getPassword(), site.getId(), Paths.get(fileFavorite.getCmisLocation()).getFileName().toString()); + + restPreferenceModel = restClient.authenticateUser(newUser).withCoreAPI().usingAuthUser() + .getPersonPreferenceInformation(PreferenceName.FOLDERS_FAVORITES_PREFIX.toString()); + restClient.assertLastError().containsSummary( + String.format("The relationship resource was not found for the" + " entity with id: %s and a relationship id of %s", newUser.getUsername(), + PreferenceName.FOLDERS_FAVORITES_PREFIX.toString())); + + restPreferenceModel = restClient.authenticateUser(newUser).withCoreAPI().usingAuthUser() + .getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX.toString()); + restClient.assertLastError().containsSummary( + String.format("The relationship resource was not found for the" + " entity with id: %s and a relationship id of %s", newUser.getUsername(), + PreferenceName.SITES_FAVORITES_PREFIX.toString())); + + restPreferenceModel = restClient.authenticateUser(newUser).withCoreAPI().usingAuthUser() + .getPersonPreferenceInformation(PreferenceName.DOCUMENTS_FAVORITES_PREFIX.toString()); + restClient.assertLastError().containsSummary( + String.format("The relationship resource was not found for the" + " entity with id: %s and a relationship id of %s", newUser.getUsername(), + PreferenceName.DOCUMENTS_FAVORITES_PREFIX.toString())); + + restPreferenceModel = restClient.authenticateUser(newUser).withCoreAPI().usingAuthUser() + .getPersonPreferenceInformation(PreferenceName.FOLDERS_FAVORITES_PREFIX.toString()); + restClient.assertLastError().containsSummary( + String.format("The relationship resource was not found for the" + " entity with id: %s and a relationship id of %s", newUser.getUsername(), + PreferenceName.FOLDERS_FAVORITES_PREFIX.toString())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, + description = "Verify admin is able to get preference of another user") + public void adminIsAbleToGetOtherUserPreference() throws Exception + { + restPreferenceModel = restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingUser(userModel) + .getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); + restClient.assertStatusCodeIs(HttpStatus.OK); + restPreferenceModel.assertThat().field("id").is(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()).and().field("value").is("true"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, + description = "Verify regular user is not able to get preference of admin user") + public void regularUserIsNotAbleToGetAdminPreference() throws Exception + { + SiteModel newSite = dataSite.usingUser(dataUser.getAdminUser()).createPublicRandomSite(); + dataSite.usingUser(dataUser.getAdminUser()).usingSite(newSite).addSiteToFavorites(); + + restClient.authenticateUser(userModel).withCoreAPI().usingUser(dataUser.getAdminUser()) + .getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + newSite.getId()); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + restClient.assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } +} \ No newline at end of file From 673e6897a6e0838b8081f6a6723e4247721d5e6d Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Wed, 11 Jan 2017 12:57:46 +0200 Subject: [PATCH 0827/1491] fix test groups --- .../rest/comments/GetCommentsSanityTests.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java index cdec30ed3..4385ea6d8 100644 --- a/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java @@ -40,7 +40,7 @@ public class GetCommentsSanityTests extends RestTest usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); } - @TestRail(section={TestGroup.REST_API, TestGroup.SANITY}, executionType= ExecutionType.SANITY, + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.SANITY, description= "Verify Admin user gets comments with Rest API and status code is 200") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) public void adminIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception @@ -51,7 +51,7 @@ public class GetCommentsSanityTests extends RestTest comments.assertThat().entriesListContains("content", content); } - @TestRail(section={TestGroup.REST_API, TestGroup.SANITY}, executionType= ExecutionType.SANITY, + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.SANITY, description= "Verify Manager user gets comments created by admin user with Rest API and status code is 200") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) public void managerIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception @@ -62,7 +62,7 @@ public class GetCommentsSanityTests extends RestTest comments.assertThat().entriesListContains("content", content); } - @TestRail(section={TestGroup.REST_API, TestGroup.SANITY}, executionType= ExecutionType.SANITY, + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.SANITY, description= "Verify Contributor user gets comments created by admin user with Rest API and status code is 200") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) public void contributorIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception @@ -73,7 +73,7 @@ public class GetCommentsSanityTests extends RestTest comments.assertThat().entriesListContains("content", content); } - @TestRail(section={TestGroup.REST_API, TestGroup.SANITY}, executionType= ExecutionType.SANITY, + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.SANITY, description= "Verify Collaborator user gets comments created by admin user with Rest API and status code is 200") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) public void collaboratorIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception @@ -84,7 +84,7 @@ public class GetCommentsSanityTests extends RestTest comments.assertThat().entriesListContains("content", content); } - @TestRail(section={TestGroup.REST_API, TestGroup.SANITY}, executionType= ExecutionType.SANITY, + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.SANITY, description= "Verify Consumer user gets comments created by admin user with Rest API and status code is 200") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) public void consumerIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception @@ -95,8 +95,9 @@ public class GetCommentsSanityTests extends RestTest comments.assertThat().entriesListContains("content", content); } - @TestRail(section={TestGroup.REST_API, TestGroup.SANITY}, executionType= ExecutionType.SANITY, - description= "Verify Manager user gets status code 401 if authentication call fails") + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.SANITY, + description= "Verify Manager user gets status code 401 if authentication call fails") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) @Bug(id="MNT-16904") public void managerIsNotAbleToRetrieveCommentIfAuthenticationFails() throws JsonToModelConversionException, Exception @@ -107,7 +108,7 @@ public class GetCommentsSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); } - @TestRail(section={TestGroup.REST_API, TestGroup.SANITY}, executionType= ExecutionType.SANITY, + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.SANITY, description= "Verify Manager user gets comments created by another user and status code is 200") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) public void managerIsAbleToRetrieveCommentsCreatedByAnotherUser() throws JsonToModelConversionException, Exception @@ -124,7 +125,7 @@ public class GetCommentsSanityTests extends RestTest .and().entriesListContains("content", content); } - @TestRail(section={TestGroup.REST_API, TestGroup.SANITY}, executionType= ExecutionType.SANITY, + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.SANITY, description= "Verify admin user gets comments created by another user and status code is 200") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) public void adminIsAbleToRetrieveCommentsCreatedByAnotherUser() throws JsonToModelConversionException, Exception From 76c655822fb23d10a468921fb5f44f547f1326bf Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Wed, 11 Jan 2017 13:02:35 +0200 Subject: [PATCH 0828/1491] fix groups --- .../workflow/deployments/GetDeploymentsSanityTests.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsSanityTests.java index df66b5e57..407689b74 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsSanityTests.java @@ -27,8 +27,7 @@ public class GetDeploymentsSanityTests extends RestTest restClient.authenticateUser(adminUserModel); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.DEPLOYMENTS }, executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets non-network deployments using REST API and status code is OK (200)") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.SANITY}) public void getNonNetworkDeploymentsWithAdmin() throws JsonToModelConversionException, Exception @@ -38,8 +37,7 @@ public class GetDeploymentsSanityTests extends RestTest deployments.assertThat().entriesListIsNotEmpty(); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.DEPLOYMENTS }, executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.SANITY, description = "Verify Tenant Admin user gets network deployments using REST API and status code is OK (200)") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.SANITY, TestGroup.NETWORKS}) public void getNetworkDeploymentsWithAdmin() throws JsonToModelConversionException, Exception From d49b58bad281a7cf230a083011bc245b83dc5352 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Wed, 11 Jan 2017 15:21:15 +0200 Subject: [PATCH 0829/1491] updated due to PreferenceName updated --- .../people/GetPeoplePreferenceCoreTests.java | 10 ++++----- .../GetPeoplePreferenceSanityTests.java | 22 +++++++++---------- .../GetPeoplePreferencesSanityTests.java | 10 ++++----- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceCoreTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceCoreTests.java index 759229be7..e2b943312 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceCoreTests.java @@ -30,7 +30,7 @@ public class GetPeoplePreferenceCoreTests extends RestTest { UserModel secondUser = dataUser.createRandomTestUser(); restClient.authenticateUser(secondUser).withCoreAPI().usingUser(userModel) - .getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); + .getPersonPreferenceInformation(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); restClient.assertLastError().containsSummary("Permission was denied"); } @@ -40,7 +40,7 @@ public class GetPeoplePreferenceCoreTests extends RestTest public void statusNotFoundIsReturnedForAPersonIDThatDoesNotExist() throws Exception { restClient.authenticateUser(userModel).withCoreAPI().usingUser(new UserModel("invalidPersonID", "password")) - .getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); + .getPersonPreferenceInformation(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); restClient.assertLastError().containsSummary("The entity with id: invalidPersonID was not found"); } @@ -57,17 +57,17 @@ public class GetPeoplePreferenceCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify manager fails to get a specific preference for an removed preference with Rest API and response is 404") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify manager fails to get a specific preference for removed preference with Rest API and response is 404") public void statusNotFoundIsReturnedForAPreferenceNameThatHasBeenRemoved() throws Exception { SiteModel preferenceSite = dataSite.usingUser(userModel).createPublicRandomSite(); dataSite.usingUser(userModel).usingSite(preferenceSite).addSiteToFavorites(); dataSite.usingUser(userModel).usingSite(preferenceSite).removeSiteFromFavorites(); restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser() - .getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + preferenceSite.getId()); + .getPersonPreferenceInformation(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), preferenceSite.getId())); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); restClient.assertLastError().containsSummary( String.format("The relationship resource was not found for the" + " entity with id: %s and a relationship id of %s", userModel.getUsername(), - PreferenceName.SITES_FAVORITES_PREFIX + preferenceSite.getId())); + String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), preferenceSite.getId()))); } } diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceSanityTests.java index 525a693a5..74013fd91 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceSanityTests.java @@ -42,9 +42,9 @@ public class GetPeoplePreferenceSanityTests extends RestTest dataSite.usingUser(managerUser).usingSite(siteModel).addSiteToFavorites(); restPreferenceModel = restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser() - .getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); + .getPersonPreferenceInformation(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())); restClient.assertStatusCodeIs(HttpStatus.OK); - restPreferenceModel.assertThat().field("id").is(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()).and().field("value").is("true"); + restPreferenceModel.assertThat().field("id").is(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())).and().field("value").is("true"); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) @@ -56,9 +56,9 @@ public class GetPeoplePreferenceSanityTests extends RestTest dataSite.usingUser(collaboratorUser).usingSite(siteModel).addSiteToFavorites(); restPreferenceModel = restClient.authenticateUser(collaboratorUser).withCoreAPI().usingAuthUser() - .getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); + .getPersonPreferenceInformation(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())); restClient.assertStatusCodeIs(HttpStatus.OK); - restPreferenceModel.assertThat().field("id").is(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()).and().field("value").is("true"); + restPreferenceModel.assertThat().field("id").is(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())).and().field("value").is("true"); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) @@ -70,9 +70,9 @@ public class GetPeoplePreferenceSanityTests extends RestTest dataSite.usingUser(contributorUser).usingSite(siteModel).addSiteToFavorites(); restPreferenceModel = restClient.authenticateUser(contributorUser).withCoreAPI().usingAuthUser() - .getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); + .getPersonPreferenceInformation(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())); restClient.assertStatusCodeIs(HttpStatus.OK); - restPreferenceModel.assertThat().field("id").is(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()).and().field("value").is("true"); + restPreferenceModel.assertThat().field("id").is(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())).and().field("value").is("true"); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) @@ -84,9 +84,9 @@ public class GetPeoplePreferenceSanityTests extends RestTest dataSite.usingUser(consumerUser).usingSite(siteModel).addSiteToFavorites(); restPreferenceModel = restClient.authenticateUser(consumerUser).withCoreAPI().usingAuthUser() - .getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); + .getPersonPreferenceInformation(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(),siteModel.getId())); restClient.assertStatusCodeIs(HttpStatus.OK); - restPreferenceModel.assertThat().field("id").is(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()).and().field("value").is("true"); + restPreferenceModel.assertThat().field("id").is(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(),siteModel.getId())).and().field("value").is("true"); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) @@ -97,9 +97,9 @@ public class GetPeoplePreferenceSanityTests extends RestTest dataSite.usingUser(adminUser).usingSite(siteModel).addSiteToFavorites(); restPreferenceModel = restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser() - .getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); + .getPersonPreferenceInformation(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())); restClient.assertStatusCodeIs(HttpStatus.OK); - restPreferenceModel.assertThat().field("id").is(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()).and().field("value").is("true"); + restPreferenceModel.assertThat().field("id").is(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())).and().field("value").is("true"); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) @@ -113,7 +113,7 @@ public class GetPeoplePreferenceSanityTests extends RestTest managerUser.setPassword("newpassword"); restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser() - .getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); + .getPersonPreferenceInformation(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); } } diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesSanityTests.java index 933ee0ce5..6a871427f 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesSanityTests.java @@ -44,7 +44,7 @@ public class GetPeoplePreferencesSanityTests extends RestTest restPreferenceModelsCollection = restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().getPersonPreferences(); restClient.assertStatusCodeIs(HttpStatus.OK); restPreferenceModelsCollection.assertThat().entriesListIsNotEmpty().assertThat().paginationExist().and() - .entriesListContains("id", PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); + .entriesListContains("id", String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) @@ -58,7 +58,7 @@ public class GetPeoplePreferencesSanityTests extends RestTest restPreferenceModelsCollection = restClient.authenticateUser(collaboratorUser).withCoreAPI().usingAuthUser().getPersonPreferences(); restClient.assertStatusCodeIs(HttpStatus.OK); restPreferenceModelsCollection.assertThat().entriesListIsNotEmpty().assertThat().paginationExist().and() - .entriesListContains("id", PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); + .entriesListContains("id", String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) @@ -72,7 +72,7 @@ public class GetPeoplePreferencesSanityTests extends RestTest restPreferenceModelsCollection = restClient.authenticateUser(contributorUser).withCoreAPI().usingAuthUser().getPersonPreferences(); restClient.assertStatusCodeIs(HttpStatus.OK); restPreferenceModelsCollection.assertThat().entriesListIsNotEmpty().assertThat().paginationExist().and() - .entriesListContains("id", PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); + .entriesListContains("id", String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) @@ -86,7 +86,7 @@ public class GetPeoplePreferencesSanityTests extends RestTest restPreferenceModelsCollection = restClient.authenticateUser(consumerUser).withCoreAPI().usingAuthUser().getPersonPreferences(); restClient.assertStatusCodeIs(HttpStatus.OK); restPreferenceModelsCollection.assertThat().entriesListIsNotEmpty().assertThat().paginationExist().and() - .entriesListContains("id", PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); + .entriesListContains("id", String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) @@ -101,7 +101,7 @@ public class GetPeoplePreferencesSanityTests extends RestTest restPreferenceModelsCollection = restClient.authenticateUser(adminUser).withCoreAPI().usingUser(managerUser).getPersonPreferences(); restClient.assertStatusCodeIs(HttpStatus.OK); restPreferenceModelsCollection.assertThat().entriesListIsNotEmpty().assertThat().paginationExist().and() - .entriesListContains("id", PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); + .entriesListContains("id", String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) From 5e042d2d511cee266b6ab68cde634215e4e17636 Mon Sep 17 00:00:00 2001 From: Bogdan Bocancea Date: Wed, 11 Jan 2017 15:32:36 +0200 Subject: [PATCH 0830/1491] add full tests for 'people/{personId}/favorite-sites/{siteId}' --- .../rest/people/GetFavoriteSiteFullTests.java | 163 ++++++++++++++++++ 1 file changed, 163 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteFullTests.java b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteFullTests.java new file mode 100644 index 000000000..06c9fd69b --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteFullTests.java @@ -0,0 +1,163 @@ +package org.alfresco.rest.people; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestSiteModel; +import org.alfresco.rest.model.RestSiteModelsCollection; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.apache.commons.lang3.RandomStringUtils; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.springframework.social.alfresco.api.entities.Site.Visibility; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Created by Bogdan Bocancea + */ +public class GetFavoriteSiteFullTests extends RestTest +{ + UserModel userModel; + SiteModel site1; + private RestSiteModel restSiteModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + site1 = dataSite.usingUser(userModel).createPublicRandomSite(); + dataSite.usingUser(userModel).usingSite(site1).addSiteToFavorites(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify invalid request returns status 404 when personId is invalid") + public void getFavoriteSiteWithInvalidPersonId() throws Exception + { + UserModel userSpecialChars = dataUser.usingAdmin().createUser(RandomStringUtils.randomAlphabetic(2) + "~!@#$%^&*()_+[]{}|;'d", "password"); + userSpecialChars.setUsername(RandomStringUtils.randomAlphabetic(2) + "~!%40%23%24%25%5E%26*()_%2B%5B%5D%7B%7D%7C%5C%3B%27%3A%22%2C.%2F%3C%3E"); + + restClient.authenticateUser(userModel).withCoreAPI().usingUser(userSpecialChars).getFavoriteSite(site1); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, userSpecialChars.getUsername())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify request with empty site id") + public void getFavoriteSiteWithEmptySiteId() throws Exception + { + restClient.authenticateUser(userModel).withCoreAPI(); + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "people/{personId}/favorite-sites/{siteId}?{parameters}", + userModel.getUsername(), "", restClient.getParameters()); + RestSiteModelsCollection sites = restClient.processModels(RestSiteModelsCollection.class, request); + restClient.assertStatusCodeIs(HttpStatus.OK); + sites.assertThat().entriesListIsNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify invalid request returns status 401 when user is empty") + public void getFavoriteSiteWithEmptyPersonId() throws Exception + { + UserModel emptyUser = new UserModel("", "password"); + restClient.authenticateUser(emptyUser).withCoreAPI().usingAuthUser().getFavoriteSite(site1); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify invalid request returns status 404 when another user get favorite site of an user") + public void getFavoriteSiteWithAnotherUser() throws Exception + { + UserModel user = dataUser.createRandomTestUser(); + restClient.authenticateUser(user).withCoreAPI().usingAuthUser().getFavoriteSite(site1); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, user.getUsername(), site1.getId())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE) + .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify request returns status 200 when using -me-") + public void getFavoriteSiteUsingMe() throws Exception + { + restSiteModel = restClient.authenticateUser(userModel).withCoreAPI().usingMe().getFavoriteSite(site1); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteModel.assertThat().field("id").is(site1.getId()) + .and().field("title").is(site1.getTitle()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify entry details for get site favorite response with Rest API") + public void checkResponseSchemaForGetSiteFavorite() throws Exception + { + restSiteModel = restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().getFavoriteSite(site1); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteModel.assertThat().field("id").is(site1.getId()) + .and().field("title").is(site1.getTitle()) + .and().field("role").is(UserRole.SiteManager.toString()) + .and().field("visibility").is(Visibility.PUBLIC.toString()) + .and().field("guid").isNotEmpty() + .and().field("description").is(site1.getDescription()) + .and().field("preset").is("site-dashboard"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify invalid request returns status 404 when providing folder name instead of site id") + public void getFavoriteSiteUsingFolder() throws Exception + { + FolderModel folder = dataContent.usingUser(userModel).usingSite(site1).createFolder(); + SiteModel siteFolder = new SiteModel(folder.getName()); + restSiteModel = restClient.authenticateUser(userModel).withCoreAPI().usingMe().getFavoriteSite(siteFolder); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, userModel.getUsername(), folder.getName())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify request returns status 200 when using valid parameters") + public void getFavoriteSiteUsingParameters() throws Exception + { + restSiteModel = restClient.withParams("maxItems=100").authenticateUser(userModel).withCoreAPI().usingMe().getFavoriteSite(site1); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteModel.assertThat().field("id").is(site1.getId()) + .and().field("title").is(site1.getTitle()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify request returns status 400 when using maxItems=0") + public void getFavoriteSiteUsingInvalidMaxItems() throws Exception + { + restSiteModel = restClient.withParams("maxItems=0").authenticateUser(userModel).withCoreAPI().usingMe().getFavoriteSite(site1); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify request returns status 200 when using -me-") + public void getFavoriteSiteUsingInvalidNetwork() throws Exception + { + UserModel invalidUserNetwork = dataUser.createRandomTestUser(); + SiteModel site = dataSite.usingUser(invalidUserNetwork).createPublicRandomSite(); + dataSite.usingUser(invalidUserNetwork).usingSite(site).addSiteToFavorites(); + invalidUserNetwork.setDomain("invalidNetwork"); + restSiteModel = restClient.authenticateUser(invalidUserNetwork).withCoreAPI().usingMe().getFavoriteSite(site); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } +} From 9f4e9690b2e06aaf13e0d62ed50a44815fb9f426 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Wed, 11 Jan 2017 15:32:55 +0200 Subject: [PATCH 0831/1491] updated some test names --- .../alfresco/rest/people/GetPeopleActivitiesCoreTests.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesCoreTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesCoreTests.java index a7549c9c0..fbb7265da 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesCoreTests.java @@ -78,7 +78,7 @@ public class GetPeopleActivitiesCoreTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.CORE }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities with invald skipCount parameter with Rest API and response is 400") - public void userGetPeopleActivitiesUsingSkipCountParameter() throws Exception + public void userGetPeopleActivitiesUsingInvalidSkipCountParameter() throws Exception { restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingMe().usingParams("skipCount=-1").getPersonActivities(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) @@ -90,7 +90,7 @@ public class GetPeopleActivitiesCoreTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.CORE }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities with invalid maxItems parameter with Rest API and response is 400") - public void userGetPeopleActivitiesUsingMaxItemsParameter() throws Exception + public void userGetPeopleActivitiesUsingInvalidMaxItemsParameter() throws Exception { restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingMe().usingParams("maxItems=0").getPersonActivities(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) @@ -102,7 +102,7 @@ public class GetPeopleActivitiesCoreTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.CORE }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities using invalid value for parameter 'who'with Rest API and response is 400") - public void userGetsPeopleActivitiesUsingMeForWhoParameter() throws Exception + public void userGetsPeopleActivitiesUsingInvalidValueForWhoParameter() throws Exception { restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingUser(userModel).usingParams("who=mee").getPersonActivities(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) From 803d570c8b719fefbe746dcc48f0e070895fa812 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Wed, 11 Jan 2017 15:39:22 +0200 Subject: [PATCH 0832/1491] Added GetFavorites full tests --- .../rest/favorites/GetFavoritesFullTests.java | 228 ++++++++++++++++++ 1 file changed, 228 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/favorites/GetFavoritesFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesFullTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesFullTests.java new file mode 100644 index 000000000..187bd0a30 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesFullTests.java @@ -0,0 +1,228 @@ +package org.alfresco.rest.favorites; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestPersonFavoritesModel; +import org.alfresco.rest.model.RestPersonFavoritesModelsCollection; +import org.alfresco.rest.model.RestSiteModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class GetFavoritesFullTests extends RestTest +{ + private UserModel adminUserModel; + private UserModel secondUserModel; + private SiteModel firstSiteModel, secondSiteModel, thirdSiteModel; + private RestPersonFavoritesModelsCollection userFavorites; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + secondUserModel = dataUser.createRandomTestUser(); + restClient.authenticateUser(adminUserModel); + firstSiteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + secondSiteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + thirdSiteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + + firstSiteModel.setGuid(restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(firstSiteModel).getSite().getGuid()); + secondSiteModel.setGuid(restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(secondSiteModel).getSite().getGuid()); + thirdSiteModel.setGuid(restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(thirdSiteModel).getSite().getGuid()); + + restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); + restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(secondSiteModel); + + restClient.authenticateUser(secondUserModel); + restClient.withCoreAPI().usingUser(secondUserModel).addSiteToFavorites(firstSiteModel); + restClient.withCoreAPI().usingUser(secondUserModel).addSiteToFavorites(secondSiteModel); + restClient.withCoreAPI().usingUser(secondUserModel).addSiteToFavorites(thirdSiteModel); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify get favorites specifying -me- string in place of for request") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) + public void userIsAbleToGetFavoritesWhenUsingMeAsUsername() throws Exception + { + userFavorites = restClient.authenticateUser(secondUserModel).withCoreAPI().usingMe().getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + userFavorites.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()).and().entriesListContains("targetGuid", secondSiteModel.getGuid()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify get favorites using empty for where parameter for request") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) + public void userIsAbleToGetFavoritesWhenUsingEmptyWhereParameter() throws Exception + { + userFavorites = restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().where().getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_ARGUMENT, "WHERE query")); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that for invalid maxItems parameter status code returned is 400.") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) + public void checkInvalidMaxItemsStatusCode() throws Exception + { + restClient.authenticateUser(adminUserModel).withParams("maxItems=AB").withCoreAPI().usingUser(adminUserModel).getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Invalid paging parameter"); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that for invalid skipCount parameter status code returned is 400.") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) + public void checkInvalidSkipCountStatusCode() throws Exception + { + restClient.authenticateUser(adminUserModel).withParams("skipCount=AB").withCoreAPI().usingUser(adminUserModel).getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Invalid paging parameter"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify get favorites when using invalid network id") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) + public void getFavoritesWhenNetworkIdIsInvalid() throws Exception + { + UserModel networkUserModel = dataUser.createRandomTestUser(); + networkUserModel.setDomain("invalidNetwork"); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(networkUserModel).where().targetSiteExist().getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, networkUserModel.getUsername())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify get favorites using special chars in where parameter for request") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) + public void userIsNotAbleToGetFavoritesWhenUsingSpecialCharsInWhereParameter() throws Exception + { + userFavorites = restClient.withCoreAPI().usingAuthUser().where().invalidWhereParameter("~!%40%23%24%25%5E%26*()_%2B%5B%5D%7B%7D%7C%5C%3B%27%3A%22%2C.%2F%3C%3E").getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_ARGUMENT, "WHERE query")) + .containsErrorKey(RestErrorModel.INVALID_QUERY_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify get favorites using AND instead of OR in where parameter for request") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) + public void userIsNotAbleToGetFavoritesWhenUsingANDInWhereParameter() throws Exception + { + userFavorites = restClient.withCoreAPI().usingAuthUser().where().targetFolderExist().invalidWhereParameter("AND").targetFileExist().getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_ARGUMENT, "WHERE query")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify get favorites using wrong name instead of EXISTS in where parameter for request") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) + public void userIsNotAbleToGetFavoritesWhenUsingWrongWhereParameter() throws Exception + { + userFavorites = restClient.withCoreAPI().usingAuthUser().where().invalidWhereParameter("EXIST((target/site))").targetFileExist().getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_ARGUMENT, "WHERE query")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify get favorites except the first one for request") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) + public void userIsAbleToGetFavoritesExceptTheFirstOne() throws Exception + { + userFavorites = restClient.authenticateUser(secondUserModel).withParams("skipCount=1").withCoreAPI().usingUser(secondUserModel).getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + userFavorites.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) + .and().entriesListContains("targetGuid", secondSiteModel.getGuid()) + .and().entriesListDoesNotContain("targetGuid", thirdSiteModel.getGuid()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify get first two favorites sites") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) + public void userIsAbleToGetFirstTwoFavorites() throws Exception + { + userFavorites = restClient.authenticateUser(secondUserModel).withParams("maxItems=2").withCoreAPI().usingUser(secondUserModel).getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + userFavorites.assertThat().entriesListContains("targetGuid", thirdSiteModel.getGuid()) + .and().entriesListContains("targetGuid", secondSiteModel.getGuid()) + .and().entriesListDoesNotContain("targetGuid", firstSiteModel.getGuid()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify get first two favorites sites") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) + public void userIsAbleToGetFavoritesWhenSkipCountAndMaxItemsAreEmpty() throws Exception + { + restClient.authenticateUser(secondUserModel).withParams("skipCount= ").withCoreAPI().usingUser(secondUserModel).getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, " ")); + + restClient.authenticateUser(secondUserModel).withParams("maxItems= ").withCoreAPI().usingUser(secondUserModel).getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, " ")); + } + + @Bug(id = "MNT-16904") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify the get favorites request when network id is invalid") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL, TestGroup.NETWORKS}) + public void getFavoriteSitesWhenNetworkIdIsInvalid() throws JsonToModelConversionException, Exception + { + UserModel adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUserModel); + restClient.usingTenant().createTenant(adminTenantUser); + UserModel tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); + + tenantUser.setDomain("invalidNetwork"); + restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify the get favorites request for a high value for skipCount parameter") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) + public void userIsAbleToGetFavoritesWithHighSkipCount() throws Exception + { + userFavorites = restClient.authenticateUser(secondUserModel).withParams("skipCount=999999999").withCoreAPI().usingUser(secondUserModel).getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + userFavorites.assertThat().entriesListIsEmpty().assertThat().paginationField("skipCount").is("999999999"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify the get favorites request with properties parameter applied") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) + public void userIsAbleToGetFavoritesWithPropertiesParamApplied() throws Exception + { + userFavorites = restClient.authenticateUser(secondUserModel).withParams("properties=targetGuid").withCoreAPI().usingUser(secondUserModel).getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + RestPersonFavoritesModel restPersonFavoritesModel = userFavorites.getEntries().get(0).onModel(); + restPersonFavoritesModel.assertThat().field("targetGuid").is(thirdSiteModel.getGuid()).and().field("createdAt").isNull(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify entry details for get favorites response with Rest API") + public void checkResponseSchemaForGetFavorites() throws Exception + { + userFavorites = restClient.authenticateUser(secondUserModel).withCoreAPI().usingAuthUser().getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + RestPersonFavoritesModel restPersonFavoritesModel = userFavorites.getEntries().get(0).onModel(); + restPersonFavoritesModel.assertThat().field("targetGuid").is(thirdSiteModel.getGuid()); + + RestSiteModel restSiteModel = restPersonFavoritesModel.getTarget().getSite(); + restSiteModel.assertThat().field("visibility").is(thirdSiteModel.getVisibility()).and() + .field("guid").is(thirdSiteModel.getGuid()).and() + .field("description").is(thirdSiteModel.getDescription()).and() + .field("id").is(thirdSiteModel.getId()).and() + .field("title").is(thirdSiteModel.getTitle()); + } +} From 57fdf54f532c25d0fb65cc92d776b6c7bcfd86bb Mon Sep 17 00:00:00 2001 From: mionescu Date: Wed, 11 Jan 2017 15:46:56 +0200 Subject: [PATCH 0833/1491] test- added new test cases for Core --- .../rest/people/AddFavoriteSiteCoreTests.java | 224 ++++++++++++++++++ 1 file changed, 224 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteCoreTests.java b/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteCoreTests.java new file mode 100644 index 000000000..a8d690d00 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteCoreTests.java @@ -0,0 +1,224 @@ +package org.alfresco.rest.people; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestPersonFavoritesModelsCollection; +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.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class AddFavoriteSiteCoreTests extends RestTest +{ + UserModel userModel, adminUserModel; + SiteModel siteModel, privateSiteModel, moderatedSiteModel; + UserModel searchedUser; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + privateSiteModel = dataSite.usingUser(userModel).createPrivateRandomSite(); + moderatedSiteModel = dataSite.usingUser(userModel).createModeratedRandomSite(); + } + + @Bug(id="ACE-2413") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify empty user is not able to add a site from favorites and response is (400)") + public void emptyUserIsNotAbleToRemoveFavoriteSite() throws Exception + { + UserModel emptyUser = new UserModel("", "password"); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(emptyUser).addSiteToFavorites(siteModel); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "emptyUser")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify inexistent user is not able to add a site from favorites and response is (404)") + public void inexistentUserIsNotAbleToRemoveFavoriteSite() throws Exception + { + UserModel inexistentUser = new UserModel("inexistenUser", "password"); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(inexistentUser).addSiteToFavorites(siteModel); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "inexistenUser")) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify manager user is not able to add a favorite site when the site is already favorite - status code (409)") + public void managerUserAddFavoriteSiteAlreadyAFavoriteSite() throws Exception + { + UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); + + restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.withCoreAPI().usingUser(managerUser).addFavoriteSite(siteModel); + restClient.assertStatusCodeIs(HttpStatus.CONFLICT); + restClient.assertLastError() + .containsSummary(String.format("%s is already a favourite site", siteModel.getId())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE) + .containsErrorKey(String.format("Site %s is already a favourite site", siteModel.getId())); + } + + @Bug(id="MNT-17337") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify user is not able to add a favorite site when the 'id' is empty - status code (400)") + public void collaboratorUserAddFavoriteSiteAFavoriteSite() throws Exception + { + siteModel.setId(""); + restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().addFavoriteSite(siteModel); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + restClient.assertLastError() + .containsSummary("siteId is null") + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY); + } + + @Bug(id="MNT-17338") + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify user doesn't have permission to delete favorites of admin user with Rest API and status code is 403") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + public void userIsNotAbleToAddFavoriteSiteOfAnotherUser() throws JsonToModelConversionException, Exception + { + UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(contributorUser, siteModel, UserRole.SiteContributor); + UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel, UserRole.SiteConsumer); + + restClient.authenticateUser(consumerUser).withCoreAPI() + .usingUser(contributorUser).addSiteToFavorites(siteModel); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError() + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Bug(id="MNT-17338") + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify admin user doesn't have permission to add a favorite site of another user with Rest API and status code is 403") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + public void adminIsNotAbleToAddFavoriteSiteOfAnotherUser() throws JsonToModelConversionException, Exception + { + UserModel collaboratorrUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(collaboratorrUser, siteModel, UserRole.SiteCollaborator); + restClient.authenticateUser(collaboratorrUser) + .withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); + + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError() + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Bug(id="MNT-17339") + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify non member user is not able to add a public favorite site - status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + public void privateSiteAddFavoriteSiteUserNotMemberOfTheSite() throws JsonToModelConversionException, Exception + { + UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); + restClient.authenticateUser(contributorUser).withCoreAPI() + .usingAuthUser().addSiteToFavorites(privateSiteModel); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, privateSiteModel.getId())) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify manager user is able to add as favorite a private site.") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + public void managerAddsPrivateSiteAsFavorite() throws JsonToModelConversionException, Exception + { + UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(managerUser, privateSiteModel, UserRole.SiteManager); + + restClient.authenticateUser(managerUser).withCoreAPI().usingUser(managerUser).addSiteToFavorites(privateSiteModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestPersonFavoritesModelsCollection favorites = restClient.withCoreAPI().usingAuthUser().getFavorites(); + favorites.assertThat().entriesListContains("targetGuid", privateSiteModel.getGuidWithoutVersion()) + .and().paginationField("totalItems").is("1"); + favorites.getOneRandomEntry().onModel().getTarget().getSite() + .assertThat() + .field("description").is(privateSiteModel.getDescription()) + .and().field("id").is(privateSiteModel.getId()) + .and().field("visibility").is(privateSiteModel.getVisibility().toString()) + .and().field("title").is(privateSiteModel.getTitle()); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify manager user is able to add as favorite a moderated site.") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + public void managerAddsModeratedSiteAsFavorite() throws JsonToModelConversionException, Exception + { + UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(managerUser, moderatedSiteModel, UserRole.SiteManager); + + restClient.authenticateUser(managerUser).withCoreAPI().usingUser(managerUser).addSiteToFavorites(moderatedSiteModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestPersonFavoritesModelsCollection favorites = restClient.withCoreAPI().usingAuthUser().getFavorites(); + favorites.assertThat().entriesListContains("targetGuid", moderatedSiteModel.getGuidWithoutVersion()) + .and().paginationField("totalItems").is("1"); + favorites.getOneRandomEntry().onModel().getTarget().getSite() + .assertThat() + .field("description").is(moderatedSiteModel.getDescription()) + .and().field("id").is(moderatedSiteModel.getId()) + .and().field("visibility").is(moderatedSiteModel.getVisibility().toString()) + .and().field("title").is(moderatedSiteModel.getTitle()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify user removes a site from favorites using '-me-' in place of personId with Rest API and response is successful (201)") + public void addFavoriteSiteWithSuccessUsingMeAsPersonId() throws Exception + { + restClient.authenticateUser(adminUserModel); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingMe().addSiteToFavorites(moderatedSiteModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify manager user removes a site from its favorites and adds it again and response is successful (204)") + public void managerUserRemovesFavoriteSiteAndAddItAgain() throws Exception + { + UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); + dataSite.usingUser(managerUser).usingSite(siteModel).addSiteToFavorites(); + + restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingUser(managerUser).addSiteToFavorites(siteModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + } + + +} From f5bced7195bb5a6b733d81c49e59ac96b977573e Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Wed, 11 Jan 2017 16:17:30 +0200 Subject: [PATCH 0834/1491] Fix preference name strings --- .../people/GetPeoplePreferenceFullTests.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceFullTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceFullTests.java index 4cc9a45cb..f9f310fde 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceFullTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceFullTests.java @@ -40,7 +40,7 @@ public class GetPeoplePreferenceFullTests extends RestTest public void checkDefaultErrorSchema() throws Exception { restClient.authenticateUser(userModel).withCoreAPI().usingUser(new UserModel("invalidPersonID", "password")) - .getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); + .getPersonPreferenceInformation(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidPersonID")) .statusCodeIs(HttpStatus.NOT_FOUND) @@ -55,10 +55,10 @@ public class GetPeoplePreferenceFullTests extends RestTest public void preferenceIsReturnedWhenUsingMeAsPersonId() throws Exception { restPreferenceModel = restClient.authenticateUser(userModel).withCoreAPI().usingMe() - .getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); + .getPersonPreferenceInformation(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())); restClient.assertStatusCodeIs(HttpStatus.OK); - restPreferenceModel.assertThat().field("id").is(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) + restPreferenceModel.assertThat().field("id").is(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())) .and().field("value").is("true"); } @@ -68,15 +68,15 @@ public class GetPeoplePreferenceFullTests extends RestTest public void propertiesParameterIsAppliedWhenRetrievingPreference() throws Exception { restPreferenceModel = restClient.authenticateUser(userModel).withParams("properties=id").withCoreAPI().usingUser(userModel) - .getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); + .getPersonPreferenceInformation(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())); restClient.assertStatusCodeIs(HttpStatus.OK); - restPreferenceModel.assertThat().field("id").is(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) + restPreferenceModel.assertThat().field("id").is(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())) .and().field("value").isNull(); restPreferenceModel = restClient.authenticateUser(userModel).withParams("properties=id,value").withCoreAPI().usingUser(userModel) - .getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); + .getPersonPreferenceInformation(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())); restClient.assertStatusCodeIs(HttpStatus.OK); - restPreferenceModel.assertThat().field("id").is(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) + restPreferenceModel.assertThat().field("id").is(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())) .and().field("value").is("true"); } @@ -86,8 +86,8 @@ public class GetPeoplePreferenceFullTests extends RestTest public void validateIdElementInGetSitePreferenceResponse() throws Exception { restPreferenceModel = restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser() - .getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); - restPreferenceModel.assertThat().field("id").is(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()) + .getPersonPreferenceInformation(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())); + restPreferenceModel.assertThat().field("id").is(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())) .and().field("value").is("true"); } @@ -201,9 +201,9 @@ public class GetPeoplePreferenceFullTests extends RestTest public void adminIsAbleToGetOtherUserPreference() throws Exception { restPreferenceModel = restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingUser(userModel) - .getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()); + .getPersonPreferenceInformation(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())); restClient.assertStatusCodeIs(HttpStatus.OK); - restPreferenceModel.assertThat().field("id").is(PreferenceName.SITES_FAVORITES_PREFIX + siteModel.getId()).and().field("value").is("true"); + restPreferenceModel.assertThat().field("id").is(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())).and().field("value").is("true"); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.FULL }) From 83dc5427122a146fe2e8e3c824f363d5bbc52f73 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Wed, 11 Jan 2017 16:36:55 +0200 Subject: [PATCH 0835/1491] added core tests for GetPreferences --- .../people/GetPeoplePreferencesCoreTests.java | 123 ++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesCoreTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesCoreTests.java new file mode 100644 index 000000000..94ea64631 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesCoreTests.java @@ -0,0 +1,123 @@ +package org.alfresco.rest.people; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestPreferenceModelsCollection; +import org.alfresco.utility.constants.PreferenceName; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * + * @author Cristina Axinte + * + */ +public class GetPeoplePreferencesCoreTests extends RestTest +{ + UserModel userModel, user1, user2, adminUser; + SiteModel siteModel; + FolderModel folderModel; + private RestPreferenceModelsCollection restPreferenceModelsCollection; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + + user1 = dataUser.createRandomTestUser(); + dataSite.usingUser(user1).usingSite(siteModel).addSiteToFavorites(); + dataContent.usingUser(user1).usingSite(siteModel).addFolderToFavorites(folderModel); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its preferences with invalid maxItems parameter with Rest API and response is 400") + public void userGetsPeoplePreferencesUsingInvalidMaxItemsParameter() throws Exception + { + restPreferenceModelsCollection = restClient.authenticateUser(user1).withCoreAPI().usingMe().usingParams("maxItems=0").getPersonPreferences(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsErrorKey(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) + .containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its preferences with skipCount parameter applied with Rest API and response is successful") + public void userGetsPeoplePreferencesUsingInvalidSkipCountParameter() throws Exception + { + restPreferenceModelsCollection = restClient.authenticateUser(user1).withCoreAPI().usingMe().usingParams("skipCount=-1").getPersonPreferences(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsErrorKey(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT) + .containsSummary(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user which doesn't have access to another user preferences fails to get its preferences with Rest API and response is permission denied") + public void userWithNoAccessToOtherUserPreferencesIsForbiddenToGetItsPreferences() throws Exception + { + UserModel noAccessUser = dataUser.createRandomTestUser(); + dataSite.usingUser(noAccessUser).usingSite(siteModel).addSiteToFavorites(); + + restPreferenceModelsCollection = restClient.authenticateUser(user1).withCoreAPI().usingUser(noAccessUser).getPersonPreferences(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + restClient.assertLastError().containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user fails to get preferences for inexistent personId with Rest API and response is 404") + public void userCannotGetPeoplePreferencesForInexistentPersonId() throws Exception + { + UserModel inexistentUserName = new UserModel("inexistent", "password"); + + restPreferenceModelsCollection = restClient.authenticateUser(user1).withCoreAPI().usingUser(inexistentUserName).getPersonPreferences(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + restClient.assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, inexistentUserName.getUsername())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user get preferences for a user with no preferences with Rest API and response is empty") + public void userGetsPeoplePreferencesForUserWithNoPreferences() throws Exception + { + UserModel userNoActivities = dataUser.createRandomTestUser(); + + restPreferenceModelsCollection = restClient.authenticateUser(adminUser).withCoreAPI().usingUser(userNoActivities).getPersonPreferences(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restPreferenceModelsCollection.assertThat().paginationField("count").is("0"); + restPreferenceModelsCollection.assertThat().entriesListIsEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user fails to get preferences for a removed preference with Rest API and response is 404") + public void userFailsToGetPeoplePreferencesIfPreferenceWasRemoved() throws Exception + { + SiteModel preferenceSite = dataSite.usingUser(user1).createPublicRandomSite(); + dataSite.usingUser(user1).usingSite(preferenceSite).addSiteToFavorites(); + restPreferenceModelsCollection = restClient.authenticateUser(user1).withCoreAPI().usingAuthUser().getPersonPreferences(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restPreferenceModelsCollection.assertThat().paginationField("count").is("6"); + + dataSite.usingUser(user1).usingSite(preferenceSite).removeSiteFromFavorites(); + restPreferenceModelsCollection = restClient.authenticateUser(user1).withCoreAPI().usingAuthUser().getPersonPreferences(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restPreferenceModelsCollection.assertThat().paginationField("count").is("5"); + restPreferenceModelsCollection.assertThat().entriesListDoesNotContain("id", String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), preferenceSite.getId())); + } +} From fa5c6c459b817df7b68fc2a5ff8b1fdb6d384386 Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 11 Jan 2017 16:40:51 +0200 Subject: [PATCH 0836/1491] TAS-2706 -> TAS-2717 getSiteMembershipRequest tests --- .../GetSiteMembershipRequestsFullTests.java | 170 ++++++++++++++++++ 1 file changed, 170 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsFullTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsFullTests.java new file mode 100644 index 000000000..59bcf2b5a --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsFullTests.java @@ -0,0 +1,170 @@ +package org.alfresco.rest.people; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestSiteMembershipRequestModel; +import org.alfresco.rest.model.RestSiteMembershipRequestModelsCollection; +import org.alfresco.rest.model.RestTaskModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Created by Claudia Agache on 1/10/2017. + */ +public class GetSiteMembershipRequestsFullTests extends RestTest +{ + UserModel siteManager, newMember, adminUser, regularUser; + SiteModel moderatedSite1, moderatedSite2, publicSite, privateSite; + RestSiteMembershipRequestModelsCollection siteMembershipRequests; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + siteManager = dataUser.createRandomTestUser(); + publicSite = dataSite.usingUser(siteManager).createPublicRandomSite(); + moderatedSite1 = dataSite.usingUser(siteManager).createModeratedRandomSite(); + moderatedSite2 = dataSite.usingUser(siteManager).createModeratedRandomSite(); + privateSite = dataSite.usingUser(siteManager).createPrivateRandomSite(); + + adminUser = dataUser.getAdminUser(); + newMember = dataUser.createRandomTestUser(); + regularUser = dataUser.createRandomTestUser(); + + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite1); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite1); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, + description = "Verify admin user gets all its own site membership requests with Rest API and response is successful (200)") + public void adminGetsItsOwnSiteMembershipRequestsWithSuccess() throws Exception + { + siteMembershipRequests = restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembershipRequests.assertThat().entriesListContains("id", moderatedSite1.getId()) + .assertThat().entriesListContains("id", moderatedSite2.getId()); + } + + @Bug(id = "MNT-16557") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, + description = "Verify regular user fails to get all site membership requests of another user with Rest API (403)") + public void regularUserFailsToGetSiteMembershipRequestsOfAnotherUser() throws Exception + { + restClient.authenticateUser(regularUser).withCoreAPI() + .usingUser(newMember).getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Bug(id = "MNT-16557") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, + description = "Verify regular user fails to get all site membership requests of admin with Rest API (403)") + public void regularUserFailsToGetSiteMembershipRequestsOfAdmin() throws Exception + { + restClient.authenticateUser(regularUser).withCoreAPI() + .usingUser(adminUser).getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, + description = "Verify regular user is able to get his site membership requests with, but skip the first one") + public void getSiteMembershipRequestsButSkipTheFirstOne() throws Exception + { + siteMembershipRequests = restClient.authenticateUser(newMember).withParams("orderBy=id ASC").withCoreAPI() + .usingMe().getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembershipRequests.assertThat().entriesListContains("id", moderatedSite1.getId()) + .assertThat().entriesListContains("id", moderatedSite2.getId()); + + RestSiteMembershipRequestModel firstSiteMembershipRequest = siteMembershipRequests.getEntries().get(0).onModel(); + + siteMembershipRequests = restClient.authenticateUser(newMember).withParams("orderBy=id ASC&skipCount=1").withCoreAPI() + .usingMe().getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembershipRequests.assertThat().entriesListDoesNotContain("id", firstSiteMembershipRequest.getId()) + .assertThat().entriesListContains("id", moderatedSite2.getId()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, + description = "Verify regular user is able to get his site membership requests with higher skipCount than number of requests") + public void getSiteMembershipRequestsWithHighSkipCount() throws Exception + { + siteMembershipRequests = restClient.authenticateUser(newMember).withParams("skipCount=3").withCoreAPI() + .usingMe().getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembershipRequests.assertThat().entriesListIsEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, + description = "Verify get site membership requests returns an empty list where there are no requests") + public void getSiteMembershipRequestsWhereThereAreNoRequests() throws Exception + { + siteMembershipRequests = restClient.authenticateUser(regularUser).withCoreAPI().usingMe().getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembershipRequests.assertThat().entriesListIsEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, + description = "Reject request then get site membership requests.") + public void rejectRequestThenGetSiteMembershipRequests() throws Exception + { + UserModel userWithRejectedRequests = dataUser.createRandomTestUser(); + + restClient.authenticateUser(userWithRejectedRequests).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite1); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestTaskModel taskModel = restClient.authenticateUser(userWithRejectedRequests).withWorkflowAPI().getTasks().getTaskModelByDescription(moderatedSite1); + workflow.approveSiteMembershipRequest(siteManager.getUsername(), siteManager.getPassword(), taskModel.getId(), false, "Rejected"); + + siteMembershipRequests = restClient.authenticateUser(userWithRejectedRequests).withCoreAPI().usingMe().getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembershipRequests.assertThat().entriesListDoesNotContain("id", moderatedSite1.getId()) + .assertThat().entriesListContains("id", moderatedSite2.getId()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, + description = "Check get site membership requests when properties parameter is used") + public void getSiteMembershipRequestsWithProperties() throws Exception + { + siteMembershipRequests = restClient.authenticateUser(newMember).withParams("properties=id") + .withCoreAPI().usingAuthUser().getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembershipRequests.assertThat().entriesListContains("id", moderatedSite1.getId()) + .assertThat().entriesListContains("id", moderatedSite2.getId()); + RestSiteMembershipRequestModel siteMembershipRequest = siteMembershipRequests.getOneRandomEntry().onModel(); + siteMembershipRequest.assertThat().fieldsCount().is(1); + } + +} From 5a8ae80da49e3af8c6f6184ae82428226b9230ba Mon Sep 17 00:00:00 2001 From: mionescu Date: Wed, 11 Jan 2017 16:42:41 +0200 Subject: [PATCH 0837/1491] test- updates --- .../favorites/DeleteFavoriteFullTests.java | 4 +-- .../favorites/DeleteFavoriteSanityTests.java | 35 ++----------------- 2 files changed, 5 insertions(+), 34 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteFullTests.java b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteFullTests.java index 7efeca5e9..5b6047afa 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteFullTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteFullTests.java @@ -141,7 +141,7 @@ public class DeleteFavoriteFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify user can't delete favorites using an invalid network ID.") @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) - public void userIsNotAbleToDeleteFavoriteSiteWithInvalidNetworkID() throws JsonToModelConversionException, Exception + public void userIsNotAbleToDeleteFavoriteSiteWithInvalidNetworkID() throws Exception { UserModel networkUserModel = dataUser.createRandomTestUser(); restClient.authenticateUser(networkUserModel).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); @@ -227,7 +227,7 @@ public class DeleteFavoriteFullTests extends RestTest public void tenantUserIsAbleToDeleteFavoriteSiteAddedByAdminSameNetwork() throws JsonToModelConversionException, Exception { adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUserModel).usingTenant().createTenant(adminTenantUser); + restClient.authenticateUser(adminUserModel).usingTenant().createTenant(adminTenantUser); tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); siteModel.setGuid(restClient.authenticateUser(adminTenantUser).withCoreAPI().usingSite(siteModel).getSite().getGuid()); diff --git a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteSanityTests.java index 8dd2bf957..6c12b8631 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteSanityTests.java @@ -27,7 +27,6 @@ public class DeleteFavoriteSanityTests extends RestTest adminUserModel = dataUser.getAdminUser(); siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - siteModel.setGuid(restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(siteModel).getSite().getGuid()); usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, @@ -39,7 +38,7 @@ public class DeleteFavoriteSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) public void adminIsAbleToDeleteFavorite() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); + restClient.withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); restClient.withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel).assertStatusCodeIs(HttpStatus.NO_CONTENT); restClient.withCoreAPI().usingAuthUser().getFavorites().assertThat().entriesListDoesNotContain("targetGuid", siteModel.getGuid()); @@ -67,6 +66,7 @@ public class DeleteFavoriteSanityTests extends RestTest { UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); siteManager.setPassword("wrongPassword"); + restClient.authenticateUser(siteManager).withCoreAPI().usingAuthUser() .deleteSiteFromFavorites(siteModel).assertStatusCodeIs(HttpStatus.UNAUTHORIZED) .assertLastError() @@ -117,37 +117,8 @@ public class DeleteFavoriteSanityTests extends RestTest UserModel siteCollaborator = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); restClient.authenticateUser(siteCollaborator).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel) - .assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Bug(id="MNT-16557") - @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Verify admin user doesn't have permission to delete favorites of another user with Rest API and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - public void adminIsNotAbleToDeleteFavoritesOfAnotherUser() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - - restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel) - .assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Bug(id = "MNT-16904", description = "fails only on environment with tenants") - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Verify user gets status code 401 if authentication call fails") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - public void userIsNotAbleToDeleteFavoritesIfAuthenticationFails() throws JsonToModelConversionException, Exception - { - UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); - siteManager.setPassword("wrongPassword"); - restClient.authenticateUser(siteManager).withCoreAPI().usingAuthUser() - .deleteSiteFromFavorites(siteModel).assertStatusCodeIs(HttpStatus.UNAUTHORIZED); restClient.withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel).assertStatusCodeIs(HttpStatus.NO_CONTENT); restClient.withCoreAPI().usingAuthUser().getFavorites().assertThat().entriesListDoesNotContain("targetGuid", siteModel.getGuid()); - } + } From 6ded774fd59ab9fd810d6906501c971041446fc0 Mon Sep 17 00:00:00 2001 From: mionescu Date: Wed, 11 Jan 2017 16:46:28 +0200 Subject: [PATCH 0838/1491] TEST- updated bug ID's --- .../alfresco/rest/favorites/DeleteFavoriteCoreTests.java | 4 ++-- .../alfresco/rest/favorites/DeleteFavoriteFullTests.java | 6 +++--- .../alfresco/rest/favorites/DeleteFavoriteSanityTests.java | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteCoreTests.java b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteCoreTests.java index 15c954a6f..ac965bcf9 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteCoreTests.java @@ -138,7 +138,7 @@ public class DeleteFavoriteCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } - @Bug(id="MNT-16557") + @Bug(id="ACE-5588") @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify user doesn't have permission to delete favorites of another user with Rest API and status code is 404") @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) @@ -153,7 +153,7 @@ public class DeleteFavoriteCoreTests extends RestTest .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } - @Bug(id="MNT-16557") + @Bug(id="ACE-5588") @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify admin user doesn't have permission to delete favorites of another user with Rest API and status code is 404") @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) diff --git a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteFullTests.java b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteFullTests.java index 5b6047afa..854fd3451 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteFullTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteFullTests.java @@ -70,7 +70,7 @@ public class DeleteFavoriteFullTests extends RestTest .entriesListDoesNotContain("targetGuid", fileModel.getNodeRefWithoutVersion()); } - @Bug(id="MNT-16557") + @Bug(id="ACE-5588") @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify consumer user doesn't have permission to delete favorites of another user with Rest API and status code is 404") @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) @@ -86,7 +86,7 @@ public class DeleteFavoriteFullTests extends RestTest .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } - @Bug(id="MNT-16557") + @Bug(id="ACE-5588") @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify contributor user doesn't have permission to delete favorites of another user with Rest API and status code is 404") @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) @@ -102,7 +102,7 @@ public class DeleteFavoriteFullTests extends RestTest .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } - @Bug(id="MNT-16557") + @Bug(id="ACE-5588") @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify contributor user doesn't have permission to delete favorites of another user with Rest API and status code is 404") @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) diff --git a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteSanityTests.java index 6c12b8631..acb7f60b3 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteSanityTests.java @@ -44,7 +44,7 @@ public class DeleteFavoriteSanityTests extends RestTest restClient.withCoreAPI().usingAuthUser().getFavorites().assertThat().entriesListDoesNotContain("targetGuid", siteModel.getGuid()); } - @Bug(id="MNT-16557") + @Bug(id="ACE-5588") @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify user doesn't have permission to delete favorites of admin user with Rest API and status code is 404") @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) From 5ba9eff3080593c3aaaa4a64c1d6ee9f1600df70 Mon Sep 17 00:00:00 2001 From: "NESS\\P3700299" Date: Wed, 11 Jan 2017 17:30:41 +0200 Subject: [PATCH 0839/1491] fixed test --- .../java/org/alfresco/rest/favorites/GetFavoriteCoreTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteCoreTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteCoreTests.java index e9d2df22a..e078d9bda 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteCoreTests.java @@ -123,7 +123,7 @@ public class GetFavoriteCoreTests extends RestTest { @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) public void getFavoriteFileUsingMe() throws Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingAuthUser().addFileToFavorites(fileModel); RestPersonFavoritesModel favoriteFile = restClient.withCoreAPI().usingMe().getFavorite(fileModel.getNodeRefWithoutVersion()); restClient.assertStatusCodeIs(HttpStatus.OK); From 3684c152d3b88e5657f456b0db761e22f59f8dc7 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Wed, 11 Jan 2017 17:41:45 +0200 Subject: [PATCH 0840/1491] Fixes for get favorite sites --- .../rest/favorites/GetFavoritesFullTests.java | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesFullTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesFullTests.java index 187bd0a30..382cbed41 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesFullTests.java @@ -63,7 +63,7 @@ public class GetFavoritesFullTests extends RestTest { userFavorites = restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().where().getFavorites(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_ARGUMENT, "WHERE query")); + .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_ARGUMENT, "WHERE query")); } @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, @@ -125,7 +125,7 @@ public class GetFavoritesFullTests extends RestTest { userFavorites = restClient.withCoreAPI().usingAuthUser().where().invalidWhereParameter("EXIST((target/site))").targetFileExist().getFavorites(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_ARGUMENT, "WHERE query")); + .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_ARGUMENT, "WHERE query")); } @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, @@ -137,8 +137,8 @@ public class GetFavoritesFullTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); userFavorites.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) - .and().entriesListContains("targetGuid", secondSiteModel.getGuid()) - .and().entriesListDoesNotContain("targetGuid", thirdSiteModel.getGuid()); + .and().entriesListContains("targetGuid", secondSiteModel.getGuid()) + .and().entriesListDoesNotContain("targetGuid", thirdSiteModel.getGuid()); } @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, @@ -150,12 +150,15 @@ public class GetFavoritesFullTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); userFavorites.assertThat().entriesListContains("targetGuid", thirdSiteModel.getGuid()) - .and().entriesListContains("targetGuid", secondSiteModel.getGuid()) - .and().entriesListDoesNotContain("targetGuid", firstSiteModel.getGuid()); + .and().entriesListContains("targetGuid", secondSiteModel.getGuid()) + .and().entriesListDoesNotContain("targetGuid", firstSiteModel.getGuid()) + .getPagination().assertThat().field("maxItems").is("2") + .and().field("hasMoreItems").is("true") + .and().field("count").is("2"); } @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify get first two favorites sites") + description = "Verify get favorites sites when using empty values for skipCount and maxItems") @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) public void userIsAbleToGetFavoritesWhenSkipCountAndMaxItemsAreEmpty() throws Exception { @@ -181,8 +184,7 @@ public class GetFavoritesFullTests extends RestTest tenantUser.setDomain("invalidNetwork"); restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().getFavorites(); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + .assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, @@ -225,4 +227,4 @@ public class GetFavoritesFullTests extends RestTest .field("id").is(thirdSiteModel.getId()).and() .field("title").is(thirdSiteModel.getTitle()); } -} +} \ No newline at end of file From 80f4f80bd8b2c3ebfc428a449c943a326dd71840 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Wed, 11 Jan 2017 17:52:05 +0200 Subject: [PATCH 0841/1491] fixed: updated getPersonActivitiesWithRetry to wait til the no of entries is as expected --- .../rest/people/AddSiteMembershipRequestSanityTests.java | 1 - .../org/alfresco/rest/people/GetPeopleActivitiesCoreTests.java | 2 +- .../org/alfresco/rest/people/GetPeopleActivitiesFullTests.java | 2 +- .../alfresco/rest/people/GetPeopleActivitiesSanityTests.java | 3 +-- .../rest/people/GetSiteMembershipRequestsSanityTests.java | 2 -- 5 files changed, 3 insertions(+), 7 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java index 91f59b4ef..a248b6cb2 100644 --- a/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java @@ -6,7 +6,6 @@ import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestSiteMembershipRequestModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; -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; diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesCoreTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesCoreTests.java index fbb7265da..cd86f55be 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesCoreTests.java @@ -45,7 +45,7 @@ public class GetPeopleActivitiesCoreTests extends RestTest dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel2, UserRole.SiteManager); // only once the activity list is checked with retry in order not to wait the entire list in each test - restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingMe().getPersonActivitiesWithRetry(); + restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingMe().getPersonActivitiesUntilEntriesCountIs(4); restClient.assertStatusCodeIs(HttpStatus.OK); restActivityModelsCollection.assertThat().paginationField("count").is("4"); } diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesFullTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesFullTests.java index f6536c095..ffe5b50d9 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesFullTests.java @@ -53,7 +53,7 @@ public class GetPeopleActivitiesFullTests extends RestTest dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel2, UserRole.SiteManager); // only once the activity list is checked with retry in order not to wait the entire list in each test - restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingMe().getPersonActivitiesWithRetry(); + restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingMe().getPersonActivitiesUntilEntriesCountIs(4); restClient.assertStatusCodeIs(HttpStatus.OK); restActivityModelsCollection.assertThat().paginationField("count").is("4"); } diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java index 96fb63082..f0b91dce5 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java @@ -39,9 +39,8 @@ public class GetPeopleActivitiesSanityTests extends RestTest unauthenticatedUser.setPassword("newpassword"); // only once the activity list is checked with retry in order not to wait the entire list in each test - restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().getPersonActivitiesWithRetry(); + restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().getPersonActivitiesUntilEntriesCountIs(5); restClient.assertStatusCodeIs(HttpStatus.OK); - restActivityModelsCollection.assertThat().entriesListIsNotEmpty(); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.SANITY }) diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java index 78a08b88e..1551fa7c3 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java @@ -5,7 +5,6 @@ import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestSiteMembershipRequestModelsCollection; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; -import org.alfresco.utility.data.RandomData; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; @@ -13,7 +12,6 @@ import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; -import org.springframework.social.alfresco.api.entities.Site.Visibility; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; From 8977512310b692dff88934e7dd4ef81807f20a1c Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Wed, 11 Jan 2017 18:27:23 +0200 Subject: [PATCH 0842/1491] Updates to get comments full tests --- .../rest/comments/GetCommentsFullTests.java | 86 ++++++------------- 1 file changed, 27 insertions(+), 59 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/comments/GetCommentsFullTests.java b/e2e-test/java/org/alfresco/rest/comments/GetCommentsFullTests.java index 6d8425bdb..b736d551f 100644 --- a/e2e-test/java/org/alfresco/rest/comments/GetCommentsFullTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/GetCommentsFullTests.java @@ -1,14 +1,12 @@ package org.alfresco.rest.comments; -import java.util.List; - import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestCommentModel; import org.alfresco.rest.model.RestCommentModelsCollection; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; @@ -18,6 +16,7 @@ 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.BeforeMethod; import org.testng.annotations.Test; public class GetCommentsFullTests extends RestTest @@ -28,6 +27,7 @@ public class GetCommentsFullTests extends RestTest private String comment2 = "This is the second comment"; private RestCommentModelsCollection comments; private DataUser.ListUserWithRoles usersWithRoles; + private FileModel file; @BeforeClass(alwaysRun=true) public void dataPreparation() throws Exception @@ -37,23 +37,25 @@ public class GetCommentsFullTests extends RestTest usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteContributor, UserRole.SiteConsumer); } + + @BeforeMethod(alwaysRun=true) + public void setUp() throws DataPreparationException, Exception { + file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + } @TestRail(section={TestGroup.REST_API, TestGroup.FULL, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Verify that if manager adds one comment, it will be returned in getComments response") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) public void addCommentWithManagerAndCheckThatCommentIsReturned() throws Exception { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(file).addComment(comment); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(file).addComment(comment); restClient.assertStatusCodeIs(HttpStatus.CREATED); comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", comment); - comments.assertThat().paginationField("totalItems").is("1"); - comments.assertThat().paginationField("count").is("1"); + comments.assertThat().entriesListContains("content", comment) + .getPagination().assertThat().field("totalItems").is("1") + .assertThat().field("count").is("1"); } @TestRail(section={TestGroup.REST_API, TestGroup.FULL, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, @@ -61,17 +63,15 @@ public class GetCommentsFullTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) public void addCommentWithCollaboratorAndCheckThatCommentIsReturned() throws Exception { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingResource(file).addComment(comment); + .withCoreAPI().usingResource(file).addComment(comment); restClient.assertStatusCodeIs(HttpStatus.CREATED); comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", comment); - comments.assertThat().paginationField("totalItems").is("1"); - comments.assertThat().paginationField("count").is("1"); + comments.assertThat().entriesListContains("content", comment) + .getPagination().assertThat().field("totalItems").is("1") + .assertThat().field("count").is("1"); } @TestRail(section={TestGroup.REST_API, TestGroup.FULL, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, @@ -80,17 +80,15 @@ public class GetCommentsFullTests extends RestTest @Bug(id = "ACE-4614") public void addCommentWithContributorAndCheckThatCommentIsReturned() throws Exception { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) - .withCoreAPI().usingResource(file).addComment(comment); + .withCoreAPI().usingResource(file).addComment(comment); restClient.assertStatusCodeIs(HttpStatus.CREATED); comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", comment); - comments.assertThat().paginationField("totalItems").is("1"); - comments.assertThat().paginationField("count").is("1"); + comments.assertThat().entriesListContains("content", comment) + .getPagination().assertThat().field("totalItems").is("1") + .assertThat().field("count").is("1"); } @TestRail(section={TestGroup.REST_API, TestGroup.FULL, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, @@ -98,10 +96,8 @@ public class GetCommentsFullTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) public void addCommentWithConsumerAndCheckThatCommentIsNotReturned() throws Exception { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .withCoreAPI().usingResource(file).addComment(comment); + .withCoreAPI().usingResource(file).addComment(comment); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); @@ -115,19 +111,13 @@ public class GetCommentsFullTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) public void addCommentWithManagerCheckReturnedPersonIsTheRightOne() throws Exception { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); UserModel user1 = dataUser.createRandomTestUser(); dataUser.addUserToSite(user1, siteModel, UserRole.SiteManager); restClient.authenticateUser(user1).withCoreAPI().usingResource(file).addComment(comment); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListIsNotEmpty(); - List commentsList = comments.getEntries(); - commentsList.get(0).onModel().getCreatedBy().assertThat().field("firstName").is(user1.getUsername() + " FirstName") - .assertThat().field("lastName").is("LN-" + user1.getUsername()); + comments.getOneRandomEntry().onModel().getCreatedBy().assertThat().field("firstName").is(user1.getUsername() + " FirstName") + .assertThat().field("lastName").is("LN-" + user1.getUsername()); } @TestRail(section={TestGroup.REST_API, TestGroup.FULL, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, @@ -135,16 +125,11 @@ public class GetCommentsFullTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) public void addCommentWithCollaboratorCheckReturnedCompanyDetails() throws Exception { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(file).addComment(comment); restClient.assertStatusCodeIs(HttpStatus.CREATED); comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListIsNotEmpty(); - List commentsList = comments.getEntries(); - commentsList.get(0).onModel().getCreatedBy().getCompany() + comments.getOneRandomEntry().onModel().getCreatedBy().getCompany() .assertThat().field("organization").isNull() .assertThat().field("address1").isNull() .assertThat().field("address2").isNull() @@ -160,12 +145,8 @@ public class GetCommentsFullTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) public void addTwoCommentsWithManagerCollaboratorVerifySkipCountParamIsApplied() throws Exception { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(file).addComment(comment); - restClient.assertStatusCodeIs(HttpStatus.CREATED); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(file).addComment(comment2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); comments = restClient.authenticateUser(adminUserModel).withParams("skipCount=1") .withCoreAPI().usingResource(file).getNodeComments(); @@ -181,12 +162,8 @@ public class GetCommentsFullTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) public void addTwoCommentsWithAdminCollaboratorVerifyMaxItemsParamIsApplied() throws Exception { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(comment); - restClient.assertStatusCodeIs(HttpStatus.CREATED); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(file).addComment(comment2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); comments = restClient.authenticateUser(adminUserModel).withParams("maxItems=1") .withCoreAPI().usingResource(file).getNodeComments(); @@ -201,27 +178,20 @@ public class GetCommentsFullTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) public void addTwoCommentsWithAdminManagerVerifyPropertiesParamIsApplied() throws Exception { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(comment); - restClient.assertStatusCodeIs(HttpStatus.CREATED); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(file).addComment(comment2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); comments = restClient.authenticateUser(adminUserModel).withParams("properties=createdBy,modifiedBy") .withCoreAPI().usingResource(file).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); comments.assertThat().entriesListIsNotEmpty() .and().paginationField("count").is("2"); comments.assertThat().paginationField("totalItems").is("2"); - List commentsList = comments.getEntries(); - - commentsList.get(0).onModel().getCreatedBy() + comments.getEntries().get(0).onModel().getCreatedBy() .assertThat().field("firstName").is(usersWithRoles.getOneUserWithRole(UserRole.SiteManager).getUsername() + " FirstName") .assertThat().field("lastName").is("LN-" + usersWithRoles.getOneUserWithRole(UserRole.SiteManager).getUsername()); - commentsList.get(1).onModel().getCreatedBy() + comments.getEntries().get(1).onModel().getCreatedBy() .assertThat().field("firstName").is("Administrator") .assertThat().field("id").is("admin"); } @@ -231,10 +201,8 @@ public class GetCommentsFullTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) public void addTwoCommentsWithManagerCheckDefaultErrorModelSchema() throws Exception { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(file).addComments(comment, comment2); + .withCoreAPI().usingResource(file).addComments(comment, comment2); restClient.assertStatusCodeIs(HttpStatus.CREATED); restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).usingParams("maxItems=0").getNodeComments(); From b3bc2168a2cde1ce877ff971712b73139bf71032 Mon Sep 17 00:00:00 2001 From: Bogdan Bocancea Date: Thu, 12 Jan 2017 12:07:59 +0200 Subject: [PATCH 0843/1491] update description for getFavoriteSiteUsingInvalidNetwork() test --- .../java/org/alfresco/rest/people/GetFavoriteSiteFullTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteFullTests.java b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteFullTests.java index 06c9fd69b..ef1d79fb2 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteFullTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteFullTests.java @@ -149,7 +149,7 @@ public class GetFavoriteSiteFullTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify request returns status 200 when using -me-") + description = "Verify request returns status 401 when using invalid network") public void getFavoriteSiteUsingInvalidNetwork() throws Exception { UserModel invalidUserNetwork = dataUser.createRandomTestUser(); From 6fcc3388f3adfd918358c22afdf9d707e552551e Mon Sep 17 00:00:00 2001 From: cagache Date: Thu, 12 Jan 2017 12:08:20 +0200 Subject: [PATCH 0844/1491] commented bug on 5.2 --- .../java/org/alfresco/rest/sites/UpdateSiteMemberCoreTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberCoreTests.java index 25ff17c44..9ac8ba828 100644 --- a/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberCoreTests.java @@ -68,7 +68,7 @@ public class UpdateSiteMemberCoreTests extends RestTest .assertLastError().containsSummary("User is not a member of the site"); } - @Bug(id="REPO-1642", description = "reproduced on 5.2.1 only, it works on 5.2.0") +// @Bug(id="REPO-1642", description = "reproduced on 5.2.1 only, it works on 5.2.0") @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if update site member request returns status code 404 when personId does not exist") From 2d70045eed60239a3770ea1aa39a6cfbfb95e32d Mon Sep 17 00:00:00 2001 From: cagache Date: Thu, 12 Jan 2017 12:27:46 +0200 Subject: [PATCH 0845/1491] replaced assertLastException with assertLastError for all tests annotated with MNT-16904 --- .../org/alfresco/rest/comments/AddCommentCoreTests.java | 3 ++- .../org/alfresco/rest/comments/AddCommentSanityTests.java | 3 ++- .../alfresco/rest/comments/DeleteCommentsSanityTests.java | 4 +++- .../org/alfresco/rest/comments/GetCommentsSanityTests.java | 4 +++- .../alfresco/rest/comments/UpdateCommentsSanityTests.java | 3 ++- .../alfresco/rest/favorites/AddFavoritesSanityTests.java | 4 +++- .../alfresco/rest/favorites/DeleteFavoriteSanityTests.java | 3 ++- .../org/alfresco/rest/favorites/GetFavoritesCoreTests.java | 2 +- .../rest/networks/RestGetNetworksForPersonSanityTests.java | 4 +++- .../alfresco/rest/people/AddFavoriteSiteSanityTests.java | 4 +++- .../alfresco/rest/people/DeleteFavoriteSiteCoreTests.java | 2 +- .../people/DeleteSiteMembershipRequestSanityTests.java | 3 ++- .../alfresco/rest/people/GetFavoriteSiteSanityTests.java | 3 ++- .../alfresco/rest/people/GetFavoriteSitesSanityTests.java | 3 ++- .../rest/people/GetPeoplePreferenceSanityTests.java | 4 +++- .../rest/people/GetPeoplePreferencesSanityTests.java | 4 +++- .../alfresco/rest/people/GetSiteMembershipCoreTests.java | 2 +- .../rest/people/GetSiteMembershipRequestCoreTests.java | 5 +++-- .../alfresco/rest/people/GetSiteMembershipSanityTests.java | 4 +++- .../people/GetSitesMembershipInformationSanityTests.java | 4 +++- .../org/alfresco/rest/ratings/AddRatingSanityTests.java | 7 +++++-- .../org/alfresco/rest/ratings/DeleteRatingSanityTests.java | 7 +++++-- .../org/alfresco/rest/ratings/GetRatingsSanityTests.java | 3 ++- .../org/alfresco/rest/sites/AddSiteMemberSanityTests.java | 4 +++- .../alfresco/rest/sites/GetSiteContainerSanityTests.java | 4 +++- .../alfresco/rest/sites/GetSiteContainersSanityTests.java | 4 +++- .../org/alfresco/rest/sites/GetSiteMemberSanityTests.java | 4 +++- .../org/alfresco/rest/sites/GetSiteMembersSanityTests.java | 4 +++- .../java/org/alfresco/rest/sites/GetSiteSanityTests.java | 4 +++- .../java/org/alfresco/rest/sites/GetSitesSanityTests.java | 4 +++- .../alfresco/rest/sites/RemoveSiteMemberSanityTests.java | 4 +++- .../alfresco/rest/sites/UpdateSiteMemberSanityTests.java | 4 +++- .../java/org/alfresco/rest/tags/AddTagSanityTests.java | 3 ++- .../java/org/alfresco/rest/tags/AddTagsSanityTests.java | 3 ++- .../java/org/alfresco/rest/tags/DeleteTagSanityTests.java | 3 ++- .../org/alfresco/rest/tags/GetNodeTagsSanityTests.java | 4 +++- .../java/org/alfresco/rest/tags/GetTagSanityTests.java | 4 +++- .../java/org/alfresco/rest/tags/GetTagsSanityTests.java | 4 +++- .../java/org/alfresco/rest/tags/UpdateTagSanityTests.java | 3 ++- .../rest/workflow/tasks/DeleteTaskVariableCoreTests.java | 3 ++- .../rest/workflow/tasks/RemoveTaskItemCoreTests.java | 3 ++- .../rest/workflow/tasks/UpdateTaskVariableCoreTests.java | 3 ++- 42 files changed, 109 insertions(+), 45 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentCoreTests.java b/e2e-test/java/org/alfresco/rest/comments/AddCommentCoreTests.java index 732fd1a23..23ea6a54f 100644 --- a/e2e-test/java/org/alfresco/rest/comments/AddCommentCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/AddCommentCoreTests.java @@ -147,7 +147,8 @@ public class AddCommentCoreTests extends RestTest restClient.authenticateUser(member) .withCoreAPI().usingResource(document).addComment(comment); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java index 89484e438..c5625db02 100644 --- a/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java @@ -106,7 +106,8 @@ public class AddCommentSanityTests extends RestTest { restClient.authenticateUser(new UserModel("random user", "random password")); restClient.withCoreAPI().usingResource(document).addComment("This is a new comment"); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } } diff --git a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java index c12260d5e..3d23be26d 100644 --- a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java @@ -4,6 +4,7 @@ import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestCommentModel; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.FileModel; @@ -90,6 +91,7 @@ public class DeleteCommentsSanityTests extends RestTest UserModel nonexistentModel = new UserModel("nonexistentUser", "nonexistentPassword"); restClient.authenticateUser(nonexistentModel); restClient.withCoreAPI().usingResource(document).deleteComment(comment); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } } diff --git a/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java index 4385ea6d8..d3e2927ac 100644 --- a/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java @@ -4,6 +4,7 @@ import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestCommentModelsCollection; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.FileModel; @@ -105,7 +106,8 @@ public class GetCommentsSanityTests extends RestTest UserModel nonexistentModel = new UserModel("nonexistentUser", "nonexistentPassword"); restClient.authenticateUser(nonexistentModel).withCoreAPI() .usingResource(document).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.SANITY, diff --git a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java index 10f66a968..05badefac 100644 --- a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java @@ -114,7 +114,8 @@ public class UpdateCommentsSanityTests extends RestTest UserModel incorrectUserModel = new UserModel("userName", "password"); restClient.authenticateUser(incorrectUserModel) .withCoreAPI().usingResource(document).updateComment(commentModel, "try to update"); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } @TestRail(section = { TestGroup.REST_API, TestGroup.SANITY }, executionType = ExecutionType.SANITY, description = "Verify update comment with inexistent nodeId returns status code 404") diff --git a/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesSanityTests.java index 91fb77a7e..8a270a7c8 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesSanityTests.java @@ -2,6 +2,7 @@ package org.alfresco.rest.favorites; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestPersonFavoritesModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; @@ -95,6 +96,7 @@ public class AddFavoritesSanityTests extends RestTest UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); siteManager.setPassword("wrongPassword"); restClient.authenticateUser(siteManager).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } } diff --git a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteSanityTests.java index 2d399c106..4aabae20f 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteSanityTests.java @@ -166,6 +166,7 @@ public class DeleteFavoriteSanityTests extends RestTest UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); siteManager.setPassword("wrongPassword"); restClient.authenticateUser(siteManager).withCoreAPI().usingAuthUser() - .deleteSiteFromFavorites(siteModel).assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + .deleteSiteFromFavorites(siteModel).assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } } diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesCoreTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesCoreTests.java index 94c4175f9..5585e77f1 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesCoreTests.java @@ -235,7 +235,7 @@ public class GetFavoritesCoreTests extends RestTest .and().paginationField("totalItems").is("2"); } - @Bug(id="REPO-1642", description = "reproduced on 5.2.1 only, it works on 5.2.0") +// @Bug(id="REPO-1642", description = "reproduced on 5.2.1 only, it works on 5.2.0") @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify request using personId that does not exist returns status 404") @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonSanityTests.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonSanityTests.java index c22cf8901..b045e101c 100644 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonSanityTests.java @@ -1,6 +1,7 @@ package org.alfresco.rest.networks; import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; @@ -36,7 +37,8 @@ public class RestGetNetworksForPersonSanityTests extends RestTest tenantUser.setDomain(adminTenantUser.getDomain()); restClient.authenticateUser(tenantUser); restClient.withCoreAPI().usingAuthUser().getNetworks(adminTenantUser); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, diff --git a/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteSanityTests.java index 8bb41699c..a6c8a7c74 100644 --- a/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteSanityTests.java @@ -1,6 +1,7 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestFavoriteSiteModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.model.SiteModel; @@ -100,6 +101,7 @@ public class AddFavoriteSiteSanityTests extends RestTest managerUser.setPassword("newpassword"); restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().addFavoriteSite(siteModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } } diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteCoreTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteCoreTests.java index cb1c898da..265a878e7 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteCoreTests.java @@ -42,7 +42,7 @@ public class DeleteFavoriteSiteCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @Bug(id = "REPO-1642", description = "reproduced on 5.2.1 only, it works on 5.2.0") +// @Bug(id = "REPO-1642", description = "reproduced on 5.2.1 only, it works on 5.2.0") @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify inexistent user is not able to remove a site from favorites and response is 404") public void inexistentUserIsNotAbleToRemoveFavoriteSite() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java index b41d19224..5c6c69a94 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java @@ -131,6 +131,7 @@ public class DeleteSiteMembershipRequestSanityTests extends RestTest restClient.authenticateUser(dataUser.createRandomTestUser()).withCoreAPI().usingAuthUser().addSiteMembershipRequest(siteModel); UserModel inexistentUser = new UserModel("inexistent user", "inexistent password"); restClient.authenticateUser(inexistentUser).withCoreAPI().usingAuthUser().deleteSiteMembershipRequest(siteModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } } diff --git a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java index 55fb74ea9..070a2020f 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java @@ -131,6 +131,7 @@ public class GetFavoriteSiteSanityTests extends RestTest managerUser.setPassword("newpassword"); restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().getFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } } diff --git a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java index 840157a6b..d4d169b8f 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java @@ -118,6 +118,7 @@ public class GetFavoriteSitesSanityTests extends RestTest anyUser.setPassword("newpassword"); restClient.authenticateUser(anyUser).withCoreAPI().usingAuthUser().getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } } diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceSanityTests.java index 74013fd91..b9d7427e1 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceSanityTests.java @@ -1,6 +1,7 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestPreferenceModel; import org.alfresco.utility.constants.PreferenceName; import org.alfresco.utility.constants.UserRole; @@ -114,6 +115,7 @@ public class GetPeoplePreferenceSanityTests extends RestTest restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser() .getPersonPreferenceInformation(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } } diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesSanityTests.java index 6a871427f..b7a3da1fd 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesSanityTests.java @@ -1,6 +1,7 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestPreferenceModelsCollection; import org.alfresco.utility.constants.PreferenceName; import org.alfresco.utility.constants.UserRole; @@ -115,6 +116,7 @@ public class GetPeoplePreferencesSanityTests extends RestTest managerUser.setPassword("newpassword"); restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().getPersonPreferences(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } } diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipCoreTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipCoreTests.java index 66670c3f9..d867acfd1 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipCoreTests.java @@ -55,7 +55,7 @@ public class GetSiteMembershipCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @Bug(id = "REPO-1642", description = "reproduced on 5.2.1 only, it works on 5.2.0") +// @Bug(id = "REPO-1642", description = "reproduced on 5.2.1 only, it works on 5.2.0") @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify get site membership for a site returns status 404 when personId does not exist.") public void getSiteMembershipUsingNonExistentPersonId() throws Exception { diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestCoreTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestCoreTests.java index 85e9185e4..b5ef3a2a2 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestCoreTests.java @@ -38,7 +38,7 @@ public class GetSiteMembershipRequestCoreTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify contributor user fails to get all site membership requests of a specific person with Rest API when the authentication fails (401)") - @Bug(id = "16904") + @Bug(id = "MNT-16904") public void unauthorizedContributorUserFailsToGetSiteMembershipRequests() throws Exception { UserModel contributor = dataUser.usingAdmin().createRandomTestUser(); @@ -71,7 +71,8 @@ public class GetSiteMembershipRequestCoreTests extends RestTest dataUser.usingUser(userModel).addUserToSite(consumer, siteModel, UserRole.SiteContributor); consumer.setPassword("newpassword"); restClient.authenticateUser(consumer).withCoreAPI().usingUser(newMember).getSiteMembershipRequest(siteModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java index f3ba0e718..6d46dfbc2 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java @@ -2,6 +2,7 @@ package org.alfresco.rest.people; 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; @@ -84,6 +85,7 @@ public class GetSiteMembershipSanityTests extends RestTest { restClient.authenticateUser(new UserModel("random user", "random password")).withCoreAPI() .usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).getSiteMembership(siteModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java index 59f3c16a7..74f5b07f3 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java @@ -2,6 +2,7 @@ package org.alfresco.rest.people; 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; @@ -83,6 +84,7 @@ public class GetSitesMembershipInformationSanityTests extends RestTest UserModel inexistentUser = new UserModel("inexistent user", "wrong password"); restClient.authenticateUser(inexistentUser).withCoreAPI().usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) .getSitesMembershipInformation(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java index 8f0e2253d..503db0088 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java @@ -2,6 +2,7 @@ package org.alfresco.rest.ratings; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestRatingModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; @@ -123,7 +124,8 @@ public class AddRatingSanityTests extends RestTest FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); restClient.authenticateUser(new UserModel("random user", "random password")).withCoreAPI().usingResource(document).likeDocument(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } @TestRail(section = { TestGroup.REST_API, @@ -206,6 +208,7 @@ public class AddRatingSanityTests extends RestTest FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); restClient.authenticateUser(new UserModel("random user", "random password")).withCoreAPI().usingResource(document).rateStarsToDocument(5); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java index aa5caa827..1b2472d2b 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java @@ -2,6 +2,7 @@ package org.alfresco.rest.ratings; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestRatingModelsCollection; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; @@ -177,10 +178,12 @@ public class DeleteRatingSanityTests extends RestTest restClient.authenticateUser(new UserModel("random user", "random password")); restClient.withCoreAPI().usingResource(document).deleteLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } @TestRail(section = { TestGroup.REST_API,TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify one user is not able to remove rating added by another user") diff --git a/e2e-test/java/org/alfresco/rest/ratings/GetRatingsSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/GetRatingsSanityTests.java index 58a0f18a3..0c07f6419 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/GetRatingsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/GetRatingsSanityTests.java @@ -144,6 +144,7 @@ public class GetRatingsSanityTests extends RestTest restClient.authenticateUser(new UserModel("random user", "random password")); restClient.withCoreAPI().usingResource(document).getRatings(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(RestErrorModel.AUTHENTICATION_FAILED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java index 7a7c5916b..a99b7713e 100644 --- a/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java @@ -1,6 +1,7 @@ package org.alfresco.rest.sites; import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.SiteModel; @@ -111,6 +112,7 @@ public class AddSiteMemberSanityTests extends RestTest UserModel inexistentUser = new UserModel("inexistent user", "inexistent password"); restClient.authenticateUser(inexistentUser) .withCoreAPI().usingSite(siteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } } diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java index 3082c299f..34517290d 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java @@ -1,6 +1,7 @@ package org.alfresco.rest.sites; import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestSiteContainerModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; @@ -112,6 +113,7 @@ public class GetSiteContainerSanityTests extends RestTest dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); restClient.authenticateUser(userModel) .withCoreAPI().usingSite(siteModel).getSiteContainer(siteContainerModel.onModel()); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } } diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java index 492c49495..775947145 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java @@ -2,6 +2,7 @@ package org.alfresco.rest.sites; 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.model.SiteModel; @@ -108,6 +109,7 @@ public class GetSiteContainersSanityTests extends RestTest dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); restClient.authenticateUser(userModel) .withCoreAPI().usingSite(siteModel).getSiteContainers(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } } diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java index fd320cd8b..046721e56 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java @@ -2,6 +2,7 @@ package org.alfresco.rest.sites; 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; @@ -105,6 +106,7 @@ public class GetSiteMemberSanityTests extends RestTest UserModel inexistentUser = new UserModel("inexistent user", "inexistent password"); restClient.authenticateUser(inexistentUser); restClient.withCoreAPI().usingSite(siteModel).getSiteMember(userModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } } diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java index af245beb4..4b2cf6c80 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java @@ -2,6 +2,7 @@ package org.alfresco.rest.sites; 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; @@ -104,6 +105,7 @@ public class GetSiteMembersSanityTests extends RestTest dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); restClient.authenticateUser(userModel) .withCoreAPI().usingSite(siteModel).getSiteMembers(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } } diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteSanityTests.java index 2f8290df7..b5813979e 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteSanityTests.java @@ -2,6 +2,7 @@ package org.alfresco.rest.sites; 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; @@ -113,6 +114,7 @@ public class GetSiteSanityTests extends RestTest restClient.authenticateUser(userModel).withParams("maxItems=10000") .withCoreAPI() .getSites(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } } diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java index f4b6266fb..12792a552 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java @@ -2,6 +2,7 @@ package org.alfresco.rest.sites; 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.model.SiteModel; @@ -110,6 +111,7 @@ public class GetSitesSanityTests extends RestTest dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); restClient.authenticateUser(userModel).withParams("maxItems=1") .withCoreAPI().getSites(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } } diff --git a/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java index c84996bca..a1395a62e 100644 --- a/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java @@ -1,6 +1,7 @@ package org.alfresco.rest.sites; import org.alfresco.rest.RestTest; +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; @@ -125,6 +126,7 @@ public class RemoveSiteMemberSanityTests extends RestTest UserModel inexistentUser = new UserModel("inexistent user", "inexistent password"); restClient.authenticateUser(inexistentUser).withCoreAPI().usingSite(siteModel).deleteSiteMember(testUserModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } } diff --git a/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java index b09c3ddf3..f924eb71a 100644 --- a/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java @@ -1,6 +1,7 @@ package org.alfresco.rest.sites; import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.SiteModel; @@ -108,6 +109,7 @@ public class UpdateSiteMemberSanityTests extends RestTest restClient.authenticateUser(inexistentUser); testUserModel.setUserRole(UserRole.SiteCollaborator); restClient.withCoreAPI().usingSite(siteModel).updateSiteMember(testUserModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } } diff --git a/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java index d9d08fbcd..84e2d8f10 100644 --- a/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java @@ -128,6 +128,7 @@ public class AddTagSanityTests extends RestTest siteManager.setPassword("wrongPassword"); restClient.authenticateUser(siteManager); restClient.withCoreAPI().usingResource(document).addTag("tagUnauthorized"); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/tags/AddTagsSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/AddTagsSanityTests.java index ca09f76ef..712715ee2 100644 --- a/e2e-test/java/org/alfresco/rest/tags/AddTagsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/AddTagsSanityTests.java @@ -126,6 +126,7 @@ public class AddTagsSanityTests extends RestTest UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); siteManager.setPassword("wrongPassword"); restClient.authenticateUser(siteManager).withCoreAPI().usingResource(document).addTags(tag1, tag2); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/tags/DeleteTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/DeleteTagSanityTests.java index 0cba0200b..963cf13ad 100644 --- a/e2e-test/java/org/alfresco/rest/tags/DeleteTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/DeleteTagSanityTests.java @@ -130,6 +130,7 @@ public class DeleteTagSanityTests extends RestTest siteManager.setPassword("wrongPassword"); restClient.authenticateUser(siteManager); restClient.withCoreAPI().usingResource(document).deleteTag(tag); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java index e22ad4e1e..19b263703 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java @@ -3,6 +3,7 @@ package org.alfresco.rest.tags; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestTagModelsCollection; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; @@ -124,6 +125,7 @@ public class GetNodeTagsSanityTests extends RestTest { restClient.authenticateUser(new UserModel("random user", "random password")); restClient.withCoreAPI().usingResource(document).getNodeTags(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/tags/GetTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagSanityTests.java index 192c01e20..62122f44e 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetTagSanityTests.java @@ -3,6 +3,7 @@ package org.alfresco.rest.tags; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestTagModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; @@ -120,7 +121,8 @@ public class GetTagSanityTests extends RestTest managerUser.setPassword("wrongPassword"); restClient.authenticateUser(managerUser); restClient.withCoreAPI().getTag(tag); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java index 508017a5d..df502158e 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java @@ -3,6 +3,7 @@ package org.alfresco.rest.tags; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestTagModelsCollection; import org.alfresco.utility.Utility; import org.alfresco.utility.constants.UserRole; @@ -118,6 +119,7 @@ public class GetTagsSanityTests extends RestTest dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); restClient.authenticateUser(userModel); restClient.withCoreAPI().getTags(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } } diff --git a/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java index 259c01b28..442e24e10 100644 --- a/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java @@ -111,6 +111,7 @@ public class UpdateTagSanityTests extends RestTest siteManager.setPassword("wrongPassword"); restClient.authenticateUser(siteManager); restClient.withCoreAPI().usingTag(oldTag).update(randomTag); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/DeleteTaskVariableCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/DeleteTaskVariableCoreTests.java index 893156fea..3cb14acf9 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/DeleteTaskVariableCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/DeleteTaskVariableCoreTests.java @@ -120,6 +120,7 @@ public class DeleteTaskVariableCoreTests extends RestTest .withWorkflowAPI() .usingTask(taskModel) .deleteTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/RemoveTaskItemCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/RemoveTaskItemCoreTests.java index 5802f0246..462d8e477 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/RemoveTaskItemCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/RemoveTaskItemCoreTests.java @@ -129,7 +129,8 @@ public class RemoveTaskItemCoreTests extends RestTest document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); taskItem = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); restClient.authenticateUser(UserModel.getRandomUserModel()).withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskVariableCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskVariableCoreTests.java index 595d696b9..e38d7ea47 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskVariableCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskVariableCoreTests.java @@ -167,7 +167,8 @@ public class UpdateTaskVariableCoreTests extends RestTest variableModel.setName("new-name"); taskVariable = restClient.authenticateUser(UserModel.getRandomUserModel()) .withWorkflowAPI().usingTask(taskModel).updateTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } } \ No newline at end of file From 9fccc649574f026e70877848c08edbb770b1bb1f Mon Sep 17 00:00:00 2001 From: cagache Date: Thu, 12 Jan 2017 12:32:56 +0200 Subject: [PATCH 0846/1491] added test annotation --- .../java/org/alfresco/rest/comments/DeleteCommentsCoreTests.java | 1 + 1 file changed, 1 insertion(+) diff --git a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsCoreTests.java b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsCoreTests.java index cefe84996..83e63ef7e 100644 --- a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsCoreTests.java @@ -38,6 +38,7 @@ public class DeleteCommentsCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Consumer user can't delete comments created by admin user and status code is 403") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) public void consumerIsNotAbleToDeleteComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); From b2959c36ddf401f12d7bd64847659d8f96fa26d6 Mon Sep 17 00:00:00 2001 From: cagache Date: Thu, 12 Jan 2017 12:37:22 +0200 Subject: [PATCH 0847/1491] added test annotation --- .../alfresco/rest/workflow/tasks/AddTaskVariablesCoreTests.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesCoreTests.java index 946f6028e..b3b31a4b6 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesCoreTests.java @@ -79,6 +79,7 @@ public class AddTaskVariablesCoreTests extends RestTest } + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case incomplete body - missing required: name type is provided") public void failedAddingTaskVariableIfIncompleteRequiredBodyIsProvided() throws Exception { @@ -103,6 +104,7 @@ public class AddTaskVariablesCoreTests extends RestTest } @Bug(id = "ACE-5674") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case invalid type prefix is provided") public void failedAddingTaskVariableIfInvalidTypePrefixIsProvided() throws Exception { From d5be0fe1da98ed2e17da13ab3af73983b84a00a7 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Thu, 12 Jan 2017 15:42:46 +0200 Subject: [PATCH 0848/1491] Add missing sanity tests for Get network membership --- .../RestGetNetworksForPersonSanityTests.java | 69 +++++++++++++++++-- 1 file changed, 65 insertions(+), 4 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonSanityTests.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonSanityTests.java index b045e101c..d1d4bb596 100644 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonSanityTests.java @@ -2,6 +2,9 @@ package org.alfresco.rest.networks; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestNetworkModelsCollection; +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.report.Bug; @@ -14,8 +17,9 @@ import org.testng.annotations.Test; public class RestGetNetworksForPersonSanityTests extends RestTest { private UserModel adminUserModel; - UserModel adminTenantUser; - UserModel tenantUser; + private UserModel adminTenantUser; + private UserModel tenantUser; + private SiteModel siteModel; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception @@ -25,11 +29,12 @@ public class RestGetNetworksForPersonSanityTests extends RestTest restClient.authenticateUser(adminUserModel); restClient.usingTenant().createTenant(adminTenantUser); tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); } @Bug(id = "MNT-16904") @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, - description = "Verify non existing user gets another exisiting network with Rest API and checks the forbidden status") + description = "Verify non existing user gets another exisiting network with Rest API and checks the unauthorized status") @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY, TestGroup.COMMENTS, TestGroup.NETWORKS }) public void nonExistingTenantUserIsNotAuthorizedToRequest() throws Exception { @@ -73,4 +78,60 @@ public class RestGetNetworksForPersonSanityTests extends RestTest restClient.withCoreAPI().usingAuthUser().getNetworks(secondTenantUser); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); } -} + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, + description = "Verify tenant manager user gets specific network with Rest API and response is not empty") + @Test(groups = {TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY, TestGroup.COMMENTS, TestGroup.NETWORKS }) + public void managerTenantChecksIfNetworkIsPresent() throws Exception + { + UserModel managerTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("managerTenant"); + dataUser.usingUser(adminTenantUser).addUserToSite(managerTenantUser, siteModel, UserRole.SiteManager); + + restClient.authenticateUser(managerTenantUser); + RestNetworkModelsCollection networks = restClient.withCoreAPI().usingAuthUser().getNetworks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + networks.getOneRandomEntry().onModel().assertNetworkIsEnabled().and().field("id").is(managerTenantUser.getDomain().toLowerCase()); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, + description = "Verify tenant collaborator user gets specific network with Rest API and response is not empty") + @Test(groups = {TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY, TestGroup.COMMENTS, TestGroup.NETWORKS }) + public void collaboratorTenantChecksIfNetworkIsPresent() throws Exception + { + UserModel collaboratorTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("collaboratorTenant"); + dataUser.usingUser(adminTenantUser).addUserToSite(collaboratorTenantUser, siteModel, UserRole.SiteCollaborator); + + restClient.authenticateUser(collaboratorTenantUser); + RestNetworkModelsCollection networks = restClient.withCoreAPI().usingAuthUser().getNetworks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + networks.getOneRandomEntry().onModel().assertNetworkIsEnabled().and().field("id").is(collaboratorTenantUser.getDomain().toLowerCase()); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, + description = "Verify tenant contributor user gets specific network with Rest API and response is not empty") + @Test(groups = {TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY, TestGroup.COMMENTS, TestGroup.NETWORKS }) + public void contributorTenantChecksIfNetworkIsPresent() throws Exception + { + UserModel contributorTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("contributorTenant"); + dataUser.usingUser(adminTenantUser).addUserToSite(contributorTenantUser, siteModel, UserRole.SiteContributor); + + restClient.authenticateUser(contributorTenantUser); + RestNetworkModelsCollection networks = restClient.withCoreAPI().usingAuthUser().getNetworks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + networks.getOneRandomEntry().onModel().assertNetworkIsEnabled().and().field("id").is(contributorTenantUser.getDomain().toLowerCase()); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, + description = "Verify tenant consumer user gets specific network with Rest API and response is not empty") + @Test(groups = {TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY, TestGroup.COMMENTS, TestGroup.NETWORKS }) + public void consumerTenantChecksIfNetworkIsPresent() throws Exception + { + UserModel consumerTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("consumerTenant"); + dataUser.usingUser(adminTenantUser).addUserToSite(consumerTenantUser, siteModel, UserRole.SiteConsumer); + + restClient.authenticateUser(consumerTenantUser); + RestNetworkModelsCollection networks = restClient.withCoreAPI().usingAuthUser().getNetworks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + networks.getOneRandomEntry().onModel().assertNetworkIsEnabled().and().field("id").is(consumerTenantUser.getDomain().toLowerCase()); + } +} \ No newline at end of file From 7d702890ac8f1f98fcc02fdf007b4fa21dc5a01e Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Thu, 12 Jan 2017 16:16:33 +0200 Subject: [PATCH 0849/1491] Fixing AddFavoritesCoreTests --- .../alfresco/rest/favorites/AddFavoritesCoreTests.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesCoreTests.java b/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesCoreTests.java index 2c09b2b53..cbe312f90 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesCoreTests.java @@ -88,7 +88,7 @@ public class AddFavoritesCoreTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) public void addFavoriteTwice() throws Exception { - restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); restClient.assertStatusCodeIs(HttpStatus.CONFLICT); @@ -129,7 +129,7 @@ public class AddFavoritesCoreTests extends RestTest .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.withCoreAPI().usingAuthUser().getFavoriteSites().assertThat().entriesListContains("guid", siteModel.getGuid()); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().getFavoriteSites().assertThat().entriesListContains("guid", siteModel.getGuid()); } @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, @@ -164,7 +164,7 @@ public class AddFavoritesCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.CREATED); restPersonFavoritesModel.assertThat().field("targetGuid").is(siteModel.getGuid()); - restClient.withCoreAPI().usingAuthUser().getFavoriteSites().assertThat().entriesListContains("guid", siteModel.getGuid()); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().getFavoriteSites().assertThat().entriesListContains("guid", siteModel.getGuid()); } @Bug(id = "MNT-17158") @@ -204,7 +204,7 @@ public class AddFavoritesCoreTests extends RestTest String guid = siteModel.getGuid(); siteModel.setGuid(document.getNodeRefWithoutVersion()); - restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, document.getNodeRefWithoutVersion())); siteModel.setGuid(guid); @@ -218,7 +218,7 @@ public class AddFavoritesCoreTests extends RestTest String nodeRef = folder.getNodeRef(); folder.setNodeRef(document.getNodeRef()); - restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(folder); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFolderToFavorites(folder); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, document.getNodeRef())); folder.setNodeRef(nodeRef); From 960350f5d6652865ec75355a2a7cf2a1ecba56a1 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Thu, 12 Jan 2017 16:52:58 +0200 Subject: [PATCH 0850/1491] Fixing AddFavorites Core and Sanity Tests --- .../alfresco/rest/favorites/AddFavoritesCoreTests.java | 8 ++++---- .../alfresco/rest/favorites/AddFavoritesSanityTests.java | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesCoreTests.java b/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesCoreTests.java index cbe312f90..941dd06b5 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesCoreTests.java @@ -55,7 +55,7 @@ public class AddFavoritesCoreTests extends RestTest SiteModel site = dataSite.usingUser(adminUserModel).createPublicRandomSite(); site.setGuid(link.getNodeRef()); - restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(site); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteToFavorites(site); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, site.getGuid().split("/")[3])); } @@ -64,7 +64,7 @@ public class AddFavoritesCoreTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) public void addFavoriteUsingInexistentUser() throws Exception { - restClient.withCoreAPI().usingUser(new UserModel("random_user", "random_password")).addSiteToFavorites(siteModel); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(new UserModel("random_user", "random_password")).addSiteToFavorites(siteModel); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "random_user")); } @@ -77,7 +77,7 @@ public class AddFavoritesCoreTests extends RestTest SiteModel site = dataSite.usingUser(adminUserModel).createPublicRandomSite(); site.setGuid("random_guid"); - restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(site); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteToFavorites(site); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "random_guid")); } @@ -102,7 +102,7 @@ public class AddFavoritesCoreTests extends RestTest String nodeRef = document.getNodeRef(); document.setNodeRef(folder.getNodeRef()); - restClient.withCoreAPI().usingAuthUser().addFileToFavorites(document); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFileToFavorites(document); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, adminUserModel.getUsername(), folder.getNodeRefWithoutVersion())); diff --git a/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesSanityTests.java index 8a270a7c8..672fed851 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesSanityTests.java @@ -37,7 +37,7 @@ public class AddFavoritesSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) public void adminIsAbleToAddToFavorites() throws Exception { - restPersonFavoritesModel = restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + restPersonFavoritesModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); restPersonFavoritesModel.assertThat().field("targetGuid").is(siteModel.getGuid()); } From 1b5ca90e03164642d0cc1c379650952d3c66b562 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Thu, 12 Jan 2017 17:17:46 +0200 Subject: [PATCH 0851/1491] Added core tests for get networks membership --- .../RestGetNetworksForPersonCoreTests.java | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonCoreTests.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonCoreTests.java new file mode 100644 index 000000000..8f1bd55fe --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonCoreTests.java @@ -0,0 +1,80 @@ +package org.alfresco.rest.networks; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestNetworkModelsCollection; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class RestGetNetworksForPersonCoreTests extends RestTest +{ + private UserModel adminUserModel; + UserModel adminTenantUser; + UserModel tenantUser; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUserModel); + restClient.usingTenant().createTenant(adminTenantUser); + tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Get tenant user networks using invalid value for skipCount") + @Test(groups = {TestGroup.REST_API, TestGroup.CORE, TestGroup.NETWORKS }) + public void invalidValueForSkipCountTest() throws Exception + { + restClient.authenticateUser(adminTenantUser).withParams("skipCount=abc").withCoreAPI().usingAuthUser().getNetworks(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "abc")); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Get tenant user networks using invalid value for maxItems") + @Test(groups = {TestGroup.REST_API, TestGroup.CORE, TestGroup.NETWORKS }) + public void invalidValueForMaxItemsTest() throws Exception + { + restClient.authenticateUser(adminTenantUser).withParams("maxItems=abc").withCoreAPI().usingAuthUser().getNetworks(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "abc")); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Get tenant user networks using personId that does not exist") + @Test(groups = {TestGroup.REST_API, TestGroup.CORE, TestGroup.NETWORKS }) + public void inexistentTenantTest() throws Exception + { + restClient.authenticateUser(adminTenantUser).withCoreAPI().usingUser(new UserModel("invalidTenantUser", "password")).getNetworks(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidTenantUser")); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Get tenant user networks using -me- instead of personId") + @Test(groups = {TestGroup.REST_API, TestGroup.CORE, TestGroup.NETWORKS }) + public void specifyMeInsteadOfPersonIdTest() throws Exception + { + RestNetworkModelsCollection networks = restClient.authenticateUser(adminTenantUser).withCoreAPI().usingMe().getNetworks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + networks.getOneRandomEntry().onModel().assertNetworkIsEnabled().and().field("id").is(adminTenantUser.getDomain().toLowerCase()); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Get tenant user networks and validate network entry") + @Test(groups = {TestGroup.REST_API, TestGroup.CORE, TestGroup.NETWORKS }) + public void checkNetworkEntryTest() throws Exception + { + RestNetworkModelsCollection networks = restClient.authenticateUser(adminTenantUser).withCoreAPI().usingAuthUser().getNetworks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + networks.getOneRandomEntry().onModel().assertNetworkIsEnabled() + .and().field("id").is(adminTenantUser.getDomain().toLowerCase()) + .and().field("quotas").is("[]") + .and().field("homeNetwork").is("false"); + } + +} \ No newline at end of file From 4c839d2af314183ba9c9e2f22550512cfd77c9b1 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Thu, 12 Jan 2017 17:33:08 +0200 Subject: [PATCH 0852/1491] fixed tests --- .../rest/workflow/tasks/GetTasksCoreTests.java | 16 +++------------- .../workflow/tasks/UpdateTaskCoreTestsBulk3.java | 2 +- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksCoreTests.java index c8136c971..da3b9651d 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksCoreTests.java @@ -56,21 +56,11 @@ public class GetTasksCoreTests extends RestTest TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check that orderBy parameter is applied.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) public void orderByParameterApplied() throws Exception - { - - - taskModels = restClient.authenticateUser(dataUser.getAdminUser()).withParams("orderBy=id DESC").withWorkflowAPI().getTasks(); + { + taskModels = restClient.authenticateUser(dataUser.getAdminUser()).withParams("orderBy=id").withWorkflowAPI().getTasks(); restClient.assertStatusCodeIs(HttpStatus.OK); taskModels.assertThat().entriesListIsNotEmpty(). - and().entriesListIsSortedAscBy("id"); - List tasksList = taskModels.getEntries(); - List taskIds = new ArrayList(); - for(RestTaskModel task: tasksList) - { - taskIds.add(task.onModel().getId()); - } - boolean sorted = Ordering.natural().isOrdered(taskIds); - Assert.assertTrue(sorted, "Tasks list should be ordered ascendent after id"); + and().entriesListIsSortedAscBy("id"); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTestsBulk3.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTestsBulk3.java index 217acf38c..d6e53b4e7 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTestsBulk3.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTestsBulk3.java @@ -107,7 +107,7 @@ public class UpdateTaskCoreTestsBulk3 extends RestTest RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); restTaskModel = restClient.processModel(RestTaskModel.class, request); restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("priorityTask").is(CMISUtil.Priority.Low.getLevel()); + restTaskModel.assertThat().field("priority").is(CMISUtil.Priority.Low.getLevel()); } @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) From 2655157ae67247f6861144cd2f625dae7407b2e9 Mon Sep 17 00:00:00 2001 From: mionescu Date: Thu, 12 Jan 2017 17:41:48 +0200 Subject: [PATCH 0853/1491] test - added new test cases for addFavoriteSiteTests --- .../rest/people/AddFavoriteSiteCoreTests.java | 63 +++++-------------- .../people/AddFavoriteSiteSanityTests.java | 19 ++++-- 2 files changed, 27 insertions(+), 55 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteCoreTests.java b/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteCoreTests.java index a8d690d00..1f79a14f7 100644 --- a/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteCoreTests.java @@ -38,7 +38,7 @@ public class AddFavoriteSiteCoreTests extends RestTest public void emptyUserIsNotAbleToRemoveFavoriteSite() throws Exception { UserModel emptyUser = new UserModel("", "password"); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(emptyUser).addSiteToFavorites(siteModel); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(emptyUser).addFavoriteSite(siteModel); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "emptyUser")); @@ -49,12 +49,12 @@ public class AddFavoriteSiteCoreTests extends RestTest description = "Verify inexistent user is not able to add a site from favorites and response is (404)") public void inexistentUserIsNotAbleToRemoveFavoriteSite() throws Exception { - UserModel inexistentUser = new UserModel("inexistenUser", "password"); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(inexistentUser).addSiteToFavorites(siteModel); + UserModel inexistentUser = new UserModel("inexistentUser", "password"); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(inexistentUser).addFavoriteSite(siteModel); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) .assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "inexistenUser")) + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "inexistentUser")) .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) .stackTraceIs(RestErrorModel.STACKTRACE); @@ -65,11 +65,11 @@ public class AddFavoriteSiteCoreTests extends RestTest description = "Verify manager user is not able to add a favorite site when the site is already favorite - status code (409)") public void managerUserAddFavoriteSiteAlreadyAFavoriteSite() throws Exception { - UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); - restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().addFavoriteSite(siteModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); restClient.withCoreAPI().usingUser(managerUser).addFavoriteSite(siteModel); @@ -85,7 +85,7 @@ public class AddFavoriteSiteCoreTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to add a favorite site when the 'id' is empty - status code (400)") - public void collaboratorUserAddFavoriteSiteAFavoriteSite() throws Exception + public void userAddFavoriteSiteAFavoriteSite() throws Exception { siteModel.setId(""); restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().addFavoriteSite(siteModel); @@ -98,58 +98,24 @@ public class AddFavoriteSiteCoreTests extends RestTest .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY); } - @Bug(id="MNT-17338") @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user doesn't have permission to delete favorites of admin user with Rest API and status code is 403") @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) public void userIsNotAbleToAddFavoriteSiteOfAnotherUser() throws JsonToModelConversionException, Exception { + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(contributorUser, siteModel, UserRole.SiteContributor); UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel, UserRole.SiteConsumer); restClient.authenticateUser(consumerUser).withCoreAPI() - .usingUser(contributorUser).addSiteToFavorites(siteModel); + .usingUser(contributorUser).addFavoriteSite(siteModel); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) .assertLastError() .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Bug(id="MNT-17338") - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify admin user doesn't have permission to add a favorite site of another user with Rest API and status code is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - public void adminIsNotAbleToAddFavoriteSiteOfAnotherUser() throws JsonToModelConversionException, Exception - { - UserModel collaboratorrUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(collaboratorrUser, siteModel, UserRole.SiteCollaborator); - restClient.authenticateUser(collaboratorrUser) - .withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); - - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError() - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } + } - @Bug(id="MNT-17339") - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify non member user is not able to add a public favorite site - status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - public void privateSiteAddFavoriteSiteUserNotMemberOfTheSite() throws JsonToModelConversionException, Exception - { - UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); - restClient.authenticateUser(contributorUser).withCoreAPI() - .usingAuthUser().addSiteToFavorites(privateSiteModel); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, privateSiteModel.getId())) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify manager user is able to add as favorite a private site.") @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) @@ -158,7 +124,7 @@ public class AddFavoriteSiteCoreTests extends RestTest UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(managerUser, privateSiteModel, UserRole.SiteManager); - restClient.authenticateUser(managerUser).withCoreAPI().usingUser(managerUser).addSiteToFavorites(privateSiteModel); + restClient.authenticateUser(managerUser).withCoreAPI().usingUser(managerUser).addFavoriteSite(privateSiteModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); RestPersonFavoritesModelsCollection favorites = restClient.withCoreAPI().usingAuthUser().getFavorites(); @@ -180,7 +146,7 @@ public class AddFavoriteSiteCoreTests extends RestTest UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(managerUser, moderatedSiteModel, UserRole.SiteManager); - restClient.authenticateUser(managerUser).withCoreAPI().usingUser(managerUser).addSiteToFavorites(moderatedSiteModel); + restClient.authenticateUser(managerUser).withCoreAPI().usingUser(managerUser).addFavoriteSite(moderatedSiteModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); RestPersonFavoritesModelsCollection favorites = restClient.withCoreAPI().usingAuthUser().getFavorites(); @@ -200,7 +166,7 @@ public class AddFavoriteSiteCoreTests extends RestTest public void addFavoriteSiteWithSuccessUsingMeAsPersonId() throws Exception { restClient.authenticateUser(adminUserModel); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingMe().addSiteToFavorites(moderatedSiteModel); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingMe().addFavoriteSite(moderatedSiteModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); } @@ -218,7 +184,6 @@ public class AddFavoriteSiteCoreTests extends RestTest restClient.withCoreAPI().usingUser(managerUser).addSiteToFavorites(siteModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); - } - + } } diff --git a/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteSanityTests.java index 8bb41699c..89782bd07 100644 --- a/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteSanityTests.java @@ -1,6 +1,7 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestFavoriteSiteModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.model.SiteModel; @@ -56,7 +57,8 @@ public class AddFavoriteSiteSanityTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify contributor user add a favorite site with Rest API and response is successful (201)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, + description = "Verify contributor user add a favorite site with Rest API and response is successful (201)") public void contributorUserAddFavoriteSiteWithSuccess() throws Exception { UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); @@ -68,7 +70,8 @@ public class AddFavoriteSiteSanityTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify consumer user add a favorite site with Rest API and response is successful (201)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, + description = "Verify consumer user add a favorite site with Rest API and response is successful (201)") public void consumerUserAddFavoriteSiteWithSuccess() throws Exception { UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -80,7 +83,8 @@ public class AddFavoriteSiteSanityTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify admin user add a favorite site with Rest API and response is successful (201)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, + description = "Verify admin user add a favorite site with Rest API and response is successful (201)") public void adminUserAddFavoriteSiteWithSuccess() throws Exception { UserModel adminUser = dataUser.getAdminUser(); @@ -91,8 +95,8 @@ public class AddFavoriteSiteSanityTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify a manager user is NOT Authorized to add a favorite site with Rest API when authentication fails (401)") - @Bug(id="MNT-16904") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, + description = "Verify a manager user is NOT Authorized to add a favorite site with Rest API when authentication fails (401)") public void managerUserNotAuthorizedFailsToAddFavoriteSite() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -100,6 +104,9 @@ public class AddFavoriteSiteSanityTests extends RestTest managerUser.setPassword("newpassword"); restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().addFavoriteSite(siteModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } } From 317b71326a4d710cb1745ca5b6fc0b9d584df03c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alecsandru=20Prun=C4=83?= Date: Thu, 12 Jan 2017 17:59:42 +0200 Subject: [PATCH 0854/1491] test: Added core tests for people/{personId}/networks/{networkId} --- .../RestGetNetworkForPersonCoreTests.java | 88 ++++++++++++++++++ .../RestGetNetworkForPersonFullTests.java | 70 ++++++++++++++ .../RestGetNetworkForPersonSanityTests.java | 93 ++++++++++++++----- 3 files changed, 230 insertions(+), 21 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonCoreTests.java create mode 100644 e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonCoreTests.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonCoreTests.java new file mode 100644 index 000000000..7c5bab860 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonCoreTests.java @@ -0,0 +1,88 @@ +package org.alfresco.rest.networks; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestNetworkModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Tests for /people/{personId}/networks + */ +public class RestGetNetworkForPersonCoreTests extends RestTest +{ + UserModel adminUser; + UserModel adminTenantUser; + UserModel tenantUser; + UserModel randomTestUser; + RestNetworkModel restNetworkModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser); + restClient.usingTenant().createTenant(adminTenantUser); + tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + randomTestUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("randomTestUser"); + } + + @Bug(id = "needs to be checked") + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify getNetwork request status code is 200 if a user tries to get network information of another user") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.CORE }) + public void verifyGetNetworkByAUserForAnotherUser() throws Exception + { + restNetworkModel = restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().getNetwork(randomTestUser); + restClient.assertStatusCodeIs(HttpStatus.OK); + restNetworkModel.assertThat().field("id").is(tenantUser.getDomain()); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that getNetwork status code is 404 for a personId that does not exist") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.CORE }) + public void verifyThatGetNetworkStatusIs404ForAPersonIdThatDoesNotExist() throws Exception + { + UserModel invalidUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("validUsername"); + invalidUser.setUsername("invalidUsername"); + + restClient.authenticateUser(adminTenantUser).withCoreAPI().usingUser(invalidUser).getNetwork(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, invalidUser.getUsername())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that getNetwork status code is 404 for a networkId that does not exist") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.CORE }) + public void verifyThatGetNetworkStatusIs404ForANetworkIdThatDoesNotExist() throws Exception + { + UserModel invalidUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("invalidNetworkId"); + invalidUser.setDomain("invalidNetworkId"); + + restClient.authenticateUser(adminTenantUser).withCoreAPI().usingUser(invalidUser).getNetwork(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, invalidUser.getUsername())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify getNetwork request that is made using -me- instead of personId") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.CORE }) + public void verifyGetNetworkRequestUsingMeInsteadOfPersonId() throws Exception + { + restClient.authenticateUser(adminTenantUser).withCoreAPI().usingMe().getNetwork(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } +} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonFullTests.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonFullTests.java new file mode 100644 index 000000000..e5a5e344d --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonFullTests.java @@ -0,0 +1,70 @@ +package org.alfresco.rest.networks; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestNetworkModel; +import org.alfresco.rest.model.RestNetworkQuotaModel; +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; + +import java.util.ArrayList; + +/** + * Tests for /people/{personId}/networks + */ +public class RestGetNetworkForPersonFullTests extends RestTest +{ + UserModel adminUser; + UserModel adminTenantUser; + UserModel secondAdminTenantUser; + UserModel tenantUser; + RestNetworkModel restNetworkModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + adminTenantUser = UserModel.getAdminTenantUser(); + secondAdminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser); + restClient.usingTenant().createTenant(secondAdminTenantUser); + tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify getNetwork request response entry details") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.FULL }) + public void verifyGetNetworkRequestResponseEntryDetails() throws Exception + { + restNetworkModel = restClient.authenticateUser(adminTenantUser).withCoreAPI().usingMe().getNetwork(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restNetworkModel.assertThat().field("quotas").is(new ArrayList()) + .assertThat().field("isEnabled").is("true") + .assertThat().field("homeNetwork").is("true") + .assertThat().field("id").is(adminTenantUser.getDomain().toLowerCase()); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that properties parameter is applied to getNetwork request") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.FULL }) + public void verifyPropertiesParameterIsAppliedToGetNetworkRequest() throws Exception + { + restNetworkModel = restClient.authenticateUser(adminTenantUser).withParams("properties=id").withCoreAPI().usingMe().getNetwork(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restNetworkModel.assertThat().field("id").is(adminTenantUser.getDomain().toLowerCase()); + // TODO add assert that entry has only 1 field + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify getNetwork request status code is 404 for a network to which user does not belong") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.FULL }) + public void verifyGetNetworkRequestStatusCodeIs404ForANetworkToWhichTheUserDoesNotBelong() throws Exception + { + restClient.authenticateUser(adminTenantUser).withCoreAPI().usingAuthUser().getNetwork(secondAdminTenantUser); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } +} diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java index 697954a56..908d7991f 100644 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java @@ -1,6 +1,8 @@ package org.alfresco.rest.networks; import org.alfresco.rest.RestTest; +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.report.Bug; @@ -10,11 +12,19 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +/** + * Tests for /people/{personId}/networks + */ public class RestGetNetworkForPersonSanityTests extends RestTest { - private UserModel adminUserModel; + UserModel adminUserModel; UserModel adminTenantUser; UserModel tenantUser; + UserModel tenantSiteManager; + UserModel tenantSiteCollaborator; + UserModel tenantSiteContributor; + UserModel tenantSiteConsumer; + SiteModel tenantSite; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception @@ -24,51 +34,92 @@ public class RestGetNetworkForPersonSanityTests extends RestTest restClient.authenticateUser(adminUserModel); restClient.usingTenant().createTenant(adminTenantUser); tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + tenantSiteManager = dataUser.usingUser(adminTenantUser).createUserWithTenant("tenantSiteManager"); + tenantSiteCollaborator = dataUser.usingUser(adminTenantUser).createUserWithTenant("tenantSiteCollaborator"); + tenantSiteContributor = dataUser.usingUser(adminTenantUser).createUserWithTenant("tenantSiteContributor"); + tenantSiteConsumer = dataUser.usingUser(adminTenantUser).createUserWithTenant("tenantSiteConsumer"); + tenantSite = dataSite.usingUser(tenantSiteManager).createPublicRandomSite(); + dataUser.usingUser(tenantSiteManager).addUserToSite(tenantSiteCollaborator, tenantSite, UserRole.SiteCollaborator); + dataUser.usingUser(tenantSiteManager).addUserToSite(tenantSiteContributor, tenantSite, UserRole.SiteContributor); + dataUser.usingUser(tenantSiteManager).addUserToSite(tenantSiteConsumer, tenantSite, UserRole.SiteConsumer); } @Bug(id = "MNT-16904") @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, - description = "Verify non existing user gets another exisiting network with Rest API and checks the forbidden status") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.COMMENTS, TestGroup.SANITY }) + description = "Verify non existing user gets another existing network with Rest API and checks the forbidden status") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) public void nonExistingTenantUserIsNotAuthorizedToRequest() throws Exception { UserModel tenantUser = new UserModel("nonexisting", "password"); tenantUser.setDomain(adminTenantUser.getDomain()); - restClient.authenticateUser(tenantUser); - restClient.withCoreAPI().usingAuthUser().getNetwork(adminTenantUser); + restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().getNetwork(adminTenantUser); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify tenant admin user gets specific network with Rest API and response is not empty") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.COMMENTS,TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) public void adminTenantChecksIfNetworkIsPresent() throws Exception { - restClient.authenticateUser(adminTenantUser); - restClient.withCoreAPI().usingUser(adminTenantUser).getNetwork(); + restClient.authenticateUser(adminTenantUser).withCoreAPI().usingUser(adminTenantUser).getNetwork(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Bug(id = "needs to be checked") + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, + description = "Verify tenant user check network of admin user with Rest API") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) + public void tenantUserIsNotAuthorizedToCheckNetworkOfAdminUser() throws Exception + { + restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().getNetwork(adminTenantUser); restClient.assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, - description = "Verify tenant user is not authorized to check network of admin user with Rest API and checks the forbidden status") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.COMMENTS, TestGroup.SANITY }) - public void tenantUserIsNotAuthorizedToCheckNetworkOfAdminUser() throws Exception - { - restClient.authenticateUser(tenantUser); - restClient.withCoreAPI().usingAuthUser().getNetwork(adminTenantUser); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify admin tenant user is not authorized to check network of another user with Rest API and checks the forbidden status") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.COMMENTS, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) public void adminTenantUserIsNotAuthorizedToCheckNetworkOfAnotherUser() throws Exception { UserModel secondAdminTenantUser = UserModel.getAdminTenantUser(); restClient.usingTenant().createTenant(secondAdminTenantUser); UserModel secondTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("anotherTenant"); - restClient.authenticateUser(adminTenantUser); - restClient.withCoreAPI().usingAuthUser().getNetwork(secondTenantUser); + restClient.authenticateUser(adminTenantUser).withCoreAPI().usingAuthUser().getNetwork(secondTenantUser); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, + description = "Verify site manager user gets specific network with Rest API and response is not empty") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) + public void siteManagerChecksIfNetworkIsPresent() throws Exception + { + restClient.authenticateUser(tenantSiteManager).withCoreAPI().usingAuthUser().getNetwork(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, + description = "Verify site collaborator user gets specific network with Rest API and response is not empty") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) + public void siteCollaboratorChecksIfNetworkIsPresent() throws Exception + { + restClient.authenticateUser(tenantSiteCollaborator).withCoreAPI().usingAuthUser().getNetwork(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, + description = "Verify site contributor user gets specific network with Rest API and response is not empty") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) + public void siteContributorChecksIfNetworkIsPresent() throws Exception + { + restClient.authenticateUser(tenantSiteContributor).withCoreAPI().usingAuthUser().getNetwork(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, + description = "Verify site consumer user gets specific network with Rest API and response is not empty") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) + public void siteConsumerChecksIfNetworkIsPresent() throws Exception + { + restClient.authenticateUser(tenantSiteConsumer).withCoreAPI().usingAuthUser().getNetwork(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } } From 72a7cb4273a32c9fc94177c64f9b6c069087db7e Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Thu, 12 Jan 2017 18:19:38 +0200 Subject: [PATCH 0855/1491] added full tests for GetNetwork and additional methods --- .../networks/RestGetNetworkFullTests.java | 103 ++++++++++++++++++ .../networks/RestGetNetworkSanityTests.java | 14 +-- 2 files changed, 110 insertions(+), 7 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/networks/RestGetNetworkFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkFullTests.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkFullTests.java new file mode 100644 index 000000000..a5f43081b --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkFullTests.java @@ -0,0 +1,103 @@ +package org.alfresco.rest.networks; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestNetworkModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.json.JSONException; +import org.json.JSONObject; +import org.springframework.http.HttpStatus; +import org.testng.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * + * @author Cristina Axinte + * + */ +public class RestGetNetworkFullTests extends RestTest +{ + UserModel adminTenantUser, adminuser; + UserModel adminAnotherTenantUser; + SiteModel site; + UserModel tenantUser; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminuser = dataUser.getAdminUser(); + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminuser); + restClient.usingTenant().createTenant(adminTenantUser); + + adminAnotherTenantUser = UserModel.getAdminTenantUser(); + restClient.usingTenant().createTenant(adminAnotherTenantUser); + + tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("userTenant1"); + site = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); + } + + @Bug(id = "ACE-5738") + @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify tenant admin user gets an invalid network with Rest API and checks the not found status") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.FULL }) + public void adminTenantGetsInvalidNetwork() throws Exception + { + restClient.authenticateUser(adminAnotherTenantUser); + adminAnotherTenantUser.setDomain("tenant.@%"); + + restClient.withCoreAPI().usingNetworks().getNetwork(adminAnotherTenantUser); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.UNEXPECTED_TENANT, adminTenantUser.getDomain(), "@")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Bug(id = "needs to be checked") + @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify admin user gets an existing network successfully with Rest API") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.FULL }) + public void adminUserGetsExistingNetwork() throws Exception + { + restClient.authenticateUser(adminuser); + RestNetworkModel restNetworkModel = restClient.withCoreAPI().usingNetworks().getNetwork(adminTenantUser); + restClient.assertStatusCodeIs(HttpStatus.OK); + restNetworkModel.assertThat().fieldsCount().is("1"); + restNetworkModel.assertThat().field("id").is(adminTenantUser.getDomain()) + .and().field("homeNetwork").isNull() + .and().field("isEnabled").is("true"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify tenant admin user gets network using properties parameter successfully with Rest API") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.FULL }) + public void adminTenantGetsNetworkUsingPropertiesParameter() throws Exception + { + restClient.authenticateUser(tenantUser); + JSONObject entryResponse= restClient.withCoreAPI().usingNetworks().usingParams("properties=id").getNetworkWithParams(adminTenantUser); + restClient.assertStatusCodeIs(HttpStatus.OK); + Assert.assertTrue(entryResponse.get("id").equals(adminTenantUser.getDomain().toLowerCase())); + assertJsonResponseDoesnotContainField(entryResponse, "homeNetwork"); + assertJsonResponseDoesnotContainField(entryResponse, "isEnabled"); + } + + private void assertJsonResponseDoesnotContainField(JSONObject entryResponse, String field) + { + try{ + entryResponse.get(field); + } + catch(JSONException ex) + { + Assert.assertTrue(ex.getMessage().equals(String.format("JSONObject[\"%s\"] not found.", field))); + } + } + + +} diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkSanityTests.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkSanityTests.java index 27fe6119a..cf0cd9e96 100644 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkSanityTests.java @@ -39,7 +39,7 @@ public class RestGetNetworkSanityTests extends RestTest @Bug(id = "MNT-16904") @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify non existing user gets another exisiting network with Rest API and checks the forbidden status") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.COMMENTS, TestGroup.SANITY}) + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY}) public void nonExistingTenantUserIsNotAuthorizedToRequest() throws Exception { UserModel tenantUser = new UserModel("nonexisting", "password"); @@ -51,7 +51,7 @@ public class RestGetNetworkSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify tenant admin user gets specific network with Rest API and response is not empty") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.COMMENTS, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) public void adminTenantChecksIfNetworkIsPresent() throws Exception { restClient.authenticateUser(adminTenantUser); @@ -119,7 +119,7 @@ public class RestGetNetworkSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify any tenant user gets another existing network with Rest API and checks the forbidden status") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.COMMENTS, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) public void userTenantChecksIfAnotherExistingNetworkIsForbidden() throws Exception { restClient.authenticateUser(tenantUser); @@ -129,7 +129,7 @@ public class RestGetNetworkSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify manager tenant user gets its network with Rest API and response is not empty") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.COMMENTS, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) public void tenantManagerUserChecksIfNetworkIsPresent() throws Exception { UserModel managerTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("manTenant"); @@ -142,7 +142,7 @@ public class RestGetNetworkSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify collaborator tenant user gets its network with Rest API and response is not empty") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.COMMENTS, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) public void tenantCollaboratorUserChecksIfNetworkIsPresent() throws Exception { UserModel collaboratorTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("colTenant"); @@ -155,7 +155,7 @@ public class RestGetNetworkSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify consumer tenant user gets its network with Rest API and response is not empty") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.COMMENTS, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) public void tenantConsumerUserChecksIfNetworkIsPresent() throws Exception { UserModel consumerTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("consTenant"); @@ -168,7 +168,7 @@ public class RestGetNetworkSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify contributor tenant user gets its network with Rest API and response is not empty") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.COMMENTS, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) public void tenantContributorUserChecksIfItsNetworkIsPresent() throws Exception { UserModel contributorTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("contTenant"); From 72a3a8058ed8cddf734d34768441db25945386d2 Mon Sep 17 00:00:00 2001 From: mionescu Date: Thu, 12 Jan 2017 18:57:31 +0200 Subject: [PATCH 0856/1491] test - added new test cases --- .../rest/people/AddFavoriteSiteFullTests.java | 265 ++++++++++++++++++ 1 file changed, 265 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteFullTests.java b/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteFullTests.java new file mode 100644 index 000000000..d30081b31 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteFullTests.java @@ -0,0 +1,265 @@ +package org.alfresco.rest.people; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.JsonBodyGenerator; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.exception.EmptyJsonResponseException; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestCommentModel; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestFavoriteSiteModel; +import org.alfresco.rest.model.RestPersonFavoritesModel; +import org.alfresco.rest.model.RestPersonFavoritesModelsCollection; +import org.alfresco.rest.model.RestTagModel; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.LinkModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class AddFavoriteSiteFullTests extends RestTest +{ + UserModel userModel, adminUserModel; + SiteModel siteModel, privateSiteModel, moderatedSiteModel; + UserModel searchedUser; + FileModel document; + FolderModel folder; + private RestCommentModel comment; + private RestTagModel returnedModel; + private RestFavoriteSiteModel restFavoriteSiteModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + privateSiteModel = dataSite.usingUser(userModel).createPrivateRandomSite(); + moderatedSiteModel = dataSite.usingUser(userModel).createModeratedRandomSite(); + + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + folder = dataContent.usingSite(siteModel).usingUser(adminUserModel).createFolder(); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify admin user doesn't have permission to add a favorite site of another user with Rest API and status code is 403") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + public void adminIsNotAbleToAddFavoriteSiteOfAnotherUser() throws JsonToModelConversionException, Exception + { + UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(collaboratorUser, siteModel, UserRole.SiteCollaborator); + restClient.authenticateUser(collaboratorUser) + .withCoreAPI().usingUser(adminUserModel).addFavoriteSite(siteModel); + + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError() + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Bug(id="MNT-17338") + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify admin user doesn't have permission to add a favorite site of another user with Rest API and status code is 403") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + public void userIsNotAbleToAddFavoriteSiteOfAdmin() throws JsonToModelConversionException, Exception + { + UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel, UserRole.SiteConsumer); + restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingUser(consumerUser).addFavoriteSite(siteModel); + + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError() + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify add favorite site using empty body - status code is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL}) + public void addFavoriteSiteWithEmptyBody() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI(); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{\"ids\": \"local\"}" , + "people/{personId}/favorite-sites", adminUserModel.getUsername()); + restClient.processModel(RestPersonFavoritesModel.class, request); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsSummary(String.format(RestErrorModel.NO_CONTENT, "Unrecognized field " + "\"ids\"")); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify add favorite site using empty body - status code is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + public void addFavoriteSiteWithEmptyRequiredFieldsBody() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI(); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{\"\": \"\"}", + "people/{personId}/favorite-sites", adminUserModel.getUsername()); + restClient.processModel(RestPersonFavoritesModel.class, request); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsSummary(String.format(RestErrorModel.NO_CONTENT, "Unrecognized field " + "\"\"")); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify non member user is not able to add a private favorite site - status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + public void userAddFavoriteSiteUserNotMemberOfPrivateSite() throws JsonToModelConversionException, Exception + { + UserModel user = dataUser.usingAdmin().createRandomTestUser(); + restClient.authenticateUser(user).withCoreAPI() + .usingAuthUser().addFavoriteSite(privateSiteModel); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, privateSiteModel.getId())) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify non member user is able to add a moderated favorite site") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + public void userAddFavoriteSiteUserNotMemberOfModeratedSite() throws JsonToModelConversionException, Exception + { + UserModel user = dataUser.usingAdmin().createRandomTestUser(); + restClient.authenticateUser(user).withCoreAPI().usingAuthUser() + .addFavoriteSite(moderatedSiteModel); + + RestPersonFavoritesModelsCollection favorites = restClient.withCoreAPI().usingAuthUser().getFavorites(); + favorites.assertThat().entriesListContains("targetGuid", moderatedSiteModel.getGuidWithoutVersion()) + .and().paginationField("totalItems").is("1"); + favorites.getOneRandomEntry().onModel().getTarget().getSite() + .assertThat() + .field("description").is(moderatedSiteModel.getDescription()) + .and().field("id").is(moderatedSiteModel.getId()) + .and().field("visibility").is(moderatedSiteModel.getVisibility().toString()) + .and().field("title").is(moderatedSiteModel.getTitle()); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify non member user is able to add a public favorite site") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + public void userAddFavoriteSiteUserNotMemberOfPublicSite() throws JsonToModelConversionException, Exception + { + UserModel user = dataUser.usingAdmin().createRandomTestUser(); + restFavoriteSiteModel = restClient.authenticateUser(user).withCoreAPI().usingAuthUser().addFavoriteSite(siteModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restFavoriteSiteModel.assertThat().field("id").is(siteModel.getId()); + + RestPersonFavoritesModelsCollection favorites = restClient.withCoreAPI().usingAuthUser().getFavorites(); + favorites.assertThat().entriesListContains("targetGuid", siteModel.getGuidWithoutVersion()) + .and().paginationField("totalItems").is("1"); + favorites.getOneRandomEntry().onModel().getTarget().getSite() + .assertThat() + .field("description").is(siteModel.getDescription()) + .and().field("id").is(siteModel.getId()) + .and().field("visibility").is(siteModel.getVisibility().toString()) + .and().field("title").is(siteModel.getTitle()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Check that if id does not exist, status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + public void addFavoriteSiteUsingInvalidId() throws Exception + { + SiteModel site = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + String id = siteModel.getId(); + site.setId("invalidID"); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFavoriteSite(site); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidID")); + + siteModel.setId(id); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Check that if user provides site in id but id is of a file status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + public void addSiteToFavoritesUsingFileId() throws Exception + { + String id = siteModel.getId(); + siteModel.setId(document.getNodeRefWithoutVersion()); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFavoriteSite(siteModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, document.getNodeRefWithoutVersion())); + + siteModel.setId(id); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Check that if user provides site in id but id is of a folder status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + public void addSiteToFavoritesUsingFolderId() throws Exception + { + String id = siteModel.getId(); + siteModel.setId(folder.getNodeRefWithoutVersion()); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFavoriteSite(siteModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, folder.getNodeRefWithoutVersion())); + + siteModel.setId(id); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Check that if user provides site in id but id is of a comment status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + public void addSiteToFavoriteUsingCommentId() throws Exception + { + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + String id = siteModel.getId(); + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + comment = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment("This is a comment"); + file.setNodeRef(comment.getId()); + siteModel.setId(comment.getId()); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFavoriteSite(siteModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + siteModel.setId(id); + } + + @Bug(id="MNT-16917") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Check that if user provides site in id but id is of a tag status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + public void addSiteFavoriteUsingTagId() throws Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + returnedModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).addTag("random_tag"); + file.setNodeRef(returnedModel.getId()); + siteModel.setId(returnedModel.getId()); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFavoriteSite(siteModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, returnedModel.getId())); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Check that if id does not describe a site, file, or folder status code is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) + public void addFavoriteUsingInvalidGuid() throws Exception + { + LinkModel link = dataLink.usingAdmin().usingSite(siteModel).createRandomLink(); + SiteModel site = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + site.setId(link.getNodeRef()); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFavoriteSite(site); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, site.getId().split("/")[3])); + } + +} From ea4ad7e0c93a16b19111fe74ee6f194b0966914b Mon Sep 17 00:00:00 2001 From: Andrei Rusu Date: Fri, 13 Jan 2017 09:59:36 +0200 Subject: [PATCH 0857/1491] added deleteCommentFullTests updated deleteCommentCoreTests --- ...Tests.java => DeleteCommentCoreTests.java} | 2 +- .../rest/comments/DeleteCommentFullTests.java | 185 ++++++++++++++++++ ...sts.java => DeleteCommentSanityTests.java} | 14 +- 3 files changed, 199 insertions(+), 2 deletions(-) rename e2e-test/java/org/alfresco/rest/comments/{DeleteCommentsCoreTests.java => DeleteCommentCoreTests.java} (97%) create mode 100644 e2e-test/java/org/alfresco/rest/comments/DeleteCommentFullTests.java rename e2e-test/java/org/alfresco/rest/comments/{DeleteCommentsSanityTests.java => DeleteCommentSanityTests.java} (83%) diff --git a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsCoreTests.java b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentCoreTests.java similarity index 97% rename from e2e-test/java/org/alfresco/rest/comments/DeleteCommentsCoreTests.java rename to e2e-test/java/org/alfresco/rest/comments/DeleteCommentCoreTests.java index 83e63ef7e..bcfb1850c 100644 --- a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentCoreTests.java @@ -17,7 +17,7 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -public class DeleteCommentsCoreTests extends RestTest +public class DeleteCommentCoreTests extends RestTest { private UserModel adminUserModel; diff --git a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentFullTests.java b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentFullTests.java new file mode 100644 index 000000000..61f0a4386 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentFullTests.java @@ -0,0 +1,185 @@ +package org.alfresco.rest.comments; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestCommentModel; +import org.alfresco.rest.model.RestCommentModelsCollection; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class DeleteCommentFullTests extends RestTest +{ + private UserModel adminUserModel, networkUserModel; + private SiteModel siteModel; + private RestCommentModel commentModel; + private RestCommentModelsCollection comments; + private ListUserWithRoles usersWithRoles; + private String comment = "This is a new comment"; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + networkUserModel = dataUser.createRandomTestUser(); + restClient.authenticateUser(adminUserModel); + siteModel = dataSite.usingUser(adminUserModel).createPrivateRandomSite(); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteConsumer, + UserRole.SiteCollaborator, UserRole.SiteContributor); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS }, + executionType = ExecutionType.REGRESSION, description = "Verify Manager user deletes comment created by admin" + + " and status code is 204. Check with getComments for validation") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void managerIsAbleToDeleteCommentCreatedByOthers() throws JsonToModelConversionException, Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + + commentModel = restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingResource(file).addComment(comment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(file).deleteComment(commentModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListDoesNotContain("content", comment); + comments.getPagination().assertThat().field("totalItems").is("0").and().field("count").is("0"); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS }, + executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user can delete comment created by self" + + " and status code is 204. Check with getComments for validation") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void collaboratorIsAbleToDeleteCommentCreatedBySelf() throws JsonToModelConversionException, Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + + commentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingResource(file).addComment(comment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.withCoreAPI().usingResource(file).deleteComment(commentModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListDoesNotContain("content", comment); + comments.getPagination().assertThat().field("totalItems").is("0").and().field("count").is("0"); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS }, + executionType = ExecutionType.REGRESSION, description = "Verify Contributor user deletes comment created by self" + + " and status code is 204. Check with getComments for validation") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + @Bug(id = "ACE-4614") + public void contributorIsAbleToDeleteCommentCreatedBySelf() throws JsonToModelConversionException, Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + + commentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) + .withCoreAPI().usingResource(file).addComment(comment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.withCoreAPI().usingResource(file).deleteComment(commentModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListDoesNotContain("content", comment); + comments.getPagination().assertThat().field("totalItems").is("0").and().field("count").is("0"); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS }, + executionType = ExecutionType.REGRESSION, description = "Verify Consumer user cannot delete comment created by admin" + + " and status code is 403. Check with getComments for validation and check default error model schema.") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void consumerIsNotAbleToDeleteCommentCreatedByOthersDefaultErrorModelSchema() throws JsonToModelConversionException, Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + + commentModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(comment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + .withCoreAPI().usingResource(file).deleteComment(commentModel); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + restClient.assertLastError().getErrorKey().contains("PermissionDenied"); + restClient.assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + restClient.assertLastError().getDescriptionURL().contains("https://api-explorer.alfresco.com"); + restClient.assertLastError().getStackTrace().contains("For security reasons the stack trace is no longer displayed"); + + comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", comment); + comments.getPagination().assertThat().field("totalItems").is("1").and().field("count").is("1"); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS }, + executionType = ExecutionType.REGRESSION, description = "Verify Manager can delete comment with version number") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void usingManagerDeleteCommentWithVersionNumber() throws JsonToModelConversionException, Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + dataContent.usingAdmin().usingResource(file).updateContent("updated content to increase version number"); + + commentModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(comment); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(file).deleteComment(commentModel); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS }, + executionType = ExecutionType.REGRESSION, description = "Verify Manager user cannot delete comment with invalid node " + + "and status code is 404. Check with getComments for validation") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void usingManagerDeleteCommentWithInvalidNode() throws JsonToModelConversionException, Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + + commentModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(comment); + file.setNodeRef("invalid"); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(file).deleteComment(commentModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(file.getNodeRef() + " was not found"); + + comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(file.getNodeRef() + " was not found"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, + description = "Verify deleteComment from node with invalid network id returns status code 401") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.COMMENTS, TestGroup.FULL }) + public void deleteCommentWithInvalidNetworkId() throws Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + + commentModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(comment); + networkUserModel.setDomain("invalidNetwork"); + restClient.authenticateUser(networkUserModel).withCoreAPI().usingResource(file).deleteComment(commentModel); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS }, + executionType = ExecutionType.REGRESSION, description = "Verify deleteComment from node with empty network id returns status code 401") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void deleteCommentWithEmptyNetworkId() throws JsonToModelConversionException, Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + + commentModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(comment); + networkUserModel.setDomain(""); + restClient.authenticateUser(networkUserModel).withCoreAPI().usingResource(file).deleteComment(commentModel); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + +} diff --git a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentSanityTests.java similarity index 83% rename from e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java rename to e2e-test/java/org/alfresco/rest/comments/DeleteCommentSanityTests.java index 3d23be26d..32ac39335 100644 --- a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentSanityTests.java @@ -18,7 +18,7 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -public class DeleteCommentsSanityTests extends RestTest +public class DeleteCommentSanityTests extends RestTest { private UserModel adminUserModel; @@ -81,6 +81,18 @@ public class DeleteCommentsSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } + @TestRail(section = { TestGroup.REST_API, + TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Consumer user cannot delete comments and status code returned is 403") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) + public void consumerIsNotAbleToDeleteComments() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + comment = restClient.withCoreAPI().usingResource(document).addComment("New comment added by Manager"); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + restClient.withCoreAPI().usingResource(document).deleteComment(comment); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + @TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify User gets status code 401 if authentication call fails") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) @Bug(id="MNT-16904") From af567fc3cc939f8fc133e5750aca21c9e8a90e9e Mon Sep 17 00:00:00 2001 From: cagache Date: Fri, 13 Jan 2017 10:26:01 +0200 Subject: [PATCH 0858/1491] updated 2 scenarios --- .../rest/comments/DeleteCommentFullTests.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentFullTests.java b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentFullTests.java index 61f0a4386..8386b5a39 100644 --- a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentFullTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentFullTests.java @@ -113,11 +113,11 @@ public class DeleteCommentFullTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.CREATED); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) .withCoreAPI().usingResource(file).deleteComment(commentModel); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - restClient.assertLastError().getErrorKey().contains("PermissionDenied"); - restClient.assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - restClient.assertLastError().getDescriptionURL().contains("https://api-explorer.alfresco.com"); - restClient.assertLastError().getStackTrace().contains("For security reasons the stack trace is no longer displayed"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .statusCodeIs(HttpStatus.FORBIDDEN) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE) + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY); comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -136,6 +136,7 @@ public class DeleteCommentFullTests extends RestTest commentModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(comment); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) .withCoreAPI().usingResource(file).deleteComment(commentModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } @TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS }, From ffbc345a2eab4ac4deaac2d4ab0dfb3f3d264751 Mon Sep 17 00:00:00 2001 From: mionescu Date: Fri, 13 Jan 2017 10:34:23 +0200 Subject: [PATCH 0859/1491] test- formatting --- .../people/DeleteFavoriteSiteCoreTests.java | 45 +++++++++++++------ .../people/DeleteFavoriteSiteSanityTests.java | 37 ++++++++------- 2 files changed, 50 insertions(+), 32 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteCoreTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteCoreTests.java index 265a878e7..4081e1775 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteCoreTests.java @@ -7,7 +7,6 @@ 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.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -48,8 +47,12 @@ public class DeleteFavoriteSiteCoreTests extends RestTest public void inexistentUserIsNotAbleToRemoveFavoriteSite() throws Exception { UserModel inexistentUser = new UserModel("inexistenUser", "password"); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(inexistentUser).removeFavoriteSite(siteModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "inexistenUser")); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(inexistentUser) + .removeFavoriteSite(siteModel); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "inexistenUser")); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) @@ -58,7 +61,9 @@ public class DeleteFavoriteSiteCoreTests extends RestTest public void userIsNotAbleToRemoveFavoriteSiteWithInexistentId() throws Exception { SiteModel inexistentSite = new SiteModel("inexistentSite"); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).removeFavoriteSite(inexistentSite); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel) + .removeFavoriteSite(inexistentSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) .assertLastError() .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, @@ -77,7 +82,9 @@ public class DeleteFavoriteSiteCoreTests extends RestTest dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); dataSite.usingUser(managerUser).usingSite(siteModel).addSiteToFavorites(); - restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel); + restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser() + .removeFavoriteSite(siteModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); restClient.withCoreAPI().usingUser(managerUser).addFavoriteSite(siteModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); @@ -92,9 +99,12 @@ public class DeleteFavoriteSiteCoreTests extends RestTest dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); dataSite.usingUser(managerUser).usingSite(siteModel).addSiteToFavorites(); - restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel); + restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser() + .removeFavoriteSite(siteModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingAuthUser().getFavorites().assertThat().entriesListDoesNotContain("id", siteModel.getId()); + restClient.withCoreAPI().usingAuthUser().getFavorites() + .assertThat().entriesListDoesNotContain("id", siteModel.getId()); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) @@ -105,9 +115,12 @@ public class DeleteFavoriteSiteCoreTests extends RestTest SiteModel publicSiteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); restClient.authenticateUser(userModel).withCoreAPI().usingUser(userModel).addFavoriteSite(publicSiteModel); - restClient.withCoreAPI().usingAuthUser().removeFavoriteSite(publicSiteModel); + restClient.withCoreAPI().usingAuthUser() + .removeFavoriteSite(publicSiteModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingAuthUser().getFavoriteSites().assertThat().entriesListDoesNotContain("id", publicSiteModel.getId()); + restClient.withCoreAPI().usingAuthUser().getFavoriteSites() + .assertThat().entriesListDoesNotContain("id", publicSiteModel.getId()); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) @@ -118,9 +131,12 @@ public class DeleteFavoriteSiteCoreTests extends RestTest SiteModel moderatedSiteModel = dataSite.usingUser(adminUserModel).createModeratedRandomSite(); restClient.authenticateUser(userModel).withCoreAPI().usingUser(userModel).addFavoriteSite(moderatedSiteModel); - restClient.withCoreAPI().usingAuthUser().removeFavoriteSite(moderatedSiteModel); + restClient.withCoreAPI().usingAuthUser() + .removeFavoriteSite(moderatedSiteModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingAuthUser().getFavoriteSites().assertThat().entriesListDoesNotContain("id", moderatedSiteModel.getId()); + restClient.withCoreAPI().usingAuthUser().getFavoriteSites() + .assertThat().entriesListDoesNotContain("id", moderatedSiteModel.getId()); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) @@ -131,9 +147,12 @@ public class DeleteFavoriteSiteCoreTests extends RestTest SiteModel privateSiteModel = dataSite.usingUser(userModel).createPrivateRandomSite(); restClient.authenticateUser(userModel).withCoreAPI().usingUser(userModel).addFavoriteSite(privateSiteModel); - restClient.withCoreAPI().usingAuthUser().removeFavoriteSite(privateSiteModel); + restClient.withCoreAPI().usingAuthUser() + .removeFavoriteSite(privateSiteModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingAuthUser().getFavoriteSites().assertThat().entriesListDoesNotContain("id", privateSiteModel.getId()); + restClient.withCoreAPI().usingAuthUser().getFavoriteSites() + .assertThat().entriesListDoesNotContain("id", privateSiteModel.getId()); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java index 2e91ed8e2..7eb61bbc8 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java @@ -68,12 +68,12 @@ public class DeleteFavoriteSiteSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); restClient.withCoreAPI().usingAuthUser().getFavorites() - .assertThat() - .entriesListDoesNotContain("targetGuid", siteModel1.getGuid()) - .and().entriesListDoesNotContain("id", siteModel1.getId()) - .and().entriesListDoesNotContain("description", siteModel1.getDescription()) - .and().entriesListDoesNotContain("visibility", siteModel1.getVisibility().toString()) - .and().entriesListDoesNotContain("title", siteModel1.getTitle()); + .assertThat() + .entriesListDoesNotContain("targetGuid", siteModel1.getGuid()) + .and().entriesListDoesNotContain("id", siteModel1.getId()) + .and().entriesListDoesNotContain("description", siteModel1.getDescription()) + .and().entriesListDoesNotContain("visibility", siteModel1.getVisibility().toString()) + .and().entriesListDoesNotContain("title", siteModel1.getTitle()); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) @@ -90,12 +90,12 @@ public class DeleteFavoriteSiteSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); restClient.withCoreAPI().usingAuthUser().getFavorites() - .assertThat() - .entriesListDoesNotContain("targetGuid", siteModel1.getGuid()) - .and().entriesListDoesNotContain("id", siteModel1.getId()) - .and().entriesListDoesNotContain("description", siteModel1.getDescription()) - .and().entriesListDoesNotContain("visibility", siteModel1.getVisibility().toString()) - .and().entriesListDoesNotContain("title", siteModel1.getTitle()); + .assertThat() + .entriesListDoesNotContain("targetGuid", siteModel1.getGuid()) + .and().entriesListDoesNotContain("id", siteModel1.getId()) + .and().entriesListDoesNotContain("description", siteModel1.getDescription()) + .and().entriesListDoesNotContain("visibility", siteModel1.getVisibility().toString()) + .and().entriesListDoesNotContain("title", siteModel1.getTitle()); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) @@ -112,12 +112,12 @@ public class DeleteFavoriteSiteSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); restClient.withCoreAPI().usingAuthUser().getFavorites() - .assertThat() - .entriesListDoesNotContain("targetGuid", siteModel1.getGuid()) - .and().entriesListDoesNotContain("id", siteModel1.getId()) - .and().entriesListDoesNotContain("description", siteModel1.getDescription()) - .and().entriesListDoesNotContain("visibility", siteModel1.getVisibility().toString()) - .and().entriesListDoesNotContain("title", siteModel1.getTitle()); + .assertThat() + .entriesListDoesNotContain("targetGuid", siteModel1.getGuid()) + .and().entriesListDoesNotContain("id", siteModel1.getId()) + .and().entriesListDoesNotContain("description", siteModel1.getDescription()) + .and().entriesListDoesNotContain("visibility", siteModel1.getVisibility().toString()) + .and().entriesListDoesNotContain("title", siteModel1.getTitle()); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) @@ -156,7 +156,6 @@ public class DeleteFavoriteSiteSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized to remove a site from its favorite sites list with Rest API when authentication fails (401)") - @Bug(id = "MNT-16904") public void managerUserNotAuthorizedFailsToRemoveFavoriteSite() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); From a2387c14e88558520cf5ceb0b3bc4c3b14cad3c2 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Fri, 13 Jan 2017 10:53:45 +0200 Subject: [PATCH 0860/1491] Remove not needed groups --- .../RestGetNetworksForPersonSanityTests.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonSanityTests.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonSanityTests.java index d1d4bb596..4f46e7402 100644 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonSanityTests.java @@ -35,7 +35,7 @@ public class RestGetNetworksForPersonSanityTests extends RestTest @Bug(id = "MNT-16904") @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify non existing user gets another exisiting network with Rest API and checks the unauthorized status") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY, TestGroup.COMMENTS, TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.SANITY, TestGroup.NETWORKS }) public void nonExistingTenantUserIsNotAuthorizedToRequest() throws Exception { UserModel tenantUser = new UserModel("nonexisting", "password"); @@ -48,7 +48,7 @@ public class RestGetNetworksForPersonSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify tenant admin user gets specific network with Rest API and response is not empty") - @Test(groups = {TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY, TestGroup.COMMENTS, TestGroup.NETWORKS }) + @Test(groups = {TestGroup.REST_API, TestGroup.SANITY, TestGroup.NETWORKS }) public void adminTenantChecksIfNetworkIsPresent() throws Exception { restClient.authenticateUser(adminTenantUser); @@ -58,7 +58,7 @@ public class RestGetNetworksForPersonSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify tenant user is not authorized to check network of admin user with Rest API and checks the forbidden status") - @Test(groups = {TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY, TestGroup.COMMENTS, TestGroup.NETWORKS }) + @Test(groups = {TestGroup.REST_API, TestGroup.SANITY, TestGroup.NETWORKS }) public void tenantUserIsNotAuthorizedToCheckNetworkOfAdminUser() throws Exception { restClient.authenticateUser(tenantUser); @@ -68,7 +68,7 @@ public class RestGetNetworksForPersonSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify admin tenant user is not authorized to check network of another user with Rest API and checks the forbidden status") - @Test(groups = {TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY, TestGroup.COMMENTS, TestGroup.NETWORKS }) + @Test(groups = {TestGroup.REST_API, TestGroup.SANITY, TestGroup.NETWORKS }) public void adminTenantUserIsNotAuthorizedToCheckNetworkOfAnotherUser() throws Exception { UserModel secondAdminTenantUser = UserModel.getAdminTenantUser(); @@ -81,7 +81,7 @@ public class RestGetNetworksForPersonSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify tenant manager user gets specific network with Rest API and response is not empty") - @Test(groups = {TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY, TestGroup.COMMENTS, TestGroup.NETWORKS }) + @Test(groups = {TestGroup.REST_API, TestGroup.SANITY, TestGroup.NETWORKS }) public void managerTenantChecksIfNetworkIsPresent() throws Exception { UserModel managerTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("managerTenant"); @@ -95,7 +95,7 @@ public class RestGetNetworksForPersonSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify tenant collaborator user gets specific network with Rest API and response is not empty") - @Test(groups = {TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY, TestGroup.COMMENTS, TestGroup.NETWORKS }) + @Test(groups = {TestGroup.REST_API, TestGroup.SANITY, TestGroup.NETWORKS }) public void collaboratorTenantChecksIfNetworkIsPresent() throws Exception { UserModel collaboratorTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("collaboratorTenant"); @@ -109,7 +109,7 @@ public class RestGetNetworksForPersonSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify tenant contributor user gets specific network with Rest API and response is not empty") - @Test(groups = {TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY, TestGroup.COMMENTS, TestGroup.NETWORKS }) + @Test(groups = {TestGroup.REST_API, TestGroup.SANITY, TestGroup.NETWORKS }) public void contributorTenantChecksIfNetworkIsPresent() throws Exception { UserModel contributorTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("contributorTenant"); @@ -123,7 +123,7 @@ public class RestGetNetworksForPersonSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify tenant consumer user gets specific network with Rest API and response is not empty") - @Test(groups = {TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY, TestGroup.COMMENTS, TestGroup.NETWORKS }) + @Test(groups = {TestGroup.REST_API, TestGroup.SANITY, TestGroup.NETWORKS }) public void consumerTenantChecksIfNetworkIsPresent() throws Exception { UserModel consumerTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("consumerTenant"); From 7b6020252d5817990c7e2d966d9352c7c594daf8 Mon Sep 17 00:00:00 2001 From: mionescu Date: Fri, 13 Jan 2017 11:44:21 +0200 Subject: [PATCH 0861/1491] test- added new test cases using tenant --- .../rest/people/AddFavoriteSiteFullTests.java | 68 ++++++++++++++++++- 1 file changed, 67 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteFullTests.java b/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteFullTests.java index d30081b31..c8df80f33 100644 --- a/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteFullTests.java +++ b/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteFullTests.java @@ -29,7 +29,7 @@ import org.testng.annotations.Test; public class AddFavoriteSiteFullTests extends RestTest { - UserModel userModel, adminUserModel; + UserModel userModel, adminUserModel, adminTenantUser, tenantUser; SiteModel siteModel, privateSiteModel, moderatedSiteModel; UserModel searchedUser; FileModel document; @@ -261,5 +261,71 @@ public class AddFavoriteSiteFullTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, site.getId().split("/")[3])); } + + @Bug(id="MNT-16904") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify tenant user is not able to delete favorites using an invalid network ID - status code (401)") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.NETWORKS, TestGroup.FULL }) + public void tenantIsNotAbleToDeleteFavoriteSiteWithInvalidNetworkID() throws JsonToModelConversionException, Exception + { + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUserModel).usingTenant().createTenant(adminTenantUser); + tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + siteModel = dataSite.usingUser(tenantUser).createPublicRandomSite(); + siteModel.setGuid(restClient.authenticateUser(tenantUser).withCoreAPI().usingSite(siteModel).getSite().getGuid()); + restClient.authenticateUser(tenantUser).withCoreAPI(); + tenantUser.setDomain("invalidNetwork"); + + restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify tenant user deletes favorites site and status code is (201)") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.NETWORKS, TestGroup.FULL }) + public void tenantDeleteFavoriteSiteValidNetwork() throws JsonToModelConversionException, Exception + { + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUserModel).usingTenant().createTenant(adminTenantUser); + tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + siteModel = dataSite.usingUser(tenantUser).createPublicRandomSite(); + siteModel.setGuid(restClient.authenticateUser(tenantUser).withCoreAPI().usingSite(siteModel).getSite().getGuid()); + restClient.authenticateUser(tenantUser).withCoreAPI(); + tenantUser.setDomain(tenantUser.getDomain()); + + restClient.withCoreAPI() + .usingAuthUser().addSiteToFavorites(siteModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.withCoreAPI().usingAuthUser().getFavorites() + .assertThat() + .entriesListContains("targetGuid", siteModel.getGuidWithoutVersion()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify tenant user deletes favorites site created by admin tenant - same network and status code is (201)") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.NETWORKS, TestGroup.FULL }) + public void tenantUserIsAbleToDeleteFavoriteSiteAddedByAdminSameNetwork() throws JsonToModelConversionException, Exception + { + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUserModel).usingTenant().createTenant(adminTenantUser); + tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); + siteModel.setGuid(restClient.authenticateUser(adminTenantUser).withCoreAPI().usingSite(siteModel).getSite().getGuid()); + restClient.authenticateUser(tenantUser).withCoreAPI(); + tenantUser.setDomain(adminTenantUser.getDomain()); + + restClient.withCoreAPI().usingAuthUser().addFavoriteSite(siteModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.withCoreAPI().usingAuthUser().getFavorites() + .assertThat() + .entriesListContains("targetGuid", siteModel.getGuidWithoutVersion()); + } } From 5f712553df7e039fa622f6c70f833320ddb320e3 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Fri, 13 Jan 2017 11:47:27 +0200 Subject: [PATCH 0862/1491] Add AddFavorites Core tests --- .../rest/favorites/AddFavoritesFullTests.java | 267 ++++++++++++++++++ .../rest/favorites/GetFavoritesFullTests.java | 4 +- 2 files changed, 269 insertions(+), 2 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/favorites/AddFavoritesFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesFullTests.java b/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesFullTests.java new file mode 100644 index 000000000..4460b3370 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesFullTests.java @@ -0,0 +1,267 @@ +package org.alfresco.rest.favorites; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestFileModel; +import org.alfresco.rest.model.RestFolderModel; +import org.alfresco.rest.model.RestPersonFavoritesModel; +import org.alfresco.rest.model.RestSiteModel; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class AddFavoritesFullTests extends RestTest +{ + private UserModel adminUserModel; + private SiteModel siteModel; + private ListUserWithRoles usersWithRoles; + private RestPersonFavoritesModel restPersonFavoritesModel; + + FileModel document; + FolderModel folder; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + folder = dataContent.usingSite(siteModel).usingUser(adminUserModel).createFolder(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Add to favorites a file for a Collaborator, check it was added") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) + public void collaboratorIsAbleToAddFileToFavorites() throws Exception + { + restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingAuthUser().addFileToFavorites(document); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restPersonFavoritesModel.assertThat().field("targetGuid").is(document.getNodeRefWithoutVersion()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Add to favorites a file for a Contributor, check it was added") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) + public void contributorIsAbleToAddFileToFavorites() throws Exception + { + restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) + .withCoreAPI().usingAuthUser().addFileToFavorites(document); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restPersonFavoritesModel.assertThat().field("targetGuid").is(document.getNodeRefWithoutVersion()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Add to favorites a file for a Consumer, check it was added") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) + public void consumerIsAbleToAddFileToFavorites() throws Exception + { + restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + .withCoreAPI().usingAuthUser().addFileToFavorites(document); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restPersonFavoritesModel.assertThat().field("targetGuid").is(document.getNodeRefWithoutVersion()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Add to favorites a folder for a Collaborator, check it was added") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) + public void collaboratorIsAbleToAddFolderToFavorites() throws Exception + { + restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).addFolderToFavorites(folder); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restPersonFavoritesModel.assertThat().field("targetGuid").is(folder.getNodeRefWithoutVersion()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Add to favorites a folder for a Contributor, check it was added") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) + public void contributorIsAbleToAddFolderToFavorites() throws Exception + { + restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) + .withCoreAPI().usingAuthUser().addFolderToFavorites(folder); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restPersonFavoritesModel.assertThat().field("targetGuid").is(folder.getNodeRefWithoutVersion()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Add to favorites a folder for a Consumer, check it was added") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) + public void consumerIsAbleToAddFolderToFavorites() throws Exception + { + restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + .withCoreAPI().usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).addFolderToFavorites(folder); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restPersonFavoritesModel.assertThat().field("targetGuid").is(folder.getNodeRefWithoutVersion()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Add to favorites a site for a Collaborator, check it was added") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) + public void collaboratorIsAbleToAddSiteToFavorites() throws Exception + { + restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restPersonFavoritesModel.assertThat().field("targetGuid").is(siteModel.getGuid()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Add to favorites a site for a Contributor, check it was added") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) + public void contributorIsAbleToAddSiteToFavorites() throws Exception + { + restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) + .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restPersonFavoritesModel.assertThat().field("targetGuid").is(siteModel.getGuid()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Add to favorites a site for a Consumer, check it was added") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) + public void consumerIsAbleToAddSiteToFavorites() throws Exception + { + restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restPersonFavoritesModel.assertThat().field("targetGuid").is(siteModel.getGuid()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Check that if user provides file in target but guid is of a site status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) + public void addSiteToFavoritesUsingFolderId() throws Exception + { + SiteModel newSiteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + newSiteModel.setGuid(folder.getNodeRef()); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteToFavorites(newSiteModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, folder.getNodeRef())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Check that if user provides folder in target but guid is of a site status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) + public void addFolderToFavoritesUsingSiteId() throws Exception + { + FolderModel newFolder = dataContent.usingSite(siteModel).usingUser(adminUserModel).createFolder(); + newFolder.setNodeRef(siteModel.getGuid()); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFolderToFavorites(newFolder); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, + adminUserModel.getUsername(), siteModel.getGuid())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify the response of favorite a site call is valid") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) + public void verifyFavoriteASiteResponseIsValid() throws Exception + { + restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restPersonFavoritesModel.assertThat().field("targetGuid").is(siteModel.getGuid()); + + RestSiteModel restSiteModel = restPersonFavoritesModel.getTarget().getSite(); + restSiteModel.assertThat().field("visibility").is(siteModel.getVisibility()).and() + .field("guid").is(siteModel.getGuid()).and() + .field("description").is(siteModel.getDescription()).and() + .field("id").is(siteModel.getId()).and() + .field("title").is(siteModel.getTitle()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify the response of favorite a file call is valid") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) + public void verifyFavoriteAFileResponseIsValid() throws Exception + { + restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingAuthUser().addFileToFavorites(document); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restPersonFavoritesModel.assertThat().field("targetGuid").is(document.getNodeRefWithoutVersion()); + + RestFileModel restFileModel = restPersonFavoritesModel.getTarget().getFile(); + restFileModel.assertThat().field("mimeType").is("text/plain").and() + .field("isFile").is("true").and() + .field("isFolder").is("false").and() + .field("createdBy").is(adminUserModel.getUsername()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify the response of favorite a folder call is valid") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) + public void verifyFavoriteAFolderResponseIsValid() throws Exception + { + restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingAuthUser().addFolderToFavorites(folder); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restPersonFavoritesModel.assertThat().field("targetGuid").is(folder.getNodeRef()); + + RestFolderModel restFolderModel = restPersonFavoritesModel.getTarget().getFolder(); + restFolderModel.assertThat().field("isFile").is("false").and() + .field("isFolder").is("true").and() + .field("createdBy").is(adminUserModel.getUsername()); + } + + @Bug(id = "REPO-1061") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Check that if user does not have permission to favorite a site status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) + public void verifyFavoriteASiteIfTheUserDoesNotHavePermission() throws Exception + { + SiteModel privateSite = dataSite.usingUser(adminUserModel).createPrivateRandomSite(); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingAuthUser().addSiteToFavorites(privateSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, privateSite.getGuid())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .containsErrorKey(RestErrorModel.NOT_FOUND_ERRORKEY) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Bug(id = "MNT-16904") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify the post favorites request when network id is invalid for tenant user") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL, TestGroup.NETWORKS}) + public void addFavoriteSitesWhenNetworkIdIsInvalid() throws JsonToModelConversionException, Exception + { + UserModel adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUserModel); + restClient.usingTenant().createTenant(adminTenantUser); + UserModel tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + + tenantUser.setDomain("invalidNetwork"); + restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify the response of favorite a sie with empty body at request") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) + public void verifyFavoriteASiteWithEmptyBody() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI(); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "", "people/{personId}/favorites", adminUserModel.getUsername()); + restClient.processModel(RestPersonFavoritesModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.NO_CONTENT, "No content to map to Object due to end of input"));; + } +} diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesFullTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesFullTests.java index 382cbed41..9d553dcc1 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesFullTests.java @@ -85,7 +85,7 @@ public class GetFavoritesFullTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify get favorites when using invalid network id") + description = "Verify get favorites when using invalid network id for non-tenant user") @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) public void getFavoritesWhenNetworkIdIsInvalid() throws Exception { @@ -171,7 +171,7 @@ public class GetFavoritesFullTests extends RestTest @Bug(id = "MNT-16904") @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify the get favorites request when network id is invalid") + description = "Verify the get favorites request when network id is invalid for tenant user") @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL, TestGroup.NETWORKS}) public void getFavoriteSitesWhenNetworkIdIsInvalid() throws JsonToModelConversionException, Exception { From 0b93d0b94700103bc5acff4dd39386e4b146349a Mon Sep 17 00:00:00 2001 From: Andrei Rusu Date: Fri, 13 Jan 2017 11:49:20 +0200 Subject: [PATCH 0863/1491] UpdateCommentFullTests added --- .../{UpdateCommentsCoreTests.java => UpdateCommentCoreTests.java} | 0 ...dateCommentsSanityTests.java => UpdateCommentSanityTests.java} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename e2e-test/java/org/alfresco/rest/comments/{UpdateCommentsCoreTests.java => UpdateCommentCoreTests.java} (100%) rename e2e-test/java/org/alfresco/rest/comments/{UpdateCommentsSanityTests.java => UpdateCommentSanityTests.java} (100%) diff --git a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsCoreTests.java b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentCoreTests.java similarity index 100% rename from e2e-test/java/org/alfresco/rest/comments/UpdateCommentsCoreTests.java rename to e2e-test/java/org/alfresco/rest/comments/UpdateCommentCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentSanityTests.java similarity index 100% rename from e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java rename to e2e-test/java/org/alfresco/rest/comments/UpdateCommentSanityTests.java From 247af74991e6a3e1a347a5253c05882a04ad715a Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Fri, 13 Jan 2017 11:51:30 +0200 Subject: [PATCH 0864/1491] move one core test from full class of tests and added new bug to a test --- .../networks/RestGetNetworkCoreTests.java | 41 +++++++++++++++++++ .../networks/RestGetNetworkFullTests.java | 8 ++-- .../networks/RestGetNetworkSanityTests.java | 10 ----- 3 files changed, 44 insertions(+), 15 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/networks/RestGetNetworkCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkCoreTests.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkCoreTests.java new file mode 100644 index 000000000..cdb116035 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkCoreTests.java @@ -0,0 +1,41 @@ +package org.alfresco.rest.networks; + +import org.alfresco.rest.RestTest; +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 Cristina Axinte + * + */ +public class RestGetNetworkCoreTests extends RestTest +{ + UserModel adminTenantUser; + UserModel tenantUser; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + UserModel adminuser = dataUser.getAdminUser(); + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminuser); + restClient.usingTenant().createTenant(adminTenantUser); + tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify tenant admin user gets non existing network with Rest API and checks the not found status") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.CORE }) + public void adminTenantChecksIfNonExistingNetworkIsNotFound() throws Exception + { + restClient.authenticateUser(adminTenantUser); + restClient.withCoreAPI().usingNetworks().getNetwork(UserModel.getRandomTenantUser()); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } +} diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkFullTests.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkFullTests.java index a5f43081b..4b39e7d72 100644 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkFullTests.java +++ b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkFullTests.java @@ -60,14 +60,13 @@ public class RestGetNetworkFullTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE); } - @Bug(id = "needs to be checked") + @Bug(id = "ACE-5745") @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, description = "Verify admin user gets an existing network successfully with Rest API") @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.FULL }) public void adminUserGetsExistingNetwork() throws Exception { - restClient.authenticateUser(adminuser); - RestNetworkModel restNetworkModel = restClient.withCoreAPI().usingNetworks().getNetwork(adminTenantUser); + RestNetworkModel restNetworkModel = restClient.authenticateUser(adminuser).withCoreAPI().usingNetworks().getNetwork(adminTenantUser); restClient.assertStatusCodeIs(HttpStatus.OK); restNetworkModel.assertThat().fieldsCount().is("1"); restNetworkModel.assertThat().field("id").is(adminTenantUser.getDomain()) @@ -80,8 +79,7 @@ public class RestGetNetworkFullTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.FULL }) public void adminTenantGetsNetworkUsingPropertiesParameter() throws Exception { - restClient.authenticateUser(tenantUser); - JSONObject entryResponse= restClient.withCoreAPI().usingNetworks().usingParams("properties=id").getNetworkWithParams(adminTenantUser); + JSONObject entryResponse= restClient.authenticateUser(tenantUser).withCoreAPI().usingNetworks().usingParams("properties=id").getNetworkWithParams(adminTenantUser); restClient.assertStatusCodeIs(HttpStatus.OK); Assert.assertTrue(entryResponse.get("id").equals(adminTenantUser.getDomain().toLowerCase())); assertJsonResponseDoesnotContainField(entryResponse, "homeNetwork"); diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkSanityTests.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkSanityTests.java index cf0cd9e96..a56e2cc0b 100644 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkSanityTests.java @@ -68,16 +68,6 @@ public class RestGetNetworkSanityTests extends RestTest restClient.withCoreAPI().usingNetworks().getNetwork().assertNetworkHasName(adminTenantUser).assertNetworkIsEnabled(); } - @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, - description = "Verify tenant admin user gets non existing network with Rest API and checks the not found status") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) - public void adminTenantChecksIfNonExistingNetworkIsNotFound() throws Exception - { - restClient.authenticateUser(adminTenantUser); - restClient.withCoreAPI().usingNetworks().getNetwork(UserModel.getRandomTenantUser()); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } - @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify tenant admin user gets another existing network with Rest API and checks the forbidden status") @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) From be621f655d75b8f888f3830e68d0c9128af65e4b Mon Sep 17 00:00:00 2001 From: Andrei Rusu Date: Fri, 13 Jan 2017 11:52:16 +0200 Subject: [PATCH 0865/1491] updateCommentFullTests --- .../rest/comments/UpdateCommentCoreTests.java | 15 +- .../rest/comments/UpdateCommentFullTests.java | 286 ++++++++++++++++++ .../comments/UpdateCommentSanityTests.java | 4 +- 3 files changed, 296 insertions(+), 9 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/comments/UpdateCommentFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentCoreTests.java b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentCoreTests.java index 43ed657fb..1625945e8 100644 --- a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentCoreTests.java @@ -21,7 +21,7 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -public class UpdateCommentsCoreTests extends RestTest +public class UpdateCommentCoreTests extends RestTest { private UserModel adminUserModel; private FileModel document; @@ -74,21 +74,22 @@ public class UpdateCommentsCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify updated comment by Manager is listed when calling getComments and status code is 200") - @Bug(id="REPO-1011") +// @Bug(id="REPO-1011") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) public void updatedCommentByManagerIsListed() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by collaborator"); - restClient.withCoreAPI().usingResource(document).updateComment(commentModel, "This is the updated comment with Collaborator user"); + commentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingResource(document).addComment("This is a new comment added by collaborator"); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI() + .usingResource(document).updateComment(commentModel, "This is the updated comment with Manager user"); comments = restClient.withCoreAPI().usingResource(document).getNodeComments(); restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", "This is the updated comment with Collaborator user"); + comments.assertThat().entriesListContains("content", "This is the updated comment with Manager user"); } @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user can not update comments of another user and status code is 200") - @Bug(id="MNT-2502",description="seems it's one old issue: also logged as MNT-2502, MNT-2346") +// @Bug(id="MNT-2502",description="seems it's one old issue: also logged as MNT-2502, MNT-2346") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) public void collaboratorIsNotAbleToUpdateCommentOfAnotherUser() throws JsonToModelConversionException, Exception { diff --git a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentFullTests.java b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentFullTests.java new file mode 100644 index 000000000..aa1b74dad --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentFullTests.java @@ -0,0 +1,286 @@ +package org.alfresco.rest.comments; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestCommentModel; +import org.alfresco.rest.model.RestCommentModelsCollection; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.apache.commons.lang.RandomStringUtils; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class UpdateCommentFullTests extends RestTest +{ + private UserModel adminUserModel, networkUserModel; + private SiteModel siteModel; + private RestCommentModel commentModel, returnedCommentModel; + private RestCommentModelsCollection comments; + private DataUser.ListUserWithRoles usersWithRoles; + private String firstComment = "This is a new comment"; + private String updatedComment = "This is the updated comment"; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + networkUserModel = dataUser.createRandomTestUser(); + restClient.authenticateUser(adminUserModel); + siteModel = dataSite.usingUser(adminUserModel).createPrivateRandomSite(); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, + UserRole.SiteConsumer, UserRole.SiteContributor); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.FULL}, executionType= ExecutionType.REGRESSION, + description= "Verify Manager user can update a comment with a large string") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void managerIsAbleToUpdateACommentWithALargeString() throws JsonToModelConversionException, Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + String longString = RandomStringUtils.randomAlphanumeric(10000); + + commentModel = restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingResource(file).addComment(firstComment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedCommentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(file).updateComment(commentModel, longString); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCommentModel.assertThat().field("content").is(longString); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.FULL}, executionType= ExecutionType.REGRESSION, + description= "Verify Manager user can update a comment with a short string") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void managerIsAbleToUpdateACommentWithAShortString() throws JsonToModelConversionException, Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + String shortString = RandomStringUtils.randomAlphanumeric(2); + + commentModel = restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingResource(file).addComment(firstComment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedCommentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(file).updateComment(commentModel, shortString); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCommentModel.assertThat().field("content").is(shortString); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.FULL}, executionType= ExecutionType.REGRESSION, + description= "Verify Collaborator user can update a comment with special characters") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void collaboratorIsAbleToUpdateACommentThatContainsSpecialChars() throws JsonToModelConversionException, Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + String specialChars = "!@#$%^&*()'\".,<>-_+=|\\"; + + commentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingResource(file).addComment(firstComment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedCommentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingResource(file).updateComment(commentModel, specialChars); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCommentModel.assertThat().field("content").is(specialChars); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.FULL}, executionType= ExecutionType.REGRESSION, + description= "Check that you cannot update comment with Consumer then call getComments and check new comment is not listed") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void cannotUpdateCommentWithConsumerCallGetComments() throws JsonToModelConversionException, Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + + commentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingResource(file).addComment(firstComment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingResource(file).updateComment(commentModel, updatedComment); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + + comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", firstComment) + .and().entriesListDoesNotContain("content", updatedComment) + .and().paginationField("totalItems").is("1"); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.FULL}, executionType= ExecutionType.REGRESSION, + description= "Update comment with Contributor then call getComments and check new comment is listed") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + @Bug(id = "ACE-4614") + public void updateCommentWithContributorCallGetComments() throws JsonToModelConversionException, Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + + commentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) + .withCoreAPI().usingResource(file).addComment(firstComment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingResource(file).updateComment(commentModel, updatedComment); + restClient.assertStatusCodeIs(HttpStatus.OK); + + comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", updatedComment) + .and().entriesListDoesNotContain("content", firstComment) + .and().paginationField("totalItems").is("1"); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.FULL}, executionType= ExecutionType.REGRESSION, + description= "Update comment with Collaborator then call getComments and check new comment is listed") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void updateCommentWithCollaboratorCallGetComments() throws JsonToModelConversionException, Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + + commentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingResource(file).addComment(firstComment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(file).updateComment(commentModel, updatedComment); + restClient.assertStatusCodeIs(HttpStatus.OK); + + comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", updatedComment) + .and().entriesListDoesNotContain("content", firstComment) + .and().paginationField("totalItems").is("1"); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.FULL}, executionType= ExecutionType.REGRESSION, + description= "Update comment with Manager then check modified by information in response") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void updateCommentWithManagerCheckModifiedBy() throws JsonToModelConversionException, Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + UserModel manager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); + + commentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingResource(file).addComment(firstComment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedCommentModel = restClient.authenticateUser(manager).withCoreAPI().usingResource(file).updateComment(commentModel, updatedComment); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCommentModel.assertThat().field("modifiedBy.id").is(manager.getUsername()) + .and().field("content").is(updatedComment); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.FULL}, executionType= ExecutionType.REGRESSION, + description= "Delete comment with Admin then try to update it") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void deleteCommentThenTryToUpdateIt() throws JsonToModelConversionException, Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + + commentModel = restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingResource(file).addComment(firstComment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.withCoreAPI().usingResource(file).deleteComment(commentModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingResource(file).updateComment(commentModel, updatedComment); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.FULL}, executionType= ExecutionType.REGRESSION, + description= "Verify Manager user can update a comment with multi byte content") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void managerIsAbleToUpdateACommentWithMultiByteContent() throws JsonToModelConversionException, Exception + { + //TODO update comment with multi-byte content - verify + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + String multiByte = "\ufeff\u6768\u6728\u91d1"; + + commentModel = restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingResource(file).addComment(firstComment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedCommentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(file).updateComment(commentModel, multiByte); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCommentModel.assertThat().field("content").is(multiByte); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.FULL}, executionType= ExecutionType.REGRESSION, + description= "Verify Admin user can update a comment with properties parameter") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void adminIsAbleToUpdateACommentWithPropertiesParameter() throws JsonToModelConversionException, Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + + commentModel = restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingResource(file).addComment(firstComment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + UserModel manager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); + + returnedCommentModel = restClient.authenticateUser(manager) + .withParams("properties=createdBy,modifiedBy,canEdit,canDelete").withCoreAPI().usingResource(file).updateComment(commentModel, updatedComment); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCommentModel.assertThat().field("createdBy.id").is(adminUserModel.getUsername()) + .assertThat().field("modifiedBy.id").is(manager.getUsername()) + .assertThat().fieldsCount().is(4); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FULL }, executionType = ExecutionType.REGRESSION, + description = "Update comment with invalid node") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void updateCommentUsingInvalidNodeId() throws JsonToModelConversionException, Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + + commentModel = restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingResource(file).addComment(firstComment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + file.setNodeRef(RandomStringUtils.randomAlphanumeric(20)); + restClient.withCoreAPI().usingResource(file).updateComment(commentModel, updatedComment); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, file.getNodeRef())); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.FULL, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify update comment from node with invalid network id returns status code 401") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void updateCommentWithInvalidNetworkId() throws Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + + commentModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(firstComment); + networkUserModel.setDomain("invalidNetwork"); + restClient.authenticateUser(networkUserModel).withCoreAPI().usingResource(file).updateComment(commentModel, updatedComment); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.FULL, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify User can not update comment to a not joined private site. Status code returned is 403") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void userCanNotUpdateCommentToANotJoinedPrivateSiteDefaultErrorModelSchema() throws Exception + { + UserModel newUser = dataUser.createRandomTestUser(); + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + + commentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(file).addComment(firstComment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(newUser).withCoreAPI().usingResource(file).updateComment(commentModel, updatedComment); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + restClient.assertLastError().getErrorKey().contains(RestErrorModel.PERMISSION_DENIED_ERRORKEY); + restClient.assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + restClient.assertLastError().getDescriptionURL().contains("https://api-explorer.alfresco.com"); + restClient.assertLastError().getStackTrace().contains("For security reasons the stack trace is no longer displayed"); + } +} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentSanityTests.java index 05badefac..87756ff4e 100644 --- a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentSanityTests.java @@ -19,7 +19,7 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -public class UpdateCommentsSanityTests extends RestTest +public class UpdateCommentSanityTests extends RestTest { private UserModel adminUserModel; private FileModel document; @@ -93,7 +93,7 @@ public class UpdateCommentsSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user can update his own comment and status code is 200") - @Bug(id="REPO-1011") +// @Bug(id="REPO-1011") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) public void collaboratorIsAbleToUpdateHisComment() throws JsonToModelConversionException, Exception { From 6268a04db0123d2f001989b56ad8d3c562d09891 Mon Sep 17 00:00:00 2001 From: "NESS\\P3700299" Date: Fri, 13 Jan 2017 12:08:13 +0200 Subject: [PATCH 0866/1491] added 3 tests to full --- .../rest/favorites/GetFavoriteFullTests.java | 82 ++++++++++++++++++- 1 file changed, 79 insertions(+), 3 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteFullTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteFullTests.java index 6d9d2d43c..c7c68feba 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteFullTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteFullTests.java @@ -16,6 +16,7 @@ import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; +import org.springframework.social.alfresco.api.entities.Site; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -121,11 +122,86 @@ public class GetFavoriteFullTests extends RestTest { { UserModel collaborator = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); restClient.authenticateUser(collaborator); - restClient.withCoreAPI().usingUser(collaborator).addSiteToFavorites(siteModel); + restClient.withCoreAPI().usingUser(collaborator).addFileToFavorites(fileModel); - RestPersonFavoritesModel favoriteSite = restClient.authenticateUser(collaborator).withParams("properties=tas") + RestPersonFavoritesModel favoriteFile = restClient.authenticateUser(collaborator).withParams("properties=tas") .withCoreAPI().usingAuthUser().getFavorite(fileModel.getNodeRefWithoutVersion()); restClient.assertStatusCodeIs(HttpStatus.OK); - favoriteSite.assertThat().fieldsCount().is(0); + favoriteFile.assertThat().fieldsCount().is(0); + } + + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify all values from get favorite rest api for a file") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) + public void verifyRequestFieldsforGetFavoriteFile() throws JsonToModelConversionException, Exception + { + UserModel contributor = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); + restClient.authenticateUser(contributor); + restClient.withCoreAPI().usingUser(contributor).addFileToFavorites(fileModel); + + RestPersonFavoritesModel favoriteFile = restClient.authenticateUser(contributor) + .withCoreAPI().usingAuthUser().getFavorite(fileModel.getNodeRefWithoutVersion()); + restClient.assertStatusCodeIs(HttpStatus.OK); + + favoriteFile.assertThat().field("targetGuid").is(fileModel.getNodeRefWithoutVersion()) + .and().field("target.file.isFile").is("true") + .and().field("target.file.mimeType").is("text/plain") + .and().field("target.file.isFolder").is("false") + .and().field("target.file.createdBy").is(adminUserModel.getUsername()) + .and().field("target.file.versionLabel").is("1.0") + .and().field("target.file.name").is(fileModel.getName()) + .and().field("target.file.parentId").is(folderModel.getNodeRef()) + .and().field("target.file.guid").is(fileModel.getNodeRefWithoutVersion()) + .and().field("target.file.modifiedBy").is(adminUserModel.getUsername()) + .and().field("target.file.id").is(fileModel.getNodeRefWithoutVersion()); + } + + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify all values from get favorite rest api for a site") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) + public void verifyRequestFieldsforGetFavoriteSite() throws JsonToModelConversionException, Exception + { + UserModel contributor = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); + restClient.authenticateUser(contributor); + restClient.withCoreAPI().usingUser(contributor).addFavoriteSite(siteModel); + + RestPersonFavoritesModel favoriteSite = restClient.authenticateUser(contributor) + .withCoreAPI().usingAuthUser().getFavorite(siteModel.getGuid()); + restClient.assertStatusCodeIs(HttpStatus.OK); + + favoriteSite.assertThat().field("targetGuid").is(siteModel.getGuid()) + .and().field("target.site.role").is(UserRole.SiteContributor.toString()) + .and().field("target.site.visibility").is(Site.Visibility.PUBLIC.toString()) + .and().field("target.site.guid").is(siteModel.getGuid()) + .and().field("target.site.description").is(siteModel.getDescription()) + .and().field("target.site.id").is(siteModel.getId()) + .and().field("target.site.preset").is("site-dashboard") + .and().field("target.site.title").is(siteModel.getTitle()); + } + + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify all values from get favorite rest api for a folder") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) + public void verifyRequestFieldsforGetFavoriteFolder() throws JsonToModelConversionException, Exception + { + UserModel contributor = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); + restClient.authenticateUser(contributor); + restClient.withCoreAPI().usingUser(contributor).addFolderToFavorites(folderModel); + + RestPersonFavoritesModel favoriteFolder = restClient.authenticateUser(contributor) + .withCoreAPI().usingAuthUser().getFavorite(folderModel.getNodeRef()); + restClient.assertStatusCodeIs(HttpStatus.OK); + + favoriteFolder.assertThat().field("targetGuid").is(folderModel.getNodeRef()) + .and().field("target.folder.isFile").is("false") + .and().field("target.folder.isFolder").is("true") + .and().field("target.folder.createdBy").is(adminUserModel.getUsername()) + .and().field("target.folder.name").is(folderModel.getName()) + .and().field("target.folder.guid").is(folderModel.getNodeRef()) + .and().field("target.folder.modifiedBy").is(adminUserModel.getUsername()) + .and().field("target.folder.id").is(folderModel.getNodeRef()); } } \ No newline at end of file From f646552458d081f412d25fbd02c30a0afb3af1da Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Fri, 13 Jan 2017 12:29:57 +0200 Subject: [PATCH 0867/1491] Added full tests for networks membership --- .../RestGetNetworksForPersonFullTests.java | 88 +++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonFullTests.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonFullTests.java new file mode 100644 index 000000000..6a4232416 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonFullTests.java @@ -0,0 +1,88 @@ +package org.alfresco.rest.networks; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestNetworkModelsCollection; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class RestGetNetworksForPersonFullTests extends RestTest +{ + private UserModel adminUserModel; + private UserModel adminTenantUser; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUserModel); + restClient.usingTenant().createTenant(adminTenantUser); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Check default error schema for get networks for member") + @Test(groups = { TestGroup.REST_API, TestGroup.FULL, TestGroup.NETWORKS }) + public void getNetworksAndCheckErrorSchema() throws Exception + { + restClient.authenticateUser(adminTenantUser).withCoreAPI().usingUser(new UserModel("invalidUser", "invalidPassword")).getNetworks(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidUser")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Check default error schema for get networks for member") + @Test(groups = { TestGroup.REST_API, TestGroup.FULL, TestGroup.NETWORKS }) + public void getNetworksAndCheckPropertiesParameter() throws Exception + { + RestNetworkModelsCollection networks = restClient.authenticateUser(adminTenantUser).withParams("properties=isEnabled,id").withCoreAPI().usingAuthUser().getNetworks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + networks.getOneRandomEntry().onModel().assertThat().field("homeNetwork").is("false") + .and().field("quotas").isNull() + .and().field("isEnabled").is("true") + .and().field("id").is(adminTenantUser.getDomain().toLowerCase()); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Check that skipCount parameter is applied") + @Test(groups = { TestGroup.REST_API, TestGroup.FULL, TestGroup.NETWORKS }) + public void checkThatSkipCountParameterIsApplied() throws Exception + { + RestNetworkModelsCollection networks = restClient.authenticateUser(adminTenantUser).withParams("skipCount=1").withCoreAPI().usingAuthUser().getNetworks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + networks.assertThat().entriesListIsEmpty(); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Check that high skipCount parameter is applied") + @Test(groups = { TestGroup.REST_API, TestGroup.FULL, TestGroup.NETWORKS }) + public void checkThatHighSkipCountParameterIsApplied() throws Exception + { + RestNetworkModelsCollection networks = restClient.authenticateUser(adminTenantUser).withParams("skipCount=100").withCoreAPI().usingAuthUser().getNetworks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + networks.assertThat().entriesListIsEmpty(); + networks.assertThat().paginationField("skipCount").is("100"); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Check that maxItems parameter is applied") + @Test(groups = { TestGroup.REST_API, TestGroup.FULL, TestGroup.NETWORKS }) + public void checkThatMaxItemsParameterIsApplied() throws Exception + { + RestNetworkModelsCollection networks = restClient.authenticateUser(adminTenantUser).withParams("maxItems=1").withCoreAPI().usingAuthUser().getNetworks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + networks.getOneRandomEntry().onModel().assertThat().field("homeNetwork").is("false") + .and().field("quotas").is("[]") + .and().field("isEnabled").is("true") + .and().field("id").is(adminTenantUser.getDomain().toLowerCase()); + networks.assertThat().paginationField("maxItems").is("1"); + } + +} \ No newline at end of file From e76f61278bdff8f3d235e0da962a6800bbc69506 Mon Sep 17 00:00:00 2001 From: cagache Date: Fri, 13 Jan 2017 12:51:51 +0200 Subject: [PATCH 0868/1491] fix put for multi-byte content --- .../rest/comments/UpdateCommentFullTests.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentFullTests.java b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentFullTests.java index aa1b74dad..f15aba274 100644 --- a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentFullTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentFullTests.java @@ -201,7 +201,6 @@ public class UpdateCommentFullTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) public void managerIsAbleToUpdateACommentWithMultiByteContent() throws JsonToModelConversionException, Exception { - //TODO update comment with multi-byte content - verify FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); String multiByte = "\ufeff\u6768\u6728\u91d1"; @@ -277,10 +276,10 @@ public class UpdateCommentFullTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.CREATED); restClient.authenticateUser(newUser).withCoreAPI().usingResource(file).updateComment(commentModel, updatedComment); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - restClient.assertLastError().getErrorKey().contains(RestErrorModel.PERMISSION_DENIED_ERRORKEY); - restClient.assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - restClient.assertLastError().getDescriptionURL().contains("https://api-explorer.alfresco.com"); - restClient.assertLastError().getStackTrace().contains("For security reasons the stack trace is no longer displayed"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE) + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY); } } \ No newline at end of file From b2332ea021ff96a435f998d3e03bda6c494cac24 Mon Sep 17 00:00:00 2001 From: cagache Date: Fri, 13 Jan 2017 17:07:21 +0200 Subject: [PATCH 0869/1491] changed special chars string --- .../java/org/alfresco/rest/comments/AddCommentsFullTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentsFullTests.java b/e2e-test/java/org/alfresco/rest/comments/AddCommentsFullTests.java index 23a46bacd..87eaff002 100644 --- a/e2e-test/java/org/alfresco/rest/comments/AddCommentsFullTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/AddCommentsFullTests.java @@ -91,7 +91,7 @@ public class AddCommentsFullTests extends RestTest public void addCommentsWithSpecialCharsWithCollaboratorCheckCommentIsReturned() throws Exception { document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - String specialCharsString = "!@#$%^&*()_+♂µΓyádo«√<╡┌6£"; + String specialCharsString = "!@#$%^&*()'\".,<>-_+=|\\"; String shortString = RandomStringUtils.randomAlphanumeric(2); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) From 4dc518ba912137267dbf12568df519498ebde32c Mon Sep 17 00:00:00 2001 From: "NESS\\P3700299" Date: Fri, 13 Jan 2017 17:56:32 +0200 Subject: [PATCH 0870/1491] merged POSTFavSiteCore --- .../rest/people/AddFavoriteSiteCoreTests.java | 189 ++++++++++++++++++ 1 file changed, 189 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteCoreTests.java b/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteCoreTests.java new file mode 100644 index 000000000..7b487deb5 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteCoreTests.java @@ -0,0 +1,189 @@ +package org.alfresco.rest.people; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestPersonFavoritesModelsCollection; +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.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class AddFavoriteSiteCoreTests extends RestTest +{ + UserModel userModel, adminUserModel; + SiteModel siteModel, privateSiteModel, moderatedSiteModel; + UserModel searchedUser; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + privateSiteModel = dataSite.usingUser(userModel).createPrivateRandomSite(); + moderatedSiteModel = dataSite.usingUser(userModel).createModeratedRandomSite(); + } + + @Bug(id="ACE-2413") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify empty user is not able to add a site from favorites and response is (400)") + public void emptyUserIsNotAbleToRemoveFavoriteSite() throws Exception + { + UserModel emptyUser = new UserModel("", "password"); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(emptyUser).addFavoriteSite(siteModel); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "emptyUser")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify inexistent user is not able to add a site from favorites and response is (404)") + public void inexistentUserIsNotAbleToRemoveFavoriteSite() throws Exception + { + UserModel inexistentUser = new UserModel("inexistentUser", "password"); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(inexistentUser).addFavoriteSite(siteModel); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "inexistentUser")) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify manager user is not able to add a favorite site when the site is already favorite - status code (409)") + public void managerUserAddFavoriteSiteAlreadyAFavoriteSite() throws Exception + { + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); + + restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().addFavoriteSite(siteModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.withCoreAPI().usingUser(managerUser).addFavoriteSite(siteModel); + restClient.assertStatusCodeIs(HttpStatus.CONFLICT); + restClient.assertLastError() + .containsSummary(String.format("%s is already a favourite site", siteModel.getId())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE) + .containsErrorKey(String.format("Site %s is already a favourite site", siteModel.getId())); + } + + @Bug(id="MNT-17337") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify user is not able to add a favorite site when the 'id' is empty - status code (400)") + public void userAddFavoriteSiteAFavoriteSite() throws Exception + { + siteModel.setId(""); + restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().addFavoriteSite(siteModel); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + restClient.assertLastError() + .containsSummary("siteId is null") + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify user doesn't have permission to delete favorites of admin user with Rest API and status code is 403") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + public void userIsNotAbleToAddFavoriteSiteOfAnotherUser() throws JsonToModelConversionException, Exception + { + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(contributorUser, siteModel, UserRole.SiteContributor); + UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel, UserRole.SiteConsumer); + + restClient.authenticateUser(consumerUser).withCoreAPI() + .usingUser(contributorUser).addFavoriteSite(siteModel); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError() + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify manager user is able to add as favorite a private site.") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + public void managerAddsPrivateSiteAsFavorite() throws JsonToModelConversionException, Exception + { + UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(managerUser, privateSiteModel, UserRole.SiteManager); + + restClient.authenticateUser(managerUser).withCoreAPI().usingUser(managerUser).addFavoriteSite(privateSiteModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestPersonFavoritesModelsCollection favorites = restClient.withCoreAPI().usingAuthUser().getFavorites(); + favorites.assertThat().entriesListContains("targetGuid", privateSiteModel.getGuidWithoutVersion()) + .and().paginationField("totalItems").is("1"); + favorites.getOneRandomEntry().onModel().getTarget().getSite() + .assertThat() + .field("description").is(privateSiteModel.getDescription()) + .and().field("id").is(privateSiteModel.getId()) + .and().field("visibility").is(privateSiteModel.getVisibility().toString()) + .and().field("title").is(privateSiteModel.getTitle()); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify manager user is able to add as favorite a moderated site.") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + public void managerAddsModeratedSiteAsFavorite() throws JsonToModelConversionException, Exception + { + UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(managerUser, moderatedSiteModel, UserRole.SiteManager); + + restClient.authenticateUser(managerUser).withCoreAPI().usingUser(managerUser).addFavoriteSite(moderatedSiteModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestPersonFavoritesModelsCollection favorites = restClient.withCoreAPI().usingAuthUser().getFavorites(); + favorites.assertThat().entriesListContains("targetGuid", moderatedSiteModel.getGuidWithoutVersion()) + .and().paginationField("totalItems").is("1"); + favorites.getOneRandomEntry().onModel().getTarget().getSite() + .assertThat() + .field("description").is(moderatedSiteModel.getDescription()) + .and().field("id").is(moderatedSiteModel.getId()) + .and().field("visibility").is(moderatedSiteModel.getVisibility().toString()) + .and().field("title").is(moderatedSiteModel.getTitle()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify user removes a site from favorites using '-me-' in place of personId with Rest API and response is successful (201)") + public void addFavoriteSiteWithSuccessUsingMeAsPersonId() throws Exception + { + restClient.authenticateUser(adminUserModel); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingMe().addFavoriteSite(moderatedSiteModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify manager user removes a site from its favorites and adds it again and response is successful (204)") + public void managerUserRemovesFavoriteSiteAndAddItAgain() throws Exception + { + UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); + dataSite.usingUser(managerUser).usingSite(siteModel).addSiteToFavorites(); + + restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingUser(managerUser).addSiteToFavorites(siteModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + } + +} \ No newline at end of file From ce2254d9c070bdbe719d767483f7ca4cd61bb2d1 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Mon, 16 Jan 2017 10:28:41 +0200 Subject: [PATCH 0871/1491] TAS-2753 fixed 2 tests failed in Jenkins --- .../people/GetPeopleActivitiesFullTests.java | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesFullTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesFullTests.java index ffe5b50d9..4c885320c 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesFullTests.java @@ -200,25 +200,37 @@ public class GetPeopleActivitiesFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities with skipCount parameter applied with Rest API and response is successful") public void userGetPeopleActivitiesUsingSkipCountParameter() throws Exception { + restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingMe().getPersonActivities(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restActivityModelsCollection.assertThat().paginationField("count").is("4"); + RestActivityModel expectedRestActivity3 = restActivityModelsCollection.getEntries().get(2).onModel(); + RestActivityModel expectedRestActivity4 = restActivityModelsCollection.getEntries().get(3).onModel(); + restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingMe().usingParams("skipCount=2").getPersonActivities(); restClient.assertStatusCodeIs(HttpStatus.OK); restActivityModelsCollection.assertThat().paginationField("count").is("2"); - restActivityModelsCollection.getEntries().get(0).onModel().assertThat().field("postPersonId").is(userModel.getUsername().toLowerCase()) - .and().field("activityType").is(ActivityType.FOLDER_ADDED.toString()); - restActivityModelsCollection.getEntries().get(1).onModel().assertThat().field("postPersonId").is(userModel.getUsername().toLowerCase()) - .and().field("activityType").is(ActivityType.FILE_ADDED.toString()); + restActivityModelsCollection.getEntries().get(0).onModel().assertThat().field("postPersonId").is(expectedRestActivity3.getPostPersonId()) + .and().field("activityType").is(expectedRestActivity3.getActivityType()); + restActivityModelsCollection.getEntries().get(1).onModel().assertThat().field("postPersonId").is(expectedRestActivity4.getPostPersonId()) + .and().field("activityType").is(expectedRestActivity4.getActivityType()); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.FULL }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities with maxItems parameter applied with Rest API and response is successful") public void userGetPeopleActivitiesUsingMaxItemsParameter() throws Exception { + restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingMe().getPersonActivities(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restActivityModelsCollection.assertThat().paginationField("count").is("4"); + RestActivityModel expectedRestActivity1 = restActivityModelsCollection.getEntries().get(0).onModel(); + RestActivityModel expectedRestActivity2 = restActivityModelsCollection.getEntries().get(1).onModel(); + restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingMe().usingParams("maxItems=2").getPersonActivities(); restClient.assertStatusCodeIs(HttpStatus.OK); restActivityModelsCollection.assertThat().paginationField("count").is("2"); - restActivityModelsCollection.getEntries().get(0).onModel().assertThat().field("postPersonId").is(managerUser.getUsername().toLowerCase()) - .and().field("activityType").is(ActivityType.USER_JOINED.toString()); - restActivityModelsCollection.getEntries().get(1).onModel().assertThat().field("postPersonId").is(adminUser.getUsername().toLowerCase()) - .and().field("activityType").is(ActivityType.FILE_ADDED.toString()); + restActivityModelsCollection.getEntries().get(0).onModel().assertThat().field("postPersonId").is(expectedRestActivity1.getPostPersonId()) + .and().field("activityType").is(expectedRestActivity1.getActivityType()); + restActivityModelsCollection.getEntries().get(1).onModel().assertThat().field("postPersonId").is(expectedRestActivity2.getPostPersonId()) + .and().field("activityType").is(expectedRestActivity2.getActivityType()); } } From 97086cca09320c5725de35a95c55e0bfdcdcedac Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Tue, 17 Jan 2017 13:39:01 +0200 Subject: [PATCH 0872/1491] fix imports on people, favorites, comments tests --- .../org/alfresco/rest/comments/AddCommentsSanityTests.java | 1 - .../org/alfresco/rest/favorites/GetFavoritesCoreTests.java | 7 +++++-- .../rest/people/DeleteFavoriteSiteSanityTests.java | 1 - .../alfresco/rest/people/GetSiteMembershipCoreTests.java | 1 - .../alfresco/rest/workflow/tasks/GetTasksCoreTests.java | 7 ------- 5 files changed, 5 insertions(+), 12 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java index cc6838009..5ec6167e1 100644 --- a/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java @@ -11,7 +11,6 @@ import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesCoreTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesCoreTests.java index 5585e77f1..9cb4503c8 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesCoreTests.java @@ -6,8 +6,11 @@ import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestPersonFavoritesModelsCollection; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; -import org.alfresco.utility.model.*; -import org.alfresco.utility.report.Bug; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java index 7eb61bbc8..773db9048 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java @@ -6,7 +6,6 @@ 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.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipCoreTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipCoreTests.java index d867acfd1..9ccb41f7d 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipCoreTests.java @@ -8,7 +8,6 @@ import org.alfresco.utility.data.DataUser; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksCoreTests.java index da3b9651d..f60f151ee 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksCoreTests.java @@ -1,12 +1,8 @@ package org.alfresco.rest.workflow.tasks; -import java.util.ArrayList; -import java.util.List; - import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.CMISUtil.Priority; import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestTaskModel; import org.alfresco.rest.model.RestTaskModelsCollection; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; @@ -15,12 +11,9 @@ import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; -import org.testng.Assert; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import com.google.common.collect.Ordering; - public class GetTasksCoreTests extends RestTest { UserModel userModel, userNotInvolved, candidateUser, assigneeUser, adminUser; From c4e330e15ba0f46c47e60fd8ebae0bd705a3d61d Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Tue, 17 Jan 2017 14:59:46 +0200 Subject: [PATCH 0873/1491] fixed one test --- .../rest/people/GetSiteMembershipRequestsFullTests.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsFullTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsFullTests.java index 59bcf2b5a..904d653ad 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsFullTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsFullTests.java @@ -99,12 +99,14 @@ public class GetSiteMembershipRequestsFullTests extends RestTest .assertThat().entriesListContains("id", moderatedSite2.getId()); RestSiteMembershipRequestModel firstSiteMembershipRequest = siteMembershipRequests.getEntries().get(0).onModel(); + RestSiteMembershipRequestModel secondSiteMembershipRequest = siteMembershipRequests.getEntries().get(1).onModel(); siteMembershipRequests = restClient.authenticateUser(newMember).withParams("orderBy=id ASC&skipCount=1").withCoreAPI() .usingMe().getSiteMembershipRequests(); restClient.assertStatusCodeIs(HttpStatus.OK); siteMembershipRequests.assertThat().entriesListDoesNotContain("id", firstSiteMembershipRequest.getId()) - .assertThat().entriesListContains("id", moderatedSite2.getId()); + .assertThat().entriesListContains("id", secondSiteMembershipRequest.getId()) + .assertThat().entriesListContains("id", secondSiteMembershipRequest.getSite().getId()); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) From 791695ae30da01a8aab1e4d0b340f12e7e69e345 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Tue, 17 Jan 2017 15:36:49 +0200 Subject: [PATCH 0874/1491] Added DeleteSiteMember full tests --- .../people/DeleteSiteMemberFullTests.java | 229 ++++++++++++++++++ 1 file changed, 229 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberFullTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberFullTests.java new file mode 100644 index 000000000..57622380c --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberFullTests.java @@ -0,0 +1,229 @@ +package org.alfresco.rest.people; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +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.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class DeleteSiteMemberFullTests extends RestTest +{ + private SiteModel publicSiteModel; + private SiteModel moderatedSiteModel; + private SiteModel privateSiteModel; + private UserModel adminUserModel; + private ListUserWithRoles usersWithRolesPublicSite; + private ListUserWithRoles usersWithRolesModeratedSite; + private ListUserWithRoles usersWithRolesPrivateSite; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + adminUserModel.setUserRole(UserRole.SiteManager); + publicSiteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + moderatedSiteModel = dataSite.usingUser(adminUserModel).createModeratedRandomSite(); + privateSiteModel = dataSite.usingUser(adminUserModel).createPrivateRandomSite(); + + usersWithRolesPublicSite = dataUser.addUsersWithRolesToSite(publicSiteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + usersWithRolesModeratedSite = dataUser.addUsersWithRolesToSite(moderatedSiteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + usersWithRolesPrivateSite = dataUser.addUsersWithRolesToSite(privateSiteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove collaborator member of a public site") + public void adminIsAbleToRemoveCollaboratorSiteMembershipFromPublicSite() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteCollaborator)).deleteSiteMember(publicSiteModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteCollaborator)); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove contributor member of a public site") + public void adminIsAbleToRemoveContributorSiteMembershipFromPublicSite() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteContributor)).deleteSiteMember(publicSiteModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteContributor)); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove consumer member of a public site") + public void adminIsAbleToRemoveConsumerSiteMembershipFromPublicSite() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteConsumer)).deleteSiteMember(publicSiteModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteConsumer)); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove contributor member of a public site and response is 422") + public void userIsNotAbleToRemoveContributorSiteMembershipFromPublicSite() throws Exception + { + restClient.authenticateUser(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingUser(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteContributor)).deleteSiteMember(publicSiteModel); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() + .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove consumer member of a public site and response is 422") + public void userIsNotAbleToRemoveConsumerSiteMembershipFromPublicSite() throws Exception + { + restClient.authenticateUser(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingUser(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteConsumer)).deleteSiteMember(publicSiteModel); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() + .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove collaborator member of a moderated site") + public void adminIsAbleToRemoveCollaboratorSiteMembershipFromModeratedSite() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(usersWithRolesModeratedSite.getOneUserWithRole(UserRole.SiteCollaborator)).deleteSiteMember(moderatedSiteModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(usersWithRolesModeratedSite.getOneUserWithRole(UserRole.SiteCollaborator)); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove contributor member of a moderated site") + public void adminIsAbleToRemoveContributorSiteMembershipFromModeratedSite() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(usersWithRolesModeratedSite.getOneUserWithRole(UserRole.SiteContributor)).deleteSiteMember(moderatedSiteModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(usersWithRolesModeratedSite.getOneUserWithRole(UserRole.SiteContributor)); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove consumer member of a moderated site") + public void adminIsAbleToRemoveConsumerSiteMembershipFromModeratedSite() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(usersWithRolesModeratedSite.getOneUserWithRole(UserRole.SiteConsumer)).deleteSiteMember(moderatedSiteModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(usersWithRolesModeratedSite.getOneUserWithRole(UserRole.SiteConsumer)); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove contributor member of a moderated site and response is 422") + public void userIsNotAbleToRemoveContributorSiteMembershipFromModeratedSite() throws Exception + { + restClient.authenticateUser(usersWithRolesModeratedSite.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingUser(usersWithRolesModeratedSite.getOneUserWithRole(UserRole.SiteContributor)).deleteSiteMember(moderatedSiteModel); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() + .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, moderatedSiteModel.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove consumer member of a moderated site and response is 422") + public void userIsNotAbleToRemoveConsumerSiteMembershipFromModeratedSite() throws Exception + { + restClient.authenticateUser(usersWithRolesModeratedSite.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingUser(usersWithRolesModeratedSite.getOneUserWithRole(UserRole.SiteConsumer)).deleteSiteMember(moderatedSiteModel); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() + .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, moderatedSiteModel.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove collaborator member of a private site") + public void adminIsAbleToRemoveCollaboratorSiteMembershipFromPrivateSite() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(usersWithRolesPrivateSite.getOneUserWithRole(UserRole.SiteCollaborator)).deleteSiteMember(privateSiteModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(usersWithRolesPrivateSite.getOneUserWithRole(UserRole.SiteCollaborator)); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove contributor member of a private site") + public void adminIsAbleToRemoveContributorSiteMembershipFromPrivateSite() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(usersWithRolesPrivateSite.getOneUserWithRole(UserRole.SiteContributor)).deleteSiteMember(privateSiteModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(usersWithRolesPrivateSite.getOneUserWithRole(UserRole.SiteContributor)); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove consumer member of a private site") + public void adminIsAbleToRemoveConsumerSiteMembershipFromPrivateSite() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(usersWithRolesPrivateSite.getOneUserWithRole(UserRole.SiteConsumer)).deleteSiteMember(privateSiteModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(usersWithRolesPrivateSite.getOneUserWithRole(UserRole.SiteConsumer)); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove contributor member of a private site and response is 422") + public void userIsNotAbleToRemoveContributorSiteMembershipFromPrivateSite() throws Exception + { + restClient.authenticateUser(usersWithRolesPrivateSite.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingUser(usersWithRolesPrivateSite.getOneUserWithRole(UserRole.SiteContributor)).deleteSiteMember(privateSiteModel); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() + .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, privateSiteModel.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove consumer member of a private site and response is 422") + public void userIsNotAbleToRemoveConsumerSiteMembershipFromPrivateSite() throws Exception + { + restClient.authenticateUser(usersWithRolesPrivateSite.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingUser(usersWithRolesPrivateSite.getOneUserWithRole(UserRole.SiteConsumer)).deleteSiteMember(privateSiteModel); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() + .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, privateSiteModel.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is not able to remove same user twice and response is 400") + @Bug(id="ACE-5447") + public void adminIsNotAbleToRemoveSameUserTwice() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteCollaborator)).deleteSiteMember(publicSiteModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteCollaborator)).deleteSiteMember(publicSiteModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(RestErrorModel.ENTITY_NOT_FOUND); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteCollaborator)); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify single manager is not able to delete himself and response is 400") + public void lastManagerIsNotAbleToDeleteHimself() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteManager)).deleteSiteMember(publicSiteModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withCoreAPI().usingUser(adminUserModel).deleteSiteMember(publicSiteModel); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsSummary(String.format(RestErrorModel.DELETE_LAST_MANAGER, publicSiteModel.getTitle())) + .containsErrorKey(String.format(RestErrorModel.DELETE_LAST_MANAGER, publicSiteModel.getTitle())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + + restClient.withCoreAPI().usingSite(publicSiteModel).addPerson(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteManager)); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site creator can be deleted") + public void siteCreatorCanBeDeleted() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).deleteSiteMember(publicSiteModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.authenticateUser(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingSite(publicSiteModel).addPerson(adminUserModel); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is not able to remove from site a user that created a member request that was not accepted yet") + public void adminIsNotAbleToRemoveFromSiteANonExistingMember() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(publicSiteModel); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(newMember).deleteSiteMember(publicSiteModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.authenticateUser(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingSite(publicSiteModel).addPerson(adminUserModel); + } + +} From cc4b2be18422339b616ecc017e3652ba59a3da18 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Mon, 16 Jan 2017 17:40:09 +0200 Subject: [PATCH 0875/1491] fixed tests failed in Jenkins --- .../rest/people/GetFavoriteSitesFullTests.java | 3 ++- .../rest/people/GetPeopleActivitiesFullTests.java | 15 ++++++--------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesFullTests.java b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesFullTests.java index 63e26b989..76df72a97 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesFullTests.java @@ -143,7 +143,8 @@ public class GetFavoriteSitesFullTests extends RestTest RestSiteModel restSiteModel = restClient.authenticateUser(userModel).withParams("properties=title") .withCoreAPI().usingAuthUser().getFavoriteSites().getOneRandomEntry().onModel(); restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModel.assertThat().fieldsCount().is(1); + restSiteModel.assertThat().fieldsCount().is(1) + .assertThat().field("title").isNotEmpty(); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesFullTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesFullTests.java index 4c885320c..3725f1a3a 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesFullTests.java @@ -82,17 +82,14 @@ public class GetPeopleActivitiesFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify activity summary from user gets activities response with Rest API") public void userGetPeopleActivitiesWithActivitySummaryCheck() throws Exception { - restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingMe().getPersonActivities(); + restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingMe().usingParams(String.format("siteId=%s", siteModel1.getId())).getPersonActivities(); restClient.assertStatusCodeIs(HttpStatus.OK); - restActivityModelsCollection.assertThat().paginationField("count").is("4"); + restActivityModelsCollection.assertThat().paginationField("count").is("1"); RestActivitySummaryModel summary = restActivityModelsCollection.getEntries().get(0).onModel().getActivitySummary(); - summary.assertThat().field("firstName").is(managerUser.getUsername() + " FirstName") - .and().field("lastName").is("LN-" + managerUser.getUsername()) - .and().field("memberFirstName").is(managerUser.getUsername() + " FirstName") - .and().field("role").is(managerUser.getUserRole()) - .and().field("memberLastName").is("LN-" + managerUser.getUsername()) - .and().field("title").is(String.format("%s FirstName LN-%s (%s)", managerUser.getUsername(), managerUser.getUsername(), managerUser.getUsername())) - .and().field("memberPersonId").is(managerUser.getUsername()); + summary.assertThat().field("firstName").is(userModel.getUsername() + " FirstName") + .and().field("lastName").is("LN-" + userModel.getUsername()) + .and().field("title").is(fileInSite1.getName()) + .and().field("objectId").is(fileInSite1.getNodeRefWithoutVersion()); } @Bug(id = "ACE-5460") From 72ec26c496dcec489d7edb1ef0dcb1f81420610b Mon Sep 17 00:00:00 2001 From: Andrei Rusu Date: Tue, 17 Jan 2017 16:44:49 +0200 Subject: [PATCH 0876/1491] added tests for AddTagFullTests --- .../alfresco/rest/tags/AddTagFullTests.java | 175 ++++++++++++++++++ 1 file changed, 175 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/tags/AddTagFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/tags/AddTagFullTests.java b/e2e-test/java/org/alfresco/rest/tags/AddTagFullTests.java new file mode 100644 index 000000000..de374c063 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/tags/AddTagFullTests.java @@ -0,0 +1,175 @@ +package org.alfresco.rest.tags; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestCommentModel; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestTagModel; +import org.alfresco.rest.model.RestTagModelsCollection; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.data.RandomData; +import org.alfresco.utility.exception.DataPreparationException; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +public class AddTagFullTests extends RestTest +{ + private UserModel adminUserModel; + private SiteModel siteModel; + private DataUser.ListUserWithRoles usersWithRoles; + private String tagValue; + private RestTagModel returnedModel; + private RestCommentModel returnedModelComment; + private RestTagModelsCollection returnedModelTags; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws DataPreparationException + { + adminUserModel = dataUser.getAdminUser(); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + } + + @BeforeMethod(alwaysRun = true) + public void generateRandomTag() throws DataPreparationException, Exception + { + tagValue = RandomData.getRandomName("tag"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that contributor is able to tag a folder created by self") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) + public void contributorIsAbleToTagAFolderCreatedBySelf() throws JsonToModelConversionException, Exception + { + FolderModel folderModel = dataContent.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingSite(siteModel).createFolder(); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + returnedModel = restClient.withCoreAPI().usingResource(folderModel).addTag(tagValue); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedModel.assertThat().field("tag").is(tagValue).and().field("id").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that collaborator is able to tag a folder") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) + public void collaboratorIsAbleToTagAFolder() throws JsonToModelConversionException, Exception + { + FolderModel folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + returnedModel = restClient.withCoreAPI().usingResource(folderModel).addTag(tagValue); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedModel.assertThat().field("tag").is(tagValue).and().field("id").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that consumer is not able to tag a folder. Check default error model schema.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) + public void consumerIsNotAbleToTagAFolder() throws JsonToModelConversionException, Exception + { + FolderModel folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + .withCoreAPI().usingResource(folderModel).addTag(tagValue); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that tagged folder can be tagged again") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) + public void addTagToATaggedFolder() throws JsonToModelConversionException, Exception + { + FolderModel folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + + returnedModel = restClient.withCoreAPI().usingResource(folderModel).addTag(tagValue); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedModel.assertThat().field("tag").is(tagValue).and().field("id").isNotEmpty(); + + returnedModel = restClient.withCoreAPI().usingResource(folderModel).addTag("random_tag_value"); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedModel.assertThat().field("tag").is("random_tag_value").and().field("id").isNotEmpty(); + + restClient.withCoreAPI().usingResource(folderModel).getNodeTags().assertThat() + .entriesListContains("tag", tagValue.toLowerCase()) + .and().entriesListContains("tag", "random_tag_value") + .and().entriesListCountIs(2); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Using collaborator provide more than one tag element") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) + public void provideMoreThanOneTagElement() throws JsonToModelConversionException, Exception + { + FolderModel folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); + String tagValue1 = RandomData.getRandomName("tag1"); + String tagValue2 = RandomData.getRandomName("tag2"); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + + returnedModelTags = restClient.withCoreAPI().usingResource(folderModel).addTags(tagValue, tagValue1, tagValue2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedModelTags.assertThat().entriesListContains("tag", tagValue) + .and().entriesListContains("tag", tagValue1) + .and().entriesListContains("tag", tagValue2) + .and().entriesListCountIs(3); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that manager cannot add tag with special characters.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) + public void addTagWithSpecialCharacters() throws JsonToModelConversionException, Exception + { + FolderModel folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); + String specialCharsTag = "!@#$%^&*()'\".,<>-_+=|\\"; + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(folderModel).addTag(specialCharsTag); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_TAG, "|")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that you cannot tag a comment and it returns status code 405") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) + public void addTagToAComment() throws JsonToModelConversionException, Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + String comment = "comment for a tag"; + + restClient.authenticateUser(adminUserModel); + returnedModelComment = restClient.withCoreAPI().usingResource(file).addComment(comment); + file.setNodeRef(returnedModelComment.getId()); + restClient.withCoreAPI().usingResource(file).addTag(tagValue); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.CANNOT_TAG); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that you cannot tag a tag and it returns status code 405") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) + public void addTagToATag() throws JsonToModelConversionException, Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(adminUserModel); + returnedModel = restClient.withCoreAPI().usingResource(file).addTag(tagValue); + file.setNodeRef(returnedModel.getId()); + restClient.withCoreAPI().usingResource(file).addTag(tagValue); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.CANNOT_TAG); + } +} From c050ba0650d32a860fa38b5f74741c2a36dca3de Mon Sep 17 00:00:00 2001 From: mionescu Date: Tue, 17 Jan 2017 16:54:14 +0200 Subject: [PATCH 0877/1491] core - added enum: RATING_OUT_OF_BOUNDS test - updated test cases in 'AddRatingCoreTests', added new test for full suite: AddRatingCoreTests --- .../rest/ratings/AddRatingCoreTests.java | 24 +- .../rest/ratings/AddRatingFullTests.java | 517 ++++++++++++++++++ 2 files changed, 536 insertions(+), 5 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/ratings/AddRatingFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/ratings/AddRatingCoreTests.java b/e2e-test/java/org/alfresco/rest/ratings/AddRatingCoreTests.java index fcb87765f..c2fe21051 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/AddRatingCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/AddRatingCoreTests.java @@ -50,7 +50,12 @@ public class AddRatingCoreTests extends RestTest FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"invalidRate\"}"); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_RATING, "invalidRate")); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsSummary(String.format(RestErrorModel.INVALID_RATING, "invalidRate")) + .containsErrorKey(String.format(RestErrorModel.INVALID_RATING, "invalidRate")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); } @TestRail(section = { TestGroup.REST_API, @@ -63,8 +68,12 @@ public class AddRatingCoreTests extends RestTest document.setNodeRef(RandomStringUtils.randomAlphanumeric(10)); restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, document.getNodeRef())); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, document.getNodeRef())) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); } @TestRail(section = { TestGroup.REST_API, @@ -223,8 +232,13 @@ public class AddRatingCoreTests extends RestTest document.setNodeRef(comment.getId()); restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(String.format(RestErrorModel.CANNOT_RATE)); - + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) + .assertLastError() + .containsSummary(String.format(RestErrorModel.CANNOT_RATE)) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).rateStarsToDocument(5); restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(String.format(RestErrorModel.CANNOT_RATE)); } diff --git a/e2e-test/java/org/alfresco/rest/ratings/AddRatingFullTests.java b/e2e-test/java/org/alfresco/rest/ratings/AddRatingFullTests.java new file mode 100644 index 000000000..5e3beb038 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/ratings/AddRatingFullTests.java @@ -0,0 +1,517 @@ +package org.alfresco.rest.ratings; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestCommentModel; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestRatingModel; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.exception.DataPreparationException; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.apache.commons.lang3.RandomStringUtils; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class AddRatingFullTests extends RestTest +{ + private UserModel userModel; + private SiteModel siteModel; + private UserModel adminUser; + private ListUserWithRoles usersWithRoles; + private RestRatingModel returnedRatingModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws DataPreparationException + { + userModel = dataUser.createUser(RandomStringUtils.randomAlphanumeric(20)); + adminUser = dataUser.getAdminUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that Contributor is able to like a file") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) + public void contributorIsAbleToLikeAFile() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI() + .usingResource(document) + .likeDocument(); + + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedRatingModel.assertThat().field("myRating").is("true") + .and().field("id").is("likes") + .and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that Collaborator is able to like a file") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) + public void collaboratorIsAbleToLikeAFile() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI() + .usingResource(document) + .likeDocument(); + + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedRatingModel.assertThat().field("myRating").is("true") + .and().field("id").is("likes") + .and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that Consumer is able to like a file") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) + public void consumerIsAbleToLikeAFile() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI() + .usingResource(document) + .likeDocument(); + + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedRatingModel.assertThat().field("myRating").is("true") + .and().field("id").is("likes") + .and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that Contributor is able to like a folder") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) + public void contributorIsAbleToLikeAFolder() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI() + .usingResource(folderModel) + .likeDocument(); + + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedRatingModel.assertThat().field("myRating").is("true") + .and().field("id").is("likes") + .and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that Collaborator is able to like a folder") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) + public void collaboratorIsAbleToLikeAFolder() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI() + .usingResource(folderModel) + .likeDocument(); + + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedRatingModel.assertThat().field("myRating").is("true") + .and().field("id").is("likes") + .and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that Consumer is able to like a folder") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) + public void consumerIsAbleToLikeAFolder() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI() + .usingResource(folderModel) + .likeDocument(); + + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedRatingModel.assertThat().field("myRating").is("true") + .and().field("id").is("likes") + .and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that Contributor is able to rate a file") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) + public void contributorIsAbleToRateAFile() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI() + .usingResource(document) + .rateStarsToDocument(5); + + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedRatingModel.assertThat().field("myRating").is("5") + .and().field("id").is("fiveStar") + .and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that Collaborator is able to rate a file") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) + public void collaboratorIsAbleToRateAFile() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI() + .usingResource(document) + .rateStarsToDocument(5); + + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedRatingModel.assertThat().field("myRating").is("5") + .and().field("id").is("fiveStar") + .and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that Consumer is able to rate a file") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) + public void consumerIsAbleToRateAFile() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI() + .usingResource(document) + .rateStarsToDocument(5); + + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedRatingModel.assertThat().field("myRating").is("5") + .and().field("id").is("fiveStar") + .and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that Contributor is able to rate a folder") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) + public void contributorIsAbleToRateAFolder() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI() + .usingResource(folderModel) + .rateStarsToDocument(5); + + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedRatingModel.assertThat().field("myRating").is("5") + .and().field("id").is("fiveStar") + .and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that Collaborator is able to rate a folder") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) + public void collaboratorIsAbleToRateAFolder() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI() + .usingResource(folderModel) + .rateStarsToDocument(5); + + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedRatingModel.assertThat().field("myRating").is("5") + .and().field("id").is("fiveStar") + .and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that Consumer is able to rate a folder") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) + public void consumerIsAbleToRateAFolder() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI() + .usingResource(folderModel) + .rateStarsToDocument(5); + + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedRatingModel.assertThat().field("myRating").is("5") + .and().field("id").is("fiveStar") + .and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that adding like again has no effect on a folder") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) + public void folderCanBeLikedTwice() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folderModel).likeDocument(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folderModel).likeDocument(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("true") + .and().field("id").is("likes") + .and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that adding rate again has no effect on a folder") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) + public void folderCanBeRatedTwice() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folderModel).rateStarsToDocument(5); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folderModel).rateStarsToDocument(5); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("5") + .and().field("id").is("fiveStar") + .and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that if invalid rate id is provided status code is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) + public void addRateUsingInvalidValueForId() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"like\"}"); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsSummary(String.format(RestErrorModel.INVALID_RATING, "like")) + .containsErrorKey(String.format(RestErrorModel.INVALID_RATING, "like")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that rate id is case sensitive is provided status code is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) + public void addRateUsingInvalidValueForIdCaseSensitive() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"Likes\"}"); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsSummary(String.format(RestErrorModel.INVALID_RATING, "Likes")) + .containsErrorKey(String.format(RestErrorModel.INVALID_RATING, "Likes")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"FiveStar\"}"); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsSummary(String.format(RestErrorModel.INVALID_RATING, "FiveStar")) + .containsErrorKey(String.format(RestErrorModel.INVALID_RATING, "FiveStar")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that if invalid rating is provided status code is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) + public void addRateUsingInvalidValueForMyRating() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"likes\", \"myRating\":\"skiped\"}"); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsSummary(String.format(RestErrorModel.NULL_LIKE_RATING)); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"fiveStar\", \"myRating\":\"string\"}"); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsSummary(String.format(RestErrorModel.NULL_FIVESTAR_RATING)); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Like file created by a different user") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) + public void addLikeToAnotherUserFile() throws Exception + { + UserModel user = dataUser.usingAdmin().createRandomTestUser(); + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + returnedRatingModel = restClient.authenticateUser(user).withCoreAPI().usingResource(document).likeDocument(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedRatingModel.assertThat().field("myRating").is("true") + .and().field("id").is("likes") + .and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Rate a file created by a different user") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) + public void addRatingToAnotherUserFile() throws Exception + { + UserModel user = dataUser.usingAdmin().createRandomTestUser(); + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + returnedRatingModel = restClient.authenticateUser(user).withCoreAPI().usingResource(document).rateStarsToDocument(5); + returnedRatingModel.assertThat().field("myRating").is("5") + .and().field("id").is("fiveStar") + .and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Add Rate Using Boolean Value For 'myRating'") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) + public void addRateUsingBooleanValueForMyRating() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"fiveStar\", \"myRating\":\"true\"}"); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsSummary(RestErrorModel.NULL_FIVESTAR_RATING) + .containsErrorKey(RestErrorModel.NULL_FIVESTAR_RATING) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Add Like Using Integer Value For 'myRating'") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) + public void addLikeUsingIntegerValueForMyRating() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"likes\", \"myRating\":\"2\"}"); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsSummary(RestErrorModel.NULL_LIKE_RATING) + .containsErrorKey(RestErrorModel.NULL_LIKE_RATING) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that user is not able to like his own comment") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) + public void userCannotLikeHisOwnComment() throws Exception + { + UserModel user = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); + FolderModel folderModel = dataContent.usingUser(user).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(user).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + RestCommentModel comment = restClient.authenticateUser(user).withCoreAPI().usingResource(document).addComment("This is a comment"); + document.setNodeRef(comment.getId()); + + returnedRatingModel = restClient.authenticateUser(user).withCoreAPI().usingResource(document).likeDocument(); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) + .assertLastError() + .containsSummary(String.format(RestErrorModel.CANNOT_RATE)) + .containsErrorKey(RestErrorModel.CANNOT_RATE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER).stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that user is not able to rate his own comment") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) + public void userCannotRateHisOwnComment() throws Exception + { + UserModel user = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); + FolderModel folderModel = dataContent.usingUser(user).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(user).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + RestCommentModel comment = restClient.authenticateUser(user).withCoreAPI().usingResource(document).addComment("This is a comment"); + document.setNodeRef(comment.getId()); + + returnedRatingModel = restClient.authenticateUser(user).withCoreAPI().usingResource(document).rateStarsToDocument(5); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) + .assertLastError() + .containsSummary(String.format(RestErrorModel.CANNOT_RATE)) + .containsErrorKey(RestErrorModel.CANNOT_RATE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that Collaborator is NOT able to add a negative rating to a file") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) + public void collaboratorIsNotAbleToAddANegativeRatingToAFile() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI() + .usingResource(document) + .rateStarsToDocument(-5); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsSummary(RestErrorModel.RATING_OUT_OF_BOUNDS) + .containsErrorKey(RestErrorModel.RATING_OUT_OF_BOUNDS) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that Collaborator is NOT able to add a high rating to a file") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) + public void contributorIsNotAbleToAddANegativeRatingToAFile() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI() + .usingResource(document) + .rateStarsToDocument(10); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsSummary(RestErrorModel.RATING_OUT_OF_BOUNDS) + .containsErrorKey(RestErrorModel.RATING_OUT_OF_BOUNDS) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Do not provide field - 'id'") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) + public void notProvideIdLikeFile() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"\":\"likes\", \"myRating\":\"2\"}"); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsSummary(String.format(RestErrorModel.NO_CONTENT, "Unrecognized field \"\"")) + .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "Unrecognized field \"\"")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Do not provide field - 'myRating'") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) + public void notProvideMyRatingRateFile() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"likes\", \"\":\"2\"}"); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsSummary(String.format(RestErrorModel.NO_CONTENT, "Unrecognized field \"\"")) + .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "Unrecognized field \"\"")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } +} From 2aac94ca91896443544b2fe275432c71bbfec4a1 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Tue, 17 Jan 2017 18:16:13 +0200 Subject: [PATCH 0878/1491] added full tests for getSiteContainers --- .../sites/GetSiteContainersCoreTests.java | 24 ++-- .../sites/GetSiteContainersFullTests.java | 129 ++++++++++++++++++ 2 files changed, 141 insertions(+), 12 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/sites/GetSiteContainersFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersCoreTests.java index 298b37c78..70aefbb9b 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersCoreTests.java @@ -50,7 +50,7 @@ public class GetSiteContainersCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if get site container request returns status code 200 with valid maxItems parameter") public void getContainersWithValidMaxItems() throws Exception { @@ -75,7 +75,7 @@ public class GetSiteContainersCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if get site container request returns status code 400 when invalid maxItems parameter is used") public void getContainersWithMaxItemsZero () throws Exception { @@ -87,7 +87,7 @@ public class GetSiteContainersCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if get site container request returns status code 400 when invalid maxItems parameter is used") public void getContainersWithMaxItemsCharacter () throws Exception { @@ -99,7 +99,7 @@ public class GetSiteContainersCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if get site container request returns status code 200 when maxItems parameter starts with multiple zero") public void getContainersWithMaxItemsMultipleZero () throws Exception { @@ -111,7 +111,7 @@ public class GetSiteContainersCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if get site containers request returns status code 200 when valid skipCount parameter is used") public void getSiteContainersWithValidSkipCount() throws Exception { @@ -137,7 +137,7 @@ public class GetSiteContainersCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if get site containers request returns status code 400 when invalid skipCount parameter is used") public void getSiteContainersWithSkipCountCharacter() throws Exception { @@ -148,7 +148,7 @@ public class GetSiteContainersCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if get site containers request returns status code 200 when skipCount parameter starts with multiple zero") public void getSiteContainersWithSkipCountMultipleZero() throws Exception { @@ -159,7 +159,7 @@ public class GetSiteContainersCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if get site containers request returns status code 400 when site doesn't exist") public void getSiteContainersWithNonExistentSite() throws Exception { @@ -170,7 +170,7 @@ public class GetSiteContainersCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify get site containers request returns status 200 for private site") public void getSiteContainersForPrivateSite() throws Exception { @@ -181,7 +181,7 @@ public class GetSiteContainersCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify get site containers request returns status 200 for moderated site") public void getSiteContainersForModeratedSite() throws Exception { @@ -192,7 +192,7 @@ public class GetSiteContainersCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify get site containers request returns status 200 for several containers") public void getSiteContainersForSeveralItems() throws Exception { @@ -206,7 +206,7 @@ public class GetSiteContainersCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify get site containers request returns status 200 for one container") public void getSiteContainersWithOneItem() throws Exception { diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersFullTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersFullTests.java new file mode 100644 index 000000000..57baa59a3 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersFullTests.java @@ -0,0 +1,129 @@ +package org.alfresco.rest.sites; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestSiteContainerModelsCollection; +import org.alfresco.utility.constants.ContainerName; +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.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 Cristina Axinte + * + */ +public class GetSiteContainersFullTests extends RestTest +{ + private SiteModel publicSiteWithContainers; + private ListUserWithRoles publicSiteWithContainersUsers; + RestSiteContainerModelsCollection restSiteContainers; + int totalItems; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + publicSiteWithContainers = dataSite.usingAdmin().createPublicRandomSite(); + + publicSiteWithContainersUsers = dataUser + .addUsersWithRolesToSite(publicSiteWithContainers, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + + dataLink.usingAdmin().usingSite(publicSiteWithContainers).createRandomLink(); + dataDiscussion.usingAdmin().usingSite(publicSiteWithContainers).createRandomDiscussion(); + dataContent.usingAdmin().usingSite(publicSiteWithContainers).createFolder(); + + restSiteContainers = restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers(); + totalItems = restSiteContainers.getPagination().getTotalItems(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if get site container request for a container that is not empty returns status code 200") + public void getSiteContainersThatIsNotEmpty() throws Exception + { + restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() + .assertThat().entriesListCountIs(3) + .and().entriesListContains("folderId" ,ContainerName.documentLibrary.toString()); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if get site containers request returns status code 200 when first container is skipped") + public void getSiteContainersAndSkipFirst() throws Exception + { + restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteCollaborator)) + .withParams("skipCount=1").withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() + .assertThat().entriesListCountIs(2) + .and().entriesListDoesNotContain("folderId" , restSiteContainers.getEntries().get(0).onModel().getFolderId()) + .and().entriesListContains("folderId" , restSiteContainers.getEntries().get(1).onModel().getFolderId()) + .and().entriesListContains("folderId" , restSiteContainers.getEntries().get(2).onModel().getFolderId()); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if get site containers request and get last container returns status code 200") + public void getLastSiteContainer() throws Exception + { + restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteCollaborator)) + .withParams("skipCount=" + String.valueOf(totalItems-1)).withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() + .assertThat().entriesListCountIs(1) + .and().entriesListDoesNotContain("folderId" , restSiteContainers.getEntries().get(0).onModel().getFolderId()) + .and().entriesListDoesNotContain("folderId" , restSiteContainers.getEntries().get(1).onModel().getFolderId()) + .and().entriesListContains("folderId" , restSiteContainers.getEntries().get(2).onModel().getFolderId()); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if get site containers request returns status code 200 when high skipCount parameter is used") + public void getSiteContainersWithHighSkipCount() throws Exception + { + restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteCollaborator)) + .withParams("skipCount=999999").withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() + .assertThat().entriesListIsEmpty() + .and().entriesListCountIs(0) + .and().paginationField("skipCount").is("999999"); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if get site container request for a empty siteId returns status code 404") + public void getSiteContainersForEmptySiteId() throws Exception + { + restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingSite("").getSiteContainers(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if get site container request returns status code 200 with valid maxItems parameter") + public void getContainersWithValidMaxItems() throws Exception + { + restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteManager)) + .withParams("maxItems=2").withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() + .assertThat().entriesListCountIs(2) + .getPagination().assertThat().field("count").is("2") + .and().field("hasMoreItems").is("true") + .and().field("totalItems").is("3") + .and().field("skipCount").is("0") + .and().field("maxItems").is("2"); + restClient.assertStatusCodeIs(HttpStatus.OK); + } +} From ad3015c4825a050fdd3cd3d36f8b2adcb67dd4ce Mon Sep 17 00:00:00 2001 From: mionescu Date: Wed, 18 Jan 2017 10:48:40 +0200 Subject: [PATCH 0879/1491] test- added class: DeleteSiteMembershipRequestFullTests.java --- .../DeleteSiteMembershipRequestFullTests.java | 169 ++++++++++++++++++ 1 file changed, 169 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestFullTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestFullTests.java new file mode 100644 index 000000000..4f4fb107e --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestFullTests.java @@ -0,0 +1,169 @@ +package org.alfresco.rest.people; + +import org.alfresco.dataprep.WorkflowService; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestSiteMembershipRequestModelsCollection; +import org.alfresco.rest.model.RestTaskModel; +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.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class DeleteSiteMembershipRequestFullTests extends RestTest +{ + SiteModel moderatedSite, publicSite, secondModeratedSite; + UserModel adminUserModel, siteMember, secondSiteMember; + RestSiteMembershipRequestModelsCollection siteMembershipRequests; + + @Autowired + WorkflowService workflow; + private ListUserWithRoles usersWithRoles; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + moderatedSite = dataSite.usingUser(adminUserModel).createModeratedRandomSite(); + adminUserModel = dataUser.getAdminUser(); + siteMember = dataUser.createRandomTestUser(); + secondSiteMember = dataUser.createRandomTestUser(); + secondModeratedSite = dataSite.usingUser(siteMember).createModeratedRandomSite(); + publicSite = dataSite.usingUser(siteMember).createPublicRandomSite(); + + usersWithRoles = dataUser.addUsersWithRolesToSite(moderatedSite, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify COLLABORATOR is able to remove/cancel a site memebership request of admin to a moderated site and response is 204") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + public void collaboratorUserIsAbleToCancelSiteMembershipRequestOfAnotherUserToAModeratedSite() throws JsonToModelConversionException, + DataPreparationException, Exception + { + UserModel user = dataUser.createRandomTestUser(); + UserModel userCollaborator = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); + moderatedSite = dataSite.usingUser(userCollaborator).createModeratedRandomSite(); + + restClient.authenticateUser(user).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + restClient.authenticateUser(userCollaborator).withCoreAPI().usingUser(user).getSiteMembershipRequest(moderatedSite).assertThat().field("id") + .is(moderatedSite.getId()); + + restClient.authenticateUser(userCollaborator).withCoreAPI().usingUser(user).deleteSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingUser(user).getSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, user.getUsername(), moderatedSite.getTitle())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify CONTRIBUTOR is able to remove/cancel a site memebership request of admin to a moderated site and response is 204") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + public void contributorUserIsAbleToCancelSiteMembershipRequestOfAnotherUserToAModeratedSite() throws JsonToModelConversionException, + DataPreparationException, Exception + { + UserModel user = dataUser.createRandomTestUser(); + UserModel userContributor = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); + moderatedSite = dataSite.usingUser(userContributor).createModeratedRandomSite(); + + restClient.authenticateUser(user).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + restClient.authenticateUser(userContributor).withCoreAPI().usingUser(user).getSiteMembershipRequest(moderatedSite).assertThat().field("id") + .is(moderatedSite.getId()); + + restClient.authenticateUser(userContributor).withCoreAPI().usingUser(user).deleteSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingUser(user).getSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, user.getUsername(), moderatedSite.getTitle())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify CONSUMER is able to remove/cancel a site memebership request of admin to a moderated site and response is 204") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + public void consumerUserIsAbleToCancelSiteMembershipRequestOfAnotherUserToAModeratedSite() throws JsonToModelConversionException, DataPreparationException, + Exception + { + UserModel user = dataUser.createRandomTestUser(); + UserModel userConsumer = usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer); + moderatedSite = dataSite.usingUser(userConsumer).createModeratedRandomSite(); + + restClient.authenticateUser(user).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + restClient.authenticateUser(userConsumer).withCoreAPI().usingUser(user).getSiteMembershipRequest(moderatedSite).assertThat().field("id") + .is(moderatedSite.getId()); + + restClient.authenticateUser(userConsumer).withCoreAPI().usingUser(user).deleteSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingUser(user).getSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, user.getUsername(), moderatedSite.getTitle())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify user is not able to remove a site memebership request of admin to a public site and response is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + public void regularUserIsNotAbleToDeleteSiteMembershipRequestOfAdminToAPublicSite() throws JsonToModelConversionException, DataPreparationException, + Exception + { + UserModel userCollaborator = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); + restClient.authenticateUser(siteMember).withCoreAPI().usingSite(publicSite).addPerson(userCollaborator); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteMembershipRequest(publicSite); + + restClient.authenticateUser(userCollaborator).withCoreAPI().usingUser(adminUserModel).deleteSiteMembershipRequest(publicSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, adminUserModel.getUsername(), publicSite.getId())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Delete a rejected site membership request.") + public void deleteARejectedSiteMembershipRequest() throws Exception + { + UserModel userWithRejectedRequests = dataUser.createRandomTestUser(); + restClient.authenticateUser(userWithRejectedRequests).withCoreAPI().usingAuthUser().addSiteMembershipRequest(secondModeratedSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestTaskModel taskModel = restClient.authenticateUser(userWithRejectedRequests).withWorkflowAPI().getTasks() + .getTaskModelByDescription(secondModeratedSite); + workflow.approveSiteMembershipRequest(siteMember.getUsername(), siteMember.getPassword(), taskModel.getId(), false, "Rejected"); + + siteMembershipRequests = restClient.authenticateUser(userWithRejectedRequests).withCoreAPI().usingMe().getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembershipRequests.assertThat().entriesListDoesNotContain("id", secondModeratedSite.getId()); + + restClient.authenticateUser(userWithRejectedRequests).withCoreAPI().usingUser(adminUserModel).deleteSiteMembershipRequest(secondModeratedSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, adminUserModel.getUsername(), secondModeratedSite.getId())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + +} From ad45fb6df348fca31e1b8618593c2347fd338041 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Wed, 18 Jan 2017 10:56:38 +0200 Subject: [PATCH 0880/1491] added one full test for call using properties parameter --- .../rest/sites/GetSiteContainersFullTests.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersFullTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersFullTests.java index 57baa59a3..b4f0210d6 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersFullTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersFullTests.java @@ -44,6 +44,21 @@ public class GetSiteContainersFullTests extends RestTest totalItems = restSiteContainers.getPagination().getTotalItems(); } + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if get site container request with properties paramater applied returns status code 200") + public void getSiteContainersUsingPropertiesParameter() throws Exception + { + restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingSite(publicSiteWithContainers).usingParams("properties=folderId").getSiteContainers() + .assertThat().entriesListCountIs(3) + .and().entriesListContains("folderId" ,ContainerName.discussions.toString()) + .and().entriesListContains("folderId" ,ContainerName.documentLibrary.toString()) + .and().entriesListContains("folderId" ,ContainerName.links.toString()) + .and().entriesListDoesNotContain("id"); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if get site container request for a container that is not empty returns status code 200") From 9ec4fcc3b3812231fd06d974ee7e2ccf5fc84445 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Wed, 18 Jan 2017 12:21:23 +0200 Subject: [PATCH 0881/1491] updated: remove sanity, core, full groups from @TestRail --- .../rest/comments/AddCommentsCoreTests.java | 12 ++++----- .../rest/comments/AddCommentsFullTests.java | 12 ++++----- .../rest/comments/GetCommentsCoreTests.java | 14 +++++----- .../rest/comments/GetCommentsFullTests.java | 20 +++++++------- .../rest/comments/UpdateCommentCoreTests.java | 14 ++++------ .../rest/comments/UpdateCommentFullTests.java | 26 +++++++++---------- .../comments/UpdateCommentSanityTests.java | 22 ++++++---------- .../people/DeleteFavoriteSiteFullTests.java | 8 +++--- .../rest/sites/GetSiteContainerCoreTests.java | 10 +++---- .../sites/GetSiteContainersCoreTests.java | 24 ++++++++--------- .../alfresco/rest/sites/GetSiteCoreTests.java | 12 ++++----- .../rest/sites/GetSiteMembersCoreTests.java | 16 ++++++------ .../rest/sites/GetSitesCoreTests.java | 12 ++++----- .../rest/sites/UpdateSiteMemberCoreTests.java | 24 ++++++++--------- 14 files changed, 108 insertions(+), 118 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentsCoreTests.java b/e2e-test/java/org/alfresco/rest/comments/AddCommentsCoreTests.java index e4da2c957..2cdcd2cf3 100644 --- a/e2e-test/java/org/alfresco/rest/comments/AddCommentsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/AddCommentsCoreTests.java @@ -44,7 +44,7 @@ public class AddCommentsCoreTests extends RestTest usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); } - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Verify User can't add comments to a node with ID that does not exist and status code is 404") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) public void userCanNotAddCommentsOnNonexistentFile() throws Exception @@ -57,7 +57,7 @@ public class AddCommentsCoreTests extends RestTest .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, nonexistentFile.getNodeRef())); } - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Verify User can't add comments to a node that exists but is not a document or a folder and status code is 405") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) @Bug(id = "MNT-16904") @@ -73,7 +73,7 @@ public class AddCommentsCoreTests extends RestTest .assertLastError().containsSummary(RestErrorModel.UNABLE_TO_LOCATE); } - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Verify User can add comments with the same content as one existing comment") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) public void userCanAddCommentWithTheSameContentAsExistingOne() throws Exception @@ -97,7 +97,7 @@ public class AddCommentsCoreTests extends RestTest commentsList.get(1).onModel().assertThat().field("content").is(sameComment); } - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Verify User can not add comments to a not joined private site. Status code returned is 403") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) public void userCanNotAddCommentsToANotJoinedPrivateSite() throws Exception @@ -110,7 +110,7 @@ public class AddCommentsCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Verify add comments from node with invalid network id returns status code 401") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) public void addCommentsWithInvalidNetworkId() throws Exception @@ -122,7 +122,7 @@ public class AddCommentsCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Verify add comments from node with empty network id returns status code 401") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) public void addCommentsWithEmptyNetworkId() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentsFullTests.java b/e2e-test/java/org/alfresco/rest/comments/AddCommentsFullTests.java index 87eaff002..58cd1f92a 100644 --- a/e2e-test/java/org/alfresco/rest/comments/AddCommentsFullTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/AddCommentsFullTests.java @@ -43,7 +43,7 @@ public class AddCommentsFullTests extends RestTest usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); } - @TestRail(section={TestGroup.REST_API, TestGroup.FULL, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Using Manager user verify that you can provide a large string for one comment") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) public void addLongCommentsWithManagerAndCheckThatCommentIsReturned() throws Exception @@ -64,7 +64,7 @@ public class AddCommentsFullTests extends RestTest comments.assertThat().paginationField("count").is("2"); } - @TestRail(section={TestGroup.REST_API, TestGroup.FULL, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Using Manager user verify that you can provide a short string for one comment") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) public void addShortCommentsWithManagerAndCheckThatCommentIsReturned() throws Exception @@ -85,7 +85,7 @@ public class AddCommentsFullTests extends RestTest comments.assertThat().paginationField("count").is("2"); } - @TestRail(section={TestGroup.REST_API, TestGroup.FULL, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Using Collaborator user verify that you can provide a string with special characters for one comment") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) public void addCommentsWithSpecialCharsWithCollaboratorCheckCommentIsReturned() throws Exception @@ -106,7 +106,7 @@ public class AddCommentsFullTests extends RestTest comments.assertThat().paginationField("count").is("2"); } - @TestRail(section={TestGroup.REST_API, TestGroup.FULL, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Using Manager user verify that you can not provide an empty string for one comment") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) public void addEmptyStringCommentsWithManagerCheckCommentIsReturned() throws Exception @@ -120,7 +120,7 @@ public class AddCommentsFullTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(RestErrorModel.NON_NULL_COMMENT); } - @TestRail(section={TestGroup.REST_API, TestGroup.FULL, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Using Collaborator user verify that you can provide several comments in one request") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) public void addSeveralCommentsWithCollaboratorCheckCommentsAreReturned() throws Exception @@ -141,7 +141,7 @@ public class AddCommentsFullTests extends RestTest comments.assertThat().paginationField("count").is("5"); } - @TestRail(section={TestGroup.REST_API, TestGroup.FULL, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Provide invalid request body parameter and check default error model schema") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) public void invalidRequestBodyParameterCheckErrorModelSchema() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/comments/GetCommentsCoreTests.java b/e2e-test/java/org/alfresco/rest/comments/GetCommentsCoreTests.java index c018b1f87..0836c3045 100644 --- a/e2e-test/java/org/alfresco/rest/comments/GetCommentsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/GetCommentsCoreTests.java @@ -42,7 +42,7 @@ public class GetCommentsCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.CREATED); } - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Verify invalid request returns status code 400 for invalid maxItems or skipCount") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) public void checkStatusCodeForInvalidMaxItems() throws Exception @@ -53,7 +53,7 @@ public class GetCommentsCoreTests extends RestTest .assertLastError().containsSummary("Only positive values supported for maxItems"); } - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Verify User can't get comments for node with ID that does not exist and status code is 404") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) public void userCanNotGetCommentsOnNonexistentFile() throws Exception @@ -66,7 +66,7 @@ public class GetCommentsCoreTests extends RestTest .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, nonexistentFile.getNodeRef())); } - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Verify User can't get comments for node that exists but is not a document or a folder and status code is 400") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) @Bug(id = "MNT-16904") @@ -81,7 +81,7 @@ public class GetCommentsCoreTests extends RestTest .assertLastError().containsSummary(RestErrorModel.UNABLE_TO_LOCATE); } - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Verify request returns status 403 if the user does not have permission read comments on the node") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) public void uninvitedUserCanNotGetCommentsFromPrivateSite() throws Exception @@ -92,7 +92,7 @@ public class GetCommentsCoreTests extends RestTest .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Verify user gets comments without the first 2 and status code is 200") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) public void skipFirst2Comments() throws Exception @@ -106,7 +106,7 @@ public class GetCommentsCoreTests extends RestTest comments.assertThat().paginationField("totalItems").is("3"); } - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Verify get comments from node with invalid network id returns status code 401") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) public void getCommentsWithInvalidNetwork() throws Exception @@ -116,7 +116,7 @@ public class GetCommentsCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Verify get comments from node with empty network id returns status code 401") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) public void getCommentsWithEmptyNetwork() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/comments/GetCommentsFullTests.java b/e2e-test/java/org/alfresco/rest/comments/GetCommentsFullTests.java index b736d551f..b7021f602 100644 --- a/e2e-test/java/org/alfresco/rest/comments/GetCommentsFullTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/GetCommentsFullTests.java @@ -43,7 +43,7 @@ public class GetCommentsFullTests extends RestTest file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); } - @TestRail(section={TestGroup.REST_API, TestGroup.FULL, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Verify that if manager adds one comment, it will be returned in getComments response") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) public void addCommentWithManagerAndCheckThatCommentIsReturned() throws Exception @@ -58,7 +58,7 @@ public class GetCommentsFullTests extends RestTest .assertThat().field("count").is("1"); } - @TestRail(section={TestGroup.REST_API, TestGroup.FULL, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Verify that if collaborator adds one comment, it will be returned in getComments response") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) public void addCommentWithCollaboratorAndCheckThatCommentIsReturned() throws Exception @@ -74,7 +74,7 @@ public class GetCommentsFullTests extends RestTest .assertThat().field("count").is("1"); } - @TestRail(section={TestGroup.REST_API, TestGroup.FULL, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Verify that if contributor adds one comment, it will be returned in getComments response") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) @Bug(id = "ACE-4614") @@ -91,7 +91,7 @@ public class GetCommentsFullTests extends RestTest .assertThat().field("count").is("1"); } - @TestRail(section={TestGroup.REST_API, TestGroup.FULL, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Verify that consumer cannot add a comment and no comments will be returned in getComments response") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) public void addCommentWithConsumerAndCheckThatCommentIsNotReturned() throws Exception @@ -106,7 +106,7 @@ public class GetCommentsFullTests extends RestTest comments.assertThat().paginationField("count").is("0"); } - @TestRail(section={TestGroup.REST_API, TestGroup.FULL, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Add one comment with Manager and check that returned person is the right one") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) public void addCommentWithManagerCheckReturnedPersonIsTheRightOne() throws Exception @@ -120,7 +120,7 @@ public class GetCommentsFullTests extends RestTest .assertThat().field("lastName").is("LN-" + user1.getUsername()); } - @TestRail(section={TestGroup.REST_API, TestGroup.FULL, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Add one comment with Collaborator and check that returned company details are correct") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) public void addCommentWithCollaboratorCheckReturnedCompanyDetails() throws Exception @@ -140,7 +140,7 @@ public class GetCommentsFullTests extends RestTest .assertThat().field("email").isNull(); } - @TestRail(section={TestGroup.REST_API, TestGroup.FULL, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Add 2 comments with Manager and Collaborator users and verify valid request using skipCount. Check that param is applied") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) public void addTwoCommentsWithManagerCollaboratorVerifySkipCountParamIsApplied() throws Exception @@ -157,7 +157,7 @@ public class GetCommentsFullTests extends RestTest comments.assertThat().paginationField("totalItems").is("2"); } - @TestRail(section={TestGroup.REST_API, TestGroup.FULL, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Add 2 comments with Admin and Collaborator users and verify valid request using maxItems. Check that param is applied") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) public void addTwoCommentsWithAdminCollaboratorVerifyMaxItemsParamIsApplied() throws Exception @@ -173,7 +173,7 @@ public class GetCommentsFullTests extends RestTest comments.assertThat().paginationField("totalItems").is("2"); } - @TestRail(section={TestGroup.REST_API, TestGroup.FULL, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Add 2 comments with Manager and Admin users and verify valid request using properties. Check that param is applied") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) public void addTwoCommentsWithAdminManagerVerifyPropertiesParamIsApplied() throws Exception @@ -196,7 +196,7 @@ public class GetCommentsFullTests extends RestTest .assertThat().field("id").is("admin"); } - @TestRail(section={TestGroup.REST_API, TestGroup.FULL, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Check default error model schema") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) public void addTwoCommentsWithManagerCheckDefaultErrorModelSchema() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentCoreTests.java b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentCoreTests.java index 1625945e8..b84e77039 100644 --- a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentCoreTests.java @@ -41,7 +41,7 @@ public class UpdateCommentCoreTests extends RestTest usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator); } - @TestRail(section = { TestGroup.REST_API, TestGroup.SANITY }, executionType = ExecutionType.REGRESSION, description = "Verify can not update comment if NodeId is neither document or folder and returns status code 405") + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify can not update comment if NodeId is neither document or folder and returns status code 405") @Bug(id="MNT-16904") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) public void canNotUpdateCommentIfNodeIdIsNeitherDocumentOrFolder() throws JsonToModelConversionException, Exception @@ -60,8 +60,7 @@ public class UpdateCommentCoreTests extends RestTest .assertLastError().containsSummary("node ref that does not exist was not found"); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Admin user is not able to update with empty comment body and status code is 400") + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Admin user is not able to update with empty comment body and status code is 400") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) public void adminIsNotAbleToUpdateWithEmptyCommentBody() throws JsonToModelConversionException, Exception { @@ -72,8 +71,7 @@ public class UpdateCommentCoreTests extends RestTest .assertLastError().containsSummary("An invalid argument was received"); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify updated comment by Manager is listed when calling getComments and status code is 200") + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify updated comment by Manager is listed when calling getComments and status code is 200") // @Bug(id="REPO-1011") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) public void updatedCommentByManagerIsListed() throws JsonToModelConversionException, Exception @@ -87,8 +85,7 @@ public class UpdateCommentCoreTests extends RestTest comments.assertThat().entriesListContains("content", "This is the updated comment with Manager user"); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user can not update comments of another user and status code is 200") + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user can not update comments of another user and status code is 200") // @Bug(id="MNT-2502",description="seems it's one old issue: also logged as MNT-2502, MNT-2346") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) public void collaboratorIsNotAbleToUpdateCommentOfAnotherUser() throws JsonToModelConversionException, Exception @@ -100,8 +97,7 @@ public class UpdateCommentCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify entry content in response") + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify entry content in response") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) public void checkEntryContentInResponse() throws JsonToModelConversionException, Exception { diff --git a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentFullTests.java b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentFullTests.java index f15aba274..f96cf475a 100644 --- a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentFullTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentFullTests.java @@ -42,7 +42,7 @@ public class UpdateCommentFullTests extends RestTest UserRole.SiteConsumer, UserRole.SiteContributor); } - @TestRail(section={TestGroup.REST_API, TestGroup.FULL}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Verify Manager user can update a comment with a large string") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) public void managerIsAbleToUpdateACommentWithALargeString() throws JsonToModelConversionException, Exception @@ -60,7 +60,7 @@ public class UpdateCommentFullTests extends RestTest returnedCommentModel.assertThat().field("content").is(longString); } - @TestRail(section={TestGroup.REST_API, TestGroup.FULL}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Verify Manager user can update a comment with a short string") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) public void managerIsAbleToUpdateACommentWithAShortString() throws JsonToModelConversionException, Exception @@ -78,7 +78,7 @@ public class UpdateCommentFullTests extends RestTest returnedCommentModel.assertThat().field("content").is(shortString); } - @TestRail(section={TestGroup.REST_API, TestGroup.FULL}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Verify Collaborator user can update a comment with special characters") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) public void collaboratorIsAbleToUpdateACommentThatContainsSpecialChars() throws JsonToModelConversionException, Exception @@ -96,7 +96,7 @@ public class UpdateCommentFullTests extends RestTest returnedCommentModel.assertThat().field("content").is(specialChars); } - @TestRail(section={TestGroup.REST_API, TestGroup.FULL}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Check that you cannot update comment with Consumer then call getComments and check new comment is not listed") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) public void cannotUpdateCommentWithConsumerCallGetComments() throws JsonToModelConversionException, Exception @@ -117,7 +117,7 @@ public class UpdateCommentFullTests extends RestTest .and().paginationField("totalItems").is("1"); } - @TestRail(section={TestGroup.REST_API, TestGroup.FULL}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Update comment with Contributor then call getComments and check new comment is listed") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) @Bug(id = "ACE-4614") @@ -139,7 +139,7 @@ public class UpdateCommentFullTests extends RestTest .and().paginationField("totalItems").is("1"); } - @TestRail(section={TestGroup.REST_API, TestGroup.FULL}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Update comment with Collaborator then call getComments and check new comment is listed") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) public void updateCommentWithCollaboratorCallGetComments() throws JsonToModelConversionException, Exception @@ -160,7 +160,7 @@ public class UpdateCommentFullTests extends RestTest .and().paginationField("totalItems").is("1"); } - @TestRail(section={TestGroup.REST_API, TestGroup.FULL}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Update comment with Manager then check modified by information in response") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) public void updateCommentWithManagerCheckModifiedBy() throws JsonToModelConversionException, Exception @@ -178,7 +178,7 @@ public class UpdateCommentFullTests extends RestTest .and().field("content").is(updatedComment); } - @TestRail(section={TestGroup.REST_API, TestGroup.FULL}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Delete comment with Admin then try to update it") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) public void deleteCommentThenTryToUpdateIt() throws JsonToModelConversionException, Exception @@ -196,7 +196,7 @@ public class UpdateCommentFullTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); } - @TestRail(section={TestGroup.REST_API, TestGroup.FULL}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Verify Manager user can update a comment with multi byte content") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) public void managerIsAbleToUpdateACommentWithMultiByteContent() throws JsonToModelConversionException, Exception @@ -214,7 +214,7 @@ public class UpdateCommentFullTests extends RestTest returnedCommentModel.assertThat().field("content").is(multiByte); } - @TestRail(section={TestGroup.REST_API, TestGroup.FULL}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Verify Admin user can update a comment with properties parameter") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) public void adminIsAbleToUpdateACommentWithPropertiesParameter() throws JsonToModelConversionException, Exception @@ -234,7 +234,7 @@ public class UpdateCommentFullTests extends RestTest .assertThat().fieldsCount().is(4); } - @TestRail(section = { TestGroup.REST_API, TestGroup.FULL }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Update comment with invalid node") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) public void updateCommentUsingInvalidNodeId() throws JsonToModelConversionException, Exception @@ -250,7 +250,7 @@ public class UpdateCommentFullTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, file.getNodeRef())); } - @TestRail(section={TestGroup.REST_API, TestGroup.FULL, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Verify update comment from node with invalid network id returns status code 401") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) public void updateCommentWithInvalidNetworkId() throws Exception @@ -263,7 +263,7 @@ public class UpdateCommentFullTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } - @TestRail(section={TestGroup.REST_API, TestGroup.FULL, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Verify User can not update comment to a not joined private site. Status code returned is 403") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) public void userCanNotUpdateCommentToANotJoinedPrivateSiteDefaultErrorModelSchema() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentSanityTests.java index 87756ff4e..b77a895da 100644 --- a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentSanityTests.java @@ -38,8 +38,7 @@ public class UpdateCommentSanityTests extends RestTest usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Admin user updates comments and status code is 200") + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Admin user updates comments and status code is 200") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) public void adminIsAbleToUpdateHisComment() throws JsonToModelConversionException, Exception { @@ -52,8 +51,7 @@ public class UpdateCommentSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Manager user updates comments created by admin user and status code is 200") + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Manager user updates comments created by admin user and status code is 200") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) public void managerIsAbleToUpdateHisComment() throws JsonToModelConversionException, Exception { @@ -66,8 +64,7 @@ public class UpdateCommentSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Contributor user can update his own comment and status code is 200") + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Contributor user can update his own comment and status code is 200") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) public void contributorIsAbleToUpdateHisComment() throws JsonToModelConversionException, Exception { @@ -78,8 +75,7 @@ public class UpdateCommentSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Consumer user can not update comments created by admin user and status code is 403") + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Consumer user can not update comments created by admin user and status code is 403") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) public void consumerIsNotAbleToUpdateComment() throws JsonToModelConversionException, Exception { @@ -91,8 +87,7 @@ public class UpdateCommentSanityTests extends RestTest .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user can update his own comment and status code is 200") + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user can update his own comment and status code is 200") // @Bug(id="REPO-1011") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) public void collaboratorIsAbleToUpdateHisComment() throws JsonToModelConversionException, Exception @@ -103,8 +98,7 @@ public class UpdateCommentSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user gets status code 401 on update comment call") + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user gets status code 401 on update comment call") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) @Bug(id="MNT-16904") public void unauthenticatedUserIsNotAbleToUpdateComment() throws JsonToModelConversionException, Exception @@ -118,7 +112,7 @@ public class UpdateCommentSanityTests extends RestTest .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } - @TestRail(section = { TestGroup.REST_API, TestGroup.SANITY }, executionType = ExecutionType.SANITY, description = "Verify update comment with inexistent nodeId returns status code 404") + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify update comment with inexistent nodeId returns status code 404") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) public void canNotUpdateCommentIfNodeIdIsNotSet() throws JsonToModelConversionException, Exception { @@ -132,7 +126,7 @@ public class UpdateCommentSanityTests extends RestTest .assertLastError().containsSummary("node ref that does not exist was not found"); } - @TestRail(section = { TestGroup.REST_API, TestGroup.SANITY }, executionType = ExecutionType.SANITY, description = "Verify if commentId is not set the status code is 404") + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify if commentId is not set the status code is 404") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) public void canNotUpdateCommentIfCommentIdIsNotSet() throws JsonToModelConversionException, Exception { diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteFullTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteFullTests.java index 16d74659b..0f234b70f 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteFullTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteFullTests.java @@ -36,7 +36,7 @@ public class DeleteFavoriteSiteFullTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "User is not able to remove a favorite site of admin user") public void userIsNotAbleToDeleteFavoritesOfAdmin() throws Exception { @@ -52,7 +52,7 @@ public class DeleteFavoriteSiteFullTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Users removed twice from favorites same site.") public void managerUserRemovesDeletedFavoriteSite() throws Exception { @@ -67,7 +67,7 @@ public class DeleteFavoriteSiteFullTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Users removes from favorite a site that is already deleted.") public void consumerUserRemovesDeletedFavoriteSite() throws Exception { @@ -86,7 +86,7 @@ public class DeleteFavoriteSiteFullTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Delete favorite site that is NOT favorite.") public void adminUserRemovesDeletedFavoriteSiteThatIsNotFavorite() throws Exception { diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerCoreTests.java index aa1ff1dd2..0dab7cf58 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerCoreTests.java @@ -37,7 +37,7 @@ public class GetSiteContainerCoreTests extends RestTest{ } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if get container request returns status code 400 when site doesn't exist") public void getContainerWithNonExistentSite() throws Exception { @@ -48,7 +48,7 @@ public class GetSiteContainerCoreTests extends RestTest{ } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if get container request returns status code 400 when container item doesn't exist") public void getContainerWithNonExistentItem() throws Exception { @@ -59,7 +59,7 @@ public class GetSiteContainerCoreTests extends RestTest{ } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify get container request returns status 200 for public site") public void getContainerForPublicSite() throws Exception { @@ -75,7 +75,7 @@ public class GetSiteContainerCoreTests extends RestTest{ } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify get container request returns status 200 for private site") public void getContainerForPrivateSite() throws Exception { @@ -90,7 +90,7 @@ public class GetSiteContainerCoreTests extends RestTest{ } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify get container request returns status 200 for moderated site") public void getContainerForModeratedSite() throws Exception { diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersCoreTests.java index 298b37c78..70aefbb9b 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersCoreTests.java @@ -50,7 +50,7 @@ public class GetSiteContainersCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if get site container request returns status code 200 with valid maxItems parameter") public void getContainersWithValidMaxItems() throws Exception { @@ -75,7 +75,7 @@ public class GetSiteContainersCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if get site container request returns status code 400 when invalid maxItems parameter is used") public void getContainersWithMaxItemsZero () throws Exception { @@ -87,7 +87,7 @@ public class GetSiteContainersCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if get site container request returns status code 400 when invalid maxItems parameter is used") public void getContainersWithMaxItemsCharacter () throws Exception { @@ -99,7 +99,7 @@ public class GetSiteContainersCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if get site container request returns status code 200 when maxItems parameter starts with multiple zero") public void getContainersWithMaxItemsMultipleZero () throws Exception { @@ -111,7 +111,7 @@ public class GetSiteContainersCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if get site containers request returns status code 200 when valid skipCount parameter is used") public void getSiteContainersWithValidSkipCount() throws Exception { @@ -137,7 +137,7 @@ public class GetSiteContainersCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if get site containers request returns status code 400 when invalid skipCount parameter is used") public void getSiteContainersWithSkipCountCharacter() throws Exception { @@ -148,7 +148,7 @@ public class GetSiteContainersCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if get site containers request returns status code 200 when skipCount parameter starts with multiple zero") public void getSiteContainersWithSkipCountMultipleZero() throws Exception { @@ -159,7 +159,7 @@ public class GetSiteContainersCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if get site containers request returns status code 400 when site doesn't exist") public void getSiteContainersWithNonExistentSite() throws Exception { @@ -170,7 +170,7 @@ public class GetSiteContainersCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify get site containers request returns status 200 for private site") public void getSiteContainersForPrivateSite() throws Exception { @@ -181,7 +181,7 @@ public class GetSiteContainersCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify get site containers request returns status 200 for moderated site") public void getSiteContainersForModeratedSite() throws Exception { @@ -192,7 +192,7 @@ public class GetSiteContainersCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify get site containers request returns status 200 for several containers") public void getSiteContainersForSeveralItems() throws Exception { @@ -206,7 +206,7 @@ public class GetSiteContainersCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify get site containers request returns status 200 for one container") public void getSiteContainersWithOneItem() throws Exception { diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteCoreTests.java index 7d03ccf45..e7123a90d 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteCoreTests.java @@ -37,7 +37,7 @@ public class GetSiteCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify invalid request returns status code 404 if siteId does not exist") public void checkStatusCodeForNonExistentSiteId() throws Exception { @@ -48,7 +48,7 @@ public class GetSiteCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify user gets all public and moderated sites if an empty siteId is provided") public void checkStatusCodeForEmptySiteId() throws Exception { @@ -60,7 +60,7 @@ public class GetSiteCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if any user gets public site details and status code is 200") public void getPublicSite() throws Exception { @@ -75,7 +75,7 @@ public class GetSiteCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if any user gets moderated site details and status code is 200") public void getModeratedSite() throws Exception { @@ -90,7 +90,7 @@ public class GetSiteCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if member of a private site gets that site details and status code is 200") public void getPrivateSiteBySiteMember() throws Exception { @@ -105,7 +105,7 @@ public class GetSiteCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if user that is not member of a private site does not get that site details and status code is 200") public void getPrivateSiteByNotASiteMember() throws Exception { diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersCoreTests.java index 8467854e0..5abaf3d86 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersCoreTests.java @@ -40,7 +40,7 @@ public class GetSiteMembersCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.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 { @@ -51,7 +51,7 @@ public class GetSiteMembersCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.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 { @@ -67,7 +67,7 @@ public class GetSiteMembersCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.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 { @@ -83,7 +83,7 @@ public class GetSiteMembersCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.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 { @@ -96,7 +96,7 @@ public class GetSiteMembersCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.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 { @@ -109,7 +109,7 @@ public class GetSiteMembersCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.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 { @@ -122,7 +122,7 @@ public class GetSiteMembersCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.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 { @@ -133,7 +133,7 @@ public class GetSiteMembersCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.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 { diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java index 2da9a46c4..d59cbf27a 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java @@ -47,7 +47,7 @@ public class GetSitesCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if get sites request returns status code 400 when invalid maxItems parameter is used") public void getSitesWithInvalidMaxItems() throws Exception { @@ -68,7 +68,7 @@ public class GetSitesCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if get sites request returns status code 400 when invalid skipCount parameter is used") public void getSitesWithInvalidSkipCount() throws Exception { @@ -84,7 +84,7 @@ public class GetSitesCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if User gets sites ordered by title ascending and status code is 200") public void getSitesOrderedByNameASC() throws Exception { @@ -99,7 +99,7 @@ public class GetSitesCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if a regular user gets all public and moderated sites and status code is 200") public void regularUserGetsOnlyPublicAndModeratedSites() throws Exception { @@ -112,7 +112,7 @@ public class GetSitesCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if a member of a private site gets the private site, all public sites and all moderated sites. Verify if status code is 200") public void privateSiteMemberGetsSitesVisibleForHim() throws Exception { @@ -125,7 +125,7 @@ public class GetSitesCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if a site is not retrieved anymore after deletion and status code is 200") public void checkDeletedSiteIsNotRetrieved() throws Exception { diff --git a/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberCoreTests.java index 9ac8ba828..4f79c1355 100644 --- a/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberCoreTests.java @@ -43,7 +43,7 @@ public class UpdateSiteMemberCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if update site member request returns status code 404 when nonexistent siteId is used") public void updateSiteMemberOfNonexistentSite() throws Exception { @@ -58,7 +58,7 @@ public class UpdateSiteMemberCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if update site member request returns status code 400 when personId is not member of the site") public void updateNotASiteMember() throws Exception { @@ -70,7 +70,7 @@ public class UpdateSiteMemberCoreTests extends RestTest // @Bug(id="REPO-1642", description = "reproduced on 5.2.1 only, it works on 5.2.0") @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if update site member request returns status code 404 when personId does not exist") public void updateNonexistentSiteMember() throws Exception { @@ -84,7 +84,7 @@ public class UpdateSiteMemberCoreTests extends RestTest @Bug(id="REPO-1660") @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if a manager is able to downgrade to contributor using -me- string in place of personId.") public void updateSiteManagerToSiteContributorUsingMe() throws Exception { @@ -100,7 +100,7 @@ public class UpdateSiteMemberCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if update site member request returns status code 404 when empty siteId is used") public void updateSiteMemberUsingEmptySiteId() throws Exception { @@ -111,7 +111,7 @@ public class UpdateSiteMemberCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if update site member request returns status code 405 when empty personId is used") public void updateSiteMemberUsingEmptyPersonId() throws Exception { @@ -124,7 +124,7 @@ public class UpdateSiteMemberCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if update site member request returns status code 400 when invalid role is used") public void updateSiteMemberUsingInvalidRole() throws Exception { @@ -138,7 +138,7 @@ public class UpdateSiteMemberCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if manager is able to update another site manager to site collaborator") public void managerUpdateSiteManagerToSiteCollaborator() throws Exception { @@ -152,7 +152,7 @@ public class UpdateSiteMemberCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if manager is able to update site contributor to site manager") public void managerUpdateSiteContributorToSiteManager() throws Exception { @@ -166,7 +166,7 @@ public class UpdateSiteMemberCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if manager is able to update site collaborator to site manager") public void managerUpdateSiteCollaboratorToSiteManager() throws Exception { @@ -180,7 +180,7 @@ public class UpdateSiteMemberCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if manager is able to update site consumer to site manager") public void managerUpdateSiteConsumerToSiteManager() throws Exception { @@ -194,7 +194,7 @@ public class UpdateSiteMemberCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if manager is able to downgrade himself to site consumer") public void managerDowngradeHimselfToSiteConsumer() throws Exception { From 2c1f20320a4a50b243752269dd81be431e662708 Mon Sep 17 00:00:00 2001 From: mionescu Date: Wed, 18 Jan 2017 12:24:00 +0200 Subject: [PATCH 0882/1491] test - added test cases: userIsNotAbleToDeleteSiteMembershipRequestEmptyPersonID, userCancelsSiteMembershipRequestTwiceModeratedSite --- .../DeleteSiteMembershipRequestFullTests.java | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestFullTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestFullTests.java index 4f4fb107e..f0440f84c 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestFullTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestFullTests.java @@ -12,6 +12,7 @@ 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.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.beans.factory.annotation.Autowired; @@ -166,4 +167,47 @@ public class DeleteSiteMembershipRequestFullTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE); } + @Bug(id="ACE-2413") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify user is not able to remove a site memebership request- empty person id and response is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + public void userIsNotAbleToDeleteSiteMembershipRequestEmptyPersonID() throws JsonToModelConversionException, DataPreparationException, Exception + { + UserModel emptyPersonId = new UserModel("", "password"); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(emptyPersonId).deleteSiteMembershipRequest(moderatedSite); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .containsSummary(RestErrorModel.ENTITY_NOT_FOUND) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify COLLABORATOR removes/cancel twice same site memebership request and response is 204") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + public void userCancelsSiteMembershipRequestTwiceModeratedSite() throws JsonToModelConversionException, + DataPreparationException, Exception + { + UserModel user = dataUser.createRandomTestUser(); + UserModel userCollaborator = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); + moderatedSite = dataSite.usingUser(userCollaborator).createModeratedRandomSite(); + + restClient.authenticateUser(user).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + restClient.authenticateUser(userCollaborator).withCoreAPI().usingUser(user).getSiteMembershipRequest(moderatedSite).assertThat().field("id") + .is(moderatedSite.getId()); + + restClient.authenticateUser(userCollaborator).withCoreAPI().usingUser(user).deleteSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.authenticateUser(userCollaborator).withCoreAPI().usingUser(user).deleteSiteMembershipRequest(moderatedSite); + + restClient.withCoreAPI().usingUser(user).getSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, user.getUsername(), moderatedSite.getTitle())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } } From e7170127ff637c7d8e3d8dddafe443fa2976d91f Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Wed, 18 Jan 2017 12:43:41 +0200 Subject: [PATCH 0883/1491] update rest suite & default.properties --- .../java/org/alfresco/rest/auth/AuthTests.java | 2 +- e2e-test/resources/default.properties | 17 ++++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/auth/AuthTests.java b/e2e-test/java/org/alfresco/rest/auth/AuthTests.java index 03a8a456a..2be7bfc7e 100644 --- a/e2e-test/java/org/alfresco/rest/auth/AuthTests.java +++ b/e2e-test/java/org/alfresco/rest/auth/AuthTests.java @@ -13,7 +13,7 @@ import org.testng.annotations.Test; public class AuthTests extends RestTest { @TestRail(section = { TestGroup.REST_API, TestGroup.AUTH }, executionType = ExecutionType.SANITY, description = "Verify TICKET is returned on admin user") - @Test(groups = { TestGroup.REST_API, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.SANITY, TestGroup.AUTH }) public void adminShouldGetTicketBody() throws JsonToModelConversionException, Exception { RestTicketBodyModel ticketBody = new RestTicketBodyModel(); diff --git a/e2e-test/resources/default.properties b/e2e-test/resources/default.properties index 6d12861d7..1dc1987e1 100644 --- a/e2e-test/resources/default.properties +++ b/e2e-test/resources/default.properties @@ -5,7 +5,7 @@ alfresco.port=8080 # in containers we cannot access directly JMX, so we will use http://jolokia.org agent # disabling this we will use direct JMX calls to server -jmx.useJolokiaAgent=false +jmx.useJolokiaAgent=true # credentials admin.user=admin @@ -17,22 +17,25 @@ admin.password=admin # # Example of configuration: # ------------------------------------------------------ -# testManagement.endPoint=https://alfresco.testrail.com/ # if testManagement.enabled=true we enabled TestRailExecutorListener (if used in your suite xml file) # testManagement.updateTestExecutionResultsOnly=true (this will just update the results of a test: no step will be updated - good for performance) +# testManagement.endPoint=https://alfresco.testrail.com/ # testManagement.username= # testManagement.apiKey= -# testManagement.project= +# testManagement.project= +# testManagement.includeAllTests=false #if you want to include in your run ONLY the test cases that you run, then set this value to false +# testManagement.rateLimitInSeconds=2 #is the default rate limit after what minimum time, should we upload the next request. http://docs.gurock.com/testrail-api2/introduction #Rate Limit # testManagement.suiteId=23 (the id of the Master suite) # ------------------------------------------------------ -testManagement.enabled=false -testManagement.updateTestExecutionResultsOnly=true +testManagement.enabled=true testManagement.endPoint=https://alfresco.testrail.com/ testManagement.username=tas.alfresco@gmail.com testManagement.apiKey=EYpY7.fV0AoMGWbmyuVC-k5u.nzwHy6a.QWzJq8.S testManagement.project=7 -testManagement.testRun=Automation +testManagement.includeAllTests=false +testManagement.rateLimitInSeconds=1 +testManagement.testRun=MyTestRunInTestRail testManagement.suiteId=12 # The location of the reports path From 667cbe4205a39a1f1a85af6ae6c9e26dbac1c637 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Wed, 18 Jan 2017 12:49:18 +0200 Subject: [PATCH 0884/1491] disable testRail integration by default --- e2e-test/resources/default.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/resources/default.properties b/e2e-test/resources/default.properties index 1dc1987e1..fcaab38d2 100644 --- a/e2e-test/resources/default.properties +++ b/e2e-test/resources/default.properties @@ -28,7 +28,7 @@ admin.password=admin # testManagement.rateLimitInSeconds=2 #is the default rate limit after what minimum time, should we upload the next request. http://docs.gurock.com/testrail-api2/introduction #Rate Limit # testManagement.suiteId=23 (the id of the Master suite) # ------------------------------------------------------ -testManagement.enabled=true +testManagement.enabled=false testManagement.endPoint=https://alfresco.testrail.com/ testManagement.username=tas.alfresco@gmail.com testManagement.apiKey=EYpY7.fV0AoMGWbmyuVC-k5u.nzwHy6a.QWzJq8.S From 181874db77cea88af86226601f7a64f0d2c39f1b Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Wed, 18 Jan 2017 13:03:16 +0200 Subject: [PATCH 0885/1491] update Jenkinsfile due to TestRail v2 --- e2e-test/resources/default.properties | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/e2e-test/resources/default.properties b/e2e-test/resources/default.properties index fcaab38d2..460444321 100644 --- a/e2e-test/resources/default.properties +++ b/e2e-test/resources/default.properties @@ -5,7 +5,7 @@ alfresco.port=8080 # in containers we cannot access directly JMX, so we will use http://jolokia.org agent # disabling this we will use direct JMX calls to server -jmx.useJolokiaAgent=true +jmx.useJolokiaAgent=false # credentials admin.user=admin @@ -24,16 +24,16 @@ admin.password=admin # testManagement.apiKey= # testManagement.project= -# testManagement.includeAllTests=false #if you want to include in your run ONLY the test cases that you run, then set this value to false -# testManagement.rateLimitInSeconds=2 #is the default rate limit after what minimum time, should we upload the next request. http://docs.gurock.com/testrail-api2/introduction #Rate Limit +# testManagement.includeOnlyTestCasesExecuted=false #if you want to include in your run ONLY the test cases that you run, then set this value to false +# testManagement.rateLimitInSeconds=1 #is the default rate limit after what minimum time, should we upload the next request. http://docs.gurock.com/testrail-api2/introduction #Rate Limit # testManagement.suiteId=23 (the id of the Master suite) # ------------------------------------------------------ -testManagement.enabled=false +testManagement.enabled=true testManagement.endPoint=https://alfresco.testrail.com/ testManagement.username=tas.alfresco@gmail.com testManagement.apiKey=EYpY7.fV0AoMGWbmyuVC-k5u.nzwHy6a.QWzJq8.S testManagement.project=7 -testManagement.includeAllTests=false +testManagement.includeOnlyTestCasesExecuted=true testManagement.rateLimitInSeconds=1 testManagement.testRun=MyTestRunInTestRail testManagement.suiteId=12 From cf7039c8589fdc7dbca7cbc5904a3019d36ba42f Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Wed, 18 Jan 2017 15:29:54 +0200 Subject: [PATCH 0886/1491] Added RemoveSiteMember full tests --- .../rest/sites/RemoveSiteMemberFullTests.java | 150 ++++++++++++++++++ 1 file changed, 150 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberFullTests.java b/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberFullTests.java new file mode 100644 index 000000000..bc483ab06 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberFullTests.java @@ -0,0 +1,150 @@ +package org.alfresco.rest.sites; + +import org.alfresco.rest.RestTest; +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.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class RemoveSiteMemberFullTests extends RestTest +{ + private SiteModel siteModel; + private UserModel adminUserModel; + private ListUserWithRoles usersWithRoles; + private SiteModel moderatedSiteModel; + private SiteModel privateSiteModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws DataPreparationException + { + adminUserModel = dataUser.getAdminUser(); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + moderatedSiteModel = dataSite.usingUser(adminUserModel).createModeratedRandomSite(); + privateSiteModel = dataSite.usingUser(adminUserModel).createPrivateRandomSite(); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, + UserRole.SiteConsumer, UserRole.SiteContributor); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin can delete a site member with Contributor role and gets status code 204") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + public void adminIsAbleToDeleteSiteMemberWithContributorRole() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(siteModel) + .deleteSiteMember(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + dataUser.addUserToSite(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor), siteModel, UserRole.SiteContributor); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin can delete site member with Manager role and gets status code 204") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + public void aminIsAbleToDeleteSiteMemberWithManagerRole() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(siteModel) + .deleteSiteMember(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + dataUser.addUserToSite(usersWithRoles.getOneUserWithRole(UserRole.SiteManager), siteModel, UserRole.SiteManager); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin can delete site member with Consumer role and gets status code 204") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + public void adminIsAbleToDeleteSiteMemberWithConsumerRole() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(siteModel) + .deleteSiteMember(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + dataUser.addUserToSite(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer), siteModel, UserRole.SiteConsumer); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin can delete a site member with Collaborator role and gets status code 204") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + public void adminIsNotAbleToDeleteSiteMemberWithCollaboratorRole() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(siteModel) + .deleteSiteMember(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + dataUser.addUserToSite(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), siteModel, UserRole.SiteCollaborator); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin can delete a site member of moderated site and gets status code 204") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + public void adminIsAbleToDeleteModeratedSiteMember() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + newMember.setUserRole(UserRole.SiteManager); + dataUser.addUserToSite(newMember, moderatedSiteModel, UserRole.SiteManager); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).deleteSiteMember(newMember); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin can delete a site member of private site and gets status code 204") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + public void adminIsAbleToDeletePrivateSiteMember() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + newMember.setUserRole(UserRole.SiteManager); + dataUser.addUserToSite(newMember, privateSiteModel, UserRole.SiteManager); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).deleteSiteMember(newMember); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that regular user can not delete admin and gets status code 422") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + public void regularUserIsNotAbleToDeleteAdmin() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingSite(siteModel) + .deleteSiteMember(adminUserModel); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() + .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getTitle())) + .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin can not delete a site member twice and gets status code 204") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @Bug(id="ACE-5447") + public void adminIsNotAbleToRemoveSiteMemberTwice() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(siteModel) + .deleteSiteMember(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(siteModel) + .deleteSiteMember(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(RestErrorModel.ENTITY_NOT_FOUND); + dataUser.addUserToSite(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor), siteModel, UserRole.SiteContributor); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify admin is not able to remove from site a user that created a member request that was not accepted yet") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @Bug(id="ACE-5447") + public void adminIsNotAbleToRemoveFromSiteANonExistingMember() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(siteModel); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).deleteSiteMember(newMember); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(RestErrorModel.ENTITY_NOT_FOUND); + } +} From 1bdc4016e58f97ed07b1efa6d81dfe28bfab8fba Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Wed, 18 Jan 2017 15:43:31 +0200 Subject: [PATCH 0887/1491] Minor changes for delete site member --- .../people/DeleteSiteMemberFullTests.java | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberFullTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberFullTests.java index 57622380c..1bb75d872 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberFullTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberFullTests.java @@ -11,6 +11,7 @@ import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; +import org.springframework.social.alfresco.api.entities.Role; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -119,7 +120,7 @@ public class DeleteSiteMemberFullTests extends RestTest { restClient.authenticateUser(usersWithRolesModeratedSite.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingUser(usersWithRolesModeratedSite.getOneUserWithRole(UserRole.SiteContributor)).deleteSiteMember(moderatedSiteModel); restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() - .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, moderatedSiteModel.getId())); + .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, moderatedSiteModel.getId())); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) @@ -128,7 +129,7 @@ public class DeleteSiteMemberFullTests extends RestTest { restClient.authenticateUser(usersWithRolesModeratedSite.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingUser(usersWithRolesModeratedSite.getOneUserWithRole(UserRole.SiteConsumer)).deleteSiteMember(moderatedSiteModel); restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() - .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, moderatedSiteModel.getId())); + .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, moderatedSiteModel.getId())); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) @@ -164,7 +165,7 @@ public class DeleteSiteMemberFullTests extends RestTest { restClient.authenticateUser(usersWithRolesPrivateSite.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingUser(usersWithRolesPrivateSite.getOneUserWithRole(UserRole.SiteContributor)).deleteSiteMember(privateSiteModel); restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() - .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, privateSiteModel.getId())); + .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, privateSiteModel.getId())); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) @@ -173,7 +174,7 @@ public class DeleteSiteMemberFullTests extends RestTest { restClient.authenticateUser(usersWithRolesPrivateSite.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingUser(usersWithRolesPrivateSite.getOneUserWithRole(UserRole.SiteConsumer)).deleteSiteMember(privateSiteModel); restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() - .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, privateSiteModel.getId())); + .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, privateSiteModel.getId())); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) @@ -186,6 +187,9 @@ public class DeleteSiteMemberFullTests extends RestTest restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteCollaborator)).deleteSiteMember(publicSiteModel); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(RestErrorModel.ENTITY_NOT_FOUND); restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteCollaborator)); + restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMembers().assertThat().entriesListContains("id", usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteCollaborator).getUsername()) + .when().getSiteMember(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteCollaborator).getUsername()) + .assertSiteMemberHasRole(Role.SiteCollaborator); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) @@ -197,13 +201,13 @@ public class DeleteSiteMemberFullTests extends RestTest restClient.withCoreAPI().usingUser(adminUserModel).deleteSiteMember(publicSiteModel); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsSummary(String.format(RestErrorModel.DELETE_LAST_MANAGER, publicSiteModel.getTitle())) - .containsErrorKey(String.format(RestErrorModel.DELETE_LAST_MANAGER, publicSiteModel.getTitle())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); + .assertLastError().containsSummary(String.format(RestErrorModel.DELETE_LAST_MANAGER, publicSiteModel.getTitle())) + .containsErrorKey(String.format(RestErrorModel.DELETE_LAST_MANAGER, publicSiteModel.getTitle())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER).stackTraceIs(RestErrorModel.STACKTRACE); restClient.withCoreAPI().usingSite(publicSiteModel).addPerson(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteManager)); + restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMembers() + .assertThat().entriesListContains("id", usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteManager).getUsername()); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) @@ -213,6 +217,7 @@ public class DeleteSiteMemberFullTests extends RestTest restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).deleteSiteMember(publicSiteModel); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); restClient.authenticateUser(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingSite(publicSiteModel).addPerson(adminUserModel); + restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMembers().assertThat().entriesListContains("id", adminUserModel.getUsername()); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) @@ -224,6 +229,7 @@ public class DeleteSiteMemberFullTests extends RestTest restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(newMember).deleteSiteMember(publicSiteModel); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); restClient.authenticateUser(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingSite(publicSiteModel).addPerson(adminUserModel); + restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMembers().assertThat().entriesListContains("id", adminUserModel.getUsername()); } -} +} \ No newline at end of file From 4e2e15016c528451959d7afa2f3ed88566cd7cd5 Mon Sep 17 00:00:00 2001 From: Andrei Rusu Date: Wed, 18 Jan 2017 16:11:27 +0200 Subject: [PATCH 0888/1491] added tests for DeleteTagFullTests --- .../rest/tags/DeleteTagFullTests.java | 130 ++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/tags/DeleteTagFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/tags/DeleteTagFullTests.java b/e2e-test/java/org/alfresco/rest/tags/DeleteTagFullTests.java new file mode 100644 index 000000000..b864eda33 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/tags/DeleteTagFullTests.java @@ -0,0 +1,130 @@ +package org.alfresco.rest.tags; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestTagModel; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.data.RandomData; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.apache.commons.lang.RandomStringUtils; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class DeleteTagFullTests extends RestTest +{ + private UserModel adminUserModel; + private SiteModel siteModel; + private DataUser.ListUserWithRoles usersWithRoles; + private RestTagModel tagReturnedModel, returnedTag; + private FileModel document; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, + executionType = ExecutionType.REGRESSION, description = "Verify Manager user can't delete deleted tag.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) + @Bug(id = "ACE-5455") + public void managerCannotDeleteDeletedTag() throws JsonToModelConversionException, Exception + { + tagReturnedModel = restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(document).deleteTag(tagReturnedModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingResource(document).deleteTag(tagReturnedModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, + executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user can delete long tag.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) + public void collaboratorCanDeleteLongTag() throws JsonToModelConversionException, Exception + { + String longTag = RandomStringUtils.randomAlphanumeric(10000); + + tagReturnedModel = restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingResource(document).addTag(longTag); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingResource(document).deleteTag(tagReturnedModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, + executionType = ExecutionType.REGRESSION, description = "Verify Manager user can delete short tag.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) + public void managerCanDeleteShortTag() throws JsonToModelConversionException, Exception + { + String shortTag = RandomStringUtils.randomAlphanumeric(10); + + tagReturnedModel = restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingResource(document).addTag(shortTag); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(document).deleteTag(tagReturnedModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, + executionType = ExecutionType.REGRESSION, description = "Verify Admin can delete tag then add it again.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) + public void adminRemovesTagAndAddsItAgain() throws JsonToModelConversionException, Exception + { + String tag = RandomStringUtils.randomAlphanumeric(10); + + tagReturnedModel = restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingResource(document).addTag(tag); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(document).deleteTag(tagReturnedModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + tagReturnedModel = restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingResource(document).addTag(tag); + returnedTag = restClient.withCoreAPI().getTag(tagReturnedModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedTag.assertThat().field("tag").is(tag.toLowerCase()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, + executionType = ExecutionType.REGRESSION, description = "Verify Contributor user cannot delete tag added by another user. Check default error model schema.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) + public void contributorCannotDeleteTagAddedByAnotherUserCheckDefaultErrorModelSchema() throws JsonToModelConversionException, Exception + { + String tag = RandomStringUtils.randomAlphanumeric(10); + + tagReturnedModel = restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingResource(document).addTag(tag); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) + .withCoreAPI().usingResource(document).deleteTag(tagReturnedModel); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + + returnedTag = restClient.withCoreAPI().getTag(tagReturnedModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedTag.assertThat().field("tag").is(tag.toLowerCase()); + } +} From 3716c5abb22302dc7e178680b1c3b8a3b4475e55 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Wed, 18 Jan 2017 17:05:01 +0200 Subject: [PATCH 0889/1491] Minor changes --- .../sites/GetSiteContainersFullTests.java | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersFullTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersFullTests.java index b4f0210d6..84d2f1595 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersFullTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersFullTests.java @@ -46,15 +46,15 @@ public class GetSiteContainersFullTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if get site container request with properties paramater applied returns status code 200") + description= "Verify if get site container request with properties parameter applied returns status code 200") public void getSiteContainersUsingPropertiesParameter() throws Exception { restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteManager)) .withCoreAPI().usingSite(publicSiteWithContainers).usingParams("properties=folderId").getSiteContainers() .assertThat().entriesListCountIs(3) - .and().entriesListContains("folderId" ,ContainerName.discussions.toString()) - .and().entriesListContains("folderId" ,ContainerName.documentLibrary.toString()) - .and().entriesListContains("folderId" ,ContainerName.links.toString()) + .and().entriesListContains("folderId", ContainerName.discussions.toString()) + .and().entriesListContains("folderId", ContainerName.documentLibrary.toString()) + .and().entriesListContains("folderId", ContainerName.links.toString()) .and().entriesListDoesNotContain("id"); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -67,7 +67,7 @@ public class GetSiteContainersFullTests extends RestTest restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteManager)) .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() .assertThat().entriesListCountIs(3) - .and().entriesListContains("folderId" ,ContainerName.documentLibrary.toString()); + .and().entriesListContains("folderId", ContainerName.documentLibrary.toString()); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -79,9 +79,9 @@ public class GetSiteContainersFullTests extends RestTest restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteCollaborator)) .withParams("skipCount=1").withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() .assertThat().entriesListCountIs(2) - .and().entriesListDoesNotContain("folderId" , restSiteContainers.getEntries().get(0).onModel().getFolderId()) - .and().entriesListContains("folderId" , restSiteContainers.getEntries().get(1).onModel().getFolderId()) - .and().entriesListContains("folderId" , restSiteContainers.getEntries().get(2).onModel().getFolderId()); + .and().entriesListDoesNotContain("folderId", restSiteContainers.getEntries().get(0).onModel().getFolderId()) + .and().entriesListContains("folderId", restSiteContainers.getEntries().get(1).onModel().getFolderId()) + .and().entriesListContains("folderId", restSiteContainers.getEntries().get(2).onModel().getFolderId()); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -93,9 +93,9 @@ public class GetSiteContainersFullTests extends RestTest restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteCollaborator)) .withParams("skipCount=" + String.valueOf(totalItems-1)).withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() .assertThat().entriesListCountIs(1) - .and().entriesListDoesNotContain("folderId" , restSiteContainers.getEntries().get(0).onModel().getFolderId()) - .and().entriesListDoesNotContain("folderId" , restSiteContainers.getEntries().get(1).onModel().getFolderId()) - .and().entriesListContains("folderId" , restSiteContainers.getEntries().get(2).onModel().getFolderId()); + .and().entriesListDoesNotContain("folderId", restSiteContainers.getEntries().get(0).onModel().getFolderId()) + .and().entriesListDoesNotContain("folderId", restSiteContainers.getEntries().get(1).onModel().getFolderId()) + .and().entriesListContains("folderId", restSiteContainers.getEntries().get(2).onModel().getFolderId()); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -114,7 +114,7 @@ public class GetSiteContainersFullTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if get site container request for a empty siteId returns status code 404") + description= "Verify if get site container request for an empty siteId returns status code 404") public void getSiteContainersForEmptySiteId() throws Exception { restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteManager)) @@ -141,4 +141,4 @@ public class GetSiteContainersFullTests extends RestTest .and().field("maxItems").is("2"); restClient.assertStatusCodeIs(HttpStatus.OK); } -} +} \ No newline at end of file From c9d4f98ba81ce4d0dd33f1661bc88ec554ef919c Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Wed, 18 Jan 2017 17:37:48 +0200 Subject: [PATCH 0890/1491] Changed DeleteSiteMemberFullTests#lastManagerIsNotAbleToDeleteHimself test --- .../rest/people/DeleteSiteMemberFullTests.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberFullTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberFullTests.java index 1bb75d872..d069379bb 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberFullTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberFullTests.java @@ -222,14 +222,14 @@ public class DeleteSiteMemberFullTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is not able to remove from site a user that created a member request that was not accepted yet") + @Bug(id="ACE-5447") public void adminIsNotAbleToRemoveFromSiteANonExistingMember() throws Exception { UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(publicSiteModel); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(newMember).deleteSiteMember(publicSiteModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.authenticateUser(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingSite(publicSiteModel).addPerson(adminUserModel); - restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMembers().assertThat().entriesListContains("id", adminUserModel.getUsername()); + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSiteModel); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(newMember).deleteSiteMember(moderatedSiteModel); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(RestErrorModel.ENTITY_NOT_FOUND); } } \ No newline at end of file From def27b5e56c1b533dd7dcb7f670b33a85ea99e94 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Wed, 18 Jan 2017 17:45:44 +0200 Subject: [PATCH 0891/1491] added full tests for GetSiteContainer --- .../rest/sites/GetSiteContainerFullTests.java | 176 ++++++++++++++++++ .../sites/GetSiteContainerSanityTests.java | 2 - 2 files changed, 176 insertions(+), 2 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/sites/GetSiteContainerFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerFullTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerFullTests.java new file mode 100644 index 000000000..5a4a5e2cd --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerFullTests.java @@ -0,0 +1,176 @@ +package org.alfresco.rest.sites; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.utility.constants.ContainerName; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.apache.commons.lang3.RandomStringUtils; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * + * @author Cristina Axinte + * + */ +public class GetSiteContainerFullTests extends RestTest +{ + private UserModel adminUserModel, testUserModel; + private SiteModel publicSiteModel, moderatedSiteModel, privateSiteModelByAdmin, privateSiteModelByUser; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + testUserModel = dataUser.createRandomTestUser(); + publicSiteModel = dataSite.usingAdmin().createPublicRandomSite(); + moderatedSiteModel = dataSite.usingUser(testUserModel).createModeratedRandomSite(); + privateSiteModelByAdmin = dataSite.usingAdmin().createPrivateRandomSite(); + + privateSiteModelByUser = dataSite.usingUser(testUserModel).createPrivateRandomSite(); + + dataLink.usingAdmin().usingSite(publicSiteModel).createRandomLink(); + dataDiscussion.usingAdmin().usingSite(publicSiteModel).createRandomDiscussion(); + + dataLink.usingUser(testUserModel).usingSite(moderatedSiteModel).createRandomLink(); + + dataLink.usingAdmin().usingSite(privateSiteModelByAdmin).createRandomLink(); + + dataDiscussion.usingUser(testUserModel).usingSite(privateSiteModelByUser).createRandomDiscussion(); + dataLink.usingUser(testUserModel).usingSite(privateSiteModelByUser).createRandomLink(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if get container request with properties parameter returns status code 200 and parameter is applied") + public void getContainerUsingPropertiesParameter() throws Exception + { + restClient.authenticateUser(testUserModel) + .withCoreAPI().usingSite(publicSiteModel).usingParams("properties=id").getSiteContainer(ContainerName.discussions.toString()) + .assertThat().fieldsCount().is(1) + .and().field("id").isNotEmpty() + .and().field("folderId").isNull(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if get container request for a container that does not belong to site returns status code 404") + public void getContainerThatDoesNotBelongToSite() throws Exception + { + restClient.authenticateUser(testUserModel) + .withCoreAPI().usingSite(moderatedSiteModel).getSiteContainer(ContainerName.discussions.toString()); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, moderatedSiteModel.getId(), ContainerName.discussions.toString())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if get container request for empty siteId returns status code 404") + public void getContainerForEmptySiteId() throws Exception + { + restClient.authenticateUser(testUserModel) + .withCoreAPI().usingSite("").getSiteContainer(ContainerName.discussions.toString()); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, "", ContainerName.discussions.toString())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if get container request for empty container returns status code 200 and the list of containers") + public void getContainerForEmptyContainer() throws Exception + { + restClient.authenticateUser(testUserModel) + .withCoreAPI().usingSite(moderatedSiteModel).getSiteContainer(""); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if get container with name containing special chars returns status code 404") + public void getContainerWithNameContainingSpecialChars() throws Exception + { + String containerSpecialName = RandomStringUtils.randomAlphabetic(2) + "~!%40%23%24%25%5E%26*()_%2B%5B%5D%7B%7D%7C%5C%3B%27%3A%22%2C.%2F%3C%3E"; + + restClient.authenticateUser(testUserModel) + .withCoreAPI().usingSite(publicSiteModel).getSiteContainer(containerSpecialName); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, publicSiteModel.getId(), containerSpecialName)) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if admin can get container request for a private site created by another user and status code is 200") + public void adminCanGetContainerForPrivateSiteCreatedByUser() throws Exception + { + restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingSite(privateSiteModelByUser).getSiteContainer(ContainerName.discussions.toString()) + .assertThat().field("folderId").is(ContainerName.discussions.toString()) + .and().field("id").isNotEmpty(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if user cannot get container request for a private site created by admin and status code is 403") + public void userCannotGetContainerForPrivateSiteCreatedByAdmin() throws Exception + { + restClient.authenticateUser(testUserModel) + .withCoreAPI().usingSite(privateSiteModelByAdmin).getSiteContainer(ContainerName.links.toString()); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, privateSiteModelByAdmin.getId(), ContainerName.links.toString())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if user can get container request for a public site created by admin and status code is 200") + public void userCanGetContainerForPublicSiteCreatedByAdmin() throws Exception + { + restClient.authenticateUser(testUserModel) + .withCoreAPI().usingSite(publicSiteModel).getSiteContainer(ContainerName.links.toString()) + .assertThat().field("folderId").is(ContainerName.links.toString()); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if get container request for a deleted container returns status code is 404") + public void getContainerThatWasDeleted() throws Exception + { + restClient.authenticateUser(testUserModel) + .withCoreAPI().usingSite(privateSiteModelByUser).getSiteContainer(ContainerName.links.toString()) + .assertThat().field("folderId").is(ContainerName.links.toString()); + restClient.assertStatusCodeIs(HttpStatus.OK); + + //use dataprep for delete 'links' container + FolderModel folder= new FolderModel("links"); + folder.setCmisLocation(String.format("/Sites/%s/%s", privateSiteModelByUser.getId(), ContainerName.links.toString())); + dataContent.deleteTree(folder); + + restClient.authenticateUser(testUserModel) + .withCoreAPI().usingSite(privateSiteModelByUser).getSiteContainer(ContainerName.links.toString()); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, privateSiteModelByUser.getId(), ContainerName.links.toString())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } +} diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java index 34517290d..40ceeb104 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java @@ -8,7 +8,6 @@ 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.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -103,7 +102,6 @@ public class GetSiteContainerSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Failed authentication get site container call returns status code 401") - @Bug(id="MNT-16904") public void unauthenticatedUserIsNotAuthorizedToRetrieveSiteContainer() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); From 0352ee0570c0d41bf80a00a81e2b40beded2d6b6 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Thu, 19 Jan 2017 11:56:39 +0200 Subject: [PATCH 0892/1491] updated to 2 tests and added a bug --- .../rest/ratings/AddRatingFullTests.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/ratings/AddRatingFullTests.java b/e2e-test/java/org/alfresco/rest/ratings/AddRatingFullTests.java index 5e3beb038..1b81e93de 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/AddRatingFullTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/AddRatingFullTests.java @@ -13,6 +13,7 @@ import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.apache.commons.lang3.RandomStringUtils; @@ -465,12 +466,12 @@ public class AddRatingFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Verify that Collaborator is NOT able to add a high rating to a file") @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) - public void contributorIsNotAbleToAddANegativeRatingToAFile() throws Exception + public void collaboratorIsNotAbleToAddAHighRatingToAFile() throws Exception { FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI() + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI() .usingResource(document) .rateStarsToDocument(10); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) @@ -481,6 +482,7 @@ public class AddRatingFullTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE); } + @Bug(id = "MNT-17375") @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Do not provide field - 'id'") @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) @@ -489,11 +491,11 @@ public class AddRatingFullTests extends RestTest FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"\":\"likes\", \"myRating\":\"2\"}"); + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"myRating\":\"true\"}"); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) .assertLastError() - .containsSummary(String.format(RestErrorModel.NO_CONTENT, "Unrecognized field \"\"")) - .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "Unrecognized field \"\"")) + .containsSummary(RestErrorModel.NULL_LIKE_RATING) + .containsErrorKey(RestErrorModel.NULL_LIKE_RATING) .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) .stackTraceIs(RestErrorModel.STACKTRACE); } @@ -506,11 +508,11 @@ public class AddRatingFullTests extends RestTest FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"likes\", \"\":\"2\"}"); + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"likes\"}"); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) .assertLastError() - .containsSummary(String.format(RestErrorModel.NO_CONTENT, "Unrecognized field \"\"")) - .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "Unrecognized field \"\"")) + .containsSummary(RestErrorModel.NULL_LIKE_RATING) + .containsErrorKey(RestErrorModel.NULL_LIKE_RATING) .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) .stackTraceIs(RestErrorModel.STACKTRACE); } From 0a88e5e231819966600b41cde6207394a4e60132 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Thu, 19 Jan 2017 12:51:59 +0200 Subject: [PATCH 0893/1491] minor changes --- .../rest/people/DeleteSiteMembershipRequestFullTests.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestFullTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestFullTests.java index f0440f84c..56030f691 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestFullTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestFullTests.java @@ -45,7 +45,7 @@ public class DeleteSiteMembershipRequestFullTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify COLLABORATOR is able to remove/cancel a site memebership request of admin to a moderated site and response is 204") + description = "Verify COLLABORATOR is able to remove/cancel a site memebership request of a user to a moderated site and response is 204") @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) public void collaboratorUserIsAbleToCancelSiteMembershipRequestOfAnotherUserToAModeratedSite() throws JsonToModelConversionException, DataPreparationException, Exception @@ -71,7 +71,7 @@ public class DeleteSiteMembershipRequestFullTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify CONTRIBUTOR is able to remove/cancel a site memebership request of admin to a moderated site and response is 204") + description = "Verify CONTRIBUTOR is able to remove/cancel a site memebership request of a user to a moderated site and response is 204") @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) public void contributorUserIsAbleToCancelSiteMembershipRequestOfAnotherUserToAModeratedSite() throws JsonToModelConversionException, DataPreparationException, Exception @@ -97,7 +97,7 @@ public class DeleteSiteMembershipRequestFullTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify CONSUMER is able to remove/cancel a site memebership request of admin to a moderated site and response is 204") + description = "Verify CONSUMER is able to remove/cancel a site memebership request of a user to a moderated site and response is 204") @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) public void consumerUserIsAbleToCancelSiteMembershipRequestOfAnotherUserToAModeratedSite() throws JsonToModelConversionException, DataPreparationException, Exception @@ -185,7 +185,7 @@ public class DeleteSiteMembershipRequestFullTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify COLLABORATOR removes/cancel twice same site memebership request and response is 204") + description = "Verify COLLABORATOR removes/cancel twice same site memebership request and response is 404") @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) public void userCancelsSiteMembershipRequestTwiceModeratedSite() throws JsonToModelConversionException, DataPreparationException, Exception From fbaa13aa029e5db931b6d064a650640ede0ef797 Mon Sep 17 00:00:00 2001 From: mionescu Date: Thu, 19 Jan 2017 14:43:09 +0200 Subject: [PATCH 0894/1491] test- added new test cases in GetSiteMembershipRequestFullTests.java core - added new enum: ACCEPT_ME --- .../GetSiteMembershipRequestFullTests.java | 280 ++++++++++++++++++ 1 file changed, 280 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestFullTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestFullTests.java new file mode 100644 index 000000000..7e9011f07 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestFullTests.java @@ -0,0 +1,280 @@ +package org.alfresco.rest.people; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestSiteMembershipRequestModel; +import org.alfresco.rest.model.RestTaskModel; +import org.alfresco.utility.constants.UserRole; +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.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.springframework.social.alfresco.api.entities.Site.Visibility; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class GetSiteMembershipRequestFullTests extends RestTest +{ + UserModel userModel, newMember, adminUser, userCollaborator, userConsumer, adminTenantUser, adminTenantUser2, + tenantUser, tenantUserAssignee; + SiteModel moderatedSite, secondModeratedSite; + RestSiteMembershipRequestModel returnedModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userModel = dataUser.createRandomTestUser(); + moderatedSite = dataSite.usingUser(userModel).createModeratedRandomSite(); + newMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify site manager can get site membership requests on moderated site and response is not found (200)") + public void siteManagerCanGetModeratedSiteMembershipRequests() throws Exception + { + UserModel moderatedUser = dataUser.createRandomTestUser(); + SiteModel moderatedSite = dataSite.usingUser(userModel).createModeratedRandomSite(); + restClient.authenticateUser(moderatedUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + returnedModel = restClient.authenticateUser(userModel).withCoreAPI().usingUser(moderatedUser).getSiteMembershipRequest(moderatedSite); + + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedModel.assertThat().field("id").is(moderatedSite.getId()) + .and().field("message").is("Please accept me") + .and().field("site.title").is(moderatedSite.getTitle()) + .and().field("site.visibility").is(Visibility.MODERATED.toString()) + .and().field("site.guid").isNotEmpty() + .and().field("site.description").is(moderatedSite.getDescription()) + .and().field("site.preset").is("site-dashboard"); + } + + @Bug(id = "ACE-2413") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify if person ID field is empty user can't get site membership requests on moderated site and response is not found (400)") + public void emptyPersonIdCantGetModeratedSiteMembershipRequests() throws Exception + { + UserModel emptyUser = new UserModel("", "password"); + restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + restClient.authenticateUser(userModel).withCoreAPI().usingUser(emptyUser).getSiteMembershipRequest(moderatedSite); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .containsSummary(String.format("The entity with id: personId is null. was not found")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Approve site membership request then verify get site membership requests - response is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + public void approveRequestThenGetSiteMembershipRequest() throws JsonToModelConversionException, DataPreparationException, Exception + { + UserModel userWithApprovedRequests = dataUser.createRandomTestUser(); + restClient.authenticateUser(userWithApprovedRequests).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestTaskModel taskModel = restClient.authenticateUser(userWithApprovedRequests).withWorkflowAPI().getTasks().getTaskModelByDescription(moderatedSite); + workflow.approveSiteMembershipRequest(userModel.getUsername(), userModel.getPassword(), taskModel.getId(), true, "Approve"); + + returnedModel = restClient.authenticateUser(userWithApprovedRequests).withCoreAPI().usingMe().getSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, userWithApprovedRequests.getUsername(), moderatedSite.getId())) + .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Reject site membership request then verify get site membership requests - response is 404") + public void rejectRequestThenGetSiteMembershipRequest() throws Exception + { + UserModel userWithRejectedRequests = dataUser.createRandomTestUser(); + restClient.authenticateUser(userWithRejectedRequests).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestTaskModel taskModel = restClient.authenticateUser(userWithRejectedRequests).withWorkflowAPI().getTasks().getTaskModelByDescription(moderatedSite); + workflow.approveSiteMembershipRequest(userModel.getUsername(), userModel.getPassword(), taskModel.getId(), false, "Rejected"); + + returnedModel = restClient.authenticateUser(userWithRejectedRequests).withCoreAPI().usingMe().getSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, userWithRejectedRequests.getUsername(), moderatedSite.getId())) + .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify entry details for get site favorite response with Rest API") + public void checkResponseSchemaForGetSiteMembershipRequest() throws Exception + { + dataUser.usingUser(userModel).addUserToSite(newMember, moderatedSite, UserRole.SiteContributor); + returnedModel = restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().getSiteMembershipRequest(moderatedSite); + + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedModel.assertThat().field("id").is(moderatedSite.getId()) + .and().field("message").is("Please accept me") + .and().field("site.title").is(moderatedSite.getTitle()) + .and().field("site.visibility").is(Visibility.MODERATED.toString()) + .and().field("site.guid").isNotEmpty() + .and().field("site.description").is(moderatedSite.getDescription()) + .and().field("site.preset").is("site-dashboard") + .and().field("site.role").is("SiteContributor"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify that getFavoriteSites request applies valid properties param") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + public void getSiteMembershipRequestWithValidPropertiesParam() throws Exception + { + RestSiteMembershipRequestModel returnedModel = restClient.authenticateUser(newMember).withParams("properties=message").withCoreAPI().usingAuthUser() + .getSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedModel.assertThat().fieldsCount().is(1).assertThat().field("message").isNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify request returns status 200 when using valid parameters") + public void getSiteMembershipRequestUsingParameters() throws Exception + { + RestSiteMembershipRequestModel returnedModel = restClient.withParams("message=Please accept me") + .authenticateUser(newMember).withCoreAPI().usingMe() + .getSiteMembershipRequest(moderatedSite); + + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedModel.assertThat().field("id").is(moderatedSite.getId()).and().field("site.title").is(moderatedSite.getTitle()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify admin user have permission to get site membership request of another user with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + public void adminIsAbleToGetSiteMembershipRequestOfAnotherUser() throws JsonToModelConversionException, Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + + returnedModel = restClient.authenticateUser(adminUser).withCoreAPI().usingUser(newMember).getSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedModel.assertThat().field("id").is(moderatedSite.getId()) + .and().field("message").is("Please accept me") + .and().field("site.title").is(moderatedSite.getTitle()) + .and().field("site.visibility").is(Visibility.MODERATED.toString()) + .and().field("site.guid").isNotEmpty() + .and().field("site.description").is(moderatedSite.getDescription()) + .and().field("site.preset").is("site-dashboard"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify user doesn't have permission to get site membership request of admin with Rest API and status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + public void userIsNotAbleToGetSiteMembershipRequestOfAdmin() throws JsonToModelConversionException, Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + + returnedModel = restClient.authenticateUser(newMember).withCoreAPI().usingUser(adminUser).getSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, adminUser.getUsername(), moderatedSite.getId())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER).stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify admin user doesn't have permission to get site membership request of another user with Rest API and status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + public void adminIsNotAbleToGetSiteMembershipRequestOfUser() throws JsonToModelConversionException, Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + + returnedModel = restClient.authenticateUser(newMember).withCoreAPI().usingUser(adminUser).getSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, adminUser.getUsername(), moderatedSite.getId())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify admin user doesn't have permission to get site membership request of another user with Rest API and status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + public void userIsNotAbleToGetSiteMembershipRequestOfAnotherUser() throws JsonToModelConversionException, Exception + { + userCollaborator = dataUser.createRandomTestUser(); + userConsumer = dataUser.createRandomTestUser(); + restClient.authenticateUser(userConsumer).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + dataUser.usingUser(userModel).addUserToSite(userConsumer, moderatedSite, UserRole.SiteConsumer); + restClient.authenticateUser(userCollaborator).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + dataUser.usingUser(userModel).addUserToSite(userCollaborator, moderatedSite, UserRole.SiteCollaborator); + + returnedModel = restClient.authenticateUser(userCollaborator).withCoreAPI().usingUser(userConsumer).getSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, userConsumer.getUsername(), moderatedSite.getId())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, description = "Add process item using by the admin in same network.") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL, TestGroup.NETWORKS }) + public void getSiteMembershipRequestByAdminSameNetwork() throws Exception + { + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser); + tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + + moderatedSite = dataSite.usingUser(adminTenantUser).createModeratedRandomSite(); + restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + + returnedModel = restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().getSiteMembershipRequest(moderatedSite); + + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedModel.assertThat().field("id").is(moderatedSite.getId()) + .and().field("message").is("Please accept me") + .and().field("site.title").is(moderatedSite.getTitle()) + .and().field("site.visibility").is(Visibility.MODERATED.toString()) + .and().field("site.guid").isNotEmpty() + .and().field("site.description").is(moderatedSite.getDescription()) + .and().field("site.preset").is("site-dashboard"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, description = "Add process item using by admin in other network.") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL, TestGroup.NETWORKS }) + public void getSiteMembershipRequestByAdminInOtherNetwork() throws Exception + { + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser); + tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); + + adminTenantUser2 = UserModel.getAdminTenantUser(); + restClient.usingTenant().createTenant(adminTenantUser2); + moderatedSite = dataSite.usingUser(adminTenantUser2).createModeratedRandomSite(); + + restClient.authenticateUser(adminTenantUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + returnedModel = restClient.authenticateUser(adminTenantUser2).withCoreAPI().usingAuthUser().getSiteMembershipRequest(moderatedSite); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, adminTenantUser2.getUsername().toLowerCase(), moderatedSite.getId())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + +} From e5ce067e42bfab6d90f90f15ea6594f5b59217f5 Mon Sep 17 00:00:00 2001 From: mionescu Date: Thu, 19 Jan 2017 14:48:07 +0200 Subject: [PATCH 0895/1491] formatting test case --- .../rest/people/GetSiteMembershipRequestFullTests.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestFullTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestFullTests.java index 7e9011f07..2987f71e3 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestFullTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestFullTests.java @@ -231,7 +231,8 @@ public class GetSiteMembershipRequestFullTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, description = "Add process item using by the admin in same network.") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Add process item using by the admin in same network.") @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL, TestGroup.NETWORKS }) public void getSiteMembershipRequestByAdminSameNetwork() throws Exception { @@ -254,7 +255,8 @@ public class GetSiteMembershipRequestFullTests extends RestTest .and().field("site.preset").is("site-dashboard"); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, description = "Add process item using by admin in other network.") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Add process item using by admin in other network.") @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL, TestGroup.NETWORKS }) public void getSiteMembershipRequestByAdminInOtherNetwork() throws Exception { From b783324b7193eda097ed069c6652e5f8c60a56c6 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Thu, 19 Jan 2017 16:39:35 +0200 Subject: [PATCH 0896/1491] Merge master into TAS-2801 --- .../org/alfresco/rest/sites/GetSiteContainerFullTests.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerFullTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerFullTests.java index 5a4a5e2cd..bf9b2f7b4 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerFullTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerFullTests.java @@ -127,7 +127,7 @@ public class GetSiteContainerFullTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if user cannot get container request for a private site created by admin and status code is 403") + description= "Verify if user cannot get container request for a private site created by admin and status code is 404") public void userCannotGetContainerForPrivateSiteCreatedByAdmin() throws Exception { restClient.authenticateUser(testUserModel) @@ -173,4 +173,4 @@ public class GetSiteContainerFullTests extends RestTest .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) .stackTraceIs(RestErrorModel.STACKTRACE); } -} +} \ No newline at end of file From a21f5ac0269887ed1433d71acaa683ddfa6273b7 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Thu, 19 Jan 2017 17:01:00 +0200 Subject: [PATCH 0897/1491] Merge master into TAS-2803 --- .../org/alfresco/rest/sites/RemoveSiteMemberFullTests.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberFullTests.java b/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberFullTests.java index bc483ab06..164966644 100644 --- a/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberFullTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberFullTests.java @@ -70,7 +70,7 @@ public class RemoveSiteMemberFullTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Verify that admin can delete a site member with Collaborator role and gets status code 204") @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) - public void adminIsNotAbleToDeleteSiteMemberWithCollaboratorRole() throws Exception + public void adminIsAbleToDeleteSiteMemberWithCollaboratorRole() throws Exception { restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(siteModel) .deleteSiteMember(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); @@ -119,7 +119,7 @@ public class RemoveSiteMemberFullTests extends RestTest } @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin can not delete a site member twice and gets status code 204") + description = "Verify that admin can not delete a site member twice and gets status code 404 for the second attempt") @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) @Bug(id="ACE-5447") public void adminIsNotAbleToRemoveSiteMemberTwice() throws Exception @@ -147,4 +147,4 @@ public class RemoveSiteMemberFullTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() .containsSummary(RestErrorModel.ENTITY_NOT_FOUND); } -} +} \ No newline at end of file From fad8cefdeffb396965ef1dcf815c1752272a25da Mon Sep 17 00:00:00 2001 From: Andrei Rusu Date: Fri, 20 Jan 2017 08:14:50 +0200 Subject: [PATCH 0898/1491] added getNodeTagsFull tests. updated getNodeTagsSanity tests --- .../rest/tags/GetNodeTagsFullTests.java | 195 ++++++++++++++++++ .../rest/tags/GetNodeTagsSanityTests.java | 3 +- 2 files changed, 196 insertions(+), 2 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/tags/GetNodeTagsFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsFullTests.java b/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsFullTests.java new file mode 100644 index 000000000..b82d8eef1 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsFullTests.java @@ -0,0 +1,195 @@ +package org.alfresco.rest.tags; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestTagModelsCollection; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.RandomData; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class GetNodeTagsFullTests extends RestTest +{ + private UserModel adminUserModel, userModel; + private SiteModel siteModel; + private FileModel document; + private String tagValue; + private String tagValue2; + private RestTagModelsCollection returnedCollection; + private ListUserWithRoles usersWithRoles; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + adminUserModel = dataUser.getAdminUser(); + restClient.authenticateUser(adminUserModel); + siteModel = dataSite.usingUser(adminUserModel).createPrivateRandomSite(); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + + tagValue = RandomData.getRandomName("tag"); + restClient.withCoreAPI().usingResource(document).addTag(tagValue); + + tagValue2 = RandomData.getRandomName("tag"); + restClient.withCoreAPI().usingResource(document).addTag(tagValue2); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify site Manager is able to get node tags " + + "using properties parameter.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) + public void siteManagerIsAbleToRetrieveNodeTagsWithPropertiesParameter() throws JsonToModelConversionException, Exception + { + returnedCollection = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withParams("properties=tag").withCoreAPI().usingResource(document).getNodeTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat().entriesListContains("tag", tagValue.toLowerCase()) + .and().entriesListContains("tag", tagValue2.toLowerCase()) + .and().entriesListDoesNotContain("id"); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify that Collaborator user is not able to get node tags " + + "using site id instead of node id.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) + public void collaboratorGetNodeTagsUseSiteIdInsteadOfNodeId() throws JsonToModelConversionException, Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + + file.setNodeRef(siteModel.getId()); + returnedCollection = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(file).getNodeTags(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, file.getNodeRef())); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "With admin get node tags and use skipCount parameter. Check pagination and maxItems.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) + public void useSkipCountCheckPaginationAndMaxItems() throws JsonToModelConversionException, Exception + { + returnedCollection = restClient.authenticateUser(adminUserModel) + .withParams("skipCount=1").withCoreAPI().usingResource(document).getNodeTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.getPagination().assertThat().field("maxItems").is(100) + .and().field("hasMoreItems").is("false") + .and().field("totalItems").is(2) + .and().field("count").is("1"); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "With admin get node tags and use maxItems parameter. Check pagination.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) + public void useMaxItemsParameterCheckPagination() throws JsonToModelConversionException, Exception + { + returnedCollection = restClient.authenticateUser(adminUserModel) + .withParams("maxItems=1").withCoreAPI().usingResource(document).getNodeTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.getPagination().assertThat().field("maxItems").is(1) + .and().field("hasMoreItems").is("true") + .and().field("totalItems").is("2") + .and().field("count").is("1") + .and().field("skipCount").is("0"); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Get tags from a node to which user does not have access." + + " Check default error model schema") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) + public void getTagsFromNodeWithUserWhoDoesNotHaveAccessCheckDefaultErrorModelSchema() throws JsonToModelConversionException, Exception + { + returnedCollection = restClient.authenticateUser(userModel) + .withCoreAPI().usingResource(document).getNodeTags(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Using manager user get only one tag.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) + public void usingManagerGetOnlyOneTag() throws JsonToModelConversionException, Exception + { + FileModel file = dataContent.usingAdmin().usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.withCoreAPI().usingResource(file).addTag(tagValue); + + returnedCollection = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(file).getNodeTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.getPagination().assertThat().field("maxItems").is(100) + .and().field("hasMoreItems").is("false") + .and().field("totalItems").is("1") + .and().field("count").is("1") + .and().field("skipCount").is("0"); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Using admin get last 2 tags and skip first 2 tags") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) + public void adminUserGetLast2TagsAndSkipFirst2Tags() throws JsonToModelConversionException, Exception + { + String firstTag = "1st tag"; + String secondTag = "2nd tag"; + String thirdTag = "3rd tag"; + String fourthTag = "4th tag"; + FileModel file = dataContent.usingAdmin().usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addTag(firstTag); + restClient.withCoreAPI().usingResource(file).addTag(secondTag); + restClient.withCoreAPI().usingResource(file).addTag(thirdTag); + restClient.withCoreAPI().usingResource(file).addTag(fourthTag); + + returnedCollection = restClient.withParams("skipCount=2").withCoreAPI().usingResource(file).getNodeTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + returnedCollection.assertThat().entriesListContains("tag", thirdTag.toLowerCase()) + .and().entriesListContains("tag", fourthTag.toLowerCase()); + returnedCollection.getPagination().assertThat().field("maxItems").is(100) + .and().field("hasMoreItems").is("false") + .and().field("totalItems").is("4") + .and().field("count").is("2") + .and().field("skipCount").is("2"); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "With admin get node tags and use maxItems=0.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) + public void getTagsWithZeroMaxItems() throws JsonToModelConversionException, Exception + { + returnedCollection = restClient.authenticateUser(adminUserModel) + .withParams("maxItems=0").withCoreAPI().usingResource(document).getNodeTags(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that using high skipCount parameter returns status code 200.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) + public void getTagsWithHighSkipCount() throws JsonToModelConversionException, Exception + { + returnedCollection = restClient.authenticateUser(adminUserModel).withParams("skipCount=10000") + .withCoreAPI().usingResource(document).getNodeTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.getPagination().assertThat().field("maxItems").is(100) + .and().field("hasMoreItems").is("false") + .and().field("totalItems").is("2") + .and().field("count").is("0") + .and().field("skipCount").is("10000"); + returnedCollection.assertThat().entriesListCountIs(0); + } +} diff --git a/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java index 19b263703..9c2545c73 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java @@ -12,7 +12,6 @@ import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -120,7 +119,7 @@ public class GetNodeTagsSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to get node tags") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) - @Bug(id="MNT-16904") +// @Bug(id="MNT-16904") public void unauthenticatedUserIsNotAbleToRetrieveNodeTags() throws JsonToModelConversionException, Exception { restClient.authenticateUser(new UserModel("random user", "random password")); From cdffcf6c078af49427cd628381929203fe856e3a Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Fri, 20 Jan 2017 11:34:13 +0200 Subject: [PATCH 0899/1491] add full tests for GetSiteMembers and small updates --- .../rest/sites/GetSiteMembersCoreTests.java | 5 +- .../rest/sites/GetSiteMembersFullTests.java | 161 ++++++++++++++++++ 2 files changed, 165 insertions(+), 1 deletion(-) create mode 100644 e2e-test/java/org/alfresco/rest/sites/GetSiteMembersFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersCoreTests.java index 5abaf3d86..ae7381b62 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersCoreTests.java @@ -58,7 +58,10 @@ public class GetSiteMembersCoreTests extends RestTest restClient.authenticateUser(publicSiteContributor).withParams("maxItems=0") .withCoreAPI().usingSite(publicSite).getSiteMembers(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); + .assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) + .containsErrorKey(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); restClient.authenticateUser(publicSiteContributor).withParams("maxItems=A") .withCoreAPI().usingSite(publicSite).getSiteMembers(); diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersFullTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersFullTests.java new file mode 100644 index 000000000..eb0085252 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersFullTests.java @@ -0,0 +1,161 @@ +package org.alfresco.rest.sites; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestSiteMemberModel; +import org.alfresco.rest.model.RestSiteMemberModelsCollection; +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.HttpStatus; +import org.springframework.social.alfresco.api.entities.Role; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * + * @author Cristina Axinte + * + */ +public class GetSiteMembersFullTests extends RestTest +{ + private UserModel userModel, publicSiteContributor; + private UserModel moderatedSiteContributor, moderatedSiteCollaborator, moderatedSiteConsumer; + private SiteModel publicSite, moderatedSite, moderatedSite2; + private RestSiteMemberModelsCollection siteMembers; + private RestSiteMemberModel firstSiteMember, secondSiteMember, thirdSiteMember, fourthSiteMember; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + publicSiteContributor = dataUser.createRandomTestUser(); + moderatedSiteContributor = dataUser.createRandomTestUser(); + moderatedSiteCollaborator = dataUser.createRandomTestUser(); + moderatedSiteConsumer = dataUser.createRandomTestUser(); + publicSite = dataSite.usingUser(userModel).createPublicRandomSite(); + moderatedSite = dataSite.usingUser(userModel).createModeratedRandomSite(); + moderatedSite2 = dataSite.usingUser(userModel).createModeratedRandomSite(); + dataUser.addUserToSite(publicSiteContributor, publicSite, UserRole.SiteContributor); + dataUser.addUserToSite(publicSiteContributor, publicSite, UserRole.SiteContributor); + dataUser.addUserToSite(moderatedSiteContributor, moderatedSite, UserRole.SiteContributor); + dataUser.addUserToSite(moderatedSiteCollaborator, moderatedSite, UserRole.SiteCollaborator); + dataUser.addUserToSite(moderatedSiteConsumer, moderatedSite, UserRole.SiteConsumer); + dataUser.addUserToSite(moderatedSiteContributor, moderatedSite2, UserRole.SiteContributor); + + siteMembers = restClient.authenticateUser(userModel).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(2).onModel(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @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(userModel).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", userModel.getUsername()) + .and().entriesListContains("role", UserRole.SiteContributor.toString()) + .and().entriesListContains("id", moderatedSiteContributor.getUsername()) + .and().entriesListContains("role", UserRole.SiteCollaborator.toString()) + .and().entriesListContains("id", moderatedSiteCollaborator.getUsername()) + .and().entriesListContains("role", UserRole.SiteConsumer.toString()) + .and().entriesListContains("id", moderatedSiteConsumer.getUsername()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @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(userModel).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.FULL }) + @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(userModel).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.FULL }) + @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(userModel).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.FULL }) + @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(userModel).withCoreAPI() + .usingSite(moderatedSite2).getSiteMembers(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembers.assertThat().entriesListContains("role", Role.SiteManager.toString()) + .and().entriesListContains("id", userModel.getUsername()) + .and().entriesListDoesNotContain("id", userNotJoined.getUsername()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @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 getSiteMembersAfterRemoveTheSiteMember() throws Exception + { + siteMembers = restClient.authenticateUser(userModel).withCoreAPI() + .usingSite(moderatedSite2).getSiteMembers(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembers.assertThat().entriesListCountIs(2); + + restClient.authenticateUser(userModel).withCoreAPI().usingSite(moderatedSite2).deleteSiteMember(moderatedSiteContributor); + + siteMembers = restClient.authenticateUser(userModel).withCoreAPI() + .usingSite(moderatedSite2).getSiteMembers(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembers.assertThat().entriesListCountIs(1) + .and().entriesListContains("role", Role.SiteManager.toString()) + .and().entriesListContains("id", userModel.getUsername()); + } +} From 3eec29242f77499ad09b301ae55233e59e16af3a Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Fri, 20 Jan 2017 12:05:35 +0200 Subject: [PATCH 0900/1491] fix default.properties --- e2e-test/resources/default.properties | 141 +++++++++++++------------- 1 file changed, 71 insertions(+), 70 deletions(-) diff --git a/e2e-test/resources/default.properties b/e2e-test/resources/default.properties index 460444321..2e4c58893 100644 --- a/e2e-test/resources/default.properties +++ b/e2e-test/resources/default.properties @@ -1,70 +1,71 @@ -# dataprep related -alfresco.scheme=http -alfresco.server=localhost -alfresco.port=8080 - -# in containers we cannot access directly JMX, so we will use http://jolokia.org agent -# disabling this we will use direct JMX calls to server -jmx.useJolokiaAgent=false - -# credentials -admin.user=admin -admin.password=admin - -# TEST MANAGEMENT SECTION - Test Rail -# -# (currently supporting Test Rail v5.2.1.3472 integration) -# -# Example of configuration: -# ------------------------------------------------------ -# if testManagement.enabled=true we enabled TestRailExecutorListener (if used in your suite xml file) -# testManagement.updateTestExecutionResultsOnly=true (this will just update the results of a test: no step will be updated - good for performance) -# testManagement.endPoint=https://alfresco.testrail.com/ -# testManagement.username= -# testManagement.apiKey= -# testManagement.project= -# testManagement.includeOnlyTestCasesExecuted=false #if you want to include in your run ONLY the test cases that you run, then set this value to false -# testManagement.rateLimitInSeconds=1 #is the default rate limit after what minimum time, should we upload the next request. http://docs.gurock.com/testrail-api2/introduction #Rate Limit -# testManagement.suiteId=23 (the id of the Master suite) -# ------------------------------------------------------ -testManagement.enabled=true -testManagement.endPoint=https://alfresco.testrail.com/ -testManagement.username=tas.alfresco@gmail.com -testManagement.apiKey=EYpY7.fV0AoMGWbmyuVC-k5u.nzwHy6a.QWzJq8.S -testManagement.project=7 -testManagement.includeOnlyTestCasesExecuted=true -testManagement.rateLimitInSeconds=1 -testManagement.testRun=MyTestRunInTestRail -testManagement.suiteId=12 - -# The location of the reports path -reports.path=./target/reports - -# -# Database Section -# You should provide here the database URL, that can be a differed server as alfresco. -# https://docs.oracle.com/javase/tutorial/jdbc/basics/connecting.html -# -# Current supported db.url: -# -# MySQL: -# db.url = jdbc:mysql://${alfresco.server}:3306/alfresco -# -# PostgreSQL: -# db.url = jdbc:postgresql://:3306/alfresco -# -# Oracle: -# db.url = jdbc:oracle://:3306/alfresco -# -# MariaDB: -# db.url = jdbc:mariadb://:3306/alfresco -# -db.url = jdbc:mysql://${alfresco.server}:3306/alfresco -db.username = alfresco -db.password = alfresco - -# Server Health section -# in ServerHealth#isServerReachable() - could also be shown. -# enable this option to view if on server there are tenants or not -serverHealth.showTenants=true +# dataprep related +alfresco.scheme=http +alfresco.server=localhost +alfresco.port=8080 + +# credentials +admin.user=admin +admin.password=admin + +# in containers we cannot access directly JMX, so we will use http://jolokia.org agent +# disabling this we will use direct JMX calls to server +jmx.useJolokiaAgent=false + +# Server Health section +# in ServerHealth#isServerReachable() - could also be shown. +# enable this option to view if on server there are tenants or not +serverHealth.showTenants=true + +# TEST MANAGEMENT SECTION - Test Rail +# +# (currently supporting Test Rail v5.2.1.3472 integration) +# +# Example of configuration: +# ------------------------------------------------------ +# if testManagement.enabled=true we enabled TestRailExecutorListener (if used in your suite xml file) +# testManagement.updateTestExecutionResultsOnly=true (this will just update the results of a test: no step will be updated - good for performance) +# testManagement.endPoint=https://alfresco.testrail.com/ +# testManagement.username= +# testManagement.apiKey= +# testManagement.project= +# testManagement.includeOnlyTestCasesExecuted=true #if you want to include in your run ONLY the test cases that you run, then set this value to false +# testManagement.rateLimitInSeconds=1 #is the default rate limit after what minimum time, should we upload the next request. http://docs.gurock.com/testrail-api2/introduction #Rate Limit +# testManagement.suiteId=23 (the id of the Master suite) +# ------------------------------------------------------ +testManagement.enabled=false +testManagement.endPoint=https://alfresco.testrail.com/ +testManagement.username=tas.alfresco@gmail.com +testManagement.apiKey=EYpY7.fV0AoMGWbmyuVC-k5u.nzwHy6a.QWzJq8.S +testManagement.project=7 +testManagement.includeOnlyTestCasesExecuted=true +testManagement.rateLimitInSeconds=1 +testManagement.testRun=MyTestRunInTestRail +testManagement.suiteId=12 + +# The location of the reports path +reports.path=./target/reports + +# +# Database Section +# You should provide here the database URL, that can be a differed server as alfresco. +# https://docs.oracle.com/javase/tutorial/jdbc/basics/connecting.html +# +# Current supported db.url: +# +# MySQL: +# db.url = jdbc:mysql://${alfresco.server}:3306/alfresco +# +# PostgreSQL: +# db.url = jdbc:postgresql://:3306/alfresco +# +# Oracle: +# db.url = jdbc:oracle://:3306/alfresco +# +# MariaDB: +# db.url = jdbc:mariadb://:3306/alfresco +# +db.url = jdbc:mysql://${alfresco.server}:3306/alfresco +db.username = alfresco +db.password = alfresco + From df5be70469539fdf51e9a62a102fd4aaa3bb1a69 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Fri, 20 Jan 2017 13:44:56 +0200 Subject: [PATCH 0901/1491] Add full tests for get rating REST API call --- .../rest/ratings/GetRatingFullTests.java | 199 ++++++++++++++++++ 1 file changed, 199 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/ratings/GetRatingFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/ratings/GetRatingFullTests.java b/e2e-test/java/org/alfresco/rest/ratings/GetRatingFullTests.java new file mode 100644 index 000000000..3fdc99e28 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/ratings/GetRatingFullTests.java @@ -0,0 +1,199 @@ +package org.alfresco.rest.ratings; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestRatingModel; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.exception.DataPreparationException; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.apache.commons.lang.RandomStringUtils; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class GetRatingFullTests extends RestTest +{ + private SiteModel siteModel; + private UserModel adminUserModel, userModel; + private RestRatingModel returnedRatingModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws DataPreparationException + { + adminUserModel = dataUser.getAdminUser(); + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingAdmin().createPublicRandomSite(); + dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Check default error schema") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) + public void checkDefaultErrorSchema() throws Exception + { + FileModel document = dataContent.usingSite(siteModel).usingAdmin().createContent(DocumentType.TEXT_PLAIN); + String randomNodeRef = RandomStringUtils.randomAlphanumeric(10); + document.setNodeRef(randomNodeRef); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, randomNodeRef)) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Get rating of a folder that has only stars") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) + public void getRatingOfFolderThatHasOnlyStars() throws Exception + { + FolderModel folder = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); + restClient.authenticateUser(userModel).withCoreAPI().usingResource(folder).rateStarsToDocument(3); + returnedRatingModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(folder).getFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedRatingModel.assertThat().field("id").is("fiveStar") + .getAggregate().assertThat().field("numberOfRatings").is("1") + .assertThat().field("average").is("3.0"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Get rating of a folder that has both likes and stars") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) + public void getRatingOfFolderThatHasLikedAndStars() throws Exception + { + FolderModel folder = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); + restClient.authenticateUser(userModel).withCoreAPI().usingResource(folder).rateStarsToDocument(3); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(folder).likeDocument(); + + returnedRatingModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(folder).getFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedRatingModel.assertThat().field("id").is("fiveStar") + .getAggregate().assertThat().field("numberOfRatings").is("1") + .assertThat().field("average").is("3.0"); + + returnedRatingModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(folder).getLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedRatingModel.assertThat().field("id").is("likes") + .assertThat().field("myRating").is("true"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Get rating of a folder that has no ratings") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) + public void getRatingOfFolderThatHasNoRatings() throws Exception + { + FolderModel folder = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); + + returnedRatingModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(folder).getFiveStarRating(); + returnedRatingModel.getAggregate().assertThat().field("numberOfRatings").is("0"); + + returnedRatingModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(folder).getLikeRating(); + returnedRatingModel.getAggregate().assertThat().field("numberOfRatings").is("0"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Get rating of a folder after rating was deleted") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) + public void getDeletedRatingOfAFolder() throws Exception + { + FolderModel folder = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); + restClient.authenticateUser(userModel).withCoreAPI().usingResource(folder).rateStarsToDocument(3); + restClient.authenticateUser(userModel).withCoreAPI().usingResource(folder).deleteFiveStarRating(); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(folder).likeDocument(); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(folder).deleteLikeRating(); + + returnedRatingModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(folder).getFiveStarRating(); + returnedRatingModel.assertThat().field("id").is("fiveStar").getAggregate().assertThat().field("numberOfRatings").is("0") + .assertThat().field("average").isNull(); + + returnedRatingModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(folder).getLikeRating(); + returnedRatingModel.assertThat().field("id").is("likes").assertThat().field("myRating").isNull() + .getAggregate().assertThat().field("numberOfRatings").is("0"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Get rating of a file after rating was deleted") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) + public void getDeletedRatingOfAFile() throws Exception + { + FileModel file = dataContent.usingUser(adminUserModel).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(userModel).withCoreAPI().usingResource(file).rateStarsToDocument(3); + restClient.authenticateUser(userModel).withCoreAPI().usingResource(file).deleteFiveStarRating(); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).likeDocument(); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).deleteLikeRating(); + + returnedRatingModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getFiveStarRating(); + returnedRatingModel.assertThat().field("id").is("fiveStar").getAggregate().assertThat().field("numberOfRatings").is("0") + .assertThat().field("average").isNull(); + + returnedRatingModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getLikeRating(); + returnedRatingModel.assertThat().field("id").is("likes").assertThat().field("myRating").isNull() + .getAggregate().assertThat().field("numberOfRatings").is("0"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Get rating of another user as admin") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) + public void getRatingOfAnotherUserAsAdmin() throws Exception + { + FileModel file = dataContent.usingUser(adminUserModel).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(userModel).withCoreAPI().usingResource(file).rateStarsToDocument(3); + restClient.authenticateUser(userModel).withCoreAPI().usingResource(file).likeDocument(); + + returnedRatingModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getFiveStarRating(); + returnedRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").isNull() + .getAggregate().assertThat().field("numberOfRatings").is("1").assertThat().field("average").is("3.0"); + + returnedRatingModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getLikeRating(); + returnedRatingModel.assertThat().field("id").is("likes").assertThat().field("myRating").isNull() + .getAggregate().assertThat().field("numberOfRatings").is("1"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Get rating of admin with another user") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) + public void getRatingOfAdminWithAnotherUser() throws Exception + { + FileModel file = dataContent.usingUser(userModel).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).rateStarsToDocument(3); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).likeDocument(); + + returnedRatingModel = restClient.authenticateUser(userModel).withCoreAPI().usingResource(file).getFiveStarRating(); + returnedRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").isNull() + .getAggregate().assertThat().field("numberOfRatings").is("1").assertThat().field("average").is("3.0"); + + returnedRatingModel = restClient.authenticateUser(userModel).withCoreAPI().usingResource(file).getLikeRating(); + returnedRatingModel.assertThat().field("id").is("likes").assertThat().field("myRating").isNull() + .getAggregate().assertThat().field("numberOfRatings").is("1"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Get five star rating") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) + public void getFiveStarRating() throws Exception + { + FileModel file = dataContent.usingUser(userModel).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).rateStarsToDocument(5); + + returnedRatingModel = restClient.authenticateUser(userModel).withCoreAPI().usingResource(file).getFiveStarRating(); + returnedRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").isNull() + .getAggregate().assertThat().field("numberOfRatings").is("1").assertThat().field("average").is("5.0"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Get one star rating") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) + public void getOneStarRating() throws Exception + { + FileModel file = dataContent.usingUser(userModel).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).rateStarsToDocument(1); + + returnedRatingModel = restClient.authenticateUser(userModel).withCoreAPI().usingResource(file).getFiveStarRating(); + returnedRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").isNull() + .getAggregate().assertThat().field("numberOfRatings").is("1").assertThat().field("average").is("1.0"); + } +} \ No newline at end of file From 50e322b296437c80fce5cd519f79055279866487 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Fri, 20 Jan 2017 14:17:06 +0200 Subject: [PATCH 0902/1491] Added GetSiteMemberFullTests --- .../rest/sites/GetSiteMemberFullTests.java | 191 ++++++++++++++++++ 1 file changed, 191 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/sites/GetSiteMemberFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberFullTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberFullTests.java new file mode 100644 index 000000000..fa7e0e875 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberFullTests.java @@ -0,0 +1,191 @@ +package org.alfresco.rest.sites; + +import org.alfresco.rest.RestTest; +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; + +public class GetSiteMemberFullTests extends RestTest +{ + private UserModel adminUser; + private SiteModel siteModel; + private SiteModel moderatedSiteModel; + private SiteModel privateSiteModel; + private ListUserWithRoles usersWithRoles; + private UserModel manager, consumer, collaborator, contributor; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws DataPreparationException + { + adminUser = dataUser.getAdminUser(); + siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); + moderatedSiteModel = dataSite.usingUser(adminUser).createModeratedRandomSite(); + privateSiteModel = dataSite.usingUser(adminUser).createPrivateRandomSite(); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + + consumer = usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer); + manager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); + collaborator = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); + contributor = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); + + 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.FULL }) + @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(siteModel).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.FULL }) + @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(siteModel).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.FULL }) + @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(siteModel).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.FULL }) + @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(siteModel).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.FULL }) + @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.FULL }) + @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 userThatIsNotMemberOfPrivateSiteIsNotAbleToGetSiteMember() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + + restClient.authenticateUser(newMember).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.FULL }) + 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.FULL }) + @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, siteModel, 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.FULL }) + @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.FULL }) + @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.FULL }) + @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 userThatIsNotMemberOfModeratedSiteIsAbleToGetSiteMember() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + + restClient.authenticateUser(newMember).withCoreAPI().usingSite(moderatedSiteModel).getSiteMember(consumer); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @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(siteModel).usingParams("properties=id").getSiteMember(consumer) + .assertThat().fieldsCount().is(1) + .and().field("id").isNotEmpty() + .and().field("role").isNull(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } +} From f3522222c08fd143e969cce1ad10845415520805 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Fri, 20 Jan 2017 16:21:16 +0200 Subject: [PATCH 0903/1491] added description for issue MNT-16904 for tests failed only on env with tenants --- .../java/org/alfresco/rest/comments/AddCommentCoreTests.java | 2 +- .../org/alfresco/rest/comments/AddCommentSanityTests.java | 2 +- .../org/alfresco/rest/comments/DeleteCommentSanityTests.java | 2 +- .../org/alfresco/rest/comments/GetCommentsSanityTests.java | 2 +- .../org/alfresco/rest/comments/UpdateCommentSanityTests.java | 2 +- .../org/alfresco/rest/favorites/AddFavoritesSanityTests.java | 2 +- .../alfresco/rest/favorites/DeleteFavoriteSanityTests.java | 2 +- .../org/alfresco/rest/favorites/GetFavoriteSanityTests.java | 2 +- .../org/alfresco/rest/favorites/GetFavoritesSanityTests.java | 2 +- .../org/alfresco/rest/people/AddFavoriteSiteSanityTests.java | 2 +- .../rest/people/DeleteSiteMembershipRequestSanityTests.java | 2 +- .../org/alfresco/rest/people/GetFavoriteSiteSanityTests.java | 2 +- .../org/alfresco/rest/people/GetFavoriteSitesSanityTests.java | 2 +- .../alfresco/rest/people/GetPeoplePreferenceSanityTests.java | 2 +- .../alfresco/rest/people/GetPeoplePreferencesSanityTests.java | 2 +- .../rest/people/GetSiteMembershipRequestCoreTests.java | 4 ++-- .../rest/people/GetSiteMembershipRequestsSanityTests.java | 2 +- .../alfresco/rest/people/GetSiteMembershipSanityTests.java | 2 +- .../rest/people/GetSitesMembershipInformationSanityTests.java | 2 +- .../java/org/alfresco/rest/ratings/AddRatingSanityTests.java | 4 ++-- .../org/alfresco/rest/ratings/DeleteRatingSanityTests.java | 2 +- .../java/org/alfresco/rest/ratings/GetRatingSanityTests.java | 2 +- .../java/org/alfresco/rest/ratings/GetRatingsSanityTests.java | 2 +- .../org/alfresco/rest/sites/AddSiteMemberSanityTests.java | 2 +- .../org/alfresco/rest/sites/GetSiteContainersSanityTests.java | 2 +- .../org/alfresco/rest/sites/GetSiteMemberSanityTests.java | 2 +- .../org/alfresco/rest/sites/GetSiteMembersSanityTests.java | 2 +- e2e-test/java/org/alfresco/rest/sites/GetSiteSanityTests.java | 2 +- .../java/org/alfresco/rest/sites/GetSitesSanityTests.java | 2 +- .../org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java | 2 +- .../org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java | 2 +- e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java | 2 +- e2e-test/java/org/alfresco/rest/tags/AddTagsSanityTests.java | 2 +- .../java/org/alfresco/rest/tags/DeleteTagSanityTests.java | 2 +- .../java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java | 2 +- e2e-test/java/org/alfresco/rest/tags/GetTagSanityTests.java | 2 +- e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java | 2 +- .../java/org/alfresco/rest/tags/UpdateTagSanityTests.java | 2 +- .../rest/workflow/tasks/DeleteTaskVariableCoreTests.java | 2 +- .../alfresco/rest/workflow/tasks/RemoveTaskItemCoreTests.java | 2 +- .../rest/workflow/tasks/UpdateTaskVariableCoreTests.java | 2 +- 41 files changed, 43 insertions(+), 43 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentCoreTests.java b/e2e-test/java/org/alfresco/rest/comments/AddCommentCoreTests.java index 23ea6a54f..7f6955cd9 100644 --- a/e2e-test/java/org/alfresco/rest/comments/AddCommentCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/AddCommentCoreTests.java @@ -138,7 +138,7 @@ public class AddCommentCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify comment cannot be added if empty network ID is provided") - @Bug(id = "MNT-16904") + @Bug(id = "MNT-16904", description = "It fails only on environment with tenants") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) public void addCommentUsingEmptyNetworkId() throws JsonToModelConversionException, Exception { diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java index c5625db02..93606fb20 100644 --- a/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java @@ -101,7 +101,7 @@ public class AddCommentSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user gets status code 401 on post comments call") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) - @Bug(id = "MNT-16904") + @Bug(id = "MNT-16904", description = "It fails only on environment with tenants") public void unauthenticatedUserIsNotAbleToAddComment() throws JsonToModelConversionException, Exception { restClient.authenticateUser(new UserModel("random user", "random password")); diff --git a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentSanityTests.java index 32ac39335..aecc7fd06 100644 --- a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentSanityTests.java @@ -95,7 +95,7 @@ public class DeleteCommentSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify User gets status code 401 if authentication call fails") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) - @Bug(id="MNT-16904") + @Bug(id="MNT-16904", description = "It fails only on environment with tenants") public void userIsNotAbleToDeleteCommentIfAuthenticationFails() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); diff --git a/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java index d3e2927ac..f781e0eea 100644 --- a/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java @@ -100,7 +100,7 @@ public class GetCommentsSanityTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.SANITY, description= "Verify Manager user gets status code 401 if authentication call fails") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) - @Bug(id="MNT-16904") + @Bug(id="MNT-16904", description = "It fails only on environment with tenants") public void managerIsNotAbleToRetrieveCommentIfAuthenticationFails() throws JsonToModelConversionException, Exception { UserModel nonexistentModel = new UserModel("nonexistentUser", "nonexistentPassword"); diff --git a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentSanityTests.java index b77a895da..c724ef6e3 100644 --- a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentSanityTests.java @@ -100,7 +100,7 @@ public class UpdateCommentSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user gets status code 401 on update comment call") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) - @Bug(id="MNT-16904") + @Bug(id = "MNT-16904", description = "fails only on environment with tenants") public void unauthenticatedUserIsNotAbleToUpdateComment() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); diff --git a/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesSanityTests.java index 672fed851..4373b0050 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesSanityTests.java @@ -87,7 +87,7 @@ public class AddFavoritesSanityTests extends RestTest restPersonFavoritesModel.and().field("targetGuid").is(siteModel.getGuid()); } - @Bug(id="MNT-16904") + @Bug(id="MNT-16904", description = "It fails only on environment with tenants") @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Manager user gets status code 401 if authentication call fails") @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) diff --git a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteSanityTests.java index 4aabae20f..cc0ed1abf 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteSanityTests.java @@ -157,7 +157,7 @@ public class DeleteFavoriteSanityTests extends RestTest .assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } - @Bug(id = "MNT-16904") + @Bug(id = "MNT-16904", description = "It fails only on environment with tenants") @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify user gets status code 401 if authentication call fails") @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java index 62613ef1f..86de14f71 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java @@ -281,7 +281,7 @@ public class GetFavoriteSanityTests extends RestTest description = "Verify user gets status code 401 if authentication call fails") @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) @Bug(id = "MNT-16904", description = "fails only on environment with tenants") - public void userIsNotAbleToRetrieveFavoritesIfAuthenticationFails() throws JsonToModelConversionException, Exception + public void userIsNotAbleToRetrieveFavoriteSiteIfAuthenticationFails() throws JsonToModelConversionException, Exception { UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); siteManager.setPassword("wrongPassword"); diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java index 38c0789f1..c27b699fe 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java @@ -185,7 +185,7 @@ public class GetFavoritesSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify user gets status code 401 if authentication call fails") @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - @Bug(id = "MNT-16904", description = "fails only on environment with tenants") + @Bug(id = "MNT-16904", description = "It fails only on environment with tenants") public void userIsNotAbleToRetrieveFavoritesIfAuthenticationFails() throws JsonToModelConversionException, Exception { UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); diff --git a/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteSanityTests.java index a6c8a7c74..9e7e9ff8b 100644 --- a/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteSanityTests.java @@ -93,7 +93,7 @@ public class AddFavoriteSiteSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify a manager user is NOT Authorized to add a favorite site with Rest API when authentication fails (401)") - @Bug(id="MNT-16904") + @Bug(id="MNT-16904", description = "It fails only on environment with tenants") public void managerUserNotAuthorizedFailsToAddFavoriteSite() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java index 5c6c69a94..af2db17eb 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java @@ -125,7 +125,7 @@ public class DeleteSiteMembershipRequestSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, 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") + @Bug(id = "MNT-16904", description = "It fails only on environment with tenants") public void unauthenticatedUserIsNotAuthorizedToDeleteSiteMmebershipRequest() throws JsonToModelConversionException, Exception { restClient.authenticateUser(dataUser.createRandomTestUser()).withCoreAPI().usingAuthUser().addSiteMembershipRequest(siteModel); diff --git a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java index 070a2020f..dcbd77d31 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java @@ -121,7 +121,7 @@ public class GetFavoriteSiteSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized gets its specific favorite site with Rest API when authentication fails (401)") - @Bug(id="MNT-16904") + @Bug(id="MNT-16904", description = "It fails only on environment with tenants") public void managerUserNotAuthorizedFailsToGetFavoriteSite() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); diff --git a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java index 506945afd..cc7f16302 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java @@ -109,7 +109,7 @@ public class GetFavoriteSitesSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify any user is NOT Authorized to get its favorite sites with Rest API when authentication fails (401)") - @Bug(id = "MNT-16904") + @Bug(id = "MNT-16904", description = "It fails only on environment with tenants") public void anyUserNotAuthenticatedIsNotAuthorizedToGetFavoriteSites() throws Exception { UserModel anyUser = dataUser.usingAdmin().createRandomTestUser(); diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceSanityTests.java index b9d7427e1..8f5397812 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceSanityTests.java @@ -105,7 +105,7 @@ public class GetPeoplePreferenceSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized to get a specific preference with Rest API when authentication fails (401)") - @Bug(id = "MNT-16904") + @Bug(id = "MNT-16904", description = "fails only on environment with tenants") public void managerUserNotAuthorizedFailsToGetsAPreference() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesSanityTests.java index b7a3da1fd..7e435e681 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesSanityTests.java @@ -107,7 +107,7 @@ public class GetPeoplePreferencesSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized to gets its preferences with Rest API when authentication fails(401)") - @Bug(id = "MNT-16904") + @Bug(id = "MNT-16904", description = "It fails only on environment with tenants") public void managerUserGetsPeoplePreferencesIsNotAuthorized() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestCoreTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestCoreTests.java index b5ef3a2a2..1698d7bab 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestCoreTests.java @@ -51,7 +51,7 @@ public class GetSiteMembershipRequestCoreTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify collaborator user fails to get all site membership requests of a specific person with Rest API when the authentication fails (401)") - @Bug(id="MNT-16904") + @Bug(id="MNT-16904", description = "It fails only on environment with tenants") public void unauthorizedCollaboratorUserFailsToGetSiteMembershipRequests() throws Exception { UserModel collaborator = dataUser.usingAdmin().createRandomTestUser(); @@ -64,7 +64,7 @@ public class GetSiteMembershipRequestCoreTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify consumer user fails to get all site membership requests of a specific person with Rest API when the authentication fails (401)") - @Bug(id = "MNT-16904") + @Bug(id = "MNT-16904", description = "It fails only on environment with tenants") public void unauthorizedConsumerUserFailsToGetSiteMembershipRequests() throws Exception { UserModel consumer = dataUser.usingAdmin().createRandomTestUser(); diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java index 1551fa7c3..03cbf8b33 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java @@ -92,7 +92,7 @@ public class GetSiteMembershipRequestsSanityTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @Bug(id = "MNT-16904") + @Bug(id = "MNT-16904", description = "It fails only on environment with tenants") @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user fails to get all site membership requests of a specific person with Rest API when the authentication fails (401)") public void unauthorizedUserFailsToGetSiteMembershipRequests() throws Exception { diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java index 6d46dfbc2..04766c5d1 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java @@ -80,7 +80,7 @@ public class GetSiteMembershipSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to retrieve site membership information of another user") - @Bug(id="MNT-16904") + @Bug(id="MNT-16904", description = "It fails only on environment with tenants") public void unauthenticatedUserCannotRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception { restClient.authenticateUser(new UserModel("random user", "random password")).withCoreAPI() diff --git a/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java index 74f5b07f3..685d06aee 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java @@ -78,7 +78,7 @@ public class GetSitesMembershipInformationSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify that unauthenticated user is not able to retrieve sites membership information") - @Bug(id="MNT-16904") + @Bug(id="MNT-16904", description = "It fails only on environment with tenants") public void unauthenticatedUserCannotRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception { UserModel inexistentUser = new UserModel("inexistent user", "wrong password"); diff --git a/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java index 503db0088..8b81a47c6 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java @@ -117,7 +117,7 @@ public class AddRatingSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to post like rating to a document") @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) - @Bug(id="MNT-16904") + @Bug(id="MNT-16904", description = "It fails only on environment with tenants") public void unauthenticatedUserIsNotAbleToLikeDocument() throws Exception { FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); @@ -201,7 +201,7 @@ public class AddRatingSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to post stars rating to a document") @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) - @Bug(id="MNT-16904") + @Bug(id="MNT-16904", description = "fails only on environment with tenants") public void unauthenticatedUserIsNotAbleToRateStarsToDocument() throws Exception { FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); diff --git a/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java index 1b2472d2b..10d6bc214 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java @@ -162,7 +162,7 @@ public class DeleteRatingSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to remove its own rating of a document") @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) - @Bug(id="MNT-16904") + @Bug(id="MNT-16904", description = "It fails only on environment with tenants") public void unauthenticatedUserIsNotAbleToDeleteRatings() throws Exception { FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); diff --git a/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java index 5ddddd6df..dc9d23178 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java @@ -151,7 +151,7 @@ public class GetRatingSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to retrieve rating of a document") @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) - @Bug(id = "MNT-16904") + @Bug(id = "MNT-16904", description = "It fails only on environment with tenants") public void unauthenticatedUserIsNotAbleToRetrieveRating() throws Exception { FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); diff --git a/e2e-test/java/org/alfresco/rest/ratings/GetRatingsSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/GetRatingsSanityTests.java index 0c07f6419..a973d37c5 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/GetRatingsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/GetRatingsSanityTests.java @@ -131,7 +131,7 @@ public class GetRatingsSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to retrieve document ratings") @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) - @Bug(id="MNT-16904") + @Bug(id="MNT-16904", description = "It fails only on environment with tenants") public void unauthenticatedUserIsNotAbleToRetrieveRatings() throws Exception { FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); diff --git a/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java index a99b7713e..3bfb390e1 100644 --- a/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java @@ -105,7 +105,7 @@ public class AddSiteMemberSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that unauthenticated user is not able to add site member") - @Bug(id="MNT-16904") + @Bug(id="MNT-16904", description = "It fails only on environment with tenants") public void unauthenticatedUserIsNotAuthorizedToAddSiteMmeber() throws Exception{ UserModel testUser = dataUser.createRandomTestUser("testUser"); testUser.setUserRole(UserRole.SiteConsumer); diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java index 775947145..1de49a617 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java @@ -101,7 +101,7 @@ public class GetSiteContainersSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Failed authentication get site containers call returns status code 401 with Manager role") - @Bug(id="MNT-16904") + @Bug(id="MNT-16904", description = "It fails only on environment with tenants") public void unauthenticatedUserIsNotAuthorizedToRetrieveSiteContainers() throws JsonToModelConversionException, Exception { userModel = dataUser.createRandomTestUser(); diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java index 046721e56..8a3348955 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java @@ -100,7 +100,7 @@ public class GetSiteMemberSanityTests extends RestTest @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") + @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"); diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java index 4b2cf6c80..3c152678e 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java @@ -97,7 +97,7 @@ public class GetSiteMembersSanityTests extends RestTest @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") + @Bug(id="MNT-16904", description = "It fails only on environment with tenants") public void unauthenticatedUserIsNotAuthorizedToRetrieveSiteMembers() throws JsonToModelConversionException, Exception { userModel = dataUser.createRandomTestUser(); diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteSanityTests.java index b5813979e..8c8c5f4e1 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteSanityTests.java @@ -105,7 +105,7 @@ public class GetSiteSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Failed authentication get site call returns status code 401") - @Bug(id="MNT-16904") + @Bug(id="MNT-16904", description = "It fails only on environment with tenants") public void unauthenticatedUserIsNotAuthorizedToRetrieveSite() throws JsonToModelConversionException, Exception { userModel = dataUser.createRandomTestUser(); diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java index 12792a552..377b383e6 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java @@ -102,7 +102,7 @@ public class GetSitesSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Failed authentication get sites call returns status code 401") - @Bug(id="MNT-16904") + @Bug(id="MNT-16904", description = "It fails only on environment with tenants") public void unauthenticatedUserIsNotAuthorizedToRetrieveSites() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); diff --git a/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java index a1395a62e..0d412043d 100644 --- a/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java @@ -117,7 +117,7 @@ public class RemoveSiteMemberSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that unauthenticated user is not able to delete site member") - @Bug(id = "MNT-16904") + @Bug(id = "MNT-16904", description = "It fails only on environment with tenants") public void unauthenticatedUserIsNotAuthorizedToDeleteSiteMember() throws Exception { UserModel testUserModel = dataUser.createRandomTestUser(); diff --git a/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java index f924eb71a..724fb236f 100644 --- a/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java @@ -103,7 +103,7 @@ public class UpdateSiteMemberSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that unauthenticated user is not able to update site member") - @Bug(id="MNT-16904") + @Bug(id="MNT-16904", description = "It fails only on environment with tenants") public void unauthenticatedUserIsNotAuthorizedToUpdateSiteMmeber() throws Exception{ UserModel inexistentUser = new UserModel("inexistent user", "inexistent password"); restClient.authenticateUser(inexistentUser); diff --git a/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java index 84e2d8f10..8de6c31e0 100644 --- a/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java @@ -121,7 +121,7 @@ public class AddTagSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user gets status code 401 if authentication call fails") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) - @Bug(id="MNT-16904") + @Bug(id="MNT-16904", description = "It fails only on environment with tenants") public void userIsNotAbleToAddTagIfAuthenticationFails() throws JsonToModelConversionException, Exception { UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); diff --git a/e2e-test/java/org/alfresco/rest/tags/AddTagsSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/AddTagsSanityTests.java index 712715ee2..8ab6b4cbf 100644 --- a/e2e-test/java/org/alfresco/rest/tags/AddTagsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/AddTagsSanityTests.java @@ -120,7 +120,7 @@ public class AddTagsSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API,TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user gets status code 401 if authentication call fails") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) - @Bug(id="MNT-16904") + @Bug(id="MNT-16904", description = "It fails only on environment with tenants") public void userIsNotAbleToAddTagsIfAuthenticationFails() throws JsonToModelConversionException, Exception { UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); diff --git a/e2e-test/java/org/alfresco/rest/tags/DeleteTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/DeleteTagSanityTests.java index 963cf13ad..b6df9ce7d 100644 --- a/e2e-test/java/org/alfresco/rest/tags/DeleteTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/DeleteTagSanityTests.java @@ -120,7 +120,7 @@ public class DeleteTagSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user gets status code 401 if authentication call fails") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) - @Bug(id="MNT-16904") + @Bug(id="MNT-16904", description = "It fails only on environment with tenants") public void userIsNotAbleToDeleteTagIfAuthenticationFails() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); diff --git a/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java index 19b263703..82584e862 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java @@ -120,7 +120,7 @@ public class GetNodeTagsSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to get node tags") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) - @Bug(id="MNT-16904") + @Bug(id = "MNT-16904", description = "fails only on environment with tenants") public void unauthenticatedUserIsNotAbleToRetrieveNodeTags() throws JsonToModelConversionException, Exception { restClient.authenticateUser(new UserModel("random user", "random password")); diff --git a/e2e-test/java/org/alfresco/rest/tags/GetTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagSanityTests.java index 62122f44e..72dd369cd 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetTagSanityTests.java @@ -109,7 +109,7 @@ public class GetTagSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Manager user gets status code 401 if authentication call fails") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) - @Bug(id="MNT-16904") + @Bug(id="MNT-16904", description = "It fails only on environment with tenants") public void managerIsNotAbleToGetTagIfAuthenticationFails() throws JsonToModelConversionException, Exception { String tagValue = RandomData.getRandomName("tag"); diff --git a/e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java index df502158e..f11250c23 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java @@ -110,7 +110,7 @@ public class GetTagsSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Failed authentication get tags call returns status code 401 with Manager role") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) - @Bug(id="MNT-16904") + @Bug(id="MNT-16904", description = "It fails only on environment with tenants") public void failedAuthenticationReturnsUnauthorizedStatus() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); diff --git a/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java index 442e24e10..567148d6c 100644 --- a/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java @@ -104,7 +104,7 @@ public class UpdateTagSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user gets status code 401 if authentication call fails") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) - @Bug(id="MNT-16904") + @Bug(id="MNT-16904", description = "It fails only on environment with tenants") public void userIsNotAbleToUpdateTagIfAuthenticationFails() throws JsonToModelConversionException, Exception { UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/DeleteTaskVariableCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/DeleteTaskVariableCoreTests.java index 3cb14acf9..00b28faf6 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/DeleteTaskVariableCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/DeleteTaskVariableCoreTests.java @@ -111,7 +111,7 @@ public class DeleteTaskVariableCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Delete task variable by inexistent user") @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @Bug(id="MNT-16904") + @Bug(id="MNT-16904", description = "It fails only on environment with tenants") public void deleteTaskVarialbleByInexistentUser() throws Exception { RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/RemoveTaskItemCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/RemoveTaskItemCoreTests.java index 462d8e477..6cf8bba17 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/RemoveTaskItemCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/RemoveTaskItemCoreTests.java @@ -122,7 +122,7 @@ public class RemoveTaskItemCoreTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Delete existing task item with inexistent user") @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @Bug(id="MNT-16904") + @Bug(id="MNT-16904", description = "It fails only on environment with tenants") public void deleteTaskItemWithInexistentUser() throws Exception { taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskVariableCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskVariableCoreTests.java index e38d7ea47..883f78e74 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskVariableCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskVariableCoreTests.java @@ -157,7 +157,7 @@ public class UpdateTaskVariableCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Update task variable by inexistent user") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @Bug(id="MNT-16904") + @Bug(id="MNT-16904", description = "It fails only on environment with tenants") public void updateTaskVariableByInexistentser() throws Exception { variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); From e934920bab62d2789baa4eeb4297ef4f0f793e99 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Fri, 20 Jan 2017 17:01:28 +0200 Subject: [PATCH 0904/1491] fixed test likeResourceThatCannotBeRated --- .../org/alfresco/rest/ratings/AddRatingCoreTests.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/ratings/AddRatingCoreTests.java b/e2e-test/java/org/alfresco/rest/ratings/AddRatingCoreTests.java index c2fe21051..493837ee1 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/AddRatingCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/AddRatingCoreTests.java @@ -15,7 +15,6 @@ import org.alfresco.utility.model.LinkModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.apache.commons.lang3.RandomStringUtils; @@ -79,16 +78,20 @@ public class AddRatingCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Verify that if nodeId provided cannot be rated 405 status code is returned") @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) - @Bug(id = "MNT-16904") public void likeResourceThatCannotBeRated() throws Exception { FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); LinkModel link = dataLink.usingAdmin().usingSite(siteModel).createRandomLink(); - document.setNodeRef(link.getNodeRef()); + document.setNodeRef(link.getNodeRef().replace("workspace://SpacesStore/", "workspace%3A%2F%2FSpacesStore%2F")); restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, document.getNodeRef())) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); } @TestRail(section = { TestGroup.REST_API, From 82d9f1c9ff2ed1d547fbdeff1143aba9aaf97ac1 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Fri, 20 Jan 2017 17:10:23 +0200 Subject: [PATCH 0905/1491] Mark correct execution type/test group --- .../rest/tags/GetNodeTagsFullTests.java | 39 +++++++++---------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsFullTests.java b/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsFullTests.java index b82d8eef1..9de001f0e 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsFullTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsFullTests.java @@ -48,9 +48,8 @@ public class GetNodeTagsFullTests extends RestTest restClient.withCoreAPI().usingResource(document).addTag(tagValue2); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify site Manager is able to get node tags " - + "using properties parameter.") + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify site Manager is able to get node tags using properties parameter") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) public void siteManagerIsAbleToRetrieveNodeTagsWithPropertiesParameter() throws JsonToModelConversionException, Exception { @@ -62,9 +61,8 @@ public class GetNodeTagsFullTests extends RestTest .and().entriesListDoesNotContain("id"); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify that Collaborator user is not able to get node tags " - + "using site id instead of node id.") + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that Collaborator user is not able to get node tags using site id instead of node id") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) public void collaboratorGetNodeTagsUseSiteIdInsteadOfNodeId() throws JsonToModelConversionException, Exception { @@ -77,8 +75,8 @@ public class GetNodeTagsFullTests extends RestTest .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, file.getNodeRef())); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "With admin get node tags and use skipCount parameter. Check pagination and maxItems.") + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "With admin get node tags and use skipCount parameter. Check pagination and maxItems") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) public void useSkipCountCheckPaginationAndMaxItems() throws JsonToModelConversionException, Exception { @@ -91,8 +89,8 @@ public class GetNodeTagsFullTests extends RestTest .and().field("count").is("1"); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "With admin get node tags and use maxItems parameter. Check pagination.") + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "With admin get node tags and use maxItems parameter. Check pagination") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) public void useMaxItemsParameterCheckPagination() throws JsonToModelConversionException, Exception { @@ -106,9 +104,8 @@ public class GetNodeTagsFullTests extends RestTest .and().field("skipCount").is("0"); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Get tags from a node to which user does not have access." - + " Check default error model schema") + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Get tags from a node to which user does not have access. Check default error model schema") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) public void getTagsFromNodeWithUserWhoDoesNotHaveAccessCheckDefaultErrorModelSchema() throws JsonToModelConversionException, Exception { @@ -120,8 +117,8 @@ public class GetNodeTagsFullTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Using manager user get only one tag.") + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Using manager user get only one tag.") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) public void usingManagerGetOnlyOneTag() throws JsonToModelConversionException, Exception { @@ -139,8 +136,8 @@ public class GetNodeTagsFullTests extends RestTest .and().field("skipCount").is("0"); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Using admin get last 2 tags and skip first 2 tags") + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Using admin get last 2 tags and skip first 2 tags") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) public void adminUserGetLast2TagsAndSkipFirst2Tags() throws JsonToModelConversionException, Exception { @@ -167,8 +164,8 @@ public class GetNodeTagsFullTests extends RestTest .and().field("skipCount").is("2"); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "With admin get node tags and use maxItems=0.") + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "With admin get node tags and use maxItems=0.") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) public void getTagsWithZeroMaxItems() throws JsonToModelConversionException, Exception { @@ -179,7 +176,7 @@ public class GetNodeTagsFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify that using high skipCount parameter returns status code 200.") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) public void getTagsWithHighSkipCount() throws JsonToModelConversionException, Exception { returnedCollection = restClient.authenticateUser(adminUserModel).withParams("skipCount=10000") @@ -192,4 +189,4 @@ public class GetNodeTagsFullTests extends RestTest .and().field("skipCount").is("10000"); returnedCollection.assertThat().entriesListCountIs(0); } -} +} \ No newline at end of file From 8adebbae1b0132e43b8dab87aa41b5bea97f348a Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Fri, 20 Jan 2017 17:34:09 +0200 Subject: [PATCH 0906/1491] fixed tests not related to MNT-16904 --- .../rest/comments/GetCommentsCoreTests.java | 19 +++++++++++++------ .../rest/comments/UpdateCommentCoreTests.java | 12 +++++++----- .../rest/people/AddFavoriteSiteFullTests.java | 2 -- .../people/DeleteSiteMemberSanityTests.java | 6 +++--- .../GetPeopleActivitiesSanityTests.java | 7 ++++--- .../GetSiteMembershipRequestCoreTests.java | 5 +++-- .../UpdateSiteMembershipRequestCoreTests.java | 6 +++--- 7 files changed, 33 insertions(+), 24 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/comments/GetCommentsCoreTests.java b/e2e-test/java/org/alfresco/rest/comments/GetCommentsCoreTests.java index 0836c3045..1fd7a1f5c 100644 --- a/e2e-test/java/org/alfresco/rest/comments/GetCommentsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/GetCommentsCoreTests.java @@ -4,8 +4,12 @@ import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestCommentModelsCollection; import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.utility.model.*; -import org.alfresco.utility.report.Bug; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FileType; +import org.alfresco.utility.model.LinkModel; +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; @@ -69,16 +73,19 @@ public class GetCommentsCoreTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Verify User can't get comments for node that exists but is not a document or a folder and status code is 400") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) - @Bug(id = "MNT-16904") public void userCanNotGetCommentsOnLink() throws Exception { LinkModel link = dataLink.usingAdmin().usingSite(siteModel).createRandomLink(); FileModel fileWithNodeRefFromLink = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); - fileWithNodeRefFromLink.setNodeRef(link.getNodeRef()); + fileWithNodeRefFromLink.setNodeRef(link.getNodeRef().replace("workspace://SpacesStore/", "workspace%3A%2F%2FSpacesStore%2F")); restClient.authenticateUser(adminUserModel).withCoreAPI() .usingResource(fileWithNodeRefFromLink).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(RestErrorModel.UNABLE_TO_LOCATE); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, fileWithNodeRefFromLink.getNodeRef())) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); } @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, diff --git a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentCoreTests.java b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentCoreTests.java index b84e77039..32caa9b5e 100644 --- a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentCoreTests.java @@ -14,7 +14,6 @@ import org.alfresco.utility.model.LinkModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -42,7 +41,6 @@ public class UpdateCommentCoreTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify can not update comment if NodeId is neither document or folder and returns status code 405") - @Bug(id="MNT-16904") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) public void canNotUpdateCommentIfNodeIdIsNeitherDocumentOrFolder() throws JsonToModelConversionException, Exception { @@ -53,11 +51,15 @@ public class UpdateCommentCoreTests extends RestTest commentModel = restClient.withCoreAPI().usingResource(content).addComment("This is a new comment"); LinkModel link = dataLink.usingAdmin().usingSite(siteModel).createRandomLink(); - content.setNodeRef(link.getNodeRef()); + content.setNodeRef(link.getNodeRef().replace("workspace://SpacesStore/", "workspace%3A%2F%2FSpacesStore%2F")); restClient.withCoreAPI().usingResource(content).updateComment(commentModel, "This is the updated comment."); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) - .assertLastError().containsSummary("node ref that does not exist was not found"); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, content.getNodeRef())) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); } @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Admin user is not able to update with empty comment body and status code is 400") diff --git a/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteFullTests.java b/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteFullTests.java index c8df80f33..19510d56a 100644 --- a/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteFullTests.java +++ b/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteFullTests.java @@ -2,9 +2,7 @@ package org.alfresco.rest.people; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; -import org.alfresco.rest.core.JsonBodyGenerator; import org.alfresco.rest.core.RestRequest; -import org.alfresco.rest.exception.EmptyJsonResponseException; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestCommentModel; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java index ec9e8d6b7..3c15d11d0 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java @@ -9,7 +9,6 @@ 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.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -100,12 +99,13 @@ public class DeleteSiteMemberSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to delete another member of the site") - @Bug(id = "MNT-16904") public void unauthenticatedUserIsNotAbleToDeleteSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception { restClient.authenticateUser(new UserModel("random user", "random password")); restClient.withCoreAPI().usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).deleteSiteMember(siteModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError().containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED);; } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java index f0b91dce5..618d7457c 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java @@ -3,12 +3,12 @@ package org.alfresco.rest.people; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestActivityModelsCollection; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -101,10 +101,11 @@ public class GetPeopleActivitiesSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is NOT Authorized to gets another user activities with Rest API") - @Bug(id = "MNT-16904") public void unauthenticatedUserShouldNotGetPeopleActivitiesList() throws Exception { restClient.authenticateUser(unauthenticatedUser).withCoreAPI().usingUser(userModel).getPersonActivities(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError().containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } } diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestCoreTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestCoreTests.java index 1698d7bab..d7873b296 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestCoreTests.java @@ -38,14 +38,15 @@ public class GetSiteMembershipRequestCoreTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify contributor user fails to get all site membership requests of a specific person with Rest API when the authentication fails (401)") - @Bug(id = "MNT-16904") public void unauthorizedContributorUserFailsToGetSiteMembershipRequests() throws Exception { UserModel contributor = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(contributor, siteModel, UserRole.SiteContributor); contributor.setPassword("newpassword"); restClient.authenticateUser(contributor).withCoreAPI().usingUser(newMember).getSiteMembershipRequest(siteModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError().containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) diff --git a/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestCoreTests.java b/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestCoreTests.java index 2efde507d..71c40c86c 100644 --- a/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestCoreTests.java @@ -7,7 +7,6 @@ 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.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -32,14 +31,15 @@ public class UpdateSiteMembershipRequestCoreTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify unauthorized user is not able to update user site membership request") - @Bug(id="MNT-16904") public void unauthorizedUserIsNotAbleToUpdateSiteMembershipRequest() throws Exception { UserModel newMember = dataUser.createRandomTestUser(); restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(siteModel); newMember.setPassword("fakePass"); restClient.withCoreAPI().usingUser(newMember).updateSiteMembershipRequest(siteModel, updatedMessage); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError().containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) From 67a584d749a6c32ec101c56104749081fc160b39 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Fri, 20 Jan 2017 17:58:20 +0200 Subject: [PATCH 0907/1491] fixed test addRatingToAComment --- e2e-test/java/org/alfresco/rest/ratings/AddRatingCoreTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/ratings/AddRatingCoreTests.java b/e2e-test/java/org/alfresco/rest/ratings/AddRatingCoreTests.java index 493837ee1..a86c4a6af 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/AddRatingCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/AddRatingCoreTests.java @@ -238,7 +238,7 @@ public class AddRatingCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) .assertLastError() .containsSummary(String.format(RestErrorModel.CANNOT_RATE)) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .containsErrorKey(RestErrorModel.CANNOT_RATE) .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) .stackTraceIs(RestErrorModel.STACKTRACE); From 41028caa23a256596461510c7153632fc6e79213 Mon Sep 17 00:00:00 2001 From: mionescu Date: Fri, 20 Jan 2017 18:03:14 +0200 Subject: [PATCH 0908/1491] test - added new tests in: UpdateSiteMembershipRequestFullTests.java --- .../UpdateSiteMembershipRequestFullTests.java | 230 ++++++++++++++++++ 1 file changed, 230 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestFullTests.java b/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestFullTests.java new file mode 100644 index 000000000..5a217fb0d --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestFullTests.java @@ -0,0 +1,230 @@ +package org.alfresco.rest.people; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestSiteMembershipRequestModel; +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.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class UpdateSiteMembershipRequestFullTests extends RestTest +{ + private SiteModel moderatedSite; + private UserModel managerUser, adminUser, newMember, regularUser; + private String updatedMessage; + private RestSiteMembershipRequestModel requestUpdateModel, requestGetModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + managerUser = dataUser.createRandomTestUser(); + moderatedSite = dataSite.usingUser(managerUser).createModeratedRandomSite(); + updatedMessage = "Please review my request"; + + newMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is not able to update membership request of another user") + // @Bug(id = "MNT-16919") + public void userIsNotAbleToUpdateSiteMembershipRequestOfAdmin() throws JsonToModelConversionException, Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + + restClient.authenticateUser(newMember).withCoreAPI().usingUser(adminUser).updateSiteMembershipRequest(moderatedSite, updatedMessage); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format("The entity with id: " + RestErrorModel.ENTITY_NOT_FOUND, adminUser.getUsername())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER).stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to update its own site membership request for private site") + public void userCanUpdateSiteMembershipRequestForModeratedSite() throws Exception + { + SiteModel moderatedSite = dataSite.usingUser(managerUser).createModeratedRandomSite(); + UserModel newMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + + requestUpdateModel = restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(moderatedSite, updatedMessage); + restClient.assertStatusCodeIs(HttpStatus.OK); + + requestUpdateModel.assertThat().field("id").is(moderatedSite.getId()).assertThat().field("message").is("Please review my request").assertThat() + .field("site").isNotEmpty().assertThat().field("modifiedAt").isNotEmpty().assertThat().field("createdAt").isNotEmpty(); + requestUpdateModel.getSite().assertThat().field("visibility").is(moderatedSite.getVisibility()).assertThat().field("guid").is(moderatedSite.getGuid()) + .assertThat().field("description").is(moderatedSite.getDescription()).assertThat().field("id").is(moderatedSite.getId()).assertThat() + .field("preset").is("site-dashboard").assertThat().field("title").is(moderatedSite.getTitle()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site collaborator is able to retrieve site membership request") + public void siteCollaboratorIsAbleToUpdateSiteMembershipRequest() throws JsonToModelConversionException, Exception + { + dataUser.usingUser(managerUser).addUserToSite(newMember, moderatedSite, UserRole.SiteCollaborator); + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + requestUpdateModel = restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().updateSiteMembershipRequest(moderatedSite, updatedMessage); + + restClient.assertStatusCodeIs(HttpStatus.OK); + requestUpdateModel.assertThat().field("id").is(moderatedSite.getId()) + .assertThat().field("message").is("Please review my request") + .assertThat().field("modifiedAt").isNotEmpty() + .assertThat().field("createdAt").isNotEmpty(); + requestUpdateModel.getSite() + .assertThat().field("role").is(UserRole.SiteCollaborator) + .assertThat().field("visibility").is(moderatedSite.getVisibility()) + .assertThat().field("guid").is(moderatedSite.getGuid()) + .assertThat().field("description").is(moderatedSite.getDescription()) + .assertThat().field("id").is(moderatedSite.getId()) + .assertThat().field("preset").is("site-dashboard") + .assertThat().field("title").is(moderatedSite.getTitle()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site contributor is able to retrieve site membership request") + public void siteContributorIsAbleToUpdateSiteMembershipRequest() throws JsonToModelConversionException, Exception + { + newMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + dataUser.usingUser(managerUser).addUserToSite(newMember, moderatedSite, UserRole.SiteContributor); + requestUpdateModel = restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().updateSiteMembershipRequest(moderatedSite, updatedMessage); + + restClient.assertStatusCodeIs(HttpStatus.OK); + requestUpdateModel.assertThat().field("id").is(moderatedSite.getId()) + .assertThat().field("message").is("Please review my request") + .assertThat().field("modifiedAt").isNotEmpty() + .assertThat().field("createdAt").isNotEmpty(); + requestUpdateModel.getSite() + .assertThat().field("role").is(UserRole.SiteContributor) + .assertThat().field("visibility").is(moderatedSite.getVisibility()) + .assertThat().field("guid").is(moderatedSite.getGuid()) + .assertThat().field("description").is(moderatedSite.getDescription()) + .assertThat().field("id").is(moderatedSite.getId()) + .assertThat().field("preset").is("site-dashboard") + .assertThat().field("title").is(moderatedSite.getTitle()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site consumer is able to retrieve site membership request") + public void siteConsumerIsAbleToUpdateSiteMembershipRequest() throws JsonToModelConversionException, Exception + { + newMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + dataUser.usingUser(managerUser).addUserToSite(newMember, moderatedSite, UserRole.SiteConsumer); + requestUpdateModel = restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().updateSiteMembershipRequest(moderatedSite, updatedMessage); + + restClient.assertStatusCodeIs(HttpStatus.OK); + requestUpdateModel.assertThat().field("id").is(moderatedSite.getId()) + .assertThat().field("message").is("Please review my request") + .assertThat().field("modifiedAt").isNotEmpty() + .assertThat().field("createdAt").isNotEmpty(); + requestUpdateModel.getSite() + .assertThat().field("role").is(UserRole.SiteConsumer) + .assertThat().field("visibility").is(moderatedSite.getVisibility()) + .assertThat().field("guid").is(moderatedSite.getGuid()) + .assertThat().field("description").is(moderatedSite.getDescription()) + .assertThat().field("id").is(moderatedSite.getId()) + .assertThat().field("preset").is("site-dashboard") + .assertThat().field("title").is(moderatedSite.getTitle()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site manager is able to retrieve site membership request") + public void siteManagerIsAbleToUpdateSiteMembershipRequest() throws JsonToModelConversionException, Exception + { + newMember = dataUser.createRandomTestUser(); + dataUser.usingUser(managerUser).addUserToSite(newMember, moderatedSite, UserRole.SiteManager); + requestUpdateModel = restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().updateSiteMembershipRequest(moderatedSite, updatedMessage); + + restClient.assertStatusCodeIs(HttpStatus.OK); + requestUpdateModel.assertThat().field("id").is(moderatedSite.getId()) + .assertThat().field("message").is("Please review my request") + .assertThat().field("modifiedAt").isNotEmpty() + .assertThat().field("createdAt").isNotEmpty(); + requestUpdateModel.getSite() + .assertThat().field("role").is(UserRole.SiteManager) + .assertThat().field("visibility").is(moderatedSite.getVisibility()) + .assertThat().field("guid").is(moderatedSite.getGuid()) + .assertThat().field("description").is(moderatedSite.getDescription()) + .assertThat().field("id").is(moderatedSite.getId()) + .assertThat().field("preset").is("site-dashboard") + .assertThat().field("title").is(moderatedSite.getTitle()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to retrieve site membership request") + public void adminIsAbleToRetrieveSiteMembershipRequest() throws JsonToModelConversionException, Exception + { + regularUser = dataUser.createRandomTestUser(); + SiteModel anotherModeratedSite = dataSite.usingUser(regularUser).createModeratedRandomSite(); + requestUpdateModel = restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(anotherModeratedSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + requestUpdateModel = restClient.withCoreAPI().usingAuthUser().updateSiteMembershipRequest(anotherModeratedSite, updatedMessage); + restClient.assertStatusCodeIs(HttpStatus.OK); + requestUpdateModel.assertThat().field("id").is(anotherModeratedSite.getId()) + .assertThat().field("message").is("Please review my request") + .assertThat().field("modifiedAt").isNotEmpty() + .assertThat().field("createdAt").isNotEmpty(); + requestUpdateModel.getSite() + .assertThat().field("visibility").is(anotherModeratedSite.getVisibility()) + .assertThat().field("guid").is(anotherModeratedSite.getGuid()) + .assertThat().field("description").is(anotherModeratedSite.getDescription()) + .assertThat().field("id").is(anotherModeratedSite.getId()) + .assertThat().field("preset").is("site-dashboard") + .assertThat().field("title").is(anotherModeratedSite.getTitle()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is able to update its own site membership request with initial message") + public void userUpdateWithNoMessageThenAddsNewMessage() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + requestUpdateModel = restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + requestUpdateModel.assertThat().field("id").is(moderatedSite.getId()) + .assertThat().field("message").is("Please accept me"); + + requestUpdateModel = restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(moderatedSite, ""); + + restClient.assertStatusCodeIs(HttpStatus.OK); + requestUpdateModel.assertThat().field("id").is(moderatedSite.getId()) + .and().field("modifiedAt").isNotEmpty() + .assertThat().field("message").isNull(); + + requestUpdateModel = restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(moderatedSite, updatedMessage); + requestUpdateModel.assertThat().field("id").is(moderatedSite.getId()) + .assertThat().field("message").is("Please review my request") + .assertThat().field("modifiedAt").isNotEmpty() + .assertThat().field("createdAt").isNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is able to update its own site membership request with initial message") + public void userUpdateSiteMembershipRequestAndCheckModifiedAtWithGet() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + requestUpdateModel = restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + requestUpdateModel.assertThat().field("id").is(moderatedSite.getId()) + .assertThat().field("message").is("Please accept me"); + + requestUpdateModel = restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(moderatedSite, updatedMessage); + requestGetModel = restClient.withCoreAPI().usingMe().getSiteMembershipRequest(moderatedSite); + + restClient.assertStatusCodeIs(HttpStatus.OK); + requestGetModel.assertThat().field("id").is(requestUpdateModel.getId()) + .and().field("modifiedAt").is(requestUpdateModel.getModifiedAt()) + .assertThat().field("message").is(requestUpdateModel.getMessage()); + } + +} From 9bc78a77db7bbd2ec4f472604780fe7d414041d6 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Mon, 23 Jan 2017 12:13:42 +0200 Subject: [PATCH 0909/1491] Validate person field when using properties --- .../java/org/alfresco/rest/sites/GetSiteMemberFullTests.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberFullTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberFullTests.java index fa7e0e875..1a84376ac 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberFullTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberFullTests.java @@ -185,7 +185,8 @@ public class GetSiteMemberFullTests extends RestTest .withCoreAPI().usingSite(siteModel).usingParams("properties=id").getSiteMember(consumer) .assertThat().fieldsCount().is(1) .and().field("id").isNotEmpty() - .and().field("role").isNull(); + .and().field("role").isNull() + .and().field("person").isNull(); restClient.assertStatusCodeIs(HttpStatus.OK); } -} +} \ No newline at end of file From b00f403dda082f041cbbb692d9c07880c577aeda Mon Sep 17 00:00:00 2001 From: mionescu Date: Mon, 23 Jan 2017 16:00:43 +0200 Subject: [PATCH 0910/1491] test-added new tests --- .../UpdateSiteMembershipRequestFullTests.java | 523 ++++++++++++++---- 1 file changed, 411 insertions(+), 112 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestFullTests.java b/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestFullTests.java index 5a217fb0d..fbe49a7c9 100644 --- a/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestFullTests.java +++ b/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestFullTests.java @@ -1,15 +1,19 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestSiteMembershipRequestModel; +import org.alfresco.rest.model.RestTaskModel; import org.alfresco.utility.constants.UserRole; +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.HttpMethod; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -18,7 +22,7 @@ public class UpdateSiteMembershipRequestFullTests extends RestTest { private SiteModel moderatedSite; private UserModel managerUser, adminUser, newMember, regularUser; - private String updatedMessage; + private String updatedMessage, moderatedSiteId; private RestSiteMembershipRequestModel requestUpdateModel, requestGetModel; @BeforeClass(alwaysRun = true) @@ -31,200 +35,495 @@ public class UpdateSiteMembershipRequestFullTests extends RestTest newMember = dataUser.createRandomTestUser(); restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + moderatedSiteId = moderatedSite.getId(); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is not able to update membership request of another user") - // @Bug(id = "MNT-16919") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify user is not able to update membership request of admin") public void userIsNotAbleToUpdateSiteMembershipRequestOfAdmin() throws JsonToModelConversionException, Exception { UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser() + .addSiteMembershipRequest(moderatedSite); - restClient.authenticateUser(newMember).withCoreAPI().usingUser(adminUser).updateSiteMembershipRequest(moderatedSite, updatedMessage); + restClient.authenticateUser(newMember).withCoreAPI().usingUser(adminUser) + .updateSiteMembershipRequest(moderatedSite, updatedMessage); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format("The entity with id: " + RestErrorModel.ENTITY_NOT_FOUND, adminUser.getUsername())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER).stackTraceIs(RestErrorModel.STACKTRACE); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format("The entity with id: " + RestErrorModel.ENTITY_NOT_FOUND, adminUser.getUsername())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to update its own site membership request for private site") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify user is able to update site membership request for moderated site") public void userCanUpdateSiteMembershipRequestForModeratedSite() throws Exception { SiteModel moderatedSite = dataSite.usingUser(managerUser).createModeratedRandomSite(); UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser() + .addSiteMembershipRequest(moderatedSite); - requestUpdateModel = restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(moderatedSite, updatedMessage); + requestUpdateModel = restClient.withCoreAPI().usingMe() + .updateSiteMembershipRequest(moderatedSite, updatedMessage); restClient.assertStatusCodeIs(HttpStatus.OK); - requestUpdateModel.assertThat().field("id").is(moderatedSite.getId()).assertThat().field("message").is("Please review my request").assertThat() - .field("site").isNotEmpty().assertThat().field("modifiedAt").isNotEmpty().assertThat().field("createdAt").isNotEmpty(); - requestUpdateModel.getSite().assertThat().field("visibility").is(moderatedSite.getVisibility()).assertThat().field("guid").is(moderatedSite.getGuid()) - .assertThat().field("description").is(moderatedSite.getDescription()).assertThat().field("id").is(moderatedSite.getId()).assertThat() - .field("preset").is("site-dashboard").assertThat().field("title").is(moderatedSite.getTitle()); + requestUpdateModel.assertThat().field("id").is(moderatedSite.getId()) + .assertThat().field("message").is(updatedMessage) + .assertThat().field("site").isNotEmpty() + .assertThat().field("modifiedAt").isNotEmpty() + .assertThat().field("createdAt").isNotEmpty(); + requestUpdateModel.getSite().assertThat().field("visibility").is(moderatedSite.getVisibility()) + .assertThat().field("guid").is(moderatedSite.getGuid()) + .assertThat().field("description").is(moderatedSite.getDescription()) + .assertThat().field("id").is(moderatedSite.getId()) + .assertThat().field("preset").is("site-dashboard") + .assertThat().field("title").is(moderatedSite.getTitle()); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site collaborator is able to retrieve site membership request") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify site collaborator is able to update site membership request") public void siteCollaboratorIsAbleToUpdateSiteMembershipRequest() throws JsonToModelConversionException, Exception { dataUser.usingUser(managerUser).addUserToSite(newMember, moderatedSite, UserRole.SiteCollaborator); - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - requestUpdateModel = restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().updateSiteMembershipRequest(moderatedSite, updatedMessage); + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser() + .addSiteMembershipRequest(moderatedSite); + requestUpdateModel = restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser() + .updateSiteMembershipRequest(moderatedSite, updatedMessage); restClient.assertStatusCodeIs(HttpStatus.OK); requestUpdateModel.assertThat().field("id").is(moderatedSite.getId()) - .assertThat().field("message").is("Please review my request") - .assertThat().field("modifiedAt").isNotEmpty() - .assertThat().field("createdAt").isNotEmpty(); - requestUpdateModel.getSite() - .assertThat().field("role").is(UserRole.SiteCollaborator) - .assertThat().field("visibility").is(moderatedSite.getVisibility()) - .assertThat().field("guid").is(moderatedSite.getGuid()) - .assertThat().field("description").is(moderatedSite.getDescription()) - .assertThat().field("id").is(moderatedSite.getId()) - .assertThat().field("preset").is("site-dashboard") - .assertThat().field("title").is(moderatedSite.getTitle()); + .assertThat().field("message").is(updatedMessage) + .assertThat().field("modifiedAt").isNotEmpty() + .assertThat().field("createdAt").isNotEmpty(); + requestUpdateModel.getSite().assertThat().field("role").is(UserRole.SiteCollaborator) + .assertThat().field("visibility").is(moderatedSite.getVisibility()) + .assertThat().field("guid").is(moderatedSite.getGuid()) + .assertThat().field("description").is(moderatedSite.getDescription()) + .assertThat().field("id").is(moderatedSite.getId()) + .assertThat().field("preset").is("site-dashboard") + .assertThat().field("title").is(moderatedSite.getTitle()); } - + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site contributor is able to retrieve site membership request") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify site contributor is able to update site membership request") public void siteContributorIsAbleToUpdateSiteMembershipRequest() throws JsonToModelConversionException, Exception { newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser() + .addSiteMembershipRequest(moderatedSite); dataUser.usingUser(managerUser).addUserToSite(newMember, moderatedSite, UserRole.SiteContributor); - requestUpdateModel = restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().updateSiteMembershipRequest(moderatedSite, updatedMessage); + requestUpdateModel = restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser() + .updateSiteMembershipRequest(moderatedSite, updatedMessage); restClient.assertStatusCodeIs(HttpStatus.OK); requestUpdateModel.assertThat().field("id").is(moderatedSite.getId()) - .assertThat().field("message").is("Please review my request") - .assertThat().field("modifiedAt").isNotEmpty() - .assertThat().field("createdAt").isNotEmpty(); - requestUpdateModel.getSite() - .assertThat().field("role").is(UserRole.SiteContributor) - .assertThat().field("visibility").is(moderatedSite.getVisibility()) - .assertThat().field("guid").is(moderatedSite.getGuid()) - .assertThat().field("description").is(moderatedSite.getDescription()) - .assertThat().field("id").is(moderatedSite.getId()) - .assertThat().field("preset").is("site-dashboard") - .assertThat().field("title").is(moderatedSite.getTitle()); + .assertThat().field("message").is(updatedMessage) + .assertThat().field("modifiedAt").isNotEmpty() + .assertThat().field("createdAt").isNotEmpty(); + requestUpdateModel.getSite().assertThat().field("role").is(UserRole.SiteContributor) + .assertThat().field("visibility").is(moderatedSite.getVisibility()) + .assertThat().field("guid").is(moderatedSite.getGuid()) + .assertThat().field("description").is(moderatedSite.getDescription()) + .assertThat().field("id").is(moderatedSite.getId()) + .assertThat().field("preset").is("site-dashboard") + .assertThat().field("title").is(moderatedSite.getTitle()); } - + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site consumer is able to retrieve site membership request") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify site consumer is able to update site membership request") public void siteConsumerIsAbleToUpdateSiteMembershipRequest() throws JsonToModelConversionException, Exception { newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser() + .addSiteMembershipRequest(moderatedSite); dataUser.usingUser(managerUser).addUserToSite(newMember, moderatedSite, UserRole.SiteConsumer); - requestUpdateModel = restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().updateSiteMembershipRequest(moderatedSite, updatedMessage); + requestUpdateModel = restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser() + .updateSiteMembershipRequest(moderatedSite, updatedMessage); restClient.assertStatusCodeIs(HttpStatus.OK); requestUpdateModel.assertThat().field("id").is(moderatedSite.getId()) - .assertThat().field("message").is("Please review my request") - .assertThat().field("modifiedAt").isNotEmpty() - .assertThat().field("createdAt").isNotEmpty(); - requestUpdateModel.getSite() - .assertThat().field("role").is(UserRole.SiteConsumer) - .assertThat().field("visibility").is(moderatedSite.getVisibility()) - .assertThat().field("guid").is(moderatedSite.getGuid()) - .assertThat().field("description").is(moderatedSite.getDescription()) - .assertThat().field("id").is(moderatedSite.getId()) - .assertThat().field("preset").is("site-dashboard") - .assertThat().field("title").is(moderatedSite.getTitle()); + .assertThat().field("message").is(updatedMessage) + .assertThat().field("modifiedAt").isNotEmpty() + .assertThat().field("createdAt").isNotEmpty(); + requestUpdateModel.getSite().assertThat().field("role").is(UserRole.SiteConsumer) + .assertThat().field("visibility").is(moderatedSite.getVisibility()) + .assertThat().field("guid").is(moderatedSite.getGuid()) + .assertThat().field("description").is(moderatedSite.getDescription()) + .assertThat().field("id").is(moderatedSite.getId()) + .assertThat().field("preset").is("site-dashboard") + .assertThat().field("title").is(moderatedSite.getTitle()); } - + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site manager is able to retrieve site membership request") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify site manager is able to update site membership request") public void siteManagerIsAbleToUpdateSiteMembershipRequest() throws JsonToModelConversionException, Exception { newMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser() + .addSiteMembershipRequest(moderatedSite); dataUser.usingUser(managerUser).addUserToSite(newMember, moderatedSite, UserRole.SiteManager); - requestUpdateModel = restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().updateSiteMembershipRequest(moderatedSite, updatedMessage); + requestUpdateModel = restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser() + .updateSiteMembershipRequest(moderatedSite, updatedMessage); restClient.assertStatusCodeIs(HttpStatus.OK); requestUpdateModel.assertThat().field("id").is(moderatedSite.getId()) - .assertThat().field("message").is("Please review my request") - .assertThat().field("modifiedAt").isNotEmpty() - .assertThat().field("createdAt").isNotEmpty(); - requestUpdateModel.getSite() - .assertThat().field("role").is(UserRole.SiteManager) - .assertThat().field("visibility").is(moderatedSite.getVisibility()) - .assertThat().field("guid").is(moderatedSite.getGuid()) - .assertThat().field("description").is(moderatedSite.getDescription()) - .assertThat().field("id").is(moderatedSite.getId()) - .assertThat().field("preset").is("site-dashboard") - .assertThat().field("title").is(moderatedSite.getTitle()); + .assertThat().field("message").is(updatedMessage) + .assertThat().field("modifiedAt").isNotEmpty() + .assertThat().field("createdAt").isNotEmpty(); + requestUpdateModel.getSite().assertThat().field("role").is(UserRole.SiteManager) + .assertThat().field("visibility").is(moderatedSite.getVisibility()) + .assertThat().field("guid").is(moderatedSite.getGuid()) + .assertThat().field("description").is(moderatedSite.getDescription()) + .assertThat().field("id").is(moderatedSite.getId()) + .assertThat().field("preset").is("site-dashboard") + .assertThat().field("title").is(moderatedSite.getTitle()); } - + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to retrieve site membership request") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify admin is able to update site membership request") public void adminIsAbleToRetrieveSiteMembershipRequest() throws JsonToModelConversionException, Exception { regularUser = dataUser.createRandomTestUser(); SiteModel anotherModeratedSite = dataSite.usingUser(regularUser).createModeratedRandomSite(); - requestUpdateModel = restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(anotherModeratedSite); + requestUpdateModel = restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser() + .addSiteMembershipRequest(anotherModeratedSite); restClient.assertStatusCodeIs(HttpStatus.CREATED); - - requestUpdateModel = restClient.withCoreAPI().usingAuthUser().updateSiteMembershipRequest(anotherModeratedSite, updatedMessage); + + requestUpdateModel = restClient.withCoreAPI().usingAuthUser() + .updateSiteMembershipRequest(anotherModeratedSite, updatedMessage); + restClient.assertStatusCodeIs(HttpStatus.OK); requestUpdateModel.assertThat().field("id").is(anotherModeratedSite.getId()) - .assertThat().field("message").is("Please review my request") - .assertThat().field("modifiedAt").isNotEmpty() - .assertThat().field("createdAt").isNotEmpty(); - requestUpdateModel.getSite() - .assertThat().field("visibility").is(anotherModeratedSite.getVisibility()) - .assertThat().field("guid").is(anotherModeratedSite.getGuid()) - .assertThat().field("description").is(anotherModeratedSite.getDescription()) - .assertThat().field("id").is(anotherModeratedSite.getId()) - .assertThat().field("preset").is("site-dashboard") - .assertThat().field("title").is(anotherModeratedSite.getTitle()); + .assertThat().field("message").is("Please review my request") + .assertThat().field("modifiedAt").isNotEmpty() + .assertThat().field("createdAt").isNotEmpty(); + requestUpdateModel.getSite().assertThat().field("visibility").is(anotherModeratedSite.getVisibility()) + .assertThat().field("guid").is(anotherModeratedSite.getGuid()) + .assertThat().field("description").is(anotherModeratedSite.getDescription()) + .assertThat().field("id").is(anotherModeratedSite.getId()) + .assertThat().field("preset").is("site-dashboard") + .assertThat().field("title").is(anotherModeratedSite.getTitle()); } - + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is able to update its own site membership request with initial message") - public void userUpdateWithNoMessageThenAddsNewMessage() throws Exception + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify user update site membership request with no message then adds a new message") + public void userUpdateSiteMembershipRequestWithNoMessageThenAddsNewMessage() throws Exception { UserModel newMember = dataUser.createRandomTestUser(); - requestUpdateModel = restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + requestUpdateModel = restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser() + .addSiteMembershipRequest(moderatedSite); restClient.assertStatusCodeIs(HttpStatus.CREATED); requestUpdateModel.assertThat().field("id").is(moderatedSite.getId()) - .assertThat().field("message").is("Please accept me"); - + .assertThat().field("message").is("Please accept me"); + requestUpdateModel = restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(moderatedSite, ""); - restClient.assertStatusCodeIs(HttpStatus.OK); requestUpdateModel.assertThat().field("id").is(moderatedSite.getId()) - .and().field("modifiedAt").isNotEmpty() - .assertThat().field("message").isNull(); - + .and().field("modifiedAt").isNotEmpty() + .assertThat().field("message").isNull(); + requestUpdateModel = restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(moderatedSite, updatedMessage); requestUpdateModel.assertThat().field("id").is(moderatedSite.getId()) - .assertThat().field("message").is("Please review my request") - .assertThat().field("modifiedAt").isNotEmpty() - .assertThat().field("createdAt").isNotEmpty(); + .assertThat().field("message").is(updatedMessage) + .assertThat().field("modifiedAt").isNotEmpty() + .assertThat().field("createdAt").isNotEmpty(); } - + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is able to update its own site membership request with initial message") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify user updates site membership request and verifies 'ModifiedAt' field using GET") public void userUpdateSiteMembershipRequestAndCheckModifiedAtWithGet() throws Exception { UserModel newMember = dataUser.createRandomTestUser(); - requestUpdateModel = restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + requestUpdateModel = restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser() + .addSiteMembershipRequest(moderatedSite); restClient.assertStatusCodeIs(HttpStatus.CREATED); requestUpdateModel.assertThat().field("id").is(moderatedSite.getId()) - .assertThat().field("message").is("Please accept me"); - - requestUpdateModel = restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(moderatedSite, updatedMessage); - requestGetModel = restClient.withCoreAPI().usingMe().getSiteMembershipRequest(moderatedSite); - + .assertThat().field("message").is("Please accept me"); + + requestUpdateModel = restClient.withCoreAPI().usingAuthUser().updateSiteMembershipRequest(moderatedSite, updatedMessage); + requestGetModel = restClient.withCoreAPI().usingAuthUser().getSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.OK); requestGetModel.assertThat().field("id").is(requestUpdateModel.getId()) - .and().field("modifiedAt").is(requestUpdateModel.getModifiedAt()) - .assertThat().field("message").is(requestUpdateModel.getMessage()); + .and().field("modifiedAt").is(requestUpdateModel.getModifiedAt()) + .assertThat().field("message").is(requestUpdateModel.getMessage()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Update membership request - empty body") + public void emptyBodyUpdateSiteMembershipRequest() throws Exception + { + restClient.authenticateUser(adminUser).withCoreAPI(); + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"\": \"\",\"\": \"\", \"\": \"\"}", + "people/{personId}/site-membership-requests/{siteId}", adminUser.getUsername(), moderatedSite.getId()); + restClient.processModel(RestSiteMembershipRequestModel.class, request); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.NO_CONTENT, "Unrecognized field " + "\"\"")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Update membership request - missing 'Title' field from Json") + public void missingTitleFieldBodyUpdateSiteMembershipRequest() throws Exception + { + SiteModel moderatedSite = dataSite.usingUser(managerUser).createModeratedRandomSite(); + UserModel newMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser() + .addSiteMembershipRequest(moderatedSite); + + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, + "{\"message\":\"Please review my request\",\"id\":\"" + moderatedSite.getId() + "\"}", + "people/{personId}/site-membership-requests/{siteId}", + newMember.getUsername(), moderatedSite.getId()); + requestUpdateModel = restClient.processModel(RestSiteMembershipRequestModel.class, request); + + restClient.assertStatusCodeIs(HttpStatus.OK); + requestUpdateModel.assertThat().field("id").is(moderatedSite.getId()) + .assertThat().field("message").is(updatedMessage) + .assertThat().field("site").isNotEmpty() + .assertThat().field("modifiedAt").isNotEmpty() + .assertThat().field("createdAt").isNotEmpty(); + requestUpdateModel.getSite().assertThat().field("visibility").is(moderatedSite.getVisibility()) + .assertThat().field("guid").is(moderatedSite.getGuid()) + .assertThat().field("description").is(moderatedSite.getDescription()) + .assertThat().field("id").is(moderatedSite.getId()) + .assertThat().field("preset").is("site-dashboard") + .assertThat().field("title").is(moderatedSite.getTitle()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Update site membership request - missing JSON body") + public void missingJsonFieldBodyUpdateSiteMembershipRequest() throws Exception + { + SiteModel moderatedSite = dataSite.usingUser(managerUser).createModeratedRandomSite(); + UserModel newMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser() + .addSiteMembershipRequest(moderatedSite); + + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "", + "people/{personId}/site-membership-requests/{siteId}", newMember.getUsername(), + moderatedSite.getId()); + requestUpdateModel = restClient.processModel(RestSiteMembershipRequestModel.class, request); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsSummary(String.format(RestErrorModel.NO_CONTENT, "No content to map to Object due to end of input")) + .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "No content to map to Object due to end of input")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Update site membership request - empty JSON body") + public void emptyJsonFieldBodyUpdateSiteMembershipRequest() throws Exception + { + SiteModel moderatedSite = dataSite.usingUser(managerUser).createModeratedRandomSite(); + UserModel newMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser() + .addSiteMembershipRequest(moderatedSite); + + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{}", + "people/{personId}/site-membership-requests/{siteId}", newMember.getUsername(), + moderatedSite.getId()); + requestUpdateModel = restClient.processModel(RestSiteMembershipRequestModel.class, request); + + restClient.assertStatusCodeIs(HttpStatus.OK); + requestUpdateModel.assertThat().field("id").is(moderatedSite.getId()) + .assertThat().field("message").isNull() + .assertThat().field("site").isNotEmpty() + .assertThat().field("modifiedAt").isNotEmpty() + .assertThat().field("createdAt").isNotEmpty(); + requestUpdateModel.getSite().assertThat().field("visibility").is(moderatedSite.getVisibility()) + .assertThat().field("guid").is(moderatedSite.getGuid()) + .assertThat().field("description").is(moderatedSite.getDescription()) + .assertThat().field("id").is(moderatedSite.getId()) + .assertThat().field("preset").is("site-dashboard") + .assertThat().field("title").is(moderatedSite.getTitle()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Update site membership request - invalid SiteId") + public void invalidSiteIdUpdateSiteMembershipRequest() throws Exception + { + moderatedSite.setId("invalidSiteId"); + restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser() + .updateSiteMembershipRequest(moderatedSite, updatedMessage); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, managerUser.getUsername(), moderatedSite.getId())); + + moderatedSite.setId(moderatedSiteId); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Update site membership request - empty SiteId") + public void emptySiteIdUpdateSiteMembershipRequest() throws Exception + { + moderatedSite.setId(""); + restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser() + .updateSiteMembershipRequest(moderatedSite, updatedMessage); + + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) + .assertLastError() + .containsSummary(RestErrorModel.PUT_EMPTY_ARGUMENT) + .containsErrorKey(RestErrorModel.PUT_EMPTY_ARGUMENT) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + + moderatedSite.setId(moderatedSiteId); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify inexistent user is not able to update site membership request") + public void emptyUserCannotUpdateSiteMembershipRequest() throws Exception + { + UserModel emptyUser = new UserModel("", "password"); + restClient.authenticateUser(emptyUser).withCoreAPI().usingAuthUser() + .updateSiteMembershipRequest(moderatedSite, updatedMessage); + + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Update site membership request - rejected Request") + public void rejectRequestTheUpdateSiteMembershipRequest() throws Exception + { + UserModel userWithRejectedRequests = dataUser.createRandomTestUser(); + restClient.authenticateUser(userWithRejectedRequests).withCoreAPI().usingAuthUser() + .addSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + RestTaskModel taskModel = restClient.authenticateUser(userWithRejectedRequests).withWorkflowAPI().getTasks() + .getTaskModelByDescription(moderatedSite); + workflow.approveSiteMembershipRequest(managerUser.getUsername(), managerUser.getPassword(), taskModel.getId(), false, "Rejected"); + + requestUpdateModel = restClient.authenticateUser(userWithRejectedRequests).withCoreAPI().usingMe() + .updateSiteMembershipRequest(moderatedSite, updatedMessage); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, userWithRejectedRequests.getUsername(), moderatedSite.getId())) + .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Update site membership request - approved Request") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + public void approveRequestTheUpdateSiteMembershipRequest() throws JsonToModelConversionException, DataPreparationException, Exception + { + UserModel userWithApprovedRequests = dataUser.createRandomTestUser(); + restClient.authenticateUser(userWithApprovedRequests).withCoreAPI().usingAuthUser() + .addSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + RestTaskModel taskModel = restClient.authenticateUser(userWithApprovedRequests).withWorkflowAPI().getTasks().getTaskModelByDescription(moderatedSite); + workflow.approveSiteMembershipRequest(managerUser.getUsername(), managerUser.getPassword(), taskModel.getId(), true, "Approve"); + + requestUpdateModel = restClient.authenticateUser(userWithApprovedRequests).withCoreAPI().usingMe() + .updateSiteMembershipRequest(moderatedSite, updatedMessage); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, userWithApprovedRequests.getUsername(), moderatedSite.getId())) + .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify user is able to update site membership request - empty message") + public void userUpdateSiteMembershipRequestWithEmptyMessage() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + requestUpdateModel = restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser() + .addSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + requestUpdateModel.assertThat().field("id").is(moderatedSite.getId()) + .assertThat().field("message").is("Please accept me"); + + requestUpdateModel = restClient.withCoreAPI().usingMe() + .updateSiteMembershipRequest(moderatedSite, ""); + + restClient.assertStatusCodeIs(HttpStatus.OK); + requestUpdateModel.assertThat().field("id").is(moderatedSite.getId()) + .and().field("modifiedAt").isNotEmpty() + .assertThat().field("message").isNull(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }, executionType = ExecutionType.REGRESSION, + description = "Update site membership request using invalid network") + public void updateSiteMembershipRequestUsingInvalidNetwork() throws Exception + { + UserModel invalidUserNetwork = dataUser.createRandomTestUser(); + SiteModel site = dataSite.usingUser(invalidUserNetwork).createModeratedRandomSite(); + dataSite.usingUser(invalidUserNetwork).usingSite(site).addSiteToFavorites(); + invalidUserNetwork.setDomain("invalidNetwork"); + + requestUpdateModel = restClient.authenticateUser(invalidUserNetwork).withCoreAPI().usingMe() + .updateSiteMembershipRequest(site, updatedMessage); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL}, executionType = ExecutionType.REGRESSION, + description = "Verify user is not able to update an inexitent site membership request") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + public void userIsNotAbleToUpdateAnInexistentSiteMembershipRequest() throws JsonToModelConversionException, DataPreparationException, Exception + { + SiteModel moderatedSite = dataSite.usingUser(managerUser).createModeratedRandomSite(); + UserModel newMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser() + .updateSiteMembershipRequest(moderatedSite, updatedMessage); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, newMember.getUsername(), moderatedSite.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }, executionType = ExecutionType.REGRESSION, + description = "Verify user is not able to update a deleted site membership request") + public void userCantUpdateSiteMembershipRequestForDeletedRequest() throws Exception + { + SiteModel moderatedSite = dataSite.usingUser(managerUser).createModeratedRandomSite(); + UserModel newMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser() + .addSiteMembershipRequest(moderatedSite); + + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser() + .deleteSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + requestUpdateModel = restClient.withCoreAPI().usingAuthUser() + .updateSiteMembershipRequest(moderatedSite, updatedMessage); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, newMember.getUsername(), moderatedSite.getId())); } } From 987f26f89f8765f013e6f3588266fe4a9f92b118 Mon Sep 17 00:00:00 2001 From: mionescu Date: Mon, 23 Jan 2017 16:44:07 +0200 Subject: [PATCH 0911/1491] updated test (removed bug id: MNT-16917) - addFileFavoriteUsingTagId, addSiteFavoriteUsingTagId --- .../org/alfresco/rest/favorites/AddFavoritesCoreTests.java | 3 +-- .../org/alfresco/rest/people/AddFavoriteSiteFullTests.java | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesCoreTests.java b/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesCoreTests.java index 941dd06b5..54cdbcee7 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesCoreTests.java @@ -181,14 +181,13 @@ public class AddFavoritesCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); } - @Bug(id="MNT-16917") @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify add file favorite with tag id returns status code 404") @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) public void addFileFavoriteUsingTagId() throws Exception { FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - returnedModel = restClient.withCoreAPI().usingResource(document).addTag("random_tag"); + returnedModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addTag("random_tag"); file.setNodeRef(returnedModel.getId()); restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFileToFavorites(file); diff --git a/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteFullTests.java b/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteFullTests.java index 19510d56a..4367dce8a 100644 --- a/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteFullTests.java +++ b/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteFullTests.java @@ -230,14 +230,13 @@ public class AddFavoriteSiteFullTests extends RestTest siteModel.setId(id); } - @Bug(id="MNT-16917") @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Check that if user provides site in id but id is of a tag status code is 404") @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) public void addSiteFavoriteUsingTagId() throws Exception { FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - returnedModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).addTag("random_tag"); + returnedModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addTag("random_tag"); file.setNodeRef(returnedModel.getId()); siteModel.setId(returnedModel.getId()); From 3ee3529ebed7a920193961979265936fa8a3dd88 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Mon, 23 Jan 2017 17:56:13 +0200 Subject: [PATCH 0912/1491] Add site member - full tests --- .../rest/sites/AddSiteMemberFullTests.java | 254 ++++++++++++++++++ 1 file changed, 254 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/sites/AddSiteMemberFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberFullTests.java b/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberFullTests.java new file mode 100644 index 000000000..4c4c2ad93 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberFullTests.java @@ -0,0 +1,254 @@ +package org.alfresco.rest.sites; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestSiteMemberModel; +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 AddSiteMemberFullTests extends RestTest +{ + private UserModel adminUserModel; + private SiteModel publicSiteModel; + private SiteModel moderatedSiteModel; + private SiteModel privateSiteModel; + private String addMembersJson; + private RestSiteMemberModel memberModel; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + publicSiteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + moderatedSiteModel = dataSite.usingUser(adminUserModel).createModeratedRandomSite(); + privateSiteModel = dataSite.usingUser(adminUserModel).createPrivateRandomSite(); + addMembersJson = "{\"role\":\"%s\",\"id\":\"%s\"}"; + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Check default error schema when request fails") + public void checkDefaultErrorSchema() throws Exception + { + UserModel testUser = new UserModel("inexistentUser", "password"); + testUser.setUserRole(UserRole.SiteManager); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, testUser.getUsername())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Add new site member request by providing an empty body") + public void addSiteMemberUsingEmptyBody() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI(); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "", "sites/{siteId}/members?{parameters}", + publicSiteModel.getId(), restClient.getParameters()); + restClient.processModel(RestSiteMemberModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.NO_CONTENT, "No content to map to Object due to end of input")) + .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "No content to map to Object due to end of input")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Check lower and upper case letters for role field") + public void checkLowerUpperCaseLettersForRole() throws Exception + { + UserModel user = dataUser.createRandomTestUser(); + + String json = String.format(addMembersJson, "SITEMANAGER", user.getUsername()); + restClient.authenticateUser(adminUserModel).withCoreAPI(); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, json, "sites/{siteId}/members?{parameters}", publicSiteModel.getId(), restClient.getParameters()); + restClient.processModel(RestSiteMemberModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.UNKNOWN_ROLE, "SITEMANAGER")) + .containsErrorKey(String.format(RestErrorModel.UNKNOWN_ROLE, "SITEMANAGER")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + + json = String.format(addMembersJson, "sitemanager", user.getUsername()); + restClient.authenticateUser(adminUserModel).withCoreAPI(); + request = RestRequest.requestWithBody(HttpMethod.POST, json, "sites/{siteId}/members?{parameters}", publicSiteModel.getId(), restClient.getParameters()); + restClient.processModel(RestSiteMemberModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.UNKNOWN_ROLE, "sitemanager")) + .containsErrorKey(String.format(RestErrorModel.UNKNOWN_ROLE, "sitemanager")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Check empty value for user role") + public void checkEmptyValueForRole() throws Exception + { + UserModel user = dataUser.createRandomTestUser(); + + String json = String.format(addMembersJson, "", user.getUsername()); + restClient.authenticateUser(adminUserModel).withCoreAPI(); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, json, "sites/{siteId}/members?{parameters}", publicSiteModel.getId(), restClient.getParameters()); + restClient.processModel(RestSiteMemberModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.NO_CONTENT, + "N/A (through reference chain: org.alfresco.rest.api.model.SiteMember[\"role\"])")); + + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that collaborator role can be added to public site") + public void addCollaboratorToPublicSite() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteCollaborator); + memberModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + memberModel.assertThat().field("id").is(testUser.getUsername()) + .and().field("role").is(testUser.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that contributor role can be added to public site") + public void addContributorToPublicSite() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteContributor); + memberModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + memberModel.assertThat().field("id").is(testUser.getUsername()) + .and().field("role").is(testUser.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that consumer role can be added to public site") + public void addConsumerToPublicSite() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteConsumer); + memberModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + memberModel.assertThat().field("id").is(testUser.getUsername()) + .and().field("role").is(testUser.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that collaborator role can be added to moderated site") + public void addCollaboratorToModeratedSite() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteCollaborator); + memberModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + memberModel.assertThat().field("id").is(testUser.getUsername()) + .and().field("role").is(testUser.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that contributor role can be added to moderated site") + public void addContributorToModeratedSite() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteContributor); + memberModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + memberModel.assertThat().field("id").is(testUser.getUsername()) + .and().field("role").is(testUser.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that consumer role can be added to moderated site") + public void addConsumerToModeratedSite() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteConsumer); + memberModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + memberModel.assertThat().field("id").is(testUser.getUsername()) + .and().field("role").is(testUser.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that collaborator role can be added to private site") + public void addCollaboratorToPrivateSite() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteCollaborator); + memberModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + memberModel.assertThat().field("id").is(testUser.getUsername()) + .and().field("role").is(testUser.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that contributor role can be added to private site") + public void addContributorToPrivateSite() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteContributor); + memberModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + memberModel.assertThat().field("id").is(testUser.getUsername()) + .and().field("role").is(testUser.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that consumer role can be added to private site") + public void addConsumerToPrivateSite() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteConsumer); + memberModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + memberModel.assertThat().field("id").is(testUser.getUsername()) + .and().field("role").is(testUser.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin can be added to private site by site manager") + public void adminCanBeAddedToPrivateSiteBySiteManager() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser(); + SiteModel privateSite = dataSite.usingUser(testUser).createPrivateRandomSite(); + memberModel = restClient.authenticateUser(testUser).withCoreAPI().usingSite(privateSite).addPerson(adminUserModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + memberModel.assertThat().field("id").is(adminUserModel.getUsername()) + .and().field("role").is(adminUserModel.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin can be added to private site by site manager") + public void adminCanBeAddedToPrivateSiteBySiteCollaborator() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser(); + SiteModel privateSite = dataSite.usingUser(testUser).createPrivateRandomSite(); + UserModel siteCollaborator = dataUser.createRandomTestUser(); + dataUser.addUserToSite(siteCollaborator, privateSite, UserRole.SiteCollaborator); + memberModel = restClient.authenticateUser(siteCollaborator).withCoreAPI().usingSite(privateSite).addPerson(adminUserModel); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } +} \ No newline at end of file From 75ec88f743ac0e1e795e69bdf620db784ff2876e Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Wed, 25 Jan 2017 10:37:52 +0200 Subject: [PATCH 0913/1491] minor format changes --- .../rest/people/GetSiteMembershipRequestFullTests.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestFullTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestFullTests.java index 2987f71e3..18f9c9c4a 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestFullTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestFullTests.java @@ -38,7 +38,7 @@ public class GetSiteMembershipRequestFullTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify site manager can get site membership requests on moderated site and response is not found (200)") + description = "Verify site manager can get site membership requests on moderated site and response is successful (200)") public void siteManagerCanGetModeratedSiteMembershipRequests() throws Exception { UserModel moderatedUser = dataUser.createRandomTestUser(); @@ -147,7 +147,8 @@ public class GetSiteMembershipRequestFullTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify request returns status 200 when using valid parameters") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify that getFavoriteSites request returns status 200 when using valid parameters") public void getSiteMembershipRequestUsingParameters() throws Exception { RestSiteMembershipRequestModel returnedModel = restClient.withParams("message=Please accept me") From 0b76795c09632a687dc1e9ace3332b8dbc8d6f61 Mon Sep 17 00:00:00 2001 From: Andrei Rusu Date: Wed, 25 Jan 2017 10:59:25 +0200 Subject: [PATCH 0914/1491] updated according to comments --- .../rest/tags/DeleteTagFullTests.java | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/tags/DeleteTagFullTests.java b/e2e-test/java/org/alfresco/rest/tags/DeleteTagFullTests.java index b864eda33..db7d2c4c3 100644 --- a/e2e-test/java/org/alfresco/rest/tags/DeleteTagFullTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/DeleteTagFullTests.java @@ -106,13 +106,28 @@ public class DeleteTagFullTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, - executionType = ExecutionType.REGRESSION, description = "Verify Contributor user cannot delete tag added by another user. Check default error model schema.") + executionType = ExecutionType.REGRESSION, description = "Verify Manager user can delete tag added by another user.") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) - public void contributorCannotDeleteTagAddedByAnotherUserCheckDefaultErrorModelSchema() throws JsonToModelConversionException, Exception + public void managerCanDeleteTagAddedByAnotherUser() throws JsonToModelConversionException, Exception { String tag = RandomStringUtils.randomAlphanumeric(10); - tagReturnedModel = restClient.authenticateUser(adminUserModel) + tagReturnedModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingResource(document).addTag(tag); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(document).deleteTag(tagReturnedModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, + executionType = ExecutionType.REGRESSION, description = "Check default error model schema. Contributor cannot delete tag added by Manager.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) + public void checkDefaultErrorModelSchema() throws JsonToModelConversionException, Exception + { + String tag = RandomStringUtils.randomAlphanumeric(10); + + tagReturnedModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) .withCoreAPI().usingResource(document).addTag(tag); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) From 61e579efe42eca33e7fca7e1703c5b4c6ddc825a Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Wed, 25 Jan 2017 11:41:43 +0200 Subject: [PATCH 0915/1491] Fix some failing tests --- .../rest/sites/AddSiteMemberFullTests.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberFullTests.java b/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberFullTests.java index 4c4c2ad93..ed5f3e0b5 100644 --- a/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberFullTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberFullTests.java @@ -104,9 +104,10 @@ public class AddSiteMemberFullTests extends RestTest RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, json, "sites/{siteId}/members?{parameters}", publicSiteModel.getId(), restClient.getParameters()); restClient.processModel(RestSiteMemberModel.class, request); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.NO_CONTENT, - "N/A (through reference chain: org.alfresco.rest.api.model.SiteMember[\"role\"])")); - + .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "N/A (through reference chain: org.alfresco.rest.api.model.SiteMember[\"role\"])")) + .containsSummary(String.format(RestErrorModel.NO_CONTENT, "N/A (through reference chain: org.alfresco.rest.api.model.SiteMember[\"role\"])")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) @@ -233,21 +234,22 @@ public class AddSiteMemberFullTests extends RestTest { UserModel testUser = dataUser.createRandomTestUser(); SiteModel privateSite = dataSite.usingUser(testUser).createPrivateRandomSite(); + adminUserModel.setUserRole(UserRole.SiteContributor); memberModel = restClient.authenticateUser(testUser).withCoreAPI().usingSite(privateSite).addPerson(adminUserModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); - memberModel.assertThat().field("id").is(adminUserModel.getUsername()) - .and().field("role").is(adminUserModel.getUserRole()); + memberModel.assertThat().field("id").is(adminUserModel.getUsername()).and().field("role").is(adminUserModel.getUserRole()); } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin can be added to private site by site manager") - public void adminCanBeAddedToPrivateSiteBySiteCollaborator() throws Exception + description = "Verify that admin cannot be added to private site by site collaborator") + public void adminCannotBeAddedToPrivateSiteBySiteCollaborator() throws Exception { UserModel testUser = dataUser.createRandomTestUser(); SiteModel privateSite = dataSite.usingUser(testUser).createPrivateRandomSite(); UserModel siteCollaborator = dataUser.createRandomTestUser(); dataUser.addUserToSite(siteCollaborator, privateSite, UserRole.SiteCollaborator); + adminUserModel.setUserRole(UserRole.SiteContributor); memberModel = restClient.authenticateUser(siteCollaborator).withCoreAPI().usingSite(privateSite).addPerson(adminUserModel); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } From 8c70ac106dd581d172a36513039df547edf4ba9e Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Wed, 25 Jan 2017 11:49:19 +0200 Subject: [PATCH 0916/1491] updates: removing some @TestRail groups --- .../UpdateSiteMembershipRequestFullTests.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestFullTests.java b/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestFullTests.java index fbe49a7c9..de9774b0c 100644 --- a/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestFullTests.java +++ b/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestFullTests.java @@ -190,7 +190,7 @@ public class UpdateSiteMembershipRequestFullTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to update site membership request") - public void adminIsAbleToRetrieveSiteMembershipRequest() throws JsonToModelConversionException, Exception + public void adminIsAbleToUpdateSiteMembershipRequest() throws JsonToModelConversionException, Exception { regularUser = dataUser.createRandomTestUser(); SiteModel anotherModeratedSite = dataSite.usingUser(regularUser).createModeratedRandomSite(); @@ -391,7 +391,7 @@ public class UpdateSiteMembershipRequestFullTests extends RestTest moderatedSite.setId(moderatedSiteId); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify inexistent user is not able to update site membership request") public void emptyUserCannotUpdateSiteMembershipRequest() throws Exception @@ -408,7 +408,7 @@ public class UpdateSiteMembershipRequestFullTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Update site membership request - rejected Request") - public void rejectRequestTheUpdateSiteMembershipRequest() throws Exception + public void rejectRequestThenUpdateSiteMembershipRequest() throws Exception { UserModel userWithRejectedRequests = dataUser.createRandomTestUser(); restClient.authenticateUser(userWithRejectedRequests).withCoreAPI().usingAuthUser() @@ -432,7 +432,7 @@ public class UpdateSiteMembershipRequestFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Update site membership request - approved Request") @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - public void approveRequestTheUpdateSiteMembershipRequest() throws JsonToModelConversionException, DataPreparationException, Exception + public void approveRequestThenUpdateSiteMembershipRequest() throws JsonToModelConversionException, DataPreparationException, Exception { UserModel userWithApprovedRequests = dataUser.createRandomTestUser(); restClient.authenticateUser(userWithApprovedRequests).withCoreAPI().usingAuthUser() @@ -474,7 +474,7 @@ public class UpdateSiteMembershipRequestFullTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Update site membership request using invalid network") public void updateSiteMembershipRequestUsingInvalidNetwork() throws Exception { @@ -490,9 +490,9 @@ public class UpdateSiteMembershipRequestFullTests extends RestTest .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL}, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE}, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to update an inexitent site membership request") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) public void userIsNotAbleToUpdateAnInexistentSiteMembershipRequest() throws JsonToModelConversionException, DataPreparationException, Exception { SiteModel moderatedSite = dataSite.usingUser(managerUser).createModeratedRandomSite(); @@ -506,7 +506,7 @@ public class UpdateSiteMembershipRequestFullTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE}, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to update a deleted site membership request") public void userCantUpdateSiteMembershipRequestForDeletedRequest() throws Exception { From 291190e84c63378ae232c9c346e871e2691a3416 Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 25 Jan 2017 12:13:15 +0200 Subject: [PATCH 0917/1491] TAS - 2796 --- .../rest/ratings/AddRatingCoreTests.java | 35 +++ .../rest/ratings/DeleteRatingCoreTests.java | 35 ++- .../rest/ratings/DeleteRatingFullTests.java | 237 ++++++++++++++++++ .../rest/ratings/DeleteRatingSanityTests.java | 9 +- 4 files changed, 293 insertions(+), 23 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/ratings/DeleteRatingFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/ratings/AddRatingCoreTests.java b/e2e-test/java/org/alfresco/rest/ratings/AddRatingCoreTests.java index a86c4a6af..123976721 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/AddRatingCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/AddRatingCoreTests.java @@ -123,6 +123,24 @@ public class AddRatingCoreTests extends RestTest returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty(); } + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Verify that manager is able to like a site") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) + public void managerIsAbleToLikeASite() throws Exception + { + FolderModel folderModel = new FolderModel(); + folderModel.setNodeRef(siteModel.getGuid()); + + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(folderModel) + .likeDocument(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty(); + + restClient.withCoreAPI().usingResource(folderModel).getRatings() + .assertNodeIsLiked(); + } + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Verify that manager is able to rate a folder") @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) @@ -150,6 +168,23 @@ public class AddRatingCoreTests extends RestTest returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); } + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Verify that manager is able to rate a site") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) + public void managerIsAbleToRateASite() throws Exception + { + FolderModel folderModel = new FolderModel(); + folderModel.setNodeRef(siteModel.getGuid()); + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(folderModel) + .rateStarsToDocument(5); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); + + restClient.withCoreAPI().usingResource(folderModel).getRatings() + .assertNodeHasFiveStarRating(); + } + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Verify that adding like again has no effect on a file") @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) diff --git a/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingCoreTests.java b/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingCoreTests.java index a3f0b61e9..55216d92d 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingCoreTests.java @@ -46,7 +46,12 @@ public class DeleteRatingCoreTests extends RestTest FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).deleteInvalidRating("random_rating"); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_RATING, "random_rating")); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsSummary(String.format(RestErrorModel.INVALID_RATING, "random_rating")) + .containsErrorKey(String.format(RestErrorModel.INVALID_RATING, "random_rating")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); } @TestRail(section = { TestGroup.REST_API, @@ -121,34 +126,24 @@ public class DeleteRatingCoreTests extends RestTest } @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Delete rating of a document using site manager") + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Verify site manager is not able to remove rating added by another user") @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) + @Bug(id = "ACE-5459") public void deleteDocumentRatingUsingManager() throws Exception { FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(document).rateStarsToDocument(5); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(document).likeDocument(); + restClient.withCoreAPI().usingResource(document).likeDocument(); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(document).deleteFiveStarRating(); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(document).deleteLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + restClient.withCoreAPI().usingResource(document).deleteLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - restClient.withCoreAPI().usingResource(document).getRatings().assertNodeIsLiked().assertNodeHasFiveStarRating(); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "One user is not able to delete like of another user") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) - public void deleteLikeOfAnotherUser() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingResource(document).likeDocument(); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(document).deleteLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingResource(document).getRatings().assertNodeIsLiked(); + restClient.withCoreAPI().usingResource(document).getRatings() + .assertNodeIsLiked() + .assertNodeHasFiveStarRating(); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingFullTests.java b/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingFullTests.java new file mode 100644 index 000000000..b2dfd66d6 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingFullTests.java @@ -0,0 +1,237 @@ +package org.alfresco.rest.ratings; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestRatingModel; +import org.alfresco.rest.model.RestRatingModelsCollection; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.exception.DataPreparationException; +import org.alfresco.utility.model.*; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Created by Claudia Agache on 1/25/2017. + */ +public class DeleteRatingFullTests extends RestTest +{ + private SiteModel siteModel; + private UserModel adminUser; + private DataUser.ListUserWithRoles usersWithRoles; + private RestRatingModelsCollection returnedRatingModelCollection; + private RestRatingModel returnedRatingModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws DataPreparationException + { + adminUser = dataUser.getAdminUser(); + siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); + + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Verify site contributor is not able to remove rating added by another user") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) + @Bug(id = "ACE-5459") + public void contributorIsNotAbleToDeleteRatingsOfAnotherUser() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(document).rateStarsToDocument(5); + restClient.withCoreAPI().usingResource(document).likeDocument(); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingResource(document).deleteFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + restClient.withCoreAPI().usingResource(document).deleteLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + + restClient.withCoreAPI().usingResource(document).getRatings() + .assertNodeIsLiked() + .assertNodeHasFiveStarRating(); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Verify site collaborator is not able to remove rating added by another user") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) + @Bug(id = "ACE-5459") + public void collaboratorIsNotAbleToDeleteRatingsOfAnotherUser() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(document).rateStarsToDocument(5); + restClient.withCoreAPI().usingResource(document).likeDocument(); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(document).deleteFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + restClient.withCoreAPI().usingResource(document).deleteLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + + restClient.withCoreAPI().usingResource(document).getRatings() + .assertNodeIsLiked() + .assertNodeHasFiveStarRating(); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Verify site consumer is not able to remove rating added by another user") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) + @Bug(id = "ACE-5459") + public void consumerIsNotAbleToDeleteRatingsOfAnotherUser() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(document).rateStarsToDocument(5); + restClient.withCoreAPI().usingResource(document).likeDocument(); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingResource(document).deleteFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + restClient.withCoreAPI().usingResource(document).deleteLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + + restClient.withCoreAPI().usingResource(document).getRatings() + .assertNodeIsLiked() + .assertNodeHasFiveStarRating(); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Delete rating stars twice") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) + @Bug(id = "MNT-17181") + public void deleteStarsTwice() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(document).rateStarsToDocument(5); + + restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + returnedRatingModelCollection = restClient.withCoreAPI().usingResource(document).getRatings(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedRatingModelCollection.assertNodeHasNoFiveStarRating(); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).deleteFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Delete like rating twice") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) + @Bug(id = "MNT-17181") + public void deleteLikeTwice() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + restClient.withCoreAPI().usingResource(document).likeDocument(); + + restClient.withCoreAPI().usingResource(document).deleteLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + returnedRatingModelCollection = restClient.withCoreAPI().usingResource(document).getRatings(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedRatingModelCollection.assertNodeIsNotLiked(); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).deleteLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Delete like for a folder then add it again") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) + public void likeFolderAfterLikeRatingIsDeleted() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folderModel).likeDocument(); + restClient.withCoreAPI().usingResource(folderModel).deleteLikeRating(); + returnedRatingModel = restClient.withCoreAPI().usingResource(folderModel).likeDocument(); + + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Delete stars for a folder then add them again") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) + public void addStarsToFolderAfterRatingIsDeleted() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(folderModel).rateStarsToDocument(5); + restClient.withCoreAPI().usingResource(folderModel).deleteFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + returnedRatingModel = restClient.withCoreAPI().usingResource(folderModel).rateStarsToDocument(5); + + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Delete like for a site then add it again") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) + public void likeSiteAfterLikeRatingIsDeleted() throws Exception + { + FolderModel folderModel = new FolderModel(); + folderModel.setNodeRef(siteModel.getGuid()); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folderModel).likeDocument(); + restClient.withCoreAPI().usingResource(folderModel).deleteLikeRating(); + returnedRatingModel = restClient.withCoreAPI().usingResource(folderModel).likeDocument(); + + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Delete stars for a site then add them again") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) + public void addStarsToSiteAfterRatingIsDeleted() throws Exception + { + FolderModel folderModel = new FolderModel(); + folderModel.setNodeRef(siteModel.getGuid()); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(folderModel).rateStarsToDocument(5); + restClient.withCoreAPI().usingResource(folderModel).deleteFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + returnedRatingModel = restClient.withCoreAPI().usingResource(folderModel).rateStarsToDocument(5); + + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Verify user with Manager role is able to remove one star rating of a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) + public void removeOneStarRating() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + restClient.withCoreAPI().usingResource(document).rateStarsToDocument(1); + + restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + returnedRatingModelCollection = restClient.withCoreAPI().usingResource(document).getRatings(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedRatingModelCollection.assertNodeIsNotLiked().assertNodeHasNoFiveStarRating().and().entriesListIsNotEmpty().and().paginationExist(); + } + +} diff --git a/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java index 10d6bc214..b6361d095 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java @@ -203,10 +203,13 @@ public class DeleteRatingSanityTests extends RestTest restClient.authenticateUser(userB); - restClient.authenticateUser(userB).withCoreAPI().usingResource(document).deleteLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); + restClient.withCoreAPI().usingResource(document).deleteLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + restClient.withCoreAPI().usingResource(document).getRatings() + .assertNodeIsLiked() + .assertNodeHasFiveStarRating(); } } \ No newline at end of file From 48d0e0fd0d7455455bc6f85d72c5cf9bc52e288a Mon Sep 17 00:00:00 2001 From: Andrei Rusu Date: Wed, 25 Jan 2017 12:21:32 +0200 Subject: [PATCH 0918/1491] added changes to test for scenario: check default error model schema --- .../rest/tags/DeleteTagCoreTests.java | 10 ++++--- .../rest/tags/DeleteTagFullTests.java | 26 +------------------ 2 files changed, 8 insertions(+), 28 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/tags/DeleteTagCoreTests.java b/e2e-test/java/org/alfresco/rest/tags/DeleteTagCoreTests.java index 431573fdc..98c6b53ea 100644 --- a/e2e-test/java/org/alfresco/rest/tags/DeleteTagCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/DeleteTagCoreTests.java @@ -36,16 +36,20 @@ public class DeleteTagCoreTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that if user has no permission to remove tag returned status code is 403") + description = "Verify that if user has no permission to remove tag returned status code is 403. Check default error model schema") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) - public void deleteTagWithUserWithoutPermission() throws Exception + public void deleteTagWithUserWithoutPermissionCheckDefaultErrorModelSchema() throws Exception { restClient.authenticateUser(adminUserModel); RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); restClient.authenticateUser(userModel); restClient.withCoreAPI().usingResource(document).deleteTag(tag); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); } @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, diff --git a/e2e-test/java/org/alfresco/rest/tags/DeleteTagFullTests.java b/e2e-test/java/org/alfresco/rest/tags/DeleteTagFullTests.java index db7d2c4c3..869b2b4d1 100644 --- a/e2e-test/java/org/alfresco/rest/tags/DeleteTagFullTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/DeleteTagFullTests.java @@ -3,7 +3,6 @@ package org.alfresco.rest.tags; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestTagModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; @@ -118,28 +117,5 @@ public class DeleteTagFullTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) .withCoreAPI().usingResource(document).deleteTag(tagReturnedModel); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, - executionType = ExecutionType.REGRESSION, description = "Check default error model schema. Contributor cannot delete tag added by Manager.") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) - public void checkDefaultErrorModelSchema() throws JsonToModelConversionException, Exception - { - String tag = RandomStringUtils.randomAlphanumeric(10); - - tagReturnedModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(document).addTag(tag); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) - .withCoreAPI().usingResource(document).deleteTag(tagReturnedModel); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - - returnedTag = restClient.withCoreAPI().getTag(tagReturnedModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedTag.assertThat().field("tag").is(tag.toLowerCase()); - } + } } From 929b5c2b5a56c4adbd30ed7b8de347b760481f1a Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Wed, 25 Jan 2017 14:21:20 +0200 Subject: [PATCH 0919/1491] Added UpdateSiteMemberFullTests and removed @Bug from UpdateSiteMemberSanityTests --- .../rest/sites/UpdateSiteMemberFullTests.java | 279 ++++++++++++++++++ .../sites/UpdateSiteMemberSanityTests.java | 9 +- 2 files changed, 282 insertions(+), 6 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberFullTests.java b/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberFullTests.java new file mode 100644 index 000000000..205e3735d --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberFullTests.java @@ -0,0 +1,279 @@ +package org.alfresco.rest.sites; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestSiteMemberModel; +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 UpdateSiteMemberFullTests extends RestTest +{ + private UserModel adminUser, anotherManager; + private SiteModel publicSite, moderatedSite, privateSite; + private RestSiteMemberModel updatedMember; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + publicSite = dataSite.usingUser(adminUser).createPublicRandomSite(); + moderatedSite = dataSite.usingUser(adminUser).createModeratedRandomSite(); + privateSite = dataSite.usingUser(adminUser).createPrivateRandomSite(); + anotherManager = dataUser.createRandomTestUser(); + dataUser.addUserToSite(anotherManager, publicSite, UserRole.SiteManager); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if manager is able to update another site manager to site contributor") + public void managerUpdateSiteManagerToSiteContributor() throws Exception + { + UserModel siteManager = dataUser.createRandomTestUser(); + dataUser.addUserToSite(siteManager, publicSite, UserRole.SiteManager); + + siteManager.setUserRole(UserRole.SiteContributor); + updatedMember = restClient.authenticateUser(anotherManager).withCoreAPI() + .usingSite(publicSite).updateSiteMember(siteManager); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedMember.assertThat().field("id").is(siteManager.getUsername()).and().field("role").is(siteManager.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if manager is able to update another site manager to site consumer") + public void managerUpdateSiteManagerToSiteConsumer() throws Exception + { + UserModel siteManager = dataUser.createRandomTestUser(); + dataUser.addUserToSite(siteManager, publicSite, UserRole.SiteManager); + + siteManager.setUserRole(UserRole.SiteConsumer); + updatedMember = restClient.authenticateUser(anotherManager).withCoreAPI() + .usingSite(publicSite).updateSiteMember(siteManager); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedMember.assertThat().field("id").is(siteManager.getUsername()).and().field("role").is(siteManager.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if manager is able to update site contributor to site collaborator") + public void managerUpdateSiteContributorToSiteCollaborator() throws Exception + { + UserModel siteContributor = dataUser.createRandomTestUser(); + dataUser.addUserToSite(siteContributor, publicSite, UserRole.SiteContributor); + + siteContributor.setUserRole(UserRole.SiteCollaborator); + updatedMember = restClient.authenticateUser(anotherManager).withCoreAPI() + .usingSite(publicSite).updateSiteMember(siteContributor); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedMember.assertThat().field("id").is(siteContributor.getUsername()).and().field("role").is(siteContributor.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if manager is able to update site contributor to site consumer") + public void managerUpdateSiteContributorToSiteConsumer() throws Exception + { + UserModel siteContributor = dataUser.createRandomTestUser(); + dataUser.addUserToSite(siteContributor, publicSite, UserRole.SiteContributor); + + siteContributor.setUserRole(UserRole.SiteConsumer); + updatedMember = restClient.authenticateUser(anotherManager).withCoreAPI() + .usingSite(publicSite).updateSiteMember(siteContributor); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedMember.assertThat().field("id").is(siteContributor.getUsername()).and().field("role").is(siteContributor.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if manager is able to update site collaborator to site contributor") + public void managerUpdateSiteCollaboratorToSiteContributor() throws Exception + { + UserModel siteCollaborator = dataUser.createRandomTestUser(); + dataUser.addUserToSite(siteCollaborator, publicSite, UserRole.SiteCollaborator); + + siteCollaborator.setUserRole(UserRole.SiteContributor); + updatedMember = restClient.authenticateUser(anotherManager).withCoreAPI() + .usingSite(publicSite).updateSiteMember(siteCollaborator); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedMember.assertThat().field("id").is(siteCollaborator.getUsername()).and().field("role").is(siteCollaborator.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if manager is able to update site collaborator to site consumer") + public void managerUpdateSiteCollaboratorToSiteConsumer() throws Exception + { + UserModel siteCollaborator = dataUser.createRandomTestUser(); + dataUser.addUserToSite(siteCollaborator, publicSite, UserRole.SiteCollaborator); + + siteCollaborator.setUserRole(UserRole.SiteConsumer); + updatedMember = restClient.authenticateUser(anotherManager).withCoreAPI() + .usingSite(publicSite).updateSiteMember(siteCollaborator); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedMember.assertThat().field("id").is(siteCollaborator.getUsername()).and().field("role").is(siteCollaborator.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if manager is able to update site consumer to site collaborator") + public void managerUpdateSiteConsumerToSiteCollaborator() throws Exception + { + UserModel siteConsumer = dataUser.createRandomTestUser(); + dataUser.addUserToSite(siteConsumer, publicSite, UserRole.SiteConsumer); + + siteConsumer.setUserRole(UserRole.SiteCollaborator); + updatedMember = restClient.authenticateUser(anotherManager).withCoreAPI() + .usingSite(publicSite).updateSiteMember(siteConsumer); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedMember.assertThat().field("id").is(siteConsumer.getUsername()).and().field("role").is(siteConsumer.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if manager is able to update site consumer to site contributor") + public void managerUpdateSiteConsumerToSiteContributor() throws Exception + { + UserModel siteConsumer = dataUser.createRandomTestUser(); + dataUser.addUserToSite(siteConsumer, publicSite, UserRole.SiteConsumer); + + siteConsumer.setUserRole(UserRole.SiteContributor); + updatedMember = restClient.authenticateUser(anotherManager).withCoreAPI() + .usingSite(publicSite).updateSiteMember(siteConsumer); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedMember.assertThat().field("id").is(siteConsumer.getUsername()).and().field("role").is(siteConsumer.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if manager is able to update another site manager to site manager") + public void managerUpdateSiteManagerToSiteManager() throws Exception + { + UserModel siteManager = dataUser.createRandomTestUser(); + dataUser.addUserToSite(siteManager, publicSite, UserRole.SiteManager); + + siteManager.setUserRole(UserRole.SiteManager); + updatedMember = restClient.authenticateUser(anotherManager).withCoreAPI() + .usingSite(publicSite).updateSiteMember(siteManager); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedMember.assertThat().field("id").is(siteManager.getUsername()).and().field("role").is(siteManager.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if manager is able to update site collaborator to site collaborator") + public void managerUpdateSiteCollaboratorToSiteCollaborator() throws Exception + { + UserModel siteCollaborator = dataUser.createRandomTestUser(); + dataUser.addUserToSite(siteCollaborator, publicSite, UserRole.SiteCollaborator); + + siteCollaborator.setUserRole(UserRole.SiteCollaborator); + updatedMember = restClient.authenticateUser(anotherManager).withCoreAPI() + .usingSite(publicSite).updateSiteMember(siteCollaborator); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedMember.assertThat().field("id").is(siteCollaborator.getUsername()).and().field("role").is(siteCollaborator.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if manager is able to update site contributor to site contributor") + public void managerUpdateSiteContributorToSiteContributor() throws Exception + { + UserModel siteContributor = dataUser.createRandomTestUser(); + dataUser.addUserToSite(siteContributor, publicSite, UserRole.SiteContributor); + + siteContributor.setUserRole(UserRole.SiteContributor); + updatedMember = restClient.authenticateUser(anotherManager).withCoreAPI() + .usingSite(publicSite).updateSiteMember(siteContributor); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedMember.assertThat().field("id").is(siteContributor.getUsername()).and().field("role").is(siteContributor.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if manager is able to update site consumer to site consumer") + public void managerUpdateSiteConsumerToSiteConsumer() throws Exception + { + UserModel siteConsumer = dataUser.createRandomTestUser(); + dataUser.addUserToSite(siteConsumer, publicSite, UserRole.SiteConsumer); + + siteConsumer.setUserRole(UserRole.SiteConsumer); + updatedMember = restClient.authenticateUser(anotherManager).withCoreAPI() + .usingSite(publicSite).updateSiteMember(siteConsumer); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedMember.assertThat().field("id").is(siteConsumer.getUsername()).and().field("role").is(siteConsumer.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if manager of a private site is able to downgrade his role") + public void privateSiteManagerDowngradesRole() throws Exception + { + UserModel siteManager = dataUser.createRandomTestUser(); + dataUser.addUserToSite(siteManager, privateSite, UserRole.SiteManager); + + siteManager.setUserRole(UserRole.SiteConsumer); + updatedMember = restClient.authenticateUser(siteManager).withCoreAPI() + .usingSite(privateSite).updateSiteMember(siteManager); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedMember.assertThat().field("id").is(siteManager.getUsername()).and().field("role").is(siteManager.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if manager of a moderated site is able to downgrade his role") + public void moderatedSiteManagerDowngradesRole() throws Exception + { + UserModel siteManager = dataUser.createRandomTestUser(); + dataUser.addUserToSite(siteManager, moderatedSite, UserRole.SiteManager); + + siteManager.setUserRole(UserRole.SiteConsumer); + updatedMember = restClient.authenticateUser(siteManager).withCoreAPI() + .usingSite(moderatedSite).updateSiteMember(siteManager); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedMember.assertThat().field("id").is(siteManager.getUsername()).and().field("role").is(siteManager.getUserRole()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify the response of updating a site member with empty body at request") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) + public void verifyManagerCanNotUpdateSiteMemberWithEmptyBody() throws Exception + { + restClient.authenticateUser(anotherManager).withCoreAPI(); + UserModel siteCollaborator = dataUser.createRandomTestUser(); + dataUser.addUserToSite(siteCollaborator, publicSite, UserRole.SiteCollaborator); + siteCollaborator.setUserRole(UserRole.SiteConsumer); + + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "", "sites/{siteId}/members/{personId}", publicSite.getId(), siteCollaborator.getUsername()); + restClient.processModel(RestSiteMemberModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.NO_CONTENT, "No content to map to Object due to end of input")) + .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "No content to map to Object due to end of input")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if manager is able to update a user that has created a merge request, but it's not a member of the site yet") + public void verifyManagerCanNotUpdateUserWithMergeRequest() throws Exception + { + UserModel siteConsumer = dataUser.createRandomTestUser(); + siteConsumer.setUserRole(UserRole.SiteConsumer); + restClient.authenticateUser(siteConsumer).withCoreAPI().usingUser(siteConsumer).addSiteMembershipRequest(moderatedSite); + + updatedMember = restClient.authenticateUser(anotherManager).withCoreAPI() + .usingSite(moderatedSite).updateSiteMember(siteConsumer); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(RestErrorModel.NOT_A_MEMBER); + } + +} diff --git a/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java index 724fb236f..6e021d1f0 100644 --- a/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java @@ -45,7 +45,6 @@ public class UpdateSiteMemberSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); } - @Bug(id="ACE-5444") @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that collaborator is not able to update site member and gets status code FORBIDDEN (403)") @@ -54,12 +53,11 @@ public class UpdateSiteMemberSanityTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); testUserModel.setUserRole(UserRole.SiteCollaborator); restClient.withCoreAPI().usingSite(siteModel).updateSiteMember(testUserModel); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY); restClient.assertLastError() .containsSummary(String.format("The current user does not have permissions to modify the membership details of the site %s.", siteModel.getTitle())); } - @Bug(id="ACE-5444") @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that contributor is not able to update site member and gets status code FORBIDDEN (403)") @@ -68,12 +66,11 @@ public class UpdateSiteMemberSanityTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); testUserModel.setUserRole(UserRole.SiteCollaborator); restClient.withCoreAPI().usingSite(siteModel).updateSiteMember(testUserModel); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY); restClient.assertLastError() .containsSummary(String.format("The current user does not have permissions to modify the membership details of the site %s.", siteModel.getTitle())); } - @Bug(id="ACE-5444") @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that consumer is not able to update site member and gets status code FORBIDDEN (403)") @@ -84,7 +81,7 @@ public class UpdateSiteMemberSanityTests extends RestTest restClient.withCoreAPI().usingSite(siteModel).updateSiteMember(testUserModel); restClient.assertLastError() .containsSummary(String.format("The current user does not have permissions to modify the membership details of the site %s.", siteModel.getTitle())); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY); } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) From 79a2aaeff85ced618174e30f6ee225c0c5920555 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alecsandru=20Prun=C4=83?= Date: Wed, 25 Jan 2017 14:40:55 +0200 Subject: [PATCH 0920/1491] Fixed deleteCommentWithInvalidNetworkId testrail path --- .../java/org/alfresco/rest/comments/DeleteCommentFullTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentFullTests.java b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentFullTests.java index 8386b5a39..9f3037f1d 100644 --- a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentFullTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentFullTests.java @@ -157,7 +157,7 @@ public class DeleteCommentFullTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(file.getNodeRef() + " was not found"); } - @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, description = "Verify deleteComment from node with invalid network id returns status code 401") @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.COMMENTS, TestGroup.FULL }) public void deleteCommentWithInvalidNetworkId() throws Exception From 775f268812560f34e8a07d60ba0a7517bd9fb022 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alecsandru=20Prun=C4=83?= Date: Wed, 25 Jan 2017 16:08:54 +0200 Subject: [PATCH 0921/1491] bug: fixed failedAddingProcessItemIfInvalidProcessIdIsProvided and getProcessVariablesUsingEmptyProcessId --- .../rest/workflow/processes/AddProcessItemCoreTests.java | 2 -- .../workflow/processes/GetProcessVariablesCoreTests.java | 8 +++----- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemCoreTests.java index 2a78e2d40..26353e547 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemCoreTests.java @@ -113,7 +113,6 @@ public class AddProcessItemCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process item is falling in case of invalid process id is provided") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) - @Bug(id="AUTOMATION", description="Please fix this issue. It seems it's failing with 400 or 404 error code on 5.2") public void failedAddingProcessItemIfInvalidProcessIdIsProvided() throws Exception { RestProcessModelsCollection processes = restClient.authenticateUser(adminUser).withParams("maxItems=1").withWorkflowAPI().getProcesses(); @@ -156,5 +155,4 @@ public class AddProcessItemCoreTests extends RestTest restClient.processModel(RestItemModel.class, request); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.REQUIRED_TO_ADD, "itemId")); } - } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesCoreTests.java index e99fb2975..a17dcea20 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesCoreTests.java @@ -93,13 +93,12 @@ public class GetProcessVariablesCoreTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Get process variables using empty process ID") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) - @Bug(id="AUTOMATION", description="Please fix this automated test") public void getProcessVariablesUsingEmptyProcessId() throws JsonToModelConversionException, Exception { processModel = restClient.authenticateUser(userWhoStartsTask).withParams("maxItems=2").withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - processModel.setId(" /"); + processModel.setId(""); variables = restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, " ")); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); } @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, @@ -117,5 +116,4 @@ public class GetProcessVariablesCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); variables.assertThat().entriesListIsNotEmpty(); } - -} \ No newline at end of file +} From e31f0a30fce5d8b8d9192e9919a940cbaf840d14 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Wed, 25 Jan 2017 17:45:15 +0200 Subject: [PATCH 0922/1491] Get ratings full tests and fixes --- .../rest/ratings/GetRatingsCoreTests.java | 51 ++++---- .../rest/ratings/GetRatingsFullTests.java | 116 ++++++++++++++++++ 2 files changed, 145 insertions(+), 22 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/ratings/GetRatingsFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/ratings/GetRatingsCoreTests.java b/e2e-test/java/org/alfresco/rest/ratings/GetRatingsCoreTests.java index 54d0da2b4..3051df8f4 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/GetRatingsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/GetRatingsCoreTests.java @@ -3,7 +3,7 @@ package org.alfresco.rest.ratings; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestRatingModel; +import org.alfresco.rest.model.RestRatingModelsCollection; import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; @@ -22,7 +22,7 @@ public class GetRatingsCoreTests extends RestTest private SiteModel siteModel; private UserModel adminUserModel, userModel; private FileModel document; - private RestRatingModel returnedRatingModel; + private RestRatingModelsCollection ratingsModel; @BeforeClass(alwaysRun = true) public void dataPreparation() throws DataPreparationException @@ -36,63 +36,70 @@ public class GetRatingsCoreTests extends RestTest public void setUp() throws DataPreparationException, Exception { document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); + restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).rateStarsToDocument(5); + restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).likeDocument(); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Check that rating for invalid maxItems status code is 400") + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Check that rating for invalid maxItems status code is 400") @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) public void checkInvalidMaxItemsStatusCode() throws Exception { - restClient.authenticateUser(adminUserModel).withParams("maxItems=0").withCoreAPI().usingResource(document).getLikeRating(); + restClient.authenticateUser(adminUserModel).withParams("maxItems=0").withCoreAPI().usingResource(document).getRatings(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Only positive values supported for maxItems"); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Check that rating for invalid skipCount status code is 400") + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Check that rating for invalid skipCount status code is 400") @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) public void checkInvalidSkipCountStatusCode() throws Exception { - restClient.authenticateUser(adminUserModel).withParams("skipCount=AB").withCoreAPI().usingResource(document).getLikeRating(); + restClient.authenticateUser(adminUserModel).withParams("skipCount=AB").withCoreAPI().usingResource(document).getRatings(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Invalid paging parameter skipCount:AB"); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "If nodeId does not exist status code is 404 when a document is liked") + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "If nodeId does not exist status code is 404 when a document is liked") @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) public void addLikeUsingInvalidNodeId() throws Exception { - + FileModel document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); + restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).rateStarsToDocument(5); + restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).likeDocument(); document.setNodeRef(RandomStringUtils.randomAlphanumeric(20)); - returnedRatingModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).likeDocument(); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getRatings(); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, document.getNodeRef())); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Check that rating value is TRUE for a like rating") + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Check that rating value is TRUE for a like rating") @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) public void checkRatingValueIsTrueForLikedDoc() throws Exception { - returnedRatingModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).likeDocument(); - restClient.assertStatusCodeIs(HttpStatus.CREATED); + ratingsModel = restClient.authenticateUser(userModel).withCoreAPI().usingResource(document).getRatings(); + restClient.assertStatusCodeIs(HttpStatus.OK); - returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes"); + ratingsModel.assertThat().entriesListContains("myRating", "true") + .assertThat().entriesListContains("id", "likes"); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Check that rating value is an INTEGER value for stars rating") + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Check that rating value is an INTEGER value for stars rating") @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) public void checkRatingValueIsIntegerForStarsRating() throws Exception { - returnedRatingModel = restClient.authenticateUser(userModel).withCoreAPI().usingResource(document).rateStarsToDocument(5); - restClient.assertStatusCodeIs(HttpStatus.CREATED); + ratingsModel = restClient.authenticateUser(userModel).withCoreAPI().usingResource(document).getRatings(); + restClient.assertStatusCodeIs(HttpStatus.OK); - returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); + ratingsModel.assertThat().entriesListContains("myRating", "5") + .assertThat().entriesListContains("id", "fiveStar"); } } diff --git a/e2e-test/java/org/alfresco/rest/ratings/GetRatingsFullTests.java b/e2e-test/java/org/alfresco/rest/ratings/GetRatingsFullTests.java new file mode 100644 index 000000000..1fdbd80ba --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/ratings/GetRatingsFullTests.java @@ -0,0 +1,116 @@ +package org.alfresco.rest.ratings; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestRatingModelsCollection; +import org.alfresco.utility.exception.DataPreparationException; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +public class GetRatingsFullTests extends RestTest +{ + private SiteModel siteModel; + private UserModel adminUserModel, userModel; + private FileModel document; + private RestRatingModelsCollection ratingsModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws DataPreparationException + { + adminUserModel = dataUser.getAdminUser(); + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingAdmin().createPublicRandomSite(); + } + + @BeforeMethod(alwaysRun = true) + public void setUp() throws DataPreparationException, Exception + { + document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); + restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).rateStarsToDocument(5); + restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).likeDocument(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Check default error schema in case of failure") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) + public void checkDefaultErrorSchema() throws Exception + { + FileModel document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); + document.setNodeRef("abc"); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getRatings(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "abc")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Check maxItems and skipCount parameters") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) + public void checkMaxItemsAndSkipCountParameters() throws Exception + { + ratingsModel = restClient.authenticateUser(adminUserModel).withParams("maxItems=1", "skipCount=1").withCoreAPI().usingResource(document).getRatings(); + ratingsModel.assertThat().entriesListCountIs(1); + ratingsModel.getPagination().assertThat().field("maxItems").is("1") + .and().field("skipCount").is("1"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Check totalItems and hasMoreitems parameters") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) + public void checkTotalItemsAndHasMoreItemsParameters() throws Exception + { + ratingsModel = restClient.authenticateUser(adminUserModel).withParams("maxItems=1").withCoreAPI().usingResource(document).getRatings(); + ratingsModel.assertThat().entriesListCountIs(1); + ratingsModel.getPagination().assertThat().field("hasMoreItems").is("true") + .and().field("totalItems").is("2"); + } + + @Bug(id = "REPO-1831") + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Get ratings for a document to which authenticated user does not have access") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) + public void userIsNotAbleToGetRatingsOfDocumentToWhichItHasNoAccess() throws Exception + { + SiteModel privateSite = dataSite.usingAdmin().createPrivateRandomSite(); + FileModel file = dataContent.usingSite(privateSite).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); + ratingsModel = restClient.authenticateUser(userModel).withCoreAPI().usingResource(file).getRatings(); + ratingsModel.assertThat().entriesListIsEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Check high value for skipCount parameter") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) + public void getRatingsUsingHighValueForSkipCount() throws Exception + { + ratingsModel = restClient.authenticateUser(adminUserModel).withParams("skipCount=100").withCoreAPI().usingResource(document).getRatings(); + ratingsModel.getPagination().assertThat().field("skipCount").is("100"); + ratingsModel.assertThat().entriesListIsEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Get ratings using site id instead of node id") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) + public void getRatingsUsingSiteId() throws Exception + { + FileModel document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); + document.setNodeRef(siteModel.getId()); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getRatings(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, siteModel.getId())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } +} \ No newline at end of file From 986797b0aea86c24e5c0c35e106caa2641afbfc1 Mon Sep 17 00:00:00 2001 From: mionescu Date: Thu, 26 Jan 2017 10:04:46 +0200 Subject: [PATCH 0923/1491] test- removed TC 'userUpdateSiteMembershipRequestWithEmptyMessage' --- .../UpdateSiteMembershipRequestFullTests.java | 21 ------------------- 1 file changed, 21 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestFullTests.java b/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestFullTests.java index fbe49a7c9..a44186016 100644 --- a/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestFullTests.java +++ b/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestFullTests.java @@ -452,27 +452,6 @@ public class UpdateSiteMembershipRequestFullTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify user is able to update site membership request - empty message") - public void userUpdateSiteMembershipRequestWithEmptyMessage() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - requestUpdateModel = restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser() - .addSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - requestUpdateModel.assertThat().field("id").is(moderatedSite.getId()) - .assertThat().field("message").is("Please accept me"); - - requestUpdateModel = restClient.withCoreAPI().usingMe() - .updateSiteMembershipRequest(moderatedSite, ""); - - restClient.assertStatusCodeIs(HttpStatus.OK); - requestUpdateModel.assertThat().field("id").is(moderatedSite.getId()) - .and().field("modifiedAt").isNotEmpty() - .assertThat().field("message").isNull(); - } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }, executionType = ExecutionType.REGRESSION, description = "Update site membership request using invalid network") From 8044bb40754dfcd2b62afe953fdb92bd2762dd08 Mon Sep 17 00:00:00 2001 From: mionescu Date: Thu, 26 Jan 2017 10:22:52 +0200 Subject: [PATCH 0924/1491] test- updates after review --- .../rest/people/GetSiteMembershipRequestFullTests.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestFullTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestFullTests.java index 18f9c9c4a..93fd2342a 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestFullTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestFullTests.java @@ -160,9 +160,9 @@ public class GetSiteMembershipRequestFullTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify admin user have permission to get site membership request of another user with Rest API and status code is 200") + description = "Verify user doesn't have permission to get site membership request of admin with membership request with Rest API and status code is 404") @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - public void adminIsAbleToGetSiteMembershipRequestOfAnotherUser() throws JsonToModelConversionException, Exception + public void userIsNotAbleToGetSiteMembershipRequestOfAdminWithRequest() throws JsonToModelConversionException, Exception { UserModel newMember = dataUser.createRandomTestUser(); restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); @@ -179,10 +179,12 @@ public class GetSiteMembershipRequestFullTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify user doesn't have permission to get site membership request of admin with Rest API and status code is 404") + description = "Verify user doesn't have permission to get site membership request of admin without membership request with Rest API and status code is 404") @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - public void userIsNotAbleToGetSiteMembershipRequestOfAdmin() throws JsonToModelConversionException, Exception + public void userIsNotAbleToGetSiteMembershipRequestOfAdminWithoutRequest() throws JsonToModelConversionException, Exception { + SiteModel moderatedSite = dataSite.usingUser(userModel).createModeratedRandomSite(); + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); UserModel newMember = dataUser.createRandomTestUser(); restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); From 3d304c59a44e417ed34351e7f283df8bc54c5acb Mon Sep 17 00:00:00 2001 From: Andrei Rusu Date: Thu, 26 Jan 2017 11:45:05 +0200 Subject: [PATCH 0925/1491] added full tests getSiteForMember (get /people/{personId}/sites/{siteId}) --- .../people/GetSiteMembershipFullTests.java | 128 ++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/people/GetSiteMembershipFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipFullTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipFullTests.java new file mode 100644 index 000000000..aa286500e --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipFullTests.java @@ -0,0 +1,128 @@ +package org.alfresco.rest.people; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestSiteEntry; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class GetSiteMembershipFullTests extends RestTest +{ + UserModel regularUser, adminUser; + SiteModel publicSite, moderatedSite; + private DataUser.ListUserWithRoles publicSiteUsers; + private RestSiteEntry restSiteEntry; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + regularUser = dataUser.createRandomTestUser(); + publicSite = dataSite.usingAdmin().createPublicRandomSite(); + moderatedSite = dataSite.usingAdmin().createModeratedRandomSite(); + + publicSiteUsers = dataUser.addUsersWithRolesToSite(publicSite, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify that properties parameter is applied.") + public void checkThatPropertiesParameterIsApplied() throws Exception + { + restSiteEntry = restClient.authenticateUser(regularUser).withCoreAPI().usingParams("properties=site,role,id") + .usingUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteManager)).getSiteMembership(publicSite); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteEntry.assertThat().field("role").is(UserRole.SiteManager) + .and().field("id").is(publicSite.getId()) + .and().field("site").isNotEmpty() + .and().field("guid").isNull(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify that regular user " + + "is able to retrieve site membership information of admin.") + public void regularUserGetsSiteMembershipForAdmin() throws Exception + { + restSiteEntry = restClient.authenticateUser(regularUser).withCoreAPI().usingUser(adminUser).getSiteMembership(publicSite); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteEntry.assertThat().field("role").is(UserRole.SiteManager).and().field("id").is(publicSite.getId()).and().field("site").isNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify that regular user " + + "is able to retrieve site membership details for a Collaborator role.") + public void getSiteMembershipDetailsForACollaboratorRole() throws Exception + { + restSiteEntry = restClient.authenticateUser(regularUser).withCoreAPI() + .usingUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)).getSiteMembership(publicSite); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteEntry.assertThat().field("role").is(UserRole.SiteCollaborator) + .and().field("id").is(publicSite.getId()) + .and().field("site").isNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify that regular user " + + "is able to retrieve site membership details for a Contributor role.") + public void getSiteMembershipDetailsForAContributorRole() throws Exception + { + restSiteEntry = restClient.authenticateUser(regularUser).withCoreAPI() + .usingUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteContributor)).getSiteMembership(publicSite); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteEntry.assertThat().field("role").is(UserRole.SiteContributor) + .and().field("id").is(publicSite.getId()) + .and().field("site").isNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify that regular user " + + "is able to retrieve site membership details for a Consumer role.") + public void getSiteMembershipDetailsForAConsumerRole() throws Exception + { + restSiteEntry = restClient.authenticateUser(regularUser).withCoreAPI() + .usingUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteConsumer)).getSiteMembership(publicSite); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteEntry.assertThat().field("role").is(UserRole.SiteConsumer) + .and().field("id").is(publicSite.getId()) + .and().field("site").isNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "As regular user make a request to join a moderated site." + + " The request is pending. Check membership details.") + public void pendingRequestToASiteCheckMembershipDetails() throws Exception + { + restClient.authenticateUser(regularUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restSiteEntry = restClient.authenticateUser(adminUser).withCoreAPI() + .usingUser(regularUser).getSiteMembership(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, regularUser.getUsername(), moderatedSite.getTitle())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "As Collaborator user leave site and perform get call." + + "Check default error model schema.") + public void leaveSiteAndPerformGetCallCheckDefaultErrorModelSchema() throws Exception + { + UserModel leaveSiteUser = dataUser.createRandomTestUser(); + dataUser.addUserToSite(leaveSiteUser, publicSite, UserRole.SiteCollaborator); + restClient.authenticateUser(leaveSiteUser).withCoreAPI().usingAuthUser().deleteSiteMember(publicSite); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restSiteEntry = restClient.authenticateUser(adminUser).withCoreAPI() + .usingUser(leaveSiteUser).getSiteMembership(publicSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, leaveSiteUser.getUsername(), publicSite.getTitle())) + .descriptionURLIs(RestErrorModel.DESCRIPTION_URL_ERRORS_EXPLAINED); + } +} From ae11f1245a58fc7c98589c7a9f5a5f4252eee61b Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Thu, 26 Jan 2017 11:59:56 +0200 Subject: [PATCH 0926/1491] fix test description --- .../org/alfresco/rest/sites/UpdateSiteMemberFullTests.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberFullTests.java b/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberFullTests.java index 205e3735d..0dd6117f0 100644 --- a/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberFullTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberFullTests.java @@ -263,8 +263,8 @@ public class UpdateSiteMemberFullTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if manager is able to update a user that has created a merge request, but it's not a member of the site yet") - public void verifyManagerCanNotUpdateUserWithMergeRequest() throws Exception + description= "Verify if manager is able to update a user that has created a site membership request, but it's not a member of the site yet") + public void verifyManagerCanNotUpdateUserWithSiteMembershipRequest() throws Exception { UserModel siteConsumer = dataUser.createRandomTestUser(); siteConsumer.setUserRole(UserRole.SiteConsumer); @@ -276,4 +276,4 @@ public class UpdateSiteMemberFullTests extends RestTest .containsSummary(RestErrorModel.NOT_A_MEMBER); } -} +} \ No newline at end of file From 6d845c3f8c14336e366cb90ea0d2df751559569f Mon Sep 17 00:00:00 2001 From: Andrei Rusu Date: Thu, 26 Jan 2017 15:15:24 +0200 Subject: [PATCH 0927/1491] updated test leaveSiteAndPerformGetCallCheckDefaultErrorModelSchema --- .../org/alfresco/rest/people/GetSiteMembershipFullTests.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipFullTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipFullTests.java index aa286500e..61311498e 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipFullTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipFullTests.java @@ -123,6 +123,7 @@ public class GetSiteMembershipFullTests extends RestTest .usingUser(leaveSiteUser).getSiteMembership(publicSite); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, leaveSiteUser.getUsername(), publicSite.getTitle())) - .descriptionURLIs(RestErrorModel.DESCRIPTION_URL_ERRORS_EXPLAINED); + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); } } From 0394aa09897cf1fed4a6b6c0d8cfe7a308719d75 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Thu, 26 Jan 2017 15:17:33 +0200 Subject: [PATCH 0928/1491] added full test for getSitesMembership --- ...tSitesMembershipInformationCoreTests.java} | 12 +- ...etSitesMembershipInformationFullTests.java | 216 ++++++++++++++++++ 2 files changed, 225 insertions(+), 3 deletions(-) rename e2e-test/java/org/alfresco/rest/people/{GetSiteMembershipInformationCoreTests.java => GetSitesMembershipInformationCoreTests.java} (92%) create mode 100644 e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipInformationCoreTests.java b/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationCoreTests.java similarity index 92% rename from e2e-test/java/org/alfresco/rest/people/GetSiteMembershipInformationCoreTests.java rename to e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationCoreTests.java index c315b3424..07878cf0a 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipInformationCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationCoreTests.java @@ -13,7 +13,7 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -public class GetSiteMembershipInformationCoreTests extends RestTest +public class GetSitesMembershipInformationCoreTests extends RestTest { private SiteModel publicSiteModel; private SiteModel moderatedSiteModel; @@ -48,7 +48,10 @@ public class GetSiteMembershipInformationCoreTests extends RestTest restClient.authenticateUser(userModel).withCoreAPI().usingUser(new UserModel("invalidPersonId", "password")).getSitesMembershipInformation() .assertThat().entriesListIsEmpty(); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - restClient.assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidPersonId")); + restClient.assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidPersonId")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) @@ -89,7 +92,10 @@ public class GetSiteMembershipInformationCoreTests extends RestTest restClient.withParams("skipCount=test").withCoreAPI().usingAuthUser().getSitesMembershipInformation().assertThat().entriesListIsEmpty(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - restClient.assertLastError().containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "test")); + restClient.assertLastError().containsErrorKey(String.format(RestErrorModel.INVALID_SKIPCOUNT, "test")) + .containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "test")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) diff --git a/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationFullTests.java b/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationFullTests.java new file mode 100644 index 000000000..9abef3e7e --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationFullTests.java @@ -0,0 +1,216 @@ +package org.alfresco.rest.people; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestSiteMembershipModelsCollection; +import org.alfresco.rest.model.RestTaskModel; +import org.alfresco.utility.constants.UserRole; +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 Cristina Axinte + * + */ +public class GetSitesMembershipInformationFullTests extends RestTest +{ + private SiteModel publicSiteModel; + private SiteModel moderatedSiteModel; + private SiteModel privateSiteModel; + private SiteModel anotherUserSite; + private UserModel userModel, adminUser, anotherUserModel; + private RestSiteMembershipModelsCollection sitesMembershipInformation; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws DataPreparationException + { + adminUser = dataUser.getAdminUser(); + anotherUserSite = dataSite.usingUser(adminUser).createPublicRandomSite(); + userModel = dataUser.createRandomTestUser(); + anotherUserModel = dataUser.createRandomTestUser(); + publicSiteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); + dataUser.addUserToSite(userModel, publicSiteModel, UserRole.SiteCollaborator); + moderatedSiteModel = dataSite.usingUser(adminUser).createModeratedRandomSite(); + dataUser.addUserToSite(userModel, moderatedSiteModel, UserRole.SiteConsumer); + privateSiteModel = dataSite.usingUser(userModel).createPrivateRandomSite(); + dataUser.addUserToSite(anotherUserModel, anotherUserSite, UserRole.SiteCollaborator); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify if get site membership information request returns status code 200 for valid properties parameter") + public void getSiteMembershipInformationUsingPropertiesParameter() throws Exception + { + sitesMembershipInformation = restClient.authenticateUser(userModel).withParams("properties=id").withCoreAPI().usingAuthUser().getSitesMembershipInformation(); + restClient.assertStatusCodeIs(HttpStatus.OK); + sitesMembershipInformation.assertThat().entriesListIsNotEmpty().getPagination().assertThat().field("count").is("3"); + sitesMembershipInformation.assertThat().entriesListContains("id", publicSiteModel.getId()) + .and().entriesListContains("id", moderatedSiteModel.getId()) + .and().entriesListContains("id", privateSiteModel.getId()) + .and().entriesListDoesNotContain("site") + .and().entriesListDoesNotContain("role") + .and().entriesListDoesNotContain("guid"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify if get site membership information request returns status code 200 for order ASC by parameter") + public void getSiteMembershipInformationUsingOrderAscByParameter() throws Exception + { + sitesMembershipInformation = restClient.authenticateUser(userModel).withParams("orderBy=id ASC").withCoreAPI().usingAuthUser().getSitesMembershipInformation(); + restClient.assertStatusCodeIs(HttpStatus.OK); + sitesMembershipInformation.assertThat().entriesListIsNotEmpty().getPagination().assertThat().field("count").is("3"); + sitesMembershipInformation.assertThat().entriesListIsSortedAscBy("id"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify if get site membership information request returns status code 200 for order DESC by parameter") + public void getSiteMembershipInformationUsingOrderDescByParameter() throws Exception + { + sitesMembershipInformation = restClient.authenticateUser(userModel).withParams("orderBy=id Desc").withCoreAPI().usingAuthUser().getSitesMembershipInformation(); + restClient.assertStatusCodeIs(HttpStatus.OK); + sitesMembershipInformation.assertThat().entriesListIsNotEmpty().getPagination().assertThat().field("count").is("3"); + sitesMembershipInformation.assertThat().entriesListIsSortedDescBy("id"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify if get site membership information request returns status code 200 for order by parameter") + public void getSiteMembershipInformationUsingOrderByParameter() throws Exception + { + sitesMembershipInformation = restClient.authenticateUser(userModel).withParams("orderBy=id").withCoreAPI().usingAuthUser().getSitesMembershipInformation(); + restClient.assertStatusCodeIs(HttpStatus.OK); + sitesMembershipInformation.assertThat().entriesListIsNotEmpty().getPagination().assertThat().field("count").is("3"); + sitesMembershipInformation.assertThat().entriesListIsSortedAscBy("id"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify if get site membership information request returns status code 200 for order by role parameter") + public void getSiteMembershipInformationUsingOrderByRoleParameter() throws Exception + { + sitesMembershipInformation = restClient.authenticateUser(userModel).withParams("orderBy=role").withCoreAPI().usingAuthUser().getSitesMembershipInformation(); + restClient.assertStatusCodeIs(HttpStatus.OK); + sitesMembershipInformation.assertThat().entriesListIsNotEmpty().getPagination().assertThat().field("count").is("3"); + sitesMembershipInformation.assertThat().entriesListIsSortedAscBy("role"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify if user gets site membership information of another user successfully") + public void userCanGetSiteMembershipInformationOfAnotherUser() throws Exception + { + sitesMembershipInformation = restClient.authenticateUser(userModel).withCoreAPI().usingUser(anotherUserModel).getSitesMembershipInformation(); + restClient.assertStatusCodeIs(HttpStatus.OK); + sitesMembershipInformation.assertThat().entriesListIsNotEmpty().getPagination().assertThat().field("count").is("1"); + sitesMembershipInformation.getEntries().get(0).onModel() + .assertThat().field("site.visibility").is(anotherUserSite.getVisibility().toString()) + .and().field("site.guid").is(anotherUserSite.getGuid()) + .and().field("site.description").is(anotherUserSite.getDescription()) + .and().field("site.id").is(anotherUserSite.getId()) + .and().field("site.preset").is("site-dashboard") + .and().field("site.title").is(anotherUserSite.getTitle()) + .and().field("id").is(anotherUserSite.getId()) + .and().field("guid").is(anotherUserSite.getGuid()) + .and().field("role").is(UserRole.SiteCollaborator.toString()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify if get site membership information request returns status code 200 for relations parameter") + public void getSiteMembershipInformationUsingRelationsParameter() throws Exception + { + sitesMembershipInformation = restClient.authenticateUser(userModel).withParams("relations=site-membership-requests").withCoreAPI().usingAuthUser().getSitesMembershipInformation(); + restClient.assertStatusCodeIs(HttpStatus.OK); + sitesMembershipInformation.assertThat().entriesListIsNotEmpty().getPagination().assertThat().field("count").is("3"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify get site membership information request when a site membership request is rejected") + public void getSiteMembershipInformationWhenASiteRequestIsRejected() throws Exception + { + UserModel userWithRequests = dataUser.createRandomTestUser(); + + restClient.authenticateUser(userWithRequests).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSiteModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + sitesMembershipInformation = restClient.authenticateUser(adminUser).withCoreAPI().usingUser(userWithRequests).getSitesMembershipInformation(); + restClient.assertStatusCodeIs(HttpStatus.OK); + sitesMembershipInformation.assertThat().entriesListIsEmpty() + .and().paginationField("count").is("0"); + + RestTaskModel taskModel = restClient.authenticateUser(userWithRequests).withWorkflowAPI().getTasks().getTaskModelByDescription(moderatedSiteModel); + workflow.approveSiteMembershipRequest(adminUser.getUsername(), adminUser.getPassword(), taskModel.getId(), false, "Rejected"); + + sitesMembershipInformation = restClient.authenticateUser(adminUser).withCoreAPI().usingUser(userWithRequests).getSitesMembershipInformation(); + restClient.assertStatusCodeIs(HttpStatus.OK); + sitesMembershipInformation.assertThat().entriesListIsEmpty() + .and().paginationField("count").is("0"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify get site membership information request when a site membership request is approved") + public void getSiteMembershipInformationWhenASiteRequestIsAppropved() throws Exception + { + UserModel userWithRequests = dataUser.createRandomTestUser(); + + restClient.authenticateUser(userWithRequests).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSiteModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + sitesMembershipInformation = restClient.authenticateUser(adminUser).withCoreAPI().usingUser(userWithRequests).getSitesMembershipInformation(); + restClient.assertStatusCodeIs(HttpStatus.OK); + sitesMembershipInformation.assertThat().entriesListIsEmpty() + .and().paginationField("count").is("0"); + + RestTaskModel taskModel = restClient.authenticateUser(userWithRequests).withWorkflowAPI().getTasks().getTaskModelByDescription(moderatedSiteModel); + workflow.approveSiteMembershipRequest(adminUser.getUsername(), adminUser.getPassword(), taskModel.getId(), true, "Approve"); + + sitesMembershipInformation = restClient.authenticateUser(adminUser).withCoreAPI().usingUser(userWithRequests).getSitesMembershipInformation(); + restClient.assertStatusCodeIs(HttpStatus.OK); + sitesMembershipInformation.assertThat().entriesListIsNotEmpty() + .and().entriesListContains("role", UserRole.SiteConsumer.toString()) + .and().entriesListContains("guid", moderatedSiteModel.getGuid()) + .and().entriesListContains("id", moderatedSiteModel.getId()) + .and().paginationField("count").is("1"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify if get site membership information request returns status code 200 for valid maxItems parameter") + public void getSiteMembershipInformationUsingMaxItemsParameter() throws Exception + { + sitesMembershipInformation = restClient.authenticateUser(userModel).withParams("maxItems=2").withCoreAPI().usingAuthUser().getSitesMembershipInformation(); + restClient.assertStatusCodeIs(HttpStatus.OK); + sitesMembershipInformation.assertThat().entriesListCountIs(2) + .getPagination().assertThat().field("count").is("2") + .and().field("hasMoreItems").is("true") + .and().field("totalItems").is("3") + .and().field("skipCount").is("0") + .and().field("maxItems").is("2"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify if get site membership information request returns status code 200 for valid skipCount parameter") + public void getSiteMembershipInformationUsingSkipCountParameter() throws Exception + { + sitesMembershipInformation = restClient.authenticateUser(userModel).withParams("skipCount=2").withCoreAPI().usingAuthUser().getSitesMembershipInformation(); + restClient.assertStatusCodeIs(HttpStatus.OK); + sitesMembershipInformation.assertThat().entriesListCountIs(1) + .getPagination().assertThat().field("count").is("1") + .and().field("hasMoreItems").is("false") + .and().field("totalItems").is("3") + .and().field("skipCount").is("2") + .and().field("maxItems").is("100"); + } +} From d62d097841fe54f83173665fafa0f2e0c0c957cd Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Thu, 26 Jan 2017 15:43:43 +0200 Subject: [PATCH 0929/1491] added more fields assertions --- .../rest/people/GetSiteMembershipFullTests.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipFullTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipFullTests.java index 61311498e..f27644f74 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipFullTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipFullTests.java @@ -53,7 +53,9 @@ public class GetSiteMembershipFullTests extends RestTest { restSiteEntry = restClient.authenticateUser(regularUser).withCoreAPI().usingUser(adminUser).getSiteMembership(publicSite); restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteEntry.assertThat().field("role").is(UserRole.SiteManager).and().field("id").is(publicSite.getId()).and().field("site").isNotEmpty(); + restSiteEntry.assertThat().field("role").is(UserRole.SiteManager) + .and().field("id").is(publicSite.getId()) + .and().field("site.id").is(publicSite.getId()); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) @@ -65,8 +67,14 @@ public class GetSiteMembershipFullTests extends RestTest .usingUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)).getSiteMembership(publicSite); restClient.assertStatusCodeIs(HttpStatus.OK); restSiteEntry.assertThat().field("role").is(UserRole.SiteCollaborator) + .and().field("guid").is(publicSite.getGuid()) .and().field("id").is(publicSite.getId()) - .and().field("site").isNotEmpty(); + .and().field("site.visibility").is(publicSite.getVisibility().toString()) + .and().field("site.guid").is(publicSite.getGuid()) + .and().field("site.description").is(publicSite.getDescription()) + .and().field("site.id").is(publicSite.getId()) + .and().field("site.preset").is("site-dashboard") + .and().field("site.title").is(publicSite.getTitle()); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) @@ -122,6 +130,7 @@ public class GetSiteMembershipFullTests extends RestTest restSiteEntry = restClient.authenticateUser(adminUser).withCoreAPI() .usingUser(leaveSiteUser).getSiteMembership(publicSite); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, leaveSiteUser.getUsername(), publicSite.getTitle())) .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) .stackTraceIs(RestErrorModel.STACKTRACE); From 4f819f202d7a4908373c7724e96a8209ea39cd8a Mon Sep 17 00:00:00 2001 From: Ana Bozianu Date: Thu, 26 Jan 2017 16:37:30 +0200 Subject: [PATCH 0930/1491] RM-4627 - added get children nodes call and added test --- .../rest/nodes/NodesChildrenTests.java | 68 ++++++++++++++++++- 1 file changed, 67 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/nodes/NodesChildrenTests.java b/e2e-test/java/org/alfresco/rest/nodes/NodesChildrenTests.java index bd46bfe2c..77f305ff9 100644 --- a/e2e-test/java/org/alfresco/rest/nodes/NodesChildrenTests.java +++ b/e2e-test/java/org/alfresco/rest/nodes/NodesChildrenTests.java @@ -1,8 +1,11 @@ package org.alfresco.rest.nodes; +import java.util.UUID; + import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestNodeBodyModel; import org.alfresco.rest.model.RestNodeModel; +import org.alfresco.rest.model.RestNodeModelsCollection; import org.alfresco.utility.Utility; import org.alfresco.utility.model.ContentModel; import org.alfresco.utility.model.TestGroup; @@ -48,11 +51,74 @@ public class NodesChildrenTests extends RestTest .addFormParam("renditions", "doclib") .addFormParam("autoRename", true); - RestNodeModel newNode = restClient.withCoreAPI().usingNode(ContentModel.my()).createNode(); + RestNodeModel newNode = restClient.withCoreAPI().usingNode(ContentModel.my()).createNode(); restClient.assertStatusCodeIs(HttpStatus.CREATED); newNode.assertThat().field("aspectNames").contains("cm:auditable") .assertThat().field("isFolder").is(false) .assertThat().field("isFile").is(true) .assertThat().field("name").contains("restapi-resource"); } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NODES }, executionType = ExecutionType.SANITY, + description = "Verify list children when listing with relativePath and pagination") + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY}) + public void listChildrenTest() throws Exception + { + /* + * Given we have a folder hierarchy folder1/folder2/folder3 and folder3 containing 3 files file1, file2, and file3 + */ + restClient.authenticateUser(dataContent.getAdminUser()); + + RestNodeModel folder1 = createTestNode(ContentModel.my().getNodeRef(), "F1", "cm:folder"); + RestNodeModel folder2 = createTestNode(folder1.getId(), "F2", "cm:folder"); + RestNodeModel folder3 = createTestNode(folder2.getId(), "F3", "cm:folder"); + + RestNodeModel file1 = createTestNode(folder3.getId(), "f1", "cm:content"); + RestNodeModel file2 = createTestNode(folder3.getId(), "f2", "cm:content"); + RestNodeModel file3 = createTestNode(folder3.getId(), "f3", "cm:content"); + + /* + * When listing the children of folder1 with relative path folder2/folder3, page size 2 and skip count 1 + */ + ContentModel folder1Model = new ContentModel(); + folder1Model.setNodeRef(folder1.getId()); + RestNodeModelsCollection files = restClient.withParams("maxItems=2", "skipCount=1", "relativePath="+folder2.getName()+"/"+folder3.getName()) + .withCoreAPI().usingNode(folder1Model).listChildren(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + /* + * Then I receive file2 and file3 + */ + assert(files.getEntries().size() == 2); + assert(files.getEntries().get(0).onModel().getId().equals(file2.getId())); + assert(files.getEntries().get(1).onModel().getId().equals(file3.getId())); + } + + /** + * Helper method that creates a node in a specified folder + * + * @param parentId id of the parent folder + * @param name the name if the new node (a random string will be appended at the end) + * @param nodeType the type of the new node + * @return the model of the created node + * @throws Exception if the node failed to be created + */ + private RestNodeModel createTestNode(String parentId, String name, String nodeType) throws Exception + { + // define the new node model + RestNodeBodyModel model = new RestNodeBodyModel(); + model.setName(name + "-" + UUID.randomUUID().toString()); + model.setNodeType(nodeType); + + // define the parent + ContentModel parent = new ContentModel(); + parent.setNodeRef(parentId); + + // call the create children api + RestNodeModel newNode = restClient.withCoreAPI().usingNode(parent).createNode(model); + + // check and return the result + restClient.assertStatusCodeIs(HttpStatus.CREATED); + return newNode; + } } From 0c3ca18f8c2e162ad7845ad94aa6cdd1d3632bc5 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Thu, 26 Jan 2017 18:48:43 +0200 Subject: [PATCH 0931/1491] Get site full tests scenarios --- .../alfresco/rest/sites/GetSiteFullTests.java | 209 ++++++++++++++++++ 1 file changed, 209 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/sites/GetSiteFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteFullTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteFullTests.java new file mode 100644 index 000000000..06900a42d --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteFullTests.java @@ -0,0 +1,209 @@ +package org.alfresco.rest.sites; + +import java.util.List; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestSiteContainerModelsCollection; +import org.alfresco.rest.model.RestSiteMemberModelsCollection; +import org.alfresco.rest.model.RestSiteModel; +import org.alfresco.utility.constants.ContainerName; +import org.alfresco.utility.constants.UserRole; +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.springframework.social.alfresco.api.entities.Site.Visibility; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class GetSiteFullTests extends RestTest +{ + private UserModel adminUserModel, testUser; + private SiteModel publicSite; + private RestSiteModel restSiteModel; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws DataPreparationException + { + adminUserModel = dataUser.getAdminUser(); + testUser = dataUser.createRandomTestUser(); + restClient.authenticateUser(adminUserModel); + publicSite = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Perform invalid request and check default error schema") + public void checkDefaultErrorSchema() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite("NonExistentSiteId").getSite(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "NonExistentSiteId")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }, expectedExceptions = java.lang.AssertionError.class) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Check that properties parameter is applied (guid field is mandatory, thus assertion error is expected)") + public void checkThatPropertiesParameterIsApplied() throws Exception + { + restSiteModel = restClient.authenticateUser(adminUserModel).withParams("properties=id, visibility").withCoreAPI().usingSite(publicSite).getSite(); + restSiteModel.assertThat().field("id").is(publicSite.getId()).and().field("visibility").is(Visibility.PUBLIC.toString()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL } ) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Check that properties parameter is applied") + public void checkThatPropertiesParameterIsAppliedPositiveTest() throws Exception + { + restSiteModel = restClient.authenticateUser(adminUserModel).withParams("properties=id,guid,title,visibility").withCoreAPI().usingSite(publicSite).getSite(); + restSiteModel.assertThat().field("id").is(publicSite.getId()).and().field("visibility").is(Visibility.PUBLIC.toString()) + .and().field("description").isNull() + .and().field("role").isNull(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL } ) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Delete site then get site details") + public void deleteSiteThenGetSiteDetails() throws Exception + { + SiteModel newSite = dataSite.usingAdmin().createPublicRandomSite(); + dataSite.deleteSite(newSite); + restSiteModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(newSite).getSite(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newSite.getId())) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL } ) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Delete site then get site details") + public void updateSiteVisibilityToPrivateThenGetSite() throws Exception + { + SiteModel newSite = dataSite.usingAdmin().createPublicRandomSite(); + restSiteModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(newSite).getSite(); + restClient.assertStatusCodeIs(HttpStatus.OK); + dataSite.updateSiteVisibility(newSite, Visibility.PRIVATE); + restSiteModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(newSite).getSite(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteModel.assertThat().field("id").is(newSite.getId()) + .and().field("visibility").is(Visibility.PRIVATE.toString()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL } ) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Get private site with a non member") + public void getPrivateSiteWithNonMemberUser() throws Exception + { + SiteModel newSite = dataSite.usingAdmin().createPrivateRandomSite(); + restSiteModel = restClient.authenticateUser(testUser).withCoreAPI().usingSite(newSite).getSite(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newSite.getId())) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL } ) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Get moderated site with a non member") + public void getModeratedSiteWithNonMemberUser() throws Exception + { + SiteModel newSite = dataSite.usingAdmin().createModeratedRandomSite(); + restSiteModel = restClient.authenticateUser(testUser).withCoreAPI().usingSite(newSite).getSite(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteModel.assertThat().field("id").is(newSite.getId()) + .and().field("visibility").is(Visibility.MODERATED.toString()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL } ) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Get public site with a non member") + public void getPublicSiteWithNonMemberUser() throws Exception + { + SiteModel newSite = dataSite.usingAdmin().createPublicRandomSite(); + restSiteModel = restClient.authenticateUser(testUser).withCoreAPI().usingSite(newSite).getSite(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteModel.assertThat().field("id").is(newSite.getId()) + .and().field("visibility").is(Visibility.PUBLIC.toString()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL } ) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Check that relations parameter is applied for containers") + public void checkThatRelationsParameterIsAppliedForContainers() throws Exception + { + List jsonObjects = restClient.authenticateUser(adminUserModel) + .withParams("relations=containers").withCoreAPI().usingSite(publicSite).getSiteWithRelations(); + + RestSiteModel siteModel = (RestSiteModel) jsonObjects.get(0); + RestSiteContainerModelsCollection containers = (RestSiteContainerModelsCollection) jsonObjects.get(1); + + siteModel.assertThat().field("visibility").is(publicSite.getVisibility()) + .and().field("id").is(publicSite.getId()) + .and().field("description").is(publicSite.getDescription()) + .and().field("title").is(publicSite.getTitle()) + .and().field("preset").is("site-dashboard") + .and().field("guid").isNotEmpty(); + + containers.assertThat().entriesListCountIs(1) + .and().entriesListContains("folderId", ContainerName.documentLibrary.toString()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL } ) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Check that relations parameter is applied for members") + public void checkThatRelationsParameterIsAppliedForMembers() throws Exception + { + List jsonObjects = restClient.authenticateUser(adminUserModel) + .withParams("relations=members").withCoreAPI().usingSite(publicSite).getSiteWithRelations(); + + RestSiteModel siteModel = (RestSiteModel) jsonObjects.get(0); + RestSiteMemberModelsCollection siteMembers = (RestSiteMemberModelsCollection) jsonObjects.get(1); + + siteModel.assertThat().field("visibility").is(publicSite.getVisibility()) + .and().field("id").is(publicSite.getId()) + .and().field("description").is(publicSite.getDescription()) + .and().field("title").is(publicSite.getTitle()) + .and().field("preset").is("site-dashboard") + .and().field("guid").isNotEmpty(); + + siteMembers.assertThat().entriesListCountIs(1) + .assertThat().entriesListContains("id", adminUserModel.getUsername()) + .assertThat().entriesListContains("role", UserRole.SiteManager.toString()); + siteMembers.getOneRandomEntry().onModel().getPerson().assertThat().field("firstName").is("Administrator") + .and().field("id").is("admin"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL } ) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Check that relations parameter is applied for containers and members") + public void checkThatRelationsParameterIsAppliedForContainersAndMembers() throws Exception + { + List jsonObjects = restClient.authenticateUser(adminUserModel) + .withParams("relations=containers,members").withCoreAPI().usingSite(publicSite).getSiteWithRelations(); + + RestSiteModel siteModel = (RestSiteModel) jsonObjects.get(0); + RestSiteContainerModelsCollection containers = (RestSiteContainerModelsCollection) jsonObjects.get(1); + RestSiteMemberModelsCollection siteMembers = (RestSiteMemberModelsCollection) jsonObjects.get(2); + + siteModel.assertThat().field("visibility").is(publicSite.getVisibility()) + .and().field("id").is(publicSite.getId()) + .and().field("description").is(publicSite.getDescription()) + .and().field("title").is(publicSite.getTitle()) + .and().field("preset").is("site-dashboard") + .and().field("guid").isNotEmpty(); + + containers.assertThat().entriesListCountIs(1) + .and().entriesListContains("folderId", ContainerName.documentLibrary.toString()); + + siteMembers.assertThat().entriesListCountIs(1) + .assertThat().entriesListContains("id", adminUserModel.getUsername()) + .assertThat().entriesListContains("role", UserRole.SiteManager.toString()); + siteMembers.getOneRandomEntry().onModel().getPerson().assertThat().field("firstName").is("Administrator") + .and().field("id").is("admin"); + } +} \ No newline at end of file From 2942cf98d3d7a729123687279fc40c6e20dca0c1 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Thu, 26 Jan 2017 19:04:13 +0200 Subject: [PATCH 0932/1491] fixed 3 tests and added one test to cover the new logged bug REPO-1889 --- .../sites/UpdateSiteMemberSanityTests.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java index 6e021d1f0..f60de1cdd 100644 --- a/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java @@ -50,6 +50,9 @@ public class UpdateSiteMemberSanityTests extends RestTest description = "Verify that collaborator is not able to update site member and gets status code FORBIDDEN (403)") public void collaboratorIsNotAbleToUpdateSiteMember() throws Exception { + UserModel testUserModel = dataUser.createRandomTestUser(); + dataUser.addUserToSite(testUserModel, siteModel, UserRole.SiteConsumer); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); testUserModel.setUserRole(UserRole.SiteCollaborator); restClient.withCoreAPI().usingSite(siteModel).updateSiteMember(testUserModel); @@ -58,11 +61,31 @@ public class UpdateSiteMemberSanityTests extends RestTest .containsSummary(String.format("The current user does not have permissions to modify the membership details of the site %s.", siteModel.getTitle())); } + @Bug(id = "REPO-1889") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, + description = "Verify that collaborator is not able to update site member and gets status code FORBIDDEN (403)") + public void collaboratorIsNotAbleToUpdateSiteMemberWithTheSameRole() throws Exception + { + UserModel testUserModel = dataUser.createRandomTestUser(); + dataUser.addUserToSite(testUserModel, siteModel, UserRole.SiteConsumer); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + testUserModel.setUserRole(UserRole.SiteConsumer); + restClient.withCoreAPI().usingSite(siteModel).updateSiteMember(testUserModel); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY); + restClient.assertLastError() + .containsSummary(String.format("The current user does not have permissions to modify the membership details of the site %s.", siteModel.getTitle())); + } + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that contributor is not able to update site member and gets status code FORBIDDEN (403)") public void contributorIsNotAbleToUpdateSiteMember() throws Exception { + UserModel testUserModel = dataUser.createRandomTestUser(); + dataUser.addUserToSite(testUserModel, siteModel, UserRole.SiteConsumer); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); testUserModel.setUserRole(UserRole.SiteCollaborator); restClient.withCoreAPI().usingSite(siteModel).updateSiteMember(testUserModel); @@ -76,6 +99,9 @@ public class UpdateSiteMemberSanityTests extends RestTest description = "Verify that consumer is not able to update site member and gets status code FORBIDDEN (403)") public void consumerIsNotAbleToUpdateSiteMember() throws Exception { + UserModel testUserModel = dataUser.createRandomTestUser(); + dataUser.addUserToSite(testUserModel, siteModel, UserRole.SiteConsumer); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); testUserModel.setUserRole(UserRole.SiteCollaborator); restClient.withCoreAPI().usingSite(siteModel).updateSiteMember(testUserModel); From 92911fc17e31df814a682f4243c52ca9ff22f4f8 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Fri, 27 Jan 2017 09:22:16 +0200 Subject: [PATCH 0933/1491] refactor NodesChildrenTests to use NodeBuilder --- .../rest/nodes/NodesChildrenTests.java | 77 ++++++------------- 1 file changed, 24 insertions(+), 53 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/nodes/NodesChildrenTests.java b/e2e-test/java/org/alfresco/rest/nodes/NodesChildrenTests.java index 77f305ff9..c981cc2dd 100644 --- a/e2e-test/java/org/alfresco/rest/nodes/NodesChildrenTests.java +++ b/e2e-test/java/org/alfresco/rest/nodes/NodesChildrenTests.java @@ -1,11 +1,10 @@ package org.alfresco.rest.nodes; -import java.util.UUID; - import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestNodeBodyModel; import org.alfresco.rest.model.RestNodeModel; import org.alfresco.rest.model.RestNodeModelsCollection; +import org.alfresco.rest.model.builder.NodesBuilder; import org.alfresco.utility.Utility; import org.alfresco.utility.model.ContentModel; import org.alfresco.utility.model.TestGroup; @@ -62,63 +61,35 @@ public class NodesChildrenTests extends RestTest @TestRail(section = { TestGroup.REST_API,TestGroup.NODES }, executionType = ExecutionType.SANITY, description = "Verify list children when listing with relativePath and pagination") @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY}) - public void listChildrenTest() throws Exception + public void checkRelativePathAndPaginationOnCreateChildrenNode() throws Exception { /* * Given we have a folder hierarchy folder1/folder2/folder3 and folder3 containing 3 files file1, file2, and file3 */ - restClient.authenticateUser(dataContent.getAdminUser()); - - RestNodeModel folder1 = createTestNode(ContentModel.my().getNodeRef(), "F1", "cm:folder"); - RestNodeModel folder2 = createTestNode(folder1.getId(), "F2", "cm:folder"); - RestNodeModel folder3 = createTestNode(folder2.getId(), "F3", "cm:folder"); - - RestNodeModel file1 = createTestNode(folder3.getId(), "f1", "cm:content"); - RestNodeModel file2 = createTestNode(folder3.getId(), "f2", "cm:content"); - RestNodeModel file3 = createTestNode(folder3.getId(), "f3", "cm:content"); - - /* - * When listing the children of folder1 with relative path folder2/folder3, page size 2 and skip count 1 - */ - ContentModel folder1Model = new ContentModel(); - folder1Model.setNodeRef(folder1.getId()); - RestNodeModelsCollection files = restClient.withParams("maxItems=2", "skipCount=1", "relativePath="+folder2.getName()+"/"+folder3.getName()) - .withCoreAPI().usingNode(folder1Model).listChildren(); + NodesBuilder nodesBuilder = restClient.authenticateUser(dataUser.getAdminUser()) + .withCoreAPI().usingNode(ContentModel.my()) + .defineNodes(); + nodesBuilder + .folder("F1") + .folder("F2") + .folder("F3") + .file("f1") + .file("f2") + .file("f2"); + + RestNodeModelsCollection returnedFiles = restClient.withParams("maxItems=2", + "skipCount=1", + String.format("relativePath=%s/%s", nodesBuilder.getNode("F2").getName(), nodesBuilder.getNode("F3").getName())) + .withCoreAPI().usingNode(nodesBuilder.getNode("F1").toContentModel()).listChildren(); restClient.assertStatusCodeIs(HttpStatus.OK); /* - * Then I receive file2 and file3 - */ - assert(files.getEntries().size() == 2); - assert(files.getEntries().get(0).onModel().getId().equals(file2.getId())); - assert(files.getEntries().get(1).onModel().getId().equals(file3.getId())); - } - - /** - * Helper method that creates a node in a specified folder - * - * @param parentId id of the parent folder - * @param name the name if the new node (a random string will be appended at the end) - * @param nodeType the type of the new node - * @return the model of the created node - * @throws Exception if the node failed to be created - */ - private RestNodeModel createTestNode(String parentId, String name, String nodeType) throws Exception - { - // define the new node model - RestNodeBodyModel model = new RestNodeBodyModel(); - model.setName(name + "-" + UUID.randomUUID().toString()); - model.setNodeType(nodeType); - - // define the parent - ContentModel parent = new ContentModel(); - parent.setNodeRef(parentId); - - // call the create children api - RestNodeModel newNode = restClient.withCoreAPI().usingNode(parent).createNode(model); - - // check and return the result - restClient.assertStatusCodeIs(HttpStatus.CREATED); - return newNode; + * Then I receive file2 and file3 + * + */ + returnedFiles.assertThat().entriesListCountIs(2); + returnedFiles.getEntries().get(0).onModel().assertThat().field("id").equals(nodesBuilder.getNode("F2").getId()); + returnedFiles.getEntries().get(1).onModel().assertThat().field("id").equals(nodesBuilder.getNode("F3").getId()); } + } From be2ca760a42fea49b2581c489639ed6bd4fa198b Mon Sep 17 00:00:00 2001 From: cagache Date: Fri, 27 Jan 2017 09:57:00 +0200 Subject: [PATCH 0934/1491] updated testcase and added bug annotation --- .../rest/workflow/tasks/UpdateTaskCoreTests.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTests.java index bebb9ac36..50c98b054 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTests.java @@ -13,6 +13,7 @@ import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TaskModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpMethod; @@ -142,10 +143,11 @@ public class UpdateTaskCoreTests extends RestTest restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); } + @Bug(id = "MNT-17407") @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can not update task from delegated to completed and response is 500") + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can update task from delegated to completed and response is 200") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void taskOwnerCanNotUpdateTaskFromDelegatedToCompleted() throws Exception + public void taskOwnerCanUpdateTaskFromDelegatedToCompleted() throws Exception { restClient.authenticateUser(userModel).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel); HashMap body = new HashMap(); @@ -160,7 +162,8 @@ public class UpdateTaskCoreTests extends RestTest .is(assigneeUser.getUsername()); restTaskModel = restClient.authenticateUser(userModel).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.INTERNAL_SERVER_ERROR).assertLastError().containsSummary(RestErrorModel.DELEGATED_TASK_CAN_NOT_BE_COMPLETED); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("completed"); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, From a30577a39a1739c1c6b8c3c73e0633db9164c34d Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Fri, 27 Jan 2017 10:42:16 +0200 Subject: [PATCH 0935/1491] Added GetSitesFullTests --- .../rest/sites/GetSitesFullTests.java | 179 ++++++++++++++++++ 1 file changed, 179 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/sites/GetSitesFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSitesFullTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSitesFullTests.java new file mode 100644 index 000000000..204d3fc63 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/sites/GetSitesFullTests.java @@ -0,0 +1,179 @@ +package org.alfresco.rest.sites; +import java.util.List; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestSiteModel; +import org.alfresco.rest.model.RestSiteModelsCollection; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.RandomData; +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.springframework.social.alfresco.api.entities.Site.Visibility; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class GetSitesFullTests extends RestTest +{ + private UserModel regularUser; + private SiteModel publicSite, secondSite, privateSite, moderatedSite; + private RestSiteModelsCollection sites; + private String name; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + name = RandomData.getRandomName("ZZZZZZZZZ-PublicSite"); + regularUser = dataUser.createRandomTestUser(); + publicSite = dataSite.usingAdmin().createSite(new SiteModel(Visibility.PUBLIC, "guid", name, name, name)); + privateSite = dataSite.usingAdmin().createSite(new SiteModel(RandomData.getRandomName("ZZZZZZZZZ-PrivateSite"), Visibility.PRIVATE)); + moderatedSite = dataSite.usingAdmin().createSite(new SiteModel(RandomData.getRandomName("ZZZZZZZZZ-ModeratedSite"), Visibility.MODERATED)); + secondSite = dataSite.usingAdmin().createSite(new SiteModel(RandomData.getRandomName("000000000-PublicSite"))); + dataUser.addUserToSite(regularUser, privateSite, UserRole.SiteManager); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if User gets sites ordered by title descending and status code is 200") + public void getSitesOrderedByTitleDESC() throws Exception + { + int totalItems = restClient.authenticateUser(regularUser).withCoreAPI().getSites().getPagination().getTotalItems(); + sites = restClient.authenticateUser(regularUser).withParams(String.format("maxItems=%s&orderBy=title DESC", totalItems)) + .withCoreAPI().getSites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + sites.assertThat().entriesListIsNotEmpty(); + List sitesList = sites.getEntries(); + sitesList.get(0).onModel().assertThat().field("title").is(publicSite.getTitle()); + sitesList.get(1).onModel().assertThat().field("title").is(privateSite.getTitle()); + sitesList.get(2).onModel().assertThat().field("title").is(moderatedSite.getTitle()); + sitesList.get(sitesList.size()-1).onModel().assertThat().field("title").is(secondSite.getTitle()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if User gets sites ordered by id ascending and status code is 200") + public void getSitesOrderedByIdASC() throws Exception + { + int totalItems = restClient.authenticateUser(regularUser).withCoreAPI().getSites().getPagination().getTotalItems(); + sites = restClient.authenticateUser(regularUser).withParams(String.format("maxItems=%s&orderBy=id ASC", totalItems)) + .withCoreAPI().getSites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + sites.assertThat().entriesListIsNotEmpty(); + List sitesList = sites.getEntries(); + sitesList.get(sitesList.size()-1).onModel().assertThat().field("id").is(publicSite.getId()); + sitesList.get(sitesList.size()-2).onModel().assertThat().field("id").is(privateSite.getId()); + sitesList.get(sitesList.size()-3).onModel().assertThat().field("id").is(moderatedSite.getId()); + sitesList.get(0).onModel().assertThat().field("id").is(secondSite.getId()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify pagination") + public void checkPagination() throws Exception + { + restClient.authenticateUser(regularUser).withCoreAPI().getSites().getPagination().assertThat() + .field("totalItems").isNotEmpty().and() + .field("maxItems").is("100").and() + .field("hasMoreItems").is("true").and() + .field("skipCount").is("0").and() + .field("count").is("100"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify user can get only first two sites and status code is 200") + public void getFirstTwoSites() throws Exception + { + sites = restClient.authenticateUser(regularUser).withParams(String.format("maxItems=%s&orderBy=id DESC", 2)) + .withCoreAPI().getSites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + sites.getPagination().assertThat().field("maxItems").is("2").and().field("count").is("2"); + sites.assertThat().entriesListCountIs(2).and().entriesListDoesNotContain(moderatedSite.getId()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify user can get sites using high skipCount parameter and status code is 200") + public void getSitesUsingHighSkipCount() throws Exception + { + sites = restClient.authenticateUser(regularUser).withParams("skipCount=100").withCoreAPI().getSites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + sites.assertThat().paginationField("skipCount").is("100"); + sites.assertThat().entriesListIsNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify user can not get sites using zero maxItems parameter and status code is 404") + public void userCanNotGetSitesUsingZeroMaxItems() throws Exception + { + sites = restClient.authenticateUser(regularUser).withParams("maxItems=0").withCoreAPI().getSites(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsErrorKey(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) + .containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify that getSites request applies valid properties param and status code is 200") + public void getSitesRequestWithValidPropertiesParam() throws Exception + { + sites = restClient.authenticateUser(regularUser).withParams("properties=id").withCoreAPI().getSites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + sites.assertThat().entriesListDoesNotContain("description") + .assertThat().entriesListDoesNotContain("title") + .assertThat().entriesListDoesNotContain("visibility") + .assertThat().entriesListDoesNotContain("guid") + .assertThat().entriesListContains("id"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify pagination when skipCount and MaxItems are used") + public void checkPaginationWithSkipCountAndMaxItems() throws Exception + { + restClient.authenticateUser(regularUser).withParams("skipCount=10&maxItems=200").withCoreAPI().getSites().getPagination().assertThat() + .field("totalItems").isNotEmpty().and() + .field("maxItems").is("200").and() + .field("hasMoreItems").is("true").and() + .field("skipCount").is("10").and() + .field("count").is("200"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if User gets sites ordered by id ascending and status code is 200") + public void getSitesOrderedByTitleASCAndVisibilityASC() throws Exception + { + SiteModel secondPublicSite = dataSite.usingAdmin().createSite( + new SiteModel(Visibility.PUBLIC, "guid", name+"A", name+"A", name)); + + int totalItems = restClient.authenticateUser(regularUser).withCoreAPI().getSites().getPagination().getTotalItems(); + sites = restClient.authenticateUser(regularUser).withParams(String.format("maxItems=%s&orderBy=description ASC&orderBy=title ASC", totalItems)) + .withCoreAPI().getSites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + sites.assertThat().entriesListIsNotEmpty(); + List sitesList = sites.getEntries(); + sitesList.get(sitesList.size()-1).onModel().assertThat().field("title").is(secondPublicSite.getTitle()); + sitesList.get(sitesList.size()-2).onModel().assertThat().field("title").is(publicSite.getTitle()); + + dataSite.deleteSite(secondPublicSite); + } + + @AfterClass(alwaysRun=true) + public void tearDown() throws Exception + { + dataSite.deleteSite(publicSite); + dataSite.deleteSite(privateSite); + dataSite.deleteSite(moderatedSite); + dataSite.deleteSite(secondSite); + } +} From 1f52f58db67bd13122d1951ffaf13b186e9ce4f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alecsandru=20Prun=C4=83?= Date: Fri, 27 Jan 2017 10:54:29 +0200 Subject: [PATCH 0936/1491] bug: fixed tests described in TAS-2887 --- .../rest/workflow/processes/AddProcessItemCoreTests.java | 5 +++-- .../workflow/processes/GetProcessVariablesCoreTests.java | 9 +++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemCoreTests.java index 26353e547..e33414d2c 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemCoreTests.java @@ -116,10 +116,11 @@ public class AddProcessItemCoreTests extends RestTest public void failedAddingProcessItemIfInvalidProcessIdIsProvided() throws Exception { RestProcessModelsCollection processes = restClient.authenticateUser(adminUser).withParams("maxItems=1").withWorkflowAPI().getProcesses(); - processModel= processes.assertThat().entriesListIsNotEmpty().when().getOneRandomEntry().onModel(); + processModel = processes.assertThat().entriesListIsNotEmpty().when().getOneRandomEntry().onModel(); + FileModel testDocument = dataContent.usingAdmin().usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); processModel.setId("invalidProcessId"); - processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); + processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(testDocument); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidProcessId")); } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesCoreTests.java index a17dcea20..1483bab99 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesCoreTests.java @@ -106,6 +106,15 @@ public class GetProcessVariablesCoreTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) public void getProcessVariablesForADeletedProcess() throws JsonToModelConversionException, Exception { + SiteModel siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); + UserModel userWhoStartsTask = dataUser.createRandomTestUser(); + UserModel assignee = dataUser.createRandomTestUser(); + FileModel document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + RestProcessModel processModel; + RestProcessVariableCollection variables; + + dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); + processModel = restClient.authenticateUser(userWhoStartsTask).withParams("maxItems=2").withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); restClient.authenticateUser(admin).withWorkflowAPI().usingProcess(processModel).deleteProcess(); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); From c02ff905c3637e27a258d6ec71a708a48919592b Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Fri, 27 Jan 2017 11:25:36 +0200 Subject: [PATCH 0937/1491] minor assert updates --- .../java/org/alfresco/rest/sites/GetSiteFullTests.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteFullTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteFullTests.java index 06900a42d..3ee6795d0 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteFullTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteFullTests.java @@ -174,8 +174,8 @@ public class GetSiteFullTests extends RestTest siteMembers.assertThat().entriesListCountIs(1) .assertThat().entriesListContains("id", adminUserModel.getUsername()) .assertThat().entriesListContains("role", UserRole.SiteManager.toString()); - siteMembers.getOneRandomEntry().onModel().getPerson().assertThat().field("firstName").is("Administrator") - .and().field("id").is("admin"); + siteMembers.getOneRandomEntry().onModel().assertThat().field("person.firstName").is("Administrator") + .and().field("person.id").is("admin"); } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL } ) @@ -203,7 +203,7 @@ public class GetSiteFullTests extends RestTest siteMembers.assertThat().entriesListCountIs(1) .assertThat().entriesListContains("id", adminUserModel.getUsername()) .assertThat().entriesListContains("role", UserRole.SiteManager.toString()); - siteMembers.getOneRandomEntry().onModel().getPerson().assertThat().field("firstName").is("Administrator") - .and().field("id").is("admin"); + siteMembers.getOneRandomEntry().onModel().assertThat().field("person.firstName").is("Administrator") + .and().field("person.id").is("admin"); } } \ No newline at end of file From 19a9d220a348616b2fa2b591f9071a5ca56a95ec Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Fri, 27 Jan 2017 12:28:32 +0200 Subject: [PATCH 0938/1491] update bug id since REPO-1889 is duplicate --- .../org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java index f60de1cdd..71d2dff2e 100644 --- a/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java @@ -61,7 +61,7 @@ public class UpdateSiteMemberSanityTests extends RestTest .containsSummary(String.format("The current user does not have permissions to modify the membership details of the site %s.", siteModel.getTitle())); } - @Bug(id = "REPO-1889") + @Bug(id = "REPO-1832") @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that collaborator is not able to update site member and gets status code FORBIDDEN (403)") From d6c806f784c891f8455ec2e01605a2049698696f Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Fri, 27 Jan 2017 14:34:50 +0200 Subject: [PATCH 0939/1491] Add tests that cover the relations parameter in get sites call --- .../rest/sites/GetSitesFullTests.java | 99 ++++++++++++++++++- 1 file changed, 97 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSitesFullTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSitesFullTests.java index 204d3fc63..c0ebd23b6 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSitesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSitesFullTests.java @@ -3,8 +3,11 @@ import java.util.List; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestSiteContainerModelsCollection; +import org.alfresco.rest.model.RestSiteMemberModelsCollection; import org.alfresco.rest.model.RestSiteModel; import org.alfresco.rest.model.RestSiteModelsCollection; +import org.alfresco.utility.constants.ContainerName; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.RandomData; import org.alfresco.utility.model.SiteModel; @@ -24,10 +27,12 @@ public class GetSitesFullTests extends RestTest private SiteModel publicSite, secondSite, privateSite, moderatedSite; private RestSiteModelsCollection sites; private String name; + private UserModel adminUser; @BeforeClass(alwaysRun=true) public void dataPreparation() throws Exception { + adminUser = dataUser.getAdminUser(); name = RandomData.getRandomName("ZZZZZZZZZ-PublicSite"); regularUser = dataUser.createRandomTestUser(); publicSite = dataSite.usingAdmin().createSite(new SiteModel(Visibility.PUBLIC, "guid", name, name, name)); @@ -109,7 +114,7 @@ public class GetSitesFullTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify user can not get sites using zero maxItems parameter and status code is 404") + description= "Verify user can not get sites using zero maxItems parameter and status code is 400") public void userCanNotGetSitesUsingZeroMaxItems() throws Exception { sites = restClient.authenticateUser(regularUser).withParams("maxItems=0").withCoreAPI().getSites(); @@ -168,6 +173,96 @@ public class GetSitesFullTests extends RestTest dataSite.deleteSite(secondPublicSite); } + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL } ) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Check that relations parameter is applied for containers") + public void checkThatRelationsParameterIsAppliedForContainers() throws Exception + { + List> jsonObjects = restClient.authenticateUser(adminUser) + .withParams("relations=containers").withCoreAPI().usingSite(publicSite).getSitesWithRelations(); + + List siteObjects = jsonObjects.get(0); + for (int i = 0; i < siteObjects.size(); i++) + { + RestSiteModel siteModel = (RestSiteModel) siteObjects.get(i); + siteModel.assertThat().field("visibility").isNotEmpty() + .and().field("id").isNotEmpty() + .and().field("title").isNotEmpty() + .and().field("preset").is("site-dashboard") + .and().field("guid").isNotEmpty(); + } + + List containerObjects = jsonObjects.get(1); + for (int i = 0; i < containerObjects.size(); i++) + { + RestSiteContainerModelsCollection containers = (RestSiteContainerModelsCollection) containerObjects.get(i); + containers.assertThat().entriesListIsNotEmpty().and().entriesListContains("folderId", ContainerName.documentLibrary.toString()); + } + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL } ) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Check that relations parameter is applied for members") + public void checkThatRelationsParameterIsAppliedForMembers() throws Exception + { + List> jsonObjects = restClient.authenticateUser(adminUser) + .withParams("relations=members").withCoreAPI().usingSite(publicSite).getSitesWithRelations(); + + List siteObjects = jsonObjects.get(0); + for (int i = 0; i < siteObjects.size(); i++) + { + RestSiteModel siteModel = (RestSiteModel) siteObjects.get(i); + siteModel.assertThat().field("visibility").isNotEmpty() + .and().field("id").isNotEmpty() + .and().field("title").isNotEmpty() + .and().field("preset").is("site-dashboard") + .and().field("guid").isNotEmpty(); + } + + List memberObjects = jsonObjects.get(1); + for (int i = 0; i < memberObjects.size(); i++) + { + RestSiteMemberModelsCollection siteMembers = (RestSiteMemberModelsCollection) memberObjects.get(i); + siteMembers.assertThat().entriesListIsNotEmpty().assertThat().entriesListContains("id").assertThat().entriesListContains("role", UserRole.SiteManager.toString()); + siteMembers.getOneRandomEntry().onModel().assertThat().field("person.firstName").isNotEmpty().and().field("person.id").isNotEmpty(); + } + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL } ) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Check that relations parameter is applied for members and containers") + public void checkThatRelationsParameterIsAppliedForMembersAndContainers() throws Exception + { + List> jsonObjects = restClient.authenticateUser(adminUser) + .withParams("relations=containers,members").withCoreAPI().usingSite(publicSite).getSitesWithRelations(); + + List siteObjects = jsonObjects.get(0); + for (int i = 0; i < siteObjects.size(); i++) + { + RestSiteModel siteModel = (RestSiteModel) siteObjects.get(i); + siteModel.assertThat().field("visibility").isNotEmpty() + .and().field("id").isNotEmpty() + .and().field("title").isNotEmpty() + .and().field("preset").is("site-dashboard") + .and().field("guid").isNotEmpty(); + } + + List containerObjects = jsonObjects.get(1); + for (int i = 0; i < containerObjects.size(); i++) + { + RestSiteContainerModelsCollection containers = (RestSiteContainerModelsCollection) containerObjects.get(i); + containers.assertThat().entriesListIsNotEmpty().and().entriesListContains("folderId", ContainerName.documentLibrary.toString()); + } + + List memberObjects = jsonObjects.get(2); + for (int i = 0; i < memberObjects.size(); i++) + { + RestSiteMemberModelsCollection siteMembers = (RestSiteMemberModelsCollection) memberObjects.get(i); + siteMembers.assertThat().entriesListIsNotEmpty().assertThat().entriesListContains("id").assertThat().entriesListContains("role", UserRole.SiteManager.toString()); + siteMembers.getOneRandomEntry().onModel().assertThat().field("person.firstName").isNotEmpty().and().field("person.id").isNotEmpty(); + } + } + @AfterClass(alwaysRun=true) public void tearDown() throws Exception { @@ -176,4 +271,4 @@ public class GetSitesFullTests extends RestTest dataSite.deleteSite(moderatedSite); dataSite.deleteSite(secondSite); } -} +} \ No newline at end of file From 9f3664044c5c76167c757a2d03ad6addb11c9437 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Fri, 27 Jan 2017 16:23:36 +0200 Subject: [PATCH 0940/1491] update jira issue for the test --- .../java/org/alfresco/rest/people/AddFavoriteSiteCoreTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteCoreTests.java b/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteCoreTests.java index 7b487deb5..34312995b 100644 --- a/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteCoreTests.java @@ -81,7 +81,7 @@ public class AddFavoriteSiteCoreTests extends RestTest .containsErrorKey(String.format("Site %s is already a favourite site", siteModel.getId())); } - @Bug(id="MNT-17337") + @Bug(id="REPO-1827") @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to add a favorite site when the 'id' is empty - status code (400)") From a1375172ea476ad423936b0083b0e98383443797 Mon Sep 17 00:00:00 2001 From: cagache Date: Fri, 27 Jan 2017 16:31:50 +0200 Subject: [PATCH 0941/1491] updated testcase based on REPO-1924 comments --- .../rest/workflow/tasks/UpdateTaskCoreTests.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTests.java index 50c98b054..cdfbaffdd 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTests.java @@ -143,11 +143,11 @@ public class UpdateTaskCoreTests extends RestTest restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); } - @Bug(id = "MNT-17407") + @Bug(id = "REPO-1924") @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can update task from delegated to completed and response is 200") + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can not update task from delegated to completed and response is 422") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void taskOwnerCanUpdateTaskFromDelegatedToCompleted() throws Exception + public void taskOwnerCanNotUpdateTaskFromDelegatedToCompleted() throws Exception { restClient.authenticateUser(userModel).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel); HashMap body = new HashMap(); @@ -161,9 +161,8 @@ public class UpdateTaskCoreTests extends RestTest restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated").and().field("assignee") .is(assigneeUser.getUsername()); - restTaskModel = restClient.authenticateUser(userModel).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("completed"); + restClient.authenticateUser(userModel).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(RestErrorModel.DELEGATED_TASK_CAN_NOT_BE_COMPLETED); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, From a98dd18cdafb2a924757067a040cd0b1736f1998 Mon Sep 17 00:00:00 2001 From: cagache Date: Mon, 30 Jan 2017 11:16:50 +0200 Subject: [PATCH 0942/1491] updated bug id --- .../org/alfresco/rest/people/GetPeopleActivitiesFullTests.java | 2 +- .../org/alfresco/rest/people/GetPeoplePreferencesFullTests.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesFullTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesFullTests.java index 3725f1a3a..167480f93 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesFullTests.java @@ -92,7 +92,7 @@ public class GetPeopleActivitiesFullTests extends RestTest .and().field("objectId").is(fileInSite1.getNodeRefWithoutVersion()); } - @Bug(id = "ACE-5460") + @Bug(id = "REPO-1911") @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.FULL }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot get activities for empty user with Rest API and response is 400") public void userCannotGetPeopleActivitiesForEmptyPersonId() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesFullTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesFullTests.java index 8eda8ca1f..dfd5ed18e 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesFullTests.java @@ -113,7 +113,7 @@ public class GetPeoplePreferencesFullTests extends RestTest restPreferenceModelsCollection.assertThat().entriesListIsEmpty(); } - @Bug(id = "ACE-5460") + @Bug(id = "REPO-1911") @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.FULL }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot get preferences for empty user with Rest API and response is 400") public void userGetsItsPeoplePreferencesForEmptyPersonId() throws Exception From f90f83788a45a9b4f7d715ad10d4142dcd05d805 Mon Sep 17 00:00:00 2001 From: cagache Date: Mon, 30 Jan 2017 11:36:54 +0200 Subject: [PATCH 0943/1491] updated testcase due to MNT-17158 comments --- .../rest/favorites/AddFavoritesCoreTests.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesCoreTests.java b/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesCoreTests.java index 54cdbcee7..08e00885d 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesCoreTests.java @@ -167,18 +167,19 @@ public class AddFavoritesCoreTests extends RestTest restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().getFavoriteSites().assertThat().entriesListContains("guid", siteModel.getGuid()); } - @Bug(id = "MNT-17158") +// @Bug(id = "MNT-17158", description="Not a bug, If we need to stop comments from being favourited then an improvement/enhancement request should be raised against the platform.") @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify add file favorite with comment id returns status code 404") + description = "Verify add file favorite with comment id returns status code 201") @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) public void addFileFavoriteUsingCommentId() throws Exception { FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); comment = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment("This is a comment"); file.setNodeRef(comment.getId()); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFileToFavorites(file); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + + restPersonFavoritesModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFileToFavorites(file); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restPersonFavoritesModel.assertThat().field("targetGuid").is(file.getNodeRef()); } @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, From ef60254446143fb2163c6bd29a44158cef31d72e Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Mon, 30 Jan 2017 11:41:09 +0200 Subject: [PATCH 0944/1491] Fixed GetSitesFullTests --- .../rest/sites/GetSitesFullTests.java | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSitesFullTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSitesFullTests.java index c0ebd23b6..57908f353 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSitesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSitesFullTests.java @@ -28,6 +28,8 @@ public class GetSitesFullTests extends RestTest private RestSiteModelsCollection sites; private String name; private UserModel adminUser; + private int maxItems = 200; + private int skipCount = 10; @BeforeClass(alwaysRun=true) public void dataPreparation() throws Exception @@ -81,12 +83,15 @@ public class GetSitesFullTests extends RestTest description= "Verify pagination") public void checkPagination() throws Exception { - restClient.authenticateUser(regularUser).withCoreAPI().getSites().getPagination().assertThat() + sites = restClient.authenticateUser(regularUser).withCoreAPI().getSites(); + int totalItems = sites.getPagination().getTotalItems(); + int maxItems = 100; + sites.getPagination().assertThat() .field("totalItems").isNotEmpty().and() - .field("maxItems").is("100").and() - .field("hasMoreItems").is("true").and() + .field("maxItems").is(String.valueOf(maxItems)).and() + .field("hasMoreItems").is((totalItems>maxItems) ? true : false).and() .field("skipCount").is("0").and() - .field("count").is("100"); + .field("count").is(String.valueOf((maxItems>totalItems) ? totalItems - skipCount : maxItems)); } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) @@ -145,12 +150,14 @@ public class GetSitesFullTests extends RestTest description= "Verify pagination when skipCount and MaxItems are used") public void checkPaginationWithSkipCountAndMaxItems() throws Exception { - restClient.authenticateUser(regularUser).withParams("skipCount=10&maxItems=200").withCoreAPI().getSites().getPagination().assertThat() + sites = restClient.authenticateUser(regularUser).withParams(String.format("skipCount=%s&maxItems=%s", skipCount, maxItems)).withCoreAPI().getSites(); + int totalItems = sites.getPagination().getTotalItems(); + sites.getPagination().assertThat() .field("totalItems").isNotEmpty().and() - .field("maxItems").is("200").and() - .field("hasMoreItems").is("true").and() - .field("skipCount").is("10").and() - .field("count").is("200"); + .field("maxItems").is(String.valueOf(maxItems)).and() + .field("hasMoreItems").is((totalItems>maxItems) ? true : false).and() + .field("skipCount").is(String.valueOf(skipCount)).and() + .field("count").is(String.valueOf((maxItems>totalItems) ? totalItems - skipCount : maxItems)); } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) From 821e9e712a9e6f70b0b7d2b3a2ec16212bf84cca Mon Sep 17 00:00:00 2001 From: cagache Date: Mon, 30 Jan 2017 11:51:58 +0200 Subject: [PATCH 0945/1491] updated testcase due to MNT-17375 comments --- .../java/org/alfresco/rest/ratings/AddRatingFullTests.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/ratings/AddRatingFullTests.java b/e2e-test/java/org/alfresco/rest/ratings/AddRatingFullTests.java index 1b81e93de..97c94e6a0 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/AddRatingFullTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/AddRatingFullTests.java @@ -482,7 +482,7 @@ public class AddRatingFullTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE); } - @Bug(id = "MNT-17375") +// @Bug(id = "MNT-17375", description = "Won't Fix, the error message is not ideal and a little cryptic but it does provide the reason i.e. ratingSchemeId is null.") @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Do not provide field - 'id'") @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) @@ -494,8 +494,8 @@ public class AddRatingFullTests extends RestTest restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"myRating\":\"true\"}"); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) .assertLastError() - .containsSummary(RestErrorModel.NULL_LIKE_RATING) - .containsErrorKey(RestErrorModel.NULL_LIKE_RATING) + .containsSummary(String.format(RestErrorModel.INVALID_RATING, "null")) + .containsErrorKey(String.format(RestErrorModel.INVALID_RATING, "null")) .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) .stackTraceIs(RestErrorModel.STACKTRACE); } From 67253f946e172634e8db1dbbadb250044dfb6fd4 Mon Sep 17 00:00:00 2001 From: cagache Date: Mon, 30 Jan 2017 12:13:15 +0200 Subject: [PATCH 0946/1491] updated testcases due to MNT-16919 comments. --- ...pdateSiteMembershipRequestSanityTests.java | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestSanityTests.java index c62d58e12..6908f60cd 100644 --- a/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestSanityTests.java @@ -23,12 +23,6 @@ import org.testng.annotations.Test; public class UpdateSiteMembershipRequestSanityTests extends RestTest { - @Autowired - DataUser dataUser; - - @Autowired - DataSite dataSite; - private SiteModel siteModel; private ListUserWithRoles usersWithRoles; private UserModel adminUser; @@ -60,7 +54,7 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site manager is not able to update membership request of another user") - @Bug(id = "MNT-16919") +// @Bug(id = "MNT-16919", description = "Not a bug, The presence of the personId in the URL does not mean it should be possible to act on any other users behalf.") public void siteManagerIsNotAbleToUpdateSiteMembershipRequestOfAnotherUser() throws JsonToModelConversionException, Exception { UserModel newMember = dataUser.createRandomTestUser(); @@ -70,12 +64,13 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingUser(newMember) .updateSiteMembershipRequest(siteModel, updatedMessage); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site collaborator is not able to update membership request of another user") - @Bug(id = "MNT-16919") + // @Bug(id = "MNT-16919", description = "Not a bug, The presence of the personId in the URL does not mean it should be possible to act on any other users behalf.") public void siteCollaboratorIsNotAbleToUpdateSiteMembershipRequestOfAnotherUser() throws JsonToModelConversionException, Exception { UserModel newMember = dataUser.createRandomTestUser(); @@ -85,12 +80,13 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingUser(newMember) .updateSiteMembershipRequest(siteModel, updatedMessage); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site contributor is not able to update membership request of another user") - @Bug(id = "MNT-16919") + // @Bug(id = "MNT-16919", description = "Not a bug, The presence of the personId in the URL does not mean it should be possible to act on any other users behalf.") public void siteContributorIsNotAbleToUpdateSiteMembershipRequestOfAnotherUser() throws JsonToModelConversionException, Exception { UserModel newMember = dataUser.createRandomTestUser(); @@ -100,12 +96,13 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingUser(newMember) .updateSiteMembershipRequest(siteModel, updatedMessage); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site consumer is not able to update membership request of another user") - @Bug(id = "MNT-16919") + // @Bug(id = "MNT-16919", description = "Not a bug, The presence of the personId in the URL does not mean it should be possible to act on any other users behalf.") public void siteConsumerIsNotAbleToUpdateSiteMembershipRequestOfAnotherUser() throws JsonToModelConversionException, Exception { UserModel newMember = dataUser.createRandomTestUser(); @@ -115,12 +112,13 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingUser(newMember) .updateSiteMembershipRequest(siteModel, updatedMessage); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify one user is not able to update membership request of another user") - @Bug(id = "MNT-16919") + // @Bug(id = "MNT-16919", description = "Not a bug, The presence of the personId in the URL does not mean it should be possible to act on any other users behalf.") public void oneUserIsNotAbleToUpdateSiteMembershipRequestOfAnotherUser() throws JsonToModelConversionException, Exception { UserModel newMember = dataUser.createRandomTestUser(); @@ -130,12 +128,13 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest restClient.authenticateUser(otherMember).withCoreAPI().usingUser(newMember).updateSiteMembershipRequest(siteModel, updatedMessage); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify admin is not able to update membership request of another user") - @Bug(id = "MNT-16919") + // @Bug(id = "MNT-16919", description = "Not a bug, The presence of the personId in the URL does not mean it should be possible to act on any other users behalf.") public void adminIsNotAbleToUpdateSiteMembershipRequestOfAnotherUser() throws JsonToModelConversionException, Exception { UserModel newMember = dataUser.createRandomTestUser(); @@ -144,6 +143,7 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest restClient.authenticateUser(adminUser).withCoreAPI().usingUser(newMember).updateSiteMembershipRequest(siteModel, updatedMessage); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); } } \ No newline at end of file From b47a4577e0dc8b35fc175305797f188b6571b03e Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Mon, 30 Jan 2017 16:50:19 +0200 Subject: [PATCH 0947/1491] update or remove bug id from @Bug --- ...eleteSiteMembershipRequestSanityTests.java | 28 +++++++++---------- .../sites/RemoveSiteMemberSanityTests.java | 24 ++++++++-------- .../rest/sites/UpdateSiteMemberCoreTests.java | 2 +- 3 files changed, 28 insertions(+), 26 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java index af2db17eb..d25f62f14 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java @@ -51,19 +51,17 @@ public class DeleteSiteMembershipRequestSanityTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @Bug(id = "MNT-16916") @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site manager is able to delete site membership request") public void siteManagerCanDeleteSiteMembershipRequest() throws JsonToModelConversionException, DataPreparationException, Exception { siteMember = dataUser.createRandomTestUser(); restClient.authenticateUser(siteMember).withCoreAPI().usingUser(siteMember).addSiteMembershipRequest(siteModel); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingAuthUser() + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingUser(siteMember) .deleteSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @Bug(id = "MNT-16916") @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify admin user is able to delete site memebership request") public void adminUserCanDeleteSiteMembershipRequest() throws JsonToModelConversionException, DataPreparationException, Exception { @@ -71,61 +69,63 @@ public class DeleteSiteMembershipRequestSanityTests extends RestTest restClient.authenticateUser(siteMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingAuthUser().deleteSiteMembershipRequest(siteModel); + restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingUser(siteMember).deleteSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @Bug(id = "MNT-16916") + @Bug(id = "REPO-1946") @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify collaborator user is not able to delete site memebership request") public void collaboratorCannotDeleteSiteMembershipRequest() throws JsonToModelConversionException, DataPreparationException, Exception { siteMember = dataUser.createRandomTestUser(); restClient.authenticateUser(siteMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(siteModel); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingAuthUser() + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingUser(siteMember) .deleteSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @Bug(id = "MNT-16916") + @Bug(id = "REPO-1946") @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify contributor user is not able to delete site memebership request") public void contributorCannotDeleteSiteMembershipRequest() throws JsonToModelConversionException, DataPreparationException, Exception { siteMember = dataUser.createRandomTestUser(); restClient.authenticateUser(siteMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(siteModel); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingAuthUser() + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingUser(siteMember) .deleteSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @Bug(id = "MNT-16916") + @Bug(id = "REPO-1946") @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify consumer user is not able to delete site memebership request") public void consumerCannotDeleteSiteMembershipRequest() throws JsonToModelConversionException, DataPreparationException, Exception { siteMember = dataUser.createRandomTestUser(); restClient.authenticateUser(siteMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(siteModel); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingAuthUser() + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingUser(siteMember) .deleteSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @Bug(id = "MNT-16916") + @Bug(id = "REPO-1946") @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify random user is not able to delete site memebership request") public void randomUserCanDeleteSiteMembershipRequest() throws JsonToModelConversionException, DataPreparationException, Exception { - restClient.authenticateUser(dataUser.createRandomTestUser()).withCoreAPI().usingAuthUser().addSiteMembershipRequest(siteModel); + siteMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(siteMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(siteModel); - restClient.authenticateUser(dataUser.createRandomTestUser()).withCoreAPI().usingAuthUser().deleteSiteMembershipRequest(siteModel); + restClient.authenticateUser(dataUser.createRandomTestUser()).withCoreAPI().usingUser(siteMember).deleteSiteMembershipRequest(siteModel); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, 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") + @Bug(id = "MNT-16904") public void unauthenticatedUserIsNotAuthorizedToDeleteSiteMmebershipRequest() throws JsonToModelConversionException, Exception { restClient.authenticateUser(dataUser.createRandomTestUser()).withCoreAPI().usingAuthUser().addSiteMembershipRequest(siteModel); diff --git a/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java index 0d412043d..2607dbc0e 100644 --- a/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java @@ -44,11 +44,11 @@ public class RemoveSiteMemberSanityTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); restClient.withCoreAPI().usingSite(siteModel).deleteSiteMember(testUserModel); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().getSites().assertThat().entriesListDoesNotContain("id", testUserModel.getUsername()); + restClient.withCoreAPI().usingSite(siteModel).getSiteMembers() + .assertThat().entriesListDoesNotContain("id", testUserModel.getUsername()); restClient.assertStatusCodeIs(HttpStatus.OK); } - @Bug(id = "ACE-5444") @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that site collaborator cannot delete site member and gets status code 403, 'Forbidden'") @@ -59,13 +59,13 @@ public class RemoveSiteMemberSanityTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); restClient.withCoreAPI().usingSite(siteModel).deleteSiteMember(testUserModel); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY); - restClient.withCoreAPI().getSites().assertThat().entriesListContains("id", testUserModel.getUsername()); + restClient.withCoreAPI().usingSite(siteModel).getSiteMembers() + .assertThat().entriesListContains("id", testUserModel.getUsername()); restClient.assertStatusCodeIs(HttpStatus.OK); } - @Bug(id = "ACE-5444") @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that site contributor cannot delete site member and gets status code 403, 'Forbidden'") @@ -76,13 +76,13 @@ public class RemoveSiteMemberSanityTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); restClient.withCoreAPI().usingSite(siteModel).deleteSiteMember(testUserModel); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY); - restClient.withCoreAPI().getSites().assertThat().entriesListContains("id", testUserModel.getUsername()); + restClient.withCoreAPI().usingSite(siteModel).getSiteMembers() + .assertThat().entriesListContains("id", testUserModel.getUsername()); restClient.assertStatusCodeIs(HttpStatus.OK); } - @Bug(id = "ACE-5444") @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that site consumer cannot delete site member and gets status code 403, 'Forbidden'") @@ -93,9 +93,10 @@ public class RemoveSiteMemberSanityTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingSite(siteModel) .deleteSiteMember(testUserModel); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY); - restClient.withCoreAPI().getSites().assertThat().entriesListContains("id", testUserModel.getUsername()); + restClient.withCoreAPI().usingSite(siteModel).getSiteMembers() + .assertThat().entriesListContains("id", testUserModel.getUsername()); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -110,7 +111,8 @@ public class RemoveSiteMemberSanityTests extends RestTest restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(siteModel).deleteSiteMember(testUserModel); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().getSites().assertThat().entriesListDoesNotContain("id", testUserModel.getUsername()); + restClient.withCoreAPI().usingSite(siteModel).getSiteMembers() + .assertThat().entriesListDoesNotContain("id", testUserModel.getUsername()); restClient.assertStatusCodeIs(HttpStatus.OK); } diff --git a/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberCoreTests.java index 4f79c1355..de2905cc1 100644 --- a/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberCoreTests.java @@ -82,7 +82,7 @@ public class UpdateSiteMemberCoreTests extends RestTest .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, nonexistentUser.getUsername())); } - @Bug(id="REPO-1660") + @Bug(id="REPO-1941") @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if a manager is able to downgrade to contributor using -me- string in place of personId.") From 456f45ae3e2ca994bdf07868d65574a1d135ab98 Mon Sep 17 00:00:00 2001 From: cagache Date: Tue, 31 Jan 2017 11:22:06 +0200 Subject: [PATCH 0948/1491] TAS - 2891 - getDeployments --- .../deployments/GetDeploymentsFullTests.java | 146 ++++++++++++++++++ .../GetDeploymentsSanityTests.java | 8 +- 2 files changed, 153 insertions(+), 1 deletion(-) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsFullTests.java new file mode 100644 index 000000000..b97446893 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsFullTests.java @@ -0,0 +1,146 @@ +package org.alfresco.rest.workflow.deployments; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestDeploymentModel; +import org.alfresco.rest.model.RestDeploymentModelsCollection; +import org.alfresco.rest.model.RestErrorModel; +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; + +/** + * Created by Claudia Agache on 1/30/2017. + */ +public class GetDeploymentsFullTests extends RestTest +{ + private UserModel adminUserModel; + private RestDeploymentModelsCollection deployments; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + restClient.authenticateUser(adminUserModel); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, + description = "Verify Admin user gets non-network deployments with skipCount parameter applied using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.FULL}) + public void getNonNetworkDeploymentsWithValidSkipCount() throws JsonToModelConversionException, Exception + { + deployments = restClient.withWorkflowAPI().getDeployments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + RestDeploymentModel firstDeployment = deployments.getEntries().get(0); + RestDeploymentModel secondDeployment = deployments.getEntries().get(1); + RestDeploymentModelsCollection deploymentsWithSkipCount = restClient.withParams("skipCount=2").withWorkflowAPI().getDeployments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + deploymentsWithSkipCount + .assertThat().entriesListDoesNotContain("name", firstDeployment.getName()) + .assertThat().entriesListDoesNotContain("name", secondDeployment.getName()) + .assertThat().entriesListCountIs(deployments.getEntries().size()-2); + deploymentsWithSkipCount.assertThat().paginationField("skipCount").is("2"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, + description = "Verify Admin user doesn't get non-network deployments when negative skipCount parameter is applied using REST API and status code is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.FULL}) + public void getNonNetworkDeploymentsWithNegativeSkipCount() throws JsonToModelConversionException, Exception + { + restClient.withParams("skipCount=-1").withWorkflowAPI().getDeployments(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT) + .containsErrorKey(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE) + .statusCodeIs(HttpStatus.BAD_REQUEST); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, + description = "Verify Admin user doesn't get non-network deployments when non numeric skipCount parameter is applied using REST API and status code is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.FULL}) + public void getNonNetworkDeploymentsWithNotNumericSkipCount() throws JsonToModelConversionException, Exception + { + restClient.withParams("skipCount=A").withWorkflowAPI().getDeployments(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "A")); + } + + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, + description = "Verify Admin user gets non-network deployments with maxItems parameter applied using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.FULL}) + public void getNonNetworkDeploymentsWithValidMaxItems() throws JsonToModelConversionException, Exception + { + deployments = restClient.withWorkflowAPI().getDeployments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + RestDeploymentModel firstDeployment = deployments.getEntries().get(0); + RestDeploymentModel secondDeployment = deployments.getEntries().get(1); + RestDeploymentModelsCollection deploymentsWithMaxItems = restClient.withParams("maxItems=2").withWorkflowAPI().getDeployments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + deploymentsWithMaxItems + .assertThat().entriesListContains("name", firstDeployment.getName()) + .assertThat().entriesListContains("name", secondDeployment.getName()) + .assertThat().entriesListCountIs(2); + deploymentsWithMaxItems.assertThat().paginationField("maxItems").is("2"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, + description = "Verify Admin user doesn't get non-network deployments when negative maxItems parameter is applied using REST API and status code is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.FULL}) + public void getNonNetworkDeploymentsWithNegativeMaxItems() throws JsonToModelConversionException, Exception + { + restClient.withParams("maxItems=-1").withWorkflowAPI().getDeployments(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) + .containsErrorKey(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE) + .statusCodeIs(HttpStatus.BAD_REQUEST); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, + description = "Verify Admin user doesn't get non-network deployments when non numeric maxItems parameter is applied using REST API and status code is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.FULL}) + public void getNonNetworkDeploymentsWithNotNumericMaxItems() throws JsonToModelConversionException, Exception + { + restClient.withParams("skipCount=A").withWorkflowAPI().getDeployments(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "A")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, + description = "Verify Admin user gets non-network deployments with properties parameter applied using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.FULL}) + public void getNonNetworkDeploymentsWithValidProperties() throws JsonToModelConversionException, Exception + { + deployments = restClient.withParams("properties=name").withWorkflowAPI().getDeployments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + deployments.assertThat().entriesListIsNotEmpty(); + deployments.getOneRandomEntry().onModel().assertThat() + .fieldsCount().is(1).and() + .field("id").isNull().and() + .field("deployedAt").isNull().and() + .field("name").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, + description = "Verify Admin user gets non-network deployments with non existing properties parameter applied using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.FULL}) + public void getNonNetworkDeploymentsWithNonExistingProperties() throws JsonToModelConversionException, Exception + { + deployments = restClient.withParams("properties=TAS").withWorkflowAPI().getDeployments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + deployments.assertThat().entriesListIsNotEmpty(); + deployments.getOneRandomEntry().onModel().assertThat() + .fieldsCount().is(0).and() + .field("id").isNull().and() + .field("deployedAt").isNull().and() + .field("name").isNull(); + } + +} diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsSanityTests.java index 407689b74..1ee87f741 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsSanityTests.java @@ -35,6 +35,11 @@ public class GetDeploymentsSanityTests extends RestTest deployments = restClient.authenticateUser(adminUserModel).withWorkflowAPI().getDeployments(); restClient.assertStatusCodeIs(HttpStatus.OK); deployments.assertThat().entriesListIsNotEmpty(); + deployments.getOneRandomEntry().onModel().assertThat() + .fieldsCount().is(3).and() + .field("id").isNotEmpty().and() + .field("deployedAt").isNotEmpty().and() + .field("name").isNotEmpty(); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.SANITY, @@ -45,6 +50,7 @@ public class GetDeploymentsSanityTests extends RestTest restClient.usingTenant().createTenant(adminTenantUser); deployments = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getDeployments(); restClient.assertStatusCodeIs(HttpStatus.OK); - deployments.assertThat().entriesListIsNotEmpty(); + deployments.assertThat().entriesListIsNotEmpty() + .and().entriesListDoesNotContain("name", "customWorkflowExtentionForRest.bpmn"); } } From 649deca70c2abfc9a3ed3ed5d6ae93b175aa1af9 Mon Sep 17 00:00:00 2001 From: cagache Date: Tue, 31 Jan 2017 11:51:19 +0200 Subject: [PATCH 0949/1491] TAS - 2891 - getDeployments --- .../rest/workflow/deployments/GetDeploymentsFullTests.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsFullTests.java index b97446893..a62735f91 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsFullTests.java @@ -78,8 +78,8 @@ public class GetDeploymentsFullTests extends RestTest { deployments = restClient.withWorkflowAPI().getDeployments(); restClient.assertStatusCodeIs(HttpStatus.OK); - RestDeploymentModel firstDeployment = deployments.getEntries().get(0); - RestDeploymentModel secondDeployment = deployments.getEntries().get(1); + RestDeploymentModel firstDeployment = deployments.getEntries().get(0).onModel(); + RestDeploymentModel secondDeployment = deployments.getEntries().get(1).onModel(); RestDeploymentModelsCollection deploymentsWithMaxItems = restClient.withParams("maxItems=2").withWorkflowAPI().getDeployments(); restClient.assertStatusCodeIs(HttpStatus.OK); deploymentsWithMaxItems @@ -108,7 +108,7 @@ public class GetDeploymentsFullTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.FULL}) public void getNonNetworkDeploymentsWithNotNumericMaxItems() throws JsonToModelConversionException, Exception { - restClient.withParams("skipCount=A").withWorkflowAPI().getDeployments(); + restClient.withParams("maxItems=A").withWorkflowAPI().getDeployments(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() .containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "A")); } From 2a368b7116edf60984003951880e4772d97fee41 Mon Sep 17 00:00:00 2001 From: cagache Date: Tue, 31 Jan 2017 12:16:36 +0200 Subject: [PATCH 0950/1491] TAS - 2891 - getDeployments --- .../deployments/GetDeploymentsFullTests.java | 17 +++++++++++++++++ .../deployments/GetDeploymentsSanityTests.java | 3 +-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsFullTests.java index a62735f91..6080faa3b 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsFullTests.java @@ -143,4 +143,21 @@ public class GetDeploymentsFullTests extends RestTest .field("name").isNull(); } + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, + executionType = ExecutionType.REGRESSION, + description = "Verify that network admin user is not able to get a deployment from other network using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.FULL, TestGroup.NETWORKS}) + public void adminDoesNotGetDeploymentsFromOtherNetwork() throws Exception + { + UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); + UserModel adminTenantUser2 = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUserModel).usingTenant().createTenant(adminTenantUser1); + restClient.usingTenant().createTenant(adminTenantUser2); + + RestDeploymentModel deployment = restClient.authenticateUser(adminTenantUser1).withWorkflowAPI().getDeployments().getOneRandomEntry().onModel(); + deployments = restClient.authenticateUser(adminTenantUser2).withWorkflowAPI().getDeployments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + deployments.assertThat().entriesListDoesNotContain("id", deployment.getId()); + } + } diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsSanityTests.java index 1ee87f741..6eab0bae6 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsSanityTests.java @@ -50,7 +50,6 @@ public class GetDeploymentsSanityTests extends RestTest restClient.usingTenant().createTenant(adminTenantUser); deployments = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getDeployments(); restClient.assertStatusCodeIs(HttpStatus.OK); - deployments.assertThat().entriesListIsNotEmpty() - .and().entriesListDoesNotContain("name", "customWorkflowExtentionForRest.bpmn"); + deployments.assertThat().entriesListIsNotEmpty(); } } From aeb1fe90ce87b01735180c3bace0f87631afd508 Mon Sep 17 00:00:00 2001 From: cagache Date: Tue, 31 Jan 2017 12:19:43 +0200 Subject: [PATCH 0951/1491] TAS - 2893 - getDeployment --- .../deployments/GetDeploymentFullTests.java | 102 ++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentFullTests.java new file mode 100644 index 000000000..cb2c38466 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentFullTests.java @@ -0,0 +1,102 @@ +package org.alfresco.rest.workflow.deployments; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.model.RestDeploymentModel; +import org.alfresco.rest.model.RestDeploymentModelsCollection; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Created by Claudia Agache on 1/31/2017. + */ +public class GetDeploymentFullTests extends RestTest +{ + private UserModel adminUser; + private RestDeploymentModel expectedDeployment, actualDeployment; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, + executionType = ExecutionType.REGRESSION, + description = "Verify if get deployment request returns all deployments if empty deploymentId is used.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.FULL }) + public void getNonNetworkDeploymentUsingEmptyDeploymentId() throws Exception + { + restClient.authenticateUser(adminUser).withWorkflowAPI(); + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "deployments/{deploymentId}", ""); + RestDeploymentModelsCollection deployments = restClient.processModels(RestDeploymentModelsCollection.class, request); + restClient.assertStatusCodeIs(HttpStatus.OK); + deployments.assertThat().entriesListIsNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, + description = "Verify Admin user gets non-network deployments with properties parameter applied using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.FULL}) + public void getNonNetworkDeploymentsWithValidProperties() throws Exception + { + expectedDeployment = restClient.authenticateUser(adminUser).withWorkflowAPI().getDeployments().getOneRandomEntry().onModel(); + actualDeployment = restClient.withParams("properties=id,name").withWorkflowAPI().usingDeployment(expectedDeployment).getDeployment(); + restClient.assertStatusCodeIs(HttpStatus.OK); + actualDeployment.assertThat() + .fieldsCount().is(2).and() + .field("id").is(expectedDeployment.getId()).and() + .field("deployedAt").isNull().and() + .field("name").is(expectedDeployment.getName()); + } + + + @Bug(id = "MNT-16996") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, + executionType = ExecutionType.REGRESSION, description = "Verify admin user deletes a specific deployment using REST API and status code is successful (204)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.FULL}, priority = 100) + public void deleteDeploymentThenGet() throws Exception + { + dataContent.assertExtensionAmpExists("alfresco-workflow-extension"); + // The deployment with name "customWorkflowExtentionForRest.bpmn" is created by Workflow Extention Point + RestDeploymentModelsCollection allDeployments = restClient.authenticateUser(adminUser).withWorkflowAPI().getDeployments(); + allDeployments.assertThat().entriesListContains("name", "customWorkflowExtentionForRest.bpmn"); + expectedDeployment = allDeployments.getDeploymentByName("customWorkflowExtentionForRest.bpmn"); + + restClient.withWorkflowAPI().usingDeployment(expectedDeployment).deleteDeployment(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withWorkflowAPI().usingDeployment(expectedDeployment).getDeployment(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, expectedDeployment.getId())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, + executionType = ExecutionType.REGRESSION, + description = "Verify that network admin user is not able to get a deployment from other network using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.FULL, TestGroup.NETWORKS}) + public void adminDoesNotGetDeploymentFromOtherNetwork() throws Exception + { + UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); + UserModel adminTenantUser2 = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser1); + restClient.usingTenant().createTenant(adminTenantUser2); + + expectedDeployment = restClient.authenticateUser(adminTenantUser1).withWorkflowAPI().getDeployments().getOneRandomEntry().onModel(); + actualDeployment = restClient.authenticateUser(adminTenantUser2).withWorkflowAPI().usingDeployment(expectedDeployment).getDeployment(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, expectedDeployment.getId())) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + +} From 1469497719f9fa97af16eeda59a8d9934a9a7ad6 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Tue, 31 Jan 2017 14:54:40 +0200 Subject: [PATCH 0952/1491] Added TAS-2948 and TAS-2949 scenarios --- .../alfresco/rest/FunctionalCasesTests.java | 102 ++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java diff --git a/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java b/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java new file mode 100644 index 000000000..dbf0059aa --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java @@ -0,0 +1,102 @@ +package org.alfresco.rest; + +import org.alfresco.rest.model.RestSiteMemberModel; +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.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class FunctionalCasesTests extends RestTest +{ + private UserModel adminUserModel; + private SiteModel siteModel; + private RestSiteMemberModel updatedMember; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + } + + /** + * Scenario: + * 1. Add a site member as Manager + * 2. Update it's role to Collaborator + * 3. Update it's role to Contributor + * 4. Update it's role to Consumer + */ + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that manager is able to update manager with different roles and gets status code CREATED (201)") + public void managerIsAbleToUpdateManagerWithDifferentRoles() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteManager); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(siteModel).addPerson(testUser) + .assertThat().field("id").is(testUser.getUsername()) + .and().field("role").is(testUser.getUserRole()); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + testUser.setUserRole(UserRole.SiteCollaborator); + updatedMember = restClient.authenticateUser(adminUserModel).withCoreAPI() + .usingSite(siteModel).updateSiteMember(testUser); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedMember.assertThat().field("id").is(testUser.getUsername()).and().field("role").is(testUser.getUserRole()); + + testUser.setUserRole(UserRole.SiteContributor); + updatedMember = restClient.authenticateUser(adminUserModel).withCoreAPI() + .usingSite(siteModel).updateSiteMember(testUser); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedMember.assertThat().field("id").is(testUser.getUsername()).and().field("role").is(testUser.getUserRole()); + + testUser.setUserRole(UserRole.SiteConsumer); + updatedMember = restClient.authenticateUser(adminUserModel).withCoreAPI() + .usingSite(siteModel).updateSiteMember(testUser); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedMember.assertThat().field("id").is(testUser.getUsername()).and().field("role").is(testUser.getUserRole()); + } + + /** + * Scenario: + * 1. Add a site member as Consumer + * 2. Update it's role to Contributor + * 3. Update it's role to Collaborator + * 4. Update it's role to Manager + */ + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that manager is able to update consumer with different roles and gets status code CREATED (201)") + public void managerIsAbleToUpdateConsumerWithDifferentRoles() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteConsumer); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(siteModel).addPerson(testUser) + .assertThat().field("id").is(testUser.getUsername()) + .and().field("role").is(testUser.getUserRole()); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + testUser.setUserRole(UserRole.SiteContributor); + updatedMember = restClient.authenticateUser(adminUserModel).withCoreAPI() + .usingSite(siteModel).updateSiteMember(testUser); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedMember.assertThat().field("id").is(testUser.getUsername()).and().field("role").is(testUser.getUserRole()); + + testUser.setUserRole(UserRole.SiteCollaborator); + updatedMember = restClient.authenticateUser(adminUserModel).withCoreAPI() + .usingSite(siteModel).updateSiteMember(testUser); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedMember.assertThat().field("id").is(testUser.getUsername()).and().field("role").is(testUser.getUserRole()); + + testUser.setUserRole(UserRole.SiteManager); + updatedMember = restClient.authenticateUser(adminUserModel).withCoreAPI() + .usingSite(siteModel).updateSiteMember(testUser); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedMember.assertThat().field("id").is(testUser.getUsername()).and().field("role").is(testUser.getUserRole()); + } +} From 13040d0662328a1fa0746f950a2f7543c8564169 Mon Sep 17 00:00:00 2001 From: cagache Date: Tue, 31 Jan 2017 15:33:16 +0200 Subject: [PATCH 0953/1491] TAS - 2892 removeDeployment --- .../DeleteDeploymentSanityTests.java | 50 +++++++++++++++++-- .../deployments/GetDeploymentFullTests.java | 21 -------- 2 files changed, 45 insertions(+), 26 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java index 0d7def475..0d44ff30e 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java @@ -1,9 +1,8 @@ package org.alfresco.rest.workflow.deployments; +import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestDeploymentModel; -import org.alfresco.rest.model.RestDeploymentModelsCollection; -import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.*; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; @@ -13,6 +12,8 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import java.util.List; + /** * Tests for REST API call DELETE "/deployments/{deploymentId}" * Class has priority 100 in order to be executed last in the list of tests classes @@ -33,8 +34,8 @@ public class DeleteDeploymentSanityTests extends RestTest @Bug(id = "MNT-16996") @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, - executionType = ExecutionType.SANITY, description = "Verify admin user deletes a specific deployment using REST API and status code is successful (204)") - @Test(groups = { TestGroup.REST_API, TestGroup.DEPLOYMENTS, TestGroup.SANITY, TestGroup.WORKFLOW }, priority = 100) + executionType = ExecutionType.REGRESSION, description = "Verify admin user deletes a specific deployment using REST API and status code is successful (204)") + @Test(groups = { TestGroup.REST_API, TestGroup.DEPLOYMENTS, TestGroup.FULL, TestGroup.WORKFLOW }, priority = 100) public void adminDeletesDeploymentWithSuccess() throws Exception { dataContent.assertExtensionAmpExists("alfresco-workflow-extension"); @@ -43,8 +44,47 @@ public class DeleteDeploymentSanityTests extends RestTest allDeployments.assertThat().entriesListContains("name", "customWorkflowExtentionForRest.bpmn"); deployment = allDeployments.getDeploymentByName("customWorkflowExtentionForRest.bpmn"); + RestProcessDefinitionModel processDefinitionAssociated = + restClient.withWorkflowAPI().getAllProcessDefinitions().getProcessDefinitionByDeploymentId(deployment.getId()); + + RestProcessModel addedProcess = + restClient.withWorkflowAPI().addProcess(processDefinitionAssociated.getName(), adminUser, false, CMISUtil.Priority.Normal); + + List processTasks = + restClient.withWorkflowAPI().usingProcess(addedProcess).getProcessTasks().getEntries(); + restClient.withWorkflowAPI().usingDeployment(deployment).deleteDeployment(); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + //check get deployment returns http status Not Found after deleting the deployment + restClient.withWorkflowAPI().usingDeployment(deployment).getDeployment(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, deployment.getId())); + + //check that process definitions contained by deployment are deleted + restClient.withWorkflowAPI().usingProcessDefinitions(processDefinitionAssociated).getProcessDefinition(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, processDefinitionAssociated.getId())); + + //check that history information associated with the deployment is deleted + restClient.withWorkflowAPI().usingProcess(addedProcess).getProcess(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, addedProcess.getId())); + + for (RestTaskModel processTask: processTasks) + { + restClient.withWorkflowAPI().usingTask(processTask).getTask(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, processTask.getId())); + } + + //delete deployment twice + restClient.withWorkflowAPI().usingDeployment(deployment).deleteDeployment(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, deployment.getId())) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); } @Bug(id = "MNT-16996") diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentFullTests.java index cb2c38466..335e0f3ad 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentFullTests.java @@ -57,27 +57,6 @@ public class GetDeploymentFullTests extends RestTest .field("name").is(expectedDeployment.getName()); } - - @Bug(id = "MNT-16996") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, - executionType = ExecutionType.REGRESSION, description = "Verify admin user deletes a specific deployment using REST API and status code is successful (204)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.FULL}, priority = 100) - public void deleteDeploymentThenGet() throws Exception - { - dataContent.assertExtensionAmpExists("alfresco-workflow-extension"); - // The deployment with name "customWorkflowExtentionForRest.bpmn" is created by Workflow Extention Point - RestDeploymentModelsCollection allDeployments = restClient.authenticateUser(adminUser).withWorkflowAPI().getDeployments(); - allDeployments.assertThat().entriesListContains("name", "customWorkflowExtentionForRest.bpmn"); - expectedDeployment = allDeployments.getDeploymentByName("customWorkflowExtentionForRest.bpmn"); - - restClient.withWorkflowAPI().usingDeployment(expectedDeployment).deleteDeployment(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withWorkflowAPI().usingDeployment(expectedDeployment).getDeployment(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, expectedDeployment.getId())); - } - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify that network admin user is not able to get a deployment from other network using REST API and status code is OK (200)") From a5e2bcdb330b5bcb32ff1a0b0a5247d04683b23b Mon Sep 17 00:00:00 2001 From: cagache Date: Tue, 31 Jan 2017 15:34:06 +0200 Subject: [PATCH 0954/1491] TAS - 2892 removeDeployment --- .../workflow/deployments/DeleteDeploymentSanityTests.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java index 0d44ff30e..f2af443f3 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java @@ -34,8 +34,8 @@ public class DeleteDeploymentSanityTests extends RestTest @Bug(id = "MNT-16996") @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, - executionType = ExecutionType.REGRESSION, description = "Verify admin user deletes a specific deployment using REST API and status code is successful (204)") - @Test(groups = { TestGroup.REST_API, TestGroup.DEPLOYMENTS, TestGroup.FULL, TestGroup.WORKFLOW }, priority = 100) + executionType = ExecutionType.SANITY, description = "Verify admin user deletes a specific deployment using REST API and status code is successful (204)") + @Test(groups = { TestGroup.REST_API, TestGroup.DEPLOYMENTS, TestGroup.SANITY, TestGroup.WORKFLOW }, priority = 100) public void adminDeletesDeploymentWithSuccess() throws Exception { dataContent.assertExtensionAmpExists("alfresco-workflow-extension"); From d3d3dca04eab459b4ad65f4bd4c749594490c5e7 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Tue, 31 Jan 2017 15:47:56 +0200 Subject: [PATCH 0955/1491] added full tests for getProcesses and refactoring --- .../rest/sites/GetSiteMembersFullTests.java | 2 +- .../GetProcessDefinitionsCoreTests.java | 4 +- .../GetProcessVariablesCoreTests.java | 1 - .../processes/GetProcessesFullTests.java | 166 ++++++++++++++++++ 4 files changed, 169 insertions(+), 4 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersFullTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersFullTests.java index eb0085252..7c91d7c7d 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersFullTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersFullTests.java @@ -50,7 +50,7 @@ public class GetSiteMembersFullTests extends RestTest firstSiteMember = siteMembers.getEntries().get(0).onModel(); secondSiteMember = siteMembers.getEntries().get(1).onModel(); thirdSiteMember = siteMembers.getEntries().get(2).onModel(); - fourthSiteMember = siteMembers.getEntries().get(2).onModel(); + fourthSiteMember = siteMembers.getEntries().get(3).onModel(); } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsCoreTests.java index 750feacb7..a16497513 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsCoreTests.java @@ -62,7 +62,7 @@ public class GetProcessDefinitionsCoreTests extends RestTest .getAllProcessDefinitions() .assertThat().entriesListIsEmpty(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.PROCESS_DEFINITIONS_INVALID_ORDERBY, "test")); + .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_ORDERBY, "test", "deploymentId, name, id, category, version, key")); } @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, @@ -76,6 +76,6 @@ public class GetProcessDefinitionsCoreTests extends RestTest .getAllProcessDefinitions() .assertThat().entriesListIsEmpty(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.PROCESS_DEFINITIONS_INVALID_WHERE, "test")); + .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_WHERE_QUERY, "test")); } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesCoreTests.java index 1483bab99..e46dc791e 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesCoreTests.java @@ -13,7 +13,6 @@ import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.apache.commons.lang.RandomStringUtils; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesFullTests.java new file mode 100644 index 000000000..799fb5f39 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesFullTests.java @@ -0,0 +1,166 @@ +package org.alfresco.rest.workflow.processes; + +import java.util.List; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.dataprep.CMISUtil.Priority; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestProcessModelsCollection; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.ProcessModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TaskModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * + * @author Cristina Axinte + * + */ +public class GetProcessesFullTests extends RestTest +{ + private FileModel document; + private SiteModel siteModel; + private UserModel adminUser, userWhoStartsTask, assignee; + private TaskModel task1, task2; + private ProcessModel process3; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userWhoStartsTask = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + task1 = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); + task2 = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(adminUser); + process3 = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createSingleReviewerTaskAndAssignTo(assignee); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify any user cannot get processes from same network") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL, TestGroup.NETWORKS }) + public void getProcessFromSameNetworkUsingAnyUser() throws Exception + { + UserModel adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser); + UserModel tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + UserModel tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); + restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee, false, Priority.Normal); + + UserModel otherTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("otherTenant"); + RestProcessModelsCollection tenantProcesses = restClient.authenticateUser(otherTenantUser).withWorkflowAPI().getProcesses(); + restClient.assertStatusCodeIs(HttpStatus.OK); + tenantProcesses.assertThat().entriesListIsEmpty().and().paginationField("count").is("0"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify user gets processes when skipCount parameter is applied") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void getProcessesWithSkipCountParameter() throws Exception + { + RestProcessModelsCollection processes = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getProcesses(); + restClient.assertStatusCodeIs(HttpStatus.OK); + processes.assertThat().paginationField("count").is("3"); + RestProcessModel process1 = processes.getEntries().get(0).onModel(); + RestProcessModel process2 = processes.getEntries().get(1).onModel(); + RestProcessModel process3 = processes.getEntries().get(2).onModel(); + + processes = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingParams("skipCount=2").getProcesses(); + restClient.assertStatusCodeIs(HttpStatus.OK); + processes.assertThat().paginationField("count").is("1"); + processes.assertThat().paginationField("skipCount").is("2"); + processes.assertThat().entriesListDoesNotContain("id", process1.getId()); + processes.assertThat().entriesListDoesNotContain("id", process2.getId()); + processes.getEntries().get(0).onModel().assertThat().field("id").is(process3.getId()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify user gets processes when maxItems parameter is applied") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void getProcessesWithMaxItemsParameter() throws Exception + { + RestProcessModelsCollection processes = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getProcesses(); + restClient.assertStatusCodeIs(HttpStatus.OK); + processes.assertThat().paginationField("count").is("3"); + RestProcessModel process1 = processes.getEntries().get(0).onModel(); + RestProcessModel process2 = processes.getEntries().get(1).onModel(); + RestProcessModel process3 = processes.getEntries().get(2).onModel(); + + processes = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingParams("maxItems=2").getProcesses(); + restClient.assertStatusCodeIs(HttpStatus.OK); + processes.assertThat().paginationField("count").is("2"); + processes.assertThat().paginationField("maxItems").is("2"); + processes.assertThat().entriesListDoesNotContain("id", process3.getId()); + processes.getEntries().get(0).onModel().assertThat().field("id").is(process1.getId()); + processes.getEntries().get(1).onModel().assertThat().field("id").is(process2.getId()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify user gets processes when properties parameter is applied") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void getProcessesWithPropertiesParameter() throws Exception + { + RestProcessModelsCollection processes = restClient.authenticateUser(userWhoStartsTask).withParams("properties=id") + .withWorkflowAPI().getProcesses(); + restClient.assertStatusCodeIs(HttpStatus.OK); + processes.assertThat().entriesListIsNotEmpty(); + List processesList = processes.getEntries(); + processesList.get(0).onModel().assertThat().fieldsCount().is(1).and().field("id").is(process3.getId()); + processesList.get(1).onModel().assertThat().fieldsCount().is(1).and().field("id").is(task2.getNodeRef()); + processesList.get(2).onModel().assertThat().fieldsCount().is(1).and().field("id").is(task1.getNodeRef()); + } + + @Bug(id = "REPO-1958") + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify user cannot get processes when using an invalid orderBy parameter") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void getProcessesWithInvalidOrderByParameter() throws Exception + { + restClient.authenticateUser(userWhoStartsTask).withParams("orderBy=test") + .withWorkflowAPI().getProcesses(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(String.format(RestErrorModel.INVALID_ORDERBY, "test", "processDefinitionId, startUserId, startActivityId,startedAt, id, completed, processDefinitionKey")) + .containsSummary(String.format(RestErrorModel.INVALID_ORDERBY, "test", "processDefinitionId, startUserId, startActivityId,startedAt, id, completed, processDefinitionKey")) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify user cannot get processes when using an invalid parameter in where clause") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void getProcessesWithInvalidWhereParameter() throws Exception + { + restClient.authenticateUser(userWhoStartsTask).where("startUserIdd='" + userWhoStartsTask.getUsername() + "'") + .withWorkflowAPI().getProcesses(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(RestErrorModel.INVALID_PROPERTY_ERRORKEY) + .containsSummary(String.format(RestErrorModel.PROPERTY_IS_NOT_SUPPORTED_EQUALS, "startUserIdd", userWhoStartsTask.getUsername())) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify user cannot get processes when using an invalid where clause expression") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void getProcessesWithInvalidWhereClauseExpression() throws Exception + { + restClient.authenticateUser(userWhoStartsTask).where("startUserId AND '" + userWhoStartsTask.getUsername() + "'") + .withWorkflowAPI().getProcesses(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(RestErrorModel.INVALID_QUERY_ERRORKEY) + .containsSummary(String.format(RestErrorModel.INVALID_WHERE_QUERY, "(startUserId AND '" + userWhoStartsTask.getUsername() + "')")) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } +} From 68547c249f5ecf0d38dc24b10be2d69946bb04ec Mon Sep 17 00:00:00 2001 From: Andrei Rusu Date: Tue, 31 Jan 2017 16:40:26 +0200 Subject: [PATCH 0956/1491] added tests for GetTagsFullTests --- .../alfresco/rest/tags/GetTagsFullTests.java | 141 ++++++++++++++++++ 1 file changed, 141 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/tags/GetTagsFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/tags/GetTagsFullTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagsFullTests.java new file mode 100644 index 000000000..eb7c98243 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/tags/GetTagsFullTests.java @@ -0,0 +1,141 @@ +package org.alfresco.rest.tags; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestTagModel; +import org.alfresco.rest.model.RestTagModelsCollection; +import org.alfresco.utility.Utility; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.RandomData; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class GetTagsFullTests extends RestTest +{ + private UserModel adminUserModel; + private SiteModel siteModel; + private ListUserWithRoles usersWithRoles; + private RestTagModelsCollection returnedCollection; + + private String tagValue, tagValue2; + private FileModel document; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + restClient.authenticateUser(adminUserModel); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + document = dataContent.usingUser(adminUserModel).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + + tagValue = RandomData.getRandomName("tag"); + tagValue2 = RandomData.getRandomName("tag"); + restClient.withCoreAPI().usingResource(document).addTags(tagValue, tagValue2); + + Utility.waitToLoopTime(20); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify site Manager is able to get tags using properties parameter." + + "Check that properties filter is applied.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) + public void siteManagerIsAbleToRetrieveTagsWithPropertiesParameter() throws JsonToModelConversionException, Exception + { + returnedCollection = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withParams("maxItems=5000&properties=tag").withCoreAPI().getTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat().entriesListIsNotEmpty() + .and().entriesListContains("tag", tagValue.toLowerCase()) + .and().entriesListContains("tag", tagValue2.toLowerCase()) + .and().entriesListDoesNotContain("id"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "With admin get tags and use skipCount parameter. Check pagination") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) + public void useSkipCountCheckPagination() throws JsonToModelConversionException, Exception + { + returnedCollection = restClient.authenticateUser(adminUserModel) + .withParams("skipCount=20").withCoreAPI().getTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.getPagination().assertThat().field("maxItems").is(100) + .and().field("hasMoreItems").is("true") + .and().field("count").is("100") + .and().field("skipCount").is(20) + .and().field("totalItems").isNull(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "With admin get tags and use maxItems parameter. Check pagination") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) + public void useMaxItemsParameterCheckPagination() throws JsonToModelConversionException, Exception + { + returnedCollection = restClient.authenticateUser(adminUserModel) + .withParams("maxItems=50").withCoreAPI().getTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.getPagination().assertThat().field("maxItems").is(50) + .and().field("hasMoreItems").is("true") + .and().field("count").is("50") + .and().field("skipCount").is("0") + .and().field("totalItems").isNull(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "With manager get tags and use high skipCount parameter. Check pagination") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) + public void useHighSkipCountCheckPagination() throws JsonToModelConversionException, Exception + { + returnedCollection = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withParams("skipCount=20000").withCoreAPI().getTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat().entriesListIsEmpty() + .getPagination().assertThat().field("maxItems").is(100) + .and().field("hasMoreItems").is("false") + .and().field("count").is("0") + .and().field("skipCount").is(20000) + .and().field("totalItems").isNull(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "With Collaborator user get tags and use maxItems with value zero. Check default error model schema") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) + public void useMaxItemsWithValueZeroCheckDefaultErrorModelSchema() throws JsonToModelConversionException, Exception + { + returnedCollection = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withParams("maxItems=0").withCoreAPI().getTags(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) + .containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "With Manager user delete tag. Check it is not retrieved anymore.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) + public void checkThatDeletedTagIsNotRetrievedAnymore() throws JsonToModelConversionException, Exception + { + String removedTag = RandomData.getRandomName("tag3"); + + RestTagModel deletedTag = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(document).addTag(removedTag); + + restClient.withCoreAPI().usingResource(document).deleteTag(deletedTag); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + returnedCollection = restClient.withParams("maxItems=5000").withCoreAPI().getTags(); + returnedCollection.assertThat().entriesListIsNotEmpty() + .and().entriesListDoesNotContain("tag", removedTag.toLowerCase()); + } +} From 2c8a67027136f0391339ca24313e28dbd3daa6a0 Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 1 Feb 2017 10:20:48 +0200 Subject: [PATCH 0957/1491] TAS - 2896 getProcessDefinitionStartFormModel --- .../DeleteDeploymentSanityTests.java | 10 ++ ...cessDefinitionStartFormModelCoreTests.java | 13 ++- ...cessDefinitionStartFormModelFullTests.java | 93 +++++++++++++++++++ ...ssDefinitionStartFormModelSanityTests.java | 4 +- 4 files changed, 113 insertions(+), 7 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java index f2af443f3..7fcd6da35 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java @@ -78,6 +78,16 @@ public class DeleteDeploymentSanityTests extends RestTest .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, processTask.getId())); } + //check getProcessDefinitionStartFormModel after deletion of process definition + restClient.withWorkflowAPI().usingProcessDefinitions(processDefinitionAssociated).getProcessDefinitionStartFormModel(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, processDefinitionAssociated.getId())); + + //check getProcessDefinitionImage after deletion of process definition + restClient.withWorkflowAPI().usingProcessDefinitions(processDefinitionAssociated).getProcessDefinitionImage(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, processDefinitionAssociated.getId())); + //delete deployment twice restClient.withWorkflowAPI().usingDeployment(deployment).deleteDeployment(); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java index 6ddc232cc..71997998b 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java @@ -36,7 +36,7 @@ public class GetProcessDefinitionStartFormModelCoreTests extends RestTest public void nonNetworkUserGetsStartFormModel() throws Exception { UserModel nonNetworkUser = dataUser.createRandomTestUser(); - randomProcessDefinition = allProcessDefinitions.getOneRandomEntry(); + randomProcessDefinition = allProcessDefinitions.getOneRandomEntry().onModel(); restClient.authenticateUser(nonNetworkUser).withWorkflowAPI() .usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionStartFormModel() .assertThat().entriesListIsNotEmpty(); @@ -50,13 +50,16 @@ public class GetProcessDefinitionStartFormModelCoreTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.CORE }) public void getStartFormModelUsingInvalidProcessDefinitionId() throws Exception { - randomProcessDefinition = allProcessDefinitions.getOneRandomEntry(); + randomProcessDefinition = allProcessDefinitions.getOneRandomEntry().onModel(); randomProcessDefinition.onModel().setId("invalidID"); restClient.authenticateUser(adminUser).withWorkflowAPI() .usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionStartFormModel(); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidID")); + .assertLastError().containsSummary(String.format("no deployed process definition found with id '%s'", "invalidID")) + .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); } @Bug(id = "ALF-20187") @@ -66,7 +69,7 @@ public class GetProcessDefinitionStartFormModelCoreTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.CORE }) public void getStartFormModelUsingEmptyProcessDefinitionId() throws Exception { - randomProcessDefinition = allProcessDefinitions.getOneRandomEntry(); + randomProcessDefinition = allProcessDefinitions.getOneRandomEntry().onModel(); randomProcessDefinition.onModel().setId(""); restClient.authenticateUser(adminUser).withWorkflowAPI() @@ -86,7 +89,7 @@ public class GetProcessDefinitionStartFormModelCoreTests extends RestTest .usingTenant().createTenant(adminTenantUser); UserModel tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); randomProcessDefinition = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() - .getAllProcessDefinitions().getOneRandomEntry(); + .getAllProcessDefinitions().getOneRandomEntry().onModel(); restClient.authenticateUser(tenantUser).withWorkflowAPI() .usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionStartFormModel() .assertThat().entriesListIsNotEmpty(); diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelFullTests.java new file mode 100644 index 000000000..c80a5b704 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelFullTests.java @@ -0,0 +1,93 @@ +package org.alfresco.rest.workflow.processDefinitions; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestFormModelsCollection; +import org.alfresco.rest.model.RestProcessDefinitionModel; +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; + +import java.util.Arrays; + +/** + * Created by Claudia Agache on 1/31/2017. + */ +public class GetProcessDefinitionStartFormModelFullTests extends RestTest +{ + private UserModel adminUser; + private RestProcessDefinitionModel activitiAdhoc; + private RestFormModelsCollection returnedResponse; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + activitiAdhoc = restClient.authenticateUser(adminUser).withWorkflowAPI().getAllProcessDefinitions().getProcessDefinitionByDeploymentId("1"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, + executionType = ExecutionType.REGRESSION, + description = "Verify admin gets a model of the start form type definition for specific process definition using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.FULL }) + public void adminGetsStartFormModelForActivitiAdhocProcessDefinition() throws Exception + { + returnedResponse = restClient.authenticateUser(adminUser).withWorkflowAPI() + .usingProcessDefinitions(activitiAdhoc).getProcessDefinitionStartFormModel(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedResponse.assertThat().entriesListContains("qualifiedName", "{http://www.alfresco.org/model/bpm/1.0}workflowPriority"); + returnedResponse.getStartFormModelByQualifiedName("{http://www.alfresco.org/model/bpm/1.0}workflowPriority") + .assertThat().field("defaultValue").is("2") + .and().field("dataType").is("d:int") + .and().field("name").is("bpm_workflowPriority") + .and().field("title").is("Workflow Priority") + .and().field("required").is("false") + .and().field("allowedValues").is(Arrays.asList("1", "2", "3")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, + executionType = ExecutionType.REGRESSION, + description = "Verify admin gets a model of the start form type definition with properties parameter applied using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.FULL }) + public void adminGetsStartFormModelWithPropertiesParameterApplied() throws Exception + { + returnedResponse = restClient.authenticateUser(adminUser).withParams("properties=qualifiedName,dataType,title").withWorkflowAPI() + .usingProcessDefinitions(activitiAdhoc).getProcessDefinitionStartFormModel(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedResponse.assertThat().entriesListContains("qualifiedName", "{http://www.alfresco.org/model/bpm/1.0}workflowPriority"); + returnedResponse.getStartFormModelByQualifiedName("{http://www.alfresco.org/model/bpm/1.0}workflowPriority") + .assertThat().fieldsCount().is(3) + .and().field("qualifiedName").is("{http://www.alfresco.org/model/bpm/1.0}workflowPriority") + .and().field("defaultValue").isNull() + .and().field("dataType").is("d:int") + .and().field("name").isNull() + .and().field("title").is("Workflow Priority") + .and().field("required").isNull() + .and().field("allowedValues").isNull(); + } + + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, + executionType = ExecutionType.REGRESSION, + description = "Verify Tenant User doesn't get a model of the start form type definition for another network deployment using REST API") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.FULL, TestGroup.NETWORKS }) + public void networkUserIsNotAbleToGetStartFormModelForAnotherNetwork() throws Exception + { + UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); + UserModel adminTenantUser2 = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser1); + restClient.usingTenant().createTenant(adminTenantUser2); + + RestProcessDefinitionModel randomProcessDefinition = restClient.authenticateUser(adminTenantUser1).withWorkflowAPI() + .getAllProcessDefinitions().getOneRandomEntry().onModel(); + restClient.authenticateUser(adminTenantUser2).withWorkflowAPI() + .usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionStartFormModel(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, randomProcessDefinition.getId())); + } + +} diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java index 7603af737..0eb010e8c 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java @@ -32,7 +32,7 @@ public class GetProcessDefinitionStartFormModelSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY }) public void nonNetworkAdminGetsStartFormModel() throws Exception { - randomProcessDefinition = restClient.withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry(); + randomProcessDefinition = restClient.withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry().onModel(); restClient.withWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionStartFormModel().assertThat().entriesListIsNotEmpty(); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -45,7 +45,7 @@ public class GetProcessDefinitionStartFormModelSanityTests extends RestTest { restClient.usingTenant().createTenant(adminTenantUser); restClient.authenticateUser(adminTenantUser); - randomProcessDefinition = restClient.withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry(); + randomProcessDefinition = restClient.withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry().onModel(); restClient.withWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionStartFormModel().assertThat().entriesListIsNotEmpty(); restClient.assertStatusCodeIs(HttpStatus.OK); } From aa78a61d47c29f3b4202a22d95afc80a6455b535 Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 1 Feb 2017 10:35:24 +0200 Subject: [PATCH 0958/1491] TAS - 2896 getProcessDefinitionStartFormModel --- .../GetProcessDefinitionStartFormModelCoreTests.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java index 71997998b..b1d7a4642 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java @@ -51,7 +51,7 @@ public class GetProcessDefinitionStartFormModelCoreTests extends RestTest public void getStartFormModelUsingInvalidProcessDefinitionId() throws Exception { randomProcessDefinition = allProcessDefinitions.getOneRandomEntry().onModel(); - randomProcessDefinition.onModel().setId("invalidID"); + randomProcessDefinition.setId("invalidID"); restClient.authenticateUser(adminUser).withWorkflowAPI() .usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionStartFormModel(); @@ -70,12 +70,12 @@ public class GetProcessDefinitionStartFormModelCoreTests extends RestTest public void getStartFormModelUsingEmptyProcessDefinitionId() throws Exception { randomProcessDefinition = allProcessDefinitions.getOneRandomEntry().onModel(); - randomProcessDefinition.onModel().setId(""); + randomProcessDefinition.setId(""); restClient.authenticateUser(adminUser).withWorkflowAPI() .usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionStartFormModel(); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); + .assertLastError().containsSummary("no deployed process definition found with id ''"); } @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, From 3c8c8a8f0ea5396cc14a4a1214a44e72069dbe6a Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 1 Feb 2017 12:17:28 +0200 Subject: [PATCH 0959/1491] TAS - 2895 getProcessDefinitionImage --- .../GetProcessDefinitionImageCoreTests.java | 5 +- .../GetProcessDefinitionImageFullTests.java | 62 +++++++++++++++++++ 2 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageCoreTests.java index 790311f74..a3eb00c04 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageCoreTests.java @@ -38,7 +38,10 @@ public class GetProcessDefinitionImageCoreTests extends RestTest restClient.withWorkflowAPI() .usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionImage(); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidID")); + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidID")) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); } @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageFullTests.java new file mode 100644 index 000000000..009284b61 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageFullTests.java @@ -0,0 +1,62 @@ +package org.alfresco.rest.workflow.processDefinitions; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestProcessDefinitionModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Created by Claudia Agache on 2/1/2017. + */ +public class GetProcessDefinitionImageFullTests extends RestTest +{ + private UserModel adminUser; + private RestProcessDefinitionModel randomProcessDefinition; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + } + + @Bug(id = "REPO-1911") + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, + executionType = ExecutionType.REGRESSION, + description = "Verify if get process definition image returns status code 404 when empty processDefinitionId is used") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.CORE }) + public void getProcessDefinitionImageUsingEmptyProcessDefinitionId() throws Exception + { + restClient.authenticateUser(adminUser); + randomProcessDefinition = restClient.withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry(); + randomProcessDefinition.onModel().setId(""); + restClient.withWorkflowAPI() + .usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionImage(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, + executionType = ExecutionType.REGRESSION, + description = "Verify Tenant User doesn't get process definition image for another network deployment using REST API") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.FULL, TestGroup.NETWORKS }) + public void networkUserIsNotAbleToGetProcessDefinitionImageForAnotherNetwork() throws Exception + { + UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); + UserModel adminTenantUser2 = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser1); + restClient.usingTenant().createTenant(adminTenantUser2); + + RestProcessDefinitionModel randomProcessDefinition = restClient.authenticateUser(adminTenantUser1).withWorkflowAPI() + .getAllProcessDefinitions().getOneRandomEntry(); + restClient.authenticateUser(adminTenantUser2).withWorkflowAPI() + .usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionImage(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, randomProcessDefinition.onModel().getId())); + } +} From 1e2876d701a3a227694cc16f9fec33a8571e3805 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Wed, 1 Feb 2017 12:43:39 +0200 Subject: [PATCH 0960/1491] added full tests for addProcess --- .../processes/AddProcessFullTests.java | 194 ++++++++++++++++++ 1 file changed, 194 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessFullTests.java new file mode 100644 index 000000000..48154377f --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessFullTests.java @@ -0,0 +1,194 @@ +package org.alfresco.rest.workflow.processes; + +import javax.json.JsonObject; + +import org.alfresco.dataprep.CMISUtil.Priority; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.JsonBodyGenerator; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestProcessDefinitionModel; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * + * @author Cristina Axinte + * + */ +public class AddProcessFullTests extends RestTest +{ + private UserModel userWhoStartsProcess, assignee; + RestProcessModel addedProcess; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + assignee = dataUser.createRandomTestUser(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify network user cannot start new process with processDefinitionKey from another network using REST API and status code is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL, TestGroup.NETWORKS}) + public void networkUserCannotStartNewProcessWithProcessDefinitionFromAnotherNetwork() throws JsonToModelConversionException, Exception + { + UserModel adminTenant1 = UserModel.getAdminTenantUser(); + restClient.authenticateUser(dataUser.getAdminUser()).usingTenant().createTenant(adminTenant1); + RestProcessDefinitionModel firstProcessDefTenant1 = restClient.authenticateUser(adminTenant1).withWorkflowAPI().getAllProcessDefinitions().getEntries().get(0).onModel(); + + UserModel adminTenant2 = UserModel.getAdminTenantUser(); + restClient.authenticateUser(dataUser.getAdminUser()).usingTenant().createTenant(adminTenant2); + UserModel assigneeTenant2 = dataUser.usingUser(adminTenant2).createUserWithTenant("assigneeT2"); + + String processDefinitionKey = firstProcessDefTenant1.getId().substring(0,firstProcessDefTenant1.getId().indexOf(":")); + addedProcess = restClient.authenticateUser(adminTenant2).withWorkflowAPI().addProcess(processDefinitionKey, assigneeTenant2, false, Priority.Normal); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(String.format(RestErrorModel.NO_WORKFLOW_DEFINITION_FOUND, processDefinitionKey)) + .containsSummary(String.format(RestErrorModel.NO_WORKFLOW_DEFINITION_FOUND, processDefinitionKey)) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify network user can start new process with processDefinitionKey from same network using REST API and status code is 201") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL, TestGroup.NETWORKS}) + public void networkUserCanStartNewProcessWithProcessDefinitionFromSameNetwork() throws JsonToModelConversionException, Exception + { + UserModel adminTenant1 = UserModel.getAdminTenantUser(); + restClient.authenticateUser(dataUser.getAdminUser()).usingTenant().createTenant(adminTenant1); + RestProcessDefinitionModel firstProcessDefTenant1 = restClient.authenticateUser(adminTenant1).withWorkflowAPI().getAllProcessDefinitions().getEntries().get(0).onModel(); + + UserModel processStarterTenant1 = dataUser.usingUser(adminTenant1).createUserWithTenant("startert1"); + UserModel assigneeTenant1 = dataUser.usingUser(adminTenant1).createUserWithTenant("assigneet1"); + + + String processDefinitionKey = firstProcessDefTenant1.getKey(); + addedProcess = restClient.authenticateUser(processStarterTenant1).withWorkflowAPI().addProcess(processDefinitionKey, assigneeTenant1, false, Priority.Normal); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + addedProcess.assertThat().field("processDefinitionId").is(firstProcessDefTenant1.getId()) + .and().field("startUserId").is(processStarterTenant1.getEmailAddress().toLowerCase()) + .and().field("processDefinitionKey").is(processDefinitionKey); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify user cannot start new process with invalid processDefinitionKey using REST API and status code is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void userStartsNewProcessWithInvalidProcessDefinitionKey() throws JsonToModelConversionException, Exception + { + userWhoStartsProcess = dataUser.createRandomTestUser(); + + addedProcess = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcess("activitiAdhocc", assignee, false, Priority.Normal); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(String.format(RestErrorModel.NO_WORKFLOW_DEFINITION_FOUND, "activitiAdhocc")) + .containsSummary(String.format(RestErrorModel.NO_WORKFLOW_DEFINITION_FOUND, "activitiAdhocc")) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } + + @Bug(id = "REPO-1970") + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify user cannot start new process with invalid processDefinitionKey using REST API and status code is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void userStartsNewProcessWithEmptyVariablesBody() throws JsonToModelConversionException, Exception + { + userWhoStartsProcess = dataUser.createRandomTestUser(); + + JsonObject postJson = JsonBodyGenerator.defineJSON() + .add("processDefinitionKey", "activitiAdhoc") + .add("variables", + JsonBodyGenerator.defineJSON().build() + ).build(); + addedProcess = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcessWithBody(postJson); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(String.format(RestErrorModel.NO_WORKFLOW_DEFINITION_FOUND, "activitiAdhoc")); + } + + @Bug(id = "REPO-1970") + @TestRail(section = { TestGroup.REST_API,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify user cannot start new process with invalid processDefinitionKey using REST API and status code is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void userStartsNewProcessWithNoAssigneeInVariablesBody() throws JsonToModelConversionException, Exception + { + userWhoStartsProcess = dataUser.createRandomTestUser(); + + JsonObject postJson = JsonBodyGenerator.defineJSON() + .add("processDefinitionKey", "activitiAdhoc") + .add("variables", + JsonBodyGenerator.defineJSON() + .add("bpm_sendEMailNotifications", false) + .add("bpm_workflowPriority", Priority.Low.getLevel()).build() + ).build(); + addedProcess = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcessWithBody(postJson); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(String.format(RestErrorModel.NO_WORKFLOW_DEFINITION_FOUND, "activitiAdhoc")); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify user cannot start new process with invalid assignee using REST API and status code is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void userStartsNewProcessWithInvalidAssignee() throws JsonToModelConversionException, Exception + { + userWhoStartsProcess = dataUser.createRandomTestUser(); + UserModel invalidAssignee = new UserModel("invalidAssignee", "password"); + + addedProcess = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcess("activitiAdhoc", invalidAssignee, false, Priority.Normal); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(String.format(RestErrorModel.INVALID_USER_ID, invalidAssignee.getUsername())) + .containsSummary(String.format(RestErrorModel.INVALID_USER_ID, invalidAssignee.getUsername())) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } + + @Bug(id = "REPO-1970") + @TestRail(section = { TestGroup.REST_API,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify user cannot start new process with invalid sendEMailNotifications value using REST API and status code is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void userStartsNewProcessWithInvalidEmailNotification() throws JsonToModelConversionException, Exception + { + userWhoStartsProcess = dataUser.createRandomTestUser(); + JsonObject postJson = JsonBodyGenerator.defineJSON() + .add("processDefinitionKey", "activitiAdhoc") + .add("variables", + JsonBodyGenerator.defineJSON() + .add("bpm_assignee", assignee.getUsername()) + .add("bpm_sendEMailNotifications", "111") + .add("bpm_workflowPriority", Priority.Low.getLevel()).build() + ).build(); + + addedProcess = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcessWithBody(postJson); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(String.format(RestErrorModel.UNSUPPORTED_TYPE, "111")) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } + + @Bug(id = "REPO-1970") + @TestRail(section = { TestGroup.REST_API,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify user cannot start new process with invalid priority using REST API and status code is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void userStartsNewProcessWithInvalidPriority() throws JsonToModelConversionException, Exception + { + userWhoStartsProcess = dataUser.createRandomTestUser(); + JsonObject postJson = JsonBodyGenerator.defineJSON() + .add("processDefinitionKey", "activitiAdhoc") + .add("variables", + JsonBodyGenerator.defineJSON() + .add("bpm_assignee", assignee.getUsername()) + .add("bpm_sendEMailNotifications", false) + .add("bpm_workflowPriority", "test").build() + ).build(); + + addedProcess = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcessWithBody(postJson); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(String.format(RestErrorModel.UNSUPPORTED_TYPE, "test")) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } +} From ff40ade01d136306b929c83cc42b8f2b508ee0ef Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 1 Feb 2017 16:04:14 +0200 Subject: [PATCH 0961/1491] TAS - 2894 getProcessDefinitions --- .../deployments/GetDeploymentsFullTests.java | 4 +- .../GetProcessDefinitionsCoreTests.java | 22 +- .../GetProcessDefinitionsFullTests.java | 193 ++++++++++++++++++ .../GetProcessDefinitionsSanityTests.java | 3 - .../workflow/tasks/GetTasksCoreTests.java | 3 +- 5 files changed, 215 insertions(+), 10 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsFullTests.java index 6080faa3b..d6ab2eaec 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsFullTests.java @@ -35,8 +35,8 @@ public class GetDeploymentsFullTests extends RestTest { deployments = restClient.withWorkflowAPI().getDeployments(); restClient.assertStatusCodeIs(HttpStatus.OK); - RestDeploymentModel firstDeployment = deployments.getEntries().get(0); - RestDeploymentModel secondDeployment = deployments.getEntries().get(1); + RestDeploymentModel firstDeployment = deployments.getEntries().get(0).onModel(); + RestDeploymentModel secondDeployment = deployments.getEntries().get(1).onModel(); RestDeploymentModelsCollection deploymentsWithSkipCount = restClient.withParams("skipCount=2").withWorkflowAPI().getDeployments(); restClient.assertStatusCodeIs(HttpStatus.OK); deploymentsWithSkipCount diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsCoreTests.java index a16497513..cb127190b 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsCoreTests.java @@ -2,6 +2,7 @@ package org.alfresco.rest.workflow.processDefinitions; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestProcessDefinitionModelsCollection; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; @@ -30,11 +31,21 @@ public class GetProcessDefinitionsCoreTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.CORE }) public void nonNetworkUserGetsProcessDefinitions() throws Exception { - restClient.authenticateUser(userModel) + RestProcessDefinitionModelsCollection processDefinitions = restClient.authenticateUser(userModel) .withWorkflowAPI() - .getAllProcessDefinitions() - .assertThat().entriesListIsNotEmpty(); + .getAllProcessDefinitions(); restClient.assertStatusCodeIs(HttpStatus.OK); + processDefinitions.assertThat().entriesListIsNotEmpty(); + processDefinitions.getProcessDefinitionByDeploymentId("1").assertThat() + .field("name").is("Adhoc Activiti Process").and() + .field("description").is("Assign a new task to yourself or a colleague").and() + .field("id").is("activitiAdhoc:1:4").and() + .field("startFormResourceKey").is("wf:submitAdhocTask").and() + .field("category").is("http://alfresco.org").and() + .field("title").is("New Task").and() + .field("version").is("1").and() + .field("graphicNotationDefined").is("true").and() + .field("key").is("activitiAdhoc"); } @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, @@ -76,6 +87,9 @@ public class GetProcessDefinitionsCoreTests extends RestTest .getAllProcessDefinitions() .assertThat().entriesListIsEmpty(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_WHERE_QUERY, "test")); + .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_WHERE_QUERY, "test")) + .containsErrorKey(RestErrorModel.INVALID_QUERY_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsFullTests.java new file mode 100644 index 000000000..23fea5554 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsFullTests.java @@ -0,0 +1,193 @@ +package org.alfresco.rest.workflow.processDefinitions; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestProcessDefinitionModel; +import org.alfresco.rest.model.RestProcessDefinitionModelsCollection; +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; + +/** + * Created by Claudia Agache on 2/1/2017. + */ +public class GetProcessDefinitionsFullTests extends RestTest +{ + private UserModel adminUserModel; + private RestProcessDefinitionModelsCollection processDefinitions; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, + description = "Verify admin gets process definitions with valid skipCount parameter applied using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.FULL }) + public void getProcessDefinitionsWithValidSkipCount() throws Exception + { + processDefinitions = restClient.authenticateUser(adminUserModel) + .withWorkflowAPI().getAllProcessDefinitions(); + restClient.assertStatusCodeIs(HttpStatus.OK); + RestProcessDefinitionModel firstProcessDefinition = processDefinitions.getEntries().get(0).onModel(); + RestProcessDefinitionModel secondProcessDefinition = processDefinitions.getEntries().get(1).onModel(); + + RestProcessDefinitionModelsCollection procDefWithSkipCount = restClient.withParams("skipCount=2").withWorkflowAPI().getAllProcessDefinitions(); + restClient.assertStatusCodeIs(HttpStatus.OK); + procDefWithSkipCount + .assertThat().entriesListDoesNotContain("name", firstProcessDefinition.getName()) + .assertThat().entriesListDoesNotContain("name", secondProcessDefinition.getName()) + .assertThat().entriesListCountIs(processDefinitions.getEntries().size()-2); + procDefWithSkipCount.assertThat().paginationField("skipCount").is("2"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, + description = "Verify admin doesn't get process definitions with negative skipCount parameter applied using REST API") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.FULL }) + public void getProcessDefinitionsWithNegativeSkipCount() throws Exception + { + restClient.authenticateUser(adminUserModel).withParams("skipCount=-1").withWorkflowAPI().getAllProcessDefinitions(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT) + .containsErrorKey(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE) + .statusCodeIs(HttpStatus.BAD_REQUEST); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, + description = "Verify admin doesn't get process definitions with non numeric skipCount parameter applied using REST API") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.FULL }) + public void getProcessDefinitionsWithNonNumericSkipCount() throws Exception + { + restClient.authenticateUser(adminUserModel).withParams("skipCount=A").withWorkflowAPI().getAllProcessDefinitions(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "A")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, + description = "Verify admin gets process definitions with valid maxItems parameter applied using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.FULL }) + public void getProcessDefinitionsWithValidMaxItems() throws Exception + { + processDefinitions = restClient.authenticateUser(adminUserModel) + .withWorkflowAPI().getAllProcessDefinitions(); + restClient.assertStatusCodeIs(HttpStatus.OK); + RestProcessDefinitionModel firstProcessDefinition = processDefinitions.getEntries().get(0).onModel(); + RestProcessDefinitionModel secondProcessDefinition = processDefinitions.getEntries().get(1).onModel(); + + RestProcessDefinitionModelsCollection procDefWithMaxItems = restClient.withParams("maxItems=2").withWorkflowAPI().getAllProcessDefinitions(); + restClient.assertStatusCodeIs(HttpStatus.OK); + procDefWithMaxItems + .assertThat().entriesListContains("name", firstProcessDefinition.getName()) + .assertThat().entriesListContains("name", secondProcessDefinition.getName()) + .assertThat().entriesListCountIs(2); + procDefWithMaxItems.assertThat().paginationField("maxItems").is("2"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, + description = "Verify admin doesn't get process definitions with negative maxItems parameter applied using REST API") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.FULL }) + public void getProcessDefinitionsWithNegativeMaxItems() throws Exception + { + restClient.authenticateUser(adminUserModel).withParams("maxItems=-1").withWorkflowAPI().getAllProcessDefinitions(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) + .containsErrorKey(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE) + .statusCodeIs(HttpStatus.BAD_REQUEST); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, + description = "Verify admin doesn't get process definitions with non numeric maxItems parameter applied using REST API") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.FULL }) + public void getProcessDefinitionsWithNonNumericMaxItems() throws Exception + { + restClient.authenticateUser(adminUserModel).withParams("maxItems=A").withWorkflowAPI().getAllProcessDefinitions(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "A")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, + description = "Verify Admin user gets process definitions with properties parameter applied using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.FULL }) + public void getProcessDefinitionsWithValidProperties() throws Exception + { + processDefinitions =restClient.authenticateUser(adminUserModel).withParams("properties=name,graphicNotationDefined,version").withWorkflowAPI().getAllProcessDefinitions(); + restClient.assertStatusCodeIs(HttpStatus.OK); + processDefinitions.assertThat().entriesListIsNotEmpty(); + processDefinitions.getOneRandomEntry().onModel().assertThat() + .fieldsCount().is(3).and() + .field("deploymentId").isNull().and() + .field("description").isNull().and() + .field("id").isNull().and() + .field("startFormResourceKey").isNull().and() + .field("category").isNull().and() + .field("title").isNull().and() + .field("version").isNotEmpty().and() + .field("graphicNotationDefined").isNotEmpty().and() + .field("key").isNull().and() + .field("name").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, + description = "Verify admin gets process definitions ordered by name ascendant using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.FULL }) + public void getProcessDefinitionsOrderedByNameAsc() throws Exception + { + processDefinitions = restClient.authenticateUser(adminUserModel) + .withParams("orderBy=name ASC").withWorkflowAPI().getAllProcessDefinitions(); + restClient.assertStatusCodeIs(HttpStatus.OK); + processDefinitions.assertThat().entriesListIsSortedAscBy("name"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, + description = "Verify admin doesn't get process definitions when many fields are used for orderBy parameter") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.FULL }) + public void getProcessDefinitionsOrderedByManyFields() throws Exception + { + restClient.authenticateUser(adminUserModel) + .withParams("orderBy=name,id").withWorkflowAPI().getAllProcessDefinitions(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(RestErrorModel.ONLY_ONE_ORDERBY); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, + description = "Verify admin gets process definitions when where parameter is applied") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.FULL }) + public void getProcessDefinitionsFilteredByKey() throws Exception + { + processDefinitions = restClient.authenticateUser(adminUserModel) + .withParams("where=(key matches('activitiParallel%'))").withWorkflowAPI().getAllProcessDefinitions(); + restClient.assertStatusCodeIs(HttpStatus.OK); + processDefinitions.assertThat().entriesListCountIs(2) + .assertThat().entriesListContains("key", "activitiParallelReview") + .assertThat().entriesListContains("key", "activitiParallelGroupReview"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, + executionType = ExecutionType.REGRESSION, + description = "Verify Tenant User doesn't get process definitions for another network deployment using REST API") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.FULL, TestGroup.NETWORKS }) + public void networkUserIsNotAbleToGetProcessDefinitionsForAnotherNetwork() throws Exception + { + UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); + UserModel adminTenantUser2 = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUserModel).usingTenant().createTenant(adminTenantUser1); + restClient.usingTenant().createTenant(adminTenantUser2); + + RestProcessDefinitionModel randomProcessDefinitionTenant1 = restClient.authenticateUser(adminTenantUser1).withWorkflowAPI() + .getAllProcessDefinitions().getOneRandomEntry().onModel(); + RestProcessDefinitionModelsCollection processDefinitionsTenant2 = restClient.authenticateUser(adminTenantUser2).withWorkflowAPI() + .getAllProcessDefinitions(); + restClient.assertStatusCodeIs(HttpStatus.OK); + processDefinitionsTenant2.assertThat().entriesListDoesNotContain("id", randomProcessDefinitionTenant1.getId()); + } + +} diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java index dbdd1cf7b..8a719a929 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java @@ -16,9 +16,6 @@ import org.testng.annotations.Test; */ public class GetProcessDefinitionsSanityTests extends RestTest { - @Autowired - private DataUser dataUser; - private UserModel adminUserModel, adminTenantUser; @BeforeClass(alwaysRun = true) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksCoreTests.java index f60f151ee..d2bf42756 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksCoreTests.java @@ -3,6 +3,7 @@ package org.alfresco.rest.workflow.tasks; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.CMISUtil.Priority; import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestTaskModelsCollection; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; @@ -62,7 +63,7 @@ public class GetTasksCoreTests extends RestTest public void orderByParameterSupportsOnlyOneParameter() throws Exception { taskModels = restClient.authenticateUser(dataUser.getAdminUser()).withParams("orderBy=id,processDefinitionId").withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Only one order by parameter is supported"); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(RestErrorModel.ONLY_ONE_ORDERBY); taskModels.assertThat().entriesListIsEmpty(); } From 851eb6bd622f32c6331251d93d2215f6566dc316 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Wed, 1 Feb 2017 16:11:08 +0200 Subject: [PATCH 0962/1491] TAS-2899 added one full test for deleteProcess --- .../processes/DeleteProcessFullTests.java | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessFullTests.java new file mode 100644 index 000000000..25d87412b --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessFullTests.java @@ -0,0 +1,52 @@ +package org.alfresco.rest.workflow.processes; + +import org.alfresco.dataprep.CMISUtil.Priority; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestProcessModel; +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 Cristina Axinte + * + */ +public class DeleteProcessFullTests extends RestTest +{ + private UserModel userWhoAddsProcess, assignee; + private RestProcessModel process; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + userWhoAddsProcess = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify user is able to delete process started by him twice using REST API and status code is OK (204)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void deleteProcessByUserWhoStartedProcessTwice() throws Exception + { + process = restClient.authenticateUser(userWhoAddsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.withWorkflowAPI().usingProcess(process).deleteProcess(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withWorkflowAPI().usingProcess(process).deleteProcess(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .containsSummary(String.format("%s: %s ", "The entity with id" , process.getId(), RestErrorModel.ENTITY_NOT_FOUND)) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + + restClient.withWorkflowAPI().getProcesses().assertThat().entriesListDoesNotContain("id", process.getId()); + } +} From dbd9e11f2eb7a27d819668a1f0cdf648685fae0a Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Wed, 1 Feb 2017 16:16:59 +0200 Subject: [PATCH 0963/1491] updated test description --- .../rest/workflow/processes/DeleteProcessFullTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessFullTests.java index 25d87412b..ca69ff98c 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessFullTests.java @@ -30,7 +30,7 @@ public class DeleteProcessFullTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify user is able to delete process started by him twice using REST API and status code is OK (204)") + description = "Verify user is NOT able to delete process started by him twice using REST API and status code is NOT FOUND (404)") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) public void deleteProcessByUserWhoStartedProcessTwice() throws Exception { From 83f2cdc8141c2b99e7ecad9b6019a4d43ae0fafb Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 1 Feb 2017 16:53:14 +0200 Subject: [PATCH 0964/1491] TAS - 2894 getProcessDefinition --- .../GetProcessDefinitionCoreTests.java | 5 +- .../GetProcessDefinitionFullTests.java | 90 +++++++++++++++++++ .../GetProcessDefinitionSanityTests.java | 12 ++- 3 files changed, 105 insertions(+), 2 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionCoreTests.java index b8bf9cb89..286b84400 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionCoreTests.java @@ -37,7 +37,10 @@ public class GetProcessDefinitionCoreTests extends RestTest restClient.withWorkflowAPI() .usingProcessDefinitions(randomProcessDefinition).getProcessDefinition(); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidID")); + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidID")) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); } @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionFullTests.java new file mode 100644 index 000000000..9af418895 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionFullTests.java @@ -0,0 +1,90 @@ +package org.alfresco.rest.workflow.processDefinitions; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestProcessDefinitionModel; +import org.alfresco.rest.model.RestProcessDefinitionModelsCollection; +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; + +/** + * Created by Claudia Agache on 2/1/2017. + */ +public class GetProcessDefinitionFullTests extends RestTest +{ + private UserModel adminUser; + private RestProcessDefinitionModel randomProcessDefinition, returnedProcessDefinition; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, + executionType = ExecutionType.REGRESSION, + description = "Verify if get process definition returns all process definitions when empty processDefinitionId is used") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.FULL }) + public void getProcessDefinitionUsingEmptyProcessDefinitionId() throws Exception + { + restClient.authenticateUser(adminUser).withWorkflowAPI(); + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "/process-definitions/{processDefinitionId}", ""); + RestProcessDefinitionModelsCollection processDefinitions = restClient.processModels(RestProcessDefinitionModelsCollection.class, request); + restClient.assertStatusCodeIs(HttpStatus.OK); + processDefinitions.assertThat().entriesListIsNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, + executionType = ExecutionType.REGRESSION, + description = "Verify Admin user gets a process definition with properties parameter applied using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.FULL }) + public void getProcessDefinitionWithValidProperties() throws Exception + { + randomProcessDefinition = restClient.authenticateUser(adminUser).withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry().onModel(); + returnedProcessDefinition = restClient.withParams("properties=id,name,graphicNotationDefined,version") + .withWorkflowAPI() + .usingProcessDefinitions(randomProcessDefinition).getProcessDefinition(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedProcessDefinition.assertThat() + .fieldsCount().is(4).and() + .field("deploymentId").isNull().and() + .field("description").isNull().and() + .field("id").is(randomProcessDefinition.getId()).and() + .field("startFormResourceKey").isNull().and() + .field("category").isNull().and() + .field("title").isNull().and() + .field("version").is(randomProcessDefinition.getVersion()).and() + .field("graphicNotationDefined").is(randomProcessDefinition.getGraphicNotationDefined()).and() + .field("key").isNull().and() + .field("name").is(randomProcessDefinition.getName()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, + executionType = ExecutionType.REGRESSION, + description = "Verify Network user is not able to get a process definition from another network") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.NETWORKS, TestGroup.FULL }) + public void getProcessDefinitionFromAnotherNetwork() throws Exception + { + UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); + UserModel adminTenantUser2 = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser1); + restClient.usingTenant().createTenant(adminTenantUser2); + + randomProcessDefinition = restClient.authenticateUser(adminTenantUser1).withWorkflowAPI() + .getAllProcessDefinitions().getOneRandomEntry().onModel(); + restClient.authenticateUser(adminTenantUser2).withWorkflowAPI() + .usingProcessDefinitions(randomProcessDefinition).getProcessDefinition(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, randomProcessDefinition.getId())) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } +} diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java index ac7d3e9cb..9a733f851 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java @@ -46,6 +46,16 @@ public class GetProcessDefinitionSanityTests extends RestTest restClient.authenticateUser(testUser); returnedProcessDefinition = restClient.withWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinition(); restClient.assertStatusCodeIs(HttpStatus.OK); - returnedProcessDefinition.assertThat().field("name").is(randomProcessDefinition.getName()); + returnedProcessDefinition.assertThat() + .field("name").is(randomProcessDefinition.getName()).and() + .field("deploymentId").is(randomProcessDefinition.getDeploymentId()).and() + .field("description").is(randomProcessDefinition.getDescription()).and() + .field("id").is(randomProcessDefinition.getId()).and() + .field("startFormResourceKey").is(randomProcessDefinition.getStartFormResourceKey()).and() + .field("category").is(randomProcessDefinition.getCategory()).and() + .field("title").is(randomProcessDefinition.getTitle()).and() + .field("version").is(randomProcessDefinition.getVersion()).and() + .field("graphicNotationDefined").is(randomProcessDefinition.getGraphicNotationDefined()).and() + .field("key").is(randomProcessDefinition.getKey()); } } From 02d87da718c9bd2081b997b138d362c69311024d Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Wed, 1 Feb 2017 17:21:34 +0200 Subject: [PATCH 0965/1491] added full tests for getProcess --- .../processes/GetProcessCoreTests.java | 8 +- .../processes/GetProcessFullTests.java | 104 ++++++++++++++++++ 2 files changed, 108 insertions(+), 4 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessCoreTests.java index d0ffd695d..214a562d7 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessCoreTests.java @@ -28,7 +28,7 @@ public class GetProcessCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify that using invalid process ID returns status code 404") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.CORE}) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE}) public void invalidProcessIdTest() throws Exception { RestProcessModel newProcess = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.High); @@ -41,7 +41,7 @@ public class GetProcessCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES, TestGroup.NETWORKS}, executionType = ExecutionType.REGRESSION, description = "Verify that tenant user cannot get process from another network") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.CORE, TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE, TestGroup.NETWORKS }) @Bug(id = "MNT-17238") public void tenantUserCannotGetProcessFromAnotherNetwork() throws Exception { @@ -62,7 +62,7 @@ public class GetProcessCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify that tenant user can get process from the same network") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.CORE, TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE, TestGroup.NETWORKS }) public void tenantUserCanGetProcessFromTheSameNetwork() throws Exception { UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); @@ -79,7 +79,7 @@ public class GetProcessCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES, TestGroup.NETWORKS}, executionType = ExecutionType.REGRESSION, description = "Verify that non network user cannot get process from a network") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.CORE, TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE, TestGroup.NETWORKS }) @Bug(id = "MNT-17238") public void nonNetworkUserCannotAccessNetworkprocess() throws Exception { diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessFullTests.java new file mode 100644 index 000000000..87c0272c3 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessFullTests.java @@ -0,0 +1,104 @@ +package org.alfresco.rest.workflow.processes; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestProcessModel; +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 Cristina Axinte + * + */ +public class GetProcessFullTests extends RestTest +{ + private UserModel userWhoStartsProcess, assignee; + private RestProcessModel addedProcess, process; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + userWhoStartsProcess = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + addedProcess = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.High); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin user can get process started by a network user") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL, TestGroup.NETWORKS }) + public void adminUserCanGetProcessFromANetwork() throws Exception + { + UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); + restClient.authenticateUser(dataUser.getAdminUser()).usingTenant().createTenant(adminTenantUser1); + UserModel tenantUser1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("utenant1"); + + RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser1).withWorkflowAPI().addProcess("activitiReview", adminTenantUser1, false, CMISUtil.Priority.High); + + restClient.authenticateUser(dataUser.getAdminUser()).withWorkflowAPI().usingProcess(networkProcess1).getProcess(); + restClient.assertStatusCodeIs(HttpStatus.OK); + networkProcess1.assertThat().field("processDefinitionId").contains(String.format("@%s%s", tenantUser1.getDomain().toLowerCase(), "@activitiReview:1")) + .and().field("startUserId").is(tenantUser1.getEmailAddress().toLowerCase()) + .and().field("startActivityId").is("start") + .and().field("startedAt").isNotEmpty() + .and().field("id").is(networkProcess1.getId()) + .and().field("completed").is(false) + .and().field("processDefinitionKey").is("activitiReview"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify user is able to get the process with properties parameter applied using REST API") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void getProcessWithPropertiesParameter() throws Exception + { + process = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingParams("properties=startUserId,id").usingProcess(addedProcess).getProcess(); + restClient.assertStatusCodeIs(HttpStatus.OK); + process.assertThat().fieldsCount().is(2) + .and().field("startUserId").is(addedProcess.getStartUserId()) + .and().field("id").is(addedProcess.getId()) + .and().field("processDefinitionKey").isNull(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify user is able to get a process that was deleted, but it has 'deleted through REST API call' deleteReason") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void getDeletedProcess() throws Exception + { + addedProcess = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.High); + + process = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingProcess(addedProcess).getProcess(); + restClient.assertStatusCodeIs(HttpStatus.OK); + process.assertThat() + .field("processDefinitionId").is("activitiAdhoc:1:4") + .and().field("startUserId").is(addedProcess.getStartUserId()) + .and().field("startActivityId").is("start") + .and().field("startedAt").isNotEmpty() + .and().field("id").is(addedProcess.getId()) + .and().field("completed").is(false) + .and().field("processDefinitionKey").is("activitiAdhoc"); + + restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingProcess(addedProcess).deleteProcess(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + process = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingProcess(addedProcess).getProcess(); + restClient.assertStatusCodeIs(HttpStatus.OK); + process.assertThat() + .field("processDefinitionId").is("activitiAdhoc:1:4") + .and().field("durationInMs").isNotNull() + .and().field("startUserId").is(addedProcess.getStartUserId()) + .and().field("startActivityId").is("start") + .and().field("endedAt").isNotEmpty() + .and().field("startedAt").isNotEmpty() + .and().field("id").is(addedProcess.getId()) + .and().field("completed").is(true) + .and().field("deleteReason").is("deleted through REST API call") + .and().field("processDefinitionKey").is("activitiAdhoc"); + + restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().assertThat().entriesListDoesNotContain("id", process.getId()); + } +} From 98708463021ad6985954d8cabdbdbd8361be0660 Mon Sep 17 00:00:00 2001 From: Andrei Rusu Date: Thu, 2 Feb 2017 10:21:40 +0200 Subject: [PATCH 0966/1491] added tests for UpdateTagFullTests --- .../rest/tags/UpdateTagFullTests.java | 161 ++++++++++++++++++ .../rest/tags/UpdateTagSanityTests.java | 2 +- 2 files changed, 162 insertions(+), 1 deletion(-) create mode 100644 e2e-test/java/org/alfresco/rest/tags/UpdateTagFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/tags/UpdateTagFullTests.java b/e2e-test/java/org/alfresco/rest/tags/UpdateTagFullTests.java new file mode 100644 index 000000000..1d8a9242c --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/tags/UpdateTagFullTests.java @@ -0,0 +1,161 @@ +package org.alfresco.rest.tags; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestTagModel; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.data.RandomData; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.apache.commons.lang.RandomStringUtils; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +public class UpdateTagFullTests extends RestTest +{ + private UserModel adminUserModel; + private FileModel document; + private SiteModel siteModel; + private RestTagModel oldTag; + private DataUser.ListUserWithRoles usersWithRoles; + private RestTagModel returnedModel; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + } + + @BeforeMethod(alwaysRun=true) + public void addTagToDocument() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + oldTag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("old")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify Manager user can provide large string for new tag value.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) + @Bug(id="REPO-1828") + public void managerIsAbleToUpdateTagsProvideLargeStringTag() throws JsonToModelConversionException, Exception + { + String largeStringTag = RandomStringUtils.randomAlphanumeric(10000); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + returnedModel = restClient.withCoreAPI().usingTag(oldTag).update(largeStringTag); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedModel.assertThat().field("tag").is(largeStringTag); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify Manager user can provide short string for new tag value.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) + @Bug(id="REPO-1828") + public void managerIsAbleToUpdateTagsProvideShortStringTag() throws JsonToModelConversionException, Exception + { + String shortStringTag = RandomStringUtils.randomAlphanumeric(2); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + returnedModel = restClient.withCoreAPI().usingTag(oldTag).update(shortStringTag); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedModel.assertThat().field("tag").is(shortStringTag); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify Manager user can provide string with special chars for new tag value.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) + @Bug(id="REPO-1828") + public void managerIsAbleToUpdateTagsProvideSpecialCharsStringTag() throws JsonToModelConversionException, Exception + { + String specialCharsString = "!@#$%^&*()'\".,<>-_+=|\\"; + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + returnedModel = restClient.withCoreAPI().usingTag(oldTag).update(specialCharsString); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedModel.assertThat().field("tag").is(specialCharsString); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user can't update tags with Rest API and status code is 403." + + "Check default error model schema.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) + public void collaboratorIsNotAbleToUpdateTagCheckDefaultErrorModelSchema() throws JsonToModelConversionException, Exception + { + String newTag = "newTag"; + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + restClient.withCoreAPI().usingTag(oldTag).update(newTag); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify Admin user can provide existing tag for new tag value.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) + @Bug(id="REPO-1828") + public void adminIsAbleToUpdateTagsProvideExistingTag() throws JsonToModelConversionException, Exception + { + String existingTag = "oldTag"; + RestTagModel oldExistingTag = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(document).addTag(existingTag); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(adminUserModel); + returnedModel = restClient.withCoreAPI().usingTag(oldExistingTag).update(existingTag); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedModel.assertThat().field("tag").is(existingTag); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify Admin user can delete a tag, add tag and update it.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) + @Bug(id="REPO-1828") + public void withAdminDeleteTagAddTagUpdateTag() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingResource(document).deleteTag(oldTag); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + String newTag = "addTag"; + RestTagModel newTagModel = restClient.withCoreAPI().usingResource(document).addTag(newTag); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedModel = restClient.withCoreAPI().usingTag(newTagModel).update(newTag); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedModel.assertThat().field("tag").is(newTag); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify Admin user can update a tag, delete tag and add it.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) + @Bug(id="REPO-1828") + public void withAdminUpdateTagDeleteTagAddTag() throws JsonToModelConversionException, Exception + { + String newTag = "addTag"; + + returnedModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingTag(oldTag).update(newTag); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedModel.assertThat().field("tag").is(newTag); + + restClient.withCoreAPI().usingResource(document).deleteTag(returnedModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingResource(document).addTag(newTag); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + } +} diff --git a/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java index 567148d6c..b50ceb2ab 100644 --- a/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java @@ -51,7 +51,7 @@ public class UpdateTagSanityTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Admin user updates tags and status code is 200") - @Bug(id="MNT-16917") + @Bug(id="REPO-1828") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) public void adminIsAbleToUpdateTags() throws JsonToModelConversionException, Exception { From 80425cc01d61f436dad13ade00c6840e41e5b9c9 Mon Sep 17 00:00:00 2001 From: cagache Date: Thu, 2 Feb 2017 10:37:14 +0200 Subject: [PATCH 0967/1491] fix test orderByParameterSupportsOnlyOneParameter --- .../org/alfresco/rest/workflow/tasks/GetTasksCoreTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksCoreTests.java index d2bf42756..1c5a51e30 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksCoreTests.java @@ -63,7 +63,7 @@ public class GetTasksCoreTests extends RestTest public void orderByParameterSupportsOnlyOneParameter() throws Exception { taskModels = restClient.authenticateUser(dataUser.getAdminUser()).withParams("orderBy=id,processDefinitionId").withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(RestErrorModel.ONLY_ONE_ORDERBY); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Only one order by parameter is supported"); taskModels.assertThat().entriesListIsEmpty(); } From ad46b2c42d905fcbd53773cf1fc16ce319bd7ed0 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Thu, 2 Feb 2017 10:47:28 +0200 Subject: [PATCH 0968/1491] Added new scenarios : TAS-2941, TAS-2942 --- .../alfresco/rest/FunctionalCasesTests.java | 78 ++++++++++++++++++- 1 file changed, 77 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java b/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java index dbf0059aa..a8862bb80 100644 --- a/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java +++ b/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java @@ -1,6 +1,9 @@ package org.alfresco.rest; +import org.alfresco.rest.model.RestFavoriteSiteModel; import org.alfresco.rest.model.RestSiteMemberModel; +import org.alfresco.rest.model.RestSiteMembershipRequestModelsCollection; +import org.alfresco.rest.model.RestTaskModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; @@ -14,14 +17,17 @@ import org.testng.annotations.Test; public class FunctionalCasesTests extends RestTest { private UserModel adminUserModel; - private SiteModel siteModel; + private SiteModel siteModel, moderatedSite; private RestSiteMemberModel updatedMember; + private RestSiteMembershipRequestModelsCollection returnedCollection; + private RestFavoriteSiteModel restFavoriteSiteModel; @BeforeClass(alwaysRun=true) public void dataPreparation() throws Exception { adminUserModel = dataUser.getAdminUser(); siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + moderatedSite = dataSite.usingUser(adminUserModel).createModeratedRandomSite(); } /** @@ -99,4 +105,74 @@ public class FunctionalCasesTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); updatedMember.assertThat().field("id").is(testUser.getUsername()).and().field("role").is(testUser.getUserRole()); } + + /** + * Scenario: + * 1. Create site membership request + * 2. Approve site membership request + * 3. Add site to Favorites + * 4. Delete site from Favorites + */ + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, description = "Approve request, add site to favorites, then delete it") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + public void approveRequestAddAndDeleteSiteFromFavorites() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + + restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestTaskModel taskModel = restClient.authenticateUser(newMember).withWorkflowAPI().getTasks().getTaskModelByDescription(moderatedSite); + workflow.approveSiteMembershipRequest(adminUserModel.getUsername(), adminUserModel.getPassword(), taskModel.getId(), true, "Approve"); + returnedCollection = restClient.authenticateUser(newMember).withCoreAPI().usingMe().getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat().entriesListDoesNotContain("id", moderatedSite.getId()); + + restFavoriteSiteModel = restClient.authenticateUser(newMember).withCoreAPI().usingUser(newMember).addFavoriteSite(siteModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restFavoriteSiteModel.assertThat().field("id").is(siteModel.getId()); + + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + /** + * Scenario: + * 1. Create site membership request + * 2. Reject site membership request + * 3. Add moderated site to Favorites + * 4. Create site membership request again + * 5. Approve site membership request + * 6. Delete member from site + */ + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, description = "Reject request, add moderated site to favorites, create request again and approve it") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + public void rejectRequestAddModeratedSiteToFavorites() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + + restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestTaskModel taskModel = restClient.authenticateUser(newMember).withWorkflowAPI().getTasks().getTaskModelByDescription(moderatedSite); + workflow.approveSiteMembershipRequest(adminUserModel.getUsername(), adminUserModel.getPassword(), taskModel.getId(), false, "Rejected"); + returnedCollection = restClient.authenticateUser(newMember).withCoreAPI().usingMe().getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat().entriesListDoesNotContain("id", moderatedSite.getId()); + + restFavoriteSiteModel = restClient.authenticateUser(newMember).withCoreAPI().usingUser(newMember).addFavoriteSite(siteModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restFavoriteSiteModel.assertThat().field("id").is(siteModel.getId()); + + restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + taskModel = restClient.authenticateUser(newMember).withWorkflowAPI().getTasks().getTaskModelByDescription(moderatedSite); + workflow.approveSiteMembershipRequest(adminUserModel.getUsername(), adminUserModel.getPassword(), taskModel.getId(), true, "Accept"); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(newMember).deleteSiteMember(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } } From 87061e5618c1739cb16d7007a3d0a7eb60aff8f2 Mon Sep 17 00:00:00 2001 From: Andrei Rusu Date: Thu, 2 Feb 2017 11:44:12 +0200 Subject: [PATCH 0969/1491] updated tests for skipCount, maxItems --- .../alfresco/rest/tags/GetTagsFullTests.java | 35 +++++++++++-------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/tags/GetTagsFullTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagsFullTests.java index eb7c98243..c6dace4c7 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetTagsFullTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetTagsFullTests.java @@ -66,14 +66,17 @@ public class GetTagsFullTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) public void useSkipCountCheckPagination() throws JsonToModelConversionException, Exception { - returnedCollection = restClient.authenticateUser(adminUserModel) - .withParams("skipCount=20").withCoreAPI().getTags(); + returnedCollection = restClient.authenticateUser(adminUserModel).withCoreAPI().getTags(); restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.getPagination().assertThat().field("maxItems").is(100) - .and().field("hasMoreItems").is("true") - .and().field("count").is("100") - .and().field("skipCount").is(20) - .and().field("totalItems").isNull(); + + RestTagModel firstTag = returnedCollection.getEntries().get(0).onModel(); + RestTagModel secondTag = returnedCollection.getEntries().get(1).onModel(); + RestTagModelsCollection tagsWithSkipCount = restClient.withParams("skipCount=2").withCoreAPI().getTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + tagsWithSkipCount.assertThat().entriesListDoesNotContain("tag", firstTag.getTag()) + .assertThat().entriesListDoesNotContain("tag", secondTag.getTag()); + tagsWithSkipCount.assertThat().paginationField("skipCount").is("2"); } @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, @@ -81,14 +84,18 @@ public class GetTagsFullTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) public void useMaxItemsParameterCheckPagination() throws JsonToModelConversionException, Exception { - returnedCollection = restClient.authenticateUser(adminUserModel) - .withParams("maxItems=50").withCoreAPI().getTags(); + returnedCollection = restClient.authenticateUser(adminUserModel).withCoreAPI().getTags(); restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.getPagination().assertThat().field("maxItems").is(50) - .and().field("hasMoreItems").is("true") - .and().field("count").is("50") - .and().field("skipCount").is("0") - .and().field("totalItems").isNull(); + + RestTagModel firstTag = returnedCollection.getEntries().get(0).onModel(); + RestTagModel secondTag = returnedCollection.getEntries().get(1).onModel(); + RestTagModelsCollection tagsWithMaxItems = restClient.withParams("maxItems=2").withCoreAPI().getTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + tagsWithMaxItems.assertThat().entriesListContains("tag", firstTag.getTag()) + .assertThat().entriesListContains("tag", secondTag.getTag()) + .assertThat().entriesListCountIs(2); + tagsWithMaxItems.assertThat().paginationField("maxItems").is("2"); } @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, From 9719c53bde1467b4b23a059f89377db18c3393d3 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Thu, 2 Feb 2017 11:55:58 +0200 Subject: [PATCH 0970/1491] Added a check after deleting user --- .../org/alfresco/rest/FunctionalCasesTests.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java b/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java index a8862bb80..7a6391536 100644 --- a/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java +++ b/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java @@ -114,7 +114,7 @@ public class FunctionalCasesTests extends RestTest * 4. Delete site from Favorites */ @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, description = "Approve request, add site to favorites, then delete it") + executionType = ExecutionType.REGRESSION, description = "Approve request, add site to favorites, then delete it from favorites") @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) public void approveRequestAddAndDeleteSiteFromFavorites() throws Exception { @@ -129,11 +129,11 @@ public class FunctionalCasesTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); returnedCollection.assertThat().entriesListDoesNotContain("id", moderatedSite.getId()); - restFavoriteSiteModel = restClient.authenticateUser(newMember).withCoreAPI().usingUser(newMember).addFavoriteSite(siteModel); + restFavoriteSiteModel = restClient.authenticateUser(newMember).withCoreAPI().usingUser(newMember).addFavoriteSite(moderatedSite); restClient.assertStatusCodeIs(HttpStatus.CREATED); - restFavoriteSiteModel.assertThat().field("id").is(siteModel.getId()); + restFavoriteSiteModel.assertThat().field("id").is(moderatedSite.getId()); - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel); + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().removeFavoriteSite(moderatedSite); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } @@ -162,9 +162,9 @@ public class FunctionalCasesTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); returnedCollection.assertThat().entriesListDoesNotContain("id", moderatedSite.getId()); - restFavoriteSiteModel = restClient.authenticateUser(newMember).withCoreAPI().usingUser(newMember).addFavoriteSite(siteModel); + restFavoriteSiteModel = restClient.authenticateUser(newMember).withCoreAPI().usingUser(newMember).addFavoriteSite(moderatedSite); restClient.assertStatusCodeIs(HttpStatus.CREATED); - restFavoriteSiteModel.assertThat().field("id").is(siteModel.getId()); + restFavoriteSiteModel.assertThat().field("id").is(moderatedSite.getId()); restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest(moderatedSite); restClient.assertStatusCodeIs(HttpStatus.CREATED); @@ -174,5 +174,7 @@ public class FunctionalCasesTests extends RestTest restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(newMember).deleteSiteMember(moderatedSite); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingSite(moderatedSite).getSiteMembers().assertThat().entriesListDoesNotContain("id", newMember.getUsername()); } } From bc0088a07c7d7e09ad4a8b65cc106ecb6c94d2e1 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Thu, 2 Feb 2017 13:49:26 +0200 Subject: [PATCH 0971/1491] TAS-2838: add sample example of using restWrapper.process(RestReques request) --- .../alfresco/rest/sites/GetSiteFullTests.java | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteFullTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteFullTests.java index 3ee6795d0..dff227d0d 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteFullTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteFullTests.java @@ -1,8 +1,12 @@ package org.alfresco.rest.sites; +import static org.hamcrest.CoreMatchers.equalTo; + import java.util.List; import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.core.RestResponse; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestSiteContainerModelsCollection; import org.alfresco.rest.model.RestSiteMemberModelsCollection; @@ -15,11 +19,11 @@ 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.springframework.social.alfresco.api.entities.Site.Visibility; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; - public class GetSiteFullTests extends RestTest { private UserModel adminUserModel, testUser; @@ -178,6 +182,23 @@ public class GetSiteFullTests extends RestTest .and().field("person.id").is("admin"); } + @Test(groups="demo") + public void checkThatRelationsParameterIsAppliedForMembersCustom() + { + /*1 - select API endpoint*/ + restClient.withCoreAPI(); + + /*2 - define request */ + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "sites/{siteId}?{parameters}", publicSite.getId(), "relations=members"); + + /*3 - send request */ + RestResponse response = restClient.authenticateUser(adminUserModel).process(request); + + /*assertions */ + response.assertThat().body("entry.id", equalTo(publicSite.getId())); + response.assertThat().body("relations.members.list.entries.entry[0].role", equalTo("SiteManager")); + } + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL } ) @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Check that relations parameter is applied for containers and members") From cf2c66ff5f234d3df38f7eab967543b3e45d3934 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Thu, 2 Feb 2017 14:04:20 +0200 Subject: [PATCH 0972/1491] fix imports on tests --- e2e-test/java/org/alfresco/rest/RestTest.java | 8 +++++++- .../RestGetNetworkForPersonFullTests.java | 4 ++-- .../UpdateSiteMembershipRequestSanityTests.java | 4 ---- .../alfresco/rest/ratings/AddRatingFullTests.java | 1 - .../rest/ratings/DeleteRatingFullTests.java | 6 +++++- .../alfresco/rest/tags/GetNodeTagsFullTests.java | 2 +- .../deployments/DeleteDeploymentSanityTests.java | 11 ++++++++--- .../deployments/GetDeploymentFullTests.java | 1 - ...tProcessDefinitionStartFormModelFullTests.java | 4 ++-- .../GetProcessDefinitionsSanityTests.java | 2 -- .../processes/GetProcessTasksCoreTests.java | 7 ++++++- .../processes/GetProcessTasksSanityTests.java | 6 +++++- .../processes/GetProcessesSanityTests.java | 6 +++++- .../UpdateProcessVariableSanityTests.java | 5 ++++- .../workflow/tasks/GetTaskItemsCoreTests.java | 15 ++++++++++++--- .../workflow/tasks/GetTaskVariablesCoreTests.java | 6 +++++- .../rest/workflow/tasks/GetTasksCoreTests.java | 1 - 17 files changed, 62 insertions(+), 27 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/RestTest.java b/e2e-test/java/org/alfresco/rest/RestTest.java index 09ecbe5e0..749b80d92 100644 --- a/e2e-test/java/org/alfresco/rest/RestTest.java +++ b/e2e-test/java/org/alfresco/rest/RestTest.java @@ -7,7 +7,13 @@ import org.alfresco.rest.core.RestProperties; import org.alfresco.rest.core.RestWrapper; import org.alfresco.utility.LogFactory; import org.alfresco.utility.TasProperties; -import org.alfresco.utility.data.*; +import org.alfresco.utility.data.DataContent; +import org.alfresco.utility.data.DataDiscussion; +import org.alfresco.utility.data.DataGroup; +import org.alfresco.utility.data.DataLink; +import org.alfresco.utility.data.DataSite; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.data.DataWorkflow; import org.alfresco.utility.network.ServerHealth; import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonFullTests.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonFullTests.java index e5a5e344d..3ce6393f9 100644 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonFullTests.java +++ b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonFullTests.java @@ -1,5 +1,7 @@ package org.alfresco.rest.networks; +import java.util.ArrayList; + import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestNetworkModel; import org.alfresco.rest.model.RestNetworkQuotaModel; @@ -11,8 +13,6 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import java.util.ArrayList; - /** * Tests for /people/{personId}/networks */ diff --git a/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestSanityTests.java index 6908f60cd..a0eb8abed 100644 --- a/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestSanityTests.java @@ -4,18 +4,14 @@ 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.DataSite; -import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.data.RandomData; 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.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.social.alfresco.api.entities.Site.Visibility; import org.testng.annotations.BeforeClass; diff --git a/e2e-test/java/org/alfresco/rest/ratings/AddRatingFullTests.java b/e2e-test/java/org/alfresco/rest/ratings/AddRatingFullTests.java index 97c94e6a0..6207473b7 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/AddRatingFullTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/AddRatingFullTests.java @@ -13,7 +13,6 @@ import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.apache.commons.lang3.RandomStringUtils; diff --git a/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingFullTests.java b/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingFullTests.java index b2dfd66d6..b3c68262f 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingFullTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingFullTests.java @@ -8,7 +8,11 @@ import org.alfresco.rest.model.RestRatingModelsCollection; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.exception.DataPreparationException; -import org.alfresco.utility.model.*; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; diff --git a/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsFullTests.java b/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsFullTests.java index 9de001f0e..0da991ef8 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsFullTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsFullTests.java @@ -7,8 +7,8 @@ import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestTagModelsCollection; import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.RandomData; import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.data.RandomData; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java index 7fcd6da35..254d40c00 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java @@ -1,8 +1,15 @@ package org.alfresco.rest.workflow.deployments; +import java.util.List; + import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.*; +import org.alfresco.rest.model.RestDeploymentModel; +import org.alfresco.rest.model.RestDeploymentModelsCollection; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestProcessDefinitionModel; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestTaskModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; @@ -12,8 +19,6 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import java.util.List; - /** * Tests for REST API call DELETE "/deployments/{deploymentId}" * Class has priority 100 in order to be executed last in the list of tests classes diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentFullTests.java index 335e0f3ad..a13c4a50f 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentFullTests.java @@ -7,7 +7,6 @@ import org.alfresco.rest.model.RestDeploymentModelsCollection; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpMethod; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelFullTests.java index c80a5b704..27e146a38 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelFullTests.java @@ -1,5 +1,7 @@ package org.alfresco.rest.workflow.processDefinitions; +import java.util.Arrays; + import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestFormModelsCollection; @@ -12,8 +14,6 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import java.util.Arrays; - /** * Created by Claudia Agache on 1/31/2017. */ diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java index 8a719a929..9925ebd93 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java @@ -1,12 +1,10 @@ package org.alfresco.rest.workflow.processDefinitions; import org.alfresco.rest.RestTest; -import org.alfresco.utility.data.DataUser; 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.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksCoreTests.java index 2528a0e88..fcd3c9718 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksCoreTests.java @@ -4,7 +4,12 @@ import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestTaskModel; -import org.alfresco.utility.model.*; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.GroupModel; +import org.alfresco.utility.model.ProcessModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksSanityTests.java index d9e161119..b899780f5 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksSanityTests.java @@ -4,7 +4,11 @@ import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestTaskModelsCollection; -import org.alfresco.utility.model.*; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.ProcessModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java index 2e756b033..ffdf90930 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java @@ -3,7 +3,11 @@ package org.alfresco.rest.workflow.processes; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestProcessModelsCollection; -import org.alfresco.utility.model.*; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TaskModel; +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; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/UpdateProcessVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/UpdateProcessVariableSanityTests.java index 165c11b7c..e84f3f45c 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/UpdateProcessVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/UpdateProcessVariableSanityTests.java @@ -7,7 +7,10 @@ import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.rest.model.RestProcessVariableCollection; import org.alfresco.rest.model.RestProcessVariableModel; -import org.alfresco.utility.model.*; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskItemsCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskItemsCoreTests.java index 916c52283..63b469f2d 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskItemsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskItemsCoreTests.java @@ -1,9 +1,18 @@ package org.alfresco.rest.workflow.tasks; -import org.alfresco.dataprep.CMISUtil.*; +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.dataprep.CMISUtil.Priority; import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.*; -import org.alfresco.utility.model.*; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestItemModel; +import org.alfresco.rest.model.RestItemModelsCollection; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestTaskModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TaskModel; +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; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskVariablesCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskVariablesCoreTests.java index a3c76115e..ed14bcf3f 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskVariablesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskVariablesCoreTests.java @@ -6,7 +6,11 @@ import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.rest.model.RestTaskModel; import org.alfresco.rest.model.RestVariableModelsCollection; -import org.alfresco.utility.model.*; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TaskModel; +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; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksCoreTests.java index 1c5a51e30..f60f151ee 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksCoreTests.java @@ -3,7 +3,6 @@ package org.alfresco.rest.workflow.tasks; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.CMISUtil.Priority; import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestTaskModelsCollection; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; From b4a1434b66b32c8975482ca6d33632cf08ad3893 Mon Sep 17 00:00:00 2001 From: cagache Date: Thu, 2 Feb 2017 15:20:58 +0200 Subject: [PATCH 0973/1491] TAS - 2901 - getProcessVariables --- .../GetProcessVariablesCoreTests.java | 43 +++-- .../GetProcessVariablesFullTests.java | 161 ++++++++++++++++++ 2 files changed, 180 insertions(+), 24 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesCoreTests.java index e46dc791e..9ca8d14df 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesCoreTests.java @@ -42,42 +42,40 @@ public class GetProcessVariablesCoreTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, description = "Verify that admin from the same network is able to retrieve network process variables") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE, TestGroup.NETWORKS }) - public void getProcessVariablesWithAdminFromSameNetwork() throws JsonToModelConversionException, Exception + public void getProcessVariablesWithAdminFromSameNetwork() throws Exception { UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); restClient.authenticateUser(admin).usingTenant().createTenant(adminTenantUser1); UserModel tenantUser1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenant1"); - RestProcessModel networkProcess1 = restClient.authenticateUser(adminTenantUser1).withWorkflowAPI() - .addProcess("activitiReview", tenantUser1, false, CMISUtil.Priority.High); - processModel = restClient.authenticateUser(adminTenantUser1).withWorkflowAPI().usingProcess(networkProcess1).getProcess(); + RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser1).withWorkflowAPI() + .addProcess("activitiReview", tenantUser1, false, CMISUtil.Priority.High); - variables = restClient.authenticateUser(adminTenantUser1).withWorkflowAPI().usingProcess(processModel).getProcessVariables(); + variables = restClient.authenticateUser(adminTenantUser1).withWorkflowAPI().usingProcess(networkProcess1).getProcessVariables(); restClient.assertStatusCodeIs(HttpStatus.OK); variables.assertThat().entriesListIsNotEmpty(); } - + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, description = "Verify that admin from different network is not able to retrieve network process variables") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE, TestGroup.NETWORKS }) - public void getProcessVariablesWithAdminFromDifferentNetwork() throws JsonToModelConversionException, Exception + public void getProcessVariablesWithAdminFromDifferentNetwork() throws Exception { UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); restClient.authenticateUser(admin).usingTenant().createTenant(adminTenantUser1); UserModel tenantUser1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenant1"); RestProcessModel networkProcess1 = restClient.authenticateUser(adminTenantUser1).withWorkflowAPI() - .addProcess("activitiReview", tenantUser1, false, CMISUtil.Priority.High); - processModel = restClient.authenticateUser(adminTenantUser1).withWorkflowAPI().usingProcess(networkProcess1).getProcess(); + .addProcess("activitiReview", tenantUser1, false, CMISUtil.Priority.High); - variables = restClient.authenticateUser(admin).withWorkflowAPI().usingProcess(processModel).getProcessVariables(); + variables = restClient.authenticateUser(admin).withWorkflowAPI().usingProcess(networkProcess1).getProcessVariables(); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT); } - + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Get process variables using invalid process ID") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) - public void getProcessVariablesUsingInvalidProcessId() throws JsonToModelConversionException, Exception + public void getProcessVariablesUsingInvalidProcessId() throws Exception { restClient.authenticateUser(userWhoStartsTask).withParams("maxItems=2").withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); RestProcessModelsCollection processes = restClient.authenticateUser(userWhoStartsTask).withParams("maxItems=2").withWorkflowAPI().getProcesses(); @@ -86,13 +84,17 @@ public class GetProcessVariablesCoreTests extends RestTest String id = RandomStringUtils.randomAlphanumeric(10); processModel.setId(id); variables = restClient.withParams("maxItems=2").withWorkflowAPI().usingProcess(processModel).getProcessVariables(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, id)); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, id)) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); } @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Get process variables using empty process ID") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) - public void getProcessVariablesUsingEmptyProcessId() throws JsonToModelConversionException, Exception + public void getProcessVariablesUsingEmptyProcessId() throws Exception { processModel = restClient.authenticateUser(userWhoStartsTask).withParams("maxItems=2").withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); processModel.setId(""); @@ -103,24 +105,17 @@ public class GetProcessVariablesCoreTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Delete process then get process variables, status OK should be returned") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) - public void getProcessVariablesForADeletedProcess() throws JsonToModelConversionException, Exception + public void getProcessVariablesForADeletedProcess() throws Exception { - SiteModel siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); UserModel userWhoStartsTask = dataUser.createRandomTestUser(); UserModel assignee = dataUser.createRandomTestUser(); - FileModel document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - RestProcessModel processModel; - RestProcessVariableCollection variables; - dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); + RestProcessModel processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); - processModel = restClient.authenticateUser(userWhoStartsTask).withParams("maxItems=2").withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); restClient.authenticateUser(admin).withWorkflowAPI().usingProcess(processModel).deleteProcess(); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.authenticateUser(admin).withParams("maxItems=2").withWorkflowAPI().usingProcess(processModel).getProcess(); - - variables = restClient.authenticateUser(admin).withWorkflowAPI().usingProcess(processModel).getProcessVariables(); + RestProcessVariableCollection variables = restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables(); restClient.assertStatusCodeIs(HttpStatus.OK); variables.assertThat().entriesListIsNotEmpty(); } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesFullTests.java new file mode 100644 index 000000000..d201a6337 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesFullTests.java @@ -0,0 +1,161 @@ +package org.alfresco.rest.workflow.processes; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestProcessVariableCollection; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Created by Claudia Agache on 2/2/2017. + */ +public class GetProcessVariablesFullTests extends RestTest +{ + private UserModel userWhoStartsProcess, assignee, admin; + private RestProcessModel processModel; + private RestProcessVariableCollection variables; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + admin = dataUser.getAdminUser(); + userWhoStartsProcess = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.Normal); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify get all process variables call using admin user. Admin can see the process even if he isn't involved in it.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void getProcessVariablesUsingAdmin() throws Exception + { + variables = restClient.authenticateUser(admin).withWorkflowAPI().usingProcess(processModel).getProcessVariables(); + restClient.assertStatusCodeIs(HttpStatus.OK); + variables.assertThat().entriesListIsNotEmpty(); + variables.getProcessVariableByName("initiator") + .assertThat().field("name").is("initiator") + .assertThat().field("type").is("d:noderef") + .assertThat().field("value").is(userWhoStartsProcess.getUsername()); + variables.getProcessVariableByName("bpm_assignee") + .assertThat().field("name").is("bpm_assignee") + .assertThat().field("type").is("cm:person") + .assertThat().field("value").is(assignee.getUsername()); + variables.getProcessVariableByName("bpm_sendEMailNotifications") + .assertThat().field("name").is("bpm_sendEMailNotifications") + .assertThat().field("type").is("d:boolean") + .assertThat().field("value").is(false); + variables.getProcessVariableByName("bpm_priority") + .assertThat().field("name").is("bpm_priority") + .assertThat().field("type").is("d:int") + .assertThat().field("value").is(CMISUtil.Priority.Normal.getLevel()); + } + + @Bug(id = "MNT-17438") + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify get all process variables with valid skip count parameter applied.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void getProcessVariablesWithValidSkipCount() throws Exception + { + variables = restClient.authenticateUser(admin).withWorkflowAPI().usingProcess(processModel).getProcessVariables(); + restClient.assertStatusCodeIs(HttpStatus.OK); + variables.assertThat().entriesListIsNotEmpty(); + + RestProcessVariableCollection variablesSkipped = restClient.authenticateUser(admin).withParams("skipCount=2").withWorkflowAPI().usingProcess(processModel).getProcessVariables(); + restClient.assertStatusCodeIs(HttpStatus.OK); + variablesSkipped + .assertThat().entriesListDoesNotContain("name", variables.getEntries().get(0).onModel().getName()) + .assertThat().entriesListDoesNotContain("name", variables.getEntries().get(1).onModel().getName()) + .assertThat().entriesListCountIs(variables.getEntries().size()-2) + .assertThat().paginationField("skipCount").is("2"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify get all process variables with negative skip count parameter applied.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void getProcessVariablesWithNegativeSkipCount() throws Exception + { + restClient.authenticateUser(admin).withParams("skipCount=-2").withWorkflowAPI().usingProcess(processModel).getProcessVariables(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT) + .containsErrorKey(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE) + .statusCodeIs(HttpStatus.BAD_REQUEST); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify get all process variables with not numeric skip count parameter applied.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void getProcessVariablesWithNonNumericSkipCount() throws Exception + { + restClient.authenticateUser(admin).withParams("skipCount=A").withWorkflowAPI().usingProcess(processModel).getProcessVariables(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "A")); + } + + @Bug(id = "MNT-17438") + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify get all process variables with valid maxItems parameter applied.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void getProcessVariablesWithValidMaxItems() throws Exception + { + variables = restClient.authenticateUser(admin).withWorkflowAPI().usingProcess(processModel).getProcessVariables(); + restClient.assertStatusCodeIs(HttpStatus.OK); + variables.assertThat().entriesListIsNotEmpty(); + + RestProcessVariableCollection variablesSkipped = restClient.authenticateUser(admin).withParams("maxItems=2").withWorkflowAPI().usingProcess(processModel).getProcessVariables(); + restClient.assertStatusCodeIs(HttpStatus.OK); + variablesSkipped + .assertThat().entriesListContains("name", variables.getEntries().get(0).onModel().getName()) + .assertThat().entriesListContains("name", variables.getEntries().get(1).onModel().getName()) + .assertThat().entriesListCountIs(2) + .assertThat().paginationField("maxItems").is("2"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify get all process variables with negative maxItems parameter applied.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void getProcessVariablesWithNegativeMaxItems() throws Exception + { + restClient.authenticateUser(admin).withParams("maxItems=-2").withWorkflowAPI().usingProcess(processModel).getProcessVariables(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) + .containsErrorKey(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE) + .statusCodeIs(HttpStatus.BAD_REQUEST); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify get all process variables with not numeric maxItems parameter applied.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void getProcessVariablesWithNonNumericMaxItems() throws Exception + { + restClient.authenticateUser(admin).withParams("maxItems=A").withWorkflowAPI().usingProcess(processModel).getProcessVariables(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "A")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify get all process variables call using admin user. Admin can see the process even if he isn't involved in it.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void getProcessVariablesWithPropertiesParameter() throws Exception + { + variables = restClient.authenticateUser(admin).withParams("properties=name").withWorkflowAPI().usingProcess(processModel).getProcessVariables(); + restClient.assertStatusCodeIs(HttpStatus.OK); + variables.assertThat().entriesListIsNotEmpty(); + variables.getProcessVariableByName("initiator") + .assertThat().field("name").is("initiator") + .assertThat().field("type").isNull() + .assertThat().field("value").isNull() + .assertThat().fieldsCount().is(1); + } +} From deb770a94d8c5f27a7e4cbf9ac2871442a066856 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Thu, 2 Feb 2017 15:33:02 +0200 Subject: [PATCH 0974/1491] REST API functional scenarios for TAS-2944, TAS-2945, TAS-2951 --- .../alfresco/rest/FunctionalCasesTests.java | 67 ++++++++++++++++++- 1 file changed, 65 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java b/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java index 7a6391536..e128a7817 100644 --- a/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java +++ b/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java @@ -1,10 +1,13 @@ package org.alfresco.rest; +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.model.RestActivityModelsCollection; import org.alfresco.rest.model.RestFavoriteSiteModel; import org.alfresco.rest.model.RestSiteMemberModel; import org.alfresco.rest.model.RestSiteMembershipRequestModelsCollection; import org.alfresco.rest.model.RestTaskModel; import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; @@ -21,12 +24,16 @@ public class FunctionalCasesTests extends RestTest private RestSiteMemberModel updatedMember; private RestSiteMembershipRequestModelsCollection returnedCollection; private RestFavoriteSiteModel restFavoriteSiteModel; + private RestActivityModelsCollection activities; + private UserModel user; @BeforeClass(alwaysRun=true) public void dataPreparation() throws Exception { - adminUserModel = dataUser.getAdminUser(); + adminUserModel = dataUser.getAdminUser(); + user = dataUser.createRandomTestUser(); siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + dataUser.addUserToSite(user, siteModel, UserRole.SiteManager); moderatedSite = dataSite.usingUser(adminUserModel).createModeratedRandomSite(); } @@ -177,4 +184,60 @@ public class FunctionalCasesTests extends RestTest restClient.withCoreAPI().usingSite(moderatedSite).getSiteMembers().assertThat().entriesListDoesNotContain("id", newMember.getUsername()); } -} + + /** + * Scenario: + * 1. Add file + * 2. Check file is included in person activities list + */ + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Add a file and check that activity is included in person activities") + public void addFileThenGetPersonActivities() throws Exception + { + FileModel file = dataContent.usingUser(user).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + activities = restClient.authenticateUser(user).withCoreAPI().usingAuthUser().getPersonActivitiesUntilEntriesCountIs(2); + activities.assertThat().entriesListIsNotEmpty() + .and().entriesListContains("siteId", siteModel.getId()) + .and().entriesListContains("activityType", "org.alfresco.documentlibrary.file-added") + .and().entriesListContains("activitySummary.objectId", file.getNodeRefWithoutVersion()); + } + + /** + * Scenario: + * 1. Add a comment to a file + * 2. Check that comment is included in person activities list + */ + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Add a comment to a file and check that activity is included in person activities") + public void addCommentThenGetPersonActivities() throws Exception + { + FileModel file = dataContent.usingUser(user).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(user).withCoreAPI().usingResource(file).addComment("new comment"); + activities = restClient.authenticateUser(user).withCoreAPI().usingAuthUser().getPersonActivitiesUntilEntriesCountIs(3); + activities.assertThat().entriesListIsNotEmpty() + .and().entriesListContains("siteId", siteModel.getId()) + .and().entriesListContains("activityType", "org.alfresco.comments.comment-created") + .and().entriesListContains("activitySummary.objectId", file.getNodeRefWithoutVersion()); + } + + /** + * Scenario: + * 1. Add file then delete it + * 2. Check action is included in person activities list + */ + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Add a file, delete it and check that activity is included in person activities") + public void addFileDeleteItThenGetPersonActivities() throws Exception + { + FileModel file = dataContent.usingUser(user).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + dataContent.usingUser(user).usingResource(file).deleteContent(); + activities = restClient.authenticateUser(user).withCoreAPI().usingAuthUser().getPersonActivitiesUntilEntriesCountIs(2); + activities.assertThat().entriesListIsNotEmpty() + .and().entriesListContains("siteId", siteModel.getId()) + .and().entriesListContains("activityType", "org.alfresco.documentlibrary.file-deleted") + .and().entriesListContains("activitySummary.objectId", file.getNodeRefWithoutVersion()); + } +} \ No newline at end of file From d21569e494152764588f3ce40c9d8a8d379c93e3 Mon Sep 17 00:00:00 2001 From: cagache Date: Thu, 2 Feb 2017 15:45:43 +0200 Subject: [PATCH 0975/1491] check entriesListCount when skipCount parameter is applied --- e2e-test/java/org/alfresco/rest/tags/GetTagsFullTests.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/tags/GetTagsFullTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagsFullTests.java index c6dace4c7..c166a08c2 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetTagsFullTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetTagsFullTests.java @@ -75,7 +75,8 @@ public class GetTagsFullTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); tagsWithSkipCount.assertThat().entriesListDoesNotContain("tag", firstTag.getTag()) - .assertThat().entriesListDoesNotContain("tag", secondTag.getTag()); + .assertThat().entriesListDoesNotContain("tag", secondTag.getTag()) + .assertThat().entriesListCountIs(returnedCollection.getEntries().size()-2); tagsWithSkipCount.assertThat().paginationField("skipCount").is("2"); } From 99921aac7ebe2650970a44fba5412447bae11a50 Mon Sep 17 00:00:00 2001 From: Andrei Rusu Date: Thu, 2 Feb 2017 16:54:27 +0200 Subject: [PATCH 0976/1491] add tests for getTagFullTests --- .../alfresco/rest/tags/GetTagFullTests.java | 92 +++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/tags/GetTagFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/tags/GetTagFullTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagFullTests.java new file mode 100644 index 000000000..db657220d --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/tags/GetTagFullTests.java @@ -0,0 +1,92 @@ +package org.alfresco.rest.tags; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestTagModel; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.RandomData; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class GetTagFullTests extends RestTest +{ + private UserModel adminUserModel; + private SiteModel siteModel; + private ListUserWithRoles usersWithRoles; + private FileModel document; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + restClient.authenticateUser(adminUserModel); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, + executionType = ExecutionType.REGRESSION, description = "Check that properties filter is applied when getting tag using Manager user.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) + public void checkPropertiesFilterIsApplied() throws JsonToModelConversionException, Exception + { + String tagValue = RandomData.getRandomName("tag"); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(tagValue); + + RestTagModel returnedTag = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withParams("properties=id,tag").withCoreAPI().getTag(tag); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedTag.assertThat().field("id").is(tag.getId()) + .assertThat().field("tag").is(tag.getTag().toLowerCase()) + .assertThat().fieldsCount().is(2); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, + executionType = ExecutionType.REGRESSION, description = "Check that Manager user can get tag of a folder.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) + public void getTagOfAFolder() throws JsonToModelConversionException, Exception + { + String tagValue = RandomData.getRandomName("tagFolder"); + FolderModel folder = dataContent.usingAdmin().usingSite(siteModel).createFolder(); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + RestTagModel tag = restClient.withCoreAPI().usingResource(folder).addTag(tagValue); + + RestTagModel returnedTag = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().getTag(tag); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedTag.assertThat().field("tag").is(tagValue.toLowerCase()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, + executionType = ExecutionType.REGRESSION, description = "Check default error model schema. Use invalid skipCount parameter.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) + public void checkDefaultErrorModelSchema() throws JsonToModelConversionException, Exception + { + String tagValue = RandomData.getRandomName("tag"); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(tagValue); + + restClient.withParams("skipCount=abc").withCoreAPI().getTag(tag); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(RestErrorModel.INVALID_SKIPCOUNT) + .containsSummary(RestErrorModel.INVALID_SKIPCOUNT) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } +} \ No newline at end of file From 821a8089f20e644b83ff701534ad28760f0c8388 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Thu, 2 Feb 2017 16:55:14 +0200 Subject: [PATCH 0977/1491] updates due to TaskModel changes --- .../rest/workflow/processes/GetProcessesCoreTests.java | 4 ++-- .../rest/workflow/processes/GetProcessesFullTests.java | 4 ++-- .../rest/workflow/processes/GetProcessesSanityTests.java | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesCoreTests.java index 95ab411c2..249792319 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesCoreTests.java @@ -74,8 +74,8 @@ public class GetProcessesCoreTests extends RestTest processes.assertThat().entriesListIsNotEmpty(); List processesList = processes.getEntries(); processesList.get(0).onModel().assertThat().field("id").is(process3.getId()); - processesList.get(1).onModel().assertThat().field("id").is(task2.getNodeRef()); - processesList.get(2).onModel().assertThat().field("id").is(task1.getNodeRef()); + processesList.get(1).onModel().assertThat().field("id").is(task2.getProcessId()); + processesList.get(2).onModel().assertThat().field("id").is(task1.getProcessId()); } @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesFullTests.java index 799fb5f39..96bb3d92b 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesFullTests.java @@ -117,8 +117,8 @@ public class GetProcessesFullTests extends RestTest processes.assertThat().entriesListIsNotEmpty(); List processesList = processes.getEntries(); processesList.get(0).onModel().assertThat().fieldsCount().is(1).and().field("id").is(process3.getId()); - processesList.get(1).onModel().assertThat().fieldsCount().is(1).and().field("id").is(task2.getNodeRef()); - processesList.get(2).onModel().assertThat().fieldsCount().is(1).and().field("id").is(task1.getNodeRef()); + processesList.get(1).onModel().assertThat().fieldsCount().is(1).and().field("id").is(task2.getProcessId()); + processesList.get(2).onModel().assertThat().fieldsCount().is(1).and().field("id").is(task1.getProcessId()); } @Bug(id = "REPO-1958") diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java index ffdf90930..3a3a62bf5 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java @@ -43,7 +43,7 @@ public class GetProcessesSanityTests extends RestTest { allProcesses = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getProcesses(); restClient.assertStatusCodeIs(HttpStatus.OK); - allProcesses.assertThat().entriesListContains("id", task.getNodeRef()); + allProcesses.assertThat().entriesListContains("id", task.getProcessId()); } @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, @@ -53,7 +53,7 @@ public class GetProcessesSanityTests extends RestTest { allProcesses = restClient.authenticateUser(assignee).withWorkflowAPI().getProcesses(); restClient.assertStatusCodeIs(HttpStatus.OK); - allProcesses.assertThat().entriesListContains("id", task.getNodeRef()); + allProcesses.assertThat().entriesListContains("id", task.getProcessId()); } @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, @@ -63,7 +63,7 @@ public class GetProcessesSanityTests extends RestTest { allProcesses = restClient.authenticateUser(anotherUser).withWorkflowAPI().getProcesses(); restClient.assertStatusCodeIs(HttpStatus.OK); - allProcesses.assertThat().entriesListDoesNotContain("id", task.getNodeRef()); + allProcesses.assertThat().entriesListDoesNotContain("id", task.getProcessId()); } @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, @@ -73,6 +73,6 @@ public class GetProcessesSanityTests extends RestTest { allProcesses = restClient.authenticateUser(dataUser.getAdminUser()).withWorkflowAPI().getProcesses(); restClient.assertStatusCodeIs(HttpStatus.OK); - allProcesses.assertThat().entriesListContains("id", task.getNodeRef()); + allProcesses.assertThat().entriesListContains("id", task.getProcessId()); } } From eb72553b5e9b7e2fe8be550865c67d5ed9d3f351 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Thu, 2 Feb 2017 16:57:14 +0200 Subject: [PATCH 0978/1491] added full tests for getTask --- .../rest/workflow/tasks/GetTaskFullTests.java | 137 ++++++++++++++++++ 1 file changed, 137 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFullTests.java new file mode 100644 index 000000000..7d72d05a3 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFullTests.java @@ -0,0 +1,137 @@ +package org.alfresco.rest.workflow.tasks; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.dataprep.CMISUtil.Priority; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestTaskModel; +import org.alfresco.rest.model.RestTaskModelsCollection; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.ProcessModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TaskModel; +import org.alfresco.utility.model.TestGroup; +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; + +/** + * + * @author Cristina Axinte + * + */ +public class GetTaskFullTests extends RestTest +{ + UserModel userModel; + SiteModel siteModel; + UserModel candidateUser; + FileModel fileModel; + UserModel assigneeUser; + TaskModel taskModel; + RestTaskModel restTaskModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + assigneeUser = dataUser.createRandomTestUser(); + taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, + executionType = ExecutionType.REGRESSION, description = "Verify user who started a task gets the task with empty taskId with Rest API") + public void starterUserGetsTaskWithEmptyTaskId() throws Exception + { + restClient.authenticateUser(userModel).withWorkflowAPI(); + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "tasks/{taskId}", ""); + RestTaskModelsCollection tasks = restClient.processModels(RestTaskModelsCollection.class, request); + + restClient.assertStatusCodeIs(HttpStatus.OK); + tasks.assertThat().entriesListIsNotEmpty() + .and().entriesListCountIs(1) + .and().entriesListContains("id", taskModel.getId()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, + executionType = ExecutionType.REGRESSION, description = "Verify user who started a task gets the task with properties parameter with Rest API") + public void starterUserGetsTaskWithPropertiesParameter() throws Exception + { + restTaskModel = restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).usingParams("properties=id,assignee,formResourceKey").getTask(); + + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().fieldsCount().is(3) + .and().field("id").is(taskModel.getId()) + .and().field("assignee").is(taskModel.getAssignee()) + .and().field("formResourceKey").is("wf:adhocTask") + .and().field("processDefinitionId").isNull() + .and().field("processId").isNull(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, + executionType = ExecutionType.REGRESSION, description = "Verify user who started a task gets the task after it is deleted with Rest API") + public void starterUserGetsDeletedTask() throws Exception + { + restTaskModel = restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).getTask(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()); + + ProcessModel process = new ProcessModel(); + process.setId(taskModel.getProcessId()); + dataWorkflow.usingUser(userModel).deleteProcess(process); + + restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).getTask(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, taskModel.getId())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, + executionType = ExecutionType.REGRESSION, description = "Check that for admin network gets task only from its network.") + public void adminTenantGetsTaskOnlyFromItsNetwork() throws Exception + { + UserModel adminUser = dataUser.getAdminUser(); + restClient.authenticateUser(adminUser); + + UserModel adminTenant1 = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenant1); + + UserModel tenantUser1 = dataUser.usingUser(adminTenant1).createUserWithTenant("userTenant1"); + UserModel tenantUserAssignee1 = dataUser.usingUser(adminTenant1).createUserWithTenant("userTenantAssignee1"); + + RestProcessModel processOnTenant1 = restClient.authenticateUser(tenantUser1).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee1, false, Priority.Low); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + UserModel adminTenant2 = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenant2); + + UserModel tenantUser2 = dataUser.usingUser(adminTenant2).createUserWithTenant("userTenant2"); + UserModel tenantUserAssignee2 = dataUser.usingUser(adminTenant2).createUserWithTenant("userTenantAssignee2"); + + RestProcessModel processOnTenant2 = restClient.authenticateUser(tenantUser2).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee2, false, Priority.Normal); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestTaskModelsCollection tenantTasks2 = restClient.authenticateUser(tenantUser2).withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + tenantTasks2.assertThat().entriesListIsNotEmpty() + .and().entriesListCountIs(1) + .and().entriesListContains("assignee", String.format("userTenantAssignee2@%s", tenantUserAssignee2.getDomain().toLowerCase())) + .and().entriesListContains("processId", processOnTenant2.getId()) + .and().entriesListDoesNotContain("assignee", String.format("userTenantAssignee1@%s", tenantUserAssignee1.getDomain().toLowerCase())) + .and().entriesListDoesNotContain("processId", processOnTenant1.getId()); + + } +} From bd689d42ec8ec40a2296cbceddaa9fce090c85b6 Mon Sep 17 00:00:00 2001 From: mionescu Date: Thu, 2 Feb 2017 16:58:02 +0200 Subject: [PATCH 0979/1491] test- added new test cases: Core/Full --- .../DeleteProcessVariableCoreTests.java | 68 ++++++++---- .../DeleteProcessVariableFullTests.java | 102 ++++++++++++++++++ 2 files changed, 152 insertions(+), 18 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableCoreTests.java index aea7b66b4..a0700b405 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableCoreTests.java @@ -2,6 +2,7 @@ package org.alfresco.rest.workflow.processes; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.rest.model.RestProcessVariableModel; @@ -25,7 +26,7 @@ public class DeleteProcessVariableCoreTests extends RestTest { private FileModel document; private SiteModel siteModel; - private UserModel userWhoStartsTask, assignee; + private UserModel userWhoStartsTask, assignee, adminUser; private RestProcessModel restProcessModel; private ProcessModel processModel; private RestProcessVariableModel variableModel; @@ -33,8 +34,9 @@ public class DeleteProcessVariableCoreTests extends RestTest @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception { + adminUser = dataUser.getAdminUser(); userWhoStartsTask = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); processModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document) @@ -51,22 +53,12 @@ public class DeleteProcessVariableCoreTests extends RestTest .getProcesses().getProcessModelByProcessDefId(processModel.getId()); restClient.withWorkflowAPI().usingProcess(restProcessModel).deleteProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, variableModel.getName())); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Delete empty process variable") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) - public void deleteEmptyProcessVariable() throws Exception - { - variableModel = new RestProcessVariableModel("","", "d:text"); - restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() - .getProcesses().getProcessModelByProcessDefId(processModel.getId()); - restClient.withWorkflowAPI().usingProcess(restProcessModel).deleteProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) - .assertLastError().containsSummary(RestErrorModel.DELETE_EMPTY_ARGUMENT); - } - + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, variableModel.getName())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Delete process variable twice") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) @@ -83,4 +75,44 @@ public class DeleteProcessVariableCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, variableModel.getName())); } + + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Remove process variables with empty processId") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + public void deleteProcessVariableEmptyProcessId() throws JsonToModelConversionException, Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() + .getProcesses().getProcessModelByProcessDefId(processModel.getId()); + restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restProcessModel.setId(""); + restClient.withWorkflowAPI().usingProcess(restProcessModel).deleteProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Delete process variable with admin.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + public void deleteProcessVariableWithAdmin() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() + .getProcesses().getProcessModelByProcessDefId(processModel.getId()); + restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(adminUser).withWorkflowAPI().usingProcess(processModel) + .deleteProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() + .assertThat().entriesListDoesNotContain("name", variableModel.getName()); + } + } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableFullTests.java new file mode 100644 index 000000000..0d557c0db --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableFullTests.java @@ -0,0 +1,102 @@ +package org.alfresco.rest.workflow.processes; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.dataprep.CMISUtil.Priority; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestProcessVariableModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.ProcessModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class DeleteProcessVariableFullTests extends RestTest +{ + private FileModel document; + private SiteModel siteModel; + private UserModel userWhoStartsTask, assignee, anotherUser; + private RestProcessModel restProcessModel; + private ProcessModel processModel; + private RestProcessVariableModel variableModel, updatedVariable; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + userWhoStartsTask = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + anotherUser = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + processModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document) + .createSingleReviewerTaskAndAssignTo(assignee); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Delete empty process variable") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void deleteEmptyProcessVariable() throws Exception + { + variableModel = new RestProcessVariableModel("","", "d:text"); + restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() + .getProcesses().getProcessModelByProcessDefId(processModel.getId()); + restClient.withWorkflowAPI().usingProcess(restProcessModel).deleteProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) + .assertLastError().containsSummary(RestErrorModel.DELETE_EMPTY_ARGUMENT) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .containsErrorKey(RestErrorModel.DELETE_EMPTY_ARGUMENT) + .stackTraceIs(RestErrorModel.STACKTRACE);; + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Delete process variable using any user.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void deleteProcessVariableWithAnyUser() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(anotherUser).withWorkflowAPI() + .addProcess("activitiAdhoc", anotherUser, false, Priority.Normal); + + variableModel = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + variableModel.assertThat().field("name").is(variableModel.getName()).and().field("type") + .is(variableModel.getType()).and().field("value") + .is(variableModel.getValue()); + + restClient.authenticateUser(anotherUser).withWorkflowAPI().usingProcess(processModel) + .deleteProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() + .assertThat().entriesListDoesNotContain("name", variableModel.getName()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Add a new process varaiables, update the variable and then delete.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void createUpdateDeleteVariableProcess() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() + .getProcesses().getProcessModelByProcessDefId(processModel.getId()); + restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + variableModel.setValue("newValue"); + updatedVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedVariable.assertThat().field("value").is("newValue"); + + restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingProcess(processModel) + .deleteProcessVariable(updatedVariable); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() + .assertThat().entriesListDoesNotContain("name", updatedVariable.getName()); + } + +} From 200db1d1697c4e76c64f09b30d1a993172051459 Mon Sep 17 00:00:00 2001 From: cagache Date: Thu, 2 Feb 2017 17:59:51 +0200 Subject: [PATCH 0980/1491] TAS - 2905 -getProcessItems --- .../processes/GetProcessItemsFullTests.java | 253 ++++++++++++++++++ .../processes/GetProcessItemsSanityTests.java | 13 +- .../GetProcessVariablesFullTests.java | 2 +- 3 files changed, 263 insertions(+), 5 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsFullTests.java new file mode 100644 index 000000000..11293777c --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsFullTests.java @@ -0,0 +1,253 @@ +package org.alfresco.rest.workflow.processes; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestItemModelsCollection; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Created by Claudia Agache on 2/2/2017. + */ +public class GetProcessItemsFullTests extends RestTest +{ + private FileModel document1, document2, document3; + private SiteModel siteModel; + private UserModel userWhoStartsTask, assignee, adminTenantUser, tenantUser, tenantUserAssignee; + private RestProcessModel processModel; + private RestItemModelsCollection items; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + userWhoStartsTask = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); + document1 = dataContent.usingUser(userWhoStartsTask).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + document2 = dataContent.usingUser(userWhoStartsTask).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + document3 = dataContent.usingUser(userWhoStartsTask).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + } + +// @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, +// description = "Get process items using admin from different network") +// @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL, TestGroup.NETWORKS }) +// public void getProcessItemsUsingAdminUserFromDifferentNetwork() throws Exception +// { +// adminTenantUser = UserModel.getAdminTenantUser(); +// restClient.authenticateUser(dataUser.getAdminUser()).usingTenant().createTenant(adminTenantUser); +// tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); +// tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); +// processModel = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee, false, CMISUtil.Priority.Normal); +// +// siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); +// document1 = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); +// restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document1); +// restClient.assertStatusCodeIs(HttpStatus.CREATED); +// +// UserModel adminTenantUser2 = UserModel.getAdminTenantUser(); +// restClient.authenticateUser(dataUser.getAdminUser()).usingTenant().createTenant(adminTenantUser2); +// +// restClient.authenticateUser(adminTenantUser2).withWorkflowAPI().usingProcess(processModel).getProcessItems(); +// restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) +// .assertLastError().containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT); +// } +// +// @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, +// description = "Get process items using admin from different network") +// @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL, TestGroup.NETWORKS }) +// public void getProcessItemsReturnsOnlyItemsInsideNetwork() throws Exception +// { +// adminTenantUser = UserModel.getAdminTenantUser(); +// restClient.authenticateUser(dataUser.getAdminUser()).usingTenant().createTenant(adminTenantUser); +// tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); +// tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); +// processModel = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee, false, CMISUtil.Priority.Normal); +// +// siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); +// document1 = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); +// restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document1); +// restClient.assertStatusCodeIs(HttpStatus.CREATED); +// +// UserModel adminTenantUser2 = UserModel.getAdminTenantUser(); +// restClient.authenticateUser(dataUser.getAdminUser()).usingTenant().createTenant(adminTenantUser2); +// RestProcessModel processModel2 = restClient.authenticateUser(adminTenantUser2).withWorkflowAPI().addProcess("activitiAdhoc", adminTenantUser2, false, CMISUtil.Priority.Normal); +// +// SiteModel siteModel2 = dataSite.usingUser(adminTenantUser2).createPublicRandomSite(); +// document2 = dataContent.usingUser(adminTenantUser2).usingSite(siteModel2).createContent(CMISUtil.DocumentType.TEXT_PLAIN); +// restClient.authenticateUser(adminTenantUser2).withWorkflowAPI().usingProcess(processModel2).addProcessItem(document2); +// restClient.assertStatusCodeIs(HttpStatus.CREATED); +// +// items = restClient.withWorkflowAPI().usingProcess(processModel2).getProcessItems(); +// restClient.assertStatusCodeIs(HttpStatus.OK); +// items.assertThat().entriesListDoesNotContain("name", document1.getName()); +// } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Get process items for process without items") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL}) + public void getProcessItemsForProcessWithoutItems() throws Exception + { + processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.Normal); + items = restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems(); + restClient.assertStatusCodeIs(HttpStatus.OK); + items.assertThat().entriesListIsEmpty(); + } + + @Bug(id = "MNT-17438") + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Get process items for process with valid skipCount parameter") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL}) + public void getProcessItemsWithValidSkipCount() throws Exception + { + processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.Normal); + restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document1); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document3); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + items = restClient.authenticateUser(assignee).withParams("skipCount=2").withWorkflowAPI().usingProcess(processModel).getProcessItems(); + restClient.assertStatusCodeIs(HttpStatus.OK); + items.assertThat().entriesListContains("name", document3.getName()) + .assertThat().entriesListDoesNotContain("name", document1.getName()) + .assertThat().entriesListDoesNotContain("name", document2.getName()) + .assertThat().entriesListCountIs(1) + .assertThat().paginationField("skipCount").is("2"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Get process items for process with negative skipCount") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL}) + public void getProcessItemsWithNegativeSkipCount() throws Exception + { + processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.Normal); + restClient.authenticateUser(assignee).withParams("skipCount=-2").withWorkflowAPI().usingProcess(processModel).getProcessItems(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT) + .containsErrorKey(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE) + .statusCodeIs(HttpStatus.BAD_REQUEST); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Get process items for process with non numeric skipCount") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL}) + public void getProcessItemsWithNonNumericSkipCount() throws Exception + { + processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.Normal); + restClient.authenticateUser(assignee).withParams("skipCount=A").withWorkflowAPI().usingProcess(processModel).getProcessItems(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "A")); + } + + @Bug(id = "MNT-17438") + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Get process items for process with valid maxItems parameter") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL}) + public void getProcessItemsWithValidMaxItems() throws Exception + { + processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.Normal); + restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document1); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document3); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + items = restClient.authenticateUser(assignee).withParams("maxItems=2").withWorkflowAPI().usingProcess(processModel).getProcessItems(); + restClient.assertStatusCodeIs(HttpStatus.OK); + items.assertThat().entriesListDoesNotContain("name", document3.getName()) + .assertThat().entriesListContains("name", document1.getName()) + .assertThat().entriesListContains("name", document2.getName()) + .assertThat().entriesListCountIs(2) + .assertThat().paginationField("maxItems").is("2"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Get process items for process with negative maxItems") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL}) + public void getProcessItemsWithNegativeMaxItems() throws Exception + { + processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.Normal); + restClient.authenticateUser(assignee).withParams("maxItems=-2").withWorkflowAPI().usingProcess(processModel).getProcessItems(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) + .containsErrorKey(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE) + .statusCodeIs(HttpStatus.BAD_REQUEST); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Get process items for process with non numeric maxItems") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL}) + public void getProcessItemsWithNonNumericMaxItems() throws Exception + { + processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.Normal); + restClient.authenticateUser(assignee).withParams("maxItems=A").withWorkflowAPI().usingProcess(processModel).getProcessItems(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "A")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify get all process items with properties parameter.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void getProcessItemsWithPropertiesParameter() throws Exception + { + processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.Normal); + restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document1); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + items = restClient.authenticateUser(assignee).withParams("properties=createdBy,name,mimeType,size").withWorkflowAPI().usingProcess(processModel).getProcessItems(); + restClient.assertStatusCodeIs(HttpStatus.OK); + items.assertThat().entriesListIsNotEmpty(); + items.getProcessItemByName(document1.getName()) + .assertThat().field("createdBy").is(userWhoStartsTask.getUsername()) + .assertThat().field("name").is(document1.getName()) + .assertThat().field("mimeType").is(document1.getFileType().mimeType) + .assertThat().field("size").isNotNull() + .assertThat().field("modifiedAt").isNull() + .assertThat().field("modifiedBy").isNull() + .assertThat().field("id").isNull() + .assertThat().field("createdAt ").isNull() + .assertThat().fieldsCount().is(4); + } + + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify get all process items after process is deleted.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void getProcessItemsAfterDeletingProcess() throws Exception + { + processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.Normal); + restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document1); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.withWorkflowAPI().usingProcess(processModel).deleteProcess(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + items = restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(processModel).getProcessItems(); + restClient.assertStatusCodeIs(HttpStatus.OK); + items.assertThat().entriesListIsNotEmpty(); + items.getProcessItemByName(document1.getName()) + .assertThat().field("createdBy").is(userWhoStartsTask.getUsername()) + .assertThat().field("name").is(document1.getName()) + .assertThat().field("mimeType").is(document1.getFileType().mimeType) + .assertThat().field("size").isNotNull() + .assertThat().field("modifiedAt").isNotNull() + .assertThat().field("modifiedBy").is(userWhoStartsTask.getUsername()) + .assertThat().field("id").is(document1.getNodeRefWithoutVersion()) + .assertThat().field("createdAt ").isNotNull(); + } +} diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsSanityTests.java index 8e2adf8a7..7f4ec57ed 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsSanityTests.java @@ -32,7 +32,7 @@ public class GetProcessItemsSanityTests extends RestTest userWhoStartsTask = dataUser.createRandomTestUser(); assignee = dataUser.createRandomTestUser(); siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + document = dataContent.usingUser(userWhoStartsTask).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); } @@ -67,11 +67,16 @@ public class GetProcessItemsSanityTests extends RestTest restClient.authenticateUser(dataUser.getAdminUser()).usingTenant().createTenant(adminTenantUser); tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); - restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee, false, Priority.Normal); + processModel = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee, false, Priority.Normal); + + siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); + document = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); + + restClient.assertStatusCodeIs(HttpStatus.CREATED); - processModel = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); items = restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems(); restClient.assertStatusCodeIs(HttpStatus.OK); - items.assertThat().entriesListIsNotEmpty(); + items.assertThat().entriesListContains("name", document.getName()); } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesFullTests.java index d201a6337..695e29683 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesFullTests.java @@ -145,7 +145,7 @@ public class GetProcessVariablesFullTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify get all process variables call using admin user. Admin can see the process even if he isn't involved in it.") + description = "Verify get all process variables with properties parameter.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) public void getProcessVariablesWithPropertiesParameter() throws Exception { From 3076115877c46ed10d2fa62ba77ba1be46e5894c Mon Sep 17 00:00:00 2001 From: cagache Date: Thu, 2 Feb 2017 18:00:53 +0200 Subject: [PATCH 0981/1491] TAS - 2905 -getProcessItems --- .../processes/GetProcessItemsFullTests.java | 106 +++++++++--------- 1 file changed, 53 insertions(+), 53 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsFullTests.java index 11293777c..aba458d6c 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsFullTests.java @@ -38,59 +38,59 @@ public class GetProcessItemsFullTests extends RestTest document3 = dataContent.usingUser(userWhoStartsTask).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); } -// @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, -// description = "Get process items using admin from different network") -// @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL, TestGroup.NETWORKS }) -// public void getProcessItemsUsingAdminUserFromDifferentNetwork() throws Exception -// { -// adminTenantUser = UserModel.getAdminTenantUser(); -// restClient.authenticateUser(dataUser.getAdminUser()).usingTenant().createTenant(adminTenantUser); -// tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); -// tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); -// processModel = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee, false, CMISUtil.Priority.Normal); -// -// siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); -// document1 = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); -// restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document1); -// restClient.assertStatusCodeIs(HttpStatus.CREATED); -// -// UserModel adminTenantUser2 = UserModel.getAdminTenantUser(); -// restClient.authenticateUser(dataUser.getAdminUser()).usingTenant().createTenant(adminTenantUser2); -// -// restClient.authenticateUser(adminTenantUser2).withWorkflowAPI().usingProcess(processModel).getProcessItems(); -// restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) -// .assertLastError().containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT); -// } -// -// @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, -// description = "Get process items using admin from different network") -// @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL, TestGroup.NETWORKS }) -// public void getProcessItemsReturnsOnlyItemsInsideNetwork() throws Exception -// { -// adminTenantUser = UserModel.getAdminTenantUser(); -// restClient.authenticateUser(dataUser.getAdminUser()).usingTenant().createTenant(adminTenantUser); -// tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); -// tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); -// processModel = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee, false, CMISUtil.Priority.Normal); -// -// siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); -// document1 = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); -// restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document1); -// restClient.assertStatusCodeIs(HttpStatus.CREATED); -// -// UserModel adminTenantUser2 = UserModel.getAdminTenantUser(); -// restClient.authenticateUser(dataUser.getAdminUser()).usingTenant().createTenant(adminTenantUser2); -// RestProcessModel processModel2 = restClient.authenticateUser(adminTenantUser2).withWorkflowAPI().addProcess("activitiAdhoc", adminTenantUser2, false, CMISUtil.Priority.Normal); -// -// SiteModel siteModel2 = dataSite.usingUser(adminTenantUser2).createPublicRandomSite(); -// document2 = dataContent.usingUser(adminTenantUser2).usingSite(siteModel2).createContent(CMISUtil.DocumentType.TEXT_PLAIN); -// restClient.authenticateUser(adminTenantUser2).withWorkflowAPI().usingProcess(processModel2).addProcessItem(document2); -// restClient.assertStatusCodeIs(HttpStatus.CREATED); -// -// items = restClient.withWorkflowAPI().usingProcess(processModel2).getProcessItems(); -// restClient.assertStatusCodeIs(HttpStatus.OK); -// items.assertThat().entriesListDoesNotContain("name", document1.getName()); -// } + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Get process items using admin from different network") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL, TestGroup.NETWORKS }) + public void getProcessItemsUsingAdminUserFromDifferentNetwork() throws Exception + { + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(dataUser.getAdminUser()).usingTenant().createTenant(adminTenantUser); + tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); + processModel = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee, false, CMISUtil.Priority.Normal); + + siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); + document1 = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document1); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + UserModel adminTenantUser2 = UserModel.getAdminTenantUser(); + restClient.authenticateUser(dataUser.getAdminUser()).usingTenant().createTenant(adminTenantUser2); + + restClient.authenticateUser(adminTenantUser2).withWorkflowAPI().usingProcess(processModel).getProcessItems(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Get process items using admin from different network") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL, TestGroup.NETWORKS }) + public void getProcessItemsReturnsOnlyItemsInsideNetwork() throws Exception + { + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(dataUser.getAdminUser()).usingTenant().createTenant(adminTenantUser); + tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); + processModel = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee, false, CMISUtil.Priority.Normal); + + siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); + document1 = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document1); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + UserModel adminTenantUser2 = UserModel.getAdminTenantUser(); + restClient.authenticateUser(dataUser.getAdminUser()).usingTenant().createTenant(adminTenantUser2); + RestProcessModel processModel2 = restClient.authenticateUser(adminTenantUser2).withWorkflowAPI().addProcess("activitiAdhoc", adminTenantUser2, false, CMISUtil.Priority.Normal); + + SiteModel siteModel2 = dataSite.usingUser(adminTenantUser2).createPublicRandomSite(); + document2 = dataContent.usingUser(adminTenantUser2).usingSite(siteModel2).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + restClient.authenticateUser(adminTenantUser2).withWorkflowAPI().usingProcess(processModel2).addProcessItem(document2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + items = restClient.withWorkflowAPI().usingProcess(processModel2).getProcessItems(); + restClient.assertStatusCodeIs(HttpStatus.OK); + items.assertThat().entriesListDoesNotContain("name", document1.getName()); + } @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Get process items for process without items") From 682b16b73e7f9ff571f6bd8062a896f5afa3d96c Mon Sep 17 00:00:00 2001 From: mionescu Date: Fri, 3 Feb 2017 11:56:57 +0200 Subject: [PATCH 0982/1491] test- added new test cases in FULL --- .../DeleteProcessVariableCoreTests.java | 2 +- .../DeleteProcessVariableFullTests.java | 255 ++++++++++++++++-- 2 files changed, 229 insertions(+), 28 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableCoreTests.java index a0700b405..ba4eec3e6 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableCoreTests.java @@ -113,6 +113,6 @@ public class DeleteProcessVariableCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() .assertThat().entriesListDoesNotContain("name", variableModel.getName()); - } + } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableFullTests.java index 0d557c0db..40ec2877b 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableFullTests.java @@ -21,41 +21,44 @@ public class DeleteProcessVariableFullTests extends RestTest { private FileModel document; private SiteModel siteModel; - private UserModel userWhoStartsTask, assignee, anotherUser; + private UserModel userWhoStartsTask, assignee, anotherUser, adminUser; private RestProcessModel restProcessModel; private ProcessModel processModel; private RestProcessVariableModel variableModel, updatedVariable; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception - { + { + adminUser = dataUser.getAdminUser(); userWhoStartsTask = dataUser.createRandomTestUser(); assignee = dataUser.createRandomTestUser(); anotherUser = dataUser.createRandomTestUser(); siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - processModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document) - .createSingleReviewerTaskAndAssignTo(assignee); + processModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createSingleReviewerTaskAndAssignTo(assignee); } - - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Delete empty process variable") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) public void deleteEmptyProcessVariable() throws Exception { - variableModel = new RestProcessVariableModel("","", "d:text"); - restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() - .getProcesses().getProcessModelByProcessDefId(processModel.getId()); - restClient.withWorkflowAPI().usingProcess(restProcessModel).deleteProcessVariable(variableModel); + variableModel = new RestProcessVariableModel("", "", "bpm:workflowPackage"); + restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getProcesses() + .getProcessModelByProcessDefId(processModel.getId()); + + restClient.withWorkflowAPI().usingProcess(restProcessModel) + .deleteProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) - .assertLastError().containsSummary(RestErrorModel.DELETE_EMPTY_ARGUMENT) + .assertLastError() + .containsSummary(RestErrorModel.DELETE_EMPTY_ARGUMENT) .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) .containsErrorKey(RestErrorModel.DELETE_EMPTY_ARGUMENT) - .stackTraceIs(RestErrorModel.STACKTRACE);; + .stackTraceIs(RestErrorModel.STACKTRACE); } - + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Delete process variable using any user.") + description = "Delete process variable using any user.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) public void deleteProcessVariableWithAnyUser() throws Exception { @@ -68,35 +71,233 @@ public class DeleteProcessVariableFullTests extends RestTest variableModel.assertThat().field("name").is(variableModel.getName()).and().field("type") .is(variableModel.getType()).and().field("value") .is(variableModel.getValue()); - + restClient.authenticateUser(anotherUser).withWorkflowAPI().usingProcess(processModel) .deleteProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() - .assertThat().entriesListDoesNotContain("name", variableModel.getName()); + .assertThat() + .entriesListDoesNotContain("name", variableModel.getName()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Add a new process varaiables, update the variable and then delete.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void createUpdateDeleteProcessVariable() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getProcesses() + .getProcessModelByProcessDefId(processModel.getId()); + restClient.withWorkflowAPI().usingProcess(restProcessModel) + .addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + variableModel.setValue("newValue"); + updatedVariable = restClient.withWorkflowAPI().usingProcess(processModel) + .updateProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedVariable.assertThat().field("value").is("newValue"); + + restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingProcess(processModel) + .deleteProcessVariable(updatedVariable); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() + .assertThat() + .entriesListDoesNotContain("name", updatedVariable.getName()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Delete process then delete process variables, status OK should be returned") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void deleteProcessVariablesForADeletedProcess() throws Exception + { + UserModel userWhoStartsTask = dataUser.createRandomTestUser(); + UserModel assignee = dataUser.createRandomTestUser(); + + RestProcessModel processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() + .addProcess("activitiAdhoc", assignee, false, Priority.Normal); + + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() + .getProcesses().getProcessModelByProcessDefId(processModel.getId()); + restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingProcess(processModel) + .deleteProcess(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withWorkflowAPI().usingProcess(processModel).deleteProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, processModel.getId())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Delete process variable using by the user who started the process.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void deleteProcessVariableByUserThatStartedTheProcess() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() + .addProcess("activitiAdhoc", assignee, false, Priority.Normal); + + restProcessModel = restClient.withWorkflowAPI().getProcesses() + .getProcessModelByProcessDefId(processModel.getId()); + restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.withWorkflowAPI().usingProcess(processModel) + .deleteProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() + .assertThat() + .entriesListDoesNotContain("name", variableModel.getName()); } @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Add a new process varaiables, update the variable and then delete.") + description = "Delete process variable using by the user involved in the process.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) - public void createUpdateDeleteVariableProcess() throws Exception - { + public void deleteProcessVariableByUserInvolvedInTheProcess() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() + .addProcess("activitiAdhoc", assignee, false, Priority.Normal); + + restProcessModel = restClient.withWorkflowAPI().getProcesses() + .getProcessModelByProcessDefId(processModel.getId()); + restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(processModel) + .deleteProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() + .assertThat() + .entriesListDoesNotContain("name", variableModel.getName()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Delete process variable with invalid type") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void deleteProcessVariableInvalidType() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() + .getProcesses().getProcessModelByProcessDefId(processModel.getId()); + restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + variableModel.setType("invalid-type"); + restClient.withWorkflowAPI().usingProcess(restProcessModel).deleteProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() + .assertThat() + .entriesListDoesNotContain("name", variableModel.getName()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Delete process variable by non assigned user") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void deleteProcessVarialbleByNonAssignedUser() throws Exception + { + UserModel nonAssigned = dataUser.createRandomTestUser(); variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() .getProcesses().getProcessModelByProcessDefId(processModel.getId()); restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); - variableModel.setValue("newValue"); - updatedVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedVariable.assertThat().field("value").is("newValue"); + restClient.authenticateUser(nonAssigned).withWorkflowAPI().usingProcess(restProcessModel) + .deleteProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError() + .containsSummary(String.format(RestErrorModel.ACCESS_INFORMATION_NOT_ALLOWED, processModel.getId())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .containsErrorKey(String.format(RestErrorModel.ACCESS_INFORMATION_NOT_ALLOWED, processModel.getId())) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Delete process variable by inexistent user") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void deleteProcessVarialbleByInexistentUser() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() + .addProcess("activitiAdhoc", userWhoStartsTask, false, Priority.Normal); + restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() + .getProcesses().getProcessModelByProcessDefId(processModel.getId()); + restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingProcess(processModel) - .deleteProcessVariable(updatedVariable); + restClient.authenticateUser(UserModel.getRandomUserModel()).withWorkflowAPI() + .usingProcess(restProcessModel) + .deleteProcessVariable(variableModel); + + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin from the same network is able to delete network process variables") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL, TestGroup.NETWORKS }) + public void deleteProcessVariablesWithAdminFromSameNetwork() throws Exception + { + UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser1); + UserModel tenantUser1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenant1"); + + RestProcessModel processModel = restClient.authenticateUser(adminTenantUser1).withWorkflowAPI() + .addProcess("activitiAdhoc", tenantUser1, false, Priority.Normal); + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser1).withWorkflowAPI() + .getProcesses().getProcessModelByProcessDefId(processModel.getId()); + restClient.withWorkflowAPI().usingProcess(networkProcess1).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(adminTenantUser1).withWorkflowAPI().usingProcess(networkProcess1) + .deleteProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() - .assertThat().entriesListDoesNotContain("name", updatedVariable.getName()); + restClient.withWorkflowAPI().usingProcess(networkProcess1).getProcessVariables() + .assertThat() + .entriesListDoesNotContain("name", variableModel.getName()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin from different network is not able to delete network process variables") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL, TestGroup.NETWORKS }) + public void deleteProcessVariablesWithAdminFromDifferentNetwork() throws Exception + { + UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser1); + UserModel tenantUser1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenant1"); + + RestProcessModel processModel = restClient.authenticateUser(adminTenantUser1).withWorkflowAPI() + .addProcess("activitiAdhoc", tenantUser1, false, Priority.Normal); + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser1).withWorkflowAPI() + .getProcesses().getProcessModelByProcessDefId(processModel.getId()); + restClient.withWorkflowAPI().usingProcess(networkProcess1).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(adminUser).withWorkflowAPI().usingProcess(networkProcess1) + .deleteProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + restClient.assertLastError().containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .containsErrorKey(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT) + .stackTraceIs(RestErrorModel.STACKTRACE); + + restClient.authenticateUser(tenantUser1).withWorkflowAPI().usingProcess(networkProcess1).getProcessVariables().assertThat() + .entriesListContains("name", variableModel.getName()); } } From a528417f1b5f3e4b4834a02563cf46bc6d69435e Mon Sep 17 00:00:00 2001 From: Bogdan Bocancea Date: Fri, 3 Feb 2017 11:57:08 +0200 Subject: [PATCH 0983/1491] TAS-2928: add full tests for getTaskVariables(). Contains TAS-2930 addTaskVariables(0 --- .../tasks/AddTaskVariablesFullTests.java | 129 +++++++++++++ .../tasks/GetTaskVariablesFullTests.java | 176 ++++++++++++++++++ 2 files changed, 305 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesFullTests.java create mode 100644 e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskVariablesFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesFullTests.java new file mode 100644 index 000000000..ceba3ab3f --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesFullTests.java @@ -0,0 +1,129 @@ +package org.alfresco.rest.workflow.tasks; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestTaskModel; +import org.alfresco.rest.model.RestVariableModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TaskModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + + +public class AddTaskVariablesFullTests extends RestTest +{ + private UserModel userWhoStartsTask, adminUser; + private SiteModel siteModel; + private FileModel fileModel; + private UserModel assigneeUser; + private TaskModel taskModel; + private RestVariableModel restVariablemodel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userWhoStartsTask = dataUser.createRandomTestUser(); + assigneeUser = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); + fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + } + + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Create task variable with name containing symbols") + public void createTaskVariableWithSymbolsInName() throws Exception + { + UserModel adminUser = dataUser.getAdminUser(); + restClient.authenticateUser(adminUser); + RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + variableModel.setName("!@#$%^&*({}<>.,;'=_|"); + restVariablemodel = restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restVariablemodel.assertThat() + .field("scope").is(variableModel.getScope()) + .and().field("name").is(variableModel.getName()) + .and().field("value").is(variableModel.getValue()) + .and().field("type").is(variableModel.getType()); + } + + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Create task variable with empty name") + public void createTaskVariableWithEmptyName() throws Exception + { + UserModel adminUser = dataUser.getAdminUser(); + restClient.authenticateUser(adminUser); + RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + variableModel.setName(""); + restVariablemodel = restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsErrorKey(RestErrorModel.VARIABLE_NAME_REQUIRED) + .containsSummary(RestErrorModel.VARIABLE_NAME_REQUIRED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL, TestGroup.NETWORKS }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin from the same network is able to add task variables") + public void addTaskVariablesByTenantAdmin() throws Exception + { + UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); + restClient.authenticateUser(dataUser.getAdminUser()).usingTenant().createTenant(adminTenantUser1); + UserModel tenantUser1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenant1"); + + RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser1).withWorkflowAPI() + .addProcess("activitiReview", tenantUser1, false, CMISUtil.Priority.High); + RestTaskModel task = restClient.authenticateUser(adminTenantUser1) + .withWorkflowAPI().usingProcess(networkProcess1).getProcessTasks().getOneRandomEntry(); + restClient.authenticateUser(adminTenantUser1); + RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + restVariablemodel = restClient.withWorkflowAPI() + .usingTask(task.onModel()) + .addTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restVariablemodel.assertThat() + .field("scope").is(variableModel.getScope()) + .and().field("name").is(variableModel.getName()) + .and().field("value").is(variableModel.getValue()) + .and().field("type").is(variableModel.getType()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL, TestGroup.NETWORKS }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin from another network is not able to add task variables") + public void addTaskVariablesByTenantFromAnotherNetwork() throws Exception + { + UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); + UserModel adminTenantUser2 = UserModel.getAdminTenantUser(); + restClient.authenticateUser(dataUser.getAdminUser()).usingTenant().createTenant(adminTenantUser1); + restClient.authenticateUser(dataUser.getAdminUser()).usingTenant().createTenant(adminTenantUser2); + UserModel tenantUser1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenant1"); + + RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser1).withWorkflowAPI() + .addProcess("activitiReview", tenantUser1, false, CMISUtil.Priority.High); + RestTaskModel task = restClient.authenticateUser(adminTenantUser1) + .withWorkflowAPI().usingProcess(networkProcess1).getProcessTasks().getOneRandomEntry(); + restClient.authenticateUser(adminTenantUser1); + RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + restVariablemodel = restClient.authenticateUser(adminTenantUser2).withWorkflowAPI() + .usingTask(task.onModel()) + .addTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } +} diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskVariablesFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskVariablesFullTests.java new file mode 100644 index 000000000..cc1faf53d --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskVariablesFullTests.java @@ -0,0 +1,176 @@ +package org.alfresco.rest.workflow.tasks; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestTaskModel; +import org.alfresco.rest.model.RestVariableModelsCollection; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TaskModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class GetTaskVariablesFullTests extends RestTest +{ + private UserModel userWhoStartsTask, assignee; + private SiteModel siteModel; + private FileModel fileModel; + private TaskModel taskModel; + private RestVariableModelsCollection variableModels; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + userWhoStartsTask = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); + fileModel = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify default error shema for get task variables") + public void getTaskVariablesCheckDefaultErrorSchema() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask) + .usingSite(siteModel).usingResource(fileModel) + .createNewTaskAndAssignTo(assignee); + taskModel.setId("invalidId"); + + restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingTask(taskModel).getTaskVariables(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidId")) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } + + @Bug(id="MNT-17438") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify user gets task with 'maxItems' parameter") + public void getTaskVariablesWithMaxItems() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); + variableModels = restClient.authenticateUser(userWhoStartsTask) + .withWorkflowAPI().usingParams("maxItems=2").usingTask(taskModel).getTaskVariables(); + restClient.assertStatusCodeIs(HttpStatus.OK); + variableModels.assertThat().entriesListIsNotEmpty() + .and().paginationField("count").is("2"); + } + + @Bug(id="MNT-17438") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify user gets task with 'skipCount' parameter") + public void getTaskVariablesWithSkipCount() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); + variableModels = restClient.authenticateUser(userWhoStartsTask) + .withWorkflowAPI().usingParams("skipCount=10").usingTask(taskModel).getTaskVariables(); + restClient.assertStatusCodeIs(HttpStatus.OK); + variableModels.assertThat().entriesListIsNotEmpty() + .and().paginationField("count").is("20"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify user cannot get task variables with invalid where clause.") + public void getTaskVariablesWithInvalidWhereClauseAsParameter() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); + variableModels = restClient.authenticateUser(userWhoStartsTask).where("scope='fake-where'") + .withWorkflowAPI().usingTask(taskModel).getTaskVariables(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_WHERE_QUERY, "Invalid value for 'scope' used in query: fake-where.")) + .containsErrorKey(RestErrorModel.INVALID_QUERY_ERRORKEY) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify user gets tasks variables with 'properties' parameter") + public void getTaskVariablesWithValidProperties() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); + variableModels = restClient.authenticateUser(userWhoStartsTask).withParams("properties=scope,name") + .withWorkflowAPI().usingTask(taskModel).getTaskVariables(); + restClient.assertStatusCodeIs(HttpStatus.OK); + variableModels.assertThat().entriesListIsNotEmpty(); + variableModels.getOneRandomEntry().onModel().assertThat() + .fieldsCount().is(2).and() + .field("type").isNull().and() + .field("value").isNull().and() + .field("scope").isNotEmpty().and() + .field("name").isNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify user cannot get tasks variables with invalid 'properties' parameter") + public void getTaskVariablesWithInvalidProperties() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); + variableModels = restClient.authenticateUser(userWhoStartsTask).withParams("properties=fake") + .withWorkflowAPI().usingTask(taskModel).getTaskVariables(); + restClient.assertStatusCodeIs(HttpStatus.OK); + variableModels.getOneRandomEntry().onModel().assertThat() + .fieldsCount().is(0).and() + .field("type").isNull().and() + .field("value").isNull().and() + .field("scope").isNull().and() + .field("name").isNull(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL, TestGroup.NETWORKS }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin from the same network is able to retrieve network task variables") + public void getTaskVariablesByTenantAdmin() throws Exception + { + UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); + restClient.authenticateUser(dataUser.getAdminUser()).usingTenant().createTenant(adminTenantUser1); + UserModel tenantUser1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenant1"); + + RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser1).withWorkflowAPI() + .addProcess("activitiReview", tenantUser1, false, CMISUtil.Priority.High); + RestTaskModel task = restClient.authenticateUser(adminTenantUser1) + .withWorkflowAPI().usingProcess(networkProcess1).getProcessTasks().getOneRandomEntry(); + + variableModels = restClient.withWorkflowAPI().usingTask(task.onModel()).getTaskVariables(); + restClient.assertStatusCodeIs(HttpStatus.OK); + variableModels.assertThat().entriesListIsNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL, TestGroup.NETWORKS }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin from another network is not able to retrieve network task variables") + public void getTaskVariablesByTenantFromAnotherNetwork() throws Exception + { + UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); + UserModel adminTenantUser2= UserModel.getAdminTenantUser(); + restClient.authenticateUser(dataUser.getAdminUser()).usingTenant().createTenant(adminTenantUser1); + restClient.authenticateUser(dataUser.getAdminUser()).usingTenant().createTenant(adminTenantUser2); + UserModel tenantUser1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenant1"); + + RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser1).withWorkflowAPI() + .addProcess("activitiReview", tenantUser1, false, CMISUtil.Priority.High); + RestTaskModel task = restClient.authenticateUser(adminTenantUser1) + .withWorkflowAPI().usingProcess(networkProcess1).getProcessTasks().getOneRandomEntry(); + + variableModels = restClient.authenticateUser(adminTenantUser2).withWorkflowAPI().usingTask(task.onModel()).getTaskVariables(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } +} From ab5a239a987a621887e0a1e01ae867f414d11cbc Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Fri, 3 Feb 2017 12:08:19 +0200 Subject: [PATCH 0984/1491] TAS-2910, TAS-2911, TAS-2912 added full tests for these 3 tasks --- .../tasks/UpdateTaskFullTestsBulk1.java | 277 ++++++++++++++++++ 1 file changed, 277 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk1.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk1.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk1.java new file mode 100644 index 000000000..f30efad31 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk1.java @@ -0,0 +1,277 @@ +package org.alfresco.rest.workflow.tasks; + +import javax.json.JsonObject; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.JsonBodyGenerator; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestProcessDefinitionModel; +import org.alfresco.rest.model.RestTaskModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TaskModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +/** + * + * @author Cristina Axinte + * + */ +public class UpdateTaskFullTestsBulk1 extends RestTest +{ + UserModel owner; + SiteModel siteModel; + UserModel candidateUser; + FileModel fileModel; + UserModel assigneeUser; + TaskModel taskModel; + RestTaskModel restTaskModel; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + owner = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(owner).createPublicRandomSite(); + fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + assigneeUser = dataUser.createRandomTestUser(); + } + + @BeforeMethod(alwaysRun=true) + public void createTask() throws Exception + { + taskModel = dataWorkflow.usingUser(owner).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL, TestGroup.NETWORKS }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify tenant user that created the task can update task only in its network and response is 200, for other networks is 403") + public void ownerTenantCanUpdatedTaskOnlyInItsNetwork() throws Exception + { + UserModel adminUser = dataUser.getAdminUser(); + restClient.authenticateUser(adminUser); + + UserModel adminTenant1 = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenant1); + + UserModel ownerTenant1 = dataUser.usingUser(adminTenant1).createUserWithTenant("ownerTenant1"); + UserModel assigneeTenant1 = dataUser.usingUser(adminTenant1).createUserWithTenant("assigneeTenant1"); + SiteModel siteModel1 = dataSite.usingUser(ownerTenant1).createPublicRandomSite(); + FileModel fileModel1 = dataContent.usingUser(ownerTenant1).usingSite(siteModel1).createContent(DocumentType.TEXT_PLAIN); + RestProcessDefinitionModel def1 = restClient.authenticateUser(ownerTenant1).withWorkflowAPI().getAllProcessDefinitions().getEntries().get(0).onModel(); + TaskModel taskModel1 = dataWorkflow.usingUser(ownerTenant1).usingSite(siteModel1).usingResource(fileModel1) + .createTaskWithProcessDefAndAssignTo(def1.getId(), assigneeTenant1); + + UserModel adminTenant2 = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenant2); + + UserModel ownerTenant2 = dataUser.usingUser(adminTenant2).createUserWithTenant("ownerTenant2"); + UserModel assigneeTenant2 = dataUser.usingUser(adminTenant2).createUserWithTenant("userTenantAssignee2"); + SiteModel siteModel2 = dataSite.usingUser(ownerTenant2).createPublicRandomSite(); + FileModel fileModel2 = dataContent.usingUser(ownerTenant2).usingSite(siteModel2).createContent(DocumentType.TEXT_PLAIN); + RestProcessDefinitionModel def2 = restClient.authenticateUser(ownerTenant2).withWorkflowAPI().getAllProcessDefinitions().getEntries().get(0).onModel(); + TaskModel taskModel2 = dataWorkflow.usingUser(ownerTenant2).usingSite(siteModel2).usingResource(fileModel2) + .createTaskWithProcessDefAndAssignTo(def2.getId(), assigneeTenant2); + + restTaskModel = restClient.authenticateUser(ownerTenant2).withParams("select=state").withWorkflowAPI().usingTask(taskModel2).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel2.getId()) + .and().field("state").is("completed"); + + restTaskModel = restClient.authenticateUser(ownerTenant2).withParams("select=state").withWorkflowAPI().usingTask(taskModel1).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + + } + + @Bug(id = "REPO-1980") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL, TestGroup.NETWORKS }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify tenant admin can update only task from its network and response is 200") + public void adminTenantCanUpdateOnlyTaskInItsNetwork() throws Exception + { + UserModel adminUser = dataUser.getAdminUser(); + restClient.authenticateUser(adminUser); + + UserModel adminTenant1 = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenant1); + + UserModel ownerTenant1 = dataUser.usingUser(adminTenant1).createUserWithTenant("ownerTenant1"); + UserModel assigneeTenant1 = dataUser.usingUser(adminTenant1).createUserWithTenant("assigneeTenant1"); + SiteModel siteModel1 = dataSite.usingUser(ownerTenant1).createPublicRandomSite(); + FileModel fileModel1 = dataContent.usingUser(ownerTenant1).usingSite(siteModel1).createContent(DocumentType.TEXT_PLAIN); + RestProcessDefinitionModel def1 = restClient.authenticateUser(ownerTenant1).withWorkflowAPI().getAllProcessDefinitions().getEntries().get(0).onModel(); + TaskModel taskModel1 = dataWorkflow.usingUser(ownerTenant1).usingSite(siteModel1).usingResource(fileModel1) + .createTaskWithProcessDefAndAssignTo(def1.getId(), assigneeTenant1); + + UserModel adminTenant2 = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenant2); + + UserModel ownerTenant2 = dataUser.usingUser(adminTenant2).createUserWithTenant("ownerTenant2"); + UserModel assigneeTenant2 = dataUser.usingUser(adminTenant2).createUserWithTenant("userTenantAssignee2"); + SiteModel siteModel2 = dataSite.usingUser(ownerTenant2).createPublicRandomSite(); + FileModel fileModel2 = dataContent.usingUser(ownerTenant2).usingSite(siteModel2).createContent(DocumentType.TEXT_PLAIN); + RestProcessDefinitionModel def2 = restClient.authenticateUser(ownerTenant2).withWorkflowAPI().getAllProcessDefinitions().getEntries().get(0).onModel(); + TaskModel taskModel2 = dataWorkflow.usingUser(ownerTenant2).usingSite(siteModel2).usingResource(fileModel2) + .createTaskWithProcessDefAndAssignTo(def2.getId(), assigneeTenant2); + + restTaskModel = restClient.authenticateUser(adminTenant2).withParams("select=state").withWorkflowAPI().usingTask(taskModel2).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel2.getId()) + .and().field("state").is("completed"); + + restTaskModel = restClient.authenticateUser(adminTenant2).withParams("select=state").withWorkflowAPI().usingTask(taskModel1).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task cannot be updated from status completed to delegated and response is 404") + public void taskCannotBeUpdatedFromCompletedToDelegated() throws Exception + { + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("completed"); + + restClient.authenticateUser(assigneeUser) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("delegated"); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() + .containsErrorKey(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) + .containsSummary(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task cannot be updated from status completed to resolved and response is 404") + public void taskCannotBeUpdatedFromCompletedToResolved() throws Exception + { + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("completed"); + + restClient.authenticateUser(assigneeUser) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() + .containsErrorKey(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) + .containsSummary(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task cannot be updated from status completed to completed and response is 404") + public void taskCannotBeUpdatedFromCompletedToCompleted() throws Exception + { + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("completed"); + + restClient.authenticateUser(assigneeUser) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() + .containsErrorKey(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) + .containsSummary(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task can be updated from status claimed to unclaimed and response is 200") + public void taskCanBeUpdatedFromClaimedToUnclaimed() throws Exception + { + restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).getTask(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("claimed"); + + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("unclaimed"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task can be updated from status claimed to delegated and response is 200") + public void taskCanBeUpdatedFromClaimedToDelegated() throws Exception + { + restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).getTask(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("claimed"); + + UserModel newAssignee = dataUser.createRandomTestUser(); + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("state", "delegated") + .add("assignee", newAssignee.getUsername()).build(); + + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("delegated") + .and().field("assignee").is(newAssignee.getUsername()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task can be updated from status claimed to resolved and response is 200") + public void taskCanBeUpdatedFromClaimedToResolved() throws Exception + { + restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).getTask(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("claimed"); + + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("resolved"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task can be updated from status claimed to claimed and response is 200") + public void taskCanBeUpdatedFromClaimedToClaimed() throws Exception + { + restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).getTask(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("claimed"); + + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); + restClient.assertStatusCodeIs(HttpStatus.CONFLICT).assertLastError() + .containsErrorKey(RestErrorModel.TAS_ALREADY_CLAIMED) + .containsSummary(RestErrorModel.TAS_ALREADY_CLAIMED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } +} From cd98c0ef53a732fc26e2ce703b21fa7f428e1dda Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Fri, 3 Feb 2017 12:08:25 +0200 Subject: [PATCH 0985/1491] Added end to end scenarios --- .../alfresco/rest/FunctionalCasesTests.java | 66 ++++++++++++++++++- 1 file changed, 65 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java b/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java index e128a7817..2d602d2dd 100644 --- a/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java +++ b/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java @@ -1,7 +1,10 @@ package org.alfresco.rest; +import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.model.RestActivityModelsCollection; +import org.alfresco.rest.model.RestCommentModelsCollection; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestFavoriteSiteModel; import org.alfresco.rest.model.RestSiteMemberModel; import org.alfresco.rest.model.RestSiteMembershipRequestModelsCollection; @@ -20,7 +23,7 @@ import org.testng.annotations.Test; public class FunctionalCasesTests extends RestTest { private UserModel adminUserModel; - private SiteModel siteModel, moderatedSite; + private SiteModel siteModel, moderatedSite, privateSite; private RestSiteMemberModel updatedMember; private RestSiteMembershipRequestModelsCollection returnedCollection; private RestFavoriteSiteModel restFavoriteSiteModel; @@ -35,6 +38,7 @@ public class FunctionalCasesTests extends RestTest siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); dataUser.addUserToSite(user, siteModel, UserRole.SiteManager); moderatedSite = dataSite.usingUser(adminUserModel).createModeratedRandomSite(); + privateSite = dataSite.usingUser(adminUserModel).createPrivateRandomSite(); } /** @@ -240,4 +244,64 @@ public class FunctionalCasesTests extends RestTest .and().entriesListContains("activityType", "org.alfresco.documentlibrary.file-deleted") .and().entriesListContains("activitySummary.objectId", file.getNodeRefWithoutVersion()); } + + /** + * Scenario: + * 1. Create document in site + * 2. Add comment + * 3. Delete document + * 4. Get comments and check if the above comment was deleted + */ + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, + executionType = ExecutionType.REGRESSION, description = "Check that a comment of a document was also removed after deleting the document") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void checkTheCommentOfADocumentThatWasDeletedDoesNotExist() throws Exception + { + FileModel document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + String newContent = "This is a new comment added by " + adminUserModel.getUsername(); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).addComment(newContent) + .assertThat().field("content").isNotEmpty() + .and().field("content").is(newContent); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + dataContent.usingUser(adminUserModel).usingResource(document).deleteContent(); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary((String.format(RestErrorModel.ENTITY_WAS_NOT_FOUND, document.getNodeRefWithoutVersion()))); + } + + /** + * Scenario: + * 1. Add user to private site + * 2. Add comment to a document of private site + * 3. Remove user from site + * 4. Get comments and check if the above comment was deleted + */ + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, + executionType = ExecutionType.REGRESSION, description = "Check that a comment of a document in a private site was also removed after deleting the document") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void checkTheCommentOfADocumentFromPrivateSiteDoesNotExist() throws Exception + { + UserModel newUser = dataUser.createRandomTestUser(); + newUser.setUserRole(UserRole.SiteManager); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSite).addPerson(newUser); + + FileModel document = dataContent.usingSite(privateSite).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + String newContent = "This is a new comment added by " + newUser.getUsername(); + + restClient.authenticateUser(newUser).withCoreAPI().usingResource(document).addComment(newContent) + .assertThat().field("content").isNotEmpty() + .and().field("content").is(newContent); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSite).deleteSiteMember(newUser); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withCoreAPI().usingSite(privateSite).getSiteMembers().assertThat().entriesListDoesNotContain("id", newUser.getUsername()); + + RestCommentModelsCollection comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", newContent) + .and().entriesListContains("createdBy.id", newUser.getUsername()); + } } \ No newline at end of file From 58f5691f8c5016a37f83b3f1b21d140ae6cf462f Mon Sep 17 00:00:00 2001 From: cagache Date: Fri, 3 Feb 2017 12:51:06 +0200 Subject: [PATCH 0986/1491] fix TAS-3187 --- e2e-test/java/org/alfresco/rest/tags/GetTagsFullTests.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/tags/GetTagsFullTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagsFullTests.java index c166a08c2..c6dace4c7 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetTagsFullTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetTagsFullTests.java @@ -75,8 +75,7 @@ public class GetTagsFullTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); tagsWithSkipCount.assertThat().entriesListDoesNotContain("tag", firstTag.getTag()) - .assertThat().entriesListDoesNotContain("tag", secondTag.getTag()) - .assertThat().entriesListCountIs(returnedCollection.getEntries().size()-2); + .assertThat().entriesListDoesNotContain("tag", secondTag.getTag()); tagsWithSkipCount.assertThat().paginationField("skipCount").is("2"); } From 27c06a5373b97bac2988a0229d8754f8fe6db88b Mon Sep 17 00:00:00 2001 From: cagache Date: Fri, 3 Feb 2017 15:12:45 +0200 Subject: [PATCH 0987/1491] TAS - 2906 - getProcessTasks --- .../processes/GetProcessTasksCoreTests.java | 54 ++--- .../processes/GetProcessTasksFullTests.java | 208 ++++++++++++++++++ .../processes/GetProcessTasksSanityTests.java | 6 +- 3 files changed, 235 insertions(+), 33 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksCoreTests.java index fcd3c9718..60d47b888 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksCoreTests.java @@ -3,6 +3,7 @@ package org.alfresco.rest.workflow.processes; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestProcessModel; import org.alfresco.rest.model.RestTaskModel; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.GroupModel; @@ -10,7 +11,6 @@ import org.alfresco.utility.model.ProcessModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -21,7 +21,7 @@ public class GetProcessTasksCoreTests extends RestTest { private FileModel document, document1, document2, document3; private SiteModel siteModel; - private UserModel adminUser, userModel, userModel1, userModel2, assignee; + private UserModel adminUser, userWhoStartsProcess, candidate, anotherAssignee, assignee; private ProcessModel process; private GroupModel group; @@ -29,57 +29,52 @@ public class GetProcessTasksCoreTests extends RestTest public void dataPreparation() throws Exception { adminUser = dataUser.getAdminUser(); - userModel = dataUser.createRandomTestUser(); - userModel1 = dataUser.createRandomTestUser(); - userModel2 = dataUser.createRandomTestUser(); + userWhoStartsProcess = dataUser.createRandomTestUser(); + candidate = dataUser.createRandomTestUser(); + anotherAssignee = dataUser.createRandomTestUser(); assignee = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + siteModel = dataSite.usingUser(userWhoStartsProcess).createPublicRandomSite(); document = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); document1 = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); document2 = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - process = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(document) + process = dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document) .createSingleReviewerTaskAndAssignTo(assignee); group = dataGroup.createRandomGroup(); - dataGroup.addListOfUsersToGroup(group, userModel1); + dataGroup.addListOfUsersToGroup(group, candidate); } - @Bug(id = "TBD") @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "getProcessTaks with user that is candidate with REST API and status code is OK (200)") + description = "getProcessTasks with user that is candidate with REST API and status code is OK (200)") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) public void getProcessTasksWithUserThatIsCandidate() throws Exception { - ProcessModel processModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(document1) + ProcessModel processModel = dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document1) .createGroupReviewTaskAndAssignTo(group); - restClient.authenticateUser(assignee).withWorkflowAPI() + restClient.authenticateUser(candidate).withWorkflowAPI() .usingProcess(processModel).getProcessTasks().assertThat().entriesListIsNotEmpty() - .and().entriesListContains("assignee", assignee.getUsername()); + .and().entriesListContains("assignee", candidate.getUsername()); restClient.assertStatusCodeIs(HttpStatus.OK); } - @Bug(id = "TBD") @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify getProcessTasks using admin from same network with REST API and status code is FORBIDDEN (403)") + description = "Verify getProcessTasks using admin from same network with REST API and status code is OK") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE, TestGroup.NETWORKS }) public void getProcessTasksWithAdminFromSameNetwork() throws Exception { - UserModel adminTenant, tenantAssignee; - adminTenant = UserModel.getAdminTenantUser(); + UserModel adminTenant = UserModel.getAdminTenantUser(); restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenant); SiteModel siteModel = dataSite.usingUser(adminTenant).createPublicRandomSite(); - tenantAssignee = dataUser.usingUser(adminTenant).createUserWithTenant("uTenant"); + UserModel tenantAssignee = dataUser.usingUser(adminTenant).createUserWithTenant("uTenant"); document3 = dataContent.usingUser(adminTenant).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - ProcessModel processModel = dataWorkflow.usingUser(adminTenant).usingSite(siteModel).usingResource(document3) - .createSingleReviewerTaskAndAssignTo(tenantAssignee); + RestProcessModel processModel = restClient.authenticateUser(tenantAssignee).withWorkflowAPI().addProcess("activitiAdhoc", tenantAssignee, false, CMISUtil.Priority.Normal); - restClient.withWorkflowAPI() + restClient.authenticateUser(adminTenant).withWorkflowAPI() .usingProcess(processModel).getProcessTasks().assertThat().entriesListIsNotEmpty(); restClient.assertStatusCodeIs(HttpStatus.OK); } - @Bug(id = "TBD") @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify getProcessTasks using admin from different network with REST API and status code is FORBIDDEN (403)") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE, TestGroup.NETWORKS }) @@ -93,14 +88,13 @@ public class GetProcessTasksCoreTests extends RestTest SiteModel siteModel = dataSite.usingUser(adminTenant).createPublicRandomSite(); document3 = dataContent.usingUser(adminTenant).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); tenantAssignee = dataUser.usingUser(adminTenant).createUserWithTenant("uTenant"); - ProcessModel processModel = dataWorkflow.usingUser(adminTenant).usingSite(siteModel).usingResource(document3) - .createSingleReviewerTaskAndAssignTo(tenantAssignee); + RestProcessModel processModel = restClient.authenticateUser(adminTenant).withWorkflowAPI().addProcess("activitiAdhoc", tenantAssignee, false, CMISUtil.Priority.Normal); restClient.authenticateUser(adminUser).usingTenant().createTenant(secondAdminTenant); restClient.authenticateUser(secondAdminTenant).withWorkflowAPI() .usingProcess(processModel).getProcessTasks().assertThat().entriesListIsEmpty(); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + .assertLastError().containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, @@ -110,7 +104,7 @@ public class GetProcessTasksCoreTests extends RestTest { ProcessModel processModel = process; processModel.setId("invalidProcessId"); - restClient.authenticateUser(userModel).withWorkflowAPI() + restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI() .usingProcess(processModel).getProcessTasks().assertThat().entriesListIsEmpty(); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); @@ -123,7 +117,7 @@ public class GetProcessTasksCoreTests extends RestTest { ProcessModel processModel = process; processModel.setId(""); - restClient.authenticateUser(userModel).withWorkflowAPI() + restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI() .usingProcess(processModel).getProcessTasks().assertThat().entriesListIsEmpty(); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); @@ -134,9 +128,9 @@ public class GetProcessTasksCoreTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) public void completeTaskThenGetProcessTasks() throws Exception { - ProcessModel processModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(document2) - .createMoreReviewersWorkflowAndAssignTo(userModel2); - RestTaskModel restTaskModel = restClient.authenticateUser(userModel2).withWorkflowAPI() + ProcessModel processModel = dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document2) + .createMoreReviewersWorkflowAndAssignTo(anotherAssignee); + RestTaskModel restTaskModel = restClient.authenticateUser(anotherAssignee).withWorkflowAPI() .usingProcess(processModel).getProcessTasks().assertThat().entriesListIsNotEmpty().getOneRandomEntry().onModel(); restTaskModel = restClient.withParams("select=state").withWorkflowAPI().usingTask(restTaskModel).updateTask("completed"); restTaskModel.assertThat().field("id").is(restTaskModel.getId()).and().field("state").is("completed"); diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksFullTests.java new file mode 100644 index 000000000..e9ff76c4d --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksFullTests.java @@ -0,0 +1,208 @@ +package org.alfresco.rest.workflow.processes; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestTaskModelsCollection; +import org.alfresco.utility.model.*; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Created by Claudia Agache on 2/3/2017. + */ +public class GetProcessTasksFullTests extends RestTest +{ + private FileModel document; + private SiteModel publicSite; + private UserModel adminUser, userWhoStartsProcess, assignee1, assignee2, assignee3; + private ProcessModel processWithSingleTask, processWithMultipleTasks; + private RestTaskModelsCollection processTasks; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userWhoStartsProcess = dataUser.createRandomTestUser(); + assignee1 = dataUser.createRandomTestUser(); + assignee2 = dataUser.createRandomTestUser(); + assignee3 = dataUser.createRandomTestUser(); + publicSite = dataSite.usingUser(userWhoStartsProcess).createPublicRandomSite(); + document = dataContent.usingSite(publicSite).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + processWithSingleTask = dataWorkflow.usingUser(userWhoStartsProcess).usingSite(publicSite).usingResource(document) + .createSingleReviewerTaskAndAssignTo(assignee1); + processWithMultipleTasks = dataWorkflow.usingUser(userWhoStartsProcess).usingSite(publicSite).usingResource(document) + .createMoreReviewersWorkflowAndAssignTo(assignee1, assignee2, assignee3); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify admin user is able to getProcessTasks even if he wasn't involved in process. Check status code is OK") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void getProcessTasksWithAdmin() throws Exception + { + processTasks = restClient.authenticateUser(adminUser).withWorkflowAPI() + .usingProcess(processWithSingleTask).getProcessTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + processTasks.assertThat().entriesListCountIs(1) + .and().entriesListContains("assignee", assignee1.getUsername()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Get process tasks with valid skipCount parameter applied") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL}) + public void getProcessTasksWithValidSkipCount() throws Exception + { + processTasks = restClient.authenticateUser(userWhoStartsProcess) + .withParams("skipCount=2").withWorkflowAPI() + .usingProcess(processWithMultipleTasks).getProcessTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + processTasks.assertThat().entriesListContains("assignee", assignee3.getUsername()) + .assertThat().entriesListDoesNotContain("assignee", assignee1.getUsername()) + .assertThat().entriesListDoesNotContain("assignee", assignee2.getUsername()) + .assertThat().entriesListCountIs(1) + .assertThat().paginationField("skipCount").is("2"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Get process tasks with negative skipCount parameter applied") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL}) + public void getProcessTasksWithNegativeSkipCount() throws Exception + { + restClient.authenticateUser(userWhoStartsProcess) + .withParams("skipCount=-2").withWorkflowAPI() + .usingProcess(processWithMultipleTasks).getProcessTasks(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT) + .containsErrorKey(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE) + .statusCodeIs(HttpStatus.BAD_REQUEST); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Get process tasks with non numeric skipCount parameter applied") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL}) + public void getProcessTasksWithNonNumericSkipCount() throws Exception + { + restClient.authenticateUser(userWhoStartsProcess) + .withParams("skipCount=A").withWorkflowAPI() + .usingProcess(processWithMultipleTasks).getProcessTasks(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "A")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Get process tasks with valid maxItems parameter applied") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL}) + public void getProcessTasksWithValidMaxItems() throws Exception + { + processTasks = restClient.authenticateUser(userWhoStartsProcess) + .withParams("maxItems=2").withWorkflowAPI() + .usingProcess(processWithMultipleTasks).getProcessTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + processTasks.assertThat().entriesListDoesNotContain("assignee", assignee3.getUsername()) + .assertThat().entriesListContains("assignee", assignee1.getUsername()) + .assertThat().entriesListContains("assignee", assignee2.getUsername()) + .assertThat().entriesListCountIs(2) + .assertThat().paginationField("maxItems").is("2"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Get process tasks with negative maxItems parameter applied") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL}) + public void getProcessTasksWithNegativeMaxItems() throws Exception + { + restClient.authenticateUser(userWhoStartsProcess) + .withParams("maxItems=-2").withWorkflowAPI() + .usingProcess(processWithMultipleTasks).getProcessTasks(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) + .containsErrorKey(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE) + .statusCodeIs(HttpStatus.BAD_REQUEST); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Get process tasks with non numeric maxItems parameter applied") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL}) + public void getProcessTasksWithNonNumericMaxItems() throws Exception + { + restClient.authenticateUser(userWhoStartsProcess) + .withParams("maxItems=A").withWorkflowAPI() + .usingProcess(processWithMultipleTasks).getProcessTasks(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "A")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify getProcessTasks with properties parameter") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void getProcessTasksWithPropertiesParameter() throws Exception + { + processTasks = restClient.authenticateUser(adminUser) + .withParams("properties=name,assignee,state").withWorkflowAPI() + .usingProcess(processWithSingleTask).getProcessTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + processTasks.assertThat().entriesListCountIs(1); + processTasks.getOneRandomEntry().onModel().assertThat() + .field("dueAt").isNull().and() + .field("processDefinitionId").isNull().and() + .field("processId").isNull().and() + .field("description").isNull().and() + .field("startedAt").isNull().and() + .field("id").isNull().and() + .field("activityDefinitionId").isNull().and() + .field("priority").isNull().and() + .field("formResourceKey").isNull().and() + .field("name").is("Review Task").and() + .field("state").is("claimed").and() + .field("assignee").is(assignee1.getUsername()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify admin gets Process Tasks ordered by assignee ascendant using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void getProcessTasksOrderedByAssignee() throws Exception + { + processTasks = restClient.authenticateUser(adminUser) + .withParams("orderBy=assignee").withWorkflowAPI() + .usingProcess(processWithMultipleTasks).getProcessTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + processTasks.assertThat().entriesListIsSortedAscBy("assignee"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify admin doesn't get Process Tasks ordered by many fields") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void getProcessTasksOrderedByMultipleFields() throws Exception + { + restClient.authenticateUser(adminUser) + .withParams("orderBy=assignee,state").withWorkflowAPI() + .usingProcess(processWithMultipleTasks).getProcessTasks(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary("Only one order by parameter is supported"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify get all process tasks after process is deleted.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void getProcessTasksAfterDeletingProcess() throws Exception + { + ProcessModel processModel = dataWorkflow.usingUser(userWhoStartsProcess).usingSite(publicSite).usingResource(document) + .createSingleReviewerTaskAndAssignTo(assignee1); + + restClient.authenticateUser(adminUser).withWorkflowAPI().usingProcess(processModel).deleteProcess(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + processTasks = restClient.authenticateUser(adminUser).withWorkflowAPI() + .usingProcess(processModel).getProcessTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + processTasks.assertThat().entriesListIsEmpty(); + } + + +} diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksSanityTests.java index b899780f5..57e747c63 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksSanityTests.java @@ -49,10 +49,10 @@ public class GetProcessTasksSanityTests extends RestTest processTasks = restClient.authenticateUser(userModel).withWorkflowAPI().usingProcess(process).getProcessTasks(); restClient.assertStatusCodeIs(HttpStatus.OK); processTasks.assertThat() - .entriesListIsNotEmpty().and() + .entriesListCountIs(3).and() .entriesListContains("assignee", assignee1.getUsername()).and() .entriesListContains("assignee", assignee2.getUsername()).and() - .entriesListContains("assignee", assignee2.getUsername()); + .entriesListContains("assignee", assignee3.getUsername()); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, @@ -65,7 +65,7 @@ public class GetProcessTasksSanityTests extends RestTest processTasks.assertThat() .entriesListContains("assignee", assignee1.getUsername()).and() .entriesListContains("assignee", assignee2.getUsername()).and() - .entriesListContains("assignee", assignee2.getUsername()); + .entriesListContains("assignee", assignee3.getUsername()); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, From 93d64e04aa3ad477dc01e3c6d30707d4a200d27b Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Fri, 3 Feb 2017 15:15:04 +0200 Subject: [PATCH 0988/1491] TAS-2913 - update tasks from unclaiming to other states --- .../tasks/UpdateTaskFullTestsBulk2.java | 101 ++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk2.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk2.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk2.java new file mode 100644 index 000000000..53ea3c1d5 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk2.java @@ -0,0 +1,101 @@ +package org.alfresco.rest.workflow.tasks; + +import javax.json.JsonObject; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.JsonBodyGenerator; +import org.alfresco.rest.model.RestTaskModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TaskModel; +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.BeforeMethod; +import org.testng.annotations.Test; + +public class UpdateTaskFullTestsBulk2 extends RestTest +{ + private UserModel userModel; + private SiteModel siteModel; + private FileModel fileModel; + private UserModel assigneeUser; + private TaskModel taskModel; + private RestTaskModel restTaskModel; + private UserModel adminUser; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); + fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + assigneeUser = dataUser.createRandomTestUser(); + } + + @BeforeMethod(alwaysRun = true) + public void createTask() throws Exception + { + taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from unclaimed to claimed") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + public void userCanUpdateTaskFromUnclaimedToClaimed() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); + restTaskModel = restClient.authenticateUser(userModel).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("claimed"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from unclaimed to delegated") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + public void userCanUpdateTaskFromUnclaimedToDelegated() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); + + JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); + + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from unclaimed to resolved") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + public void userCanUpdateTaskFromUnclaimedToResolved() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); + restTaskModel = restClient.authenticateUser(userModel).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("resolved"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from unclaimed to unclaimed") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + public void userCanUpdateTaskFromUnclaimedToUnclaimed() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); + restTaskModel = restClient.authenticateUser(userModel).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); + } +} \ No newline at end of file From c8b2a3ce7e63554e59da2d10d790cad7b965b77a Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Fri, 3 Feb 2017 15:58:58 +0200 Subject: [PATCH 0989/1491] TAS-2914 - update tasks from delegated to other states --- .../tasks/UpdateTaskFullTestsBulk1.java | 4 +- .../tasks/UpdateTaskFullTestsBulk2.java | 72 ++++++++++++++++++- 2 files changed, 73 insertions(+), 3 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk1.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk1.java index f30efad31..1ead445e1 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk1.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk1.java @@ -269,8 +269,8 @@ public class UpdateTaskFullTestsBulk1 extends RestTest restTaskModel = restClient.authenticateUser(owner) .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); restClient.assertStatusCodeIs(HttpStatus.CONFLICT).assertLastError() - .containsErrorKey(RestErrorModel.TAS_ALREADY_CLAIMED) - .containsSummary(RestErrorModel.TAS_ALREADY_CLAIMED) + .containsErrorKey(RestErrorModel.TASK_ALREADY_CLAIMED) + .containsSummary(RestErrorModel.TASK_ALREADY_CLAIMED) .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) .stackTraceIs(RestErrorModel.STACKTRACE); } diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk2.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk2.java index 53ea3c1d5..911a293b5 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk2.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk2.java @@ -5,12 +5,14 @@ import javax.json.JsonObject; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.core.JsonBodyGenerator; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestTaskModel; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TaskModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -68,7 +70,7 @@ public class UpdateTaskFullTestsBulk2 extends RestTest JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restTaskModel = restClient.authenticateUser(userModel).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); restClient.assertStatusCodeIs(HttpStatus.OK); restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); } @@ -98,4 +100,72 @@ public class UpdateTaskFullTestsBulk2 extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); } + + @Bug(id = "REPO-1982") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from delegated to unclaimed") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + public void userCanUpdateTaskFromDelegatedToUnclaimed() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); + restTaskModel = restClient.authenticateUser(userModel).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); + + restTaskModel = restClient.authenticateUser(userModel).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task cannot be updated from delegated to claimed since it is already claimed") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + public void userCannotUpdateTaskFromDelegatedToClaimed() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); + restTaskModel = restClient.authenticateUser(userModel).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); + + restTaskModel = restClient.authenticateUser(userModel).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); + restClient.assertStatusCodeIs(HttpStatus.CONFLICT).assertLastError() + .containsErrorKey(RestErrorModel.TASK_ALREADY_CLAIMED) + .containsSummary(RestErrorModel.TASK_ALREADY_CLAIMED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Bug(id = "REPO-1924") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from delegated to completed") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + public void userCanUpdateTaskFromDelegatedToCompleted() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); + restTaskModel = restClient.authenticateUser(userModel).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); + + restTaskModel = restClient.authenticateUser(userModel).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() + .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .containsSummary(RestErrorModel.DELEGATED_TASK_CAN_NOT_BE_COMPLETED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from delegated to resolved") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + public void userCanUpdateTaskFromDelegatedToResolved() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); + restTaskModel = restClient.authenticateUser(userModel).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); + + restTaskModel = restClient.authenticateUser(userModel).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("resolved"); + } } \ No newline at end of file From c607bdf218cbbf0b4e069040bc02385b2ebdb0b3 Mon Sep 17 00:00:00 2001 From: Bogdan Bocancea Date: Fri, 3 Feb 2017 16:03:44 +0200 Subject: [PATCH 0990/1491] TAS-2932: add full tests for delete task variable --- .../tasks/DeleteTaskVariableFullTests.java | 166 ++++++++++++++++++ 1 file changed, 166 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/tasks/DeleteTaskVariableFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/DeleteTaskVariableFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/DeleteTaskVariableFullTests.java new file mode 100644 index 000000000..76d4cff6c --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/DeleteTaskVariableFullTests.java @@ -0,0 +1,166 @@ +package org.alfresco.rest.workflow.tasks; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestTaskModel; +import org.alfresco.rest.model.RestVariableModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TaskModel; +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 bogdan.bocancea + */ +public class DeleteTaskVariableFullTests extends RestTest +{ + private UserModel userModel; + private SiteModel siteModel; + private FileModel fileModel; + private TaskModel taskModel; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(userModel); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Delete task variable twice") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + public void deleteTaskVarialbleTwice() throws Exception + { + restClient.authenticateUser(userModel); + RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + + restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables() + .assertThat().entriesListDoesNotContain("name", variableModel.getName()); + + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, variableModel.getName())) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Delete task variable with empty variable name") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + public void deleteTaskEmptyVarialbleName() throws Exception + { + restClient.authenticateUser(userModel); + RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + + restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); + variableModel.setName(""); + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) + .assertLastError().containsErrorKey(RestErrorModel.DELETE_EMPTY_ARGUMENT) + .containsSummary(RestErrorModel.DELETE_EMPTY_ARGUMENT) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Delete task variable with empty variable scope") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + public void deleteTaskEmptyVarialbleScope() throws Exception + { + restClient.authenticateUser(userModel); + RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + + restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); + variableModel.setScope(""); + variableModel.setType(""); + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables() + .assertThat().entriesListDoesNotContain("name", variableModel.getName()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Delete task variable with invalid variable name") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + public void deleteTaskInvalidVarialbleName() throws Exception + { + restClient.authenticateUser(userModel); + RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + + restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); + variableModel.setName("invalid-name"); + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalid-name")) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL, TestGroup.NETWORKS }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin from the same network is able to remove task variables") + public void addTaskVariablesByTenantAdmin() throws Exception + { + UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); + restClient.authenticateUser(dataUser.getAdminUser()).usingTenant().createTenant(adminTenantUser1); + RestProcessModel networkProcess1 = restClient.authenticateUser(adminTenantUser1).withWorkflowAPI() + .addProcess("activitiReview", adminTenantUser1, false, CMISUtil.Priority.High); + RestTaskModel task = restClient.authenticateUser(adminTenantUser1) + .withWorkflowAPI().usingProcess(networkProcess1).getProcessTasks().getOneRandomEntry(); + restClient.authenticateUser(adminTenantUser1); + RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + restClient.withWorkflowAPI() + .usingTask(task.onModel()) + .addTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.withWorkflowAPI().usingTask(task.onModel()).deleteTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingTask(task.onModel()).getTaskVariables() + .assertThat().entriesListDoesNotContain("name", variableModel.getName()); + } + + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL, TestGroup.NETWORKS }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin from the other network is not able to remove task variables") + public void addTaskVariablesByTenantAdminOtherNetwork() throws Exception + { + UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); + UserModel adminTenantUser2 = UserModel.getAdminTenantUser(); + restClient.authenticateUser(dataUser.getAdminUser()).usingTenant().createTenant(adminTenantUser1); + restClient.authenticateUser(dataUser.getAdminUser()).usingTenant().createTenant(adminTenantUser2); + + RestProcessModel networkProcess1 = restClient.authenticateUser(adminTenantUser1).withWorkflowAPI() + .addProcess("activitiReview", adminTenantUser1, false, CMISUtil.Priority.High); + RestTaskModel task = restClient.authenticateUser(adminTenantUser1) + .withWorkflowAPI().usingProcess(networkProcess1).getProcessTasks().getOneRandomEntry(); + restClient.authenticateUser(adminTenantUser1); + RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + restClient.withWorkflowAPI() + .usingTask(task.onModel()) + .addTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.authenticateUser(adminTenantUser2).withWorkflowAPI().usingTask(task.onModel()).deleteTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } +} From 1349d7733e797317cea283d88350452127503af6 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Fri, 3 Feb 2017 16:23:14 +0200 Subject: [PATCH 0991/1491] TAS-2916 - update task providing invalid values for state and select fields --- .../tasks/UpdateTaskFullTestsBulk2.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk2.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk2.java index 911a293b5..dbd1c9d64 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk2.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk2.java @@ -168,4 +168,30 @@ public class UpdateTaskFullTestsBulk2 extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("resolved"); } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Update task by providing empty select value") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + public void updateTaskByProvidingEmptySelectValue() throws Exception + { + restTaskModel = restClient.authenticateUser(userModel).withParams("select=").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(RestErrorModel.INVALID_SELECT_ERRORKEY) + .containsSummary(RestErrorModel.INVALID_SELECT) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Update task by providing empty select value") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + public void updateTaskByProvidingEmptyStateValue() throws Exception + { + restTaskModel = restClient.authenticateUser(userModel).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask(""); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() + .containsErrorKey(RestErrorModel.PUT_EMPTY_ARGUMENT) + .containsSummary(RestErrorModel.PUT_EMPTY_ARGUMENT) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } } \ No newline at end of file From 8260d3cce47cd80cc4da0b0e22b961dedc76b279 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Fri, 3 Feb 2017 16:34:38 +0200 Subject: [PATCH 0992/1491] TAS-2919 one full test added for updateTask --- .../tasks/UpdateTaskFullTestsBulk1.java | 34 +++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk1.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk1.java index f30efad31..672fd4441 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk1.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk1.java @@ -8,6 +8,7 @@ import org.alfresco.rest.core.JsonBodyGenerator; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessDefinitionModel; import org.alfresco.rest.model.RestTaskModel; +import org.alfresco.rest.model.RestVariableModelsCollection; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TaskModel; @@ -258,8 +259,8 @@ public class UpdateTaskFullTestsBulk1 extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task can be updated from status claimed to claimed and response is 200") - public void taskCanBeUpdatedFromClaimedToClaimed() throws Exception + description = "Verify task cannot be updated from status claimed to claimed and response is 200") + public void taskCannotBeUpdatedFromClaimedToClaimed() throws Exception { restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).getTask(); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -274,4 +275,33 @@ public class UpdateTaskFullTestsBulk1 extends RestTest .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) .stackTraceIs(RestErrorModel.STACKTRACE); } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task owner can complete task with valid variables and response is 200") + public void taskOwnerCanCompleteTaskWithValidVariables() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("state", "completed") + .add("variables", JsonBodyGenerator.defineJSONArray() + .add(JsonBodyGenerator.defineJSON() + .add("name", "bpm_priority") + .add("type", "d:int") + .add("value", 3) + .add("scope", "global").build()) + ).build(); + + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state,variables").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("priority").is(1) + .and().field("state").is("completed") + .and().field("assignee").is(taskModel.getAssignee()); + RestVariableModelsCollection variables = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(restTaskModel).getTaskVariables(); + restClient.assertStatusCodeIs(HttpStatus.OK); + variables.getVariableByName("bpm_priority").assertThat().field("scope").is("global") + .and().field("name").is("bpm_priority") + .and().field("type").is("d:int") + .and().field("value").is(3); + } } From 9cf159f4d86dc2cc90813363081cb5bb9502457e Mon Sep 17 00:00:00 2001 From: cagache Date: Fri, 3 Feb 2017 16:37:02 +0200 Subject: [PATCH 0993/1491] TAS - 2927 - getTaskFormModel --- .../tasks/GetTaskFormModelFullTests.java | 166 ++++++++++++++++++ .../tasks/GetTaskFormModelSanityTests.java | 8 +- 2 files changed, 168 insertions(+), 6 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelFullTests.java new file mode 100644 index 000000000..d9b501d60 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelFullTests.java @@ -0,0 +1,166 @@ +package org.alfresco.rest.workflow.tasks; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.*; +import org.alfresco.utility.model.*; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Created by Claudia Agache on 2/3/2017. + */ +public class GetTaskFormModelFullTests extends RestTest +{ + UserModel userModel, adminUser; + SiteModel siteModel; + FileModel fileModel; + TaskModel taskModel; + RestFormModelsCollection returnedCollection; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + fileModel = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(userModel); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, + executionType = ExecutionType.REGRESSION, description = "Verify admin user gets all task form models with properties parameter applied and response is successful (200)") + public void adminGetsTaskFormModelsWithPropertiesParameter() throws Exception + { + returnedCollection = restClient.authenticateUser(adminUser).withParams("properties=qualifiedName,required").withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat().entriesListIsNotEmpty(); + returnedCollection.getOneRandomEntry().onModel() + .assertThat() + .field("qualifiedName").isNotEmpty().and() + .field("required").isNotEmpty().and() + .field("dataType").isNull().and() + .field("name").isNull().and() + .field("title").isNull().and() + .field("defaultValue").isNull().and() + .field("allowedValues").isNull().and() + .fieldsCount().is(2); + } + + @Bug(id = "MNT-17438") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify admin gets task form model with valid skipCount parameter applied using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + public void getTaskFormModelWithValidSkipCount() throws Exception + { + returnedCollection = restClient.authenticateUser(adminUser) + .withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); + restClient.assertStatusCodeIs(HttpStatus.OK); + RestFormModel firstTaskFormModel = returnedCollection.getEntries().get(0).onModel(); + RestFormModel secondTaskFormModel = returnedCollection.getEntries().get(1).onModel(); + + RestFormModelsCollection formModelsWithSkipCount = restClient.withParams("skipCount=2").withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); + restClient.assertStatusCodeIs(HttpStatus.OK); + formModelsWithSkipCount + .assertThat().entriesListDoesNotContain("name", firstTaskFormModel.getName()) + .assertThat().entriesListDoesNotContain("name", secondTaskFormModel.getName()) + .assertThat().entriesListCountIs(returnedCollection.getEntries().size()-2); + formModelsWithSkipCount.assertThat().paginationField("skipCount").is("2"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify admin doesn't get task form model with negative skipCount parameter applied using REST API") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + public void getTaskFormModelWithNegativeSkipCount() throws Exception + { + restClient.authenticateUser(adminUser).withParams("skipCount=-1").withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT) + .containsErrorKey(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE) + .statusCodeIs(HttpStatus.BAD_REQUEST); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify admin doesn't get task form model with non numeric skipCount parameter applied using REST API") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + public void getTaskFormModelWithNonNumericSkipCount() throws Exception + { + restClient.authenticateUser(adminUser).withParams("skipCount=A").withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "A")); + } + + @Bug(id = "MNT-17438") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify admin gets task form model with valid maxItems parameter applied using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + public void getTaskFormModelWithValidMaxItems() throws Exception + { + returnedCollection = restClient.authenticateUser(adminUser) + .withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); + restClient.assertStatusCodeIs(HttpStatus.OK); + RestFormModel firstTaskFormModel = returnedCollection.getEntries().get(0).onModel(); + RestFormModel secondTaskFormModel = returnedCollection.getEntries().get(1).onModel(); + + RestFormModelsCollection formModelsWithMaxItems = restClient.withParams("maxItems=2").withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); + restClient.assertStatusCodeIs(HttpStatus.OK); + formModelsWithMaxItems + .assertThat().entriesListContains("name", firstTaskFormModel.getName()) + .assertThat().entriesListContains("name", secondTaskFormModel.getName()) + .assertThat().entriesListCountIs(2); + formModelsWithMaxItems.assertThat().paginationField("maxItems").is("2"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify admin doesn't get task form model with negative maxItems parameter applied using REST API") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + public void getTaskFormModelWithNegativeMaxItems() throws Exception + { + restClient.authenticateUser(adminUser).withParams("maxItems=-1").withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) + .containsErrorKey(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE) + .statusCodeIs(HttpStatus.BAD_REQUEST); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify admin doesn't get task form model with non numeric maxItems parameter applied using REST API") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + public void getTaskFormModelWithNonNumericMaxItems() throws Exception + { + restClient.authenticateUser(adminUser).withParams("maxItems=A").withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "A")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL, TestGroup.NETWORKS }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, + executionType = ExecutionType.REGRESSION, description = "Verify network admin user gets all task form models inside his network with Rest API and response is successful (200)") + public void networkAdminGetsTaskFormModels() throws Exception + { + UserModel adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser); + UserModel tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant1"); + + RestProcessModel networkProcess = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() + .addProcess("activitiReview", tenantUser, false, CMISUtil.Priority.High); + RestTaskModel networkTask = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() + .usingProcess(networkProcess).getProcessTasks().getOneRandomEntry().onModel(); + + restClient.authenticateUser(adminUser).withWorkflowAPI().usingTask(networkTask).getTaskFormModel(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + + returnedCollection = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().usingTask(networkTask).getTaskFormModel(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat().entriesListIsNotEmpty(); + } +} diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelSanityTests.java index 0bb678207..36a98a800 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelSanityTests.java @@ -40,8 +40,7 @@ public class GetTaskFormModelSanityTests extends RestTest executionType = ExecutionType.SANITY, description = "Verify admin user gets all task form models with Rest API and response is successful (200)") public void adminGetsTaskFormModels() throws Exception { - restClient.authenticateUser(dataUser.getAdminUser()); - returnedCollection = restClient.withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); + returnedCollection = restClient.authenticateUser(dataUser.getAdminUser()).withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); restClient.assertStatusCodeIs(HttpStatus.OK); returnedCollection.assertThat().entriesListIsNotEmpty(); @@ -62,8 +61,6 @@ public class GetTaskFormModelSanityTests extends RestTest { returnedCollection.assertThat().entriesListContains("qualifiedName", formQualifiedName); } - - restClient.assertStatusCodeIs(HttpStatus.OK); } @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) @@ -71,8 +68,7 @@ public class GetTaskFormModelSanityTests extends RestTest executionType = ExecutionType.SANITY, description = "Verify user involved in task gets all the task form models with Rest API and response is successful (200)") public void involvedUserGetsTaskFormModels() throws Exception { - restClient.authenticateUser(userModel); - returnedCollection = restClient.withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); + returnedCollection = restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); restClient.assertStatusCodeIs(HttpStatus.OK); returnedCollection.assertThat().entriesListIsNotEmpty(); } From 897d7ddb4abb243792b2739cd44cb67125185589 Mon Sep 17 00:00:00 2001 From: mionescu Date: Fri, 3 Feb 2017 16:49:34 +0200 Subject: [PATCH 0994/1491] test- added new testcases - Full --- .../processes/DeleteProcessItemFullTests.java | 267 ++++++++++++++++++ 1 file changed, 267 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessItemFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessItemFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessItemFullTests.java new file mode 100644 index 000000000..13f9acf76 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessItemFullTests.java @@ -0,0 +1,267 @@ +package org.alfresco.rest.workflow.processes; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.EmptyRestModelCollectionException; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestItemModel; +import org.alfresco.rest.model.RestItemModelsCollection; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.ProcessModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class DeleteProcessItemFullTests extends RestTest +{ + private FileModel document, document2; + private SiteModel siteModel; + private UserModel userWhoStartsProcess, assignee, adminUser, anotherUser, adminTenantUser, tenantUser, tenantUserAssignee, adminTenantUser2; + private ProcessModel processModel; + private RestItemModelsCollection items; + private RestItemModel processItem; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userWhoStartsProcess = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userWhoStartsProcess).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Try to delete existing process item using empty processId") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void deleteProcessItemUsingEmptyProcessId() throws Exception + { + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + document2 = dataContent.usingAdmin().usingSite(siteModel).createContent(DocumentType.MSPOWERPOINT); + processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + processModel.setId(""); + restClient.withWorkflowAPI().usingProcess(processModel).deleteProcessItem(processItem); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "The entity with id: ")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Add a new process item, update the item and then delete.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void createUpdateDeleteProcessItem() throws Exception + { + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + document2 = dataContent.usingAdmin().usingSite(siteModel).createContent(DocumentType.MSPOWERPOINT); + processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + processItem.setName("newItemName"); + processItem.assertThat().field("name").is("newItemName"); + + restClient.withWorkflowAPI().usingProcess(processModel).deleteProcessItem(processItem); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems() + .assertThat().entriesListDoesNotContain("name", processItem.getName()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Delete process item using any user.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void deleteProcessItemByAnyUser() throws Exception + { + anotherUser = dataUser.createRandomTestUser(); + + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + document2 = dataContent.usingAdmin().usingSite(siteModel).createContent(DocumentType.HTML); + processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(anotherUser).withWorkflowAPI().usingProcess(processModel) + .deleteProcessItem(processItem); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError() + .containsSummary(String.format(RestErrorModel.ACCESS_INFORMATION_NOT_ALLOWED, processModel.getId())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .containsErrorKey(String.format(RestErrorModel.ACCESS_INFORMATION_NOT_ALLOWED, processModel.getId())) + .stackTraceIs(RestErrorModel.STACKTRACE);; + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Delete process item with admin.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void deleteProcessItemWithAdmin() throws Exception + { + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + document2 = dataContent.usingAdmin().usingSite(siteModel).createContent(DocumentType.HTML); + processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(adminUser).withWorkflowAPI().usingProcess(processModel) + .deleteProcessItem(processItem); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() + .assertThat().entriesListDoesNotContain("name", processItem.getName()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Delete process item by the user who is involved in the process.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void deleteProcessItemByUserInvolvedInTheProcess() throws Exception + { + processModel = restClient.authenticateUser(assignee).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(processModel) + .deleteProcessItem(processItem); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() + .assertThat().entriesListDoesNotContain("name", processItem.getName()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Delete process item by the user who started the process.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void deleteProcessItemByUserThatStartedTheProcess() throws Exception + { + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingProcess(processModel) + .deleteProcessItem(processItem); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() + .assertThat().entriesListDoesNotContain("name", processItem.getName()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Delete process item for a deleted process.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void deleteProcessItemsForDeletedProcess() throws Exception + { + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.withWorkflowAPI().usingProcess(processModel).deleteProcess(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withWorkflowAPI().usingProcess(processModel).deleteProcessItem(processItem); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, processModel.getId())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Delete process item by inexistent user.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void deleteProcessItemByInexistentUser() throws Exception + { + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(UserModel.getRandomUserModel()).withWorkflowAPI().usingProcess(processModel) + .deleteProcessItem(processItem); + + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Delete process item for process without items.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL}, + expectedExceptions = EmptyRestModelCollectionException.class) + public void deleteProcessItemsForProcessWithoutItems() throws Exception + { + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI() + .addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.Normal); + + items = restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems(); + restClient.assertStatusCodeIs(HttpStatus.OK); + items.assertThat().entriesListIsEmpty(); + + restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingProcess(processModel) + .deleteProcessItem(items.getOneRandomEntry()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Delete process item using by the admin in same network.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL, TestGroup.NETWORKS }) + public void deleteProcessItemByAdminSameNetwork() throws Exception + { + restClient.authenticateUser(adminUser); + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.usingTenant().createTenant(adminTenantUser); + + tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); + + siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); + dataWorkflow.usingUser(tenantUser).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(tenantUserAssignee); + + processModel = restClient.withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(adminTenantUser).withWorkflowAPI().usingProcess(processModel) + .deleteProcessItem(processItem); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() + .assertThat().entriesListDoesNotContain("name", processItem.getName()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Delete process item using by admin in other network.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE, TestGroup.NETWORKS }) + public void deleteProcessItemByAdminInOtherNetwork() throws Exception + { + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser); + tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); + tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + + adminTenantUser2 = UserModel.getAdminTenantUser(); + restClient.usingTenant().createTenant(adminTenantUser2); + + siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); + dataWorkflow.usingUser(tenantUser).usingSite(siteModel).usingResource(document) + .createNewTaskAndAssignTo(tenantUserAssignee); + + processModel = restClient.withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(adminTenantUser2).withWorkflowAPI().usingProcess(processModel) + .deleteProcessItem(processItem); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError() + .containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .containsErrorKey(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + +} From ea735c2491aa60b7c1329cb2a24931095af8ee59 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Fri, 3 Feb 2017 16:50:34 +0200 Subject: [PATCH 0995/1491] Added ome end to end scenarios --- .../alfresco/rest/FunctionalCasesTests.java | 62 ++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java b/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java index e128a7817..18ebcaae8 100644 --- a/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java +++ b/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java @@ -2,6 +2,7 @@ package org.alfresco.rest; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.model.RestActivityModelsCollection; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestFavoriteSiteModel; import org.alfresco.rest.model.RestSiteMemberModel; import org.alfresco.rest.model.RestSiteMembershipRequestModelsCollection; @@ -20,7 +21,7 @@ import org.testng.annotations.Test; public class FunctionalCasesTests extends RestTest { private UserModel adminUserModel; - private SiteModel siteModel, moderatedSite; + private SiteModel siteModel, moderatedSite, privateSite; private RestSiteMemberModel updatedMember; private RestSiteMembershipRequestModelsCollection returnedCollection; private RestFavoriteSiteModel restFavoriteSiteModel; @@ -35,6 +36,7 @@ public class FunctionalCasesTests extends RestTest siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); dataUser.addUserToSite(user, siteModel, UserRole.SiteManager); moderatedSite = dataSite.usingUser(adminUserModel).createModeratedRandomSite(); + privateSite = dataSite.usingUser(adminUserModel).createPrivateRandomSite(); } /** @@ -240,4 +242,62 @@ public class FunctionalCasesTests extends RestTest .and().entriesListContains("activityType", "org.alfresco.documentlibrary.file-deleted") .and().entriesListContains("activitySummary.objectId", file.getNodeRefWithoutVersion()); } + + /** + * Scenario: + * 1. Add user to private site + * 2. Remove user from private site + * 3. User creates membership request to the same private site + */ + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, description = "Verify membership request by user after it was removed from site gets status code 404") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + public void userCanNotCreateMembershipRequestIfItWasRemovedFromPrivateSite() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + newMember.setUserRole(UserRole.SiteCollaborator); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSite).addPerson(newMember) + .assertThat().field("id").is(newMember.getUsername()); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(newMember).deleteSiteMember(privateSite); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest(privateSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, newMember.getUsername(), privateSite.getTitle())); + } + + /** + * Scenario: + * 1. User creates membership request to moderated site + * 2. Accept membership request + * 3. Remove user from moderated site + * 4. Add user on private site + */ + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, description = "Verify user can be added back after if was removed from site") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + public void userCanBeAddedAfterItWasRemovedFromSite() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + newMember.setUserRole(UserRole.SiteCollaborator); + + restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestTaskModel taskModel = restClient.authenticateUser(newMember).withWorkflowAPI().getTasks().getTaskModelByDescription(moderatedSite); + workflow.approveSiteMembershipRequest(adminUserModel.getUsername(), adminUserModel.getPassword(), taskModel.getId(), true, "Accept"); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(newMember).deleteSiteMember(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withCoreAPI().usingSite(moderatedSite).getSiteMembers().assertThat().entriesListDoesNotContain("id", newMember.getUsername()); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSite).addPerson(newMember) + .assertThat().field("id").is(newMember.getUsername()); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.withCoreAPI().usingSite(moderatedSite).getSiteMembers().assertThat().entriesListContains("id", newMember.getUsername()); + + } } \ No newline at end of file From 5d19d5420bbf2a25301f238dffa5579f219b4d04 Mon Sep 17 00:00:00 2001 From: mionescu Date: Fri, 3 Feb 2017 16:57:08 +0200 Subject: [PATCH 0996/1491] removed TC:deleteProcessVariableWithAnyUser --- .../DeleteProcessVariableFullTests.java | 25 +------------------ 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableFullTests.java index 40ec2877b..ffe0ae06d 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableFullTests.java @@ -56,30 +56,7 @@ public class DeleteProcessVariableFullTests extends RestTest .containsErrorKey(RestErrorModel.DELETE_EMPTY_ARGUMENT) .stackTraceIs(RestErrorModel.STACKTRACE); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Delete process variable using any user.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) - public void deleteProcessVariableWithAnyUser() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(anotherUser).withWorkflowAPI() - .addProcess("activitiAdhoc", anotherUser, false, Priority.Normal); - - variableModel = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - variableModel.assertThat().field("name").is(variableModel.getName()).and().field("type") - .is(variableModel.getType()).and().field("value") - .is(variableModel.getValue()); - - restClient.authenticateUser(anotherUser).withWorkflowAPI().usingProcess(processModel) - .deleteProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() - .assertThat() - .entriesListDoesNotContain("name", variableModel.getName()); - } - + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add a new process varaiables, update the variable and then delete.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) From b10edf1e5fb81410151d665a63f3b778786c411b Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Fri, 3 Feb 2017 16:59:58 +0200 Subject: [PATCH 0997/1491] TAS-2915 - update tasks from resolved to other states --- .../tasks/UpdateTaskFullTestsBulk2.java | 67 ++++++++++++++++++- 1 file changed, 65 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk2.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk2.java index dbd1c9d64..0a04ac2a9 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk2.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk2.java @@ -169,6 +169,69 @@ public class UpdateTaskFullTestsBulk2 extends RestTest restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("resolved"); } + @Bug(id = "REPO-1982") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from resolved to unclaimed") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + public void userCanUpdateTaskFromResolvedToUnclaimed() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + + restTaskModel = restClient.authenticateUser(userModel).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("resolved"); + } + + @Bug(id = "REPO-1982") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task cannot be updated from resolved to claimed") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + public void updateTaskFromResolvedToClaimed() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + + // assignee tries to claim the task + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + + // owner tries to claim the task + restTaskModel = restClient.authenticateUser(userModel).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("resolved"); + } + + @Bug(id = "REPO-1982") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from resolved to delegated") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + public void userCannotUpdateTaskFromResolvedToDelegated() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + + JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); + restTaskModel = restClient.authenticateUser(userModel).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); + } + + @Bug(id = "REPO-1982") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from resolved to resolved") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + public void userCannotUpdateTaskFromResolvedToResolved() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + + restTaskModel = restClient.authenticateUser(userModel).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("resolved"); + } + + @Bug(id = "REPO-1982") @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Update task by providing empty select value") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) @@ -183,11 +246,11 @@ public class UpdateTaskFullTestsBulk2 extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Update task by providing empty select value") + description = "Update task by providing empty state value") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) public void updateTaskByProvidingEmptyStateValue() throws Exception { - restTaskModel = restClient.authenticateUser(userModel).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask(""); + restTaskModel = restClient.authenticateUser(userModel).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask(" "); restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() .containsErrorKey(RestErrorModel.PUT_EMPTY_ARGUMENT) .containsSummary(RestErrorModel.PUT_EMPTY_ARGUMENT) From 8c27d43fd206ae644b551131c71770295bae5fb6 Mon Sep 17 00:00:00 2001 From: mionescu Date: Fri, 3 Feb 2017 17:21:35 +0200 Subject: [PATCH 0998/1491] removed unused variables --- .../workflow/processes/DeleteProcessVariableFullTests.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableFullTests.java index ffe0ae06d..06625e13a 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableFullTests.java @@ -21,7 +21,7 @@ public class DeleteProcessVariableFullTests extends RestTest { private FileModel document; private SiteModel siteModel; - private UserModel userWhoStartsTask, assignee, anotherUser, adminUser; + private UserModel userWhoStartsTask, assignee, adminUser; private RestProcessModel restProcessModel; private ProcessModel processModel; private RestProcessVariableModel variableModel, updatedVariable; @@ -31,8 +31,7 @@ public class DeleteProcessVariableFullTests extends RestTest { adminUser = dataUser.getAdminUser(); userWhoStartsTask = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - anotherUser = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); processModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createSingleReviewerTaskAndAssignTo(assignee); From 74218b93fbef1ab249fcdd9585af6849fb751c14 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Fri, 3 Feb 2017 18:45:09 +0200 Subject: [PATCH 0999/1491] added tests to complete all update scenarios for owner and assignee --- .../tasks/UpdateTaskFullTestsBulk1.java | 241 +++++++++++++++++- 1 file changed, 227 insertions(+), 14 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk1.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk1.java index 672fd4441..49497c376 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk1.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk1.java @@ -143,8 +143,28 @@ public class UpdateTaskFullTestsBulk1 extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task cannot be updated from status completed to delegated and response is 404") - public void taskCannotBeUpdatedFromCompletedToDelegated() throws Exception + description = "Verify owner cannot update task from status completed to delegated and response is 404") + public void ownerCannotUpdateTaskFromCompletedToDelegated() throws Exception + { + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("completed"); + + restClient.authenticateUser(owner) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("delegated"); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() + .containsErrorKey(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) + .containsSummary(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify assignee cannot update task from status completed to delegated and response is 404") + public void assigneeCannotUpdateTaskFromCompletedToDelegated() throws Exception { restTaskModel = restClient.authenticateUser(owner) .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); @@ -163,8 +183,28 @@ public class UpdateTaskFullTestsBulk1 extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task cannot be updated from status completed to resolved and response is 404") - public void taskCannotBeUpdatedFromCompletedToResolved() throws Exception + description = "Verify owner cannot update task from status completed to resolved and response is 404") + public void ownerCannotUpdateTaskFromCompletedToResolved() throws Exception + { + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("completed"); + + restClient.authenticateUser(owner) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() + .containsErrorKey(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) + .containsSummary(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify assignee cannot update task from status completed to resolved and response is 404") + public void assigneeCannotUpdateTaskFromCompletedToResolved() throws Exception { restTaskModel = restClient.authenticateUser(owner) .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); @@ -183,8 +223,28 @@ public class UpdateTaskFullTestsBulk1 extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task cannot be updated from status completed to completed and response is 404") - public void taskCannotBeUpdatedFromCompletedToCompleted() throws Exception + description = "Verify owner cannot update task from status completed to completed and response is 404") + public void ownerCannotUpdateTaskFromCompletedToCompleted() throws Exception + { + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("completed"); + + restClient.authenticateUser(owner) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() + .containsErrorKey(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) + .containsSummary(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify assignee cannot update task from status completed to completed and response is 404") + public void assigneeCannotUpdateTaskFromCompletedToCompleted() throws Exception { restTaskModel = restClient.authenticateUser(owner) .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); @@ -203,8 +263,8 @@ public class UpdateTaskFullTestsBulk1 extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task can be updated from status claimed to unclaimed and response is 200") - public void taskCanBeUpdatedFromClaimedToUnclaimed() throws Exception + description = "Verify owner can update task from status claimed to unclaimed and response is 200") + public void ownerCanUpdateTaskFromClaimedToUnclaimed() throws Exception { restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).getTask(); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -219,8 +279,24 @@ public class UpdateTaskFullTestsBulk1 extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task can be updated from status claimed to delegated and response is 200") - public void taskCanBeUpdatedFromClaimedToDelegated() throws Exception + description = "Verify assignee can update task from status claimed to unclaimed and response is 200") + public void assigneeCanUpdateTaskFromClaimedToUnclaimed() throws Exception + { + restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).getTask(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("claimed"); + + restTaskModel = restClient.authenticateUser(assigneeUser) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("unclaimed"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify owner can update task from status claimed to delegated and response is 200") + public void ownerCanUpdateTaskFromClaimedToDelegated() throws Exception { restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).getTask(); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -242,8 +318,31 @@ public class UpdateTaskFullTestsBulk1 extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task can be updated from status claimed to resolved and response is 200") - public void taskCanBeUpdatedFromClaimedToResolved() throws Exception + description = "Verify assignee can update task from status claimed to delegated and response is 200") + public void assigneeCanUpdateTaskFromClaimedToDelegated() throws Exception + { + restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).getTask(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("claimed"); + + UserModel newAssignee = dataUser.createRandomTestUser(); + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("state", "delegated") + .add("assignee", newAssignee.getUsername()).build(); + + restTaskModel = restClient.authenticateUser(assigneeUser) + .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("delegated") + .and().field("assignee").is(newAssignee.getUsername()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify owner can update task from status claimed to resolved and response is 200") + public void ownerCanUpdateTaskFromClaimedToResolved() throws Exception { restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).getTask(); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -259,8 +358,25 @@ public class UpdateTaskFullTestsBulk1 extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task cannot be updated from status claimed to claimed and response is 200") - public void taskCannotBeUpdatedFromClaimedToClaimed() throws Exception + description = "Verify assignee can update task from status claimed to resolved and response is 200") + public void assigneeCanUpdateTaskFromClaimedToResolved() throws Exception + { + restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).getTask(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("claimed"); + + restTaskModel = restClient.authenticateUser(assigneeUser) + .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("resolved"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify owner cannot update task from status claimed to claimed and response is 409") + public void ownerCannotUpdateTaskFromClaimedToClaimed() throws Exception { restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).getTask(); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -276,6 +392,23 @@ public class UpdateTaskFullTestsBulk1 extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE); } + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify assignee can update task from status claimed to claimed and response is 200") + public void assigneeCanUpdateTaskFromClaimedToClaimed() throws Exception + { + restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).getTask(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("claimed"); + + restTaskModel = restClient.authenticateUser(assigneeUser) + .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("claimed"); + } + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify task owner can complete task with valid variables and response is 200") @@ -304,4 +437,84 @@ public class UpdateTaskFullTestsBulk1 extends RestTest .and().field("type").is("d:int") .and().field("value").is(3); } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task owner cannot complete task with empty variables array and response is 200") + public void taskOwnerCannotUpdateTaskWithEmptyVariablesArray() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("state", "completed") + .add("variables", JsonBodyGenerator.defineJSONArray() + ).build(); + + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state,variables").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("priority").is(1) + .and().field("state").is("completed") + .and().field("assignee").is(taskModel.getAssignee()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task owner cannot complete task with empty variables json body and response is 200") + public void taskOwnerCannotUpdateTaskWithEmptyVariablesJsonBody() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("state", "completed") + .add("variables", JsonBodyGenerator.defineJSONArray() + .add(JsonBodyGenerator.defineJSON().build()) + ).build(); + + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state,variables").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(RestErrorModel.VARIABLE_NAME_REQUIRED) + .containsSummary(RestErrorModel.VARIABLE_NAME_REQUIRED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify any user with no relation to task is forbidden to delegate other task with Rest API (403)") + public void anyUserIsForbiddenToDelegateOtherTask() throws Exception + { + UserModel anyUser= dataUser.createRandomTestUser(); + + restTaskModel = restClient.authenticateUser(anyUser).withWorkflowAPI().usingTask(taskModel).updateTask("delegated"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify any user with no relation to task is forbidden to resolve other task with Rest API (403)") + public void anyUserIsForbiddenToResolveOtherTask() throws Exception + { + UserModel anyUser= dataUser.createRandomTestUser(); + + restTaskModel = restClient.authenticateUser(anyUser).withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify any user with no relation to task is forbidden to claim other task with Rest API (403)") + public void anyUserIsForbiddenToClaimOtherTask() throws Exception + { + UserModel anyUser= dataUser.createRandomTestUser(); + + restTaskModel = restClient.authenticateUser(anyUser).withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify any user with no relation to task is forbidden to unclaim other task with Rest API (403)") + public void anyUserIsForbiddenToUnclaimOtherTask() throws Exception + { + UserModel anyUser= dataUser.createRandomTestUser(); + + restTaskModel = restClient.authenticateUser(anyUser).withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); + } } From 9bd086dbf619b1f6900b2b0fcbb410d02d4b9e92 Mon Sep 17 00:00:00 2001 From: Andrei Rusu Date: Mon, 6 Feb 2017 10:39:54 +0200 Subject: [PATCH 1000/1491] updated tests GetTagFullTests --- e2e-test/java/org/alfresco/rest/tags/GetTagFullTests.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/tags/GetTagFullTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagFullTests.java index db657220d..f16116f0d 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetTagFullTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetTagFullTests.java @@ -84,8 +84,8 @@ public class GetTagFullTests extends RestTest restClient.withParams("skipCount=abc").withCoreAPI().getTag(tag); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(RestErrorModel.INVALID_SKIPCOUNT) - .containsSummary(RestErrorModel.INVALID_SKIPCOUNT) + .containsErrorKey(String.format(RestErrorModel.INVALID_SKIPCOUNT, "abc")) + .containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "abc")) .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) .stackTraceIs(RestErrorModel.STACKTRACE); } From f9443cc479875f60c78a3128c1c0a3f004fe81df Mon Sep 17 00:00:00 2001 From: Andrei Rusu Date: Mon, 6 Feb 2017 10:55:28 +0200 Subject: [PATCH 1001/1491] updated tests UpdateTag Full and Sanity tests --- .../alfresco/rest/tags/UpdateTagFullTests.java | 17 ----------------- .../rest/tags/UpdateTagSanityTests.java | 7 +++++-- 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/tags/UpdateTagFullTests.java b/e2e-test/java/org/alfresco/rest/tags/UpdateTagFullTests.java index 1d8a9242c..d8dcb0066 100644 --- a/e2e-test/java/org/alfresco/rest/tags/UpdateTagFullTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/UpdateTagFullTests.java @@ -3,7 +3,6 @@ package org.alfresco.rest.tags; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestTagModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; @@ -88,22 +87,6 @@ public class UpdateTagFullTests extends RestTest returnedModel.assertThat().field("tag").is(specialCharsString); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user can't update tags with Rest API and status code is 403." - + "Check default error model schema.") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) - public void collaboratorIsNotAbleToUpdateTagCheckDefaultErrorModelSchema() throws JsonToModelConversionException, Exception - { - String newTag = "newTag"; - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.withCoreAPI().usingTag(oldTag).update(newTag); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify Admin user can provide existing tag for new tag value.") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) diff --git a/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java index b50ceb2ab..4b6bb81ae 100644 --- a/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java @@ -74,11 +74,14 @@ public class UpdateTagSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user can't update tags with Rest API and status code is 403") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) - public void collaboratorIsNotAbleToUpdateTag() throws JsonToModelConversionException, Exception + public void collaboratorIsNotAbleToUpdateTagCheckDefaultErrorModelSchema() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); restClient.withCoreAPI().usingTag(oldTag).update(randomTag); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); } @TestRail(section = { TestGroup.REST_API, From 9b51758f3d4964915a56e0dea541e877102bdf86 Mon Sep 17 00:00:00 2001 From: cagache Date: Mon, 6 Feb 2017 10:55:41 +0200 Subject: [PATCH 1002/1491] TAS - 2937 - end-to-end scenario for comments --- .../alfresco/rest/FunctionalCasesTests.java | 43 ++++++++++++++++--- 1 file changed, 38 insertions(+), 5 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java b/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java index e128a7817..d333b06da 100644 --- a/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java +++ b/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java @@ -1,11 +1,7 @@ package org.alfresco.rest; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.model.RestActivityModelsCollection; -import org.alfresco.rest.model.RestFavoriteSiteModel; -import org.alfresco.rest.model.RestSiteMemberModel; -import org.alfresco.rest.model.RestSiteMembershipRequestModelsCollection; -import org.alfresco.rest.model.RestTaskModel; +import org.alfresco.rest.model.*; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; @@ -240,4 +236,41 @@ public class FunctionalCasesTests extends RestTest .and().entriesListContains("activityType", "org.alfresco.documentlibrary.file-deleted") .and().entriesListContains("activitySummary.objectId", file.getNodeRefWithoutVersion()); } + + /** + * 1. Post one comment + * 2. Get comment details + * 3. Update comment + * 4. Get again comment details + * 5. Delete comment + */ + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, + executionType = ExecutionType.REGRESSION, + description = "Add comment to a file, then get comment details. Update it and check that get comment returns updated details. Delete comment then check that file has no comments.") + public void addUpdateDeleteCommentThenGetCommentDetails() throws Exception + { + FileModel file = dataContent.usingUser(user).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + RestCommentModel newComment = restClient.authenticateUser(user).withCoreAPI().usingResource(file).addComment("new comment"); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestCommentModelsCollection fileComments = restClient.withCoreAPI().usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + fileComments.assertThat().entriesListContains("content", newComment.getContent()); + + RestCommentModel updatedComment = restClient.withCoreAPI().usingResource(file).updateComment(newComment, "updated comment"); + restClient.assertStatusCodeIs(HttpStatus.OK); + + fileComments = restClient.withCoreAPI().usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + fileComments.assertThat().entriesListContains("content", updatedComment.getContent()) + .assertThat().entriesListDoesNotContain("content", newComment.getContent()); + + restClient.withCoreAPI().usingResource(file).deleteComment(updatedComment); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + fileComments = restClient.withCoreAPI().usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + fileComments.assertThat().entriesListIsEmpty(); + } } \ No newline at end of file From 419018bad8b6052a5f24fe45ad69471246da014f Mon Sep 17 00:00:00 2001 From: Andreea Nechifor Date: Mon, 6 Feb 2017 11:03:14 +0200 Subject: [PATCH 1003/1491] added testCase --- .../alfresco/rest/FunctionalCasesTests.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java b/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java index e128a7817..5780f3254 100644 --- a/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java +++ b/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java @@ -26,12 +26,14 @@ public class FunctionalCasesTests extends RestTest private RestFavoriteSiteModel restFavoriteSiteModel; private RestActivityModelsCollection activities; private UserModel user; + private UserModel userJoinSite; @BeforeClass(alwaysRun=true) public void dataPreparation() throws Exception { adminUserModel = dataUser.getAdminUser(); user = dataUser.createRandomTestUser(); + userJoinSite = dataUser.createRandomTestUser(); siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); dataUser.addUserToSite(user, siteModel, UserRole.SiteManager); moderatedSite = dataSite.usingUser(adminUserModel).createModeratedRandomSite(); @@ -240,4 +242,25 @@ public class FunctionalCasesTests extends RestTest .and().entriesListContains("activityType", "org.alfresco.documentlibrary.file-deleted") .and().entriesListContains("activitySummary.objectId", file.getNodeRefWithoutVersion()); } + + /** + * Scenario: + * 1. join an user to a site + * 2. Check action is included in person activities list + * + * @throws Exception + */ + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Create an user, join the user to a site and check that activity is included in person activities") + public void joinUserToSiteThenGetPersonActivities() throws Exception{ + restClient.authenticateUser(userJoinSite).withCoreAPI().usingMe().addSiteMembershipRequest(siteModel); + activities = restClient.withCoreAPI().usingAuthUser().getPersonActivitiesUntilEntriesCountIs(2); + activities.assertThat().entriesListIsNotEmpty().and() + .entriesListContains("siteId", siteModel.getId()).and() + .entriesListContains("activityType", "org.alfresco.site.user-joined").and() + .entriesListContains("activitySummary.memberPersonId", userJoinSite.getUsername()); + + } } \ No newline at end of file From 83be33ca91366e0e8a6044a7511278dea3cfdaa7 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Mon, 6 Feb 2017 11:23:52 +0200 Subject: [PATCH 1004/1491] Fix update task test --- .../rest/workflow/tasks/UpdateTaskFullTestsBulk2.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk2.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk2.java index 0a04ac2a9..0c3693255 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk2.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk2.java @@ -251,9 +251,9 @@ public class UpdateTaskFullTestsBulk2 extends RestTest public void updateTaskByProvidingEmptyStateValue() throws Exception { restTaskModel = restClient.authenticateUser(userModel).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask(" "); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() - .containsErrorKey(RestErrorModel.PUT_EMPTY_ARGUMENT) - .containsSummary(RestErrorModel.PUT_EMPTY_ARGUMENT) + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(String.format(RestErrorModel.TASK_INVALID_STATE, " ")) + .containsSummary(String.format(RestErrorModel.TASK_INVALID_STATE, " ")) .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) .stackTraceIs(RestErrorModel.STACKTRACE); } From e4bebdb4e94e7499e21cac709ca88c365f1caba0 Mon Sep 17 00:00:00 2001 From: cagache Date: Mon, 6 Feb 2017 11:34:11 +0200 Subject: [PATCH 1005/1491] TAS-2938 --- .../alfresco/rest/FunctionalCasesTests.java | 120 +++++++++++------- 1 file changed, 77 insertions(+), 43 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java b/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java index f787f8890..593d8f72e 100644 --- a/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java +++ b/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java @@ -15,24 +15,22 @@ import org.testng.annotations.Test; public class FunctionalCasesTests extends RestTest { - private UserModel adminUserModel; - private SiteModel siteModel, moderatedSite; + private UserModel adminUser, manager; + private SiteModel publicSite, moderatedSite; private RestSiteMemberModel updatedMember; private RestSiteMembershipRequestModelsCollection returnedCollection; private RestFavoriteSiteModel restFavoriteSiteModel; private RestActivityModelsCollection activities; - private UserModel user; - private UserModel userJoinSite; + private FileModel file; @BeforeClass(alwaysRun=true) public void dataPreparation() throws Exception { - adminUserModel = dataUser.getAdminUser(); - user = dataUser.createRandomTestUser(); - userJoinSite = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - dataUser.addUserToSite(user, siteModel, UserRole.SiteManager); - moderatedSite = dataSite.usingUser(adminUserModel).createModeratedRandomSite(); + adminUser = dataUser.getAdminUser(); + manager = dataUser.createRandomTestUser(); + publicSite = dataSite.usingUser(adminUser).createPublicRandomSite(); + dataUser.addUserToSite(manager, publicSite, UserRole.SiteManager); + moderatedSite = dataSite.usingUser(adminUser).createModeratedRandomSite(); } /** @@ -49,26 +47,26 @@ public class FunctionalCasesTests extends RestTest { UserModel testUser = dataUser.createRandomTestUser("testUser"); testUser.setUserRole(UserRole.SiteManager); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(siteModel).addPerson(testUser) + restClient.authenticateUser(adminUser).withCoreAPI().usingSite(publicSite).addPerson(testUser) .assertThat().field("id").is(testUser.getUsername()) .and().field("role").is(testUser.getUserRole()); restClient.assertStatusCodeIs(HttpStatus.CREATED); testUser.setUserRole(UserRole.SiteCollaborator); - updatedMember = restClient.authenticateUser(adminUserModel).withCoreAPI() - .usingSite(siteModel).updateSiteMember(testUser); + updatedMember = restClient.withCoreAPI() + .usingSite(publicSite).updateSiteMember(testUser); restClient.assertStatusCodeIs(HttpStatus.OK); updatedMember.assertThat().field("id").is(testUser.getUsername()).and().field("role").is(testUser.getUserRole()); testUser.setUserRole(UserRole.SiteContributor); - updatedMember = restClient.authenticateUser(adminUserModel).withCoreAPI() - .usingSite(siteModel).updateSiteMember(testUser); + updatedMember = restClient.withCoreAPI() + .usingSite(publicSite).updateSiteMember(testUser); restClient.assertStatusCodeIs(HttpStatus.OK); updatedMember.assertThat().field("id").is(testUser.getUsername()).and().field("role").is(testUser.getUserRole()); testUser.setUserRole(UserRole.SiteConsumer); - updatedMember = restClient.authenticateUser(adminUserModel).withCoreAPI() - .usingSite(siteModel).updateSiteMember(testUser); + updatedMember = restClient.withCoreAPI() + .usingSite(publicSite).updateSiteMember(testUser); restClient.assertStatusCodeIs(HttpStatus.OK); updatedMember.assertThat().field("id").is(testUser.getUsername()).and().field("role").is(testUser.getUserRole()); } @@ -87,26 +85,26 @@ public class FunctionalCasesTests extends RestTest { UserModel testUser = dataUser.createRandomTestUser("testUser"); testUser.setUserRole(UserRole.SiteConsumer); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(siteModel).addPerson(testUser) + restClient.authenticateUser(adminUser).withCoreAPI().usingSite(publicSite).addPerson(testUser) .assertThat().field("id").is(testUser.getUsername()) .and().field("role").is(testUser.getUserRole()); restClient.assertStatusCodeIs(HttpStatus.CREATED); testUser.setUserRole(UserRole.SiteContributor); - updatedMember = restClient.authenticateUser(adminUserModel).withCoreAPI() - .usingSite(siteModel).updateSiteMember(testUser); + updatedMember = restClient.withCoreAPI() + .usingSite(publicSite).updateSiteMember(testUser); restClient.assertStatusCodeIs(HttpStatus.OK); updatedMember.assertThat().field("id").is(testUser.getUsername()).and().field("role").is(testUser.getUserRole()); testUser.setUserRole(UserRole.SiteCollaborator); - updatedMember = restClient.authenticateUser(adminUserModel).withCoreAPI() - .usingSite(siteModel).updateSiteMember(testUser); + updatedMember = restClient.withCoreAPI() + .usingSite(publicSite).updateSiteMember(testUser); restClient.assertStatusCodeIs(HttpStatus.OK); updatedMember.assertThat().field("id").is(testUser.getUsername()).and().field("role").is(testUser.getUserRole()); testUser.setUserRole(UserRole.SiteManager); - updatedMember = restClient.authenticateUser(adminUserModel).withCoreAPI() - .usingSite(siteModel).updateSiteMember(testUser); + updatedMember = restClient.withCoreAPI() + .usingSite(publicSite).updateSiteMember(testUser); restClient.assertStatusCodeIs(HttpStatus.OK); updatedMember.assertThat().field("id").is(testUser.getUsername()).and().field("role").is(testUser.getUserRole()); } @@ -129,7 +127,7 @@ public class FunctionalCasesTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.CREATED); RestTaskModel taskModel = restClient.authenticateUser(newMember).withWorkflowAPI().getTasks().getTaskModelByDescription(moderatedSite); - workflow.approveSiteMembershipRequest(adminUserModel.getUsername(), adminUserModel.getPassword(), taskModel.getId(), true, "Approve"); + workflow.approveSiteMembershipRequest(adminUser.getUsername(), adminUser.getPassword(), taskModel.getId(), true, "Approve"); returnedCollection = restClient.authenticateUser(newMember).withCoreAPI().usingMe().getSiteMembershipRequests(); restClient.assertStatusCodeIs(HttpStatus.OK); returnedCollection.assertThat().entriesListDoesNotContain("id", moderatedSite.getId()); @@ -162,7 +160,7 @@ public class FunctionalCasesTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.CREATED); RestTaskModel taskModel = restClient.authenticateUser(newMember).withWorkflowAPI().getTasks().getTaskModelByDescription(moderatedSite); - workflow.approveSiteMembershipRequest(adminUserModel.getUsername(), adminUserModel.getPassword(), taskModel.getId(), false, "Rejected"); + workflow.approveSiteMembershipRequest(adminUser.getUsername(), adminUser.getPassword(), taskModel.getId(), false, "Rejected"); returnedCollection = restClient.authenticateUser(newMember).withCoreAPI().usingMe().getSiteMembershipRequests(); restClient.assertStatusCodeIs(HttpStatus.OK); returnedCollection.assertThat().entriesListDoesNotContain("id", moderatedSite.getId()); @@ -175,9 +173,9 @@ public class FunctionalCasesTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.CREATED); taskModel = restClient.authenticateUser(newMember).withWorkflowAPI().getTasks().getTaskModelByDescription(moderatedSite); - workflow.approveSiteMembershipRequest(adminUserModel.getUsername(), adminUserModel.getPassword(), taskModel.getId(), true, "Accept"); + workflow.approveSiteMembershipRequest(adminUser.getUsername(), adminUser.getPassword(), taskModel.getId(), true, "Accept"); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(newMember).deleteSiteMember(moderatedSite); + restClient.authenticateUser(adminUser).withCoreAPI().usingUser(newMember).deleteSiteMember(moderatedSite); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); restClient.withCoreAPI().usingSite(moderatedSite).getSiteMembers().assertThat().entriesListDoesNotContain("id", newMember.getUsername()); @@ -193,10 +191,10 @@ public class FunctionalCasesTests extends RestTest description = "Add a file and check that activity is included in person activities") public void addFileThenGetPersonActivities() throws Exception { - FileModel file = dataContent.usingUser(user).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - activities = restClient.authenticateUser(user).withCoreAPI().usingAuthUser().getPersonActivitiesUntilEntriesCountIs(2); + file = dataContent.usingUser(manager).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); + activities = restClient.authenticateUser(manager).withCoreAPI().usingAuthUser().getPersonActivitiesUntilEntriesCountIs(2); activities.assertThat().entriesListIsNotEmpty() - .and().entriesListContains("siteId", siteModel.getId()) + .and().entriesListContains("siteId", publicSite.getId()) .and().entriesListContains("activityType", "org.alfresco.documentlibrary.file-added") .and().entriesListContains("activitySummary.objectId", file.getNodeRefWithoutVersion()); } @@ -211,11 +209,11 @@ public class FunctionalCasesTests extends RestTest description = "Add a comment to a file and check that activity is included in person activities") public void addCommentThenGetPersonActivities() throws Exception { - FileModel file = dataContent.usingUser(user).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(user).withCoreAPI().usingResource(file).addComment("new comment"); - activities = restClient.authenticateUser(user).withCoreAPI().usingAuthUser().getPersonActivitiesUntilEntriesCountIs(3); + file = dataContent.usingUser(manager).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(manager).withCoreAPI().usingResource(file).addComment("new comment"); + activities = restClient.authenticateUser(manager).withCoreAPI().usingAuthUser().getPersonActivitiesUntilEntriesCountIs(3); activities.assertThat().entriesListIsNotEmpty() - .and().entriesListContains("siteId", siteModel.getId()) + .and().entriesListContains("siteId", publicSite.getId()) .and().entriesListContains("activityType", "org.alfresco.comments.comment-created") .and().entriesListContains("activitySummary.objectId", file.getNodeRefWithoutVersion()); } @@ -230,11 +228,11 @@ public class FunctionalCasesTests extends RestTest description = "Add a file, delete it and check that activity is included in person activities") public void addFileDeleteItThenGetPersonActivities() throws Exception { - FileModel file = dataContent.usingUser(user).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - dataContent.usingUser(user).usingResource(file).deleteContent(); - activities = restClient.authenticateUser(user).withCoreAPI().usingAuthUser().getPersonActivitiesUntilEntriesCountIs(2); + file = dataContent.usingUser(manager).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); + dataContent.usingUser(manager).usingResource(file).deleteContent(); + activities = restClient.authenticateUser(manager).withCoreAPI().usingAuthUser().getPersonActivitiesUntilEntriesCountIs(2); activities.assertThat().entriesListIsNotEmpty() - .and().entriesListContains("siteId", siteModel.getId()) + .and().entriesListContains("siteId", publicSite.getId()) .and().entriesListContains("activityType", "org.alfresco.documentlibrary.file-deleted") .and().entriesListContains("activitySummary.objectId", file.getNodeRefWithoutVersion()); } @@ -252,8 +250,8 @@ public class FunctionalCasesTests extends RestTest description = "Add comment to a file, then get comment details. Update it and check that get comment returns updated details. Delete comment then check that file has no comments.") public void addUpdateDeleteCommentThenGetCommentDetails() throws Exception { - FileModel file = dataContent.usingUser(user).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - RestCommentModel newComment = restClient.authenticateUser(user).withCoreAPI().usingResource(file).addComment("new comment"); + file = dataContent.usingUser(manager).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); + RestCommentModel newComment = restClient.authenticateUser(manager).withCoreAPI().usingResource(file).addComment("new comment"); restClient.assertStatusCodeIs(HttpStatus.CREATED); RestCommentModelsCollection fileComments = restClient.withCoreAPI().usingResource(file).getNodeComments(); @@ -275,6 +273,40 @@ public class FunctionalCasesTests extends RestTest fileComments.assertThat().entriesListIsEmpty(); } + /** + * 1. Post one comment + * 2. Delete comment + * 3. Post the same comment again + */ + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, + executionType = ExecutionType.REGRESSION, + description = "Add a comment to a file, delete it, then added the same comment again.") + public void checkThatADeletedCommentCanBePostedAgain() throws Exception + { + file = dataContent.usingUser(manager).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); + RestCommentModel newComment = restClient.authenticateUser(manager).withCoreAPI().usingResource(file).addComment("new comment"); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestCommentModelsCollection fileComments = restClient.withCoreAPI().usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + fileComments.assertThat().entriesListContains("content", newComment.getContent()); + + restClient.withCoreAPI().usingResource(file).deleteComment(newComment); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + fileComments = restClient.withCoreAPI().usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + fileComments.assertThat().entriesListIsEmpty(); + + restClient.authenticateUser(manager).withCoreAPI().usingResource(file).addComment("new comment"); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + fileComments = restClient.withCoreAPI().usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + fileComments.assertThat().entriesListContains("content", newComment.getContent()); + } + /** * Scenario: * 1. join an user to a site @@ -288,10 +320,12 @@ public class FunctionalCasesTests extends RestTest description = "Create an user, join the user to a site and check that activity is included in person activities") public void joinUserToSiteThenGetPersonActivities() throws Exception { - restClient.authenticateUser(userJoinSite).withCoreAPI().usingMe().addSiteMembershipRequest(siteModel); + UserModel userJoinSite = dataUser.createRandomTestUser(); + + restClient.authenticateUser(userJoinSite).withCoreAPI().usingMe().addSiteMembershipRequest(publicSite); activities = restClient.withCoreAPI().usingAuthUser().getPersonActivitiesUntilEntriesCountIs(2); activities.assertThat().entriesListIsNotEmpty().and() - .entriesListContains("siteId", siteModel.getId()).and() + .entriesListContains("siteId", publicSite.getId()).and() .entriesListContains("activityType", "org.alfresco.site.user-joined").and() .entriesListContains("activitySummary.memberPersonId", userJoinSite.getUsername()); } From 7b23071acd97d68152bfa09339fc66692302f0b4 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Mon, 6 Feb 2017 11:43:07 +0200 Subject: [PATCH 1006/1491] Fix test name --- e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java b/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java index 2d602d2dd..c04a9cd34 100644 --- a/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java +++ b/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java @@ -279,9 +279,9 @@ public class FunctionalCasesTests extends RestTest * 4. Get comments and check if the above comment was deleted */ @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, - executionType = ExecutionType.REGRESSION, description = "Check that a comment of a document in a private site was also removed after deleting the document") + executionType = ExecutionType.REGRESSION, description = "Check that a comment of a document from a private site is not deleted after user is removed") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void checkTheCommentOfADocumentFromPrivateSiteDoesNotExist() throws Exception + public void checkThatCommentIsNotDeletedWhenPrivateSiteMemberIsRemoved() throws Exception { UserModel newUser = dataUser.createRandomTestUser(); newUser.setUserRole(UserRole.SiteManager); From 7f3a26957add84a438f1944172b793a91921687a Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Mon, 6 Feb 2017 12:55:54 +0200 Subject: [PATCH 1007/1491] TAS-2923 two new full tests for updateTask --- .../tasks/UpdateTaskFullTestsBulk1.java | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk1.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk1.java index 6724b2d97..0022872d0 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk1.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk1.java @@ -517,4 +517,40 @@ public class UpdateTaskFullTestsBulk1 extends RestTest restTaskModel = restClient.authenticateUser(anyUser).withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify user cannot delegate task with emty assignee name and response is 400") + public void updateTaskWithEmptyAssigneeValue() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("state", "delegated") + .add("assignee", "") + .build(); + + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(RestErrorModel.DELEGATING_ASSIGNEE_PROVIDED) + .containsSummary(RestErrorModel.DELEGATING_ASSIGNEE_PROVIDED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify owner can resolve task when assignee is the owner and response is 200") + public void taskOwnerUpdateTaskResolveStateAndOwnerAssignee() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("state", "resolved") + .add("assignee", owner.getUsername()) + .build(); + + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("state").is("resolved") + .and().field("assignee").isNull(); + } } From 91d5332074dd4a195629da5c8f7361e40d78dd61 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Mon, 6 Feb 2017 13:40:14 +0200 Subject: [PATCH 1008/1491] TAS-2924 two full tests added and one test updated for updateTask --- .../tasks/UpdateTaskFullTestsBulk1.java | 31 +++++++++++++++++++ .../workflow/tasks/UpdateTaskSanityTests.java | 14 +++++++-- 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk1.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk1.java index 0022872d0..a00e448dd 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk1.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk1.java @@ -10,6 +10,7 @@ import org.alfresco.rest.model.RestProcessDefinitionModel; import org.alfresco.rest.model.RestTaskModel; import org.alfresco.rest.model.RestVariableModelsCollection; import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.ProcessModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TaskModel; import org.alfresco.utility.model.TestGroup; @@ -553,4 +554,34 @@ public class UpdateTaskFullTestsBulk1 extends RestTest restTaskModel.assertThat().field("state").is("resolved") .and().field("assignee").isNull(); } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify owner cannot update task after it was deleted and response is 404") + public void updateTaskAfterItWasDeleted() throws Exception + { + ProcessModel process = new ProcessModel(); + process.setId(taskModel.getProcessId()); + dataWorkflow.usingUser(owner).deleteProcess(process); + + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.ENTITY_WAS_NOT_FOUND, taskModel.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task owner cannot update task with empty input body and response is 400") + public void taskOwnerCannotUpdateTaskWithEmptyInputBody() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON().build(); + + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(String.format(RestErrorModel.TASK_INVALID_STATE, "null")) + .containsSummary(String.format(RestErrorModel.TASK_INVALID_STATE, "null")); + } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskSanityTests.java index bc5329c55..edb4670ef 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskSanityTests.java @@ -88,7 +88,17 @@ public class UpdateTaskSanityTests extends RestTest restTaskModel = restClient.authenticateUser(userModel1).withWorkflowAPI().usingTask(taskModel).updateTask("completed"); restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("description").is(taskModel.getMessage()); + restTaskModel.assertThat() + .field("dueAt").isNotEmpty() + .and().field("processDefinitionId").is("activitiReviewPooled:1:12") + .and().field("processId").is(taskModel.getProcessId()) + .and().field("name").is("Review Task") + .and().field("description").is(taskModel.getMessage()) + .and().field("startedAt").isNotEmpty() + .and().field("id").is(taskModel.getId()) + .and().field("state").is("unclaimed") + .and().field("activityDefinitionId").is("reviewTask") + .and().field("priority").is(taskModel.getPriority().getLevel()) + .and().field("formResourceKey").is("wf:activitiReviewTask"); } } \ No newline at end of file From c19c22fe39dc5566324a645e72e4963e390592b2 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Mon, 6 Feb 2017 13:51:09 +0200 Subject: [PATCH 1009/1491] TAS-3188 fixed 2 tests --- .../alfresco/rest/workflow/tasks/GetTaskFullTests.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFullTests.java index 7d72d05a3..9bba5e6c9 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFullTests.java @@ -19,6 +19,7 @@ import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; /** @@ -42,7 +43,12 @@ public class GetTaskFullTests extends RestTest userModel = dataUser.createRandomTestUser(); siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - assigneeUser = dataUser.createRandomTestUser(); + assigneeUser = dataUser.createRandomTestUser(); + } + + @BeforeMethod(alwaysRun=true) + public void createTask() throws Exception + { taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); } From 817cd0659b1e0cc34d5c1170008cb6a524f57be9 Mon Sep 17 00:00:00 2001 From: mionescu Date: Mon, 6 Feb 2017 14:31:07 +0200 Subject: [PATCH 1010/1491] updates --- .../processes/AddProcessVariableCoreTests.java | 5 +++-- .../AddProcessVariableSanityTests.java | 18 +++++++++--------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableCoreTests.java index 3df6e4c01..889b850a8 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableCoreTests.java @@ -97,10 +97,11 @@ public class AddProcessVariableCoreTests extends RestTest processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Unsupported type of variable: 'd:textarea'."); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary( + String.format(RestErrorModel.UNSUPPORTED_TYPE, "d:textarea")); } - @Bug(id = "ACE-5674") + @Bug(id = "REPO-1938") @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process variable is falling in case invalid type prefix is provided") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java index aa509009b..0910f99aa 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java @@ -46,8 +46,8 @@ public class AddProcessVariableSanityTests extends RestTest variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - processVariable = restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); + processVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.OK); processVariable.assertThat().field("name").is(variableModel.getName()) .and().field("type").is(variableModel.getType()) .and().field("value").is(variableModel.getValue()); @@ -63,16 +63,16 @@ public class AddProcessVariableSanityTests extends RestTest { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - processVariable = restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); + processVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.OK); processVariable.assertThat().field("name").is(variableModel.getName()) .and().field("type").is(variableModel.getType()) .and().field("value").is(variableModel.getValue()); String newValue = RandomData.getRandomName("value"); variableModel.setValue(newValue); - processVariable = restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); + processVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.OK); processVariable.assertThat().field("value").is(newValue); } @@ -89,8 +89,8 @@ public class AddProcessVariableSanityTests extends RestTest restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee, false, Priority.Normal); variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); processModel = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - processVariable = restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); + processVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.OK); processVariable.assertThat().field("name").is(variableModel.getName()) .and().field("type").is(variableModel.getType()) .and().field("value").is(variableModel.getValue()); @@ -103,7 +103,7 @@ public class AddProcessVariableSanityTests extends RestTest { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("incorrect type"); processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); + restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) .assertLastError().containsSummary("Unsupported type of variable: 'incorrect type'."); } From b07ae0e4da30326ef2aafa415df97471a2d90d89 Mon Sep 17 00:00:00 2001 From: mionescu Date: Mon, 6 Feb 2017 14:43:07 +0200 Subject: [PATCH 1011/1491] added new test cases: TAS-2902 (Sanity, Core, Full) --- .../AddProcessVariablesCoreTests.java | 59 +++-- .../AddProcessVariablesFullTests.java | 249 ++++++++++++++++++ .../AddProcessVariablesSanityTests.java | 111 ++++++++ 3 files changed, 401 insertions(+), 18 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesFullTests.java create mode 100644 e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesCoreTests.java index 324e74351..7d8b0330a 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesCoreTests.java @@ -19,7 +19,7 @@ public class AddProcessVariablesCoreTests extends RestTest { private FileModel document; private SiteModel siteModel; - private UserModel userWhoStartsTask, assignee, adminUser, adminTenantUser, secondAdminTenantUser, tenantUser; + private UserModel userWhoStartsProcess, assignee, adminUser, adminTenantUser, secondAdminTenantUser, tenantUser; private RestProcessModel processModel; private RestProcessVariableModel variableModel, processVariable; @@ -27,17 +27,17 @@ public class AddProcessVariablesCoreTests extends RestTest public void dataPreparation() throws Exception { adminUser = dataUser.getAdminUser(); - userWhoStartsTask = dataUser.createRandomTestUser(); + userWhoStartsProcess = dataUser.createRandomTestUser(); assignee = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); + siteModel = dataSite.usingUser(userWhoStartsProcess).createPublicRandomSite(); document = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); + dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); } @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify addProcessVariable by admin in other network with REST API and status code is FORBIDDEN (403)") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE, TestGroup.NETWORKS }) - public void addProcessVariableByAdminInOtherNetworkIsForbidden() throws Exception + public void addProcessVariablesByAdminInOtherNetworkIsForbidden() throws Exception { adminTenantUser = UserModel.getAdminTenantUser(); secondAdminTenantUser = UserModel.getAdminTenantUser(); @@ -50,7 +50,8 @@ public class AddProcessVariablesCoreTests extends RestTest variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); processModel = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); + restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().usingProcess(processModel) + .addProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) .assertLastError().containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT); } @@ -58,16 +59,17 @@ public class AddProcessVariablesCoreTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify addProcessVariable by any user with REST API and status code is CREATED (201)") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) - public void addProcessVariableByAnyUser() throws Exception + public void addProcessVariablesByAnyUser() throws Exception { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - processVariable = restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); + processVariable = restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(processModel) + .addProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); - processVariable.assertThat().field("name").is(variableModel.getName()) - .and().field("type").is(variableModel.getType()) - .and().field("value").is(variableModel.getValue()); + processVariable.assertThat().field("name").is(processVariable.getName()) + .and().field("type").is(processVariable.getType()) + .and().field("value").is(processVariable.getValue()); restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() .assertThat().entriesListContains("name", processVariable.getName()); @@ -76,13 +78,14 @@ public class AddProcessVariablesCoreTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify addProcessVariable by any user for invalid processID with REST API and status code is NOT_FOUND (404)") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) - public void addProcessVariableForInvalidProcessIdIsNotFound() throws Exception + public void addProcessVariablesForInvalidProcessIdIsNotFound() throws Exception { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); processModel.setId("invalidProcessID"); - processVariable = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); + processVariable = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingProcess(processModel) + .addProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidProcessID")); } @@ -90,14 +93,34 @@ public class AddProcessVariablesCoreTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify addProcessVariable by any user for empty processID with REST API and status code is NOT_FOUND (404)") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) - public void addProcessVariableForInvalidProcessIdIsEmpty() throws Exception + public void addProcessVariablesForInvalidProcessIdIsEmpty() throws Exception { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); processModel.setId(""); - processVariable = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); + processVariable = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Add process variables using by the user who started the process.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + public void addProcessVariablesByUserThatStartedTheProcess() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + + processVariable = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingProcess(processModel) + .addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + processVariable.assertThat().field("name").is(processVariable.getName()) + .and().field("type").is(processVariable.getType()) + .and().field("value").is(processVariable.getValue()); + + restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() + .assertThat().entriesListContains("name", processVariable.getName()); + } + } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesFullTests.java new file mode 100644 index 000000000..e4cb13768 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesFullTests.java @@ -0,0 +1,249 @@ +package org.alfresco.rest.workflow.processes; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.dataprep.CMISUtil.Priority; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestProcessVariableModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class AddProcessVariablesFullTests extends RestTest +{ + private FileModel document; + private SiteModel siteModel; + private UserModel userWhoStartsProcess, assignee, adminUser, adminTenantUser, adminTenantUser2, tenantUser, tenantUserAssignee; + private RestProcessModel processModel; + private RestProcessVariableModel variableModel, processVariable; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userWhoStartsProcess = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userWhoStartsProcess).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Add process variables using by the user involved in the process.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void addProcessVariablesByUserInvolvedTheProcess() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(assignee).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + + processVariable = restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(processModel) + .addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + processVariable.assertThat().field("name").is(processVariable.getName()) + .and().field("type").is(processVariable.getType()) + .and().field("value").is(processVariable.getValue()); + + restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() + .assertThat().entriesListContains("name", processVariable.getName()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Add process variables using by inexistent user.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void addProcessVariablesByInexistentUser() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + + processVariable = restClient.authenticateUser(UserModel.getRandomUserModel()).withWorkflowAPI().usingProcess(processModel) + .addProcessVariable(variableModel); + + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding process variables is falling in case invalid type is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void failedAddingProcessVariablesIfInvalidTypeIsProvided() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:textarea"); + + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary( + String.format(RestErrorModel.UNSUPPORTED_TYPE, "d:textarea")) + .containsErrorKey(String.format(RestErrorModel.UNSUPPORTED_TYPE, "d:textarea")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Bug(id = "REPO-1938") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding process variables is falling in case invalid type prefix is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void failedAddingProcessVariablesIfInvalidTypePrefixIsProvided() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("ddt:text"); + + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsSummary(String.format(RestErrorModel.INVALID_NAMEPACE_PREFIX, "ddt")) + .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding process variables is falling in case invalid value is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void failedAddingProcessVariablesIfInvalidValueIsProvided() throws Exception + { + RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:int"); + variableModel.setValue("invalidValue"); + + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .containsSummary(String.format(RestErrorModel.FOR_INPUT_STRING, "invalidValue")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding process variables is falling in case invalid variableBody (adding extra parameter in body:scope) is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void failedAddingProcessVariablesIfInvalidBodyIsProvided() throws Exception + { + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{\"name\": \"variableName\",\"scope\": \"local\",\"value\": \"testing\",\"type\": \"d:text\"}", + "processes/{processId}/variables", processModel.getId()); + restClient.processModel(RestProcessVariableModel.class, request); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsSummary(String.format(RestErrorModel.NO_CONTENT, "Unrecognized field \"scope\"")) + .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "Unrecognized field \"scope\"")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Bug(id="REPO-1985") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding process variables is falling in case empty name is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void failedAddingProcessVariablesIfEmptyNameIsProvided() throws Exception + { + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); + RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + variableModel.setName(""); + + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsSummary(RestErrorModel.VARIABLE_NAME_REQUIRED) + .containsErrorKey(RestErrorModel.VARIABLE_NAME_REQUIRED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Bug(id="REPO-1985") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding process variables is falling in case invalid name is provided: ony white spaces") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void failedAddingProcessVariablesUsingOnlyWhiteSpaceInName() throws Exception + { + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); + RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + variableModel.setName(" "); + + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processVariable = restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); + + restClient.assertStatusCodeIs(HttpStatus.CREATED); + processVariable.assertThat().field("name").isNull() + .and().field("type").is(processVariable.getType()) + .and().field("value").is(processVariable.getValue()); + + restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() + .assertThat().entriesListContains("value", processVariable.getValue()); + } + + @Bug(id="REPO-1987") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding process variables is falling in case invalid name is provided: symbols") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void addingProcessVariablesUsingSymbolsInName() throws Exception + { + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + variableModel.setName("123_%^&: õÈ,Ì,Ò"); + + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processVariable = restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); + + restClient.assertStatusCodeIs(HttpStatus.CREATED); + processVariable.assertThat().field("name").is(processVariable.getName()) + .and().field("type").is(processVariable.getType()) + .and().field("value").is(processVariable.getValue()); + + restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() + .assertThat().entriesListContains("name", processVariable.getName()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Add process variables using by Admin in other network.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL, TestGroup.NETWORKS }) + public void addProcessVariablesByAdminInOtherNetwork() throws Exception + { + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser); + tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); + tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + + adminTenantUser2 = UserModel.getAdminTenantUser(); + restClient.usingTenant().createTenant(adminTenantUser2); + + siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); + dataWorkflow.usingUser(tenantUser).usingSite(siteModel).usingResource(document) + .createNewTaskAndAssignTo(tenantUserAssignee); + + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processVariable = restClient.authenticateUser(adminTenantUser2).withWorkflowAPI().usingProcess(processModel) + .addProcessVariable(variableModel); + + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError() + .containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .containsErrorKey(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + +} diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesSanityTests.java new file mode 100644 index 000000000..9a8e99e57 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesSanityTests.java @@ -0,0 +1,111 @@ +package org.alfresco.rest.workflow.processes; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.dataprep.CMISUtil.Priority; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestProcessVariableModel; +import org.alfresco.utility.data.RandomData; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class AddProcessVariablesSanityTests extends RestTest +{ + private FileModel document; + private SiteModel siteModel; + private UserModel userWhoStartsProcess, assignee, adminUser, adminTenantUser, tenantUserAssignee, tenantUser; + private RestProcessModel processModel; + private RestProcessVariableModel variableModel, processVariable; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userWhoStartsProcess = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userWhoStartsProcess).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Create non-existing variable") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) + public void addProcessVariables() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + + processVariable = restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + processVariable.assertThat().field("name").is(processVariable.getName()) + .and().field("type").is(processVariable.getType()) + .and().field("value").is(processVariable.getValue()); + + restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() + .assertThat().entriesListContains("name", processVariable.getName()); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Update existing variables") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) + public void updateExistingProcessVariables() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + + processVariable = restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + processVariable.assertThat().field("name").is(processVariable.getName()) + .and().field("type").is(processVariable.getType()) + .and().field("value").is(processVariable.getValue()); + + String newValue = RandomData.getRandomName("value"); + variableModel.setValue(newValue); + processVariable = restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + processVariable.assertThat().field("value").is(newValue); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Adding process variables is falling in case invalid variableBody is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) + public void failedAddingProcessVariablesIfInvalidBodyIsProvided() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("incorrect type"); + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + + restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary("Unsupported type of variable: 'incorrect type'."); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Add process variables using admin user from same network") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY, TestGroup.NETWORKS }) + public void addProcessVariablesByAdminSameNetwork() throws Exception + { + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser); + tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); + + restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee, false, Priority.Normal); + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + + processVariable = restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + processVariable.assertThat().field("name").is(processVariable.getName()) + .and().field("type").is(processVariable.getType()) + .and().field("value").is(processVariable.getValue()); + } + +} From bf4b907b2b35a455d310f12470b8ab4afdfdf174 Mon Sep 17 00:00:00 2001 From: Andrei Rusu Date: Mon, 6 Feb 2017 14:49:03 +0200 Subject: [PATCH 1012/1491] added tests for GetTasksFullTests --- .../workflow/tasks/GetTasksFullTests.java | 148 ++++++++++++++++++ 1 file changed, 148 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksFullTests.java new file mode 100644 index 000000000..c51564b97 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksFullTests.java @@ -0,0 +1,148 @@ +package org.alfresco.rest.workflow.tasks; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.dataprep.CMISUtil.Priority; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestTaskModel; +import org.alfresco.rest.model.RestTaskModelsCollection; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class GetTasksFullTests extends RestTest +{ + UserModel userModel, adminUser; + SiteModel siteModel; + UserModel candidateUser; + FileModel fileModel; + UserModel assigneeUser; + RestTaskModelsCollection taskModels; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + adminUser = dataUser.getAdminUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + assigneeUser = dataUser.createRandomTestUser(); + dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check that skipCount parameter is applied.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + public void skipCountParameterApplied() throws Exception + { + RestTaskModelsCollection taskCollections = restClient.authenticateUser(dataUser.getAdminUser()).withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + RestTaskModel firstTask = taskCollections.getEntries().get(0).onModel(); + RestTaskModel secondTask = taskCollections.getEntries().get(1).onModel(); + + taskModels = restClient.withParams("skipCount=2").withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + taskModels.assertThat().entriesListIsNotEmpty() + .assertThat().entriesListDoesNotContain("id", firstTask.getId()) + .assertThat().entriesListDoesNotContain("id", secondTask.getId()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check that maxItems parameter is applied.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + public void maxItemsParameterApplied() throws Exception + { + RestTaskModelsCollection taskCollections = restClient.authenticateUser(dataUser.getAdminUser()).withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + RestTaskModel firstTask = taskCollections.getEntries().get(0).onModel(); + RestTaskModel secondTask = taskCollections.getEntries().get(1).onModel(); + + taskModels = restClient.withParams("maxItems=2").withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + taskModels.assertThat().entriesListIsNotEmpty() + .assertThat().entriesListContains("id", firstTask.getId()) + .assertThat().entriesListContains("id", secondTask.getId()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check that properties parameter is applied.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + public void propertiesParameterApplied() throws Exception + { + taskModels = restClient.authenticateUser(dataUser.getAdminUser()).withParams("properties=name,description").withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + taskModels.assertThat().entriesListIsNotEmpty() + .assertThat().entriesListContains("name") + .assertThat().entriesListContains("description") + .assertThat().entriesListDoesNotContain("processDefinitionId") + .assertThat().entriesListDoesNotContain("processId") + .assertThat().entriesListDoesNotContain("startedAt") + .assertThat().entriesListDoesNotContain("id") + .assertThat().entriesListDoesNotContain("state") + .assertThat().entriesListDoesNotContain("activityDefinitionId") + .assertThat().entriesListDoesNotContain("priority") + .assertThat().entriesListDoesNotContain("formResourceKey"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Use invalid where parameter. Check default error model schema.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + public void invalidWhereParameterCheckDefaultErrorModelSchema() throws Exception + { + restClient.authenticateUser(dataUser.getAdminUser()).where("assignee AND '" + assigneeUser.getUsername() + "'").withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(RestErrorModel.INVALID_QUERY_ERRORKEY) + .containsSummary(String.format(RestErrorModel.INVALID_WHERE_QUERY, "(assignee AND '" + assigneeUser.getUsername() + "')")) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, + executionType = ExecutionType.REGRESSION, description = "Check that for admin network gets tasks only from its network.") + public void adminTenantGetsTasksOnlyFromItsNetwork() throws Exception + { + UserModel adminTenant1 = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenant1); + + UserModel adminTenant2 = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenant2); + + UserModel tenantUser1 = dataUser.usingUser(adminTenant1).createUserWithTenant("userTenant1"); + UserModel tenantUserAssignee1 = dataUser.usingUser(adminTenant1).createUserWithTenant("userTenantAssignee1"); + + UserModel tenantUser2 = dataUser.usingUser(adminTenant2).createUserWithTenant("userTenant2"); + UserModel tenantUserAssignee2 = dataUser.usingUser(adminTenant2).createUserWithTenant("userTenantAssignee2"); + + RestProcessModel processOnTenant1 = restClient.authenticateUser(tenantUser1).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee1, false, Priority.Low); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestProcessModel processOnTenant2 = restClient.authenticateUser(tenantUser2).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee2, false, Priority.Normal); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestTaskModelsCollection tenantTasks1 = restClient.authenticateUser(adminTenant1).withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + tenantTasks1.assertThat().entriesListIsNotEmpty() + .and().entriesListCountIs(1) + .and().entriesListContains("assignee", String.format("userTenantAssignee1@%s", tenantUserAssignee1.getDomain().toLowerCase())) + .and().entriesListContains("processId", processOnTenant1.getId()) + .and().entriesListDoesNotContain("assignee", String.format("userTenantAssignee2@%s", tenantUserAssignee2.getDomain().toLowerCase())) + .and().entriesListDoesNotContain("processId", processOnTenant2.getId()); + + RestTaskModelsCollection tenantTasks2 = restClient.authenticateUser(adminTenant2).withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + tenantTasks2.assertThat().entriesListIsNotEmpty() + .and().entriesListCountIs(1) + .and().entriesListContains("assignee", String.format("userTenantAssignee2@%s", tenantUserAssignee2.getDomain().toLowerCase())) + .and().entriesListContains("processId", processOnTenant2.getId()) + .and().entriesListDoesNotContain("assignee", String.format("userTenantAssignee1@%s", tenantUserAssignee1.getDomain().toLowerCase())) + .and().entriesListDoesNotContain("processId", processOnTenant1.getId()); + } +} From 81c896c9fc052c93c479484f90c408d22e74b3bf Mon Sep 17 00:00:00 2001 From: mionescu Date: Mon, 6 Feb 2017 14:56:55 +0200 Subject: [PATCH 1013/1491] updates --- .../alfresco/rest/FunctionalCasesTests.java | 293 +++++++++++++++--- .../alfresco/rest/tags/GetTagFullTests.java | 92 ++++++ .../rest/tags/UpdateTagFullTests.java | 144 +++++++++ .../rest/tags/UpdateTagSanityTests.java | 9 +- .../processes/DeleteProcessItemFullTests.java | 267 ++++++++++++++++ .../rest/workflow/tasks/GetTaskFullTests.java | 8 +- .../tasks/UpdateTaskFullTestsBulk1.java | 67 ++++ .../tasks/UpdateTaskFullTestsBulk2.java | 6 +- .../workflow/tasks/UpdateTaskSanityTests.java | 14 +- 9 files changed, 849 insertions(+), 51 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/tags/GetTagFullTests.java create mode 100644 e2e-test/java/org/alfresco/rest/tags/UpdateTagFullTests.java create mode 100644 e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessItemFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java b/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java index e128a7817..7204afd91 100644 --- a/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java +++ b/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java @@ -1,11 +1,8 @@ package org.alfresco.rest; +import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.model.RestActivityModelsCollection; -import org.alfresco.rest.model.RestFavoriteSiteModel; -import org.alfresco.rest.model.RestSiteMemberModel; -import org.alfresco.rest.model.RestSiteMembershipRequestModelsCollection; -import org.alfresco.rest.model.RestTaskModel; +import org.alfresco.rest.model.*; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; @@ -19,22 +16,23 @@ import org.testng.annotations.Test; public class FunctionalCasesTests extends RestTest { - private UserModel adminUserModel; - private SiteModel siteModel, moderatedSite; + private UserModel adminUser, manager; + private SiteModel publicSite, moderatedSite, privateSite; private RestSiteMemberModel updatedMember; private RestSiteMembershipRequestModelsCollection returnedCollection; private RestFavoriteSiteModel restFavoriteSiteModel; private RestActivityModelsCollection activities; - private UserModel user; + private FileModel file; @BeforeClass(alwaysRun=true) public void dataPreparation() throws Exception { - adminUserModel = dataUser.getAdminUser(); - user = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - dataUser.addUserToSite(user, siteModel, UserRole.SiteManager); - moderatedSite = dataSite.usingUser(adminUserModel).createModeratedRandomSite(); + adminUser = dataUser.getAdminUser(); + manager = dataUser.createRandomTestUser(); + publicSite = dataSite.usingUser(adminUser).createPublicRandomSite(); + dataUser.addUserToSite(manager, publicSite, UserRole.SiteManager); + moderatedSite = dataSite.usingUser(adminUser).createModeratedRandomSite(); + privateSite = dataSite.usingUser(adminUser).createPrivateRandomSite(); } /** @@ -51,26 +49,26 @@ public class FunctionalCasesTests extends RestTest { UserModel testUser = dataUser.createRandomTestUser("testUser"); testUser.setUserRole(UserRole.SiteManager); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(siteModel).addPerson(testUser) + restClient.authenticateUser(adminUser).withCoreAPI().usingSite(publicSite).addPerson(testUser) .assertThat().field("id").is(testUser.getUsername()) .and().field("role").is(testUser.getUserRole()); restClient.assertStatusCodeIs(HttpStatus.CREATED); testUser.setUserRole(UserRole.SiteCollaborator); - updatedMember = restClient.authenticateUser(adminUserModel).withCoreAPI() - .usingSite(siteModel).updateSiteMember(testUser); + updatedMember = restClient.withCoreAPI() + .usingSite(publicSite).updateSiteMember(testUser); restClient.assertStatusCodeIs(HttpStatus.OK); updatedMember.assertThat().field("id").is(testUser.getUsername()).and().field("role").is(testUser.getUserRole()); testUser.setUserRole(UserRole.SiteContributor); - updatedMember = restClient.authenticateUser(adminUserModel).withCoreAPI() - .usingSite(siteModel).updateSiteMember(testUser); + updatedMember = restClient.withCoreAPI() + .usingSite(publicSite).updateSiteMember(testUser); restClient.assertStatusCodeIs(HttpStatus.OK); updatedMember.assertThat().field("id").is(testUser.getUsername()).and().field("role").is(testUser.getUserRole()); testUser.setUserRole(UserRole.SiteConsumer); - updatedMember = restClient.authenticateUser(adminUserModel).withCoreAPI() - .usingSite(siteModel).updateSiteMember(testUser); + updatedMember = restClient.withCoreAPI() + .usingSite(publicSite).updateSiteMember(testUser); restClient.assertStatusCodeIs(HttpStatus.OK); updatedMember.assertThat().field("id").is(testUser.getUsername()).and().field("role").is(testUser.getUserRole()); } @@ -89,26 +87,26 @@ public class FunctionalCasesTests extends RestTest { UserModel testUser = dataUser.createRandomTestUser("testUser"); testUser.setUserRole(UserRole.SiteConsumer); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(siteModel).addPerson(testUser) + restClient.authenticateUser(adminUser).withCoreAPI().usingSite(publicSite).addPerson(testUser) .assertThat().field("id").is(testUser.getUsername()) .and().field("role").is(testUser.getUserRole()); restClient.assertStatusCodeIs(HttpStatus.CREATED); testUser.setUserRole(UserRole.SiteContributor); - updatedMember = restClient.authenticateUser(adminUserModel).withCoreAPI() - .usingSite(siteModel).updateSiteMember(testUser); + updatedMember = restClient.withCoreAPI() + .usingSite(publicSite).updateSiteMember(testUser); restClient.assertStatusCodeIs(HttpStatus.OK); updatedMember.assertThat().field("id").is(testUser.getUsername()).and().field("role").is(testUser.getUserRole()); testUser.setUserRole(UserRole.SiteCollaborator); - updatedMember = restClient.authenticateUser(adminUserModel).withCoreAPI() - .usingSite(siteModel).updateSiteMember(testUser); + updatedMember = restClient.withCoreAPI() + .usingSite(publicSite).updateSiteMember(testUser); restClient.assertStatusCodeIs(HttpStatus.OK); updatedMember.assertThat().field("id").is(testUser.getUsername()).and().field("role").is(testUser.getUserRole()); testUser.setUserRole(UserRole.SiteManager); - updatedMember = restClient.authenticateUser(adminUserModel).withCoreAPI() - .usingSite(siteModel).updateSiteMember(testUser); + updatedMember = restClient.withCoreAPI() + .usingSite(publicSite).updateSiteMember(testUser); restClient.assertStatusCodeIs(HttpStatus.OK); updatedMember.assertThat().field("id").is(testUser.getUsername()).and().field("role").is(testUser.getUserRole()); } @@ -131,7 +129,7 @@ public class FunctionalCasesTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.CREATED); RestTaskModel taskModel = restClient.authenticateUser(newMember).withWorkflowAPI().getTasks().getTaskModelByDescription(moderatedSite); - workflow.approveSiteMembershipRequest(adminUserModel.getUsername(), adminUserModel.getPassword(), taskModel.getId(), true, "Approve"); + workflow.approveSiteMembershipRequest(adminUser.getUsername(), adminUser.getPassword(), taskModel.getId(), true, "Approve"); returnedCollection = restClient.authenticateUser(newMember).withCoreAPI().usingMe().getSiteMembershipRequests(); restClient.assertStatusCodeIs(HttpStatus.OK); returnedCollection.assertThat().entriesListDoesNotContain("id", moderatedSite.getId()); @@ -164,7 +162,7 @@ public class FunctionalCasesTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.CREATED); RestTaskModel taskModel = restClient.authenticateUser(newMember).withWorkflowAPI().getTasks().getTaskModelByDescription(moderatedSite); - workflow.approveSiteMembershipRequest(adminUserModel.getUsername(), adminUserModel.getPassword(), taskModel.getId(), false, "Rejected"); + workflow.approveSiteMembershipRequest(adminUser.getUsername(), adminUser.getPassword(), taskModel.getId(), false, "Rejected"); returnedCollection = restClient.authenticateUser(newMember).withCoreAPI().usingMe().getSiteMembershipRequests(); restClient.assertStatusCodeIs(HttpStatus.OK); returnedCollection.assertThat().entriesListDoesNotContain("id", moderatedSite.getId()); @@ -177,9 +175,9 @@ public class FunctionalCasesTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.CREATED); taskModel = restClient.authenticateUser(newMember).withWorkflowAPI().getTasks().getTaskModelByDescription(moderatedSite); - workflow.approveSiteMembershipRequest(adminUserModel.getUsername(), adminUserModel.getPassword(), taskModel.getId(), true, "Accept"); + workflow.approveSiteMembershipRequest(adminUser.getUsername(), adminUser.getPassword(), taskModel.getId(), true, "Accept"); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(newMember).deleteSiteMember(moderatedSite); + restClient.authenticateUser(adminUser).withCoreAPI().usingUser(newMember).deleteSiteMember(moderatedSite); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); restClient.withCoreAPI().usingSite(moderatedSite).getSiteMembers().assertThat().entriesListDoesNotContain("id", newMember.getUsername()); @@ -195,10 +193,10 @@ public class FunctionalCasesTests extends RestTest description = "Add a file and check that activity is included in person activities") public void addFileThenGetPersonActivities() throws Exception { - FileModel file = dataContent.usingUser(user).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - activities = restClient.authenticateUser(user).withCoreAPI().usingAuthUser().getPersonActivitiesUntilEntriesCountIs(2); + file = dataContent.usingUser(manager).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); + activities = restClient.authenticateUser(manager).withCoreAPI().usingAuthUser().getPersonActivitiesUntilEntriesCountIs(2); activities.assertThat().entriesListIsNotEmpty() - .and().entriesListContains("siteId", siteModel.getId()) + .and().entriesListContains("siteId", publicSite.getId()) .and().entriesListContains("activityType", "org.alfresco.documentlibrary.file-added") .and().entriesListContains("activitySummary.objectId", file.getNodeRefWithoutVersion()); } @@ -213,11 +211,11 @@ public class FunctionalCasesTests extends RestTest description = "Add a comment to a file and check that activity is included in person activities") public void addCommentThenGetPersonActivities() throws Exception { - FileModel file = dataContent.usingUser(user).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(user).withCoreAPI().usingResource(file).addComment("new comment"); - activities = restClient.authenticateUser(user).withCoreAPI().usingAuthUser().getPersonActivitiesUntilEntriesCountIs(3); + file = dataContent.usingUser(manager).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(manager).withCoreAPI().usingResource(file).addComment("new comment"); + activities = restClient.authenticateUser(manager).withCoreAPI().usingAuthUser().getPersonActivitiesUntilEntriesCountIs(3); activities.assertThat().entriesListIsNotEmpty() - .and().entriesListContains("siteId", siteModel.getId()) + .and().entriesListContains("siteId", publicSite.getId()) .and().entriesListContains("activityType", "org.alfresco.comments.comment-created") .and().entriesListContains("activitySummary.objectId", file.getNodeRefWithoutVersion()); } @@ -232,12 +230,223 @@ public class FunctionalCasesTests extends RestTest description = "Add a file, delete it and check that activity is included in person activities") public void addFileDeleteItThenGetPersonActivities() throws Exception { - FileModel file = dataContent.usingUser(user).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - dataContent.usingUser(user).usingResource(file).deleteContent(); - activities = restClient.authenticateUser(user).withCoreAPI().usingAuthUser().getPersonActivitiesUntilEntriesCountIs(2); + file = dataContent.usingUser(manager).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); + dataContent.usingUser(manager).usingResource(file).deleteContent(); + activities = restClient.authenticateUser(manager).withCoreAPI().usingAuthUser().getPersonActivitiesUntilEntriesCountIs(2); activities.assertThat().entriesListIsNotEmpty() - .and().entriesListContains("siteId", siteModel.getId()) + .and().entriesListContains("siteId", publicSite.getId()) .and().entriesListContains("activityType", "org.alfresco.documentlibrary.file-deleted") .and().entriesListContains("activitySummary.objectId", file.getNodeRefWithoutVersion()); } + + /** + * 1. Post one comment + * 2. Get comment details + * 3. Update comment + * 4. Get again comment details + * 5. Delete comment + */ + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, + executionType = ExecutionType.REGRESSION, + description = "Add comment to a file, then get comment details. Update it and check that get comment returns updated details. Delete comment then check that file has no comments.") + public void addUpdateDeleteCommentThenGetCommentDetails() throws Exception + { + file = dataContent.usingUser(manager).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); + RestCommentModel newComment = restClient.authenticateUser(manager).withCoreAPI().usingResource(file).addComment("new comment"); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestCommentModelsCollection fileComments = restClient.withCoreAPI().usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + fileComments.assertThat().entriesListContains("content", newComment.getContent()); + + RestCommentModel updatedComment = restClient.withCoreAPI().usingResource(file).updateComment(newComment, "updated comment"); + restClient.assertStatusCodeIs(HttpStatus.OK); + + fileComments = restClient.withCoreAPI().usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + fileComments.assertThat().entriesListContains("content", updatedComment.getContent()).assertThat().entriesListDoesNotContain("content", newComment.getContent()); + + restClient.withCoreAPI().usingResource(file).deleteComment(updatedComment); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + fileComments = restClient.withCoreAPI().usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + fileComments.assertThat().entriesListIsEmpty(); + } + + /** + * 1. Post one comment + * 2. Delete comment + * 3. Post the same comment again + */ + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, + executionType = ExecutionType.REGRESSION, + description = "Add a comment to a file, delete it, then added the same comment again.") + public void checkThatADeletedCommentCanBePostedAgain() throws Exception + { + file = dataContent.usingUser(manager).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); + RestCommentModel newComment = restClient.authenticateUser(manager).withCoreAPI().usingResource(file).addComment("new comment"); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestCommentModelsCollection fileComments = restClient.withCoreAPI().usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + fileComments.assertThat().entriesListContains("content", newComment.getContent()); + + restClient.withCoreAPI().usingResource(file).deleteComment(newComment); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + fileComments = restClient.withCoreAPI().usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + fileComments.assertThat().entriesListIsEmpty(); + + restClient.authenticateUser(manager).withCoreAPI().usingResource(file).addComment("new comment"); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + fileComments = restClient.withCoreAPI().usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + fileComments.assertThat().entriesListContains("content", newComment.getContent()); + } + + /** + * Scenario: + * 1. join an user to a site + * 2. Check action is included in person activities list + * + * @throws Exception + */ + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Create an user, join the user to a site and check that activity is included in person activities") + public void joinUserToSiteThenGetPersonActivities() throws Exception + { + UserModel userJoinSite = dataUser.createRandomTestUser(); + + restClient.authenticateUser(userJoinSite).withCoreAPI().usingMe().addSiteMembershipRequest(publicSite); + activities = restClient.withCoreAPI().usingAuthUser().getPersonActivitiesUntilEntriesCountIs(2); + activities.assertThat().entriesListIsNotEmpty().and() + .entriesListContains("siteId", publicSite.getId()).and() + .entriesListContains("activityType", "org.alfresco.site.user-joined").and() + .entriesListContains("activitySummary.memberPersonId", userJoinSite.getUsername()); + } + + /** + * Scenario: + * 1. Add user to private site + * 2. Remove user from private site + * 3. User creates membership request to the same private site + */ + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, description = "Verify membership request by user after it was removed from site gets status code 404") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + public void userCanNotCreateMembershipRequestIfItWasRemovedFromPrivateSite() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + newMember.setUserRole(UserRole.SiteCollaborator); + + restClient.authenticateUser(adminUser).withCoreAPI().usingSite(privateSite).addPerson(newMember) + .assertThat().field("id").is(newMember.getUsername()); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(adminUser).withCoreAPI().usingUser(newMember).deleteSiteMember(privateSite); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest(privateSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, newMember.getUsername(), privateSite.getTitle())); + } + + /** + * Scenario: + * 1. User creates membership request to moderated site + * 2. Accept membership request + * 3. Remove user from moderated site + * 4. Add user on moderated site + */ + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, description = "Verify user can be added back after if was removed from site") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + public void userCanBeAddedAfterItWasRemovedFromSite() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + newMember.setUserRole(UserRole.SiteCollaborator); + + restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestTaskModel taskModel = restClient.authenticateUser(newMember).withWorkflowAPI().getTasks().getTaskModelByDescription(moderatedSite); + workflow.approveSiteMembershipRequest(adminUser.getUsername(), adminUser.getPassword(), taskModel.getId(), true, "Accept"); + + restClient.authenticateUser(adminUser).withCoreAPI().usingUser(newMember).deleteSiteMember(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withCoreAPI().usingSite(moderatedSite).getSiteMembers().assertThat().entriesListDoesNotContain("id", newMember.getUsername()); + + restClient.authenticateUser(adminUser).withCoreAPI().usingSite(moderatedSite).addPerson(newMember) + .assertThat().field("id").is(newMember.getUsername()); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.withCoreAPI().usingSite(moderatedSite).getSiteMembers().assertThat().entriesListContains("id", newMember.getUsername()); + } + + /** + * Scenario: + * 1. Create document in site + * 2. Add comment + * 3. Delete document + * 4. Get comments and check if the above comment was deleted + */ + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, + executionType = ExecutionType.REGRESSION, description = "Check that a comment of a document was also removed after deleting the document") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void checkTheCommentOfADocumentThatWasDeletedDoesNotExist() throws Exception + { + FileModel document = dataContent.usingSite(publicSite).usingUser(adminUser).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + String newContent = "This is a new comment added by " + adminUser.getUsername(); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addComment(newContent) + .assertThat().field("content").isNotEmpty() + .and().field("content").is(newContent); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + dataContent.usingUser(adminUser).usingResource(document).deleteContent(); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary((String.format(RestErrorModel.ENTITY_WAS_NOT_FOUND, document.getNodeRefWithoutVersion()))); + } + + /** + * Scenario: + * 1. Add user to private site + * 2. Add comment to a document of private site + * 3. Remove user from site + * 4. Get comments and check if the above comment was deleted + */ + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, + executionType = ExecutionType.REGRESSION, description = "Check that a comment of a document from a private site is not deleted after user is removed") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void checkThatCommentIsNotDeletedWhenPrivateSiteMemberIsRemoved() throws Exception + { + UserModel newUser = dataUser.createRandomTestUser(); + newUser.setUserRole(UserRole.SiteManager); + restClient.authenticateUser(adminUser).withCoreAPI().usingSite(privateSite).addPerson(newUser); + + FileModel document = dataContent.usingSite(privateSite).usingUser(adminUser).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + String newContent = "This is a new comment added by " + newUser.getUsername(); + + restClient.authenticateUser(newUser).withCoreAPI().usingResource(document).addComment(newContent) + .assertThat().field("content").isNotEmpty() + .and().field("content").is(newContent); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(adminUser).withCoreAPI().usingSite(privateSite).deleteSiteMember(newUser); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withCoreAPI().usingSite(privateSite).getSiteMembers().assertThat().entriesListDoesNotContain("id", newUser.getUsername()); + + RestCommentModelsCollection comments = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", newContent) + .and().entriesListContains("createdBy.id", newUser.getUsername()); + } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/tags/GetTagFullTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagFullTests.java new file mode 100644 index 000000000..f16116f0d --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/tags/GetTagFullTests.java @@ -0,0 +1,92 @@ +package org.alfresco.rest.tags; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestTagModel; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.RandomData; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class GetTagFullTests extends RestTest +{ + private UserModel adminUserModel; + private SiteModel siteModel; + private ListUserWithRoles usersWithRoles; + private FileModel document; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + restClient.authenticateUser(adminUserModel); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, + executionType = ExecutionType.REGRESSION, description = "Check that properties filter is applied when getting tag using Manager user.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) + public void checkPropertiesFilterIsApplied() throws JsonToModelConversionException, Exception + { + String tagValue = RandomData.getRandomName("tag"); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(tagValue); + + RestTagModel returnedTag = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withParams("properties=id,tag").withCoreAPI().getTag(tag); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedTag.assertThat().field("id").is(tag.getId()) + .assertThat().field("tag").is(tag.getTag().toLowerCase()) + .assertThat().fieldsCount().is(2); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, + executionType = ExecutionType.REGRESSION, description = "Check that Manager user can get tag of a folder.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) + public void getTagOfAFolder() throws JsonToModelConversionException, Exception + { + String tagValue = RandomData.getRandomName("tagFolder"); + FolderModel folder = dataContent.usingAdmin().usingSite(siteModel).createFolder(); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + RestTagModel tag = restClient.withCoreAPI().usingResource(folder).addTag(tagValue); + + RestTagModel returnedTag = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().getTag(tag); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedTag.assertThat().field("tag").is(tagValue.toLowerCase()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, + executionType = ExecutionType.REGRESSION, description = "Check default error model schema. Use invalid skipCount parameter.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) + public void checkDefaultErrorModelSchema() throws JsonToModelConversionException, Exception + { + String tagValue = RandomData.getRandomName("tag"); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(tagValue); + + restClient.withParams("skipCount=abc").withCoreAPI().getTag(tag); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(String.format(RestErrorModel.INVALID_SKIPCOUNT, "abc")) + .containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "abc")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } +} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/tags/UpdateTagFullTests.java b/e2e-test/java/org/alfresco/rest/tags/UpdateTagFullTests.java new file mode 100644 index 000000000..d8dcb0066 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/tags/UpdateTagFullTests.java @@ -0,0 +1,144 @@ +package org.alfresco.rest.tags; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestTagModel; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.data.RandomData; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.apache.commons.lang.RandomStringUtils; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +public class UpdateTagFullTests extends RestTest +{ + private UserModel adminUserModel; + private FileModel document; + private SiteModel siteModel; + private RestTagModel oldTag; + private DataUser.ListUserWithRoles usersWithRoles; + private RestTagModel returnedModel; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + } + + @BeforeMethod(alwaysRun=true) + public void addTagToDocument() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + oldTag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("old")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify Manager user can provide large string for new tag value.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) + @Bug(id="REPO-1828") + public void managerIsAbleToUpdateTagsProvideLargeStringTag() throws JsonToModelConversionException, Exception + { + String largeStringTag = RandomStringUtils.randomAlphanumeric(10000); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + returnedModel = restClient.withCoreAPI().usingTag(oldTag).update(largeStringTag); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedModel.assertThat().field("tag").is(largeStringTag); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify Manager user can provide short string for new tag value.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) + @Bug(id="REPO-1828") + public void managerIsAbleToUpdateTagsProvideShortStringTag() throws JsonToModelConversionException, Exception + { + String shortStringTag = RandomStringUtils.randomAlphanumeric(2); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + returnedModel = restClient.withCoreAPI().usingTag(oldTag).update(shortStringTag); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedModel.assertThat().field("tag").is(shortStringTag); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify Manager user can provide string with special chars for new tag value.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) + @Bug(id="REPO-1828") + public void managerIsAbleToUpdateTagsProvideSpecialCharsStringTag() throws JsonToModelConversionException, Exception + { + String specialCharsString = "!@#$%^&*()'\".,<>-_+=|\\"; + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + returnedModel = restClient.withCoreAPI().usingTag(oldTag).update(specialCharsString); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedModel.assertThat().field("tag").is(specialCharsString); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify Admin user can provide existing tag for new tag value.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) + @Bug(id="REPO-1828") + public void adminIsAbleToUpdateTagsProvideExistingTag() throws JsonToModelConversionException, Exception + { + String existingTag = "oldTag"; + RestTagModel oldExistingTag = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(document).addTag(existingTag); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(adminUserModel); + returnedModel = restClient.withCoreAPI().usingTag(oldExistingTag).update(existingTag); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedModel.assertThat().field("tag").is(existingTag); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify Admin user can delete a tag, add tag and update it.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) + @Bug(id="REPO-1828") + public void withAdminDeleteTagAddTagUpdateTag() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingResource(document).deleteTag(oldTag); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + String newTag = "addTag"; + RestTagModel newTagModel = restClient.withCoreAPI().usingResource(document).addTag(newTag); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedModel = restClient.withCoreAPI().usingTag(newTagModel).update(newTag); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedModel.assertThat().field("tag").is(newTag); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify Admin user can update a tag, delete tag and add it.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) + @Bug(id="REPO-1828") + public void withAdminUpdateTagDeleteTagAddTag() throws JsonToModelConversionException, Exception + { + String newTag = "addTag"; + + returnedModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingTag(oldTag).update(newTag); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedModel.assertThat().field("tag").is(newTag); + + restClient.withCoreAPI().usingResource(document).deleteTag(returnedModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingResource(document).addTag(newTag); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + } +} diff --git a/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java index 567148d6c..4b6bb81ae 100644 --- a/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java @@ -51,7 +51,7 @@ public class UpdateTagSanityTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Admin user updates tags and status code is 200") - @Bug(id="MNT-16917") + @Bug(id="REPO-1828") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) public void adminIsAbleToUpdateTags() throws JsonToModelConversionException, Exception { @@ -74,11 +74,14 @@ public class UpdateTagSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user can't update tags with Rest API and status code is 403") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) - public void collaboratorIsNotAbleToUpdateTag() throws JsonToModelConversionException, Exception + public void collaboratorIsNotAbleToUpdateTagCheckDefaultErrorModelSchema() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); restClient.withCoreAPI().usingTag(oldTag).update(randomTag); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); } @TestRail(section = { TestGroup.REST_API, diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessItemFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessItemFullTests.java new file mode 100644 index 000000000..13f9acf76 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessItemFullTests.java @@ -0,0 +1,267 @@ +package org.alfresco.rest.workflow.processes; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.EmptyRestModelCollectionException; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestItemModel; +import org.alfresco.rest.model.RestItemModelsCollection; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.ProcessModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class DeleteProcessItemFullTests extends RestTest +{ + private FileModel document, document2; + private SiteModel siteModel; + private UserModel userWhoStartsProcess, assignee, adminUser, anotherUser, adminTenantUser, tenantUser, tenantUserAssignee, adminTenantUser2; + private ProcessModel processModel; + private RestItemModelsCollection items; + private RestItemModel processItem; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userWhoStartsProcess = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userWhoStartsProcess).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Try to delete existing process item using empty processId") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void deleteProcessItemUsingEmptyProcessId() throws Exception + { + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + document2 = dataContent.usingAdmin().usingSite(siteModel).createContent(DocumentType.MSPOWERPOINT); + processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + processModel.setId(""); + restClient.withWorkflowAPI().usingProcess(processModel).deleteProcessItem(processItem); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "The entity with id: ")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Add a new process item, update the item and then delete.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void createUpdateDeleteProcessItem() throws Exception + { + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + document2 = dataContent.usingAdmin().usingSite(siteModel).createContent(DocumentType.MSPOWERPOINT); + processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + processItem.setName("newItemName"); + processItem.assertThat().field("name").is("newItemName"); + + restClient.withWorkflowAPI().usingProcess(processModel).deleteProcessItem(processItem); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems() + .assertThat().entriesListDoesNotContain("name", processItem.getName()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Delete process item using any user.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void deleteProcessItemByAnyUser() throws Exception + { + anotherUser = dataUser.createRandomTestUser(); + + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + document2 = dataContent.usingAdmin().usingSite(siteModel).createContent(DocumentType.HTML); + processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(anotherUser).withWorkflowAPI().usingProcess(processModel) + .deleteProcessItem(processItem); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError() + .containsSummary(String.format(RestErrorModel.ACCESS_INFORMATION_NOT_ALLOWED, processModel.getId())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .containsErrorKey(String.format(RestErrorModel.ACCESS_INFORMATION_NOT_ALLOWED, processModel.getId())) + .stackTraceIs(RestErrorModel.STACKTRACE);; + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Delete process item with admin.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void deleteProcessItemWithAdmin() throws Exception + { + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + document2 = dataContent.usingAdmin().usingSite(siteModel).createContent(DocumentType.HTML); + processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(adminUser).withWorkflowAPI().usingProcess(processModel) + .deleteProcessItem(processItem); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() + .assertThat().entriesListDoesNotContain("name", processItem.getName()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Delete process item by the user who is involved in the process.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void deleteProcessItemByUserInvolvedInTheProcess() throws Exception + { + processModel = restClient.authenticateUser(assignee).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(processModel) + .deleteProcessItem(processItem); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() + .assertThat().entriesListDoesNotContain("name", processItem.getName()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Delete process item by the user who started the process.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void deleteProcessItemByUserThatStartedTheProcess() throws Exception + { + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingProcess(processModel) + .deleteProcessItem(processItem); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() + .assertThat().entriesListDoesNotContain("name", processItem.getName()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Delete process item for a deleted process.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void deleteProcessItemsForDeletedProcess() throws Exception + { + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.withWorkflowAPI().usingProcess(processModel).deleteProcess(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withWorkflowAPI().usingProcess(processModel).deleteProcessItem(processItem); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, processModel.getId())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Delete process item by inexistent user.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void deleteProcessItemByInexistentUser() throws Exception + { + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(UserModel.getRandomUserModel()).withWorkflowAPI().usingProcess(processModel) + .deleteProcessItem(processItem); + + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Delete process item for process without items.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL}, + expectedExceptions = EmptyRestModelCollectionException.class) + public void deleteProcessItemsForProcessWithoutItems() throws Exception + { + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI() + .addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.Normal); + + items = restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems(); + restClient.assertStatusCodeIs(HttpStatus.OK); + items.assertThat().entriesListIsEmpty(); + + restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingProcess(processModel) + .deleteProcessItem(items.getOneRandomEntry()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Delete process item using by the admin in same network.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL, TestGroup.NETWORKS }) + public void deleteProcessItemByAdminSameNetwork() throws Exception + { + restClient.authenticateUser(adminUser); + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.usingTenant().createTenant(adminTenantUser); + + tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); + + siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); + dataWorkflow.usingUser(tenantUser).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(tenantUserAssignee); + + processModel = restClient.withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(adminTenantUser).withWorkflowAPI().usingProcess(processModel) + .deleteProcessItem(processItem); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() + .assertThat().entriesListDoesNotContain("name", processItem.getName()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Delete process item using by admin in other network.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE, TestGroup.NETWORKS }) + public void deleteProcessItemByAdminInOtherNetwork() throws Exception + { + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser); + tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); + tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + + adminTenantUser2 = UserModel.getAdminTenantUser(); + restClient.usingTenant().createTenant(adminTenantUser2); + + siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); + dataWorkflow.usingUser(tenantUser).usingSite(siteModel).usingResource(document) + .createNewTaskAndAssignTo(tenantUserAssignee); + + processModel = restClient.withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(adminTenantUser2).withWorkflowAPI().usingProcess(processModel) + .deleteProcessItem(processItem); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError() + .containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .containsErrorKey(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + +} diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFullTests.java index 7d72d05a3..9bba5e6c9 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFullTests.java @@ -19,6 +19,7 @@ import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; /** @@ -42,7 +43,12 @@ public class GetTaskFullTests extends RestTest userModel = dataUser.createRandomTestUser(); siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - assigneeUser = dataUser.createRandomTestUser(); + assigneeUser = dataUser.createRandomTestUser(); + } + + @BeforeMethod(alwaysRun=true) + public void createTask() throws Exception + { taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); } diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk1.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk1.java index 6724b2d97..a00e448dd 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk1.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk1.java @@ -10,6 +10,7 @@ import org.alfresco.rest.model.RestProcessDefinitionModel; import org.alfresco.rest.model.RestTaskModel; import org.alfresco.rest.model.RestVariableModelsCollection; import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.ProcessModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TaskModel; import org.alfresco.utility.model.TestGroup; @@ -517,4 +518,70 @@ public class UpdateTaskFullTestsBulk1 extends RestTest restTaskModel = restClient.authenticateUser(anyUser).withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify user cannot delegate task with emty assignee name and response is 400") + public void updateTaskWithEmptyAssigneeValue() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("state", "delegated") + .add("assignee", "") + .build(); + + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(RestErrorModel.DELEGATING_ASSIGNEE_PROVIDED) + .containsSummary(RestErrorModel.DELEGATING_ASSIGNEE_PROVIDED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify owner can resolve task when assignee is the owner and response is 200") + public void taskOwnerUpdateTaskResolveStateAndOwnerAssignee() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("state", "resolved") + .add("assignee", owner.getUsername()) + .build(); + + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("state").is("resolved") + .and().field("assignee").isNull(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify owner cannot update task after it was deleted and response is 404") + public void updateTaskAfterItWasDeleted() throws Exception + { + ProcessModel process = new ProcessModel(); + process.setId(taskModel.getProcessId()); + dataWorkflow.usingUser(owner).deleteProcess(process); + + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.ENTITY_WAS_NOT_FOUND, taskModel.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task owner cannot update task with empty input body and response is 400") + public void taskOwnerCannotUpdateTaskWithEmptyInputBody() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON().build(); + + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(String.format(RestErrorModel.TASK_INVALID_STATE, "null")) + .containsSummary(String.format(RestErrorModel.TASK_INVALID_STATE, "null")); + } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk2.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk2.java index 0a04ac2a9..0c3693255 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk2.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk2.java @@ -251,9 +251,9 @@ public class UpdateTaskFullTestsBulk2 extends RestTest public void updateTaskByProvidingEmptyStateValue() throws Exception { restTaskModel = restClient.authenticateUser(userModel).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask(" "); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() - .containsErrorKey(RestErrorModel.PUT_EMPTY_ARGUMENT) - .containsSummary(RestErrorModel.PUT_EMPTY_ARGUMENT) + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(String.format(RestErrorModel.TASK_INVALID_STATE, " ")) + .containsSummary(String.format(RestErrorModel.TASK_INVALID_STATE, " ")) .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) .stackTraceIs(RestErrorModel.STACKTRACE); } diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskSanityTests.java index bc5329c55..edb4670ef 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskSanityTests.java @@ -88,7 +88,17 @@ public class UpdateTaskSanityTests extends RestTest restTaskModel = restClient.authenticateUser(userModel1).withWorkflowAPI().usingTask(taskModel).updateTask("completed"); restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("description").is(taskModel.getMessage()); + restTaskModel.assertThat() + .field("dueAt").isNotEmpty() + .and().field("processDefinitionId").is("activitiReviewPooled:1:12") + .and().field("processId").is(taskModel.getProcessId()) + .and().field("name").is("Review Task") + .and().field("description").is(taskModel.getMessage()) + .and().field("startedAt").isNotEmpty() + .and().field("id").is(taskModel.getId()) + .and().field("state").is("unclaimed") + .and().field("activityDefinitionId").is("reviewTask") + .and().field("priority").is(taskModel.getPriority().getLevel()) + .and().field("formResourceKey").is("wf:activitiReviewTask"); } } \ No newline at end of file From e45ee85b24e5b7b139b37a85c842dbbf673ab5a6 Mon Sep 17 00:00:00 2001 From: cagache Date: Mon, 6 Feb 2017 15:00:44 +0200 Subject: [PATCH 1014/1491] TAS-2939, TAS-2940 --- .../alfresco/rest/FunctionalCasesTests.java | 64 ++++++++++++++++--- 1 file changed, 56 insertions(+), 8 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java b/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java index 7204afd91..4af8fc716 100644 --- a/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java +++ b/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java @@ -401,19 +401,19 @@ public class FunctionalCasesTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) public void checkTheCommentOfADocumentThatWasDeletedDoesNotExist() throws Exception { - FileModel document = dataContent.usingSite(publicSite).usingUser(adminUser).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + file = dataContent.usingSite(publicSite).usingUser(adminUser).createContent(CMISUtil.DocumentType.TEXT_PLAIN); String newContent = "This is a new comment added by " + adminUser.getUsername(); - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addComment(newContent) + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(file).addComment(newContent) .assertThat().field("content").isNotEmpty() .and().field("content").is(newContent); restClient.assertStatusCodeIs(HttpStatus.CREATED); - dataContent.usingUser(adminUser).usingResource(document).deleteContent(); + dataContent.usingUser(adminUser).usingResource(file).deleteContent(); - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).getNodeComments(); + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(file).getNodeComments(); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary((String.format(RestErrorModel.ENTITY_WAS_NOT_FOUND, document.getNodeRefWithoutVersion()))); + .assertLastError().containsSummary((String.format(RestErrorModel.ENTITY_WAS_NOT_FOUND, file.getNodeRefWithoutVersion()))); } /** @@ -432,10 +432,10 @@ public class FunctionalCasesTests extends RestTest newUser.setUserRole(UserRole.SiteManager); restClient.authenticateUser(adminUser).withCoreAPI().usingSite(privateSite).addPerson(newUser); - FileModel document = dataContent.usingSite(privateSite).usingUser(adminUser).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + file = dataContent.usingSite(privateSite).usingUser(adminUser).createContent(CMISUtil.DocumentType.TEXT_PLAIN); String newContent = "This is a new comment added by " + newUser.getUsername(); - restClient.authenticateUser(newUser).withCoreAPI().usingResource(document).addComment(newContent) + restClient.authenticateUser(newUser).withCoreAPI().usingResource(file).addComment(newContent) .assertThat().field("content").isNotEmpty() .and().field("content").is(newContent); restClient.assertStatusCodeIs(HttpStatus.CREATED); @@ -444,9 +444,57 @@ public class FunctionalCasesTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); restClient.withCoreAPI().usingSite(privateSite).getSiteMembers().assertThat().entriesListDoesNotContain("id", newUser.getUsername()); - RestCommentModelsCollection comments = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).getNodeComments(); + RestCommentModelsCollection comments = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(file).getNodeComments(); restClient.assertStatusCodeIs(HttpStatus.OK); comments.assertThat().entriesListContains("content", newContent) .and().entriesListContains("createdBy.id", newUser.getUsername()); } + + /** + * Scenario: + * 1. Add one file to favorites then add a comment to this file + */ + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, + executionType = ExecutionType.REGRESSION, + description = "Add one file to favorites then add a comment to this file") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void commentAFavoriteFile() throws Exception + { + file = dataContent.usingSite(publicSite).usingUser(adminUser).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + restClient.authenticateUser(manager).withCoreAPI().usingMe().addFileToFavorites(file); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.withCoreAPI().usingAuthUser().getFavorites() + .assertThat().entriesListContains("targetGuid", file.getNodeRefWithoutVersion()); + + RestCommentModel comment = restClient.withCoreAPI().usingResource(file).addComment("new comment"); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + comment.assertThat().field("content").is("new comment"); + } + + /** + * Scenario: + * 1. Remove one file from favorites then add a comment to this file + */ + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, + executionType = ExecutionType.REGRESSION, + description = "Remove one file from favorites then add a comment to this file") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void commentFileRemovedFromFavorites() throws Exception + { + file = dataContent.usingSite(publicSite).usingUser(adminUser).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + restClient.authenticateUser(manager).withCoreAPI().usingMe().addFileToFavorites(file); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.withCoreAPI().usingMe().deleteFileFromFavorites(file); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingAuthUser().getFavorites() + .assertThat().entriesListDoesNotContain("targetGuid", file.getNodeRefWithoutVersion()); + + RestCommentModel comment = restClient.withCoreAPI().usingResource(file).addComment("new comment"); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + comment.assertThat().field("content").is("new comment"); + } + } \ No newline at end of file From c53ced1e0d682f972dd1d573c8a5cbc62d6dad80 Mon Sep 17 00:00:00 2001 From: Bogdan Bocancea Date: Mon, 6 Feb 2017 15:22:50 +0200 Subject: [PATCH 1015/1491] TAS-2933: add full tests for get task items call --- .../workflow/tasks/GetTaskItemsFullTests.java | 199 ++++++++++++++++++ 1 file changed, 199 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskItemsFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskItemsFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskItemsFullTests.java new file mode 100644 index 000000000..9ababbafa --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskItemsFullTests.java @@ -0,0 +1,199 @@ +package org.alfresco.rest.workflow.tasks; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestItemModel; +import org.alfresco.rest.model.RestItemModelsCollection; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TaskModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class GetTaskItemsFullTests extends RestTest +{ + private UserModel userWhoStartsTask, assignee; + private SiteModel siteModel; + private FileModel fileModel; + private TaskModel taskModel; + private RestItemModelsCollection itemModels; + private RestItemModel taskItem; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + userWhoStartsTask = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); + fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Check default error model schema for get task items api call") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + public void getTaskItemsUsingCheckErrorModel() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); + taskModel.setId("invalidId"); + restClient.authenticateUser(assignee).withWorkflowAPI() + .usingTask(taskModel).getTaskItems(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidId")) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } + + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin user can get task items") + public void getTaskItemsByAdminUser() throws Exception + { + restClient.authenticateUser(userWhoStartsTask); + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); + taskItem = restClient.withWorkflowAPI().usingTask(taskModel).getTaskItems().getOneRandomEntry(); + + itemModels = restClient.authenticateUser(dataUser.getAdminUser()).withWorkflowAPI().usingTask(taskModel).getTaskItems(); + restClient.assertStatusCodeIs(HttpStatus.OK); + itemModels.assertThat() + .entriesListIsNotEmpty().and() + .entriesListContains("id", taskItem.onModel().getId()).and() + .entriesListContains("name", taskItem.onModel().getName()) + .getEntries().get(0).onModel() + .assertThat().field("createdAt").isNotNull() + .assertThat().field("size").isNotNull() + .assertThat().field("createdBy").contains(dataUser.getAdminUser().getUsername()) + .assertThat().field("modifiedAt").isNotNull() + .assertThat().field("name").contains(fileModel.getName()) + .assertThat().field("modifiedBy").contains(userWhoStartsTask.getUsername()) + .assertThat().field("id").contains(fileModel.getNodeRef().split(";")[0]) + .assertThat().field("mimeType").contains(fileModel.getFileType().mimeType); + } + + @Bug(id="MNT-17438") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that user who started the process can get task items with skip count parameter") + public void getTaskItemsWithSkipCount() throws Exception + { + restClient.authenticateUser(userWhoStartsTask); + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); + FileModel document1 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document1); + itemModels = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() + .usingParams("skipCount=1").usingTask(taskModel).getTaskItems(); + restClient.assertStatusCodeIs(HttpStatus.OK); + itemModels.assertThat() + .entriesListIsNotEmpty() + .and().paginationField("count").is("1"); + } + + @Bug(id="MNT-17438") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that user who started the process can get task items with max items parameter") + public void getTaskItemsWithMaxItems() throws Exception + { + restClient.authenticateUser(userWhoStartsTask); + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); + FileModel document1 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document1); + itemModels = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() + .usingParams("maxItems=1").usingTask(taskModel).getTaskItems(); + restClient.assertStatusCodeIs(HttpStatus.OK); + itemModels.assertThat() + .entriesListIsNotEmpty() + .and().paginationField("count").is("1"); + } + + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that user who started the process can get task items with valid properties") + public void getTaskItemsWithValidProperties() throws Exception + { + restClient.authenticateUser(userWhoStartsTask); + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); + taskItem = restClient.withWorkflowAPI().usingTask(taskModel).getTaskItems().getOneRandomEntry(); + itemModels = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() + .usingParams("properties=createdAt,createdBy,id,size").usingTask(taskModel).getTaskItems(); + restClient.assertStatusCodeIs(HttpStatus.OK); + itemModels.getOneRandomEntry().onModel().assertThat() + .fieldsCount().is(4).and() + .field("createdAt").isNotNull().and() + .field("size").isNotNull().and() + .field("createdBy").isNotNull().and() + .field("modifiedAt").isNull().and() + .field("name").isNull().and() + .field("modifiedBy").isNull().and() + .field("id").isNotNull().and() + .field("mimeType").isNull(); + } + + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that user who started the process can get task items with an invalid property") + public void getTaskItemsWithInvalidProperties() throws Exception + { + restClient.authenticateUser(userWhoStartsTask); + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); + taskItem = restClient.withWorkflowAPI().usingTask(taskModel).getTaskItems().getOneRandomEntry(); + itemModels = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() + .usingParams("properties=size,fake-prop").usingTask(taskModel).getTaskItems(); + restClient.assertStatusCodeIs(HttpStatus.OK); + itemModels.getOneRandomEntry().onModel().assertThat() + .fieldsCount().is(1).and() + .field("createdAt").isNull().and() + .field("size").isNotNull().and() + .field("createdBy").isNull().and() + .field("modifiedAt").isNull().and() + .field("name").isNull().and() + .field("modifiedBy").isNull().and() + .field("id").isNull().and() + .field("mimeType").isNull(); + } + + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that involved user in process that was deleted cannot get task items") + public void getTaskItemsByDeletedUserInvolvedInProcess() throws Exception + { + UserModel assigneeDeleted = dataUser.createRandomTestUser(); + restClient.authenticateUser(userWhoStartsTask); + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeDeleted); + + dataUser.usingAdmin().deleteUser(assigneeDeleted); + + itemModels = restClient.authenticateUser(assigneeDeleted).withWorkflowAPI().usingTask(taskModel).getTaskItems(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError().containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } + + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that involved user in process that was disabled cannot get task items") + public void getTaskItemsByDisabledUserInvolvedInProcess() throws Exception + { + UserModel assigneeDisabled = dataUser.createRandomTestUser(); + restClient.authenticateUser(userWhoStartsTask); + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeDisabled); + + dataUser.usingAdmin().disableUser(assigneeDisabled); + + itemModels = restClient.authenticateUser(assigneeDisabled).withWorkflowAPI().usingTask(taskModel).getTaskItems(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError().containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } +} From c7894d58bef53a6ce5ed7b28831383abbdd831c7 Mon Sep 17 00:00:00 2001 From: cagache Date: Mon, 6 Feb 2017 15:52:59 +0200 Subject: [PATCH 1016/1491] TAS-2964 --- .../alfresco/rest/FunctionalCasesTests.java | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java b/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java index 4af8fc716..918971f2c 100644 --- a/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java +++ b/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java @@ -11,6 +11,7 @@ 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.springframework.social.alfresco.api.entities.Site; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -497,4 +498,53 @@ public class FunctionalCasesTests extends RestTest comment.assertThat().field("content").is("new comment"); } + /** + * Scenario: + * 1. Add public site to favorites + * 2. Change site visibility to moderated + * 3. Check favorites + * 4. Change site visibility to private + * 5. Check favorites + */ + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, + executionType = ExecutionType.REGRESSION, + description = "Check favorite sites after a favorite site visibility is changed") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) + public void changeFavoriteSiteVisibilityThenCheckFavorites() throws Exception + { + SiteModel favoriteSite = dataSite.usingUser(manager).createPublicRandomSite(); + UserModel regularUser = dataUser.createRandomTestUser(); + + restClient.authenticateUser(regularUser).withCoreAPI().usingAuthUser().addSiteToFavorites(favoriteSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestPersonFavoritesModelsCollection userFavoriteSites = restClient.withCoreAPI().usingAuthUser().where().targetSiteExist().getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + userFavoriteSites.assertThat().entriesListContains("targetGuid", favoriteSite.getGuid()) + .assertThat().entriesListContains("target.site.visibility", favoriteSite.getVisibility().name()) + .assertThat().entriesListContains("target.site.id", favoriteSite.getId()); + + dataSite.usingUser(manager).updateSiteVisibility(favoriteSite, Site.Visibility.MODERATED); + + userFavoriteSites = restClient.authenticateUser(regularUser).withCoreAPI().usingAuthUser().where().targetSiteExist().getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + userFavoriteSites.assertThat().entriesListContains("targetGuid", favoriteSite.getGuid()) + .assertThat().entriesListContains("target.site.visibility", "MODERATED") + .assertThat().entriesListContains("target.site.id", favoriteSite.getId()); + + dataSite.usingUser(manager).updateSiteVisibility(favoriteSite, Site.Visibility.PRIVATE); + + userFavoriteSites = restClient.authenticateUser(regularUser).withCoreAPI().usingAuthUser().where().targetSiteExist().getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + userFavoriteSites.assertThat().entriesListIsEmpty(); + + dataSite.usingUser(manager).updateSiteVisibility(favoriteSite, Site.Visibility.PUBLIC); + + userFavoriteSites = restClient.authenticateUser(regularUser).withCoreAPI().usingAuthUser().where().targetSiteExist().getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + userFavoriteSites.assertThat().entriesListContains("targetGuid", favoriteSite.getGuid()) + .assertThat().entriesListContains("target.site.visibility", favoriteSite.getVisibility().name()) + .assertThat().entriesListContains("target.site.id", favoriteSite.getId()); + } + } \ No newline at end of file From e259c11170161847ee3b0700b19b00b403d2b5cf Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Mon, 6 Feb 2017 16:03:02 +0200 Subject: [PATCH 1017/1491] added 5 full tests for updateTask --- .../tasks/UpdateTaskFullTestsBulk1.java | 80 ++++++++++++++++++- 1 file changed, 79 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk1.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk1.java index a00e448dd..81e966827 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk1.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk1.java @@ -30,7 +30,7 @@ import org.testng.annotations.Test; */ public class UpdateTaskFullTestsBulk1 extends RestTest { - UserModel owner; + UserModel owner, anyUser; SiteModel siteModel; UserModel candidateUser; FileModel fileModel; @@ -41,6 +41,7 @@ public class UpdateTaskFullTestsBulk1 extends RestTest @BeforeClass(alwaysRun=true) public void dataPreparation() throws Exception { + anyUser = dataUser.createRandomTestUser(); owner = dataUser.createRandomTestUser(); siteModel = dataSite.usingUser(owner).createPublicRandomSite(); fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); @@ -584,4 +585,81 @@ public class UpdateTaskFullTestsBulk1 extends RestTest .containsErrorKey(String.format(RestErrorModel.TASK_INVALID_STATE, "null")) .containsSummary(String.format(RestErrorModel.TASK_INVALID_STATE, "null")); } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify any user cannot update task using another name") + public void anyUserCannotUpdateTaskUsingAnotherName() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("name", "Review Task-updated") + .build(); + + restClient.authenticateUser(anyUser).withParams("select=name").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify any user cannot update task using another description") + public void anyUserCannotUpdateTaskUsingAnotherDescription() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("description", "description updated") + .build(); + + restClient.authenticateUser(anyUser).withParams("select=description").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify any user cannot update task using another description") + public void anyUserCannotUpdateTaskUsingAnotherDueAt() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("dueAt", "2025-01-01T11:57:32.000+0000") + .build(); + + restClient.authenticateUser(anyUser).withParams("select=dueAt").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify any user cannot update task using another priority") + public void anyUserCannotUpdateTaskUsingAnotherPriority() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("priority", 3) + .build(); + + restClient.authenticateUser(anyUser).withParams("select=priority").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify any user cannot update task using another priority") + public void anyUserCannotUpdateTaskUsingAnotherOwner() throws Exception + { + UserModel newOwner = dataUser.createRandomTestUser(); + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("owner", newOwner.getUsername()) + .build(); + + + restClient.authenticateUser(anyUser).withParams("select=owner").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } } From 8f3010cac7d88aa491e90ea494dbf3daa2b6028b Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Mon, 6 Feb 2017 16:44:09 +0200 Subject: [PATCH 1018/1491] added 5 full tests for updateTask --- .../tasks/UpdateTaskFullTestsBulk1.java | 79 ++++++++++++++++++- 1 file changed, 78 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk1.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk1.java index 81e966827..e3ee74d64 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk1.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk1.java @@ -5,6 +5,7 @@ import javax.json.JsonObject; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.core.JsonBodyGenerator; +import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessDefinitionModel; import org.alfresco.rest.model.RestTaskModel; @@ -18,6 +19,7 @@ import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; @@ -618,7 +620,7 @@ public class UpdateTaskFullTestsBulk1 extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify any user cannot update task using another description") + description = "Verify any user cannot update task using another dueAt") public void anyUserCannotUpdateTaskUsingAnotherDueAt() throws Exception { JsonObject inputJson = JsonBodyGenerator.defineJSON() @@ -662,4 +664,79 @@ public class UpdateTaskFullTestsBulk1 extends RestTest .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify any user cannot update task using invalid name") + public void anyUserCannotUpdateTaskUsingInvalidName() throws Exception + { + restClient.authenticateUser(owner).withParams("select=name").withWorkflowAPI().usingTask(taskModel); + String postBody = "{\"name\":\"invalid-\"a\"}"; + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); + restTaskModel = restClient.processModel(RestTaskModel.class, request); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "Unexpected character ('a'")) + .containsSummary(String.format(RestErrorModel.NO_CONTENT, "Unexpected character ('a'")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify any user cannot update task using invalid description") + public void anyUserCannotUpdateTaskUsingInvalidDescription() throws Exception + { + restClient.authenticateUser(owner).withParams("select=description").withWorkflowAPI().usingTask(taskModel); + String postBody = "{\"description\":\"invalid-\"a\"}"; + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); + restTaskModel = restClient.processModel(RestTaskModel.class, request); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "Unexpected character ('a'")) + .containsSummary(String.format(RestErrorModel.NO_CONTENT, "Unexpected character ('a'")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify any user cannot update task using invalid dueAt") + public void anyUserCannotUpdateTaskUsingInvalidDueAt() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("dueAt", "invalid-date") + .build(); + + restClient.authenticateUser(anyUser).withParams("select=dueAt").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "Can not construct instance of java.util.Date from String value 'invalid-date'")) + .containsSummary(String.format(RestErrorModel.NO_CONTENT, "Can not construct instance of java.util.Date from String value 'invalid-date'")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify any user cannot update task using invalid priority") + public void anyUserCannotUpdateTaskUsingInvalidPriority() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("priority", "a") + .build(); + + restClient.authenticateUser(anyUser).withParams("select=priority").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "Can not construct instance of int from String value 'a'")) + .containsSummary(String.format(RestErrorModel.NO_CONTENT, "Can not construct instance of int from String value 'a'")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify any user cannot update task using invalid priority") + public void anyUserCannotUpdateTaskUsingInvalidOwner() throws Exception + { + restClient.authenticateUser(owner).withParams("select=owner").withWorkflowAPI().usingTask(taskModel); + String postBody = "{\"owner\":\"invalid-\"a\"}"; + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); + restTaskModel = restClient.processModel(RestTaskModel.class, request); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "Unexpected character ('a'")) + .containsSummary(String.format(RestErrorModel.NO_CONTENT, "Unexpected character ('a'")); + } } From 807191d026976f949344d648653b8bd298652f3c Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Mon, 6 Feb 2017 17:14:46 +0200 Subject: [PATCH 1019/1491] fixed test getProcessesWithPropertiesParameter --- .../processes/GetProcessesFullTests.java | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesFullTests.java index 96bb3d92b..58c981d5e 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesFullTests.java @@ -114,11 +114,23 @@ public class GetProcessesFullTests extends RestTest RestProcessModelsCollection processes = restClient.authenticateUser(userWhoStartsTask).withParams("properties=id") .withWorkflowAPI().getProcesses(); restClient.assertStatusCodeIs(HttpStatus.OK); - processes.assertThat().entriesListIsNotEmpty(); List processesList = processes.getEntries(); - processesList.get(0).onModel().assertThat().fieldsCount().is(1).and().field("id").is(process3.getId()); - processesList.get(1).onModel().assertThat().fieldsCount().is(1).and().field("id").is(task2.getProcessId()); - processesList.get(2).onModel().assertThat().fieldsCount().is(1).and().field("id").is(task1.getProcessId()); + processesList.get(0).onModel().assertThat().fieldsCount().is(1) + .and().field("id").isNotEmpty() + .and().field("processDefinitionId").isNull() + .and().field("startUserId").isNull(); + processesList.get(1).onModel().assertThat().fieldsCount().is(1) + .and().field("id").isNotEmpty() + .and().field("processDefinitionId").isNull() + .and().field("startUserId").isNull(); + processesList.get(2).onModel().assertThat().fieldsCount().is(1) + .and().field("id").isNotEmpty() + .and().field("processDefinitionId").isNull() + .and().field("startUserId").isNull(); + processes.assertThat().entriesListIsNotEmpty() + .and().entriesListContains("id", process3.getId()) + .and().entriesListContains("id", task2.getProcessId()) + .and().entriesListContains("id", task1.getProcessId()); } @Bug(id = "REPO-1958") From 1e1f4c3c818505791260cc2c65f621cce5f77914 Mon Sep 17 00:00:00 2001 From: mionescu Date: Tue, 7 Feb 2017 09:46:52 +0200 Subject: [PATCH 1020/1491] added new test cases: FULL suite - TAS-2904 updated tests: check error model (Core and Sanity) --- .../AddProcessVariableCoreTests.java | 216 ++++++++++-------- .../AddProcessVariableFullTests.java | 201 ++++++++++++++++ .../AddProcessVariableSanityTests.java | 9 +- 3 files changed, 334 insertions(+), 92 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableCoreTests.java index 889b850a8..9d3748599 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableCoreTests.java @@ -49,8 +49,9 @@ public class AddProcessVariableCoreTests extends RestTest processVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.OK); - processVariable.assertThat().field("name").is(processVariable.getName()).and().field("type").is(processVariable.getType()).and().field("value") - .is(processVariable.getValue()); + processVariable.assertThat().field("name").is(processVariable.getName()) + .and().field("type").is(processVariable.getType()) + .and().field("value").is(processVariable.getValue()); } @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, @@ -63,10 +64,127 @@ public class AddProcessVariableCoreTests extends RestTest processVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.OK); - processVariable.assertThat().field("name").is(processVariable.getName()).and().field("type").is(processVariable.getType()).and().field("value") - .is(processVariable.getValue()); + processVariable.assertThat().field("name").is(processVariable.getName()) + .and().field("type").is(processVariable.getType()) + .and().field("value").is(processVariable.getValue()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding process variable is falling in case invalid type is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + public void failedAddingProcessVariableIfInvalidTypeIsProvided() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:textarea"); + + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsErrorKey(String.format(RestErrorModel.UNSUPPORTED_TYPE, "d:textarea")) + .containsSummary(String.format(RestErrorModel.UNSUPPORTED_TYPE, "d:textarea")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Bug(id = "REPO-1938") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding process variable is falling in case invalid type prefix is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + public void failedAddingProcessVariableIfInvalidTypePrefixIsProvided() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("ddt:text"); + + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .containsSummary(String.format(RestErrorModel.INVALID_NAMEPACE_PREFIX, "ddt")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); } + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding process variable is falling in case invalid value is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + public void failedAddingProcessVariableIfInvalidValueIsProvided() throws Exception + { + RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:int"); + variableModel.setValue("invalidValue"); + + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .containsSummary(String.format(RestErrorModel.FOR_INPUT_STRING, "invalidValue")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding process variable is falling in case missing required variable body (name) is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + public void failedAddingProcessVariableIfMissingRequiredVariableNameBodyIsProvided() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"value\": \"missingVariableName\",\"type\": \"d:text\"}", + "processes/{processId}/variables/{variableName}", processModel.getId(), variableModel.getName()); + restClient.processModel(RestProcessVariableModel.class, request); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsErrorKey(RestErrorModel.VARIABLE_NAME_REQUIRED) + .containsSummary(RestErrorModel.VARIABLE_NAME_REQUIRED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding process variable is falling in case invalid variableBody (adding extra parameter in body) is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + public void failedAddingProcessVariableIfInvalidBodyIsProvided() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"scope\": \"local\",\"value\": \"testing\",\"type\": \"d:text\"}", + "processes/{processId}/variables/{variableName}", processModel.getId(), variableModel.getName()); + restClient.processModel(RestProcessVariableModel.class, request); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "Unrecognized field \"scope\"")) + .containsSummary(String.format(RestErrorModel.NO_CONTENT, "Unrecognized field \"scope\"")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding process variable is falling in case empty name is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + public void failedAddingProcessVariableIfEmptyNameIsProvided() throws Exception + { + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); + RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + variableModel.setName(""); + + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); + + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) + .assertLastError() + .containsErrorKey(RestErrorModel.PUT_EMPTY_ARGUMENT) + .containsSummary(RestErrorModel.PUT_EMPTY_ARGUMENT) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add process variable using by admin in other network.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE, TestGroup.NETWORKS }) @@ -84,93 +202,9 @@ public class AddProcessVariableCoreTests extends RestTest restClient.authenticateUser(adminTenantUser2); variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); processVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding process variable is falling in case invalid type is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) - public void failedAddingProcessVariableIfInvalidTypeIsProvided() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:textarea"); - - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary( - String.format(RestErrorModel.UNSUPPORTED_TYPE, "d:textarea")); - } - - @Bug(id = "REPO-1938") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding process variable is falling in case invalid type prefix is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) - public void failedAddingProcessVariableIfInvalidTypePrefixIsProvided() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("ddt:text"); - - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Namespace prefix ddt is not mapped to a namespace URI"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding process variable is falling in case invalid value is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) - public void failedAddingProcessVariableIfInvalidValueIsProvided() throws Exception - { - RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:int"); - variableModel.setValue("invalidValue"); - - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("For input string: \"invalidValue\""); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding process variable is falling in case missing required variable body (name) is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) - public void failedAddingProcessVariableIfMissingRequiredVariableBodyIsProvided() throws Exception - { - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"value\": \"missingVariableName\",\"type\": \"d:text\"}", - "processes/{processId}/variables/{variableName}", processModel.getId(), variableModel.getName()); - restClient.processModel(RestProcessVariableModel.class, request); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Variable name is required."); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding process variable is falling in case invalid variableBody (adding extra parameter in body) is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) - public void failedAddingProcessVariableIfInvalidBodyIsProvided() throws Exception - { - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"scope\": \"local\",\"value\": \"testing\",\"type\": \"d:text\"}", - "processes/{processId}/variables/{variableName}", processModel.getId(), variableModel.getName()); - restClient.processModel(RestProcessVariableModel.class, request); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary("Could not read content from HTTP request body: Unrecognized field \"scope\""); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding process variable is falling in case empty name is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) - public void failedAddingProcessVariableIfEmptyNameIsProvided() throws Exception - { - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); - RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - variableModel.setName(""); - - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); - - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.PUT_EMPTY_ARGUMENT); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError() + .containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT); } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableFullTests.java new file mode 100644 index 000000000..219f4ba1d --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableFullTests.java @@ -0,0 +1,201 @@ +package org.alfresco.rest.workflow.processes; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestProcessVariableModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.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 AddProcessVariableFullTests extends RestTest +{ + private FileModel document; + private SiteModel siteModel; + private UserModel userWhoStartsProcess, assignee, adminUser; + private RestProcessModel processModel; + private RestProcessVariableModel variableModel, processVariable, updatedProcessVariable; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userWhoStartsProcess = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userWhoStartsProcess).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify addProcessVariable by any user for invalid processID with REST API and status code is NOT_FOUND (404)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void addProcessVariableWithInvalidProcessId() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processModel.setId("invalidProcessID"); + + processVariable = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingProcess(processModel) + .updateProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidProcessID")); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify addProcessVariable by any user for empty processID with REST API and status code is NOT_FOUND (404)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void addProcessVariableWithEmptyProcessId() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processModel.setId(""); + + processVariable = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingProcess(processModel) + .updateProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding process variable is falling in case of empty value is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void failedAddingProcessVariableIfEmptyValueIsProvided() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:int"); + variableModel.setValue(""); + + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .containsSummary(String.format(RestErrorModel.FOR_INPUT_STRING, "")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding process variable in case of having only 'name' field is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void addingProcessVariableWithOnlyNameProvided() throws Exception + { + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"name\": \"variableName\"}", + "processes/{processId}/variables/{variableName}", processModel.getId(), "variableName"); + processVariable = restClient.processModel(RestProcessVariableModel.class, request); + + restClient.assertStatusCodeIs(HttpStatus.OK); + processVariable.assertThat().field("name").is("variableName") + .and().field("type").is("d:any") + .and().field("value").isNull(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding process variable in case of missing type field is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void addingProcessVariableIfMissingValueIsProvided() throws Exception + { + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"name\": \"variableName\", \"type\": \"d:text\"}", + "processes/{processId}/variables/{variableName}", processModel.getId(), "variableName"); + processVariable = restClient.processModel(RestProcessVariableModel.class, request); + + restClient.assertStatusCodeIs(HttpStatus.OK); + processVariable.assertThat().field("name").is("variableName") + .and().field("type").is("d:text") + .and().field("value").isNull(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding process variable in case of missing type field is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void addingProcessVariableIfMissingTypeIsProvided() throws Exception + { + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"value\": \"variableValue\", \"name\": \"variableName\"}", + "processes/{processId}/variables/{variableName}", processModel.getId(), "variableValue"); + processVariable = restClient.processModel(RestProcessVariableModel.class, request); + + restClient.assertStatusCodeIs(HttpStatus.OK); + processVariable.assertThat().field("name").is("variableName") + .and().field("type").is("d:text") + .and().field("value").is("variableValue"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding process variable is case of empty type value is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void addingProcessVariableIfEmptyTypeIsProvided() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel(""); + + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); + + restClient.assertStatusCodeIs(HttpStatus.OK); + processVariable.assertThat().field("name").is(processVariable.getName()) + .and().field("type").is("d:text") + .and().field("value").is(processVariable.getValue()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding process variable in case of empty body field is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void addingProcessVariableWithEmptyBodyProvided() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel(""); + + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{ }", + "processes/{processId}/variables/{variableName}", processModel.getId(), variableModel.getName()); + processVariable = restClient.processModel(RestProcessVariableModel.class, request); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsErrorKey(RestErrorModel.VARIABLE_NAME_REQUIRED) + .containsSummary(RestErrorModel.VARIABLE_NAME_REQUIRED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Update twice in a row the same variable.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void updateTwiceInARowSameProcessVariable() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + + processVariable = restClient.withWorkflowAPI().usingProcess(processModel) + .updateProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + processVariable.assertThat().field("name").is(variableModel.getName()) + .and().field("type").is(variableModel.getType()) + .and().field("value").is(variableModel.getValue()); + + restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() + .assertThat().entriesListContains("name", processVariable.getName()); + + updatedProcessVariable = restClient.withWorkflowAPI().usingProcess(processModel) + .updateProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedProcessVariable.assertThat().field("name").is(variableModel.getName()) + .and().field("type").is(variableModel.getType()) + .and().field("value").is(variableModel.getValue()); + + restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() + .assertThat().entriesListContains("name", variableModel.getName()); + } + +} diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java index 0910f99aa..89c7dbdd9 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java @@ -3,6 +3,7 @@ package org.alfresco.rest.workflow.processes; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.CMISUtil.Priority; import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.rest.model.RestProcessVariableModel; import org.alfresco.utility.data.RandomData; @@ -89,6 +90,7 @@ public class AddProcessVariableSanityTests extends RestTest restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee, false, Priority.Normal); variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); processModel = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.OK); processVariable.assertThat().field("name").is(variableModel.getName()) @@ -103,8 +105,13 @@ public class AddProcessVariableSanityTests extends RestTest { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("incorrect type"); processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary("Unsupported type of variable: 'incorrect type'."); + .assertLastError() + .containsErrorKey(String.format(RestErrorModel.UNSUPPORTED_TYPE, "incorrect type")) + .containsSummary(String.format(RestErrorModel.UNSUPPORTED_TYPE, "incorrect type")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); } } From 8ab0936a0a25e9f7ef36121807ce3377a99c91c7 Mon Sep 17 00:00:00 2001 From: cagache Date: Tue, 7 Feb 2017 10:04:08 +0200 Subject: [PATCH 1021/1491] TAS-2950 --- .../alfresco/rest/FunctionalCasesTests.java | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java b/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java index 918971f2c..f6fc081ab 100644 --- a/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java +++ b/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java @@ -547,4 +547,79 @@ public class FunctionalCasesTests extends RestTest .assertThat().entriesListContains("target.site.id", favoriteSite.getId()); } + /** + * Scenario: + * 1. Regular user adds moderated site membership request + * 2. Site manager approves the request + * 3. Site manager updates the new member role to Manager + * 4. New member adds comment to a file on site + * 5. New member likes and rate one file + * 6. New member adds tags to a file + * 7. New member adds site to favorite + * 8. New member adds, then deletes a site member + */ + @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, + executionType = ExecutionType.REGRESSION, + description = "Check that a user who joins a moderated site as manager is able to comment, rate, tag an existing file from the site, add site to favorites, add and remove site members.") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + public void checkNewManagerActions() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + file = dataContent.usingSite(moderatedSite).usingUser(adminUser).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestTaskModel taskModel = restClient.withWorkflowAPI().getTasks().getTaskModelByDescription(moderatedSite); + workflow.approveSiteMembershipRequest(adminUser.getUsername(), adminUser.getPassword(), taskModel.getId(), true, "Approve"); + returnedCollection = restClient.withCoreAPI().usingMe().getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat().entriesListDoesNotContain("id", moderatedSite.getId()); + + newMember.setUserRole(UserRole.SiteManager); + restClient.authenticateUser(adminUser).withCoreAPI().usingSite(moderatedSite).updateSiteMember(newMember) + .assertThat().field("id").is(newMember.getUsername()) + .and().field("role").is(newMember.getUserRole()); + restClient.assertStatusCodeIs(HttpStatus.OK); + + RestCommentModel comment = restClient.authenticateUser(newMember).withCoreAPI().usingResource(file).addComment("new comment"); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + comment.assertThat().field("content").is("new comment"); + + RestRatingModel returnedRatingModel = restClient.withCoreAPI().usingResource(file).likeDocument(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedRatingModel.assertThat().field("myRating").is("true") + .and().field("id").is("likes") + .and().field("aggregate").isNotEmpty(); + + returnedRatingModel = restClient.withCoreAPI().usingResource(file).rateStarsToDocument(5); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedRatingModel.assertThat().field("myRating").is("5") + .and().field("id").is("fiveStar") + .and().field("aggregate").isNotEmpty(); + + RestTagModel tag = restClient.withCoreAPI().usingResource(file).addTag("filetag"); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + tag.assertThat().field("tag").is("filetag") + .and().field("id").isNotEmpty(); + + restFavoriteSiteModel = restClient.withCoreAPI().usingAuthUser().addFavoriteSite(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restFavoriteSiteModel.assertThat().field("id").is(moderatedSite.getId()); + + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteManager); + restClient.withCoreAPI().usingSite(moderatedSite).addPerson(testUser) + .assertThat().field("id").is(testUser.getUsername()) + .and().field("role").is(testUser.getUserRole()); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.withCoreAPI().usingSite(moderatedSite).deleteSiteMember(testUser); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingSite(moderatedSite).getSiteMembers() + .assertThat().entriesListDoesNotContain("id", testUser.getUsername()); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + } \ No newline at end of file From 330e4037fc62c64b23884b883b3018de448e9036 Mon Sep 17 00:00:00 2001 From: Bogdan Bocancea Date: Tue, 7 Feb 2017 10:33:22 +0200 Subject: [PATCH 1022/1491] TAS-2935: add full tests for delete /tasks/{taskId}/items/{itemId} --- .../tasks/RemoveTaskItemFullTests.java | 97 +++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/tasks/RemoveTaskItemFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/RemoveTaskItemFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/RemoveTaskItemFullTests.java new file mode 100644 index 000000000..c28acc196 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/RemoveTaskItemFullTests.java @@ -0,0 +1,97 @@ +package org.alfresco.rest.workflow.tasks; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestItemModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TaskModel; +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 bogdan.bocancea + */ +public class RemoveTaskItemFullTests extends RestTest +{ + private UserModel userWhoStartsTask, assigneeUser; + private SiteModel siteModel; + private FileModel fileModel, document2; + private TaskModel taskModel; + private RestItemModel taskItem; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + userWhoStartsTask = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); + fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + assigneeUser = dataUser.createRandomTestUser(); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Delete task item twice") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + public void deleteTaskItemTwice() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + restClient.authenticateUser(userWhoStartsTask); + document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); + + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Delete task item with locked document") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + public void deleteTaskItemWithLockedDocument() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + restClient.authenticateUser(userWhoStartsTask); + document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); + + dataContent.usingUser(userWhoStartsTask).usingResource(document2).checkOutDocument(); + + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); + restClient.assertStatusCodeIs(HttpStatus.CONFLICT) + .assertLastError().containsSummary(String.format(RestErrorModel.LOCKED_NODE_OPERATION, document2.getNodeRefWithoutVersion())) + .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Delete task item with deleted document") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + public void deleteTaskItemWithDeletedDocument() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + restClient.authenticateUser(userWhoStartsTask); + document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); + + dataContent.usingUser(userWhoStartsTask).usingResource(document2).deleteContent(); + + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.PROCESS_ENTITY_NOT_FOUND, document2.getNodeRefWithoutVersion())) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } +} \ No newline at end of file From bf7a1682b165a03bcf23ea4018eac9cfd234b577 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Tue, 7 Feb 2017 10:43:29 +0200 Subject: [PATCH 1023/1491] Added scenario for create, modify, delete types of activities for an user inside a siteand check activities call --- .../alfresco/rest/FunctionalCasesTests.java | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java b/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java index f6fc081ab..ba8a8b826 100644 --- a/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java +++ b/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java @@ -3,11 +3,14 @@ package org.alfresco.rest; import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.model.*; +import org.alfresco.utility.constants.ActivityType; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -24,6 +27,10 @@ public class FunctionalCasesTests extends RestTest private RestFavoriteSiteModel restFavoriteSiteModel; private RestActivityModelsCollection activities; private FileModel file; + private RestActivityModelsCollection restActivityModelsCollection; + private FolderModel folderInSite; + private FileModel fileInSite; + private RestCommentModel commentModel; @BeforeClass(alwaysRun=true) public void dataPreparation() throws Exception @@ -621,5 +628,63 @@ public class FunctionalCasesTests extends RestTest .assertThat().entriesListDoesNotContain("id", testUser.getUsername()); restClient.assertStatusCodeIs(HttpStatus.OK); } + + /** + * Scenario: + * 1. Add user to site + * 2. Create folder + * 3. Create document + * 4. Add comment to the document + * 5. Like document + * 6. Update Comment + * 7. Update user role + * 8. Delete like rating + * 9. Delete site member + * 10. Delete comment + * 11. Get Activities + * + * @throws Exception + */ + @Bug(id="REPO-1830") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its activities with Rest API and response is successful") + public void userGetsItsPeopleActivities() throws Exception + { + UserModel newUser = dataUser.createRandomTestUser(); + SiteModel userSiteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); + dataUser.addUserToSite(newUser, userSiteModel, UserRole.SiteCollaborator); + folderInSite = dataContent.usingUser(newUser).usingSite(userSiteModel).createFolder(); + fileInSite = dataContent.usingUser(newUser).usingSite(userSiteModel).createContent(DocumentType.TEXT_PLAIN); + String newContent = "This is a new comment added by " + newUser.getUsername(); + commentModel = restClient.authenticateUser(newUser).withCoreAPI().usingResource(fileInSite).addComment(newContent); + restClient.authenticateUser(newUser).withCoreAPI().usingResource(fileInSite).likeDocument(); + + restClient.withCoreAPI().usingResource(fileInSite).updateComment(commentModel, "new Content"); + newUser.setUserRole(UserRole.SiteManager); + restClient.authenticateUser(adminUser).withCoreAPI().usingSite(userSiteModel).updateSiteMember(newUser); + + restClient.authenticateUser(newUser).withCoreAPI().usingResource(fileInSite).deleteLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withCoreAPI().usingResource(fileInSite).deleteComment(commentModel); + restClient.authenticateUser(adminUser).withCoreAPI().usingSite(userSiteModel).deleteSiteMember(newUser); + + restActivityModelsCollection = restClient.authenticateUser(newUser).withCoreAPI().usingMe().getPersonActivitiesUntilEntriesCountIs(10); + restClient.assertStatusCodeIs(HttpStatus.OK); + restActivityModelsCollection.assertThat().paginationField("count").is("10"); + + restActivityModelsCollection = restClient.authenticateUser(newUser).withCoreAPI().usingMe().getPersonActivities(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restActivityModelsCollection.assertThat().paginationField("count").is("10"); + + restActivityModelsCollection.assertThat().entriesListContains("activityType", ActivityType.USER_JOINED.toString()).assertThat() + .entriesListContains("activityType", ActivityType.FILE_ADDED.toString()).assertThat() + .entriesListContains("activityType", ActivityType.FOLDER_ADDED.toString()).assertThat() + .entriesListContains("activityType", ActivityType.COMMENT_CREATED.toString()).assertThat() + .entriesListContains("activityType", ActivityType.FILE_LIKED.toString()).assertThat() + .entriesListContains("activityType", ActivityType.COMMENT_UPDATED.toString()).assertThat() + .entriesListContains("activityType", ActivityType.USER_ROLE_CHANGED.toString()).assertThat() + .entriesListContains("activityType", ActivityType.COMMENT_DELETED.toString()).assertThat() + .entriesListContains("activityType", ActivityType.USER_LEFT.toString()); + } } \ No newline at end of file From 353d6365a6841f288a8588fb215d9045894160db Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Tue, 7 Feb 2017 11:12:46 +0200 Subject: [PATCH 1024/1491] Add separate tests for update task by creator and assignee --- .../tasks/UpdateTaskFullTestsBulk2.java | 302 ++++++++++++++---- 1 file changed, 244 insertions(+), 58 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk2.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk2.java index 0c3693255..22f741646 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk2.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk2.java @@ -22,7 +22,7 @@ import org.testng.annotations.Test; public class UpdateTaskFullTestsBulk2 extends RestTest { - private UserModel userModel; + private UserModel taskCreator; private SiteModel siteModel; private FileModel fileModel; private UserModel assigneeUser; @@ -34,7 +34,7 @@ public class UpdateTaskFullTestsBulk2 extends RestTest public void dataPreparation() throws Exception { adminUser = dataUser.getAdminUser(); - userModel = dataUser.createRandomTestUser(); + taskCreator = dataUser.createRandomTestUser(); siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); assigneeUser = dataUser.createRandomTestUser(); @@ -43,91 +43,174 @@ public class UpdateTaskFullTestsBulk2 extends RestTest @BeforeMethod(alwaysRun = true) public void createTask() throws Exception { - taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + taskModel = dataWorkflow.usingUser(taskCreator).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from unclaimed to claimed") + description = "Verify that task can be updated from unclaimed to claimed by task creator") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void userCanUpdateTaskFromUnclaimedToClaimed() throws Exception + public void taskCreatorCanUpdateTaskFromUnclaimedToClaimed() throws Exception { - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); restClient.assertStatusCodeIs(HttpStatus.OK); restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); - restTaskModel = restClient.authenticateUser(userModel).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); + restTaskModel = restClient.authenticateUser(taskCreator).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); restClient.assertStatusCodeIs(HttpStatus.OK); restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("claimed"); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from unclaimed to delegated") + description = "Verify that task cannot be updated from unclaimed to claimed by a regular user not connected to the task") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void userCanUpdateTaskFromUnclaimedToDelegated() throws Exception + public void regularUserCannotUpdateTaskFromUnclaimedToClaimed() throws Exception { - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from unclaimed to delegated by task creator") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + public void taskCreatorCanUpdateTaskFromUnclaimedToDelegated() throws Exception + { + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); restClient.assertStatusCodeIs(HttpStatus.OK); restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); - JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); + JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", taskCreator.getUsername()).build(); - restTaskModel = restClient.authenticateUser(userModel).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restTaskModel = restClient.authenticateUser(taskCreator).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); restClient.assertStatusCodeIs(HttpStatus.OK); restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from unclaimed to resolved") + description = "Verify that task cannot be updated from unclaimed to delegated by a regular user not connected to the task") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void userCanUpdateTaskFromUnclaimedToResolved() throws Exception + public void regularUserCannotUpdateTaskFromUnclaimedToDelegated() throws Exception { - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); restClient.assertStatusCodeIs(HttpStatus.OK); restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); - restTaskModel = restClient.authenticateUser(userModel).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + + JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); + + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from unclaimed to resolved by task creator") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + public void taskCreatorCanUpdateTaskFromUnclaimedToResolved() throws Exception + { + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); + restTaskModel = restClient.authenticateUser(taskCreator).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); restClient.assertStatusCodeIs(HttpStatus.OK); restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("resolved"); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from unclaimed to unclaimed") + description = "Verify that task can be updated from unclaimed to resolved by a regular user not connected to the task") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void userCanUpdateTaskFromUnclaimedToUnclaimed() throws Exception + public void regularCanUpdateTaskFromUnclaimedToResolved() throws Exception { - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); restClient.assertStatusCodeIs(HttpStatus.OK); restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); - restTaskModel = restClient.authenticateUser(userModel).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from unclaimed to unclaimed by task creator") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + public void taskCreatorCanUpdateTaskFromUnclaimedToUnclaimed() throws Exception + { + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); + restTaskModel = restClient.authenticateUser(taskCreator).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from unclaimed to unclaimed by a regular user not connected to the task") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + public void regularUserCannotUpdateTaskFromUnclaimedToUnclaimed() throws Exception + { + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Bug(id = "REPO-1982") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from delegated to unclaimed by task creator") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + public void taskCreatorCanUpdateTaskFromDelegatedToUnclaimed() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); + + restTaskModel = restClient.authenticateUser(taskCreator).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); restClient.assertStatusCodeIs(HttpStatus.OK); restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); } @Bug(id = "REPO-1982") @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from delegated to unclaimed") + description = "Verify that task can be updated from delegated to unclaimed by task assignee") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void userCanUpdateTaskFromDelegatedToUnclaimed() throws Exception + public void taskAssigneeCanUpdateTaskFromDelegatedToUnclaimed() throws Exception { JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); - restTaskModel = restClient.authenticateUser(userModel).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); restClient.assertStatusCodeIs(HttpStatus.OK); restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); - restTaskModel = restClient.authenticateUser(userModel).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); restClient.assertStatusCodeIs(HttpStatus.OK); restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task cannot be updated from delegated to claimed since it is already claimed") + description = "Verify that task cannot be updated from delegated to claimed since it is already claimed by task creator") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void userCannotUpdateTaskFromDelegatedToClaimed() throws Exception + public void taskCreatorCannotUpdateTaskFromDelegatedToClaimed() throws Exception { JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); - restTaskModel = restClient.authenticateUser(userModel).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); restClient.assertStatusCodeIs(HttpStatus.OK); restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); - restTaskModel = restClient.authenticateUser(userModel).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); + restTaskModel = restClient.authenticateUser(taskCreator).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); restClient.assertStatusCodeIs(HttpStatus.CONFLICT).assertLastError() .containsErrorKey(RestErrorModel.TASK_ALREADY_CLAIMED) .containsSummary(RestErrorModel.TASK_ALREADY_CLAIMED) @@ -135,18 +218,52 @@ public class UpdateTaskFullTestsBulk2 extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE); } - @Bug(id = "REPO-1924") @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from delegated to completed") + description = "Verify that task can be updated from delegated to claimed since it is already claimed by task assignee") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void userCanUpdateTaskFromDelegatedToCompleted() throws Exception + public void taskAssigneeCanUpdateTaskFromDelegatedToClaimed() throws Exception { JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); - restTaskModel = restClient.authenticateUser(userModel).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); restClient.assertStatusCodeIs(HttpStatus.OK); restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); - restTaskModel = restClient.authenticateUser(userModel).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); + } + + @Bug(id = "REPO-1924") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from delegated to completed by task creator") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + public void taskCreatorCanUpdateTaskFromDelegatedToCompleted() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); + + restTaskModel = restClient.authenticateUser(taskCreator).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() + .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .containsSummary(RestErrorModel.DELEGATED_TASK_CAN_NOT_BE_COMPLETED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Bug(id = "REPO-1924") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from delegated to completed by task assignee") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + public void taskAssigneeCanUpdateTaskFromDelegatedToCompleted() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); + + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) .containsSummary(RestErrorModel.DELEGATED_TASK_CAN_NOT_BE_COMPLETED) @@ -157,87 +274,156 @@ public class UpdateTaskFullTestsBulk2 extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify that task can be updated from delegated to resolved") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void userCanUpdateTaskFromDelegatedToResolved() throws Exception + public void taskCreatorCanUpdateTaskFromDelegatedToResolved() throws Exception { JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); - restTaskModel = restClient.authenticateUser(userModel).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); restClient.assertStatusCodeIs(HttpStatus.OK); restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); - restTaskModel = restClient.authenticateUser(userModel).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restTaskModel = restClient.authenticateUser(taskCreator).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("resolved"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from delegated to resolved by task assignee") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + public void taskAssigneeCanUpdateTaskFromDelegatedToResolved() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); + + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); restClient.assertStatusCodeIs(HttpStatus.OK); restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("resolved"); } @Bug(id = "REPO-1982") @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from resolved to unclaimed") + description = "Verify that task can be updated from resolved to unclaimed by task creator") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void userCanUpdateTaskFromResolvedToUnclaimed() throws Exception + public void taskCreatorCanUpdateTaskFromResolvedToUnclaimed() throws Exception { - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restTaskModel = restClient.authenticateUser(taskCreator).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restTaskModel = restClient.authenticateUser(userModel).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restTaskModel = restClient.authenticateUser(taskCreator).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); restClient.assertStatusCodeIs(HttpStatus.OK); restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("resolved"); } @Bug(id = "REPO-1982") @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task cannot be updated from resolved to claimed") + description = "Verify that task cannot be updated from resolved to unclaimed by task assignee") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void updateTaskFromResolvedToClaimed() throws Exception + public void taskAssigneeCannotUpdateTaskFromResolvedToUnclaimed() throws Exception { restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - // assignee tries to claim the task + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Bug(id = "REPO-1982") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task cannot be updated from resolved to claimed by task owner") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + public void taskOwnerCanUpdateTaskFromResolvedToClaimed() throws Exception + { + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + + restTaskModel = restClient.authenticateUser(taskCreator).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("resolved"); + } + + @Bug(id = "REPO-1982") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task cannot be updated from resolved to claimed by task assignee") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + public void taskAssigneeCanUpdateTaskFromResolvedToClaimed() throws Exception + { + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) .stackTraceIs(RestErrorModel.STACKTRACE); - - // owner tries to claim the task - restTaskModel = restClient.authenticateUser(userModel).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("resolved"); } @Bug(id = "REPO-1982") @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from resolved to delegated") + description = "Verify that task can be updated from resolved to delegated by task creator") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void userCannotUpdateTaskFromResolvedToDelegated() throws Exception + public void taskCreatorCannotUpdateTaskFromResolvedToDelegated() throws Exception { - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); - restTaskModel = restClient.authenticateUser(userModel).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restTaskModel = restClient.authenticateUser(taskCreator).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); restClient.assertStatusCodeIs(HttpStatus.OK); restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); } + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from resolved to delegated by task assignee") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + public void taskAssigneeCannotUpdateTaskFromResolvedToDelegated() throws Exception + { + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + + JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + @Bug(id = "REPO-1982") @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from resolved to resolved") + description = "Verify that task can be updated from resolved to resolved by task creator") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void userCannotUpdateTaskFromResolvedToResolved() throws Exception + public void taskCreatorCannotUpdateTaskFromResolvedToResolved() throws Exception { - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restTaskModel = restClient.authenticateUser(userModel).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restTaskModel = restClient.authenticateUser(taskCreator).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); restClient.assertStatusCodeIs(HttpStatus.OK); restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("resolved"); } + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from resolved to resolved by task assignee") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + public void taskAssigneeCannotUpdateTaskFromResolvedToResolved() throws Exception + { + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + @Bug(id = "REPO-1982") @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Update task by providing empty select value") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) public void updateTaskByProvidingEmptySelectValue() throws Exception { - restTaskModel = restClient.authenticateUser(userModel).withParams("select=").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restTaskModel = restClient.authenticateUser(taskCreator).withParams("select=").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() .containsErrorKey(RestErrorModel.INVALID_SELECT_ERRORKEY) .containsSummary(RestErrorModel.INVALID_SELECT) @@ -250,7 +436,7 @@ public class UpdateTaskFullTestsBulk2 extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) public void updateTaskByProvidingEmptyStateValue() throws Exception { - restTaskModel = restClient.authenticateUser(userModel).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask(" "); + restTaskModel = restClient.authenticateUser(taskCreator).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask(" "); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() .containsErrorKey(String.format(RestErrorModel.TASK_INVALID_STATE, " ")) .containsSummary(String.format(RestErrorModel.TASK_INVALID_STATE, " ")) From 25cc89214c296045183492cef2701f154e335369 Mon Sep 17 00:00:00 2001 From: Bogdan Bocancea Date: Tue, 7 Feb 2017 11:21:18 +0200 Subject: [PATCH 1025/1491] update deleteTaskItemTwice() --- .../alfresco/rest/workflow/tasks/RemoveTaskItemFullTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/RemoveTaskItemFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/RemoveTaskItemFullTests.java index c28acc196..f1b8b0ddd 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/RemoveTaskItemFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/RemoveTaskItemFullTests.java @@ -49,7 +49,7 @@ public class RemoveTaskItemFullTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")) + .assertLastError().containsSummary(String.format(RestErrorModel.PROCESS_ENTITY_NOT_FOUND, document2.getNodeRefWithoutVersion())) .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) .stackTraceIs(RestErrorModel.STACKTRACE); From 6427e0b72c624746d6282a93e8dcc7d5d3a28be5 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Tue, 7 Feb 2017 12:07:41 +0200 Subject: [PATCH 1026/1491] fix input data for all tests from DeleteProcessItemFullTests and some imports --- .../processes/DeleteProcessItemFullTests.java | 20 ++++++++++--------- .../processes/GetProcessTasksCoreTests.java | 6 +++--- .../GetProcessVariablesCoreTests.java | 1 - 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessItemFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessItemFullTests.java index 13f9acf76..bbf103914 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessItemFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessItemFullTests.java @@ -10,12 +10,14 @@ import org.alfresco.rest.model.RestItemModelsCollection; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.ProcessModel; import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TaskModel; 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.BeforeMethod; import org.testng.annotations.Test; public class DeleteProcessItemFullTests extends RestTest @@ -35,7 +37,15 @@ public class DeleteProcessItemFullTests extends RestTest assignee = dataUser.createRandomTestUser(); siteModel = dataSite.usingUser(userWhoStartsProcess).createPublicRandomSite(); document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); + } + + @BeforeMethod(alwaysRun = true) + public void createProcess() throws Exception + { + TaskModel task = dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); + processModel = new ProcessModel(); + processModel.setId(task.getProcessId()); + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().usingProcess(processModel).getProcess(); } @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, @@ -43,7 +53,6 @@ public class DeleteProcessItemFullTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) public void deleteProcessItemUsingEmptyProcessId() throws Exception { - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); document2 = dataContent.usingAdmin().usingSite(siteModel).createContent(DocumentType.MSPOWERPOINT); processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document2); restClient.assertStatusCodeIs(HttpStatus.CREATED); @@ -63,7 +72,6 @@ public class DeleteProcessItemFullTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) public void createUpdateDeleteProcessItem() throws Exception { - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); document2 = dataContent.usingAdmin().usingSite(siteModel).createContent(DocumentType.MSPOWERPOINT); processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document2); restClient.assertStatusCodeIs(HttpStatus.CREATED); @@ -84,7 +92,6 @@ public class DeleteProcessItemFullTests extends RestTest { anotherUser = dataUser.createRandomTestUser(); - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); document2 = dataContent.usingAdmin().usingSite(siteModel).createContent(DocumentType.HTML); processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document2); restClient.assertStatusCodeIs(HttpStatus.CREATED); @@ -104,7 +111,6 @@ public class DeleteProcessItemFullTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) public void deleteProcessItemWithAdmin() throws Exception { - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); document2 = dataContent.usingAdmin().usingSite(siteModel).createContent(DocumentType.HTML); processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document2); restClient.assertStatusCodeIs(HttpStatus.CREATED); @@ -121,7 +127,6 @@ public class DeleteProcessItemFullTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) public void deleteProcessItemByUserInvolvedInTheProcess() throws Exception { - processModel = restClient.authenticateUser(assignee).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); restClient.assertStatusCodeIs(HttpStatus.CREATED); @@ -137,7 +142,6 @@ public class DeleteProcessItemFullTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) public void deleteProcessItemByUserThatStartedTheProcess() throws Exception { - processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); restClient.assertStatusCodeIs(HttpStatus.CREATED); @@ -153,7 +157,6 @@ public class DeleteProcessItemFullTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) public void deleteProcessItemsForDeletedProcess() throws Exception { - processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); restClient.assertStatusCodeIs(HttpStatus.CREATED); @@ -175,7 +178,6 @@ public class DeleteProcessItemFullTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) public void deleteProcessItemByInexistentUser() throws Exception { - processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); restClient.assertStatusCodeIs(HttpStatus.CREATED); diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksCoreTests.java index 60d47b888..0b8e057d7 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksCoreTests.java @@ -19,7 +19,7 @@ import org.testng.annotations.Test; public class GetProcessTasksCoreTests extends RestTest { - private FileModel document, document1, document2, document3; + private FileModel document, document1, document2; private SiteModel siteModel; private UserModel adminUser, userWhoStartsProcess, candidate, anotherAssignee, assignee; private ProcessModel process; @@ -66,7 +66,7 @@ public class GetProcessTasksCoreTests extends RestTest restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenant); SiteModel siteModel = dataSite.usingUser(adminTenant).createPublicRandomSite(); UserModel tenantAssignee = dataUser.usingUser(adminTenant).createUserWithTenant("uTenant"); - document3 = dataContent.usingUser(adminTenant).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + dataContent.usingUser(adminTenant).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); RestProcessModel processModel = restClient.authenticateUser(tenantAssignee).withWorkflowAPI().addProcess("activitiAdhoc", tenantAssignee, false, CMISUtil.Priority.Normal); @@ -86,7 +86,7 @@ public class GetProcessTasksCoreTests extends RestTest restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenant); SiteModel siteModel = dataSite.usingUser(adminTenant).createPublicRandomSite(); - document3 = dataContent.usingUser(adminTenant).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + dataContent.usingUser(adminTenant).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); tenantAssignee = dataUser.usingUser(adminTenant).createUserWithTenant("uTenant"); RestProcessModel processModel = restClient.authenticateUser(adminTenant).withWorkflowAPI().addProcess("activitiAdhoc", tenantAssignee, false, CMISUtil.Priority.Normal); diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesCoreTests.java index 9ca8d14df..b87a570e8 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesCoreTests.java @@ -4,7 +4,6 @@ import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.CMISUtil.Priority; import org.alfresco.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.rest.model.RestProcessModelsCollection; From a5440896f92fc71d7fde320370e4f737aa2114f0 Mon Sep 17 00:00:00 2001 From: cagache Date: Tue, 7 Feb 2017 13:37:38 +0200 Subject: [PATCH 1027/1491] fix getSites tests for 5.1 (cherry picked from commit 3d4f780) --- .../rest/sites/GetSitesFullTests.java | 40 +++++++++---------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSitesFullTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSitesFullTests.java index 57908f353..26344a547 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSitesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSitesFullTests.java @@ -1,18 +1,14 @@ package org.alfresco.rest.sites; -import java.util.List; import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestSiteContainerModelsCollection; -import org.alfresco.rest.model.RestSiteMemberModelsCollection; -import org.alfresco.rest.model.RestSiteModel; -import org.alfresco.rest.model.RestSiteModelsCollection; +import org.alfresco.rest.model.*; import org.alfresco.utility.constants.ContainerName; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.RandomData; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -21,6 +17,8 @@ import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import java.util.List; + public class GetSitesFullTests extends RestTest { private UserModel regularUser; @@ -28,8 +26,6 @@ public class GetSitesFullTests extends RestTest private RestSiteModelsCollection sites; private String name; private UserModel adminUser; - private int maxItems = 200; - private int skipCount = 10; @BeforeClass(alwaysRun=true) public void dataPreparation() throws Exception @@ -84,14 +80,12 @@ public class GetSitesFullTests extends RestTest public void checkPagination() throws Exception { sites = restClient.authenticateUser(regularUser).withCoreAPI().getSites(); - int totalItems = sites.getPagination().getTotalItems(); - int maxItems = 100; sites.getPagination().assertThat() .field("totalItems").isNotEmpty().and() - .field("maxItems").is(String.valueOf(maxItems)).and() - .field("hasMoreItems").is((totalItems>maxItems) ? true : false).and() + .field("maxItems").is("100").and() + .field("hasMoreItems").is((sites.getPagination().getTotalItems() > sites.getPagination().getMaxItems()) ? "true" : "false").and() .field("skipCount").is("0").and() - .field("count").is(String.valueOf((maxItems>totalItems) ? totalItems - skipCount : maxItems)); + .field("count").is((sites.getPagination().isHasMoreItems()) ? sites.getPagination().getMaxItems() : sites.getPagination().getTotalItems()); } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) @@ -111,10 +105,14 @@ public class GetSitesFullTests extends RestTest description= "Verify user can get sites using high skipCount parameter and status code is 200") public void getSitesUsingHighSkipCount() throws Exception { - sites = restClient.authenticateUser(regularUser).withParams("skipCount=100").withCoreAPI().getSites(); + RestSiteModelsCollection allSites = restClient.authenticateUser(regularUser).withCoreAPI().getSites(); + sites = restClient.withParams("skipCount=100").withCoreAPI().getSites(); restClient.assertStatusCodeIs(HttpStatus.OK); sites.assertThat().paginationField("skipCount").is("100"); - sites.assertThat().entriesListIsNotEmpty(); + if(allSites.getPagination().getTotalItems() > 100) + sites.assertThat().entriesListIsNotEmpty(); + else + sites.assertThat().entriesListIsEmpty(); } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) @@ -150,14 +148,14 @@ public class GetSitesFullTests extends RestTest description= "Verify pagination when skipCount and MaxItems are used") public void checkPaginationWithSkipCountAndMaxItems() throws Exception { - sites = restClient.authenticateUser(regularUser).withParams(String.format("skipCount=%s&maxItems=%s", skipCount, maxItems)).withCoreAPI().getSites(); - int totalItems = sites.getPagination().getTotalItems(); + sites = restClient.authenticateUser(regularUser).withParams("skipCount=10&maxItems=110").withCoreAPI().getSites(); sites.getPagination().assertThat() .field("totalItems").isNotEmpty().and() - .field("maxItems").is(String.valueOf(maxItems)).and() - .field("hasMoreItems").is((totalItems>maxItems) ? true : false).and() - .field("skipCount").is(String.valueOf(skipCount)).and() - .field("count").is(String.valueOf((maxItems>totalItems) ? totalItems - skipCount : maxItems)); + .field("maxItems").is("110").and() + .field("hasMoreItems").is((sites.getPagination().getTotalItems() > sites.getPagination().getMaxItems())?"true":"false").and() + .field("skipCount").is("10").and() + .field("count").is((sites.getPagination().isHasMoreItems()) ? sites.getPagination().getMaxItems() + : sites.getPagination().getTotalItems() - sites.getPagination().getSkipCount()); } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) From 4e88729c217cea31fec7181bb386c71bc0506c30 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Tue, 7 Feb 2017 14:46:10 +0200 Subject: [PATCH 1028/1491] fixed unused imports removed --- .../org/alfresco/rest/sites/GetSitesFullTests.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSitesFullTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSitesFullTests.java index 26344a547..cd787aa03 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSitesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSitesFullTests.java @@ -1,14 +1,19 @@ package org.alfresco.rest.sites; +import java.util.List; + import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.*; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestSiteContainerModelsCollection; +import org.alfresco.rest.model.RestSiteMemberModelsCollection; +import org.alfresco.rest.model.RestSiteModel; +import org.alfresco.rest.model.RestSiteModelsCollection; import org.alfresco.utility.constants.ContainerName; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.RandomData; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -17,8 +22,6 @@ import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import java.util.List; - public class GetSitesFullTests extends RestTest { private UserModel regularUser; From 7de693b069be61323a67799e35c0a8bb36f7cbd8 Mon Sep 17 00:00:00 2001 From: Bogdan Bocancea Date: Tue, 7 Feb 2017 15:01:36 +0200 Subject: [PATCH 1029/1491] TAS-2936: add full tests for 'get /tasks/{taskId}/candidates' --- .../tasks/GetTaskCandidatesFullTests.java | 215 ++++++++++++++++++ 1 file changed, 215 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCandidatesFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCandidatesFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCandidatesFullTests.java new file mode 100644 index 000000000..a2b8b1d4c --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCandidatesFullTests.java @@ -0,0 +1,215 @@ +package org.alfresco.rest.workflow.tasks; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestCandidateModelsCollection; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.GroupModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TaskModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * + * @author bogdan.bocancea + * + */ +public class GetTaskCandidatesFullTests extends RestTest +{ + private UserModel userModel, userModel1, userModel2; + private SiteModel siteModel; + private FileModel fileModel; + private TaskModel taskModel; + private GroupModel group; + private RestCandidateModelsCollection candidateModels; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + userModel1 = dataUser.createRandomTestUser(); + userModel2 = dataUser.createRandomTestUser(); + group = dataGroup.createRandomGroup(); + dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); + } + + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Check default error model schema for get task candidates") + public void getTaskCandidatesErrorSchemaCheck() throws Exception + { + taskModel = dataWorkflow.usingUser(userModel) + .usingSite(siteModel) + .usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); + taskModel.setId("invalid-id"); + restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).getTaskCandidates(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalid-id")) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } + + @Bug(id="MNT-17438") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Get task candidates with skip count parameter") + public void getTaskCandidatesWithSkipCount() throws Exception + { + taskModel = dataWorkflow.usingUser(userModel) + .usingSite(siteModel) + .usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); + candidateModels = restClient.authenticateUser(userModel).withWorkflowAPI() + .usingParams("skipCount=1").usingTask(taskModel).getTaskCandidates(); + restClient.assertStatusCodeIs(HttpStatus.OK); + candidateModels.assertThat() + .entriesListIsNotEmpty() + .and().paginationField("count").is("0"); + } + + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Get task candidates with max items parameter set to 0") + public void getTaskCandidatesWithZeroMaxItems() throws Exception + { + taskModel = dataWorkflow.usingUser(userModel) + .usingSite(siteModel) + .usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); + candidateModels = restClient.authenticateUser(userModel).withWorkflowAPI() + .usingParams("maxItems=0").usingTask(taskModel).getTaskCandidates(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsErrorKey(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) + .containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } + + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Get task candidates with max items parameter") + public void getTaskCandidatesWithMaxItems() throws Exception + { + taskModel = dataWorkflow.usingUser(userModel) + .usingSite(siteModel) + .usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); + candidateModels = restClient.authenticateUser(userModel).withWorkflowAPI() + .usingParams("maxItems=2").usingTask(taskModel).getTaskCandidates(); + restClient.assertStatusCodeIs(HttpStatus.OK); + candidateModels.assertThat() + .entriesListIsNotEmpty() + .and().paginationField("count").is("1"); + } + + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Get task candidates with properties") + public void getTaskCandidatesWithProperties() throws Exception + { + taskModel = dataWorkflow.usingUser(userModel) + .usingSite(siteModel) + .usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); + candidateModels = restClient.authenticateUser(userModel).withWorkflowAPI() + .usingParams("properties=candidateId").usingTask(taskModel).getTaskCandidates(); + restClient.assertStatusCodeIs(HttpStatus.OK); + candidateModels.getEntries().get(0).onModel().assertThat() + .field("candidateId").contains(group.getGroupIdentifier()).and() + .field("candidateType").isNull(); + } + + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Get task candidates with invalid properties") + public void getTaskCandidatesWithInvalidProperties() throws Exception + { + taskModel = dataWorkflow.usingUser(userModel) + .usingSite(siteModel) + .usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); + candidateModels = restClient.authenticateUser(userModel).withWorkflowAPI() + .usingParams("properties=unknown-prop").usingTask(taskModel).getTaskCandidates(); + restClient.assertStatusCodeIs(HttpStatus.OK); + candidateModels.getEntries().get(0).onModel().assertThat() + .fieldsCount().is(0).and(); + } + + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Get task candidates by deleted candidate") + public void getTaskCandidatesByDeletedCandidate() throws Exception + { + taskModel = dataWorkflow.usingUser(userModel) + .usingSite(siteModel) + .usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); + restClient.authenticateUser(userModel1).withWorkflowAPI() + .usingTask(taskModel).getTaskCandidates(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + dataUser.usingAdmin().deleteUser(userModel1); + + restClient.authenticateUser(userModel1).withWorkflowAPI() + .usingTask(taskModel).getTaskCandidates(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError().containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } + + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Get task candidates by deleted group") + public void getTaskCandidatesByDeletedGroup() throws Exception + { + GroupModel deletedGroup = dataGroup.createRandomGroup(); + UserModel newUser = dataUser.createRandomTestUser(); + dataGroup.addListOfUsersToGroup(deletedGroup, userModel2, newUser); + taskModel = dataWorkflow.usingUser(userModel) + .usingSite(siteModel) + .usingResource(fileModel).createPooledReviewTaskAndAssignTo(deletedGroup); + restClient.authenticateUser(newUser).withWorkflowAPI() + .usingTask(taskModel).getTaskCandidates(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + dataGroup.usingAdmin().deleteGroup(deletedGroup); + + restClient.authenticateUser(newUser).withWorkflowAPI() + .usingTask(taskModel).getTaskCandidates(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Get task candidates by user that was removed from group") + public void getTaskCandidatesByUserRemovedFromGroup() throws Exception + { + UserModel newUser = dataUser.createRandomTestUser(); + dataGroup.addListOfUsersToGroup(group, newUser); + taskModel = dataWorkflow.usingUser(userModel) + .usingSite(siteModel) + .usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); + restClient.authenticateUser(newUser).withWorkflowAPI() + .usingTask(taskModel).getTaskCandidates(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + dataGroup.usingAdmin().removeUserFromGroup(group, newUser); + + restClient.authenticateUser(newUser).withWorkflowAPI() + .usingTask(taskModel).getTaskCandidates(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .stackTraceIs(RestErrorModel.STACKTRACE); + } +} \ No newline at end of file From 3d3678ca422a316b584cab8aa1a1fb2ac1182512 Mon Sep 17 00:00:00 2001 From: mionescu Date: Wed, 8 Feb 2017 10:47:38 +0200 Subject: [PATCH 1030/1491] test - added new testcases --- .../AddProcessVariablesCoreTests.java | 74 +++-- .../AddProcessVariablesFullTests.java | 278 ++++++++++++++---- .../AddProcessVariablesSanityTests.java | 43 ++- 3 files changed, 298 insertions(+), 97 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesCoreTests.java index 7d8b0330a..8a4b62c6e 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesCoreTests.java @@ -4,6 +4,7 @@ import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestProcessVariableCollection; import org.alfresco.rest.model.RestProcessVariableModel; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; @@ -19,9 +20,10 @@ public class AddProcessVariablesCoreTests extends RestTest { private FileModel document; private SiteModel siteModel; - private UserModel userWhoStartsProcess, assignee, adminUser, adminTenantUser, secondAdminTenantUser, tenantUser; + private UserModel userWhoStartsProcess, assignee, adminUser; private RestProcessModel processModel; - private RestProcessVariableModel variableModel, processVariable; + private RestProcessVariableModel variableModel, processVariable, variableModel1; + private RestProcessVariableCollection processVariableCollection; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception @@ -32,34 +34,12 @@ public class AddProcessVariablesCoreTests extends RestTest siteModel = dataSite.usingUser(userWhoStartsProcess).createPublicRandomSite(); document = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify addProcessVariable by admin in other network with REST API and status code is FORBIDDEN (403)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE, TestGroup.NETWORKS }) - public void addProcessVariablesByAdminInOtherNetworkIsForbidden() throws Exception - { - adminTenantUser = UserModel.getAdminTenantUser(); - secondAdminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser); - restClient.authenticateUser(adminUser).usingTenant().createTenant(secondAdminTenantUser); - tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - - restClient.authenticateUser(adminTenantUser).withWorkflowAPI() - .addProcess("activitiAdhoc", tenantUser, false, CMISUtil.Priority.Normal); - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - - restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().usingProcess(processModel) - .addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT); - } + } @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify addProcessVariable by any user with REST API and status code is CREATED (201)") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) - public void addProcessVariablesByAnyUser() throws Exception + public void addProcessVariableByAnyUser() throws Exception { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); @@ -78,7 +58,7 @@ public class AddProcessVariablesCoreTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify addProcessVariable by any user for invalid processID with REST API and status code is NOT_FOUND (404)") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) - public void addProcessVariablesForInvalidProcessIdIsNotFound() throws Exception + public void addProcessVariableForInvalidProcessIdIsNotFound() throws Exception { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); @@ -93,7 +73,7 @@ public class AddProcessVariablesCoreTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify addProcessVariable by any user for empty processID with REST API and status code is NOT_FOUND (404)") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) - public void addProcessVariablesForInvalidProcessIdIsEmpty() throws Exception + public void addProcessVariableForInvalidProcessIdIsEmpty() throws Exception { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); @@ -107,7 +87,7 @@ public class AddProcessVariablesCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add process variables using by the user who started the process.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) - public void addProcessVariablesByUserThatStartedTheProcess() throws Exception + public void addProcessVariableByUserThatStartedTheProcess() throws Exception { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); @@ -121,6 +101,40 @@ public class AddProcessVariablesCoreTests extends RestTest restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() .assertThat().entriesListContains("name", processVariable.getName()); - } + } + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding multiple process variables is falling in case invalid process id is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void addMultipleProcessVariablesInvalidProcessId() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:int"); + variableModel1 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processModel.setId("invalidProcessID"); + + processVariableCollection = restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(processModel) + .addProcessVariables(variableModel1, variableModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidProcessID")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding multiple process variables is falling in case empty process id is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void addMultipleProcessVariablesEmptyProcessId() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:int"); + variableModel1 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processModel.setId(""); + + processVariableCollection = restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(processModel) + .addProcessVariables(variableModel1, variableModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); + } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesFullTests.java index e4cb13768..d2e6de34d 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesFullTests.java @@ -1,13 +1,14 @@ package org.alfresco.rest.workflow.processes; import org.alfresco.dataprep.CMISUtil; -import org.alfresco.dataprep.CMISUtil.Priority; import org.alfresco.rest.RestTest; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestProcessVariableCollection; import org.alfresco.rest.model.RestProcessVariableModel; import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.ProcessModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; @@ -24,8 +25,10 @@ public class AddProcessVariablesFullTests extends RestTest private FileModel document; private SiteModel siteModel; private UserModel userWhoStartsProcess, assignee, adminUser, adminTenantUser, adminTenantUser2, tenantUser, tenantUserAssignee; - private RestProcessModel processModel; - private RestProcessVariableModel variableModel, processVariable; + private ProcessModel processModel; + private RestProcessModel restProcessModel; + private RestProcessVariableModel variableModel, processVariable, variableModel1, variableModel2, variableModel3; + private RestProcessVariableCollection processVariableCollection; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception @@ -35,39 +38,41 @@ public class AddProcessVariablesFullTests extends RestTest assignee = dataUser.createRandomTestUser(); siteModel = dataSite.usingUser(userWhoStartsProcess).createPublicRandomSite(); document = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); - } + processModel = dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document).createSingleReviewerTaskAndAssignTo(assignee); + } @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add process variables using by the user involved in the process.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) - public void addProcessVariablesByUserInvolvedTheProcess() throws Exception + public void addProcessVariableByUserInvolvedTheProcess() throws Exception { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(assignee).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - - processVariable = restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(processModel) + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + restProcessModel = restClient.authenticateUser(assignee).withWorkflowAPI().getProcesses() + .getProcessModelByProcessDefId(processModel.getId()); + + processVariable = restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(restProcessModel) .addProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); processVariable.assertThat().field("name").is(processVariable.getName()) .and().field("type").is(processVariable.getType()) .and().field("value").is(processVariable.getValue()); - restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() + restClient.withWorkflowAPI().usingProcess(restProcessModel).getProcessVariables() .assertThat().entriesListContains("name", processVariable.getName()); } @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add process variables using by inexistent user.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) - public void addProcessVariablesByInexistentUser() throws Exception + public void addProcessVariableByInexistentUser() throws Exception { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - - processVariable = restClient.authenticateUser(UserModel.getRandomUserModel()).withWorkflowAPI().usingProcess(processModel) - .addProcessVariable(variableModel); + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + restProcessModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses() + .getProcessModelByProcessDefId(processModel.getId()); + processVariable = restClient.authenticateUser(UserModel.getRandomUserModel()).withWorkflowAPI() + .usingProcess(restProcessModel) + .addProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) .assertLastError() .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) @@ -79,13 +84,13 @@ public class AddProcessVariablesFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process variables is falling in case invalid type is provided") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) - public void failedAddingProcessVariablesIfInvalidTypeIsProvided() throws Exception + public void failedAddingProcessVariableIfInvalidTypeIsProvided() throws Exception { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:textarea"); - - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); - + restProcessModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses() + .getProcessModelByProcessDefId(processModel.getId()); + + restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) .assertLastError().containsSummary( String.format(RestErrorModel.UNSUPPORTED_TYPE, "d:textarea")) @@ -98,13 +103,13 @@ public class AddProcessVariablesFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process variables is falling in case invalid type prefix is provided") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) - public void failedAddingProcessVariablesIfInvalidTypePrefixIsProvided() throws Exception + public void failedAddingProcessVariableIfInvalidTypePrefixIsProvided() throws Exception { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("ddt:text"); - - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); - + restProcessModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses() + .getProcessModelByProcessDefId(processModel.getId()); + + restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) .assertLastError() .containsSummary(String.format(RestErrorModel.INVALID_NAMEPACE_PREFIX, "ddt")) @@ -116,14 +121,14 @@ public class AddProcessVariablesFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process variables is falling in case invalid value is provided") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) - public void failedAddingProcessVariablesIfInvalidValueIsProvided() throws Exception + public void failedAddingProcessVariableIfInvalidValueIsProvided() throws Exception { RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:int"); variableModel.setValue("invalidValue"); - - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); - + restProcessModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses() + .getProcessModelByProcessDefId(processModel.getId()); + + restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) .assertLastError() .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) @@ -135,14 +140,14 @@ public class AddProcessVariablesFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process variables is falling in case invalid variableBody (adding extra parameter in body:scope) is provided") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) - public void failedAddingProcessVariablesIfInvalidBodyIsProvided() throws Exception + public void failedAddingProcessVariableIfInvalidBodyIsProvided() throws Exception { - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + restProcessModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses() + .getProcessModelByProcessDefId(processModel.getId()); RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{\"name\": \"variableName\",\"scope\": \"local\",\"value\": \"testing\",\"type\": \"d:text\"}", "processes/{processId}/variables", processModel.getId()); - restClient.processModel(RestProcessVariableModel.class, request); - + restClient.processModel(RestProcessVariableModel.class, request); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) .assertLastError() .containsSummary(String.format(RestErrorModel.NO_CONTENT, "Unrecognized field \"scope\"")) @@ -151,19 +156,18 @@ public class AddProcessVariablesFullTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE); } - @Bug(id="REPO-1985") + //@Bug(id="REPO-1985") @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process variables is falling in case empty name is provided") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) - public void failedAddingProcessVariablesIfEmptyNameIsProvided() throws Exception - { - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); + public void failedAddingProcessVariableIfEmptyNameIsProvided() throws Exception + { + restProcessModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses() + .getProcessModelByProcessDefId(processModel.getId()); RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - variableModel.setName(""); - - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); - + variableModel.setName(""); + + restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) .assertLastError() .containsSummary(RestErrorModel.VARIABLE_NAME_REQUIRED) @@ -172,25 +176,24 @@ public class AddProcessVariablesFullTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE); } - @Bug(id="REPO-1985") + //@Bug(id="REPO-1985") @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process variables is falling in case invalid name is provided: ony white spaces") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) - public void failedAddingProcessVariablesUsingOnlyWhiteSpaceInName() throws Exception + public void failedAddingProcessVariableUsingOnlyWhiteSpaceInName() throws Exception { - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); - RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + restProcessModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses() + .getProcessModelByProcessDefId(processModel.getId()); + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); variableModel.setName(" "); - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - processVariable = restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); - + processVariable = restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); processVariable.assertThat().field("name").isNull() .and().field("type").is(processVariable.getType()) .and().field("value").is(processVariable.getValue()); - restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() + restClient.withWorkflowAPI().usingProcess(restProcessModel).getProcessVariables() .assertThat().entriesListContains("value", processVariable.getValue()); } @@ -198,23 +201,143 @@ public class AddProcessVariablesFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process variables is falling in case invalid name is provided: symbols") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) - public void addingProcessVariablesUsingSymbolsInName() throws Exception + public void failedAddingProcessVariableWithSymbolsInName() throws Exception { - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); + restProcessModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses() + .getProcessModelByProcessDefId(processModel.getId()); variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - variableModel.setName("123_%^&: õÈ,Ì,Ò"); - - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - processVariable = restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); - + variableModel.setName("123_%^&: õÈ,Ì,Ò"); + + processVariable = restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); processVariable.assertThat().field("name").is(processVariable.getName()) .and().field("type").is(processVariable.getType()) .and().field("value").is(processVariable.getValue()); - restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() + restClient.withWorkflowAPI().usingProcess(restProcessModel).getProcessVariables() .assertThat().entriesListContains("name", processVariable.getName()); - } + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Add two process variables using by the user involved in the process.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void addingMultipleValidProcessVariables() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + variableModel2 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + variableModel3 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + restProcessModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses() + .getProcessModelByProcessDefId(processModel.getId()); + + processVariableCollection = restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(restProcessModel) + .addProcessVariables(variableModel, variableModel2, variableModel3); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + processVariableCollection.assertThat().entriesListContains("name", variableModel.getName()) + .assertThat().entriesListContains("name", variableModel2.getName()) + .assertThat().entriesListContains("name", variableModel3.getName()); + + processVariableCollection.getEntries().get(0).onModel().assertThat() + .field("name").is(variableModel.getName()).and() + .field("value").is(variableModel.getValue()).and() + .field("type").is(variableModel.getType()); + processVariableCollection.getEntries().get(1).onModel().assertThat() + .field("name").is(variableModel2.getName()).and() + .field("value").is(variableModel2.getValue()).and() + .field("type").is(variableModel2.getType()); + processVariableCollection.getEntries().get(2).onModel().assertThat() + .field("name").is(variableModel3.getName()).and() + .field("value").is(variableModel3.getValue()).and() + .field("type").is(variableModel3.getType()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Add two process variables using by the user involved in the process.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void failedAddingMultipleProcessVariablesInvalidType() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + variableModel.setType("d:string"); + variableModel2 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + restProcessModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses() + .getProcessModelByProcessDefId(processModel.getId()); + + processVariableCollection = restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(restProcessModel) + .addProcessVariables(variableModel, variableModel2); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.UNSUPPORTED_TYPE, "d:string")) + .containsErrorKey(String.format(RestErrorModel.UNSUPPORTED_TYPE, "d:string")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Bug(id = "REPO-1938") + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Add two process variables using by the user involved in the process.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void failledAddingMultipleProcessVariablesInvalidTypePrefix() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + variableModel.setType("e:text"); + variableModel2 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + restProcessModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses() + .getProcessModelByProcessDefId(processModel.getId()); + + processVariableCollection = restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(restProcessModel) + .addProcessVariables(variableModel, variableModel2); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsSummary(String.format(RestErrorModel.INVALID_NAMEPACE_PREFIX, "e")) + .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding process variables is falling in case invalid value is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void failledAddingMultipleProcessVariablesInvalidValue() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:int"); + variableModel.setValue("invalidValue"); + variableModel1 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + variableModel2 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + restProcessModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses() + .getProcessModelByProcessDefId(processModel.getId()); + + processVariableCollection = restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(restProcessModel) + .addProcessVariables(variableModel, variableModel1, variableModel2); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .containsSummary(String.format(RestErrorModel.FOR_INPUT_STRING, "invalidValue")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding process variables is falling in case invalid value is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void failledAddingMultipleInvalidProcessVariables() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:int"); + variableModel.setValue("invalidValue"); + variableModel1 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + variableModel1.setType(""); + restProcessModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses() + .getProcessModelByProcessDefId(processModel.getId()); + + processVariableCollection = restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(restProcessModel) + .addProcessVariables(variableModel1, variableModel); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .containsSummary(String.format(RestErrorModel.FOR_INPUT_STRING, "invalidValue")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, description = "Add process variables using by Admin in other network.") @@ -245,5 +368,36 @@ public class AddProcessVariablesFullTests extends RestTest .containsErrorKey(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT) .stackTraceIs(RestErrorModel.STACKTRACE); } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Add multiple process variables using by Admin in other network.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL, TestGroup.NETWORKS }) + public void addMultipleProcessVariablesByAdminInOtherNetwork() throws Exception + { + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser); + tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); + tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + + adminTenantUser2 = UserModel.getAdminTenantUser(); + restClient.usingTenant().createTenant(adminTenantUser2); + + siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); + dataWorkflow.usingUser(tenantUser).usingSite(siteModel).usingResource(document) + .createNewTaskAndAssignTo(tenantUserAssignee); + + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + variableModel1 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + restClient.authenticateUser(adminTenantUser2).withWorkflowAPI().usingProcess(processModel) + .addProcessVariables(variableModel, variableModel1); + + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError() + .containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .containsErrorKey(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT) + .stackTraceIs(RestErrorModel.STACKTRACE); + } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesSanityTests.java index 9a8e99e57..2c97af9d8 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesSanityTests.java @@ -4,6 +4,7 @@ import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.CMISUtil.Priority; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestProcessVariableCollection; import org.alfresco.rest.model.RestProcessVariableModel; import org.alfresco.utility.data.RandomData; import org.alfresco.utility.model.FileModel; @@ -22,7 +23,8 @@ public class AddProcessVariablesSanityTests extends RestTest private SiteModel siteModel; private UserModel userWhoStartsProcess, assignee, adminUser, adminTenantUser, tenantUserAssignee, tenantUser; private RestProcessModel processModel; - private RestProcessVariableModel variableModel, processVariable; + private RestProcessVariableModel variableModel, variableModel1, processVariable; + private RestProcessVariableCollection processVariableCollection; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception @@ -38,7 +40,7 @@ public class AddProcessVariablesSanityTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Create non-existing variable") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) - public void addProcessVariables() throws Exception + public void addProcessVariable() throws Exception { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); @@ -56,7 +58,7 @@ public class AddProcessVariablesSanityTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Update existing variables") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) - public void updateExistingProcessVariables() throws Exception + public void updateExistingProcessVariable() throws Exception { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); @@ -77,7 +79,7 @@ public class AddProcessVariablesSanityTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Adding process variables is falling in case invalid variableBody is provided") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) - public void failedAddingProcessVariablesIfInvalidBodyIsProvided() throws Exception + public void failedAddingProcessVariableIfInvalidBodyIsProvided() throws Exception { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("incorrect type"); processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); @@ -90,7 +92,7 @@ public class AddProcessVariablesSanityTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Add process variables using admin user from same network") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY, TestGroup.NETWORKS }) - public void addProcessVariablesByAdminSameNetwork() throws Exception + public void addProcessVariableByAdminSameNetwork() throws Exception { adminTenantUser = UserModel.getAdminTenantUser(); restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser); @@ -107,5 +109,36 @@ public class AddProcessVariablesSanityTests extends RestTest .and().field("type").is(processVariable.getType()) .and().field("value").is(processVariable.getValue()); } + + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Add multiple process variables using admin user from same network") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY, TestGroup.NETWORKS }) + public void addMultipleProcessVariablesByAdminSameNetwork() throws Exception + { + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser); + tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); + + restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee, false, Priority.Normal); + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + variableModel1 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + + processVariableCollection = restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariables(variableModel, variableModel1); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + processVariableCollection.assertThat().entriesListContains("name", variableModel.getName()) + .assertThat().entriesListContains("name", variableModel1.getName()); + + processVariableCollection.getEntries().get(0).onModel().assertThat() + .field("name").is(variableModel.getName()).and() + .field("value").is(variableModel.getValue()).and() + .field("type").is(variableModel.getType()); + processVariableCollection.getEntries().get(1).onModel().assertThat() + .field("name").is(variableModel1.getName()).and() + .field("value").is(variableModel1.getValue()).and() + .field("type").is(variableModel1.getType()); + } } From 114440e463423701e7bd539cf3efda4598b5e144 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Wed, 8 Feb 2017 11:18:00 +0200 Subject: [PATCH 1031/1491] renamed as class contains full tests too --- ...loymentCoreTests.java => DeleteDeploymentCoreFullTests.java} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename e2e-test/java/org/alfresco/rest/workflow/deployments/{DeleteDeploymentCoreTests.java => DeleteDeploymentCoreFullTests.java} (97%) diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentCoreFullTests.java similarity index 97% rename from e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentCoreTests.java rename to e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentCoreFullTests.java index af521d2f6..b389c17ea 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentCoreFullTests.java @@ -12,7 +12,7 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -public class DeleteDeploymentCoreTests extends RestTest +public class DeleteDeploymentCoreFullTests extends RestTest { private UserModel adminUser; private UserModel userModel; From 66cc5e3a6c51c35b757848515d5e96bab690e5e1 Mon Sep 17 00:00:00 2001 From: mionescu Date: Wed, 8 Feb 2017 11:55:10 +0200 Subject: [PATCH 1032/1491] test- added test cases: multiple items --- .../processes/AddProcessItemCoreTests.java | 121 +++++++++++++++++- .../processes/AddProcessItemFullTests.java | 119 +++++++++++++++++ .../AddProcessVariablesCoreTests.java | 6 +- 3 files changed, 236 insertions(+), 10 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemCoreTests.java index e33414d2c..2a8b12e53 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemCoreTests.java @@ -6,6 +6,7 @@ import org.alfresco.rest.RestTest; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestItemModel; +import org.alfresco.rest.model.RestItemModelsCollection; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.rest.model.RestProcessModelsCollection; import org.alfresco.utility.model.FileModel; @@ -27,6 +28,7 @@ public class AddProcessItemCoreTests extends RestTest private UserModel userWhoStartsProcess, assignee, adminUser, anotherUser, adminTenantUser, tenantUserAssignee, adminTenantUser2, tenantUser; private RestProcessModel processModel; private RestItemModel processItem; + private RestItemModelsCollection processItems; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception @@ -36,6 +38,7 @@ public class AddProcessItemCoreTests extends RestTest assignee = dataUser.createRandomTestUser(); siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + document2 = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); } @@ -52,6 +55,35 @@ public class AddProcessItemCoreTests extends RestTest .field("modifiedAt").isNotEmpty().and().field("name").is(document.getName()).and().field("modifiedBy").is(userWhoStartsProcess.getUsername()) .and().field("id").isNotEmpty().and().field("mimeType").is(document.getFileType().mimeType); } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Add multiple process items using by the user who started the process.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + public void addMultipleProcessItemsByUserThatStartedTheProcess() throws Exception + { + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processItems = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItems(document, document2); + + restClient.assertStatusCodeIs(HttpStatus.CREATED); + processItems.getEntries().get(0).onModel().assertThat() + .field("createdAt").isNotEmpty().and() + .field("size").is("19").and() + .field("createdBy").is(adminUser.getUsername()).and() + .field("modifiedAt").isNotEmpty().and() + .field("name").is(document.getName()).and() + .field("modifiedBy").is(userWhoStartsProcess.getUsername()).and() + .field("id").isNotEmpty().and() + .field("mimeType").is(document.getFileType().mimeType); + processItems.getEntries().get(1).onModel().assertThat() + .field("createdAt").isNotEmpty().and() + .field("size").is("19").and() + .field("createdBy").is(adminUser.getUsername()).and() + .field("modifiedAt").isNotEmpty().and() + .field("name").is(document2.getName()).and() + .field("modifiedBy").is(userWhoStartsProcess.getUsername()).and() + .field("id").isNotEmpty().and() + .field("mimeType").is(document2.getFileType().mimeType); + } @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add process item by a random user.") @@ -91,6 +123,45 @@ public class AddProcessItemCoreTests extends RestTest .field("modifiedAt").isNotEmpty().and().field("name").is(document.getName()).and().field("modifiedBy").is(adminUser.getUsername()).and() .field("id").isNotEmpty().and().field("mimeType").is(document.getFileType().mimeType); } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Add multiple process items using by the admin in same network.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE, TestGroup.NETWORKS }) + public void addMultipleProcessItemsByAdminSameNetwork() throws Exception + { + restClient.authenticateUser(adminUser); + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.usingTenant().createTenant(adminTenantUser); + + tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); + + siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); + dataWorkflow.usingUser(tenantUser).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(tenantUserAssignee); + + processModel = restClient.withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processItems = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItems(document, document2); + + restClient.assertStatusCodeIs(HttpStatus.CREATED); + processItems.getEntries().get(0).onModel().assertThat() + .field("createdAt").isNotEmpty().and() + .field("size").is("19").and() + .field("createdBy").is(adminUser.getUsername()).and() + .field("modifiedAt").isNotEmpty().and() + .field("name").is(document.getName()).and() + .field("modifiedBy").is(userWhoStartsProcess.getUsername()).and() + .field("id").isNotEmpty().and() + .field("mimeType").is(document.getFileType().mimeType); + processItems.getEntries().get(1).onModel().assertThat() + .field("createdAt").isNotEmpty().and() + .field("size").is("19").and() + .field("createdBy").is(adminUser.getUsername()).and() + .field("modifiedAt").isNotEmpty().and() + .field("name").is(document2.getName()).and() + .field("modifiedBy").is(userWhoStartsProcess.getUsername()).and() + .field("id").isNotEmpty().and() + .field("mimeType").is(document2.getFileType().mimeType); + } @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add process item using by admin in other network.") @@ -109,6 +180,27 @@ public class AddProcessItemCoreTests extends RestTest processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT); } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Add multiple process items using by admin in other network.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE, TestGroup.NETWORKS }) + public void addMultipleProcessItemsByAdminInOtherNetwork() throws Exception + { + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser); + tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); + + adminTenantUser2 = UserModel.getAdminTenantUser(); + restClient.usingTenant().createTenant(adminTenantUser2); + + processModel = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee, false, Priority.Normal); + restClient.authenticateUser(adminTenantUser2); + + processItems = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItems(document, document2); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError() + .containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT); + } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process item is falling in case of invalid process id is provided") @@ -124,6 +216,21 @@ public class AddProcessItemCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidProcessId")); } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding multiple process items is falling in case of invalid process id is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + public void failedAddingMultipleProcessItemsIfInvalidProcessIdIsProvided() throws Exception + { + RestProcessModelsCollection processes = restClient.authenticateUser(adminUser).withParams("maxItems=1").withWorkflowAPI().getProcesses(); + processModel = processes.assertThat().entriesListIsNotEmpty().when().getOneRandomEntry().onModel(); + FileModel testDocument = dataContent.usingAdmin().usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + + processModel.setId("invalidProcessId"); + processItems = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItems(testDocument, document); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidProcessId")); + } @Bug(id = "ACE-5683") @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, @@ -134,16 +241,18 @@ public class AddProcessItemCoreTests extends RestTest document.setNodeRef("invalidNodeRef"); processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidId")); - } - + } + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding process item is falling in case of empty body item value is provided") + description = "Adding multiple process items is falling in case of empty body item value is provided") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) - public void failedAddingProcessItemIfEmptyItemBodyIsProvided() throws Exception + public void failedAddingMultipleProcessItemIfEmptyItemBodyIsProvided() throws Exception { + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); document.setNodeRef(""); - processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.REQUIRED_TO_ADD, "itemId")); + processItems = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItems(document, document2); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.REQUIRED_TO_ADD, "itemId")); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemFullTests.java new file mode 100644 index 000000000..25b352136 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemFullTests.java @@ -0,0 +1,119 @@ +package org.alfresco.rest.workflow.processes; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestItemModel; +import org.alfresco.rest.model.RestItemModelsCollection; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestProcessModelsCollection; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.ProcessModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class AddProcessItemFullTests extends RestTest +{ + private FileModel document, document2; + private SiteModel siteModel; + private UserModel userWhoStartsProcess, assignee, adminUser; + private ProcessModel processModel; + private RestItemModel processItem; + private RestItemModelsCollection processItems; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userWhoStartsProcess = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + document2 = dataContent.usingSite(siteModel).createContent(DocumentType.MSPOWERPOINT); + dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding multiple process items is falling in case of empty process id is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void failedAddingMultipleProcessItemsIfInvalidProcessIdIsProvided() throws Exception + { + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + FileModel testDocument = dataContent.usingAdmin().usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + + processModel.setId(""); + processItems = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItems(testDocument, document); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_WAS_NOT_FOUND, "")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding process item is falling in case of empty body item value is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void failedAddingProcessItemIfEmptyItemBodyIsProvided() throws Exception + { + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + document.setNodeRef(""); + processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.REQUIRED_TO_ADD, "itemId")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding multiple process items is falling in case of empty body item value is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void failedAddingMultipleProcessItemsIfEmptyItemBodyIsProvided() throws Exception + { + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + document.setNodeRef(""); + + processItems = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItems(document, document2); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.REQUIRED_TO_ADD, "itemId")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Add a new process item, update the item and then delete.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void createDeleteCreateMultipleProcessItems() throws Exception + { + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + document2 = dataContent.usingAdmin().usingSite(siteModel).createContent(DocumentType.MSPOWERPOINT); + processItems = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItems(document, document2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.withWorkflowAPI().usingProcess(processModel).deleteProcessItem(processItems.getEntries().get(0).onModel()); + + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems() + .assertThat().entriesListDoesNotContain("name", processItems.getEntries().get(0).onModel().getName()); + + processItems = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItems(document); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Add a new process item, delete the item and create it again.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void createDeleteCreateProcessItem() throws Exception + { + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem( document2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.withWorkflowAPI().usingProcess(processModel).deleteProcessItem(processItem); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems() + .assertThat().entriesListDoesNotContain("name", processItem.getName()); + + processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems() + .assertThat().entriesListContains("name", processItem.getName()); + } + +} diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesCoreTests.java index 8a4b62c6e..a6ba286b0 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesCoreTests.java @@ -4,7 +4,6 @@ import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.model.RestProcessVariableCollection; import org.alfresco.rest.model.RestProcessVariableModel; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; @@ -23,7 +22,6 @@ public class AddProcessVariablesCoreTests extends RestTest private UserModel userWhoStartsProcess, assignee, adminUser; private RestProcessModel processModel; private RestProcessVariableModel variableModel, processVariable, variableModel1; - private RestProcessVariableCollection processVariableCollection; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception @@ -114,7 +112,7 @@ public class AddProcessVariablesCoreTests extends RestTest processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); processModel.setId("invalidProcessID"); - processVariableCollection = restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(processModel) + restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(processModel) .addProcessVariables(variableModel1, variableModel); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) .assertLastError() @@ -131,7 +129,7 @@ public class AddProcessVariablesCoreTests extends RestTest processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); processModel.setId(""); - processVariableCollection = restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(processModel) + restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(processModel) .addProcessVariables(variableModel1, variableModel); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) .assertLastError() From 884ef0da6d9df386c5a7c65b64f0f4e9e8fee449 Mon Sep 17 00:00:00 2001 From: mionescu Date: Wed, 8 Feb 2017 12:52:38 +0200 Subject: [PATCH 1033/1491] updates --- .../rest/workflow/processes/AddProcessVariablesFullTests.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesFullTests.java index d2e6de34d..c74c67a42 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesFullTests.java @@ -1,6 +1,7 @@ package org.alfresco.rest.workflow.processes; import org.alfresco.dataprep.CMISUtil; +import org.alfresco.dataprep.CMISUtil.Priority; import org.alfresco.rest.RestTest; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.model.RestErrorModel; @@ -162,6 +163,7 @@ public class AddProcessVariablesFullTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) public void failedAddingProcessVariableIfEmptyNameIsProvided() throws Exception { + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); restProcessModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses() .getProcessModelByProcessDefId(processModel.getId()); RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); @@ -182,6 +184,7 @@ public class AddProcessVariablesFullTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) public void failedAddingProcessVariableUsingOnlyWhiteSpaceInName() throws Exception { + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); restProcessModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses() .getProcessModelByProcessDefId(processModel.getId()); variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); From d687f9af6f43daba83c59b17a9b304f00e05d709 Mon Sep 17 00:00:00 2001 From: mionescu Date: Wed, 8 Feb 2017 13:47:38 +0200 Subject: [PATCH 1034/1491] test- added test cases: multiple task variables --- .../tasks/AddTaskVariablesCoreTests.java | 106 +++++++++++++++-- .../tasks/AddTaskVariablesFullTests.java | 112 +++++++++++++++++- .../tasks/AddTaskVariablesSanityTests.java | 93 +++++++++++++++ 3 files changed, 301 insertions(+), 10 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesCoreTests.java index b3b31a4b6..04d7675bd 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesCoreTests.java @@ -5,6 +5,7 @@ import org.alfresco.rest.RestTest; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestVariableModel; +import org.alfresco.rest.model.RestVariableModelsCollection; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TaskModel; @@ -26,7 +27,9 @@ public class AddTaskVariablesCoreTests extends RestTest private FileModel fileModel; private UserModel assigneeUser; private TaskModel taskModel; - + private RestVariableModel invalidVariableModel, variableModel, variableModel1; + private RestVariableModelsCollection restVariableCollection; + private String taskId; @BeforeClass(alwaysRun = true) @@ -47,11 +50,22 @@ public class AddTaskVariablesCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case invalid variableBody is provided") public void failedAddingTaskVariableIfInvalidBodyIsProvided() throws Exception { - RestVariableModel invalidVariableModel = RestVariableModel.getRandomTaskVariableModel("instance", "d:char"); + invalidVariableModel = RestVariableModel.getRandomTaskVariableModel("instance", "d:char"); restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(invalidVariableModel); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Illegal value for variable scope: 'instance'."); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Adding multiple task variable is falling in case invalid variableBody is provided") + public void failedAddingMultipleTaskVariableIfInvalidBodyIsProvided() throws Exception + { + variableModel = RestVariableModel.getRandomTaskVariableModel("instance", "d:char"); + variableModel1 = RestVariableModel.getRandomTaskVariableModel("global", "d:text"); + restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariables(variableModel, variableModel1); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Illegal value for variable scope: 'instance'."); } @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) @@ -63,7 +77,19 @@ public class AddTaskVariablesCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() .containsSummary("Variable scope is required and can only be 'local' or 'global'."); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Adding multiple task variable is falling in case empty body type is provided") + public void failedAddingMultipleTaskVariableIfEmptyBodyIsProvided() throws Exception + { + RestVariableModel invalidVariableModel = RestVariableModel.getRandomTaskVariableModel("", ""); + variableModel1 = RestVariableModel.getRandomTaskVariableModel("global", "d:text"); + restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariables(invalidVariableModel, variableModel1); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary("Variable scope is required and can only be 'local' or 'global'."); } @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) @@ -76,7 +102,6 @@ public class AddTaskVariablesCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() .containsSummary("Variable scope is required and can only be 'local' or 'global'."); - } @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) @@ -88,7 +113,6 @@ public class AddTaskVariablesCoreTests extends RestTest restClient.processModel(RestVariableModel.class, request); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Variable name is required."); - } @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) @@ -97,10 +121,22 @@ public class AddTaskVariablesCoreTests extends RestTest { RestVariableModel invalidVariableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:char"); taskModel.setId(taskId); + restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(invalidVariableModel); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Unsupported type of variable: 'd:char'."); - + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Adding multiple task variable is falling in case invalid type is provided") + public void failedAddingMultipleTaskVariableIfInvalidTypeIsProvided() throws Exception + { + RestVariableModel invalidVariableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:char"); + taskModel.setId(taskId); + variableModel1 = RestVariableModel.getRandomTaskVariableModel("global", "d:text"); + + restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariables(invalidVariableModel, variableModel1); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Unsupported type of variable: 'd:char'."); } @Bug(id = "ACE-5674") @@ -110,10 +146,24 @@ public class AddTaskVariablesCoreTests extends RestTest { RestVariableModel invalidVariableModel = RestVariableModel.getRandomTaskVariableModel("local", "ddm:text"); taskModel.setId(taskId); + restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(invalidVariableModel); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Namespace prefix ddm is not mapped to a namespace URI"); - + } + + @Bug(id = "ACE-5674") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Adding multiple task variable is falling in case invalid type prefix is provided") + public void failedAddingMultipleTaskVariableIfInvalidTypePrefixIsProvided() throws Exception + { + RestVariableModel invalidVariableModel = RestVariableModel.getRandomTaskVariableModel("local", "ddm:text"); + taskModel.setId(taskId); + variableModel1 = RestVariableModel.getRandomTaskVariableModel("global", "d:text"); + variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + + restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariables(invalidVariableModel,variableModel1, variableModel); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Namespace prefix ddm is not mapped to a namespace URI"); } @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) @@ -122,10 +172,23 @@ public class AddTaskVariablesCoreTests extends RestTest { RestVariableModel invalidVariableModel = RestVariableModel.getRandomTaskVariableModel("instance", "d:text"); taskModel.setId(taskId); + restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(invalidVariableModel); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Illegal value for variable scope: 'instance'."); + } + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Adding multiple task variable is falling in case invalid scope is provided") + public void failedAddingMultipleTaskVariableIfInvalidScopeIsProvided() throws Exception + { + RestVariableModel invalidVariableModel = RestVariableModel.getRandomTaskVariableModel("instance", "d:text"); + taskModel.setId(taskId); + variableModel1 = RestVariableModel.getRandomTaskVariableModel("global", "d:text"); + variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + + restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariables(invalidVariableModel, variableModel, variableModel1); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Illegal value for variable scope: 'instance'."); } @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) @@ -138,7 +201,20 @@ public class AddTaskVariablesCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, taskModel.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Adding multiple task variable is falling in case invalid task id is provided") + public void failedAddingMultipleTaskVariableIfInvalidTaskIdIsProvided() throws Exception + { + variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + taskModel.setId(taskModel.getId() + "TEST"); + variableModel1 = RestVariableModel.getRandomTaskVariableModel("global", "d:text"); + restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariables(variableModel, variableModel1); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, taskModel.getId())); } @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) @@ -149,7 +225,19 @@ public class AddTaskVariablesCoreTests extends RestTest variableModel.setValue("invalidValue"); restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("For input string: \"invalidValue\""); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Adding multiple task variable is falling in case invalid task id is provided") + public void failedAddingMultipleTaskVariableIfInvalidValueIsProvided() throws Exception + { + variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:int"); + variableModel.setValue("invalidValue"); + variableModel1 = RestVariableModel.getRandomTaskVariableModel("global", "d:text"); + restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariables(variableModel, variableModel1); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("For input string: \"invalidValue\""); } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesFullTests.java index ceba3ab3f..2f4096315 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesFullTests.java @@ -7,6 +7,7 @@ import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.rest.model.RestTaskModel; import org.alfresco.rest.model.RestVariableModel; +import org.alfresco.rest.model.RestVariableModelsCollection; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TaskModel; @@ -26,7 +27,8 @@ public class AddTaskVariablesFullTests extends RestTest private FileModel fileModel; private UserModel assigneeUser; private TaskModel taskModel; - private RestVariableModel restVariablemodel; + private RestVariableModel restVariablemodel, variableModel, variableModel1; + private RestVariableModelsCollection restVariableCollection; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception @@ -57,6 +59,32 @@ public class AddTaskVariablesFullTests extends RestTest .and().field("type").is(variableModel.getType()); } + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Create multiple task variable with name containing symbols") + public void createMultipleTaskVariableWithSymbolsInName() throws Exception + { + UserModel adminUser = dataUser.getAdminUser(); + restClient.authenticateUser(adminUser); + variableModel1 = RestVariableModel.getRandomTaskVariableModel("global", "d:text"); + variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + variableModel.setName("!@#$%^&*({}<>.,;'=_|"); + + restVariableCollection = restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariables(variableModel,variableModel1); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restVariableCollection.getEntries().get(0).onModel().assertThat() + .field("scope").is(variableModel.getScope()) + .and().field("name").is(variableModel.getName()) + .and().field("value").is(variableModel.getValue()) + .and().field("type").is(variableModel.getType()); + + restVariableCollection.getEntries().get(1).onModel().assertThat() + .field("scope").is(variableModel1.getScope()) + .and().field("name").is(variableModel1.getName()) + .and().field("value").is(variableModel1.getValue()) + .and().field("type").is(variableModel1.getType()); + } + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Create task variable with empty name") @@ -74,6 +102,25 @@ public class AddTaskVariablesFullTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE); } + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Create task variable with empty name") + public void failledCreatingMultipleTaskVariableWithEmptyName() throws Exception + { + UserModel adminUser = dataUser.getAdminUser(); + restClient.authenticateUser(adminUser); + variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + variableModel1 = RestVariableModel.getRandomTaskVariableModel("global", "d:text"); + variableModel.setName(""); + + restVariableCollection = restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariables(variableModel, variableModel1); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsErrorKey(RestErrorModel.VARIABLE_NAME_REQUIRED) + .containsSummary(RestErrorModel.VARIABLE_NAME_REQUIRED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL, TestGroup.NETWORKS }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify that admin from the same network is able to add task variables") @@ -100,6 +147,40 @@ public class AddTaskVariablesFullTests extends RestTest .and().field("type").is(variableModel.getType()); } + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL, TestGroup.NETWORKS }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin from the same network is able to add multiple task variables") + public void addMultipleTaskVariablesByTenantAdmin() throws Exception + { + UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); + restClient.authenticateUser(dataUser.getAdminUser()).usingTenant().createTenant(adminTenantUser1); + UserModel tenantUser1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenant1"); + + RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser1).withWorkflowAPI() + .addProcess("activitiReview", tenantUser1, false, CMISUtil.Priority.High); + RestTaskModel task = restClient.authenticateUser(adminTenantUser1) + .withWorkflowAPI().usingProcess(networkProcess1).getProcessTasks().getOneRandomEntry(); + restClient.authenticateUser(adminTenantUser1); + + variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + variableModel1 = RestVariableModel.getRandomTaskVariableModel("global", "d:text"); + + restVariableCollection = restClient.withWorkflowAPI().usingTask(task.onModel()) + .addTaskVariables(variableModel, variableModel1); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restVariableCollection.getEntries().get(0).onModel().assertThat() + .field("scope").is(variableModel.getScope()) + .and().field("name").is(variableModel.getName()) + .and().field("value").is(variableModel.getValue()) + .and().field("type").is(variableModel.getType()); + + restVariableCollection.getEntries().get(1).onModel().assertThat() + .field("scope").is(variableModel1.getScope()) + .and().field("name").is(variableModel1.getName()) + .and().field("value").is(variableModel1.getValue()) + .and().field("type").is(variableModel1.getType()); + } + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL, TestGroup.NETWORKS }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify that admin from another network is not able to add task variables") @@ -126,4 +207,33 @@ public class AddTaskVariablesFullTests extends RestTest .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) .stackTraceIs(RestErrorModel.STACKTRACE); } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL, TestGroup.NETWORKS }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin from another network is not able to add multiple task variables") + public void addMultipleTaskVariablesByTenantFromAnotherNetwork() throws Exception + { + UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); + UserModel adminTenantUser2 = UserModel.getAdminTenantUser(); + restClient.authenticateUser(dataUser.getAdminUser()).usingTenant().createTenant(adminTenantUser1); + restClient.authenticateUser(dataUser.getAdminUser()).usingTenant().createTenant(adminTenantUser2); + UserModel tenantUser1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenant1"); + + RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser1).withWorkflowAPI() + .addProcess("activitiReview", tenantUser1, false, CMISUtil.Priority.High); + RestTaskModel task = restClient.authenticateUser(adminTenantUser1) + .withWorkflowAPI().usingProcess(networkProcess1).getProcessTasks().getOneRandomEntry(); + restClient.authenticateUser(adminTenantUser1); + + variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + variableModel1 = RestVariableModel.getRandomTaskVariableModel("global", "d:text"); + restVariableCollection = restClient.authenticateUser(adminTenantUser2).withWorkflowAPI() + .usingTask(task.onModel()) + .addTaskVariables(variableModel,variableModel1); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesSanityTests.java index e4df01a99..794395c46 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesSanityTests.java @@ -3,6 +3,7 @@ package org.alfresco.rest.workflow.tasks; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestVariableModel; +import org.alfresco.rest.model.RestVariableModelsCollection; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TaskModel; @@ -26,6 +27,8 @@ public class AddTaskVariablesSanityTests extends RestTest private UserModel assigneeUser; private TaskModel taskModel; private RestVariableModel restVariablemodel; + private RestVariableModelsCollection restVariableCollection; + private RestVariableModel variableModel, variableModel1; @BeforeClass(alwaysRun=true) public void dataPreparation() throws Exception @@ -55,6 +58,32 @@ public class AddTaskVariablesSanityTests extends RestTest .and().field("value").is(variableModel.getValue()) .and().field("type").is(variableModel.getType()); } + + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Create non-existing task variable with admin") + public void createMultipleTaskVariablesWithAdmin() throws Exception + { + UserModel adminUser = dataUser.getAdminUser(); + restClient.authenticateUser(adminUser); + variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + variableModel1 = RestVariableModel.getRandomTaskVariableModel("global", "d:text"); + + restVariableCollection = restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariables(variableModel,variableModel1); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restVariableCollection.getEntries().get(0).onModel().assertThat() + .field("scope").is(variableModel.getScope()) + .and().field("name").is(variableModel.getName()) + .and().field("value").is(variableModel.getValue()) + .and().field("type").is(variableModel.getType()); + + restVariableCollection.getEntries().get(1).onModel().assertThat() + .field("scope").is(variableModel1.getScope()) + .and().field("name").is(variableModel1.getName()) + .and().field("value").is(variableModel1.getValue()) + .and().field("type").is(variableModel1.getType()); + } @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, @@ -73,6 +102,31 @@ public class AddTaskVariablesSanityTests extends RestTest restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables().assertThat().entriesListContains("name", variableModel.getName()); } + + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Create multiple non-existing task variable with involved user") + public void createMultipleTaskVariableWithInvolvedUser() throws Exception + { + restClient.authenticateUser(assigneeUser); + variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + variableModel1 = RestVariableModel.getRandomTaskVariableModel("global", "d:text"); + + restVariableCollection = restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariables(variableModel,variableModel1); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restVariableCollection.getEntries().get(0).onModel().assertThat() + .field("scope").is(variableModel.getScope()) + .and().field("name").is(variableModel.getName()) + .and().field("value").is(variableModel.getValue()) + .and().field("type").is(variableModel.getType()); + + restVariableCollection.getEntries().get(1).onModel().assertThat() + .field("scope").is(variableModel1.getScope()) + .and().field("name").is(variableModel1.getName()) + .and().field("value").is(variableModel1.getValue()) + .and().field("type").is(variableModel1.getType()); + } @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, @@ -89,6 +143,31 @@ public class AddTaskVariablesSanityTests extends RestTest .and().field("value").is(variableModel.getValue()) .and().field("type").is(variableModel.getType()); } + + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Create multiple non-existing task variable with task owner") + public void createMultipleTaskVariableWithTaskOwner() throws Exception + { + restClient.authenticateUser(userWhoStartsTask); + variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + variableModel1 = RestVariableModel.getRandomTaskVariableModel("global", "d:text"); + + restVariableCollection = restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariables(variableModel,variableModel1); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restVariableCollection.getEntries().get(0).onModel().assertThat() + .field("scope").is(variableModel.getScope()) + .and().field("name").is(variableModel.getName()) + .and().field("value").is(variableModel.getValue()) + .and().field("type").is(variableModel.getType()); + + restVariableCollection.getEntries().get(1).onModel().assertThat() + .field("scope").is(variableModel1.getScope()) + .and().field("name").is(variableModel1.getName()) + .and().field("value").is(variableModel1.getValue()) + .and().field("type").is(variableModel1.getType()); + } @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, @@ -102,4 +181,18 @@ public class AddTaskVariablesSanityTests extends RestTest restVariablemodel = restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); } + + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Create multiple non-existing task variable with any user") + public void createMultipleTaskVariableWithRandomUser() throws Exception + { + restClient.authenticateUser(userModel); + variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + variableModel1 = RestVariableModel.getRandomTaskVariableModel("global", "d:text"); + + restVariableCollection = restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariables(variableModel,variableModel1); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); + } + } From 8e2618bcd04fcba5daf635b050fd53a7fe1ccf17 Mon Sep 17 00:00:00 2001 From: mionescu Date: Wed, 8 Feb 2017 15:37:51 +0200 Subject: [PATCH 1035/1491] test- added AddTaskItemFullTests.java test - added test cases using multiple items/variables --- .../processes/AddProcessItemCoreTests.java | 16 ++ .../processes/AddProcessItemFullTests.java | 16 +- .../processes/AddProcessItemSanityTests.java | 83 ++++++++ .../AddProcessVariablesCoreTests.java | 58 +++++- .../AddProcessVariablesFullTests.java | 50 +++++ .../AddProcessVariablesSanityTests.java | 70 ++++++- .../workflow/tasks/AddTaskItemCoreTests.java | 111 +++++++++-- .../workflow/tasks/AddTaskItemFullTests.java | 182 ++++++++++++++++++ .../tasks/AddTaskItemSanityTests.java | 118 +++++++++++- .../tasks/AddTaskVariablesCoreTests.java | 1 - 10 files changed, 682 insertions(+), 23 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemCoreTests.java index 2a8b12e53..379a8ecb2 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemCoreTests.java @@ -99,6 +99,22 @@ public class AddProcessItemCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() .containsSummary(String.format(RestErrorModel.ACCESS_INFORMATION_NOT_ALLOWED, processModel.getId())); } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Add multiple process item by a random user.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + public void addMultipleProcessItemByAnyUser() throws Exception + { + anotherUser = dataUser.createRandomTestUser(); + + document2 = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + processModel = restClient.authenticateUser(adminUser).withParams("maxItems=1").withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processItems = restClient.authenticateUser(anotherUser).withWorkflowAPI().usingProcess(processModel) + .addProcessItems(document2, document); + + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsSummary(String.format(RestErrorModel.ACCESS_INFORMATION_NOT_ALLOWED, processModel.getId())); + } @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add process item using by the admin in same network.") diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemFullTests.java index 25b352136..fcab4ac73 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemFullTests.java @@ -42,7 +42,7 @@ public class AddProcessItemFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding multiple process items is falling in case of empty process id is provided") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) - public void failedAddingMultipleProcessItemsIfInvalidProcessIdIsProvided() throws Exception + public void failedAddingMultipleProcessItemsIfEmptyProcessIdIsProvided() throws Exception { processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); FileModel testDocument = dataContent.usingAdmin().usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); @@ -53,6 +53,20 @@ public class AddProcessItemFullTests extends RestTest .containsSummary(String.format(RestErrorModel.ENTITY_WAS_NOT_FOUND, "")); } + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding process items is falling in case of empty process id is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void failedAddingProcessItemsIfEmptyProcessIdIsProvided() throws Exception + { + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + FileModel testDocument = dataContent.usingAdmin().usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + + processModel.setId(""); + processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(testDocument); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_WAS_NOT_FOUND, "")); + } + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process item is falling in case of empty body item value is provided") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemSanityTests.java index a0d7044d2..1f9fc439f 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemSanityTests.java @@ -4,6 +4,7 @@ import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestItemModel; +import org.alfresco.rest.model.RestItemModelsCollection; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FileType; @@ -27,6 +28,7 @@ public class AddProcessItemSanityTests extends RestTest private UserModel userWhoStartsTask, assignee, adminUser; private RestProcessModel processModel; private RestItemModel processItem; + private RestItemModelsCollection processItems; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception @@ -62,6 +64,45 @@ public class AddProcessItemSanityTests extends RestTest restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems() .assertThat().entriesListContains("id", processItem.getId()); } + + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Create non-existing process item") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY}) + public void addMultipleProcessItem() throws JsonToModelConversionException, Exception + { + document2 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file content"); + dataContent.usingSite(siteModel).createContent(document2); + document = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file content"); + dataContent.usingSite(siteModel).createContent(document); + + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processItems = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItems(document2, document); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + processItems.getEntries().get(0).onModel() + .assertThat().field("createdAt").isNotEmpty() + .and().field("size").is(document2.getContent().length()) + .and().field("createdBy").is(adminUser.getUsername()) + .and().field("modifiedAt").isNotEmpty() + .and().field("name").is(document2.getName()) + .and().field("modifiedBy").is(adminUser.getUsername()) + .and().field("id").isNotEmpty() + .and().field("mimeType").is(document2.getFileType().mimeType); + + processItems.getEntries().get(1).onModel() + .assertThat().field("createdAt").isNotEmpty() + .and().field("size").is(document.getContent().length()) + .and().field("createdBy").is(adminUser.getUsername()) + .and().field("modifiedAt").isNotEmpty() + .and().field("name").is(document.getName()) + .and().field("modifiedBy").is(adminUser.getUsername()) + .and().field("id").isNotEmpty() + .and().field("mimeType").is(document.getFileType().mimeType); + + restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems() + .assertThat().entriesListContains("id", processItems.getEntries().get(0).onModel().getId()) + .assertThat().entriesListContains("id", processItems.getEntries().get(1).onModel().getId()); + } @Bug(id= "MNT-16966") @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, @@ -89,4 +130,46 @@ public class AddProcessItemSanityTests extends RestTest restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document2); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); } + + @Bug(id= "MNT-16966") + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Add process item that already exists") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY}) + public void addMultipleProcessItemThatAlreadyExists() throws JsonToModelConversionException, Exception + { + document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + document = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processItems = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItems(document2, document); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + processItems.getEntries().get(0).onModel() + .assertThat().field("createdAt").isNotEmpty() + .and().field("size").is("19") + .and().field("createdBy").is(adminUser.getUsername()) + .and().field("modifiedAt").isNotEmpty() + .and().field("name").is(document2.getName()) + .and().field("modifiedBy").is(adminUser.getUsername()) + .and().field("id").isNotEmpty() + .and().field("mimeType").is(document2.getFileType().mimeType); + + processItems.getEntries().get(1).onModel() + .assertThat().field("createdAt").isNotEmpty() + .and().field("size").is("19") + .and().field("createdBy").is(adminUser.getUsername()) + .and().field("modifiedAt").isNotEmpty() + .and().field("name").is(document.getName()) + .and().field("modifiedBy").is(adminUser.getUsername()) + .and().field("id").isNotEmpty() + .and().field("mimeType").is(document.getFileType().mimeType); + + restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems() + .assertThat().entriesListContains("id", processItems.getEntries().get(0).onModel().getId()) + .and().entriesListContains("name", document2.getName()) + .assertThat().entriesListContains("id", processItems.getEntries().get(1).onModel().getId()) + .and().entriesListContains("name", document.getName()); + + restClient.withWorkflowAPI().usingProcess(processModel).addProcessItems(document2, document); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesCoreTests.java index a6ba286b0..617bb81c0 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesCoreTests.java @@ -4,6 +4,7 @@ import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestProcessVariableCollection; import org.alfresco.rest.model.RestProcessVariableModel; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; @@ -22,6 +23,7 @@ public class AddProcessVariablesCoreTests extends RestTest private UserModel userWhoStartsProcess, assignee, adminUser; private RestProcessModel processModel; private RestProcessVariableModel variableModel, processVariable, variableModel1; + private RestProcessVariableCollection processVariableCollection; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception @@ -52,6 +54,33 @@ public class AddProcessVariablesCoreTests extends RestTest restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() .assertThat().entriesListContains("name", processVariable.getName()); } + + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify multiple addProcessVariable by any user with REST API and status code is CREATED (201)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + public void addMultipleProcessVariableByAnyUser() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + variableModel1 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + + processVariableCollection = restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(processModel) + .addProcessVariables(variableModel, variableModel1); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + processVariableCollection.getEntries().get(0).onModel() + .assertThat().field("name").is(variableModel.getName()) + .and().field("type").is(variableModel.getType()) + .and().field("value").is(variableModel.getValue()); + processVariableCollection.getEntries().get(1).onModel() + .assertThat().field("name").is(variableModel1.getName()) + .and().field("type").is(variableModel1.getType()) + .and().field("value").is(variableModel1.getValue()); + + restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() + .assertThat().entriesListContains("name", processVariableCollection.getEntries().get(0).onModel().getName()) + .assertThat().entriesListContains("name", processVariableCollection.getEntries().get(1).onModel().getName()); + } @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify addProcessVariable by any user for invalid processID with REST API and status code is NOT_FOUND (404)") @@ -71,7 +100,7 @@ public class AddProcessVariablesCoreTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify addProcessVariable by any user for empty processID with REST API and status code is NOT_FOUND (404)") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) - public void addProcessVariableForInvalidProcessIdIsEmpty() throws Exception + public void addProcessVariableForEmptyProcessIdIsEmpty() throws Exception { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); @@ -101,6 +130,33 @@ public class AddProcessVariablesCoreTests extends RestTest .assertThat().entriesListContains("name", processVariable.getName()); } + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Add multiple process variables using by the user who started the process.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + public void addMultipleProcessVariableByUserThatStartedTheProcess() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + variableModel1 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + + processVariableCollection = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingProcess(processModel) + .addProcessVariables(variableModel, variableModel1); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + processVariableCollection.getEntries().get(0).onModel() + .assertThat().field("name").is(variableModel.getName()) + .and().field("type").is(variableModel.getType()) + .and().field("value").is(variableModel.getValue()); + + processVariableCollection.getEntries().get(1).onModel() + .assertThat().field("name").is(variableModel1.getName()) + .and().field("type").is(variableModel1.getType()) + .and().field("value").is(variableModel1.getValue()); + + restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() + .assertThat().entriesListContains("name", processVariableCollection.getEntries().get(1).onModel().getName()) + .assertThat().entriesListContains("name", processVariableCollection.getEntries().get(0).onModel().getName()); + } + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding multiple process variables is falling in case invalid process id is provided") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesFullTests.java index c74c67a42..3c03edb43 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesFullTests.java @@ -62,6 +62,35 @@ public class AddProcessVariablesFullTests extends RestTest .assertThat().entriesListContains("name", processVariable.getName()); } + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Add process variables using by the user involved in the process.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void addMultipleProcessVariableByUserInvolvedTheProcess() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + variableModel1 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + restProcessModel = restClient.authenticateUser(assignee).withWorkflowAPI().getProcesses() + .getProcessModelByProcessDefId(processModel.getId()); + + processVariableCollection = restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(restProcessModel) + .addProcessVariables(variableModel, variableModel1); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + processVariableCollection.getEntries().get(0).onModel() + .assertThat().field("name").is(processVariableCollection.getEntries().get(0).onModel().getName()) + .and().field("type").is(processVariableCollection.getEntries().get(0).onModel().getType()) + .and().field("value").is(processVariableCollection.getEntries().get(0).onModel().getValue()); + + processVariableCollection.getEntries().get(1).onModel() + .assertThat().field("name").is(processVariableCollection.getEntries().get(1).onModel().getName()) + .and().field("type").is(processVariableCollection.getEntries().get(1).onModel().getType()) + .and().field("value").is(processVariableCollection.getEntries().get(1).onModel().getValue()); + + restClient.withWorkflowAPI().usingProcess(restProcessModel).getProcessVariables() + .assertThat().entriesListContains("name", processVariableCollection.getEntries().get(0).onModel().getName()) + .assertThat().entriesListContains("name", processVariableCollection.getEntries().get(1).onModel().getName()); + } + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add process variables using by inexistent user.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) @@ -82,6 +111,27 @@ public class AddProcessVariablesFullTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE); } + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Add multiple process variables using by inexistent user.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void addMultipleProcessVariableByInexistentUser() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + variableModel1 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + restProcessModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses() + .getProcessModelByProcessDefId(processModel.getId()); + + processVariableCollection = restClient.authenticateUser(UserModel.getRandomUserModel()).withWorkflowAPI() + .usingProcess(restProcessModel) + .addProcessVariables(variableModel,variableModel1); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process variables is falling in case invalid type is provided") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesSanityTests.java index 2c97af9d8..2e2243196 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesSanityTests.java @@ -23,7 +23,7 @@ public class AddProcessVariablesSanityTests extends RestTest private SiteModel siteModel; private UserModel userWhoStartsProcess, assignee, adminUser, adminTenantUser, tenantUserAssignee, tenantUser; private RestProcessModel processModel; - private RestProcessVariableModel variableModel, variableModel1, processVariable; + private RestProcessVariableModel variableModel, variableModel1, variableModel2, processVariable; private RestProcessVariableCollection processVariableCollection; @BeforeClass(alwaysRun = true) @@ -55,6 +55,41 @@ public class AddProcessVariablesSanityTests extends RestTest .assertThat().entriesListContains("name", processVariable.getName()); } + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Create non-existing variable") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) + public void addMultipleProcessVariable() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + variableModel1 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + variableModel2 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + + processVariableCollection = restClient.withWorkflowAPI().usingProcess(processModel) + .addProcessVariables(variableModel, variableModel1, variableModel2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + processVariableCollection.getEntries().get(0).onModel() + .assertThat().field("name").is( processVariableCollection.getEntries().get(0).onModel().getName()) + .and().field("type").is( processVariableCollection.getEntries().get(0).onModel().getType()) + .and().field("value").is( processVariableCollection.getEntries().get(0).onModel().getValue()); + + processVariableCollection.getEntries().get(1).onModel() + .assertThat().field("name").is( processVariableCollection.getEntries().get(1).onModel().getName()) + .and().field("type").is( processVariableCollection.getEntries().get(1).onModel().getType()) + .and().field("value").is( processVariableCollection.getEntries().get(1).onModel().getValue()); + + processVariableCollection.getEntries().get(2).onModel() + .assertThat().field("name").is( processVariableCollection.getEntries().get(2).onModel().getName()) + .and().field("type").is( processVariableCollection.getEntries().get(2).onModel().getType()) + .and().field("value").is( processVariableCollection.getEntries().get(2).onModel().getValue()); + + restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() + .assertThat().entriesListContains("name", processVariableCollection.getEntries().get(1).onModel().getName()) + .assertThat().entriesListContains("name", processVariableCollection.getEntries().get(0).onModel().getName()) + .assertThat().entriesListContains("name", processVariableCollection.getEntries().get(2).onModel().getName()); + } + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Update existing variables") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) @@ -76,6 +111,39 @@ public class AddProcessVariablesSanityTests extends RestTest processVariable.assertThat().field("value").is(newValue); } + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Update existing variables") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) + public void updateExistingMultipleProcessVariable() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + variableModel1 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + + processVariableCollection = restClient.withWorkflowAPI().usingProcess(processModel) + .addProcessVariables(variableModel, variableModel1); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + processVariableCollection.getEntries().get(0).onModel() + .assertThat().field("name").is(variableModel.getName()) + .and().field("type").is(variableModel.getType()) + .and().field("value").is(variableModel.getValue()); + + processVariableCollection.getEntries().get(1).onModel() + .assertThat().field("name").is(variableModel1.getName()) + .and().field("type").is(variableModel1.getType()) + .and().field("value").is(variableModel1.getValue()); + + String newValueVar = RandomData.getRandomName("valueVar"); + variableModel.setValue(newValueVar); + String newValueVar1 = RandomData.getRandomName("valueVar1"); + variableModel1.setValue(newValueVar1); + + processVariableCollection = restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariables(variableModel, variableModel1); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + processVariableCollection.getEntries().get(0).onModel().assertThat().field("value").is(newValueVar); + processVariableCollection.getEntries().get(1).onModel().assertThat().field("value").is(newValueVar1); + } + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Adding process variables is falling in case invalid variableBody is provided") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemCoreTests.java index bfc84cf0a..e8110de93 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemCoreTests.java @@ -24,11 +24,8 @@ public class AddTaskItemCoreTests extends RestTest { private UserModel userModel, assigneeUser, anotherUser; private SiteModel siteModel; - private FileModel fileModel; + private FileModel fileModel, fileModel1; private TaskModel taskModel; - @SuppressWarnings("unused") - private RestItemModel taskItem; - private String taskId; @BeforeClass(alwaysRun = true) @@ -37,6 +34,7 @@ public class AddTaskItemCoreTests extends RestTest userModel = dataUser.createRandomTestUser(); siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + fileModel1 = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); assigneeUser = dataUser.createRandomTestUser(); taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); @@ -44,51 +42,130 @@ public class AddTaskItemCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Add task item using random user.") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Add task item using random user.") public void addTaskItemByRandomUser() throws JsonToModelConversionException, Exception { anotherUser = dataUser.createRandomTestUser(); - taskItem = restClient.authenticateUser(anotherUser).withWorkflowAPI().usingTask(taskModel).addTaskItem(fileModel); + restClient.authenticateUser(anotherUser).withWorkflowAPI().usingTask(taskModel).addTaskItem(fileModel); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError() + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Add multiple task item using random user.") + public void addMultipleTaskItemByRandomUser() throws JsonToModelConversionException, Exception + { + anotherUser = dataUser.createRandomTestUser(); + restClient.authenticateUser(anotherUser).withWorkflowAPI().usingTask(taskModel) + .addTaskItems(fileModel,fileModel1); + + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE);; } @Bug(id = "ACE-5683") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task item, is falling in case invalid itemBody is provided") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Adding task item, is falling in case invalid itemBody is provided") public void failedAddingTaskItemIfInvalidItemBodyIsProvided() throws Exception { fileModel.setNodeRef("invalidNodeRef"); - taskItem = restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).addTaskItem(fileModel); + restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).addTaskItem(fileModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidNodeRef")); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidNodeRef")) + .containsErrorKey(RestErrorModel.NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Bug(id = "ACE-5683") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Adding multiple task item, is falling in case invalid itemBody is provided") + public void failedAddingMultipleTaskItemIfInvalidItemBodyIsProvided() throws Exception + { + fileModel.setNodeRef("invalidNodeRef"); + restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel) + .addTaskItems(fileModel, fileModel1); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidNodeRef")) + .containsErrorKey(RestErrorModel.NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE);; } @Bug(id = "ACE-5675") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task item is falling in case empty item body is provided") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Adding task item is falling in case empty item body is provided") public void failedAddingTaskItemIfEmptyItemBodyIsProvided() throws Exception { fileModel.setNodeRef(""); - taskItem = restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).addTaskItem(fileModel); + restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).addTaskItem(fileModel); + + // TODO - expected error message to be added + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(""); + } + + @Bug(id = "ACE-5675") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Adding multiple task item is falling in case empty item body is provided") + public void failedAddingMultipleTaskItemIfEmptyItemBodyIsProvided() throws Exception + { + fileModel.setNodeRef(""); + restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).addTaskItems(fileModel, fileModel1); // TODO - expected error message to be added restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(""); } @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task item is falling in case invalid task id is provided") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Adding task item is falling in case invalid task id is provided") public void failedAddingTaskItemIfInvalidTaskIdIsProvided() throws Exception { taskModel.setId("invalidTaskId"); - taskItem = restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).addTaskItem(fileModel); + restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).addTaskItem(fileModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidTaskId")); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidTaskId")) + .containsErrorKey(RestErrorModel.NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE);; + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Adding task item is falling in case invalid task id is provided") + public void failedAddingMultipleTaskItemIfInvalidTaskIdIsProvided() throws Exception + { + taskModel.setId("invalidTaskId"); + restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).addTaskItems(fileModel,fileModel1); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidTaskId")) + .containsErrorKey(RestErrorModel.NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE);; } @Bug(id = "ACE-5675") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task item is falling in case incomplete body type is provided") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Adding task item is falling in case incomplete body type is provided") public void failedAddingTaskVariableIfIncompleteBodyIsProvided() throws Exception { RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{}", "tasks/{taskId}/items", taskId); @@ -96,5 +173,5 @@ public class AddTaskItemCoreTests extends RestTest // TODO - expected error message to be added restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(""); - } + } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemFullTests.java new file mode 100644 index 000000000..2b55cd6d3 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemFullTests.java @@ -0,0 +1,182 @@ +package org.alfresco.rest.workflow.tasks; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestItemModel; +import org.alfresco.rest.model.RestItemModelsCollection; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TaskModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class AddTaskItemFullTests extends RestTest +{ + private UserModel userModel, adminUser,userWhoStartsTask, assigneeUser, adminTenantUser, tenantUser, tenantUserAssignee, adminTenantUser2; + private SiteModel siteModel; + private FileModel fileModel, fileModel1, document1, document2,document3; + private TaskModel taskModel; + private RestItemModelsCollection taskItems; + private RestItemModel taskItem; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + userWhoStartsTask = dataUser.createRandomTestUser(); + assigneeUser = dataUser.createRandomTestUser(); + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Add task item using random user.") + public void addTaskItemByTheUserThatStartedTheProcess() throws JsonToModelConversionException, Exception + { + taskItem = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingTask(taskModel).addTaskItem(fileModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + taskItem.assertThat().field("createdAt").is(taskItem.getCreatedAt()) + .and().field("size").is(taskItem.getSize()) + .and().field("createdBy").is(taskItem.getCreatedBy()) + .and().field("modifiedAt").is(taskItem.getModifiedAt()) + .and().field("name").is(taskItem.getName()) + .and().field("modifiedBy").is(taskItem.getModifiedBy()) + .and().field("id").is(taskItem.getId()) + .and().field("mimeType").is(taskItem.getMimeType()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Add multiple task item using random user.") + public void addMultipleTaskItemByTheUserThatStartedTheProcess() throws JsonToModelConversionException, Exception + { + fileModel1 = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + taskItems = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingTask(taskModel) + .addTaskItems(fileModel, fileModel1); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + taskItems.getEntries().get(0).onModel() + .assertThat().field("createdAt").is(taskItems.getEntries().get(0).onModel().getCreatedAt()) + .and().field("size").is(taskItems.getEntries().get(0).onModel().getSize()) + .and().field("createdBy").is(taskItems.getEntries().get(0).onModel().getCreatedBy()) + .and().field("modifiedAt").is(taskItems.getEntries().get(0).onModel().getModifiedAt()) + .and().field("name").is(taskItems.getEntries().get(0).onModel().getName()) + .and().field("modifiedBy").is(taskItems.getEntries().get(0).onModel().getModifiedBy()) + .and().field("id").is(taskItems.getEntries().get(0).onModel().getId()) + .and().field("mimeType").is(taskItems.getEntries().get(0).onModel().getMimeType()); + + taskItems.getEntries().get(1).onModel() + .assertThat().field("createdAt").is(taskItems.getEntries().get(1).onModel().getCreatedAt()) + .assertThat().field("size").is(taskItems.getEntries().get(1).onModel().getSize()) + .assertThat().field("createdBy").is(taskItems.getEntries().get(1).onModel().getCreatedBy()) + .assertThat().field("modifiedAt").is(taskItems.getEntries().get(1).onModel().getModifiedAt()) + .assertThat().field("name").is(taskItems.getEntries().get(1).onModel().getName()) + .assertThat().field("modifiedBy").is(taskItems.getEntries().get(1).onModel().getModifiedBy()) + .assertThat().field("id").is(taskItems.getEntries().get(1).onModel().getId()) + .assertThat().field("mimeType").is(taskItems.getEntries().get(1).onModel().getMimeType()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Add task item using by admin in other network.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL, TestGroup.NETWORKS }) + public void addTaskItemByAdminInOtherNetwork() throws Exception + { + adminTenantUser = UserModel.getAdminTenantUser(); + adminTenantUser2 = UserModel.getAdminTenantUser(); + + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser); + tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); + restClient.usingTenant().createTenant(adminTenantUser2); + siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); + dataWorkflow.usingUser(tenantUser).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(tenantUserAssignee); + + document1 = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(DocumentType.XML); + restClient.authenticateUser(adminTenantUser2).withWorkflowAPI().usingTask(taskModel).addTaskItem(document1); + + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .containsErrorKey(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Add multiple task item using by admin in other network.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL, TestGroup.NETWORKS }) + public void addMultipleTaskItemByAdminInOtherNetwork() throws Exception + { + adminTenantUser = UserModel.getAdminTenantUser(); + adminTenantUser2 = UserModel.getAdminTenantUser(); + + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser); + tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); + restClient.usingTenant().createTenant(adminTenantUser2); + siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); + dataWorkflow.usingUser(tenantUser).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(tenantUserAssignee); + + document1 = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(DocumentType.XML); + document2 = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(DocumentType.XML); + + restClient.authenticateUser(adminTenantUser2).withWorkflowAPI().usingTask(taskModel).addTaskItems(document1, document2); + + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .containsErrorKey(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT) + .stackTraceIs(RestErrorModel.STACKTRACE);; + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Delete task item then create it again") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL}) + public void deleteTaskItemThenCreateItAgain() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel) + .createNewTaskAndAssignTo(assigneeUser); + restClient.authenticateUser(userWhoStartsTask); + document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Delete multiple task item then create it again") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL}) + public void deleteMultipleTaskItemThenCreateItAgain() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel) + .createNewTaskAndAssignTo(assigneeUser); + restClient.authenticateUser(userWhoStartsTask); + document1 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + document3 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + taskItems = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItems(document2, document1, document3); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItems.getEntries().get(0).onModel()); + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItems.getEntries().get(1).onModel()); + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItems.getEntries().get(2).onModel()); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withWorkflowAPI().usingTask(taskModel).addTaskItems(document2, document1, document3); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + } + + } diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemSanityTests.java index c6b95b0e2..bd1c566e6 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemSanityTests.java @@ -4,6 +4,7 @@ import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestItemModel; +import org.alfresco.rest.model.RestItemModelsCollection; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TaskModel; @@ -23,7 +24,7 @@ public class AddTaskItemSanityTests extends RestTest private SiteModel siteModel; private FileModel fileModel, document2, document3, document4; private TaskModel taskModel; - + private RestItemModelsCollection taskItems; private RestItemModel taskItem; @BeforeClass(alwaysRun=true) @@ -56,8 +57,40 @@ public class AddTaskItemSanityTests extends RestTest .assertThat().field("name").is(taskItem.getName()) .assertThat().field("modifiedBy").is(taskItem.getModifiedBy()) .assertThat().field("id").is(taskItem.getId()) - .assertThat().field("mimeType").is(taskItem.getMimeType()); + .assertThat().field("mimeType").is(taskItem.getMimeType()); + } + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Create multiple non-existing task item") + public void createMultipleTaskItem() throws Exception + { + UserModel adminUser = dataUser.getAdminUser(); + restClient.authenticateUser(adminUser); + document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + + taskItems = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItems(document2, fileModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + taskItems.getEntries().get(0).onModel() + .assertThat().field("createdAt").is(taskItems.getEntries().get(0).onModel().getCreatedAt()) + .assertThat().field("size").is(taskItems.getEntries().get(0).onModel().getSize()) + .assertThat().field("createdBy").is(taskItems.getEntries().get(0).onModel().getCreatedBy()) + .assertThat().field("modifiedAt").is(taskItems.getEntries().get(0).onModel().getModifiedAt()) + .assertThat().field("name").is(taskItems.getEntries().get(0).onModel().getName()) + .assertThat().field("modifiedBy").is(taskItems.getEntries().get(0).onModel().getModifiedBy()) + .assertThat().field("id").is(taskItems.getEntries().get(0).onModel().getId()) + .assertThat().field("mimeType").is(taskItems.getEntries().get(0).onModel().getMimeType()); + + taskItems.getEntries().get(1).onModel() + .assertThat().field("createdAt").is(taskItems.getEntries().get(1).onModel().getCreatedAt()) + .assertThat().field("size").is(taskItems.getEntries().get(1).onModel().getSize()) + .assertThat().field("createdBy").is(taskItems.getEntries().get(1).onModel().getCreatedBy()) + .assertThat().field("modifiedAt").is(taskItems.getEntries().get(1).onModel().getModifiedAt()) + .assertThat().field("name").is(taskItems.getEntries().get(1).onModel().getName()) + .assertThat().field("modifiedBy").is(taskItems.getEntries().get(1).onModel().getModifiedBy()) + .assertThat().field("id").is(taskItems.getEntries().get(1).onModel().getId()) + .assertThat().field("mimeType").is(taskItems.getEntries().get(1).onModel().getMimeType()); } @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) @@ -85,6 +118,44 @@ public class AddTaskItemSanityTests extends RestTest taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document3); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); } + + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @Bug(id = "MNT-16966") + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Verify that in case task item exists the request fails") + public void createMultipleTaskItemThatAlreadyExists() throws Exception + { + UserModel adminUser = dataUser.getAdminUser(); + restClient.authenticateUser(adminUser); + document3 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + + taskItems = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItems(document3, document2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + taskItems.getEntries().get(0).onModel() + .assertThat().field("createdAt").is(taskItems.getEntries().get(0).onModel().getCreatedAt()) + .assertThat().field("size").is(taskItems.getEntries().get(0).onModel().getSize()) + .assertThat().field("createdBy").is(taskItems.getEntries().get(0).onModel().getCreatedBy()) + .assertThat().field("modifiedAt").is(taskItems.getEntries().get(0).onModel().getModifiedAt()) + .assertThat().field("name").is(taskItems.getEntries().get(0).onModel().getName()) + .assertThat().field("modifiedBy").is(taskItems.getEntries().get(0).onModel().getModifiedBy()) + .assertThat().field("id").is(taskItems.getEntries().get(0).onModel().getId()) + .assertThat().field("mimeType").is(taskItems.getEntries().get(0).onModel().getMimeType()); + + taskItems.getEntries().get(1).onModel() + .assertThat().field("createdAt").is(taskItems.getEntries().get(1).onModel().getCreatedAt()) + .assertThat().field("size").is(taskItems.getEntries().get(1).onModel().getSize()) + .assertThat().field("createdBy").is(taskItems.getEntries().get(1).onModel().getCreatedBy()) + .assertThat().field("modifiedAt").is(taskItems.getEntries().get(1).onModel().getModifiedAt()) + .assertThat().field("name").is(taskItems.getEntries().get(1).onModel().getName()) + .assertThat().field("modifiedBy").is(taskItems.getEntries().get(1).onModel().getModifiedBy()) + .assertThat().field("id").is(taskItems.getEntries().get(1).onModel().getId()) + .assertThat().field("mimeType").is(taskItems.getEntries().get(1).onModel().getMimeType()); + + taskItems = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItems(document3, document2); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + } @Test(groups = { TestGroup.NETWORKS,TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, @@ -116,4 +187,47 @@ public class AddTaskItemSanityTests extends RestTest .and().field("id").is(taskItem.getId()) .and().field("mimeType").is(taskItem.getMimeType()); } + + @Test(groups = { TestGroup.NETWORKS,TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Add task item using admin user from same network") + public void addMultipleTaskItemByAdminSameNetwork() throws JsonToModelConversionException, Exception + { + UserModel adminuser = dataUser.getAdminUser(); + restClient.authenticateUser(adminuser); + + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.usingTenant().createTenant(adminTenantUser); + + tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); + + siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); + dataWorkflow.usingUser(tenantUser).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(tenantUserAssignee); + + document4 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + document3 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + + taskItems = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItems(document4,document3); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + taskItems.getEntries().get(0).onModel() + .assertThat().field("createdAt").is(taskItems.getEntries().get(0).onModel().getCreatedAt()) + .assertThat().field("size").is(taskItems.getEntries().get(0).onModel().getSize()) + .assertThat().field("createdBy").is(taskItems.getEntries().get(0).onModel().getCreatedBy()) + .assertThat().field("modifiedAt").is(taskItems.getEntries().get(0).onModel().getModifiedAt()) + .assertThat().field("name").is(taskItems.getEntries().get(0).onModel().getName()) + .assertThat().field("modifiedBy").is(taskItems.getEntries().get(0).onModel().getModifiedBy()) + .assertThat().field("id").is(taskItems.getEntries().get(0).onModel().getId()) + .assertThat().field("mimeType").is(taskItems.getEntries().get(0).onModel().getMimeType()); + + taskItems.getEntries().get(1).onModel() + .assertThat().field("createdAt").is(taskItems.getEntries().get(1).onModel().getCreatedAt()) + .assertThat().field("size").is(taskItems.getEntries().get(1).onModel().getSize()) + .assertThat().field("createdBy").is(taskItems.getEntries().get(1).onModel().getCreatedBy()) + .assertThat().field("modifiedAt").is(taskItems.getEntries().get(1).onModel().getModifiedAt()) + .assertThat().field("name").is(taskItems.getEntries().get(1).onModel().getName()) + .assertThat().field("modifiedBy").is(taskItems.getEntries().get(1).onModel().getModifiedBy()) + .assertThat().field("id").is(taskItems.getEntries().get(1).onModel().getId()); + } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesCoreTests.java index 04d7675bd..c82dfb159 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesCoreTests.java @@ -28,7 +28,6 @@ public class AddTaskVariablesCoreTests extends RestTest private UserModel assigneeUser; private TaskModel taskModel; private RestVariableModel invalidVariableModel, variableModel, variableModel1; - private RestVariableModelsCollection restVariableCollection; private String taskId; From c2c42f962c74cc72aa892d928271f055784d5b71 Mon Sep 17 00:00:00 2001 From: mionescu Date: Thu, 9 Feb 2017 15:18:58 +0200 Subject: [PATCH 1036/1491] test- added UpdateTaskVariableFullTests.java - renamed class - formatting --- .../processes/AddProcessItemFullTests.java | 2 - .../AddProcessVariablesCoreTests.java | 3 +- .../UpdateProcessVariableSanityTests.java | 84 ------ .../processes/UpdateProcessVariableTests.java | 139 +++++++++ .../tasks/UpdateTaskVariableFullTests.java | 281 ++++++++++++++++++ 5 files changed, 421 insertions(+), 88 deletions(-) delete mode 100644 e2e-test/java/org/alfresco/rest/workflow/processes/UpdateProcessVariableSanityTests.java create mode 100644 e2e-test/java/org/alfresco/rest/workflow/processes/UpdateProcessVariableTests.java create mode 100644 e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskVariableFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemFullTests.java index fcab4ac73..27d3558aa 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemFullTests.java @@ -5,8 +5,6 @@ import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestItemModel; import org.alfresco.rest.model.RestItemModelsCollection; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.model.RestProcessModelsCollection; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.ProcessModel; import org.alfresco.utility.model.SiteModel; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesCoreTests.java index 617bb81c0..92089694d 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesCoreTests.java @@ -20,7 +20,7 @@ public class AddProcessVariablesCoreTests extends RestTest { private FileModel document; private SiteModel siteModel; - private UserModel userWhoStartsProcess, assignee, adminUser; + private UserModel userWhoStartsProcess, assignee; private RestProcessModel processModel; private RestProcessVariableModel variableModel, processVariable, variableModel1; private RestProcessVariableCollection processVariableCollection; @@ -28,7 +28,6 @@ public class AddProcessVariablesCoreTests extends RestTest @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception { - adminUser = dataUser.getAdminUser(); userWhoStartsProcess = dataUser.createRandomTestUser(); assignee = dataUser.createRandomTestUser(); siteModel = dataSite.usingUser(userWhoStartsProcess).createPublicRandomSite(); diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/UpdateProcessVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/UpdateProcessVariableSanityTests.java deleted file mode 100644 index e84f3f45c..000000000 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/UpdateProcessVariableSanityTests.java +++ /dev/null @@ -1,84 +0,0 @@ -package org.alfresco.rest.workflow.processes; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.model.RestProcessVariableCollection; -import org.alfresco.rest.model.RestProcessVariableModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.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 UpdateProcessVariableSanityTests extends RestTest -{ - private FileModel document; - private SiteModel siteModel; - private UserModel userWhoStartsTask, assignee, adminUser; - private RestProcessModel processModel; - private RestProcessVariableCollection variables; - private RestProcessVariableModel variableModel, updatedVariable; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userWhoStartsTask = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Create non-existing variable using put call") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) - public void addProcessVariable() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().addProcess("activitiAdhoc", adminUser, false, CMISUtil.Priority.Normal); - restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - variables = restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables(); - restClient.assertStatusCodeIs(HttpStatus.OK); - variables.assertThat().entriesListContains("name", variableModel.getName()); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Update existing variable using put call") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) - public void updateProcessVariable() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - variableModel.setValue("newValue"); - updatedVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedVariable.assertThat().field("value").is("newValue"); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Try to add process variable using an invalid processId") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) - public void addProcessVariableUsingInvalidProcessId() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - processModel.setId("abc"); - restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "abc")); - } -} diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/UpdateProcessVariableTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/UpdateProcessVariableTests.java new file mode 100644 index 000000000..4098d7411 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/UpdateProcessVariableTests.java @@ -0,0 +1,139 @@ +package org.alfresco.rest.workflow.processes; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestProcessVariableModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + + +public class UpdateProcessVariableTests extends RestTest +{ + private FileModel document; + private SiteModel siteModel; + private UserModel userWhoStartsProcess, assignee; + private RestProcessModel processModel; + private RestProcessVariableModel variableModel, updatedVariable; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + userWhoStartsProcess = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userWhoStartsProcess).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Update existing variable using PUT call - invalid type") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) + public void updateProcessVariableInvalidType() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + variableModel.setType("dd"); + + updatedVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsErrorKey(String.format(RestErrorModel.UNSUPPORTED_TYPE, "dd")) + .containsSummary(String.format(RestErrorModel.UNSUPPORTED_TYPE, "dd")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Update existing variable using PUT call - invalid type") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) + public void updateProcessVariableTwoUsers() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + variableModel.setType("d:boolean"); + + updatedVariable = restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(processModel) + .updateProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedVariable.assertThat().field("type").is("d:boolean"); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Update existing variable using PUT call - value") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) + public void updateProcessVariableValue() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + variableModel.setValue("newValue"); + + updatedVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedVariable.assertThat().field("value").is("newValue"); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Update existing variable using PUT call - name") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) + public void updateProcessVariableName() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + variableModel.setName("newVariableName"); + + updatedVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedVariable.assertThat().field("name").is("newVariableName"); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Update existing variable created by the user who started the process using put call with a user that is not involved in the process- value") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) + public void anyUserCantUpdateProcessVariableValueCreated() throws Exception + { + UserModel anotherUser = dataUser.createRandomTestUser(); + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + variableModel.setValue("newValue"); + + restClient.authenticateUser(anotherUser).withWorkflowAPI().usingProcess(processModel) + .updateProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(String.format(RestErrorModel.ACCESS_INFORMATION_NOT_ALLOWED, processModel.getId())); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Try to add process variable using an invalid processId") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) + public void updateProcessVariableUsingInvalidProcessId() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + processModel.setId("abc"); + + restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "abc")); + } +} diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskVariableFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskVariableFullTests.java new file mode 100644 index 000000000..603431e0d --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskVariableFullTests.java @@ -0,0 +1,281 @@ +package org.alfresco.rest.workflow.tasks; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestTaskModel; +import org.alfresco.rest.model.RestVariableModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TaskModel; +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 UpdateTaskVariableFullTests extends RestTest +{ + private SiteModel siteModel; + private FileModel fileModel; + private TaskModel taskModel; + private UserModel userModel; + private RestVariableModel taskVariable, updatedTaskVariable; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(userModel); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Update task variable with invalid name - PUT call") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + public void updateTaskVariableWithInvalidVariableName() throws Exception + { + taskVariable = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + restClient.authenticateUser(userModel) + .withWorkflowAPI().usingTask(taskModel).addTaskVariable(taskVariable); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"scope\": \"local\",\"names\": \"varName\",\"value\": \"test\"," + + "\"type\": \"d:text\"}", + "tasks/{taskId}/variables/{variableName}", taskModel.getId(), taskVariable.getName()); + restClient.processModel(RestVariableModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsSummary(String.format(RestErrorModel.NO_CONTENT,"Unrecognized field " + "\"names\"")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Update task variable with invalid name - PUT call") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + public void updateTaskVariableWithInvalidVariableValue() throws Exception + { + taskVariable = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + restClient.authenticateUser(userModel) + .withWorkflowAPI().usingTask(taskModel).addTaskVariable(taskVariable); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"scope\": \"local\",\"name\": \"varName\",\"values\": \"test\"," + + "\"type\": \"d:text\"}", + "tasks/{taskId}/variables/{variableName}", taskModel.getId(), taskVariable.getName()); + restClient.processModel(RestVariableModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsSummary(String.format(RestErrorModel.NO_CONTENT,"Unrecognized field " + "\"values\"")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Update task variable with invalid name - PUT call") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + public void updateTaskVariableWithEmptyVariableName() throws Exception + { + taskVariable = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + restClient.authenticateUser(userModel) + .withWorkflowAPI().usingTask(taskModel).addTaskVariable(taskVariable); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"scope\": \"local\",\"\": \"varName\",\"value\": \"test\"," + + "\"type\": \"d:text\"}", + "tasks/{taskId}/variables/{variableName}", taskModel.getId(), taskVariable.getName()); + restClient.processModel(RestVariableModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsSummary(String.format(RestErrorModel.NO_CONTENT,"Unrecognized field " + "\"\"")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Update task variable with empty name - PUT call") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + public void updateTaskVariableWithEmptyName() throws Exception + { + taskVariable = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).addTaskVariable(taskVariable); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + taskVariable.setName(""); + restClient.withWorkflowAPI().usingTask(taskModel).updateTaskVariable(taskVariable); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) + .assertLastError().containsErrorKey(RestErrorModel.PUT_EMPTY_ARGUMENT) + .containsSummary(RestErrorModel.PUT_EMPTY_ARGUMENT) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Update task variable with empty name - PUT call") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + public void updateTaskVariableWithInvalidName() throws Exception + { + taskVariable = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).addTaskVariable(taskVariable); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"scope\": \"local\",\"name\": ',\"value\": \"test\"," + + "\"type\": \"d:text\"}", + "tasks/{taskId}/variables/{variableName}", taskModel.getId(), taskVariable.getName()); + restClient.processModel(RestVariableModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsSummary(String.format(RestErrorModel.NO_CONTENT,"Unexpected character " + "('''")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Update task variable with empty name - PUT call") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + public void updateTaskVariableWithInvalidValue() throws Exception + { + taskVariable = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).addTaskVariable(taskVariable); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"scope\": \"local\",\"name\": \"varName\",\"value\"::," + + "\"type\": \"d:text\"}", + "tasks/{taskId}/variables/{variableName}", taskModel.getId(), taskVariable.getName()); + restClient.processModel(RestVariableModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsSummary(String.format(RestErrorModel.NO_CONTENT,"Unexpected character " + "(':'")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Update task variable with empty name - PUT call") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + public void updateTaskVariableWithMissingType() throws Exception + { + taskVariable = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + restClient.authenticateUser(userModel) + .withWorkflowAPI().usingTask(taskModel).addTaskVariable(taskVariable); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"scope\": \"local\",\"name\": \"varName\",\"value\": \"test\"}", + "tasks/{taskId}/variables/{variableName}", taskModel.getId(), taskVariable.getName()); + restClient.processModel(RestVariableModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.OK); + taskVariable.assertThat().field("scope").is(taskVariable.getScope()) + .and().field("name").is(taskVariable.getName()) + .and().field("type").is("d:text") + .and().field("value").is(taskVariable.getValue()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Update task variable with empty name - PUT call") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + public void updateTaskVariableWithMissingTypeAndValue() throws Exception + { + taskVariable = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + restClient.authenticateUser(userModel) + .withWorkflowAPI().usingTask(taskModel).addTaskVariable(taskVariable); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"scope\": \"local\",\"name\": \"varName\"}", + "tasks/{taskId}/variables/{variableName}", taskModel.getId(), taskVariable.getName()); + updatedTaskVariable = restClient.processModel(RestVariableModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedTaskVariable.assertThat().field("scope").is(updatedTaskVariable.getScope()) + .and().field("name").is(updatedTaskVariable.getName()) + .and().field("type").is("d:any"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Update task variable with invalid name - PUT call") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + public void updateTaskVariableWithEmptyBody() throws Exception + { + taskVariable = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + restClient.authenticateUser(userModel) + .withWorkflowAPI().usingTask(taskModel).addTaskVariable(taskVariable); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{}", + "tasks/{taskId}/variables/{variableName}", taskModel.getId(), taskVariable.getName()); + restClient.processModel(RestVariableModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsErrorKey(RestErrorModel.VARIABLE_NAME_REQUIRED) + .containsSummary(RestErrorModel.VARIABLE_NAME_REQUIRED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Update task variable with invalid name - PUT call") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + public void updateTaskVariableWithInvalidBody() throws Exception + { + taskVariable = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + restClient.authenticateUser(userModel) + .withWorkflowAPI().usingTask(taskModel).addTaskVariable(taskVariable); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"scope\": \"local\",\"name\": \"varName\",\"value\": \"test\"," + + "\"type\": \"d:text\", \"errorKey\": \"invalidBody\"}", + "tasks/{taskId}/variables/{variableName}", taskModel.getId(), taskVariable.getName()); + restClient.processModel(RestVariableModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsSummary(String.format(RestErrorModel.NO_CONTENT,"Unrecognized field " + "\"errorKey\"")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Update task variable with empty name - PUT call") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + public void updateTwiceInARowSameTaskVariable() throws Exception + { + taskVariable = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).addTaskVariable(taskVariable); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + taskVariable.setName("newName"); + taskVariable.setScope("global"); + updatedTaskVariable = restClient.withWorkflowAPI().usingTask(taskModel).updateTaskVariable(taskVariable); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedTaskVariable.assertThat().field("scope").is("global"); + updatedTaskVariable.assertThat().field("name").is("newName"); + + updatedTaskVariable = restClient.withWorkflowAPI().usingTask(taskModel).updateTaskVariable(taskVariable); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedTaskVariable.assertThat().field("scope").is("global"); + updatedTaskVariable.assertThat().field("name").is("newName"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL, TestGroup.NETWORKS }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin from another network is not able to update task variables") + public void updateTaskVariablesByTenantFromAnotherNetwork() throws Exception + { + UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); + UserModel adminTenantUser2 = UserModel.getAdminTenantUser(); + restClient.authenticateUser(dataUser.getAdminUser()).usingTenant().createTenant(adminTenantUser1); + restClient.authenticateUser(dataUser.getAdminUser()).usingTenant().createTenant(adminTenantUser2); + UserModel tenantUser1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenant1"); + + RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser1).withWorkflowAPI() + .addProcess("activitiReview", tenantUser1, false, CMISUtil.Priority.High); + RestTaskModel task = restClient.authenticateUser(adminTenantUser1) + .withWorkflowAPI().usingProcess(networkProcess1).getProcessTasks().getOneRandomEntry(); + restClient.authenticateUser(adminTenantUser1); + RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + taskVariable = restClient.authenticateUser(adminTenantUser1).withWorkflowAPI().usingTask(task.onModel()) + .addTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(adminTenantUser2).withWorkflowAPI().usingTask(task.onModel()) + .updateTaskVariable(taskVariable); + + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } +} From 1884c117f05ce49d3fda0db2fb097f629ef14116 Mon Sep 17 00:00:00 2001 From: mionescu Date: Fri, 10 Feb 2017 10:19:26 +0200 Subject: [PATCH 1037/1491] test- updated errorKey enum --- .../alfresco/rest/workflow/tasks/AddTaskItemCoreTests.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemCoreTests.java index e8110de93..f5077f526 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemCoreTests.java @@ -142,7 +142,7 @@ public class AddTaskItemCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidTaskId")) - .containsErrorKey(RestErrorModel.NOT_FOUND_ERRORKEY) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) .stackTraceIs(RestErrorModel.STACKTRACE);; } @@ -157,9 +157,9 @@ public class AddTaskItemCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidTaskId")) - .containsErrorKey(RestErrorModel.NOT_FOUND_ERRORKEY) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE);; + .stackTraceIs(RestErrorModel.STACKTRACE); } @Bug(id = "ACE-5675") From c7b9babf6f993048d79ac1d21beb02ef1e15e1fe Mon Sep 17 00:00:00 2001 From: mionescu Date: Fri, 10 Feb 2017 11:31:06 +0200 Subject: [PATCH 1038/1491] test- updated TC updateProcessVariableTwoUsers --- .../workflow/processes/UpdateProcessVariableTests.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/UpdateProcessVariableTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/UpdateProcessVariableTests.java index 4098d7411..51285293d 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/UpdateProcessVariableTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/UpdateProcessVariableTests.java @@ -59,16 +59,16 @@ public class UpdateProcessVariableTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public void updateProcessVariableTwoUsers() throws Exception { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:any"); processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); - variableModel.setType("d:boolean"); - + + variableModel.setType("d:text"); updatedVariable = restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(processModel) .updateProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.OK); - updatedVariable.assertThat().field("type").is("d:boolean"); + updatedVariable.assertThat().field("type").is("d:text"); } @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, @@ -106,7 +106,7 @@ public class UpdateProcessVariableTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Update existing variable created by the user who started the process using put call with a user that is not involved in the process- value") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) - public void anyUserCantUpdateProcessVariableValueCreated() throws Exception + public void cantUpdateProcessVariableValueCreatedWithAnyUser() throws Exception { UserModel anotherUser = dataUser.createRandomTestUser(); variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); From a67f6a281639e7bab56bab3194d2860ab74a8bbd Mon Sep 17 00:00:00 2001 From: Ana Bozianu Date: Fri, 10 Feb 2017 13:45:26 +0200 Subject: [PATCH 1039/1491] RM-4672 - implemented move file api call --- .../org/alfresco/rest/nodes/NodesTests.java | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/nodes/NodesTests.java diff --git a/e2e-test/java/org/alfresco/rest/nodes/NodesTests.java b/e2e-test/java/org/alfresco/rest/nodes/NodesTests.java new file mode 100644 index 000000000..bea26d467 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/nodes/NodesTests.java @@ -0,0 +1,57 @@ +package org.alfresco.rest.nodes; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestNodeBodyMoveModel; +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.Assert; +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 + RestNodeBodyMoveModel moveDestinationInfo = new RestNodeBodyMoveModel(); + 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 + */ + Assert.assertEquals(response.getParentId(), destinationFolder.getId()); + } +} From 34b3a59be400965f1484119ef633538ca326e43e Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Fri, 10 Feb 2017 14:33:02 +0200 Subject: [PATCH 1040/1491] update standard assertiong with TAS DSL assertion --- e2e-test/java/org/alfresco/rest/nodes/NodesTests.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/nodes/NodesTests.java b/e2e-test/java/org/alfresco/rest/nodes/NodesTests.java index bea26d467..b7b0efc5c 100644 --- a/e2e-test/java/org/alfresco/rest/nodes/NodesTests.java +++ b/e2e-test/java/org/alfresco/rest/nodes/NodesTests.java @@ -10,7 +10,6 @@ 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.Assert; import org.testng.annotations.Test; /** @@ -52,6 +51,6 @@ public class NodesTests extends RestTest * - destinationFolder * - file */ - Assert.assertEquals(response.getParentId(), destinationFolder.getId()); + response.assertThat().field("parentId").equals(destinationFolder.getId()); } } From c013359fcf634481fe558be2c289ba18e75443f2 Mon Sep 17 00:00:00 2001 From: mionescu Date: Tue, 14 Feb 2017 08:58:12 +0200 Subject: [PATCH 1041/1491] updates --- .../AddProcessVariableCoreTests.java | 12 ++--- .../AddProcessVariableFullTests.java | 6 +-- .../AddProcessVariableSanityTests.java | 2 +- .../AddProcessVariablesCoreTests.java | 27 ++++++------ .../AddProcessVariablesFullTests.java | 38 ++++++++-------- .../AddProcessVariablesSanityTests.java | 44 +++++++++---------- .../tasks/AddTaskVariablesCoreTests.java | 1 - 7 files changed, 65 insertions(+), 65 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableCoreTests.java index 9d3748599..d2668c907 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableCoreTests.java @@ -49,9 +49,9 @@ public class AddProcessVariableCoreTests extends RestTest processVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.OK); - processVariable.assertThat().field("name").is(processVariable.getName()) - .and().field("type").is(processVariable.getType()) - .and().field("value").is(processVariable.getValue()); + processVariable.assertThat().field("name").is(variableModel.getName()) + .and().field("type").is(variableModel.getType()) + .and().field("value").is(variableModel.getValue()); } @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, @@ -64,9 +64,9 @@ public class AddProcessVariableCoreTests extends RestTest processVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.OK); - processVariable.assertThat().field("name").is(processVariable.getName()) - .and().field("type").is(processVariable.getType()) - .and().field("value").is(processVariable.getValue()); + processVariable.assertThat().field("name").is(variableModel.getName()) + .and().field("type").is(variableModel.getType()) + .and().field("value").is(variableModel.getValue()); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableFullTests.java index 219f4ba1d..a735538ad 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableFullTests.java @@ -144,9 +144,9 @@ public class AddProcessVariableFullTests extends RestTest processVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.OK); - processVariable.assertThat().field("name").is(processVariable.getName()) + processVariable.assertThat().field("name").is(variableModel.getName()) .and().field("type").is("d:text") - .and().field("value").is(processVariable.getValue()); + .and().field("value").is(variableModel.getValue()); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, @@ -185,7 +185,7 @@ public class AddProcessVariableFullTests extends RestTest .and().field("value").is(variableModel.getValue()); restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() - .assertThat().entriesListContains("name", processVariable.getName()); + .assertThat().entriesListContains("name", variableModel.getName()); updatedProcessVariable = restClient.withWorkflowAPI().usingProcess(processModel) .updateProcessVariable(variableModel); diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java index 89c7dbdd9..c8f2961c6 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java @@ -54,7 +54,7 @@ public class AddProcessVariableSanityTests extends RestTest .and().field("value").is(variableModel.getValue()); restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() - .assertThat().entriesListContains("name", processVariable.getName()); + .assertThat().entriesListContains("name", variableModel.getName()); } @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesCoreTests.java index 92089694d..4cc9fe80b 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesCoreTests.java @@ -46,12 +46,12 @@ public class AddProcessVariablesCoreTests extends RestTest processVariable = restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(processModel) .addProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); - processVariable.assertThat().field("name").is(processVariable.getName()) - .and().field("type").is(processVariable.getType()) - .and().field("value").is(processVariable.getValue()); + processVariable.assertThat().field("name").is(variableModel.getName()) + .and().field("type").is(variableModel.getType()) + .and().field("value").is(variableModel.getValue()); restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() - .assertThat().entriesListContains("name", processVariable.getName()); + .assertThat().entriesListContains("name", variableModel.getName()); } @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, @@ -77,8 +77,8 @@ public class AddProcessVariablesCoreTests extends RestTest .and().field("value").is(variableModel1.getValue()); restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() - .assertThat().entriesListContains("name", processVariableCollection.getEntries().get(0).onModel().getName()) - .assertThat().entriesListContains("name", processVariableCollection.getEntries().get(1).onModel().getName()); + .assertThat().entriesListContains("name",variableModel.getName()) + .assertThat().entriesListContains("name",variableModel1.getName()); } @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, @@ -105,7 +105,8 @@ public class AddProcessVariablesCoreTests extends RestTest processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); processModel.setId(""); - processVariable = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); + processVariable = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingProcess(processModel) + .addProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); } @@ -121,12 +122,12 @@ public class AddProcessVariablesCoreTests extends RestTest processVariable = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingProcess(processModel) .addProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); - processVariable.assertThat().field("name").is(processVariable.getName()) - .and().field("type").is(processVariable.getType()) - .and().field("value").is(processVariable.getValue()); + processVariable.assertThat().field("name").is(variableModel.getName()) + .and().field("type").is(variableModel.getType()) + .and().field("value").is(variableModel.getValue()); restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() - .assertThat().entriesListContains("name", processVariable.getName()); + .assertThat().entriesListContains("name", variableModel.getName()); } @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, @@ -152,8 +153,8 @@ public class AddProcessVariablesCoreTests extends RestTest .and().field("value").is(variableModel1.getValue()); restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() - .assertThat().entriesListContains("name", processVariableCollection.getEntries().get(1).onModel().getName()) - .assertThat().entriesListContains("name", processVariableCollection.getEntries().get(0).onModel().getName()); + .assertThat().entriesListContains("name", variableModel.getName()) + .assertThat().entriesListContains("name", variableModel1.getName()); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesFullTests.java index 3c03edb43..39fbefd92 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesFullTests.java @@ -54,12 +54,12 @@ public class AddProcessVariablesFullTests extends RestTest processVariable = restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(restProcessModel) .addProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); - processVariable.assertThat().field("name").is(processVariable.getName()) - .and().field("type").is(processVariable.getType()) - .and().field("value").is(processVariable.getValue()); + processVariable.assertThat().field("name").is(variableModel.getName()) + .and().field("type").is(variableModel.getType()) + .and().field("value").is(variableModel.getValue()); restClient.withWorkflowAPI().usingProcess(restProcessModel).getProcessVariables() - .assertThat().entriesListContains("name", processVariable.getName()); + .assertThat().entriesListContains("name", variableModel.getName()); } @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, @@ -77,18 +77,18 @@ public class AddProcessVariablesFullTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.CREATED); processVariableCollection.getEntries().get(0).onModel() - .assertThat().field("name").is(processVariableCollection.getEntries().get(0).onModel().getName()) - .and().field("type").is(processVariableCollection.getEntries().get(0).onModel().getType()) - .and().field("value").is(processVariableCollection.getEntries().get(0).onModel().getValue()); + .assertThat().field("name").is(variableModel.getName()) + .and().field("type").is(variableModel.getType()) + .and().field("value").is(variableModel.getValue()); processVariableCollection.getEntries().get(1).onModel() - .assertThat().field("name").is(processVariableCollection.getEntries().get(1).onModel().getName()) - .and().field("type").is(processVariableCollection.getEntries().get(1).onModel().getType()) - .and().field("value").is(processVariableCollection.getEntries().get(1).onModel().getValue()); + .assertThat().field("name").is(variableModel1.getName()) + .and().field("type").is(variableModel1.getType()) + .and().field("value").is(variableModel1.getValue()); restClient.withWorkflowAPI().usingProcess(restProcessModel).getProcessVariables() - .assertThat().entriesListContains("name", processVariableCollection.getEntries().get(0).onModel().getName()) - .assertThat().entriesListContains("name", processVariableCollection.getEntries().get(1).onModel().getName()); + .assertThat().entriesListContains("name", variableModel.getName()) + .assertThat().entriesListContains("name", variableModel1.getName()); } @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, @@ -243,11 +243,11 @@ public class AddProcessVariablesFullTests extends RestTest processVariable = restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); processVariable.assertThat().field("name").isNull() - .and().field("type").is(processVariable.getType()) - .and().field("value").is(processVariable.getValue()); + .and().field("type").is(variableModel.getType()) + .and().field("value").is(variableModel.getValue()); restClient.withWorkflowAPI().usingProcess(restProcessModel).getProcessVariables() - .assertThat().entriesListContains("value", processVariable.getValue()); + .assertThat().entriesListContains("value", variableModel.getValue()); } @Bug(id="REPO-1987") @@ -263,12 +263,12 @@ public class AddProcessVariablesFullTests extends RestTest processVariable = restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); - processVariable.assertThat().field("name").is(processVariable.getName()) - .and().field("type").is(processVariable.getType()) - .and().field("value").is(processVariable.getValue()); + processVariable.assertThat().field("name").is(variableModel.getName()) + .and().field("type").is(variableModel.getType()) + .and().field("value").is(variableModel.getValue()); restClient.withWorkflowAPI().usingProcess(restProcessModel).getProcessVariables() - .assertThat().entriesListContains("name", processVariable.getName()); + .assertThat().entriesListContains("name", variableModel.getName()); } @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesSanityTests.java index 2e2243196..265c0e32e 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesSanityTests.java @@ -47,12 +47,12 @@ public class AddProcessVariablesSanityTests extends RestTest processVariable = restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); - processVariable.assertThat().field("name").is(processVariable.getName()) - .and().field("type").is(processVariable.getType()) - .and().field("value").is(processVariable.getValue()); + processVariable.assertThat().field("name").is(variableModel.getName()) + .and().field("type").is(variableModel.getType()) + .and().field("value").is(variableModel.getValue()); restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() - .assertThat().entriesListContains("name", processVariable.getName()); + .assertThat().entriesListContains("name", variableModel.getName()); } @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, @@ -70,24 +70,24 @@ public class AddProcessVariablesSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.CREATED); processVariableCollection.getEntries().get(0).onModel() - .assertThat().field("name").is( processVariableCollection.getEntries().get(0).onModel().getName()) - .and().field("type").is( processVariableCollection.getEntries().get(0).onModel().getType()) - .and().field("value").is( processVariableCollection.getEntries().get(0).onModel().getValue()); + .assertThat().field("name").is( variableModel.getName()) + .and().field("type").is( variableModel.getType()) + .and().field("value").is( variableModel.getValue()); processVariableCollection.getEntries().get(1).onModel() - .assertThat().field("name").is( processVariableCollection.getEntries().get(1).onModel().getName()) - .and().field("type").is( processVariableCollection.getEntries().get(1).onModel().getType()) - .and().field("value").is( processVariableCollection.getEntries().get(1).onModel().getValue()); + .assertThat().field("name").is(variableModel1.getName()) + .and().field("type").is(variableModel1.getType()) + .and().field("value").is(variableModel1.getValue()); processVariableCollection.getEntries().get(2).onModel() - .assertThat().field("name").is( processVariableCollection.getEntries().get(2).onModel().getName()) - .and().field("type").is( processVariableCollection.getEntries().get(2).onModel().getType()) - .and().field("value").is( processVariableCollection.getEntries().get(2).onModel().getValue()); + .assertThat().field("name").is(variableModel2.getName()) + .and().field("type").is(variableModel2.getType()) + .and().field("value").is(variableModel2.getValue()); restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() - .assertThat().entriesListContains("name", processVariableCollection.getEntries().get(1).onModel().getName()) - .assertThat().entriesListContains("name", processVariableCollection.getEntries().get(0).onModel().getName()) - .assertThat().entriesListContains("name", processVariableCollection.getEntries().get(2).onModel().getName()); + .assertThat().entriesListContains("name", variableModel.getName()) + .assertThat().entriesListContains("name", variableModel1.getName()) + .assertThat().entriesListContains("name", variableModel2.getName()); } @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, @@ -100,9 +100,9 @@ public class AddProcessVariablesSanityTests extends RestTest processVariable = restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); - processVariable.assertThat().field("name").is(processVariable.getName()) - .and().field("type").is(processVariable.getType()) - .and().field("value").is(processVariable.getValue()); + processVariable.assertThat().field("name").is(variableModel.getName()) + .and().field("type").is(variableModel.getType()) + .and().field("value").is(variableModel.getValue()); String newValue = RandomData.getRandomName("value"); variableModel.setValue(newValue); @@ -173,9 +173,9 @@ public class AddProcessVariablesSanityTests extends RestTest processVariable = restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); - processVariable.assertThat().field("name").is(processVariable.getName()) - .and().field("type").is(processVariable.getType()) - .and().field("value").is(processVariable.getValue()); + processVariable.assertThat().field("name").is(variableModel.getName()) + .and().field("type").is(variableModel.getType()) + .and().field("value").is(variableModel.getValue()); } @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesCoreTests.java index c82dfb159..eaca6d13e 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesCoreTests.java @@ -5,7 +5,6 @@ import org.alfresco.rest.RestTest; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestVariableModel; -import org.alfresco.rest.model.RestVariableModelsCollection; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TaskModel; From a9eb54f6444b5531ec3bc26b90fc738b5015f471 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Tue, 14 Feb 2017 15:45:32 +0200 Subject: [PATCH 1042/1491] fix imports in tests --- .../alfresco/rest/FunctionalCasesTests.java | 19 +++++++++++++++---- .../workflow/tasks/AddTaskItemCoreTests.java | 1 - 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java b/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java index ba8a8b826..d3598c42b 100644 --- a/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java +++ b/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java @@ -2,11 +2,20 @@ package org.alfresco.rest; import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.model.*; +import org.alfresco.rest.model.RestActivityModelsCollection; +import org.alfresco.rest.model.RestCommentModel; +import org.alfresco.rest.model.RestCommentModelsCollection; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestFavoriteSiteModel; +import org.alfresco.rest.model.RestPersonFavoritesModelsCollection; +import org.alfresco.rest.model.RestRatingModel; +import org.alfresco.rest.model.RestSiteMemberModel; +import org.alfresco.rest.model.RestSiteMembershipRequestModelsCollection; +import org.alfresco.rest.model.RestTagModel; +import org.alfresco.rest.model.RestTaskModel; import org.alfresco.utility.constants.ActivityType; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; @@ -28,7 +37,7 @@ public class FunctionalCasesTests extends RestTest private RestActivityModelsCollection activities; private FileModel file; private RestActivityModelsCollection restActivityModelsCollection; - private FolderModel folderInSite; + private FileModel fileInSite; private RestCommentModel commentModel; @@ -652,8 +661,10 @@ public class FunctionalCasesTests extends RestTest { UserModel newUser = dataUser.createRandomTestUser(); SiteModel userSiteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); + dataUser.addUserToSite(newUser, userSiteModel, UserRole.SiteCollaborator); - folderInSite = dataContent.usingUser(newUser).usingSite(userSiteModel).createFolder(); + dataContent.usingUser(newUser).usingSite(userSiteModel).createFolder(); + fileInSite = dataContent.usingUser(newUser).usingSite(userSiteModel).createContent(DocumentType.TEXT_PLAIN); String newContent = "This is a new comment added by " + newUser.getUsername(); commentModel = restClient.authenticateUser(newUser).withCoreAPI().usingResource(fileInSite).addComment(newContent); diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemCoreTests.java index f5077f526..566f83a7b 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemCoreTests.java @@ -5,7 +5,6 @@ import org.alfresco.rest.RestTest; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestItemModel; import org.alfresco.rest.model.RestVariableModel; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; From 774a2bec078af66b20b33666c7af03b628c243a7 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Tue, 14 Feb 2017 16:14:18 +0200 Subject: [PATCH 1043/1491] added Queryes GET /queries/nodes --- .../alfresco/rest/queries/QueriesTest.java | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/queries/QueriesTest.java diff --git a/e2e-test/java/org/alfresco/rest/queries/QueriesTest.java b/e2e-test/java/org/alfresco/rest/queries/QueriesTest.java new file mode 100644 index 000000000..50a75c436 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/queries/QueriesTest.java @@ -0,0 +1,49 @@ +package org.alfresco.rest.queries; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestNodeModelsCollection; +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; + +/** + * Handle requests on Queries + * + */ +public class QueriesTest extends RestTest +{ + + @TestRail(section = { TestGroup.REST_API, + TestGroup.QUERIES }, executionType = ExecutionType.REGRESSION, description = "Verify GET queries on queries/nodes returnes success status code") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) + public void getOnQueriesNodesRoute() throws Exception + { + restClient.authenticateUser(dataContent.getAdminUser()) + .withCoreAPI() + .usingQueries().findNodes(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + + restClient.assertLastError() + .containsErrorKey("Query 'term' not specified") + //and assert on summary too if you want + .containsSummary("Query 'term' not specified"); + + restClient.withCoreAPI() + .usingQueries() + .usingParams("term=ab") + .findNodes(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + + restClient.assertLastError() + .containsErrorKey("Query 'term' is too short"); + + /* + * now making the correct call with a valid term value + */ + RestNodeModelsCollection nodes = restClient.withCoreAPI().usingQueries().usingParams("term=name").findNodes(); + restClient.assertStatusCodeIs(HttpStatus.OK); + nodes.assertThat().entriesListIsNotEmpty(); + } +} From 451aad04353caba58a72a1b20e9172af2e4b358d Mon Sep 17 00:00:00 2001 From: Ana Bozianu Date: Tue, 14 Feb 2017 18:12:04 +0200 Subject: [PATCH 1044/1491] RM-4684 - create site request --- .../org/alfresco/rest/sites/SitesTests.java | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/sites/SitesTests.java diff --git a/e2e-test/java/org/alfresco/rest/sites/SitesTests.java b/e2e-test/java/org/alfresco/rest/sites/SitesTests.java new file mode 100644 index 000000000..6d17fdc79 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/sites/SitesTests.java @@ -0,0 +1,42 @@ +package org.alfresco.rest.sites; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestSiteBodyCreateModel; +import org.alfresco.rest.model.RestSiteModel; +import org.alfresco.utility.data.RandomData; +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.springframework.social.alfresco.api.entities.Site.Visibility; +import org.testng.annotations.Test; + +/** + * Handles tests related to api-explorer/#!/sites + * + * @author Ana Bozianu + */ +public class SitesTests extends RestTest +{ + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Tests the creation of a site") + public void testCreateSite() throws Exception + { + RestSiteBodyCreateModel site = new RestSiteBodyCreateModel(); + site.setId(RandomData.getRandomName("siteId")); + site.setTitle(RandomData.getRandomName("siteTitle")); + site.setDescription(RandomData.getRandomName("siteDescription")); + site.setVisibility(Visibility.PUBLIC); + + RestSiteModel createdSite = restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingSite("").createSite(site); + + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + createdSite.assertThat().field("id").is(site.getId()) + .assertThat().field("title").is(site.getTitle()) + .assertThat().field("description").is(site.getDescription()) + .assertThat().field("visibility").is(site.getVisibility()); + } + +} From 164e7b075687e48c3782f92b81f807c569be320e Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Wed, 15 Feb 2017 10:38:26 +0200 Subject: [PATCH 1045/1491] removed RestSiteBodyCreateModel this is a duplication of SiteModel --- .../java/org/alfresco/rest/sites/SitesTests.java | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/sites/SitesTests.java b/e2e-test/java/org/alfresco/rest/sites/SitesTests.java index 6d17fdc79..5e73fa1ff 100644 --- a/e2e-test/java/org/alfresco/rest/sites/SitesTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/SitesTests.java @@ -1,14 +1,12 @@ package org.alfresco.rest.sites; import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestSiteBodyCreateModel; import org.alfresco.rest.model.RestSiteModel; -import org.alfresco.utility.data.RandomData; +import org.alfresco.utility.model.SiteModel; 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.springframework.social.alfresco.api.entities.Site.Visibility; import org.testng.annotations.Test; /** @@ -23,12 +21,8 @@ public class SitesTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Tests the creation of a site") public void testCreateSite() throws Exception { - RestSiteBodyCreateModel site = new RestSiteBodyCreateModel(); - site.setId(RandomData.getRandomName("siteId")); - site.setTitle(RandomData.getRandomName("siteTitle")); - site.setDescription(RandomData.getRandomName("siteDescription")); - site.setVisibility(Visibility.PUBLIC); - + SiteModel site = RestSiteModel.getRandomSiteModel(); + RestSiteModel createdSite = restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingSite("").createSite(site); restClient.assertStatusCodeIs(HttpStatus.CREATED); From ea1112f47aac7a704ff500119bbd4e18307c47e3 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Wed, 15 Feb 2017 10:39:19 +0200 Subject: [PATCH 1046/1491] passing new site to usingSite(..) method and remove parameter on createSite() --- e2e-test/java/org/alfresco/rest/sites/SitesTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/sites/SitesTests.java b/e2e-test/java/org/alfresco/rest/sites/SitesTests.java index 5e73fa1ff..4ae25e6a2 100644 --- a/e2e-test/java/org/alfresco/rest/sites/SitesTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/SitesTests.java @@ -23,7 +23,7 @@ public class SitesTests extends RestTest { SiteModel site = RestSiteModel.getRandomSiteModel(); - RestSiteModel createdSite = restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingSite("").createSite(site); + RestSiteModel createdSite = restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingSite(site).createSite(); restClient.assertStatusCodeIs(HttpStatus.CREATED); From 5030a169396a2cff2df654fe8d5ed1a9793fe536 Mon Sep 17 00:00:00 2001 From: mionescu Date: Fri, 17 Feb 2017 09:45:39 +0200 Subject: [PATCH 1047/1491] updates --- .../processes/DeleteProcessVariableSanityTests.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableSanityTests.java index 8dbc52b16..7743ce292 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableSanityTests.java @@ -37,6 +37,7 @@ public class DeleteProcessVariableSanityTests extends RestTest siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().addProcess("activitiAdhoc", adminUser, false, Priority.Normal); } @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, @@ -44,11 +45,7 @@ public class DeleteProcessVariableSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public void deleteProcessVariable() throws Exception { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - restClient.authenticateUser(adminUser).withWorkflowAPI().addProcess("activitiAdhoc", adminUser, false, Priority.Normal); - RestProcessModelsCollection pmColl = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses(); - processModel = pmColl.assertThat().entriesListIsNotEmpty().when().getOneRandomEntry().onModel(); - + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); restClient.withWorkflowAPI().usingProcess(processModel).deleteProcessVariable(variableModel); @@ -63,7 +60,6 @@ public class DeleteProcessVariableSanityTests extends RestTest public void deleteProcessVariableUsingInvalidProcessId() throws Exception { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); processModel.setId("incorrectProcessId"); From dba14c72198cb1d6aeed38655ef9fe80ed5ca41d Mon Sep 17 00:00:00 2001 From: Michael Suzuki Date: Fri, 17 Feb 2017 17:18:44 +0000 Subject: [PATCH 1048/1491] Inital search rest api test --- .../org/alfresco/rest/search/SearchTest.java | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/search/SearchTest.java diff --git a/e2e-test/java/org/alfresco/rest/search/SearchTest.java b/e2e-test/java/org/alfresco/rest/search/SearchTest.java new file mode 100644 index 000000000..a443ea151 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/search/SearchTest.java @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2017 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.rest.search; + +import org.alfresco.rest.RestTest; +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.SiteModel; +import org.alfresco.utility.model.UserModel; +import org.testng.annotations.BeforeClass; + +/** + * Search end point Public API test. + * @author Michael Suzuki + * + */ +public class SearchTest extends RestTest +{ + UserModel userModel, adminUserModel; + SiteModel siteModel, privateSiteModel, moderatedSiteModel; + UserModel searchedUser; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + moderatedSiteModel = dataSite.usingUser(userModel).createModeratedRandomSite(); + + /* + * Create the following file structure for preconditions : + * - sourceFolder + * - suzuki + */ + NodesBuilder nodesBuilder = restClient.withCoreAPI().usingNode(ContentModel.my()).defineNodes(); + NodeDetail sourceFolder = nodesBuilder.folder("source"); + sourceFolder.file("suzuki"); + } +} From f831444249a5906998ceb1b55eda5306fd9608b9 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Mon, 20 Feb 2017 15:24:36 +0200 Subject: [PATCH 1049/1491] some sample usage --- .../org/alfresco/rest/search/SearchTest.java | 35 ++++++++++++++++--- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/SearchTest.java b/e2e-test/java/org/alfresco/rest/search/SearchTest.java index a443ea151..3e406c1df 100644 --- a/e2e-test/java/org/alfresco/rest/search/SearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/SearchTest.java @@ -19,12 +19,14 @@ package org.alfresco.rest.search; import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestNodeModelsCollection; 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.SiteModel; import org.alfresco.utility.model.UserModel; +import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; /** * Search end point Public API test. @@ -36,7 +38,8 @@ public class SearchTest extends RestTest UserModel userModel, adminUserModel; SiteModel siteModel, privateSiteModel, moderatedSiteModel; UserModel searchedUser; - + NodesBuilder nodesBuilder; + @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception { @@ -50,8 +53,30 @@ public class SearchTest extends RestTest * - sourceFolder * - suzuki */ - NodesBuilder nodesBuilder = restClient.withCoreAPI().usingNode(ContentModel.my()).defineNodes(); - NodeDetail sourceFolder = nodesBuilder.folder("source"); - sourceFolder.file("suzuki"); + nodesBuilder = restClient.authenticateUser(userModel).withCoreAPI().usingNode(ContentModel.my()).defineNodes(); + + nodesBuilder.folder("source") + .file("suzuki") + .file("suzuki-2"); + + //just for showing available properties + System.out.println(String.format("Source Folder Full Name [%s ] withd ID: %s",nodesBuilder.getNode("source").getName(), nodesBuilder.getNode("source").getId())); + System.out.println(String.format("Source File Full Name [%s ] withd ID: %s",nodesBuilder.getNode("suzuki").getName(), nodesBuilder.getNode("suzuki").getId())); + } + + @Test + public void searchCreatedData() throws Exception + { + RestNodeModelsCollection nodes = restClient.authenticateUser(userModel) + .withCoreAPI() + .usingParams("term=suzuki") + .usingQueries() + .findNodes(); + + restClient.assertStatusCodeIs(HttpStatus.OK); + + nodes.assertThat() + .entriesListIsNotEmpty() + .and().entriesListCountIs(2); } } From 9bb92273c0eccdf66dfa9c34e0c43437b2e9015a Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Mon, 20 Feb 2017 15:26:09 +0200 Subject: [PATCH 1050/1491] added new bug id and description updates --- .../tasks/UpdateTaskCoreTestsBulk2.java | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTestsBulk2.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTestsBulk2.java index 5cb4aa8a3..bce915178 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTestsBulk2.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTestsBulk2.java @@ -183,9 +183,9 @@ public class UpdateTaskCoreTestsBulk2 extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @Bug(id = "TBD") + @Bug(id = "REPO-2062") @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task owner cannot complete task with invalid name - (200))") + description = "Verify task owner cannot complete task with invalid name - Bad Request(400))") public void taskOwnerCannotCompleteTaskWithInvalidName() throws Exception { JsonObject inputJson = JsonBodyGenerator.defineJSON() @@ -205,7 +205,6 @@ public class UpdateTaskCoreTestsBulk2 extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @Bug(id = "TBD") @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify task owner cannot complete task with invalid Type - Bad Request(400))") public void taskOwnerCannotCompleteTaskWithInvalidType() throws Exception @@ -227,7 +226,7 @@ public class UpdateTaskCoreTestsBulk2 extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @Bug(id = "TBD") + @Bug(id = "REPO-2062") @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify task owner cannot complete task with invalid value - Bad Request(400))") public void taskOwnerCannotCompleteTaskWithInvalidValue() throws Exception @@ -330,9 +329,9 @@ public class UpdateTaskCoreTestsBulk2 extends RestTest } - @Bug(id = "TBD") //as per api-explorer: should not have OK status + @Bug(id = "REPO-2063") @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task assignee cannot delegate task to task owner - (200)") + description = "Verify task assignee cannot delegate task to task owner - (400)") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) public void taskAssigneeCannotDelegateTaskToTaskOwner() throws Exception { @@ -340,16 +339,16 @@ public class UpdateTaskCoreTestsBulk2 extends RestTest .add("state", "delegated") .add("assignee", owner.getUsername()).build(); - restTaskModel = restClient.authenticateUser(owner) + restTaskModel = restClient.authenticateUser(assigneeUser) .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); } @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @Bug(id = "TBD") + @Bug(id = "REPO-2063") @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task owner cannot delegate task to invalid assignee - (200)") - public void taskOwnerCannotDelegateTaskToInvalidAssignee() throws Exception + description = "Verify task assignee cannot delegate task to invalid assignee - (400)") + public void taskAssigneeCannotDelegateTaskToInvalidAssignee() throws Exception { UserModel invalidAssignee = new UserModel("invalidAssignee", "password"); @@ -357,7 +356,7 @@ public class UpdateTaskCoreTestsBulk2 extends RestTest .add("state", "delegated") .add("assignee", invalidAssignee.getUsername()).build(); - restTaskModel = restClient.authenticateUser(owner) + restTaskModel = restClient.authenticateUser(assigneeUser) .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); } From 0bce954f103089a81455c2cb5ba4081db0214c9e Mon Sep 17 00:00:00 2001 From: mionescu Date: Mon, 20 Feb 2017 15:50:16 +0200 Subject: [PATCH 1051/1491] test - re-structure test cases --- .../alfresco/rest/FunctionalCasesTests.java | 2 +- .../GetPeopleActivitiesCoreTests.java | 14 +++++------ .../GetPeopleActivitiesFullTests.java | 24 +++++++++---------- .../GetPeopleActivitiesSanityTests.java | 14 +++++------ .../{ => delete}/DeleteCommentCoreTests.java | 2 +- .../{ => delete}/DeleteCommentFullTests.java | 2 +- .../DeleteCommentSanityTests.java | 2 +- .../{ => get}/GetCommentsCoreTests.java | 2 +- .../{ => get}/GetCommentsFullTests.java | 2 +- .../{ => get}/GetCommentsSanityTests.java | 2 +- .../{ => post}/AddCommentCoreTests.java | 2 +- .../{ => post}/AddCommentSanityTests.java | 2 +- .../{ => post}/AddCommentsCoreTests.java | 2 +- .../{ => post}/AddCommentsFullTests.java | 2 +- .../{ => post}/AddCommentsSanityTests.java | 2 +- .../{ => put}/UpdateCommentCoreTests.java | 2 +- .../{ => put}/UpdateCommentFullTests.java | 2 +- .../{ => put}/UpdateCommentSanityTests.java | 2 +- .../{ => delete}/DeleteFavoriteCoreTests.java | 7 ++---- .../{ => delete}/DeleteFavoriteFullTests.java | 8 +++---- .../DeleteFavoriteSanityTests.java | 2 +- .../delete}/DeleteFavoriteSiteCoreTests.java | 2 +- .../delete}/DeleteFavoriteSiteFullTests.java | 8 +++---- .../DeleteFavoriteSiteSanityTests.java | 2 +- .../{ => get}/GetFavoriteCoreTests.java | 2 +- .../{ => get}/GetFavoriteFullTests.java | 2 +- .../{ => get}/GetFavoriteSanityTests.java | 2 +- .../get}/GetFavoriteSiteCoreTests.java | 2 +- .../get}/GetFavoriteSiteFullTests.java | 2 +- .../get}/GetFavoriteSiteSanityTests.java | 2 +- .../get}/GetFavoriteSitesCoreTests.java | 2 +- .../get}/GetFavoriteSitesFullTests.java | 2 +- .../get}/GetFavoriteSitesSanityTests.java | 2 +- .../{ => get}/GetFavoritesCoreTests.java | 2 +- .../{ => get}/GetFavoritesFullTests.java | 2 +- .../{ => get}/GetFavoritesSanityTests.java | 2 +- .../post}/AddFavoriteSiteCoreTests.java | 2 +- .../post}/AddFavoriteSiteFullTests.java | 6 ++--- .../post}/AddFavoriteSiteSanityTests.java | 2 +- .../{ => post}/AddFavoritesCoreTests.java | 2 +- .../{ => post}/AddFavoritesFullTests.java | 2 +- .../{ => post}/AddFavoritesSanityTests.java | 2 +- .../GetPeoplePreferenceCoreTests.java | 10 ++++---- .../GetPeoplePreferenceFullTests.java | 22 ++++++++--------- .../GetPeoplePreferenceSanityTests.java | 14 +++++------ .../GetPeoplePreferencesCoreTests.java | 14 +++++------ .../GetPeoplePreferencesFullTests.java | 14 +++++------ .../GetPeoplePreferencesSanityTests.java | 14 +++++------ .../{ => delete}/DeleteRatingCoreTests.java | 2 +- .../{ => delete}/DeleteRatingFullTests.java | 2 +- .../{ => delete}/DeleteRatingSanityTests.java | 2 +- .../ratings/{ => get}/GetRatingCoreTests.java | 2 +- .../ratings/{ => get}/GetRatingFullTests.java | 2 +- .../{ => get}/GetRatingSanityTests.java | 2 +- .../{ => get}/GetRatingsCoreTests.java | 2 +- .../{ => get}/GetRatingsFullTests.java | 2 +- .../{ => get}/GetRatingsSanityTests.java | 2 +- .../{ => post}/AddRatingCoreTests.java | 2 +- .../{ => post}/AddRatingFullTests.java | 2 +- .../{ => post}/AddRatingSanityTests.java | 2 +- .../delete}/DeleteSiteMemberCoreTests.java | 2 +- .../delete}/DeleteSiteMemberFullTests.java | 2 +- .../delete}/DeleteSiteMemberSanityTests.java | 2 +- .../DeleteSiteMembershipRequestCoreTests.java | 2 +- .../DeleteSiteMembershipRequestFullTests.java | 2 +- ...eleteSiteMembershipRequestSanityTests.java | 2 +- .../RemoveSiteMemberCoreTests.java | 2 +- .../RemoveSiteMemberFullTests.java | 2 +- .../RemoveSiteMemberSanityTests.java | 2 +- .../{ => get}/GetSiteContainerCoreTests.java | 2 +- .../{ => get}/GetSiteContainerFullTests.java | 2 +- .../GetSiteContainerSanityTests.java | 2 +- .../{ => get}/GetSiteContainersCoreTests.java | 2 +- .../{ => get}/GetSiteContainersFullTests.java | 2 +- .../GetSiteContainersSanityTests.java | 2 +- .../sites/{ => get}/GetSiteCoreTests.java | 2 +- .../sites/{ => get}/GetSiteFullTests.java | 2 +- .../{ => get}/GetSiteMemberCoreTests.java | 2 +- .../{ => get}/GetSiteMemberFullTests.java | 2 +- .../{ => get}/GetSiteMemberSanityTests.java | 2 +- .../{ => get}/GetSiteMembersCoreTests.java | 2 +- .../{ => get}/GetSiteMembersFullTests.java | 2 +- .../{ => get}/GetSiteMembersSanityTests.java | 2 +- .../get}/GetSiteMembershipCoreTests.java | 2 +- .../get}/GetSiteMembershipFullTests.java | 2 +- .../GetSiteMembershipRequestCoreTests.java | 2 +- .../GetSiteMembershipRequestFullTests.java | 2 +- .../GetSiteMembershipRequestSanityTests.java | 2 +- .../GetSiteMembershipRequestsCoreTests.java | 2 +- .../GetSiteMembershipRequestsFullTests.java | 2 +- .../GetSiteMembershipRequestsSanityTests.java | 2 +- .../get}/GetSiteMembershipSanityTests.java | 2 +- .../sites/{ => get}/GetSiteSanityTests.java | 2 +- .../sites/{ => get}/GetSitesCoreTests.java | 2 +- .../sites/{ => get}/GetSitesFullTests.java | 2 +- ...etSitesMembershipInformationCoreTests.java | 2 +- ...etSitesMembershipInformationFullTests.java | 2 +- ...SitesMembershipInformationSanityTests.java | 2 +- .../sites/{ => get}/GetSitesSanityTests.java | 2 +- .../{ => post}/AddSiteMemberCoreTests.java | 2 +- .../{ => post}/AddSiteMemberFullTests.java | 2 +- .../{ => post}/AddSiteMemberSanityTests.java | 2 +- .../AddSiteMembershipRequestCoreTests.java | 2 +- .../AddSiteMembershipRequestFullTests.java | 2 +- .../AddSiteMembershipRequestSanityTests.java | 2 +- .../{ => put}/UpdateSiteMemberCoreTests.java | 2 +- .../{ => put}/UpdateSiteMemberFullTests.java | 2 +- .../UpdateSiteMemberSanityTests.java | 2 +- .../UpdateSiteMembershipRequestCoreTests.java | 2 +- .../UpdateSiteMembershipRequestFullTests.java | 8 +++---- ...pdateSiteMembershipRequestSanityTests.java | 2 +- .../tags/{ => delete}/DeleteTagCoreTests.java | 2 +- .../tags/{ => delete}/DeleteTagFullTests.java | 2 +- .../{ => delete}/DeleteTagSanityTests.java | 2 +- .../tags/{ => get}/GetNodeTagsCoreTests.java | 2 +- .../tags/{ => get}/GetNodeTagsFullTests.java | 2 +- .../{ => get}/GetNodeTagsSanityTests.java | 2 +- .../rest/tags/{ => get}/GetTagCoreTests.java | 2 +- .../rest/tags/{ => get}/GetTagFullTests.java | 2 +- .../tags/{ => get}/GetTagSanityTests.java | 2 +- .../rest/tags/{ => get}/GetTagsCoreTests.java | 2 +- .../rest/tags/{ => get}/GetTagsFullTests.java | 2 +- .../tags/{ => get}/GetTagsSanityTests.java | 2 +- .../rest/tags/{ => post}/AddTagCoreTests.java | 2 +- .../rest/tags/{ => post}/AddTagFullTests.java | 2 +- .../tags/{ => post}/AddTagSanityTests.java | 2 +- .../tags/{ => post}/AddTagsSanityTests.java | 2 +- .../tags/{ => put}/UpdateTagCoreTests.java | 2 +- .../tags/{ => put}/UpdateTagFullTests.java | 2 +- .../tags/{ => put}/UpdateTagSanityTests.java | 2 +- .../DeleteDeploymentCoreFullTests.java | 2 +- .../DeleteDeploymentSanityTests.java | 2 +- .../{ => get}/GetDeploymentCoreTests.java | 2 +- .../{ => get}/GetDeploymentFullTests.java | 2 +- .../{ => get}/GetDeploymentSanityTests.java | 2 +- .../{ => get}/GetDeploymentsCoreTests.java | 2 +- .../{ => get}/GetDeploymentsFullTests.java | 2 +- .../{ => get}/GetDeploymentsSanityTests.java | 2 +- .../{ => delete}/DeleteProcessCoreTests.java | 8 +++---- .../{ => delete}/DeleteProcessFullTests.java | 4 ++-- .../DeleteProcessItemCoreTests.java | 8 +++---- .../DeleteProcessItemFullTests.java | 24 +++++++++---------- .../DeleteProcessItemSanityTests.java | 6 ++--- .../DeleteProcessSanityTests.java | 8 +++---- .../DeleteProcessVariableCoreTests.java | 10 ++++---- .../DeleteProcessVariableFullTests.java | 16 ++++++------- .../DeleteProcessVariableSanityTests.java | 6 ++--- .../{ => get}/GetProcessCoreTests.java | 10 ++++---- .../{ => get}/GetProcessFullTests.java | 8 +++---- .../{ => get}/GetProcessItemsCoreTests.java | 8 +++---- .../{ => get}/GetProcessItemsFullTests.java | 2 +- .../{ => get}/GetProcessItemsSanityTests.java | 2 +- .../{ => get}/GetProcessSanityTests.java | 2 +- .../{ => get}/GetProcessTasksCoreTests.java | 2 +- .../{ => get}/GetProcessTasksFullTests.java | 2 +- .../{ => get}/GetProcessTasksSanityTests.java | 2 +- .../GetProcessVariablesCoreTests.java | 12 +++++----- .../GetProcessVariablesFullTests.java | 18 +++++++------- .../GetProcessVariablesSanityTests.java | 6 ++--- .../{ => get}/GetProcessesCoreTests.java | 8 +++---- .../{ => get}/GetProcessesFullTests.java | 16 ++++++------- .../{ => get}/GetProcessesSanityTests.java | 10 ++++---- .../{ => post}/AddProcessCoreTests.java | 14 +++++------ .../{ => post}/AddProcessFullTests.java | 18 +++++++------- .../{ => post}/AddProcessItemCoreTests.java | 18 +++++++------- .../{ => post}/AddProcessItemFullTests.java | 6 ++--- .../{ => post}/AddProcessItemSanityTests.java | 10 ++++---- .../{ => post}/AddProcessSanityTests.java | 6 ++--- .../AddProcessVariableCoreTests.java | 8 +++---- .../AddProcessVariableFullTests.java | 8 +++---- .../AddProcessVariableSanityTests.java | 10 ++++---- .../AddProcessVariablesCoreTests.java | 14 +++++------ .../AddProcessVariablesFullTests.java | 20 ++++++++-------- .../AddProcessVariablesSanityTests.java | 16 ++++++------- .../{ => put}/UpdateProcessVariableTests.java | 14 +++++------ .../DeleteTaskVariableCoreTests.java | 2 +- .../DeleteTaskVariableFullTests.java | 2 +- .../DeleteTaskVariableSanityTests.java | 2 +- .../{ => delete}/RemoveTaskItemCoreTests.java | 2 +- .../{ => delete}/RemoveTaskItemFullTests.java | 2 +- .../RemoveTaskItemSanityTests.java | 2 +- .../{ => get}/GetTaskCandidatesCoreTests.java | 2 +- .../{ => get}/GetTaskCandidatesFullTests.java | 2 +- .../GetTaskCandidatesSanityTests.java | 2 +- .../tasks/{ => get}/GetTaskCoreTests.java | 2 +- .../{ => get}/GetTaskFormModelCoreTests.java | 2 +- .../{ => get}/GetTaskFormModelFullTests.java | 2 +- .../GetTaskFormModelSanityTests.java | 2 +- .../tasks/{ => get}/GetTaskFullTests.java | 2 +- .../{ => get}/GetTaskItemsCoreTests.java | 2 +- .../{ => get}/GetTaskItemsFullTests.java | 2 +- .../{ => get}/GetTaskItemsSanityTests.java | 2 +- .../tasks/{ => get}/GetTaskSanityTests.java | 2 +- .../{ => get}/GetTaskVariablesCoreTests.java | 2 +- .../{ => get}/GetTaskVariablesFullTests.java | 2 +- .../GetTaskVariablesSanityTests.java | 2 +- .../tasks/{ => get}/GetTasksCoreTests.java | 2 +- .../tasks/{ => get}/GetTasksFullTests.java | 2 +- .../tasks/{ => get}/GetTasksSanityTests.java | 2 +- .../{ => post}/AddTaskItemCoreTests.java | 2 +- .../{ => post}/AddTaskItemFullTests.java | 2 +- .../{ => post}/AddTaskItemSanityTests.java | 2 +- .../{ => post}/AddTaskVariablesCoreTests.java | 2 +- .../{ => post}/AddTaskVariablesFullTests.java | 2 +- .../AddTaskVariablesSanityTests.java | 2 +- .../tasks/{ => put}/UpdateTaskCoreTests.java | 2 +- .../{ => put}/UpdateTaskCoreTestsBulk2.java | 2 +- .../{ => put}/UpdateTaskCoreTestsBulk3.java | 2 +- .../{ => put}/UpdateTaskFullTestsBulk1.java | 2 +- .../{ => put}/UpdateTaskFullTestsBulk2.java | 2 +- .../{ => put}/UpdateTaskSanityTests.java | 2 +- .../UpdateTaskVariableCoreTests.java | 2 +- .../UpdateTaskVariableFullTests.java | 2 +- .../UpdateTaskVariableSanityTests.java | 2 +- 214 files changed, 430 insertions(+), 433 deletions(-) rename e2e-test/java/org/alfresco/rest/{people => activities}/GetPeopleActivitiesCoreTests.java (82%) rename e2e-test/java/org/alfresco/rest/{people => activities}/GetPeopleActivitiesFullTests.java (83%) rename e2e-test/java/org/alfresco/rest/{people => activities}/GetPeopleActivitiesSanityTests.java (80%) rename e2e-test/java/org/alfresco/rest/comments/{ => delete}/DeleteCommentCoreTests.java (97%) rename e2e-test/java/org/alfresco/rest/comments/{ => delete}/DeleteCommentFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/comments/{ => delete}/DeleteCommentSanityTests.java (97%) rename e2e-test/java/org/alfresco/rest/comments/{ => get}/GetCommentsCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/comments/{ => get}/GetCommentsFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/comments/{ => get}/GetCommentsSanityTests.java (97%) rename e2e-test/java/org/alfresco/rest/comments/{ => post}/AddCommentCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/comments/{ => post}/AddCommentSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/comments/{ => post}/AddCommentsCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/comments/{ => post}/AddCommentsFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/comments/{ => post}/AddCommentsSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/comments/{ => put}/UpdateCommentCoreTests.java (97%) rename e2e-test/java/org/alfresco/rest/comments/{ => put}/UpdateCommentFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/comments/{ => put}/UpdateCommentSanityTests.java (98%) rename e2e-test/java/org/alfresco/rest/favorites/{ => delete}/DeleteFavoriteCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/favorites/{ => delete}/DeleteFavoriteFullTests.java (98%) rename e2e-test/java/org/alfresco/rest/favorites/{ => delete}/DeleteFavoriteSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/{people => favorites/delete}/DeleteFavoriteSiteCoreTests.java (97%) rename e2e-test/java/org/alfresco/rest/{people => favorites/delete}/DeleteFavoriteSiteFullTests.java (96%) rename e2e-test/java/org/alfresco/rest/{people => favorites/delete}/DeleteFavoriteSiteSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/favorites/{ => get}/GetFavoriteCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/favorites/{ => get}/GetFavoriteFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/favorites/{ => get}/GetFavoriteSanityTests.java (98%) rename e2e-test/java/org/alfresco/rest/{people => favorites/get}/GetFavoriteSiteCoreTests.java (98%) rename e2e-test/java/org/alfresco/rest/{people => favorites/get}/GetFavoriteSiteFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/{people => favorites/get}/GetFavoriteSiteSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/{people => favorites/get}/GetFavoriteSitesCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/{people => favorites/get}/GetFavoriteSitesFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/{people => favorites/get}/GetFavoriteSitesSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/favorites/{ => get}/GetFavoritesCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/favorites/{ => get}/GetFavoritesFullTests.java (98%) rename e2e-test/java/org/alfresco/rest/favorites/{ => get}/GetFavoritesSanityTests.java (98%) rename e2e-test/java/org/alfresco/rest/{people => favorites/post}/AddFavoriteSiteCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/{people => favorites/post}/AddFavoriteSiteFullTests.java (98%) rename e2e-test/java/org/alfresco/rest/{people => favorites/post}/AddFavoriteSiteSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/favorites/{ => post}/AddFavoritesCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/favorites/{ => post}/AddFavoritesFullTests.java (98%) rename e2e-test/java/org/alfresco/rest/favorites/{ => post}/AddFavoritesSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/{people => preferences}/GetPeoplePreferenceCoreTests.java (78%) rename e2e-test/java/org/alfresco/rest/{people => preferences}/GetPeoplePreferenceFullTests.java (91%) rename e2e-test/java/org/alfresco/rest/{people => preferences}/GetPeoplePreferenceSanityTests.java (81%) rename e2e-test/java/org/alfresco/rest/{people => preferences}/GetPeoplePreferencesCoreTests.java (80%) rename e2e-test/java/org/alfresco/rest/{people => preferences}/GetPeoplePreferencesFullTests.java (83%) rename e2e-test/java/org/alfresco/rest/{people => preferences}/GetPeoplePreferencesSanityTests.java (81%) rename e2e-test/java/org/alfresco/rest/ratings/{ => delete}/DeleteRatingCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/ratings/{ => delete}/DeleteRatingFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/ratings/{ => delete}/DeleteRatingSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/ratings/{ => get}/GetRatingCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/ratings/{ => get}/GetRatingFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/ratings/{ => get}/GetRatingSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/ratings/{ => get}/GetRatingsCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/ratings/{ => get}/GetRatingsFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/ratings/{ => get}/GetRatingsSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/ratings/{ => post}/AddRatingCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/ratings/{ => post}/AddRatingFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/ratings/{ => post}/AddRatingSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/{people => sites/delete}/DeleteSiteMemberCoreTests.java (98%) rename e2e-test/java/org/alfresco/rest/{people => sites/delete}/DeleteSiteMemberFullTests.java (98%) rename e2e-test/java/org/alfresco/rest/{people => sites/delete}/DeleteSiteMemberSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/{people => sites/delete}/DeleteSiteMembershipRequestCoreTests.java (98%) rename e2e-test/java/org/alfresco/rest/{people => sites/delete}/DeleteSiteMembershipRequestFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/{people => sites/delete}/DeleteSiteMembershipRequestSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/sites/{ => delete}/RemoveSiteMemberCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/sites/{ => delete}/RemoveSiteMemberFullTests.java (97%) rename e2e-test/java/org/alfresco/rest/sites/{ => delete}/RemoveSiteMemberSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/sites/{ => get}/GetSiteContainerCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/sites/{ => get}/GetSiteContainerFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/sites/{ => get}/GetSiteContainerSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/sites/{ => get}/GetSiteContainersCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/sites/{ => get}/GetSiteContainersFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/sites/{ => get}/GetSiteContainersSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/sites/{ => get}/GetSiteCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/sites/{ => get}/GetSiteFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/sites/{ => get}/GetSiteMemberCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/sites/{ => get}/GetSiteMemberFullTests.java (98%) rename e2e-test/java/org/alfresco/rest/sites/{ => get}/GetSiteMemberSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/sites/{ => get}/GetSiteMembersCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/sites/{ => get}/GetSiteMembersFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/sites/{ => get}/GetSiteMembersSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/{people => sites/get}/GetSiteMembershipCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/{people => sites/get}/GetSiteMembershipFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/{people => sites/get}/GetSiteMembershipRequestCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/{people => sites/get}/GetSiteMembershipRequestFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/{people => sites/get}/GetSiteMembershipRequestSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/{people => sites/get}/GetSiteMembershipRequestsCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/{people => sites/get}/GetSiteMembershipRequestsFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/{people => sites/get}/GetSiteMembershipRequestsSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/{people => sites/get}/GetSiteMembershipSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/sites/{ => get}/GetSiteSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/sites/{ => get}/GetSitesCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/sites/{ => get}/GetSitesFullTests.java (98%) rename e2e-test/java/org/alfresco/rest/{people => sites/get}/GetSitesMembershipInformationCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/{people => sites/get}/GetSitesMembershipInformationFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/{people => sites/get}/GetSitesMembershipInformationSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/sites/{ => get}/GetSitesSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/sites/{ => post}/AddSiteMemberCoreTests.java (98%) rename e2e-test/java/org/alfresco/rest/sites/{ => post}/AddSiteMemberFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/sites/{ => post}/AddSiteMemberSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/{people => sites/post}/AddSiteMembershipRequestCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/{people => sites/post}/AddSiteMembershipRequestFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/{people => sites/post}/AddSiteMembershipRequestSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/sites/{ => put}/UpdateSiteMemberCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/sites/{ => put}/UpdateSiteMemberFullTests.java (98%) rename e2e-test/java/org/alfresco/rest/sites/{ => put}/UpdateSiteMemberSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/{people => sites/put}/UpdateSiteMembershipRequestCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/{people => sites/put}/UpdateSiteMembershipRequestFullTests.java (98%) rename e2e-test/java/org/alfresco/rest/{people => sites/put}/UpdateSiteMembershipRequestSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/tags/{ => delete}/DeleteTagCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/tags/{ => delete}/DeleteTagFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/tags/{ => delete}/DeleteTagSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/tags/{ => get}/GetNodeTagsCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/tags/{ => get}/GetNodeTagsFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/tags/{ => get}/GetNodeTagsSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/tags/{ => get}/GetTagCoreTests.java (98%) rename e2e-test/java/org/alfresco/rest/tags/{ => get}/GetTagFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/tags/{ => get}/GetTagSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/tags/{ => get}/GetTagsCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/tags/{ => get}/GetTagsFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/tags/{ => get}/GetTagsSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/tags/{ => post}/AddTagCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/tags/{ => post}/AddTagFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/tags/{ => post}/AddTagSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/tags/{ => post}/AddTagsSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/tags/{ => put}/UpdateTagCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/tags/{ => put}/UpdateTagFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/tags/{ => put}/UpdateTagSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/deployments/{ => delete}/DeleteDeploymentCoreFullTests.java (97%) rename e2e-test/java/org/alfresco/rest/workflow/deployments/{ => delete}/DeleteDeploymentSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/deployments/{ => get}/GetDeploymentCoreTests.java (98%) rename e2e-test/java/org/alfresco/rest/workflow/deployments/{ => get}/GetDeploymentFullTests.java (98%) rename e2e-test/java/org/alfresco/rest/workflow/deployments/{ => get}/GetDeploymentSanityTests.java (98%) rename e2e-test/java/org/alfresco/rest/workflow/deployments/{ => get}/GetDeploymentsCoreTests.java (98%) rename e2e-test/java/org/alfresco/rest/workflow/deployments/{ => get}/GetDeploymentsFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/deployments/{ => get}/GetDeploymentsSanityTests.java (98%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{ => delete}/DeleteProcessCoreTests.java (93%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{ => delete}/DeleteProcessFullTests.java (92%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{ => delete}/DeleteProcessItemCoreTests.java (91%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{ => delete}/DeleteProcessItemFullTests.java (90%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{ => delete}/DeleteProcessItemSanityTests.java (91%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{ => delete}/DeleteProcessSanityTests.java (88%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{ => delete}/DeleteProcessVariableCoreTests.java (91%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{ => delete}/DeleteProcessVariableFullTests.java (94%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{ => delete}/DeleteProcessVariableSanityTests.java (91%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{ => get}/GetProcessCoreTests.java (90%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{ => get}/GetProcessFullTests.java (92%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{ => get}/GetProcessItemsCoreTests.java (89%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{ => get}/GetProcessItemsFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{ => get}/GetProcessItemsSanityTests.java (98%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{ => get}/GetProcessSanityTests.java (98%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{ => get}/GetProcessTasksCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{ => get}/GetProcessTasksFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{ => get}/GetProcessTasksSanityTests.java (98%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{ => get}/GetProcessVariablesCoreTests.java (90%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{ => get}/GetProcessVariablesFullTests.java (89%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{ => get}/GetProcessVariablesSanityTests.java (90%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{ => get}/GetProcessesCoreTests.java (91%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{ => get}/GetProcessesFullTests.java (91%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{ => get}/GetProcessesSanityTests.java (86%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{ => post}/AddProcessCoreTests.java (92%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{ => post}/AddProcessFullTests.java (91%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{ => post}/AddProcessItemCoreTests.java (94%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{ => post}/AddProcessItemFullTests.java (96%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{ => post}/AddProcessItemSanityTests.java (94%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{ => post}/AddProcessSanityTests.java (94%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{ => post}/AddProcessVariableCoreTests.java (96%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{ => post}/AddProcessVariableFullTests.java (96%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{ => post}/AddProcessVariableSanityTests.java (92%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{ => post}/AddProcessVariablesCoreTests.java (93%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{ => post}/AddProcessVariablesFullTests.java (95%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{ => post}/AddProcessVariablesSanityTests.java (93%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{ => put}/UpdateProcessVariableTests.java (90%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{ => delete}/DeleteTaskVariableCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{ => delete}/DeleteTaskVariableFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{ => delete}/DeleteTaskVariableSanityTests.java (98%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{ => delete}/RemoveTaskItemCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{ => delete}/RemoveTaskItemFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{ => delete}/RemoveTaskItemSanityTests.java (98%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{ => get}/GetTaskCandidatesCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{ => get}/GetTaskCandidatesFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{ => get}/GetTaskCandidatesSanityTests.java (98%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{ => get}/GetTaskCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{ => get}/GetTaskFormModelCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{ => get}/GetTaskFormModelFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{ => get}/GetTaskFormModelSanityTests.java (98%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{ => get}/GetTaskFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{ => get}/GetTaskItemsCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{ => get}/GetTaskItemsFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{ => get}/GetTaskItemsSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{ => get}/GetTaskSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{ => get}/GetTaskVariablesCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{ => get}/GetTaskVariablesFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{ => get}/GetTaskVariablesSanityTests.java (98%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{ => get}/GetTasksCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{ => get}/GetTasksFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{ => get}/GetTasksSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{ => post}/AddTaskItemCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{ => post}/AddTaskItemFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{ => post}/AddTaskItemSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{ => post}/AddTaskVariablesCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{ => post}/AddTaskVariablesFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{ => post}/AddTaskVariablesSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{ => put}/UpdateTaskCoreTests.java (98%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{ => put}/UpdateTaskCoreTestsBulk2.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{ => put}/UpdateTaskCoreTestsBulk3.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{ => put}/UpdateTaskFullTestsBulk1.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{ => put}/UpdateTaskFullTestsBulk2.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{ => put}/UpdateTaskSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{ => put}/UpdateTaskVariableCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{ => put}/UpdateTaskVariableFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{ => put}/UpdateTaskVariableSanityTests.java (99%) diff --git a/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java b/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java index d3598c42b..f6b22487c 100644 --- a/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java +++ b/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java @@ -656,7 +656,7 @@ public class FunctionalCasesTests extends RestTest */ @Bug(id="REPO-1830") @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its activities with Rest API and response is successful") + @TestRail(section = { TestGroup.REST_API, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its activities with Rest API and response is successful") public void userGetsItsPeopleActivities() throws Exception { UserModel newUser = dataUser.createRandomTestUser(); diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesCoreTests.java b/e2e-test/java/org/alfresco/rest/activities/GetPeopleActivitiesCoreTests.java similarity index 82% rename from e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesCoreTests.java rename to e2e-test/java/org/alfresco/rest/activities/GetPeopleActivitiesCoreTests.java index cd86f55be..54256694a 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/activities/GetPeopleActivitiesCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.people; +package org.alfresco.rest.activities; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; @@ -51,7 +51,7 @@ public class GetPeopleActivitiesCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot get activities for inexistent user with Rest API and response is 404") + @TestRail(section = { TestGroup.REST_API, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot get activities for inexistent user with Rest API and response is 404") public void userCannotGetPeopleActivitiesForInexistentPersonId() throws Exception { UserModel inexistentUserName = new UserModel("inexistent", "password"); @@ -65,7 +65,7 @@ public class GetPeopleActivitiesCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its activities for inexistent siteId with Rest API and response is 404") + @TestRail(section = { TestGroup.REST_API, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its activities for inexistent siteId with Rest API and response is 404") public void userGetItsPeopleActivitiesForInexistentSite() throws Exception { restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingUser(userModel).usingParams(String.format("siteId=inexistent")).getPersonActivities(); @@ -77,7 +77,7 @@ public class GetPeopleActivitiesCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities with invald skipCount parameter with Rest API and response is 400") + @TestRail(section = { TestGroup.REST_API, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities with invald skipCount parameter with Rest API and response is 400") public void userGetPeopleActivitiesUsingInvalidSkipCountParameter() throws Exception { restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingMe().usingParams("skipCount=-1").getPersonActivities(); @@ -89,7 +89,7 @@ public class GetPeopleActivitiesCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities with invalid maxItems parameter with Rest API and response is 400") + @TestRail(section = { TestGroup.REST_API, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities with invalid maxItems parameter with Rest API and response is 400") public void userGetPeopleActivitiesUsingInvalidMaxItemsParameter() throws Exception { restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingMe().usingParams("maxItems=0").getPersonActivities(); @@ -101,7 +101,7 @@ public class GetPeopleActivitiesCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities using invalid value for parameter 'who'with Rest API and response is 400") + @TestRail(section = { TestGroup.REST_API, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities using invalid value for parameter 'who'with Rest API and response is 400") public void userGetsPeopleActivitiesUsingInvalidValueForWhoParameter() throws Exception { restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingUser(userModel).usingParams("who=mee").getPersonActivities(); @@ -113,7 +113,7 @@ public class GetPeopleActivitiesCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities successfully using parameter 'who' with 'others' value with Rest API") + @TestRail(section = { TestGroup.REST_API, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities successfully using parameter 'who' with 'others' value with Rest API") public void userGetsPeopleActivitiesUsingOthersForWhoParameter() throws Exception { restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingUser(userModel).usingParams("who=others").getPersonActivities(); diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesFullTests.java b/e2e-test/java/org/alfresco/rest/activities/GetPeopleActivitiesFullTests.java similarity index 83% rename from e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesFullTests.java rename to e2e-test/java/org/alfresco/rest/activities/GetPeopleActivitiesFullTests.java index 167480f93..3a0e11d1b 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/activities/GetPeopleActivitiesFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.people; +package org.alfresco.rest.activities; import java.util.ArrayList; import java.util.List; @@ -59,7 +59,7 @@ public class GetPeopleActivitiesFullTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its activities using me with Rest API and response is successful") + @TestRail(section = { TestGroup.REST_API, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its activities using me with Rest API and response is successful") public void userGetsItsPeopleActivitiesUsingMe() throws Exception { restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingMe().getPersonActivities(); @@ -79,7 +79,7 @@ public class GetPeopleActivitiesFullTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify activity summary from user gets activities response with Rest API") + @TestRail(section = { TestGroup.REST_API, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify activity summary from user gets activities response with Rest API") public void userGetPeopleActivitiesWithActivitySummaryCheck() throws Exception { restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingMe().usingParams(String.format("siteId=%s", siteModel1.getId())).getPersonActivities(); @@ -94,7 +94,7 @@ public class GetPeopleActivitiesFullTests extends RestTest @Bug(id = "REPO-1911") @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot get activities for empty user with Rest API and response is 400") + @TestRail(section = { TestGroup.REST_API,TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot get activities for empty user with Rest API and response is 400") public void userCannotGetPeopleActivitiesForEmptyPersonId() throws Exception { UserModel emptyUserName = new UserModel("", "password"); @@ -108,7 +108,7 @@ public class GetPeopleActivitiesFullTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities successfully using parameter 'who' with 'me' value with Rest API") + @TestRail(section = { TestGroup.REST_API, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities successfully using parameter 'who' with 'me' value with Rest API") public void userGetsPeopleActivitiesUsingMeForWhoParameter() throws Exception { restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingUser(userModel).usingParams("who=me").getPersonActivities(); @@ -120,7 +120,7 @@ public class GetPeopleActivitiesFullTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its activities for siteId specified in siteId parameter using me with Rest API and response is successful") + @TestRail(section = { TestGroup.REST_API,TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its activities for siteId specified in siteId parameter using me with Rest API and response is successful") public void userGetItsPeopleActivitiesForASpecificSite() throws Exception { restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingUser(userModel).usingParams(String.format("siteId=%s", siteModel1.getId())).getPersonActivities(); @@ -131,7 +131,7 @@ public class GetPeopleActivitiesFullTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities for user with no activities with Rest API and response is successful") + @TestRail(section = { TestGroup.REST_API, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities for user with no activities with Rest API and response is successful") public void userGetPeopleActivitiesForUserWithNoActivities() throws Exception { UserModel userNoActivities = dataUser.createRandomTestUser(); @@ -156,7 +156,7 @@ public class GetPeopleActivitiesFullTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot get activities for siteId that user doesn't have access to with Rest API and response is not found") + @TestRail(section = { TestGroup.REST_API, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot get activities for siteId that user doesn't have access to with Rest API and response is not found") public void userGetPeopleActivitiesForASiteWithNoAccess() throws Exception { SiteModel siteNoAccess = dataSite.usingUser(managerUser).createPrivateRandomSite(); @@ -167,7 +167,7 @@ public class GetPeopleActivitiesFullTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot get activities for another user with Rest API and response is permission denied") + @TestRail(section = { TestGroup.REST_API, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot get activities for another user with Rest API and response is permission denied") public void userGetPeopleActivitiesForAnotherUser() throws Exception { restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingUser(managerUser).getPersonActivities(); @@ -176,7 +176,7 @@ public class GetPeopleActivitiesFullTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities with properties parameter applied with Rest API and response is successful") + @TestRail(section = { TestGroup.REST_API, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities with properties parameter applied with Rest API and response is successful") public void userGetPeopleActivitiesUsingPropertiesParameter() throws Exception { restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingMe().usingParams("properties=postPersonId").getPersonActivities(); @@ -194,7 +194,7 @@ public class GetPeopleActivitiesFullTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities with skipCount parameter applied with Rest API and response is successful") + @TestRail(section = { TestGroup.REST_API, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities with skipCount parameter applied with Rest API and response is successful") public void userGetPeopleActivitiesUsingSkipCountParameter() throws Exception { restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingMe().getPersonActivities(); @@ -213,7 +213,7 @@ public class GetPeopleActivitiesFullTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities with maxItems parameter applied with Rest API and response is successful") + @TestRail(section = { TestGroup.REST_API, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities with maxItems parameter applied with Rest API and response is successful") public void userGetPeopleActivitiesUsingMaxItemsParameter() throws Exception { restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingMe().getPersonActivities(); diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java b/e2e-test/java/org/alfresco/rest/activities/GetPeopleActivitiesSanityTests.java similarity index 80% rename from e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java rename to e2e-test/java/org/alfresco/rest/activities/GetPeopleActivitiesSanityTests.java index 618d7457c..1d7c2a8bf 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleActivitiesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/activities/GetPeopleActivitiesSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.people; +package org.alfresco.rest.activities; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; @@ -44,7 +44,7 @@ public class GetPeopleActivitiesSanityTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.SANITY, description = "Verify manager user gets its activities with Rest API and response is successful") + @TestRail(section = { TestGroup.REST_API, TestGroup.ACTIVITIES }, executionType = ExecutionType.SANITY, description = "Verify manager user gets its activities with Rest API and response is successful") public void managerUserShouldGetPeopleActivitiesList() throws Exception { UserModel managerUser = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); @@ -56,7 +56,7 @@ public class GetPeopleActivitiesSanityTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.SANITY, description = "Verify collaborator user gets its activities with Rest API and response is successful") + @TestRail(section = { TestGroup.REST_API, TestGroup.ACTIVITIES }, executionType = ExecutionType.SANITY, description = "Verify collaborator user gets its activities with Rest API and response is successful") public void collaboratorUserShouldGetPeopleActivitiesList() throws Exception { UserModel collaboratorUser = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); @@ -68,7 +68,7 @@ public class GetPeopleActivitiesSanityTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.SANITY, description = "Verify contributor user gets its activities with Rest API and response is successful") + @TestRail(section = { TestGroup.REST_API, TestGroup.ACTIVITIES }, executionType = ExecutionType.SANITY, description = "Verify contributor user gets its activities with Rest API and response is successful") public void contributorUserShouldGetPeopleActivitiesList() throws Exception { UserModel contributorUser = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); @@ -80,7 +80,7 @@ public class GetPeopleActivitiesSanityTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.SANITY, description = "Verify consumer user gets its activities with Rest API and response is successful") + @TestRail(section = { TestGroup.REST_API, TestGroup.ACTIVITIES }, executionType = ExecutionType.SANITY, description = "Verify consumer user gets its activities with Rest API and response is successful") public void consumerUserShouldGetPeopleActivitiesList() throws Exception { UserModel consumerUser = usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer); @@ -91,7 +91,7 @@ public class GetPeopleActivitiesSanityTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.SANITY, description = "Verify admin user gets another user activities with Rest API and response is successful") + @TestRail(section = { TestGroup.REST_API, TestGroup.ACTIVITIES }, executionType = ExecutionType.SANITY, description = "Verify admin user gets another user activities with Rest API and response is successful") public void adminUserShouldGetPeopleActivitiesList() throws Exception { restActivityModelsCollection = restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingUser(userModel).getPersonActivities(); @@ -100,7 +100,7 @@ public class GetPeopleActivitiesSanityTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is NOT Authorized to gets another user activities with Rest API") + @TestRail(section = { TestGroup.REST_API, TestGroup.ACTIVITIES }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is NOT Authorized to gets another user activities with Rest API") public void unauthenticatedUserShouldNotGetPeopleActivitiesList() throws Exception { restClient.authenticateUser(unauthenticatedUser).withCoreAPI().usingUser(userModel).getPersonActivities(); diff --git a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentCoreTests.java b/e2e-test/java/org/alfresco/rest/comments/delete/DeleteCommentCoreTests.java similarity index 97% rename from e2e-test/java/org/alfresco/rest/comments/DeleteCommentCoreTests.java rename to e2e-test/java/org/alfresco/rest/comments/delete/DeleteCommentCoreTests.java index bcfb1850c..411ec166d 100644 --- a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/delete/DeleteCommentCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.comments; +package org.alfresco.rest.comments.delete; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentFullTests.java b/e2e-test/java/org/alfresco/rest/comments/delete/DeleteCommentFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/comments/DeleteCommentFullTests.java rename to e2e-test/java/org/alfresco/rest/comments/delete/DeleteCommentFullTests.java index 9f3037f1d..b6c605ba1 100644 --- a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentFullTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/delete/DeleteCommentFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.comments; +package org.alfresco.rest.comments.delete; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/delete/DeleteCommentSanityTests.java similarity index 97% rename from e2e-test/java/org/alfresco/rest/comments/DeleteCommentSanityTests.java rename to e2e-test/java/org/alfresco/rest/comments/delete/DeleteCommentSanityTests.java index aecc7fd06..45551d045 100644 --- a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/delete/DeleteCommentSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.comments; +package org.alfresco.rest.comments.delete; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/comments/GetCommentsCoreTests.java b/e2e-test/java/org/alfresco/rest/comments/get/GetCommentsCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/comments/GetCommentsCoreTests.java rename to e2e-test/java/org/alfresco/rest/comments/get/GetCommentsCoreTests.java index 1fd7a1f5c..e494f07cd 100644 --- a/e2e-test/java/org/alfresco/rest/comments/GetCommentsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/get/GetCommentsCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.comments; +package org.alfresco.rest.comments.get; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/comments/GetCommentsFullTests.java b/e2e-test/java/org/alfresco/rest/comments/get/GetCommentsFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/comments/GetCommentsFullTests.java rename to e2e-test/java/org/alfresco/rest/comments/get/GetCommentsFullTests.java index b7021f602..00f820e3c 100644 --- a/e2e-test/java/org/alfresco/rest/comments/GetCommentsFullTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/get/GetCommentsFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.comments; +package org.alfresco.rest.comments.get; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/get/GetCommentsSanityTests.java similarity index 97% rename from e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java rename to e2e-test/java/org/alfresco/rest/comments/get/GetCommentsSanityTests.java index f781e0eea..534e1389b 100644 --- a/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/get/GetCommentsSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.comments; +package org.alfresco.rest.comments.get; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentCoreTests.java b/e2e-test/java/org/alfresco/rest/comments/post/AddCommentCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/comments/AddCommentCoreTests.java rename to e2e-test/java/org/alfresco/rest/comments/post/AddCommentCoreTests.java index 7f6955cd9..d118285d8 100644 --- a/e2e-test/java/org/alfresco/rest/comments/AddCommentCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/post/AddCommentCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.comments; +package org.alfresco.rest.comments.post; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/post/AddCommentSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java rename to e2e-test/java/org/alfresco/rest/comments/post/AddCommentSanityTests.java index 93606fb20..1bde6f02f 100644 --- a/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/post/AddCommentSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.comments; +package org.alfresco.rest.comments.post; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentsCoreTests.java b/e2e-test/java/org/alfresco/rest/comments/post/AddCommentsCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/comments/AddCommentsCoreTests.java rename to e2e-test/java/org/alfresco/rest/comments/post/AddCommentsCoreTests.java index 2cdcd2cf3..6482dfaf4 100644 --- a/e2e-test/java/org/alfresco/rest/comments/AddCommentsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/post/AddCommentsCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.comments; +package org.alfresco.rest.comments.post; import java.util.List; diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentsFullTests.java b/e2e-test/java/org/alfresco/rest/comments/post/AddCommentsFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/comments/AddCommentsFullTests.java rename to e2e-test/java/org/alfresco/rest/comments/post/AddCommentsFullTests.java index 58cd1f92a..d020fa304 100644 --- a/e2e-test/java/org/alfresco/rest/comments/AddCommentsFullTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/post/AddCommentsFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.comments; +package org.alfresco.rest.comments.post; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/post/AddCommentsSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java rename to e2e-test/java/org/alfresco/rest/comments/post/AddCommentsSanityTests.java index 5ec6167e1..b3f6972ee 100644 --- a/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/post/AddCommentsSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.comments; +package org.alfresco.rest.comments.post; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentCoreTests.java b/e2e-test/java/org/alfresco/rest/comments/put/UpdateCommentCoreTests.java similarity index 97% rename from e2e-test/java/org/alfresco/rest/comments/UpdateCommentCoreTests.java rename to e2e-test/java/org/alfresco/rest/comments/put/UpdateCommentCoreTests.java index 32caa9b5e..0fa97f1c6 100644 --- a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/put/UpdateCommentCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.comments; +package org.alfresco.rest.comments.put; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentFullTests.java b/e2e-test/java/org/alfresco/rest/comments/put/UpdateCommentFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/comments/UpdateCommentFullTests.java rename to e2e-test/java/org/alfresco/rest/comments/put/UpdateCommentFullTests.java index f96cf475a..42a1f66ae 100644 --- a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentFullTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/put/UpdateCommentFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.comments; +package org.alfresco.rest.comments.put; import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.CMISUtil.DocumentType; diff --git a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/put/UpdateCommentSanityTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/comments/UpdateCommentSanityTests.java rename to e2e-test/java/org/alfresco/rest/comments/put/UpdateCommentSanityTests.java index c724ef6e3..4a8c58ea6 100644 --- a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/put/UpdateCommentSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.comments; +package org.alfresco.rest.comments.put; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteCoreTests.java b/e2e-test/java/org/alfresco/rest/favorites/delete/DeleteFavoriteCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteCoreTests.java rename to e2e-test/java/org/alfresco/rest/favorites/delete/DeleteFavoriteCoreTests.java index ac965bcf9..51ac36648 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/delete/DeleteFavoriteCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.favorites; +package org.alfresco.rest.favorites.delete; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; @@ -167,8 +167,5 @@ public class DeleteFavoriteCoreTests extends RestTest .assertStatusCodeIs(HttpStatus.FORBIDDEN) .assertLastError() .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - - + } } diff --git a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteFullTests.java b/e2e-test/java/org/alfresco/rest/favorites/delete/DeleteFavoriteFullTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteFullTests.java rename to e2e-test/java/org/alfresco/rest/favorites/delete/DeleteFavoriteFullTests.java index 854fd3451..4147fe7c8 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteFullTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/delete/DeleteFavoriteFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.favorites; +package org.alfresco.rest.favorites.delete; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; @@ -176,7 +176,7 @@ public class DeleteFavoriteFullTests extends RestTest } @Bug(id="MNT-16904") - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify tenant user is not able to delete favorites using an invalid network ID") @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES,TestGroup.NETWORKS, TestGroup.FULL }) public void tenantIsNotAbleToDeleteFavoriteSiteWithInvalidNetworkID() throws JsonToModelConversionException, Exception @@ -199,7 +199,7 @@ public class DeleteFavoriteFullTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE); } - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES}, executionType = ExecutionType.REGRESSION, description = "Verify tenant user deletes favorites site and status code is (204)") @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES,TestGroup.NETWORKS, TestGroup.FULL }) public void tenantDeleteFavoriteSiteValidNetwork() throws JsonToModelConversionException, Exception @@ -221,7 +221,7 @@ public class DeleteFavoriteFullTests extends RestTest .entriesListDoesNotContain("targetGuid", siteModel.getGuidWithoutVersion()); } - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES}, executionType = ExecutionType.REGRESSION, description = "Verify tenant user deletes favorites site created by admin tenant - same network and status code is (204)") @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES,TestGroup.NETWORKS, TestGroup.FULL }) public void tenantUserIsAbleToDeleteFavoriteSiteAddedByAdminSameNetwork() throws JsonToModelConversionException, Exception diff --git a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/delete/DeleteFavoriteSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteSanityTests.java rename to e2e-test/java/org/alfresco/rest/favorites/delete/DeleteFavoriteSanityTests.java index cc0ed1abf..500a939d1 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/delete/DeleteFavoriteSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.favorites; +package org.alfresco.rest.favorites.delete; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteCoreTests.java b/e2e-test/java/org/alfresco/rest/favorites/delete/DeleteFavoriteSiteCoreTests.java similarity index 97% rename from e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteCoreTests.java rename to e2e-test/java/org/alfresco/rest/favorites/delete/DeleteFavoriteSiteCoreTests.java index 4081e1775..461fcdc99 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/delete/DeleteFavoriteSiteCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.people; +package org.alfresco.rest.favorites.delete; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteFullTests.java b/e2e-test/java/org/alfresco/rest/favorites/delete/DeleteFavoriteSiteFullTests.java similarity index 96% rename from e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteFullTests.java rename to e2e-test/java/org/alfresco/rest/favorites/delete/DeleteFavoriteSiteFullTests.java index 0f234b70f..e77dcd566 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteFullTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/delete/DeleteFavoriteSiteFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.people; +package org.alfresco.rest.favorites.delete; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; @@ -117,7 +117,7 @@ public class DeleteFavoriteSiteFullTests extends RestTest } @Bug(id="MNT-16904") - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE}, executionType = ExecutionType.REGRESSION, description = "Verify tenant user is not able to delete favorites using an invalid network ID") @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.NETWORKS, TestGroup.FULL }) public void tenantIsNotAbleToDeleteFavoriteSiteWithInvalidNetworkID() throws JsonToModelConversionException, Exception @@ -139,7 +139,7 @@ public class DeleteFavoriteSiteFullTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE}, executionType = ExecutionType.REGRESSION, description = "Verify tenant user deletes favorites site and status code is (204)") @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.NETWORKS, TestGroup.FULL }) public void tenantDeleteFavoriteSiteValidNetwork() throws JsonToModelConversionException, Exception @@ -161,7 +161,7 @@ public class DeleteFavoriteSiteFullTests extends RestTest .entriesListDoesNotContain("targetGuid", siteModel.getGuidWithoutVersion()); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE}, executionType = ExecutionType.REGRESSION, description = "Verify tenant user deletes favorites site created by admin tenant - same network and status code is (204)") @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.NETWORKS, TestGroup.FULL }) public void tenantUserIsAbleToDeleteFavoriteSiteAddedByAdminSameNetwork() throws JsonToModelConversionException, Exception diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/delete/DeleteFavoriteSiteSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java rename to e2e-test/java/org/alfresco/rest/favorites/delete/DeleteFavoriteSiteSanityTests.java index 773db9048..33de684bc 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteFavoriteSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/delete/DeleteFavoriteSiteSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.people; +package org.alfresco.rest.favorites.delete; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteCoreTests.java b/e2e-test/java/org/alfresco/rest/favorites/get/GetFavoriteCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/favorites/GetFavoriteCoreTests.java rename to e2e-test/java/org/alfresco/rest/favorites/get/GetFavoriteCoreTests.java index e078d9bda..2d9021a0b 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/get/GetFavoriteCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.favorites; +package org.alfresco.rest.favorites.get; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteFullTests.java b/e2e-test/java/org/alfresco/rest/favorites/get/GetFavoriteFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/favorites/GetFavoriteFullTests.java rename to e2e-test/java/org/alfresco/rest/favorites/get/GetFavoriteFullTests.java index c7c68feba..d9448c9c0 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteFullTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/get/GetFavoriteFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.favorites; +package org.alfresco.rest.favorites.get; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/get/GetFavoriteSanityTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java rename to e2e-test/java/org/alfresco/rest/favorites/get/GetFavoriteSanityTests.java index 86de14f71..822838d75 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/get/GetFavoriteSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.favorites; +package org.alfresco.rest.favorites.get; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteCoreTests.java b/e2e-test/java/org/alfresco/rest/favorites/get/GetFavoriteSiteCoreTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteCoreTests.java rename to e2e-test/java/org/alfresco/rest/favorites/get/GetFavoriteSiteCoreTests.java index 6f1dd7e50..836219204 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/get/GetFavoriteSiteCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.people; +package org.alfresco.rest.favorites.get; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteFullTests.java b/e2e-test/java/org/alfresco/rest/favorites/get/GetFavoriteSiteFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteFullTests.java rename to e2e-test/java/org/alfresco/rest/favorites/get/GetFavoriteSiteFullTests.java index ef1d79fb2..d14639520 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteFullTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/get/GetFavoriteSiteFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.people; +package org.alfresco.rest.favorites.get; import org.alfresco.rest.RestTest; import org.alfresco.rest.core.RestRequest; diff --git a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/get/GetFavoriteSiteSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java rename to e2e-test/java/org/alfresco/rest/favorites/get/GetFavoriteSiteSanityTests.java index dcbd77d31..024b4dd38 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/get/GetFavoriteSiteSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.people; +package org.alfresco.rest.favorites.get; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesCoreTests.java b/e2e-test/java/org/alfresco/rest/favorites/get/GetFavoriteSitesCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesCoreTests.java rename to e2e-test/java/org/alfresco/rest/favorites/get/GetFavoriteSitesCoreTests.java index 313dadd0d..01bcb789c 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/get/GetFavoriteSitesCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.people; +package org.alfresco.rest.favorites.get; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesFullTests.java b/e2e-test/java/org/alfresco/rest/favorites/get/GetFavoriteSitesFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesFullTests.java rename to e2e-test/java/org/alfresco/rest/favorites/get/GetFavoriteSitesFullTests.java index 76df72a97..3ba068c0e 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/get/GetFavoriteSitesFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.people; +package org.alfresco.rest.favorites.get; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/get/GetFavoriteSitesSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java rename to e2e-test/java/org/alfresco/rest/favorites/get/GetFavoriteSitesSanityTests.java index cc7f16302..0960f56c6 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSitesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/get/GetFavoriteSitesSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.people; +package org.alfresco.rest.favorites.get; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesCoreTests.java b/e2e-test/java/org/alfresco/rest/favorites/get/GetFavoritesCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/favorites/GetFavoritesCoreTests.java rename to e2e-test/java/org/alfresco/rest/favorites/get/GetFavoritesCoreTests.java index 9cb4503c8..f4660b842 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/get/GetFavoritesCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.favorites; +package org.alfresco.rest.favorites.get; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesFullTests.java b/e2e-test/java/org/alfresco/rest/favorites/get/GetFavoritesFullTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/favorites/GetFavoritesFullTests.java rename to e2e-test/java/org/alfresco/rest/favorites/get/GetFavoritesFullTests.java index 9d553dcc1..1fb6ffbef 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/get/GetFavoritesFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.favorites; +package org.alfresco.rest.favorites.get; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/get/GetFavoritesSanityTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java rename to e2e-test/java/org/alfresco/rest/favorites/get/GetFavoritesSanityTests.java index c27b699fe..7a4be3527 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/get/GetFavoritesSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.favorites; +package org.alfresco.rest.favorites.get; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteCoreTests.java b/e2e-test/java/org/alfresco/rest/favorites/post/AddFavoriteSiteCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteCoreTests.java rename to e2e-test/java/org/alfresco/rest/favorites/post/AddFavoriteSiteCoreTests.java index 34312995b..e6c196db3 100644 --- a/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/post/AddFavoriteSiteCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.people; +package org.alfresco.rest.favorites.post; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; diff --git a/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteFullTests.java b/e2e-test/java/org/alfresco/rest/favorites/post/AddFavoriteSiteFullTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteFullTests.java rename to e2e-test/java/org/alfresco/rest/favorites/post/AddFavoriteSiteFullTests.java index 4367dce8a..6b5d75186 100644 --- a/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteFullTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/post/AddFavoriteSiteFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.people; +package org.alfresco.rest.favorites.post; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; @@ -282,7 +282,7 @@ public class AddFavoriteSiteFullTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE}, executionType = ExecutionType.REGRESSION, description = "Verify tenant user deletes favorites site and status code is (201)") @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.NETWORKS, TestGroup.FULL }) public void tenantDeleteFavoriteSiteValidNetwork() throws JsonToModelConversionException, Exception @@ -304,7 +304,7 @@ public class AddFavoriteSiteFullTests extends RestTest .entriesListContains("targetGuid", siteModel.getGuidWithoutVersion()); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE}, executionType = ExecutionType.REGRESSION, description = "Verify tenant user deletes favorites site created by admin tenant - same network and status code is (201)") @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.NETWORKS, TestGroup.FULL }) public void tenantUserIsAbleToDeleteFavoriteSiteAddedByAdminSameNetwork() throws JsonToModelConversionException, Exception diff --git a/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/post/AddFavoriteSiteSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteSanityTests.java rename to e2e-test/java/org/alfresco/rest/favorites/post/AddFavoriteSiteSanityTests.java index 9e7e9ff8b..dbe0ed8a1 100644 --- a/e2e-test/java/org/alfresco/rest/people/AddFavoriteSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/post/AddFavoriteSiteSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.people; +package org.alfresco.rest.favorites.post; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesCoreTests.java b/e2e-test/java/org/alfresco/rest/favorites/post/AddFavoritesCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/favorites/AddFavoritesCoreTests.java rename to e2e-test/java/org/alfresco/rest/favorites/post/AddFavoritesCoreTests.java index 08e00885d..e7a52f484 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/post/AddFavoritesCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.favorites; +package org.alfresco.rest.favorites.post; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesFullTests.java b/e2e-test/java/org/alfresco/rest/favorites/post/AddFavoritesFullTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/favorites/AddFavoritesFullTests.java rename to e2e-test/java/org/alfresco/rest/favorites/post/AddFavoritesFullTests.java index 4460b3370..c24e1acde 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/post/AddFavoritesFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.favorites; +package org.alfresco.rest.favorites.post; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/post/AddFavoritesSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/favorites/AddFavoritesSanityTests.java rename to e2e-test/java/org/alfresco/rest/favorites/post/AddFavoritesSanityTests.java index 4373b0050..267c9af2e 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/post/AddFavoritesSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.favorites; +package org.alfresco.rest.favorites.post; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceCoreTests.java b/e2e-test/java/org/alfresco/rest/preferences/GetPeoplePreferenceCoreTests.java similarity index 78% rename from e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceCoreTests.java rename to e2e-test/java/org/alfresco/rest/preferences/GetPeoplePreferenceCoreTests.java index e2b943312..afa64d7ba 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/preferences/GetPeoplePreferenceCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.people; +package org.alfresco.rest.preferences; import org.alfresco.rest.RestTest; import org.alfresco.utility.constants.PreferenceName; @@ -25,7 +25,7 @@ public class GetPeoplePreferenceCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user is Forbidden to get a specific preference for another user with Rest API and response is 403") + @TestRail(section = { TestGroup.REST_API, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user is Forbidden to get a specific preference for another user with Rest API and response is 403") public void userDoesNotHaveAccessToFavoriteSitesOfAnotherUser() throws Exception { UserModel secondUser = dataUser.createRandomTestUser(); @@ -36,7 +36,7 @@ public class GetPeoplePreferenceCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify manager fails to get a specific preference for an invalid user with Rest API and response is 404") + @TestRail(section = { TestGroup.REST_API, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify manager fails to get a specific preference for an invalid user with Rest API and response is 404") public void statusNotFoundIsReturnedForAPersonIDThatDoesNotExist() throws Exception { restClient.authenticateUser(userModel).withCoreAPI().usingUser(new UserModel("invalidPersonID", "password")) @@ -46,7 +46,7 @@ public class GetPeoplePreferenceCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify manager fails to get a specific preference for an invalid preference with Rest API and response is 404") + @TestRail(section = { TestGroup.REST_API, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify manager fails to get a specific preference for an invalid preference with Rest API and response is 404") public void statusNotFoundIsReturnedForAPreferenceNameThatDoesNotExist() throws Exception { restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().getPersonPreferenceInformation("invalidPreferenceName"); @@ -57,7 +57,7 @@ public class GetPeoplePreferenceCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify manager fails to get a specific preference for removed preference with Rest API and response is 404") + @TestRail(section = { TestGroup.REST_API, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify manager fails to get a specific preference for removed preference with Rest API and response is 404") public void statusNotFoundIsReturnedForAPreferenceNameThatHasBeenRemoved() throws Exception { SiteModel preferenceSite = dataSite.usingUser(userModel).createPublicRandomSite(); diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceFullTests.java b/e2e-test/java/org/alfresco/rest/preferences/GetPeoplePreferenceFullTests.java similarity index 91% rename from e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceFullTests.java rename to e2e-test/java/org/alfresco/rest/preferences/GetPeoplePreferenceFullTests.java index f9f310fde..28e3e0636 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceFullTests.java +++ b/e2e-test/java/org/alfresco/rest/preferences/GetPeoplePreferenceFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.people; +package org.alfresco.rest.preferences; import java.nio.file.Paths; @@ -35,7 +35,7 @@ public class GetPeoplePreferenceFullTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Check default error schema in case of failure") public void checkDefaultErrorSchema() throws Exception { @@ -50,7 +50,7 @@ public class GetPeoplePreferenceFullTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Specify -me- string in place of for request") public void preferenceIsReturnedWhenUsingMeAsPersonId() throws Exception { @@ -63,7 +63,7 @@ public class GetPeoplePreferenceFullTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Check that properties parameter is applied") public void propertiesParameterIsAppliedWhenRetrievingPreference() throws Exception { @@ -81,7 +81,7 @@ public class GetPeoplePreferenceFullTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Validate ID element in get site preference response") public void validateIdElementInGetSitePreferenceResponse() throws Exception { @@ -92,7 +92,7 @@ public class GetPeoplePreferenceFullTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Validate ID element in get folder preference response") public void validateIdElementInGetFolderPreferenceResponse() throws Exception { @@ -107,7 +107,7 @@ public class GetPeoplePreferenceFullTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Validate ID element in get file preference response") public void validateIdElementInGetFilePreferenceResponse() throws Exception { @@ -122,7 +122,7 @@ public class GetPeoplePreferenceFullTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Get preference of an user that has no preferences") public void getPreferenceForUserWithoutPreferences() throws Exception { @@ -148,7 +148,7 @@ public class GetPeoplePreferenceFullTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Change one preference for an user then perform get call") @Bug(id = "ACE-5736") public void changePreferenceThenPerformGetPreferenceCall() throws Exception @@ -196,7 +196,7 @@ public class GetPeoplePreferenceFullTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to get preference of another user") public void adminIsAbleToGetOtherUserPreference() throws Exception { @@ -207,7 +207,7 @@ public class GetPeoplePreferenceFullTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify regular user is not able to get preference of admin user") public void regularUserIsNotAbleToGetAdminPreference() throws Exception { diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceSanityTests.java b/e2e-test/java/org/alfresco/rest/preferences/GetPeoplePreferenceSanityTests.java similarity index 81% rename from e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceSanityTests.java rename to e2e-test/java/org/alfresco/rest/preferences/GetPeoplePreferenceSanityTests.java index 8f5397812..205c32d30 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferenceSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/preferences/GetPeoplePreferenceSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.people; +package org.alfresco.rest.preferences; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; @@ -35,7 +35,7 @@ public class GetPeoplePreferenceSanityTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify manager user gets a specific preference with Rest API and response is successful (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify manager user gets a specific preference with Rest API and response is successful (200)") public void managerUserGetsAPreferenceWithSuccess() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -49,7 +49,7 @@ public class GetPeoplePreferenceSanityTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify collaborator user gets a specific preference with Rest API and response is successful (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify collaborator user gets a specific preference with Rest API and response is successful (200)") public void collaboratorUserGetsAPreferenceWithSuccess() throws Exception { UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); @@ -63,7 +63,7 @@ public class GetPeoplePreferenceSanityTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify contributor user gets a specific preference with Rest API and response is successful (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify contributor user gets a specific preference with Rest API and response is successful (200)") public void contributorUserGetsAPreferenceWithSuccess() throws Exception { UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); @@ -77,7 +77,7 @@ public class GetPeoplePreferenceSanityTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify consumer user gets a specific preference with Rest API and response is successful (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify consumer user gets a specific preference with Rest API and response is successful (200)") public void consumerUserGetsAPreferenceWithSuccess() throws Exception { UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -91,7 +91,7 @@ public class GetPeoplePreferenceSanityTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify admin user gets a specific preference with Rest API and response is successful (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify admin user gets a specific preference with Rest API and response is successful (200)") public void adminUserGetsAPreferenceWithSuccess() throws Exception { UserModel adminUser = dataUser.getAdminUser(); @@ -104,7 +104,7 @@ public class GetPeoplePreferenceSanityTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized to get a specific preference with Rest API when authentication fails (401)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized to get a specific preference with Rest API when authentication fails (401)") @Bug(id = "MNT-16904", description = "fails only on environment with tenants") public void managerUserNotAuthorizedFailsToGetsAPreference() throws Exception { diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesCoreTests.java b/e2e-test/java/org/alfresco/rest/preferences/GetPeoplePreferencesCoreTests.java similarity index 80% rename from e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesCoreTests.java rename to e2e-test/java/org/alfresco/rest/preferences/GetPeoplePreferencesCoreTests.java index 94ea64631..77a78bf53 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/preferences/GetPeoplePreferencesCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.people; +package org.alfresco.rest.preferences; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; @@ -40,7 +40,7 @@ public class GetPeoplePreferencesCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its preferences with invalid maxItems parameter with Rest API and response is 400") + @TestRail(section = { TestGroup.REST_API, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its preferences with invalid maxItems parameter with Rest API and response is 400") public void userGetsPeoplePreferencesUsingInvalidMaxItemsParameter() throws Exception { restPreferenceModelsCollection = restClient.authenticateUser(user1).withCoreAPI().usingMe().usingParams("maxItems=0").getPersonPreferences(); @@ -52,7 +52,7 @@ public class GetPeoplePreferencesCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its preferences with skipCount parameter applied with Rest API and response is successful") + @TestRail(section = { TestGroup.REST_API, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its preferences with skipCount parameter applied with Rest API and response is successful") public void userGetsPeoplePreferencesUsingInvalidSkipCountParameter() throws Exception { restPreferenceModelsCollection = restClient.authenticateUser(user1).withCoreAPI().usingMe().usingParams("skipCount=-1").getPersonPreferences(); @@ -64,7 +64,7 @@ public class GetPeoplePreferencesCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user which doesn't have access to another user preferences fails to get its preferences with Rest API and response is permission denied") + @TestRail(section = { TestGroup.REST_API, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user which doesn't have access to another user preferences fails to get its preferences with Rest API and response is permission denied") public void userWithNoAccessToOtherUserPreferencesIsForbiddenToGetItsPreferences() throws Exception { UserModel noAccessUser = dataUser.createRandomTestUser(); @@ -79,7 +79,7 @@ public class GetPeoplePreferencesCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user fails to get preferences for inexistent personId with Rest API and response is 404") + @TestRail(section = { TestGroup.REST_API, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user fails to get preferences for inexistent personId with Rest API and response is 404") public void userCannotGetPeoplePreferencesForInexistentPersonId() throws Exception { UserModel inexistentUserName = new UserModel("inexistent", "password"); @@ -93,7 +93,7 @@ public class GetPeoplePreferencesCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user get preferences for a user with no preferences with Rest API and response is empty") + @TestRail(section = { TestGroup.REST_API, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user get preferences for a user with no preferences with Rest API and response is empty") public void userGetsPeoplePreferencesForUserWithNoPreferences() throws Exception { UserModel userNoActivities = dataUser.createRandomTestUser(); @@ -105,7 +105,7 @@ public class GetPeoplePreferencesCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user fails to get preferences for a removed preference with Rest API and response is 404") + @TestRail(section = { TestGroup.REST_API, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user fails to get preferences for a removed preference with Rest API and response is 404") public void userFailsToGetPeoplePreferencesIfPreferenceWasRemoved() throws Exception { SiteModel preferenceSite = dataSite.usingUser(user1).createPublicRandomSite(); diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesFullTests.java b/e2e-test/java/org/alfresco/rest/preferences/GetPeoplePreferencesFullTests.java similarity index 83% rename from e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesFullTests.java rename to e2e-test/java/org/alfresco/rest/preferences/GetPeoplePreferencesFullTests.java index dfd5ed18e..3c06774ea 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/preferences/GetPeoplePreferencesFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.people; +package org.alfresco.rest.preferences; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; @@ -41,7 +41,7 @@ public class GetPeoplePreferencesFullTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its preferences using me with Rest API and response is successful") + @TestRail(section = { TestGroup.REST_API,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its preferences using me with Rest API and response is successful") public void userGetsItsPeoplePreferencesUsingMe() throws Exception { restPreferenceModelsCollection = restClient.authenticateUser(user1).withCoreAPI().usingMe().getPersonPreferences(); @@ -57,7 +57,7 @@ public class GetPeoplePreferencesFullTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its preferences with skipCount parameter applied with Rest API and response is successful") + @TestRail(section = { TestGroup.REST_API, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its preferences with skipCount parameter applied with Rest API and response is successful") public void userGetsItsPeoplePreferencesUsingSkipCountParameter() throws Exception { restPreferenceModelsCollection = restClient.authenticateUser(user1).withCoreAPI().usingMe().usingParams("skipCount=2").getPersonPreferences(); @@ -74,7 +74,7 @@ public class GetPeoplePreferencesFullTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its preferences with maxItems parameter applied with Rest API and response is successful") + @TestRail(section = { TestGroup.REST_API, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its preferences with maxItems parameter applied with Rest API and response is successful") public void userGetsItsPeoplePreferencesUsingMaxItemsParameter() throws Exception { restPreferenceModelsCollection = restClient.authenticateUser(user1).withCoreAPI().usingMe().usingParams("maxItems=1").getPersonPreferences(); @@ -91,7 +91,7 @@ public class GetPeoplePreferencesFullTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets admin preferences with Rest API and response is permission denied") + @TestRail(section = { TestGroup.REST_API,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets admin preferences with Rest API and response is permission denied") public void userIsForbiddenToGetAdminPreferences() throws Exception { restPreferenceModelsCollection = restClient.authenticateUser(user1).withCoreAPI().usingUser(adminUser).getPersonPreferences(); @@ -103,7 +103,7 @@ public class GetPeoplePreferencesFullTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its preferences with skipCount parameter higher then no of entries with Rest API and response is empty") + @TestRail(section = { TestGroup.REST_API, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its preferences with skipCount parameter higher then no of entries with Rest API and response is empty") public void userGetsItsPeoplePreferencesUsingHighSkipCount() throws Exception { restPreferenceModelsCollection = restClient.authenticateUser(user1).withCoreAPI().usingMe().usingParams("skipCount=100").getPersonPreferences(); @@ -115,7 +115,7 @@ public class GetPeoplePreferencesFullTests extends RestTest @Bug(id = "REPO-1911") @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot get preferences for empty user with Rest API and response is 400") + @TestRail(section = { TestGroup.REST_API, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot get preferences for empty user with Rest API and response is 400") public void userGetsItsPeoplePreferencesForEmptyPersonId() throws Exception { UserModel emptyUserName = new UserModel("", "password"); diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesSanityTests.java b/e2e-test/java/org/alfresco/rest/preferences/GetPeoplePreferencesSanityTests.java similarity index 81% rename from e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesSanityTests.java rename to e2e-test/java/org/alfresco/rest/preferences/GetPeoplePreferencesSanityTests.java index 7e435e681..273125dcd 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeoplePreferencesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/preferences/GetPeoplePreferencesSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.people; +package org.alfresco.rest.preferences; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; @@ -35,7 +35,7 @@ public class GetPeoplePreferencesSanityTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify manager user gets its preferences with Rest API and response is successful (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify manager user gets its preferences with Rest API and response is successful (200)") public void managerUserGetsPeoplePreferencesWithSuccess() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -49,7 +49,7 @@ public class GetPeoplePreferencesSanityTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify collaborator user gets its preferences with Rest API and response is successful (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify collaborator user gets its preferences with Rest API and response is successful (200)") public void collaboratorUserGetsPeoplePreferencesWithSuccess() throws Exception { UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); @@ -63,7 +63,7 @@ public class GetPeoplePreferencesSanityTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify contributor user gets its preferences with Rest API and response is successful (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify contributor user gets its preferences with Rest API and response is successful (200)") public void contributorUserGetsPeoplePreferencesWithSuccess() throws Exception { UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); @@ -77,7 +77,7 @@ public class GetPeoplePreferencesSanityTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify consumer user gets its preferences with Rest API and response is successful (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify consumer user gets its preferences with Rest API and response is successful (200)") public void consumerUserGetsPeoplePreferencesWithSuccess() throws Exception { UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -91,7 +91,7 @@ public class GetPeoplePreferencesSanityTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify admin user gets another user preferences with Rest API and response is successful (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify admin user gets another user preferences with Rest API and response is successful (200)") public void adminUserGetsPeoplePreferencesWithSuccess() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -106,7 +106,7 @@ public class GetPeoplePreferencesSanityTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized to gets its preferences with Rest API when authentication fails(401)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized to gets its preferences with Rest API when authentication fails(401)") @Bug(id = "MNT-16904", description = "It fails only on environment with tenants") public void managerUserGetsPeoplePreferencesIsNotAuthorized() throws Exception { diff --git a/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingCoreTests.java b/e2e-test/java/org/alfresco/rest/ratings/delete/DeleteRatingCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/ratings/DeleteRatingCoreTests.java rename to e2e-test/java/org/alfresco/rest/ratings/delete/DeleteRatingCoreTests.java index 55216d92d..0012e4790 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/delete/DeleteRatingCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.ratings; +package org.alfresco.rest.ratings.delete; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingFullTests.java b/e2e-test/java/org/alfresco/rest/ratings/delete/DeleteRatingFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/ratings/DeleteRatingFullTests.java rename to e2e-test/java/org/alfresco/rest/ratings/delete/DeleteRatingFullTests.java index b3c68262f..1c3aaf3aa 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingFullTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/delete/DeleteRatingFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.ratings; +package org.alfresco.rest.ratings.delete; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/delete/DeleteRatingSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java rename to e2e-test/java/org/alfresco/rest/ratings/delete/DeleteRatingSanityTests.java index b6361d095..f51b4dfb8 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/delete/DeleteRatingSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.ratings; +package org.alfresco.rest.ratings.delete; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/ratings/GetRatingCoreTests.java b/e2e-test/java/org/alfresco/rest/ratings/get/GetRatingCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/ratings/GetRatingCoreTests.java rename to e2e-test/java/org/alfresco/rest/ratings/get/GetRatingCoreTests.java index 5b17497de..ecb6c8540 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/GetRatingCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/get/GetRatingCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.ratings; +package org.alfresco.rest.ratings.get; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/ratings/GetRatingFullTests.java b/e2e-test/java/org/alfresco/rest/ratings/get/GetRatingFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/ratings/GetRatingFullTests.java rename to e2e-test/java/org/alfresco/rest/ratings/get/GetRatingFullTests.java index 3fdc99e28..d1bdfb729 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/GetRatingFullTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/get/GetRatingFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.ratings; +package org.alfresco.rest.ratings.get; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/get/GetRatingSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java rename to e2e-test/java/org/alfresco/rest/ratings/get/GetRatingSanityTests.java index dc9d23178..be3a8c46b 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/get/GetRatingSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.ratings; +package org.alfresco.rest.ratings.get; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/ratings/GetRatingsCoreTests.java b/e2e-test/java/org/alfresco/rest/ratings/get/GetRatingsCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/ratings/GetRatingsCoreTests.java rename to e2e-test/java/org/alfresco/rest/ratings/get/GetRatingsCoreTests.java index 3051df8f4..1c0a173d7 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/GetRatingsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/get/GetRatingsCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.ratings; +package org.alfresco.rest.ratings.get; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/ratings/GetRatingsFullTests.java b/e2e-test/java/org/alfresco/rest/ratings/get/GetRatingsFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/ratings/GetRatingsFullTests.java rename to e2e-test/java/org/alfresco/rest/ratings/get/GetRatingsFullTests.java index 1fdbd80ba..ca6de45b9 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/GetRatingsFullTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/get/GetRatingsFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.ratings; +package org.alfresco.rest.ratings.get; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/ratings/GetRatingsSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/get/GetRatingsSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/ratings/GetRatingsSanityTests.java rename to e2e-test/java/org/alfresco/rest/ratings/get/GetRatingsSanityTests.java index a973d37c5..60352c5a2 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/GetRatingsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/get/GetRatingsSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.ratings; +package org.alfresco.rest.ratings.get; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/ratings/AddRatingCoreTests.java b/e2e-test/java/org/alfresco/rest/ratings/post/AddRatingCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/ratings/AddRatingCoreTests.java rename to e2e-test/java/org/alfresco/rest/ratings/post/AddRatingCoreTests.java index 123976721..fef772bbf 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/AddRatingCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/post/AddRatingCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.ratings; +package org.alfresco.rest.ratings.post; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/ratings/AddRatingFullTests.java b/e2e-test/java/org/alfresco/rest/ratings/post/AddRatingFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/ratings/AddRatingFullTests.java rename to e2e-test/java/org/alfresco/rest/ratings/post/AddRatingFullTests.java index 6207473b7..b52340b6d 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/AddRatingFullTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/post/AddRatingFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.ratings; +package org.alfresco.rest.ratings.post; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/post/AddRatingSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java rename to e2e-test/java/org/alfresco/rest/ratings/post/AddRatingSanityTests.java index 8b81a47c6..714bd6b84 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/post/AddRatingSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.ratings; +package org.alfresco.rest.ratings.post; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/delete/DeleteSiteMemberCoreTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberCoreTests.java rename to e2e-test/java/org/alfresco/rest/sites/delete/DeleteSiteMemberCoreTests.java index 536dd36b3..06ab77c4a 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/delete/DeleteSiteMemberCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.people; +package org.alfresco.rest.sites.delete; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberFullTests.java b/e2e-test/java/org/alfresco/rest/sites/delete/DeleteSiteMemberFullTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberFullTests.java rename to e2e-test/java/org/alfresco/rest/sites/delete/DeleteSiteMemberFullTests.java index d069379bb..204492503 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberFullTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/delete/DeleteSiteMemberFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.people; +package org.alfresco.rest.sites.delete; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/delete/DeleteSiteMemberSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java rename to e2e-test/java/org/alfresco/rest/sites/delete/DeleteSiteMemberSanityTests.java index 3c15d11d0..57dd02b5e 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/delete/DeleteSiteMemberSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.people; +package org.alfresco.rest.sites.delete; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/delete/DeleteSiteMembershipRequestCoreTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestCoreTests.java rename to e2e-test/java/org/alfresco/rest/sites/delete/DeleteSiteMembershipRequestCoreTests.java index b956921db..fb08000b6 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/delete/DeleteSiteMembershipRequestCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.people; +package org.alfresco.rest.sites.delete; import org.alfresco.dataprep.WorkflowService; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestFullTests.java b/e2e-test/java/org/alfresco/rest/sites/delete/DeleteSiteMembershipRequestFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestFullTests.java rename to e2e-test/java/org/alfresco/rest/sites/delete/DeleteSiteMembershipRequestFullTests.java index 56030f691..6e36c4ff3 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestFullTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/delete/DeleteSiteMembershipRequestFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.people; +package org.alfresco.rest.sites.delete; import org.alfresco.dataprep.WorkflowService; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/delete/DeleteSiteMembershipRequestSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java rename to e2e-test/java/org/alfresco/rest/sites/delete/DeleteSiteMembershipRequestSanityTests.java index d25f62f14..79a2f83de 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/delete/DeleteSiteMembershipRequestSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.people; +package org.alfresco.rest.sites.delete; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; diff --git a/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/delete/RemoveSiteMemberCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberCoreTests.java rename to e2e-test/java/org/alfresco/rest/sites/delete/RemoveSiteMemberCoreTests.java index f0fb15ec6..de10fd1bb 100644 --- a/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/delete/RemoveSiteMemberCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites; +package org.alfresco.rest.sites.delete; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberFullTests.java b/e2e-test/java/org/alfresco/rest/sites/delete/RemoveSiteMemberFullTests.java similarity index 97% rename from e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberFullTests.java rename to e2e-test/java/org/alfresco/rest/sites/delete/RemoveSiteMemberFullTests.java index 164966644..724cbcc25 100644 --- a/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberFullTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/delete/RemoveSiteMemberFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites; +package org.alfresco.rest.sites.delete; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/delete/RemoveSiteMemberSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java rename to e2e-test/java/org/alfresco/rest/sites/delete/RemoveSiteMemberSanityTests.java index 2607dbc0e..0cd31ac2f 100644 --- a/e2e-test/java/org/alfresco/rest/sites/RemoveSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/delete/RemoveSiteMemberSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites; +package org.alfresco.rest.sites.delete; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/get/GetSiteContainerCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/GetSiteContainerCoreTests.java rename to e2e-test/java/org/alfresco/rest/sites/get/GetSiteContainerCoreTests.java index 0dab7cf58..76b9686d4 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/get/GetSiteContainerCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites; +package org.alfresco.rest.sites.get; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerFullTests.java b/e2e-test/java/org/alfresco/rest/sites/get/GetSiteContainerFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/GetSiteContainerFullTests.java rename to e2e-test/java/org/alfresco/rest/sites/get/GetSiteContainerFullTests.java index bf9b2f7b4..c6762248b 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerFullTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/get/GetSiteContainerFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites; +package org.alfresco.rest.sites.get; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/get/GetSiteContainerSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java rename to e2e-test/java/org/alfresco/rest/sites/get/GetSiteContainerSanityTests.java index 40ceeb104..d4fcd3b1c 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/get/GetSiteContainerSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites; +package org.alfresco.rest.sites.get; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/get/GetSiteContainersCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/GetSiteContainersCoreTests.java rename to e2e-test/java/org/alfresco/rest/sites/get/GetSiteContainersCoreTests.java index 70aefbb9b..47ee3bd6f 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/get/GetSiteContainersCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites; +package org.alfresco.rest.sites.get; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersFullTests.java b/e2e-test/java/org/alfresco/rest/sites/get/GetSiteContainersFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/GetSiteContainersFullTests.java rename to e2e-test/java/org/alfresco/rest/sites/get/GetSiteContainersFullTests.java index 84d2f1595..cfdfe1e28 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersFullTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/get/GetSiteContainersFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites; +package org.alfresco.rest.sites.get; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/get/GetSiteContainersSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java rename to e2e-test/java/org/alfresco/rest/sites/get/GetSiteContainersSanityTests.java index 1de49a617..77cd0d1f0 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/get/GetSiteContainersSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites; +package org.alfresco.rest.sites.get; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/get/GetSiteCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/GetSiteCoreTests.java rename to e2e-test/java/org/alfresco/rest/sites/get/GetSiteCoreTests.java index e7123a90d..e0eb2ea57 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/get/GetSiteCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites; +package org.alfresco.rest.sites.get; import org.alfresco.rest.RestTest; import org.alfresco.rest.core.RestRequest; diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteFullTests.java b/e2e-test/java/org/alfresco/rest/sites/get/GetSiteFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/GetSiteFullTests.java rename to e2e-test/java/org/alfresco/rest/sites/get/GetSiteFullTests.java index dff227d0d..05dd45aac 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteFullTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/get/GetSiteFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites; +package org.alfresco.rest.sites.get; import static org.hamcrest.CoreMatchers.equalTo; diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/get/GetSiteMemberCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/GetSiteMemberCoreTests.java rename to e2e-test/java/org/alfresco/rest/sites/get/GetSiteMemberCoreTests.java index 371cac7da..d0c40ff9c 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/get/GetSiteMemberCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites; +package org.alfresco.rest.sites.get; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberFullTests.java b/e2e-test/java/org/alfresco/rest/sites/get/GetSiteMemberFullTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/sites/GetSiteMemberFullTests.java rename to e2e-test/java/org/alfresco/rest/sites/get/GetSiteMemberFullTests.java index 1a84376ac..2e75a3a94 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberFullTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/get/GetSiteMemberFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites; +package org.alfresco.rest.sites.get; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/get/GetSiteMemberSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java rename to e2e-test/java/org/alfresco/rest/sites/get/GetSiteMemberSanityTests.java index 8a3348955..c247ca183 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/get/GetSiteMemberSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites; +package org.alfresco.rest.sites.get; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/get/GetSiteMembersCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/GetSiteMembersCoreTests.java rename to e2e-test/java/org/alfresco/rest/sites/get/GetSiteMembersCoreTests.java index ae7381b62..dca259bf7 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/get/GetSiteMembersCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites; +package org.alfresco.rest.sites.get; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersFullTests.java b/e2e-test/java/org/alfresco/rest/sites/get/GetSiteMembersFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/GetSiteMembersFullTests.java rename to e2e-test/java/org/alfresco/rest/sites/get/GetSiteMembersFullTests.java index 7c91d7c7d..1c3f089ba 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersFullTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/get/GetSiteMembersFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites; +package org.alfresco.rest.sites.get; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestSiteMemberModel; diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/get/GetSiteMembersSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java rename to e2e-test/java/org/alfresco/rest/sites/get/GetSiteMembersSanityTests.java index 3c152678e..0ad1ec5d3 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/get/GetSiteMembersSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites; +package org.alfresco.rest.sites.get; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/get/GetSiteMembershipCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/people/GetSiteMembershipCoreTests.java rename to e2e-test/java/org/alfresco/rest/sites/get/GetSiteMembershipCoreTests.java index 9ccb41f7d..e7abb8284 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/get/GetSiteMembershipCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.people; +package org.alfresco.rest.sites.get; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipFullTests.java b/e2e-test/java/org/alfresco/rest/sites/get/GetSiteMembershipFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/people/GetSiteMembershipFullTests.java rename to e2e-test/java/org/alfresco/rest/sites/get/GetSiteMembershipFullTests.java index f27644f74..934b1090f 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipFullTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/get/GetSiteMembershipFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.people; +package org.alfresco.rest.sites.get; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/get/GetSiteMembershipRequestCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestCoreTests.java rename to e2e-test/java/org/alfresco/rest/sites/get/GetSiteMembershipRequestCoreTests.java index d7873b296..7482d6fac 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/get/GetSiteMembershipRequestCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.people; +package org.alfresco.rest.sites.get; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestFullTests.java b/e2e-test/java/org/alfresco/rest/sites/get/GetSiteMembershipRequestFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestFullTests.java rename to e2e-test/java/org/alfresco/rest/sites/get/GetSiteMembershipRequestFullTests.java index 93fd2342a..a7a7e0e52 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestFullTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/get/GetSiteMembershipRequestFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.people; +package org.alfresco.rest.sites.get; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/get/GetSiteMembershipRequestSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestSanityTests.java rename to e2e-test/java/org/alfresco/rest/sites/get/GetSiteMembershipRequestSanityTests.java index 574300402..9b6ff9174 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/get/GetSiteMembershipRequestSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.people; +package org.alfresco.rest.sites.get; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/get/GetSiteMembershipRequestsCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsCoreTests.java rename to e2e-test/java/org/alfresco/rest/sites/get/GetSiteMembershipRequestsCoreTests.java index b82ea8998..e667df490 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/get/GetSiteMembershipRequestsCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.people; +package org.alfresco.rest.sites.get; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsFullTests.java b/e2e-test/java/org/alfresco/rest/sites/get/GetSiteMembershipRequestsFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsFullTests.java rename to e2e-test/java/org/alfresco/rest/sites/get/GetSiteMembershipRequestsFullTests.java index 904d653ad..ddad9ad9e 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsFullTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/get/GetSiteMembershipRequestsFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.people; +package org.alfresco.rest.sites.get; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/get/GetSiteMembershipRequestsSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java rename to e2e-test/java/org/alfresco/rest/sites/get/GetSiteMembershipRequestsSanityTests.java index 03cbf8b33..d0158fd60 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipRequestsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/get/GetSiteMembershipRequestsSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.people; +package org.alfresco.rest.sites.get; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/get/GetSiteMembershipSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java rename to e2e-test/java/org/alfresco/rest/sites/get/GetSiteMembershipSanityTests.java index 04766c5d1..d44c70572 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/get/GetSiteMembershipSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.people; +package org.alfresco.rest.sites.get; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/get/GetSiteSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/GetSiteSanityTests.java rename to e2e-test/java/org/alfresco/rest/sites/get/GetSiteSanityTests.java index 8c8c5f4e1..af35e5bee 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/get/GetSiteSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites; +package org.alfresco.rest.sites.get; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/get/GetSitesCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java rename to e2e-test/java/org/alfresco/rest/sites/get/GetSitesCoreTests.java index d59cbf27a..0278011b5 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/get/GetSitesCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites; +package org.alfresco.rest.sites.get; import java.util.List; diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSitesFullTests.java b/e2e-test/java/org/alfresco/rest/sites/get/GetSitesFullTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/sites/GetSitesFullTests.java rename to e2e-test/java/org/alfresco/rest/sites/get/GetSitesFullTests.java index cd787aa03..ee41b343f 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSitesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/get/GetSitesFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites; +package org.alfresco.rest.sites.get; import java.util.List; diff --git a/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/get/GetSitesMembershipInformationCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationCoreTests.java rename to e2e-test/java/org/alfresco/rest/sites/get/GetSitesMembershipInformationCoreTests.java index 07878cf0a..53e462c43 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/get/GetSitesMembershipInformationCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.people; +package org.alfresco.rest.sites.get; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationFullTests.java b/e2e-test/java/org/alfresco/rest/sites/get/GetSitesMembershipInformationFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationFullTests.java rename to e2e-test/java/org/alfresco/rest/sites/get/GetSitesMembershipInformationFullTests.java index 9abef3e7e..6d5c0cc7a 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationFullTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/get/GetSitesMembershipInformationFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.people; +package org.alfresco.rest.sites.get; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestSiteMembershipModelsCollection; diff --git a/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/get/GetSitesMembershipInformationSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java rename to e2e-test/java/org/alfresco/rest/sites/get/GetSitesMembershipInformationSanityTests.java index 685d06aee..82748f3e2 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/get/GetSitesMembershipInformationSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.people; +package org.alfresco.rest.sites.get; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/get/GetSitesSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java rename to e2e-test/java/org/alfresco/rest/sites/get/GetSitesSanityTests.java index 377b383e6..e1fe7b4d6 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/get/GetSitesSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites; +package org.alfresco.rest.sites.get; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; diff --git a/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/post/AddSiteMemberCoreTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/sites/AddSiteMemberCoreTests.java rename to e2e-test/java/org/alfresco/rest/sites/post/AddSiteMemberCoreTests.java index 70df50abc..b2ac9b622 100644 --- a/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/post/AddSiteMemberCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites; +package org.alfresco.rest.sites.post; import org.alfresco.rest.RestTest; import org.alfresco.rest.core.JsonBodyGenerator; diff --git a/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberFullTests.java b/e2e-test/java/org/alfresco/rest/sites/post/AddSiteMemberFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/AddSiteMemberFullTests.java rename to e2e-test/java/org/alfresco/rest/sites/post/AddSiteMemberFullTests.java index ed5f3e0b5..9c0e31568 100644 --- a/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberFullTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/post/AddSiteMemberFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites; +package org.alfresco.rest.sites.post; import org.alfresco.rest.RestTest; import org.alfresco.rest.core.RestRequest; diff --git a/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/post/AddSiteMemberSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java rename to e2e-test/java/org/alfresco/rest/sites/post/AddSiteMemberSanityTests.java index 3bfb390e1..1d7247b44 100644 --- a/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/post/AddSiteMemberSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites; +package org.alfresco.rest.sites.post; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/post/AddSiteMembershipRequestCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestCoreTests.java rename to e2e-test/java/org/alfresco/rest/sites/post/AddSiteMembershipRequestCoreTests.java index 6d3e9be45..70f33ad43 100644 --- a/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/post/AddSiteMembershipRequestCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.people; +package org.alfresco.rest.sites.post; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestFullTests.java b/e2e-test/java/org/alfresco/rest/sites/post/AddSiteMembershipRequestFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestFullTests.java rename to e2e-test/java/org/alfresco/rest/sites/post/AddSiteMembershipRequestFullTests.java index dd418e472..13c1f8b09 100644 --- a/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestFullTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/post/AddSiteMembershipRequestFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.people; +package org.alfresco.rest.sites.post; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; diff --git a/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/post/AddSiteMembershipRequestSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java rename to e2e-test/java/org/alfresco/rest/sites/post/AddSiteMembershipRequestSanityTests.java index a248b6cb2..ddc91cb5e 100644 --- a/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/post/AddSiteMembershipRequestSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.people; +package org.alfresco.rest.sites.post; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; diff --git a/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/put/UpdateSiteMemberCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberCoreTests.java rename to e2e-test/java/org/alfresco/rest/sites/put/UpdateSiteMemberCoreTests.java index de2905cc1..bb1ae6707 100644 --- a/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/put/UpdateSiteMemberCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites; +package org.alfresco.rest.sites.put; import org.alfresco.rest.RestTest; import org.alfresco.rest.core.JsonBodyGenerator; diff --git a/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberFullTests.java b/e2e-test/java/org/alfresco/rest/sites/put/UpdateSiteMemberFullTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberFullTests.java rename to e2e-test/java/org/alfresco/rest/sites/put/UpdateSiteMemberFullTests.java index 0dd6117f0..ceae15734 100644 --- a/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberFullTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/put/UpdateSiteMemberFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites; +package org.alfresco.rest.sites.put; import org.alfresco.rest.RestTest; import org.alfresco.rest.core.RestRequest; diff --git a/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/put/UpdateSiteMemberSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java rename to e2e-test/java/org/alfresco/rest/sites/put/UpdateSiteMemberSanityTests.java index 71d2dff2e..bc4bb918f 100644 --- a/e2e-test/java/org/alfresco/rest/sites/UpdateSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/put/UpdateSiteMemberSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites; +package org.alfresco.rest.sites.put; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/put/UpdateSiteMembershipRequestCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestCoreTests.java rename to e2e-test/java/org/alfresco/rest/sites/put/UpdateSiteMembershipRequestCoreTests.java index 71c40c86c..2b7a82a49 100644 --- a/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/put/UpdateSiteMembershipRequestCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.people; +package org.alfresco.rest.sites.put; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestFullTests.java b/e2e-test/java/org/alfresco/rest/sites/put/UpdateSiteMembershipRequestFullTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestFullTests.java rename to e2e-test/java/org/alfresco/rest/sites/put/UpdateSiteMembershipRequestFullTests.java index a44186016..3c9847311 100644 --- a/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestFullTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/put/UpdateSiteMembershipRequestFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.people; +package org.alfresco.rest.sites.put; import org.alfresco.rest.RestTest; import org.alfresco.rest.core.RestRequest; @@ -453,7 +453,7 @@ public class UpdateSiteMembershipRequestFullTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE}, executionType = ExecutionType.REGRESSION, description = "Update site membership request using invalid network") public void updateSiteMembershipRequestUsingInvalidNetwork() throws Exception { @@ -469,7 +469,7 @@ public class UpdateSiteMembershipRequestFullTests extends RestTest .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL}, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE}, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to update an inexitent site membership request") @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) public void userIsNotAbleToUpdateAnInexistentSiteMembershipRequest() throws JsonToModelConversionException, DataPreparationException, Exception @@ -485,7 +485,7 @@ public class UpdateSiteMembershipRequestFullTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE}, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to update a deleted site membership request") public void userCantUpdateSiteMembershipRequestForDeletedRequest() throws Exception { diff --git a/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/put/UpdateSiteMembershipRequestSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestSanityTests.java rename to e2e-test/java/org/alfresco/rest/sites/put/UpdateSiteMembershipRequestSanityTests.java index a0eb8abed..b911f0e02 100644 --- a/e2e-test/java/org/alfresco/rest/people/UpdateSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/put/UpdateSiteMembershipRequestSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.people; +package org.alfresco.rest.sites.put; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; diff --git a/e2e-test/java/org/alfresco/rest/tags/DeleteTagCoreTests.java b/e2e-test/java/org/alfresco/rest/tags/delete/DeleteTagCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/tags/DeleteTagCoreTests.java rename to e2e-test/java/org/alfresco/rest/tags/delete/DeleteTagCoreTests.java index 98c6b53ea..9795d20e6 100644 --- a/e2e-test/java/org/alfresco/rest/tags/DeleteTagCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/delete/DeleteTagCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.tags; +package org.alfresco.rest.tags.delete; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/tags/DeleteTagFullTests.java b/e2e-test/java/org/alfresco/rest/tags/delete/DeleteTagFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/tags/DeleteTagFullTests.java rename to e2e-test/java/org/alfresco/rest/tags/delete/DeleteTagFullTests.java index 869b2b4d1..208952b11 100644 --- a/e2e-test/java/org/alfresco/rest/tags/DeleteTagFullTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/delete/DeleteTagFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.tags; +package org.alfresco.rest.tags.delete; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/tags/DeleteTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/delete/DeleteTagSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/tags/DeleteTagSanityTests.java rename to e2e-test/java/org/alfresco/rest/tags/delete/DeleteTagSanityTests.java index b6df9ce7d..ca6a7a44e 100644 --- a/e2e-test/java/org/alfresco/rest/tags/DeleteTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/delete/DeleteTagSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.tags; +package org.alfresco.rest.tags.delete; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsCoreTests.java b/e2e-test/java/org/alfresco/rest/tags/get/GetNodeTagsCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/tags/GetNodeTagsCoreTests.java rename to e2e-test/java/org/alfresco/rest/tags/get/GetNodeTagsCoreTests.java index 5cf50cbb1..d055fadc6 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/get/GetNodeTagsCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.tags; +package org.alfresco.rest.tags.get; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsFullTests.java b/e2e-test/java/org/alfresco/rest/tags/get/GetNodeTagsFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/tags/GetNodeTagsFullTests.java rename to e2e-test/java/org/alfresco/rest/tags/get/GetNodeTagsFullTests.java index 0da991ef8..d71f6cfe3 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsFullTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/get/GetNodeTagsFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.tags; +package org.alfresco.rest.tags.get; import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.CMISUtil.DocumentType; diff --git a/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/get/GetNodeTagsSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java rename to e2e-test/java/org/alfresco/rest/tags/get/GetNodeTagsSanityTests.java index 82584e862..a4ff0dade 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/get/GetNodeTagsSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.tags; +package org.alfresco.rest.tags.get; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/tags/GetTagCoreTests.java b/e2e-test/java/org/alfresco/rest/tags/get/GetTagCoreTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/tags/GetTagCoreTests.java rename to e2e-test/java/org/alfresco/rest/tags/get/GetTagCoreTests.java index dc1b8c62f..3d205d4c1 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetTagCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/get/GetTagCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.tags; +package org.alfresco.rest.tags.get; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/tags/GetTagFullTests.java b/e2e-test/java/org/alfresco/rest/tags/get/GetTagFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/tags/GetTagFullTests.java rename to e2e-test/java/org/alfresco/rest/tags/get/GetTagFullTests.java index f16116f0d..bee509909 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetTagFullTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/get/GetTagFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.tags; +package org.alfresco.rest.tags.get; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/tags/GetTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/get/GetTagSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/tags/GetTagSanityTests.java rename to e2e-test/java/org/alfresco/rest/tags/get/GetTagSanityTests.java index 72dd369cd..c2a18bbf0 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/get/GetTagSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.tags; +package org.alfresco.rest.tags.get; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/tags/GetTagsCoreTests.java b/e2e-test/java/org/alfresco/rest/tags/get/GetTagsCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/tags/GetTagsCoreTests.java rename to e2e-test/java/org/alfresco/rest/tags/get/GetTagsCoreTests.java index 92f006e77..a9caee949 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetTagsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/get/GetTagsCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.tags; +package org.alfresco.rest.tags.get; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/tags/GetTagsFullTests.java b/e2e-test/java/org/alfresco/rest/tags/get/GetTagsFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/tags/GetTagsFullTests.java rename to e2e-test/java/org/alfresco/rest/tags/get/GetTagsFullTests.java index c6dace4c7..7aa97f887 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetTagsFullTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/get/GetTagsFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.tags; +package org.alfresco.rest.tags.get; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/get/GetTagsSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java rename to e2e-test/java/org/alfresco/rest/tags/get/GetTagsSanityTests.java index f11250c23..8d768e8e6 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/get/GetTagsSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.tags; +package org.alfresco.rest.tags.get; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/tags/AddTagCoreTests.java b/e2e-test/java/org/alfresco/rest/tags/post/AddTagCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/tags/AddTagCoreTests.java rename to e2e-test/java/org/alfresco/rest/tags/post/AddTagCoreTests.java index e6779db48..be2b4937a 100644 --- a/e2e-test/java/org/alfresco/rest/tags/AddTagCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/post/AddTagCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.tags; +package org.alfresco.rest.tags.post; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/tags/AddTagFullTests.java b/e2e-test/java/org/alfresco/rest/tags/post/AddTagFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/tags/AddTagFullTests.java rename to e2e-test/java/org/alfresco/rest/tags/post/AddTagFullTests.java index de374c063..5d0887490 100644 --- a/e2e-test/java/org/alfresco/rest/tags/AddTagFullTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/post/AddTagFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.tags; +package org.alfresco.rest.tags.post; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/post/AddTagSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java rename to e2e-test/java/org/alfresco/rest/tags/post/AddTagSanityTests.java index 8de6c31e0..e4150d373 100644 --- a/e2e-test/java/org/alfresco/rest/tags/AddTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/post/AddTagSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.tags; +package org.alfresco.rest.tags.post; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/tags/AddTagsSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/post/AddTagsSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/tags/AddTagsSanityTests.java rename to e2e-test/java/org/alfresco/rest/tags/post/AddTagsSanityTests.java index 8ab6b4cbf..44e4be139 100644 --- a/e2e-test/java/org/alfresco/rest/tags/AddTagsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/post/AddTagsSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.tags; +package org.alfresco.rest.tags.post; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/tags/UpdateTagCoreTests.java b/e2e-test/java/org/alfresco/rest/tags/put/UpdateTagCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/tags/UpdateTagCoreTests.java rename to e2e-test/java/org/alfresco/rest/tags/put/UpdateTagCoreTests.java index 4904972e6..a4ddb4194 100644 --- a/e2e-test/java/org/alfresco/rest/tags/UpdateTagCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/put/UpdateTagCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.tags; +package org.alfresco.rest.tags.put; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/tags/UpdateTagFullTests.java b/e2e-test/java/org/alfresco/rest/tags/put/UpdateTagFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/tags/UpdateTagFullTests.java rename to e2e-test/java/org/alfresco/rest/tags/put/UpdateTagFullTests.java index d8dcb0066..ab80fee1b 100644 --- a/e2e-test/java/org/alfresco/rest/tags/UpdateTagFullTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/put/UpdateTagFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.tags; +package org.alfresco.rest.tags.put; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/put/UpdateTagSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java rename to e2e-test/java/org/alfresco/rest/tags/put/UpdateTagSanityTests.java index 4b6bb81ae..e2f5e9321 100644 --- a/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/put/UpdateTagSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.tags; +package org.alfresco.rest.tags.put; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentCoreFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/delete/DeleteDeploymentCoreFullTests.java similarity index 97% rename from e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentCoreFullTests.java rename to e2e-test/java/org/alfresco/rest/workflow/deployments/delete/DeleteDeploymentCoreFullTests.java index b389c17ea..32e50db56 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentCoreFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/delete/DeleteDeploymentCoreFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.deployments; +package org.alfresco.rest.workflow.deployments.delete; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestDeploymentModel; diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/delete/DeleteDeploymentSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java rename to e2e-test/java/org/alfresco/rest/workflow/deployments/delete/DeleteDeploymentSanityTests.java index 254d40c00..87e4745f0 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/delete/DeleteDeploymentSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.deployments; +package org.alfresco.rest.workflow.deployments.delete; import java.util.List; diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/get/GetDeploymentCoreTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentCoreTests.java rename to e2e-test/java/org/alfresco/rest/workflow/deployments/get/GetDeploymentCoreTests.java index 0fbad6d14..8c22f71ab 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/get/GetDeploymentCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.deployments; +package org.alfresco.rest.workflow.deployments.get; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestDeploymentModel; diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/get/GetDeploymentFullTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentFullTests.java rename to e2e-test/java/org/alfresco/rest/workflow/deployments/get/GetDeploymentFullTests.java index a13c4a50f..aa18d6bd9 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/get/GetDeploymentFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.deployments; +package org.alfresco.rest.workflow.deployments.get; import org.alfresco.rest.RestTest; import org.alfresco.rest.core.RestRequest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/get/GetDeploymentSanityTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentSanityTests.java rename to e2e-test/java/org/alfresco/rest/workflow/deployments/get/GetDeploymentSanityTests.java index 3259dbb1c..487d7dc9a 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/get/GetDeploymentSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.deployments; +package org.alfresco.rest.workflow.deployments.get; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/get/GetDeploymentsCoreTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsCoreTests.java rename to e2e-test/java/org/alfresco/rest/workflow/deployments/get/GetDeploymentsCoreTests.java index d2542f4b9..7082bff55 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/get/GetDeploymentsCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.deployments; +package org.alfresco.rest.workflow.deployments.get; import java.util.List; diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/get/GetDeploymentsFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsFullTests.java rename to e2e-test/java/org/alfresco/rest/workflow/deployments/get/GetDeploymentsFullTests.java index d6ab2eaec..d8b16cac8 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/get/GetDeploymentsFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.deployments; +package org.alfresco.rest.workflow.deployments.get; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/get/GetDeploymentsSanityTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsSanityTests.java rename to e2e-test/java/org/alfresco/rest/workflow/deployments/get/GetDeploymentsSanityTests.java index 6eab0bae6..2da6f8daf 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/get/GetDeploymentsSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.deployments; +package org.alfresco.rest.workflow.deployments.get; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/delete/DeleteProcessCoreTests.java similarity index 93% rename from e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessCoreTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/delete/DeleteProcessCoreTests.java index 98f6226ec..e63ac0aa5 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/delete/DeleteProcessCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes; +package org.alfresco.rest.workflow.processes.delete; import org.alfresco.dataprep.CMISUtil.Priority; import org.alfresco.rest.RestTest; @@ -24,7 +24,7 @@ public class DeleteProcessCoreTests extends RestTest assignee = dataUser.createRandomTestUser(); } - @TestRail(section = { TestGroup.REST_API, + @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify admin user is able to delete a process started by another user.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) @@ -39,7 +39,7 @@ public class DeleteProcessCoreTests extends RestTest .assertThat().entriesListDoesNotContain("id", process.getId()); } - @TestRail(section = { TestGroup.REST_API, + @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify User is not able to delete process with invalid id") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) @@ -53,7 +53,7 @@ public class DeleteProcessCoreTests extends RestTest .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "00001")); } - @TestRail(section = { TestGroup.REST_API, + @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify User is not able to delete process with empty id") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/delete/DeleteProcessFullTests.java similarity index 92% rename from e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessFullTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/delete/DeleteProcessFullTests.java index ca69ff98c..6c6e0729b 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/delete/DeleteProcessFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes; +package org.alfresco.rest.workflow.processes.delete; import org.alfresco.dataprep.CMISUtil.Priority; import org.alfresco.rest.RestTest; @@ -29,7 +29,7 @@ public class DeleteProcessFullTests extends RestTest assignee = dataUser.createRandomTestUser(); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify user is NOT able to delete process started by him twice using REST API and status code is NOT FOUND (404)") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) public void deleteProcessByUserWhoStartedProcessTwice() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessItemCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/delete/DeleteProcessItemCoreTests.java similarity index 91% rename from e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessItemCoreTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/delete/DeleteProcessItemCoreTests.java index 71fa125bc..0faa26e46 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessItemCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/delete/DeleteProcessItemCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes; +package org.alfresco.rest.workflow.processes.delete; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; @@ -37,7 +37,7 @@ public class DeleteProcessItemCoreTests extends RestTest .createSingleReviewerTaskAndAssignTo(assignee); } - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Delete process item with invalid id") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) public void deleteProcessItemWithInvalidItemId() throws Exception @@ -52,7 +52,7 @@ public class DeleteProcessItemCoreTests extends RestTest .assertLastError().containsSummary(String.format(RestErrorModel.PROCESS_ENTITY_NOT_FOUND, "invalid-id")); } - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Delete process item with empty id") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) public void deleteProcessItemWithEmptyItemId() throws Exception @@ -67,7 +67,7 @@ public class DeleteProcessItemCoreTests extends RestTest .assertLastError().containsSummary(String.format(RestErrorModel.DELETE_EMPTY_ARGUMENT)); } - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Delete process item twice") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) public void deleteProcessItemTwice() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessItemFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/delete/DeleteProcessItemFullTests.java similarity index 90% rename from e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessItemFullTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/delete/DeleteProcessItemFullTests.java index bbf103914..e9e0009b4 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessItemFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/delete/DeleteProcessItemFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes; +package org.alfresco.rest.workflow.processes.delete; import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.CMISUtil.DocumentType; @@ -48,7 +48,7 @@ public class DeleteProcessItemFullTests extends RestTest processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().usingProcess(processModel).getProcess(); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Try to delete existing process item using empty processId") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) public void deleteProcessItemUsingEmptyProcessId() throws Exception @@ -67,7 +67,7 @@ public class DeleteProcessItemFullTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add a new process item, update the item and then delete.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) public void createUpdateDeleteProcessItem() throws Exception @@ -85,7 +85,7 @@ public class DeleteProcessItemFullTests extends RestTest .assertThat().entriesListDoesNotContain("name", processItem.getName()); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Delete process item using any user.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) public void deleteProcessItemByAnyUser() throws Exception @@ -106,7 +106,7 @@ public class DeleteProcessItemFullTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE);; } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Delete process item with admin.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) public void deleteProcessItemWithAdmin() throws Exception @@ -122,7 +122,7 @@ public class DeleteProcessItemFullTests extends RestTest .assertThat().entriesListDoesNotContain("name", processItem.getName()); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Delete process item by the user who is involved in the process.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) public void deleteProcessItemByUserInvolvedInTheProcess() throws Exception @@ -137,7 +137,7 @@ public class DeleteProcessItemFullTests extends RestTest .assertThat().entriesListDoesNotContain("name", processItem.getName()); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Delete process item by the user who started the process.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) public void deleteProcessItemByUserThatStartedTheProcess() throws Exception @@ -152,7 +152,7 @@ public class DeleteProcessItemFullTests extends RestTest .assertThat().entriesListDoesNotContain("name", processItem.getName()); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Delete process item for a deleted process.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) public void deleteProcessItemsForDeletedProcess() throws Exception @@ -173,7 +173,7 @@ public class DeleteProcessItemFullTests extends RestTest } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Delete process item by inexistent user.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) public void deleteProcessItemByInexistentUser() throws Exception @@ -192,7 +192,7 @@ public class DeleteProcessItemFullTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Delete process item for process without items.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL}, expectedExceptions = EmptyRestModelCollectionException.class) @@ -209,7 +209,7 @@ public class DeleteProcessItemFullTests extends RestTest .deleteProcessItem(items.getOneRandomEntry()); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Delete process item using by the admin in same network.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL, TestGroup.NETWORKS }) public void deleteProcessItemByAdminSameNetwork() throws Exception @@ -235,7 +235,7 @@ public class DeleteProcessItemFullTests extends RestTest .assertThat().entriesListDoesNotContain("name", processItem.getName()); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Delete process item using by admin in other network.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE, TestGroup.NETWORKS }) public void deleteProcessItemByAdminInOtherNetwork() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessItemSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/delete/DeleteProcessItemSanityTests.java similarity index 91% rename from e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessItemSanityTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/delete/DeleteProcessItemSanityTests.java index f5f9e0170..a2189edff 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessItemSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/delete/DeleteProcessItemSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes; +package org.alfresco.rest.workflow.processes.delete; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; @@ -36,7 +36,7 @@ public class DeleteProcessItemSanityTests extends RestTest dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); } - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Delete existing process item") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public void deleteProcessItem() throws Exception @@ -51,7 +51,7 @@ public class DeleteProcessItemSanityTests extends RestTest .assertThat().entriesListDoesNotContain("id", processItem.getId()); } - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Try to delete existing process item using invalid processId") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public void deleteProcessItemUsingInvalidProcessId() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/delete/DeleteProcessSanityTests.java similarity index 88% rename from e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/delete/DeleteProcessSanityTests.java index 720a99870..69d14332b 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/delete/DeleteProcessSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes; +package org.alfresco.rest.workflow.processes.delete; import org.alfresco.dataprep.CMISUtil.Priority; import org.alfresco.rest.RestTest; @@ -27,7 +27,7 @@ public class DeleteProcessSanityTests extends RestTest anotherUser = dataUser.createRandomTestUser(); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify User is able to delete process started by him using REST API and status code is OK (204)") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public void deleteProcessByUserWhoStartedProcess() throws Exception @@ -41,7 +41,7 @@ public class DeleteProcessSanityTests extends RestTest restClient.withWorkflowAPI().getProcesses().assertThat().entriesListDoesNotContain("id", process.getId()); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify User is able to delete process assigned to him using REST API and status code is OK (204)") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public void deleteProcessByAssignedUser() throws Exception @@ -55,7 +55,7 @@ public class DeleteProcessSanityTests extends RestTest restClient.withWorkflowAPI().getProcesses().assertThat().entriesListDoesNotContain("id", process.getId()); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify User that is not involved in a process is not authorized to delete it using REST API and status code is 403") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public void deleteProcessByAnotherUser() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/delete/DeleteProcessVariableCoreTests.java similarity index 91% rename from e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableCoreTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/delete/DeleteProcessVariableCoreTests.java index ba4eec3e6..b4484ebd5 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/delete/DeleteProcessVariableCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes; +package org.alfresco.rest.workflow.processes.delete; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; @@ -43,7 +43,7 @@ public class DeleteProcessVariableCoreTests extends RestTest .createSingleReviewerTaskAndAssignTo(assignee); } - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Delete invalid process variable") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) public void deleteInvalidProcessVariable() throws Exception @@ -59,7 +59,7 @@ public class DeleteProcessVariableCoreTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE); } - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Delete process variable twice") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) public void deleteProcessVariableTwice() throws Exception @@ -76,7 +76,7 @@ public class DeleteProcessVariableCoreTests extends RestTest .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, variableModel.getName())); } - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = {TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Remove process variables with empty processId") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) public void deleteProcessVariableEmptyProcessId() throws JsonToModelConversionException, Exception @@ -97,7 +97,7 @@ public class DeleteProcessVariableCoreTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Delete process variable with admin.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) public void deleteProcessVariableWithAdmin() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/delete/DeleteProcessVariableFullTests.java similarity index 94% rename from e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableFullTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/delete/DeleteProcessVariableFullTests.java index 06625e13a..241ade05b 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/delete/DeleteProcessVariableFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes; +package org.alfresco.rest.workflow.processes.delete; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.CMISUtil.Priority; @@ -37,7 +37,7 @@ public class DeleteProcessVariableFullTests extends RestTest processModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createSingleReviewerTaskAndAssignTo(assignee); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Delete empty process variable") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) public void deleteEmptyProcessVariable() throws Exception @@ -56,7 +56,7 @@ public class DeleteProcessVariableFullTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add a new process varaiables, update the variable and then delete.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) public void createUpdateDeleteProcessVariable() throws Exception @@ -82,7 +82,7 @@ public class DeleteProcessVariableFullTests extends RestTest .entriesListDoesNotContain("name", updatedVariable.getName()); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Delete process then delete process variables, status OK should be returned") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) public void deleteProcessVariablesForADeletedProcess() throws Exception @@ -112,7 +112,7 @@ public class DeleteProcessVariableFullTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Delete process variable using by the user who started the process.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) public void deleteProcessVariableByUserThatStartedTheProcess() throws Exception @@ -134,7 +134,7 @@ public class DeleteProcessVariableFullTests extends RestTest .entriesListDoesNotContain("name", variableModel.getName()); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Delete process variable using by the user involved in the process.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) public void deleteProcessVariableByUserInvolvedInTheProcess() throws Exception @@ -222,7 +222,7 @@ public class DeleteProcessVariableFullTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, description = "Verify that admin from the same network is able to delete network process variables") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL, TestGroup.NETWORKS }) public void deleteProcessVariablesWithAdminFromSameNetwork() throws Exception @@ -247,7 +247,7 @@ public class DeleteProcessVariableFullTests extends RestTest .entriesListDoesNotContain("name", variableModel.getName()); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, description = "Verify that admin from different network is not able to delete network process variables") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL, TestGroup.NETWORKS }) public void deleteProcessVariablesWithAdminFromDifferentNetwork() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/delete/DeleteProcessVariableSanityTests.java similarity index 91% rename from e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableSanityTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/delete/DeleteProcessVariableSanityTests.java index 7743ce292..35e30b523 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/delete/DeleteProcessVariableSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes; +package org.alfresco.rest.workflow.processes.delete; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.CMISUtil.Priority; @@ -40,7 +40,7 @@ public class DeleteProcessVariableSanityTests extends RestTest processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().addProcess("activitiAdhoc", adminUser, false, Priority.Normal); } - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Delete existing variable") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public void deleteProcessVariable() throws Exception @@ -54,7 +54,7 @@ public class DeleteProcessVariableSanityTests extends RestTest .assertThat().entriesListDoesNotContain("name", variableModel.getName()); } - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Try to delete existing variable using invalid processId") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public void deleteProcessVariableUsingInvalidProcessId() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessCoreTests.java similarity index 90% rename from e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessCoreTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessCoreTests.java index 214a562d7..cec46a122 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes; +package org.alfresco.rest.workflow.processes.get; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; @@ -26,7 +26,7 @@ public class GetProcessCoreTests extends RestTest assignee = dataUser.createRandomTestUser(); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify that using invalid process ID returns status code 404") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE}) public void invalidProcessIdTest() throws Exception @@ -39,7 +39,7 @@ public class GetProcessCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, processId)); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES, TestGroup.NETWORKS}, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES}, executionType = ExecutionType.REGRESSION, description = "Verify that tenant user cannot get process from another network") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE, TestGroup.NETWORKS }) @Bug(id = "MNT-17238") @@ -60,7 +60,7 @@ public class GetProcessCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify that tenant user can get process from the same network") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE, TestGroup.NETWORKS }) public void tenantUserCanGetProcessFromTheSameNetwork() throws Exception @@ -77,7 +77,7 @@ public class GetProcessCoreTests extends RestTest .and().field("startUserId").is(networkProcess1.getStartUserId());; } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES, TestGroup.NETWORKS}, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES}, executionType = ExecutionType.REGRESSION, description = "Verify that non network user cannot get process from a network") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE, TestGroup.NETWORKS }) @Bug(id = "MNT-17238") diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessFullTests.java similarity index 92% rename from e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessFullTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessFullTests.java index 87c0272c3..addd77720 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes; +package org.alfresco.rest.workflow.processes.get; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; @@ -29,7 +29,7 @@ public class GetProcessFullTests extends RestTest addedProcess = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.High); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify that admin user can get process started by a network user") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL, TestGroup.NETWORKS }) public void adminUserCanGetProcessFromANetwork() throws Exception @@ -51,7 +51,7 @@ public class GetProcessFullTests extends RestTest .and().field("processDefinitionKey").is("activitiReview"); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify user is able to get the process with properties parameter applied using REST API") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) public void getProcessWithPropertiesParameter() throws Exception @@ -64,7 +64,7 @@ public class GetProcessFullTests extends RestTest .and().field("processDefinitionKey").isNull(); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify user is able to get a process that was deleted, but it has 'deleted through REST API call' deleteReason") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) public void getDeletedProcess() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessItemsCoreTests.java similarity index 89% rename from e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsCoreTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessItemsCoreTests.java index eb34615df..5cf56d990 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessItemsCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes; +package org.alfresco.rest.workflow.processes.get; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; @@ -32,7 +32,7 @@ public class GetProcessItemsCoreTests extends RestTest dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify that admin calling getProcessItems can see anything with REST API and status code is OK (200)") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) public void getProcessItemsAsAdminReturnsAnything() throws Exception @@ -44,7 +44,7 @@ public class GetProcessItemsCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify getProcessItems for invalid processId with REST API and status code is NOT_FOUND (404)") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) public void getProcessItemsForInvalidProcessId() throws Exception @@ -56,7 +56,7 @@ public class GetProcessItemsCoreTests extends RestTest .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidProcessId")); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify getProcessItems for empty processId with REST API and status code is NOT_FOUND (404)") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) public void getProcessItemsForEmptyProcessId() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessItemsFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsFullTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessItemsFullTests.java index aba458d6c..ba9fc7f44 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessItemsFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes; +package org.alfresco.rest.workflow.processes.get; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessItemsSanityTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsSanityTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessItemsSanityTests.java index 7f4ec57ed..4190225f2 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessItemsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessItemsSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes; +package org.alfresco.rest.workflow.processes.get; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.CMISUtil.Priority; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessSanityTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessSanityTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessSanityTests.java index b4288002a..3f1312e75 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes; +package org.alfresco.rest.workflow.processes.get; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessTasksCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksCoreTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessTasksCoreTests.java index 0b8e057d7..8bd5344da 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessTasksCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes; +package org.alfresco.rest.workflow.processes.get; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessTasksFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksFullTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessTasksFullTests.java index e9ff76c4d..17c7292c3 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessTasksFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes; +package org.alfresco.rest.workflow.processes.get; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessTasksSanityTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksSanityTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessTasksSanityTests.java index 57e747c63..33235d61b 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessTasksSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessTasksSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes; +package org.alfresco.rest.workflow.processes.get; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessVariablesCoreTests.java similarity index 90% rename from e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesCoreTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessVariablesCoreTests.java index b87a570e8..ca51f802e 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessVariablesCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes; +package org.alfresco.rest.workflow.processes.get; import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.CMISUtil.DocumentType; @@ -38,7 +38,7 @@ public class GetProcessVariablesCoreTests extends RestTest dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); } - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + @TestRail(section = {TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify that admin from the same network is able to retrieve network process variables") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE, TestGroup.NETWORKS }) public void getProcessVariablesWithAdminFromSameNetwork() throws Exception @@ -55,7 +55,7 @@ public class GetProcessVariablesCoreTests extends RestTest variables.assertThat().entriesListIsNotEmpty(); } - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify that admin from different network is not able to retrieve network process variables") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE, TestGroup.NETWORKS }) public void getProcessVariablesWithAdminFromDifferentNetwork() throws Exception @@ -71,7 +71,7 @@ public class GetProcessVariablesCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT); } - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Get process variables using invalid process ID") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) public void getProcessVariablesUsingInvalidProcessId() throws Exception @@ -90,7 +90,7 @@ public class GetProcessVariablesCoreTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE); } - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Get process variables using empty process ID") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) public void getProcessVariablesUsingEmptyProcessId() throws Exception @@ -101,7 +101,7 @@ public class GetProcessVariablesCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); } - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Delete process then get process variables, status OK should be returned") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) public void getProcessVariablesForADeletedProcess() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessVariablesFullTests.java similarity index 89% rename from e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesFullTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessVariablesFullTests.java index 695e29683..b775bcbbd 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessVariablesFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes; +package org.alfresco.rest.workflow.processes.get; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; @@ -32,7 +32,7 @@ public class GetProcessVariablesFullTests extends RestTest processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.Normal); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify get all process variables call using admin user. Admin can see the process even if he isn't involved in it.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) public void getProcessVariablesUsingAdmin() throws Exception @@ -59,7 +59,7 @@ public class GetProcessVariablesFullTests extends RestTest } @Bug(id = "MNT-17438") - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify get all process variables with valid skip count parameter applied.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) public void getProcessVariablesWithValidSkipCount() throws Exception @@ -77,7 +77,7 @@ public class GetProcessVariablesFullTests extends RestTest .assertThat().paginationField("skipCount").is("2"); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify get all process variables with negative skip count parameter applied.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) public void getProcessVariablesWithNegativeSkipCount() throws Exception @@ -91,7 +91,7 @@ public class GetProcessVariablesFullTests extends RestTest .statusCodeIs(HttpStatus.BAD_REQUEST); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify get all process variables with not numeric skip count parameter applied.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) public void getProcessVariablesWithNonNumericSkipCount() throws Exception @@ -102,7 +102,7 @@ public class GetProcessVariablesFullTests extends RestTest } @Bug(id = "MNT-17438") - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify get all process variables with valid maxItems parameter applied.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) public void getProcessVariablesWithValidMaxItems() throws Exception @@ -120,7 +120,7 @@ public class GetProcessVariablesFullTests extends RestTest .assertThat().paginationField("maxItems").is("2"); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify get all process variables with negative maxItems parameter applied.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) public void getProcessVariablesWithNegativeMaxItems() throws Exception @@ -134,7 +134,7 @@ public class GetProcessVariablesFullTests extends RestTest .statusCodeIs(HttpStatus.BAD_REQUEST); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify get all process variables with not numeric maxItems parameter applied.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) public void getProcessVariablesWithNonNumericMaxItems() throws Exception @@ -144,7 +144,7 @@ public class GetProcessVariablesFullTests extends RestTest .containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "A")); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify get all process variables with properties parameter.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) public void getProcessVariablesWithPropertiesParameter() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessVariablesSanityTests.java similarity index 90% rename from e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesSanityTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessVariablesSanityTests.java index fbeb3d116..d68f3be1c 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessVariablesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessVariablesSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes; +package org.alfresco.rest.workflow.processes.get; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; @@ -36,7 +36,7 @@ public class GetProcessVariablesSanityTests extends RestTest dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); } - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify that user that started the process gets all process variables") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public void getProcessVariablesUsingTheUserWhoStartedProcess() throws JsonToModelConversionException, Exception @@ -47,7 +47,7 @@ public class GetProcessVariablesSanityTests extends RestTest variables.assertThat().entriesListIsNotEmpty(); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify get all process variables call using a user that is involved in the process") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public void getProcessVariablesUsingUserInvolvedInProcess() throws JsonToModelConversionException, Exception diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessesCoreTests.java similarity index 91% rename from e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesCoreTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessesCoreTests.java index 249792319..cb70f074c 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessesCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes; +package org.alfresco.rest.workflow.processes.get; import java.util.List; @@ -46,7 +46,7 @@ public class GetProcessesCoreTests extends RestTest process3 = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createSingleReviewerTaskAndAssignTo(assignee); } - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify admin gets all processes from same network") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE, TestGroup.NETWORKS }) public void getProcessFromSameNetworkUsingAdmin() throws Exception @@ -63,7 +63,7 @@ public class GetProcessesCoreTests extends RestTest tenantProcesses.assertThat().entriesListContains("id", process.getId()); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets all processes started by him ordered descending by id") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) public void getProcessesOrderedByIdDESC() throws Exception @@ -78,7 +78,7 @@ public class GetProcessesCoreTests extends RestTest processesList.get(2).onModel().assertThat().field("id").is(task1.getProcessId()); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets processes that matches a where clause") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) public void getProcessesWithWhereClauseAsParameter() throws JsonToModelConversionException, Exception diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessesFullTests.java similarity index 91% rename from e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesFullTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessesFullTests.java index 58c981d5e..d8dd46427 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessesFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes; +package org.alfresco.rest.workflow.processes.get; import java.util.List; @@ -47,7 +47,7 @@ public class GetProcessesFullTests extends RestTest process3 = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createSingleReviewerTaskAndAssignTo(assignee); } - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify any user cannot get processes from same network") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL, TestGroup.NETWORKS }) public void getProcessFromSameNetworkUsingAnyUser() throws Exception @@ -64,7 +64,7 @@ public class GetProcessesFullTests extends RestTest tenantProcesses.assertThat().entriesListIsEmpty().and().paginationField("count").is("0"); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets processes when skipCount parameter is applied") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) public void getProcessesWithSkipCountParameter() throws Exception @@ -85,7 +85,7 @@ public class GetProcessesFullTests extends RestTest processes.getEntries().get(0).onModel().assertThat().field("id").is(process3.getId()); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets processes when maxItems parameter is applied") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) public void getProcessesWithMaxItemsParameter() throws Exception @@ -106,7 +106,7 @@ public class GetProcessesFullTests extends RestTest processes.getEntries().get(1).onModel().assertThat().field("id").is(process2.getId()); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets processes when properties parameter is applied") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) public void getProcessesWithPropertiesParameter() throws Exception @@ -134,7 +134,7 @@ public class GetProcessesFullTests extends RestTest } @Bug(id = "REPO-1958") - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot get processes when using an invalid orderBy parameter") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) public void getProcessesWithInvalidOrderByParameter() throws Exception @@ -148,7 +148,7 @@ public class GetProcessesFullTests extends RestTest .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot get processes when using an invalid parameter in where clause") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) public void getProcessesWithInvalidWhereParameter() throws Exception @@ -162,7 +162,7 @@ public class GetProcessesFullTests extends RestTest .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot get processes when using an invalid where clause expression") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) public void getProcessesWithInvalidWhereClauseExpression() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessesSanityTests.java similarity index 86% rename from e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessesSanityTests.java index 3a3a62bf5..9ee7687bd 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessesSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes; +package org.alfresco.rest.workflow.processes.get; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; @@ -36,7 +36,7 @@ public class GetProcessesSanityTests extends RestTest task = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify User gets all processes started by him using REST API and status code is OK (200)") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public void getProcessesByUserWhoStartedProcess() throws Exception @@ -46,7 +46,7 @@ public class GetProcessesSanityTests extends RestTest allProcesses.assertThat().entriesListContains("id", task.getProcessId()); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify User gets all processes assigned to him using REST API and status code is OK (200)") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public void getProcessesByAssignedUser() throws Exception @@ -56,7 +56,7 @@ public class GetProcessesSanityTests extends RestTest allProcesses.assertThat().entriesListContains("id", task.getProcessId()); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify User that is not involved in a process can not get that process using REST API and status code is OK (200)") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public void getProcessesByAnotherUser() throws Exception @@ -66,7 +66,7 @@ public class GetProcessesSanityTests extends RestTest allProcesses.assertThat().entriesListDoesNotContain("id", task.getProcessId()); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify Admin gets all processes, even if he isn't involved in a process, using REST API and status code is OK (200)") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public void getProcessesByAdmin() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/post/AddProcessCoreTests.java similarity index 92% rename from e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessCoreTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/post/AddProcessCoreTests.java index 12bc5e898..4ec85a49c 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/post/AddProcessCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes; +package org.alfresco.rest.workflow.processes.post; import org.alfresco.dataprep.CMISUtil.Priority; import org.alfresco.rest.RestTest; @@ -27,7 +27,7 @@ public class AddProcessCoreTests extends RestTest private RestProcessModel addedProcess; private RestProcessModelsCollection processes; - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify non network admin is able to start new process using REST API and status code is OK (200)") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) public void nonNetworkAdminUserStartsNewProcess() throws JsonToModelConversionException, Exception @@ -50,7 +50,7 @@ public class AddProcessCoreTests extends RestTest .assertThat().entriesListContains("processDefinitionKey", "activitiAdhoc"); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify start new process with empty request body using REST API returns status code is Bad Request (400)") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) public void startNewProcessWithEmptyProcessBody() throws JsonToModelConversionException, Exception @@ -66,7 +66,7 @@ public class AddProcessCoreTests extends RestTest } @Bug(id = "ACE-5671") - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify start new process with invalid request body using REST API returns status code is Bad Request (400)") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) public void startNewProcessWithInvalidProcessDefInProcessBody() throws JsonToModelConversionException, Exception @@ -80,7 +80,7 @@ public class AddProcessCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify start new process with invalid request body using REST API returns status code is Bad Request (400)") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) public void startNewProcessWithInvalidVariablesInProcessBody1() throws JsonToModelConversionException, Exception @@ -95,7 +95,7 @@ public class AddProcessCoreTests extends RestTest .assertLastError().containsSummary("Either processDefinitionId or processDefinitionKey is required"); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify start new process with invalid request body using REST API returns status code is Bad Request (400)") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) public void startNewProcessWithInvalidVariablesInProcessBody2() throws JsonToModelConversionException, Exception @@ -110,7 +110,7 @@ public class AddProcessCoreTests extends RestTest .assertLastError().containsSummary("Either processDefinitionId or processDefinitionKey is required"); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify start new process with invalid request body using REST API returns status code is Bad Request (400)") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) public void startNewProcessWithInvalidVariablesInProcessBody3() throws JsonToModelConversionException, Exception diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/post/AddProcessFullTests.java similarity index 91% rename from e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessFullTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/post/AddProcessFullTests.java index 48154377f..e76865b02 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/post/AddProcessFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes; +package org.alfresco.rest.workflow.processes.post; import javax.json.JsonObject; @@ -34,7 +34,7 @@ public class AddProcessFullTests extends RestTest assignee = dataUser.createRandomTestUser(); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify network user cannot start new process with processDefinitionKey from another network using REST API and status code is 400") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL, TestGroup.NETWORKS}) public void networkUserCannotStartNewProcessWithProcessDefinitionFromAnotherNetwork() throws JsonToModelConversionException, Exception @@ -56,7 +56,7 @@ public class AddProcessFullTests extends RestTest .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify network user can start new process with processDefinitionKey from same network using REST API and status code is 201") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL, TestGroup.NETWORKS}) public void networkUserCanStartNewProcessWithProcessDefinitionFromSameNetwork() throws JsonToModelConversionException, Exception @@ -77,7 +77,7 @@ public class AddProcessFullTests extends RestTest .and().field("processDefinitionKey").is(processDefinitionKey); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot start new process with invalid processDefinitionKey using REST API and status code is 400") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) public void userStartsNewProcessWithInvalidProcessDefinitionKey() throws JsonToModelConversionException, Exception @@ -93,7 +93,7 @@ public class AddProcessFullTests extends RestTest } @Bug(id = "REPO-1970") - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot start new process with invalid processDefinitionKey using REST API and status code is 400") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) public void userStartsNewProcessWithEmptyVariablesBody() throws JsonToModelConversionException, Exception @@ -111,7 +111,7 @@ public class AddProcessFullTests extends RestTest } @Bug(id = "REPO-1970") - @TestRail(section = { TestGroup.REST_API,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot start new process with invalid processDefinitionKey using REST API and status code is 400") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) public void userStartsNewProcessWithNoAssigneeInVariablesBody() throws JsonToModelConversionException, Exception @@ -130,7 +130,7 @@ public class AddProcessFullTests extends RestTest .containsErrorKey(String.format(RestErrorModel.NO_WORKFLOW_DEFINITION_FOUND, "activitiAdhoc")); } - @TestRail(section = { TestGroup.REST_API,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot start new process with invalid assignee using REST API and status code is 400") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) public void userStartsNewProcessWithInvalidAssignee() throws JsonToModelConversionException, Exception @@ -147,7 +147,7 @@ public class AddProcessFullTests extends RestTest } @Bug(id = "REPO-1970") - @TestRail(section = { TestGroup.REST_API,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot start new process with invalid sendEMailNotifications value using REST API and status code is 400") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) public void userStartsNewProcessWithInvalidEmailNotification() throws JsonToModelConversionException, Exception @@ -170,7 +170,7 @@ public class AddProcessFullTests extends RestTest } @Bug(id = "REPO-1970") - @TestRail(section = { TestGroup.REST_API,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot start new process with invalid priority using REST API and status code is 400") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) public void userStartsNewProcessWithInvalidPriority() throws JsonToModelConversionException, Exception diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/post/AddProcessItemCoreTests.java similarity index 94% rename from e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemCoreTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/post/AddProcessItemCoreTests.java index 379a8ecb2..d76dbd106 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/post/AddProcessItemCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes; +package org.alfresco.rest.workflow.processes.post; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.CMISUtil.Priority; @@ -42,7 +42,7 @@ public class AddProcessItemCoreTests extends RestTest dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add process item using by the user who started the process.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) public void addProcessItemByUserThatStartedTheProcess() throws Exception @@ -56,7 +56,7 @@ public class AddProcessItemCoreTests extends RestTest .and().field("id").isNotEmpty().and().field("mimeType").is(document.getFileType().mimeType); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add multiple process items using by the user who started the process.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) public void addMultipleProcessItemsByUserThatStartedTheProcess() throws Exception @@ -85,7 +85,7 @@ public class AddProcessItemCoreTests extends RestTest .field("mimeType").is(document2.getFileType().mimeType); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add process item by a random user.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) public void addProcessItemByAnyUser() throws Exception @@ -100,7 +100,7 @@ public class AddProcessItemCoreTests extends RestTest .containsSummary(String.format(RestErrorModel.ACCESS_INFORMATION_NOT_ALLOWED, processModel.getId())); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add multiple process item by a random user.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) public void addMultipleProcessItemByAnyUser() throws Exception @@ -116,7 +116,7 @@ public class AddProcessItemCoreTests extends RestTest .containsSummary(String.format(RestErrorModel.ACCESS_INFORMATION_NOT_ALLOWED, processModel.getId())); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add process item using by the admin in same network.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE, TestGroup.NETWORKS }) public void addProcessItemByAdminSameNetwork() throws Exception @@ -140,7 +140,7 @@ public class AddProcessItemCoreTests extends RestTest .field("id").isNotEmpty().and().field("mimeType").is(document.getFileType().mimeType); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add multiple process items using by the admin in same network.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE, TestGroup.NETWORKS }) public void addMultipleProcessItemsByAdminSameNetwork() throws Exception @@ -179,7 +179,7 @@ public class AddProcessItemCoreTests extends RestTest .field("mimeType").is(document2.getFileType().mimeType); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add process item using by admin in other network.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE, TestGroup.NETWORKS }) public void addProcessItemByAdminInOtherNetwork() throws Exception @@ -197,7 +197,7 @@ public class AddProcessItemCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add multiple process items using by admin in other network.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE, TestGroup.NETWORKS }) public void addMultipleProcessItemsByAdminInOtherNetwork() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/post/AddProcessItemFullTests.java similarity index 96% rename from e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemFullTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/post/AddProcessItemFullTests.java index 27d3558aa..13de3c29d 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/post/AddProcessItemFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes; +package org.alfresco.rest.workflow.processes.post; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; @@ -88,7 +88,7 @@ public class AddProcessItemFullTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.REQUIRED_TO_ADD, "itemId")); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add a new process item, update the item and then delete.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) public void createDeleteCreateMultipleProcessItems() throws Exception @@ -108,7 +108,7 @@ public class AddProcessItemFullTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.CREATED); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add a new process item, delete the item and create it again.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) public void createDeleteCreateProcessItem() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/post/AddProcessItemSanityTests.java similarity index 94% rename from e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemSanityTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/post/AddProcessItemSanityTests.java index 1f9fc439f..44a4982c5 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessItemSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/post/AddProcessItemSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes; +package org.alfresco.rest.workflow.processes.post; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; @@ -41,7 +41,7 @@ public class AddProcessItemSanityTests extends RestTest dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); } - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Create non-existing process item") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY}) public void addProcessItem() throws JsonToModelConversionException, Exception @@ -65,7 +65,7 @@ public class AddProcessItemSanityTests extends RestTest .assertThat().entriesListContains("id", processItem.getId()); } - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Create non-existing process item") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY}) public void addMultipleProcessItem() throws JsonToModelConversionException, Exception @@ -105,7 +105,7 @@ public class AddProcessItemSanityTests extends RestTest } @Bug(id= "MNT-16966") - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Add process item that already exists") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY}) public void addProcessItemThatAlreadyExists() throws JsonToModelConversionException, Exception @@ -132,7 +132,7 @@ public class AddProcessItemSanityTests extends RestTest } @Bug(id= "MNT-16966") - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Add process item that already exists") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY}) public void addMultipleProcessItemThatAlreadyExists() throws JsonToModelConversionException, Exception diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/post/AddProcessSanityTests.java similarity index 94% rename from e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessSanityTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/post/AddProcessSanityTests.java index c1e110d7d..8f748ac3b 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/post/AddProcessSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes; +package org.alfresco.rest.workflow.processes.post; import org.alfresco.dataprep.CMISUtil.Priority; import org.alfresco.rest.RestTest; @@ -22,7 +22,7 @@ public class AddProcessSanityTests extends RestTest private RestProcessModel addedProcess; private RestProcessModelsCollection processes; - @TestRail(section = { TestGroup.REST_API, + @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify non network user is able to start new process using REST API and status code is OK (200)") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) @@ -41,7 +41,7 @@ public class AddProcessSanityTests extends RestTest processes.assertThat().entriesListContains("id", addedProcess.getId()); } - @TestRail(section = { TestGroup.REST_API, + @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Verify network user is able to start new process using REST API and status code is OK (200)") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY, TestGroup.NETWORKS }) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/post/AddProcessVariableCoreTests.java similarity index 96% rename from e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableCoreTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/post/AddProcessVariableCoreTests.java index d2668c907..b0bfb4656 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/post/AddProcessVariableCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes; +package org.alfresco.rest.workflow.processes.post; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.CMISUtil.Priority; @@ -39,7 +39,7 @@ public class AddProcessVariableCoreTests extends RestTest dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add process variable using by the user who started the process.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) public void addProcessVariableByUserThatStartedTheProcess() throws Exception @@ -54,7 +54,7 @@ public class AddProcessVariableCoreTests extends RestTest .and().field("value").is(variableModel.getValue()); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add process variable using by a random user.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) public void addProcessVariableByAnyUser() throws Exception @@ -185,7 +185,7 @@ public class AddProcessVariableCoreTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add process variable using by admin in other network.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE, TestGroup.NETWORKS }) public void addProcessVariableByAdminInOtherNetwork() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/post/AddProcessVariableFullTests.java similarity index 96% rename from e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableFullTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/post/AddProcessVariableFullTests.java index a735538ad..ad53fea97 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/post/AddProcessVariableFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes; +package org.alfresco.rest.workflow.processes.post; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; @@ -36,7 +36,7 @@ public class AddProcessVariableFullTests extends RestTest dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); } - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify addProcessVariable by any user for invalid processID with REST API and status code is NOT_FOUND (404)") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) public void addProcessVariableWithInvalidProcessId() throws Exception @@ -51,7 +51,7 @@ public class AddProcessVariableFullTests extends RestTest .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidProcessID")); } - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify addProcessVariable by any user for empty processID with REST API and status code is NOT_FOUND (404)") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) public void addProcessVariableWithEmptyProcessId() throws Exception @@ -169,7 +169,7 @@ public class AddProcessVariableFullTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE); } - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Update twice in a row the same variable.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) public void updateTwiceInARowSameProcessVariable() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/post/AddProcessVariableSanityTests.java similarity index 92% rename from e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/post/AddProcessVariableSanityTests.java index c8f2961c6..5065f86e4 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/post/AddProcessVariableSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes; +package org.alfresco.rest.workflow.processes.post; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.CMISUtil.Priority; @@ -39,7 +39,7 @@ public class AddProcessVariableSanityTests extends RestTest dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); } - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Create non-existing variable") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public void addProcessVariable() throws Exception @@ -57,7 +57,7 @@ public class AddProcessVariableSanityTests extends RestTest .assertThat().entriesListContains("name", variableModel.getName()); } - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Update existing variable") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public void updateExistingProcessVariable() throws Exception @@ -77,7 +77,7 @@ public class AddProcessVariableSanityTests extends RestTest processVariable.assertThat().field("value").is(newValue); } - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Add process variable using admin user from same network") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY, TestGroup.NETWORKS }) public void addProcessVariableByAdmin() throws Exception @@ -98,7 +98,7 @@ public class AddProcessVariableSanityTests extends RestTest .and().field("value").is(variableModel.getValue()); } - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Adding process variable is falling in case invalid variableBody is provided") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public void failedAddingProcessVariableIfInvalidBodyIsProvided() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/post/AddProcessVariablesCoreTests.java similarity index 93% rename from e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesCoreTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/post/AddProcessVariablesCoreTests.java index 4cc9fe80b..a00e49dd7 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/post/AddProcessVariablesCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes; +package org.alfresco.rest.workflow.processes.post; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; @@ -35,7 +35,7 @@ public class AddProcessVariablesCoreTests extends RestTest dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); } - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify addProcessVariable by any user with REST API and status code is CREATED (201)") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) public void addProcessVariableByAnyUser() throws Exception @@ -54,7 +54,7 @@ public class AddProcessVariablesCoreTests extends RestTest .assertThat().entriesListContains("name", variableModel.getName()); } - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify multiple addProcessVariable by any user with REST API and status code is CREATED (201)") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) public void addMultipleProcessVariableByAnyUser() throws Exception @@ -81,7 +81,7 @@ public class AddProcessVariablesCoreTests extends RestTest .assertThat().entriesListContains("name",variableModel1.getName()); } - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify addProcessVariable by any user for invalid processID with REST API and status code is NOT_FOUND (404)") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) public void addProcessVariableForInvalidProcessIdIsNotFound() throws Exception @@ -96,7 +96,7 @@ public class AddProcessVariablesCoreTests extends RestTest .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidProcessID")); } - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify addProcessVariable by any user for empty processID with REST API and status code is NOT_FOUND (404)") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) public void addProcessVariableForEmptyProcessIdIsEmpty() throws Exception @@ -111,7 +111,7 @@ public class AddProcessVariablesCoreTests extends RestTest .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add process variables using by the user who started the process.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) public void addProcessVariableByUserThatStartedTheProcess() throws Exception @@ -130,7 +130,7 @@ public class AddProcessVariablesCoreTests extends RestTest .assertThat().entriesListContains("name", variableModel.getName()); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add multiple process variables using by the user who started the process.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) public void addMultipleProcessVariableByUserThatStartedTheProcess() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/post/AddProcessVariablesFullTests.java similarity index 95% rename from e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesFullTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/post/AddProcessVariablesFullTests.java index 39fbefd92..eb7293108 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/post/AddProcessVariablesFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes; +package org.alfresco.rest.workflow.processes.post; import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.CMISUtil.Priority; @@ -42,7 +42,7 @@ public class AddProcessVariablesFullTests extends RestTest processModel = dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document).createSingleReviewerTaskAndAssignTo(assignee); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add process variables using by the user involved in the process.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) public void addProcessVariableByUserInvolvedTheProcess() throws Exception @@ -62,7 +62,7 @@ public class AddProcessVariablesFullTests extends RestTest .assertThat().entriesListContains("name", variableModel.getName()); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add process variables using by the user involved in the process.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) public void addMultipleProcessVariableByUserInvolvedTheProcess() throws Exception @@ -91,7 +91,7 @@ public class AddProcessVariablesFullTests extends RestTest .assertThat().entriesListContains("name", variableModel1.getName()); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add process variables using by inexistent user.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) public void addProcessVariableByInexistentUser() throws Exception @@ -111,7 +111,7 @@ public class AddProcessVariablesFullTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add multiple process variables using by inexistent user.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) public void addMultipleProcessVariableByInexistentUser() throws Exception @@ -271,7 +271,7 @@ public class AddProcessVariablesFullTests extends RestTest .assertThat().entriesListContains("name", variableModel.getName()); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add two process variables using by the user involved in the process.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) public void addingMultipleValidProcessVariables() throws Exception @@ -304,7 +304,7 @@ public class AddProcessVariablesFullTests extends RestTest .field("type").is(variableModel3.getType()); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add two process variables using by the user involved in the process.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) public void failedAddingMultipleProcessVariablesInvalidType() throws Exception @@ -326,7 +326,7 @@ public class AddProcessVariablesFullTests extends RestTest } @Bug(id = "REPO-1938") - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add two process variables using by the user involved in the process.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) public void failledAddingMultipleProcessVariablesInvalidTypePrefix() throws Exception @@ -392,7 +392,7 @@ public class AddProcessVariablesFullTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES}, executionType = ExecutionType.REGRESSION, description = "Add process variables using by Admin in other network.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL, TestGroup.NETWORKS }) public void addProcessVariablesByAdminInOtherNetwork() throws Exception @@ -422,7 +422,7 @@ public class AddProcessVariablesFullTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW,TestGroup.PROCESSES}, executionType = ExecutionType.REGRESSION, description = "Add multiple process variables using by Admin in other network.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL, TestGroup.NETWORKS }) public void addMultipleProcessVariablesByAdminInOtherNetwork() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/post/AddProcessVariablesSanityTests.java similarity index 93% rename from e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesSanityTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/post/AddProcessVariablesSanityTests.java index 265c0e32e..0e425975f 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariablesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/post/AddProcessVariablesSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes; +package org.alfresco.rest.workflow.processes.post; import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.CMISUtil.Priority; @@ -37,7 +37,7 @@ public class AddProcessVariablesSanityTests extends RestTest dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); } - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Create non-existing variable") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public void addProcessVariable() throws Exception @@ -55,7 +55,7 @@ public class AddProcessVariablesSanityTests extends RestTest .assertThat().entriesListContains("name", variableModel.getName()); } - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Create non-existing variable") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public void addMultipleProcessVariable() throws Exception @@ -90,7 +90,7 @@ public class AddProcessVariablesSanityTests extends RestTest .assertThat().entriesListContains("name", variableModel2.getName()); } - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Update existing variables") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public void updateExistingProcessVariable() throws Exception @@ -111,7 +111,7 @@ public class AddProcessVariablesSanityTests extends RestTest processVariable.assertThat().field("value").is(newValue); } - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Update existing variables") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public void updateExistingMultipleProcessVariable() throws Exception @@ -144,7 +144,7 @@ public class AddProcessVariablesSanityTests extends RestTest processVariableCollection.getEntries().get(1).onModel().assertThat().field("value").is(newValueVar1); } - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Adding process variables is falling in case invalid variableBody is provided") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public void failedAddingProcessVariableIfInvalidBodyIsProvided() throws Exception @@ -157,7 +157,7 @@ public class AddProcessVariablesSanityTests extends RestTest .assertLastError().containsSummary("Unsupported type of variable: 'incorrect type'."); } - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Add process variables using admin user from same network") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY, TestGroup.NETWORKS }) public void addProcessVariableByAdminSameNetwork() throws Exception @@ -178,7 +178,7 @@ public class AddProcessVariablesSanityTests extends RestTest .and().field("value").is(variableModel.getValue()); } - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Add multiple process variables using admin user from same network") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY, TestGroup.NETWORKS }) public void addMultipleProcessVariablesByAdminSameNetwork() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/UpdateProcessVariableTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/put/UpdateProcessVariableTests.java similarity index 90% rename from e2e-test/java/org/alfresco/rest/workflow/processes/UpdateProcessVariableTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/put/UpdateProcessVariableTests.java index 51285293d..fb497c827 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/UpdateProcessVariableTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/put/UpdateProcessVariableTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes; +package org.alfresco.rest.workflow.processes.put; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; @@ -34,7 +34,7 @@ public class UpdateProcessVariableTests extends RestTest dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); } - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Update existing variable using PUT call - invalid type") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public void updateProcessVariableInvalidType() throws Exception @@ -54,7 +54,7 @@ public class UpdateProcessVariableTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE); } - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Update existing variable using PUT call - invalid type") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public void updateProcessVariableTwoUsers() throws Exception @@ -71,7 +71,7 @@ public class UpdateProcessVariableTests extends RestTest updatedVariable.assertThat().field("type").is("d:text"); } - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Update existing variable using PUT call - value") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public void updateProcessVariableValue() throws Exception @@ -87,7 +87,7 @@ public class UpdateProcessVariableTests extends RestTest updatedVariable.assertThat().field("value").is("newValue"); } - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Update existing variable using PUT call - name") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public void updateProcessVariableName() throws Exception @@ -103,7 +103,7 @@ public class UpdateProcessVariableTests extends RestTest updatedVariable.assertThat().field("name").is("newVariableName"); } - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = {TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Update existing variable created by the user who started the process using put call with a user that is not involved in the process- value") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public void cantUpdateProcessVariableValueCreatedWithAnyUser() throws Exception @@ -121,7 +121,7 @@ public class UpdateProcessVariableTests extends RestTest .assertLastError().containsSummary(String.format(RestErrorModel.ACCESS_INFORMATION_NOT_ALLOWED, processModel.getId())); } - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Try to add process variable using an invalid processId") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public void updateProcessVariableUsingInvalidProcessId() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/DeleteTaskVariableCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/delete/DeleteTaskVariableCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/DeleteTaskVariableCoreTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/delete/DeleteTaskVariableCoreTests.java index 00b28faf6..8ada88687 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/DeleteTaskVariableCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/delete/DeleteTaskVariableCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks; +package org.alfresco.rest.workflow.tasks.delete; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/DeleteTaskVariableFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/delete/DeleteTaskVariableFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/DeleteTaskVariableFullTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/delete/DeleteTaskVariableFullTests.java index 76d4cff6c..4a9fce414 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/DeleteTaskVariableFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/delete/DeleteTaskVariableFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks; +package org.alfresco.rest.workflow.tasks.delete; import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.CMISUtil.DocumentType; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/DeleteTaskVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/delete/DeleteTaskVariableSanityTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/DeleteTaskVariableSanityTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/delete/DeleteTaskVariableSanityTests.java index ccd18b85f..219f2db04 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/DeleteTaskVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/delete/DeleteTaskVariableSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks; +package org.alfresco.rest.workflow.tasks.delete; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/RemoveTaskItemCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/delete/RemoveTaskItemCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/RemoveTaskItemCoreTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/delete/RemoveTaskItemCoreTests.java index 6cf8bba17..270fd72ff 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/RemoveTaskItemCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/delete/RemoveTaskItemCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks; +package org.alfresco.rest.workflow.tasks.delete; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/RemoveTaskItemFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/delete/RemoveTaskItemFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/RemoveTaskItemFullTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/delete/RemoveTaskItemFullTests.java index f1b8b0ddd..1be46face 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/RemoveTaskItemFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/delete/RemoveTaskItemFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks; +package org.alfresco.rest.workflow.tasks.delete; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/RemoveTaskItemSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/delete/RemoveTaskItemSanityTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/RemoveTaskItemSanityTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/delete/RemoveTaskItemSanityTests.java index b98c28042..d441b8405 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/RemoveTaskItemSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/delete/RemoveTaskItemSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks; +package org.alfresco.rest.workflow.tasks.delete; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCandidatesCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskCandidatesCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCandidatesCoreTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskCandidatesCoreTests.java index f8831a252..95bc35e10 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCandidatesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskCandidatesCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks; +package org.alfresco.rest.workflow.tasks.get; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCandidatesFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskCandidatesFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCandidatesFullTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskCandidatesFullTests.java index a2b8b1d4c..45f06df47 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCandidatesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskCandidatesFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks; +package org.alfresco.rest.workflow.tasks.get; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCandidatesSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskCandidatesSanityTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCandidatesSanityTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskCandidatesSanityTests.java index f6b7651fc..ff4ee8b49 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCandidatesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskCandidatesSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks; +package org.alfresco.rest.workflow.tasks.get; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCoreTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskCoreTests.java index dd2b8906e..687c8a998 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks; +package org.alfresco.rest.workflow.tasks.get; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.CMISUtil.Priority; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskFormModelCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelCoreTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskFormModelCoreTests.java index 366a60ead..1bedbf658 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskFormModelCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks; +package org.alfresco.rest.workflow.tasks.get; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskFormModelFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelFullTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskFormModelFullTests.java index d9b501d60..2bf561891 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskFormModelFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks; +package org.alfresco.rest.workflow.tasks.get; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskFormModelSanityTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelSanityTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskFormModelSanityTests.java index 36a98a800..6be7aa247 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskFormModelSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks; +package org.alfresco.rest.workflow.tasks.get; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFullTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskFullTests.java index 9bba5e6c9..23da8a30a 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks; +package org.alfresco.rest.workflow.tasks.get; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.CMISUtil.Priority; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskItemsCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskItemsCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskItemsCoreTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskItemsCoreTests.java index 63b469f2d..e1f5281f9 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskItemsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskItemsCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks; +package org.alfresco.rest.workflow.tasks.get; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.CMISUtil.Priority; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskItemsFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskItemsFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskItemsFullTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskItemsFullTests.java index 9ababbafa..9b36550b8 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskItemsFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskItemsFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks; +package org.alfresco.rest.workflow.tasks.get; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskItemsSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskItemsSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskItemsSanityTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskItemsSanityTests.java index 71ed12c34..29e38c7c2 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskItemsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskItemsSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks; +package org.alfresco.rest.workflow.tasks.get; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskSanityTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskSanityTests.java index 9f7f638bd..4e914d732 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskSanityTests.java @@ -1,5 +1,5 @@ -package org.alfresco.rest.workflow.tasks; +package org.alfresco.rest.workflow.tasks.get; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskVariablesCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskVariablesCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskVariablesCoreTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskVariablesCoreTests.java index ed14bcf3f..2ce70e0f3 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskVariablesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskVariablesCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks; +package org.alfresco.rest.workflow.tasks.get; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskVariablesFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskVariablesFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskVariablesFullTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskVariablesFullTests.java index cc1faf53d..fee0d069c 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskVariablesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskVariablesFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks; +package org.alfresco.rest.workflow.tasks.get; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskVariablesSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskVariablesSanityTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskVariablesSanityTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskVariablesSanityTests.java index d5d057cdd..d290af8f6 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskVariablesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskVariablesSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks; +package org.alfresco.rest.workflow.tasks.get; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTasksCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksCoreTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTasksCoreTests.java index f60f151ee..f3df71016 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTasksCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks; +package org.alfresco.rest.workflow.tasks.get; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.CMISUtil.Priority; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTasksFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksFullTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTasksFullTests.java index c51564b97..5b8f1d4c3 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTasksFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks; +package org.alfresco.rest.workflow.tasks.get; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.CMISUtil.Priority; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTasksSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksSanityTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTasksSanityTests.java index 18f26dc24..71ec7b830 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTasksSanityTests.java @@ -1,6 +1,6 @@ -package org.alfresco.rest.workflow.tasks; +package org.alfresco.rest.workflow.tasks.get; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/post/AddTaskItemCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemCoreTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/post/AddTaskItemCoreTests.java index 566f83a7b..a0dcbb36a 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/post/AddTaskItemCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks; +package org.alfresco.rest.workflow.tasks.post; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/post/AddTaskItemFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemFullTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/post/AddTaskItemFullTests.java index 2b55cd6d3..5824206de 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/post/AddTaskItemFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks; +package org.alfresco.rest.workflow.tasks.post; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/post/AddTaskItemSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemSanityTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/post/AddTaskItemSanityTests.java index bd1c566e6..2f5e4a983 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskItemSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/post/AddTaskItemSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks; +package org.alfresco.rest.workflow.tasks.post; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/post/AddTaskVariablesCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesCoreTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/post/AddTaskVariablesCoreTests.java index eaca6d13e..a608371ce 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/post/AddTaskVariablesCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks; +package org.alfresco.rest.workflow.tasks.post; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/post/AddTaskVariablesFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesFullTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/post/AddTaskVariablesFullTests.java index 2f4096315..cb41c444b 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/post/AddTaskVariablesFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks; +package org.alfresco.rest.workflow.tasks.post; import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.CMISUtil.DocumentType; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/post/AddTaskVariablesSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesSanityTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/post/AddTaskVariablesSanityTests.java index 794395c46..899aaa2b7 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/post/AddTaskVariablesSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks; +package org.alfresco.rest.workflow.tasks.post; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/put/UpdateTaskCoreTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/put/UpdateTaskCoreTests.java index cdfbaffdd..ff70b0bfd 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/put/UpdateTaskCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks; +package org.alfresco.rest.workflow.tasks.put; import java.util.HashMap; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTestsBulk2.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/put/UpdateTaskCoreTestsBulk2.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTestsBulk2.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/put/UpdateTaskCoreTestsBulk2.java index 5cb4aa8a3..658384fed 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTestsBulk2.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/put/UpdateTaskCoreTestsBulk2.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks; +package org.alfresco.rest.workflow.tasks.put; import javax.json.JsonObject; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTestsBulk3.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/put/UpdateTaskCoreTestsBulk3.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTestsBulk3.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/put/UpdateTaskCoreTestsBulk3.java index d6e53b4e7..9f2fe32ab 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTestsBulk3.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/put/UpdateTaskCoreTestsBulk3.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks; +package org.alfresco.rest.workflow.tasks.put; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk1.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/put/UpdateTaskFullTestsBulk1.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk1.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/put/UpdateTaskFullTestsBulk1.java index e3ee74d64..35e608770 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk1.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/put/UpdateTaskFullTestsBulk1.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks; +package org.alfresco.rest.workflow.tasks.put; import javax.json.JsonObject; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk2.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/put/UpdateTaskFullTestsBulk2.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk2.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/put/UpdateTaskFullTestsBulk2.java index 22f741646..a2185e126 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk2.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/put/UpdateTaskFullTestsBulk2.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks; +package org.alfresco.rest.workflow.tasks.put; import javax.json.JsonObject; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/put/UpdateTaskSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskSanityTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/put/UpdateTaskSanityTests.java index edb4670ef..d1631246f 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/put/UpdateTaskSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks; +package org.alfresco.rest.workflow.tasks.put; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskVariableCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/put/UpdateTaskVariableCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskVariableCoreTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/put/UpdateTaskVariableCoreTests.java index 883f78e74..f92fd52d2 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskVariableCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/put/UpdateTaskVariableCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks; +package org.alfresco.rest.workflow.tasks.put; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskVariableFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/put/UpdateTaskVariableFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskVariableFullTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/put/UpdateTaskVariableFullTests.java index 603431e0d..5f90ec367 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskVariableFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/put/UpdateTaskVariableFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks; +package org.alfresco.rest.workflow.tasks.put; import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.CMISUtil.DocumentType; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/put/UpdateTaskVariableSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskVariableSanityTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/put/UpdateTaskVariableSanityTests.java index fd1419c4e..e3ddb0c72 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/put/UpdateTaskVariableSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks; +package org.alfresco.rest.workflow.tasks.put; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; From 078823c37c8e3c245527b75f3d719b5f5cbe1db3 Mon Sep 17 00:00:00 2001 From: mionescu Date: Mon, 20 Feb 2017 17:14:40 +0200 Subject: [PATCH 1052/1491] updates - test structure --- .../{post => }/AddCommentCoreTests.java | 2 +- .../{post => }/AddCommentSanityTests.java | 2 +- .../{post => }/AddCommentsCoreTests.java | 2 +- .../{post => }/AddCommentsFullTests.java | 2 +- .../{post => }/AddCommentsSanityTests.java | 2 +- .../{delete => }/DeleteCommentCoreTests.java | 2 +- .../{delete => }/DeleteCommentFullTests.java | 2 +- .../DeleteCommentSanityTests.java | 2 +- .../{get => }/GetCommentsCoreTests.java | 2 +- .../{get => }/GetCommentsFullTests.java | 2 +- .../{get => }/GetCommentsSanityTests.java | 2 +- .../{put => }/UpdateCommentCoreTests.java | 2 +- .../{put => }/UpdateCommentFullTests.java | 2 +- .../{put => }/UpdateCommentSanityTests.java | 2 +- .../{post => }/AddFavoriteSiteCoreTests.java | 2 +- .../{post => }/AddFavoriteSiteFullTests.java | 2 +- .../AddFavoriteSiteSanityTests.java | 2 +- .../{post => }/AddFavoritesCoreTests.java | 2 +- .../{post => }/AddFavoritesFullTests.java | 2 +- .../{post => }/AddFavoritesSanityTests.java | 2 +- .../{delete => }/DeleteFavoriteCoreTests.java | 2 +- .../{delete => }/DeleteFavoriteFullTests.java | 2 +- .../DeleteFavoriteSanityTests.java | 2 +- .../DeleteFavoriteSiteCoreTests.java | 2 +- .../DeleteFavoriteSiteFullTests.java | 2 +- .../DeleteFavoriteSiteSanityTests.java | 2 +- .../{get => }/GetFavoriteCoreTests.java | 2 +- .../{get => }/GetFavoriteFullTests.java | 2 +- .../{get => }/GetFavoriteSanityTests.java | 2 +- .../{get => }/GetFavoriteSiteCoreTests.java | 2 +- .../{get => }/GetFavoriteSiteFullTests.java | 2 +- .../{get => }/GetFavoriteSiteSanityTests.java | 2 +- .../{get => }/GetFavoriteSitesCoreTests.java | 2 +- .../{get => }/GetFavoriteSitesFullTests.java | 2 +- .../GetFavoriteSitesSanityTests.java | 2 +- .../{get => }/GetFavoritesCoreTests.java | 2 +- .../{get => }/GetFavoritesFullTests.java | 2 +- .../{get => }/GetFavoritesSanityTests.java | 2 +- .../GetPeopleActivitiesCoreTests.java | 14 +++++------ .../GetPeopleActivitiesFullTests.java | 24 +++++++++---------- .../GetPeopleActivitiesSanityTests.java | 14 +++++------ .../GetPeoplePreferenceCoreTests.java | 10 ++++---- .../GetPeoplePreferenceFullTests.java | 22 ++++++++--------- .../GetPeoplePreferenceSanityTests.java | 14 +++++------ .../GetPeoplePreferencesCoreTests.java | 14 +++++------ .../GetPeoplePreferencesFullTests.java | 14 +++++------ .../GetPeoplePreferencesSanityTests.java | 14 +++++------ .../{post => }/AddRatingCoreTests.java | 2 +- .../{post => }/AddRatingFullTests.java | 2 +- .../{post => }/AddRatingSanityTests.java | 2 +- .../{delete => }/DeleteRatingCoreTests.java | 2 +- .../{delete => }/DeleteRatingFullTests.java | 2 +- .../{delete => }/DeleteRatingSanityTests.java | 2 +- .../ratings/{get => }/GetRatingCoreTests.java | 2 +- .../ratings/{get => }/GetRatingFullTests.java | 2 +- .../{get => }/GetRatingSanityTests.java | 2 +- .../{get => }/GetRatingsCoreTests.java | 2 +- .../{get => }/GetRatingsFullTests.java | 2 +- .../{get => }/GetRatingsSanityTests.java | 2 +- .../DeleteSiteMemberCoreTests.java | 2 +- .../DeleteSiteMemberFullTests.java | 2 +- .../DeleteSiteMemberSanityTests.java | 2 +- .../sites/{get => }/GetSiteCoreTests.java | 2 +- .../sites/{get => }/GetSiteFullTests.java | 2 +- .../{get => }/GetSiteMembershipCoreTests.java | 2 +- .../{get => }/GetSiteMembershipFullTests.java | 2 +- .../GetSiteMembershipSanityTests.java | 2 +- .../sites/{get => }/GetSiteSanityTests.java | 2 +- .../sites/{get => }/GetSitesCoreTests.java | 2 +- .../sites/{get => }/GetSitesFullTests.java | 2 +- ...etSitesMembershipInformationCoreTests.java | 2 +- ...etSitesMembershipInformationFullTests.java | 2 +- ...SitesMembershipInformationSanityTests.java | 2 +- .../sites/{get => }/GetSitesSanityTests.java | 2 +- .../GetSiteContainerCoreTests.java | 2 +- .../GetSiteContainerFullTests.java | 2 +- .../GetSiteContainerSanityTests.java | 2 +- .../GetSiteContainersCoreTests.java | 2 +- .../GetSiteContainersFullTests.java | 2 +- .../GetSiteContainersSanityTests.java | 2 +- .../AddSiteMemberCoreTests.java | 2 +- .../AddSiteMemberFullTests.java | 2 +- .../AddSiteMemberSanityTests.java | 2 +- .../GetSiteMemberCoreTests.java | 2 +- .../GetSiteMemberFullTests.java | 2 +- .../GetSiteMemberSanityTests.java | 2 +- .../GetSiteMembersCoreTests.java | 2 +- .../GetSiteMembersFullTests.java | 2 +- .../GetSiteMembersSanityTests.java | 2 +- .../RemoveSiteMemberCoreTests.java | 2 +- .../RemoveSiteMemberFullTests.java | 2 +- .../RemoveSiteMemberSanityTests.java | 2 +- .../UpdateSiteMemberCoreTests.java | 2 +- .../UpdateSiteMemberFullTests.java | 2 +- .../UpdateSiteMemberSanityTests.java | 2 +- .../AddSiteMembershipRequestCoreTests.java | 2 +- .../AddSiteMembershipRequestFullTests.java | 2 +- .../AddSiteMembershipRequestSanityTests.java | 2 +- .../DeleteSiteMembershipRequestCoreTests.java | 2 +- .../DeleteSiteMembershipRequestFullTests.java | 2 +- ...eleteSiteMembershipRequestSanityTests.java | 2 +- .../GetSiteMembershipRequestCoreTests.java | 2 +- .../GetSiteMembershipRequestFullTests.java | 2 +- .../GetSiteMembershipRequestSanityTests.java | 2 +- .../GetSiteMembershipRequestsCoreTests.java | 2 +- .../GetSiteMembershipRequestsFullTests.java | 2 +- .../GetSiteMembershipRequestsSanityTests.java | 2 +- .../UpdateSiteMembershipRequestCoreTests.java | 2 +- .../UpdateSiteMembershipRequestFullTests.java | 2 +- ...pdateSiteMembershipRequestSanityTests.java | 2 +- .../rest/tags/{get => }/GetTagCoreTests.java | 2 +- .../rest/tags/{get => }/GetTagFullTests.java | 2 +- .../tags/{get => }/GetTagSanityTests.java | 2 +- .../rest/tags/{get => }/GetTagsCoreTests.java | 2 +- .../rest/tags/{get => }/GetTagsFullTests.java | 2 +- .../tags/{get => }/GetTagsSanityTests.java | 2 +- .../tags/{put => }/UpdateTagCoreTests.java | 2 +- .../tags/{put => }/UpdateTagFullTests.java | 2 +- .../tags/{put => }/UpdateTagSanityTests.java | 2 +- .../tags/{post => nodes}/AddTagCoreTests.java | 2 +- .../tags/{post => nodes}/AddTagFullTests.java | 2 +- .../{post => nodes}/AddTagSanityTests.java | 2 +- .../{post => nodes}/AddTagsSanityTests.java | 2 +- .../{delete => nodes}/DeleteTagCoreTests.java | 2 +- .../{delete => nodes}/DeleteTagFullTests.java | 2 +- .../DeleteTagSanityTests.java | 2 +- .../{get => nodes}/GetNodeTagsCoreTests.java | 2 +- .../{get => nodes}/GetNodeTagsFullTests.java | 2 +- .../GetNodeTagsSanityTests.java | 2 +- .../DeleteDeploymentCoreFullTests.java | 2 +- .../DeleteDeploymentSanityTests.java | 2 +- .../{get => }/GetDeploymentCoreTests.java | 2 +- .../{get => }/GetDeploymentFullTests.java | 2 +- .../{get => }/GetDeploymentSanityTests.java | 2 +- .../{get => }/GetDeploymentsCoreTests.java | 2 +- .../{get => }/GetDeploymentsFullTests.java | 2 +- .../{get => }/GetDeploymentsSanityTests.java | 2 +- .../{post => }/AddProcessCoreTests.java | 2 +- .../{post => }/AddProcessFullTests.java | 2 +- .../{post => }/AddProcessSanityTests.java | 2 +- .../{delete => }/DeleteProcessCoreTests.java | 2 +- .../{delete => }/DeleteProcessFullTests.java | 2 +- .../DeleteProcessSanityTests.java | 2 +- .../{get => }/GetProcessCoreTests.java | 2 +- .../{get => }/GetProcessFullTests.java | 2 +- .../{get => }/GetProcessSanityTests.java | 2 +- .../{get => }/GetProcessesCoreTests.java | 2 +- .../{get => }/GetProcessesFullTests.java | 2 +- .../{get => }/GetProcessesSanityTests.java | 2 +- .../AddProcessItemCoreTests.java | 2 +- .../AddProcessItemFullTests.java | 2 +- .../AddProcessItemSanityTests.java | 2 +- .../DeleteProcessItemCoreTests.java | 2 +- .../DeleteProcessItemFullTests.java | 2 +- .../DeleteProcessItemSanityTests.java | 2 +- .../GetProcessItemsCoreTests.java | 2 +- .../GetProcessItemsFullTests.java | 2 +- .../GetProcessItemsSanityTests.java | 2 +- .../GetProcessTasksCoreTests.java | 2 +- .../GetProcessTasksFullTests.java | 2 +- .../GetProcessTasksSanityTests.java | 2 +- .../AddProcessVariableCoreTests.java | 2 +- .../AddProcessVariableFullTests.java | 2 +- .../AddProcessVariableSanityTests.java | 2 +- .../AddProcessVariablesCoreTests.java | 2 +- .../AddProcessVariablesFullTests.java | 2 +- .../AddProcessVariablesSanityTests.java | 2 +- .../DeleteProcessVariableCoreTests.java | 2 +- .../DeleteProcessVariableFullTests.java | 2 +- .../DeleteProcessVariableSanityTests.java | 2 +- .../GetProcessVariablesCoreTests.java | 2 +- .../GetProcessVariablesFullTests.java | 2 +- .../GetProcessVariablesSanityTests.java | 2 +- .../UpdateProcessVariableTests.java | 2 +- .../tasks/{get => }/GetTaskCoreTests.java | 2 +- .../{get => }/GetTaskFormModelCoreTests.java | 2 +- .../{get => }/GetTaskFormModelFullTests.java | 2 +- .../GetTaskFormModelSanityTests.java | 2 +- .../tasks/{get => }/GetTaskFullTests.java | 2 +- .../tasks/{get => }/GetTaskSanityTests.java | 2 +- .../tasks/{get => }/GetTasksCoreTests.java | 2 +- .../tasks/{get => }/GetTasksFullTests.java | 2 +- .../tasks/{get => }/GetTasksSanityTests.java | 2 +- .../tasks/{put => }/UpdateTaskCoreTests.java | 2 +- .../{put => }/UpdateTaskCoreTestsBulk2.java | 2 +- .../{put => }/UpdateTaskCoreTestsBulk3.java | 2 +- .../{put => }/UpdateTaskFullTestsBulk1.java | 2 +- .../{put => }/UpdateTaskFullTestsBulk2.java | 2 +- .../{put => }/UpdateTaskSanityTests.java | 2 +- .../GetTaskCandidatesCoreTests.java | 2 +- .../GetTaskCandidatesFullTests.java | 2 +- .../GetTaskCandidatesSanityTests.java | 2 +- .../{post => items}/AddTaskItemCoreTests.java | 2 +- .../{post => items}/AddTaskItemFullTests.java | 2 +- .../AddTaskItemSanityTests.java | 2 +- .../{get => items}/GetTaskItemsCoreTests.java | 2 +- .../{get => items}/GetTaskItemsFullTests.java | 2 +- .../GetTaskItemsSanityTests.java | 2 +- .../RemoveTaskItemCoreTests.java | 2 +- .../RemoveTaskItemFullTests.java | 2 +- .../RemoveTaskItemSanityTests.java | 2 +- .../AddTaskVariablesCoreTests.java | 2 +- .../AddTaskVariablesFullTests.java | 2 +- .../AddTaskVariablesSanityTests.java | 2 +- .../DeleteTaskVariableCoreTests.java | 2 +- .../DeleteTaskVariableFullTests.java | 2 +- .../DeleteTaskVariableSanityTests.java | 2 +- .../GetTaskVariablesCoreTests.java | 2 +- .../GetTaskVariablesFullTests.java | 2 +- .../GetTaskVariablesSanityTests.java | 2 +- .../UpdateTaskVariableCoreTests.java | 2 +- .../UpdateTaskVariableFullTests.java | 2 +- .../UpdateTaskVariableSanityTests.java | 2 +- 213 files changed, 274 insertions(+), 274 deletions(-) rename e2e-test/java/org/alfresco/rest/comments/{post => }/AddCommentCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/comments/{post => }/AddCommentSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/comments/{post => }/AddCommentsCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/comments/{post => }/AddCommentsFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/comments/{post => }/AddCommentsSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/comments/{delete => }/DeleteCommentCoreTests.java (97%) rename e2e-test/java/org/alfresco/rest/comments/{delete => }/DeleteCommentFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/comments/{delete => }/DeleteCommentSanityTests.java (97%) rename e2e-test/java/org/alfresco/rest/comments/{get => }/GetCommentsCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/comments/{get => }/GetCommentsFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/comments/{get => }/GetCommentsSanityTests.java (97%) rename e2e-test/java/org/alfresco/rest/comments/{put => }/UpdateCommentCoreTests.java (97%) rename e2e-test/java/org/alfresco/rest/comments/{put => }/UpdateCommentFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/comments/{put => }/UpdateCommentSanityTests.java (98%) rename e2e-test/java/org/alfresco/rest/favorites/{post => }/AddFavoriteSiteCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/favorites/{post => }/AddFavoriteSiteFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/favorites/{post => }/AddFavoriteSiteSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/favorites/{post => }/AddFavoritesCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/favorites/{post => }/AddFavoritesFullTests.java (98%) rename e2e-test/java/org/alfresco/rest/favorites/{post => }/AddFavoritesSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/favorites/{delete => }/DeleteFavoriteCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/favorites/{delete => }/DeleteFavoriteFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/favorites/{delete => }/DeleteFavoriteSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/favorites/{delete => }/DeleteFavoriteSiteCoreTests.java (97%) rename e2e-test/java/org/alfresco/rest/favorites/{delete => }/DeleteFavoriteSiteFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/favorites/{delete => }/DeleteFavoriteSiteSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/favorites/{get => }/GetFavoriteCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/favorites/{get => }/GetFavoriteFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/favorites/{get => }/GetFavoriteSanityTests.java (98%) rename e2e-test/java/org/alfresco/rest/favorites/{get => }/GetFavoriteSiteCoreTests.java (98%) rename e2e-test/java/org/alfresco/rest/favorites/{get => }/GetFavoriteSiteFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/favorites/{get => }/GetFavoriteSiteSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/favorites/{get => }/GetFavoriteSitesCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/favorites/{get => }/GetFavoriteSitesFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/favorites/{get => }/GetFavoriteSitesSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/favorites/{get => }/GetFavoritesCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/favorites/{get => }/GetFavoritesFullTests.java (98%) rename e2e-test/java/org/alfresco/rest/favorites/{get => }/GetFavoritesSanityTests.java (98%) rename e2e-test/java/org/alfresco/rest/{ => people}/activities/GetPeopleActivitiesCoreTests.java (82%) rename e2e-test/java/org/alfresco/rest/{ => people}/activities/GetPeopleActivitiesFullTests.java (83%) rename e2e-test/java/org/alfresco/rest/{ => people}/activities/GetPeopleActivitiesSanityTests.java (80%) rename e2e-test/java/org/alfresco/rest/{ => people}/preferences/GetPeoplePreferenceCoreTests.java (78%) rename e2e-test/java/org/alfresco/rest/{ => people}/preferences/GetPeoplePreferenceFullTests.java (91%) rename e2e-test/java/org/alfresco/rest/{ => people}/preferences/GetPeoplePreferenceSanityTests.java (81%) rename e2e-test/java/org/alfresco/rest/{ => people}/preferences/GetPeoplePreferencesCoreTests.java (80%) rename e2e-test/java/org/alfresco/rest/{ => people}/preferences/GetPeoplePreferencesFullTests.java (83%) rename e2e-test/java/org/alfresco/rest/{ => people}/preferences/GetPeoplePreferencesSanityTests.java (81%) rename e2e-test/java/org/alfresco/rest/ratings/{post => }/AddRatingCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/ratings/{post => }/AddRatingFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/ratings/{post => }/AddRatingSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/ratings/{delete => }/DeleteRatingCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/ratings/{delete => }/DeleteRatingFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/ratings/{delete => }/DeleteRatingSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/ratings/{get => }/GetRatingCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/ratings/{get => }/GetRatingFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/ratings/{get => }/GetRatingSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/ratings/{get => }/GetRatingsCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/ratings/{get => }/GetRatingsFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/ratings/{get => }/GetRatingsSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/sites/{delete => }/DeleteSiteMemberCoreTests.java (98%) rename e2e-test/java/org/alfresco/rest/sites/{delete => }/DeleteSiteMemberFullTests.java (98%) rename e2e-test/java/org/alfresco/rest/sites/{delete => }/DeleteSiteMemberSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/sites/{get => }/GetSiteCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/sites/{get => }/GetSiteFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/sites/{get => }/GetSiteMembershipCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/sites/{get => }/GetSiteMembershipFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/sites/{get => }/GetSiteMembershipSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/sites/{get => }/GetSiteSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/sites/{get => }/GetSitesCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/sites/{get => }/GetSitesFullTests.java (98%) rename e2e-test/java/org/alfresco/rest/sites/{get => }/GetSitesMembershipInformationCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/sites/{get => }/GetSitesMembershipInformationFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/sites/{get => }/GetSitesMembershipInformationSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/sites/{get => }/GetSitesSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/sites/{get => containers}/GetSiteContainerCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/sites/{get => containers}/GetSiteContainerFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/sites/{get => containers}/GetSiteContainerSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/sites/{get => containers}/GetSiteContainersCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/sites/{get => containers}/GetSiteContainersFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/sites/{get => containers}/GetSiteContainersSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/sites/{post => members}/AddSiteMemberCoreTests.java (98%) rename e2e-test/java/org/alfresco/rest/sites/{post => members}/AddSiteMemberFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/sites/{post => members}/AddSiteMemberSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/sites/{get => members}/GetSiteMemberCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/sites/{get => members}/GetSiteMemberFullTests.java (98%) rename e2e-test/java/org/alfresco/rest/sites/{get => members}/GetSiteMemberSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/sites/{get => members}/GetSiteMembersCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/sites/{get => members}/GetSiteMembersFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/sites/{get => members}/GetSiteMembersSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/sites/{delete => members}/RemoveSiteMemberCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/sites/{delete => members}/RemoveSiteMemberFullTests.java (97%) rename e2e-test/java/org/alfresco/rest/sites/{delete => members}/RemoveSiteMemberSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/sites/{put => members}/UpdateSiteMemberCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/sites/{put => members}/UpdateSiteMemberFullTests.java (98%) rename e2e-test/java/org/alfresco/rest/sites/{put => members}/UpdateSiteMemberSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/sites/{post => membershipRequests}/AddSiteMembershipRequestCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/sites/{post => membershipRequests}/AddSiteMembershipRequestFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/sites/{post => membershipRequests}/AddSiteMembershipRequestSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/sites/{delete => membershipRequests}/DeleteSiteMembershipRequestCoreTests.java (98%) rename e2e-test/java/org/alfresco/rest/sites/{delete => membershipRequests}/DeleteSiteMembershipRequestFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/sites/{delete => membershipRequests}/DeleteSiteMembershipRequestSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/sites/{get => membershipRequests}/GetSiteMembershipRequestCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/sites/{get => membershipRequests}/GetSiteMembershipRequestFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/sites/{get => membershipRequests}/GetSiteMembershipRequestSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/sites/{get => membershipRequests}/GetSiteMembershipRequestsCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/sites/{get => membershipRequests}/GetSiteMembershipRequestsFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/sites/{get => membershipRequests}/GetSiteMembershipRequestsSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/sites/{put => membershipRequests}/UpdateSiteMembershipRequestCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/sites/{put => membershipRequests}/UpdateSiteMembershipRequestFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/sites/{put => membershipRequests}/UpdateSiteMembershipRequestSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/tags/{get => }/GetTagCoreTests.java (98%) rename e2e-test/java/org/alfresco/rest/tags/{get => }/GetTagFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/tags/{get => }/GetTagSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/tags/{get => }/GetTagsCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/tags/{get => }/GetTagsFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/tags/{get => }/GetTagsSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/tags/{put => }/UpdateTagCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/tags/{put => }/UpdateTagFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/tags/{put => }/UpdateTagSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/tags/{post => nodes}/AddTagCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/tags/{post => nodes}/AddTagFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/tags/{post => nodes}/AddTagSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/tags/{post => nodes}/AddTagsSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/tags/{delete => nodes}/DeleteTagCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/tags/{delete => nodes}/DeleteTagFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/tags/{delete => nodes}/DeleteTagSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/tags/{get => nodes}/GetNodeTagsCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/tags/{get => nodes}/GetNodeTagsFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/tags/{get => nodes}/GetNodeTagsSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/deployments/{delete => }/DeleteDeploymentCoreFullTests.java (97%) rename e2e-test/java/org/alfresco/rest/workflow/deployments/{delete => }/DeleteDeploymentSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/deployments/{get => }/GetDeploymentCoreTests.java (98%) rename e2e-test/java/org/alfresco/rest/workflow/deployments/{get => }/GetDeploymentFullTests.java (98%) rename e2e-test/java/org/alfresco/rest/workflow/deployments/{get => }/GetDeploymentSanityTests.java (98%) rename e2e-test/java/org/alfresco/rest/workflow/deployments/{get => }/GetDeploymentsCoreTests.java (98%) rename e2e-test/java/org/alfresco/rest/workflow/deployments/{get => }/GetDeploymentsFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/deployments/{get => }/GetDeploymentsSanityTests.java (98%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{post => }/AddProcessCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{post => }/AddProcessFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{post => }/AddProcessSanityTests.java (98%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{delete => }/DeleteProcessCoreTests.java (98%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{delete => }/DeleteProcessFullTests.java (97%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{delete => }/DeleteProcessSanityTests.java (98%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{get => }/GetProcessCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{get => }/GetProcessFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{get => }/GetProcessSanityTests.java (98%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{get => }/GetProcessesCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{get => }/GetProcessesFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{get => }/GetProcessesSanityTests.java (98%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{post => items}/AddProcessItemCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{post => items}/AddProcessItemFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{post => items}/AddProcessItemSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{delete => items}/DeleteProcessItemCoreTests.java (98%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{delete => items}/DeleteProcessItemFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{delete => items}/DeleteProcessItemSanityTests.java (98%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{get => items}/GetProcessItemsCoreTests.java (98%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{get => items}/GetProcessItemsFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{get => items}/GetProcessItemsSanityTests.java (98%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{get => tasks}/GetProcessTasksCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{get => tasks}/GetProcessTasksFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{get => tasks}/GetProcessTasksSanityTests.java (98%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{post => variables}/AddProcessVariableCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{post => variables}/AddProcessVariableFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{post => variables}/AddProcessVariableSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{post => variables}/AddProcessVariablesCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{post => variables}/AddProcessVariablesFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{post => variables}/AddProcessVariablesSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{delete => variables}/DeleteProcessVariableCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{delete => variables}/DeleteProcessVariableFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{delete => variables}/DeleteProcessVariableSanityTests.java (98%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{get => variables}/GetProcessVariablesCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{get => variables}/GetProcessVariablesFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{get => variables}/GetProcessVariablesSanityTests.java (98%) rename e2e-test/java/org/alfresco/rest/workflow/processes/{put => variables}/UpdateProcessVariableTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{get => }/GetTaskCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{get => }/GetTaskFormModelCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{get => }/GetTaskFormModelFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{get => }/GetTaskFormModelSanityTests.java (98%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{get => }/GetTaskFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{get => }/GetTaskSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{get => }/GetTasksCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{get => }/GetTasksFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{get => }/GetTasksSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{put => }/UpdateTaskCoreTests.java (98%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{put => }/UpdateTaskCoreTestsBulk2.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{put => }/UpdateTaskCoreTestsBulk3.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{put => }/UpdateTaskFullTestsBulk1.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{put => }/UpdateTaskFullTestsBulk2.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{put => }/UpdateTaskSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{get => candidates}/GetTaskCandidatesCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{get => candidates}/GetTaskCandidatesFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{get => candidates}/GetTaskCandidatesSanityTests.java (98%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{post => items}/AddTaskItemCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{post => items}/AddTaskItemFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{post => items}/AddTaskItemSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{get => items}/GetTaskItemsCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{get => items}/GetTaskItemsFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{get => items}/GetTaskItemsSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{delete => items}/RemoveTaskItemCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{delete => items}/RemoveTaskItemFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{delete => items}/RemoveTaskItemSanityTests.java (98%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{post => variables}/AddTaskVariablesCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{post => variables}/AddTaskVariablesFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{post => variables}/AddTaskVariablesSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{delete => variables}/DeleteTaskVariableCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{delete => variables}/DeleteTaskVariableFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{delete => variables}/DeleteTaskVariableSanityTests.java (98%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{get => variables}/GetTaskVariablesCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{get => variables}/GetTaskVariablesFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{get => variables}/GetTaskVariablesSanityTests.java (98%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{put => variables}/UpdateTaskVariableCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{put => variables}/UpdateTaskVariableFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/{put => variables}/UpdateTaskVariableSanityTests.java (99%) diff --git a/e2e-test/java/org/alfresco/rest/comments/post/AddCommentCoreTests.java b/e2e-test/java/org/alfresco/rest/comments/AddCommentCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/comments/post/AddCommentCoreTests.java rename to e2e-test/java/org/alfresco/rest/comments/AddCommentCoreTests.java index d118285d8..7f6955cd9 100644 --- a/e2e-test/java/org/alfresco/rest/comments/post/AddCommentCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/AddCommentCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.comments.post; +package org.alfresco.rest.comments; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/comments/post/AddCommentSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/comments/post/AddCommentSanityTests.java rename to e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java index 1bde6f02f..93606fb20 100644 --- a/e2e-test/java/org/alfresco/rest/comments/post/AddCommentSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.comments.post; +package org.alfresco.rest.comments; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/comments/post/AddCommentsCoreTests.java b/e2e-test/java/org/alfresco/rest/comments/AddCommentsCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/comments/post/AddCommentsCoreTests.java rename to e2e-test/java/org/alfresco/rest/comments/AddCommentsCoreTests.java index 6482dfaf4..2cdcd2cf3 100644 --- a/e2e-test/java/org/alfresco/rest/comments/post/AddCommentsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/AddCommentsCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.comments.post; +package org.alfresco.rest.comments; import java.util.List; diff --git a/e2e-test/java/org/alfresco/rest/comments/post/AddCommentsFullTests.java b/e2e-test/java/org/alfresco/rest/comments/AddCommentsFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/comments/post/AddCommentsFullTests.java rename to e2e-test/java/org/alfresco/rest/comments/AddCommentsFullTests.java index d020fa304..58cd1f92a 100644 --- a/e2e-test/java/org/alfresco/rest/comments/post/AddCommentsFullTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/AddCommentsFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.comments.post; +package org.alfresco.rest.comments; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/comments/post/AddCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/comments/post/AddCommentsSanityTests.java rename to e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java index b3f6972ee..5ec6167e1 100644 --- a/e2e-test/java/org/alfresco/rest/comments/post/AddCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.comments.post; +package org.alfresco.rest.comments; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/comments/delete/DeleteCommentCoreTests.java b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentCoreTests.java similarity index 97% rename from e2e-test/java/org/alfresco/rest/comments/delete/DeleteCommentCoreTests.java rename to e2e-test/java/org/alfresco/rest/comments/DeleteCommentCoreTests.java index 411ec166d..bcfb1850c 100644 --- a/e2e-test/java/org/alfresco/rest/comments/delete/DeleteCommentCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.comments.delete; +package org.alfresco.rest.comments; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/comments/delete/DeleteCommentFullTests.java b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/comments/delete/DeleteCommentFullTests.java rename to e2e-test/java/org/alfresco/rest/comments/DeleteCommentFullTests.java index b6c605ba1..9f3037f1d 100644 --- a/e2e-test/java/org/alfresco/rest/comments/delete/DeleteCommentFullTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.comments.delete; +package org.alfresco.rest.comments; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/comments/delete/DeleteCommentSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentSanityTests.java similarity index 97% rename from e2e-test/java/org/alfresco/rest/comments/delete/DeleteCommentSanityTests.java rename to e2e-test/java/org/alfresco/rest/comments/DeleteCommentSanityTests.java index 45551d045..aecc7fd06 100644 --- a/e2e-test/java/org/alfresco/rest/comments/delete/DeleteCommentSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.comments.delete; +package org.alfresco.rest.comments; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/comments/get/GetCommentsCoreTests.java b/e2e-test/java/org/alfresco/rest/comments/GetCommentsCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/comments/get/GetCommentsCoreTests.java rename to e2e-test/java/org/alfresco/rest/comments/GetCommentsCoreTests.java index e494f07cd..1fd7a1f5c 100644 --- a/e2e-test/java/org/alfresco/rest/comments/get/GetCommentsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/GetCommentsCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.comments.get; +package org.alfresco.rest.comments; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/comments/get/GetCommentsFullTests.java b/e2e-test/java/org/alfresco/rest/comments/GetCommentsFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/comments/get/GetCommentsFullTests.java rename to e2e-test/java/org/alfresco/rest/comments/GetCommentsFullTests.java index 00f820e3c..b7021f602 100644 --- a/e2e-test/java/org/alfresco/rest/comments/get/GetCommentsFullTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/GetCommentsFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.comments.get; +package org.alfresco.rest.comments; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/comments/get/GetCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java similarity index 97% rename from e2e-test/java/org/alfresco/rest/comments/get/GetCommentsSanityTests.java rename to e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java index 534e1389b..f781e0eea 100644 --- a/e2e-test/java/org/alfresco/rest/comments/get/GetCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.comments.get; +package org.alfresco.rest.comments; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/comments/put/UpdateCommentCoreTests.java b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentCoreTests.java similarity index 97% rename from e2e-test/java/org/alfresco/rest/comments/put/UpdateCommentCoreTests.java rename to e2e-test/java/org/alfresco/rest/comments/UpdateCommentCoreTests.java index 0fa97f1c6..32caa9b5e 100644 --- a/e2e-test/java/org/alfresco/rest/comments/put/UpdateCommentCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.comments.put; +package org.alfresco.rest.comments; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/comments/put/UpdateCommentFullTests.java b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/comments/put/UpdateCommentFullTests.java rename to e2e-test/java/org/alfresco/rest/comments/UpdateCommentFullTests.java index 42a1f66ae..f96cf475a 100644 --- a/e2e-test/java/org/alfresco/rest/comments/put/UpdateCommentFullTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.comments.put; +package org.alfresco.rest.comments; import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.CMISUtil.DocumentType; diff --git a/e2e-test/java/org/alfresco/rest/comments/put/UpdateCommentSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentSanityTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/comments/put/UpdateCommentSanityTests.java rename to e2e-test/java/org/alfresco/rest/comments/UpdateCommentSanityTests.java index 4a8c58ea6..c724ef6e3 100644 --- a/e2e-test/java/org/alfresco/rest/comments/put/UpdateCommentSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.comments.put; +package org.alfresco.rest.comments; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/favorites/post/AddFavoriteSiteCoreTests.java b/e2e-test/java/org/alfresco/rest/favorites/AddFavoriteSiteCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/favorites/post/AddFavoriteSiteCoreTests.java rename to e2e-test/java/org/alfresco/rest/favorites/AddFavoriteSiteCoreTests.java index e6c196db3..59ae6aa3c 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/post/AddFavoriteSiteCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/AddFavoriteSiteCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.favorites.post; +package org.alfresco.rest.favorites; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; diff --git a/e2e-test/java/org/alfresco/rest/favorites/post/AddFavoriteSiteFullTests.java b/e2e-test/java/org/alfresco/rest/favorites/AddFavoriteSiteFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/favorites/post/AddFavoriteSiteFullTests.java rename to e2e-test/java/org/alfresco/rest/favorites/AddFavoriteSiteFullTests.java index 6b5d75186..c10480f3e 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/post/AddFavoriteSiteFullTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/AddFavoriteSiteFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.favorites.post; +package org.alfresco.rest.favorites; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/favorites/post/AddFavoriteSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/AddFavoriteSiteSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/favorites/post/AddFavoriteSiteSanityTests.java rename to e2e-test/java/org/alfresco/rest/favorites/AddFavoriteSiteSanityTests.java index dbe0ed8a1..b01e0472d 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/post/AddFavoriteSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/AddFavoriteSiteSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.favorites.post; +package org.alfresco.rest.favorites; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/favorites/post/AddFavoritesCoreTests.java b/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/favorites/post/AddFavoritesCoreTests.java rename to e2e-test/java/org/alfresco/rest/favorites/AddFavoritesCoreTests.java index e7a52f484..08e00885d 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/post/AddFavoritesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.favorites.post; +package org.alfresco.rest.favorites; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/favorites/post/AddFavoritesFullTests.java b/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesFullTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/favorites/post/AddFavoritesFullTests.java rename to e2e-test/java/org/alfresco/rest/favorites/AddFavoritesFullTests.java index c24e1acde..4460b3370 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/post/AddFavoritesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.favorites.post; +package org.alfresco.rest.favorites; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/favorites/post/AddFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/favorites/post/AddFavoritesSanityTests.java rename to e2e-test/java/org/alfresco/rest/favorites/AddFavoritesSanityTests.java index 267c9af2e..4373b0050 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/post/AddFavoritesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.favorites.post; +package org.alfresco.rest.favorites; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; diff --git a/e2e-test/java/org/alfresco/rest/favorites/delete/DeleteFavoriteCoreTests.java b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/favorites/delete/DeleteFavoriteCoreTests.java rename to e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteCoreTests.java index 51ac36648..5d30132a1 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/delete/DeleteFavoriteCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.favorites.delete; +package org.alfresco.rest.favorites; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/favorites/delete/DeleteFavoriteFullTests.java b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/favorites/delete/DeleteFavoriteFullTests.java rename to e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteFullTests.java index 4147fe7c8..7cdcc2710 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/delete/DeleteFavoriteFullTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.favorites.delete; +package org.alfresco.rest.favorites; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/favorites/delete/DeleteFavoriteSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/favorites/delete/DeleteFavoriteSanityTests.java rename to e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteSanityTests.java index 500a939d1..cc0ed1abf 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/delete/DeleteFavoriteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.favorites.delete; +package org.alfresco.rest.favorites; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; diff --git a/e2e-test/java/org/alfresco/rest/favorites/delete/DeleteFavoriteSiteCoreTests.java b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteSiteCoreTests.java similarity index 97% rename from e2e-test/java/org/alfresco/rest/favorites/delete/DeleteFavoriteSiteCoreTests.java rename to e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteSiteCoreTests.java index 461fcdc99..9a312bcb5 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/delete/DeleteFavoriteSiteCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteSiteCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.favorites.delete; +package org.alfresco.rest.favorites; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/favorites/delete/DeleteFavoriteSiteFullTests.java b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteSiteFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/favorites/delete/DeleteFavoriteSiteFullTests.java rename to e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteSiteFullTests.java index e77dcd566..486df6394 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/delete/DeleteFavoriteSiteFullTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteSiteFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.favorites.delete; +package org.alfresco.rest.favorites; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; diff --git a/e2e-test/java/org/alfresco/rest/favorites/delete/DeleteFavoriteSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteSiteSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/favorites/delete/DeleteFavoriteSiteSanityTests.java rename to e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteSiteSanityTests.java index 33de684bc..387c2845c 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/delete/DeleteFavoriteSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteSiteSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.favorites.delete; +package org.alfresco.rest.favorites; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/favorites/get/GetFavoriteCoreTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/favorites/get/GetFavoriteCoreTests.java rename to e2e-test/java/org/alfresco/rest/favorites/GetFavoriteCoreTests.java index 2d9021a0b..e078d9bda 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/get/GetFavoriteCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.favorites.get; +package org.alfresco.rest.favorites; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/favorites/get/GetFavoriteFullTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/favorites/get/GetFavoriteFullTests.java rename to e2e-test/java/org/alfresco/rest/favorites/GetFavoriteFullTests.java index d9448c9c0..c7c68feba 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/get/GetFavoriteFullTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.favorites.get; +package org.alfresco.rest.favorites; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/favorites/get/GetFavoriteSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/favorites/get/GetFavoriteSanityTests.java rename to e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java index 822838d75..86de14f71 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/get/GetFavoriteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.favorites.get; +package org.alfresco.rest.favorites; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/favorites/get/GetFavoriteSiteCoreTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSiteCoreTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/favorites/get/GetFavoriteSiteCoreTests.java rename to e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSiteCoreTests.java index 836219204..8a4f01629 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/get/GetFavoriteSiteCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSiteCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.favorites.get; +package org.alfresco.rest.favorites; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/favorites/get/GetFavoriteSiteFullTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSiteFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/favorites/get/GetFavoriteSiteFullTests.java rename to e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSiteFullTests.java index d14639520..e352afc64 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/get/GetFavoriteSiteFullTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSiteFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.favorites.get; +package org.alfresco.rest.favorites; import org.alfresco.rest.RestTest; import org.alfresco.rest.core.RestRequest; diff --git a/e2e-test/java/org/alfresco/rest/favorites/get/GetFavoriteSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSiteSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/favorites/get/GetFavoriteSiteSanityTests.java rename to e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSiteSanityTests.java index 024b4dd38..cbd1bb91f 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/get/GetFavoriteSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSiteSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.favorites.get; +package org.alfresco.rest.favorites; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/favorites/get/GetFavoriteSitesCoreTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSitesCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/favorites/get/GetFavoriteSitesCoreTests.java rename to e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSitesCoreTests.java index 01bcb789c..99cab6a70 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/get/GetFavoriteSitesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSitesCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.favorites.get; +package org.alfresco.rest.favorites; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/favorites/get/GetFavoriteSitesFullTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSitesFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/favorites/get/GetFavoriteSitesFullTests.java rename to e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSitesFullTests.java index 3ba068c0e..662940c8e 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/get/GetFavoriteSitesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSitesFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.favorites.get; +package org.alfresco.rest.favorites; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/favorites/get/GetFavoriteSitesSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSitesSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/favorites/get/GetFavoriteSitesSanityTests.java rename to e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSitesSanityTests.java index 0960f56c6..654ddc26f 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/get/GetFavoriteSitesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSitesSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.favorites.get; +package org.alfresco.rest.favorites; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/favorites/get/GetFavoritesCoreTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/favorites/get/GetFavoritesCoreTests.java rename to e2e-test/java/org/alfresco/rest/favorites/GetFavoritesCoreTests.java index f4660b842..9cb4503c8 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/get/GetFavoritesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.favorites.get; +package org.alfresco.rest.favorites; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/favorites/get/GetFavoritesFullTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesFullTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/favorites/get/GetFavoritesFullTests.java rename to e2e-test/java/org/alfresco/rest/favorites/GetFavoritesFullTests.java index 1fb6ffbef..9d553dcc1 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/get/GetFavoritesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.favorites.get; +package org.alfresco.rest.favorites; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; diff --git a/e2e-test/java/org/alfresco/rest/favorites/get/GetFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/favorites/get/GetFavoritesSanityTests.java rename to e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java index 7a4be3527..c27b699fe 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/get/GetFavoritesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.favorites.get; +package org.alfresco.rest.favorites; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/activities/GetPeopleActivitiesCoreTests.java b/e2e-test/java/org/alfresco/rest/people/activities/GetPeopleActivitiesCoreTests.java similarity index 82% rename from e2e-test/java/org/alfresco/rest/activities/GetPeopleActivitiesCoreTests.java rename to e2e-test/java/org/alfresco/rest/people/activities/GetPeopleActivitiesCoreTests.java index 54256694a..2185521e3 100644 --- a/e2e-test/java/org/alfresco/rest/activities/GetPeopleActivitiesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/activities/GetPeopleActivitiesCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.activities; +package org.alfresco.rest.people.activities; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; @@ -51,7 +51,7 @@ public class GetPeopleActivitiesCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot get activities for inexistent user with Rest API and response is 404") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot get activities for inexistent user with Rest API and response is 404") public void userCannotGetPeopleActivitiesForInexistentPersonId() throws Exception { UserModel inexistentUserName = new UserModel("inexistent", "password"); @@ -65,7 +65,7 @@ public class GetPeopleActivitiesCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its activities for inexistent siteId with Rest API and response is 404") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its activities for inexistent siteId with Rest API and response is 404") public void userGetItsPeopleActivitiesForInexistentSite() throws Exception { restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingUser(userModel).usingParams(String.format("siteId=inexistent")).getPersonActivities(); @@ -77,7 +77,7 @@ public class GetPeopleActivitiesCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities with invald skipCount parameter with Rest API and response is 400") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities with invald skipCount parameter with Rest API and response is 400") public void userGetPeopleActivitiesUsingInvalidSkipCountParameter() throws Exception { restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingMe().usingParams("skipCount=-1").getPersonActivities(); @@ -89,7 +89,7 @@ public class GetPeopleActivitiesCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities with invalid maxItems parameter with Rest API and response is 400") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities with invalid maxItems parameter with Rest API and response is 400") public void userGetPeopleActivitiesUsingInvalidMaxItemsParameter() throws Exception { restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingMe().usingParams("maxItems=0").getPersonActivities(); @@ -101,7 +101,7 @@ public class GetPeopleActivitiesCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities using invalid value for parameter 'who'with Rest API and response is 400") + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities using invalid value for parameter 'who'with Rest API and response is 400") public void userGetsPeopleActivitiesUsingInvalidValueForWhoParameter() throws Exception { restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingUser(userModel).usingParams("who=mee").getPersonActivities(); @@ -113,7 +113,7 @@ public class GetPeopleActivitiesCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities successfully using parameter 'who' with 'others' value with Rest API") + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities successfully using parameter 'who' with 'others' value with Rest API") public void userGetsPeopleActivitiesUsingOthersForWhoParameter() throws Exception { restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingUser(userModel).usingParams("who=others").getPersonActivities(); diff --git a/e2e-test/java/org/alfresco/rest/activities/GetPeopleActivitiesFullTests.java b/e2e-test/java/org/alfresco/rest/people/activities/GetPeopleActivitiesFullTests.java similarity index 83% rename from e2e-test/java/org/alfresco/rest/activities/GetPeopleActivitiesFullTests.java rename to e2e-test/java/org/alfresco/rest/people/activities/GetPeopleActivitiesFullTests.java index 3a0e11d1b..068b81fef 100644 --- a/e2e-test/java/org/alfresco/rest/activities/GetPeopleActivitiesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/people/activities/GetPeopleActivitiesFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.activities; +package org.alfresco.rest.people.activities; import java.util.ArrayList; import java.util.List; @@ -59,7 +59,7 @@ public class GetPeopleActivitiesFullTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its activities using me with Rest API and response is successful") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its activities using me with Rest API and response is successful") public void userGetsItsPeopleActivitiesUsingMe() throws Exception { restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingMe().getPersonActivities(); @@ -79,7 +79,7 @@ public class GetPeopleActivitiesFullTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify activity summary from user gets activities response with Rest API") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify activity summary from user gets activities response with Rest API") public void userGetPeopleActivitiesWithActivitySummaryCheck() throws Exception { restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingMe().usingParams(String.format("siteId=%s", siteModel1.getId())).getPersonActivities(); @@ -94,7 +94,7 @@ public class GetPeopleActivitiesFullTests extends RestTest @Bug(id = "REPO-1911") @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API,TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot get activities for empty user with Rest API and response is 400") + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE,TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot get activities for empty user with Rest API and response is 400") public void userCannotGetPeopleActivitiesForEmptyPersonId() throws Exception { UserModel emptyUserName = new UserModel("", "password"); @@ -108,7 +108,7 @@ public class GetPeopleActivitiesFullTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities successfully using parameter 'who' with 'me' value with Rest API") + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities successfully using parameter 'who' with 'me' value with Rest API") public void userGetsPeopleActivitiesUsingMeForWhoParameter() throws Exception { restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingUser(userModel).usingParams("who=me").getPersonActivities(); @@ -120,7 +120,7 @@ public class GetPeopleActivitiesFullTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API,TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its activities for siteId specified in siteId parameter using me with Rest API and response is successful") + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE,TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its activities for siteId specified in siteId parameter using me with Rest API and response is successful") public void userGetItsPeopleActivitiesForASpecificSite() throws Exception { restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingUser(userModel).usingParams(String.format("siteId=%s", siteModel1.getId())).getPersonActivities(); @@ -131,7 +131,7 @@ public class GetPeopleActivitiesFullTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities for user with no activities with Rest API and response is successful") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities for user with no activities with Rest API and response is successful") public void userGetPeopleActivitiesForUserWithNoActivities() throws Exception { UserModel userNoActivities = dataUser.createRandomTestUser(); @@ -156,7 +156,7 @@ public class GetPeopleActivitiesFullTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot get activities for siteId that user doesn't have access to with Rest API and response is not found") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot get activities for siteId that user doesn't have access to with Rest API and response is not found") public void userGetPeopleActivitiesForASiteWithNoAccess() throws Exception { SiteModel siteNoAccess = dataSite.usingUser(managerUser).createPrivateRandomSite(); @@ -167,7 +167,7 @@ public class GetPeopleActivitiesFullTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot get activities for another user with Rest API and response is permission denied") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot get activities for another user with Rest API and response is permission denied") public void userGetPeopleActivitiesForAnotherUser() throws Exception { restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingUser(managerUser).getPersonActivities(); @@ -176,7 +176,7 @@ public class GetPeopleActivitiesFullTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities with properties parameter applied with Rest API and response is successful") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities with properties parameter applied with Rest API and response is successful") public void userGetPeopleActivitiesUsingPropertiesParameter() throws Exception { restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingMe().usingParams("properties=postPersonId").getPersonActivities(); @@ -194,7 +194,7 @@ public class GetPeopleActivitiesFullTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities with skipCount parameter applied with Rest API and response is successful") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities with skipCount parameter applied with Rest API and response is successful") public void userGetPeopleActivitiesUsingSkipCountParameter() throws Exception { restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingMe().getPersonActivities(); @@ -213,7 +213,7 @@ public class GetPeopleActivitiesFullTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities with maxItems parameter applied with Rest API and response is successful") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities with maxItems parameter applied with Rest API and response is successful") public void userGetPeopleActivitiesUsingMaxItemsParameter() throws Exception { restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingMe().getPersonActivities(); diff --git a/e2e-test/java/org/alfresco/rest/activities/GetPeopleActivitiesSanityTests.java b/e2e-test/java/org/alfresco/rest/people/activities/GetPeopleActivitiesSanityTests.java similarity index 80% rename from e2e-test/java/org/alfresco/rest/activities/GetPeopleActivitiesSanityTests.java rename to e2e-test/java/org/alfresco/rest/people/activities/GetPeopleActivitiesSanityTests.java index 1d7c2a8bf..468f13bfa 100644 --- a/e2e-test/java/org/alfresco/rest/activities/GetPeopleActivitiesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/activities/GetPeopleActivitiesSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.activities; +package org.alfresco.rest.people.activities; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; @@ -44,7 +44,7 @@ public class GetPeopleActivitiesSanityTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.ACTIVITIES }, executionType = ExecutionType.SANITY, description = "Verify manager user gets its activities with Rest API and response is successful") + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.SANITY, description = "Verify manager user gets its activities with Rest API and response is successful") public void managerUserShouldGetPeopleActivitiesList() throws Exception { UserModel managerUser = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); @@ -56,7 +56,7 @@ public class GetPeopleActivitiesSanityTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.ACTIVITIES }, executionType = ExecutionType.SANITY, description = "Verify collaborator user gets its activities with Rest API and response is successful") + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.SANITY, description = "Verify collaborator user gets its activities with Rest API and response is successful") public void collaboratorUserShouldGetPeopleActivitiesList() throws Exception { UserModel collaboratorUser = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); @@ -68,7 +68,7 @@ public class GetPeopleActivitiesSanityTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.ACTIVITIES }, executionType = ExecutionType.SANITY, description = "Verify contributor user gets its activities with Rest API and response is successful") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.ACTIVITIES }, executionType = ExecutionType.SANITY, description = "Verify contributor user gets its activities with Rest API and response is successful") public void contributorUserShouldGetPeopleActivitiesList() throws Exception { UserModel contributorUser = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); @@ -80,7 +80,7 @@ public class GetPeopleActivitiesSanityTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.ACTIVITIES }, executionType = ExecutionType.SANITY, description = "Verify consumer user gets its activities with Rest API and response is successful") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.ACTIVITIES }, executionType = ExecutionType.SANITY, description = "Verify consumer user gets its activities with Rest API and response is successful") public void consumerUserShouldGetPeopleActivitiesList() throws Exception { UserModel consumerUser = usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer); @@ -91,7 +91,7 @@ public class GetPeopleActivitiesSanityTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.ACTIVITIES }, executionType = ExecutionType.SANITY, description = "Verify admin user gets another user activities with Rest API and response is successful") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.ACTIVITIES }, executionType = ExecutionType.SANITY, description = "Verify admin user gets another user activities with Rest API and response is successful") public void adminUserShouldGetPeopleActivitiesList() throws Exception { restActivityModelsCollection = restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingUser(userModel).getPersonActivities(); @@ -100,7 +100,7 @@ public class GetPeopleActivitiesSanityTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.ACTIVITIES }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is NOT Authorized to gets another user activities with Rest API") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.ACTIVITIES }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is NOT Authorized to gets another user activities with Rest API") public void unauthenticatedUserShouldNotGetPeopleActivitiesList() throws Exception { restClient.authenticateUser(unauthenticatedUser).withCoreAPI().usingUser(userModel).getPersonActivities(); diff --git a/e2e-test/java/org/alfresco/rest/preferences/GetPeoplePreferenceCoreTests.java b/e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferenceCoreTests.java similarity index 78% rename from e2e-test/java/org/alfresco/rest/preferences/GetPeoplePreferenceCoreTests.java rename to e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferenceCoreTests.java index afa64d7ba..3369dacc1 100644 --- a/e2e-test/java/org/alfresco/rest/preferences/GetPeoplePreferenceCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferenceCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.preferences; +package org.alfresco.rest.people.preferences; import org.alfresco.rest.RestTest; import org.alfresco.utility.constants.PreferenceName; @@ -25,7 +25,7 @@ public class GetPeoplePreferenceCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user is Forbidden to get a specific preference for another user with Rest API and response is 403") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user is Forbidden to get a specific preference for another user with Rest API and response is 403") public void userDoesNotHaveAccessToFavoriteSitesOfAnotherUser() throws Exception { UserModel secondUser = dataUser.createRandomTestUser(); @@ -36,7 +36,7 @@ public class GetPeoplePreferenceCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify manager fails to get a specific preference for an invalid user with Rest API and response is 404") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify manager fails to get a specific preference for an invalid user with Rest API and response is 404") public void statusNotFoundIsReturnedForAPersonIDThatDoesNotExist() throws Exception { restClient.authenticateUser(userModel).withCoreAPI().usingUser(new UserModel("invalidPersonID", "password")) @@ -46,7 +46,7 @@ public class GetPeoplePreferenceCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify manager fails to get a specific preference for an invalid preference with Rest API and response is 404") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify manager fails to get a specific preference for an invalid preference with Rest API and response is 404") public void statusNotFoundIsReturnedForAPreferenceNameThatDoesNotExist() throws Exception { restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().getPersonPreferenceInformation("invalidPreferenceName"); @@ -57,7 +57,7 @@ public class GetPeoplePreferenceCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify manager fails to get a specific preference for removed preference with Rest API and response is 404") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify manager fails to get a specific preference for removed preference with Rest API and response is 404") public void statusNotFoundIsReturnedForAPreferenceNameThatHasBeenRemoved() throws Exception { SiteModel preferenceSite = dataSite.usingUser(userModel).createPublicRandomSite(); diff --git a/e2e-test/java/org/alfresco/rest/preferences/GetPeoplePreferenceFullTests.java b/e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferenceFullTests.java similarity index 91% rename from e2e-test/java/org/alfresco/rest/preferences/GetPeoplePreferenceFullTests.java rename to e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferenceFullTests.java index 28e3e0636..4c90ab3a2 100644 --- a/e2e-test/java/org/alfresco/rest/preferences/GetPeoplePreferenceFullTests.java +++ b/e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferenceFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.preferences; +package org.alfresco.rest.people.preferences; import java.nio.file.Paths; @@ -35,7 +35,7 @@ public class GetPeoplePreferenceFullTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Check default error schema in case of failure") public void checkDefaultErrorSchema() throws Exception { @@ -50,7 +50,7 @@ public class GetPeoplePreferenceFullTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Specify -me- string in place of for request") public void preferenceIsReturnedWhenUsingMeAsPersonId() throws Exception { @@ -63,7 +63,7 @@ public class GetPeoplePreferenceFullTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Check that properties parameter is applied") public void propertiesParameterIsAppliedWhenRetrievingPreference() throws Exception { @@ -81,7 +81,7 @@ public class GetPeoplePreferenceFullTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Validate ID element in get site preference response") public void validateIdElementInGetSitePreferenceResponse() throws Exception { @@ -92,7 +92,7 @@ public class GetPeoplePreferenceFullTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Validate ID element in get folder preference response") public void validateIdElementInGetFolderPreferenceResponse() throws Exception { @@ -107,7 +107,7 @@ public class GetPeoplePreferenceFullTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Validate ID element in get file preference response") public void validateIdElementInGetFilePreferenceResponse() throws Exception { @@ -122,7 +122,7 @@ public class GetPeoplePreferenceFullTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Get preference of an user that has no preferences") public void getPreferenceForUserWithoutPreferences() throws Exception { @@ -148,7 +148,7 @@ public class GetPeoplePreferenceFullTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Change one preference for an user then perform get call") @Bug(id = "ACE-5736") public void changePreferenceThenPerformGetPreferenceCall() throws Exception @@ -196,7 +196,7 @@ public class GetPeoplePreferenceFullTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to get preference of another user") public void adminIsAbleToGetOtherUserPreference() throws Exception { @@ -207,7 +207,7 @@ public class GetPeoplePreferenceFullTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify regular user is not able to get preference of admin user") public void regularUserIsNotAbleToGetAdminPreference() throws Exception { diff --git a/e2e-test/java/org/alfresco/rest/preferences/GetPeoplePreferenceSanityTests.java b/e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferenceSanityTests.java similarity index 81% rename from e2e-test/java/org/alfresco/rest/preferences/GetPeoplePreferenceSanityTests.java rename to e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferenceSanityTests.java index 205c32d30..1a5d5194d 100644 --- a/e2e-test/java/org/alfresco/rest/preferences/GetPeoplePreferenceSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferenceSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.preferences; +package org.alfresco.rest.people.preferences; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; @@ -35,7 +35,7 @@ public class GetPeoplePreferenceSanityTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify manager user gets a specific preference with Rest API and response is successful (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify manager user gets a specific preference with Rest API and response is successful (200)") public void managerUserGetsAPreferenceWithSuccess() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -49,7 +49,7 @@ public class GetPeoplePreferenceSanityTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify collaborator user gets a specific preference with Rest API and response is successful (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify collaborator user gets a specific preference with Rest API and response is successful (200)") public void collaboratorUserGetsAPreferenceWithSuccess() throws Exception { UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); @@ -63,7 +63,7 @@ public class GetPeoplePreferenceSanityTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify contributor user gets a specific preference with Rest API and response is successful (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify contributor user gets a specific preference with Rest API and response is successful (200)") public void contributorUserGetsAPreferenceWithSuccess() throws Exception { UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); @@ -77,7 +77,7 @@ public class GetPeoplePreferenceSanityTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify consumer user gets a specific preference with Rest API and response is successful (200)") + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify consumer user gets a specific preference with Rest API and response is successful (200)") public void consumerUserGetsAPreferenceWithSuccess() throws Exception { UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -91,7 +91,7 @@ public class GetPeoplePreferenceSanityTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify admin user gets a specific preference with Rest API and response is successful (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify admin user gets a specific preference with Rest API and response is successful (200)") public void adminUserGetsAPreferenceWithSuccess() throws Exception { UserModel adminUser = dataUser.getAdminUser(); @@ -104,7 +104,7 @@ public class GetPeoplePreferenceSanityTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized to get a specific preference with Rest API when authentication fails (401)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized to get a specific preference with Rest API when authentication fails (401)") @Bug(id = "MNT-16904", description = "fails only on environment with tenants") public void managerUserNotAuthorizedFailsToGetsAPreference() throws Exception { diff --git a/e2e-test/java/org/alfresco/rest/preferences/GetPeoplePreferencesCoreTests.java b/e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferencesCoreTests.java similarity index 80% rename from e2e-test/java/org/alfresco/rest/preferences/GetPeoplePreferencesCoreTests.java rename to e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferencesCoreTests.java index 77a78bf53..1ec4a9e73 100644 --- a/e2e-test/java/org/alfresco/rest/preferences/GetPeoplePreferencesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferencesCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.preferences; +package org.alfresco.rest.people.preferences; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; @@ -40,7 +40,7 @@ public class GetPeoplePreferencesCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its preferences with invalid maxItems parameter with Rest API and response is 400") + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its preferences with invalid maxItems parameter with Rest API and response is 400") public void userGetsPeoplePreferencesUsingInvalidMaxItemsParameter() throws Exception { restPreferenceModelsCollection = restClient.authenticateUser(user1).withCoreAPI().usingMe().usingParams("maxItems=0").getPersonPreferences(); @@ -52,7 +52,7 @@ public class GetPeoplePreferencesCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its preferences with skipCount parameter applied with Rest API and response is successful") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its preferences with skipCount parameter applied with Rest API and response is successful") public void userGetsPeoplePreferencesUsingInvalidSkipCountParameter() throws Exception { restPreferenceModelsCollection = restClient.authenticateUser(user1).withCoreAPI().usingMe().usingParams("skipCount=-1").getPersonPreferences(); @@ -64,7 +64,7 @@ public class GetPeoplePreferencesCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user which doesn't have access to another user preferences fails to get its preferences with Rest API and response is permission denied") + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user which doesn't have access to another user preferences fails to get its preferences with Rest API and response is permission denied") public void userWithNoAccessToOtherUserPreferencesIsForbiddenToGetItsPreferences() throws Exception { UserModel noAccessUser = dataUser.createRandomTestUser(); @@ -79,7 +79,7 @@ public class GetPeoplePreferencesCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user fails to get preferences for inexistent personId with Rest API and response is 404") + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user fails to get preferences for inexistent personId with Rest API and response is 404") public void userCannotGetPeoplePreferencesForInexistentPersonId() throws Exception { UserModel inexistentUserName = new UserModel("inexistent", "password"); @@ -93,7 +93,7 @@ public class GetPeoplePreferencesCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user get preferences for a user with no preferences with Rest API and response is empty") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user get preferences for a user with no preferences with Rest API and response is empty") public void userGetsPeoplePreferencesForUserWithNoPreferences() throws Exception { UserModel userNoActivities = dataUser.createRandomTestUser(); @@ -105,7 +105,7 @@ public class GetPeoplePreferencesCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user fails to get preferences for a removed preference with Rest API and response is 404") + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user fails to get preferences for a removed preference with Rest API and response is 404") public void userFailsToGetPeoplePreferencesIfPreferenceWasRemoved() throws Exception { SiteModel preferenceSite = dataSite.usingUser(user1).createPublicRandomSite(); diff --git a/e2e-test/java/org/alfresco/rest/preferences/GetPeoplePreferencesFullTests.java b/e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferencesFullTests.java similarity index 83% rename from e2e-test/java/org/alfresco/rest/preferences/GetPeoplePreferencesFullTests.java rename to e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferencesFullTests.java index 3c06774ea..9cc6f55dd 100644 --- a/e2e-test/java/org/alfresco/rest/preferences/GetPeoplePreferencesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferencesFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.preferences; +package org.alfresco.rest.people.preferences; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; @@ -41,7 +41,7 @@ public class GetPeoplePreferencesFullTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its preferences using me with Rest API and response is successful") + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its preferences using me with Rest API and response is successful") public void userGetsItsPeoplePreferencesUsingMe() throws Exception { restPreferenceModelsCollection = restClient.authenticateUser(user1).withCoreAPI().usingMe().getPersonPreferences(); @@ -57,7 +57,7 @@ public class GetPeoplePreferencesFullTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its preferences with skipCount parameter applied with Rest API and response is successful") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its preferences with skipCount parameter applied with Rest API and response is successful") public void userGetsItsPeoplePreferencesUsingSkipCountParameter() throws Exception { restPreferenceModelsCollection = restClient.authenticateUser(user1).withCoreAPI().usingMe().usingParams("skipCount=2").getPersonPreferences(); @@ -74,7 +74,7 @@ public class GetPeoplePreferencesFullTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its preferences with maxItems parameter applied with Rest API and response is successful") + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its preferences with maxItems parameter applied with Rest API and response is successful") public void userGetsItsPeoplePreferencesUsingMaxItemsParameter() throws Exception { restPreferenceModelsCollection = restClient.authenticateUser(user1).withCoreAPI().usingMe().usingParams("maxItems=1").getPersonPreferences(); @@ -91,7 +91,7 @@ public class GetPeoplePreferencesFullTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets admin preferences with Rest API and response is permission denied") + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets admin preferences with Rest API and response is permission denied") public void userIsForbiddenToGetAdminPreferences() throws Exception { restPreferenceModelsCollection = restClient.authenticateUser(user1).withCoreAPI().usingUser(adminUser).getPersonPreferences(); @@ -103,7 +103,7 @@ public class GetPeoplePreferencesFullTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its preferences with skipCount parameter higher then no of entries with Rest API and response is empty") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its preferences with skipCount parameter higher then no of entries with Rest API and response is empty") public void userGetsItsPeoplePreferencesUsingHighSkipCount() throws Exception { restPreferenceModelsCollection = restClient.authenticateUser(user1).withCoreAPI().usingMe().usingParams("skipCount=100").getPersonPreferences(); @@ -115,7 +115,7 @@ public class GetPeoplePreferencesFullTests extends RestTest @Bug(id = "REPO-1911") @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot get preferences for empty user with Rest API and response is 400") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot get preferences for empty user with Rest API and response is 400") public void userGetsItsPeoplePreferencesForEmptyPersonId() throws Exception { UserModel emptyUserName = new UserModel("", "password"); diff --git a/e2e-test/java/org/alfresco/rest/preferences/GetPeoplePreferencesSanityTests.java b/e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferencesSanityTests.java similarity index 81% rename from e2e-test/java/org/alfresco/rest/preferences/GetPeoplePreferencesSanityTests.java rename to e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferencesSanityTests.java index 273125dcd..813af4f38 100644 --- a/e2e-test/java/org/alfresco/rest/preferences/GetPeoplePreferencesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferencesSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.preferences; +package org.alfresco.rest.people.preferences; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; @@ -35,7 +35,7 @@ public class GetPeoplePreferencesSanityTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify manager user gets its preferences with Rest API and response is successful (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify manager user gets its preferences with Rest API and response is successful (200)") public void managerUserGetsPeoplePreferencesWithSuccess() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -49,7 +49,7 @@ public class GetPeoplePreferencesSanityTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify collaborator user gets its preferences with Rest API and response is successful (200)") + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify collaborator user gets its preferences with Rest API and response is successful (200)") public void collaboratorUserGetsPeoplePreferencesWithSuccess() throws Exception { UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); @@ -63,7 +63,7 @@ public class GetPeoplePreferencesSanityTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify contributor user gets its preferences with Rest API and response is successful (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify contributor user gets its preferences with Rest API and response is successful (200)") public void contributorUserGetsPeoplePreferencesWithSuccess() throws Exception { UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); @@ -77,7 +77,7 @@ public class GetPeoplePreferencesSanityTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify consumer user gets its preferences with Rest API and response is successful (200)") + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify consumer user gets its preferences with Rest API and response is successful (200)") public void consumerUserGetsPeoplePreferencesWithSuccess() throws Exception { UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -91,7 +91,7 @@ public class GetPeoplePreferencesSanityTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify admin user gets another user preferences with Rest API and response is successful (200)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify admin user gets another user preferences with Rest API and response is successful (200)") public void adminUserGetsPeoplePreferencesWithSuccess() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); @@ -106,7 +106,7 @@ public class GetPeoplePreferencesSanityTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized to gets its preferences with Rest API when authentication fails(401)") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized to gets its preferences with Rest API when authentication fails(401)") @Bug(id = "MNT-16904", description = "It fails only on environment with tenants") public void managerUserGetsPeoplePreferencesIsNotAuthorized() throws Exception { diff --git a/e2e-test/java/org/alfresco/rest/ratings/post/AddRatingCoreTests.java b/e2e-test/java/org/alfresco/rest/ratings/AddRatingCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/ratings/post/AddRatingCoreTests.java rename to e2e-test/java/org/alfresco/rest/ratings/AddRatingCoreTests.java index fef772bbf..123976721 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/post/AddRatingCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/AddRatingCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.ratings.post; +package org.alfresco.rest.ratings; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/ratings/post/AddRatingFullTests.java b/e2e-test/java/org/alfresco/rest/ratings/AddRatingFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/ratings/post/AddRatingFullTests.java rename to e2e-test/java/org/alfresco/rest/ratings/AddRatingFullTests.java index b52340b6d..6207473b7 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/post/AddRatingFullTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/AddRatingFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.ratings.post; +package org.alfresco.rest.ratings; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/ratings/post/AddRatingSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/ratings/post/AddRatingSanityTests.java rename to e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java index 714bd6b84..8b81a47c6 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/post/AddRatingSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.ratings.post; +package org.alfresco.rest.ratings; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/ratings/delete/DeleteRatingCoreTests.java b/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/ratings/delete/DeleteRatingCoreTests.java rename to e2e-test/java/org/alfresco/rest/ratings/DeleteRatingCoreTests.java index 0012e4790..55216d92d 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/delete/DeleteRatingCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.ratings.delete; +package org.alfresco.rest.ratings; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/ratings/delete/DeleteRatingFullTests.java b/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/ratings/delete/DeleteRatingFullTests.java rename to e2e-test/java/org/alfresco/rest/ratings/DeleteRatingFullTests.java index 1c3aaf3aa..b3c68262f 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/delete/DeleteRatingFullTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.ratings.delete; +package org.alfresco.rest.ratings; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/ratings/delete/DeleteRatingSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/ratings/delete/DeleteRatingSanityTests.java rename to e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java index f51b4dfb8..b6361d095 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/delete/DeleteRatingSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.ratings.delete; +package org.alfresco.rest.ratings; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/ratings/get/GetRatingCoreTests.java b/e2e-test/java/org/alfresco/rest/ratings/GetRatingCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/ratings/get/GetRatingCoreTests.java rename to e2e-test/java/org/alfresco/rest/ratings/GetRatingCoreTests.java index ecb6c8540..5b17497de 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/get/GetRatingCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/GetRatingCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.ratings.get; +package org.alfresco.rest.ratings; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/ratings/get/GetRatingFullTests.java b/e2e-test/java/org/alfresco/rest/ratings/GetRatingFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/ratings/get/GetRatingFullTests.java rename to e2e-test/java/org/alfresco/rest/ratings/GetRatingFullTests.java index d1bdfb729..3fdc99e28 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/get/GetRatingFullTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/GetRatingFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.ratings.get; +package org.alfresco.rest.ratings; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/ratings/get/GetRatingSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/ratings/get/GetRatingSanityTests.java rename to e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java index be3a8c46b..dc9d23178 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/get/GetRatingSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.ratings.get; +package org.alfresco.rest.ratings; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/ratings/get/GetRatingsCoreTests.java b/e2e-test/java/org/alfresco/rest/ratings/GetRatingsCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/ratings/get/GetRatingsCoreTests.java rename to e2e-test/java/org/alfresco/rest/ratings/GetRatingsCoreTests.java index 1c0a173d7..3051df8f4 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/get/GetRatingsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/GetRatingsCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.ratings.get; +package org.alfresco.rest.ratings; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/ratings/get/GetRatingsFullTests.java b/e2e-test/java/org/alfresco/rest/ratings/GetRatingsFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/ratings/get/GetRatingsFullTests.java rename to e2e-test/java/org/alfresco/rest/ratings/GetRatingsFullTests.java index ca6de45b9..1fdbd80ba 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/get/GetRatingsFullTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/GetRatingsFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.ratings.get; +package org.alfresco.rest.ratings; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/ratings/get/GetRatingsSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/GetRatingsSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/ratings/get/GetRatingsSanityTests.java rename to e2e-test/java/org/alfresco/rest/ratings/GetRatingsSanityTests.java index 60352c5a2..a973d37c5 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/get/GetRatingsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/GetRatingsSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.ratings.get; +package org.alfresco.rest.ratings; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/sites/delete/DeleteSiteMemberCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/DeleteSiteMemberCoreTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/sites/delete/DeleteSiteMemberCoreTests.java rename to e2e-test/java/org/alfresco/rest/sites/DeleteSiteMemberCoreTests.java index 06ab77c4a..3ecc49316 100644 --- a/e2e-test/java/org/alfresco/rest/sites/delete/DeleteSiteMemberCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/DeleteSiteMemberCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites.delete; +package org.alfresco.rest.sites; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/sites/delete/DeleteSiteMemberFullTests.java b/e2e-test/java/org/alfresco/rest/sites/DeleteSiteMemberFullTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/sites/delete/DeleteSiteMemberFullTests.java rename to e2e-test/java/org/alfresco/rest/sites/DeleteSiteMemberFullTests.java index 204492503..21e41ac48 100644 --- a/e2e-test/java/org/alfresco/rest/sites/delete/DeleteSiteMemberFullTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/DeleteSiteMemberFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites.delete; +package org.alfresco.rest.sites; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/sites/delete/DeleteSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/DeleteSiteMemberSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/delete/DeleteSiteMemberSanityTests.java rename to e2e-test/java/org/alfresco/rest/sites/DeleteSiteMemberSanityTests.java index 57dd02b5e..03324752d 100644 --- a/e2e-test/java/org/alfresco/rest/sites/delete/DeleteSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/DeleteSiteMemberSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites.delete; +package org.alfresco.rest.sites; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; diff --git a/e2e-test/java/org/alfresco/rest/sites/get/GetSiteCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/get/GetSiteCoreTests.java rename to e2e-test/java/org/alfresco/rest/sites/GetSiteCoreTests.java index e0eb2ea57..e7123a90d 100644 --- a/e2e-test/java/org/alfresco/rest/sites/get/GetSiteCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites.get; +package org.alfresco.rest.sites; import org.alfresco.rest.RestTest; import org.alfresco.rest.core.RestRequest; diff --git a/e2e-test/java/org/alfresco/rest/sites/get/GetSiteFullTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/get/GetSiteFullTests.java rename to e2e-test/java/org/alfresco/rest/sites/GetSiteFullTests.java index 05dd45aac..dff227d0d 100644 --- a/e2e-test/java/org/alfresco/rest/sites/get/GetSiteFullTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites.get; +package org.alfresco.rest.sites; import static org.hamcrest.CoreMatchers.equalTo; diff --git a/e2e-test/java/org/alfresco/rest/sites/get/GetSiteMembershipCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembershipCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/get/GetSiteMembershipCoreTests.java rename to e2e-test/java/org/alfresco/rest/sites/GetSiteMembershipCoreTests.java index e7abb8284..2c7906906 100644 --- a/e2e-test/java/org/alfresco/rest/sites/get/GetSiteMembershipCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembershipCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites.get; +package org.alfresco.rest.sites; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/sites/get/GetSiteMembershipFullTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembershipFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/get/GetSiteMembershipFullTests.java rename to e2e-test/java/org/alfresco/rest/sites/GetSiteMembershipFullTests.java index 934b1090f..292a3381d 100644 --- a/e2e-test/java/org/alfresco/rest/sites/get/GetSiteMembershipFullTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembershipFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites.get; +package org.alfresco.rest.sites; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/sites/get/GetSiteMembershipSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembershipSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/get/GetSiteMembershipSanityTests.java rename to e2e-test/java/org/alfresco/rest/sites/GetSiteMembershipSanityTests.java index d44c70572..67058443e 100644 --- a/e2e-test/java/org/alfresco/rest/sites/get/GetSiteMembershipSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembershipSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites.get; +package org.alfresco.rest.sites; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; diff --git a/e2e-test/java/org/alfresco/rest/sites/get/GetSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/get/GetSiteSanityTests.java rename to e2e-test/java/org/alfresco/rest/sites/GetSiteSanityTests.java index af35e5bee..8c8c5f4e1 100644 --- a/e2e-test/java/org/alfresco/rest/sites/get/GetSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites.get; +package org.alfresco.rest.sites; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; diff --git a/e2e-test/java/org/alfresco/rest/sites/get/GetSitesCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/get/GetSitesCoreTests.java rename to e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java index 0278011b5..d59cbf27a 100644 --- a/e2e-test/java/org/alfresco/rest/sites/get/GetSitesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites.get; +package org.alfresco.rest.sites; import java.util.List; diff --git a/e2e-test/java/org/alfresco/rest/sites/get/GetSitesFullTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSitesFullTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/sites/get/GetSitesFullTests.java rename to e2e-test/java/org/alfresco/rest/sites/GetSitesFullTests.java index ee41b343f..cd787aa03 100644 --- a/e2e-test/java/org/alfresco/rest/sites/get/GetSitesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSitesFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites.get; +package org.alfresco.rest.sites; import java.util.List; diff --git a/e2e-test/java/org/alfresco/rest/sites/get/GetSitesMembershipInformationCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSitesMembershipInformationCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/get/GetSitesMembershipInformationCoreTests.java rename to e2e-test/java/org/alfresco/rest/sites/GetSitesMembershipInformationCoreTests.java index 53e462c43..b2b4d172c 100644 --- a/e2e-test/java/org/alfresco/rest/sites/get/GetSitesMembershipInformationCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSitesMembershipInformationCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites.get; +package org.alfresco.rest.sites; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/sites/get/GetSitesMembershipInformationFullTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSitesMembershipInformationFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/get/GetSitesMembershipInformationFullTests.java rename to e2e-test/java/org/alfresco/rest/sites/GetSitesMembershipInformationFullTests.java index 6d5c0cc7a..f9dddb52b 100644 --- a/e2e-test/java/org/alfresco/rest/sites/get/GetSitesMembershipInformationFullTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSitesMembershipInformationFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites.get; +package org.alfresco.rest.sites; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestSiteMembershipModelsCollection; diff --git a/e2e-test/java/org/alfresco/rest/sites/get/GetSitesMembershipInformationSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSitesMembershipInformationSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/get/GetSitesMembershipInformationSanityTests.java rename to e2e-test/java/org/alfresco/rest/sites/GetSitesMembershipInformationSanityTests.java index 82748f3e2..949d0e563 100644 --- a/e2e-test/java/org/alfresco/rest/sites/get/GetSitesMembershipInformationSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSitesMembershipInformationSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites.get; +package org.alfresco.rest.sites; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; diff --git a/e2e-test/java/org/alfresco/rest/sites/get/GetSitesSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/get/GetSitesSanityTests.java rename to e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java index e1fe7b4d6..377b383e6 100644 --- a/e2e-test/java/org/alfresco/rest/sites/get/GetSitesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites.get; +package org.alfresco.rest.sites; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; diff --git a/e2e-test/java/org/alfresco/rest/sites/get/GetSiteContainerCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/containers/GetSiteContainerCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/get/GetSiteContainerCoreTests.java rename to e2e-test/java/org/alfresco/rest/sites/containers/GetSiteContainerCoreTests.java index 76b9686d4..1bb1f262d 100644 --- a/e2e-test/java/org/alfresco/rest/sites/get/GetSiteContainerCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/containers/GetSiteContainerCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites.get; +package org.alfresco.rest.sites.containers; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/sites/get/GetSiteContainerFullTests.java b/e2e-test/java/org/alfresco/rest/sites/containers/GetSiteContainerFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/get/GetSiteContainerFullTests.java rename to e2e-test/java/org/alfresco/rest/sites/containers/GetSiteContainerFullTests.java index c6762248b..65cf5a42f 100644 --- a/e2e-test/java/org/alfresco/rest/sites/get/GetSiteContainerFullTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/containers/GetSiteContainerFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites.get; +package org.alfresco.rest.sites.containers; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/sites/get/GetSiteContainerSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/containers/GetSiteContainerSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/get/GetSiteContainerSanityTests.java rename to e2e-test/java/org/alfresco/rest/sites/containers/GetSiteContainerSanityTests.java index d4fcd3b1c..777eb7147 100644 --- a/e2e-test/java/org/alfresco/rest/sites/get/GetSiteContainerSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/containers/GetSiteContainerSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites.get; +package org.alfresco.rest.sites.containers; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/sites/get/GetSiteContainersCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/containers/GetSiteContainersCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/get/GetSiteContainersCoreTests.java rename to e2e-test/java/org/alfresco/rest/sites/containers/GetSiteContainersCoreTests.java index 47ee3bd6f..f39fa5546 100644 --- a/e2e-test/java/org/alfresco/rest/sites/get/GetSiteContainersCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/containers/GetSiteContainersCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites.get; +package org.alfresco.rest.sites.containers; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/sites/get/GetSiteContainersFullTests.java b/e2e-test/java/org/alfresco/rest/sites/containers/GetSiteContainersFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/get/GetSiteContainersFullTests.java rename to e2e-test/java/org/alfresco/rest/sites/containers/GetSiteContainersFullTests.java index cfdfe1e28..42c508dbb 100644 --- a/e2e-test/java/org/alfresco/rest/sites/get/GetSiteContainersFullTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/containers/GetSiteContainersFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites.get; +package org.alfresco.rest.sites.containers; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/sites/get/GetSiteContainersSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/containers/GetSiteContainersSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/get/GetSiteContainersSanityTests.java rename to e2e-test/java/org/alfresco/rest/sites/containers/GetSiteContainersSanityTests.java index 77cd0d1f0..0a7d6b398 100644 --- a/e2e-test/java/org/alfresco/rest/sites/get/GetSiteContainersSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/containers/GetSiteContainersSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites.get; +package org.alfresco.rest.sites.containers; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; diff --git a/e2e-test/java/org/alfresco/rest/sites/post/AddSiteMemberCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/members/AddSiteMemberCoreTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/sites/post/AddSiteMemberCoreTests.java rename to e2e-test/java/org/alfresco/rest/sites/members/AddSiteMemberCoreTests.java index b2ac9b622..8b291c0fc 100644 --- a/e2e-test/java/org/alfresco/rest/sites/post/AddSiteMemberCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/members/AddSiteMemberCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites.post; +package org.alfresco.rest.sites.members; import org.alfresco.rest.RestTest; import org.alfresco.rest.core.JsonBodyGenerator; diff --git a/e2e-test/java/org/alfresco/rest/sites/post/AddSiteMemberFullTests.java b/e2e-test/java/org/alfresco/rest/sites/members/AddSiteMemberFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/post/AddSiteMemberFullTests.java rename to e2e-test/java/org/alfresco/rest/sites/members/AddSiteMemberFullTests.java index 9c0e31568..047fb7439 100644 --- a/e2e-test/java/org/alfresco/rest/sites/post/AddSiteMemberFullTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/members/AddSiteMemberFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites.post; +package org.alfresco.rest.sites.members; import org.alfresco.rest.RestTest; import org.alfresco.rest.core.RestRequest; diff --git a/e2e-test/java/org/alfresco/rest/sites/post/AddSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/members/AddSiteMemberSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/post/AddSiteMemberSanityTests.java rename to e2e-test/java/org/alfresco/rest/sites/members/AddSiteMemberSanityTests.java index 1d7247b44..e13bb0ca1 100644 --- a/e2e-test/java/org/alfresco/rest/sites/post/AddSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/members/AddSiteMemberSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites.post; +package org.alfresco.rest.sites.members; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/sites/get/GetSiteMemberCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/members/GetSiteMemberCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/get/GetSiteMemberCoreTests.java rename to e2e-test/java/org/alfresco/rest/sites/members/GetSiteMemberCoreTests.java index d0c40ff9c..3b0e1b12e 100644 --- a/e2e-test/java/org/alfresco/rest/sites/get/GetSiteMemberCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/members/GetSiteMemberCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites.get; +package org.alfresco.rest.sites.members; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/sites/get/GetSiteMemberFullTests.java b/e2e-test/java/org/alfresco/rest/sites/members/GetSiteMemberFullTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/sites/get/GetSiteMemberFullTests.java rename to e2e-test/java/org/alfresco/rest/sites/members/GetSiteMemberFullTests.java index 2e75a3a94..9a49a67b9 100644 --- a/e2e-test/java/org/alfresco/rest/sites/get/GetSiteMemberFullTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/members/GetSiteMemberFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites.get; +package org.alfresco.rest.sites.members; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/sites/get/GetSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/members/GetSiteMemberSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/get/GetSiteMemberSanityTests.java rename to e2e-test/java/org/alfresco/rest/sites/members/GetSiteMemberSanityTests.java index c247ca183..02d86b00a 100644 --- a/e2e-test/java/org/alfresco/rest/sites/get/GetSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/members/GetSiteMemberSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites.get; +package org.alfresco.rest.sites.members; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; diff --git a/e2e-test/java/org/alfresco/rest/sites/get/GetSiteMembersCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/members/GetSiteMembersCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/get/GetSiteMembersCoreTests.java rename to e2e-test/java/org/alfresco/rest/sites/members/GetSiteMembersCoreTests.java index dca259bf7..75a125bc9 100644 --- a/e2e-test/java/org/alfresco/rest/sites/get/GetSiteMembersCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/members/GetSiteMembersCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites.get; +package org.alfresco.rest.sites.members; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/sites/get/GetSiteMembersFullTests.java b/e2e-test/java/org/alfresco/rest/sites/members/GetSiteMembersFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/get/GetSiteMembersFullTests.java rename to e2e-test/java/org/alfresco/rest/sites/members/GetSiteMembersFullTests.java index 1c3f089ba..208903f1e 100644 --- a/e2e-test/java/org/alfresco/rest/sites/get/GetSiteMembersFullTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/members/GetSiteMembersFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites.get; +package org.alfresco.rest.sites.members; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestSiteMemberModel; diff --git a/e2e-test/java/org/alfresco/rest/sites/get/GetSiteMembersSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/members/GetSiteMembersSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/get/GetSiteMembersSanityTests.java rename to e2e-test/java/org/alfresco/rest/sites/members/GetSiteMembersSanityTests.java index 0ad1ec5d3..dee39cf47 100644 --- a/e2e-test/java/org/alfresco/rest/sites/get/GetSiteMembersSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/members/GetSiteMembersSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites.get; +package org.alfresco.rest.sites.members; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; diff --git a/e2e-test/java/org/alfresco/rest/sites/delete/RemoveSiteMemberCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/members/RemoveSiteMemberCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/delete/RemoveSiteMemberCoreTests.java rename to e2e-test/java/org/alfresco/rest/sites/members/RemoveSiteMemberCoreTests.java index de10fd1bb..48570de79 100644 --- a/e2e-test/java/org/alfresco/rest/sites/delete/RemoveSiteMemberCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/members/RemoveSiteMemberCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites.delete; +package org.alfresco.rest.sites.members; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/sites/delete/RemoveSiteMemberFullTests.java b/e2e-test/java/org/alfresco/rest/sites/members/RemoveSiteMemberFullTests.java similarity index 97% rename from e2e-test/java/org/alfresco/rest/sites/delete/RemoveSiteMemberFullTests.java rename to e2e-test/java/org/alfresco/rest/sites/members/RemoveSiteMemberFullTests.java index 724cbcc25..e50fea524 100644 --- a/e2e-test/java/org/alfresco/rest/sites/delete/RemoveSiteMemberFullTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/members/RemoveSiteMemberFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites.delete; +package org.alfresco.rest.sites.members; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/sites/delete/RemoveSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/members/RemoveSiteMemberSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/delete/RemoveSiteMemberSanityTests.java rename to e2e-test/java/org/alfresco/rest/sites/members/RemoveSiteMemberSanityTests.java index 0cd31ac2f..f7e101113 100644 --- a/e2e-test/java/org/alfresco/rest/sites/delete/RemoveSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/members/RemoveSiteMemberSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites.delete; +package org.alfresco.rest.sites.members; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/sites/put/UpdateSiteMemberCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/members/UpdateSiteMemberCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/put/UpdateSiteMemberCoreTests.java rename to e2e-test/java/org/alfresco/rest/sites/members/UpdateSiteMemberCoreTests.java index bb1ae6707..acb9cd596 100644 --- a/e2e-test/java/org/alfresco/rest/sites/put/UpdateSiteMemberCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/members/UpdateSiteMemberCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites.put; +package org.alfresco.rest.sites.members; import org.alfresco.rest.RestTest; import org.alfresco.rest.core.JsonBodyGenerator; diff --git a/e2e-test/java/org/alfresco/rest/sites/put/UpdateSiteMemberFullTests.java b/e2e-test/java/org/alfresco/rest/sites/members/UpdateSiteMemberFullTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/sites/put/UpdateSiteMemberFullTests.java rename to e2e-test/java/org/alfresco/rest/sites/members/UpdateSiteMemberFullTests.java index ceae15734..970566fca 100644 --- a/e2e-test/java/org/alfresco/rest/sites/put/UpdateSiteMemberFullTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/members/UpdateSiteMemberFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites.put; +package org.alfresco.rest.sites.members; import org.alfresco.rest.RestTest; import org.alfresco.rest.core.RestRequest; diff --git a/e2e-test/java/org/alfresco/rest/sites/put/UpdateSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/members/UpdateSiteMemberSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/put/UpdateSiteMemberSanityTests.java rename to e2e-test/java/org/alfresco/rest/sites/members/UpdateSiteMemberSanityTests.java index bc4bb918f..db14a344e 100644 --- a/e2e-test/java/org/alfresco/rest/sites/put/UpdateSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/members/UpdateSiteMemberSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites.put; +package org.alfresco.rest.sites.members; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/sites/post/AddSiteMembershipRequestCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/AddSiteMembershipRequestCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/post/AddSiteMembershipRequestCoreTests.java rename to e2e-test/java/org/alfresco/rest/sites/membershipRequests/AddSiteMembershipRequestCoreTests.java index 70f33ad43..3ec6180a9 100644 --- a/e2e-test/java/org/alfresco/rest/sites/post/AddSiteMembershipRequestCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/AddSiteMembershipRequestCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites.post; +package org.alfresco.rest.sites.membershipRequests; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/sites/post/AddSiteMembershipRequestFullTests.java b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/AddSiteMembershipRequestFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/post/AddSiteMembershipRequestFullTests.java rename to e2e-test/java/org/alfresco/rest/sites/membershipRequests/AddSiteMembershipRequestFullTests.java index 13c1f8b09..616abf09c 100644 --- a/e2e-test/java/org/alfresco/rest/sites/post/AddSiteMembershipRequestFullTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/AddSiteMembershipRequestFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites.post; +package org.alfresco.rest.sites.membershipRequests; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; diff --git a/e2e-test/java/org/alfresco/rest/sites/post/AddSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/AddSiteMembershipRequestSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/post/AddSiteMembershipRequestSanityTests.java rename to e2e-test/java/org/alfresco/rest/sites/membershipRequests/AddSiteMembershipRequestSanityTests.java index ddc91cb5e..9958520cf 100644 --- a/e2e-test/java/org/alfresco/rest/sites/post/AddSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/AddSiteMembershipRequestSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites.post; +package org.alfresco.rest.sites.membershipRequests; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; diff --git a/e2e-test/java/org/alfresco/rest/sites/delete/DeleteSiteMembershipRequestCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/DeleteSiteMembershipRequestCoreTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/sites/delete/DeleteSiteMembershipRequestCoreTests.java rename to e2e-test/java/org/alfresco/rest/sites/membershipRequests/DeleteSiteMembershipRequestCoreTests.java index fb08000b6..b08bc7146 100644 --- a/e2e-test/java/org/alfresco/rest/sites/delete/DeleteSiteMembershipRequestCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/DeleteSiteMembershipRequestCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites.delete; +package org.alfresco.rest.sites.membershipRequests; import org.alfresco.dataprep.WorkflowService; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/sites/delete/DeleteSiteMembershipRequestFullTests.java b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/DeleteSiteMembershipRequestFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/delete/DeleteSiteMembershipRequestFullTests.java rename to e2e-test/java/org/alfresco/rest/sites/membershipRequests/DeleteSiteMembershipRequestFullTests.java index 6e36c4ff3..7ddd11106 100644 --- a/e2e-test/java/org/alfresco/rest/sites/delete/DeleteSiteMembershipRequestFullTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/DeleteSiteMembershipRequestFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites.delete; +package org.alfresco.rest.sites.membershipRequests; import org.alfresco.dataprep.WorkflowService; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/sites/delete/DeleteSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/DeleteSiteMembershipRequestSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/delete/DeleteSiteMembershipRequestSanityTests.java rename to e2e-test/java/org/alfresco/rest/sites/membershipRequests/DeleteSiteMembershipRequestSanityTests.java index 79a2f83de..ccd29cc72 100644 --- a/e2e-test/java/org/alfresco/rest/sites/delete/DeleteSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/DeleteSiteMembershipRequestSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites.delete; +package org.alfresco.rest.sites.membershipRequests; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; diff --git a/e2e-test/java/org/alfresco/rest/sites/get/GetSiteMembershipRequestCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/get/GetSiteMembershipRequestCoreTests.java rename to e2e-test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestCoreTests.java index 7482d6fac..fdfcad18d 100644 --- a/e2e-test/java/org/alfresco/rest/sites/get/GetSiteMembershipRequestCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites.get; +package org.alfresco.rest.sites.membershipRequests; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/sites/get/GetSiteMembershipRequestFullTests.java b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/get/GetSiteMembershipRequestFullTests.java rename to e2e-test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestFullTests.java index a7a7e0e52..edc38a89e 100644 --- a/e2e-test/java/org/alfresco/rest/sites/get/GetSiteMembershipRequestFullTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites.get; +package org.alfresco.rest.sites.membershipRequests; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; diff --git a/e2e-test/java/org/alfresco/rest/sites/get/GetSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/get/GetSiteMembershipRequestSanityTests.java rename to e2e-test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestSanityTests.java index 9b6ff9174..5b38be20a 100644 --- a/e2e-test/java/org/alfresco/rest/sites/get/GetSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites.get; +package org.alfresco.rest.sites.membershipRequests; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; diff --git a/e2e-test/java/org/alfresco/rest/sites/get/GetSiteMembershipRequestsCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestsCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/get/GetSiteMembershipRequestsCoreTests.java rename to e2e-test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestsCoreTests.java index e667df490..c99d29a58 100644 --- a/e2e-test/java/org/alfresco/rest/sites/get/GetSiteMembershipRequestsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestsCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites.get; +package org.alfresco.rest.sites.membershipRequests; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/sites/get/GetSiteMembershipRequestsFullTests.java b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestsFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/get/GetSiteMembershipRequestsFullTests.java rename to e2e-test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestsFullTests.java index ddad9ad9e..d2cb8c720 100644 --- a/e2e-test/java/org/alfresco/rest/sites/get/GetSiteMembershipRequestsFullTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestsFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites.get; +package org.alfresco.rest.sites.membershipRequests; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/sites/get/GetSiteMembershipRequestsSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestsSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/get/GetSiteMembershipRequestsSanityTests.java rename to e2e-test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestsSanityTests.java index d0158fd60..cde5142ad 100644 --- a/e2e-test/java/org/alfresco/rest/sites/get/GetSiteMembershipRequestsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestsSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites.get; +package org.alfresco.rest.sites.membershipRequests; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/sites/put/UpdateSiteMembershipRequestCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/UpdateSiteMembershipRequestCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/put/UpdateSiteMembershipRequestCoreTests.java rename to e2e-test/java/org/alfresco/rest/sites/membershipRequests/UpdateSiteMembershipRequestCoreTests.java index 2b7a82a49..eb814966a 100644 --- a/e2e-test/java/org/alfresco/rest/sites/put/UpdateSiteMembershipRequestCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/UpdateSiteMembershipRequestCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites.put; +package org.alfresco.rest.sites.membershipRequests; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/sites/put/UpdateSiteMembershipRequestFullTests.java b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/UpdateSiteMembershipRequestFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/put/UpdateSiteMembershipRequestFullTests.java rename to e2e-test/java/org/alfresco/rest/sites/membershipRequests/UpdateSiteMembershipRequestFullTests.java index 3c9847311..c62ca1c1d 100644 --- a/e2e-test/java/org/alfresco/rest/sites/put/UpdateSiteMembershipRequestFullTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/UpdateSiteMembershipRequestFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites.put; +package org.alfresco.rest.sites.membershipRequests; import org.alfresco.rest.RestTest; import org.alfresco.rest.core.RestRequest; diff --git a/e2e-test/java/org/alfresco/rest/sites/put/UpdateSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/UpdateSiteMembershipRequestSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/put/UpdateSiteMembershipRequestSanityTests.java rename to e2e-test/java/org/alfresco/rest/sites/membershipRequests/UpdateSiteMembershipRequestSanityTests.java index b911f0e02..a40a0b5e0 100644 --- a/e2e-test/java/org/alfresco/rest/sites/put/UpdateSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/UpdateSiteMembershipRequestSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites.put; +package org.alfresco.rest.sites.membershipRequests; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; diff --git a/e2e-test/java/org/alfresco/rest/tags/get/GetTagCoreTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagCoreTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/tags/get/GetTagCoreTests.java rename to e2e-test/java/org/alfresco/rest/tags/GetTagCoreTests.java index 3d205d4c1..dc1b8c62f 100644 --- a/e2e-test/java/org/alfresco/rest/tags/get/GetTagCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetTagCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.tags.get; +package org.alfresco.rest.tags; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/tags/get/GetTagFullTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/tags/get/GetTagFullTests.java rename to e2e-test/java/org/alfresco/rest/tags/GetTagFullTests.java index bee509909..f16116f0d 100644 --- a/e2e-test/java/org/alfresco/rest/tags/get/GetTagFullTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetTagFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.tags.get; +package org.alfresco.rest.tags; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/tags/get/GetTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/tags/get/GetTagSanityTests.java rename to e2e-test/java/org/alfresco/rest/tags/GetTagSanityTests.java index c2a18bbf0..72dd369cd 100644 --- a/e2e-test/java/org/alfresco/rest/tags/get/GetTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetTagSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.tags.get; +package org.alfresco.rest.tags; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/tags/get/GetTagsCoreTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagsCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/tags/get/GetTagsCoreTests.java rename to e2e-test/java/org/alfresco/rest/tags/GetTagsCoreTests.java index a9caee949..92f006e77 100644 --- a/e2e-test/java/org/alfresco/rest/tags/get/GetTagsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetTagsCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.tags.get; +package org.alfresco.rest.tags; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/tags/get/GetTagsFullTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagsFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/tags/get/GetTagsFullTests.java rename to e2e-test/java/org/alfresco/rest/tags/GetTagsFullTests.java index 7aa97f887..c6dace4c7 100644 --- a/e2e-test/java/org/alfresco/rest/tags/get/GetTagsFullTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetTagsFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.tags.get; +package org.alfresco.rest.tags; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/tags/get/GetTagsSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/tags/get/GetTagsSanityTests.java rename to e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java index 8d768e8e6..f11250c23 100644 --- a/e2e-test/java/org/alfresco/rest/tags/get/GetTagsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.tags.get; +package org.alfresco.rest.tags; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/tags/put/UpdateTagCoreTests.java b/e2e-test/java/org/alfresco/rest/tags/UpdateTagCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/tags/put/UpdateTagCoreTests.java rename to e2e-test/java/org/alfresco/rest/tags/UpdateTagCoreTests.java index a4ddb4194..4904972e6 100644 --- a/e2e-test/java/org/alfresco/rest/tags/put/UpdateTagCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/UpdateTagCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.tags.put; +package org.alfresco.rest.tags; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/tags/put/UpdateTagFullTests.java b/e2e-test/java/org/alfresco/rest/tags/UpdateTagFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/tags/put/UpdateTagFullTests.java rename to e2e-test/java/org/alfresco/rest/tags/UpdateTagFullTests.java index ab80fee1b..d8dcb0066 100644 --- a/e2e-test/java/org/alfresco/rest/tags/put/UpdateTagFullTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/UpdateTagFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.tags.put; +package org.alfresco.rest.tags; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/tags/put/UpdateTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/tags/put/UpdateTagSanityTests.java rename to e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java index e2f5e9321..4b6bb81ae 100644 --- a/e2e-test/java/org/alfresco/rest/tags/put/UpdateTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.tags.put; +package org.alfresco.rest.tags; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/tags/post/AddTagCoreTests.java b/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/tags/post/AddTagCoreTests.java rename to e2e-test/java/org/alfresco/rest/tags/nodes/AddTagCoreTests.java index be2b4937a..a31a7f9b3 100644 --- a/e2e-test/java/org/alfresco/rest/tags/post/AddTagCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.tags.post; +package org.alfresco.rest.tags.nodes; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/tags/post/AddTagFullTests.java b/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/tags/post/AddTagFullTests.java rename to e2e-test/java/org/alfresco/rest/tags/nodes/AddTagFullTests.java index 5d0887490..56cac1672 100644 --- a/e2e-test/java/org/alfresco/rest/tags/post/AddTagFullTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.tags.post; +package org.alfresco.rest.tags.nodes; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/tags/post/AddTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/tags/post/AddTagSanityTests.java rename to e2e-test/java/org/alfresco/rest/tags/nodes/AddTagSanityTests.java index e4150d373..623d675c3 100644 --- a/e2e-test/java/org/alfresco/rest/tags/post/AddTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.tags.post; +package org.alfresco.rest.tags.nodes; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/tags/post/AddTagsSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagsSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/tags/post/AddTagsSanityTests.java rename to e2e-test/java/org/alfresco/rest/tags/nodes/AddTagsSanityTests.java index 44e4be139..c63150703 100644 --- a/e2e-test/java/org/alfresco/rest/tags/post/AddTagsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagsSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.tags.post; +package org.alfresco.rest.tags.nodes; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/tags/delete/DeleteTagCoreTests.java b/e2e-test/java/org/alfresco/rest/tags/nodes/DeleteTagCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/tags/delete/DeleteTagCoreTests.java rename to e2e-test/java/org/alfresco/rest/tags/nodes/DeleteTagCoreTests.java index 9795d20e6..45d7c8ea0 100644 --- a/e2e-test/java/org/alfresco/rest/tags/delete/DeleteTagCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/nodes/DeleteTagCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.tags.delete; +package org.alfresco.rest.tags.nodes; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/tags/delete/DeleteTagFullTests.java b/e2e-test/java/org/alfresco/rest/tags/nodes/DeleteTagFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/tags/delete/DeleteTagFullTests.java rename to e2e-test/java/org/alfresco/rest/tags/nodes/DeleteTagFullTests.java index 208952b11..beab76ae1 100644 --- a/e2e-test/java/org/alfresco/rest/tags/delete/DeleteTagFullTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/nodes/DeleteTagFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.tags.delete; +package org.alfresco.rest.tags.nodes; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/tags/delete/DeleteTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/nodes/DeleteTagSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/tags/delete/DeleteTagSanityTests.java rename to e2e-test/java/org/alfresco/rest/tags/nodes/DeleteTagSanityTests.java index ca6a7a44e..1f59a671b 100644 --- a/e2e-test/java/org/alfresco/rest/tags/delete/DeleteTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/nodes/DeleteTagSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.tags.delete; +package org.alfresco.rest.tags.nodes; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/tags/get/GetNodeTagsCoreTests.java b/e2e-test/java/org/alfresco/rest/tags/nodes/GetNodeTagsCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/tags/get/GetNodeTagsCoreTests.java rename to e2e-test/java/org/alfresco/rest/tags/nodes/GetNodeTagsCoreTests.java index d055fadc6..2f21b5284 100644 --- a/e2e-test/java/org/alfresco/rest/tags/get/GetNodeTagsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/nodes/GetNodeTagsCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.tags.get; +package org.alfresco.rest.tags.nodes; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/tags/get/GetNodeTagsFullTests.java b/e2e-test/java/org/alfresco/rest/tags/nodes/GetNodeTagsFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/tags/get/GetNodeTagsFullTests.java rename to e2e-test/java/org/alfresco/rest/tags/nodes/GetNodeTagsFullTests.java index d71f6cfe3..4e86af200 100644 --- a/e2e-test/java/org/alfresco/rest/tags/get/GetNodeTagsFullTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/nodes/GetNodeTagsFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.tags.get; +package org.alfresco.rest.tags.nodes; import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.CMISUtil.DocumentType; diff --git a/e2e-test/java/org/alfresco/rest/tags/get/GetNodeTagsSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/nodes/GetNodeTagsSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/tags/get/GetNodeTagsSanityTests.java rename to e2e-test/java/org/alfresco/rest/tags/nodes/GetNodeTagsSanityTests.java index a4ff0dade..f82282875 100644 --- a/e2e-test/java/org/alfresco/rest/tags/get/GetNodeTagsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/nodes/GetNodeTagsSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.tags.get; +package org.alfresco.rest.tags.nodes; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/delete/DeleteDeploymentCoreFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentCoreFullTests.java similarity index 97% rename from e2e-test/java/org/alfresco/rest/workflow/deployments/delete/DeleteDeploymentCoreFullTests.java rename to e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentCoreFullTests.java index 32e50db56..b389c17ea 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/delete/DeleteDeploymentCoreFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentCoreFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.deployments.delete; +package org.alfresco.rest.workflow.deployments; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestDeploymentModel; diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/delete/DeleteDeploymentSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/deployments/delete/DeleteDeploymentSanityTests.java rename to e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java index 87e4745f0..254d40c00 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/delete/DeleteDeploymentSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.deployments.delete; +package org.alfresco.rest.workflow.deployments; import java.util.List; diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/get/GetDeploymentCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentCoreTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/workflow/deployments/get/GetDeploymentCoreTests.java rename to e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentCoreTests.java index 8c22f71ab..0fbad6d14 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/get/GetDeploymentCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.deployments.get; +package org.alfresco.rest.workflow.deployments; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestDeploymentModel; diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/get/GetDeploymentFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentFullTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/workflow/deployments/get/GetDeploymentFullTests.java rename to e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentFullTests.java index aa18d6bd9..a13c4a50f 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/get/GetDeploymentFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.deployments.get; +package org.alfresco.rest.workflow.deployments; import org.alfresco.rest.RestTest; import org.alfresco.rest.core.RestRequest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/get/GetDeploymentSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentSanityTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/workflow/deployments/get/GetDeploymentSanityTests.java rename to e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentSanityTests.java index 487d7dc9a..3259dbb1c 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/get/GetDeploymentSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.deployments.get; +package org.alfresco.rest.workflow.deployments; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/get/GetDeploymentsCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsCoreTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/workflow/deployments/get/GetDeploymentsCoreTests.java rename to e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsCoreTests.java index 7082bff55..d2542f4b9 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/get/GetDeploymentsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.deployments.get; +package org.alfresco.rest.workflow.deployments; import java.util.List; diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/get/GetDeploymentsFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/deployments/get/GetDeploymentsFullTests.java rename to e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsFullTests.java index d8b16cac8..d6ab2eaec 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/get/GetDeploymentsFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.deployments.get; +package org.alfresco.rest.workflow.deployments; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/get/GetDeploymentsSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsSanityTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/workflow/deployments/get/GetDeploymentsSanityTests.java rename to e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsSanityTests.java index 2da6f8daf..6eab0bae6 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/get/GetDeploymentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.deployments.get; +package org.alfresco.rest.workflow.deployments; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/post/AddProcessCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/processes/post/AddProcessCoreTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessCoreTests.java index 4ec85a49c..0af7b1302 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/post/AddProcessCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes.post; +package org.alfresco.rest.workflow.processes; import org.alfresco.dataprep.CMISUtil.Priority; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/post/AddProcessFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/processes/post/AddProcessFullTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessFullTests.java index e76865b02..44ce78d45 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/post/AddProcessFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes.post; +package org.alfresco.rest.workflow.processes; import javax.json.JsonObject; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/post/AddProcessSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessSanityTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/workflow/processes/post/AddProcessSanityTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessSanityTests.java index 8f748ac3b..9990d4ad4 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/post/AddProcessSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes.post; +package org.alfresco.rest.workflow.processes; import org.alfresco.dataprep.CMISUtil.Priority; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/delete/DeleteProcessCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessCoreTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/workflow/processes/delete/DeleteProcessCoreTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessCoreTests.java index e63ac0aa5..944c6a234 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/delete/DeleteProcessCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes.delete; +package org.alfresco.rest.workflow.processes; import org.alfresco.dataprep.CMISUtil.Priority; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/delete/DeleteProcessFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessFullTests.java similarity index 97% rename from e2e-test/java/org/alfresco/rest/workflow/processes/delete/DeleteProcessFullTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessFullTests.java index 6c6e0729b..9463d812b 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/delete/DeleteProcessFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes.delete; +package org.alfresco.rest.workflow.processes; import org.alfresco.dataprep.CMISUtil.Priority; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/delete/DeleteProcessSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/workflow/processes/delete/DeleteProcessSanityTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java index 69d14332b..9478b9d0e 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/delete/DeleteProcessSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes.delete; +package org.alfresco.rest.workflow.processes; import org.alfresco.dataprep.CMISUtil.Priority; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessCoreTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessCoreTests.java index cec46a122..ead91ed39 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes.get; +package org.alfresco.rest.workflow.processes; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessFullTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessFullTests.java index addd77720..2282fc002 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes.get; +package org.alfresco.rest.workflow.processes; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessSanityTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessSanityTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessSanityTests.java index 3f1312e75..b4288002a 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes.get; +package org.alfresco.rest.workflow.processes; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessesCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessesCoreTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesCoreTests.java index cb70f074c..e8c78309e 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes.get; +package org.alfresco.rest.workflow.processes; import java.util.List; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessesFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessesFullTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesFullTests.java index d8dd46427..a69c672d0 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes.get; +package org.alfresco.rest.workflow.processes; import java.util.List; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessesSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessesSanityTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java index 9ee7687bd..b64d0d141 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes.get; +package org.alfresco.rest.workflow.processes; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/post/AddProcessItemCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/processes/post/AddProcessItemCoreTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemCoreTests.java index d76dbd106..fa7dd9e38 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/post/AddProcessItemCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes.post; +package org.alfresco.rest.workflow.processes.items; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.CMISUtil.Priority; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/post/AddProcessItemFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/processes/post/AddProcessItemFullTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemFullTests.java index 13de3c29d..c6142cab0 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/post/AddProcessItemFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes.post; +package org.alfresco.rest.workflow.processes.items; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/post/AddProcessItemSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/processes/post/AddProcessItemSanityTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemSanityTests.java index 44a4982c5..51fcf800d 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/post/AddProcessItemSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes.post; +package org.alfresco.rest.workflow.processes.items; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/delete/DeleteProcessItemCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/items/DeleteProcessItemCoreTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/workflow/processes/delete/DeleteProcessItemCoreTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/items/DeleteProcessItemCoreTests.java index 0faa26e46..167984a4a 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/delete/DeleteProcessItemCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/items/DeleteProcessItemCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes.delete; +package org.alfresco.rest.workflow.processes.items; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/delete/DeleteProcessItemFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/items/DeleteProcessItemFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/processes/delete/DeleteProcessItemFullTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/items/DeleteProcessItemFullTests.java index e9e0009b4..556e0822f 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/delete/DeleteProcessItemFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/items/DeleteProcessItemFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes.delete; +package org.alfresco.rest.workflow.processes.items; import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.CMISUtil.DocumentType; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/delete/DeleteProcessItemSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/items/DeleteProcessItemSanityTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/workflow/processes/delete/DeleteProcessItemSanityTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/items/DeleteProcessItemSanityTests.java index a2189edff..df776f144 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/delete/DeleteProcessItemSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/items/DeleteProcessItemSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes.delete; +package org.alfresco.rest.workflow.processes.items; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessItemsCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/items/GetProcessItemsCoreTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessItemsCoreTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/items/GetProcessItemsCoreTests.java index 5cf56d990..b0bce742c 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessItemsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/items/GetProcessItemsCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes.get; +package org.alfresco.rest.workflow.processes.items; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessItemsFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/items/GetProcessItemsFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessItemsFullTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/items/GetProcessItemsFullTests.java index ba9fc7f44..e4f4db5a9 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessItemsFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/items/GetProcessItemsFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes.get; +package org.alfresco.rest.workflow.processes.items; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessItemsSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/items/GetProcessItemsSanityTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessItemsSanityTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/items/GetProcessItemsSanityTests.java index 4190225f2..68ba5ceae 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessItemsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/items/GetProcessItemsSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes.get; +package org.alfresco.rest.workflow.processes.items; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.CMISUtil.Priority; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessTasksCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/tasks/GetProcessTasksCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessTasksCoreTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/tasks/GetProcessTasksCoreTests.java index 8bd5344da..482dd0db7 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessTasksCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/tasks/GetProcessTasksCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes.get; +package org.alfresco.rest.workflow.processes.tasks; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessTasksFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/tasks/GetProcessTasksFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessTasksFullTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/tasks/GetProcessTasksFullTests.java index 17c7292c3..f0b2c24a6 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessTasksFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/tasks/GetProcessTasksFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes.get; +package org.alfresco.rest.workflow.processes.tasks; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessTasksSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/tasks/GetProcessTasksSanityTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessTasksSanityTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/tasks/GetProcessTasksSanityTests.java index 33235d61b..d0c5f0efd 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessTasksSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/tasks/GetProcessTasksSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes.get; +package org.alfresco.rest.workflow.processes.tasks; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/post/AddProcessVariableCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariableCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/processes/post/AddProcessVariableCoreTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariableCoreTests.java index b0bfb4656..e22fb34f3 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/post/AddProcessVariableCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariableCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes.post; +package org.alfresco.rest.workflow.processes.variables; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.CMISUtil.Priority; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/post/AddProcessVariableFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariableFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/processes/post/AddProcessVariableFullTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariableFullTests.java index ad53fea97..2685475e9 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/post/AddProcessVariableFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariableFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes.post; +package org.alfresco.rest.workflow.processes.variables; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/post/AddProcessVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariableSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/processes/post/AddProcessVariableSanityTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariableSanityTests.java index 5065f86e4..f53d84f18 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/post/AddProcessVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariableSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes.post; +package org.alfresco.rest.workflow.processes.variables; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.CMISUtil.Priority; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/post/AddProcessVariablesCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/processes/post/AddProcessVariablesCoreTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesCoreTests.java index a00e49dd7..fc34db68d 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/post/AddProcessVariablesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes.post; +package org.alfresco.rest.workflow.processes.variables; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/post/AddProcessVariablesFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/processes/post/AddProcessVariablesFullTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesFullTests.java index eb7293108..0409d1a1a 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/post/AddProcessVariablesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes.post; +package org.alfresco.rest.workflow.processes.variables; import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.CMISUtil.Priority; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/post/AddProcessVariablesSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/processes/post/AddProcessVariablesSanityTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesSanityTests.java index 0e425975f..88670aff0 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/post/AddProcessVariablesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes.post; +package org.alfresco.rest.workflow.processes.variables; import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.CMISUtil.Priority; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/delete/DeleteProcessVariableCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/DeleteProcessVariableCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/processes/delete/DeleteProcessVariableCoreTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/variables/DeleteProcessVariableCoreTests.java index b4484ebd5..172988a65 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/delete/DeleteProcessVariableCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/DeleteProcessVariableCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes.delete; +package org.alfresco.rest.workflow.processes.variables; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/delete/DeleteProcessVariableFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/DeleteProcessVariableFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/processes/delete/DeleteProcessVariableFullTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/variables/DeleteProcessVariableFullTests.java index 241ade05b..edbb5d714 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/delete/DeleteProcessVariableFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/DeleteProcessVariableFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes.delete; +package org.alfresco.rest.workflow.processes.variables; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.CMISUtil.Priority; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/delete/DeleteProcessVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/DeleteProcessVariableSanityTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/workflow/processes/delete/DeleteProcessVariableSanityTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/variables/DeleteProcessVariableSanityTests.java index 35e30b523..e97633b46 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/delete/DeleteProcessVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/DeleteProcessVariableSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes.delete; +package org.alfresco.rest.workflow.processes.variables; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.CMISUtil.Priority; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessVariablesCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/GetProcessVariablesCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessVariablesCoreTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/variables/GetProcessVariablesCoreTests.java index ca51f802e..370aee125 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessVariablesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/GetProcessVariablesCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes.get; +package org.alfresco.rest.workflow.processes.variables; import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.CMISUtil.DocumentType; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessVariablesFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/GetProcessVariablesFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessVariablesFullTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/variables/GetProcessVariablesFullTests.java index b775bcbbd..0eb5e8c93 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessVariablesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/GetProcessVariablesFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes.get; +package org.alfresco.rest.workflow.processes.variables; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessVariablesSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/GetProcessVariablesSanityTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessVariablesSanityTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/variables/GetProcessVariablesSanityTests.java index d68f3be1c..9cb56b95f 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/get/GetProcessVariablesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/GetProcessVariablesSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes.get; +package org.alfresco.rest.workflow.processes.variables; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/put/UpdateProcessVariableTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/UpdateProcessVariableTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/processes/put/UpdateProcessVariableTests.java rename to e2e-test/java/org/alfresco/rest/workflow/processes/variables/UpdateProcessVariableTests.java index fb497c827..a9d9ef814 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/put/UpdateProcessVariableTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/UpdateProcessVariableTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes.put; +package org.alfresco.rest.workflow.processes.variables; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskCoreTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCoreTests.java index 687c8a998..dd2b8906e 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks.get; +package org.alfresco.rest.workflow.tasks; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.CMISUtil.Priority; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskFormModelCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskFormModelCoreTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelCoreTests.java index 1bedbf658..366a60ead 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskFormModelCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks.get; +package org.alfresco.rest.workflow.tasks; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskFormModelFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskFormModelFullTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelFullTests.java index 2bf561891..d9b501d60 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskFormModelFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks.get; +package org.alfresco.rest.workflow.tasks; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskFormModelSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelSanityTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskFormModelSanityTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelSanityTests.java index 6be7aa247..36a98a800 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskFormModelSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks.get; +package org.alfresco.rest.workflow.tasks; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskFullTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFullTests.java index 23da8a30a..9bba5e6c9 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks.get; +package org.alfresco.rest.workflow.tasks; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.CMISUtil.Priority; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskSanityTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskSanityTests.java index 4e914d732..9f7f638bd 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskSanityTests.java @@ -1,5 +1,5 @@ -package org.alfresco.rest.workflow.tasks.get; +package org.alfresco.rest.workflow.tasks; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTasksCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTasksCoreTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksCoreTests.java index f3df71016..f60f151ee 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTasksCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks.get; +package org.alfresco.rest.workflow.tasks; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.CMISUtil.Priority; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTasksFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTasksFullTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksFullTests.java index 5b8f1d4c3..c51564b97 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTasksFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks.get; +package org.alfresco.rest.workflow.tasks; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.CMISUtil.Priority; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTasksSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTasksSanityTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksSanityTests.java index 71ec7b830..18f26dc24 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTasksSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksSanityTests.java @@ -1,6 +1,6 @@ -package org.alfresco.rest.workflow.tasks.get; +package org.alfresco.rest.workflow.tasks; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/put/UpdateTaskCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/put/UpdateTaskCoreTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTests.java index ff70b0bfd..cdfbaffdd 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/put/UpdateTaskCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks.put; +package org.alfresco.rest.workflow.tasks; import java.util.HashMap; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/put/UpdateTaskCoreTestsBulk2.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTestsBulk2.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/put/UpdateTaskCoreTestsBulk2.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTestsBulk2.java index 6a170a653..bce915178 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/put/UpdateTaskCoreTestsBulk2.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTestsBulk2.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks.put; +package org.alfresco.rest.workflow.tasks; import javax.json.JsonObject; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/put/UpdateTaskCoreTestsBulk3.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTestsBulk3.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/put/UpdateTaskCoreTestsBulk3.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTestsBulk3.java index 9f2fe32ab..d6e53b4e7 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/put/UpdateTaskCoreTestsBulk3.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTestsBulk3.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks.put; +package org.alfresco.rest.workflow.tasks; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/put/UpdateTaskFullTestsBulk1.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk1.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/put/UpdateTaskFullTestsBulk1.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk1.java index 35e608770..e3ee74d64 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/put/UpdateTaskFullTestsBulk1.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk1.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks.put; +package org.alfresco.rest.workflow.tasks; import javax.json.JsonObject; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/put/UpdateTaskFullTestsBulk2.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk2.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/put/UpdateTaskFullTestsBulk2.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk2.java index a2185e126..22f741646 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/put/UpdateTaskFullTestsBulk2.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk2.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks.put; +package org.alfresco.rest.workflow.tasks; import javax.json.JsonObject; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/put/UpdateTaskSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/put/UpdateTaskSanityTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskSanityTests.java index d1631246f..edb4670ef 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/put/UpdateTaskSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks.put; +package org.alfresco.rest.workflow.tasks; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskCandidatesCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/candidates/GetTaskCandidatesCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskCandidatesCoreTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/candidates/GetTaskCandidatesCoreTests.java index 95bc35e10..eaa4bcf0f 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskCandidatesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/candidates/GetTaskCandidatesCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks.get; +package org.alfresco.rest.workflow.tasks.candidates; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskCandidatesFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/candidates/GetTaskCandidatesFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskCandidatesFullTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/candidates/GetTaskCandidatesFullTests.java index 45f06df47..aebaa0707 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskCandidatesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/candidates/GetTaskCandidatesFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks.get; +package org.alfresco.rest.workflow.tasks.candidates; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskCandidatesSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/candidates/GetTaskCandidatesSanityTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskCandidatesSanityTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/candidates/GetTaskCandidatesSanityTests.java index ff4ee8b49..b9fd88f1a 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskCandidatesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/candidates/GetTaskCandidatesSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks.get; +package org.alfresco.rest.workflow.tasks.candidates; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/post/AddTaskItemCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/post/AddTaskItemCoreTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemCoreTests.java index a0dcbb36a..911725f2b 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/post/AddTaskItemCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks.post; +package org.alfresco.rest.workflow.tasks.items; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/post/AddTaskItemFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/post/AddTaskItemFullTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemFullTests.java index 5824206de..aea3e0317 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/post/AddTaskItemFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks.post; +package org.alfresco.rest.workflow.tasks.items; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/post/AddTaskItemSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/post/AddTaskItemSanityTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemSanityTests.java index 2f5e4a983..7b271c3ac 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/post/AddTaskItemSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks.post; +package org.alfresco.rest.workflow.tasks.items; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskItemsCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/items/GetTaskItemsCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskItemsCoreTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/items/GetTaskItemsCoreTests.java index e1f5281f9..8b853dac7 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskItemsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/items/GetTaskItemsCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks.get; +package org.alfresco.rest.workflow.tasks.items; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.CMISUtil.Priority; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskItemsFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/items/GetTaskItemsFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskItemsFullTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/items/GetTaskItemsFullTests.java index 9b36550b8..9bc9d7046 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskItemsFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/items/GetTaskItemsFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks.get; +package org.alfresco.rest.workflow.tasks.items; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskItemsSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/items/GetTaskItemsSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskItemsSanityTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/items/GetTaskItemsSanityTests.java index 29e38c7c2..c8990f431 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskItemsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/items/GetTaskItemsSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks.get; +package org.alfresco.rest.workflow.tasks.items; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/delete/RemoveTaskItemCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/items/RemoveTaskItemCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/delete/RemoveTaskItemCoreTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/items/RemoveTaskItemCoreTests.java index 270fd72ff..b72978e0e 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/delete/RemoveTaskItemCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/items/RemoveTaskItemCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks.delete; +package org.alfresco.rest.workflow.tasks.items; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/delete/RemoveTaskItemFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/items/RemoveTaskItemFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/delete/RemoveTaskItemFullTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/items/RemoveTaskItemFullTests.java index 1be46face..8d334062d 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/delete/RemoveTaskItemFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/items/RemoveTaskItemFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks.delete; +package org.alfresco.rest.workflow.tasks.items; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/delete/RemoveTaskItemSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/items/RemoveTaskItemSanityTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/delete/RemoveTaskItemSanityTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/items/RemoveTaskItemSanityTests.java index d441b8405..4bff98e35 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/delete/RemoveTaskItemSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/items/RemoveTaskItemSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks.delete; +package org.alfresco.rest.workflow.tasks.items; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/post/AddTaskVariablesCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/post/AddTaskVariablesCoreTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesCoreTests.java index a608371ce..9efbdd957 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/post/AddTaskVariablesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks.post; +package org.alfresco.rest.workflow.tasks.variables; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/post/AddTaskVariablesFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/post/AddTaskVariablesFullTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesFullTests.java index cb41c444b..4fb3fc284 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/post/AddTaskVariablesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks.post; +package org.alfresco.rest.workflow.tasks.variables; import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.CMISUtil.DocumentType; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/post/AddTaskVariablesSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/post/AddTaskVariablesSanityTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesSanityTests.java index 899aaa2b7..86cd6c2cb 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/post/AddTaskVariablesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks.post; +package org.alfresco.rest.workflow.tasks.variables; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/delete/DeleteTaskVariableCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/DeleteTaskVariableCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/delete/DeleteTaskVariableCoreTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/variables/DeleteTaskVariableCoreTests.java index 8ada88687..192e0ca4f 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/delete/DeleteTaskVariableCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/DeleteTaskVariableCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks.delete; +package org.alfresco.rest.workflow.tasks.variables; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/delete/DeleteTaskVariableFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/DeleteTaskVariableFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/delete/DeleteTaskVariableFullTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/variables/DeleteTaskVariableFullTests.java index 4a9fce414..c93ffb765 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/delete/DeleteTaskVariableFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/DeleteTaskVariableFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks.delete; +package org.alfresco.rest.workflow.tasks.variables; import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.CMISUtil.DocumentType; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/delete/DeleteTaskVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/DeleteTaskVariableSanityTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/delete/DeleteTaskVariableSanityTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/variables/DeleteTaskVariableSanityTests.java index 219f2db04..ba8ae1e73 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/delete/DeleteTaskVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/DeleteTaskVariableSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks.delete; +package org.alfresco.rest.workflow.tasks.variables; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskVariablesCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/GetTaskVariablesCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskVariablesCoreTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/variables/GetTaskVariablesCoreTests.java index 2ce70e0f3..d0e788191 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskVariablesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/GetTaskVariablesCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks.get; +package org.alfresco.rest.workflow.tasks.variables; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskVariablesFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/GetTaskVariablesFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskVariablesFullTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/variables/GetTaskVariablesFullTests.java index fee0d069c..7ee844cbd 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskVariablesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/GetTaskVariablesFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks.get; +package org.alfresco.rest.workflow.tasks.variables; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskVariablesSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/GetTaskVariablesSanityTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskVariablesSanityTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/variables/GetTaskVariablesSanityTests.java index d290af8f6..f6d249f05 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/get/GetTaskVariablesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/GetTaskVariablesSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks.get; +package org.alfresco.rest.workflow.tasks.variables; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/put/UpdateTaskVariableCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/put/UpdateTaskVariableCoreTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableCoreTests.java index f92fd52d2..d29930dd8 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/put/UpdateTaskVariableCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks.put; +package org.alfresco.rest.workflow.tasks.variables; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/put/UpdateTaskVariableFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/put/UpdateTaskVariableFullTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableFullTests.java index 5f90ec367..e8ab9696f 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/put/UpdateTaskVariableFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks.put; +package org.alfresco.rest.workflow.tasks.variables; import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.CMISUtil.DocumentType; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/put/UpdateTaskVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/put/UpdateTaskVariableSanityTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableSanityTests.java index e3ddb0c72..4456d4f6e 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/put/UpdateTaskVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks.put; +package org.alfresco.rest.workflow.tasks.variables; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; From 3812a9d230cb3783cd1c351977af1efe83f7464b Mon Sep 17 00:00:00 2001 From: mionescu Date: Tue, 21 Feb 2017 09:23:04 +0200 Subject: [PATCH 1053/1491] update tests group --- e2e-test/resources/default.properties | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/e2e-test/resources/default.properties b/e2e-test/resources/default.properties index 2e4c58893..c3acbc877 100644 --- a/e2e-test/resources/default.properties +++ b/e2e-test/resources/default.properties @@ -1,7 +1,7 @@ # dataprep related alfresco.scheme=http -alfresco.server=localhost -alfresco.port=8080 +alfresco.server=172.29.101.200 +alfresco.port=8070 # credentials admin.user=admin @@ -9,7 +9,7 @@ admin.password=admin # in containers we cannot access directly JMX, so we will use http://jolokia.org agent # disabling this we will use direct JMX calls to server -jmx.useJolokiaAgent=false +jmx.useJolokiaAgent=true # Server Health section # in ServerHealth#isServerReachable() - could also be shown. From 928508d2255f2850bafd62f9e63a91aaec009dde Mon Sep 17 00:00:00 2001 From: mionescu Date: Tue, 21 Feb 2017 09:24:15 +0200 Subject: [PATCH 1054/1491] update tests group --- .../alfresco/rest/FunctionalCasesTests.java | 2 +- .../GetProcessDefinitionCoreTests.java | 6 ++--- .../GetProcessDefinitionFullTests.java | 6 ++--- .../GetProcessDefinitionImageCoreTests.java | 6 ++--- .../GetProcessDefinitionImageFullTests.java | 4 ++-- .../GetProcessDefinitionImageSanityTests.java | 4 ++-- .../GetProcessDefinitionSanityTests.java | 4 ++-- ...cessDefinitionStartFormModelCoreTests.java | 8 +++---- ...cessDefinitionStartFormModelFullTests.java | 7 +++--- ...ssDefinitionStartFormModelSanityTests.java | 4 ++-- .../GetProcessDefinitionsCoreTests.java | 8 +++---- .../GetProcessDefinitionsFullTests.java | 22 +++++++++---------- .../GetProcessDefinitionsSanityTests.java | 4 ++-- .../tasks/items/AddTaskItemFullTests.java | 8 +++---- e2e-test/resources/default.properties | 6 ++--- 15 files changed, 49 insertions(+), 50 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java b/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java index f6b22487c..a4377bc30 100644 --- a/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java +++ b/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java @@ -656,7 +656,7 @@ public class FunctionalCasesTests extends RestTest */ @Bug(id="REPO-1830") @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its activities with Rest API and response is successful") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its activities with Rest API and response is successful") public void userGetsItsPeopleActivities() throws Exception { UserModel newUser = dataUser.createRandomTestUser(); diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionCoreTests.java index 286b84400..9f9dc621a 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionCoreTests.java @@ -25,7 +25,7 @@ public class GetProcessDefinitionCoreTests extends RestTest adminUser = dataUser.getAdminUser(); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify if get process definition returns status code 404 when invalid processDefinitionId is used") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.CORE }) @@ -43,7 +43,7 @@ public class GetProcessDefinitionCoreTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify network admin is able to get a process definition using REST API and status code is OK (200)") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.CORE, TestGroup.NETWORKS }) @@ -58,7 +58,7 @@ public class GetProcessDefinitionCoreTests extends RestTest returnedProcessDefinition.assertThat().field("name").is(randomProcessDefinition.getName()); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify network user is able to get a process definition using REST API and status code is OK (200)") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.CORE, TestGroup.NETWORKS }) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionFullTests.java index 9af418895..53721b10d 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionFullTests.java @@ -28,7 +28,7 @@ public class GetProcessDefinitionFullTests extends RestTest adminUser = dataUser.getAdminUser(); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify if get process definition returns all process definitions when empty processDefinitionId is used") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.FULL }) @@ -41,7 +41,7 @@ public class GetProcessDefinitionFullTests extends RestTest processDefinitions.assertThat().entriesListIsNotEmpty(); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify Admin user gets a process definition with properties parameter applied using REST API and status code is OK (200)") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.FULL }) @@ -66,7 +66,7 @@ public class GetProcessDefinitionFullTests extends RestTest .field("name").is(randomProcessDefinition.getName()); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify Network user is not able to get a process definition from another network") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.NETWORKS, TestGroup.FULL }) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageCoreTests.java index a3eb00c04..5b0fd87f1 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageCoreTests.java @@ -26,7 +26,7 @@ public class GetProcessDefinitionImageCoreTests extends RestTest adminUser = dataUser.getAdminUser(); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify if get process definition image returns status code 404 when invalid processDefinitionId is used") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.CORE }) @@ -44,7 +44,7 @@ public class GetProcessDefinitionImageCoreTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify network admin is able to get a process definition image using REST API and status code is OK (200)") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.CORE, TestGroup.NETWORKS }) @@ -60,7 +60,7 @@ public class GetProcessDefinitionImageCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify network user is able to get a process definition image using REST API and status code is OK (200)") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.CORE, TestGroup.NETWORKS }) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageFullTests.java index 009284b61..ae3168893 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageFullTests.java @@ -27,7 +27,7 @@ public class GetProcessDefinitionImageFullTests extends RestTest } @Bug(id = "REPO-1911") - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify if get process definition image returns status code 404 when empty processDefinitionId is used") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.CORE }) @@ -41,7 +41,7 @@ public class GetProcessDefinitionImageFullTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify Tenant User doesn't get process definition image for another network deployment using REST API") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.FULL, TestGroup.NETWORKS }) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java index 361e1d4e8..038d7aafb 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java @@ -26,7 +26,7 @@ public class GetProcessDefinitionImageSanityTests extends RestTest randomProcessDefinition = restClient.withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry(); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.SANITY, description = "Verify Any user gets a specific process definition image for non-network deployments using REST API and status code is OK (200)") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY }) public void anyUserGetsProcessDefinitionImage() throws Exception @@ -37,7 +37,7 @@ public class GetProcessDefinitionImageSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets a specific process definition image for non-network deployments using REST API and status code is OK (200)") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY }) public void adminGetsProcessDefinitionImage() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java index 9a733f851..d8efb06af 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java @@ -26,7 +26,7 @@ public class GetProcessDefinitionSanityTests extends RestTest randomProcessDefinition = restClient.withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry().onModel(); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets a specific process definition for non-network deployments using REST API and status code is OK (200)") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY }) @@ -37,7 +37,7 @@ public class GetProcessDefinitionSanityTests extends RestTest returnedProcessDefinition.assertThat().field("name").is(randomProcessDefinition.getName()); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.SANITY, description = "Verify Any user gets a specific process definition for non-network deployments using REST API and status code is OK (200)") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY }) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java index b1d7a4642..5322dd11f 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java @@ -29,7 +29,7 @@ public class GetProcessDefinitionStartFormModelCoreTests extends RestTest allProcessDefinitions = restClient.authenticateUser(adminUser).withWorkflowAPI().getAllProcessDefinitions(); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify any user gets a model of the start form type definition for non-network deployments using REST API and status code is OK (200)") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.CORE }) @@ -44,7 +44,7 @@ public class GetProcessDefinitionStartFormModelCoreTests extends RestTest } @Bug(id = "ALF-20187") - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify if get request returns status code 404 when invalid processDefinitionId is used") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.CORE }) @@ -63,7 +63,7 @@ public class GetProcessDefinitionStartFormModelCoreTests extends RestTest } @Bug(id = "ALF-20187") - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify if get request returns status code 404 when empty processDefinitionId is used") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.CORE }) @@ -78,7 +78,7 @@ public class GetProcessDefinitionStartFormModelCoreTests extends RestTest .assertLastError().containsSummary("no deployed process definition found with id ''"); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify Tenant User gets a model of the start form type definition for network deployments using REST API and status code is OK (200)") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.CORE, TestGroup.NETWORKS }) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelFullTests.java index 27e146a38..c7bfcc303 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelFullTests.java @@ -30,7 +30,7 @@ public class GetProcessDefinitionStartFormModelFullTests extends RestTest activitiAdhoc = restClient.authenticateUser(adminUser).withWorkflowAPI().getAllProcessDefinitions().getProcessDefinitionByDeploymentId("1"); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify admin gets a model of the start form type definition for specific process definition using REST API and status code is OK (200)") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.FULL }) @@ -49,7 +49,7 @@ public class GetProcessDefinitionStartFormModelFullTests extends RestTest .and().field("allowedValues").is(Arrays.asList("1", "2", "3")); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify admin gets a model of the start form type definition with properties parameter applied using REST API and status code is OK (200)") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.FULL }) @@ -70,8 +70,7 @@ public class GetProcessDefinitionStartFormModelFullTests extends RestTest .and().field("allowedValues").isNull(); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify Tenant User doesn't get a model of the start form type definition for another network deployment using REST API") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.FULL, TestGroup.NETWORKS }) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java index 0eb010e8c..3c35bd28b 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java @@ -26,7 +26,7 @@ public class GetProcessDefinitionStartFormModelSanityTests extends RestTest restClient.authenticateUser(adminUserModel); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.SANITY, description = "Verify Admin gets a model of the start form type definition for non-network deployments using REST API and status code is OK (200)") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY }) @@ -37,7 +37,7 @@ public class GetProcessDefinitionStartFormModelSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.SANITY, description = "Verify Tenant Admin gets a model of the start form type definition for network deployments using REST API and status code is OK (200)") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY, TestGroup.NETWORKS }) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsCoreTests.java index cb127190b..d1c9729f8 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsCoreTests.java @@ -26,7 +26,7 @@ public class GetProcessDefinitionsCoreTests extends RestTest adminTenantUser = UserModel.getAdminTenantUser(); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify any user gets process definitions for non-network deployments using REST API and status code is OK (200)") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.CORE }) public void nonNetworkUserGetsProcessDefinitions() throws Exception @@ -48,7 +48,7 @@ public class GetProcessDefinitionsCoreTests extends RestTest .field("key").is("activitiAdhoc"); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify get process definitions using any network user for network enabled deployments with REST API status code is OK (200)") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.CORE, TestGroup.NETWORKS}) public void networkUserGetsProcessDefinitions() throws Exception @@ -62,7 +62,7 @@ public class GetProcessDefinitionsCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify call to get process definitions with invalid orderBy parameter with REST API and status code is BAD_REQUEST (400)") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.CORE }) public void userGetProcessDefinitionsWithInvalidOrderBy() throws Exception @@ -76,7 +76,7 @@ public class GetProcessDefinitionsCoreTests extends RestTest .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_ORDERBY, "test", "deploymentId, name, id, category, version, key")); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify call to get process definitions with invalid where parameter with REST API and status code is BAD_REQUEST (400)") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.CORE }) public void userGetProcessDefinitionsWithInvalidWhere() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsFullTests.java index 23fea5554..3c9a370d8 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsFullTests.java @@ -26,7 +26,7 @@ public class GetProcessDefinitionsFullTests extends RestTest adminUserModel = dataUser.getAdminUser(); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify admin gets process definitions with valid skipCount parameter applied using REST API and status code is OK (200)") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.FULL }) public void getProcessDefinitionsWithValidSkipCount() throws Exception @@ -46,7 +46,7 @@ public class GetProcessDefinitionsFullTests extends RestTest procDefWithSkipCount.assertThat().paginationField("skipCount").is("2"); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify admin doesn't get process definitions with negative skipCount parameter applied using REST API") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.FULL }) public void getProcessDefinitionsWithNegativeSkipCount() throws Exception @@ -60,7 +60,7 @@ public class GetProcessDefinitionsFullTests extends RestTest .statusCodeIs(HttpStatus.BAD_REQUEST); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify admin doesn't get process definitions with non numeric skipCount parameter applied using REST API") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.FULL }) public void getProcessDefinitionsWithNonNumericSkipCount() throws Exception @@ -70,7 +70,7 @@ public class GetProcessDefinitionsFullTests extends RestTest .containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "A")); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify admin gets process definitions with valid maxItems parameter applied using REST API and status code is OK (200)") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.FULL }) public void getProcessDefinitionsWithValidMaxItems() throws Exception @@ -90,7 +90,7 @@ public class GetProcessDefinitionsFullTests extends RestTest procDefWithMaxItems.assertThat().paginationField("maxItems").is("2"); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify admin doesn't get process definitions with negative maxItems parameter applied using REST API") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.FULL }) public void getProcessDefinitionsWithNegativeMaxItems() throws Exception @@ -104,7 +104,7 @@ public class GetProcessDefinitionsFullTests extends RestTest .statusCodeIs(HttpStatus.BAD_REQUEST); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify admin doesn't get process definitions with non numeric maxItems parameter applied using REST API") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.FULL }) public void getProcessDefinitionsWithNonNumericMaxItems() throws Exception @@ -114,7 +114,7 @@ public class GetProcessDefinitionsFullTests extends RestTest .containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "A")); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify Admin user gets process definitions with properties parameter applied using REST API and status code is OK (200)") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.FULL }) public void getProcessDefinitionsWithValidProperties() throws Exception @@ -136,7 +136,7 @@ public class GetProcessDefinitionsFullTests extends RestTest .field("name").isNotEmpty(); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify admin gets process definitions ordered by name ascendant using REST API and status code is OK (200)") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.FULL }) public void getProcessDefinitionsOrderedByNameAsc() throws Exception @@ -147,7 +147,7 @@ public class GetProcessDefinitionsFullTests extends RestTest processDefinitions.assertThat().entriesListIsSortedAscBy("name"); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify admin doesn't get process definitions when many fields are used for orderBy parameter") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.FULL }) public void getProcessDefinitionsOrderedByManyFields() throws Exception @@ -158,7 +158,7 @@ public class GetProcessDefinitionsFullTests extends RestTest .assertLastError().containsSummary(RestErrorModel.ONLY_ONE_ORDERBY); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify admin gets process definitions when where parameter is applied") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.FULL }) public void getProcessDefinitionsFilteredByKey() throws Exception @@ -171,7 +171,7 @@ public class GetProcessDefinitionsFullTests extends RestTest .assertThat().entriesListContains("key", "activitiParallelGroupReview"); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify Tenant User doesn't get process definitions for another network deployment using REST API") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.FULL, TestGroup.NETWORKS }) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java index 9925ebd93..02f49ff44 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java @@ -24,7 +24,7 @@ public class GetProcessDefinitionsSanityTests extends RestTest restClient.authenticateUser(adminUserModel); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets process definitions for non-network deployments using REST API and status code is OK (200)") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY }) public void nonNetworkAdminGetsProcessDefinitions() throws Exception @@ -34,7 +34,7 @@ public class GetProcessDefinitionsSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.SANITY, description = "Verify Tenant Admin user gets process definitions for network deployments using REST API and status code is OK (200)") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY, TestGroup.NETWORKS}) public void networkAdminGetsProcessDefinitions() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemFullTests.java index aea3e0317..93a804e9e 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemFullTests.java @@ -87,7 +87,7 @@ public class AddTaskItemFullTests extends RestTest .assertThat().field("mimeType").is(taskItems.getEntries().get(1).onModel().getMimeType()); } - @TestRail(section = { TestGroup.REST_API, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Add task item using by admin in other network.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL, TestGroup.NETWORKS }) public void addTaskItemByAdminInOtherNetwork() throws Exception @@ -111,7 +111,7 @@ public class AddTaskItemFullTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE); } - @TestRail(section = { TestGroup.REST_API, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Add multiple task item using by admin in other network.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL, TestGroup.NETWORKS }) public void addMultipleTaskItemByAdminInOtherNetwork() throws Exception @@ -137,7 +137,7 @@ public class AddTaskItemFullTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE);; } - @TestRail(section = { TestGroup.REST_API, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Delete task item then create it again") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL}) public void deleteTaskItemThenCreateItAgain() throws Exception @@ -156,7 +156,7 @@ public class AddTaskItemFullTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.CREATED); } - @TestRail(section = { TestGroup.REST_API, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Delete multiple task item then create it again") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL}) public void deleteMultipleTaskItemThenCreateItAgain() throws Exception diff --git a/e2e-test/resources/default.properties b/e2e-test/resources/default.properties index c3acbc877..2e4c58893 100644 --- a/e2e-test/resources/default.properties +++ b/e2e-test/resources/default.properties @@ -1,7 +1,7 @@ # dataprep related alfresco.scheme=http -alfresco.server=172.29.101.200 -alfresco.port=8070 +alfresco.server=localhost +alfresco.port=8080 # credentials admin.user=admin @@ -9,7 +9,7 @@ admin.password=admin # in containers we cannot access directly JMX, so we will use http://jolokia.org agent # disabling this we will use direct JMX calls to server -jmx.useJolokiaAgent=true +jmx.useJolokiaAgent=false # Server Health section # in ServerHealth#isServerReachable() - could also be shown. From 6178d734931549b03f93dd82b7e99b184fd56be4 Mon Sep 17 00:00:00 2001 From: mionescu Date: Tue, 21 Feb 2017 11:19:18 +0200 Subject: [PATCH 1055/1491] update- moved tests --- .../rest/{sites => people}/DeleteSiteMemberCoreTests.java | 2 +- .../rest/{sites => people}/DeleteSiteMemberFullTests.java | 2 +- .../rest/{sites => people}/DeleteSiteMemberSanityTests.java | 2 +- .../rest/{sites => people}/GetSiteMembershipCoreTests.java | 2 +- .../rest/{sites => people}/GetSiteMembershipFullTests.java | 2 +- .../rest/{sites => people}/GetSiteMembershipSanityTests.java | 2 +- .../GetSitesMembershipInformationCoreTests.java | 2 +- .../GetSitesMembershipInformationFullTests.java | 2 +- .../GetSitesMembershipInformationSanityTests.java | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) rename e2e-test/java/org/alfresco/rest/{sites => people}/DeleteSiteMemberCoreTests.java (98%) rename e2e-test/java/org/alfresco/rest/{sites => people}/DeleteSiteMemberFullTests.java (98%) rename e2e-test/java/org/alfresco/rest/{sites => people}/DeleteSiteMemberSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/{sites => people}/GetSiteMembershipCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/{sites => people}/GetSiteMembershipFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/{sites => people}/GetSiteMembershipSanityTests.java (99%) rename e2e-test/java/org/alfresco/rest/{sites => people}/GetSitesMembershipInformationCoreTests.java (99%) rename e2e-test/java/org/alfresco/rest/{sites => people}/GetSitesMembershipInformationFullTests.java (99%) rename e2e-test/java/org/alfresco/rest/{sites => people}/GetSitesMembershipInformationSanityTests.java (99%) diff --git a/e2e-test/java/org/alfresco/rest/sites/DeleteSiteMemberCoreTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberCoreTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/sites/DeleteSiteMemberCoreTests.java rename to e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberCoreTests.java index 3ecc49316..536dd36b3 100644 --- a/e2e-test/java/org/alfresco/rest/sites/DeleteSiteMemberCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites; +package org.alfresco.rest.people; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/sites/DeleteSiteMemberFullTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberFullTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/sites/DeleteSiteMemberFullTests.java rename to e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberFullTests.java index 21e41ac48..d069379bb 100644 --- a/e2e-test/java/org/alfresco/rest/sites/DeleteSiteMemberFullTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites; +package org.alfresco.rest.people; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/sites/DeleteSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/DeleteSiteMemberSanityTests.java rename to e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java index 03324752d..3c15d11d0 100644 --- a/e2e-test/java/org/alfresco/rest/sites/DeleteSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites; +package org.alfresco.rest.people; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembershipCoreTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/GetSiteMembershipCoreTests.java rename to e2e-test/java/org/alfresco/rest/people/GetSiteMembershipCoreTests.java index 2c7906906..9ccb41f7d 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembershipCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites; +package org.alfresco.rest.people; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembershipFullTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/GetSiteMembershipFullTests.java rename to e2e-test/java/org/alfresco/rest/people/GetSiteMembershipFullTests.java index 292a3381d..f27644f74 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembershipFullTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites; +package org.alfresco.rest.people; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembershipSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/GetSiteMembershipSanityTests.java rename to e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java index 67058443e..04766c5d1 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembershipSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites; +package org.alfresco.rest.people; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSitesMembershipInformationCoreTests.java b/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/GetSitesMembershipInformationCoreTests.java rename to e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationCoreTests.java index b2b4d172c..07878cf0a 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSitesMembershipInformationCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites; +package org.alfresco.rest.people; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSitesMembershipInformationFullTests.java b/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/GetSitesMembershipInformationFullTests.java rename to e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationFullTests.java index f9dddb52b..9abef3e7e 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSitesMembershipInformationFullTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites; +package org.alfresco.rest.people; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestSiteMembershipModelsCollection; diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSitesMembershipInformationSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/GetSitesMembershipInformationSanityTests.java rename to e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java index 949d0e563..685d06aee 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSitesMembershipInformationSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites; +package org.alfresco.rest.people; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; From 74024f75a43953f26045c2bce179ffe67e0d0930 Mon Sep 17 00:00:00 2001 From: Michael Suzuki Date: Tue, 21 Feb 2017 11:50:58 +0000 Subject: [PATCH 1056/1491] Added basic search test --- .../org/alfresco/rest/search/SearchTest.java | 47 ++++++++++++------- 1 file changed, 30 insertions(+), 17 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/SearchTest.java b/e2e-test/java/org/alfresco/rest/search/SearchTest.java index 3e406c1df..f97e5b665 100644 --- a/e2e-test/java/org/alfresco/rest/search/SearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/SearchTest.java @@ -21,7 +21,11 @@ package org.alfresco.rest.search; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestNodeModelsCollection; 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.FileModel; +import org.alfresco.utility.model.FileType; +import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; import org.springframework.http.HttpStatus; @@ -35,8 +39,9 @@ import org.testng.annotations.Test; */ public class SearchTest extends RestTest { + private static final String SEARCH_DATA_SAMPLE_FOLDER = "folder"; UserModel userModel, adminUserModel; - SiteModel siteModel, privateSiteModel, moderatedSiteModel; + SiteModel siteModel; UserModel searchedUser; NodesBuilder nodesBuilder; @@ -46,37 +51,45 @@ public class SearchTest extends RestTest adminUserModel = dataUser.getAdminUser(); userModel = dataUser.createRandomTestUser(); siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - moderatedSiteModel = dataSite.usingUser(userModel).createModeratedRandomSite(); - /* * Create the following file structure for preconditions : - * - sourceFolder - * - suzuki + * |- folder + * |-- pangram.txt + * |-- cars.pdf */ nodesBuilder = restClient.authenticateUser(userModel).withCoreAPI().usingNode(ContentModel.my()).defineNodes(); + FolderModel folder = new FolderModel(SEARCH_DATA_SAMPLE_FOLDER); + dataContent.usingSite(siteModel).createFolder(folder); + //Create files + FileModel file = new FileModel("pangram.txt", FileType.TEXT_PLAIN, "The qucik brown fox jumps over the lazy dog"); + FileModel file2 = new FileModel("cars.txt", FileType.TEXT_PLAIN, "The landrover discovery is not a sports car"); + ContentModel cm = new ContentModel(); + cm.setCmisLocation(folder.getCmisLocation()); + cm.setName(folder.getName()); + dataContent.usingSite(siteModel).usingResource(cm).createContent(file); + dataContent.usingSite(siteModel).usingResource(cm).createContent(file2); - nodesBuilder.folder("source") - .file("suzuki") - .file("suzuki-2"); - - //just for showing available properties - System.out.println(String.format("Source Folder Full Name [%s ] withd ID: %s",nodesBuilder.getNode("source").getName(), nodesBuilder.getNode("source").getId())); - System.out.println(String.format("Source File Full Name [%s ] withd ID: %s",nodesBuilder.getNode("suzuki").getName(), nodesBuilder.getNode("suzuki").getId())); - } + } @Test public void searchCreatedData() throws Exception { RestNodeModelsCollection nodes = restClient.authenticateUser(userModel) .withCoreAPI() - .usingParams("term=suzuki") + .usingParams("term=cars") .usingQueries() .findNodes(); restClient.assertStatusCodeIs(HttpStatus.OK); + nodes.assertThat().entriesListIsNotEmpty(); + + nodes = restClient.authenticateUser(userModel) + .withCoreAPI() + .usingParams("term=fox") + .usingQueries() + .findNodes(); - nodes.assertThat() - .entriesListIsNotEmpty() - .and().entriesListCountIs(2); + restClient.assertStatusCodeIs(HttpStatus.OK); + nodes.assertThat().entriesListIsNotEmpty(); } } From 53e86c068364447dc0f83a6471f14d6234394c6f Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Tue, 21 Feb 2017 14:31:21 +0200 Subject: [PATCH 1057/1491] fix imports, added Search group --- e2e-test/java/org/alfresco/rest/search/SearchTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/SearchTest.java b/e2e-test/java/org/alfresco/rest/search/SearchTest.java index f97e5b665..e6275c33a 100644 --- a/e2e-test/java/org/alfresco/rest/search/SearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/SearchTest.java @@ -21,12 +21,12 @@ package org.alfresco.rest.search; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestNodeModelsCollection; 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.FileModel; import org.alfresco.utility.model.FileType; import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; @@ -71,7 +71,7 @@ public class SearchTest extends RestTest } - @Test + @Test(groups={TestGroup.SEARCH}) public void searchCreatedData() throws Exception { RestNodeModelsCollection nodes = restClient.authenticateUser(userModel) From cbabcf7ac6cff0a196b72529e5f30cb1b2bdb53e Mon Sep 17 00:00:00 2001 From: Michael Suzuki Date: Tue, 21 Feb 2017 13:34:03 +0000 Subject: [PATCH 1058/1491] compacting the calls --- .../org/alfresco/rest/search/SearchTest.java | 27 +++++++++---------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/SearchTest.java b/e2e-test/java/org/alfresco/rest/search/SearchTest.java index e6275c33a..0808d6d97 100644 --- a/e2e-test/java/org/alfresco/rest/search/SearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/SearchTest.java @@ -68,27 +68,24 @@ public class SearchTest extends RestTest cm.setName(folder.getName()); dataContent.usingSite(siteModel).usingResource(cm).createContent(file); dataContent.usingSite(siteModel).usingResource(cm).createContent(file2); - - } + } + + protected RestNodeModelsCollection query(String term) throws Exception + { + return restClient.authenticateUser(userModel) + .withCoreAPI() + .usingParams("term=" + term) + .usingQueries() + .findNodes(); + } @Test(groups={TestGroup.SEARCH}) public void searchCreatedData() throws Exception { - RestNodeModelsCollection nodes = restClient.authenticateUser(userModel) - .withCoreAPI() - .usingParams("term=cars") - .usingQueries() - .findNodes(); - + RestNodeModelsCollection nodes = query("cars"); restClient.assertStatusCodeIs(HttpStatus.OK); nodes.assertThat().entriesListIsNotEmpty(); - - nodes = restClient.authenticateUser(userModel) - .withCoreAPI() - .usingParams("term=fox") - .usingQueries() - .findNodes(); - + nodes = query("fox"); restClient.assertStatusCodeIs(HttpStatus.OK); nodes.assertThat().entriesListIsNotEmpty(); } From 34d3614d18dcd04fe4bbcba452593579d4c25d80 Mon Sep 17 00:00:00 2001 From: Michael Suzuki Date: Tue, 21 Feb 2017 13:38:18 +0000 Subject: [PATCH 1059/1491] Beef up test and refactored layout stuff --- .../rest/search/AbstractSearchTest.java | 79 +++++++++++++++++++ .../org/alfresco/rest/search/SearchTest.java | 59 +++----------- 2 files changed, 88 insertions(+), 50 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java diff --git a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java new file mode 100644 index 000000000..5b79f8808 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2017 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.rest.search; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestNodeModelsCollection; +import org.alfresco.rest.model.builder.NodesBuilder; +import org.alfresco.utility.model.ContentModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FileType; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; +import org.testng.annotations.BeforeClass; + +/** + * Abstract Search test. + * @author Michael Suzuki + * + */ +public class AbstractSearchTest extends RestTest +{ + protected static final String SEARCH_DATA_SAMPLE_FOLDER = "folder"; + UserModel userModel, adminUserModel; + SiteModel siteModel; + UserModel searchedUser; + NodesBuilder nodesBuilder; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + /* + * Create the following file structure for preconditions : + * |- folder + * |-- pangram.txt + * |-- cars.pdf + */ + nodesBuilder = restClient.authenticateUser(userModel).withCoreAPI().usingNode(ContentModel.my()).defineNodes(); + FolderModel folder = new FolderModel(SEARCH_DATA_SAMPLE_FOLDER); + dataContent.usingSite(siteModel).createFolder(folder); + //Create files + FileModel file = new FileModel("pangram.txt", FileType.TEXT_PLAIN, "The qucik brown fox jumps over the lazy dog"); + FileModel file2 = new FileModel("cars.txt", FileType.TEXT_PLAIN, "The landrover discovery is not a sports car"); + ContentModel cm = new ContentModel(); + cm.setCmisLocation(folder.getCmisLocation()); + cm.setName(folder.getName()); + dataContent.usingSite(siteModel).usingResource(cm).createContent(file); + dataContent.usingSite(siteModel).usingResource(cm).createContent(file2); + } + + protected RestNodeModelsCollection query(String term) throws Exception + { + return restClient.authenticateUser(userModel) + .withCoreAPI() + .usingParams("term=" + term) + .usingQueries() + .findNodes(); + } + +} diff --git a/e2e-test/java/org/alfresco/rest/search/SearchTest.java b/e2e-test/java/org/alfresco/rest/search/SearchTest.java index 0808d6d97..036ee5c97 100644 --- a/e2e-test/java/org/alfresco/rest/search/SearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/SearchTest.java @@ -18,18 +18,9 @@ */ package org.alfresco.rest.search; -import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestNodeModelsCollection; -import org.alfresco.rest.model.builder.NodesBuilder; -import org.alfresco.utility.model.ContentModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FileType; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; /** @@ -37,48 +28,8 @@ import org.testng.annotations.Test; * @author Michael Suzuki * */ -public class SearchTest extends RestTest +public class SearchTest extends AbstractSearchTest { - private static final String SEARCH_DATA_SAMPLE_FOLDER = "folder"; - UserModel userModel, adminUserModel; - SiteModel siteModel; - UserModel searchedUser; - NodesBuilder nodesBuilder; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - /* - * Create the following file structure for preconditions : - * |- folder - * |-- pangram.txt - * |-- cars.pdf - */ - nodesBuilder = restClient.authenticateUser(userModel).withCoreAPI().usingNode(ContentModel.my()).defineNodes(); - FolderModel folder = new FolderModel(SEARCH_DATA_SAMPLE_FOLDER); - dataContent.usingSite(siteModel).createFolder(folder); - //Create files - FileModel file = new FileModel("pangram.txt", FileType.TEXT_PLAIN, "The qucik brown fox jumps over the lazy dog"); - FileModel file2 = new FileModel("cars.txt", FileType.TEXT_PLAIN, "The landrover discovery is not a sports car"); - ContentModel cm = new ContentModel(); - cm.setCmisLocation(folder.getCmisLocation()); - cm.setName(folder.getName()); - dataContent.usingSite(siteModel).usingResource(cm).createContent(file); - dataContent.usingSite(siteModel).usingResource(cm).createContent(file2); - } - - protected RestNodeModelsCollection query(String term) throws Exception - { - return restClient.authenticateUser(userModel) - .withCoreAPI() - .usingParams("term=" + term) - .usingQueries() - .findNodes(); - } - @Test(groups={TestGroup.SEARCH}) public void searchCreatedData() throws Exception { @@ -89,4 +40,12 @@ public class SearchTest extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); nodes.assertThat().entriesListIsNotEmpty(); } + + @Test(groups={TestGroup.SEARCH}) + public void searchNonIndexedData() throws Exception + { + RestNodeModelsCollection nodes = query("yeti"); + restClient.assertStatusCodeIs(HttpStatus.OK); + nodes.assertThat().entriesListIsEmpty(); + } } From ab8447755da72076c2ab70ba77041fa263a2bd1e Mon Sep 17 00:00:00 2001 From: mionescu Date: Tue, 21 Feb 2017 16:24:04 +0200 Subject: [PATCH 1060/1491] update - formatting, adding some missing tests --- .../favorites/GetFavoriteSiteCoreTests.java | 6 ++-- .../favorites/GetFavoriteSiteFullTests.java | 14 ++++++++ .../sites/members/AddSiteMemberCoreTests.java | 4 +-- .../processes/GetProcessCoreTests.java | 15 ++++++-- .../tasks/UpdateTaskCoreTestsBulk2.java | 3 +- .../variables/AddTaskVariablesFullTests.java | 36 +++++++++++++++++++ .../DeleteTaskVariableCoreTests.java | 6 ++-- .../DeleteTaskVariableFullTests.java | 8 ++--- 8 files changed, 75 insertions(+), 17 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSiteCoreTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSiteCoreTests.java index 8a4f01629..5e8d78deb 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSiteCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSiteCoreTests.java @@ -51,10 +51,12 @@ public class GetFavoriteSiteCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify User fails to get specific favorite site of admin with Rest API and response is 403") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify User fails to get specific favorite site of admin with Rest API and response is 403") public void userFailsToGetFavoriteSiteOfAdmin() throws Exception { restClient.authenticateUser(userModel).withCoreAPI().usingUser(dataUser.getAdminUser()).getFavoriteSite(site1); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } + } + } diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSiteFullTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSiteFullTests.java index e352afc64..b6ff75384 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSiteFullTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSiteFullTests.java @@ -1,11 +1,13 @@ package org.alfresco.rest.favorites; +import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestSiteModel; import org.alfresco.rest.model.RestSiteModelsCollection; import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; @@ -126,6 +128,18 @@ public class GetFavoriteSiteFullTests extends RestTest .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, userModel.getUsername(), folder.getName())); } + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify invalid request returns status 404 when providing file name instead of site id") + public void getFavoriteSiteUsingFile() throws Exception + { + FileModel file = dataContent.usingSite(site1).createContent(DocumentType.TEXT_PLAIN); + SiteModel siteFolder = new SiteModel(file.getName()); + restSiteModel = restClient.authenticateUser(userModel).withCoreAPI().usingMe().getFavoriteSite(siteFolder); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, userModel.getUsername(), file.getName())); + } + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify request returns status 200 when using valid parameters") diff --git a/e2e-test/java/org/alfresco/rest/sites/members/AddSiteMemberCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/members/AddSiteMemberCoreTests.java index 8b291c0fc..1f1357b21 100644 --- a/e2e-test/java/org/alfresco/rest/sites/members/AddSiteMemberCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/members/AddSiteMemberCoreTests.java @@ -40,10 +40,8 @@ public class AddSiteMemberCoreTests extends RestTest usersWithRolesToPrivateSite = dataUser.addUsersWithRolesToSite(privateSiteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer,UserRole.SiteContributor); addMembersJson = "{\"role\":\"%s\",\"id\":\"%s\"}, {\"role\":\"%s\",\"id\":\"%s\"}"; - } + } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Verify that manager can add another user as manager to a public site and gets status code CREATED (201)") diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessCoreTests.java index ead91ed39..7dbfd4c1d 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessCoreTests.java @@ -36,7 +36,12 @@ public class GetProcessCoreTests extends RestTest newProcess.setId(processId); restClient.authenticateUser(dataUser.getAdminUser()) .withWorkflowAPI().usingProcess(newProcess).getProcess(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, processId)); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, processId)) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES}, executionType = ExecutionType.REGRESSION, @@ -57,7 +62,9 @@ public class GetProcessCoreTests extends RestTest RestProcessModel networkProcess1 = restClient.authenticateUser(adminTenantUser1).withWorkflowAPI().addProcess("activitiReview", tenantUser1, false, CMISUtil.Priority.High); restClient.authenticateUser(tenantUser2).withWorkflowAPI().usingProcess(networkProcess1).getProcess(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError().containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, @@ -90,7 +97,9 @@ public class GetProcessCoreTests extends RestTest RestProcessModel networkProcess1 = restClient.authenticateUser(adminTenantUser1).withWorkflowAPI().addProcess("activitiReview", tenantUser1, false, CMISUtil.Priority.High); restClient.authenticateUser(adminUser).withWorkflowAPI().usingProcess(networkProcess1).getProcess(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError().containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTestsBulk2.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTestsBulk2.java index bce915178..469e4b5b9 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTestsBulk2.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTestsBulk2.java @@ -66,8 +66,7 @@ public class UpdateTaskCoreTestsBulk2 extends RestTest restClient.authenticateUser(owner) .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restClient.assertStatusCodeIs(HttpStatus.OK); - + restClient.assertStatusCodeIs(HttpStatus.OK); } @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesFullTests.java index 4fb3fc284..495cd72b7 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesFullTests.java @@ -3,6 +3,8 @@ package org.alfresco.rest.workflow.tasks.variables; import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.exception.EmptyJsonResponseException; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.rest.model.RestTaskModel; @@ -15,6 +17,7 @@ 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; @@ -29,6 +32,7 @@ public class AddTaskVariablesFullTests extends RestTest private TaskModel taskModel; private RestVariableModel restVariablemodel, variableModel, variableModel1; private RestVariableModelsCollection restVariableCollection; + private String taskId; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception @@ -39,6 +43,8 @@ public class AddTaskVariablesFullTests extends RestTest siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + + taskId = taskModel.getId(); } @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) @@ -102,6 +108,36 @@ public class AddTaskVariablesFullTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE); } + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Update task variable with invalid variable name") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + public void createTaskVariableWithInvalidVariableName() throws Exception + { + restClient.authenticateUser(adminUser).withWorkflowAPI(); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{\"scope\": \"local\",\"names\": \"varName\",\"value\": \"test\"," + + "\"type\": \"d:text\"}", "tasks/{taskId}/variables", taskId); + restClient.processModel(RestVariableModel.class, request); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsSummary(String.format(RestErrorModel.NO_CONTENT,"Unrecognized field " + "\"names\"")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Create task variable with invalid name") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + public void createTaskVariableWithInvalidName() throws Exception + { + restClient.authenticateUser(adminUser).withWorkflowAPI(); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{\"scope\": \"local\",\"name\": ',\"value\": \"test\"," + + "\"type\": \"d:text\"}", "tasks/{taskId}/variables", taskId); + restClient.processModel(RestVariableModel.class, request); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsSummary(String.format(RestErrorModel.NO_CONTENT,"Unexpected character " + "('''")); + } + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Create task variable with empty name") diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/DeleteTaskVariableCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/DeleteTaskVariableCoreTests.java index 192e0ca4f..6b475c6db 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/DeleteTaskVariableCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/DeleteTaskVariableCoreTests.java @@ -38,7 +38,7 @@ public class DeleteTaskVariableCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Delete task variable with any user") @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void deleteTaskVarialbleByAnyUser() throws Exception + public void deleteTaskVariableByAnyUser() throws Exception { restClient.authenticateUser(userModel); RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); @@ -97,7 +97,7 @@ public class DeleteTaskVariableCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Delete task variable by non assigned user") @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void deleteTaskVarialbleByNonAssignedUser() throws Exception + public void deleteTaskVariableByNonAssignedUser() throws Exception { UserModel nonAssigned = dataUser.createRandomTestUser(); RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); @@ -112,7 +112,7 @@ public class DeleteTaskVariableCoreTests extends RestTest description = "Delete task variable by inexistent user") @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void deleteTaskVarialbleByInexistentUser() throws Exception + public void deleteTaskVariableByInexistentUser() throws Exception { RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/DeleteTaskVariableFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/DeleteTaskVariableFullTests.java index c93ffb765..e405a0278 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/DeleteTaskVariableFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/DeleteTaskVariableFullTests.java @@ -40,7 +40,7 @@ public class DeleteTaskVariableFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Delete task variable twice") @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void deleteTaskVarialbleTwice() throws Exception + public void deleteTaskVariableTwice() throws Exception { restClient.authenticateUser(userModel); RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); @@ -62,7 +62,7 @@ public class DeleteTaskVariableFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Delete task variable with empty variable name") @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void deleteTaskEmptyVarialbleName() throws Exception + public void deleteTaskEmptyVariableName() throws Exception { restClient.authenticateUser(userModel); RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); @@ -80,7 +80,7 @@ public class DeleteTaskVariableFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Delete task variable with empty variable scope") @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void deleteTaskEmptyVarialbleScope() throws Exception + public void deleteTaskEmptyVariableScope() throws Exception { restClient.authenticateUser(userModel); RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); @@ -97,7 +97,7 @@ public class DeleteTaskVariableFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Delete task variable with invalid variable name") @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void deleteTaskInvalidVarialbleName() throws Exception + public void deleteTaskInvalidVariableName() throws Exception { restClient.authenticateUser(userModel); RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); From 1afba48ee876c30bc67cbe29a2fa35987e16f369 Mon Sep 17 00:00:00 2001 From: mionescu Date: Wed, 22 Feb 2017 09:14:54 +0200 Subject: [PATCH 1061/1491] test- updated: anyUserGetsProcessDefinition --- .../GetProcessDefinitionSanityTests.java | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java index d8efb06af..36d8ef872 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java @@ -16,7 +16,7 @@ import org.testng.annotations.Test; public class GetProcessDefinitionSanityTests extends RestTest { private UserModel testUser; - private RestProcessDefinitionModel randomProcessDefinition, returnedProcessDefinition; + private RestProcessDefinitionModel randomProcessDefinition, firstRandomProcessDefinition, returnedProcessDefinition; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception @@ -24,6 +24,7 @@ public class GetProcessDefinitionSanityTests extends RestTest testUser = dataUser.createRandomTestUser(); restClient.authenticateUser(dataUser.getAdminUser()); randomProcessDefinition = restClient.withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry().onModel(); + firstRandomProcessDefinition = restClient.withWorkflowAPI().getAllProcessDefinitions().getProcessDefinitionByDeploymentId("1"); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, @@ -44,18 +45,18 @@ public class GetProcessDefinitionSanityTests extends RestTest public void anyUserGetsProcessDefinition() throws Exception { restClient.authenticateUser(testUser); - returnedProcessDefinition = restClient.withWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinition(); + returnedProcessDefinition = restClient.withWorkflowAPI().usingProcessDefinitions(firstRandomProcessDefinition).getProcessDefinition(); restClient.assertStatusCodeIs(HttpStatus.OK); - returnedProcessDefinition.assertThat() - .field("name").is(randomProcessDefinition.getName()).and() - .field("deploymentId").is(randomProcessDefinition.getDeploymentId()).and() - .field("description").is(randomProcessDefinition.getDescription()).and() - .field("id").is(randomProcessDefinition.getId()).and() - .field("startFormResourceKey").is(randomProcessDefinition.getStartFormResourceKey()).and() - .field("category").is(randomProcessDefinition.getCategory()).and() - .field("title").is(randomProcessDefinition.getTitle()).and() - .field("version").is(randomProcessDefinition.getVersion()).and() - .field("graphicNotationDefined").is(randomProcessDefinition.getGraphicNotationDefined()).and() - .field("key").is(randomProcessDefinition.getKey()); + returnedProcessDefinition.assertThat() + .field("name").is(firstRandomProcessDefinition.getName()).and() + .field("deploymentId").is(firstRandomProcessDefinition.getDeploymentId()).and() + .field("description").is(firstRandomProcessDefinition.getDescription()).and() + .field("id").is(firstRandomProcessDefinition.getId()).and() + .field("startFormResourceKey").is(firstRandomProcessDefinition.getStartFormResourceKey()).and() + .field("category").is(firstRandomProcessDefinition.getCategory()).and() + .field("title").is(firstRandomProcessDefinition.getTitle()).and() + .field("version").is(firstRandomProcessDefinition.getVersion()).and() + .field("graphicNotationDefined").is(firstRandomProcessDefinition.getGraphicNotationDefined()).and() + .field("key").is(firstRandomProcessDefinition.getKey()); } } From 3ea3ecedb6ecfc4fd586fc6e0fad7fd0c37155ae Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 22 Feb 2017 10:41:54 +0200 Subject: [PATCH 1062/1491] increased maxItems --- e2e-test/java/org/alfresco/rest/tags/GetTagsCoreTests.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/tags/GetTagsCoreTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagsCoreTests.java index 92f006e77..54c119230 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetTagsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetTagsCoreTests.java @@ -70,7 +70,7 @@ public class GetTagsCoreTests extends RestTest public void fileTagIsRetrieved() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); - returnedCollection = restClient.withParams("maxItems=500").withCoreAPI().getTags(); + returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); restClient.assertStatusCodeIs(HttpStatus.OK); returnedCollection.assertThat().entriesListIsNotEmpty() .and().entriesListContains("tag", tagValue.toLowerCase()); @@ -82,7 +82,7 @@ public class GetTagsCoreTests extends RestTest public void folderTagIsRetrieved() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); - returnedCollection = restClient.withParams("maxItems=500").withCoreAPI().getTags(); + returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); restClient.assertStatusCodeIs(HttpStatus.OK); returnedCollection.assertThat().entriesListIsNotEmpty() .and().entriesListContains("tag", tagValue2.toLowerCase()); From 54faf6d5e44aa7d0118f199f4a5c2c72130086d1 Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 22 Feb 2017 11:15:18 +0200 Subject: [PATCH 1063/1491] increased maxItems --- .../java/org/alfresco/rest/tags/GetTagsFullTests.java | 2 +- .../org/alfresco/rest/tags/GetTagsSanityTests.java | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/tags/GetTagsFullTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagsFullTests.java index c6dace4c7..470bddcec 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetTagsFullTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetTagsFullTests.java @@ -141,7 +141,7 @@ public class GetTagsFullTests extends RestTest restClient.withCoreAPI().usingResource(document).deleteTag(deletedTag); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - returnedCollection = restClient.withParams("maxItems=5000").withCoreAPI().getTags(); + returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); returnedCollection.assertThat().entriesListIsNotEmpty() .and().entriesListDoesNotContain("tag", removedTag.toLowerCase()); } diff --git a/e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java index f11250c23..40234c816 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java @@ -53,7 +53,7 @@ public class GetTagsSanityTests extends RestTest public void getTagsWithManagerRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - RestTagModelsCollection returnedCollection = restClient.withParams("maxItems=500").withCoreAPI().getTags(); + RestTagModelsCollection returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); restClient.assertStatusCodeIs(HttpStatus.OK); returnedCollection.assertThat().entriesListIsNotEmpty() .and().entriesListContains("tag", tagValue.toLowerCase()) @@ -65,7 +65,7 @@ public class GetTagsSanityTests extends RestTest public void getTagsWithCollaboratorRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - RestTagModelsCollection returnedCollection = restClient.withParams("maxItems=500").withCoreAPI().getTags(); + RestTagModelsCollection returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); restClient.assertStatusCodeIs(HttpStatus.OK); returnedCollection.assertThat().entriesListIsNotEmpty() .and().entriesListContains("tag", tagValue.toLowerCase()) @@ -77,7 +77,7 @@ public class GetTagsSanityTests extends RestTest public void getTagsWithContributorRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - RestTagModelsCollection returnedCollection = restClient.withParams("maxItems=500").withCoreAPI().getTags(); + RestTagModelsCollection returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); restClient.assertStatusCodeIs(HttpStatus.OK); returnedCollection.assertThat().entriesListIsNotEmpty() .and().entriesListContains("tag", tagValue.toLowerCase()) @@ -89,7 +89,7 @@ public class GetTagsSanityTests extends RestTest public void getTagsWithConsumerRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - RestTagModelsCollection returnedCollection = restClient.withParams("maxItems=500").withCoreAPI().getTags(); + RestTagModelsCollection returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); restClient.assertStatusCodeIs(HttpStatus.OK); returnedCollection.assertThat().entriesListIsNotEmpty() .and().entriesListContains("tag", tagValue.toLowerCase()) @@ -101,7 +101,7 @@ public class GetTagsSanityTests extends RestTest public void getTagsWithAdminUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); - RestTagModelsCollection returnedCollection = restClient.withParams("maxItems=500").withCoreAPI().getTags(); + RestTagModelsCollection returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); restClient.assertStatusCodeIs(HttpStatus.OK); returnedCollection.assertThat().entriesListIsNotEmpty() .and().entriesListContains("tag", tagValue.toLowerCase()) From 169d6aa5bd5af01e038ec81123a0356155de1ea6 Mon Sep 17 00:00:00 2001 From: mionescu Date: Wed, 22 Feb 2017 11:21:14 +0200 Subject: [PATCH 1064/1491] test- fixed issues --- .../org/alfresco/rest/comments/DeleteCommentFullTests.java | 4 ++-- .../workflow/processes/items/AddProcessItemCoreTests.java | 4 ++-- .../workflow/processes/items/DeleteProcessItemFullTests.java | 3 ++- .../processes/variables/AddProcessVariablesFullTests.java | 4 ++-- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentFullTests.java b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentFullTests.java index 9f3037f1d..9ca7d540a 100644 --- a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentFullTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentFullTests.java @@ -157,9 +157,9 @@ public class DeleteCommentFullTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(file.getNodeRef() + " was not found"); } - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS}, executionType = ExecutionType.REGRESSION, description = "Verify deleteComment from node with invalid network id returns status code 401") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.COMMENTS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) public void deleteCommentWithInvalidNetworkId() throws Exception { FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemCoreTests.java index fa7dd9e38..c154beb07 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemCoreTests.java @@ -165,7 +165,7 @@ public class AddProcessItemCoreTests extends RestTest .field("createdBy").is(adminUser.getUsername()).and() .field("modifiedAt").isNotEmpty().and() .field("name").is(document.getName()).and() - .field("modifiedBy").is(userWhoStartsProcess.getUsername()).and() + .field("modifiedBy").is(adminUser.getUsername()).and() .field("id").isNotEmpty().and() .field("mimeType").is(document.getFileType().mimeType); processItems.getEntries().get(1).onModel().assertThat() @@ -174,7 +174,7 @@ public class AddProcessItemCoreTests extends RestTest .field("createdBy").is(adminUser.getUsername()).and() .field("modifiedAt").isNotEmpty().and() .field("name").is(document2.getName()).and() - .field("modifiedBy").is(userWhoStartsProcess.getUsername()).and() + .field("modifiedBy").is(adminUser.getUsername()).and() .field("id").isNotEmpty().and() .field("mimeType").is(document2.getFileType().mimeType); } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/items/DeleteProcessItemFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/items/DeleteProcessItemFullTests.java index 556e0822f..1adafa20a 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/items/DeleteProcessItemFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/items/DeleteProcessItemFullTests.java @@ -42,7 +42,8 @@ public class DeleteProcessItemFullTests extends RestTest @BeforeMethod(alwaysRun = true) public void createProcess() throws Exception { - TaskModel task = dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); + TaskModel task = dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document) + .createNewTaskAndAssignTo(assignee); processModel = new ProcessModel(); processModel.setId(task.getProcessId()); processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().usingProcess(processModel).getProcess(); diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesFullTests.java index 0409d1a1a..30056bb6f 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesFullTests.java @@ -410,7 +410,7 @@ public class AddProcessVariablesFullTests extends RestTest .createNewTaskAndAssignTo(tenantUserAssignee); variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processModel = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee, false, Priority.Normal); processVariable = restClient.authenticateUser(adminTenantUser2).withWorkflowAPI().usingProcess(processModel) .addProcessVariable(variableModel); @@ -441,7 +441,7 @@ public class AddProcessVariablesFullTests extends RestTest variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); variableModel1 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processModel = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee, false, Priority.Normal); restClient.authenticateUser(adminTenantUser2).withWorkflowAPI().usingProcess(processModel) .addProcessVariables(variableModel, variableModel1); From ccab6f6593a43e7ec8627093eddd2ada820b1637 Mon Sep 17 00:00:00 2001 From: Michael Suzuki Date: Wed, 22 Feb 2017 10:12:43 +0000 Subject: [PATCH 1065/1491] Implement intial search test based on search api endpoint --- .../rest/search/AbstractSearchTest.java | 27 ++++++++++++------- .../org/alfresco/rest/search/SearchTest.java | 10 +++---- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java index 5b79f8808..0d4674af8 100644 --- a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java @@ -19,7 +19,6 @@ package org.alfresco.rest.search; import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestNodeModelsCollection; import org.alfresco.rest.model.builder.NodesBuilder; import org.alfresco.utility.model.ContentModel; import org.alfresco.utility.model.FileModel; @@ -30,7 +29,11 @@ import org.alfresco.utility.model.UserModel; import org.testng.annotations.BeforeClass; /** - * Abstract Search test. + * Abstract Search test class that contains useful methods + * such as: + *
    + *
  • Preparing the data to index. + *
  • Preparing search requests. * @author Michael Suzuki * */ @@ -66,14 +69,20 @@ public class AbstractSearchTest extends RestTest dataContent.usingSite(siteModel).usingResource(cm).createContent(file); dataContent.usingSite(siteModel).usingResource(cm).createContent(file2); } - - protected RestNodeModelsCollection query(String term) throws Exception + /** + * Helper method which create an http post request to Search API end point. + * @param term String search term + * @return {@link SearchResponse} response. + * @throws Exception if error + */ + protected SearchResponse query(String term) throws Exception { - return restClient.authenticateUser(userModel) - .withCoreAPI() - .usingParams("term=" + term) - .usingQueries() - .findNodes(); + RestRequestQueryModel queryReq = new RestRequestQueryModel(); + + queryReq.setLanguage("afts"); + queryReq.setQuery(term); + SearchRequest query = new SearchRequest(queryReq); + return restClient.authenticateUser(dataUser.getAdminUser()).withSearchAPI().search(query); } } diff --git a/e2e-test/java/org/alfresco/rest/search/SearchTest.java b/e2e-test/java/org/alfresco/rest/search/SearchTest.java index 036ee5c97..a0bcb4610 100644 --- a/e2e-test/java/org/alfresco/rest/search/SearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/SearchTest.java @@ -18,7 +18,6 @@ */ package org.alfresco.rest.search; -import org.alfresco.rest.model.RestNodeModelsCollection; import org.alfresco.utility.model.TestGroup; import org.springframework.http.HttpStatus; import org.testng.annotations.Test; @@ -30,21 +29,22 @@ import org.testng.annotations.Test; */ public class SearchTest extends AbstractSearchTest { - @Test(groups={TestGroup.SEARCH}) + @Test(groups={TestGroup.SEARCH, TestGroup.REST_API}) public void searchCreatedData() throws Exception { - RestNodeModelsCollection nodes = query("cars"); + SearchResponse nodes = query("ipsum"); restClient.assertStatusCodeIs(HttpStatus.OK); nodes.assertThat().entriesListIsNotEmpty(); + nodes = query("fox"); restClient.assertStatusCodeIs(HttpStatus.OK); nodes.assertThat().entriesListIsNotEmpty(); } - @Test(groups={TestGroup.SEARCH}) + @Test(groups={TestGroup.SEARCH,TestGroup.REST_API}) public void searchNonIndexedData() throws Exception { - RestNodeModelsCollection nodes = query("yeti"); + SearchResponse nodes = query("yeti"); restClient.assertStatusCodeIs(HttpStatus.OK); nodes.assertThat().entriesListIsEmpty(); } From be9986b3dcbe220797fb8f887d869263f036441c Mon Sep 17 00:00:00 2001 From: mionescu Date: Wed, 22 Feb 2017 12:32:40 +0200 Subject: [PATCH 1066/1491] test- fixed network tests --- .../tasks/items/AddTaskItemFullTests.java | 69 +++++++++++-------- .../tasks/items/AddTaskItemSanityTests.java | 62 +++++++++-------- .../tasks/items/GetTaskItemsSanityTests.java | 30 ++++---- .../variables/AddTaskVariablesFullTests.java | 1 - .../UpdateTaskVariableSanityTests.java | 29 ++++---- 5 files changed, 102 insertions(+), 89 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemFullTests.java index 93a804e9e..c929d2652 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemFullTests.java @@ -1,11 +1,14 @@ package org.alfresco.rest.workflow.tasks.items; import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.dataprep.CMISUtil.Priority; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestItemModel; import org.alfresco.rest.model.RestItemModelsCollection; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestTaskModel; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TaskModel; @@ -19,7 +22,7 @@ import org.testng.annotations.Test; public class AddTaskItemFullTests extends RestTest { - private UserModel userModel, adminUser,userWhoStartsTask, assigneeUser, adminTenantUser, tenantUser, tenantUserAssignee, adminTenantUser2; + private UserModel userModel, adminUser,userWhoStartsTask, assigneeUser; private SiteModel siteModel; private FileModel fileModel, fileModel1, document1, document2,document3; private TaskModel taskModel; @@ -92,23 +95,26 @@ public class AddTaskItemFullTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL, TestGroup.NETWORKS }) public void addTaskItemByAdminInOtherNetwork() throws Exception { - adminTenantUser = UserModel.getAdminTenantUser(); - adminTenantUser2 = UserModel.getAdminTenantUser(); - - restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser); - tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); - restClient.usingTenant().createTenant(adminTenantUser2); - siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); - dataWorkflow.usingUser(tenantUser).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(tenantUserAssignee); - - document1 = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(DocumentType.XML); - restClient.authenticateUser(adminTenantUser2).withWorkflowAPI().usingTask(taskModel).addTaskItem(document1); + UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); + UserModel adminTenantUser2 = UserModel.getAdminTenantUser(); + + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser1); + restClient.usingTenant().createTenant(adminTenantUser2); + + UserModel tenantUser1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenant"); + UserModel tenantUserAssignee1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenantAssignee"); + + siteModel = dataSite.usingUser(adminTenantUser1).createPublicRandomSite(); + fileModel = dataContent.usingUser(adminTenantUser1).usingSite(siteModel).createContent(DocumentType.XML); + RestProcessModel addedProcess = restClient.authenticateUser(tenantUser1).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee1, false, Priority.Normal); + RestTaskModel addedTask = restClient.withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess); + restClient.authenticateUser(adminTenantUser2).withWorkflowAPI().usingTask(addedTask).addTaskItem(fileModel); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .containsErrorKey(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT) - .stackTraceIs(RestErrorModel.STACKTRACE); + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .stackTraceIs(RestErrorModel.STACKTRACE); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, @@ -116,24 +122,27 @@ public class AddTaskItemFullTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL, TestGroup.NETWORKS }) public void addMultipleTaskItemByAdminInOtherNetwork() throws Exception { - adminTenantUser = UserModel.getAdminTenantUser(); - adminTenantUser2 = UserModel.getAdminTenantUser(); - - restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser); - tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); - restClient.usingTenant().createTenant(adminTenantUser2); - siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); - dataWorkflow.usingUser(tenantUser).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(tenantUserAssignee); - - document1 = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(DocumentType.XML); - document2 = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(DocumentType.XML); + UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); + UserModel adminTenantUser2 = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminTenantUser2).withWorkflowAPI().usingTask(taskModel).addTaskItems(document1, document2); - + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser1); + restClient.usingTenant().createTenant(adminTenantUser2); + + UserModel tenantUser1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenant"); + UserModel tenantUserAssignee1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenantAssignee"); + + siteModel = dataSite.usingUser(adminTenantUser1).createPublicRandomSite(); + document1 = dataContent.usingUser(adminTenantUser1).usingSite(siteModel).createContent(DocumentType.XML); + document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + + RestProcessModel addedProcess = restClient.authenticateUser(tenantUser1).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee1, false, Priority.Normal); + RestTaskModel addedTask = restClient.withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess); + restClient.authenticateUser(adminTenantUser2).withWorkflowAPI().usingTask(addedTask).addTaskItems(document1, document2); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .containsErrorKey(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT) + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) .stackTraceIs(RestErrorModel.STACKTRACE);; } diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemSanityTests.java index 7b271c3ac..6e5b66bc7 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemSanityTests.java @@ -1,10 +1,13 @@ package org.alfresco.rest.workflow.tasks.items; import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.dataprep.CMISUtil.Priority; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestItemModel; import org.alfresco.rest.model.RestItemModelsCollection; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestTaskModel; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TaskModel; @@ -20,7 +23,7 @@ import org.testng.annotations.Test; public class AddTaskItemSanityTests extends RestTest { - private UserModel userModel, userWhoStartsTask, assigneeUser, adminTenantUser, tenantUser, tenantUserAssignee;; + private UserModel userModel, userWhoStartsTask, assigneeUser; private SiteModel siteModel; private FileModel fileModel, document2, document3, document4; private TaskModel taskModel; @@ -162,21 +165,20 @@ public class AddTaskItemSanityTests extends RestTest description = "Add task item using admin user from same network") public void addTaskItemByAdminSameNetwork() throws JsonToModelConversionException, Exception { - UserModel adminuser = dataUser.getAdminUser(); - restClient.authenticateUser(adminuser); + UserModel adminUser = dataUser.getAdminUser(); + restClient.authenticateUser(adminUser); + UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser1); + + UserModel tenantUser1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenant"); + UserModel tenantUserAssignee1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenantAssignee"); - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.usingTenant().createTenant(adminTenantUser); - - tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); - - siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); - dataWorkflow.usingUser(tenantUser).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(tenantUserAssignee); - - document4 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - - taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document4); + siteModel = dataSite.usingUser(adminTenantUser1).createPublicRandomSite(); + document4 = dataContent.usingUser(adminTenantUser1).usingSite(siteModel).createContent(DocumentType.XML); + RestProcessModel addedProcess = restClient.authenticateUser(tenantUser1).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee1, false, Priority.Normal); + RestTaskModel addedTask = restClient.authenticateUser(adminTenantUser1).withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess); + + taskItem = restClient.withWorkflowAPI().usingTask(addedTask).addTaskItem(document4); restClient.assertStatusCodeIs(HttpStatus.CREATED); taskItem.assertThat().field("createdAt").is(taskItem.getCreatedAt()) .and().field("size").is(taskItem.getSize()) @@ -193,22 +195,22 @@ public class AddTaskItemSanityTests extends RestTest description = "Add task item using admin user from same network") public void addMultipleTaskItemByAdminSameNetwork() throws JsonToModelConversionException, Exception { - UserModel adminuser = dataUser.getAdminUser(); - restClient.authenticateUser(adminuser); + UserModel adminUser = dataUser.getAdminUser(); + restClient.authenticateUser(adminUser); + UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser1); + + UserModel tenantUser1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenant"); + UserModel tenantUserAssignee1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenantAssignee"); - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.usingTenant().createTenant(adminTenantUser); - - tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); - - siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); - dataWorkflow.usingUser(tenantUser).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(tenantUserAssignee); - - document4 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - document3 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - - taskItems = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItems(document4,document3); + siteModel = dataSite.usingUser(adminTenantUser1).createPublicRandomSite(); + document3 = dataContent.usingUser(adminTenantUser1).usingSite(siteModel).createContent(DocumentType.XML); + document4 = dataContent.usingUser(adminTenantUser1).usingUser(adminTenantUser1).usingSite(siteModel).createContent(DocumentType.XML); + RestProcessModel addedProcess = restClient.authenticateUser(tenantUser1).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee1, false, Priority.Normal); + RestTaskModel addedTask = restClient.authenticateUser(adminTenantUser1).withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess); + + taskItems = restClient.authenticateUser(adminTenantUser1).withWorkflowAPI().usingTask(addedTask) + .addTaskItems(document4,document3); restClient.assertStatusCodeIs(HttpStatus.CREATED); taskItems.getEntries().get(0).onModel() diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/items/GetTaskItemsSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/items/GetTaskItemsSanityTests.java index c8990f431..88fd21c02 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/items/GetTaskItemsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/items/GetTaskItemsSanityTests.java @@ -1,9 +1,12 @@ package org.alfresco.rest.workflow.tasks.items; import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.dataprep.CMISUtil.Priority; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestItemModel; import org.alfresco.rest.model.RestItemModelsCollection; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestTaskModel; import org.alfresco.utility.Utility; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; @@ -78,22 +81,21 @@ public class GetTaskItemsSanityTests extends RestTest @Test(groups = { TestGroup.NETWORKS,TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY}) public void getTaskItemsByAdminInSameNetwork() throws Exception { - UserModel adminuser = dataUser.getAdminUser(); - restClient.authenticateUser(adminuser); + UserModel adminUser = dataUser.getAdminUser(); + restClient.authenticateUser(adminUser); + UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser1); + + UserModel tenantUser1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenant"); + UserModel tenantUserAssignee1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenantAssignee"); - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.usingTenant().createTenant(adminTenantUser); - - tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); - - siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); - dataWorkflow.usingUser(tenantUser).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(tenantUserAssignee); - - document1 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document1); + siteModel = dataSite.usingUser(adminTenantUser1).createPublicRandomSite(); + document1 = dataContent.usingUser(adminTenantUser1).usingSite(siteModel).createContent(DocumentType.XML); + RestProcessModel addedProcess = restClient.authenticateUser(tenantUser1).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee1, false, Priority.Normal); + RestTaskModel addedTask = restClient.authenticateUser(adminTenantUser1).withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess); + taskItem = restClient.withWorkflowAPI().usingTask(addedTask).addTaskItem(document1); - itemModels = restClient.withWorkflowAPI().usingTask(taskModel).getTaskItems(); + itemModels = restClient.withWorkflowAPI().usingTask(addedTask).getTaskItems(); restClient.assertStatusCodeIs(HttpStatus.OK); itemModels.assertThat() .entriesListIsNotEmpty().and() diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesFullTests.java index 495cd72b7..bd22c1893 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesFullTests.java @@ -232,7 +232,6 @@ public class AddTaskVariablesFullTests extends RestTest .addProcess("activitiReview", tenantUser1, false, CMISUtil.Priority.High); RestTaskModel task = restClient.authenticateUser(adminTenantUser1) .withWorkflowAPI().usingProcess(networkProcess1).getProcessTasks().getOneRandomEntry(); - restClient.authenticateUser(adminTenantUser1); RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); restVariablemodel = restClient.authenticateUser(adminTenantUser2).withWorkflowAPI() .usingTask(task.onModel()) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableSanityTests.java index 4456d4f6e..51246cde3 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableSanityTests.java @@ -1,7 +1,10 @@ package org.alfresco.rest.workflow.tasks.variables; +import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestTaskModel; import org.alfresco.rest.model.RestVariableModel; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; @@ -81,23 +84,21 @@ public class UpdateTaskVariableSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY, TestGroup.NETWORKS}) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, - description = "Update existing task variable by admin in the same network") - + description = "Update existing task variable by admin in the same network") public void updateTaskVariableByAdminInSameNetwork() throws Exception { - restClient.authenticateUser(adminUser); - - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.usingTenant().createTenant(adminTenantUser); - - tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); - - siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); - tenantTask = dataWorkflow.usingUser(tenantUser).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(tenantUserAssignee); + UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); + restClient.authenticateUser(dataUser.getAdminUser()).usingTenant().createTenant(adminTenantUser1); + UserModel tenantUser1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenant1"); + RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser1).withWorkflowAPI() + .addProcess("activitiReview", tenantUser1, false, CMISUtil.Priority.High); + RestTaskModel task = restClient.authenticateUser(adminTenantUser1) + .withWorkflowAPI().usingProcess(networkProcess1).getProcessTasks().getOneRandomEntry(); + variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - taskVariable = restClient.withWorkflowAPI().usingTask(tenantTask).updateTaskVariable(variableModel); + taskVariable = restClient.withWorkflowAPI().usingTask(task.onModel()) + .updateTaskVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.OK); taskVariable.assertThat().field("scope").is(taskVariable.getScope()) .and().field("name").is(taskVariable.getName()) @@ -105,7 +106,7 @@ public class UpdateTaskVariableSanityTests extends RestTest .and().field("value").is(taskVariable.getValue()); variableModel.setValue("updatedValue"); - taskVariable = restClient.withWorkflowAPI().usingTask(taskModel).updateTaskVariable(variableModel).and().field("value").is("updatedValue"); + taskVariable = restClient.withWorkflowAPI().usingTask(task.onModel()).updateTaskVariable(variableModel).and().field("value").is("updatedValue"); restClient.assertStatusCodeIs(HttpStatus.OK); } } \ No newline at end of file From 1bd859e8235a54839eaee8d9a1e9e03c87fbd62a Mon Sep 17 00:00:00 2001 From: mionescu Date: Wed, 22 Feb 2017 14:40:02 +0200 Subject: [PATCH 1067/1491] test- fixed issues --- .../rest/tags/nodes/DeleteTagFullTests.java | 3 +- .../items/AddProcessItemCoreTests.java | 35 ++++++++----------- .../items/DeleteProcessItemFullTests.java | 13 ++----- 3 files changed, 20 insertions(+), 31 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/tags/nodes/DeleteTagFullTests.java b/e2e-test/java/org/alfresco/rest/tags/nodes/DeleteTagFullTests.java index beab76ae1..b6c627bd5 100644 --- a/e2e-test/java/org/alfresco/rest/tags/nodes/DeleteTagFullTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/nodes/DeleteTagFullTests.java @@ -59,8 +59,9 @@ public class DeleteTagFullTests extends RestTest public void collaboratorCanDeleteLongTag() throws JsonToModelConversionException, Exception { String longTag = RandomStringUtils.randomAlphanumeric(10000); + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - tagReturnedModel = restClient.authenticateUser(adminUserModel) + RestTagModel tagReturnedModel = restClient.authenticateUser(adminUserModel) .withCoreAPI().usingResource(document).addTag(longTag); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemCoreTests.java index c154beb07..5a4f65317 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemCoreTests.java @@ -121,22 +121,19 @@ public class AddProcessItemCoreTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE, TestGroup.NETWORKS }) public void addProcessItemByAdminSameNetwork() throws Exception { - restClient.authenticateUser(adminUser); adminTenantUser = UserModel.getAdminTenantUser(); - restClient.usingTenant().createTenant(adminTenantUser); - + restClient.authenticateUser(dataUser.getAdminUser()).usingTenant().createTenant(adminTenantUser); tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); + processModel = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee, false, Priority.Normal); siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); - dataWorkflow.usingUser(tenantUser).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(tenantUserAssignee); - - processModel = restClient.withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); + document = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + processItem = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().usingProcess(processModel).addProcessItem(document); restClient.assertStatusCodeIs(HttpStatus.CREATED); - processItem.assertThat().field("createdAt").isNotEmpty().and().field("size").is("19").and().field("createdBy").is(adminUser.getUsername()).and() - .field("modifiedAt").isNotEmpty().and().field("name").is(document.getName()).and().field("modifiedBy").is(adminUser.getUsername()).and() + processItem.assertThat().field("createdAt").isNotEmpty().and().field("size").is("19").and().field("createdBy").is(adminTenantUser.getUsername().toLowerCase()).and() + .field("modifiedAt").isNotEmpty().and().field("name").is(document.getName()).and().field("modifiedBy").is(adminTenantUser.getUsername().toLowerCase()).and() .field("id").isNotEmpty().and().field("mimeType").is(document.getFileType().mimeType); } @@ -145,36 +142,34 @@ public class AddProcessItemCoreTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE, TestGroup.NETWORKS }) public void addMultipleProcessItemsByAdminSameNetwork() throws Exception { - restClient.authenticateUser(adminUser); adminTenantUser = UserModel.getAdminTenantUser(); - restClient.usingTenant().createTenant(adminTenantUser); - + restClient.authenticateUser(dataUser.getAdminUser()).usingTenant().createTenant(adminTenantUser); tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); + processModel = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee, false, Priority.Normal); siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); - dataWorkflow.usingUser(tenantUser).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(tenantUserAssignee); - - processModel = restClient.withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - processItems = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItems(document, document2); + document = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + document2 = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + processItems = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().usingProcess(processModel).addProcessItems(document, document2); restClient.assertStatusCodeIs(HttpStatus.CREATED); processItems.getEntries().get(0).onModel().assertThat() .field("createdAt").isNotEmpty().and() .field("size").is("19").and() - .field("createdBy").is(adminUser.getUsername()).and() + .field("createdBy").is(adminTenantUser.getUsername().toLowerCase()).and() .field("modifiedAt").isNotEmpty().and() .field("name").is(document.getName()).and() - .field("modifiedBy").is(adminUser.getUsername()).and() + .field("modifiedBy").is(adminTenantUser.getUsername().toLowerCase()).and() .field("id").isNotEmpty().and() .field("mimeType").is(document.getFileType().mimeType); processItems.getEntries().get(1).onModel().assertThat() .field("createdAt").isNotEmpty().and() .field("size").is("19").and() - .field("createdBy").is(adminUser.getUsername()).and() + .field("createdBy").is(adminTenantUser.getUsername().toLowerCase()).and() .field("modifiedAt").isNotEmpty().and() .field("name").is(document2.getName()).and() - .field("modifiedBy").is(adminUser.getUsername()).and() + .field("modifiedBy").is(adminTenantUser.getUsername().toLowerCase()).and() .field("id").isNotEmpty().and() .field("mimeType").is(document2.getFileType().mimeType); } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/items/DeleteProcessItemFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/items/DeleteProcessItemFullTests.java index 1adafa20a..fa11a9b50 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/items/DeleteProcessItemFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/items/DeleteProcessItemFullTests.java @@ -1,7 +1,7 @@ package org.alfresco.rest.workflow.processes.items; -import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.dataprep.CMISUtil.Priority; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.EmptyRestModelCollectionException; import org.alfresco.rest.model.RestErrorModel; @@ -10,7 +10,6 @@ import org.alfresco.rest.model.RestItemModelsCollection; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.ProcessModel; import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TaskModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; @@ -42,11 +41,8 @@ public class DeleteProcessItemFullTests extends RestTest @BeforeMethod(alwaysRun = true) public void createProcess() throws Exception { - TaskModel task = dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document) - .createNewTaskAndAssignTo(assignee); - processModel = new ProcessModel(); - processModel.setId(task.getProcessId()); - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().usingProcess(processModel).getProcess(); + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI() + .addProcess("activitiAdhoc", assignee, false, Priority.Normal); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, @@ -199,9 +195,6 @@ public class DeleteProcessItemFullTests extends RestTest expectedExceptions = EmptyRestModelCollectionException.class) public void deleteProcessItemsForProcessWithoutItems() throws Exception { - processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI() - .addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.Normal); - items = restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems(); restClient.assertStatusCodeIs(HttpStatus.OK); items.assertThat().entriesListIsEmpty(); From 31cd2a19c6a8d6a450d62f928e19b38ee59cbb8e Mon Sep 17 00:00:00 2001 From: mionescu Date: Wed, 22 Feb 2017 16:45:34 +0200 Subject: [PATCH 1068/1491] test- fixed bamboo issues --- .../items/DeleteProcessItemFullTests.java | 52 +++++++++++-------- 1 file changed, 29 insertions(+), 23 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/items/DeleteProcessItemFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/items/DeleteProcessItemFullTests.java index fa11a9b50..f67e9e9a2 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/items/DeleteProcessItemFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/items/DeleteProcessItemFullTests.java @@ -1,5 +1,6 @@ package org.alfresco.rest.workflow.processes.items; +import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.CMISUtil.Priority; import org.alfresco.rest.RestTest; @@ -16,7 +17,6 @@ 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.BeforeMethod; import org.testng.annotations.Test; public class DeleteProcessItemFullTests extends RestTest @@ -38,18 +38,13 @@ public class DeleteProcessItemFullTests extends RestTest document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); } - @BeforeMethod(alwaysRun = true) - public void createProcess() throws Exception - { - processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI() - .addProcess("activitiAdhoc", assignee, false, Priority.Normal); - } - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Try to delete existing process item using empty processId") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) public void deleteProcessItemUsingEmptyProcessId() throws Exception { + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI() + .addProcess("activitiAdhoc", assignee, false, Priority.Normal); document2 = dataContent.usingAdmin().usingSite(siteModel).createContent(DocumentType.MSPOWERPOINT); processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document2); restClient.assertStatusCodeIs(HttpStatus.CREATED); @@ -69,6 +64,8 @@ public class DeleteProcessItemFullTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) public void createUpdateDeleteProcessItem() throws Exception { + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI() + .addProcess("activitiAdhoc", assignee, false, Priority.Normal); document2 = dataContent.usingAdmin().usingSite(siteModel).createContent(DocumentType.MSPOWERPOINT); processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document2); restClient.assertStatusCodeIs(HttpStatus.CREATED); @@ -86,7 +83,7 @@ public class DeleteProcessItemFullTests extends RestTest description = "Delete process item using any user.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) public void deleteProcessItemByAnyUser() throws Exception - { + { anotherUser = dataUser.createRandomTestUser(); document2 = dataContent.usingAdmin().usingSite(siteModel).createContent(DocumentType.HTML); @@ -108,6 +105,9 @@ public class DeleteProcessItemFullTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) public void deleteProcessItemWithAdmin() throws Exception { + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI() + .addProcess("activitiAdhoc", assignee, false, Priority.Normal); + document2 = dataContent.usingAdmin().usingSite(siteModel).createContent(DocumentType.HTML); processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document2); restClient.assertStatusCodeIs(HttpStatus.CREATED); @@ -124,6 +124,9 @@ public class DeleteProcessItemFullTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) public void deleteProcessItemByUserInvolvedInTheProcess() throws Exception { + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI() + .addProcess("activitiAdhoc", assignee, false, Priority.Normal); + processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); restClient.assertStatusCodeIs(HttpStatus.CREATED); @@ -139,6 +142,8 @@ public class DeleteProcessItemFullTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) public void deleteProcessItemByUserThatStartedTheProcess() throws Exception { + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI() + .addProcess("activitiAdhoc", assignee, false, Priority.Normal); processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); restClient.assertStatusCodeIs(HttpStatus.CREATED); @@ -154,6 +159,8 @@ public class DeleteProcessItemFullTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) public void deleteProcessItemsForDeletedProcess() throws Exception { + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI() + .addProcess("activitiAdhoc", assignee, false, Priority.Normal); processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); restClient.assertStatusCodeIs(HttpStatus.CREATED); @@ -169,12 +176,13 @@ public class DeleteProcessItemFullTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE); } - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Delete process item by inexistent user.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) public void deleteProcessItemByInexistentUser() throws Exception { + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI() + .addProcess("activitiAdhoc", assignee, false, Priority.Normal); processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); restClient.assertStatusCodeIs(HttpStatus.CREATED); @@ -195,6 +203,9 @@ public class DeleteProcessItemFullTests extends RestTest expectedExceptions = EmptyRestModelCollectionException.class) public void deleteProcessItemsForProcessWithoutItems() throws Exception { + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI() + .addProcess("activitiAdhoc", assignee, false, Priority.Normal); + items = restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems(); restClient.assertStatusCodeIs(HttpStatus.OK); items.assertThat().entriesListIsEmpty(); @@ -208,17 +219,14 @@ public class DeleteProcessItemFullTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL, TestGroup.NETWORKS }) public void deleteProcessItemByAdminSameNetwork() throws Exception { - restClient.authenticateUser(adminUser); adminTenantUser = UserModel.getAdminTenantUser(); - restClient.usingTenant().createTenant(adminTenantUser); - + restClient.authenticateUser(dataUser.getAdminUser()).usingTenant().createTenant(adminTenantUser); tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); + processModel = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee, false, CMISUtil.Priority.Normal); siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); - dataWorkflow.usingUser(tenantUser).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(tenantUserAssignee); - - processModel = restClient.withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + document = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); restClient.assertStatusCodeIs(HttpStatus.CREATED); @@ -236,17 +244,15 @@ public class DeleteProcessItemFullTests extends RestTest { adminTenantUser = UserModel.getAdminTenantUser(); restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser); - tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); adminTenantUser2 = UserModel.getAdminTenantUser(); - restClient.usingTenant().createTenant(adminTenantUser2); - + restClient.authenticateUser(dataUser.getAdminUser()).usingTenant().createTenant(adminTenantUser2); + + processModel = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee, false, CMISUtil.Priority.Normal); siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); - dataWorkflow.usingUser(tenantUser).usingSite(siteModel).usingResource(document) - .createNewTaskAndAssignTo(tenantUserAssignee); - - processModel = restClient.withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + document = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); restClient.assertStatusCodeIs(HttpStatus.CREATED); From 991c827ecb1a1eb54b4f831eeda283347177f006 Mon Sep 17 00:00:00 2001 From: mionescu Date: Wed, 22 Feb 2017 16:48:08 +0200 Subject: [PATCH 1069/1491] updates --- .../java/org/alfresco/rest/tags/nodes/DeleteTagFullTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/tags/nodes/DeleteTagFullTests.java b/e2e-test/java/org/alfresco/rest/tags/nodes/DeleteTagFullTests.java index b6c627bd5..cac339cb0 100644 --- a/e2e-test/java/org/alfresco/rest/tags/nodes/DeleteTagFullTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/nodes/DeleteTagFullTests.java @@ -58,7 +58,7 @@ public class DeleteTagFullTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) public void collaboratorCanDeleteLongTag() throws JsonToModelConversionException, Exception { - String longTag = RandomStringUtils.randomAlphanumeric(10000); + String longTag = RandomStringUtils.randomAlphanumeric(3000); document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); RestTagModel tagReturnedModel = restClient.authenticateUser(adminUserModel) From 565e794d809bcaff52358cdb09a8050150ce55d1 Mon Sep 17 00:00:00 2001 From: mionescu Date: Wed, 22 Feb 2017 17:10:03 +0200 Subject: [PATCH 1070/1491] updates --- .../workflow/tasks/GetTasksFullTests.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksFullTests.java index c51564b97..1ef5d7aaf 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksFullTests.java @@ -24,7 +24,7 @@ public class GetTasksFullTests extends RestTest UserModel candidateUser; FileModel fileModel; UserModel assigneeUser; - RestTaskModelsCollection taskModels; + RestTaskModelsCollection taskModels, taskCollections; @BeforeClass(alwaysRun=true) public void dataPreparation() throws Exception @@ -42,16 +42,16 @@ public class GetTasksFullTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) public void skipCountParameterApplied() throws Exception { - RestTaskModelsCollection taskCollections = restClient.authenticateUser(dataUser.getAdminUser()).withWorkflowAPI().getTasks(); + taskCollections = restClient.authenticateUser(dataUser.getAdminUser()).withWorkflowAPI().getTasks(); restClient.assertStatusCodeIs(HttpStatus.OK); RestTaskModel firstTask = taskCollections.getEntries().get(0).onModel(); RestTaskModel secondTask = taskCollections.getEntries().get(1).onModel(); taskModels = restClient.withParams("skipCount=2").withWorkflowAPI().getTasks(); restClient.assertStatusCodeIs(HttpStatus.OK); - taskModels.assertThat().entriesListIsNotEmpty() - .assertThat().entriesListDoesNotContain("id", firstTask.getId()) - .assertThat().entriesListDoesNotContain("id", secondTask.getId()); + taskModels.assertThat().entriesListDoesNotContain("id", firstTask.getId()) + .assertThat().entriesListDoesNotContain("id", secondTask.getId()); + taskModels.assertThat().paginationField("skipCount").is("2"); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, @@ -59,16 +59,17 @@ public class GetTasksFullTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) public void maxItemsParameterApplied() throws Exception { - RestTaskModelsCollection taskCollections = restClient.authenticateUser(dataUser.getAdminUser()).withWorkflowAPI().getTasks(); + taskCollections = restClient.authenticateUser(dataUser.getAdminUser()).withWorkflowAPI().getTasks(); restClient.assertStatusCodeIs(HttpStatus.OK); RestTaskModel firstTask = taskCollections.getEntries().get(0).onModel(); RestTaskModel secondTask = taskCollections.getEntries().get(1).onModel(); taskModels = restClient.withParams("maxItems=2").withWorkflowAPI().getTasks(); restClient.assertStatusCodeIs(HttpStatus.OK); - taskModels.assertThat().entriesListIsNotEmpty() - .assertThat().entriesListContains("id", firstTask.getId()) - .assertThat().entriesListContains("id", secondTask.getId()); + + taskModels.assertThat().entriesListContains("id", firstTask.getId()) + .assertThat().entriesListContains("id", secondTask.getId()); + taskModels.assertThat().paginationField("maxItems").is("2"); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, From d29ff1a13033daea725e3cd75c514cabdf24826b Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Wed, 22 Feb 2017 17:32:02 +0200 Subject: [PATCH 1071/1491] Modified GetSites full tests --- .../rest/sites/GetSitesFullTests.java | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSitesFullTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSitesFullTests.java index cd787aa03..e7bf2cc9f 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSitesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSitesFullTests.java @@ -19,6 +19,7 @@ import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; import org.springframework.social.alfresco.api.entities.Site.Visibility; import org.testng.annotations.AfterClass; +import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -29,6 +30,7 @@ public class GetSitesFullTests extends RestTest private RestSiteModelsCollection sites; private String name; private UserModel adminUser; + private SiteModel secondPublicSite, thirdPublicSite; @BeforeClass(alwaysRun=true) public void dataPreparation() throws Exception @@ -166,8 +168,10 @@ public class GetSitesFullTests extends RestTest description= "Verify if User gets sites ordered by id ascending and status code is 200") public void getSitesOrderedByTitleASCAndVisibilityASC() throws Exception { - SiteModel secondPublicSite = dataSite.usingAdmin().createSite( - new SiteModel(Visibility.PUBLIC, "guid", name+"A", name+"A", name)); + secondPublicSite = dataSite.usingAdmin().createSite( + new SiteModel(Visibility.PUBLIC, "guid", name+"A", name+"A", name)); + thirdPublicSite = dataSite.usingAdmin().createSite( + new SiteModel(Visibility.PUBLIC, "guid", name+"B", name+"B", name)); int totalItems = restClient.authenticateUser(regularUser).withCoreAPI().getSites().getPagination().getTotalItems(); sites = restClient.authenticateUser(regularUser).withParams(String.format("maxItems=%s&orderBy=description ASC&orderBy=title ASC", totalItems)) @@ -175,10 +179,13 @@ public class GetSitesFullTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); sites.assertThat().entriesListIsNotEmpty(); List sitesList = sites.getEntries(); - sitesList.get(sitesList.size()-1).onModel().assertThat().field("title").is(secondPublicSite.getTitle()); - sitesList.get(sitesList.size()-2).onModel().assertThat().field("title").is(publicSite.getTitle()); + sitesList.get(sitesList.size()-1).onModel().assertThat().field("title").is(thirdPublicSite.getTitle()); + sitesList.get(sitesList.size()-2).onModel().assertThat().field("title").is(secondPublicSite.getTitle()); dataSite.deleteSite(secondPublicSite); + secondPublicSite = null; + dataSite.deleteSite(thirdPublicSite); + thirdPublicSite = null; } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL } ) @@ -271,6 +278,15 @@ public class GetSitesFullTests extends RestTest } } + @AfterMethod(alwaysRun=true) + public void deleteSites() throws Exception + { + if(secondPublicSite != null) + dataSite.deleteSite(secondPublicSite); + if(thirdPublicSite != null) + dataSite.deleteSite(thirdPublicSite); + } + @AfterClass(alwaysRun=true) public void tearDown() throws Exception { From efd6b613f64b38c7c999db834b3d9d78835a2757 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Thu, 23 Feb 2017 09:16:49 +0200 Subject: [PATCH 1072/1491] Modified maxItemsParameterApplied --- .../org/alfresco/rest/workflow/tasks/GetTasksFullTests.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksFullTests.java index 1ef5d7aaf..6e1aa1b2b 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksFullTests.java @@ -59,7 +59,8 @@ public class GetTasksFullTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) public void maxItemsParameterApplied() throws Exception { - taskCollections = restClient.authenticateUser(dataUser.getAdminUser()).withWorkflowAPI().getTasks(); + taskCollections = restClient.authenticateUser(dataUser.getAdminUser()).withParams("orderBy=name ASC").withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); RestTaskModel firstTask = taskCollections.getEntries().get(0).onModel(); RestTaskModel secondTask = taskCollections.getEntries().get(1).onModel(); From d3b178c128ef1aaf6402fba897e94d7d80c42705 Mon Sep 17 00:00:00 2001 From: mionescu Date: Thu, 23 Feb 2017 09:26:45 +0200 Subject: [PATCH 1073/1491] updated test: userCollaboratorCanDeleteLongTag --- .../org/alfresco/rest/tags/nodes/DeleteTagFullTests.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/tags/nodes/DeleteTagFullTests.java b/e2e-test/java/org/alfresco/rest/tags/nodes/DeleteTagFullTests.java index cac339cb0..219d46619 100644 --- a/e2e-test/java/org/alfresco/rest/tags/nodes/DeleteTagFullTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/nodes/DeleteTagFullTests.java @@ -56,12 +56,11 @@ public class DeleteTagFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user can delete long tag.") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) - public void collaboratorCanDeleteLongTag() throws JsonToModelConversionException, Exception + public void userCollaboratorCanDeleteLongTag() throws JsonToModelConversionException, Exception { - String longTag = RandomStringUtils.randomAlphanumeric(3000); - document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - - RestTagModel tagReturnedModel = restClient.authenticateUser(adminUserModel) + String longTag = RandomStringUtils.randomAlphanumeric(5000); + + tagReturnedModel = restClient.authenticateUser(adminUserModel) .withCoreAPI().usingResource(document).addTag(longTag); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) From 383c162dcdef2261557b3f08ab71c46a96641bef Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Thu, 23 Feb 2017 09:27:11 +0200 Subject: [PATCH 1074/1491] Modified skipCountParameterApplied --- .../org/alfresco/rest/workflow/tasks/GetTasksFullTests.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksFullTests.java index 6e1aa1b2b..056715d2c 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksFullTests.java @@ -42,12 +42,12 @@ public class GetTasksFullTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) public void skipCountParameterApplied() throws Exception { - taskCollections = restClient.authenticateUser(dataUser.getAdminUser()).withWorkflowAPI().getTasks(); + taskCollections = restClient.authenticateUser(dataUser.getAdminUser()).withParams("orderBy=name ASC").withWorkflowAPI().getTasks(); restClient.assertStatusCodeIs(HttpStatus.OK); RestTaskModel firstTask = taskCollections.getEntries().get(0).onModel(); RestTaskModel secondTask = taskCollections.getEntries().get(1).onModel(); - taskModels = restClient.withParams("skipCount=2").withWorkflowAPI().getTasks(); + taskModels = restClient.withParams("skipCount=2&orderBy=name ASC").withWorkflowAPI().getTasks(); restClient.assertStatusCodeIs(HttpStatus.OK); taskModels.assertThat().entriesListDoesNotContain("id", firstTask.getId()) .assertThat().entriesListDoesNotContain("id", secondTask.getId()); @@ -65,7 +65,7 @@ public class GetTasksFullTests extends RestTest RestTaskModel firstTask = taskCollections.getEntries().get(0).onModel(); RestTaskModel secondTask = taskCollections.getEntries().get(1).onModel(); - taskModels = restClient.withParams("maxItems=2").withWorkflowAPI().getTasks(); + taskModels = restClient.withParams("maxItems=2&orderBy=name ASC").withWorkflowAPI().getTasks(); restClient.assertStatusCodeIs(HttpStatus.OK); taskModels.assertThat().entriesListContains("id", firstTask.getId()) From 652a570ba17a501845bd78b574545473772ea920 Mon Sep 17 00:00:00 2001 From: mionescu Date: Thu, 23 Feb 2017 10:46:48 +0200 Subject: [PATCH 1075/1491] test - updated: skipCountParameterApplied and maxItemsParameterApplied --- .../rest/workflow/tasks/GetTasksFullTests.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksFullTests.java index 056715d2c..59d8573ee 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksFullTests.java @@ -42,12 +42,12 @@ public class GetTasksFullTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) public void skipCountParameterApplied() throws Exception { - taskCollections = restClient.authenticateUser(dataUser.getAdminUser()).withParams("orderBy=name ASC").withWorkflowAPI().getTasks(); + taskCollections = restClient.authenticateUser(dataUser.getAdminUser()).withParams("orderBy=description ASC").withWorkflowAPI().getTasks(); restClient.assertStatusCodeIs(HttpStatus.OK); RestTaskModel firstTask = taskCollections.getEntries().get(0).onModel(); RestTaskModel secondTask = taskCollections.getEntries().get(1).onModel(); - taskModels = restClient.withParams("skipCount=2&orderBy=name ASC").withWorkflowAPI().getTasks(); + taskModels = restClient.withParams("orderBy=description ASC&skipCount=2").withWorkflowAPI().getTasks(); restClient.assertStatusCodeIs(HttpStatus.OK); taskModels.assertThat().entriesListDoesNotContain("id", firstTask.getId()) .assertThat().entriesListDoesNotContain("id", secondTask.getId()); @@ -59,18 +59,18 @@ public class GetTasksFullTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) public void maxItemsParameterApplied() throws Exception { - taskCollections = restClient.authenticateUser(dataUser.getAdminUser()).withParams("orderBy=name ASC").withWorkflowAPI().getTasks(); - + taskCollections = restClient.authenticateUser(dataUser.getAdminUser()).withParams("orderBy=description ASC").withWorkflowAPI().getTasks(); restClient.assertStatusCodeIs(HttpStatus.OK); RestTaskModel firstTask = taskCollections.getEntries().get(0).onModel(); RestTaskModel secondTask = taskCollections.getEntries().get(1).onModel(); - taskModels = restClient.withParams("maxItems=2&orderBy=name ASC").withWorkflowAPI().getTasks(); + taskModels = restClient.withParams("orderBy=description ASC&maxItems=2").withWorkflowAPI().getTasks(); restClient.assertStatusCodeIs(HttpStatus.OK); taskModels.assertThat().entriesListContains("id", firstTask.getId()) .assertThat().entriesListContains("id", secondTask.getId()); taskModels.assertThat().paginationField("maxItems").is("2"); + taskModels.assertThat().paginationField("count").is("2"); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, From a8da3f9f91308a60d55bc941b38cd8cd7af2e744 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Thu, 23 Feb 2017 10:48:11 +0200 Subject: [PATCH 1076/1491] Modified GetSitesFullTests --- e2e-test/java/org/alfresco/rest/sites/GetSitesFullTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSitesFullTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSitesFullTests.java index e7bf2cc9f..cd189fac9 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSitesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSitesFullTests.java @@ -174,7 +174,7 @@ public class GetSitesFullTests extends RestTest new SiteModel(Visibility.PUBLIC, "guid", name+"B", name+"B", name)); int totalItems = restClient.authenticateUser(regularUser).withCoreAPI().getSites().getPagination().getTotalItems(); - sites = restClient.authenticateUser(regularUser).withParams(String.format("maxItems=%s&orderBy=description ASC&orderBy=title ASC", totalItems)) + sites = restClient.authenticateUser(regularUser).withParams(String.format("maxItems=%s&orderBy=title ASC&orderBy=description ASC", totalItems)) .withCoreAPI().getSites(); restClient.assertStatusCodeIs(HttpStatus.OK); sites.assertThat().entriesListIsNotEmpty(); From 13f163682c25b1adac8049379596e68ff618578f Mon Sep 17 00:00:00 2001 From: mionescu Date: Thu, 23 Feb 2017 11:02:54 +0200 Subject: [PATCH 1077/1491] test- fixed issue: checkTotalItemsAndHasMoreItemsParameters --- .../java/org/alfresco/rest/ratings/GetRatingsFullTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/ratings/GetRatingsFullTests.java b/e2e-test/java/org/alfresco/rest/ratings/GetRatingsFullTests.java index 1fdbd80ba..7b124ffeb 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/GetRatingsFullTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/GetRatingsFullTests.java @@ -74,7 +74,7 @@ public class GetRatingsFullTests extends RestTest ratingsModel = restClient.authenticateUser(adminUserModel).withParams("maxItems=1").withCoreAPI().usingResource(document).getRatings(); ratingsModel.assertThat().entriesListCountIs(1); ratingsModel.getPagination().assertThat().field("hasMoreItems").is("true") - .and().field("totalItems").is("2"); + .and().field("count").is("1").and().field("maxItems").is("1"); } @Bug(id = "REPO-1831") From d70c032cf8dfad957f180f586b9dcd1e07c69fbf Mon Sep 17 00:00:00 2001 From: mionescu Date: Thu, 23 Feb 2017 12:01:49 +0200 Subject: [PATCH 1078/1491] test- userCollaboratorCanDeleteLongTag --- .../java/org/alfresco/rest/tags/nodes/DeleteTagFullTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/tags/nodes/DeleteTagFullTests.java b/e2e-test/java/org/alfresco/rest/tags/nodes/DeleteTagFullTests.java index 219d46619..c9f387641 100644 --- a/e2e-test/java/org/alfresco/rest/tags/nodes/DeleteTagFullTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/nodes/DeleteTagFullTests.java @@ -58,7 +58,7 @@ public class DeleteTagFullTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) public void userCollaboratorCanDeleteLongTag() throws JsonToModelConversionException, Exception { - String longTag = RandomStringUtils.randomAlphanumeric(5000); + String longTag = RandomStringUtils.randomAlphanumeric(800); tagReturnedModel = restClient.authenticateUser(adminUserModel) .withCoreAPI().usingResource(document).addTag(longTag); From 691d27869f3432aaa12829a5f28f58c652e2b80b Mon Sep 17 00:00:00 2001 From: Michael Suzuki Date: Thu, 23 Feb 2017 10:56:45 +0000 Subject: [PATCH 1079/1491] Refactored to use objects that represent the search response --- e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java | 2 +- e2e-test/java/org/alfresco/rest/search/SearchTest.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java index 0d4674af8..67df467c3 100644 --- a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java @@ -61,7 +61,7 @@ public class AbstractSearchTest extends RestTest FolderModel folder = new FolderModel(SEARCH_DATA_SAMPLE_FOLDER); dataContent.usingSite(siteModel).createFolder(folder); //Create files - FileModel file = new FileModel("pangram.txt", FileType.TEXT_PLAIN, "The qucik brown fox jumps over the lazy dog"); + FileModel file = new FileModel("pangram.txt", FileType.TEXT_PLAIN, "The quick brown fox jumps over the lazy dog"); FileModel file2 = new FileModel("cars.txt", FileType.TEXT_PLAIN, "The landrover discovery is not a sports car"); ContentModel cm = new ContentModel(); cm.setCmisLocation(folder.getCmisLocation()); diff --git a/e2e-test/java/org/alfresco/rest/search/SearchTest.java b/e2e-test/java/org/alfresco/rest/search/SearchTest.java index a0bcb4610..51f8b25f0 100644 --- a/e2e-test/java/org/alfresco/rest/search/SearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/SearchTest.java @@ -32,7 +32,7 @@ public class SearchTest extends AbstractSearchTest @Test(groups={TestGroup.SEARCH, TestGroup.REST_API}) public void searchCreatedData() throws Exception { - SearchResponse nodes = query("ipsum"); + SearchResponse nodes = query("car"); restClient.assertStatusCodeIs(HttpStatus.OK); nodes.assertThat().entriesListIsNotEmpty(); From 69aa70a5fc75e2ea38c4be0f1fa48baeda3ac637 Mon Sep 17 00:00:00 2001 From: Michael Suzuki Date: Thu, 23 Feb 2017 20:14:19 +0000 Subject: [PATCH 1080/1491] Harden the basic test --- .../java/org/alfresco/rest/search/SearchTest.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/SearchTest.java b/e2e-test/java/org/alfresco/rest/search/SearchTest.java index 51f8b25f0..3c785a718 100644 --- a/e2e-test/java/org/alfresco/rest/search/SearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/SearchTest.java @@ -20,6 +20,7 @@ package org.alfresco.rest.search; import org.alfresco.utility.model.TestGroup; import org.springframework.http.HttpStatus; +import org.testng.Assert; import org.testng.annotations.Test; /** @@ -32,13 +33,22 @@ public class SearchTest extends AbstractSearchTest @Test(groups={TestGroup.SEARCH, TestGroup.REST_API}) public void searchCreatedData() throws Exception { - SearchResponse nodes = query("car"); + SearchResponse nodes = query("fox"); restClient.assertStatusCodeIs(HttpStatus.OK); nodes.assertThat().entriesListIsNotEmpty(); - nodes = query("fox"); + SearchNodeModel entity = nodes.getEntryByIndex(0); + Assert.assertEquals(entity.getSearch().getScore(), 1); + entity.assertThat().field("name").contains("pangram.txt"); + + nodes = query("car"); restClient.assertStatusCodeIs(HttpStatus.OK); + entity = nodes.getEntryByIndex(0); + nodes.assertThat().entriesListIsNotEmpty(); + Assert.assertEquals(entity.getSearch().getScore(), 1); + entity.assertThat().field("search").contains("score"); + entity.assertThat().field("name").contains("cars.txt"); } @Test(groups={TestGroup.SEARCH,TestGroup.REST_API}) From 47419fb565285171cc0e5dd349d3bd29324729c3 Mon Sep 17 00:00:00 2001 From: mionescu Date: Fri, 24 Feb 2017 10:50:35 +0200 Subject: [PATCH 1081/1491] test- fixed Bamboo issues: getProcessTasksWithValidSkipCount, getProcessTasksWithValidMaxItems --- .../processes/tasks/GetProcessTasksFullTests.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/tasks/GetProcessTasksFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/tasks/GetProcessTasksFullTests.java index f0b2c24a6..11f820f71 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/tasks/GetProcessTasksFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/tasks/GetProcessTasksFullTests.java @@ -27,9 +27,9 @@ public class GetProcessTasksFullTests extends RestTest { adminUser = dataUser.getAdminUser(); userWhoStartsProcess = dataUser.createRandomTestUser(); - assignee1 = dataUser.createRandomTestUser(); - assignee2 = dataUser.createRandomTestUser(); - assignee3 = dataUser.createRandomTestUser(); + assignee1 = dataUser.createRandomTestUser("A_1"); + assignee2 = dataUser.createRandomTestUser("B_2"); + assignee3 = dataUser.createRandomTestUser("C_3"); publicSite = dataSite.usingUser(userWhoStartsProcess).createPublicRandomSite(); document = dataContent.usingSite(publicSite).createContent(CMISUtil.DocumentType.TEXT_PLAIN); processWithSingleTask = dataWorkflow.usingUser(userWhoStartsProcess).usingSite(publicSite).usingResource(document) @@ -56,7 +56,7 @@ public class GetProcessTasksFullTests extends RestTest public void getProcessTasksWithValidSkipCount() throws Exception { processTasks = restClient.authenticateUser(userWhoStartsProcess) - .withParams("skipCount=2").withWorkflowAPI() + .withParams("orderBy=assignee ASC&skipCount=2").withWorkflowAPI() .usingProcess(processWithMultipleTasks).getProcessTasks(); restClient.assertStatusCodeIs(HttpStatus.OK); processTasks.assertThat().entriesListContains("assignee", assignee3.getUsername()) @@ -100,7 +100,7 @@ public class GetProcessTasksFullTests extends RestTest public void getProcessTasksWithValidMaxItems() throws Exception { processTasks = restClient.authenticateUser(userWhoStartsProcess) - .withParams("maxItems=2").withWorkflowAPI() + .withParams("orderBy=assignee ASC&maxItems=2").withWorkflowAPI() .usingProcess(processWithMultipleTasks).getProcessTasks(); restClient.assertStatusCodeIs(HttpStatus.OK); processTasks.assertThat().entriesListDoesNotContain("assignee", assignee3.getUsername()) From db3e1751350ef83a99c5b3616deec91c211de2bc Mon Sep 17 00:00:00 2001 From: Michael Suzuki Date: Fri, 24 Feb 2017 14:55:55 +0000 Subject: [PATCH 1082/1491] Added highlighting tests --- .../rest/search/AbstractSearchTest.java | 21 +++++- .../rest/search/SearchHighLightTest.java | 71 +++++++++++++++++++ 2 files changed, 89 insertions(+), 3 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/search/SearchHighLightTest.java diff --git a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java index 67df467c3..47d1d8b6d 100644 --- a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java @@ -44,6 +44,7 @@ public class AbstractSearchTest extends RestTest SiteModel siteModel; UserModel searchedUser; NodesBuilder nodesBuilder; + protected FileModel file,file2; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception @@ -61,8 +62,8 @@ public class AbstractSearchTest extends RestTest FolderModel folder = new FolderModel(SEARCH_DATA_SAMPLE_FOLDER); dataContent.usingSite(siteModel).createFolder(folder); //Create files - FileModel file = new FileModel("pangram.txt", FileType.TEXT_PLAIN, "The quick brown fox jumps over the lazy dog"); - FileModel file2 = new FileModel("cars.txt", FileType.TEXT_PLAIN, "The landrover discovery is not a sports car"); + file = new FileModel("pangram.txt", FileType.TEXT_PLAIN, "The quick brown fox jumps over the lazy dog"); + file2 = new FileModel("cars.txt", FileType.TEXT_PLAIN, "The landrover discovery is not a sports car"); ContentModel cm = new ContentModel(); cm.setCmisLocation(folder.getCmisLocation()); cm.setName(folder.getName()); @@ -74,15 +75,29 @@ public class AbstractSearchTest extends RestTest * @param term String search term * @return {@link SearchResponse} response. * @throws Exception if error + * */ protected SearchResponse query(String term) throws Exception { RestRequestQueryModel queryReq = new RestRequestQueryModel(); - queryReq.setLanguage("afts"); queryReq.setQuery(term); SearchRequest query = new SearchRequest(queryReq); return restClient.authenticateUser(dataUser.getAdminUser()).withSearchAPI().search(query); } + /** + * Helper method which create an http post request to Search API end point. + * @param term String search term + * @return {@link SearchResponse} response. + * @throws Exception if error + * + */ + protected SearchResponse query(RestRequestQueryModel queryReq,RestRequestHighlightModel highlight) throws Exception + { + SearchRequest query = new SearchRequest(queryReq); + query.setHighlight(highlight); + System.out.println(query.toString()); + return restClient.authenticateUser(dataUser.getAdminUser()).withSearchAPI().search(query); + } } diff --git a/e2e-test/java/org/alfresco/rest/search/SearchHighLightTest.java b/e2e-test/java/org/alfresco/rest/search/SearchHighLightTest.java new file mode 100644 index 000000000..08aa6c473 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/search/SearchHighLightTest.java @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2017 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.rest.search; + +import java.util.ArrayList; +import java.util.List; + +import org.alfresco.utility.model.TestGroup; +import org.testng.annotations.Test; + +/** + * Search high lighting test. + * @author Michael Suzuki + * + */ +public class SearchHighLightTest extends AbstractSearchTest +{ + @Test(groups={TestGroup.SEARCH, TestGroup.REST_API}) + public void searchWithHighLight() throws Exception + { + RestRequestQueryModel queryReq = new RestRequestQueryModel(); + queryReq.setQuery("description:workflow"); + queryReq.setUserQuery("workflow"); + + RestRequestHighlightModel highlight = new RestRequestHighlightModel(); + highlight.setPrefix("¿"); + highlight.setPostfix("?"); + highlight.setMergeContiguous(true); + List fields = new ArrayList(); + fields.add(new RestRequestFieldsModel("cm:title")); + highlight.setFields(fields); + SearchResponse nodes = query(queryReq, highlight); + nodes.assertThat().entriesListIsNotEmpty(); + ResponseHighLightModel hl = nodes.getEntryByIndex(0).getSearch().getHighlight().get(0); + hl.assertThat().field("snippets").contains("Customized ¿Workflow? Process Definitions"); + } + + @Test(groups={TestGroup.SEARCH,TestGroup.REST_API}) + public void searchNonIndexedData() throws Exception + { + RestRequestQueryModel queryReq = new RestRequestQueryModel(); + queryReq.setQuery("cm:title"); + queryReq.setUserQuery("zoro"); + + RestRequestHighlightModel highlight = new RestRequestHighlightModel(); + highlight.setPrefix("¿"); + highlight.setPostfix("?"); + highlight.setMergeContiguous(true); + List fields = new ArrayList(); + fields.add(new RestRequestFieldsModel("cm:title")); + highlight.setFields(fields); + SearchResponse nodes = query(queryReq, highlight); + nodes.assertThat().entriesListDoesNotContain("highlight"); + } +} From c4954932ff1b54a84c69ada4d420253842b62739 Mon Sep 17 00:00:00 2001 From: Michael Suzuki Date: Fri, 24 Feb 2017 15:39:06 +0000 Subject: [PATCH 1083/1491] Changed test to search content loaded on data prep --- .../org/alfresco/rest/search/SearchHighLightTest.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/SearchHighLightTest.java b/e2e-test/java/org/alfresco/rest/search/SearchHighLightTest.java index 08aa6c473..13117120b 100644 --- a/e2e-test/java/org/alfresco/rest/search/SearchHighLightTest.java +++ b/e2e-test/java/org/alfresco/rest/search/SearchHighLightTest.java @@ -31,24 +31,24 @@ import org.testng.annotations.Test; */ public class SearchHighLightTest extends AbstractSearchTest { - @Test(groups={TestGroup.SEARCH, TestGroup.REST_API}) + @Test(groups={TestGroup.SEARCH,TestGroup.REST_API}) public void searchWithHighLight() throws Exception { RestRequestQueryModel queryReq = new RestRequestQueryModel(); - queryReq.setQuery("description:workflow"); - queryReq.setUserQuery("workflow"); + queryReq.setQuery("cm:content:cars"); + queryReq.setUserQuery("cars"); RestRequestHighlightModel highlight = new RestRequestHighlightModel(); highlight.setPrefix("¿"); highlight.setPostfix("?"); highlight.setMergeContiguous(true); List fields = new ArrayList(); - fields.add(new RestRequestFieldsModel("cm:title")); + fields.add(new RestRequestFieldsModel("cm:content")); highlight.setFields(fields); SearchResponse nodes = query(queryReq, highlight); nodes.assertThat().entriesListIsNotEmpty(); ResponseHighLightModel hl = nodes.getEntryByIndex(0).getSearch().getHighlight().get(0); - hl.assertThat().field("snippets").contains("Customized ¿Workflow? Process Definitions"); + hl.assertThat().field("snippets").contains( "The landrover discovery is not a sports ¿car?"); } @Test(groups={TestGroup.SEARCH,TestGroup.REST_API}) From 7f643deb6daf2f7563368c926143898a312eb008 Mon Sep 17 00:00:00 2001 From: Michael Suzuki Date: Fri, 24 Feb 2017 18:09:10 +0000 Subject: [PATCH 1084/1491] Added start of a faceted search test --- .../rest/search/AbstractSearchTest.java | 13 ++- .../rest/search/FacetedSearchTest.java | 80 +++++++++++++++++++ 2 files changed, 91 insertions(+), 2 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java diff --git a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java index 47d1d8b6d..da27484f7 100644 --- a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java @@ -96,8 +96,17 @@ public class AbstractSearchTest extends RestTest { SearchRequest query = new SearchRequest(queryReq); query.setHighlight(highlight); - System.out.println(query.toString()); return restClient.authenticateUser(dataUser.getAdminUser()).withSearchAPI().search(query); } - + /** + * Helper method which create an http post request to Search API end point. + * @param term String search term + * @return {@link SearchResponse} response. + * @throws Exception if error + * + */ + protected SearchResponse query(SearchRequest query) throws Exception + { + return restClient.authenticateUser(dataUser.getAdminUser()).withSearchAPI().search(query); + } } diff --git a/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java b/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java new file mode 100644 index 000000000..2c913194e --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java @@ -0,0 +1,80 @@ +/* + * Copyright (C) 2017 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.rest.search; + +import java.util.ArrayList; +import java.util.List; + +import org.alfresco.rest.model.RestRequestFacetFieldsModel; +import org.alfresco.utility.model.TestGroup; +import org.testng.Assert; +import org.testng.annotations.Test; + +/** + * Search high lighting test. + * @author Michael Suzuki + * + */ +public class FacetedSearchTest extends AbstractSearchTest +{ + + @Test(groups={TestGroup.SEARCH, TestGroup.REST_API}) + /** + * Perform the below facet query. + * { + * "query": { + * "query": "cars", + * "language": "afts" + * }, + * "facetQueries": [ + * {"query": "content.size:[o TO 102400]", "label": "small"}, + * {"query": "content.size:[102400 TO 1048576]", "label": "medium"}, + * {"query": "content.size:[1048576 TO 16777216]", "label": "large"} + * ], + * "facetFields": {"facets": [{"field": "'content.size'"}]} + * } + * @throws Exception + */ + public void searchWithFaceting() throws Exception + { + SearchRequest query = new SearchRequest(); + RestRequestQueryModel queryReq = new RestRequestQueryModel(); + queryReq.setQuery("cars"); + query.setQuery(queryReq); + + List facets = new ArrayList(); + facets.add(new FacetQuery("content.size:[0 TO 102400]", "small")); + facets.add(new FacetQuery("content.size:[102400 TO 1048576]", "medium")); + facets.add(new FacetQuery("content.size:[1048576 TO 16777216]", "large")); + query.setFacetQueries(facets); + + RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); + List list = new ArrayList(); + list.add(new FacetField("'content.size'")); + facetFields.setFacets(list); + + query.setFacetFields(facetFields); + + SearchResponse nodes = query(query); + nodes.assertThat().entriesListIsNotEmpty(); + nodes.getContext().assertThat().field("facetQueries").isNotEmpty(); + + } + +} From 1f07c00c25b9cf5ea37edee639af1c5709f2f6a2 Mon Sep 17 00:00:00 2001 From: Michael Suzuki Date: Mon, 27 Feb 2017 11:10:19 +0000 Subject: [PATCH 1085/1491] Added faceted search test and updated ModelAssertion with new asserts --- .../rest/search/FacetedSearchTest.java | 44 ++++++++++++++++--- 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java b/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java index 2c913194e..ae79f4620 100644 --- a/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java @@ -23,11 +23,10 @@ import java.util.List; import org.alfresco.rest.model.RestRequestFacetFieldsModel; import org.alfresco.utility.model.TestGroup; -import org.testng.Assert; import org.testng.annotations.Test; /** - * Search high lighting test. + * Faceted search test. * @author Michael Suzuki * */ @@ -49,6 +48,35 @@ public class FacetedSearchTest extends AbstractSearchTest * ], * "facetFields": {"facets": [{"field": "'content.size'"}]} * } + * + * Expected response + * {"list": { + * "entries": [... All the results], + * "pagination": { + * "maxItems": 100, + * "hasMoreItems": false, + * "totalItems": 61, + * "count": 61, + * "skipCount": 0 + * }, + * "context": { + * "consistency": {"lastTxId": 512}, + * "facetQueries": [ + * { + * "count": 61, + * "label": "small" + * }, + * { + * "count": 0, + * "label": "large" + * }, + * { + * "count": 0, + * "label": "medium" + * } + * ] + * } + * }} * @throws Exception */ public void searchWithFaceting() throws Exception @@ -66,14 +94,18 @@ public class FacetedSearchTest extends AbstractSearchTest RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); List list = new ArrayList(); - list.add(new FacetField("'content.size'")); + list.add(new FacetFieldQuery("'content.size'")); facetFields.setFacets(list); query.setFacetFields(facetFields); - SearchResponse nodes = query(query); - nodes.assertThat().entriesListIsNotEmpty(); - nodes.getContext().assertThat().field("facetQueries").isNotEmpty(); + SearchResponse response = query(query); + response.assertThat().entriesListIsNotEmpty(); + response.getContext().assertThat().field("facetQueries").isNotEmpty(); + FacetFieldResponse facet = response.getContext().getFacetQueries().get(0); + facet.assertThat().field("label").contains("small").and().field("count").isGreaterThan(0); + response.getContext().getFacetQueries().get(1).assertThat().field("label").contains("large").and().field("count").isLessThan(1); + response.getContext().getFacetQueries().get(2).assertThat().field("label").contains("medium").and().field("count").isLessThan(1); } From 0dfc2f7d46a070188df384748c07388acabc1f70 Mon Sep 17 00:00:00 2001 From: mionescu Date: Mon, 27 Feb 2017 15:01:11 +0200 Subject: [PATCH 1086/1491] test- fixed Bamboo issue:maxItemsParameterApplied --- .../rest/workflow/tasks/GetTasksFullTests.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksFullTests.java index 59d8573ee..1fdfff937 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksFullTests.java @@ -59,16 +59,16 @@ public class GetTasksFullTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) public void maxItemsParameterApplied() throws Exception { - taskCollections = restClient.authenticateUser(dataUser.getAdminUser()).withParams("orderBy=description ASC").withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - RestTaskModel firstTask = taskCollections.getEntries().get(0).onModel(); - RestTaskModel secondTask = taskCollections.getEntries().get(1).onModel(); + restClient.authenticateUser(userModel).withWorkflowAPI().addProcess("activitiAdhoc", assigneeUser, false, Priority.Low); + restClient.authenticateUser(userModel).withWorkflowAPI().addProcess("activitiAdhoc", adminUser, false, Priority.Low); + taskCollections = restClient.authenticateUser(userModel).withParams("orderBy=assignee ASC").withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); - taskModels = restClient.withParams("orderBy=description ASC&maxItems=2").withWorkflowAPI().getTasks(); + taskModels = restClient.withParams("orderBy=assignee ASC&maxItems=2").withWorkflowAPI().getTasks(); restClient.assertStatusCodeIs(HttpStatus.OK); - - taskModels.assertThat().entriesListContains("id", firstTask.getId()) - .assertThat().entriesListContains("id", secondTask.getId()); + taskModels.assertThat().entriesListIsNotEmpty() + .assertThat().entriesListContains("assignee", assigneeUser.getUsername()) + .assertThat().entriesListDoesNotContain("assignee", adminUser.getUsername()); taskModels.assertThat().paginationField("maxItems").is("2"); taskModels.assertThat().paginationField("count").is("2"); } From 98b34b711b06e3fcf7973e5ca1d5f95fefb34726 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Tue, 28 Feb 2017 13:30:19 +0200 Subject: [PATCH 1087/1491] Check server health before running rest suite --- e2e-test/java/org/alfresco/rest/RestTest.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/RestTest.java b/e2e-test/java/org/alfresco/rest/RestTest.java index 749b80d92..bd25d30ff 100644 --- a/e2e-test/java/org/alfresco/rest/RestTest.java +++ b/e2e-test/java/org/alfresco/rest/RestTest.java @@ -20,8 +20,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; +import org.testng.annotations.BeforeSuite; @ContextConfiguration("classpath:alfresco-restapi-context.xml") public abstract class RestTest extends AbstractTestNGSpringContextTests @@ -63,9 +63,10 @@ public abstract class RestTest extends AbstractTestNGSpringContextTests @Autowired protected WorkflowService workflow; - @BeforeClass(alwaysRun = true) + @BeforeSuite(alwaysRun = true) public void checkServerHealth() throws Exception { + super.springTestContextPrepareTestInstance(); serverHealth.assertServerIsOnline(); } From f0571ad44784b1f8ddb4346eae8a83165561b676 Mon Sep 17 00:00:00 2001 From: Michael Suzuki Date: Tue, 28 Feb 2017 16:00:45 +0000 Subject: [PATCH 1088/1491] Tidy up and added FingerPrint test. --- .../rest/search/AbstractSearchTest.java | 1 - .../alfresco/rest/search/FingerPrintTest.java | 56 +++++++++++++++++++ 2 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java diff --git a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java index da27484f7..60dc5d733 100644 --- a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java @@ -58,7 +58,6 @@ public class AbstractSearchTest extends RestTest * |-- pangram.txt * |-- cars.pdf */ - nodesBuilder = restClient.authenticateUser(userModel).withCoreAPI().usingNode(ContentModel.my()).defineNodes(); FolderModel folder = new FolderModel(SEARCH_DATA_SAMPLE_FOLDER); dataContent.usingSite(siteModel).createFolder(folder); //Create files diff --git a/e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java b/e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java new file mode 100644 index 000000000..6d977a35d --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2017 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.rest.search; + +import org.alfresco.utility.model.TestGroup; +import org.testng.Assert; +import org.testng.annotations.Test; + +/** + * Search end point Public API test with finger print. + * @author Michael Suzuki + * + */ +public class FingerPrintTest extends AbstractSearchTest +{ + @Test(groups={TestGroup.SEARCH, TestGroup.REST_API}) + /** + * Search similar document based on document finger print. + * The data prep should have loaded a file + * identical to the one loaded as part of this test. + * @throws Exception + */ + public void search() throws Exception + { + String uuid = file.getNodeRefWithoutVersion(); + Assert.assertNotNull(uuid); + SearchResponse response = query(uuid); + int count = response.getEntries().size(); + String fingerprint = String.format("FINGERPRINT:%s", uuid); + Thread.sleep(25000);//Allow indexing to complete. + response = query(fingerprint); + count = response.getEntries().size(); + Assert.assertTrue(count > 1); + for(SearchNodeModel m :response.getEntries()) + { + m.getModel().assertThat().field("name").contains("pangram.txt"); + } + } + +} From 4c3a994e8df66321c2f1e2f806ec16432aa63179 Mon Sep 17 00:00:00 2001 From: Michael Suzuki Date: Tue, 28 Feb 2017 16:06:19 +0000 Subject: [PATCH 1089/1491] added spell check tests --- .../rest/search/SearchSpellCheckTest.java | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/search/SearchSpellCheckTest.java diff --git a/e2e-test/java/org/alfresco/rest/search/SearchSpellCheckTest.java b/e2e-test/java/org/alfresco/rest/search/SearchSpellCheckTest.java new file mode 100644 index 000000000..7e7c9442d --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/search/SearchSpellCheckTest.java @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2017 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.rest.search; + +import org.alfresco.rest.model.RestRequestSpellcheckModel; +import org.alfresco.utility.model.TestGroup; +import org.springframework.http.HttpStatus; +import org.testng.annotations.Test; + +/** + * Search end point Public API test with spell checking enabled. + * @author Michael Suzuki + * + */ +public class SearchSpellCheckTest extends AbstractSearchTest +{ +// @Test(groups={TestGroup.SEARCH, TestGroup.REST_API}) + public void searchMissSpelled() throws Exception + { + + SearchResponse nodes = query("carz"); + restClient.assertStatusCodeIs(HttpStatus.OK); + nodes.assertThat().entriesListIsEmpty(); + + SearchRequest searchReq = new SearchRequest(); + RestRequestQueryModel queryReq = new RestRequestQueryModel(); + queryReq.setQuery("cm:content:carz"); + queryReq.setUserQuery("carz"); + searchReq.setQuery(queryReq); + searchReq.setSpellcheck(new RestRequestSpellcheckModel()); + nodes = query(searchReq); + nodes.assertThat().entriesListIsNotEmpty(); + } + +} From ace65aaeed96976cf16b2b5e4413aa79733fd916 Mon Sep 17 00:00:00 2001 From: Michael Suzuki Date: Wed, 1 Mar 2017 07:54:58 +0000 Subject: [PATCH 1090/1491] Fix failing tests on solr4 --- .../java/org/alfresco/rest/search/AbstractSearchTest.java | 1 + e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java | 2 +- e2e-test/java/org/alfresco/rest/search/SearchTest.java | 5 +++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java index 60dc5d733..da27484f7 100644 --- a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java @@ -58,6 +58,7 @@ public class AbstractSearchTest extends RestTest * |-- pangram.txt * |-- cars.pdf */ + nodesBuilder = restClient.authenticateUser(userModel).withCoreAPI().usingNode(ContentModel.my()).defineNodes(); FolderModel folder = new FolderModel(SEARCH_DATA_SAMPLE_FOLDER); dataContent.usingSite(siteModel).createFolder(folder); //Create files diff --git a/e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java b/e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java index 6d977a35d..e0741fa00 100644 --- a/e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java @@ -35,7 +35,7 @@ public class FingerPrintTest extends AbstractSearchTest * The data prep should have loaded a file * identical to the one loaded as part of this test. * @throws Exception - */ + */ public void search() throws Exception { String uuid = file.getNodeRefWithoutVersion(); diff --git a/e2e-test/java/org/alfresco/rest/search/SearchTest.java b/e2e-test/java/org/alfresco/rest/search/SearchTest.java index 3c785a718..72e72801a 100644 --- a/e2e-test/java/org/alfresco/rest/search/SearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/SearchTest.java @@ -38,7 +38,8 @@ public class SearchTest extends AbstractSearchTest nodes.assertThat().entriesListIsNotEmpty(); SearchNodeModel entity = nodes.getEntryByIndex(0); - Assert.assertEquals(entity.getSearch().getScore(), 1); + entity.assertThat().field("search").contains("score"); + entity.getSearch().assertThat().field("score").isNotEmpty(); entity.assertThat().field("name").contains("pangram.txt"); nodes = query("car"); @@ -46,8 +47,8 @@ public class SearchTest extends AbstractSearchTest entity = nodes.getEntryByIndex(0); nodes.assertThat().entriesListIsNotEmpty(); - Assert.assertEquals(entity.getSearch().getScore(), 1); entity.assertThat().field("search").contains("score"); + entity.getSearch().assertThat().field("score").isNotEmpty(); entity.assertThat().field("name").contains("cars.txt"); } From 33fdac86357c8060782e15f21e7c4754eea96f78 Mon Sep 17 00:00:00 2001 From: Michael Suzuki Date: Wed, 1 Mar 2017 08:03:47 +0000 Subject: [PATCH 1091/1491] Disabled fingerprint test until we resolve solr4 --- e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java b/e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java index e0741fa00..4569ad349 100644 --- a/e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java @@ -29,7 +29,7 @@ import org.testng.annotations.Test; */ public class FingerPrintTest extends AbstractSearchTest { - @Test(groups={TestGroup.SEARCH, TestGroup.REST_API}) +// Disabled until solr4 resolution @Test(groups={TestGroup.SEARCH, TestGroup.REST_API}) /** * Search similar document based on document finger print. * The data prep should have loaded a file From 17db7229254061ea5c49a17d430bfd7dae7c2acb Mon Sep 17 00:00:00 2001 From: Michael Suzuki Date: Wed, 1 Mar 2017 10:14:45 +0000 Subject: [PATCH 1092/1491] Disabled test until TAS-3220 resolved --- e2e-test/java/org/alfresco/rest/search/SearchHighLightTest.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/search/SearchHighLightTest.java b/e2e-test/java/org/alfresco/rest/search/SearchHighLightTest.java index 13117120b..91f082957 100644 --- a/e2e-test/java/org/alfresco/rest/search/SearchHighLightTest.java +++ b/e2e-test/java/org/alfresco/rest/search/SearchHighLightTest.java @@ -22,6 +22,7 @@ import java.util.ArrayList; import java.util.List; import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.report.Bug; import org.testng.annotations.Test; /** @@ -32,6 +33,7 @@ import org.testng.annotations.Test; public class SearchHighLightTest extends AbstractSearchTest { @Test(groups={TestGroup.SEARCH,TestGroup.REST_API}) + @Bug(id = "TAS-3220") public void searchWithHighLight() throws Exception { RestRequestQueryModel queryReq = new RestRequestQueryModel(); From 0cc33e6f1ccb84b0dbbf8b8a8e22ad7b0c0f13da Mon Sep 17 00:00:00 2001 From: mionescu Date: Thu, 2 Mar 2017 15:36:05 +0200 Subject: [PATCH 1093/1491] test- define new constant in RestErrorModel, updated tests --- .../org/alfresco/rest/comments/AddCommentsFullTests.java | 8 ++++---- .../org/alfresco/rest/comments/GetCommentsFullTests.java | 8 ++++---- .../rest/workflow/processes/DeleteProcessFullTests.java | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentsFullTests.java b/e2e-test/java/org/alfresco/rest/comments/AddCommentsFullTests.java index 58cd1f92a..91d4b8153 100644 --- a/e2e-test/java/org/alfresco/rest/comments/AddCommentsFullTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/AddCommentsFullTests.java @@ -154,9 +154,9 @@ public class AddCommentsFullTests extends RestTest restClient.processModel(RestCommentModel.class, request); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - restClient.assertLastError().getErrorKey().contains("Unrecognized field \"content2\""); - restClient.assertLastError().containsSummary("Unrecognized field \"content2\""); - restClient.assertLastError().getDescriptionURL().contains("https://api-explorer.alfresco.com"); - restClient.assertLastError().getStackTrace().contains("For security reasons the stack trace is no longer displayed, but the property is kept for previous versions"); + restClient.assertLastError().containsErrorKey(String.format(RestErrorModel.UNRECOGNIZED_FIELD, "content2")); + restClient.assertLastError().containsSummary(String.format(RestErrorModel.UNRECOGNIZED_FIELD, "content2")); + restClient.assertLastError().descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + restClient.assertLastError().stackTraceIs(RestErrorModel.STACKTRACE); } } diff --git a/e2e-test/java/org/alfresco/rest/comments/GetCommentsFullTests.java b/e2e-test/java/org/alfresco/rest/comments/GetCommentsFullTests.java index b7021f602..cf0e38b9f 100644 --- a/e2e-test/java/org/alfresco/rest/comments/GetCommentsFullTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/GetCommentsFullTests.java @@ -207,9 +207,9 @@ public class GetCommentsFullTests extends RestTest restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).usingParams("maxItems=0").getNodeComments(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); - restClient.assertLastError().getErrorKey().contains("Only positive values supported for maxItems."); - restClient.assertLastError().containsSummary("Only positive values supported for maxItems."); - restClient.assertLastError().getDescriptionURL().contains("https://api-explorer.alfresco.com"); - restClient.assertLastError().getStackTrace().contains("For security reasons the stack trace is no longer displayed, but the property is kept for previous versions"); + restClient.assertLastError().containsErrorKey(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); + restClient.assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); + restClient.assertLastError().descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + restClient.assertLastError().stackTraceIs(RestErrorModel.STACKTRACE); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessFullTests.java index 9463d812b..3487bd5f8 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessFullTests.java @@ -43,7 +43,7 @@ public class DeleteProcessFullTests extends RestTest restClient.withWorkflowAPI().usingProcess(process).deleteProcess(); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .containsSummary(String.format("%s: %s ", "The entity with id" , process.getId(), RestErrorModel.ENTITY_NOT_FOUND)) + .containsSummary(String.format(RestErrorModel.ENTITY_WAS_NOT_FOUND, process.getId())) .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) .stackTraceIs(RestErrorModel.STACKTRACE); From fe1e4b95a278062467906c88605e93fa030f20ce Mon Sep 17 00:00:00 2001 From: Gethin James Date: Fri, 3 Mar 2017 17:04:03 +0100 Subject: [PATCH 1094/1491] SEARCH-339: Adding Facet intervals tests --- .../rest/search/FacetIntervalSearchTest.java | 160 ++++++++++++++++++ .../rest/search/FacetedSearchTest.java | 12 +- 2 files changed, 168 insertions(+), 4 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/search/FacetIntervalSearchTest.java diff --git a/e2e-test/java/org/alfresco/rest/search/FacetIntervalSearchTest.java b/e2e-test/java/org/alfresco/rest/search/FacetIntervalSearchTest.java new file mode 100644 index 000000000..f8c6d5d66 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/search/FacetIntervalSearchTest.java @@ -0,0 +1,160 @@ +/* + * Copyright (C) 2017 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.rest.search; + +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.utility.model.TestGroup; +import org.springframework.http.HttpStatus; +import org.testng.Assert; +import org.testng.annotations.Test; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +/** + * Faceted Intervals Search Test + * @author Gethin James + * + */ +public class FacetIntervalSearchTest extends AbstractSearchTest +{ + + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API }) + public void testValidation() throws Exception + { + SearchRequest query = carsQuery(); + + RestRequestFacetIntervalsModel facetIntervalsModel = new RestRequestFacetIntervalsModel(); + FacetInterval facetInterval = new FacetInterval(null, null, null); + facetIntervalsModel.setIntervals(Arrays.asList(facetInterval)); + query.setFacetIntervals(facetIntervalsModel); + + SearchResponse response = query(query); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.MANDATORY_PARAM, "facetIntervals intervals field")); + facetInterval.setField("created"); + response = query(query); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.MANDATORY_COLLECTION, "facetIntervals intervals sets")); + + RestRequestFacetSetModel restFacetSetModel = new RestRequestFacetSetModel(); + restFacetSetModel.setLabel("theRest"); + facetInterval.setSets(Arrays.asList(restFacetSetModel)); + response = query(query); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.MANDATORY_PARAM, "facetIntervals intervals created sets start")); + + restFacetSetModel.setStart("A"); + response = query(query); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.MANDATORY_PARAM, "facetIntervals intervals created sets end")); + + } + + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API }) + public void searchWithBasicInterval() throws Exception + { + SearchRequest query = carsQuery(); + + RestRequestFacetIntervalsModel facetIntervalsModel = new RestRequestFacetIntervalsModel(); + RestRequestFacetSetModel restRequestFacetSetModel = new RestRequestFacetSetModel(); + restRequestFacetSetModel.setStart("a"); + restRequestFacetSetModel.setEnd("user"); + restRequestFacetSetModel.setLabel("aUser"); + + RestRequestFacetSetModel restFacetSetModel = new RestRequestFacetSetModel(); + restFacetSetModel.setStart("user"); + restFacetSetModel.setEnd("z"); + restFacetSetModel.setStartInclusive(false); + restFacetSetModel.setLabel("theRest"); + + FacetInterval facetInterval = new FacetInterval("creator", null, Arrays.asList(restRequestFacetSetModel, restFacetSetModel)); + facetIntervalsModel.setIntervals(Arrays.asList(facetInterval)); + query.setFacetIntervals(facetIntervalsModel); + + SearchResponse response = query(query); + response.assertThat().entriesListIsNotEmpty(); + response.getContext().assertThat().field("facetIntervals").isNotEmpty(); + RestResultBucketsModel resultBucketsModel = response.getContext().getFacetIntervals().get(0); + + FacetFieldBucket bucket = resultBucketsModel.getBuckets().get(0); + Assert.assertEquals(resultBucketsModel.getBuckets().size(), 2); + bucket.assertThat().field("label").is("aUser"); + bucket.assertThat().field("count").isGreaterThan(1); + bucket.assertThat().field("filterQuery").is("creator:[a,user]"); + + bucket = resultBucketsModel.getBuckets().get(1); + + bucket.assertThat().field("label").is("theRest"); + bucket.assertThat().field("count").isLessThan(1); + bucket.assertThat().field("filterQuery").is("creator:(user,z]"); + + } + + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API }) + public void searchWithDates() throws Exception + { + SearchRequest query = carsQuery(); + + RestRequestFacetIntervalsModel facetIntervalsModel = new RestRequestFacetIntervalsModel(); + RestRequestFacetSetModel restRequestFacetSetModel = new RestRequestFacetSetModel(); + restRequestFacetSetModel.setStart("*"); + restRequestFacetSetModel.setEnd("2016"); + restRequestFacetSetModel.setEndInclusive(false); + restRequestFacetSetModel.setLabel("Before2016"); + + RestRequestFacetSetModel restFacetSetModel = new RestRequestFacetSetModel(); + restFacetSetModel.setStart("2016"); + restFacetSetModel.setEnd("now"); + restFacetSetModel.setLabel("From2016"); + + FacetInterval facetInterval = new FacetInterval("cm:modified", null, Arrays.asList(restRequestFacetSetModel, restFacetSetModel)); + facetIntervalsModel.setIntervals(Arrays.asList(facetInterval)); + query.setFacetIntervals(facetIntervalsModel); + + SearchResponse response = query(query); + response.assertThat().entriesListIsNotEmpty(); + response.getContext().assertThat().field("facetIntervals").isNotEmpty(); + RestResultBucketsModel resultBucketsModel = response.getContext().getFacetIntervals().get(0); + + FacetFieldBucket bucket = resultBucketsModel.getBuckets().get(0); + Assert.assertEquals(resultBucketsModel.getBuckets().size(), 2); + + bucket.assertThat().field("label").is("From2016"); + bucket.assertThat().field("count").isGreaterThan(1); + bucket.assertThat().field("filterQuery").is("cm:modified:[2016,now]"); + + bucket = resultBucketsModel.getBuckets().get(1); + + bucket.assertThat().field("label").is("Before2016"); + bucket.assertThat().field("count").isLessThan(1); + bucket.assertThat().field("filterQuery").is("cm:modified:[*,2016)"); + + } + + private SearchRequest carsQuery() + { + SearchRequest query = new SearchRequest(); + RestRequestQueryModel queryReq = new RestRequestQueryModel(); + queryReq.setQuery("cars"); + query.setQuery(queryReq); + return query; + } +} diff --git a/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java b/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java index ae79f4620..54eccb4eb 100644 --- a/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java @@ -21,7 +21,6 @@ package org.alfresco.rest.search; import java.util.ArrayList; import java.util.List; -import org.alfresco.rest.model.RestRequestFacetFieldsModel; import org.alfresco.utility.model.TestGroup; import org.testng.annotations.Test; @@ -102,10 +101,15 @@ public class FacetedSearchTest extends AbstractSearchTest SearchResponse response = query(query); response.assertThat().entriesListIsNotEmpty(); response.getContext().assertThat().field("facetQueries").isNotEmpty(); - FacetFieldResponse facet = response.getContext().getFacetQueries().get(0); + FacetFieldBucket facet = response.getContext().getFacetQueries().get(0); facet.assertThat().field("label").contains("small").and().field("count").isGreaterThan(0); - response.getContext().getFacetQueries().get(1).assertThat().field("label").contains("large").and().field("count").isLessThan(1); - response.getContext().getFacetQueries().get(2).assertThat().field("label").contains("medium").and().field("count").isLessThan(1); + facet.assertThat().field("label").contains("small").and().field("filterQuery").equals("content.size:[0 TO 102400]"); + response.getContext().getFacetQueries().get(1).assertThat().field("label").contains("large") + .and().field("count").isLessThan(1) + .and().field("filterQuery").equals("content.size:[1048576 TO 16777216]"); + response.getContext().getFacetQueries().get(2).assertThat().field("label").contains("medium") + .and().field("count").isLessThan(1) + .and().field("filterQuery").equals("content.size:[102400 TO 1048576]"); } From 8fd341739d948458e5d53364596a9dd90cfa7700 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Mon, 6 Mar 2017 11:20:10 +0200 Subject: [PATCH 1095/1491] added restapi method createNodeRendition and two tests for it --- .../rest/renditions/CreateRenditionTests.java | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/renditions/CreateRenditionTests.java diff --git a/e2e-test/java/org/alfresco/rest/renditions/CreateRenditionTests.java b/e2e-test/java/org/alfresco/rest/renditions/CreateRenditionTests.java new file mode 100644 index 000000000..024f2e41e --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/renditions/CreateRenditionTests.java @@ -0,0 +1,65 @@ +package org.alfresco.rest.renditions; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +/** + * Handles tests related to POST api-explorer/#!/renditions + * @author Cristina Axinte + * + */ +public class CreateRenditionTests extends RestTest +{ + private UserModel adminUser, user; + private SiteModel site; + private FileModel document; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + user = dataUser.createRandomTestUser(); + site = dataSite.usingUser(user).createPublicRandomSite(); + } + + @BeforeMethod(alwaysRun = true) + public void createDocument() throws Exception + { + document = dataContent.usingUser(user).usingSite(site).createContent(DocumentType.TEXT_PLAIN); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RENDITIONS }, executionType = ExecutionType.SANITY, + description = "Verify admin user creates rendition with Rest API and status code is 202") + @Test(groups = { TestGroup.REST_API, TestGroup.RENDITIONS, TestGroup.SANITY }) + public void adminCanToCreateRenditionToExistingNode() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUser).withCoreAPI().usingNode(document).createNodeRendition("pdf"); + restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); + + restClient.withCoreAPI().usingNode(document).getNodeRendition("pdf") + .assertThat().field("status").is("CREATED"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RENDITIONS }, executionType = ExecutionType.SANITY, + description = "Verify user that created the document can also creates rendition for it with Rest API and status code is 202") + @Test(groups = { TestGroup.REST_API, TestGroup.RENDITIONS, TestGroup.SANITY }) + public void adminIsAbleToAddComment() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(user).withCoreAPI().usingNode(document).createNodeRendition("pdf"); + restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); + + restClient.withCoreAPI().usingNode(document).getNodeRendition("pdf") + .assertThat().field("status").is("CREATED"); + } +} From 547f356504796b60bfde8f6e695edee72fea9af2 Mon Sep 17 00:00:00 2001 From: Michael Suzuki Date: Mon, 6 Mar 2017 10:21:20 +0000 Subject: [PATCH 1096/1491] Complete spellcheck rest tests --- .../rest/search/SearchSpellCheckTest.java | 92 ++++++++++++++++--- 1 file changed, 80 insertions(+), 12 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/SearchSpellCheckTest.java b/e2e-test/java/org/alfresco/rest/search/SearchSpellCheckTest.java index 7e7c9442d..a13e447fb 100644 --- a/e2e-test/java/org/alfresco/rest/search/SearchSpellCheckTest.java +++ b/e2e-test/java/org/alfresco/rest/search/SearchSpellCheckTest.java @@ -20,32 +20,100 @@ package org.alfresco.rest.search; import org.alfresco.rest.model.RestRequestSpellcheckModel; import org.alfresco.utility.model.TestGroup; -import org.springframework.http.HttpStatus; +import org.junit.Assert; import org.testng.annotations.Test; /** * Search end point Public API test with spell checking enabled. * @author Michael Suzuki - * + *5 */ public class SearchSpellCheckTest extends AbstractSearchTest { -// @Test(groups={TestGroup.SEARCH, TestGroup.REST_API}) + /** + * Perform the below query + * { + * "spellcheck" : { }, + * "query" : { + * "userQuery" : "alfrezco", + * "query" : "cm:title:alfrezco" + * } + * to yeild the following result. + * { + * "list": { + * "pagination": { + * "count": 22, + * "hasMoreItems": false, + * "totalItems": 22, + * "skipCount": 0, + * "maxItems": 100 + * }, + * "context": { + * "spellCheck": { + * "type": "searchInsteadFor", + * "suggestions": [ + * "alfresco" + * ] + * } + * }, + * "entries": [...] + * } + * + * @throws Exception + */ + @Test(groups={TestGroup.SEARCH, TestGroup.REST_API}) public void searchMissSpelled() throws Exception { - - SearchResponse nodes = query("carz"); - restClient.assertStatusCodeIs(HttpStatus.OK); - nodes.assertThat().entriesListIsEmpty(); - SearchRequest searchReq = new SearchRequest(); RestRequestQueryModel queryReq = new RestRequestQueryModel(); - queryReq.setQuery("cm:content:carz"); - queryReq.setUserQuery("carz"); + queryReq.setQuery("cm:title:alfrezco"); + queryReq.setUserQuery("alfrezco"); searchReq.setQuery(queryReq); searchReq.setSpellcheck(new RestRequestSpellcheckModel()); - nodes = query(searchReq); + assertResponse(query(searchReq)); + } + private void assertResponse(SearchResponse nodes) throws Exception + { nodes.assertThat().entriesListIsNotEmpty(); + nodes.getContext().assertThat().field("spellCheck").isNotEmpty(); + nodes.getContext().getSpellCheck().assertThat().field("suggestions").contains("alfresco"); + } + @Test + /** + * Perform alternative way by setting the value in spellcheck object. + * + * { + * "query": { + * "query": "cm:title:alfrezco", + * "language": "afts" + * }, + * "spellcheck": {"query": "alfrezco"} + * } + * @throws Exception + */ + public void searchMissSpelledVersion2() throws Exception + { + SearchRequest searchReq = new SearchRequest(); + RestRequestQueryModel queryReq = new RestRequestQueryModel(); + queryReq.setQuery("cm:title:alfrezco"); + searchReq.setQuery(queryReq); + + RestRequestSpellcheckModel spellCheck = new RestRequestSpellcheckModel(); + spellCheck.setQuery("alfrezco"); + searchReq.setSpellcheck(spellCheck); + assertResponse(query(searchReq)); + } + @Test + public void searchWithSpellcheckerAndCorrectSpelling() throws Exception + { + SearchRequest searchReq = new SearchRequest(); + RestRequestQueryModel queryReq = new RestRequestQueryModel(); + queryReq.setQuery("cm:title:alfresco"); + queryReq.setUserQuery("alfresco"); + searchReq.setQuery(queryReq); + searchReq.setSpellcheck(new RestRequestSpellcheckModel()); + SearchResponse res = query(searchReq); + Assert.assertNull(res.getContext()); + res.assertThat().entriesListIsNotEmpty(); } - } From fb2cde04e2484607b578c54ce4701ecb29b35234 Mon Sep 17 00:00:00 2001 From: cagache Date: Mon, 6 Mar 2017 13:11:17 +0200 Subject: [PATCH 1097/1491] added getProcessDefinitionById and updated getProcessDefinitionImage (cherry picked from commit fa9a326) --- .../deployments/DeleteDeploymentSanityTests.java | 2 +- .../GetProcessDefinitionImageCoreTests.java | 16 +++++++++------- .../GetProcessDefinitionImageFullTests.java | 6 +++--- .../GetProcessDefinitionImageSanityTests.java | 2 +- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java index 254d40c00..a433d2609 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java @@ -50,7 +50,7 @@ public class DeleteDeploymentSanityTests extends RestTest deployment = allDeployments.getDeploymentByName("customWorkflowExtentionForRest.bpmn"); RestProcessDefinitionModel processDefinitionAssociated = - restClient.withWorkflowAPI().getAllProcessDefinitions().getProcessDefinitionByDeploymentId(deployment.getId()); + restClient.withWorkflowAPI().getAllProcessDefinitions().getProcessDefinitionById(deployment.getId()); RestProcessModel addedProcess = restClient.withWorkflowAPI().addProcess(processDefinitionAssociated.getName(), adminUser, false, CMISUtil.Priority.Normal); diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageCoreTests.java index 5b0fd87f1..dfe7f05c2 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageCoreTests.java @@ -33,8 +33,9 @@ public class GetProcessDefinitionImageCoreTests extends RestTest public void getProcessDefinitionImageUsingInvalidProcessDefinitionId() throws Exception { restClient.authenticateUser(adminUser); - randomProcessDefinition = restClient.withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry(); - randomProcessDefinition.onModel().setId("invalidID"); + randomProcessDefinition = restClient.withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry().onModel(); + randomProcessDefinition.setId("invalidID"); + restClient.withWorkflowAPI() .usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionImage(); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) @@ -47,23 +48,24 @@ public class GetProcessDefinitionImageCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify network admin is able to get a process definition image using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.CORE, TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.CORE, TestGroup.NETWORKS}) @Bug(id = "MNT-17243") public void networkAdminGetProcessDefinitionImage() throws Exception { adminTenantUser = UserModel.getAdminTenantUser(); restClient.authenticateUser(adminUser) .usingTenant().createTenant(adminTenantUser); - randomProcessDefinition = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry(); + + randomProcessDefinition = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry().onModel(); restClient.withWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionImage() .assertResponseContainsImage(); restClient.assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify network user is able to get a process definition image using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.CORE, TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.CORE, TestGroup.NETWORKS}) @Bug(id = "MNT-17243") public void networkUserGetProcessDefinitionImage() throws Exception { @@ -72,7 +74,7 @@ public class GetProcessDefinitionImageCoreTests extends RestTest .usingTenant().createTenant(adminTenantUser); UserModel tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); randomProcessDefinition = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() - .getAllProcessDefinitions().getOneRandomEntry(); + .getAllProcessDefinitions().getOneRandomEntry().onModel(); restClient.authenticateUser(tenantUser).withWorkflowAPI() .usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionImage() .assertResponseContainsImage(); diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageFullTests.java index ae3168893..8f1f352fc 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageFullTests.java @@ -34,8 +34,8 @@ public class GetProcessDefinitionImageFullTests extends RestTest public void getProcessDefinitionImageUsingEmptyProcessDefinitionId() throws Exception { restClient.authenticateUser(adminUser); - randomProcessDefinition = restClient.withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry(); - randomProcessDefinition.onModel().setId(""); + randomProcessDefinition = restClient.withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry().onModel(); + randomProcessDefinition.setId(""); restClient.withWorkflowAPI() .usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionImage(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); @@ -53,7 +53,7 @@ public class GetProcessDefinitionImageFullTests extends RestTest restClient.usingTenant().createTenant(adminTenantUser2); RestProcessDefinitionModel randomProcessDefinition = restClient.authenticateUser(adminTenantUser1).withWorkflowAPI() - .getAllProcessDefinitions().getOneRandomEntry(); + .getAllProcessDefinitions().getOneRandomEntry().onModel(); restClient.authenticateUser(adminTenantUser2).withWorkflowAPI() .usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionImage(); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java index 038d7aafb..159dee846 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java @@ -23,7 +23,7 @@ public class GetProcessDefinitionImageSanityTests extends RestTest { testUser = dataUser.createRandomTestUser(); restClient.authenticateUser(dataUser.getAdminUser()); - randomProcessDefinition = restClient.withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry(); + randomProcessDefinition = restClient.withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry().onModel(); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.SANITY, From c13fa76b63ce00626a2cea9a92e60fb032e06478 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Mon, 6 Mar 2017 14:08:42 +0200 Subject: [PATCH 1098/1491] added corresponding bug id --- .../org/alfresco/rest/renditions/CreateRenditionTests.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/renditions/CreateRenditionTests.java b/e2e-test/java/org/alfresco/rest/renditions/CreateRenditionTests.java index 024f2e41e..6463700ee 100644 --- a/e2e-test/java/org/alfresco/rest/renditions/CreateRenditionTests.java +++ b/e2e-test/java/org/alfresco/rest/renditions/CreateRenditionTests.java @@ -7,6 +7,7 @@ import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -39,10 +40,11 @@ public class CreateRenditionTests extends RestTest document = dataContent.usingUser(user).usingSite(site).createContent(DocumentType.TEXT_PLAIN); } + @Bug(id = "REPO-2042", description = "Should fail only on MAC OS System and Linux" ) @TestRail(section = { TestGroup.REST_API, TestGroup.RENDITIONS }, executionType = ExecutionType.SANITY, description = "Verify admin user creates rendition with Rest API and status code is 202") @Test(groups = { TestGroup.REST_API, TestGroup.RENDITIONS, TestGroup.SANITY }) - public void adminCanToCreateRenditionToExistingNode() throws JsonToModelConversionException, Exception + public void adminCanCreateRenditionToExistingNode() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUser).withCoreAPI().usingNode(document).createNodeRendition("pdf"); restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); @@ -51,10 +53,11 @@ public class CreateRenditionTests extends RestTest .assertThat().field("status").is("CREATED"); } + @Bug(id = "REPO-2042", description = "Should fail only on MAC OS System and Linux" ) @TestRail(section = { TestGroup.REST_API, TestGroup.RENDITIONS }, executionType = ExecutionType.SANITY, description = "Verify user that created the document can also creates rendition for it with Rest API and status code is 202") @Test(groups = { TestGroup.REST_API, TestGroup.RENDITIONS, TestGroup.SANITY }) - public void adminIsAbleToAddComment() throws JsonToModelConversionException, Exception + public void userThatCreatedFileCanCreateRenditionForIt() throws JsonToModelConversionException, Exception { restClient.authenticateUser(user).withCoreAPI().usingNode(document).createNodeRendition("pdf"); restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); From 9e9f7cbc9513bd25c095cd45be33afee186797a4 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Mon, 6 Mar 2017 15:09:19 +0200 Subject: [PATCH 1099/1491] added test for createDoclibRendition --- .../rest/renditions/CreateRenditionTests.java | 31 +++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/renditions/CreateRenditionTests.java b/e2e-test/java/org/alfresco/rest/renditions/CreateRenditionTests.java index 6463700ee..441008d64 100644 --- a/e2e-test/java/org/alfresco/rest/renditions/CreateRenditionTests.java +++ b/e2e-test/java/org/alfresco/rest/renditions/CreateRenditionTests.java @@ -3,7 +3,10 @@ package org.alfresco.rest.renditions; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestNodeModel; +import org.alfresco.utility.Utility; import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; @@ -55,9 +58,9 @@ public class CreateRenditionTests extends RestTest @Bug(id = "REPO-2042", description = "Should fail only on MAC OS System and Linux" ) @TestRail(section = { TestGroup.REST_API, TestGroup.RENDITIONS }, executionType = ExecutionType.SANITY, - description = "Verify user that created the document can also creates rendition for it with Rest API and status code is 202") + description = "Verify user that created the document can also creates 'pdf' rendition for it with Rest API and status code is 202") @Test(groups = { TestGroup.REST_API, TestGroup.RENDITIONS, TestGroup.SANITY }) - public void userThatCreatedFileCanCreateRenditionForIt() throws JsonToModelConversionException, Exception + public void userThatCreatedFileCanCreatePdfRenditionForIt() throws JsonToModelConversionException, Exception { restClient.authenticateUser(user).withCoreAPI().usingNode(document).createNodeRendition("pdf"); restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); @@ -65,4 +68,28 @@ public class CreateRenditionTests extends RestTest restClient.withCoreAPI().usingNode(document).getNodeRendition("pdf") .assertThat().field("status").is("CREATED"); } + + @Bug(id = "REPO-2042", description = "Should fail only on MAC OS System and Linux" ) + @TestRail(section = { TestGroup.REST_API, TestGroup.RENDITIONS }, executionType = ExecutionType.SANITY, + description = "Verify user that created the document can also creates 'doclib' rendition for it with Rest API and status code is 202") + @Test(groups = { TestGroup.REST_API, TestGroup.RENDITIONS, TestGroup.SANITY }) + public void userThatCreatedFileCanCreateDoclibRenditionForIt() throws JsonToModelConversionException, Exception + { + FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder(); + restClient.authenticateUser(user) + .configureRequestSpec() + .addMultiPart("filedata", Utility.getResourceTestDataFile("my-file.tif")); + + RestNodeModel fileNode = restClient.authenticateUser(user).withCoreAPI().usingResource(folder).createNode(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + document = new FileModel("my-file.tif"); + document.setCmisLocation(folder.getCmisLocation() + "/my-file.tif"); + document.setNodeRef(fileNode.getId()); + + restClient.authenticateUser(user).withCoreAPI().usingNode(document).createNodeRendition("doclib"); + restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); + + restClient.withCoreAPI().usingNode(document).getNodeRendition("doclib") + .assertThat().field("status").is("CREATED"); + } } From 99c32ff6832ab8f0b40a8fa70e23f29797c18375 Mon Sep 17 00:00:00 2001 From: Gethin James Date: Mon, 6 Mar 2017 16:19:08 +0100 Subject: [PATCH 1100/1491] SEARCH-339: Adding label to Facet intervals --- .../java/org/alfresco/rest/search/FacetIntervalSearchTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/search/FacetIntervalSearchTest.java b/e2e-test/java/org/alfresco/rest/search/FacetIntervalSearchTest.java index f8c6d5d66..cee1c67d0 100644 --- a/e2e-test/java/org/alfresco/rest/search/FacetIntervalSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FacetIntervalSearchTest.java @@ -125,7 +125,7 @@ public class FacetIntervalSearchTest extends AbstractSearchTest restFacetSetModel.setEnd("now"); restFacetSetModel.setLabel("From2016"); - FacetInterval facetInterval = new FacetInterval("cm:modified", null, Arrays.asList(restRequestFacetSetModel, restFacetSetModel)); + FacetInterval facetInterval = new FacetInterval("cm:modified", "modified", Arrays.asList(restRequestFacetSetModel, restFacetSetModel)); facetIntervalsModel.setIntervals(Arrays.asList(facetInterval)); query.setFacetIntervals(facetIntervalsModel); @@ -134,6 +134,7 @@ public class FacetIntervalSearchTest extends AbstractSearchTest response.getContext().assertThat().field("facetIntervals").isNotEmpty(); RestResultBucketsModel resultBucketsModel = response.getContext().getFacetIntervals().get(0); + resultBucketsModel.assertThat().field("label").is("modified"); FacetFieldBucket bucket = resultBucketsModel.getBuckets().get(0); Assert.assertEquals(resultBucketsModel.getBuckets().size(), 2); From 7bf3756c6ecae550b150509cd84c6e249c904885 Mon Sep 17 00:00:00 2001 From: mionescu Date: Tue, 7 Mar 2017 09:39:49 +0200 Subject: [PATCH 1101/1491] test- fixed bamboo issue:networkUserIsNotAbleToGetProcessDefinitionImageForAnotherNetwork removed unused imports and variables --- e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java | 2 -- e2e-test/java/org/alfresco/rest/search/SearchTest.java | 1 - .../GetProcessDefinitionImageFullTests.java | 2 +- .../rest/workflow/tasks/items/GetTaskItemsSanityTests.java | 2 +- .../tasks/variables/UpdateTaskVariableSanityTests.java | 4 +--- 5 files changed, 3 insertions(+), 8 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java b/e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java index 4569ad349..8396f8cc0 100644 --- a/e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java @@ -18,9 +18,7 @@ */ package org.alfresco.rest.search; -import org.alfresco.utility.model.TestGroup; import org.testng.Assert; -import org.testng.annotations.Test; /** * Search end point Public API test with finger print. diff --git a/e2e-test/java/org/alfresco/rest/search/SearchTest.java b/e2e-test/java/org/alfresco/rest/search/SearchTest.java index 72e72801a..5b989e6c6 100644 --- a/e2e-test/java/org/alfresco/rest/search/SearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/SearchTest.java @@ -20,7 +20,6 @@ package org.alfresco.rest.search; import org.alfresco.utility.model.TestGroup; import org.springframework.http.HttpStatus; -import org.testng.Assert; import org.testng.annotations.Test; /** diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageFullTests.java index 8f1f352fc..a43f77700 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageFullTests.java @@ -57,6 +57,6 @@ public class GetProcessDefinitionImageFullTests extends RestTest restClient.authenticateUser(adminTenantUser2).withWorkflowAPI() .usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionImage(); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, randomProcessDefinition.onModel().getId())); + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, randomProcessDefinition.getId())); } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/items/GetTaskItemsSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/items/GetTaskItemsSanityTests.java index 88fd21c02..04b9e05ee 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/items/GetTaskItemsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/items/GetTaskItemsSanityTests.java @@ -22,7 +22,7 @@ import org.testng.annotations.Test; public class GetTaskItemsSanityTests extends RestTest { - private UserModel userModel, userWhoStartsTask, assignee, adminTenantUser, tenantUser, tenantUserAssignee; + private UserModel userModel, userWhoStartsTask, assignee; private SiteModel siteModel; private FileModel fileModel, document1; private TaskModel taskModel; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableSanityTests.java index 51246cde3..f98157164 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableSanityTests.java @@ -27,9 +27,7 @@ public class UpdateTaskVariableSanityTests extends RestTest private SiteModel siteModel; private FileModel fileModel; private UserModel assigneeUser; - private TaskModel taskModel, tenantTask; - - private UserModel adminTenantUser, tenantUser, tenantUserAssignee; + private TaskModel taskModel; private RestVariableModel taskVariable; private RestVariableModel variableModel; From 13c9cf183e84671b66b8daff45960c93b1b19532 Mon Sep 17 00:00:00 2001 From: Mihaela Popa Date: Tue, 7 Mar 2017 10:27:56 +0200 Subject: [PATCH 1102/1491] REPO-2112 / MNT-17545: HTTP Header Injection in ContentStreamer Added support for getNodeContent and tests for REPO-2112 --- .../rest/nodes/NodesContentTests.java | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/nodes/NodesContentTests.java diff --git a/e2e-test/java/org/alfresco/rest/nodes/NodesContentTests.java b/e2e-test/java/org/alfresco/rest/nodes/NodesContentTests.java new file mode 100644 index 000000000..a83064640 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/nodes/NodesContentTests.java @@ -0,0 +1,52 @@ +package org.alfresco.rest.nodes; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FileType; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.Test; +/** + * + * @author mpopa + * + */ +public class NodesContentTests extends RestTest +{ + @TestRail(section = { TestGroup.REST_API,TestGroup.NODES }, executionType = ExecutionType.SANITY, + description = "Verify file name in Content-Disposition header") + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY}) + public void checkFileNameWithRegularCharsInHeader() throws Exception + { + UserModel user = dataUser.createRandomTestUser(); + SiteModel site = dataSite.usingUser(user).createPublicRandomSite(); + FileModel file = dataContent.usingUser(user).usingSite(site).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(user).withCoreAPI().usingNode(file).usingParams("attachment=false").getNodeContent(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.assertHeaderValueContains("Content-Disposition", String.format("filename=\"%s\"", file.getName())); + } + + @Bug(id="REPO-2112") + @TestRail(section = { TestGroup.REST_API,TestGroup.NODES }, executionType = ExecutionType.REGRESSION, + description = "Verify file name with special chars is escaped in Content-Disposition header") + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE}) + public void checkFileNameWithSpecialCharsInHeader() throws Exception + { + char c1 = 127; + char c2 = 31; + char c3 = 256; + UserModel user = dataUser.createRandomTestUser(); + SiteModel site = dataSite.usingUser(user).createPublicRandomSite(); + FileModel file = dataContent.usingUser(user).usingSite(site).createContent(new FileModel("\ntest\""+c1+c2+c3,FileType.TEXT_PLAIN)); + restClient.authenticateUser(user).withCoreAPI().usingNode(file).usingParams("attachment=false").getNodeContent(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.assertHeaderValueContains("Content-Disposition","filename=\" test .txt\""); + } + +} From 6ea05f9dbfe9a0ee37465af76cc82d645daea4bd Mon Sep 17 00:00:00 2001 From: Mihaela Popa Date: Tue, 7 Mar 2017 11:21:42 +0200 Subject: [PATCH 1103/1491] REPO-2112 / MNT-17545: HTTP Header Injection in ContentStreamer Added @BeforeClass for NodesContentTests and java doc for assertHeaderValueContains --- .../rest/nodes/NodesContentTests.java | 28 +++++++++++++------ 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/nodes/NodesContentTests.java b/e2e-test/java/org/alfresco/rest/nodes/NodesContentTests.java index a83064640..abc729ab7 100644 --- a/e2e-test/java/org/alfresco/rest/nodes/NodesContentTests.java +++ b/e2e-test/java/org/alfresco/rest/nodes/NodesContentTests.java @@ -11,6 +11,7 @@ import org.alfresco.utility.report.Bug; 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; /** * @@ -19,17 +20,28 @@ import org.testng.annotations.Test; */ public class NodesContentTests extends RestTest { + private UserModel user1, user2; + private SiteModel site1, site2; + private FileModel file1; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + user1 = dataUser.createRandomTestUser(); + user2 = dataUser.createRandomTestUser(); + site1 = dataSite.usingUser(user1).createPublicRandomSite(); + site2 = dataSite.usingUser(user2).createPublicRandomSite(); + file1 = dataContent.usingUser(user1).usingSite(site1).createContent(DocumentType.TEXT_PLAIN); + } + @TestRail(section = { TestGroup.REST_API,TestGroup.NODES }, executionType = ExecutionType.SANITY, description = "Verify file name in Content-Disposition header") @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY}) public void checkFileNameWithRegularCharsInHeader() throws Exception { - UserModel user = dataUser.createRandomTestUser(); - SiteModel site = dataSite.usingUser(user).createPublicRandomSite(); - FileModel file = dataContent.usingUser(user).usingSite(site).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(user).withCoreAPI().usingNode(file).usingParams("attachment=false").getNodeContent(); + restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("attachment=false").getNodeContent(); restClient.assertStatusCodeIs(HttpStatus.OK); - restClient.assertHeaderValueContains("Content-Disposition", String.format("filename=\"%s\"", file.getName())); + restClient.assertHeaderValueContains("Content-Disposition", String.format("filename=\"%s\"", file1.getName())); } @Bug(id="REPO-2112") @@ -41,10 +53,8 @@ public class NodesContentTests extends RestTest char c1 = 127; char c2 = 31; char c3 = 256; - UserModel user = dataUser.createRandomTestUser(); - SiteModel site = dataSite.usingUser(user).createPublicRandomSite(); - FileModel file = dataContent.usingUser(user).usingSite(site).createContent(new FileModel("\ntest\""+c1+c2+c3,FileType.TEXT_PLAIN)); - restClient.authenticateUser(user).withCoreAPI().usingNode(file).usingParams("attachment=false").getNodeContent(); + FileModel file = dataContent.usingUser(user2).usingSite(site2).createContent(new FileModel("\ntest\"" + c1 + c2 + c3, FileType.TEXT_PLAIN)); + restClient.authenticateUser(user2).withCoreAPI().usingNode(file).usingParams("attachment=false").getNodeContent(); restClient.assertStatusCodeIs(HttpStatus.OK); restClient.assertHeaderValueContains("Content-Disposition","filename=\" test .txt\""); } From c22c2159224bdeda778a77e6996f15f14af20468 Mon Sep 17 00:00:00 2001 From: Michael Suzuki Date: Tue, 7 Mar 2017 11:58:48 +0000 Subject: [PATCH 1104/1491] amend data prep to use the random user to load files instead of the admin user --- .../java/org/alfresco/rest/search/AbstractSearchTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java index da27484f7..d02cbe1c6 100644 --- a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java @@ -60,15 +60,15 @@ public class AbstractSearchTest extends RestTest */ nodesBuilder = restClient.authenticateUser(userModel).withCoreAPI().usingNode(ContentModel.my()).defineNodes(); FolderModel folder = new FolderModel(SEARCH_DATA_SAMPLE_FOLDER); - dataContent.usingSite(siteModel).createFolder(folder); + dataContent.usingUser(userModel).usingSite(siteModel).createFolder(folder); //Create files file = new FileModel("pangram.txt", FileType.TEXT_PLAIN, "The quick brown fox jumps over the lazy dog"); file2 = new FileModel("cars.txt", FileType.TEXT_PLAIN, "The landrover discovery is not a sports car"); ContentModel cm = new ContentModel(); cm.setCmisLocation(folder.getCmisLocation()); cm.setName(folder.getName()); - dataContent.usingSite(siteModel).usingResource(cm).createContent(file); - dataContent.usingSite(siteModel).usingResource(cm).createContent(file2); + dataContent.usingUser(userModel).usingSite(siteModel).usingResource(cm).createContent(file); + dataContent.usingUser(userModel).usingSite(siteModel).usingResource(cm).createContent(file2); } /** * Helper method which create an http post request to Search API end point. From 8afe3d1eba918c72512d4cd6e0d85e7925f4b06f Mon Sep 17 00:00:00 2001 From: Michael Suzuki Date: Tue, 7 Mar 2017 12:03:07 +0000 Subject: [PATCH 1105/1491] finished fingerprint tests for solr 6 --- .../alfresco/rest/search/FingerPrintTest.java | 123 ++++++++++++++++-- 1 file changed, 112 insertions(+), 11 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java b/e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java index 8396f8cc0..78a239d91 100644 --- a/e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java @@ -18,7 +18,14 @@ */ package org.alfresco.rest.search; +import org.alfresco.utility.model.ContentModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FileType; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.TestGroup; import org.testng.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; /** * Search end point Public API test with finger print. @@ -27,28 +34,122 @@ import org.testng.Assert; */ public class FingerPrintTest extends AbstractSearchTest { -// Disabled until solr4 resolution @Test(groups={TestGroup.SEARCH, TestGroup.REST_API}) + private FileModel file1,file2,file3,file4; + @BeforeClass + public void indexSimilarFile() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + /* + * Create the following file structure for preconditions : + * |- folder + * |-- fox.txt + */ + nodesBuilder = restClient.authenticateUser(userModel).withCoreAPI().usingNode(ContentModel.my()).defineNodes(); + FolderModel folder = new FolderModel(SEARCH_DATA_SAMPLE_FOLDER); + dataContent.usingUser(userModel).usingSite(siteModel).createFolder(folder); + file1 = new FileModel("pangram-banana.txt", FileType.TEXT_PLAIN, "The quick brown fox jumps over the lazy banana"); + file2 = new FileModel("pangram-taco.txt", FileType.TEXT_PLAIN, "The quick brown fox jumps over the lazy dog that ate the taco"); + file3 = new FileModel("pangram-cat.txt", FileType.TEXT_PLAIN, "The quick brown fox jumps over the lazy cat"); + file4 = new FileModel("dog.txt", FileType.TEXT_PLAIN, "The quick brown fox ate the lazy dog"); + ContentModel cm = new ContentModel(); + cm.setCmisLocation(folder.getCmisLocation()); + cm.setName(folder.getName()); + dataContent.usingUser(userModel).usingSite(siteModel).usingResource(cm).createContent(file1); + dataContent.usingUser(userModel).usingSite(siteModel).usingResource(cm).createContent(file2); + dataContent.usingUser(userModel).usingSite(siteModel).usingResource(cm).createContent(file3); + dataContent.usingUser(userModel).usingSite(siteModel).usingResource(cm).createContent(file4); + Thread.sleep(35000);//Allow indexing to complete. + } /** * Search similar document based on document finger print. - * The data prep should have loaded a file - * identical to the one loaded as part of this test. + * The data prep should have loaded 2 files which one is similar + * to the files loaded as part of this test. + * Note that for fingerprint to work it need a 5 word sequence. + * * @throws Exception */ + @Test(groups= {TestGroup.REST_API, TestGroup.SEARCH}) public void search() throws Exception { - String uuid = file.getNodeRefWithoutVersion(); + String uuid = file1.getNodeRefWithoutVersion(); Assert.assertNotNull(uuid); - SearchResponse response = query(uuid); - int count = response.getEntries().size(); String fingerprint = String.format("FINGERPRINT:%s", uuid); - Thread.sleep(25000);//Allow indexing to complete. - response = query(fingerprint); - count = response.getEntries().size(); + SearchResponse response = query(fingerprint); + int count = response.getEntries().size(); Assert.assertTrue(count > 1); for(SearchNodeModel m :response.getEntries()) { - m.getModel().assertThat().field("name").contains("pangram.txt"); + String match = m.getModel().getName(); + switch (match) + { + case "pangram.txt": + break; + case "pangram-banana.txt": + break; + case "pangram-taco.txt": + break; + case "pangram-cat.txt": + break; + default: + throw new AssertionError("Not a match to an expected file: " + m.getModel().getName()); + } + m.getModel().assertThat().field("name").isNot("dog.txt"); + m.getModel().assertThat().field("name").isNot("cars.txt"); + } + } + @Test(groups= {TestGroup.REST_API, TestGroup.SEARCH}) + public void searchSimilar() throws Exception + { + String uuid = file2.getNodeRefWithoutVersion(); + Assert.assertNotNull(uuid); + String fingerprint = String.format("FINGERPRINT:%s_68", uuid); + SearchResponse response = query(fingerprint); + int count = response.getEntries().size(); + Assert.assertTrue(count > 1); + for(SearchNodeModel m :response.getEntries()) + { + switch (m.getModel().getName()) + { + case "pangram.txt": + break; + case "pangram-taco.txt": + break; + default: + throw new AssertionError("Not a match to an expected file: " + m.getModel().getName()); + } + m.getModel().assertThat().field("name").isNot("pangram-banana.txt"); + m.getModel().assertThat().field("name").isNot("pangram-cat.txt"); + m.getModel().assertThat().field("name").isNot("dog.txt"); + m.getModel().assertThat().field("name").isNot("cars.txt"); + } + } + @Test(groups= {TestGroup.REST_API, TestGroup.SEARCH}) + public void searchSimilar67Percent() throws Exception + { + String uuid = file2.getNodeRefWithoutVersion(); + Assert.assertNotNull(uuid); + String fingerprint = String.format("FINGERPRINT:%s_68", uuid); + SearchResponse response = query(fingerprint); + int count = response.getEntries().size(); + Assert.assertTrue(count > 1); + for(SearchNodeModel m :response.getEntries()) + { + switch (m.getModel().getName()) + { + case "pangram.txt": + break; + case "pangram-taco.txt": + break; + case "pangram-cat.txt": + break; + default: + throw new AssertionError("Not a match to an expected file: " + m.getModel().getName()); + } + m.getModel().assertThat().field("name").isNot("pangram-banana.txt"); + m.getModel().assertThat().field("name").isNot("dog.txt"); + m.getModel().assertThat().field("name").isNot("cars.txt"); } } - } From a633af7ff7c2df580348d0e9aa293b8534980d5d Mon Sep 17 00:00:00 2001 From: Michael Suzuki Date: Tue, 7 Mar 2017 12:03:17 +0000 Subject: [PATCH 1106/1491] finished fingerprint tests for solr 6 --- e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java b/e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java index 78a239d91..765e29ea5 100644 --- a/e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java @@ -70,7 +70,7 @@ public class FingerPrintTest extends AbstractSearchTest * * @throws Exception */ - @Test(groups= {TestGroup.REST_API, TestGroup.SEARCH}) +// @Test(groups= {TestGroup.REST_API, TestGroup.SEARCH}) public void search() throws Exception { String uuid = file1.getNodeRefWithoutVersion(); @@ -99,7 +99,7 @@ public class FingerPrintTest extends AbstractSearchTest m.getModel().assertThat().field("name").isNot("cars.txt"); } } - @Test(groups= {TestGroup.REST_API, TestGroup.SEARCH}) +// @Test(groups= {TestGroup.REST_API, TestGroup.SEARCH}) public void searchSimilar() throws Exception { String uuid = file2.getNodeRefWithoutVersion(); @@ -125,7 +125,7 @@ public class FingerPrintTest extends AbstractSearchTest m.getModel().assertThat().field("name").isNot("cars.txt"); } } - @Test(groups= {TestGroup.REST_API, TestGroup.SEARCH}) +// @Test(groups= {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ass}) public void searchSimilar67Percent() throws Exception { String uuid = file2.getNodeRefWithoutVersion(); From eabeac14f0c6d1f17a0d1e83a120262a4929423b Mon Sep 17 00:00:00 2001 From: Gethin James Date: Wed, 8 Mar 2017 11:43:44 +0100 Subject: [PATCH 1107/1491] SEARCH-372: Switched .equals to .is --- .../java/org/alfresco/rest/search/FacetedSearchTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java b/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java index 54eccb4eb..7c3478817 100644 --- a/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java @@ -103,13 +103,13 @@ public class FacetedSearchTest extends AbstractSearchTest response.getContext().assertThat().field("facetQueries").isNotEmpty(); FacetFieldBucket facet = response.getContext().getFacetQueries().get(0); facet.assertThat().field("label").contains("small").and().field("count").isGreaterThan(0); - facet.assertThat().field("label").contains("small").and().field("filterQuery").equals("content.size:[0 TO 102400]"); + facet.assertThat().field("label").contains("small").and().field("filterQuery").is("content.size:[0 TO 102400]"); response.getContext().getFacetQueries().get(1).assertThat().field("label").contains("large") .and().field("count").isLessThan(1) - .and().field("filterQuery").equals("content.size:[1048576 TO 16777216]"); + .and().field("filterQuery").is("content.size:[1048576 TO 16777216]"); response.getContext().getFacetQueries().get(2).assertThat().field("label").contains("medium") .and().field("count").isLessThan(1) - .and().field("filterQuery").equals("content.size:[102400 TO 1048576]"); + .and().field("filterQuery").is("content.size:[102400 TO 1048576]"); } From fcc9482eebea91d810e2b9c566dbe185a7fcb68d Mon Sep 17 00:00:00 2001 From: Gethin James Date: Wed, 8 Mar 2017 11:45:13 +0100 Subject: [PATCH 1108/1491] SEARCH-339: Adding a 60 second wait after dataprep --- e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java index da27484f7..e69a47cce 100644 --- a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java @@ -20,6 +20,7 @@ package org.alfresco.rest.search; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.builder.NodesBuilder; +import org.alfresco.utility.Utility; import org.alfresco.utility.model.ContentModel; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FileType; @@ -69,6 +70,8 @@ public class AbstractSearchTest extends RestTest cm.setName(folder.getName()); dataContent.usingSite(siteModel).usingResource(cm).createContent(file); dataContent.usingSite(siteModel).usingResource(cm).createContent(file2); + + Utility.waitToLoopTime(60); } /** * Helper method which create an http post request to Search API end point. From 4648b93b898562f1db50ec824efa09bf71d60c18 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Wed, 8 Mar 2017 16:34:43 +0200 Subject: [PATCH 1109/1491] adding CMIS rest api calls on RestCmisAPI class --- e2e-test/java/org/alfresco/rest/RestTest.java | 4 +++ .../alfresco/rest/cmis/CmisBrowserTest.java | 25 +++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/cmis/CmisBrowserTest.java diff --git a/e2e-test/java/org/alfresco/rest/RestTest.java b/e2e-test/java/org/alfresco/rest/RestTest.java index bd25d30ff..789d7cca1 100644 --- a/e2e-test/java/org/alfresco/rest/RestTest.java +++ b/e2e-test/java/org/alfresco/rest/RestTest.java @@ -14,6 +14,7 @@ import org.alfresco.utility.data.DataLink; import org.alfresco.utility.data.DataSite; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.DataWorkflow; +import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.network.ServerHealth; import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; @@ -63,11 +64,14 @@ public abstract class RestTest extends AbstractTestNGSpringContextTests @Autowired protected WorkflowService workflow; + protected SiteModel testSite; + @BeforeSuite(alwaysRun = true) public void checkServerHealth() throws Exception { super.springTestContextPrepareTestInstance(); serverHealth.assertServerIsOnline(); + testSite = dataSite.createPublicRandomSite(); } @BeforeMethod(alwaysRun=true) diff --git a/e2e-test/java/org/alfresco/rest/cmis/CmisBrowserTest.java b/e2e-test/java/org/alfresco/rest/cmis/CmisBrowserTest.java new file mode 100644 index 000000000..1e9afbab7 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/cmis/CmisBrowserTest.java @@ -0,0 +1,25 @@ +package org.alfresco.rest.cmis; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.RestResponse; +import org.alfresco.utility.model.FileModel; +import org.testng.annotations.Test; + +public class CmisBrowserTest extends RestTest +{ + /* + * @author: Paul Brodner + * simple test for demo purposes on how to use CMIS browser binding with Rest + */ + @Test(enabled=false) + public void assertContentDispositionHeaderOnCmisFile() throws Exception + { + FileModel document = dataContent.usingUser(dataUser.getAdminUser()) + .usingSite(testSite).createContent(DocumentType.HTML); + + RestResponse response = restClient.authenticateUser(dataUser.getAdminUser()).withCMISApi().getRootObjectByID(document); + response.assertThat().header("Content-Disposition", String.format("attachment; filename=%s", document.getName())); + } + +} From 133e0602c932c2347366ee3589f5c87c51d8a330 Mon Sep 17 00:00:00 2001 From: cgornea Date: Wed, 8 Mar 2017 18:07:09 +0200 Subject: [PATCH 1110/1491] REPO-2096: Add support for AOS calls using REST API --- .../org/alfresco/rest/aos/AosApiTest.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/aos/AosApiTest.java diff --git a/e2e-test/java/org/alfresco/rest/aos/AosApiTest.java b/e2e-test/java/org/alfresco/rest/aos/AosApiTest.java new file mode 100644 index 000000000..6223db2f7 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/aos/AosApiTest.java @@ -0,0 +1,24 @@ +package org.alfresco.rest.aos; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.RestRequest; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.testng.annotations.Test; + +public class AosApiTest extends RestTest +{ + /* + * @author: Catalin Gornea + * + * simple test for demo purposes on how to use Aos with Rest + */ + @Test(enabled=false) + public void assertResponsIsSuccesufulWhenGetRootDirectory() throws Exception + { + restClient.authenticateUser(dataUser.getAdminUser()).withAosAPI(); + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, ""); + restClient.process(request); + restClient.assertStatusCodeIs(HttpStatus.OK); + } +} From 5b1232d701df76e7ae7da12068f58ccae990aa57 Mon Sep 17 00:00:00 2001 From: Michael Suzuki Date: Thu, 9 Mar 2017 15:35:03 +0000 Subject: [PATCH 1111/1491] Added APATH end 2 end tests --- .../rest/search/AbstractSearchTest.java | 1 + .../alfresco/rest/search/FingerPrintTest.java | 9 +- .../alfresco/rest/search/SearchAPATHTest.java | 168 ++++++++++++++++++ 3 files changed, 174 insertions(+), 4 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java diff --git a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java index d02cbe1c6..7d72684b6 100644 --- a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java @@ -34,6 +34,7 @@ import org.testng.annotations.BeforeClass; *
      *
    • Preparing the data to index. *
    • Preparing search requests. + * * @author Michael Suzuki * */ diff --git a/e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java b/e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java index 765e29ea5..675d5da3c 100644 --- a/e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java @@ -70,7 +70,7 @@ public class FingerPrintTest extends AbstractSearchTest * * @throws Exception */ -// @Test(groups= {TestGroup.REST_API, TestGroup.SEARCH}) + @Test(groups= {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1}) public void search() throws Exception { String uuid = file1.getNodeRefWithoutVersion(); @@ -99,12 +99,13 @@ public class FingerPrintTest extends AbstractSearchTest m.getModel().assertThat().field("name").isNot("cars.txt"); } } -// @Test(groups= {TestGroup.REST_API, TestGroup.SEARCH}) + @Test(groups= {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1}) public void searchSimilar() throws Exception { String uuid = file2.getNodeRefWithoutVersion(); Assert.assertNotNull(uuid); - String fingerprint = String.format("FINGERPRINT:%s_68", uuid); + // In the response eneity there is a score of each doc, change below threshold to bring more like or less. + String fingerprint = String.format("FINGERPRINT:%s_68", uuid); SearchResponse response = query(fingerprint); int count = response.getEntries().size(); Assert.assertTrue(count > 1); @@ -125,7 +126,7 @@ public class FingerPrintTest extends AbstractSearchTest m.getModel().assertThat().field("name").isNot("cars.txt"); } } -// @Test(groups= {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ass}) + @Test(groups= {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1}) public void searchSimilar67Percent() throws Exception { String uuid = file2.getNodeRefWithoutVersion(); diff --git a/e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java b/e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java new file mode 100644 index 000000000..78647cbf9 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java @@ -0,0 +1,168 @@ +/* + * Copyright (C) 2017 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.rest.search; + +import java.util.ArrayList; +import java.util.List; + +import org.alfresco.rest.model.RestRequestFacetFieldsModel; +import org.alfresco.utility.model.TestGroup; +import org.testng.Assert; +import org.testng.annotations.Test; + +/** + * Tests the search functionality using an ancestor path. + * Using the category as an example, it is a node that is located + * in root/rootCategory/classifiable. We now provide the ability to search by path + * so that we can return all the child elements of our target path. + * A search on root/rootCategory/classifiable should return Regions, Languages + * as they are the child elements of the given path. + * + * @author Michael Suzuki + * + */ +public class SearchAPATHTest extends AbstractSearchTest +{ + + @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_1}) + /** + * { + * "query": { + * "query": "name:*" + * }, + * "facetFields": { + * "facets": [ + * {"field": "APATH", "prefix": "0" } + * ] + * } + * } + * Expected result + * entries[], + * "pagination": { + * "maxItems": 100, + * "hasMoreItems": true, + * "totalItems": 914, + * "count": 100, + * "skipCount": 0 + * }, + * "context": { + * "facetsFields": [{ + * "buckets": [ + * { + * "count": 913, + * "label": "0/5c09534f-3ca2-4272-bc25-064a7c1762b4" + * }, + * { + * "count": 2, + * "label": "0/" + * } + * ], + * "label": "APATH" + * }], + * "consistency": {"lastTxId": 89} + * } + *}} + * + */ + public void searchLevel0() throws Exception + { + SearchRequest searchQuery = new SearchRequest(); + RestRequestQueryModel queryReq = new RestRequestQueryModel(); + queryReq.setQuery("name:*"); + searchQuery.setQuery(queryReq); + + RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); + List list = new ArrayList(); + list.add(new FacetFieldQuery("APATH","0")); + facetFields.setFacets(list); + searchQuery.setFacetFields(facetFields); + SearchResponse response = query(searchQuery); + FacetFieldResponse fresponse = response.getContext().getFacetsFields().get(0); + fresponse.assertThat().field("buckets").isNotEmpty(); + Assert.assertEquals(2,fresponse.getBuckets().size()); + fresponse.getBuckets().get(0).assertThat().field("label").contains("0/"); + fresponse.getBuckets().get(1).assertThat().field("label").is("0/"); + } + @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_1}) + public void searchLevel0andIncludeSubLevel1() throws Exception + { + SearchRequest searchQuery = new SearchRequest(); + RestRequestQueryModel queryReq = new RestRequestQueryModel(); + queryReq.setQuery("name:*"); + searchQuery.setQuery(queryReq); + + RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); + List list = new ArrayList(); + list.add(new FacetFieldQuery("APATH","1")); + facetFields.setFacets(list); + searchQuery.setFacetFields(facetFields); + SearchResponse response = query(searchQuery); + FacetFieldResponse fresponse = response.getContext().getFacetsFields().get(0); + Assert.assertEquals(4,fresponse.getBuckets().size()); + fresponse.getBuckets().get(0).assertThat().field("label").contains("1/"); + } + @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_1}) + public void searchLevel2() throws Exception + { + SearchRequest searchQuery = new SearchRequest(); + RestRequestQueryModel queryReq = new RestRequestQueryModel(); + queryReq.setQuery("name:*"); + searchQuery.setQuery(queryReq); + + RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); + List list = new ArrayList(); + list.add(new FacetFieldQuery("APATH","1/")); + facetFields.setFacets(list); + searchQuery.setFacetFields(facetFields); + + SearchResponse response = query(searchQuery); + FacetFieldResponse fresponse = response.getContext().getFacetsFields().get(0); + String path = fresponse.getBuckets().get(0).getLabel().replace("1/", "2/"); + list.remove(0); + list.add(new FacetFieldQuery("APATH", path)); + + facetFields.setFacets(list); + searchQuery.setFacetFields(facetFields); + response = query(searchQuery); + fresponse = response.getContext().getFacetsFields().get(0); + Assert.assertEquals(fresponse.getBuckets().size(),3); + fresponse.getBuckets().get(0).assertThat().field("label").contains("2/"); + fresponse.getBuckets().get(0).assertThat().field("label").contains(path); + /** + * To return the contents of the path and its sub directory change the prefix + * Below 2/path/path -> will return whats in path/path only + * if 3/path/path -> will return contents from path/path/path + * @throws Exception + */ + searchQuery = new SearchRequest(); + queryReq = new RestRequestQueryModel(); + queryReq.setQuery("name:*"); + searchQuery.setQuery(queryReq); + facetFields = new RestRequestFacetFieldsModel(); + list.remove(0); + list.add(new FacetFieldQuery("APATH",path.replace("2/", "3/"))); + facetFields.setFacets(list); + searchQuery.setFacetFields(facetFields); + response = query(searchQuery); + fresponse = response.getContext().getFacetsFields().get(0); + System.out.println(response); + Assert.assertTrue(fresponse.getBuckets().size() > 5); + fresponse.getBuckets().get(0).assertThat().field("label").contains("3/"); + } +} From e5eb2817b2896b94f7eb3e2cd78c34ec880658cf Mon Sep 17 00:00:00 2001 From: Gethin James Date: Fri, 10 Mar 2017 13:20:15 +0100 Subject: [PATCH 1112/1491] Renaming to facetsFields after merge --- .../java/org/alfresco/rest/search/SearchAPATHTest.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java b/e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java index 01ee183e7..3ed0bbb04 100644 --- a/e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java +++ b/e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java @@ -92,7 +92,7 @@ public class SearchAPATHTest extends AbstractSearchTest facetFields.setFacets(list); searchQuery.setFacetFields(facetFields); SearchResponse response = query(searchQuery); - RestResultBucketsModel fresponse = response.getContext().getFacetFields().get(0); + RestResultBucketsModel fresponse = response.getContext().getFacetsFields().get(0); fresponse.assertThat().field("buckets").isNotEmpty(); Assert.assertEquals(2,fresponse.getBuckets().size()); fresponse.getBuckets().get(0).assertThat().field("label").contains("0/"); @@ -112,7 +112,7 @@ public class SearchAPATHTest extends AbstractSearchTest facetFields.setFacets(list); searchQuery.setFacetFields(facetFields); SearchResponse response = query(searchQuery); - RestResultBucketsModel fresponse = response.getContext().getFacetFields().get(0); + RestResultBucketsModel fresponse = response.getContext().getFacetsFields().get(0); Assert.assertEquals(4,fresponse.getBuckets().size()); fresponse.getBuckets().get(0).assertThat().field("label").contains("1/"); } @@ -131,7 +131,7 @@ public class SearchAPATHTest extends AbstractSearchTest searchQuery.setFacetFields(facetFields); SearchResponse response = query(searchQuery); - RestResultBucketsModel fresponse = response.getContext().getFacetFields().get(0); + RestResultBucketsModel fresponse = response.getContext().getFacetsFields().get(0); String path = fresponse.getBuckets().get(0).getLabel().replace("1/", "2/"); list.remove(0); list.add(new FacetFieldQuery("APATH", path)); @@ -139,7 +139,7 @@ public class SearchAPATHTest extends AbstractSearchTest facetFields.setFacets(list); searchQuery.setFacetFields(facetFields); response = query(searchQuery); - fresponse = response.getContext().getFacetFields().get(0); + fresponse = response.getContext().getFacetsFields().get(0); Assert.assertEquals(fresponse.getBuckets().size(),3); fresponse.getBuckets().get(0).assertThat().field("label").contains("2/"); fresponse.getBuckets().get(0).assertThat().field("label").contains(path); @@ -159,7 +159,7 @@ public class SearchAPATHTest extends AbstractSearchTest facetFields.setFacets(list); searchQuery.setFacetFields(facetFields); response = query(searchQuery); - fresponse = response.getContext().getFacetFields().get(0); + fresponse = response.getContext().getFacetsFields().get(0); System.out.println(response); Assert.assertTrue(fresponse.getBuckets().size() > 5); fresponse.getBuckets().get(0).assertThat().field("label").contains("3/"); From 516471f9cf110b471d9c25ef4a97bbfe038449a4 Mon Sep 17 00:00:00 2001 From: Gethin James Date: Fri, 10 Mar 2017 13:47:28 +0100 Subject: [PATCH 1113/1491] SEARCH-339: Adding tests to ASS_1 group --- .../org/alfresco/rest/search/FacetIntervalSearchTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/FacetIntervalSearchTest.java b/e2e-test/java/org/alfresco/rest/search/FacetIntervalSearchTest.java index cee1c67d0..8d82324eb 100644 --- a/e2e-test/java/org/alfresco/rest/search/FacetIntervalSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FacetIntervalSearchTest.java @@ -36,7 +36,7 @@ import java.util.List; public class FacetIntervalSearchTest extends AbstractSearchTest { - @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API }) + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_1 }) public void testValidation() throws Exception { SearchRequest query = carsQuery(); @@ -68,7 +68,7 @@ public class FacetIntervalSearchTest extends AbstractSearchTest } - @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API }) + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_1 }) public void searchWithBasicInterval() throws Exception { SearchRequest query = carsQuery(); @@ -108,7 +108,7 @@ public class FacetIntervalSearchTest extends AbstractSearchTest } - @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API }) + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_1 }) public void searchWithDates() throws Exception { SearchRequest query = carsQuery(); From 50e58a76b6e75838588444ba79a86d54dd491833 Mon Sep 17 00:00:00 2001 From: Gethin James Date: Fri, 10 Mar 2017 14:19:44 +0100 Subject: [PATCH 1114/1491] SEARCH-339: Adding testrail groups --- .../rest/search/FacetIntervalSearchTest.java | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/FacetIntervalSearchTest.java b/e2e-test/java/org/alfresco/rest/search/FacetIntervalSearchTest.java index 8d82324eb..5b66fbcb2 100644 --- a/e2e-test/java/org/alfresco/rest/search/FacetIntervalSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FacetIntervalSearchTest.java @@ -20,13 +20,13 @@ package org.alfresco.rest.search; import org.alfresco.rest.model.RestErrorModel; 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.Assert; import org.testng.annotations.Test; -import java.util.ArrayList; import java.util.Arrays; -import java.util.List; /** * Faceted Intervals Search Test @@ -36,8 +36,10 @@ import java.util.List; public class FacetIntervalSearchTest extends AbstractSearchTest { - @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_1 }) - public void testValidation() throws Exception + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, + description = "Check facet intervals mandatory fields") + public void checkingFacetsMandatoryErrorMessages()throws Exception { SearchRequest query = carsQuery(); @@ -68,8 +70,10 @@ public class FacetIntervalSearchTest extends AbstractSearchTest } - @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_1 }) - public void searchWithBasicInterval() throws Exception + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, + description = "Check basic facet intervals search api") + public void searchWithBasicInterval()throws Exception { SearchRequest query = carsQuery(); @@ -108,7 +112,9 @@ public class FacetIntervalSearchTest extends AbstractSearchTest } - @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_1 }) + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, + description = "Check date facet intervals search api") public void searchWithDates() throws Exception { SearchRequest query = carsQuery(); From 2174dc9cc60506b36a2433b28d24211a980a2ba7 Mon Sep 17 00:00:00 2001 From: Gethin James Date: Fri, 10 Mar 2017 15:25:20 +0100 Subject: [PATCH 1115/1491] Adding testrail groups --- .../java/org/alfresco/rest/search/FacetedSearchTest.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java b/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java index 7c3478817..4da544b17 100644 --- a/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java @@ -22,6 +22,8 @@ import java.util.ArrayList; import java.util.List; import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; import org.testng.annotations.Test; /** @@ -31,8 +33,10 @@ import org.testng.annotations.Test; */ public class FacetedSearchTest extends AbstractSearchTest { - - @Test(groups={TestGroup.SEARCH, TestGroup.REST_API}) + + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH }, executionType = ExecutionType.REGRESSION, + description = "Checks facet queries for the Search api") /** * Perform the below facet query. * { From dd447377112ffe1ee290dd151e8725bd8e18027e Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Mon, 13 Mar 2017 12:02:15 +0200 Subject: [PATCH 1116/1491] Update REST-API assertion of "equals" to "is" --- .../rest/favorites/GetFavoriteCoreTests.java | 6 ++-- .../rest/favorites/GetFavoriteFullTests.java | 7 ++-- .../favorites/GetFavoriteSanityTests.java | 32 +++++++++---------- .../rest/nodes/NodesChildrenTests.java | 11 +++---- .../org/alfresco/rest/nodes/NodesTests.java | 2 +- .../deployments/GetDeploymentSanityTests.java | 2 +- 6 files changed, 28 insertions(+), 32 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteCoreTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteCoreTests.java index e078d9bda..f1e161d04 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteCoreTests.java @@ -73,8 +73,6 @@ public class GetFavoriteCoreTests extends RestTest { .statusCodeIs(HttpStatus.BAD_REQUEST); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify get favorite site when favorite id does't exist") @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) @@ -115,7 +113,7 @@ public class GetFavoriteCoreTests extends RestTest { RestPersonFavoritesModel favoriteSite = restClient.withCoreAPI().usingMe().getFavorite(siteModel.getGuid()); restClient.assertStatusCodeIs(HttpStatus.OK); - favoriteSite.assertThat().field("targetGuid").equals(siteModel.getGuid()); + favoriteSite.assertThat().field("targetGuid").is(siteModel.getGuid()); } @TestRail(section = { TestGroup.REST_API, @@ -127,6 +125,6 @@ public class GetFavoriteCoreTests extends RestTest { RestPersonFavoritesModel favoriteFile = restClient.withCoreAPI().usingMe().getFavorite(fileModel.getNodeRefWithoutVersion()); restClient.assertStatusCodeIs(HttpStatus.OK); - favoriteFile.assertThat().field("targetGuid").equals(fileModel.getNodeRef()); + favoriteFile.assertThat().field("targetGuid").is(fileModel.getNodeRefWithoutVersion()); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteFullTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteFullTests.java index c7c68feba..8e4b24b9b 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteFullTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteFullTests.java @@ -42,7 +42,6 @@ public class GetFavoriteFullTests extends RestTest { usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); } - @Bug(id = "MNT-16904") @TestRail(section = { TestGroup.REST_API, @@ -93,9 +92,9 @@ public class GetFavoriteFullTests extends RestTest { RestPersonFavoritesModel favoriteSite = restClient.withCoreAPI().usingUser(adminUserModel).getFavorite(siteModel.getGuid()); restClient.assertStatusCodeIs(HttpStatus.OK); - favoriteSite.assertThat().field("targetGuid").equals(siteModel.getGuid()); + favoriteSite.assertThat().field("targetGuid").is(siteModel.getGuid()); favoriteSite.getTarget().getSite() - .assertThat().field("guid").equals(siteModel.getGuid()); + .assertThat().field("guid").is(siteModel.getGuid()); } @@ -111,7 +110,7 @@ public class GetFavoriteFullTests extends RestTest { RestPersonFavoritesModel favoriteSite = restClient.authenticateUser(manager).withParams("properties=targetGuid") .withCoreAPI().usingAuthUser().getFavorite(siteModel.getGuid()); restClient.assertStatusCodeIs(HttpStatus.OK); - favoriteSite.assertThat().field("targetGuid").equals(siteModel.getGuid()); + favoriteSite.assertThat().field("targetGuid").is(siteModel.getGuid()); favoriteSite.assertThat().fieldsCount().is(1); } diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java index 86de14f71..e0c4e61c8 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java @@ -49,7 +49,7 @@ public class GetFavoriteSanityTests extends RestTest RestPersonFavoritesModel favoriteSite = restClient.withCoreAPI().usingUser(adminUserModel).getFavorite(siteModel.getGuid()); restClient.assertStatusCodeIs(HttpStatus.OK); - favoriteSite.assertThat().field("targetGuid").equals(siteModel.getGuid()); + favoriteSite.assertThat().field("targetGuid").is(siteModel.getGuid()); } @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, @@ -61,7 +61,7 @@ public class GetFavoriteSanityTests extends RestTest RestPersonFavoritesModel favoriteFolder = restClient.withCoreAPI().usingUser(adminUserModel).getFavorite(folderModel.getNodeRef()); restClient.assertStatusCodeIs(HttpStatus.OK); - favoriteFolder.assertThat().field("targetGuid").equals(folderModel.getNodeRef()); + favoriteFolder.assertThat().field("targetGuid").is(folderModel.getNodeRef()); } @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, @@ -73,7 +73,7 @@ public class GetFavoriteSanityTests extends RestTest RestPersonFavoritesModel favoriteFile = restClient.withCoreAPI().usingUser(adminUserModel).getFavorite(fileModel.getNodeRefWithoutVersion()); restClient.assertStatusCodeIs(HttpStatus.OK); - favoriteFile.assertThat().field("targetGuid").equals(fileModel.getNodeRef()); + favoriteFile.assertThat().field("targetGuid").is(fileModel.getNodeRefWithoutVersion()); } @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, @@ -86,7 +86,7 @@ public class GetFavoriteSanityTests extends RestTest RestPersonFavoritesModel favSite = restClient.withCoreAPI().usingAuthUser().getFavorite(siteModel.getGuid()); restClient.assertStatusCodeIs(HttpStatus.OK); - favSite.assertThat().field("targetGuid").equals(siteModel.getGuid()); + favSite.assertThat().field("targetGuid").is(siteModel.getGuid()); } @@ -100,7 +100,7 @@ public class GetFavoriteSanityTests extends RestTest RestPersonFavoritesModel favoriteFolder = restClient.withCoreAPI().usingAuthUser().getFavorite(folderModel.getNodeRef()); restClient.assertStatusCodeIs(HttpStatus.OK); - favoriteFolder.assertThat().field("targetGuid").equals(folderModel.getNodeRef()); + favoriteFolder.assertThat().field("targetGuid").is(folderModel.getNodeRef()); } @@ -114,7 +114,7 @@ public class GetFavoriteSanityTests extends RestTest RestPersonFavoritesModel favoriteFile = restClient.withCoreAPI().usingAuthUser().getFavorite(fileModel.getNodeRefWithoutVersion()); restClient.assertStatusCodeIs(HttpStatus.OK); - favoriteFile.assertThat().field("targetGuid").equals(fileModel.getNodeRef()); + favoriteFile.assertThat().field("targetGuid").is(fileModel.getNodeRefWithoutVersion()); } @@ -128,7 +128,7 @@ public class GetFavoriteSanityTests extends RestTest RestPersonFavoritesModel favSite = restClient.withCoreAPI().usingAuthUser().getFavorite(siteModel.getGuid()); restClient.assertStatusCodeIs(HttpStatus.OK); - favSite.assertThat().field("targetGuid").equals(siteModel.getGuid()); + favSite.assertThat().field("targetGuid").is(siteModel.getGuid()); } @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, @@ -141,7 +141,7 @@ public class GetFavoriteSanityTests extends RestTest RestPersonFavoritesModel favoriteFolder = restClient.withCoreAPI().usingAuthUser().getFavorite(folderModel.getNodeRef()); restClient.assertStatusCodeIs(HttpStatus.OK); - favoriteFolder.assertThat().field("targetGuid").equals(folderModel.getNodeRef()); + favoriteFolder.assertThat().field("targetGuid").is(folderModel.getNodeRef()); } @@ -155,7 +155,7 @@ public class GetFavoriteSanityTests extends RestTest RestPersonFavoritesModel favoriteFile = restClient.withCoreAPI().usingAuthUser().getFavorite(fileModel.getNodeRefWithoutVersion()); restClient.assertStatusCodeIs(HttpStatus.OK); - favoriteFile.assertThat().field("targetGuid").equals(fileModel.getNodeRef()); + favoriteFile.assertThat().field("targetGuid").is(fileModel.getNodeRefWithoutVersion()); } @@ -169,7 +169,7 @@ public class GetFavoriteSanityTests extends RestTest RestPersonFavoritesModel favSite = restClient.withCoreAPI().usingAuthUser().getFavorite(siteModel.getGuid()); restClient.assertStatusCodeIs(HttpStatus.OK); - favSite.assertThat().field("targetGuid").equals(siteModel.getGuid()); ; + favSite.assertThat().field("targetGuid").is(siteModel.getGuid()); ; } @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, @@ -182,7 +182,7 @@ public class GetFavoriteSanityTests extends RestTest RestPersonFavoritesModel favoriteFolder = restClient.withCoreAPI().usingAuthUser().getFavorite(folderModel.getNodeRef()); restClient.assertStatusCodeIs(HttpStatus.OK); - favoriteFolder.assertThat().field("targetGuid").equals(folderModel.getNodeRef()); + favoriteFolder.assertThat().field("targetGuid").is(folderModel.getNodeRef()); } @@ -196,7 +196,7 @@ public class GetFavoriteSanityTests extends RestTest RestPersonFavoritesModel favoriteFile = restClient.withCoreAPI().usingAuthUser().getFavorite(fileModel.getNodeRefWithoutVersion()); restClient.assertStatusCodeIs(HttpStatus.OK); - favoriteFile.assertThat().field("targetGuid").equals(fileModel.getNodeRef()); + favoriteFile.assertThat().field("targetGuid").is(fileModel.getNodeRefWithoutVersion()); } @@ -210,7 +210,7 @@ public class GetFavoriteSanityTests extends RestTest RestPersonFavoritesModel favSite = restClient.withCoreAPI().usingAuthUser().getFavorite(siteModel.getGuid()); restClient.assertStatusCodeIs(HttpStatus.OK); - favSite.assertThat().field("targetGuid").equals(siteModel.getGuid()); + favSite.assertThat().field("targetGuid").is(siteModel.getGuid()); } @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, @@ -223,7 +223,7 @@ public class GetFavoriteSanityTests extends RestTest RestPersonFavoritesModel favoriteFolder = restClient.withCoreAPI().usingAuthUser().getFavorite(folderModel.getNodeRef()); restClient.assertStatusCodeIs(HttpStatus.OK); - favoriteFolder.assertThat().field("targetGuid").equals(folderModel.getNodeRef()); + favoriteFolder.assertThat().field("targetGuid").is(folderModel.getNodeRef()); } @@ -237,7 +237,7 @@ public class GetFavoriteSanityTests extends RestTest RestPersonFavoritesModel favoriteFile = restClient.withCoreAPI().usingAuthUser().getFavorite(fileModel.getNodeRefWithoutVersion()); restClient.assertStatusCodeIs(HttpStatus.OK); - favoriteFile.assertThat().field("targetGuid").equals(fileModel.getNodeRef()); + favoriteFile.assertThat().field("targetGuid").is(fileModel.getNodeRefWithoutVersion()); } @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, @@ -290,4 +290,4 @@ public class GetFavoriteSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) .assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } -} +} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/nodes/NodesChildrenTests.java b/e2e-test/java/org/alfresco/rest/nodes/NodesChildrenTests.java index c981cc2dd..270ba6595 100644 --- a/e2e-test/java/org/alfresco/rest/nodes/NodesChildrenTests.java +++ b/e2e-test/java/org/alfresco/rest/nodes/NodesChildrenTests.java @@ -75,7 +75,7 @@ public class NodesChildrenTests extends RestTest .folder("F3") .file("f1") .file("f2") - .file("f2"); + .file("f3"); RestNodeModelsCollection returnedFiles = restClient.withParams("maxItems=2", "skipCount=1", @@ -84,12 +84,11 @@ public class NodesChildrenTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); /* - * Then I receive file2 and file3 - * - */ + * Then I receive file2 and file3 + */ returnedFiles.assertThat().entriesListCountIs(2); - returnedFiles.getEntries().get(0).onModel().assertThat().field("id").equals(nodesBuilder.getNode("F2").getId()); - returnedFiles.getEntries().get(1).onModel().assertThat().field("id").equals(nodesBuilder.getNode("F3").getId()); + returnedFiles.getEntries().get(0).onModel().assertThat().field("id").is(nodesBuilder.getNode("f2").getId()); + returnedFiles.getEntries().get(1).onModel().assertThat().field("id").is(nodesBuilder.getNode("f3").getId()); } } diff --git a/e2e-test/java/org/alfresco/rest/nodes/NodesTests.java b/e2e-test/java/org/alfresco/rest/nodes/NodesTests.java index b7b0efc5c..eb4c25846 100644 --- a/e2e-test/java/org/alfresco/rest/nodes/NodesTests.java +++ b/e2e-test/java/org/alfresco/rest/nodes/NodesTests.java @@ -51,6 +51,6 @@ public class NodesTests extends RestTest * - destinationFolder * - file */ - response.assertThat().field("parentId").equals(destinationFolder.getId()); + response.assertThat().field("parentId").is(destinationFolder.getId()); } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentSanityTests.java index 3259dbb1c..67bda8b8a 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentSanityTests.java @@ -42,7 +42,7 @@ public class GetDeploymentSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); actualDeployment.assertThat().field("deployedAt").isNotEmpty() .and().field("name").is(expectedDeployment.getName()) - .and().field("id").equals(expectedDeployment.getId()); + .and().field("id").is(expectedDeployment.getId()); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, From b816a04a0cbdd92d2dde6aabac00794ffe5e9243 Mon Sep 17 00:00:00 2001 From: Michael Suzuki Date: Mon, 13 Mar 2017 11:09:03 +0000 Subject: [PATCH 1117/1491] added comments --- .../org/alfresco/rest/search/FacetedSearchTest.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java b/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java index 4da544b17..3e61dad1e 100644 --- a/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java @@ -77,7 +77,15 @@ public class FacetedSearchTest extends AbstractSearchTest * "count": 0, * "label": "medium" * } - * ] + * ], + * //Added below as part of SEARCH-374 + * "facetsFields": [ + * { "label": "woof", + * "buckets": [ + * { "label": "CreatedThisYear", "count": 75, "filterQuery": "created:2017"}, + * { "label": "CreatedLastYear", "count": 75, "filterQuery": "created:2016"} + * ] + * } * } * }} * @throws Exception From 4cd17d21f3358c0522c0eb5181ae785e4804604c Mon Sep 17 00:00:00 2001 From: Michael Suzuki Date: Mon, 13 Mar 2017 13:25:43 +0000 Subject: [PATCH 1118/1491] Adding test for grouping facets --- .../rest/search/FacetedSearchTest.java | 97 ++++++++++++++++--- 1 file changed, 85 insertions(+), 12 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java b/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java index 3e61dad1e..8ce825fcd 100644 --- a/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java @@ -24,6 +24,7 @@ import java.util.List; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; +import org.testng.Assert; import org.testng.annotations.Test; /** @@ -67,25 +68,20 @@ public class FacetedSearchTest extends AbstractSearchTest * "facetQueries": [ * { * "count": 61, - * "label": "small" + * "label": "small", + * "filterQuery": "content.size:[o TO 102400]" * }, * { * "count": 0, - * "label": "large" + * "label": "large", + * "filterQuery": "content.size:[o TO 102400]" * }, * { * "count": 0, - * "label": "medium" + * "label": "medium", + * "filterQuery": "content.size:[o TO 102400]" * } - * ], - * //Added below as part of SEARCH-374 - * "facetsFields": [ - * { "label": "woof", - * "buckets": [ - * { "label": "CreatedThisYear", "count": 75, "filterQuery": "created:2017"}, - * { "label": "CreatedLastYear", "count": 75, "filterQuery": "created:2016"} - * ] - * } + * ] * } * }} * @throws Exception @@ -122,6 +118,83 @@ public class FacetedSearchTest extends AbstractSearchTest response.getContext().getFacetQueries().get(2).assertThat().field("label").contains("medium") .and().field("count").isLessThan(1) .and().field("filterQuery").is("content.size:[102400 TO 1048576]"); + //We don't expect to see the FacetFields if group is being used. + Assert.assertNull(response.getContext().getFacetsFields()); + Assert.assertNull(response.getContext().getFacetIntervals()); + } + /** + * * Perform a group by faceting, below test groups the facet by group name foo. + * { + * "query": { + * "query": "cars", + * "language": "afts" + * }, + * "facetQueries": [ + * {"query": "content.size:[o TO 102400]", "label": "small","group":"foo"}, + * {"query": "content.size:[102400 TO 1048576]", "label": "medium","group":"foo"}, + * {"query": "content.size:[1048576 TO 16777216]", "label": "large","group":"foo"} + * ], + * "facetFields": {"facets": [{"field": "'content.size'"}]} + * } + * + * Expected response + * {"list": { + * "entries": [... All the results], + * "pagination": { + * "maxItems": 100, + * "hasMoreItems": false, + * "totalItems": 61, + * "count": 61, + * "skipCount": 0 + * }, + * "context": { + * "consistency": {"lastTxId": 512}, + * //Added below as part of SEARCH-374 + * "facetsFields": [ + * { "label": "foo", + * "buckets": [ + * { "label": "small", "count": 61, "filterQuery": "content.size:[o TO 102400]"}, + * { "label": "large", "count": 0, "filterQuery": "content.size:[1048576 TO 16777216]"}, + * { "label": "medium", "count": 61, "filterQuery": "content.size:[102400 TO 1048576]"} + * ] + * } + * } + * }} + * @throws Exception + */ + public void searchFacetGroup() throws Exception + { + SearchRequest query = new SearchRequest(); + RestRequestQueryModel queryReq = new RestRequestQueryModel(); + queryReq.setQuery("cars"); + query.setQuery(queryReq); + + List facets = new ArrayList(); + facets.add(new FacetQuery("content.size:[0 TO 102400]", "small", "foo")); + facets.add(new FacetQuery("content.size:[102400 TO 1048576]", "medium","foo")); + facets.add(new FacetQuery("content.size:[1048576 TO 16777216]", "large","foo")); + query.setFacetQueries(facets); + + RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); + List list = new ArrayList(); + list.add(new FacetFieldQuery("'content.size'")); + facetFields.setFacets(list); + + query.setFacetFields(facetFields); + + SearchResponse response = query(query); + //We don't expect to see the FacetQueries if group is being used. + Assert.assertTrue(response.getContext().getFacetQueries().isEmpty()); + //Validate the facet field structure is correct. + Assert.assertFalse(response.getContext().getFacetsFields().isEmpty()); + RestResultBucketsModel bucket = response.getContext().getFacetsFields().get(0); + bucket.assertThat().field("label").isNotEmpty(); + bucket.assertThat().field("count").isNotEmpty(); + bucket.assertThat().field("filterQuery").isNotEmpty(); + Assert.assertEquals(bucket.getLabel(), "foo"); + bucket.assertThat().field("label").contains("small").and().field("filterQuery").is("content.size:[0 TO 102400]"); + bucket.assertThat().field("label").contains("medium").and().field("filterQuery").is("content.size:[1048576 TO 16777216]"); + bucket.assertThat().field("label").contains("large").and().field("filterQuery").is("content.size:[102400 TO 1048576]"); } From c14396f9672cfaa530f8da7baaa3a05a05baa29b Mon Sep 17 00:00:00 2001 From: Mihaela Popa Date: Tue, 14 Mar 2017 15:46:25 +0200 Subject: [PATCH 1119/1491] REPO-2112 / MNT-17545: update test with bug.status.Fixed to not be skipped. Also, removed double quotes from test as a new issue was raised: MNT-17594 RegEx for filename fails / Regular Expression constraints not checked properly --- .../java/org/alfresco/rest/nodes/NodesContentTests.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/nodes/NodesContentTests.java b/e2e-test/java/org/alfresco/rest/nodes/NodesContentTests.java index abc729ab7..73ec6e537 100644 --- a/e2e-test/java/org/alfresco/rest/nodes/NodesContentTests.java +++ b/e2e-test/java/org/alfresco/rest/nodes/NodesContentTests.java @@ -44,7 +44,7 @@ public class NodesContentTests extends RestTest restClient.assertHeaderValueContains("Content-Disposition", String.format("filename=\"%s\"", file1.getName())); } - @Bug(id="REPO-2112") + @Bug(id="MNT-17545", description = "HTTP Header Injection in ContentStreamer", status = Bug.Status.FIXED) @TestRail(section = { TestGroup.REST_API,TestGroup.NODES }, executionType = ExecutionType.REGRESSION, description = "Verify file name with special chars is escaped in Content-Disposition header") @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE}) @@ -53,10 +53,10 @@ public class NodesContentTests extends RestTest char c1 = 127; char c2 = 31; char c3 = 256; - FileModel file = dataContent.usingUser(user2).usingSite(site2).createContent(new FileModel("\ntest\"" + c1 + c2 + c3, FileType.TEXT_PLAIN)); + FileModel file = dataContent.usingUser(user2).usingSite(site2).createContent(new FileModel("\ntest" + c1 + c2 + c3, FileType.TEXT_PLAIN)); restClient.authenticateUser(user2).withCoreAPI().usingNode(file).usingParams("attachment=false").getNodeContent(); restClient.assertStatusCodeIs(HttpStatus.OK); - restClient.assertHeaderValueContains("Content-Disposition","filename=\" test .txt\""); + restClient.assertHeaderValueContains("Content-Disposition","filename=\" test .txt\""); } } From 8f0e7ac4cd987191b69a549dbbb2493ac0774723 Mon Sep 17 00:00:00 2001 From: Gethin James Date: Wed, 15 Mar 2017 13:03:40 +0100 Subject: [PATCH 1120/1491] SEARCH-376: Including the original request in the response --- .../org/alfresco/rest/search/SearchTest.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/search/SearchTest.java b/e2e-test/java/org/alfresco/rest/search/SearchTest.java index 5b989e6c6..ace33e9a1 100644 --- a/e2e-test/java/org/alfresco/rest/search/SearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/SearchTest.java @@ -19,6 +19,8 @@ package org.alfresco.rest.search; 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; @@ -58,4 +60,22 @@ public class SearchTest extends AbstractSearchTest restClient.assertStatusCodeIs(HttpStatus.OK); nodes.assertThat().entriesListIsEmpty(); } + + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, + description = "Checks its possible to include the original request in the response") + public void searchWithRequest() throws Exception + { + SearchRequest query = new SearchRequest(); + RestRequestQueryModel queryReq = new RestRequestQueryModel(); + queryReq.setQuery("fox"); + query.setQuery(queryReq); + query.setIncludeRequest(true); + + SearchResponse response = query(query); + restClient.assertStatusCodeIs(HttpStatus.OK); + + response.getContext().assertThat().field("request").isNotEmpty(); + } + } From 59cfd19e4c1f85461f0d1d802d9db29616c36fe5 Mon Sep 17 00:00:00 2001 From: Michael Suzuki Date: Wed, 15 Mar 2017 16:27:53 +0000 Subject: [PATCH 1121/1491] save local changes --- .../rest/search/FacetedSearchTest.java | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java b/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java index 8ce825fcd..e866286c1 100644 --- a/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java @@ -19,7 +19,10 @@ package org.alfresco.rest.search; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.testrail.ExecutionType; @@ -35,7 +38,7 @@ import org.testng.annotations.Test; public class FacetedSearchTest extends AbstractSearchTest { - @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH }) +// @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH }) @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH }, executionType = ExecutionType.REGRESSION, description = "Checks facet queries for the Search api") /** @@ -99,12 +102,12 @@ public class FacetedSearchTest extends AbstractSearchTest facets.add(new FacetQuery("content.size:[1048576 TO 16777216]", "large")); query.setFacetQueries(facets); - RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); - List list = new ArrayList(); - list.add(new FacetFieldQuery("'content.size'")); - facetFields.setFacets(list); - - query.setFacetFields(facetFields); +// RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); +// List list = new ArrayList(); +// list.add(new FacetFieldQuery("'content.size'")); +// facetFields.setFacets(list); +// +// query.setFacetFields(facetFields); SearchResponse response = query(query); response.assertThat().entriesListIsNotEmpty(); @@ -122,6 +125,9 @@ public class FacetedSearchTest extends AbstractSearchTest Assert.assertNull(response.getContext().getFacetsFields()); Assert.assertNull(response.getContext().getFacetIntervals()); } + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH , TestGroup.ASS_1}) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH ,TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, + description = "Checks facet queries for the Search api") /** * * Perform a group by faceting, below test groups the facet by group name foo. * { @@ -181,8 +187,9 @@ public class FacetedSearchTest extends AbstractSearchTest facetFields.setFacets(list); query.setFacetFields(facetFields); - + System.out.println(query.toJson()); SearchResponse response = query(query); + System.out.println(response); //We don't expect to see the FacetQueries if group is being used. Assert.assertTrue(response.getContext().getFacetQueries().isEmpty()); //Validate the facet field structure is correct. @@ -195,7 +202,6 @@ public class FacetedSearchTest extends AbstractSearchTest bucket.assertThat().field("label").contains("small").and().field("filterQuery").is("content.size:[0 TO 102400]"); bucket.assertThat().field("label").contains("medium").and().field("filterQuery").is("content.size:[1048576 TO 16777216]"); bucket.assertThat().field("label").contains("large").and().field("filterQuery").is("content.size:[102400 TO 1048576]"); - } } From c5b43b21baebd135373f5a80153a654be574c16e Mon Sep 17 00:00:00 2001 From: Michael Suzuki Date: Wed, 15 Mar 2017 17:17:31 +0000 Subject: [PATCH 1122/1491] Made the faceted group test go green --- .../rest/search/FacetedSearchTest.java | 42 +++++++++++-------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java b/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java index e866286c1..5a83de2a4 100644 --- a/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java @@ -19,15 +19,13 @@ package org.alfresco.rest.search; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.testng.Assert; +import org.testng.TestException; import org.testng.annotations.Test; /** @@ -102,13 +100,6 @@ public class FacetedSearchTest extends AbstractSearchTest facets.add(new FacetQuery("content.size:[1048576 TO 16777216]", "large")); query.setFacetQueries(facets); -// RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); -// List list = new ArrayList(); -// list.add(new FacetFieldQuery("'content.size'")); -// facetFields.setFacets(list); -// -// query.setFacetFields(facetFields); - SearchResponse response = query(query); response.assertThat().entriesListIsNotEmpty(); response.getContext().assertThat().field("facetQueries").isNotEmpty(); @@ -166,6 +157,8 @@ public class FacetedSearchTest extends AbstractSearchTest * } * } * }} + * + * * @throws Exception */ public void searchFacetGroup() throws Exception @@ -187,21 +180,34 @@ public class FacetedSearchTest extends AbstractSearchTest facetFields.setFacets(list); query.setFacetFields(facetFields); - System.out.println(query.toJson()); SearchResponse response = query(query); - System.out.println(response); //We don't expect to see the FacetQueries if group is being used. - Assert.assertTrue(response.getContext().getFacetQueries().isEmpty()); + Assert.assertTrue(response.getContext().getFacetQueries() == null); //Validate the facet field structure is correct. Assert.assertFalse(response.getContext().getFacetsFields().isEmpty()); - RestResultBucketsModel bucket = response.getContext().getFacetsFields().get(0); + Assert.assertEquals(response.getContext().getFacetsFields().get(0).getLabel(), "foo"); + FacetFieldBucket bucket = response.getContext().getFacetsFields().get(0).getBuckets().get(0); bucket.assertThat().field("label").isNotEmpty(); bucket.assertThat().field("count").isNotEmpty(); bucket.assertThat().field("filterQuery").isNotEmpty(); - Assert.assertEquals(bucket.getLabel(), "foo"); - bucket.assertThat().field("label").contains("small").and().field("filterQuery").is("content.size:[0 TO 102400]"); - bucket.assertThat().field("label").contains("medium").and().field("filterQuery").is("content.size:[1048576 TO 16777216]"); - bucket.assertThat().field("label").contains("large").and().field("filterQuery").is("content.size:[102400 TO 1048576]"); + response.getContext().getFacetsFields().get(0).getBuckets().forEach(action -> { + switch (action.getLabel()) + { + case "small": + Assert.assertEquals(action.getFilterQuery(), "content.size:[0 TO 102400]"); + break; + case "medium": + Assert.assertEquals(action.getFilterQuery(), "content.size:[102400 TO 1048576]"); + break; + case "large": + Assert.assertEquals(action.getFilterQuery(), "content.size:[1048576 TO 16777216]"); + break; + + default: + throw new TestException("Unexpected value returned"); + } + }); + } } From b17f0bbf8ae66360bb6fb1b6d82c2c5722fd8c22 Mon Sep 17 00:00:00 2001 From: Michael Suzuki Date: Fri, 17 Mar 2017 11:12:15 +0000 Subject: [PATCH 1123/1491] Updated test to include the new faceted groups --- .../java/org/alfresco/rest/search/FacetedSearchTest.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java b/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java index 5a83de2a4..2f6fd696c 100644 --- a/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java @@ -36,7 +36,7 @@ import org.testng.annotations.Test; public class FacetedSearchTest extends AbstractSearchTest { -// @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH }) + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH }) @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH }, executionType = ExecutionType.REGRESSION, description = "Checks facet queries for the Search api") /** @@ -93,12 +93,19 @@ public class FacetedSearchTest extends AbstractSearchTest RestRequestQueryModel queryReq = new RestRequestQueryModel(); queryReq.setQuery("cars"); query.setQuery(queryReq); + List facets = new ArrayList(); facets.add(new FacetQuery("content.size:[0 TO 102400]", "small")); facets.add(new FacetQuery("content.size:[102400 TO 1048576]", "medium")); facets.add(new FacetQuery("content.size:[1048576 TO 16777216]", "large")); query.setFacetQueries(facets); + RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); + List list = new ArrayList(); + list.add(new FacetFieldQuery("'content.size'")); + facetFields.setFacets(list); + query.setFacetFields(facetFields); + query.setIncludeRequest(true); SearchResponse response = query(query); response.assertThat().entriesListIsNotEmpty(); From 33f9ecf194a171a2843bae1e260c8d4ce5c682c2 Mon Sep 17 00:00:00 2001 From: Gethin James Date: Fri, 17 Mar 2017 14:00:51 +0100 Subject: [PATCH 1124/1491] SEARCH-339: Updating the interval tests with new response --- .../rest/search/FacetIntervalSearchTest.java | 37 ++++++++++--------- .../rest/search/FacetedSearchTest.java | 2 +- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/FacetIntervalSearchTest.java b/e2e-test/java/org/alfresco/rest/search/FacetIntervalSearchTest.java index 5b66fbcb2..f472bff18 100644 --- a/e2e-test/java/org/alfresco/rest/search/FacetIntervalSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FacetIntervalSearchTest.java @@ -95,21 +95,22 @@ public class FacetIntervalSearchTest extends AbstractSearchTest SearchResponse response = query(query); response.assertThat().entriesListIsNotEmpty(); - response.getContext().assertThat().field("facetIntervals").isNotEmpty(); - RestResultBucketsModel resultBucketsModel = response.getContext().getFacetIntervals().get(0); + response.getContext().assertThat().field("facets").isNotEmpty(); + RestGenericFacetResponseModel facetResponseModel = response.getContext().getFacets().get(0); - FacetFieldBucket bucket = resultBucketsModel.getBuckets().get(0); - Assert.assertEquals(resultBucketsModel.getBuckets().size(), 2); + RestGenericBucketModel bucket = facetResponseModel.getBuckets().get(0); + Assert.assertEquals(facetResponseModel.getBuckets().size(), 2); bucket.assertThat().field("label").is("aUser"); - bucket.assertThat().field("count").isGreaterThan(1); bucket.assertThat().field("filterQuery").is("creator:[a,user]"); + bucket.getMetrics().get(0).assertThat().field("type").is("count"); + bucket.getMetrics().get(0).assertThat().field("value").contains("{count="); - bucket = resultBucketsModel.getBuckets().get(1); + bucket = facetResponseModel.getBuckets().get(1); bucket.assertThat().field("label").is("theRest"); - bucket.assertThat().field("count").isLessThan(1); bucket.assertThat().field("filterQuery").is("creator:(user,z]"); - + bucket.getMetrics().get(0).assertThat().field("type").is("count"); + bucket.getMetrics().get(0).assertThat().field("value").is("{count=0}"); } @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) @@ -137,23 +138,25 @@ public class FacetIntervalSearchTest extends AbstractSearchTest SearchResponse response = query(query); response.assertThat().entriesListIsNotEmpty(); - response.getContext().assertThat().field("facetIntervals").isNotEmpty(); - RestResultBucketsModel resultBucketsModel = response.getContext().getFacetIntervals().get(0); + response.getContext().assertThat().field("facets").isNotEmpty(); + RestGenericFacetResponseModel facetResponseModel = response.getContext().getFacets().get(0); - resultBucketsModel.assertThat().field("label").is("modified"); - FacetFieldBucket bucket = resultBucketsModel.getBuckets().get(0); - Assert.assertEquals(resultBucketsModel.getBuckets().size(), 2); + facetResponseModel.assertThat().field("label").is("modified"); + RestGenericBucketModel bucket = facetResponseModel.getBuckets().get(0); + Assert.assertEquals(facetResponseModel.getBuckets().size(), 2); bucket.assertThat().field("label").is("From2016"); - bucket.assertThat().field("count").isGreaterThan(1); bucket.assertThat().field("filterQuery").is("cm:modified:[2016,now]"); + bucket.getMetrics().get(0).assertThat().field("type").is("count"); + bucket.getMetrics().get(0).assertThat().field("value").contains("{count="); - bucket = resultBucketsModel.getBuckets().get(1); + + bucket = facetResponseModel.getBuckets().get(1); bucket.assertThat().field("label").is("Before2016"); - bucket.assertThat().field("count").isLessThan(1); bucket.assertThat().field("filterQuery").is("cm:modified:[*,2016)"); - + bucket.getMetrics().get(0).assertThat().field("type").is("count"); + bucket.getMetrics().get(0).assertThat().field("value").is("{count=0}"); } private SearchRequest carsQuery() diff --git a/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java b/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java index 2f6fd696c..6b8424d55 100644 --- a/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java @@ -121,7 +121,7 @@ public class FacetedSearchTest extends AbstractSearchTest .and().field("filterQuery").is("content.size:[102400 TO 1048576]"); //We don't expect to see the FacetFields if group is being used. Assert.assertNull(response.getContext().getFacetsFields()); - Assert.assertNull(response.getContext().getFacetIntervals()); + Assert.assertNull(response.getContext().getFacets()); } @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH , TestGroup.ASS_1}) @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH ,TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, From 20182bc0703e8f6d6a0a3c3c41fd487c75b19053 Mon Sep 17 00:00:00 2001 From: "NESS\\P3700654" Date: Fri, 17 Mar 2017 17:35:59 +0200 Subject: [PATCH 1125/1491] REPO-2090 - Service Pack: MNT-16882: CMIS does not detect text encoding correctly Added a test that creates two files with the specific encoding using the multipart upload (POST nodes/{nodeId}/children}, then using the get on the node (GET nodes/{nodeId}) we verify the encoding (content type). --- .../rest/nodes/NodesContentTests.java | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/nodes/NodesContentTests.java b/e2e-test/java/org/alfresco/rest/nodes/NodesContentTests.java index abc729ab7..3db71ab14 100644 --- a/e2e-test/java/org/alfresco/rest/nodes/NodesContentTests.java +++ b/e2e-test/java/org/alfresco/rest/nodes/NodesContentTests.java @@ -1,9 +1,14 @@ package org.alfresco.rest.nodes; +import static org.alfresco.utility.report.log.Step.STEP; + import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestNodeModel; +import org.alfresco.utility.Utility; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FileType; +import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; @@ -59,4 +64,34 @@ public class NodesContentTests extends RestTest restClient.assertHeaderValueContains("Content-Disposition","filename=\" test .txt\""); } + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.NODES }, executionType = ExecutionType.SANITY, description = "Verify that alfresco returns the correct encoding for files created via REST.") + public void verifyFileEncodingUsingRestAPI() throws Exception + { + STEP("1. Create a folder, two text file templates and define the expected encoding."); + FileModel utf8File = dataContent.usingUser(user1).usingSite(site1).createContent(DocumentType.TEXT_PLAIN); + FileModel iso8859File = dataContent.usingUser(user1).usingSite(site1).createContent(DocumentType.TEXT_PLAIN); + FolderModel folder = dataContent.usingUser(user1).usingSite(site1).createFolder(FolderModel.getRandomFolderModel()); + String utf8Type = "text/plain;charset=UTF-8"; + String iso8859Type = "text/plain;charset=ISO-8859-1"; + + STEP("2. Using multipart data upload (POST nodes/{nodeId}/children) the UTF-8 encoded file."); + restClient.authenticateUser(user1).configureRequestSpec().addMultiPart("filedata", Utility.getResourceTestDataFile("UTF-8FILE.txt")); + RestNodeModel fileNode = restClient.authenticateUser(user1).withCoreAPI().usingNode(folder).createNode(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + utf8File.setNodeRef(fileNode.getId()); + + STEP("3. Using multipart data upload (POST nodes/{nodeId}/children) the ISO-8859-1 file."); + restClient.authenticateUser(user1).configureRequestSpec().addMultiPart("filedata", Utility.getResourceTestDataFile("iso8859File.txt")); + fileNode = restClient.authenticateUser(user1).withCoreAPI().usingNode(folder).createNode(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + iso8859File.setNodeRef(fileNode.getId()); + + STEP("4. Retrieve the nodes and verify that the content type is the expected one (GET nodes/{nodeId})."); + restClient.authenticateUser(user1).withCoreAPI().usingNode(utf8File).getNodeContent().assertThat().contentType(utf8Type); + restClient.authenticateUser(user1).withCoreAPI().usingNode(iso8859File).getNodeContent().assertThat().contentType(iso8859Type); + + } + } From e791e781604c91328236d33e8c33bc85151653b3 Mon Sep 17 00:00:00 2001 From: "NESS\\P3700654" Date: Fri, 17 Mar 2017 18:40:15 +0200 Subject: [PATCH 1126/1491] REPO-2090 - Service Pack: MNT-16882: CMIS does not detect text encoding correctly Removed additional reduntant steps (authentificating multiple times). Instead of creating the two files and the change the nodeRef(with the uploaded one via RestAPI), I`m now just defining the fileModels. --- .../org/alfresco/rest/nodes/NodesContentTests.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/nodes/NodesContentTests.java b/e2e-test/java/org/alfresco/rest/nodes/NodesContentTests.java index 3db71ab14..2945105c5 100644 --- a/e2e-test/java/org/alfresco/rest/nodes/NodesContentTests.java +++ b/e2e-test/java/org/alfresco/rest/nodes/NodesContentTests.java @@ -70,27 +70,27 @@ public class NodesContentTests extends RestTest public void verifyFileEncodingUsingRestAPI() throws Exception { STEP("1. Create a folder, two text file templates and define the expected encoding."); - FileModel utf8File = dataContent.usingUser(user1).usingSite(site1).createContent(DocumentType.TEXT_PLAIN); - FileModel iso8859File = dataContent.usingUser(user1).usingSite(site1).createContent(DocumentType.TEXT_PLAIN); + FileModel utf8File = new FileModel("utf8File",FileType.TEXT_PLAIN); + FileModel iso8859File = new FileModel("iso8859File",FileType.TEXT_PLAIN); FolderModel folder = dataContent.usingUser(user1).usingSite(site1).createFolder(FolderModel.getRandomFolderModel()); String utf8Type = "text/plain;charset=UTF-8"; String iso8859Type = "text/plain;charset=ISO-8859-1"; STEP("2. Using multipart data upload (POST nodes/{nodeId}/children) the UTF-8 encoded file."); restClient.authenticateUser(user1).configureRequestSpec().addMultiPart("filedata", Utility.getResourceTestDataFile("UTF-8FILE.txt")); - RestNodeModel fileNode = restClient.authenticateUser(user1).withCoreAPI().usingNode(folder).createNode(); + RestNodeModel fileNode = restClient.withCoreAPI().usingNode(folder).createNode(); restClient.assertStatusCodeIs(HttpStatus.CREATED); utf8File.setNodeRef(fileNode.getId()); STEP("3. Using multipart data upload (POST nodes/{nodeId}/children) the ISO-8859-1 file."); - restClient.authenticateUser(user1).configureRequestSpec().addMultiPart("filedata", Utility.getResourceTestDataFile("iso8859File.txt")); - fileNode = restClient.authenticateUser(user1).withCoreAPI().usingNode(folder).createNode(); + restClient.configureRequestSpec().addMultiPart("filedata", Utility.getResourceTestDataFile("iso8859File.txt")); + fileNode = restClient.withCoreAPI().usingNode(folder).createNode(); restClient.assertStatusCodeIs(HttpStatus.CREATED); iso8859File.setNodeRef(fileNode.getId()); STEP("4. Retrieve the nodes and verify that the content type is the expected one (GET nodes/{nodeId})."); - restClient.authenticateUser(user1).withCoreAPI().usingNode(utf8File).getNodeContent().assertThat().contentType(utf8Type); - restClient.authenticateUser(user1).withCoreAPI().usingNode(iso8859File).getNodeContent().assertThat().contentType(iso8859Type); + restClient.withCoreAPI().usingNode(utf8File).getNodeContent().assertThat().contentType(utf8Type); + restClient.withCoreAPI().usingNode(iso8859File).getNodeContent().assertThat().contentType(iso8859Type); } From bf97817ad30c7351b6fa2662a2308c73d1195e18 Mon Sep 17 00:00:00 2001 From: Gethin James Date: Thu, 23 Mar 2017 11:45:06 +0100 Subject: [PATCH 1127/1491] Updated the request / response search api model --- .../alfresco/rest/search/FacetedSearchTest.java | 8 ++++---- .../alfresco/rest/search/SearchAPATHTest.java | 16 ++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java b/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java index 6b8424d55..5e334970d 100644 --- a/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java @@ -101,8 +101,8 @@ public class FacetedSearchTest extends AbstractSearchTest facets.add(new FacetQuery("content.size:[1048576 TO 16777216]", "large")); query.setFacetQueries(facets); RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); - List list = new ArrayList(); - list.add(new FacetFieldQuery("'content.size'")); + List list = new ArrayList<>(); + list.add(new RestRequestFacetFieldModel("'content.size'")); facetFields.setFacets(list); query.setFacetFields(facetFields); query.setIncludeRequest(true); @@ -182,8 +182,8 @@ public class FacetedSearchTest extends AbstractSearchTest query.setFacetQueries(facets); RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); - List list = new ArrayList(); - list.add(new FacetFieldQuery("'content.size'")); + List list = new ArrayList<>(); + list.add(new RestRequestFacetFieldModel("'content.size'")); facetFields.setFacets(list); query.setFacetFields(facetFields); diff --git a/e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java b/e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java index 3ed0bbb04..030494997 100644 --- a/e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java +++ b/e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java @@ -87,8 +87,8 @@ public class SearchAPATHTest extends AbstractSearchTest searchQuery.setQuery(queryReq); RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); - List list = new ArrayList(); - list.add(new FacetFieldQuery("APATH","0")); + List list = new ArrayList<>(); + list.add(new RestRequestFacetFieldModel("APATH","0")); facetFields.setFacets(list); searchQuery.setFacetFields(facetFields); SearchResponse response = query(searchQuery); @@ -107,8 +107,8 @@ public class SearchAPATHTest extends AbstractSearchTest searchQuery.setQuery(queryReq); RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); - List list = new ArrayList(); - list.add(new FacetFieldQuery("APATH","1")); + List list = new ArrayList<>(); + list.add(new RestRequestFacetFieldModel("APATH","1")); facetFields.setFacets(list); searchQuery.setFacetFields(facetFields); SearchResponse response = query(searchQuery); @@ -125,8 +125,8 @@ public class SearchAPATHTest extends AbstractSearchTest searchQuery.setQuery(queryReq); RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); - List list = new ArrayList(); - list.add(new FacetFieldQuery("APATH","1/")); + List list = new ArrayList<>(); + list.add(new RestRequestFacetFieldModel("APATH","1/")); facetFields.setFacets(list); searchQuery.setFacetFields(facetFields); @@ -134,7 +134,7 @@ public class SearchAPATHTest extends AbstractSearchTest RestResultBucketsModel fresponse = response.getContext().getFacetsFields().get(0); String path = fresponse.getBuckets().get(0).getLabel().replace("1/", "2/"); list.remove(0); - list.add(new FacetFieldQuery("APATH", path)); + list.add(new RestRequestFacetFieldModel("APATH", path)); facetFields.setFacets(list); searchQuery.setFacetFields(facetFields); @@ -155,7 +155,7 @@ public class SearchAPATHTest extends AbstractSearchTest searchQuery.setQuery(queryReq); facetFields = new RestRequestFacetFieldsModel(); list.remove(0); - list.add(new FacetFieldQuery("APATH",path.replace("2/", "3/"))); + list.add(new RestRequestFacetFieldModel("APATH",path.replace("2/", "3/"))); facetFields.setFacets(list); searchQuery.setFacetFields(facetFields); response = query(searchQuery); From ce5816b5466eb1477ab03736eda18b9fc7b44d7d Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Thu, 23 Mar 2017 15:45:57 +0200 Subject: [PATCH 1128/1491] fix test and update jenkins file to run at 20:00 --- e2e-test/java/org/alfresco/rest/nodes/NodesContentTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/nodes/NodesContentTests.java b/e2e-test/java/org/alfresco/rest/nodes/NodesContentTests.java index 48eab84bb..e65185a58 100644 --- a/e2e-test/java/org/alfresco/rest/nodes/NodesContentTests.java +++ b/e2e-test/java/org/alfresco/rest/nodes/NodesContentTests.java @@ -77,7 +77,7 @@ public class NodesContentTests extends RestTest String iso8859Type = "text/plain;charset=ISO-8859-1"; STEP("2. Using multipart data upload (POST nodes/{nodeId}/children) the UTF-8 encoded file."); - restClient.authenticateUser(user1).configureRequestSpec().addMultiPart("filedata", Utility.getResourceTestDataFile("UTF-8FILE.txt")); + restClient.authenticateUser(user1).configureRequestSpec().addMultiPart("filedata", Utility.getResourceTestDataFile("UTF-8File.txt")); RestNodeModel fileNode = restClient.withCoreAPI().usingNode(folder).createNode(); restClient.assertStatusCodeIs(HttpStatus.CREATED); utf8File.setNodeRef(fileNode.getId()); From f031954e9b70aff42e356d18ea19b3f92d3e4025 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Fri, 24 Mar 2017 12:16:03 +0200 Subject: [PATCH 1129/1491] fix failed tests from Jenkins --- .../rest/favorites/AddFavoritesCoreTests.java | 18 +++++++++++------- .../favorites/DeleteFavoriteSiteFullTests.java | 2 +- .../rest/favorites/GetFavoritesCoreTests.java | 2 +- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesCoreTests.java b/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesCoreTests.java index 08e00885d..d740582e3 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesCoreTests.java @@ -88,9 +88,10 @@ public class AddFavoritesCoreTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) public void addFavoriteTwice() throws Exception { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + SiteModel site = dataSite.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).createPublicRandomSite(); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteToFavorites(site); restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(site); restClient.assertStatusCodeIs(HttpStatus.CONFLICT); } @@ -125,11 +126,13 @@ public class AddFavoritesCoreTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) public void verifyGetFavoritesAfterFavoritingSite() throws Exception { - restPersonFavoritesModel = restClient.authenticateUser(adminUserModel) + UserModel user = dataUser.createRandomTestUser(); + restPersonFavoritesModel = restClient.authenticateUser(user) .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().getFavoriteSites().assertThat().entriesListContains("guid", siteModel.getGuid()); + restClient.authenticateUser(user).withCoreAPI().usingAuthUser().getFavoriteSites() + .assertThat().entriesListContains("guid", siteModel.getGuid()); } @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, @@ -159,15 +162,16 @@ public class AddFavoritesCoreTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) public void userIsAbleToAddFavoriteWhenUsingMeAsUsername() throws Exception { - restPersonFavoritesModel = restClient.authenticateUser(adminUserModel) + UserModel user = dataUser.createRandomTestUser(); + restPersonFavoritesModel = restClient.authenticateUser(user) .withCoreAPI().usingMe().addSiteToFavorites(siteModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); restPersonFavoritesModel.assertThat().field("targetGuid").is(siteModel.getGuid()); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().getFavoriteSites().assertThat().entriesListContains("guid", siteModel.getGuid()); + restClient.authenticateUser(user).withCoreAPI().usingAuthUser().getFavoriteSites().assertThat().entriesListContains("guid", siteModel.getGuid()); } -// @Bug(id = "MNT-17158", description="Not a bug, If we need to stop comments from being favourited then an improvement/enhancement request should be raised against the platform.") +// @Bug(id = "MNT-17158", description="Not a bug, If we need to stop comments from being favorited then an improvement/enhancement request should be raised against the platform.") @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify add file favorite with comment id returns status code 201") @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) diff --git a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteSiteFullTests.java b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteSiteFullTests.java index 486df6394..4a763ab7f 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteSiteFullTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteSiteFullTests.java @@ -91,7 +91,7 @@ public class DeleteFavoriteSiteFullTests extends RestTest public void adminUserRemovesDeletedFavoriteSiteThatIsNotFavorite() throws Exception { siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel); + restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) .assertLastError() diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesCoreTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesCoreTests.java index 9cb4503c8..afd655b53 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesCoreTests.java @@ -124,7 +124,7 @@ public class GetFavoritesCoreTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) public void userIsAbleToRetrieveFavoritesFilesOrSites() throws Exception { - restClient.authenticateUser(adminUserModel); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); restClient.withCoreAPI().usingAuthUser().addFileToFavorites(firstFileModel); restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(firstFolderModel); From 12ffa5642af0d5e6795cbcb12a9e363a79b10276 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Fri, 24 Mar 2017 15:04:52 +0200 Subject: [PATCH 1130/1491] fix Bamboo failed test --- .../rest/workflow/deployments/GetDeploymentCoreTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentCoreTests.java index 0fbad6d14..68dabae09 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentCoreTests.java @@ -54,7 +54,7 @@ public class GetDeploymentCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); actualDeployment.assertThat().field("deployedAt").isNotEmpty() .and().field("name").is(expectedDeployment.getName()) - .and().field("id").equals(expectedDeployment.getId()); + .and().field("id").is(expectedDeployment.getId()); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, From c0d1080bbd156d63b3a5cc43eebd40117ff1130f Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Mon, 27 Mar 2017 16:24:22 +0300 Subject: [PATCH 1131/1491] update rest-suites.xml to exclude ASS_1.0.0 group and include FacetedSearchTest in this group --- e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java b/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java index 4da544b17..46af12765 100644 --- a/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java @@ -34,8 +34,8 @@ import org.testng.annotations.Test; public class FacetedSearchTest extends AbstractSearchTest { - @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH }, executionType = ExecutionType.REGRESSION, + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, description = "Checks facet queries for the Search api") /** * Perform the below facet query. From b2ad73bbe490a5a8b1f0f25f85f25e8ba6930bb6 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Tue, 28 Mar 2017 18:14:13 +0300 Subject: [PATCH 1132/1491] fix test: update the formula to calculate the value of hasMoreItems field --- e2e-test/java/org/alfresco/rest/sites/GetSitesFullTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSitesFullTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSitesFullTests.java index cd189fac9..6b2e1a768 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSitesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSitesFullTests.java @@ -157,7 +157,7 @@ public class GetSitesFullTests extends RestTest sites.getPagination().assertThat() .field("totalItems").isNotEmpty().and() .field("maxItems").is("110").and() - .field("hasMoreItems").is((sites.getPagination().getTotalItems() > sites.getPagination().getMaxItems())?"true":"false").and() + .field("hasMoreItems").is((sites.getPagination().getTotalItems() - sites.getPagination().getSkipCount() > sites.getPagination().getMaxItems())?"true":"false").and() .field("skipCount").is("10").and() .field("count").is((sites.getPagination().isHasMoreItems()) ? sites.getPagination().getMaxItems() : sites.getPagination().getTotalItems() - sites.getPagination().getSkipCount()); From 068dd5011c5b93eb44f989784a22cd26dd39f36a Mon Sep 17 00:00:00 2001 From: Gethin James Date: Mon, 3 Apr 2017 15:21:56 +0200 Subject: [PATCH 1133/1491] SEARCH-334: Adding pivot tests --- .../rest/search/AbstractSearchTest.java | 9 ++ .../rest/search/FacetIntervalSearchTest.java | 8 - .../rest/search/PivotFacetedSearchTest.java | 152 ++++++++++++++++++ 3 files changed, 161 insertions(+), 8 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/search/PivotFacetedSearchTest.java diff --git a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java index 594105873..2bb43effc 100644 --- a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java @@ -111,4 +111,13 @@ public class AbstractSearchTest extends RestTest { return restClient.authenticateUser(dataUser.getAdminUser()).withSearchAPI().search(query); } + + protected SearchRequest carsQuery() + { + SearchRequest query = new SearchRequest(); + RestRequestQueryModel queryReq = new RestRequestQueryModel(); + queryReq.setQuery("cars"); + query.setQuery(queryReq); + return query; + } } diff --git a/e2e-test/java/org/alfresco/rest/search/FacetIntervalSearchTest.java b/e2e-test/java/org/alfresco/rest/search/FacetIntervalSearchTest.java index f472bff18..c32908fd0 100644 --- a/e2e-test/java/org/alfresco/rest/search/FacetIntervalSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FacetIntervalSearchTest.java @@ -159,12 +159,4 @@ public class FacetIntervalSearchTest extends AbstractSearchTest bucket.getMetrics().get(0).assertThat().field("value").is("{count=0}"); } - private SearchRequest carsQuery() - { - SearchRequest query = new SearchRequest(); - RestRequestQueryModel queryReq = new RestRequestQueryModel(); - queryReq.setQuery("cars"); - query.setQuery(queryReq); - return query; - } } diff --git a/e2e-test/java/org/alfresco/rest/search/PivotFacetedSearchTest.java b/e2e-test/java/org/alfresco/rest/search/PivotFacetedSearchTest.java new file mode 100644 index 000000000..87f3f6e64 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/search/PivotFacetedSearchTest.java @@ -0,0 +1,152 @@ +/* + * Copyright (C) 2017 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.rest.search; + +import org.alfresco.rest.model.RestErrorModel; +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.Assert; +import org.testng.TestException; +import org.testng.annotations.Test; + +import java.util.ArrayList; +import java.util.List; + +/** + * Faceted search test. + * @author Gethin James + * + */ +public class PivotFacetedSearchTest extends AbstractSearchTest +{ + + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH }, executionType = ExecutionType.REGRESSION, + description = "Checks errors with pivot using Search api") + public void searchWithPivotingErrors() throws Exception + { + SearchRequest query = carsQuery(); + + RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); + List list = new ArrayList<>(); + list.add(new RestRequestFacetFieldModel("'creator'")); + facetFields.setFacets(list); + query.setFacetFields(facetFields); + query.setIncludeRequest(false); + List pivotModelList = new ArrayList<>(); + RestRequestPivotModel pivots = new RestRequestPivotModel(); + pivotModelList.add(pivots); + query.setPivots(pivotModelList); + + SearchResponse response = query(query); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.MANDATORY_PARAM, "pivot key")); + + + pivots.setKey("none_like_this"); + response = query(query); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary("Pivot parameter none_like_this is does not reference a facet Field"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH }, executionType = ExecutionType.REGRESSION, + description = "Checks with pivot using Search api") + public void searchWithPivoting() throws Exception + { + SearchRequest query = carsQuery(); + + RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); + List list = new ArrayList<>(); + list.add(new RestRequestFacetFieldModel("creator")); + facetFields.setFacets(list); + query.setFacetFields(facetFields); + query.setIncludeRequest(false); + + SearchResponse response = query(query); + response.getContext().assertThat().field("facetsFields").isNotNull(); + + List pivotModelList = new ArrayList<>(); + RestRequestPivotModel pivots = new RestRequestPivotModel(); + pivots.setKey("creator"); + pivotModelList.add(pivots); + query.setPivots(pivotModelList); + response = query(query); + + //Pivot key has matched facet field so there is no longer a facet fields response + assertPivotResponse(response, "creator", null); + } + + private void assertPivotResponse(SearchResponse response, String field, String alabel) throws Exception + { + String label = alabel!=null?alabel:field; + response.getContext().assertThat().field("facetsFields").isNull(); + response.getContext().assertThat().field("facets").isNotEmpty(); + RestGenericFacetResponseModel facetResponseModel = response.getContext().getFacets().get(0); + facetResponseModel.assertThat().field("type").is("pivot"); + facetResponseModel.assertThat().field("label").is(label); + RestGenericBucketModel bucket = facetResponseModel.getBuckets().get(0); + bucket.assertThat().field("label").isNotEmpty(); + bucket.assertThat().field("filterQuery").is(field+":"+bucket.getLabel()); + Assert.assertEquals("count", bucket.getMetrics().get(0).getType()); + Assert.assertTrue(bucket.getMetrics().get(0).getValue().toString().contains("{count=")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH }, executionType = ExecutionType.REGRESSION, + description = "Checks with pivot using Search api and a label as a key") + public void searchWithPivotingUsingLabel() throws Exception + { + SearchRequest query = carsQuery(); + RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); + List list = new ArrayList<>(); + RestRequestFacetFieldModel creatorFacetFieldModel = new RestRequestFacetFieldModel("creator"); + creatorFacetFieldModel.setLabel("create"); + list.add(creatorFacetFieldModel); + RestRequestFacetFieldModel restRequestFacetFieldModel = new RestRequestFacetFieldModel("modifier"); + restRequestFacetFieldModel.setLabel("aLabel"); + list.add(restRequestFacetFieldModel); + facetFields.setFacets(list); + query.setFacetFields(facetFields); + query.setIncludeRequest(false); + RestRequestPivotModel pivots = new RestRequestPivotModel(); + pivots.setKey("create"); + RestRequestPivotModel pivotmod = new RestRequestPivotModel(); + pivotmod.setKey("aLabel"); + + List pivotModelList = new ArrayList<>(); + pivotModelList.add(pivots); + pivotModelList.add(pivotmod); + query.setPivots(pivotModelList); + SearchResponse response = query(query); + assertPivotResponse(response, "creator", "create"); + + //Now check the nesting + RestGenericFacetResponseModel facetResponseModel = response.getContext().getFacets().get(0); + RestGenericFacetResponseModel nestedFacet = facetResponseModel.getBuckets().get(0).getFacets().get(0); + RestGenericBucketModel bucket = nestedFacet.getBuckets().get(0); + nestedFacet.assertThat().field("label").isNotEmpty(); + nestedFacet.assertThat().field("label").is("aLabel"); + bucket.assertThat().field("filterQuery").is("modifier:"+bucket.getLabel()); + Assert.assertEquals("count", bucket.getMetrics().get(0).getType()); + Assert.assertTrue(bucket.getMetrics().get(0).getValue().toString().contains("{count=")); + } +} From 488ecd7ceef15a8d02edb434d8073c870226f7fd Mon Sep 17 00:00:00 2001 From: Michael Suzuki Date: Mon, 3 Apr 2017 16:21:35 +0100 Subject: [PATCH 1134/1491] Change order of test execution to allow time to index data --- e2e-test/java/org/alfresco/rest/search/SearchTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/search/SearchTest.java b/e2e-test/java/org/alfresco/rest/search/SearchTest.java index ace33e9a1..58f5a4199 100644 --- a/e2e-test/java/org/alfresco/rest/search/SearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/SearchTest.java @@ -32,7 +32,7 @@ import org.testng.annotations.Test; public class SearchTest extends AbstractSearchTest { @Test(groups={TestGroup.SEARCH, TestGroup.REST_API}) - public void searchCreatedData() throws Exception + public void searchOnIndexedData() throws Exception { SearchResponse nodes = query("fox"); restClient.assertStatusCodeIs(HttpStatus.OK); From e1d5732e25f7ed0917c59a144fd7033c4ad9cb76 Mon Sep 17 00:00:00 2001 From: Michael Suzuki Date: Fri, 7 Apr 2017 08:15:54 +0100 Subject: [PATCH 1135/1491] Updated test group to ASS 1, as solr 6 is required --- .../rest/search/PivotFacetedSearchTest.java | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/PivotFacetedSearchTest.java b/e2e-test/java/org/alfresco/rest/search/PivotFacetedSearchTest.java index 87f3f6e64..7bf4e1c20 100644 --- a/e2e-test/java/org/alfresco/rest/search/PivotFacetedSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/PivotFacetedSearchTest.java @@ -18,18 +18,17 @@ */ package org.alfresco.rest.search; +import java.util.ArrayList; +import java.util.List; + import org.alfresco.rest.model.RestErrorModel; 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.Assert; -import org.testng.TestException; import org.testng.annotations.Test; -import java.util.ArrayList; -import java.util.List; - /** * Faceted search test. * @author Gethin James @@ -38,8 +37,8 @@ import java.util.List; public class PivotFacetedSearchTest extends AbstractSearchTest { - @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH }, executionType = ExecutionType.REGRESSION, + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH , TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, description = "Checks errors with pivot using Search api") public void searchWithPivotingErrors() throws Exception { @@ -67,8 +66,8 @@ public class PivotFacetedSearchTest extends AbstractSearchTest .containsSummary("Pivot parameter none_like_this is does not reference a facet Field"); } - @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH }, executionType = ExecutionType.REGRESSION, + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, description = "Checks with pivot using Search api") public void searchWithPivoting() throws Exception { @@ -110,8 +109,8 @@ public class PivotFacetedSearchTest extends AbstractSearchTest Assert.assertTrue(bucket.getMetrics().get(0).getValue().toString().contains("{count=")); } - @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH }, executionType = ExecutionType.REGRESSION, + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH , TestGroup.ASS_1}) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH , TestGroup.ASS_1}, executionType = ExecutionType.REGRESSION, description = "Checks with pivot using Search api and a label as a key") public void searchWithPivotingUsingLabel() throws Exception { From 3e0b203e402a4b1a8d118ed8a798e1cbc10a2641 Mon Sep 17 00:00:00 2001 From: Michael Suzuki Date: Fri, 7 Apr 2017 08:23:39 +0100 Subject: [PATCH 1136/1491] Reverted to previous commit, functionality is present in solr4 --- .../alfresco/rest/search/PivotFacetedSearchTest.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/PivotFacetedSearchTest.java b/e2e-test/java/org/alfresco/rest/search/PivotFacetedSearchTest.java index 7bf4e1c20..4f1a8ad09 100644 --- a/e2e-test/java/org/alfresco/rest/search/PivotFacetedSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/PivotFacetedSearchTest.java @@ -37,8 +37,8 @@ import org.testng.annotations.Test; public class PivotFacetedSearchTest extends AbstractSearchTest { - @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH , TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH }, executionType = ExecutionType.REGRESSION, description = "Checks errors with pivot using Search api") public void searchWithPivotingErrors() throws Exception { @@ -66,8 +66,8 @@ public class PivotFacetedSearchTest extends AbstractSearchTest .containsSummary("Pivot parameter none_like_this is does not reference a facet Field"); } - @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH }, executionType = ExecutionType.REGRESSION, description = "Checks with pivot using Search api") public void searchWithPivoting() throws Exception { @@ -109,8 +109,8 @@ public class PivotFacetedSearchTest extends AbstractSearchTest Assert.assertTrue(bucket.getMetrics().get(0).getValue().toString().contains("{count=")); } - @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH , TestGroup.ASS_1}) - @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH , TestGroup.ASS_1}, executionType = ExecutionType.REGRESSION, + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH }, executionType = ExecutionType.REGRESSION, description = "Checks with pivot using Search api and a label as a key") public void searchWithPivotingUsingLabel() throws Exception { From b07f85811f6cb4d38c5d22473e78ec90b2c27700 Mon Sep 17 00:00:00 2001 From: Gethin James Date: Wed, 12 Apr 2017 10:28:54 +0200 Subject: [PATCH 1137/1491] SEARCH-339: Adding afts filterquery --- .../org/alfresco/rest/search/FacetIntervalSearchTest.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/FacetIntervalSearchTest.java b/e2e-test/java/org/alfresco/rest/search/FacetIntervalSearchTest.java index c32908fd0..3c7ccfc0c 100644 --- a/e2e-test/java/org/alfresco/rest/search/FacetIntervalSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FacetIntervalSearchTest.java @@ -101,14 +101,14 @@ public class FacetIntervalSearchTest extends AbstractSearchTest RestGenericBucketModel bucket = facetResponseModel.getBuckets().get(0); Assert.assertEquals(facetResponseModel.getBuckets().size(), 2); bucket.assertThat().field("label").is("aUser"); - bucket.assertThat().field("filterQuery").is("creator:[a,user]"); + bucket.assertThat().field("filterQuery").is("creator:[a TO user]"); bucket.getMetrics().get(0).assertThat().field("type").is("count"); bucket.getMetrics().get(0).assertThat().field("value").contains("{count="); bucket = facetResponseModel.getBuckets().get(1); bucket.assertThat().field("label").is("theRest"); - bucket.assertThat().field("filterQuery").is("creator:(user,z]"); + bucket.assertThat().field("filterQuery").is("creator:"); bucket.getMetrics().get(0).assertThat().field("type").is("count"); bucket.getMetrics().get(0).assertThat().field("value").is("{count=0}"); } From 458ecc1959e3038ec006591747a66697aed573a3 Mon Sep 17 00:00:00 2001 From: Gethin James Date: Mon, 8 May 2017 13:02:08 +0200 Subject: [PATCH 1138/1491] SEARCH-409: Adding stats tests --- .../alfresco/rest/search/StatsSearchTest.java | 309 ++++++++++++++++++ 1 file changed, 309 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/search/StatsSearchTest.java diff --git a/e2e-test/java/org/alfresco/rest/search/StatsSearchTest.java b/e2e-test/java/org/alfresco/rest/search/StatsSearchTest.java new file mode 100644 index 000000000..ac5932750 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/search/StatsSearchTest.java @@ -0,0 +1,309 @@ +/* + * Copyright (C) 2017 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.rest.search; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertTrue; +import org.alfresco.rest.model.RestErrorModel; +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.Assert; +import org.testng.annotations.Test; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + +/** + * Stats search test. + * @author Gethin James + * + */ +public class StatsSearchTest extends AbstractSearchTest +{ + + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH }, executionType = ExecutionType.REGRESSION, + description = "Checks errors with stats using Search api") + public void searchWithBasicStats() throws Exception + { + SearchRequest query = carsQuery(); + Pagination pagination = new Pagination(); + pagination.setMaxItems(2); + List statsModels = new ArrayList<>(); + RestRequestStatsModel statsModel1 = new RestRequestStatsModel(); + statsModels.add(statsModel1); + query.setStats(statsModels); + query.setPaging(pagination); + + SearchResponse response = query(query); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.MANDATORY_PARAM, "stats field")); + + statsModel1.setField("DBID"); + response = query(query); + //8 metrics by default for a numeric field + Set metricTypes = assertStatsFacetedResponse(response, "DBID", 8); + assertTrue(metricTypes.containsAll(Arrays.asList("missing", "count", "sum","min","max", "sumOfSquares", "mean", "stddev"))); + + statsModel1.setField("creator"); + response = query(query); + //4 metrics by default for a string field + metricTypes = assertStatsFacetedResponse(response, "creator", 4); + assertTrue(metricTypes.containsAll(Arrays.asList("missing", "count", "min","max"))); + + statsModel1.setField("modified"); + response = query(query); + //8 metrics by default for a date field + metricTypes = assertStatsFacetedResponse(response, "modified", 8); + assertTrue(metricTypes.containsAll(Arrays.asList("missing", "count", "sum","min","max", "sumOfSquares", "mean", "stddev"))); + + statsModel1.setField("modifier"); + statsModel1.setMin(false); + statsModel1.setMax(false); + statsModel1.setMissing(false); + response = query(query); + metricTypes = assertStatsFacetedResponse(response, "modifier", 1); + assertFalse(metricTypes.containsAll(Arrays.asList("missing", "min","max"))); + + statsModel1.setField("DBID"); + statsModel1.setMin(true); + statsModel1.setMax(true); + statsModel1.setCount(false); + statsModel1.setMissing(false); + statsModel1.setSum(false); + statsModel1.setSumOfSquares(false); + statsModel1.setMean(false); + statsModel1.setStddev(false); + response = query(query); + metricTypes = assertStatsFacetedResponse(response, "DBID", 2); + assertTrue(metricTypes.containsAll(Arrays.asList("min","max"))); + assertFalse(metricTypes.containsAll(Arrays.asList("missing", "count", "sum","sumOfSquares", "mean", "stddev"))); + + statsModel1.setField("modifier"); + statsModel1.setMin(false); + statsModel1.setMax(false); + statsModel1.setCountDistinct(true); + statsModel1.setDistinctValues(true); + statsModel1.setCardinality(true); + response = query(query); + metricTypes = assertStatsFacetedResponse(response, "modifier", 3); + assertTrue(metricTypes.containsAll(Arrays.asList("countDistinct", "distinctValues", "cardinality"))); + + statsModel1.setField("DBID"); + statsModel1.setPercentiles(Arrays.asList(1,75,99,99.9)); + statsModel1.setCountDistinct(false); + statsModel1.setDistinctValues(false); + statsModel1.setCardinality(false); + response = query(query); + assertStatsFacetedResponse(response, "DBID", 1); + RestGenericMetricModel percMetric = response.getContext().getFacets().get(0).getBuckets().get(0).getMetrics().get(0); + assertEquals(percMetric.getType(),"percentiles"); + Map percVal = (Map) percMetric.getValue(); + Map percentiles = (Map) percVal.get("percentiles"); + assertEquals(percentiles.size(),4); + assertTrue(percentiles.keySet().containsAll(Arrays.asList("1.0","75.0","99.0","99.9"))); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH }, executionType = ExecutionType.REGRESSION, + description = "Checks errors with stats labels using Search api") + public void searchWithStatsLabel() throws Exception + { + SearchRequest query = carsQuery(); + Pagination pagination = new Pagination(); + pagination.setMaxItems(2); + List statsModels = new ArrayList<>(); + RestRequestStatsModel statsModel1 = new RestRequestStatsModel(); + statsModel1.setField("modified"); + statsModel1.setLabel("DateChanged"); + statsModels.add(statsModel1); + query.setStats(statsModels); + query.setPaging(pagination); + SearchResponse response = query(query); + assertStatsFacetedResponse(response, "DateChanged", 8); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH }, executionType = ExecutionType.REGRESSION, + description = "Checks errors with stats fitlers using Search api") + public void searchWithStatsFilters() throws Exception + { + SearchRequest query = new SearchRequest(); + RestRequestQueryModel queryReq = new RestRequestQueryModel(); + queryReq.setQuery("content.mimetype:text/plain"); + query.setQuery(queryReq); + List statsModels = new ArrayList<>(); + RestRequestStatsModel statsModel1 = new RestRequestStatsModel(); + statsModel1.setField("creator"); + statsModel1.setMin(false); + statsModel1.setMax(false); + statsModel1.setMissing(false); + statsModels.add(statsModel1); + query.setFilterQueries(new RestRequestFilterQueryModel("cars", Arrays.asList("justCars"))); + query.setStats(statsModels); + SearchResponse response = query(query); + assertStatsFacetedResponse(response, "creator", 1); + RestGenericMetricModel countMetric = response.getContext().getFacets().get(0).getBuckets().get(0).getMetrics().get(0); + Integer count = response.getEntries().size(); + Map metricCount = (Map) countMetric.getValue(); + assertEquals(count, metricCount.get("count")); + + statsModel1.setExcludeFilters(Arrays.asList("justCars")); + response = query(query); + assertStatsFacetedResponse(response, "creator", 1); + countMetric = response.getContext().getFacets().get(0).getBuckets().get(0).getMetrics().get(0); + count = response.getEntries().size(); + metricCount = (Map) countMetric.getValue(); + assertTrue((Integer)metricCount.get("count") > count, "With the exclude filter there will be more documents than returned"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH }, executionType = ExecutionType.REGRESSION, + description = "Checks errors with stats with Pivot using Search api") + public void searchWithStatsAndMutlilevelPivot() throws Exception + { + SearchRequest query = carsQuery(); + + Pagination pagination = new Pagination(); + pagination.setMaxItems(1); + query.setPaging(pagination); + RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); + List list = new ArrayList<>(); + RestRequestFacetFieldModel b0 = new RestRequestFacetFieldModel("SITE"); + b0.setLabel("b0"); + list.add(b0); + list.add(new RestRequestFacetFieldModel("created")); + RestRequestFacetFieldModel b2 = new RestRequestFacetFieldModel("modifier"); + b2.setLabel("b2"); + list.add(b2); + facetFields.setFacets(list); + query.setFacetFields(facetFields); + query.setIncludeRequest(false); + + + List pivotModelList = new ArrayList<>(); + RestRequestPivotModel pivots = new RestRequestPivotModel(); + pivots.setKey("b0"); + RestRequestPivotModel pivotn = new RestRequestPivotModel(); + pivotn.setKey("created"); + RestRequestPivotModel pivot2 = new RestRequestPivotModel(); + pivot2.setKey("aNumber"); + pivotModelList.add(pivots); + pivotModelList.add(pivotn); + pivotModelList.add(pivot2); + query.setPivots(pivotModelList); + + List statsModels = new ArrayList<>(); + RestRequestStatsModel statsModel1 = new RestRequestStatsModel(); + statsModels.add(statsModel1); + query.setStats(statsModels); + statsModel1.setField("DBID"); + statsModel1.setLabel("aNumber"); + + SearchResponse response = query(query); + response.getContext().assertThat().field("facetsFields").isNotNull(); + response.getContext().assertThat().field("facets").isNotEmpty(); + assertEquals(response.getContext().getFacetsFields().size(), 1, "There should be 1 facet field for modifier"); + assertEquals(response.getContext().getFacets().size(), 2, "There should be 1 pivot facet with stats on the end and a high level stats facet"); + + RestGenericFacetResponseModel facetResponseModel = response.getContext().getFacets().get(0); + facetResponseModel.assertThat().field("type").is("pivot"); + facetResponseModel.assertThat().field("label").is("b0"); + assertEquals(facetResponseModel.getBuckets().get(0).getMetrics().size(), 8, "Metrics on the pivot bucket"); + + //Another nested stats + assertEquals(facetResponseModel.getBuckets().get(0).getFacets().get(0).getBuckets().get(0).getMetrics().size(), 8, "Metrics are on the end of a pivot bucket"); + + RestGenericFacetResponseModel statsFacet = response.getContext().getFacets().get(1); + statsFacet.assertThat().field("type").is("stats"); + statsFacet.assertThat().field("label").is("aNumber"); + + } + + + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH }, executionType = ExecutionType.REGRESSION, + description = "Checks errors with stats with Pivot using Search api") + public void searchWithStatsAndPivot() throws Exception + { + SearchRequest query = carsQuery(); + + Pagination pagination = new Pagination(); + pagination.setMaxItems(2); + query.setPaging(pagination); + RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); + List list = new ArrayList<>(); + list.add(new RestRequestFacetFieldModel("creator")); + facetFields.setFacets(list); + query.setFacetFields(facetFields); + query.setIncludeRequest(false); + + SearchResponse response = query(query); + response.getContext().assertThat().field("facetsFields").isNotNull(); + + List pivotModelList = new ArrayList<>(); + RestRequestPivotModel pivots = new RestRequestPivotModel(); + pivots.setKey("creator"); + RestRequestPivotModel pivotn = new RestRequestPivotModel(); + pivotn.setKey("numericId"); + pivotModelList.add(pivots); + pivotModelList.add(pivotn); + query.setPivots(pivotModelList); + + List statsModels = new ArrayList<>(); + RestRequestStatsModel statsModel1 = new RestRequestStatsModel(); + statsModels.add(statsModel1); + query.setStats(statsModels); + statsModel1.setField("DBID"); + statsModel1.setLabel("numericId"); + + response = query(query); + + response.getContext().assertThat().field("facets").isNotEmpty(); + assertEquals(response.getContext().getFacets().size(), 2, "There should be 1 pivot facet with stats on the end and a high level stats facet"); + RestGenericFacetResponseModel facetResponseModel = response.getContext().getFacets().get(0); + facetResponseModel.assertThat().field("type").is("pivot"); + facetResponseModel.assertThat().field("label").is("creator"); + assertEquals(facetResponseModel.getBuckets().get(0).getMetrics().size(), 8, "Metrics are on the end of a pivot bucket"); + RestGenericFacetResponseModel statsFacet = response.getContext().getFacets().get(1); + statsFacet.assertThat().field("type").is("stats"); + statsFacet.assertThat().field("label").is("numericId"); + + } + + private Set assertStatsFacetedResponse(SearchResponse response, String label, int metricsCount) throws Exception + { + response.getContext().assertThat().field("facets").isNotEmpty(); + RestGenericFacetResponseModel facetResponseModel = response.getContext().getFacets().get(0); + facetResponseModel.assertThat().field("type").is("stats"); + facetResponseModel.assertThat().field("label").is(label); + RestGenericBucketModel bucket = facetResponseModel.getBuckets().get(0); + List metrics = bucket.getMetrics(); + assertEquals(metrics.size(),metricsCount); + return metrics.stream().map(m -> m.getType()).collect(Collectors.toSet()); + } + +} From e89a6d2f87b186de3ce366f29c79ab886a2de989 Mon Sep 17 00:00:00 2001 From: "NESS\\P3700654" Date: Wed, 10 May 2017 10:06:41 +0300 Subject: [PATCH 1139/1491] REPO-2116 Created a new get method for Renditions(getNodeRenditionUntilTheyAreCreated), that waits for the renditions to be created. Modified 3 tests from the CreateRenditionsTests.java class (adminCanCreateRenditionToExistingNode(), userThatCreatedFileCanCreatePdfRenditionForIt(),userThatCreatedFileCanCreateDoclibRenditionForIt()) in order to pass on slower machines. --- .../org/alfresco/rest/renditions/CreateRenditionTests.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/renditions/CreateRenditionTests.java b/e2e-test/java/org/alfresco/rest/renditions/CreateRenditionTests.java index 441008d64..0a628bb0b 100644 --- a/e2e-test/java/org/alfresco/rest/renditions/CreateRenditionTests.java +++ b/e2e-test/java/org/alfresco/rest/renditions/CreateRenditionTests.java @@ -52,7 +52,7 @@ public class CreateRenditionTests extends RestTest restClient.authenticateUser(adminUser).withCoreAPI().usingNode(document).createNodeRendition("pdf"); restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); - restClient.withCoreAPI().usingNode(document).getNodeRendition("pdf") + restClient.withCoreAPI().usingNode(document).getNodeRenditionUntilTheyAreCreated("pdf") .assertThat().field("status").is("CREATED"); } @@ -65,7 +65,7 @@ public class CreateRenditionTests extends RestTest restClient.authenticateUser(user).withCoreAPI().usingNode(document).createNodeRendition("pdf"); restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); - restClient.withCoreAPI().usingNode(document).getNodeRendition("pdf") + restClient.withCoreAPI().usingNode(document).getNodeRenditionUntilTheyAreCreated("pdf") .assertThat().field("status").is("CREATED"); } @@ -89,7 +89,7 @@ public class CreateRenditionTests extends RestTest restClient.authenticateUser(user).withCoreAPI().usingNode(document).createNodeRendition("doclib"); restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); - restClient.withCoreAPI().usingNode(document).getNodeRendition("doclib") + restClient.withCoreAPI().usingNode(document).getNodeRenditionUntilTheyAreCreated("doclib") .assertThat().field("status").is("CREATED"); } } From 3c76b1c9a180ff273ebfe64875970c5686a79dff Mon Sep 17 00:00:00 2001 From: Michael Suzuki Date: Mon, 15 May 2017 14:29:56 +0100 Subject: [PATCH 1140/1491] Search-340, adding end 2 end test for search range api --- .../rest/search/AbstractSearchTest.java | 9 +- .../rest/search/FacetRangeSearchTest.java | 168 ++++++++++++++++++ 2 files changed, 174 insertions(+), 3 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java diff --git a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java index 2bb43effc..d4a4896b6 100644 --- a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java @@ -111,13 +111,16 @@ public class AbstractSearchTest extends RestTest { return restClient.authenticateUser(dataUser.getAdminUser()).withSearchAPI().search(query); } - - protected SearchRequest carsQuery() + protected SearchRequest createQuery(String term) { SearchRequest query = new SearchRequest(); RestRequestQueryModel queryReq = new RestRequestQueryModel(); - queryReq.setQuery("cars"); + queryReq.setQuery(term); query.setQuery(queryReq); return query; } + protected SearchRequest carsQuery() + { + return createQuery("cars"); + } } diff --git a/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java b/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java new file mode 100644 index 000000000..ee76feb21 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java @@ -0,0 +1,168 @@ +/* + * Copyright (C) 2017 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.rest.search; + +import java.util.Map; + +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestRequestRangeModel; +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.Assert; +import org.testng.annotations.Test; + +/** + * Faceted Range Search Test + * @author Michael Suzuki + * + */ +public class FacetRangeSearchTest extends AbstractSearchTest +{ + + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, + description = "Check facet intervals mandatory fields") + public void checkingFacetsMandatoryErrorMessages()throws Exception + { + SearchRequest query = carsQuery(); + + RestRequestRangeModel facetRangeModel = new RestRequestRangeModel(); + query.setRange(facetRangeModel); + + SearchResponse response = query(query); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.MANDATORY_PARAM, "field")); + facetRangeModel.setField("content.size"); + + query.setRange(facetRangeModel); + response = query(query); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.MANDATORY_PARAM, "start")); + facetRangeModel.setStart("0"); + + query.setRange(facetRangeModel); + response = query(query); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.MANDATORY_PARAM, "end")); + facetRangeModel.setEnd("400"); + query.setRange(facetRangeModel); + response = query(query); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.MANDATORY_PARAM, "gap")); + + facetRangeModel.setGap(100); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, + description = "Check basic facet range search api") + public void searchWithRange()throws Exception + { + SearchRequest query = createQuery("A*"); + + RestRequestRangeModel facetRangeModel = new RestRequestRangeModel(); + facetRangeModel.setField("content.size"); + facetRangeModel.setStart("0"); + facetRangeModel.setEnd("500"); + facetRangeModel.setGap(200); + query.setRange(facetRangeModel); + SearchResponse response = query(query); + response.assertThat().entriesListIsNotEmpty(); + response.getContext().assertThat().field("facets").isNotEmpty(); + RestGenericFacetResponseModel facetResponseModel = response.getContext().getFacets().get(0); + + RestGenericBucketModel bucket = facetResponseModel.getBuckets().get(0); + bucket.assertThat().field("label").is("0 - 200"); + bucket.assertThat().field("filterQuery").is("content.size:(0 TO 200)"); + bucket.getMetrics().get(0).assertThat().field("value").is("{count=4}"); + Map info = (Map) bucket.getFacetInfo(); + Assert.assertEquals(info.get("from"),"0"); + Assert.assertEquals(info.get("to"),"200"); + Assert.assertEquals(info.get("count"),"4"); + + bucket = facetResponseModel.getBuckets().get(1); + bucket.assertThat().field("label").is("200 - 400"); + bucket.assertThat().field("filterQuery").is("content.size:(200 TO 400)"); + bucket.getMetrics().get(0).assertThat().field("value").is("{count=4}"); + info = (Map) bucket.getFacetInfo(); + Assert.assertEquals(info.get("from"),"200"); + Assert.assertEquals(info.get("to"),"400"); + Assert.assertEquals(info.get("count"),"4"); + + bucket = facetResponseModel.getBuckets().get(2); + bucket.assertThat().field("label").is("400 - 600"); + bucket.assertThat().field("filterQuery").is("content.size:(400 TO 600)"); + bucket.getMetrics().get(0).assertThat().field("value").is("{count=7}"); + info = (Map) bucket.getFacetInfo(); + Assert.assertEquals(info.get("from"),"400"); + Assert.assertEquals(info.get("to"),"600"); + Assert.assertEquals(info.get("count"),"7"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, + description = "Check date facet intervals search api") + public void searchWithRangeHardend()throws Exception + { + SearchRequest query = createQuery("A*"); + + RestRequestRangeModel facetRangeModel = new RestRequestRangeModel(); + facetRangeModel.setField("content.size"); + facetRangeModel.setStart("0"); + facetRangeModel.setEnd("500"); + facetRangeModel.setGap(200); + facetRangeModel.setHardend(true); + query.setRange(facetRangeModel); + SearchResponse response = query(query); + response.assertThat().entriesListIsNotEmpty(); + response.getContext().assertThat().field("facets").isNotEmpty(); + RestGenericFacetResponseModel facetResponseModel = response.getContext().getFacets().get(0); + + RestGenericBucketModel bucket = facetResponseModel.getBuckets().get(0); + bucket.assertThat().field("label").is("0 - 200"); + bucket.assertThat().field("filterQuery").is("content.size:(0 TO 200)"); + bucket.getMetrics().get(0).assertThat().field("value").is("{count=4}"); + Map info = (Map) bucket.getFacetInfo(); + Assert.assertEquals(info.get("from"),"0"); + Assert.assertEquals(info.get("to"),"200"); + Assert.assertEquals(info.get("count"),"4"); + + bucket = facetResponseModel.getBuckets().get(1); + bucket.assertThat().field("label").is("200 - 400"); + bucket.assertThat().field("filterQuery").is("content.size:(200 TO 400)"); + bucket.getMetrics().get(0).assertThat().field("value").is("{count=4}"); + info = (Map) bucket.getFacetInfo(); + Assert.assertEquals(info.get("from"),"200"); + Assert.assertEquals(info.get("to"),"400"); + Assert.assertEquals(info.get("count"),"4"); + + bucket = facetResponseModel.getBuckets().get(2); + bucket.assertThat().field("label").is("400 - 500"); + bucket.assertThat().field("filterQuery").is("content.size:(400 TO 500)"); + bucket.getMetrics().get(0).assertThat().field("value").is("{count=3}"); + info = (Map) bucket.getFacetInfo(); + Assert.assertEquals(info.get("from"),"400"); + Assert.assertEquals(info.get("to"),"500"); + Assert.assertEquals(info.get("count"),"3"); + } + +} From 3bcaab7b92f576245240ddedf8f24fdffb6cdc97 Mon Sep 17 00:00:00 2001 From: "NESS\\P3700654" Date: Tue, 16 May 2017 14:16:57 +0300 Subject: [PATCH 1141/1491] Renamed getNodeRenditionUntilTheyAreCreated to getNodeRenditionUntilIsCreated, Added fixed status to the Renditions tests that were failing. --- .../rest/renditions/CreateRenditionTests.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/renditions/CreateRenditionTests.java b/e2e-test/java/org/alfresco/rest/renditions/CreateRenditionTests.java index 0a628bb0b..d5b58b4e0 100644 --- a/e2e-test/java/org/alfresco/rest/renditions/CreateRenditionTests.java +++ b/e2e-test/java/org/alfresco/rest/renditions/CreateRenditionTests.java @@ -11,6 +11,7 @@ import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; +import org.alfresco.utility.report.Bug.Status; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -43,7 +44,7 @@ public class CreateRenditionTests extends RestTest document = dataContent.usingUser(user).usingSite(site).createContent(DocumentType.TEXT_PLAIN); } - @Bug(id = "REPO-2042", description = "Should fail only on MAC OS System and Linux" ) + @Bug(id = "REPO-2042", description = "Should fail only on MAC OS System and Linux", status = Status.FIXED ) @TestRail(section = { TestGroup.REST_API, TestGroup.RENDITIONS }, executionType = ExecutionType.SANITY, description = "Verify admin user creates rendition with Rest API and status code is 202") @Test(groups = { TestGroup.REST_API, TestGroup.RENDITIONS, TestGroup.SANITY }) @@ -52,11 +53,11 @@ public class CreateRenditionTests extends RestTest restClient.authenticateUser(adminUser).withCoreAPI().usingNode(document).createNodeRendition("pdf"); restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); - restClient.withCoreAPI().usingNode(document).getNodeRenditionUntilTheyAreCreated("pdf") + restClient.withCoreAPI().usingNode(document).getNodeRenditionUntilIsCreated("pdf") .assertThat().field("status").is("CREATED"); } - @Bug(id = "REPO-2042", description = "Should fail only on MAC OS System and Linux" ) + @Bug(id = "REPO-2042", description = "Should fail only on MAC OS System and Linux", status = Status.FIXED ) @TestRail(section = { TestGroup.REST_API, TestGroup.RENDITIONS }, executionType = ExecutionType.SANITY, description = "Verify user that created the document can also creates 'pdf' rendition for it with Rest API and status code is 202") @Test(groups = { TestGroup.REST_API, TestGroup.RENDITIONS, TestGroup.SANITY }) @@ -65,11 +66,11 @@ public class CreateRenditionTests extends RestTest restClient.authenticateUser(user).withCoreAPI().usingNode(document).createNodeRendition("pdf"); restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); - restClient.withCoreAPI().usingNode(document).getNodeRenditionUntilTheyAreCreated("pdf") + restClient.withCoreAPI().usingNode(document).getNodeRenditionUntilIsCreated("pdf") .assertThat().field("status").is("CREATED"); } - @Bug(id = "REPO-2042", description = "Should fail only on MAC OS System and Linux" ) + @Bug(id = "REPO-2042", description = "Should fail only on MAC OS System and Linux", status = Status.FIXED ) @TestRail(section = { TestGroup.REST_API, TestGroup.RENDITIONS }, executionType = ExecutionType.SANITY, description = "Verify user that created the document can also creates 'doclib' rendition for it with Rest API and status code is 202") @Test(groups = { TestGroup.REST_API, TestGroup.RENDITIONS, TestGroup.SANITY }) @@ -89,7 +90,7 @@ public class CreateRenditionTests extends RestTest restClient.authenticateUser(user).withCoreAPI().usingNode(document).createNodeRendition("doclib"); restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); - restClient.withCoreAPI().usingNode(document).getNodeRenditionUntilTheyAreCreated("doclib") + restClient.withCoreAPI().usingNode(document).getNodeRenditionUntilIsCreated("doclib") .assertThat().field("status").is("CREATED"); } } From bb0e31c0c4b4fecc131e25ff202cf9721b93e759 Mon Sep 17 00:00:00 2001 From: Michael Suzuki Date: Tue, 16 May 2017 16:45:10 +0100 Subject: [PATCH 1142/1491] Search-340, added test to cover date range search --- .../rest/search/FacetRangeSearchTest.java | 66 +++++++++++++++++-- 1 file changed, 62 insertions(+), 4 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java b/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java index ee76feb21..b3f887d8f 100644 --- a/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java @@ -30,7 +30,30 @@ import org.testng.Assert; import org.testng.annotations.Test; /** - * Faceted Range Search Test + * Faceted Range Search Query for numeric range + * { + * "query": { + * "query": "name:A*" + * }, + * "range": { + * "field": "content.size", + * "start": "0", + * "end": "400", + * "gap": "100" + * } + * } + * Date range query: + * { + * "query": { + * "query": "name:A*" + * }, + * "range": { + * "field": "created", + * "start": "2015-09-29T10:45:15.729Z", + * "end": "2016-09-29T10:45:15.729Z", + * "gap": "+100DAY" + * } + * } * @author Michael Suzuki * */ @@ -69,7 +92,7 @@ public class FacetRangeSearchTest extends AbstractSearchTest restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() .containsSummary(String.format(RestErrorModel.MANDATORY_PARAM, "gap")); - facetRangeModel.setGap(100); + facetRangeModel.setGap("100"); } @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) @@ -83,7 +106,7 @@ public class FacetRangeSearchTest extends AbstractSearchTest facetRangeModel.setField("content.size"); facetRangeModel.setStart("0"); facetRangeModel.setEnd("500"); - facetRangeModel.setGap(200); + facetRangeModel.setGap("200"); query.setRange(facetRangeModel); SearchResponse response = query(query); response.assertThat().entriesListIsNotEmpty(); @@ -129,7 +152,7 @@ public class FacetRangeSearchTest extends AbstractSearchTest facetRangeModel.setField("content.size"); facetRangeModel.setStart("0"); facetRangeModel.setEnd("500"); - facetRangeModel.setGap(200); + facetRangeModel.setGap("200"); facetRangeModel.setHardend(true); query.setRange(facetRangeModel); SearchResponse response = query(query); @@ -164,5 +187,40 @@ public class FacetRangeSearchTest extends AbstractSearchTest Assert.assertEquals(info.get("to"),"500"); Assert.assertEquals(info.get("count"),"3"); } + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, + description = "Check date facet intervals search api") + public void searchDateRange()throws Exception + { + SearchRequest query = createQuery("name:A*"); + RestRequestRangeModel facetRangeModel = new RestRequestRangeModel(); + facetRangeModel.setField("created"); + facetRangeModel.setStart("2015-09-29T10:45:15.729Z"); + facetRangeModel.setEnd("2016-09-29T10:45:15.729Z"); + facetRangeModel.setGap("+280DAY"); + query.setRange(facetRangeModel); + SearchResponse response = query(query); + response.assertThat().entriesListIsNotEmpty(); + response.getContext().assertThat().field("facets").isNotEmpty(); + RestGenericFacetResponseModel facetResponseModel = response.getContext().getFacets().get(0); + + RestGenericBucketModel bucket = facetResponseModel.getBuckets().get(0); + bucket.assertThat().field("label").is("2015-09-29T10:45:15.729Z - 2016-07-05T10:45:15.729Z"); + bucket.assertThat().field("filterQuery").is("created:(2015-09-29T10:45:15.729Z TO 2016-07-05T10:45:15.729Z)"); + bucket.getMetrics().get(0).assertThat().field("value").is("{count=1}"); + Map info = (Map) bucket.getFacetInfo(); + Assert.assertEquals(info.get("from"),"2015-09-29T10:45:15.729Z"); + Assert.assertEquals(info.get("to"),"2016-07-05T10:45:15.729Z"); + Assert.assertEquals(info.get("count"),"1"); + + bucket = facetResponseModel.getBuckets().get(1); + bucket.assertThat().field("label").is("2016-07-05T10:45:15.729Z - 2017-04-11T10:45:15.729Z"); + bucket.assertThat().field("filterQuery").is("created:(2016-07-05T10:45:15.729Z TO 2017-04-11T10:45:15.729Z)"); + bucket.getMetrics().get(0).assertThat().field("value").is("{count=0}"); + info = (Map) bucket.getFacetInfo(); + Assert.assertEquals(info.get("from"),"2016-07-05T10:45:15.729Z"); + Assert.assertEquals(info.get("to"),"2017-04-11T10:45:15.729Z"); + Assert.assertEquals(info.get("count"),"0"); + } } From 0137a119f5af5121433e262a35fabd0502f90e07 Mon Sep 17 00:00:00 2001 From: Michael Suzuki Date: Wed, 17 May 2017 11:33:31 +0100 Subject: [PATCH 1143/1491] Search-340, renamed facetInfo to bucketInfo --- .../rest/search/FacetRangeSearchTest.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java b/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java index b3f887d8f..4d191480f 100644 --- a/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java @@ -117,7 +117,7 @@ public class FacetRangeSearchTest extends AbstractSearchTest bucket.assertThat().field("label").is("0 - 200"); bucket.assertThat().field("filterQuery").is("content.size:(0 TO 200)"); bucket.getMetrics().get(0).assertThat().field("value").is("{count=4}"); - Map info = (Map) bucket.getFacetInfo(); + Map info = (Map) bucket.getBucketInfo(); Assert.assertEquals(info.get("from"),"0"); Assert.assertEquals(info.get("to"),"200"); Assert.assertEquals(info.get("count"),"4"); @@ -126,7 +126,7 @@ public class FacetRangeSearchTest extends AbstractSearchTest bucket.assertThat().field("label").is("200 - 400"); bucket.assertThat().field("filterQuery").is("content.size:(200 TO 400)"); bucket.getMetrics().get(0).assertThat().field("value").is("{count=4}"); - info = (Map) bucket.getFacetInfo(); + info = (Map) bucket.getBucketInfo(); Assert.assertEquals(info.get("from"),"200"); Assert.assertEquals(info.get("to"),"400"); Assert.assertEquals(info.get("count"),"4"); @@ -135,7 +135,7 @@ public class FacetRangeSearchTest extends AbstractSearchTest bucket.assertThat().field("label").is("400 - 600"); bucket.assertThat().field("filterQuery").is("content.size:(400 TO 600)"); bucket.getMetrics().get(0).assertThat().field("value").is("{count=7}"); - info = (Map) bucket.getFacetInfo(); + info = (Map) bucket.getBucketInfo(); Assert.assertEquals(info.get("from"),"400"); Assert.assertEquals(info.get("to"),"600"); Assert.assertEquals(info.get("count"),"7"); @@ -164,7 +164,7 @@ public class FacetRangeSearchTest extends AbstractSearchTest bucket.assertThat().field("label").is("0 - 200"); bucket.assertThat().field("filterQuery").is("content.size:(0 TO 200)"); bucket.getMetrics().get(0).assertThat().field("value").is("{count=4}"); - Map info = (Map) bucket.getFacetInfo(); + Map info = (Map) bucket.getBucketInfo(); Assert.assertEquals(info.get("from"),"0"); Assert.assertEquals(info.get("to"),"200"); Assert.assertEquals(info.get("count"),"4"); @@ -173,7 +173,7 @@ public class FacetRangeSearchTest extends AbstractSearchTest bucket.assertThat().field("label").is("200 - 400"); bucket.assertThat().field("filterQuery").is("content.size:(200 TO 400)"); bucket.getMetrics().get(0).assertThat().field("value").is("{count=4}"); - info = (Map) bucket.getFacetInfo(); + info = (Map) bucket.getBucketInfo(); Assert.assertEquals(info.get("from"),"200"); Assert.assertEquals(info.get("to"),"400"); Assert.assertEquals(info.get("count"),"4"); @@ -182,7 +182,7 @@ public class FacetRangeSearchTest extends AbstractSearchTest bucket.assertThat().field("label").is("400 - 500"); bucket.assertThat().field("filterQuery").is("content.size:(400 TO 500)"); bucket.getMetrics().get(0).assertThat().field("value").is("{count=3}"); - info = (Map) bucket.getFacetInfo(); + info = (Map) bucket.getBucketInfo(); Assert.assertEquals(info.get("from"),"400"); Assert.assertEquals(info.get("to"),"500"); Assert.assertEquals(info.get("count"),"3"); @@ -209,7 +209,7 @@ public class FacetRangeSearchTest extends AbstractSearchTest bucket.assertThat().field("label").is("2015-09-29T10:45:15.729Z - 2016-07-05T10:45:15.729Z"); bucket.assertThat().field("filterQuery").is("created:(2015-09-29T10:45:15.729Z TO 2016-07-05T10:45:15.729Z)"); bucket.getMetrics().get(0).assertThat().field("value").is("{count=1}"); - Map info = (Map) bucket.getFacetInfo(); + Map info = (Map) bucket.getBucketInfo(); Assert.assertEquals(info.get("from"),"2015-09-29T10:45:15.729Z"); Assert.assertEquals(info.get("to"),"2016-07-05T10:45:15.729Z"); Assert.assertEquals(info.get("count"),"1"); @@ -218,7 +218,7 @@ public class FacetRangeSearchTest extends AbstractSearchTest bucket.assertThat().field("label").is("2016-07-05T10:45:15.729Z - 2017-04-11T10:45:15.729Z"); bucket.assertThat().field("filterQuery").is("created:(2016-07-05T10:45:15.729Z TO 2017-04-11T10:45:15.729Z)"); bucket.getMetrics().get(0).assertThat().field("value").is("{count=0}"); - info = (Map) bucket.getFacetInfo(); + info = (Map) bucket.getBucketInfo(); Assert.assertEquals(info.get("from"),"2016-07-05T10:45:15.729Z"); Assert.assertEquals(info.get("to"),"2017-04-11T10:45:15.729Z"); Assert.assertEquals(info.get("count"),"0"); From 3a235fcb371281d31573eb3783b2312c3f04db76 Mon Sep 17 00:00:00 2001 From: Michael Suzuki Date: Wed, 17 May 2017 15:49:57 +0100 Subject: [PATCH 1144/1491] Search-340, amend from range to ranges --- .../rest/search/FacetRangeSearchTest.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java b/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java index 4d191480f..c8c98f4ea 100644 --- a/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java @@ -21,7 +21,7 @@ package org.alfresco.rest.search; import java.util.Map; import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestRequestRangeModel; +import org.alfresco.rest.model.RestRequestRangesModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; @@ -67,8 +67,8 @@ public class FacetRangeSearchTest extends AbstractSearchTest { SearchRequest query = carsQuery(); - RestRequestRangeModel facetRangeModel = new RestRequestRangeModel(); - query.setRange(facetRangeModel); + RestRequestRangesModel facetRangeModel = new RestRequestRangesModel(); + query.setRanges(facetRangeModel); SearchResponse response = query(query); @@ -76,18 +76,18 @@ public class FacetRangeSearchTest extends AbstractSearchTest .containsSummary(String.format(RestErrorModel.MANDATORY_PARAM, "field")); facetRangeModel.setField("content.size"); - query.setRange(facetRangeModel); + query.setRanges(facetRangeModel); response = query(query); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() .containsSummary(String.format(RestErrorModel.MANDATORY_PARAM, "start")); facetRangeModel.setStart("0"); - query.setRange(facetRangeModel); + query.setRanges(facetRangeModel); response = query(query); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() .containsSummary(String.format(RestErrorModel.MANDATORY_PARAM, "end")); facetRangeModel.setEnd("400"); - query.setRange(facetRangeModel); + query.setRanges(facetRangeModel); response = query(query); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() .containsSummary(String.format(RestErrorModel.MANDATORY_PARAM, "gap")); @@ -102,12 +102,12 @@ public class FacetRangeSearchTest extends AbstractSearchTest { SearchRequest query = createQuery("A*"); - RestRequestRangeModel facetRangeModel = new RestRequestRangeModel(); + RestRequestRangesModel facetRangeModel = new RestRequestRangesModel(); facetRangeModel.setField("content.size"); facetRangeModel.setStart("0"); facetRangeModel.setEnd("500"); facetRangeModel.setGap("200"); - query.setRange(facetRangeModel); + query.setRanges(facetRangeModel); SearchResponse response = query(query); response.assertThat().entriesListIsNotEmpty(); response.getContext().assertThat().field("facets").isNotEmpty(); @@ -148,13 +148,13 @@ public class FacetRangeSearchTest extends AbstractSearchTest { SearchRequest query = createQuery("A*"); - RestRequestRangeModel facetRangeModel = new RestRequestRangeModel(); + RestRequestRangesModel facetRangeModel = new RestRequestRangesModel(); facetRangeModel.setField("content.size"); facetRangeModel.setStart("0"); facetRangeModel.setEnd("500"); facetRangeModel.setGap("200"); facetRangeModel.setHardend(true); - query.setRange(facetRangeModel); + query.setRanges(facetRangeModel); SearchResponse response = query(query); response.assertThat().entriesListIsNotEmpty(); response.getContext().assertThat().field("facets").isNotEmpty(); @@ -194,12 +194,12 @@ public class FacetRangeSearchTest extends AbstractSearchTest { SearchRequest query = createQuery("name:A*"); - RestRequestRangeModel facetRangeModel = new RestRequestRangeModel(); + RestRequestRangesModel facetRangeModel = new RestRequestRangesModel(); facetRangeModel.setField("created"); facetRangeModel.setStart("2015-09-29T10:45:15.729Z"); facetRangeModel.setEnd("2016-09-29T10:45:15.729Z"); facetRangeModel.setGap("+280DAY"); - query.setRange(facetRangeModel); + query.setRanges(facetRangeModel); SearchResponse response = query(query); response.assertThat().entriesListIsNotEmpty(); response.getContext().assertThat().field("facets").isNotEmpty(); From 058fe354f7155a4b9bee92aa822147fd2bbfdf35 Mon Sep 17 00:00:00 2001 From: Michael Suzuki Date: Thu, 18 May 2017 18:28:54 +0100 Subject: [PATCH 1145/1491] Search-340, updated to verify range handling multiple range facets --- .../rest/search/FacetRangeSearchTest.java | 58 +++++++++++++++---- 1 file changed, 47 insertions(+), 11 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java b/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java index c8c98f4ea..e8e0c9de2 100644 --- a/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java @@ -18,6 +18,10 @@ */ package org.alfresco.rest.search; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; import java.util.Map; import org.alfresco.rest.model.RestErrorModel; @@ -66,28 +70,32 @@ public class FacetRangeSearchTest extends AbstractSearchTest public void checkingFacetsMandatoryErrorMessages()throws Exception { SearchRequest query = carsQuery(); - + List ranges = new ArrayList(); RestRequestRangesModel facetRangeModel = new RestRequestRangesModel(); - query.setRanges(facetRangeModel); - + ranges.add(facetRangeModel); + query.setRanges(ranges); SearchResponse response = query(query); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() .containsSummary(String.format(RestErrorModel.MANDATORY_PARAM, "field")); + ranges.clear(); facetRangeModel.setField("content.size"); - - query.setRanges(facetRangeModel); + ranges.add(facetRangeModel); + query.setRanges(ranges); response = query(query); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() .containsSummary(String.format(RestErrorModel.MANDATORY_PARAM, "start")); facetRangeModel.setStart("0"); - - query.setRanges(facetRangeModel); + ranges.clear(); + ranges.add(facetRangeModel); + query.setRanges(ranges); response = query(query); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() .containsSummary(String.format(RestErrorModel.MANDATORY_PARAM, "end")); facetRangeModel.setEnd("400"); - query.setRanges(facetRangeModel); + query.setRanges(ranges); + ranges.clear(); + ranges.add(facetRangeModel); response = query(query); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() .containsSummary(String.format(RestErrorModel.MANDATORY_PARAM, "gap")); @@ -107,7 +115,9 @@ public class FacetRangeSearchTest extends AbstractSearchTest facetRangeModel.setStart("0"); facetRangeModel.setEnd("500"); facetRangeModel.setGap("200"); - query.setRanges(facetRangeModel); + List ranges = new ArrayList(); + ranges.add(facetRangeModel); + query.setRanges(ranges); SearchResponse response = query(query); response.assertThat().entriesListIsNotEmpty(); response.getContext().assertThat().field("facets").isNotEmpty(); @@ -154,7 +164,9 @@ public class FacetRangeSearchTest extends AbstractSearchTest facetRangeModel.setEnd("500"); facetRangeModel.setGap("200"); facetRangeModel.setHardend(true); - query.setRanges(facetRangeModel); + List ranges = new ArrayList(); + ranges.add(facetRangeModel); + query.setRanges(ranges); SearchResponse response = query(query); response.assertThat().entriesListIsNotEmpty(); response.getContext().assertThat().field("facets").isNotEmpty(); @@ -199,7 +211,9 @@ public class FacetRangeSearchTest extends AbstractSearchTest facetRangeModel.setStart("2015-09-29T10:45:15.729Z"); facetRangeModel.setEnd("2016-09-29T10:45:15.729Z"); facetRangeModel.setGap("+280DAY"); - query.setRanges(facetRangeModel); + List ranges = new ArrayList(); + ranges.add(facetRangeModel); + query.setRanges(ranges); SearchResponse response = query(query); response.assertThat().entriesListIsNotEmpty(); response.getContext().assertThat().field("facets").isNotEmpty(); @@ -223,4 +237,26 @@ public class FacetRangeSearchTest extends AbstractSearchTest Assert.assertEquals(info.get("to"),"2017-04-11T10:45:15.729Z"); Assert.assertEquals(info.get("count"),"0"); } + + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, + description = "Check date facet intervals search api") + public void searchDateAndSizeRanges()throws Exception + { + SearchRequest query = createQuery("name:A*"); + List ranges = new ArrayList(); + RestRequestRangesModel facetRangeModel = new RestRequestRangesModel(); + facetRangeModel.setField("created"); + facetRangeModel.setStart("2015-09-29T10:45:15.729Z"); + facetRangeModel.setEnd("2016-09-29T10:45:15.729Z"); + facetRangeModel.setGap("+280DAY"); + ranges.add(facetRangeModel); + RestRequestRangesModel facetCountRangeModel = new RestRequestRangesModel(); + facetCountRangeModel.setField("content.size"); + facetCountRangeModel.setStart("0"); + facetCountRangeModel.setEnd("500"); + facetCountRangeModel.setGap("200"); + ranges.add(facetCountRangeModel); + query.setRanges(ranges); + } } From a0765d0700a080accb10a320d105f9866c26ccfa Mon Sep 17 00:00:00 2001 From: Michael Suzuki Date: Fri, 19 May 2017 15:03:11 +0100 Subject: [PATCH 1146/1491] Fix failing test --- .../rest/search/FacetRangeSearchTest.java | 2 -- .../java/org/alfresco/rest/search/SearchTest.java | 15 ++++----------- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java b/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java index e8e0c9de2..24f5a5fa4 100644 --- a/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java @@ -19,8 +19,6 @@ package org.alfresco.rest.search; import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; import java.util.List; import java.util.Map; diff --git a/e2e-test/java/org/alfresco/rest/search/SearchTest.java b/e2e-test/java/org/alfresco/rest/search/SearchTest.java index 58f5a4199..5f038dfc6 100644 --- a/e2e-test/java/org/alfresco/rest/search/SearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/SearchTest.java @@ -24,6 +24,8 @@ import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; import org.testng.annotations.Test; +import junit.framework.Assert; + /** * Search end point Public API test. * @author Michael Suzuki @@ -34,23 +36,14 @@ public class SearchTest extends AbstractSearchTest @Test(groups={TestGroup.SEARCH, TestGroup.REST_API}) public void searchOnIndexedData() throws Exception { - SearchResponse nodes = query("fox"); + SearchResponse nodes = query("ipsum"); restClient.assertStatusCodeIs(HttpStatus.OK); nodes.assertThat().entriesListIsNotEmpty(); SearchNodeModel entity = nodes.getEntryByIndex(0); entity.assertThat().field("search").contains("score"); entity.getSearch().assertThat().field("score").isNotEmpty(); - entity.assertThat().field("name").contains("pangram.txt"); - - nodes = query("car"); - restClient.assertStatusCodeIs(HttpStatus.OK); - entity = nodes.getEntryByIndex(0); - - nodes.assertThat().entriesListIsNotEmpty(); - entity.assertThat().field("search").contains("score"); - entity.getSearch().assertThat().field("score").isNotEmpty(); - entity.assertThat().field("name").contains("cars.txt"); + Assert.assertEquals("Project Overview.ppt",entity.getName()); } @Test(groups={TestGroup.SEARCH,TestGroup.REST_API}) From 4f009c7db33348d8740e63b360892d415f0309a0 Mon Sep 17 00:00:00 2001 From: Gethin James Date: Mon, 22 May 2017 15:34:25 +0200 Subject: [PATCH 1147/1491] SEARCH-339: Updating interval tests --- .../rest/search/FacetIntervalSearchTest.java | 19 +++++++++++++++++++ .../alfresco/rest/search/StatsSearchTest.java | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/search/FacetIntervalSearchTest.java b/e2e-test/java/org/alfresco/rest/search/FacetIntervalSearchTest.java index 3c7ccfc0c..c7e9cf9fa 100644 --- a/e2e-test/java/org/alfresco/rest/search/FacetIntervalSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FacetIntervalSearchTest.java @@ -68,6 +68,25 @@ public class FacetIntervalSearchTest extends AbstractSearchTest restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() .containsSummary(String.format(RestErrorModel.MANDATORY_PARAM, "facetIntervals intervals created sets end")); + restFacetSetModel.setEnd("B"); + RestRequestFacetSetModel duplicate = new RestRequestFacetSetModel(); + facetInterval.setSets(Arrays.asList(restFacetSetModel,duplicate)); + duplicate.setLabel("theRest"); + duplicate.setStart("A"); + duplicate.setEnd("C"); + response = query(query); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary("duplicate set interval label [theRest=2]"); + + facetInterval.setSets(Arrays.asList(restFacetSetModel)); + facetInterval.setLabel("thesame"); + FacetInterval duplicateLabel = new FacetInterval("creator", "thesame", Arrays.asList(duplicate)); + facetIntervalsModel.setIntervals(Arrays.asList(facetInterval, duplicateLabel)); + query.setFacetIntervals(facetIntervalsModel); + response = query(query); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary("duplicate interval label [thesame=2]"); + } @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) diff --git a/e2e-test/java/org/alfresco/rest/search/StatsSearchTest.java b/e2e-test/java/org/alfresco/rest/search/StatsSearchTest.java index ac5932750..7546a2e58 100644 --- a/e2e-test/java/org/alfresco/rest/search/StatsSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/StatsSearchTest.java @@ -167,7 +167,7 @@ public class StatsSearchTest extends AbstractSearchTest SearchResponse response = query(query); assertStatsFacetedResponse(response, "creator", 1); RestGenericMetricModel countMetric = response.getContext().getFacets().get(0).getBuckets().get(0).getMetrics().get(0); - Integer count = response.getEntries().size(); + Integer count = response.getPagination().getTotalItems(); Map metricCount = (Map) countMetric.getValue(); assertEquals(count, metricCount.get("count")); From ea016eee9d83d4a827ef8ef766dbbec18593d066 Mon Sep 17 00:00:00 2001 From: Michael Suzuki Date: Mon, 22 May 2017 14:40:21 +0100 Subject: [PATCH 1148/1491] Added test to cover facet fields search test --- .../rest/search/FacetRangeSearchTest.java | 1 - .../rest/search/FacetedSearchTest.java | 91 ++++++++++++++----- 2 files changed, 67 insertions(+), 25 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java b/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java index 24f5a5fa4..5dd9c34b1 100644 --- a/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java @@ -61,7 +61,6 @@ import org.testng.annotations.Test; */ public class FacetRangeSearchTest extends AbstractSearchTest { - @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, description = "Check facet intervals mandatory fields") diff --git a/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java b/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java index ae8a7fcbd..c1770dc61 100644 --- a/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java @@ -64,30 +64,32 @@ public class FacetedSearchTest extends AbstractSearchTest * "count": 61, * "skipCount": 0 * }, - * "context": { - * "consistency": {"lastTxId": 512}, - * "facetQueries": [ + * "facetsFields": [ + * { + * "type": "query", + * "label": "foo", + * "buckets": [ * { - * "count": 61, - * "label": "small", - * "filterQuery": "content.size:[o TO 102400]" + * "label": "small", + * "filterQuery": "content.size:[0 TO 102400]", + * "display": 1 * }, * { - * "count": 0, - * "label": "large", - * "filterQuery": "content.size:[o TO 102400]" + * "label": "large", + * "filterQuery": "content.size:[1048576 TO 16777216]", + * "metrics": [ + * { + * "type": "count", + * "value": { + * "count": 0 + * } + * } + * ] * }, - * { - * "count": 0, - * "label": "medium", - * "filterQuery": "content.size:[o TO 102400]" - * } - * ] - * } * }} * @throws Exception */ - public void searchWithFaceting() throws Exception + public void searchWithQueryFaceting() throws Exception { SearchRequest query = new SearchRequest(); RestRequestQueryModel queryReq = new RestRequestQueryModel(); @@ -154,7 +156,7 @@ public class FacetedSearchTest extends AbstractSearchTest * "context": { * "consistency": {"lastTxId": 512}, * //Added below as part of SEARCH-374 - * "facetsFields": [ + * "facets": [ * { "label": "foo", * "buckets": [ * { "label": "small", "count": 61, "filterQuery": "content.size:[o TO 102400]"}, @@ -168,7 +170,7 @@ public class FacetedSearchTest extends AbstractSearchTest * * @throws Exception */ - public void searchFacetGroup() throws Exception + public void searchQueryFacetingWithGroup() throws Exception { SearchRequest query = new SearchRequest(); RestRequestQueryModel queryReq = new RestRequestQueryModel(); @@ -191,13 +193,15 @@ public class FacetedSearchTest extends AbstractSearchTest //We don't expect to see the FacetQueries if group is being used. Assert.assertTrue(response.getContext().getFacetQueries() == null); //Validate the facet field structure is correct. - Assert.assertFalse(response.getContext().getFacetsFields().isEmpty()); - Assert.assertEquals(response.getContext().getFacetsFields().get(0).getLabel(), "foo"); - FacetFieldBucket bucket = response.getContext().getFacetsFields().get(0).getBuckets().get(0); + Assert.assertFalse(response.getContext().getFacets().isEmpty()); + Assert.assertEquals(response.getContext().getFacets().get(0).getLabel(), "foo"); + + RestGenericBucketModel bucket = response.getContext().getFacets().get(0).getBuckets().get(0); bucket.assertThat().field("label").isNotEmpty(); - bucket.assertThat().field("count").isNotEmpty(); + Assert.assertEquals( bucket.getMetrics().get(0).getType(), "count"); + Assert.assertNotEquals( bucket.getMetrics().get(0).getValue(), ""); bucket.assertThat().field("filterQuery").isNotEmpty(); - response.getContext().getFacetsFields().get(0).getBuckets().forEach(action -> { + response.getContext().getFacets().get(0).getBuckets().forEach(action -> { switch (action.getLabel()) { case "small": @@ -217,4 +221,43 @@ public class FacetedSearchTest extends AbstractSearchTest } + @Test + /** + * { + * "query": { + * "query": "*" + * }, + * "facetFields": { + * "facets": [{"field": "cm:mimetype"},{"field": "modifier"}] + * } + * } + */ + public void searchWithFactedFields() throws Exception + { + SearchRequest query = new SearchRequest(); + RestRequestQueryModel queryReq = new RestRequestQueryModel(); + queryReq.setQuery("*"); + query.setQuery(queryReq); + RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); + Listfacets = new ArrayList(); + facets.add(new RestRequestFacetFieldModel("cm:mimetype")); + facets.add(new RestRequestFacetFieldModel("modifier")); + facetFields.setFacets(facets); + query.setFacetFields(facetFields); + SearchResponse response = query(query); + Assert.assertFalse(response.getContext().getFacetsFields().isEmpty()); + Assert.assertNull(response.getContext().getFacetQueries()); + Assert.assertNull(response.getContext().getFacets()); + RestResultBucketsModel model = response.getContext().getFacetsFields().get(0); + Assert.assertEquals(model.getLabel(), "modifier"); + + model.assertThat().field("label").is("modifier"); + FacetFieldBucket bucket1 = model.getBuckets().get(0); + bucket1.assertThat().field("label").is("System"); + bucket1.assertThat().field("display").is("System"); + bucket1.assertThat().field("filterQuery").is("modifier:System"); + bucket1.assertThat().field("count").is(684); + } + + } From ae6b69e354037dfb9013bc67b6f912204b1c5d6d Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Tue, 23 May 2017 12:25:14 +0300 Subject: [PATCH 1149/1491] REPO-2449: REPO-2485: added 2 tests for thumbnail and preview of a zip file --- .../rest/renditions/GetRenditionTests.java | 97 +++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/renditions/GetRenditionTests.java diff --git a/e2e-test/java/org/alfresco/rest/renditions/GetRenditionTests.java b/e2e-test/java/org/alfresco/rest/renditions/GetRenditionTests.java new file mode 100644 index 000000000..5e18e628d --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/renditions/GetRenditionTests.java @@ -0,0 +1,97 @@ +package org.alfresco.rest.renditions; + +import static org.alfresco.utility.report.log.Step.STEP; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestNodeModel; +import org.alfresco.rest.model.RestRenditionInfoModel; +import org.alfresco.utility.Utility; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.report.Bug.Status; +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; + +/** + * Handles tests related to GET api-explorer/#!/renditions + * @author Cristina Axinte + * + */ +public class GetRenditionTests extends RestTest +{ + private UserModel user; + private SiteModel site; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + user = dataUser.createRandomTestUser(); + site = dataSite.usingUser(user).createPublicRandomSite(); + } + + @Bug(id = "REPO-2449", status = Status.FIXED) + @Test(groups = { TestGroup.REST_API, TestGroup.RENDITIONS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.RENDITIONS }, executionType = ExecutionType.SANITY, + description = "Verify that ZIP document preview is rendered") + public void verifyPreviewOfZipFile() throws Exception + { + STEP("1. Create a folder in existing site"); + FolderModel folder = FolderModel.getRandomFolderModel(); + folder = dataContent.usingUser(user).usingSite(site).createFolder(folder); + + STEP("2. Upload a local ZIP file using RESTAPI"); + restClient.authenticateUser(user).configureRequestSpec().addMultiPart("filedata", Utility.getResourceTestDataFile("content-zip-test.zip")); + + RestNodeModel fileNode = restClient.authenticateUser(user).withCoreAPI().usingNode(folder).createNode(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + FileModel file = new FileModel("content-zip-test.zip"); + file.setCmisLocation(folder.getCmisLocation() + "/content-zip-test.zip"); + file.setNodeRef(fileNode.getId()); + + STEP("3. Create preview of ZIP file using RESTAPI"); + restClient.withCoreAPI().usingNode(file).createNodeRendition("pdf"); + restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); + + STEP("4. Verify preview of ZIP file is created using RESTAPI"); + RestRenditionInfoModel renditionInfo = restClient.withCoreAPI().usingNode(file).getNodeRenditionUntilIsCreated("pdf"); + restClient.assertStatusCodeIs(HttpStatus.OK); + renditionInfo.assertThat().field("status").is("CREATED"); + } + + @Bug(id = "REPO-2485", status = Status.FIXED) + @Test(groups = { TestGroup.REST_API, TestGroup.RENDITIONS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.RENDITIONS }, executionType = ExecutionType.SANITY, + description = "Verify that ZIP document thumbnail is rendered") + public void verifyThumbnailOfZipFile() throws Exception + { + STEP("1. Create a folder in existing site"); + FolderModel folder = FolderModel.getRandomFolderModel(); + folder = dataContent.usingUser(user).usingSite(site).createFolder(folder); + + STEP("2. Upload a local ZIP file using RESTAPI"); + restClient.authenticateUser(user).configureRequestSpec().addMultiPart("filedata", Utility.getResourceTestDataFile("content-zip-test.zip")); + + RestNodeModel fileNode = restClient.authenticateUser(user).withCoreAPI().usingNode(folder).createNode(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + FileModel file = new FileModel("content-zip-test.zip"); + file.setCmisLocation(folder.getCmisLocation() + "/content-zip-test.zip"); + file.setNodeRef(fileNode.getId()); + + STEP("3. Create thumbnail of ZIP file using RESTAPI"); + restClient.withCoreAPI().usingNode(file).createNodeRendition("doclib"); + restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); + + STEP("4. Verify thumbnail of ZIP file is created and has content using RESTAPI"); + RestRenditionInfoModel renditionInfo = restClient.withCoreAPI().usingNode(file).getNodeRenditionUntilIsCreated("doclib"); + restClient.assertStatusCodeIs(HttpStatus.OK); + renditionInfo.assertThat().field("status").is("CREATED"); + renditionInfo.assertThat().field("content.sizeInBytes").isGreaterThan(120); + } +} From a28aab06f89295bd7b2f53ffdfbb0bd25571510a Mon Sep 17 00:00:00 2001 From: Michael Suzuki Date: Wed, 24 May 2017 10:23:27 +0100 Subject: [PATCH 1150/1491] Search-340, added test to cover inclusive and exclusive range search --- .../rest/search/FacetRangeSearchTest.java | 123 ++++++++++++++---- 1 file changed, 100 insertions(+), 23 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java b/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java index 691b1c786..a74782b5a 100644 --- a/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java @@ -126,33 +126,39 @@ public class FacetRangeSearchTest extends AbstractSearchTest RestGenericFacetResponseModel facetResponseModel = response.getContext().getFacets().get(0); RestGenericBucketModel bucket = facetResponseModel.getBuckets().get(0); - bucket.assertThat().field("label").is("0 - 200"); - bucket.assertThat().field("filterQuery").is("content.size:(0 TO 200)"); + bucket.assertThat().field("label").is("[0 - 200)"); + bucket.assertThat().field("filterQuery").is("content.size:[0 TO 200>"); Map metric = (Map) bucket.getMetrics().get(0).getValue(); - Assert.assertTrue(new Integer(metric.get("count")) > 4); + Assert.assertTrue(new Integer(metric.get("count")) >= 4); Map info = (Map) bucket.getBucketInfo(); Assert.assertEquals(info.get("start"),"0"); Assert.assertEquals(info.get("end"),"200"); - Assert.assertTrue(!info.get("count").isEmpty()); + Assert.assertNull(info.get("count")); + Assert.assertEquals(info.get("startInclusive"),"true"); + Assert.assertEquals(info.get("endInclusive"),"false"); bucket = facetResponseModel.getBuckets().get(1); - bucket.assertThat().field("label").is("200 - 400"); - bucket.assertThat().field("filterQuery").is("content.size:(200 TO 400)"); + bucket.assertThat().field("label").is("[200 - 400)"); + bucket.assertThat().field("filterQuery").is("content.size:[200 TO 400>"); metric = (Map) bucket.getMetrics().get(0).getValue(); Integer count = new Integer(metric.get("count")); Assert.assertTrue(count >= 4); info = (Map) bucket.getBucketInfo(); Assert.assertEquals(info.get("start"),"200"); Assert.assertEquals(info.get("end"),"400"); + Assert.assertEquals(info.get("startInclusive"),"true"); + Assert.assertEquals(info.get("endInclusive"),"false"); bucket = facetResponseModel.getBuckets().get(2); - bucket.assertThat().field("label").is("400 - 600"); - bucket.assertThat().field("filterQuery").is("content.size:(400 TO 600)"); + bucket.assertThat().field("label").is("[400 - 600)"); + bucket.assertThat().field("filterQuery").is("content.size:[400 TO 600>"); metric = (Map) bucket.getMetrics().get(0).getValue(); Assert.assertTrue(new Integer(metric.get("count")) >= 7); info = (Map) bucket.getBucketInfo(); Assert.assertEquals(info.get("start"),"400"); Assert.assertEquals(info.get("end"),"600"); + Assert.assertEquals(info.get("startInclusive"),"true"); + Assert.assertEquals(info.get("endInclusive"),"false"); } @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) @@ -177,34 +183,40 @@ public class FacetRangeSearchTest extends AbstractSearchTest RestGenericFacetResponseModel facetResponseModel = response.getContext().getFacets().get(0); RestGenericBucketModel bucket = facetResponseModel.getBuckets().get(0); - bucket.assertThat().field("label").is("0 - 200"); - bucket.assertThat().field("filterQuery").is("content.size:(0 TO 200)"); + bucket.assertThat().field("label").is("[0 - 200)"); + bucket.assertThat().field("filterQuery").is("content.size:[0 TO 200>"); Map metric = (Map) bucket.getMetrics().get(0).getValue(); Assert.assertTrue(new Integer(metric.get("count")) >= 4); Map info = (Map) bucket.getBucketInfo(); Assert.assertEquals(info.get("start"),"0"); Assert.assertEquals(info.get("end"),"200"); - Assert.assertTrue(!info.get("count").isEmpty()); + Assert.assertEquals(info.get("startInclusive"),"true"); + Assert.assertEquals(info.get("endInclusive"),"false"); + Assert.assertNull(info.get("count")); bucket = facetResponseModel.getBuckets().get(1); - bucket.assertThat().field("label").is("200 - 400"); - bucket.assertThat().field("filterQuery").is("content.size:(200 TO 400)"); + bucket.assertThat().field("label").is("[200 - 400)"); + bucket.assertThat().field("filterQuery").is("content.size:[200 TO 400>"); info = (Map) bucket.getBucketInfo(); Assert.assertEquals(info.get("start"),"200"); Assert.assertEquals(info.get("end"),"400"); metric = (Map) bucket.getMetrics().get(0).getValue(); Assert.assertTrue(new Integer(metric.get("count")) >= 4); - Assert.assertTrue(!info.get("count").isEmpty()); + Assert.assertNull(info.get("count")); + Assert.assertEquals(info.get("startInclusive"),"true"); + Assert.assertEquals(info.get("endInclusive"),"false"); bucket = facetResponseModel.getBuckets().get(2); - bucket.assertThat().field("label").is("400 - 500"); - bucket.assertThat().field("filterQuery").is("content.size:(400 TO 500)"); + bucket.assertThat().field("label").is("[400 - 500)"); + bucket.assertThat().field("filterQuery").is("content.size:[400 TO 500>"); metric = (Map) bucket.getMetrics().get(0).getValue(); Assert.assertTrue(new Integer(metric.get("count")) >= 3); info = (Map) bucket.getBucketInfo(); Assert.assertEquals(info.get("start"),"400"); Assert.assertEquals(info.get("end"),"500"); - Assert.assertTrue(!info.get("count").isEmpty()); + Assert.assertNull(info.get("count")); + Assert.assertEquals(info.get("startInclusive"),"true"); + Assert.assertEquals(info.get("endInclusive"),"false"); } @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, @@ -227,22 +239,26 @@ public class FacetRangeSearchTest extends AbstractSearchTest RestGenericFacetResponseModel facetResponseModel = response.getContext().getFacets().get(0); RestGenericBucketModel bucket = facetResponseModel.getBuckets().get(0); - bucket.assertThat().field("label").is("2015-09-29T10:45:15.729Z - 2016-07-05T10:45:15.729Z"); - bucket.assertThat().field("filterQuery").is("created:(2015-09-29T10:45:15.729Z TO 2016-07-05T10:45:15.729Z)"); + bucket.assertThat().field("label").is("[2015-09-29T10:45:15.729Z - 2016-07-05T10:45:15.729Z)"); + bucket.assertThat().field("filterQuery").is("created:[2015-09-29T10:45:15.729Z TO 2016-07-05T10:45:15.729Z>"); bucket.getMetrics().get(0).assertThat().field("value").is("{count=1}"); Map info = (Map) bucket.getBucketInfo(); Assert.assertEquals(info.get("start"),"2015-09-29T10:45:15.729Z"); Assert.assertEquals(info.get("end"),"2016-07-05T10:45:15.729Z"); - Assert.assertEquals(info.get("count"),"1"); + Assert.assertNull(info.get("count"),"1"); + Assert.assertEquals(info.get("startInclusive"),"true"); + Assert.assertEquals(info.get("endInclusive"),"false"); bucket = facetResponseModel.getBuckets().get(1); - bucket.assertThat().field("label").is("2016-07-05T10:45:15.729Z - 2017-04-11T10:45:15.729Z"); - bucket.assertThat().field("filterQuery").is("created:(2016-07-05T10:45:15.729Z TO 2017-04-11T10:45:15.729Z)"); + bucket.assertThat().field("label").is("[2016-07-05T10:45:15.729Z - 2017-04-11T10:45:15.729Z)"); + bucket.assertThat().field("filterQuery").is("created:[2016-07-05T10:45:15.729Z TO 2017-04-11T10:45:15.729Z>"); bucket.getMetrics().get(0).assertThat().field("value").is("{count=0}"); info = (Map) bucket.getBucketInfo(); Assert.assertEquals(info.get("start"),"2016-07-05T10:45:15.729Z"); Assert.assertEquals(info.get("end"),"2017-04-11T10:45:15.729Z"); - Assert.assertEquals(info.get("count"),"0"); + Assert.assertNull(info.get("count"),"0"); + Assert.assertEquals(info.get("startInclusive"),"true"); + Assert.assertEquals(info.get("endInclusive"),"false"); } @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) @@ -266,4 +282,65 @@ public class FacetRangeSearchTest extends AbstractSearchTest ranges.add(facetCountRangeModel); query.setRanges(ranges); } + + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, + description = "Check basic facet range search api") + public void searchWithRangeAndIncludeUpperBound()throws Exception + { + SearchRequest query = createQuery("A*"); + + RestRequestRangesModel facetRangeModel = new RestRequestRangesModel(); + facetRangeModel.setField("content.size"); + facetRangeModel.setStart("0"); + facetRangeModel.setEnd("500"); + facetRangeModel.setGap("200"); + List include = new ArrayList(); + include.add("upper"); +// include.add("lower"); + facetRangeModel.setInclude(include); + List ranges = new ArrayList(); + ranges.add(facetRangeModel); + query.setRanges(ranges); + SearchResponse response = query(query); + response.assertThat().entriesListIsNotEmpty(); + response.getContext().assertThat().field("facets").isNotEmpty(); + RestGenericFacetResponseModel facetResponseModel = response.getContext().getFacets().get(0); + + RestGenericBucketModel bucket = facetResponseModel.getBuckets().get(0); + bucket.assertThat().field("label").is("(0 - 200]"); + bucket.assertThat().field("filterQuery").is("content.size:<0 TO 200]"); + Map metric = (Map) bucket.getMetrics().get(0).getValue(); + Assert.assertTrue(new Integer(metric.get("count")) >= 4); + Map info = (Map) bucket.getBucketInfo(); + Assert.assertEquals(info.get("start"),"0"); + Assert.assertEquals(info.get("end"),"200"); + Assert.assertNull(info.get("count")); + Assert.assertEquals(info.get("startInclusive"),"false"); + Assert.assertEquals(info.get("endInclusive"),"true"); + + bucket = facetResponseModel.getBuckets().get(1); + bucket.assertThat().field("label").is("(200 - 400]"); + bucket.assertThat().field("filterQuery").is("content.size:<200 TO 400]"); + metric = (Map) bucket.getMetrics().get(0).getValue(); + Integer count = new Integer(metric.get("count")); + Assert.assertTrue(count >= 4); + info = (Map) bucket.getBucketInfo(); + Assert.assertEquals(info.get("start"),"200"); + Assert.assertEquals(info.get("end"),"400"); + Assert.assertEquals(info.get("startInclusive"),"false"); + Assert.assertEquals(info.get("endInclusive"),"true"); + + bucket = facetResponseModel.getBuckets().get(2); + bucket.assertThat().field("label").is("(400 - 600]"); + bucket.assertThat().field("filterQuery").is("content.size:<400 TO 600]"); + metric = (Map) bucket.getMetrics().get(0).getValue(); + Assert.assertTrue(new Integer(metric.get("count")) >= 7); + info = (Map) bucket.getBucketInfo(); + Assert.assertEquals(info.get("start"),"400"); + Assert.assertEquals(info.get("end"),"600"); + Assert.assertEquals(info.get("startInclusive"),"false"); + Assert.assertEquals(info.get("endInclusive"),"true"); + } + } From 1382d828ecf73450fe71578f003cc6c0f1df7d8f Mon Sep 17 00:00:00 2001 From: Gethin James Date: Fri, 26 May 2017 09:30:31 +0200 Subject: [PATCH 1151/1491] SEARCH-451: Switching to the new pivot format, and fixing stats tests --- .../rest/search/PivotFacetedSearchTest.java | 80 ++++++++++++++++--- .../alfresco/rest/search/StatsSearchTest.java | 20 ++--- 2 files changed, 79 insertions(+), 21 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/PivotFacetedSearchTest.java b/e2e-test/java/org/alfresco/rest/search/PivotFacetedSearchTest.java index 4f1a8ad09..ed8c109de 100644 --- a/e2e-test/java/org/alfresco/rest/search/PivotFacetedSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/PivotFacetedSearchTest.java @@ -19,6 +19,7 @@ package org.alfresco.rest.search; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import org.alfresco.rest.model.RestErrorModel; @@ -54,16 +55,16 @@ public class PivotFacetedSearchTest extends AbstractSearchTest RestRequestPivotModel pivots = new RestRequestPivotModel(); pivotModelList.add(pivots); query.setPivots(pivotModelList); - - SearchResponse response = query(query); + + SearchResponse response = query(query); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() .containsSummary(String.format(RestErrorModel.MANDATORY_PARAM, "pivot key")); - pivots.setKey("none_like_this"); - response = query(query); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary("Pivot parameter none_like_this is does not reference a facet Field"); + response = query(query); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary("invalid argument was received") + .containsSummary("Pivot parameter none_like_this does not reference"); } @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH }) @@ -94,6 +95,63 @@ public class PivotFacetedSearchTest extends AbstractSearchTest assertPivotResponse(response, "creator", null); } + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH }, executionType = ExecutionType.REGRESSION, + description = "Checks nested pivot using Search api") + public void searchWithNestedPivoting() throws Exception + { + SearchRequest query = carsQuery(); + + RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); + List list = new ArrayList<>(); + RestRequestFacetFieldModel restRequestFacetFieldModel = new RestRequestFacetFieldModel("SITE"); + restRequestFacetFieldModel.setLabel("site"); + list.add(restRequestFacetFieldModel); + list.add(new RestRequestFacetFieldModel("creator")); + list.add(new RestRequestFacetFieldModel("modifier")); + facetFields.setFacets(list); + query.setFacetFields(facetFields); + query.setIncludeRequest(false); + + List pivotModelList = new ArrayList<>(); + RestRequestPivotModel sitepivots = new RestRequestPivotModel(); + sitepivots.setKey("site"); + RestRequestPivotModel creatorpivot = new RestRequestPivotModel(); + creatorpivot.setKey("creator"); + RestRequestPivotModel modifierpivot = new RestRequestPivotModel(); + modifierpivot.setKey("modifier"); + sitepivots.setPivots(Arrays.asList(creatorpivot, modifierpivot)); + pivotModelList.add(sitepivots); + query.setPivots(pivotModelList); + + SearchResponse response = query(query); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary("invalid argument was received") + .containsSummary("Currently only 1 nested pivot is supported, you have 2"); + + pivotModelList = new ArrayList<>(); + sitepivots = new RestRequestPivotModel(); + sitepivots.setKey("site"); + sitepivots.setPivots(Arrays.asList(modifierpivot)); + pivotModelList.add(sitepivots); + pivotModelList.add(creatorpivot); + query.setPivots(pivotModelList); + + response = query(query); + assertPivotResponse(response, "SITE", "site"); + + RestGenericFacetResponseModel siteResponse = response.getContext().getFacets().get(0); + RestGenericBucketModel bucket = siteResponse.getBuckets().get(0); + RestGenericFacetResponseModel modifiedResponse = bucket.getFacets().get(0); + modifiedResponse.assertThat().field("type").is("pivot"); + modifiedResponse.assertThat().field("label").is("modifier"); + + RestGenericFacetResponseModel creatorResponse = response.getContext().getFacets().get(1); + creatorResponse.assertThat().field("type").is("pivot"); + creatorResponse.assertThat().field("label").is("creator"); + } + + private void assertPivotResponse(SearchResponse response, String field, String alabel) throws Exception { String label = alabel!=null?alabel:field; @@ -139,11 +197,11 @@ public class PivotFacetedSearchTest extends AbstractSearchTest assertPivotResponse(response, "creator", "create"); //Now check the nesting - RestGenericFacetResponseModel facetResponseModel = response.getContext().getFacets().get(0); - RestGenericFacetResponseModel nestedFacet = facetResponseModel.getBuckets().get(0).getFacets().get(0); - RestGenericBucketModel bucket = nestedFacet.getBuckets().get(0); - nestedFacet.assertThat().field("label").isNotEmpty(); - nestedFacet.assertThat().field("label").is("aLabel"); + RestGenericFacetResponseModel labelResponseModel = response.getContext().getFacets().get(1); + labelResponseModel.assertThat().field("type").is("pivot"); + labelResponseModel.assertThat().field("label").isNotEmpty(); + labelResponseModel.assertThat().field("label").is("aLabel"); + RestGenericBucketModel bucket = labelResponseModel.getBuckets().get(0); bucket.assertThat().field("filterQuery").is("modifier:"+bucket.getLabel()); Assert.assertEquals("count", bucket.getMetrics().get(0).getType()); Assert.assertTrue(bucket.getMetrics().get(0).getValue().toString().contains("{count=")); diff --git a/e2e-test/java/org/alfresco/rest/search/StatsSearchTest.java b/e2e-test/java/org/alfresco/rest/search/StatsSearchTest.java index 7546a2e58..5cacb186f 100644 --- a/e2e-test/java/org/alfresco/rest/search/StatsSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/StatsSearchTest.java @@ -203,7 +203,6 @@ public class StatsSearchTest extends AbstractSearchTest query.setFacetFields(facetFields); query.setIncludeRequest(false); - List pivotModelList = new ArrayList<>(); RestRequestPivotModel pivots = new RestRequestPivotModel(); pivots.setKey("b0"); @@ -211,9 +210,10 @@ public class StatsSearchTest extends AbstractSearchTest pivotn.setKey("created"); RestRequestPivotModel pivot2 = new RestRequestPivotModel(); pivot2.setKey("aNumber"); + + pivotn.setPivots(Arrays.asList(pivot2)); + pivots.setPivots(Arrays.asList(pivotn)); pivotModelList.add(pivots); - pivotModelList.add(pivotn); - pivotModelList.add(pivot2); query.setPivots(pivotModelList); List statsModels = new ArrayList<>(); @@ -232,14 +232,13 @@ public class StatsSearchTest extends AbstractSearchTest RestGenericFacetResponseModel facetResponseModel = response.getContext().getFacets().get(0); facetResponseModel.assertThat().field("type").is("pivot"); facetResponseModel.assertThat().field("label").is("b0"); - assertEquals(facetResponseModel.getBuckets().get(0).getMetrics().size(), 8, "Metrics on the pivot bucket"); + //pivot created + RestGenericFacetResponseModel created = facetResponseModel.getBuckets().get(0).getFacets().get(0); + created.assertThat().field("type").is("pivot"); + created.assertThat().field("label").is("created"); //Another nested stats - assertEquals(facetResponseModel.getBuckets().get(0).getFacets().get(0).getBuckets().get(0).getMetrics().size(), 8, "Metrics are on the end of a pivot bucket"); - - RestGenericFacetResponseModel statsFacet = response.getContext().getFacets().get(1); - statsFacet.assertThat().field("type").is("stats"); - statsFacet.assertThat().field("label").is("aNumber"); + assertEquals(created.getBuckets().get(0).getMetrics().size(), 8, "Metrics are on the end of a pivot bucket"); } @@ -269,8 +268,9 @@ public class StatsSearchTest extends AbstractSearchTest pivots.setKey("creator"); RestRequestPivotModel pivotn = new RestRequestPivotModel(); pivotn.setKey("numericId"); + + pivots.setPivots(Arrays.asList(pivotn)); pivotModelList.add(pivots); - pivotModelList.add(pivotn); query.setPivots(pivotModelList); List statsModels = new ArrayList<>(); From 567bdf56ed295e074fa46bbe7a50c2be9b52a5f2 Mon Sep 17 00:00:00 2001 From: Mihaela Popa Date: Mon, 29 May 2017 18:31:32 +0300 Subject: [PATCH 1152/1491] REPO-2451: Service Pack: MNT-17612: AccessDeniedException in Edit Offline Upload New Version Added tests to cover lock and unlock endpoints --- .../alfresco/rest/nodes/NodesLockTests.java | 765 ++++++++++++++++++ .../alfresco/rest/nodes/NodesUnlockTests.java | 161 ++++ 2 files changed, 926 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/nodes/NodesLockTests.java create mode 100644 e2e-test/java/org/alfresco/rest/nodes/NodesUnlockTests.java diff --git a/e2e-test/java/org/alfresco/rest/nodes/NodesLockTests.java b/e2e-test/java/org/alfresco/rest/nodes/NodesLockTests.java new file mode 100644 index 000000000..6c197f839 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/nodes/NodesLockTests.java @@ -0,0 +1,765 @@ +package org.alfresco.rest.nodes; + +import static org.alfresco.utility.report.log.Step.STEP; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestNodeLockBodyModel; +import org.alfresco.rest.model.RestNodeModel; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.report.Bug.Status; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class NodesLockTests extends RestTest +{ + private UserModel user1, user2, adminUser; + private SiteModel publicSite; + private FileModel file1; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + publicSite = dataSite.usingUser(adminUser).createPublicRandomSite(); + user1 = dataUser.createRandomTestUser(); + user2 = dataUser.createRandomTestUser(); + dataUser.addUserToSite(user1, publicSite, UserRole.SiteCollaborator); + user1.setUserRole(UserRole.SiteCollaborator); + dataUser.addUserToSite(user2, publicSite, UserRole.SiteCollaborator); + user2.setUserRole(UserRole.SiteCollaborator); + + } + + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.NODES }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator can lock PERSISTENT after EPHEMERAL lock made by different user") + public void lockEphemeralAndRelockPersistentWithDifferentUser() throws Exception + { + + STEP("1. Add user(s) as collaborators to the site created by administrator and add a file in this site."); + file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); + + STEP("2. Verify with admin that the file is not locked."); + RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1) + .usingParams("include=isLocked").getNode(); + file1Model1.assertThat().field("isLocked").is(false); + + STEP("3. Lock the file using mode EPHEMERAL with user1 (POST nodes/{nodeId}/lock)."); + RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); + lockBodyModel.setLifetime("EPHEMERAL"); + lockBodyModel.setTimeToExpire(20); + lockBodyModel.setType("FULL"); + restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + + STEP("4. Verify with user1 that the file is locked."); + RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1) + .usingParams("include=isLocked").getNode(); + file1Model2.assertThat().field("isLocked").is(true).assertThat().field("properties").contains("lockLifetime=EPHEMERAL") + .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); + + STEP("5. Lock the file using mode PERSISTENT with user2 while the file is still locked"); + RestNodeLockBodyModel lockBodyModel2 = new RestNodeLockBodyModel(); + lockBodyModel2.setLifetime("PERSISTENT"); + lockBodyModel2.setTimeToExpire(20); + lockBodyModel2.setType("ALLOW_OWNER_CHANGES"); + restClient.authenticateUser(user2).withCoreAPI().usingNode(file1).usingParams("include=isLocked") + .lockNode(lockBodyModel2); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() + .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .containsSummary(String.format(RestErrorModel.LOCKED_NODE_SUMMARY, file1.getNodeRefWithoutVersion())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.NODES }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator can lock PERSISTENT after EPHEMERAL lock made by different user") + public void lockEphemeralAndRelockEphemeralWithDifferentUser() throws Exception + { + + STEP("1. Add user(s) as collaborators to the site created by administrator and add a file in this site."); + file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); + + STEP("2. Verify with admin that the file is not locked."); + RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1) + .usingParams("include=isLocked").getNode(); + file1Model1.assertThat().field("isLocked").is(false); + + STEP("3. Lock the file using mode EPHEMERAL with user1 (POST nodes/{nodeId}/lock)."); + RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); + lockBodyModel.setLifetime("EPHEMERAL"); + lockBodyModel.setTimeToExpire(20); + lockBodyModel.setType("FULL"); + restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + + STEP("4. Verify with user1 that the file is locked."); + RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1) + .usingParams("include=isLocked").getNode(); + file1Model2.assertThat().field("isLocked").is(true).assertThat().field("properties").contains("lockLifetime=EPHEMERAL") + .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); + + STEP("5. Lock the file using mode EPHEMERAL with user2 while the file is still locked"); + RestNodeLockBodyModel lockBodyModel2 = new RestNodeLockBodyModel(); + lockBodyModel2.setLifetime("EPHEMERAL"); + lockBodyModel2.setTimeToExpire(20); + lockBodyModel2.setType("FULL"); + restClient.authenticateUser(user2).withCoreAPI().usingNode(file1).usingParams("include=isLocked") + .lockNode(lockBodyModel2); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() + .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .containsSummary(String.format(RestErrorModel.LOCKED_NODE_SUMMARY, file1.getNodeRefWithoutVersion())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.NODES }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator can lock EPHEMERAL after EPHEMERAL lock made by same user") + public void lockEphemeralAndRelockEphemeralWithSameUser() throws Exception + { + + STEP("1. Add user(s) as collaborators to the site created by administrator and add a file in this site."); + file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); + + STEP("2. Verify with admin that the file is not locked."); + RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1) + .usingParams("include=isLocked").getNode(); + file1Model1.assertThat().field("isLocked").is(false); + + STEP("3. Lock the file using mode EPHEMERAL with user1 (POST nodes/{nodeId}/lock)."); + RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); + lockBodyModel.setLifetime("EPHEMERAL"); + lockBodyModel.setTimeToExpire(20); + lockBodyModel.setType("FULL"); + restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + + STEP("4. Verify with user1 that the file is locked."); + RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1) + .usingParams("include=isLocked").getNode(); + file1Model2.assertThat().field("isLocked").is(true).assertThat().field("properties").contains("lockLifetime=EPHEMERAL") + .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); + + STEP("5. Lock the file using mode EPHEMERAL with user1 while the file is still locked"); + RestNodeLockBodyModel lockBodyModel2 = new RestNodeLockBodyModel(); + lockBodyModel2.setLifetime("EPHEMERAL"); + lockBodyModel2.setTimeToExpire(20); + lockBodyModel2.setType("FULL"); + RestNodeModel file1Model3 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1) + .usingParams("include=isLocked").lockNode(lockBodyModel2); + restClient.assertStatusCodeIs(HttpStatus.OK); + file1Model3.assertThat().field("isLocked").is(true).assertThat().field("properties").contains("lockLifetime=EPHEMERAL") + .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); + } + + @Bug(id = "MNT-17612", status = Status.FIXED, description = "AccessDeniedException in AOS Edit Offline Upload New Version") + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.NODES }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator can lock PERSISTENT after EPHEMERAL lock made by same user") + public void lockEphemeralAndRelockPersistentWithSameUser() throws Exception + { + + STEP("1. Add user(s) as collaborators to the site created by administrator and add a file in this site."); + file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); + + STEP("2. Verify with admin that the file is not locked."); + RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1) + .usingParams("include=isLocked").getNode(); + file1Model1.assertThat().field("isLocked").is(false); + + STEP("3. Lock the file using mode EPHEMERAL with user1 (POST nodes/{nodeId}/lock)."); + RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); + lockBodyModel.setLifetime("EPHEMERAL"); + lockBodyModel.setTimeToExpire(2); + lockBodyModel.setType("FULL"); + restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + + STEP("4. Verify with user1 that the file is locked."); + RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1) + .usingParams("include=isLocked").getNode(); + file1Model2.assertThat().field("isLocked").is(true).assertThat().field("properties").contains("lockLifetime=EPHEMERAL") + .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); + + STEP("5. Lock the file using mode PERSISTENT with user1 while the file is still locked"); + RestNodeLockBodyModel lockBodyModel2 = new RestNodeLockBodyModel(); + lockBodyModel2.setLifetime("PERSISTENT"); + lockBodyModel2.setTimeToExpire(20); + lockBodyModel2.setType("ALLOW_OWNER_CHANGES"); + RestNodeModel file1Model3 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1) + .usingParams("include=isLocked").lockNode(lockBodyModel2); + restClient.assertStatusCodeIs(HttpStatus.OK); + file1Model3.assertThat().field("isLocked").is(true).assertThat().field("properties").contains("lockLifetime=EPHEMERAL") + .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); + + STEP("6. Verify that the file is locked PERSISTENT only after EPHEMERAL lock has expired"); + try + { + Thread.sleep(2500); + } + finally + { + } + RestNodeModel file1Model4 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1) + .usingParams("include=isLocked").getNode(); + file1Model4.assertThat().field("isLocked").is(true).assertThat().field("properties").contains("lockLifetime=PERSISTENT") + .assertThat().field("properties").contains("lockType=WRITE_LOCK"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.NODES }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator can lock EPHEMERAL after PERSISTENT lock made by different user") + public void lockPersistentAndRelockEphemeralWithDifferentUser() throws Exception + { + + STEP("1. Add user(s) as collaborators to the site created by administrator and add a file in this site."); + file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); + + STEP("2. Verify with admin that the file is not locked."); + RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1) + .usingParams("include=isLocked").getNode(); + file1Model1.assertThat().field("isLocked").is(false); + + STEP("3. Lock the file using mode PERSISTENT with user1 (POST nodes/{nodeId}/lock)."); + RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); + lockBodyModel.setLifetime("PERSISTENT"); + lockBodyModel.setTimeToExpire(20); + lockBodyModel.setType("ALLOW_OWNER_CHANGES"); + restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + + STEP("4. Verify with user1 that the file is locked."); + RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1) + .usingParams("include=isLocked").getNode(); + file1Model2.assertThat().field("isLocked").is(true).assertThat().field("properties").contains("lockLifetime=PERSISTENT") + .assertThat().field("properties").contains("lockType=WRITE_LOCK"); + + STEP("5. Lock the file using mode EPHEMERAL with user2 while the file is still locked"); + RestNodeLockBodyModel lockBodyModel2 = new RestNodeLockBodyModel(); + lockBodyModel2.setLifetime("EPHEMERAL"); + lockBodyModel2.setTimeToExpire(20); + lockBodyModel2.setType("FULL"); + restClient.authenticateUser(user2).withCoreAPI().usingNode(file1).usingParams("include=isLocked") + .lockNode(lockBodyModel2); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() + .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .containsSummary(String.format(RestErrorModel.LOCKED_NODE_SUMMARY, file1.getNodeRefWithoutVersion())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.NODES }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator can lock EPHEMERAL after PERSISTENT lock made by different user") + public void lockPersistentAndRelockPersistentWithDifferentUser() throws Exception + { + + STEP("1. Add user(s) as collaborators to the site created by administrator and add a file in this site."); + file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); + + STEP("2. Verify with admin that the file is not locked."); + RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1) + .usingParams("include=isLocked").getNode(); + file1Model1.assertThat().field("isLocked").is(false); + + STEP("3. Lock the file using mode PERSISTENT with user1 (POST nodes/{nodeId}/lock)."); + RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); + lockBodyModel.setLifetime("PERSISTENT"); + lockBodyModel.setTimeToExpire(20); + lockBodyModel.setType("ALLOW_OWNER_CHANGES"); + restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + + STEP("4. Verify with user1 that the file is locked."); + RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1) + .usingParams("include=isLocked").getNode(); + file1Model2.assertThat().field("isLocked").is(true).assertThat().field("properties").contains("lockLifetime=PERSISTENT") + .assertThat().field("properties").contains("lockType=WRITE_LOCK"); + + STEP("5. Lock the file using mode PERSISTENT with user2 while the file is still locked"); + RestNodeLockBodyModel lockBodyModel2 = new RestNodeLockBodyModel(); + lockBodyModel2.setLifetime("PERSISTENT"); + lockBodyModel2.setTimeToExpire(20); + lockBodyModel2.setType("ALLOW_OWNER_CHANGES"); + restClient.authenticateUser(user2).withCoreAPI().usingNode(file1).usingParams("include=isLocked") + .lockNode(lockBodyModel2); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() + .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .containsSummary(String.format(RestErrorModel.LOCKED_NODE_SUMMARY, file1.getNodeRefWithoutVersion())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.NODES }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator can lock EPHEMERAL after PERSISTENT lock made by different user is expired") + public void lockPersistentAndRelockEphemeralAfterExpiredLockDifferentUser() throws Exception + { + + STEP("1. Add user(s) as collaborators to the site created by administrator and add a file in this site."); + file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); + + STEP("2. Verify with admin that the file is not locked."); + RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1) + .usingParams("include=isLocked").getNode(); + file1Model1.assertThat().field("isLocked").is(false); + + STEP("3. Lock the file using mode PERSISTENT with user1 (POST nodes/{nodeId}/lock)."); + RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); + lockBodyModel.setLifetime("PERSISTENT"); + lockBodyModel.setTimeToExpire(1); + lockBodyModel.setType("ALLOW_OWNER_CHANGES"); + restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + + STEP("4. Verify with admin that the file is locked."); + RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1) + .usingParams("include=isLocked").getNode(); + file1Model2.assertThat().field("isLocked").is(true).assertThat().field("properties").contains("lockLifetime=PERSISTENT") + .assertThat().field("properties").contains("lockType=WRITE_LOCK"); + + STEP("5. Lock the file using mode EPHEMERAL with user2 while the first lock has expired"); + RestNodeLockBodyModel lockBodyModel2 = new RestNodeLockBodyModel(); + lockBodyModel2.setLifetime("EPHEMERAL"); + lockBodyModel2.setTimeToExpire(20); + lockBodyModel2.setType("FULL"); + try + { + Thread.sleep(1500); + } + finally + { + } + RestNodeModel file1Model3 = restClient.authenticateUser(user2).withCoreAPI().usingNode(file1) + .usingParams("include=isLocked").lockNode(lockBodyModel2); + restClient.assertStatusCodeIs(HttpStatus.OK); + file1Model3.assertThat().field("isLocked").is(true).assertThat().field("properties").contains("lockLifetime=EPHEMERAL") + .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); + } + + @Bug(id = "MNT-17612", status = Status.FIXED, description = "AccessDeniedException in AOS Edit Offline Upload New Version") + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.NODES }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator can lock PERSISTENT after EPHEMERAL lock made by another user is expired") + public void lockEphemeralAndRelockPersistentAfterExpiredLockDifferentUser() throws Exception + { + + STEP("1. Add user(s) as collaborators to the site created by administrator and add a file in this site."); + file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); + + STEP("2. Verify with admin that the file is not locked."); + RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1) + .usingParams("include=isLocked").getNode(); + file1Model1.assertThat().field("isLocked").is(false); + + STEP("3. Lock the file using mode EPHEMERAL with user1 (POST nodes/{nodeId}/lock)."); + RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); + lockBodyModel.setLifetime("EPHEMERAL"); + lockBodyModel.setTimeToExpire(1); + lockBodyModel.setType("FULL"); + restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + + STEP("4. Verify with user1 that the file is locked."); + RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1) + .usingParams("include=isLocked").getNode(); + file1Model2.assertThat().field("isLocked").is(true).assertThat().field("properties").contains("lockLifetime=EPHEMERAL") + .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); + + STEP("5. Lock the file using mode PERSISTENT with user2 after the first lock has expired"); + RestNodeLockBodyModel lockBodyModel2 = new RestNodeLockBodyModel(); + lockBodyModel2.setLifetime("PERSISTENT"); + lockBodyModel2.setTimeToExpire(20); + lockBodyModel2.setType("ALLOW_OWNER_CHANGES"); + try + { + Thread.sleep(1500); + } + finally + { + } + RestNodeModel file1Model3 = restClient.authenticateUser(user2).withCoreAPI().usingNode(file1) + .usingParams("include=isLocked").lockNode(lockBodyModel2); + restClient.assertStatusCodeIs(HttpStatus.OK); + file1Model3.assertThat().field("isLocked").is(true).assertThat().field("properties").contains("lockLifetime=PERSISTENT") + .assertThat().field("properties").contains("lockType=WRITE_LOCK"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.NODES }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator can lock EPHEMERAL after EPHEMERAL lock made by another user is expired") + public void lockEphemeralAndRelockEphemeralAfterExpiredLockDifferentUser() throws Exception + { + + STEP("1. Add user(s) as collaborators to the site created by administrator and add a file in this site."); + file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); + + STEP("2. Verify with admin that the file is not locked."); + RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1) + .usingParams("include=isLocked").getNode(); + file1Model1.assertThat().field("isLocked").is(false); + + STEP("3. Lock the file using mode EPHEMERAL with user1 (POST nodes/{nodeId}/lock)."); + RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); + lockBodyModel.setLifetime("EPHEMERAL"); + lockBodyModel.setTimeToExpire(1); + lockBodyModel.setType("FULL"); + restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + + STEP("4. Verify with user1 that the file is locked."); + RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1) + .usingParams("include=isLocked").getNode(); + file1Model2.assertThat().field("isLocked").is(true).assertThat().field("properties").contains("lockLifetime=EPHEMERAL") + .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); + + STEP("5. Lock the file using mode EPHEMERAL with user2 while the first lock has expired"); + RestNodeLockBodyModel lockBodyModel2 = new RestNodeLockBodyModel(); + lockBodyModel2.setLifetime("EPHEMERAL"); + lockBodyModel2.setTimeToExpire(20); + lockBodyModel2.setType("FULL"); + try + { + Thread.sleep(1500); + } + finally + { + } + RestNodeModel file1Model3 = restClient.authenticateUser(user2).withCoreAPI().usingNode(file1) + .usingParams("include=isLocked").lockNode(lockBodyModel2); + restClient.assertStatusCodeIs(HttpStatus.OK); + file1Model3.assertThat().field("isLocked").is(true); + file1Model3.assertThat().field("properties").contains("lockLifetime=EPHEMERAL").assertThat().field("properties") + .contains("lockType=READ_ONLY_LOCK"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.NODES }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator can lock EPHEMERAL after PERSISTENT lock made by different user is expired") + public void lockPersistentAndRelockPersistentAfterExpiredLockDifferentUser() throws Exception + { + + STEP("1. Add user(s) as collaborators to the site created by administrator and add a file in this site."); + file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); + + STEP("2. Verify with admin that the file is not locked."); + RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1) + .usingParams("include=isLocked").getNode(); + file1Model1.assertThat().field("isLocked").is(false); + + STEP("3. Lock the file using mode PERSISTENT with user1 (POST nodes/{nodeId}/lock)."); + RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); + lockBodyModel.setLifetime("PERSISTENT"); + lockBodyModel.setTimeToExpire(1); + lockBodyModel.setType("ALLOW_OWNER_CHANGES"); + restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + + STEP("4. Verify with admin that the file is locked."); + RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1) + .usingParams("include=isLocked").getNode(); + file1Model2.assertThat().field("isLocked").is(true).assertThat().field("properties").contains("lockLifetime=PERSISTENT") + .assertThat().field("properties").contains("lockType=WRITE_LOCK"); + + STEP("5. Lock the file using mode PERSISTENT with user2 after the first lock has expired"); + RestNodeLockBodyModel lockBodyModel2 = new RestNodeLockBodyModel(); + lockBodyModel2.setLifetime("PERSISTENT"); + lockBodyModel2.setTimeToExpire(20); + lockBodyModel2.setType("ALLOW_OWNER_CHANGES"); + try + { + Thread.sleep(1500); + } + finally + { + } + RestNodeModel file1Model3 = restClient.authenticateUser(user2).withCoreAPI().usingNode(file1) + .usingParams("include=isLocked").lockNode(lockBodyModel2); + restClient.assertStatusCodeIs(HttpStatus.OK); + file1Model3.assertThat().field("isLocked").is(true); + file1Model3.assertThat().field("properties").contains("lockLifetime=PERSISTENT").assertThat().field("properties") + .contains("lockType=WRITE_LOCK"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.NODES }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator can lock EPHEMERAL after EPHEMERAL lock made by same user is expired") + public void lockEphemeralAndRelockEphemeralAfterLocktimeIsPassedSameUser() throws Exception + { + + STEP("1. Add user(s) as collaborators to the site created by administrator and add a file in this site."); + file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); + + STEP("2. Verify with admin that the file is not locked."); + RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1) + .usingParams("include=isLocked").getNode(); + file1Model1.assertThat().field("isLocked").is(false); + + STEP("3. Lock the file using mode EPHEMERAL with user1 (POST nodes/{nodeId}/lock)."); + RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); + lockBodyModel.setLifetime("EPHEMERAL"); + lockBodyModel.setTimeToExpire(1); + lockBodyModel.setType("FULL"); + restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + + STEP("4. Verify with user1 that the file is locked."); + RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1) + .usingParams("include=isLocked").getNode(); + file1Model2.assertThat().field("isLocked").is(true).assertThat().field("properties").contains("lockLifetime=EPHEMERAL") + .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); + + STEP("5. Lock the file using mode EPHEMERAL with user1 after the first lock has expired"); + RestNodeLockBodyModel lockBodyModel2 = new RestNodeLockBodyModel(); + lockBodyModel2.setLifetime("EPHEMERAL"); + lockBodyModel2.setTimeToExpire(20); + lockBodyModel2.setType("FULL"); + try + { + Thread.sleep(1500); + } + finally + { + } + RestNodeModel file1Model3 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1) + .usingParams("include=isLocked").lockNode(lockBodyModel2); + restClient.assertStatusCodeIs(HttpStatus.OK); + file1Model3.assertThat().field("isLocked").is(true); + file1Model3.assertThat().field("properties").contains("lockLifetime=EPHEMERAL").assertThat().field("properties") + .contains("lockType=READ_ONLY_LOCK"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.NODES }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator can lock PERSISTENT after PERSISTENT lock made by same user is expired") + public void lockPersistentAndRelockPersistentAfterExpiredLockSameUser() throws Exception + { + + STEP("1. Add user(s) as collaborators to the site created by administrator and add a file in this site."); + file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); + + STEP("2. Verify with admin that the file is not locked."); + RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1) + .usingParams("include=isLocked").getNode(); + file1Model1.assertThat().field("isLocked").is(false); + + STEP("3. Lock the file using mode PERSISTENT with user1 (POST nodes/{nodeId}/lock)."); + RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); + lockBodyModel.setLifetime("PERSISTENT"); + lockBodyModel.setTimeToExpire(1); + lockBodyModel.setType("ALLOW_OWNER_CHANGES"); + restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + + STEP("4. Verify with user1 that the file is locked."); + RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1) + .usingParams("include=isLocked").getNode(); + file1Model2.assertThat().field("isLocked").is(true); + file1Model2.assertThat().field("properties").contains("lockLifetime=PERSISTENT"); + + STEP("5. Lock the file using mode PERSISTENT with user1 while the first lock has expired"); + RestNodeLockBodyModel lockBodyModel2 = new RestNodeLockBodyModel(); + lockBodyModel2.setLifetime("PERSISTENT"); + lockBodyModel2.setTimeToExpire(20); + lockBodyModel2.setType("ALLOW_OWNER_CHANGES"); + try + { + Thread.sleep(1500); + } + finally + { + } + RestNodeModel file1Model3 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1) + .usingParams("include=isLocked").lockNode(lockBodyModel2); + restClient.assertStatusCodeIs(HttpStatus.OK); + file1Model3.assertThat().field("isLocked").is(true); + file1Model3.assertThat().field("properties").contains("lockLifetime=PERSISTENT").assertThat().field("properties") + .contains("lockType=WRITE_LOCK"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.NODES }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator can lock EPHEMERAL after PERSISTENT lock made by same user is expired") + public void lockPersistentAndRelockEphemeralAfterExpiredLockSameUser() throws Exception + { + + STEP("1. Add user(s) as collaborators to the site created by administrator and add a file in this site."); + file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); + + STEP("2. Verify with admin that the file is not locked."); + RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1) + .usingParams("include=isLocked").getNode(); + file1Model1.assertThat().field("isLocked").is(false); + + STEP("3. Lock the file using mode PERSISTENT with user1 (POST nodes/{nodeId}/lock)."); + RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); + lockBodyModel.setLifetime("PERSISTENT"); + lockBodyModel.setTimeToExpire(1); + lockBodyModel.setType("ALLOW_OWNER_CHANGES"); + restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + + STEP("4. Verify with admin that the file is locked."); + RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1) + .usingParams("include=isLocked").getNode(); + file1Model2.assertThat().field("isLocked").is(true).assertThat().field("properties").contains("lockLifetime=PERSISTENT") + .assertThat().field("properties").contains("lockType=WRITE_LOCK"); + + STEP("5. Lock the file using mode EPHEMERAL with user1 while the first lock has expired"); + RestNodeLockBodyModel lockBodyModel2 = new RestNodeLockBodyModel(); + lockBodyModel2.setLifetime("EPHEMERAL"); + lockBodyModel2.setTimeToExpire(20); + lockBodyModel2.setType("FULL"); + try + { + Thread.sleep(1500); + } + finally + { + } + RestNodeModel file1Model3 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1) + .usingParams("include=isLocked").lockNode(lockBodyModel2); + restClient.assertStatusCodeIs(HttpStatus.OK); + file1Model3.assertThat().field("isLocked").is(true).assertThat().field("properties").contains("lockLifetime=EPHEMERAL") + .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); + } + + @Bug(id = "MNT-17612", status = Status.FIXED, description = "AccessDeniedException in AOS Edit Offline Upload New Version") + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.NODES }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator can lock PERSISTENT after EPHEMERAL lock made by same user is expired") + public void lockEphemeralAndRelockPersistentAfterExpiredLockSameUser() throws Exception + { + + STEP("1. Add user(s) as collaborators to the site created by administrator and add a file in this site."); + file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); + + STEP("2. Verify with admin that the file is not locked."); + RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1) + .usingParams("include=isLocked").getNode(); + file1Model1.assertThat().field("isLocked").is(false); + + STEP("3. Lock the file using mode EPHEMERAL with user1 (POST nodes/{nodeId}/lock)."); + RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); + lockBodyModel.setLifetime("EPHEMERAL"); + lockBodyModel.setTimeToExpire(1); + lockBodyModel.setType("FULL"); + restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + + STEP("4. Verify with useer1 that the file is locked."); + RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1) + .usingParams("include=isLocked").getNode(); + file1Model2.assertThat().field("isLocked").is(true).assertThat().field("properties").contains("lockLifetime=EPHEMERAL") + .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); + + STEP("5. Lock the file using mode PERSISTENT with user1 while the first lock has expired"); + RestNodeLockBodyModel lockBodyModel2 = new RestNodeLockBodyModel(); + lockBodyModel2.setLifetime("PERSISTENT"); + lockBodyModel2.setTimeToExpire(20); + lockBodyModel2.setType("ALLOW_OWNER_CHANGES"); + try + { + Thread.sleep(1500); + } + finally + { + } + RestNodeModel file1Model3 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1) + .usingParams("include=isLocked").lockNode(lockBodyModel2); + restClient.assertStatusCodeIs(HttpStatus.OK); + file1Model3.assertThat().field("isLocked").is(true).assertThat().field("properties").contains("lockLifetime=PERSISTENT") + .assertThat().field("properties").contains("lockType=WRITE_LOCK"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.NODES }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator can lock PERSISTENT after PERSISTENT lock made by same user") + public void lockPersistentAndRelockPersistentWithSameUser() throws Exception + { + + STEP("1. Add user(s) as collaborators to the site created by administrator and add a file in this site."); + file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); + + STEP("2. Verify with admin that the file is not locked."); + RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1) + .usingParams("include=isLocked").getNode(); + file1Model1.assertThat().field("isLocked").is(false); + + STEP("3. Lock the file using mode PERSISTENT with user1 (POST nodes/{nodeId}/lock)."); + RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); + lockBodyModel.setLifetime("PERSISTENT"); + lockBodyModel.setTimeToExpire(20); + lockBodyModel.setType("ALLOW_OWNER_CHANGES"); + restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + + STEP("4. Verify with user1 that the file is locked."); + RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1) + .usingParams("include=isLocked").getNode(); + file1Model2.assertThat().field("isLocked").is(true).assertThat().field("properties").contains("lockLifetime=PERSISTENT") + .assertThat().field("properties").contains("lockType=WRITE_LOCK"); + + STEP("5. Lock the file using mode PERSISTENT with user1 while the file is still locked"); + RestNodeLockBodyModel lockBodyModel2 = new RestNodeLockBodyModel(); + lockBodyModel2.setLifetime("PERSISTENT"); + lockBodyModel2.setTimeToExpire(20); + lockBodyModel2.setType("ALLOW_OWNER_CHANGES"); + RestNodeModel file1Model3 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1) + .usingParams("include=isLocked").lockNode(lockBodyModel2); + restClient.assertStatusCodeIs(HttpStatus.OK); + file1Model3.assertThat().field("isLocked").is(true); + file1Model3.assertThat().field("properties").contains("lockLifetime=PERSISTENT").assertThat().field("properties") + .contains("lockType=WRITE_LOCK"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.NODES }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator can lock EPHERMERAL after PERSISTENT lock made by same user") + public void lockPersistentAndRelockEphemeralWithSameUser() throws Exception + { + + STEP("1. Add user(s) as collaborators to the site created by administrator and add a file in this site."); + file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); + + STEP("2. Verify with admin that the file is not locked."); + RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1) + .usingParams("include=isLocked").getNode(); + file1Model1.assertThat().field("isLocked").is(false); + + STEP("3. Lock the file using mode PERSISTENT with user1 (POST nodes/{nodeId}/lock)."); + RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); + lockBodyModel.setLifetime("PERSISTENT"); + lockBodyModel.setTimeToExpire(1); + lockBodyModel.setType("ALLOW_OWNER_CHANGES"); + restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + + STEP("4. Verify with user1 that the file is locked."); + RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1) + .usingParams("include=isLocked").getNode(); + file1Model2.assertThat().field("isLocked").is(true).assertThat().field("properties").contains("lockLifetime=PERSISTENT") + .assertThat().field("properties").contains("lockType=WRITE_LOCK"); + + STEP("5. Lock the file using mode EPHERMERAL with user1 while the file is still locked"); + RestNodeLockBodyModel lockBodyModel2 = new RestNodeLockBodyModel(); + lockBodyModel2.setLifetime("EPHEMERAL"); + lockBodyModel2.setTimeToExpire(20); + lockBodyModel2.setType("FULL"); + RestNodeModel file1Model3 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1) + .usingParams("include=isLocked").lockNode(lockBodyModel2); + restClient.assertStatusCodeIs(HttpStatus.OK); + file1Model3.assertThat().field("isLocked").is(true); + file1Model3.assertThat().field("properties").contains("lockLifetime=EPHEMERAL").assertThat().field("properties") + .contains("lockType=READ_ONLY_LOCK"); + } + +} diff --git a/e2e-test/java/org/alfresco/rest/nodes/NodesUnlockTests.java b/e2e-test/java/org/alfresco/rest/nodes/NodesUnlockTests.java new file mode 100644 index 000000000..ac855fe48 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/nodes/NodesUnlockTests.java @@ -0,0 +1,161 @@ +package org.alfresco.rest.nodes; + +import static org.alfresco.utility.report.log.Step.STEP; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestNodeLockBodyModel; +import org.alfresco.rest.model.RestNodeModel; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class NodesUnlockTests extends RestTest +{ + private UserModel user1, user2, adminUser; + private SiteModel publicSite; + private FileModel file1; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + publicSite = dataSite.usingUser(adminUser).createPublicRandomSite(); + user1 = dataUser.createRandomTestUser(); + user2 = dataUser.createRandomTestUser(); + dataUser.addUserToSite(user1, publicSite, UserRole.SiteCollaborator); + user1.setUserRole(UserRole.SiteCollaborator); + dataUser.addUserToSite(user2, publicSite, UserRole.SiteCollaborator); + user2.setUserRole(UserRole.SiteCollaborator); + + } + + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) + @TestRail(section={TestGroup.REST_API, TestGroup.NODES}, executionType= ExecutionType.REGRESSION, + description= "Verify Collaborator can unlock after EPHEMERAL lock made by same user") + public void lockEphemeralAndUnlockWithSameUser() throws Exception{ + + STEP("1. Add user(s) as collaborators to the site created by administrator and add a file in this site."); + file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); + + STEP("2. Verify with user1 that the file is not locked."); + RestNodeModel file1Model1 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); + file1Model1.assertThat().field("isLocked").is(false); + + STEP("3. Lock the file using mode EPHEMERAL with user1 (POST nodes/{nodeId}/lock)."); + RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); + lockBodyModel.setLifetime("EPHEMERAL"); + lockBodyModel.setTimeToExpire(20); + restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + + STEP("4. Verify with user1 that the file is locked."); + RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); + file1Model2.assertThat().field("isLocked").is(true); + + STEP("5. Unlock the file with user1 while the file is still locked"); + RestNodeModel file1Model3 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").unlockNode(); + file1Model3.assertThat().field("isLocked").is(false); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) + @TestRail(section={TestGroup.REST_API, TestGroup.NODES}, executionType= ExecutionType.REGRESSION, + description= "Verify Collaborator can unlock after PERSISTENT lock made by same user") + public void lockPersistentAndUnlockSameUser() throws Exception{ + + STEP("1. Add user(s) as collaborators to the site created by administrator and add a file in this site."); + file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); + + STEP("2. Verify with admin that the file is not locked."); + RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); + file1Model1.assertThat().field("isLocked").is(false); + + STEP("3. Lock the file using mode PERSISTENT with user1 (POST nodes/{nodeId}/lock)."); + RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); + lockBodyModel.setLifetime("PERSISTENT"); + lockBodyModel.setTimeToExpire(20); + restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + + STEP("4. Verify with user1 that the file is locked."); + RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); + file1Model2.assertThat().field("isLocked").is(true); + + STEP("5. Unlock the file with user1 while the file is still locked"); + RestNodeModel file1Model3 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").unlockNode(); + file1Model3.assertThat().field("isLocked").is(false); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) + @TestRail(section={TestGroup.REST_API, TestGroup.NODES}, executionType= ExecutionType.REGRESSION, + description= "Verify Collaborator can unlock file after EPHEMERAL lock made by different user") + public void lockEphemeralAndUnlockWithDifferentUser() throws Exception{ + + STEP("1. Add user(s) as collaborators to the site created by administrator and add a file in this site."); + file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); + + STEP("2. Verify with admin that the file is not locked."); + RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); + file1Model1.assertThat().field("isLocked").is(false); + + STEP("3. Lock the file using mode EPHEMERAL with user1 (POST nodes/{nodeId}/lock)."); + RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); + lockBodyModel.setLifetime("EPHEMERAL"); + lockBodyModel.setTimeToExpire(20); + restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + + STEP("4. Verify with user1 that the file is locked."); + RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); + file1Model2.assertThat().field("isLocked").is(true); + + STEP("5. Lock the file with user2 while the file is still locked"); + restClient.authenticateUser(user2).withCoreAPI().usingNode(file1).usingParams("include=isLocked").unlockNode(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError() + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) + @TestRail(section={TestGroup.REST_API, TestGroup.NODES}, executionType= ExecutionType.REGRESSION, + description= "Verify Collaborator can unlock file after PERSISTENT lock made by different user") + public void lockPersistentAndUnlockWithDifferentUser() throws Exception{ + + STEP("1. Add user(s) as collaborators to the site created by administrator and add a file in this site."); + file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); + + STEP("2. Verify with admin that the file is not locked."); + RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); + file1Model1.assertThat().field("isLocked").is(false); + + STEP("3. Lock the file using mode PERSISTENT with user1 (POST nodes/{nodeId}/lock)."); + RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); + lockBodyModel.setLifetime("PERSISTENT"); + lockBodyModel.setTimeToExpire(20); + restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + + STEP("4. Verify with admin that the file is locked."); + RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); + file1Model2.assertThat().field("isLocked").is(true); + + STEP("5. Unlock the file with user2 while the file is still locked"); + restClient.authenticateUser(user2).withCoreAPI().usingNode(file1).usingParams("include=isLocked").unlockNode(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError() + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } + +} From f57f53c39245f5d11c9b59725dcebb5c093bf29e Mon Sep 17 00:00:00 2001 From: Mihaela Popa Date: Mon, 29 May 2017 18:56:27 +0300 Subject: [PATCH 1153/1491] REPO-2451: Service Pack: MNT-17612: AccessDeniedException in Edit Offline Upload New Version Update code formating --- .../alfresco/rest/nodes/NodesLockTests.java | 396 +++++++----------- 1 file changed, 157 insertions(+), 239 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/nodes/NodesLockTests.java b/e2e-test/java/org/alfresco/rest/nodes/NodesLockTests.java index 6c197f839..47f5290d5 100644 --- a/e2e-test/java/org/alfresco/rest/nodes/NodesLockTests.java +++ b/e2e-test/java/org/alfresco/rest/nodes/NodesLockTests.java @@ -41,17 +41,16 @@ public class NodesLockTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.NODES }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator can lock PERSISTENT after EPHEMERAL lock made by different user") - public void lockEphemeralAndRelockPersistentWithDifferentUser() throws Exception + @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, + description = "Verify Collaborator can lock PERSISTENT after EPHEMERAL lock made by different user") + public void lockEphemeralAndRelockPersistentDifferentUser() throws Exception { STEP("1. Add user(s) as collaborators to the site created by administrator and add a file in this site."); file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); STEP("2. Verify with admin that the file is not locked."); - RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1) - .usingParams("include=isLocked").getNode(); + RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); file1Model1.assertThat().field("isLocked").is(false); STEP("3. Lock the file using mode EPHEMERAL with user1 (POST nodes/{nodeId}/lock)."); @@ -63,18 +62,15 @@ public class NodesLockTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); STEP("4. Verify with user1 that the file is locked."); - RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1) - .usingParams("include=isLocked").getNode(); - file1Model2.assertThat().field("isLocked").is(true).assertThat().field("properties").contains("lockLifetime=EPHEMERAL") - .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); + RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); + file1Model2.assertThat().field("isLocked").is(true).assertThat().field("properties").contains("lockLifetime=EPHEMERAL").assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); STEP("5. Lock the file using mode PERSISTENT with user2 while the file is still locked"); RestNodeLockBodyModel lockBodyModel2 = new RestNodeLockBodyModel(); lockBodyModel2.setLifetime("PERSISTENT"); lockBodyModel2.setTimeToExpire(20); lockBodyModel2.setType("ALLOW_OWNER_CHANGES"); - restClient.authenticateUser(user2).withCoreAPI().usingNode(file1).usingParams("include=isLocked") - .lockNode(lockBodyModel2); + restClient.authenticateUser(user2).withCoreAPI().usingNode(file1).usingParams("include=isLocked").lockNode(lockBodyModel2); restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) .containsSummary(String.format(RestErrorModel.LOCKED_NODE_SUMMARY, file1.getNodeRefWithoutVersion())) @@ -82,17 +78,16 @@ public class NodesLockTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.NODES }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator can lock PERSISTENT after EPHEMERAL lock made by different user") - public void lockEphemeralAndRelockEphemeralWithDifferentUser() throws Exception + @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, + description = "Verify Collaborator can lock PERSISTENT after EPHEMERAL lock made by different user") + public void lockEphemeralAndRelockEphemeralDifferentUser() throws Exception { STEP("1. Add user(s) as collaborators to the site created by administrator and add a file in this site."); file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); STEP("2. Verify with admin that the file is not locked."); - RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1) - .usingParams("include=isLocked").getNode(); + RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); file1Model1.assertThat().field("isLocked").is(false); STEP("3. Lock the file using mode EPHEMERAL with user1 (POST nodes/{nodeId}/lock)."); @@ -104,9 +99,9 @@ public class NodesLockTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); STEP("4. Verify with user1 that the file is locked."); - RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1) - .usingParams("include=isLocked").getNode(); - file1Model2.assertThat().field("isLocked").is(true).assertThat().field("properties").contains("lockLifetime=EPHEMERAL") + RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); + file1Model2.assertThat().field("isLocked").is(true) + .assertThat().field("properties").contains("lockLifetime=EPHEMERAL") .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); STEP("5. Lock the file using mode EPHEMERAL with user2 while the file is still locked"); @@ -114,8 +109,7 @@ public class NodesLockTests extends RestTest lockBodyModel2.setLifetime("EPHEMERAL"); lockBodyModel2.setTimeToExpire(20); lockBodyModel2.setType("FULL"); - restClient.authenticateUser(user2).withCoreAPI().usingNode(file1).usingParams("include=isLocked") - .lockNode(lockBodyModel2); + restClient.authenticateUser(user2).withCoreAPI().usingNode(file1).usingParams("include=isLocked").lockNode(lockBodyModel2); restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) .containsSummary(String.format(RestErrorModel.LOCKED_NODE_SUMMARY, file1.getNodeRefWithoutVersion())) @@ -123,17 +117,16 @@ public class NodesLockTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.NODES }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator can lock EPHEMERAL after EPHEMERAL lock made by same user") - public void lockEphemeralAndRelockEphemeralWithSameUser() throws Exception + @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, + description = "Verify Collaborator can lock EPHEMERAL after EPHEMERAL lock made by same user") + public void lockEphemeralAndRelockEphemeralSameUser() throws Exception { STEP("1. Add user(s) as collaborators to the site created by administrator and add a file in this site."); file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); STEP("2. Verify with admin that the file is not locked."); - RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1) - .usingParams("include=isLocked").getNode(); + RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); file1Model1.assertThat().field("isLocked").is(false); STEP("3. Lock the file using mode EPHEMERAL with user1 (POST nodes/{nodeId}/lock)."); @@ -145,9 +138,9 @@ public class NodesLockTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); STEP("4. Verify with user1 that the file is locked."); - RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1) - .usingParams("include=isLocked").getNode(); - file1Model2.assertThat().field("isLocked").is(true).assertThat().field("properties").contains("lockLifetime=EPHEMERAL") + RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); + file1Model2.assertThat().field("isLocked").is(true) + .assertThat().field("properties").contains("lockLifetime=EPHEMERAL") .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); STEP("5. Lock the file using mode EPHEMERAL with user1 while the file is still locked"); @@ -155,26 +148,25 @@ public class NodesLockTests extends RestTest lockBodyModel2.setLifetime("EPHEMERAL"); lockBodyModel2.setTimeToExpire(20); lockBodyModel2.setType("FULL"); - RestNodeModel file1Model3 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1) - .usingParams("include=isLocked").lockNode(lockBodyModel2); + RestNodeModel file1Model3 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").lockNode(lockBodyModel2); restClient.assertStatusCodeIs(HttpStatus.OK); - file1Model3.assertThat().field("isLocked").is(true).assertThat().field("properties").contains("lockLifetime=EPHEMERAL") + file1Model3.assertThat().field("isLocked").is(true) + .assertThat().field("properties").contains("lockLifetime=EPHEMERAL") .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); } @Bug(id = "MNT-17612", status = Status.FIXED, description = "AccessDeniedException in AOS Edit Offline Upload New Version") @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.NODES }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator can lock PERSISTENT after EPHEMERAL lock made by same user") - public void lockEphemeralAndRelockPersistentWithSameUser() throws Exception + @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, + description = "Verify Collaborator can lock PERSISTENT after EPHEMERAL lock made by same user") + public void lockEphemeralAndRelockPersistentSameUser() throws Exception { STEP("1. Add user(s) as collaborators to the site created by administrator and add a file in this site."); file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); STEP("2. Verify with admin that the file is not locked."); - RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1) - .usingParams("include=isLocked").getNode(); + RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); file1Model1.assertThat().field("isLocked").is(false); STEP("3. Lock the file using mode EPHEMERAL with user1 (POST nodes/{nodeId}/lock)."); @@ -186,9 +178,9 @@ public class NodesLockTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); STEP("4. Verify with user1 that the file is locked."); - RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1) - .usingParams("include=isLocked").getNode(); - file1Model2.assertThat().field("isLocked").is(true).assertThat().field("properties").contains("lockLifetime=EPHEMERAL") + RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); + file1Model2.assertThat().field("isLocked").is(true) + .assertThat().field("properties").contains("lockLifetime=EPHEMERAL") .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); STEP("5. Lock the file using mode PERSISTENT with user1 while the file is still locked"); @@ -196,38 +188,31 @@ public class NodesLockTests extends RestTest lockBodyModel2.setLifetime("PERSISTENT"); lockBodyModel2.setTimeToExpire(20); lockBodyModel2.setType("ALLOW_OWNER_CHANGES"); - RestNodeModel file1Model3 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1) - .usingParams("include=isLocked").lockNode(lockBodyModel2); + RestNodeModel file1Model3 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").lockNode(lockBodyModel2); restClient.assertStatusCodeIs(HttpStatus.OK); - file1Model3.assertThat().field("isLocked").is(true).assertThat().field("properties").contains("lockLifetime=EPHEMERAL") + file1Model3.assertThat().field("isLocked").is(true) + .assertThat().field("properties").contains("lockLifetime=EPHEMERAL") .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); STEP("6. Verify that the file is locked PERSISTENT only after EPHEMERAL lock has expired"); - try - { - Thread.sleep(2500); - } - finally - { - } - RestNodeModel file1Model4 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1) - .usingParams("include=isLocked").getNode(); - file1Model4.assertThat().field("isLocked").is(true).assertThat().field("properties").contains("lockLifetime=PERSISTENT") + try{Thread.sleep(2500);}finally{} + RestNodeModel file1Model4 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); + file1Model4.assertThat().field("isLocked").is(true) + .assertThat().field("properties").contains("lockLifetime=PERSISTENT") .assertThat().field("properties").contains("lockType=WRITE_LOCK"); } @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.NODES }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator can lock EPHEMERAL after PERSISTENT lock made by different user") - public void lockPersistentAndRelockEphemeralWithDifferentUser() throws Exception + @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, + description = "Verify Collaborator can lock EPHEMERAL after PERSISTENT lock made by different user") + public void lockPersistentAndRelockEphemeralDifferentUser() throws Exception { STEP("1. Add user(s) as collaborators to the site created by administrator and add a file in this site."); file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); STEP("2. Verify with admin that the file is not locked."); - RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1) - .usingParams("include=isLocked").getNode(); + RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); file1Model1.assertThat().field("isLocked").is(false); STEP("3. Lock the file using mode PERSISTENT with user1 (POST nodes/{nodeId}/lock)."); @@ -239,9 +224,9 @@ public class NodesLockTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); STEP("4. Verify with user1 that the file is locked."); - RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1) - .usingParams("include=isLocked").getNode(); - file1Model2.assertThat().field("isLocked").is(true).assertThat().field("properties").contains("lockLifetime=PERSISTENT") + RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); + file1Model2.assertThat().field("isLocked").is(true) + .assertThat().field("properties").contains("lockLifetime=PERSISTENT") .assertThat().field("properties").contains("lockType=WRITE_LOCK"); STEP("5. Lock the file using mode EPHEMERAL with user2 while the file is still locked"); @@ -249,8 +234,7 @@ public class NodesLockTests extends RestTest lockBodyModel2.setLifetime("EPHEMERAL"); lockBodyModel2.setTimeToExpire(20); lockBodyModel2.setType("FULL"); - restClient.authenticateUser(user2).withCoreAPI().usingNode(file1).usingParams("include=isLocked") - .lockNode(lockBodyModel2); + restClient.authenticateUser(user2).withCoreAPI().usingNode(file1).usingParams("include=isLocked").lockNode(lockBodyModel2); restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) .containsSummary(String.format(RestErrorModel.LOCKED_NODE_SUMMARY, file1.getNodeRefWithoutVersion())) @@ -258,17 +242,16 @@ public class NodesLockTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.NODES }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator can lock EPHEMERAL after PERSISTENT lock made by different user") - public void lockPersistentAndRelockPersistentWithDifferentUser() throws Exception + @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, + description = "Verify Collaborator can lock EPHEMERAL after PERSISTENT lock made by different user") + public void lockPersistentAndRelockPersistentDifferentUser() throws Exception { STEP("1. Add user(s) as collaborators to the site created by administrator and add a file in this site."); file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); STEP("2. Verify with admin that the file is not locked."); - RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1) - .usingParams("include=isLocked").getNode(); + RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); file1Model1.assertThat().field("isLocked").is(false); STEP("3. Lock the file using mode PERSISTENT with user1 (POST nodes/{nodeId}/lock)."); @@ -280,9 +263,9 @@ public class NodesLockTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); STEP("4. Verify with user1 that the file is locked."); - RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1) - .usingParams("include=isLocked").getNode(); - file1Model2.assertThat().field("isLocked").is(true).assertThat().field("properties").contains("lockLifetime=PERSISTENT") + RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); + file1Model2.assertThat().field("isLocked").is(true) + .assertThat().field("properties").contains("lockLifetime=PERSISTENT") .assertThat().field("properties").contains("lockType=WRITE_LOCK"); STEP("5. Lock the file using mode PERSISTENT with user2 while the file is still locked"); @@ -290,8 +273,7 @@ public class NodesLockTests extends RestTest lockBodyModel2.setLifetime("PERSISTENT"); lockBodyModel2.setTimeToExpire(20); lockBodyModel2.setType("ALLOW_OWNER_CHANGES"); - restClient.authenticateUser(user2).withCoreAPI().usingNode(file1).usingParams("include=isLocked") - .lockNode(lockBodyModel2); + restClient.authenticateUser(user2).withCoreAPI().usingNode(file1).usingParams("include=isLocked").lockNode(lockBodyModel2); restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) .containsSummary(String.format(RestErrorModel.LOCKED_NODE_SUMMARY, file1.getNodeRefWithoutVersion())) @@ -299,8 +281,8 @@ public class NodesLockTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.NODES }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator can lock EPHEMERAL after PERSISTENT lock made by different user is expired") + @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, + description = "Verify Collaborator can lock EPHEMERAL after PERSISTENT lock made by different user is expired") public void lockPersistentAndRelockEphemeralAfterExpiredLockDifferentUser() throws Exception { @@ -308,8 +290,7 @@ public class NodesLockTests extends RestTest file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); STEP("2. Verify with admin that the file is not locked."); - RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1) - .usingParams("include=isLocked").getNode(); + RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); file1Model1.assertThat().field("isLocked").is(false); STEP("3. Lock the file using mode PERSISTENT with user1 (POST nodes/{nodeId}/lock)."); @@ -321,9 +302,9 @@ public class NodesLockTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); STEP("4. Verify with admin that the file is locked."); - RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1) - .usingParams("include=isLocked").getNode(); - file1Model2.assertThat().field("isLocked").is(true).assertThat().field("properties").contains("lockLifetime=PERSISTENT") + RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); + file1Model2.assertThat().field("isLocked").is(true) + .assertThat().field("properties").contains("lockLifetime=PERSISTENT") .assertThat().field("properties").contains("lockType=WRITE_LOCK"); STEP("5. Lock the file using mode EPHEMERAL with user2 while the first lock has expired"); @@ -331,24 +312,18 @@ public class NodesLockTests extends RestTest lockBodyModel2.setLifetime("EPHEMERAL"); lockBodyModel2.setTimeToExpire(20); lockBodyModel2.setType("FULL"); - try - { - Thread.sleep(1500); - } - finally - { - } - RestNodeModel file1Model3 = restClient.authenticateUser(user2).withCoreAPI().usingNode(file1) - .usingParams("include=isLocked").lockNode(lockBodyModel2); + try{Thread.sleep(1500);}finally{} + RestNodeModel file1Model3 = restClient.authenticateUser(user2).withCoreAPI().usingNode(file1).usingParams("include=isLocked").lockNode(lockBodyModel2); restClient.assertStatusCodeIs(HttpStatus.OK); - file1Model3.assertThat().field("isLocked").is(true).assertThat().field("properties").contains("lockLifetime=EPHEMERAL") + file1Model3.assertThat().field("isLocked").is(true) + .assertThat().field("properties").contains("lockLifetime=EPHEMERAL") .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); } @Bug(id = "MNT-17612", status = Status.FIXED, description = "AccessDeniedException in AOS Edit Offline Upload New Version") @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.NODES }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator can lock PERSISTENT after EPHEMERAL lock made by another user is expired") + @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, + description = "Verify Collaborator can lock PERSISTENT after EPHEMERAL lock made by another user is expired") public void lockEphemeralAndRelockPersistentAfterExpiredLockDifferentUser() throws Exception { @@ -356,8 +331,7 @@ public class NodesLockTests extends RestTest file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); STEP("2. Verify with admin that the file is not locked."); - RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1) - .usingParams("include=isLocked").getNode(); + RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); file1Model1.assertThat().field("isLocked").is(false); STEP("3. Lock the file using mode EPHEMERAL with user1 (POST nodes/{nodeId}/lock)."); @@ -369,9 +343,9 @@ public class NodesLockTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); STEP("4. Verify with user1 that the file is locked."); - RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1) - .usingParams("include=isLocked").getNode(); - file1Model2.assertThat().field("isLocked").is(true).assertThat().field("properties").contains("lockLifetime=EPHEMERAL") + RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); + file1Model2.assertThat().field("isLocked").is(true) + .assertThat().field("properties").contains("lockLifetime=EPHEMERAL") .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); STEP("5. Lock the file using mode PERSISTENT with user2 after the first lock has expired"); @@ -379,23 +353,17 @@ public class NodesLockTests extends RestTest lockBodyModel2.setLifetime("PERSISTENT"); lockBodyModel2.setTimeToExpire(20); lockBodyModel2.setType("ALLOW_OWNER_CHANGES"); - try - { - Thread.sleep(1500); - } - finally - { - } - RestNodeModel file1Model3 = restClient.authenticateUser(user2).withCoreAPI().usingNode(file1) - .usingParams("include=isLocked").lockNode(lockBodyModel2); + try{Thread.sleep(1500);}finally{} + RestNodeModel file1Model3 = restClient.authenticateUser(user2).withCoreAPI().usingNode(file1).usingParams("include=isLocked").lockNode(lockBodyModel2); restClient.assertStatusCodeIs(HttpStatus.OK); - file1Model3.assertThat().field("isLocked").is(true).assertThat().field("properties").contains("lockLifetime=PERSISTENT") + file1Model3.assertThat().field("isLocked").is(true) + .assertThat().field("properties").contains("lockLifetime=PERSISTENT") .assertThat().field("properties").contains("lockType=WRITE_LOCK"); } @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.NODES }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator can lock EPHEMERAL after EPHEMERAL lock made by another user is expired") + @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, + description = "Verify Collaborator can lock EPHEMERAL after EPHEMERAL lock made by another user is expired") public void lockEphemeralAndRelockEphemeralAfterExpiredLockDifferentUser() throws Exception { @@ -403,8 +371,7 @@ public class NodesLockTests extends RestTest file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); STEP("2. Verify with admin that the file is not locked."); - RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1) - .usingParams("include=isLocked").getNode(); + RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); file1Model1.assertThat().field("isLocked").is(false); STEP("3. Lock the file using mode EPHEMERAL with user1 (POST nodes/{nodeId}/lock)."); @@ -416,9 +383,9 @@ public class NodesLockTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); STEP("4. Verify with user1 that the file is locked."); - RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1) - .usingParams("include=isLocked").getNode(); - file1Model2.assertThat().field("isLocked").is(true).assertThat().field("properties").contains("lockLifetime=EPHEMERAL") + RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); + file1Model2.assertThat().field("isLocked").is(true) + .assertThat().field("properties").contains("lockLifetime=EPHEMERAL") .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); STEP("5. Lock the file using mode EPHEMERAL with user2 while the first lock has expired"); @@ -426,24 +393,17 @@ public class NodesLockTests extends RestTest lockBodyModel2.setLifetime("EPHEMERAL"); lockBodyModel2.setTimeToExpire(20); lockBodyModel2.setType("FULL"); - try - { - Thread.sleep(1500); - } - finally - { - } - RestNodeModel file1Model3 = restClient.authenticateUser(user2).withCoreAPI().usingNode(file1) - .usingParams("include=isLocked").lockNode(lockBodyModel2); + try{Thread.sleep(1500);}finally{} + RestNodeModel file1Model3 = restClient.authenticateUser(user2).withCoreAPI().usingNode(file1).usingParams("include=isLocked").lockNode(lockBodyModel2); restClient.assertStatusCodeIs(HttpStatus.OK); - file1Model3.assertThat().field("isLocked").is(true); - file1Model3.assertThat().field("properties").contains("lockLifetime=EPHEMERAL").assertThat().field("properties") - .contains("lockType=READ_ONLY_LOCK"); + file1Model3.assertThat().field("isLocked").is(true) + .assertThat().field("properties").contains("lockLifetime=EPHEMERAL") + .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); } @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.NODES }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator can lock EPHEMERAL after PERSISTENT lock made by different user is expired") + @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, + description = "Verify Collaborator can lock EPHEMERAL after PERSISTENT lock made by different user is expired") public void lockPersistentAndRelockPersistentAfterExpiredLockDifferentUser() throws Exception { @@ -451,8 +411,7 @@ public class NodesLockTests extends RestTest file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); STEP("2. Verify with admin that the file is not locked."); - RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1) - .usingParams("include=isLocked").getNode(); + RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); file1Model1.assertThat().field("isLocked").is(false); STEP("3. Lock the file using mode PERSISTENT with user1 (POST nodes/{nodeId}/lock)."); @@ -464,9 +423,9 @@ public class NodesLockTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); STEP("4. Verify with admin that the file is locked."); - RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1) - .usingParams("include=isLocked").getNode(); - file1Model2.assertThat().field("isLocked").is(true).assertThat().field("properties").contains("lockLifetime=PERSISTENT") + RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); + file1Model2.assertThat().field("isLocked").is(true) + .assertThat().field("properties").contains("lockLifetime=PERSISTENT") .assertThat().field("properties").contains("lockType=WRITE_LOCK"); STEP("5. Lock the file using mode PERSISTENT with user2 after the first lock has expired"); @@ -474,33 +433,25 @@ public class NodesLockTests extends RestTest lockBodyModel2.setLifetime("PERSISTENT"); lockBodyModel2.setTimeToExpire(20); lockBodyModel2.setType("ALLOW_OWNER_CHANGES"); - try - { - Thread.sleep(1500); - } - finally - { - } - RestNodeModel file1Model3 = restClient.authenticateUser(user2).withCoreAPI().usingNode(file1) - .usingParams("include=isLocked").lockNode(lockBodyModel2); + try{Thread.sleep(1500);}finally{} + RestNodeModel file1Model3 = restClient.authenticateUser(user2).withCoreAPI().usingNode(file1).usingParams("include=isLocked").lockNode(lockBodyModel2); restClient.assertStatusCodeIs(HttpStatus.OK); - file1Model3.assertThat().field("isLocked").is(true); - file1Model3.assertThat().field("properties").contains("lockLifetime=PERSISTENT").assertThat().field("properties") - .contains("lockType=WRITE_LOCK"); + file1Model3.assertThat().field("isLocked").is(true) + .assertThat().field("properties").contains("lockLifetime=PERSISTENT") + .assertThat().field("properties").contains("lockType=WRITE_LOCK"); } @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.NODES }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator can lock EPHEMERAL after EPHEMERAL lock made by same user is expired") - public void lockEphemeralAndRelockEphemeralAfterLocktimeIsPassedSameUser() throws Exception + @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, + description = "Verify Collaborator can lock EPHEMERAL after EPHEMERAL lock made by same user is expired") + public void lockEphemeralAndRelockEphemeralAfterExpiredLockSameUser() throws Exception { STEP("1. Add user(s) as collaborators to the site created by administrator and add a file in this site."); file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); STEP("2. Verify with admin that the file is not locked."); - RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1) - .usingParams("include=isLocked").getNode(); + RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); file1Model1.assertThat().field("isLocked").is(false); STEP("3. Lock the file using mode EPHEMERAL with user1 (POST nodes/{nodeId}/lock)."); @@ -512,9 +463,9 @@ public class NodesLockTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); STEP("4. Verify with user1 that the file is locked."); - RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1) - .usingParams("include=isLocked").getNode(); - file1Model2.assertThat().field("isLocked").is(true).assertThat().field("properties").contains("lockLifetime=EPHEMERAL") + RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); + file1Model2.assertThat().field("isLocked").is(true) + .assertThat().field("properties").contains("lockLifetime=EPHEMERAL") .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); STEP("5. Lock the file using mode EPHEMERAL with user1 after the first lock has expired"); @@ -522,24 +473,17 @@ public class NodesLockTests extends RestTest lockBodyModel2.setLifetime("EPHEMERAL"); lockBodyModel2.setTimeToExpire(20); lockBodyModel2.setType("FULL"); - try - { - Thread.sleep(1500); - } - finally - { - } - RestNodeModel file1Model3 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1) - .usingParams("include=isLocked").lockNode(lockBodyModel2); + try{Thread.sleep(1500);}finally{} + RestNodeModel file1Model3 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").lockNode(lockBodyModel2); restClient.assertStatusCodeIs(HttpStatus.OK); - file1Model3.assertThat().field("isLocked").is(true); - file1Model3.assertThat().field("properties").contains("lockLifetime=EPHEMERAL").assertThat().field("properties") - .contains("lockType=READ_ONLY_LOCK"); + file1Model3.assertThat().field("isLocked").is(true) + .assertThat().field("properties").contains("lockLifetime=EPHEMERAL") + .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); } @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.NODES }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator can lock PERSISTENT after PERSISTENT lock made by same user is expired") + @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, + description = "Verify Collaborator can lock PERSISTENT after PERSISTENT lock made by same user is expired") public void lockPersistentAndRelockPersistentAfterExpiredLockSameUser() throws Exception { @@ -547,8 +491,7 @@ public class NodesLockTests extends RestTest file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); STEP("2. Verify with admin that the file is not locked."); - RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1) - .usingParams("include=isLocked").getNode(); + RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); file1Model1.assertThat().field("isLocked").is(false); STEP("3. Lock the file using mode PERSISTENT with user1 (POST nodes/{nodeId}/lock)."); @@ -560,8 +503,7 @@ public class NodesLockTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); STEP("4. Verify with user1 that the file is locked."); - RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1) - .usingParams("include=isLocked").getNode(); + RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); file1Model2.assertThat().field("isLocked").is(true); file1Model2.assertThat().field("properties").contains("lockLifetime=PERSISTENT"); @@ -570,24 +512,17 @@ public class NodesLockTests extends RestTest lockBodyModel2.setLifetime("PERSISTENT"); lockBodyModel2.setTimeToExpire(20); lockBodyModel2.setType("ALLOW_OWNER_CHANGES"); - try - { - Thread.sleep(1500); - } - finally - { - } - RestNodeModel file1Model3 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1) - .usingParams("include=isLocked").lockNode(lockBodyModel2); + try{Thread.sleep(1500);}finally{} + RestNodeModel file1Model3 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").lockNode(lockBodyModel2); restClient.assertStatusCodeIs(HttpStatus.OK); - file1Model3.assertThat().field("isLocked").is(true); - file1Model3.assertThat().field("properties").contains("lockLifetime=PERSISTENT").assertThat().field("properties") - .contains("lockType=WRITE_LOCK"); + file1Model3.assertThat().field("isLocked").is(true) + .assertThat().field("properties").contains("lockLifetime=PERSISTENT") + .assertThat().field("properties").contains("lockType=WRITE_LOCK"); } @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.NODES }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator can lock EPHEMERAL after PERSISTENT lock made by same user is expired") + @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, + description = "Verify Collaborator can lock EPHEMERAL after PERSISTENT lock made by same user is expired") public void lockPersistentAndRelockEphemeralAfterExpiredLockSameUser() throws Exception { @@ -595,8 +530,7 @@ public class NodesLockTests extends RestTest file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); STEP("2. Verify with admin that the file is not locked."); - RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1) - .usingParams("include=isLocked").getNode(); + RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); file1Model1.assertThat().field("isLocked").is(false); STEP("3. Lock the file using mode PERSISTENT with user1 (POST nodes/{nodeId}/lock)."); @@ -608,9 +542,9 @@ public class NodesLockTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); STEP("4. Verify with admin that the file is locked."); - RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1) - .usingParams("include=isLocked").getNode(); - file1Model2.assertThat().field("isLocked").is(true).assertThat().field("properties").contains("lockLifetime=PERSISTENT") + RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); + file1Model2.assertThat().field("isLocked").is(true) + .assertThat().field("properties").contains("lockLifetime=PERSISTENT") .assertThat().field("properties").contains("lockType=WRITE_LOCK"); STEP("5. Lock the file using mode EPHEMERAL with user1 while the first lock has expired"); @@ -618,24 +552,18 @@ public class NodesLockTests extends RestTest lockBodyModel2.setLifetime("EPHEMERAL"); lockBodyModel2.setTimeToExpire(20); lockBodyModel2.setType("FULL"); - try - { - Thread.sleep(1500); - } - finally - { - } - RestNodeModel file1Model3 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1) - .usingParams("include=isLocked").lockNode(lockBodyModel2); + try{Thread.sleep(1500);}finally{} + RestNodeModel file1Model3 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").lockNode(lockBodyModel2); restClient.assertStatusCodeIs(HttpStatus.OK); - file1Model3.assertThat().field("isLocked").is(true).assertThat().field("properties").contains("lockLifetime=EPHEMERAL") + file1Model3.assertThat().field("isLocked").is(true) + .assertThat().field("properties").contains("lockLifetime=EPHEMERAL") .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); } @Bug(id = "MNT-17612", status = Status.FIXED, description = "AccessDeniedException in AOS Edit Offline Upload New Version") @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.NODES }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator can lock PERSISTENT after EPHEMERAL lock made by same user is expired") + @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, + description = "Verify Collaborator can lock PERSISTENT after EPHEMERAL lock made by same user is expired") public void lockEphemeralAndRelockPersistentAfterExpiredLockSameUser() throws Exception { @@ -656,9 +584,9 @@ public class NodesLockTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); STEP("4. Verify with useer1 that the file is locked."); - RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1) - .usingParams("include=isLocked").getNode(); - file1Model2.assertThat().field("isLocked").is(true).assertThat().field("properties").contains("lockLifetime=EPHEMERAL") + RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); + file1Model2.assertThat().field("isLocked").is(true) + .assertThat().field("properties").contains("lockLifetime=EPHEMERAL") .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); STEP("5. Lock the file using mode PERSISTENT with user1 while the first lock has expired"); @@ -666,32 +594,25 @@ public class NodesLockTests extends RestTest lockBodyModel2.setLifetime("PERSISTENT"); lockBodyModel2.setTimeToExpire(20); lockBodyModel2.setType("ALLOW_OWNER_CHANGES"); - try - { - Thread.sleep(1500); - } - finally - { - } - RestNodeModel file1Model3 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1) - .usingParams("include=isLocked").lockNode(lockBodyModel2); + try{Thread.sleep(1500);}finally{} + RestNodeModel file1Model3 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").lockNode(lockBodyModel2); restClient.assertStatusCodeIs(HttpStatus.OK); - file1Model3.assertThat().field("isLocked").is(true).assertThat().field("properties").contains("lockLifetime=PERSISTENT") + file1Model3.assertThat().field("isLocked").is(true) + .assertThat().field("properties").contains("lockLifetime=PERSISTENT") .assertThat().field("properties").contains("lockType=WRITE_LOCK"); } @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.NODES }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator can lock PERSISTENT after PERSISTENT lock made by same user") - public void lockPersistentAndRelockPersistentWithSameUser() throws Exception + @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, + description = "Verify Collaborator can lock PERSISTENT after PERSISTENT lock made by same user") + public void lockPersistentAndRelockPersistentSameUser() throws Exception { STEP("1. Add user(s) as collaborators to the site created by administrator and add a file in this site."); file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); STEP("2. Verify with admin that the file is not locked."); - RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1) - .usingParams("include=isLocked").getNode(); + RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); file1Model1.assertThat().field("isLocked").is(false); STEP("3. Lock the file using mode PERSISTENT with user1 (POST nodes/{nodeId}/lock)."); @@ -703,9 +624,9 @@ public class NodesLockTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); STEP("4. Verify with user1 that the file is locked."); - RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1) - .usingParams("include=isLocked").getNode(); - file1Model2.assertThat().field("isLocked").is(true).assertThat().field("properties").contains("lockLifetime=PERSISTENT") + RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); + file1Model2.assertThat().field("isLocked").is(true) + .assertThat().field("properties").contains("lockLifetime=PERSISTENT") .assertThat().field("properties").contains("lockType=WRITE_LOCK"); STEP("5. Lock the file using mode PERSISTENT with user1 while the file is still locked"); @@ -713,26 +634,24 @@ public class NodesLockTests extends RestTest lockBodyModel2.setLifetime("PERSISTENT"); lockBodyModel2.setTimeToExpire(20); lockBodyModel2.setType("ALLOW_OWNER_CHANGES"); - RestNodeModel file1Model3 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1) - .usingParams("include=isLocked").lockNode(lockBodyModel2); + RestNodeModel file1Model3 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").lockNode(lockBodyModel2); restClient.assertStatusCodeIs(HttpStatus.OK); file1Model3.assertThat().field("isLocked").is(true); - file1Model3.assertThat().field("properties").contains("lockLifetime=PERSISTENT").assertThat().field("properties") - .contains("lockType=WRITE_LOCK"); + file1Model3.assertThat().field("properties").contains("lockLifetime=PERSISTENT") + .assertThat().field("properties").contains("lockType=WRITE_LOCK"); } @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.NODES }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator can lock EPHERMERAL after PERSISTENT lock made by same user") - public void lockPersistentAndRelockEphemeralWithSameUser() throws Exception + @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, + description = "Verify Collaborator can lock EPHERMERAL after PERSISTENT lock made by same user") + public void lockPersistentAndRelockEphemeralSameUser() throws Exception { STEP("1. Add user(s) as collaborators to the site created by administrator and add a file in this site."); file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); STEP("2. Verify with admin that the file is not locked."); - RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1) - .usingParams("include=isLocked").getNode(); + RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); file1Model1.assertThat().field("isLocked").is(false); STEP("3. Lock the file using mode PERSISTENT with user1 (POST nodes/{nodeId}/lock)."); @@ -744,9 +663,9 @@ public class NodesLockTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); STEP("4. Verify with user1 that the file is locked."); - RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1) - .usingParams("include=isLocked").getNode(); - file1Model2.assertThat().field("isLocked").is(true).assertThat().field("properties").contains("lockLifetime=PERSISTENT") + RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); + file1Model2.assertThat().field("isLocked").is(true) + .assertThat().field("properties").contains("lockLifetime=PERSISTENT") .assertThat().field("properties").contains("lockType=WRITE_LOCK"); STEP("5. Lock the file using mode EPHERMERAL with user1 while the file is still locked"); @@ -754,12 +673,11 @@ public class NodesLockTests extends RestTest lockBodyModel2.setLifetime("EPHEMERAL"); lockBodyModel2.setTimeToExpire(20); lockBodyModel2.setType("FULL"); - RestNodeModel file1Model3 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1) - .usingParams("include=isLocked").lockNode(lockBodyModel2); + RestNodeModel file1Model3 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").lockNode(lockBodyModel2); restClient.assertStatusCodeIs(HttpStatus.OK); file1Model3.assertThat().field("isLocked").is(true); - file1Model3.assertThat().field("properties").contains("lockLifetime=EPHEMERAL").assertThat().field("properties") - .contains("lockType=READ_ONLY_LOCK"); + file1Model3.assertThat().field("properties").contains("lockLifetime=EPHEMERAL") + .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); } } From 2c9886a853dfed1130679f794234e6a6a7820a6e Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Tue, 30 May 2017 14:47:56 +0300 Subject: [PATCH 1154/1491] updated some steps descriptions --- .../alfresco/rest/nodes/NodesLockTests.java | 74 ++++++++----------- .../alfresco/rest/nodes/NodesUnlockTests.java | 17 ++--- 2 files changed, 38 insertions(+), 53 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/nodes/NodesLockTests.java b/e2e-test/java/org/alfresco/rest/nodes/NodesLockTests.java index 47f5290d5..cef556b7b 100644 --- a/e2e-test/java/org/alfresco/rest/nodes/NodesLockTests.java +++ b/e2e-test/java/org/alfresco/rest/nodes/NodesLockTests.java @@ -5,8 +5,8 @@ import static org.alfresco.utility.report.log.Step.STEP; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestNodeLockBodyModel; import org.alfresco.rest.model.RestNodeModel; +import org.alfresco.rest.model.body.RestNodeLockBodyModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; @@ -42,18 +42,17 @@ public class NodesLockTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, - description = "Verify Collaborator can lock PERSISTENT after EPHEMERAL lock made by different user") + description = "Verify Collaborator can not lock PERSISTENT after EPHEMERAL lock made by different user") public void lockEphemeralAndRelockPersistentDifferentUser() throws Exception { - - STEP("1. Add user(s) as collaborators to the site created by administrator and add a file in this site."); + STEP("1. Administrator adds a file in the site."); file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); STEP("2. Verify with admin that the file is not locked."); RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); file1Model1.assertThat().field("isLocked").is(false); - STEP("3. Lock the file using mode EPHEMERAL with user1 (POST nodes/{nodeId}/lock)."); + STEP("3. Lock the file using mode EPHEMERAL for 20 seconds with user1 (POST nodes/{nodeId}/lock)."); RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); lockBodyModel.setLifetime("EPHEMERAL"); lockBodyModel.setTimeToExpire(20); @@ -63,9 +62,11 @@ public class NodesLockTests extends RestTest STEP("4. Verify with user1 that the file is locked."); RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model2.assertThat().field("isLocked").is(true).assertThat().field("properties").contains("lockLifetime=EPHEMERAL").assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); + file1Model2.assertThat().field("isLocked").is(true) + .assertThat().field("properties").contains("lockLifetime=EPHEMERAL") + .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); - STEP("5. Lock the file using mode PERSISTENT with user2 while the file is still locked"); + STEP("5. Cannot lock the file using mode PERSISTENT with user2 while the file is still locked"); RestNodeLockBodyModel lockBodyModel2 = new RestNodeLockBodyModel(); lockBodyModel2.setLifetime("PERSISTENT"); lockBodyModel2.setTimeToExpire(20); @@ -79,11 +80,10 @@ public class NodesLockTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, - description = "Verify Collaborator can lock PERSISTENT after EPHEMERAL lock made by different user") + description = "Verify Collaborator can not lock PERSISTENT after EPHEMERAL lock made by different user") public void lockEphemeralAndRelockEphemeralDifferentUser() throws Exception { - - STEP("1. Add user(s) as collaborators to the site created by administrator and add a file in this site."); + STEP("1. Adds a file in the site by administrator."); file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); STEP("2. Verify with admin that the file is not locked."); @@ -104,7 +104,7 @@ public class NodesLockTests extends RestTest .assertThat().field("properties").contains("lockLifetime=EPHEMERAL") .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); - STEP("5. Lock the file using mode EPHEMERAL with user2 while the file is still locked"); + STEP("5. Cannot lock the file using mode EPHEMERAL with user2 while the file is still locked"); RestNodeLockBodyModel lockBodyModel2 = new RestNodeLockBodyModel(); lockBodyModel2.setLifetime("EPHEMERAL"); lockBodyModel2.setTimeToExpire(20); @@ -121,8 +121,7 @@ public class NodesLockTests extends RestTest description = "Verify Collaborator can lock EPHEMERAL after EPHEMERAL lock made by same user") public void lockEphemeralAndRelockEphemeralSameUser() throws Exception { - - STEP("1. Add user(s) as collaborators to the site created by administrator and add a file in this site."); + STEP("1. Adds a file in the site by administrator."); file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); STEP("2. Verify with admin that the file is not locked."); @@ -161,8 +160,7 @@ public class NodesLockTests extends RestTest description = "Verify Collaborator can lock PERSISTENT after EPHEMERAL lock made by same user") public void lockEphemeralAndRelockPersistentSameUser() throws Exception { - - STEP("1. Add user(s) as collaborators to the site created by administrator and add a file in this site."); + STEP("1. Adds a file in the site by administrator."); file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); STEP("2. Verify with admin that the file is not locked."); @@ -204,11 +202,10 @@ public class NodesLockTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, - description = "Verify Collaborator can lock EPHEMERAL after PERSISTENT lock made by different user") + description = "Verify Collaborator can not lock EPHEMERAL after PERSISTENT lock made by different user") public void lockPersistentAndRelockEphemeralDifferentUser() throws Exception { - - STEP("1. Add user(s) as collaborators to the site created by administrator and add a file in this site."); + STEP("1. Adds a file in the site by administrator."); file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); STEP("2. Verify with admin that the file is not locked."); @@ -229,7 +226,7 @@ public class NodesLockTests extends RestTest .assertThat().field("properties").contains("lockLifetime=PERSISTENT") .assertThat().field("properties").contains("lockType=WRITE_LOCK"); - STEP("5. Lock the file using mode EPHEMERAL with user2 while the file is still locked"); + STEP("5. Cannot lock the file using mode EPHEMERAL with user2 while the file is still locked"); RestNodeLockBodyModel lockBodyModel2 = new RestNodeLockBodyModel(); lockBodyModel2.setLifetime("EPHEMERAL"); lockBodyModel2.setTimeToExpire(20); @@ -243,11 +240,10 @@ public class NodesLockTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, - description = "Verify Collaborator can lock EPHEMERAL after PERSISTENT lock made by different user") + description = "Verify Collaborator can not lock PERSISTENT after PERSISTENT lock made by different user") public void lockPersistentAndRelockPersistentDifferentUser() throws Exception { - - STEP("1. Add user(s) as collaborators to the site created by administrator and add a file in this site."); + STEP("1. Adds a file in the site by administrator."); file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); STEP("2. Verify with admin that the file is not locked."); @@ -268,7 +264,7 @@ public class NodesLockTests extends RestTest .assertThat().field("properties").contains("lockLifetime=PERSISTENT") .assertThat().field("properties").contains("lockType=WRITE_LOCK"); - STEP("5. Lock the file using mode PERSISTENT with user2 while the file is still locked"); + STEP("5. Cannot lock the file using mode PERSISTENT with user2 while the file is still locked"); RestNodeLockBodyModel lockBodyModel2 = new RestNodeLockBodyModel(); lockBodyModel2.setLifetime("PERSISTENT"); lockBodyModel2.setTimeToExpire(20); @@ -285,8 +281,7 @@ public class NodesLockTests extends RestTest description = "Verify Collaborator can lock EPHEMERAL after PERSISTENT lock made by different user is expired") public void lockPersistentAndRelockEphemeralAfterExpiredLockDifferentUser() throws Exception { - - STEP("1. Add user(s) as collaborators to the site created by administrator and add a file in this site."); + STEP("1. Adds a file in the site by administrator."); file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); STEP("2. Verify with admin that the file is not locked."); @@ -326,8 +321,7 @@ public class NodesLockTests extends RestTest description = "Verify Collaborator can lock PERSISTENT after EPHEMERAL lock made by another user is expired") public void lockEphemeralAndRelockPersistentAfterExpiredLockDifferentUser() throws Exception { - - STEP("1. Add user(s) as collaborators to the site created by administrator and add a file in this site."); + STEP("1. Adds a file in the site by administrator."); file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); STEP("2. Verify with admin that the file is not locked."); @@ -366,8 +360,7 @@ public class NodesLockTests extends RestTest description = "Verify Collaborator can lock EPHEMERAL after EPHEMERAL lock made by another user is expired") public void lockEphemeralAndRelockEphemeralAfterExpiredLockDifferentUser() throws Exception { - - STEP("1. Add user(s) as collaborators to the site created by administrator and add a file in this site."); + STEP("1. Adds a file in the site by administrator."); file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); STEP("2. Verify with admin that the file is not locked."); @@ -403,11 +396,10 @@ public class NodesLockTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, - description = "Verify Collaborator can lock EPHEMERAL after PERSISTENT lock made by different user is expired") + description = "Verify Collaborator can lock PERSISTENT after PERSISTENT lock made by different user is expired") public void lockPersistentAndRelockPersistentAfterExpiredLockDifferentUser() throws Exception { - - STEP("1. Add user(s) as collaborators to the site created by administrator and add a file in this site."); + STEP("1. Adds a file in the site by administrator."); file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); STEP("2. Verify with admin that the file is not locked."); @@ -446,8 +438,7 @@ public class NodesLockTests extends RestTest description = "Verify Collaborator can lock EPHEMERAL after EPHEMERAL lock made by same user is expired") public void lockEphemeralAndRelockEphemeralAfterExpiredLockSameUser() throws Exception { - - STEP("1. Add user(s) as collaborators to the site created by administrator and add a file in this site."); + STEP("1. Adds a file in the site by administrator."); file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); STEP("2. Verify with admin that the file is not locked."); @@ -486,8 +477,7 @@ public class NodesLockTests extends RestTest description = "Verify Collaborator can lock PERSISTENT after PERSISTENT lock made by same user is expired") public void lockPersistentAndRelockPersistentAfterExpiredLockSameUser() throws Exception { - - STEP("1. Add user(s) as collaborators to the site created by administrator and add a file in this site."); + STEP("1. Adds a file in the site by administrator."); file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); STEP("2. Verify with admin that the file is not locked."); @@ -525,8 +515,7 @@ public class NodesLockTests extends RestTest description = "Verify Collaborator can lock EPHEMERAL after PERSISTENT lock made by same user is expired") public void lockPersistentAndRelockEphemeralAfterExpiredLockSameUser() throws Exception { - - STEP("1. Add user(s) as collaborators to the site created by administrator and add a file in this site."); + STEP("1. Adds a file in the site by administrator."); file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); STEP("2. Verify with admin that the file is not locked."); @@ -566,8 +555,7 @@ public class NodesLockTests extends RestTest description = "Verify Collaborator can lock PERSISTENT after EPHEMERAL lock made by same user is expired") public void lockEphemeralAndRelockPersistentAfterExpiredLockSameUser() throws Exception { - - STEP("1. Add user(s) as collaborators to the site created by administrator and add a file in this site."); + STEP("1. Adds a file in the site by administrator."); file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); STEP("2. Verify with admin that the file is not locked."); @@ -607,8 +595,7 @@ public class NodesLockTests extends RestTest description = "Verify Collaborator can lock PERSISTENT after PERSISTENT lock made by same user") public void lockPersistentAndRelockPersistentSameUser() throws Exception { - - STEP("1. Add user(s) as collaborators to the site created by administrator and add a file in this site."); + STEP("1. Adds a file in the site by administrator."); file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); STEP("2. Verify with admin that the file is not locked."); @@ -646,8 +633,7 @@ public class NodesLockTests extends RestTest description = "Verify Collaborator can lock EPHERMERAL after PERSISTENT lock made by same user") public void lockPersistentAndRelockEphemeralSameUser() throws Exception { - - STEP("1. Add user(s) as collaborators to the site created by administrator and add a file in this site."); + STEP("1. Adds a file in the site by administrator."); file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); STEP("2. Verify with admin that the file is not locked."); diff --git a/e2e-test/java/org/alfresco/rest/nodes/NodesUnlockTests.java b/e2e-test/java/org/alfresco/rest/nodes/NodesUnlockTests.java index ac855fe48..9be1281c6 100644 --- a/e2e-test/java/org/alfresco/rest/nodes/NodesUnlockTests.java +++ b/e2e-test/java/org/alfresco/rest/nodes/NodesUnlockTests.java @@ -5,8 +5,8 @@ import static org.alfresco.utility.report.log.Step.STEP; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestNodeLockBodyModel; import org.alfresco.rest.model.RestNodeModel; +import org.alfresco.rest.model.body.RestNodeLockBodyModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; @@ -34,15 +34,14 @@ public class NodesUnlockTests extends RestTest dataUser.addUserToSite(user1, publicSite, UserRole.SiteCollaborator); user1.setUserRole(UserRole.SiteCollaborator); dataUser.addUserToSite(user2, publicSite, UserRole.SiteCollaborator); - user2.setUserRole(UserRole.SiteCollaborator); - + user2.setUserRole(UserRole.SiteCollaborator); } @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) @TestRail(section={TestGroup.REST_API, TestGroup.NODES}, executionType= ExecutionType.REGRESSION, description= "Verify Collaborator can unlock after EPHEMERAL lock made by same user") - public void lockEphemeralAndUnlockWithSameUser() throws Exception{ - + public void lockEphemeralAndUnlockWithSameUser() throws Exception + { STEP("1. Add user(s) as collaborators to the site created by administrator and add a file in this site."); file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); @@ -96,7 +95,7 @@ public class NodesUnlockTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) @TestRail(section={TestGroup.REST_API, TestGroup.NODES}, executionType= ExecutionType.REGRESSION, - description= "Verify Collaborator can unlock file after EPHEMERAL lock made by different user") + description= "Verify Collaborator can not unlock file after EPHEMERAL lock made by different user") public void lockEphemeralAndUnlockWithDifferentUser() throws Exception{ STEP("1. Add user(s) as collaborators to the site created by administrator and add a file in this site."); @@ -117,7 +116,7 @@ public class NodesUnlockTests extends RestTest RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); file1Model2.assertThat().field("isLocked").is(true); - STEP("5. Lock the file with user2 while the file is still locked"); + STEP("5. Cannot unlock the file with user2 while the file is still locked"); restClient.authenticateUser(user2).withCoreAPI().usingNode(file1).usingParams("include=isLocked").unlockNode(); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) .assertLastError() @@ -128,7 +127,7 @@ public class NodesUnlockTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) @TestRail(section={TestGroup.REST_API, TestGroup.NODES}, executionType= ExecutionType.REGRESSION, - description= "Verify Collaborator can unlock file after PERSISTENT lock made by different user") + description= "Verify Collaborator can not unlock file after PERSISTENT lock made by different user") public void lockPersistentAndUnlockWithDifferentUser() throws Exception{ STEP("1. Add user(s) as collaborators to the site created by administrator and add a file in this site."); @@ -149,7 +148,7 @@ public class NodesUnlockTests extends RestTest RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); file1Model2.assertThat().field("isLocked").is(true); - STEP("5. Unlock the file with user2 while the file is still locked"); + STEP("5. Cannot unlock the file with user2 while the file is still locked"); restClient.authenticateUser(user2).withCoreAPI().usingNode(file1).usingParams("include=isLocked").unlockNode(); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) .assertLastError() From beae6d898a31285b023b8500f0d1c934f742c099 Mon Sep 17 00:00:00 2001 From: Michael Suzuki Date: Tue, 30 May 2017 13:34:06 +0100 Subject: [PATCH 1155/1491] Search-426, added end to end test that validates the v2 response of facet fields --- .../rest/search/FacetRangeSearchTest.java | 19 ++++----- .../rest/search/FacetedSearchTest.java | 41 ++++++++++++++++++- 2 files changed, 49 insertions(+), 11 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java b/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java index a74782b5a..7e4d6d7ce 100644 --- a/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java @@ -297,7 +297,6 @@ public class FacetRangeSearchTest extends AbstractSearchTest facetRangeModel.setGap("200"); List include = new ArrayList(); include.add("upper"); -// include.add("lower"); facetRangeModel.setInclude(include); List ranges = new ArrayList(); ranges.add(facetRangeModel); @@ -308,38 +307,38 @@ public class FacetRangeSearchTest extends AbstractSearchTest RestGenericFacetResponseModel facetResponseModel = response.getContext().getFacets().get(0); RestGenericBucketModel bucket = facetResponseModel.getBuckets().get(0); - bucket.assertThat().field("label").is("(0 - 200]"); - bucket.assertThat().field("filterQuery").is("content.size:<0 TO 200]"); + bucket.assertThat().field("label").is("[0 - 200]"); + bucket.assertThat().field("filterQuery").is("content.size:[0 TO 200]"); Map metric = (Map) bucket.getMetrics().get(0).getValue(); Assert.assertTrue(new Integer(metric.get("count")) >= 4); Map info = (Map) bucket.getBucketInfo(); Assert.assertEquals(info.get("start"),"0"); Assert.assertEquals(info.get("end"),"200"); Assert.assertNull(info.get("count")); - Assert.assertEquals(info.get("startInclusive"),"false"); + Assert.assertEquals(info.get("startInclusive"),"true"); Assert.assertEquals(info.get("endInclusive"),"true"); bucket = facetResponseModel.getBuckets().get(1); - bucket.assertThat().field("label").is("(200 - 400]"); - bucket.assertThat().field("filterQuery").is("content.size:<200 TO 400]"); + bucket.assertThat().field("label").is("[200 - 400]"); + bucket.assertThat().field("filterQuery").is("content.size:[200 TO 400]"); metric = (Map) bucket.getMetrics().get(0).getValue(); Integer count = new Integer(metric.get("count")); Assert.assertTrue(count >= 4); info = (Map) bucket.getBucketInfo(); Assert.assertEquals(info.get("start"),"200"); Assert.assertEquals(info.get("end"),"400"); - Assert.assertEquals(info.get("startInclusive"),"false"); + Assert.assertEquals(info.get("startInclusive"),"true"); Assert.assertEquals(info.get("endInclusive"),"true"); bucket = facetResponseModel.getBuckets().get(2); - bucket.assertThat().field("label").is("(400 - 600]"); - bucket.assertThat().field("filterQuery").is("content.size:<400 TO 600]"); + bucket.assertThat().field("label").is("[400 - 600]"); + bucket.assertThat().field("filterQuery").is("content.size:[400 TO 600]"); metric = (Map) bucket.getMetrics().get(0).getValue(); Assert.assertTrue(new Integer(metric.get("count")) >= 7); info = (Map) bucket.getBucketInfo(); Assert.assertEquals(info.get("start"),"400"); Assert.assertEquals(info.get("end"),"600"); - Assert.assertEquals(info.get("startInclusive"),"false"); + Assert.assertEquals(info.get("startInclusive"),"true"); Assert.assertEquals(info.get("endInclusive"),"true"); } diff --git a/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java b/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java index c1770dc61..a83be0234 100644 --- a/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java @@ -258,6 +258,45 @@ public class FacetedSearchTest extends AbstractSearchTest bucket1.assertThat().field("filterQuery").is("modifier:System"); bucket1.assertThat().field("count").is(684); } - + @Test + /** + * Test that items returned are in the format of generic facets. + * { + * "query": { + * "query": "*" + * }, + * "facetFields": { + * "facets": [{"field": "cm:mimetype"},{"field": "modifier"}] + * }, + * "facetFormat":"V2" + * } + */ + public void searchWithFactedFieldsFacetFormatV2() throws Exception + { + SearchRequest query = new SearchRequest(); + RestRequestQueryModel queryReq = new RestRequestQueryModel(); + queryReq.setQuery("*"); + query.setQuery(queryReq); + query.setFacetFormat("V2"); + RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); + Listfacets = new ArrayList(); + facets.add(new RestRequestFacetFieldModel("cm:mimetype")); + facets.add(new RestRequestFacetFieldModel("modifier")); + facetFields.setFacets(facets); + query.setFacetFields(facetFields); + SearchResponse response = query(query); + Assert.assertNull(response.getContext().getFacetsFields()); + Assert.assertNull(response.getContext().getFacetQueries()); + Assert.assertFalse(response.getContext().getFacets().isEmpty()); + RestGenericFacetResponseModel model = response.getContext().getFacets().get(0); + Assert.assertEquals(model.getLabel(), "modifier"); + + model.assertThat().field("label").is("modifier"); + RestGenericBucketModel bucket1 = model.getBuckets().get(0); + bucket1.assertThat().field("label").is("System"); + bucket1.assertThat().field("display").isNull(); + bucket1.assertThat().field("filterQuery").is("modifier:System"); + bucket1.assertThat().field("metrics").is("[{entry=null, type=count, value={count=684}}]"); + } } From c9549485c3adbdffb1df3bad2235950c3ad8abe5 Mon Sep 17 00:00:00 2001 From: Gethin James Date: Wed, 31 May 2017 17:00:02 +0200 Subject: [PATCH 1156/1491] SEARCH-430: Adding a pivot range test --- .../rest/search/PivotFacetedSearchTest.java | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/search/PivotFacetedSearchTest.java b/e2e-test/java/org/alfresco/rest/search/PivotFacetedSearchTest.java index ed8c109de..b5bb1863b 100644 --- a/e2e-test/java/org/alfresco/rest/search/PivotFacetedSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/PivotFacetedSearchTest.java @@ -18,11 +18,14 @@ */ package org.alfresco.rest.search; +import static org.junit.Assert.assertTrue; + import java.util.ArrayList; import java.util.Arrays; import java.util.List; import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestRequestRangesModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; @@ -151,6 +154,52 @@ public class PivotFacetedSearchTest extends AbstractSearchTest creatorResponse.assertThat().field("label").is("creator"); } + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH }, executionType = ExecutionType.REGRESSION, + description = "Checks range pivots using Search api") + public void searchWithRangePivoting() throws Exception + { + SearchRequest query = carsQuery(); + + Pagination pagination = new Pagination(); + pagination.setMaxItems(2); + query.setPaging(pagination); + RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); + List list = new ArrayList<>(); + list.add(new RestRequestFacetFieldModel("creator")); + facetFields.setFacets(list); + query.setFacetFields(facetFields); + query.setIncludeRequest(false); + + RestRequestRangesModel facetRangeModel = new RestRequestRangesModel(); + facetRangeModel.setField("created"); + facetRangeModel.setStart("2015-09-29T10:45:15.729Z"); + facetRangeModel.setEnd("2016-09-29T10:45:15.729Z"); + facetRangeModel.setGap("+280DAY"); + facetRangeModel.setLabel("aRange"); + List ranges = new ArrayList(); + ranges.add(facetRangeModel); + query.setRanges(ranges); + + List pivotModelList = new ArrayList<>(); + RestRequestPivotModel creatorpivot = new RestRequestPivotModel(); + creatorpivot.setKey("creator"); + RestRequestPivotModel rangepivot = new RestRequestPivotModel(); + rangepivot.setKey("aRange"); + creatorpivot.setPivots(Arrays.asList(rangepivot)); + pivotModelList.add(creatorpivot); + query.setPivots(pivotModelList); + + SearchResponse response = query(query); + RestGenericFacetResponseModel facetResponseModel = response.getContext().getFacets().get(1); + facetResponseModel.assertThat().field("type").is("pivot"); + facetResponseModel.assertThat().field("label").is("creator"); + RestGenericBucketModel bucket = facetResponseModel.getBuckets().get(0); + RestGenericFacetResponseModel rangeResponse = bucket.getFacets().get(0); + rangeResponse.assertThat().field("type").is("range"); + assertTrue(rangeResponse.getBuckets().size()>0); + + } private void assertPivotResponse(SearchResponse response, String field, String alabel) throws Exception { From 50fb4536c112ae8b0c31dfae903ed0206e4f1c41 Mon Sep 17 00:00:00 2001 From: Gethin James Date: Thu, 1 Jun 2017 15:58:59 +0200 Subject: [PATCH 1157/1491] SEARCH-456: Fixing filter queries tests. --- .../org/alfresco/rest/search/FacetIntervalSearchTest.java | 8 ++++---- .../java/org/alfresco/rest/search/FacetedSearchTest.java | 4 ++-- .../org/alfresco/rest/search/PivotFacetedSearchTest.java | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/FacetIntervalSearchTest.java b/e2e-test/java/org/alfresco/rest/search/FacetIntervalSearchTest.java index c7e9cf9fa..9d8d74b37 100644 --- a/e2e-test/java/org/alfresco/rest/search/FacetIntervalSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FacetIntervalSearchTest.java @@ -120,14 +120,14 @@ public class FacetIntervalSearchTest extends AbstractSearchTest RestGenericBucketModel bucket = facetResponseModel.getBuckets().get(0); Assert.assertEquals(facetResponseModel.getBuckets().size(), 2); bucket.assertThat().field("label").is("aUser"); - bucket.assertThat().field("filterQuery").is("creator:[a TO user]"); + bucket.assertThat().field("filterQuery").is("creator:[\"a\" TO \"user\"]"); bucket.getMetrics().get(0).assertThat().field("type").is("count"); bucket.getMetrics().get(0).assertThat().field("value").contains("{count="); bucket = facetResponseModel.getBuckets().get(1); bucket.assertThat().field("label").is("theRest"); - bucket.assertThat().field("filterQuery").is("creator:"); + bucket.assertThat().field("filterQuery").is("cm:modified:[\"*\" TO \"2016\">"); bucket.getMetrics().get(0).assertThat().field("type").is("count"); bucket.getMetrics().get(0).assertThat().field("value").is("{count=0}"); } diff --git a/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java b/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java index a83be0234..a8eccf613 100644 --- a/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java @@ -255,7 +255,7 @@ public class FacetedSearchTest extends AbstractSearchTest FacetFieldBucket bucket1 = model.getBuckets().get(0); bucket1.assertThat().field("label").is("System"); bucket1.assertThat().field("display").is("System"); - bucket1.assertThat().field("filterQuery").is("modifier:System"); + bucket1.assertThat().field("filterQuery").is("modifier:\"System\""); bucket1.assertThat().field("count").is(684); } @Test @@ -295,7 +295,7 @@ public class FacetedSearchTest extends AbstractSearchTest RestGenericBucketModel bucket1 = model.getBuckets().get(0); bucket1.assertThat().field("label").is("System"); bucket1.assertThat().field("display").isNull(); - bucket1.assertThat().field("filterQuery").is("modifier:System"); + bucket1.assertThat().field("filterQuery").is("modifier:\"System\""); bucket1.assertThat().field("metrics").is("[{entry=null, type=count, value={count=684}}]"); } diff --git a/e2e-test/java/org/alfresco/rest/search/PivotFacetedSearchTest.java b/e2e-test/java/org/alfresco/rest/search/PivotFacetedSearchTest.java index b5bb1863b..198438173 100644 --- a/e2e-test/java/org/alfresco/rest/search/PivotFacetedSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/PivotFacetedSearchTest.java @@ -211,7 +211,7 @@ public class PivotFacetedSearchTest extends AbstractSearchTest facetResponseModel.assertThat().field("label").is(label); RestGenericBucketModel bucket = facetResponseModel.getBuckets().get(0); bucket.assertThat().field("label").isNotEmpty(); - bucket.assertThat().field("filterQuery").is(field+":"+bucket.getLabel()); + bucket.assertThat().field("filterQuery").is(field+":\""+bucket.getLabel()+"\""); Assert.assertEquals("count", bucket.getMetrics().get(0).getType()); Assert.assertTrue(bucket.getMetrics().get(0).getValue().toString().contains("{count=")); } @@ -251,7 +251,7 @@ public class PivotFacetedSearchTest extends AbstractSearchTest labelResponseModel.assertThat().field("label").isNotEmpty(); labelResponseModel.assertThat().field("label").is("aLabel"); RestGenericBucketModel bucket = labelResponseModel.getBuckets().get(0); - bucket.assertThat().field("filterQuery").is("modifier:"+bucket.getLabel()); + bucket.assertThat().field("filterQuery").is("modifier:\""+bucket.getLabel()+"\""); Assert.assertEquals("count", bucket.getMetrics().get(0).getType()); Assert.assertTrue(bucket.getMetrics().get(0).getValue().toString().contains("{count=")); } From fa2bba2a76380c3640201720a599aa1130a5e3f6 Mon Sep 17 00:00:00 2001 From: Michael Suzuki Date: Mon, 5 Jun 2017 15:36:51 +0100 Subject: [PATCH 1158/1491] Search-340, amend test to reflect inclusive logic and fixed qoutes --- .../rest/search/FacetRangeSearchTest.java | 46 +++++++++---------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java b/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java index 7e4d6d7ce..d4ae6bfa7 100644 --- a/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java @@ -127,7 +127,7 @@ public class FacetRangeSearchTest extends AbstractSearchTest RestGenericBucketModel bucket = facetResponseModel.getBuckets().get(0); bucket.assertThat().field("label").is("[0 - 200)"); - bucket.assertThat().field("filterQuery").is("content.size:[0 TO 200>"); + bucket.assertThat().field("filterQuery").is("content.size:[\"0\" TO \"200\">"); Map metric = (Map) bucket.getMetrics().get(0).getValue(); Assert.assertTrue(new Integer(metric.get("count")) >= 4); Map info = (Map) bucket.getBucketInfo(); @@ -139,7 +139,7 @@ public class FacetRangeSearchTest extends AbstractSearchTest bucket = facetResponseModel.getBuckets().get(1); bucket.assertThat().field("label").is("[200 - 400)"); - bucket.assertThat().field("filterQuery").is("content.size:[200 TO 400>"); + bucket.assertThat().field("filterQuery").is("content.size:[\"200\" TO \"400\">"); metric = (Map) bucket.getMetrics().get(0).getValue(); Integer count = new Integer(metric.get("count")); Assert.assertTrue(count >= 4); @@ -150,15 +150,15 @@ public class FacetRangeSearchTest extends AbstractSearchTest Assert.assertEquals(info.get("endInclusive"),"false"); bucket = facetResponseModel.getBuckets().get(2); - bucket.assertThat().field("label").is("[400 - 600)"); - bucket.assertThat().field("filterQuery").is("content.size:[400 TO 600>"); + bucket.assertThat().field("label").is("[400 - 600]"); + bucket.assertThat().field("filterQuery").is("content.size:[\"400\" TO \"600\"]"); metric = (Map) bucket.getMetrics().get(0).getValue(); Assert.assertTrue(new Integer(metric.get("count")) >= 7); info = (Map) bucket.getBucketInfo(); Assert.assertEquals(info.get("start"),"400"); Assert.assertEquals(info.get("end"),"600"); Assert.assertEquals(info.get("startInclusive"),"true"); - Assert.assertEquals(info.get("endInclusive"),"false"); + Assert.assertEquals(info.get("endInclusive"),"true"); } @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) @@ -184,7 +184,7 @@ public class FacetRangeSearchTest extends AbstractSearchTest RestGenericBucketModel bucket = facetResponseModel.getBuckets().get(0); bucket.assertThat().field("label").is("[0 - 200)"); - bucket.assertThat().field("filterQuery").is("content.size:[0 TO 200>"); + bucket.assertThat().field("filterQuery").is("content.size:[\"0\" TO \"200\">"); Map metric = (Map) bucket.getMetrics().get(0).getValue(); Assert.assertTrue(new Integer(metric.get("count")) >= 4); Map info = (Map) bucket.getBucketInfo(); @@ -196,7 +196,7 @@ public class FacetRangeSearchTest extends AbstractSearchTest bucket = facetResponseModel.getBuckets().get(1); bucket.assertThat().field("label").is("[200 - 400)"); - bucket.assertThat().field("filterQuery").is("content.size:[200 TO 400>"); + bucket.assertThat().field("filterQuery").is("content.size:[\"200\" TO \"400\">"); info = (Map) bucket.getBucketInfo(); Assert.assertEquals(info.get("start"),"200"); Assert.assertEquals(info.get("end"),"400"); @@ -207,8 +207,8 @@ public class FacetRangeSearchTest extends AbstractSearchTest Assert.assertEquals(info.get("endInclusive"),"false"); bucket = facetResponseModel.getBuckets().get(2); - bucket.assertThat().field("label").is("[400 - 500)"); - bucket.assertThat().field("filterQuery").is("content.size:[400 TO 500>"); + bucket.assertThat().field("label").is("[400 - 500]"); + bucket.assertThat().field("filterQuery").is("content.size:[\"400\" TO \"500\"]"); metric = (Map) bucket.getMetrics().get(0).getValue(); Assert.assertTrue(new Integer(metric.get("count")) >= 3); info = (Map) bucket.getBucketInfo(); @@ -216,7 +216,7 @@ public class FacetRangeSearchTest extends AbstractSearchTest Assert.assertEquals(info.get("end"),"500"); Assert.assertNull(info.get("count")); Assert.assertEquals(info.get("startInclusive"),"true"); - Assert.assertEquals(info.get("endInclusive"),"false"); + Assert.assertEquals(info.get("endInclusive"),"true"); } @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, @@ -240,7 +240,7 @@ public class FacetRangeSearchTest extends AbstractSearchTest RestGenericBucketModel bucket = facetResponseModel.getBuckets().get(0); bucket.assertThat().field("label").is("[2015-09-29T10:45:15.729Z - 2016-07-05T10:45:15.729Z)"); - bucket.assertThat().field("filterQuery").is("created:[2015-09-29T10:45:15.729Z TO 2016-07-05T10:45:15.729Z>"); + bucket.assertThat().field("filterQuery").is("created:[\"2015-09-29T10:45:15.729Z\" TO \"2016-07-05T10:45:15.729Z\">"); bucket.getMetrics().get(0).assertThat().field("value").is("{count=1}"); Map info = (Map) bucket.getBucketInfo(); Assert.assertEquals(info.get("start"),"2015-09-29T10:45:15.729Z"); @@ -250,15 +250,15 @@ public class FacetRangeSearchTest extends AbstractSearchTest Assert.assertEquals(info.get("endInclusive"),"false"); bucket = facetResponseModel.getBuckets().get(1); - bucket.assertThat().field("label").is("[2016-07-05T10:45:15.729Z - 2017-04-11T10:45:15.729Z)"); - bucket.assertThat().field("filterQuery").is("created:[2016-07-05T10:45:15.729Z TO 2017-04-11T10:45:15.729Z>"); + bucket.assertThat().field("label").is("[2016-07-05T10:45:15.729Z - 2017-04-11T10:45:15.729Z]"); + bucket.assertThat().field("filterQuery").is("created:[\"2016-07-05T10:45:15.729Z\" TO \"2017-04-11T10:45:15.729Z\"]"); bucket.getMetrics().get(0).assertThat().field("value").is("{count=0}"); info = (Map) bucket.getBucketInfo(); Assert.assertEquals(info.get("start"),"2016-07-05T10:45:15.729Z"); Assert.assertEquals(info.get("end"),"2017-04-11T10:45:15.729Z"); Assert.assertNull(info.get("count"),"0"); Assert.assertEquals(info.get("startInclusive"),"true"); - Assert.assertEquals(info.get("endInclusive"),"false"); + Assert.assertEquals(info.get("endInclusive"),"true"); } @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) @@ -307,38 +307,38 @@ public class FacetRangeSearchTest extends AbstractSearchTest RestGenericFacetResponseModel facetResponseModel = response.getContext().getFacets().get(0); RestGenericBucketModel bucket = facetResponseModel.getBuckets().get(0); - bucket.assertThat().field("label").is("[0 - 200]"); - bucket.assertThat().field("filterQuery").is("content.size:[0 TO 200]"); + bucket.assertThat().field("label").is("(0 - 200]"); + bucket.assertThat().field("filterQuery").is("content.size:<\"0\" TO \"200\"]"); Map metric = (Map) bucket.getMetrics().get(0).getValue(); Assert.assertTrue(new Integer(metric.get("count")) >= 4); Map info = (Map) bucket.getBucketInfo(); Assert.assertEquals(info.get("start"),"0"); Assert.assertEquals(info.get("end"),"200"); Assert.assertNull(info.get("count")); - Assert.assertEquals(info.get("startInclusive"),"true"); + Assert.assertEquals(info.get("startInclusive"),"false"); Assert.assertEquals(info.get("endInclusive"),"true"); bucket = facetResponseModel.getBuckets().get(1); - bucket.assertThat().field("label").is("[200 - 400]"); - bucket.assertThat().field("filterQuery").is("content.size:[200 TO 400]"); + bucket.assertThat().field("label").is("(200 - 400]"); + bucket.assertThat().field("filterQuery").is("content.size:<\"200\" TO \"400\"]"); metric = (Map) bucket.getMetrics().get(0).getValue(); Integer count = new Integer(metric.get("count")); Assert.assertTrue(count >= 4); info = (Map) bucket.getBucketInfo(); Assert.assertEquals(info.get("start"),"200"); Assert.assertEquals(info.get("end"),"400"); - Assert.assertEquals(info.get("startInclusive"),"true"); + Assert.assertEquals(info.get("startInclusive"),"false"); Assert.assertEquals(info.get("endInclusive"),"true"); bucket = facetResponseModel.getBuckets().get(2); - bucket.assertThat().field("label").is("[400 - 600]"); - bucket.assertThat().field("filterQuery").is("content.size:[400 TO 600]"); + bucket.assertThat().field("label").is("(400 - 600]"); + bucket.assertThat().field("filterQuery").is("content.size:<\"400\" TO \"600\"]"); metric = (Map) bucket.getMetrics().get(0).getValue(); Assert.assertTrue(new Integer(metric.get("count")) >= 7); info = (Map) bucket.getBucketInfo(); Assert.assertEquals(info.get("start"),"400"); Assert.assertEquals(info.get("end"),"600"); - Assert.assertEquals(info.get("startInclusive"),"true"); + Assert.assertEquals(info.get("startInclusive"),"false"); Assert.assertEquals(info.get("endInclusive"),"true"); } From 2243adeea9c4825ca95e3dd38e45c36b59a5b6f9 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Tue, 13 Jun 2017 10:32:26 +0300 Subject: [PATCH 1159/1491] added bug id to the failing tests till they get fixed --- .../rest/search/PivotFacetedSearchTest.java | 5 +++++ .../alfresco/rest/search/StatsSearchTest.java | 21 ++++++++++++------- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/PivotFacetedSearchTest.java b/e2e-test/java/org/alfresco/rest/search/PivotFacetedSearchTest.java index 198438173..4162f47b9 100644 --- a/e2e-test/java/org/alfresco/rest/search/PivotFacetedSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/PivotFacetedSearchTest.java @@ -27,6 +27,7 @@ import java.util.List; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestRequestRangesModel; import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -70,6 +71,7 @@ public class PivotFacetedSearchTest extends AbstractSearchTest .containsSummary("Pivot parameter none_like_this does not reference"); } + @Bug(id = "TAS-3500") @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH }) @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH }, executionType = ExecutionType.REGRESSION, description = "Checks with pivot using Search api") @@ -98,6 +100,7 @@ public class PivotFacetedSearchTest extends AbstractSearchTest assertPivotResponse(response, "creator", null); } + @Bug(id = "TAS-3500") @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH }) @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH }, executionType = ExecutionType.REGRESSION, description = "Checks nested pivot using Search api") @@ -154,6 +157,7 @@ public class PivotFacetedSearchTest extends AbstractSearchTest creatorResponse.assertThat().field("label").is("creator"); } + @Bug(id = "TAS-3500") @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH }) @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH }, executionType = ExecutionType.REGRESSION, description = "Checks range pivots using Search api") @@ -216,6 +220,7 @@ public class PivotFacetedSearchTest extends AbstractSearchTest Assert.assertTrue(bucket.getMetrics().get(0).getValue().toString().contains("{count=")); } + @Bug(id = "TAS-3500") @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH }) @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH }, executionType = ExecutionType.REGRESSION, description = "Checks with pivot using Search api and a label as a key") diff --git a/e2e-test/java/org/alfresco/rest/search/StatsSearchTest.java b/e2e-test/java/org/alfresco/rest/search/StatsSearchTest.java index 5cacb186f..24ac4c26e 100644 --- a/e2e-test/java/org/alfresco/rest/search/StatsSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/StatsSearchTest.java @@ -21,13 +21,6 @@ package org.alfresco.rest.search; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertTrue; -import org.alfresco.rest.model.RestErrorModel; -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.Assert; -import org.testng.annotations.Test; import java.util.ArrayList; import java.util.Arrays; @@ -36,6 +29,14 @@ import java.util.Map; import java.util.Set; import java.util.stream.Collectors; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.Test; + /** * Stats search test. * @author Gethin James @@ -44,6 +45,7 @@ import java.util.stream.Collectors; public class StatsSearchTest extends AbstractSearchTest { + @Bug(id = "TAS-3500") @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH }) @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH }, executionType = ExecutionType.REGRESSION, description = "Checks errors with stats using Search api") @@ -127,6 +129,7 @@ public class StatsSearchTest extends AbstractSearchTest assertTrue(percentiles.keySet().containsAll(Arrays.asList("1.0","75.0","99.0","99.9"))); } + @Bug(id = "TAS-3500") @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH }) @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH }, executionType = ExecutionType.REGRESSION, description = "Checks errors with stats labels using Search api") @@ -146,6 +149,7 @@ public class StatsSearchTest extends AbstractSearchTest assertStatsFacetedResponse(response, "DateChanged", 8); } + @Bug(id = "TAS-3500") @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH }) @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH }, executionType = ExecutionType.REGRESSION, description = "Checks errors with stats fitlers using Search api") @@ -180,6 +184,7 @@ public class StatsSearchTest extends AbstractSearchTest assertTrue((Integer)metricCount.get("count") > count, "With the exclude filter there will be more documents than returned"); } + @Bug(id = "TAS-3500") @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH }) @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH }, executionType = ExecutionType.REGRESSION, description = "Checks errors with stats with Pivot using Search api") @@ -242,7 +247,7 @@ public class StatsSearchTest extends AbstractSearchTest } - + @Bug(id = "TAS-3500") @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH }) @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH }, executionType = ExecutionType.REGRESSION, description = "Checks errors with stats with Pivot using Search api") From d1294cacdbd612d2b128321f250d21ce1b4bb2ab Mon Sep 17 00:00:00 2001 From: Gethin James Date: Tue, 13 Jun 2017 15:58:23 +0200 Subject: [PATCH 1160/1491] Revert "added bug id to the failing tests till they get fixed" This reverts commit 656b562c8acf7b56517d7a118f3469031def300c. --- .../rest/search/PivotFacetedSearchTest.java | 5 ----- .../alfresco/rest/search/StatsSearchTest.java | 21 +++++++------------ 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/PivotFacetedSearchTest.java b/e2e-test/java/org/alfresco/rest/search/PivotFacetedSearchTest.java index 4162f47b9..198438173 100644 --- a/e2e-test/java/org/alfresco/rest/search/PivotFacetedSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/PivotFacetedSearchTest.java @@ -27,7 +27,6 @@ import java.util.List; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestRequestRangesModel; import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -71,7 +70,6 @@ public class PivotFacetedSearchTest extends AbstractSearchTest .containsSummary("Pivot parameter none_like_this does not reference"); } - @Bug(id = "TAS-3500") @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH }) @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH }, executionType = ExecutionType.REGRESSION, description = "Checks with pivot using Search api") @@ -100,7 +98,6 @@ public class PivotFacetedSearchTest extends AbstractSearchTest assertPivotResponse(response, "creator", null); } - @Bug(id = "TAS-3500") @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH }) @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH }, executionType = ExecutionType.REGRESSION, description = "Checks nested pivot using Search api") @@ -157,7 +154,6 @@ public class PivotFacetedSearchTest extends AbstractSearchTest creatorResponse.assertThat().field("label").is("creator"); } - @Bug(id = "TAS-3500") @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH }) @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH }, executionType = ExecutionType.REGRESSION, description = "Checks range pivots using Search api") @@ -220,7 +216,6 @@ public class PivotFacetedSearchTest extends AbstractSearchTest Assert.assertTrue(bucket.getMetrics().get(0).getValue().toString().contains("{count=")); } - @Bug(id = "TAS-3500") @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH }) @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH }, executionType = ExecutionType.REGRESSION, description = "Checks with pivot using Search api and a label as a key") diff --git a/e2e-test/java/org/alfresco/rest/search/StatsSearchTest.java b/e2e-test/java/org/alfresco/rest/search/StatsSearchTest.java index 24ac4c26e..5cacb186f 100644 --- a/e2e-test/java/org/alfresco/rest/search/StatsSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/StatsSearchTest.java @@ -21,6 +21,13 @@ package org.alfresco.rest.search; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertTrue; +import org.alfresco.rest.model.RestErrorModel; +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.Assert; +import org.testng.annotations.Test; import java.util.ArrayList; import java.util.Arrays; @@ -29,14 +36,6 @@ import java.util.Map; import java.util.Set; import java.util.stream.Collectors; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.Test; - /** * Stats search test. * @author Gethin James @@ -45,7 +44,6 @@ import org.testng.annotations.Test; public class StatsSearchTest extends AbstractSearchTest { - @Bug(id = "TAS-3500") @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH }) @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH }, executionType = ExecutionType.REGRESSION, description = "Checks errors with stats using Search api") @@ -129,7 +127,6 @@ public class StatsSearchTest extends AbstractSearchTest assertTrue(percentiles.keySet().containsAll(Arrays.asList("1.0","75.0","99.0","99.9"))); } - @Bug(id = "TAS-3500") @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH }) @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH }, executionType = ExecutionType.REGRESSION, description = "Checks errors with stats labels using Search api") @@ -149,7 +146,6 @@ public class StatsSearchTest extends AbstractSearchTest assertStatsFacetedResponse(response, "DateChanged", 8); } - @Bug(id = "TAS-3500") @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH }) @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH }, executionType = ExecutionType.REGRESSION, description = "Checks errors with stats fitlers using Search api") @@ -184,7 +180,6 @@ public class StatsSearchTest extends AbstractSearchTest assertTrue((Integer)metricCount.get("count") > count, "With the exclude filter there will be more documents than returned"); } - @Bug(id = "TAS-3500") @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH }) @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH }, executionType = ExecutionType.REGRESSION, description = "Checks errors with stats with Pivot using Search api") @@ -247,7 +242,7 @@ public class StatsSearchTest extends AbstractSearchTest } - @Bug(id = "TAS-3500") + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH }) @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH }, executionType = ExecutionType.REGRESSION, description = "Checks errors with stats with Pivot using Search api") From b5955868d1b325b2a4b3e4fafbcd3df014af3a1a Mon Sep 17 00:00:00 2001 From: Gethin James Date: Tue, 13 Jun 2017 16:00:58 +0200 Subject: [PATCH 1161/1491] TAS-3500: Tagging tests are TestGroup.ASS_1 --- .../org/alfresco/rest/search/PivotFacetedSearchTest.java | 5 +++-- e2e-test/java/org/alfresco/rest/search/StatsSearchTest.java | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/PivotFacetedSearchTest.java b/e2e-test/java/org/alfresco/rest/search/PivotFacetedSearchTest.java index 198438173..5bbeaf171 100644 --- a/e2e-test/java/org/alfresco/rest/search/PivotFacetedSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/PivotFacetedSearchTest.java @@ -41,8 +41,9 @@ import org.testng.annotations.Test; public class PivotFacetedSearchTest extends AbstractSearchTest { - @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH }, executionType = ExecutionType.REGRESSION, + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, + executionType = ExecutionType.REGRESSION, description = "Checks errors with pivot using Search api") public void searchWithPivotingErrors() throws Exception { diff --git a/e2e-test/java/org/alfresco/rest/search/StatsSearchTest.java b/e2e-test/java/org/alfresco/rest/search/StatsSearchTest.java index 5cacb186f..764803150 100644 --- a/e2e-test/java/org/alfresco/rest/search/StatsSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/StatsSearchTest.java @@ -44,8 +44,9 @@ import java.util.stream.Collectors; public class StatsSearchTest extends AbstractSearchTest { - @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH }, executionType = ExecutionType.REGRESSION, + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, + executionType = ExecutionType.REGRESSION, description = "Checks errors with stats using Search api") public void searchWithBasicStats() throws Exception { From 469c2c0e176ee43189b19d203cbba879e1389856 Mon Sep 17 00:00:00 2001 From: Gethin James Date: Thu, 15 Jun 2017 12:20:37 +0200 Subject: [PATCH 1162/1491] MNT-18051: Changed stats count to countValues --- .../alfresco/rest/search/StatsSearchTest.java | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/StatsSearchTest.java b/e2e-test/java/org/alfresco/rest/search/StatsSearchTest.java index 764803150..ba4719931 100644 --- a/e2e-test/java/org/alfresco/rest/search/StatsSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/StatsSearchTest.java @@ -26,7 +26,6 @@ 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.Assert; import org.testng.annotations.Test; import java.util.ArrayList; @@ -67,19 +66,19 @@ public class StatsSearchTest extends AbstractSearchTest response = query(query); //8 metrics by default for a numeric field Set metricTypes = assertStatsFacetedResponse(response, "DBID", 8); - assertTrue(metricTypes.containsAll(Arrays.asList("missing", "count", "sum","min","max", "sumOfSquares", "mean", "stddev"))); + assertTrue(metricTypes.containsAll(Arrays.asList("missing", "countValues", "sum","min","max", "sumOfSquares", "mean", "stddev"))); statsModel1.setField("creator"); response = query(query); //4 metrics by default for a string field metricTypes = assertStatsFacetedResponse(response, "creator", 4); - assertTrue(metricTypes.containsAll(Arrays.asList("missing", "count", "min","max"))); + assertTrue(metricTypes.containsAll(Arrays.asList("missing", "countValues", "min","max"))); statsModel1.setField("modified"); response = query(query); //8 metrics by default for a date field metricTypes = assertStatsFacetedResponse(response, "modified", 8); - assertTrue(metricTypes.containsAll(Arrays.asList("missing", "count", "sum","min","max", "sumOfSquares", "mean", "stddev"))); + assertTrue(metricTypes.containsAll(Arrays.asList("missing", "countValues", "sum","min","max", "sumOfSquares", "mean", "stddev"))); statsModel1.setField("modifier"); statsModel1.setMin(false); @@ -92,7 +91,7 @@ public class StatsSearchTest extends AbstractSearchTest statsModel1.setField("DBID"); statsModel1.setMin(true); statsModel1.setMax(true); - statsModel1.setCount(false); + statsModel1.setCountValues(false); statsModel1.setMissing(false); statsModel1.setSum(false); statsModel1.setSumOfSquares(false); @@ -101,7 +100,7 @@ public class StatsSearchTest extends AbstractSearchTest response = query(query); metricTypes = assertStatsFacetedResponse(response, "DBID", 2); assertTrue(metricTypes.containsAll(Arrays.asList("min","max"))); - assertFalse(metricTypes.containsAll(Arrays.asList("missing", "count", "sum","sumOfSquares", "mean", "stddev"))); + assertFalse(metricTypes.containsAll(Arrays.asList("missing", "countValues", "sum","sumOfSquares", "mean", "stddev"))); statsModel1.setField("modifier"); statsModel1.setMin(false); @@ -170,7 +169,7 @@ public class StatsSearchTest extends AbstractSearchTest RestGenericMetricModel countMetric = response.getContext().getFacets().get(0).getBuckets().get(0).getMetrics().get(0); Integer count = response.getPagination().getTotalItems(); Map metricCount = (Map) countMetric.getValue(); - assertEquals(count, metricCount.get("count")); + assertEquals(count, metricCount.get("countValues")); statsModel1.setExcludeFilters(Arrays.asList("justCars")); response = query(query); @@ -178,7 +177,7 @@ public class StatsSearchTest extends AbstractSearchTest countMetric = response.getContext().getFacets().get(0).getBuckets().get(0).getMetrics().get(0); count = response.getEntries().size(); metricCount = (Map) countMetric.getValue(); - assertTrue((Integer)metricCount.get("count") > count, "With the exclude filter there will be more documents than returned"); + assertTrue((Integer)metricCount.get("countValues") > count, "With the exclude filter there will be more documents than returned"); } @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH }) @@ -239,7 +238,7 @@ public class StatsSearchTest extends AbstractSearchTest created.assertThat().field("type").is("pivot"); created.assertThat().field("label").is("created"); //Another nested stats - assertEquals(created.getBuckets().get(0).getMetrics().size(), 8, "Metrics are on the end of a pivot bucket"); + assertEquals(created.getBuckets().get(0).getMetrics().size(), 9, "Metrics are on the end of a pivot bucket"); } @@ -288,7 +287,7 @@ public class StatsSearchTest extends AbstractSearchTest RestGenericFacetResponseModel facetResponseModel = response.getContext().getFacets().get(0); facetResponseModel.assertThat().field("type").is("pivot"); facetResponseModel.assertThat().field("label").is("creator"); - assertEquals(facetResponseModel.getBuckets().get(0).getMetrics().size(), 8, "Metrics are on the end of a pivot bucket"); + assertEquals(facetResponseModel.getBuckets().get(0).getMetrics().size(), 9, "Metrics are on the end of a pivot bucket"); RestGenericFacetResponseModel statsFacet = response.getContext().getFacets().get(1); statsFacet.assertThat().field("type").is("stats"); statsFacet.assertThat().field("label").is("numericId"); From 66fec6e1bf2070d5a2eecba567c4efaeb2878f40 Mon Sep 17 00:00:00 2001 From: Gethin James Date: Tue, 20 Jun 2017 12:48:03 +0200 Subject: [PATCH 1163/1491] TAS-3500: Tagging more tests are TestGroup.ASS_1 --- .../rest/search/PivotFacetedSearchTest.java | 20 +++++++++++-------- .../alfresco/rest/search/StatsSearchTest.java | 20 +++++++++++-------- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/PivotFacetedSearchTest.java b/e2e-test/java/org/alfresco/rest/search/PivotFacetedSearchTest.java index 5bbeaf171..bc54be77d 100644 --- a/e2e-test/java/org/alfresco/rest/search/PivotFacetedSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/PivotFacetedSearchTest.java @@ -71,8 +71,9 @@ public class PivotFacetedSearchTest extends AbstractSearchTest .containsSummary("Pivot parameter none_like_this does not reference"); } - @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH }, executionType = ExecutionType.REGRESSION, + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, + executionType = ExecutionType.REGRESSION, description = "Checks with pivot using Search api") public void searchWithPivoting() throws Exception { @@ -99,8 +100,9 @@ public class PivotFacetedSearchTest extends AbstractSearchTest assertPivotResponse(response, "creator", null); } - @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH }, executionType = ExecutionType.REGRESSION, + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, + executionType = ExecutionType.REGRESSION, description = "Checks nested pivot using Search api") public void searchWithNestedPivoting() throws Exception { @@ -155,8 +157,9 @@ public class PivotFacetedSearchTest extends AbstractSearchTest creatorResponse.assertThat().field("label").is("creator"); } - @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH }, executionType = ExecutionType.REGRESSION, + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, + executionType = ExecutionType.REGRESSION, description = "Checks range pivots using Search api") public void searchWithRangePivoting() throws Exception { @@ -217,8 +220,9 @@ public class PivotFacetedSearchTest extends AbstractSearchTest Assert.assertTrue(bucket.getMetrics().get(0).getValue().toString().contains("{count=")); } - @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH }, executionType = ExecutionType.REGRESSION, + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, + executionType = ExecutionType.REGRESSION, description = "Checks with pivot using Search api and a label as a key") public void searchWithPivotingUsingLabel() throws Exception { diff --git a/e2e-test/java/org/alfresco/rest/search/StatsSearchTest.java b/e2e-test/java/org/alfresco/rest/search/StatsSearchTest.java index ba4719931..59735b6ee 100644 --- a/e2e-test/java/org/alfresco/rest/search/StatsSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/StatsSearchTest.java @@ -127,8 +127,9 @@ public class StatsSearchTest extends AbstractSearchTest assertTrue(percentiles.keySet().containsAll(Arrays.asList("1.0","75.0","99.0","99.9"))); } - @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH }, executionType = ExecutionType.REGRESSION, + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, + executionType = ExecutionType.REGRESSION, description = "Checks errors with stats labels using Search api") public void searchWithStatsLabel() throws Exception { @@ -146,8 +147,9 @@ public class StatsSearchTest extends AbstractSearchTest assertStatsFacetedResponse(response, "DateChanged", 8); } - @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH }, executionType = ExecutionType.REGRESSION, + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, + executionType = ExecutionType.REGRESSION, description = "Checks errors with stats fitlers using Search api") public void searchWithStatsFilters() throws Exception { @@ -180,8 +182,9 @@ public class StatsSearchTest extends AbstractSearchTest assertTrue((Integer)metricCount.get("countValues") > count, "With the exclude filter there will be more documents than returned"); } - @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH }, executionType = ExecutionType.REGRESSION, + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, + executionType = ExecutionType.REGRESSION, description = "Checks errors with stats with Pivot using Search api") public void searchWithStatsAndMutlilevelPivot() throws Exception { @@ -243,8 +246,9 @@ public class StatsSearchTest extends AbstractSearchTest } - @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH }, executionType = ExecutionType.REGRESSION, + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, + executionType = ExecutionType.REGRESSION, description = "Checks errors with stats with Pivot using Search api") public void searchWithStatsAndPivot() throws Exception { From d948012b44d6880dc0f399c9d5c929d225d703f6 Mon Sep 17 00:00:00 2001 From: Bogdan Bocancea Date: Tue, 27 Jun 2017 16:54:42 +0300 Subject: [PATCH 1164/1491] - set utility to 1.0.16-SNAPSHOT - update site visibility (from dataprep) and user role in test --- .../alfresco/rest/FunctionalCasesTests.java | 8 ++++---- .../org/alfresco/rest/demo/RestDemoTests.java | 20 +++++++++---------- .../rest/favorites/GetFavoriteFullTests.java | 7 ++++--- .../favorites/GetFavoriteSiteFullTests.java | 2 +- .../people/DeleteSiteMemberFullTests.java | 3 +-- .../rest/search/AbstractSearchTest.java | 1 - .../alfresco/rest/sites/GetSiteFullTests.java | 6 +++--- .../rest/sites/GetSitesCoreTests.java | 2 +- .../rest/sites/GetSitesFullTests.java | 2 +- .../members/GetSiteMembersFullTests.java | 5 ++--- .../AddSiteMembershipRequestFullTests.java | 4 ++-- ...eleteSiteMembershipRequestSanityTests.java | 2 +- .../GetSiteMembershipRequestFullTests.java | 2 +- ...pdateSiteMembershipRequestSanityTests.java | 2 +- 14 files changed, 31 insertions(+), 35 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java b/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java index a4377bc30..2477c46df 100644 --- a/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java +++ b/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java @@ -2,6 +2,7 @@ package org.alfresco.rest; import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.dataprep.SiteService.Visibility; import org.alfresco.rest.model.RestActivityModelsCollection; import org.alfresco.rest.model.RestCommentModel; import org.alfresco.rest.model.RestCommentModelsCollection; @@ -23,7 +24,6 @@ import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; -import org.springframework.social.alfresco.api.entities.Site; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -540,7 +540,7 @@ public class FunctionalCasesTests extends RestTest .assertThat().entriesListContains("target.site.visibility", favoriteSite.getVisibility().name()) .assertThat().entriesListContains("target.site.id", favoriteSite.getId()); - dataSite.usingUser(manager).updateSiteVisibility(favoriteSite, Site.Visibility.MODERATED); + dataSite.usingUser(manager).updateSiteVisibility(favoriteSite, Visibility.MODERATED); userFavoriteSites = restClient.authenticateUser(regularUser).withCoreAPI().usingAuthUser().where().targetSiteExist().getFavorites(); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -548,13 +548,13 @@ public class FunctionalCasesTests extends RestTest .assertThat().entriesListContains("target.site.visibility", "MODERATED") .assertThat().entriesListContains("target.site.id", favoriteSite.getId()); - dataSite.usingUser(manager).updateSiteVisibility(favoriteSite, Site.Visibility.PRIVATE); + dataSite.usingUser(manager).updateSiteVisibility(favoriteSite, Visibility.PRIVATE); userFavoriteSites = restClient.authenticateUser(regularUser).withCoreAPI().usingAuthUser().where().targetSiteExist().getFavorites(); restClient.assertStatusCodeIs(HttpStatus.OK); userFavoriteSites.assertThat().entriesListIsEmpty(); - dataSite.usingUser(manager).updateSiteVisibility(favoriteSite, Site.Visibility.PUBLIC); + dataSite.usingUser(manager).updateSiteVisibility(favoriteSite, Visibility.PUBLIC); userFavoriteSites = restClient.authenticateUser(regularUser).withCoreAPI().usingAuthUser().where().targetSiteExist().getFavorites(); restClient.assertStatusCodeIs(HttpStatus.OK); diff --git a/e2e-test/java/org/alfresco/rest/demo/RestDemoTests.java b/e2e-test/java/org/alfresco/rest/demo/RestDemoTests.java index 9bcbcf02d..80ba29199 100644 --- a/e2e-test/java/org/alfresco/rest/demo/RestDemoTests.java +++ b/e2e-test/java/org/alfresco/rest/demo/RestDemoTests.java @@ -1,6 +1,7 @@ package org.alfresco.rest.demo; import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.dataprep.SiteService.Visibility; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.utility.constants.UserRole; @@ -10,14 +11,11 @@ import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; import org.springframework.http.HttpStatus; -import org.springframework.social.alfresco.api.entities.Role; -import org.springframework.social.alfresco.api.entities.Site.Visibility; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; - public class RestDemoTests extends RestTest -{ +{ private UserModel userModel; private SiteModel siteModel; @@ -26,7 +24,7 @@ public class RestDemoTests extends RestTest { userModel = dataUser.getAdminUser(); siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - restClient.authenticateUser(userModel); + restClient.authenticateUser(userModel); } /** @@ -47,8 +45,8 @@ public class RestDemoTests extends RestTest restClient.withCoreAPI().usingSite(siteModel).getSite() .assertThat().field("id").isNotNull() .assertThat().field("description").is(siteModel.getDescription()) - .assertThat().field("title").is(siteModel.getTitle()) - .assertThat().field("visibility").is(Visibility.PUBLIC); + .assertThat().field("title").is(siteModel.getTitle()) + .assertThat().field("visibility").is(Visibility.PUBLIC); } /** @@ -62,7 +60,7 @@ public class RestDemoTests extends RestTest public void adminCanPostAndUpdateComments() throws Exception { FileModel fileModel = dataContent.usingUser(userModel) - .usingResource(FolderModel.getSharedFolderModel()) + .usingResource(FolderModel.getSharedFolderModel()) .createContent(DocumentType.TEXT_PLAIN); // add new comment restClient.withCoreAPI().usingResource(fileModel).addComment("This is a new comment"); @@ -87,10 +85,10 @@ public class RestDemoTests extends RestTest testUser.setUserRole(UserRole.SiteConsumer); // add user as Consumer to site - restClient.withCoreAPI().usingSite(siteModel).addPerson(testUser); + restClient.withCoreAPI().usingSite(siteModel).addPerson(testUser); restClient.withCoreAPI().usingSite(siteModel).getSiteMembers().assertThat().entriesListContains("id", testUser.getUsername()) .when().getSiteMember(testUser.getUsername()) - .assertSiteMemberHasRole(Role.SiteConsumer); + .assertSiteMemberHasRole(UserRole.SiteConsumer); // update site member to Manager testUser.setUserRole(UserRole.SiteCollaborator); @@ -98,7 +96,7 @@ public class RestDemoTests extends RestTest restClient.withCoreAPI().usingSite(siteModel).getSiteMembers().and() .entriesListContains("id", testUser.getUsername()) .when().getSiteMember(testUser.getUsername()) - .assertSiteMemberHasRole(Role.SiteCollaborator); + .assertSiteMemberHasRole(UserRole.SiteCollaborator); restClient.withCoreAPI().usingSite(siteModel).deleteSiteMember(testUser); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteFullTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteFullTests.java index 8e4b24b9b..531698180 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteFullTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteFullTests.java @@ -1,6 +1,7 @@ package org.alfresco.rest.favorites; import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.dataprep.SiteService.Visibility; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestErrorModel; @@ -16,11 +17,11 @@ import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; -import org.springframework.social.alfresco.api.entities.Site; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -public class GetFavoriteFullTests extends RestTest { +public class GetFavoriteFullTests extends RestTest +{ private UserModel adminUserModel; private SiteModel siteModel; private FolderModel folderModel; @@ -172,7 +173,7 @@ public class GetFavoriteFullTests extends RestTest { favoriteSite.assertThat().field("targetGuid").is(siteModel.getGuid()) .and().field("target.site.role").is(UserRole.SiteContributor.toString()) - .and().field("target.site.visibility").is(Site.Visibility.PUBLIC.toString()) + .and().field("target.site.visibility").is(Visibility.PUBLIC.toString()) .and().field("target.site.guid").is(siteModel.getGuid()) .and().field("target.site.description").is(siteModel.getDescription()) .and().field("target.site.id").is(siteModel.getId()) diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSiteFullTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSiteFullTests.java index b6ff75384..87fbffd25 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSiteFullTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSiteFullTests.java @@ -1,6 +1,7 @@ package org.alfresco.rest.favorites; import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.dataprep.SiteService.Visibility; import org.alfresco.rest.RestTest; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.model.RestErrorModel; @@ -17,7 +18,6 @@ import org.alfresco.utility.testrail.annotation.TestRail; import org.apache.commons.lang3.RandomStringUtils; import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; -import org.springframework.social.alfresco.api.entities.Site.Visibility; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberFullTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberFullTests.java index d069379bb..a0bbf187d 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberFullTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberFullTests.java @@ -11,7 +11,6 @@ import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; -import org.springframework.social.alfresco.api.entities.Role; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -189,7 +188,7 @@ public class DeleteSiteMemberFullTests extends RestTest restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteCollaborator)); restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMembers().assertThat().entriesListContains("id", usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteCollaborator).getUsername()) .when().getSiteMember(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteCollaborator).getUsername()) - .assertSiteMemberHasRole(Role.SiteCollaborator); + .assertSiteMemberHasRole(UserRole.SiteCollaborator); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) diff --git a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java index d4a4896b6..4eeb2abc6 100644 --- a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java @@ -20,7 +20,6 @@ package org.alfresco.rest.search; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.builder.NodesBuilder; -import org.alfresco.utility.Utility; import org.alfresco.utility.model.ContentModel; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FileType; diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteFullTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteFullTests.java index dff227d0d..574f29434 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteFullTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteFullTests.java @@ -4,6 +4,7 @@ import static org.hamcrest.CoreMatchers.equalTo; import java.util.List; +import org.alfresco.dataprep.SiteService.Visibility; import org.alfresco.rest.RestTest; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.core.RestResponse; @@ -21,7 +22,6 @@ 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.springframework.social.alfresco.api.entities.Site.Visibility; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; public class GetSiteFullTests extends RestTest @@ -35,7 +35,7 @@ public class GetSiteFullTests extends RestTest { adminUserModel = dataUser.getAdminUser(); testUser = dataUser.createRandomTestUser(); - restClient.authenticateUser(adminUserModel); + restClient.authenticateUser(adminUserModel); publicSite = dataSite.usingUser(adminUserModel).createPublicRandomSite(); } @@ -82,7 +82,7 @@ public class GetSiteFullTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newSite.getId())) .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); + .stackTraceIs(RestErrorModel.STACKTRACE); } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL } ) diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java index d59cbf27a..48928c61a 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java @@ -2,6 +2,7 @@ package org.alfresco.rest.sites; import java.util.List; +import org.alfresco.dataprep.SiteService.Visibility; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestSiteModel; @@ -14,7 +15,6 @@ 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.springframework.social.alfresco.api.entities.Site.Visibility; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSitesFullTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSitesFullTests.java index 6b2e1a768..b1ab58011 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSitesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSitesFullTests.java @@ -2,6 +2,7 @@ package org.alfresco.rest.sites; import java.util.List; +import org.alfresco.dataprep.SiteService.Visibility; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestSiteContainerModelsCollection; @@ -17,7 +18,6 @@ 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.springframework.social.alfresco.api.entities.Site.Visibility; import org.testng.annotations.AfterClass; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeClass; diff --git a/e2e-test/java/org/alfresco/rest/sites/members/GetSiteMembersFullTests.java b/e2e-test/java/org/alfresco/rest/sites/members/GetSiteMembersFullTests.java index 208903f1e..443ab28dc 100644 --- a/e2e-test/java/org/alfresco/rest/sites/members/GetSiteMembersFullTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/members/GetSiteMembersFullTests.java @@ -10,7 +10,6 @@ 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.springframework.social.alfresco.api.entities.Role; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -134,7 +133,7 @@ public class GetSiteMembersFullTests extends RestTest siteMembers = restClient.authenticateUser(userModel).withCoreAPI() .usingSite(moderatedSite2).getSiteMembers(); restClient.assertStatusCodeIs(HttpStatus.OK); - siteMembers.assertThat().entriesListContains("role", Role.SiteManager.toString()) + siteMembers.assertThat().entriesListContains("role", UserRole.SiteManager.toString()) .and().entriesListContains("id", userModel.getUsername()) .and().entriesListDoesNotContain("id", userNotJoined.getUsername()); } @@ -155,7 +154,7 @@ public class GetSiteMembersFullTests extends RestTest .usingSite(moderatedSite2).getSiteMembers(); restClient.assertStatusCodeIs(HttpStatus.OK); siteMembers.assertThat().entriesListCountIs(1) - .and().entriesListContains("role", Role.SiteManager.toString()) + .and().entriesListContains("role", UserRole.SiteManager.toString()) .and().entriesListContains("id", userModel.getUsername()); } } diff --git a/e2e-test/java/org/alfresco/rest/sites/membershipRequests/AddSiteMembershipRequestFullTests.java b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/AddSiteMembershipRequestFullTests.java index 616abf09c..3fca73cdf 100644 --- a/e2e-test/java/org/alfresco/rest/sites/membershipRequests/AddSiteMembershipRequestFullTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/AddSiteMembershipRequestFullTests.java @@ -1,5 +1,6 @@ package org.alfresco.rest.sites.membershipRequests; +import org.alfresco.dataprep.SiteService.Visibility; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestErrorModel; @@ -16,7 +17,6 @@ import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; -import org.springframework.social.alfresco.api.entities.Site; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -304,7 +304,7 @@ public class AddSiteMembershipRequestFullTests extends RestTest siteMembershipRequest.assertThat().field("id").is(moderatedThenPrivateSite.getId()) .assertThat().field("site").isNotEmpty(); - dataSite.usingUser(adminUser).updateSiteVisibility(moderatedThenPrivateSite, Site.Visibility.PRIVATE); + dataSite.usingUser(adminUser).updateSiteVisibility(moderatedThenPrivateSite, Visibility.PRIVATE); siteMembershipRequests = restClient.withCoreAPI().usingAuthUser().getSiteMembershipRequests(); restClient.assertStatusCodeIs(HttpStatus.OK); diff --git a/e2e-test/java/org/alfresco/rest/sites/membershipRequests/DeleteSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/DeleteSiteMembershipRequestSanityTests.java index ccd29cc72..2ff501e68 100644 --- a/e2e-test/java/org/alfresco/rest/sites/membershipRequests/DeleteSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/DeleteSiteMembershipRequestSanityTests.java @@ -1,5 +1,6 @@ package org.alfresco.rest.sites.membershipRequests; +import org.alfresco.dataprep.SiteService.Visibility; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestErrorModel; @@ -14,7 +15,6 @@ import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; -import org.springframework.social.alfresco.api.entities.Site.Visibility; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; diff --git a/e2e-test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestFullTests.java b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestFullTests.java index edc38a89e..f4c4102d7 100644 --- a/e2e-test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestFullTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestFullTests.java @@ -1,5 +1,6 @@ package org.alfresco.rest.sites.membershipRequests; +import org.alfresco.dataprep.SiteService.Visibility; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestErrorModel; @@ -14,7 +15,6 @@ import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; -import org.springframework.social.alfresco.api.entities.Site.Visibility; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; diff --git a/e2e-test/java/org/alfresco/rest/sites/membershipRequests/UpdateSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/UpdateSiteMembershipRequestSanityTests.java index a40a0b5e0..4027d8e48 100644 --- a/e2e-test/java/org/alfresco/rest/sites/membershipRequests/UpdateSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/UpdateSiteMembershipRequestSanityTests.java @@ -1,5 +1,6 @@ package org.alfresco.rest.sites.membershipRequests; +import org.alfresco.dataprep.SiteService.Visibility; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestErrorModel; @@ -13,7 +14,6 @@ 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.springframework.social.alfresco.api.entities.Site.Visibility; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; From 028a424ed5e70ae79574ea986c616a675d039bdf Mon Sep 17 00:00:00 2001 From: jcule Date: Wed, 28 Jun 2017 10:53:50 +0100 Subject: [PATCH 1165/1491] REPO-2590: Fix Deleted nodes pagination - add TAS-level test --- .../rest/trashcan/GetDeletedNodesTests.java | 91 +++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/trashcan/GetDeletedNodesTests.java diff --git a/e2e-test/java/org/alfresco/rest/trashcan/GetDeletedNodesTests.java b/e2e-test/java/org/alfresco/rest/trashcan/GetDeletedNodesTests.java new file mode 100644 index 000000000..c5fcffc4c --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/trashcan/GetDeletedNodesTests.java @@ -0,0 +1,91 @@ +/* + * Copyright (C) 2005-2017 Alfresco Software Limited. + * This file is part of Alfresco + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ + +package org.alfresco.rest.trashcan; + + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestNodeModelsCollection; +import org.alfresco.utility.exception.DataPreparationException; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; +import org.springframework.http.HttpStatus; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + + +/** + * Tests for /api-explorer/#!/trashcan/listDeletedNodes + * + * @author jcule + * + */ +public class GetDeletedNodesTests extends RestTest +{ + private UserModel adminUserModel; + private SiteModel deleteNodesSiteModel; + private FolderModel deleteNodesFolder1, deleteNodesFolder2, deleteNodesFolder3; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws DataPreparationException + { + adminUserModel = dataUser.getAdminUser(); + restClient.authenticateUser(adminUserModel); + deleteNodesSiteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + + } + + @AfterClass(alwaysRun=true) + public void cleanup() throws Exception + { + dataSite.usingAdmin().deleteSite(deleteNodesSiteModel); + } + + @Test + public void testDeletedNodesBiggerThanMaxCount() throws Exception + { + //get the number of item in the trashcan + RestNodeModelsCollection deletedNodes = restClient.withCoreAPI().usingQueries().findDeletedNodes(); + int count = deletedNodes.getPagination().getCount(); + int totalItems = deletedNodes.getPagination().getTotalItems(); + + //create folders + deleteNodesFolder1 = dataContent.usingUser(adminUserModel).usingSite(deleteNodesSiteModel).createFolder(); + deleteNodesFolder2 = dataContent.usingUser(adminUserModel).usingSite(deleteNodesSiteModel).createFolder(); + deleteNodesFolder3 = dataContent.usingUser(adminUserModel).usingSite(deleteNodesSiteModel).createFolder(); + + //delete folders + dataContent.usingUser(adminUserModel).usingResource(deleteNodesFolder1).deleteContent(); + dataContent.usingUser(adminUserModel).usingResource(deleteNodesFolder2).deleteContent(); + dataContent.usingUser(adminUserModel).usingResource(deleteNodesFolder3).deleteContent(); + + int maxItems = count + 1; + RestNodeModelsCollection deletedNodesMaxItem = restClient.withCoreAPI().usingQueries().usingParams(String.format("maxItems=%s", maxItems)).findDeletedNodes(); + + String countMaxItem = Integer.toString(maxItems); + String totalItemsMaxItem = Integer.toString(totalItems + 3); + String hasMoreItemsMaxItem = Boolean.toString(deletedNodesMaxItem.getPagination().isHasMoreItems()); + String skipCount = Integer.toString(deletedNodesMaxItem.getPagination().getSkipCount()); + + restClient.assertStatusCodeIs(HttpStatus.OK); + deletedNodesMaxItem.getPagination().assertThat().field("totalItems").is(totalItemsMaxItem).and().field("count").is(countMaxItem); + deletedNodesMaxItem.getPagination().assertThat().field("hasMoreItems").is(hasMoreItemsMaxItem).and().field("skipCount").is(skipCount); + + } + + +} From 806fcbf70000964160f28477e71d9f337ae48768 Mon Sep 17 00:00:00 2001 From: jcule Date: Wed, 28 Jun 2017 14:09:51 +0100 Subject: [PATCH 1166/1491] REPO-2117: Deleted nodes pagination returns incorrect properties - adding the test to the build --- .../org/alfresco/rest/trashcan/GetDeletedNodesTests.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/trashcan/GetDeletedNodesTests.java b/e2e-test/java/org/alfresco/rest/trashcan/GetDeletedNodesTests.java index 114e8d45f..09de17433 100644 --- a/e2e-test/java/org/alfresco/rest/trashcan/GetDeletedNodesTests.java +++ b/e2e-test/java/org/alfresco/rest/trashcan/GetDeletedNodesTests.java @@ -21,8 +21,8 @@ import org.alfresco.rest.model.RestNodeModelsCollection; import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; import org.springframework.http.HttpStatus; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; @@ -56,8 +56,7 @@ public class GetDeletedNodesTests extends RestTest dataSite.usingAdmin().deleteSite(deleteNodesSiteModel); } - @Bug(id = "REPO-2117") - @Test + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) public void testDeletedNodesBiggerThanMaxCount() throws Exception { //get the number of item in the trashcan From 384aa9f2c0eca2db9869b4568e8eedd57476b294 Mon Sep 17 00:00:00 2001 From: jcule Date: Wed, 28 Jun 2017 17:34:09 +0100 Subject: [PATCH 1167/1491] REPO-2117: Deleted nodes pagination returns incorrect properties - adding the test to the build --- .../java/org/alfresco/rest/trashcan/GetDeletedNodesTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/trashcan/GetDeletedNodesTests.java b/e2e-test/java/org/alfresco/rest/trashcan/GetDeletedNodesTests.java index 09de17433..69e5f406e 100644 --- a/e2e-test/java/org/alfresco/rest/trashcan/GetDeletedNodesTests.java +++ b/e2e-test/java/org/alfresco/rest/trashcan/GetDeletedNodesTests.java @@ -56,7 +56,7 @@ public class GetDeletedNodesTests extends RestTest dataSite.usingAdmin().deleteSite(deleteNodesSiteModel); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @Test(groups = { TestGroup.FULL }) public void testDeletedNodesBiggerThanMaxCount() throws Exception { //get the number of item in the trashcan From ae9b0b5b83cfd2b294330aa2b7c1f82927a83946 Mon Sep 17 00:00:00 2001 From: jcule Date: Wed, 28 Jun 2017 21:05:26 +0100 Subject: [PATCH 1168/1491] REPO-2117: Deleted nodes pagination returns incorrect properties - adding the test to the build --- .../java/org/alfresco/rest/trashcan/GetDeletedNodesTests.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/trashcan/GetDeletedNodesTests.java b/e2e-test/java/org/alfresco/rest/trashcan/GetDeletedNodesTests.java index 69e5f406e..5a9b64e1e 100644 --- a/e2e-test/java/org/alfresco/rest/trashcan/GetDeletedNodesTests.java +++ b/e2e-test/java/org/alfresco/rest/trashcan/GetDeletedNodesTests.java @@ -60,7 +60,7 @@ public class GetDeletedNodesTests extends RestTest public void testDeletedNodesBiggerThanMaxCount() throws Exception { //get the number of item in the trashcan - RestNodeModelsCollection deletedNodes = restClient.withCoreAPI().usingQueries().findDeletedNodes(); + RestNodeModelsCollection deletedNodes = restClient.withCoreAPI().usingTrashcan().findDeletedNodes(); int count = deletedNodes.getPagination().getCount(); int totalItems = deletedNodes.getPagination().getTotalItems(); @@ -75,7 +75,7 @@ public class GetDeletedNodesTests extends RestTest dataContent.usingUser(adminUserModel).usingResource(deleteNodesFolder3).deleteContent(); int maxItems = count + 1; - RestNodeModelsCollection deletedNodesMaxItem = restClient.withCoreAPI().usingQueries().usingParams(String.format("maxItems=%s", maxItems)).findDeletedNodes(); + RestNodeModelsCollection deletedNodesMaxItem = restClient.withCoreAPI().usingTrashcan().usingParams(String.format("maxItems=%s", maxItems)).findDeletedNodes(); String countMaxItem = Integer.toString(maxItems); String totalItemsMaxItem = Integer.toString(totalItems + 3); From 2df339791a9ae181e5ffeb392b31aa9cd4c716dd Mon Sep 17 00:00:00 2001 From: jcule Date: Thu, 29 Jun 2017 22:51:06 +0100 Subject: [PATCH 1169/1491] REPO-2586: REST API: Retrieve Audit Application info - add TAS-level test --- .../org/alfresco/rest/audit/DeleteAuditCoreTests.java | 8 ++++++++ .../java/org/alfresco/rest/audit/GetAuditCoreTests.java | 8 ++++++++ .../java/org/alfresco/rest/audit/PutAuditCoreTests.java | 8 ++++++++ 3 files changed, 24 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/audit/DeleteAuditCoreTests.java create mode 100644 e2e-test/java/org/alfresco/rest/audit/GetAuditCoreTests.java create mode 100644 e2e-test/java/org/alfresco/rest/audit/PutAuditCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/audit/DeleteAuditCoreTests.java b/e2e-test/java/org/alfresco/rest/audit/DeleteAuditCoreTests.java new file mode 100644 index 000000000..42340b0a6 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/audit/DeleteAuditCoreTests.java @@ -0,0 +1,8 @@ +package org.alfresco.rest.audit; + +import org.alfresco.rest.RestTest; + +public class DeleteAuditCoreTests extends RestTest +{ + +} diff --git a/e2e-test/java/org/alfresco/rest/audit/GetAuditCoreTests.java b/e2e-test/java/org/alfresco/rest/audit/GetAuditCoreTests.java new file mode 100644 index 000000000..9c1025810 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/audit/GetAuditCoreTests.java @@ -0,0 +1,8 @@ +package org.alfresco.rest.audit; + +import org.alfresco.rest.RestTest; + +public class GetAuditCoreTests extends RestTest +{ + +} diff --git a/e2e-test/java/org/alfresco/rest/audit/PutAuditCoreTests.java b/e2e-test/java/org/alfresco/rest/audit/PutAuditCoreTests.java new file mode 100644 index 000000000..9c620497a --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/audit/PutAuditCoreTests.java @@ -0,0 +1,8 @@ +package org.alfresco.rest.audit; + +import org.alfresco.rest.RestTest; + +public class PutAuditCoreTests extends RestTest +{ + +} From 83d44e474c171b60d350054cfff3fe581fa0014a Mon Sep 17 00:00:00 2001 From: Alexandru-Eusebiu Epure Date: Mon, 3 Jul 2017 15:24:47 +0300 Subject: [PATCH 1170/1491] REPO-2582 Retrieve Audit Applications - add TAS-level test Add core tests for Retrieve Audit Applications. Creat AuditTest abstract class for the dataprep, and validate if the audit is enabled. --- .../org/alfresco/rest/audit/AuditTest.java | 36 ++++++ .../rest/audit/DeleteAuditCoreTests.java | 4 +- .../rest/audit/GetAuditCoreTests.java | 116 +++++++++++++++++- .../rest/audit/PutAuditCoreTests.java | 4 +- 4 files changed, 152 insertions(+), 8 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/audit/AuditTest.java diff --git a/e2e-test/java/org/alfresco/rest/audit/AuditTest.java b/e2e-test/java/org/alfresco/rest/audit/AuditTest.java new file mode 100644 index 000000000..deefac86f --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/audit/AuditTest.java @@ -0,0 +1,36 @@ +package org.alfresco.rest.audit; + +import static org.hamcrest.Matchers.is; + +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.RestAuditAppModelsCollection; +import org.alfresco.utility.model.UserModel; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpMethod; +import org.testng.annotations.BeforeClass; + +import com.jayway.restassured.RestAssured; + +public abstract class AuditTest extends RestTest +{ + + @Autowired + protected RestWrapper restAPI; + + protected UserModel userModel; + protected RestAuditAppModelsCollection restAuditCollection; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + RestAssured.basePath = ""; + restAPI.configureRequestSpec().setBasePath(RestAssured.basePath); + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "alfresco/service/api/audit/control"); + RestResponse response = restAPI.authenticateUser(dataUser.getAdminUser()).process(request); + response.assertThat().body("enabled", is(true)); + } +} diff --git a/e2e-test/java/org/alfresco/rest/audit/DeleteAuditCoreTests.java b/e2e-test/java/org/alfresco/rest/audit/DeleteAuditCoreTests.java index 42340b0a6..31aa73f1c 100644 --- a/e2e-test/java/org/alfresco/rest/audit/DeleteAuditCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/audit/DeleteAuditCoreTests.java @@ -1,8 +1,6 @@ package org.alfresco.rest.audit; -import org.alfresco.rest.RestTest; - -public class DeleteAuditCoreTests extends RestTest +public class DeleteAuditCoreTests extends AuditTest { } diff --git a/e2e-test/java/org/alfresco/rest/audit/GetAuditCoreTests.java b/e2e-test/java/org/alfresco/rest/audit/GetAuditCoreTests.java index 9c1025810..ca477df5f 100644 --- a/e2e-test/java/org/alfresco/rest/audit/GetAuditCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/audit/GetAuditCoreTests.java @@ -1,8 +1,120 @@ package org.alfresco.rest.audit; -import org.alfresco.rest.RestTest; +import static org.testng.Assert.assertEquals; -public class GetAuditCoreTests extends RestTest +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; + +public class GetAuditCoreTests extends AuditTest { + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if the admin user gets a list of audit applications and status code is 200") + public void getAuditApplicationsWithAdminUser() throws Exception + { + restAuditCollection = restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingAudit() + .getAuditApplications(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restAuditCollection.assertThat().entriesListIsNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify a normal user gets a list of audit applications and status code is 403") + public void getAuditApplicationsWithNormalUser() throws Exception + { + restAuditCollection = restClient.authenticateUser(userModel).withCoreAPI().usingAudit().getAuditApplications(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + restAuditCollection.assertThat().entriesListIsEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if the admin user gets a list of audit applications using skipCount and status code is 200") + public void getAuditApplicationsWithAdminUserUsingValidSkipCount() throws Exception + { + restAuditCollection = restClient.authenticateUser(dataUser.getAdminUser()).withParams("skipCount=1").withCoreAPI() + .usingAudit().getAuditApplications(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restAuditCollection.getPagination().assertThat().field("totalItems").isNotNull().and().field("totalItems") + .isGreaterThan(0).and().field("skipCount").is("1"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if the admin user gets a list of audit applications using invalid skipCount and status code is 403") + public void getAuditApplicationsWithAdminUserUsingInvalidSkipCount() throws Exception + { + restClient.authenticateUser(dataUser.getAdminUser()).withParams("skipCount=-1").withCoreAPI().usingAudit() + .getAuditApplications(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if the admin user gets a list of audit applications using maxItems and status code is 200") + public void getAuditApplicationsWithAdminUserUsingValidMaxItems() throws Exception + { + restAuditCollection = restClient.authenticateUser(dataUser.getAdminUser()).withParams("maxItems=1").withCoreAPI() + .usingAudit().getAuditApplications(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restAuditCollection.getPagination().assertThat().field("totalItems").isNotNull().and().field("totalItems") + .isGreaterThan(0).and().field("maxItems").is("1"); + assertEquals(restAuditCollection.getEntries().size(), 1); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if the admin user gets a list of audit applications using invalid maxItems and status code is 403") + public void getAuditApplicationsWithAdminUserUsingInvalidMaxItems() throws Exception + { + restClient.authenticateUser(dataUser.getAdminUser()).withParams("maxItems=-1").withCoreAPI().usingAudit() + .getAuditApplications(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + + restClient.authenticateUser(dataUser.getAdminUser()).withParams("maxItems=0").withCoreAPI().usingAudit() + .getAuditApplications(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + + } + + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if the admin user gets a list of audit applications using skipCount and maxItems and status code is 200") + public void getAuditApplicationsWithAdminUserUsingValidSkipCountAndMaxItems() throws Exception + { + restAuditCollection = restClient.authenticateUser(dataUser.getAdminUser()).withParams("skipCount=1&maxItems=1") + .withCoreAPI().usingAudit().getAuditApplications(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restAuditCollection.getPagination().assertThat().field("totalItems").isNotNull().and().field("totalItems") + .isGreaterThan(0).and().field("maxItems").is("1").and().field("skipCount").is("1"); + assertEquals(restAuditCollection.getEntries().size(), 1); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if the admin user gets a list of audit applications using invalid skipCount and/or invalid maxItems and status code is 403") + public void getAuditApplicationsWithAdminUserUsingInvalidSkipCountAndMaxItems() throws Exception + { + restClient.authenticateUser(dataUser.getAdminUser()).withParams("skipCount=-1&maxItems=1").withCoreAPI().usingAudit() + .getAuditApplications(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + + restClient.authenticateUser(dataUser.getAdminUser()).withParams("skipCount=-1&maxItems=-1").withCoreAPI().usingAudit() + .getAuditApplications(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + + restClient.authenticateUser(dataUser.getAdminUser()).withParams("skipCount=-1&maxItems=0").withCoreAPI().usingAudit() + .getAuditApplications(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + + restClient.authenticateUser(dataUser.getAdminUser()).withParams("skipCount=1&maxItems=-1").withCoreAPI().usingAudit() + .getAuditApplications(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + } + } diff --git a/e2e-test/java/org/alfresco/rest/audit/PutAuditCoreTests.java b/e2e-test/java/org/alfresco/rest/audit/PutAuditCoreTests.java index 9c620497a..efdbbedda 100644 --- a/e2e-test/java/org/alfresco/rest/audit/PutAuditCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/audit/PutAuditCoreTests.java @@ -1,8 +1,6 @@ package org.alfresco.rest.audit; -import org.alfresco.rest.RestTest; - -public class PutAuditCoreTests extends RestTest +public class PutAuditCoreTests extends AuditTest { } From a5b080c3578bb65b87be075c7ea835ef776c4bd2 Mon Sep 17 00:00:00 2001 From: jcule Date: Mon, 3 Jul 2017 23:16:54 +0100 Subject: [PATCH 1171/1491] REPO-2586: REST API: Retrieve Audit Application info - add TAS-level test --- .../rest/audit/GetAuditCoreTests.java | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/audit/GetAuditCoreTests.java b/e2e-test/java/org/alfresco/rest/audit/GetAuditCoreTests.java index ca477df5f..e31186544 100644 --- a/e2e-test/java/org/alfresco/rest/audit/GetAuditCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/audit/GetAuditCoreTests.java @@ -2,6 +2,7 @@ package org.alfresco.rest.audit; import static org.testng.Assert.assertEquals; +import org.alfresco.rest.model.RestAuditAppModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; @@ -21,6 +22,45 @@ public class GetAuditCoreTests extends AuditTest restClient.assertStatusCodeIs(HttpStatus.OK); restAuditCollection.assertThat().entriesListIsNotEmpty(); } + + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if the admin user gets audit application info") + public void getAuditApplicationInfoWithAdminUser() throws Exception + { + restAuditCollection = restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingAudit().getAuditApplications(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restAuditCollection.assertThat().entriesListIsNotEmpty(); + + RestAuditAppModel firstRestAuditAppModel = restAuditCollection.getEntries().get(0).onModel(); + firstRestAuditAppModel.assertThat().field("isEnabled").is(true); + firstRestAuditAppModel.assertThat().field("name").is("Alfresco Sync Service"); + firstRestAuditAppModel.assertThat().field("id").is("sync"); + + restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingAudit() + .getAuditApp(firstRestAuditAppModel).assertThat().field("isEnabled").is(true); + + restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingAudit() + .getAuditApp(firstRestAuditAppModel).assertThat().field("name").is("Alfresco Sync Service"); + + restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingAudit() + .getAuditApp(firstRestAuditAppModel).assertThat().field("id").is("sync"); + + RestAuditAppModel secondRestAuditAppModel = restAuditCollection.getEntries().get(1).onModel(); + secondRestAuditAppModel.assertThat().field("isEnabled").is(true); + secondRestAuditAppModel.assertThat().field("name").is("Alfresco Tagging Service"); + secondRestAuditAppModel.assertThat().field("id").is("tagging"); + + restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingAudit() + .getAuditApp(secondRestAuditAppModel).assertThat().field("isEnabled").is(true); + + restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingAudit() + .getAuditApp(secondRestAuditAppModel).assertThat().field("name").is("Alfresco Tagging Service"); + + restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingAudit() + .getAuditApp(secondRestAuditAppModel).assertThat().field("id").is("tagging"); + + } @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) @TestRail(section = { TestGroup.REST_API, From 6b84a9d7e214c0a586759b52aab97989d516b5c3 Mon Sep 17 00:00:00 2001 From: Alexandru-Eusebiu Epure Date: Tue, 4 Jul 2017 11:45:11 +0300 Subject: [PATCH 1172/1491] REPO-2582 Retrieve Audit Applications - add TAS-level test Correct test description(error code from 403 to 400), removed the optional parameter from getAuditApplication, removed extra spaces and tabs from RestAuditAppModel.java REPO-2620 REST API: Retrieve Application Audit Entries - add TAS-level test Add AuditEntryModel and AuditEntryModelsCollection(a list of AuditEntryModel), and add listAuditEntriesForAnAuditApplication call --- .../java/org/alfresco/rest/audit/GetAuditCoreTests.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/audit/GetAuditCoreTests.java b/e2e-test/java/org/alfresco/rest/audit/GetAuditCoreTests.java index ca477df5f..ce652f556 100644 --- a/e2e-test/java/org/alfresco/rest/audit/GetAuditCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/audit/GetAuditCoreTests.java @@ -46,7 +46,7 @@ public class GetAuditCoreTests extends AuditTest @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) @TestRail(section = { TestGroup.REST_API, - TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if the admin user gets a list of audit applications using invalid skipCount and status code is 403") + TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if the admin user gets a list of audit applications using invalid skipCount and status code is 400") public void getAuditApplicationsWithAdminUserUsingInvalidSkipCount() throws Exception { restClient.authenticateUser(dataUser.getAdminUser()).withParams("skipCount=-1").withCoreAPI().usingAudit() @@ -69,7 +69,7 @@ public class GetAuditCoreTests extends AuditTest @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) @TestRail(section = { TestGroup.REST_API, - TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if the admin user gets a list of audit applications using invalid maxItems and status code is 403") + TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if the admin user gets a list of audit applications using invalid maxItems and status code is 400") public void getAuditApplicationsWithAdminUserUsingInvalidMaxItems() throws Exception { restClient.authenticateUser(dataUser.getAdminUser()).withParams("maxItems=-1").withCoreAPI().usingAudit() @@ -97,7 +97,7 @@ public class GetAuditCoreTests extends AuditTest @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) @TestRail(section = { TestGroup.REST_API, - TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if the admin user gets a list of audit applications using invalid skipCount and/or invalid maxItems and status code is 403") + TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if the admin user gets a list of audit applications using invalid skipCount and/or invalid maxItems and status code is 400") public void getAuditApplicationsWithAdminUserUsingInvalidSkipCountAndMaxItems() throws Exception { restClient.authenticateUser(dataUser.getAdminUser()).withParams("skipCount=-1&maxItems=1").withCoreAPI().usingAudit() From 5b999a1f39a1ac78345edf77558bec337bdac4e1 Mon Sep 17 00:00:00 2001 From: jcule Date: Thu, 6 Jul 2017 21:18:27 +0100 Subject: [PATCH 1173/1491] REPO-2632: REST-API: Enable/Disable Application Auditing - add TAS level test --- .../org/alfresco/rest/audit/AuditTest.java | 24 +++++ .../rest/audit/GetAuditCoreTests.java | 42 ++------ .../rest/audit/PutAuditCoreTests.java | 97 +++++++++++++++++++ 3 files changed, 131 insertions(+), 32 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/audit/AuditTest.java b/e2e-test/java/org/alfresco/rest/audit/AuditTest.java index deefac86f..084b3c2ea 100644 --- a/e2e-test/java/org/alfresco/rest/audit/AuditTest.java +++ b/e2e-test/java/org/alfresco/rest/audit/AuditTest.java @@ -6,10 +6,12 @@ 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.RestAuditAppModel; import org.alfresco.rest.model.RestAuditAppModelsCollection; import org.alfresco.utility.model.UserModel; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import com.jayway.restassured.RestAssured; @@ -22,6 +24,9 @@ public abstract class AuditTest extends RestTest protected UserModel userModel; protected RestAuditAppModelsCollection restAuditCollection; + protected RestAuditAppModel syncRestAuditAppModel; + protected RestAuditAppModel taggingRestAuditAppModel; + @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception @@ -33,4 +38,23 @@ public abstract class AuditTest extends RestTest RestResponse response = restAPI.authenticateUser(dataUser.getAdminUser()).process(request); response.assertThat().body("enabled", is(true)); } + + protected RestAuditAppModel getSyncRestAuditAppModel(UserModel userModel) throws Exception + { + restAuditCollection = restClient.authenticateUser(userModel).withCoreAPI().usingAudit().getAuditApplications(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restAuditCollection.assertThat().entriesListIsNotEmpty(); + RestAuditAppModel syncRestAuditAppModel = restAuditCollection.getEntries().get(0).onModel(); + return syncRestAuditAppModel; + } + + protected RestAuditAppModel getTaggingRestAuditAppModel(UserModel userModel) throws Exception + { + restAuditCollection = restClient.authenticateUser(userModel).withCoreAPI().usingAudit().getAuditApplications(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restAuditCollection.assertThat().entriesListIsNotEmpty(); + RestAuditAppModel taggingRestAuditAppModel = restAuditCollection.getEntries().get(1).onModel(); + return taggingRestAuditAppModel; + } + } diff --git a/e2e-test/java/org/alfresco/rest/audit/GetAuditCoreTests.java b/e2e-test/java/org/alfresco/rest/audit/GetAuditCoreTests.java index 6c765deb0..a9ff76cf1 100644 --- a/e2e-test/java/org/alfresco/rest/audit/GetAuditCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/audit/GetAuditCoreTests.java @@ -2,7 +2,7 @@ package org.alfresco.rest.audit; import static org.testng.Assert.assertEquals; -import org.alfresco.rest.model.RestAuditAppModel; + import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; @@ -25,40 +25,18 @@ public class GetAuditCoreTests extends AuditTest @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) @TestRail(section = { TestGroup.REST_API, - TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if the admin user gets audit application info") + TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify that the admin user can get audit application info") public void getAuditApplicationInfoWithAdminUser() throws Exception { - restAuditCollection = restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingAudit().getAuditApplications(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restAuditCollection.assertThat().entriesListIsNotEmpty(); - - RestAuditAppModel firstRestAuditAppModel = restAuditCollection.getEntries().get(0).onModel(); - firstRestAuditAppModel.assertThat().field("isEnabled").is(true); - firstRestAuditAppModel.assertThat().field("name").is("Alfresco Sync Service"); - firstRestAuditAppModel.assertThat().field("id").is("sync"); + syncRestAuditAppModel = getSyncRestAuditAppModel(dataUser.getAdminUser()); + syncRestAuditAppModel.assertThat().field("isEnabled").is(true); + syncRestAuditAppModel.assertThat().field("name").is("Alfresco Sync Service"); + syncRestAuditAppModel.assertThat().field("id").is("sync"); - restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingAudit() - .getAuditApp(firstRestAuditAppModel).assertThat().field("isEnabled").is(true); - - restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingAudit() - .getAuditApp(firstRestAuditAppModel).assertThat().field("name").is("Alfresco Sync Service"); - - restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingAudit() - .getAuditApp(firstRestAuditAppModel).assertThat().field("id").is("sync"); - - RestAuditAppModel secondRestAuditAppModel = restAuditCollection.getEntries().get(1).onModel(); - secondRestAuditAppModel.assertThat().field("isEnabled").is(true); - secondRestAuditAppModel.assertThat().field("name").is("Alfresco Tagging Service"); - secondRestAuditAppModel.assertThat().field("id").is("tagging"); - - restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingAudit() - .getAuditApp(secondRestAuditAppModel).assertThat().field("isEnabled").is(true); - - restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingAudit() - .getAuditApp(secondRestAuditAppModel).assertThat().field("name").is("Alfresco Tagging Service"); - - restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingAudit() - .getAuditApp(secondRestAuditAppModel).assertThat().field("id").is("tagging"); + taggingRestAuditAppModel = getTaggingRestAuditAppModel(dataUser.getAdminUser()); + taggingRestAuditAppModel.assertThat().field("isEnabled").is(true); + taggingRestAuditAppModel.assertThat().field("name").is("Alfresco Tagging Service"); + taggingRestAuditAppModel.assertThat().field("id").is("tagging"); } diff --git a/e2e-test/java/org/alfresco/rest/audit/PutAuditCoreTests.java b/e2e-test/java/org/alfresco/rest/audit/PutAuditCoreTests.java index efdbbedda..05a28bf2f 100644 --- a/e2e-test/java/org/alfresco/rest/audit/PutAuditCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/audit/PutAuditCoreTests.java @@ -1,6 +1,103 @@ package org.alfresco.rest.audit; +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; + public class PutAuditCoreTests extends AuditTest { + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify that the admin user can enable/disable sync application auditing") + public void enableDisableSyncApplicationAuditingAsAdminUser() throws Exception + { + //disable sync audit app + syncRestAuditAppModel = getSyncRestAuditAppModel(dataUser.getAdminUser()); + restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingAudit().updateAuditApp(syncRestAuditAppModel, "isEnabled", "false"); + + //check isEnabled=false + syncRestAuditAppModel = getSyncRestAuditAppModel(dataUser.getAdminUser()); + syncRestAuditAppModel.assertThat().field("isEnabled").is(false); + syncRestAuditAppModel.assertThat().field("name").is("Alfresco Sync Service"); + syncRestAuditAppModel.assertThat().field("id").is("sync"); + + //enable sync audit app + restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingAudit().updateAuditApp(syncRestAuditAppModel, "isEnabled", "true"); + + //check isEnabled=true + syncRestAuditAppModel = getSyncRestAuditAppModel(dataUser.getAdminUser()); + syncRestAuditAppModel.assertThat().field("isEnabled").is(true); + syncRestAuditAppModel.assertThat().field("name").is("Alfresco Sync Service"); + syncRestAuditAppModel.assertThat().field("id").is("sync"); + + } + + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify that the admin user can enable/disable tagging application auditing") + public void enableDisableTaggingApplicationAuditingAsAdminUser() throws Exception + { + //disable tagging audit app + taggingRestAuditAppModel = getTaggingRestAuditAppModel(dataUser.getAdminUser()); + restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingAudit().updateAuditApp(taggingRestAuditAppModel, "isEnabled", "false"); + + //check isEnabled=false + taggingRestAuditAppModel = getTaggingRestAuditAppModel(dataUser.getAdminUser()); + taggingRestAuditAppModel.assertThat().field("isEnabled").is(false); + taggingRestAuditAppModel.assertThat().field("name").is("Alfresco Tagging Service"); + taggingRestAuditAppModel.assertThat().field("id").is("tagging"); + + //enable tagging audit app + restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingAudit().updateAuditApp(taggingRestAuditAppModel, "isEnabled", "true"); + + //check isEnabled=true + taggingRestAuditAppModel = getTaggingRestAuditAppModel(dataUser.getAdminUser()); + taggingRestAuditAppModel.assertThat().field("isEnabled").is(true); + taggingRestAuditAppModel.assertThat().field("name").is("Alfresco Tagging Service"); + taggingRestAuditAppModel.assertThat().field("id").is("tagging"); + + } + + + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify that the normal user can't enable/disable sync application auditing") + public void enableDisableSyncApplicationAuditingAsNormalUser() throws Exception + { + //disable sync audit app + syncRestAuditAppModel = getSyncRestAuditAppModel(dataUser.getAdminUser()); + restClient.authenticateUser(userModel).withCoreAPI().usingAudit().updateAuditApp(syncRestAuditAppModel, "isEnabled", "false"); + + //permission denied + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + + //enable sync audit app + restClient.authenticateUser(userModel).withCoreAPI().usingAudit().updateAuditApp(syncRestAuditAppModel, "isEnabled", "true"); + + //permission denied + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify that the normal user can't enable/disable tagging application auditing") + public void enableDisableTaggingApplicationAuditingAsNormalUser() throws Exception + { + //disable tagging audit app + taggingRestAuditAppModel = getTaggingRestAuditAppModel(dataUser.getAdminUser()); + restClient.authenticateUser(userModel).withCoreAPI().usingAudit().updateAuditApp(taggingRestAuditAppModel, "isEnabled", "false"); + + //permission denied + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + + //disable tagging audit app + restClient.authenticateUser(userModel).withCoreAPI().usingAudit().updateAuditApp(taggingRestAuditAppModel, "isEnabled", "true"); + + //permission denied + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + + } } From 3197eba6b53469a4d889bf1a701a1294d6b6c0f8 Mon Sep 17 00:00:00 2001 From: Alexandru-Eusebiu Epure Date: Thu, 13 Jul 2017 17:46:48 +0300 Subject: [PATCH 1174/1491] REPO-2620 REST API: Retrieve Application Audit Entries - add TAS-level test Extend TAS with AuditValuesModel in order to validate Retrieval of the Audit App Entries Add Sanity level TAS Tests. --- .../org/alfresco/rest/audit/AuditTest.java | 23 ++- .../rest/audit/GetAuditCoreTests.java | 146 +++++++++++++----- 2 files changed, 129 insertions(+), 40 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/audit/AuditTest.java b/e2e-test/java/org/alfresco/rest/audit/AuditTest.java index deefac86f..32fbce1f6 100644 --- a/e2e-test/java/org/alfresco/rest/audit/AuditTest.java +++ b/e2e-test/java/org/alfresco/rest/audit/AuditTest.java @@ -6,10 +6,14 @@ 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.RestAuditAppModel; import org.alfresco.rest.model.RestAuditAppModelsCollection; +import org.alfresco.rest.model.RestAuditEntryModel; +import org.alfresco.rest.model.RestAuditEntryModelsCollection; import org.alfresco.utility.model.UserModel; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import com.jayway.restassured.RestAssured; @@ -20,17 +24,34 @@ public abstract class AuditTest extends RestTest @Autowired protected RestWrapper restAPI; - protected UserModel userModel; + protected UserModel userModel,adminUser; protected RestAuditAppModelsCollection restAuditCollection; + protected RestAuditAppModel restAuditAppModel; + protected RestAuditEntryModel restAuditEntryModel; + protected RestAuditEntryModelsCollection restAuditEntryCollection; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception { + //Using two users, because audit API is designed for users with admin rights. userModel = dataUser.createRandomTestUser(); + adminUser=dataUser.getAdminUser(); + //GET /alfresco/service/api/audit/control to verify if Audit is enabled on the system. RestAssured.basePath = ""; restAPI.configureRequestSpec().setBasePath(RestAssured.basePath); RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "alfresco/service/api/audit/control"); RestResponse response = restAPI.authenticateUser(dataUser.getAdminUser()).process(request); response.assertThat().body("enabled", is(true)); + //GET /audit-applications and verify that there are audit applications in the system. + restAuditCollection = restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingAudit().getAuditApplications(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restAuditCollection.assertThat().entriesListIsNotEmpty(); + // + int i=0; + do + { + restAuditAppModel = restAuditCollection.getEntries().get(i++).onModel(); + }while (!restAuditAppModel.getName().equals("alfresco-access")); + } } diff --git a/e2e-test/java/org/alfresco/rest/audit/GetAuditCoreTests.java b/e2e-test/java/org/alfresco/rest/audit/GetAuditCoreTests.java index 6c765deb0..9c530d756 100644 --- a/e2e-test/java/org/alfresco/rest/audit/GetAuditCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/audit/GetAuditCoreTests.java @@ -1,6 +1,7 @@ package org.alfresco.rest.audit; import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; import org.alfresco.rest.model.RestAuditAppModel; import org.alfresco.utility.model.TestGroup; @@ -12,59 +13,43 @@ import org.testng.annotations.Test; public class GetAuditCoreTests extends AuditTest { - @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if the admin user gets a list of audit applications and status code is 200") - public void getAuditApplicationsWithAdminUser() throws Exception - { - restAuditCollection = restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingAudit() - .getAuditApplications(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restAuditCollection.assertThat().entriesListIsNotEmpty(); - } - @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) @TestRail(section = { TestGroup.REST_API, TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if the admin user gets audit application info") public void getAuditApplicationInfoWithAdminUser() throws Exception { - restAuditCollection = restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingAudit().getAuditApplications(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restAuditCollection.assertThat().entriesListIsNotEmpty(); - - RestAuditAppModel firstRestAuditAppModel = restAuditCollection.getEntries().get(0).onModel(); - firstRestAuditAppModel.assertThat().field("isEnabled").is(true); - firstRestAuditAppModel.assertThat().field("name").is("Alfresco Sync Service"); - firstRestAuditAppModel.assertThat().field("id").is("sync"); + restAuditAppModel.assertThat().field("isEnabled").is(true); + restAuditAppModel.assertThat().field("name").is("alfresco-access"); + restAuditAppModel.assertThat().field("id").is("alfresco-access"); - restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingAudit() - .getAuditApp(firstRestAuditAppModel).assertThat().field("isEnabled").is(true); + restClient.authenticateUser(adminUser).withCoreAPI().usingAudit() + .getAuditApp(restAuditAppModel).assertThat().field("isEnabled").is(true); - restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingAudit() - .getAuditApp(firstRestAuditAppModel).assertThat().field("name").is("Alfresco Sync Service"); + restClient.authenticateUser(adminUser).withCoreAPI().usingAudit() + .getAuditApp(restAuditAppModel).assertThat().field("name").is("alfresco-access"); - restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingAudit() - .getAuditApp(firstRestAuditAppModel).assertThat().field("id").is("sync"); + restClient.authenticateUser(adminUser).withCoreAPI().usingAudit() + .getAuditApp(restAuditAppModel).assertThat().field("id").is("alfresco-access"); RestAuditAppModel secondRestAuditAppModel = restAuditCollection.getEntries().get(1).onModel(); secondRestAuditAppModel.assertThat().field("isEnabled").is(true); secondRestAuditAppModel.assertThat().field("name").is("Alfresco Tagging Service"); secondRestAuditAppModel.assertThat().field("id").is("tagging"); - restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingAudit() + restClient.authenticateUser(adminUser).withCoreAPI().usingAudit() .getAuditApp(secondRestAuditAppModel).assertThat().field("isEnabled").is(true); - restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingAudit() + restClient.authenticateUser(adminUser).withCoreAPI().usingAudit() .getAuditApp(secondRestAuditAppModel).assertThat().field("name").is("Alfresco Tagging Service"); - restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingAudit() + restClient.authenticateUser(adminUser).withCoreAPI().usingAudit() .getAuditApp(secondRestAuditAppModel).assertThat().field("id").is("tagging"); } @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) @TestRail(section = { TestGroup.REST_API, - TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify a normal user gets a list of audit applications and status code is 403") + TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if a normal user gets a list of audit applications and status code is 403") public void getAuditApplicationsWithNormalUser() throws Exception { restAuditCollection = restClient.authenticateUser(userModel).withCoreAPI().usingAudit().getAuditApplications(); @@ -77,7 +62,7 @@ public class GetAuditCoreTests extends AuditTest TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if the admin user gets a list of audit applications using skipCount and status code is 200") public void getAuditApplicationsWithAdminUserUsingValidSkipCount() throws Exception { - restAuditCollection = restClient.authenticateUser(dataUser.getAdminUser()).withParams("skipCount=1").withCoreAPI() + restAuditCollection = restClient.authenticateUser(adminUser).withParams("skipCount=1").withCoreAPI() .usingAudit().getAuditApplications(); restClient.assertStatusCodeIs(HttpStatus.OK); restAuditCollection.getPagination().assertThat().field("totalItems").isNotNull().and().field("totalItems") @@ -89,7 +74,7 @@ public class GetAuditCoreTests extends AuditTest TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if the admin user gets a list of audit applications using invalid skipCount and status code is 400") public void getAuditApplicationsWithAdminUserUsingInvalidSkipCount() throws Exception { - restClient.authenticateUser(dataUser.getAdminUser()).withParams("skipCount=-1").withCoreAPI().usingAudit() + restClient.authenticateUser(adminUser).withParams("skipCount=-1").withCoreAPI().usingAudit() .getAuditApplications(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); } @@ -99,7 +84,7 @@ public class GetAuditCoreTests extends AuditTest TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if the admin user gets a list of audit applications using maxItems and status code is 200") public void getAuditApplicationsWithAdminUserUsingValidMaxItems() throws Exception { - restAuditCollection = restClient.authenticateUser(dataUser.getAdminUser()).withParams("maxItems=1").withCoreAPI() + restAuditCollection = restClient.authenticateUser(adminUser).withParams("maxItems=1").withCoreAPI() .usingAudit().getAuditApplications(); restClient.assertStatusCodeIs(HttpStatus.OK); restAuditCollection.getPagination().assertThat().field("totalItems").isNotNull().and().field("totalItems") @@ -112,11 +97,11 @@ public class GetAuditCoreTests extends AuditTest TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if the admin user gets a list of audit applications using invalid maxItems and status code is 400") public void getAuditApplicationsWithAdminUserUsingInvalidMaxItems() throws Exception { - restClient.authenticateUser(dataUser.getAdminUser()).withParams("maxItems=-1").withCoreAPI().usingAudit() + restClient.authenticateUser(adminUser).withParams("maxItems=-1").withCoreAPI().usingAudit() .getAuditApplications(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - restClient.authenticateUser(dataUser.getAdminUser()).withParams("maxItems=0").withCoreAPI().usingAudit() + restClient.authenticateUser(adminUser).withParams("maxItems=0").withCoreAPI().usingAudit() .getAuditApplications(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); @@ -127,7 +112,7 @@ public class GetAuditCoreTests extends AuditTest TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if the admin user gets a list of audit applications using skipCount and maxItems and status code is 200") public void getAuditApplicationsWithAdminUserUsingValidSkipCountAndMaxItems() throws Exception { - restAuditCollection = restClient.authenticateUser(dataUser.getAdminUser()).withParams("skipCount=1&maxItems=1") + restAuditCollection = restClient.authenticateUser(adminUser).withParams("skipCount=1&maxItems=1") .withCoreAPI().usingAudit().getAuditApplications(); restClient.assertStatusCodeIs(HttpStatus.OK); restAuditCollection.getPagination().assertThat().field("totalItems").isNotNull().and().field("totalItems") @@ -140,21 +125,104 @@ public class GetAuditCoreTests extends AuditTest TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if the admin user gets a list of audit applications using invalid skipCount and/or invalid maxItems and status code is 400") public void getAuditApplicationsWithAdminUserUsingInvalidSkipCountAndMaxItems() throws Exception { - restClient.authenticateUser(dataUser.getAdminUser()).withParams("skipCount=-1&maxItems=1").withCoreAPI().usingAudit() + restClient.authenticateUser(adminUser).withParams("skipCount=-1&maxItems=1").withCoreAPI().usingAudit() .getAuditApplications(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - restClient.authenticateUser(dataUser.getAdminUser()).withParams("skipCount=-1&maxItems=-1").withCoreAPI().usingAudit() + restClient.authenticateUser(adminUser).withParams("skipCount=-1&maxItems=-1").withCoreAPI().usingAudit() .getAuditApplications(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - restClient.authenticateUser(dataUser.getAdminUser()).withParams("skipCount=-1&maxItems=0").withCoreAPI().usingAudit() + restClient.authenticateUser(adminUser).withParams("skipCount=-1&maxItems=0").withCoreAPI().usingAudit() .getAuditApplications(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - restClient.authenticateUser(dataUser.getAdminUser()).withParams("skipCount=1&maxItems=-1").withCoreAPI().usingAudit() + restClient.authenticateUser(adminUser).withParams("skipCount=1&maxItems=-1").withCoreAPI().usingAudit() .getAuditApplications(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); } + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if a normal user gets a list of audit entries for audit application auditApplicationId and status code is 403") + public void getAuditEntriesWithNormalUser() throws Exception + { + restClient.authenticateUser(userModel).withCoreAPI().usingAudit() + .listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if the admin user gets a list of audit applications using invalid skipCount and/or invalid maxItems and status code is 400") + public void getAuditEntriesWithAdminUserUsingInvalidSkipCountAndMaxItems() throws Exception + { + restClient.authenticateUser(adminUser).withParams("skipCount=-1&maxItems=1").withCoreAPI().usingAudit() + .listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + + restClient.authenticateUser(adminUser).withParams("skipCount=-1&maxItems=-1").withCoreAPI().usingAudit() + .listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + + restClient.authenticateUser(adminUser).withParams("skipCount=-1&maxItems=0").withCoreAPI().usingAudit() + .listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + + restClient.authenticateUser(adminUser).withParams("skipCount=1&maxItems=-1").withCoreAPI().usingAudit() + .listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if the admin user gets a list of audit applications using valid skipCount and maxItems and status code is 200") + public void getAuditEntriesWithAdminUserUsingValidSkipCountAndMaxItems() throws Exception + { + restAuditEntryCollection = restClient.authenticateUser(adminUser).withParams("skipCount=1&maxItems=1") + .withCoreAPI().usingAudit().listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); + restClient.assertStatusCodeIs(HttpStatus.OK); + restAuditEntryCollection.getPagination().assertThat().field("totalItems").isNotNull().and().field("totalItems") + .isGreaterThan(0).and().field("maxItems").is("1").and().field("skipCount").is("1"); + assertEquals(restAuditEntryCollection.getEntries().size(), 1); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if the admin user gets a list of audit applications using orderBy and status code is 200") + public void getAuditEntriesWithAdminUserUsingOrderBy() throws Exception + { + restAuditEntryCollection = restClient.authenticateUser(adminUser).withParams("orderBy=createdAt ASC&maxItems=10") + .withCoreAPI().usingAudit().listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); + restClient.assertStatusCodeIs(HttpStatus.OK); + + String ascId = restAuditEntryCollection.getEntries().get(1).onModel().getId(); + + restAuditEntryCollection = restClient.authenticateUser(adminUser).withParams("orderBy=createdAt DESC&maxItems=10") + .withCoreAPI().usingAudit().listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); + restClient.assertStatusCodeIs(HttpStatus.OK); + + assertTrue(Integer.parseInt(restAuditEntryCollection.getEntries().get(1).onModel().getId()) > Integer.parseInt(ascId)); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if the admin user gets a list of audit applications using the where parameter to and status code is 200") + public void getAuditEntriesWithAdminUserUsingWhere() throws Exception + { + restAuditEntryCollection = restClient.authenticateUser(adminUser).withParams("maxItems=10").withCoreAPI().usingAudit().listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); + restClient.assertStatusCodeIs(HttpStatus.OK); + + String id1 = restAuditEntryCollection.getEntries().get(restAuditEntryCollection.getPagination().getCount()-1).onModel().getId(); + String id2 = restAuditEntryCollection.getEntries().get(restAuditEntryCollection.getPagination().getCount()/2).onModel().getId(); + + restAuditEntryCollection = restClient.authenticateUser(adminUser).withParams("where=(id BETWEEN ("+id2+","+id1+"))") + .withCoreAPI().usingAudit().listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); + restClient.assertStatusCodeIs(HttpStatus.OK); + + restAuditEntryCollection.assertThat().entriesListCountIs(Integer.parseInt(id1)-Integer.parseInt(id2)); + assertEquals(id2, restAuditEntryCollection.getEntries().get(0).onModel().getId()); + assertEquals(Integer.toString(Integer.parseInt(id1)-1), restAuditEntryCollection.getEntries().get(Integer.parseInt(id1)-Integer.parseInt(id2)-1).onModel().getId()); + + } } From b206af38e3fe40d131897dae95a11f1236506cc0 Mon Sep 17 00:00:00 2001 From: jcule Date: Fri, 14 Jul 2017 20:44:40 +0100 Subject: [PATCH 1175/1491] added checks for property setting, fixing merge fallouts and reusing code --- .../org/alfresco/rest/audit/AuditTest.java | 20 ++++++++--- .../rest/audit/GetAuditCoreTests.java | 33 ++++++------------- .../rest/audit/PutAuditCoreTests.java | 24 +++++++------- 3 files changed, 37 insertions(+), 40 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/audit/AuditTest.java b/e2e-test/java/org/alfresco/rest/audit/AuditTest.java index 52ea43b61..f99563c6d 100644 --- a/e2e-test/java/org/alfresco/rest/audit/AuditTest.java +++ b/e2e-test/java/org/alfresco/rest/audit/AuditTest.java @@ -11,11 +11,12 @@ import org.alfresco.rest.model.RestAuditAppModelsCollection; import org.alfresco.rest.model.RestAuditEntryModel; import org.alfresco.rest.model.RestAuditEntryModelsCollection; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.network.JmxBuilder; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; - +import org.testng.Assert; import com.jayway.restassured.RestAssured; public abstract class AuditTest extends RestTest @@ -24,6 +25,9 @@ public abstract class AuditTest extends RestTest @Autowired protected RestWrapper restAPI; + @Autowired + protected JmxBuilder jmxBuilder; + protected UserModel userModel,adminUser; protected RestAuditAppModelsCollection restAuditCollection; protected RestAuditAppModel restAuditAppModel; @@ -43,12 +47,18 @@ public abstract class AuditTest extends RestTest RestAssured.basePath = ""; restAPI.configureRequestSpec().setBasePath(RestAssured.basePath); RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "alfresco/service/api/audit/control"); - RestResponse response = restAPI.authenticateUser(dataUser.getAdminUser()).process(request); + RestResponse response = restAPI.authenticateUser(adminUser).process(request); response.assertThat().body("enabled", is(true)); //GET /audit-applications and verify that there are audit applications in the system. - restAuditCollection = restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingAudit().getAuditApplications(); + restAuditCollection = restClient.authenticateUser(adminUser).withCoreAPI().usingAudit().getAuditApplications(); restClient.assertStatusCodeIs(HttpStatus.OK); restAuditCollection.assertThat().entriesListIsNotEmpty(); + + //enable alfresco-access audit application + jmxBuilder.getJmxClient().writeProperty("Alfresco:Type=Configuration,Category=Audit,id1=default", "audit.alfresco-access.enabled", Boolean.TRUE.toString()); + String alfrescoAccessEnabled = jmxBuilder.getJmxClient().readProperty("Alfresco:Type=Configuration,Category=Audit,id1=default", "audit.alfresco-access.enabled").toString(); + Assert.assertEquals(alfrescoAccessEnabled, Boolean.TRUE.toString(), String.format("Property audit.alfresco-access.enabled is [%s]", alfrescoAccessEnabled)); + // int i=0; do @@ -64,7 +74,7 @@ public abstract class AuditTest extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); restAuditCollection.assertThat().entriesListIsNotEmpty(); RestAuditAppModel syncRestAuditAppModel = restAuditCollection.getEntries().get(0).onModel(); - return syncRestAuditAppModel; + return syncRestAuditAppModel; } protected RestAuditAppModel getTaggingRestAuditAppModel(UserModel userModel) throws Exception @@ -73,7 +83,7 @@ public abstract class AuditTest extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); restAuditCollection.assertThat().entriesListIsNotEmpty(); RestAuditAppModel taggingRestAuditAppModel = restAuditCollection.getEntries().get(1).onModel(); - return taggingRestAuditAppModel; + return taggingRestAuditAppModel; } } diff --git a/e2e-test/java/org/alfresco/rest/audit/GetAuditCoreTests.java b/e2e-test/java/org/alfresco/rest/audit/GetAuditCoreTests.java index e955bcbe9..a9acb7851 100644 --- a/e2e-test/java/org/alfresco/rest/audit/GetAuditCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/audit/GetAuditCoreTests.java @@ -21,30 +21,17 @@ public class GetAuditCoreTests extends AuditTest restAuditAppModel.assertThat().field("isEnabled").is(true); restAuditAppModel.assertThat().field("name").is("alfresco-access"); restAuditAppModel.assertThat().field("id").is("alfresco-access"); + + syncRestAuditAppModel = getSyncRestAuditAppModel(adminUser); + syncRestAuditAppModel.assertThat().field("isEnabled").is(true); + syncRestAuditAppModel.assertThat().field("name").is("Alfresco Sync Service"); + syncRestAuditAppModel.assertThat().field("id").is("sync"); - restClient.authenticateUser(adminUser).withCoreAPI().usingAudit() - .getAuditApp(restAuditAppModel).assertThat().field("isEnabled").is(true); - - restClient.authenticateUser(adminUser).withCoreAPI().usingAudit() - .getAuditApp(restAuditAppModel).assertThat().field("name").is("alfresco-access"); - - restClient.authenticateUser(adminUser).withCoreAPI().usingAudit() - .getAuditApp(restAuditAppModel).assertThat().field("id").is("alfresco-access"); - - RestAuditAppModel secondRestAuditAppModel = restAuditCollection.getEntries().get(1).onModel(); - secondRestAuditAppModel.assertThat().field("isEnabled").is(true); - secondRestAuditAppModel.assertThat().field("name").is("Alfresco Tagging Service"); - secondRestAuditAppModel.assertThat().field("id").is("tagging"); - - restClient.authenticateUser(adminUser).withCoreAPI().usingAudit() - .getAuditApp(secondRestAuditAppModel).assertThat().field("isEnabled").is(true); - - restClient.authenticateUser(adminUser).withCoreAPI().usingAudit() - .getAuditApp(secondRestAuditAppModel).assertThat().field("name").is("Alfresco Tagging Service"); - - restClient.authenticateUser(adminUser).withCoreAPI().usingAudit() - .getAuditApp(secondRestAuditAppModel).assertThat().field("id").is("tagging"); - + taggingRestAuditAppModel = getTaggingRestAuditAppModel(adminUser); + taggingRestAuditAppModel.assertThat().field("isEnabled").is(true); + taggingRestAuditAppModel.assertThat().field("name").is("Alfresco Tagging Service"); + taggingRestAuditAppModel.assertThat().field("id").is("tagging"); + } @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) diff --git a/e2e-test/java/org/alfresco/rest/audit/PutAuditCoreTests.java b/e2e-test/java/org/alfresco/rest/audit/PutAuditCoreTests.java index 05a28bf2f..3f97f2f75 100644 --- a/e2e-test/java/org/alfresco/rest/audit/PutAuditCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/audit/PutAuditCoreTests.java @@ -14,20 +14,20 @@ public class PutAuditCoreTests extends AuditTest public void enableDisableSyncApplicationAuditingAsAdminUser() throws Exception { //disable sync audit app - syncRestAuditAppModel = getSyncRestAuditAppModel(dataUser.getAdminUser()); - restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingAudit().updateAuditApp(syncRestAuditAppModel, "isEnabled", "false"); + syncRestAuditAppModel = getSyncRestAuditAppModel(adminUser); + restClient.authenticateUser(adminUser).withCoreAPI().usingAudit().updateAuditApp(syncRestAuditAppModel, "isEnabled", "false"); //check isEnabled=false - syncRestAuditAppModel = getSyncRestAuditAppModel(dataUser.getAdminUser()); + syncRestAuditAppModel = getSyncRestAuditAppModel(adminUser); syncRestAuditAppModel.assertThat().field("isEnabled").is(false); syncRestAuditAppModel.assertThat().field("name").is("Alfresco Sync Service"); syncRestAuditAppModel.assertThat().field("id").is("sync"); //enable sync audit app - restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingAudit().updateAuditApp(syncRestAuditAppModel, "isEnabled", "true"); + restClient.authenticateUser(adminUser).withCoreAPI().usingAudit().updateAuditApp(syncRestAuditAppModel, "isEnabled", "true"); //check isEnabled=true - syncRestAuditAppModel = getSyncRestAuditAppModel(dataUser.getAdminUser()); + syncRestAuditAppModel = getSyncRestAuditAppModel(adminUser); syncRestAuditAppModel.assertThat().field("isEnabled").is(true); syncRestAuditAppModel.assertThat().field("name").is("Alfresco Sync Service"); syncRestAuditAppModel.assertThat().field("id").is("sync"); @@ -40,20 +40,20 @@ public class PutAuditCoreTests extends AuditTest public void enableDisableTaggingApplicationAuditingAsAdminUser() throws Exception { //disable tagging audit app - taggingRestAuditAppModel = getTaggingRestAuditAppModel(dataUser.getAdminUser()); - restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingAudit().updateAuditApp(taggingRestAuditAppModel, "isEnabled", "false"); + taggingRestAuditAppModel = getTaggingRestAuditAppModel(adminUser); + restClient.authenticateUser(adminUser).withCoreAPI().usingAudit().updateAuditApp(taggingRestAuditAppModel, "isEnabled", "false"); //check isEnabled=false - taggingRestAuditAppModel = getTaggingRestAuditAppModel(dataUser.getAdminUser()); + taggingRestAuditAppModel = getTaggingRestAuditAppModel(adminUser); taggingRestAuditAppModel.assertThat().field("isEnabled").is(false); taggingRestAuditAppModel.assertThat().field("name").is("Alfresco Tagging Service"); taggingRestAuditAppModel.assertThat().field("id").is("tagging"); //enable tagging audit app - restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingAudit().updateAuditApp(taggingRestAuditAppModel, "isEnabled", "true"); + restClient.authenticateUser(adminUser).withCoreAPI().usingAudit().updateAuditApp(taggingRestAuditAppModel, "isEnabled", "true"); //check isEnabled=true - taggingRestAuditAppModel = getTaggingRestAuditAppModel(dataUser.getAdminUser()); + taggingRestAuditAppModel = getTaggingRestAuditAppModel(adminUser); taggingRestAuditAppModel.assertThat().field("isEnabled").is(true); taggingRestAuditAppModel.assertThat().field("name").is("Alfresco Tagging Service"); taggingRestAuditAppModel.assertThat().field("id").is("tagging"); @@ -67,7 +67,7 @@ public class PutAuditCoreTests extends AuditTest public void enableDisableSyncApplicationAuditingAsNormalUser() throws Exception { //disable sync audit app - syncRestAuditAppModel = getSyncRestAuditAppModel(dataUser.getAdminUser()); + syncRestAuditAppModel = getSyncRestAuditAppModel(adminUser); restClient.authenticateUser(userModel).withCoreAPI().usingAudit().updateAuditApp(syncRestAuditAppModel, "isEnabled", "false"); //permission denied @@ -86,7 +86,7 @@ public class PutAuditCoreTests extends AuditTest public void enableDisableTaggingApplicationAuditingAsNormalUser() throws Exception { //disable tagging audit app - taggingRestAuditAppModel = getTaggingRestAuditAppModel(dataUser.getAdminUser()); + taggingRestAuditAppModel = getTaggingRestAuditAppModel(adminUser); restClient.authenticateUser(userModel).withCoreAPI().usingAudit().updateAuditApp(taggingRestAuditAppModel, "isEnabled", "false"); //permission denied From 419cb50b1480c7f7bc70b0a9c079314bbf97b47c Mon Sep 17 00:00:00 2001 From: Alexandru-Eusebiu Epure Date: Tue, 18 Jul 2017 15:14:16 +0300 Subject: [PATCH 1176/1491] REPO-2665 REST API: Delete Audit Entry - add sanity TAS test REPO-2662 REST API: Retrieve Audit Entry - add sanity TAS test Add sanity tests. Fix some coding style (tabs to spaces). --- .../org/alfresco/rest/audit/AuditTest.java | 25 ++- .../rest/audit/DeleteAuditCoreTests.java | 30 +++ .../rest/audit/GetAuditCoreTests.java | 79 ++++++-- .../rest/audit/PutAuditCoreTests.java | 183 +++++++++--------- 4 files changed, 200 insertions(+), 117 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/audit/AuditTest.java b/e2e-test/java/org/alfresco/rest/audit/AuditTest.java index f99563c6d..5f12bb4bd 100644 --- a/e2e-test/java/org/alfresco/rest/audit/AuditTest.java +++ b/e2e-test/java/org/alfresco/rest/audit/AuditTest.java @@ -65,25 +65,24 @@ public abstract class AuditTest extends RestTest { restAuditAppModel = restAuditCollection.getEntries().get(i++).onModel(); }while (!restAuditAppModel.getName().equals("alfresco-access")); - } - + protected RestAuditAppModel getSyncRestAuditAppModel(UserModel userModel) throws Exception { - restAuditCollection = restClient.authenticateUser(userModel).withCoreAPI().usingAudit().getAuditApplications(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restAuditCollection.assertThat().entriesListIsNotEmpty(); - RestAuditAppModel syncRestAuditAppModel = restAuditCollection.getEntries().get(0).onModel(); - return syncRestAuditAppModel; + restAuditCollection = restClient.authenticateUser(userModel).withCoreAPI().usingAudit().getAuditApplications(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restAuditCollection.assertThat().entriesListIsNotEmpty(); + RestAuditAppModel syncRestAuditAppModel = restAuditCollection.getEntries().get(0).onModel(); + return syncRestAuditAppModel; } - + protected RestAuditAppModel getTaggingRestAuditAppModel(UserModel userModel) throws Exception { - restAuditCollection = restClient.authenticateUser(userModel).withCoreAPI().usingAudit().getAuditApplications(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restAuditCollection.assertThat().entriesListIsNotEmpty(); - RestAuditAppModel taggingRestAuditAppModel = restAuditCollection.getEntries().get(1).onModel(); - return taggingRestAuditAppModel; + restAuditCollection = restClient.authenticateUser(userModel).withCoreAPI().usingAudit().getAuditApplications(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restAuditCollection.assertThat().entriesListIsNotEmpty(); + RestAuditAppModel taggingRestAuditAppModel = restAuditCollection.getEntries().get(1).onModel(); + return taggingRestAuditAppModel; } } diff --git a/e2e-test/java/org/alfresco/rest/audit/DeleteAuditCoreTests.java b/e2e-test/java/org/alfresco/rest/audit/DeleteAuditCoreTests.java index 31aa73f1c..6475ee4c8 100644 --- a/e2e-test/java/org/alfresco/rest/audit/DeleteAuditCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/audit/DeleteAuditCoreTests.java @@ -1,6 +1,36 @@ package org.alfresco.rest.audit; +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; + public class DeleteAuditCoreTests extends AuditTest { + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if deleting an audit entry for an application is only for admin user, and status code is 204") + public void deleteAuditEntry() throws Exception + { + restAuditEntryCollection = restClient.authenticateUser(adminUser).withParams("maxItems=10").withCoreAPI().usingAudit() + .listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); + restClient.assertStatusCodeIs(HttpStatus.OK); + String entryId = restAuditEntryCollection.getEntries().get(restAuditEntryCollection.getPagination().getCount() - 1) + .onModel().getId(); + + restClient.authenticateUser(userModel).withCoreAPI().usingAudit() + .deleteAuditEntryForAnAuditApplication(restAuditAppModel.getId(), entryId); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + + restClient.authenticateUser(adminUser).withCoreAPI().usingAudit() + .deleteAuditEntryForAnAuditApplication(restAuditAppModel.getId(), entryId); + + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restAuditEntryModel = restClient.authenticateUser(adminUser).withCoreAPI().usingAudit() + .getAuditEntryForAnAuditApplication(restAuditAppModel.getId(), entryId); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } + } diff --git a/e2e-test/java/org/alfresco/rest/audit/GetAuditCoreTests.java b/e2e-test/java/org/alfresco/rest/audit/GetAuditCoreTests.java index a9acb7851..1caebd41f 100644 --- a/e2e-test/java/org/alfresco/rest/audit/GetAuditCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/audit/GetAuditCoreTests.java @@ -1,9 +1,11 @@ package org.alfresco.rest.audit; import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertNull; import static org.testng.Assert.assertTrue; - +import org.alfresco.rest.model.RestAuditAppModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; @@ -21,17 +23,16 @@ public class GetAuditCoreTests extends AuditTest restAuditAppModel.assertThat().field("isEnabled").is(true); restAuditAppModel.assertThat().field("name").is("alfresco-access"); restAuditAppModel.assertThat().field("id").is("alfresco-access"); - - syncRestAuditAppModel = getSyncRestAuditAppModel(adminUser); + + syncRestAuditAppModel = getSyncRestAuditAppModel(adminUser); syncRestAuditAppModel.assertThat().field("isEnabled").is(true); syncRestAuditAppModel.assertThat().field("name").is("Alfresco Sync Service"); syncRestAuditAppModel.assertThat().field("id").is("sync"); - taggingRestAuditAppModel = getTaggingRestAuditAppModel(adminUser); - taggingRestAuditAppModel.assertThat().field("isEnabled").is(true); - taggingRestAuditAppModel.assertThat().field("name").is("Alfresco Tagging Service"); - taggingRestAuditAppModel.assertThat().field("id").is("tagging"); - + taggingRestAuditAppModel = getTaggingRestAuditAppModel(adminUser); + taggingRestAuditAppModel.assertThat().field("isEnabled").is(true); + taggingRestAuditAppModel.assertThat().field("name").is("Alfresco Tagging Service"); + taggingRestAuditAppModel.assertThat().field("id").is("tagging"); } @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) @@ -191,25 +192,71 @@ public class GetAuditCoreTests extends AuditTest assertTrue(Integer.parseInt(restAuditEntryCollection.getEntries().get(1).onModel().getId()) > Integer.parseInt(ascId)); } - + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) @TestRail(section = { TestGroup.REST_API, TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if the admin user gets a list of audit applications using the where parameter to and status code is 200") public void getAuditEntriesWithAdminUserUsingWhere() throws Exception { - restAuditEntryCollection = restClient.authenticateUser(adminUser).withParams("maxItems=10").withCoreAPI().usingAudit().listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); + int expectedNumberOfItems; + String id1,id2; + restAuditEntryCollection = restClient.authenticateUser(adminUser).withParams("maxItems=2").withCoreAPI().usingAudit().listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); restClient.assertStatusCodeIs(HttpStatus.OK); - String id1 = restAuditEntryCollection.getEntries().get(restAuditEntryCollection.getPagination().getCount()-1).onModel().getId(); - String id2 = restAuditEntryCollection.getEntries().get(restAuditEntryCollection.getPagination().getCount()/2).onModel().getId(); + if (restAuditEntryCollection.getPagination().getCount() == 2) + { + id1 = restAuditEntryCollection.getEntries().get(0).onModel().getId(); + id2 = restAuditEntryCollection.getEntries().get(1).onModel().getId(); + expectedNumberOfItems = 2; + } + else + { + id1 = id2 = restAuditEntryCollection.getEntries().get(0).onModel().getId(); + expectedNumberOfItems = 1; + } - restAuditEntryCollection = restClient.authenticateUser(adminUser).withParams("where=(id BETWEEN ("+id2+","+id1+"))") + restAuditEntryCollection = restClient.authenticateUser(adminUser).withParams("where=(id BETWEEN ("+id1+","+id2+"))") .withCoreAPI().usingAudit().listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); restClient.assertStatusCodeIs(HttpStatus.OK); - restAuditEntryCollection.assertThat().entriesListCountIs(Integer.parseInt(id1)-Integer.parseInt(id2)); - assertEquals(id2, restAuditEntryCollection.getEntries().get(0).onModel().getId()); - assertEquals(Integer.toString(Integer.parseInt(id1)-1), restAuditEntryCollection.getEntries().get(Integer.parseInt(id1)-Integer.parseInt(id2)-1).onModel().getId()); + restAuditEntryCollection.assertThat().entriesListCountIs(expectedNumberOfItems); + assertEquals(id1, restAuditEntryCollection.getEntries().get(0).onModel().getId()); + if(!id1.equals(id2)) + { + assertEquals( id2, restAuditEntryCollection.getEntries().get(1).onModel().getId()); + } } + + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if retrieving an audit entry for an audit application is only for admin user, with and without the include=values paramater and status code is 200") + public void getAuditEntry() throws Exception + { + restAuditEntryCollection = restClient.authenticateUser(adminUser).withParams("maxItems=10").withCoreAPI().usingAudit() + .listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); + restClient.assertStatusCodeIs(HttpStatus.OK); + String entryId = restAuditEntryCollection.getEntries().get(restAuditEntryCollection.getPagination().getCount() - 1) + .onModel().getId(); + String entryApplicationId = restAuditEntryCollection.getEntries() + .get(restAuditEntryCollection.getPagination().getCount() - 1).onModel().getAuditApplicationId(); + + restAuditEntryModel = restClient.authenticateUser(userModel).withCoreAPI().usingAudit() + .getAuditEntryForAnAuditApplication(restAuditAppModel.getId(), entryId); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + + restAuditEntryModel = restClient.authenticateUser(adminUser).withCoreAPI().usingAudit() + .getAuditEntryForAnAuditApplication(restAuditAppModel.getId(), entryId); + restClient.assertStatusCodeIs(HttpStatus.OK); + assertEquals(entryId, restAuditEntryModel.getId()); + assertEquals(entryApplicationId, restAuditEntryModel.getAuditApplicationId()); + assertNull(restAuditEntryModel.getValues()); + + restAuditEntryModel = restClient.authenticateUser(adminUser).withParams("include=values").withCoreAPI().usingAudit() + .getAuditEntryForAnAuditApplication(restAuditAppModel.getId(), entryId); + restClient.assertStatusCodeIs(HttpStatus.OK); + assertEquals(entryId, restAuditEntryModel.getId()); + assertEquals(entryApplicationId, restAuditEntryModel.getAuditApplicationId()); + assertNotNull(restAuditEntryModel.getValues()); + } } diff --git a/e2e-test/java/org/alfresco/rest/audit/PutAuditCoreTests.java b/e2e-test/java/org/alfresco/rest/audit/PutAuditCoreTests.java index 3f97f2f75..10e051c1f 100644 --- a/e2e-test/java/org/alfresco/rest/audit/PutAuditCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/audit/PutAuditCoreTests.java @@ -8,96 +8,103 @@ import org.testng.annotations.Test; public class PutAuditCoreTests extends AuditTest { - @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify that the admin user can enable/disable sync application auditing") - public void enableDisableSyncApplicationAuditingAsAdminUser() throws Exception - { - //disable sync audit app - syncRestAuditAppModel = getSyncRestAuditAppModel(adminUser); - restClient.authenticateUser(adminUser).withCoreAPI().usingAudit().updateAuditApp(syncRestAuditAppModel, "isEnabled", "false"); - - //check isEnabled=false - syncRestAuditAppModel = getSyncRestAuditAppModel(adminUser); - syncRestAuditAppModel.assertThat().field("isEnabled").is(false); - syncRestAuditAppModel.assertThat().field("name").is("Alfresco Sync Service"); - syncRestAuditAppModel.assertThat().field("id").is("sync"); - - //enable sync audit app - restClient.authenticateUser(adminUser).withCoreAPI().usingAudit().updateAuditApp(syncRestAuditAppModel, "isEnabled", "true"); - - //check isEnabled=true - syncRestAuditAppModel = getSyncRestAuditAppModel(adminUser); - syncRestAuditAppModel.assertThat().field("isEnabled").is(true); - syncRestAuditAppModel.assertThat().field("name").is("Alfresco Sync Service"); - syncRestAuditAppModel.assertThat().field("id").is("sync"); - - } - - @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify that the admin user can enable/disable tagging application auditing") - public void enableDisableTaggingApplicationAuditingAsAdminUser() throws Exception - { - //disable tagging audit app - taggingRestAuditAppModel = getTaggingRestAuditAppModel(adminUser); - restClient.authenticateUser(adminUser).withCoreAPI().usingAudit().updateAuditApp(taggingRestAuditAppModel, "isEnabled", "false"); - - //check isEnabled=false - taggingRestAuditAppModel = getTaggingRestAuditAppModel(adminUser); - taggingRestAuditAppModel.assertThat().field("isEnabled").is(false); - taggingRestAuditAppModel.assertThat().field("name").is("Alfresco Tagging Service"); - taggingRestAuditAppModel.assertThat().field("id").is("tagging"); - - //enable tagging audit app - restClient.authenticateUser(adminUser).withCoreAPI().usingAudit().updateAuditApp(taggingRestAuditAppModel, "isEnabled", "true"); - - //check isEnabled=true - taggingRestAuditAppModel = getTaggingRestAuditAppModel(adminUser); - taggingRestAuditAppModel.assertThat().field("isEnabled").is(true); - taggingRestAuditAppModel.assertThat().field("name").is("Alfresco Tagging Service"); - taggingRestAuditAppModel.assertThat().field("id").is("tagging"); - - } + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify that the admin user can enable/disable sync application auditing") + public void enableDisableSyncApplicationAuditingAsAdminUser() throws Exception + { + // disable sync audit app + syncRestAuditAppModel = getSyncRestAuditAppModel(adminUser); + restClient.authenticateUser(adminUser).withCoreAPI().usingAudit().updateAuditApp(syncRestAuditAppModel, "isEnabled", + "false"); - @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify that the normal user can't enable/disable sync application auditing") - public void enableDisableSyncApplicationAuditingAsNormalUser() throws Exception - { - //disable sync audit app - syncRestAuditAppModel = getSyncRestAuditAppModel(adminUser); - restClient.authenticateUser(userModel).withCoreAPI().usingAudit().updateAuditApp(syncRestAuditAppModel, "isEnabled", "false"); - - //permission denied - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - - //enable sync audit app - restClient.authenticateUser(userModel).withCoreAPI().usingAudit().updateAuditApp(syncRestAuditAppModel, "isEnabled", "true"); - - //permission denied - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify that the normal user can't enable/disable tagging application auditing") - public void enableDisableTaggingApplicationAuditingAsNormalUser() throws Exception - { - //disable tagging audit app - taggingRestAuditAppModel = getTaggingRestAuditAppModel(adminUser); - restClient.authenticateUser(userModel).withCoreAPI().usingAudit().updateAuditApp(taggingRestAuditAppModel, "isEnabled", "false"); - - //permission denied - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - - //disable tagging audit app - restClient.authenticateUser(userModel).withCoreAPI().usingAudit().updateAuditApp(taggingRestAuditAppModel, "isEnabled", "true"); - - //permission denied - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + // check isEnabled=false + syncRestAuditAppModel = getSyncRestAuditAppModel(adminUser); + syncRestAuditAppModel.assertThat().field("isEnabled").is(false); + syncRestAuditAppModel.assertThat().field("name").is("Alfresco Sync Service"); + syncRestAuditAppModel.assertThat().field("id").is("sync"); - } + // enable sync audit app + restClient.authenticateUser(adminUser).withCoreAPI().usingAudit().updateAuditApp(syncRestAuditAppModel, "isEnabled", + "true"); + + // check isEnabled=true + syncRestAuditAppModel = getSyncRestAuditAppModel(adminUser); + syncRestAuditAppModel.assertThat().field("isEnabled").is(true); + syncRestAuditAppModel.assertThat().field("name").is("Alfresco Sync Service"); + syncRestAuditAppModel.assertThat().field("id").is("sync"); + + } + + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify that the admin user can enable/disable tagging application auditing") + public void enableDisableTaggingApplicationAuditingAsAdminUser() throws Exception + { + // disable tagging audit app + taggingRestAuditAppModel = getTaggingRestAuditAppModel(adminUser); + restClient.authenticateUser(adminUser).withCoreAPI().usingAudit().updateAuditApp(taggingRestAuditAppModel, "isEnabled", + "false"); + + // check isEnabled=false + taggingRestAuditAppModel = getTaggingRestAuditAppModel(adminUser); + taggingRestAuditAppModel.assertThat().field("isEnabled").is(false); + taggingRestAuditAppModel.assertThat().field("name").is("Alfresco Tagging Service"); + taggingRestAuditAppModel.assertThat().field("id").is("tagging"); + + // enable tagging audit app + restClient.authenticateUser(adminUser).withCoreAPI().usingAudit().updateAuditApp(taggingRestAuditAppModel, "isEnabled", + "true"); + + // check isEnabled=true + taggingRestAuditAppModel = getTaggingRestAuditAppModel(adminUser); + taggingRestAuditAppModel.assertThat().field("isEnabled").is(true); + taggingRestAuditAppModel.assertThat().field("name").is("Alfresco Tagging Service"); + taggingRestAuditAppModel.assertThat().field("id").is("tagging"); + + } + + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify that the normal user can't enable/disable sync application auditing") + public void enableDisableSyncApplicationAuditingAsNormalUser() throws Exception + { + // disable sync audit app + syncRestAuditAppModel = getSyncRestAuditAppModel(adminUser); + restClient.authenticateUser(userModel).withCoreAPI().usingAudit().updateAuditApp(syncRestAuditAppModel, "isEnabled", + "false"); + + // permission denied + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + + // enable sync audit app + restClient.authenticateUser(userModel).withCoreAPI().usingAudit().updateAuditApp(syncRestAuditAppModel, "isEnabled", + "true"); + + // permission denied + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify that the normal user can't enable/disable tagging application auditing") + public void enableDisableTaggingApplicationAuditingAsNormalUser() throws Exception + { + // disable tagging audit app + taggingRestAuditAppModel = getTaggingRestAuditAppModel(adminUser); + restClient.authenticateUser(userModel).withCoreAPI().usingAudit().updateAuditApp(taggingRestAuditAppModel, "isEnabled", + "false"); + + // permission denied + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + + // disable tagging audit app + restClient.authenticateUser(userModel).withCoreAPI().usingAudit().updateAuditApp(taggingRestAuditAppModel, "isEnabled", + "true"); + + // permission denied + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + } } From f380912fb69483b479118b3617be7fbb54d3a452 Mon Sep 17 00:00:00 2001 From: jcule Date: Wed, 19 Jul 2017 09:34:56 +0100 Subject: [PATCH 1177/1491] REPO-2644: REST API: Delete Application Audit Entries - add TAS-level sanity test - added test for deleting of range of entries --- .../rest/audit/DeleteAuditCoreTests.java | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/audit/DeleteAuditCoreTests.java b/e2e-test/java/org/alfresco/rest/audit/DeleteAuditCoreTests.java index 31aa73f1c..6e1b72c26 100644 --- a/e2e-test/java/org/alfresco/rest/audit/DeleteAuditCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/audit/DeleteAuditCoreTests.java @@ -1,6 +1,55 @@ package org.alfresco.rest.audit; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +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; + public class DeleteAuditCoreTests extends AuditTest { + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if the admin user can delete audit application entries between the range of ids") + public void deleteAuditApplicationEntriesBeetween() throws Exception + { + int numberOfAlfrescoAccessAuditEntries = restClient.authenticateUser(adminUser).withParams("maxItems=3").withCoreAPI().usingAudit().listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()).getEntries().size(); + + List ids = new ArrayList(); + for (int i=0; i Date: Wed, 19 Jul 2017 11:43:19 +0300 Subject: [PATCH 1178/1491] REPO-2662 / REPO-2644: Retrieve audit entry / Delete audit entry - minor formatting --- e2e-test/java/org/alfresco/rest/audit/AuditTest.java | 10 ++++++---- .../org/alfresco/rest/audit/GetAuditCoreTests.java | 3 +-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/audit/AuditTest.java b/e2e-test/java/org/alfresco/rest/audit/AuditTest.java index 5f12bb4bd..4dcd9ee62 100644 --- a/e2e-test/java/org/alfresco/rest/audit/AuditTest.java +++ b/e2e-test/java/org/alfresco/rest/audit/AuditTest.java @@ -42,13 +42,15 @@ public abstract class AuditTest extends RestTest { //Using two users, because audit API is designed for users with admin rights. userModel = dataUser.createRandomTestUser(); - adminUser=dataUser.getAdminUser(); + adminUser = dataUser.getAdminUser(); + //GET /alfresco/service/api/audit/control to verify if Audit is enabled on the system. RestAssured.basePath = ""; restAPI.configureRequestSpec().setBasePath(RestAssured.basePath); RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "alfresco/service/api/audit/control"); RestResponse response = restAPI.authenticateUser(adminUser).process(request); response.assertThat().body("enabled", is(true)); + //GET /audit-applications and verify that there are audit applications in the system. restAuditCollection = restClient.authenticateUser(adminUser).withCoreAPI().usingAudit().getAuditApplications(); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -59,12 +61,12 @@ public abstract class AuditTest extends RestTest String alfrescoAccessEnabled = jmxBuilder.getJmxClient().readProperty("Alfresco:Type=Configuration,Category=Audit,id1=default", "audit.alfresco-access.enabled").toString(); Assert.assertEquals(alfrescoAccessEnabled, Boolean.TRUE.toString(), String.format("Property audit.alfresco-access.enabled is [%s]", alfrescoAccessEnabled)); - // - int i=0; + //Find alfresco-access audit application in the list of audit applications + int i = 0; do { restAuditAppModel = restAuditCollection.getEntries().get(i++).onModel(); - }while (!restAuditAppModel.getName().equals("alfresco-access")); + } while (!restAuditAppModel.getName().equals("alfresco-access")); } protected RestAuditAppModel getSyncRestAuditAppModel(UserModel userModel) throws Exception diff --git a/e2e-test/java/org/alfresco/rest/audit/GetAuditCoreTests.java b/e2e-test/java/org/alfresco/rest/audit/GetAuditCoreTests.java index 1caebd41f..fb4dca8f1 100644 --- a/e2e-test/java/org/alfresco/rest/audit/GetAuditCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/audit/GetAuditCoreTests.java @@ -5,7 +5,6 @@ import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNull; import static org.testng.Assert.assertTrue; -import org.alfresco.rest.model.RestAuditAppModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; @@ -142,7 +141,7 @@ public class GetAuditCoreTests extends AuditTest @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) @TestRail(section = { TestGroup.REST_API, - TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if the admin user gets a list of audit applications using invalid skipCount and/or invalid maxItems and status code is 400") + TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if the admin user gets a list of audit entries using invalid skipCount and/or invalid maxItems and status code is 400") public void getAuditEntriesWithAdminUserUsingInvalidSkipCountAndMaxItems() throws Exception { restClient.authenticateUser(adminUser).withParams("skipCount=-1&maxItems=1").withCoreAPI().usingAudit() From c32c239e2d3314fd205f75c087d5b88a1c45a068 Mon Sep 17 00:00:00 2001 From: Alexandru-Eusebiu Epure Date: Wed, 19 Jul 2017 17:30:58 +0300 Subject: [PATCH 1179/1491] Fixed failing bamboo build. Moved the enable auditing part at the start of the dataPrep. --- e2e-test/java/org/alfresco/rest/audit/AuditTest.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/audit/AuditTest.java b/e2e-test/java/org/alfresco/rest/audit/AuditTest.java index 4dcd9ee62..15cc57e16 100644 --- a/e2e-test/java/org/alfresco/rest/audit/AuditTest.java +++ b/e2e-test/java/org/alfresco/rest/audit/AuditTest.java @@ -44,6 +44,11 @@ public abstract class AuditTest extends RestTest userModel = dataUser.createRandomTestUser(); adminUser = dataUser.getAdminUser(); + //enable alfresco-access audit application + jmxBuilder.getJmxClient().writeProperty("Alfresco:Type=Configuration,Category=Audit,id1=default", "audit.alfresco-access.enabled", Boolean.TRUE.toString()); + String alfrescoAccessEnabled = jmxBuilder.getJmxClient().readProperty("Alfresco:Type=Configuration,Category=Audit,id1=default", "audit.alfresco-access.enabled").toString(); + Assert.assertEquals(alfrescoAccessEnabled, Boolean.TRUE.toString(), String.format("Property audit.alfresco-access.enabled is [%s]", alfrescoAccessEnabled)); + //GET /alfresco/service/api/audit/control to verify if Audit is enabled on the system. RestAssured.basePath = ""; restAPI.configureRequestSpec().setBasePath(RestAssured.basePath); @@ -56,11 +61,6 @@ public abstract class AuditTest extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); restAuditCollection.assertThat().entriesListIsNotEmpty(); - //enable alfresco-access audit application - jmxBuilder.getJmxClient().writeProperty("Alfresco:Type=Configuration,Category=Audit,id1=default", "audit.alfresco-access.enabled", Boolean.TRUE.toString()); - String alfrescoAccessEnabled = jmxBuilder.getJmxClient().readProperty("Alfresco:Type=Configuration,Category=Audit,id1=default", "audit.alfresco-access.enabled").toString(); - Assert.assertEquals(alfrescoAccessEnabled, Boolean.TRUE.toString(), String.format("Property audit.alfresco-access.enabled is [%s]", alfrescoAccessEnabled)); - //Find alfresco-access audit application in the list of audit applications int i = 0; do From dc5dd8beac9bd1ef8ee42e340a19d8dd00157a92 Mon Sep 17 00:00:00 2001 From: Andrei Forascu Date: Thu, 20 Jul 2017 13:46:32 +0300 Subject: [PATCH 1180/1491] REPO-1786 / REPO-2670: REST API: Retrieve Node (alfresco-access) Audit Entries - add sanity TAS-level test - TAS sanity test added: getAuditEntriesForNodeUsingMaxItemsAndWhereParam - Fixed some test descriptions / minor code formatting --- .../org/alfresco/rest/audit/AuditTest.java | 15 ++++- .../rest/audit/GetAuditCoreTests.java | 64 +++++++++++++++++-- 2 files changed, 71 insertions(+), 8 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/audit/AuditTest.java b/e2e-test/java/org/alfresco/rest/audit/AuditTest.java index 15cc57e16..df29de006 100644 --- a/e2e-test/java/org/alfresco/rest/audit/AuditTest.java +++ b/e2e-test/java/org/alfresco/rest/audit/AuditTest.java @@ -10,13 +10,17 @@ import org.alfresco.rest.model.RestAuditAppModel; import org.alfresco.rest.model.RestAuditAppModelsCollection; import org.alfresco.rest.model.RestAuditEntryModel; import org.alfresco.rest.model.RestAuditEntryModelsCollection; +import org.alfresco.rest.model.RestNodeBodyModel; +import org.alfresco.rest.model.RestNodeModel; +import org.alfresco.utility.model.ContentModel; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.network.JmxBuilder; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; import org.testng.Assert; +import org.testng.annotations.BeforeClass; + import com.jayway.restassured.RestAssured; public abstract class AuditTest extends RestTest @@ -35,6 +39,7 @@ public abstract class AuditTest extends RestTest protected RestAuditEntryModelsCollection restAuditEntryCollection; protected RestAuditAppModel syncRestAuditAppModel; protected RestAuditAppModel taggingRestAuditAppModel; + protected RestNodeModel node; @BeforeClass(alwaysRun = true) @@ -67,6 +72,14 @@ public abstract class AuditTest extends RestTest { restAuditAppModel = restAuditCollection.getEntries().get(i++).onModel(); } while (!restAuditAppModel.getName().equals("alfresco-access")); + + //Create new node + RestNodeBodyModel nodeBody = new RestNodeBodyModel(); + nodeBody.setName("MyFile"); + nodeBody.setNodeType("cm:content"); + node = restClient.withParams("autoRename=true").withCoreAPI().usingNode(ContentModel.my()).createNode(nodeBody); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + } protected RestAuditAppModel getSyncRestAuditAppModel(UserModel userModel) throws Exception diff --git a/e2e-test/java/org/alfresco/rest/audit/GetAuditCoreTests.java b/e2e-test/java/org/alfresco/rest/audit/GetAuditCoreTests.java index fb4dca8f1..a3ddc7604 100644 --- a/e2e-test/java/org/alfresco/rest/audit/GetAuditCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/audit/GetAuditCoreTests.java @@ -1,10 +1,13 @@ package org.alfresco.rest.audit; +import static org.alfresco.utility.report.log.Step.STEP; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNull; import static org.testng.Assert.assertTrue; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FileType; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; @@ -163,7 +166,7 @@ public class GetAuditCoreTests extends AuditTest @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) @TestRail(section = { TestGroup.REST_API, - TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if the admin user gets a list of audit applications using valid skipCount and maxItems and status code is 200") + TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if the admin user gets a list of audit entries using valid skipCount and maxItems and status code is 200") public void getAuditEntriesWithAdminUserUsingValidSkipCountAndMaxItems() throws Exception { restAuditEntryCollection = restClient.authenticateUser(adminUser).withParams("skipCount=1&maxItems=1") @@ -176,7 +179,7 @@ public class GetAuditCoreTests extends AuditTest @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) @TestRail(section = { TestGroup.REST_API, - TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if the admin user gets a list of audit applications using orderBy and status code is 200") + TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if the admin user gets a list of audit entries using orderBy and status code is 200") public void getAuditEntriesWithAdminUserUsingOrderBy() throws Exception { restAuditEntryCollection = restClient.authenticateUser(adminUser).withParams("orderBy=createdAt ASC&maxItems=10") @@ -194,7 +197,7 @@ public class GetAuditCoreTests extends AuditTest @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) @TestRail(section = { TestGroup.REST_API, - TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if the admin user gets a list of audit applications using the where parameter to and status code is 200") + TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if the admin user gets a list of audit entries using the where parameter to and status code is 200") public void getAuditEntriesWithAdminUserUsingWhere() throws Exception { int expectedNumberOfItems; @@ -217,14 +220,14 @@ public class GetAuditCoreTests extends AuditTest restAuditEntryCollection = restClient.authenticateUser(adminUser).withParams("where=(id BETWEEN ("+id1+","+id2+"))") .withCoreAPI().usingAudit().listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); restClient.assertStatusCodeIs(HttpStatus.OK); - + restAuditEntryCollection.assertThat().entriesListCountIs(expectedNumberOfItems); assertEquals(id1, restAuditEntryCollection.getEntries().get(0).onModel().getId()); - if(!id1.equals(id2)) + if (!id1.equals(id2)) { - assertEquals( id2, restAuditEntryCollection.getEntries().get(1).onModel().getId()); + assertEquals(id2, restAuditEntryCollection.getEntries().get(1).onModel().getId()); } - + } @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) @@ -258,4 +261,51 @@ public class GetAuditCoreTests extends AuditTest assertEquals(entryApplicationId, restAuditEntryModel.getAuditApplicationId()); assertNotNull(restAuditEntryModel.getValues()); } + + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if the admin user gets a list of audit entries for node id nodeId using 'where' and 'maxItems' param and status code is 200") + public void getAuditEntriesForNodeUsingMaxItemsAndWhereParam() throws Exception + { + String createdAt1, createdAt2; + int expectedNumberOfItems; + + // Get the node id and construct a fileModel to be used when adding comments + String nodeId = node.getId(); + FileModel fileModel = new FileModel("testFile", FileType.TEXT_PLAIN); + fileModel.setNodeRef(nodeId); + + STEP("1. Add comments for a node (to create audit entries)"); + restClient.authenticateUser(adminUser).withCoreAPI().usingNode(fileModel).addComment("This is the first comment"); + restClient.authenticateUser(adminUser).withCoreAPI().usingNode(fileModel).addComment("This is the second comment"); + + STEP("2. Get maxium two audit entries for the node using 'maxItems' param on /nodes/{nodeId}/audit-entries"); + restAuditEntryCollection = restClient.authenticateUser(adminUser).withParams("maxItems=2").withCoreAPI().usingAudit().listAuditEntriesForNode(nodeId); + restClient.assertStatusCodeIs(HttpStatus.OK); + + if (restAuditEntryCollection.getPagination().getCount() == 2) + { + createdAt1 = restAuditEntryCollection.getEntries().get(0).onModel().getCreatedAt(); + createdAt2 = restAuditEntryCollection.getEntries().get(1).onModel().getCreatedAt(); + expectedNumberOfItems = 2; + } + else + { + createdAt1 = createdAt2 = restAuditEntryCollection.getEntries().get(0).onModel().getCreatedAt(); + expectedNumberOfItems = 1; + } + + STEP("3. Get audit entries between ids for the node using 'where' clause on /nodes/{nodeId}/audit-entries"); + restAuditEntryCollection = restClient.authenticateUser(adminUser).withParams("where=(createdAt BETWEEN ('" + createdAt1 + "','" + createdAt2 + "'))") + .withCoreAPI().usingAudit().listAuditEntriesForNode(nodeId); + restClient.assertStatusCodeIs(HttpStatus.OK); + + restAuditEntryCollection.assertThat().entriesListCountIs(expectedNumberOfItems); + assertEquals(createdAt1, restAuditEntryCollection.getEntries().get(0).onModel().getCreatedAt()); + if (!createdAt1.equals(createdAt2)) + { + assertEquals(createdAt2, restAuditEntryCollection.getEntries().get(1).onModel().getCreatedAt()); + } + + } } From 05fe676459248ea60b63a362b7e27c70df310990 Mon Sep 17 00:00:00 2001 From: Alexandru-Eusebiu Epure Date: Thu, 20 Jul 2017 14:48:47 +0300 Subject: [PATCH 1181/1491] REPO-2644 : REST API: Delete Application Audit Entries - add TAS-level sanity test Add TAS test for deleting audit application entries. --- .../rest/audit/DeleteAuditCoreTests.java | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/audit/DeleteAuditCoreTests.java b/e2e-test/java/org/alfresco/rest/audit/DeleteAuditCoreTests.java index 6475ee4c8..30dd2b244 100644 --- a/e2e-test/java/org/alfresco/rest/audit/DeleteAuditCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/audit/DeleteAuditCoreTests.java @@ -1,5 +1,7 @@ package org.alfresco.rest.audit; +import static org.testng.Assert.assertEquals; + import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; @@ -26,11 +28,35 @@ public class DeleteAuditCoreTests extends AuditTest restClient.authenticateUser(adminUser).withCoreAPI().usingAudit() .deleteAuditEntryForAnAuditApplication(restAuditAppModel.getId(), entryId); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restAuditEntryModel = restClient.authenticateUser(adminUser).withCoreAPI().usingAudit() .getAuditEntryForAnAuditApplication(restAuditAppModel.getId(), entryId); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); } + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if deleting a set of audit entries for an application is only for admin user, and status code is 204") + public void deleteAuditEntriesForAnAuditApplication() throws Exception + { + restAuditEntryCollection = restClient.authenticateUser(adminUser).withParams("maxItems=4").withCoreAPI().usingAudit() + .listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); + restClient.assertStatusCodeIs(HttpStatus.OK); + String firstId = restAuditEntryCollection.getEntries().get(restAuditEntryCollection.getPagination().getCount() - 1) + .onModel().getId(); + String secondId = restAuditEntryCollection.getEntries().get(0).onModel().getId(); + + restClient.authenticateUser(userModel).withParams("where=(id BETWEEN ("+firstId+","+secondId+"))").withCoreAPI().usingAudit().deleteAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + + restClient.authenticateUser(adminUser).withParams("where=(id BETWEEN ("+firstId+","+secondId+"))").withCoreAPI().usingAudit().deleteAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restAuditEntryCollection = restClient.authenticateUser(adminUser).withParams("where=(id BETWEEN ("+firstId+","+secondId+"))").withCoreAPI().usingAudit() + .listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); + restClient.assertStatusCodeIs(HttpStatus.OK); + assertEquals(restAuditEntryCollection.getPagination().getCount(), 0); + } + } From 59be5d5cec37678cfd12d5220189abfc423a7617 Mon Sep 17 00:00:00 2001 From: Alexandru-Eusebiu Epure Date: Thu, 20 Jul 2017 15:29:24 +0300 Subject: [PATCH 1182/1491] REPO-2644: REST API: Delete Application Audit Entries - add TAS-level sanity test Refactor existing TAS test. --- .../org/alfresco/rest/audit/DeleteAuditCoreTests.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/audit/DeleteAuditCoreTests.java b/e2e-test/java/org/alfresco/rest/audit/DeleteAuditCoreTests.java index 493e1b6a7..5d0a4e94f 100644 --- a/e2e-test/java/org/alfresco/rest/audit/DeleteAuditCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/audit/DeleteAuditCoreTests.java @@ -48,10 +48,12 @@ public class DeleteAuditCoreTests extends AuditTest String secondId = restAuditEntryCollection.getEntries().get(restAuditEntryCollection.getPagination().getCount() - 1) .onModel().getId(); - restClient.authenticateUser(userModel).withParams("where=(id BETWEEN ("+firstId+","+secondId+"))").withCoreAPI().usingAudit().deleteAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); + restClient.authenticateUser(userModel).withParams("where=(id BETWEEN (" + firstId + "," + secondId + "))").withCoreAPI() + .usingAudit().deleteAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - - restClient.authenticateUser(adminUser).withParams("where=(id BETWEEN ("+firstId+","+secondId+"))").withCoreAPI().usingAudit().deleteAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); + + restClient.authenticateUser(adminUser).withParams("where=(id BETWEEN (" + firstId + "," + secondId + "))").withCoreAPI() + .usingAudit().deleteAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); restAuditEntryCollection = restClient.authenticateUser(adminUser).withParams("where=(id BETWEEN ("+firstId+","+secondId+"))").withCoreAPI().usingAudit() From ec8f0d2dddf12135c49e3460b18ead79eb22b775 Mon Sep 17 00:00:00 2001 From: Andrei Forascu Date: Thu, 20 Jul 2017 15:47:14 +0300 Subject: [PATCH 1183/1491] REPO-1786 / REPO-2670: REST API: Retrieve Node (alfresco-access) Audit Entries - add sanity TAS-level test - removed steps from testgetAuditEntriesForNodeUsingMaxItemsAndWhereParam to match the existing tests --- .../java/org/alfresco/rest/audit/GetAuditCoreTests.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/audit/GetAuditCoreTests.java b/e2e-test/java/org/alfresco/rest/audit/GetAuditCoreTests.java index a3ddc7604..0c3304ece 100644 --- a/e2e-test/java/org/alfresco/rest/audit/GetAuditCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/audit/GetAuditCoreTests.java @@ -275,11 +275,11 @@ public class GetAuditCoreTests extends AuditTest FileModel fileModel = new FileModel("testFile", FileType.TEXT_PLAIN); fileModel.setNodeRef(nodeId); - STEP("1. Add comments for a node (to create audit entries)"); + // Add comments for a node (to create audit entries) restClient.authenticateUser(adminUser).withCoreAPI().usingNode(fileModel).addComment("This is the first comment"); restClient.authenticateUser(adminUser).withCoreAPI().usingNode(fileModel).addComment("This is the second comment"); - STEP("2. Get maxium two audit entries for the node using 'maxItems' param on /nodes/{nodeId}/audit-entries"); + // Get maxium two audit entries for the node using 'maxItems' param on /nodes/{nodeId}/audit-entries restAuditEntryCollection = restClient.authenticateUser(adminUser).withParams("maxItems=2").withCoreAPI().usingAudit().listAuditEntriesForNode(nodeId); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -295,7 +295,7 @@ public class GetAuditCoreTests extends AuditTest expectedNumberOfItems = 1; } - STEP("3. Get audit entries between ids for the node using 'where' clause on /nodes/{nodeId}/audit-entries"); + // Get audit entries between ids for the node using 'where' clause on /nodes/{nodeId}/audit-entries restAuditEntryCollection = restClient.authenticateUser(adminUser).withParams("where=(createdAt BETWEEN ('" + createdAt1 + "','" + createdAt2 + "'))") .withCoreAPI().usingAudit().listAuditEntriesForNode(nodeId); restClient.assertStatusCodeIs(HttpStatus.OK); From 4bab6d828298f673a77ebfdb6dc49413baef87bc Mon Sep 17 00:00:00 2001 From: Alexandru-Eusebiu Epure Date: Fri, 21 Jul 2017 14:29:23 +0300 Subject: [PATCH 1184/1491] REPO-2644 Fix the merge request conflicts Now getAuditEntriesWithAdminUserUsingValidSkipCountAndMaxItems also tests pagination --- .../rest/audit/GetAuditCoreTests.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/audit/GetAuditCoreTests.java b/e2e-test/java/org/alfresco/rest/audit/GetAuditCoreTests.java index 0c3304ece..97b9cc654 100644 --- a/e2e-test/java/org/alfresco/rest/audit/GetAuditCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/audit/GetAuditCoreTests.java @@ -175,6 +175,27 @@ public class GetAuditCoreTests extends AuditTest restAuditEntryCollection.getPagination().assertThat().field("totalItems").isNotNull().and().field("totalItems") .isGreaterThan(0).and().field("maxItems").is("1").and().field("skipCount").is("1"); assertEquals(restAuditEntryCollection.getEntries().size(), 1); + + //Testing Pagination + restAuditEntryCollection = restClient.authenticateUser(adminUser).withParams("maxItems=10") + .withCoreAPI().usingAudit().listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); + restClient.assertStatusCodeIs(HttpStatus.OK); + Long firstId = Long.valueOf(restAuditEntryCollection.getEntries().get(0).onModel().getId()); + Long lastId = Long.valueOf(restAuditEntryCollection.getEntries().get(restAuditEntryCollection.getPagination().getCount()-1).onModel().getId()); + System.out.println(firstId + " " + lastId); + int skipCount = 0; + do + { + restAuditEntryCollection = restClient.authenticateUser(adminUser).withParams("maxItems=1&skipCount="+skipCount) + .withCoreAPI().usingAudit().listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); + restClient.assertStatusCodeIs(HttpStatus.OK); + assertEquals(restAuditEntryCollection.getEntries().size(), 1); + assertEquals(restAuditEntryCollection.getPagination().getCount(), 1); + assertEquals(restAuditEntryCollection.getPagination().getSkipCount(),skipCount); + assertEquals(restAuditEntryCollection.getEntries().get(0).onModel().getId(),Long.toString(firstId)); + skipCount++; + firstId++; + }while(firstId<=lastId); } @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) From 038d9695a7a15a5b9f3a4faa3c1f37edfb8a84d9 Mon Sep 17 00:00:00 2001 From: Andrei Forascu Date: Mon, 24 Jul 2017 11:23:22 +0300 Subject: [PATCH 1185/1491] REPO-2644 - REST API: Delete Application Audit Entries - add TAS-level sanity test: - minor code formatting --- .../org/alfresco/rest/audit/GetAuditCoreTests.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/audit/GetAuditCoreTests.java b/e2e-test/java/org/alfresco/rest/audit/GetAuditCoreTests.java index 97b9cc654..724f58bc0 100644 --- a/e2e-test/java/org/alfresco/rest/audit/GetAuditCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/audit/GetAuditCoreTests.java @@ -186,16 +186,16 @@ public class GetAuditCoreTests extends AuditTest int skipCount = 0; do { - restAuditEntryCollection = restClient.authenticateUser(adminUser).withParams("maxItems=1&skipCount="+skipCount) - .withCoreAPI().usingAudit().listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); + restAuditEntryCollection = restClient.authenticateUser(adminUser).withParams("maxItems=1&skipCount=" + skipCount).withCoreAPI().usingAudit() + .listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); restClient.assertStatusCodeIs(HttpStatus.OK); assertEquals(restAuditEntryCollection.getEntries().size(), 1); assertEquals(restAuditEntryCollection.getPagination().getCount(), 1); - assertEquals(restAuditEntryCollection.getPagination().getSkipCount(),skipCount); - assertEquals(restAuditEntryCollection.getEntries().get(0).onModel().getId(),Long.toString(firstId)); + assertEquals(restAuditEntryCollection.getPagination().getSkipCount(), skipCount); + assertEquals(restAuditEntryCollection.getEntries().get(0).onModel().getId(), Long.toString(firstId)); skipCount++; firstId++; - }while(firstId<=lastId); + } while (firstId <= lastId); } @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) From ed05b6b4eb00a397ee8470f98c9264744ef4c05f Mon Sep 17 00:00:00 2001 From: Alexandru-Eusebiu Epure Date: Mon, 24 Jul 2017 11:46:02 +0300 Subject: [PATCH 1186/1491] REPO-437: Audit REST API Fix code formatting (tabs -> spaces, added/removed newlines were needed). Added description for updateAuditApp call. --- .../java/org/alfresco/rest/audit/AuditTest.java | 14 ++++++-------- .../org/alfresco/rest/audit/GetAuditCoreTests.java | 4 +--- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/audit/AuditTest.java b/e2e-test/java/org/alfresco/rest/audit/AuditTest.java index df29de006..084bedc94 100644 --- a/e2e-test/java/org/alfresco/rest/audit/AuditTest.java +++ b/e2e-test/java/org/alfresco/rest/audit/AuditTest.java @@ -28,10 +28,10 @@ public abstract class AuditTest extends RestTest @Autowired protected RestWrapper restAPI; - + @Autowired protected JmxBuilder jmxBuilder; - + protected UserModel userModel,adminUser; protected RestAuditAppModelsCollection restAuditCollection; protected RestAuditAppModel restAuditAppModel; @@ -40,7 +40,6 @@ public abstract class AuditTest extends RestTest protected RestAuditAppModel syncRestAuditAppModel; protected RestAuditAppModel taggingRestAuditAppModel; protected RestNodeModel node; - @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception @@ -49,7 +48,7 @@ public abstract class AuditTest extends RestTest userModel = dataUser.createRandomTestUser(); adminUser = dataUser.getAdminUser(); - //enable alfresco-access audit application + //Enable alfresco-access audit application. jmxBuilder.getJmxClient().writeProperty("Alfresco:Type=Configuration,Category=Audit,id1=default", "audit.alfresco-access.enabled", Boolean.TRUE.toString()); String alfrescoAccessEnabled = jmxBuilder.getJmxClient().readProperty("Alfresco:Type=Configuration,Category=Audit,id1=default", "audit.alfresco-access.enabled").toString(); Assert.assertEquals(alfrescoAccessEnabled, Boolean.TRUE.toString(), String.format("Property audit.alfresco-access.enabled is [%s]", alfrescoAccessEnabled)); @@ -66,20 +65,19 @@ public abstract class AuditTest extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); restAuditCollection.assertThat().entriesListIsNotEmpty(); - //Find alfresco-access audit application in the list of audit applications + //Find alfresco-access audit application in the list of audit applications. int i = 0; do { restAuditAppModel = restAuditCollection.getEntries().get(i++).onModel(); } while (!restAuditAppModel.getName().equals("alfresco-access")); - //Create new node + //Create new node. RestNodeBodyModel nodeBody = new RestNodeBodyModel(); nodeBody.setName("MyFile"); nodeBody.setNodeType("cm:content"); - node = restClient.withParams("autoRename=true").withCoreAPI().usingNode(ContentModel.my()).createNode(nodeBody); + node = restClient.withParams("autoRename=true").withCoreAPI().usingNode(ContentModel.my()).createNode(nodeBody); restClient.assertStatusCodeIs(HttpStatus.CREATED); - } protected RestAuditAppModel getSyncRestAuditAppModel(UserModel userModel) throws Exception diff --git a/e2e-test/java/org/alfresco/rest/audit/GetAuditCoreTests.java b/e2e-test/java/org/alfresco/rest/audit/GetAuditCoreTests.java index 97b9cc654..d1af3ebfb 100644 --- a/e2e-test/java/org/alfresco/rest/audit/GetAuditCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/audit/GetAuditCoreTests.java @@ -1,6 +1,5 @@ package org.alfresco.rest.audit; -import static org.alfresco.utility.report.log.Step.STEP; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNull; @@ -248,7 +247,6 @@ public class GetAuditCoreTests extends AuditTest { assertEquals(id2, restAuditEntryCollection.getEntries().get(1).onModel().getId()); } - } @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) @@ -327,6 +325,6 @@ public class GetAuditCoreTests extends AuditTest { assertEquals(createdAt2, restAuditEntryCollection.getEntries().get(1).onModel().getCreatedAt()); } - } + } From 46e1f4134c6265389aff404a3f7f560a057eac92 Mon Sep 17 00:00:00 2001 From: Alexandru-Eusebiu Epure Date: Tue, 25 Jul 2017 11:33:32 +0300 Subject: [PATCH 1187/1491] Fix getAuditEntriesWithAdminUserUsingValidSkipCountAndMaxItems test that was failing if the interval used for pagination was no formed of consecutive ids values. --- .../rest/audit/GetAuditCoreTests.java | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/audit/GetAuditCoreTests.java b/e2e-test/java/org/alfresco/rest/audit/GetAuditCoreTests.java index 0fe88131e..7d0608fd0 100644 --- a/e2e-test/java/org/alfresco/rest/audit/GetAuditCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/audit/GetAuditCoreTests.java @@ -5,6 +5,8 @@ import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNull; import static org.testng.Assert.assertTrue; +import java.util.ArrayList; + import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FileType; import org.alfresco.utility.model.TestGroup; @@ -175,26 +177,29 @@ public class GetAuditCoreTests extends AuditTest .isGreaterThan(0).and().field("maxItems").is("1").and().field("skipCount").is("1"); assertEquals(restAuditEntryCollection.getEntries().size(), 1); - //Testing Pagination - restAuditEntryCollection = restClient.authenticateUser(adminUser).withParams("maxItems=10") - .withCoreAPI().usingAudit().listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); + // Testing Pagination + restAuditEntryCollection = restClient.authenticateUser(adminUser).withParams("maxItems=10").withCoreAPI().usingAudit() + .listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); restClient.assertStatusCodeIs(HttpStatus.OK); - Long firstId = Long.valueOf(restAuditEntryCollection.getEntries().get(0).onModel().getId()); - Long lastId = Long.valueOf(restAuditEntryCollection.getEntries().get(restAuditEntryCollection.getPagination().getCount()-1).onModel().getId()); - System.out.println(firstId + " " + lastId); + ArrayList ids = new ArrayList<>(); + int numberOfElements = restAuditEntryCollection.getPagination().getCount(); + for (int i = 0; i < numberOfElements; i++) + { + ids.add(restAuditEntryCollection.getEntries().get(i).onModel().getId()); + } + int skipCount = 0; do { - restAuditEntryCollection = restClient.authenticateUser(adminUser).withParams("maxItems=1&skipCount=" + skipCount).withCoreAPI().usingAudit() - .listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); + restAuditEntryCollection = restClient.authenticateUser(adminUser).withParams("maxItems=1&skipCount=" + skipCount) + .withCoreAPI().usingAudit().listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); restClient.assertStatusCodeIs(HttpStatus.OK); assertEquals(restAuditEntryCollection.getEntries().size(), 1); assertEquals(restAuditEntryCollection.getPagination().getCount(), 1); assertEquals(restAuditEntryCollection.getPagination().getSkipCount(), skipCount); - assertEquals(restAuditEntryCollection.getEntries().get(0).onModel().getId(), Long.toString(firstId)); + assertEquals(restAuditEntryCollection.getEntries().get(0).onModel().getId(), ids.get(skipCount)); skipCount++; - firstId++; - } while (firstId <= lastId); + } while (skipCount < numberOfElements); } @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) From 6e6d0cac3fa077b8a7afde77cd6f9920cf656cb9 Mon Sep 17 00:00:00 2001 From: Andrei Forascu Date: Wed, 26 Jul 2017 12:16:48 +0300 Subject: [PATCH 1188/1491] REPO-2670 - REST API: Retrieve Node (alfresco-access) Audit Entries - add sanity TAS-level test: - added TAS test to cover the scenario where a non-admin user with access to a node can access the audit entries for that node using nodes/{nodeId}/audit-entries --- e2e-test/java/org/alfresco/rest/RestTest.java | 5 ++- .../org/alfresco/rest/audit/AuditTest.java | 25 ++++++++----- .../rest/audit/GetAuditCoreTests.java | 35 +++++++++++++++---- 3 files changed, 48 insertions(+), 17 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/RestTest.java b/e2e-test/java/org/alfresco/rest/RestTest.java index 789d7cca1..c65cd7710 100644 --- a/e2e-test/java/org/alfresco/rest/RestTest.java +++ b/e2e-test/java/org/alfresco/rest/RestTest.java @@ -65,13 +65,16 @@ public abstract class RestTest extends AbstractTestNGSpringContextTests protected WorkflowService workflow; protected SiteModel testSite; - + + protected SiteModel privateTestSite; + @BeforeSuite(alwaysRun = true) public void checkServerHealth() throws Exception { super.springTestContextPrepareTestInstance(); serverHealth.assertServerIsOnline(); testSite = dataSite.createPublicRandomSite(); + privateTestSite = dataSite.createPrivateRandomSite(); } @BeforeMethod(alwaysRun=true) diff --git a/e2e-test/java/org/alfresco/rest/audit/AuditTest.java b/e2e-test/java/org/alfresco/rest/audit/AuditTest.java index 084bedc94..a64f4147f 100644 --- a/e2e-test/java/org/alfresco/rest/audit/AuditTest.java +++ b/e2e-test/java/org/alfresco/rest/audit/AuditTest.java @@ -2,6 +2,7 @@ package org.alfresco.rest.audit; import static org.hamcrest.Matchers.is; +import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.core.RestResponse; @@ -12,7 +13,10 @@ import org.alfresco.rest.model.RestAuditEntryModel; import org.alfresco.rest.model.RestAuditEntryModelsCollection; import org.alfresco.rest.model.RestNodeBodyModel; import org.alfresco.rest.model.RestNodeModel; +import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.model.ContentModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.network.JmxBuilder; import org.springframework.beans.factory.annotation.Autowired; @@ -32,21 +36,26 @@ public abstract class AuditTest extends RestTest @Autowired protected JmxBuilder jmxBuilder; - protected UserModel userModel,adminUser; + protected UserModel userModel, userModel1, adminUser; protected RestAuditAppModelsCollection restAuditCollection; protected RestAuditAppModel restAuditAppModel; protected RestAuditEntryModel restAuditEntryModel; protected RestAuditEntryModelsCollection restAuditEntryCollection; protected RestAuditAppModel syncRestAuditAppModel; protected RestAuditAppModel taggingRestAuditAppModel; - protected RestNodeModel node; + protected RestNodeModel node; + protected FileModel file; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception { - //Using two users, because audit API is designed for users with admin rights. + //Audit API is designed for users with admin rights (except /nodes/{nodeId}/audit-entries) + //Create users and add userModel as SiteCollaborator on private site userModel = dataUser.createRandomTestUser(); + userModel1 = dataUser.createRandomTestUser(); adminUser = dataUser.getAdminUser(); + dataUser.addUserToSite(userModel, privateTestSite, UserRole.SiteCollaborator); + userModel.setUserRole(UserRole.SiteCollaborator); //Enable alfresco-access audit application. jmxBuilder.getJmxClient().writeProperty("Alfresco:Type=Configuration,Category=Audit,id1=default", "audit.alfresco-access.enabled", Boolean.TRUE.toString()); @@ -72,12 +81,10 @@ public abstract class AuditTest extends RestTest restAuditAppModel = restAuditCollection.getEntries().get(i++).onModel(); } while (!restAuditAppModel.getName().equals("alfresco-access")); - //Create new node. - RestNodeBodyModel nodeBody = new RestNodeBodyModel(); - nodeBody.setName("MyFile"); - nodeBody.setNodeType("cm:content"); - node = restClient.withParams("autoRename=true").withCoreAPI().usingNode(ContentModel.my()).createNode(nodeBody); - restClient.assertStatusCodeIs(HttpStatus.CREATED); + //Create new file + file = dataContent.usingUser(adminUser).usingSite(privateTestSite).createContent(DocumentType.TEXT_PLAIN); + node = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file).usingParams("include=isLocked").getNode(); + restClient.assertStatusCodeIs(HttpStatus.OK); } protected RestAuditAppModel getSyncRestAuditAppModel(UserModel userModel) throws Exception diff --git a/e2e-test/java/org/alfresco/rest/audit/GetAuditCoreTests.java b/e2e-test/java/org/alfresco/rest/audit/GetAuditCoreTests.java index 7d0608fd0..12683aacb 100644 --- a/e2e-test/java/org/alfresco/rest/audit/GetAuditCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/audit/GetAuditCoreTests.java @@ -7,8 +7,6 @@ import static org.testng.Assert.assertTrue; import java.util.ArrayList; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FileType; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; @@ -294,18 +292,18 @@ public class GetAuditCoreTests extends AuditTest String createdAt1, createdAt2; int expectedNumberOfItems; - // Get the node id and construct a fileModel to be used when adding comments + // Get the node id String nodeId = node.getId(); - FileModel fileModel = new FileModel("testFile", FileType.TEXT_PLAIN); - fileModel.setNodeRef(nodeId); // Add comments for a node (to create audit entries) - restClient.authenticateUser(adminUser).withCoreAPI().usingNode(fileModel).addComment("This is the first comment"); - restClient.authenticateUser(adminUser).withCoreAPI().usingNode(fileModel).addComment("This is the second comment"); + restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file).addComment("This is the first comment"); + restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file).addComment("This is the second comment"); + restClient.assertStatusCodeIs(HttpStatus.CREATED); // Get maxium two audit entries for the node using 'maxItems' param on /nodes/{nodeId}/audit-entries restAuditEntryCollection = restClient.authenticateUser(adminUser).withParams("maxItems=2").withCoreAPI().usingAudit().listAuditEntriesForNode(nodeId); restClient.assertStatusCodeIs(HttpStatus.OK); + restAuditEntryCollection.assertThat().entriesListIsNotEmpty(); if (restAuditEntryCollection.getPagination().getCount() == 2) { @@ -332,4 +330,27 @@ public class GetAuditCoreTests extends AuditTest } } + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if user with permissions can get a list of audit entries for node and status code is 200") + public void getAuditEntriesForNodeUsingUserWithPermissions() throws Exception + { + // Get the node id + String nodeId = node.getId(); + + // Add comments for a node using user with permissions (to create audit entries and check if user can view/edit the node) + restClient.authenticateUser(userModel).withCoreAPI().usingNode(file).addComment("This is a comment"); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + // Get audit entries for the node using a user with permissions and /nodes/{nodeId}/audit-entries + restAuditEntryCollection = restClient.authenticateUser(userModel).withCoreAPI().usingAudit().listAuditEntriesForNode(nodeId); + restClient.assertStatusCodeIs(HttpStatus.OK); + restAuditEntryCollection.assertThat().entriesListIsNotEmpty(); + + // Check that a user that doesn't have access to node, doesn't have access to audit entries for node + restClient.authenticateUser(userModel1).withCoreAPI().usingNode(file).getNode(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + restClient.authenticateUser(userModel1).withCoreAPI().usingAudit().listAuditEntriesForNode(nodeId); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + } } From f7835390cb5602001b64b6def9c24f673d50c98b Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Thu, 27 Jul 2017 10:49:31 +0300 Subject: [PATCH 1189/1491] clean up --- .../alfresco/rest/search/StatsSearchTest.java | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/StatsSearchTest.java b/e2e-test/java/org/alfresco/rest/search/StatsSearchTest.java index 59735b6ee..8e39d9ac8 100644 --- a/e2e-test/java/org/alfresco/rest/search/StatsSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/StatsSearchTest.java @@ -21,12 +21,6 @@ package org.alfresco.rest.search; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertTrue; -import org.alfresco.rest.model.RestErrorModel; -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; import java.util.ArrayList; import java.util.Arrays; @@ -35,6 +29,13 @@ import java.util.Map; import java.util.Set; import java.util.stream.Collectors; +import org.alfresco.rest.model.RestErrorModel; +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; + /** * Stats search test. * @author Gethin James @@ -121,8 +122,8 @@ public class StatsSearchTest extends AbstractSearchTest assertStatsFacetedResponse(response, "DBID", 1); RestGenericMetricModel percMetric = response.getContext().getFacets().get(0).getBuckets().get(0).getMetrics().get(0); assertEquals(percMetric.getType(),"percentiles"); - Map percVal = (Map) percMetric.getValue(); - Map percentiles = (Map) percVal.get("percentiles"); + Map percVal = (Map) percMetric.getValue(); + Map percentiles = (Map) percVal.get("percentiles"); assertEquals(percentiles.size(),4); assertTrue(percentiles.keySet().containsAll(Arrays.asList("1.0","75.0","99.0","99.9"))); } @@ -170,7 +171,7 @@ public class StatsSearchTest extends AbstractSearchTest assertStatsFacetedResponse(response, "creator", 1); RestGenericMetricModel countMetric = response.getContext().getFacets().get(0).getBuckets().get(0).getMetrics().get(0); Integer count = response.getPagination().getTotalItems(); - Map metricCount = (Map) countMetric.getValue(); + Map metricCount = (Map) countMetric.getValue(); assertEquals(count, metricCount.get("countValues")); statsModel1.setExcludeFilters(Arrays.asList("justCars")); @@ -178,7 +179,7 @@ public class StatsSearchTest extends AbstractSearchTest assertStatsFacetedResponse(response, "creator", 1); countMetric = response.getContext().getFacets().get(0).getBuckets().get(0).getMetrics().get(0); count = response.getEntries().size(); - metricCount = (Map) countMetric.getValue(); + metricCount = (Map) countMetric.getValue(); assertTrue((Integer)metricCount.get("countValues") > count, "With the exclude filter there will be more documents than returned"); } From 181a98a2d6c445359db3778a646cd60d521068ed Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Tue, 1 Aug 2017 15:05:47 +0300 Subject: [PATCH 1190/1491] added response assertion onResponse on RestWrapper --- .../java/org/alfresco/rest/comments/AddCommentSanityTests.java | 1 + 1 file changed, 1 insertion(+) diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java index 93606fb20..1b7c44974 100644 --- a/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java @@ -46,6 +46,7 @@ public class AddCommentSanityTests extends RestTest .assertThat().field("content").isNotEmpty() .and().field("content").is(newContent); restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.onResponse().assertThat().body("entry.edited", org.hamcrest.Matchers.is(false)); } @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Manager user adds comments with Rest API and status code is 201") From 8e0834ceac1aeabc7b5bf3d71590305d0aae3790 Mon Sep 17 00:00:00 2001 From: Andrei Forascu Date: Wed, 2 Aug 2017 10:19:06 +0300 Subject: [PATCH 1191/1491] REPO-1787 - Retrieve Audit Entry: - fixed a TAS test that was failing after we decided to display by default values for a single audit entry --- e2e-test/java/org/alfresco/rest/audit/GetAuditCoreTests.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/audit/GetAuditCoreTests.java b/e2e-test/java/org/alfresco/rest/audit/GetAuditCoreTests.java index 12683aacb..1ac998beb 100644 --- a/e2e-test/java/org/alfresco/rest/audit/GetAuditCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/audit/GetAuditCoreTests.java @@ -274,7 +274,8 @@ public class GetAuditCoreTests extends AuditTest restClient.assertStatusCodeIs(HttpStatus.OK); assertEquals(entryId, restAuditEntryModel.getId()); assertEquals(entryApplicationId, restAuditEntryModel.getAuditApplicationId()); - assertNull(restAuditEntryModel.getValues()); + // Values are displayed by default for single audit application entry + assertNotNull(restAuditEntryModel.getValues()); restAuditEntryModel = restClient.authenticateUser(adminUser).withParams("include=values").withCoreAPI().usingAudit() .getAuditEntryForAnAuditApplication(restAuditAppModel.getId(), entryId); From de775c64b28e7bcb81dff8389a007d7d9f7c5f3d Mon Sep 17 00:00:00 2001 From: Andrei Forascu Date: Thu, 3 Aug 2017 18:00:26 +0300 Subject: [PATCH 1192/1491] REPO-437: Audit REST API - fixed Audit tests by creating the private site in the AuditTest class --- e2e-test/java/org/alfresco/rest/RestTest.java | 3 --- e2e-test/java/org/alfresco/rest/audit/AuditTest.java | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/RestTest.java b/e2e-test/java/org/alfresco/rest/RestTest.java index c65cd7710..0358a948d 100644 --- a/e2e-test/java/org/alfresco/rest/RestTest.java +++ b/e2e-test/java/org/alfresco/rest/RestTest.java @@ -66,15 +66,12 @@ public abstract class RestTest extends AbstractTestNGSpringContextTests protected SiteModel testSite; - protected SiteModel privateTestSite; - @BeforeSuite(alwaysRun = true) public void checkServerHealth() throws Exception { super.springTestContextPrepareTestInstance(); serverHealth.assertServerIsOnline(); testSite = dataSite.createPublicRandomSite(); - privateTestSite = dataSite.createPrivateRandomSite(); } @BeforeMethod(alwaysRun=true) diff --git a/e2e-test/java/org/alfresco/rest/audit/AuditTest.java b/e2e-test/java/org/alfresco/rest/audit/AuditTest.java index a64f4147f..fea6bfa49 100644 --- a/e2e-test/java/org/alfresco/rest/audit/AuditTest.java +++ b/e2e-test/java/org/alfresco/rest/audit/AuditTest.java @@ -45,6 +45,7 @@ public abstract class AuditTest extends RestTest protected RestAuditAppModel taggingRestAuditAppModel; protected RestNodeModel node; protected FileModel file; + protected SiteModel privateTestSite; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception @@ -54,6 +55,8 @@ public abstract class AuditTest extends RestTest userModel = dataUser.createRandomTestUser(); userModel1 = dataUser.createRandomTestUser(); adminUser = dataUser.getAdminUser(); + privateTestSite = dataSite.createPrivateRandomSite(); + dataUser.addUserToSite(userModel, privateTestSite, UserRole.SiteCollaborator); userModel.setUserRole(UserRole.SiteCollaborator); From 786ceda277286e50f24f9a13b59ac04aa04d7c4f Mon Sep 17 00:00:00 2001 From: mbhave Date: Wed, 2 Aug 2017 15:14:50 +0100 Subject: [PATCH 1193/1491] cherry pick includePath feature from 5.2.1 --- .../FavoritesIncludePathSanityTests.java | 143 ++++++++++++++++++ 1 file changed, 143 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/favorites/FavoritesIncludePathSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/favorites/FavoritesIncludePathSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/FavoritesIncludePathSanityTests.java new file mode 100644 index 000000000..0b3a1b2d7 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/favorites/FavoritesIncludePathSanityTests.java @@ -0,0 +1,143 @@ +package org.alfresco.rest.favorites; + +import static org.alfresco.utility.report.log.Step.STEP; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class FavoritesIncludePathSanityTests extends RestTest +{ + private UserModel adminUser; + private UserModel testUser1; + + private SiteModel siteModel1; + + private FolderModel folder1; + + private FileModel file1; + + private FolderModel subFolder1; + private FileModel fileInSubFolder; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + + adminUser = dataUser.getAdminUser(); + restClient.authenticateUser(adminUser); + + // Create Standard User + testUser1 = dataUser.usingUser(adminUser).createRandomTestUser(); + + // Create Site + siteModel1 = dataSite.usingUser(testUser1).createPublicRandomSite(); + + folder1 = dataContent.usingUser(adminUser).usingSite(siteModel1).createFolder(); + subFolder1 = dataContent.usingUser(adminUser).usingResource(folder1).createFolder(); + file1 = dataContent.usingUser(adminUser).usingResource(folder1).createContent(DocumentType.TEXT_PLAIN); + fileInSubFolder = dataContent.usingUser(adminUser).usingResource(subFolder1).createContent(DocumentType.TEXT_PLAIN); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify that get favorite site request does not include Path") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES}) + public void testGetFavoriteIncludePathForSite() throws Exception + { + restClient.authenticateUser(testUser1).withCoreAPI().usingAuthUser().includePath().getFavorite(siteModel1.getGuid()); + restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.onResponse().assertThat().body("entry.target.site.id", org.hamcrest.Matchers.equalTo(siteModel1.getId()));//(org.hamcrest.Matchers.nullValue())); + restClient.onResponse().assertThat().body("entry.target.site.path", org.hamcrest.Matchers.is(org.hamcrest.Matchers.nullValue())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify that get favorite file or folder request includes path when requested") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES}) + public void testGetFavouriteIncludePathForFileFolder() throws Exception + { + STEP("1. Favourite Folder and File"); + restClient.authenticateUser(testUser1).withCoreAPI().usingAuthUser().addFolderToFavorites(folder1); + restClient.authenticateUser(testUser1).withCoreAPI().usingAuthUser().addFileToFavorites(file1); + + STEP("2. Check Path for Folder: Displayed when requested"); + restClient.authenticateUser(testUser1).withCoreAPI().usingAuthUser().includePath().getFavorite(folder1.getNodeRefWithoutVersion()); + restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.onResponse().assertThat().body("entry.target.folder.id", org.hamcrest.Matchers.equalTo(folder1.getNodeRefWithoutVersion())); + restClient.onResponse().assertThat().body("entry.target.folder.path", org.hamcrest.Matchers.notNullValue()); + + STEP("3. Check Path for file: Displayed when requested"); + restClient.authenticateUser(testUser1).withCoreAPI().usingAuthUser().includePath().getFavorite(file1.getNodeRefWithoutVersion()); + restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.onResponse().assertThat().body("entry.target.file.id", org.hamcrest.Matchers.equalTo(file1.getNodeRefWithoutVersion())); + restClient.onResponse().assertThat().body("entry.target.file.path", org.hamcrest.Matchers.notNullValue()); + + STEP("4. Check Path for Folder: Not Displayed when not requested"); + restClient.authenticateUser(testUser1).withCoreAPI().usingAuthUser().getFavorite(folder1.getNodeRefWithoutVersion()); + restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.onResponse().assertThat().body("entry.target.folder.id", org.hamcrest.Matchers.equalTo(folder1.getNodeRefWithoutVersion())); + restClient.onResponse().assertThat().body("entry.target.folder.path", org.hamcrest.Matchers.nullValue()); + + STEP("5. Check Path for file: Not Displayed when not requested"); + restClient.authenticateUser(testUser1).withCoreAPI().usingAuthUser().getFavorite(file1.getNodeRefWithoutVersion()); + restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.onResponse().assertThat().body("entry.target.file.id", org.hamcrest.Matchers.equalTo(file1.getNodeRefWithoutVersion())); + restClient.onResponse().assertThat().body("entry.target.file.path", org.hamcrest.Matchers.nullValue()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify path in get favorites") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES}) + public void testGetFavouritesIncludePath() throws Exception + { + STEP("1. Favourite Folder and File"); + restClient.authenticateUser(testUser1).withCoreAPI().usingAuthUser().addFolderToFavorites(folder1); + restClient.authenticateUser(testUser1).withCoreAPI().usingAuthUser().addFileToFavorites(file1); + + STEP("2. Check Path: Displayed when appropriate"); + restClient.authenticateUser(testUser1).withCoreAPI().usingAuthUser().includePath().getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + // Folder + restClient.onResponse().assertThat().body("list.entries.entry.target.folder.id", org.hamcrest.Matchers.contains(folder1.getNodeRefWithoutVersion())); + restClient.onResponse().assertThat().body("list.entries.entry.target.folder.path", org.hamcrest.Matchers.notNullValue()); + // File + restClient.onResponse().assertThat().body("list.entries.entry.target.file.id", org.hamcrest.Matchers.contains(file1.getNodeRefWithoutVersion())); + restClient.onResponse().assertThat().body("list.entries.entry.target.file.path", org.hamcrest.Matchers.notNullValue()); + // Site + restClient.onResponse().assertThat().body("list.entries.entry.target.site.id", org.hamcrest.Matchers.contains(siteModel1.getId())); + restClient.onResponse().assertThat().body("list.entries.entry.target.site.path", org.hamcrest.Matchers.contains(org.hamcrest.Matchers.nullValue())); + } + + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify path in post favorites") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES}) + public void testPostFavouritesIncludePath() throws Exception + { + STEP("1. Favourite Site"); + restClient.authenticateUser(testUser1).withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel1); + restClient.authenticateUser(testUser1).withCoreAPI().usingAuthUser().usingParams("include=path").addFavoriteSite(siteModel1); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.onResponse().assertThat().body("entry.id", org.hamcrest.Matchers.equalTo(siteModel1.getId())); + restClient.onResponse().assertThat().body("entry.path", org.hamcrest.Matchers.nullValue()); + + STEP("2. Favourite Folder"); + restClient.authenticateUser(testUser1).withCoreAPI().usingAuthUser().usingParams("include=path").addFolderToFavorites(subFolder1); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.onResponse().assertThat().body("entry.target.folder.id", org.hamcrest.Matchers.equalTo(subFolder1.getNodeRefWithoutVersion())); + restClient.onResponse().assertThat().body("entry.target.folder.path", org.hamcrest.Matchers.notNullValue()); + + STEP("3. Favourite File"); + restClient.authenticateUser(testUser1).withCoreAPI().usingAuthUser().includePath().addFileToFavorites(fileInSubFolder); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.onResponse().assertThat().body("entry.target.file.id", org.hamcrest.Matchers.equalTo(fileInSubFolder.getNodeRefWithoutVersion())); + restClient.onResponse().assertThat().body("entry.target.file.path", org.hamcrest.Matchers.notNullValue()); + + + } + +} \ No newline at end of file From e42cb60fe5e3255f7f5abefbf20692c6eb3980f1 Mon Sep 17 00:00:00 2001 From: mbhave Date: Mon, 7 Aug 2017 11:49:59 +0100 Subject: [PATCH 1194/1491] cherry picked APPSREPO-165 from 5.2.1 --- .../SharedLinks/SharedLinksSanityTests.java | 150 ++++++++++++++++++ .../FavoritesIncludePathSanityTests.java | 5 + 2 files changed, 155 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/SharedLinks/SharedLinksSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/SharedLinks/SharedLinksSanityTests.java b/e2e-test/java/org/alfresco/rest/SharedLinks/SharedLinksSanityTests.java new file mode 100644 index 000000000..7d43e1550 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/SharedLinks/SharedLinksSanityTests.java @@ -0,0 +1,150 @@ +package org.alfresco.rest.SharedLinks; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestSharedLinksModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Class includes Sanity tests for the shared-links api. Detailed tests would be covered in the alfresco-remote-api test project + * + * @author meenal bhave + */ +public class SharedLinksSanityTests extends RestTest +{ + private UserModel adminUser; + private UserModel testUser1; + + private SiteModel siteModel1; + + private FolderModel folder1; + + private FileModel file1; + private FileModel file2; + private FileModel file3; + private FileModel file4; + private FileModel file5; + + private RestSharedLinksModel sharedLink1; + private RestSharedLinksModel sharedLink2; + private RestSharedLinksModel sharedLink3; + private RestSharedLinksModel sharedLink4; + private RestSharedLinksModel sharedLink5; + + private String expiryDate = "2027-03-23T23:00:00.000+0000"; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + + adminUser = dataUser.getAdminUser(); + restClient.authenticateUser(adminUser); + + // Create Standard User + testUser1 = dataUser.usingUser(adminUser).createRandomTestUser(); + + // Create Site + siteModel1 = dataSite.usingUser(testUser1).createPublicRandomSite(); + + folder1 = dataContent.usingUser(adminUser).usingSite(siteModel1).createFolder(); + + file1 = dataContent.usingUser(adminUser).usingResource(folder1).createContent(DocumentType.TEXT_PLAIN); + file2 = dataContent.usingUser(adminUser).usingResource(folder1).createContent(DocumentType.TEXT_PLAIN); + file3 = dataContent.usingUser(adminUser).usingResource(folder1).createContent(DocumentType.TEXT_PLAIN); + file4 = dataContent.usingUser(adminUser).usingResource(folder1).createContent(DocumentType.TEXT_PLAIN); + file5 = dataContent.usingUser(adminUser).usingResource(folder1).createContent(DocumentType.TEXT_PLAIN); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.SHAREDLINKS }, executionType = ExecutionType.REGRESSION, description = "Verify empty sharedLinks with and without Path") + @Test(groups = { TestGroup.REST_API, TestGroup.SHAREDLINKS }) + public void testGetSharedLinksNoLinks() throws Exception + { + restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().getSharedLinks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + restClient.authenticateUser(testUser1).withCoreAPI().includePath().usingSharedLinks().getSharedLinks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.SHAREDLINKS }, executionType = ExecutionType.REGRESSION, description = "Verify create sharedLinks with and without Path") + @Test(groups = { TestGroup.REST_API, TestGroup.SHAREDLINKS }) + public void testCreateAndGetSharedLinks() throws Exception + { + // Post without includePath + sharedLink1 = restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().createSharedLink(file1); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.onResponse().assertThat().body("entry.nodeId", org.hamcrest.Matchers.equalTo(file1.getNodeRefWithoutVersion())); + restClient.onResponse().assertThat().body("entry.name", org.hamcrest.Matchers.equalTo(file1.getName())); + restClient.onResponse().assertThat().body("entry.id", org.hamcrest.Matchers.equalTo(sharedLink1.getId())); + restClient.onResponse().assertThat().body("entry.path", org.hamcrest.Matchers.nullValue()); + + // Get without includePath + restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().getSharedLink(sharedLink1); + restClient.onResponse().assertThat().body("entry.nodeId", org.hamcrest.Matchers.equalTo(file1.getNodeRefWithoutVersion())); + restClient.onResponse().assertThat().body("entry.name", org.hamcrest.Matchers.equalTo(file1.getName())); + restClient.onResponse().assertThat().body("entry.id", org.hamcrest.Matchers.equalTo(sharedLink1.getId())); + restClient.onResponse().assertThat().body("entry.path", org.hamcrest.Matchers.nullValue()); + + // Post with includePath + sharedLink2 = restClient.authenticateUser(testUser1).withCoreAPI().includePath().usingSharedLinks().createSharedLink(file2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.onResponse().assertThat().body("entry.nodeId", org.hamcrest.Matchers.equalTo(file2.getNodeRefWithoutVersion())); + restClient.onResponse().assertThat().body("entry.name", org.hamcrest.Matchers.equalTo(file2.getName())); + restClient.onResponse().assertThat().body("entry.id", org.hamcrest.Matchers.equalTo(sharedLink2.getId())); + restClient.onResponse().assertThat().body("entry.path", org.hamcrest.Matchers.notNullValue()); + + // Get with includePath + restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().getSharedLink(sharedLink2); + restClient.onResponse().assertThat().body("entry.nodeId", org.hamcrest.Matchers.equalTo(file2.getNodeRefWithoutVersion())); + restClient.onResponse().assertThat().body("entry.name", org.hamcrest.Matchers.equalTo(file2.getName())); + restClient.onResponse().assertThat().body("entry.id", org.hamcrest.Matchers.equalTo(sharedLink2.getId())); + // Verify that path is null since includePath is not supported for this noAuth api + restClient.onResponse().assertThat().body("entry.path", org.hamcrest.Matchers.nullValue()); + + // Get: noAuth with includePath + restClient.withCoreAPI().usingSharedLinks().getSharedLink(sharedLink2); + restClient.onResponse().assertThat().body("entry.nodeId", org.hamcrest.Matchers.equalTo(file2.getNodeRefWithoutVersion())); + restClient.onResponse().assertThat().body("entry.name", org.hamcrest.Matchers.equalTo(file2.getName())); + restClient.onResponse().assertThat().body("entry.id", org.hamcrest.Matchers.equalTo(sharedLink2.getId())); + // Verify that path is null since includePath is not supported for this noAuth api + restClient.onResponse().assertThat().body("entry.path", org.hamcrest.Matchers.nullValue()); // includePath is not supported since this is noAuth api + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.SHAREDLINKS }, executionType = ExecutionType.REGRESSION, description = "Verify delete sharedLinks with and without Path") + @Test(groups = { TestGroup.REST_API, TestGroup.SHAREDLINKS }) + public void testDeleteSharedLinks() throws Exception + { + sharedLink3 = restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().createSharedLink(file3); + restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().deleteSharedLink(sharedLink3); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + sharedLink4 = restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().createSharedLink(file4); + restClient.authenticateUser(testUser1).withCoreAPI().includePath().usingSharedLinks().deleteSharedLink(sharedLink4); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.SHAREDLINKS }, executionType = ExecutionType.REGRESSION, description = "Verify get sharedLink/content and get/renditions") + @Test(groups = { TestGroup.REST_API, TestGroup.SHAREDLINKS }) + public void testCreateWithExpiryDateAndGetSharedLinkRendition() throws Exception + { + sharedLink5 = restClient.authenticateUser(testUser1).withCoreAPI().includePath().usingSharedLinks().createSharedLinkWithExpiryDate(file5, expiryDate); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.onResponse().assertThat().body("entry.expiresAt", org.hamcrest.Matchers.equalTo(expiryDate)); + restClient.onResponse().assertThat().body("entry.path", org.hamcrest.Matchers.notNullValue()); + + restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().getSharedLinkRenditions(sharedLink5); + restClient.assertStatusCodeIs(HttpStatus.OK); + + restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().getSharedLinkRendition(sharedLink5, "doclib"); + restClient.assertStatusCodeIs(HttpStatus.OK); + } +} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/favorites/FavoritesIncludePathSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/FavoritesIncludePathSanityTests.java index 0b3a1b2d7..a22228c89 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/FavoritesIncludePathSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/FavoritesIncludePathSanityTests.java @@ -15,6 +15,11 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +/** + * Class includes Sanity tests for the favorites api. Detailed tests would be covered in the alfresco-remote-api test project + * + * @author meenal bhave + */ public class FavoritesIncludePathSanityTests extends RestTest { private UserModel adminUser; From 0709643308ba360ba8b9385d838b84c1953ce74b Mon Sep 17 00:00:00 2001 From: mbhave Date: Mon, 7 Aug 2017 14:14:52 +0100 Subject: [PATCH 1195/1491] Added getter and setter for expiresAt and test code to test sharedLink methods --- .../SharedLinks/SharedLinksSanityTests.java | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/SharedLinks/SharedLinksSanityTests.java b/e2e-test/java/org/alfresco/rest/SharedLinks/SharedLinksSanityTests.java index 7d43e1550..c624c0522 100644 --- a/e2e-test/java/org/alfresco/rest/SharedLinks/SharedLinksSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/SharedLinks/SharedLinksSanityTests.java @@ -11,6 +11,7 @@ import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; +import org.testng.Assert; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -87,6 +88,11 @@ public class SharedLinksSanityTests extends RestTest restClient.onResponse().assertThat().body("entry.id", org.hamcrest.Matchers.equalTo(sharedLink1.getId())); restClient.onResponse().assertThat().body("entry.path", org.hamcrest.Matchers.nullValue()); + // Same Checks above using sharedLink methods: GET sharedLink: without includePath + Assert.assertEquals(sharedLink1.getNodeId(), file1.getNodeRefWithoutVersion()); + Assert.assertEquals(sharedLink1.getName(), file1.getName()); + Assert.assertNull(sharedLink1.getPath(), "Path is expected to be null for noauth api: Response shows: " + sharedLink1.toJson()); + // Get without includePath restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().getSharedLink(sharedLink1); restClient.onResponse().assertThat().body("entry.nodeId", org.hamcrest.Matchers.equalTo(file1.getNodeRefWithoutVersion())); @@ -102,6 +108,11 @@ public class SharedLinksSanityTests extends RestTest restClient.onResponse().assertThat().body("entry.id", org.hamcrest.Matchers.equalTo(sharedLink2.getId())); restClient.onResponse().assertThat().body("entry.path", org.hamcrest.Matchers.notNullValue()); + // Same Checks above using sharedLink methods: POST sharedLink: includePath + Assert.assertEquals(sharedLink2.getNodeId(), file2.getNodeRefWithoutVersion()); + Assert.assertEquals(sharedLink2.getName(), file2.getName()); + Assert.assertNotNull(sharedLink2.getPath(), "Path not expected to be null for noauth api: Response shows: " + sharedLink1.toJson()); + // Get with includePath restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().getSharedLink(sharedLink2); restClient.onResponse().assertThat().body("entry.nodeId", org.hamcrest.Matchers.equalTo(file2.getNodeRefWithoutVersion())); @@ -111,12 +122,17 @@ public class SharedLinksSanityTests extends RestTest restClient.onResponse().assertThat().body("entry.path", org.hamcrest.Matchers.nullValue()); // Get: noAuth with includePath - restClient.withCoreAPI().usingSharedLinks().getSharedLink(sharedLink2); + sharedLink2 = restClient.withCoreAPI().usingSharedLinks().getSharedLink(sharedLink2); restClient.onResponse().assertThat().body("entry.nodeId", org.hamcrest.Matchers.equalTo(file2.getNodeRefWithoutVersion())); restClient.onResponse().assertThat().body("entry.name", org.hamcrest.Matchers.equalTo(file2.getName())); restClient.onResponse().assertThat().body("entry.id", org.hamcrest.Matchers.equalTo(sharedLink2.getId())); // Verify that path is null since includePath is not supported for this noAuth api - restClient.onResponse().assertThat().body("entry.path", org.hamcrest.Matchers.nullValue()); // includePath is not supported since this is noAuth api + restClient.onResponse().assertThat().body("entry.path", org.hamcrest.Matchers.nullValue()); + + // Same Checks above using sharedLink methods: GET sharedLink: noAuth + Assert.assertEquals(sharedLink2.getNodeId(), file2.getNodeRefWithoutVersion()); + Assert.assertEquals(sharedLink2.getName(), file2.getName()); + Assert.assertNull(sharedLink2.getPath(), "Path is expected to be null for noauth api: Response shows: " + sharedLink2.toJson()); } @TestRail(section = { TestGroup.REST_API, TestGroup.SHAREDLINKS }, executionType = ExecutionType.REGRESSION, description = "Verify delete sharedLinks with and without Path") @@ -138,8 +154,9 @@ public class SharedLinksSanityTests extends RestTest { sharedLink5 = restClient.authenticateUser(testUser1).withCoreAPI().includePath().usingSharedLinks().createSharedLinkWithExpiryDate(file5, expiryDate); restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.onResponse().assertThat().body("entry.expiresAt", org.hamcrest.Matchers.equalTo(expiryDate)); - restClient.onResponse().assertThat().body("entry.path", org.hamcrest.Matchers.notNullValue()); + + Assert.assertEquals(sharedLink5.getExpiresAt(), expiryDate); + Assert.assertNotNull(sharedLink5.getPath(), "Path not expected to be null: Response shows: " + sharedLink5.toJson()); restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().getSharedLinkRenditions(sharedLink5); restClient.assertStatusCodeIs(HttpStatus.OK); From b5b852ce0c3178534714c5565d93c224e86ab62f Mon Sep 17 00:00:00 2001 From: Andrei Forascu Date: Tue, 8 Aug 2017 17:51:27 +0300 Subject: [PATCH 1196/1491] REPO-2365 - GET /shared-links?include=allowableOperations returns 403 for a user that has granular permissions on a shared file: - added a TAS test for the issue --- .../SharedLinks/SharedLinksSanityTests.java | 2 +- .../sharedlinks/GetSharedLinksFullTests.java | 54 +++++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 e2e-test/java/org/alfresco/rest/sharedlinks/GetSharedLinksFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/SharedLinks/SharedLinksSanityTests.java b/e2e-test/java/org/alfresco/rest/SharedLinks/SharedLinksSanityTests.java index c624c0522..8e51ae808 100644 --- a/e2e-test/java/org/alfresco/rest/SharedLinks/SharedLinksSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/SharedLinks/SharedLinksSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.SharedLinks; +package org.alfresco.rest.sharedlinks; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/sharedlinks/GetSharedLinksFullTests.java b/e2e-test/java/org/alfresco/rest/sharedlinks/GetSharedLinksFullTests.java new file mode 100644 index 000000000..e3302c526 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/sharedlinks/GetSharedLinksFullTests.java @@ -0,0 +1,54 @@ +package org.alfresco.rest.sharedlinks; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestSharedLinksModel; +import org.alfresco.rest.model.RestSharedLinksModelCollection; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.exception.DataPreparationException; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class GetSharedLinksFullTests extends RestTest +{ + private SiteModel privateSite; + private UserModel adminUser, userModel; + protected FileModel file; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws DataPreparationException + { + adminUser = dataUser.getAdminUser(); + userModel = dataUser.createRandomTestUser(); + privateSite = dataSite.usingUser(adminUser).createPrivateRandomSite(); + } + + @Bug(id="REPO-2365") + @TestRail(section = { TestGroup.REST_API, + TestGroup.SHAREDLINKS }, executionType = ExecutionType.REGRESSION, description = "Verify that a user with permission can get allowableOperations on sharedLinks") + @Test(groups = { TestGroup.REST_API, TestGroup.SHAREDLINKS, TestGroup.FULL }) + public void getSharedLinksWithAllowableOperations() throws Exception + { + file = dataContent.usingUser(adminUser).usingSite(privateSite).createContent(DocumentType.TEXT_PLAIN); + + RestSharedLinksModel sharedLink = restClient.authenticateUser(adminUser).withCoreAPI().usingSharedLinks().createSharedLink(file); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + dataContent.usingUser(adminUser).usingResource(file).setPermissionsForUser(userModel, UserRole.SiteCollaborator, false); + restClient.authenticateUser(userModel).withCoreAPI().usingNode(file).usingParams("include=permissions").getNode(); + + restClient.authenticateUser(userModel).withCoreAPI().usingSharedLinks().usingParams("include=allowableOperations").getSharedLinks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + restClient.authenticateUser(userModel).withCoreAPI().usingSharedLinks().getSharedLink(sharedLink); + restClient.assertStatusCodeIs(HttpStatus.OK); + } +} From 5e19918e9ce3589a30da230ae7e916c90c8572fc Mon Sep 17 00:00:00 2001 From: Alexandru-Eusebiu Epure Date: Wed, 9 Aug 2017 18:55:40 +0300 Subject: [PATCH 1197/1491] REPO-2365 : Extended Node class with PUT /nodes/{nodeId} (update a node) Refactor getSharedLinksWithAllowableOperations TAS test using PUT /nodes/{nodeId} for creating permission and added a timer (max 15s) for the solr to index the sharedLink. --- .../sharedlinks/GetSharedLinksFullTests.java | 43 ++++++++++++++----- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/sharedlinks/GetSharedLinksFullTests.java b/e2e-test/java/org/alfresco/rest/sharedlinks/GetSharedLinksFullTests.java index e3302c526..40fd83e56 100644 --- a/e2e-test/java/org/alfresco/rest/sharedlinks/GetSharedLinksFullTests.java +++ b/e2e-test/java/org/alfresco/rest/sharedlinks/GetSharedLinksFullTests.java @@ -1,10 +1,12 @@ package org.alfresco.rest.sharedlinks; +import javax.json.Json; +import javax.json.JsonObject; + import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestSharedLinksModel; +import org.alfresco.rest.model.RestNodeModel; import org.alfresco.rest.model.RestSharedLinksModelCollection; -import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; @@ -38,17 +40,36 @@ public class GetSharedLinksFullTests extends RestTest public void getSharedLinksWithAllowableOperations() throws Exception { file = dataContent.usingUser(adminUser).usingSite(privateSite).createContent(DocumentType.TEXT_PLAIN); - - RestSharedLinksModel sharedLink = restClient.authenticateUser(adminUser).withCoreAPI().usingSharedLinks().createSharedLink(file); + + /* + * { "permissions": { "isInheritanceEnabled": true, "locallySet": { "authorityId": "userModel.getUsername()", + * "name": "SiteConsumer", "accessStatus":"ALLOWED" } } } + */ + JsonObject userPermission = Json.createObjectBuilder().add("permissions", + Json.createObjectBuilder().add("isInheritanceEnabled", true).add("locallySet", Json.createObjectBuilder() + .add("authorityId", userModel.getUsername()).add("name", "SiteConsumer").add("accessStatus", "ALLOWED"))) + .build(); + String putBody = userPermission.toString(); + restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file).updateNode(putBody); + restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.authenticateUser(adminUser).withCoreAPI().usingSharedLinks().createSharedLink(file); restClient.assertStatusCodeIs(HttpStatus.CREATED); - dataContent.usingUser(adminUser).usingResource(file).setPermissionsForUser(userModel, UserRole.SiteCollaborator, false); - restClient.authenticateUser(userModel).withCoreAPI().usingNode(file).usingParams("include=permissions").getNode(); + // verify that the permision exists + RestNodeModel permissionsRequest = restClient.authenticateUser(userModel).withCoreAPI().usingNode(file) + .usingParams("include=permissions").getNode(); + permissionsRequest.assertThat().field("permissions.locallySet.authorityId").is("[" + userModel.getUsername() + "]"); - restClient.authenticateUser(userModel).withCoreAPI().usingSharedLinks().usingParams("include=allowableOperations").getSharedLinks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - restClient.authenticateUser(userModel).withCoreAPI().usingSharedLinks().getSharedLink(sharedLink); - restClient.assertStatusCodeIs(HttpStatus.OK); + // because the sharedLink take time to be created, we may need to wait for solr to index it. + int numberOfTries = 0; + RestSharedLinksModelCollection operationsRequest; + do + { + Thread.sleep(1000); + numberOfTries++; + operationsRequest = restClient.authenticateUser(userModel).withCoreAPI().usingSharedLinks().usingParams("include=allowableOperations").getSharedLinks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } while (operationsRequest.getPagination().getCount() == 0 && numberOfTries < 15); + operationsRequest.getPagination().assertThat().field("count").is(1); } } From 7479648c1fac8b4c28b8e8d5c733e7f16e34246d Mon Sep 17 00:00:00 2001 From: Raluca Munteanu Date: Wed, 9 Aug 2017 11:33:18 +0300 Subject: [PATCH 1198/1491] REPO-2369: Removed negative tests from SANITY group. --- .../rest/comments/AddCommentSanityTests.java | 4 ++-- .../rest/comments/AddCommentsSanityTests.java | 2 +- .../rest/comments/DeleteCommentSanityTests.java | 2 +- .../rest/comments/UpdateCommentSanityTests.java | 6 +++--- .../favorites/DeleteFavoriteSiteSanityTests.java | 2 +- .../rest/favorites/GetFavoriteSanityTests.java | 6 +++--- .../rest/favorites/GetFavoriteSiteSanityTests.java | 2 +- .../rest/favorites/GetFavoriteSitesSanityTests.java | 8 ++++---- .../rest/favorites/GetFavoritesSanityTests.java | 6 +++--- .../alfresco/rest/people/GetPeopleSanityTests.java | 2 +- .../rest/sites/members/AddSiteMemberSanityTests.java | 6 +++--- .../UpdateSiteMembershipRequestSanityTests.java | 12 ++++++------ .../org/alfresco/rest/tags/UpdateTagSanityTests.java | 8 ++++---- .../alfresco/rest/tags/nodes/AddTagSanityTests.java | 4 ++-- .../alfresco/rest/tags/nodes/AddTagsSanityTests.java | 4 ++-- .../rest/tags/nodes/DeleteTagSanityTests.java | 4 ++-- 16 files changed, 39 insertions(+), 39 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java index 1b7c44974..4cf540c8e 100644 --- a/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java @@ -63,7 +63,7 @@ public class AddCommentSanityTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Contributor user adds comments with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS }) @Bug(id="ACE-4614") public void contributorIsAbleToAddComment() throws JsonToModelConversionException, Exception { @@ -89,7 +89,7 @@ public class AddCommentSanityTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Consumer user can't add comments with Rest API and status code is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS }) public void consumerIsNotAbleToAddComment() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java index 5ec6167e1..5022d7dd6 100644 --- a/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java @@ -102,7 +102,7 @@ public class AddCommentsSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Consumer user adds multiple comments with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS }) public void consumerIsAbleToAddComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) diff --git a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentSanityTests.java index aecc7fd06..dc9381aa2 100644 --- a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentSanityTests.java @@ -83,7 +83,7 @@ public class DeleteCommentSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Consumer user cannot delete comments and status code returned is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS }) public void consumerIsNotAbleToDeleteComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); diff --git a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentSanityTests.java index c724ef6e3..7c360b527 100644 --- a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentSanityTests.java @@ -76,7 +76,7 @@ public class UpdateCommentSanityTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Consumer user can not update comments created by admin user and status code is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS }) public void consumerIsNotAbleToUpdateComment() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); @@ -113,7 +113,7 @@ public class UpdateCommentSanityTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify update comment with inexistent nodeId returns status code 404") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS }) public void canNotUpdateCommentIfNodeIdIsNotSet() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); @@ -127,7 +127,7 @@ public class UpdateCommentSanityTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify if commentId is not set the status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS }) public void canNotUpdateCommentIfCommentIdIsNotSet() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); diff --git a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteSiteSanityTests.java index 387c2845c..43598e19c 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteSiteSanityTests.java @@ -133,7 +133,7 @@ public class DeleteFavoriteSiteSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify a user removes a site from another user's favorite sites list with Rest API and response is permission denied (403)") public void userRemovesAnotherUserFavoriteSiteWithSuccess() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java index e0c4e61c8..cde2cb9ae 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java @@ -242,7 +242,7 @@ public class GetFavoriteSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify user doesn't get favorite site of another user with Rest API and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES }) public void userIsNotAbleToRetrieveFavoriteSiteOfAnotherUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); @@ -255,7 +255,7 @@ public class GetFavoriteSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify user doesn't get favorite site of admin user with Rest API and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES }) public void userIsNotAbleToRetrieveFavoritesOfAdminUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) @@ -267,7 +267,7 @@ public class GetFavoriteSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify admin user doesn't get favorite site of another user with Rest API and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES }) public void adminIsNotAbleToRetrieveFavoritesOfAnotherUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel).withCoreAPI() diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSiteSanityTests.java index cbd1bb91f..eaee26af5 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSiteSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSiteSanityTests.java @@ -106,7 +106,7 @@ public class GetFavoriteSiteSanityTests extends RestTest restSiteModel.assertThat().field("id").is(siteModel1.getId()).and().field("title").isNotNull(); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user fails to get specific favorite site of another user with Rest API and response is successful (403)") public void managerUserFailsToGetFavoriteSiteOfAnotherUser() throws Exception { diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSitesSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSitesSanityTests.java index 654ddc26f..fdac3c266 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSitesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSitesSanityTests.java @@ -27,7 +27,7 @@ public class GetFavoriteSitesSanityTests extends RestTest siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user fails to get an user favorite sites with Rest API (403)") public void managerUserFailsToGetAnUserFavoriteSites() throws Exception { @@ -40,7 +40,7 @@ public class GetFavoriteSitesSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify collaborator user fails to get an user favorite sites with Rest API (403)") public void collaboratorUserFailsToGetAnUserFavoriteSites() throws Exception { @@ -54,7 +54,7 @@ public class GetFavoriteSitesSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify contributor user fails to get an user favorite sites with Rest API (403)") public void contributorUserFailsToGetAnUserFavoriteSites() throws Exception { @@ -68,7 +68,7 @@ public class GetFavoriteSitesSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify consumer user fails to get an user favorite sites with Rest API (403)") public void consumerUserFailsToGetAnUserFavoriteSites() throws Exception { diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java index c27b699fe..3cca0d5a1 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java @@ -151,7 +151,7 @@ public class GetFavoritesSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify user doesn't have permission to get favorites of another user with Rest API and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES }) public void userIsNotAbleToRetrieveFavoritesOfAnotherUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) @@ -162,7 +162,7 @@ public class GetFavoritesSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify user doesn't have permission to get favorites of admin user with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES }) public void userIsNotAbleToRetrieveFavoritesOfAdminUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI() @@ -173,7 +173,7 @@ public class GetFavoritesSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify admin user doesn't have permission to get favorites of another user with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES }) public void adminIsNotAbleToRetrieveFavoritesOfAnotherUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleSanityTests.java index acbc56c40..2678895a5 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleSanityTests.java @@ -96,7 +96,7 @@ public class GetPeopleSanityTests extends RestTest ; } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user gets a non existing person with Rest API and person is not found") public void managerUserChecksIfNonExistingPersonIsPresent() throws Exception { diff --git a/e2e-test/java/org/alfresco/rest/sites/members/AddSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/members/AddSiteMemberSanityTests.java index e13bb0ca1..3d4563b7b 100644 --- a/e2e-test/java/org/alfresco/rest/sites/members/AddSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/members/AddSiteMemberSanityTests.java @@ -47,7 +47,7 @@ public class AddSiteMemberSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.CREATED); } - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.SITES }) @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that site collaborator is not able to add site member and gets status code FORBIDDEN (403)") public void collaboratorIsNotAbleToAddSiteMember() throws Exception @@ -61,7 +61,7 @@ public class AddSiteMemberSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); } - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.SITES }) @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that site contributor is not able to add site member and gets status code FORBIDDEN (403)") public void contributorIsNotAbleToAddSiteMember() throws Exception @@ -74,7 +74,7 @@ public class AddSiteMemberSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); } - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.SITES }) @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that site consumer is not able to add site member and gets status code FORBIDDEN (403)") public void consumerIsNotAbleToAddSiteMember() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/sites/membershipRequests/UpdateSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/UpdateSiteMembershipRequestSanityTests.java index 4027d8e48..b4474ce5f 100644 --- a/e2e-test/java/org/alfresco/rest/sites/membershipRequests/UpdateSiteMembershipRequestSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/UpdateSiteMembershipRequestSanityTests.java @@ -48,7 +48,7 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site manager is not able to update membership request of another user") // @Bug(id = "MNT-16919", description = "Not a bug, The presence of the personId in the URL does not mean it should be possible to act on any other users behalf.") public void siteManagerIsNotAbleToUpdateSiteMembershipRequestOfAnotherUser() throws JsonToModelConversionException, Exception @@ -64,7 +64,7 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site collaborator is not able to update membership request of another user") // @Bug(id = "MNT-16919", description = "Not a bug, The presence of the personId in the URL does not mean it should be possible to act on any other users behalf.") public void siteCollaboratorIsNotAbleToUpdateSiteMembershipRequestOfAnotherUser() throws JsonToModelConversionException, Exception @@ -80,7 +80,7 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site contributor is not able to update membership request of another user") // @Bug(id = "MNT-16919", description = "Not a bug, The presence of the personId in the URL does not mean it should be possible to act on any other users behalf.") public void siteContributorIsNotAbleToUpdateSiteMembershipRequestOfAnotherUser() throws JsonToModelConversionException, Exception @@ -96,7 +96,7 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site consumer is not able to update membership request of another user") // @Bug(id = "MNT-16919", description = "Not a bug, The presence of the personId in the URL does not mean it should be possible to act on any other users behalf.") public void siteConsumerIsNotAbleToUpdateSiteMembershipRequestOfAnotherUser() throws JsonToModelConversionException, Exception @@ -112,7 +112,7 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify one user is not able to update membership request of another user") // @Bug(id = "MNT-16919", description = "Not a bug, The presence of the personId in the URL does not mean it should be possible to act on any other users behalf.") public void oneUserIsNotAbleToUpdateSiteMembershipRequestOfAnotherUser() throws JsonToModelConversionException, Exception @@ -128,7 +128,7 @@ public class UpdateSiteMembershipRequestSanityTests extends RestTest .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify admin is not able to update membership request of another user") // @Bug(id = "MNT-16919", description = "Not a bug, The presence of the personId in the URL does not mean it should be possible to act on any other users behalf.") public void adminIsNotAbleToUpdateSiteMembershipRequestOfAnotherUser() throws JsonToModelConversionException, Exception diff --git a/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java index 4b6bb81ae..3361d9a54 100644 --- a/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java @@ -63,7 +63,7 @@ public class UpdateTagSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Manager user can't update tags with Rest API and status code is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS }) public void managerIsNotAbleToUpdateTag() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); @@ -73,7 +73,7 @@ public class UpdateTagSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user can't update tags with Rest API and status code is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS }) public void collaboratorIsNotAbleToUpdateTagCheckDefaultErrorModelSchema() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); @@ -86,7 +86,7 @@ public class UpdateTagSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Contributor user can't update tags with Rest API and status code is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS }) public void contributorIsNotAbleToUpdateTag() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); @@ -96,7 +96,7 @@ public class UpdateTagSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Consumer user can't update tags with Rest API and status code is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS }) public void consumerIsNotAbleToUpdateTag() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); diff --git a/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagSanityTests.java index 623d675c3..94447b432 100644 --- a/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagSanityTests.java @@ -86,7 +86,7 @@ public class AddTagSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Contributor user doesn't have permission to add tags with Rest API and status code is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS }) public void contributorIsNotAbleToAddTagToAnotherContent() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); @@ -110,7 +110,7 @@ public class AddTagSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Consumer user doesn't have permission to add tags with Rest API and status code is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS }) public void consumerIsNotAbleToAddTag() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); diff --git a/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagsSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagsSanityTests.java index c63150703..955f714c7 100644 --- a/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagsSanityTests.java @@ -87,7 +87,7 @@ public class AddTagsSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Contributor user doesn't have permission to add multiple tags with Rest API and status code is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS }) public void contributorIsNotAbleToAddTagsToAnotherContent() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); @@ -111,7 +111,7 @@ public class AddTagsSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Consumer user doesn't have permission to add multiple tags with Rest API and status code is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS }) public void consumerIsNotAbleToAddTags() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingResource(document).addTags(tag1, tag2); diff --git a/e2e-test/java/org/alfresco/rest/tags/nodes/DeleteTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/nodes/DeleteTagSanityTests.java index 1f59a671b..ac2eaae88 100644 --- a/e2e-test/java/org/alfresco/rest/tags/nodes/DeleteTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/nodes/DeleteTagSanityTests.java @@ -79,7 +79,7 @@ public class DeleteTagSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Contributor user can't delete tags created by admin user with Rest API and status code is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS }) public void contributorIsNotAbleToDeleteTagsForAnotherUserContent() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); @@ -106,7 +106,7 @@ public class DeleteTagSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Consumer user can't delete tags created by admin user with Rest API and status code is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS }) public void consumerIsNotAbleToDeleteTags() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); From cdef522d4fa410e043c30e641a3d5bb3b91d080d Mon Sep 17 00:00:00 2001 From: Andreea Nechifor Date: Thu, 10 Aug 2017 10:02:43 +0300 Subject: [PATCH 1199/1491] REPO-1858 --- .../people/GetAvatarPeopleSanityTest.java | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/people/GetAvatarPeopleSanityTest.java diff --git a/e2e-test/java/org/alfresco/rest/people/GetAvatarPeopleSanityTest.java b/e2e-test/java/org/alfresco/rest/people/GetAvatarPeopleSanityTest.java new file mode 100644 index 000000000..8f6bc81f4 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/people/GetAvatarPeopleSanityTest.java @@ -0,0 +1,56 @@ +package org.alfresco.rest.people; + +import java.io.File; + +import org.alfresco.rest.RestTest; +import org.alfresco.utility.Utility; +import org.alfresco.utility.exception.DataPreparationException; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class GetAvatarPeopleSanityTest extends RestTest { + + private UserModel userModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws DataPreparationException { + userModel = dataUser.createRandomTestUser(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Update Avatar for People") + public void updateGetAvatarForPeople() throws Exception { + + File avatarFile = Utility.getResourceTestDataFile("avatar.jpg"); + restClient.authenticateUser(userModel); + restClient.withCoreAPI().usingAuthUser() + .uploadAvatarContent(restProperties.envProperty().getFullServerUrl(), avatarFile).statusCode(200); + restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().downloadAvatarContent(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Update Avatar for People") + public void removeGetAvatarForPeople() throws Exception { + File avatarFile = Utility.getResourceTestDataFile("avatar.jpg"); + restClient.authenticateUser(userModel); + restClient.withCoreAPI().usingAuthUser() + .uploadAvatarContent(restProperties.envProperty().getFullServerUrl(), avatarFile).statusCode(200); + + restClient.authenticateUser(userModel); + restClient.withCoreAPI().usingAuthUser().resetAvatarImageRequest(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().downloadAvatarContent(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } + +} From fed62445767c87b618de4321c490d56123f86708 Mon Sep 17 00:00:00 2001 From: Andreea Nechifor Date: Thu, 10 Aug 2017 16:12:26 +0300 Subject: [PATCH 1200/1491] problem init dataPreparation --- e2e-test/java/org/alfresco/rest/audit/AuditTest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/e2e-test/java/org/alfresco/rest/audit/AuditTest.java b/e2e-test/java/org/alfresco/rest/audit/AuditTest.java index a64f4147f..535e277e6 100644 --- a/e2e-test/java/org/alfresco/rest/audit/AuditTest.java +++ b/e2e-test/java/org/alfresco/rest/audit/AuditTest.java @@ -51,6 +51,7 @@ public abstract class AuditTest extends RestTest { //Audit API is designed for users with admin rights (except /nodes/{nodeId}/audit-entries) //Create users and add userModel as SiteCollaborator on private site + privateTestSite = dataSite.createPrivateRandomSite(); userModel = dataUser.createRandomTestUser(); userModel1 = dataUser.createRandomTestUser(); adminUser = dataUser.getAdminUser(); From 77209423e6b6ef554cbd650b7b30e9e3507352bb Mon Sep 17 00:00:00 2001 From: Alexandru-Eusebiu Epure Date: Thu, 10 Aug 2017 17:30:08 +0300 Subject: [PATCH 1201/1491] REPO-1821 : Avatar REST API Rename GetAvatarPeopleSanityTest.java to AvatarPeopleSanityTests.java because this class contains GET/PUT/POST /people/{personId}/avatar requests. Format the code avatar API specific code (Tests+requests). --- .../rest/people/AvatarPeopleSanityTest.java | 57 +++++++++++++++++++ .../people/GetAvatarPeopleSanityTest.java | 56 ------------------ e2e-test/resources/default.properties | 2 +- 3 files changed, 58 insertions(+), 57 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/people/AvatarPeopleSanityTest.java delete mode 100644 e2e-test/java/org/alfresco/rest/people/GetAvatarPeopleSanityTest.java diff --git a/e2e-test/java/org/alfresco/rest/people/AvatarPeopleSanityTest.java b/e2e-test/java/org/alfresco/rest/people/AvatarPeopleSanityTest.java new file mode 100644 index 000000000..709dc6ce1 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/people/AvatarPeopleSanityTest.java @@ -0,0 +1,57 @@ +package org.alfresco.rest.people; + +import java.io.File; + +import org.alfresco.rest.RestTest; +import org.alfresco.utility.Utility; +import org.alfresco.utility.exception.DataPreparationException; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class AvatarPeopleSanityTest extends RestTest { + + private UserModel userModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws DataPreparationException + { + userModel = dataUser.createRandomTestUser(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Update Avatar for People") + public void updateGetAvatarForPeople() throws Exception + { + + File avatarFile = Utility.getResourceTestDataFile("avatar.jpg"); + restClient.authenticateUser(userModel); + restClient.withCoreAPI().usingAuthUser().uploadAvatarContent(restProperties.envProperty().getFullServerUrl(), avatarFile).statusCode(200); + restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().downloadAvatarContent(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Update Avatar for People") + public void removeGetAvatarForPeople() throws Exception + { + File avatarFile = Utility.getResourceTestDataFile("avatar.jpg"); + restClient.authenticateUser(userModel); + restClient.withCoreAPI().usingAuthUser().uploadAvatarContent(restProperties.envProperty().getFullServerUrl(), avatarFile).statusCode(200); + + restClient.authenticateUser(userModel); + restClient.withCoreAPI().usingAuthUser().resetAvatarImageRequest(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().downloadAvatarContent(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } + +} diff --git a/e2e-test/java/org/alfresco/rest/people/GetAvatarPeopleSanityTest.java b/e2e-test/java/org/alfresco/rest/people/GetAvatarPeopleSanityTest.java deleted file mode 100644 index 8f6bc81f4..000000000 --- a/e2e-test/java/org/alfresco/rest/people/GetAvatarPeopleSanityTest.java +++ /dev/null @@ -1,56 +0,0 @@ -package org.alfresco.rest.people; - -import java.io.File; - -import org.alfresco.rest.RestTest; -import org.alfresco.utility.Utility; -import org.alfresco.utility.exception.DataPreparationException; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class GetAvatarPeopleSanityTest extends RestTest { - - private UserModel userModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws DataPreparationException { - userModel = dataUser.createRandomTestUser(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Update Avatar for People") - public void updateGetAvatarForPeople() throws Exception { - - File avatarFile = Utility.getResourceTestDataFile("avatar.jpg"); - restClient.authenticateUser(userModel); - restClient.withCoreAPI().usingAuthUser() - .uploadAvatarContent(restProperties.envProperty().getFullServerUrl(), avatarFile).statusCode(200); - restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().downloadAvatarContent(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Update Avatar for People") - public void removeGetAvatarForPeople() throws Exception { - File avatarFile = Utility.getResourceTestDataFile("avatar.jpg"); - restClient.authenticateUser(userModel); - restClient.withCoreAPI().usingAuthUser() - .uploadAvatarContent(restProperties.envProperty().getFullServerUrl(), avatarFile).statusCode(200); - - restClient.authenticateUser(userModel); - restClient.withCoreAPI().usingAuthUser().resetAvatarImageRequest(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().downloadAvatarContent(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } - -} diff --git a/e2e-test/resources/default.properties b/e2e-test/resources/default.properties index 2e4c58893..c195a6344 100644 --- a/e2e-test/resources/default.properties +++ b/e2e-test/resources/default.properties @@ -1,6 +1,6 @@ # dataprep related alfresco.scheme=http -alfresco.server=localhost +alfresco.server=172.29.100.209 alfresco.port=8080 # credentials From 4a83f15bdb599c7265617b00e1df8323b4009136 Mon Sep 17 00:00:00 2001 From: Alexandru-Eusebiu Epure Date: Fri, 11 Aug 2017 14:44:26 +0300 Subject: [PATCH 1202/1491] REPO-2365 : GET /shared-links?include=allowableOperations returns 403 Remove GetSharedLinksFullTests.java and SharedLinksSanityTests.java, because they are in different packages (will add them in the next commit). --- .../SharedLinks/SharedLinksSanityTests.java | 167 ------------------ .../sharedlinks/GetSharedLinksFullTests.java | 75 -------- 2 files changed, 242 deletions(-) delete mode 100644 e2e-test/java/org/alfresco/rest/SharedLinks/SharedLinksSanityTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/sharedlinks/GetSharedLinksFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/SharedLinks/SharedLinksSanityTests.java b/e2e-test/java/org/alfresco/rest/SharedLinks/SharedLinksSanityTests.java deleted file mode 100644 index 8e51ae808..000000000 --- a/e2e-test/java/org/alfresco/rest/SharedLinks/SharedLinksSanityTests.java +++ /dev/null @@ -1,167 +0,0 @@ -package org.alfresco.rest.sharedlinks; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestSharedLinksModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.Assert; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Class includes Sanity tests for the shared-links api. Detailed tests would be covered in the alfresco-remote-api test project - * - * @author meenal bhave - */ -public class SharedLinksSanityTests extends RestTest -{ - private UserModel adminUser; - private UserModel testUser1; - - private SiteModel siteModel1; - - private FolderModel folder1; - - private FileModel file1; - private FileModel file2; - private FileModel file3; - private FileModel file4; - private FileModel file5; - - private RestSharedLinksModel sharedLink1; - private RestSharedLinksModel sharedLink2; - private RestSharedLinksModel sharedLink3; - private RestSharedLinksModel sharedLink4; - private RestSharedLinksModel sharedLink5; - - private String expiryDate = "2027-03-23T23:00:00.000+0000"; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - - adminUser = dataUser.getAdminUser(); - restClient.authenticateUser(adminUser); - - // Create Standard User - testUser1 = dataUser.usingUser(adminUser).createRandomTestUser(); - - // Create Site - siteModel1 = dataSite.usingUser(testUser1).createPublicRandomSite(); - - folder1 = dataContent.usingUser(adminUser).usingSite(siteModel1).createFolder(); - - file1 = dataContent.usingUser(adminUser).usingResource(folder1).createContent(DocumentType.TEXT_PLAIN); - file2 = dataContent.usingUser(adminUser).usingResource(folder1).createContent(DocumentType.TEXT_PLAIN); - file3 = dataContent.usingUser(adminUser).usingResource(folder1).createContent(DocumentType.TEXT_PLAIN); - file4 = dataContent.usingUser(adminUser).usingResource(folder1).createContent(DocumentType.TEXT_PLAIN); - file5 = dataContent.usingUser(adminUser).usingResource(folder1).createContent(DocumentType.TEXT_PLAIN); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.SHAREDLINKS }, executionType = ExecutionType.REGRESSION, description = "Verify empty sharedLinks with and without Path") - @Test(groups = { TestGroup.REST_API, TestGroup.SHAREDLINKS }) - public void testGetSharedLinksNoLinks() throws Exception - { - restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().getSharedLinks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - restClient.authenticateUser(testUser1).withCoreAPI().includePath().usingSharedLinks().getSharedLinks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.SHAREDLINKS }, executionType = ExecutionType.REGRESSION, description = "Verify create sharedLinks with and without Path") - @Test(groups = { TestGroup.REST_API, TestGroup.SHAREDLINKS }) - public void testCreateAndGetSharedLinks() throws Exception - { - // Post without includePath - sharedLink1 = restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().createSharedLink(file1); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.onResponse().assertThat().body("entry.nodeId", org.hamcrest.Matchers.equalTo(file1.getNodeRefWithoutVersion())); - restClient.onResponse().assertThat().body("entry.name", org.hamcrest.Matchers.equalTo(file1.getName())); - restClient.onResponse().assertThat().body("entry.id", org.hamcrest.Matchers.equalTo(sharedLink1.getId())); - restClient.onResponse().assertThat().body("entry.path", org.hamcrest.Matchers.nullValue()); - - // Same Checks above using sharedLink methods: GET sharedLink: without includePath - Assert.assertEquals(sharedLink1.getNodeId(), file1.getNodeRefWithoutVersion()); - Assert.assertEquals(sharedLink1.getName(), file1.getName()); - Assert.assertNull(sharedLink1.getPath(), "Path is expected to be null for noauth api: Response shows: " + sharedLink1.toJson()); - - // Get without includePath - restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().getSharedLink(sharedLink1); - restClient.onResponse().assertThat().body("entry.nodeId", org.hamcrest.Matchers.equalTo(file1.getNodeRefWithoutVersion())); - restClient.onResponse().assertThat().body("entry.name", org.hamcrest.Matchers.equalTo(file1.getName())); - restClient.onResponse().assertThat().body("entry.id", org.hamcrest.Matchers.equalTo(sharedLink1.getId())); - restClient.onResponse().assertThat().body("entry.path", org.hamcrest.Matchers.nullValue()); - - // Post with includePath - sharedLink2 = restClient.authenticateUser(testUser1).withCoreAPI().includePath().usingSharedLinks().createSharedLink(file2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.onResponse().assertThat().body("entry.nodeId", org.hamcrest.Matchers.equalTo(file2.getNodeRefWithoutVersion())); - restClient.onResponse().assertThat().body("entry.name", org.hamcrest.Matchers.equalTo(file2.getName())); - restClient.onResponse().assertThat().body("entry.id", org.hamcrest.Matchers.equalTo(sharedLink2.getId())); - restClient.onResponse().assertThat().body("entry.path", org.hamcrest.Matchers.notNullValue()); - - // Same Checks above using sharedLink methods: POST sharedLink: includePath - Assert.assertEquals(sharedLink2.getNodeId(), file2.getNodeRefWithoutVersion()); - Assert.assertEquals(sharedLink2.getName(), file2.getName()); - Assert.assertNotNull(sharedLink2.getPath(), "Path not expected to be null for noauth api: Response shows: " + sharedLink1.toJson()); - - // Get with includePath - restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().getSharedLink(sharedLink2); - restClient.onResponse().assertThat().body("entry.nodeId", org.hamcrest.Matchers.equalTo(file2.getNodeRefWithoutVersion())); - restClient.onResponse().assertThat().body("entry.name", org.hamcrest.Matchers.equalTo(file2.getName())); - restClient.onResponse().assertThat().body("entry.id", org.hamcrest.Matchers.equalTo(sharedLink2.getId())); - // Verify that path is null since includePath is not supported for this noAuth api - restClient.onResponse().assertThat().body("entry.path", org.hamcrest.Matchers.nullValue()); - - // Get: noAuth with includePath - sharedLink2 = restClient.withCoreAPI().usingSharedLinks().getSharedLink(sharedLink2); - restClient.onResponse().assertThat().body("entry.nodeId", org.hamcrest.Matchers.equalTo(file2.getNodeRefWithoutVersion())); - restClient.onResponse().assertThat().body("entry.name", org.hamcrest.Matchers.equalTo(file2.getName())); - restClient.onResponse().assertThat().body("entry.id", org.hamcrest.Matchers.equalTo(sharedLink2.getId())); - // Verify that path is null since includePath is not supported for this noAuth api - restClient.onResponse().assertThat().body("entry.path", org.hamcrest.Matchers.nullValue()); - - // Same Checks above using sharedLink methods: GET sharedLink: noAuth - Assert.assertEquals(sharedLink2.getNodeId(), file2.getNodeRefWithoutVersion()); - Assert.assertEquals(sharedLink2.getName(), file2.getName()); - Assert.assertNull(sharedLink2.getPath(), "Path is expected to be null for noauth api: Response shows: " + sharedLink2.toJson()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.SHAREDLINKS }, executionType = ExecutionType.REGRESSION, description = "Verify delete sharedLinks with and without Path") - @Test(groups = { TestGroup.REST_API, TestGroup.SHAREDLINKS }) - public void testDeleteSharedLinks() throws Exception - { - sharedLink3 = restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().createSharedLink(file3); - restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().deleteSharedLink(sharedLink3); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - sharedLink4 = restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().createSharedLink(file4); - restClient.authenticateUser(testUser1).withCoreAPI().includePath().usingSharedLinks().deleteSharedLink(sharedLink4); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.SHAREDLINKS }, executionType = ExecutionType.REGRESSION, description = "Verify get sharedLink/content and get/renditions") - @Test(groups = { TestGroup.REST_API, TestGroup.SHAREDLINKS }) - public void testCreateWithExpiryDateAndGetSharedLinkRendition() throws Exception - { - sharedLink5 = restClient.authenticateUser(testUser1).withCoreAPI().includePath().usingSharedLinks().createSharedLinkWithExpiryDate(file5, expiryDate); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - Assert.assertEquals(sharedLink5.getExpiresAt(), expiryDate); - Assert.assertNotNull(sharedLink5.getPath(), "Path not expected to be null: Response shows: " + sharedLink5.toJson()); - - restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().getSharedLinkRenditions(sharedLink5); - restClient.assertStatusCodeIs(HttpStatus.OK); - - restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().getSharedLinkRendition(sharedLink5, "doclib"); - restClient.assertStatusCodeIs(HttpStatus.OK); - } -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/sharedlinks/GetSharedLinksFullTests.java b/e2e-test/java/org/alfresco/rest/sharedlinks/GetSharedLinksFullTests.java deleted file mode 100644 index 40fd83e56..000000000 --- a/e2e-test/java/org/alfresco/rest/sharedlinks/GetSharedLinksFullTests.java +++ /dev/null @@ -1,75 +0,0 @@ -package org.alfresco.rest.sharedlinks; - -import javax.json.Json; -import javax.json.JsonObject; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestNodeModel; -import org.alfresco.rest.model.RestSharedLinksModelCollection; -import org.alfresco.utility.exception.DataPreparationException; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class GetSharedLinksFullTests extends RestTest -{ - private SiteModel privateSite; - private UserModel adminUser, userModel; - protected FileModel file; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws DataPreparationException - { - adminUser = dataUser.getAdminUser(); - userModel = dataUser.createRandomTestUser(); - privateSite = dataSite.usingUser(adminUser).createPrivateRandomSite(); - } - - @Bug(id="REPO-2365") - @TestRail(section = { TestGroup.REST_API, - TestGroup.SHAREDLINKS }, executionType = ExecutionType.REGRESSION, description = "Verify that a user with permission can get allowableOperations on sharedLinks") - @Test(groups = { TestGroup.REST_API, TestGroup.SHAREDLINKS, TestGroup.FULL }) - public void getSharedLinksWithAllowableOperations() throws Exception - { - file = dataContent.usingUser(adminUser).usingSite(privateSite).createContent(DocumentType.TEXT_PLAIN); - - /* - * { "permissions": { "isInheritanceEnabled": true, "locallySet": { "authorityId": "userModel.getUsername()", - * "name": "SiteConsumer", "accessStatus":"ALLOWED" } } } - */ - JsonObject userPermission = Json.createObjectBuilder().add("permissions", - Json.createObjectBuilder().add("isInheritanceEnabled", true).add("locallySet", Json.createObjectBuilder() - .add("authorityId", userModel.getUsername()).add("name", "SiteConsumer").add("accessStatus", "ALLOWED"))) - .build(); - String putBody = userPermission.toString(); - restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file).updateNode(putBody); - restClient.assertStatusCodeIs(HttpStatus.OK); - restClient.authenticateUser(adminUser).withCoreAPI().usingSharedLinks().createSharedLink(file); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - // verify that the permision exists - RestNodeModel permissionsRequest = restClient.authenticateUser(userModel).withCoreAPI().usingNode(file) - .usingParams("include=permissions").getNode(); - permissionsRequest.assertThat().field("permissions.locallySet.authorityId").is("[" + userModel.getUsername() + "]"); - - // because the sharedLink take time to be created, we may need to wait for solr to index it. - int numberOfTries = 0; - RestSharedLinksModelCollection operationsRequest; - do - { - Thread.sleep(1000); - numberOfTries++; - operationsRequest = restClient.authenticateUser(userModel).withCoreAPI().usingSharedLinks().usingParams("include=allowableOperations").getSharedLinks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } while (operationsRequest.getPagination().getCount() == 0 && numberOfTries < 15); - operationsRequest.getPagination().assertThat().field("count").is(1); - } -} From ea2972bb19ba5524775c8146031b678150a714b6 Mon Sep 17 00:00:00 2001 From: Alexandru-Eusebiu Epure Date: Fri, 11 Aug 2017 14:47:23 +0300 Subject: [PATCH 1203/1491] REPO-2365 : GET /shared-links?include=allowableOperations returns 403 Added GetSharedLinksFullTests.java and SharedLinksSanityTests.java in the same folder and package. --- .../sharedlinks/GetSharedLinksFullTests.java | 75 ++++++++ .../sharedlinks/SharedLinksSanityTests.java | 167 ++++++++++++++++++ 2 files changed, 242 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/sharedlinks/GetSharedLinksFullTests.java create mode 100644 e2e-test/java/org/alfresco/rest/sharedlinks/SharedLinksSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/sharedlinks/GetSharedLinksFullTests.java b/e2e-test/java/org/alfresco/rest/sharedlinks/GetSharedLinksFullTests.java new file mode 100644 index 000000000..40fd83e56 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/sharedlinks/GetSharedLinksFullTests.java @@ -0,0 +1,75 @@ +package org.alfresco.rest.sharedlinks; + +import javax.json.Json; +import javax.json.JsonObject; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestNodeModel; +import org.alfresco.rest.model.RestSharedLinksModelCollection; +import org.alfresco.utility.exception.DataPreparationException; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class GetSharedLinksFullTests extends RestTest +{ + private SiteModel privateSite; + private UserModel adminUser, userModel; + protected FileModel file; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws DataPreparationException + { + adminUser = dataUser.getAdminUser(); + userModel = dataUser.createRandomTestUser(); + privateSite = dataSite.usingUser(adminUser).createPrivateRandomSite(); + } + + @Bug(id="REPO-2365") + @TestRail(section = { TestGroup.REST_API, + TestGroup.SHAREDLINKS }, executionType = ExecutionType.REGRESSION, description = "Verify that a user with permission can get allowableOperations on sharedLinks") + @Test(groups = { TestGroup.REST_API, TestGroup.SHAREDLINKS, TestGroup.FULL }) + public void getSharedLinksWithAllowableOperations() throws Exception + { + file = dataContent.usingUser(adminUser).usingSite(privateSite).createContent(DocumentType.TEXT_PLAIN); + + /* + * { "permissions": { "isInheritanceEnabled": true, "locallySet": { "authorityId": "userModel.getUsername()", + * "name": "SiteConsumer", "accessStatus":"ALLOWED" } } } + */ + JsonObject userPermission = Json.createObjectBuilder().add("permissions", + Json.createObjectBuilder().add("isInheritanceEnabled", true).add("locallySet", Json.createObjectBuilder() + .add("authorityId", userModel.getUsername()).add("name", "SiteConsumer").add("accessStatus", "ALLOWED"))) + .build(); + String putBody = userPermission.toString(); + restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file).updateNode(putBody); + restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.authenticateUser(adminUser).withCoreAPI().usingSharedLinks().createSharedLink(file); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + // verify that the permision exists + RestNodeModel permissionsRequest = restClient.authenticateUser(userModel).withCoreAPI().usingNode(file) + .usingParams("include=permissions").getNode(); + permissionsRequest.assertThat().field("permissions.locallySet.authorityId").is("[" + userModel.getUsername() + "]"); + + // because the sharedLink take time to be created, we may need to wait for solr to index it. + int numberOfTries = 0; + RestSharedLinksModelCollection operationsRequest; + do + { + Thread.sleep(1000); + numberOfTries++; + operationsRequest = restClient.authenticateUser(userModel).withCoreAPI().usingSharedLinks().usingParams("include=allowableOperations").getSharedLinks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } while (operationsRequest.getPagination().getCount() == 0 && numberOfTries < 15); + operationsRequest.getPagination().assertThat().field("count").is(1); + } +} diff --git a/e2e-test/java/org/alfresco/rest/sharedlinks/SharedLinksSanityTests.java b/e2e-test/java/org/alfresco/rest/sharedlinks/SharedLinksSanityTests.java new file mode 100644 index 000000000..8e51ae808 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/sharedlinks/SharedLinksSanityTests.java @@ -0,0 +1,167 @@ +package org.alfresco.rest.sharedlinks; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestSharedLinksModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Class includes Sanity tests for the shared-links api. Detailed tests would be covered in the alfresco-remote-api test project + * + * @author meenal bhave + */ +public class SharedLinksSanityTests extends RestTest +{ + private UserModel adminUser; + private UserModel testUser1; + + private SiteModel siteModel1; + + private FolderModel folder1; + + private FileModel file1; + private FileModel file2; + private FileModel file3; + private FileModel file4; + private FileModel file5; + + private RestSharedLinksModel sharedLink1; + private RestSharedLinksModel sharedLink2; + private RestSharedLinksModel sharedLink3; + private RestSharedLinksModel sharedLink4; + private RestSharedLinksModel sharedLink5; + + private String expiryDate = "2027-03-23T23:00:00.000+0000"; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + + adminUser = dataUser.getAdminUser(); + restClient.authenticateUser(adminUser); + + // Create Standard User + testUser1 = dataUser.usingUser(adminUser).createRandomTestUser(); + + // Create Site + siteModel1 = dataSite.usingUser(testUser1).createPublicRandomSite(); + + folder1 = dataContent.usingUser(adminUser).usingSite(siteModel1).createFolder(); + + file1 = dataContent.usingUser(adminUser).usingResource(folder1).createContent(DocumentType.TEXT_PLAIN); + file2 = dataContent.usingUser(adminUser).usingResource(folder1).createContent(DocumentType.TEXT_PLAIN); + file3 = dataContent.usingUser(adminUser).usingResource(folder1).createContent(DocumentType.TEXT_PLAIN); + file4 = dataContent.usingUser(adminUser).usingResource(folder1).createContent(DocumentType.TEXT_PLAIN); + file5 = dataContent.usingUser(adminUser).usingResource(folder1).createContent(DocumentType.TEXT_PLAIN); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.SHAREDLINKS }, executionType = ExecutionType.REGRESSION, description = "Verify empty sharedLinks with and without Path") + @Test(groups = { TestGroup.REST_API, TestGroup.SHAREDLINKS }) + public void testGetSharedLinksNoLinks() throws Exception + { + restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().getSharedLinks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + restClient.authenticateUser(testUser1).withCoreAPI().includePath().usingSharedLinks().getSharedLinks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.SHAREDLINKS }, executionType = ExecutionType.REGRESSION, description = "Verify create sharedLinks with and without Path") + @Test(groups = { TestGroup.REST_API, TestGroup.SHAREDLINKS }) + public void testCreateAndGetSharedLinks() throws Exception + { + // Post without includePath + sharedLink1 = restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().createSharedLink(file1); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.onResponse().assertThat().body("entry.nodeId", org.hamcrest.Matchers.equalTo(file1.getNodeRefWithoutVersion())); + restClient.onResponse().assertThat().body("entry.name", org.hamcrest.Matchers.equalTo(file1.getName())); + restClient.onResponse().assertThat().body("entry.id", org.hamcrest.Matchers.equalTo(sharedLink1.getId())); + restClient.onResponse().assertThat().body("entry.path", org.hamcrest.Matchers.nullValue()); + + // Same Checks above using sharedLink methods: GET sharedLink: without includePath + Assert.assertEquals(sharedLink1.getNodeId(), file1.getNodeRefWithoutVersion()); + Assert.assertEquals(sharedLink1.getName(), file1.getName()); + Assert.assertNull(sharedLink1.getPath(), "Path is expected to be null for noauth api: Response shows: " + sharedLink1.toJson()); + + // Get without includePath + restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().getSharedLink(sharedLink1); + restClient.onResponse().assertThat().body("entry.nodeId", org.hamcrest.Matchers.equalTo(file1.getNodeRefWithoutVersion())); + restClient.onResponse().assertThat().body("entry.name", org.hamcrest.Matchers.equalTo(file1.getName())); + restClient.onResponse().assertThat().body("entry.id", org.hamcrest.Matchers.equalTo(sharedLink1.getId())); + restClient.onResponse().assertThat().body("entry.path", org.hamcrest.Matchers.nullValue()); + + // Post with includePath + sharedLink2 = restClient.authenticateUser(testUser1).withCoreAPI().includePath().usingSharedLinks().createSharedLink(file2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.onResponse().assertThat().body("entry.nodeId", org.hamcrest.Matchers.equalTo(file2.getNodeRefWithoutVersion())); + restClient.onResponse().assertThat().body("entry.name", org.hamcrest.Matchers.equalTo(file2.getName())); + restClient.onResponse().assertThat().body("entry.id", org.hamcrest.Matchers.equalTo(sharedLink2.getId())); + restClient.onResponse().assertThat().body("entry.path", org.hamcrest.Matchers.notNullValue()); + + // Same Checks above using sharedLink methods: POST sharedLink: includePath + Assert.assertEquals(sharedLink2.getNodeId(), file2.getNodeRefWithoutVersion()); + Assert.assertEquals(sharedLink2.getName(), file2.getName()); + Assert.assertNotNull(sharedLink2.getPath(), "Path not expected to be null for noauth api: Response shows: " + sharedLink1.toJson()); + + // Get with includePath + restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().getSharedLink(sharedLink2); + restClient.onResponse().assertThat().body("entry.nodeId", org.hamcrest.Matchers.equalTo(file2.getNodeRefWithoutVersion())); + restClient.onResponse().assertThat().body("entry.name", org.hamcrest.Matchers.equalTo(file2.getName())); + restClient.onResponse().assertThat().body("entry.id", org.hamcrest.Matchers.equalTo(sharedLink2.getId())); + // Verify that path is null since includePath is not supported for this noAuth api + restClient.onResponse().assertThat().body("entry.path", org.hamcrest.Matchers.nullValue()); + + // Get: noAuth with includePath + sharedLink2 = restClient.withCoreAPI().usingSharedLinks().getSharedLink(sharedLink2); + restClient.onResponse().assertThat().body("entry.nodeId", org.hamcrest.Matchers.equalTo(file2.getNodeRefWithoutVersion())); + restClient.onResponse().assertThat().body("entry.name", org.hamcrest.Matchers.equalTo(file2.getName())); + restClient.onResponse().assertThat().body("entry.id", org.hamcrest.Matchers.equalTo(sharedLink2.getId())); + // Verify that path is null since includePath is not supported for this noAuth api + restClient.onResponse().assertThat().body("entry.path", org.hamcrest.Matchers.nullValue()); + + // Same Checks above using sharedLink methods: GET sharedLink: noAuth + Assert.assertEquals(sharedLink2.getNodeId(), file2.getNodeRefWithoutVersion()); + Assert.assertEquals(sharedLink2.getName(), file2.getName()); + Assert.assertNull(sharedLink2.getPath(), "Path is expected to be null for noauth api: Response shows: " + sharedLink2.toJson()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.SHAREDLINKS }, executionType = ExecutionType.REGRESSION, description = "Verify delete sharedLinks with and without Path") + @Test(groups = { TestGroup.REST_API, TestGroup.SHAREDLINKS }) + public void testDeleteSharedLinks() throws Exception + { + sharedLink3 = restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().createSharedLink(file3); + restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().deleteSharedLink(sharedLink3); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + sharedLink4 = restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().createSharedLink(file4); + restClient.authenticateUser(testUser1).withCoreAPI().includePath().usingSharedLinks().deleteSharedLink(sharedLink4); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.SHAREDLINKS }, executionType = ExecutionType.REGRESSION, description = "Verify get sharedLink/content and get/renditions") + @Test(groups = { TestGroup.REST_API, TestGroup.SHAREDLINKS }) + public void testCreateWithExpiryDateAndGetSharedLinkRendition() throws Exception + { + sharedLink5 = restClient.authenticateUser(testUser1).withCoreAPI().includePath().usingSharedLinks().createSharedLinkWithExpiryDate(file5, expiryDate); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + Assert.assertEquals(sharedLink5.getExpiresAt(), expiryDate); + Assert.assertNotNull(sharedLink5.getPath(), "Path not expected to be null: Response shows: " + sharedLink5.toJson()); + + restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().getSharedLinkRenditions(sharedLink5); + restClient.assertStatusCodeIs(HttpStatus.OK); + + restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().getSharedLinkRendition(sharedLink5, "doclib"); + restClient.assertStatusCodeIs(HttpStatus.OK); + } +} \ No newline at end of file From 7215d336801b3bf076d774c60a577096451c728e Mon Sep 17 00:00:00 2001 From: Andreea Nechifor Date: Thu, 31 Aug 2017 12:10:04 +0300 Subject: [PATCH 1204/1491] added more check on getAvatar --- .../rest/people/AvatarPeopleSanityTest.java | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/AvatarPeopleSanityTest.java b/e2e-test/java/org/alfresco/rest/people/AvatarPeopleSanityTest.java index 709dc6ce1..5b6276d24 100644 --- a/e2e-test/java/org/alfresco/rest/people/AvatarPeopleSanityTest.java +++ b/e2e-test/java/org/alfresco/rest/people/AvatarPeopleSanityTest.java @@ -13,7 +13,12 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -public class AvatarPeopleSanityTest extends RestTest { +import com.jayway.restassured.response.ValidatableResponse; + +import junit.framework.Assert; + +public class AvatarPeopleSanityTest extends RestTest +{ private UserModel userModel; @@ -24,22 +29,21 @@ public class AvatarPeopleSanityTest extends RestTest { } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Update Avatar for People") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Update Avatar for People") public void updateGetAvatarForPeople() throws Exception { - File avatarFile = Utility.getResourceTestDataFile("avatar.jpg"); restClient.authenticateUser(userModel); - restClient.withCoreAPI().usingAuthUser().uploadAvatarContent(restProperties.envProperty().getFullServerUrl(), avatarFile).statusCode(200); + ValidatableResponse response = restClient.withCoreAPI().usingAuthUser() + .uploadAvatarContent(restProperties.envProperty().getFullServerUrl(), avatarFile).statusCode(200); restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().downloadAvatarContent(); restClient.assertStatusCodeIs(HttpStatus.OK); - + Assert.assertNotNull(response.extract().body().asByteArray()); + Assert.assertTrue("Avatar Image not uploaded", response.extract().body().asByteArray().length > 0); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Update Avatar for People") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Remove Avatar for People") public void removeGetAvatarForPeople() throws Exception { File avatarFile = Utility.getResourceTestDataFile("avatar.jpg"); From 0ed27d3526f51b9b70fa300f85f43af0d7bac7b5 Mon Sep 17 00:00:00 2001 From: Alexandru-Eusebiu Epure Date: Fri, 1 Sep 2017 10:47:05 +0300 Subject: [PATCH 1205/1491] REPO-2299 : Implement TAS tests for 'Nodes' RestApi endpoint - part 1 Create a sanity test for updateNodeContent and copyNode Extend TAS framework with PUT /nodes/{nodeId}/content and POST /nodes/{nodeId}/copy --- .../rest/nodes/NodesContentTests.java | 66 ++++++++++++++++++- 1 file changed, 64 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/nodes/NodesContentTests.java b/e2e-test/java/org/alfresco/rest/nodes/NodesContentTests.java index e65185a58..e5fe2f057 100644 --- a/e2e-test/java/org/alfresco/rest/nodes/NodesContentTests.java +++ b/e2e-test/java/org/alfresco/rest/nodes/NodesContentTests.java @@ -1,10 +1,18 @@ package org.alfresco.rest.nodes; import static org.alfresco.utility.report.log.Step.STEP; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertNotSame; +import static org.testng.Assert.assertSame; +import static org.testng.Assert.assertTrue; + +import java.io.File; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.JsonBodyGenerator; import org.alfresco.rest.model.RestNodeModel; +import org.alfresco.rest.model.body.RestNodeLockBodyModel; import org.alfresco.utility.Utility; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FileType; @@ -14,15 +22,19 @@ import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.TestRailExecutorListener; import org.alfresco.utility.testrail.annotation.TestRail; +import org.json.JSONObject; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; +import org.testng.annotations.Listeners; import org.testng.annotations.Test; /** * * @author mpopa * */ +@Listeners(value=TestRailExecutorListener.class) public class NodesContentTests extends RestTest { private UserModel user1, user2; @@ -35,7 +47,7 @@ public class NodesContentTests extends RestTest user1 = dataUser.createRandomTestUser(); user2 = dataUser.createRandomTestUser(); site1 = dataSite.usingUser(user1).createPublicRandomSite(); - site2 = dataSite.usingUser(user2).createPublicRandomSite(); + site2 = dataSite.usingUser(user2).createPublicRandomSite(); file1 = dataContent.usingUser(user1).usingSite(site1).createContent(DocumentType.TEXT_PLAIN); } @@ -91,7 +103,57 @@ public class NodesContentTests extends RestTest STEP("4. Retrieve the nodes and verify that the content type is the expected one (GET nodes/{nodeId})."); restClient.withCoreAPI().usingNode(utf8File).getNodeContent().assertThat().contentType(utf8Type); restClient.withCoreAPI().usingNode(iso8859File).getNodeContent().assertThat().contentType(iso8859Type); - } + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.NODES }, executionType = ExecutionType.SANITY, description = "Verify updating a node content.") + public void testUpdateNodeContent() throws Exception + { + STEP("1. Retrieve the node in order to get data to compare after update GET /nodes/{nodeId}?include=path."); + RestNodeModel initialNode = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=path").getNode(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + STEP("2. Update the node content (different from the initial one) PUT /nodes/{nodeId}/content?majorVersion=true&name=newfile.txt."); + File avatarFile = Utility.getResourceTestDataFile("my-file.tif"); + RestNodeModel updatedBodyNode = restClient.withCoreAPI().usingNode(file1).usingParams("majorVersion=true&name=newfile.txt").updateNodeContent(avatarFile); + restClient.assertStatusCodeIs(HttpStatus.OK); + + STEP("3. Compare contentSize, modifiedAt, name and version, they should be different."); + assertNotSame(initialNode.getContent().getSizeInBytes(), updatedBodyNode.getContent().getSizeInBytes()); + assertNotSame(initialNode.getModifiedAt(), updatedBodyNode.getModifiedAt()); + assertNotSame(initialNode.getName(), updatedBodyNode.getName()); + + String initialNodeVersion = new JSONObject(initialNode.toJson()).getJSONObject("properties").getString("cm:versionLabel"); + String updatedBodyNodeVersion = new JSONObject(updatedBodyNode.toJson()).getJSONObject("properties").getString("cm:versionLabel"); + assertTrue(updatedBodyNodeVersion.charAt(0)>initialNodeVersion.charAt(0)); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.NODES }, executionType = ExecutionType.SANITY, description = "Test copy a node.") + public void testCopyNode() throws Exception + { + STEP("1. Create a lock and lock the node POST /nodes/{nodeId}/lock?include=path,isLocked."); + RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); + lockBodyModel.setLifetime("EPHEMERAL"); + lockBodyModel.setTimeToExpire(20); + lockBodyModel.setType("FULL"); + RestNodeModel initialNode = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=path,isLocked").lockNode(lockBodyModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + + STEP("2. With another user(that has access to the file), copy the node to another path POST /nodes/{nodeId}/copy?include=path,isLocked."); + String postBody = JsonBodyGenerator.keyValueJson("targetParentId", site2.getGuid()); + RestNodeModel copiedNode = restClient.authenticateUser(user2).withCoreAPI().usingNode(file1).usingParams("include=path,isLocked") + .copyNode(postBody); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + STEP("3. parentId, createdAt, path and lock are different, but the nodes have the same contentSize."); + assertNotSame(copiedNode.getParentId(), initialNode.getParentId()); + assertNotSame(copiedNode.getCreatedAt(), initialNode.getCreatedAt()); + assertNotSame(copiedNode.getPath(), initialNode.getPath()); + assertTrue(initialNode.getIsLocked()); + assertSame(copiedNode.getContent().getSizeInBytes(), initialNode.getContent().getSizeInBytes()); + assertFalse(copiedNode.getIsLocked()); + } } From eda37669f0421a6260f93c7eef70d2fbd218ad83 Mon Sep 17 00:00:00 2001 From: Andrei Forascu Date: Fri, 1 Sep 2017 11:19:37 +0300 Subject: [PATCH 1206/1491] REPO-2301 - RestAPI: Implement TAS tests for 'Nodes' RestApi endpoint - part 2: - implemented sanity tests for the following V1 REST API endpoints: POST /nodes/{nodeId}/secondary-children GET /nodes/{nodeId}/secondary-children DELETE /nodes/{nodeId}/secondary-children/{childId} GET /nodes/{nodeId}/parents --- .../rest/nodes/NodesChildrenTests.java | 94 -------- .../rest/nodes/NodesParentChildrenTests.java | 205 ++++++++++++++++++ 2 files changed, 205 insertions(+), 94 deletions(-) delete mode 100644 e2e-test/java/org/alfresco/rest/nodes/NodesChildrenTests.java create mode 100644 e2e-test/java/org/alfresco/rest/nodes/NodesParentChildrenTests.java diff --git a/e2e-test/java/org/alfresco/rest/nodes/NodesChildrenTests.java b/e2e-test/java/org/alfresco/rest/nodes/NodesChildrenTests.java deleted file mode 100644 index 270ba6595..000000000 --- a/e2e-test/java/org/alfresco/rest/nodes/NodesChildrenTests.java +++ /dev/null @@ -1,94 +0,0 @@ -package org.alfresco.rest.nodes; - -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestNodeBodyModel; -import org.alfresco.rest.model.RestNodeModel; -import org.alfresco.rest.model.RestNodeModelsCollection; -import org.alfresco.rest.model.builder.NodesBuilder; -import org.alfresco.utility.Utility; -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/children - */ -public class NodesChildrenTests extends RestTest -{ - @TestRail(section = { TestGroup.REST_API,TestGroup.NODES }, executionType = ExecutionType.SANITY, - description = "Verify new folder node is created as children on -my- posting as JSON content type") - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY}) - public void createNewFolderNodeViaJason() throws Exception - { - restClient.authenticateUser(dataContent.getAdminUser()); - - RestNodeBodyModel node = new RestNodeBodyModel(); - node.setName("My Folder"); - node.setNodeType("cm:folder"); - - RestNodeModel newNode = restClient.withParams("autoRename=true").withCoreAPI().usingNode(ContentModel.my()).createNode(node); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - newNode.assertThat().field("aspectNames").contains("cm:auditable") - .assertThat().field("isFolder").is(true) - .assertThat().field("isFile").is(false) - .assertThat().field("name").contains(node.getName()); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NODES }, executionType = ExecutionType.SANITY, - description = "Verify new folder node is created as children on -my- posting as MultiPart content type") - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY}) - public void createNewFolderNodeWithMultiPartForms() throws Exception - { - //configuring multipart form - restClient.authenticateUser(dataContent.getAdminUser()) - .configureRequestSpec() - .addMultiPart("filedata", Utility.getResourceTestDataFile("restapi-resource")) - .addFormParam("renditions", "doclib") - .addFormParam("autoRename", true); - - RestNodeModel newNode = restClient.withCoreAPI().usingNode(ContentModel.my()).createNode(); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - newNode.assertThat().field("aspectNames").contains("cm:auditable") - .assertThat().field("isFolder").is(false) - .assertThat().field("isFile").is(true) - .assertThat().field("name").contains("restapi-resource"); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NODES }, executionType = ExecutionType.SANITY, - description = "Verify list children when listing with relativePath and pagination") - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY}) - public void checkRelativePathAndPaginationOnCreateChildrenNode() throws Exception - { - /* - * Given we have a folder hierarchy folder1/folder2/folder3 and folder3 containing 3 files file1, file2, and file3 - */ - NodesBuilder nodesBuilder = restClient.authenticateUser(dataUser.getAdminUser()) - .withCoreAPI().usingNode(ContentModel.my()) - .defineNodes(); - nodesBuilder - .folder("F1") - .folder("F2") - .folder("F3") - .file("f1") - .file("f2") - .file("f3"); - - RestNodeModelsCollection returnedFiles = restClient.withParams("maxItems=2", - "skipCount=1", - String.format("relativePath=%s/%s", nodesBuilder.getNode("F2").getName(), nodesBuilder.getNode("F3").getName())) - .withCoreAPI().usingNode(nodesBuilder.getNode("F1").toContentModel()).listChildren(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - /* - * Then I receive file2 and file3 - */ - returnedFiles.assertThat().entriesListCountIs(2); - returnedFiles.getEntries().get(0).onModel().assertThat().field("id").is(nodesBuilder.getNode("f2").getId()); - returnedFiles.getEntries().get(1).onModel().assertThat().field("id").is(nodesBuilder.getNode("f3").getId()); - } - -} diff --git a/e2e-test/java/org/alfresco/rest/nodes/NodesParentChildrenTests.java b/e2e-test/java/org/alfresco/rest/nodes/NodesParentChildrenTests.java new file mode 100644 index 000000000..f9eece0d2 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/nodes/NodesParentChildrenTests.java @@ -0,0 +1,205 @@ +package org.alfresco.rest.nodes; + +import static org.alfresco.utility.report.log.Step.STEP; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestNodeBodyModel; +import org.alfresco.rest.model.RestNodeChildAssocModelCollection; +import org.alfresco.rest.model.RestNodeChildAssociationModel; +import org.alfresco.rest.model.RestNodeModel; +import org.alfresco.rest.model.RestNodeModelsCollection; +import org.alfresco.rest.model.RestNodeParentChildModelCollection; +import org.alfresco.rest.model.builder.NodesBuilder; +import org.alfresco.utility.Utility; +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/children + * api-explorer/#!/nodes/secondary-children + * api-explorer/#!/nodes/parents + */ +public class NodesParentChildrenTests extends RestTest +{ + @TestRail(section = { TestGroup.REST_API,TestGroup.NODES }, executionType = ExecutionType.SANITY, + description = "Verify new folder node is created as children on -my- posting as JSON content type") + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY}) + public void createNewFolderNodeViaJason() throws Exception + { + restClient.authenticateUser(dataContent.getAdminUser()); + + RestNodeBodyModel node = new RestNodeBodyModel(); + node.setName("My Folder"); + node.setNodeType("cm:folder"); + + RestNodeModel newNode = restClient.withParams("autoRename=true").withCoreAPI().usingNode(ContentModel.my()).createNode(node); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + newNode.assertThat().field("aspectNames").contains("cm:auditable") + .assertThat().field("isFolder").is(true) + .assertThat().field("isFile").is(false) + .assertThat().field("name").contains(node.getName()); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NODES }, executionType = ExecutionType.SANITY, + description = "Verify new folder node is created as children on -my- posting as MultiPart content type") + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY}) + public void createNewFolderNodeWithMultiPartForms() throws Exception + { + //configuring multipart form + restClient.authenticateUser(dataContent.getAdminUser()) + .configureRequestSpec() + .addMultiPart("filedata", Utility.getResourceTestDataFile("restapi-resource")) + .addFormParam("renditions", "doclib") + .addFormParam("autoRename", true); + + RestNodeModel newNode = restClient.withCoreAPI().usingNode(ContentModel.my()).createNode(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + newNode.assertThat().field("aspectNames").contains("cm:auditable") + .assertThat().field("isFolder").is(false) + .assertThat().field("isFile").is(true) + .assertThat().field("name").contains("restapi-resource"); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NODES }, executionType = ExecutionType.SANITY, + description = "Verify list children when listing with relativePath and pagination") + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY}) + public void checkRelativePathAndPaginationOnCreateChildrenNode() throws Exception + { + /* + * Given we have a folder hierarchy folder1/folder2/folder3 and folder3 containing 3 files file1, file2, and file3 + */ + NodesBuilder nodesBuilder = restClient.authenticateUser(dataUser.getAdminUser()) + .withCoreAPI().usingNode(ContentModel.my()) + .defineNodes(); + nodesBuilder + .folder("F1") + .folder("F2") + .folder("F3") + .file("f1") + .file("f2") + .file("f3"); + + RestNodeModelsCollection returnedFiles = restClient.withParams("maxItems=2", + "skipCount=1", + String.format("relativePath=%s/%s", nodesBuilder.getNode("F2").getName(), nodesBuilder.getNode("F3").getName())) + .withCoreAPI().usingNode(nodesBuilder.getNode("F1").toContentModel()).listChildren(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + /* + * Then I receive file2 and file3 + */ + returnedFiles.assertThat().entriesListCountIs(2); + returnedFiles.getEntries().get(0).onModel().assertThat().field("id").is(nodesBuilder.getNode("f2").getId()); + returnedFiles.getEntries().get(1).onModel().assertThat().field("id").is(nodesBuilder.getNode("f3").getId()); + } + + /** + * Sanity check for the following api endpoints + * POST /nodes/{nodeId}/secondary-children + * GET /nodes/{nodeId}/secondary-children + * DELETE /nodes/{nodeId}/secondary-children/{childId} + */ + @TestRail(section = { TestGroup.REST_API, + TestGroup.NODES }, executionType = ExecutionType.SANITY, description = "Check /secondary-children (create, list, delete) api calls") + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY }) + public void checkSecondaryChildrenApi() throws Exception + { + STEP("1. Create a folder hierarchy folder1/folder2, with folder2 containing 3 files: f1, f2, and f3"); + NodesBuilder nodesBuilder = restClient.authenticateUser(dataUser.getAdminUser()) + .withCoreAPI().usingNode(ContentModel.my()) + .defineNodes(); + nodesBuilder + .folder("F1") + .folder("F2") + .file("f1") + .file("f2") + .file("f3"); + + STEP("2. Create secondary child associations model objects"); + RestNodeChildAssociationModel childAssoc1 = new RestNodeChildAssociationModel(nodesBuilder.getNode("f1").getId(), "cm:contains"); + RestNodeChildAssociationModel childAssoc2 = new RestNodeChildAssociationModel(nodesBuilder.getNode("f2").getId(), "cm:contains"); + RestNodeChildAssociationModel childAssoc3 = new RestNodeChildAssociationModel(nodesBuilder.getNode("f3").getId(), "cm:preferenceImage"); + String secondaryChildrenBody = "[" + childAssoc1.toJson() + "," + childAssoc2.toJson() + "," + childAssoc3.toJson() + "]"; + + STEP("3. Create secondary child associations using POST /nodes/{nodeId}/secondary-children"); + RestNodeChildAssocModelCollection secondaryChildAssoc = restClient.withCoreAPI().usingNode(nodesBuilder.getNode("F1").toContentModel()) + .createSecondaryChildren(secondaryChildrenBody); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + secondaryChildAssoc.getEntryByIndex(0).assertThat().field("childId").is(childAssoc1.getChildId()); + secondaryChildAssoc.getEntryByIndex(1).assertThat().field("childId").is(childAssoc2.getChildId()); + secondaryChildAssoc.getEntryByIndex(2).assertThat().field("childId").is(childAssoc3.getChildId()); + + STEP("4. Check using GET /nodes/{nodeId}/secondary-children that the secondary 'cm:contains' child associations were created"); + RestNodeParentChildModelCollection secondaryChildren = restClient.withParams("where=(assocType='cm:contains')").withCoreAPI() + .usingNode(nodesBuilder.getNode("F1").toContentModel()).getSecondaryChildren(); + restClient.assertStatusCodeIs(HttpStatus.OK); + secondaryChildren.assertThat().entriesListCountIs(2); + + STEP("5. Check using DELETE /nodes/{nodeId}/secondary-children/{childId} that a secondary child can be deleted"); + restClient.withCoreAPI().usingNode(nodesBuilder.getNode("F1").toContentModel()).deleteSecondaryChild(secondaryChildren.getEntryByIndex(0)); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + STEP("6. Check using GET /nodes/{nodeId}/secondary-children that a secondary child association was deleted"); + secondaryChildren = restClient.withCoreAPI().usingNode(nodesBuilder.getNode("F1").toContentModel()) + .getSecondaryChildren(); + restClient.assertStatusCodeIs(HttpStatus.OK); + secondaryChildren.assertThat().entriesListCountIs(2); + secondaryChildren.getEntryByIndex(0).assertThat() + .field("id").is(secondaryChildAssoc.getEntryByIndex(1).getChildId()).and() + .field("parentId").is(nodesBuilder.getNode("F2").getId()) + .getAssociation().assertThat() + .field("isPrimary").is(false).and() + .field("assocType").is("cm:contains"); + secondaryChildren.getEntryByIndex(1).assertThat() + .field("id").is(secondaryChildAssoc.getEntryByIndex(2).getChildId()) + .getAssociation().assertThat() + .field("assocType").is("cm:preferenceImage"); + } + + /** + * Sanity check for the following api endpoint + * GET /nodes/{nodeId}/parents + */ + @TestRail(section = { TestGroup.REST_API, + TestGroup.NODES }, executionType = ExecutionType.SANITY, description = "Check that GET /parents retrieves primary and secondary parents for a node") + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY }) + public void checkGetNodeParents() throws Exception + { + STEP("1. Create a folder hierarchy folder1/folder2, with folder2 containing file f1"); + NodesBuilder nodesBuilder = restClient.authenticateUser(dataUser.getAdminUser()) + .withCoreAPI().usingNode(ContentModel.my()) + .defineNodes(); + nodesBuilder + .folder("F1") + .folder("F2") + .file("f1"); + + STEP("2. Create secondary child associations using POST /nodes/{nodeId}/secondary-children"); + RestNodeChildAssociationModel childAssoc = new RestNodeChildAssociationModel(nodesBuilder.getNode("f1").getId(), "cm:contains"); + restClient.withCoreAPI().usingNode(nodesBuilder.getNode("F1").toContentModel()).createSecondaryChildren(childAssoc.toJson()); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + STEP("3. Get all parents for file 'f1' - both primary and secondary"); + RestNodeParentChildModelCollection parents = restClient.withCoreAPI().usingNode(nodesBuilder.getNode("f1").toContentModel()).getParents(); + restClient.assertStatusCodeIs(HttpStatus.OK); + parents.assertThat().entriesListCountIs(2); + + STEP("4. Check using GET /nodes/{nodeId}/parents that the parent (not primary) for f1 is found"); + parents = restClient.withParams("where=(isPrimary=false)").withCoreAPI().usingNode(nodesBuilder.getNode("f1").toContentModel()).getParents(); + restClient.assertStatusCodeIs(HttpStatus.OK); + parents.assertThat().entriesListCountIs(1); + parents.getEntryByIndex(0).assertThat() + .field("isFolder").is("true").and() + .field("isFile").is(false).and() + .field("name").is(nodesBuilder.getNode("F1").getName()) + .getAssociation().assertThat() + .field("isPrimary").is(false).and() + .field("assocType").is("cm:contains"); + } +} From e9912b74a015be3e0070bf1aef9f816ebbc7b49f Mon Sep 17 00:00:00 2001 From: Alexandru-Eusebiu Epure Date: Fri, 1 Sep 2017 11:33:34 +0300 Subject: [PATCH 1207/1491] REPO-2299 : Implement TAS tests for 'Nodes' RestApi endpoint - part 1 Add an additional step to testCopyNode(), unlocking the used node because other tests were failing. --- e2e-test/java/org/alfresco/rest/nodes/NodesContentTests.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/nodes/NodesContentTests.java b/e2e-test/java/org/alfresco/rest/nodes/NodesContentTests.java index e5fe2f057..bc4b57980 100644 --- a/e2e-test/java/org/alfresco/rest/nodes/NodesContentTests.java +++ b/e2e-test/java/org/alfresco/rest/nodes/NodesContentTests.java @@ -155,5 +155,10 @@ public class NodesContentTests extends RestTest assertTrue(initialNode.getIsLocked()); assertSame(copiedNode.getContent().getSizeInBytes(), initialNode.getContent().getSizeInBytes()); assertFalse(copiedNode.getIsLocked()); + + STEP("4. Unlock the node (this node may be used in the next tests)."); + initialNode = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").unlockNode(); + restClient.assertStatusCodeIs(HttpStatus.OK); + assertFalse(initialNode.getIsLocked()); } } From b9e9be49d70b280deb3db85064c1c169c3ca88d3 Mon Sep 17 00:00:00 2001 From: Andrei Forascu Date: Fri, 1 Sep 2017 12:34:44 +0300 Subject: [PATCH 1208/1491] REPO-2301 : RestAPI: Implement TAS tests for 'Nodes' RestApi endpoint - part 2 REPO-2299 : RestAPI: Implement TAS tests for 'Nodes' RestApi endpoint - part 1 - code formatting --- .../rest/nodes/NodesContentTests.java | 9 +++---- .../rest/nodes/NodesParentChildrenTests.java | 24 +++++++++---------- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/nodes/NodesContentTests.java b/e2e-test/java/org/alfresco/rest/nodes/NodesContentTests.java index bc4b57980..7991f5a27 100644 --- a/e2e-test/java/org/alfresco/rest/nodes/NodesContentTests.java +++ b/e2e-test/java/org/alfresco/rest/nodes/NodesContentTests.java @@ -22,19 +22,16 @@ import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.TestRailExecutorListener; import org.alfresco.utility.testrail.annotation.TestRail; import org.json.JSONObject; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; -import org.testng.annotations.Listeners; import org.testng.annotations.Test; /** * * @author mpopa * */ -@Listeners(value=TestRailExecutorListener.class) public class NodesContentTests extends RestTest { private UserModel user1, user2; @@ -126,7 +123,7 @@ public class NodesContentTests extends RestTest String initialNodeVersion = new JSONObject(initialNode.toJson()).getJSONObject("properties").getString("cm:versionLabel"); String updatedBodyNodeVersion = new JSONObject(updatedBodyNode.toJson()).getJSONObject("properties").getString("cm:versionLabel"); - assertTrue(updatedBodyNodeVersion.charAt(0)>initialNodeVersion.charAt(0)); + assertTrue(updatedBodyNodeVersion.charAt(0) > initialNodeVersion.charAt(0)); } @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) @@ -148,14 +145,14 @@ public class NodesContentTests extends RestTest .copyNode(postBody); restClient.assertStatusCodeIs(HttpStatus.CREATED); - STEP("3. parentId, createdAt, path and lock are different, but the nodes have the same contentSize."); + STEP("3. ParentId, createdAt, path and lock are different, but the nodes have the same contentSize."); assertNotSame(copiedNode.getParentId(), initialNode.getParentId()); assertNotSame(copiedNode.getCreatedAt(), initialNode.getCreatedAt()); assertNotSame(copiedNode.getPath(), initialNode.getPath()); assertTrue(initialNode.getIsLocked()); assertSame(copiedNode.getContent().getSizeInBytes(), initialNode.getContent().getSizeInBytes()); assertFalse(copiedNode.getIsLocked()); - + STEP("4. Unlock the node (this node may be used in the next tests)."); initialNode = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").unlockNode(); restClient.assertStatusCodeIs(HttpStatus.OK); diff --git a/e2e-test/java/org/alfresco/rest/nodes/NodesParentChildrenTests.java b/e2e-test/java/org/alfresco/rest/nodes/NodesParentChildrenTests.java index f9eece0d2..74f107adf 100644 --- a/e2e-test/java/org/alfresco/rest/nodes/NodesParentChildrenTests.java +++ b/e2e-test/java/org/alfresco/rest/nodes/NodesParentChildrenTests.java @@ -36,16 +36,16 @@ public class NodesParentChildrenTests extends RestTest RestNodeBodyModel node = new RestNodeBodyModel(); node.setName("My Folder"); node.setNodeType("cm:folder"); - - RestNodeModel newNode = restClient.withParams("autoRename=true").withCoreAPI().usingNode(ContentModel.my()).createNode(node); + + RestNodeModel newNode = restClient.withParams("autoRename=true").withCoreAPI().usingNode(ContentModel.my()).createNode(node); restClient.assertStatusCodeIs(HttpStatus.CREATED); - + newNode.assertThat().field("aspectNames").contains("cm:auditable") .assertThat().field("isFolder").is(true) .assertThat().field("isFile").is(false) - .assertThat().field("name").contains(node.getName()); + .assertThat().field("name").contains(node.getName()); } - + @TestRail(section = { TestGroup.REST_API,TestGroup.NODES }, executionType = ExecutionType.SANITY, description = "Verify new folder node is created as children on -my- posting as MultiPart content type") @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY}) @@ -53,17 +53,17 @@ public class NodesParentChildrenTests extends RestTest { //configuring multipart form restClient.authenticateUser(dataContent.getAdminUser()) - .configureRequestSpec() + .configureRequestSpec() .addMultiPart("filedata", Utility.getResourceTestDataFile("restapi-resource")) .addFormParam("renditions", "doclib") .addFormParam("autoRename", true); - + RestNodeModel newNode = restClient.withCoreAPI().usingNode(ContentModel.my()).createNode(); restClient.assertStatusCodeIs(HttpStatus.CREATED); newNode.assertThat().field("aspectNames").contains("cm:auditable") .assertThat().field("isFolder").is(false) .assertThat().field("isFile").is(true) - .assertThat().field("name").contains("restapi-resource"); + .assertThat().field("name").contains("restapi-resource"); } @TestRail(section = { TestGroup.REST_API,TestGroup.NODES }, executionType = ExecutionType.SANITY, @@ -76,18 +76,18 @@ public class NodesParentChildrenTests extends RestTest */ NodesBuilder nodesBuilder = restClient.authenticateUser(dataUser.getAdminUser()) .withCoreAPI().usingNode(ContentModel.my()) - .defineNodes(); + .defineNodes(); nodesBuilder .folder("F1") .folder("F2") - .folder("F3") + .folder("F3") .file("f1") .file("f2") .file("f3"); RestNodeModelsCollection returnedFiles = restClient.withParams("maxItems=2", "skipCount=1", - String.format("relativePath=%s/%s", nodesBuilder.getNode("F2").getName(), nodesBuilder.getNode("F3").getName())) + String.format("relativePath=%s/%s", nodesBuilder.getNode("F2").getName(), nodesBuilder.getNode("F3").getName())) .withCoreAPI().usingNode(nodesBuilder.getNode("F1").toContentModel()).listChildren(); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -96,7 +96,7 @@ public class NodesParentChildrenTests extends RestTest */ returnedFiles.assertThat().entriesListCountIs(2); returnedFiles.getEntries().get(0).onModel().assertThat().field("id").is(nodesBuilder.getNode("f2").getId()); - returnedFiles.getEntries().get(1).onModel().assertThat().field("id").is(nodesBuilder.getNode("f3").getId()); + returnedFiles.getEntries().get(1).onModel().assertThat().field("id").is(nodesBuilder.getNode("f3").getId()); } /** From 14c6c0342df85517e187bdcc9e3aa3339f08e53f Mon Sep 17 00:00:00 2001 From: Andreea Nechifor Date: Mon, 4 Sep 2017 10:27:55 +0300 Subject: [PATCH 1209/1491] REPO-2304. Added targets tests. --- .../rest/targets/GetTargetSanityTests.java | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/targets/GetTargetSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/targets/GetTargetSanityTests.java b/e2e-test/java/org/alfresco/rest/targets/GetTargetSanityTests.java new file mode 100644 index 000000000..a4e7ba14a --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/targets/GetTargetSanityTests.java @@ -0,0 +1,74 @@ +package org.alfresco.rest.targets; + +import static org.alfresco.utility.report.log.Step.STEP; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestAssocTargetModel; +import org.alfresco.rest.model.RestNodeParentChildModelCollection; +import org.alfresco.rest.model.builder.NodesBuilder; +import org.alfresco.utility.model.ContentModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class GetTargetSanityTests extends RestTest +{ + + private UserModel adminUserModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + } + + /** + * Sanity check for the following api endpoints + * POST /nodes/{nodeId}/targets + * GET /nodes/{nodeId}/targets + * DELETE /nodes/{nodeId}/targets/{targetId} + */ + + @TestRail(section = { TestGroup.REST_API, + TestGroup.NODES }, executionType = ExecutionType.SANITY, description = "Check /targets (create, list, delete) api calls") + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY }) + public void checkTargetsNodeApi() throws Exception + { + STEP("1.Create a folder hierarchy folder1/folder2, with folder2 containing 3 files: f1, f2, and f3"); + NodesBuilder nodesBuilder = restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingNode(ContentModel.my()).defineNodes(); + nodesBuilder.folder("F1").folder("F2").folder("F3").file("f1").file("f2").file("f3"); + + STEP("2. Create target associations model objects"); + RestAssocTargetModel assocDocTarget1 = new RestAssocTargetModel(nodesBuilder.getNode("f2").toContentModel().getNodeRef(), "cm:references"); + RestAssocTargetModel assocDocTarget2 = new RestAssocTargetModel(nodesBuilder.getNode("f3").toContentModel().getNodeRef(), "cm:references"); + + STEP("3. Create target associations using POST /nodes/{nodeId}/targets"); + restClient.authenticateUser(adminUserModel); + restClient.withCoreAPI().usingResource(nodesBuilder.getNode("f1").toContentModel()).createTargetForNode(assocDocTarget1); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.withCoreAPI().usingResource(nodesBuilder.getNode("f1").toContentModel()).createTargetForNode(assocDocTarget2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + STEP("4. Check using GET /nodes/{nodeId}/targets targets associations were created"); + RestNodeParentChildModelCollection tagets = restClient.withParams("where=(assocType='cm:references')").withCoreAPI() + .usingResource(nodesBuilder.getNode("f1").toContentModel()).getNodeTargets(); + restClient.assertStatusCodeIs(HttpStatus.OK); + tagets.assertThat().entriesListCountIs(2); + + STEP("5. Check using DELETE /nodes/{nodeId}/targets/{targetId} that a target can be deleted"); + restClient.authenticateUser(adminUserModel); + restClient.withCoreAPI().usingResource(nodesBuilder.getNode("f1").toContentModel()).deleteTarget(assocDocTarget1); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + STEP("6. Check using GET /nodes/{nodeId}/targets that target association was deleted"); + RestNodeParentChildModelCollection targetsRes = restClient.withParams("where=(assocType='cm:references')").withCoreAPI() + .usingResource(nodesBuilder.getNode("f1").toContentModel()).getNodeTargets(); + restClient.assertStatusCodeIs(HttpStatus.OK); + targetsRes.assertThat().entriesListCountIs(1); + } + +} From 10186bc279b554baeb59a7e07ceda4433b27b724 Mon Sep 17 00:00:00 2001 From: Andrei Forascu Date: Mon, 4 Sep 2017 12:50:08 +0300 Subject: [PATCH 1210/1491] REPO - 2304 - RestAPI: Implement tests in TAS project for 'Nodes' RestApi endpoint - part 4: - rename some models and tests to match OpenAPI spec --- .../rest/nodes/NodesParentChildrenTests.java | 6 +- .../rest/nodes/NodesTargetSourcesTests.java | 74 +++++++++++++++++++ 2 files changed, 77 insertions(+), 3 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/nodes/NodesTargetSourcesTests.java diff --git a/e2e-test/java/org/alfresco/rest/nodes/NodesParentChildrenTests.java b/e2e-test/java/org/alfresco/rest/nodes/NodesParentChildrenTests.java index 74f107adf..097f652e3 100644 --- a/e2e-test/java/org/alfresco/rest/nodes/NodesParentChildrenTests.java +++ b/e2e-test/java/org/alfresco/rest/nodes/NodesParentChildrenTests.java @@ -8,7 +8,7 @@ import org.alfresco.rest.model.RestNodeChildAssocModelCollection; import org.alfresco.rest.model.RestNodeChildAssociationModel; import org.alfresco.rest.model.RestNodeModel; import org.alfresco.rest.model.RestNodeModelsCollection; -import org.alfresco.rest.model.RestNodeParentChildModelCollection; +import org.alfresco.rest.model.RestNodeAssociationModelCollection; import org.alfresco.rest.model.builder.NodesBuilder; import org.alfresco.utility.Utility; import org.alfresco.utility.model.ContentModel; @@ -136,7 +136,7 @@ public class NodesParentChildrenTests extends RestTest secondaryChildAssoc.getEntryByIndex(2).assertThat().field("childId").is(childAssoc3.getChildId()); STEP("4. Check using GET /nodes/{nodeId}/secondary-children that the secondary 'cm:contains' child associations were created"); - RestNodeParentChildModelCollection secondaryChildren = restClient.withParams("where=(assocType='cm:contains')").withCoreAPI() + RestNodeAssociationModelCollection secondaryChildren = restClient.withParams("where=(assocType='cm:contains')").withCoreAPI() .usingNode(nodesBuilder.getNode("F1").toContentModel()).getSecondaryChildren(); restClient.assertStatusCodeIs(HttpStatus.OK); secondaryChildren.assertThat().entriesListCountIs(2); @@ -186,7 +186,7 @@ public class NodesParentChildrenTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.CREATED); STEP("3. Get all parents for file 'f1' - both primary and secondary"); - RestNodeParentChildModelCollection parents = restClient.withCoreAPI().usingNode(nodesBuilder.getNode("f1").toContentModel()).getParents(); + RestNodeAssociationModelCollection parents = restClient.withCoreAPI().usingNode(nodesBuilder.getNode("f1").toContentModel()).getParents(); restClient.assertStatusCodeIs(HttpStatus.OK); parents.assertThat().entriesListCountIs(2); diff --git a/e2e-test/java/org/alfresco/rest/nodes/NodesTargetSourcesTests.java b/e2e-test/java/org/alfresco/rest/nodes/NodesTargetSourcesTests.java new file mode 100644 index 000000000..47290fd09 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/nodes/NodesTargetSourcesTests.java @@ -0,0 +1,74 @@ +package org.alfresco.rest.nodes; + +import static org.alfresco.utility.report.log.Step.STEP; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestNodeAssocTargetModel; +import org.alfresco.rest.model.RestNodeAssociationModelCollection; +import org.alfresco.rest.model.builder.NodesBuilder; +import org.alfresco.utility.model.ContentModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class NodesTargetSourcesTests extends RestTest +{ + + private UserModel adminUserModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + } + + /** + * Sanity check for the following api endpoints + * POST /nodes/{nodeId}/targets + * GET /nodes/{nodeId}/targets + * DELETE /nodes/{nodeId}/targets/{targetId} + */ + + @TestRail(section = { TestGroup.REST_API, + TestGroup.NODES }, executionType = ExecutionType.SANITY, description = "Check /targets (create, list, delete) api calls") + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY }) + public void checkTargetsNodeApi() throws Exception + { + STEP("1.Create a folder hierarchy folder1/folder2, with folder2 containing 3 files: f1, f2, and f3"); + NodesBuilder nodesBuilder = restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingNode(ContentModel.my()).defineNodes(); + nodesBuilder.folder("F1").folder("F2").folder("F3").file("f1").file("f2").file("f3"); + + STEP("2. Create target associations model objects"); + RestNodeAssocTargetModel assocDocTarget1 = new RestNodeAssocTargetModel(nodesBuilder.getNode("f2").toContentModel().getNodeRef(), "cm:references"); + RestNodeAssocTargetModel assocDocTarget2 = new RestNodeAssocTargetModel(nodesBuilder.getNode("f3").toContentModel().getNodeRef(), "cm:references"); + + STEP("3. Create target associations using POST /nodes/{nodeId}/targets"); + restClient.authenticateUser(adminUserModel); + restClient.withCoreAPI().usingResource(nodesBuilder.getNode("f1").toContentModel()).createTargetForNode(assocDocTarget1); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.withCoreAPI().usingResource(nodesBuilder.getNode("f1").toContentModel()).createTargetForNode(assocDocTarget2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + STEP("4. Check using GET /nodes/{nodeId}/targets targets associations were created"); + RestNodeAssociationModelCollection tagets = restClient.withParams("where=(assocType='cm:references')").withCoreAPI() + .usingResource(nodesBuilder.getNode("f1").toContentModel()).getNodeTargets(); + restClient.assertStatusCodeIs(HttpStatus.OK); + tagets.assertThat().entriesListCountIs(2); + + STEP("5. Check using DELETE /nodes/{nodeId}/targets/{targetId} that a target can be deleted"); + restClient.authenticateUser(adminUserModel); + restClient.withCoreAPI().usingResource(nodesBuilder.getNode("f1").toContentModel()).deleteTarget(assocDocTarget1); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + STEP("6. Check using GET /nodes/{nodeId}/targets that target association was deleted"); + RestNodeAssociationModelCollection targetsRes = restClient.withParams("where=(assocType='cm:references')").withCoreAPI() + .usingResource(nodesBuilder.getNode("f1").toContentModel()).getNodeTargets(); + restClient.assertStatusCodeIs(HttpStatus.OK); + targetsRes.assertThat().entriesListCountIs(1); + } + +} From d94288fd632f2e0df698a820e03fc362d32cd4f0 Mon Sep 17 00:00:00 2001 From: Andrei Forascu Date: Mon, 4 Sep 2017 12:51:44 +0300 Subject: [PATCH 1211/1491] REPO - 2304 - RestAPI: Implement tests in TAS project for 'Nodes' RestApi endpoint - part 4: - rename some models and tests to match OpenAPI spec - delete classes --- .../rest/targets/GetTargetSanityTests.java | 74 ------------------- 1 file changed, 74 deletions(-) delete mode 100644 e2e-test/java/org/alfresco/rest/targets/GetTargetSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/targets/GetTargetSanityTests.java b/e2e-test/java/org/alfresco/rest/targets/GetTargetSanityTests.java deleted file mode 100644 index a4e7ba14a..000000000 --- a/e2e-test/java/org/alfresco/rest/targets/GetTargetSanityTests.java +++ /dev/null @@ -1,74 +0,0 @@ -package org.alfresco.rest.targets; - -import static org.alfresco.utility.report.log.Step.STEP; - -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestAssocTargetModel; -import org.alfresco.rest.model.RestNodeParentChildModelCollection; -import org.alfresco.rest.model.builder.NodesBuilder; -import org.alfresco.utility.model.ContentModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class GetTargetSanityTests extends RestTest -{ - - private UserModel adminUserModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - } - - /** - * Sanity check for the following api endpoints - * POST /nodes/{nodeId}/targets - * GET /nodes/{nodeId}/targets - * DELETE /nodes/{nodeId}/targets/{targetId} - */ - - @TestRail(section = { TestGroup.REST_API, - TestGroup.NODES }, executionType = ExecutionType.SANITY, description = "Check /targets (create, list, delete) api calls") - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY }) - public void checkTargetsNodeApi() throws Exception - { - STEP("1.Create a folder hierarchy folder1/folder2, with folder2 containing 3 files: f1, f2, and f3"); - NodesBuilder nodesBuilder = restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingNode(ContentModel.my()).defineNodes(); - nodesBuilder.folder("F1").folder("F2").folder("F3").file("f1").file("f2").file("f3"); - - STEP("2. Create target associations model objects"); - RestAssocTargetModel assocDocTarget1 = new RestAssocTargetModel(nodesBuilder.getNode("f2").toContentModel().getNodeRef(), "cm:references"); - RestAssocTargetModel assocDocTarget2 = new RestAssocTargetModel(nodesBuilder.getNode("f3").toContentModel().getNodeRef(), "cm:references"); - - STEP("3. Create target associations using POST /nodes/{nodeId}/targets"); - restClient.authenticateUser(adminUserModel); - restClient.withCoreAPI().usingResource(nodesBuilder.getNode("f1").toContentModel()).createTargetForNode(assocDocTarget1); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.withCoreAPI().usingResource(nodesBuilder.getNode("f1").toContentModel()).createTargetForNode(assocDocTarget2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - STEP("4. Check using GET /nodes/{nodeId}/targets targets associations were created"); - RestNodeParentChildModelCollection tagets = restClient.withParams("where=(assocType='cm:references')").withCoreAPI() - .usingResource(nodesBuilder.getNode("f1").toContentModel()).getNodeTargets(); - restClient.assertStatusCodeIs(HttpStatus.OK); - tagets.assertThat().entriesListCountIs(2); - - STEP("5. Check using DELETE /nodes/{nodeId}/targets/{targetId} that a target can be deleted"); - restClient.authenticateUser(adminUserModel); - restClient.withCoreAPI().usingResource(nodesBuilder.getNode("f1").toContentModel()).deleteTarget(assocDocTarget1); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - STEP("6. Check using GET /nodes/{nodeId}/targets that target association was deleted"); - RestNodeParentChildModelCollection targetsRes = restClient.withParams("where=(assocType='cm:references')").withCoreAPI() - .usingResource(nodesBuilder.getNode("f1").toContentModel()).getNodeTargets(); - restClient.assertStatusCodeIs(HttpStatus.OK); - targetsRes.assertThat().entriesListCountIs(1); - } - -} From 1e8ddebd0601f093872a4801abecea67f24cccfb Mon Sep 17 00:00:00 2001 From: Andrei Forascu Date: Mon, 4 Sep 2017 16:57:42 +0300 Subject: [PATCH 1212/1491] REPO-2302 - RestAPI: Implement tests in TAS project for 'Nodes' RestApi endpoint - part 3: - added sanity test for GET /nodes/{nodeId}/sources: checkGetNodeSources --- .../rest/nodes/NodesTargetSourcesTests.java | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/nodes/NodesTargetSourcesTests.java b/e2e-test/java/org/alfresco/rest/nodes/NodesTargetSourcesTests.java index 47290fd09..6bf85f41b 100644 --- a/e2e-test/java/org/alfresco/rest/nodes/NodesTargetSourcesTests.java +++ b/e2e-test/java/org/alfresco/rest/nodes/NodesTargetSourcesTests.java @@ -71,4 +71,47 @@ public class NodesTargetSourcesTests extends RestTest targetsRes.assertThat().entriesListCountIs(1); } + /** + * Sanity check for the following api endpoint + * GET /nodes/{nodeId}/sources + */ + @TestRail(section = { TestGroup.REST_API, + TestGroup.NODES }, executionType = ExecutionType.SANITY, description = "Check that source objects are retrieved using GET /nodes/{nodeId}/sources") + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY }) + public void checkGetNodeSources() throws Exception + { + STEP("1.Create a folder hierarchy folder1 containing 4 files: f1, f2, and f3"); + NodesBuilder nodesBuilder = restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingNode(ContentModel.my()).defineNodes(); + nodesBuilder.folder("F1").file("f1").file("f2").file("f3"); + + STEP("2. Create target associations model objects"); + RestNodeAssocTargetModel assocDocTarget1 = new RestNodeAssocTargetModel(nodesBuilder.getNode("f3").toContentModel().getNodeRef(), "cm:references"); + RestNodeAssocTargetModel assocDocTarget2 = new RestNodeAssocTargetModel(nodesBuilder.getNode("f3").toContentModel().getNodeRef(), "cm:preferenceImage"); + + STEP("3. Create target associations using POST /nodes/{nodeId}/targets"); + restClient.authenticateUser(adminUserModel); + restClient.withCoreAPI().usingResource(nodesBuilder.getNode("f1").toContentModel()).createTargetForNode(assocDocTarget1); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.withCoreAPI().usingResource(nodesBuilder.getNode("f2").toContentModel()).createTargetForNode(assocDocTarget2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + STEP("4. Check using GET /nodes/{nodeId}/sources that all source associations are displayed"); + RestNodeAssociationModelCollection sources = restClient.withCoreAPI().usingNode(nodesBuilder.getNode("f3").toContentModel()).getNodeSources(); + restClient.assertStatusCodeIs(HttpStatus.OK); + sources.assertThat().entriesListCountIs(2); + + STEP("5. Check using GET /nodes/{nodeId}/sources with params that sources and fields can be filtered in the response"); + sources = restClient.withParams("where=(assocType='cm:references')", "fields=isFile,name,association,id,nodeType,parentId").withCoreAPI().usingResource(nodesBuilder.getNode("f3").toContentModel()).getNodeSources(); + restClient.assertStatusCodeIs(HttpStatus.OK); + sources.assertThat().entriesListCountIs(1); + + sources.getEntryByIndex(0).assertThat() + .field("isFile").is(true).and() + .field("name").is(nodesBuilder.getNode("f1").getName()).and() + .field("id").is(nodesBuilder.getNode("f1").getId()).and() + .field("id").is(nodesBuilder.getNode("f1").getId()).and() + .field("nodeType").is("cm:content") + .getAssociation().assertThat() + .field("assocType").is("cm:references"); + } } From 94d82407dc2f104dcc38153d78cc402cf83eac1e Mon Sep 17 00:00:00 2001 From: Andreea Nechifor Date: Mon, 4 Sep 2017 17:07:57 +0300 Subject: [PATCH 1213/1491] Repo 2302 --- .../rest/renditions/GetRenditionTests.java | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/renditions/GetRenditionTests.java b/e2e-test/java/org/alfresco/rest/renditions/GetRenditionTests.java index 5e18e628d..62baa27f9 100644 --- a/e2e-test/java/org/alfresco/rest/renditions/GetRenditionTests.java +++ b/e2e-test/java/org/alfresco/rest/renditions/GetRenditionTests.java @@ -3,6 +3,7 @@ package org.alfresco.rest.renditions; import static org.alfresco.utility.report.log.Step.STEP; import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.RestResponse; import org.alfresco.rest.model.RestNodeModel; import org.alfresco.rest.model.RestRenditionInfoModel; import org.alfresco.utility.Utility; @@ -16,6 +17,7 @@ import org.alfresco.utility.report.Bug.Status; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; +import org.testng.Assert; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -94,4 +96,42 @@ public class GetRenditionTests extends RestTest renditionInfo.assertThat().field("status").is("CREATED"); renditionInfo.assertThat().field("content.sizeInBytes").isGreaterThan(120); } + + /** + * Sanity test for the following endpoint: + * GET /nodes/{nodeId}/renditions/{renditionId}/content + * @throws Exception + */ + @Test(groups = { TestGroup.REST_API, TestGroup.RENDITIONS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.RENDITIONS }, executionType = ExecutionType.SANITY, + description = "Verify that the rendition content can be downloaded using GET /nodes/{nodeId}/renditions/{renditionId}/content") + public void getRenditionContent() throws Exception + { + STEP("1. Create a folder in existing site"); + FolderModel folder = FolderModel.getRandomFolderModel(); + folder = dataContent.usingUser(user).usingSite(site).createFolder(folder); + + STEP("2. Upload a local txt file using RESTAPI"); + restClient.authenticateUser(user).configureRequestSpec().addMultiPart("filedata", Utility.getResourceTestDataFile("iso8859File.txt")); + + RestNodeModel fileNode = restClient.authenticateUser(user).withCoreAPI().usingNode(folder).createNode(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + FileModel file = new FileModel("iso8859File.txt"); + file.setCmisLocation(folder.getCmisLocation() + "/iso8859File.txt"); + file.setNodeRef(fileNode.getId()); + + STEP("3. Create thumbnail of txt file using RESTAPI"); + restClient.withCoreAPI().usingNode(file).createNodeRendition("doclib"); + restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); + + STEP("4. Verify thumbnail of txt file is created and has content using RESTAPI"); + RestResponse restResponse = restClient.withCoreAPI().usingNode(file).getNodeRenditionContentUntilIsCreated("doclib"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.assertHeaderValueContains("Content-Type","image/png;charset=UTF-8"); + Assert.assertTrue(restResponse.getResponse().body().asInputStream().available() > 0); + + + } + } + From 3a43b1b02bddd7b8ce1a73331278876a6168ffbd Mon Sep 17 00:00:00 2001 From: Andreea Nechifor Date: Tue, 5 Sep 2017 10:39:28 +0300 Subject: [PATCH 1214/1491] Repo-2304 --- .../rest/nodes/NodesTargetSourcesTests.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/nodes/NodesTargetSourcesTests.java b/e2e-test/java/org/alfresco/rest/nodes/NodesTargetSourcesTests.java index 6bf85f41b..efbaacc52 100644 --- a/e2e-test/java/org/alfresco/rest/nodes/NodesTargetSourcesTests.java +++ b/e2e-test/java/org/alfresco/rest/nodes/NodesTargetSourcesTests.java @@ -38,26 +38,28 @@ public class NodesTargetSourcesTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY }) public void checkTargetsNodeApi() throws Exception { - STEP("1.Create a folder hierarchy folder1/folder2, with folder2 containing 3 files: f1, f2, and f3"); - NodesBuilder nodesBuilder = restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingNode(ContentModel.my()).defineNodes(); - nodesBuilder.folder("F1").folder("F2").folder("F3").file("f1").file("f2").file("f3"); + STEP("1.Create folder1 which contains 3 files: f1, f2, and f3"); + NodesBuilder nodesBuilder = restClient.authenticateUser(adminUserModel).withCoreAPI().usingNode(ContentModel.my()).defineNodes(); + nodesBuilder.folder("F1").file("f1").file("f2").file("f3"); STEP("2. Create target associations model objects"); RestNodeAssocTargetModel assocDocTarget1 = new RestNodeAssocTargetModel(nodesBuilder.getNode("f2").toContentModel().getNodeRef(), "cm:references"); RestNodeAssocTargetModel assocDocTarget2 = new RestNodeAssocTargetModel(nodesBuilder.getNode("f3").toContentModel().getNodeRef(), "cm:references"); STEP("3. Create target associations using POST /nodes/{nodeId}/targets"); - restClient.authenticateUser(adminUserModel); restClient.withCoreAPI().usingResource(nodesBuilder.getNode("f1").toContentModel()).createTargetForNode(assocDocTarget1); restClient.assertStatusCodeIs(HttpStatus.CREATED); restClient.withCoreAPI().usingResource(nodesBuilder.getNode("f1").toContentModel()).createTargetForNode(assocDocTarget2); restClient.assertStatusCodeIs(HttpStatus.CREATED); STEP("4. Check using GET /nodes/{nodeId}/targets targets associations were created"); - RestNodeAssociationModelCollection tagets = restClient.withParams("where=(assocType='cm:references')").withCoreAPI() + RestNodeAssociationModelCollection targetsRes = restClient.withParams("where=(assocType='cm:references')").withCoreAPI() .usingResource(nodesBuilder.getNode("f1").toContentModel()).getNodeTargets(); restClient.assertStatusCodeIs(HttpStatus.OK); - tagets.assertThat().entriesListCountIs(2); + targetsRes.assertThat().entriesListCountIs(2); + targetsRes.getEntryByIndex(0).assertThat().field("association.assocType").is("cm:references"); + targetsRes.getEntryByIndex(1).assertThat().field("association.assocType").is("cm:references"); + STEP("5. Check using DELETE /nodes/{nodeId}/targets/{targetId} that a target can be deleted"); restClient.authenticateUser(adminUserModel); @@ -65,10 +67,11 @@ public class NodesTargetSourcesTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); STEP("6. Check using GET /nodes/{nodeId}/targets that target association was deleted"); - RestNodeAssociationModelCollection targetsRes = restClient.withParams("where=(assocType='cm:references')").withCoreAPI() + targetsRes = restClient.withParams("where=(assocType='cm:references')").withCoreAPI() .usingResource(nodesBuilder.getNode("f1").toContentModel()).getNodeTargets(); restClient.assertStatusCodeIs(HttpStatus.OK); targetsRes.assertThat().entriesListCountIs(1); + targetsRes.getEntryByIndex(0).assertThat().field("association.assocType").is("cm:references"); } /** From c3a7f5bd101bf7226083e588b35385016f8a7008 Mon Sep 17 00:00:00 2001 From: Andreea Nechifor Date: Tue, 5 Sep 2017 11:35:52 +0300 Subject: [PATCH 1215/1491] REpo-2302 --- .../java/org/alfresco/rest/renditions/GetRenditionTests.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/renditions/GetRenditionTests.java b/e2e-test/java/org/alfresco/rest/renditions/GetRenditionTests.java index 62baa27f9..2f602824f 100644 --- a/e2e-test/java/org/alfresco/rest/renditions/GetRenditionTests.java +++ b/e2e-test/java/org/alfresco/rest/renditions/GetRenditionTests.java @@ -129,8 +129,6 @@ public class GetRenditionTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); restClient.assertHeaderValueContains("Content-Type","image/png;charset=UTF-8"); Assert.assertTrue(restResponse.getResponse().body().asInputStream().available() > 0); - - } } From 018153f6bd927ae9735f660f2ff9d9c03fb89860 Mon Sep 17 00:00:00 2001 From: Andrei Forascu Date: Tue, 5 Sep 2017 12:02:10 +0300 Subject: [PATCH 1216/1491] REPO-2302 - RestAPI: Implement tests in TAS project for 'Nodes' RestApi endpoint - part 3: - changed sanity test to run faster --- .../java/org/alfresco/rest/nodes/NodesTargetSourcesTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/nodes/NodesTargetSourcesTests.java b/e2e-test/java/org/alfresco/rest/nodes/NodesTargetSourcesTests.java index efbaacc52..0cc46dfe9 100644 --- a/e2e-test/java/org/alfresco/rest/nodes/NodesTargetSourcesTests.java +++ b/e2e-test/java/org/alfresco/rest/nodes/NodesTargetSourcesTests.java @@ -99,7 +99,7 @@ public class NodesTargetSourcesTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.CREATED); STEP("4. Check using GET /nodes/{nodeId}/sources that all source associations are displayed"); - RestNodeAssociationModelCollection sources = restClient.withCoreAPI().usingNode(nodesBuilder.getNode("f3").toContentModel()).getNodeSources(); + RestNodeAssociationModelCollection sources = restClient.withCoreAPI().usingResource(nodesBuilder.getNode("f3").toContentModel()).getNodeSources(); restClient.assertStatusCodeIs(HttpStatus.OK); sources.assertThat().entriesListCountIs(2); From 7412e84e15af5f1f17eb5f3710a3c84e7d4751d0 Mon Sep 17 00:00:00 2001 From: Alexandru-Eusebiu Epure Date: Tue, 5 Sep 2017 12:22:22 +0300 Subject: [PATCH 1217/1491] REPO-2305 : RestAPI: Implement tests in TAS project for 'Nodes' RestApi endpoint - part 5 REPO-2306 : RestAPI: Implement tests in TAS project for 'Nodes' RestApi endpoint - part 6 Rename NodesContentTest to NodesContentAndVersioningTests Add two sanity tests (testGetVersionContent and testRevertDeleteVersion) --- ...va => NodesContentAndVersioningTests.java} | 97 ++++++++++++++++++- 1 file changed, 92 insertions(+), 5 deletions(-) rename e2e-test/java/org/alfresco/rest/nodes/{NodesContentTests.java => NodesContentAndVersioningTests.java} (58%) diff --git a/e2e-test/java/org/alfresco/rest/nodes/NodesContentTests.java b/e2e-test/java/org/alfresco/rest/nodes/NodesContentAndVersioningTests.java similarity index 58% rename from e2e-test/java/org/alfresco/rest/nodes/NodesContentTests.java rename to e2e-test/java/org/alfresco/rest/nodes/NodesContentAndVersioningTests.java index 7991f5a27..f4da4d307 100644 --- a/e2e-test/java/org/alfresco/rest/nodes/NodesContentTests.java +++ b/e2e-test/java/org/alfresco/rest/nodes/NodesContentAndVersioningTests.java @@ -1,8 +1,11 @@ package org.alfresco.rest.nodes; import static org.alfresco.utility.report.log.Step.STEP; +import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNotSame; +import static org.testng.Assert.assertNull; import static org.testng.Assert.assertSame; import static org.testng.Assert.assertTrue; @@ -11,7 +14,10 @@ import java.io.File; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.core.JsonBodyGenerator; +import org.alfresco.rest.core.RestResponse; import org.alfresco.rest.model.RestNodeModel; +import org.alfresco.rest.model.RestVersionModel; +import org.alfresco.rest.model.RestVersionModelsCollection; import org.alfresco.rest.model.body.RestNodeLockBodyModel; import org.alfresco.utility.Utility; import org.alfresco.utility.model.FileModel; @@ -32,12 +38,12 @@ import org.testng.annotations.Test; * @author mpopa * */ -public class NodesContentTests extends RestTest +public class NodesContentAndVersioningTests extends RestTest { private UserModel user1, user2; private SiteModel site1, site2; - private FileModel file1; - + private FileModel file1, file2; + @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception { @@ -46,6 +52,7 @@ public class NodesContentTests extends RestTest site1 = dataSite.usingUser(user1).createPublicRandomSite(); site2 = dataSite.usingUser(user2).createPublicRandomSite(); file1 = dataContent.usingUser(user1).usingSite(site1).createContent(DocumentType.TEXT_PLAIN); + file2 = dataContent.usingUser(user2).usingSite(site2).createContent(DocumentType.TEXT_PLAIN); } @TestRail(section = { TestGroup.REST_API,TestGroup.NODES }, executionType = ExecutionType.SANITY, @@ -112,8 +119,8 @@ public class NodesContentTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); STEP("2. Update the node content (different from the initial one) PUT /nodes/{nodeId}/content?majorVersion=true&name=newfile.txt."); - File avatarFile = Utility.getResourceTestDataFile("my-file.tif"); - RestNodeModel updatedBodyNode = restClient.withCoreAPI().usingNode(file1).usingParams("majorVersion=true&name=newfile.txt").updateNodeContent(avatarFile); + File updatedConentFile = Utility.getResourceTestDataFile("sampleContent.txt"); + RestNodeModel updatedBodyNode = restClient.withCoreAPI().usingNode(file1).usingParams("majorVersion=true&name=newfile.txt").updateNodeContent(updatedConentFile); restClient.assertStatusCodeIs(HttpStatus.OK); STEP("3. Compare contentSize, modifiedAt, name and version, they should be different."); @@ -158,4 +165,84 @@ public class NodesContentTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); assertFalse(initialNode.getIsLocked()); } + + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.NODES }, executionType = ExecutionType.SANITY, description = "Test retrieving node versions, a specific version and version content.") + public void testGetVersionContent() throws Exception + { + file2 = dataContent.usingUser(user2).usingSite(site2).createContent(DocumentType.TEXT_PLAIN); + File sampleFile = Utility.getResourceTestDataFile("sampleContent.txt"); + + STEP("1. Update the node content in order to increase version(one minor and one major) PUT /nodes/{nodeId}/content."); + //minor version update + restClient.authenticateUser(user2).withCoreAPI().usingNode(file2).updateNodeContent(sampleFile); + restClient.assertStatusCodeIs(HttpStatus.OK); + //major version update + restClient.authenticateUser(user2).withCoreAPI().usingParams("majorVersion=true").usingNode(file2).updateNodeContent(sampleFile); + restClient.assertStatusCodeIs(HttpStatus.OK); + + STEP("2. List node version history GET /nodes/{nodeId}/versions. And verify that first (in the list) version is 2.0 and last is 1.0."); + RestVersionModelsCollection versionListing = restClient.withCoreAPI().usingNode(file2).listVersionHistory(); + restClient.assertStatusCodeIs(HttpStatus.OK); + //additional check that the properties are not displayed by default. + assertEquals(versionListing.getEntries().get(versionListing.getPagination().getCount()-1).onModel().getId(),"1.0"); + assertEquals(versionListing.getEntries().get(0).onModel().getId(),"2.0"); + assertNull(versionListing.getEntries().get(0).onModel().getProperties()); + + STEP("3. List node version using skipCount(1),maxItems(1) and include(properties) GET /nodes/{nodeId}/versions?include=properties&skipCount=1&maxItems=1"); + versionListing = restClient.withCoreAPI().usingParams("include=properties&skipCount=1&maxItems=1").usingNode(file2).listVersionHistory(); + restClient.assertStatusCodeIs(HttpStatus.OK); + //we expect only version 1.1 to be retrieved with the value for properties. + RestVersionModel version = versionListing.getEntries().get(0).onModel(); + assertNotNull(version.getProperties()); + assertEquals(version.getId(), "1.1"); + assertEquals(versionListing.getPagination().getMaxItems(), 1); + assertEquals(versionListing.getPagination().getSkipCount(), 1); + assertEquals(versionListing.getPagination().getCount(), 1); + + STEP("4. Get version information for version 1.1 GET /nodes/{nodeId}/versions/{versionId} ."); + RestVersionModel version11 = restClient.withCoreAPI().usingNode(file2).getVersionInformation("1.1"); + restClient.assertStatusCodeIs(HttpStatus.OK); + //aspectNames and properties are displayed by default. We compare id,contentSize and name with the values from v1.1, taken from listing all versions. + assertNotNull(version11.getAspectNames()); + assertNotNull(version11.getProperties()); + assertEquals(version.getId(),version11.getId()); + assertEquals(version.getContent().getSizeInBytes(),version11.getContent().getSizeInBytes()); + assertEquals(version.getName(),version11.getName()); + + STEP("5. Retrieve version 2.0 content GET /nodes/{nodeId}/versions/{versionId}/content"); + RestResponse versionContent = restClient.withCoreAPI().usingNode(file2).getVersionContent("2.0"); + restClient.assertStatusCodeIs(HttpStatus.OK); + //verify the content is the same as the uploaded file and check in headers for Content-Disposition to validate the download as attachment and fileName. + assertEquals("Sample text.\n", versionContent.getResponse().body().asString()); + restClient.assertHeaderValueContains("Content-Disposition", "attachment"); + restClient.assertHeaderValueContains("Content-Disposition", String.format("filename=\"%s\"", file2.getName())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.NODES }, executionType = ExecutionType.SANITY, description = "Test revert and delete a node version.") + public void testRevertDeleteVersion() throws Exception + { + STEP("1. Revert to version 1.0 POST /nodes/{nodeId}/versions/{versionId}/revert"); + RestVersionModel version = restClient.authenticateUser(user2).withCoreAPI().usingNode(file2).revertVersion("1.0", new String("{}")); + restClient.assertStatusCodeIs(HttpStatus.OK); + String nodeVersionType = new JSONObject(version.toJson()).getJSONObject("properties").getString("cm:versionType"); + assertEquals(nodeVersionType , "MINOR"); + String nodeVersion = version.getId(); + + STEP("2. Revert to last minor version /nodes/{nodeId}/versions/{versionId}/revert"); + version = restClient.withCoreAPI().usingNode(file2).revertVersion(nodeVersion, new String("{\"majorVersion\": true}")); + restClient.assertStatusCodeIs(HttpStatus.OK); + nodeVersionType = new JSONObject(version.toJson()).getJSONObject("properties").getString("cm:versionType"); + assertEquals(nodeVersionType , "MAJOR"); + assertTrue(nodeVersion.charAt(0)+1 == version.getId().charAt(0)); + + STEP("3. Delete last MINOR version DELETE /nodes/{nodeId}/versions/{versionId}"); + restClient.withCoreAPI().usingNode(file2).deleteNodeVersion(nodeVersion); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withCoreAPI().usingNode(file2).getVersionInformation(nodeVersion); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } } From 75c4a6631cdaa7f37ae0d79ef4b1f141ba9af05f Mon Sep 17 00:00:00 2001 From: Andrei Forascu Date: Tue, 5 Sep 2017 13:40:13 +0300 Subject: [PATCH 1218/1491] REPO-2302 / REPO-2304 - code formatting --- .../java/org/alfresco/rest/nodes/NodesTargetSourcesTests.java | 4 +--- .../java/org/alfresco/rest/renditions/GetRenditionTests.java | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/nodes/NodesTargetSourcesTests.java b/e2e-test/java/org/alfresco/rest/nodes/NodesTargetSourcesTests.java index 0cc46dfe9..e0cbc83e0 100644 --- a/e2e-test/java/org/alfresco/rest/nodes/NodesTargetSourcesTests.java +++ b/e2e-test/java/org/alfresco/rest/nodes/NodesTargetSourcesTests.java @@ -53,14 +53,12 @@ public class NodesTargetSourcesTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.CREATED); STEP("4. Check using GET /nodes/{nodeId}/targets targets associations were created"); - RestNodeAssociationModelCollection targetsRes = restClient.withParams("where=(assocType='cm:references')").withCoreAPI() - .usingResource(nodesBuilder.getNode("f1").toContentModel()).getNodeTargets(); + RestNodeAssociationModelCollection targetsRes = restClient.withParams("where=(assocType='cm:references')").withCoreAPI().usingResource(nodesBuilder.getNode("f1").toContentModel()).getNodeTargets(); restClient.assertStatusCodeIs(HttpStatus.OK); targetsRes.assertThat().entriesListCountIs(2); targetsRes.getEntryByIndex(0).assertThat().field("association.assocType").is("cm:references"); targetsRes.getEntryByIndex(1).assertThat().field("association.assocType").is("cm:references"); - STEP("5. Check using DELETE /nodes/{nodeId}/targets/{targetId} that a target can be deleted"); restClient.authenticateUser(adminUserModel); restClient.withCoreAPI().usingResource(nodesBuilder.getNode("f1").toContentModel()).deleteTarget(assocDocTarget1); diff --git a/e2e-test/java/org/alfresco/rest/renditions/GetRenditionTests.java b/e2e-test/java/org/alfresco/rest/renditions/GetRenditionTests.java index 2f602824f..d5debda40 100644 --- a/e2e-test/java/org/alfresco/rest/renditions/GetRenditionTests.java +++ b/e2e-test/java/org/alfresco/rest/renditions/GetRenditionTests.java @@ -96,7 +96,7 @@ public class GetRenditionTests extends RestTest renditionInfo.assertThat().field("status").is("CREATED"); renditionInfo.assertThat().field("content.sizeInBytes").isGreaterThan(120); } - + /** * Sanity test for the following endpoint: * GET /nodes/{nodeId}/renditions/{renditionId}/content @@ -130,6 +130,6 @@ public class GetRenditionTests extends RestTest restClient.assertHeaderValueContains("Content-Type","image/png;charset=UTF-8"); Assert.assertTrue(restResponse.getResponse().body().asInputStream().available() > 0); } - + } From 48b9961db04796ef369d3659a66adb6c0d51627d Mon Sep 17 00:00:00 2001 From: Andreea Nechifor Date: Tue, 5 Sep 2017 14:16:59 +0300 Subject: [PATCH 1219/1491] Added more check --- .../org/alfresco/rest/nodes/NodesTargetSourcesTests.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/nodes/NodesTargetSourcesTests.java b/e2e-test/java/org/alfresco/rest/nodes/NodesTargetSourcesTests.java index e0cbc83e0..83863ad59 100644 --- a/e2e-test/java/org/alfresco/rest/nodes/NodesTargetSourcesTests.java +++ b/e2e-test/java/org/alfresco/rest/nodes/NodesTargetSourcesTests.java @@ -56,8 +56,10 @@ public class NodesTargetSourcesTests extends RestTest RestNodeAssociationModelCollection targetsRes = restClient.withParams("where=(assocType='cm:references')").withCoreAPI().usingResource(nodesBuilder.getNode("f1").toContentModel()).getNodeTargets(); restClient.assertStatusCodeIs(HttpStatus.OK); targetsRes.assertThat().entriesListCountIs(2); - targetsRes.getEntryByIndex(0).assertThat().field("association.assocType").is("cm:references"); - targetsRes.getEntryByIndex(1).assertThat().field("association.assocType").is("cm:references"); + targetsRes.getEntryByIndex(0).assertThat().field("association.assocType").is("cm:references").and().field("name") + .is(nodesBuilder.getNode("f2").getName()); + targetsRes.getEntryByIndex(1).assertThat().field("association.assocType").is("cm:references").and().field("name") + .is(nodesBuilder.getNode("f3").getName()); STEP("5. Check using DELETE /nodes/{nodeId}/targets/{targetId} that a target can be deleted"); restClient.authenticateUser(adminUserModel); From 8ebda8925ffe68e0beea27a0400dbc4e8d864626 Mon Sep 17 00:00:00 2001 From: Andrei Forascu Date: Wed, 13 Sep 2017 17:26:23 +0300 Subject: [PATCH 1220/1491] - fix maxItemsParameterApplied test by changing sort order --- .../org/alfresco/rest/workflow/tasks/GetTasksFullTests.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksFullTests.java index 1fdfff937..b1fa28ff2 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksFullTests.java @@ -64,11 +64,11 @@ public class GetTasksFullTests extends RestTest taskCollections = restClient.authenticateUser(userModel).withParams("orderBy=assignee ASC").withWorkflowAPI().getTasks(); restClient.assertStatusCodeIs(HttpStatus.OK); - taskModels = restClient.withParams("orderBy=assignee ASC&maxItems=2").withWorkflowAPI().getTasks(); + taskModels = restClient.withParams("orderBy=startedAt DESC&maxItems=2").withWorkflowAPI().getTasks(); restClient.assertStatusCodeIs(HttpStatus.OK); taskModels.assertThat().entriesListIsNotEmpty() .assertThat().entriesListContains("assignee", assigneeUser.getUsername()) - .assertThat().entriesListDoesNotContain("assignee", adminUser.getUsername()); + .assertThat().entriesListDoesNotContain("assignee", userModel.getUsername()); taskModels.assertThat().paginationField("maxItems").is("2"); taskModels.assertThat().paginationField("count").is("2"); } From e99a82a2efcedf4fb690adddbd631c9857aa0ac8 Mon Sep 17 00:00:00 2001 From: Rodica Sutu Date: Fri, 29 Sep 2017 16:47:50 +0300 Subject: [PATCH 1221/1491] - add requests for Trashcan - deleteNodes,Node - deleteNode,copyNode --- e2e-test/java/org/alfresco/rest/nodes/NodesTests.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/nodes/NodesTests.java b/e2e-test/java/org/alfresco/rest/nodes/NodesTests.java index eb4c25846..7bad114a4 100644 --- a/e2e-test/java/org/alfresco/rest/nodes/NodesTests.java +++ b/e2e-test/java/org/alfresco/rest/nodes/NodesTests.java @@ -1,7 +1,7 @@ package org.alfresco.rest.nodes; import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestNodeBodyMoveModel; +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; @@ -36,7 +36,7 @@ public class NodesTests extends RestTest NodeDetail destinationFolder = nodesBuilder.folder("destinationFolder"); // Move file from sourceFolder to destinationFolder - RestNodeBodyMoveModel moveDestinationInfo = new RestNodeBodyMoveModel(); + RestNodeBodyMoveCopyModel moveDestinationInfo = new RestNodeBodyMoveCopyModel(); moveDestinationInfo.setTargetParentId(destinationFolder.getId()); ContentModel fileToMove = new ContentModel(); From e760944c3b5631fd0249510e717780a98b52e443 Mon Sep 17 00:00:00 2001 From: cagache Date: Tue, 3 Oct 2017 11:50:36 +0300 Subject: [PATCH 1222/1491] REPO-2755 / REPO-2251: regrouped add favorites tests --- .../favorites/AddFavoriteSiteCoreTests.java | 189 ------ .../favorites/AddFavoriteSiteFullTests.java | 328 ----------- .../favorites/AddFavoriteSiteSanityTests.java | 107 ---- .../rest/favorites/AddFavoriteSiteTests.java | 544 ++++++++++++++++++ .../rest/favorites/AddFavoritesCoreTests.java | 230 -------- .../rest/favorites/AddFavoritesFullTests.java | 267 --------- .../favorites/AddFavoritesSanityTests.java | 102 ---- .../rest/favorites/AddFavoritesTests.java | 509 ++++++++++++++++ 8 files changed, 1053 insertions(+), 1223 deletions(-) delete mode 100644 e2e-test/java/org/alfresco/rest/favorites/AddFavoriteSiteCoreTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/favorites/AddFavoriteSiteFullTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/favorites/AddFavoriteSiteSanityTests.java create mode 100644 e2e-test/java/org/alfresco/rest/favorites/AddFavoriteSiteTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/favorites/AddFavoritesCoreTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/favorites/AddFavoritesFullTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/favorites/AddFavoritesSanityTests.java create mode 100644 e2e-test/java/org/alfresco/rest/favorites/AddFavoritesTests.java diff --git a/e2e-test/java/org/alfresco/rest/favorites/AddFavoriteSiteCoreTests.java b/e2e-test/java/org/alfresco/rest/favorites/AddFavoriteSiteCoreTests.java deleted file mode 100644 index 59ae6aa3c..000000000 --- a/e2e-test/java/org/alfresco/rest/favorites/AddFavoriteSiteCoreTests.java +++ /dev/null @@ -1,189 +0,0 @@ -package org.alfresco.rest.favorites; - -import org.alfresco.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestPersonFavoritesModelsCollection; -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.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class AddFavoriteSiteCoreTests extends RestTest -{ - UserModel userModel, adminUserModel; - SiteModel siteModel, privateSiteModel, moderatedSiteModel; - UserModel searchedUser; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - privateSiteModel = dataSite.usingUser(userModel).createPrivateRandomSite(); - moderatedSiteModel = dataSite.usingUser(userModel).createModeratedRandomSite(); - } - - @Bug(id="ACE-2413") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify empty user is not able to add a site from favorites and response is (400)") - public void emptyUserIsNotAbleToRemoveFavoriteSite() throws Exception - { - UserModel emptyUser = new UserModel("", "password"); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(emptyUser).addFavoriteSite(siteModel); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "emptyUser")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify inexistent user is not able to add a site from favorites and response is (404)") - public void inexistentUserIsNotAbleToRemoveFavoriteSite() throws Exception - { - UserModel inexistentUser = new UserModel("inexistentUser", "password"); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(inexistentUser).addFavoriteSite(siteModel); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "inexistentUser")) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify manager user is not able to add a favorite site when the site is already favorite - status code (409)") - public void managerUserAddFavoriteSiteAlreadyAFavoriteSite() throws Exception - { - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); - - restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().addFavoriteSite(siteModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.withCoreAPI().usingUser(managerUser).addFavoriteSite(siteModel); - restClient.assertStatusCodeIs(HttpStatus.CONFLICT); - restClient.assertLastError() - .containsSummary(String.format("%s is already a favourite site", siteModel.getId())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE) - .containsErrorKey(String.format("Site %s is already a favourite site", siteModel.getId())); - } - - @Bug(id="REPO-1827") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify user is not able to add a favorite site when the 'id' is empty - status code (400)") - public void userAddFavoriteSiteAFavoriteSite() throws Exception - { - siteModel.setId(""); - restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().addFavoriteSite(siteModel); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - restClient.assertLastError() - .containsSummary("siteId is null") - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify user doesn't have permission to delete favorites of admin user with Rest API and status code is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - public void userIsNotAbleToAddFavoriteSiteOfAnotherUser() throws JsonToModelConversionException, Exception - { - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(contributorUser, siteModel, UserRole.SiteContributor); - UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel, UserRole.SiteConsumer); - - restClient.authenticateUser(consumerUser).withCoreAPI() - .usingUser(contributorUser).addFavoriteSite(siteModel); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError() - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify manager user is able to add as favorite a private site.") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - public void managerAddsPrivateSiteAsFavorite() throws JsonToModelConversionException, Exception - { - UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(managerUser, privateSiteModel, UserRole.SiteManager); - - restClient.authenticateUser(managerUser).withCoreAPI().usingUser(managerUser).addFavoriteSite(privateSiteModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestPersonFavoritesModelsCollection favorites = restClient.withCoreAPI().usingAuthUser().getFavorites(); - favorites.assertThat().entriesListContains("targetGuid", privateSiteModel.getGuidWithoutVersion()) - .and().paginationField("totalItems").is("1"); - favorites.getOneRandomEntry().onModel().getTarget().getSite() - .assertThat() - .field("description").is(privateSiteModel.getDescription()) - .and().field("id").is(privateSiteModel.getId()) - .and().field("visibility").is(privateSiteModel.getVisibility().toString()) - .and().field("title").is(privateSiteModel.getTitle()); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify manager user is able to add as favorite a moderated site.") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - public void managerAddsModeratedSiteAsFavorite() throws JsonToModelConversionException, Exception - { - UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(managerUser, moderatedSiteModel, UserRole.SiteManager); - - restClient.authenticateUser(managerUser).withCoreAPI().usingUser(managerUser).addFavoriteSite(moderatedSiteModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestPersonFavoritesModelsCollection favorites = restClient.withCoreAPI().usingAuthUser().getFavorites(); - favorites.assertThat().entriesListContains("targetGuid", moderatedSiteModel.getGuidWithoutVersion()) - .and().paginationField("totalItems").is("1"); - favorites.getOneRandomEntry().onModel().getTarget().getSite() - .assertThat() - .field("description").is(moderatedSiteModel.getDescription()) - .and().field("id").is(moderatedSiteModel.getId()) - .and().field("visibility").is(moderatedSiteModel.getVisibility().toString()) - .and().field("title").is(moderatedSiteModel.getTitle()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify user removes a site from favorites using '-me-' in place of personId with Rest API and response is successful (201)") - public void addFavoriteSiteWithSuccessUsingMeAsPersonId() throws Exception - { - restClient.authenticateUser(adminUserModel); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingMe().addFavoriteSite(moderatedSiteModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify manager user removes a site from its favorites and adds it again and response is successful (204)") - public void managerUserRemovesFavoriteSiteAndAddItAgain() throws Exception - { - UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); - dataSite.usingUser(managerUser).usingSite(siteModel).addSiteToFavorites(); - - restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingUser(managerUser).addSiteToFavorites(siteModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - } - -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/favorites/AddFavoriteSiteFullTests.java b/e2e-test/java/org/alfresco/rest/favorites/AddFavoriteSiteFullTests.java deleted file mode 100644 index c10480f3e..000000000 --- a/e2e-test/java/org/alfresco/rest/favorites/AddFavoriteSiteFullTests.java +++ /dev/null @@ -1,328 +0,0 @@ -package org.alfresco.rest.favorites; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.core.RestRequest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestCommentModel; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestFavoriteSiteModel; -import org.alfresco.rest.model.RestPersonFavoritesModel; -import org.alfresco.rest.model.RestPersonFavoritesModelsCollection; -import org.alfresco.rest.model.RestTagModel; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.LinkModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class AddFavoriteSiteFullTests extends RestTest -{ - UserModel userModel, adminUserModel, adminTenantUser, tenantUser; - SiteModel siteModel, privateSiteModel, moderatedSiteModel; - UserModel searchedUser; - FileModel document; - FolderModel folder; - private RestCommentModel comment; - private RestTagModel returnedModel; - private RestFavoriteSiteModel restFavoriteSiteModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - privateSiteModel = dataSite.usingUser(userModel).createPrivateRandomSite(); - moderatedSiteModel = dataSite.usingUser(userModel).createModeratedRandomSite(); - - document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - folder = dataContent.usingSite(siteModel).usingUser(adminUserModel).createFolder(); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify admin user doesn't have permission to add a favorite site of another user with Rest API and status code is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - public void adminIsNotAbleToAddFavoriteSiteOfAnotherUser() throws JsonToModelConversionException, Exception - { - UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(collaboratorUser, siteModel, UserRole.SiteCollaborator); - restClient.authenticateUser(collaboratorUser) - .withCoreAPI().usingUser(adminUserModel).addFavoriteSite(siteModel); - - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError() - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Bug(id="MNT-17338") - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify admin user doesn't have permission to add a favorite site of another user with Rest API and status code is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - public void userIsNotAbleToAddFavoriteSiteOfAdmin() throws JsonToModelConversionException, Exception - { - UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel, UserRole.SiteConsumer); - restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingUser(consumerUser).addFavoriteSite(siteModel); - - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError() - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify add favorite site using empty body - status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL}) - public void addFavoriteSiteWithEmptyBody() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI(); - RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{\"ids\": \"local\"}" , - "people/{personId}/favorite-sites", adminUserModel.getUsername()); - restClient.processModel(RestPersonFavoritesModel.class, request); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsSummary(String.format(RestErrorModel.NO_CONTENT, "Unrecognized field " + "\"ids\"")); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify add favorite site using empty body - status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - public void addFavoriteSiteWithEmptyRequiredFieldsBody() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI(); - RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{\"\": \"\"}", - "people/{personId}/favorite-sites", adminUserModel.getUsername()); - restClient.processModel(RestPersonFavoritesModel.class, request); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsSummary(String.format(RestErrorModel.NO_CONTENT, "Unrecognized field " + "\"\"")); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify non member user is not able to add a private favorite site - status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - public void userAddFavoriteSiteUserNotMemberOfPrivateSite() throws JsonToModelConversionException, Exception - { - UserModel user = dataUser.usingAdmin().createRandomTestUser(); - restClient.authenticateUser(user).withCoreAPI() - .usingAuthUser().addFavoriteSite(privateSiteModel); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, privateSiteModel.getId())) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify non member user is able to add a moderated favorite site") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - public void userAddFavoriteSiteUserNotMemberOfModeratedSite() throws JsonToModelConversionException, Exception - { - UserModel user = dataUser.usingAdmin().createRandomTestUser(); - restClient.authenticateUser(user).withCoreAPI().usingAuthUser() - .addFavoriteSite(moderatedSiteModel); - - RestPersonFavoritesModelsCollection favorites = restClient.withCoreAPI().usingAuthUser().getFavorites(); - favorites.assertThat().entriesListContains("targetGuid", moderatedSiteModel.getGuidWithoutVersion()) - .and().paginationField("totalItems").is("1"); - favorites.getOneRandomEntry().onModel().getTarget().getSite() - .assertThat() - .field("description").is(moderatedSiteModel.getDescription()) - .and().field("id").is(moderatedSiteModel.getId()) - .and().field("visibility").is(moderatedSiteModel.getVisibility().toString()) - .and().field("title").is(moderatedSiteModel.getTitle()); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify non member user is able to add a public favorite site") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - public void userAddFavoriteSiteUserNotMemberOfPublicSite() throws JsonToModelConversionException, Exception - { - UserModel user = dataUser.usingAdmin().createRandomTestUser(); - restFavoriteSiteModel = restClient.authenticateUser(user).withCoreAPI().usingAuthUser().addFavoriteSite(siteModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restFavoriteSiteModel.assertThat().field("id").is(siteModel.getId()); - - RestPersonFavoritesModelsCollection favorites = restClient.withCoreAPI().usingAuthUser().getFavorites(); - favorites.assertThat().entriesListContains("targetGuid", siteModel.getGuidWithoutVersion()) - .and().paginationField("totalItems").is("1"); - favorites.getOneRandomEntry().onModel().getTarget().getSite() - .assertThat() - .field("description").is(siteModel.getDescription()) - .and().field("id").is(siteModel.getId()) - .and().field("visibility").is(siteModel.getVisibility().toString()) - .and().field("title").is(siteModel.getTitle()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Check that if id does not exist, status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - public void addFavoriteSiteUsingInvalidId() throws Exception - { - SiteModel site = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - String id = siteModel.getId(); - site.setId("invalidID"); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFavoriteSite(site); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidID")); - - siteModel.setId(id); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Check that if user provides site in id but id is of a file status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - public void addSiteToFavoritesUsingFileId() throws Exception - { - String id = siteModel.getId(); - siteModel.setId(document.getNodeRefWithoutVersion()); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFavoriteSite(siteModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, document.getNodeRefWithoutVersion())); - - siteModel.setId(id); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Check that if user provides site in id but id is of a folder status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - public void addSiteToFavoritesUsingFolderId() throws Exception - { - String id = siteModel.getId(); - siteModel.setId(folder.getNodeRefWithoutVersion()); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFavoriteSite(siteModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, folder.getNodeRefWithoutVersion())); - - siteModel.setId(id); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Check that if user provides site in id but id is of a comment status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - public void addSiteToFavoriteUsingCommentId() throws Exception - { - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - String id = siteModel.getId(); - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - comment = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment("This is a comment"); - file.setNodeRef(comment.getId()); - siteModel.setId(comment.getId()); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFavoriteSite(siteModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - siteModel.setId(id); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Check that if user provides site in id but id is of a tag status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - public void addSiteFavoriteUsingTagId() throws Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - returnedModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addTag("random_tag"); - file.setNodeRef(returnedModel.getId()); - siteModel.setId(returnedModel.getId()); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFavoriteSite(siteModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, returnedModel.getId())); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Check that if id does not describe a site, file, or folder status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) - public void addFavoriteUsingInvalidGuid() throws Exception - { - LinkModel link = dataLink.usingAdmin().usingSite(siteModel).createRandomLink(); - SiteModel site = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - site.setId(link.getNodeRef()); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFavoriteSite(site); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, site.getId().split("/")[3])); - } - - @Bug(id="MNT-16904") - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Verify tenant user is not able to delete favorites using an invalid network ID - status code (401)") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.NETWORKS, TestGroup.FULL }) - public void tenantIsNotAbleToDeleteFavoriteSiteWithInvalidNetworkID() throws JsonToModelConversionException, Exception - { - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUserModel).usingTenant().createTenant(adminTenantUser); - tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - siteModel = dataSite.usingUser(tenantUser).createPublicRandomSite(); - siteModel.setGuid(restClient.authenticateUser(tenantUser).withCoreAPI().usingSite(siteModel).getSite().getGuid()); - restClient.authenticateUser(tenantUser).withCoreAPI(); - tenantUser.setDomain("invalidNetwork"); - - restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE}, executionType = ExecutionType.REGRESSION, - description = "Verify tenant user deletes favorites site and status code is (201)") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.NETWORKS, TestGroup.FULL }) - public void tenantDeleteFavoriteSiteValidNetwork() throws JsonToModelConversionException, Exception - { - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUserModel).usingTenant().createTenant(adminTenantUser); - tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - siteModel = dataSite.usingUser(tenantUser).createPublicRandomSite(); - siteModel.setGuid(restClient.authenticateUser(tenantUser).withCoreAPI().usingSite(siteModel).getSite().getGuid()); - restClient.authenticateUser(tenantUser).withCoreAPI(); - tenantUser.setDomain(tenantUser.getDomain()); - - restClient.withCoreAPI() - .usingAuthUser().addSiteToFavorites(siteModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.withCoreAPI().usingAuthUser().getFavorites() - .assertThat() - .entriesListContains("targetGuid", siteModel.getGuidWithoutVersion()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE}, executionType = ExecutionType.REGRESSION, - description = "Verify tenant user deletes favorites site created by admin tenant - same network and status code is (201)") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.NETWORKS, TestGroup.FULL }) - public void tenantUserIsAbleToDeleteFavoriteSiteAddedByAdminSameNetwork() throws JsonToModelConversionException, Exception - { - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUserModel).usingTenant().createTenant(adminTenantUser); - tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); - siteModel.setGuid(restClient.authenticateUser(adminTenantUser).withCoreAPI().usingSite(siteModel).getSite().getGuid()); - restClient.authenticateUser(tenantUser).withCoreAPI(); - tenantUser.setDomain(adminTenantUser.getDomain()); - - restClient.withCoreAPI().usingAuthUser().addFavoriteSite(siteModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.withCoreAPI().usingAuthUser().getFavorites() - .assertThat() - .entriesListContains("targetGuid", siteModel.getGuidWithoutVersion()); - } - -} diff --git a/e2e-test/java/org/alfresco/rest/favorites/AddFavoriteSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/AddFavoriteSiteSanityTests.java deleted file mode 100644 index b01e0472d..000000000 --- a/e2e-test/java/org/alfresco/rest/favorites/AddFavoriteSiteSanityTests.java +++ /dev/null @@ -1,107 +0,0 @@ -package org.alfresco.rest.favorites; - -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestFavoriteSiteModel; -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.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class AddFavoriteSiteSanityTests extends RestTest -{ - UserModel userModel; - SiteModel siteModel; - UserModel searchedUser; - private RestFavoriteSiteModel restFavoriteSiteModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user add a favorite site with Rest API and response is successful (201)") - public void managerUserAddFavoriteSiteWithSuccess() throws Exception - { - UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); - - restFavoriteSiteModel = restClient.authenticateUser(managerUser).withCoreAPI().usingUser(managerUser).addFavoriteSite(siteModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restFavoriteSiteModel.assertThat().field("id").is(siteModel.getId()); - - restClient.withCoreAPI().usingUser(managerUser).addFavoriteSite(siteModel); - restClient.assertStatusCodeIs(HttpStatus.CONFLICT); - restClient.assertLastError().containsSummary(String.format("%s is already a favourite site", siteModel.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify collaborator user add a favorite site with Rest API and response is successful (201)") - public void collaboratorUserAddFavoriteSiteWithSuccess() throws Exception - { - UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(collaboratorUser, siteModel, UserRole.SiteCollaborator); - - restFavoriteSiteModel = restClient.authenticateUser(collaboratorUser).withCoreAPI().usingAuthUser().addFavoriteSite(siteModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restFavoriteSiteModel.assertThat().field("id").is(siteModel.getId()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify contributor user add a favorite site with Rest API and response is successful (201)") - public void contributorUserAddFavoriteSiteWithSuccess() throws Exception - { - UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(contributorUser, siteModel, UserRole.SiteContributor); - - restFavoriteSiteModel = restClient.authenticateUser(contributorUser).withCoreAPI().usingAuthUser().addFavoriteSite(siteModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restFavoriteSiteModel.assertThat().field("id").is(siteModel.getId()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify consumer user add a favorite site with Rest API and response is successful (201)") - public void consumerUserAddFavoriteSiteWithSuccess() throws Exception - { - UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel, UserRole.SiteConsumer); - - restFavoriteSiteModel = restClient.authenticateUser(consumerUser).withCoreAPI().usingAuthUser().addFavoriteSite(siteModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restFavoriteSiteModel.assertThat().field("id").is(siteModel.getId()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify admin user add a favorite site with Rest API and response is successful (201)") - public void adminUserAddFavoriteSiteWithSuccess() throws Exception - { - UserModel adminUser = dataUser.getAdminUser(); - - restFavoriteSiteModel = restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().addFavoriteSite(siteModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restFavoriteSiteModel.assertThat().field("id").is(siteModel.getId()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify a manager user is NOT Authorized to add a favorite site with Rest API when authentication fails (401)") - @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void managerUserNotAuthorizedFailsToAddFavoriteSite() throws Exception - { - UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); - managerUser.setPassword("newpassword"); - - restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().addFavoriteSite(siteModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } -} diff --git a/e2e-test/java/org/alfresco/rest/favorites/AddFavoriteSiteTests.java b/e2e-test/java/org/alfresco/rest/favorites/AddFavoriteSiteTests.java new file mode 100644 index 000000000..51f4d7525 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/favorites/AddFavoriteSiteTests.java @@ -0,0 +1,544 @@ +package org.alfresco.rest.favorites; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.*; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.model.*; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class AddFavoriteSiteTests extends RestTest +{ + private UserModel userModel, adminUser, adminTenantUser, tenantUser; + private SiteModel publicSite, privateSite, moderatedSite; + private FileModel document; + private FolderModel folder; + private RestFavoriteSiteModel restFavoriteSiteModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userModel = dataUser.createRandomTestUser(); + + publicSite = dataSite.usingUser(userModel).createPublicRandomSite(); + privateSite = dataSite.usingUser(userModel).createPrivateRandomSite(); + moderatedSite = dataSite.usingUser(userModel).createModeratedRandomSite(); + + document = dataContent.usingSite(publicSite).usingUser(adminUser).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + folder = dataContent.usingSite(publicSite).usingUser(adminUser).createFolder(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user add a favorite site with Rest API and response is successful (201)") + public void managerUserAddFavoriteSiteWithSuccess() throws Exception + { + UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(managerUser, publicSite, UserRole.SiteManager); + + restFavoriteSiteModel = restClient.authenticateUser(managerUser).withCoreAPI().usingUser(managerUser).addFavoriteSite(publicSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restFavoriteSiteModel.assertThat().field("id").is(publicSite.getId()); + + restClient.withCoreAPI().usingUser(managerUser).addFavoriteSite(publicSite); + restClient.assertStatusCodeIs(HttpStatus.CONFLICT); + restClient.assertLastError().containsSummary(String.format("%s is already a favourite site", publicSite.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify a manager user is NOT Authorized to add a favorite site with Rest API when authentication fails (401)") +// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") + public void managerUserNotAuthorizedFailsToAddFavoriteSite() throws Exception + { + UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(managerUser, publicSite, UserRole.SiteManager); + managerUser.setPassword("newpassword"); + + restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().addFavoriteSite(publicSite); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify collaborator user add a favorite site with Rest API and response is successful (201)") + public void collaboratorUserAddFavoriteSiteWithSuccess() throws Exception + { + UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(collaboratorUser, publicSite, UserRole.SiteCollaborator); + + restFavoriteSiteModel = restClient.authenticateUser(collaboratorUser).withCoreAPI().usingAuthUser().addFavoriteSite(publicSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restFavoriteSiteModel.assertThat().field("id").is(publicSite.getId()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify contributor user add a favorite site with Rest API and response is successful (201)") + public void contributorUserAddFavoriteSiteWithSuccess() throws Exception + { + UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(contributorUser, publicSite, UserRole.SiteContributor); + + restFavoriteSiteModel = restClient.authenticateUser(contributorUser).withCoreAPI().usingAuthUser().addFavoriteSite(publicSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restFavoriteSiteModel.assertThat().field("id").is(publicSite.getId()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify consumer user add a favorite site with Rest API and response is successful (201)") + public void consumerUserAddFavoriteSiteWithSuccess() throws Exception + { + UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(consumerUser, publicSite, UserRole.SiteConsumer); + + restFavoriteSiteModel = restClient.authenticateUser(consumerUser).withCoreAPI().usingAuthUser().addFavoriteSite(publicSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restFavoriteSiteModel.assertThat().field("id").is(publicSite.getId()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin user add a favorite site with Rest API and response is successful (201)") + public void adminUserAddFavoriteSiteWithSuccess() throws Exception + { + restFavoriteSiteModel = restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().addFavoriteSite(publicSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restFavoriteSiteModel.assertThat().field("id").is(publicSite.getId()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify manager user is not able to add a favorite site when the site is already favorite - status code (409)") + public void managerUserAddFavoriteSiteAlreadyAFavoriteSite() throws Exception + { + publicSite = dataSite.usingUser(userModel).createPublicRandomSite(); + UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(managerUser, publicSite, UserRole.SiteManager); + + restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().addFavoriteSite(publicSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.withCoreAPI().usingUser(managerUser).addFavoriteSite(publicSite); + restClient.assertStatusCodeIs(HttpStatus.CONFLICT); + restClient.assertLastError() + .containsSummary(String.format("%s is already a favourite site", publicSite.getId())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE) + .containsErrorKey(String.format("Site %s is already a favourite site", publicSite.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify user doesn't have permission to delete favorites of admin user with Rest API and status code is 403") + public void userIsNotAbleToAddFavoriteSiteOfAnotherUser() throws Exception + { + publicSite = dataSite.usingUser(userModel).createPublicRandomSite(); + UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(contributorUser, publicSite, UserRole.SiteContributor); + UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(consumerUser, publicSite, UserRole.SiteConsumer); + + restClient.authenticateUser(consumerUser).withCoreAPI() + .usingUser(contributorUser).addFavoriteSite(publicSite); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError() + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify manager user is able to add as favorite a private site.") + public void managerAddsPrivateSiteAsFavorite() throws Exception + { + UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(managerUser, privateSite, UserRole.SiteManager); + + restClient.authenticateUser(managerUser).withCoreAPI().usingUser(managerUser).addFavoriteSite(privateSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestPersonFavoritesModelsCollection favorites = restClient.withCoreAPI().usingAuthUser().getFavorites(); + favorites.assertThat().entriesListContains("targetGuid", privateSite.getGuidWithoutVersion()) + .and().paginationField("totalItems").is("1"); + favorites.getOneRandomEntry().onModel().getTarget().getSite() + .assertThat() + .field("description").is(privateSite.getDescription()) + .and().field("id").is(privateSite.getId()) + .and().field("visibility").is(privateSite.getVisibility().toString()) + .and().field("title").is(privateSite.getTitle()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify manager user is able to add as favorite a moderated site.") + public void managerAddsModeratedSiteAsFavorite() throws Exception + { + UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(managerUser, moderatedSite, UserRole.SiteManager); + + restClient.authenticateUser(managerUser).withCoreAPI().usingUser(managerUser).addFavoriteSite(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestPersonFavoritesModelsCollection favorites = restClient.withCoreAPI().usingAuthUser().getFavorites(); + favorites.assertThat().entriesListContains("targetGuid", moderatedSite.getGuidWithoutVersion()) + .and().paginationField("totalItems").is("1"); + favorites.getOneRandomEntry().onModel().getTarget().getSite() + .assertThat() + .field("description").is(moderatedSite.getDescription()) + .and().field("id").is(moderatedSite.getId()) + .and().field("visibility").is(moderatedSite.getVisibility().toString()) + .and().field("title").is(moderatedSite.getTitle()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify user removes a site from favorites using '-me-' in place of personId with Rest API and response is successful (201)") + public void addFavoriteSiteWithSuccessUsingMeAsPersonId() throws Exception + { + restClient.authenticateUser(adminUser).withCoreAPI().usingMe().addFavoriteSite(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify manager user removes a site from its favorites and adds it again and response is successful (204)") + public void managerUserRemovesFavoriteSiteAndAddItAgain() throws Exception + { + UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(managerUser, publicSite, UserRole.SiteManager); + dataSite.usingUser(managerUser).usingSite(publicSite).addSiteToFavorites(); + + restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().removeFavoriteSite(publicSite); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingUser(managerUser).addSiteToFavorites(publicSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + } + + @Bug(id="ACE-2413") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify empty user is not able to add a site from favorites and response is (400)") + public void emptyUserIsNotAbleToRemoveFavoriteSite() throws Exception + { + UserModel emptyUser = new UserModel("", "password"); + restClient.authenticateUser(adminUser).withCoreAPI().usingUser(emptyUser).addFavoriteSite(publicSite); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "emptyUser")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify inexistent user is not able to add a site from favorites and response is (404)") + public void inexistentUserIsNotAbleToRemoveFavoriteSite() throws Exception + { + UserModel inexistentUser = new UserModel("inexistentUser", "password"); + restClient.authenticateUser(adminUser).withCoreAPI().usingUser(inexistentUser).addFavoriteSite(publicSite); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "inexistentUser")) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Bug(id="REPO-1827") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify user is not able to add a favorite site when the 'id' is empty - status code (400)") + public void userAddFavoriteSiteWithEmptySiteId() throws Exception + { + publicSite.setId(""); + restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().addFavoriteSite(publicSite); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + restClient.assertLastError() + .containsSummary("siteId is null") + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify admin user doesn't have permission to add a favorite site of another user with Rest API and status code is 403") + public void adminIsNotAbleToAddFavoriteSiteOfAnotherUser() throws Exception + { + UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(collaboratorUser, publicSite, UserRole.SiteCollaborator); + restClient.authenticateUser(collaboratorUser) + .withCoreAPI().usingUser(adminUser).addFavoriteSite(publicSite); + + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError() + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Bug(id="MNT-17338") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify admin user doesn't have permission to add a favorite site of another user with Rest API and status code is 403") + public void userIsNotAbleToAddFavoriteSiteOfAdmin() throws Exception + { + UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(consumerUser, publicSite, UserRole.SiteConsumer); + restClient.authenticateUser(adminUser) + .withCoreAPI().usingUser(consumerUser).addFavoriteSite(publicSite); + + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError() + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify add favorite site using empty body - status code is 400") + public void addFavoriteSiteWithEmptyBody() throws Exception + { + restClient.authenticateUser(adminUser).withCoreAPI(); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{\"ids\": \"local\"}" , + "people/{personId}/favorite-sites", adminUser.getUsername()); + restClient.processModel(RestPersonFavoritesModel.class, request); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsSummary(String.format(RestErrorModel.NO_CONTENT, "Unrecognized field " + "\"ids\"")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify add favorite site using empty body - status code is 400") + public void addFavoriteSiteWithEmptyRequiredFieldsBody() throws Exception + { + restClient.authenticateUser(adminUser).withCoreAPI(); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{\"\": \"\"}", + "people/{personId}/favorite-sites", adminUser.getUsername()); + restClient.processModel(RestPersonFavoritesModel.class, request); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsSummary(String.format(RestErrorModel.NO_CONTENT, "Unrecognized field " + "\"\"")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify non member user is not able to add a private favorite site - status code is 404") + public void userAddFavoriteSiteUserNotMemberOfPrivateSite() throws Exception + { + UserModel user = dataUser.usingAdmin().createRandomTestUser(); + restClient.authenticateUser(user).withCoreAPI() + .usingAuthUser().addFavoriteSite(privateSite); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, privateSite.getId())) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify non member user is able to add a moderated favorite site") + public void userAddFavoriteSiteUserNotMemberOfModeratedSite() throws Exception + { + UserModel user = dataUser.usingAdmin().createRandomTestUser(); + restClient.authenticateUser(user).withCoreAPI().usingAuthUser() + .addFavoriteSite(moderatedSite); + + RestPersonFavoritesModelsCollection favorites = restClient.withCoreAPI().usingAuthUser().getFavorites(); + favorites.assertThat().entriesListContains("targetGuid", moderatedSite.getGuidWithoutVersion()) + .and().paginationField("totalItems").is("1"); + favorites.getOneRandomEntry().onModel().getTarget().getSite() + .assertThat() + .field("description").is(moderatedSite.getDescription()) + .and().field("id").is(moderatedSite.getId()) + .and().field("visibility").is(moderatedSite.getVisibility().toString()) + .and().field("title").is(moderatedSite.getTitle()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify non member user is able to add a public favorite site") + public void userAddFavoriteSiteUserNotMemberOfPublicSite() throws Exception + { + UserModel user = dataUser.usingAdmin().createRandomTestUser(); + restFavoriteSiteModel = restClient.authenticateUser(user).withCoreAPI().usingAuthUser().addFavoriteSite(publicSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restFavoriteSiteModel.assertThat().field("id").is(publicSite.getId()); + + RestPersonFavoritesModelsCollection favorites = restClient.withCoreAPI().usingAuthUser().getFavorites(); + favorites.assertThat().entriesListContains("targetGuid", publicSite.getGuidWithoutVersion()) + .and().paginationField("totalItems").is("1"); + favorites.getOneRandomEntry().onModel().getTarget().getSite() + .assertThat() + .field("description").is(publicSite.getDescription()) + .and().field("id").is(publicSite.getId()) + .and().field("visibility").is(publicSite.getVisibility().toString()) + .and().field("title").is(publicSite.getTitle()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Check that if id does not exist, status code is 404") + public void addFavoriteSiteUsingInvalidId() throws Exception + { + SiteModel site = dataSite.usingUser(adminUser).createPublicRandomSite(); + String id = publicSite.getId(); + site.setId("invalidID"); + + restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().addFavoriteSite(site); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidID")); + + publicSite.setId(id); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Check that if user provides site in id but id is of a file status code is 404") + public void addSiteToFavoritesUsingFileId() throws Exception + { + String id = publicSite.getId(); + publicSite.setId(document.getNodeRefWithoutVersion()); + + restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().addFavoriteSite(publicSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, document.getNodeRefWithoutVersion())); + + publicSite.setId(id); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Check that if user provides site in id but id is of a folder status code is 404") + public void addSiteToFavoritesUsingFolderId() throws Exception + { + String id = publicSite.getId(); + publicSite.setId(folder.getNodeRefWithoutVersion()); + + restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().addFavoriteSite(publicSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, folder.getNodeRefWithoutVersion())); + + publicSite.setId(id); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Check that if user provides site in id but id is of a comment status code is 404") + public void addSiteToFavoriteUsingCommentId() throws Exception + { + publicSite = dataSite.usingUser(userModel).createPublicRandomSite(); + String id = publicSite.getId(); + FileModel file = dataContent.usingSite(publicSite).usingUser(adminUser).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + RestCommentModel comment = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(file).addComment("This is a comment"); + file.setNodeRef(comment.getId()); + publicSite.setId(comment.getId()); + + restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().addFavoriteSite(publicSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + publicSite.setId(id); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Check that if user provides site in id but id is of a tag status code is 404") + public void addSiteFavoriteUsingTagId() throws Exception + { + FileModel file = dataContent.usingSite(publicSite).usingUser(adminUser).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + RestTagModel returnedModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(file).addTag("random_tag"); + file.setNodeRef(returnedModel.getId()); + publicSite.setId(returnedModel.getId()); + + restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().addFavoriteSite(publicSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, returnedModel.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Check that if id does not describe a site, file, or folder status code is 400") + public void addFavoriteUsingInvalidGuid() throws Exception + { + LinkModel link = dataLink.usingAdmin().usingSite(publicSite).createRandomLink(); + SiteModel site = dataSite.usingUser(adminUser).createPublicRandomSite(); + site.setId(link.getNodeRef()); + + restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().addFavoriteSite(site); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, site.getId().split("/")[3])); + } + + @Bug(id="MNT-16904") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.NETWORKS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify tenant user is not able to delete favorites using an invalid network ID - status code (401)") + public void tenantIsNotAbleToDeleteFavoriteSiteWithInvalidNetworkID() throws Exception + { + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser); + tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + publicSite = dataSite.usingUser(tenantUser).createPublicRandomSite(); + + restClient.authenticateUser(tenantUser).withCoreAPI(); + tenantUser.setDomain("invalidNetwork"); + + restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(publicSite); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.NETWORKS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE}, executionType = ExecutionType.REGRESSION, + description = "Verify tenant user is able to add to favorites his site and status code is (201)") + public void tenantAddFavoriteSiteValidNetwork() throws Exception + { + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser); + tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + publicSite = dataSite.usingUser(tenantUser).createPublicRandomSite(); + + restClient.authenticateUser(tenantUser).withCoreAPI(); + tenantUser.setDomain(tenantUser.getDomain()); + + restClient.withCoreAPI() + .usingAuthUser().addSiteToFavorites(publicSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.withCoreAPI().usingAuthUser().getFavorites() + .assertThat() + .entriesListContains("targetGuid", publicSite.getGuidWithoutVersion()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.NETWORKS, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE}, executionType = ExecutionType.REGRESSION, + description = "Verify tenant user is able to add to favorites a site created by admin tenant - same network and status code is (201)") + public void tenantUserIsAbleToAddFavoriteSiteAddedByAdminSameNetwork() throws Exception + { + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser); + tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + publicSite = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); + + restClient.authenticateUser(tenantUser).withCoreAPI(); + tenantUser.setDomain(adminTenantUser.getDomain()); + + restClient.withCoreAPI().usingAuthUser().addFavoriteSite(publicSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.withCoreAPI().usingAuthUser().getFavorites() + .assertThat() + .entriesListContains("targetGuid", publicSite.getGuidWithoutVersion()); + } +} diff --git a/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesCoreTests.java b/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesCoreTests.java deleted file mode 100644 index d740582e3..000000000 --- a/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesCoreTests.java +++ /dev/null @@ -1,230 +0,0 @@ -package org.alfresco.rest.favorites; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestCommentModel; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestPersonFavoritesModel; -import org.alfresco.rest.model.RestTagModel; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.LinkModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class AddFavoritesCoreTests extends RestTest -{ - private UserModel adminUserModel; - private SiteModel siteModel; - private ListUserWithRoles usersWithRoles; - private RestPersonFavoritesModel restPersonFavoritesModel; - - FileModel document; - FolderModel folder; - - private RestCommentModel comment; - private RestTagModel returnedModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - - document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - folder = dataContent.usingSite(siteModel).usingUser(adminUserModel).createFolder(); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Check that if target guid does not describe a site, file, or folder status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) - public void addFavoriteUsingInvalidGuid() throws Exception - { - LinkModel link = dataLink.usingAdmin().usingSite(siteModel).createRandomLink(); - SiteModel site = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - site.setGuid(link.getNodeRef()); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteToFavorites(site); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, site.getGuid().split("/")[3])); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Check that if personId does not exist, status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) - public void addFavoriteUsingInexistentUser() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(new UserModel("random_user", "random_password")).addSiteToFavorites(siteModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "random_user")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Check that if target guid does not exist, status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) - public void addFavoriteUsingInexistentGuid() throws Exception - { - SiteModel site = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - site.setGuid("random_guid"); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteToFavorites(site); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "random_guid")); - } - - @Bug(id = "MNT-17157") - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Check that if a favorite already exists with the specified id status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) - public void addFavoriteTwice() throws Exception - { - SiteModel site = dataSite.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).createPublicRandomSite(); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteToFavorites(site); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(site); - restClient.assertStatusCodeIs(HttpStatus.CONFLICT); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Check that if user provides file in target but guid is of a folder status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) - public void addFileToFavoritesUsingFolderGuid() throws Exception - { - String nodeRef = document.getNodeRef(); - document.setNodeRef(folder.getNodeRef()); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFileToFavorites(document); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, - adminUserModel.getUsername(), folder.getNodeRefWithoutVersion())); - - document.setNodeRef(nodeRef); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Add to favorites a file for a Manager, check it was added") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) - public void managerIsAbleToAddFileToFavorites() throws Exception - { - restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingAuthUser().addFileToFavorites(document); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restPersonFavoritesModel.assertThat().field("targetGuid").is(document.getNodeRefWithoutVersion()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify add favorite, perform getFavorites call, check value is updated") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) - public void verifyGetFavoritesAfterFavoritingSite() throws Exception - { - UserModel user = dataUser.createRandomTestUser(); - restPersonFavoritesModel = restClient.authenticateUser(user) - .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(user).withCoreAPI().usingAuthUser().getFavoriteSites() - .assertThat().entriesListContains("guid", siteModel.getGuid()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Add to favorites a folder for a Manager, check it was added") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) - public void managerIsAbleToAddFolderToFavorites() throws Exception - { - restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingAuthUser().addFolderToFavorites(folder); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restPersonFavoritesModel.assertThat().field("targetGuid").is(folder.getNodeRefWithoutVersion()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Add to favorites a site for a Manager, check it was added") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) - public void managerIsAbleToAddSiteToFavorites() throws Exception - { - restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restPersonFavoritesModel.assertThat().field("targetGuid").is(siteModel.getGuid()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify add favorite specifying -me- string in place of for request") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) - public void userIsAbleToAddFavoriteWhenUsingMeAsUsername() throws Exception - { - UserModel user = dataUser.createRandomTestUser(); - restPersonFavoritesModel = restClient.authenticateUser(user) - .withCoreAPI().usingMe().addSiteToFavorites(siteModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restPersonFavoritesModel.assertThat().field("targetGuid").is(siteModel.getGuid()); - - restClient.authenticateUser(user).withCoreAPI().usingAuthUser().getFavoriteSites().assertThat().entriesListContains("guid", siteModel.getGuid()); - } - -// @Bug(id = "MNT-17158", description="Not a bug, If we need to stop comments from being favorited then an improvement/enhancement request should be raised against the platform.") - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify add file favorite with comment id returns status code 201") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) - public void addFileFavoriteUsingCommentId() throws Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - comment = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment("This is a comment"); - file.setNodeRef(comment.getId()); - - restPersonFavoritesModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFileToFavorites(file); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restPersonFavoritesModel.assertThat().field("targetGuid").is(file.getNodeRef()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify add file favorite with tag id returns status code 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) - public void addFileFavoriteUsingTagId() throws Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - returnedModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addTag("random_tag"); - file.setNodeRef(returnedModel.getId()); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFileToFavorites(file); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, - adminUserModel.getUsername(), returnedModel.getId())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Check that if user provides site in target but id is of a file status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) - public void addSiteToFavoritesUsingFileId() throws Exception - { - String guid = siteModel.getGuid(); - siteModel.setGuid(document.getNodeRefWithoutVersion()); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, document.getNodeRefWithoutVersion())); - - siteModel.setGuid(guid); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Check that if user provides folder in target but guid is of a file status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) - public void addFolderToFavoritesUsingFileGuid() throws Exception - { - String nodeRef = folder.getNodeRef(); - folder.setNodeRef(document.getNodeRef()); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFolderToFavorites(folder); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, document.getNodeRef())); - - folder.setNodeRef(nodeRef); - } -} diff --git a/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesFullTests.java b/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesFullTests.java deleted file mode 100644 index 4460b3370..000000000 --- a/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesFullTests.java +++ /dev/null @@ -1,267 +0,0 @@ -package org.alfresco.rest.favorites; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.core.RestRequest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestFileModel; -import org.alfresco.rest.model.RestFolderModel; -import org.alfresco.rest.model.RestPersonFavoritesModel; -import org.alfresco.rest.model.RestSiteModel; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class AddFavoritesFullTests extends RestTest -{ - private UserModel adminUserModel; - private SiteModel siteModel; - private ListUserWithRoles usersWithRoles; - private RestPersonFavoritesModel restPersonFavoritesModel; - - FileModel document; - FolderModel folder; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - - document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - folder = dataContent.usingSite(siteModel).usingUser(adminUserModel).createFolder(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Add to favorites a file for a Collaborator, check it was added") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) - public void collaboratorIsAbleToAddFileToFavorites() throws Exception - { - restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingAuthUser().addFileToFavorites(document); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restPersonFavoritesModel.assertThat().field("targetGuid").is(document.getNodeRefWithoutVersion()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Add to favorites a file for a Contributor, check it was added") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) - public void contributorIsAbleToAddFileToFavorites() throws Exception - { - restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) - .withCoreAPI().usingAuthUser().addFileToFavorites(document); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restPersonFavoritesModel.assertThat().field("targetGuid").is(document.getNodeRefWithoutVersion()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Add to favorites a file for a Consumer, check it was added") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) - public void consumerIsAbleToAddFileToFavorites() throws Exception - { - restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .withCoreAPI().usingAuthUser().addFileToFavorites(document); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restPersonFavoritesModel.assertThat().field("targetGuid").is(document.getNodeRefWithoutVersion()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Add to favorites a folder for a Collaborator, check it was added") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) - public void collaboratorIsAbleToAddFolderToFavorites() throws Exception - { - restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).addFolderToFavorites(folder); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restPersonFavoritesModel.assertThat().field("targetGuid").is(folder.getNodeRefWithoutVersion()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Add to favorites a folder for a Contributor, check it was added") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) - public void contributorIsAbleToAddFolderToFavorites() throws Exception - { - restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) - .withCoreAPI().usingAuthUser().addFolderToFavorites(folder); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restPersonFavoritesModel.assertThat().field("targetGuid").is(folder.getNodeRefWithoutVersion()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Add to favorites a folder for a Consumer, check it was added") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) - public void consumerIsAbleToAddFolderToFavorites() throws Exception - { - restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .withCoreAPI().usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).addFolderToFavorites(folder); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restPersonFavoritesModel.assertThat().field("targetGuid").is(folder.getNodeRefWithoutVersion()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Add to favorites a site for a Collaborator, check it was added") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) - public void collaboratorIsAbleToAddSiteToFavorites() throws Exception - { - restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restPersonFavoritesModel.assertThat().field("targetGuid").is(siteModel.getGuid()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Add to favorites a site for a Contributor, check it was added") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) - public void contributorIsAbleToAddSiteToFavorites() throws Exception - { - restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) - .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restPersonFavoritesModel.assertThat().field("targetGuid").is(siteModel.getGuid()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Add to favorites a site for a Consumer, check it was added") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) - public void consumerIsAbleToAddSiteToFavorites() throws Exception - { - restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restPersonFavoritesModel.assertThat().field("targetGuid").is(siteModel.getGuid()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Check that if user provides file in target but guid is of a site status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) - public void addSiteToFavoritesUsingFolderId() throws Exception - { - SiteModel newSiteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - newSiteModel.setGuid(folder.getNodeRef()); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteToFavorites(newSiteModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, folder.getNodeRef())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Check that if user provides folder in target but guid is of a site status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) - public void addFolderToFavoritesUsingSiteId() throws Exception - { - FolderModel newFolder = dataContent.usingSite(siteModel).usingUser(adminUserModel).createFolder(); - newFolder.setNodeRef(siteModel.getGuid()); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFolderToFavorites(newFolder); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, - adminUserModel.getUsername(), siteModel.getGuid())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify the response of favorite a site call is valid") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) - public void verifyFavoriteASiteResponseIsValid() throws Exception - { - restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restPersonFavoritesModel.assertThat().field("targetGuid").is(siteModel.getGuid()); - - RestSiteModel restSiteModel = restPersonFavoritesModel.getTarget().getSite(); - restSiteModel.assertThat().field("visibility").is(siteModel.getVisibility()).and() - .field("guid").is(siteModel.getGuid()).and() - .field("description").is(siteModel.getDescription()).and() - .field("id").is(siteModel.getId()).and() - .field("title").is(siteModel.getTitle()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify the response of favorite a file call is valid") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) - public void verifyFavoriteAFileResponseIsValid() throws Exception - { - restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingAuthUser().addFileToFavorites(document); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restPersonFavoritesModel.assertThat().field("targetGuid").is(document.getNodeRefWithoutVersion()); - - RestFileModel restFileModel = restPersonFavoritesModel.getTarget().getFile(); - restFileModel.assertThat().field("mimeType").is("text/plain").and() - .field("isFile").is("true").and() - .field("isFolder").is("false").and() - .field("createdBy").is(adminUserModel.getUsername()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify the response of favorite a folder call is valid") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) - public void verifyFavoriteAFolderResponseIsValid() throws Exception - { - restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingAuthUser().addFolderToFavorites(folder); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restPersonFavoritesModel.assertThat().field("targetGuid").is(folder.getNodeRef()); - - RestFolderModel restFolderModel = restPersonFavoritesModel.getTarget().getFolder(); - restFolderModel.assertThat().field("isFile").is("false").and() - .field("isFolder").is("true").and() - .field("createdBy").is(adminUserModel.getUsername()); - } - - @Bug(id = "REPO-1061") - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Check that if user does not have permission to favorite a site status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) - public void verifyFavoriteASiteIfTheUserDoesNotHavePermission() throws Exception - { - SiteModel privateSite = dataSite.usingUser(adminUserModel).createPrivateRandomSite(); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingAuthUser().addSiteToFavorites(privateSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, privateSite.getGuid())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .containsErrorKey(RestErrorModel.NOT_FOUND_ERRORKEY) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Bug(id = "MNT-16904") - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify the post favorites request when network id is invalid for tenant user") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL, TestGroup.NETWORKS}) - public void addFavoriteSitesWhenNetworkIdIsInvalid() throws JsonToModelConversionException, Exception - { - UserModel adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUserModel); - restClient.usingTenant().createTenant(adminTenantUser); - UserModel tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - - tenantUser.setDomain("invalidNetwork"); - restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify the response of favorite a sie with empty body at request") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) - public void verifyFavoriteASiteWithEmptyBody() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI(); - RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "", "people/{personId}/favorites", adminUserModel.getUsername()); - restClient.processModel(RestPersonFavoritesModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.NO_CONTENT, "No content to map to Object due to end of input"));; - } -} diff --git a/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesSanityTests.java deleted file mode 100644 index 4373b0050..000000000 --- a/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesSanityTests.java +++ /dev/null @@ -1,102 +0,0 @@ -package org.alfresco.rest.favorites; - -import org.alfresco.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestPersonFavoritesModel; -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.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class AddFavoritesSanityTests extends RestTest -{ - private UserModel adminUserModel; - private SiteModel siteModel; - private ListUserWithRoles usersWithRoles; - private RestPersonFavoritesModel restPersonFavoritesModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Verify Admin user add site to favorites with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - public void adminIsAbleToAddToFavorites() throws Exception - { - restPersonFavoritesModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restPersonFavoritesModel.assertThat().field("targetGuid").is(siteModel.getGuid()); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, - executionType = ExecutionType.SANITY, - description = "Verify Manager user add site to favorites with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - public void managerIsAbleToAddToFavorites() throws Exception - { - restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI() - .usingAuthUser().addSiteToFavorites(siteModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restPersonFavoritesModel.assertThat().field("targetGuid").is(siteModel.getGuid()); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Verify Collaborator user add site to favorites with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - public void collaboratorIsAbleToAddToFavorites() throws Exception - { - restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restPersonFavoritesModel.and().field("targetGuid").is(siteModel.getGuid()); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Verify Contributor user add site to favorites with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - public void contributorIsAbleToAddToFavorites() throws JsonToModelConversionException, Exception - { - restPersonFavoritesModel= restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) - .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restPersonFavoritesModel.and().field("targetGuid").is(siteModel.getGuid()); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Verify Consumer user add site to favorites with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - public void consumerIsAbleToAddToFavorites() throws Exception - { - restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restPersonFavoritesModel.and().field("targetGuid").is(siteModel.getGuid()); - } - - @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Verify Manager user gets status code 401 if authentication call fails") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - public void managerIsNotAbleToAddToFavoritesIfAuthenticationFails() throws Exception - { - UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); - siteManager.setPassword("wrongPassword"); - restClient.authenticateUser(siteManager).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } -} diff --git a/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesTests.java b/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesTests.java new file mode 100644 index 000000000..11e09299a --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesTests.java @@ -0,0 +1,509 @@ +package org.alfresco.rest.favorites; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.*; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.model.*; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class AddFavoritesTests extends RestTest +{ + private UserModel adminUserModel; + private SiteModel siteModel; + private ListUserWithRoles usersWithRoles; + private RestPersonFavoritesModel restPersonFavoritesModel; + private FileModel document; + private FolderModel folder; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + folder = dataContent.usingSite(siteModel).usingUser(adminUserModel).createFolder(); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, + executionType = ExecutionType.SANITY, + description = "Verify Manager user add site to favorites with Rest API and status code is 201") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) + public void managerIsAbleToAddToFavorites() throws Exception + { + restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI() + .usingAuthUser().addSiteToFavorites(siteModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restPersonFavoritesModel.assertThat().field("targetGuid").is(siteModel.getGuid()); + } + + // @Bug(id="MNT-16904", description = "It fails only on environment with tenants") + @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, + description = "Verify Manager user gets status code 401 if authentication call fails") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) + public void managerIsNotAbleToAddToFavoritesIfAuthenticationFails() throws Exception + { + UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); + siteManager.setPassword("wrongPassword"); + restClient.authenticateUser(siteManager).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify Collaborator user add site to favorites with Rest API and status code is 201") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) + public void collaboratorIsAbleToAddToFavorites() throws Exception + { + restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restPersonFavoritesModel.and().field("targetGuid").is(siteModel.getGuid()); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify Contributor user add site to favorites with Rest API and status code is 201") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) + public void contributorIsAbleToAddToFavorites() throws JsonToModelConversionException, Exception + { + restPersonFavoritesModel= restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) + .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restPersonFavoritesModel.and().field("targetGuid").is(siteModel.getGuid()); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify Consumer user add site to favorites with Rest API and status code is 201") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) + public void consumerIsAbleToAddToFavorites() throws Exception + { + restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restPersonFavoritesModel.and().field("targetGuid").is(siteModel.getGuid()); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify Admin user add site to favorites with Rest API and status code is 201") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) + public void adminIsAbleToAddToFavorites() throws Exception + { + restPersonFavoritesModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restPersonFavoritesModel.assertThat().field("targetGuid").is(siteModel.getGuid()); + } + + @Bug(id = "MNT-17157") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Check that if a favorite already exists with the specified id status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) + public void addFavoriteTwice() throws Exception + { + SiteModel site = dataSite.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).createPublicRandomSite(); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteToFavorites(site); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(site); + restClient.assertStatusCodeIs(HttpStatus.CONFLICT); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Add to favorites a file for a Manager, check it was added") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) + public void managerIsAbleToAddFileToFavorites() throws Exception + { + restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingAuthUser().addFileToFavorites(document); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restPersonFavoritesModel.assertThat().field("targetGuid").is(document.getNodeRefWithoutVersion()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Add to favorites a folder for a Manager, check it was added") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) + public void managerIsAbleToAddFolderToFavorites() throws Exception + { + restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingAuthUser().addFolderToFavorites(folder); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restPersonFavoritesModel.assertThat().field("targetGuid").is(folder.getNodeRefWithoutVersion()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Add to favorites a site for a Manager, check it was added") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) + public void managerIsAbleToAddSiteToFavorites() throws Exception + { + restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restPersonFavoritesModel.assertThat().field("targetGuid").is(siteModel.getGuid()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify add favorite specifying -me- string in place of for request") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) + public void userIsAbleToAddFavoriteWhenUsingMeAsUsername() throws Exception + { + UserModel user = dataUser.createRandomTestUser(); + restPersonFavoritesModel = restClient.authenticateUser(user) + .withCoreAPI().usingMe().addSiteToFavorites(siteModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restPersonFavoritesModel.assertThat().field("targetGuid").is(siteModel.getGuid()); + + restClient.authenticateUser(user).withCoreAPI().usingAuthUser().getFavoriteSites().assertThat().entriesListContains("guid", siteModel.getGuid()); + } + + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Add to favorites a file for a Collaborator, check it was added") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) + public void collaboratorIsAbleToAddFileToFavorites() throws Exception + { + restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingAuthUser().addFileToFavorites(document); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restPersonFavoritesModel.assertThat().field("targetGuid").is(document.getNodeRefWithoutVersion()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Add to favorites a file for a Contributor, check it was added") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) + public void contributorIsAbleToAddFileToFavorites() throws Exception + { + restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) + .withCoreAPI().usingAuthUser().addFileToFavorites(document); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restPersonFavoritesModel.assertThat().field("targetGuid").is(document.getNodeRefWithoutVersion()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Add to favorites a file for a Consumer, check it was added") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) + public void consumerIsAbleToAddFileToFavorites() throws Exception + { + restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + .withCoreAPI().usingAuthUser().addFileToFavorites(document); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restPersonFavoritesModel.assertThat().field("targetGuid").is(document.getNodeRefWithoutVersion()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Add to favorites a folder for a Collaborator, check it was added") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) + public void collaboratorIsAbleToAddFolderToFavorites() throws Exception + { + restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).addFolderToFavorites(folder); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restPersonFavoritesModel.assertThat().field("targetGuid").is(folder.getNodeRefWithoutVersion()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Add to favorites a folder for a Contributor, check it was added") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) + public void contributorIsAbleToAddFolderToFavorites() throws Exception + { + restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) + .withCoreAPI().usingAuthUser().addFolderToFavorites(folder); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restPersonFavoritesModel.assertThat().field("targetGuid").is(folder.getNodeRefWithoutVersion()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Add to favorites a folder for a Consumer, check it was added") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) + public void consumerIsAbleToAddFolderToFavorites() throws Exception + { + restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + .withCoreAPI().usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).addFolderToFavorites(folder); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restPersonFavoritesModel.assertThat().field("targetGuid").is(folder.getNodeRefWithoutVersion()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Add to favorites a site for a Collaborator, check it was added") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) + public void collaboratorIsAbleToAddSiteToFavorites() throws Exception + { + restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restPersonFavoritesModel.assertThat().field("targetGuid").is(siteModel.getGuid()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Add to favorites a site for a Contributor, check it was added") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) + public void contributorIsAbleToAddSiteToFavorites() throws Exception + { + restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) + .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restPersonFavoritesModel.assertThat().field("targetGuid").is(siteModel.getGuid()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Add to favorites a site for a Consumer, check it was added") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) + public void consumerIsAbleToAddSiteToFavorites() throws Exception + { + restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restPersonFavoritesModel.assertThat().field("targetGuid").is(siteModel.getGuid()); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Check that if target guid does not describe a site, file, or folder status code is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) + public void addFavoriteUsingInvalidGuid() throws Exception + { + LinkModel link = dataLink.usingAdmin().usingSite(siteModel).createRandomLink(); + SiteModel site = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + site.setGuid(link.getNodeRef()); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteToFavorites(site); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, site.getGuid().split("/")[3])); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Check that if personId does not exist, status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) + public void addFavoriteUsingInexistentUser() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(new UserModel("random_user", "random_password")).addSiteToFavorites(siteModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "random_user")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Check that if target guid does not exist, status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) + public void addFavoriteUsingInexistentGuid() throws Exception + { + SiteModel site = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + site.setGuid("random_guid"); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteToFavorites(site); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "random_guid")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Check that if user provides file in target but guid is of a folder status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) + public void addFileToFavoritesUsingFolderGuid() throws Exception + { + String nodeRef = document.getNodeRef(); + document.setNodeRef(folder.getNodeRef()); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFileToFavorites(document); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, + adminUserModel.getUsername(), folder.getNodeRefWithoutVersion())); + + document.setNodeRef(nodeRef); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify add favorite, perform getFavorites call, check value is updated") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) + public void verifyGetFavoritesAfterFavoritingSite() throws Exception + { + UserModel user = dataUser.createRandomTestUser(); + restPersonFavoritesModel = restClient.authenticateUser(user) + .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(user).withCoreAPI().usingAuthUser().getFavoriteSites() + .assertThat().entriesListContains("guid", siteModel.getGuid()); + } + + // @Bug(id = "MNT-17158", description="Not a bug, If we need to stop comments from being favorited then an improvement/enhancement request should be raised against the platform.") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify add file favorite with comment id returns status code 201") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) + public void addFileFavoriteUsingCommentId() throws Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + RestCommentModel comment = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment("This is a comment"); + file.setNodeRef(comment.getId()); + + restPersonFavoritesModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFileToFavorites(file); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restPersonFavoritesModel.assertThat().field("targetGuid").is(file.getNodeRef()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify add file favorite with tag id returns status code 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) + public void addFileFavoriteUsingTagId() throws Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + RestTagModel returnedModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addTag("random_tag"); + file.setNodeRef(returnedModel.getId()); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFileToFavorites(file); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, + adminUserModel.getUsername(), returnedModel.getId())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Check that if user provides site in target but id is of a file status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) + public void addSiteToFavoritesUsingFileId() throws Exception + { + String guid = siteModel.getGuid(); + siteModel.setGuid(document.getNodeRefWithoutVersion()); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, document.getNodeRefWithoutVersion())); + + siteModel.setGuid(guid); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Check that if user provides folder in target but guid is of a file status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) + public void addFolderToFavoritesUsingFileGuid() throws Exception + { + String nodeRef = folder.getNodeRef(); + folder.setNodeRef(document.getNodeRef()); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFolderToFavorites(folder); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, document.getNodeRef())); + + folder.setNodeRef(nodeRef); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Check that if user provides file in target but guid is of a site status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) + public void addSiteToFavoritesUsingFolderId() throws Exception + { + SiteModel newSiteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + newSiteModel.setGuid(folder.getNodeRef()); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteToFavorites(newSiteModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, folder.getNodeRef())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Check that if user provides folder in target but guid is of a site status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) + public void addFolderToFavoritesUsingSiteId() throws Exception + { + FolderModel newFolder = dataContent.usingSite(siteModel).usingUser(adminUserModel).createFolder(); + newFolder.setNodeRef(siteModel.getGuid()); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFolderToFavorites(newFolder); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, + adminUserModel.getUsername(), siteModel.getGuid())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify the response of favorite a site call is valid") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) + public void verifyFavoriteASiteResponseIsValid() throws Exception + { + restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restPersonFavoritesModel.assertThat().field("targetGuid").is(siteModel.getGuid()); + + RestSiteModel restSiteModel = restPersonFavoritesModel.getTarget().getSite(); + restSiteModel.assertThat().field("visibility").is(siteModel.getVisibility()).and() + .field("guid").is(siteModel.getGuid()).and() + .field("description").is(siteModel.getDescription()).and() + .field("id").is(siteModel.getId()).and() + .field("title").is(siteModel.getTitle()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify the response of favorite a file call is valid") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) + public void verifyFavoriteAFileResponseIsValid() throws Exception + { + restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingAuthUser().addFileToFavorites(document); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restPersonFavoritesModel.assertThat().field("targetGuid").is(document.getNodeRefWithoutVersion()); + + RestFileModel restFileModel = restPersonFavoritesModel.getTarget().getFile(); + restFileModel.assertThat().field("mimeType").is("text/plain").and() + .field("isFile").is("true").and() + .field("isFolder").is("false").and() + .field("createdBy").is(adminUserModel.getUsername()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify the response of favorite a folder call is valid") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) + public void verifyFavoriteAFolderResponseIsValid() throws Exception + { + restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingAuthUser().addFolderToFavorites(folder); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restPersonFavoritesModel.assertThat().field("targetGuid").is(folder.getNodeRef()); + + RestFolderModel restFolderModel = restPersonFavoritesModel.getTarget().getFolder(); + restFolderModel.assertThat().field("isFile").is("false").and() + .field("isFolder").is("true").and() + .field("createdBy").is(adminUserModel.getUsername()); + } + + @Bug(id = "REPO-1061") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Check that if user does not have permission to favorite a site status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) + public void verifyFavoriteASiteIfTheUserDoesNotHavePermission() throws Exception + { + SiteModel privateSite = dataSite.usingUser(adminUserModel).createPrivateRandomSite(); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingAuthUser().addSiteToFavorites(privateSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, privateSite.getGuid())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .containsErrorKey(RestErrorModel.NOT_FOUND_ERRORKEY) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Bug(id = "MNT-16904") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify the post favorites request when network id is invalid for tenant user") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL, TestGroup.NETWORKS}) + public void addFavoriteSitesWhenNetworkIdIsInvalid() throws JsonToModelConversionException, Exception + { + UserModel adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUserModel); + restClient.usingTenant().createTenant(adminTenantUser); + UserModel tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + + tenantUser.setDomain("invalidNetwork"); + restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify the response of favorite a sie with empty body at request") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) + public void verifyFavoriteASiteWithEmptyBody() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI(); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "", "people/{personId}/favorites", adminUserModel.getUsername()); + restClient.processModel(RestPersonFavoritesModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.NO_CONTENT, "No content to map to Object due to end of input"));; + } +} From 75959e710c5cee46c848ead7b0f4037a6f3ee92c Mon Sep 17 00:00:00 2001 From: Andrei Forascu Date: Wed, 4 Oct 2017 14:34:06 +0300 Subject: [PATCH 1223/1491] REPO-2755: REST API & CMIS TAS sanity builds: - refactored RestAPI "Comments" API tests to be included in a single class per endpoint (not separate Sanity/Core/Full tests) --- .../rest/comments/AddCommentSanityTests.java | 114 ----- ...entCoreTests.java => AddCommentTests.java} | 150 +++++-- .../rest/comments/AddCommentsCoreTests.java | 168 ------- .../rest/comments/AddCommentsFullTests.java | 162 ------- .../rest/comments/AddCommentsSanityTests.java | 123 ----- .../rest/comments/AddCommentsTests.java | 377 ++++++++++++++++ .../rest/comments/DeleteCommentCoreTests.java | 101 ----- ...FullTests.java => DeleteCommentTests.java} | 162 +++++-- .../rest/comments/GetCommentsCoreTests.java | 136 ------ .../rest/comments/GetCommentsFullTests.java | 215 --------- .../rest/comments/GetCommentsTests.java | 424 ++++++++++++++++++ .../rest/comments/UpdateCommentCoreTests.java | 112 ----- ...FullTests.java => UpdateCommentTests.java} | 259 +++++++++-- 13 files changed, 1268 insertions(+), 1235 deletions(-) delete mode 100644 e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java rename e2e-test/java/org/alfresco/rest/comments/{AddCommentCoreTests.java => AddCommentTests.java} (61%) delete mode 100644 e2e-test/java/org/alfresco/rest/comments/AddCommentsCoreTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/comments/AddCommentsFullTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java create mode 100644 e2e-test/java/org/alfresco/rest/comments/AddCommentsTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/comments/DeleteCommentCoreTests.java rename e2e-test/java/org/alfresco/rest/comments/{DeleteCommentFullTests.java => DeleteCommentTests.java} (57%) delete mode 100644 e2e-test/java/org/alfresco/rest/comments/GetCommentsCoreTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/comments/GetCommentsFullTests.java create mode 100644 e2e-test/java/org/alfresco/rest/comments/GetCommentsTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/comments/UpdateCommentCoreTests.java rename e2e-test/java/org/alfresco/rest/comments/{UpdateCommentFullTests.java => UpdateCommentTests.java} (52%) diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java deleted file mode 100644 index 4cf540c8e..000000000 --- a/e2e-test/java/org/alfresco/rest/comments/AddCommentSanityTests.java +++ /dev/null @@ -1,114 +0,0 @@ -package org.alfresco.rest.comments; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestCommentModel; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class AddCommentSanityTests extends RestTest -{ - private UserModel adminUserModel; - private FileModel document; - private SiteModel siteModel; - private ListUserWithRoles usersWithRoles; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - restClient.authenticateUser(adminUserModel); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify admin user adds comments with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) - public void adminIsAbleToAddComment() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel); - String newContent = "This is a new comment added by " + adminUserModel.getUsername(); - restClient.withCoreAPI().usingResource(document).addComment(newContent) - .assertThat().field("content").isNotEmpty() - .and().field("content").is(newContent); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.onResponse().assertThat().body("entry.edited", org.hamcrest.Matchers.is(false)); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Manager user adds comments with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) - public void managerIsAbleToAddComment() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - String contentSiteManger = "This is a new comment added by user with role: " + UserRole.SiteManager; - RestCommentModel createdComment = restClient.withCoreAPI().usingResource(document).addComment(contentSiteManger); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - createdComment.assertThat().field("content").isNotEmpty() - .and().field("content").is(contentSiteManger); - - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Contributor user adds comments with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS }) - @Bug(id="ACE-4614") - public void contributorIsAbleToAddComment() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - String contentSiteContributor = "This is a new comment added by user with role" + UserRole.SiteContributor; - RestCommentModel createdComment = restClient.withCoreAPI().usingResource(document).addComment(contentSiteContributor); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - createdComment.assertThat().field("content").isNotEmpty() - .and().field("content").is(contentSiteContributor); - - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user adds comments with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) - public void collaboratorIsAbleToAddComment() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - String contentSiteCollaborator = "This is a new comment added by user with role: " + UserRole.SiteCollaborator; - restClient.withCoreAPI().usingResource(document).addComment(contentSiteCollaborator) - .assertThat().field("content").isNotEmpty() - .and().field("content").is(contentSiteCollaborator); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Consumer user can't add comments with Rest API and status code is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS }) - public void consumerIsNotAbleToAddComment() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - String contentSiteConsumer = "This is a new comment added by user with role: " + UserRole.SiteConsumer; - restClient.withCoreAPI().usingResource(document).addComment(contentSiteConsumer); - restClient - .assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user gets status code 401 on post comments call") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) - @Bug(id = "MNT-16904", description = "It fails only on environment with tenants") - public void unauthenticatedUserIsNotAbleToAddComment() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(new UserModel("random user", "random password")); - restClient.withCoreAPI().usingResource(document).addComment("This is a new comment"); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - -} diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentCoreTests.java b/e2e-test/java/org/alfresco/rest/comments/AddCommentTests.java similarity index 61% rename from e2e-test/java/org/alfresco/rest/comments/AddCommentCoreTests.java rename to e2e-test/java/org/alfresco/rest/comments/AddCommentTests.java index 7f6955cd9..d8e61dc6a 100644 --- a/e2e-test/java/org/alfresco/rest/comments/AddCommentCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/AddCommentTests.java @@ -1,6 +1,7 @@ package org.alfresco.rest.comments; import org.alfresco.dataprep.CMISUtil; +import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestCommentModel; @@ -8,8 +9,8 @@ import org.alfresco.rest.model.RestCommentModelsCollection; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestTagModel; import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.RandomData; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FileType; import org.alfresco.utility.model.LinkModel; @@ -22,15 +23,14 @@ import org.alfresco.utility.testrail.annotation.TestRail; import org.apache.commons.lang.RandomStringUtils; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -public class AddCommentCoreTests extends RestTest -{ +public class AddCommentTests extends RestTest +{ private UserModel adminUserModel; private FileModel document; private SiteModel siteModel; - private DataUser.ListUserWithRoles usersWithRoles; + private ListUserWithRoles usersWithRoles; private String comment; @BeforeClass(alwaysRun = true) @@ -38,17 +38,102 @@ public class AddCommentCoreTests extends RestTest { adminUserModel = dataUser.getAdminUser(); restClient.authenticateUser(adminUserModel); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - - document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, - UserRole.SiteConsumer, UserRole.SiteContributor); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); } - @BeforeMethod(alwaysRun = true) - public void setUp() + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify admin user adds comments with Rest API and status code is 201") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) + public void adminIsAbleToAddComment() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel); + String newContent = "This is a new comment added by " + adminUserModel.getUsername(); + restClient.withCoreAPI().usingResource(document).addComment(newContent) + .assertThat().field("content").isNotEmpty() + .and().field("content").is(newContent); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.onResponse().assertThat().body("entry.edited", org.hamcrest.Matchers.is(false)); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, + description = "Verify that comment can be retrieved after it is added") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) + public void addCommentThenRetrieveComment() throws JsonToModelConversionException, Exception { comment = RandomData.getRandomName("comment1"); + restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingResource(document).addComment(comment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestCommentModelsCollection comments = restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingResource(document).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + comments.assertThat().entriesListContains("content", comment); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user gets status code 401 on post comments call") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) +// @Bug(id = "MNT-16904", description = "It fails only on environment with tenants") + public void unauthenticatedUserIsNotAbleToAddComment() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(new UserModel("random user", "random password")); + restClient.withCoreAPI().usingResource(document).addComment("This is a new comment"); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Manager user adds comments with Rest API and status code is 201") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + public void managerIsAbleToAddComment() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + String contentSiteManger = "This is a new comment added by user with role: " + UserRole.SiteManager; + RestCommentModel createdComment = restClient.withCoreAPI().usingResource(document).addComment(contentSiteManger); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + createdComment.assertThat().field("content").isNotEmpty() + .and().field("content").is(contentSiteManger); + + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Contributor user adds comments with Rest API and status code is 201") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + @Bug(id="ACE-4614") + public void contributorIsAbleToAddComment() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + String contentSiteContributor = "This is a new comment added by user with role" + UserRole.SiteContributor; + RestCommentModel createdComment = restClient.withCoreAPI().usingResource(document).addComment(contentSiteContributor); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + createdComment.assertThat().field("content").isNotEmpty() + .and().field("content").is(contentSiteContributor); + + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user adds comments with Rest API and status code is 201") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + public void collaboratorIsAbleToAddComment() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + String contentSiteCollaborator = "This is a new comment added by user with role: " + UserRole.SiteCollaborator; + restClient.withCoreAPI().usingResource(document).addComment(contentSiteCollaborator) + .assertThat().field("content").isNotEmpty() + .and().field("content").is(contentSiteCollaborator); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Consumer user can't add comments with Rest API and status code is 403") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + public void consumerIsNotAbleToAddComment() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + String contentSiteConsumer = "This is a new comment added by user with role: " + UserRole.SiteConsumer; + restClient.withCoreAPI().usingResource(document).addComment(contentSiteConsumer); + restClient + .assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, @@ -56,6 +141,7 @@ public class AddCommentCoreTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) public void addCommentUsingInvalidNodeId() throws JsonToModelConversionException, Exception { + comment = RandomData.getRandomName("comment1"); FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); file.setNodeRef(RandomStringUtils.randomAlphanumeric(20)); @@ -67,9 +153,10 @@ public class AddCommentCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify that request using nodeId that is neither document or folder returns 405") @Bug(id = "MNT-16904") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) public void addCommentUsingResourceThatIsNotFileOrFolder() throws JsonToModelConversionException, Exception { + comment = RandomData.getRandomName("comment1"); LinkModel link = dataLink.usingAdmin().usingSite(siteModel).createRandomLink(); FileModel fileWithNodeRefFromLink = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); fileWithNodeRefFromLink = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); @@ -82,7 +169,7 @@ public class AddCommentCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify that adding comment using empty content returns 400 status code") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) public void addCommentUsingEmptyContent() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel) @@ -92,9 +179,10 @@ public class AddCommentCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify adding comment with the same content as one existing comment") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) public void addCommentTwice() throws JsonToModelConversionException, Exception { + comment = RandomData.getRandomName("comment1"); restClient.authenticateUser(adminUserModel) .withCoreAPI().usingResource(document).addComment(comment); restClient.assertStatusCodeIs(HttpStatus.CREATED); @@ -105,28 +193,13 @@ public class AddCommentCoreTests extends RestTest restClient.withCoreAPI().usingResource(document).getNodeComments() .assertThat().entriesListContains("content", comment); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, - description = "Verify that comment can be retrieved after it is added") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) - public void addCommentThenRetrieveComment() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingResource(document).addComment(comment); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestCommentModelsCollection comments = restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingResource(document).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", comment); - } - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify comment cannot be added if user is not member of private site") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) public void addCommentWithNonMemberOfPrivateSite() throws JsonToModelConversionException, Exception { + comment = RandomData.getRandomName("comment1"); UserModel member = dataUser.createRandomTestUser(); SiteModel privateSite = dataSite.usingUser(adminUserModel).createPrivateRandomSite(); FileModel file = dataContent.usingSite(privateSite).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); @@ -138,10 +211,11 @@ public class AddCommentCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify comment cannot be added if empty network ID is provided") - @Bug(id = "MNT-16904", description = "It fails only on environment with tenants") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) +// @Bug(id = "MNT-16904", description = "It fails only on environment with tenants") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) public void addCommentUsingEmptyNetworkId() throws JsonToModelConversionException, Exception { + comment = RandomData.getRandomName("comment1"); UserModel member = dataUser.createRandomTestUser(); member.setDomain(""); @@ -153,9 +227,10 @@ public class AddCommentCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify that comment cannot be added to another comment") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) public void addCommentToAComment() throws JsonToModelConversionException, Exception { + comment = RandomData.getRandomName("comment1"); FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); RestCommentModel commentEntry = restClient.authenticateUser(adminUserModel) .withCoreAPI().usingResource(file).addComment(comment); @@ -169,9 +244,10 @@ public class AddCommentCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify that comment cannot be added to a tag") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) public void addCommentToATag() throws JsonToModelConversionException, Exception { + comment = RandomData.getRandomName("comment1"); FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag("randomTag"); @@ -182,4 +258,4 @@ public class AddCommentCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.CANNOT_COMMENT); } -} \ No newline at end of file +} diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentsCoreTests.java b/e2e-test/java/org/alfresco/rest/comments/AddCommentsCoreTests.java deleted file mode 100644 index 2cdcd2cf3..000000000 --- a/e2e-test/java/org/alfresco/rest/comments/AddCommentsCoreTests.java +++ /dev/null @@ -1,168 +0,0 @@ -package org.alfresco.rest.comments; - -import java.util.List; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestCommentModel; -import org.alfresco.rest.model.RestCommentModelsCollection; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestTagModel; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FileType; -import org.alfresco.utility.model.LinkModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class AddCommentsCoreTests extends RestTest -{ - private UserModel adminUserModel, networkUserModel; - private SiteModel siteModel; - private DataUser.ListUserWithRoles usersWithRoles; - private RestCommentModelsCollection comments; - private String comment = "This is a new comment"; - private String comment2 = "This is the second comment"; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - networkUserModel = dataUser.createRandomTestUser(); - restClient.authenticateUser(adminUserModel); - siteModel = dataSite.usingUser(adminUserModel).createPrivateRandomSite(); - - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify User can't add comments to a node with ID that does not exist and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) - public void userCanNotAddCommentsOnNonexistentFile() throws Exception - { - FileModel nonexistentFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); - - nonexistentFile.setNodeRef("ABC"); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(nonexistentFile).addComments(comment,comment2); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, nonexistentFile.getNodeRef())); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify User can't add comments to a node that exists but is not a document or a folder and status code is 405") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) - @Bug(id = "MNT-16904") - public void userCanNotAddCommentsOnLink() throws Exception - { - LinkModel link = dataLink.usingAdmin().usingSite(siteModel).createRandomLink(); - FileModel fileWithNodeRefFromLink = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); - fileWithNodeRefFromLink.setNodeRef(link.getNodeRef()); - - restClient.authenticateUser(adminUserModel).withCoreAPI() - .usingResource(fileWithNodeRefFromLink).addComments(comment,comment2); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(RestErrorModel.UNABLE_TO_LOCATE); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify User can add comments with the same content as one existing comment") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) - public void userCanAddCommentWithTheSameContentAsExistingOne() throws Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - String sameComment = comment; - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(file).addComments(comment, sameComment) - .assertThat().paginationExist().and().entriesListIsNotEmpty() - .and().entriesListContains("content", comment) - .and().entriesListContains("content", sameComment); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - comments = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI() - .usingResource(file).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListIsNotEmpty(); - List commentsList = comments.getEntries(); - commentsList.get(0).onModel().assertThat().field("content").is(comment); - commentsList.get(1).onModel().assertThat().field("content").is(sameComment); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify User can not add comments to a not joined private site. Status code returned is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) - public void userCanNotAddCommentsToANotJoinedPrivateSite() throws Exception - { - SiteModel sitePrivateNotJoined = dataSite.createPrivateRandomSite(); - FileModel file = dataContent.usingSite(sitePrivateNotJoined).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(file).addComments(comment, comment2); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify add comments from node with invalid network id returns status code 401") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) - public void addCommentsWithInvalidNetworkId() throws Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - - networkUserModel.setDomain("invalidNetwork"); - restClient.authenticateUser(networkUserModel).withCoreAPI().usingResource(file).addComments(comment,comment2); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify add comments from node with empty network id returns status code 401") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) - public void addCommentsWithEmptyNetworkId() throws Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - - networkUserModel.setDomain(""); - restClient.authenticateUser(networkUserModel).withCoreAPI().usingResource(file).addComments(comment,comment2); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, - description = "Verify that comments cannot be added to another comment") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) - public void addCommentsToAComment() throws JsonToModelConversionException, Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - RestCommentModel commentEntry = restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingResource(file).addComment(comment); - file.setNodeRef(commentEntry.getId()); - - restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingResource(file).addComments(comment, comment2); - - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.CANNOT_COMMENT); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, - description = "Verify that comments cannot be added to a tag") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) - public void addCommentsToATag() throws JsonToModelConversionException, Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - RestTagModel tag = restClient.withCoreAPI().usingResource(file).addTag("randomTag"); - - file.setNodeRef(tag.getId()); - - restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingResource(file).addComments(comment, comment2); - - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.CANNOT_COMMENT); - } -} diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentsFullTests.java b/e2e-test/java/org/alfresco/rest/comments/AddCommentsFullTests.java deleted file mode 100644 index 91d4b8153..000000000 --- a/e2e-test/java/org/alfresco/rest/comments/AddCommentsFullTests.java +++ /dev/null @@ -1,162 +0,0 @@ -package org.alfresco.rest.comments; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.core.JsonBodyGenerator; -import org.alfresco.rest.core.RestRequest; -import org.alfresco.rest.model.RestCommentModel; -import org.alfresco.rest.model.RestCommentModelsCollection; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.apache.commons.lang.RandomStringUtils; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Created by Andrei Rusu - */ -public class AddCommentsFullTests extends RestTest -{ - private UserModel adminUserModel; - private FileModel document; - private SiteModel siteModel; - private DataUser.ListUserWithRoles usersWithRoles; - private String comment = "This is a new comment"; - private String comment2 = "This is the second comment"; - private RestCommentModelsCollection comments; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - restClient.authenticateUser(adminUserModel); - siteModel = dataSite.usingUser(adminUserModel).createPrivateRandomSite(); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Using Manager user verify that you can provide a large string for one comment") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void addLongCommentsWithManagerAndCheckThatCommentIsReturned() throws Exception - { - document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - String longString = RandomStringUtils.randomAlphanumeric(10000); - String longString1 = RandomStringUtils.randomAlphanumeric(90000); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(document).addComments(longString, longString1); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", longString); - comments.assertThat().entriesListContains("content", longString1); - comments.assertThat().paginationField("totalItems").is("2"); - comments.assertThat().paginationField("count").is("2"); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Using Manager user verify that you can provide a short string for one comment") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void addShortCommentsWithManagerAndCheckThatCommentIsReturned() throws Exception - { - document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - String shortString = RandomStringUtils.randomAlphanumeric(2); - String shortString1 = RandomStringUtils.randomAlphanumeric(1); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(document).addComments(shortString, shortString1); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", shortString); - comments.assertThat().entriesListContains("content", shortString1); - comments.assertThat().paginationField("totalItems").is("2"); - comments.assertThat().paginationField("count").is("2"); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Using Collaborator user verify that you can provide a string with special characters for one comment") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void addCommentsWithSpecialCharsWithCollaboratorCheckCommentIsReturned() throws Exception - { - document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - String specialCharsString = "!@#$%^&*()'\".,<>-_+=|\\"; - String shortString = RandomStringUtils.randomAlphanumeric(2); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingResource(document).addComments(specialCharsString, shortString); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", specialCharsString); - comments.assertThat().entriesListContains("content", shortString); - comments.assertThat().paginationField("totalItems").is("2"); - comments.assertThat().paginationField("count").is("2"); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Using Manager user verify that you can not provide an empty string for one comment") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void addEmptyStringCommentsWithManagerCheckCommentIsReturned() throws Exception - { - document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - String emptyString = ""; - String spaceString = " "; - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(document).addComments(emptyString, spaceString); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(RestErrorModel.NON_NULL_COMMENT); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Using Collaborator user verify that you can provide several comments in one request") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void addSeveralCommentsWithCollaboratorCheckCommentsAreReturned() throws Exception - { - document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - String charString = RandomStringUtils.randomAlphanumeric(10); - String charString1 = RandomStringUtils.randomAlphanumeric(10); - String charString2 = RandomStringUtils.randomAlphanumeric(10); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingResource(document).addComments(comment, comment2, charString, charString1, charString2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", comment); - comments.assertThat().paginationField("totalItems").is("5"); - comments.assertThat().paginationField("count").is("5"); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Provide invalid request body parameter and check default error model schema") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void invalidRequestBodyParameterCheckErrorModelSchema() throws Exception - { - document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(adminUserModel).withCoreAPI(); - String postBody = JsonBodyGenerator.keyValueJson("content2", comment); - RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, postBody, "nodes/{nodeId}/comments", document.getNodeRef()); - restClient.processModel(RestCommentModel.class, request); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - restClient.assertLastError().containsErrorKey(String.format(RestErrorModel.UNRECOGNIZED_FIELD, "content2")); - restClient.assertLastError().containsSummary(String.format(RestErrorModel.UNRECOGNIZED_FIELD, "content2")); - restClient.assertLastError().descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - restClient.assertLastError().stackTraceIs(RestErrorModel.STACKTRACE); - } -} diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java deleted file mode 100644 index 5022d7dd6..000000000 --- a/e2e-test/java/org/alfresco/rest/comments/AddCommentsSanityTests.java +++ /dev/null @@ -1,123 +0,0 @@ -package org.alfresco.rest.comments; - -import org.alfresco.dataprep.CMISUtil; -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; -import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -/** - * Created by Claudia Agache on 10/10/2016. - */ -public class AddCommentsSanityTests extends RestTest -{ - private UserModel adminUserModel; - private FileModel document; - private SiteModel siteModel; - private DataUser.ListUserWithRoles usersWithRoles; - private String comment1, comment2; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - restClient.authenticateUser(adminUserModel); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - - document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); - } - - @BeforeMethod(alwaysRun = true) - public void generateRandomComments() - { - comment1 = RandomData.getRandomName("comment1"); - comment2 = RandomData.getRandomName("comment2"); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify admin user adds multiple comments with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) - public void adminIsAbleToAddComments() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingResource(document).addComments(comment1, comment2) - .assertThat().entriesListIsNotEmpty() - .and().entriesListContains("content", comment1) - .and().entriesListContains("content", comment2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Manager user adds multiple comments with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) - public void managerIsAbleToAddComments() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(document).addComments(comment1, comment2) - .assertThat().entriesListIsNotEmpty() - .and().entriesListContains("content", comment1) - .and().entriesListContains("content", comment2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Contributor user adds multiple comments with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) - public void contributorIsAbleToAddComments() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) - .withCoreAPI().usingResource(document).addComments(comment1, comment2) - .assertThat().entriesListIsNotEmpty() - .and().entriesListContains("content", comment1) - .and().entriesListContains("content", comment2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user adds multiple comments with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) - public void collaboratorIsAbleToAddComments() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingResource(document).addComments(comment1, comment2) - .assertThat().paginationExist().and().entriesListIsNotEmpty() - .and().entriesListContains("content", comment1) - .and().entriesListContains("content", comment2); - - restClient.assertStatusCodeIs(HttpStatus.CREATED); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Consumer user adds multiple comments with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS }) - public void consumerIsAbleToAddComments() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .withCoreAPI().usingResource(document).addComments(comment1, comment2); - - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user gets status code 401 on post multiple comments call") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) - public void unauthenticatedUserIsNotAbleToAddComments() throws JsonToModelConversionException, Exception - { - restClient.noAuthentication() - .withCoreAPI().usingResource(document).addComments(comment1, comment2); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } -} diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentsTests.java b/e2e-test/java/org/alfresco/rest/comments/AddCommentsTests.java new file mode 100644 index 000000000..371964adf --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/comments/AddCommentsTests.java @@ -0,0 +1,377 @@ +package org.alfresco.rest.comments; + +import java.util.List; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.JsonBodyGenerator; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestCommentModel; +import org.alfresco.rest.model.RestCommentModelsCollection; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestTagModel; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.data.RandomData; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FileType; +import org.alfresco.utility.model.LinkModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.apache.commons.lang.RandomStringUtils; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +/** + * Created by Claudia Agache on 10/10/2016. + */ +public class AddCommentsTests extends RestTest +{ + private UserModel adminUserModel, networkUserModel; + private FileModel document; + private SiteModel siteModel; + private DataUser.ListUserWithRoles usersWithRoles; + private RestCommentModelsCollection comments; + private String comment1, comment2; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + networkUserModel = dataUser.createRandomTestUser(); + restClient.authenticateUser(adminUserModel); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + } + + @BeforeMethod(alwaysRun = true) + public void generateRandomComments() + { + comment1 = RandomData.getRandomName("comment1"); + comment2 = RandomData.getRandomName("comment2"); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify admin user adds multiple comments with Rest API and status code is 201") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) + public void adminIsAbleToAddComments() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingResource(document).addComments(comment1, comment2) + .assertThat().entriesListIsNotEmpty() + .and().entriesListContains("content", comment1) + .and().entriesListContains("content", comment2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user gets status code 401 on post multiple comments call") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) + public void unauthenticatedUserIsNotAbleToAddComments() throws JsonToModelConversionException, Exception + { + restClient.noAuthentication() + .withCoreAPI().usingResource(document).addComments(comment1, comment2); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Manager user adds multiple comments with Rest API and status code is 201") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + public void managerIsAbleToAddComments() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(document).addComments(comment1, comment2) + .assertThat().entriesListIsNotEmpty() + .and().entriesListContains("content", comment1) + .and().entriesListContains("content", comment2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Contributor user adds multiple comments with Rest API and status code is 201") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + public void contributorIsAbleToAddComments() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) + .withCoreAPI().usingResource(document).addComments(comment1, comment2) + .assertThat().entriesListIsNotEmpty() + .and().entriesListContains("content", comment1) + .and().entriesListContains("content", comment2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user adds multiple comments with Rest API and status code is 201") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + public void collaboratorIsAbleToAddComments() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingResource(document).addComments(comment1, comment2) + .assertThat().paginationExist().and().entriesListIsNotEmpty() + .and().entriesListContains("content", comment1) + .and().entriesListContains("content", comment2); + + restClient.assertStatusCodeIs(HttpStatus.CREATED); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Consumer user adds multiple comments with Rest API and status code is 201") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + public void consumerIsAbleToAddComments() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + .withCoreAPI().usingResource(document).addComments(comment1, comment2); + + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify User can not add comments to a not joined private site. Status code returned is 403") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + public void userCanNotAddCommentsToANotJoinedPrivateSite() throws Exception + { + SiteModel sitePrivateNotJoined = dataSite.createPrivateRandomSite(); + FileModel file = dataContent.usingSite(sitePrivateNotJoined).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(file).addComments(comment1, comment2); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify User can't add comments to a node with ID that does not exist and status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void userCanNotAddCommentsOnNonexistentFile() throws Exception + { + FileModel nonexistentFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); + + nonexistentFile.setNodeRef("ABC"); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(nonexistentFile).addComments(comment1,comment2); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, nonexistentFile.getNodeRef())); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify User can't add comments to a node that exists but is not a document or a folder and status code is 405") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + @Bug(id = "MNT-16904") + public void userCanNotAddCommentsOnLink() throws Exception + { + LinkModel link = dataLink.usingAdmin().usingSite(siteModel).createRandomLink(); + FileModel fileWithNodeRefFromLink = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); + fileWithNodeRefFromLink.setNodeRef(link.getNodeRef()); + + restClient.authenticateUser(adminUserModel).withCoreAPI() + .usingResource(fileWithNodeRefFromLink).addComments(comment1,comment2); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(RestErrorModel.UNABLE_TO_LOCATE); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify User can add comments with the same content as one existing comment") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void userCanAddCommentWithTheSameContentAsExistingOne() throws Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + String sameComment = comment1; + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(file).addComments(comment1, sameComment) + .assertThat().paginationExist().and().entriesListIsNotEmpty() + .and().entriesListContains("content", comment1) + .and().entriesListContains("content", sameComment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + comments = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI() + .usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListIsNotEmpty(); + List commentsList = comments.getEntries(); + commentsList.get(0).onModel().assertThat().field("content").is(comment1); + commentsList.get(1).onModel().assertThat().field("content").is(sameComment); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify add comments from node with invalid network id returns status code 401") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void addCommentsWithInvalidNetworkId() throws Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + + networkUserModel.setDomain("invalidNetwork"); + restClient.authenticateUser(networkUserModel).withCoreAPI().usingResource(file).addComments(comment1,comment2); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify add comments from node with empty network id returns status code 401") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void addCommentsWithEmptyNetworkId() throws Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + + networkUserModel.setDomain(""); + restClient.authenticateUser(networkUserModel).withCoreAPI().usingResource(file).addComments(comment1,comment2); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, + description = "Verify that comments cannot be added to another comment") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void addCommentsToAComment() throws JsonToModelConversionException, Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + RestCommentModel commentEntry = restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingResource(file).addComment(comment1); + file.setNodeRef(commentEntry.getId()); + + restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingResource(file).addComments(comment1, comment2); + + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.CANNOT_COMMENT); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, + description = "Verify that comments cannot be added to a tag") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void addCommentsToATag() throws JsonToModelConversionException, Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + RestTagModel tag = restClient.withCoreAPI().usingResource(file).addTag("randomTag"); + + file.setNodeRef(tag.getId()); + + restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingResource(file).addComments(comment1, comment2); + + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.CANNOT_COMMENT); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Using Manager user verify that you can provide a large string for one comment") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void addLongCommentsWithManagerAndCheckThatCommentIsReturned() throws Exception + { + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + String longString = RandomStringUtils.randomAlphanumeric(10000); + String longString1 = RandomStringUtils.randomAlphanumeric(90000); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(document).addComments(longString, longString1); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", longString); + comments.assertThat().entriesListContains("content", longString1); + comments.assertThat().paginationField("totalItems").is("2"); + comments.assertThat().paginationField("count").is("2"); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Using Manager user verify that you can provide a short string for one comment") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void addShortCommentsWithManagerAndCheckThatCommentIsReturned() throws Exception + { + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + String shortString = RandomStringUtils.randomAlphanumeric(2); + String shortString1 = RandomStringUtils.randomAlphanumeric(1); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(document).addComments(shortString, shortString1); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", shortString); + comments.assertThat().entriesListContains("content", shortString1); + comments.assertThat().paginationField("totalItems").is("2"); + comments.assertThat().paginationField("count").is("2"); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Using Collaborator user verify that you can provide a string with special characters for one comment") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void addCommentsWithSpecialCharsWithCollaboratorCheckCommentIsReturned() throws Exception + { + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + String specialCharsString = "!@#$%^&*()'\".,<>-_+=|\\"; + String shortString = RandomStringUtils.randomAlphanumeric(2); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingResource(document).addComments(specialCharsString, shortString); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", specialCharsString); + comments.assertThat().entriesListContains("content", shortString); + comments.assertThat().paginationField("totalItems").is("2"); + comments.assertThat().paginationField("count").is("2"); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Using Manager user verify that you can not provide an empty string for one comment") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void addEmptyStringCommentsWithManagerCheckCommentIsReturned() throws Exception + { + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + String emptyString = ""; + String spaceString = " "; + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(document).addComments(emptyString, spaceString); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(RestErrorModel.NON_NULL_COMMENT); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Using Collaborator user verify that you can provide several comments in one request") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void addSeveralCommentsWithCollaboratorCheckCommentsAreReturned() throws Exception + { + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + String charString = RandomStringUtils.randomAlphanumeric(10); + String charString1 = RandomStringUtils.randomAlphanumeric(10); + String charString2 = RandomStringUtils.randomAlphanumeric(10); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingResource(document).addComments(comment1, comment2, charString, charString1, charString2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", comment1); + comments.assertThat().paginationField("totalItems").is("5"); + comments.assertThat().paginationField("count").is("5"); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Provide invalid request body parameter and check default error model schema") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void invalidRequestBodyParameterCheckErrorModelSchema() throws Exception + { + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(adminUserModel).withCoreAPI(); + String postBody = JsonBodyGenerator.keyValueJson("content2", comment1); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, postBody, "nodes/{nodeId}/comments", document.getNodeRef()); + restClient.processModel(RestCommentModel.class, request); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + restClient.assertLastError().containsErrorKey(String.format(RestErrorModel.UNRECOGNIZED_FIELD, "content2")); + restClient.assertLastError().containsSummary(String.format(RestErrorModel.UNRECOGNIZED_FIELD, "content2")); + restClient.assertLastError().descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + restClient.assertLastError().stackTraceIs(RestErrorModel.STACKTRACE); + } +} diff --git a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentCoreTests.java b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentCoreTests.java deleted file mode 100644 index bcfb1850c..000000000 --- a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentCoreTests.java +++ /dev/null @@ -1,101 +0,0 @@ -package org.alfresco.rest.comments; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestCommentModel; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class DeleteCommentCoreTests extends RestTest -{ - private UserModel adminUserModel; - - private FileModel document; - private SiteModel siteModel; - private RestCommentModel comment; - private ListUserWithRoles usersWithRoles; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - restClient.authenticateUser(adminUserModel); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteConsumer); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Consumer user can't delete comments created by admin user and status code is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) - public void consumerIsNotAbleToDeleteComments() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel); - comment = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment"); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.withCoreAPI().usingResource(document).deleteComment(comment); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Manager user deletes comments created by admin and status code is 204") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) - public void managerIsAbleToDeleteComments() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel); - comment = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment"); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingResource(document).deleteComment(comment); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Admin user can't delete comments with inexistent ID and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) - public void userIsNotAbleToDeleteInexistentComment() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel); - comment = new RestCommentModel(); - comment.setId("inexistent"); - restClient.withCoreAPI().usingResource(document).deleteComment(comment); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Admin user can't delete comments with inexistend NodeId and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) - public void userIsNotAbleToDeleteCommentWithInexistentNodeId() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel); - comment = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment"); - FileModel inexistentDocument = new FileModel(); - inexistentDocument.setNodeRef("inexistent"); - restClient.withCoreAPI().usingResource(inexistentDocument).deleteComment(comment); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Admin user can't delete deleted comments and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) - public void userIsNotAbleToDeleteDeletedComment() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel); - comment = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment"); - restClient.withCoreAPI().usingResource(document).deleteComment(comment); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingResource(document).deleteComment(comment); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } -} diff --git a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentFullTests.java b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentTests.java similarity index 57% rename from e2e-test/java/org/alfresco/rest/comments/DeleteCommentFullTests.java rename to e2e-test/java/org/alfresco/rest/comments/DeleteCommentTests.java index 9ca7d540a..3762e6238 100644 --- a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentFullTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentTests.java @@ -19,26 +19,137 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -public class DeleteCommentFullTests extends RestTest +public class DeleteCommentTests extends RestTest { private UserModel adminUserModel, networkUserModel; + + private FileModel document; private SiteModel siteModel; - private RestCommentModel commentModel; private RestCommentModelsCollection comments; + private RestCommentModel commentModel; private ListUserWithRoles usersWithRoles; - private String comment = "This is a new comment"; - + private String commentText = "This is a new comment"; + @BeforeClass(alwaysRun=true) public void dataPreparation() throws Exception { adminUserModel = dataUser.getAdminUser(); networkUserModel = dataUser.createRandomTestUser(); restClient.authenticateUser(adminUserModel); - siteModel = dataSite.usingUser(adminUserModel).createPrivateRandomSite(); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteConsumer, - UserRole.SiteCollaborator, UserRole.SiteContributor); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); } - + + @TestRail(section = { TestGroup.REST_API, + TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Admin user deletes comments with Rest API and status code is 204") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) + public void adminIsAbleToDeleteComments() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel); + commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment"); + restClient.withCoreAPI().usingResource(document).deleteComment(commentModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify User gets status code 401 if authentication call fails") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) + @Bug(id="MNT-16904", description = "It fails only on environment with tenants") + public void userIsNotAbleToDeleteCommentIfAuthenticationFails() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel); + commentModel = restClient.withCoreAPI().usingResource(document).addComment("New comment addded by admin"); + UserModel nonexistentModel = new UserModel("nonexistentUser", "nonexistentPassword"); + restClient.authenticateUser(nonexistentModel); + restClient.withCoreAPI().usingResource(document).deleteComment(commentModel); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Manager user deletes own comments and status code is 204") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + public void managerIsAbleToDeleteComments() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + commentModel = restClient.withCoreAPI().usingResource(document).addComment("New comment added by Manager"); + restClient.withCoreAPI().usingResource(document).deleteComment(commentModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user deletes own comments and status code is 204") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + public void collaboratorIsAbleToDeleteComments() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + commentModel = restClient.withCoreAPI().usingResource(document).addComment("New comment added by Collaborator"); + restClient.withCoreAPI().usingResource(document).deleteComment(commentModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Contributor user deletes own comments and status code is 204") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + public void contributorIsAbleToDeleteComments() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + commentModel = restClient.withCoreAPI().usingResource(document).addComment("New comment added by Contributor"); + restClient.withCoreAPI().usingResource(document).deleteComment(commentModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Consumer user can't delete comments created by admin user and status code is 403") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + public void consumerIsNotAbleToDeleteComments() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel); + commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment"); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + restClient.withCoreAPI().usingResource(document).deleteComment(commentModel); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Admin user can't delete comments with inexistent ID and status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + public void userIsNotAbleToDeleteInexistentComment() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel); + commentModel = new RestCommentModel(); + commentModel.setId("inexistent"); + restClient.withCoreAPI().usingResource(document).deleteComment(commentModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Admin user can't delete comments with inexistend NodeId and status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + public void userIsNotAbleToDeleteCommentWithInexistentNodeId() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel); + commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment"); + FileModel inexistentDocument = new FileModel(); + inexistentDocument.setNodeRef("inexistent"); + restClient.withCoreAPI().usingResource(inexistentDocument).deleteComment(commentModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Admin user can't delete deleted comments and status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + public void userIsNotAbleToDeleteDeletedComment() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel); + commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment"); + restClient.withCoreAPI().usingResource(document).deleteComment(commentModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withCoreAPI().usingResource(document).deleteComment(commentModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } + @TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Manager user deletes comment created by admin" + " and status code is 204. Check with getComments for validation") @@ -48,7 +159,7 @@ public class DeleteCommentFullTests extends RestTest FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); commentModel = restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingResource(file).addComment(comment); + .withCoreAPI().usingResource(file).addComment(commentText); restClient.assertStatusCodeIs(HttpStatus.CREATED); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) .withCoreAPI().usingResource(file).deleteComment(commentModel); @@ -56,10 +167,10 @@ public class DeleteCommentFullTests extends RestTest comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListDoesNotContain("content", comment); + comments.assertThat().entriesListDoesNotContain("content", commentText); comments.getPagination().assertThat().field("totalItems").is("0").and().field("count").is("0"); } - + @TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user can delete comment created by self" + " and status code is 204. Check with getComments for validation") @@ -69,17 +180,17 @@ public class DeleteCommentFullTests extends RestTest FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); commentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingResource(file).addComment(comment); + .withCoreAPI().usingResource(file).addComment(commentText); restClient.assertStatusCodeIs(HttpStatus.CREATED); restClient.withCoreAPI().usingResource(file).deleteComment(commentModel); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListDoesNotContain("content", comment); + comments.assertThat().entriesListDoesNotContain("content", commentText); comments.getPagination().assertThat().field("totalItems").is("0").and().field("count").is("0"); } - + @TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Contributor user deletes comment created by self" + " and status code is 204. Check with getComments for validation") @@ -90,17 +201,17 @@ public class DeleteCommentFullTests extends RestTest FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); commentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) - .withCoreAPI().usingResource(file).addComment(comment); + .withCoreAPI().usingResource(file).addComment(commentText); restClient.assertStatusCodeIs(HttpStatus.CREATED); restClient.withCoreAPI().usingResource(file).deleteComment(commentModel); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListDoesNotContain("content", comment); + comments.assertThat().entriesListDoesNotContain("content", commentText); comments.getPagination().assertThat().field("totalItems").is("0").and().field("count").is("0"); } - + @TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Consumer user cannot delete comment created by admin" + " and status code is 403. Check with getComments for validation and check default error model schema.") @@ -109,7 +220,7 @@ public class DeleteCommentFullTests extends RestTest { FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - commentModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(comment); + commentModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(commentText); restClient.assertStatusCodeIs(HttpStatus.CREATED); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) .withCoreAPI().usingResource(file).deleteComment(commentModel); @@ -121,7 +232,7 @@ public class DeleteCommentFullTests extends RestTest comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", comment); + comments.assertThat().entriesListContains("content", commentText); comments.getPagination().assertThat().field("totalItems").is("1").and().field("count").is("1"); } @@ -133,12 +244,12 @@ public class DeleteCommentFullTests extends RestTest FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); dataContent.usingAdmin().usingResource(file).updateContent("updated content to increase version number"); - commentModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(comment); + commentModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(commentText); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) .withCoreAPI().usingResource(file).deleteComment(commentModel); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } - + @TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Manager user cannot delete comment with invalid node " + "and status code is 404. Check with getComments for validation") @@ -147,7 +258,7 @@ public class DeleteCommentFullTests extends RestTest { FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - commentModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(comment); + commentModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(commentText); file.setNodeRef("invalid"); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) .withCoreAPI().usingResource(file).deleteComment(commentModel); @@ -164,12 +275,12 @@ public class DeleteCommentFullTests extends RestTest { FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - commentModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(comment); + commentModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(commentText); networkUserModel.setDomain("invalidNetwork"); restClient.authenticateUser(networkUserModel).withCoreAPI().usingResource(file).deleteComment(commentModel); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } - + @TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify deleteComment from node with empty network id returns status code 401") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) @@ -177,10 +288,9 @@ public class DeleteCommentFullTests extends RestTest { FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - commentModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(comment); + commentModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(commentText); networkUserModel.setDomain(""); restClient.authenticateUser(networkUserModel).withCoreAPI().usingResource(file).deleteComment(commentModel); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } - } diff --git a/e2e-test/java/org/alfresco/rest/comments/GetCommentsCoreTests.java b/e2e-test/java/org/alfresco/rest/comments/GetCommentsCoreTests.java deleted file mode 100644 index 1fd7a1f5c..000000000 --- a/e2e-test/java/org/alfresco/rest/comments/GetCommentsCoreTests.java +++ /dev/null @@ -1,136 +0,0 @@ -package org.alfresco.rest.comments; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestCommentModelsCollection; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FileType; -import org.alfresco.utility.model.LinkModel; -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; - -/** - * Created by Claudia Agache on 11/18/2016. - */ -public class GetCommentsCoreTests extends RestTest -{ - private UserModel adminUserModel, userModel, networkUserModel; - private FileModel document; - private SiteModel siteModel; - private String comment = "This is a new comment"; - private String comment2 = "This is a 2nd comment"; - private String comment3 = "This is a 3rd comment"; - private RestCommentModelsCollection comments; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - userModel = dataUser.createRandomTestUser(); - networkUserModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(adminUserModel).createPrivateRandomSite(); - document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - restClient.authenticateUser(adminUserModel).withCoreAPI() - .usingResource(document).addComment(comment); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.withCoreAPI().usingResource(document).addComment(comment2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.withCoreAPI().usingResource(document).addComment(comment3); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify invalid request returns status code 400 for invalid maxItems or skipCount") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) - public void checkStatusCodeForInvalidMaxItems() throws Exception - { - restClient.authenticateUser(adminUserModel).withParams("maxItems=0") - .withCoreAPI().usingResource(document).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary("Only positive values supported for maxItems"); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify User can't get comments for node with ID that does not exist and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) - public void userCanNotGetCommentsOnNonexistentFile() throws Exception - { - FileModel nonexistentFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); - nonexistentFile.setNodeRef("ABC"); - restClient.authenticateUser(adminUserModel).withCoreAPI() - .usingResource(nonexistentFile).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, nonexistentFile.getNodeRef())); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify User can't get comments for node that exists but is not a document or a folder and status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) - public void userCanNotGetCommentsOnLink() throws Exception - { - LinkModel link = dataLink.usingAdmin().usingSite(siteModel).createRandomLink(); - FileModel fileWithNodeRefFromLink = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); - fileWithNodeRefFromLink.setNodeRef(link.getNodeRef().replace("workspace://SpacesStore/", "workspace%3A%2F%2FSpacesStore%2F")); - restClient.authenticateUser(adminUserModel).withCoreAPI() - .usingResource(fileWithNodeRefFromLink).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, fileWithNodeRefFromLink.getNodeRef())) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify request returns status 403 if the user does not have permission read comments on the node") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) - public void uninvitedUserCanNotGetCommentsFromPrivateSite() throws Exception - { - restClient.authenticateUser(userModel).withCoreAPI() - .usingResource(document).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify user gets comments without the first 2 and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) - public void skipFirst2Comments() throws Exception - { - comments = restClient.authenticateUser(adminUserModel).withParams("skipCount=2") - .withCoreAPI().usingResource(document).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", comment) - .and().paginationField("count").is("1"); - comments.assertThat().paginationField("skipCount").is("2"); - comments.assertThat().paginationField("totalItems").is("3"); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify get comments from node with invalid network id returns status code 401") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) - public void getCommentsWithInvalidNetwork() throws Exception - { - networkUserModel.setDomain("invalidNetwork"); - restClient.authenticateUser(networkUserModel).withCoreAPI().usingResource(document).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify get comments from node with empty network id returns status code 401") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) - public void getCommentsWithEmptyNetwork() throws Exception - { - networkUserModel.setDomain(""); - restClient.authenticateUser(networkUserModel).withCoreAPI().usingResource(document).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - -} diff --git a/e2e-test/java/org/alfresco/rest/comments/GetCommentsFullTests.java b/e2e-test/java/org/alfresco/rest/comments/GetCommentsFullTests.java deleted file mode 100644 index cf0e38b9f..000000000 --- a/e2e-test/java/org/alfresco/rest/comments/GetCommentsFullTests.java +++ /dev/null @@ -1,215 +0,0 @@ -package org.alfresco.rest.comments; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestCommentModelsCollection; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser; -import org.alfresco.utility.exception.DataPreparationException; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -public class GetCommentsFullTests extends RestTest -{ - private UserModel adminUserModel; - private SiteModel siteModel; - private String comment = "This is a new comment"; - private String comment2 = "This is the second comment"; - private RestCommentModelsCollection comments; - private DataUser.ListUserWithRoles usersWithRoles; - private FileModel file; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - siteModel = dataSite.usingUser(adminUserModel).createPrivateRandomSite(); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, - UserRole.SiteContributor, UserRole.SiteConsumer); - } - - @BeforeMethod(alwaysRun=true) - public void setUp() throws DataPreparationException, Exception { - file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify that if manager adds one comment, it will be returned in getComments response") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void addCommentWithManagerAndCheckThatCommentIsReturned() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(file).addComment(comment); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", comment) - .getPagination().assertThat().field("totalItems").is("1") - .assertThat().field("count").is("1"); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify that if collaborator adds one comment, it will be returned in getComments response") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void addCommentWithCollaboratorAndCheckThatCommentIsReturned() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingResource(file).addComment(comment); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", comment) - .getPagination().assertThat().field("totalItems").is("1") - .assertThat().field("count").is("1"); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify that if contributor adds one comment, it will be returned in getComments response") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - @Bug(id = "ACE-4614") - public void addCommentWithContributorAndCheckThatCommentIsReturned() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) - .withCoreAPI().usingResource(file).addComment(comment); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", comment) - .getPagination().assertThat().field("totalItems").is("1") - .assertThat().field("count").is("1"); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify that consumer cannot add a comment and no comments will be returned in getComments response") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void addCommentWithConsumerAndCheckThatCommentIsNotReturned() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .withCoreAPI().usingResource(file).addComment(comment); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - - comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().paginationField("totalItems").is("0"); - comments.assertThat().paginationField("count").is("0"); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Add one comment with Manager and check that returned person is the right one") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void addCommentWithManagerCheckReturnedPersonIsTheRightOne() throws Exception - { - UserModel user1 = dataUser.createRandomTestUser(); - dataUser.addUserToSite(user1, siteModel, UserRole.SiteManager); - - restClient.authenticateUser(user1).withCoreAPI().usingResource(file).addComment(comment); - comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); - comments.getOneRandomEntry().onModel().getCreatedBy().assertThat().field("firstName").is(user1.getUsername() + " FirstName") - .assertThat().field("lastName").is("LN-" + user1.getUsername()); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Add one comment with Collaborator and check that returned company details are correct") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void addCommentWithCollaboratorCheckReturnedCompanyDetails() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(file).addComment(comment); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); - comments.getOneRandomEntry().onModel().getCreatedBy().getCompany() - .assertThat().field("organization").isNull() - .assertThat().field("address1").isNull() - .assertThat().field("address2").isNull() - .assertThat().field("address3").isNull() - .assertThat().field("postcode").isNull() - .assertThat().field("telephone").isNull() - .assertThat().field("fax").isNull() - .assertThat().field("email").isNull(); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Add 2 comments with Manager and Collaborator users and verify valid request using skipCount. Check that param is applied") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void addTwoCommentsWithManagerCollaboratorVerifySkipCountParamIsApplied() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(file).addComment(comment); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(file).addComment(comment2); - - comments = restClient.authenticateUser(adminUserModel).withParams("skipCount=1") - .withCoreAPI().usingResource(file).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", comment) - .and().paginationField("count").is("1"); - comments.assertThat().paginationField("skipCount").is("1"); - comments.assertThat().paginationField("totalItems").is("2"); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Add 2 comments with Admin and Collaborator users and verify valid request using maxItems. Check that param is applied") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void addTwoCommentsWithAdminCollaboratorVerifyMaxItemsParamIsApplied() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(comment); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(file).addComment(comment2); - - comments = restClient.authenticateUser(adminUserModel).withParams("maxItems=1") - .withCoreAPI().usingResource(file).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", comment2) - .and().paginationField("count").is("1"); - comments.assertThat().paginationField("totalItems").is("2"); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Add 2 comments with Manager and Admin users and verify valid request using properties. Check that param is applied") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void addTwoCommentsWithAdminManagerVerifyPropertiesParamIsApplied() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(comment); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(file).addComment(comment2); - - comments = restClient.authenticateUser(adminUserModel).withParams("properties=createdBy,modifiedBy") - .withCoreAPI().usingResource(file).getNodeComments(); - comments.assertThat().entriesListIsNotEmpty() - .and().paginationField("count").is("2"); - comments.assertThat().paginationField("totalItems").is("2"); - - comments.getEntries().get(0).onModel().getCreatedBy() - .assertThat().field("firstName").is(usersWithRoles.getOneUserWithRole(UserRole.SiteManager).getUsername() + " FirstName") - .assertThat().field("lastName").is("LN-" + usersWithRoles.getOneUserWithRole(UserRole.SiteManager).getUsername()); - - comments.getEntries().get(1).onModel().getCreatedBy() - .assertThat().field("firstName").is("Administrator") - .assertThat().field("id").is("admin"); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Check default error model schema") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void addTwoCommentsWithManagerCheckDefaultErrorModelSchema() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(file).addComments(comment, comment2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).usingParams("maxItems=0").getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); - restClient.assertLastError().containsErrorKey(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); - restClient.assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); - restClient.assertLastError().descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - restClient.assertLastError().stackTraceIs(RestErrorModel.STACKTRACE); - } -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/comments/GetCommentsTests.java b/e2e-test/java/org/alfresco/rest/comments/GetCommentsTests.java new file mode 100644 index 000000000..ad5675cc9 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/comments/GetCommentsTests.java @@ -0,0 +1,424 @@ +package org.alfresco.rest.comments; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestCommentModelsCollection; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FileType; +import org.alfresco.utility.model.LinkModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class GetCommentsTests extends RestTest +{ + private FileModel file, document, document1; + private SiteModel siteModel, privateSiteModel; + private UserModel adminUserModel, userModel, networkUserModel; + private ListUserWithRoles usersWithRoles; + private String comment = "This is a new comment"; + private String comment2 = "This is a 2nd comment"; + private String comment3 = "This is a 3rd comment"; + private RestCommentModelsCollection comments; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + networkUserModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + privateSiteModel = dataSite.usingUser(adminUserModel).createPrivateRandomSite(); + document = dataContent.usingSite(privateSiteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + document1 = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(adminUserModel).withCoreAPI() + .usingResource(document1).addComment(comment); + restClient.withCoreAPI().usingResource(document).addComment(comment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.withCoreAPI().usingResource(document).addComment(comment2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.withCoreAPI().usingResource(document).addComment(comment3); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.SANITY, + description= "Verify Admin user gets comments with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) + public void adminIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception + { + comments = restClient.authenticateUser(adminUserModel).withCoreAPI() + .usingResource(document1).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", comment); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.SANITY, + description= "Verify Manager user gets status code 401 if authentication call fails") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) + @Bug(id="MNT-16904", description = "It fails only on environment with tenants") + public void managerIsNotAbleToRetrieveCommentIfAuthenticationFails() throws JsonToModelConversionException, Exception + { + UserModel nonexistentModel = new UserModel("nonexistentUser", "nonexistentPassword"); + restClient.authenticateUser(nonexistentModel).withCoreAPI() + .usingResource(document1).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify Manager user gets comments created by admin user with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + public void managerIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception + { + comments = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI() + .usingResource(document1).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", comment); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify Contributor user gets comments created by admin user with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + public void contributorIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception + { + comments = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI() + .usingResource(document1).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", comment); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify Collaborator user gets comments created by admin user with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + public void collaboratorIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception + { + comments = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI() + .usingResource(document1).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", comment); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify Consumer user gets comments created by admin user with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + public void consumerIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception + { + comments = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI() + .usingResource(document1).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", comment); + } + + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify Manager user gets comments created by another user and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + public void managerIsAbleToRetrieveCommentsCreatedByAnotherUser() throws JsonToModelConversionException, Exception + { + userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); + String contentManager = "This is a new comment added by " + userModel.getUsername(); + restClient.authenticateUser(userModel).withCoreAPI() + .usingResource(document1).addComment(contentManager); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + comments = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI() + .usingResource(document1).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", contentManager) + .and().entriesListContains("content", comment); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify admin user gets comments created by another user and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + public void adminIsAbleToRetrieveCommentsCreatedByAnotherUser() throws JsonToModelConversionException, Exception + { + userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); + String contentCollaborator = "This is a new comment added by " + userModel.getUsername(); + restClient.authenticateUser(userModel).withCoreAPI() + .usingResource(document1).addComment(contentCollaborator); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + comments = restClient.authenticateUser(adminUserModel).withCoreAPI() + .usingResource(document1).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", contentCollaborator) + .and().entriesListContains("content", comment); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify request returns status 403 if the user does not have permission read comments on the node") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + public void uninvitedUserCanNotGetCommentsFromPrivateSite() throws Exception + { + restClient.authenticateUser(userModel).withCoreAPI() + .usingResource(document).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify user gets comments without the first 2 and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + public void skipFirst2Comments() throws Exception + { + comments = restClient.authenticateUser(adminUserModel).withParams("skipCount=2") + .withCoreAPI().usingResource(document).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", comment) + .and().paginationField("count").is("1"); + comments.assertThat().paginationField("skipCount").is("2"); + comments.assertThat().paginationField("totalItems").is("3"); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify invalid request returns status code 400 for invalid maxItems or skipCount") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void checkStatusCodeForInvalidMaxItems() throws Exception + { + restClient.authenticateUser(adminUserModel).withParams("maxItems=0") + .withCoreAPI().usingResource(document).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary("Only positive values supported for maxItems"); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify User can't get comments for node with ID that does not exist and status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void userCanNotGetCommentsOnNonExistentFile() throws Exception + { + FileModel nonexistentFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); + nonexistentFile.setNodeRef("ABC"); + restClient.authenticateUser(adminUserModel).withCoreAPI() + .usingResource(nonexistentFile).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, nonexistentFile.getNodeRef())); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify User can't get comments for node that exists but is not a document or a folder and status code is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void userCanNotGetCommentsOnLink() throws Exception + { + LinkModel link = dataLink.usingAdmin().usingSite(siteModel).createRandomLink(); + FileModel fileWithNodeRefFromLink = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); + fileWithNodeRefFromLink.setNodeRef(link.getNodeRef().replace("workspace://SpacesStore/", "workspace%3A%2F%2FSpacesStore%2F")); + restClient.authenticateUser(adminUserModel).withCoreAPI() + .usingResource(fileWithNodeRefFromLink).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, fileWithNodeRefFromLink.getNodeRef())) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify get comments from node with invalid network id returns status code 401") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void getCommentsWithInvalidNetwork() throws Exception + { + networkUserModel.setDomain("invalidNetwork"); + restClient.authenticateUser(networkUserModel).withCoreAPI().usingResource(document).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify get comments from node with empty network id returns status code 401") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void getCommentsWithEmptyNetwork() throws Exception + { + networkUserModel.setDomain(""); + restClient.authenticateUser(networkUserModel).withCoreAPI().usingResource(document).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify that if manager adds one comment, it will be returned in getComments response") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void addCommentWithManagerAndCheckThatCommentIsReturned() throws Exception + { + file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(file).addComment(comment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", comment) + .getPagination().assertThat().field("totalItems").is("1") + .assertThat().field("count").is("1"); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify that if collaborator adds one comment, it will be returned in getComments response") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void addCommentWithCollaboratorAndCheckThatCommentIsReturned() throws Exception + { + file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingResource(file).addComment(comment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", comment) + .getPagination().assertThat().field("totalItems").is("1") + .assertThat().field("count").is("1"); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify that if contributor adds one comment, it will be returned in getComments response") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + @Bug(id = "ACE-4614") + public void addCommentWithContributorAndCheckThatCommentIsReturned() throws Exception + { + file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) + .withCoreAPI().usingResource(file).addComment(comment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", comment) + .getPagination().assertThat().field("totalItems").is("1") + .assertThat().field("count").is("1"); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify that consumer cannot add a comment and no comments will be returned in getComments response") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void addCommentWithConsumerAndCheckThatCommentIsNotReturned() throws Exception + { + file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + .withCoreAPI().usingResource(file).addComment(comment); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + + comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().paginationField("totalItems").is("0"); + comments.assertThat().paginationField("count").is("0"); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Add one comment with Manager and check that returned person is the right one") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void addCommentWithManagerCheckReturnedPersonIsTheRightOne() throws Exception + { + file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + UserModel user1 = dataUser.createRandomTestUser(); + dataUser.addUserToSite(user1, siteModel, UserRole.SiteManager); + + restClient.authenticateUser(user1).withCoreAPI().usingResource(file).addComment(comment); + comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); + comments.getOneRandomEntry().onModel().getCreatedBy().assertThat().field("firstName").is(user1.getUsername() + " FirstName") + .assertThat().field("lastName").is("LN-" + user1.getUsername()); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Add one comment with Collaborator and check that returned company details are correct") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void addCommentWithCollaboratorCheckReturnedCompanyDetails() throws Exception + { + file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(file).addComment(comment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); + comments.getOneRandomEntry().onModel().getCreatedBy().getCompany() + .assertThat().field("organization").isNull() + .assertThat().field("address1").isNull() + .assertThat().field("address2").isNull() + .assertThat().field("address3").isNull() + .assertThat().field("postcode").isNull() + .assertThat().field("telephone").isNull() + .assertThat().field("fax").isNull() + .assertThat().field("email").isNull(); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Add 2 comments with Manager and Collaborator users and verify valid request using skipCount. Check that param is applied") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void addTwoCommentsWithManagerCollaboratorVerifySkipCountParamIsApplied() throws Exception + { + file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(file).addComment(comment); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(file).addComment(comment2); + + comments = restClient.authenticateUser(adminUserModel).withParams("skipCount=1") + .withCoreAPI().usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", comment) + .and().paginationField("count").is("1"); + comments.assertThat().paginationField("skipCount").is("1"); + comments.assertThat().paginationField("totalItems").is("2"); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Add 2 comments with Admin and Collaborator users and verify valid request using maxItems. Check that param is applied") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void addTwoCommentsWithAdminCollaboratorVerifyMaxItemsParamIsApplied() throws Exception + { + file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(comment); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(file).addComment(comment2); + + comments = restClient.authenticateUser(adminUserModel).withParams("maxItems=1") + .withCoreAPI().usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", comment2) + .and().paginationField("count").is("1"); + comments.assertThat().paginationField("totalItems").is("2"); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Add 2 comments with Manager and Admin users and verify valid request using properties. Check that param is applied") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void addTwoCommentsWithAdminManagerVerifyPropertiesParamIsApplied() throws Exception + { + file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(comment); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(file).addComment(comment2); + + comments = restClient.authenticateUser(adminUserModel).withParams("properties=createdBy,modifiedBy") + .withCoreAPI().usingResource(file).getNodeComments(); + comments.assertThat().entriesListIsNotEmpty() + .and().paginationField("count").is("2"); + comments.assertThat().paginationField("totalItems").is("2"); + + comments.getEntries().get(0).onModel().getCreatedBy() + .assertThat().field("firstName").is(usersWithRoles.getOneUserWithRole(UserRole.SiteManager).getUsername() + " FirstName") + .assertThat().field("lastName").is("LN-" + usersWithRoles.getOneUserWithRole(UserRole.SiteManager).getUsername()); + + comments.getEntries().get(1).onModel().getCreatedBy() + .assertThat().field("firstName").is("Administrator") + .assertThat().field("id").is("admin"); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Check default error model schema") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void addTwoCommentsWithManagerCheckDefaultErrorModelSchema() throws Exception + { + file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(file).addComments(comment, comment2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).usingParams("maxItems=0").getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); + restClient.assertLastError().containsErrorKey(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); + restClient.assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); + restClient.assertLastError().descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + restClient.assertLastError().stackTraceIs(RestErrorModel.STACKTRACE); + } +} diff --git a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentCoreTests.java b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentCoreTests.java deleted file mode 100644 index 32caa9b5e..000000000 --- a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentCoreTests.java +++ /dev/null @@ -1,112 +0,0 @@ -package org.alfresco.rest.comments; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestCommentModel; -import org.alfresco.rest.model.RestCommentModelsCollection; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FileType; -import org.alfresco.utility.model.LinkModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class UpdateCommentCoreTests extends RestTest -{ - private UserModel adminUserModel; - private FileModel document; - private SiteModel siteModel; - private RestCommentModel commentModel; - private ListUserWithRoles usersWithRoles; - private RestCommentModelsCollection comments; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - restClient.authenticateUser(adminUserModel); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - - document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify can not update comment if NodeId is neither document or folder and returns status code 405") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) - public void canNotUpdateCommentIfNodeIdIsNeitherDocumentOrFolder() throws JsonToModelConversionException, Exception - { - FileModel content = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); - content = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(adminUserModel); - commentModel = restClient.withCoreAPI().usingResource(content).addComment("This is a new comment"); - - LinkModel link = dataLink.usingAdmin().usingSite(siteModel).createRandomLink(); - content.setNodeRef(link.getNodeRef().replace("workspace://SpacesStore/", "workspace%3A%2F%2FSpacesStore%2F")); - - restClient.withCoreAPI().usingResource(content).updateComment(commentModel, "This is the updated comment."); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, content.getNodeRef())) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Admin user is not able to update with empty comment body and status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) - public void adminIsNotAbleToUpdateWithEmptyCommentBody() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel); - commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by admin"); - restClient.withCoreAPI().usingResource(document).updateComment(commentModel, ""); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary("An invalid argument was received"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify updated comment by Manager is listed when calling getComments and status code is 200") -// @Bug(id="REPO-1011") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) - public void updatedCommentByManagerIsListed() throws JsonToModelConversionException, Exception - { - commentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingResource(document).addComment("This is a new comment added by collaborator"); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI() - .usingResource(document).updateComment(commentModel, "This is the updated comment with Manager user"); - comments = restClient.withCoreAPI().usingResource(document).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", "This is the updated comment with Manager user"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user can not update comments of another user and status code is 200") -// @Bug(id="MNT-2502",description="seems it's one old issue: also logged as MNT-2502, MNT-2346") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) - public void collaboratorIsNotAbleToUpdateCommentOfAnotherUser() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel); - commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by admin"); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingResource(document).updateComment(commentModel, "This is the updated comment with Collaborator user"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify entry content in response") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) - public void checkEntryContentInResponse() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel); - commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by admin"); - commentModel = restClient.withCoreAPI().usingResource(document).updateComment(commentModel, "This is the updated comment with admin user"); - restClient.assertStatusCodeIs(HttpStatus.OK); - commentModel.assertThat().field("content").is("This is the updated comment with admin user"); - } -} diff --git a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentFullTests.java b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentTests.java similarity index 52% rename from e2e-test/java/org/alfresco/rest/comments/UpdateCommentFullTests.java rename to e2e-test/java/org/alfresco/rest/comments/UpdateCommentTests.java index f96cf475a..fd8661ef3 100644 --- a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentFullTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentTests.java @@ -8,8 +8,11 @@ import org.alfresco.rest.model.RestCommentModel; import org.alfresco.rest.model.RestCommentModelsCollection; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FileType; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.LinkModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; @@ -21,27 +24,201 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -public class UpdateCommentFullTests extends RestTest -{ +public class UpdateCommentTests extends RestTest +{ private UserModel adminUserModel, networkUserModel; + private FileModel document; private SiteModel siteModel; private RestCommentModel commentModel, returnedCommentModel; - private RestCommentModelsCollection comments; - private DataUser.ListUserWithRoles usersWithRoles; + private RestCommentModelsCollection comments;; + private ListUserWithRoles usersWithRoles; private String firstComment = "This is a new comment"; private String updatedComment = "This is the updated comment"; - @BeforeClass(alwaysRun = true) + @BeforeClass(alwaysRun=true) public void dataPreparation() throws Exception { adminUserModel = dataUser.getAdminUser(); - networkUserModel = dataUser.createRandomTestUser(); restClient.authenticateUser(adminUserModel); - siteModel = dataSite.usingUser(adminUserModel).createPrivateRandomSite(); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, - UserRole.SiteConsumer, UserRole.SiteContributor); + networkUserModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); } - + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Admin user updates comments and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) + public void adminIsAbleToUpdateHisComment() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel); + commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by admin"); + String updatedContent = "This is the updated comment with admin user"; + restClient.withCoreAPI().usingResource(document).updateComment(commentModel, updatedContent) + .assertThat().field("content").isNotEmpty() + .and().field("content").is(updatedContent); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user gets status code 401 on update comment call") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) + @Bug(id = "MNT-16904", description = "fails only on environment with tenants") + public void unauthenticatedUserIsNotAbleToUpdateComment() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel); + commentModel = restClient.withCoreAPI().usingResource(document).addComment("To be updated by unauthenticated user."); + UserModel incorrectUserModel = new UserModel("userName", "password"); + restClient.authenticateUser(incorrectUserModel) + .withCoreAPI().usingResource(document).updateComment(commentModel, "try to update"); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify entry content in response") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) + public void checkEntryContentInResponse() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel); + commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by admin"); + commentModel = restClient.withCoreAPI().usingResource(document).updateComment(commentModel, "This is the updated comment with admin user"); + restClient.assertStatusCodeIs(HttpStatus.OK); + commentModel.assertThat().field("content").is("This is the updated comment with admin user"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Manager user updates comments created by admin user and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + public void managerIsAbleToUpdateHisComment() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by manager"); + restClient.withCoreAPI().usingResource(document).updateComment(commentModel, "This is the updated comment with Manager user") + .and().field("content").is("This is the updated comment with Manager user") + .and().field("canEdit").is(true) + .and().field("canDelete").is(true); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Contributor user can update his own comment and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + public void contributorIsAbleToUpdateHisComment() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by contributor"); + String updatedContent = "This is the updated comment with Contributor user"; + restClient.withCoreAPI().usingResource(document).updateComment(commentModel, updatedContent); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Consumer user can not update comments created by admin user and status code is 403") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + public void consumerIsNotAbleToUpdateComment() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel); + commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by admin"); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + restClient.withCoreAPI().usingResource(document).updateComment(commentModel, "This is the updated comment with Consumer user"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user can update his own comment and status code is 200") +// @Bug(id="REPO-1011") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + public void collaboratorIsAbleToUpdateHisComment() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by collaborator"); + restClient.withCoreAPI().usingResource(document).updateComment(commentModel, "This is the updated comment with Collaborator user"); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user can not update comments of another user and status code is 200") +// @Bug(id="MNT-2502",description="seems it's one old issue: also logged as MNT-2502, MNT-2346") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + public void collaboratorIsNotAbleToUpdateCommentOfAnotherUser() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel); + commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by admin"); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingResource(document).updateComment(commentModel, "This is the updated comment with Collaborator user"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify update comment with inexistent nodeId returns status code 404") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void canNotUpdateCommentIfNodeIdIsNotSet() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel); + + FolderModel content = FolderModel.getRandomFolderModel(); + content.setNodeRef("node ref that does not exist"); + commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment"); + restClient.withCoreAPI().usingResource(content).updateComment(commentModel, "This is the updated comment."); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary("node ref that does not exist was not found"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify if commentId is not set the status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void canNotUpdateCommentIfCommentIdIsNotSet() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel); + + RestCommentModel comment = new RestCommentModel(); + String id = "comment id that does not exist"; + comment.setId(id); + restClient.withCoreAPI().usingResource(document).updateComment(comment, "This is the updated comment."); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, id)); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify can not update comment if NodeId is neither document or folder and returns status code 405") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void canNotUpdateCommentIfNodeIdIsNeitherDocumentOrFolder() throws JsonToModelConversionException, Exception + { + FileModel content = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); + content = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(adminUserModel); + commentModel = restClient.withCoreAPI().usingResource(content).addComment("This is a new comment"); + + LinkModel link = dataLink.usingAdmin().usingSite(siteModel).createRandomLink(); + content.setNodeRef(link.getNodeRef().replace("workspace://SpacesStore/", "workspace%3A%2F%2FSpacesStore%2F")); + + restClient.withCoreAPI().usingResource(content).updateComment(commentModel, "This is the updated comment."); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, content.getNodeRef())) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Admin user is not able to update with empty comment body and status code is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void adminIsNotAbleToUpdateWithEmptyCommentBody() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel); + commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by admin"); + restClient.withCoreAPI().usingResource(document).updateComment(commentModel, ""); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary("An invalid argument was received"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify updated comment by Manager is listed when calling getComments and status code is 200") +// @Bug(id="REPO-1011") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void updatedCommentByManagerIsListed() throws JsonToModelConversionException, Exception + { + commentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingResource(document).addComment("This is a new comment added by collaborator"); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI() + .usingResource(document).updateComment(commentModel, "This is the updated comment with Manager user"); + comments = restClient.withCoreAPI().usingResource(document).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", "This is the updated comment with Manager user"); + } + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Verify Manager user can update a comment with a large string") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) @@ -59,7 +236,7 @@ public class UpdateCommentFullTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); returnedCommentModel.assertThat().field("content").is(longString); } - + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Verify Manager user can update a comment with a short string") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) @@ -77,7 +254,7 @@ public class UpdateCommentFullTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); returnedCommentModel.assertThat().field("content").is(shortString); } - + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Verify Collaborator user can update a comment with special characters") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) @@ -95,7 +272,7 @@ public class UpdateCommentFullTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); returnedCommentModel.assertThat().field("content").is(specialChars); } - + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Check that you cannot update comment with Consumer then call getComments and check new comment is not listed") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) @@ -116,7 +293,7 @@ public class UpdateCommentFullTests extends RestTest .and().entriesListDoesNotContain("content", updatedComment) .and().paginationField("totalItems").is("1"); } - + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Update comment with Contributor then call getComments and check new comment is listed") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) @@ -138,7 +315,7 @@ public class UpdateCommentFullTests extends RestTest .and().entriesListDoesNotContain("content", firstComment) .and().paginationField("totalItems").is("1"); } - + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Update comment with Collaborator then call getComments and check new comment is listed") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) @@ -177,7 +354,7 @@ public class UpdateCommentFullTests extends RestTest returnedCommentModel.assertThat().field("modifiedBy.id").is(manager.getUsername()) .and().field("content").is(updatedComment); } - + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Delete comment with Admin then try to update it") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) @@ -195,7 +372,7 @@ public class UpdateCommentFullTests extends RestTest restClient.withCoreAPI().usingResource(file).updateComment(commentModel, updatedComment); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); } - + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Verify Manager user can update a comment with multi byte content") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) @@ -213,7 +390,7 @@ public class UpdateCommentFullTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); returnedCommentModel.assertThat().field("content").is(multiByte); } - + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Verify Admin user can update a comment with properties parameter") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) @@ -233,7 +410,7 @@ public class UpdateCommentFullTests extends RestTest .assertThat().field("modifiedBy.id").is(manager.getUsername()) .assertThat().fieldsCount().is(4); } - + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Update comment with invalid node") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) @@ -249,7 +426,7 @@ public class UpdateCommentFullTests extends RestTest restClient.withCoreAPI().usingResource(file).updateComment(commentModel, updatedComment); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, file.getNodeRef())); } - + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Verify update comment from node with invalid network id returns status code 401") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) @@ -262,24 +439,24 @@ public class UpdateCommentFullTests extends RestTest restClient.authenticateUser(networkUserModel).withCoreAPI().usingResource(file).updateComment(commentModel, updatedComment); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify User can not update comment to a not joined private site. Status code returned is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void userCanNotUpdateCommentToANotJoinedPrivateSiteDefaultErrorModelSchema() throws Exception - { - UserModel newUser = dataUser.createRandomTestUser(); - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - - commentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + + @TestRail(section = { TestGroup.REST_API, + TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify User can not update comment to a not joined private site. Status code returned is 403") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void userCanNotUpdateCommentToANotJoinedPrivateSiteDefaultErrorModelSchema() throws Exception + { + UserModel newUser = dataUser.createRandomTestUser(); + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + + commentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) .withCoreAPI().usingResource(file).addComment(firstComment); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(newUser).withCoreAPI().usingResource(file).updateComment(commentModel, updatedComment); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE) - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY); - } -} \ No newline at end of file + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(newUser).withCoreAPI().usingResource(file).updateComment(commentModel, updatedComment); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE) + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY); + } +} From 6c82a7a22b5f374a007275e8f4cce13eb619efb0 Mon Sep 17 00:00:00 2001 From: Andrei Forascu Date: Wed, 4 Oct 2017 14:52:00 +0300 Subject: [PATCH 1224/1491] REPO-2755: REST API & CMIS TAS sanity builds: - refactored RestAPI "Comments" API tests to be included in a single class per endpoint (not separate Sanity/Core/Full tests) (2) --- .../comments/DeleteCommentSanityTests.java | 109 ------------- .../rest/comments/GetCommentsSanityTests.java | 146 ------------------ .../comments/UpdateCommentSanityTests.java | 143 ----------------- 3 files changed, 398 deletions(-) delete mode 100644 e2e-test/java/org/alfresco/rest/comments/DeleteCommentSanityTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/comments/UpdateCommentSanityTests.java diff --git a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentSanityTests.java deleted file mode 100644 index dc9381aa2..000000000 --- a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentSanityTests.java +++ /dev/null @@ -1,109 +0,0 @@ -package org.alfresco.rest.comments; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestCommentModel; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class DeleteCommentSanityTests extends RestTest -{ - private UserModel adminUserModel; - - private FileModel document; - private SiteModel siteModel; - private RestCommentModel comment; - private ListUserWithRoles usersWithRoles; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - restClient.authenticateUser(adminUserModel); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Admin user deletes comments with Rest API and status code is 204") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) - public void adminIsAbleToDeleteComments() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel); - comment = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment"); - restClient.withCoreAPI().usingResource(document).deleteComment(comment); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Manager user deletes own comments and status code is 204") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) - public void managerIsAbleToDeleteComments() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - comment = restClient.withCoreAPI().usingResource(document).addComment("New comment added by Manager"); - restClient.withCoreAPI().usingResource(document).deleteComment(comment); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user deletes own comments and status code is 204") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) - public void collaboratorIsAbleToDeleteComments() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - comment = restClient.withCoreAPI().usingResource(document).addComment("New comment added by Collaborator"); - restClient.withCoreAPI().usingResource(document).deleteComment(comment); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Contributor user deletes own comments and status code is 204") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) - public void contributorIsAbleToDeleteComments() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - comment = restClient.withCoreAPI().usingResource(document).addComment("New comment added by Contributor"); - restClient.withCoreAPI().usingResource(document).deleteComment(comment); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Consumer user cannot delete comments and status code returned is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS }) - public void consumerIsNotAbleToDeleteComments() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - comment = restClient.withCoreAPI().usingResource(document).addComment("New comment added by Manager"); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.withCoreAPI().usingResource(document).deleteComment(comment); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify User gets status code 401 if authentication call fails") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) - @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void userIsNotAbleToDeleteCommentIfAuthenticationFails() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel); - comment = restClient.withCoreAPI().usingResource(document).addComment("New comment addded by admin"); - UserModel nonexistentModel = new UserModel("nonexistentUser", "nonexistentPassword"); - restClient.authenticateUser(nonexistentModel); - restClient.withCoreAPI().usingResource(document).deleteComment(comment); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } -} diff --git a/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java deleted file mode 100644 index f781e0eea..000000000 --- a/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java +++ /dev/null @@ -1,146 +0,0 @@ -package org.alfresco.rest.comments; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestCommentModelsCollection; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class GetCommentsSanityTests extends RestTest -{ - private UserModel adminUserModel; - - private FileModel document; - private SiteModel siteModel; - private UserModel userModel; - private ListUserWithRoles usersWithRoles; - private String content = "This is a new comment"; - private RestCommentModelsCollection comments; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(adminUserModel).withCoreAPI() - .usingResource(document).addComment(content); - - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.SANITY, - description= "Verify Admin user gets comments with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) - public void adminIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception - { - comments = restClient.authenticateUser(adminUserModel).withCoreAPI() - .usingResource(document).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", content); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.SANITY, - description= "Verify Manager user gets comments created by admin user with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) - public void managerIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception - { - comments = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI() - .usingResource(document).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", content); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.SANITY, - description= "Verify Contributor user gets comments created by admin user with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) - public void contributorIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception - { - comments = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI() - .usingResource(document).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", content); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.SANITY, - description= "Verify Collaborator user gets comments created by admin user with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) - public void collaboratorIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception - { - comments = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI() - .usingResource(document).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", content); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.SANITY, - description= "Verify Consumer user gets comments created by admin user with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) - public void consumerIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception - { - comments = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI() - .usingResource(document).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", content); - } - - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.SANITY, - description= "Verify Manager user gets status code 401 if authentication call fails") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) - @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void managerIsNotAbleToRetrieveCommentIfAuthenticationFails() throws JsonToModelConversionException, Exception - { - UserModel nonexistentModel = new UserModel("nonexistentUser", "nonexistentPassword"); - restClient.authenticateUser(nonexistentModel).withCoreAPI() - .usingResource(document).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.SANITY, - description= "Verify Manager user gets comments created by another user and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) - public void managerIsAbleToRetrieveCommentsCreatedByAnotherUser() throws JsonToModelConversionException, Exception - { - userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); - String contentManager = "This is a new comment added by " + userModel.getUsername(); - restClient.authenticateUser(userModel).withCoreAPI() - .usingResource(document).addComment(contentManager); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - comments = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI() - .usingResource(document).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", contentManager) - .and().entriesListContains("content", content); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.SANITY, - description= "Verify admin user gets comments created by another user and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) - public void adminIsAbleToRetrieveCommentsCreatedByAnotherUser() throws JsonToModelConversionException, Exception - { - userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); - String contentCollaborator = "This is a new comment added by " + userModel.getUsername(); - restClient.authenticateUser(userModel).withCoreAPI() - .usingResource(document).addComment(contentCollaborator); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - comments = restClient.authenticateUser(adminUserModel).withCoreAPI() - .usingResource(document).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", contentCollaborator) - .and().entriesListContains("content", content); - } -} diff --git a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentSanityTests.java deleted file mode 100644 index 7c360b527..000000000 --- a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentSanityTests.java +++ /dev/null @@ -1,143 +0,0 @@ -package org.alfresco.rest.comments; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestCommentModel; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class UpdateCommentSanityTests extends RestTest -{ - private UserModel adminUserModel; - private FileModel document; - private SiteModel siteModel; - private RestCommentModel commentModel; - private ListUserWithRoles usersWithRoles; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - restClient.authenticateUser(adminUserModel); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - - document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Admin user updates comments and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) - public void adminIsAbleToUpdateHisComment() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel); - commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by admin"); - String updatedContent = "This is the updated comment with admin user"; - restClient.withCoreAPI().usingResource(document).updateComment(commentModel, updatedContent) - .assertThat().field("content").isNotEmpty() - .and().field("content").is(updatedContent); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Manager user updates comments created by admin user and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) - public void managerIsAbleToUpdateHisComment() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by manager"); - restClient.withCoreAPI().usingResource(document).updateComment(commentModel, "This is the updated comment with Manager user") - .and().field("content").is("This is the updated comment with Manager user") - .and().field("canEdit").is(true) - .and().field("canDelete").is(true); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Contributor user can update his own comment and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) - public void contributorIsAbleToUpdateHisComment() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by contributor"); - String updatedContent = "This is the updated comment with Contributor user"; - restClient.withCoreAPI().usingResource(document).updateComment(commentModel, updatedContent); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Consumer user can not update comments created by admin user and status code is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS }) - public void consumerIsNotAbleToUpdateComment() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel); - commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by admin"); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.withCoreAPI().usingResource(document).updateComment(commentModel, "This is the updated comment with Consumer user"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user can update his own comment and status code is 200") -// @Bug(id="REPO-1011") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) - public void collaboratorIsAbleToUpdateHisComment() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by collaborator"); - restClient.withCoreAPI().usingResource(document).updateComment(commentModel, "This is the updated comment with Collaborator user"); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user gets status code 401 on update comment call") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) - @Bug(id = "MNT-16904", description = "fails only on environment with tenants") - public void unauthenticatedUserIsNotAbleToUpdateComment() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel); - commentModel = restClient.withCoreAPI().usingResource(document).addComment("To be updated by unauthenticated user."); - UserModel incorrectUserModel = new UserModel("userName", "password"); - restClient.authenticateUser(incorrectUserModel) - .withCoreAPI().usingResource(document).updateComment(commentModel, "try to update"); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify update comment with inexistent nodeId returns status code 404") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS }) - public void canNotUpdateCommentIfNodeIdIsNotSet() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel); - - FolderModel content = FolderModel.getRandomFolderModel(); - content.setNodeRef("node ref that does not exist"); - commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment"); - restClient.withCoreAPI().usingResource(content).updateComment(commentModel, "This is the updated comment."); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary("node ref that does not exist was not found"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify if commentId is not set the status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS }) - public void canNotUpdateCommentIfCommentIdIsNotSet() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel); - - RestCommentModel comment = new RestCommentModel(); - String id = "comment id that does not exist"; - comment.setId(id); - restClient.withCoreAPI().usingResource(document).updateComment(comment, "This is the updated comment."); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, id)); - } - -} From 7afbe20d0cb624b44eb133f4a87eacc7576354fa Mon Sep 17 00:00:00 2001 From: Andrei Forascu Date: Wed, 4 Oct 2017 15:03:11 +0300 Subject: [PATCH 1225/1491] REPO-2755: REST API & CMIS TAS sanity builds: - refactored RestAPI "Comments" API tests to be included in a single class per endpoint (not separate Sanity/Core/Full tests) (3) --- .../rest/comments/DeleteCommentTests.java | 592 +++++------ .../rest/comments/GetCommentsTests.java | 848 ++++++++-------- .../rest/comments/UpdateCommentTests.java | 924 +++++++++--------- 3 files changed, 1182 insertions(+), 1182 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentTests.java b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentTests.java index 3762e6238..0500bf2a1 100644 --- a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentTests.java @@ -1,296 +1,296 @@ -package org.alfresco.rest.comments; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestCommentModel; -import org.alfresco.rest.model.RestCommentModelsCollection; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class DeleteCommentTests extends RestTest -{ - private UserModel adminUserModel, networkUserModel; - - private FileModel document; - private SiteModel siteModel; - private RestCommentModelsCollection comments; - private RestCommentModel commentModel; - private ListUserWithRoles usersWithRoles; - private String commentText = "This is a new comment"; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - networkUserModel = dataUser.createRandomTestUser(); - restClient.authenticateUser(adminUserModel); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Admin user deletes comments with Rest API and status code is 204") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) - public void adminIsAbleToDeleteComments() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel); - commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment"); - restClient.withCoreAPI().usingResource(document).deleteComment(commentModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify User gets status code 401 if authentication call fails") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) - @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void userIsNotAbleToDeleteCommentIfAuthenticationFails() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel); - commentModel = restClient.withCoreAPI().usingResource(document).addComment("New comment addded by admin"); - UserModel nonexistentModel = new UserModel("nonexistentUser", "nonexistentPassword"); - restClient.authenticateUser(nonexistentModel); - restClient.withCoreAPI().usingResource(document).deleteComment(commentModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Manager user deletes own comments and status code is 204") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) - public void managerIsAbleToDeleteComments() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - commentModel = restClient.withCoreAPI().usingResource(document).addComment("New comment added by Manager"); - restClient.withCoreAPI().usingResource(document).deleteComment(commentModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user deletes own comments and status code is 204") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) - public void collaboratorIsAbleToDeleteComments() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - commentModel = restClient.withCoreAPI().usingResource(document).addComment("New comment added by Collaborator"); - restClient.withCoreAPI().usingResource(document).deleteComment(commentModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Contributor user deletes own comments and status code is 204") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) - public void contributorIsAbleToDeleteComments() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - commentModel = restClient.withCoreAPI().usingResource(document).addComment("New comment added by Contributor"); - restClient.withCoreAPI().usingResource(document).deleteComment(commentModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Consumer user can't delete comments created by admin user and status code is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) - public void consumerIsNotAbleToDeleteComments() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel); - commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment"); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.withCoreAPI().usingResource(document).deleteComment(commentModel); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Admin user can't delete comments with inexistent ID and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) - public void userIsNotAbleToDeleteInexistentComment() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel); - commentModel = new RestCommentModel(); - commentModel.setId("inexistent"); - restClient.withCoreAPI().usingResource(document).deleteComment(commentModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Admin user can't delete comments with inexistend NodeId and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) - public void userIsNotAbleToDeleteCommentWithInexistentNodeId() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel); - commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment"); - FileModel inexistentDocument = new FileModel(); - inexistentDocument.setNodeRef("inexistent"); - restClient.withCoreAPI().usingResource(inexistentDocument).deleteComment(commentModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Admin user can't delete deleted comments and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) - public void userIsNotAbleToDeleteDeletedComment() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel); - commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment"); - restClient.withCoreAPI().usingResource(document).deleteComment(commentModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingResource(document).deleteComment(commentModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS }, - executionType = ExecutionType.REGRESSION, description = "Verify Manager user deletes comment created by admin" - + " and status code is 204. Check with getComments for validation") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void managerIsAbleToDeleteCommentCreatedByOthers() throws JsonToModelConversionException, Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - - commentModel = restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingResource(file).addComment(commentText); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(file).deleteComment(commentModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListDoesNotContain("content", commentText); - comments.getPagination().assertThat().field("totalItems").is("0").and().field("count").is("0"); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS }, - executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user can delete comment created by self" - + " and status code is 204. Check with getComments for validation") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void collaboratorIsAbleToDeleteCommentCreatedBySelf() throws JsonToModelConversionException, Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - - commentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingResource(file).addComment(commentText); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.withCoreAPI().usingResource(file).deleteComment(commentModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListDoesNotContain("content", commentText); - comments.getPagination().assertThat().field("totalItems").is("0").and().field("count").is("0"); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS }, - executionType = ExecutionType.REGRESSION, description = "Verify Contributor user deletes comment created by self" - + " and status code is 204. Check with getComments for validation") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - @Bug(id = "ACE-4614") - public void contributorIsAbleToDeleteCommentCreatedBySelf() throws JsonToModelConversionException, Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - - commentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) - .withCoreAPI().usingResource(file).addComment(commentText); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.withCoreAPI().usingResource(file).deleteComment(commentModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListDoesNotContain("content", commentText); - comments.getPagination().assertThat().field("totalItems").is("0").and().field("count").is("0"); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS }, - executionType = ExecutionType.REGRESSION, description = "Verify Consumer user cannot delete comment created by admin" - + " and status code is 403. Check with getComments for validation and check default error model schema.") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void consumerIsNotAbleToDeleteCommentCreatedByOthersDefaultErrorModelSchema() throws JsonToModelConversionException, Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - - commentModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(commentText); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .withCoreAPI().usingResource(file).deleteComment(commentModel); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .statusCodeIs(HttpStatus.FORBIDDEN) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE) - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY); - - comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", commentText); - comments.getPagination().assertThat().field("totalItems").is("1").and().field("count").is("1"); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS }, - executionType = ExecutionType.REGRESSION, description = "Verify Manager can delete comment with version number") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void usingManagerDeleteCommentWithVersionNumber() throws JsonToModelConversionException, Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - dataContent.usingAdmin().usingResource(file).updateContent("updated content to increase version number"); - - commentModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(commentText); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(file).deleteComment(commentModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS }, - executionType = ExecutionType.REGRESSION, description = "Verify Manager user cannot delete comment with invalid node " - + "and status code is 404. Check with getComments for validation") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void usingManagerDeleteCommentWithInvalidNode() throws JsonToModelConversionException, Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - - commentModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(commentText); - file.setNodeRef("invalid"); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(file).deleteComment(commentModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(file.getNodeRef() + " was not found"); - - comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(file.getNodeRef() + " was not found"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS}, executionType = ExecutionType.REGRESSION, - description = "Verify deleteComment from node with invalid network id returns status code 401") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void deleteCommentWithInvalidNetworkId() throws Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - - commentModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(commentText); - networkUserModel.setDomain("invalidNetwork"); - restClient.authenticateUser(networkUserModel).withCoreAPI().usingResource(file).deleteComment(commentModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS }, - executionType = ExecutionType.REGRESSION, description = "Verify deleteComment from node with empty network id returns status code 401") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void deleteCommentWithEmptyNetworkId() throws JsonToModelConversionException, Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - - commentModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(commentText); - networkUserModel.setDomain(""); - restClient.authenticateUser(networkUserModel).withCoreAPI().usingResource(file).deleteComment(commentModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } -} +package org.alfresco.rest.comments; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestCommentModel; +import org.alfresco.rest.model.RestCommentModelsCollection; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class DeleteCommentTests extends RestTest +{ + private UserModel adminUserModel, networkUserModel; + + private FileModel document; + private SiteModel siteModel; + private RestCommentModelsCollection comments; + private RestCommentModel commentModel; + private ListUserWithRoles usersWithRoles; + private String commentText = "This is a new comment"; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + networkUserModel = dataUser.createRandomTestUser(); + restClient.authenticateUser(adminUserModel); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Admin user deletes comments with Rest API and status code is 204") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) + public void adminIsAbleToDeleteComments() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel); + commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment"); + restClient.withCoreAPI().usingResource(document).deleteComment(commentModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify User gets status code 401 if authentication call fails") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) + @Bug(id="MNT-16904", description = "It fails only on environment with tenants") + public void userIsNotAbleToDeleteCommentIfAuthenticationFails() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel); + commentModel = restClient.withCoreAPI().usingResource(document).addComment("New comment addded by admin"); + UserModel nonexistentModel = new UserModel("nonexistentUser", "nonexistentPassword"); + restClient.authenticateUser(nonexistentModel); + restClient.withCoreAPI().usingResource(document).deleteComment(commentModel); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Manager user deletes own comments and status code is 204") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + public void managerIsAbleToDeleteComments() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + commentModel = restClient.withCoreAPI().usingResource(document).addComment("New comment added by Manager"); + restClient.withCoreAPI().usingResource(document).deleteComment(commentModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user deletes own comments and status code is 204") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + public void collaboratorIsAbleToDeleteComments() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + commentModel = restClient.withCoreAPI().usingResource(document).addComment("New comment added by Collaborator"); + restClient.withCoreAPI().usingResource(document).deleteComment(commentModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Contributor user deletes own comments and status code is 204") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + public void contributorIsAbleToDeleteComments() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + commentModel = restClient.withCoreAPI().usingResource(document).addComment("New comment added by Contributor"); + restClient.withCoreAPI().usingResource(document).deleteComment(commentModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Consumer user can't delete comments created by admin user and status code is 403") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + public void consumerIsNotAbleToDeleteComments() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel); + commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment"); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + restClient.withCoreAPI().usingResource(document).deleteComment(commentModel); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Admin user can't delete comments with inexistent ID and status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + public void userIsNotAbleToDeleteInexistentComment() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel); + commentModel = new RestCommentModel(); + commentModel.setId("inexistent"); + restClient.withCoreAPI().usingResource(document).deleteComment(commentModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Admin user can't delete comments with inexistend NodeId and status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + public void userIsNotAbleToDeleteCommentWithInexistentNodeId() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel); + commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment"); + FileModel inexistentDocument = new FileModel(); + inexistentDocument.setNodeRef("inexistent"); + restClient.withCoreAPI().usingResource(inexistentDocument).deleteComment(commentModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Admin user can't delete deleted comments and status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + public void userIsNotAbleToDeleteDeletedComment() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel); + commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment"); + restClient.withCoreAPI().usingResource(document).deleteComment(commentModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withCoreAPI().usingResource(document).deleteComment(commentModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS }, + executionType = ExecutionType.REGRESSION, description = "Verify Manager user deletes comment created by admin" + + " and status code is 204. Check with getComments for validation") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void managerIsAbleToDeleteCommentCreatedByOthers() throws JsonToModelConversionException, Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + + commentModel = restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingResource(file).addComment(commentText); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(file).deleteComment(commentModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListDoesNotContain("content", commentText); + comments.getPagination().assertThat().field("totalItems").is("0").and().field("count").is("0"); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS }, + executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user can delete comment created by self" + + " and status code is 204. Check with getComments for validation") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void collaboratorIsAbleToDeleteCommentCreatedBySelf() throws JsonToModelConversionException, Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + + commentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingResource(file).addComment(commentText); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.withCoreAPI().usingResource(file).deleteComment(commentModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListDoesNotContain("content", commentText); + comments.getPagination().assertThat().field("totalItems").is("0").and().field("count").is("0"); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS }, + executionType = ExecutionType.REGRESSION, description = "Verify Contributor user deletes comment created by self" + + " and status code is 204. Check with getComments for validation") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + @Bug(id = "ACE-4614") + public void contributorIsAbleToDeleteCommentCreatedBySelf() throws JsonToModelConversionException, Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + + commentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) + .withCoreAPI().usingResource(file).addComment(commentText); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.withCoreAPI().usingResource(file).deleteComment(commentModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListDoesNotContain("content", commentText); + comments.getPagination().assertThat().field("totalItems").is("0").and().field("count").is("0"); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS }, + executionType = ExecutionType.REGRESSION, description = "Verify Consumer user cannot delete comment created by admin" + + " and status code is 403. Check with getComments for validation and check default error model schema.") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void consumerIsNotAbleToDeleteCommentCreatedByOthersDefaultErrorModelSchema() throws JsonToModelConversionException, Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + + commentModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(commentText); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + .withCoreAPI().usingResource(file).deleteComment(commentModel); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .statusCodeIs(HttpStatus.FORBIDDEN) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE) + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY); + + comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", commentText); + comments.getPagination().assertThat().field("totalItems").is("1").and().field("count").is("1"); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS }, + executionType = ExecutionType.REGRESSION, description = "Verify Manager can delete comment with version number") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void usingManagerDeleteCommentWithVersionNumber() throws JsonToModelConversionException, Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + dataContent.usingAdmin().usingResource(file).updateContent("updated content to increase version number"); + + commentModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(commentText); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(file).deleteComment(commentModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS }, + executionType = ExecutionType.REGRESSION, description = "Verify Manager user cannot delete comment with invalid node " + + "and status code is 404. Check with getComments for validation") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void usingManagerDeleteCommentWithInvalidNode() throws JsonToModelConversionException, Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + + commentModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(commentText); + file.setNodeRef("invalid"); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(file).deleteComment(commentModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(file.getNodeRef() + " was not found"); + + comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(file.getNodeRef() + " was not found"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS}, executionType = ExecutionType.REGRESSION, + description = "Verify deleteComment from node with invalid network id returns status code 401") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void deleteCommentWithInvalidNetworkId() throws Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + + commentModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(commentText); + networkUserModel.setDomain("invalidNetwork"); + restClient.authenticateUser(networkUserModel).withCoreAPI().usingResource(file).deleteComment(commentModel); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS }, + executionType = ExecutionType.REGRESSION, description = "Verify deleteComment from node with empty network id returns status code 401") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void deleteCommentWithEmptyNetworkId() throws JsonToModelConversionException, Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + + commentModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(commentText); + networkUserModel.setDomain(""); + restClient.authenticateUser(networkUserModel).withCoreAPI().usingResource(file).deleteComment(commentModel); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } +} diff --git a/e2e-test/java/org/alfresco/rest/comments/GetCommentsTests.java b/e2e-test/java/org/alfresco/rest/comments/GetCommentsTests.java index ad5675cc9..d8fe7d9d0 100644 --- a/e2e-test/java/org/alfresco/rest/comments/GetCommentsTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/GetCommentsTests.java @@ -1,424 +1,424 @@ -package org.alfresco.rest.comments; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestCommentModelsCollection; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FileType; -import org.alfresco.utility.model.LinkModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class GetCommentsTests extends RestTest -{ - private FileModel file, document, document1; - private SiteModel siteModel, privateSiteModel; - private UserModel adminUserModel, userModel, networkUserModel; - private ListUserWithRoles usersWithRoles; - private String comment = "This is a new comment"; - private String comment2 = "This is a 2nd comment"; - private String comment3 = "This is a 3rd comment"; - private RestCommentModelsCollection comments; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - networkUserModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - privateSiteModel = dataSite.usingUser(adminUserModel).createPrivateRandomSite(); - document = dataContent.usingSite(privateSiteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - document1 = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(adminUserModel).withCoreAPI() - .usingResource(document1).addComment(comment); - restClient.withCoreAPI().usingResource(document).addComment(comment); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.withCoreAPI().usingResource(document).addComment(comment2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.withCoreAPI().usingResource(document).addComment(comment3); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.SANITY, - description= "Verify Admin user gets comments with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) - public void adminIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception - { - comments = restClient.authenticateUser(adminUserModel).withCoreAPI() - .usingResource(document1).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", comment); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.SANITY, - description= "Verify Manager user gets status code 401 if authentication call fails") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) - @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void managerIsNotAbleToRetrieveCommentIfAuthenticationFails() throws JsonToModelConversionException, Exception - { - UserModel nonexistentModel = new UserModel("nonexistentUser", "nonexistentPassword"); - restClient.authenticateUser(nonexistentModel).withCoreAPI() - .usingResource(document1).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify Manager user gets comments created by admin user with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) - public void managerIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception - { - comments = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI() - .usingResource(document1).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", comment); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify Contributor user gets comments created by admin user with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) - public void contributorIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception - { - comments = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI() - .usingResource(document1).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", comment); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify Collaborator user gets comments created by admin user with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) - public void collaboratorIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception - { - comments = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI() - .usingResource(document1).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", comment); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify Consumer user gets comments created by admin user with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) - public void consumerIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception - { - comments = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI() - .usingResource(document1).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", comment); - } - - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify Manager user gets comments created by another user and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) - public void managerIsAbleToRetrieveCommentsCreatedByAnotherUser() throws JsonToModelConversionException, Exception - { - userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); - String contentManager = "This is a new comment added by " + userModel.getUsername(); - restClient.authenticateUser(userModel).withCoreAPI() - .usingResource(document1).addComment(contentManager); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - comments = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI() - .usingResource(document1).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", contentManager) - .and().entriesListContains("content", comment); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify admin user gets comments created by another user and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) - public void adminIsAbleToRetrieveCommentsCreatedByAnotherUser() throws JsonToModelConversionException, Exception - { - userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); - String contentCollaborator = "This is a new comment added by " + userModel.getUsername(); - restClient.authenticateUser(userModel).withCoreAPI() - .usingResource(document1).addComment(contentCollaborator); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - comments = restClient.authenticateUser(adminUserModel).withCoreAPI() - .usingResource(document1).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", contentCollaborator) - .and().entriesListContains("content", comment); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify request returns status 403 if the user does not have permission read comments on the node") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) - public void uninvitedUserCanNotGetCommentsFromPrivateSite() throws Exception - { - restClient.authenticateUser(userModel).withCoreAPI() - .usingResource(document).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify user gets comments without the first 2 and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) - public void skipFirst2Comments() throws Exception - { - comments = restClient.authenticateUser(adminUserModel).withParams("skipCount=2") - .withCoreAPI().usingResource(document).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", comment) - .and().paginationField("count").is("1"); - comments.assertThat().paginationField("skipCount").is("2"); - comments.assertThat().paginationField("totalItems").is("3"); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify invalid request returns status code 400 for invalid maxItems or skipCount") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void checkStatusCodeForInvalidMaxItems() throws Exception - { - restClient.authenticateUser(adminUserModel).withParams("maxItems=0") - .withCoreAPI().usingResource(document).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary("Only positive values supported for maxItems"); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify User can't get comments for node with ID that does not exist and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void userCanNotGetCommentsOnNonExistentFile() throws Exception - { - FileModel nonexistentFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); - nonexistentFile.setNodeRef("ABC"); - restClient.authenticateUser(adminUserModel).withCoreAPI() - .usingResource(nonexistentFile).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, nonexistentFile.getNodeRef())); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify User can't get comments for node that exists but is not a document or a folder and status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void userCanNotGetCommentsOnLink() throws Exception - { - LinkModel link = dataLink.usingAdmin().usingSite(siteModel).createRandomLink(); - FileModel fileWithNodeRefFromLink = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); - fileWithNodeRefFromLink.setNodeRef(link.getNodeRef().replace("workspace://SpacesStore/", "workspace%3A%2F%2FSpacesStore%2F")); - restClient.authenticateUser(adminUserModel).withCoreAPI() - .usingResource(fileWithNodeRefFromLink).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, fileWithNodeRefFromLink.getNodeRef())) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify get comments from node with invalid network id returns status code 401") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void getCommentsWithInvalidNetwork() throws Exception - { - networkUserModel.setDomain("invalidNetwork"); - restClient.authenticateUser(networkUserModel).withCoreAPI().usingResource(document).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify get comments from node with empty network id returns status code 401") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void getCommentsWithEmptyNetwork() throws Exception - { - networkUserModel.setDomain(""); - restClient.authenticateUser(networkUserModel).withCoreAPI().usingResource(document).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify that if manager adds one comment, it will be returned in getComments response") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void addCommentWithManagerAndCheckThatCommentIsReturned() throws Exception - { - file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(file).addComment(comment); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", comment) - .getPagination().assertThat().field("totalItems").is("1") - .assertThat().field("count").is("1"); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify that if collaborator adds one comment, it will be returned in getComments response") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void addCommentWithCollaboratorAndCheckThatCommentIsReturned() throws Exception - { - file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingResource(file).addComment(comment); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", comment) - .getPagination().assertThat().field("totalItems").is("1") - .assertThat().field("count").is("1"); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify that if contributor adds one comment, it will be returned in getComments response") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - @Bug(id = "ACE-4614") - public void addCommentWithContributorAndCheckThatCommentIsReturned() throws Exception - { - file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) - .withCoreAPI().usingResource(file).addComment(comment); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", comment) - .getPagination().assertThat().field("totalItems").is("1") - .assertThat().field("count").is("1"); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify that consumer cannot add a comment and no comments will be returned in getComments response") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void addCommentWithConsumerAndCheckThatCommentIsNotReturned() throws Exception - { - file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .withCoreAPI().usingResource(file).addComment(comment); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - - comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().paginationField("totalItems").is("0"); - comments.assertThat().paginationField("count").is("0"); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Add one comment with Manager and check that returned person is the right one") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void addCommentWithManagerCheckReturnedPersonIsTheRightOne() throws Exception - { - file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - UserModel user1 = dataUser.createRandomTestUser(); - dataUser.addUserToSite(user1, siteModel, UserRole.SiteManager); - - restClient.authenticateUser(user1).withCoreAPI().usingResource(file).addComment(comment); - comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); - comments.getOneRandomEntry().onModel().getCreatedBy().assertThat().field("firstName").is(user1.getUsername() + " FirstName") - .assertThat().field("lastName").is("LN-" + user1.getUsername()); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Add one comment with Collaborator and check that returned company details are correct") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void addCommentWithCollaboratorCheckReturnedCompanyDetails() throws Exception - { - file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(file).addComment(comment); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); - comments.getOneRandomEntry().onModel().getCreatedBy().getCompany() - .assertThat().field("organization").isNull() - .assertThat().field("address1").isNull() - .assertThat().field("address2").isNull() - .assertThat().field("address3").isNull() - .assertThat().field("postcode").isNull() - .assertThat().field("telephone").isNull() - .assertThat().field("fax").isNull() - .assertThat().field("email").isNull(); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Add 2 comments with Manager and Collaborator users and verify valid request using skipCount. Check that param is applied") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void addTwoCommentsWithManagerCollaboratorVerifySkipCountParamIsApplied() throws Exception - { - file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(file).addComment(comment); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(file).addComment(comment2); - - comments = restClient.authenticateUser(adminUserModel).withParams("skipCount=1") - .withCoreAPI().usingResource(file).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", comment) - .and().paginationField("count").is("1"); - comments.assertThat().paginationField("skipCount").is("1"); - comments.assertThat().paginationField("totalItems").is("2"); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Add 2 comments with Admin and Collaborator users and verify valid request using maxItems. Check that param is applied") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void addTwoCommentsWithAdminCollaboratorVerifyMaxItemsParamIsApplied() throws Exception - { - file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(comment); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(file).addComment(comment2); - - comments = restClient.authenticateUser(adminUserModel).withParams("maxItems=1") - .withCoreAPI().usingResource(file).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", comment2) - .and().paginationField("count").is("1"); - comments.assertThat().paginationField("totalItems").is("2"); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Add 2 comments with Manager and Admin users and verify valid request using properties. Check that param is applied") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void addTwoCommentsWithAdminManagerVerifyPropertiesParamIsApplied() throws Exception - { - file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(comment); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(file).addComment(comment2); - - comments = restClient.authenticateUser(adminUserModel).withParams("properties=createdBy,modifiedBy") - .withCoreAPI().usingResource(file).getNodeComments(); - comments.assertThat().entriesListIsNotEmpty() - .and().paginationField("count").is("2"); - comments.assertThat().paginationField("totalItems").is("2"); - - comments.getEntries().get(0).onModel().getCreatedBy() - .assertThat().field("firstName").is(usersWithRoles.getOneUserWithRole(UserRole.SiteManager).getUsername() + " FirstName") - .assertThat().field("lastName").is("LN-" + usersWithRoles.getOneUserWithRole(UserRole.SiteManager).getUsername()); - - comments.getEntries().get(1).onModel().getCreatedBy() - .assertThat().field("firstName").is("Administrator") - .assertThat().field("id").is("admin"); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Check default error model schema") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void addTwoCommentsWithManagerCheckDefaultErrorModelSchema() throws Exception - { - file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(file).addComments(comment, comment2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).usingParams("maxItems=0").getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); - restClient.assertLastError().containsErrorKey(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); - restClient.assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); - restClient.assertLastError().descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - restClient.assertLastError().stackTraceIs(RestErrorModel.STACKTRACE); - } -} +package org.alfresco.rest.comments; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestCommentModelsCollection; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FileType; +import org.alfresco.utility.model.LinkModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class GetCommentsTests extends RestTest +{ + private FileModel file, document, document1; + private SiteModel siteModel, privateSiteModel; + private UserModel adminUserModel, userModel, networkUserModel; + private ListUserWithRoles usersWithRoles; + private String comment = "This is a new comment"; + private String comment2 = "This is a 2nd comment"; + private String comment3 = "This is a 3rd comment"; + private RestCommentModelsCollection comments; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + networkUserModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + privateSiteModel = dataSite.usingUser(adminUserModel).createPrivateRandomSite(); + document = dataContent.usingSite(privateSiteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + document1 = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(adminUserModel).withCoreAPI() + .usingResource(document1).addComment(comment); + restClient.withCoreAPI().usingResource(document).addComment(comment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.withCoreAPI().usingResource(document).addComment(comment2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.withCoreAPI().usingResource(document).addComment(comment3); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.SANITY, + description= "Verify Admin user gets comments with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) + public void adminIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception + { + comments = restClient.authenticateUser(adminUserModel).withCoreAPI() + .usingResource(document1).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", comment); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.SANITY, + description= "Verify Manager user gets status code 401 if authentication call fails") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) + @Bug(id="MNT-16904", description = "It fails only on environment with tenants") + public void managerIsNotAbleToRetrieveCommentIfAuthenticationFails() throws JsonToModelConversionException, Exception + { + UserModel nonexistentModel = new UserModel("nonexistentUser", "nonexistentPassword"); + restClient.authenticateUser(nonexistentModel).withCoreAPI() + .usingResource(document1).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify Manager user gets comments created by admin user with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + public void managerIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception + { + comments = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI() + .usingResource(document1).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", comment); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify Contributor user gets comments created by admin user with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + public void contributorIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception + { + comments = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI() + .usingResource(document1).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", comment); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify Collaborator user gets comments created by admin user with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + public void collaboratorIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception + { + comments = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI() + .usingResource(document1).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", comment); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify Consumer user gets comments created by admin user with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + public void consumerIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception + { + comments = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI() + .usingResource(document1).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", comment); + } + + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify Manager user gets comments created by another user and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + public void managerIsAbleToRetrieveCommentsCreatedByAnotherUser() throws JsonToModelConversionException, Exception + { + userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); + String contentManager = "This is a new comment added by " + userModel.getUsername(); + restClient.authenticateUser(userModel).withCoreAPI() + .usingResource(document1).addComment(contentManager); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + comments = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI() + .usingResource(document1).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", contentManager) + .and().entriesListContains("content", comment); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify admin user gets comments created by another user and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + public void adminIsAbleToRetrieveCommentsCreatedByAnotherUser() throws JsonToModelConversionException, Exception + { + userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); + String contentCollaborator = "This is a new comment added by " + userModel.getUsername(); + restClient.authenticateUser(userModel).withCoreAPI() + .usingResource(document1).addComment(contentCollaborator); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + comments = restClient.authenticateUser(adminUserModel).withCoreAPI() + .usingResource(document1).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", contentCollaborator) + .and().entriesListContains("content", comment); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify request returns status 403 if the user does not have permission read comments on the node") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + public void uninvitedUserCanNotGetCommentsFromPrivateSite() throws Exception + { + restClient.authenticateUser(userModel).withCoreAPI() + .usingResource(document).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify user gets comments without the first 2 and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + public void skipFirst2Comments() throws Exception + { + comments = restClient.authenticateUser(adminUserModel).withParams("skipCount=2") + .withCoreAPI().usingResource(document).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", comment) + .and().paginationField("count").is("1"); + comments.assertThat().paginationField("skipCount").is("2"); + comments.assertThat().paginationField("totalItems").is("3"); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify invalid request returns status code 400 for invalid maxItems or skipCount") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void checkStatusCodeForInvalidMaxItems() throws Exception + { + restClient.authenticateUser(adminUserModel).withParams("maxItems=0") + .withCoreAPI().usingResource(document).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary("Only positive values supported for maxItems"); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify User can't get comments for node with ID that does not exist and status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void userCanNotGetCommentsOnNonExistentFile() throws Exception + { + FileModel nonexistentFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); + nonexistentFile.setNodeRef("ABC"); + restClient.authenticateUser(adminUserModel).withCoreAPI() + .usingResource(nonexistentFile).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, nonexistentFile.getNodeRef())); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify User can't get comments for node that exists but is not a document or a folder and status code is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void userCanNotGetCommentsOnLink() throws Exception + { + LinkModel link = dataLink.usingAdmin().usingSite(siteModel).createRandomLink(); + FileModel fileWithNodeRefFromLink = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); + fileWithNodeRefFromLink.setNodeRef(link.getNodeRef().replace("workspace://SpacesStore/", "workspace%3A%2F%2FSpacesStore%2F")); + restClient.authenticateUser(adminUserModel).withCoreAPI() + .usingResource(fileWithNodeRefFromLink).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, fileWithNodeRefFromLink.getNodeRef())) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify get comments from node with invalid network id returns status code 401") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void getCommentsWithInvalidNetwork() throws Exception + { + networkUserModel.setDomain("invalidNetwork"); + restClient.authenticateUser(networkUserModel).withCoreAPI().usingResource(document).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify get comments from node with empty network id returns status code 401") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void getCommentsWithEmptyNetwork() throws Exception + { + networkUserModel.setDomain(""); + restClient.authenticateUser(networkUserModel).withCoreAPI().usingResource(document).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify that if manager adds one comment, it will be returned in getComments response") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void addCommentWithManagerAndCheckThatCommentIsReturned() throws Exception + { + file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(file).addComment(comment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", comment) + .getPagination().assertThat().field("totalItems").is("1") + .assertThat().field("count").is("1"); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify that if collaborator adds one comment, it will be returned in getComments response") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void addCommentWithCollaboratorAndCheckThatCommentIsReturned() throws Exception + { + file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingResource(file).addComment(comment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", comment) + .getPagination().assertThat().field("totalItems").is("1") + .assertThat().field("count").is("1"); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify that if contributor adds one comment, it will be returned in getComments response") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + @Bug(id = "ACE-4614") + public void addCommentWithContributorAndCheckThatCommentIsReturned() throws Exception + { + file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) + .withCoreAPI().usingResource(file).addComment(comment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", comment) + .getPagination().assertThat().field("totalItems").is("1") + .assertThat().field("count").is("1"); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify that consumer cannot add a comment and no comments will be returned in getComments response") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void addCommentWithConsumerAndCheckThatCommentIsNotReturned() throws Exception + { + file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + .withCoreAPI().usingResource(file).addComment(comment); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + + comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().paginationField("totalItems").is("0"); + comments.assertThat().paginationField("count").is("0"); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Add one comment with Manager and check that returned person is the right one") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void addCommentWithManagerCheckReturnedPersonIsTheRightOne() throws Exception + { + file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + UserModel user1 = dataUser.createRandomTestUser(); + dataUser.addUserToSite(user1, siteModel, UserRole.SiteManager); + + restClient.authenticateUser(user1).withCoreAPI().usingResource(file).addComment(comment); + comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); + comments.getOneRandomEntry().onModel().getCreatedBy().assertThat().field("firstName").is(user1.getUsername() + " FirstName") + .assertThat().field("lastName").is("LN-" + user1.getUsername()); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Add one comment with Collaborator and check that returned company details are correct") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void addCommentWithCollaboratorCheckReturnedCompanyDetails() throws Exception + { + file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(file).addComment(comment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); + comments.getOneRandomEntry().onModel().getCreatedBy().getCompany() + .assertThat().field("organization").isNull() + .assertThat().field("address1").isNull() + .assertThat().field("address2").isNull() + .assertThat().field("address3").isNull() + .assertThat().field("postcode").isNull() + .assertThat().field("telephone").isNull() + .assertThat().field("fax").isNull() + .assertThat().field("email").isNull(); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Add 2 comments with Manager and Collaborator users and verify valid request using skipCount. Check that param is applied") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void addTwoCommentsWithManagerCollaboratorVerifySkipCountParamIsApplied() throws Exception + { + file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(file).addComment(comment); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(file).addComment(comment2); + + comments = restClient.authenticateUser(adminUserModel).withParams("skipCount=1") + .withCoreAPI().usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", comment) + .and().paginationField("count").is("1"); + comments.assertThat().paginationField("skipCount").is("1"); + comments.assertThat().paginationField("totalItems").is("2"); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Add 2 comments with Admin and Collaborator users and verify valid request using maxItems. Check that param is applied") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void addTwoCommentsWithAdminCollaboratorVerifyMaxItemsParamIsApplied() throws Exception + { + file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(comment); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(file).addComment(comment2); + + comments = restClient.authenticateUser(adminUserModel).withParams("maxItems=1") + .withCoreAPI().usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", comment2) + .and().paginationField("count").is("1"); + comments.assertThat().paginationField("totalItems").is("2"); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Add 2 comments with Manager and Admin users and verify valid request using properties. Check that param is applied") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void addTwoCommentsWithAdminManagerVerifyPropertiesParamIsApplied() throws Exception + { + file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(comment); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(file).addComment(comment2); + + comments = restClient.authenticateUser(adminUserModel).withParams("properties=createdBy,modifiedBy") + .withCoreAPI().usingResource(file).getNodeComments(); + comments.assertThat().entriesListIsNotEmpty() + .and().paginationField("count").is("2"); + comments.assertThat().paginationField("totalItems").is("2"); + + comments.getEntries().get(0).onModel().getCreatedBy() + .assertThat().field("firstName").is(usersWithRoles.getOneUserWithRole(UserRole.SiteManager).getUsername() + " FirstName") + .assertThat().field("lastName").is("LN-" + usersWithRoles.getOneUserWithRole(UserRole.SiteManager).getUsername()); + + comments.getEntries().get(1).onModel().getCreatedBy() + .assertThat().field("firstName").is("Administrator") + .assertThat().field("id").is("admin"); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Check default error model schema") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void addTwoCommentsWithManagerCheckDefaultErrorModelSchema() throws Exception + { + file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(file).addComments(comment, comment2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).usingParams("maxItems=0").getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); + restClient.assertLastError().containsErrorKey(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); + restClient.assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); + restClient.assertLastError().descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + restClient.assertLastError().stackTraceIs(RestErrorModel.STACKTRACE); + } +} diff --git a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentTests.java b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentTests.java index fd8661ef3..07d4d11e6 100644 --- a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentTests.java @@ -1,462 +1,462 @@ -package org.alfresco.rest.comments; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestCommentModel; -import org.alfresco.rest.model.RestCommentModelsCollection; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FileType; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.LinkModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.apache.commons.lang.RandomStringUtils; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class UpdateCommentTests extends RestTest -{ - private UserModel adminUserModel, networkUserModel; - private FileModel document; - private SiteModel siteModel; - private RestCommentModel commentModel, returnedCommentModel; - private RestCommentModelsCollection comments;; - private ListUserWithRoles usersWithRoles; - private String firstComment = "This is a new comment"; - private String updatedComment = "This is the updated comment"; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - restClient.authenticateUser(adminUserModel); - networkUserModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - - document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Admin user updates comments and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) - public void adminIsAbleToUpdateHisComment() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel); - commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by admin"); - String updatedContent = "This is the updated comment with admin user"; - restClient.withCoreAPI().usingResource(document).updateComment(commentModel, updatedContent) - .assertThat().field("content").isNotEmpty() - .and().field("content").is(updatedContent); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user gets status code 401 on update comment call") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) - @Bug(id = "MNT-16904", description = "fails only on environment with tenants") - public void unauthenticatedUserIsNotAbleToUpdateComment() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel); - commentModel = restClient.withCoreAPI().usingResource(document).addComment("To be updated by unauthenticated user."); - UserModel incorrectUserModel = new UserModel("userName", "password"); - restClient.authenticateUser(incorrectUserModel) - .withCoreAPI().usingResource(document).updateComment(commentModel, "try to update"); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify entry content in response") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) - public void checkEntryContentInResponse() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel); - commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by admin"); - commentModel = restClient.withCoreAPI().usingResource(document).updateComment(commentModel, "This is the updated comment with admin user"); - restClient.assertStatusCodeIs(HttpStatus.OK); - commentModel.assertThat().field("content").is("This is the updated comment with admin user"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Manager user updates comments created by admin user and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) - public void managerIsAbleToUpdateHisComment() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by manager"); - restClient.withCoreAPI().usingResource(document).updateComment(commentModel, "This is the updated comment with Manager user") - .and().field("content").is("This is the updated comment with Manager user") - .and().field("canEdit").is(true) - .and().field("canDelete").is(true); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Contributor user can update his own comment and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) - public void contributorIsAbleToUpdateHisComment() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by contributor"); - String updatedContent = "This is the updated comment with Contributor user"; - restClient.withCoreAPI().usingResource(document).updateComment(commentModel, updatedContent); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Consumer user can not update comments created by admin user and status code is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) - public void consumerIsNotAbleToUpdateComment() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel); - commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by admin"); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.withCoreAPI().usingResource(document).updateComment(commentModel, "This is the updated comment with Consumer user"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user can update his own comment and status code is 200") -// @Bug(id="REPO-1011") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) - public void collaboratorIsAbleToUpdateHisComment() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by collaborator"); - restClient.withCoreAPI().usingResource(document).updateComment(commentModel, "This is the updated comment with Collaborator user"); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user can not update comments of another user and status code is 200") -// @Bug(id="MNT-2502",description="seems it's one old issue: also logged as MNT-2502, MNT-2346") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) - public void collaboratorIsNotAbleToUpdateCommentOfAnotherUser() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel); - commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by admin"); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingResource(document).updateComment(commentModel, "This is the updated comment with Collaborator user"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify update comment with inexistent nodeId returns status code 404") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void canNotUpdateCommentIfNodeIdIsNotSet() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel); - - FolderModel content = FolderModel.getRandomFolderModel(); - content.setNodeRef("node ref that does not exist"); - commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment"); - restClient.withCoreAPI().usingResource(content).updateComment(commentModel, "This is the updated comment."); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary("node ref that does not exist was not found"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify if commentId is not set the status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void canNotUpdateCommentIfCommentIdIsNotSet() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel); - - RestCommentModel comment = new RestCommentModel(); - String id = "comment id that does not exist"; - comment.setId(id); - restClient.withCoreAPI().usingResource(document).updateComment(comment, "This is the updated comment."); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, id)); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify can not update comment if NodeId is neither document or folder and returns status code 405") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void canNotUpdateCommentIfNodeIdIsNeitherDocumentOrFolder() throws JsonToModelConversionException, Exception - { - FileModel content = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); - content = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(adminUserModel); - commentModel = restClient.withCoreAPI().usingResource(content).addComment("This is a new comment"); - - LinkModel link = dataLink.usingAdmin().usingSite(siteModel).createRandomLink(); - content.setNodeRef(link.getNodeRef().replace("workspace://SpacesStore/", "workspace%3A%2F%2FSpacesStore%2F")); - - restClient.withCoreAPI().usingResource(content).updateComment(commentModel, "This is the updated comment."); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, content.getNodeRef())) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Admin user is not able to update with empty comment body and status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void adminIsNotAbleToUpdateWithEmptyCommentBody() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel); - commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by admin"); - restClient.withCoreAPI().usingResource(document).updateComment(commentModel, ""); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary("An invalid argument was received"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify updated comment by Manager is listed when calling getComments and status code is 200") -// @Bug(id="REPO-1011") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void updatedCommentByManagerIsListed() throws JsonToModelConversionException, Exception - { - commentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingResource(document).addComment("This is a new comment added by collaborator"); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI() - .usingResource(document).updateComment(commentModel, "This is the updated comment with Manager user"); - comments = restClient.withCoreAPI().usingResource(document).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", "This is the updated comment with Manager user"); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify Manager user can update a comment with a large string") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void managerIsAbleToUpdateACommentWithALargeString() throws JsonToModelConversionException, Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - String longString = RandomStringUtils.randomAlphanumeric(10000); - - commentModel = restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingResource(file).addComment(firstComment); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedCommentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(file).updateComment(commentModel, longString); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCommentModel.assertThat().field("content").is(longString); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify Manager user can update a comment with a short string") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void managerIsAbleToUpdateACommentWithAShortString() throws JsonToModelConversionException, Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - String shortString = RandomStringUtils.randomAlphanumeric(2); - - commentModel = restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingResource(file).addComment(firstComment); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedCommentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(file).updateComment(commentModel, shortString); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCommentModel.assertThat().field("content").is(shortString); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify Collaborator user can update a comment with special characters") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void collaboratorIsAbleToUpdateACommentThatContainsSpecialChars() throws JsonToModelConversionException, Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - String specialChars = "!@#$%^&*()'\".,<>-_+=|\\"; - - commentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingResource(file).addComment(firstComment); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedCommentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingResource(file).updateComment(commentModel, specialChars); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCommentModel.assertThat().field("content").is(specialChars); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Check that you cannot update comment with Consumer then call getComments and check new comment is not listed") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void cannotUpdateCommentWithConsumerCallGetComments() throws JsonToModelConversionException, Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - - commentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingResource(file).addComment(firstComment); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingResource(file).updateComment(commentModel, updatedComment); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - - comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", firstComment) - .and().entriesListDoesNotContain("content", updatedComment) - .and().paginationField("totalItems").is("1"); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Update comment with Contributor then call getComments and check new comment is listed") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - @Bug(id = "ACE-4614") - public void updateCommentWithContributorCallGetComments() throws JsonToModelConversionException, Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - - commentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) - .withCoreAPI().usingResource(file).addComment(firstComment); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingResource(file).updateComment(commentModel, updatedComment); - restClient.assertStatusCodeIs(HttpStatus.OK); - - comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", updatedComment) - .and().entriesListDoesNotContain("content", firstComment) - .and().paginationField("totalItems").is("1"); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Update comment with Collaborator then call getComments and check new comment is listed") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void updateCommentWithCollaboratorCallGetComments() throws JsonToModelConversionException, Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - - commentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingResource(file).addComment(firstComment); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(file).updateComment(commentModel, updatedComment); - restClient.assertStatusCodeIs(HttpStatus.OK); - - comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", updatedComment) - .and().entriesListDoesNotContain("content", firstComment) - .and().paginationField("totalItems").is("1"); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Update comment with Manager then check modified by information in response") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void updateCommentWithManagerCheckModifiedBy() throws JsonToModelConversionException, Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - UserModel manager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); - - commentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingResource(file).addComment(firstComment); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedCommentModel = restClient.authenticateUser(manager).withCoreAPI().usingResource(file).updateComment(commentModel, updatedComment); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCommentModel.assertThat().field("modifiedBy.id").is(manager.getUsername()) - .and().field("content").is(updatedComment); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Delete comment with Admin then try to update it") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void deleteCommentThenTryToUpdateIt() throws JsonToModelConversionException, Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - - commentModel = restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingResource(file).addComment(firstComment); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.withCoreAPI().usingResource(file).deleteComment(commentModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingResource(file).updateComment(commentModel, updatedComment); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify Manager user can update a comment with multi byte content") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void managerIsAbleToUpdateACommentWithMultiByteContent() throws JsonToModelConversionException, Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - String multiByte = "\ufeff\u6768\u6728\u91d1"; - - commentModel = restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingResource(file).addComment(firstComment); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedCommentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(file).updateComment(commentModel, multiByte); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCommentModel.assertThat().field("content").is(multiByte); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify Admin user can update a comment with properties parameter") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void adminIsAbleToUpdateACommentWithPropertiesParameter() throws JsonToModelConversionException, Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - - commentModel = restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingResource(file).addComment(firstComment); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - UserModel manager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); - - returnedCommentModel = restClient.authenticateUser(manager) - .withParams("properties=createdBy,modifiedBy,canEdit,canDelete").withCoreAPI().usingResource(file).updateComment(commentModel, updatedComment); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCommentModel.assertThat().field("createdBy.id").is(adminUserModel.getUsername()) - .assertThat().field("modifiedBy.id").is(manager.getUsername()) - .assertThat().fieldsCount().is(4); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, - description = "Update comment with invalid node") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void updateCommentUsingInvalidNodeId() throws JsonToModelConversionException, Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - - commentModel = restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingResource(file).addComment(firstComment); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - file.setNodeRef(RandomStringUtils.randomAlphanumeric(20)); - restClient.withCoreAPI().usingResource(file).updateComment(commentModel, updatedComment); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, file.getNodeRef())); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify update comment from node with invalid network id returns status code 401") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void updateCommentWithInvalidNetworkId() throws Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - - commentModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(firstComment); - networkUserModel.setDomain("invalidNetwork"); - restClient.authenticateUser(networkUserModel).withCoreAPI().usingResource(file).updateComment(commentModel, updatedComment); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify User can not update comment to a not joined private site. Status code returned is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void userCanNotUpdateCommentToANotJoinedPrivateSiteDefaultErrorModelSchema() throws Exception - { - UserModel newUser = dataUser.createRandomTestUser(); - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - - commentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(file).addComment(firstComment); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(newUser).withCoreAPI().usingResource(file).updateComment(commentModel, updatedComment); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE) - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY); - } -} +package org.alfresco.rest.comments; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestCommentModel; +import org.alfresco.rest.model.RestCommentModelsCollection; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FileType; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.LinkModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.apache.commons.lang.RandomStringUtils; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class UpdateCommentTests extends RestTest +{ + private UserModel adminUserModel, networkUserModel; + private FileModel document; + private SiteModel siteModel; + private RestCommentModel commentModel, returnedCommentModel; + private RestCommentModelsCollection comments;; + private ListUserWithRoles usersWithRoles; + private String firstComment = "This is a new comment"; + private String updatedComment = "This is the updated comment"; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + restClient.authenticateUser(adminUserModel); + networkUserModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Admin user updates comments and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) + public void adminIsAbleToUpdateHisComment() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel); + commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by admin"); + String updatedContent = "This is the updated comment with admin user"; + restClient.withCoreAPI().usingResource(document).updateComment(commentModel, updatedContent) + .assertThat().field("content").isNotEmpty() + .and().field("content").is(updatedContent); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user gets status code 401 on update comment call") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) + @Bug(id = "MNT-16904", description = "fails only on environment with tenants") + public void unauthenticatedUserIsNotAbleToUpdateComment() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel); + commentModel = restClient.withCoreAPI().usingResource(document).addComment("To be updated by unauthenticated user."); + UserModel incorrectUserModel = new UserModel("userName", "password"); + restClient.authenticateUser(incorrectUserModel) + .withCoreAPI().usingResource(document).updateComment(commentModel, "try to update"); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify entry content in response") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) + public void checkEntryContentInResponse() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel); + commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by admin"); + commentModel = restClient.withCoreAPI().usingResource(document).updateComment(commentModel, "This is the updated comment with admin user"); + restClient.assertStatusCodeIs(HttpStatus.OK); + commentModel.assertThat().field("content").is("This is the updated comment with admin user"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Manager user updates comments created by admin user and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + public void managerIsAbleToUpdateHisComment() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by manager"); + restClient.withCoreAPI().usingResource(document).updateComment(commentModel, "This is the updated comment with Manager user") + .and().field("content").is("This is the updated comment with Manager user") + .and().field("canEdit").is(true) + .and().field("canDelete").is(true); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Contributor user can update his own comment and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + public void contributorIsAbleToUpdateHisComment() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by contributor"); + String updatedContent = "This is the updated comment with Contributor user"; + restClient.withCoreAPI().usingResource(document).updateComment(commentModel, updatedContent); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Consumer user can not update comments created by admin user and status code is 403") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + public void consumerIsNotAbleToUpdateComment() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel); + commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by admin"); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + restClient.withCoreAPI().usingResource(document).updateComment(commentModel, "This is the updated comment with Consumer user"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user can update his own comment and status code is 200") +// @Bug(id="REPO-1011") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + public void collaboratorIsAbleToUpdateHisComment() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by collaborator"); + restClient.withCoreAPI().usingResource(document).updateComment(commentModel, "This is the updated comment with Collaborator user"); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user can not update comments of another user and status code is 200") +// @Bug(id="MNT-2502",description="seems it's one old issue: also logged as MNT-2502, MNT-2346") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + public void collaboratorIsNotAbleToUpdateCommentOfAnotherUser() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel); + commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by admin"); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingResource(document).updateComment(commentModel, "This is the updated comment with Collaborator user"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify update comment with inexistent nodeId returns status code 404") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void canNotUpdateCommentIfNodeIdIsNotSet() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel); + + FolderModel content = FolderModel.getRandomFolderModel(); + content.setNodeRef("node ref that does not exist"); + commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment"); + restClient.withCoreAPI().usingResource(content).updateComment(commentModel, "This is the updated comment."); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary("node ref that does not exist was not found"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify if commentId is not set the status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void canNotUpdateCommentIfCommentIdIsNotSet() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel); + + RestCommentModel comment = new RestCommentModel(); + String id = "comment id that does not exist"; + comment.setId(id); + restClient.withCoreAPI().usingResource(document).updateComment(comment, "This is the updated comment."); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, id)); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify can not update comment if NodeId is neither document or folder and returns status code 405") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void canNotUpdateCommentIfNodeIdIsNeitherDocumentOrFolder() throws JsonToModelConversionException, Exception + { + FileModel content = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); + content = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(adminUserModel); + commentModel = restClient.withCoreAPI().usingResource(content).addComment("This is a new comment"); + + LinkModel link = dataLink.usingAdmin().usingSite(siteModel).createRandomLink(); + content.setNodeRef(link.getNodeRef().replace("workspace://SpacesStore/", "workspace%3A%2F%2FSpacesStore%2F")); + + restClient.withCoreAPI().usingResource(content).updateComment(commentModel, "This is the updated comment."); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, content.getNodeRef())) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Admin user is not able to update with empty comment body and status code is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void adminIsNotAbleToUpdateWithEmptyCommentBody() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel); + commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by admin"); + restClient.withCoreAPI().usingResource(document).updateComment(commentModel, ""); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary("An invalid argument was received"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify updated comment by Manager is listed when calling getComments and status code is 200") +// @Bug(id="REPO-1011") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void updatedCommentByManagerIsListed() throws JsonToModelConversionException, Exception + { + commentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingResource(document).addComment("This is a new comment added by collaborator"); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI() + .usingResource(document).updateComment(commentModel, "This is the updated comment with Manager user"); + comments = restClient.withCoreAPI().usingResource(document).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", "This is the updated comment with Manager user"); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify Manager user can update a comment with a large string") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void managerIsAbleToUpdateACommentWithALargeString() throws JsonToModelConversionException, Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + String longString = RandomStringUtils.randomAlphanumeric(10000); + + commentModel = restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingResource(file).addComment(firstComment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedCommentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(file).updateComment(commentModel, longString); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCommentModel.assertThat().field("content").is(longString); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify Manager user can update a comment with a short string") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void managerIsAbleToUpdateACommentWithAShortString() throws JsonToModelConversionException, Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + String shortString = RandomStringUtils.randomAlphanumeric(2); + + commentModel = restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingResource(file).addComment(firstComment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedCommentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(file).updateComment(commentModel, shortString); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCommentModel.assertThat().field("content").is(shortString); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify Collaborator user can update a comment with special characters") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void collaboratorIsAbleToUpdateACommentThatContainsSpecialChars() throws JsonToModelConversionException, Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + String specialChars = "!@#$%^&*()'\".,<>-_+=|\\"; + + commentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingResource(file).addComment(firstComment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedCommentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingResource(file).updateComment(commentModel, specialChars); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCommentModel.assertThat().field("content").is(specialChars); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Check that you cannot update comment with Consumer then call getComments and check new comment is not listed") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void cannotUpdateCommentWithConsumerCallGetComments() throws JsonToModelConversionException, Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + + commentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingResource(file).addComment(firstComment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingResource(file).updateComment(commentModel, updatedComment); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + + comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", firstComment) + .and().entriesListDoesNotContain("content", updatedComment) + .and().paginationField("totalItems").is("1"); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Update comment with Contributor then call getComments and check new comment is listed") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + @Bug(id = "ACE-4614") + public void updateCommentWithContributorCallGetComments() throws JsonToModelConversionException, Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + + commentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) + .withCoreAPI().usingResource(file).addComment(firstComment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingResource(file).updateComment(commentModel, updatedComment); + restClient.assertStatusCodeIs(HttpStatus.OK); + + comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", updatedComment) + .and().entriesListDoesNotContain("content", firstComment) + .and().paginationField("totalItems").is("1"); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Update comment with Collaborator then call getComments and check new comment is listed") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void updateCommentWithCollaboratorCallGetComments() throws JsonToModelConversionException, Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + + commentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingResource(file).addComment(firstComment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(file).updateComment(commentModel, updatedComment); + restClient.assertStatusCodeIs(HttpStatus.OK); + + comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", updatedComment) + .and().entriesListDoesNotContain("content", firstComment) + .and().paginationField("totalItems").is("1"); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Update comment with Manager then check modified by information in response") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void updateCommentWithManagerCheckModifiedBy() throws JsonToModelConversionException, Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + UserModel manager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); + + commentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingResource(file).addComment(firstComment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedCommentModel = restClient.authenticateUser(manager).withCoreAPI().usingResource(file).updateComment(commentModel, updatedComment); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCommentModel.assertThat().field("modifiedBy.id").is(manager.getUsername()) + .and().field("content").is(updatedComment); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Delete comment with Admin then try to update it") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void deleteCommentThenTryToUpdateIt() throws JsonToModelConversionException, Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + + commentModel = restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingResource(file).addComment(firstComment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.withCoreAPI().usingResource(file).deleteComment(commentModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingResource(file).updateComment(commentModel, updatedComment); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify Manager user can update a comment with multi byte content") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void managerIsAbleToUpdateACommentWithMultiByteContent() throws JsonToModelConversionException, Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + String multiByte = "\ufeff\u6768\u6728\u91d1"; + + commentModel = restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingResource(file).addComment(firstComment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedCommentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(file).updateComment(commentModel, multiByte); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCommentModel.assertThat().field("content").is(multiByte); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify Admin user can update a comment with properties parameter") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void adminIsAbleToUpdateACommentWithPropertiesParameter() throws JsonToModelConversionException, Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + + commentModel = restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingResource(file).addComment(firstComment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + UserModel manager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); + + returnedCommentModel = restClient.authenticateUser(manager) + .withParams("properties=createdBy,modifiedBy,canEdit,canDelete").withCoreAPI().usingResource(file).updateComment(commentModel, updatedComment); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCommentModel.assertThat().field("createdBy.id").is(adminUserModel.getUsername()) + .assertThat().field("modifiedBy.id").is(manager.getUsername()) + .assertThat().fieldsCount().is(4); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, + description = "Update comment with invalid node") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void updateCommentUsingInvalidNodeId() throws JsonToModelConversionException, Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + + commentModel = restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingResource(file).addComment(firstComment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + file.setNodeRef(RandomStringUtils.randomAlphanumeric(20)); + restClient.withCoreAPI().usingResource(file).updateComment(commentModel, updatedComment); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, file.getNodeRef())); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify update comment from node with invalid network id returns status code 401") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void updateCommentWithInvalidNetworkId() throws Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + + commentModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(firstComment); + networkUserModel.setDomain("invalidNetwork"); + restClient.authenticateUser(networkUserModel).withCoreAPI().usingResource(file).updateComment(commentModel, updatedComment); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify User can not update comment to a not joined private site. Status code returned is 403") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + public void userCanNotUpdateCommentToANotJoinedPrivateSiteDefaultErrorModelSchema() throws Exception + { + UserModel newUser = dataUser.createRandomTestUser(); + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + + commentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(file).addComment(firstComment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(newUser).withCoreAPI().usingResource(file).updateComment(commentModel, updatedComment); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE) + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY); + } +} From 65887702fe9debd36c8762017afe57bd541fcac4 Mon Sep 17 00:00:00 2001 From: cagache Date: Fri, 6 Oct 2017 11:59:04 +0300 Subject: [PATCH 1226/1491] REPO-2755 / REPO-2251: changed CORE and FULL groups with REGRESSION in comments package --- .../rest/comments/AddCommentTests.java | 55 ++++++----- .../rest/comments/AddCommentsTests.java | 36 +++---- .../rest/comments/DeleteCommentTests.java | 62 ++++++------ .../rest/comments/GetCommentsTests.java | 64 ++++++------- .../rest/comments/UpdateCommentTests.java | 94 +++++++++---------- 5 files changed, 154 insertions(+), 157 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentTests.java b/e2e-test/java/org/alfresco/rest/comments/AddCommentTests.java index d8e61dc6a..fbd7cde34 100644 --- a/e2e-test/java/org/alfresco/rest/comments/AddCommentTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/AddCommentTests.java @@ -3,7 +3,6 @@ package org.alfresco.rest.comments; import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestCommentModel; import org.alfresco.rest.model.RestCommentModelsCollection; import org.alfresco.rest.model.RestErrorModel; @@ -46,7 +45,7 @@ public class AddCommentTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify admin user adds comments with Rest API and status code is 201") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) - public void adminIsAbleToAddComment() throws JsonToModelConversionException, Exception + public void adminIsAbleToAddComment() throws Exception { restClient.authenticateUser(adminUserModel); String newContent = "This is a new comment added by " + adminUserModel.getUsername(); @@ -60,7 +59,7 @@ public class AddCommentTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify that comment can be retrieved after it is added") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) - public void addCommentThenRetrieveComment() throws JsonToModelConversionException, Exception + public void addCommentThenRetrieveComment() throws Exception { comment = RandomData.getRandomName("comment1"); restClient.authenticateUser(adminUserModel) @@ -77,7 +76,7 @@ public class AddCommentTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user gets status code 401 on post comments call") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) // @Bug(id = "MNT-16904", description = "It fails only on environment with tenants") - public void unauthenticatedUserIsNotAbleToAddComment() throws JsonToModelConversionException, Exception + public void unauthenticatedUserIsNotAbleToAddComment() throws Exception { restClient.authenticateUser(new UserModel("random user", "random password")); restClient.withCoreAPI().usingResource(document).addComment("This is a new comment"); @@ -86,8 +85,8 @@ public class AddCommentTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Manager user adds comments with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) - public void managerIsAbleToAddComment() throws JsonToModelConversionException, Exception + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void managerIsAbleToAddComment() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); String contentSiteManger = "This is a new comment added by user with role: " + UserRole.SiteManager; @@ -99,9 +98,9 @@ public class AddCommentTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Contributor user adds comments with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) @Bug(id="ACE-4614") - public void contributorIsAbleToAddComment() throws JsonToModelConversionException, Exception + public void contributorIsAbleToAddComment() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); String contentSiteContributor = "This is a new comment added by user with role" + UserRole.SiteContributor; @@ -113,8 +112,8 @@ public class AddCommentTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user adds comments with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) - public void collaboratorIsAbleToAddComment() throws JsonToModelConversionException, Exception + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void collaboratorIsAbleToAddComment() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); String contentSiteCollaborator = "This is a new comment added by user with role: " + UserRole.SiteCollaborator; @@ -125,8 +124,8 @@ public class AddCommentTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Consumer user can't add comments with Rest API and status code is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) - public void consumerIsNotAbleToAddComment() throws JsonToModelConversionException, Exception + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void consumerIsNotAbleToAddComment() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); String contentSiteConsumer = "This is a new comment added by user with role: " + UserRole.SiteConsumer; @@ -138,8 +137,8 @@ public class AddCommentTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify that invalid request returns status code 404 for nodeId that does not exist") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) - public void addCommentUsingInvalidNodeId() throws JsonToModelConversionException, Exception + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void addCommentUsingInvalidNodeId() throws Exception { comment = RandomData.getRandomName("comment1"); FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); @@ -153,8 +152,8 @@ public class AddCommentTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify that request using nodeId that is neither document or folder returns 405") @Bug(id = "MNT-16904") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void addCommentUsingResourceThatIsNotFileOrFolder() throws JsonToModelConversionException, Exception + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void addCommentUsingResourceThatIsNotFileOrFolder() throws Exception { comment = RandomData.getRandomName("comment1"); LinkModel link = dataLink.usingAdmin().usingSite(siteModel).createRandomLink(); @@ -169,8 +168,8 @@ public class AddCommentTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify that adding comment using empty content returns 400 status code") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void addCommentUsingEmptyContent() throws JsonToModelConversionException, Exception + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void addCommentUsingEmptyContent() throws Exception { restClient.authenticateUser(adminUserModel) .withCoreAPI().usingResource(document).addComment(""); @@ -179,8 +178,8 @@ public class AddCommentTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify adding comment with the same content as one existing comment") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void addCommentTwice() throws JsonToModelConversionException, Exception + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void addCommentTwice() throws Exception { comment = RandomData.getRandomName("comment1"); restClient.authenticateUser(adminUserModel) @@ -196,8 +195,8 @@ public class AddCommentTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify comment cannot be added if user is not member of private site") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void addCommentWithNonMemberOfPrivateSite() throws JsonToModelConversionException, Exception + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void addCommentWithNonMemberOfPrivateSite() throws Exception { comment = RandomData.getRandomName("comment1"); UserModel member = dataUser.createRandomTestUser(); @@ -212,8 +211,8 @@ public class AddCommentTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify comment cannot be added if empty network ID is provided") // @Bug(id = "MNT-16904", description = "It fails only on environment with tenants") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void addCommentUsingEmptyNetworkId() throws JsonToModelConversionException, Exception + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void addCommentUsingEmptyNetworkId() throws Exception { comment = RandomData.getRandomName("comment1"); UserModel member = dataUser.createRandomTestUser(); @@ -227,8 +226,8 @@ public class AddCommentTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify that comment cannot be added to another comment") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void addCommentToAComment() throws JsonToModelConversionException, Exception + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void addCommentToAComment() throws Exception { comment = RandomData.getRandomName("comment1"); FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); @@ -244,8 +243,8 @@ public class AddCommentTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify that comment cannot be added to a tag") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void addCommentToATag() throws JsonToModelConversionException, Exception + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void addCommentToATag() throws Exception { comment = RandomData.getRandomName("comment1"); FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentsTests.java b/e2e-test/java/org/alfresco/rest/comments/AddCommentsTests.java index 371964adf..c00ddf436 100644 --- a/e2e-test/java/org/alfresco/rest/comments/AddCommentsTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/AddCommentsTests.java @@ -87,7 +87,7 @@ public class AddCommentsTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Manager user adds multiple comments with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) public void managerIsAbleToAddComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) @@ -100,7 +100,7 @@ public class AddCommentsTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Contributor user adds multiple comments with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) public void contributorIsAbleToAddComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) @@ -113,7 +113,7 @@ public class AddCommentsTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user adds multiple comments with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) public void collaboratorIsAbleToAddComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) @@ -127,7 +127,7 @@ public class AddCommentsTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Consumer user adds multiple comments with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) public void consumerIsAbleToAddComments() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) @@ -138,7 +138,7 @@ public class AddCommentsTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Verify User can not add comments to a not joined private site. Status code returned is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) public void userCanNotAddCommentsToANotJoinedPrivateSite() throws Exception { SiteModel sitePrivateNotJoined = dataSite.createPrivateRandomSite(); @@ -151,7 +151,7 @@ public class AddCommentsTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Verify User can't add comments to a node with ID that does not exist and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) public void userCanNotAddCommentsOnNonexistentFile() throws Exception { FileModel nonexistentFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); @@ -164,7 +164,7 @@ public class AddCommentsTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Verify User can't add comments to a node that exists but is not a document or a folder and status code is 405") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) @Bug(id = "MNT-16904") public void userCanNotAddCommentsOnLink() throws Exception { @@ -180,7 +180,7 @@ public class AddCommentsTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Verify User can add comments with the same content as one existing comment") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) public void userCanAddCommentWithTheSameContentAsExistingOne() throws Exception { FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); @@ -204,7 +204,7 @@ public class AddCommentsTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Verify add comments from node with invalid network id returns status code 401") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) public void addCommentsWithInvalidNetworkId() throws Exception { FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); @@ -216,7 +216,7 @@ public class AddCommentsTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Verify add comments from node with empty network id returns status code 401") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) public void addCommentsWithEmptyNetworkId() throws Exception { FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); @@ -228,7 +228,7 @@ public class AddCommentsTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify that comments cannot be added to another comment") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) public void addCommentsToAComment() throws JsonToModelConversionException, Exception { FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); @@ -244,7 +244,7 @@ public class AddCommentsTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify that comments cannot be added to a tag") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) public void addCommentsToATag() throws JsonToModelConversionException, Exception { FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); @@ -260,7 +260,7 @@ public class AddCommentsTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Using Manager user verify that you can provide a large string for one comment") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) public void addLongCommentsWithManagerAndCheckThatCommentIsReturned() throws Exception { document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); @@ -281,7 +281,7 @@ public class AddCommentsTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Using Manager user verify that you can provide a short string for one comment") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) public void addShortCommentsWithManagerAndCheckThatCommentIsReturned() throws Exception { document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); @@ -302,7 +302,7 @@ public class AddCommentsTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Using Collaborator user verify that you can provide a string with special characters for one comment") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) public void addCommentsWithSpecialCharsWithCollaboratorCheckCommentIsReturned() throws Exception { document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); @@ -323,7 +323,7 @@ public class AddCommentsTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Using Manager user verify that you can not provide an empty string for one comment") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) public void addEmptyStringCommentsWithManagerCheckCommentIsReturned() throws Exception { document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); @@ -337,7 +337,7 @@ public class AddCommentsTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Using Collaborator user verify that you can provide several comments in one request") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) public void addSeveralCommentsWithCollaboratorCheckCommentsAreReturned() throws Exception { document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); @@ -358,7 +358,7 @@ public class AddCommentsTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Provide invalid request body parameter and check default error model schema") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) public void invalidRequestBodyParameterCheckErrorModelSchema() throws Exception { document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); diff --git a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentTests.java b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentTests.java index 0500bf2a1..e05b22c72 100644 --- a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentTests.java @@ -44,7 +44,7 @@ public class DeleteCommentTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Admin user deletes comments with Rest API and status code is 204") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) - public void adminIsAbleToDeleteComments() throws JsonToModelConversionException, Exception + public void adminIsAbleToDeleteComments() throws Exception { restClient.authenticateUser(adminUserModel); commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment"); @@ -55,7 +55,7 @@ public class DeleteCommentTests extends RestTest @TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify User gets status code 401 if authentication call fails") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void userIsNotAbleToDeleteCommentIfAuthenticationFails() throws JsonToModelConversionException, Exception + public void userIsNotAbleToDeleteCommentIfAuthenticationFails() throws Exception { restClient.authenticateUser(adminUserModel); commentModel = restClient.withCoreAPI().usingResource(document).addComment("New comment addded by admin"); @@ -68,8 +68,8 @@ public class DeleteCommentTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Manager user deletes own comments and status code is 204") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) - public void managerIsAbleToDeleteComments() throws JsonToModelConversionException, Exception + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void managerIsAbleToDeleteComments() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); commentModel = restClient.withCoreAPI().usingResource(document).addComment("New comment added by Manager"); @@ -79,8 +79,8 @@ public class DeleteCommentTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user deletes own comments and status code is 204") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) - public void collaboratorIsAbleToDeleteComments() throws JsonToModelConversionException, Exception + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void collaboratorIsAbleToDeleteComments() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); commentModel = restClient.withCoreAPI().usingResource(document).addComment("New comment added by Collaborator"); @@ -90,8 +90,8 @@ public class DeleteCommentTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Contributor user deletes own comments and status code is 204") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) - public void contributorIsAbleToDeleteComments() throws JsonToModelConversionException, Exception + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void contributorIsAbleToDeleteComments() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); commentModel = restClient.withCoreAPI().usingResource(document).addComment("New comment added by Contributor"); @@ -101,8 +101,8 @@ public class DeleteCommentTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Consumer user can't delete comments created by admin user and status code is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) - public void consumerIsNotAbleToDeleteComments() throws JsonToModelConversionException, Exception + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void consumerIsNotAbleToDeleteComments() throws Exception { restClient.authenticateUser(adminUserModel); commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment"); @@ -114,8 +114,8 @@ public class DeleteCommentTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Admin user can't delete comments with inexistent ID and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) - public void userIsNotAbleToDeleteInexistentComment() throws JsonToModelConversionException, Exception + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void userIsNotAbleToDeleteInexistentComment() throws Exception { restClient.authenticateUser(adminUserModel); commentModel = new RestCommentModel(); @@ -126,8 +126,8 @@ public class DeleteCommentTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Admin user can't delete comments with inexistend NodeId and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) - public void userIsNotAbleToDeleteCommentWithInexistentNodeId() throws JsonToModelConversionException, Exception + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void userIsNotAbleToDeleteCommentWithInexistentNodeId() throws Exception { restClient.authenticateUser(adminUserModel); commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment"); @@ -139,8 +139,8 @@ public class DeleteCommentTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Admin user can't delete deleted comments and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) - public void userIsNotAbleToDeleteDeletedComment() throws JsonToModelConversionException, Exception + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void userIsNotAbleToDeleteDeletedComment() throws Exception { restClient.authenticateUser(adminUserModel); commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment"); @@ -153,8 +153,8 @@ public class DeleteCommentTests extends RestTest @TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Manager user deletes comment created by admin" + " and status code is 204. Check with getComments for validation") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void managerIsAbleToDeleteCommentCreatedByOthers() throws JsonToModelConversionException, Exception + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void managerIsAbleToDeleteCommentCreatedByOthers() throws Exception { FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); @@ -174,8 +174,8 @@ public class DeleteCommentTests extends RestTest @TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user can delete comment created by self" + " and status code is 204. Check with getComments for validation") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void collaboratorIsAbleToDeleteCommentCreatedBySelf() throws JsonToModelConversionException, Exception + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void collaboratorIsAbleToDeleteCommentCreatedBySelf() throws Exception { FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); @@ -194,9 +194,9 @@ public class DeleteCommentTests extends RestTest @TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Contributor user deletes comment created by self" + " and status code is 204. Check with getComments for validation") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) @Bug(id = "ACE-4614") - public void contributorIsAbleToDeleteCommentCreatedBySelf() throws JsonToModelConversionException, Exception + public void contributorIsAbleToDeleteCommentCreatedBySelf() throws Exception { FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); @@ -215,8 +215,8 @@ public class DeleteCommentTests extends RestTest @TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Consumer user cannot delete comment created by admin" + " and status code is 403. Check with getComments for validation and check default error model schema.") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void consumerIsNotAbleToDeleteCommentCreatedByOthersDefaultErrorModelSchema() throws JsonToModelConversionException, Exception + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void consumerIsNotAbleToDeleteCommentCreatedByOthersDefaultErrorModelSchema() throws Exception { FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); @@ -238,8 +238,8 @@ public class DeleteCommentTests extends RestTest @TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Manager can delete comment with version number") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void usingManagerDeleteCommentWithVersionNumber() throws JsonToModelConversionException, Exception + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void usingManagerDeleteCommentWithVersionNumber() throws Exception { FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); dataContent.usingAdmin().usingResource(file).updateContent("updated content to increase version number"); @@ -253,8 +253,8 @@ public class DeleteCommentTests extends RestTest @TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Manager user cannot delete comment with invalid node " + "and status code is 404. Check with getComments for validation") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void usingManagerDeleteCommentWithInvalidNode() throws JsonToModelConversionException, Exception + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void usingManagerDeleteCommentWithInvalidNode() throws Exception { FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); @@ -270,7 +270,7 @@ public class DeleteCommentTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS}, executionType = ExecutionType.REGRESSION, description = "Verify deleteComment from node with invalid network id returns status code 401") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) public void deleteCommentWithInvalidNetworkId() throws Exception { FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); @@ -283,8 +283,8 @@ public class DeleteCommentTests extends RestTest @TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify deleteComment from node with empty network id returns status code 401") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void deleteCommentWithEmptyNetworkId() throws JsonToModelConversionException, Exception + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void deleteCommentWithEmptyNetworkId() throws Exception { FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); diff --git a/e2e-test/java/org/alfresco/rest/comments/GetCommentsTests.java b/e2e-test/java/org/alfresco/rest/comments/GetCommentsTests.java index d8fe7d9d0..0420ca6bf 100644 --- a/e2e-test/java/org/alfresco/rest/comments/GetCommentsTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/GetCommentsTests.java @@ -1,9 +1,7 @@ package org.alfresco.rest.comments; -import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestCommentModelsCollection; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.constants.UserRole; @@ -55,7 +53,7 @@ public class GetCommentsTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.SANITY, description= "Verify Admin user gets comments with Rest API and status code is 200") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) - public void adminIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception + public void adminIsAbleToRetrieveComments() throws Exception { comments = restClient.authenticateUser(adminUserModel).withCoreAPI() .usingResource(document1).getNodeComments(); @@ -67,7 +65,7 @@ public class GetCommentsTests extends RestTest description= "Verify Manager user gets status code 401 if authentication call fails") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void managerIsNotAbleToRetrieveCommentIfAuthenticationFails() throws JsonToModelConversionException, Exception + public void managerIsNotAbleToRetrieveCommentIfAuthenticationFails() throws Exception { UserModel nonexistentModel = new UserModel("nonexistentUser", "nonexistentPassword"); restClient.authenticateUser(nonexistentModel).withCoreAPI() @@ -78,8 +76,8 @@ public class GetCommentsTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Verify Manager user gets comments created by admin user with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) - public void managerIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void managerIsAbleToRetrieveComments() throws Exception { comments = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI() .usingResource(document1).getNodeComments(); @@ -89,8 +87,8 @@ public class GetCommentsTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Verify Contributor user gets comments created by admin user with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) - public void contributorIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void contributorIsAbleToRetrieveComments() throws Exception { comments = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI() .usingResource(document1).getNodeComments(); @@ -100,8 +98,8 @@ public class GetCommentsTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Verify Collaborator user gets comments created by admin user with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) - public void collaboratorIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void collaboratorIsAbleToRetrieveComments() throws Exception { comments = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI() .usingResource(document1).getNodeComments(); @@ -111,8 +109,8 @@ public class GetCommentsTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Verify Consumer user gets comments created by admin user with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) - public void consumerIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void consumerIsAbleToRetrieveComments() throws Exception { comments = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI() .usingResource(document1).getNodeComments(); @@ -123,8 +121,8 @@ public class GetCommentsTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Verify Manager user gets comments created by another user and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) - public void managerIsAbleToRetrieveCommentsCreatedByAnotherUser() throws JsonToModelConversionException, Exception + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void managerIsAbleToRetrieveCommentsCreatedByAnotherUser() throws Exception { userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); String contentManager = "This is a new comment added by " + userModel.getUsername(); @@ -140,8 +138,8 @@ public class GetCommentsTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Verify admin user gets comments created by another user and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) - public void adminIsAbleToRetrieveCommentsCreatedByAnotherUser() throws JsonToModelConversionException, Exception + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void adminIsAbleToRetrieveCommentsCreatedByAnotherUser() throws Exception { userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); String contentCollaborator = "This is a new comment added by " + userModel.getUsername(); @@ -157,7 +155,7 @@ public class GetCommentsTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Verify request returns status 403 if the user does not have permission read comments on the node") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) public void uninvitedUserCanNotGetCommentsFromPrivateSite() throws Exception { restClient.authenticateUser(userModel).withCoreAPI() @@ -168,7 +166,7 @@ public class GetCommentsTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Verify user gets comments without the first 2 and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) public void skipFirst2Comments() throws Exception { comments = restClient.authenticateUser(adminUserModel).withParams("skipCount=2") @@ -182,7 +180,7 @@ public class GetCommentsTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Verify invalid request returns status code 400 for invalid maxItems or skipCount") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) public void checkStatusCodeForInvalidMaxItems() throws Exception { restClient.authenticateUser(adminUserModel).withParams("maxItems=0") @@ -193,7 +191,7 @@ public class GetCommentsTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Verify User can't get comments for node with ID that does not exist and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) public void userCanNotGetCommentsOnNonExistentFile() throws Exception { FileModel nonexistentFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); @@ -206,7 +204,7 @@ public class GetCommentsTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Verify User can't get comments for node that exists but is not a document or a folder and status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) public void userCanNotGetCommentsOnLink() throws Exception { LinkModel link = dataLink.usingAdmin().usingSite(siteModel).createRandomLink(); @@ -224,7 +222,7 @@ public class GetCommentsTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Verify get comments from node with invalid network id returns status code 401") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) public void getCommentsWithInvalidNetwork() throws Exception { networkUserModel.setDomain("invalidNetwork"); @@ -234,7 +232,7 @@ public class GetCommentsTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Verify get comments from node with empty network id returns status code 401") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) public void getCommentsWithEmptyNetwork() throws Exception { networkUserModel.setDomain(""); @@ -244,7 +242,7 @@ public class GetCommentsTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Verify that if manager adds one comment, it will be returned in getComments response") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) public void addCommentWithManagerAndCheckThatCommentIsReturned() throws Exception { file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); @@ -260,7 +258,7 @@ public class GetCommentsTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Verify that if collaborator adds one comment, it will be returned in getComments response") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) public void addCommentWithCollaboratorAndCheckThatCommentIsReturned() throws Exception { file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); @@ -277,7 +275,7 @@ public class GetCommentsTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Verify that if contributor adds one comment, it will be returned in getComments response") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) @Bug(id = "ACE-4614") public void addCommentWithContributorAndCheckThatCommentIsReturned() throws Exception { @@ -295,7 +293,7 @@ public class GetCommentsTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Verify that consumer cannot add a comment and no comments will be returned in getComments response") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) public void addCommentWithConsumerAndCheckThatCommentIsNotReturned() throws Exception { file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); @@ -311,7 +309,7 @@ public class GetCommentsTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Add one comment with Manager and check that returned person is the right one") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) public void addCommentWithManagerCheckReturnedPersonIsTheRightOne() throws Exception { file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); @@ -326,7 +324,7 @@ public class GetCommentsTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Add one comment with Collaborator and check that returned company details are correct") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) public void addCommentWithCollaboratorCheckReturnedCompanyDetails() throws Exception { file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); @@ -347,7 +345,7 @@ public class GetCommentsTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Add 2 comments with Manager and Collaborator users and verify valid request using skipCount. Check that param is applied") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) public void addTwoCommentsWithManagerCollaboratorVerifySkipCountParamIsApplied() throws Exception { file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); @@ -365,7 +363,7 @@ public class GetCommentsTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Add 2 comments with Admin and Collaborator users and verify valid request using maxItems. Check that param is applied") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) public void addTwoCommentsWithAdminCollaboratorVerifyMaxItemsParamIsApplied() throws Exception { file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); @@ -382,7 +380,7 @@ public class GetCommentsTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Add 2 comments with Manager and Admin users and verify valid request using properties. Check that param is applied") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) public void addTwoCommentsWithAdminManagerVerifyPropertiesParamIsApplied() throws Exception { file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); @@ -406,7 +404,7 @@ public class GetCommentsTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Check default error model schema") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) public void addTwoCommentsWithManagerCheckDefaultErrorModelSchema() throws Exception { file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); diff --git a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentTests.java b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentTests.java index 07d4d11e6..9a669351c 100644 --- a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentTests.java @@ -49,7 +49,7 @@ public class UpdateCommentTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Admin user updates comments and status code is 200") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) - public void adminIsAbleToUpdateHisComment() throws JsonToModelConversionException, Exception + public void adminIsAbleToUpdateHisComment() throws Exception { restClient.authenticateUser(adminUserModel); commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by admin"); @@ -63,7 +63,7 @@ public class UpdateCommentTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user gets status code 401 on update comment call") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) @Bug(id = "MNT-16904", description = "fails only on environment with tenants") - public void unauthenticatedUserIsNotAbleToUpdateComment() throws JsonToModelConversionException, Exception + public void unauthenticatedUserIsNotAbleToUpdateComment() throws Exception { restClient.authenticateUser(adminUserModel); commentModel = restClient.withCoreAPI().usingResource(document).addComment("To be updated by unauthenticated user."); @@ -76,7 +76,7 @@ public class UpdateCommentTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify entry content in response") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) - public void checkEntryContentInResponse() throws JsonToModelConversionException, Exception + public void checkEntryContentInResponse() throws Exception { restClient.authenticateUser(adminUserModel); commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by admin"); @@ -86,8 +86,8 @@ public class UpdateCommentTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Manager user updates comments created by admin user and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) - public void managerIsAbleToUpdateHisComment() throws JsonToModelConversionException, Exception + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void managerIsAbleToUpdateHisComment() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by manager"); @@ -99,8 +99,8 @@ public class UpdateCommentTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Contributor user can update his own comment and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) - public void contributorIsAbleToUpdateHisComment() throws JsonToModelConversionException, Exception + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void contributorIsAbleToUpdateHisComment() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by contributor"); @@ -110,8 +110,8 @@ public class UpdateCommentTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Consumer user can not update comments created by admin user and status code is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) - public void consumerIsNotAbleToUpdateComment() throws JsonToModelConversionException, Exception + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void consumerIsNotAbleToUpdateComment() throws Exception { restClient.authenticateUser(adminUserModel); commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by admin"); @@ -123,8 +123,8 @@ public class UpdateCommentTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user can update his own comment and status code is 200") // @Bug(id="REPO-1011") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) - public void collaboratorIsAbleToUpdateHisComment() throws JsonToModelConversionException, Exception + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void collaboratorIsAbleToUpdateHisComment() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by collaborator"); @@ -134,8 +134,8 @@ public class UpdateCommentTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user can not update comments of another user and status code is 200") // @Bug(id="MNT-2502",description="seems it's one old issue: also logged as MNT-2502, MNT-2346") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) - public void collaboratorIsNotAbleToUpdateCommentOfAnotherUser() throws JsonToModelConversionException, Exception + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void collaboratorIsNotAbleToUpdateCommentOfAnotherUser() throws Exception { restClient.authenticateUser(adminUserModel); commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by admin"); @@ -145,8 +145,8 @@ public class UpdateCommentTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify update comment with inexistent nodeId returns status code 404") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void canNotUpdateCommentIfNodeIdIsNotSet() throws JsonToModelConversionException, Exception + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void canNotUpdateCommentIfNodeIdIsNotSet() throws Exception { restClient.authenticateUser(adminUserModel); @@ -159,8 +159,8 @@ public class UpdateCommentTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify if commentId is not set the status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void canNotUpdateCommentIfCommentIdIsNotSet() throws JsonToModelConversionException, Exception + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void canNotUpdateCommentIfCommentIdIsNotSet() throws Exception { restClient.authenticateUser(adminUserModel); @@ -173,8 +173,8 @@ public class UpdateCommentTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify can not update comment if NodeId is neither document or folder and returns status code 405") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void canNotUpdateCommentIfNodeIdIsNeitherDocumentOrFolder() throws JsonToModelConversionException, Exception + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void canNotUpdateCommentIfNodeIdIsNeitherDocumentOrFolder() throws Exception { FileModel content = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); content = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); @@ -195,8 +195,8 @@ public class UpdateCommentTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Admin user is not able to update with empty comment body and status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void adminIsNotAbleToUpdateWithEmptyCommentBody() throws JsonToModelConversionException, Exception + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void adminIsNotAbleToUpdateWithEmptyCommentBody() throws Exception { restClient.authenticateUser(adminUserModel); commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by admin"); @@ -207,8 +207,8 @@ public class UpdateCommentTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify updated comment by Manager is listed when calling getComments and status code is 200") // @Bug(id="REPO-1011") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void updatedCommentByManagerIsListed() throws JsonToModelConversionException, Exception + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void updatedCommentByManagerIsListed() throws Exception { commentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) .withCoreAPI().usingResource(document).addComment("This is a new comment added by collaborator"); @@ -221,8 +221,8 @@ public class UpdateCommentTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Verify Manager user can update a comment with a large string") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void managerIsAbleToUpdateACommentWithALargeString() throws JsonToModelConversionException, Exception + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void managerIsAbleToUpdateACommentWithALargeString() throws Exception { FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); String longString = RandomStringUtils.randomAlphanumeric(10000); @@ -239,8 +239,8 @@ public class UpdateCommentTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Verify Manager user can update a comment with a short string") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void managerIsAbleToUpdateACommentWithAShortString() throws JsonToModelConversionException, Exception + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void managerIsAbleToUpdateACommentWithAShortString() throws Exception { FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); String shortString = RandomStringUtils.randomAlphanumeric(2); @@ -257,8 +257,8 @@ public class UpdateCommentTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Verify Collaborator user can update a comment with special characters") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void collaboratorIsAbleToUpdateACommentThatContainsSpecialChars() throws JsonToModelConversionException, Exception + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void collaboratorIsAbleToUpdateACommentThatContainsSpecialChars() throws Exception { FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); String specialChars = "!@#$%^&*()'\".,<>-_+=|\\"; @@ -275,8 +275,8 @@ public class UpdateCommentTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Check that you cannot update comment with Consumer then call getComments and check new comment is not listed") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void cannotUpdateCommentWithConsumerCallGetComments() throws JsonToModelConversionException, Exception + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void cannotUpdateCommentWithConsumerCallGetComments() throws Exception { FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); @@ -296,9 +296,9 @@ public class UpdateCommentTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Update comment with Contributor then call getComments and check new comment is listed") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) @Bug(id = "ACE-4614") - public void updateCommentWithContributorCallGetComments() throws JsonToModelConversionException, Exception + public void updateCommentWithContributorCallGetComments() throws Exception { FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); @@ -318,8 +318,8 @@ public class UpdateCommentTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Update comment with Collaborator then call getComments and check new comment is listed") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void updateCommentWithCollaboratorCallGetComments() throws JsonToModelConversionException, Exception + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void updateCommentWithCollaboratorCallGetComments() throws Exception { FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); @@ -339,8 +339,8 @@ public class UpdateCommentTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Update comment with Manager then check modified by information in response") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void updateCommentWithManagerCheckModifiedBy() throws JsonToModelConversionException, Exception + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void updateCommentWithManagerCheckModifiedBy() throws Exception { FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); UserModel manager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); @@ -357,8 +357,8 @@ public class UpdateCommentTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Delete comment with Admin then try to update it") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void deleteCommentThenTryToUpdateIt() throws JsonToModelConversionException, Exception + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void deleteCommentThenTryToUpdateIt() throws Exception { FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); @@ -375,8 +375,8 @@ public class UpdateCommentTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Verify Manager user can update a comment with multi byte content") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void managerIsAbleToUpdateACommentWithMultiByteContent() throws JsonToModelConversionException, Exception + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void managerIsAbleToUpdateACommentWithMultiByteContent() throws Exception { FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); String multiByte = "\ufeff\u6768\u6728\u91d1"; @@ -393,8 +393,8 @@ public class UpdateCommentTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Verify Admin user can update a comment with properties parameter") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void adminIsAbleToUpdateACommentWithPropertiesParameter() throws JsonToModelConversionException, Exception + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void adminIsAbleToUpdateACommentWithPropertiesParameter() throws Exception { FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); @@ -413,8 +413,8 @@ public class UpdateCommentTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Update comment with invalid node") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) - public void updateCommentUsingInvalidNodeId() throws JsonToModelConversionException, Exception + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void updateCommentUsingInvalidNodeId() throws Exception { FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); @@ -429,7 +429,7 @@ public class UpdateCommentTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, description= "Verify update comment from node with invalid network id returns status code 401") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) public void updateCommentWithInvalidNetworkId() throws Exception { FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); @@ -442,7 +442,7 @@ public class UpdateCommentTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify User can not update comment to a not joined private site. Status code returned is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) public void userCanNotUpdateCommentToANotJoinedPrivateSiteDefaultErrorModelSchema() throws Exception { UserModel newUser = dataUser.createRandomTestUser(); From 9d1c12a7f11f3ebfb397c35f477e9c9da944743b Mon Sep 17 00:00:00 2001 From: cagache Date: Fri, 6 Oct 2017 11:59:47 +0300 Subject: [PATCH 1227/1491] REPO-2755 / REPO-2251: changed CORE and FULL groups with REGRESSION in favorites package --- .../rest/favorites/AddFavoriteSiteTests.java | 58 +- .../rest/favorites/AddFavoritesTests.java | 590 ++++++++---------- .../favorites/DeleteFavoriteCoreTests.java | 171 ----- .../favorites/DeleteFavoriteFullTests.java | 246 -------- .../favorites/DeleteFavoriteSanityTests.java | 172 ----- .../DeleteFavoriteSiteCoreTests.java | 158 ----- .../DeleteFavoriteSiteFullTests.java | 185 ------ .../DeleteFavoriteSiteSanityTests.java | 174 ------ .../favorites/DeleteFavoriteSiteTests.java | 432 +++++++++++++ .../rest/favorites/DeleteFavoriteTests.java | 477 ++++++++++++++ ...ts.java => FavoritesIncludePathTests.java} | 19 +- .../rest/favorites/GetFavoriteCoreTests.java | 130 ---- .../rest/favorites/GetFavoriteFullTests.java | 207 ------ .../favorites/GetFavoriteSanityTests.java | 293 --------- .../favorites/GetFavoriteSiteCoreTests.java | 62 -- .../favorites/GetFavoriteSiteFullTests.java | 177 ------ .../favorites/GetFavoriteSiteSanityTests.java | 137 ---- .../rest/favorites/GetFavoriteSiteTests.java | 302 +++++++++ .../favorites/GetFavoriteSitesCoreTests.java | 131 ---- .../favorites/GetFavoriteSitesFullTests.java | 159 ----- .../GetFavoriteSitesSanityTests.java | 123 ---- .../rest/favorites/GetFavoriteSitesTests.java | 344 ++++++++++ .../rest/favorites/GetFavoriteTests.java | 518 +++++++++++++++ .../rest/favorites/GetFavoritesCoreTests.java | 254 -------- .../rest/favorites/GetFavoritesFullTests.java | 230 ------- .../favorites/GetFavoritesSanityTests.java | 197 ------ .../rest/favorites/GetFavoritesTests.java | 588 +++++++++++++++++ 27 files changed, 2969 insertions(+), 3565 deletions(-) delete mode 100644 e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteCoreTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteFullTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteSanityTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteSiteCoreTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteSiteFullTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteSiteSanityTests.java create mode 100644 e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteSiteTests.java create mode 100644 e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteTests.java rename e2e-test/java/org/alfresco/rest/favorites/{FavoritesIncludePathSanityTests.java => FavoritesIncludePathTests.java} (95%) delete mode 100644 e2e-test/java/org/alfresco/rest/favorites/GetFavoriteCoreTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/favorites/GetFavoriteFullTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSiteCoreTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSiteFullTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSiteSanityTests.java create mode 100644 e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSiteTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSitesCoreTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSitesFullTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSitesSanityTests.java create mode 100644 e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSitesTests.java create mode 100644 e2e-test/java/org/alfresco/rest/favorites/GetFavoriteTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/favorites/GetFavoritesCoreTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/favorites/GetFavoritesFullTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java create mode 100644 e2e-test/java/org/alfresco/rest/favorites/GetFavoritesTests.java diff --git a/e2e-test/java/org/alfresco/rest/favorites/AddFavoriteSiteTests.java b/e2e-test/java/org/alfresco/rest/favorites/AddFavoriteSiteTests.java index 51f4d7525..f2266a93b 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/AddFavoriteSiteTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/AddFavoriteSiteTests.java @@ -67,7 +67,7 @@ public class AddFavoriteSiteTests extends RestTest .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify collaborator user add a favorite site with Rest API and response is successful (201)") public void collaboratorUserAddFavoriteSiteWithSuccess() throws Exception { @@ -79,7 +79,7 @@ public class AddFavoriteSiteTests extends RestTest restFavoriteSiteModel.assertThat().field("id").is(publicSite.getId()); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify contributor user add a favorite site with Rest API and response is successful (201)") public void contributorUserAddFavoriteSiteWithSuccess() throws Exception { @@ -91,7 +91,7 @@ public class AddFavoriteSiteTests extends RestTest restFavoriteSiteModel.assertThat().field("id").is(publicSite.getId()); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify consumer user add a favorite site with Rest API and response is successful (201)") public void consumerUserAddFavoriteSiteWithSuccess() throws Exception { @@ -103,7 +103,7 @@ public class AddFavoriteSiteTests extends RestTest restFavoriteSiteModel.assertThat().field("id").is(publicSite.getId()); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin user add a favorite site with Rest API and response is successful (201)") public void adminUserAddFavoriteSiteWithSuccess() throws Exception { @@ -112,7 +112,7 @@ public class AddFavoriteSiteTests extends RestTest restFavoriteSiteModel.assertThat().field("id").is(publicSite.getId()); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify manager user is not able to add a favorite site when the site is already favorite - status code (409)") public void managerUserAddFavoriteSiteAlreadyAFavoriteSite() throws Exception @@ -133,7 +133,7 @@ public class AddFavoriteSiteTests extends RestTest .containsErrorKey(String.format("Site %s is already a favourite site", publicSite.getId())); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user doesn't have permission to delete favorites of admin user with Rest API and status code is 403") public void userIsNotAbleToAddFavoriteSiteOfAnotherUser() throws Exception @@ -151,7 +151,7 @@ public class AddFavoriteSiteTests extends RestTest .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify manager user is able to add as favorite a private site.") public void managerAddsPrivateSiteAsFavorite() throws Exception @@ -173,7 +173,7 @@ public class AddFavoriteSiteTests extends RestTest .and().field("title").is(privateSite.getTitle()); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify manager user is able to add as favorite a moderated site.") public void managerAddsModeratedSiteAsFavorite() throws Exception @@ -195,7 +195,7 @@ public class AddFavoriteSiteTests extends RestTest .and().field("title").is(moderatedSite.getTitle()); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user removes a site from favorites using '-me-' in place of personId with Rest API and response is successful (201)") public void addFavoriteSiteWithSuccessUsingMeAsPersonId() throws Exception @@ -204,7 +204,7 @@ public class AddFavoriteSiteTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.CREATED); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify manager user removes a site from its favorites and adds it again and response is successful (204)") public void managerUserRemovesFavoriteSiteAndAddItAgain() throws Exception @@ -221,7 +221,7 @@ public class AddFavoriteSiteTests extends RestTest } @Bug(id="ACE-2413") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify empty user is not able to add a site from favorites and response is (400)") public void emptyUserIsNotAbleToRemoveFavoriteSite() throws Exception @@ -233,7 +233,7 @@ public class AddFavoriteSiteTests extends RestTest .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "emptyUser")); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify inexistent user is not able to add a site from favorites and response is (404)") public void inexistentUserIsNotAbleToRemoveFavoriteSite() throws Exception @@ -250,7 +250,7 @@ public class AddFavoriteSiteTests extends RestTest } @Bug(id="REPO-1827") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to add a favorite site when the 'id' is empty - status code (400)") public void userAddFavoriteSiteWithEmptySiteId() throws Exception @@ -266,7 +266,7 @@ public class AddFavoriteSiteTests extends RestTest .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin user doesn't have permission to add a favorite site of another user with Rest API and status code is 403") public void adminIsNotAbleToAddFavoriteSiteOfAnotherUser() throws Exception @@ -282,7 +282,7 @@ public class AddFavoriteSiteTests extends RestTest } @Bug(id="MNT-17338") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin user doesn't have permission to add a favorite site of another user with Rest API and status code is 403") public void userIsNotAbleToAddFavoriteSiteOfAdmin() throws Exception @@ -297,7 +297,7 @@ public class AddFavoriteSiteTests extends RestTest .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify add favorite site using empty body - status code is 400") public void addFavoriteSiteWithEmptyBody() throws Exception @@ -312,7 +312,7 @@ public class AddFavoriteSiteTests extends RestTest .containsSummary(String.format(RestErrorModel.NO_CONTENT, "Unrecognized field " + "\"ids\"")); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify add favorite site using empty body - status code is 400") public void addFavoriteSiteWithEmptyRequiredFieldsBody() throws Exception @@ -327,7 +327,7 @@ public class AddFavoriteSiteTests extends RestTest .containsSummary(String.format(RestErrorModel.NO_CONTENT, "Unrecognized field " + "\"\"")); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify non member user is not able to add a private favorite site - status code is 404") public void userAddFavoriteSiteUserNotMemberOfPrivateSite() throws Exception @@ -344,7 +344,7 @@ public class AddFavoriteSiteTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify non member user is able to add a moderated favorite site") public void userAddFavoriteSiteUserNotMemberOfModeratedSite() throws Exception @@ -364,7 +364,7 @@ public class AddFavoriteSiteTests extends RestTest .and().field("title").is(moderatedSite.getTitle()); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify non member user is able to add a public favorite site") public void userAddFavoriteSiteUserNotMemberOfPublicSite() throws Exception @@ -385,7 +385,7 @@ public class AddFavoriteSiteTests extends RestTest .and().field("title").is(publicSite.getTitle()); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Check that if id does not exist, status code is 404") public void addFavoriteSiteUsingInvalidId() throws Exception @@ -401,7 +401,7 @@ public class AddFavoriteSiteTests extends RestTest publicSite.setId(id); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Check that if user provides site in id but id is of a file status code is 404") public void addSiteToFavoritesUsingFileId() throws Exception @@ -415,7 +415,7 @@ public class AddFavoriteSiteTests extends RestTest publicSite.setId(id); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Check that if user provides site in id but id is of a folder status code is 404") public void addSiteToFavoritesUsingFolderId() throws Exception @@ -430,7 +430,7 @@ public class AddFavoriteSiteTests extends RestTest publicSite.setId(id); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Check that if user provides site in id but id is of a comment status code is 404") public void addSiteToFavoriteUsingCommentId() throws Exception @@ -447,7 +447,7 @@ public class AddFavoriteSiteTests extends RestTest publicSite.setId(id); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Check that if user provides site in id but id is of a tag status code is 404") public void addSiteFavoriteUsingTagId() throws Exception @@ -462,7 +462,7 @@ public class AddFavoriteSiteTests extends RestTest .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, returnedModel.getId())); } - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION}) @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Check that if id does not describe a site, file, or folder status code is 400") public void addFavoriteUsingInvalidGuid() throws Exception @@ -477,7 +477,7 @@ public class AddFavoriteSiteTests extends RestTest } @Bug(id="MNT-16904") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.NETWORKS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.NETWORKS, TestGroup.REGRESSION}) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, description = "Verify tenant user is not able to delete favorites using an invalid network ID - status code (401)") public void tenantIsNotAbleToDeleteFavoriteSiteWithInvalidNetworkID() throws Exception @@ -499,7 +499,7 @@ public class AddFavoriteSiteTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.NETWORKS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.NETWORKS, TestGroup.REGRESSION}) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE}, executionType = ExecutionType.REGRESSION, description = "Verify tenant user is able to add to favorites his site and status code is (201)") public void tenantAddFavoriteSiteValidNetwork() throws Exception @@ -521,7 +521,7 @@ public class AddFavoriteSiteTests extends RestTest .entriesListContains("targetGuid", publicSite.getGuidWithoutVersion()); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.NETWORKS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.NETWORKS, TestGroup.REGRESSION}) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE}, executionType = ExecutionType.REGRESSION, description = "Verify tenant user is able to add to favorites a site created by admin tenant - same network and status code is (201)") public void tenantUserIsAbleToAddFavoriteSiteAddedByAdminSameNetwork() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesTests.java b/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesTests.java index 11e09299a..0b42e72c4 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesTests.java @@ -37,18 +37,6 @@ public class AddFavoritesTests extends RestTest folder = dataContent.usingSite(siteModel).usingUser(adminUserModel).createFolder(); } - @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, - executionType = ExecutionType.SANITY, - description = "Verify Manager user add site to favorites with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - public void managerIsAbleToAddToFavorites() throws Exception - { - restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI() - .usingAuthUser().addSiteToFavorites(siteModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restPersonFavoritesModel.assertThat().field("targetGuid").is(siteModel.getGuid()); - } - // @Bug(id="MNT-16904", description = "It fails only on environment with tenants") @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Verify Manager user gets status code 401 if authentication call fails") @@ -64,7 +52,7 @@ public class AddFavoritesTests extends RestTest @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user add site to favorites with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) public void collaboratorIsAbleToAddToFavorites() throws Exception { restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) @@ -75,7 +63,7 @@ public class AddFavoritesTests extends RestTest @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify Contributor user add site to favorites with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) public void contributorIsAbleToAddToFavorites() throws JsonToModelConversionException, Exception { restPersonFavoritesModel= restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) @@ -86,7 +74,7 @@ public class AddFavoritesTests extends RestTest @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify Consumer user add site to favorites with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) public void consumerIsAbleToAddToFavorites() throws Exception { restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) @@ -97,7 +85,7 @@ public class AddFavoritesTests extends RestTest @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify Admin user add site to favorites with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) public void adminIsAbleToAddToFavorites() throws Exception { restPersonFavoritesModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); @@ -108,7 +96,7 @@ public class AddFavoritesTests extends RestTest @Bug(id = "MNT-17157") @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Check that if a favorite already exists with the specified id status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) public void addFavoriteTwice() throws Exception { SiteModel site = dataSite.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).createPublicRandomSite(); @@ -118,304 +106,43 @@ public class AddFavoritesTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.CONFLICT); } - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Add to favorites a file for a Manager, check it was added") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) public void managerIsAbleToAddFileToFavorites() throws Exception { restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) .withCoreAPI().usingAuthUser().addFileToFavorites(document); restClient.assertStatusCodeIs(HttpStatus.CREATED); restPersonFavoritesModel.assertThat().field("targetGuid").is(document.getNodeRefWithoutVersion()); + + RestFileModel restFileModel = restPersonFavoritesModel.getTarget().getFile(); + restFileModel.assertThat().field("mimeType").is("text/plain").and() + .field("isFile").is("true").and() + .field("isFolder").is("false").and() + .field("createdBy").is(adminUserModel.getUsername()); } - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Add to favorites a folder for a Manager, check it was added") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) public void managerIsAbleToAddFolderToFavorites() throws Exception { restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) .withCoreAPI().usingAuthUser().addFolderToFavorites(folder); restClient.assertStatusCodeIs(HttpStatus.CREATED); restPersonFavoritesModel.assertThat().field("targetGuid").is(folder.getNodeRefWithoutVersion()); + + RestFolderModel restFolderModel = restPersonFavoritesModel.getTarget().getFolder(); + restFolderModel.assertThat().field("isFile").is("false").and() + .field("isFolder").is("true").and() + .field("createdBy").is(adminUserModel.getUsername()); } - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, description = "Add to favorites a site for a Manager, check it was added") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) public void managerIsAbleToAddSiteToFavorites() throws Exception - { - restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restPersonFavoritesModel.assertThat().field("targetGuid").is(siteModel.getGuid()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify add favorite specifying -me- string in place of for request") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) - public void userIsAbleToAddFavoriteWhenUsingMeAsUsername() throws Exception - { - UserModel user = dataUser.createRandomTestUser(); - restPersonFavoritesModel = restClient.authenticateUser(user) - .withCoreAPI().usingMe().addSiteToFavorites(siteModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restPersonFavoritesModel.assertThat().field("targetGuid").is(siteModel.getGuid()); - - restClient.authenticateUser(user).withCoreAPI().usingAuthUser().getFavoriteSites().assertThat().entriesListContains("guid", siteModel.getGuid()); - } - - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Add to favorites a file for a Collaborator, check it was added") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) - public void collaboratorIsAbleToAddFileToFavorites() throws Exception - { - restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingAuthUser().addFileToFavorites(document); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restPersonFavoritesModel.assertThat().field("targetGuid").is(document.getNodeRefWithoutVersion()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Add to favorites a file for a Contributor, check it was added") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) - public void contributorIsAbleToAddFileToFavorites() throws Exception - { - restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) - .withCoreAPI().usingAuthUser().addFileToFavorites(document); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restPersonFavoritesModel.assertThat().field("targetGuid").is(document.getNodeRefWithoutVersion()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Add to favorites a file for a Consumer, check it was added") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) - public void consumerIsAbleToAddFileToFavorites() throws Exception - { - restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .withCoreAPI().usingAuthUser().addFileToFavorites(document); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restPersonFavoritesModel.assertThat().field("targetGuid").is(document.getNodeRefWithoutVersion()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Add to favorites a folder for a Collaborator, check it was added") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) - public void collaboratorIsAbleToAddFolderToFavorites() throws Exception - { - restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).addFolderToFavorites(folder); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restPersonFavoritesModel.assertThat().field("targetGuid").is(folder.getNodeRefWithoutVersion()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Add to favorites a folder for a Contributor, check it was added") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) - public void contributorIsAbleToAddFolderToFavorites() throws Exception - { - restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) - .withCoreAPI().usingAuthUser().addFolderToFavorites(folder); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restPersonFavoritesModel.assertThat().field("targetGuid").is(folder.getNodeRefWithoutVersion()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Add to favorites a folder for a Consumer, check it was added") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) - public void consumerIsAbleToAddFolderToFavorites() throws Exception - { - restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .withCoreAPI().usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).addFolderToFavorites(folder); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restPersonFavoritesModel.assertThat().field("targetGuid").is(folder.getNodeRefWithoutVersion()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Add to favorites a site for a Collaborator, check it was added") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) - public void collaboratorIsAbleToAddSiteToFavorites() throws Exception - { - restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restPersonFavoritesModel.assertThat().field("targetGuid").is(siteModel.getGuid()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Add to favorites a site for a Contributor, check it was added") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) - public void contributorIsAbleToAddSiteToFavorites() throws Exception - { - restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) - .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restPersonFavoritesModel.assertThat().field("targetGuid").is(siteModel.getGuid()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Add to favorites a site for a Consumer, check it was added") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) - public void consumerIsAbleToAddSiteToFavorites() throws Exception - { - restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restPersonFavoritesModel.assertThat().field("targetGuid").is(siteModel.getGuid()); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Check that if target guid does not describe a site, file, or folder status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) - public void addFavoriteUsingInvalidGuid() throws Exception - { - LinkModel link = dataLink.usingAdmin().usingSite(siteModel).createRandomLink(); - SiteModel site = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - site.setGuid(link.getNodeRef()); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteToFavorites(site); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, site.getGuid().split("/")[3])); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Check that if personId does not exist, status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) - public void addFavoriteUsingInexistentUser() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(new UserModel("random_user", "random_password")).addSiteToFavorites(siteModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "random_user")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Check that if target guid does not exist, status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) - public void addFavoriteUsingInexistentGuid() throws Exception - { - SiteModel site = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - site.setGuid("random_guid"); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteToFavorites(site); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "random_guid")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Check that if user provides file in target but guid is of a folder status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) - public void addFileToFavoritesUsingFolderGuid() throws Exception - { - String nodeRef = document.getNodeRef(); - document.setNodeRef(folder.getNodeRef()); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFileToFavorites(document); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, - adminUserModel.getUsername(), folder.getNodeRefWithoutVersion())); - - document.setNodeRef(nodeRef); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify add favorite, perform getFavorites call, check value is updated") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) - public void verifyGetFavoritesAfterFavoritingSite() throws Exception - { - UserModel user = dataUser.createRandomTestUser(); - restPersonFavoritesModel = restClient.authenticateUser(user) - .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(user).withCoreAPI().usingAuthUser().getFavoriteSites() - .assertThat().entriesListContains("guid", siteModel.getGuid()); - } - - // @Bug(id = "MNT-17158", description="Not a bug, If we need to stop comments from being favorited then an improvement/enhancement request should be raised against the platform.") - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify add file favorite with comment id returns status code 201") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) - public void addFileFavoriteUsingCommentId() throws Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - RestCommentModel comment = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment("This is a comment"); - file.setNodeRef(comment.getId()); - - restPersonFavoritesModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFileToFavorites(file); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restPersonFavoritesModel.assertThat().field("targetGuid").is(file.getNodeRef()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify add file favorite with tag id returns status code 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) - public void addFileFavoriteUsingTagId() throws Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - RestTagModel returnedModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addTag("random_tag"); - file.setNodeRef(returnedModel.getId()); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFileToFavorites(file); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, - adminUserModel.getUsername(), returnedModel.getId())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Check that if user provides site in target but id is of a file status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) - public void addSiteToFavoritesUsingFileId() throws Exception - { - String guid = siteModel.getGuid(); - siteModel.setGuid(document.getNodeRefWithoutVersion()); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, document.getNodeRefWithoutVersion())); - - siteModel.setGuid(guid); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Check that if user provides folder in target but guid is of a file status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) - public void addFolderToFavoritesUsingFileGuid() throws Exception - { - String nodeRef = folder.getNodeRef(); - folder.setNodeRef(document.getNodeRef()); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFolderToFavorites(folder); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, document.getNodeRef())); - - folder.setNodeRef(nodeRef); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Check that if user provides file in target but guid is of a site status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) - public void addSiteToFavoritesUsingFolderId() throws Exception - { - SiteModel newSiteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - newSiteModel.setGuid(folder.getNodeRef()); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteToFavorites(newSiteModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, folder.getNodeRef())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Check that if user provides folder in target but guid is of a site status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) - public void addFolderToFavoritesUsingSiteId() throws Exception - { - FolderModel newFolder = dataContent.usingSite(siteModel).usingUser(adminUserModel).createFolder(); - newFolder.setNodeRef(siteModel.getGuid()); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFolderToFavorites(newFolder); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, - adminUserModel.getUsername(), siteModel.getGuid())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify the response of favorite a site call is valid") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) - public void verifyFavoriteASiteResponseIsValid() throws Exception { restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); @@ -431,42 +158,269 @@ public class AddFavoritesTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify the response of favorite a file call is valid") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) - public void verifyFavoriteAFileResponseIsValid() throws Exception + description = "Verify add favorite specifying -me- string in place of for request") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void userIsAbleToAddFavoriteWhenUsingMeAsUsername() throws Exception { - restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingAuthUser().addFileToFavorites(document); + UserModel user = dataUser.createRandomTestUser(); + restPersonFavoritesModel = restClient.authenticateUser(user) + .withCoreAPI().usingMe().addSiteToFavorites(siteModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); - restPersonFavoritesModel.assertThat().field("targetGuid").is(document.getNodeRefWithoutVersion()); + restPersonFavoritesModel.assertThat().field("targetGuid").is(siteModel.getGuid()); - RestFileModel restFileModel = restPersonFavoritesModel.getTarget().getFile(); - restFileModel.assertThat().field("mimeType").is("text/plain").and() - .field("isFile").is("true").and() - .field("isFolder").is("false").and() - .field("createdBy").is(adminUserModel.getUsername()); + restClient.authenticateUser(user).withCoreAPI().usingAuthUser().getFavoriteSites().assertThat().entriesListContains("guid", siteModel.getGuid()); } @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify the response of favorite a folder call is valid") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) - public void verifyFavoriteAFolderResponseIsValid() throws Exception + description = "Add to favorites a file for a Collaborator, check it was added") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void collaboratorIsAbleToAddFileToFavorites() throws Exception { - restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingAuthUser().addFileToFavorites(document); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restPersonFavoritesModel.assertThat().field("targetGuid").is(document.getNodeRefWithoutVersion()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Add to favorites a file for a Contributor, check it was added") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void contributorIsAbleToAddFileToFavorites() throws Exception + { + restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) + .withCoreAPI().usingAuthUser().addFileToFavorites(document); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restPersonFavoritesModel.assertThat().field("targetGuid").is(document.getNodeRefWithoutVersion()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Add to favorites a file for a Consumer, check it was added") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void consumerIsAbleToAddFileToFavorites() throws Exception + { + restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + .withCoreAPI().usingAuthUser().addFileToFavorites(document); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restPersonFavoritesModel.assertThat().field("targetGuid").is(document.getNodeRefWithoutVersion()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Add to favorites a folder for a Collaborator, check it was added") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void collaboratorIsAbleToAddFolderToFavorites() throws Exception + { + restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).addFolderToFavorites(folder); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restPersonFavoritesModel.assertThat().field("targetGuid").is(folder.getNodeRefWithoutVersion()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Add to favorites a folder for a Contributor, check it was added") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void contributorIsAbleToAddFolderToFavorites() throws Exception + { + restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) .withCoreAPI().usingAuthUser().addFolderToFavorites(folder); restClient.assertStatusCodeIs(HttpStatus.CREATED); - restPersonFavoritesModel.assertThat().field("targetGuid").is(folder.getNodeRef()); + restPersonFavoritesModel.assertThat().field("targetGuid").is(folder.getNodeRefWithoutVersion()); + } - RestFolderModel restFolderModel = restPersonFavoritesModel.getTarget().getFolder(); - restFolderModel.assertThat().field("isFile").is("false").and() - .field("isFolder").is("true").and() - .field("createdBy").is(adminUserModel.getUsername()); + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Add to favorites a folder for a Consumer, check it was added") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void consumerIsAbleToAddFolderToFavorites() throws Exception + { + restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + .withCoreAPI().usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).addFolderToFavorites(folder); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restPersonFavoritesModel.assertThat().field("targetGuid").is(folder.getNodeRefWithoutVersion()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Add to favorites a site for a Collaborator, check it was added") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void collaboratorIsAbleToAddSiteToFavorites() throws Exception + { + restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restPersonFavoritesModel.assertThat().field("targetGuid").is(siteModel.getGuid()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Add to favorites a site for a Contributor, check it was added") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void contributorIsAbleToAddSiteToFavorites() throws Exception + { + restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) + .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restPersonFavoritesModel.assertThat().field("targetGuid").is(siteModel.getGuid()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Add to favorites a site for a Consumer, check it was added") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void consumerIsAbleToAddSiteToFavorites() throws Exception + { + restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restPersonFavoritesModel.assertThat().field("targetGuid").is(siteModel.getGuid()); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Check that if target guid does not describe a site, file, or folder status code is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void addFavoriteUsingInvalidGuid() throws Exception + { + LinkModel link = dataLink.usingAdmin().usingSite(siteModel).createRandomLink(); + SiteModel site = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + site.setGuid(link.getNodeRef()); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteToFavorites(site); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, site.getGuid().split("/")[3])); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Check that if personId does not exist, status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void addFavoriteUsingInexistentUser() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(new UserModel("random_user", "random_password")).addSiteToFavorites(siteModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "random_user")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Check that if target guid does not exist, status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void addFavoriteUsingInexistentGuid() throws Exception + { + SiteModel site = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + site.setGuid("random_guid"); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteToFavorites(site); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "random_guid")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Check that if user provides file in target but guid is of a folder status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void addFileToFavoritesUsingFolderGuid() throws Exception + { + String nodeRef = document.getNodeRef(); + document.setNodeRef(folder.getNodeRef()); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFileToFavorites(document); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, + adminUserModel.getUsername(), folder.getNodeRefWithoutVersion())); + + document.setNodeRef(nodeRef); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify add favorite, perform getFavorites call, check value is updated") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void verifyGetFavoritesAfterFavoritingSite() throws Exception + { + UserModel user = dataUser.createRandomTestUser(); + restPersonFavoritesModel = restClient.authenticateUser(user) + .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(user).withCoreAPI().usingAuthUser().getFavoriteSites() + .assertThat().entriesListContains("guid", siteModel.getGuid()); + } + + // @Bug(id = "MNT-17158", description="Not a bug, If we need to stop comments from being favorited then an improvement/enhancement request should be raised against the platform.") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify add file favorite with comment id returns status code 201") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void addFileFavoriteUsingCommentId() throws Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + RestCommentModel comment = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment("This is a comment"); + file.setNodeRef(comment.getId()); + + restPersonFavoritesModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFileToFavorites(file); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restPersonFavoritesModel.assertThat().field("targetGuid").is(file.getNodeRef()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify add file favorite with tag id returns status code 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void addFileFavoriteUsingTagId() throws Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + RestTagModel returnedModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addTag("random_tag"); + file.setNodeRef(returnedModel.getId()); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFileToFavorites(file); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, + adminUserModel.getUsername(), returnedModel.getId())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Check that if user provides site in target but id is of a file status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void addSiteToFavoritesUsingFileId() throws Exception + { + String guid = siteModel.getGuid(); + siteModel.setGuid(document.getNodeRefWithoutVersion()); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, document.getNodeRefWithoutVersion())); + + siteModel.setGuid(guid); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Check that if user provides folder in target but guid is of a file status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void addFolderToFavoritesUsingFileGuid() throws Exception + { + String nodeRef = folder.getNodeRef(); + folder.setNodeRef(document.getNodeRef()); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFolderToFavorites(folder); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, document.getNodeRef())); + + folder.setNodeRef(nodeRef); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Check that if user provides file in target but guid is of a site status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void addSiteToFavoritesUsingFolderId() throws Exception + { + SiteModel newSiteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + newSiteModel.setGuid(folder.getNodeRef()); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteToFavorites(newSiteModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, folder.getNodeRef())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Check that if user provides folder in target but guid is of a site status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void addFolderToFavoritesUsingSiteId() throws Exception + { + FolderModel newFolder = dataContent.usingSite(siteModel).usingUser(adminUserModel).createFolder(); + newFolder.setNodeRef(siteModel.getGuid()); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFolderToFavorites(newFolder); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, + adminUserModel.getUsername(), siteModel.getGuid())); } @Bug(id = "REPO-1061") @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Check that if user does not have permission to favorite a site status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) public void verifyFavoriteASiteIfTheUserDoesNotHavePermission() throws Exception { SiteModel privateSite = dataSite.usingUser(adminUserModel).createPrivateRandomSite(); @@ -481,7 +435,7 @@ public class AddFavoritesTests extends RestTest @Bug(id = "MNT-16904") @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify the post favorites request when network id is invalid for tenant user") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL, TestGroup.NETWORKS}) + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION, TestGroup.NETWORKS}) public void addFavoriteSitesWhenNetworkIdIsInvalid() throws JsonToModelConversionException, Exception { UserModel adminTenantUser = UserModel.getAdminTenantUser(); @@ -497,7 +451,7 @@ public class AddFavoritesTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify the response of favorite a sie with empty body at request") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) public void verifyFavoriteASiteWithEmptyBody() throws Exception { restClient.authenticateUser(adminUserModel).withCoreAPI(); diff --git a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteCoreTests.java b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteCoreTests.java deleted file mode 100644 index 5d30132a1..000000000 --- a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteCoreTests.java +++ /dev/null @@ -1,171 +0,0 @@ -package org.alfresco.rest.favorites; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class DeleteFavoriteCoreTests extends RestTest -{ - private UserModel adminUserModel; - private SiteModel siteModel; - private ListUserWithRoles usersWithRoles; - private FileModel fileModel; - private FolderModel folderModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - siteModel.setGuid(restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(siteModel).getSite().getGuid()); - - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - folderModel = dataContent.usingSite(siteModel).usingUser(adminUserModel).createFolder(); - - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that status code is 404 if PersonID is incorrect - favorite file.") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE}) - public void deleteFavoriteIfPersonIdNotExists() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); - restClient.withCoreAPI().usingAuthUser().addFileToFavorites(fileModel); - - restClient.withCoreAPI().usingUser(new UserModel("inexistent", "inexistent")) - .deleteFileFromFavorites(fileModel).assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "inexistent")); - } - - @Bug(id="ACE-2413") - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that status code is 404 if PersonID is empty - favorite file.") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE}) - public void deleteFavoriteIfPersonIdIsEmpty() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); - restClient.withCoreAPI().usingAuthUser().addFileToFavorites(fileModel); - - restClient.withCoreAPI().usingUser(new UserModel ("", "")) - .deleteFileFromFavorites(fileModel).assertStatusCodeIs(HttpStatus.BAD_REQUEST); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that status code is 404 if FavoriteID is incorrect - favorite file.") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE}) - public void deleteFavoriteFileIfFavoriteIdIsIncorrect() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFileToFavorites(fileModel); - - fileModel.setNodeRef("wrongFavoriteId"); - restClient.withCoreAPI().usingAuthUser() - .deleteFileFromFavorites(fileModel).assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "wrongFavoriteId")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that status code is 404 if FavoriteID is incorrect - favorite file.") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE}) - public void deleteFavoriteFileIfFavoriteIdNotExists() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFileToFavorites(fileModel); - FileModel inexistentDocument = new FileModel(); - inexistentDocument.setNodeRef("inexistent"); - - restClient.withCoreAPI().usingAuthUser() - .deleteFileFromFavorites(inexistentDocument).assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "inexistent")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that status code is 404 if FavoriteID is incorrect - favorite site.") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE}) - public void deleteFavoriteIfFavoriteIdNotExists() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); - siteModel.setGuid("wrongFavoriteId"); - - restClient.withCoreAPI().usingAuthUser() - .deleteSiteFromFavorites(siteModel).assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "wrongFavoriteId")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that status code is 404 if FavoriteID is incorrect - favorite folder.") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE}) - public void deleteFavoriteFolderIfFavoriteIdNotExists() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); - restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(folderModel); - - folderModel.setNodeRef("wrongFavoriteId"); - restClient.withCoreAPI().usingAuthUser() - .deleteFolderFromFavorites(folderModel).assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "wrongFavoriteId")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify user removes a site from favorites using '-me-' in place of personId with Rest API and response is successful (204)") - public void deleteFavoriteSiteWithSuccessUsingMeAsPersonId() throws Exception - { - siteModel.setGuid(restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(siteModel).getSite().getGuid()); - restClient.withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); - - restClient.withCoreAPI().usingMe().deleteSiteFromFavorites(siteModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @Bug(id="ACE-5588") - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify user doesn't have permission to delete favorites of another user with Rest API and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) - public void collaboratorIsNotAbleToDeleteFavoriteOfAnotherUser() throws JsonToModelConversionException, Exception - { - UserModel siteCollaborator = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); - restClient.authenticateUser(siteCollaborator).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI() - .usingAuthUser().deleteSiteFromFavorites(siteModel) - .assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError() - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Bug(id="ACE-5588") - @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify admin user doesn't have permission to delete favorites of another user with Rest API and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) - public void adminIsNotAbleToDeleteFavoriteOfAnotherUser() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - - restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel) - .assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError() - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } -} diff --git a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteFullTests.java b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteFullTests.java deleted file mode 100644 index 7cdcc2710..000000000 --- a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteFullTests.java +++ /dev/null @@ -1,246 +0,0 @@ -package org.alfresco.rest.favorites; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class DeleteFavoriteFullTests extends RestTest -{ - private UserModel adminUserModel, tenantUser, adminTenantUser; - private SiteModel siteModel; - private ListUserWithRoles usersWithRoles; - private FileModel fileModel; - private FolderModel folderModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - siteModel.setGuid(restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(siteModel).getSite().getGuid()); - - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - folderModel = dataContent.usingSite(siteModel).usingUser(adminUserModel).createFolder(); - - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify admin deletes files from favorites with Rest API and status code is (204)") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) - public void adminIsAbleToDeleteFavoriteFile() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFileToFavorites(fileModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.withCoreAPI().usingAuthUser().deleteFileFromFavorites(fileModel).assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingAuthUser().getFavorites() - .assertThat() - .entriesListDoesNotContain("targetGuid", fileModel.getNodeRefWithoutVersion()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify admin deletes folder from favorites with Rest API and status code is (204)") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) - public void adminIsAbleToDeleteFavoriteFolder() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFolderToFavorites(folderModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.withCoreAPI().usingAuthUser().deleteFolderFromFavorites(folderModel) - .assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingAuthUser().getFavorites() - .assertThat() - .entriesListDoesNotContain("targetGuid", fileModel.getNodeRefWithoutVersion()); - } - - @Bug(id="ACE-5588") - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify consumer user doesn't have permission to delete favorites of another user with Rest API and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) - public void consumerIsNotAbleToDeleteFavoriteOfAnotherUser() throws JsonToModelConversionException, Exception - { - UserModel siteConsumer = usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer); - restClient.authenticateUser(siteConsumer).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI() - .usingAuthUser().deleteSiteFromFavorites(siteModel) - .assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError() - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Bug(id="ACE-5588") - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify contributor user doesn't have permission to delete favorites of another user with Rest API and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) - public void contributorIsNotAbleToDeleteFavoriteOfAnotherUser() throws JsonToModelConversionException, Exception - { - UserModel siteContributor = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); - restClient.authenticateUser(siteContributor).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI() - .usingAuthUser().deleteSiteFromFavorites(siteModel) - .assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError() - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Bug(id="ACE-5588") - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify contributor user doesn't have permission to delete favorites of another user with Rest API and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) - public void adminIsNotAbleToDeleteFavoriteOfAnotherUser() throws JsonToModelConversionException, Exception - { - UserModel user = dataUser.createRandomTestUser(); - restClient.authenticateUser(user).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - - restClient.authenticateUser(adminUserModel).withCoreAPI() - .usingAuthUser().deleteSiteFromFavorites(siteModel) - .assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError() - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify admin is not able to deletes files from favorites that were already deleted with Rest API and status code is (404)") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) - public void adminIsNotAbleToDeletesADeletedFavoriteFile() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFileToFavorites(fileModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.withCoreAPI().usingAuthUser().deleteFileFromFavorites(fileModel).assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingAuthUser().getFavorites() - .assertThat() - .entriesListDoesNotContain("targetGuid", fileModel.getNodeRefWithoutVersion()); - - restClient.withCoreAPI().usingAuthUser().deleteFileFromFavorites(fileModel) - .assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, - adminUserModel.getUsername(), fileModel.getNodeRef())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify user can't delete favorites using an invalid network ID.") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) - public void userIsNotAbleToDeleteFavoriteSiteWithInvalidNetworkID() throws Exception - { - UserModel networkUserModel = dataUser.createRandomTestUser(); - restClient.authenticateUser(networkUserModel).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - networkUserModel.setDomain("invalidNetwork"); - - restClient.withCoreAPI() - .usingAuthUser().deleteSiteFromFavorites(siteModel) - .assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) - .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify contributor user doesn't have permission to delete favorites of another user with Rest API and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) - public void adminDeletesFavoriteForNotFavouriteFile() throws JsonToModelConversionException, Exception - { - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser() - .deleteFileFromFavorites(fileModel) - .assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, - adminUserModel.getUsername(), fileModel.getNodeRef())) - .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Bug(id="MNT-16904") - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify tenant user is not able to delete favorites using an invalid network ID") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES,TestGroup.NETWORKS, TestGroup.FULL }) - public void tenantIsNotAbleToDeleteFavoriteSiteWithInvalidNetworkID() throws JsonToModelConversionException, Exception - { - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUserModel).usingTenant().createTenant(adminTenantUser); - tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - siteModel = dataSite.usingUser(tenantUser).createPublicRandomSite(); - siteModel.setGuid(restClient.authenticateUser(tenantUser).withCoreAPI().usingSite(siteModel).getSite().getGuid()); - restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - tenantUser.setDomain("invalidNetwork"); - - restClient.withCoreAPI() - .usingAuthUser().deleteSiteFromFavorites(siteModel) - .assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES}, executionType = ExecutionType.REGRESSION, - description = "Verify tenant user deletes favorites site and status code is (204)") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES,TestGroup.NETWORKS, TestGroup.FULL }) - public void tenantDeleteFavoriteSiteValidNetwork() throws JsonToModelConversionException, Exception - { - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUserModel).usingTenant().createTenant(adminTenantUser); - tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - siteModel = dataSite.usingUser(tenantUser).createPublicRandomSite(); - siteModel.setGuid(restClient.authenticateUser(tenantUser).withCoreAPI().usingSite(siteModel).getSite().getGuid()); - restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - tenantUser.setDomain(tenantUser.getDomain()); - - restClient.withCoreAPI() - .usingAuthUser().deleteSiteFromFavorites(siteModel) - .assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingAuthUser().getFavorites() - .assertThat() - .entriesListDoesNotContain("targetGuid", siteModel.getGuidWithoutVersion()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES}, executionType = ExecutionType.REGRESSION, - description = "Verify tenant user deletes favorites site created by admin tenant - same network and status code is (204)") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES,TestGroup.NETWORKS, TestGroup.FULL }) - public void tenantUserIsAbleToDeleteFavoriteSiteAddedByAdminSameNetwork() throws JsonToModelConversionException, Exception - { - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUserModel).usingTenant().createTenant(adminTenantUser); - tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); - siteModel.setGuid(restClient.authenticateUser(adminTenantUser).withCoreAPI().usingSite(siteModel).getSite().getGuid()); - restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - tenantUser.setDomain(adminTenantUser.getDomain()); - - restClient.withCoreAPI() - .usingAuthUser().deleteSiteFromFavorites(siteModel) - .assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingAuthUser().getFavorites() - .assertThat() - .entriesListDoesNotContain("targetGuid", siteModel.getGuidWithoutVersion()); - } - -} diff --git a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteSanityTests.java deleted file mode 100644 index cc0ed1abf..000000000 --- a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteSanityTests.java +++ /dev/null @@ -1,172 +0,0 @@ -package org.alfresco.rest.favorites; - -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.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class DeleteFavoriteSanityTests extends RestTest -{ - private UserModel adminUserModel; - private SiteModel siteModel; - private ListUserWithRoles usersWithRoles; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - siteModel.setGuid(restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(siteModel).getSite().getGuid()); - - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Verify Admin user deletes site from favorites with Rest API and status code is 204") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - public void adminIsAbleToDeleteFavorites() throws JsonToModelConversionException, Exception - { - restClient.withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); - - restClient.withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel).assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingAuthUser().getFavorites().assertThat().entriesListDoesNotContain("targetGuid", siteModel.getGuid()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Verify Manager user deletes site from favorites with Rest API and status code is 204") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - public void managerIsAbleToDeleteFavorites() throws JsonToModelConversionException, Exception - { - UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); - restClient.authenticateUser(siteManager).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - - restClient.withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel).assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingAuthUser().getFavorites() - .assertThat() - .entriesListDoesNotContain("targetGuid", siteModel.getGuid()) - .and().entriesListDoesNotContain("id", siteModel.getId()) - .and().entriesListDoesNotContain("description", siteModel.getDescription()) - .and().entriesListDoesNotContain("visibility", siteModel.getVisibility().toString()) - .and().entriesListDoesNotContain("title", siteModel.getTitle()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Verify Collaborator user deletes site from favorites with Rest API and status code is 204") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - public void collaboratorIsAbleToDeleteFavorites() throws JsonToModelConversionException, Exception - { - UserModel siteCollaborator = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); - restClient.authenticateUser(siteCollaborator).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - - restClient.withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel).assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingAuthUser().getFavorites() - .assertThat() - .entriesListDoesNotContain("targetGuid", siteModel.getGuid()) - .and().entriesListDoesNotContain("id", siteModel.getId()) - .and().entriesListDoesNotContain("description", siteModel.getDescription()) - .and().entriesListDoesNotContain("visibility", siteModel.getVisibility().toString()) - .and().entriesListDoesNotContain("title", siteModel.getTitle()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Verify Contributor user deletes site from favorites with Rest API and status code is 204") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - public void contributorIsAbleToDeleteFavorites() throws JsonToModelConversionException, Exception - { - UserModel siteContributor = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); - restClient.authenticateUser(siteContributor).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - - restClient.withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel).assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingAuthUser().getFavorites() - .assertThat() - .entriesListDoesNotContain("targetGuid", siteModel.getGuid()) - .and().entriesListDoesNotContain("id", siteModel.getId()) - .and().entriesListDoesNotContain("description", siteModel.getDescription()) - .and().entriesListDoesNotContain("visibility", siteModel.getVisibility().toString()) - .and().entriesListDoesNotContain("title", siteModel.getTitle()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Verify Consumer user delets site from favorites with Rest API and status code is 204") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - public void consumerIsAbleToDeleteFavorites() throws JsonToModelConversionException, Exception - { - UserModel siteConsumer = usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer); - restClient.authenticateUser(siteConsumer).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - - restClient.withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel).assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingAuthUser().getFavorites() - .assertThat() - .entriesListDoesNotContain("targetGuid", siteModel.getGuid()) - .and().entriesListDoesNotContain("id", siteModel.getId()) - .and().entriesListDoesNotContain("description", siteModel.getDescription()) - .and().entriesListDoesNotContain("visibility", siteModel.getVisibility().toString()) - .and().entriesListDoesNotContain("title", siteModel.getTitle()); - } - - @Bug(id="MNT-16557") - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Verify user doesn't have permission to delete favorites of another user with Rest API and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - public void userIsNotAbleToDeleteFavoritesOfAnotherUser() throws JsonToModelConversionException, Exception - { - UserModel siteCollaborator = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); - restClient.authenticateUser(siteCollaborator).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI() - .usingAuthUser().deleteSiteFromFavorites(siteModel) - .assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Bug(id="MNT-16557") - @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Verify user doesn't have permission to delete favorites of admin user with Rest API and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - public void userIsNotAbleToDeleteFavoritesOfAdminUser() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel) - .assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Bug(id="MNT-16557") - @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Verify admin user doesn't have permission to delete favorites of another user with Rest API and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - public void adminIsNotAbleToDeleteFavoritesOfAnotherUser() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - - restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel) - .assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Bug(id = "MNT-16904", description = "It fails only on environment with tenants") - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Verify user gets status code 401 if authentication call fails") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - public void userIsNotAbleToDeleteFavoritesIfAuthenticationFails() throws JsonToModelConversionException, Exception - { - UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); - siteManager.setPassword("wrongPassword"); - restClient.authenticateUser(siteManager).withCoreAPI().usingAuthUser() - .deleteSiteFromFavorites(siteModel).assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } -} diff --git a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteSiteCoreTests.java b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteSiteCoreTests.java deleted file mode 100644 index 9a312bcb5..000000000 --- a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteSiteCoreTests.java +++ /dev/null @@ -1,158 +0,0 @@ -package org.alfresco.rest.favorites; - -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestSiteModel; -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.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class DeleteFavoriteSiteCoreTests extends RestTest -{ - UserModel userModel; - SiteModel siteModel; - UserModel adminUserModel; - RestSiteModel restSiteModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - adminUserModel = dataUser.getAdminUser(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify user removes a site from favorites using '-me-' in place of personId with Rest API and response is successful (204)") - public void removeFavoriteSiteWithSuccessUsingMeAsPersonId() throws Exception - { - restClient.authenticateUser(adminUserModel); - dataSite.usingUser(adminUserModel).usingSite(siteModel).addSiteToFavorites(); - - restClient.withCoreAPI().usingMe().removeFavoriteSite(siteModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) -// @Bug(id = "REPO-1642", description = "reproduced on 5.2.1 only, it works on 5.2.0") - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify inexistent user is not able to remove a site from favorites and response is 404") - public void inexistentUserIsNotAbleToRemoveFavoriteSite() throws Exception - { - UserModel inexistentUser = new UserModel("inexistenUser", "password"); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(inexistentUser) - .removeFavoriteSite(siteModel); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "inexistenUser")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify user is not able to remove from favorites a site with inexistent id and response is 404") - public void userIsNotAbleToRemoveFavoriteSiteWithInexistentId() throws Exception - { - SiteModel inexistentSite = new SiteModel("inexistentSite"); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel) - .removeFavoriteSite(inexistentSite); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, - adminUserModel.getUsername(), inexistentSite.getTitle())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE) - .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify manager user removes a site from its favorites and adds it again and response is successful (204)") - public void managerUserRemovesFavoriteSiteAndAddItAgain() throws Exception - { - UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); - dataSite.usingUser(managerUser).usingSite(siteModel).addSiteToFavorites(); - - restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser() - .removeFavoriteSite(siteModel); - - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingUser(managerUser).addFavoriteSite(siteModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify manager user removes a site from its favorite sites list with Rest API and response is successful (204)") - public void managerUserRemovesFavoriteSiteWithSuccess() throws Exception - { - UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); - dataSite.usingUser(managerUser).usingSite(siteModel).addSiteToFavorites(); - - restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser() - .removeFavoriteSite(siteModel); - - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingAuthUser().getFavorites() - .assertThat().entriesListDoesNotContain("id", siteModel.getId()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify uninvited user can delete favorite public site and response is 204") - public void uninvitedUserCanDeleteFavoritePublicSite() throws Exception - { - SiteModel publicSiteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - restClient.authenticateUser(userModel).withCoreAPI().usingUser(userModel).addFavoriteSite(publicSiteModel); - - restClient.withCoreAPI().usingAuthUser() - .removeFavoriteSite(publicSiteModel); - - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingAuthUser().getFavoriteSites() - .assertThat().entriesListDoesNotContain("id", publicSiteModel.getId()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify uninvited user can delete favorite moderated site and response is 204") - public void uninvitedUserCanDeleteFavoriteModeratedSite() throws Exception - { - SiteModel moderatedSiteModel = dataSite.usingUser(adminUserModel).createModeratedRandomSite(); - restClient.authenticateUser(userModel).withCoreAPI().usingUser(userModel).addFavoriteSite(moderatedSiteModel); - - restClient.withCoreAPI().usingAuthUser() - .removeFavoriteSite(moderatedSiteModel); - - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingAuthUser().getFavoriteSites() - .assertThat().entriesListDoesNotContain("id", moderatedSiteModel.getId()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify user can delete favorite private site and response is 204") - public void userCanDeleteFavoritePrivateSite() throws Exception - { - SiteModel privateSiteModel = dataSite.usingUser(userModel).createPrivateRandomSite(); - restClient.authenticateUser(userModel).withCoreAPI().usingUser(userModel).addFavoriteSite(privateSiteModel); - - restClient.withCoreAPI().usingAuthUser() - .removeFavoriteSite(privateSiteModel); - - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingAuthUser().getFavoriteSites() - .assertThat().entriesListDoesNotContain("id", privateSiteModel.getId()); - } - -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteSiteFullTests.java b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteSiteFullTests.java deleted file mode 100644 index 4a763ab7f..000000000 --- a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteSiteFullTests.java +++ /dev/null @@ -1,185 +0,0 @@ -package org.alfresco.rest.favorites; - -import org.alfresco.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestSiteModel; -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.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class DeleteFavoriteSiteFullTests extends RestTest -{ - UserModel userModel; - SiteModel siteModel, siteModel1; - UserModel adminUserModel, adminTenantUser, tenantUser; - RestSiteModel restSiteModel; - ListUserWithRoles usersWithRoles; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - adminUserModel = dataUser.getAdminUser(); - - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "User is not able to remove a favorite site of admin user") - public void userIsNotAbleToDeleteFavoritesOfAdmin() throws Exception - { - UserModel contributor = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); - dataSite.usingUser(contributor).usingSite(siteModel).addSiteToFavorites(); - - restClient.authenticateUser(contributor) - .withCoreAPI().usingUser(adminUserModel).removeFavoriteSite(siteModel); - - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError() - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Users removed twice from favorites same site.") - public void managerUserRemovesDeletedFavoriteSite() throws Exception - { - UserModel managerUser = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); - dataSite.usingUser(managerUser).usingSite(siteModel).addSiteToFavorites(); - - restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel); - restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.NOT_FAVOURITE_SITE, siteModel.getTitle())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Users removes from favorite a site that is already deleted.") - public void consumerUserRemovesDeletedFavoriteSite() throws Exception - { - siteModel1 = dataSite.usingUser(userModel).createPublicRandomSite(); - UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel1, UserRole.SiteConsumer); - dataSite.usingUser(consumerUser).usingSite(siteModel1).addSiteToFavorites(); - - dataSite.usingAdmin().deleteSite(siteModel1); - restClient.authenticateUser(consumerUser).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel1); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, - consumerUser.getUsername(), siteModel1.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Delete favorite site that is NOT favorite.") - public void adminUserRemovesDeletedFavoriteSiteThatIsNotFavorite() throws Exception - { - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.NOT_FAVOURITE_SITE, siteModel.getTitle())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify user doesn't have permission to delete favorites of another user with Rest API and status code is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - public void userIsNotAbleToDeleteFavoritesOfAnotherUser() throws JsonToModelConversionException, Exception - { - UserModel siteCollaborator = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); - dataSite.usingUser(siteCollaborator).usingSite(siteModel).addSiteToFavorites(); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .withCoreAPI() - .usingUser(siteCollaborator) - .removeFavoriteSite(siteModel); - - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError() - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Bug(id="MNT-16904") - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE}, executionType = ExecutionType.REGRESSION, - description = "Verify tenant user is not able to delete favorites using an invalid network ID") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.NETWORKS, TestGroup.FULL }) - public void tenantIsNotAbleToDeleteFavoriteSiteWithInvalidNetworkID() throws JsonToModelConversionException, Exception - { - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUserModel).usingTenant().createTenant(adminTenantUser); - tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - siteModel = dataSite.usingUser(tenantUser).createPublicRandomSite(); - siteModel.setGuid(restClient.authenticateUser(tenantUser).withCoreAPI().usingSite(siteModel).getSite().getGuid()); - restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - tenantUser.setDomain("invalidNetwork"); - - restClient.withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE}, executionType = ExecutionType.REGRESSION, - description = "Verify tenant user deletes favorites site and status code is (204)") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.NETWORKS, TestGroup.FULL }) - public void tenantDeleteFavoriteSiteValidNetwork() throws JsonToModelConversionException, Exception - { - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUserModel).usingTenant().createTenant(adminTenantUser); - tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - siteModel = dataSite.usingUser(tenantUser).createPublicRandomSite(); - siteModel.setGuid(restClient.authenticateUser(tenantUser).withCoreAPI().usingSite(siteModel).getSite().getGuid()); - restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - tenantUser.setDomain(tenantUser.getDomain()); - - restClient.withCoreAPI() - .usingAuthUser().removeFavoriteSite(siteModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingAuthUser().getFavorites() - .assertThat() - .entriesListDoesNotContain("targetGuid", siteModel.getGuidWithoutVersion()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE}, executionType = ExecutionType.REGRESSION, - description = "Verify tenant user deletes favorites site created by admin tenant - same network and status code is (204)") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.NETWORKS, TestGroup.FULL }) - public void tenantUserIsAbleToDeleteFavoriteSiteAddedByAdminSameNetwork() throws JsonToModelConversionException, Exception - { - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUserModel).usingTenant().createTenant(adminTenantUser); - tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); - siteModel.setGuid(restClient.authenticateUser(adminTenantUser).withCoreAPI().usingSite(siteModel).getSite().getGuid()); - restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - tenantUser.setDomain(adminTenantUser.getDomain()); - - restClient.withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingAuthUser().getFavorites() - .assertThat() - .entriesListDoesNotContain("targetGuid", siteModel.getGuidWithoutVersion()); - } - -} diff --git a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteSiteSanityTests.java deleted file mode 100644 index 43598e19c..000000000 --- a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteSiteSanityTests.java +++ /dev/null @@ -1,174 +0,0 @@ -package org.alfresco.rest.favorites; - -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -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.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * @author Cristina Axinte - */ - -public class DeleteFavoriteSiteSanityTests extends RestTest -{ - UserModel userModel; - SiteModel siteModel1; - SiteModel siteModel2; - UserModel searchedUser; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - siteModel1 = dataSite.usingUser(userModel).createPublicRandomSite(); - siteModel2 = dataSite.usingUser(userModel).createPublicRandomSite(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, - description = "Verify manager user removes a site from its favorite sites list with Rest API and response is successful (204)") - public void managerUserRemovesFavoriteSiteWithSuccess() throws Exception - { - UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel1, UserRole.SiteManager); - dataSite.usingUser(managerUser).usingSite(siteModel1).addSiteToFavorites(); - dataSite.usingUser(managerUser).usingSite(siteModel2).addSiteToFavorites(); - - restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingAuthUser().getFavorites() - .assertThat() - .entriesListDoesNotContain("targetGuid", siteModel1.getGuid()) - .and().entriesListDoesNotContain("id", siteModel1.getId()) - .and().entriesListDoesNotContain("description", siteModel1.getDescription()) - .and().entriesListDoesNotContain("visibility", siteModel1.getVisibility().toString()) - .and().entriesListDoesNotContain("title", siteModel1.getTitle()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, - description = "Verify collaborator user removes a site from its favorite sites list with Rest API and response is successful (204)") - public void collaboratorUserRemovesFavoriteSiteWithSuccess() throws Exception - { - UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(collaboratorUser, siteModel1, UserRole.SiteCollaborator); - dataSite.usingUser(collaboratorUser).usingSite(siteModel1).addSiteToFavorites(); - dataSite.usingUser(collaboratorUser).usingSite(siteModel2).addSiteToFavorites(); - - restClient.authenticateUser(collaboratorUser).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingAuthUser().getFavorites() - .assertThat() - .entriesListDoesNotContain("targetGuid", siteModel1.getGuid()) - .and().entriesListDoesNotContain("id", siteModel1.getId()) - .and().entriesListDoesNotContain("description", siteModel1.getDescription()) - .and().entriesListDoesNotContain("visibility", siteModel1.getVisibility().toString()) - .and().entriesListDoesNotContain("title", siteModel1.getTitle()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, - description = "Verify contributor user removes a site from its favorite sites list with Rest API and response is successful (204)") - public void contributorUserRemovesFavoriteSiteWithSuccess() throws Exception - { - UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(contributorUser, siteModel1, UserRole.SiteContributor); - dataSite.usingUser(contributorUser).usingSite(siteModel1).addSiteToFavorites(); - dataSite.usingUser(contributorUser).usingSite(siteModel2).addSiteToFavorites(); - - restClient.authenticateUser(contributorUser).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingAuthUser().getFavorites() - .assertThat() - .entriesListDoesNotContain("targetGuid", siteModel1.getGuid()) - .and().entriesListDoesNotContain("id", siteModel1.getId()) - .and().entriesListDoesNotContain("description", siteModel1.getDescription()) - .and().entriesListDoesNotContain("visibility", siteModel1.getVisibility().toString()) - .and().entriesListDoesNotContain("title", siteModel1.getTitle()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, - description = "Verify consumer user removes a site from its favorite sites list with Rest API and response is successful (204)") - public void consumerUserRemovesFavoriteSiteWithSuccess() throws Exception - { - UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel1, UserRole.SiteConsumer); - dataSite.usingUser(consumerUser).usingSite(siteModel1).addSiteToFavorites(); - dataSite.usingUser(consumerUser).usingSite(siteModel2).addSiteToFavorites(); - - restClient.authenticateUser(consumerUser).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingAuthUser().getFavorites() - .assertThat() - .entriesListDoesNotContain("targetGuid", siteModel1.getGuid()) - .and().entriesListDoesNotContain("id", siteModel1.getId()) - .and().entriesListDoesNotContain("description", siteModel1.getDescription()) - .and().entriesListDoesNotContain("visibility", siteModel1.getVisibility().toString()) - .and().entriesListDoesNotContain("title", siteModel1.getTitle()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, - description = "Verify admin user removes a site from any user's favorite sites list with Rest API and response is successful (204)") - public void adminUserRemovesAnyFavoriteSiteWithSuccess() throws Exception - { - UserModel adminUser = dataUser.getAdminUser(); - UserModel anyUser = dataUser.usingAdmin().createRandomTestUser(); - dataSite.usingUser(anyUser).usingSite(siteModel1).addSiteToFavorites(); - dataSite.usingUser(anyUser).usingSite(siteModel2).addSiteToFavorites(); - - restClient.authenticateUser(adminUser).withCoreAPI().usingUser(anyUser).removeFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, - description = "Verify a user removes a site from another user's favorite sites list with Rest API and response is permission denied (403)") - public void userRemovesAnotherUserFavoriteSiteWithSuccess() throws Exception - { - UserModel userAuth = dataUser.usingAdmin().createRandomTestUser(); - UserModel anotherUser = dataUser.usingAdmin().createRandomTestUser(); - dataSite.usingUser(anotherUser).usingSite(siteModel1).addSiteToFavorites(); - dataSite.usingUser(anotherUser).usingSite(siteModel2).addSiteToFavorites(); - - restClient.authenticateUser(userAuth).withCoreAPI().usingUser(anotherUser).removeFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError() - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE) - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, - description = "Verify manager user is NOT Authorized to remove a site from its favorite sites list with Rest API when authentication fails (401)") - public void managerUserNotAuthorizedFailsToRemoveFavoriteSite() throws Exception - { - UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel1, UserRole.SiteManager); - dataSite.usingUser(managerUser).usingSite(siteModel1).addSiteToFavorites(); - dataSite.usingUser(managerUser).usingSite(siteModel2).addSiteToFavorites(); - managerUser.setPassword("newpassword"); - - restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE) - .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY); - } -} diff --git a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteSiteTests.java b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteSiteTests.java new file mode 100644 index 000000000..c9b52a4bd --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteSiteTests.java @@ -0,0 +1,432 @@ +package org.alfresco.rest.favorites; + +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; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * @author Cristina Axinte + */ + +public class DeleteFavoriteSiteTests extends RestTest +{ + private UserModel userModel, adminUserModel, adminTenantUser, tenantUser; + private SiteModel siteModel1, siteModel2; + private DataUser.ListUserWithRoles usersWithRoles; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + siteModel1 = dataSite.usingUser(userModel).createPublicRandomSite(); + siteModel2 = dataSite.usingUser(userModel).createPublicRandomSite(); + adminUserModel = dataUser.getAdminUser(); + + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel1, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, + description = "Verify manager user removes a site from its favorite sites list with Rest API and response is successful (204)") + public void managerUserRemovesFavoriteSiteWithSuccess() throws Exception + { + UserModel managerUser = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); + dataSite.usingUser(managerUser).usingSite(siteModel1).addSiteToFavorites(); + dataSite.usingUser(managerUser).usingSite(siteModel2).addSiteToFavorites(); + + restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel1); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingAuthUser().getFavorites() + .assertThat() + .entriesListDoesNotContain("targetGuid", siteModel1.getGuid()) + .and().entriesListDoesNotContain("id", siteModel1.getId()) + .and().entriesListDoesNotContain("description", siteModel1.getDescription()) + .and().entriesListDoesNotContain("visibility", siteModel1.getVisibility().toString()) + .and().entriesListDoesNotContain("title", siteModel1.getTitle()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, + description = "Verify manager user is NOT Authorized to remove a site from its favorite sites list with Rest API when authentication fails (401)") + public void managerUserNotAuthorizedFailsToRemoveFavoriteSite() throws Exception + { + UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel1, UserRole.SiteManager); + dataSite.usingUser(managerUser).usingSite(siteModel1).addSiteToFavorites(); + dataSite.usingUser(managerUser).usingSite(siteModel2).addSiteToFavorites(); + managerUser.setPassword("newpassword"); + + restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel1); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE) + .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify collaborator user removes a site from its favorite sites list with Rest API and response is successful (204)") + public void collaboratorUserRemovesFavoriteSiteWithSuccess() throws Exception + { + UserModel collaboratorUser = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); + dataSite.usingUser(collaboratorUser).usingSite(siteModel1).addSiteToFavorites(); + dataSite.usingUser(collaboratorUser).usingSite(siteModel2).addSiteToFavorites(); + + restClient.authenticateUser(collaboratorUser).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel1); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingAuthUser().getFavorites() + .assertThat() + .entriesListDoesNotContain("targetGuid", siteModel1.getGuid()) + .and().entriesListDoesNotContain("id", siteModel1.getId()) + .and().entriesListDoesNotContain("description", siteModel1.getDescription()) + .and().entriesListDoesNotContain("visibility", siteModel1.getVisibility().toString()) + .and().entriesListDoesNotContain("title", siteModel1.getTitle()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify contributor user removes a site from its favorite sites list with Rest API and response is successful (204)") + public void contributorUserRemovesFavoriteSiteWithSuccess() throws Exception + { + UserModel contributorUser = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); + dataSite.usingUser(contributorUser).usingSite(siteModel1).addSiteToFavorites(); + dataSite.usingUser(contributorUser).usingSite(siteModel2).addSiteToFavorites(); + + restClient.authenticateUser(contributorUser).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel1); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingAuthUser().getFavorites() + .assertThat() + .entriesListDoesNotContain("targetGuid", siteModel1.getGuid()) + .and().entriesListDoesNotContain("id", siteModel1.getId()) + .and().entriesListDoesNotContain("description", siteModel1.getDescription()) + .and().entriesListDoesNotContain("visibility", siteModel1.getVisibility().toString()) + .and().entriesListDoesNotContain("title", siteModel1.getTitle()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify consumer user removes a site from its favorite sites list with Rest API and response is successful (204)") + public void consumerUserRemovesFavoriteSiteWithSuccess() throws Exception + { + UserModel consumerUser = usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer); + dataSite.usingUser(consumerUser).usingSite(siteModel1).addSiteToFavorites(); + dataSite.usingUser(consumerUser).usingSite(siteModel2).addSiteToFavorites(); + + restClient.authenticateUser(consumerUser).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel1); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingAuthUser().getFavorites() + .assertThat() + .entriesListDoesNotContain("targetGuid", siteModel1.getGuid()) + .and().entriesListDoesNotContain("id", siteModel1.getId()) + .and().entriesListDoesNotContain("description", siteModel1.getDescription()) + .and().entriesListDoesNotContain("visibility", siteModel1.getVisibility().toString()) + .and().entriesListDoesNotContain("title", siteModel1.getTitle()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify admin user removes a site from any user's favorite sites list with Rest API and response is successful (204)") + public void adminUserRemovesAnyFavoriteSiteWithSuccess() throws Exception + { + UserModel anyUser = dataUser.usingAdmin().createRandomTestUser(); + dataSite.usingUser(anyUser).usingSite(siteModel1).addSiteToFavorites(); + dataSite.usingUser(anyUser).usingSite(siteModel2).addSiteToFavorites(); + + restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingUser(anyUser).removeFavoriteSite(siteModel1); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE , TestGroup.REGRESSION}) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify a user removes a site from another user's favorite sites list with Rest API and response is permission denied (403)") + public void userCannotRemoveAnotherUserFavoriteSite() throws Exception + { + UserModel userAuth = dataUser.usingAdmin().createRandomTestUser(); + UserModel anotherUser = dataUser.usingAdmin().createRandomTestUser(); + dataSite.usingUser(anotherUser).usingSite(siteModel1).addSiteToFavorites(); + dataSite.usingUser(anotherUser).usingSite(siteModel2).addSiteToFavorites(); + + restClient.authenticateUser(userAuth).withCoreAPI().usingUser(anotherUser).removeFavoriteSite(siteModel1); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError() + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE) + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify uninvited user can delete favorite public site and response is 204") + public void uninvitedUserCanDeleteFavoritePublicSite() throws Exception + { + SiteModel publicSiteModel = dataSite.usingAdmin().createPublicRandomSite(); + restClient.authenticateUser(userModel).withCoreAPI().usingUser(userModel).addFavoriteSite(publicSiteModel); + + restClient.withCoreAPI().usingAuthUser() + .removeFavoriteSite(publicSiteModel); + + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withCoreAPI().usingAuthUser().getFavoriteSites() + .assertThat().entriesListDoesNotContain("id", publicSiteModel.getId()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify uninvited user can delete favorite moderated site and response is 204") + public void uninvitedUserCanDeleteFavoriteModeratedSite() throws Exception + { + SiteModel moderatedSiteModel = dataSite.usingAdmin().createModeratedRandomSite(); + restClient.authenticateUser(userModel).withCoreAPI().usingUser(userModel).addFavoriteSite(moderatedSiteModel); + + restClient.withCoreAPI().usingAuthUser() + .removeFavoriteSite(moderatedSiteModel); + + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withCoreAPI().usingAuthUser().getFavoriteSites() + .assertThat().entriesListDoesNotContain("id", moderatedSiteModel.getId()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify user can delete favorite private site and response is 204") + public void userCanDeleteFavoritePrivateSite() throws Exception + { + SiteModel privateSiteModel = dataSite.usingUser(userModel).createPrivateRandomSite(); + restClient.authenticateUser(userModel).withCoreAPI().usingUser(userModel).addFavoriteSite(privateSiteModel); + + restClient.withCoreAPI().usingAuthUser() + .removeFavoriteSite(privateSiteModel); + + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withCoreAPI().usingAuthUser().getFavoriteSites() + .assertThat().entriesListDoesNotContain("id", privateSiteModel.getId()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify manager user removes a site from its favorites and adds it again and response is successful (204)") + public void managerUserRemovesFavoriteSiteAndAddItAgain() throws Exception + { + UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel1, UserRole.SiteManager); + dataSite.usingUser(managerUser).usingSite(siteModel1).addSiteToFavorites(); + + restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser() + .removeFavoriteSite(siteModel1); + + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withCoreAPI().usingUser(managerUser).addFavoriteSite(siteModel1); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify user removes a site from favorites using '-me-' in place of personId with Rest API and response is successful (204)") + public void removeFavoriteSiteWithSuccessUsingMeAsPersonId() throws Exception + { + restClient.authenticateUser(adminUserModel); + dataSite.usingUser(adminUserModel).usingSite(siteModel1).addSiteToFavorites(); + + restClient.withCoreAPI().usingMe().removeFavoriteSite(siteModel1); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) +// @Bug(id = "REPO-1642", description = "reproduced on 5.2.1 only, it works on 5.2.0") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify inexistent user is not able to remove a site from favorites and response is 404") + public void inexistentUserIsNotAbleToRemoveFavoriteSite() throws Exception + { + UserModel inexistentUser = new UserModel("inexistenUser", "password"); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(inexistentUser) + .removeFavoriteSite(siteModel1); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "inexistenUser")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify user is not able to remove from favorites a site with inexistent id and response is 404") + public void userIsNotAbleToRemoveFavoriteSiteWithInexistentId() throws Exception + { + SiteModel inexistentSite = new SiteModel("inexistentSite"); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel) + .removeFavoriteSite(inexistentSite); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, + adminUserModel.getUsername(), inexistentSite.getTitle())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE) + .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "User is not able to remove a favorite site of admin user") + public void userIsNotAbleToDeleteFavoritesOfAdmin() throws Exception + { + UserModel contributor = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); + dataSite.usingUser(adminUserModel).usingSite(siteModel1).addSiteToFavorites(); + + restClient.authenticateUser(contributor) + .withCoreAPI().usingUser(adminUserModel).removeFavoriteSite(siteModel1); + + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError() + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Users removed twice from favorites same site.") + public void managerUserRemovesDeletedFavoriteSite() throws Exception + { + UserModel managerUser = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); + dataSite.usingUser(managerUser).usingSite(siteModel1).addSiteToFavorites(); + + restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel1); + restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel1); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.NOT_FAVOURITE_SITE, siteModel1.getTitle())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Users removes from favorite a site that is already deleted.") + public void consumerUserRemovesDeletedFavoriteSite() throws Exception + { + SiteModel siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel, UserRole.SiteConsumer); + dataSite.usingUser(consumerUser).usingSite(siteModel).addSiteToFavorites(); + + dataSite.usingAdmin().deleteSite(siteModel); + restClient.authenticateUser(consumerUser).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, + consumerUser.getUsername(), siteModel.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Delete favorite site that is NOT favorite.") + public void adminUserRemovesDeletedFavoriteSiteThatIsNotFavorite() throws Exception + { + SiteModel siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.NOT_FAVOURITE_SITE, siteModel.getTitle())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify user doesn't have permission to delete favorites of another user with Rest API and status code is 403") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void siteMemberIsNotAbleToDeleteFavoritesOfAnotherSiteMember() throws Exception + { + UserModel siteCollaborator = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); + dataSite.usingUser(siteCollaborator).usingSite(siteModel1).addSiteToFavorites(); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + .withCoreAPI() + .usingUser(siteCollaborator) + .removeFavoriteSite(siteModel1); + + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError() + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Bug(id="MNT-16904") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE}, executionType = ExecutionType.REGRESSION, + description = "Verify tenant user is not able to delete favorites using an invalid network ID") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.NETWORKS, TestGroup.REGRESSION }) + public void tenantIsNotAbleToDeleteFavoriteSiteWithInvalidNetworkID() throws Exception + { + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUserModel).usingTenant().createTenant(adminTenantUser); + tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + SiteModel siteModel = dataSite.usingUser(tenantUser).createPublicRandomSite(); + siteModel.setGuid(restClient.authenticateUser(tenantUser).withCoreAPI().usingSite(siteModel).getSite().getGuid()); + restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + tenantUser.setDomain("invalidNetwork"); + + restClient.withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE}, executionType = ExecutionType.REGRESSION, + description = "Verify tenant user deletes favorites site and status code is (204)") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.NETWORKS, TestGroup.REGRESSION }) + public void tenantDeleteFavoriteSiteValidNetwork() throws Exception + { + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUserModel).usingTenant().createTenant(adminTenantUser); + tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + SiteModel siteModel = dataSite.usingUser(tenantUser).createPublicRandomSite(); + siteModel.setGuid(restClient.authenticateUser(tenantUser).withCoreAPI().usingSite(siteModel).getSite().getGuid()); + restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + tenantUser.setDomain(tenantUser.getDomain()); + + restClient.withCoreAPI() + .usingAuthUser().removeFavoriteSite(siteModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingAuthUser().getFavorites() + .assertThat() + .entriesListDoesNotContain("targetGuid", siteModel.getGuidWithoutVersion()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE}, executionType = ExecutionType.REGRESSION, + description = "Verify tenant user deletes favorites site created by admin tenant - same network and status code is (204)") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.NETWORKS, TestGroup.REGRESSION }) + public void tenantUserIsAbleToDeleteFavoriteSiteAddedByAdminSameNetwork() throws Exception + { + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUserModel).usingTenant().createTenant(adminTenantUser); + tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + SiteModel siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); + siteModel.setGuid(restClient.authenticateUser(adminTenantUser).withCoreAPI().usingSite(siteModel).getSite().getGuid()); + restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + tenantUser.setDomain(adminTenantUser.getDomain()); + + restClient.withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingAuthUser().getFavorites() + .assertThat() + .entriesListDoesNotContain("targetGuid", siteModel.getGuidWithoutVersion()); + } +} diff --git a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteTests.java b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteTests.java new file mode 100644 index 000000000..5c3bb952a --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteTests.java @@ -0,0 +1,477 @@ +package org.alfresco.rest.favorites; + +import org.alfresco.dataprep.CMISUtil; +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.model.*; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class DeleteFavoriteTests extends RestTest +{ + private UserModel adminUserModel, tenantUser, adminTenantUser; + private SiteModel siteModel; + private ListUserWithRoles usersWithRoles; + private FileModel fileModel; + private FolderModel folderModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + siteModel.setGuid(restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(siteModel).getSite().getGuid()); + + fileModel = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + folderModel = dataContent.usingSite(siteModel).usingUser(adminUserModel).createFolder(); + + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, + description = "Verify Manager user deletes site from favorites with Rest API and status code is 204") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) + public void managerIsAbleToDeleteFavorites() throws Exception + { + UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); + restClient.authenticateUser(siteManager).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + + restClient.withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel).assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withCoreAPI().usingAuthUser().getFavorites() + .assertThat() + .entriesListDoesNotContain("targetGuid", siteModel.getGuid()) + .and().entriesListDoesNotContain("id", siteModel.getId()) + .and().entriesListDoesNotContain("description", siteModel.getDescription()) + .and().entriesListDoesNotContain("visibility", siteModel.getVisibility().toString()) + .and().entriesListDoesNotContain("title", siteModel.getTitle()); + } + + // @Bug(id = "MNT-16904", description = "It fails only on environment with tenants") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, + description = "Verify user gets status code 401 if authentication call fails") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) + public void userIsNotAbleToDeleteFavoritesIfAuthenticationFails() throws Exception + { + UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); + siteManager.setPassword("wrongPassword"); + restClient.authenticateUser(siteManager).withCoreAPI().usingAuthUser() + .deleteSiteFromFavorites(siteModel).assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify Collaborator user deletes site from favorites with Rest API and status code is 204") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void collaboratorIsAbleToDeleteFavorites() throws Exception + { + UserModel siteCollaborator = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); + restClient.authenticateUser(siteCollaborator).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + + restClient.withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel).assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withCoreAPI().usingAuthUser().getFavorites() + .assertThat() + .entriesListDoesNotContain("targetGuid", siteModel.getGuid()) + .and().entriesListDoesNotContain("id", siteModel.getId()) + .and().entriesListDoesNotContain("description", siteModel.getDescription()) + .and().entriesListDoesNotContain("visibility", siteModel.getVisibility().toString()) + .and().entriesListDoesNotContain("title", siteModel.getTitle()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify Contributor user deletes site from favorites with Rest API and status code is 204") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void contributorIsAbleToDeleteFavorites() throws Exception + { + UserModel siteContributor = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); + restClient.authenticateUser(siteContributor).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + + restClient.withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel).assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withCoreAPI().usingAuthUser().getFavorites() + .assertThat() + .entriesListDoesNotContain("targetGuid", siteModel.getGuid()) + .and().entriesListDoesNotContain("id", siteModel.getId()) + .and().entriesListDoesNotContain("description", siteModel.getDescription()) + .and().entriesListDoesNotContain("visibility", siteModel.getVisibility().toString()) + .and().entriesListDoesNotContain("title", siteModel.getTitle()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify Consumer user delets site from favorites with Rest API and status code is 204") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void consumerIsAbleToDeleteFavorites() throws Exception + { + UserModel siteConsumer = usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer); + restClient.authenticateUser(siteConsumer).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + + restClient.withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel).assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withCoreAPI().usingAuthUser().getFavorites() + .assertThat() + .entriesListDoesNotContain("targetGuid", siteModel.getGuid()) + .and().entriesListDoesNotContain("id", siteModel.getId()) + .and().entriesListDoesNotContain("description", siteModel.getDescription()) + .and().entriesListDoesNotContain("visibility", siteModel.getVisibility().toString()) + .and().entriesListDoesNotContain("title", siteModel.getTitle()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify Admin user deletes site from favorites with Rest API and status code is 204") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void adminIsAbleToDeleteFavorites() throws Exception + { + restClient.withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); + + restClient.withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel).assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withCoreAPI().usingAuthUser().getFavorites().assertThat().entriesListDoesNotContain("targetGuid", siteModel.getGuid()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify admin deletes files from favorites with Rest API and status code is (204)") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void adminIsAbleToDeleteFavoriteFile() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFileToFavorites(fileModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.withCoreAPI().usingAuthUser().deleteFileFromFavorites(fileModel).assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withCoreAPI().usingAuthUser().getFavorites() + .assertThat() + .entriesListDoesNotContain("targetGuid", fileModel.getNodeRefWithoutVersion()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify admin deletes folder from favorites with Rest API and status code is (204)") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void adminIsAbleToDeleteFavoriteFolder() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFolderToFavorites(folderModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.withCoreAPI().usingAuthUser().deleteFolderFromFavorites(folderModel) + .assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withCoreAPI().usingAuthUser().getFavorites() + .assertThat() + .entriesListDoesNotContain("targetGuid", fileModel.getNodeRefWithoutVersion()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify user removes a site from favorites using '-me-' in place of personId with Rest API and response is successful (204)") + public void deleteFavoriteSiteWithSuccessUsingMeAsPersonId() throws Exception + { + siteModel.setGuid(restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(siteModel).getSite().getGuid()); + restClient.withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); + + restClient.withCoreAPI().usingMe().deleteSiteFromFavorites(siteModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @Bug(id="ACE-5588") + @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify user doesn't have permission to delete favorites of admin user with Rest API and status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void userIsNotAbleToDeleteFavoritesOfAdminUser() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + .withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel) + .assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Bug(id="ACE-5588") + @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify admin user doesn't have permission to delete favorites of another user with Rest API and status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void adminIsNotAbleToDeleteFavoritesOfASiteMember() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + + restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel) + .assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError() + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Bug(id="ACE-5588") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify user doesn't have permission to delete favorites of another user with Rest API and status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void consumerIsNotAbleToDeleteFavoritesOfAnotherUser() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI() + .usingAuthUser().addSiteToFavorites(siteModel); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI() + .usingAuthUser().deleteSiteFromFavorites(siteModel) + .assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Bug(id="ACE-5588") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify consumer user doesn't have permission to delete favorites of another user with Rest API and status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void collaboratorIsNotAbleToDeleteFavoriteOfAnotherUser() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI() + .usingAuthUser().addSiteToFavorites(siteModel); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI() + .usingAuthUser().deleteSiteFromFavorites(siteModel) + .assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError() + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Bug(id="ACE-5588") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify contributor user doesn't have permission to delete favorites of another user with Rest API and status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void contributorIsNotAbleToDeleteFavoriteOfAnotherUser() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI() + .usingAuthUser().addSiteToFavorites(siteModel); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI() + .usingAuthUser().deleteSiteFromFavorites(siteModel) + .assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError() + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Bug(id="ACE-5588") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify contributor user doesn't have permission to delete favorites of another user with Rest API and status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void adminIsNotAbleToDeleteFavoriteOfAnotherUser() throws Exception + { + UserModel user = dataUser.createRandomTestUser(); + restClient.authenticateUser(user).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + + restClient.authenticateUser(adminUserModel).withCoreAPI() + .usingAuthUser().deleteSiteFromFavorites(siteModel) + .assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError() + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that status code is 404 if PersonID is incorrect - favorite file.") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION}) + public void deleteFavoriteIfPersonIdNotExists() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); + restClient.withCoreAPI().usingAuthUser().addFileToFavorites(fileModel); + + restClient.withCoreAPI().usingUser(new UserModel("inexistent", "inexistent")) + .deleteFileFromFavorites(fileModel).assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "inexistent")); + } + + @Bug(id="ACE-2413") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that status code is 404 if PersonID is empty - favorite file.") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION}) + public void deleteFavoriteIfPersonIdIsEmpty() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); + restClient.withCoreAPI().usingAuthUser().addFileToFavorites(fileModel); + + restClient.withCoreAPI().usingUser(new UserModel ("", "")) + .deleteFileFromFavorites(fileModel).assertStatusCodeIs(HttpStatus.BAD_REQUEST); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that status code is 404 if FavoriteID is incorrect - favorite file.") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION}) + public void deleteFavoriteFileIfFavoriteIdIsIncorrect() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFileToFavorites(fileModel); + + fileModel.setNodeRef("wrongFavoriteId"); + restClient.withCoreAPI().usingAuthUser() + .deleteFileFromFavorites(fileModel).assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "wrongFavoriteId")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that status code is 404 if FavoriteID is incorrect - favorite file.") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION}) + public void deleteFavoriteFileIfFavoriteIdNotExists() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFileToFavorites(fileModel); + FileModel inexistentDocument = new FileModel(); + inexistentDocument.setNodeRef("inexistent"); + + restClient.withCoreAPI().usingAuthUser() + .deleteFileFromFavorites(inexistentDocument).assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "inexistent")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that status code is 404 if FavoriteID is incorrect - favorite site.") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION}) + public void deleteFavoriteSiteIfFavoriteIdNotExists() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); + siteModel.setGuid("wrongFavoriteId"); + + restClient.withCoreAPI().usingAuthUser() + .deleteSiteFromFavorites(siteModel).assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "wrongFavoriteId")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that status code is 404 if FavoriteID is incorrect - favorite folder.") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION}) + public void deleteFavoriteFolderIfFavoriteIdNotExists() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); + restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(folderModel); + + folderModel.setNodeRef("wrongFavoriteId"); + restClient.withCoreAPI().usingAuthUser() + .deleteFolderFromFavorites(folderModel).assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "wrongFavoriteId")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify admin is not able to deletes files from favorites that were already deleted with Rest API and status code is (404)") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void adminIsNotAbleToDeleteADeletedFavoriteFile() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFileToFavorites(fileModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.withCoreAPI().usingAuthUser().deleteFileFromFavorites(fileModel).assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withCoreAPI().usingAuthUser().getFavorites() + .assertThat() + .entriesListDoesNotContain("targetGuid", fileModel.getNodeRefWithoutVersion()); + + restClient.withCoreAPI().usingAuthUser().deleteFileFromFavorites(fileModel) + .assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, + adminUserModel.getUsername(), fileModel.getNodeRef())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify user can't delete favorites using an invalid network ID.") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void userIsNotAbleToDeleteFavoriteSiteWithInvalidNetworkID() throws Exception + { + UserModel networkUserModel = dataUser.createRandomTestUser(); + restClient.authenticateUser(networkUserModel).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + networkUserModel.setDomain("invalidNetwork"); + + restClient.withCoreAPI() + .usingAuthUser().deleteSiteFromFavorites(siteModel) + .assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) + .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify contributor user doesn't have permission to delete favorites of another user with Rest API and status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void adminDeletesFavoriteForNotFavouriteFile() throws Exception + { + fileModel = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser() + .deleteFileFromFavorites(fileModel) + .assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, + adminUserModel.getUsername(), fileModel.getNodeRef())) + .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Bug(id="MNT-16904") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify tenant user is not able to delete favorites using an invalid network ID") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES,TestGroup.NETWORKS, TestGroup.REGRESSION }) + public void tenantIsNotAbleToDeleteFavoriteSiteWithInvalidNetworkID() throws Exception + { + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUserModel).usingTenant().createTenant(adminTenantUser); + tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + siteModel = dataSite.usingUser(tenantUser).createPublicRandomSite(); + siteModel.setGuid(restClient.authenticateUser(tenantUser).withCoreAPI().usingSite(siteModel).getSite().getGuid()); + restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + tenantUser.setDomain("invalidNetwork"); + + restClient.withCoreAPI() + .usingAuthUser().deleteSiteFromFavorites(siteModel) + .assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES}, executionType = ExecutionType.REGRESSION, + description = "Verify tenant user deletes favorites site and status code is (204)") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES,TestGroup.NETWORKS, TestGroup.REGRESSION }) + public void tenantDeleteFavoriteSiteValidNetwork() throws Exception + { + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUserModel).usingTenant().createTenant(adminTenantUser); + tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + siteModel = dataSite.usingUser(tenantUser).createPublicRandomSite(); + siteModel.setGuid(restClient.authenticateUser(tenantUser).withCoreAPI().usingSite(siteModel).getSite().getGuid()); + restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + tenantUser.setDomain(tenantUser.getDomain()); + + restClient.withCoreAPI() + .usingAuthUser().deleteSiteFromFavorites(siteModel) + .assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingAuthUser().getFavorites() + .assertThat() + .entriesListDoesNotContain("targetGuid", siteModel.getGuidWithoutVersion()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES}, executionType = ExecutionType.REGRESSION, + description = "Verify tenant user deletes favorites site created by admin tenant - same network and status code is (204)") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES,TestGroup.NETWORKS, TestGroup.REGRESSION }) + public void tenantUserIsAbleToDeleteFavoriteSiteAddedByAdminSameNetwork() throws Exception + { + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUserModel).usingTenant().createTenant(adminTenantUser); + tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); + siteModel.setGuid(restClient.authenticateUser(adminTenantUser).withCoreAPI().usingSite(siteModel).getSite().getGuid()); + restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + tenantUser.setDomain(adminTenantUser.getDomain()); + + restClient.withCoreAPI() + .usingAuthUser().deleteSiteFromFavorites(siteModel) + .assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingAuthUser().getFavorites() + .assertThat() + .entriesListDoesNotContain("targetGuid", siteModel.getGuidWithoutVersion()); + } +} diff --git a/e2e-test/java/org/alfresco/rest/favorites/FavoritesIncludePathSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/FavoritesIncludePathTests.java similarity index 95% rename from e2e-test/java/org/alfresco/rest/favorites/FavoritesIncludePathSanityTests.java rename to e2e-test/java/org/alfresco/rest/favorites/FavoritesIncludePathTests.java index a22228c89..dcbba231f 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/FavoritesIncludePathSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/FavoritesIncludePathTests.java @@ -20,7 +20,7 @@ import org.testng.annotations.Test; * * @author meenal bhave */ -public class FavoritesIncludePathSanityTests extends RestTest +public class FavoritesIncludePathTests extends RestTest { private UserModel adminUser; private UserModel testUser1; @@ -37,7 +37,6 @@ public class FavoritesIncludePathSanityTests extends RestTest @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception { - adminUser = dataUser.getAdminUser(); restClient.authenticateUser(adminUser); @@ -54,7 +53,7 @@ public class FavoritesIncludePathSanityTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify that get favorite site request does not include Path") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES}) + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION}) public void testGetFavoriteIncludePathForSite() throws Exception { restClient.authenticateUser(testUser1).withCoreAPI().usingAuthUser().includePath().getFavorite(siteModel1.getGuid()); @@ -64,7 +63,7 @@ public class FavoritesIncludePathSanityTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify that get favorite file or folder request includes path when requested") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES}) + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION}) public void testGetFavouriteIncludePathForFileFolder() throws Exception { STEP("1. Favourite Folder and File"); @@ -97,7 +96,7 @@ public class FavoritesIncludePathSanityTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify path in get favorites") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES}) + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION}) public void testGetFavouritesIncludePath() throws Exception { STEP("1. Favourite Folder and File"); @@ -117,10 +116,9 @@ public class FavoritesIncludePathSanityTests extends RestTest restClient.onResponse().assertThat().body("list.entries.entry.target.site.id", org.hamcrest.Matchers.contains(siteModel1.getId())); restClient.onResponse().assertThat().body("list.entries.entry.target.site.path", org.hamcrest.Matchers.contains(org.hamcrest.Matchers.nullValue())); } - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify path in post favorites") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES}) + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION}) public void testPostFavouritesIncludePath() throws Exception { STEP("1. Favourite Site"); @@ -140,9 +138,6 @@ public class FavoritesIncludePathSanityTests extends RestTest restClient.authenticateUser(testUser1).withCoreAPI().usingAuthUser().includePath().addFileToFavorites(fileInSubFolder); restClient.assertStatusCodeIs(HttpStatus.CREATED); restClient.onResponse().assertThat().body("entry.target.file.id", org.hamcrest.Matchers.equalTo(fileInSubFolder.getNodeRefWithoutVersion())); - restClient.onResponse().assertThat().body("entry.target.file.path", org.hamcrest.Matchers.notNullValue()); - - - } - + restClient.onResponse().assertThat().body("entry.target.file.path", org.hamcrest.Matchers.notNullValue()); + } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteCoreTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteCoreTests.java deleted file mode 100644 index f1e161d04..000000000 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteCoreTests.java +++ /dev/null @@ -1,130 +0,0 @@ -package org.alfresco.rest.favorites; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestPersonFavoritesModel; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser; -import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class GetFavoriteCoreTests extends RestTest { - private UserModel adminUserModel; - private SiteModel siteModel; - private FolderModel folderModel; - private FileModel fileModel; - private ListUserWithRoles usersWithRoles; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception { - adminUserModel = dataUser.getAdminUser(); - restClient.authenticateUser(adminUserModel); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - - folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); - fileModel = dataContent.usingUser(adminUserModel).usingResource(folderModel) - .createContent(DocumentType.TEXT_PLAIN); - - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, - UserRole.SiteConsumer, UserRole.SiteContributor); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify get favorite site when person id does't exist") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) - public void getFavoriteSiteWhenPersonIdNotExist() throws JsonToModelConversionException, Exception { - - restClient.withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); - UserModel someUser = new UserModel("invalidUser", DataUser.PASSWORD); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(someUser).getFavorite(siteModel.getGuid()); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, someUser.getUsername())) - .statusCodeIs(HttpStatus.NOT_FOUND) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY); - } - - @Bug(id = "ACE-2413") - @TestRail(section = { TestGroup.REST_API, - TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify get favorite site when person id is empty") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) - public void getFavoriteSiteWithEmptyUserId() throws JsonToModelConversionException, Exception { - - restClient.withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); - UserModel someUser = new UserModel("", DataUser.PASSWORD); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(someUser).getFavorite(siteModel.getGuid()); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, someUser.getUsername())) - .statusCodeIs(HttpStatus.BAD_REQUEST); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify get favorite site when favorite id does't exist") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) - public void getFavoriteSiteWhenFavoriteIdNotExist() throws JsonToModelConversionException, Exception { - - restClient.withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).getFavorite("invalidId"); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidId")) - .statusCodeIs(HttpStatus.NOT_FOUND) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify get favorite user doesn't have any favorite site, file or folder") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) - public void getFavoriteSiteForUserWithoutAnyFavorites() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingAuthUser().getFavorite(siteModel.getGuid()); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, usersWithRoles.getOneUserWithRole(UserRole.SiteManager).getUsername(), siteModel.getGuid())) - .statusCodeIs(HttpStatus.NOT_FOUND) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE) - .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify get favorite site for -me-") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) - public void getFavoriteSiteUsingMe() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - - RestPersonFavoritesModel favoriteSite = restClient.withCoreAPI().usingMe().getFavorite(siteModel.getGuid()); - restClient.assertStatusCodeIs(HttpStatus.OK); - favoriteSite.assertThat().field("targetGuid").is(siteModel.getGuid()); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify get favorite site for -me-") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) - public void getFavoriteFileUsingMe() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingAuthUser().addFileToFavorites(fileModel); - - RestPersonFavoritesModel favoriteFile = restClient.withCoreAPI().usingMe().getFavorite(fileModel.getNodeRefWithoutVersion()); - restClient.assertStatusCodeIs(HttpStatus.OK); - favoriteFile.assertThat().field("targetGuid").is(fileModel.getNodeRefWithoutVersion()); - } -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteFullTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteFullTests.java deleted file mode 100644 index 531698180..000000000 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteFullTests.java +++ /dev/null @@ -1,207 +0,0 @@ -package org.alfresco.rest.favorites; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.dataprep.SiteService.Visibility; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestPersonFavoritesModel; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class GetFavoriteFullTests extends RestTest -{ - private UserModel adminUserModel; - private SiteModel siteModel; - private FolderModel folderModel; - private FileModel fileModel; - private ListUserWithRoles usersWithRoles; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception { - - adminUserModel = dataUser.getAdminUser(); - restClient.authenticateUser(adminUserModel); - - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - - folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); - fileModel = dataContent.usingUser(adminUserModel).usingResource(folderModel) - .createContent(DocumentType.TEXT_PLAIN); - - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, - UserRole.SiteConsumer, UserRole.SiteContributor); - } - - @Bug(id = "MNT-16904") - @TestRail(section = { TestGroup.REST_API, - TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify the get favorite request for invalid network id") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL, TestGroup.NETWORKS }) - public void getFavoriteSiteWithInvalidNetworkId() throws Exception - { - UserModel adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUserModel); - restClient.usingTenant().createTenant(adminTenantUser); - UserModel tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - - siteModel = dataSite.usingUser(tenantUser).createPublicRandomSite(); - restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - - tenantUser.setDomain("invalidNetwork"); - restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().getFavorite(siteModel.getGuid()); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - - @TestRail(section = { TestGroup.REST_API, - TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify the get favorite request with tenant user") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL, TestGroup.NETWORKS }) - public void getFavoriteSiteWithTenantUser() throws Exception - { - UserModel adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUserModel).usingTenant().createTenant(adminTenantUser); - UserModel tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - - siteModel = dataSite.usingUser(tenantUser).createPublicRandomSite(); - restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - - restClient.withCoreAPI().usingAuthUser().getFavorite(siteModel.getGuid()); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify Admin user gets favorite site with Rest API and validate details") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) - public void verifyRequestforGetFavoriteSite() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel); - restClient.withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); - - RestPersonFavoritesModel favoriteSite = restClient.withCoreAPI().usingUser(adminUserModel).getFavorite(siteModel.getGuid()); - restClient.assertStatusCodeIs(HttpStatus.OK); - favoriteSite.assertThat().field("targetGuid").is(siteModel.getGuid()); - favoriteSite.getTarget().getSite() - .assertThat().field("guid").is(siteModel.getGuid()); - } - - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify Admin user gets favorite site with properties filter") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) - public void verifyRequestforGetFavoriteSiteWithProperties() throws JsonToModelConversionException, Exception - { - UserModel manager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); - restClient.authenticateUser(manager); - restClient.withCoreAPI().usingUser(manager).addSiteToFavorites(siteModel); - - RestPersonFavoritesModel favoriteSite = restClient.authenticateUser(manager).withParams("properties=targetGuid") - .withCoreAPI().usingAuthUser().getFavorite(siteModel.getGuid()); - restClient.assertStatusCodeIs(HttpStatus.OK); - favoriteSite.assertThat().field("targetGuid").is(siteModel.getGuid()); - favoriteSite.assertThat().fieldsCount().is(1); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify Admin user gets favorite site with inccorect properties filter") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) - public void verifyRequestforGetFavoriteSiteWithInccorectProperties() throws JsonToModelConversionException, Exception - { - UserModel collaborator = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); - restClient.authenticateUser(collaborator); - restClient.withCoreAPI().usingUser(collaborator).addFileToFavorites(fileModel); - - RestPersonFavoritesModel favoriteFile = restClient.authenticateUser(collaborator).withParams("properties=tas") - .withCoreAPI().usingAuthUser().getFavorite(fileModel.getNodeRefWithoutVersion()); - restClient.assertStatusCodeIs(HttpStatus.OK); - favoriteFile.assertThat().fieldsCount().is(0); - } - - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify all values from get favorite rest api for a file") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) - public void verifyRequestFieldsforGetFavoriteFile() throws JsonToModelConversionException, Exception - { - UserModel contributor = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); - restClient.authenticateUser(contributor); - restClient.withCoreAPI().usingUser(contributor).addFileToFavorites(fileModel); - - RestPersonFavoritesModel favoriteFile = restClient.authenticateUser(contributor) - .withCoreAPI().usingAuthUser().getFavorite(fileModel.getNodeRefWithoutVersion()); - restClient.assertStatusCodeIs(HttpStatus.OK); - - favoriteFile.assertThat().field("targetGuid").is(fileModel.getNodeRefWithoutVersion()) - .and().field("target.file.isFile").is("true") - .and().field("target.file.mimeType").is("text/plain") - .and().field("target.file.isFolder").is("false") - .and().field("target.file.createdBy").is(adminUserModel.getUsername()) - .and().field("target.file.versionLabel").is("1.0") - .and().field("target.file.name").is(fileModel.getName()) - .and().field("target.file.parentId").is(folderModel.getNodeRef()) - .and().field("target.file.guid").is(fileModel.getNodeRefWithoutVersion()) - .and().field("target.file.modifiedBy").is(adminUserModel.getUsername()) - .and().field("target.file.id").is(fileModel.getNodeRefWithoutVersion()); - } - - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify all values from get favorite rest api for a site") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) - public void verifyRequestFieldsforGetFavoriteSite() throws JsonToModelConversionException, Exception - { - UserModel contributor = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); - restClient.authenticateUser(contributor); - restClient.withCoreAPI().usingUser(contributor).addFavoriteSite(siteModel); - - RestPersonFavoritesModel favoriteSite = restClient.authenticateUser(contributor) - .withCoreAPI().usingAuthUser().getFavorite(siteModel.getGuid()); - restClient.assertStatusCodeIs(HttpStatus.OK); - - favoriteSite.assertThat().field("targetGuid").is(siteModel.getGuid()) - .and().field("target.site.role").is(UserRole.SiteContributor.toString()) - .and().field("target.site.visibility").is(Visibility.PUBLIC.toString()) - .and().field("target.site.guid").is(siteModel.getGuid()) - .and().field("target.site.description").is(siteModel.getDescription()) - .and().field("target.site.id").is(siteModel.getId()) - .and().field("target.site.preset").is("site-dashboard") - .and().field("target.site.title").is(siteModel.getTitle()); - } - - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify all values from get favorite rest api for a folder") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) - public void verifyRequestFieldsforGetFavoriteFolder() throws JsonToModelConversionException, Exception - { - UserModel contributor = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); - restClient.authenticateUser(contributor); - restClient.withCoreAPI().usingUser(contributor).addFolderToFavorites(folderModel); - - RestPersonFavoritesModel favoriteFolder = restClient.authenticateUser(contributor) - .withCoreAPI().usingAuthUser().getFavorite(folderModel.getNodeRef()); - restClient.assertStatusCodeIs(HttpStatus.OK); - - favoriteFolder.assertThat().field("targetGuid").is(folderModel.getNodeRef()) - .and().field("target.folder.isFile").is("false") - .and().field("target.folder.isFolder").is("true") - .and().field("target.folder.createdBy").is(adminUserModel.getUsername()) - .and().field("target.folder.name").is(folderModel.getName()) - .and().field("target.folder.guid").is(folderModel.getNodeRef()) - .and().field("target.folder.modifiedBy").is(adminUserModel.getUsername()) - .and().field("target.folder.id").is(folderModel.getNodeRef()); - } -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java deleted file mode 100644 index cde2cb9ae..000000000 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSanityTests.java +++ /dev/null @@ -1,293 +0,0 @@ -package org.alfresco.rest.favorites; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestPersonFavoritesModel; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class GetFavoriteSanityTests extends RestTest -{ - private UserModel adminUserModel; - private SiteModel siteModel; - private FolderModel folderModel; - private FileModel fileModel; - private ListUserWithRoles usersWithRoles; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - restClient.authenticateUser(adminUserModel); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - - folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); - fileModel = dataContent.usingUser(adminUserModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Verify Admin user gets favorite site with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - public void adminIsAbleToRetrieveFavoritesSite() throws JsonToModelConversionException, Exception - { - restClient.withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); - - RestPersonFavoritesModel favoriteSite = restClient.withCoreAPI().usingUser(adminUserModel).getFavorite(siteModel.getGuid()); - restClient.assertStatusCodeIs(HttpStatus.OK); - favoriteSite.assertThat().field("targetGuid").is(siteModel.getGuid()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Verify Admin user gets favorite folder with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - public void adminIsAbleToRetrieveFavoritesFolder() throws JsonToModelConversionException, Exception - { - restClient.withCoreAPI().usingUser(adminUserModel).addFolderToFavorites(folderModel); - - RestPersonFavoritesModel favoriteFolder = restClient.withCoreAPI().usingUser(adminUserModel).getFavorite(folderModel.getNodeRef()); - restClient.assertStatusCodeIs(HttpStatus.OK); - favoriteFolder.assertThat().field("targetGuid").is(folderModel.getNodeRef()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Verify Admin user gets favorite file with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - public void adminIsAbleToRetrieveFavoritesFile() throws JsonToModelConversionException, Exception - { - restClient.withCoreAPI().usingUser(adminUserModel).addFileToFavorites(fileModel); - - RestPersonFavoritesModel favoriteFile = restClient.withCoreAPI().usingUser(adminUserModel).getFavorite(fileModel.getNodeRefWithoutVersion()); - restClient.assertStatusCodeIs(HttpStatus.OK); - favoriteFile.assertThat().field("targetGuid").is(fileModel.getNodeRefWithoutVersion()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Verify Manager user gets favorite site with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - public void managerIsAbleToRetrieveFavoriteSite() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - - RestPersonFavoritesModel favSite = restClient.withCoreAPI().usingAuthUser().getFavorite(siteModel.getGuid()); - restClient.assertStatusCodeIs(HttpStatus.OK); - favSite.assertThat().field("targetGuid").is(siteModel.getGuid()); - - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Verify Manager user gets favorite folder with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - public void managerIsAbleToRetrieveFavoriteFolder() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(folderModel); - - RestPersonFavoritesModel favoriteFolder = restClient.withCoreAPI().usingAuthUser().getFavorite(folderModel.getNodeRef()); - restClient.assertStatusCodeIs(HttpStatus.OK); - favoriteFolder.assertThat().field("targetGuid").is(folderModel.getNodeRef()); - - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Verify Manager user gets favorite file with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - public void managerIsAbleToRetrieveFavoriteFile() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingAuthUser().addFileToFavorites(fileModel); - - RestPersonFavoritesModel favoriteFile = restClient.withCoreAPI().usingAuthUser().getFavorite(fileModel.getNodeRefWithoutVersion()); - restClient.assertStatusCodeIs(HttpStatus.OK); - favoriteFile.assertThat().field("targetGuid").is(fileModel.getNodeRefWithoutVersion()); - } - - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Verify Collaborator user gets favorite site with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - public void collaboratorIsAbleToRetrieveFavoriteSite() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - - RestPersonFavoritesModel favSite = restClient.withCoreAPI().usingAuthUser().getFavorite(siteModel.getGuid()); - restClient.assertStatusCodeIs(HttpStatus.OK); - favSite.assertThat().field("targetGuid").is(siteModel.getGuid()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Verify collaborator user gets favorite folder with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - public void collaboratorIsAbleToRetrieveFavoriteFolder() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(folderModel); - - RestPersonFavoritesModel favoriteFolder = restClient.withCoreAPI().usingAuthUser().getFavorite(folderModel.getNodeRef()); - restClient.assertStatusCodeIs(HttpStatus.OK); - favoriteFolder.assertThat().field("targetGuid").is(folderModel.getNodeRef()); - - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Verify collaborator user gets favorite file with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - public void collaboratorIsAbleToRetrieveFavoriteFile() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.withCoreAPI().usingAuthUser().addFileToFavorites(fileModel); - - RestPersonFavoritesModel favoriteFile = restClient.withCoreAPI().usingAuthUser().getFavorite(fileModel.getNodeRefWithoutVersion()); - restClient.assertStatusCodeIs(HttpStatus.OK); - favoriteFile.assertThat().field("targetGuid").is(fileModel.getNodeRefWithoutVersion()); - } - - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Verify Contributor user gets favorite site with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - public void contributorIsAbleToRetrieveFavoriteSite() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - - RestPersonFavoritesModel favSite = restClient.withCoreAPI().usingAuthUser().getFavorite(siteModel.getGuid()); - restClient.assertStatusCodeIs(HttpStatus.OK); - favSite.assertThat().field("targetGuid").is(siteModel.getGuid()); ; - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Verify contributor user gets favorite folder with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - public void contributorIsAbleToRetrieveFavoriteFolder() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(folderModel); - - RestPersonFavoritesModel favoriteFolder = restClient.withCoreAPI().usingAuthUser().getFavorite(folderModel.getNodeRef()); - restClient.assertStatusCodeIs(HttpStatus.OK); - favoriteFolder.assertThat().field("targetGuid").is(folderModel.getNodeRef()); - - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Verify contributor user gets favorite file with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - public void contributorIsAbleToRetrieveFavoriteFile() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - restClient.withCoreAPI().usingAuthUser().addFileToFavorites(fileModel); - - RestPersonFavoritesModel favoriteFile = restClient.withCoreAPI().usingAuthUser().getFavorite(fileModel.getNodeRefWithoutVersion()); - restClient.assertStatusCodeIs(HttpStatus.OK); - favoriteFile.assertThat().field("targetGuid").is(fileModel.getNodeRefWithoutVersion()); - } - - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Verify Consumer user gets favorite site with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - public void consumerIsAbleToRetrieveFavorites() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - - RestPersonFavoritesModel favSite = restClient.withCoreAPI().usingAuthUser().getFavorite(siteModel.getGuid()); - restClient.assertStatusCodeIs(HttpStatus.OK); - favSite.assertThat().field("targetGuid").is(siteModel.getGuid()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Verify consumer user gets favorite folder with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - public void consumerIsAbleToRetrieveFavoriteFolder() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(folderModel); - - RestPersonFavoritesModel favoriteFolder = restClient.withCoreAPI().usingAuthUser().getFavorite(folderModel.getNodeRef()); - restClient.assertStatusCodeIs(HttpStatus.OK); - favoriteFolder.assertThat().field("targetGuid").is(folderModel.getNodeRef()); - - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Verify consumer user gets favorite file with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - public void consumerIsAbleToRetrieveFavoriteFile() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.withCoreAPI().usingAuthUser().addFileToFavorites(fileModel); - - RestPersonFavoritesModel favoriteFile = restClient.withCoreAPI().usingAuthUser().getFavorite(fileModel.getNodeRefWithoutVersion()); - restClient.assertStatusCodeIs(HttpStatus.OK); - favoriteFile.assertThat().field("targetGuid").is(fileModel.getNodeRefWithoutVersion()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Verify user doesn't get favorite site of another user with Rest API and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES }) - public void userIsNotAbleToRetrieveFavoriteSiteOfAnotherUser() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.withCoreAPI().usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .getFavorite(siteModel.getGuid()); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator).getUsername())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Verify user doesn't get favorite site of admin user with Rest API and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES }) - public void userIsNotAbleToRetrieveFavoritesOfAdminUser() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .withCoreAPI().usingUser(adminUserModel).getFavorite(siteModel.getGuid()); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, adminUserModel.getUsername())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Verify admin user doesn't get favorite site of another user with Rest API and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES }) - public void adminIsNotAbleToRetrieveFavoritesOfAnotherUser() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI() - .usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).getFavorite(siteModel.getGuid()); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator).getUsername())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Verify user gets status code 401 if authentication call fails") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - @Bug(id = "MNT-16904", description = "fails only on environment with tenants") - public void userIsNotAbleToRetrieveFavoriteSiteIfAuthenticationFails() throws JsonToModelConversionException, Exception - { - UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); - siteManager.setPassword("wrongPassword"); - restClient.authenticateUser(siteManager).withCoreAPI() - .usingUser(siteManager).getFavorite(siteModel.getGuid()); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSiteCoreTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSiteCoreTests.java deleted file mode 100644 index 5e8d78deb..000000000 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSiteCoreTests.java +++ /dev/null @@ -1,62 +0,0 @@ -package org.alfresco.rest.favorites; - -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.utility.data.DataUser; -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; - -/** - * Created by Claudia Agache on 11/22/2016. - */ - -public class GetFavoriteSiteCoreTests extends RestTest -{ - UserModel userModel; - SiteModel site1; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - site1 = dataSite.usingUser(userModel).createPublicRandomSite(); - dataSite.usingUser(userModel).usingSite(site1).addSiteToFavorites(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify invalid request returns status 404 when personId does not exist") - public void getFavoriteSiteWithNonExistentPersonId() throws Exception - { - UserModel someUser = new UserModel("someUser", DataUser.PASSWORD); - - restClient.authenticateUser(userModel).withCoreAPI().usingUser(someUser).getFavoriteSite(site1); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "someUser")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify invalid request returns status 404 when siteId does not exist") - public void getFavoriteSiteWithNonExistentSiteId() throws Exception - { - SiteModel nonExistentSite = new SiteModel("nonExistentSite"); - - restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().getFavoriteSite(nonExistentSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, userModel.getUsername(), nonExistentSite.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify User fails to get specific favorite site of admin with Rest API and response is 403") - public void userFailsToGetFavoriteSiteOfAdmin() throws Exception - { - restClient.authenticateUser(userModel).withCoreAPI().usingUser(dataUser.getAdminUser()).getFavoriteSite(site1); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - -} diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSiteFullTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSiteFullTests.java deleted file mode 100644 index 87fbffd25..000000000 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSiteFullTests.java +++ /dev/null @@ -1,177 +0,0 @@ -package org.alfresco.rest.favorites; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.dataprep.SiteService.Visibility; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.core.RestRequest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestSiteModel; -import org.alfresco.rest.model.RestSiteModelsCollection; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.apache.commons.lang3.RandomStringUtils; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Created by Bogdan Bocancea - */ -public class GetFavoriteSiteFullTests extends RestTest -{ - UserModel userModel; - SiteModel site1; - private RestSiteModel restSiteModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - site1 = dataSite.usingUser(userModel).createPublicRandomSite(); - dataSite.usingUser(userModel).usingSite(site1).addSiteToFavorites(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify invalid request returns status 404 when personId is invalid") - public void getFavoriteSiteWithInvalidPersonId() throws Exception - { - UserModel userSpecialChars = dataUser.usingAdmin().createUser(RandomStringUtils.randomAlphabetic(2) + "~!@#$%^&*()_+[]{}|;'d", "password"); - userSpecialChars.setUsername(RandomStringUtils.randomAlphabetic(2) + "~!%40%23%24%25%5E%26*()_%2B%5B%5D%7B%7D%7C%5C%3B%27%3A%22%2C.%2F%3C%3E"); - - restClient.authenticateUser(userModel).withCoreAPI().usingUser(userSpecialChars).getFavoriteSite(site1); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, userSpecialChars.getUsername())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify request with empty site id") - public void getFavoriteSiteWithEmptySiteId() throws Exception - { - restClient.authenticateUser(userModel).withCoreAPI(); - RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "people/{personId}/favorite-sites/{siteId}?{parameters}", - userModel.getUsername(), "", restClient.getParameters()); - RestSiteModelsCollection sites = restClient.processModels(RestSiteModelsCollection.class, request); - restClient.assertStatusCodeIs(HttpStatus.OK); - sites.assertThat().entriesListIsNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify invalid request returns status 401 when user is empty") - public void getFavoriteSiteWithEmptyPersonId() throws Exception - { - UserModel emptyUser = new UserModel("", "password"); - restClient.authenticateUser(emptyUser).withCoreAPI().usingAuthUser().getFavoriteSite(site1); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify invalid request returns status 404 when another user get favorite site of an user") - public void getFavoriteSiteWithAnotherUser() throws Exception - { - UserModel user = dataUser.createRandomTestUser(); - restClient.authenticateUser(user).withCoreAPI().usingAuthUser().getFavoriteSite(site1); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, user.getUsername(), site1.getId())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE) - .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify request returns status 200 when using -me-") - public void getFavoriteSiteUsingMe() throws Exception - { - restSiteModel = restClient.authenticateUser(userModel).withCoreAPI().usingMe().getFavoriteSite(site1); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModel.assertThat().field("id").is(site1.getId()) - .and().field("title").is(site1.getTitle()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify entry details for get site favorite response with Rest API") - public void checkResponseSchemaForGetSiteFavorite() throws Exception - { - restSiteModel = restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().getFavoriteSite(site1); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModel.assertThat().field("id").is(site1.getId()) - .and().field("title").is(site1.getTitle()) - .and().field("role").is(UserRole.SiteManager.toString()) - .and().field("visibility").is(Visibility.PUBLIC.toString()) - .and().field("guid").isNotEmpty() - .and().field("description").is(site1.getDescription()) - .and().field("preset").is("site-dashboard"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify invalid request returns status 404 when providing folder name instead of site id") - public void getFavoriteSiteUsingFolder() throws Exception - { - FolderModel folder = dataContent.usingUser(userModel).usingSite(site1).createFolder(); - SiteModel siteFolder = new SiteModel(folder.getName()); - restSiteModel = restClient.authenticateUser(userModel).withCoreAPI().usingMe().getFavoriteSite(siteFolder); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, userModel.getUsername(), folder.getName())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify invalid request returns status 404 when providing file name instead of site id") - public void getFavoriteSiteUsingFile() throws Exception - { - FileModel file = dataContent.usingSite(site1).createContent(DocumentType.TEXT_PLAIN); - SiteModel siteFolder = new SiteModel(file.getName()); - restSiteModel = restClient.authenticateUser(userModel).withCoreAPI().usingMe().getFavoriteSite(siteFolder); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, userModel.getUsername(), file.getName())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify request returns status 200 when using valid parameters") - public void getFavoriteSiteUsingParameters() throws Exception - { - restSiteModel = restClient.withParams("maxItems=100").authenticateUser(userModel).withCoreAPI().usingMe().getFavoriteSite(site1); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModel.assertThat().field("id").is(site1.getId()) - .and().field("title").is(site1.getTitle()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify request returns status 400 when using maxItems=0") - public void getFavoriteSiteUsingInvalidMaxItems() throws Exception - { - restSiteModel = restClient.withParams("maxItems=0").authenticateUser(userModel).withCoreAPI().usingMe().getFavoriteSite(site1); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify request returns status 401 when using invalid network") - public void getFavoriteSiteUsingInvalidNetwork() throws Exception - { - UserModel invalidUserNetwork = dataUser.createRandomTestUser(); - SiteModel site = dataSite.usingUser(invalidUserNetwork).createPublicRandomSite(); - dataSite.usingUser(invalidUserNetwork).usingSite(site).addSiteToFavorites(); - invalidUserNetwork.setDomain("invalidNetwork"); - restSiteModel = restClient.authenticateUser(invalidUserNetwork).withCoreAPI().usingMe().getFavoriteSite(site); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } -} diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSiteSanityTests.java deleted file mode 100644 index eaee26af5..000000000 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSiteSanityTests.java +++ /dev/null @@ -1,137 +0,0 @@ -package org.alfresco.rest.favorites; - -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestSiteModel; -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.report.Bug; -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; - -/** - * Tests for Get Favorite Sites (/people/{personId}/preferences) RestAPI call - * - * @author Cristina Axinte - */ - -public class GetFavoriteSiteSanityTests extends RestTest -{ - UserModel userModel; - SiteModel siteModel1; - SiteModel siteModel2; - UserModel searchedUser; - private RestSiteModel restSiteModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - siteModel1 = dataSite.usingUser(userModel).createPublicRandomSite(); - siteModel2 = dataSite.usingUser(userModel).createPublicRandomSite(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user gets its specific favorite site with Rest API and response is successful (200)") - public void managerUserGetsFavoriteSiteWithSuccess() throws Exception - { - UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel1, UserRole.SiteManager); - dataSite.usingUser(managerUser).usingSite(siteModel1).addSiteToFavorites(); - dataSite.usingUser(managerUser).usingSite(siteModel2).addSiteToFavorites(); - - restSiteModel = restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().getFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModel.assertThat().field("id").is(siteModel1.getId()).and().field("title").isNotNull(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify collaborator user gets its specific favorite site with Rest API and response is successful (200)") - public void collaboratorUserGetsFavoriteSiteWithSuccess() throws Exception - { - UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(collaboratorUser, siteModel1, UserRole.SiteCollaborator); - dataSite.usingUser(collaboratorUser).usingSite(siteModel1).addSiteToFavorites(); - dataSite.usingUser(collaboratorUser).usingSite(siteModel2).addSiteToFavorites(); - - restSiteModel = restClient.authenticateUser(collaboratorUser).withCoreAPI().usingAuthUser().getFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModel.assertThat().field("id").is(siteModel1.getId()).and().field("title").isNotNull(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify contributor user gets its specific favorite site with Rest API and response is successful (200)") - public void contributorUserGetsFavoriteSiteWithSuccess() throws Exception - { - UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(contributorUser, siteModel1, UserRole.SiteContributor); - dataSite.usingUser(contributorUser).usingSite(siteModel1).addSiteToFavorites(); - dataSite.usingUser(contributorUser).usingSite(siteModel2).addSiteToFavorites(); - - restSiteModel = restClient.authenticateUser(contributorUser).withCoreAPI().usingAuthUser().getFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModel.assertThat().field("id").is(siteModel1.getId()).and().field("title").isNotNull(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify consumer user gets its specific favorite site with Rest API and response is successful (200)") - public void consumerUserGetsFavoriteSiteWithSuccess() throws Exception - { - UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel1, UserRole.SiteConsumer); - dataSite.usingUser(consumerUser).usingSite(siteModel1).addSiteToFavorites(); - dataSite.usingUser(consumerUser).usingSite(siteModel2).addSiteToFavorites(); - - restSiteModel = restClient.authenticateUser(consumerUser).withCoreAPI().usingAuthUser().getFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModel.assertThat().field("id").is(siteModel1.getId()).and().field("title").isNotNull(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify admin user gets specific favorite site of any user with Rest API and response is successful (200)") - public void adminUserGetsAnyFavoriteSiteWithSuccess() throws Exception - { - UserModel adminUset = dataUser.getAdminUser(); - UserModel anyUser = dataUser.usingAdmin().createRandomTestUser(); - dataSite.usingUser(anyUser).usingSite(siteModel1).addSiteToFavorites(); - dataSite.usingUser(anyUser).usingSite(siteModel2).addSiteToFavorites(); - - restSiteModel = restClient.authenticateUser(adminUset).withCoreAPI().usingUser(anyUser).getFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModel.assertThat().field("id").is(siteModel1.getId()).and().field("title").isNotNull(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user fails to get specific favorite site of another user with Rest API and response is successful (403)") - public void managerUserFailsToGetFavoriteSiteOfAnotherUser() throws Exception - { - UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel1, UserRole.SiteManager); - dataSite.usingUser(managerUser).usingSite(siteModel1).addSiteToFavorites(); - dataSite.usingUser(managerUser).usingSite(siteModel2).addSiteToFavorites(); - - restClient.authenticateUser(managerUser).withCoreAPI().usingUser(userModel).getFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized gets its specific favorite site with Rest API when authentication fails (401)") - @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void managerUserNotAuthorizedFailsToGetFavoriteSite() throws Exception - { - UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel1, UserRole.SiteManager); - dataSite.usingUser(managerUser).usingSite(siteModel1).addSiteToFavorites(); - dataSite.usingUser(managerUser).usingSite(siteModel2).addSiteToFavorites(); - managerUser.setPassword("newpassword"); - - restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().getFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } -} diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSiteTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSiteTests.java new file mode 100644 index 000000000..4c5803c6d --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSiteTests.java @@ -0,0 +1,302 @@ +package org.alfresco.rest.favorites; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.dataprep.SiteService; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestSiteModel; +import org.alfresco.rest.model.RestSiteModelsCollection; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.model.*; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.apache.commons.lang3.RandomStringUtils; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Tests for Get Favorite Sites (/people/{personId}/preferences) RestAPI call + * + * @author Cristina Axinte + */ + +public class GetFavoriteSiteTests extends RestTest +{ + private UserModel userModel; + private SiteModel siteModel1; + private SiteModel siteModel2; + private RestSiteModel restSiteModel; + private DataUser.ListUserWithRoles usersWithRoles; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + siteModel1 = dataSite.usingUser(userModel).createPublicRandomSite(); + siteModel2 = dataSite.usingUser(userModel).createPublicRandomSite(); + + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel1, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + + dataSite.usingUser(userModel).usingSite(siteModel1).addSiteToFavorites(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user gets its specific favorite site with Rest API and response is successful (200)") + public void managerUserGetsFavoriteSiteWithSuccess() throws Exception + { + UserModel managerUser = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); + + dataSite.usingUser(managerUser).usingSite(siteModel1).addSiteToFavorites(); + dataSite.usingUser(managerUser).usingSite(siteModel2).addSiteToFavorites(); + + restSiteModel = restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().getFavoriteSite(siteModel1); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteModel.assertThat().field("id").is(siteModel1.getId()).and().field("title").isNotNull(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify collaborator user gets its specific favorite site with Rest API and response is successful (200)") + public void collaboratorUserGetsFavoriteSiteWithSuccess() throws Exception + { + UserModel collaboratorUser = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); + + dataSite.usingUser(collaboratorUser).usingSite(siteModel1).addSiteToFavorites(); + dataSite.usingUser(collaboratorUser).usingSite(siteModel2).addSiteToFavorites(); + + restSiteModel = restClient.authenticateUser(collaboratorUser).withCoreAPI().usingAuthUser().getFavoriteSite(siteModel1); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteModel.assertThat().field("id").is(siteModel1.getId()).and().field("title").isNotNull(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify contributor user gets its specific favorite site with Rest API and response is successful (200)") + public void contributorUserGetsFavoriteSiteWithSuccess() throws Exception + { + UserModel contributorUser = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); + + dataSite.usingUser(contributorUser).usingSite(siteModel1).addSiteToFavorites(); + dataSite.usingUser(contributorUser).usingSite(siteModel2).addSiteToFavorites(); + + restSiteModel = restClient.authenticateUser(contributorUser).withCoreAPI().usingAuthUser().getFavoriteSite(siteModel1); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteModel.assertThat().field("id").is(siteModel1.getId()).and().field("title").isNotNull(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify consumer user gets its specific favorite site with Rest API and response is successful (200)") + public void consumerUserGetsFavoriteSiteWithSuccess() throws Exception + { + UserModel consumerUser = usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer); + + dataSite.usingUser(consumerUser).usingSite(siteModel1).addSiteToFavorites(); + dataSite.usingUser(consumerUser).usingSite(siteModel2).addSiteToFavorites(); + + restSiteModel = restClient.authenticateUser(consumerUser).withCoreAPI().usingAuthUser().getFavoriteSite(siteModel1); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteModel.assertThat().field("id").is(siteModel1.getId()).and().field("title").isNotNull(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin user gets specific favorite site of any user with Rest API and response is successful (200)") + public void adminUserGetsAnyFavoriteSiteWithSuccess() throws Exception + { + UserModel adminUser = dataUser.getAdminUser(); + UserModel anyUser = dataUser.usingAdmin().createRandomTestUser(); + dataSite.usingUser(anyUser).usingSite(siteModel1).addSiteToFavorites(); + dataSite.usingUser(anyUser).usingSite(siteModel2).addSiteToFavorites(); + + restSiteModel = restClient.authenticateUser(adminUser).withCoreAPI().usingUser(anyUser).getFavoriteSite(siteModel1); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteModel.assertThat().field("id").is(siteModel1.getId()).and().field("title").isNotNull(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify manager user fails to get specific favorite site of another user with Rest API and response is successful (403)") + public void managerUserFailsToGetFavoriteSiteOfAnotherUser() throws Exception + { + UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel1, UserRole.SiteManager); + dataSite.usingUser(managerUser).usingSite(siteModel1).addSiteToFavorites(); + dataSite.usingUser(managerUser).usingSite(siteModel2).addSiteToFavorites(); + + restClient.authenticateUser(managerUser).withCoreAPI().usingUser(userModel).getFavoriteSite(siteModel1); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized gets its specific favorite site with Rest API when authentication fails (401)") +// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") + public void managerUserNotAuthorizedFailsToGetFavoriteSite() throws Exception + { + UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel1, UserRole.SiteManager); + dataSite.usingUser(managerUser).usingSite(siteModel1).addSiteToFavorites(); + dataSite.usingUser(managerUser).usingSite(siteModel2).addSiteToFavorites(); + managerUser.setPassword("newpassword"); + + restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().getFavoriteSite(siteModel1); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify invalid request returns status 404 when personId does not exist") + public void getFavoriteSiteWithNonExistentPersonId() throws Exception + { + UserModel someUser = new UserModel("someUser", DataUser.PASSWORD); + + restClient.authenticateUser(userModel).withCoreAPI().usingUser(someUser).getFavoriteSite(siteModel1); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "someUser")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify invalid request returns status 404 when siteId does not exist") + public void getFavoriteSiteWithNonExistentSiteId() throws Exception + { + SiteModel nonExistentSite = new SiteModel("nonExistentSite"); + + restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().getFavoriteSite(nonExistentSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, userModel.getUsername(), nonExistentSite.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify User fails to get specific favorite site of admin with Rest API and response is 403") + public void userFailsToGetFavoriteSiteOfAdmin() throws Exception + { + restClient.authenticateUser(userModel).withCoreAPI().usingUser(dataUser.getAdminUser()).getFavoriteSite(siteModel1); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify invalid request returns status 404 when personId is invalid") + public void getFavoriteSiteWithInvalidPersonId() throws Exception + { + UserModel userSpecialChars = dataUser.usingAdmin().createUser(RandomStringUtils.randomAlphabetic(2) + "~!@#$%^&*()_+[]{}|;'d", "password"); + userSpecialChars.setUsername(RandomStringUtils.randomAlphabetic(2) + "~!%40%23%24%25%5E%26*()_%2B%5B%5D%7B%7D%7C%5C%3B%27%3A%22%2C.%2F%3C%3E"); + + restClient.authenticateUser(userModel).withCoreAPI().usingUser(userSpecialChars).getFavoriteSite(siteModel1); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, userSpecialChars.getUsername())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify request with empty site id") + public void getFavoriteSiteWithEmptySiteId() throws Exception + { + restClient.authenticateUser(userModel).withCoreAPI(); + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "people/{personId}/favorite-sites/{siteId}?{parameters}", + userModel.getUsername(), "", restClient.getParameters()); + RestSiteModelsCollection sites = restClient.processModels(RestSiteModelsCollection.class, request); + restClient.assertStatusCodeIs(HttpStatus.OK); + sites.assertThat().entriesListIsNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify invalid request returns status 401 when user is empty") + public void getFavoriteSiteWithEmptyPersonId() throws Exception + { + UserModel emptyUser = new UserModel("", "password"); + restClient.authenticateUser(emptyUser).withCoreAPI().usingAuthUser().getFavoriteSite(siteModel1); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify invalid request returns status 404 when another user get favorite site of an user") + public void getFavoriteSiteWithAnotherUser() throws Exception + { + UserModel user = dataUser.createRandomTestUser(); + restClient.authenticateUser(user).withCoreAPI().usingAuthUser().getFavoriteSite(siteModel1); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, user.getUsername(), siteModel1.getId())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE) + .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify request returns status 200 when using -me-") + public void getFavoriteSiteUsingMe() throws Exception + { + restSiteModel = restClient.authenticateUser(userModel).withCoreAPI().usingMe().getFavoriteSite(siteModel1); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteModel.assertThat().field("id").is(siteModel1.getId()) + .and().field("title").is(siteModel1.getTitle()) + .and().field("role").is(UserRole.SiteManager.toString()) + .and().field("visibility").is(SiteService.Visibility.PUBLIC.toString()) + .and().field("guid").isNotEmpty() + .and().field("description").is(siteModel1.getDescription()) + .and().field("preset").is("site-dashboard"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify invalid request returns status 404 when providing folder name instead of site id") + public void getFavoriteSiteUsingFolder() throws Exception + { + FolderModel folder = dataContent.usingUser(userModel).usingSite(siteModel1).createFolder(); + SiteModel siteFolder = new SiteModel(folder.getName()); + restSiteModel = restClient.authenticateUser(userModel).withCoreAPI().usingMe().getFavoriteSite(siteFolder); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, userModel.getUsername(), folder.getName())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify invalid request returns status 404 when providing file name instead of site id") + public void getFavoriteSiteUsingFile() throws Exception + { + FileModel file = dataContent.usingSite(siteModel1).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + SiteModel siteFolder = new SiteModel(file.getName()); + restSiteModel = restClient.authenticateUser(userModel).withCoreAPI().usingMe().getFavoriteSite(siteFolder); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, userModel.getUsername(), file.getName())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify request returns status 200 when using valid parameters") + public void getFavoriteSiteUsingParameters() throws Exception + { + restSiteModel = restClient.withParams("maxItems=100").authenticateUser(userModel).withCoreAPI().usingMe().getFavoriteSite(siteModel1); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteModel.assertThat().field("id").is(siteModel1.getId()) + .and().field("title").is(siteModel1.getTitle()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify request returns status 400 when using maxItems=0") + public void getFavoriteSiteUsingInvalidMaxItems() throws Exception + { + restSiteModel = restClient.withParams("maxItems=0").authenticateUser(userModel).withCoreAPI().usingMe().getFavoriteSite(siteModel1); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify request returns status 401 when using invalid network") + public void getFavoriteSiteUsingInvalidNetwork() throws Exception + { + UserModel invalidUserNetwork = dataUser.createRandomTestUser(); + SiteModel site = dataSite.usingUser(invalidUserNetwork).createPublicRandomSite(); + dataSite.usingUser(invalidUserNetwork).usingSite(site).addSiteToFavorites(); + invalidUserNetwork.setDomain("invalidNetwork"); + restSiteModel = restClient.authenticateUser(invalidUserNetwork).withCoreAPI().usingMe().getFavoriteSite(site); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } +} diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSitesCoreTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSitesCoreTests.java deleted file mode 100644 index 99cab6a70..000000000 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSitesCoreTests.java +++ /dev/null @@ -1,131 +0,0 @@ -package org.alfresco.rest.favorites; - -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestSiteModelsCollection; -import org.alfresco.utility.data.DataUser; -import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class GetFavoriteSitesCoreTests extends RestTest -{ - UserModel userModel; - UserModel testUser1; - SiteModel siteModel; - private RestSiteModelsCollection restSiteModelsCollection; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - testUser1 = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - dataSite.usingUser(userModel).usingSite(siteModel).addSiteToFavorites(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify that getFavoriteSites request status code is 404 for a personId that does not exist") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - public void getFavoriteSitesReturns404ForAPersonIdThatDoesNotExist() throws Exception - { - UserModel invalidUser = new UserModel(RandomData.getRandomName("User"), DataUser.PASSWORD); - - restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingUser(invalidUser).getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, invalidUser.getUsername())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify that getFavoriteSites request status code is 403 if the user doesn't have access to the person favorite sites") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - public void userCannotGetFavoriteSitesForAnotherUser() throws Exception - { - restClient.authenticateUser(userModel).withCoreAPI().usingUser(testUser1).getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin has access to regular user site favorites") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - public void adminCanGetFavoriteSitesForARegularUser() throws Exception - { - restSiteModelsCollection = restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingUser(userModel).getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModelsCollection.assertThat().entriesListIsNotEmpty() - .assertThat().entriesListContains("id", siteModel.getId()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify that regular user can not see admin user site favorites") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - public void regularUserCannotGetFavoriteSitesForAdminUser() throws Exception - { - restClient.authenticateUser(testUser1).withCoreAPI().usingUser(dataUser.getAdminUser()).getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify that favorite site can be removed") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - public void verifyThatFavoriteSiteCanBeRemoved() throws Exception - { - UserModel randomTestUser = dataUser.createRandomTestUser(); - dataSite.usingUser(randomTestUser).usingSite(siteModel).addSiteToFavorites(); - - restSiteModelsCollection = restClient.authenticateUser(randomTestUser).withCoreAPI().usingAuthUser().getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModelsCollection.assertThat().entriesListIsNotEmpty() - .assertThat().entriesListContains("id", siteModel.getId()); - - dataSite.usingUser(randomTestUser).usingSite(siteModel).removeSiteFromFavorites(); - restSiteModelsCollection = restClient.withCoreAPI().usingAuthUser().getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModelsCollection.assertThat().entriesListIsEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify that if maxItems param is invalid status code returned is BAD_REQUEST (400)") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - public void getFavoriteSitesMaxItemsInvalidValueTest() throws Exception - { - restClient.authenticateUser(userModel).withParams("maxItems=-1").withCoreAPI().usingAuthUser().getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); - - restClient.authenticateUser(userModel).withParams("maxItems=abc").withCoreAPI().usingAuthUser().getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "abc")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify that if skipCount param is invalid status code returned is BAD_REQUEST (400)") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - public void getFavoriteSitesSkipCountInvalidValueTest() throws Exception - { - restClient.authenticateUser(userModel).withParams("skipCount=-1").withCoreAPI().usingAuthUser().getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT); - - restClient.authenticateUser(userModel).withParams("skipCount=abc").withCoreAPI().usingAuthUser().getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "abc")); - } -} diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSitesFullTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSitesFullTests.java deleted file mode 100644 index 662940c8e..000000000 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSitesFullTests.java +++ /dev/null @@ -1,159 +0,0 @@ -package org.alfresco.rest.favorites; - -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestSiteModel; -import org.alfresco.rest.model.RestSiteModelsCollection; -import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class GetFavoriteSitesFullTests extends RestTest -{ - UserModel userModel; - SiteModel siteModel; - SiteModel testSite1; - SiteModel testSite2; - private RestSiteModelsCollection restSiteModelsCollection; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - - siteModel = new SiteModel("A-" + RandomData.getRandomAlphanumeric()); - testSite1 = new SiteModel("B-" + RandomData.getRandomAlphanumeric()); - testSite2 = new SiteModel("C-" + RandomData.getRandomAlphanumeric()); - - dataSite.usingUser(userModel).createSite(siteModel); - dataSite.usingUser(userModel).createSite(testSite1); - dataSite.usingUser(userModel).createSite(testSite2); - - dataSite.usingUser(userModel).usingSite(testSite2).addSiteToFavorites(); - dataSite.usingUser(userModel).usingSite(testSite1).addSiteToFavorites(); - dataSite.usingUser(userModel).usingSite(siteModel).addSiteToFavorites(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify that getFavoriteSites request response status using -me- string in place of personId is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - public void userGetsFavoriteSiteWithSuccessUsingMEForRequest() throws Exception - { - restSiteModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingMe().getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModelsCollection.assertThat().entriesListIsNotEmpty() - .and().entriesListContains("id", siteModel.getId()) - .and().paginationExist(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify that getFavoriteSites request response status for a user that has no favorite sites is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - public void getFavoriteSiteRequestForUserWithNoFavoriteSitesIsSuccessful() throws Exception - { - UserModel randomTestUser = dataUser.createRandomTestUser(); - - restSiteModelsCollection = restClient.authenticateUser(randomTestUser).withCoreAPI().usingMe().getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModelsCollection.assertThat().entriesListIsEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify that getFavoriteSites request response status for a user with several favorite sites is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - public void getFavoriteSiteRequestForUserWithSeveralFavoriteSitesIsSuccessful() throws Exception - { - restSiteModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModelsCollection.assertThat().entriesListIsNotEmpty() - .and().entriesListContains("id", siteModel.getId()) - .and().entriesListContains("id", testSite1.getId()) - .and().entriesListContains("id", testSite2.getId()) - .and().paginationExist(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify that getFavoriteSites request can only be called with a positive maxItems param") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - public void userCanNotGetFavoriteSitesWith0MaxItems() throws Exception - { - restClient.authenticateUser(userModel).withParams("maxItems=0").withCoreAPI().usingAuthUser().getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsErrorKey(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) - .containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify that getFavoriteSites request response status code for a high skipCount param is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - public void userCanGetFavoriteSitesWithHighSkipCount() throws Exception - { - restSiteModelsCollection = restClient.authenticateUser(userModel).withParams("skipCount=999999999").withCoreAPI().usingAuthUser().getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModelsCollection.assertThat().entriesListIsEmpty() - .assertThat().paginationField("skipCount").is("999999999"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify admin gets favorite sites for username with special chars with Rest API and response status is NOT_FOUND (404)") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - public void getFavoriteSitesRequestForPersonIDWithSpecialCharacters() throws Exception - { - String randomData = RandomData.getRandomAlphanumeric(); - UserModel userSpecialChars = dataUser.usingAdmin().createUser(randomData + "~!@#$%^&[]{}|\\;':\",./<>", "password"); - //setting the encoded text for username - userSpecialChars.setUsername(randomData + "~!%40%23%24%25%5E%26%5B%5D%7B%7D%7C%5C%3B%27%3A%22%2C.%2F%3C%3E"); - - restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingUser(userSpecialChars).getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, randomData + "~!%40%23%24%25%5E%26%5B%5D%7B%7D%7C%5C%3B%27%3A%22%2C.%2F%3C%3E")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify that user can retrieve the last 2 favorite sites") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - public void userCanRetrieveLast2FavoriteSites() throws Exception - { - restSiteModelsCollection = restClient.authenticateUser(userModel).withParams("skipCount=1&maxCount=2"). - withCoreAPI().usingAuthUser().getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModelsCollection.assertThat().entriesListIsNotEmpty() - .assertThat().entriesListCountIs(2) - .assertThat().entriesListContains("id", testSite1.getId()) - .assertThat().entriesListContains("id", testSite2.getId()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify that getFavoriteSites request applies valid properties param") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - public void getFavoriteSitesRequestWithValidPropertiesParam() throws Exception - { - RestSiteModel restSiteModel = restClient.authenticateUser(userModel).withParams("properties=title") - .withCoreAPI().usingAuthUser().getFavoriteSites().getOneRandomEntry().onModel(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModel.assertThat().fieldsCount().is(1) - .assertThat().field("title").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify that getFavoriteSites request applies invalid properties param") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - public void getFavoriteSitesRequestWithInvalidPropertiesParam() throws Exception - { - restClient.authenticateUser(userModel).withParams("properties=tas").withCoreAPI().usingAuthUser() - .getFavoriteSites().getOneRandomEntry().onModel().assertThat().fieldsCount().is(0); - restClient.assertStatusCodeIs(HttpStatus.OK); - } -} diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSitesSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSitesSanityTests.java deleted file mode 100644 index fdac3c266..000000000 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSitesSanityTests.java +++ /dev/null @@ -1,123 +0,0 @@ -package org.alfresco.rest.favorites; - -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestSiteModelsCollection; -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.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class GetFavoriteSitesSanityTests extends RestTest -{ - UserModel userModel; - SiteModel siteModel; - private RestSiteModelsCollection restSiteModelsCollection; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user fails to get an user favorite sites with Rest API (403)") - public void managerUserFailsToGetAnUserFavoriteSites() throws Exception - { - UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); - UserModel anotherUser = dataUser.usingAdmin().createRandomTestUser(); - dataSite.usingUser(anotherUser).usingSite(siteModel).addSiteToFavorites(); - - restClient.authenticateUser(managerUser).withCoreAPI().usingUser(anotherUser).getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify collaborator user fails to get an user favorite sites with Rest API (403)") - public void collaboratorUserFailsToGetAnUserFavoriteSites() throws Exception - { - UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(collaboratorUser, siteModel, UserRole.SiteCollaborator); - UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(contributorUser, siteModel, UserRole.SiteContributor); - dataSite.usingUser(contributorUser).usingSite(siteModel).addSiteToFavorites(); - - restClient.authenticateUser(collaboratorUser).withCoreAPI().usingUser(contributorUser).getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify contributor user fails to get an user favorite sites with Rest API (403)") - public void contributorUserFailsToGetAnUserFavoriteSites() throws Exception - { - UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); - UserModel contributorUser2 = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(contributorUser, siteModel, UserRole.SiteContributor); - dataUser.usingUser(userModel).addUserToSite(contributorUser2, siteModel, UserRole.SiteContributor); - dataSite.usingUser(contributorUser2).usingSite(siteModel).addSiteToFavorites(); - - restClient.authenticateUser(contributorUser).withCoreAPI().usingUser(contributorUser2).getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify consumer user fails to get an user favorite sites with Rest API (403)") - public void consumerUserFailsToGetAnUserFavoriteSites() throws Exception - { - UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); - UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel, UserRole.SiteConsumer); - dataUser.usingUser(collaboratorUser).addUserToSite(collaboratorUser, siteModel, UserRole.SiteCollaborator); - dataSite.usingUser(collaboratorUser).usingSite(siteModel).addSiteToFavorites(); - - restClient.authenticateUser(consumerUser).withCoreAPI().usingUser(collaboratorUser).getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify admin user gets its favorite sites with Rest API and response is successful (200)") - public void adminUserGetsFavoriteSitesWithSuccess() throws Exception - { - UserModel adminUser = dataUser.getAdminUser(); - UserModel anotherUser = dataUser.usingAdmin().createRandomTestUser(); - dataSite.usingUser(anotherUser).usingSite(siteModel).addSiteToFavorites(); - - restSiteModelsCollection = restClient.authenticateUser(adminUser).withCoreAPI().usingUser(anotherUser).getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModelsCollection.assertThat().entriesListIsNotEmpty().and().paginationExist().and().entriesListContains("id", siteModel.getId()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify any user gets its own user favorite sites with Rest API and response is successful (200)") - public void anyUserGetsItsUserFavoriteSites() throws Exception - { - UserModel anyUser = dataUser.usingAdmin().createRandomTestUser(); - dataSite.usingUser(anyUser).usingSite(siteModel).addSiteToFavorites(); - - restSiteModelsCollection = restClient.authenticateUser(anyUser).withCoreAPI().usingAuthUser().getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModelsCollection.assertThat().entriesListIsNotEmpty().and().entriesListContains("id", siteModel.getId()).and().paginationExist(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify any user is NOT Authorized to get its favorite sites with Rest API when authentication fails (401)") - @Bug(id = "MNT-16904", description = "It fails only on environment with tenants") - public void anyUserNotAuthenticatedIsNotAuthorizedToGetFavoriteSites() throws Exception - { - UserModel anyUser = dataUser.usingAdmin().createRandomTestUser(); - dataSite.usingUser(anyUser).usingSite(siteModel).addSiteToFavorites(); - anyUser.setPassword("newpassword"); - - restClient.authenticateUser(anyUser).withCoreAPI().usingAuthUser().getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } -} diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSitesTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSitesTests.java new file mode 100644 index 000000000..d656d44f0 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSitesTests.java @@ -0,0 +1,344 @@ +package org.alfresco.rest.favorites; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestSiteModel; +import org.alfresco.rest.model.RestSiteModelsCollection; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.data.RandomData; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class GetFavoriteSitesTests extends RestTest +{ + private UserModel userModel, testUser1; + private SiteModel siteModel, testSite1, testSite2, testSite3; + private RestSiteModelsCollection restSiteModelsCollection; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + testUser1 = dataUser.createRandomTestUser(); + + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + testSite1 = new SiteModel("A-" + RandomData.getRandomAlphanumeric()); + testSite2 = new SiteModel("B-" + RandomData.getRandomAlphanumeric()); + testSite3 = new SiteModel("C-" + RandomData.getRandomAlphanumeric()); + + dataSite.usingUser(userModel).usingSite(siteModel).addSiteToFavorites(); + + dataSite.usingUser(testUser1).createSite(testSite1); + dataSite.usingUser(testUser1).createSite(testSite2); + dataSite.usingUser(testUser1).createSite(testSite3); + + dataSite.usingUser(testUser1).usingSite(testSite3).addSiteToFavorites(); + dataSite.usingUser(testUser1).usingSite(testSite2).addSiteToFavorites(); + dataSite.usingUser(testUser1).usingSite(testSite1).addSiteToFavorites(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify manager user fails to get an user favorite sites with Rest API (403)") + public void managerUserFailsToGetAnUserFavoriteSites() throws Exception + { + UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); + UserModel anotherUser = dataUser.usingAdmin().createRandomTestUser(); + dataSite.usingUser(anotherUser).usingSite(siteModel).addSiteToFavorites(); + + restClient.authenticateUser(managerUser).withCoreAPI().usingUser(anotherUser).getFavoriteSites(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify collaborator user fails to get an user favorite sites with Rest API (403)") + public void collaboratorUserFailsToGetAnUserFavoriteSites() throws Exception + { + UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(collaboratorUser, siteModel, UserRole.SiteCollaborator); + UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(contributorUser, siteModel, UserRole.SiteContributor); + dataSite.usingUser(contributorUser).usingSite(siteModel).addSiteToFavorites(); + + restClient.authenticateUser(collaboratorUser).withCoreAPI().usingUser(contributorUser).getFavoriteSites(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify contributor user fails to get an user favorite sites with Rest API (403)") + public void contributorUserFailsToGetAnUserFavoriteSites() throws Exception + { + UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); + UserModel contributorUser2 = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(contributorUser, siteModel, UserRole.SiteContributor); + dataUser.usingUser(userModel).addUserToSite(contributorUser2, siteModel, UserRole.SiteContributor); + dataSite.usingUser(contributorUser2).usingSite(siteModel).addSiteToFavorites(); + + restClient.authenticateUser(contributorUser).withCoreAPI().usingUser(contributorUser2).getFavoriteSites(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify consumer user fails to get an user favorite sites with Rest API (403)") + public void consumerUserFailsToGetAnUserFavoriteSites() throws Exception + { + UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); + UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel, UserRole.SiteConsumer); + dataUser.usingUser(collaboratorUser).addUserToSite(collaboratorUser, siteModel, UserRole.SiteCollaborator); + dataSite.usingUser(collaboratorUser).usingSite(siteModel).addSiteToFavorites(); + + restClient.authenticateUser(consumerUser).withCoreAPI().usingUser(collaboratorUser).getFavoriteSites(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify any user gets its own user favorite sites with Rest API and response is successful (200)") + public void anyUserGetsHisFavoriteSites() throws Exception + { + UserModel anyUser = dataUser.usingAdmin().createRandomTestUser(); + dataSite.usingUser(anyUser).usingSite(siteModel).addSiteToFavorites(); + + restSiteModelsCollection = restClient.authenticateUser(anyUser).withCoreAPI().usingAuthUser().getFavoriteSites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteModelsCollection.assertThat().entriesListIsNotEmpty().and().entriesListContains("id", siteModel.getId()).and().paginationExist(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify any user is NOT Authorized to get its favorite sites with Rest API when authentication fails (401)") +// @Bug(id = "MNT-16904", description = "It fails only on environment with tenants") + public void unauthenticatedUserIsNotAuthorizedToGetFavoriteSites() throws Exception + { + UserModel anyUser = dataUser.usingAdmin().createRandomTestUser(); + dataSite.usingUser(anyUser).usingSite(siteModel).addSiteToFavorites(); + anyUser.setPassword("newpassword"); + + restClient.authenticateUser(anyUser).withCoreAPI().usingAuthUser().getFavoriteSites(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify that getFavoriteSites request status code is 404 for a personId that does not exist") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void getFavoriteSitesReturns404ForAPersonIdThatDoesNotExist() throws Exception + { + UserModel invalidUser = new UserModel(RandomData.getRandomName("User"), DataUser.PASSWORD); + + restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingUser(invalidUser).getFavoriteSites(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, invalidUser.getUsername())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify that getFavoriteSites request status code is 403 if the user doesn't have access to the person favorite sites") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void userCannotGetFavoriteSitesForAnotherUser() throws Exception + { + restClient.authenticateUser(userModel).withCoreAPI().usingUser(testUser1).getFavoriteSites(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin has access to regular user site favorites") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void adminCanGetFavoriteSitesForARegularUser() throws Exception + { + restSiteModelsCollection = restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingUser(userModel).getFavoriteSites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteModelsCollection.assertThat().entriesListIsNotEmpty() + .assertThat().entriesListContains("id", siteModel.getId()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify that regular user can not see admin user site favorites") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void regularUserCannotGetFavoriteSitesForAdminUser() throws Exception + { + restClient.authenticateUser(testUser1).withCoreAPI().usingUser(dataUser.getAdminUser()).getFavoriteSites(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify that favorite site can be removed") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void verifyThatFavoriteSiteCanBeRemoved() throws Exception + { + UserModel randomTestUser = dataUser.createRandomTestUser(); + dataSite.usingUser(randomTestUser).usingSite(siteModel).addSiteToFavorites(); + + restSiteModelsCollection = restClient.authenticateUser(randomTestUser).withCoreAPI().usingAuthUser().getFavoriteSites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteModelsCollection.assertThat().entriesListIsNotEmpty() + .assertThat().entriesListContains("id", siteModel.getId()); + + dataSite.usingUser(randomTestUser).usingSite(siteModel).removeSiteFromFavorites(); + restSiteModelsCollection = restClient.withCoreAPI().usingAuthUser().getFavoriteSites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteModelsCollection.assertThat().entriesListIsEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify that if maxItems param is invalid status code returned is BAD_REQUEST (400)") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void getFavoriteSitesMaxItemsInvalidValueTest() throws Exception + { + restClient.authenticateUser(userModel).withParams("maxItems=-1").withCoreAPI().usingAuthUser().getFavoriteSites(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); + + restClient.authenticateUser(userModel).withParams("maxItems=abc").withCoreAPI().usingAuthUser().getFavoriteSites(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "abc")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify that if skipCount param is invalid status code returned is BAD_REQUEST (400)") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void getFavoriteSitesSkipCountInvalidValueTest() throws Exception + { + restClient.authenticateUser(userModel).withParams("skipCount=-1").withCoreAPI().usingAuthUser().getFavoriteSites(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT); + + restClient.authenticateUser(userModel).withParams("skipCount=abc").withCoreAPI().usingAuthUser().getFavoriteSites(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "abc")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify that getFavoriteSites request response status using -me- string in place of personId is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void userGetsFavoriteSiteWithSuccessUsingMEForRequest() throws Exception + { + restSiteModelsCollection = restClient.authenticateUser(testUser1).withCoreAPI().usingMe().getFavoriteSites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteModelsCollection.assertThat().entriesListIsNotEmpty() + .and().entriesListContains("id", testSite1.getId()) + .and().paginationExist(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify that getFavoriteSites request response status for a user that has no favorite sites is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void getFavoriteSiteRequestForUserWithNoFavoriteSitesIsSuccessful() throws Exception + { + UserModel randomTestUser = dataUser.createRandomTestUser(); + + restSiteModelsCollection = restClient.authenticateUser(randomTestUser).withCoreAPI().usingMe().getFavoriteSites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteModelsCollection.assertThat().entriesListIsEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify that getFavoriteSites request response status for a user with several favorite sites is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void getFavoriteSiteRequestForUserWithSeveralFavoriteSitesIsSuccessful() throws Exception + { + restSiteModelsCollection = restClient.authenticateUser(testUser1).withCoreAPI().usingAuthUser().getFavoriteSites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteModelsCollection.assertThat().entriesListIsNotEmpty() + .and().entriesListContains("id", testSite1.getId()) + .and().entriesListContains("id", testSite2.getId()) + .and().entriesListContains("id", testSite3.getId()) + .and().paginationExist(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify that getFavoriteSites request can only be called with a positive maxItems param") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void userCanNotGetFavoriteSitesWith0MaxItems() throws Exception + { + restClient.authenticateUser(testUser1).withParams("maxItems=0").withCoreAPI().usingAuthUser().getFavoriteSites(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsErrorKey(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) + .containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify that getFavoriteSites request response status code for a high skipCount param is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void userCanGetFavoriteSitesWithHighSkipCount() throws Exception + { + restSiteModelsCollection = restClient.authenticateUser(testUser1).withParams("skipCount=999999999").withCoreAPI().usingAuthUser().getFavoriteSites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteModelsCollection.assertThat().entriesListIsEmpty() + .assertThat().paginationField("skipCount").is("999999999"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify admin gets favorite sites for username with special chars with Rest API and response status is NOT_FOUND (404)") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void getFavoriteSitesRequestForPersonIDWithSpecialCharacters() throws Exception + { + String randomData = RandomData.getRandomAlphanumeric(); + UserModel userSpecialChars = dataUser.usingAdmin().createUser(randomData + "~!@#$%^&[]{}|\\;':\",./<>", "password"); + //setting the encoded text for username + userSpecialChars.setUsername(randomData + "~!%40%23%24%25%5E%26%5B%5D%7B%7D%7C%5C%3B%27%3A%22%2C.%2F%3C%3E"); + + restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingUser(userSpecialChars).getFavoriteSites(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, randomData + "~!%40%23%24%25%5E%26%5B%5D%7B%7D%7C%5C%3B%27%3A%22%2C.%2F%3C%3E")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify that user can retrieve the last 2 favorite sites") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void userCanRetrieveLast2FavoriteSites() throws Exception + { + restSiteModelsCollection = restClient.authenticateUser(testUser1).withParams("skipCount=1&maxCount=2"). + withCoreAPI().usingAuthUser().getFavoriteSites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteModelsCollection.assertThat().entriesListIsNotEmpty() + .assertThat().entriesListCountIs(2) + .assertThat().entriesListContains("id", testSite2.getId()) + .assertThat().entriesListContains("id", testSite3.getId()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify that getFavoriteSites request applies valid properties param") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void getFavoriteSitesRequestWithValidPropertiesParam() throws Exception + { + RestSiteModel restSiteModel = restClient.authenticateUser(testUser1).withParams("properties=title") + .withCoreAPI().usingAuthUser().getFavoriteSites().getOneRandomEntry().onModel(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteModel.assertThat().fieldsCount().is(1) + .assertThat().field("title").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify that getFavoriteSites request applies invalid properties param") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void getFavoriteSitesRequestWithInvalidPropertiesParam() throws Exception + { + restClient.authenticateUser(testUser1).withParams("properties=tas").withCoreAPI().usingAuthUser() + .getFavoriteSites().getOneRandomEntry().onModel().assertThat().fieldsCount().is(0); + restClient.assertStatusCodeIs(HttpStatus.OK); + } +} diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteTests.java new file mode 100644 index 000000000..dadce6174 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteTests.java @@ -0,0 +1,518 @@ +package org.alfresco.rest.favorites; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.dataprep.SiteService; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestPersonFavoritesModel; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class GetFavoriteTests extends RestTest +{ + private UserModel adminUserModel; + private SiteModel siteModel; + private FolderModel folderModel; + private FileModel fileModel; + private ListUserWithRoles usersWithRoles; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + + folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); + fileModel = dataContent.usingUser(adminUserModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, + description = "Verify Manager user gets favorite site with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) + public void managerIsAbleToRetrieveFavoriteSite() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + + RestPersonFavoritesModel favSite = restClient.withCoreAPI().usingAuthUser().getFavorite(siteModel.getGuid()); + restClient.assertStatusCodeIs(HttpStatus.OK); + favSite.assertThat().field("targetGuid").is(siteModel.getGuid()); + + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, + description = "Verify Manager user gets favorite folder with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) + public void managerIsAbleToRetrieveFavoriteFolder() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(folderModel); + + RestPersonFavoritesModel favoriteFolder = restClient.withCoreAPI().usingAuthUser().getFavorite(folderModel.getNodeRef()); + restClient.assertStatusCodeIs(HttpStatus.OK); + favoriteFolder.assertThat().field("targetGuid").is(folderModel.getNodeRef()); + + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, + description = "Verify Manager user gets favorite file with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) + public void managerIsAbleToRetrieveFavoriteFile() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + restClient.withCoreAPI().usingAuthUser().addFileToFavorites(fileModel); + + RestPersonFavoritesModel favoriteFile = restClient.withCoreAPI().usingAuthUser().getFavorite(fileModel.getNodeRefWithoutVersion()); + restClient.assertStatusCodeIs(HttpStatus.OK); + favoriteFile.assertThat().field("targetGuid").is(fileModel.getNodeRefWithoutVersion()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, + description = "Verify user gets status code 401 if authentication call fails") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) +// @Bug(id = "MNT-16904", description = "fails only on environment with tenants") + public void userIsNotAbleToRetrieveFavoriteSiteIfAuthenticationFails() throws Exception + { + UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); + siteManager.setPassword("wrongPassword"); + restClient.authenticateUser(siteManager).withCoreAPI() + .usingUser(siteManager).getFavorite(siteModel.getGuid()); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify Admin user gets favorite site with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void adminIsAbleToRetrieveFavoritesSite() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); + + RestPersonFavoritesModel favoriteSite = restClient.withCoreAPI().usingUser(adminUserModel).getFavorite(siteModel.getGuid()); + restClient.assertStatusCodeIs(HttpStatus.OK); + favoriteSite.assertThat().field("targetGuid").is(siteModel.getGuid()); + favoriteSite.getTarget().getSite() + .assertThat().field("guid").is(siteModel.getGuid()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify Admin user gets favorite folder with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void adminIsAbleToRetrieveFavoritesFolder() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).addFolderToFavorites(folderModel); + + RestPersonFavoritesModel favoriteFolder = restClient.withCoreAPI().usingUser(adminUserModel).getFavorite(folderModel.getNodeRef()); + restClient.assertStatusCodeIs(HttpStatus.OK); + favoriteFolder.assertThat().field("targetGuid").is(folderModel.getNodeRef()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify Admin user gets favorite file with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void adminIsAbleToRetrieveFavoritesFile() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).addFileToFavorites(fileModel); + + RestPersonFavoritesModel favoriteFile = restClient.withCoreAPI().usingUser(adminUserModel).getFavorite(fileModel.getNodeRefWithoutVersion()); + restClient.assertStatusCodeIs(HttpStatus.OK); + favoriteFile.assertThat().field("targetGuid").is(fileModel.getNodeRefWithoutVersion()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify Collaborator user gets favorite site with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void collaboratorIsAbleToRetrieveFavoriteSite() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + + RestPersonFavoritesModel favSite = restClient.withCoreAPI().usingAuthUser().getFavorite(siteModel.getGuid()); + restClient.assertStatusCodeIs(HttpStatus.OK); + favSite.assertThat().field("targetGuid").is(siteModel.getGuid()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify collaborator user gets favorite folder with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void collaboratorIsAbleToRetrieveFavoriteFolder() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(folderModel); + + RestPersonFavoritesModel favoriteFolder = restClient.withCoreAPI().usingAuthUser().getFavorite(folderModel.getNodeRef()); + restClient.assertStatusCodeIs(HttpStatus.OK); + favoriteFolder.assertThat().field("targetGuid").is(folderModel.getNodeRef()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify collaborator user gets favorite file with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void collaboratorIsAbleToRetrieveFavoriteFile() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + restClient.withCoreAPI().usingAuthUser().addFileToFavorites(fileModel); + + RestPersonFavoritesModel favoriteFile = restClient.withCoreAPI().usingAuthUser().getFavorite(fileModel.getNodeRefWithoutVersion()); + restClient.assertStatusCodeIs(HttpStatus.OK); + favoriteFile.assertThat().field("targetGuid").is(fileModel.getNodeRefWithoutVersion()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify Contributor user gets favorite site with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void contributorIsAbleToRetrieveFavoriteSite() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + + RestPersonFavoritesModel favSite = restClient.withCoreAPI().usingAuthUser().getFavorite(siteModel.getGuid()); + restClient.assertStatusCodeIs(HttpStatus.OK); + favSite.assertThat().field("targetGuid").is(siteModel.getGuid()); ; + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify contributor user gets favorite folder with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void contributorIsAbleToRetrieveFavoriteFolder() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(folderModel); + + RestPersonFavoritesModel favoriteFolder = restClient.withCoreAPI().usingAuthUser().getFavorite(folderModel.getNodeRef()); + restClient.assertStatusCodeIs(HttpStatus.OK); + favoriteFolder.assertThat().field("targetGuid").is(folderModel.getNodeRef()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify contributor user gets favorite file with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void contributorIsAbleToRetrieveFavoriteFile() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + restClient.withCoreAPI().usingAuthUser().addFileToFavorites(fileModel); + + RestPersonFavoritesModel favoriteFile = restClient.withCoreAPI().usingAuthUser().getFavorite(fileModel.getNodeRefWithoutVersion()); + restClient.assertStatusCodeIs(HttpStatus.OK); + favoriteFile.assertThat().field("targetGuid").is(fileModel.getNodeRefWithoutVersion()); + } + + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify Consumer user gets favorite site with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void consumerIsAbleToRetrieveFavorites() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + + RestPersonFavoritesModel favSite = restClient.withCoreAPI().usingAuthUser().getFavorite(siteModel.getGuid()); + restClient.assertStatusCodeIs(HttpStatus.OK); + favSite.assertThat().field("targetGuid").is(siteModel.getGuid()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify consumer user gets favorite folder with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void consumerIsAbleToRetrieveFavoriteFolder() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(folderModel); + + RestPersonFavoritesModel favoriteFolder = restClient.withCoreAPI().usingAuthUser().getFavorite(folderModel.getNodeRef()); + restClient.assertStatusCodeIs(HttpStatus.OK); + favoriteFolder.assertThat().field("targetGuid").is(folderModel.getNodeRef()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify consumer user gets favorite file with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void consumerIsAbleToRetrieveFavoriteFile() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + restClient.withCoreAPI().usingAuthUser().addFileToFavorites(fileModel); + + RestPersonFavoritesModel favoriteFile = restClient.withCoreAPI().usingAuthUser().getFavorite(fileModel.getNodeRefWithoutVersion()); + restClient.assertStatusCodeIs(HttpStatus.OK); + favoriteFile.assertThat().field("targetGuid").is(fileModel.getNodeRefWithoutVersion()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify user doesn't get favorite site of another user with Rest API and status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void userIsNotAbleToRetrieveFavoriteSiteOfAnotherSiteMember() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + restClient.withCoreAPI().usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .getFavorite(siteModel.getGuid()); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator).getUsername())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify user doesn't get favorite site of admin user with Rest API and status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void userIsNotAbleToRetrieveFavoritesOfAdminUser() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + .withCoreAPI().usingUser(adminUserModel).getFavorite(siteModel.getGuid()); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, adminUserModel.getUsername())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify admin user doesn't get favorite site of another user with Rest API and status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void adminIsNotAbleToRetrieveFavoritesOfAnotherUser() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI() + .usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).getFavorite(siteModel.getGuid()); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator).getUsername())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, + executionType = ExecutionType.REGRESSION, description = "Verify get favorite user doesn't have any favorite site, file or folder") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void getFavoriteSiteForUserWithoutAnyFavorites() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + restClient.withCoreAPI().usingAuthUser().getFavorite(siteModel.getGuid()); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, usersWithRoles.getOneUserWithRole(UserRole.SiteManager).getUsername(), siteModel.getGuid())) + .statusCodeIs(HttpStatus.NOT_FOUND) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE) + .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify get favorite site for -me-") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void getFavoriteSiteUsingMe() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + + RestPersonFavoritesModel favoriteSite = restClient.withCoreAPI().usingMe().getFavorite(siteModel.getGuid()); + restClient.assertStatusCodeIs(HttpStatus.OK); + favoriteSite.assertThat().field("targetGuid").is(siteModel.getGuid()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify get favorite site for -me-") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void getFavoriteFileUsingMe() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingAuthUser().addFileToFavorites(fileModel); + + RestPersonFavoritesModel favoriteFile = restClient.withCoreAPI().usingMe().getFavorite(fileModel.getNodeRefWithoutVersion()); + restClient.assertStatusCodeIs(HttpStatus.OK); + favoriteFile.assertThat().field("targetGuid").is(fileModel.getNodeRefWithoutVersion()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, + executionType = ExecutionType.REGRESSION, description = "Verify get favorite site when person id does't exist") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void getFavoriteSiteWhenPersonIdNotExist() throws Exception { + + restClient.withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); + UserModel someUser = new UserModel("invalidUser", DataUser.PASSWORD); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(someUser).getFavorite(siteModel.getGuid()); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, someUser.getUsername())) + .statusCodeIs(HttpStatus.NOT_FOUND) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY); + } + + @Bug(id = "ACE-2413") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, + executionType = ExecutionType.REGRESSION, description = "Verify get favorite site when person id is empty") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void getFavoriteSiteWithEmptyUserId() throws Exception { + + restClient.withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); + UserModel someUser = new UserModel("", DataUser.PASSWORD); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(someUser).getFavorite(siteModel.getGuid()); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, someUser.getUsername())) + .statusCodeIs(HttpStatus.BAD_REQUEST); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, + executionType = ExecutionType.REGRESSION, description = "Verify get favorite site when favorite id does't exist") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void getFavoriteSiteWhenFavoriteIdNotExist() throws Exception { + + restClient.withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).getFavorite("invalidId"); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidId")) + .statusCodeIs(HttpStatus.NOT_FOUND) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify Admin user gets favorite site with properties filter") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void verifyRequestForGetFavoriteSiteWithProperties() throws Exception + { + UserModel collaborator = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); + restClient.authenticateUser(collaborator); + restClient.withCoreAPI().usingUser(collaborator).addSiteToFavorites(siteModel); + + RestPersonFavoritesModel favoriteSite = restClient.authenticateUser(collaborator).withParams("properties=targetGuid") + .withCoreAPI().usingAuthUser().getFavorite(siteModel.getGuid()); + restClient.assertStatusCodeIs(HttpStatus.OK); + favoriteSite.assertThat().field("targetGuid").is(siteModel.getGuid()); + favoriteSite.assertThat().fieldsCount().is(1); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify Admin user gets favorite site with inccorect properties filter") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void verifyRequestForGetFavoriteSiteWithInvalidProperties() throws Exception + { + UserModel collaborator = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); + restClient.authenticateUser(collaborator); + restClient.withCoreAPI().usingUser(collaborator).addFileToFavorites(fileModel); + + RestPersonFavoritesModel favoriteFile = restClient.authenticateUser(collaborator).withParams("properties=tas") + .withCoreAPI().usingAuthUser().getFavorite(fileModel.getNodeRefWithoutVersion()); + restClient.assertStatusCodeIs(HttpStatus.OK); + favoriteFile.assertThat().fieldsCount().is(0); + } + + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify all values from get favorite rest api for a file") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void verifyRequestFieldsForGetFavoriteFile() throws Exception + { + UserModel contributor = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); + restClient.authenticateUser(contributor); + restClient.withCoreAPI().usingUser(contributor).addFileToFavorites(fileModel); + + RestPersonFavoritesModel favoriteFile = restClient.authenticateUser(contributor) + .withCoreAPI().usingAuthUser().getFavorite(fileModel.getNodeRefWithoutVersion()); + restClient.assertStatusCodeIs(HttpStatus.OK); + + favoriteFile.assertThat().field("targetGuid").is(fileModel.getNodeRefWithoutVersion()) + .and().field("target.file.isFile").is("true") + .and().field("target.file.mimeType").is("text/plain") + .and().field("target.file.isFolder").is("false") + .and().field("target.file.createdBy").is(adminUserModel.getUsername()) + .and().field("target.file.versionLabel").is("1.0") + .and().field("target.file.name").is(fileModel.getName()) + .and().field("target.file.parentId").is(folderModel.getNodeRef()) + .and().field("target.file.guid").is(fileModel.getNodeRefWithoutVersion()) + .and().field("target.file.modifiedBy").is(adminUserModel.getUsername()) + .and().field("target.file.id").is(fileModel.getNodeRefWithoutVersion()); + } + + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify all values from get favorite rest api for a site") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void verifyRequestFieldsForGetFavoriteSite() throws Exception + { + UserModel contributor = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); + restClient.authenticateUser(contributor); + restClient.withCoreAPI().usingUser(contributor).addFavoriteSite(siteModel); + + RestPersonFavoritesModel favoriteSite = restClient.authenticateUser(contributor) + .withCoreAPI().usingAuthUser().getFavorite(siteModel.getGuid()); + restClient.assertStatusCodeIs(HttpStatus.OK); + + favoriteSite.assertThat().field("targetGuid").is(siteModel.getGuid()) + .and().field("target.site.role").is(UserRole.SiteContributor.toString()) + .and().field("target.site.visibility").is(SiteService.Visibility.PUBLIC.toString()) + .and().field("target.site.guid").is(siteModel.getGuid()) + .and().field("target.site.description").is(siteModel.getDescription()) + .and().field("target.site.id").is(siteModel.getId()) + .and().field("target.site.preset").is("site-dashboard") + .and().field("target.site.title").is(siteModel.getTitle()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify all values from get favorite rest api for a folder") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void verifyRequestFieldsForGetFavoriteFolder() throws Exception + { + UserModel contributor = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); + restClient.authenticateUser(contributor); + restClient.withCoreAPI().usingUser(contributor).addFolderToFavorites(folderModel); + + RestPersonFavoritesModel favoriteFolder = restClient.authenticateUser(contributor) + .withCoreAPI().usingAuthUser().getFavorite(folderModel.getNodeRef()); + restClient.assertStatusCodeIs(HttpStatus.OK); + + favoriteFolder.assertThat().field("targetGuid").is(folderModel.getNodeRef()) + .and().field("target.folder.isFile").is("false") + .and().field("target.folder.isFolder").is("true") + .and().field("target.folder.createdBy").is(adminUserModel.getUsername()) + .and().field("target.folder.name").is(folderModel.getName()) + .and().field("target.folder.guid").is(folderModel.getNodeRef()) + .and().field("target.folder.modifiedBy").is(adminUserModel.getUsername()) + .and().field("target.folder.id").is(folderModel.getNodeRef()); + } + + @Bug(id = "MNT-16904") + @TestRail(section = { TestGroup.REST_API, + TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify the get favorite request for invalid network id") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void getFavoriteSiteWithInvalidNetworkId() throws Exception + { + UserModel adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUserModel); + restClient.usingTenant().createTenant(adminTenantUser); + UserModel tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + + siteModel = dataSite.usingUser(tenantUser).createPublicRandomSite(); + restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + + tenantUser.setDomain("invalidNetwork"); + restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().getFavorite(siteModel.getGuid()); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify the get favorite request with tenant user") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void getFavoriteSiteWithTenantUser() throws Exception + { + UserModel adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUserModel).usingTenant().createTenant(adminTenantUser); + UserModel tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + + siteModel = dataSite.usingUser(tenantUser).createPublicRandomSite(); + restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + + restClient.withCoreAPI().usingAuthUser().getFavorite(siteModel.getGuid()); + restClient.assertStatusCodeIs(HttpStatus.OK); + } +} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesCoreTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesCoreTests.java deleted file mode 100644 index afd655b53..000000000 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesCoreTests.java +++ /dev/null @@ -1,254 +0,0 @@ -package org.alfresco.rest.favorites; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestPersonFavoritesModelsCollection; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Created by Claudia Agache on 11/21/2016. - */ -public class GetFavoritesCoreTests extends RestTest -{ - private UserModel adminUserModel; - private SiteModel firstSiteModel, secondSiteModel; - private FileModel firstFileModel, secondFileModel; - private FolderModel firstFolderModel, secondFolderModel; - private DataUser.ListUserWithRoles usersWithRoles; - private RestPersonFavoritesModelsCollection userFavorites; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - restClient.authenticateUser(adminUserModel); - firstSiteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - secondSiteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - firstFolderModel = dataContent.usingUser(adminUserModel).usingSite(firstSiteModel).createFolder(); - secondFolderModel = dataContent.usingUser(adminUserModel).usingSite(firstSiteModel).createFolder(); - firstFileModel = dataContent.usingUser(adminUserModel).usingResource(firstFolderModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - secondFileModel = dataContent.usingUser(adminUserModel).usingResource(firstFolderModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - usersWithRoles = dataUser.addUsersWithRolesToSite(firstSiteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify User gets only favorites sites with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) - public void userIsAbleToRetrieveOnlyFavoritesSites() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); - restClient.withCoreAPI().usingAuthUser().addFileToFavorites(firstFileModel); - restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(firstFolderModel); - - userFavorites = restClient.withCoreAPI().usingAuthUser().where().targetSiteExist().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - userFavorites.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) - .and().entriesListDoesNotContain("targetGuid", secondSiteModel.getGuid()) - .and().entriesListDoesNotContain("targetGuid", firstFileModel.getNodeRefWithoutVersion()) - .and().entriesListDoesNotContain("targetGuid", firstFolderModel.getNodeRef()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify User gets only favorites files with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) - public void userIsAbleToRetrieveOnlyFavoritesFiles() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); - restClient.withCoreAPI().usingAuthUser().addFileToFavorites(firstFileModel); - restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(firstFolderModel); - - userFavorites = restClient.withCoreAPI().usingAuthUser().where().targetFileExist().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - userFavorites.assertThat().entriesListContains("targetGuid", firstFileModel.getNodeRefWithoutVersion()) - .and().entriesListDoesNotContain("targetGuid", secondFileModel.getNodeRefWithoutVersion()) - .and().entriesListDoesNotContain("targetGuid", firstSiteModel.getGuid()) - .and().entriesListDoesNotContain("targetGuid", firstFolderModel.getNodeRef()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify User gets only favorites folders with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) - public void userIsAbleToRetrieveOnlyFavoritesFolders() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); - restClient.withCoreAPI().usingAuthUser().addFileToFavorites(firstFileModel); - restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(firstFolderModel); - - userFavorites = restClient.withCoreAPI().usingAuthUser().where().targetFolderExist().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - userFavorites.assertThat().entriesListContains("targetGuid", firstFolderModel.getNodeRef()) - .and().entriesListDoesNotContain("targetGuid", secondFolderModel.getNodeRef()) - .and().entriesListDoesNotContain("targetGuid", firstSiteModel.getGuid()) - .and().entriesListDoesNotContain("targetGuid", firstFileModel.getNodeRefWithoutVersion()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify User gets only favorites files or folders with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) - public void userIsAbleToRetrieveFavoritesFilesOrFolders() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); - restClient.withCoreAPI().usingAuthUser().addFileToFavorites(firstFileModel); - restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(firstFolderModel); - - userFavorites = restClient.withCoreAPI().usingAuthUser() - .where().targetFolderExist().or().targetFileExist() - .getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - userFavorites.assertThat().entriesListContains("targetGuid", firstFolderModel.getNodeRef()) - .and().entriesListContains("targetGuid", firstFileModel.getNodeRefWithoutVersion()) - .and().entriesListDoesNotContain("targetGuid", secondFolderModel.getNodeRef()) - .and().entriesListDoesNotContain("targetGuid", secondFileModel.getNodeRefWithoutVersion()) - .and().entriesListDoesNotContain("targetGuid", firstSiteModel.getGuid()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify User gets only favorites files or sites with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) - public void userIsAbleToRetrieveFavoritesFilesOrSites() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); - restClient.withCoreAPI().usingAuthUser().addFileToFavorites(firstFileModel); - restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(firstFolderModel); - - userFavorites = restClient.withCoreAPI().usingAuthUser() - .where().targetSiteExist().or().targetFileExist() - .getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - userFavorites.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) - .and().entriesListContains("targetGuid", firstFileModel.getNodeRefWithoutVersion()) - .and().entriesListDoesNotContain("targetGuid", secondSiteModel.getGuid()) - .and().entriesListDoesNotContain("targetGuid", secondFileModel.getNodeRefWithoutVersion()) - .and().entriesListDoesNotContain("targetGuid", firstFolderModel.getNodeRef()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify User gets only favorites folders or sites with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) - public void userIsAbleToRetrieveFavoritesFoldersOrSites() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); - restClient.withCoreAPI().usingAuthUser().addFileToFavorites(firstFileModel); - restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(firstFolderModel); - - userFavorites = restClient.withCoreAPI().usingAuthUser() - .where().targetSiteExist().or().targetFolderExist() - .getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - userFavorites.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) - .and().entriesListContains("targetGuid", firstFolderModel.getNodeRef()) - .and().entriesListDoesNotContain("targetGuid", secondSiteModel.getGuid()) - .and().entriesListDoesNotContain("targetGuid", secondFolderModel.getNodeRef()) - .and().entriesListDoesNotContain("targetGuid", firstFileModel.getNodeRefWithoutVersion()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify User gets all favorites with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) - public void userIsAbleToRetrieveAllFavorites() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); - restClient.withCoreAPI().usingAuthUser().addFileToFavorites(firstFileModel); - restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(firstFolderModel); - - userFavorites = restClient.withCoreAPI().usingAuthUser() - .where().targetSiteExist().or().targetFolderExist().or().targetFileExist() - .getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - userFavorites.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) - .and().entriesListContains("targetGuid", firstFolderModel.getNodeRef()) - .and().entriesListContains("targetGuid", firstFileModel.getNodeRefWithoutVersion()) - .and().entriesListDoesNotContain("targetGuid", secondSiteModel.getGuid()) - .and().entriesListDoesNotContain("targetGuid", secondFolderModel.getNodeRef()) - .and().entriesListDoesNotContain("targetGuid", secondFileModel.getNodeRefWithoutVersion()); - - userFavorites = restClient.withCoreAPI().usingAuthUser().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - userFavorites.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) - .and().entriesListContains("targetGuid", firstFolderModel.getNodeRef()) - .and().entriesListContains("targetGuid", firstFileModel.getNodeRefWithoutVersion()) - .and().entriesListDoesNotContain("targetGuid", secondSiteModel.getGuid()) - .and().entriesListDoesNotContain("targetGuid", secondFolderModel.getNodeRef()) - .and().entriesListDoesNotContain("targetGuid", secondFileModel.getNodeRefWithoutVersion()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify request using invalid where parameter returns status 400") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) - public void getFavoritesUsingInvalidWhereParameter() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); - restClient.withCoreAPI().usingAuthUser().addFileToFavorites(firstFileModel); - restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(firstFolderModel); - - userFavorites = restClient.withCoreAPI().usingAuthUser() - .where().or().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_ARGUMENT, "WHERE query")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify request for a user with no favorites returns status 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) - public void userHasNoFavorites() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - - userFavorites = restClient.withCoreAPI().usingAuthUser().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - userFavorites.assertThat().entriesListIsEmpty().and().paginationField("totalItems").is("0"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify User gets correct favorites after deleting a favorite") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) - public void checkFavoriteFolderIsRemoved() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); - restClient.withCoreAPI().usingAuthUser().addFileToFavorites(firstFileModel); - restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(firstFolderModel); - - restClient.withCoreAPI().usingAuthUser().deleteFolderFromFavorites(firstFolderModel); - - userFavorites = restClient.withCoreAPI().usingAuthUser().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - userFavorites.assertThat().entriesListDoesNotContain("targetGuid", firstFolderModel.getNodeRef()) - .and().paginationField("totalItems").is("2"); - } - -// @Bug(id="REPO-1642", description = "reproduced on 5.2.1 only, it works on 5.2.0") - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify request using personId that does not exist returns status 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE }) - public void checkFavoritesWhenPersonIdDoesNotExist() throws Exception - { - UserModel someUser = new UserModel("someUser", DataUser.PASSWORD); - - restClient.authenticateUser(adminUserModel).withCoreAPI() - .usingUser(someUser).getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "someUser")); - } -} diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesFullTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesFullTests.java deleted file mode 100644 index 9d553dcc1..000000000 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesFullTests.java +++ /dev/null @@ -1,230 +0,0 @@ -package org.alfresco.rest.favorites; - -import org.alfresco.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestPersonFavoritesModel; -import org.alfresco.rest.model.RestPersonFavoritesModelsCollection; -import org.alfresco.rest.model.RestSiteModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class GetFavoritesFullTests extends RestTest -{ - private UserModel adminUserModel; - private UserModel secondUserModel; - private SiteModel firstSiteModel, secondSiteModel, thirdSiteModel; - private RestPersonFavoritesModelsCollection userFavorites; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - secondUserModel = dataUser.createRandomTestUser(); - restClient.authenticateUser(adminUserModel); - firstSiteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - secondSiteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - thirdSiteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - - firstSiteModel.setGuid(restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(firstSiteModel).getSite().getGuid()); - secondSiteModel.setGuid(restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(secondSiteModel).getSite().getGuid()); - thirdSiteModel.setGuid(restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(thirdSiteModel).getSite().getGuid()); - - restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); - restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(secondSiteModel); - - restClient.authenticateUser(secondUserModel); - restClient.withCoreAPI().usingUser(secondUserModel).addSiteToFavorites(firstSiteModel); - restClient.withCoreAPI().usingUser(secondUserModel).addSiteToFavorites(secondSiteModel); - restClient.withCoreAPI().usingUser(secondUserModel).addSiteToFavorites(thirdSiteModel); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify get favorites specifying -me- string in place of for request") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) - public void userIsAbleToGetFavoritesWhenUsingMeAsUsername() throws Exception - { - userFavorites = restClient.authenticateUser(secondUserModel).withCoreAPI().usingMe().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - userFavorites.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()).and().entriesListContains("targetGuid", secondSiteModel.getGuid()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify get favorites using empty for where parameter for request") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) - public void userIsAbleToGetFavoritesWhenUsingEmptyWhereParameter() throws Exception - { - userFavorites = restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().where().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_ARGUMENT, "WHERE query")); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that for invalid maxItems parameter status code returned is 400.") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) - public void checkInvalidMaxItemsStatusCode() throws Exception - { - restClient.authenticateUser(adminUserModel).withParams("maxItems=AB").withCoreAPI().usingUser(adminUserModel).getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Invalid paging parameter"); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that for invalid skipCount parameter status code returned is 400.") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) - public void checkInvalidSkipCountStatusCode() throws Exception - { - restClient.authenticateUser(adminUserModel).withParams("skipCount=AB").withCoreAPI().usingUser(adminUserModel).getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Invalid paging parameter"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify get favorites when using invalid network id for non-tenant user") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) - public void getFavoritesWhenNetworkIdIsInvalid() throws Exception - { - UserModel networkUserModel = dataUser.createRandomTestUser(); - networkUserModel.setDomain("invalidNetwork"); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(networkUserModel).where().targetSiteExist().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, networkUserModel.getUsername())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify get favorites using special chars in where parameter for request") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) - public void userIsNotAbleToGetFavoritesWhenUsingSpecialCharsInWhereParameter() throws Exception - { - userFavorites = restClient.withCoreAPI().usingAuthUser().where().invalidWhereParameter("~!%40%23%24%25%5E%26*()_%2B%5B%5D%7B%7D%7C%5C%3B%27%3A%22%2C.%2F%3C%3E").getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_ARGUMENT, "WHERE query")) - .containsErrorKey(RestErrorModel.INVALID_QUERY_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify get favorites using AND instead of OR in where parameter for request") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) - public void userIsNotAbleToGetFavoritesWhenUsingANDInWhereParameter() throws Exception - { - userFavorites = restClient.withCoreAPI().usingAuthUser().where().targetFolderExist().invalidWhereParameter("AND").targetFileExist().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_ARGUMENT, "WHERE query")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify get favorites using wrong name instead of EXISTS in where parameter for request") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) - public void userIsNotAbleToGetFavoritesWhenUsingWrongWhereParameter() throws Exception - { - userFavorites = restClient.withCoreAPI().usingAuthUser().where().invalidWhereParameter("EXIST((target/site))").targetFileExist().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_ARGUMENT, "WHERE query")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify get favorites except the first one for request") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) - public void userIsAbleToGetFavoritesExceptTheFirstOne() throws Exception - { - userFavorites = restClient.authenticateUser(secondUserModel).withParams("skipCount=1").withCoreAPI().usingUser(secondUserModel).getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - userFavorites.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) - .and().entriesListContains("targetGuid", secondSiteModel.getGuid()) - .and().entriesListDoesNotContain("targetGuid", thirdSiteModel.getGuid()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify get first two favorites sites") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) - public void userIsAbleToGetFirstTwoFavorites() throws Exception - { - userFavorites = restClient.authenticateUser(secondUserModel).withParams("maxItems=2").withCoreAPI().usingUser(secondUserModel).getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - userFavorites.assertThat().entriesListContains("targetGuid", thirdSiteModel.getGuid()) - .and().entriesListContains("targetGuid", secondSiteModel.getGuid()) - .and().entriesListDoesNotContain("targetGuid", firstSiteModel.getGuid()) - .getPagination().assertThat().field("maxItems").is("2") - .and().field("hasMoreItems").is("true") - .and().field("count").is("2"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify get favorites sites when using empty values for skipCount and maxItems") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) - public void userIsAbleToGetFavoritesWhenSkipCountAndMaxItemsAreEmpty() throws Exception - { - restClient.authenticateUser(secondUserModel).withParams("skipCount= ").withCoreAPI().usingUser(secondUserModel).getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, " ")); - - restClient.authenticateUser(secondUserModel).withParams("maxItems= ").withCoreAPI().usingUser(secondUserModel).getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, " ")); - } - - @Bug(id = "MNT-16904") - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify the get favorites request when network id is invalid for tenant user") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL, TestGroup.NETWORKS}) - public void getFavoriteSitesWhenNetworkIdIsInvalid() throws JsonToModelConversionException, Exception - { - UserModel adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUserModel); - restClient.usingTenant().createTenant(adminTenantUser); - UserModel tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); - - tenantUser.setDomain("invalidNetwork"); - restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify the get favorites request for a high value for skipCount parameter") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) - public void userIsAbleToGetFavoritesWithHighSkipCount() throws Exception - { - userFavorites = restClient.authenticateUser(secondUserModel).withParams("skipCount=999999999").withCoreAPI().usingUser(secondUserModel).getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - userFavorites.assertThat().entriesListIsEmpty().assertThat().paginationField("skipCount").is("999999999"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify the get favorites request with properties parameter applied") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) - public void userIsAbleToGetFavoritesWithPropertiesParamApplied() throws Exception - { - userFavorites = restClient.authenticateUser(secondUserModel).withParams("properties=targetGuid").withCoreAPI().usingUser(secondUserModel).getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - RestPersonFavoritesModel restPersonFavoritesModel = userFavorites.getEntries().get(0).onModel(); - restPersonFavoritesModel.assertThat().field("targetGuid").is(thirdSiteModel.getGuid()).and().field("createdAt").isNull(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify entry details for get favorites response with Rest API") - public void checkResponseSchemaForGetFavorites() throws Exception - { - userFavorites = restClient.authenticateUser(secondUserModel).withCoreAPI().usingAuthUser().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - RestPersonFavoritesModel restPersonFavoritesModel = userFavorites.getEntries().get(0).onModel(); - restPersonFavoritesModel.assertThat().field("targetGuid").is(thirdSiteModel.getGuid()); - - RestSiteModel restSiteModel = restPersonFavoritesModel.getTarget().getSite(); - restSiteModel.assertThat().field("visibility").is(thirdSiteModel.getVisibility()).and() - .field("guid").is(thirdSiteModel.getGuid()).and() - .field("description").is(thirdSiteModel.getDescription()).and() - .field("id").is(thirdSiteModel.getId()).and() - .field("title").is(thirdSiteModel.getTitle()); - } -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java deleted file mode 100644 index 3cca0d5a1..000000000 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesSanityTests.java +++ /dev/null @@ -1,197 +0,0 @@ -package org.alfresco.rest.favorites; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestPersonFavoritesModelsCollection; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class GetFavoritesSanityTests extends RestTest -{ - private UserModel adminUserModel; - private SiteModel firstSiteModel; - private SiteModel secondSiteModel; - private FileModel firstFileModel; - private FileModel secondFileModel; - private FolderModel firstFolderModel; - private FolderModel secondFolderModel; - private ListUserWithRoles usersWithRoles; - private RestPersonFavoritesModelsCollection restPersonFavoritesModelsCollection; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - restClient.authenticateUser(adminUserModel); - firstSiteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - secondSiteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - firstFolderModel = dataContent.usingUser(adminUserModel).usingSite(firstSiteModel).createFolder(); - secondFolderModel = dataContent.usingUser(adminUserModel).usingSite(firstSiteModel).createFolder(); - firstFileModel = dataContent.usingUser(adminUserModel).usingResource(firstFolderModel).createContent(DocumentType.TEXT_PLAIN); - secondFileModel = dataContent.usingUser(adminUserModel).usingResource(firstFolderModel).createContent(DocumentType.TEXT_PLAIN); - - usersWithRoles = dataUser.addUsersWithRolesToSite(firstSiteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Verify Admin user gets favorites sites with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - public void adminIsAbleToRetrieveFavoritesSites() throws JsonToModelConversionException, Exception - { - restClient.withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(firstSiteModel); - restClient.withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(secondSiteModel); - - restPersonFavoritesModelsCollection = restClient.withCoreAPI().usingAuthUser().where().targetSiteExist().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restPersonFavoritesModelsCollection.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) - .and().entriesListContains("targetGuid", secondSiteModel.getGuid()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Verify Admin user gets favorites folders with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - public void adminIsAbleToRetrieveFavoritesFolders() throws JsonToModelConversionException, Exception - { - restClient.withCoreAPI().usingUser(adminUserModel).addFolderToFavorites(firstFolderModel); - restClient.withCoreAPI().usingUser(adminUserModel).addFolderToFavorites(secondFolderModel); - - restPersonFavoritesModelsCollection = restClient.withCoreAPI().usingAuthUser().where().targetFolderExist().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restPersonFavoritesModelsCollection.assertThat().entriesListContains("targetGuid", firstFolderModel.getNodeRef()) - .and().entriesListContains("targetGuid", secondFolderModel.getNodeRef()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Verify Admin user gets favorites files with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - public void adminIsAbleToRetrieveFavoritesFiles() throws JsonToModelConversionException, Exception - { - restClient.withCoreAPI().usingUser(adminUserModel).addFileToFavorites(firstFileModel); - restClient.withCoreAPI().usingUser(adminUserModel).addFileToFavorites(secondFileModel); - - restPersonFavoritesModelsCollection = restClient.withCoreAPI().usingAuthUser().where().targetFileExist().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restPersonFavoritesModelsCollection.assertThat().entriesListContains("targetGuid", firstFileModel.getNodeRefWithoutVersion()) - .and().entriesListContains("targetGuid", secondFileModel.getNodeRefWithoutVersion()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Verify Manager user gets favorites with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - public void managerIsAbleToRetrieveFavorites() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); - restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(secondSiteModel); - - restPersonFavoritesModelsCollection = restClient.withCoreAPI().usingAuthUser().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restPersonFavoritesModelsCollection.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) - .assertThat().entriesListContains("targetGuid", secondSiteModel.getGuid()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Verify Collaborator user gets favorites with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - public void collaboratorIsAbleToRetrieveFavorites() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); - restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(secondSiteModel); - - restPersonFavoritesModelsCollection = restClient.withCoreAPI().usingAuthUser().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restPersonFavoritesModelsCollection.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) - .and().entriesListContains("targetGuid", secondSiteModel.getGuid()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Verify Contributor user gets favorites with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - public void contributorIsAbleToRetrieveFavorites() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) - .withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); - restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(secondSiteModel); - - restPersonFavoritesModelsCollection = restClient.withCoreAPI().usingAuthUser().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restPersonFavoritesModelsCollection.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()).and() - .entriesListContains("targetGuid", secondSiteModel.getGuid()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Verify Consumer user gets favorites with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - public void consumerIsAbleToRetrieveFavorites() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); - restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(secondSiteModel); - - restPersonFavoritesModelsCollection = restClient.withCoreAPI().usingAuthUser().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restPersonFavoritesModelsCollection.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) - .assertThat().entriesListContains("targetGuid", secondSiteModel.getGuid()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Verify user doesn't have permission to get favorites of another user with Rest API and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES }) - public void userIsNotAbleToRetrieveFavoritesOfAnotherUser() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .withCoreAPI().usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator).getUsername())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Verify user doesn't have permission to get favorites of admin user with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES }) - public void userIsNotAbleToRetrieveFavoritesOfAdminUser() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI() - .usingUser(adminUserModel).getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, adminUserModel.getUsername())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Verify admin user doesn't have permission to get favorites of another user with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES }) - public void adminIsNotAbleToRetrieveFavoritesOfAnotherUser() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator).getUsername())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Verify user gets status code 401 if authentication call fails") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - @Bug(id = "MNT-16904", description = "It fails only on environment with tenants") - public void userIsNotAbleToRetrieveFavoritesIfAuthenticationFails() throws JsonToModelConversionException, Exception - { - UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); - siteManager.setPassword("wrongPassword"); - restClient.authenticateUser(siteManager).withCoreAPI().usingAuthUser().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } -} diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesTests.java new file mode 100644 index 000000000..fbb9672a0 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesTests.java @@ -0,0 +1,588 @@ +package org.alfresco.rest.favorites; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestPersonFavoritesModel; +import org.alfresco.rest.model.RestPersonFavoritesModelsCollection; +import org.alfresco.rest.model.RestSiteModel; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class GetFavoritesTests extends RestTest +{ + private UserModel adminUserModel, userModel; + private SiteModel firstSiteModel; + private SiteModel secondSiteModel; + private SiteModel thirdSiteModel; + private FileModel firstFileModel; + private FileModel secondFileModel; + private FolderModel firstFolderModel; + private FolderModel secondFolderModel; + private ListUserWithRoles firstSiteUsers, secondSiteUsers; + private RestPersonFavoritesModelsCollection userFavorites; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + userModel = dataUser.createRandomTestUser(); + + firstSiteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + secondSiteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + thirdSiteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + firstFolderModel = dataContent.usingUser(adminUserModel).usingSite(firstSiteModel).createFolder(); + secondFolderModel = dataContent.usingUser(adminUserModel).usingSite(firstSiteModel).createFolder(); + firstFileModel = dataContent.usingUser(adminUserModel).usingResource(firstFolderModel).createContent(DocumentType.TEXT_PLAIN); + secondFileModel = dataContent.usingUser(adminUserModel).usingResource(firstFolderModel).createContent(DocumentType.TEXT_PLAIN); + + firstSiteUsers = dataUser.addUsersWithRolesToSite(firstSiteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + secondSiteUsers = dataUser.addUsersWithRolesToSite(secondSiteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + + restClient.authenticateUser(userModel); + restClient.withCoreAPI().usingUser(userModel).addSiteToFavorites(firstSiteModel); + restClient.withCoreAPI().usingUser(userModel).addSiteToFavorites(secondSiteModel); + restClient.withCoreAPI().usingUser(userModel).addSiteToFavorites(thirdSiteModel); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, + description = "Verify Manager user gets favorites with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) + public void managerIsAbleToRetrieveFavorites() throws Exception + { + restClient.authenticateUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteManager)); + restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); + restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(secondSiteModel); + + userFavorites = restClient.withCoreAPI().usingAuthUser().getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + userFavorites.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) + .assertThat().entriesListContains("targetGuid", secondSiteModel.getGuid()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, + description = "Verify user gets status code 401 if authentication call fails") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) +// @Bug(id = "MNT-16904", description = "It fails only on environment with tenants") + public void userIsNotAbleToRetrieveFavoritesIfAuthenticationFails() throws Exception + { + UserModel siteManager = firstSiteUsers.getOneUserWithRole(UserRole.SiteManager); + siteManager.setPassword("wrongPassword"); + restClient.authenticateUser(siteManager).withCoreAPI().usingAuthUser().getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify Admin user gets favorites sites with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void adminIsAbleToRetrieveFavoritesSites() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(firstSiteModel); + restClient.withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(secondSiteModel); + + userFavorites = restClient.withCoreAPI() + .usingAuthUser().where().targetSiteExist().getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + userFavorites.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) + .and().entriesListContains("targetGuid", secondSiteModel.getGuid()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify Admin user gets favorites folders with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void adminIsAbleToRetrieveFavoritesFolders() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).addFolderToFavorites(firstFolderModel); + restClient.withCoreAPI().usingUser(adminUserModel).addFolderToFavorites(secondFolderModel); + + userFavorites = restClient.withCoreAPI() + .usingAuthUser().where().targetFolderExist().getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + userFavorites.assertThat().entriesListContains("targetGuid", firstFolderModel.getNodeRef()) + .and().entriesListContains("targetGuid", secondFolderModel.getNodeRef()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify Admin user gets favorites files with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void adminIsAbleToRetrieveFavoritesFiles() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).addFileToFavorites(firstFileModel); + restClient.withCoreAPI().usingUser(adminUserModel).addFileToFavorites(secondFileModel); + + userFavorites = restClient.withCoreAPI() + .usingAuthUser().where().targetFileExist().getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + userFavorites.assertThat().entriesListContains("targetGuid", firstFileModel.getNodeRefWithoutVersion()) + .and().entriesListContains("targetGuid", secondFileModel.getNodeRefWithoutVersion()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify Collaborator user gets favorites with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void collaboratorIsAbleToRetrieveFavorites() throws Exception + { + restClient.authenticateUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); + restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(secondSiteModel); + + userFavorites = restClient.withCoreAPI().usingAuthUser().getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + userFavorites.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) + .and().entriesListContains("targetGuid", secondSiteModel.getGuid()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify Contributor user gets favorites with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void contributorIsAbleToRetrieveFavorites() throws Exception + { + restClient.authenticateUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteContributor)) + .withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); + restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(secondSiteModel); + + userFavorites = restClient.withCoreAPI().usingAuthUser().getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + userFavorites.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()).and() + .entriesListContains("targetGuid", secondSiteModel.getGuid()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify Consumer user gets favorites with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void consumerIsAbleToRetrieveFavorites() throws Exception + { + restClient.authenticateUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteConsumer)) + .withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); + restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(secondSiteModel); + + userFavorites = restClient.withCoreAPI().usingAuthUser().getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + userFavorites.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) + .assertThat().entriesListContains("targetGuid", secondSiteModel.getGuid()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify user doesn't have permission to get favorites of another user with Rest API and status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void userIsNotAbleToRetrieveFavoritesOfAnotherUser() throws Exception + { + restClient.authenticateUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteConsumer)) + .withCoreAPI().usingUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)).getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, firstSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator).getUsername())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify user doesn't have permission to get favorites of admin user with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void userIsNotAbleToRetrieveFavoritesOfAdminUser() throws Exception + { + restClient.authenticateUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI() + .usingUser(adminUserModel).getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, adminUserModel.getUsername())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify admin user doesn't have permission to get favorites of another user with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void adminIsNotAbleToRetrieveFavoritesOfAnotherUser() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)) + .getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, firstSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator).getUsername())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify User gets only favorites sites with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void userIsAbleToRetrieveOnlyFavoritesSites() throws Exception + { + restClient.authenticateUser(secondSiteUsers.getOneUserWithRole(UserRole.SiteManager)); + restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); + restClient.withCoreAPI().usingAuthUser().addFileToFavorites(firstFileModel); + restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(firstFolderModel); + + userFavorites = restClient.withCoreAPI().usingAuthUser().where().targetSiteExist().getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + userFavorites.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) + .and().entriesListDoesNotContain("targetGuid", secondSiteModel.getGuid()) + .and().entriesListDoesNotContain("targetGuid", firstFileModel.getNodeRefWithoutVersion()) + .and().entriesListDoesNotContain("targetGuid", firstFolderModel.getNodeRef()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify User gets only favorites files with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void userIsAbleToRetrieveOnlyFavoritesFiles() throws Exception + { + restClient.authenticateUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)); + restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); + restClient.withCoreAPI().usingAuthUser().addFileToFavorites(firstFileModel); + restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(firstFolderModel); + + userFavorites = restClient.withCoreAPI().usingAuthUser().where().targetFileExist().getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + userFavorites.assertThat().entriesListContains("targetGuid", firstFileModel.getNodeRefWithoutVersion()) + .and().entriesListDoesNotContain("targetGuid", secondFileModel.getNodeRefWithoutVersion()) + .and().entriesListDoesNotContain("targetGuid", firstSiteModel.getGuid()) + .and().entriesListDoesNotContain("targetGuid", firstFolderModel.getNodeRef()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify User gets only favorites folders with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void userIsAbleToRetrieveOnlyFavoritesFolders() throws Exception + { + restClient.authenticateUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)); + restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); + restClient.withCoreAPI().usingAuthUser().addFileToFavorites(firstFileModel); + restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(firstFolderModel); + + userFavorites = restClient.withCoreAPI().usingAuthUser().where().targetFolderExist().getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + userFavorites.assertThat().entriesListContains("targetGuid", firstFolderModel.getNodeRef()) + .and().entriesListDoesNotContain("targetGuid", secondFolderModel.getNodeRef()) + .and().entriesListDoesNotContain("targetGuid", firstSiteModel.getGuid()) + .and().entriesListDoesNotContain("targetGuid", firstFileModel.getNodeRefWithoutVersion()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify User gets only favorites files or folders with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void userIsAbleToRetrieveFavoritesFilesOrFolders() throws Exception + { + restClient.authenticateUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteConsumer)); + restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); + restClient.withCoreAPI().usingAuthUser().addFileToFavorites(firstFileModel); + restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(firstFolderModel); + + userFavorites = restClient.withCoreAPI().usingAuthUser() + .where().targetFolderExist().or().targetFileExist() + .getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + userFavorites.assertThat().entriesListContains("targetGuid", firstFolderModel.getNodeRef()) + .and().entriesListContains("targetGuid", firstFileModel.getNodeRefWithoutVersion()) + .and().entriesListDoesNotContain("targetGuid", secondFolderModel.getNodeRef()) + .and().entriesListDoesNotContain("targetGuid", secondFileModel.getNodeRefWithoutVersion()) + .and().entriesListDoesNotContain("targetGuid", firstSiteModel.getGuid()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify User gets only favorites files or sites with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void userIsAbleToRetrieveFavoritesFilesOrSites() throws Exception + { + restClient.authenticateUser(secondSiteUsers.getOneUserWithRole(UserRole.SiteManager)); + restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); + restClient.withCoreAPI().usingAuthUser().addFileToFavorites(firstFileModel); + restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(firstFolderModel); + + userFavorites = restClient.withCoreAPI().usingAuthUser() + .where().targetSiteExist().or().targetFileExist() + .getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + userFavorites.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) + .and().entriesListContains("targetGuid", firstFileModel.getNodeRefWithoutVersion()) + .and().entriesListDoesNotContain("targetGuid", secondSiteModel.getGuid()) + .and().entriesListDoesNotContain("targetGuid", secondFileModel.getNodeRefWithoutVersion()) + .and().entriesListDoesNotContain("targetGuid", firstFolderModel.getNodeRef()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify User gets only favorites folders or sites with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void userIsAbleToRetrieveFavoritesFoldersOrSites() throws Exception + { + restClient.authenticateUser(secondSiteUsers.getOneUserWithRole(UserRole.SiteManager)); + restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); + restClient.withCoreAPI().usingAuthUser().addFileToFavorites(firstFileModel); + restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(firstFolderModel); + + userFavorites = restClient.withCoreAPI().usingAuthUser() + .where().targetSiteExist().or().targetFolderExist() + .getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + userFavorites.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) + .and().entriesListContains("targetGuid", firstFolderModel.getNodeRef()) + .and().entriesListDoesNotContain("targetGuid", secondSiteModel.getGuid()) + .and().entriesListDoesNotContain("targetGuid", secondFolderModel.getNodeRef()) + .and().entriesListDoesNotContain("targetGuid", firstFileModel.getNodeRefWithoutVersion()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify User gets all favorites with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void userIsAbleToRetrieveAllFavorites() throws Exception + { + restClient.authenticateUser(secondSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)); + restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); + restClient.withCoreAPI().usingAuthUser().addFileToFavorites(firstFileModel); + restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(firstFolderModel); + + userFavorites = restClient.withCoreAPI().usingAuthUser() + .where().targetSiteExist().or().targetFolderExist().or().targetFileExist() + .getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + userFavorites.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) + .and().entriesListContains("targetGuid", firstFolderModel.getNodeRef()) + .and().entriesListContains("targetGuid", firstFileModel.getNodeRefWithoutVersion()) + .and().entriesListDoesNotContain("targetGuid", secondSiteModel.getGuid()) + .and().entriesListDoesNotContain("targetGuid", secondFolderModel.getNodeRef()) + .and().entriesListDoesNotContain("targetGuid", secondFileModel.getNodeRefWithoutVersion()); + + userFavorites = restClient.withCoreAPI().usingAuthUser().getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + userFavorites.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) + .and().entriesListContains("targetGuid", firstFolderModel.getNodeRef()) + .and().entriesListContains("targetGuid", firstFileModel.getNodeRefWithoutVersion()) + .and().entriesListDoesNotContain("targetGuid", secondSiteModel.getGuid()) + .and().entriesListDoesNotContain("targetGuid", secondFolderModel.getNodeRef()) + .and().entriesListDoesNotContain("targetGuid", secondFileModel.getNodeRefWithoutVersion()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify request for a user with no favorites returns status 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void userHasNoFavorites() throws Exception + { + restClient.authenticateUser(secondSiteUsers.getOneUserWithRole(UserRole.SiteContributor)); + + userFavorites = restClient.withCoreAPI().usingAuthUser().getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + userFavorites.assertThat().entriesListIsEmpty().and().paginationField("totalItems").is("0"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify request using invalid where parameter returns status 400") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void getFavoritesUsingInvalidWhereParameter() throws Exception + { + restClient.authenticateUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteConsumer)); + restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); + restClient.withCoreAPI().usingAuthUser().addFileToFavorites(firstFileModel); + restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(firstFolderModel); + + userFavorites = restClient.withCoreAPI().usingAuthUser() + .where().or().getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_ARGUMENT, "WHERE query")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify User gets correct favorites after deleting a favorite") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void checkFavoriteFolderIsRemoved() throws Exception + { + restClient.authenticateUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteManager)); + restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); + restClient.withCoreAPI().usingAuthUser().addFileToFavorites(firstFileModel); + restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(firstFolderModel); + + restClient.withCoreAPI().usingAuthUser().deleteFolderFromFavorites(firstFolderModel); + + userFavorites = restClient.withCoreAPI().usingAuthUser().getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + userFavorites.assertThat().entriesListDoesNotContain("targetGuid", firstFolderModel.getNodeRef()) + .and().paginationField("totalItems").is("2"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify get favorites specifying -me- string in place of for request") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void userIsAbleToGetFavoritesWhenUsingMeAsUsername() throws Exception + { + userFavorites = restClient.authenticateUser(userModel).withCoreAPI().usingMe().getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + userFavorites.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()).and().entriesListContains("targetGuid", secondSiteModel.getGuid()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify get favorites using empty for where parameter for request") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void userIsAbleToGetFavoritesWhenUsingEmptyWhereParameter() throws Exception + { + userFavorites = restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().where().getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_ARGUMENT, "WHERE query")); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that for invalid maxItems parameter status code returned is 400.") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void checkInvalidMaxItemsStatusCode() throws Exception + { + restClient.authenticateUser(adminUserModel).withParams("maxItems=AB").withCoreAPI().usingUser(adminUserModel).getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Invalid paging parameter"); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that for invalid skipCount parameter status code returned is 400.") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void checkInvalidSkipCountStatusCode() throws Exception + { + restClient.authenticateUser(adminUserModel).withParams("skipCount=AB").withCoreAPI().usingUser(adminUserModel).getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Invalid paging parameter"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify get favorites when using invalid network id for non-tenant user") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void getFavoritesWhenNetworkIdIsInvalid() throws Exception + { + UserModel networkUserModel = dataUser.createRandomTestUser(); + networkUserModel.setDomain("invalidNetwork"); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(networkUserModel).where().targetSiteExist().getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, networkUserModel.getUsername())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify get favorites using special chars in where parameter for request") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void userIsNotAbleToGetFavoritesWhenUsingSpecialCharsInWhereParameter() throws Exception + { + userFavorites = restClient.withCoreAPI().usingAuthUser().where().invalidWhereParameter("~!%40%23%24%25%5E%26*()_%2B%5B%5D%7B%7D%7C%5C%3B%27%3A%22%2C.%2F%3C%3E").getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_ARGUMENT, "WHERE query")) + .containsErrorKey(RestErrorModel.INVALID_QUERY_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify get favorites using AND instead of OR in where parameter for request") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void userIsNotAbleToGetFavoritesWhenUsingANDInWhereParameter() throws Exception + { + userFavorites = restClient.withCoreAPI().usingAuthUser().where().targetFolderExist().invalidWhereParameter("AND").targetFileExist().getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_ARGUMENT, "WHERE query")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify get favorites using wrong name instead of EXISTS in where parameter for request") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void userIsNotAbleToGetFavoritesWhenUsingWrongWhereParameter() throws Exception + { + userFavorites = restClient.withCoreAPI().usingAuthUser().where().invalidWhereParameter("EXIST((target/site))").targetFileExist().getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_ARGUMENT, "WHERE query")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify get favorites except the first one for request") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void userIsAbleToGetFavoritesExceptTheFirstOne() throws Exception + { + userFavorites = restClient.authenticateUser(userModel).withParams("skipCount=1").withCoreAPI().usingUser(userModel).getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + userFavorites.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) + .and().entriesListContains("targetGuid", secondSiteModel.getGuid()) + .and().entriesListDoesNotContain("targetGuid", thirdSiteModel.getGuid()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify get first two favorites sites") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void userIsAbleToGetFirstTwoFavorites() throws Exception + { + userFavorites = restClient.authenticateUser(userModel).withParams("maxItems=2").withCoreAPI().usingUser(userModel).getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + userFavorites.assertThat().entriesListContains("targetGuid", thirdSiteModel.getGuid()) + .and().entriesListContains("targetGuid", secondSiteModel.getGuid()) + .and().entriesListDoesNotContain("targetGuid", firstSiteModel.getGuid()) + .getPagination().assertThat().field("maxItems").is("2") + .and().field("hasMoreItems").is("true") + .and().field("count").is("2"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify get favorites sites when using empty values for skipCount and maxItems") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void userIsAbleToGetFavoritesWhenSkipCountAndMaxItemsAreEmpty() throws Exception + { + restClient.authenticateUser(userModel).withParams("skipCount= ").withCoreAPI().usingUser(userModel).getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, " ")); + + restClient.authenticateUser(userModel).withParams("maxItems= ").withCoreAPI().usingUser(userModel).getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, " ")); + } + + @Bug(id = "MNT-16904") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify the get favorites request when network id is invalid for tenant user") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION, TestGroup.NETWORKS}) + public void getFavoriteSitesWhenNetworkIdIsInvalid() throws Exception + { + UserModel adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUserModel); + restClient.usingTenant().createTenant(adminTenantUser); + UserModel tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); + + tenantUser.setDomain("invalidNetwork"); + restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify the get favorites request for a high value for skipCount parameter") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void userIsAbleToGetFavoritesWithHighSkipCount() throws Exception + { + userFavorites = restClient.authenticateUser(userModel).withParams("skipCount=999999999").withCoreAPI().usingUser(userModel).getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + userFavorites.assertThat().entriesListIsEmpty().assertThat().paginationField("skipCount").is("999999999"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify the get favorites request with properties parameter applied") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void userIsAbleToGetFavoritesWithPropertiesParamApplied() throws Exception + { + userFavorites = restClient.authenticateUser(userModel).withParams("properties=targetGuid").withCoreAPI().usingUser(userModel).getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + RestPersonFavoritesModel restPersonFavoritesModel = userFavorites.getEntries().get(0).onModel(); + restPersonFavoritesModel.assertThat().field("targetGuid").is(thirdSiteModel.getGuid()).and().field("createdAt").isNull(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify entry details for get favorites response with Rest API") + public void checkResponseSchemaForGetFavorites() throws Exception + { + userFavorites = restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + RestPersonFavoritesModel restPersonFavoritesModel = userFavorites.getEntries().get(0).onModel(); + restPersonFavoritesModel.assertThat().field("targetGuid").is(thirdSiteModel.getGuid()); + + RestSiteModel restSiteModel = restPersonFavoritesModel.getTarget().getSite(); + restSiteModel.assertThat().field("visibility").is(thirdSiteModel.getVisibility()).and() + .field("guid").is(thirdSiteModel.getGuid()).and() + .field("description").is(thirdSiteModel.getDescription()).and() + .field("id").is(thirdSiteModel.getId()).and() + .field("title").is(thirdSiteModel.getTitle()); + } +} From f7b4958652332a3432f94d5ea186320a510bc7a4 Mon Sep 17 00:00:00 2001 From: cagache Date: Fri, 6 Oct 2017 12:45:15 +0300 Subject: [PATCH 1228/1491] REPO-2755 / REPO-2251: changed CORE group with REGRESSION in queries package --- e2e-test/java/org/alfresco/rest/queries/QueriesTest.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/queries/QueriesTest.java b/e2e-test/java/org/alfresco/rest/queries/QueriesTest.java index 50a75c436..c4abac22c 100644 --- a/e2e-test/java/org/alfresco/rest/queries/QueriesTest.java +++ b/e2e-test/java/org/alfresco/rest/queries/QueriesTest.java @@ -14,10 +14,9 @@ import org.testng.annotations.Test; */ public class QueriesTest extends RestTest { - - @TestRail(section = { TestGroup.REST_API, - TestGroup.QUERIES }, executionType = ExecutionType.REGRESSION, description = "Verify GET queries on queries/nodes returnes success status code") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.QUERIES }, + executionType = ExecutionType.REGRESSION, description = "Verify GET queries on queries/nodes returnes success status code") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) public void getOnQueriesNodesRoute() throws Exception { restClient.authenticateUser(dataContent.getAdminUser()) From 7b0e1919a83b6ea4b060e6fde91e78dbe0bd0499 Mon Sep 17 00:00:00 2001 From: cagache Date: Fri, 6 Oct 2017 13:07:11 +0300 Subject: [PATCH 1229/1491] REPO-2755 / REPO-2251: changed FULL group with REGRESSION in trashcan package --- .../org/alfresco/rest/trashcan/GetDeletedNodesTests.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/trashcan/GetDeletedNodesTests.java b/e2e-test/java/org/alfresco/rest/trashcan/GetDeletedNodesTests.java index 5a9b64e1e..d59596b1e 100644 --- a/e2e-test/java/org/alfresco/rest/trashcan/GetDeletedNodesTests.java +++ b/e2e-test/java/org/alfresco/rest/trashcan/GetDeletedNodesTests.java @@ -47,7 +47,6 @@ public class GetDeletedNodesTests extends RestTest adminUserModel = dataUser.getAdminUser(); restClient.authenticateUser(adminUserModel); deleteNodesSiteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - } @AfterClass(alwaysRun=true) @@ -56,7 +55,7 @@ public class GetDeletedNodesTests extends RestTest dataSite.usingAdmin().deleteSite(deleteNodesSiteModel); } - @Test(groups = { TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.REGRESSION }) public void testDeletedNodesBiggerThanMaxCount() throws Exception { //get the number of item in the trashcan @@ -84,9 +83,6 @@ public class GetDeletedNodesTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); deletedNodesMaxItem.getPagination().assertThat().field("totalItems").is(totalItemsMaxItem).and().field("count").is(countMaxItem); - deletedNodesMaxItem.getPagination().assertThat().field("hasMoreItems").is(hasMoreItemsMaxItem).and().field("skipCount").is(skipCount); - + deletedNodesMaxItem.getPagination().assertThat().field("hasMoreItems").is(hasMoreItemsMaxItem).and().field("skipCount").is(skipCount); } - - } From b1c63bd2e1c6efaa7d559df35139c726f1c677fc Mon Sep 17 00:00:00 2001 From: cagache Date: Fri, 6 Oct 2017 14:18:34 +0300 Subject: [PATCH 1230/1491] REPO-2755 / REPO-2251: changed CORE and FULL groups with REGRESSION in ratings package --- .../rest/ratings/AddRatingCoreTests.java | 302 ------- .../rest/ratings/AddRatingFullTests.java | 518 ----------- .../rest/ratings/AddRatingSanityTests.java | 214 ----- .../alfresco/rest/ratings/AddRatingTests.java | 813 ++++++++++++++++++ .../rest/ratings/DeleteRatingCoreTests.java | 149 ---- .../rest/ratings/DeleteRatingFullTests.java | 241 ------ .../rest/ratings/DeleteRatingSanityTests.java | 215 ----- .../rest/ratings/DeleteRatingTests.java | 525 +++++++++++ .../rest/ratings/GetRatingCoreTests.java | 150 ---- .../rest/ratings/GetRatingFullTests.java | 199 ----- .../rest/ratings/GetRatingSanityTests.java | 172 ---- .../alfresco/rest/ratings/GetRatingTests.java | 438 ++++++++++ .../rest/ratings/GetRatingsCoreTests.java | 105 --- .../rest/ratings/GetRatingsFullTests.java | 116 --- .../rest/ratings/GetRatingsSanityTests.java | 150 ---- .../rest/ratings/GetRatingsTests.java | 313 +++++++ 16 files changed, 2089 insertions(+), 2531 deletions(-) delete mode 100644 e2e-test/java/org/alfresco/rest/ratings/AddRatingCoreTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/ratings/AddRatingFullTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java create mode 100644 e2e-test/java/org/alfresco/rest/ratings/AddRatingTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/ratings/DeleteRatingCoreTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/ratings/DeleteRatingFullTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java create mode 100644 e2e-test/java/org/alfresco/rest/ratings/DeleteRatingTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/ratings/GetRatingCoreTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/ratings/GetRatingFullTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java create mode 100644 e2e-test/java/org/alfresco/rest/ratings/GetRatingTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/ratings/GetRatingsCoreTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/ratings/GetRatingsFullTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/ratings/GetRatingsSanityTests.java create mode 100644 e2e-test/java/org/alfresco/rest/ratings/GetRatingsTests.java diff --git a/e2e-test/java/org/alfresco/rest/ratings/AddRatingCoreTests.java b/e2e-test/java/org/alfresco/rest/ratings/AddRatingCoreTests.java deleted file mode 100644 index 123976721..000000000 --- a/e2e-test/java/org/alfresco/rest/ratings/AddRatingCoreTests.java +++ /dev/null @@ -1,302 +0,0 @@ -package org.alfresco.rest.ratings; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestCommentModel; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestRatingModel; -import org.alfresco.rest.model.RestTagModel; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.exception.DataPreparationException; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.LinkModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.apache.commons.lang3.RandomStringUtils; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class AddRatingCoreTests extends RestTest -{ - private UserModel userModel; - private SiteModel siteModel; - private UserModel adminUser; - private ListUserWithRoles usersWithRoles; - private RestRatingModel returnedRatingModel; // placeholder for returned model - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws DataPreparationException - { - userModel = dataUser.createUser(RandomStringUtils.randomAlphanumeric(20)); - adminUser = dataUser.getAdminUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Verify that if unknown rating scheme is provided status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) - public void unknownRatingSchemeReturnsBadRequest() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"invalidRate\"}"); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsSummary(String.format(RestErrorModel.INVALID_RATING, "invalidRate")) - .containsErrorKey(String.format(RestErrorModel.INVALID_RATING, "invalidRate")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Verify that if nodeId does not exist status code 404 is returned") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) - public void invalidNodeIdReturnsNotFound() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - document.setNodeRef(RandomStringUtils.randomAlphanumeric(10)); - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, document.getNodeRef())) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Verify that if nodeId provided cannot be rated 405 status code is returned") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) - public void likeResourceThatCannotBeRated() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - LinkModel link = dataLink.usingAdmin().usingSite(siteModel).createRandomLink(); - document.setNodeRef(link.getNodeRef().replace("workspace://SpacesStore/", "workspace%3A%2F%2FSpacesStore%2F")); - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, document.getNodeRef())) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Verify that manager is able to like a file") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) - public void managerIsAbleToLikeAFile() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(document) - .likeDocument(); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Verify that manager is able to like a folder") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) - public void managerIsAbleToLikeAFolder() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(folderModel) - .likeDocument(); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Verify that manager is able to like a site") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) - public void managerIsAbleToLikeASite() throws Exception - { - FolderModel folderModel = new FolderModel(); - folderModel.setNodeRef(siteModel.getGuid()); - - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(folderModel) - .likeDocument(); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty(); - - restClient.withCoreAPI().usingResource(folderModel).getRatings() - .assertNodeIsLiked(); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Verify that manager is able to rate a folder") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) - public void managerIsAbleToRateAFolder() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(folderModel) - .rateStarsToDocument(5); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Verify that manager is able to rate a file") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) - public void managerIsAbleToRateAFile() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(document) - .rateStarsToDocument(5); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Verify that manager is able to rate a site") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) - public void managerIsAbleToRateASite() throws Exception - { - FolderModel folderModel = new FolderModel(); - folderModel.setNodeRef(siteModel.getGuid()); - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(folderModel) - .rateStarsToDocument(5); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); - - restClient.withCoreAPI().usingResource(folderModel).getRatings() - .assertNodeHasFiveStarRating(); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Verify that adding like again has no effect on a file") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) - public void fileCanBeLikedTwice() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Verify that adding rate again has no effect on a file") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) - public void fileCanBeRatedTwice() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).rateStarsToDocument(5); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).rateStarsToDocument(5); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Verify that rate is not added if empty rating object is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) - public void addRateUsingEmptyRatingObject() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating(""); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.NO_CONTENT, "No content to map to Object due to end of input")); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Verify that if empty rate id is provided status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) - public void addRateUsingEmptyValueForId() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"\"}"); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.NO_CONTENT, "N/A (through reference chain: org.alfresco.rest.api.model.NodeRating[\"id\"])")); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Verify that if empty rating is provided status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) - public void addRateUsingEmptyValueForMyRating() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"likes\", \"myRating\":\"\"}"); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.NULL_LIKE_RATING)); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"fiveStar\", \"myRating\":\"\"}"); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.NULL_FIVESTAR_RATING)); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Verify that user is not able to rate a comment") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) - public void addRatingToAComment() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - RestCommentModel comment = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addComment("This is a comment"); - document.setNodeRef(comment.getId()); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) - .assertLastError() - .containsSummary(String.format(RestErrorModel.CANNOT_RATE)) - .containsErrorKey(RestErrorModel.CANNOT_RATE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).rateStarsToDocument(5); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(String.format(RestErrorModel.CANNOT_RATE)); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Verify that user is not able to rate a tag") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) - public void addRatingToATag() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - RestTagModel tag = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addTag("randomTag"); - document.setNodeRef(tag.getId()); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(String.format(RestErrorModel.CANNOT_RATE)); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).rateStarsToDocument(5); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(String.format(RestErrorModel.CANNOT_RATE)); - } - -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/ratings/AddRatingFullTests.java b/e2e-test/java/org/alfresco/rest/ratings/AddRatingFullTests.java deleted file mode 100644 index 6207473b7..000000000 --- a/e2e-test/java/org/alfresco/rest/ratings/AddRatingFullTests.java +++ /dev/null @@ -1,518 +0,0 @@ -package org.alfresco.rest.ratings; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestCommentModel; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestRatingModel; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.exception.DataPreparationException; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.apache.commons.lang3.RandomStringUtils; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class AddRatingFullTests extends RestTest -{ - private UserModel userModel; - private SiteModel siteModel; - private UserModel adminUser; - private ListUserWithRoles usersWithRoles; - private RestRatingModel returnedRatingModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws DataPreparationException - { - userModel = dataUser.createUser(RandomStringUtils.randomAlphanumeric(20)); - adminUser = dataUser.getAdminUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that Contributor is able to like a file") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) - public void contributorIsAbleToLikeAFile() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI() - .usingResource(document) - .likeDocument(); - - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedRatingModel.assertThat().field("myRating").is("true") - .and().field("id").is("likes") - .and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that Collaborator is able to like a file") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) - public void collaboratorIsAbleToLikeAFile() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI() - .usingResource(document) - .likeDocument(); - - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedRatingModel.assertThat().field("myRating").is("true") - .and().field("id").is("likes") - .and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that Consumer is able to like a file") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) - public void consumerIsAbleToLikeAFile() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI() - .usingResource(document) - .likeDocument(); - - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedRatingModel.assertThat().field("myRating").is("true") - .and().field("id").is("likes") - .and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that Contributor is able to like a folder") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) - public void contributorIsAbleToLikeAFolder() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI() - .usingResource(folderModel) - .likeDocument(); - - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedRatingModel.assertThat().field("myRating").is("true") - .and().field("id").is("likes") - .and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that Collaborator is able to like a folder") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) - public void collaboratorIsAbleToLikeAFolder() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI() - .usingResource(folderModel) - .likeDocument(); - - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedRatingModel.assertThat().field("myRating").is("true") - .and().field("id").is("likes") - .and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that Consumer is able to like a folder") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) - public void consumerIsAbleToLikeAFolder() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI() - .usingResource(folderModel) - .likeDocument(); - - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedRatingModel.assertThat().field("myRating").is("true") - .and().field("id").is("likes") - .and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that Contributor is able to rate a file") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) - public void contributorIsAbleToRateAFile() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI() - .usingResource(document) - .rateStarsToDocument(5); - - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedRatingModel.assertThat().field("myRating").is("5") - .and().field("id").is("fiveStar") - .and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that Collaborator is able to rate a file") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) - public void collaboratorIsAbleToRateAFile() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI() - .usingResource(document) - .rateStarsToDocument(5); - - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedRatingModel.assertThat().field("myRating").is("5") - .and().field("id").is("fiveStar") - .and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that Consumer is able to rate a file") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) - public void consumerIsAbleToRateAFile() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI() - .usingResource(document) - .rateStarsToDocument(5); - - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedRatingModel.assertThat().field("myRating").is("5") - .and().field("id").is("fiveStar") - .and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that Contributor is able to rate a folder") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) - public void contributorIsAbleToRateAFolder() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI() - .usingResource(folderModel) - .rateStarsToDocument(5); - - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedRatingModel.assertThat().field("myRating").is("5") - .and().field("id").is("fiveStar") - .and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that Collaborator is able to rate a folder") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) - public void collaboratorIsAbleToRateAFolder() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI() - .usingResource(folderModel) - .rateStarsToDocument(5); - - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedRatingModel.assertThat().field("myRating").is("5") - .and().field("id").is("fiveStar") - .and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that Consumer is able to rate a folder") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) - public void consumerIsAbleToRateAFolder() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI() - .usingResource(folderModel) - .rateStarsToDocument(5); - - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedRatingModel.assertThat().field("myRating").is("5") - .and().field("id").is("fiveStar") - .and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that adding like again has no effect on a folder") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) - public void folderCanBeLikedTwice() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folderModel).likeDocument(); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folderModel).likeDocument(); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("true") - .and().field("id").is("likes") - .and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that adding rate again has no effect on a folder") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) - public void folderCanBeRatedTwice() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folderModel).rateStarsToDocument(5); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folderModel).rateStarsToDocument(5); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("5") - .and().field("id").is("fiveStar") - .and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that if invalid rate id is provided status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) - public void addRateUsingInvalidValueForId() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"like\"}"); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsSummary(String.format(RestErrorModel.INVALID_RATING, "like")) - .containsErrorKey(String.format(RestErrorModel.INVALID_RATING, "like")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that rate id is case sensitive is provided status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) - public void addRateUsingInvalidValueForIdCaseSensitive() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"Likes\"}"); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsSummary(String.format(RestErrorModel.INVALID_RATING, "Likes")) - .containsErrorKey(String.format(RestErrorModel.INVALID_RATING, "Likes")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"FiveStar\"}"); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsSummary(String.format(RestErrorModel.INVALID_RATING, "FiveStar")) - .containsErrorKey(String.format(RestErrorModel.INVALID_RATING, "FiveStar")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that if invalid rating is provided status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) - public void addRateUsingInvalidValueForMyRating() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"likes\", \"myRating\":\"skiped\"}"); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsSummary(String.format(RestErrorModel.NULL_LIKE_RATING)); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"fiveStar\", \"myRating\":\"string\"}"); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsSummary(String.format(RestErrorModel.NULL_FIVESTAR_RATING)); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Like file created by a different user") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) - public void addLikeToAnotherUserFile() throws Exception - { - UserModel user = dataUser.usingAdmin().createRandomTestUser(); - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - returnedRatingModel = restClient.authenticateUser(user).withCoreAPI().usingResource(document).likeDocument(); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedRatingModel.assertThat().field("myRating").is("true") - .and().field("id").is("likes") - .and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Rate a file created by a different user") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) - public void addRatingToAnotherUserFile() throws Exception - { - UserModel user = dataUser.usingAdmin().createRandomTestUser(); - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - returnedRatingModel = restClient.authenticateUser(user).withCoreAPI().usingResource(document).rateStarsToDocument(5); - returnedRatingModel.assertThat().field("myRating").is("5") - .and().field("id").is("fiveStar") - .and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Add Rate Using Boolean Value For 'myRating'") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) - public void addRateUsingBooleanValueForMyRating() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"fiveStar\", \"myRating\":\"true\"}"); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsSummary(RestErrorModel.NULL_FIVESTAR_RATING) - .containsErrorKey(RestErrorModel.NULL_FIVESTAR_RATING) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Add Like Using Integer Value For 'myRating'") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) - public void addLikeUsingIntegerValueForMyRating() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"likes\", \"myRating\":\"2\"}"); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsSummary(RestErrorModel.NULL_LIKE_RATING) - .containsErrorKey(RestErrorModel.NULL_LIKE_RATING) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that user is not able to like his own comment") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) - public void userCannotLikeHisOwnComment() throws Exception - { - UserModel user = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); - FolderModel folderModel = dataContent.usingUser(user).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(user).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - RestCommentModel comment = restClient.authenticateUser(user).withCoreAPI().usingResource(document).addComment("This is a comment"); - document.setNodeRef(comment.getId()); - - returnedRatingModel = restClient.authenticateUser(user).withCoreAPI().usingResource(document).likeDocument(); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) - .assertLastError() - .containsSummary(String.format(RestErrorModel.CANNOT_RATE)) - .containsErrorKey(RestErrorModel.CANNOT_RATE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER).stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that user is not able to rate his own comment") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) - public void userCannotRateHisOwnComment() throws Exception - { - UserModel user = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); - FolderModel folderModel = dataContent.usingUser(user).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(user).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - RestCommentModel comment = restClient.authenticateUser(user).withCoreAPI().usingResource(document).addComment("This is a comment"); - document.setNodeRef(comment.getId()); - - returnedRatingModel = restClient.authenticateUser(user).withCoreAPI().usingResource(document).rateStarsToDocument(5); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) - .assertLastError() - .containsSummary(String.format(RestErrorModel.CANNOT_RATE)) - .containsErrorKey(RestErrorModel.CANNOT_RATE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that Collaborator is NOT able to add a negative rating to a file") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) - public void collaboratorIsNotAbleToAddANegativeRatingToAFile() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI() - .usingResource(document) - .rateStarsToDocument(-5); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsSummary(RestErrorModel.RATING_OUT_OF_BOUNDS) - .containsErrorKey(RestErrorModel.RATING_OUT_OF_BOUNDS) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that Collaborator is NOT able to add a high rating to a file") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) - public void collaboratorIsNotAbleToAddAHighRatingToAFile() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI() - .usingResource(document) - .rateStarsToDocument(10); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsSummary(RestErrorModel.RATING_OUT_OF_BOUNDS) - .containsErrorKey(RestErrorModel.RATING_OUT_OF_BOUNDS) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - -// @Bug(id = "MNT-17375", description = "Won't Fix, the error message is not ideal and a little cryptic but it does provide the reason i.e. ratingSchemeId is null.") - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Do not provide field - 'id'") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) - public void notProvideIdLikeFile() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"myRating\":\"true\"}"); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsSummary(String.format(RestErrorModel.INVALID_RATING, "null")) - .containsErrorKey(String.format(RestErrorModel.INVALID_RATING, "null")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Do not provide field - 'myRating'") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) - public void notProvideMyRatingRateFile() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"likes\"}"); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsSummary(RestErrorModel.NULL_LIKE_RATING) - .containsErrorKey(RestErrorModel.NULL_LIKE_RATING) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } -} diff --git a/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java deleted file mode 100644 index 8b81a47c6..000000000 --- a/e2e-test/java/org/alfresco/rest/ratings/AddRatingSanityTests.java +++ /dev/null @@ -1,214 +0,0 @@ -package org.alfresco.rest.ratings; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestRatingModel; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.exception.DataPreparationException; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.apache.commons.lang3.RandomStringUtils; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - - -public class AddRatingSanityTests extends RestTest -{ - private UserModel userModel; - private SiteModel siteModel; - private UserModel adminUser; - private ListUserWithRoles usersWithRoles; - private RestRatingModel returnedRatingModel; // placeholder for returned model - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws DataPreparationException - { - userModel = dataUser.createUser(RandomStringUtils.randomAlphanumeric(20)); - adminUser = dataUser.getAdminUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role is able to post like rating to a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) - public void managerIsAbleToLikeDocument() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(document) - .likeDocument(); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Collaborator role is able to post like rating to a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) - public void collaboratorIsAbleToLikeDocument() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(document) - .likeDocument(); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Contributor role is able to post like rating to a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) - public void contributorIsAbleToLikeDocument() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingResource(document) - .likeDocument(); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role is able to post like rating to a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) - public void consumerIsAbleToLikeDocument() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingResource(document) - .likeDocument(); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify admin user is able to post like rating to a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) - public void adminIsAbleToLikeDocument() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - returnedRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to post like rating to a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) - @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void unauthenticatedUserIsNotAbleToLikeDocument() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(new UserModel("random user", "random password")).withCoreAPI().usingResource(document).likeDocument(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role is able to post stars rating to a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) - public void managerIsAbleToAddStarsToDocument() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(document) - .rateStarsToDocument(5); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Collaborator role is able to post stars rating to a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) - public void collaboratorIsAbleToAddStarsToDocument() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(document) - .rateStarsToDocument(5); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); - - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Contributor role is able to post stars rating to a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) - public void contributorIsAbleToAddStarsToDocument() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingResource(document) - .rateStarsToDocument(5); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role is able to post stars rating to a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) - public void consumerIsAbleToAddStarsToDocument() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingResource(document) - .rateStarsToDocument(5); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify admin user is able to post stars rating to a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) - public void adminIsAbleToAddStarsToDocument() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - returnedRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).rateStarsToDocument(3); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedRatingModel.assertThat().field("myRating").is("3").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to post stars rating to a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) - @Bug(id="MNT-16904", description = "fails only on environment with tenants") - public void unauthenticatedUserIsNotAbleToRateStarsToDocument() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(new UserModel("random user", "random password")).withCoreAPI().usingResource(document).rateStarsToDocument(5); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/ratings/AddRatingTests.java b/e2e-test/java/org/alfresco/rest/ratings/AddRatingTests.java new file mode 100644 index 000000000..f6e639797 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/ratings/AddRatingTests.java @@ -0,0 +1,813 @@ +package org.alfresco.rest.ratings; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestCommentModel; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestRatingModel; +import org.alfresco.rest.model.RestTagModel; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.exception.DataPreparationException; +import org.alfresco.utility.model.*; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.apache.commons.lang3.RandomStringUtils; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + + +public class AddRatingTests extends RestTest +{ + private UserModel userModel; + private SiteModel siteModel; + private UserModel adminUser; + private ListUserWithRoles usersWithRoles; + private RestRatingModel returnedRatingModel; // placeholder for returned model + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws DataPreparationException + { + userModel = dataUser.createRandomTestUser(); + adminUser = dataUser.getAdminUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.SANITY, description = "Verify user with Manager role is able to post like rating to a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) + public void managerIsAbleToLikeDocument() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(document) + .likeDocument(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Verify user with Collaborator role is able to post like rating to a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void collaboratorIsAbleToLikeDocument() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(document) + .likeDocument(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Verify user with Contributor role is able to post like rating to a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void contributorIsAbleToLikeDocument() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingResource(document) + .likeDocument(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Verify user with Consumer role is able to post like rating to a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void consumerIsAbleToLikeDocument() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingResource(document) + .likeDocument(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Verify admin user is able to post like rating to a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void adminIsAbleToLikeDocument() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + returnedRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to post like rating to a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) +// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") + public void unauthenticatedUserIsNotAbleToLikeDocument() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(new UserModel("random user", "random password")).withCoreAPI().usingResource(document).likeDocument(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.SANITY, description = "Verify user with Manager role is able to post stars rating to a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) + public void managerIsAbleToAddStarsToDocument() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(document) + .rateStarsToDocument(5); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Verify user with Collaborator role is able to post stars rating to a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void collaboratorIsAbleToAddStarsToDocument() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(document) + .rateStarsToDocument(5); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); + + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Verify user with Contributor role is able to post stars rating to a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void contributorIsAbleToAddStarsToDocument() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingResource(document) + .rateStarsToDocument(5); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Verify user with Consumer role is able to post stars rating to a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void consumerIsAbleToAddStarsToDocument() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingResource(document) + .rateStarsToDocument(5); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.REGRESSION }, + executionType = ExecutionType.SANITY, description = "Verify admin user is able to post stars rating to a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void adminIsAbleToAddStarsToDocument() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + returnedRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).rateStarsToDocument(3); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedRatingModel.assertThat().field("myRating").is("3").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to post stars rating to a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) +// @Bug(id="MNT-16904", description = "fails only on environment with tenants") + public void unauthenticatedUserIsNotAbleToRateStarsToDocument() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(new UserModel("random user", "random password")).withCoreAPI().usingResource(document).rateStarsToDocument(5); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Verify that if unknown rating scheme is provided status code is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void unknownRatingSchemeReturnsBadRequest() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"invalidRate\"}"); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsSummary(String.format(RestErrorModel.INVALID_RATING, "invalidRate")) + .containsErrorKey(String.format(RestErrorModel.INVALID_RATING, "invalidRate")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Verify that if nodeId does not exist status code 404 is returned") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void invalidNodeIdReturnsNotFound() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + document.setNodeRef(RandomStringUtils.randomAlphanumeric(10)); + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, document.getNodeRef())) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Verify that if nodeId provided cannot be rated 405 status code is returned") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void likeResourceThatCannotBeRated() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + LinkModel link = dataLink.usingAdmin().usingSite(siteModel).createRandomLink(); + document.setNodeRef(link.getNodeRef().replace("workspace://SpacesStore/", "workspace%3A%2F%2FSpacesStore%2F")); + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, document.getNodeRef())) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.SANITY, description = "Verify that manager is able to like a folder") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) + public void managerIsAbleToLikeAFolder() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(folderModel) + .likeDocument(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.SANITY, description = "Verify that manager is able to like a site") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) + public void managerIsAbleToLikeASite() throws Exception + { + FolderModel folderModel = new FolderModel(); + folderModel.setNodeRef(siteModel.getGuid()); + + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(folderModel) + .likeDocument(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty(); + + restClient.withCoreAPI().usingResource(folderModel).getRatings() + .assertNodeIsLiked(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.SANITY, description = "Verify that manager is able to rate a folder") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) + public void managerIsAbleToRateAFolder() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(folderModel) + .rateStarsToDocument(5); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.SANITY }, + executionType = ExecutionType.REGRESSION, description = "Verify that manager is able to rate a site") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) + public void managerIsAbleToRateASite() throws Exception + { + FolderModel folderModel = new FolderModel(); + folderModel.setNodeRef(siteModel.getGuid()); + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(folderModel) + .rateStarsToDocument(5); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); + + restClient.withCoreAPI().usingResource(folderModel).getRatings() + .assertNodeHasFiveStarRating(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Verify that adding like again has no effect on a file") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void fileCanBeLikedTwice() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Verify that adding rate again has no effect on a file") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void fileCanBeRatedTwice() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).rateStarsToDocument(5); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).rateStarsToDocument(5); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Verify that rate is not added if empty rating object is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void addRateUsingEmptyRatingObject() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating(""); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.NO_CONTENT, "No content to map to Object due to end of input")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Verify that if empty rate id is provided status code is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void addRateUsingEmptyValueForId() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"\"}"); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.NO_CONTENT, "N/A (through reference chain: org.alfresco.rest.api.model.NodeRating[\"id\"])")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Verify that if empty rating is provided status code is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void addRateUsingEmptyValueForMyRating() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"likes\", \"myRating\":\"\"}"); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.NULL_LIKE_RATING)); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"fiveStar\", \"myRating\":\"\"}"); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.NULL_FIVESTAR_RATING)); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Verify that user is not able to rate a comment") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void addRatingToAComment() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + RestCommentModel comment = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addComment("This is a comment"); + document.setNodeRef(comment.getId()); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) + .assertLastError() + .containsSummary(String.format(RestErrorModel.CANNOT_RATE)) + .containsErrorKey(RestErrorModel.CANNOT_RATE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).rateStarsToDocument(5); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(String.format(RestErrorModel.CANNOT_RATE)); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Verify that user is not able to rate a tag") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void addRatingToATag() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + RestTagModel tag = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addTag("randomTag"); + document.setNodeRef(tag.getId()); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(String.format(RestErrorModel.CANNOT_RATE)); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).rateStarsToDocument(5); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(String.format(RestErrorModel.CANNOT_RATE)); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that Contributor is able to like a folder") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void contributorIsAbleToLikeAFolder() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI() + .usingResource(folderModel) + .likeDocument(); + + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedRatingModel.assertThat().field("myRating").is("true") + .and().field("id").is("likes") + .and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that Collaborator is able to like a folder") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void collaboratorIsAbleToLikeAFolder() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI() + .usingResource(folderModel) + .likeDocument(); + + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedRatingModel.assertThat().field("myRating").is("true") + .and().field("id").is("likes") + .and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that Consumer is able to like a folder") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void consumerIsAbleToLikeAFolder() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI() + .usingResource(folderModel) + .likeDocument(); + + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedRatingModel.assertThat().field("myRating").is("true") + .and().field("id").is("likes") + .and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that Contributor is able to rate a folder") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void contributorIsAbleToRateAFolder() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI() + .usingResource(folderModel) + .rateStarsToDocument(5); + + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedRatingModel.assertThat().field("myRating").is("5") + .and().field("id").is("fiveStar") + .and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that Collaborator is able to rate a folder") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void collaboratorIsAbleToRateAFolder() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI() + .usingResource(folderModel) + .rateStarsToDocument(5); + + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedRatingModel.assertThat().field("myRating").is("5") + .and().field("id").is("fiveStar") + .and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that Consumer is able to rate a folder") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void consumerIsAbleToRateAFolder() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI() + .usingResource(folderModel) + .rateStarsToDocument(5); + + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedRatingModel.assertThat().field("myRating").is("5") + .and().field("id").is("fiveStar") + .and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that adding like again has no effect on a folder") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void folderCanBeLikedTwice() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folderModel).likeDocument(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folderModel).likeDocument(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("true") + .and().field("id").is("likes") + .and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that adding rate again has no effect on a folder") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void folderCanBeRatedTwice() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folderModel).rateStarsToDocument(5); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folderModel).rateStarsToDocument(5); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("5") + .and().field("id").is("fiveStar") + .and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that if invalid rate id is provided status code is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void addRateUsingInvalidValueForId() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"like\"}"); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsSummary(String.format(RestErrorModel.INVALID_RATING, "like")) + .containsErrorKey(String.format(RestErrorModel.INVALID_RATING, "like")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that rate id is case sensitive is provided status code is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void addRateUsingInvalidValueForIdCaseSensitive() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"Likes\"}"); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsSummary(String.format(RestErrorModel.INVALID_RATING, "Likes")) + .containsErrorKey(String.format(RestErrorModel.INVALID_RATING, "Likes")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"FiveStar\"}"); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsSummary(String.format(RestErrorModel.INVALID_RATING, "FiveStar")) + .containsErrorKey(String.format(RestErrorModel.INVALID_RATING, "FiveStar")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that if invalid rating is provided status code is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void addRateUsingInvalidValueForMyRating() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"likes\", \"myRating\":\"skiped\"}"); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsSummary(String.format(RestErrorModel.NULL_LIKE_RATING)); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"fiveStar\", \"myRating\":\"string\"}"); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsSummary(String.format(RestErrorModel.NULL_FIVESTAR_RATING)); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Like file created by a different user") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void addLikeToAnotherUserFile() throws Exception + { + UserModel user = dataUser.usingAdmin().createRandomTestUser(); + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + returnedRatingModel = restClient.authenticateUser(user).withCoreAPI().usingResource(document).likeDocument(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedRatingModel.assertThat().field("myRating").is("true") + .and().field("id").is("likes") + .and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Rate a file created by a different user") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void addRatingToAnotherUserFile() throws Exception + { + UserModel user = dataUser.usingAdmin().createRandomTestUser(); + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + returnedRatingModel = restClient.authenticateUser(user).withCoreAPI().usingResource(document).rateStarsToDocument(5); + returnedRatingModel.assertThat().field("myRating").is("5") + .and().field("id").is("fiveStar") + .and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Add Rate Using Boolean Value For 'myRating'") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void addRateUsingBooleanValueForMyRating() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"fiveStar\", \"myRating\":\"true\"}"); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsSummary(RestErrorModel.NULL_FIVESTAR_RATING) + .containsErrorKey(RestErrorModel.NULL_FIVESTAR_RATING) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Add Like Using Integer Value For 'myRating'") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void addLikeUsingIntegerValueForMyRating() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"likes\", \"myRating\":\"2\"}"); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsSummary(RestErrorModel.NULL_LIKE_RATING) + .containsErrorKey(RestErrorModel.NULL_LIKE_RATING) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that user is not able to like his own comment") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void userCannotLikeHisOwnComment() throws Exception + { + UserModel user = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); + FolderModel folderModel = dataContent.usingUser(user).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(user).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + RestCommentModel comment = restClient.authenticateUser(user).withCoreAPI().usingResource(document).addComment("This is a comment"); + document.setNodeRef(comment.getId()); + + returnedRatingModel = restClient.authenticateUser(user).withCoreAPI().usingResource(document).likeDocument(); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) + .assertLastError() + .containsSummary(String.format(RestErrorModel.CANNOT_RATE)) + .containsErrorKey(RestErrorModel.CANNOT_RATE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER).stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that user is not able to rate his own comment") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void userCannotRateHisOwnComment() throws Exception + { + UserModel user = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); + FolderModel folderModel = dataContent.usingUser(user).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(user).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + RestCommentModel comment = restClient.authenticateUser(user).withCoreAPI().usingResource(document).addComment("This is a comment"); + document.setNodeRef(comment.getId()); + + returnedRatingModel = restClient.authenticateUser(user).withCoreAPI().usingResource(document).rateStarsToDocument(5); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) + .assertLastError() + .containsSummary(String.format(RestErrorModel.CANNOT_RATE)) + .containsErrorKey(RestErrorModel.CANNOT_RATE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that Collaborator is NOT able to add a negative rating to a file") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void collaboratorIsNotAbleToAddANegativeRatingToAFile() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI() + .usingResource(document) + .rateStarsToDocument(-5); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsSummary(RestErrorModel.RATING_OUT_OF_BOUNDS) + .containsErrorKey(RestErrorModel.RATING_OUT_OF_BOUNDS) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that Collaborator is NOT able to add a high rating to a file") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void collaboratorIsNotAbleToAddAHighRatingToAFile() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI() + .usingResource(document) + .rateStarsToDocument(10); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsSummary(RestErrorModel.RATING_OUT_OF_BOUNDS) + .containsErrorKey(RestErrorModel.RATING_OUT_OF_BOUNDS) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + // @Bug(id = "MNT-17375", description = "Won't Fix, the error message is not ideal and a little cryptic but it does provide the reason i.e. ratingSchemeId is null.") + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Do not provide field - 'id'") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void notProvideIdLikeFile() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"myRating\":\"true\"}"); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsSummary(String.format(RestErrorModel.INVALID_RATING, "null")) + .containsErrorKey(String.format(RestErrorModel.INVALID_RATING, "null")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Do not provide field - 'myRating'") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void notProvideMyRatingRateFile() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"likes\"}"); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsSummary(RestErrorModel.NULL_LIKE_RATING) + .containsErrorKey(RestErrorModel.NULL_LIKE_RATING) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } +} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingCoreTests.java b/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingCoreTests.java deleted file mode 100644 index 55216d92d..000000000 --- a/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingCoreTests.java +++ /dev/null @@ -1,149 +0,0 @@ -package org.alfresco.rest.ratings; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestRatingModel; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.exception.DataPreparationException; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class DeleteRatingCoreTests extends RestTest -{ - - private SiteModel siteModel; - private UserModel adminUser; - - private ListUserWithRoles usersWithRoles; - private RestRatingModel returnedRatingModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws DataPreparationException - { - adminUser = dataUser.getAdminUser(); - siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); - - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Verify that if ratingId provided is unknown status code returned is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) - public void deleteInvalidRating() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).deleteInvalidRating("random_rating"); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsSummary(String.format(RestErrorModel.INVALID_RATING, "random_rating")) - .containsErrorKey(String.format(RestErrorModel.INVALID_RATING, "random_rating")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Verify that if nodeId does not exist status code returned is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) - public void deleteRatingUsingInvalidDocument() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - document.setNodeRef("random_value"); - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).deleteLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "random_value")); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Delete rating stars for a document that was not rated") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) - @Bug(id = "MNT-17181") - public void deleteStarsForANotRatedDocument() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).deleteFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Delete like rating for a document that was not liked") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) - @Bug(id = "MNT-17181") - public void deleteLikeForANotLikedDocument() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).deleteLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Delete like for a file then add it again") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) - public void likeDocumentAfterLikeRatingIsDeleted() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); - restClient.withCoreAPI().usingResource(document).deleteLikeRating(); - returnedRatingModel = restClient.withCoreAPI().usingResource(document).likeDocument(); - - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Delete stars for a file then add them again") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) - public void addStarsToDocumentAfterRatingIsDeleted() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(document).rateStarsToDocument(5); - restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - returnedRatingModel = restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Verify site manager is not able to remove rating added by another user") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) - @Bug(id = "ACE-5459") - public void deleteDocumentRatingUsingManager() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(document).rateStarsToDocument(5); - restClient.withCoreAPI().usingResource(document).likeDocument(); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(document).deleteFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - restClient.withCoreAPI().usingResource(document).deleteLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - - restClient.withCoreAPI().usingResource(document).getRatings() - .assertNodeIsLiked() - .assertNodeHasFiveStarRating(); - } -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingFullTests.java b/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingFullTests.java deleted file mode 100644 index b3c68262f..000000000 --- a/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingFullTests.java +++ /dev/null @@ -1,241 +0,0 @@ -package org.alfresco.rest.ratings; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestRatingModel; -import org.alfresco.rest.model.RestRatingModelsCollection; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser; -import org.alfresco.utility.exception.DataPreparationException; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -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; - -/** - * Created by Claudia Agache on 1/25/2017. - */ -public class DeleteRatingFullTests extends RestTest -{ - private SiteModel siteModel; - private UserModel adminUser; - private DataUser.ListUserWithRoles usersWithRoles; - private RestRatingModelsCollection returnedRatingModelCollection; - private RestRatingModel returnedRatingModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws DataPreparationException - { - adminUser = dataUser.getAdminUser(); - siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); - - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Verify site contributor is not able to remove rating added by another user") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) - @Bug(id = "ACE-5459") - public void contributorIsNotAbleToDeleteRatingsOfAnotherUser() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(document).rateStarsToDocument(5); - restClient.withCoreAPI().usingResource(document).likeDocument(); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingResource(document).deleteFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - restClient.withCoreAPI().usingResource(document).deleteLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - - restClient.withCoreAPI().usingResource(document).getRatings() - .assertNodeIsLiked() - .assertNodeHasFiveStarRating(); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Verify site collaborator is not able to remove rating added by another user") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) - @Bug(id = "ACE-5459") - public void collaboratorIsNotAbleToDeleteRatingsOfAnotherUser() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(document).rateStarsToDocument(5); - restClient.withCoreAPI().usingResource(document).likeDocument(); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(document).deleteFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - restClient.withCoreAPI().usingResource(document).deleteLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - - restClient.withCoreAPI().usingResource(document).getRatings() - .assertNodeIsLiked() - .assertNodeHasFiveStarRating(); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Verify site consumer is not able to remove rating added by another user") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) - @Bug(id = "ACE-5459") - public void consumerIsNotAbleToDeleteRatingsOfAnotherUser() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(document).rateStarsToDocument(5); - restClient.withCoreAPI().usingResource(document).likeDocument(); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingResource(document).deleteFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - restClient.withCoreAPI().usingResource(document).deleteLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - - restClient.withCoreAPI().usingResource(document).getRatings() - .assertNodeIsLiked() - .assertNodeHasFiveStarRating(); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Delete rating stars twice") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) - @Bug(id = "MNT-17181") - public void deleteStarsTwice() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(document).rateStarsToDocument(5); - - restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - returnedRatingModelCollection = restClient.withCoreAPI().usingResource(document).getRatings(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedRatingModelCollection.assertNodeHasNoFiveStarRating(); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).deleteFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Delete like rating twice") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) - @Bug(id = "MNT-17181") - public void deleteLikeTwice() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingResource(document).likeDocument(); - - restClient.withCoreAPI().usingResource(document).deleteLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - returnedRatingModelCollection = restClient.withCoreAPI().usingResource(document).getRatings(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedRatingModelCollection.assertNodeIsNotLiked(); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).deleteLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Delete like for a folder then add it again") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) - public void likeFolderAfterLikeRatingIsDeleted() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folderModel).likeDocument(); - restClient.withCoreAPI().usingResource(folderModel).deleteLikeRating(); - returnedRatingModel = restClient.withCoreAPI().usingResource(folderModel).likeDocument(); - - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Delete stars for a folder then add them again") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) - public void addStarsToFolderAfterRatingIsDeleted() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(folderModel).rateStarsToDocument(5); - restClient.withCoreAPI().usingResource(folderModel).deleteFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - returnedRatingModel = restClient.withCoreAPI().usingResource(folderModel).rateStarsToDocument(5); - - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Delete like for a site then add it again") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) - public void likeSiteAfterLikeRatingIsDeleted() throws Exception - { - FolderModel folderModel = new FolderModel(); - folderModel.setNodeRef(siteModel.getGuid()); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folderModel).likeDocument(); - restClient.withCoreAPI().usingResource(folderModel).deleteLikeRating(); - returnedRatingModel = restClient.withCoreAPI().usingResource(folderModel).likeDocument(); - - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Delete stars for a site then add them again") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) - public void addStarsToSiteAfterRatingIsDeleted() throws Exception - { - FolderModel folderModel = new FolderModel(); - folderModel.setNodeRef(siteModel.getGuid()); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(folderModel).rateStarsToDocument(5); - restClient.withCoreAPI().usingResource(folderModel).deleteFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - returnedRatingModel = restClient.withCoreAPI().usingResource(folderModel).rateStarsToDocument(5); - - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Verify user with Manager role is able to remove one star rating of a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) - public void removeOneStarRating() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingResource(document).rateStarsToDocument(1); - - restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - returnedRatingModelCollection = restClient.withCoreAPI().usingResource(document).getRatings(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedRatingModelCollection.assertNodeIsNotLiked().assertNodeHasNoFiveStarRating().and().entriesListIsNotEmpty().and().paginationExist(); - } - -} diff --git a/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java deleted file mode 100644 index b6361d095..000000000 --- a/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingSanityTests.java +++ /dev/null @@ -1,215 +0,0 @@ -package org.alfresco.rest.ratings; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestRatingModelsCollection; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.exception.DataPreparationException; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class DeleteRatingSanityTests extends RestTest -{ - private SiteModel siteModel; - private UserModel adminUser; - private ListUserWithRoles usersWithRoles; - private RestRatingModelsCollection returnedRatingModelCollection; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws DataPreparationException - { - adminUser = dataUser.getAdminUser(); - siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); - - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - } - - - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role is able to remove its own rating of a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) - public void managerIsAbleToDeleteItsOwnRatings() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingResource(document).likeDocument(); - restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - - restClient.withCoreAPI().usingResource(document).deleteLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - returnedRatingModelCollection = restClient.withCoreAPI().usingResource(document).getRatings(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedRatingModelCollection.assertNodeIsNotLiked().assertNodeHasNoFiveStarRating().and().entriesListIsNotEmpty().and().paginationExist(); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Collaborator role is able to remove its own rating of a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) - public void collaboratorIsAbleToDeleteItsOwnRatings() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - - restClient.withCoreAPI().usingResource(document).likeDocument(); - restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - - restClient.withCoreAPI().usingResource(document).deleteLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - returnedRatingModelCollection = restClient.withCoreAPI().usingResource(document).getRatings(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedRatingModelCollection.assertNodeIsNotLiked().assertNodeHasNoFiveStarRating().and().entriesListIsNotEmpty().and().paginationExist(); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Contributor role is able to remove its own rating of a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) - public void contributorIsAbleToDeleteItsOwnRatings() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - - restClient.withCoreAPI().usingResource(document).likeDocument(); - restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - - restClient.withCoreAPI().usingResource(document).deleteLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - returnedRatingModelCollection = restClient.withCoreAPI().usingResource(document).getRatings(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedRatingModelCollection.assertNodeIsNotLiked().assertNodeHasNoFiveStarRating().and().entriesListIsNotEmpty().and().paginationExist(); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role is able to remove its own rating of a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) - public void consumerIsAbleToDeleteItsOwnRatings() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - - restClient.withCoreAPI().usingResource(document).likeDocument(); - restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - - restClient.withCoreAPI().usingResource(document).deleteLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - returnedRatingModelCollection = restClient.withCoreAPI().usingResource(document).getRatings(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedRatingModelCollection.assertNodeIsNotLiked().assertNodeHasNoFiveStarRating().and().entriesListIsNotEmpty().and().paginationExist(); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify admin user is able to remove its own rating of a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) - public void adminIsAbleToDeleteItsOwnRatings() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - document = dataContent.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).usingResource(folderModel) - .createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(adminUser); - - restClient.withCoreAPI().usingResource(document).likeDocument(); - restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - - restClient.withCoreAPI().usingResource(document).deleteLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - returnedRatingModelCollection = restClient.withCoreAPI().usingResource(document).getRatings(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedRatingModelCollection.assertNodeIsNotLiked().assertNodeHasNoFiveStarRating().and().entriesListIsNotEmpty().and().paginationExist(); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to remove its own rating of a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) - @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void unauthenticatedUserIsNotAbleToDeleteRatings() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - document = dataContent.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).usingResource(folderModel) - .createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(adminUser); - - restClient.withCoreAPI().usingResource(document).likeDocument(); - restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - - restClient.authenticateUser(new UserModel("random user", "random password")); - - restClient.withCoreAPI().usingResource(document).deleteLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - - restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify one user is not able to remove rating added by another user") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) - @Bug(id = "ACE-5459") - public void oneUserIsNotAbleToDeleteRatingsOfAnotherUser() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - UserModel userA = dataUser.createRandomTestUser(); - UserModel userB = dataUser.createRandomTestUser(); - - restClient.authenticateUser(userA); - - restClient.withCoreAPI().usingResource(document).likeDocument(); - restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - - restClient.authenticateUser(userB); - - restClient.withCoreAPI().usingResource(document).deleteLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - - restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - restClient.withCoreAPI().usingResource(document).getRatings() - .assertNodeIsLiked() - .assertNodeHasFiveStarRating(); - } -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingTests.java b/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingTests.java new file mode 100644 index 000000000..1edea1c5d --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingTests.java @@ -0,0 +1,525 @@ +package org.alfresco.rest.ratings; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestRatingModel; +import org.alfresco.rest.model.RestRatingModelsCollection; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.exception.DataPreparationException; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class DeleteRatingTests extends RestTest +{ + private SiteModel siteModel; + private UserModel adminUser; + private ListUserWithRoles usersWithRoles; + private RestRatingModelsCollection returnedRatingModelCollection; + private RestRatingModel returnedRatingModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws DataPreparationException + { + adminUser = dataUser.getAdminUser(); + siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); + + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.SANITY, description = "Verify user with Manager role is able to remove its own rating of a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) + public void managerIsAbleToDeleteItsOwnRatings() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + restClient.withCoreAPI().usingResource(document).likeDocument(); + restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); + + restClient.withCoreAPI().usingResource(document).deleteLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + returnedRatingModelCollection = restClient.withCoreAPI().usingResource(document).getRatings(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedRatingModelCollection.assertNodeIsNotLiked().assertNodeHasNoFiveStarRating().and().entriesListIsNotEmpty().and().paginationExist(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Verify user with Collaborator role is able to remove its own rating of a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void collaboratorIsAbleToDeleteItsOwnRatings() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + + restClient.withCoreAPI().usingResource(document).likeDocument(); + restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); + + restClient.withCoreAPI().usingResource(document).deleteLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + returnedRatingModelCollection = restClient.withCoreAPI().usingResource(document).getRatings(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedRatingModelCollection.assertNodeIsNotLiked().assertNodeHasNoFiveStarRating().and().entriesListIsNotEmpty().and().paginationExist(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Verify user with Contributor role is able to remove its own rating of a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void contributorIsAbleToDeleteItsOwnRatings() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + + restClient.withCoreAPI().usingResource(document).likeDocument(); + restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); + + restClient.withCoreAPI().usingResource(document).deleteLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + returnedRatingModelCollection = restClient.withCoreAPI().usingResource(document).getRatings(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedRatingModelCollection.assertNodeIsNotLiked().assertNodeHasNoFiveStarRating().and().entriesListIsNotEmpty().and().paginationExist(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Verify user with Consumer role is able to remove its own rating of a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void consumerIsAbleToDeleteItsOwnRatings() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + + restClient.withCoreAPI().usingResource(document).likeDocument(); + restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); + + restClient.withCoreAPI().usingResource(document).deleteLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + returnedRatingModelCollection = restClient.withCoreAPI().usingResource(document).getRatings(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedRatingModelCollection.assertNodeIsNotLiked().assertNodeHasNoFiveStarRating().and().entriesListIsNotEmpty().and().paginationExist(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Verify admin user is able to remove its own rating of a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void adminIsAbleToDeleteItsOwnRatings() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + document = dataContent.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).usingResource(folderModel) + .createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(adminUser); + + restClient.withCoreAPI().usingResource(document).likeDocument(); + restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); + + restClient.withCoreAPI().usingResource(document).deleteLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + returnedRatingModelCollection = restClient.withCoreAPI().usingResource(document).getRatings(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedRatingModelCollection.assertNodeIsNotLiked().assertNodeHasNoFiveStarRating().and().entriesListIsNotEmpty().and().paginationExist(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to remove its own rating of a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) +// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") + public void unauthenticatedUserIsNotAbleToDeleteRatings() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + document = dataContent.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).usingResource(folderModel) + .createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(adminUser); + + restClient.withCoreAPI().usingResource(document).likeDocument(); + restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); + + restClient.authenticateUser(new UserModel("random user", "random password")); + + restClient.withCoreAPI().usingResource(document).deleteLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + + restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Verify one user is not able to remove rating added by another user") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + @Bug(id = "ACE-5459") + public void oneUserIsNotAbleToDeleteRatingsOfAnotherUser() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + UserModel userA = dataUser.createRandomTestUser(); + UserModel userB = dataUser.createRandomTestUser(); + + restClient.authenticateUser(userA); + + restClient.withCoreAPI().usingResource(document).likeDocument(); + restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); + + restClient.authenticateUser(userB); + + restClient.withCoreAPI().usingResource(document).deleteLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + + restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + restClient.withCoreAPI().usingResource(document).getRatings() + .assertNodeIsLiked() + .assertNodeHasFiveStarRating(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Verify that if ratingId provided is unknown status code returned is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void deleteInvalidRating() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).deleteInvalidRating("random_rating"); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsSummary(String.format(RestErrorModel.INVALID_RATING, "random_rating")) + .containsErrorKey(String.format(RestErrorModel.INVALID_RATING, "random_rating")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Verify that if nodeId does not exist status code returned is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void deleteRatingUsingInvalidDocument() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + document.setNodeRef("random_value"); + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).deleteLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "random_value")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Delete rating stars for a document that was not rated") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + @Bug(id = "MNT-17181") + public void deleteStarsForANotRatedDocument() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).deleteFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Delete like rating for a document that was not liked") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + @Bug(id = "MNT-17181") + public void deleteLikeForANotLikedDocument() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).deleteLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Delete like for a file then add it again") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void likeDocumentAfterLikeRatingIsDeleted() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); + restClient.withCoreAPI().usingResource(document).deleteLikeRating(); + returnedRatingModel = restClient.withCoreAPI().usingResource(document).likeDocument(); + + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Delete stars for a file then add them again") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void addStarsToDocumentAfterRatingIsDeleted() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(document).rateStarsToDocument(5); + restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + returnedRatingModel = restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); + + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Verify site manager is not able to remove rating added by another user") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + @Bug(id = "ACE-5459") + public void deleteDocumentRatingUsingManager() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(document).rateStarsToDocument(5); + restClient.withCoreAPI().usingResource(document).likeDocument(); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(document).deleteFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + restClient.withCoreAPI().usingResource(document).deleteLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + + restClient.withCoreAPI().usingResource(document).getRatings() + .assertNodeIsLiked() + .assertNodeHasFiveStarRating(); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Verify site contributor is not able to remove rating added by another user") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + @Bug(id = "ACE-5459") + public void contributorIsNotAbleToDeleteRatingsOfAnotherUser() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(document).rateStarsToDocument(5); + restClient.withCoreAPI().usingResource(document).likeDocument(); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingResource(document).deleteFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + restClient.withCoreAPI().usingResource(document).deleteLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + + restClient.withCoreAPI().usingResource(document).getRatings() + .assertNodeIsLiked() + .assertNodeHasFiveStarRating(); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Verify site collaborator is not able to remove rating added by another user") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + @Bug(id = "ACE-5459") + public void collaboratorIsNotAbleToDeleteRatingsOfAnotherUser() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(document).rateStarsToDocument(5); + restClient.withCoreAPI().usingResource(document).likeDocument(); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(document).deleteFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + restClient.withCoreAPI().usingResource(document).deleteLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + + restClient.withCoreAPI().usingResource(document).getRatings() + .assertNodeIsLiked() + .assertNodeHasFiveStarRating(); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Verify site consumer is not able to remove rating added by another user") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + @Bug(id = "ACE-5459") + public void consumerIsNotAbleToDeleteRatingsOfAnotherUser() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(document).rateStarsToDocument(5); + restClient.withCoreAPI().usingResource(document).likeDocument(); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingResource(document).deleteFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + restClient.withCoreAPI().usingResource(document).deleteLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + + restClient.withCoreAPI().usingResource(document).getRatings() + .assertNodeIsLiked() + .assertNodeHasFiveStarRating(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Delete rating stars twice") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + @Bug(id = "MNT-17181") + public void deleteStarsTwice() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(document).rateStarsToDocument(5); + + restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + returnedRatingModelCollection = restClient.withCoreAPI().usingResource(document).getRatings(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedRatingModelCollection.assertNodeHasNoFiveStarRating(); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).deleteFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Delete like rating twice") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + @Bug(id = "MNT-17181") + public void deleteLikeTwice() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + restClient.withCoreAPI().usingResource(document).likeDocument(); + + restClient.withCoreAPI().usingResource(document).deleteLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + returnedRatingModelCollection = restClient.withCoreAPI().usingResource(document).getRatings(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedRatingModelCollection.assertNodeIsNotLiked(); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).deleteLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Delete like for a folder then add it again") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void likeFolderAfterLikeRatingIsDeleted() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folderModel).likeDocument(); + restClient.withCoreAPI().usingResource(folderModel).deleteLikeRating(); + returnedRatingModel = restClient.withCoreAPI().usingResource(folderModel).likeDocument(); + + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Delete stars for a folder then add them again") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void addStarsToFolderAfterRatingIsDeleted() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(folderModel).rateStarsToDocument(5); + restClient.withCoreAPI().usingResource(folderModel).deleteFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + returnedRatingModel = restClient.withCoreAPI().usingResource(folderModel).rateStarsToDocument(5); + + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Delete like for a site then add it again") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void likeSiteAfterLikeRatingIsDeleted() throws Exception + { + FolderModel folderModel = new FolderModel(); + folderModel.setNodeRef(siteModel.getGuid()); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folderModel).likeDocument(); + restClient.withCoreAPI().usingResource(folderModel).deleteLikeRating(); + returnedRatingModel = restClient.withCoreAPI().usingResource(folderModel).likeDocument(); + + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Delete stars for a site then add them again") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void addStarsToSiteAfterRatingIsDeleted() throws Exception + { + FolderModel folderModel = new FolderModel(); + folderModel.setNodeRef(siteModel.getGuid()); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(folderModel).rateStarsToDocument(5); + restClient.withCoreAPI().usingResource(folderModel).deleteFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + returnedRatingModel = restClient.withCoreAPI().usingResource(folderModel).rateStarsToDocument(5); + + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Verify user with Manager role is able to remove one star rating of a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void removeOneStarRating() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + restClient.withCoreAPI().usingResource(document).rateStarsToDocument(1); + + restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + returnedRatingModelCollection = restClient.withCoreAPI().usingResource(document).getRatings(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedRatingModelCollection.assertNodeIsNotLiked().assertNodeHasNoFiveStarRating().and().entriesListIsNotEmpty().and().paginationExist(); + } +} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/ratings/GetRatingCoreTests.java b/e2e-test/java/org/alfresco/rest/ratings/GetRatingCoreTests.java deleted file mode 100644 index 5b17497de..000000000 --- a/e2e-test/java/org/alfresco/rest/ratings/GetRatingCoreTests.java +++ /dev/null @@ -1,150 +0,0 @@ -package org.alfresco.rest.ratings; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.core.RestRequest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestRatingModel; -import org.alfresco.utility.exception.DataPreparationException; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.apache.commons.lang.RandomStringUtils; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -public class GetRatingCoreTests extends RestTest -{ - private SiteModel siteModel; - private UserModel adminUserModel, userModel; - private FileModel document; - private RestRatingModel returnedRatingModel; - private FolderModel firstFolderModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws DataPreparationException - { - adminUserModel = dataUser.getAdminUser(); - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingAdmin().createPublicRandomSite(); - } - - @BeforeMethod(alwaysRun = true) - public void setUp() throws DataPreparationException, Exception - { - document = dataContent.usingSite(siteModel).usingAdmin().createContent(DocumentType.TEXT_PLAIN); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Check that using invalid ratingId for get rating call returns status code 400.") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) - public void checkInvalidRatingIdStatusCode() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI(); - RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "nodes/{nodeId}/ratings/{ratingId}", document.getNodeRef(), "invalid ratingId"); - restClient.processModel(RestRatingModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.INVALID_RATING, "invalid ratingId")); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Check that using invalid node ID for get rating call returns status code 404.") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) - public void getRatingUsingInvalidNodeId() throws Exception - { - document.setNodeRef(RandomStringUtils.randomAlphanumeric(20)); - returnedRatingModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getFiveStarRating(); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, document.getNodeRef())); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Get rating of a file that has only likes.") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) - public void getRatingOfFileThatHasOnlyLikes() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).likeDocument(); - - returnedRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); - returnedRatingModel.getAggregate().assertThat().field("numberOfRatings").is("1"); - - returnedRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedRatingModel.getAggregate().assertThat().field("numberOfRatings").is("0"); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Get rating of a file that has only stars.") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) - public void getRatingOfFileThatHasOnlyStars() throws Exception - { - restClient.authenticateUser(userModel).withCoreAPI().usingResource(document).rateStarsToDocument(5); - - returnedRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); - returnedRatingModel.getAggregate().assertThat().field("numberOfRatings").is("1"); - - returnedRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedRatingModel.getAggregate().assertThat().field("numberOfRatings").is("0"); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Get rating of a file that has likes and stars.") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) - public void getRatingOfFileThatHasLikesAndStars() throws Exception - { - restClient.authenticateUser(userModel).withCoreAPI().usingResource(document).likeDocument(); - restClient.authenticateUser(userModel).withCoreAPI().usingResource(document).rateStarsToDocument(5); - - returnedRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); - returnedRatingModel.getAggregate().assertThat().field("numberOfRatings").is("1"); - - returnedRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); - returnedRatingModel.getAggregate().assertThat().field("numberOfRatings").is("1"); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Get rating of a folder that has only likes.") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) - public void getRatingOfFolderThatHasOnlyLikes() throws Exception - { - firstFolderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(firstFolderModel).likeDocument(); - - returnedRatingModel = restClient.withCoreAPI().usingResource(firstFolderModel).getLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); - returnedRatingModel.getAggregate().assertThat().field("numberOfRatings").is("1"); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Get rating of a file that has no ratings.") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) - public void getRatingOfFileThatHasNoRatings() throws Exception - { - returnedRatingModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedRatingModel.getAggregate().assertThat().field("numberOfRatings").is("0"); - - returnedRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedRatingModel.getAggregate().assertThat().field("numberOfRatings").is("0"); - } - -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/ratings/GetRatingFullTests.java b/e2e-test/java/org/alfresco/rest/ratings/GetRatingFullTests.java deleted file mode 100644 index 3fdc99e28..000000000 --- a/e2e-test/java/org/alfresco/rest/ratings/GetRatingFullTests.java +++ /dev/null @@ -1,199 +0,0 @@ -package org.alfresco.rest.ratings; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestRatingModel; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.exception.DataPreparationException; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.apache.commons.lang.RandomStringUtils; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class GetRatingFullTests extends RestTest -{ - private SiteModel siteModel; - private UserModel adminUserModel, userModel; - private RestRatingModel returnedRatingModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws DataPreparationException - { - adminUserModel = dataUser.getAdminUser(); - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingAdmin().createPublicRandomSite(); - dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Check default error schema") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) - public void checkDefaultErrorSchema() throws Exception - { - FileModel document = dataContent.usingSite(siteModel).usingAdmin().createContent(DocumentType.TEXT_PLAIN); - String randomNodeRef = RandomStringUtils.randomAlphanumeric(10); - document.setNodeRef(randomNodeRef); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, randomNodeRef)) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Get rating of a folder that has only stars") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) - public void getRatingOfFolderThatHasOnlyStars() throws Exception - { - FolderModel folder = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); - restClient.authenticateUser(userModel).withCoreAPI().usingResource(folder).rateStarsToDocument(3); - returnedRatingModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(folder).getFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedRatingModel.assertThat().field("id").is("fiveStar") - .getAggregate().assertThat().field("numberOfRatings").is("1") - .assertThat().field("average").is("3.0"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Get rating of a folder that has both likes and stars") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) - public void getRatingOfFolderThatHasLikedAndStars() throws Exception - { - FolderModel folder = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); - restClient.authenticateUser(userModel).withCoreAPI().usingResource(folder).rateStarsToDocument(3); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(folder).likeDocument(); - - returnedRatingModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(folder).getFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedRatingModel.assertThat().field("id").is("fiveStar") - .getAggregate().assertThat().field("numberOfRatings").is("1") - .assertThat().field("average").is("3.0"); - - returnedRatingModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(folder).getLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedRatingModel.assertThat().field("id").is("likes") - .assertThat().field("myRating").is("true"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Get rating of a folder that has no ratings") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) - public void getRatingOfFolderThatHasNoRatings() throws Exception - { - FolderModel folder = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); - - returnedRatingModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(folder).getFiveStarRating(); - returnedRatingModel.getAggregate().assertThat().field("numberOfRatings").is("0"); - - returnedRatingModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(folder).getLikeRating(); - returnedRatingModel.getAggregate().assertThat().field("numberOfRatings").is("0"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Get rating of a folder after rating was deleted") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) - public void getDeletedRatingOfAFolder() throws Exception - { - FolderModel folder = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); - restClient.authenticateUser(userModel).withCoreAPI().usingResource(folder).rateStarsToDocument(3); - restClient.authenticateUser(userModel).withCoreAPI().usingResource(folder).deleteFiveStarRating(); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(folder).likeDocument(); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(folder).deleteLikeRating(); - - returnedRatingModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(folder).getFiveStarRating(); - returnedRatingModel.assertThat().field("id").is("fiveStar").getAggregate().assertThat().field("numberOfRatings").is("0") - .assertThat().field("average").isNull(); - - returnedRatingModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(folder).getLikeRating(); - returnedRatingModel.assertThat().field("id").is("likes").assertThat().field("myRating").isNull() - .getAggregate().assertThat().field("numberOfRatings").is("0"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Get rating of a file after rating was deleted") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) - public void getDeletedRatingOfAFile() throws Exception - { - FileModel file = dataContent.usingUser(adminUserModel).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(userModel).withCoreAPI().usingResource(file).rateStarsToDocument(3); - restClient.authenticateUser(userModel).withCoreAPI().usingResource(file).deleteFiveStarRating(); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).likeDocument(); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).deleteLikeRating(); - - returnedRatingModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getFiveStarRating(); - returnedRatingModel.assertThat().field("id").is("fiveStar").getAggregate().assertThat().field("numberOfRatings").is("0") - .assertThat().field("average").isNull(); - - returnedRatingModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getLikeRating(); - returnedRatingModel.assertThat().field("id").is("likes").assertThat().field("myRating").isNull() - .getAggregate().assertThat().field("numberOfRatings").is("0"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Get rating of another user as admin") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) - public void getRatingOfAnotherUserAsAdmin() throws Exception - { - FileModel file = dataContent.usingUser(adminUserModel).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(userModel).withCoreAPI().usingResource(file).rateStarsToDocument(3); - restClient.authenticateUser(userModel).withCoreAPI().usingResource(file).likeDocument(); - - returnedRatingModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getFiveStarRating(); - returnedRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").isNull() - .getAggregate().assertThat().field("numberOfRatings").is("1").assertThat().field("average").is("3.0"); - - returnedRatingModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getLikeRating(); - returnedRatingModel.assertThat().field("id").is("likes").assertThat().field("myRating").isNull() - .getAggregate().assertThat().field("numberOfRatings").is("1"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Get rating of admin with another user") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) - public void getRatingOfAdminWithAnotherUser() throws Exception - { - FileModel file = dataContent.usingUser(userModel).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).rateStarsToDocument(3); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).likeDocument(); - - returnedRatingModel = restClient.authenticateUser(userModel).withCoreAPI().usingResource(file).getFiveStarRating(); - returnedRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").isNull() - .getAggregate().assertThat().field("numberOfRatings").is("1").assertThat().field("average").is("3.0"); - - returnedRatingModel = restClient.authenticateUser(userModel).withCoreAPI().usingResource(file).getLikeRating(); - returnedRatingModel.assertThat().field("id").is("likes").assertThat().field("myRating").isNull() - .getAggregate().assertThat().field("numberOfRatings").is("1"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Get five star rating") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) - public void getFiveStarRating() throws Exception - { - FileModel file = dataContent.usingUser(userModel).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).rateStarsToDocument(5); - - returnedRatingModel = restClient.authenticateUser(userModel).withCoreAPI().usingResource(file).getFiveStarRating(); - returnedRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").isNull() - .getAggregate().assertThat().field("numberOfRatings").is("1").assertThat().field("average").is("5.0"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Get one star rating") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) - public void getOneStarRating() throws Exception - { - FileModel file = dataContent.usingUser(userModel).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).rateStarsToDocument(1); - - returnedRatingModel = restClient.authenticateUser(userModel).withCoreAPI().usingResource(file).getFiveStarRating(); - returnedRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").isNull() - .getAggregate().assertThat().field("numberOfRatings").is("1").assertThat().field("average").is("1.0"); - } -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java deleted file mode 100644 index dc9d23178..000000000 --- a/e2e-test/java/org/alfresco/rest/ratings/GetRatingSanityTests.java +++ /dev/null @@ -1,172 +0,0 @@ -package org.alfresco.rest.ratings; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestRatingModel; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.exception.DataPreparationException; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class GetRatingSanityTests extends RestTest -{ - private SiteModel siteModel; - private UserModel adminUser; - private ListUserWithRoles usersWithRoles; - private RestRatingModel restRatingModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws DataPreparationException - { - adminUser = dataUser.getAdminUser(); - siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); - - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role is able to retrieve rating of a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) - public void managerIsAbleToRetrieveRating() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - - restClient.withCoreAPI().usingResource(document).likeDocument(); - restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - - restRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); - - restRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").is("5"); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Collaborator role is able to retrieve rating of a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) - public void collaboratorIsAbleToRetrieveRating() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - - restClient.withCoreAPI().usingResource(document).likeDocument(); - restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - - restRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); - - restRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").is("5"); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Contributor role is able to retrieve rating of a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) - public void contributorIsAbleToRetrieveRating() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - - restClient.withCoreAPI().usingResource(document).likeDocument(); - restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - - restRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); - - restRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").is("5"); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role is able to retrieve rating of a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) - public void consumerIsAbleToRetrieveRating() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - - restClient.withCoreAPI().usingResource(document).likeDocument(); - restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - - restRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); - - restRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").is("5"); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify admin user is able to retrieve rating of a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) - public void adminIsAbleToRetrieveRating() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - document = dataContent.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingResource(folderModel) - .createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(adminUser); - restClient.withCoreAPI().usingResource(document).likeDocument(); - restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - - restRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); - - restRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").is("5"); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to retrieve rating of a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) - @Bug(id = "MNT-16904", description = "It fails only on environment with tenants") - public void unauthenticatedUserIsNotAbleToRetrieveRating() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(adminUser); - restClient.withCoreAPI().usingResource(document).likeDocument(); - restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - - restClient.authenticateUser(new UserModel("random user", "random password")); - - restClient.withCoreAPI().usingResource(document).getLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - - restClient.withCoreAPI().usingResource(document).getFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/ratings/GetRatingTests.java b/e2e-test/java/org/alfresco/rest/ratings/GetRatingTests.java new file mode 100644 index 000000000..3e7d5c9e4 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/ratings/GetRatingTests.java @@ -0,0 +1,438 @@ +package org.alfresco.rest.ratings; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestRatingModel; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.exception.DataPreparationException; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.apache.commons.lang.RandomStringUtils; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +public class GetRatingTests extends RestTest +{ + private SiteModel siteModel; + private UserModel adminUser, userModel, managerUser; + private FileModel document; + private ListUserWithRoles usersWithRoles; + private RestRatingModel restRatingModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws DataPreparationException + { + adminUser = dataUser.getAdminUser(); + userModel = dataUser.createRandomTestUser(); + managerUser = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); + + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + + dataUser.addUserToSite(managerUser, siteModel, UserRole.SiteManager); + } + + @BeforeMethod(alwaysRun = true) + public void setUp() throws Exception + { + document = dataContent.usingSite(siteModel).usingAdmin().createContent(DocumentType.TEXT_PLAIN); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.SANITY, description = "Verify user with Manager role is able to retrieve rating of a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) + public void managerIsAbleToRetrieveRating() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + + restClient.withCoreAPI().usingResource(document).likeDocument(); + restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); + + restRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); + + restRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").is("5"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Verify user with Collaborator role is able to retrieve rating of a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void collaboratorIsAbleToRetrieveRating() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + + restClient.withCoreAPI().usingResource(document).likeDocument(); + restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); + + restRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); + + restRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").is("5"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Verify user with Contributor role is able to retrieve rating of a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void contributorIsAbleToRetrieveRating() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + + restClient.withCoreAPI().usingResource(document).likeDocument(); + restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); + + restRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); + + restRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").is("5"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Verify user with Consumer role is able to retrieve rating of a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void consumerIsAbleToRetrieveRating() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + + restClient.withCoreAPI().usingResource(document).likeDocument(); + restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); + + restRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); + + restRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").is("5"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Verify admin user is able to retrieve rating of a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void adminIsAbleToRetrieveRating() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingResource(folderModel) + .createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(adminUser); + restClient.withCoreAPI().usingResource(document).likeDocument(); + restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); + + restRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); + + restRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").is("5"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to retrieve rating of a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) +// @Bug(id = "MNT-16904", description = "It fails only on environment with tenants") + public void unauthenticatedUserIsNotAbleToRetrieveRating() throws Exception + { + restClient.authenticateUser(adminUser); + restClient.withCoreAPI().usingResource(document).likeDocument(); + restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); + + restClient.authenticateUser(new UserModel("random user", "random password")); + + restClient.withCoreAPI().usingResource(document).getLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + + restClient.withCoreAPI().usingResource(document).getFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Check that using invalid ratingId for get rating call returns status code 400.") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void checkInvalidRatingIdStatusCode() throws Exception + { + restClient.authenticateUser(adminUser).withCoreAPI(); + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "nodes/{nodeId}/ratings/{ratingId}", document.getNodeRef(), "invalid ratingId"); + restClient.processModel(RestRatingModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.INVALID_RATING, "invalid ratingId")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Check that using invalid node ID for get rating call returns status code 404.") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void getRatingUsingInvalidNodeId() throws Exception + { + document.setNodeRef(RandomStringUtils.randomAlphanumeric(20)); + restRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).getFiveStarRating(); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, document.getNodeRef())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Get rating of a file that has only likes.") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void getRatingOfFileThatHasOnlyLikes() throws Exception + { + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); + + restRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); + restRatingModel.getAggregate().assertThat().field("numberOfRatings").is("1"); + + restRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restRatingModel.getAggregate().assertThat().field("numberOfRatings").is("0"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Get rating of a file that has only stars.") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void getRatingOfFileThatHasOnlyStars() throws Exception + { + restClient.authenticateUser(userModel).withCoreAPI().usingResource(document).rateStarsToDocument(5); + + restRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); + restRatingModel.getAggregate().assertThat().field("numberOfRatings").is("1"); + + restRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restRatingModel.getAggregate().assertThat().field("numberOfRatings").is("0"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Get rating of a file that has likes and stars.") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void getRatingOfFileThatHasLikesAndStars() throws Exception + { + restClient.authenticateUser(userModel).withCoreAPI().usingResource(document).likeDocument(); + restClient.authenticateUser(userModel).withCoreAPI().usingResource(document).rateStarsToDocument(5); + + restRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); + restRatingModel.getAggregate().assertThat().field("numberOfRatings").is("1"); + + restRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); + restRatingModel.getAggregate().assertThat().field("numberOfRatings").is("1"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Get rating of a folder that has only likes.") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void getRatingOfFolderThatHasOnlyLikes() throws Exception + { + FolderModel firstFolderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(firstFolderModel).likeDocument(); + + restRatingModel = restClient.withCoreAPI().usingResource(firstFolderModel).getLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); + restRatingModel.getAggregate().assertThat().field("numberOfRatings").is("1"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Get rating of a file that has no ratings.") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void getRatingOfFileThatHasNoRatings() throws Exception + { + restRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).getLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restRatingModel.getAggregate().assertThat().field("numberOfRatings").is("0"); + + restRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restRatingModel.getAggregate().assertThat().field("numberOfRatings").is("0"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Check default error schema") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void checkDefaultErrorSchema() throws Exception + { + FileModel document = dataContent.usingSite(siteModel).usingAdmin().createContent(DocumentType.TEXT_PLAIN); + String randomNodeRef = RandomStringUtils.randomAlphanumeric(10); + document.setNodeRef(randomNodeRef); + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).getLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, randomNodeRef)) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Get rating of a folder that has only stars") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void getRatingOfFolderThatHasOnlyStars() throws Exception + { + FolderModel folder = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + restClient.authenticateUser(managerUser).withCoreAPI().usingResource(folder).rateStarsToDocument(3); + restRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folder).getFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restRatingModel.assertThat().field("id").is("fiveStar") + .getAggregate().assertThat().field("numberOfRatings").is("1") + .assertThat().field("average").is("3.0"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Get rating of a folder that has both likes and stars") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void getRatingOfFolderThatHasLikedAndStars() throws Exception + { + FolderModel folder = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + restClient.authenticateUser(managerUser).withCoreAPI().usingResource(folder).rateStarsToDocument(3); + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folder).likeDocument(); + + restRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folder).getFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restRatingModel.assertThat().field("id").is("fiveStar") + .getAggregate().assertThat().field("numberOfRatings").is("1") + .assertThat().field("average").is("3.0"); + + restRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folder).getLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restRatingModel.assertThat().field("id").is("likes") + .assertThat().field("myRating").is("true"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Get rating of a folder that has no ratings") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void getRatingOfFolderThatHasNoRatings() throws Exception + { + FolderModel folder = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + + restRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folder).getFiveStarRating(); + restRatingModel.getAggregate().assertThat().field("numberOfRatings").is("0"); + + restRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folder).getLikeRating(); + restRatingModel.getAggregate().assertThat().field("numberOfRatings").is("0"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Get rating of a folder after rating was deleted") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void getDeletedRatingOfAFolder() throws Exception + { + FolderModel folder = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + restClient.authenticateUser(managerUser).withCoreAPI().usingResource(folder).rateStarsToDocument(3); + restClient.authenticateUser(managerUser).withCoreAPI().usingResource(folder).deleteFiveStarRating(); + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folder).likeDocument(); + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folder).deleteLikeRating(); + + restRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folder).getFiveStarRating(); + restRatingModel.assertThat().field("id").is("fiveStar").getAggregate().assertThat().field("numberOfRatings").is("0") + .assertThat().field("average").isNull(); + + restRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folder).getLikeRating(); + restRatingModel.assertThat().field("id").is("likes").assertThat().field("myRating").isNull() + .getAggregate().assertThat().field("numberOfRatings").is("0"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Get rating of a file after rating was deleted") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void getDeletedRatingOfAFile() throws Exception + { + FileModel file = dataContent.usingUser(adminUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(managerUser).withCoreAPI().usingResource(file).rateStarsToDocument(3); + restClient.authenticateUser(managerUser).withCoreAPI().usingResource(file).deleteFiveStarRating(); + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(file).likeDocument(); + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(file).deleteLikeRating(); + + restRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(file).getFiveStarRating(); + restRatingModel.assertThat().field("id").is("fiveStar").getAggregate().assertThat().field("numberOfRatings").is("0") + .assertThat().field("average").isNull(); + + restRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(file).getLikeRating(); + restRatingModel.assertThat().field("id").is("likes").assertThat().field("myRating").isNull() + .getAggregate().assertThat().field("numberOfRatings").is("0"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Get rating of another user as admin") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void getRatingOfAnotherUserAsAdmin() throws Exception + { + FileModel file = dataContent.usingUser(adminUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(managerUser).withCoreAPI().usingResource(file).rateStarsToDocument(3); + restClient.authenticateUser(managerUser).withCoreAPI().usingResource(file).likeDocument(); + + restRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(file).getFiveStarRating(); + restRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").isNull() + .getAggregate().assertThat().field("numberOfRatings").is("1").assertThat().field("average").is("3.0"); + + restRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(file).getLikeRating(); + restRatingModel.assertThat().field("id").is("likes").assertThat().field("myRating").isNull() + .getAggregate().assertThat().field("numberOfRatings").is("1"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Get rating of admin with another user") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void getRatingOfAdminWithAnotherUser() throws Exception + { + FileModel file = dataContent.usingUser(managerUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(file).rateStarsToDocument(3); + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(file).likeDocument(); + + restRatingModel = restClient.authenticateUser(managerUser).withCoreAPI().usingResource(file).getFiveStarRating(); + restRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").isNull() + .getAggregate().assertThat().field("numberOfRatings").is("1").assertThat().field("average").is("3.0"); + + restRatingModel = restClient.authenticateUser(managerUser).withCoreAPI().usingResource(file).getLikeRating(); + restRatingModel.assertThat().field("id").is("likes").assertThat().field("myRating").isNull() + .getAggregate().assertThat().field("numberOfRatings").is("1"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Get five star rating") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void getFiveStarRating() throws Exception + { + FileModel file = dataContent.usingUser(managerUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(file).rateStarsToDocument(5); + + restRatingModel = restClient.authenticateUser(managerUser).withCoreAPI().usingResource(file).getFiveStarRating(); + restRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").isNull() + .getAggregate().assertThat().field("numberOfRatings").is("1").assertThat().field("average").is("5.0"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Get one star rating") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void getOneStarRating() throws Exception + { + FileModel file = dataContent.usingUser(managerUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(file).rateStarsToDocument(1); + + restRatingModel = restClient.authenticateUser(managerUser).withCoreAPI().usingResource(file).getFiveStarRating(); + restRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").isNull() + .getAggregate().assertThat().field("numberOfRatings").is("1").assertThat().field("average").is("1.0"); + } +} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/ratings/GetRatingsCoreTests.java b/e2e-test/java/org/alfresco/rest/ratings/GetRatingsCoreTests.java deleted file mode 100644 index 3051df8f4..000000000 --- a/e2e-test/java/org/alfresco/rest/ratings/GetRatingsCoreTests.java +++ /dev/null @@ -1,105 +0,0 @@ -package org.alfresco.rest.ratings; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestRatingModelsCollection; -import org.alfresco.utility.exception.DataPreparationException; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.apache.commons.lang.RandomStringUtils; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -public class GetRatingsCoreTests extends RestTest -{ - private SiteModel siteModel; - private UserModel adminUserModel, userModel; - private FileModel document; - private RestRatingModelsCollection ratingsModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws DataPreparationException - { - adminUserModel = dataUser.getAdminUser(); - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingAdmin().createPublicRandomSite(); - } - - @BeforeMethod(alwaysRun = true) - public void setUp() throws DataPreparationException, Exception - { - document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); - restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).rateStarsToDocument(5); - restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).likeDocument(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Check that rating for invalid maxItems status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) - public void checkInvalidMaxItemsStatusCode() throws Exception - { - - restClient.authenticateUser(adminUserModel).withParams("maxItems=0").withCoreAPI().usingResource(document).getRatings(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Only positive values supported for maxItems"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Check that rating for invalid skipCount status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) - public void checkInvalidSkipCountStatusCode() throws Exception - { - - restClient.authenticateUser(adminUserModel).withParams("skipCount=AB").withCoreAPI().usingResource(document).getRatings(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Invalid paging parameter skipCount:AB"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "If nodeId does not exist status code is 404 when a document is liked") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) - public void addLikeUsingInvalidNodeId() throws Exception - { - FileModel document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); - restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).rateStarsToDocument(5); - restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).likeDocument(); - document.setNodeRef(RandomStringUtils.randomAlphanumeric(20)); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getRatings(); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, document.getNodeRef())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Check that rating value is TRUE for a like rating") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) - public void checkRatingValueIsTrueForLikedDoc() throws Exception - { - - ratingsModel = restClient.authenticateUser(userModel).withCoreAPI().usingResource(document).getRatings(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - ratingsModel.assertThat().entriesListContains("myRating", "true") - .assertThat().entriesListContains("id", "likes"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Check that rating value is an INTEGER value for stars rating") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) - public void checkRatingValueIsIntegerForStarsRating() throws Exception - { - - ratingsModel = restClient.authenticateUser(userModel).withCoreAPI().usingResource(document).getRatings(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - ratingsModel.assertThat().entriesListContains("myRating", "5") - .assertThat().entriesListContains("id", "fiveStar"); - } - -} diff --git a/e2e-test/java/org/alfresco/rest/ratings/GetRatingsFullTests.java b/e2e-test/java/org/alfresco/rest/ratings/GetRatingsFullTests.java deleted file mode 100644 index 7b124ffeb..000000000 --- a/e2e-test/java/org/alfresco/rest/ratings/GetRatingsFullTests.java +++ /dev/null @@ -1,116 +0,0 @@ -package org.alfresco.rest.ratings; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestRatingModelsCollection; -import org.alfresco.utility.exception.DataPreparationException; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -public class GetRatingsFullTests extends RestTest -{ - private SiteModel siteModel; - private UserModel adminUserModel, userModel; - private FileModel document; - private RestRatingModelsCollection ratingsModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws DataPreparationException - { - adminUserModel = dataUser.getAdminUser(); - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingAdmin().createPublicRandomSite(); - } - - @BeforeMethod(alwaysRun = true) - public void setUp() throws DataPreparationException, Exception - { - document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); - restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).rateStarsToDocument(5); - restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).likeDocument(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Check default error schema in case of failure") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) - public void checkDefaultErrorSchema() throws Exception - { - FileModel document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); - document.setNodeRef("abc"); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getRatings(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "abc")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Check maxItems and skipCount parameters") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) - public void checkMaxItemsAndSkipCountParameters() throws Exception - { - ratingsModel = restClient.authenticateUser(adminUserModel).withParams("maxItems=1", "skipCount=1").withCoreAPI().usingResource(document).getRatings(); - ratingsModel.assertThat().entriesListCountIs(1); - ratingsModel.getPagination().assertThat().field("maxItems").is("1") - .and().field("skipCount").is("1"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Check totalItems and hasMoreitems parameters") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) - public void checkTotalItemsAndHasMoreItemsParameters() throws Exception - { - ratingsModel = restClient.authenticateUser(adminUserModel).withParams("maxItems=1").withCoreAPI().usingResource(document).getRatings(); - ratingsModel.assertThat().entriesListCountIs(1); - ratingsModel.getPagination().assertThat().field("hasMoreItems").is("true") - .and().field("count").is("1").and().field("maxItems").is("1"); - } - - @Bug(id = "REPO-1831") - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Get ratings for a document to which authenticated user does not have access") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) - public void userIsNotAbleToGetRatingsOfDocumentToWhichItHasNoAccess() throws Exception - { - SiteModel privateSite = dataSite.usingAdmin().createPrivateRandomSite(); - FileModel file = dataContent.usingSite(privateSite).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); - ratingsModel = restClient.authenticateUser(userModel).withCoreAPI().usingResource(file).getRatings(); - ratingsModel.assertThat().entriesListIsEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Check high value for skipCount parameter") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) - public void getRatingsUsingHighValueForSkipCount() throws Exception - { - ratingsModel = restClient.authenticateUser(adminUserModel).withParams("skipCount=100").withCoreAPI().usingResource(document).getRatings(); - ratingsModel.getPagination().assertThat().field("skipCount").is("100"); - ratingsModel.assertThat().entriesListIsEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Get ratings using site id instead of node id") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.FULL }) - public void getRatingsUsingSiteId() throws Exception - { - FileModel document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); - document.setNodeRef(siteModel.getId()); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getRatings(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, siteModel.getId())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/ratings/GetRatingsSanityTests.java b/e2e-test/java/org/alfresco/rest/ratings/GetRatingsSanityTests.java deleted file mode 100644 index a973d37c5..000000000 --- a/e2e-test/java/org/alfresco/rest/ratings/GetRatingsSanityTests.java +++ /dev/null @@ -1,150 +0,0 @@ -package org.alfresco.rest.ratings; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestRatingModelsCollection; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.exception.DataPreparationException; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class GetRatingsSanityTests extends RestTest -{ - private SiteModel siteModel; - private UserModel adminUser; - private ListUserWithRoles usersWithRoles; - private RestRatingModelsCollection restRatingModelsCollection; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws DataPreparationException - { - adminUser = dataUser.getAdminUser(); - siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); - - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Manager is able to retrieve document ratings") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) - public void managerIsAbleToRetrieveDocumentRatings() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - - restClient.withCoreAPI().usingResource(document).likeDocument(); - restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - - restRatingModelsCollection = restClient.withCoreAPI().usingResource(document).getRatings(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restRatingModelsCollection.assertNodeHasFiveStarRating().assertNodeIsLiked(); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Collaborator is able to retrieve document ratings") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) - public void collaboratorIsAbleToRetrieveDocumentRatings() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - - restClient.withCoreAPI().usingResource(document).likeDocument(); - restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - - restRatingModelsCollection = restClient.withCoreAPI().usingResource(document).getRatings(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restRatingModelsCollection.assertNodeHasFiveStarRating().assertNodeIsLiked(); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Contributor is able to retrieve document ratings") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) - public void contributorIsAbleToRetrieveDocumentRatings() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - - restClient.withCoreAPI().usingResource(document).likeDocument(); - restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - - restRatingModelsCollection = restClient.withCoreAPI().usingResource(document).getRatings(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restRatingModelsCollection.assertNodeHasFiveStarRating().assertNodeIsLiked(); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Consumer is able to retrieve document ratings") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) - public void consumerIsAbleToRetrieveDocumentRatings() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - - restClient.withCoreAPI().usingResource(document).likeDocument(); - restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - - restRatingModelsCollection = restClient.withCoreAPI().usingResource(document).getRatings(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restRatingModelsCollection.assertNodeHasFiveStarRating().assertNodeIsLiked(); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Admin user is able to retrieve document ratings") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) - public void adminIsAbleToRetrieveDocumentRatings() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - document = dataContent.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingResource(folderModel) - .createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(adminUser); - restClient.withCoreAPI().usingResource(document).likeDocument(); - restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - - restRatingModelsCollection = restClient.withCoreAPI().usingResource(document).getRatings(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restRatingModelsCollection.assertNodeHasFiveStarRating().assertNodeIsLiked(); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.RATINGS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to retrieve document ratings") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) - @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void unauthenticatedUserIsNotAbleToRetrieveRatings() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(adminUser); - restClient.withCoreAPI().usingResource(document).likeDocument(); - restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - - restClient.authenticateUser(new UserModel("random user", "random password")); - - restClient.withCoreAPI().usingResource(document).getRatings(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/ratings/GetRatingsTests.java b/e2e-test/java/org/alfresco/rest/ratings/GetRatingsTests.java new file mode 100644 index 000000000..70b205162 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/ratings/GetRatingsTests.java @@ -0,0 +1,313 @@ +package org.alfresco.rest.ratings; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestRatingModelsCollection; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.exception.DataPreparationException; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.apache.commons.lang.RandomStringUtils; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class GetRatingsTests extends RestTest +{ + private SiteModel siteModel; + private UserModel adminUser, userModel; + private ListUserWithRoles usersWithRoles; + private RestRatingModelsCollection restRatingModelsCollection; + private FileModel document; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws DataPreparationException + { + adminUser = dataUser.getAdminUser(); + userModel = dataUser.createRandomTestUser(); + + siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); + + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.SANITY, description = "Manager is able to retrieve document ratings") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) + public void managerIsAbleToRetrieveDocumentRatings() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + + restClient.withCoreAPI().usingResource(document).likeDocument(); + restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); + + restRatingModelsCollection = restClient.withCoreAPI().usingResource(document).getRatings(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restRatingModelsCollection.assertNodeHasFiveStarRating().assertNodeIsLiked(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Collaborator is able to retrieve document ratings") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void collaboratorIsAbleToRetrieveDocumentRatings() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + + restClient.withCoreAPI().usingResource(document).likeDocument(); + restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); + + restRatingModelsCollection = restClient.withCoreAPI().usingResource(document).getRatings(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restRatingModelsCollection.assertNodeHasFiveStarRating().assertNodeIsLiked(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Contributor is able to retrieve document ratings") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void contributorIsAbleToRetrieveDocumentRatings() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + + restClient.withCoreAPI().usingResource(document).likeDocument(); + restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); + + restRatingModelsCollection = restClient.withCoreAPI().usingResource(document).getRatings(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restRatingModelsCollection.assertNodeHasFiveStarRating().assertNodeIsLiked(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Consumer is able to retrieve document ratings") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void consumerIsAbleToRetrieveDocumentRatings() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + + restClient.withCoreAPI().usingResource(document).likeDocument(); + restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); + + restRatingModelsCollection = restClient.withCoreAPI().usingResource(document).getRatings(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restRatingModelsCollection.assertNodeHasFiveStarRating().assertNodeIsLiked(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Admin user is able to retrieve document ratings") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void adminIsAbleToRetrieveDocumentRatings() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + document = dataContent.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingResource(folderModel) + .createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(adminUser); + restClient.withCoreAPI().usingResource(document).likeDocument(); + restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); + + restRatingModelsCollection = restClient.withCoreAPI().usingResource(document).getRatings(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restRatingModelsCollection.assertNodeHasFiveStarRating().assertNodeIsLiked(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to retrieve document ratings") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) +// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") + public void unauthenticatedUserIsNotAbleToRetrieveRatings() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(adminUser); + restClient.withCoreAPI().usingResource(document).likeDocument(); + restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); + + restClient.authenticateUser(new UserModel("random user", "random password")); + + restClient.withCoreAPI().usingResource(document).getRatings(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Check that rating for invalid maxItems status code is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void checkInvalidMaxItemsStatusCode() throws Exception + { + document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); + restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).rateStarsToDocument(5); + restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).likeDocument(); + + restClient.authenticateUser(adminUser).withParams("maxItems=0").withCoreAPI().usingResource(document).getRatings(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Only positive values supported for maxItems"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Check that rating for invalid skipCount status code is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void checkInvalidSkipCountStatusCode() throws Exception + { + document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); + restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).rateStarsToDocument(5); + restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).likeDocument(); + + restClient.authenticateUser(adminUser).withParams("skipCount=AB").withCoreAPI().usingResource(document).getRatings(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Invalid paging parameter skipCount:AB"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "If nodeId does not exist status code is 404 when a document is liked") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void addLikeUsingInvalidNodeId() throws Exception + { + document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); + restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).rateStarsToDocument(5); + restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).likeDocument(); + document.setNodeRef(RandomStringUtils.randomAlphanumeric(20)); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).getRatings(); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, document.getNodeRef())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Check that rating value is TRUE for a like rating") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void checkRatingValueIsTrueForLikedDoc() throws Exception + { + document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); + restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).rateStarsToDocument(5); + restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).likeDocument(); + + restRatingModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingResource(document).getRatings(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + restRatingModelsCollection.assertThat().entriesListContains("myRating", "true") + .assertThat().entriesListContains("id", "likes"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Check that rating value is an INTEGER value for stars rating") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void checkRatingValueIsIntegerForStarsRating() throws Exception + { + document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); + restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).rateStarsToDocument(5); + restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).likeDocument(); + + restRatingModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingResource(document).getRatings(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + restRatingModelsCollection.assertThat().entriesListContains("myRating", "5") + .assertThat().entriesListContains("id", "fiveStar"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Check default error schema in case of failure") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void checkDefaultErrorSchema() throws Exception + { + FileModel document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); + document.setNodeRef("abc"); + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).getRatings(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "abc")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Check maxItems and skipCount parameters") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void checkMaxItemsAndSkipCountParameters() throws Exception + { + document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); + restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).rateStarsToDocument(5); + restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).likeDocument(); + + restRatingModelsCollection = restClient.authenticateUser(adminUser).withParams("maxItems=1", "skipCount=1").withCoreAPI().usingResource(document).getRatings(); + restRatingModelsCollection.assertThat().entriesListCountIs(1); + restRatingModelsCollection.getPagination().assertThat().field("maxItems").is("1") + .and().field("skipCount").is("1"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Check totalItems and hasMoreitems parameters") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void checkTotalItemsAndHasMoreItemsParameters() throws Exception + { + document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); + restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).rateStarsToDocument(5); + restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).likeDocument(); + + restRatingModelsCollection = restClient.authenticateUser(adminUser).withParams("maxItems=1").withCoreAPI().usingResource(document).getRatings(); + restRatingModelsCollection.assertThat().entriesListCountIs(1); + restRatingModelsCollection.getPagination().assertThat().field("hasMoreItems").is("true") + .and().field("count").is("1").and().field("maxItems").is("1"); + } + + @Bug(id = "REPO-1831") + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Get ratings for a document to which authenticated user does not have access") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void userIsNotAbleToGetRatingsOfDocumentToWhichItHasNoAccess() throws Exception + { + SiteModel privateSite = dataSite.usingAdmin().createPrivateRandomSite(); + FileModel file = dataContent.usingSite(privateSite).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); + restRatingModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingResource(file).getRatings(); + restRatingModelsCollection.assertThat().entriesListIsEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Check high value for skipCount parameter") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void getRatingsUsingHighValueForSkipCount() throws Exception + { + document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); + restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).rateStarsToDocument(5); + restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).likeDocument(); + + restRatingModelsCollection = restClient.authenticateUser(adminUser).withParams("skipCount=100").withCoreAPI().usingResource(document).getRatings(); + restRatingModelsCollection.getPagination().assertThat().field("skipCount").is("100"); + restRatingModelsCollection.assertThat().entriesListIsEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Get ratings using site id instead of node id") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void getRatingsUsingSiteId() throws Exception + { + FileModel document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); + document.setNodeRef(siteModel.getId()); + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).getRatings(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, siteModel.getId())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } +} \ No newline at end of file From 25af74cfffdcea1a6d1d9a7fc389bee2cd08a8b6 Mon Sep 17 00:00:00 2001 From: Alexandru-Eusebiu Epure Date: Fri, 6 Oct 2017 15:30:34 +0300 Subject: [PATCH 1231/1491] REPO-2755 : REST API & CMIS TAS sanity builds Change testgroup from CORE to REGRESSION Joined NodesUnlockTests unlock with different user is done in the same test, to avoid redundant opperations. --- .../nodes/NodesContentAndVersioningTests.java | 14 +-- .../alfresco/rest/nodes/NodesLockTests.java | 36 +++---- .../rest/nodes/NodesParentChildrenTests.java | 4 +- .../org/alfresco/rest/nodes/NodesTests.java | 2 +- .../alfresco/rest/nodes/NodesUnlockTests.java | 100 +++++------------- 5 files changed, 54 insertions(+), 102 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/nodes/NodesContentAndVersioningTests.java b/e2e-test/java/org/alfresco/rest/nodes/NodesContentAndVersioningTests.java index f4da4d307..d5f433dd6 100644 --- a/e2e-test/java/org/alfresco/rest/nodes/NodesContentAndVersioningTests.java +++ b/e2e-test/java/org/alfresco/rest/nodes/NodesContentAndVersioningTests.java @@ -57,7 +57,7 @@ public class NodesContentAndVersioningTests extends RestTest @TestRail(section = { TestGroup.REST_API,TestGroup.NODES }, executionType = ExecutionType.SANITY, description = "Verify file name in Content-Disposition header") - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY}) + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY}) public void checkFileNameWithRegularCharsInHeader() throws Exception { restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("attachment=false").getNodeContent(); @@ -68,7 +68,7 @@ public class NodesContentAndVersioningTests extends RestTest @Bug(id="MNT-17545", description = "HTTP Header Injection in ContentStreamer", status = Bug.Status.FIXED) @TestRail(section = { TestGroup.REST_API,TestGroup.NODES }, executionType = ExecutionType.REGRESSION, description = "Verify file name with special chars is escaped in Content-Disposition header") - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE}) + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION}) public void checkFileNameWithSpecialCharsInHeader() throws Exception { char c1 = 127; @@ -80,7 +80,7 @@ public class NodesContentAndVersioningTests extends RestTest restClient.assertHeaderValueContains("Content-Disposition","filename=\" test .txt\""); } - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.SANITY, description = "Verify that alfresco returns the correct encoding for files created via REST.") public void verifyFileEncodingUsingRestAPI() throws Exception @@ -109,7 +109,7 @@ public class NodesContentAndVersioningTests extends RestTest restClient.withCoreAPI().usingNode(iso8859File).getNodeContent().assertThat().contentType(iso8859Type); } - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.SANITY, description = "Verify updating a node content.") public void testUpdateNodeContent() throws Exception @@ -133,7 +133,7 @@ public class NodesContentAndVersioningTests extends RestTest assertTrue(updatedBodyNodeVersion.charAt(0) > initialNodeVersion.charAt(0)); } - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.SANITY, description = "Test copy a node.") public void testCopyNode() throws Exception @@ -166,7 +166,7 @@ public class NodesContentAndVersioningTests extends RestTest assertFalse(initialNode.getIsLocked()); } - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.SANITY, description = "Test retrieving node versions, a specific version and version content.") public void testGetVersionContent() throws Exception @@ -220,7 +220,7 @@ public class NodesContentAndVersioningTests extends RestTest restClient.assertHeaderValueContains("Content-Disposition", String.format("filename=\"%s\"", file2.getName())); } - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.SANITY, description = "Test revert and delete a node version.") public void testRevertDeleteVersion() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/nodes/NodesLockTests.java b/e2e-test/java/org/alfresco/rest/nodes/NodesLockTests.java index cef556b7b..e5eb760a9 100644 --- a/e2e-test/java/org/alfresco/rest/nodes/NodesLockTests.java +++ b/e2e-test/java/org/alfresco/rest/nodes/NodesLockTests.java @@ -40,7 +40,7 @@ public class NodesLockTests extends RestTest } - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator can not lock PERSISTENT after EPHEMERAL lock made by different user") public void lockEphemeralAndRelockPersistentDifferentUser() throws Exception @@ -57,7 +57,7 @@ public class NodesLockTests extends RestTest lockBodyModel.setLifetime("EPHEMERAL"); lockBodyModel.setTimeToExpire(20); lockBodyModel.setType("FULL"); - restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); + restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").lockNode(lockBodyModel); restClient.assertStatusCodeIs(HttpStatus.OK); STEP("4. Verify with user1 that the file is locked."); @@ -78,9 +78,9 @@ public class NodesLockTests extends RestTest .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); } - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, - description = "Verify Collaborator can not lock PERSISTENT after EPHEMERAL lock made by different user") + description = "Verify Collaborator can not lock EPHEMERAL after EPHEMERAL lock made by different user") public void lockEphemeralAndRelockEphemeralDifferentUser() throws Exception { STEP("1. Adds a file in the site by administrator."); @@ -116,7 +116,7 @@ public class NodesLockTests extends RestTest .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); } - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator can lock EPHEMERAL after EPHEMERAL lock made by same user") public void lockEphemeralAndRelockEphemeralSameUser() throws Exception @@ -155,7 +155,7 @@ public class NodesLockTests extends RestTest } @Bug(id = "MNT-17612", status = Status.FIXED, description = "AccessDeniedException in AOS Edit Offline Upload New Version") - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator can lock PERSISTENT after EPHEMERAL lock made by same user") public void lockEphemeralAndRelockPersistentSameUser() throws Exception @@ -200,7 +200,7 @@ public class NodesLockTests extends RestTest .assertThat().field("properties").contains("lockType=WRITE_LOCK"); } - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator can not lock EPHEMERAL after PERSISTENT lock made by different user") public void lockPersistentAndRelockEphemeralDifferentUser() throws Exception @@ -238,7 +238,7 @@ public class NodesLockTests extends RestTest .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); } - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator can not lock PERSISTENT after PERSISTENT lock made by different user") public void lockPersistentAndRelockPersistentDifferentUser() throws Exception @@ -276,7 +276,7 @@ public class NodesLockTests extends RestTest .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); } - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator can lock EPHEMERAL after PERSISTENT lock made by different user is expired") public void lockPersistentAndRelockEphemeralAfterExpiredLockDifferentUser() throws Exception @@ -316,7 +316,7 @@ public class NodesLockTests extends RestTest } @Bug(id = "MNT-17612", status = Status.FIXED, description = "AccessDeniedException in AOS Edit Offline Upload New Version") - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator can lock PERSISTENT after EPHEMERAL lock made by another user is expired") public void lockEphemeralAndRelockPersistentAfterExpiredLockDifferentUser() throws Exception @@ -355,7 +355,7 @@ public class NodesLockTests extends RestTest .assertThat().field("properties").contains("lockType=WRITE_LOCK"); } - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator can lock EPHEMERAL after EPHEMERAL lock made by another user is expired") public void lockEphemeralAndRelockEphemeralAfterExpiredLockDifferentUser() throws Exception @@ -394,7 +394,7 @@ public class NodesLockTests extends RestTest .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); } - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator can lock PERSISTENT after PERSISTENT lock made by different user is expired") public void lockPersistentAndRelockPersistentAfterExpiredLockDifferentUser() throws Exception @@ -433,7 +433,7 @@ public class NodesLockTests extends RestTest .assertThat().field("properties").contains("lockType=WRITE_LOCK"); } - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator can lock EPHEMERAL after EPHEMERAL lock made by same user is expired") public void lockEphemeralAndRelockEphemeralAfterExpiredLockSameUser() throws Exception @@ -472,7 +472,7 @@ public class NodesLockTests extends RestTest .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); } - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator can lock PERSISTENT after PERSISTENT lock made by same user is expired") public void lockPersistentAndRelockPersistentAfterExpiredLockSameUser() throws Exception @@ -510,7 +510,7 @@ public class NodesLockTests extends RestTest .assertThat().field("properties").contains("lockType=WRITE_LOCK"); } - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator can lock EPHEMERAL after PERSISTENT lock made by same user is expired") public void lockPersistentAndRelockEphemeralAfterExpiredLockSameUser() throws Exception @@ -550,7 +550,7 @@ public class NodesLockTests extends RestTest } @Bug(id = "MNT-17612", status = Status.FIXED, description = "AccessDeniedException in AOS Edit Offline Upload New Version") - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator can lock PERSISTENT after EPHEMERAL lock made by same user is expired") public void lockEphemeralAndRelockPersistentAfterExpiredLockSameUser() throws Exception @@ -590,7 +590,7 @@ public class NodesLockTests extends RestTest .assertThat().field("properties").contains("lockType=WRITE_LOCK"); } - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator can lock PERSISTENT after PERSISTENT lock made by same user") public void lockPersistentAndRelockPersistentSameUser() throws Exception @@ -628,7 +628,7 @@ public class NodesLockTests extends RestTest .assertThat().field("properties").contains("lockType=WRITE_LOCK"); } - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator can lock EPHERMERAL after PERSISTENT lock made by same user") public void lockPersistentAndRelockEphemeralSameUser() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/nodes/NodesParentChildrenTests.java b/e2e-test/java/org/alfresco/rest/nodes/NodesParentChildrenTests.java index 097f652e3..417eb99d1 100644 --- a/e2e-test/java/org/alfresco/rest/nodes/NodesParentChildrenTests.java +++ b/e2e-test/java/org/alfresco/rest/nodes/NodesParentChildrenTests.java @@ -46,9 +46,9 @@ public class NodesParentChildrenTests extends RestTest .assertThat().field("name").contains(node.getName()); } - @TestRail(section = { TestGroup.REST_API,TestGroup.NODES }, executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API,TestGroup.NODES }, executionType = ExecutionType.REGRESSION, description = "Verify new folder node is created as children on -my- posting as MultiPart content type") - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY}) + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION}) public void createNewFolderNodeWithMultiPartForms() throws Exception { //configuring multipart form diff --git a/e2e-test/java/org/alfresco/rest/nodes/NodesTests.java b/e2e-test/java/org/alfresco/rest/nodes/NodesTests.java index 7bad114a4..b122296c6 100644 --- a/e2e-test/java/org/alfresco/rest/nodes/NodesTests.java +++ b/e2e-test/java/org/alfresco/rest/nodes/NodesTests.java @@ -51,6 +51,6 @@ public class NodesTests extends RestTest * - destinationFolder * - file */ - response.assertThat().field("parentId").is(destinationFolder.getId()); + response.assertThat().field("parentId").is(destinationFolder.getId()); } } diff --git a/e2e-test/java/org/alfresco/rest/nodes/NodesUnlockTests.java b/e2e-test/java/org/alfresco/rest/nodes/NodesUnlockTests.java index 9be1281c6..ca10a5c59 100644 --- a/e2e-test/java/org/alfresco/rest/nodes/NodesUnlockTests.java +++ b/e2e-test/java/org/alfresco/rest/nodes/NodesUnlockTests.java @@ -37,85 +37,29 @@ public class NodesUnlockTests extends RestTest user2.setUserRole(UserRole.SiteCollaborator); } - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.NODES}, executionType= ExecutionType.REGRESSION, - description= "Verify Collaborator can unlock after EPHEMERAL lock made by same user") - public void lockEphemeralAndUnlockWithSameUser() throws Exception + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY }) + @TestRail(section={TestGroup.REST_API, TestGroup.NODES}, executionType= ExecutionType.SANITY, + description= "Verify Collaborator canot unlock EPHEMERAL lock made by different user, but can unlock EPHEMERAL lock made by same user") + public void lockEphemeralAndUnlock() throws Exception { STEP("1. Add user(s) as collaborators to the site created by administrator and add a file in this site."); file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); - + STEP("2. Verify with user1 that the file is not locked."); RestNodeModel file1Model1 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); file1Model1.assertThat().field("isLocked").is(false); - + STEP("3. Lock the file using mode EPHEMERAL with user1 (POST nodes/{nodeId}/lock)."); RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); lockBodyModel.setLifetime("EPHEMERAL"); lockBodyModel.setTimeToExpire(20); restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); restClient.assertStatusCodeIs(HttpStatus.OK); - + STEP("4. Verify with user1 that the file is locked."); RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); file1Model2.assertThat().field("isLocked").is(true); - - STEP("5. Unlock the file with user1 while the file is still locked"); - RestNodeModel file1Model3 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").unlockNode(); - file1Model3.assertThat().field("isLocked").is(false); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.NODES}, executionType= ExecutionType.REGRESSION, - description= "Verify Collaborator can unlock after PERSISTENT lock made by same user") - public void lockPersistentAndUnlockSameUser() throws Exception{ - - STEP("1. Add user(s) as collaborators to the site created by administrator and add a file in this site."); - file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); - - STEP("2. Verify with admin that the file is not locked."); - RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model1.assertThat().field("isLocked").is(false); - - STEP("3. Lock the file using mode PERSISTENT with user1 (POST nodes/{nodeId}/lock)."); - RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); - lockBodyModel.setLifetime("PERSISTENT"); - lockBodyModel.setTimeToExpire(20); - restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - - STEP("4. Verify with user1 that the file is locked."); - RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model2.assertThat().field("isLocked").is(true); - - STEP("5. Unlock the file with user1 while the file is still locked"); - RestNodeModel file1Model3 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").unlockNode(); - file1Model3.assertThat().field("isLocked").is(false); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.NODES}, executionType= ExecutionType.REGRESSION, - description= "Verify Collaborator can not unlock file after EPHEMERAL lock made by different user") - public void lockEphemeralAndUnlockWithDifferentUser() throws Exception{ - - STEP("1. Add user(s) as collaborators to the site created by administrator and add a file in this site."); - file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); - - STEP("2. Verify with admin that the file is not locked."); - RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model1.assertThat().field("isLocked").is(false); - - STEP("3. Lock the file using mode EPHEMERAL with user1 (POST nodes/{nodeId}/lock)."); - RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); - lockBodyModel.setLifetime("EPHEMERAL"); - lockBodyModel.setTimeToExpire(20); - restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - - STEP("4. Verify with user1 that the file is locked."); - RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model2.assertThat().field("isLocked").is(true); - + STEP("5. Cannot unlock the file with user2 while the file is still locked"); restClient.authenticateUser(user2).withCoreAPI().usingNode(file1).usingParams("include=isLocked").unlockNode(); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) @@ -123,31 +67,35 @@ public class NodesUnlockTests extends RestTest .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + + STEP("6. Unlock the file with user1 while the file is still locked"); + RestNodeModel file1Model3 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").unlockNode(); + file1Model3.assertThat().field("isLocked").is(false); } - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.NODES}, executionType= ExecutionType.REGRESSION, - description= "Verify Collaborator can not unlock file after PERSISTENT lock made by different user") - public void lockPersistentAndUnlockWithDifferentUser() throws Exception{ - + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY }) + @TestRail(section={TestGroup.REST_API, TestGroup.NODES}, executionType= ExecutionType.SANITY, + description= "Verify Collaborator canot unlock PERSISTENT lock made by different user, but can unlock PERSISTENT lock made by same user") + public void lockPersistentAndUnlock() throws Exception{ + STEP("1. Add user(s) as collaborators to the site created by administrator and add a file in this site."); file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); - + STEP("2. Verify with admin that the file is not locked."); RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); file1Model1.assertThat().field("isLocked").is(false); - + STEP("3. Lock the file using mode PERSISTENT with user1 (POST nodes/{nodeId}/lock)."); RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); lockBodyModel.setLifetime("PERSISTENT"); lockBodyModel.setTimeToExpire(20); restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); restClient.assertStatusCodeIs(HttpStatus.OK); - - STEP("4. Verify with admin that the file is locked."); + + STEP("4. Verify with user1 that the file is locked."); RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); file1Model2.assertThat().field("isLocked").is(true); - + STEP("5. Cannot unlock the file with user2 while the file is still locked"); restClient.authenticateUser(user2).withCoreAPI().usingNode(file1).usingParams("include=isLocked").unlockNode(); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) @@ -155,6 +103,10 @@ public class NodesUnlockTests extends RestTest .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + + STEP("6. Unlock the file with user1 while the file is still locked"); + RestNodeModel file1Model3 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").unlockNode(); + file1Model3.assertThat().field("isLocked").is(false); } } From b07d84f9c2fc9a52108c3b5ab3e2a0142c51b209 Mon Sep 17 00:00:00 2001 From: Alexandru-Eusebiu Epure Date: Fri, 6 Oct 2017 15:48:13 +0300 Subject: [PATCH 1232/1491] REPO-2755 : REST API & CMIS TAS sanity builds Change testgroup from CORE to REGRESSION for AUDIT package --- .../org/alfresco/rest/audit/AuditTest.java | 2 - ...itCoreTests.java => DeleteAuditTests.java} | 6 +-- ...AuditCoreTests.java => GetAuditTests.java} | 49 +++++++++---------- ...AuditCoreTests.java => PutAuditTests.java} | 14 +++--- 4 files changed, 34 insertions(+), 37 deletions(-) rename e2e-test/java/org/alfresco/rest/audit/{DeleteAuditCoreTests.java => DeleteAuditTests.java} (97%) rename e2e-test/java/org/alfresco/rest/audit/{GetAuditCoreTests.java => GetAuditTests.java} (92%) rename e2e-test/java/org/alfresco/rest/audit/{PutAuditCoreTests.java => PutAuditTests.java} (91%) diff --git a/e2e-test/java/org/alfresco/rest/audit/AuditTest.java b/e2e-test/java/org/alfresco/rest/audit/AuditTest.java index fea6bfa49..8259901e7 100644 --- a/e2e-test/java/org/alfresco/rest/audit/AuditTest.java +++ b/e2e-test/java/org/alfresco/rest/audit/AuditTest.java @@ -11,10 +11,8 @@ import org.alfresco.rest.model.RestAuditAppModel; import org.alfresco.rest.model.RestAuditAppModelsCollection; import org.alfresco.rest.model.RestAuditEntryModel; import org.alfresco.rest.model.RestAuditEntryModelsCollection; -import org.alfresco.rest.model.RestNodeBodyModel; import org.alfresco.rest.model.RestNodeModel; import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.model.ContentModel; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; diff --git a/e2e-test/java/org/alfresco/rest/audit/DeleteAuditCoreTests.java b/e2e-test/java/org/alfresco/rest/audit/DeleteAuditTests.java similarity index 97% rename from e2e-test/java/org/alfresco/rest/audit/DeleteAuditCoreTests.java rename to e2e-test/java/org/alfresco/rest/audit/DeleteAuditTests.java index 5d0a4e94f..bbc6f2557 100644 --- a/e2e-test/java/org/alfresco/rest/audit/DeleteAuditCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/audit/DeleteAuditTests.java @@ -8,10 +8,10 @@ import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; import org.testng.annotations.Test; -public class DeleteAuditCoreTests extends AuditTest +public class DeleteAuditTests extends AuditTest { - @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if deleting an audit entry for an application is only for admin user, and status code is 204") public void deleteAuditEntry() throws Exception @@ -35,7 +35,7 @@ public class DeleteAuditCoreTests extends AuditTest restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); } - @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if deleting a set of audit entries for an application is only for admin user, and status code is 204") public void deleteAuditEntriesForAnAuditApplication() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/audit/GetAuditCoreTests.java b/e2e-test/java/org/alfresco/rest/audit/GetAuditTests.java similarity index 92% rename from e2e-test/java/org/alfresco/rest/audit/GetAuditCoreTests.java rename to e2e-test/java/org/alfresco/rest/audit/GetAuditTests.java index 1ac998beb..5a2f063ce 100644 --- a/e2e-test/java/org/alfresco/rest/audit/GetAuditCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/audit/GetAuditTests.java @@ -2,7 +2,6 @@ package org.alfresco.rest.audit; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; import static org.testng.Assert.assertTrue; import java.util.ArrayList; @@ -13,10 +12,10 @@ import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; import org.testng.annotations.Test; -public class GetAuditCoreTests extends AuditTest +public class GetAuditTests extends AuditTest { - @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if the admin user gets audit application info") public void getAuditApplicationInfoWithAdminUser() throws Exception @@ -36,7 +35,7 @@ public class GetAuditCoreTests extends AuditTest taggingRestAuditAppModel.assertThat().field("id").is("tagging"); } - @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if a normal user gets a list of audit applications and status code is 403") public void getAuditApplicationsWithNormalUser() throws Exception @@ -46,9 +45,9 @@ public class GetAuditCoreTests extends AuditTest restAuditCollection.assertThat().entriesListIsEmpty(); } - @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, - TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if the admin user gets a list of audit applications using skipCount and status code is 200") + TestGroup.AUDIT }, executionType = ExecutionType.REGRESSION, description = "Verify if the admin user gets a list of audit applications using skipCount and status code is 200") public void getAuditApplicationsWithAdminUserUsingValidSkipCount() throws Exception { restAuditCollection = restClient.authenticateUser(adminUser).withParams("skipCount=1").withCoreAPI() @@ -58,9 +57,9 @@ public class GetAuditCoreTests extends AuditTest .isGreaterThan(0).and().field("skipCount").is("1"); } - @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, - TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if the admin user gets a list of audit applications using invalid skipCount and status code is 400") + TestGroup.AUDIT }, executionType = ExecutionType.REGRESSION, description = "Verify if the admin user gets a list of audit applications using invalid skipCount and status code is 400") public void getAuditApplicationsWithAdminUserUsingInvalidSkipCount() throws Exception { restClient.authenticateUser(adminUser).withParams("skipCount=-1").withCoreAPI().usingAudit() @@ -68,9 +67,9 @@ public class GetAuditCoreTests extends AuditTest restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); } - @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, - TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if the admin user gets a list of audit applications using maxItems and status code is 200") + TestGroup.AUDIT }, executionType = ExecutionType.REGRESSION, description = "Verify if the admin user gets a list of audit applications using maxItems and status code is 200") public void getAuditApplicationsWithAdminUserUsingValidMaxItems() throws Exception { restAuditCollection = restClient.authenticateUser(adminUser).withParams("maxItems=1").withCoreAPI() @@ -81,9 +80,9 @@ public class GetAuditCoreTests extends AuditTest assertEquals(restAuditCollection.getEntries().size(), 1); } - @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, - TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if the admin user gets a list of audit applications using invalid maxItems and status code is 400") + TestGroup.AUDIT }, executionType = ExecutionType.REGRESSION, description = "Verify if the admin user gets a list of audit applications using invalid maxItems and status code is 400") public void getAuditApplicationsWithAdminUserUsingInvalidMaxItems() throws Exception { restClient.authenticateUser(adminUser).withParams("maxItems=-1").withCoreAPI().usingAudit() @@ -96,7 +95,7 @@ public class GetAuditCoreTests extends AuditTest } - @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if the admin user gets a list of audit applications using skipCount and maxItems and status code is 200") public void getAuditApplicationsWithAdminUserUsingValidSkipCountAndMaxItems() throws Exception @@ -109,9 +108,9 @@ public class GetAuditCoreTests extends AuditTest assertEquals(restAuditCollection.getEntries().size(), 1); } - @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, - TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if the admin user gets a list of audit applications using invalid skipCount and/or invalid maxItems and status code is 400") + TestGroup.AUDIT }, executionType = ExecutionType.REGRESSION, description = "Verify if the admin user gets a list of audit applications using invalid skipCount and/or invalid maxItems and status code is 400") public void getAuditApplicationsWithAdminUserUsingInvalidSkipCountAndMaxItems() throws Exception { restClient.authenticateUser(adminUser).withParams("skipCount=-1&maxItems=1").withCoreAPI().usingAudit() @@ -131,7 +130,7 @@ public class GetAuditCoreTests extends AuditTest restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); } - @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if a normal user gets a list of audit entries for audit application auditApplicationId and status code is 403") public void getAuditEntriesWithNormalUser() throws Exception @@ -141,7 +140,7 @@ public class GetAuditCoreTests extends AuditTest restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); } - @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if the admin user gets a list of audit entries using invalid skipCount and/or invalid maxItems and status code is 400") public void getAuditEntriesWithAdminUserUsingInvalidSkipCountAndMaxItems() throws Exception @@ -163,7 +162,7 @@ public class GetAuditCoreTests extends AuditTest restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); } - @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if the admin user gets a list of audit entries using valid skipCount and maxItems and status code is 200") public void getAuditEntriesWithAdminUserUsingValidSkipCountAndMaxItems() throws Exception @@ -200,9 +199,9 @@ public class GetAuditCoreTests extends AuditTest } while (skipCount < numberOfElements); } - @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, - TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if the admin user gets a list of audit entries using orderBy and status code is 200") + TestGroup.AUDIT }, executionType = ExecutionType.REGRESSION, description = "Verify if the admin user gets a list of audit entries using orderBy and status code is 200") public void getAuditEntriesWithAdminUserUsingOrderBy() throws Exception { restAuditEntryCollection = restClient.authenticateUser(adminUser).withParams("orderBy=createdAt ASC&maxItems=10") @@ -218,9 +217,9 @@ public class GetAuditCoreTests extends AuditTest assertTrue(Integer.parseInt(restAuditEntryCollection.getEntries().get(1).onModel().getId()) > Integer.parseInt(ascId)); } - @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, - TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if the admin user gets a list of audit entries using the where parameter to and status code is 200") + TestGroup.AUDIT }, executionType = ExecutionType.REGRESSION, description = "Verify if the admin user gets a list of audit entries using the where parameter to and status code is 200") public void getAuditEntriesWithAdminUserUsingWhere() throws Exception { int expectedNumberOfItems; @@ -252,7 +251,7 @@ public class GetAuditCoreTests extends AuditTest } } - @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if retrieving an audit entry for an audit application is only for admin user, with and without the include=values paramater and status code is 200") public void getAuditEntry() throws Exception @@ -285,7 +284,7 @@ public class GetAuditCoreTests extends AuditTest assertNotNull(restAuditEntryModel.getValues()); } - @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if the admin user gets a list of audit entries for node id nodeId using 'where' and 'maxItems' param and status code is 200") public void getAuditEntriesForNodeUsingMaxItemsAndWhereParam() throws Exception @@ -331,7 +330,7 @@ public class GetAuditCoreTests extends AuditTest } } - @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if user with permissions can get a list of audit entries for node and status code is 200") public void getAuditEntriesForNodeUsingUserWithPermissions() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/audit/PutAuditCoreTests.java b/e2e-test/java/org/alfresco/rest/audit/PutAuditTests.java similarity index 91% rename from e2e-test/java/org/alfresco/rest/audit/PutAuditCoreTests.java rename to e2e-test/java/org/alfresco/rest/audit/PutAuditTests.java index 10e051c1f..fa4067721 100644 --- a/e2e-test/java/org/alfresco/rest/audit/PutAuditCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/audit/PutAuditTests.java @@ -6,12 +6,12 @@ import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; import org.testng.annotations.Test; -public class PutAuditCoreTests extends AuditTest +public class PutAuditTests extends AuditTest { - @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, - TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify that the admin user can enable/disable sync application auditing") + TestGroup.AUDIT }, executionType = ExecutionType.REGRESSION, description = "Verify that the admin user can enable/disable sync application auditing") public void enableDisableSyncApplicationAuditingAsAdminUser() throws Exception { // disable sync audit app @@ -37,7 +37,7 @@ public class PutAuditCoreTests extends AuditTest } - @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify that the admin user can enable/disable tagging application auditing") public void enableDisableTaggingApplicationAuditingAsAdminUser() throws Exception @@ -65,9 +65,9 @@ public class PutAuditCoreTests extends AuditTest } - @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, - TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify that the normal user can't enable/disable sync application auditing") + TestGroup.AUDIT }, executionType = ExecutionType.REGRESSION, description = "Verify that the normal user can't enable/disable sync application auditing") public void enableDisableSyncApplicationAuditingAsNormalUser() throws Exception { // disable sync audit app @@ -86,7 +86,7 @@ public class PutAuditCoreTests extends AuditTest restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); } - @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify that the normal user can't enable/disable tagging application auditing") public void enableDisableTaggingApplicationAuditingAsNormalUser() throws Exception From c3877ae98b619911fc6de83c3e961858b00e35a4 Mon Sep 17 00:00:00 2001 From: cagache Date: Fri, 6 Oct 2017 17:02:30 +0300 Subject: [PATCH 1233/1491] REPO-2755 / REPO-2251: changed CORE and FULL groups with REGRESSION in tags package --- .../alfresco/rest/tags/GetTagCoreTests.java | 73 ---- .../alfresco/rest/tags/GetTagFullTests.java | 92 ----- ...etTagSanityTests.java => GetTagTests.java} | 123 +++++-- .../alfresco/rest/tags/GetTagsCoreTests.java | 90 ----- .../alfresco/rest/tags/GetTagsFullTests.java | 148 -------- .../rest/tags/GetTagsSanityTests.java | 125 ------- .../org/alfresco/rest/tags/GetTagsTests.java | 270 ++++++++++++++ .../rest/tags/UpdateTagCoreTests.java | 112 ------ .../rest/tags/UpdateTagFullTests.java | 144 -------- .../rest/tags/UpdateTagSanityTests.java | 120 ------ .../alfresco/rest/tags/UpdateTagTests.java | 279 ++++++++++++++ .../rest/tags/nodes/AddTagCoreTests.java | 157 -------- .../rest/tags/nodes/AddTagFullTests.java | 175 --------- .../rest/tags/nodes/AddTagSanityTests.java | 134 ------- .../alfresco/rest/tags/nodes/AddTagTests.java | 343 ++++++++++++++++++ ...TagsSanityTests.java => AddTagsTests.java} | 57 ++- .../rest/tags/nodes/DeleteTagCoreTests.java | 124 ------- .../rest/tags/nodes/DeleteTagFullTests.java | 121 ------ .../rest/tags/nodes/DeleteTagSanityTests.java | 136 ------- .../rest/tags/nodes/DeleteTagTests.java | 288 +++++++++++++++ .../rest/tags/nodes/GetNodeTagsCoreTests.java | 136 ------- .../rest/tags/nodes/GetNodeTagsFullTests.java | 192 ---------- .../tags/nodes/GetNodeTagsSanityTests.java | 131 ------- .../rest/tags/nodes/GetNodeTagsTests.java | 339 +++++++++++++++++ 24 files changed, 1633 insertions(+), 2276 deletions(-) delete mode 100644 e2e-test/java/org/alfresco/rest/tags/GetTagCoreTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/tags/GetTagFullTests.java rename e2e-test/java/org/alfresco/rest/tags/{GetTagSanityTests.java => GetTagTests.java} (52%) delete mode 100644 e2e-test/java/org/alfresco/rest/tags/GetTagsCoreTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/tags/GetTagsFullTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java create mode 100644 e2e-test/java/org/alfresco/rest/tags/GetTagsTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/tags/UpdateTagCoreTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/tags/UpdateTagFullTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java create mode 100644 e2e-test/java/org/alfresco/rest/tags/UpdateTagTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/tags/nodes/AddTagCoreTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/tags/nodes/AddTagFullTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/tags/nodes/AddTagSanityTests.java create mode 100644 e2e-test/java/org/alfresco/rest/tags/nodes/AddTagTests.java rename e2e-test/java/org/alfresco/rest/tags/nodes/{AddTagsSanityTests.java => AddTagsTests.java} (68%) delete mode 100644 e2e-test/java/org/alfresco/rest/tags/nodes/DeleteTagCoreTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/tags/nodes/DeleteTagFullTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/tags/nodes/DeleteTagSanityTests.java create mode 100644 e2e-test/java/org/alfresco/rest/tags/nodes/DeleteTagTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/tags/nodes/GetNodeTagsCoreTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/tags/nodes/GetNodeTagsFullTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/tags/nodes/GetNodeTagsSanityTests.java create mode 100644 e2e-test/java/org/alfresco/rest/tags/nodes/GetNodeTagsTests.java diff --git a/e2e-test/java/org/alfresco/rest/tags/GetTagCoreTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagCoreTests.java deleted file mode 100644 index dc1b8c62f..000000000 --- a/e2e-test/java/org/alfresco/rest/tags/GetTagCoreTests.java +++ /dev/null @@ -1,73 +0,0 @@ -package org.alfresco.rest.tags; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestTagModel; -import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -public class GetTagCoreTests extends RestTest -{ - private UserModel adminUserModel; - private SiteModel siteModel; - private FileModel document; - private String tagValue; - private RestTagModel tag; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - } - - @BeforeMethod(alwaysRun = true) - public void setUp() throws Exception { - tagValue = RandomData.getRandomName("tag"); - restClient.authenticateUser(adminUserModel); - tag = restClient.withCoreAPI().usingResource(document).addTag(tagValue); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that if tag id is invalid status code returned is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) - public void invalidTagIdTest() throws JsonToModelConversionException, Exception - { - tag.setId("random_tag_value"); - restClient.withCoreAPI().getTag(tag); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "random_tag_value")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Retrieve and validate the id of a tag added to a file") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) - public void validateTagIdTest() throws JsonToModelConversionException, Exception - { - RestTagModel returnedTag = restClient.withCoreAPI().getTag(tag); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedTag.assertThat().field("id").is(tag.getId()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Retrieve and validate the name of a tag added to a file") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) - public void validateTagNameTest() throws JsonToModelConversionException, Exception - { - RestTagModel returnedTag = restClient.withCoreAPI().getTag(tag); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedTag.assertThat().field("tag").is(tagValue.toLowerCase()); - } - -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/tags/GetTagFullTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagFullTests.java deleted file mode 100644 index f16116f0d..000000000 --- a/e2e-test/java/org/alfresco/rest/tags/GetTagFullTests.java +++ /dev/null @@ -1,92 +0,0 @@ -package org.alfresco.rest.tags; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestTagModel; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class GetTagFullTests extends RestTest -{ - private UserModel adminUserModel; - private SiteModel siteModel; - private ListUserWithRoles usersWithRoles; - private FileModel document; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - restClient.authenticateUser(adminUserModel); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, - executionType = ExecutionType.REGRESSION, description = "Check that properties filter is applied when getting tag using Manager user.") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) - public void checkPropertiesFilterIsApplied() throws JsonToModelConversionException, Exception - { - String tagValue = RandomData.getRandomName("tag"); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(tagValue); - - RestTagModel returnedTag = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withParams("properties=id,tag").withCoreAPI().getTag(tag); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedTag.assertThat().field("id").is(tag.getId()) - .assertThat().field("tag").is(tag.getTag().toLowerCase()) - .assertThat().fieldsCount().is(2); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, - executionType = ExecutionType.REGRESSION, description = "Check that Manager user can get tag of a folder.") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) - public void getTagOfAFolder() throws JsonToModelConversionException, Exception - { - String tagValue = RandomData.getRandomName("tagFolder"); - FolderModel folder = dataContent.usingAdmin().usingSite(siteModel).createFolder(); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - RestTagModel tag = restClient.withCoreAPI().usingResource(folder).addTag(tagValue); - - RestTagModel returnedTag = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().getTag(tag); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedTag.assertThat().field("tag").is(tagValue.toLowerCase()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, - executionType = ExecutionType.REGRESSION, description = "Check default error model schema. Use invalid skipCount parameter.") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) - public void checkDefaultErrorModelSchema() throws JsonToModelConversionException, Exception - { - String tagValue = RandomData.getRandomName("tag"); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(tagValue); - - restClient.withParams("skipCount=abc").withCoreAPI().getTag(tag); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(String.format(RestErrorModel.INVALID_SKIPCOUNT, "abc")) - .containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "abc")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/tags/GetTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagTests.java similarity index 52% rename from e2e-test/java/org/alfresco/rest/tags/GetTagSanityTests.java rename to e2e-test/java/org/alfresco/rest/tags/GetTagTests.java index 72dd369cd..19121b3cf 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetTagTests.java @@ -8,23 +8,23 @@ import org.alfresco.rest.model.RestTagModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.model.*; import org.alfresco.utility.report.Bug; 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.BeforeMethod; import org.testng.annotations.Test; -public class GetTagSanityTests extends RestTest +public class GetTagTests extends RestTest { private UserModel adminUserModel; private SiteModel siteModel; private ListUserWithRoles usersWithRoles; private FileModel document; + private String tagValue; + private RestTagModel tag; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception @@ -36,25 +36,26 @@ public class GetTagSanityTests extends RestTest UserRole.SiteContributor); document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); } - - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify admin user gets tag using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) - public void userWithAdminIsAbletoGetTag() throws JsonToModelConversionException, Exception - { - String tagValue = RandomData.getRandomName("tag"); + + @BeforeMethod(alwaysRun = true) + public void setUp() throws Exception { + tagValue = RandomData.getRandomName("tag"); restClient.authenticateUser(adminUserModel); - RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(tagValue); - - RestTagModel returnedTag = restClient.withCoreAPI().getTag(tag); + tag = restClient.withCoreAPI().usingResource(document).addTag(tagValue); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify admin user gets tag using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void adminIsAbleToGetTag() throws Exception + { + RestTagModel returnedTag = restClient.authenticateUser(adminUserModel).withCoreAPI().getTag(tag); restClient.assertStatusCodeIs(HttpStatus.OK); returnedTag.assertThat().field("tag").is(tagValue.toLowerCase()); } - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role gets tag using REST API and status code is OK (200)") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) - public void userWithManagerRoleIsAbletoGetTag() throws JsonToModelConversionException, Exception + public void userWithManagerRoleIsAbleToGetTag() throws Exception { String tagValue = RandomData.getRandomName("tag"); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); @@ -62,12 +63,13 @@ public class GetTagSanityTests extends RestTest RestTagModel returnedTag = restClient.withCoreAPI().getTag(tag); restClient.assertStatusCodeIs(HttpStatus.OK); - returnedTag.assertThat().field("tag").is(tagValue.toLowerCase()); + returnedTag.assertThat().field("tag").is(tagValue.toLowerCase()) + .assertThat().field("id").is(tag.getId()); } - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user with Collaborator role gets tag using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) - public void userWithCollaboratorRoleIsAbletoGetTag() throws JsonToModelConversionException, Exception + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify user with Collaborator role gets tag using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void userWithCollaboratorRoleIsAbleToGetTag() throws Exception { String tagValue = RandomData.getRandomName("tag"); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); @@ -78,9 +80,9 @@ public class GetTagSanityTests extends RestTest returnedTag.assertThat().field("tag").is(tagValue.toLowerCase()); } - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user with Contributor role gets tag using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) - public void userWithContributorRoleIsAbletoGetTag() throws JsonToModelConversionException, Exception + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify user with Contributor role gets tag using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void userWithContributorRoleIsAbleToGetTag() throws Exception { String tagValue = RandomData.getRandomName("tag"); restClient.authenticateUser(adminUserModel); @@ -92,10 +94,9 @@ public class GetTagSanityTests extends RestTest returnedTag.assertThat().field("tag").is(tagValue.toLowerCase()); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role gets tag using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) - public void userWithConsumerRoleIsAbletoGetTag() throws JsonToModelConversionException, Exception + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify user with Consumer role gets tag using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void userWithConsumerRoleIsAbleToGetTag() throws Exception { String tagValue = RandomData.getRandomName("tag"); restClient.authenticateUser(adminUserModel); @@ -109,20 +110,68 @@ public class GetTagSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Manager user gets status code 401 if authentication call fails") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) - @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void managerIsNotAbleToGetTagIfAuthenticationFails() throws JsonToModelConversionException, Exception +// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") + public void managerIsNotAbleToGetTagIfAuthenticationFails() throws Exception { - String tagValue = RandomData.getRandomName("tag"); UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); dataUser.addUserToSite(managerUser, siteModel, UserRole.SiteManager); - restClient.authenticateUser(managerUser); - RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(tagValue); - managerUser.setPassword("wrongPassword"); - restClient.authenticateUser(managerUser); - restClient.withCoreAPI().getTag(tag); + restClient.authenticateUser(managerUser).withCoreAPI().getTag(tag); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } - + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that if tag id is invalid status code returned is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void invalidTagIdTest() throws Exception + { + tag.setId("random_tag_value"); + restClient.withCoreAPI().getTag(tag); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "random_tag_value")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, + executionType = ExecutionType.REGRESSION, description = "Check that properties filter is applied when getting tag using Manager user.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void checkPropertiesFilterIsApplied() throws Exception + { + RestTagModel returnedTag = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withParams("properties=id,tag").withCoreAPI().getTag(tag); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedTag.assertThat().field("id").is(tag.getId()) + .assertThat().field("tag").is(tag.getTag().toLowerCase()) + .assertThat().fieldsCount().is(2); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, + executionType = ExecutionType.REGRESSION, description = "Check that Manager user can get tag of a folder.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void getTagOfAFolder() throws Exception + { + String tagValue = RandomData.getRandomName("tagFolder"); + FolderModel folder = dataContent.usingAdmin().usingSite(siteModel).createFolder(); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + RestTagModel tag = restClient.withCoreAPI().usingResource(folder).addTag(tagValue); + + RestTagModel returnedTag = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().getTag(tag); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedTag.assertThat().field("tag").is(tagValue.toLowerCase()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, + executionType = ExecutionType.REGRESSION, description = "Check default error model schema. Use invalid skipCount parameter.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void checkDefaultErrorModelSchema() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withParams("skipCount=abc").withCoreAPI().getTag(tag); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(String.format(RestErrorModel.INVALID_SKIPCOUNT, "abc")) + .containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "abc")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/tags/GetTagsCoreTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagsCoreTests.java deleted file mode 100644 index 54c119230..000000000 --- a/e2e-test/java/org/alfresco/rest/tags/GetTagsCoreTests.java +++ /dev/null @@ -1,90 +0,0 @@ -package org.alfresco.rest.tags; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestTagModelsCollection; -import org.alfresco.utility.Utility; -import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class GetTagsCoreTests extends RestTest -{ - private UserModel adminUserModel; - private SiteModel siteModel; - - private String tagValue; - private String tagValue2; - private FileModel document; - private RestTagModelsCollection returnedCollection; - private FolderModel folder; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - restClient.authenticateUser(adminUserModel); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - document = dataContent.usingUser(adminUserModel).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - folder = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); - - tagValue = RandomData.getRandomName("tag"); - tagValue2 = RandomData.getRandomName("tag"); - restClient.withCoreAPI().usingResource(document).addTags(tagValue); - restClient.withCoreAPI().usingResource(folder).addTags(tagValue2); - - Utility.waitToLoopTime(60); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that if maxItems is invalid status code returned is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) - public void maxItemsInvalidValueTest() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel).withParams("maxItems=abc").withCoreAPI().getTags(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "abc")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that if skipCount is invalid status code returned is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) - public void skipCountInvalidValueTest() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel).withParams("skipCount=abc").withCoreAPI().getTags(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "abc")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that file tag is retrieved") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) - public void fileTagIsRetrieved() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel); - returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat().entriesListIsNotEmpty() - .and().entriesListContains("tag", tagValue.toLowerCase()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that folder tag is retrieved") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) - public void folderTagIsRetrieved() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel); - returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat().entriesListIsNotEmpty() - .and().entriesListContains("tag", tagValue2.toLowerCase()); - } -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/tags/GetTagsFullTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagsFullTests.java deleted file mode 100644 index 470bddcec..000000000 --- a/e2e-test/java/org/alfresco/rest/tags/GetTagsFullTests.java +++ /dev/null @@ -1,148 +0,0 @@ -package org.alfresco.rest.tags; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestTagModel; -import org.alfresco.rest.model.RestTagModelsCollection; -import org.alfresco.utility.Utility; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class GetTagsFullTests extends RestTest -{ - private UserModel adminUserModel; - private SiteModel siteModel; - private ListUserWithRoles usersWithRoles; - private RestTagModelsCollection returnedCollection; - - private String tagValue, tagValue2; - private FileModel document; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - restClient.authenticateUser(adminUserModel); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); - document = dataContent.usingUser(adminUserModel).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - - tagValue = RandomData.getRandomName("tag"); - tagValue2 = RandomData.getRandomName("tag"); - restClient.withCoreAPI().usingResource(document).addTags(tagValue, tagValue2); - - Utility.waitToLoopTime(20); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify site Manager is able to get tags using properties parameter." - + "Check that properties filter is applied.") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) - public void siteManagerIsAbleToRetrieveTagsWithPropertiesParameter() throws JsonToModelConversionException, Exception - { - returnedCollection = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withParams("maxItems=5000&properties=tag").withCoreAPI().getTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat().entriesListIsNotEmpty() - .and().entriesListContains("tag", tagValue.toLowerCase()) - .and().entriesListContains("tag", tagValue2.toLowerCase()) - .and().entriesListDoesNotContain("id"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "With admin get tags and use skipCount parameter. Check pagination") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) - public void useSkipCountCheckPagination() throws JsonToModelConversionException, Exception - { - returnedCollection = restClient.authenticateUser(adminUserModel).withCoreAPI().getTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - RestTagModel firstTag = returnedCollection.getEntries().get(0).onModel(); - RestTagModel secondTag = returnedCollection.getEntries().get(1).onModel(); - RestTagModelsCollection tagsWithSkipCount = restClient.withParams("skipCount=2").withCoreAPI().getTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - tagsWithSkipCount.assertThat().entriesListDoesNotContain("tag", firstTag.getTag()) - .assertThat().entriesListDoesNotContain("tag", secondTag.getTag()); - tagsWithSkipCount.assertThat().paginationField("skipCount").is("2"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "With admin get tags and use maxItems parameter. Check pagination") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) - public void useMaxItemsParameterCheckPagination() throws JsonToModelConversionException, Exception - { - returnedCollection = restClient.authenticateUser(adminUserModel).withCoreAPI().getTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - RestTagModel firstTag = returnedCollection.getEntries().get(0).onModel(); - RestTagModel secondTag = returnedCollection.getEntries().get(1).onModel(); - RestTagModelsCollection tagsWithMaxItems = restClient.withParams("maxItems=2").withCoreAPI().getTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - tagsWithMaxItems.assertThat().entriesListContains("tag", firstTag.getTag()) - .assertThat().entriesListContains("tag", secondTag.getTag()) - .assertThat().entriesListCountIs(2); - tagsWithMaxItems.assertThat().paginationField("maxItems").is("2"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "With manager get tags and use high skipCount parameter. Check pagination") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) - public void useHighSkipCountCheckPagination() throws JsonToModelConversionException, Exception - { - returnedCollection = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withParams("skipCount=20000").withCoreAPI().getTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat().entriesListIsEmpty() - .getPagination().assertThat().field("maxItems").is(100) - .and().field("hasMoreItems").is("false") - .and().field("count").is("0") - .and().field("skipCount").is(20000) - .and().field("totalItems").isNull(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "With Collaborator user get tags and use maxItems with value zero. Check default error model schema") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) - public void useMaxItemsWithValueZeroCheckDefaultErrorModelSchema() throws JsonToModelConversionException, Exception - { - returnedCollection = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withParams("maxItems=0").withCoreAPI().getTags(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) - .containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "With Manager user delete tag. Check it is not retrieved anymore.") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) - public void checkThatDeletedTagIsNotRetrievedAnymore() throws JsonToModelConversionException, Exception - { - String removedTag = RandomData.getRandomName("tag3"); - - RestTagModel deletedTag = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(document).addTag(removedTag); - - restClient.withCoreAPI().usingResource(document).deleteTag(deletedTag); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); - returnedCollection.assertThat().entriesListIsNotEmpty() - .and().entriesListDoesNotContain("tag", removedTag.toLowerCase()); - } -} diff --git a/e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java deleted file mode 100644 index 40234c816..000000000 --- a/e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java +++ /dev/null @@ -1,125 +0,0 @@ -package org.alfresco.rest.tags; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestTagModelsCollection; -import org.alfresco.utility.Utility; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class GetTagsSanityTests extends RestTest -{ - private UserModel adminUserModel; - private UserModel userModel; - private SiteModel siteModel; - private ListUserWithRoles usersWithRoles; - - private String tagValue; - private String tagValue2; - private FileModel document; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - restClient.authenticateUser(adminUserModel); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); - document = dataContent.usingUser(adminUserModel).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - - tagValue = RandomData.getRandomName("tag"); - tagValue2 = RandomData.getRandomName("tag"); - restClient.withCoreAPI().usingResource(document).addTags(tagValue, tagValue2); - - Utility.waitToLoopTime(60); - } - - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role gets tags using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) - public void getTagsWithManagerRole() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - RestTagModelsCollection returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat().entriesListIsNotEmpty() - .and().entriesListContains("tag", tagValue.toLowerCase()) - .and().entriesListContains("tag", tagValue2.toLowerCase()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user with Collaborator role gets tags using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) - public void getTagsWithCollaboratorRole() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - RestTagModelsCollection returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat().entriesListIsNotEmpty() - .and().entriesListContains("tag", tagValue.toLowerCase()) - .and().entriesListContains("tag", tagValue2.toLowerCase()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user with Contributor role gets tags using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) - public void getTagsWithContributorRole() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - RestTagModelsCollection returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat().entriesListIsNotEmpty() - .and().entriesListContains("tag", tagValue.toLowerCase()) - .and().entriesListContains("tag", tagValue2.toLowerCase()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role gets tags using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) - public void getTagsWithConsumerRole() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - RestTagModelsCollection returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat().entriesListIsNotEmpty() - .and().entriesListContains("tag", tagValue.toLowerCase()) - .and().entriesListContains("tag", tagValue2.toLowerCase()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets tags using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) - public void getTagsWithAdminUser() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel); - RestTagModelsCollection returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat().entriesListIsNotEmpty() - .and().entriesListContains("tag", tagValue.toLowerCase()) - .and().entriesListContains("tag", tagValue2.toLowerCase()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Failed authentication get tags call returns status code 401 with Manager role") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) - @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void failedAuthenticationReturnsUnauthorizedStatus() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - userModel = dataUser.createRandomTestUser(); - userModel.setPassword("user wrong password"); - dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); - restClient.authenticateUser(userModel); - restClient.withCoreAPI().getTags(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } -} diff --git a/e2e-test/java/org/alfresco/rest/tags/GetTagsTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagsTests.java new file mode 100644 index 000000000..2882b9ba1 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/tags/GetTagsTests.java @@ -0,0 +1,270 @@ +package org.alfresco.rest.tags; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestTagModel; +import org.alfresco.rest.model.RestTagModelsCollection; +import org.alfresco.utility.Utility; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.data.RandomData; +import org.alfresco.utility.model.*; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class GetTagsTests extends RestTest +{ + private UserModel adminUserModel; + private UserModel userModel; + private SiteModel siteModel; + private ListUserWithRoles usersWithRoles; + private RestTagModelsCollection returnedCollection; + + private String tagValue; + private String tagValue2; + private String tagValue3; + private FileModel document; + private FolderModel folder; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + restClient.authenticateUser(adminUserModel); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + document = dataContent.usingUser(adminUserModel).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + folder = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); + + tagValue = RandomData.getRandomName("tag"); + tagValue2 = RandomData.getRandomName("tag"); + tagValue3 = RandomData.getRandomName("tag"); + restClient.withCoreAPI().usingResource(document).addTags(tagValue, tagValue2); + restClient.withCoreAPI().usingResource(folder).addTags(tagValue3); + + Utility.waitToLoopTime(60); + } + + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role gets tags using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) + public void getTagsWithManagerRole() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat().entriesListIsNotEmpty() + .and().entriesListContains("tag", tagValue.toLowerCase()) + .and().entriesListContains("tag", tagValue2.toLowerCase()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify user with Collaborator role gets tags using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void getTagsWithCollaboratorRole() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat().entriesListIsNotEmpty() + .and().entriesListContains("tag", tagValue.toLowerCase()) + .and().entriesListContains("tag", tagValue2.toLowerCase()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify user with Contributor role gets tags using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void getTagsWithContributorRole() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat().entriesListIsNotEmpty() + .and().entriesListContains("tag", tagValue.toLowerCase()) + .and().entriesListContains("tag", tagValue2.toLowerCase()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify user with Consumer role gets tags using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void getTagsWithConsumerRole() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat().entriesListIsNotEmpty() + .and().entriesListContains("tag", tagValue.toLowerCase()) + .and().entriesListContains("tag", tagValue2.toLowerCase()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify Admin user gets tags using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void getTagsWithAdminUser() throws Exception + { + restClient.authenticateUser(adminUserModel); + returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat().entriesListIsNotEmpty() + .and().entriesListContains("tag", tagValue.toLowerCase()) + .and().entriesListContains("tag", tagValue2.toLowerCase()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Failed authentication get tags call returns status code 401 with Manager role") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) +// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") + public void failedAuthenticationReturnsUnauthorizedStatus() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + userModel = dataUser.createRandomTestUser(); + userModel.setPassword("user wrong password"); + dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); + restClient.authenticateUser(userModel); + restClient.withCoreAPI().getTags(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that if maxItems is invalid status code returned is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION}) + public void maxItemsInvalidValueTest() throws Exception + { + restClient.authenticateUser(adminUserModel).withParams("maxItems=abc").withCoreAPI().getTags(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "abc")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that if skipCount is invalid status code returned is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION}) + public void skipCountInvalidValueTest() throws Exception + { + restClient.authenticateUser(adminUserModel).withParams("skipCount=abc").withCoreAPI().getTags(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "abc")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that file tag is retrieved") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION}) + public void fileTagIsRetrieved() throws Exception + { + restClient.authenticateUser(adminUserModel); + returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat().entriesListIsNotEmpty() + .and().entriesListContains("tag", tagValue.toLowerCase()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that folder tag is retrieved") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION}) + public void folderTagIsRetrieved() throws Exception + { + restClient.authenticateUser(adminUserModel); + returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat().entriesListIsNotEmpty() + .and().entriesListContains("tag", tagValue3.toLowerCase()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify site Manager is able to get tags using properties parameter." + + "Check that properties filter is applied.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void siteManagerIsAbleToRetrieveTagsWithPropertiesParameter() throws Exception + { + returnedCollection = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withParams("maxItems=5000&properties=tag").withCoreAPI().getTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat().entriesListIsNotEmpty() + .and().entriesListContains("tag", tagValue.toLowerCase()) + .and().entriesListContains("tag", tagValue2.toLowerCase()) + .and().entriesListDoesNotContain("id"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "With admin get tags and use skipCount parameter. Check pagination") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void useSkipCountCheckPagination() throws Exception + { + returnedCollection = restClient.authenticateUser(adminUserModel).withCoreAPI().getTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + RestTagModel firstTag = returnedCollection.getEntries().get(0).onModel(); + RestTagModel secondTag = returnedCollection.getEntries().get(1).onModel(); + RestTagModelsCollection tagsWithSkipCount = restClient.withParams("skipCount=2").withCoreAPI().getTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + tagsWithSkipCount.assertThat().entriesListDoesNotContain("tag", firstTag.getTag()) + .assertThat().entriesListDoesNotContain("tag", secondTag.getTag()); + tagsWithSkipCount.assertThat().paginationField("skipCount").is("2"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "With admin get tags and use maxItems parameter. Check pagination") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void useMaxItemsParameterCheckPagination() throws Exception + { + returnedCollection = restClient.authenticateUser(adminUserModel).withCoreAPI().getTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + RestTagModel firstTag = returnedCollection.getEntries().get(0).onModel(); + RestTagModel secondTag = returnedCollection.getEntries().get(1).onModel(); + RestTagModelsCollection tagsWithMaxItems = restClient.withParams("maxItems=2").withCoreAPI().getTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + tagsWithMaxItems.assertThat().entriesListContains("tag", firstTag.getTag()) + .assertThat().entriesListContains("tag", secondTag.getTag()) + .assertThat().entriesListCountIs(2); + tagsWithMaxItems.assertThat().paginationField("maxItems").is("2"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "With manager get tags and use high skipCount parameter. Check pagination") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void useHighSkipCountCheckPagination() throws Exception + { + returnedCollection = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withParams("skipCount=20000").withCoreAPI().getTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat().entriesListIsEmpty() + .getPagination().assertThat().field("maxItems").is(100) + .and().field("hasMoreItems").is("false") + .and().field("count").is("0") + .and().field("skipCount").is(20000) + .and().field("totalItems").isNull(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "With Collaborator user get tags and use maxItems with value zero. Check default error model schema") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void useMaxItemsWithValueZeroCheckDefaultErrorModelSchema() throws Exception + { + returnedCollection = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withParams("maxItems=0").withCoreAPI().getTags(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) + .containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "With Manager user delete tag. Check it is not retrieved anymore.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void checkThatDeletedTagIsNotRetrievedAnymore() throws Exception + { + String removedTag = RandomData.getRandomName("tag3"); + + RestTagModel deletedTag = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(document).addTag(removedTag); + + restClient.withCoreAPI().usingResource(document).deleteTag(deletedTag); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); + returnedCollection.assertThat().entriesListIsNotEmpty() + .and().entriesListDoesNotContain("tag", removedTag.toLowerCase()); + } +} diff --git a/e2e-test/java/org/alfresco/rest/tags/UpdateTagCoreTests.java b/e2e-test/java/org/alfresco/rest/tags/UpdateTagCoreTests.java deleted file mode 100644 index 4904972e6..000000000 --- a/e2e-test/java/org/alfresco/rest/tags/UpdateTagCoreTests.java +++ /dev/null @@ -1,112 +0,0 @@ -package org.alfresco.rest.tags; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestTagModel; -import org.alfresco.utility.Utility; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser; -import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Created by Bogdan Bocancea - */ -public class UpdateTagCoreTests extends RestTest -{ - private UserModel managerUser; - private FileModel document; - private SiteModel siteModel; - @SuppressWarnings("unused") - private DataUser.ListUserWithRoles usersWithRoles; - @SuppressWarnings("unused") - private RestTagModel oldTag; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - managerUser = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(managerUser).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).usingUser(managerUser).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); - - oldTag = restClient.authenticateUser(managerUser).withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("old")); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify site manager is not able to update tag with invalid id") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) - public void managerIsNotAbleToUpdateTagWithInvalidId() throws JsonToModelConversionException, Exception - { - String invalidTagId = "invalid-id"; - RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); - tag.setId(invalidTagId); - restClient.withCoreAPI().usingTag(tag).update(RandomData.getRandomName("tag")); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, invalidTagId)); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify site manager is not able to update tag with empty id") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) - public void managerIsNotAbleToUpdateTagWithEmptyId() throws JsonToModelConversionException, Exception - { - RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); - tag.setId(""); - restClient.withCoreAPI().usingTag(tag).update(RandomData.getRandomName("tag")); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) - .assertLastError().containsSummary(RestErrorModel.PUT_EMPTY_ARGUMENT); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify site manager is not able to update tag with invalid body") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) - public void managerIsNotAbleToUpdateTagWithEmptyBody() throws JsonToModelConversionException, Exception - { - RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); - restClient.withCoreAPI().usingTag(tag).update(""); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(RestErrorModel.EMPTY_TAG); - } - - @Bug(id="ACE-5629") - @TestRail(section = { TestGroup.REST_API, - TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify site manager is not able to update tag with invalid body containing '|' symbol") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) - public void managerIsNotAbleToUpdateTagWithInvalidBodyScenario1() throws JsonToModelConversionException, Exception - { - String invalidTagBody = "|.\"/<>*"; - RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); - Utility.waitToLoopTime(20); - restClient.withCoreAPI().usingTag(tag).update(invalidTagBody); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_TAG, invalidTagBody)); - } - - @Bug(id="ACE-5629") - @TestRail(section = { TestGroup.REST_API, - TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify site manager is not able to update tag with invalid body without '|' symbol") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) - public void managerIsNotAbleToUpdateTagWithInvalidBodyScenario2() throws JsonToModelConversionException, Exception - { - String invalidTagBody = ".\"/<>*"; - RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); - Utility.waitToLoopTime(20); - restClient.withCoreAPI().usingTag(tag).update(invalidTagBody); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_TAG, invalidTagBody)); - } -} diff --git a/e2e-test/java/org/alfresco/rest/tags/UpdateTagFullTests.java b/e2e-test/java/org/alfresco/rest/tags/UpdateTagFullTests.java deleted file mode 100644 index d8dcb0066..000000000 --- a/e2e-test/java/org/alfresco/rest/tags/UpdateTagFullTests.java +++ /dev/null @@ -1,144 +0,0 @@ -package org.alfresco.rest.tags; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestTagModel; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser; -import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.apache.commons.lang.RandomStringUtils; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -public class UpdateTagFullTests extends RestTest -{ - private UserModel adminUserModel; - private FileModel document; - private SiteModel siteModel; - private RestTagModel oldTag; - private DataUser.ListUserWithRoles usersWithRoles; - private RestTagModel returnedModel; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); - } - - @BeforeMethod(alwaysRun=true) - public void addTagToDocument() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - oldTag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("old")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify Manager user can provide large string for new tag value.") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) - @Bug(id="REPO-1828") - public void managerIsAbleToUpdateTagsProvideLargeStringTag() throws JsonToModelConversionException, Exception - { - String largeStringTag = RandomStringUtils.randomAlphanumeric(10000); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - returnedModel = restClient.withCoreAPI().usingTag(oldTag).update(largeStringTag); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedModel.assertThat().field("tag").is(largeStringTag); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify Manager user can provide short string for new tag value.") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) - @Bug(id="REPO-1828") - public void managerIsAbleToUpdateTagsProvideShortStringTag() throws JsonToModelConversionException, Exception - { - String shortStringTag = RandomStringUtils.randomAlphanumeric(2); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - returnedModel = restClient.withCoreAPI().usingTag(oldTag).update(shortStringTag); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedModel.assertThat().field("tag").is(shortStringTag); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify Manager user can provide string with special chars for new tag value.") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) - @Bug(id="REPO-1828") - public void managerIsAbleToUpdateTagsProvideSpecialCharsStringTag() throws JsonToModelConversionException, Exception - { - String specialCharsString = "!@#$%^&*()'\".,<>-_+=|\\"; - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - returnedModel = restClient.withCoreAPI().usingTag(oldTag).update(specialCharsString); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedModel.assertThat().field("tag").is(specialCharsString); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify Admin user can provide existing tag for new tag value.") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) - @Bug(id="REPO-1828") - public void adminIsAbleToUpdateTagsProvideExistingTag() throws JsonToModelConversionException, Exception - { - String existingTag = "oldTag"; - RestTagModel oldExistingTag = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(document).addTag(existingTag); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(adminUserModel); - returnedModel = restClient.withCoreAPI().usingTag(oldExistingTag).update(existingTag); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedModel.assertThat().field("tag").is(existingTag); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify Admin user can delete a tag, add tag and update it.") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) - @Bug(id="REPO-1828") - public void withAdminDeleteTagAddTagUpdateTag() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingResource(document).deleteTag(oldTag); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - String newTag = "addTag"; - RestTagModel newTagModel = restClient.withCoreAPI().usingResource(document).addTag(newTag); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedModel = restClient.withCoreAPI().usingTag(newTagModel).update(newTag); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedModel.assertThat().field("tag").is(newTag); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify Admin user can update a tag, delete tag and add it.") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) - @Bug(id="REPO-1828") - public void withAdminUpdateTagDeleteTagAddTag() throws JsonToModelConversionException, Exception - { - String newTag = "addTag"; - - returnedModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingTag(oldTag).update(newTag); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedModel.assertThat().field("tag").is(newTag); - - restClient.withCoreAPI().usingResource(document).deleteTag(returnedModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingResource(document).addTag(newTag); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - } -} diff --git a/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java deleted file mode 100644 index 3361d9a54..000000000 --- a/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java +++ /dev/null @@ -1,120 +0,0 @@ -package org.alfresco.rest.tags; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestTagModel; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser; -import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -/** - * Created by Claudia Agache on 10/4/2016. - */ -public class UpdateTagSanityTests extends RestTest -{ - private UserModel adminUserModel; - private FileModel document; - private SiteModel siteModel; - private RestTagModel oldTag; - private DataUser.ListUserWithRoles usersWithRoles; - private String randomTag = ""; - private RestTagModel returnedModel; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); - } - - @BeforeMethod(alwaysRun=true) - public void addTagToDocument() throws Exception - { - restClient.authenticateUser(adminUserModel); - oldTag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("old")); - randomTag = RandomData.getRandomName("tag"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Admin user updates tags and status code is 200") - @Bug(id="REPO-1828") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) - public void adminIsAbleToUpdateTags() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel); - returnedModel = restClient.withCoreAPI().usingTag(oldTag).update(randomTag); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedModel.assertThat().field("tag").is(randomTag); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Manager user can't update tags with Rest API and status code is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS }) - public void managerIsNotAbleToUpdateTag() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingTag(oldTag).update(randomTag); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user can't update tags with Rest API and status code is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS }) - public void collaboratorIsNotAbleToUpdateTagCheckDefaultErrorModelSchema() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.withCoreAPI().usingTag(oldTag).update(randomTag); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Contributor user can't update tags with Rest API and status code is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS }) - public void contributorIsNotAbleToUpdateTag() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - restClient.withCoreAPI().usingTag(oldTag).update(randomTag); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Consumer user can't update tags with Rest API and status code is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS }) - public void consumerIsNotAbleToUpdateTag() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.withCoreAPI().usingTag(oldTag).update(randomTag); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user gets status code 401 if authentication call fails") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) - @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void userIsNotAbleToUpdateTagIfAuthenticationFails() throws JsonToModelConversionException, Exception - { - UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); - siteManager.setPassword("wrongPassword"); - restClient.authenticateUser(siteManager); - restClient.withCoreAPI().usingTag(oldTag).update(randomTag); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/tags/UpdateTagTests.java b/e2e-test/java/org/alfresco/rest/tags/UpdateTagTests.java new file mode 100644 index 000000000..cd5da20b1 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/tags/UpdateTagTests.java @@ -0,0 +1,279 @@ +package org.alfresco.rest.tags; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestTagModel; +import org.alfresco.utility.Utility; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.data.RandomData; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.apache.commons.lang.RandomStringUtils; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +/** + * Created by Claudia Agache on 10/4/2016. + */ +public class UpdateTagTests extends RestTest +{ + private UserModel adminUserModel; + private FileModel document; + private SiteModel siteModel; + private RestTagModel oldTag; + private DataUser.ListUserWithRoles usersWithRoles; + private String randomTag = ""; + private RestTagModel returnedModel; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + } + + @BeforeMethod(alwaysRun=true) + public void addTagToDocument() throws Exception + { + restClient.authenticateUser(adminUserModel); + oldTag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("old")); + randomTag = RandomData.getRandomName("tag"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Admin user updates tags and status code is 200") + @Bug(id="REPO-1828") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) + public void adminIsAbleToUpdateTags() throws Exception + { + restClient.authenticateUser(adminUserModel); + returnedModel = restClient.withCoreAPI().usingTag(oldTag).update(randomTag); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedModel.assertThat().field("tag").is(randomTag); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify Manager user can't update tags with Rest API and status code is 403") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void managerIsNotAbleToUpdateTag() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + restClient.withCoreAPI().usingTag(oldTag).update(randomTag); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, + executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user can't update tags with Rest API and status code is 403") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void collaboratorIsNotAbleToUpdateTagCheckDefaultErrorModelSchema() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + restClient.withCoreAPI().usingTag(oldTag).update(randomTag); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, + executionType = ExecutionType.REGRESSION, description = "Verify Contributor user can't update tags with Rest API and status code is 403") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void contributorIsNotAbleToUpdateTag() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + restClient.withCoreAPI().usingTag(oldTag).update(randomTag); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, + executionType = ExecutionType.SANITY, description = "Verify Consumer user can't update tags with Rest API and status code is 403") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void consumerIsNotAbleToUpdateTag() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + restClient.withCoreAPI().usingTag(oldTag).update(randomTag); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, + executionType = ExecutionType.SANITY, description = "Verify user gets status code 401 if authentication call fails") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) +// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") + public void userIsNotAbleToUpdateTagIfAuthenticationFails() throws Exception + { + UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); + siteManager.setPassword("wrongPassword"); + restClient.authenticateUser(siteManager); + restClient.withCoreAPI().usingTag(oldTag).update(randomTag); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify admin is not able to update tag with invalid id") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void adminIsNotAbleToUpdateTagWithInvalidId() throws Exception + { + String invalidTagId = "invalid-id"; + RestTagModel tag = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); + tag.setId(invalidTagId); + restClient.withCoreAPI().usingTag(tag).update(RandomData.getRandomName("tag")); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, invalidTagId)); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify admin is not able to update tag with empty id") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void adminIsNotAbleToUpdateTagWithEmptyId() throws Exception + { + RestTagModel tag = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); + tag.setId(""); + restClient.withCoreAPI().usingTag(tag).update(RandomData.getRandomName("tag")); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) + .assertLastError().containsSummary(RestErrorModel.PUT_EMPTY_ARGUMENT); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify admin is not able to update tag with invalid body") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void adminIsNotAbleToUpdateTagWithEmptyBody() throws Exception + { + RestTagModel tag = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); + restClient.withCoreAPI().usingTag(tag).update(""); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(RestErrorModel.EMPTY_TAG); + } + + @Bug(id="ACE-5629") + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify admin is not able to update tag with invalid body containing '|' symbol") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void adminIsNotAbleToUpdateTagWithInvalidBodyScenario1() throws Exception + { + String invalidTagBody = "|.\"/<>*"; + RestTagModel tag = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); + Utility.waitToLoopTime(20); + restClient.withCoreAPI().usingTag(tag).update(invalidTagBody); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_TAG, invalidTagBody)); + } + + @Bug(id="ACE-5629") + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify admin is not able to update tag with invalid body without '|' symbol") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void adminIsNotAbleToUpdateTagWithInvalidBodyScenario2() throws Exception + { + String invalidTagBody = ".\"/<>*"; + RestTagModel tag = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); + Utility.waitToLoopTime(20); + restClient.withCoreAPI().usingTag(tag).update(invalidTagBody); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_TAG, invalidTagBody)); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify admin user can provide large string for new tag value.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + @Bug(id="REPO-1828") + public void adminIsAbleToUpdateTagsProvideLargeStringTag() throws Exception + { + String largeStringTag = RandomStringUtils.randomAlphanumeric(10000); + + restClient.authenticateUser(adminUserModel); + returnedModel = restClient.withCoreAPI().usingTag(oldTag).update(largeStringTag); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedModel.assertThat().field("tag").is(largeStringTag); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify admin user can provide short string for new tag value.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + @Bug(id="REPO-1828") + public void adminIsAbleToUpdateTagsProvideShortStringTag() throws Exception + { + String shortStringTag = RandomStringUtils.randomAlphanumeric(2); + + restClient.authenticateUser(adminUserModel); + returnedModel = restClient.withCoreAPI().usingTag(oldTag).update(shortStringTag); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedModel.assertThat().field("tag").is(shortStringTag); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify admin user can provide string with special chars for new tag value.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + @Bug(id="REPO-1828") + public void adminIsAbleToUpdateTagsProvideSpecialCharsStringTag() throws Exception + { + String specialCharsString = "!@#$%^&*()'\".,<>-_+=|\\"; + + restClient.authenticateUser(adminUserModel); + returnedModel = restClient.withCoreAPI().usingTag(oldTag).update(specialCharsString); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedModel.assertThat().field("tag").is(specialCharsString); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify Admin user can provide existing tag for new tag value.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + @Bug(id="REPO-1828") + public void adminIsAbleToUpdateTagsProvideExistingTag() throws Exception + { + String existingTag = "oldTag"; + RestTagModel oldExistingTag = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(document).addTag(existingTag); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(adminUserModel); + returnedModel = restClient.withCoreAPI().usingTag(oldExistingTag).update(existingTag); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedModel.assertThat().field("tag").is(existingTag); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify Admin user can delete a tag, add tag and update it.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + @Bug(id="REPO-1828") + public void adminDeleteTagAddTagUpdateTag() throws Exception + { + restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingResource(document).deleteTag(oldTag); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + String newTag = "addTag"; + RestTagModel newTagModel = restClient.withCoreAPI().usingResource(document).addTag(newTag); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedModel = restClient.withCoreAPI().usingTag(newTagModel).update(newTag); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedModel.assertThat().field("tag").is(newTag); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify Admin user can update a tag, delete tag and add it.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + @Bug(id="REPO-1828") + public void adminUpdateTagDeleteTagAddTag() throws Exception + { + String newTag = "addTag"; + + returnedModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingTag(oldTag).update(newTag); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedModel.assertThat().field("tag").is(newTag); + + restClient.withCoreAPI().usingResource(document).deleteTag(returnedModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingResource(document).addTag(newTag); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + } +} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagCoreTests.java b/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagCoreTests.java deleted file mode 100644 index a31a7f9b3..000000000 --- a/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagCoreTests.java +++ /dev/null @@ -1,157 +0,0 @@ -package org.alfresco.rest.tags.nodes; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestTagModel; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.apache.commons.lang.RandomStringUtils; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -public class AddTagCoreTests extends RestTest -{ - private UserModel adminUserModel; - private UserModel testUser; - private FileModel document; - private SiteModel siteModel; - private ListUserWithRoles usersWithRoles; - private String tagValue; - private RestTagModel returnedModel; - private FolderModel folderModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - testUser = dataUser.createRandomTestUser(); - adminUserModel = dataUser.getAdminUser(); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); - } - - @BeforeMethod(alwaysRun = true) - public void generateRandomTag() - { - tagValue = RandomData.getRandomName("tag"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that adding empty tag returns status code 400") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) - public void emptyTagTest() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel); - returnedModel = restClient.withCoreAPI().usingResource(document).addTag(""); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.NULL_ARGUMENT, "tag")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that adding tag with user that has no permissions returns status code 403") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) - public void addTagWithUserThatDoesNotHavePermissions() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(testUser); - returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that adding tag to a node that does not exist returns status code 404") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) - public void addTagToInexistentNode() throws JsonToModelConversionException, Exception - { - FileModel document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - - String nodeRef = RandomStringUtils.randomAlphanumeric(10); - document.setNodeRef(nodeRef); - - restClient.authenticateUser(adminUserModel); - returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, nodeRef)); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that adding tag to a node that does not accepts tags returns status code 405") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) - public void addTagToANodeThatDoesNotAcceptsTags() throws JsonToModelConversionException, Exception - { - FileModel document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(adminUserModel); - returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue); - document.setNodeRef(returnedModel.getId()); - restClient.withCoreAPI().usingResource(document).addTag(tagValue); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.CANNOT_TAG); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that manager is able to tag a file") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) - public void managerIsAbleToTagAFile() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedModel.assertThat().field("tag").is(tagValue).and().field("id").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that manager is able to tag a folder") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) - public void managerIsAbleToTagAFolder() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - returnedModel = restClient.withCoreAPI().usingResource(folderModel).addTag(tagValue); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedModel.assertThat().field("tag").is(tagValue).and().field("id").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that tagged file can be tagged again") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) - public void addTagToATaggedFile() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel); - - returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedModel.assertThat().field("tag").is(tagValue).and().field("id").isNotEmpty(); - - returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedModel.assertThat().field("tag").is(tagValue).and().field("id").isNotEmpty(); - - returnedModel = restClient.withCoreAPI().usingResource(document).addTag("random_tag_value"); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedModel.assertThat().field("tag").is("random_tag_value").and().field("id").isNotEmpty(); - - restClient.withCoreAPI().usingResource(document).getNodeTags().assertThat() - .entriesListContains("tag", tagValue.toLowerCase()) - .and().entriesListContains("tag", "random_tag_value"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that user cannot add invalid tag") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) - public void addInvalidTag() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel); - returnedModel = restClient.withCoreAPI().usingResource(document).addTag("-1~!|@#$%^&*()_="); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_TAG, "|")); - } -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagFullTests.java b/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagFullTests.java deleted file mode 100644 index 56cac1672..000000000 --- a/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagFullTests.java +++ /dev/null @@ -1,175 +0,0 @@ -package org.alfresco.rest.tags.nodes; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestCommentModel; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestTagModel; -import org.alfresco.rest.model.RestTagModelsCollection; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser; -import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.exception.DataPreparationException; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -public class AddTagFullTests extends RestTest -{ - private UserModel adminUserModel; - private SiteModel siteModel; - private DataUser.ListUserWithRoles usersWithRoles; - private String tagValue; - private RestTagModel returnedModel; - private RestCommentModel returnedModelComment; - private RestTagModelsCollection returnedModelTags; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws DataPreparationException - { - adminUserModel = dataUser.getAdminUser(); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - } - - @BeforeMethod(alwaysRun = true) - public void generateRandomTag() throws DataPreparationException, Exception - { - tagValue = RandomData.getRandomName("tag"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that contributor is able to tag a folder created by self") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) - public void contributorIsAbleToTagAFolderCreatedBySelf() throws JsonToModelConversionException, Exception - { - FolderModel folderModel = dataContent.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingSite(siteModel).createFolder(); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - returnedModel = restClient.withCoreAPI().usingResource(folderModel).addTag(tagValue); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedModel.assertThat().field("tag").is(tagValue).and().field("id").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that collaborator is able to tag a folder") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) - public void collaboratorIsAbleToTagAFolder() throws JsonToModelConversionException, Exception - { - FolderModel folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - returnedModel = restClient.withCoreAPI().usingResource(folderModel).addTag(tagValue); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedModel.assertThat().field("tag").is(tagValue).and().field("id").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that consumer is not able to tag a folder. Check default error model schema.") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) - public void consumerIsNotAbleToTagAFolder() throws JsonToModelConversionException, Exception - { - FolderModel folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .withCoreAPI().usingResource(folderModel).addTag(tagValue); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that tagged folder can be tagged again") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) - public void addTagToATaggedFolder() throws JsonToModelConversionException, Exception - { - FolderModel folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - - returnedModel = restClient.withCoreAPI().usingResource(folderModel).addTag(tagValue); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedModel.assertThat().field("tag").is(tagValue).and().field("id").isNotEmpty(); - - returnedModel = restClient.withCoreAPI().usingResource(folderModel).addTag("random_tag_value"); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedModel.assertThat().field("tag").is("random_tag_value").and().field("id").isNotEmpty(); - - restClient.withCoreAPI().usingResource(folderModel).getNodeTags().assertThat() - .entriesListContains("tag", tagValue.toLowerCase()) - .and().entriesListContains("tag", "random_tag_value") - .and().entriesListCountIs(2); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Using collaborator provide more than one tag element") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) - public void provideMoreThanOneTagElement() throws JsonToModelConversionException, Exception - { - FolderModel folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); - String tagValue1 = RandomData.getRandomName("tag1"); - String tagValue2 = RandomData.getRandomName("tag2"); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - - returnedModelTags = restClient.withCoreAPI().usingResource(folderModel).addTags(tagValue, tagValue1, tagValue2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedModelTags.assertThat().entriesListContains("tag", tagValue) - .and().entriesListContains("tag", tagValue1) - .and().entriesListContains("tag", tagValue2) - .and().entriesListCountIs(3); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that manager cannot add tag with special characters.") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) - public void addTagWithSpecialCharacters() throws JsonToModelConversionException, Exception - { - FolderModel folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); - String specialCharsTag = "!@#$%^&*()'\".,<>-_+=|\\"; - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(folderModel).addTag(specialCharsTag); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_TAG, "|")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that you cannot tag a comment and it returns status code 405") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) - public void addTagToAComment() throws JsonToModelConversionException, Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - String comment = "comment for a tag"; - - restClient.authenticateUser(adminUserModel); - returnedModelComment = restClient.withCoreAPI().usingResource(file).addComment(comment); - file.setNodeRef(returnedModelComment.getId()); - restClient.withCoreAPI().usingResource(file).addTag(tagValue); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.CANNOT_TAG); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that you cannot tag a tag and it returns status code 405") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) - public void addTagToATag() throws JsonToModelConversionException, Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(adminUserModel); - returnedModel = restClient.withCoreAPI().usingResource(file).addTag(tagValue); - file.setNodeRef(returnedModel.getId()); - restClient.withCoreAPI().usingResource(file).addTag(tagValue); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.CANNOT_TAG); - } -} diff --git a/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagSanityTests.java deleted file mode 100644 index 94447b432..000000000 --- a/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagSanityTests.java +++ /dev/null @@ -1,134 +0,0 @@ -package org.alfresco.rest.tags.nodes; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestTagModel; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser; -import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -/** - * Created by Claudia Agache on 10/3/2016. - */ -public class AddTagSanityTests extends RestTest -{ - private UserModel adminUserModel, userModel; - private FileModel document; - private SiteModel siteModel; - private DataUser.ListUserWithRoles usersWithRoles; - private String tagValue; - private RestTagModel returnedModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - } - - @BeforeMethod(alwaysRun = true) - public void generateRandomTag() - { - tagValue = RandomData.getRandomName("tag"); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify admin user adds tags with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) - public void adminIsAbleToAddTag() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel); - returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedModel.assertThat().field("tag").is(tagValue) - .and().field("id").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Manager user adds tags with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) - public void managerIsAbleToAddTag() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedModel.assertThat().field("tag").is(tagValue) - .and().field("id").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user adds tags with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) - public void collaboratorIsAbleToAddTag() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedModel.assertThat().field("tag").is(tagValue) - .and().field("id").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Contributor user doesn't have permission to add tags with Rest API and status code is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS }) - public void contributorIsNotAbleToAddTagToAnotherContent() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - restClient.withCoreAPI().usingResource(document).addTag(tagValue); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Contributor user adds tags to his content with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) - public void contributorIsAbleToAddTagToHisContent() throws JsonToModelConversionException, Exception - { - userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); - restClient.authenticateUser(userModel); - FileModel contributorDoc = dataContent.usingSite(siteModel).usingUser(userModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - returnedModel = restClient.withCoreAPI().usingResource(contributorDoc).addTag(tagValue); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedModel.assertThat().field("id").isNotEmpty() - .and().field("tag").is(tagValue); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Consumer user doesn't have permission to add tags with Rest API and status code is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS }) - public void consumerIsNotAbleToAddTag() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.withCoreAPI().usingResource(document).addTag(tagValue); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user gets status code 401 if authentication call fails") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) - @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void userIsNotAbleToAddTagIfAuthenticationFails() throws JsonToModelConversionException, Exception - { - UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); - siteManager.setPassword("wrongPassword"); - restClient.authenticateUser(siteManager); - restClient.withCoreAPI().usingResource(document).addTag("tagUnauthorized"); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagTests.java b/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagTests.java new file mode 100644 index 000000000..9c9336d6d --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagTests.java @@ -0,0 +1,343 @@ +package org.alfresco.rest.tags.nodes; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestCommentModel; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestTagModel; +import org.alfresco.rest.model.RestTagModelsCollection; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.data.RandomData; +import org.alfresco.utility.model.*; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.apache.commons.lang.RandomStringUtils; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +/** + * Created by Claudia Agache on 10/3/2016. + */ +public class AddTagTests extends RestTest +{ + private UserModel adminUserModel, userModel; + private FileModel document; + private SiteModel siteModel; + private DataUser.ListUserWithRoles usersWithRoles; + private String tagValue; + private RestTagModel returnedModel; + private RestCommentModel returnedModelComment; + private RestTagModelsCollection returnedModelTags; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + } + + @BeforeMethod(alwaysRun = true) + public void generateRandomTag() + { + tagValue = RandomData.getRandomName("tag"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify admin user adds tags with Rest API and status code is 201") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void adminIsAbleToAddTag() throws Exception + { + restClient.authenticateUser(adminUserModel); + returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedModel.assertThat().field("tag").is(tagValue) + .and().field("id").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, + description = "Verify Manager user adds tags with Rest API and status code is 201") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) + public void managerIsAbleToTagAFile() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedModel.assertThat().field("tag").is(tagValue) + .and().field("id").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify Collaborator user adds tags with Rest API and status code is 201") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void collaboratorIsAbleToTagAFile() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedModel.assertThat().field("tag").is(tagValue) + .and().field("id").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify Contributor user doesn't have permission to add tags with Rest API and status code is 403") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void contributorIsNotAbleToAddTagToAnotherContent() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + restClient.withCoreAPI().usingResource(document).addTag(tagValue); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify Contributor user adds tags to his content with Rest API and status code is 201") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void contributorIsAbleToAddTagToHisContent() throws Exception + { + userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); + restClient.authenticateUser(userModel); + FileModel contributorDoc = dataContent.usingSite(siteModel).usingUser(userModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + returnedModel = restClient.withCoreAPI().usingResource(contributorDoc).addTag(tagValue); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedModel.assertThat().field("id").isNotEmpty() + .and().field("tag").is(tagValue); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify Consumer user doesn't have permission to add tags with Rest API and status code is 403") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void consumerIsNotAbleToTagAFile() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + restClient.withCoreAPI().usingResource(document).addTag(tagValue); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, + description = "Verify user gets status code 401 if authentication call fails") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) +// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") + public void userIsNotAbleToAddTagIfAuthenticationFails() throws Exception + { + UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); + siteManager.setPassword("wrongPassword"); + restClient.authenticateUser(siteManager); + restClient.withCoreAPI().usingResource(document).addTag("tagUnauthorized"); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that adding empty tag returns status code 400") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void emptyTagTest() throws Exception + { + restClient.authenticateUser(adminUserModel); + returnedModel = restClient.withCoreAPI().usingResource(document).addTag(""); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.NULL_ARGUMENT, "tag")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that adding tag with user that has no permissions returns status code 403") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void addTagWithUserThatDoesNotHavePermissions() throws Exception + { + restClient.authenticateUser(dataUser.createRandomTestUser()); + returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that adding tag to a node that does not exist returns status code 404") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void addTagToInexistentNode() throws Exception + { + FileModel document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + + String nodeRef = RandomStringUtils.randomAlphanumeric(10); + document.setNodeRef(nodeRef); + + restClient.authenticateUser(adminUserModel); + returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, nodeRef)); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, + description = "Verify that manager is able to tag a folder") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) + public void managerIsAbleToTagAFolder() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + returnedModel = restClient.withCoreAPI().usingResource(folderModel).addTag(tagValue); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedModel.assertThat().field("tag").is(tagValue).and().field("id").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that tagged file can be tagged again") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void addTagToATaggedFile() throws Exception + { + restClient.authenticateUser(adminUserModel); + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + + returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedModel.assertThat().field("tag").is(tagValue).and().field("id").isNotEmpty(); + + returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedModel.assertThat().field("tag").is(tagValue).and().field("id").isNotEmpty(); + + returnedModel = restClient.withCoreAPI().usingResource(document).addTag("random_tag_value"); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedModel.assertThat().field("tag").is("random_tag_value").and().field("id").isNotEmpty(); + + restClient.withCoreAPI().usingResource(document).getNodeTags().assertThat() + .entriesListContains("tag", tagValue.toLowerCase()) + .and().entriesListContains("tag", "random_tag_value"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that user cannot add invalid tag") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void addInvalidTag() throws Exception + { + restClient.authenticateUser(adminUserModel); + returnedModel = restClient.withCoreAPI().usingResource(document).addTag("-1~!|@#$%^&*()_="); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_TAG, "|")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that contributor is able to tag a folder created by self") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void contributorIsAbleToTagAFolderCreatedBySelf() throws Exception + { + FolderModel folderModel = dataContent.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingSite(siteModel).createFolder(); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + returnedModel = restClient.withCoreAPI().usingResource(folderModel).addTag(tagValue); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedModel.assertThat().field("tag").is(tagValue).and().field("id").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that collaborator is able to tag a folder") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void collaboratorIsAbleToTagAFolder() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + returnedModel = restClient.withCoreAPI().usingResource(folderModel).addTag(tagValue); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedModel.assertThat().field("tag").is(tagValue).and().field("id").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that consumer is not able to tag a folder. Check default error model schema.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void consumerIsNotAbleToTagAFolder() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + .withCoreAPI().usingResource(folderModel).addTag(tagValue); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that tagged folder can be tagged again") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void addTagToATaggedFolder() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + + returnedModel = restClient.withCoreAPI().usingResource(folderModel).addTag(tagValue); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedModel.assertThat().field("tag").is(tagValue).and().field("id").isNotEmpty(); + + returnedModel = restClient.withCoreAPI().usingResource(folderModel).addTag("random_tag_value"); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedModel.assertThat().field("tag").is("random_tag_value").and().field("id").isNotEmpty(); + + restClient.withCoreAPI().usingResource(folderModel).getNodeTags().assertThat() + .entriesListContains("tag", tagValue.toLowerCase()) + .and().entriesListContains("tag", "random_tag_value") + .and().entriesListCountIs(2); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Using collaborator provide more than one tag element") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void provideMoreThanOneTagElement() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); + String tagValue1 = RandomData.getRandomName("tag1"); + String tagValue2 = RandomData.getRandomName("tag2"); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + + returnedModelTags = restClient.withCoreAPI().usingResource(folderModel).addTags(tagValue, tagValue1, tagValue2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedModelTags.assertThat().entriesListContains("tag", tagValue) + .and().entriesListContains("tag", tagValue1) + .and().entriesListContains("tag", tagValue2) + .and().entriesListCountIs(3); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that manager cannot add tag with special characters.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void addTagWithSpecialCharacters() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); + String specialCharsTag = "!@#$%^&*()'\".,<>-_+=|\\"; + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(folderModel).addTag(specialCharsTag); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_TAG, "|")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that you cannot tag a comment and it returns status code 405") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void addTagToAComment() throws Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + String comment = "comment for a tag"; + + restClient.authenticateUser(adminUserModel); + returnedModelComment = restClient.withCoreAPI().usingResource(file).addComment(comment); + file.setNodeRef(returnedModelComment.getId()); + restClient.withCoreAPI().usingResource(file).addTag(tagValue); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.CANNOT_TAG); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that you cannot tag a tag and it returns status code 405") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void addTagToATag() throws Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(adminUserModel); + returnedModel = restClient.withCoreAPI().usingResource(file).addTag(tagValue); + file.setNodeRef(returnedModel.getId()); + restClient.withCoreAPI().usingResource(file).addTag(tagValue); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.CANNOT_TAG); + } +} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagsSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagsTests.java similarity index 68% rename from e2e-test/java/org/alfresco/rest/tags/nodes/AddTagsSanityTests.java rename to e2e-test/java/org/alfresco/rest/tags/nodes/AddTagsTests.java index 955f714c7..313bc3747 100644 --- a/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagsTests.java @@ -2,7 +2,6 @@ package org.alfresco.rest.tags.nodes; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestTagModelsCollection; import org.alfresco.utility.constants.UserRole; @@ -12,7 +11,6 @@ import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -23,7 +21,7 @@ import org.testng.annotations.Test; /** * Created by Claudia Agache on 10/7/2016. */ -public class AddTagsSanityTests extends RestTest +public class AddTagsTests extends RestTest { private UserModel adminUserModel, userModel; private FileModel document, contributorDoc; @@ -49,10 +47,10 @@ public class AddTagsSanityTests extends RestTest tag2 = RandomData.getRandomName("tag"); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify admin user adds multiple tags with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) - public void adminIsAbleToAddTags() throws JsonToModelConversionException, Exception + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify admin user adds multiple tags with Rest API and status code is 201") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void adminIsAbleToAddTags() throws Exception { restClient.authenticateUser(adminUserModel); returnedCollection = restClient.withCoreAPI().usingResource(document).addTags(tag1, tag2); @@ -61,10 +59,10 @@ public class AddTagsSanityTests extends RestTest .and().entriesListContains("tag", tag2); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Manager user adds multiple tags with Rest API and status code is 201") + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, + description = "Verify Manager user adds multiple tags with Rest API and status code is 201") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) - public void managerIsAbleToAddTags() throws JsonToModelConversionException, Exception + public void managerIsAbleToAddTags() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); returnedCollection = restClient.withCoreAPI().usingResource(document).addTags(tag1, tag2); @@ -73,10 +71,10 @@ public class AddTagsSanityTests extends RestTest .and().entriesListContains("tag", tag2); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user adds multiple tags with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) - public void collaboratorIsAbleToAddTags() throws JsonToModelConversionException, Exception + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, + executionType = ExecutionType.SANITY, description = "Verify Collaborator user adds multiple tags with Rest API and status code is 201") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void collaboratorIsAbleToAddTags() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); returnedCollection = restClient.withCoreAPI().usingResource(document).addTags(tag1, tag2); @@ -85,20 +83,20 @@ public class AddTagsSanityTests extends RestTest .and().entriesListContains("tag", tag2); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Contributor user doesn't have permission to add multiple tags with Rest API and status code is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS }) - public void contributorIsNotAbleToAddTagsToAnotherContent() throws JsonToModelConversionException, Exception + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify Contributor user doesn't have permission to add multiple tags with Rest API and status code is 403") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void contributorIsNotAbleToAddTagsToAnotherContent() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); restClient.withCoreAPI().usingResource(document).addTags(tag1, tag2); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Contributor user adds multiple tags to his content with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) - public void contributorIsAbleToAddTagsToHisContent() throws JsonToModelConversionException, Exception + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify Contributor user adds multiple tags to his content with Rest API and status code is 201") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void contributorIsAbleToAddTagsToHisContent() throws Exception { userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); restClient.authenticateUser(userModel); @@ -109,19 +107,20 @@ public class AddTagsSanityTests extends RestTest .and().entriesListContains("tag", tag2); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Consumer user doesn't have permission to add multiple tags with Rest API and status code is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS }) - public void consumerIsNotAbleToAddTags() throws JsonToModelConversionException, Exception + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify Consumer user doesn't have permission to add multiple tags with Rest API and status code is 403") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void consumerIsNotAbleToAddTags() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingResource(document).addTags(tag1, tag2); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } - @TestRail(section = { TestGroup.REST_API,TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user gets status code 401 if authentication call fails") + @TestRail(section = { TestGroup.REST_API,TestGroup.TAGS }, executionType = ExecutionType.SANITY, + description = "Verify user gets status code 401 if authentication call fails") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) - @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void userIsNotAbleToAddTagsIfAuthenticationFails() throws JsonToModelConversionException, Exception +// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") + public void userIsNotAbleToAddTagsIfAuthenticationFails() throws Exception { UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); siteManager.setPassword("wrongPassword"); diff --git a/e2e-test/java/org/alfresco/rest/tags/nodes/DeleteTagCoreTests.java b/e2e-test/java/org/alfresco/rest/tags/nodes/DeleteTagCoreTests.java deleted file mode 100644 index 45d7c8ea0..000000000 --- a/e2e-test/java/org/alfresco/rest/tags/nodes/DeleteTagCoreTests.java +++ /dev/null @@ -1,124 +0,0 @@ -package org.alfresco.rest.tags.nodes; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestTagModel; -import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.apache.commons.lang3.RandomStringUtils; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class DeleteTagCoreTests extends RestTest -{ - private UserModel adminUserModel; - private UserModel userModel; - private SiteModel siteModel; - private FileModel document; - private FolderModel folderModel; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - adminUserModel = dataUser.getAdminUser(); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that if user has no permission to remove tag returned status code is 403. Check default error model schema") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) - public void deleteTagWithUserWithoutPermissionCheckDefaultErrorModelSchema() throws Exception - { - restClient.authenticateUser(adminUserModel); - RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); - - restClient.authenticateUser(userModel); - restClient.withCoreAPI().usingResource(document).deleteTag(tag); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that if node does not exist returned status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) - public void deleteTagForAnInexistentNode() throws Exception - { - restClient.authenticateUser(adminUserModel); - RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); - - FileModel document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - String nodeRef = RandomStringUtils.randomAlphanumeric(10); - document.setNodeRef(nodeRef); - restClient.withCoreAPI().usingResource(document).deleteTag(tag); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, nodeRef)); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that if tag does not exist returned status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) - public void deleteTagThatDoesNotExist() throws Exception - { - restClient.authenticateUser(adminUserModel); - RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); - - tag.setId("abc"); - restClient.withCoreAPI().usingResource(document).deleteTag(tag); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "abc")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that if tag id is empty returned status code is 405") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) - public void deleteTagWithEmptyId() throws Exception - { - restClient.authenticateUser(adminUserModel); - RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); - - tag.setId(""); - restClient.withCoreAPI().usingResource(document).deleteTag(tag); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.DELETE_EMPTY_ARGUMENT); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that file tag can be deleted") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) - public void deleteFileTag() throws Exception - { - restClient.authenticateUser(adminUserModel); - RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); - - restClient.withCoreAPI().usingResource(document).deleteTag(tag); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingResource(document).getNodeTags() - .assertThat().entriesListDoesNotContain("tag", tag.getTag()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that folder tag can be deleted") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) - public void deleteFolderTag() throws Exception - { - restClient.authenticateUser(adminUserModel); - RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); - - tag = restClient.withCoreAPI().usingResource(folderModel).addTag(RandomData.getRandomName("tag")); - restClient.withCoreAPI().usingResource(folderModel).deleteTag(tag); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingResource(folderModel).getNodeTags() - .assertThat().entriesListDoesNotContain("tag", tag.getTag()); - } -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/tags/nodes/DeleteTagFullTests.java b/e2e-test/java/org/alfresco/rest/tags/nodes/DeleteTagFullTests.java deleted file mode 100644 index c9f387641..000000000 --- a/e2e-test/java/org/alfresco/rest/tags/nodes/DeleteTagFullTests.java +++ /dev/null @@ -1,121 +0,0 @@ -package org.alfresco.rest.tags.nodes; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestTagModel; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser; -import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.apache.commons.lang.RandomStringUtils; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class DeleteTagFullTests extends RestTest -{ - private UserModel adminUserModel; - private SiteModel siteModel; - private DataUser.ListUserWithRoles usersWithRoles; - private RestTagModel tagReturnedModel, returnedTag; - private FileModel document; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, - executionType = ExecutionType.REGRESSION, description = "Verify Manager user can't delete deleted tag.") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) - @Bug(id = "ACE-5455") - public void managerCannotDeleteDeletedTag() throws JsonToModelConversionException, Exception - { - tagReturnedModel = restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(document).deleteTag(tagReturnedModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingResource(document).deleteTag(tagReturnedModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, - executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user can delete long tag.") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) - public void userCollaboratorCanDeleteLongTag() throws JsonToModelConversionException, Exception - { - String longTag = RandomStringUtils.randomAlphanumeric(800); - - tagReturnedModel = restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingResource(document).addTag(longTag); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingResource(document).deleteTag(tagReturnedModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, - executionType = ExecutionType.REGRESSION, description = "Verify Manager user can delete short tag.") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) - public void managerCanDeleteShortTag() throws JsonToModelConversionException, Exception - { - String shortTag = RandomStringUtils.randomAlphanumeric(10); - - tagReturnedModel = restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingResource(document).addTag(shortTag); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(document).deleteTag(tagReturnedModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, - executionType = ExecutionType.REGRESSION, description = "Verify Admin can delete tag then add it again.") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) - public void adminRemovesTagAndAddsItAgain() throws JsonToModelConversionException, Exception - { - String tag = RandomStringUtils.randomAlphanumeric(10); - - tagReturnedModel = restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingResource(document).addTag(tag); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(document).deleteTag(tagReturnedModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - tagReturnedModel = restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingResource(document).addTag(tag); - returnedTag = restClient.withCoreAPI().getTag(tagReturnedModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedTag.assertThat().field("tag").is(tag.toLowerCase()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, - executionType = ExecutionType.REGRESSION, description = "Verify Manager user can delete tag added by another user.") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) - public void managerCanDeleteTagAddedByAnotherUser() throws JsonToModelConversionException, Exception - { - String tag = RandomStringUtils.randomAlphanumeric(10); - - tagReturnedModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingResource(document).addTag(tag); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(document).deleteTag(tagReturnedModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } -} diff --git a/e2e-test/java/org/alfresco/rest/tags/nodes/DeleteTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/nodes/DeleteTagSanityTests.java deleted file mode 100644 index ac2eaae88..000000000 --- a/e2e-test/java/org/alfresco/rest/tags/nodes/DeleteTagSanityTests.java +++ /dev/null @@ -1,136 +0,0 @@ -package org.alfresco.rest.tags.nodes; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestTagModel; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser; -import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Created by Claudia Agache on 10/4/2016. - */ -public class DeleteTagSanityTests extends RestTest -{ - private UserModel adminUserModel, userModel; - private SiteModel siteModel; - private DataUser.ListUserWithRoles usersWithRoles; - private RestTagModel tag; - private FileModel document, contributorDoc; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Admin user deletes tags with Rest API and status code is 204") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) - public void adminIsAbleToDeleteTags() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel); - tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); - - restClient.withCoreAPI().usingResource(document).deleteTag(tag); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Manager user deletes tags created by admin user with Rest API and status code is 204") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) - public void managerIsAbleToDeleteTags() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel); - tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingResource(document).deleteTag(tag); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user deletes tags created by admin user with Rest API and status code is 204") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) - public void collaboratorIsAbleToDeleteTags() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel); - tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.withCoreAPI().usingResource(document).deleteTag(tag); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, - executionType = ExecutionType.SANITY, description = "Verify Contributor user can't delete tags created by admin user with Rest API and status code is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS }) - public void contributorIsNotAbleToDeleteTagsForAnotherUserContent() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel); - tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - restClient.withCoreAPI().usingResource(document).deleteTag(tag); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Contributor user deletes tags created by him with Rest API and status code is 204") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) - public void contributorIsAbleToDeleteTagsForHisContent() throws JsonToModelConversionException, Exception - { - userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); - restClient.authenticateUser(userModel); - contributorDoc = dataContent.usingSite(siteModel).usingUser(userModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);; - tag = restClient.withCoreAPI().usingResource(contributorDoc).addTag(RandomData.getRandomName("tag")); - - restClient.withCoreAPI().usingResource(document).deleteTag(tag); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Consumer user can't delete tags created by admin user with Rest API and status code is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS }) - public void consumerIsNotAbleToDeleteTags() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel); - tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.withCoreAPI().usingResource(document).deleteTag(tag); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user gets status code 401 if authentication call fails") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) - @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void userIsNotAbleToDeleteTagIfAuthenticationFails() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel); - tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); - - UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); - siteManager.setPassword("wrongPassword"); - restClient.authenticateUser(siteManager); - restClient.withCoreAPI().usingResource(document).deleteTag(tag); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/tags/nodes/DeleteTagTests.java b/e2e-test/java/org/alfresco/rest/tags/nodes/DeleteTagTests.java new file mode 100644 index 000000000..34ea4fd51 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/tags/nodes/DeleteTagTests.java @@ -0,0 +1,288 @@ +package org.alfresco.rest.tags.nodes; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestTagModel; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.data.RandomData; +import org.alfresco.utility.model.*; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.apache.commons.lang3.RandomStringUtils; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Created by Claudia Agache on 10/4/2016. + */ +public class DeleteTagTests extends RestTest +{ + private UserModel adminUserModel, userModel; + private SiteModel siteModel; + private DataUser.ListUserWithRoles usersWithRoles; + private RestTagModel tag; + private FileModel document, contributorDoc; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify Admin user deletes tags with Rest API and status code is 204") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void adminIsAbleToDeleteTags() throws Exception + { + restClient.authenticateUser(adminUserModel); + tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); + + restClient.withCoreAPI().usingResource(document).deleteTag(tag); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withCoreAPI().usingResource(document).getNodeTags() + .assertThat().entriesListDoesNotContain("tag", tag.getTag()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, + description = "Verify Manager user deletes tags created by admin user with Rest API and status code is 204") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) + public void managerIsAbleToDeleteTags() throws Exception + { + restClient.authenticateUser(adminUserModel); + tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + restClient.withCoreAPI().usingResource(document).deleteTag(tag); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify Collaborator user deletes tags created by admin user with Rest API and status code is 204") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void collaboratorIsAbleToDeleteTags() throws Exception + { + restClient.authenticateUser(adminUserModel); + tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + restClient.withCoreAPI().usingResource(document).deleteTag(tag); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify Contributor user can't delete tags created by admin user with Rest API and status code is 403") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void contributorIsNotAbleToDeleteTagsForAnotherUserContent() throws Exception + { + restClient.authenticateUser(adminUserModel); + tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + restClient.withCoreAPI().usingResource(document).deleteTag(tag); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify Contributor user deletes tags created by him with Rest API and status code is 204") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void contributorIsAbleToDeleteTagsForHisContent() throws Exception + { + userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); + restClient.authenticateUser(userModel); + contributorDoc = dataContent.usingSite(siteModel).usingUser(userModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);; + tag = restClient.withCoreAPI().usingResource(contributorDoc).addTag(RandomData.getRandomName("tag")); + + restClient.withCoreAPI().usingResource(document).deleteTag(tag); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify Consumer user can't delete tags created by admin user with Rest API and status code is 403") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void consumerIsNotAbleToDeleteTags() throws Exception + { + restClient.authenticateUser(adminUserModel); + tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + restClient.withCoreAPI().usingResource(document).deleteTag(tag); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, + description = "Verify user gets status code 401 if authentication call fails") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) +// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") + public void userIsNotAbleToDeleteTagIfAuthenticationFails() throws Exception + { + restClient.authenticateUser(adminUserModel); + tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); + + UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); + siteManager.setPassword("wrongPassword"); + restClient.authenticateUser(siteManager); + restClient.withCoreAPI().usingResource(document).deleteTag(tag); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that if user has no permission to remove tag returned status code is 403. Check default error model schema") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void deleteTagWithUserWithoutPermissionCheckDefaultErrorModelSchema() throws Exception + { + restClient.authenticateUser(adminUserModel); + RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); + + restClient.authenticateUser(dataUser.createRandomTestUser()); + restClient.withCoreAPI().usingResource(document).deleteTag(tag); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that if node does not exist returned status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void deleteTagForANonexistentNode() throws Exception + { + restClient.authenticateUser(adminUserModel); + RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); + + FileModel document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + String nodeRef = RandomStringUtils.randomAlphanumeric(10); + document.setNodeRef(nodeRef); + restClient.withCoreAPI().usingResource(document).deleteTag(tag); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, nodeRef)); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that if tag does not exist returned status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void deleteTagThatDoesNotExist() throws Exception + { + restClient.authenticateUser(adminUserModel); + RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); + + tag.setId("abc"); + restClient.withCoreAPI().usingResource(document).deleteTag(tag); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "abc")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that if tag id is empty returned status code is 405") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void deleteTagWithEmptyId() throws Exception + { + restClient.authenticateUser(adminUserModel); + RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); + + tag.setId(""); + restClient.withCoreAPI().usingResource(document).deleteTag(tag); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.DELETE_EMPTY_ARGUMENT); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that folder tag can be deleted") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void deleteFolderTag() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder();; + restClient.authenticateUser(adminUserModel); + RestTagModel tag = restClient.withCoreAPI().usingResource(folderModel).addTag(RandomData.getRandomName("tag")); + restClient.withCoreAPI().usingResource(folderModel).deleteTag(tag); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withCoreAPI().usingResource(folderModel).getNodeTags() + .assertThat().entriesListDoesNotContain("tag", tag.getTag()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, + executionType = ExecutionType.REGRESSION, description = "Verify Manager user can't delete deleted tag.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + @Bug(id = "ACE-5455") + public void managerCannotDeleteDeletedTag() throws Exception + { + tag = restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(document).deleteTag(tag); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingResource(document).deleteTag(tag); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, + executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user can delete long tag.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void userCollaboratorCanDeleteLongTag() throws Exception + { + String longTag = org.apache.commons.lang.RandomStringUtils.randomAlphanumeric(800); + + tag = restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingResource(document).addTag(longTag); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingResource(document).deleteTag(tag); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, + executionType = ExecutionType.REGRESSION, description = "Verify Manager user can delete short tag.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void managerCanDeleteShortTag() throws Exception + { + String shortTag = org.apache.commons.lang.RandomStringUtils.randomAlphanumeric(10); + + tag = restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingResource(document).addTag(shortTag); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(document).deleteTag(tag); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, + executionType = ExecutionType.REGRESSION, description = "Verify Admin can delete tag then add it again.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void adminRemovesTagAndAddsItAgain() throws Exception + { + String tagValue = RandomStringUtils.randomAlphanumeric(10); + + tag = restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingResource(document).addTag(tagValue); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(document).deleteTag(tag); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + tag = restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingResource(document).addTag(tagValue); + RestTagModel returnedTag = restClient.withCoreAPI().getTag(tag); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedTag.assertThat().field("tag").is(tagValue.toLowerCase()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, + executionType = ExecutionType.REGRESSION, description = "Verify Manager user can delete tag added by another user.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void managerCanDeleteTagAddedByAnotherUser() throws Exception + { + tag = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingResource(document).addTag(RandomStringUtils.randomAlphanumeric(10)); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(document).deleteTag(tag); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } +} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/tags/nodes/GetNodeTagsCoreTests.java b/e2e-test/java/org/alfresco/rest/tags/nodes/GetNodeTagsCoreTests.java deleted file mode 100644 index 2f21b5284..000000000 --- a/e2e-test/java/org/alfresco/rest/tags/nodes/GetNodeTagsCoreTests.java +++ /dev/null @@ -1,136 +0,0 @@ -package org.alfresco.rest.tags.nodes; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.apache.commons.lang.RandomStringUtils; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class GetNodeTagsCoreTests extends RestTest -{ - private UserModel adminUserModel, userModel; - private SiteModel siteModel; - private FileModel document; - private String tagValue; - private String tagValue2; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - adminUserModel = dataUser.getAdminUser(); - restClient.authenticateUser(adminUserModel); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - - document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - - tagValue = RandomData.getRandomName("tag"); - restClient.withCoreAPI().usingResource(document).addTag(tagValue); - - tagValue2 = RandomData.getRandomName("tag"); - restClient.withCoreAPI().usingResource(document).addTag(tagValue2); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that using invalid value for skipCount parameter returns status code 400") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) - public void invalidSkipCountTest() throws JsonToModelConversionException, Exception - { - restClient.withParams("skipCount=abc").withCoreAPI().usingResource(document).getNodeTags(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "abc")); - - restClient.withParams("skipCount=-1").withCoreAPI().usingResource(document).getNodeTags(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that using invalid value for maxItems parameter returns status code 400") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) - public void invalidMaxItemsTest() throws JsonToModelConversionException, Exception - { - restClient.withParams("maxItems=abc").withCoreAPI().usingResource(document).getNodeTags(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "abc")); - - restClient.withParams("maxItems=-1").withCoreAPI().usingResource(document).getNodeTags(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that user without permissions returns status code 403") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) - public void userWithoutPermissionsTest() throws JsonToModelConversionException, Exception - { - SiteModel site = dataSite.usingUser(adminUserModel).createModeratedRandomSite(); - FileModel document = dataContent.usingSite(site).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - String tagValue = RandomData.getRandomName("tag"); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).addTag(tagValue); - - restClient.authenticateUser(userModel).withCoreAPI().usingResource(document).getNodeTags(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that if node does not exist returns status code 403") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) - public void inexistentNodeTest() throws JsonToModelConversionException, Exception - { - FileModel document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - String nodeRef = RandomStringUtils.randomAlphanumeric(10); - document.setNodeRef(nodeRef); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getNodeTags(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, nodeRef)); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that if node id is empty returns status code 403") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) - public void emptyNodeIdTest() throws JsonToModelConversionException, Exception - { - FileModel document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - document.setNodeRef(""); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getNodeTags(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify file tags") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) - public void fileTagsTest() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getNodeTags() - .assertThat() - .entriesListContains("tag", tagValue.toLowerCase()) - .and().entriesListContains("tag", tagValue2.toLowerCase()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify folder tags") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) - public void folderTagsTest() throws JsonToModelConversionException, Exception - { - FolderModel folder = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); - - tagValue = RandomData.getRandomName("tag"); - restClient.withCoreAPI().usingResource(folder).addTag(tagValue); - tagValue2 = RandomData.getRandomName("tag"); - restClient.withCoreAPI().usingResource(folder).addTag(tagValue2); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(folder).getNodeTags() - .assertThat() - .entriesListContains("tag", tagValue.toLowerCase()) - .and().entriesListContains("tag", tagValue2.toLowerCase()); - } -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/tags/nodes/GetNodeTagsFullTests.java b/e2e-test/java/org/alfresco/rest/tags/nodes/GetNodeTagsFullTests.java deleted file mode 100644 index 4e86af200..000000000 --- a/e2e-test/java/org/alfresco/rest/tags/nodes/GetNodeTagsFullTests.java +++ /dev/null @@ -1,192 +0,0 @@ -package org.alfresco.rest.tags.nodes; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestTagModelsCollection; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class GetNodeTagsFullTests extends RestTest -{ - private UserModel adminUserModel, userModel; - private SiteModel siteModel; - private FileModel document; - private String tagValue; - private String tagValue2; - private RestTagModelsCollection returnedCollection; - private ListUserWithRoles usersWithRoles; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - adminUserModel = dataUser.getAdminUser(); - restClient.authenticateUser(adminUserModel); - siteModel = dataSite.usingUser(adminUserModel).createPrivateRandomSite(); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - - document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - - tagValue = RandomData.getRandomName("tag"); - restClient.withCoreAPI().usingResource(document).addTag(tagValue); - - tagValue2 = RandomData.getRandomName("tag"); - restClient.withCoreAPI().usingResource(document).addTag(tagValue2); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify site Manager is able to get node tags using properties parameter") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) - public void siteManagerIsAbleToRetrieveNodeTagsWithPropertiesParameter() throws JsonToModelConversionException, Exception - { - returnedCollection = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withParams("properties=tag").withCoreAPI().usingResource(document).getNodeTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat().entriesListContains("tag", tagValue.toLowerCase()) - .and().entriesListContains("tag", tagValue2.toLowerCase()) - .and().entriesListDoesNotContain("id"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that Collaborator user is not able to get node tags using site id instead of node id") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) - public void collaboratorGetNodeTagsUseSiteIdInsteadOfNodeId() throws JsonToModelConversionException, Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - - file.setNodeRef(siteModel.getId()); - returnedCollection = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(file).getNodeTags(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, file.getNodeRef())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "With admin get node tags and use skipCount parameter. Check pagination and maxItems") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) - public void useSkipCountCheckPaginationAndMaxItems() throws JsonToModelConversionException, Exception - { - returnedCollection = restClient.authenticateUser(adminUserModel) - .withParams("skipCount=1").withCoreAPI().usingResource(document).getNodeTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.getPagination().assertThat().field("maxItems").is(100) - .and().field("hasMoreItems").is("false") - .and().field("totalItems").is(2) - .and().field("count").is("1"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "With admin get node tags and use maxItems parameter. Check pagination") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) - public void useMaxItemsParameterCheckPagination() throws JsonToModelConversionException, Exception - { - returnedCollection = restClient.authenticateUser(adminUserModel) - .withParams("maxItems=1").withCoreAPI().usingResource(document).getNodeTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.getPagination().assertThat().field("maxItems").is(1) - .and().field("hasMoreItems").is("true") - .and().field("totalItems").is("2") - .and().field("count").is("1") - .and().field("skipCount").is("0"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Get tags from a node to which user does not have access. Check default error model schema") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) - public void getTagsFromNodeWithUserWhoDoesNotHaveAccessCheckDefaultErrorModelSchema() throws JsonToModelConversionException, Exception - { - returnedCollection = restClient.authenticateUser(userModel) - .withCoreAPI().usingResource(document).getNodeTags(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Using manager user get only one tag.") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) - public void usingManagerGetOnlyOneTag() throws JsonToModelConversionException, Exception - { - FileModel file = dataContent.usingAdmin().usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.withCoreAPI().usingResource(file).addTag(tagValue); - - returnedCollection = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(file).getNodeTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.getPagination().assertThat().field("maxItems").is(100) - .and().field("hasMoreItems").is("false") - .and().field("totalItems").is("1") - .and().field("count").is("1") - .and().field("skipCount").is("0"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Using admin get last 2 tags and skip first 2 tags") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) - public void adminUserGetLast2TagsAndSkipFirst2Tags() throws JsonToModelConversionException, Exception - { - String firstTag = "1st tag"; - String secondTag = "2nd tag"; - String thirdTag = "3rd tag"; - String fourthTag = "4th tag"; - FileModel file = dataContent.usingAdmin().usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addTag(firstTag); - restClient.withCoreAPI().usingResource(file).addTag(secondTag); - restClient.withCoreAPI().usingResource(file).addTag(thirdTag); - restClient.withCoreAPI().usingResource(file).addTag(fourthTag); - - returnedCollection = restClient.withParams("skipCount=2").withCoreAPI().usingResource(file).getNodeTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - returnedCollection.assertThat().entriesListContains("tag", thirdTag.toLowerCase()) - .and().entriesListContains("tag", fourthTag.toLowerCase()); - returnedCollection.getPagination().assertThat().field("maxItems").is(100) - .and().field("hasMoreItems").is("false") - .and().field("totalItems").is("4") - .and().field("count").is("2") - .and().field("skipCount").is("2"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "With admin get node tags and use maxItems=0.") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) - public void getTagsWithZeroMaxItems() throws JsonToModelConversionException, Exception - { - returnedCollection = restClient.authenticateUser(adminUserModel) - .withParams("maxItems=0").withCoreAPI().usingResource(document).getNodeTags(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that using high skipCount parameter returns status code 200.") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) - public void getTagsWithHighSkipCount() throws JsonToModelConversionException, Exception - { - returnedCollection = restClient.authenticateUser(adminUserModel).withParams("skipCount=10000") - .withCoreAPI().usingResource(document).getNodeTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.getPagination().assertThat().field("maxItems").is(100) - .and().field("hasMoreItems").is("false") - .and().field("totalItems").is("2") - .and().field("count").is("0") - .and().field("skipCount").is("10000"); - returnedCollection.assertThat().entriesListCountIs(0); - } -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/tags/nodes/GetNodeTagsSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/nodes/GetNodeTagsSanityTests.java deleted file mode 100644 index f82282875..000000000 --- a/e2e-test/java/org/alfresco/rest/tags/nodes/GetNodeTagsSanityTests.java +++ /dev/null @@ -1,131 +0,0 @@ -package org.alfresco.rest.tags.nodes; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestTagModelsCollection; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class GetNodeTagsSanityTests extends RestTest -{ - private UserModel adminUserModel; - private SiteModel siteModel; - private ListUserWithRoles usersWithRoles; - private FileModel document; - private RestTagModelsCollection returnedCollection; - private String tagValue; - private String tagValue2; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - restClient.authenticateUser(adminUserModel); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, - UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); - document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - - tagValue = RandomData.getRandomName("tag"); - restClient.withCoreAPI().usingResource(document).addTag(tagValue); - - tagValue2 = RandomData.getRandomName("tag"); - restClient.withCoreAPI().usingResource(document).addTag(tagValue2); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, - executionType = ExecutionType.SANITY, description = "Verify site Manager is able to get node tags") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) - public void siteManagerIsAbleToRetrieveNodeTags() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - - returnedCollection = restClient.withCoreAPI().usingResource(document).getNodeTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat() - .entriesListContains("tag", tagValue.toLowerCase()) - .and().entriesListContains("tag", tagValue2.toLowerCase()); - - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, - executionType = ExecutionType.SANITY, description = "Verify site Collaborator is able to get node tags") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) - public void siteCollaboratorIsAbleToRetrieveNodeTags() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - - returnedCollection = restClient.withCoreAPI().usingResource(document).getNodeTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat() - .entriesListContains("tag", tagValue.toLowerCase()) - .and().entriesListContains("tag", tagValue2.toLowerCase()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, - executionType = ExecutionType.SANITY, description = "Verify site Contributor is able to get node tags") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) - public void siteContributorIsAbleToRetrieveNodeTags() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - - returnedCollection = restClient.withCoreAPI().usingResource(document).getNodeTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat() - .entriesListContains("tag", tagValue.toLowerCase()) - .and().entriesListContains("tag", tagValue2.toLowerCase()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, - executionType = ExecutionType.SANITY, description = "Verify site Consumer is able to get node tags") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) - public void siteConsumerIsAbleToRetrieveNodeTags() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - - returnedCollection = restClient.withCoreAPI().usingResource(document).getNodeTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat() - .entriesListContains("tag", tagValue.toLowerCase()) - .and().entriesListContains("tag", tagValue2.toLowerCase()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, - executionType = ExecutionType.SANITY, description = "Verify admin is able to get node tags") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) - public void adminIsAbleToRetrieveNodeTags() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel); - returnedCollection = restClient.withCoreAPI().usingResource(document).getNodeTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat() - .entriesListContains("tag", tagValue.toLowerCase()) - .and().entriesListContains("tag", tagValue2.toLowerCase()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, - executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to get node tags") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) - @Bug(id = "MNT-16904", description = "fails only on environment with tenants") - public void unauthenticatedUserIsNotAbleToRetrieveNodeTags() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(new UserModel("random user", "random password")); - restClient.withCoreAPI().usingResource(document).getNodeTags(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/tags/nodes/GetNodeTagsTests.java b/e2e-test/java/org/alfresco/rest/tags/nodes/GetNodeTagsTests.java new file mode 100644 index 000000000..59caddf78 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/tags/nodes/GetNodeTagsTests.java @@ -0,0 +1,339 @@ +package org.alfresco.rest.tags.nodes; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestTagModelsCollection; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.data.RandomData; +import org.alfresco.utility.model.*; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.apache.commons.lang.RandomStringUtils; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class GetNodeTagsTests extends RestTest +{ + private UserModel adminUserModel; + private SiteModel siteModel; + private ListUserWithRoles usersWithRoles; + private FileModel document; + private RestTagModelsCollection returnedCollection; + private String tagValue; + private String tagValue2; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + restClient.authenticateUser(adminUserModel); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, + UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + + tagValue = RandomData.getRandomName("tag"); + restClient.withCoreAPI().usingResource(document).addTag(tagValue); + + tagValue2 = RandomData.getRandomName("tag"); + restClient.withCoreAPI().usingResource(document).addTag(tagValue2); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, + executionType = ExecutionType.SANITY, description = "Verify site Manager is able to get node tags") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) + public void siteManagerIsAbleToRetrieveNodeTags() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + + returnedCollection = restClient.withCoreAPI().usingResource(document).getNodeTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat() + .entriesListContains("tag", tagValue.toLowerCase()) + .and().entriesListContains("tag", tagValue2.toLowerCase()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, + executionType = ExecutionType.REGRESSION, description = "Verify site Collaborator is able to get node tags") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void siteCollaboratorIsAbleToRetrieveNodeTags() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + + returnedCollection = restClient.withCoreAPI().usingResource(document).getNodeTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat() + .entriesListContains("tag", tagValue.toLowerCase()) + .and().entriesListContains("tag", tagValue2.toLowerCase()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, + executionType = ExecutionType.REGRESSION, description = "Verify site Contributor is able to get node tags") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void siteContributorIsAbleToRetrieveNodeTags() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + + returnedCollection = restClient.withCoreAPI().usingResource(document).getNodeTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat() + .entriesListContains("tag", tagValue.toLowerCase()) + .and().entriesListContains("tag", tagValue2.toLowerCase()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, + executionType = ExecutionType.REGRESSION, description = "Verify site Consumer is able to get node tags") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void siteConsumerIsAbleToRetrieveNodeTags() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + + returnedCollection = restClient.withCoreAPI().usingResource(document).getNodeTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat() + .entriesListContains("tag", tagValue.toLowerCase()) + .and().entriesListContains("tag", tagValue2.toLowerCase()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, + executionType = ExecutionType.REGRESSION, description = "Verify admin is able to get node tags") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void adminIsAbleToRetrieveNodeTags() throws Exception + { + restClient.authenticateUser(adminUserModel); + returnedCollection = restClient.withCoreAPI().usingResource(document).getNodeTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat() + .entriesListContains("tag", tagValue.toLowerCase()) + .and().entriesListContains("tag", tagValue2.toLowerCase()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, + executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to get node tags") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) +// @Bug(id = "MNT-16904", description = "fails only on environment with tenants") + public void unauthenticatedUserIsNotAbleToRetrieveNodeTags() throws Exception + { + restClient.authenticateUser(new UserModel("random user", "random password")); + restClient.withCoreAPI().usingResource(document).getNodeTags(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that using invalid value for skipCount parameter returns status code 400") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION}) + public void invalidSkipCountTest() throws Exception + { + restClient.withParams("skipCount=abc").withCoreAPI().usingResource(document).getNodeTags(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "abc")); + + restClient.withParams("skipCount=-1").withCoreAPI().usingResource(document).getNodeTags(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that using invalid value for maxItems parameter returns status code 400") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION}) + public void invalidMaxItemsTest() throws Exception + { + restClient.withParams("maxItems=abc").withCoreAPI().usingResource(document).getNodeTags(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "abc")); + + restClient.withParams("maxItems=-1").withCoreAPI().usingResource(document).getNodeTags(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that user without permissions returns status code 403") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION}) + public void userWithoutPermissionsTest() throws Exception + { + SiteModel site = dataSite.usingUser(adminUserModel).createModeratedRandomSite(); + FileModel document = dataContent.usingSite(site).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + String tagValue = RandomData.getRandomName("tag"); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).addTag(tagValue); + + restClient.authenticateUser(dataUser.createRandomTestUser()).withCoreAPI().usingResource(document).getNodeTags(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that if node does not exist returns status code 403") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION}) + public void nonexistentNodeTest() throws Exception + { + FileModel document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + String nodeRef = RandomStringUtils.randomAlphanumeric(10); + document.setNodeRef(nodeRef); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getNodeTags(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, nodeRef)); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that if node id is empty returns status code 403") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION}) + public void emptyNodeIdTest() throws Exception + { + FileModel document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + document.setNodeRef(""); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getNodeTags(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify folder tags") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION}) + public void folderTagsTest() throws Exception + { + FolderModel folder = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); + + restClient.withCoreAPI().usingResource(folder).addTag(tagValue); + restClient.withCoreAPI().usingResource(folder).addTag(tagValue2); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(folder).getNodeTags() + .assertThat() + .entriesListContains("tag", tagValue.toLowerCase()) + .and().entriesListContains("tag", tagValue2.toLowerCase()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify site Manager is able to get node tags using properties parameter") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void siteManagerIsAbleToRetrieveNodeTagsWithPropertiesParameter() throws Exception + { + returnedCollection = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withParams("properties=tag").withCoreAPI().usingResource(document).getNodeTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat().entriesListContains("tag", tagValue.toLowerCase()) + .and().entriesListContains("tag", tagValue2.toLowerCase()) + .and().entriesListDoesNotContain("id"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that Collaborator user is not able to get node tags using site id instead of node id") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void collaboratorGetNodeTagsUseSiteIdInsteadOfNodeId() throws Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + + file.setNodeRef(siteModel.getId()); + returnedCollection = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(file).getNodeTags(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, file.getNodeRef())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "With admin get node tags and use skipCount parameter. Check pagination and maxItems") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void useSkipCountCheckPaginationAndMaxItems() throws Exception + { + returnedCollection = restClient.authenticateUser(adminUserModel) + .withParams("skipCount=1").withCoreAPI().usingResource(document).getNodeTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.getPagination().assertThat().field("maxItems").is(100) + .and().field("hasMoreItems").is("false") + .and().field("totalItems").is(2) + .and().field("count").is("1"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "With admin get node tags and use maxItems parameter. Check pagination") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void useMaxItemsParameterCheckPagination() throws Exception + { + returnedCollection = restClient.authenticateUser(adminUserModel) + .withParams("maxItems=1").withCoreAPI().usingResource(document).getNodeTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.getPagination().assertThat().field("maxItems").is(1) + .and().field("hasMoreItems").is("true") + .and().field("totalItems").is("2") + .and().field("count").is("1") + .and().field("skipCount").is("0"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Using manager user get only one tag.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void usingManagerGetOnlyOneTag() throws Exception + { + FileModel file = dataContent.usingAdmin().usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addTag(tagValue); + + returnedCollection = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(file).getNodeTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.getPagination().assertThat().field("maxItems").is(100) + .and().field("hasMoreItems").is("false") + .and().field("totalItems").is("1") + .and().field("count").is("1") + .and().field("skipCount").is("0"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Using admin get last 2 tags and skip first 2 tags") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void adminUserGetLast2TagsAndSkipFirst2Tags() throws Exception + { + String firstTag = "1st tag"; + String secondTag = "2nd tag"; + String thirdTag = "3rd tag"; + String fourthTag = "4th tag"; + FileModel file = dataContent.usingAdmin().usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addTag(firstTag); + restClient.withCoreAPI().usingResource(file).addTag(secondTag); + restClient.withCoreAPI().usingResource(file).addTag(thirdTag); + restClient.withCoreAPI().usingResource(file).addTag(fourthTag); + + returnedCollection = restClient.withParams("skipCount=2").withCoreAPI().usingResource(file).getNodeTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + returnedCollection.assertThat().entriesListContains("tag", thirdTag.toLowerCase()) + .and().entriesListContains("tag", fourthTag.toLowerCase()); + returnedCollection.getPagination().assertThat().field("maxItems").is(100) + .and().field("hasMoreItems").is("false") + .and().field("totalItems").is("4") + .and().field("count").is("2") + .and().field("skipCount").is("2"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "With admin get node tags and use maxItems=0.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void getTagsWithZeroMaxItems() throws Exception + { + returnedCollection = restClient.authenticateUser(adminUserModel) + .withParams("maxItems=0").withCoreAPI().usingResource(document).getNodeTags(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that using high skipCount parameter returns status code 200.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void getTagsWithHighSkipCount() throws Exception + { + returnedCollection = restClient.authenticateUser(adminUserModel).withParams("skipCount=10000") + .withCoreAPI().usingResource(document).getNodeTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.getPagination().assertThat().field("maxItems").is(100) + .and().field("hasMoreItems").is("false") + .and().field("totalItems").is("2") + .and().field("count").is("0") + .and().field("skipCount").is("10000"); + returnedCollection.assertThat().entriesListCountIs(0); + } +} \ No newline at end of file From ee1362daf341f84b9a5ed004d86f7a199b28dd80 Mon Sep 17 00:00:00 2001 From: Alexandru-Eusebiu Epure Date: Mon, 9 Oct 2017 11:27:33 +0300 Subject: [PATCH 1234/1491] REPO-2755 : REST API & CMIS TAS sanity builds Change testgroup from CORE to REGRESSION for sharedLinks, people and audit. --- .../rest/people/AvatarPeopleSanityTest.java | 9 +- .../people/DeleteSiteMemberCoreTests.java | 69 ++++----------- .../people/DeleteSiteMemberFullTests.java | 79 ++++++----------- .../people/DeleteSiteMemberSanityTests.java | 12 +-- .../rest/people/GetPeopleCoreTests.java | 8 +- .../rest/people/GetPeopleFullTests.java | 21 +---- .../people/GetSiteMembershipCoreTests.java | 33 ++----- .../people/GetSiteMembershipFullTests.java | 28 +++--- ...etSitesMembershipInformationCoreTests.java | 27 ++---- ...etSitesMembershipInformationFullTests.java | 49 +++++------ .../GetPeopleActivitiesCoreTests.java | 12 +-- .../GetPeopleActivitiesFullTests.java | 85 ++++--------------- .../GetPeoplePreferenceCoreTests.java | 8 +- .../GetPeoplePreferenceFullTests.java | 35 +++----- .../GetPeoplePreferencesCoreTests.java | 12 +-- .../GetPeoplePreferencesFullTests.java | 30 ++----- .../rest/renditions/CreateRenditionTests.java | 10 +-- .../rest/renditions/GetRenditionTests.java | 2 +- .../sharedlinks/GetSharedLinksFullTests.java | 2 +- .../sharedlinks/SharedLinksSanityTests.java | 21 ++--- 20 files changed, 175 insertions(+), 377 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/AvatarPeopleSanityTest.java b/e2e-test/java/org/alfresco/rest/people/AvatarPeopleSanityTest.java index 5b6276d24..a622363a6 100644 --- a/e2e-test/java/org/alfresco/rest/people/AvatarPeopleSanityTest.java +++ b/e2e-test/java/org/alfresco/rest/people/AvatarPeopleSanityTest.java @@ -1,5 +1,8 @@ package org.alfresco.rest.people; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertTrue; + import java.io.File; import org.alfresco.rest.RestTest; @@ -15,8 +18,6 @@ import org.testng.annotations.Test; import com.jayway.restassured.response.ValidatableResponse; -import junit.framework.Assert; - public class AvatarPeopleSanityTest extends RestTest { @@ -38,8 +39,8 @@ public class AvatarPeopleSanityTest extends RestTest .uploadAvatarContent(restProperties.envProperty().getFullServerUrl(), avatarFile).statusCode(200); restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().downloadAvatarContent(); restClient.assertStatusCodeIs(HttpStatus.OK); - Assert.assertNotNull(response.extract().body().asByteArray()); - Assert.assertTrue("Avatar Image not uploaded", response.extract().body().asByteArray().length > 0); + assertNotNull(response.extract().body().asByteArray()); + assertTrue(response.extract().body().asByteArray().length > 0, "Avatar Image not uploaded"); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberCoreTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberCoreTests.java index 536dd36b3..71c5eb18a 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberCoreTests.java @@ -37,7 +37,7 @@ public class DeleteSiteMemberCoreTests extends RestTest privateSiteModel = dataSite.usingUser(adminUserModel).createPrivateRandomSite(); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user removes a site member using '-me-' in place of personId and response is successful (204)") public void removeSiteMemberWithSuccessUsingMeAsPersonId() throws Exception { @@ -47,22 +47,7 @@ public class DeleteSiteMemberCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user can't remove a site membership if doesn't have access to personId and response is 422") - public void notAbleToRemoveSiteMemberWithNoAccessToPersonId() throws Exception - { - UserModel user = dataUser.createRandomTestUser(); - dataSite.usingUser(user).createPublicRandomSite(); - - userModel.setUserRole(UserRole.SiteCollaborator); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(userModel); - - restClient.authenticateUser(user).withCoreAPI().usingUser(userModel).deleteSiteMember(publicSiteModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() - .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user can't remove a site membership of an inexistent uer and response is 404") public void userIsNotAbleToRemoveInexistentSiteMember() throws Exception { @@ -72,7 +57,7 @@ public class DeleteSiteMemberCoreTests extends RestTest .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, inexistentUser.getUsername())); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove a member of an inexistent site and response is 404") public void userIsNotAbleToRemoveMembershipOfInexistentSite() throws Exception { @@ -82,7 +67,7 @@ public class DeleteSiteMemberCoreTests extends RestTest .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, userModel.getUsername(), inexistentSite.getId())); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove a member of an empty site id and response is 404") public void userIsNotAbleToRemoveMembershipOfEmptySiteId() throws Exception { @@ -91,18 +76,7 @@ public class DeleteSiteMemberCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.DELETE_EMPTY_ARGUMENT); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove a regular member of a public site and response is 422") - public void regularUserIsNotAbleToRemoveRegularUserSiteMembershipFromPublicSite() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(secondUserModel); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(userModel); - restClient.authenticateUser(secondUserModel).withCoreAPI().usingUser(userModel).deleteSiteMember(publicSiteModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() - .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove a regular member a moderated site and response is 422") public void regularUserIsNotAbleToRemoveRegularUserSiteMembershipFromModeratedSite() throws Exception { @@ -113,7 +87,7 @@ public class DeleteSiteMemberCoreTests extends RestTest .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, moderatedSiteModel.getId())); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove a regular member of a private site and response is 422") public void regularUserIsNotAbleToRemoveRegularUserSiteMembershipFromPrivateSite() throws Exception { @@ -124,16 +98,7 @@ public class DeleteSiteMemberCoreTests extends RestTest .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, privateSiteModel.getId())); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove a regular member of a public site and response is 204") - public void adminIsAbleToRemoveRegularUserSiteMembershipFromPublicSite() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(userModel); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(userModel).deleteSiteMember(publicSiteModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove a regular member of a moderated site and response is 204") public void adminIsAbleToRemoveRegularUserSiteMembershipFromModeratedSite() throws Exception { @@ -142,7 +107,7 @@ public class DeleteSiteMemberCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove a regular member of a private site and response is 204") public void adminIsAbleToRemoveRegularUserSiteMembershipFromPrivateSite() throws Exception { @@ -151,7 +116,7 @@ public class DeleteSiteMemberCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove admin membership from public site and response is 422") public void regularUserIsNotAbleToRemoveAdminSiteMembershipFromPublicSite() throws Exception { @@ -162,7 +127,7 @@ public class DeleteSiteMemberCoreTests extends RestTest .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove admin membership from moderated site and response is 422") public void regularUserIsNotAbleToRemoveAdminSiteMembershipFromModeratedSite() throws Exception { @@ -173,7 +138,7 @@ public class DeleteSiteMemberCoreTests extends RestTest .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, moderatedSiteModel.getId())); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove admin membership from private site and response is 422") public void regularUserIsNotAbleToRemoveAdminSiteMembershipFromPrivateSite() throws Exception { @@ -184,7 +149,7 @@ public class DeleteSiteMemberCoreTests extends RestTest .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, privateSiteModel.getId())); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove the membership of a manager from a public site and response is 204") public void adminIsAbleToRemoveManagerSiteMembershipOfPublicSite() throws Exception { @@ -196,7 +161,7 @@ public class DeleteSiteMemberCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove the membership of a manager from a moderated site and response is 204") public void adminIsAbleToRemoveManagerSiteMembershipOfModeratedSite() throws Exception { @@ -208,7 +173,7 @@ public class DeleteSiteMemberCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove the membership of a manager from a private site and response is 204") public void adminIsAbleToRemoveManagerSiteMembershipOfPrivateSite() throws Exception { @@ -220,7 +185,7 @@ public class DeleteSiteMemberCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify collaborator is not able to remove the membership of a manager from a public site and response is 204") public void userIsNotAbleToRemoveManagerSiteMembershipOfPublicSite() throws Exception { @@ -234,7 +199,7 @@ public class DeleteSiteMemberCoreTests extends RestTest .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify collaborator is not able to remove the membership of a manager from a moderated site and response is 204") public void userIsNotAbleToRemoveManagerSiteMembershipOfModeratedSite() throws Exception { @@ -248,7 +213,7 @@ public class DeleteSiteMemberCoreTests extends RestTest .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, moderatedSiteModel.getId())); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify collaborator is not able to remove the membership of a manager from a private site and response is 204") public void userIsNotAbleToRemoveManagerSiteMembershipOfPrivateSite() throws Exception { diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberFullTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberFullTests.java index a0bbf187d..85315e3a4 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberFullTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberFullTests.java @@ -41,7 +41,7 @@ public class DeleteSiteMemberFullTests extends RestTest UserRole.SiteContributor); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove collaborator member of a public site") public void adminIsAbleToRemoveCollaboratorSiteMembershipFromPublicSite() throws Exception { @@ -49,8 +49,8 @@ public class DeleteSiteMemberFullTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteCollaborator)); } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove contributor member of a public site") public void adminIsAbleToRemoveContributorSiteMembershipFromPublicSite() throws Exception { @@ -58,17 +58,8 @@ public class DeleteSiteMemberFullTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteContributor)); } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove consumer member of a public site") - public void adminIsAbleToRemoveConsumerSiteMembershipFromPublicSite() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteConsumer)).deleteSiteMember(publicSiteModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteConsumer)); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove contributor member of a public site and response is 422") public void userIsNotAbleToRemoveContributorSiteMembershipFromPublicSite() throws Exception { @@ -76,8 +67,8 @@ public class DeleteSiteMemberFullTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove consumer member of a public site and response is 422") public void userIsNotAbleToRemoveConsumerSiteMembershipFromPublicSite() throws Exception { @@ -85,8 +76,8 @@ public class DeleteSiteMemberFullTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove collaborator member of a moderated site") public void adminIsAbleToRemoveCollaboratorSiteMembershipFromModeratedSite() throws Exception { @@ -94,8 +85,8 @@ public class DeleteSiteMemberFullTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(usersWithRolesModeratedSite.getOneUserWithRole(UserRole.SiteCollaborator)); } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove contributor member of a moderated site") public void adminIsAbleToRemoveContributorSiteMembershipFromModeratedSite() throws Exception { @@ -103,17 +94,8 @@ public class DeleteSiteMemberFullTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(usersWithRolesModeratedSite.getOneUserWithRole(UserRole.SiteContributor)); } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove consumer member of a moderated site") - public void adminIsAbleToRemoveConsumerSiteMembershipFromModeratedSite() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(usersWithRolesModeratedSite.getOneUserWithRole(UserRole.SiteConsumer)).deleteSiteMember(moderatedSiteModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(usersWithRolesModeratedSite.getOneUserWithRole(UserRole.SiteConsumer)); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove contributor member of a moderated site and response is 422") public void userIsNotAbleToRemoveContributorSiteMembershipFromModeratedSite() throws Exception { @@ -121,8 +103,8 @@ public class DeleteSiteMemberFullTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, moderatedSiteModel.getId())); } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove consumer member of a moderated site and response is 422") public void userIsNotAbleToRemoveConsumerSiteMembershipFromModeratedSite() throws Exception { @@ -130,8 +112,8 @@ public class DeleteSiteMemberFullTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, moderatedSiteModel.getId())); } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove collaborator member of a private site") public void adminIsAbleToRemoveCollaboratorSiteMembershipFromPrivateSite() throws Exception { @@ -139,8 +121,8 @@ public class DeleteSiteMemberFullTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(usersWithRolesPrivateSite.getOneUserWithRole(UserRole.SiteCollaborator)); } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove contributor member of a private site") public void adminIsAbleToRemoveContributorSiteMembershipFromPrivateSite() throws Exception { @@ -148,17 +130,8 @@ public class DeleteSiteMemberFullTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(usersWithRolesPrivateSite.getOneUserWithRole(UserRole.SiteContributor)); } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove consumer member of a private site") - public void adminIsAbleToRemoveConsumerSiteMembershipFromPrivateSite() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(usersWithRolesPrivateSite.getOneUserWithRole(UserRole.SiteConsumer)).deleteSiteMember(privateSiteModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(usersWithRolesPrivateSite.getOneUserWithRole(UserRole.SiteConsumer)); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove contributor member of a private site and response is 422") public void userIsNotAbleToRemoveContributorSiteMembershipFromPrivateSite() throws Exception { @@ -167,7 +140,7 @@ public class DeleteSiteMemberFullTests extends RestTest .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, privateSiteModel.getId())); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove consumer member of a private site and response is 422") public void userIsNotAbleToRemoveConsumerSiteMembershipFromPrivateSite() throws Exception { @@ -176,7 +149,7 @@ public class DeleteSiteMemberFullTests extends RestTest .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, privateSiteModel.getId())); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is not able to remove same user twice and response is 400") @Bug(id="ACE-5447") public void adminIsNotAbleToRemoveSameUserTwice() throws Exception @@ -191,7 +164,7 @@ public class DeleteSiteMemberFullTests extends RestTest .assertSiteMemberHasRole(UserRole.SiteCollaborator); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify single manager is not able to delete himself and response is 400") public void lastManagerIsNotAbleToDeleteHimself() throws Exception { @@ -209,7 +182,7 @@ public class DeleteSiteMemberFullTests extends RestTest .assertThat().entriesListContains("id", usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteManager).getUsername()); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site creator can be deleted") public void siteCreatorCanBeDeleted() throws Exception { @@ -219,7 +192,7 @@ public class DeleteSiteMemberFullTests extends RestTest restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMembers().assertThat().entriesListContains("id", adminUserModel.getUsername()); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is not able to remove from site a user that created a member request that was not accepted yet") @Bug(id="ACE-5447") public void adminIsNotAbleToRemoveFromSiteANonExistingMember() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java index 3c15d11d0..589c4b6ef 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java @@ -69,8 +69,8 @@ public class DeleteSiteMemberSanityTests extends RestTest .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getId())); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site contributor does not have permission to delete another member of the site") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site contributor does not have permission to delete another member of the site") public void siteContributorIsNotAbleToDeleteSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception { UserModel newUser = dataUser.createRandomTestUser("testUser"); @@ -83,8 +83,8 @@ public class DeleteSiteMemberSanityTests extends RestTest .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getId())); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site consumer does not have permission to delete another member of the site") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site consumer does not have permission to delete another member of the site") public void siteConsumerIsNotAbleToDeleteSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception { UserModel newUser = dataUser.createRandomTestUser("testUser"); @@ -97,8 +97,8 @@ public class DeleteSiteMemberSanityTests extends RestTest .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getId())); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to delete another member of the site") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify unauthenticated user is not able to delete another member of the site") public void unauthenticatedUserIsNotAbleToDeleteSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception { restClient.authenticateUser(new UserModel("random user", "random password")); diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleCoreTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleCoreTests.java index 3d814d594..a209dc427 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleCoreTests.java @@ -36,8 +36,8 @@ public class GetPeopleCoreTests extends RestTest dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); inexistentUser = new UserModel("inexistentUser", "password"); } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify inexistent user cannot get a person with Rest API and response is 401") public void inexistentUserIsUnauthorizedToGetPerson() throws Exception { @@ -45,8 +45,8 @@ public class GetPeopleCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); restClient.assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot get a person that doesn't exists with Rest API and response is 404") public void userCannotGetInexistentPerson() throws Exception { diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleFullTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleFullTests.java index 411260b41..b3e51ece1 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleFullTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleFullTests.java @@ -24,7 +24,6 @@ public class GetPeopleFullTests extends RestTest UserModel searchedUser, managerUser; UserModel adminUser; private RestPersonModel personModel; - private String domain = "@tas-automation.org"; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception @@ -36,20 +35,8 @@ public class GetPeopleFullTests extends RestTest managerUser = dataUser.usingAdmin().createRandomTestUser(); dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user gets person using '-me-' instead of personId with Rest API and response is successful") - public void checkGetPersonIsSuccessfulForMe() throws Exception - { - personModel = restClient.authenticateUser(managerUser).withCoreAPI().usingMe().getPerson(); - restClient.assertStatusCodeIs(HttpStatus.OK); - personModel.assertThat().field("id").is(managerUser.getUsername()) - .and().field("firstName").is(managerUser.getUsername() + " FirstName") - .and().field("email").is(managerUser.getUsername() + domain) - .and().field("emailNotificationsEnabled").is("true"); - } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @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 { @@ -77,7 +64,7 @@ public class GetPeopleFullTests extends RestTest .and().field("emailNotificationsEnabled").is(newUser.getEmailNotificationsEnabled()); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @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 special chars in username with Rest API and response is not found") public void userChecksIfPersonWithSpecilCharsInUsernameIsNotFound() throws Exception { @@ -93,7 +80,7 @@ public class GetPeopleFullTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @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 { @@ -104,7 +91,7 @@ public class GetPeopleFullTests extends RestTest persons.assertThat().entriesListIsNotEmpty(); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @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 { diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipCoreTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipCoreTests.java index 9ccb41f7d..a1ed9384e 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipCoreTests.java @@ -43,17 +43,7 @@ public class GetSiteMembershipCoreTests extends RestTest dataUser.usingAdmin().addUserToSite(moderatedSiteManager, moderatedSite, UserRole.SiteManager); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify request using -me- string in place of personId returns site membership information for currently authenticated user.") - public void getSiteMembershipUsingMe() throws Exception - { - restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)); - restSiteEntry = restClient.withCoreAPI().usingMe().getSiteMembership(publicSite); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteEntry.assertThat().field("role").is(UserRole.SiteCollaborator).and().field("id").is(publicSite.getId()).and().field("site").isNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) // @Bug(id = "REPO-1642", description = "reproduced on 5.2.1 only, it works on 5.2.0") @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify get site membership for a site returns status 404 when personId does not exist.") public void getSiteMembershipUsingNonExistentPersonId() throws Exception @@ -64,7 +54,7 @@ public class GetSiteMembershipCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "someUser")); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify get site membership for a site returns status 404 when siteId does not exist.") public void getSiteMembershipUsingNonExistentSiteId() throws Exception { @@ -75,7 +65,7 @@ public class GetSiteMembershipCoreTests extends RestTest .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, regularUser.getUsername(), "someSite")); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify get site membership for a site returns status 404 when personId is not a site member.") public void getSiteMembershipForPersonThatIsNotSiteMember() throws Exception { @@ -84,7 +74,7 @@ public class GetSiteMembershipCoreTests extends RestTest .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, regularUser.getUsername(), publicSite.getTitle())); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify regular user is not able to retrieve site membership information of a private site member.") public void regularUserIsNotAbleToRetrieveSiteMembershipForPrivateSiteManager() throws Exception { @@ -93,7 +83,7 @@ public class GetSiteMembershipCoreTests extends RestTest .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, privateSiteManager.getUsername(), privateSite.getTitle())); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify regular user is able to retrieve site membership information of a moderated site member.") public void regularUserGetsSiteMembershipForModeratedSiteMember() throws Exception { @@ -102,16 +92,7 @@ public class GetSiteMembershipCoreTests extends RestTest restSiteEntry.assertThat().field("role").is(UserRole.SiteManager).and().field("id").is(moderatedSite.getId()).and().field("site").isNotEmpty(); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify regular user is able to retrieve site membership information of a public site member.") - public void regularUserGetsSiteMembershipForPublicSiteMember() throws Exception - { - restSiteEntry = restClient.authenticateUser(regularUser).withCoreAPI().usingUser(publicSiteManager).getSiteMembership(publicSite); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteEntry.assertThat().field("role").is(UserRole.SiteManager).and().field("id").is(publicSite.getId()).and().field("site").isNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify if Admin user is able to retrieve site membership information of him.") public void adminGetsSiteMembershipForHim() throws Exception { @@ -120,7 +101,7 @@ public class GetSiteMembershipCoreTests extends RestTest restSiteEntry.assertThat().field("role").is(UserRole.SiteManager).and().field("id").is(privateSite.getId()).and().field("site").isNotEmpty(); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify if Admin user is able to retrieve site membership information of him.") public void getSiteMembershipAfterRemovingASiteMember() throws Exception { diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipFullTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipFullTests.java index f27644f74..7ad0ae6f9 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipFullTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipFullTests.java @@ -32,8 +32,8 @@ public class GetSiteMembershipFullTests extends RestTest publicSiteUsers = dataUser.addUsersWithRolesToSite(publicSite, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify that properties parameter is applied.") public void checkThatPropertiesParameterIsApplied() throws Exception { @@ -45,8 +45,8 @@ public class GetSiteMembershipFullTests extends RestTest .and().field("site").isNotEmpty() .and().field("guid").isNull(); } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify that regular user " + "is able to retrieve site membership information of admin.") public void regularUserGetsSiteMembershipForAdmin() throws Exception @@ -57,8 +57,8 @@ public class GetSiteMembershipFullTests extends RestTest .and().field("id").is(publicSite.getId()) .and().field("site.id").is(publicSite.getId()); } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify that regular user " + "is able to retrieve site membership details for a Collaborator role.") public void getSiteMembershipDetailsForACollaboratorRole() throws Exception @@ -76,8 +76,8 @@ public class GetSiteMembershipFullTests extends RestTest .and().field("site.preset").is("site-dashboard") .and().field("site.title").is(publicSite.getTitle()); } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify that regular user " + "is able to retrieve site membership details for a Contributor role.") public void getSiteMembershipDetailsForAContributorRole() throws Exception @@ -89,8 +89,8 @@ public class GetSiteMembershipFullTests extends RestTest .and().field("id").is(publicSite.getId()) .and().field("site").isNotEmpty(); } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify that regular user " + "is able to retrieve site membership details for a Consumer role.") public void getSiteMembershipDetailsForAConsumerRole() throws Exception @@ -102,8 +102,8 @@ public class GetSiteMembershipFullTests extends RestTest .and().field("id").is(publicSite.getId()) .and().field("site").isNotEmpty(); } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "As regular user make a request to join a moderated site." + " The request is pending. Check membership details.") public void pendingRequestToASiteCheckMembershipDetails() throws Exception @@ -116,8 +116,8 @@ public class GetSiteMembershipFullTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, regularUser.getUsername(), moderatedSite.getTitle())); } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "As Collaborator user leave site and perform get call." + "Check default error model schema.") public void leaveSiteAndPerformGetCallCheckDefaultErrorModelSchema() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationCoreTests.java b/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationCoreTests.java index 07878cf0a..16a91b969 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationCoreTests.java @@ -32,16 +32,7 @@ public class GetSitesMembershipInformationCoreTests extends RestTest dataUser.addUserToSite(leaveSiteUserModel, publicSiteModel, UserRole.SiteCollaborator); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site manager is able to retrieve site membership information with -me- as personId") - public void siteManagerCanRetrieveSiteMembershipInformationWithMeAsPersonId() throws Exception - { - restClient.authenticateUser(userModel).withCoreAPI().usingMe().getSitesMembershipInformation().assertThat().entriesListIsNotEmpty().and() - .paginationExist().and().paginationField("count").isNot("0"); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site manager is not able to retrieve site membership information for a personId that does not exist") public void siteManagerCantRetrieveSiteMembershipInformationForAPersonIdThatDoesNotExist() throws Exception { @@ -54,7 +45,7 @@ public class GetSitesMembershipInformationCoreTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify if get site membership information request returns status code 400 when invalid maxItems parameter is used") public void getSiteMembershipInformationRequestReturns400ForInvalidMaxItemsParameter() throws Exception { @@ -72,7 +63,7 @@ public class GetSitesMembershipInformationCoreTests extends RestTest restClient.assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "test")); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify if get site membership information request returns status code 200 for valid maxItems parameter") public void getSiteMembershipInformationRequestReturns200ForValidMaxItemsParameter() throws Exception { @@ -81,7 +72,7 @@ public class GetSitesMembershipInformationCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify if get site membership information request returns status code 400 when invalid skipCount parameter is used") public void getSiteMembershipInformationRequestReturns400ForInvalidSkipCountParameter() throws Exception { @@ -98,7 +89,7 @@ public class GetSitesMembershipInformationCoreTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify if get site membership information request returns status code 200 for valid skipCount parameter") public void getSiteMembershipInformationRequestReturns200ForValidSkipCountParameter() throws Exception { @@ -107,7 +98,7 @@ public class GetSitesMembershipInformationCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site manager is able to retrieve public sites") public void siteManagerCheckThatPublicSitesAreRetrieved() throws Exception { @@ -116,7 +107,7 @@ public class GetSitesMembershipInformationCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site manager is able to retrieve moderated sites") public void siteManagerCheckThatModeratedSitesAreRetrieved() throws Exception { @@ -125,7 +116,7 @@ public class GetSitesMembershipInformationCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site manager is able to retrieve private sites") public void siteManagerCheckThatPrivateSitesAreRetrieved() throws Exception { @@ -134,7 +125,7 @@ public class GetSitesMembershipInformationCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site member is able to leave site") public void siteMemberIsAbleToLeaveSite() throws Exception { diff --git a/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationFullTests.java b/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationFullTests.java index 9abef3e7e..856f8bf28 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationFullTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationFullTests.java @@ -43,7 +43,7 @@ public class GetSitesMembershipInformationFullTests extends RestTest dataUser.addUserToSite(anotherUserModel, anotherUserSite, UserRole.SiteCollaborator); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify if get site membership information request returns status code 200 for valid properties parameter") public void getSiteMembershipInformationUsingPropertiesParameter() throws Exception @@ -58,8 +58,8 @@ public class GetSitesMembershipInformationFullTests extends RestTest .and().entriesListDoesNotContain("role") .and().entriesListDoesNotContain("guid"); } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify if get site membership information request returns status code 200 for order ASC by parameter") public void getSiteMembershipInformationUsingOrderAscByParameter() throws Exception @@ -69,8 +69,8 @@ public class GetSitesMembershipInformationFullTests extends RestTest sitesMembershipInformation.assertThat().entriesListIsNotEmpty().getPagination().assertThat().field("count").is("3"); sitesMembershipInformation.assertThat().entriesListIsSortedAscBy("id"); } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify if get site membership information request returns status code 200 for order DESC by parameter") public void getSiteMembershipInformationUsingOrderDescByParameter() throws Exception @@ -80,19 +80,8 @@ public class GetSitesMembershipInformationFullTests extends RestTest sitesMembershipInformation.assertThat().entriesListIsNotEmpty().getPagination().assertThat().field("count").is("3"); sitesMembershipInformation.assertThat().entriesListIsSortedDescBy("id"); } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify if get site membership information request returns status code 200 for order by parameter") - public void getSiteMembershipInformationUsingOrderByParameter() throws Exception - { - sitesMembershipInformation = restClient.authenticateUser(userModel).withParams("orderBy=id").withCoreAPI().usingAuthUser().getSitesMembershipInformation(); - restClient.assertStatusCodeIs(HttpStatus.OK); - sitesMembershipInformation.assertThat().entriesListIsNotEmpty().getPagination().assertThat().field("count").is("3"); - sitesMembershipInformation.assertThat().entriesListIsSortedAscBy("id"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify if get site membership information request returns status code 200 for order by role parameter") public void getSiteMembershipInformationUsingOrderByRoleParameter() throws Exception @@ -102,8 +91,8 @@ public class GetSitesMembershipInformationFullTests extends RestTest sitesMembershipInformation.assertThat().entriesListIsNotEmpty().getPagination().assertThat().field("count").is("3"); sitesMembershipInformation.assertThat().entriesListIsSortedAscBy("role"); } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify if user gets site membership information of another user successfully") public void userCanGetSiteMembershipInformationOfAnotherUser() throws Exception @@ -122,8 +111,8 @@ public class GetSitesMembershipInformationFullTests extends RestTest .and().field("guid").is(anotherUserSite.getGuid()) .and().field("role").is(UserRole.SiteCollaborator.toString()); } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify if get site membership information request returns status code 200 for relations parameter") public void getSiteMembershipInformationUsingRelationsParameter() throws Exception @@ -132,8 +121,8 @@ public class GetSitesMembershipInformationFullTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); sitesMembershipInformation.assertThat().entriesListIsNotEmpty().getPagination().assertThat().field("count").is("3"); } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify get site membership information request when a site membership request is rejected") public void getSiteMembershipInformationWhenASiteRequestIsRejected() throws Exception @@ -156,8 +145,8 @@ public class GetSitesMembershipInformationFullTests extends RestTest sitesMembershipInformation.assertThat().entriesListIsEmpty() .and().paginationField("count").is("0"); } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify get site membership information request when a site membership request is approved") public void getSiteMembershipInformationWhenASiteRequestIsAppropved() throws Exception @@ -183,8 +172,8 @@ public class GetSitesMembershipInformationFullTests extends RestTest .and().entriesListContains("id", moderatedSiteModel.getId()) .and().paginationField("count").is("1"); } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify if get site membership information request returns status code 200 for valid maxItems parameter") public void getSiteMembershipInformationUsingMaxItemsParameter() throws Exception @@ -198,8 +187,8 @@ public class GetSitesMembershipInformationFullTests extends RestTest .and().field("skipCount").is("0") .and().field("maxItems").is("2"); } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify if get site membership information request returns status code 200 for valid skipCount parameter") public void getSiteMembershipInformationUsingSkipCountParameter() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/people/activities/GetPeopleActivitiesCoreTests.java b/e2e-test/java/org/alfresco/rest/people/activities/GetPeopleActivitiesCoreTests.java index 2185521e3..bdc7d7dd6 100644 --- a/e2e-test/java/org/alfresco/rest/people/activities/GetPeopleActivitiesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/activities/GetPeopleActivitiesCoreTests.java @@ -50,7 +50,7 @@ public class GetPeopleActivitiesCoreTests extends RestTest restActivityModelsCollection.assertThat().paginationField("count").is("4"); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot get activities for inexistent user with Rest API and response is 404") public void userCannotGetPeopleActivitiesForInexistentPersonId() throws Exception { @@ -64,7 +64,7 @@ public class GetPeopleActivitiesCoreTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its activities for inexistent siteId with Rest API and response is 404") public void userGetItsPeopleActivitiesForInexistentSite() throws Exception { @@ -76,7 +76,7 @@ public class GetPeopleActivitiesCoreTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities with invald skipCount parameter with Rest API and response is 400") public void userGetPeopleActivitiesUsingInvalidSkipCountParameter() throws Exception { @@ -88,7 +88,7 @@ public class GetPeopleActivitiesCoreTests extends RestTest .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities with invalid maxItems parameter with Rest API and response is 400") public void userGetPeopleActivitiesUsingInvalidMaxItemsParameter() throws Exception { @@ -100,7 +100,7 @@ public class GetPeopleActivitiesCoreTests extends RestTest .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities using invalid value for parameter 'who'with Rest API and response is 400") public void userGetsPeopleActivitiesUsingInvalidValueForWhoParameter() throws Exception { @@ -112,7 +112,7 @@ public class GetPeopleActivitiesCoreTests extends RestTest .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities successfully using parameter 'who' with 'others' value with Rest API") public void userGetsPeopleActivitiesUsingOthersForWhoParameter() throws Exception { diff --git a/e2e-test/java/org/alfresco/rest/people/activities/GetPeopleActivitiesFullTests.java b/e2e-test/java/org/alfresco/rest/people/activities/GetPeopleActivitiesFullTests.java index 068b81fef..1abd5a4e7 100644 --- a/e2e-test/java/org/alfresco/rest/people/activities/GetPeopleActivitiesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/people/activities/GetPeopleActivitiesFullTests.java @@ -1,15 +1,11 @@ package org.alfresco.rest.people.activities; -import java.util.ArrayList; -import java.util.List; - import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestActivityModel; import org.alfresco.rest.model.RestActivityModelsCollection; import org.alfresco.rest.model.RestActivitySummaryModel; import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.utility.constants.ActivityType; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FolderModel; @@ -20,7 +16,6 @@ import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; -import org.testng.Assert; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -57,28 +52,8 @@ public class GetPeopleActivitiesFullTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); restActivityModelsCollection.assertThat().paginationField("count").is("4"); } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its activities using me with Rest API and response is successful") - public void userGetsItsPeopleActivitiesUsingMe() throws Exception - { - restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingMe().getPersonActivities(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restActivityModelsCollection.assertThat().paginationField("count").is("4"); - - List allActivitySummary = new ArrayList(); - for (RestActivityModel activityModel: restActivityModelsCollection.getEntries()) - { - allActivitySummary.add(activityModel.onModel().getActivitySummary()); - } - - assertActivitySummaryTitleIsPresent(allActivitySummary, fileInSite1.getName()); - assertActivitySummaryTitleIsPresent(allActivitySummary, folderInSite2.getName()); - assertActivitySummaryTitleIsPresent(allActivitySummary, fileInSite2.getName()); - restActivityModelsCollection.assertThat().entriesListContains("activityType", ActivityType.USER_JOINED.toString()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.FULL }) + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify activity summary from user gets activities response with Rest API") public void userGetPeopleActivitiesWithActivitySummaryCheck() throws Exception { @@ -91,9 +66,9 @@ public class GetPeopleActivitiesFullTests extends RestTest .and().field("title").is(fileInSite1.getName()) .and().field("objectId").is(fileInSite1.getNodeRefWithoutVersion()); } - + @Bug(id = "REPO-1911") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE,TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot get activities for empty user with Rest API and response is 400") public void userCannotGetPeopleActivitiesForEmptyPersonId() throws Exception { @@ -106,20 +81,8 @@ public class GetPeopleActivitiesFullTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE) .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities successfully using parameter 'who' with 'me' value with Rest API") - public void userGetsPeopleActivitiesUsingMeForWhoParameter() throws Exception - { - restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingUser(userModel).usingParams("who=me").getPersonActivities(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restActivityModelsCollection.assertThat().paginationField("count").is("2"); - restActivityModelsCollection.assertThat().entriesListContains("postPersonId", userModel.getUsername().toLowerCase()) - .and().entriesListDoesNotContain("postPersonId", adminUser.getUsername().toLowerCase()) - .and().entriesListDoesNotContain("postPersonId", managerUser.getUsername().toLowerCase()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.FULL }) + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE,TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its activities for siteId specified in siteId parameter using me with Rest API and response is successful") public void userGetItsPeopleActivitiesForASpecificSite() throws Exception { @@ -129,8 +92,8 @@ public class GetPeopleActivitiesFullTests extends RestTest restActivityModelsCollection.assertThat().entriesListContains("siteId", siteModel1.getId()) .and().entriesListDoesNotContain("siteId", siteModel2.getId()); } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.FULL }) + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities for user with no activities with Rest API and response is successful") public void userGetPeopleActivitiesForUserWithNoActivities() throws Exception { @@ -142,20 +105,8 @@ public class GetPeopleActivitiesFullTests extends RestTest restActivityModelsCollection.assertThat().paginationField("count").is("0"); restActivityModelsCollection.assertThat().entriesListIsEmpty(); } - - private void assertActivitySummaryTitleIsPresent(List allActivitySummary, String title) - { - for (RestActivitySummaryModel activitySummary: allActivitySummary) - { - if (activitySummary.getTitle().equals(title)) - { - Assert.assertEquals(activitySummary.getTitle(), title, String.format("%s title was not found in Activity Summary", title)); - break; - } - } - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.FULL }) + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot get activities for siteId that user doesn't have access to with Rest API and response is not found") public void userGetPeopleActivitiesForASiteWithNoAccess() throws Exception { @@ -165,8 +116,8 @@ public class GetPeopleActivitiesFullTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); restClient.assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, siteNoAccess.getId())); } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.FULL }) + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot get activities for another user with Rest API and response is permission denied") public void userGetPeopleActivitiesForAnotherUser() throws Exception { @@ -174,8 +125,8 @@ public class GetPeopleActivitiesFullTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); restClient.assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.FULL }) + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities with properties parameter applied with Rest API and response is successful") public void userGetPeopleActivitiesUsingPropertiesParameter() throws Exception { @@ -192,8 +143,8 @@ public class GetPeopleActivitiesFullTests extends RestTest .and().entriesListDoesNotContain("id") .and().entriesListDoesNotContain("activityType"); } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.FULL }) + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities with skipCount parameter applied with Rest API and response is successful") public void userGetPeopleActivitiesUsingSkipCountParameter() throws Exception { @@ -211,8 +162,8 @@ public class GetPeopleActivitiesFullTests extends RestTest restActivityModelsCollection.getEntries().get(1).onModel().assertThat().field("postPersonId").is(expectedRestActivity4.getPostPersonId()) .and().field("activityType").is(expectedRestActivity4.getActivityType()); } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.FULL }) + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities with maxItems parameter applied with Rest API and response is successful") public void userGetPeopleActivitiesUsingMaxItemsParameter() throws Exception { diff --git a/e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferenceCoreTests.java b/e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferenceCoreTests.java index 3369dacc1..c67870cec 100644 --- a/e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferenceCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferenceCoreTests.java @@ -24,7 +24,7 @@ public class GetPeoplePreferenceCoreTests extends RestTest dataSite.usingUser(userModel).usingSite(siteModel).addSiteToFavorites(); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user is Forbidden to get a specific preference for another user with Rest API and response is 403") public void userDoesNotHaveAccessToFavoriteSitesOfAnotherUser() throws Exception { @@ -35,7 +35,7 @@ public class GetPeoplePreferenceCoreTests extends RestTest restClient.assertLastError().containsSummary("Permission was denied"); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify manager fails to get a specific preference for an invalid user with Rest API and response is 404") public void statusNotFoundIsReturnedForAPersonIDThatDoesNotExist() throws Exception { @@ -45,7 +45,7 @@ public class GetPeoplePreferenceCoreTests extends RestTest restClient.assertLastError().containsSummary("The entity with id: invalidPersonID was not found"); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify manager fails to get a specific preference for an invalid preference with Rest API and response is 404") public void statusNotFoundIsReturnedForAPreferenceNameThatDoesNotExist() throws Exception { @@ -56,7 +56,7 @@ public class GetPeoplePreferenceCoreTests extends RestTest userModel.getUsername())); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify manager fails to get a specific preference for removed preference with Rest API and response is 404") public void statusNotFoundIsReturnedForAPreferenceNameThatHasBeenRemoved() throws Exception { diff --git a/e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferenceFullTests.java b/e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferenceFullTests.java index 4c90ab3a2..d760c3d1c 100644 --- a/e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferenceFullTests.java +++ b/e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferenceFullTests.java @@ -34,7 +34,7 @@ public class GetPeoplePreferenceFullTests extends RestTest dataSite.usingUser(userModel).usingSite(siteModel).addSiteToFavorites(); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Check default error schema in case of failure") public void checkDefaultErrorSchema() throws Exception @@ -48,21 +48,8 @@ public class GetPeoplePreferenceFullTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE) .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY); } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, - description = "Specify -me- string in place of for request") - public void preferenceIsReturnedWhenUsingMeAsPersonId() throws Exception - { - restPreferenceModel = restClient.authenticateUser(userModel).withCoreAPI().usingMe() - .getPersonPreferenceInformation(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())); - - restClient.assertStatusCodeIs(HttpStatus.OK); - restPreferenceModel.assertThat().field("id").is(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())) - .and().field("value").is("true"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Check that properties parameter is applied") public void propertiesParameterIsAppliedWhenRetrievingPreference() throws Exception @@ -80,7 +67,7 @@ public class GetPeoplePreferenceFullTests extends RestTest .and().field("value").is("true"); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Validate ID element in get site preference response") public void validateIdElementInGetSitePreferenceResponse() throws Exception @@ -91,7 +78,7 @@ public class GetPeoplePreferenceFullTests extends RestTest .and().field("value").is("true"); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Validate ID element in get folder preference response") public void validateIdElementInGetFolderPreferenceResponse() throws Exception @@ -106,7 +93,7 @@ public class GetPeoplePreferenceFullTests extends RestTest .and().field("value").is(Utility.removeLastSlash(Utility.buildPath("workspace://SpacesStore", folderFavorite.getNodeRef()))); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Validate ID element in get file preference response") public void validateIdElementInGetFilePreferenceResponse() throws Exception @@ -121,7 +108,7 @@ public class GetPeoplePreferenceFullTests extends RestTest .and().field("value").is(Utility.removeLastSlash(Utility.buildPath("workspace://SpacesStore", fileFavorite.getNodeRefWithoutVersion()))); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Get preference of an user that has no preferences") public void getPreferenceForUserWithoutPreferences() throws Exception @@ -147,10 +134,10 @@ public class GetPeoplePreferenceFullTests extends RestTest PreferenceName.SITES_FAVORITES_PREFIX.toString())); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Change one preference for an user then perform get call") - @Bug(id = "ACE-5736") +// @Bug(id = "ACE-5736") public void changePreferenceThenPerformGetPreferenceCall() throws Exception { UserModel newUser = dataUser.createRandomTestUser(); @@ -195,7 +182,7 @@ public class GetPeoplePreferenceFullTests extends RestTest PreferenceName.FOLDERS_FAVORITES_PREFIX.toString())); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to get preference of another user") public void adminIsAbleToGetOtherUserPreference() throws Exception @@ -206,7 +193,7 @@ public class GetPeoplePreferenceFullTests extends RestTest restPreferenceModel.assertThat().field("id").is(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())).and().field("value").is("true"); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify regular user is not able to get preference of admin user") public void regularUserIsNotAbleToGetAdminPreference() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferencesCoreTests.java b/e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferencesCoreTests.java index 1ec4a9e73..f4b42e8c7 100644 --- a/e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferencesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferencesCoreTests.java @@ -39,7 +39,7 @@ public class GetPeoplePreferencesCoreTests extends RestTest dataContent.usingUser(user1).usingSite(siteModel).addFolderToFavorites(folderModel); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its preferences with invalid maxItems parameter with Rest API and response is 400") public void userGetsPeoplePreferencesUsingInvalidMaxItemsParameter() throws Exception { @@ -51,7 +51,7 @@ public class GetPeoplePreferencesCoreTests extends RestTest .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its preferences with skipCount parameter applied with Rest API and response is successful") public void userGetsPeoplePreferencesUsingInvalidSkipCountParameter() throws Exception { @@ -63,7 +63,7 @@ public class GetPeoplePreferencesCoreTests extends RestTest .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user which doesn't have access to another user preferences fails to get its preferences with Rest API and response is permission denied") public void userWithNoAccessToOtherUserPreferencesIsForbiddenToGetItsPreferences() throws Exception { @@ -78,7 +78,7 @@ public class GetPeoplePreferencesCoreTests extends RestTest .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user fails to get preferences for inexistent personId with Rest API and response is 404") public void userCannotGetPeoplePreferencesForInexistentPersonId() throws Exception { @@ -92,7 +92,7 @@ public class GetPeoplePreferencesCoreTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user get preferences for a user with no preferences with Rest API and response is empty") public void userGetsPeoplePreferencesForUserWithNoPreferences() throws Exception { @@ -104,7 +104,7 @@ public class GetPeoplePreferencesCoreTests extends RestTest restPreferenceModelsCollection.assertThat().entriesListIsEmpty(); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user fails to get preferences for a removed preference with Rest API and response is 404") public void userFailsToGetPeoplePreferencesIfPreferenceWasRemoved() throws Exception { diff --git a/e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferencesFullTests.java b/e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferencesFullTests.java index 9cc6f55dd..1ad0050d1 100644 --- a/e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferencesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferencesFullTests.java @@ -39,24 +39,8 @@ public class GetPeoplePreferencesFullTests extends RestTest dataSite.usingUser(user1).usingSite(siteModel).addSiteToFavorites(); dataContent.usingUser(user1).usingSite(siteModel).addFolderToFavorites(folderModel); } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its preferences using me with Rest API and response is successful") - public void userGetsItsPeoplePreferencesUsingMe() throws Exception - { - restPreferenceModelsCollection = restClient.authenticateUser(user1).withCoreAPI().usingMe().getPersonPreferences(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restPreferenceModelsCollection.assertThat().paginationField("count").is("4"); - restPreferenceModelsCollection.assertThat().entriesListIsNotEmpty() - .and().entriesListContains("id", String.format(PreferenceName.EXT_FOLDERS_FAVORITES_PREFIX.toString(), "workspace://SpacesStore/" + folderModel.getNodeRef())) - .and().entriesListContains("id", String.format(PreferenceName.EXT_SITES_FAVORITES_PREFIX.toString(), siteModel.getId())) - .and().entriesListContains("id", PreferenceName.FOLDERS_FAVORITES_PREFIX.toString()) - .and().entriesListContains("value", "workspace://SpacesStore/" + folderModel.getNodeRef()) - .and().entriesListContains("id", String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())) - .and().entriesListContains("value", "true"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.FULL }) + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its preferences with skipCount parameter applied with Rest API and response is successful") public void userGetsItsPeoplePreferencesUsingSkipCountParameter() throws Exception { @@ -73,7 +57,7 @@ public class GetPeoplePreferencesFullTests extends RestTest .and().entriesListContains("value", "true"); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its preferences with maxItems parameter applied with Rest API and response is successful") public void userGetsItsPeoplePreferencesUsingMaxItemsParameter() throws Exception { @@ -90,7 +74,7 @@ public class GetPeoplePreferencesFullTests extends RestTest .and().entriesListDoesNotContain("value", "true"); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets admin preferences with Rest API and response is permission denied") public void userIsForbiddenToGetAdminPreferences() throws Exception { @@ -102,7 +86,7 @@ public class GetPeoplePreferencesFullTests extends RestTest .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its preferences with skipCount parameter higher then no of entries with Rest API and response is empty") public void userGetsItsPeoplePreferencesUsingHighSkipCount() throws Exception { @@ -113,8 +97,8 @@ public class GetPeoplePreferencesFullTests extends RestTest restPreferenceModelsCollection.assertThat().entriesListIsEmpty(); } - @Bug(id = "REPO-1911") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.FULL }) +// @Bug(id = "REPO-1911") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot get preferences for empty user with Rest API and response is 400") public void userGetsItsPeoplePreferencesForEmptyPersonId() throws Exception { diff --git a/e2e-test/java/org/alfresco/rest/renditions/CreateRenditionTests.java b/e2e-test/java/org/alfresco/rest/renditions/CreateRenditionTests.java index d5b58b4e0..29cd178c6 100644 --- a/e2e-test/java/org/alfresco/rest/renditions/CreateRenditionTests.java +++ b/e2e-test/java/org/alfresco/rest/renditions/CreateRenditionTests.java @@ -35,7 +35,7 @@ public class CreateRenditionTests extends RestTest { adminUser = dataUser.getAdminUser(); user = dataUser.createRandomTestUser(); - site = dataSite.usingUser(user).createPublicRandomSite(); + site = dataSite.usingUser(user).createPublicRandomSite(); } @BeforeMethod(alwaysRun = true) @@ -58,9 +58,9 @@ public class CreateRenditionTests extends RestTest } @Bug(id = "REPO-2042", description = "Should fail only on MAC OS System and Linux", status = Status.FIXED ) - @TestRail(section = { TestGroup.REST_API, TestGroup.RENDITIONS }, executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API, TestGroup.RENDITIONS }, executionType = ExecutionType.REGRESSION, description = "Verify user that created the document can also creates 'pdf' rendition for it with Rest API and status code is 202") - @Test(groups = { TestGroup.REST_API, TestGroup.RENDITIONS, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.RENDITIONS, TestGroup.REGRESSION }) public void userThatCreatedFileCanCreatePdfRenditionForIt() throws JsonToModelConversionException, Exception { restClient.authenticateUser(user).withCoreAPI().usingNode(document).createNodeRendition("pdf"); @@ -71,9 +71,9 @@ public class CreateRenditionTests extends RestTest } @Bug(id = "REPO-2042", description = "Should fail only on MAC OS System and Linux", status = Status.FIXED ) - @TestRail(section = { TestGroup.REST_API, TestGroup.RENDITIONS }, executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API, TestGroup.RENDITIONS }, executionType = ExecutionType.REGRESSION, description = "Verify user that created the document can also creates 'doclib' rendition for it with Rest API and status code is 202") - @Test(groups = { TestGroup.REST_API, TestGroup.RENDITIONS, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.RENDITIONS, TestGroup.REGRESSION }) public void userThatCreatedFileCanCreateDoclibRenditionForIt() throws JsonToModelConversionException, Exception { FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder(); diff --git a/e2e-test/java/org/alfresco/rest/renditions/GetRenditionTests.java b/e2e-test/java/org/alfresco/rest/renditions/GetRenditionTests.java index d5debda40..7424e6d63 100644 --- a/e2e-test/java/org/alfresco/rest/renditions/GetRenditionTests.java +++ b/e2e-test/java/org/alfresco/rest/renditions/GetRenditionTests.java @@ -35,7 +35,7 @@ public class GetRenditionTests extends RestTest public void dataPreparation() throws Exception { user = dataUser.createRandomTestUser(); - site = dataSite.usingUser(user).createPublicRandomSite(); + site = dataSite.usingUser(user).createPublicRandomSite(); } @Bug(id = "REPO-2449", status = Status.FIXED) diff --git a/e2e-test/java/org/alfresco/rest/sharedlinks/GetSharedLinksFullTests.java b/e2e-test/java/org/alfresco/rest/sharedlinks/GetSharedLinksFullTests.java index 40fd83e56..706963b02 100644 --- a/e2e-test/java/org/alfresco/rest/sharedlinks/GetSharedLinksFullTests.java +++ b/e2e-test/java/org/alfresco/rest/sharedlinks/GetSharedLinksFullTests.java @@ -36,7 +36,7 @@ public class GetSharedLinksFullTests extends RestTest @Bug(id="REPO-2365") @TestRail(section = { TestGroup.REST_API, TestGroup.SHAREDLINKS }, executionType = ExecutionType.REGRESSION, description = "Verify that a user with permission can get allowableOperations on sharedLinks") - @Test(groups = { TestGroup.REST_API, TestGroup.SHAREDLINKS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.REGRESSION }) public void getSharedLinksWithAllowableOperations() throws Exception { file = dataContent.usingUser(adminUser).usingSite(privateSite).createContent(DocumentType.TEXT_PLAIN); diff --git a/e2e-test/java/org/alfresco/rest/sharedlinks/SharedLinksSanityTests.java b/e2e-test/java/org/alfresco/rest/sharedlinks/SharedLinksSanityTests.java index 8e51ae808..17b1e5e9a 100644 --- a/e2e-test/java/org/alfresco/rest/sharedlinks/SharedLinksSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sharedlinks/SharedLinksSanityTests.java @@ -65,19 +65,8 @@ public class SharedLinksSanityTests extends RestTest file5 = dataContent.usingUser(adminUser).usingResource(folder1).createContent(DocumentType.TEXT_PLAIN); } - @TestRail(section = { TestGroup.REST_API, TestGroup.SHAREDLINKS }, executionType = ExecutionType.REGRESSION, description = "Verify empty sharedLinks with and without Path") - @Test(groups = { TestGroup.REST_API, TestGroup.SHAREDLINKS }) - public void testGetSharedLinksNoLinks() throws Exception - { - restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().getSharedLinks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - restClient.authenticateUser(testUser1).withCoreAPI().includePath().usingSharedLinks().getSharedLinks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.SHAREDLINKS }, executionType = ExecutionType.REGRESSION, description = "Verify create sharedLinks with and without Path") - @Test(groups = { TestGroup.REST_API, TestGroup.SHAREDLINKS }) + @TestRail(section = { TestGroup.REST_API, TestGroup.SHAREDLINKS }, executionType = ExecutionType.SANITY, description = "Verify create sharedLinks with and without Path") + @Test(groups = { TestGroup.REST_API, TestGroup.SANITY }) public void testCreateAndGetSharedLinks() throws Exception { // Post without includePath @@ -135,8 +124,8 @@ public class SharedLinksSanityTests extends RestTest Assert.assertNull(sharedLink2.getPath(), "Path is expected to be null for noauth api: Response shows: " + sharedLink2.toJson()); } - @TestRail(section = { TestGroup.REST_API, TestGroup.SHAREDLINKS }, executionType = ExecutionType.REGRESSION, description = "Verify delete sharedLinks with and without Path") - @Test(groups = { TestGroup.REST_API, TestGroup.SHAREDLINKS }) + @TestRail(section = { TestGroup.REST_API, TestGroup.SHAREDLINKS }, executionType = ExecutionType.SANITY, description = "Verify delete sharedLinks with and without Path") + @Test(groups = { TestGroup.REST_API, TestGroup.SANITY }) public void testDeleteSharedLinks() throws Exception { sharedLink3 = restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().createSharedLink(file3); @@ -149,7 +138,7 @@ public class SharedLinksSanityTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.SHAREDLINKS }, executionType = ExecutionType.REGRESSION, description = "Verify get sharedLink/content and get/renditions") - @Test(groups = { TestGroup.REST_API, TestGroup.SHAREDLINKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.REGRESSION }) public void testCreateWithExpiryDateAndGetSharedLinkRendition() throws Exception { sharedLink5 = restClient.authenticateUser(testUser1).withCoreAPI().includePath().usingSharedLinks().createSharedLinkWithExpiryDate(file5, expiryDate); From 0ceae75ca07d7112013158d86ca589d79ca52171 Mon Sep 17 00:00:00 2001 From: cagache Date: Mon, 9 Oct 2017 15:21:37 +0300 Subject: [PATCH 1235/1491] REPO-2755 / REPO-2251: changed CORE and FULL groups with REGRESSION in sites package --- .../alfresco/rest/sites/GetSiteCoreTests.java | 118 ---- .../alfresco/rest/sites/GetSiteFullTests.java | 230 ------- .../rest/sites/GetSiteSanityTests.java | 120 ---- .../org/alfresco/rest/sites/GetSiteTests.java | 362 +++++++++++ .../rest/sites/GetSitesCoreTests.java | 150 ----- .../rest/sites/GetSitesFullTests.java | 298 --------- .../rest/sites/GetSitesSanityTests.java | 117 ---- .../alfresco/rest/sites/GetSitesTests.java | 484 ++++++++++++++ .../org/alfresco/rest/sites/SitesTests.java | 2 +- .../containers/GetSiteContainerCoreTests.java | 107 --- .../containers/GetSiteContainerFullTests.java | 176 ----- .../GetSiteContainerSanityTests.java | 117 ---- .../containers/GetSiteContainerTests.java | 313 +++++++++ .../GetSiteContainersCoreTests.java | 219 ------- .../GetSiteContainersFullTests.java | 144 ----- .../GetSiteContainersSanityTests.java | 115 ---- .../containers/GetSiteContainersTests.java | 390 +++++++++++ .../sites/members/AddSiteMemberCoreTests.java | 310 --------- .../sites/members/AddSiteMemberFullTests.java | 256 -------- .../members/AddSiteMemberSanityTests.java | 118 ---- .../sites/members/AddSiteMemberTests.java | 589 +++++++++++++++++ .../sites/members/GetSiteMemberCoreTests.java | 175 ----- .../sites/members/GetSiteMemberFullTests.java | 192 ------ .../members/GetSiteMemberSanityTests.java | 112 ---- .../sites/members/GetSiteMemberTests.java | 396 ++++++++++++ .../members/GetSiteMembersCoreTests.java | 159 ----- .../members/GetSiteMembersFullTests.java | 160 ----- .../members/GetSiteMembersSanityTests.java | 111 ---- .../sites/members/GetSiteMembersTests.java | 357 ++++++++++ .../members/RemoveSiteMemberCoreTests.java | 269 -------- .../members/RemoveSiteMemberFullTests.java | 150 ----- .../members/RemoveSiteMemberSanityTests.java | 134 ---- .../sites/members/RemoveSiteMemberTests.java | 467 ++++++++++++++ .../members/UpdateSiteMemberCoreTests.java | 209 ------ .../members/UpdateSiteMemberFullTests.java | 279 -------- .../members/UpdateSiteMemberSanityTests.java | 138 ---- .../sites/members/UpdateSiteMemberTests.java | 546 ++++++++++++++++ .../AddSiteMembershipRequestCoreTests.java | 90 --- .../AddSiteMembershipRequestSanityTests.java | 95 --- ...ava => AddSiteMembershipRequestTests.java} | 199 ++++-- .../DeleteSiteMembershipRequestCoreTests.java | 148 ----- .../DeleteSiteMembershipRequestFullTests.java | 213 ------ ...eleteSiteMembershipRequestSanityTests.java | 137 ---- .../DeleteSiteMembershipRequestTests.java | 319 +++++++++ .../GetSiteMembershipRequestCoreTests.java | 144 ----- .../GetSiteMembershipRequestFullTests.java | 285 -------- .../GetSiteMembershipRequestSanityTests.java | 119 ---- .../GetSiteMembershipRequestTests.java | 380 +++++++++++ .../GetSiteMembershipRequestsCoreTests.java | 167 ----- .../GetSiteMembershipRequestsFullTests.java | 172 ----- .../GetSiteMembershipRequestsSanityTests.java | 121 ---- .../GetSiteMembershipRequestsTests.java | 371 +++++++++++ .../UpdateSiteMembershipRequestCoreTests.java | 134 ---- .../UpdateSiteMembershipRequestFullTests.java | 508 --------------- ...pdateSiteMembershipRequestSanityTests.java | 145 ----- .../UpdateSiteMembershipRequestTests.java | 610 ++++++++++++++++++ 56 files changed, 5748 insertions(+), 7198 deletions(-) delete mode 100644 e2e-test/java/org/alfresco/rest/sites/GetSiteCoreTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/sites/GetSiteFullTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/sites/GetSiteSanityTests.java create mode 100644 e2e-test/java/org/alfresco/rest/sites/GetSiteTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/sites/GetSitesFullTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java create mode 100644 e2e-test/java/org/alfresco/rest/sites/GetSitesTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/sites/containers/GetSiteContainerCoreTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/sites/containers/GetSiteContainerFullTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/sites/containers/GetSiteContainerSanityTests.java create mode 100644 e2e-test/java/org/alfresco/rest/sites/containers/GetSiteContainerTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/sites/containers/GetSiteContainersCoreTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/sites/containers/GetSiteContainersFullTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/sites/containers/GetSiteContainersSanityTests.java create mode 100644 e2e-test/java/org/alfresco/rest/sites/containers/GetSiteContainersTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/sites/members/AddSiteMemberCoreTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/sites/members/AddSiteMemberFullTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/sites/members/AddSiteMemberSanityTests.java create mode 100644 e2e-test/java/org/alfresco/rest/sites/members/AddSiteMemberTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/sites/members/GetSiteMemberCoreTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/sites/members/GetSiteMemberFullTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/sites/members/GetSiteMemberSanityTests.java create mode 100644 e2e-test/java/org/alfresco/rest/sites/members/GetSiteMemberTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/sites/members/GetSiteMembersCoreTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/sites/members/GetSiteMembersFullTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/sites/members/GetSiteMembersSanityTests.java create mode 100644 e2e-test/java/org/alfresco/rest/sites/members/GetSiteMembersTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/sites/members/RemoveSiteMemberCoreTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/sites/members/RemoveSiteMemberFullTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/sites/members/RemoveSiteMemberSanityTests.java create mode 100644 e2e-test/java/org/alfresco/rest/sites/members/RemoveSiteMemberTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/sites/members/UpdateSiteMemberCoreTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/sites/members/UpdateSiteMemberFullTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/sites/members/UpdateSiteMemberSanityTests.java create mode 100644 e2e-test/java/org/alfresco/rest/sites/members/UpdateSiteMemberTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/sites/membershipRequests/AddSiteMembershipRequestCoreTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/sites/membershipRequests/AddSiteMembershipRequestSanityTests.java rename e2e-test/java/org/alfresco/rest/sites/membershipRequests/{AddSiteMembershipRequestFullTests.java => AddSiteMembershipRequestTests.java} (65%) delete mode 100644 e2e-test/java/org/alfresco/rest/sites/membershipRequests/DeleteSiteMembershipRequestCoreTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/sites/membershipRequests/DeleteSiteMembershipRequestFullTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/sites/membershipRequests/DeleteSiteMembershipRequestSanityTests.java create mode 100644 e2e-test/java/org/alfresco/rest/sites/membershipRequests/DeleteSiteMembershipRequestTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestCoreTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestFullTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestSanityTests.java create mode 100644 e2e-test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestsCoreTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestsFullTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestsSanityTests.java create mode 100644 e2e-test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestsTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/sites/membershipRequests/UpdateSiteMembershipRequestCoreTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/sites/membershipRequests/UpdateSiteMembershipRequestFullTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/sites/membershipRequests/UpdateSiteMembershipRequestSanityTests.java create mode 100644 e2e-test/java/org/alfresco/rest/sites/membershipRequests/UpdateSiteMembershipRequestTests.java diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteCoreTests.java deleted file mode 100644 index e7123a90d..000000000 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteCoreTests.java +++ /dev/null @@ -1,118 +0,0 @@ -package org.alfresco.rest.sites; - -import org.alfresco.rest.RestTest; -import org.alfresco.rest.core.RestRequest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestSiteModel; -import org.alfresco.rest.model.RestSiteModelsCollection; -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; - -/** - * Created by Claudia Agache on 11/23/2016. - */ -public class GetSiteCoreTests extends RestTest -{ - private UserModel userModel, privateSiteConsumer; - private SiteModel publicSite, privateSite, moderatedSite; - private RestSiteModel restSiteModel; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - privateSiteConsumer = dataUser.createRandomTestUser(); - publicSite = dataSite.usingAdmin().createPublicRandomSite(); - privateSite = dataSite.usingAdmin().createPrivateRandomSite(); - moderatedSite = dataSite.usingAdmin().createModeratedRandomSite(); - dataUser.addUserToSite(privateSiteConsumer, privateSite, UserRole.SiteConsumer); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify invalid request returns status code 404 if siteId does not exist") - public void checkStatusCodeForNonExistentSiteId() throws Exception - { - restClient.authenticateUser(userModel).withCoreAPI() - .usingSite("NonExistentSiteId").getSite(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "NonExistentSiteId")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify user gets all public and moderated sites if an empty siteId is provided") - public void checkStatusCodeForEmptySiteId() throws Exception - { - restClient.authenticateUser(userModel).withCoreAPI(); - RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "sites/{siteId}", ""); - RestSiteModelsCollection sites = restClient.processModels(RestSiteModelsCollection.class, request); - restClient.assertStatusCodeIs(HttpStatus.OK); - sites.assertThat().entriesListIsNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if any user gets public site details and status code is 200") - public void getPublicSite() throws Exception - { - restSiteModel = restClient.authenticateUser(userModel).withCoreAPI() - .usingSite(publicSite).getSite(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModel.assertThat().field("visibility").is(publicSite.getVisibility()) - .and().field("id").is(publicSite.getId()) - .and().field("description").is(publicSite.getDescription()) - .and().field("title").is(publicSite.getTitle()) - .and().field("guid").isNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if any user gets moderated site details and status code is 200") - public void getModeratedSite() throws Exception - { - restSiteModel = restClient.authenticateUser(userModel).withCoreAPI() - .usingSite(moderatedSite).getSite(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModel.assertThat().field("visibility").is(moderatedSite.getVisibility()) - .and().field("id").is(moderatedSite.getId()) - .and().field("description").is(moderatedSite.getDescription()) - .and().field("title").is(moderatedSite.getTitle()) - .and().field("guid").isNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if member of a private site gets that site details and status code is 200") - public void getPrivateSiteBySiteMember() throws Exception - { - restSiteModel = restClient.authenticateUser(privateSiteConsumer).withCoreAPI() - .usingSite(privateSite).getSite(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModel.assertThat().field("visibility").is(privateSite.getVisibility()) - .and().field("id").is(privateSite.getId()) - .and().field("description").is(privateSite.getDescription()) - .and().field("title").is(privateSite.getTitle()) - .and().field("guid").isNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if user that is not member of a private site does not get that site details and status code is 200") - public void getPrivateSiteByNotASiteMember() throws Exception - { - restSiteModel = restClient.authenticateUser(userModel).withCoreAPI() - .usingSite(privateSite).getSite(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, privateSite.getTitle())); - } - -} diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteFullTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteFullTests.java deleted file mode 100644 index 574f29434..000000000 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteFullTests.java +++ /dev/null @@ -1,230 +0,0 @@ -package org.alfresco.rest.sites; - -import static org.hamcrest.CoreMatchers.equalTo; - -import java.util.List; - -import org.alfresco.dataprep.SiteService.Visibility; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.core.RestRequest; -import org.alfresco.rest.core.RestResponse; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestSiteContainerModelsCollection; -import org.alfresco.rest.model.RestSiteMemberModelsCollection; -import org.alfresco.rest.model.RestSiteModel; -import org.alfresco.utility.constants.ContainerName; -import org.alfresco.utility.constants.UserRole; -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.HttpMethod; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; -public class GetSiteFullTests extends RestTest -{ - private UserModel adminUserModel, testUser; - private SiteModel publicSite; - private RestSiteModel restSiteModel; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws DataPreparationException - { - adminUserModel = dataUser.getAdminUser(); - testUser = dataUser.createRandomTestUser(); - restClient.authenticateUser(adminUserModel); - publicSite = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Perform invalid request and check default error schema") - public void checkDefaultErrorSchema() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite("NonExistentSiteId").getSite(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "NonExistentSiteId")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }, expectedExceptions = java.lang.AssertionError.class) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Check that properties parameter is applied (guid field is mandatory, thus assertion error is expected)") - public void checkThatPropertiesParameterIsApplied() throws Exception - { - restSiteModel = restClient.authenticateUser(adminUserModel).withParams("properties=id, visibility").withCoreAPI().usingSite(publicSite).getSite(); - restSiteModel.assertThat().field("id").is(publicSite.getId()).and().field("visibility").is(Visibility.PUBLIC.toString()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL } ) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Check that properties parameter is applied") - public void checkThatPropertiesParameterIsAppliedPositiveTest() throws Exception - { - restSiteModel = restClient.authenticateUser(adminUserModel).withParams("properties=id,guid,title,visibility").withCoreAPI().usingSite(publicSite).getSite(); - restSiteModel.assertThat().field("id").is(publicSite.getId()).and().field("visibility").is(Visibility.PUBLIC.toString()) - .and().field("description").isNull() - .and().field("role").isNull(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL } ) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Delete site then get site details") - public void deleteSiteThenGetSiteDetails() throws Exception - { - SiteModel newSite = dataSite.usingAdmin().createPublicRandomSite(); - dataSite.deleteSite(newSite); - restSiteModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(newSite).getSite(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newSite.getId())) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL } ) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Delete site then get site details") - public void updateSiteVisibilityToPrivateThenGetSite() throws Exception - { - SiteModel newSite = dataSite.usingAdmin().createPublicRandomSite(); - restSiteModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(newSite).getSite(); - restClient.assertStatusCodeIs(HttpStatus.OK); - dataSite.updateSiteVisibility(newSite, Visibility.PRIVATE); - restSiteModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(newSite).getSite(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModel.assertThat().field("id").is(newSite.getId()) - .and().field("visibility").is(Visibility.PRIVATE.toString()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL } ) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Get private site with a non member") - public void getPrivateSiteWithNonMemberUser() throws Exception - { - SiteModel newSite = dataSite.usingAdmin().createPrivateRandomSite(); - restSiteModel = restClient.authenticateUser(testUser).withCoreAPI().usingSite(newSite).getSite(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newSite.getId())) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL } ) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Get moderated site with a non member") - public void getModeratedSiteWithNonMemberUser() throws Exception - { - SiteModel newSite = dataSite.usingAdmin().createModeratedRandomSite(); - restSiteModel = restClient.authenticateUser(testUser).withCoreAPI().usingSite(newSite).getSite(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModel.assertThat().field("id").is(newSite.getId()) - .and().field("visibility").is(Visibility.MODERATED.toString()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL } ) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Get public site with a non member") - public void getPublicSiteWithNonMemberUser() throws Exception - { - SiteModel newSite = dataSite.usingAdmin().createPublicRandomSite(); - restSiteModel = restClient.authenticateUser(testUser).withCoreAPI().usingSite(newSite).getSite(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModel.assertThat().field("id").is(newSite.getId()) - .and().field("visibility").is(Visibility.PUBLIC.toString()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL } ) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Check that relations parameter is applied for containers") - public void checkThatRelationsParameterIsAppliedForContainers() throws Exception - { - List jsonObjects = restClient.authenticateUser(adminUserModel) - .withParams("relations=containers").withCoreAPI().usingSite(publicSite).getSiteWithRelations(); - - RestSiteModel siteModel = (RestSiteModel) jsonObjects.get(0); - RestSiteContainerModelsCollection containers = (RestSiteContainerModelsCollection) jsonObjects.get(1); - - siteModel.assertThat().field("visibility").is(publicSite.getVisibility()) - .and().field("id").is(publicSite.getId()) - .and().field("description").is(publicSite.getDescription()) - .and().field("title").is(publicSite.getTitle()) - .and().field("preset").is("site-dashboard") - .and().field("guid").isNotEmpty(); - - containers.assertThat().entriesListCountIs(1) - .and().entriesListContains("folderId", ContainerName.documentLibrary.toString()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL } ) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Check that relations parameter is applied for members") - public void checkThatRelationsParameterIsAppliedForMembers() throws Exception - { - List jsonObjects = restClient.authenticateUser(adminUserModel) - .withParams("relations=members").withCoreAPI().usingSite(publicSite).getSiteWithRelations(); - - RestSiteModel siteModel = (RestSiteModel) jsonObjects.get(0); - RestSiteMemberModelsCollection siteMembers = (RestSiteMemberModelsCollection) jsonObjects.get(1); - - siteModel.assertThat().field("visibility").is(publicSite.getVisibility()) - .and().field("id").is(publicSite.getId()) - .and().field("description").is(publicSite.getDescription()) - .and().field("title").is(publicSite.getTitle()) - .and().field("preset").is("site-dashboard") - .and().field("guid").isNotEmpty(); - - siteMembers.assertThat().entriesListCountIs(1) - .assertThat().entriesListContains("id", adminUserModel.getUsername()) - .assertThat().entriesListContains("role", UserRole.SiteManager.toString()); - siteMembers.getOneRandomEntry().onModel().assertThat().field("person.firstName").is("Administrator") - .and().field("person.id").is("admin"); - } - - @Test(groups="demo") - public void checkThatRelationsParameterIsAppliedForMembersCustom() - { - /*1 - select API endpoint*/ - restClient.withCoreAPI(); - - /*2 - define request */ - RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "sites/{siteId}?{parameters}", publicSite.getId(), "relations=members"); - - /*3 - send request */ - RestResponse response = restClient.authenticateUser(adminUserModel).process(request); - - /*assertions */ - response.assertThat().body("entry.id", equalTo(publicSite.getId())); - response.assertThat().body("relations.members.list.entries.entry[0].role", equalTo("SiteManager")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL } ) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Check that relations parameter is applied for containers and members") - public void checkThatRelationsParameterIsAppliedForContainersAndMembers() throws Exception - { - List jsonObjects = restClient.authenticateUser(adminUserModel) - .withParams("relations=containers,members").withCoreAPI().usingSite(publicSite).getSiteWithRelations(); - - RestSiteModel siteModel = (RestSiteModel) jsonObjects.get(0); - RestSiteContainerModelsCollection containers = (RestSiteContainerModelsCollection) jsonObjects.get(1); - RestSiteMemberModelsCollection siteMembers = (RestSiteMemberModelsCollection) jsonObjects.get(2); - - siteModel.assertThat().field("visibility").is(publicSite.getVisibility()) - .and().field("id").is(publicSite.getId()) - .and().field("description").is(publicSite.getDescription()) - .and().field("title").is(publicSite.getTitle()) - .and().field("preset").is("site-dashboard") - .and().field("guid").isNotEmpty(); - - containers.assertThat().entriesListCountIs(1) - .and().entriesListContains("folderId", ContainerName.documentLibrary.toString()); - - siteMembers.assertThat().entriesListCountIs(1) - .assertThat().entriesListContains("id", adminUserModel.getUsername()) - .assertThat().entriesListContains("role", UserRole.SiteManager.toString()); - siteMembers.getOneRandomEntry().onModel().assertThat().field("person.firstName").is("Administrator") - .and().field("person.id").is("admin"); - } -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteSanityTests.java deleted file mode 100644 index 8c8c5f4e1..000000000 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteSanityTests.java +++ /dev/null @@ -1,120 +0,0 @@ -package org.alfresco.rest.sites; - -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.report.Bug; -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 GetSiteSanityTests extends RestTest -{ - private UserModel adminUserModel; - private ListUserWithRoles usersWithRoles; - private UserModel userModel; - private SiteModel siteModel; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws DataPreparationException - { - adminUserModel = dataUser.getAdminUser(); - restClient.authenticateUser(adminUserModel); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); - } - - @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 information and gets status code OK (200)") - public void getSiteWithManagerRole() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingSite(siteModel) - .getSite() - .and().field("id").is(siteModel.getId()) - .and().field("title").is(siteModel.getTitle()); - - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, - description = "Verify user with Collaborator role gets site information and gets status code OK (200)") - public void getSiteWithCollaboratorRole() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingSite(siteModel) - .getSite() - .and().field("id").is(siteModel.getId()) - .and().field("title").is(siteModel.getTitle()); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, - description = "Verify user with Contributor role gets site information and gets status code OK (200)") - public void getSiteWithContributorRole() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) - .withCoreAPI().usingSite(siteModel) - .getSite() - .and().field("id").is(siteModel.getId()) - .and().field("title").is(siteModel.getTitle()); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, - description = "Verify user with Consumer role gets site information and gets status code OK (200)") - public void getSiteWithConsumerRole() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .withCoreAPI().usingSite(siteModel) - .getSite() - .and().field("id").is(siteModel.getId()) - .and().field("title").is(siteModel.getTitle()); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, - description = "Verify user with admin role gets site information and gets status code OK (200)") - public void getSiteWithAdminRole() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingSite(siteModel) - .getSite() - .and().field("id").is(siteModel.getId()) - .and().field("title").is(siteModel.getTitle()); - 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 call returns status code 401") - @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void unauthenticatedUserIsNotAuthorizedToRetrieveSite() throws JsonToModelConversionException, Exception - { - userModel = dataUser.createRandomTestUser(); - userModel.setPassword("user wrong password"); - dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); - restClient.authenticateUser(userModel).withParams("maxItems=10000") - .withCoreAPI() - .getSites(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } -} diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteTests.java new file mode 100644 index 000000000..e205fe7a1 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteTests.java @@ -0,0 +1,362 @@ +package org.alfresco.rest.sites; + +import org.alfresco.dataprep.SiteService; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.core.RestResponse; +import org.alfresco.rest.model.*; +import org.alfresco.utility.constants.ContainerName; +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.HttpMethod; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import java.util.List; + +import static org.hamcrest.CoreMatchers.equalTo; + +/** + * @author iulia.cojocea + */ + +public class GetSiteTests extends RestTest +{ + private UserModel adminUserModel; + private ListUserWithRoles usersWithRoles; + private UserModel userModel, privateSiteConsumer; + private SiteModel publicSite, privateSite, moderatedSite; + private RestSiteModel restSiteModel; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws DataPreparationException + { + adminUserModel = dataUser.getAdminUser(); + restClient.authenticateUser(adminUserModel); + publicSite = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + usersWithRoles = dataUser.addUsersWithRolesToSite(publicSite, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + + userModel = dataUser.createRandomTestUser(); + privateSiteConsumer = dataUser.createRandomTestUser(); + + privateSite = dataSite.usingAdmin().createPrivateRandomSite(); + moderatedSite = dataSite.usingAdmin().createModeratedRandomSite(); + dataUser.addUserToSite(privateSiteConsumer, privateSite, UserRole.SiteConsumer); + } + + @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 information and gets status code OK (200)") + public void getSiteWithManagerRole() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingSite(publicSite) + .getSite() + .and().field("id").is(publicSite.getId()) + .and().field("title").is(publicSite.getTitle()); + + 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 information and gets status code OK (200)") + public void getSiteWithCollaboratorRole() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingSite(publicSite) + .getSite() + .and().field("id").is(publicSite.getId()) + .and().field("title").is(publicSite.getTitle()); + 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 information and gets status code OK (200)") + public void getSiteWithContributorRole() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) + .withCoreAPI().usingSite(publicSite) + .getSite() + .and().field("id").is(publicSite.getId()) + .and().field("title").is(publicSite.getTitle()); + 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 information and gets status code OK (200)") + public void getSiteWithConsumerRole() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + .withCoreAPI().usingSite(publicSite) + .getSite() + .and().field("id").is(publicSite.getId()) + .and().field("title").is(publicSite.getTitle()); + 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 role gets site information and gets status code OK (200)") + public void getSiteWithAdminRole() throws Exception + { + restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingSite(publicSite) + .getSite() + .and().field("id").is(publicSite.getId()) + .and().field("title").is(publicSite.getTitle()); + 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 call returns status code 401") +// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") + public void unauthenticatedUserIsNotAuthorizedToRetrieveSite() throws Exception + { + UserModel unauthenticatedManager = dataUser.createRandomTestUser(); + unauthenticatedManager.setPassword("user wrong password"); + dataUser.addUserToSite(unauthenticatedManager, publicSite, UserRole.SiteManager); + restClient.authenticateUser(unauthenticatedManager).withParams("maxItems=10000") + .withCoreAPI() + .getSites(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify invalid request returns status code 404 if siteId does not exist") + public void checkStatusCodeForNonExistentSiteId() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite("NonExistentSiteId").getSite(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "NonExistentSiteId")) + .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 all public and moderated sites if an empty siteId is provided") + public void checkStatusCodeForEmptySiteId() throws Exception + { + restClient.authenticateUser(userModel).withCoreAPI(); + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "sites/{siteId}", ""); + RestSiteModelsCollection sites = restClient.processModels(RestSiteModelsCollection.class, request); + restClient.assertStatusCodeIs(HttpStatus.OK); + sites.assertThat().entriesListIsNotEmpty(); + } + + @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 details and status code is 200") + public void getPublicSiteByNotASiteMember() throws Exception + { + restSiteModel = restClient.authenticateUser(userModel).withCoreAPI() + .usingSite(publicSite).getSite(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteModel.assertThat().field("visibility").is(publicSite.getVisibility()) + .and().field("id").is(publicSite.getId()) + .and().field("description").is(publicSite.getDescription()) + .and().field("title").is(publicSite.getTitle()) + .and().field("guid").isNotEmpty(); + } + + @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 details and status code is 200") + public void getModeratedSiteByNotASiteMember() throws Exception + { + restSiteModel = restClient.authenticateUser(userModel).withCoreAPI() + .usingSite(moderatedSite).getSite(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteModel.assertThat().field("visibility").is(moderatedSite.getVisibility()) + .and().field("id").is(moderatedSite.getId()) + .and().field("description").is(moderatedSite.getDescription()) + .and().field("title").is(moderatedSite.getTitle()) + .and().field("guid").isNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if member of a private site gets that site details and status code is 200") + public void getPrivateSiteBySiteMember() throws Exception + { + restSiteModel = restClient.authenticateUser(privateSiteConsumer).withCoreAPI() + .usingSite(privateSite).getSite(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteModel.assertThat().field("visibility").is(privateSite.getVisibility()) + .and().field("id").is(privateSite.getId()) + .and().field("description").is(privateSite.getDescription()) + .and().field("title").is(privateSite.getTitle()) + .and().field("guid").isNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if user that is not member of a private site does not get that site details and status code is 200") + public void getPrivateSiteByNotASiteMember() throws Exception + { + restSiteModel = restClient.authenticateUser(userModel).withCoreAPI() + .usingSite(privateSite).getSite(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, privateSite.getTitle())) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }, expectedExceptions = java.lang.AssertionError.class) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Check that properties parameter is applied (guid field is mandatory, thus assertion error is expected)") + public void checkThatPropertiesParameterIsApplied() throws Exception + { + restSiteModel = restClient.authenticateUser(adminUserModel).withParams("properties=id, visibility").withCoreAPI().usingSite(publicSite).getSite(); + restSiteModel.assertThat().field("id").is(publicSite.getId()).and().field("visibility").is(SiteService.Visibility.PUBLIC.toString()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION } ) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Check that properties parameter is applied") + public void checkThatPropertiesParameterIsAppliedPositiveTest() throws Exception + { + restSiteModel = restClient.authenticateUser(adminUserModel).withParams("properties=id,guid,title,visibility").withCoreAPI().usingSite(publicSite).getSite(); + restSiteModel.assertThat().field("id").is(publicSite.getId()).and().field("visibility").is(SiteService.Visibility.PUBLIC.toString()) + .and().field("description").isNull() + .and().field("role").isNull(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION } ) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Delete site then get site details") + public void deleteSiteThenGetSiteDetails() throws Exception + { + SiteModel newSite = dataSite.usingAdmin().createPublicRandomSite(); + dataSite.deleteSite(newSite); + restSiteModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(newSite).getSite(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newSite.getId())) + .containsErrorKey(RestErrorModel.ENTITY_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= "Delete site then get site details") + public void updateSiteVisibilityToPrivateThenGetSite() throws Exception + { + SiteModel newSite = dataSite.usingAdmin().createPublicRandomSite(); + restSiteModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(newSite).getSite(); + restClient.assertStatusCodeIs(HttpStatus.OK); + dataSite.updateSiteVisibility(newSite, SiteService.Visibility.PRIVATE); + restSiteModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(newSite).getSite(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteModel.assertThat().field("id").is(newSite.getId()) + .and().field("visibility").is(SiteService.Visibility.PRIVATE.toString()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION } ) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Check that relations parameter is applied for containers") + public void checkThatRelationsParameterIsAppliedForContainers() throws Exception + { + List jsonObjects = restClient.authenticateUser(adminUserModel) + .withParams("relations=containers").withCoreAPI().usingSite(publicSite).getSiteWithRelations(); + + RestSiteModel siteModel = (RestSiteModel) jsonObjects.get(0); + RestSiteContainerModelsCollection containers = (RestSiteContainerModelsCollection) jsonObjects.get(1); + + siteModel.assertThat().field("visibility").is(publicSite.getVisibility()) + .and().field("id").is(publicSite.getId()) + .and().field("description").is(publicSite.getDescription()) + .and().field("title").is(publicSite.getTitle()) + .and().field("preset").is("site-dashboard") + .and().field("guid").isNotEmpty(); + + containers.assertThat().entriesListCountIs(1) + .and().entriesListContains("folderId", ContainerName.documentLibrary.toString()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION } ) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Check that relations parameter is applied for members") + public void checkThatRelationsParameterIsAppliedForMembers() throws Exception + { + SiteModel publicRandomSite = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + List jsonObjects = restClient.authenticateUser(adminUserModel) + .withParams("relations=members").withCoreAPI().usingSite(publicRandomSite).getSiteWithRelations(); + + RestSiteModel siteModel = (RestSiteModel) jsonObjects.get(0); + RestSiteMemberModelsCollection siteMembers = (RestSiteMemberModelsCollection) jsonObjects.get(1); + + siteModel.assertThat().field("visibility").is(publicRandomSite.getVisibility()) + .and().field("id").is(publicRandomSite.getId()) + .and().field("description").is(publicRandomSite.getDescription()) + .and().field("title").is(publicRandomSite.getTitle()) + .and().field("preset").is("site-dashboard") + .and().field("guid").isNotEmpty(); + + siteMembers.assertThat().entriesListCountIs(1) + .assertThat().entriesListContains("id", adminUserModel.getUsername()) + .assertThat().entriesListContains("role", UserRole.SiteManager.toString()); + siteMembers.getOneRandomEntry().onModel().assertThat().field("person.firstName").is("Administrator") + .and().field("person.id").is("admin"); + } + + @Test(groups="demo") + public void checkThatRelationsParameterIsAppliedForMembersCustom() + { + /*1 - select API endpoint*/ + restClient.withCoreAPI(); + + /*2 - define request */ + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "sites/{siteId}?{parameters}", publicSite.getId(), "relations=members"); + + /*3 - send request */ + RestResponse response = restClient.authenticateUser(adminUserModel).process(request); + + /*assertions */ + response.assertThat().body("entry.id", equalTo(publicSite.getId())); + response.assertThat().body("relations.members.list.entries.entry[0].role", equalTo("SiteManager")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION } ) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Check that relations parameter is applied for containers and members") + public void checkThatRelationsParameterIsAppliedForContainersAndMembers() throws Exception + { + SiteModel publicRandomSite = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + List jsonObjects = restClient.authenticateUser(adminUserModel) + .withParams("relations=containers,members").withCoreAPI().usingSite(publicRandomSite).getSiteWithRelations(); + + RestSiteModel siteModel = (RestSiteModel) jsonObjects.get(0); + RestSiteContainerModelsCollection containers = (RestSiteContainerModelsCollection) jsonObjects.get(1); + RestSiteMemberModelsCollection siteMembers = (RestSiteMemberModelsCollection) jsonObjects.get(2); + + siteModel.assertThat().field("visibility").is(publicRandomSite.getVisibility()) + .and().field("id").is(publicRandomSite.getId()) + .and().field("description").is(publicRandomSite.getDescription()) + .and().field("title").is(publicRandomSite.getTitle()) + .and().field("preset").is("site-dashboard") + .and().field("guid").isNotEmpty(); + + containers.assertThat().entriesListCountIs(1) + .and().entriesListContains("folderId", ContainerName.documentLibrary.toString()); + + siteMembers.assertThat().entriesListCountIs(1) + .assertThat().entriesListContains("id", adminUserModel.getUsername()) + .assertThat().entriesListContains("role", UserRole.SiteManager.toString()); + siteMembers.getOneRandomEntry().onModel().assertThat().field("person.firstName").is("Administrator") + .and().field("person.id").is("admin"); + } +} diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java deleted file mode 100644 index 48928c61a..000000000 --- a/e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java +++ /dev/null @@ -1,150 +0,0 @@ -package org.alfresco.rest.sites; - -import java.util.List; - -import org.alfresco.dataprep.SiteService.Visibility; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestSiteModel; -import org.alfresco.rest.model.RestSiteModelsCollection; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.RandomData; -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.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Created by Claudia Agache on 11/22/2016. - */ -public class GetSitesCoreTests extends RestTest -{ - private UserModel regularUser, privateSiteManager, privateSiteConsumer; - private SiteModel publicSite, privateSite, moderatedSite, deletedSite; - private RestSiteModelsCollection sites; - private SiteModel siteModel; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - regularUser = dataUser.createRandomTestUser(); - privateSiteManager = dataUser.createRandomTestUser(); - privateSiteConsumer = dataUser.createRandomTestUser(); - siteModel = new SiteModel(RandomData.getRandomName("0-PublicSite")); - publicSite = dataSite.usingAdmin().createSite(siteModel); - siteModel = new SiteModel(RandomData.getRandomName("0-PrivateSite"), Visibility.PRIVATE); - privateSite = dataSite.usingAdmin().createSite(siteModel); - siteModel = new SiteModel(RandomData.getRandomName("0-ModeratedSite"), Visibility.MODERATED); - moderatedSite = dataSite.usingAdmin().createSite(siteModel); - dataUser.addUserToSite(privateSiteManager, privateSite, UserRole.SiteManager); - dataUser.addUserToSite(privateSiteConsumer, privateSite, UserRole.SiteConsumer); - deletedSite = dataSite.usingAdmin().createPublicRandomSite(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if get sites request returns status code 400 when invalid maxItems parameter is used") - public void getSitesWithInvalidMaxItems() throws Exception - { - restClient.authenticateUser(regularUser).withParams("maxItems=0=09") - .withCoreAPI().getSites(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "0=09")); - - restClient.withParams("maxItems=A") - .withCoreAPI().getSites(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "A")); - - restClient.withParams("maxItems=0") - .withCoreAPI().getSites(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if get sites request returns status code 400 when invalid skipCount parameter is used") - public void getSitesWithInvalidSkipCount() throws Exception - { - restClient.authenticateUser(regularUser).withParams("skipCount=A") - .withCoreAPI().getSites(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "A")); - - restClient.authenticateUser(regularUser).withParams("skipCount=-1") - .withCoreAPI().getSites(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if User gets sites ordered by title ascending and status code is 200") - public void getSitesOrderedByNameASC() throws Exception - { - sites = restClient.authenticateUser(privateSiteManager).withParams("orderBy=title ASC") - .withCoreAPI().getSites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - sites.assertThat().entriesListIsNotEmpty(); - List sitesList = sites.getEntries(); - sitesList.get(0).onModel().assertThat().field("title").is(moderatedSite.getTitle()); - sitesList.get(1).onModel().assertThat().field("title").is(privateSite.getTitle()); - sitesList.get(2).onModel().assertThat().field("title").is(publicSite.getTitle()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if a regular user gets all public and moderated sites and status code is 200") - public void regularUserGetsOnlyPublicAndModeratedSites() throws Exception - { - sites = restClient.authenticateUser(regularUser).withParams("maxItems=5000") - .withCoreAPI().getSites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - sites.assertThat().entriesListContains("title", publicSite.getTitle()) - .and().entriesListContains("title", moderatedSite.getTitle()) - .and().entriesListDoesNotContain("title", privateSite.getTitle()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if a member of a private site gets the private site, all public sites and all moderated sites. Verify if status code is 200") - public void privateSiteMemberGetsSitesVisibleForHim() throws Exception - { - sites = restClient.authenticateUser(privateSiteConsumer).withParams("maxItems=5000") - .withCoreAPI().getSites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - sites.assertThat().entriesListContains("title", publicSite.getTitle()) - .and().entriesListContains("title", moderatedSite.getTitle()) - .and().entriesListContains("title", privateSite.getTitle()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if a site is not retrieved anymore after deletion and status code is 200") - public void checkDeletedSiteIsNotRetrieved() throws Exception - { - sites = restClient.authenticateUser(regularUser).withParams("maxItems=5000").withCoreAPI().getSites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - sites.assertThat().entriesListContains("title", deletedSite.getTitle()); - - dataSite.usingAdmin().deleteSite(deletedSite); - - sites = restClient.withParams("maxItems=5000").withCoreAPI().getSites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - sites.assertThat().entriesListDoesNotContain("title", deletedSite.getTitle()); - } - - @AfterClass(alwaysRun=true) - public void cleanup() throws Exception - { - dataSite.usingAdmin().deleteSite(moderatedSite); - dataSite.usingAdmin().deleteSite(privateSite); - dataSite.usingAdmin().deleteSite(publicSite); - } -} diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSitesFullTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSitesFullTests.java deleted file mode 100644 index b1ab58011..000000000 --- a/e2e-test/java/org/alfresco/rest/sites/GetSitesFullTests.java +++ /dev/null @@ -1,298 +0,0 @@ -package org.alfresco.rest.sites; - -import java.util.List; - -import org.alfresco.dataprep.SiteService.Visibility; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestSiteContainerModelsCollection; -import org.alfresco.rest.model.RestSiteMemberModelsCollection; -import org.alfresco.rest.model.RestSiteModel; -import org.alfresco.rest.model.RestSiteModelsCollection; -import org.alfresco.utility.constants.ContainerName; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.RandomData; -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.AfterClass; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class GetSitesFullTests extends RestTest -{ - private UserModel regularUser; - private SiteModel publicSite, secondSite, privateSite, moderatedSite; - private RestSiteModelsCollection sites; - private String name; - private UserModel adminUser; - private SiteModel secondPublicSite, thirdPublicSite; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - name = RandomData.getRandomName("ZZZZZZZZZ-PublicSite"); - regularUser = dataUser.createRandomTestUser(); - publicSite = dataSite.usingAdmin().createSite(new SiteModel(Visibility.PUBLIC, "guid", name, name, name)); - privateSite = dataSite.usingAdmin().createSite(new SiteModel(RandomData.getRandomName("ZZZZZZZZZ-PrivateSite"), Visibility.PRIVATE)); - moderatedSite = dataSite.usingAdmin().createSite(new SiteModel(RandomData.getRandomName("ZZZZZZZZZ-ModeratedSite"), Visibility.MODERATED)); - secondSite = dataSite.usingAdmin().createSite(new SiteModel(RandomData.getRandomName("000000000-PublicSite"))); - dataUser.addUserToSite(regularUser, privateSite, UserRole.SiteManager); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if User gets sites ordered by title descending and status code is 200") - public void getSitesOrderedByTitleDESC() throws Exception - { - int totalItems = restClient.authenticateUser(regularUser).withCoreAPI().getSites().getPagination().getTotalItems(); - sites = restClient.authenticateUser(regularUser).withParams(String.format("maxItems=%s&orderBy=title DESC", totalItems)) - .withCoreAPI().getSites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - sites.assertThat().entriesListIsNotEmpty(); - List sitesList = sites.getEntries(); - sitesList.get(0).onModel().assertThat().field("title").is(publicSite.getTitle()); - sitesList.get(1).onModel().assertThat().field("title").is(privateSite.getTitle()); - sitesList.get(2).onModel().assertThat().field("title").is(moderatedSite.getTitle()); - sitesList.get(sitesList.size()-1).onModel().assertThat().field("title").is(secondSite.getTitle()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if User gets sites ordered by id ascending and status code is 200") - public void getSitesOrderedByIdASC() throws Exception - { - int totalItems = restClient.authenticateUser(regularUser).withCoreAPI().getSites().getPagination().getTotalItems(); - sites = restClient.authenticateUser(regularUser).withParams(String.format("maxItems=%s&orderBy=id ASC", totalItems)) - .withCoreAPI().getSites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - sites.assertThat().entriesListIsNotEmpty(); - List sitesList = sites.getEntries(); - sitesList.get(sitesList.size()-1).onModel().assertThat().field("id").is(publicSite.getId()); - sitesList.get(sitesList.size()-2).onModel().assertThat().field("id").is(privateSite.getId()); - sitesList.get(sitesList.size()-3).onModel().assertThat().field("id").is(moderatedSite.getId()); - sitesList.get(0).onModel().assertThat().field("id").is(secondSite.getId()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify pagination") - public void checkPagination() throws Exception - { - sites = restClient.authenticateUser(regularUser).withCoreAPI().getSites(); - sites.getPagination().assertThat() - .field("totalItems").isNotEmpty().and() - .field("maxItems").is("100").and() - .field("hasMoreItems").is((sites.getPagination().getTotalItems() > sites.getPagination().getMaxItems()) ? "true" : "false").and() - .field("skipCount").is("0").and() - .field("count").is((sites.getPagination().isHasMoreItems()) ? sites.getPagination().getMaxItems() : sites.getPagination().getTotalItems()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify user can get only first two sites and status code is 200") - public void getFirstTwoSites() throws Exception - { - sites = restClient.authenticateUser(regularUser).withParams(String.format("maxItems=%s&orderBy=id DESC", 2)) - .withCoreAPI().getSites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - sites.getPagination().assertThat().field("maxItems").is("2").and().field("count").is("2"); - sites.assertThat().entriesListCountIs(2).and().entriesListDoesNotContain(moderatedSite.getId()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify user can get sites using high skipCount parameter and status code is 200") - public void getSitesUsingHighSkipCount() throws Exception - { - RestSiteModelsCollection allSites = restClient.authenticateUser(regularUser).withCoreAPI().getSites(); - sites = restClient.withParams("skipCount=100").withCoreAPI().getSites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - sites.assertThat().paginationField("skipCount").is("100"); - if(allSites.getPagination().getTotalItems() > 100) - sites.assertThat().entriesListIsNotEmpty(); - else - sites.assertThat().entriesListIsEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify user can not get sites using zero maxItems parameter and status code is 400") - public void userCanNotGetSitesUsingZeroMaxItems() throws Exception - { - sites = restClient.authenticateUser(regularUser).withParams("maxItems=0").withCoreAPI().getSites(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsErrorKey(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) - .containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify that getSites request applies valid properties param and status code is 200") - public void getSitesRequestWithValidPropertiesParam() throws Exception - { - sites = restClient.authenticateUser(regularUser).withParams("properties=id").withCoreAPI().getSites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - sites.assertThat().entriesListDoesNotContain("description") - .assertThat().entriesListDoesNotContain("title") - .assertThat().entriesListDoesNotContain("visibility") - .assertThat().entriesListDoesNotContain("guid") - .assertThat().entriesListContains("id"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify pagination when skipCount and MaxItems are used") - public void checkPaginationWithSkipCountAndMaxItems() throws Exception - { - sites = restClient.authenticateUser(regularUser).withParams("skipCount=10&maxItems=110").withCoreAPI().getSites(); - sites.getPagination().assertThat() - .field("totalItems").isNotEmpty().and() - .field("maxItems").is("110").and() - .field("hasMoreItems").is((sites.getPagination().getTotalItems() - sites.getPagination().getSkipCount() > sites.getPagination().getMaxItems())?"true":"false").and() - .field("skipCount").is("10").and() - .field("count").is((sites.getPagination().isHasMoreItems()) ? sites.getPagination().getMaxItems() - : sites.getPagination().getTotalItems() - sites.getPagination().getSkipCount()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if User gets sites ordered by id ascending and status code is 200") - public void getSitesOrderedByTitleASCAndVisibilityASC() throws Exception - { - secondPublicSite = dataSite.usingAdmin().createSite( - new SiteModel(Visibility.PUBLIC, "guid", name+"A", name+"A", name)); - thirdPublicSite = dataSite.usingAdmin().createSite( - new SiteModel(Visibility.PUBLIC, "guid", name+"B", name+"B", name)); - - int totalItems = restClient.authenticateUser(regularUser).withCoreAPI().getSites().getPagination().getTotalItems(); - sites = restClient.authenticateUser(regularUser).withParams(String.format("maxItems=%s&orderBy=title ASC&orderBy=description ASC", totalItems)) - .withCoreAPI().getSites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - sites.assertThat().entriesListIsNotEmpty(); - List sitesList = sites.getEntries(); - sitesList.get(sitesList.size()-1).onModel().assertThat().field("title").is(thirdPublicSite.getTitle()); - sitesList.get(sitesList.size()-2).onModel().assertThat().field("title").is(secondPublicSite.getTitle()); - - dataSite.deleteSite(secondPublicSite); - secondPublicSite = null; - dataSite.deleteSite(thirdPublicSite); - thirdPublicSite = null; - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL } ) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Check that relations parameter is applied for containers") - public void checkThatRelationsParameterIsAppliedForContainers() throws Exception - { - List> jsonObjects = restClient.authenticateUser(adminUser) - .withParams("relations=containers").withCoreAPI().usingSite(publicSite).getSitesWithRelations(); - - List siteObjects = jsonObjects.get(0); - for (int i = 0; i < siteObjects.size(); i++) - { - RestSiteModel siteModel = (RestSiteModel) siteObjects.get(i); - siteModel.assertThat().field("visibility").isNotEmpty() - .and().field("id").isNotEmpty() - .and().field("title").isNotEmpty() - .and().field("preset").is("site-dashboard") - .and().field("guid").isNotEmpty(); - } - - List containerObjects = jsonObjects.get(1); - for (int i = 0; i < containerObjects.size(); i++) - { - RestSiteContainerModelsCollection containers = (RestSiteContainerModelsCollection) containerObjects.get(i); - containers.assertThat().entriesListIsNotEmpty().and().entriesListContains("folderId", ContainerName.documentLibrary.toString()); - } - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL } ) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Check that relations parameter is applied for members") - public void checkThatRelationsParameterIsAppliedForMembers() throws Exception - { - List> jsonObjects = restClient.authenticateUser(adminUser) - .withParams("relations=members").withCoreAPI().usingSite(publicSite).getSitesWithRelations(); - - List siteObjects = jsonObjects.get(0); - for (int i = 0; i < siteObjects.size(); i++) - { - RestSiteModel siteModel = (RestSiteModel) siteObjects.get(i); - siteModel.assertThat().field("visibility").isNotEmpty() - .and().field("id").isNotEmpty() - .and().field("title").isNotEmpty() - .and().field("preset").is("site-dashboard") - .and().field("guid").isNotEmpty(); - } - - List memberObjects = jsonObjects.get(1); - for (int i = 0; i < memberObjects.size(); i++) - { - RestSiteMemberModelsCollection siteMembers = (RestSiteMemberModelsCollection) memberObjects.get(i); - siteMembers.assertThat().entriesListIsNotEmpty().assertThat().entriesListContains("id").assertThat().entriesListContains("role", UserRole.SiteManager.toString()); - siteMembers.getOneRandomEntry().onModel().assertThat().field("person.firstName").isNotEmpty().and().field("person.id").isNotEmpty(); - } - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL } ) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Check that relations parameter is applied for members and containers") - public void checkThatRelationsParameterIsAppliedForMembersAndContainers() throws Exception - { - List> jsonObjects = restClient.authenticateUser(adminUser) - .withParams("relations=containers,members").withCoreAPI().usingSite(publicSite).getSitesWithRelations(); - - List siteObjects = jsonObjects.get(0); - for (int i = 0; i < siteObjects.size(); i++) - { - RestSiteModel siteModel = (RestSiteModel) siteObjects.get(i); - siteModel.assertThat().field("visibility").isNotEmpty() - .and().field("id").isNotEmpty() - .and().field("title").isNotEmpty() - .and().field("preset").is("site-dashboard") - .and().field("guid").isNotEmpty(); - } - - List containerObjects = jsonObjects.get(1); - for (int i = 0; i < containerObjects.size(); i++) - { - RestSiteContainerModelsCollection containers = (RestSiteContainerModelsCollection) containerObjects.get(i); - containers.assertThat().entriesListIsNotEmpty().and().entriesListContains("folderId", ContainerName.documentLibrary.toString()); - } - - List memberObjects = jsonObjects.get(2); - for (int i = 0; i < memberObjects.size(); i++) - { - RestSiteMemberModelsCollection siteMembers = (RestSiteMemberModelsCollection) memberObjects.get(i); - siteMembers.assertThat().entriesListIsNotEmpty().assertThat().entriesListContains("id").assertThat().entriesListContains("role", UserRole.SiteManager.toString()); - siteMembers.getOneRandomEntry().onModel().assertThat().field("person.firstName").isNotEmpty().and().field("person.id").isNotEmpty(); - } - } - - @AfterMethod(alwaysRun=true) - public void deleteSites() throws Exception - { - if(secondPublicSite != null) - dataSite.deleteSite(secondPublicSite); - if(thirdPublicSite != null) - dataSite.deleteSite(thirdPublicSite); - } - - @AfterClass(alwaysRun=true) - public void tearDown() throws Exception - { - dataSite.deleteSite(publicSite); - dataSite.deleteSite(privateSite); - dataSite.deleteSite(moderatedSite); - dataSite.deleteSite(secondSite); - } -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java deleted file mode 100644 index 377b383e6..000000000 --- a/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java +++ /dev/null @@ -1,117 +0,0 @@ -package org.alfresco.rest.sites; - -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.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * @author iulia.cojocea - */ -public class GetSitesSanityTests extends RestTest -{ - private UserModel adminUserModel; - private UserModel userModel; - private ListUserWithRoles usersWithRoles; - private SiteModel siteModel; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); - } - - @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 sites information and gets status code OK (200)") - public void managerIsAbleToRetrieveSites() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withParams("maxItems=10000") - .withCoreAPI().getSites() - .assertThat().entriesListIsNotEmpty() - .assertThat().entriesListContains("id", siteModel.getId()) - .and().paginationExist(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, - description = "Verify user with Collaborator role gets sites information and gets status code OK (200)") - public void collaboratorIsAbleToRetrieveSites() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withParams("maxItems=10000") - .withCoreAPI().getSites().assertThat().entriesListIsNotEmpty() - .assertThat().entriesListContains("id", siteModel.getId()) - .and().paginationExist(); - - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, - description = "Verify user with Contributor role gets sites information and gets status code OK (200)") - public void contributorIsAbleToRetrieveSites() throws JsonToModelConversionException, Exception - { - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withParams("maxItems=10000") - .withCoreAPI().getSites() - .assertThat().entriesListIsNotEmpty() - .assertThat().entriesListContains("id", siteModel.getId()) - .and().paginationExist(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, - description = "Verify user with Consumer role gets sites information and gets status code OK (200)") - public void consumerIsAbleToRetrieveSites() throws JsonToModelConversionException, Exception - { - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withParams("maxItems=10000") - .withCoreAPI().getSites() - .assertThat().entriesListIsNotEmpty() - .assertThat().entriesListContains("id", siteModel.getId()) - .and().paginationExist(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, - description = "Verify user with Admin user gets sites information and gets status code OK (200)") - public void adminUserIsAbleToRetrieveSites() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel).withParams("maxItems=10000") - .withCoreAPI().getSites() - .assertThat().entriesListIsNotEmpty() - .assertThat().entriesListContains("id", siteModel.getId()) - .and().paginationExist(); - 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 sites call returns status code 401") - @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void unauthenticatedUserIsNotAuthorizedToRetrieveSites() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - userModel = dataUser.createRandomTestUser(); - userModel.setPassword("user wrong password"); - dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); - restClient.authenticateUser(userModel).withParams("maxItems=1") - .withCoreAPI().getSites(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } -} diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSitesTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSitesTests.java new file mode 100644 index 000000000..d178612bf --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/sites/GetSitesTests.java @@ -0,0 +1,484 @@ +package org.alfresco.rest.sites; + +import org.alfresco.dataprep.SiteService; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.*; +import org.alfresco.utility.constants.ContainerName; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.data.RandomData; +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.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import java.util.List; + +/** + * @author iulia.cojocea + */ +public class GetSitesTests extends RestTest +{ + private UserModel adminUser; + private UserModel lastPrivateSiteManager; + private ListUserWithRoles usersWithRoles; + private SiteModel siteModel; + private UserModel regularUser, privateSiteManager, privateSiteConsumer; + private SiteModel firstPublicSite, firstPrivateSite, firstModeratedSite, deletedSite; + private SiteModel lastPublicSite, lastPrivateSite, lastModeratedSite; + private RestSiteModelsCollection sites; + private String name; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + regularUser = dataUser.createRandomTestUser(); + lastPrivateSiteManager = dataUser.createRandomTestUser(); + privateSiteManager = dataUser.createRandomTestUser(); + privateSiteConsumer = dataUser.createRandomTestUser(); + + siteModel = new SiteModel(RandomData.getRandomName("0-PublicSite")); + firstPublicSite = dataSite.usingAdmin().createSite(siteModel); + siteModel = new SiteModel(RandomData.getRandomName("0-PrivateSite"), SiteService.Visibility.PRIVATE); + firstPrivateSite = dataSite.usingAdmin().createSite(siteModel); + siteModel = new SiteModel(RandomData.getRandomName("0-ModeratedSite"), SiteService.Visibility.MODERATED); + firstModeratedSite = dataSite.usingAdmin().createSite(siteModel); + dataUser.addUserToSite(privateSiteManager, firstPrivateSite, UserRole.SiteManager); + dataUser.addUserToSite(privateSiteConsumer, firstPrivateSite, UserRole.SiteConsumer); + deletedSite = dataSite.usingAdmin().createPublicRandomSite(); + + name = RandomData.getRandomName("ZZZZZZZZZ-PublicSite"); + lastPublicSite = dataSite.usingAdmin().createSite(new SiteModel(SiteService.Visibility.PUBLIC, "guid", name, name, name)); + lastPrivateSite = dataSite.usingAdmin().createSite(new SiteModel(RandomData.getRandomName("ZZZZZZZZZ-PrivateSite"), SiteService.Visibility.PRIVATE)); + lastModeratedSite = dataSite.usingAdmin().createSite(new SiteModel(RandomData.getRandomName("ZZZZZZZZZ-ModeratedSite"), SiteService.Visibility.MODERATED)); + + adminUser = dataUser.getAdminUser(); + siteModel = dataSite.usingAdmin().createPublicRandomSite(); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + dataUser.addUserToSite(lastPrivateSiteManager, lastPrivateSite, 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 sites information and gets status code OK (200)") + public void managerIsAbleToRetrieveSites() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withParams("maxItems=10000") + .withCoreAPI().getSites() + .assertThat().entriesListIsNotEmpty() + .assertThat().entriesListContains("id", siteModel.getId()) + .and().paginationExist(); + 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 sites information and gets status code OK (200)") + public void collaboratorIsAbleToRetrieveSites() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withParams("maxItems=10000") + .withCoreAPI().getSites().assertThat().entriesListIsNotEmpty() + .assertThat().entriesListContains("id", siteModel.getId()) + .and().paginationExist(); + + 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 sites information and gets status code OK (200)") + public void contributorIsAbleToRetrieveSites() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withParams("maxItems=10000") + .withCoreAPI().getSites() + .assertThat().entriesListIsNotEmpty() + .assertThat().entriesListContains("id", siteModel.getId()) + .and().paginationExist(); + 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 sites information and gets status code OK (200)") + public void consumerIsAbleToRetrieveSites() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withParams("maxItems=10000") + .withCoreAPI().getSites() + .assertThat().entriesListIsNotEmpty() + .assertThat().entriesListContains("id", siteModel.getId()) + .and().paginationExist(); + 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 sites information and gets status code OK (200)") + public void adminUserIsAbleToRetrieveSites() throws Exception + { + restClient.authenticateUser(adminUser).withParams("maxItems=10000") + .withCoreAPI().getSites() + .assertThat().entriesListIsNotEmpty() + .assertThat().entriesListContains("id", siteModel.getId()) + .and().paginationExist(); + 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 sites call returns status code 401") +// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") + public void unauthenticatedUserIsNotAuthorizedToRetrieveSites() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + UserModel userModel = dataUser.createRandomTestUser(); + userModel.setPassword("user wrong password"); + dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); + restClient.authenticateUser(userModel).withParams("maxItems=1") + .withCoreAPI().getSites(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if get sites request returns status code 400 when invalid maxItems parameter is used") + public void getSitesWithInvalidMaxItems() throws Exception + { + restClient.authenticateUser(regularUser).withParams("maxItems=0=09") + .withCoreAPI().getSites(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "0=09")); + + restClient.withParams("maxItems=A") + .withCoreAPI().getSites(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "A")); + + restClient.withParams("maxItems=0") + .withCoreAPI().getSites(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if get sites request returns status code 400 when invalid skipCount parameter is used") + public void getSitesWithInvalidSkipCount() throws Exception + { + restClient.authenticateUser(regularUser).withParams("skipCount=A") + .withCoreAPI().getSites(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "A")); + + restClient.authenticateUser(regularUser).withParams("skipCount=-1") + .withCoreAPI().getSites(); + 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 User gets sites ordered by title ascending and status code is 200") + public void getSitesOrderedByTitleASC() throws Exception + { + sites = restClient.authenticateUser(privateSiteManager).withParams("orderBy=title ASC") + .withCoreAPI().getSites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + sites.assertThat().entriesListIsNotEmpty(); + List sitesList = sites.getEntries(); + sitesList.get(0).onModel().assertThat().field("title").is(firstModeratedSite.getTitle()); + sitesList.get(1).onModel().assertThat().field("title").is(firstPrivateSite.getTitle()); + sitesList.get(2).onModel().assertThat().field("title").is(firstPublicSite.getTitle()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if a regular user gets all public and moderated sites and status code is 200") + public void regularUserGetsOnlyPublicAndModeratedSites() throws Exception + { + sites = restClient.authenticateUser(regularUser).withParams("maxItems=5000") + .withCoreAPI().getSites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + sites.assertThat().entriesListContains("title", firstPublicSite.getTitle()) + .and().entriesListContains("title", firstModeratedSite.getTitle()) + .and().entriesListDoesNotContain("title", firstPrivateSite.getTitle()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if a member of a private site gets the private site, all public sites and all moderated sites. Verify if status code is 200") + public void privateSiteMemberGetsSitesVisibleForHim() throws Exception + { + sites = restClient.authenticateUser(privateSiteConsumer).withParams("maxItems=5000") + .withCoreAPI().getSites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + sites.assertThat().entriesListContains("title", firstPublicSite.getTitle()) + .and().entriesListContains("title", firstModeratedSite.getTitle()) + .and().entriesListContains("title", firstPrivateSite.getTitle()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if a site is not retrieved anymore after deletion and status code is 200") + public void checkDeletedSiteIsNotRetrieved() throws Exception + { + sites = restClient.authenticateUser(regularUser).withParams("maxItems=5000").withCoreAPI().getSites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + sites.assertThat().entriesListContains("title", deletedSite.getTitle()); + + dataSite.usingAdmin().deleteSite(deletedSite); + + sites = restClient.withParams("maxItems=5000").withCoreAPI().getSites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + sites.assertThat().entriesListDoesNotContain("title", deletedSite.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 sites ordered by title descending and status code is 200") + public void getSitesOrderedByTitleDESC() throws Exception + { + int totalItems = restClient.authenticateUser(lastPrivateSiteManager).withCoreAPI().getSites().getPagination().getTotalItems(); + sites = restClient.authenticateUser(lastPrivateSiteManager).withParams(String.format("maxItems=%s&orderBy=title DESC", totalItems)) + .withCoreAPI().getSites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + sites.assertThat().entriesListIsNotEmpty(); + List sitesList = sites.getEntries(); + sitesList.get(0).onModel().assertThat().field("title").is(lastPublicSite.getTitle()); + sitesList.get(1).onModel().assertThat().field("title").is(lastPrivateSite.getTitle()); + sitesList.get(2).onModel().assertThat().field("title").is(lastModeratedSite.getTitle()); + sitesList.get(sitesList.size()-1).onModel().assertThat().field("title").is(firstModeratedSite.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 sites ordered by id ascending and status code is 200") + public void getSitesOrderedByIdASC() throws Exception + { + int totalItems = restClient.authenticateUser(lastPrivateSiteManager).withCoreAPI().getSites().getPagination().getTotalItems(); + sites = restClient.authenticateUser(lastPrivateSiteManager).withParams(String.format("maxItems=%s&orderBy=id ASC", totalItems)) + .withCoreAPI().getSites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + sites.assertThat().entriesListIsNotEmpty(); + List sitesList = sites.getEntries(); + sitesList.get(sitesList.size()-1).onModel().assertThat().field("id").is(lastPublicSite.getId()); + sitesList.get(sitesList.size()-2).onModel().assertThat().field("id").is(lastPrivateSite.getId()); + sitesList.get(sitesList.size()-3).onModel().assertThat().field("id").is(lastModeratedSite.getId()); + sitesList.get(0).onModel().assertThat().field("id").is(firstModeratedSite.getId()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION}) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify pagination") + public void checkPagination() throws Exception + { + sites = restClient.authenticateUser(regularUser).withCoreAPI().getSites(); + sites.getPagination().assertThat() + .field("totalItems").isNotEmpty().and() + .field("maxItems").is("100").and() + .field("hasMoreItems").is((sites.getPagination().getTotalItems() > sites.getPagination().getMaxItems()) ? "true" : "false").and() + .field("skipCount").is("0").and() + .field("count").is((sites.getPagination().isHasMoreItems()) ? sites.getPagination().getMaxItems() : sites.getPagination().getTotalItems()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION}) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify user can get only first two sites and status code is 200") + public void getFirstTwoSites() throws Exception + { + sites = restClient.authenticateUser(regularUser).withParams(String.format("maxItems=%s&orderBy=title ASC", 2)) + .withCoreAPI().getSites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + sites.getPagination().assertThat().field("maxItems").is("2").and().field("count").is("2"); + sites.assertThat().entriesListCountIs(2).and().entriesListDoesNotContain(firstPublicSite.getId()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION}) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify user can get sites using high skipCount parameter and status code is 200") + public void getSitesUsingHighSkipCount() throws Exception + { + RestSiteModelsCollection allSites = restClient.authenticateUser(regularUser).withCoreAPI().getSites(); + sites = restClient.withParams("skipCount=100").withCoreAPI().getSites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + sites.assertThat().paginationField("skipCount").is("100"); + if(allSites.getPagination().getTotalItems() > 100) + sites.assertThat().entriesListIsNotEmpty(); + else + sites.assertThat().entriesListIsEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION}) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify user can not get sites using zero maxItems parameter and status code is 400") + public void userCanNotGetSitesUsingZeroMaxItems() throws Exception + { + sites = restClient.authenticateUser(regularUser).withParams("maxItems=0").withCoreAPI().getSites(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsErrorKey(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) + .containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) + .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 that getSites request applies valid properties param and status code is 200") + public void getSitesRequestWithValidPropertiesParam() throws Exception + { + sites = restClient.authenticateUser(regularUser).withParams("properties=id").withCoreAPI().getSites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + sites.assertThat().entriesListDoesNotContain("description") + .assertThat().entriesListDoesNotContain("title") + .assertThat().entriesListDoesNotContain("visibility") + .assertThat().entriesListDoesNotContain("guid") + .assertThat().entriesListContains("id"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION}) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify pagination when skipCount and MaxItems are used") + public void checkPaginationWithSkipCountAndMaxItems() throws Exception + { + sites = restClient.authenticateUser(regularUser).withParams("skipCount=10&maxItems=110").withCoreAPI().getSites(); + sites.getPagination().assertThat() + .field("totalItems").isNotEmpty().and() + .field("maxItems").is("110").and() + .field("hasMoreItems").is((sites.getPagination().getTotalItems() - sites.getPagination().getSkipCount() > sites.getPagination().getMaxItems())?"true":"false").and() + .field("skipCount").is("10").and() + .field("count").is((sites.getPagination().isHasMoreItems()) ? sites.getPagination().getMaxItems() + : sites.getPagination().getTotalItems() - sites.getPagination().getSkipCount()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION}) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if User gets sites ordered by id ascending and status code is 200") + public void getSitesOrderedByTitleASCAndVisibilityASC() throws Exception + { + SiteModel secondPublicSite = dataSite.usingAdmin().createSite( + new SiteModel(SiteService.Visibility.PUBLIC, "guid", name+"A", name+"A", name)); + SiteModel thirdPublicSite = dataSite.usingAdmin().createSite( + new SiteModel(SiteService.Visibility.PUBLIC, "guid", name+"B", name+"B", name)); + + int totalItems = restClient.authenticateUser(regularUser).withCoreAPI().getSites().getPagination().getTotalItems(); + sites = restClient.authenticateUser(regularUser).withParams(String.format("maxItems=%s&orderBy=title ASC&orderBy=description ASC", totalItems)) + .withCoreAPI().getSites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + sites.assertThat().entriesListIsNotEmpty(); + List sitesList = sites.getEntries(); + sitesList.get(sitesList.size()-1).onModel().assertThat().field("title").is(thirdPublicSite.getTitle()); + sitesList.get(sitesList.size()-2).onModel().assertThat().field("title").is(secondPublicSite.getTitle()); + + dataSite.usingAdmin().deleteSite(secondPublicSite); + dataSite.usingAdmin().deleteSite(thirdPublicSite); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION} ) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Check that relations parameter is applied for containers") + public void checkThatRelationsParameterIsAppliedForContainers() throws Exception + { + List> jsonObjects = restClient.authenticateUser(adminUser) + .withParams("relations=containers").withCoreAPI().usingSite(lastPublicSite).getSitesWithRelations(); + + List siteObjects = jsonObjects.get(0); + for (int i = 0; i < siteObjects.size(); i++) + { + RestSiteModel siteModel = (RestSiteModel) siteObjects.get(i); + siteModel.assertThat().field("visibility").isNotEmpty() + .and().field("id").isNotEmpty() + .and().field("title").isNotEmpty() + .and().field("preset").is("site-dashboard") + .and().field("guid").isNotEmpty(); + } + + List containerObjects = jsonObjects.get(1); + for (int i = 0; i < containerObjects.size(); i++) + { + RestSiteContainerModelsCollection containers = (RestSiteContainerModelsCollection) containerObjects.get(i); + containers.assertThat().entriesListIsNotEmpty().and().entriesListContains("folderId", ContainerName.documentLibrary.toString()); + } + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION} ) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Check that relations parameter is applied for members") + public void checkThatRelationsParameterIsAppliedForMembers() throws Exception + { + List> jsonObjects = restClient.authenticateUser(adminUser) + .withParams("relations=members").withCoreAPI().usingSite(lastPublicSite).getSitesWithRelations(); + + List siteObjects = jsonObjects.get(0); + for (int i = 0; i < siteObjects.size(); i++) + { + RestSiteModel siteModel = (RestSiteModel) siteObjects.get(i); + siteModel.assertThat().field("visibility").isNotEmpty() + .and().field("id").isNotEmpty() + .and().field("title").isNotEmpty() + .and().field("preset").is("site-dashboard") + .and().field("guid").isNotEmpty(); + } + + List memberObjects = jsonObjects.get(1); + for (int i = 0; i < memberObjects.size(); i++) + { + RestSiteMemberModelsCollection siteMembers = (RestSiteMemberModelsCollection) memberObjects.get(i); + siteMembers.assertThat().entriesListIsNotEmpty().assertThat().entriesListContains("id").assertThat().entriesListContains("role", UserRole.SiteManager.toString()); + siteMembers.getOneRandomEntry().onModel().assertThat().field("person.firstName").isNotEmpty().and().field("person.id").isNotEmpty(); + } + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION} ) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Check that relations parameter is applied for members and containers") + public void checkThatRelationsParameterIsAppliedForMembersAndContainers() throws Exception + { + List> jsonObjects = restClient.authenticateUser(adminUser) + .withParams("relations=containers,members").withCoreAPI().usingSite(lastPublicSite).getSitesWithRelations(); + + List siteObjects = jsonObjects.get(0); + for (int i = 0; i < siteObjects.size(); i++) + { + RestSiteModel siteModel = (RestSiteModel) siteObjects.get(i); + siteModel.assertThat().field("visibility").isNotEmpty() + .and().field("id").isNotEmpty() + .and().field("title").isNotEmpty() + .and().field("preset").is("site-dashboard") + .and().field("guid").isNotEmpty(); + } + + List containerObjects = jsonObjects.get(1); + for (int i = 0; i < containerObjects.size(); i++) + { + RestSiteContainerModelsCollection containers = (RestSiteContainerModelsCollection) containerObjects.get(i); + containers.assertThat().entriesListIsNotEmpty().and().entriesListContains("folderId", ContainerName.documentLibrary.toString()); + } + + List memberObjects = jsonObjects.get(2); + for (int i = 0; i < memberObjects.size(); i++) + { + RestSiteMemberModelsCollection siteMembers = (RestSiteMemberModelsCollection) memberObjects.get(i); + siteMembers.assertThat().entriesListIsNotEmpty().assertThat().entriesListContains("id").assertThat().entriesListContains("role", UserRole.SiteManager.toString()); + siteMembers.getOneRandomEntry().onModel().assertThat().field("person.firstName").isNotEmpty().and().field("person.id").isNotEmpty(); + } + } + + @AfterClass(alwaysRun=true) + public void cleanup() throws Exception + { + dataSite.usingAdmin().deleteSite(firstModeratedSite); + dataSite.usingAdmin().deleteSite(firstPrivateSite); + dataSite.usingAdmin().deleteSite(firstPublicSite); + + dataSite.usingAdmin().deleteSite(lastPublicSite); + dataSite.usingAdmin().deleteSite(lastPrivateSite); + dataSite.usingAdmin().deleteSite(lastModeratedSite); + } +} diff --git a/e2e-test/java/org/alfresco/rest/sites/SitesTests.java b/e2e-test/java/org/alfresco/rest/sites/SitesTests.java index 4ae25e6a2..9b40f7082 100644 --- a/e2e-test/java/org/alfresco/rest/sites/SitesTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/SitesTests.java @@ -17,7 +17,7 @@ import org.testng.annotations.Test; public class SitesTests extends RestTest { - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Tests the creation of a site") public void testCreateSite() throws Exception { diff --git a/e2e-test/java/org/alfresco/rest/sites/containers/GetSiteContainerCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/containers/GetSiteContainerCoreTests.java deleted file mode 100644 index 1bb1f262d..000000000 --- a/e2e-test/java/org/alfresco/rest/sites/containers/GetSiteContainerCoreTests.java +++ /dev/null @@ -1,107 +0,0 @@ -package org.alfresco.rest.sites.containers; - -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.utility.constants.ContainerName; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class GetSiteContainerCoreTests extends RestTest{ - - private UserModel adminUserModel, testUserModel; - private SiteModel publicSiteModel, moderatedSiteModel, privateSiteModel; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - testUserModel = dataUser.createRandomTestUser(); - publicSiteModel = dataSite.usingAdmin().createPublicRandomSite(); - moderatedSiteModel = dataSite.usingAdmin().createModeratedRandomSite(); - privateSiteModel = dataSite.usingAdmin().createPrivateRandomSite(); - - dataLink.usingAdmin().usingSite(publicSiteModel).createRandomLink(); - dataDiscussion.usingAdmin().usingSite(publicSiteModel).createRandomDiscussion(); - - dataLink.usingAdmin().usingSite(moderatedSiteModel).createRandomLink(); - dataDiscussion.usingAdmin().usingSite(moderatedSiteModel).createRandomDiscussion(); - - dataLink.usingAdmin().usingSite(privateSiteModel).createRandomLink(); - dataDiscussion.usingAdmin().usingSite(privateSiteModel).createRandomDiscussion(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if get container request returns status code 400 when site doesn't exist") - public void getContainerWithNonExistentSite() throws Exception - { - restClient.authenticateUser(testUserModel) - .withCoreAPI().usingSite("NonExistentSiteId").getSiteContainer(ContainerName.discussions.toString()); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, "NonExistentSiteId", ContainerName.discussions.toString())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if get container request returns status code 400 when container item doesn't exist") - public void getContainerWithNonExistentItem() throws Exception - { - restClient.authenticateUser(testUserModel) - .withCoreAPI().usingSite(publicSiteModel).getSiteContainer("NonExistentFolder"); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, publicSiteModel.getId(), "NonExistentFolder")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify get container request returns status 200 for public site") - public void getContainerForPublicSite() throws Exception - { - restClient.authenticateUser(testUserModel) - .withCoreAPI().usingSite(publicSiteModel).getSiteContainer(ContainerName.discussions.toString()) - .assertThat().field("folderId").is(ContainerName.discussions.toString()); - restClient.assertStatusCodeIs(HttpStatus.OK); - - restClient.authenticateUser(testUserModel) - .withCoreAPI().usingSite(publicSiteModel).getSiteContainer(ContainerName.links.toString()) - .assertThat().field("folderId").is(ContainerName.links.toString()); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify get container request returns status 200 for private site") - public void getContainerForPrivateSite() throws Exception - { - restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingSite(privateSiteModel).getSiteContainer(ContainerName.discussions.toString()) - .assertThat().field("folderId").is(ContainerName.discussions.toString()); - restClient.assertStatusCodeIs(HttpStatus.OK); - - restClient.withCoreAPI().usingSite(privateSiteModel).getSiteContainer(ContainerName.links.toString()) - .assertThat().field("folderId").is(ContainerName.links.toString()); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify get container request returns status 200 for moderated site") - public void getContainerForModeratedSite() throws Exception - { - restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingSite(moderatedSiteModel).getSiteContainer(ContainerName.discussions.toString()) - .assertThat().field("folderId").is(ContainerName.discussions.toString()); - restClient.assertStatusCodeIs(HttpStatus.OK); - - restClient.withCoreAPI().usingSite(moderatedSiteModel).getSiteContainer(ContainerName.links.toString()) - .assertThat().field("folderId").is(ContainerName.links.toString()); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/sites/containers/GetSiteContainerFullTests.java b/e2e-test/java/org/alfresco/rest/sites/containers/GetSiteContainerFullTests.java deleted file mode 100644 index 65cf5a42f..000000000 --- a/e2e-test/java/org/alfresco/rest/sites/containers/GetSiteContainerFullTests.java +++ /dev/null @@ -1,176 +0,0 @@ -package org.alfresco.rest.sites.containers; - -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.utility.constants.ContainerName; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.apache.commons.lang3.RandomStringUtils; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * - * @author Cristina Axinte - * - */ -public class GetSiteContainerFullTests extends RestTest -{ - private UserModel adminUserModel, testUserModel; - private SiteModel publicSiteModel, moderatedSiteModel, privateSiteModelByAdmin, privateSiteModelByUser; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - testUserModel = dataUser.createRandomTestUser(); - publicSiteModel = dataSite.usingAdmin().createPublicRandomSite(); - moderatedSiteModel = dataSite.usingUser(testUserModel).createModeratedRandomSite(); - privateSiteModelByAdmin = dataSite.usingAdmin().createPrivateRandomSite(); - - privateSiteModelByUser = dataSite.usingUser(testUserModel).createPrivateRandomSite(); - - dataLink.usingAdmin().usingSite(publicSiteModel).createRandomLink(); - dataDiscussion.usingAdmin().usingSite(publicSiteModel).createRandomDiscussion(); - - dataLink.usingUser(testUserModel).usingSite(moderatedSiteModel).createRandomLink(); - - dataLink.usingAdmin().usingSite(privateSiteModelByAdmin).createRandomLink(); - - dataDiscussion.usingUser(testUserModel).usingSite(privateSiteModelByUser).createRandomDiscussion(); - dataLink.usingUser(testUserModel).usingSite(privateSiteModelByUser).createRandomLink(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if get container request with properties parameter returns status code 200 and parameter is applied") - public void getContainerUsingPropertiesParameter() throws Exception - { - restClient.authenticateUser(testUserModel) - .withCoreAPI().usingSite(publicSiteModel).usingParams("properties=id").getSiteContainer(ContainerName.discussions.toString()) - .assertThat().fieldsCount().is(1) - .and().field("id").isNotEmpty() - .and().field("folderId").isNull(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if get container request for a container that does not belong to site returns status code 404") - public void getContainerThatDoesNotBelongToSite() throws Exception - { - restClient.authenticateUser(testUserModel) - .withCoreAPI().usingSite(moderatedSiteModel).getSiteContainer(ContainerName.discussions.toString()); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, moderatedSiteModel.getId(), ContainerName.discussions.toString())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if get container request for empty siteId returns status code 404") - public void getContainerForEmptySiteId() throws Exception - { - restClient.authenticateUser(testUserModel) - .withCoreAPI().usingSite("").getSiteContainer(ContainerName.discussions.toString()); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, "", ContainerName.discussions.toString())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if get container request for empty container returns status code 200 and the list of containers") - public void getContainerForEmptyContainer() throws Exception - { - restClient.authenticateUser(testUserModel) - .withCoreAPI().usingSite(moderatedSiteModel).getSiteContainer(""); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if get container with name containing special chars returns status code 404") - public void getContainerWithNameContainingSpecialChars() throws Exception - { - String containerSpecialName = RandomStringUtils.randomAlphabetic(2) + "~!%40%23%24%25%5E%26*()_%2B%5B%5D%7B%7D%7C%5C%3B%27%3A%22%2C.%2F%3C%3E"; - - restClient.authenticateUser(testUserModel) - .withCoreAPI().usingSite(publicSiteModel).getSiteContainer(containerSpecialName); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, publicSiteModel.getId(), containerSpecialName)) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if admin can get container request for a private site created by another user and status code is 200") - public void adminCanGetContainerForPrivateSiteCreatedByUser() throws Exception - { - restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingSite(privateSiteModelByUser).getSiteContainer(ContainerName.discussions.toString()) - .assertThat().field("folderId").is(ContainerName.discussions.toString()) - .and().field("id").isNotEmpty(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if user cannot get container request for a private site created by admin and status code is 404") - public void userCannotGetContainerForPrivateSiteCreatedByAdmin() throws Exception - { - restClient.authenticateUser(testUserModel) - .withCoreAPI().usingSite(privateSiteModelByAdmin).getSiteContainer(ContainerName.links.toString()); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, privateSiteModelByAdmin.getId(), ContainerName.links.toString())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if user can get container request for a public site created by admin and status code is 200") - public void userCanGetContainerForPublicSiteCreatedByAdmin() throws Exception - { - restClient.authenticateUser(testUserModel) - .withCoreAPI().usingSite(publicSiteModel).getSiteContainer(ContainerName.links.toString()) - .assertThat().field("folderId").is(ContainerName.links.toString()); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if get container request for a deleted container returns status code is 404") - public void getContainerThatWasDeleted() throws Exception - { - restClient.authenticateUser(testUserModel) - .withCoreAPI().usingSite(privateSiteModelByUser).getSiteContainer(ContainerName.links.toString()) - .assertThat().field("folderId").is(ContainerName.links.toString()); - restClient.assertStatusCodeIs(HttpStatus.OK); - - //use dataprep for delete 'links' container - FolderModel folder= new FolderModel("links"); - folder.setCmisLocation(String.format("/Sites/%s/%s", privateSiteModelByUser.getId(), ContainerName.links.toString())); - dataContent.deleteTree(folder); - - restClient.authenticateUser(testUserModel) - .withCoreAPI().usingSite(privateSiteModelByUser).getSiteContainer(ContainerName.links.toString()); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, privateSiteModelByUser.getId(), ContainerName.links.toString())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/sites/containers/GetSiteContainerSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/containers/GetSiteContainerSanityTests.java deleted file mode 100644 index 777eb7147..000000000 --- a/e2e-test/java/org/alfresco/rest/sites/containers/GetSiteContainerSanityTests.java +++ /dev/null @@ -1,117 +0,0 @@ -package org.alfresco.rest.sites.containers; - -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestSiteContainerModel; -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 GetSiteContainerSanityTests extends RestTest -{ - private UserModel adminUserModel; - private SiteModel siteModel; - private ListUserWithRoles usersWithRoles; - private RestSiteContainerModel siteContainerModel; - private UserModel userModel; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - } - - @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 container and gets status code OK (200)") - public void getSiteContainerWithManagerRole() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - siteContainerModel = restClient.withCoreAPI().usingSite(siteModel).getSiteContainers().getOneRandomEntry(); - restClient.withCoreAPI().usingSite(siteModel).getSiteContainer(siteContainerModel.onModel()) - .assertThat().field("id").is(siteContainerModel.onModel().getId()) - .and().field("folderId").is(siteContainerModel.onModel().getFolderId()); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, - description = "Verify user with Collaborator role gets site container and gets status code OK (200)") - public void getSiteContainerWithCollaboratorRole() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - siteContainerModel = restClient.withCoreAPI().usingSite(siteModel).getSiteContainers().getOneRandomEntry(); - restClient.withCoreAPI().usingSite(siteModel).getSiteContainer(siteContainerModel.onModel()) - .and().field("id").is(siteContainerModel.onModel().getId()) - .and().field("folderId").is(siteContainerModel.onModel().getFolderId()); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, - description = "Verify user with Contributor role gets site container and gets status code OK (200)") - public void getSiteContainerWithContributorRole() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - siteContainerModel = restClient.withCoreAPI().usingSite(siteModel).getSiteContainers().getOneRandomEntry(); - restClient.withCoreAPI().usingSite(siteModel).getSiteContainer(siteContainerModel.onModel()) - .assertThat().field("id").is(siteContainerModel.onModel().getId()) - .and().field("folderId").is(siteContainerModel.onModel().getFolderId()); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, - description = "Verify user with Consumer role gets site container and gets status code OK (200)") - public void getSiteContainerWithConsumerRole() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - siteContainerModel = restClient.withCoreAPI().usingSite(siteModel).getSiteContainers().getOneRandomEntry(); - restClient.withCoreAPI().usingSite(siteModel).getSiteContainer(siteContainerModel.onModel()) - .assertThat().field("id").is(siteContainerModel.onModel().getId()) - .and().field("folderId").is(siteContainerModel.onModel().getFolderId()); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, - description = "Verify user with admin user gets site container and gets status code OK (200)") - public void getSiteContainerWithAdminUser() throws Exception - { - restClient.authenticateUser(adminUserModel); - siteContainerModel = restClient.withCoreAPI().usingSite(siteModel).getSiteContainers().getOneRandomEntry(); - restClient.withCoreAPI().usingSite(siteModel).getSiteContainer(siteContainerModel.onModel()) - .assertThat().field("id").is(siteContainerModel.onModel().getId()) - .and().field("folderId").is(siteContainerModel.onModel().getFolderId()); - 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 container call returns status code 401") - public void unauthenticatedUserIsNotAuthorizedToRetrieveSiteContainer() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - siteContainerModel = restClient.withCoreAPI().usingSite(siteModel).getSiteContainers().getOneRandomEntry(); - userModel = dataUser.createRandomTestUser(); - userModel.setPassword("user wrong password"); - dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); - restClient.authenticateUser(userModel) - .withCoreAPI().usingSite(siteModel).getSiteContainer(siteContainerModel.onModel()); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } -} diff --git a/e2e-test/java/org/alfresco/rest/sites/containers/GetSiteContainerTests.java b/e2e-test/java/org/alfresco/rest/sites/containers/GetSiteContainerTests.java new file mode 100644 index 000000000..a77ef8d8b --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/sites/containers/GetSiteContainerTests.java @@ -0,0 +1,313 @@ +package org.alfresco.rest.sites.containers; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestSiteContainerModel; +import org.alfresco.utility.constants.ContainerName; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.apache.commons.lang3.RandomStringUtils; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * @author iulia.cojocea + */ +public class GetSiteContainerTests extends RestTest +{ + private UserModel adminUserModel; + private SiteModel publicSiteModel, moderatedSiteModel, privateSiteModel, adminPrivateSiteModel; + private ListUserWithRoles usersWithRoles; + private RestSiteContainerModel siteContainerModel; + private UserModel testUser; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + testUser = dataUser.createRandomTestUser(); + + publicSiteModel = dataSite.usingAdmin().createPublicRandomSite(); + moderatedSiteModel = dataSite.usingUser(testUser).createModeratedRandomSite(); + privateSiteModel = dataSite.usingUser(testUser).createPrivateRandomSite(); + adminPrivateSiteModel = dataSite.usingAdmin().createPrivateRandomSite(); + + usersWithRoles = dataUser.addUsersWithRolesToSite(publicSiteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + + dataLink.usingAdmin().usingSite(publicSiteModel).createRandomLink(); + dataDiscussion.usingAdmin().usingSite(publicSiteModel).createRandomDiscussion(); + + dataLink.usingUser(testUser).usingSite(moderatedSiteModel).createRandomLink(); + + dataLink.usingAdmin().usingSite(adminPrivateSiteModel).createRandomLink(); + + dataLink.usingUser(testUser).usingSite(privateSiteModel).createRandomLink(); + dataDiscussion.usingUser(testUser).usingSite(privateSiteModel).createRandomDiscussion(); + } + + @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 container and gets status code OK (200)") + public void getSiteContainerWithManagerRole() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + siteContainerModel = restClient.withCoreAPI().usingSite(publicSiteModel).getSiteContainers().getOneRandomEntry(); + restClient.withCoreAPI().usingSite(publicSiteModel).getSiteContainer(siteContainerModel.onModel()) + .assertThat().field("id").is(siteContainerModel.onModel().getId()) + .and().field("folderId").is(siteContainerModel.onModel().getFolderId()); + 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 container and gets status code OK (200)") + public void getSiteContainerWithCollaboratorRole() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + siteContainerModel = restClient.withCoreAPI().usingSite(publicSiteModel).getSiteContainers().getOneRandomEntry(); + restClient.withCoreAPI().usingSite(publicSiteModel).getSiteContainer(siteContainerModel.onModel()) + .and().field("id").is(siteContainerModel.onModel().getId()) + .and().field("folderId").is(siteContainerModel.onModel().getFolderId()); + 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 container and gets status code OK (200)") + public void getSiteContainerWithContributorRole() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + siteContainerModel = restClient.withCoreAPI().usingSite(publicSiteModel).getSiteContainers().getOneRandomEntry(); + restClient.withCoreAPI().usingSite(publicSiteModel).getSiteContainer(siteContainerModel.onModel()) + .assertThat().field("id").is(siteContainerModel.onModel().getId()) + .and().field("folderId").is(siteContainerModel.onModel().getFolderId()); + 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 container and gets status code OK (200)") + public void getSiteContainerWithConsumerRole() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + siteContainerModel = restClient.withCoreAPI().usingSite(publicSiteModel).getSiteContainers().getOneRandomEntry(); + restClient.withCoreAPI().usingSite(publicSiteModel).getSiteContainer(siteContainerModel.onModel()) + .assertThat().field("id").is(siteContainerModel.onModel().getId()) + .and().field("folderId").is(siteContainerModel.onModel().getFolderId()); + 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 container and gets status code OK (200)") + public void getSiteContainerWithAdminUser() throws Exception + { + restClient.authenticateUser(adminUserModel); + siteContainerModel = restClient.withCoreAPI().usingSite(publicSiteModel).getSiteContainers().getOneRandomEntry(); + restClient.withCoreAPI().usingSite(publicSiteModel).getSiteContainer(siteContainerModel.onModel()) + .assertThat().field("id").is(siteContainerModel.onModel().getId()) + .and().field("folderId").is(siteContainerModel.onModel().getFolderId()); + 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 container call returns status code 401") + public void unauthenticatedUserIsNotAuthorizedToRetrieveSiteContainer() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + siteContainerModel = restClient.withCoreAPI().usingSite(publicSiteModel).getSiteContainers().getOneRandomEntry(); + UserModel userModel = dataUser.createRandomTestUser(); + userModel.setPassword("user wrong password"); + dataUser.addUserToSite(userModel, publicSiteModel, UserRole.SiteManager); + restClient.authenticateUser(userModel) + .withCoreAPI().usingSite(publicSiteModel).getSiteContainer(siteContainerModel.onModel()); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if get container request returns status code 400 when site doesn't exist") + public void getContainerWithNonExistentSite() throws Exception + { + restClient.authenticateUser(testUser) + .withCoreAPI().usingSite("NonExistentSiteId").getSiteContainer(ContainerName.discussions.toString()); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, "NonExistentSiteId", ContainerName.discussions.toString())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if get container request returns status code 400 when container item doesn't exist") + public void getContainerWithNonExistentItem() throws Exception + { + restClient.authenticateUser(testUser) + .withCoreAPI().usingSite(publicSiteModel).getSiteContainer("NonExistentFolder"); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, publicSiteModel.getId(), "NonExistentFolder")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify regular user can get container for public site and request returns status 200") + public void getContainerForPublicSite() throws Exception + { + restClient.authenticateUser(testUser) + .withCoreAPI().usingSite(publicSiteModel).getSiteContainer(ContainerName.discussions.toString()) + .assertThat().field("folderId").is(ContainerName.discussions.toString()); + restClient.assertStatusCodeIs(HttpStatus.OK); + + restClient.authenticateUser(testUser) + .withCoreAPI().usingSite(publicSiteModel).getSiteContainer(ContainerName.links.toString()) + .assertThat().field("folderId").is(ContainerName.links.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 manager is able to get container for his private site and request returns status 200") + public void getContainerForPrivateSite() throws Exception + { + restClient.authenticateUser(testUser) + .withCoreAPI().usingSite(privateSiteModel).getSiteContainer(ContainerName.discussions.toString()) + .assertThat().field("folderId").is(ContainerName.discussions.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 get container request returns status 200 for moderated site") + public void getContainerForModeratedSite() throws Exception + { + restClient.authenticateUser(testUser) + .withCoreAPI().usingSite(moderatedSiteModel).getSiteContainer(ContainerName.links.toString()) + .assertThat().field("folderId").is(ContainerName.links.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 if get container request with properties parameter returns status code 200 and parameter is applied") + public void getContainerUsingPropertiesParameter() throws Exception + { + restClient.authenticateUser(testUser) + .withCoreAPI().usingSite(publicSiteModel).usingParams("properties=id").getSiteContainer(ContainerName.discussions.toString()) + .assertThat().fieldsCount().is(1) + .and().field("id").isNotEmpty() + .and().field("folderId").isNull(); + 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 container request for a container that does not belong to site returns status code 404") + public void getContainerThatDoesNotBelongToSite() throws Exception + { + restClient.authenticateUser(testUser) + .withCoreAPI().usingSite(moderatedSiteModel).getSiteContainer(ContainerName.discussions.toString()); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, moderatedSiteModel.getId(), ContainerName.discussions.toString())) + .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 if get container request for empty siteId returns status code 404") + public void getContainerForEmptySiteId() throws Exception + { + restClient.authenticateUser(testUser) + .withCoreAPI().usingSite("").getSiteContainer(ContainerName.discussions.toString()); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, "", ContainerName.discussions.toString())) + .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 if get container request for empty container returns status code 200 and the list of containers") + public void getContainerForEmptyContainer() throws Exception + { + restClient.authenticateUser(testUser) + .withCoreAPI().usingSite(moderatedSiteModel).getSiteContainer(""); + 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 container with name containing special chars returns status code 404") + public void getContainerWithNameContainingSpecialChars() throws Exception + { + String containerSpecialName = RandomStringUtils.randomAlphabetic(2) + "~!%40%23%24%25%5E%26*()_%2B%5B%5D%7B%7D%7C%5C%3B%27%3A%22%2C.%2F%3C%3E"; + + restClient.authenticateUser(testUser) + .withCoreAPI().usingSite(publicSiteModel).getSiteContainer(containerSpecialName); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, publicSiteModel.getId(), containerSpecialName)) + .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 if admin can get container request for a private site created by another user and status code is 200") + public void adminCanGetContainerForPrivateSiteCreatedByUser() throws Exception + { + restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingSite(privateSiteModel).getSiteContainer(ContainerName.discussions.toString()) + .assertThat().field("folderId").is(ContainerName.discussions.toString()) + .and().field("id").isNotEmpty(); + 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 user cannot get container request for a private site created by admin and status code is 404") + public void userCannotGetContainerForPrivateSiteCreatedByAdmin() throws Exception + { + restClient.authenticateUser(testUser) + .withCoreAPI().usingSite(adminPrivateSiteModel).getSiteContainer(ContainerName.links.toString()); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, adminPrivateSiteModel.getId(), ContainerName.links.toString())) + .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 if get container request for a deleted container returns status code is 404") + public void getContainerThatWasDeleted() throws Exception + { + restClient.authenticateUser(testUser) + .withCoreAPI().usingSite(privateSiteModel).getSiteContainer(ContainerName.links.toString()) + .assertThat().field("folderId").is(ContainerName.links.toString()); + restClient.assertStatusCodeIs(HttpStatus.OK); + + //use dataprep for delete 'links' container + FolderModel folder= new FolderModel("links"); + folder.setCmisLocation(String.format("/Sites/%s/%s", privateSiteModel.getId(), ContainerName.links.toString())); + dataContent.deleteTree(folder); + + restClient.authenticateUser(testUser) + .withCoreAPI().usingSite(privateSiteModel).getSiteContainer(ContainerName.links.toString()); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, privateSiteModel.getId(), ContainerName.links.toString())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } +} diff --git a/e2e-test/java/org/alfresco/rest/sites/containers/GetSiteContainersCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/containers/GetSiteContainersCoreTests.java deleted file mode 100644 index f39fa5546..000000000 --- a/e2e-test/java/org/alfresco/rest/sites/containers/GetSiteContainersCoreTests.java +++ /dev/null @@ -1,219 +0,0 @@ -package org.alfresco.rest.sites.containers; - -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.utility.constants.ContainerName; -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; - -public class GetSiteContainersCoreTests extends RestTest -{ - private UserModel adminUserModel; - private SiteModel publicSiteModel, publicSiteWithContainers; - private SiteModel moderatedSiteModel, privateSiteModel; - private ListUserWithRoles publicSiteUsers; - private ListUserWithRoles publicSiteWithContainersUsers; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - - publicSiteModel = dataSite.usingAdmin().createPublicRandomSite(); - publicSiteWithContainers = dataSite.usingAdmin().createPublicRandomSite(); - moderatedSiteModel = dataSite.usingAdmin().createModeratedRandomSite(); - privateSiteModel = dataSite.usingAdmin().createPrivateRandomSite(); - - publicSiteUsers = dataUser - .addUsersWithRolesToSite(publicSiteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); - - publicSiteWithContainersUsers = dataUser - .addUsersWithRolesToSite(publicSiteWithContainers, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - - dataLink.usingAdmin().usingSite(publicSiteWithContainers).createRandomLink(); - dataDiscussion.usingAdmin().usingSite(publicSiteWithContainers).createRandomDiscussion(); - - dataLink.usingAdmin().usingSite(moderatedSiteModel).createRandomLink(); - dataDiscussion.usingAdmin().usingSite(moderatedSiteModel).createRandomDiscussion(); - - dataLink.usingAdmin().usingSite(privateSiteModel).createRandomLink(); - dataDiscussion.usingAdmin().usingSite(privateSiteModel).createRandomDiscussion(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if get site container request returns status code 200 with valid maxItems parameter") - public void getContainersWithValidMaxItems() throws Exception - { - restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteManager)) - .withParams("maxItems=5") - .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() - .assertThat().entriesListCountIs(3) - .and().entriesListContains("folderId" ,ContainerName.documentLibrary.toString()) - .and().entriesListContains("folderId", ContainerName.links.toString()) - .and().entriesListContains("folderId", ContainerName.discussions.toString()); - restClient.assertStatusCodeIs(HttpStatus.OK); - - restClient.withParams("maxItems=1") - .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() - .assertThat().entriesListCountIs(1); - - restClient.withParams("maxItems=3") - .withCoreAPI().usingSite(publicSiteModel).getSiteContainers() - .assertThat().entriesListCountIs(1) - .and().entriesListContains("folderId", ContainerName.documentLibrary.toString()); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if get site container request returns status code 400 when invalid maxItems parameter is used") - public void getContainersWithMaxItemsZero () throws Exception - { - restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteManager)) - .withParams("maxItems=0") - .withCoreAPI().usingSite(publicSiteModel).getSiteContainers(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary("Only positive values supported for maxItems"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if get site container request returns status code 400 when invalid maxItems parameter is used") - public void getContainersWithMaxItemsCharacter () throws Exception - { - restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)) - .withParams("maxItems=test") - .withCoreAPI().usingSite(publicSiteModel).getSiteContainers(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "test")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if get site container request returns status code 200 when maxItems parameter starts with multiple zero") - public void getContainersWithMaxItemsMultipleZero () throws Exception - { - restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteCollaborator)) - .withParams("maxItems=000007") - .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() - .assertThat().entriesListCountIs(3); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if get site containers request returns status code 200 when valid skipCount parameter is used") - public void getSiteContainersWithValidSkipCount() throws Exception - { - restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteManager)).withParams("skipCount=1") - .withCoreAPI().usingSite(publicSiteModel).getSiteContainers() - .assertThat().entriesListCountIs(0); - restClient.assertStatusCodeIs(HttpStatus.OK); - - restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteCollaborator)).withParams("skipCount=1") - .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() - .assertThat().entriesListCountIs(2); - restClient.assertStatusCodeIs(HttpStatus.OK); - - restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteConsumer)).withParams("skipCount=2") - .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() - .assertThat().entriesListCountIs(1); - restClient.assertStatusCodeIs(HttpStatus.OK); - - restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteCollaborator)).withParams("skipCount=0") - .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() - .assertThat().entriesListCountIs(3); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if get site containers request returns status code 400 when invalid skipCount parameter is used") - public void getSiteContainersWithSkipCountCharacter() throws Exception - { - restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)).withParams("skipCount=abc") - .withCoreAPI().usingSite(publicSiteModel).getSiteContainers(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "abc")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if get site containers request returns status code 200 when skipCount parameter starts with multiple zero") - public void getSiteContainersWithSkipCountMultipleZero() throws Exception - { - restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)).withParams("skipCount=00002") - .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() - .assertThat().entriesListCountIs(1); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if get site containers request returns status code 400 when site doesn't exist") - public void getSiteContainersWithNonExistentSite() throws Exception - { - restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingSite("NonExistentSiteId").getSiteContainers(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "NonExistentSiteId")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify get site containers request returns status 200 for private site") - public void getSiteContainersForPrivateSite() throws Exception - { - restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingSite(privateSiteModel).getSiteContainers() - .assertThat().entriesListCountIs(3); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify get site containers request returns status 200 for moderated site") - public void getSiteContainersForModeratedSite() throws Exception - { - restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingSite(moderatedSiteModel).getSiteContainers() - .assertThat().entriesListCountIs(3); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify get site containers request returns status 200 for several containers") - public void getSiteContainersForSeveralItems() throws Exception - { - restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() - .assertThat().entriesListCountIs(3) - .and().entriesListContains("folderId" ,ContainerName.documentLibrary.toString()) - .and().entriesListContains("folderId", ContainerName.links.toString()) - .and().entriesListContains("folderId", ContainerName.discussions.toString()); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify get site containers request returns status 200 for one container") - public void getSiteContainersWithOneItem() throws Exception - { - restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingSite(publicSiteModel).getSiteContainers() - .assertThat().entriesListCountIs(1) - .and().entriesListContains("folderId" ,ContainerName.documentLibrary.toString()); - restClient.assertStatusCodeIs(HttpStatus.OK); - } -} diff --git a/e2e-test/java/org/alfresco/rest/sites/containers/GetSiteContainersFullTests.java b/e2e-test/java/org/alfresco/rest/sites/containers/GetSiteContainersFullTests.java deleted file mode 100644 index 42c508dbb..000000000 --- a/e2e-test/java/org/alfresco/rest/sites/containers/GetSiteContainersFullTests.java +++ /dev/null @@ -1,144 +0,0 @@ -package org.alfresco.rest.sites.containers; - -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestSiteContainerModelsCollection; -import org.alfresco.utility.constants.ContainerName; -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.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 Cristina Axinte - * - */ -public class GetSiteContainersFullTests extends RestTest -{ - private SiteModel publicSiteWithContainers; - private ListUserWithRoles publicSiteWithContainersUsers; - RestSiteContainerModelsCollection restSiteContainers; - int totalItems; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - publicSiteWithContainers = dataSite.usingAdmin().createPublicRandomSite(); - - publicSiteWithContainersUsers = dataUser - .addUsersWithRolesToSite(publicSiteWithContainers, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - - dataLink.usingAdmin().usingSite(publicSiteWithContainers).createRandomLink(); - dataDiscussion.usingAdmin().usingSite(publicSiteWithContainers).createRandomDiscussion(); - dataContent.usingAdmin().usingSite(publicSiteWithContainers).createFolder(); - - restSiteContainers = restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers(); - totalItems = restSiteContainers.getPagination().getTotalItems(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if get site container request with properties parameter applied returns status code 200") - public void getSiteContainersUsingPropertiesParameter() throws Exception - { - restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingSite(publicSiteWithContainers).usingParams("properties=folderId").getSiteContainers() - .assertThat().entriesListCountIs(3) - .and().entriesListContains("folderId", ContainerName.discussions.toString()) - .and().entriesListContains("folderId", ContainerName.documentLibrary.toString()) - .and().entriesListContains("folderId", ContainerName.links.toString()) - .and().entriesListDoesNotContain("id"); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if get site container request for a container that is not empty returns status code 200") - public void getSiteContainersThatIsNotEmpty() throws Exception - { - restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() - .assertThat().entriesListCountIs(3) - .and().entriesListContains("folderId", ContainerName.documentLibrary.toString()); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if get site containers request returns status code 200 when first container is skipped") - public void getSiteContainersAndSkipFirst() throws Exception - { - restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteCollaborator)) - .withParams("skipCount=1").withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() - .assertThat().entriesListCountIs(2) - .and().entriesListDoesNotContain("folderId", restSiteContainers.getEntries().get(0).onModel().getFolderId()) - .and().entriesListContains("folderId", restSiteContainers.getEntries().get(1).onModel().getFolderId()) - .and().entriesListContains("folderId", restSiteContainers.getEntries().get(2).onModel().getFolderId()); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if get site containers request and get last container returns status code 200") - public void getLastSiteContainer() throws Exception - { - restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteCollaborator)) - .withParams("skipCount=" + String.valueOf(totalItems-1)).withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() - .assertThat().entriesListCountIs(1) - .and().entriesListDoesNotContain("folderId", restSiteContainers.getEntries().get(0).onModel().getFolderId()) - .and().entriesListDoesNotContain("folderId", restSiteContainers.getEntries().get(1).onModel().getFolderId()) - .and().entriesListContains("folderId", restSiteContainers.getEntries().get(2).onModel().getFolderId()); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if get site containers request returns status code 200 when high skipCount parameter is used") - public void getSiteContainersWithHighSkipCount() throws Exception - { - restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteCollaborator)) - .withParams("skipCount=999999").withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() - .assertThat().entriesListIsEmpty() - .and().entriesListCountIs(0) - .and().paginationField("skipCount").is("999999"); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if get site container request for an empty siteId returns status code 404") - public void getSiteContainersForEmptySiteId() throws Exception - { - restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingSite("").getSiteContainers(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if get site container request returns status code 200 with valid maxItems parameter") - public void getContainersWithValidMaxItems() throws Exception - { - restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteManager)) - .withParams("maxItems=2").withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() - .assertThat().entriesListCountIs(2) - .getPagination().assertThat().field("count").is("2") - .and().field("hasMoreItems").is("true") - .and().field("totalItems").is("3") - .and().field("skipCount").is("0") - .and().field("maxItems").is("2"); - restClient.assertStatusCodeIs(HttpStatus.OK); - } -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/sites/containers/GetSiteContainersSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/containers/GetSiteContainersSanityTests.java deleted file mode 100644 index 0a7d6b398..000000000 --- a/e2e-test/java/org/alfresco/rest/sites/containers/GetSiteContainersSanityTests.java +++ /dev/null @@ -1,115 +0,0 @@ -package org.alfresco.rest.sites.containers; - -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.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * @author iulia.cojocea - */ -public class GetSiteContainersSanityTests extends RestTest -{ - private UserModel adminUserModel; - private SiteModel siteModel; - private ListUserWithRoles usersWithRoles; - private UserModel userModel; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); - } - - @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 containers and gets status code OK (200)") - public void getSiteContainersWithManagerRole() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingSite(siteModel).getSiteContainers() - .assertThat().entriesListIsNotEmpty() - .assertThat().paginationExist() - .and().paginationField("count").isNot("0"); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, - description = "Verify user with Collaborator role gets site containers and gets status code OK (200)") - public void getSiteContainersWithCollaboratorRole() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.withCoreAPI().usingSite(siteModel).getSiteContainers() - .assertThat().entriesListIsNotEmpty() - .assertThat().paginationExist() - .and().paginationField("count").isNot("0"); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, - description = "Verify user with Contributor role gets site containers and gets status code OK (200)") - public void getSiteContainersWithContributorRole() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - restClient.withCoreAPI().usingSite(siteModel).getSiteContainers() - .assertThat().entriesListIsNotEmpty() - .assertThat().paginationExist() - .and().paginationField("count").isNot("0"); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, - description = "Verify user with Consumer role gets site containers and gets status code OK (200)") - public void getSiteContainersWithConsumerRole() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.withCoreAPI().usingSite(siteModel).getSiteContainers() - .assertThat().entriesListIsNotEmpty() - .assertThat().paginationExist() - .and().paginationField("count").isNot("0"); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, - description = "Verify user with Admin user gets site containers information and gets status code OK (200)") - public void getSiteContainersWithAdminUser() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel); - restClient.withCoreAPI().usingSite(siteModel).getSiteContainers() - .assertThat().entriesListIsNotEmpty() - .assertThat().paginationExist() - .and().paginationField("count").isNot("0"); - 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 containers call returns status code 401 with Manager role") - @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void unauthenticatedUserIsNotAuthorizedToRetrieveSiteContainers() throws JsonToModelConversionException, Exception - { - userModel = dataUser.createRandomTestUser(); - userModel.setPassword("user wrong password"); - dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); - restClient.authenticateUser(userModel) - .withCoreAPI().usingSite(siteModel).getSiteContainers(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } -} diff --git a/e2e-test/java/org/alfresco/rest/sites/containers/GetSiteContainersTests.java b/e2e-test/java/org/alfresco/rest/sites/containers/GetSiteContainersTests.java new file mode 100644 index 000000000..09cfc15cf --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/sites/containers/GetSiteContainersTests.java @@ -0,0 +1,390 @@ +package org.alfresco.rest.sites.containers; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestSiteContainerModelsCollection; +import org.alfresco.utility.constants.ContainerName; +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 GetSiteContainersTests extends RestTest +{ + private UserModel adminUserModel; + private SiteModel publicSiteModel, publicSiteWithContainers; + private SiteModel moderatedSiteModel, privateSiteModel; + private ListUserWithRoles publicSiteUsers; + private ListUserWithRoles publicSiteWithContainersUsers; + private RestSiteContainerModelsCollection restSiteContainers; + private int totalItems; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + publicSiteModel = dataSite.usingAdmin().createPublicRandomSite(); + publicSiteWithContainers = dataSite.usingAdmin().createPublicRandomSite(); + moderatedSiteModel = dataSite.usingAdmin().createModeratedRandomSite(); + privateSiteModel = dataSite.usingAdmin().createPrivateRandomSite(); + + publicSiteUsers = dataUser.addUsersWithRolesToSite(publicSiteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + + publicSiteWithContainersUsers = dataUser + .addUsersWithRolesToSite(publicSiteWithContainers, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + + dataLink.usingAdmin().usingSite(publicSiteWithContainers).createRandomLink(); + dataDiscussion.usingAdmin().usingSite(publicSiteWithContainers).createRandomDiscussion(); + + dataLink.usingAdmin().usingSite(moderatedSiteModel).createRandomLink(); + dataDiscussion.usingAdmin().usingSite(moderatedSiteModel).createRandomDiscussion(); + + dataLink.usingAdmin().usingSite(privateSiteModel).createRandomLink(); + dataDiscussion.usingAdmin().usingSite(privateSiteModel).createRandomDiscussion(); + + + restSiteContainers = restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers(); + totalItems = restSiteContainers.getPagination().getTotalItems(); + } + + @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 containers and gets status code OK (200)") + public void getSiteContainersWithManagerRole() throws Exception + { + restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteManager)); + restClient.withCoreAPI().usingSite(publicSiteModel).getSiteContainers() + .assertThat().entriesListIsNotEmpty() + .assertThat().paginationExist() + .and().paginationField("count").isNot("0"); + 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 containers and gets status code OK (200)") + public void getSiteContainersWithCollaboratorRole() throws Exception + { + restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)); + restClient.withCoreAPI().usingSite(publicSiteModel).getSiteContainers() + .assertThat().entriesListIsNotEmpty() + .assertThat().paginationExist() + .and().paginationField("count").isNot("0"); + 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 containers and gets status code OK (200)") + public void getSiteContainersWithContributorRole() throws Exception + { + restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteContributor)); + restClient.withCoreAPI().usingSite(publicSiteModel).getSiteContainers() + .assertThat().entriesListIsNotEmpty() + .assertThat().paginationExist() + .and().paginationField("count").isNot("0"); + 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 containers and gets status code OK (200)") + public void getSiteContainersWithConsumerRole() throws Exception + { + restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteConsumer)); + restClient.withCoreAPI().usingSite(publicSiteModel).getSiteContainers() + .assertThat().entriesListIsNotEmpty() + .assertThat().paginationExist() + .and().paginationField("count").isNot("0"); + 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 containers information and gets status code OK (200)") + public void getSiteContainersWithAdminUser() throws Exception + { + restClient.authenticateUser(adminUserModel); + restClient.withCoreAPI().usingSite(publicSiteModel).getSiteContainers() + .assertThat().entriesListIsNotEmpty() + .assertThat().paginationExist() + .and().paginationField("count").isNot("0"); + 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 containers call returns status code 401 with Manager role") +// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") + public void unauthenticatedUserIsNotAuthorizedToRetrieveSiteContainers() throws Exception + { + UserModel userModel = dataUser.createRandomTestUser(); + userModel.setPassword("user wrong password"); + dataUser.addUserToSite(userModel, publicSiteModel, UserRole.SiteManager); + restClient.authenticateUser(userModel) + .withCoreAPI().usingSite(publicSiteModel).getSiteContainers(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if get site container request returns status code 200 with valid maxItems parameter") + public void getContainersWithValidMaxItems() throws Exception + { + restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteManager)) + .withParams("maxItems=5") + .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() + .assertThat().entriesListCountIs(3) + .and().entriesListContains("folderId" , ContainerName.documentLibrary.toString()) + .and().entriesListContains("folderId", ContainerName.links.toString()) + .and().entriesListContains("folderId", ContainerName.discussions.toString()); + restClient.assertStatusCodeIs(HttpStatus.OK); + + restClient.withParams("maxItems=1") + .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() + .assertThat().entriesListCountIs(1); + + restClient.withParams("maxItems=3") + .withCoreAPI().usingSite(publicSiteModel).getSiteContainers() + .assertThat().entriesListCountIs(1) + .and().entriesListContains("folderId", ContainerName.documentLibrary.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 if get site container request returns status code 400 when invalid maxItems parameter is used") + public void getContainersWithMaxItemsZero () throws Exception + { + restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteManager)) + .withParams("maxItems=0") + .withCoreAPI().usingSite(publicSiteModel).getSiteContainers(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary("Only positive values supported for maxItems"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if get site container request returns status code 400 when invalid maxItems parameter is used") + public void getContainersWithMaxItemsCharacter () throws Exception + { + restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)) + .withParams("maxItems=test") + .withCoreAPI().usingSite(publicSiteModel).getSiteContainers(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "test")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if get site container request returns status code 200 when maxItems parameter starts with multiple zero") + public void getContainersWithMaxItemsMultipleZero () throws Exception + { + restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteCollaborator)) + .withParams("maxItems=000007") + .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() + .assertThat().entriesListCountIs(3); + 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 containers request returns status code 200 when valid skipCount parameter is used") + public void getSiteContainersWithValidSkipCount() throws Exception + { + restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteManager)).withParams("skipCount=1") + .withCoreAPI().usingSite(publicSiteModel).getSiteContainers() + .assertThat().entriesListCountIs(0); + restClient.assertStatusCodeIs(HttpStatus.OK); + + restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteCollaborator)).withParams("skipCount=1") + .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() + .assertThat().entriesListCountIs(2); + restClient.assertStatusCodeIs(HttpStatus.OK); + + restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteConsumer)).withParams("skipCount=2") + .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() + .assertThat().entriesListCountIs(1); + restClient.assertStatusCodeIs(HttpStatus.OK); + + restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteCollaborator)).withParams("skipCount=0") + .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() + .assertThat().entriesListCountIs(3); + 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 containers request returns status code 400 when invalid skipCount parameter is used") + public void getSiteContainersWithSkipCountCharacter() throws Exception + { + restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)).withParams("skipCount=abc") + .withCoreAPI().usingSite(publicSiteModel).getSiteContainers(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "abc")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if get site containers request returns status code 200 when skipCount parameter starts with multiple zero") + public void getSiteContainersWithSkipCountMultipleZero() throws Exception + { + restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)).withParams("skipCount=00002") + .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() + .assertThat().entriesListCountIs(1); + 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 containers request returns status code 400 when site doesn't exist") + public void getSiteContainersWithNonExistentSite() throws Exception + { + restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingSite("NonExistentSiteId").getSiteContainers(); + 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 containers request returns status 200 for private site") + public void getSiteContainersForPrivateSite() throws Exception + { + restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingSite(privateSiteModel).getSiteContainers() + .assertThat().entriesListCountIs(3); + 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 get site containers request returns status 200 for moderated site") + public void getSiteContainersForModeratedSite() throws Exception + { + restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingSite(moderatedSiteModel).getSiteContainers() + .assertThat().entriesListCountIs(3); + 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 get site containers request returns status 200 for several containers") + public void getSiteContainersForSeveralItems() throws Exception + { + restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() + .assertThat().entriesListCountIs(3) + .and().entriesListContains("folderId" ,ContainerName.documentLibrary.toString()) + .and().entriesListContains("folderId", ContainerName.links.toString()) + .and().entriesListContains("folderId", ContainerName.discussions.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 get site containers request returns status 200 for one container") + public void getSiteContainersWithOneItem() throws Exception + { + restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingSite(publicSiteModel).getSiteContainers() + .assertThat().entriesListCountIs(1) + .and().entriesListContains("folderId" ,ContainerName.documentLibrary.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 if get site container request with properties parameter applied returns status code 200") + public void getSiteContainersUsingPropertiesParameter() throws Exception + { + restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingSite(publicSiteWithContainers).usingParams("properties=folderId").getSiteContainers() + .assertThat().entriesListCountIs(3) + .and().entriesListContains("folderId", ContainerName.discussions.toString()) + .and().entriesListContains("folderId", ContainerName.documentLibrary.toString()) + .and().entriesListContains("folderId", ContainerName.links.toString()) + .and().entriesListDoesNotContain("id"); + 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 container request for a container that is not empty returns status code 200") + public void getSiteContainersThatIsNotEmpty() throws Exception + { + restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() + .assertThat().entriesListCountIs(3) + .and().entriesListContains("folderId", ContainerName.documentLibrary.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 if get site containers request returns status code 200 when first container is skipped") + public void getSiteContainersAndSkipFirst() throws Exception + { + restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteCollaborator)) + .withParams("skipCount=1").withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() + .assertThat().entriesListCountIs(2) + .and().entriesListDoesNotContain("folderId", restSiteContainers.getEntries().get(0).onModel().getFolderId()) + .and().entriesListContains("folderId", restSiteContainers.getEntries().get(1).onModel().getFolderId()) + .and().entriesListContains("folderId", restSiteContainers.getEntries().get(2).onModel().getFolderId()); + 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 containers request and get last container returns status code 200") + public void getLastSiteContainer() throws Exception + { + restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteCollaborator)) + .withParams("skipCount=" + String.valueOf(totalItems-1)).withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() + .assertThat().entriesListCountIs(1) + .and().entriesListDoesNotContain("folderId", restSiteContainers.getEntries().get(0).onModel().getFolderId()) + .and().entriesListDoesNotContain("folderId", restSiteContainers.getEntries().get(1).onModel().getFolderId()) + .and().entriesListContains("folderId", restSiteContainers.getEntries().get(2).onModel().getFolderId()); + 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 containers request returns status code 200 when high skipCount parameter is used") + public void getSiteContainersWithHighSkipCount() throws Exception + { + restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteCollaborator)) + .withParams("skipCount=999999").withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() + .assertThat().entriesListIsEmpty() + .and().entriesListCountIs(0) + .and().paginationField("skipCount").is("999999"); + 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 container request for an empty siteId returns status code 404") + public void getSiteContainersForEmptySiteId() throws Exception + { + restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingSite("").getSiteContainers(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } +} diff --git a/e2e-test/java/org/alfresco/rest/sites/members/AddSiteMemberCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/members/AddSiteMemberCoreTests.java deleted file mode 100644 index 1f1357b21..000000000 --- a/e2e-test/java/org/alfresco/rest/sites/members/AddSiteMemberCoreTests.java +++ /dev/null @@ -1,310 +0,0 @@ -package org.alfresco.rest.sites.members; - -import org.alfresco.rest.RestTest; -import org.alfresco.rest.core.JsonBodyGenerator; -import org.alfresco.rest.core.RestRequest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestSiteMemberModel; -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.HttpMethod; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class AddSiteMemberCoreTests extends RestTest -{ - private UserModel adminUserModel; - private SiteModel publicSiteModel; - private SiteModel moderatedSiteModel; - private SiteModel privateSiteModel; - private ListUserWithRoles usersWithRolesToModeratedSite; - private ListUserWithRoles usersWithRolesToPrivateSite; - private String addMembersJson; - private RestSiteMemberModel memberModel; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - publicSiteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - moderatedSiteModel = dataSite.usingUser(adminUserModel).createModeratedRandomSite(); - privateSiteModel = dataSite.usingUser(adminUserModel).createPrivateRandomSite(); - usersWithRolesToModeratedSite = dataUser.addUsersWithRolesToSite(moderatedSiteModel, UserRole.SiteManager, UserRole.SiteCollaborator, - UserRole.SiteConsumer,UserRole.SiteContributor); - usersWithRolesToPrivateSite = dataUser.addUsersWithRolesToSite(privateSiteModel, UserRole.SiteManager, UserRole.SiteCollaborator, - UserRole.SiteConsumer,UserRole.SiteContributor); - addMembersJson = "{\"role\":\"%s\",\"id\":\"%s\"}, {\"role\":\"%s\",\"id\":\"%s\"}"; - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that manager can add another user as manager to a public site and gets status code CREATED (201)") - public void addManagerToPublicSite() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteManager); - memberModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - memberModel.assertThat().field("id").is(testUser.getUsername()) - .and().field("role").is(testUser.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that manager can add another user as manager to a moderated site and gets status code CREATED (201)") - public void addManagerToModeratedSite() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteManager); - memberModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - memberModel.assertThat().field("id").is(testUser.getUsername()) - .and().field("role").is(testUser.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that manager can add another user as manager to a private site and gets status code CREATED (201)") - public void addManagerToPrivateSite() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteManager); - memberModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - memberModel.assertThat().field("id").is(testUser.getUsername()) - .and().field("role").is(testUser.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that consumer role is not able to add another user to a moderated site and gets status code 403") - public void addUserByConsumerToModeratedSite() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteConsumer); - restClient.authenticateUser(usersWithRolesToModeratedSite.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingSite(moderatedSiteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that consumer role is not able to add another user to a private site and gets status code 403") - public void addUserByConsumerToPrivateSite() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteConsumer); - restClient.authenticateUser(usersWithRolesToPrivateSite.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingSite(privateSiteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that collaborator role is not able to add another user to a moderated site and gets status code 403") - public void addUserByCollaboratorToModeratedSite() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteConsumer); - restClient.authenticateUser(usersWithRolesToModeratedSite.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingSite(moderatedSiteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that collaborator role is not able to add another user to a private site and gets status code 403") - public void addUserByCollaboratorToPrivateSite() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteConsumer); - restClient.authenticateUser(usersWithRolesToPrivateSite.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingSite(privateSiteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that contributor role is not able to add another user to a moderated site and gets status code 403") - public void addUserByContributorToModeratedSite() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteConsumer); - restClient.authenticateUser(usersWithRolesToModeratedSite.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingSite(moderatedSiteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that contributor role is not able to add another user to a private site and gets status code 403") - public void addUserByContributorToPrivateSite() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteConsumer); - restClient.authenticateUser(usersWithRolesToPrivateSite.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingSite(privateSiteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that a user without specified role can not be added to a site and gets status code 400") - public void canNotAddUserWithoutSpecifyingRoleToSite() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - restClient.authenticateUser(adminUserModel).withCoreAPI(); - String json = JsonBodyGenerator.keyValueJson("id", testUser.getUsername()); - RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, json, "sites/{siteId}/members?{parameters}", publicSiteModel.getId(), restClient.getParameters()); - restClient.processModel(RestSiteMemberModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(RestErrorModel.MUST_PROVIDE_ROLE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that a user with inexistent role can not be added to a site and gets status code 400") - public void canNotAddUserWithInexistentRoleToSite() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - restClient.authenticateUser(adminUserModel).withCoreAPI(); - RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, String.format("{\"role\":\"inexistentRole\",\"id\":\"%s\"}", testUser.getUsername()), "sites/{siteId}/members?{parameters}", publicSiteModel.getId(), restClient.getParameters()); - restClient.processModel(RestSiteMemberModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.UNKNOWN_ROLE, "inexistentRole")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that user can not add himself as a manager to a public site and gets status code 403") - public void userAddHimselfAsManagerToPublicSite() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteManager); - restClient.authenticateUser(testUser).withCoreAPI().usingSite(publicSiteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that user can not add himself as a manager to a moderated site and gets status code 403") - public void userAddHimselfAsManagerToModeratedSite() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteManager); - restClient.authenticateUser(testUser).withCoreAPI().usingSite(moderatedSiteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that user can not add himself as a manager to a private site and gets status code 404") - public void userAddHimselfAsManagerToPrivateSite() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteManager); - restClient.authenticateUser(testUser).withCoreAPI().usingSite(privateSiteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, privateSiteModel.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that user can not be added to an inexistent site and gets status code 404") - public void userIsNotAbleToAddUserToAnInexistentSite() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteManager); - SiteModel inexistentSite = new SiteModel("inexistentSite"); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(inexistentSite).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, inexistentSite.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that user can not be added to a site if an empty site id is provided and gets status code 404") - public void userIsNotAbleToAddAnotherUserUsingEmptySiteId() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteManager); - SiteModel inexistentSite = new SiteModel(""); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(inexistentSite).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, inexistentSite.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that inexistent user can not be added to site and gets status code 404") - public void userIsNotAbleToAddInexistentUserToSite() throws Exception - { - UserModel testUser = new UserModel("inexistentUser", "password"); - testUser.setUserRole(UserRole.SiteManager); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, testUser.getUsername())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that empty username can not be added to site and gets status code 400") - public void userIsNotAbleToAddEmptyUserIdToSite() throws Exception - { - UserModel testUser = new UserModel("", "password"); - testUser.setUserRole(UserRole.SiteManager); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.NO_CONTENT, testUser.getUsername())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that user can not add another user that is already a memeber and gets status code 409") - public void userIsNotAbleToAddUserThatIsAlreadyAMember() throws Exception - { - UserModel collaborator = usersWithRolesToModeratedSite.getOneUserWithRole(UserRole.SiteCollaborator); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(collaborator); - restClient.assertStatusCodeIs(HttpStatus.CONFLICT).assertLastError().containsSummary(String.format(RestErrorModel.ALREADY_Site_MEMBER, collaborator.getUsername(), moderatedSiteModel.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that several users with different roles can be added once in a row to a site and gets status code 201") - public void addSeveralUsersWithDifferentRolesToASite() throws Exception - { - UserModel firstUser = dataUser.createRandomTestUser("testUser"); - firstUser.setUserRole(UserRole.SiteContributor); - UserModel secondUser = dataUser.createRandomTestUser("testUser"); - secondUser.setUserRole(UserRole.SiteCollaborator); - restClient.authenticateUser(adminUserModel).withCoreAPI(); - String json = String.format(addMembersJson, firstUser.getUserRole(), firstUser.getUsername(), secondUser.getUserRole(), secondUser.getUsername()); - RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, json, "sites/{siteId}/members?{parameters}", publicSiteModel.getId(), restClient.getParameters()); - restClient.processModel(RestSiteMemberModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that several users with same roles can be added once in a row to a site and gets status code 201") - public void addSeveralUsersWithSameRolesToASite() throws Exception - { - UserModel firstUser = dataUser.createRandomTestUser("testUser"); - firstUser.setUserRole(UserRole.SiteCollaborator); - UserModel secondUser = dataUser.createRandomTestUser("testUser"); - secondUser.setUserRole(UserRole.SiteCollaborator); - restClient.authenticateUser(adminUserModel).withCoreAPI(); - String json = String.format(addMembersJson, firstUser.getUserRole(), firstUser.getUsername(), secondUser.getUserRole(), secondUser.getUsername()); - RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, json, "sites/{siteId}/members?{parameters}", publicSiteModel.getId(), restClient.getParameters()); - restClient.processModel(RestSiteMemberModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that several users that are already added to the site can not be added once in a row and gets status code 400") - public void addSeveralUsersThatAreAlreadyAddedToASite() throws Exception - { - UserModel collaborator = usersWithRolesToModeratedSite.getOneUserWithRole(UserRole.SiteCollaborator); - UserModel consumer = usersWithRolesToModeratedSite.getOneUserWithRole(UserRole.SiteConsumer); - restClient.authenticateUser(adminUserModel).withCoreAPI(); - String json = String.format(addMembersJson, collaborator.getUserRole(), collaborator.getUsername(), consumer.getUserRole(), consumer.getUsername()); - RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, json, "sites/{siteId}/members?{parameters}", moderatedSiteModel.getId(), restClient.getParameters()); - restClient.processModel(RestSiteMemberModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.CONFLICT).assertLastError().containsSummary(String.format(RestErrorModel.ALREADY_Site_MEMBER, collaborator.getUsername(), moderatedSiteModel.getId())); - } - -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/sites/members/AddSiteMemberFullTests.java b/e2e-test/java/org/alfresco/rest/sites/members/AddSiteMemberFullTests.java deleted file mode 100644 index 047fb7439..000000000 --- a/e2e-test/java/org/alfresco/rest/sites/members/AddSiteMemberFullTests.java +++ /dev/null @@ -1,256 +0,0 @@ -package org.alfresco.rest.sites.members; - -import org.alfresco.rest.RestTest; -import org.alfresco.rest.core.RestRequest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestSiteMemberModel; -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 AddSiteMemberFullTests extends RestTest -{ - private UserModel adminUserModel; - private SiteModel publicSiteModel; - private SiteModel moderatedSiteModel; - private SiteModel privateSiteModel; - private String addMembersJson; - private RestSiteMemberModel memberModel; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - publicSiteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - moderatedSiteModel = dataSite.usingUser(adminUserModel).createModeratedRandomSite(); - privateSiteModel = dataSite.usingUser(adminUserModel).createPrivateRandomSite(); - addMembersJson = "{\"role\":\"%s\",\"id\":\"%s\"}"; - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Check default error schema when request fails") - public void checkDefaultErrorSchema() throws Exception - { - UserModel testUser = new UserModel("inexistentUser", "password"); - testUser.setUserRole(UserRole.SiteManager); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, testUser.getUsername())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Add new site member request by providing an empty body") - public void addSiteMemberUsingEmptyBody() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI(); - RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "", "sites/{siteId}/members?{parameters}", - publicSiteModel.getId(), restClient.getParameters()); - restClient.processModel(RestSiteMemberModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.NO_CONTENT, "No content to map to Object due to end of input")) - .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "No content to map to Object due to end of input")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Check lower and upper case letters for role field") - public void checkLowerUpperCaseLettersForRole() throws Exception - { - UserModel user = dataUser.createRandomTestUser(); - - String json = String.format(addMembersJson, "SITEMANAGER", user.getUsername()); - restClient.authenticateUser(adminUserModel).withCoreAPI(); - RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, json, "sites/{siteId}/members?{parameters}", publicSiteModel.getId(), restClient.getParameters()); - restClient.processModel(RestSiteMemberModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.UNKNOWN_ROLE, "SITEMANAGER")) - .containsErrorKey(String.format(RestErrorModel.UNKNOWN_ROLE, "SITEMANAGER")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - - json = String.format(addMembersJson, "sitemanager", user.getUsername()); - restClient.authenticateUser(adminUserModel).withCoreAPI(); - request = RestRequest.requestWithBody(HttpMethod.POST, json, "sites/{siteId}/members?{parameters}", publicSiteModel.getId(), restClient.getParameters()); - restClient.processModel(RestSiteMemberModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.UNKNOWN_ROLE, "sitemanager")) - .containsErrorKey(String.format(RestErrorModel.UNKNOWN_ROLE, "sitemanager")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Check empty value for user role") - public void checkEmptyValueForRole() throws Exception - { - UserModel user = dataUser.createRandomTestUser(); - - String json = String.format(addMembersJson, "", user.getUsername()); - restClient.authenticateUser(adminUserModel).withCoreAPI(); - RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, json, "sites/{siteId}/members?{parameters}", publicSiteModel.getId(), restClient.getParameters()); - restClient.processModel(RestSiteMemberModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "N/A (through reference chain: org.alfresco.rest.api.model.SiteMember[\"role\"])")) - .containsSummary(String.format(RestErrorModel.NO_CONTENT, "N/A (through reference chain: org.alfresco.rest.api.model.SiteMember[\"role\"])")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that collaborator role can be added to public site") - public void addCollaboratorToPublicSite() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteCollaborator); - memberModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - memberModel.assertThat().field("id").is(testUser.getUsername()) - .and().field("role").is(testUser.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that contributor role can be added to public site") - public void addContributorToPublicSite() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteContributor); - memberModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - memberModel.assertThat().field("id").is(testUser.getUsername()) - .and().field("role").is(testUser.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that consumer role can be added to public site") - public void addConsumerToPublicSite() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteConsumer); - memberModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - memberModel.assertThat().field("id").is(testUser.getUsername()) - .and().field("role").is(testUser.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that collaborator role can be added to moderated site") - public void addCollaboratorToModeratedSite() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteCollaborator); - memberModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - memberModel.assertThat().field("id").is(testUser.getUsername()) - .and().field("role").is(testUser.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that contributor role can be added to moderated site") - public void addContributorToModeratedSite() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteContributor); - memberModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - memberModel.assertThat().field("id").is(testUser.getUsername()) - .and().field("role").is(testUser.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that consumer role can be added to moderated site") - public void addConsumerToModeratedSite() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteConsumer); - memberModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - memberModel.assertThat().field("id").is(testUser.getUsername()) - .and().field("role").is(testUser.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that collaborator role can be added to private site") - public void addCollaboratorToPrivateSite() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteCollaborator); - memberModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - memberModel.assertThat().field("id").is(testUser.getUsername()) - .and().field("role").is(testUser.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that contributor role can be added to private site") - public void addContributorToPrivateSite() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteContributor); - memberModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - memberModel.assertThat().field("id").is(testUser.getUsername()) - .and().field("role").is(testUser.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that consumer role can be added to private site") - public void addConsumerToPrivateSite() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteConsumer); - memberModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - memberModel.assertThat().field("id").is(testUser.getUsername()) - .and().field("role").is(testUser.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin can be added to private site by site manager") - public void adminCanBeAddedToPrivateSiteBySiteManager() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser(); - SiteModel privateSite = dataSite.usingUser(testUser).createPrivateRandomSite(); - adminUserModel.setUserRole(UserRole.SiteContributor); - memberModel = restClient.authenticateUser(testUser).withCoreAPI().usingSite(privateSite).addPerson(adminUserModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - memberModel.assertThat().field("id").is(adminUserModel.getUsername()).and().field("role").is(adminUserModel.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin cannot be added to private site by site collaborator") - public void adminCannotBeAddedToPrivateSiteBySiteCollaborator() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser(); - SiteModel privateSite = dataSite.usingUser(testUser).createPrivateRandomSite(); - UserModel siteCollaborator = dataUser.createRandomTestUser(); - dataUser.addUserToSite(siteCollaborator, privateSite, UserRole.SiteCollaborator); - adminUserModel.setUserRole(UserRole.SiteContributor); - memberModel = restClient.authenticateUser(siteCollaborator).withCoreAPI().usingSite(privateSite).addPerson(adminUserModel); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/sites/members/AddSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/members/AddSiteMemberSanityTests.java deleted file mode 100644 index 3d4563b7b..000000000 --- a/e2e-test/java/org/alfresco/rest/sites/members/AddSiteMemberSanityTests.java +++ /dev/null @@ -1,118 +0,0 @@ -package org.alfresco.rest.sites.members; - -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -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.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class AddSiteMemberSanityTests extends RestTest -{ - private UserModel adminUserModel; - private SiteModel siteModel; - private ListUserWithRoles usersWithRoles; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, - UserRole.SiteManager, - UserRole.SiteCollaborator, - UserRole.SiteConsumer, - UserRole.SiteContributor); - - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, - description = "Verify that manager is able to add site member and gets status code CREATED (201)") - public void managerIsAbleToAddSiteMember() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteConsumer); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingSite(siteModel).addPerson(testUser) - .assertThat().field("id").is(testUser.getUsername()) - .and().field("role").is(testUser.getUserRole()); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, - description = "Verify that site collaborator is not able to add site member and gets status code FORBIDDEN (403)") - public void collaboratorIsNotAbleToAddSiteMember() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteConsumer); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingSite(siteModel).addPerson(testUser); - - restClient.assertLastError().containsSummary("Permission was denied"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, - description = "Verify that site contributor is not able to add site member and gets status code FORBIDDEN (403)") - public void contributorIsNotAbleToAddSiteMember() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteConsumer); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) - .withCoreAPI().usingSite(siteModel).addPerson(testUser); - restClient.assertLastError().containsSummary("Permission was denied"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, - description = "Verify that site consumer is not able to add site member and gets status code FORBIDDEN (403)") - public void consumerIsNotAbleToAddSiteMember() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteConsumer); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .withCoreAPI().usingSite(siteModel).addPerson(testUser); - restClient.assertLastError().containsSummary("Permission was denied"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, - description = "Verify that admin user is able to add site member and gets status code CREATED (201)") - public void adminIsAbleToAddSiteMember() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteConsumer); - restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingSite(siteModel).addPerson(testUser) - .and().field("id").is(testUser.getUsername()) - .and().field("role").is(testUser.getUserRole()); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - } - - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, - description = "Verify that unauthenticated user is not able to add site member") - @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void unauthenticatedUserIsNotAuthorizedToAddSiteMmeber() throws Exception{ - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteConsumer); - UserModel inexistentUser = new UserModel("inexistent user", "inexistent password"); - restClient.authenticateUser(inexistentUser) - .withCoreAPI().usingSite(siteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } -} diff --git a/e2e-test/java/org/alfresco/rest/sites/members/AddSiteMemberTests.java b/e2e-test/java/org/alfresco/rest/sites/members/AddSiteMemberTests.java new file mode 100644 index 000000000..ecfa79db5 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/sites/members/AddSiteMemberTests.java @@ -0,0 +1,589 @@ +package org.alfresco.rest.sites.members; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.JsonBodyGenerator; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestSiteMemberModel; +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.HttpMethod; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class AddSiteMemberTests extends RestTest +{ + private UserModel adminUserModel; + private SiteModel publicSiteModel, moderatedSiteModel, privateSiteModel; + private ListUserWithRoles publicSiteUsersWithRoles, moderatedSiteUsersWithRoles, privateSiteUsersWithRoles; + private String addMemberJson, addMembersJson; + private RestSiteMemberModel memberModel; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + publicSiteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + moderatedSiteModel = dataSite.usingUser(adminUserModel).createModeratedRandomSite(); + privateSiteModel = dataSite.usingUser(adminUserModel).createPrivateRandomSite(); + publicSiteUsersWithRoles = dataUser.addUsersWithRolesToSite(publicSiteModel, + UserRole.SiteManager, + UserRole.SiteCollaborator, + UserRole.SiteConsumer, + UserRole.SiteContributor); + moderatedSiteUsersWithRoles = dataUser.addUsersWithRolesToSite(moderatedSiteModel, + UserRole.SiteManager, + UserRole.SiteCollaborator, + UserRole.SiteConsumer, + UserRole.SiteContributor); + privateSiteUsersWithRoles = dataUser.addUsersWithRolesToSite(privateSiteModel, + UserRole.SiteManager, + UserRole.SiteCollaborator, + UserRole.SiteConsumer, + UserRole.SiteContributor); + addMemberJson = "{\"role\":\"%s\",\"id\":\"%s\"}"; + addMembersJson = "{\"role\":\"%s\",\"id\":\"%s\"}, {\"role\":\"%s\",\"id\":\"%s\"}"; + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, + description = "Verify that manager is able to add site member and gets status code CREATED (201)") + public void managerIsAbleToAddSiteMember() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteCollaborator); + restClient.authenticateUser(publicSiteUsersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + restClient.withCoreAPI().usingSite(publicSiteModel).addPerson(testUser) + .assertThat().field("id").is(testUser.getUsername()) + .and().field("role").is(testUser.getUserRole()); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that site collaborator is not able to add site member and gets status code FORBIDDEN (403)") + public void collaboratorIsNotAbleToAddSiteMember() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteConsumer); + restClient.authenticateUser(publicSiteUsersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingSite(publicSiteModel).addPerson(testUser); + + restClient.assertLastError().containsSummary("Permission was denied"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION}) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that site contributor is not able to add site member and gets status code FORBIDDEN (403)") + public void contributorIsNotAbleToAddSiteMember() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteConsumer); + restClient.authenticateUser(publicSiteUsersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) + .withCoreAPI().usingSite(publicSiteModel).addPerson(testUser); + restClient.assertLastError().containsSummary("Permission was denied"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that site consumer is not able to add site member and gets status code FORBIDDEN (403)") + public void consumerIsNotAbleToAddSiteMember() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteConsumer); + restClient.authenticateUser(publicSiteUsersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + .withCoreAPI().usingSite(publicSiteModel).addPerson(testUser); + restClient.assertLastError().containsSummary("Permission was denied"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, + description = "Verify that admin user is able to add site member and gets status code CREATED (201)") + public void adminIsAbleToAddSiteMember() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteConsumer); + restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingSite(publicSiteModel).addPerson(testUser) + .and().field("id").is(testUser.getUsername()) + .and().field("role").is(testUser.getUserRole()); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, + description = "Verify that unauthenticated user is not able to add site member") +// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") + public void unauthenticatedUserIsNotAuthorizedToAddSiteMmeber() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteConsumer); + + UserModel userModel = dataUser.createRandomTestUser(); + userModel.setPassword("user wrong password"); + dataUser.addUserToSite(userModel, publicSiteModel, UserRole.SiteManager); + + restClient.authenticateUser(userModel) + .withCoreAPI().usingSite(publicSiteModel).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that manager can add another user as manager to a public site and gets status code CREATED (201)") + public void addManagerToPublicSite() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteManager); + memberModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + memberModel.assertThat().field("id").is(testUser.getUsername()) + .and().field("role").is(testUser.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that manager can add another user as manager to a moderated site and gets status code CREATED (201)") + public void addManagerToModeratedSite() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteManager); + memberModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + memberModel.assertThat().field("id").is(testUser.getUsername()) + .and().field("role").is(testUser.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that manager can add another user as manager to a private site and gets status code CREATED (201)") + public void addManagerToPrivateSite() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteManager); + memberModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + memberModel.assertThat().field("id").is(testUser.getUsername()) + .and().field("role").is(testUser.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that consumer role is not able to add another user to a moderated site and gets status code 403") + public void addUserByConsumerToModeratedSite() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteConsumer); + restClient.authenticateUser(moderatedSiteUsersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingSite(moderatedSiteModel).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that consumer role is not able to add another user to a private site and gets status code 403") + public void addUserByConsumerToPrivateSite() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteConsumer); + restClient.authenticateUser(privateSiteUsersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingSite(privateSiteModel).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that collaborator role is not able to add another user to a moderated site and gets status code 403") + public void addUserByCollaboratorToModeratedSite() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteConsumer); + restClient.authenticateUser(moderatedSiteUsersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingSite(moderatedSiteModel).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that collaborator role is not able to add another user to a private site and gets status code 403") + public void addUserByCollaboratorToPrivateSite() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteConsumer); + restClient.authenticateUser(privateSiteUsersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingSite(privateSiteModel).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that contributor role is not able to add another user to a moderated site and gets status code 403") + public void addUserByContributorToModeratedSite() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteConsumer); + restClient.authenticateUser(moderatedSiteUsersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingSite(moderatedSiteModel).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that contributor role is not able to add another user to a private site and gets status code 403") + public void addUserByContributorToPrivateSite() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteConsumer); + restClient.authenticateUser(privateSiteUsersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingSite(privateSiteModel).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that a user without specified role can not be added to a site and gets status code 400") + public void canNotAddUserWithoutSpecifyingRoleToSite() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + restClient.authenticateUser(adminUserModel).withCoreAPI(); + String json = JsonBodyGenerator.keyValueJson("id", testUser.getUsername()); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, json, "sites/{siteId}/members?{parameters}", publicSiteModel.getId(), restClient.getParameters()); + restClient.processModel(RestSiteMemberModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(RestErrorModel.MUST_PROVIDE_ROLE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that a user with inexistent role can not be added to a site and gets status code 400") + public void canNotAddUserWithInexistentRoleToSite() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + restClient.authenticateUser(adminUserModel).withCoreAPI(); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, String.format("{\"role\":\"inexistentRole\",\"id\":\"%s\"}", testUser.getUsername()), "sites/{siteId}/members?{parameters}", publicSiteModel.getId(), restClient.getParameters()); + restClient.processModel(RestSiteMemberModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.UNKNOWN_ROLE, "inexistentRole")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that user can not add himself as a manager to a public site and gets status code 403") + public void userAddHimselfAsManagerToPublicSite() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteManager); + restClient.authenticateUser(testUser).withCoreAPI().usingSite(publicSiteModel).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that user can not add himself as a manager to a moderated site and gets status code 403") + public void userAddHimselfAsManagerToModeratedSite() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteManager); + restClient.authenticateUser(testUser).withCoreAPI().usingSite(moderatedSiteModel).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that user can not add himself as a manager to a private site and gets status code 404") + public void userAddHimselfAsManagerToPrivateSite() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteManager); + restClient.authenticateUser(testUser).withCoreAPI().usingSite(privateSiteModel).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, privateSiteModel.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that user can not be added to an inexistent site and gets status code 404") + public void userIsNotAbleToAddUserToAnInexistentSite() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteManager); + SiteModel inexistentSite = new SiteModel("inexistentSite"); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(inexistentSite).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, inexistentSite.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that user can not be added to a site if an empty site id is provided and gets status code 404") + public void userIsNotAbleToAddAnotherUserUsingEmptySiteId() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteManager); + SiteModel inexistentSite = new SiteModel(""); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(inexistentSite).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, inexistentSite.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that inexistent user can not be added to site and gets status code 404") + public void userIsNotAbleToAddInexistentUserToSite() throws Exception + { + UserModel testUser = new UserModel("inexistentUser", "password"); + testUser.setUserRole(UserRole.SiteManager); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, testUser.getUsername())) + .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 that empty username can not be added to site and gets status code 400") + public void userIsNotAbleToAddEmptyUserIdToSite() throws Exception + { + UserModel testUser = new UserModel("", "password"); + testUser.setUserRole(UserRole.SiteManager); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.NO_CONTENT, testUser.getUsername())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that user can not add another user that is already a memeber and gets status code 409") + public void userIsNotAbleToAddUserThatIsAlreadyAMember() throws Exception + { + UserModel collaborator = moderatedSiteUsersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(collaborator); + restClient.assertStatusCodeIs(HttpStatus.CONFLICT).assertLastError().containsSummary(String.format(RestErrorModel.ALREADY_Site_MEMBER, collaborator.getUsername(), moderatedSiteModel.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that several users with different roles can be added once in a row to a site and gets status code 201") + public void addSeveralUsersWithDifferentRolesToASite() throws Exception + { + UserModel firstUser = dataUser.createRandomTestUser("testUser"); + firstUser.setUserRole(UserRole.SiteContributor); + UserModel secondUser = dataUser.createRandomTestUser("testUser"); + secondUser.setUserRole(UserRole.SiteCollaborator); + restClient.authenticateUser(adminUserModel).withCoreAPI(); + String json = String.format(addMembersJson, firstUser.getUserRole(), firstUser.getUsername(), secondUser.getUserRole(), secondUser.getUsername()); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, json, "sites/{siteId}/members?{parameters}", publicSiteModel.getId(), restClient.getParameters()); + restClient.processModel(RestSiteMemberModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that several users with same roles can be added once in a row to a site and gets status code 201") + public void addSeveralUsersWithSameRolesToASite() throws Exception + { + UserModel firstUser = dataUser.createRandomTestUser("testUser"); + firstUser.setUserRole(UserRole.SiteCollaborator); + UserModel secondUser = dataUser.createRandomTestUser("testUser"); + secondUser.setUserRole(UserRole.SiteCollaborator); + restClient.authenticateUser(adminUserModel).withCoreAPI(); + String json = String.format(addMembersJson, firstUser.getUserRole(), firstUser.getUsername(), secondUser.getUserRole(), secondUser.getUsername()); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, json, "sites/{siteId}/members?{parameters}", publicSiteModel.getId(), restClient.getParameters()); + restClient.processModel(RestSiteMemberModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that several users that are already added to the site can not be added once in a row and gets status code 400") + public void addSeveralUsersThatAreAlreadyAddedToASite() throws Exception + { + UserModel collaborator = moderatedSiteUsersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); + UserModel consumer = moderatedSiteUsersWithRoles.getOneUserWithRole(UserRole.SiteConsumer); + restClient.authenticateUser(adminUserModel).withCoreAPI(); + String json = String.format(addMembersJson, collaborator.getUserRole(), collaborator.getUsername(), consumer.getUserRole(), consumer.getUsername()); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, json, "sites/{siteId}/members?{parameters}", moderatedSiteModel.getId(), restClient.getParameters()); + restClient.processModel(RestSiteMemberModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.CONFLICT).assertLastError().containsSummary(String.format(RestErrorModel.ALREADY_Site_MEMBER, collaborator.getUsername(), moderatedSiteModel.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Add new site member request by providing an empty body") + public void addSiteMemberUsingEmptyBody() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI(); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "", "sites/{siteId}/members?{parameters}", + publicSiteModel.getId(), restClient.getParameters()); + restClient.processModel(RestSiteMemberModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.NO_CONTENT, "No content to map to Object due to end of input")) + .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "No content to map to Object due to end of input")) + .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 = "Check lower and upper case letters for role field") + public void checkLowerUpperCaseLettersForRole() throws Exception + { + UserModel user = dataUser.createRandomTestUser(); + + String json = String.format(addMemberJson, "SITEMANAGER", user.getUsername()); + restClient.authenticateUser(adminUserModel).withCoreAPI(); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, json, "sites/{siteId}/members?{parameters}", publicSiteModel.getId(), restClient.getParameters()); + restClient.processModel(RestSiteMemberModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.UNKNOWN_ROLE, "SITEMANAGER")) + .containsErrorKey(String.format(RestErrorModel.UNKNOWN_ROLE, "SITEMANAGER")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + + json = String.format(addMemberJson, "sitemanager", user.getUsername()); + restClient.authenticateUser(adminUserModel).withCoreAPI(); + request = RestRequest.requestWithBody(HttpMethod.POST, json, "sites/{siteId}/members?{parameters}", publicSiteModel.getId(), restClient.getParameters()); + restClient.processModel(RestSiteMemberModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.UNKNOWN_ROLE, "sitemanager")) + .containsErrorKey(String.format(RestErrorModel.UNKNOWN_ROLE, "sitemanager")) + .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 = "Check empty value for user role") + public void checkEmptyValueForRole() throws Exception + { + UserModel user = dataUser.createRandomTestUser(); + + String json = String.format(addMemberJson, "", user.getUsername()); + restClient.authenticateUser(adminUserModel).withCoreAPI(); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, json, "sites/{siteId}/members?{parameters}", publicSiteModel.getId(), restClient.getParameters()); + restClient.processModel(RestSiteMemberModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "N/A (through reference chain: org.alfresco.rest.api.model.SiteMember[\"role\"])")) + .containsSummary(String.format(RestErrorModel.NO_CONTENT, "N/A (through reference chain: org.alfresco.rest.api.model.SiteMember[\"role\"])")) + .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 that contributor role can be added to public site") + public void addContributorToPublicSite() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteContributor); + memberModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + memberModel.assertThat().field("id").is(testUser.getUsername()) + .and().field("role").is(testUser.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that collaborator role can be added to moderated site") + public void addCollaboratorToModeratedSite() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteCollaborator); + memberModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + memberModel.assertThat().field("id").is(testUser.getUsername()) + .and().field("role").is(testUser.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that contributor role can be added to moderated site") + public void addContributorToModeratedSite() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteContributor); + memberModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + memberModel.assertThat().field("id").is(testUser.getUsername()) + .and().field("role").is(testUser.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that consumer role can be added to moderated site") + public void addConsumerToModeratedSite() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteConsumer); + memberModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + memberModel.assertThat().field("id").is(testUser.getUsername()) + .and().field("role").is(testUser.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that collaborator role can be added to private site") + public void addCollaboratorToPrivateSite() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteCollaborator); + memberModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + memberModel.assertThat().field("id").is(testUser.getUsername()) + .and().field("role").is(testUser.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that contributor role can be added to private site") + public void addContributorToPrivateSite() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteContributor); + memberModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + memberModel.assertThat().field("id").is(testUser.getUsername()) + .and().field("role").is(testUser.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that consumer role can be added to private site") + public void addConsumerToPrivateSite() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteConsumer); + memberModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + memberModel.assertThat().field("id").is(testUser.getUsername()) + .and().field("role").is(testUser.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin can be added to private site by site manager") + public void adminCanBeAddedToPrivateSiteBySiteManager() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser(); + SiteModel privateSite = dataSite.usingUser(testUser).createPrivateRandomSite(); + adminUserModel.setUserRole(UserRole.SiteContributor); + memberModel = restClient.authenticateUser(testUser).withCoreAPI().usingSite(privateSite).addPerson(adminUserModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + memberModel.assertThat().field("id").is(adminUserModel.getUsername()).and().field("role").is(adminUserModel.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin cannot be added to private site by site collaborator") + public void adminCannotBeAddedToPrivateSiteBySiteCollaborator() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser(); + SiteModel privateSite = dataSite.usingUser(testUser).createPrivateRandomSite(); + UserModel siteCollaborator = dataUser.createRandomTestUser(); + dataUser.addUserToSite(siteCollaborator, privateSite, UserRole.SiteCollaborator); + adminUserModel.setUserRole(UserRole.SiteContributor); + memberModel = restClient.authenticateUser(siteCollaborator).withCoreAPI().usingSite(privateSite).addPerson(adminUserModel); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } +} diff --git a/e2e-test/java/org/alfresco/rest/sites/members/GetSiteMemberCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/members/GetSiteMemberCoreTests.java deleted file mode 100644 index 3b0e1b12e..000000000 --- a/e2e-test/java/org/alfresco/rest/sites/members/GetSiteMemberCoreTests.java +++ /dev/null @@ -1,175 +0,0 @@ -package org.alfresco.rest.sites.members; - -import org.alfresco.rest.RestTest; -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 Cristina Axinte - * - */ -public class GetSiteMemberCoreTests extends RestTest -{ - private UserModel adminUser; - private SiteModel siteModel; - private ListUserWithRoles usersWithRoles; - private UserModel manager, consumer, collaborator, contributor; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws DataPreparationException - { - adminUser = dataUser.getAdminUser(); - siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - consumer = dataUser.createRandomTestUser(); - dataUser.addUserToSite(consumer, siteModel, UserRole.SiteConsumer); - - manager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); - collaborator = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); - contributor = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @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.CORE }) - @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(siteModel).getSiteMember(nonMember); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, nonMember.getUsername(), siteModel.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @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(siteModel).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.CORE }) - @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 manager = dataUser.createRandomTestUser(); - dataUser.addUserToSite(manager, siteModel, UserRole.SiteManager); - UserModel meUser = new UserModel("-me-", "password"); - - restClient.authenticateUser(manager); - restClient.withCoreAPI().usingSite(siteModel).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.CORE }) - @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.CORE }) - @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, siteModel, UserRole.SiteManager); - - restClient.authenticateUser(manager); - restClient.withCoreAPI().usingSite(siteModel).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.CORE }) - @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(siteModel).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.CORE }) - @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(siteModel).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.CORE }) - @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(siteModel).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.CORE }) - @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(siteModel).getSiteMember(adminUser) - .assertThat().field("id").is(adminUser.getUsername()) - .and().field("role").is(UserRole.SiteManager); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - -} diff --git a/e2e-test/java/org/alfresco/rest/sites/members/GetSiteMemberFullTests.java b/e2e-test/java/org/alfresco/rest/sites/members/GetSiteMemberFullTests.java deleted file mode 100644 index 9a49a67b9..000000000 --- a/e2e-test/java/org/alfresco/rest/sites/members/GetSiteMemberFullTests.java +++ /dev/null @@ -1,192 +0,0 @@ -package org.alfresco.rest.sites.members; - -import org.alfresco.rest.RestTest; -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; - -public class GetSiteMemberFullTests extends RestTest -{ - private UserModel adminUser; - private SiteModel siteModel; - private SiteModel moderatedSiteModel; - private SiteModel privateSiteModel; - private ListUserWithRoles usersWithRoles; - private UserModel manager, consumer, collaborator, contributor; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws DataPreparationException - { - adminUser = dataUser.getAdminUser(); - siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); - moderatedSiteModel = dataSite.usingUser(adminUser).createModeratedRandomSite(); - privateSiteModel = dataSite.usingUser(adminUser).createPrivateRandomSite(); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - - consumer = usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer); - manager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); - collaborator = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); - contributor = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); - - 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.FULL }) - @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(siteModel).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.FULL }) - @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(siteModel).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.FULL }) - @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(siteModel).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.FULL }) - @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(siteModel).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.FULL }) - @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.FULL }) - @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 userThatIsNotMemberOfPrivateSiteIsNotAbleToGetSiteMember() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - - restClient.authenticateUser(newMember).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.FULL }) - 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.FULL }) - @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, siteModel, 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.FULL }) - @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.FULL }) - @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.FULL }) - @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 userThatIsNotMemberOfModeratedSiteIsAbleToGetSiteMember() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - - restClient.authenticateUser(newMember).withCoreAPI().usingSite(moderatedSiteModel).getSiteMember(consumer); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) - @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(siteModel).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); - } -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/sites/members/GetSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/members/GetSiteMemberSanityTests.java deleted file mode 100644 index 02d86b00a..000000000 --- a/e2e-test/java/org/alfresco/rest/sites/members/GetSiteMemberSanityTests.java +++ /dev/null @@ -1,112 +0,0 @@ -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.report.Bug; -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 GetSiteMemberSanityTests extends RestTest -{ - private UserModel adminUser; - private SiteModel siteModel; - private ListUserWithRoles usersWithRoles; - private UserModel userModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws DataPreparationException - { - adminUser = dataUser.getAdminUser(); - siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - userModel = dataUser.createRandomTestUser(); - dataUser.addUserToSite(userModel, siteModel, UserRole.SiteConsumer); - } - - @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(siteModel).getSiteMember(userModel) - .assertThat().field("id").is(userModel.getUsername()) - .and().field("role").is(userModel.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 = "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(siteModel).getSiteMember(userModel) - .and().field("id").is(userModel.getUsername()) - .and().field("role").is(userModel.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 = "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(siteModel).getSiteMember(userModel) - .and().field("id").is(userModel.getUsername()) - .and().field("role").is(userModel.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 = "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(siteModel).getSiteMember(userModel) - .and().field("id").is(userModel.getUsername()) - .and().field("role").is(userModel.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 = "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(siteModel).getSiteMember(userModel) - .and().field("id").is(userModel.getUsername()) - .and().field("role").is(userModel.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(siteModel).getSiteMember(userModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } -} diff --git a/e2e-test/java/org/alfresco/rest/sites/members/GetSiteMemberTests.java b/e2e-test/java/org/alfresco/rest/sites/members/GetSiteMemberTests.java new file mode 100644 index 000000000..b9c0e9f49 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/sites/members/GetSiteMemberTests.java @@ -0,0 +1,396 @@ +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).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @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); + } +} diff --git a/e2e-test/java/org/alfresco/rest/sites/members/GetSiteMembersCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/members/GetSiteMembersCoreTests.java deleted file mode 100644 index 75a125bc9..000000000 --- a/e2e-test/java/org/alfresco/rest/sites/members/GetSiteMembersCoreTests.java +++ /dev/null @@ -1,159 +0,0 @@ -package org.alfresco.rest.sites.members; - -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestSiteMemberModelsCollection; -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.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Created by Claudia Agache on 11/23/2016. - */ -public class GetSiteMembersCoreTests extends RestTest -{ - private UserModel userModel, publicSiteContributor, privateSiteConsumer, moderatedSiteManager, admin; - private SiteModel publicSite, privateSite, moderatedSite, moderatedSite2; - private RestSiteMemberModelsCollection siteMembers; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - admin = dataUser.getAdminUser(); - userModel = dataUser.createRandomTestUser(); - publicSiteContributor = dataUser.createRandomTestUser(); - moderatedSiteManager = dataUser.createRandomTestUser(); - privateSiteConsumer = dataUser.createRandomTestUser(); - publicSite = dataSite.usingAdmin().createPublicRandomSite(); - privateSite = dataSite.usingAdmin().createPrivateRandomSite(); - moderatedSite = dataSite.usingAdmin().createModeratedRandomSite(); - moderatedSite2 = dataSite.usingAdmin().createModeratedRandomSite(); - dataUser.addUserToSite(publicSiteContributor, publicSite, UserRole.SiteContributor); - dataUser.addUserToSite(moderatedSiteManager, moderatedSite, UserRole.SiteManager); - dataUser.addUserToSite(privateSiteConsumer, privateSite, UserRole.SiteConsumer); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @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(publicSiteContributor).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.CORE }) - @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(publicSiteContributor).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.authenticateUser(publicSiteContributor).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.CORE }) - @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(publicSiteContributor).withParams("skipCount=A") - .withCoreAPI().usingSite(publicSite).getSiteMembers(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "A")); - - restClient.authenticateUser(publicSiteContributor).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.CORE }) - @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(userModel).withCoreAPI() - .usingSite(publicSite).getSiteMembers(); - restClient.assertStatusCodeIs(HttpStatus.OK); - siteMembers.assertThat().entriesListContains("id", admin.getUsername()) - .and().entriesListContains("id", publicSiteContributor.getUsername()) - .and().paginationField("count").is("2"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @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(userModel).withCoreAPI() - .usingSite(moderatedSite).getSiteMembers(); - restClient.assertStatusCodeIs(HttpStatus.OK); - siteMembers.assertThat().entriesListContains("id", admin.getUsername()) - .and().entriesListContains("id", moderatedSiteManager.getUsername()) - .and().paginationField("count").is("2"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @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", admin.getUsername()) - .and().entriesListContains("id", privateSiteConsumer.getUsername()) - .and().paginationField("count").is("2"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @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(userModel).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.CORE }) - @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(userModel).withCoreAPI() - .usingSite(moderatedSite2).getSiteMembers(); - restClient.assertStatusCodeIs(HttpStatus.OK); - siteMembers.assertThat().entriesListContains("id", admin.getUsername()) - .and().paginationField("count").is("1"); - - restClient.authenticateUser(admin).withCoreAPI().usingSite(moderatedSite2).addPerson(privateSiteConsumer); - - siteMembers = restClient.authenticateUser(userModel).withCoreAPI() - .usingSite(moderatedSite2).getSiteMembers(); - restClient.assertStatusCodeIs(HttpStatus.OK); - siteMembers.assertThat().entriesListContains("id", admin.getUsername()) - .and().entriesListContains("id", privateSiteConsumer.getUsername()) - .and().paginationField("count").is("2"); - } - -} diff --git a/e2e-test/java/org/alfresco/rest/sites/members/GetSiteMembersFullTests.java b/e2e-test/java/org/alfresco/rest/sites/members/GetSiteMembersFullTests.java deleted file mode 100644 index 443ab28dc..000000000 --- a/e2e-test/java/org/alfresco/rest/sites/members/GetSiteMembersFullTests.java +++ /dev/null @@ -1,160 +0,0 @@ -package org.alfresco.rest.sites.members; - -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestSiteMemberModel; -import org.alfresco.rest.model.RestSiteMemberModelsCollection; -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.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * - * @author Cristina Axinte - * - */ -public class GetSiteMembersFullTests extends RestTest -{ - private UserModel userModel, publicSiteContributor; - private UserModel moderatedSiteContributor, moderatedSiteCollaborator, moderatedSiteConsumer; - private SiteModel publicSite, moderatedSite, moderatedSite2; - private RestSiteMemberModelsCollection siteMembers; - private RestSiteMemberModel firstSiteMember, secondSiteMember, thirdSiteMember, fourthSiteMember; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - publicSiteContributor = dataUser.createRandomTestUser(); - moderatedSiteContributor = dataUser.createRandomTestUser(); - moderatedSiteCollaborator = dataUser.createRandomTestUser(); - moderatedSiteConsumer = dataUser.createRandomTestUser(); - publicSite = dataSite.usingUser(userModel).createPublicRandomSite(); - moderatedSite = dataSite.usingUser(userModel).createModeratedRandomSite(); - moderatedSite2 = dataSite.usingUser(userModel).createModeratedRandomSite(); - dataUser.addUserToSite(publicSiteContributor, publicSite, UserRole.SiteContributor); - dataUser.addUserToSite(publicSiteContributor, publicSite, UserRole.SiteContributor); - dataUser.addUserToSite(moderatedSiteContributor, moderatedSite, UserRole.SiteContributor); - dataUser.addUserToSite(moderatedSiteCollaborator, moderatedSite, UserRole.SiteCollaborator); - dataUser.addUserToSite(moderatedSiteConsumer, moderatedSite, UserRole.SiteConsumer); - dataUser.addUserToSite(moderatedSiteContributor, moderatedSite2, UserRole.SiteContributor); - - siteMembers = restClient.authenticateUser(userModel).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.FULL }) - @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(userModel).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", userModel.getUsername()) - .and().entriesListContains("role", UserRole.SiteContributor.toString()) - .and().entriesListContains("id", moderatedSiteContributor.getUsername()) - .and().entriesListContains("role", UserRole.SiteCollaborator.toString()) - .and().entriesListContains("id", moderatedSiteCollaborator.getUsername()) - .and().entriesListContains("role", UserRole.SiteConsumer.toString()) - .and().entriesListContains("id", moderatedSiteConsumer.getUsername()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) - @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(userModel).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.FULL }) - @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(userModel).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.FULL }) - @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(userModel).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.FULL }) - @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(userModel).withCoreAPI() - .usingSite(moderatedSite2).getSiteMembers(); - restClient.assertStatusCodeIs(HttpStatus.OK); - siteMembers.assertThat().entriesListContains("role", UserRole.SiteManager.toString()) - .and().entriesListContains("id", userModel.getUsername()) - .and().entriesListDoesNotContain("id", userNotJoined.getUsername()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) - @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 getSiteMembersAfterRemoveTheSiteMember() throws Exception - { - siteMembers = restClient.authenticateUser(userModel).withCoreAPI() - .usingSite(moderatedSite2).getSiteMembers(); - restClient.assertStatusCodeIs(HttpStatus.OK); - siteMembers.assertThat().entriesListCountIs(2); - - restClient.authenticateUser(userModel).withCoreAPI().usingSite(moderatedSite2).deleteSiteMember(moderatedSiteContributor); - - siteMembers = restClient.authenticateUser(userModel).withCoreAPI() - .usingSite(moderatedSite2).getSiteMembers(); - restClient.assertStatusCodeIs(HttpStatus.OK); - siteMembers.assertThat().entriesListCountIs(1) - .and().entriesListContains("role", UserRole.SiteManager.toString()) - .and().entriesListContains("id", userModel.getUsername()); - } -} diff --git a/e2e-test/java/org/alfresco/rest/sites/members/GetSiteMembersSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/members/GetSiteMembersSanityTests.java deleted file mode 100644 index dee39cf47..000000000 --- a/e2e-test/java/org/alfresco/rest/sites/members/GetSiteMembersSanityTests.java +++ /dev/null @@ -1,111 +0,0 @@ -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.report.Bug; -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 GetSiteMembersSanityTests extends RestTest -{ - private SiteModel siteModel; - private UserModel adminUser; - private ListUserWithRoles usersWithRoles; - private UserModel userModel; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws DataPreparationException - { - adminUser = dataUser.getAdminUser(); - siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); - } - - @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 JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingSite(siteModel).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.SANITY }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, - description = "Verify user with Collaborator role gets site members and gets status code OK (200)") - public void getSiteMembersWithCollaboratorRole() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingSite(siteModel).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.SANITY }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, - description = "Verify user with Contributor role gets site members and gets status code OK (200)") - public void getSiteMembersWithContributorRole() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) - .withCoreAPI().usingSite(siteModel).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.SANITY }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, - description = "Verify user with Consumer role gets site members and gets status code OK (200)") - public void getSiteMembersWithConsumerRole() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .withCoreAPI().usingSite(siteModel).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.SANITY }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, - description = "Verify user with admin usere gets site members and gets status code OK (200)") - public void getSiteMembersWithAdminUser() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUser) - .withCoreAPI().usingSite(siteModel).getSiteMembers().assertThat().entriesListIsNotEmpty() - .and().entriesListContains("id", adminUser.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 JsonToModelConversionException, Exception - { - userModel = dataUser.createRandomTestUser(); - userModel.setPassword("user wrong password"); - dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); - restClient.authenticateUser(userModel) - .withCoreAPI().usingSite(siteModel).getSiteMembers(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } -} diff --git a/e2e-test/java/org/alfresco/rest/sites/members/GetSiteMembersTests.java b/e2e-test/java/org/alfresco/rest/sites/members/GetSiteMembersTests.java new file mode 100644 index 000000000..77b411880 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/sites/members/GetSiteMembersTests.java @@ -0,0 +1,357 @@ +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.Utility; +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 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).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @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()); + } +} diff --git a/e2e-test/java/org/alfresco/rest/sites/members/RemoveSiteMemberCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/members/RemoveSiteMemberCoreTests.java deleted file mode 100644 index 48570de79..000000000 --- a/e2e-test/java/org/alfresco/rest/sites/members/RemoveSiteMemberCoreTests.java +++ /dev/null @@ -1,269 +0,0 @@ -package org.alfresco.rest.sites.members; - -import org.alfresco.rest.RestTest; -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 Cristina Axinte - * - */ -public class RemoveSiteMemberCoreTests extends RestTest -{ - private SiteModel siteModel; - private UserModel adminUserModel; - private ListUserWithRoles usersWithRoles; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws DataPreparationException - { - adminUserModel = dataUser.getAdminUser(); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, - UserRole.SiteConsumer, UserRole.SiteContributor); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that manager can NOT delete site member for an inexistent user and gets status code 404, 'Not Found'") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - public void managerIsNotAbleToDeleteInexistentSiteMember() throws Exception - { - UserModel inexistentUser = new UserModel("inexistentUser", "password"); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingSite(siteModel).deleteSiteMember(inexistentUser); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, inexistentUser.getUsername())); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that manager can NOT delete site member for a non site member and gets status code 400, 'Bad Request'") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - public void managerIsNotAbleToDeleteNotSiteMember() throws Exception - { - UserModel nonMember = dataUser.createRandomTestUser(); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingSite(siteModel).deleteSiteMember(nonMember); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_ARGUMENT, "argument")); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that manager can NOT delete site member for an invalid site and gets status code 404, 'Not Found'") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - public void managerIsNotAbleToDeleteSiteMemberOfInvalidSite() throws Exception - { - SiteModel invalidSite = new SiteModel("invalidSite"); - UserModel testUserModel = dataUser.createRandomTestUser(); - dataUser.addUserToSite(testUserModel, siteModel, UserRole.SiteConsumer); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingSite(invalidSite).deleteSiteMember(testUserModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, testUserModel.getUsername(), invalidSite.getId())); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that manager can delete a site member with manager role") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - public void siteManagerIsAbleToDeleteSiteMemberWithManagerRole() throws Exception - { - UserModel anothermanager = dataUser.createRandomTestUser(); - dataUser.addUserToSite(anothermanager, siteModel, UserRole.SiteManager); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingSite(siteModel).deleteSiteMember(anothermanager); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingSite(siteModel).getSiteMembers() - .assertThat().entriesListDoesNotContain("id", anothermanager.getUsername()); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that manager can delete site member using \"-me-\" in place of personId") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - public void managerIsAbleToDeleteSiteMemberUsingMe() throws Exception - { - UserModel manager = dataUser.createRandomTestUser(); - dataUser.addUserToSite(manager, siteModel, UserRole.SiteManager); - UserModel meUser = new UserModel("-me-", "password"); - - restClient.authenticateUser(manager); - restClient.withCoreAPI().usingSite(siteModel).deleteSiteMember(meUser); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingSite(siteModel).getSiteMembers() - .assertThat().entriesListDoesNotContain("id", manager.getUsername()); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that site collaborator cannot delete a site member with Manager role and gets status code 422") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - public void siteCollaboratorIsNotAbleToDeleteSiteMemberWithManagerRole() throws Exception - { - UserModel managerForDelete = dataUser.createRandomTestUser(); - dataUser.addUserToSite(managerForDelete, siteModel, UserRole.SiteManager); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.withCoreAPI().usingSite(siteModel).deleteSiteMember(managerForDelete); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY) - .assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getId())); - - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that site contributor cannot delete site member with Manager role and gets status code 422") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - public void siteContributorIsNotAbleToDeleteSiteMemberWithManagerRole() throws Exception - { - UserModel managerForDelete = dataUser.createRandomTestUser(); - dataUser.addUserToSite(managerForDelete, siteModel, UserRole.SiteManager); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - restClient.withCoreAPI().usingSite(siteModel).deleteSiteMember(managerForDelete); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY) - .assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getId())); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that site consumer cannot delete site member with Manager role and gets status code 422") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - public void siteConsumerIsNotAbleToDeleteSiteMemberWithManagerRole() throws Exception - { - UserModel managerForDelete = dataUser.createRandomTestUser(); - dataUser.addUserToSite(managerForDelete, siteModel, UserRole.SiteManager); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.withCoreAPI().usingSite(siteModel).deleteSiteMember(managerForDelete); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY) - .assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getId())); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that site collaborator cannot delete a site member with Contributor role and gets status code 422") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - public void siteCollaboratorIsNotAbleToDeleteSiteMemberWithContributorRole() throws Exception - { - UserModel contributorForDelete = dataUser.createRandomTestUser(); - dataUser.addUserToSite(contributorForDelete, siteModel, UserRole.SiteContributor); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.withCoreAPI().usingSite(siteModel).deleteSiteMember(contributorForDelete); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY) - .assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getId())); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that site contributor cannot delete site member with Contributor role and gets status code 422") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - public void siteContributorIsNotAbleToDeleteSiteMemberWithContributorRole() throws Exception - { - UserModel contributorForDelete = dataUser.createRandomTestUser(); - dataUser.addUserToSite(contributorForDelete, siteModel, UserRole.SiteContributor); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - restClient.withCoreAPI().usingSite(siteModel).deleteSiteMember(contributorForDelete); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY) - .assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getId())); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that site consumer cannot delete site member with Contributor role and gets status code 422") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - public void siteConsumerIsNotAbleToDeleteSiteMemberWithContributorRole() throws Exception - { - UserModel contributorForDelete = dataUser.createRandomTestUser(); - dataUser.addUserToSite(contributorForDelete, siteModel, UserRole.SiteContributor); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.withCoreAPI().usingSite(siteModel).deleteSiteMember(contributorForDelete); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY) - .assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getId())); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that manager can delete a site member with Contributor role") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - public void siteManagerIsAbleToDeleteSiteMemberWithContributorRole() throws Exception - { - UserModel contributorForDelete = dataUser.createRandomTestUser(); - dataUser.addUserToSite(contributorForDelete, siteModel, UserRole.SiteContributor); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingSite(siteModel).deleteSiteMember(contributorForDelete); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingSite(siteModel).getSiteMembers() - .assertThat().entriesListDoesNotContain("id", contributorForDelete.getUsername()); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that site collaborator cannot delete a site member with Collaborator role and gets status code 422") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - public void siteCollaboratorIsNotAbleToDeleteSiteMemberWithCollaboratorRole() throws Exception - { - UserModel collaboratorForDelete = dataUser.createRandomTestUser(); - dataUser.addUserToSite(collaboratorForDelete, siteModel, UserRole.SiteCollaborator); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.withCoreAPI().usingSite(siteModel).deleteSiteMember(collaboratorForDelete); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY) - .assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getId())); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that site contributor cannot delete site member with Collaborator role and gets status code 422") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - public void siteContributorIsNotAbleToDeleteSiteMemberWithCollaboratorRole() throws Exception - { - UserModel collaboratorForDelete = dataUser.createRandomTestUser(); - dataUser.addUserToSite(collaboratorForDelete, siteModel, UserRole.SiteCollaborator); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - restClient.withCoreAPI().usingSite(siteModel).deleteSiteMember(collaboratorForDelete); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY) - .assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getId())); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that site consumer cannot delete site member with Collaborator role and gets status code 422") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - public void siteConsumerIsNotAbleToDeleteSiteMemberWithCollaboratorRole() throws Exception - { - UserModel collaboratorForDelete = dataUser.createRandomTestUser(); - dataUser.addUserToSite(collaboratorForDelete, siteModel, UserRole.SiteCollaborator); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.withCoreAPI().usingSite(siteModel).deleteSiteMember(collaboratorForDelete); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY) - .assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getId())); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that manager can delete a site member with Collaborator role") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - public void siteManagerIsAbleToDeleteSiteMemberWithCollaboratorRole() throws Exception - { - UserModel collaboratorForDelete = dataUser.createRandomTestUser(); - dataUser.addUserToSite(collaboratorForDelete, siteModel, UserRole.SiteCollaborator); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingSite(siteModel).deleteSiteMember(collaboratorForDelete); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingSite(siteModel).getSiteMembers() - .assertThat().entriesListDoesNotContain("id", collaboratorForDelete.getUsername()); - } -} diff --git a/e2e-test/java/org/alfresco/rest/sites/members/RemoveSiteMemberFullTests.java b/e2e-test/java/org/alfresco/rest/sites/members/RemoveSiteMemberFullTests.java deleted file mode 100644 index e50fea524..000000000 --- a/e2e-test/java/org/alfresco/rest/sites/members/RemoveSiteMemberFullTests.java +++ /dev/null @@ -1,150 +0,0 @@ -package org.alfresco.rest.sites.members; - -import org.alfresco.rest.RestTest; -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.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class RemoveSiteMemberFullTests extends RestTest -{ - private SiteModel siteModel; - private UserModel adminUserModel; - private ListUserWithRoles usersWithRoles; - private SiteModel moderatedSiteModel; - private SiteModel privateSiteModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws DataPreparationException - { - adminUserModel = dataUser.getAdminUser(); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - moderatedSiteModel = dataSite.usingUser(adminUserModel).createModeratedRandomSite(); - privateSiteModel = dataSite.usingUser(adminUserModel).createPrivateRandomSite(); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, - UserRole.SiteConsumer, UserRole.SiteContributor); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin can delete a site member with Contributor role and gets status code 204") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) - public void adminIsAbleToDeleteSiteMemberWithContributorRole() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(siteModel) - .deleteSiteMember(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - dataUser.addUserToSite(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor), siteModel, UserRole.SiteContributor); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin can delete site member with Manager role and gets status code 204") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) - public void aminIsAbleToDeleteSiteMemberWithManagerRole() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(siteModel) - .deleteSiteMember(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - dataUser.addUserToSite(usersWithRoles.getOneUserWithRole(UserRole.SiteManager), siteModel, UserRole.SiteManager); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin can delete site member with Consumer role and gets status code 204") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) - public void adminIsAbleToDeleteSiteMemberWithConsumerRole() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(siteModel) - .deleteSiteMember(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - dataUser.addUserToSite(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer), siteModel, UserRole.SiteConsumer); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin can delete a site member with Collaborator role and gets status code 204") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) - public void adminIsAbleToDeleteSiteMemberWithCollaboratorRole() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(siteModel) - .deleteSiteMember(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - dataUser.addUserToSite(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), siteModel, UserRole.SiteCollaborator); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin can delete a site member of moderated site and gets status code 204") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) - public void adminIsAbleToDeleteModeratedSiteMember() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - newMember.setUserRole(UserRole.SiteManager); - dataUser.addUserToSite(newMember, moderatedSiteModel, UserRole.SiteManager); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).deleteSiteMember(newMember); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin can delete a site member of private site and gets status code 204") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) - public void adminIsAbleToDeletePrivateSiteMember() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - newMember.setUserRole(UserRole.SiteManager); - dataUser.addUserToSite(newMember, privateSiteModel, UserRole.SiteManager); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).deleteSiteMember(newMember); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that regular user can not delete admin and gets status code 422") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) - public void regularUserIsNotAbleToDeleteAdmin() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingSite(siteModel) - .deleteSiteMember(adminUserModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() - .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getTitle())) - .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin can not delete a site member twice and gets status code 404 for the second attempt") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) - @Bug(id="ACE-5447") - public void adminIsNotAbleToRemoveSiteMemberTwice() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(siteModel) - .deleteSiteMember(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(siteModel) - .deleteSiteMember(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(RestErrorModel.ENTITY_NOT_FOUND); - dataUser.addUserToSite(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor), siteModel, UserRole.SiteContributor); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify admin is not able to remove from site a user that created a member request that was not accepted yet") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) - @Bug(id="ACE-5447") - public void adminIsNotAbleToRemoveFromSiteANonExistingMember() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(siteModel); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).deleteSiteMember(newMember); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(RestErrorModel.ENTITY_NOT_FOUND); - } -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/sites/members/RemoveSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/members/RemoveSiteMemberSanityTests.java deleted file mode 100644 index f7e101113..000000000 --- a/e2e-test/java/org/alfresco/rest/sites/members/RemoveSiteMemberSanityTests.java +++ /dev/null @@ -1,134 +0,0 @@ -package org.alfresco.rest.sites.members; - -import org.alfresco.rest.RestTest; -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.report.Bug; -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 RemoveSiteMemberSanityTests extends RestTest -{ - private SiteModel siteModel; - private UserModel adminUserModel; - private ListUserWithRoles usersWithRoles; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws DataPreparationException - { - adminUserModel = dataUser.getAdminUser(); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that site manager can delete site member and gets status code 204, 'No Content'") - public void siteManagerIsAbleToDeleteSiteMemberWithConsumerRole() throws Exception - { - UserModel testUserModel = dataUser.createRandomTestUser(); - dataUser.addUserToSite(testUserModel, siteModel, UserRole.SiteConsumer); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingSite(siteModel).deleteSiteMember(testUserModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingSite(siteModel).getSiteMembers() - .assertThat().entriesListDoesNotContain("id", testUserModel.getUsername()); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that site collaborator cannot delete site member and gets status code 403, 'Forbidden'") - public void siteCollaboratorIsNotAbleToDeleteSiteMemberWithConsumerRole() throws Exception - { - UserModel testUserModel = dataUser.createRandomTestUser(); - dataUser.addUserToSite(testUserModel, siteModel, UserRole.SiteConsumer); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.withCoreAPI().usingSite(siteModel).deleteSiteMember(testUserModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY); - - restClient.withCoreAPI().usingSite(siteModel).getSiteMembers() - .assertThat().entriesListContains("id", testUserModel.getUsername()); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that site contributor cannot delete site member and gets status code 403, 'Forbidden'") - public void siteContributorIsNotAbleToDeleteSiteMemberWithConsumerRole() throws Exception - { - UserModel testUserModel = dataUser.createRandomTestUser(); - dataUser.addUserToSite(testUserModel, siteModel, UserRole.SiteConsumer); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - restClient.withCoreAPI().usingSite(siteModel).deleteSiteMember(testUserModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY); - - restClient.withCoreAPI().usingSite(siteModel).getSiteMembers() - .assertThat().entriesListContains("id", testUserModel.getUsername()); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that site consumer cannot delete site member and gets status code 403, 'Forbidden'") - public void siteConsumerIsNotAbleToDeleteSiteMemberWithConsumerRole() throws Exception - { - UserModel testUserModel = dataUser.createRandomTestUser(); - dataUser.addUserToSite(testUserModel, siteModel, UserRole.SiteConsumer); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingSite(siteModel) - .deleteSiteMember(testUserModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY); - - restClient.withCoreAPI().usingSite(siteModel).getSiteMembers() - .assertThat().entriesListContains("id", testUserModel.getUsername()); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that admin user can delete site member and gets status code 204, 'No Content'") - public void adminUserIsAbleToDeleteSiteMember() throws Exception - { - UserModel testUserModel = dataUser.createRandomTestUser(); - dataUser.addUserToSite(testUserModel, siteModel, UserRole.SiteConsumer); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(siteModel).deleteSiteMember(testUserModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingSite(siteModel).getSiteMembers() - .assertThat().entriesListDoesNotContain("id", testUserModel.getUsername()); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that unauthenticated user is not able to delete site member") - @Bug(id = "MNT-16904", description = "It fails only on environment with tenants") - public void unauthenticatedUserIsNotAuthorizedToDeleteSiteMember() throws Exception - { - UserModel testUserModel = dataUser.createRandomTestUser(); - dataUser.addUserToSite(testUserModel, siteModel, UserRole.SiteConsumer); - - UserModel inexistentUser = new UserModel("inexistent user", "inexistent password"); - restClient.authenticateUser(inexistentUser).withCoreAPI().usingSite(siteModel).deleteSiteMember(testUserModel); - - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } -} diff --git a/e2e-test/java/org/alfresco/rest/sites/members/RemoveSiteMemberTests.java b/e2e-test/java/org/alfresco/rest/sites/members/RemoveSiteMemberTests.java new file mode 100644 index 000000000..cfca3e3d5 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/sites/members/RemoveSiteMemberTests.java @@ -0,0 +1,467 @@ +package org.alfresco.rest.sites.members; + +import org.alfresco.rest.RestTest; +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.report.Bug; +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 RemoveSiteMemberTests extends RestTest +{ + private SiteModel publicSiteModel, moderatedSiteModel, privateSiteModel; + private UserModel adminUserModel, siteCreator; + private ListUserWithRoles usersWithRoles; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws DataPreparationException + { + adminUserModel = dataUser.getAdminUser(); + siteCreator = dataUser.createRandomTestUser(); + publicSiteModel = dataSite.usingUser(siteCreator).createPublicRandomSite(); + moderatedSiteModel = dataSite.usingUser(siteCreator).createModeratedRandomSite(); + privateSiteModel = dataSite.usingUser(siteCreator).createPrivateRandomSite(); + usersWithRoles = dataUser.addUsersWithRolesToSite(publicSiteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that site manager can delete site member and gets status code 204, 'No Content'") + public void siteManagerIsAbleToDeleteSiteMemberWithConsumerRole() throws Exception + { + UserModel testUserModel = dataUser.createRandomTestUser(); + dataUser.addUserToSite(testUserModel, publicSiteModel, UserRole.SiteConsumer); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + restClient.withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(testUserModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMembers() + .assertThat().entriesListDoesNotContain("id", testUserModel.getUsername()); + 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 that site collaborator cannot delete site member and gets status code 403, 'Forbidden'") + public void siteCollaboratorIsNotAbleToDeleteSiteMemberWithConsumerRole() throws Exception + { + UserModel testUserModel = dataUser.createRandomTestUser(); + dataUser.addUserToSite(testUserModel, publicSiteModel, UserRole.SiteConsumer); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + restClient.withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(testUserModel); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY); + + restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMembers() + .assertThat().entriesListContains("id", testUserModel.getUsername()); + 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 that site contributor cannot delete site member and gets status code 403, 'Forbidden'") + public void siteContributorIsNotAbleToDeleteSiteMemberWithConsumerRole() throws Exception + { + UserModel testUserModel = dataUser.createRandomTestUser(); + dataUser.addUserToSite(testUserModel, publicSiteModel, UserRole.SiteConsumer); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + restClient.withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(testUserModel); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY); + + restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMembers() + .assertThat().entriesListContains("id", testUserModel.getUsername()); + 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 that site consumer cannot delete site member and gets status code 403, 'Forbidden'") + public void siteConsumerIsNotAbleToDeleteSiteMemberWithConsumerRole() throws Exception + { + UserModel testUserModel = dataUser.createRandomTestUser(); + dataUser.addUserToSite(testUserModel, publicSiteModel, UserRole.SiteConsumer); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingSite(publicSiteModel) + .deleteSiteMember(testUserModel); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY); + + restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMembers() + .assertThat().entriesListContains("id", testUserModel.getUsername()); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that unauthenticated user is not able to delete site member") +// @Bug(id = "MNT-16904", description = "It fails only on environment with tenants") + public void unauthenticatedUserIsNotAuthorizedToDeleteSiteMember() throws Exception + { + UserModel testUserModel = dataUser.createRandomTestUser(); + dataUser.addUserToSite(testUserModel, publicSiteModel, UserRole.SiteConsumer); + + UserModel inexistentUser = new UserModel("inexistent user", "inexistent password"); + restClient.authenticateUser(inexistentUser).withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(testUserModel); + + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that manager can NOT delete site member for an inexistent user and gets status code 404, 'Not Found'") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + public void managerIsNotAbleToDeleteInexistentSiteMember() throws Exception + { + UserModel inexistentUser = new UserModel("inexistentUser", "password"); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + restClient.withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(inexistentUser); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, inexistentUser.getUsername())); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that manager can NOT delete site member for a non site member and gets status code 400, 'Bad Request'") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + public void managerIsNotAbleToDeleteNotSiteMember() throws Exception + { + UserModel nonMember = dataUser.createRandomTestUser(); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + restClient.withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(nonMember); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_ARGUMENT, "argument")); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that manager can NOT delete site member for an invalid site and gets status code 404, 'Not Found'") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + public void managerIsNotAbleToDeleteSiteMemberOfInvalidSite() throws Exception + { + SiteModel invalidSite = new SiteModel("invalidSite"); + UserModel testUserModel = dataUser.createRandomTestUser(); + dataUser.addUserToSite(testUserModel, publicSiteModel, UserRole.SiteConsumer); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + restClient.withCoreAPI().usingSite(invalidSite).deleteSiteMember(testUserModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, testUserModel.getUsername(), invalidSite.getId())); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that manager can delete a site member with manager role") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + public void siteManagerIsAbleToDeleteSiteMemberWithManagerRole() throws Exception + { + UserModel anothermanager = dataUser.createRandomTestUser(); + dataUser.addUserToSite(anothermanager, publicSiteModel, UserRole.SiteManager); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(anothermanager); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMembers() + .assertThat().entriesListDoesNotContain("id", anothermanager.getUsername()); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that manager can delete site member using \"-me-\" in place of personId") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + public void managerIsAbleToDeleteSiteMemberUsingMe() throws Exception + { + UserModel manager = dataUser.createRandomTestUser(); + dataUser.addUserToSite(manager, publicSiteModel, UserRole.SiteManager); + UserModel meUser = new UserModel("-me-", "password"); + + restClient.authenticateUser(manager); + restClient.withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(meUser); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMembers() + .assertThat().entriesListDoesNotContain("id", manager.getUsername()); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that site collaborator cannot delete a site member with Manager role and gets status code 422") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + public void siteCollaboratorIsNotAbleToDeleteSiteMemberWithManagerRole() throws Exception + { + UserModel managerForDelete = dataUser.createRandomTestUser(); + dataUser.addUserToSite(managerForDelete, publicSiteModel, UserRole.SiteManager); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + restClient.withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(managerForDelete); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY) + .assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that site contributor cannot delete site member with Manager role and gets status code 422") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + public void siteContributorIsNotAbleToDeleteSiteMemberWithManagerRole() throws Exception + { + UserModel managerForDelete = dataUser.createRandomTestUser(); + dataUser.addUserToSite(managerForDelete, publicSiteModel, UserRole.SiteManager); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + restClient.withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(managerForDelete); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY) + .assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that site consumer cannot delete site member with Manager role and gets status code 422") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + public void siteConsumerIsNotAbleToDeleteSiteMemberWithManagerRole() throws Exception + { + UserModel managerForDelete = dataUser.createRandomTestUser(); + dataUser.addUserToSite(managerForDelete, publicSiteModel, UserRole.SiteManager); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + restClient.withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(managerForDelete); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY) + .assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that site collaborator cannot delete a site member with Contributor role and gets status code 422") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + public void siteCollaboratorIsNotAbleToDeleteSiteMemberWithContributorRole() throws Exception + { + UserModel contributorForDelete = dataUser.createRandomTestUser(); + dataUser.addUserToSite(contributorForDelete, publicSiteModel, UserRole.SiteContributor); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + restClient.withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(contributorForDelete); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY) + .assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that site contributor cannot delete site member with Contributor role and gets status code 422") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + public void siteContributorIsNotAbleToDeleteSiteMemberWithContributorRole() throws Exception + { + UserModel contributorForDelete = dataUser.createRandomTestUser(); + dataUser.addUserToSite(contributorForDelete, publicSiteModel, UserRole.SiteContributor); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + restClient.withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(contributorForDelete); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY) + .assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that site consumer cannot delete site member with Contributor role and gets status code 422") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + public void siteConsumerIsNotAbleToDeleteSiteMemberWithContributorRole() throws Exception + { + UserModel contributorForDelete = dataUser.createRandomTestUser(); + dataUser.addUserToSite(contributorForDelete, publicSiteModel, UserRole.SiteContributor); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + restClient.withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(contributorForDelete); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY) + .assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that manager can delete a site member with Contributor role") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + public void siteManagerIsAbleToDeleteSiteMemberWithContributorRole() throws Exception + { + UserModel contributorForDelete = dataUser.createRandomTestUser(); + dataUser.addUserToSite(contributorForDelete, publicSiteModel, UserRole.SiteContributor); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(contributorForDelete); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMembers() + .assertThat().entriesListDoesNotContain("id", contributorForDelete.getUsername()); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that site collaborator cannot delete a site member with Collaborator role and gets status code 422") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + public void siteCollaboratorIsNotAbleToDeleteSiteMemberWithCollaboratorRole() throws Exception + { + UserModel collaboratorForDelete = dataUser.createRandomTestUser(); + dataUser.addUserToSite(collaboratorForDelete, publicSiteModel, UserRole.SiteCollaborator); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + restClient.withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(collaboratorForDelete); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY) + .assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that site contributor cannot delete site member with Collaborator role and gets status code 422") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + public void siteContributorIsNotAbleToDeleteSiteMemberWithCollaboratorRole() throws Exception + { + UserModel collaboratorForDelete = dataUser.createRandomTestUser(); + dataUser.addUserToSite(collaboratorForDelete, publicSiteModel, UserRole.SiteCollaborator); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + restClient.withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(collaboratorForDelete); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY) + .assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that site consumer cannot delete site member with Collaborator role and gets status code 422") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + public void siteConsumerIsNotAbleToDeleteSiteMemberWithCollaboratorRole() throws Exception + { + UserModel collaboratorForDelete = dataUser.createRandomTestUser(); + dataUser.addUserToSite(collaboratorForDelete, publicSiteModel, UserRole.SiteCollaborator); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + restClient.withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(collaboratorForDelete); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY) + .assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that manager can delete a site member with Collaborator role") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + public void siteManagerIsAbleToDeleteSiteMemberWithCollaboratorRole() throws Exception + { + UserModel collaboratorForDelete = dataUser.createRandomTestUser(); + dataUser.addUserToSite(collaboratorForDelete, publicSiteModel, UserRole.SiteCollaborator); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(collaboratorForDelete); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMembers() + .assertThat().entriesListDoesNotContain("id", collaboratorForDelete.getUsername()); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin can delete a site member with Contributor role and gets status code 204") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + public void adminIsAbleToDeleteSiteMemberWithContributorRole() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel) + .deleteSiteMember(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + dataUser.addUserToSite(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor), publicSiteModel, UserRole.SiteContributor); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin can delete site member with Manager role and gets status code 204") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + public void aminIsAbleToDeleteSiteMemberWithManagerRole() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel) + .deleteSiteMember(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + dataUser.addUserToSite(usersWithRoles.getOneUserWithRole(UserRole.SiteManager), publicSiteModel, UserRole.SiteManager); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin can delete site member with Consumer role and gets status code 204") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + public void adminIsAbleToDeleteSiteMemberWithConsumerRole() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel) + .deleteSiteMember(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + dataUser.addUserToSite(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer), publicSiteModel, UserRole.SiteConsumer); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin can delete a site member with Collaborator role and gets status code 204") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + public void adminIsAbleToDeleteSiteMemberWithCollaboratorRole() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel) + .deleteSiteMember(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + dataUser.addUserToSite(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), publicSiteModel, UserRole.SiteCollaborator); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin can delete a site member of moderated site and gets status code 204") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + public void adminIsAbleToDeleteModeratedSiteMember() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + newMember.setUserRole(UserRole.SiteManager); + dataUser.addUserToSite(newMember, moderatedSiteModel, UserRole.SiteManager); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).deleteSiteMember(newMember); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin can delete a site member of private site and gets status code 204") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + public void adminIsAbleToDeletePrivateSiteMember() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + newMember.setUserRole(UserRole.SiteManager); + dataUser.addUserToSite(newMember, privateSiteModel, UserRole.SiteManager); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).deleteSiteMember(newMember); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that regular user can not delete admin and gets status code 422") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + public void regularUserIsNotAbleToDeleteASiteMember() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingSite(publicSiteModel) + .deleteSiteMember(siteCreator); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() + .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getTitle())) + .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin can not delete a site member twice and gets status code 404 for the second attempt") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @Bug(id="ACE-5447") + public void adminIsNotAbleToRemoveSiteMemberTwice() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel) + .deleteSiteMember(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel) + .deleteSiteMember(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(RestErrorModel.ENTITY_NOT_FOUND); + dataUser.addUserToSite(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor), publicSiteModel, UserRole.SiteContributor); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify admin is not able to remove from site a user that created a member request that was not accepted yet") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @Bug(id="ACE-5447") + public void adminIsNotAbleToRemoveFromSiteANonExistingMember() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(publicSiteModel); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).deleteSiteMember(newMember); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(RestErrorModel.ENTITY_NOT_FOUND); + } +} diff --git a/e2e-test/java/org/alfresco/rest/sites/members/UpdateSiteMemberCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/members/UpdateSiteMemberCoreTests.java deleted file mode 100644 index acb9cd596..000000000 --- a/e2e-test/java/org/alfresco/rest/sites/members/UpdateSiteMemberCoreTests.java +++ /dev/null @@ -1,209 +0,0 @@ -package org.alfresco.rest.sites.members; - -import org.alfresco.rest.RestTest; -import org.alfresco.rest.core.JsonBodyGenerator; -import org.alfresco.rest.core.RestRequest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestSiteMemberModel; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser; -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.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Created by Claudia Agache on 11/29/2016. - */ -public class UpdateSiteMemberCoreTests extends RestTest -{ - private UserModel adminUser, regularUser, anotherManager; - private SiteModel publicSite; - private ListUserWithRoles publicSiteUsers; - private RestSiteMemberModel updatedMember; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - publicSite = dataSite.usingUser(adminUser).createPublicRandomSite(); - publicSiteUsers = dataUser.addUsersWithRolesToSite(publicSite, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - anotherManager = dataUser.createRandomTestUser(); - dataUser.addUserToSite(anotherManager, publicSite, UserRole.SiteManager); - regularUser = dataUser.createRandomTestUser(); - regularUser.setUserRole(UserRole.SiteConsumer); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if update site member request returns status code 404 when nonexistent siteId is used") - public void updateSiteMemberOfNonexistentSite() throws Exception - { - SiteModel deletedSite = dataSite.usingUser(adminUser).createPublicRandomSite(); - dataUser.addUserToSite(regularUser, deletedSite, UserRole.SiteConsumer); - dataSite.deleteSite(deletedSite); - - restClient.authenticateUser(adminUser).withCoreAPI() - .usingSite(deletedSite).updateSiteMember(regularUser); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, deletedSite.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if update site member request returns status code 400 when personId is not member of the site") - public void updateNotASiteMember() throws Exception - { - restClient.authenticateUser(adminUser).withCoreAPI() - .usingSite(publicSite).updateSiteMember(regularUser); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary("User is not a member of the site"); - } - -// @Bug(id="REPO-1642", description = "reproduced on 5.2.1 only, it works on 5.2.0") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if update site member request returns status code 404 when personId does not exist") - public void updateNonexistentSiteMember() throws Exception - { - UserModel nonexistentUser = new UserModel("nonexistentUser", DataUser.PASSWORD); - nonexistentUser.setUserRole(UserRole.SiteContributor); - restClient.authenticateUser(adminUser).withCoreAPI() - .usingSite(publicSite).updateSiteMember(nonexistentUser); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, nonexistentUser.getUsername())); - } - - @Bug(id="REPO-1941") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if a manager is able to downgrade to contributor using -me- string in place of personId.") - public void updateSiteManagerToSiteContributorUsingMe() throws Exception - { - UserModel meManager = dataUser.createRandomTestUser(); - dataUser.addUserToSite(meManager, publicSite, UserRole.SiteManager); - UserModel meUser = new UserModel("-me-", "password"); - meUser.setUserRole(UserRole.SiteContributor); - updatedMember = restClient.authenticateUser(meManager).withCoreAPI() - .usingSite(publicSite).updateSiteMember(meUser); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedMember.assertThat().field("id").is(meManager.getUsername()) - .and().field("role").is(meUser.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if update site member request returns status code 404 when empty siteId is used") - public void updateSiteMemberUsingEmptySiteId() throws Exception - { - restClient.authenticateUser(adminUser).withCoreAPI() - .usingSite("").updateSiteMember(regularUser); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if update site member request returns status code 405 when empty personId is used") - public void updateSiteMemberUsingEmptyPersonId() throws Exception - { - UserModel emptyUser = new UserModel("", DataUser.PASSWORD); - emptyUser.setUserRole(UserRole.SiteCollaborator); - restClient.authenticateUser(adminUser).withCoreAPI() - .usingSite(publicSite).updateSiteMember(emptyUser); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) - .assertLastError().containsSummary(RestErrorModel.PUT_EMPTY_ARGUMENT); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if update site member request returns status code 400 when invalid role is used") - public void updateSiteMemberUsingInvalidRole() throws Exception - { - restClient.authenticateUser(anotherManager).withCoreAPI(); - UserModel siteConsumer = publicSiteUsers.getOneUserWithRole(UserRole.SiteConsumer); - String json = JsonBodyGenerator.keyValueJson("role","invalidRole"); - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, json, "sites/{siteId}/members/{personId}", publicSite.getId(), siteConsumer.getUsername()); - restClient.processModel(RestSiteMemberModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.UNKNOWN_ROLE, "invalidRole")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if manager is able to update another site manager to site collaborator") - public void managerUpdateSiteManagerToSiteCollaborator() throws Exception - { - UserModel siteManager = publicSiteUsers.getOneUserWithRole(UserRole.SiteManager); - siteManager.setUserRole(UserRole.SiteCollaborator); - updatedMember = restClient.authenticateUser(anotherManager).withCoreAPI() - .usingSite(publicSite).updateSiteMember(siteManager); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedMember.assertThat().field("id").is(siteManager.getUsername()) - .and().field("role").is(siteManager.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if manager is able to update site contributor to site manager") - public void managerUpdateSiteContributorToSiteManager() throws Exception - { - UserModel siteContributor = publicSiteUsers.getOneUserWithRole(UserRole.SiteContributor); - siteContributor.setUserRole(UserRole.SiteManager); - updatedMember = restClient.authenticateUser(anotherManager).withCoreAPI() - .usingSite(publicSite).updateSiteMember(siteContributor); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedMember.assertThat().field("id").is(siteContributor.getUsername()) - .and().field("role").is(siteContributor.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if manager is able to update site collaborator to site manager") - public void managerUpdateSiteCollaboratorToSiteManager() throws Exception - { - UserModel siteCollaborator = publicSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator); - siteCollaborator.setUserRole(UserRole.SiteManager); - updatedMember = restClient.authenticateUser(anotherManager).withCoreAPI() - .usingSite(publicSite).updateSiteMember(siteCollaborator); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedMember.assertThat().field("id").is(siteCollaborator.getUsername()) - .and().field("role").is(siteCollaborator.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if manager is able to update site consumer to site manager") - public void managerUpdateSiteConsumerToSiteManager() throws Exception - { - UserModel siteConsumer = publicSiteUsers.getOneUserWithRole(UserRole.SiteConsumer); - siteConsumer.setUserRole(UserRole.SiteManager); - updatedMember = restClient.authenticateUser(anotherManager).withCoreAPI() - .usingSite(publicSite).updateSiteMember(siteConsumer); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedMember.assertThat().field("id").is(siteConsumer.getUsername()) - .and().field("role").is(siteConsumer.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if manager is able to downgrade himself to site consumer") - public void managerDowngradeHimselfToSiteConsumer() throws Exception - { - UserModel siteManager = publicSiteUsers.getOneUserWithRole(UserRole.SiteManager); - siteManager.setUserRole(UserRole.SiteConsumer); - updatedMember = restClient.authenticateUser(siteManager).withCoreAPI() - .usingSite(publicSite).updateSiteMember(siteManager); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedMember.assertThat().field("id").is(siteManager.getUsername()) - .and().field("role").is(siteManager.getUserRole()); - } -} diff --git a/e2e-test/java/org/alfresco/rest/sites/members/UpdateSiteMemberFullTests.java b/e2e-test/java/org/alfresco/rest/sites/members/UpdateSiteMemberFullTests.java deleted file mode 100644 index 970566fca..000000000 --- a/e2e-test/java/org/alfresco/rest/sites/members/UpdateSiteMemberFullTests.java +++ /dev/null @@ -1,279 +0,0 @@ -package org.alfresco.rest.sites.members; - -import org.alfresco.rest.RestTest; -import org.alfresco.rest.core.RestRequest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestSiteMemberModel; -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 UpdateSiteMemberFullTests extends RestTest -{ - private UserModel adminUser, anotherManager; - private SiteModel publicSite, moderatedSite, privateSite; - private RestSiteMemberModel updatedMember; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - publicSite = dataSite.usingUser(adminUser).createPublicRandomSite(); - moderatedSite = dataSite.usingUser(adminUser).createModeratedRandomSite(); - privateSite = dataSite.usingUser(adminUser).createPrivateRandomSite(); - anotherManager = dataUser.createRandomTestUser(); - dataUser.addUserToSite(anotherManager, publicSite, UserRole.SiteManager); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if manager is able to update another site manager to site contributor") - public void managerUpdateSiteManagerToSiteContributor() throws Exception - { - UserModel siteManager = dataUser.createRandomTestUser(); - dataUser.addUserToSite(siteManager, publicSite, UserRole.SiteManager); - - siteManager.setUserRole(UserRole.SiteContributor); - updatedMember = restClient.authenticateUser(anotherManager).withCoreAPI() - .usingSite(publicSite).updateSiteMember(siteManager); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedMember.assertThat().field("id").is(siteManager.getUsername()).and().field("role").is(siteManager.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if manager is able to update another site manager to site consumer") - public void managerUpdateSiteManagerToSiteConsumer() throws Exception - { - UserModel siteManager = dataUser.createRandomTestUser(); - dataUser.addUserToSite(siteManager, publicSite, UserRole.SiteManager); - - siteManager.setUserRole(UserRole.SiteConsumer); - updatedMember = restClient.authenticateUser(anotherManager).withCoreAPI() - .usingSite(publicSite).updateSiteMember(siteManager); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedMember.assertThat().field("id").is(siteManager.getUsername()).and().field("role").is(siteManager.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if manager is able to update site contributor to site collaborator") - public void managerUpdateSiteContributorToSiteCollaborator() throws Exception - { - UserModel siteContributor = dataUser.createRandomTestUser(); - dataUser.addUserToSite(siteContributor, publicSite, UserRole.SiteContributor); - - siteContributor.setUserRole(UserRole.SiteCollaborator); - updatedMember = restClient.authenticateUser(anotherManager).withCoreAPI() - .usingSite(publicSite).updateSiteMember(siteContributor); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedMember.assertThat().field("id").is(siteContributor.getUsername()).and().field("role").is(siteContributor.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if manager is able to update site contributor to site consumer") - public void managerUpdateSiteContributorToSiteConsumer() throws Exception - { - UserModel siteContributor = dataUser.createRandomTestUser(); - dataUser.addUserToSite(siteContributor, publicSite, UserRole.SiteContributor); - - siteContributor.setUserRole(UserRole.SiteConsumer); - updatedMember = restClient.authenticateUser(anotherManager).withCoreAPI() - .usingSite(publicSite).updateSiteMember(siteContributor); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedMember.assertThat().field("id").is(siteContributor.getUsername()).and().field("role").is(siteContributor.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if manager is able to update site collaborator to site contributor") - public void managerUpdateSiteCollaboratorToSiteContributor() throws Exception - { - UserModel siteCollaborator = dataUser.createRandomTestUser(); - dataUser.addUserToSite(siteCollaborator, publicSite, UserRole.SiteCollaborator); - - siteCollaborator.setUserRole(UserRole.SiteContributor); - updatedMember = restClient.authenticateUser(anotherManager).withCoreAPI() - .usingSite(publicSite).updateSiteMember(siteCollaborator); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedMember.assertThat().field("id").is(siteCollaborator.getUsername()).and().field("role").is(siteCollaborator.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if manager is able to update site collaborator to site consumer") - public void managerUpdateSiteCollaboratorToSiteConsumer() throws Exception - { - UserModel siteCollaborator = dataUser.createRandomTestUser(); - dataUser.addUserToSite(siteCollaborator, publicSite, UserRole.SiteCollaborator); - - siteCollaborator.setUserRole(UserRole.SiteConsumer); - updatedMember = restClient.authenticateUser(anotherManager).withCoreAPI() - .usingSite(publicSite).updateSiteMember(siteCollaborator); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedMember.assertThat().field("id").is(siteCollaborator.getUsername()).and().field("role").is(siteCollaborator.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if manager is able to update site consumer to site collaborator") - public void managerUpdateSiteConsumerToSiteCollaborator() throws Exception - { - UserModel siteConsumer = dataUser.createRandomTestUser(); - dataUser.addUserToSite(siteConsumer, publicSite, UserRole.SiteConsumer); - - siteConsumer.setUserRole(UserRole.SiteCollaborator); - updatedMember = restClient.authenticateUser(anotherManager).withCoreAPI() - .usingSite(publicSite).updateSiteMember(siteConsumer); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedMember.assertThat().field("id").is(siteConsumer.getUsername()).and().field("role").is(siteConsumer.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if manager is able to update site consumer to site contributor") - public void managerUpdateSiteConsumerToSiteContributor() throws Exception - { - UserModel siteConsumer = dataUser.createRandomTestUser(); - dataUser.addUserToSite(siteConsumer, publicSite, UserRole.SiteConsumer); - - siteConsumer.setUserRole(UserRole.SiteContributor); - updatedMember = restClient.authenticateUser(anotherManager).withCoreAPI() - .usingSite(publicSite).updateSiteMember(siteConsumer); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedMember.assertThat().field("id").is(siteConsumer.getUsername()).and().field("role").is(siteConsumer.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if manager is able to update another site manager to site manager") - public void managerUpdateSiteManagerToSiteManager() throws Exception - { - UserModel siteManager = dataUser.createRandomTestUser(); - dataUser.addUserToSite(siteManager, publicSite, UserRole.SiteManager); - - siteManager.setUserRole(UserRole.SiteManager); - updatedMember = restClient.authenticateUser(anotherManager).withCoreAPI() - .usingSite(publicSite).updateSiteMember(siteManager); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedMember.assertThat().field("id").is(siteManager.getUsername()).and().field("role").is(siteManager.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if manager is able to update site collaborator to site collaborator") - public void managerUpdateSiteCollaboratorToSiteCollaborator() throws Exception - { - UserModel siteCollaborator = dataUser.createRandomTestUser(); - dataUser.addUserToSite(siteCollaborator, publicSite, UserRole.SiteCollaborator); - - siteCollaborator.setUserRole(UserRole.SiteCollaborator); - updatedMember = restClient.authenticateUser(anotherManager).withCoreAPI() - .usingSite(publicSite).updateSiteMember(siteCollaborator); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedMember.assertThat().field("id").is(siteCollaborator.getUsername()).and().field("role").is(siteCollaborator.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if manager is able to update site contributor to site contributor") - public void managerUpdateSiteContributorToSiteContributor() throws Exception - { - UserModel siteContributor = dataUser.createRandomTestUser(); - dataUser.addUserToSite(siteContributor, publicSite, UserRole.SiteContributor); - - siteContributor.setUserRole(UserRole.SiteContributor); - updatedMember = restClient.authenticateUser(anotherManager).withCoreAPI() - .usingSite(publicSite).updateSiteMember(siteContributor); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedMember.assertThat().field("id").is(siteContributor.getUsername()).and().field("role").is(siteContributor.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if manager is able to update site consumer to site consumer") - public void managerUpdateSiteConsumerToSiteConsumer() throws Exception - { - UserModel siteConsumer = dataUser.createRandomTestUser(); - dataUser.addUserToSite(siteConsumer, publicSite, UserRole.SiteConsumer); - - siteConsumer.setUserRole(UserRole.SiteConsumer); - updatedMember = restClient.authenticateUser(anotherManager).withCoreAPI() - .usingSite(publicSite).updateSiteMember(siteConsumer); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedMember.assertThat().field("id").is(siteConsumer.getUsername()).and().field("role").is(siteConsumer.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if manager of a private site is able to downgrade his role") - public void privateSiteManagerDowngradesRole() throws Exception - { - UserModel siteManager = dataUser.createRandomTestUser(); - dataUser.addUserToSite(siteManager, privateSite, UserRole.SiteManager); - - siteManager.setUserRole(UserRole.SiteConsumer); - updatedMember = restClient.authenticateUser(siteManager).withCoreAPI() - .usingSite(privateSite).updateSiteMember(siteManager); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedMember.assertThat().field("id").is(siteManager.getUsername()).and().field("role").is(siteManager.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if manager of a moderated site is able to downgrade his role") - public void moderatedSiteManagerDowngradesRole() throws Exception - { - UserModel siteManager = dataUser.createRandomTestUser(); - dataUser.addUserToSite(siteManager, moderatedSite, UserRole.SiteManager); - - siteManager.setUserRole(UserRole.SiteConsumer); - updatedMember = restClient.authenticateUser(siteManager).withCoreAPI() - .usingSite(moderatedSite).updateSiteMember(siteManager); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedMember.assertThat().field("id").is(siteManager.getUsername()).and().field("role").is(siteManager.getUserRole()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify the response of updating a site member with empty body at request") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) - public void verifyManagerCanNotUpdateSiteMemberWithEmptyBody() throws Exception - { - restClient.authenticateUser(anotherManager).withCoreAPI(); - UserModel siteCollaborator = dataUser.createRandomTestUser(); - dataUser.addUserToSite(siteCollaborator, publicSite, UserRole.SiteCollaborator); - siteCollaborator.setUserRole(UserRole.SiteConsumer); - - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "", "sites/{siteId}/members/{personId}", publicSite.getId(), siteCollaborator.getUsername()); - restClient.processModel(RestSiteMemberModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.NO_CONTENT, "No content to map to Object due to end of input")) - .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "No content to map to Object due to end of input")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if manager is able to update a user that has created a site membership request, but it's not a member of the site yet") - public void verifyManagerCanNotUpdateUserWithSiteMembershipRequest() throws Exception - { - UserModel siteConsumer = dataUser.createRandomTestUser(); - siteConsumer.setUserRole(UserRole.SiteConsumer); - restClient.authenticateUser(siteConsumer).withCoreAPI().usingUser(siteConsumer).addSiteMembershipRequest(moderatedSite); - - updatedMember = restClient.authenticateUser(anotherManager).withCoreAPI() - .usingSite(moderatedSite).updateSiteMember(siteConsumer); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(RestErrorModel.NOT_A_MEMBER); - } - -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/sites/members/UpdateSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/members/UpdateSiteMemberSanityTests.java deleted file mode 100644 index db14a344e..000000000 --- a/e2e-test/java/org/alfresco/rest/sites/members/UpdateSiteMemberSanityTests.java +++ /dev/null @@ -1,138 +0,0 @@ -package org.alfresco.rest.sites.members; - -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -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.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class UpdateSiteMemberSanityTests extends RestTest -{ - private UserModel adminUserModel; - private SiteModel siteModel; - private ListUserWithRoles usersWithRoles; - private UserModel testUserModel; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - testUserModel = dataUser.createRandomTestUser(); - dataUser.addUserToSite(testUserModel, siteModel, UserRole.SiteConsumer); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, - description = "Verify that manager is able to update site member and gets status code OK (200)") - public void managerIsAbleToUpdateSiteMember() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - testUserModel.setUserRole(UserRole.SiteConsumer); - restClient.withCoreAPI().usingSite(siteModel).updateSiteMember(testUserModel) - .assertThat().field("id").is(testUserModel.getUsername()) - .and().field("role").is(testUserModel.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 = "Verify that collaborator is not able to update site member and gets status code FORBIDDEN (403)") - public void collaboratorIsNotAbleToUpdateSiteMember() throws Exception - { - UserModel testUserModel = dataUser.createRandomTestUser(); - dataUser.addUserToSite(testUserModel, siteModel, UserRole.SiteConsumer); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - testUserModel.setUserRole(UserRole.SiteCollaborator); - restClient.withCoreAPI().usingSite(siteModel).updateSiteMember(testUserModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY); - restClient.assertLastError() - .containsSummary(String.format("The current user does not have permissions to modify the membership details of the site %s.", siteModel.getTitle())); - } - - @Bug(id = "REPO-1832") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, - description = "Verify that collaborator is not able to update site member and gets status code FORBIDDEN (403)") - public void collaboratorIsNotAbleToUpdateSiteMemberWithTheSameRole() throws Exception - { - UserModel testUserModel = dataUser.createRandomTestUser(); - dataUser.addUserToSite(testUserModel, siteModel, UserRole.SiteConsumer); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - testUserModel.setUserRole(UserRole.SiteConsumer); - restClient.withCoreAPI().usingSite(siteModel).updateSiteMember(testUserModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY); - restClient.assertLastError() - .containsSummary(String.format("The current user does not have permissions to modify the membership details of the site %s.", siteModel.getTitle())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, - description = "Verify that contributor is not able to update site member and gets status code FORBIDDEN (403)") - public void contributorIsNotAbleToUpdateSiteMember() throws Exception - { - UserModel testUserModel = dataUser.createRandomTestUser(); - dataUser.addUserToSite(testUserModel, siteModel, UserRole.SiteConsumer); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - testUserModel.setUserRole(UserRole.SiteCollaborator); - restClient.withCoreAPI().usingSite(siteModel).updateSiteMember(testUserModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY); - restClient.assertLastError() - .containsSummary(String.format("The current user does not have permissions to modify the membership details of the site %s.", siteModel.getTitle())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, - description = "Verify that consumer is not able to update site member and gets status code FORBIDDEN (403)") - public void consumerIsNotAbleToUpdateSiteMember() throws Exception - { - UserModel testUserModel = dataUser.createRandomTestUser(); - dataUser.addUserToSite(testUserModel, siteModel, UserRole.SiteConsumer); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - testUserModel.setUserRole(UserRole.SiteCollaborator); - restClient.withCoreAPI().usingSite(siteModel).updateSiteMember(testUserModel); - restClient.assertLastError() - .containsSummary(String.format("The current user does not have permissions to modify the membership details of the site %s.", siteModel.getTitle())); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, - description = "Verify that admin is able to update site member and gets status code OK (200)") - public void adminIsAbleToUpdateSiteMember() throws Exception - { - restClient.authenticateUser(adminUserModel); - testUserModel.setUserRole(UserRole.SiteCollaborator); - restClient.withCoreAPI().usingSite(siteModel).updateSiteMember(testUserModel) - .assertThat().field("id").is(testUserModel.getUsername()) - .and().field("role").is(testUserModel.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 = "Verify that unauthenticated user is not able to update site member") - @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void unauthenticatedUserIsNotAuthorizedToUpdateSiteMmeber() throws Exception{ - UserModel inexistentUser = new UserModel("inexistent user", "inexistent password"); - restClient.authenticateUser(inexistentUser); - testUserModel.setUserRole(UserRole.SiteCollaborator); - restClient.withCoreAPI().usingSite(siteModel).updateSiteMember(testUserModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } -} diff --git a/e2e-test/java/org/alfresco/rest/sites/members/UpdateSiteMemberTests.java b/e2e-test/java/org/alfresco/rest/sites/members/UpdateSiteMemberTests.java new file mode 100644 index 000000000..4325a7746 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/sites/members/UpdateSiteMemberTests.java @@ -0,0 +1,546 @@ +package org.alfresco.rest.sites.members; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.JsonBodyGenerator; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestSiteMemberModel; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser; +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.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class UpdateSiteMemberTests extends RestTest +{ + private UserModel adminUser, siteCreator, regularUser; + private SiteModel publicSite, moderatedSite, privateSite; + private ListUserWithRoles publicSiteUsers; + private UserModel userToBeUpdated; + private RestSiteMemberModel updatedMember; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + siteCreator = dataUser.createRandomTestUser(); + publicSite = dataSite.usingUser(siteCreator).createPublicRandomSite(); + moderatedSite = dataSite.usingUser(siteCreator).createModeratedRandomSite(); + privateSite = dataSite.usingUser(siteCreator).createPrivateRandomSite(); + publicSiteUsers = dataUser.addUsersWithRolesToSite(publicSite, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + + regularUser = dataUser.createRandomTestUser(); + regularUser.setUserRole(UserRole.SiteConsumer); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that collaborator is not able to update site member and gets status code FORBIDDEN (403)") + public void collaboratorIsNotAbleToUpdateSiteMember() throws Exception + { + userToBeUpdated = dataUser.createRandomTestUser(); + dataUser.addUserToSite(userToBeUpdated, publicSite, UserRole.SiteConsumer); + userToBeUpdated.setUserRole(UserRole.SiteCollaborator); + restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)); + restClient.withCoreAPI().usingSite(publicSite).updateSiteMember(userToBeUpdated); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY); + restClient.assertLastError() + .containsSummary(String.format("The current user does not have permissions to modify the membership details of the site %s.", publicSite.getTitle())); + } + + @Bug(id = "REPO-1832") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that collaborator is not able to update site member and gets status code FORBIDDEN (403)") + public void collaboratorIsNotAbleToUpdateSiteMemberWithTheSameRole() throws Exception + { + userToBeUpdated = dataUser.createRandomTestUser(); + dataUser.addUserToSite(userToBeUpdated, publicSite, UserRole.SiteConsumer); + userToBeUpdated.setUserRole(UserRole.SiteConsumer); + restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)); + restClient.withCoreAPI().usingSite(publicSite).updateSiteMember(userToBeUpdated); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY); + restClient.assertLastError() + .containsSummary(String.format("The current user does not have permissions to modify the membership details of the site %s.", publicSite.getTitle())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that contributor is not able to update site member and gets status code FORBIDDEN (403)") + public void contributorIsNotAbleToUpdateSiteMember() throws Exception + { + userToBeUpdated = dataUser.createRandomTestUser(); + dataUser.addUserToSite(userToBeUpdated, publicSite, UserRole.SiteConsumer); + userToBeUpdated.setUserRole(UserRole.SiteCollaborator); + restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteContributor)); + restClient.withCoreAPI().usingSite(publicSite).updateSiteMember(userToBeUpdated); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY); + restClient.assertLastError() + .containsSummary(String.format("The current user does not have permissions to modify the membership details of the site %s.", publicSite.getTitle())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that consumer is not able to update site member and gets status code FORBIDDEN (403)") + public void consumerIsNotAbleToUpdateSiteMember() throws Exception + { + userToBeUpdated = dataUser.createRandomTestUser(); + dataUser.addUserToSite(userToBeUpdated, publicSite, UserRole.SiteConsumer); + userToBeUpdated.setUserRole(UserRole.SiteCollaborator); + restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteConsumer)); + restClient.withCoreAPI().usingSite(publicSite).updateSiteMember(userToBeUpdated); + restClient.assertLastError() + .containsSummary(String.format("The current user does not have permissions to modify the membership details of the site %s.", publicSite.getTitle())); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin is able to update site member and gets status code OK (200)") + public void adminIsAbleToUpdateSiteMember() throws Exception + { + userToBeUpdated = dataUser.createRandomTestUser(); + dataUser.addUserToSite(userToBeUpdated, publicSite, UserRole.SiteConsumer); + userToBeUpdated.setUserRole(UserRole.SiteCollaborator); + restClient.authenticateUser(adminUser); + restClient.withCoreAPI().usingSite(publicSite).updateSiteMember(userToBeUpdated) + .assertThat().field("id").is(userToBeUpdated.getUsername()) + .and().field("role").is(userToBeUpdated.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 = "Verify that unauthenticated user is not able to update site member") +// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") + public void unauthenticatedUserIsNotAuthorizedToUpdateSiteMmeber() throws Exception + { + userToBeUpdated = dataUser.createRandomTestUser(); + dataUser.addUserToSite(userToBeUpdated, publicSite, UserRole.SiteConsumer); + userToBeUpdated.setUserRole(UserRole.SiteCollaborator); + UserModel inexistentUser = new UserModel("inexistent user", "inexistent password"); + restClient.authenticateUser(inexistentUser); + restClient.withCoreAPI().usingSite(publicSite).updateSiteMember(userToBeUpdated); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if update site member request returns status code 404 when nonexistent siteId is used") + public void updateSiteMemberOfNonexistentSite() throws Exception + { + SiteModel deletedSite = dataSite.usingUser(adminUser).createPublicRandomSite(); + dataUser.addUserToSite(regularUser, deletedSite, UserRole.SiteConsumer); + dataSite.deleteSite(deletedSite); + + restClient.authenticateUser(adminUser).withCoreAPI() + .usingSite(deletedSite).updateSiteMember(regularUser); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, deletedSite.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if update site member request returns status code 400 when personId is not member of the site") + public void updateNotASiteMember() throws Exception + { + restClient.authenticateUser(adminUser).withCoreAPI() + .usingSite(publicSite).updateSiteMember(regularUser); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary("User is not a member of the site"); + } + + // @Bug(id="REPO-1642", description = "reproduced on 5.2.1 only, it works on 5.2.0") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if update site member request returns status code 404 when personId does not exist") + public void updateNonexistentSiteMember() throws Exception + { + UserModel nonexistentUser = new UserModel("nonexistentUser", DataUser.PASSWORD); + nonexistentUser.setUserRole(UserRole.SiteContributor); + restClient.authenticateUser(adminUser).withCoreAPI() + .usingSite(publicSite).updateSiteMember(nonexistentUser); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, nonexistentUser.getUsername())); + } + + @Bug(id="REPO-1941") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if a manager is able to downgrade to contributor using -me- string in place of personId.") + public void updateSiteManagerToSiteContributorUsingMe() throws Exception + { + UserModel meManager = dataUser.createRandomTestUser(); + dataUser.addUserToSite(meManager, publicSite, UserRole.SiteManager); + UserModel meUser = new UserModel("-me-", "password"); + meUser.setUserRole(UserRole.SiteContributor); + updatedMember = restClient.authenticateUser(meManager).withCoreAPI() + .usingSite(publicSite).updateSiteMember(meUser); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedMember.assertThat().field("id").is(meManager.getUsername()) + .and().field("role").is(meUser.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if update site member request returns status code 404 when empty siteId is used") + public void updateSiteMemberUsingEmptySiteId() throws Exception + { + restClient.authenticateUser(adminUser).withCoreAPI() + .usingSite("").updateSiteMember(regularUser); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if update site member request returns status code 405 when empty personId is used") + public void updateSiteMemberUsingEmptyPersonId() throws Exception + { + UserModel emptyUser = new UserModel("", DataUser.PASSWORD); + emptyUser.setUserRole(UserRole.SiteCollaborator); + restClient.authenticateUser(adminUser).withCoreAPI() + .usingSite(publicSite).updateSiteMember(emptyUser); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) + .assertLastError().containsSummary(RestErrorModel.PUT_EMPTY_ARGUMENT); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if update site member request returns status code 400 when invalid role is used") + public void updateSiteMemberUsingInvalidRole() throws Exception + { + restClient.authenticateUser(siteCreator).withCoreAPI(); + UserModel siteConsumer = publicSiteUsers.getOneUserWithRole(UserRole.SiteConsumer); + String json = JsonBodyGenerator.keyValueJson("role","invalidRole"); + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, json, "sites/{siteId}/members/{personId}", publicSite.getId(), siteConsumer.getUsername()); + restClient.processModel(RestSiteMemberModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.UNKNOWN_ROLE, "invalidRole")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if manager is able to update another site manager to site collaborator") + public void managerUpdateSiteManagerToSiteCollaborator() throws Exception + { + UserModel siteManager = dataUser.createRandomTestUser(); + dataUser.addUserToSite(siteManager, publicSite, UserRole.SiteManager); + siteManager.setUserRole(UserRole.SiteCollaborator); + updatedMember = restClient.authenticateUser(siteCreator).withCoreAPI() + .usingSite(publicSite).updateSiteMember(siteManager); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedMember.assertThat().field("id").is(siteManager.getUsername()) + .and().field("role").is(siteManager.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if manager is able to update site contributor to site manager") + public void managerUpdateSiteContributorToSiteManager() throws Exception + { + UserModel siteContributor = publicSiteUsers.getOneUserWithRole(UserRole.SiteContributor); + siteContributor.setUserRole(UserRole.SiteManager); + updatedMember = restClient.authenticateUser(siteCreator).withCoreAPI() + .usingSite(publicSite).updateSiteMember(siteContributor); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedMember.assertThat().field("id").is(siteContributor.getUsername()) + .and().field("role").is(siteContributor.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if manager is able to update site collaborator to site manager") + public void managerUpdateSiteCollaboratorToSiteManager() throws Exception + { + UserModel siteCollaborator = publicSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator); + siteCollaborator.setUserRole(UserRole.SiteManager); + updatedMember = restClient.authenticateUser(siteCreator).withCoreAPI() + .usingSite(publicSite).updateSiteMember(siteCollaborator); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedMember.assertThat().field("id").is(siteCollaborator.getUsername()) + .and().field("role").is(siteCollaborator.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.SANITY, + description= "Verify if manager is able to update site consumer to site manager") + public void managerUpdateSiteConsumerToSiteManager() throws Exception + { + UserModel siteConsumer = publicSiteUsers.getOneUserWithRole(UserRole.SiteConsumer); + siteConsumer.setUserRole(UserRole.SiteManager); + updatedMember = restClient.authenticateUser(siteCreator).withCoreAPI() + .usingSite(publicSite).updateSiteMember(siteConsumer); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedMember.assertThat().field("id").is(siteConsumer.getUsername()) + .and().field("role").is(siteConsumer.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if manager is able to downgrade himself to site consumer") + public void publicSiteManagerDowngradesRole() throws Exception + { + UserModel siteManager = publicSiteUsers.getOneUserWithRole(UserRole.SiteManager); + siteManager.setUserRole(UserRole.SiteConsumer); + updatedMember = restClient.authenticateUser(siteManager).withCoreAPI() + .usingSite(publicSite).updateSiteMember(siteManager); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedMember.assertThat().field("id").is(siteManager.getUsername()) + .and().field("role").is(siteManager.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if manager is able to update another site manager to site contributor") + public void managerUpdateSiteManagerToSiteContributor() throws Exception + { + UserModel siteManager = dataUser.createRandomTestUser(); + dataUser.addUserToSite(siteManager, publicSite, UserRole.SiteManager); + + siteManager.setUserRole(UserRole.SiteContributor); + updatedMember = restClient.authenticateUser(siteCreator).withCoreAPI() + .usingSite(publicSite).updateSiteMember(siteManager); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedMember.assertThat().field("id").is(siteManager.getUsername()).and().field("role").is(siteManager.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if manager is able to update another site manager to site consumer") + public void managerUpdateSiteManagerToSiteConsumer() throws Exception + { + UserModel siteManager = dataUser.createRandomTestUser(); + dataUser.addUserToSite(siteManager, publicSite, UserRole.SiteManager); + + siteManager.setUserRole(UserRole.SiteConsumer); + updatedMember = restClient.authenticateUser(siteCreator).withCoreAPI() + .usingSite(publicSite).updateSiteMember(siteManager); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedMember.assertThat().field("id").is(siteManager.getUsername()).and().field("role").is(siteManager.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if manager is able to update site contributor to site collaborator") + public void managerUpdateSiteContributorToSiteCollaborator() throws Exception + { + UserModel siteContributor = dataUser.createRandomTestUser(); + dataUser.addUserToSite(siteContributor, publicSite, UserRole.SiteContributor); + + siteContributor.setUserRole(UserRole.SiteCollaborator); + updatedMember = restClient.authenticateUser(siteCreator).withCoreAPI() + .usingSite(publicSite).updateSiteMember(siteContributor); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedMember.assertThat().field("id").is(siteContributor.getUsername()).and().field("role").is(siteContributor.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if manager is able to update site contributor to site consumer") + public void managerUpdateSiteContributorToSiteConsumer() throws Exception + { + UserModel siteContributor = dataUser.createRandomTestUser(); + dataUser.addUserToSite(siteContributor, publicSite, UserRole.SiteContributor); + + siteContributor.setUserRole(UserRole.SiteConsumer); + updatedMember = restClient.authenticateUser(siteCreator).withCoreAPI() + .usingSite(publicSite).updateSiteMember(siteContributor); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedMember.assertThat().field("id").is(siteContributor.getUsername()).and().field("role").is(siteContributor.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if manager is able to update site collaborator to site contributor") + public void managerUpdateSiteCollaboratorToSiteContributor() throws Exception + { + UserModel siteCollaborator = dataUser.createRandomTestUser(); + dataUser.addUserToSite(siteCollaborator, publicSite, UserRole.SiteCollaborator); + + siteCollaborator.setUserRole(UserRole.SiteContributor); + updatedMember = restClient.authenticateUser(siteCreator).withCoreAPI() + .usingSite(publicSite).updateSiteMember(siteCollaborator); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedMember.assertThat().field("id").is(siteCollaborator.getUsername()).and().field("role").is(siteCollaborator.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if manager is able to update site collaborator to site consumer") + public void managerUpdateSiteCollaboratorToSiteConsumer() throws Exception + { + UserModel siteCollaborator = dataUser.createRandomTestUser(); + dataUser.addUserToSite(siteCollaborator, publicSite, UserRole.SiteCollaborator); + + siteCollaborator.setUserRole(UserRole.SiteConsumer); + updatedMember = restClient.authenticateUser(siteCreator).withCoreAPI() + .usingSite(publicSite).updateSiteMember(siteCollaborator); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedMember.assertThat().field("id").is(siteCollaborator.getUsername()).and().field("role").is(siteCollaborator.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if manager is able to update site consumer to site collaborator") + public void managerUpdateSiteConsumerToSiteCollaborator() throws Exception + { + UserModel siteConsumer = dataUser.createRandomTestUser(); + dataUser.addUserToSite(siteConsumer, publicSite, UserRole.SiteConsumer); + + siteConsumer.setUserRole(UserRole.SiteCollaborator); + updatedMember = restClient.authenticateUser(siteCreator).withCoreAPI() + .usingSite(publicSite).updateSiteMember(siteConsumer); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedMember.assertThat().field("id").is(siteConsumer.getUsername()).and().field("role").is(siteConsumer.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if manager is able to update site consumer to site contributor") + public void managerUpdateSiteConsumerToSiteContributor() throws Exception + { + UserModel siteConsumer = dataUser.createRandomTestUser(); + dataUser.addUserToSite(siteConsumer, publicSite, UserRole.SiteConsumer); + + siteConsumer.setUserRole(UserRole.SiteContributor); + updatedMember = restClient.authenticateUser(siteCreator).withCoreAPI() + .usingSite(publicSite).updateSiteMember(siteConsumer); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedMember.assertThat().field("id").is(siteConsumer.getUsername()).and().field("role").is(siteConsumer.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if manager is able to update another site manager to site manager") + public void managerUpdateSiteManagerToSiteManager() throws Exception + { + UserModel siteManager = dataUser.createRandomTestUser(); + dataUser.addUserToSite(siteManager, publicSite, UserRole.SiteManager); + + siteManager.setUserRole(UserRole.SiteManager); + updatedMember = restClient.authenticateUser(siteCreator).withCoreAPI() + .usingSite(publicSite).updateSiteMember(siteManager); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedMember.assertThat().field("id").is(siteManager.getUsername()).and().field("role").is(siteManager.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if manager is able to update site collaborator to site collaborator") + public void managerUpdateSiteCollaboratorToSiteCollaborator() throws Exception + { + UserModel siteCollaborator = dataUser.createRandomTestUser(); + dataUser.addUserToSite(siteCollaborator, publicSite, UserRole.SiteCollaborator); + + siteCollaborator.setUserRole(UserRole.SiteCollaborator); + updatedMember = restClient.authenticateUser(siteCreator).withCoreAPI() + .usingSite(publicSite).updateSiteMember(siteCollaborator); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedMember.assertThat().field("id").is(siteCollaborator.getUsername()).and().field("role").is(siteCollaborator.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if manager is able to update site contributor to site contributor") + public void managerUpdateSiteContributorToSiteContributor() throws Exception + { + UserModel siteContributor = dataUser.createRandomTestUser(); + dataUser.addUserToSite(siteContributor, publicSite, UserRole.SiteContributor); + + siteContributor.setUserRole(UserRole.SiteContributor); + updatedMember = restClient.authenticateUser(siteCreator).withCoreAPI() + .usingSite(publicSite).updateSiteMember(siteContributor); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedMember.assertThat().field("id").is(siteContributor.getUsername()).and().field("role").is(siteContributor.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if manager is able to update site consumer to site consumer") + public void managerUpdateSiteConsumerToSiteConsumer() throws Exception + { + UserModel siteConsumer = dataUser.createRandomTestUser(); + dataUser.addUserToSite(siteConsumer, publicSite, UserRole.SiteConsumer); + + siteConsumer.setUserRole(UserRole.SiteConsumer); + updatedMember = restClient.authenticateUser(siteCreator).withCoreAPI() + .usingSite(publicSite).updateSiteMember(siteConsumer); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedMember.assertThat().field("id").is(siteConsumer.getUsername()).and().field("role").is(siteConsumer.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if manager of a private site is able to downgrade his role") + public void privateSiteManagerDowngradesRole() throws Exception + { + UserModel siteManager = dataUser.createRandomTestUser(); + dataUser.addUserToSite(siteManager, privateSite, UserRole.SiteManager); + + siteManager.setUserRole(UserRole.SiteConsumer); + updatedMember = restClient.authenticateUser(siteManager).withCoreAPI() + .usingSite(privateSite).updateSiteMember(siteManager); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedMember.assertThat().field("id").is(siteManager.getUsername()).and().field("role").is(siteManager.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if manager of a moderated site is able to downgrade his role") + public void moderatedSiteManagerDowngradesRole() throws Exception + { + UserModel siteManager = dataUser.createRandomTestUser(); + dataUser.addUserToSite(siteManager, moderatedSite, UserRole.SiteManager); + + siteManager.setUserRole(UserRole.SiteConsumer); + updatedMember = restClient.authenticateUser(siteManager).withCoreAPI() + .usingSite(moderatedSite).updateSiteMember(siteManager); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedMember.assertThat().field("id").is(siteManager.getUsername()).and().field("role").is(siteManager.getUserRole()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify the response of updating a site member with empty body at request") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) + public void managerCanNotUpdateSiteMemberWithEmptyBody() throws Exception + { + restClient.authenticateUser(siteCreator).withCoreAPI(); + UserModel siteCollaborator = dataUser.createRandomTestUser(); + dataUser.addUserToSite(siteCollaborator, publicSite, UserRole.SiteCollaborator); + siteCollaborator.setUserRole(UserRole.SiteConsumer); + + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "", "sites/{siteId}/members/{personId}", publicSite.getId(), siteCollaborator.getUsername()); + restClient.processModel(RestSiteMemberModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.NO_CONTENT, "No content to map to Object due to end of input")) + .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "No content to map to Object due to end of input")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if manager is able to update a user that has created a site membership request, but it's not a member of the site yet") + public void managerCanNotUpdateUserWithSiteMembershipRequest() throws Exception + { + UserModel siteConsumer = dataUser.createRandomTestUser(); + siteConsumer.setUserRole(UserRole.SiteConsumer); + restClient.authenticateUser(siteConsumer).withCoreAPI().usingUser(siteConsumer).addSiteMembershipRequest(moderatedSite); + + updatedMember = restClient.authenticateUser(siteCreator).withCoreAPI() + .usingSite(moderatedSite).updateSiteMember(siteConsumer); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(RestErrorModel.NOT_A_MEMBER); + } +} diff --git a/e2e-test/java/org/alfresco/rest/sites/membershipRequests/AddSiteMembershipRequestCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/AddSiteMembershipRequestCoreTests.java deleted file mode 100644 index 3ec6180a9..000000000 --- a/e2e-test/java/org/alfresco/rest/sites/membershipRequests/AddSiteMembershipRequestCoreTests.java +++ /dev/null @@ -1,90 +0,0 @@ -package org.alfresco.rest.sites.membershipRequests; - -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestSiteMembershipRequestModel; -import org.alfresco.utility.constants.UserRole; -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; - -public class AddSiteMembershipRequestCoreTests extends RestTest -{ - private UserModel adminUser; - private SiteModel moderatedSite; - private RestSiteMembershipRequestModel requestModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws DataPreparationException - { - adminUser = dataUser.getAdminUser(); - moderatedSite = dataSite.usingUser(adminUser).createModeratedRandomSite(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify addSiteMembershipRequest Rest API status code is 400 for a user that has already been invited") - public void addSiteMembershipRequestStatusCodeIs400ReceivedForAUserThatIsAlreadyInvited() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - dataUser.addUserToSite(newMember, moderatedSite, UserRole.SiteContributor); - restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - restClient.assertLastError().containsSummary(String.format(RestErrorModel.ALREADY_Site_MEMBER, newMember.getUsername(), moderatedSite.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify addSiteMembershipRequest Rest API status code is 404 for a user that does not exist") - public void addSiteMembershipRequestStatusCodeIs404ReceivedForAUserThatDoesNotExist() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingUser(new UserModel("invalidUser", "password")).addSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - restClient.assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidUser")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify addSiteMembershipRequest Rest API status code is 404 for a site that does not exist") - public void addSiteMembershipRequestStatusCodeIs404ReceivedForASiteThatDoesNotExist() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest(new SiteModel("invalidSiteID")); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - restClient.assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, newMember.getUsername(), "invalidSiteID")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify addSiteMembershipRequest Rest API status code is 400 for empty request body") - public void addSiteMembershipRequestStatusCodeIs400ForEmptyRequestBody() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest(""); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.NO_CONTENT, "No content to map to Object due to end of input")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify addSiteMembershipRequest Rest API status code is 201 for request with empty message") - public void addSiteMembershipRequestStatusCodeIs201ForRequestWithEmptyMessage() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - requestModel = restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest("", moderatedSite, "New request"); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - requestModel.assertThat().field("id").is(moderatedSite.getId()).assertThat().field("site").isNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify addSiteMembershipRequest Rest API status code is 201 for request with empty title") - public void addSiteMembershipRequestStatusCodeIs201ForRequestWithEmptyTitle() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - requestModel = restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest("Please accept me", moderatedSite, ""); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - requestModel.assertThat().field("id").is(moderatedSite.getId()).assertThat().field("site").isNotEmpty(); - } -} diff --git a/e2e-test/java/org/alfresco/rest/sites/membershipRequests/AddSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/AddSiteMembershipRequestSanityTests.java deleted file mode 100644 index 9958520cf..000000000 --- a/e2e-test/java/org/alfresco/rest/sites/membershipRequests/AddSiteMembershipRequestSanityTests.java +++ /dev/null @@ -1,95 +0,0 @@ -package org.alfresco.rest.sites.membershipRequests; - -import org.alfresco.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestSiteMembershipRequestModel; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser; -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; - -public class AddSiteMembershipRequestSanityTests extends RestTest -{ - private SiteModel publicSite, anotherPublicSite; - private DataUser.ListUserWithRoles usersWithRoles; - private UserModel adminUser, siteManager; - private RestSiteMembershipRequestModel requestModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws DataPreparationException - { - adminUser = dataUser.getAdminUser(); - publicSite = dataSite.usingUser(adminUser).createPublicRandomSite(); - usersWithRoles = dataUser.addUsersWithRolesToSite(publicSite, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - - siteManager = dataUser.createRandomTestUser(); - anotherPublicSite = dataSite.usingUser(siteManager).createPublicRandomSite(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site manager is able to create new site membership request for himself and status code is 201") - public void managerCreatesNewSiteMembershipRequestForSelf() throws Exception - { - requestModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingAuthUser().addSiteMembershipRequest(anotherPublicSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - requestModel.assertThat().field("id").is(anotherPublicSite.getId()) - .assertThat().field("site").isNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site contributor is able to create new site membership request for himself and status code is 201") - public void contributorCreatesNewSiteMembershipRequestForSelf() throws Exception - { - requestModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingAuthUser().addSiteMembershipRequest(anotherPublicSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - requestModel.assertThat().field("id").is(anotherPublicSite.getId()) - .assertThat().field("site").isNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site collaborator is able to create new site membership request for himself and status code is 201") - public void collaboratorCreatesNewSiteMembershipRequestForSelf() throws Exception - { - requestModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingAuthUser().addSiteMembershipRequest(anotherPublicSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - requestModel.assertThat().field("id").is(anotherPublicSite.getId()) - .assertThat().field("site").isNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site consumer is able to create new site membership request for himself and status code is 201") - public void consumerCreatesNewSiteMembershipRequestForSelf() throws Exception - { - requestModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingAuthUser().addSiteMembershipRequest(anotherPublicSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - requestModel.assertThat().field("id").is(anotherPublicSite.getId()) - .assertThat().field("site").isNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify admin is able to create new site membership request for himself and status code is 201") - public void adminCreatesNewSiteMembershipRequestForSelf() throws Exception - { - requestModel = restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(anotherPublicSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - requestModel.assertThat().field("id").is(anotherPublicSite.getId()) - .assertThat().field("site").isNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to create new site membership request") - public void unauthenticatedUserIsNotAbleToCreateSiteMembershipRequest() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(new UserModel("random user", "random password")).withCoreAPI().usingAuthUser().addSiteMembershipRequest(publicSite); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/sites/membershipRequests/AddSiteMembershipRequestFullTests.java b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/AddSiteMembershipRequestTests.java similarity index 65% rename from e2e-test/java/org/alfresco/rest/sites/membershipRequests/AddSiteMembershipRequestFullTests.java rename to e2e-test/java/org/alfresco/rest/sites/membershipRequests/AddSiteMembershipRequestTests.java index 3fca73cdf..793a6ffd3 100644 --- a/e2e-test/java/org/alfresco/rest/sites/membershipRequests/AddSiteMembershipRequestFullTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/AddSiteMembershipRequestTests.java @@ -1,6 +1,6 @@ package org.alfresco.rest.sites.membershipRequests; -import org.alfresco.dataprep.SiteService.Visibility; +import org.alfresco.dataprep.SiteService; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestErrorModel; @@ -20,14 +20,11 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -/** - * Created by Claudia Agache on 1/9/2017. - */ -public class AddSiteMembershipRequestFullTests extends RestTest +public class AddSiteMembershipRequestTests extends RestTest { - private SiteModel publicSite, privateSite, moderatedSite; + private SiteModel publicSite, anotherPublicSite, moderatedSite, privateSite; private DataUser.ListUserWithRoles usersWithRoles; - private UserModel adminUser, newMember, regularUser; + private UserModel adminUser, siteManager, regularUser, newMember; private RestSiteMembershipRequestModel siteMembershipRequest; private RestSiteMembershipRequestModelsCollection siteMembershipRequests; @@ -36,16 +33,146 @@ public class AddSiteMembershipRequestFullTests extends RestTest { adminUser = dataUser.getAdminUser(); publicSite = dataSite.usingUser(adminUser).createPublicRandomSite(); - privateSite = dataSite.usingUser(adminUser).createPrivateRandomSite(); - moderatedSite = dataSite.usingUser(adminUser).createModeratedRandomSite(); usersWithRoles = dataUser.addUsersWithRolesToSite(publicSite, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + + siteManager = dataUser.createRandomTestUser(); + anotherPublicSite = dataSite.usingUser(siteManager).createPublicRandomSite(); + + moderatedSite = dataSite.usingUser(adminUser).createModeratedRandomSite(); + privateSite = dataSite.usingUser(adminUser).createPrivateRandomSite(); + newMember = dataUser.createRandomTestUser(); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, + description = "Verify site manager is able to create new site membership request for himself and status code is 201") + public void managerCreatesNewSiteMembershipRequestForSelf() throws Exception + { + siteMembershipRequest = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingAuthUser().addSiteMembershipRequest(anotherPublicSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + siteMembershipRequest.assertThat().field("id").is(anotherPublicSite.getId()) + .assertThat().field("site").isNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify site contributor is able to create new site membership request for himself and status code is 201") + public void contributorCreatesNewSiteMembershipRequestForSelf() throws Exception + { + siteMembershipRequest = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingAuthUser().addSiteMembershipRequest(anotherPublicSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + siteMembershipRequest.assertThat().field("id").is(anotherPublicSite.getId()) + .assertThat().field("site").isNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify site collaborator is able to create new site membership request for himself and status code is 201") + public void collaboratorCreatesNewSiteMembershipRequestForSelf() throws Exception + { + siteMembershipRequest = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingAuthUser().addSiteMembershipRequest(anotherPublicSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + siteMembershipRequest.assertThat().field("id").is(anotherPublicSite.getId()) + .assertThat().field("site").isNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify site consumer is able to create new site membership request for himself and status code is 201") + public void consumerCreatesNewSiteMembershipRequestForSelf() throws Exception + { + siteMembershipRequest = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingAuthUser().addSiteMembershipRequest(anotherPublicSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + siteMembershipRequest.assertThat().field("id").is(anotherPublicSite.getId()) + .assertThat().field("site").isNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify admin is able to create new site membership request for himself and status code is 201") + public void adminCreatesNewSiteMembershipRequestForSelf() throws Exception + { + siteMembershipRequest = restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(anotherPublicSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + siteMembershipRequest.assertThat().field("id").is(anotherPublicSite.getId()) + .assertThat().field("site").isNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, + description = "Verify unauthenticated user is not able to create new site membership request") + public void unauthenticatedUserIsNotAbleToCreateSiteMembershipRequest() throws Exception + { + restClient.authenticateUser(new UserModel("random user", "random password")).withCoreAPI().usingAuthUser().addSiteMembershipRequest(publicSite); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify addSiteMembershipRequest Rest API status code is 400 for a user that has already been invited") + public void addSiteMembershipRequestStatusCodeIs400ReceivedForAUserThatIsAlreadyInvited() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + dataUser.addUserToSite(newMember, moderatedSite, UserRole.SiteContributor); + restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + restClient.assertLastError().containsSummary(String.format(RestErrorModel.ALREADY_Site_MEMBER, newMember.getUsername(), moderatedSite.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify addSiteMembershipRequest Rest API status code is 404 for a user that does not exist") + public void addSiteMembershipRequestStatusCodeIs404ReceivedForAUserThatDoesNotExist() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(newMember).withCoreAPI().usingUser(new UserModel("invalidUser", "password")).addSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + restClient.assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidUser")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify addSiteMembershipRequest Rest API status code is 404 for a site that does not exist") + public void addSiteMembershipRequestStatusCodeIs404ReceivedForASiteThatDoesNotExist() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest(new SiteModel("invalidSiteID")); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + restClient.assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, newMember.getUsername(), "invalidSiteID")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify addSiteMembershipRequest Rest API status code is 400 for empty request body") + public void addSiteMembershipRequestStatusCodeIs400ForEmptyRequestBody() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest(""); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.NO_CONTENT, "No content to map to Object due to end of input")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify addSiteMembershipRequest Rest API status code is 201 for request with empty message") + public void addSiteMembershipRequestStatusCodeIs201ForRequestWithEmptyMessage() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + siteMembershipRequest = restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest("", moderatedSite, "New request"); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + siteMembershipRequest.assertThat().field("id").is(moderatedSite.getId()).assertThat().field("site").isNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify addSiteMembershipRequest Rest API status code is 201 for request with empty title") + public void addSiteMembershipRequestStatusCodeIs201ForRequestWithEmptyTitle() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + siteMembershipRequest = restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest("Please accept me", moderatedSite, ""); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + siteMembershipRequest.assertThat().field("id").is(moderatedSite.getId()).assertThat().field("site").isNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site manager is not able to create new site membership request for other user") - public void managerIsNotAbleToCreateSiteMembershipRequestForOtherUser() throws JsonToModelConversionException, Exception + public void managerIsNotAbleToCreateSiteMembershipRequestForOtherUser() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingUser(newMember) .addSiteMembershipRequest(publicSite); @@ -57,9 +184,9 @@ public class AddSiteMembershipRequestFullTests extends RestTest .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site collaborator is not able to create new site membership request for other user") - public void collaboratorIsNotAbleToCreateSiteMembershipRequestForOtherUser() throws JsonToModelConversionException, Exception + public void collaboratorIsNotAbleToCreateSiteMembershipRequestForOtherUser() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingUser(newMember) .addSiteMembershipRequest(publicSite); @@ -67,9 +194,9 @@ public class AddSiteMembershipRequestFullTests extends RestTest .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site contributor is not able to create new site membership request for other user") - public void contributorIsNotAbleToCreateSiteMembershipRequestForOtherUser() throws JsonToModelConversionException, Exception + public void contributorIsNotAbleToCreateSiteMembershipRequestForOtherUser() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingUser(newMember) .addSiteMembershipRequest(publicSite); @@ -77,9 +204,9 @@ public class AddSiteMembershipRequestFullTests extends RestTest .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site consumer is not able to create new site membership request for other user") - public void consumerIsNotAbleToCreateSiteMembershipRequestForOtherUser() throws JsonToModelConversionException, Exception + public void consumerIsNotAbleToCreateSiteMembershipRequestForOtherUser() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingUser(newMember) .addSiteMembershipRequest(publicSite); @@ -87,9 +214,9 @@ public class AddSiteMembershipRequestFullTests extends RestTest .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin user is not able to create new site membership request for other user") - public void adminIsNotAbleToCreateSiteMembershipRequestForOtherUser() throws JsonToModelConversionException, Exception + public void adminIsNotAbleToCreateSiteMembershipRequestForOtherUser() throws Exception { restClient.authenticateUser(adminUser).withCoreAPI().usingUser(newMember).addSiteMembershipRequest(publicSite); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) @@ -105,7 +232,7 @@ public class AddSiteMembershipRequestFullTests extends RestTest } @Bug(id="ACE-2413") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify addSiteMembershipRequest Rest API status code is 400 for an invalid user id") public void addSiteMembershipRequestReturns400ForEmptyUserId() throws Exception { @@ -114,7 +241,7 @@ public class AddSiteMembershipRequestFullTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify regular user is able to create new public site membership request for himself. Check that user joins immediately as consumer.") public void userIsAbleToRequestMembershipOfPublicSite() throws Exception @@ -127,13 +254,13 @@ public class AddSiteMembershipRequestFullTests extends RestTest RestSiteEntry siteEntry = restClient.withCoreAPI().usingAuthUser().getSiteMembership(publicSite); restClient.assertStatusCodeIs(HttpStatus.OK); siteEntry.assertThat().field("role").is(UserRole.SiteConsumer) - .and().field("id").is(publicSite.getId()); + .and().field("id").is(publicSite.getId()); siteMembershipRequests = restClient.withCoreAPI().usingAuthUser().getSiteMembershipRequests(); restClient.assertStatusCodeIs(HttpStatus.OK); siteMembershipRequests.assertThat().entriesListIsEmpty(); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify regular user is able to create new moderated site membership request for himself. Check that the request is added to the site membership request list.") public void userIsAbleToRequestMembershipOfModeratedSite() throws Exception @@ -158,7 +285,7 @@ public class AddSiteMembershipRequestFullTests extends RestTest } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify regular user is not able to request membership of a private site.") public void userIsNotAbleToRequestMembershipOfPrivateSite() throws Exception @@ -172,9 +299,9 @@ public class AddSiteMembershipRequestFullTests extends RestTest siteMembershipRequests.assertThat().entriesListIsEmpty(); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify regular user is not able to create new site membership request for other user") - public void regularUserIsNotAbleToCreateSiteMembershipRequestForOtherUser() throws JsonToModelConversionException, Exception + public void regularUserIsNotAbleToCreateSiteMembershipRequestForOtherUser() throws Exception { regularUser = dataUser.createRandomTestUser(); restClient.authenticateUser(regularUser).withCoreAPI().usingUser(newMember) @@ -191,7 +318,7 @@ public class AddSiteMembershipRequestFullTests extends RestTest .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify create public site membership request returns status code 400 when the request is made twice") public void userRequestsTwiceMembershipOfPublicSite() throws Exception @@ -206,7 +333,7 @@ public class AddSiteMembershipRequestFullTests extends RestTest restClient.assertLastError().containsSummary(String.format(RestErrorModel.ALREADY_Site_MEMBER, regularUser.getUsername(), publicSite.getId())); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify create moderated site membership request returns status code 400 when the request is made twice") public void userRequestsTwiceMembershipOfModeratedSite() throws Exception @@ -226,7 +353,7 @@ public class AddSiteMembershipRequestFullTests extends RestTest .assertThat().entriesListCountIs(1); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify create private site membership request returns status code 404 when request is made with the user who created the site") public void siteCreatorRequestsMembershipOfHisPrivateSite() throws Exception @@ -236,7 +363,7 @@ public class AddSiteMembershipRequestFullTests extends RestTest .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, adminUser.getUsername(), privateSite.getId())); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify create moderated site membership request returns status code 400 when request is made with the user who created the site") public void siteCreatorRequestsMembershipOfHisModeratedSite() throws Exception @@ -246,7 +373,7 @@ public class AddSiteMembershipRequestFullTests extends RestTest .assertLastError().containsSummary(String.format(RestErrorModel.ALREADY_Site_MEMBER, adminUser.getUsername(), moderatedSite.getId())); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to create new moderated site membership request for himself. Check that the request is added to the site membership request list.") public void adminIsAbleToRequestMembershipOfModeratedSite() throws Exception @@ -262,7 +389,7 @@ public class AddSiteMembershipRequestFullTests extends RestTest siteMembershipRequests.assertThat().entriesListContains("id", anotherModeratedSite.getId()); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL, TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION, TestGroup.NETWORKS }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify create site membership request returns status code 404 when personId is not member of the domain.") public void addSiteMembershipRequestWhenPersonIdIsNotInTheDomain() throws Exception @@ -275,7 +402,7 @@ public class AddSiteMembershipRequestFullTests extends RestTest .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, adminTenantUser.getUsername().toLowerCase(), publicSite.getId())); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL, TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION, TestGroup.NETWORKS }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify create site membership request returns status code 200 with tenant.") public void addSiteMembershipRequestWithTenant() throws Exception @@ -292,7 +419,7 @@ public class AddSiteMembershipRequestFullTests extends RestTest .assertThat().field("site").isNotEmpty(); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site membership request is automatically rejected when a site is switched from moderated to private") public void siteMembershipRequestIsRejectedWhenSiteIsSwitchedFromModeratedToPrivate() throws Exception @@ -304,10 +431,10 @@ public class AddSiteMembershipRequestFullTests extends RestTest siteMembershipRequest.assertThat().field("id").is(moderatedThenPrivateSite.getId()) .assertThat().field("site").isNotEmpty(); - dataSite.usingUser(adminUser).updateSiteVisibility(moderatedThenPrivateSite, Visibility.PRIVATE); + dataSite.usingUser(adminUser).updateSiteVisibility(moderatedThenPrivateSite, SiteService.Visibility.PRIVATE); siteMembershipRequests = restClient.withCoreAPI().usingAuthUser().getSiteMembershipRequests(); restClient.assertStatusCodeIs(HttpStatus.OK); siteMembershipRequests.assertThat().entriesListIsEmpty(); } -} +} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/sites/membershipRequests/DeleteSiteMembershipRequestCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/DeleteSiteMembershipRequestCoreTests.java deleted file mode 100644 index b08bc7146..000000000 --- a/e2e-test/java/org/alfresco/rest/sites/membershipRequests/DeleteSiteMembershipRequestCoreTests.java +++ /dev/null @@ -1,148 +0,0 @@ -package org.alfresco.rest.sites.membershipRequests; - -import org.alfresco.dataprep.WorkflowService; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestTaskModel; -import org.alfresco.utility.constants.UserRole; -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.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -public class DeleteSiteMembershipRequestCoreTests extends RestTest -{ - SiteModel moderatedSite; - UserModel adminUserModel; - UserModel siteMember; - UserModel secondSiteMember; - SiteModel secondModeratedSite; - @Autowired - WorkflowService workflow; - - @BeforeMethod(alwaysRun = true) - public void dataPreparation() throws Exception - { - moderatedSite = dataSite.usingUser(adminUserModel).createModeratedRandomSite(); - adminUserModel = dataUser.getAdminUser(); - siteMember = dataUser.createRandomTestUser(); - secondSiteMember = dataUser.createRandomTestUser(); - secondModeratedSite = dataSite.usingUser(siteMember).createModeratedRandomSite(); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is able to remove his own site memebership request using '-me-' in place of personId and response is successful (204)") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - public void userCanDeleteHisOwnSiteMembershipRequestUsingMeAsPersonId() throws JsonToModelConversionException, DataPreparationException, Exception - { - restClient.authenticateUser(siteMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - restClient.withCoreAPI().usingMe().deleteSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove site memebership request if doesn't have access to personI and response is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - public void userIsNotAbleToDeleteSiteMembershipRequestWithNoAccessToPersonId() throws JsonToModelConversionException, DataPreparationException, Exception - { - restClient.authenticateUser(secondSiteMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - restClient.authenticateUser(siteMember).withCoreAPI().usingUser(secondSiteMember).deleteSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, secondSiteMember.getUsername(), moderatedSite.getId())); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove a site memebership request of an inexistent user and response is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - public void userIsNotAbleToDeleteSiteMembershipRequestOfAnInexistentUser() throws JsonToModelConversionException, DataPreparationException, Exception - { - UserModel inexistentUser = new UserModel("inexistenUser", "password"); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(inexistentUser).deleteSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, inexistentUser.getUsername())); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove a site memebership request to an inexistent site and response is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - public void userIsNotAbleToDeleteSiteMembershipRequestToAnInexistentSite() throws JsonToModelConversionException, DataPreparationException, Exception - { - SiteModel inexistentSite = new SiteModel("inexistentSite"); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).deleteSiteMembershipRequest(inexistentSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, adminUserModel.getUsername(), inexistentSite.getId())); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove a site memebership request to an empty site id and response is 405") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - public void userIsNotAbleToDeleteSiteMembershipRequestWithEmptySiteId() throws JsonToModelConversionException, DataPreparationException, Exception - { - SiteModel inexistentSite = new SiteModel(""); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).deleteSiteMembershipRequest(inexistentSite); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.DELETE_EMPTY_ARGUMENT); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove a site memebership request of another regular user from moderated site and response is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - public void regularUserIsNotAbleToDeleteSiteMembershipRequestOfAnotherRegularUserToAModeratedSite() throws JsonToModelConversionException, DataPreparationException, Exception - { - siteMember.setUserRole(UserRole.SiteCollaborator); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSite).addPerson(siteMember); - restClient.authenticateUser(secondSiteMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - restClient.authenticateUser(siteMember).withCoreAPI().usingUser(secondSiteMember).deleteSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, secondSiteMember.getUsername(), moderatedSite.getId())); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove a site memebership request of admin to a moderated site and response is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - public void regularUserIsNotAbleToDeleteSiteMembershipRequestOfAdminToAModeratedSite() throws JsonToModelConversionException, DataPreparationException, Exception - { - UserModel collaboratorUser = dataUser.createRandomTestUser(); - collaboratorUser.setUserRole(UserRole.SiteCollaborator); - restClient.authenticateUser(siteMember).withCoreAPI().usingSite(secondModeratedSite).addPerson(collaboratorUser); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteMembershipRequest(secondModeratedSite); - restClient.authenticateUser(collaboratorUser).withCoreAPI().usingUser(adminUserModel).deleteSiteMembershipRequest(secondModeratedSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, adminUserModel.getUsername(), secondModeratedSite.getId())); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify manager is able to remove a site memebership request of admin to a moderated site and response is 204") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - public void managerUserIsAbleToDeleteSiteMembershipRequestOfAdminToAModeratedSite() throws JsonToModelConversionException, DataPreparationException, Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteMembershipRequest(secondModeratedSite); - restClient.authenticateUser(siteMember).withCoreAPI().usingUser(adminUserModel).deleteSiteMembershipRequest(secondModeratedSite); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify manager is not able to remove a site memebership request if it was already approved and response is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - public void managerUserIsNotAbleToDeleteASiteMembershipRequestIfItWasAlreadyApproved() throws JsonToModelConversionException, DataPreparationException, Exception - { - secondSiteMember.setUserRole(UserRole.SiteCollaborator); - restClient.authenticateUser(secondSiteMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(secondModeratedSite); - RestTaskModel taskModel = restClient.authenticateUser(secondSiteMember).withWorkflowAPI().getTasks().getTaskModelByDescription(secondModeratedSite); - workflow.approveSiteMembershipRequest(siteMember.getUsername(), siteMember.getPassword(), taskModel.getId(), true, "Approve"); - - restClient.authenticateUser(siteMember).withCoreAPI().usingUser(secondSiteMember).deleteSiteMembershipRequest(secondModeratedSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, secondSiteMember.getUsername(), secondModeratedSite.getId())); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify manager is not able to remove an inexitent site memebership request and response is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - public void managerUserIsNotAbleToDeleteAnInexistentSiteMembershipRequest() throws JsonToModelConversionException, DataPreparationException, Exception - { - restClient.authenticateUser(siteMember).withCoreAPI().usingUser(adminUserModel).deleteSiteMembershipRequest(secondModeratedSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, adminUserModel.getUsername(), secondModeratedSite.getId())); - } -} diff --git a/e2e-test/java/org/alfresco/rest/sites/membershipRequests/DeleteSiteMembershipRequestFullTests.java b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/DeleteSiteMembershipRequestFullTests.java deleted file mode 100644 index 7ddd11106..000000000 --- a/e2e-test/java/org/alfresco/rest/sites/membershipRequests/DeleteSiteMembershipRequestFullTests.java +++ /dev/null @@ -1,213 +0,0 @@ -package org.alfresco.rest.sites.membershipRequests; - -import org.alfresco.dataprep.WorkflowService; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestSiteMembershipRequestModelsCollection; -import org.alfresco.rest.model.RestTaskModel; -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.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class DeleteSiteMembershipRequestFullTests extends RestTest -{ - SiteModel moderatedSite, publicSite, secondModeratedSite; - UserModel adminUserModel, siteMember, secondSiteMember; - RestSiteMembershipRequestModelsCollection siteMembershipRequests; - - @Autowired - WorkflowService workflow; - private ListUserWithRoles usersWithRoles; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - moderatedSite = dataSite.usingUser(adminUserModel).createModeratedRandomSite(); - adminUserModel = dataUser.getAdminUser(); - siteMember = dataUser.createRandomTestUser(); - secondSiteMember = dataUser.createRandomTestUser(); - secondModeratedSite = dataSite.usingUser(siteMember).createModeratedRandomSite(); - publicSite = dataSite.usingUser(siteMember).createPublicRandomSite(); - - usersWithRoles = dataUser.addUsersWithRolesToSite(moderatedSite, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify COLLABORATOR is able to remove/cancel a site memebership request of a user to a moderated site and response is 204") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - public void collaboratorUserIsAbleToCancelSiteMembershipRequestOfAnotherUserToAModeratedSite() throws JsonToModelConversionException, - DataPreparationException, Exception - { - UserModel user = dataUser.createRandomTestUser(); - UserModel userCollaborator = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); - moderatedSite = dataSite.usingUser(userCollaborator).createModeratedRandomSite(); - - restClient.authenticateUser(user).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - restClient.authenticateUser(userCollaborator).withCoreAPI().usingUser(user).getSiteMembershipRequest(moderatedSite).assertThat().field("id") - .is(moderatedSite.getId()); - - restClient.authenticateUser(userCollaborator).withCoreAPI().usingUser(user).deleteSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingUser(user).getSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, user.getUsername(), moderatedSite.getTitle())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify CONTRIBUTOR is able to remove/cancel a site memebership request of a user to a moderated site and response is 204") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - public void contributorUserIsAbleToCancelSiteMembershipRequestOfAnotherUserToAModeratedSite() throws JsonToModelConversionException, - DataPreparationException, Exception - { - UserModel user = dataUser.createRandomTestUser(); - UserModel userContributor = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); - moderatedSite = dataSite.usingUser(userContributor).createModeratedRandomSite(); - - restClient.authenticateUser(user).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - restClient.authenticateUser(userContributor).withCoreAPI().usingUser(user).getSiteMembershipRequest(moderatedSite).assertThat().field("id") - .is(moderatedSite.getId()); - - restClient.authenticateUser(userContributor).withCoreAPI().usingUser(user).deleteSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingUser(user).getSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, user.getUsername(), moderatedSite.getTitle())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify CONSUMER is able to remove/cancel a site memebership request of a user to a moderated site and response is 204") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - public void consumerUserIsAbleToCancelSiteMembershipRequestOfAnotherUserToAModeratedSite() throws JsonToModelConversionException, DataPreparationException, - Exception - { - UserModel user = dataUser.createRandomTestUser(); - UserModel userConsumer = usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer); - moderatedSite = dataSite.usingUser(userConsumer).createModeratedRandomSite(); - - restClient.authenticateUser(user).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - restClient.authenticateUser(userConsumer).withCoreAPI().usingUser(user).getSiteMembershipRequest(moderatedSite).assertThat().field("id") - .is(moderatedSite.getId()); - - restClient.authenticateUser(userConsumer).withCoreAPI().usingUser(user).deleteSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingUser(user).getSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, user.getUsername(), moderatedSite.getTitle())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify user is not able to remove a site memebership request of admin to a public site and response is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - public void regularUserIsNotAbleToDeleteSiteMembershipRequestOfAdminToAPublicSite() throws JsonToModelConversionException, DataPreparationException, - Exception - { - UserModel userCollaborator = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); - restClient.authenticateUser(siteMember).withCoreAPI().usingSite(publicSite).addPerson(userCollaborator); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteMembershipRequest(publicSite); - - restClient.authenticateUser(userCollaborator).withCoreAPI().usingUser(adminUserModel).deleteSiteMembershipRequest(publicSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, adminUserModel.getUsername(), publicSite.getId())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Delete a rejected site membership request.") - public void deleteARejectedSiteMembershipRequest() throws Exception - { - UserModel userWithRejectedRequests = dataUser.createRandomTestUser(); - restClient.authenticateUser(userWithRejectedRequests).withCoreAPI().usingAuthUser().addSiteMembershipRequest(secondModeratedSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestTaskModel taskModel = restClient.authenticateUser(userWithRejectedRequests).withWorkflowAPI().getTasks() - .getTaskModelByDescription(secondModeratedSite); - workflow.approveSiteMembershipRequest(siteMember.getUsername(), siteMember.getPassword(), taskModel.getId(), false, "Rejected"); - - siteMembershipRequests = restClient.authenticateUser(userWithRejectedRequests).withCoreAPI().usingMe().getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.OK); - siteMembershipRequests.assertThat().entriesListDoesNotContain("id", secondModeratedSite.getId()); - - restClient.authenticateUser(userWithRejectedRequests).withCoreAPI().usingUser(adminUserModel).deleteSiteMembershipRequest(secondModeratedSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, adminUserModel.getUsername(), secondModeratedSite.getId())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Bug(id="ACE-2413") - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify user is not able to remove a site memebership request- empty person id and response is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - public void userIsNotAbleToDeleteSiteMembershipRequestEmptyPersonID() throws JsonToModelConversionException, DataPreparationException, Exception - { - UserModel emptyPersonId = new UserModel("", "password"); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(emptyPersonId).deleteSiteMembershipRequest(moderatedSite); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .containsSummary(RestErrorModel.ENTITY_NOT_FOUND) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify COLLABORATOR removes/cancel twice same site memebership request and response is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - public void userCancelsSiteMembershipRequestTwiceModeratedSite() throws JsonToModelConversionException, - DataPreparationException, Exception - { - UserModel user = dataUser.createRandomTestUser(); - UserModel userCollaborator = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); - moderatedSite = dataSite.usingUser(userCollaborator).createModeratedRandomSite(); - - restClient.authenticateUser(user).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - restClient.authenticateUser(userCollaborator).withCoreAPI().usingUser(user).getSiteMembershipRequest(moderatedSite).assertThat().field("id") - .is(moderatedSite.getId()); - - restClient.authenticateUser(userCollaborator).withCoreAPI().usingUser(user).deleteSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.authenticateUser(userCollaborator).withCoreAPI().usingUser(user).deleteSiteMembershipRequest(moderatedSite); - - restClient.withCoreAPI().usingUser(user).getSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, user.getUsername(), moderatedSite.getTitle())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } -} diff --git a/e2e-test/java/org/alfresco/rest/sites/membershipRequests/DeleteSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/DeleteSiteMembershipRequestSanityTests.java deleted file mode 100644 index 2ff501e68..000000000 --- a/e2e-test/java/org/alfresco/rest/sites/membershipRequests/DeleteSiteMembershipRequestSanityTests.java +++ /dev/null @@ -1,137 +0,0 @@ -package org.alfresco.rest.sites.membershipRequests; - -import org.alfresco.dataprep.SiteService.Visibility; -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.data.RandomData; -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.report.Bug; -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 DeleteSiteMembershipRequestSanityTests extends RestTest -{ - UserModel userModel; - UserModel siteMember; - SiteModel siteModel; - private ListUserWithRoles usersWithRoles; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - String siteId = RandomData.getRandomName("site"); - siteModel = dataSite.usingUser(userModel).createSite(new SiteModel(Visibility.MODERATED, siteId, siteId, siteId, siteId)); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify one user is able to delete his one site memebership request") - public void userCanDeleteHisOwnSiteMembershipRequest() throws JsonToModelConversionException, DataPreparationException, Exception - { - siteMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(siteMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(siteModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingUser(siteMember) - .deleteSiteMembershipRequest(siteModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site manager is able to delete site membership request") - public void siteManagerCanDeleteSiteMembershipRequest() throws JsonToModelConversionException, DataPreparationException, Exception - { - siteMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(siteMember).withCoreAPI().usingUser(siteMember).addSiteMembershipRequest(siteModel); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingUser(siteMember) - .deleteSiteMembershipRequest(siteModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify admin user is able to delete site memebership request") - public void adminUserCanDeleteSiteMembershipRequest() throws JsonToModelConversionException, DataPreparationException, Exception - { - siteMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(siteMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(siteModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingUser(siteMember).deleteSiteMembershipRequest(siteModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @Bug(id = "REPO-1946") - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify collaborator user is not able to delete site memebership request") - public void collaboratorCannotDeleteSiteMembershipRequest() throws JsonToModelConversionException, DataPreparationException, Exception - { - siteMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(siteMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(siteModel); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingUser(siteMember) - .deleteSiteMembershipRequest(siteModel); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @Bug(id = "REPO-1946") - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify contributor user is not able to delete site memebership request") - public void contributorCannotDeleteSiteMembershipRequest() throws JsonToModelConversionException, DataPreparationException, Exception - { - siteMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(siteMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(siteModel); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingUser(siteMember) - .deleteSiteMembershipRequest(siteModel); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @Bug(id = "REPO-1946") - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify consumer user is not able to delete site memebership request") - public void consumerCannotDeleteSiteMembershipRequest() throws JsonToModelConversionException, DataPreparationException, Exception - { - siteMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(siteMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(siteModel); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingUser(siteMember) - .deleteSiteMembershipRequest(siteModel); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @Bug(id = "REPO-1946") - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify random user is not able to delete site memebership request") - public void randomUserCanDeleteSiteMembershipRequest() throws JsonToModelConversionException, DataPreparationException, Exception - { - siteMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(siteMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(siteModel); - - restClient.authenticateUser(dataUser.createRandomTestUser()).withCoreAPI().usingUser(siteMember).deleteSiteMembershipRequest(siteModel); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, 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") - public void unauthenticatedUserIsNotAuthorizedToDeleteSiteMmebershipRequest() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(dataUser.createRandomTestUser()).withCoreAPI().usingAuthUser().addSiteMembershipRequest(siteModel); - UserModel inexistentUser = new UserModel("inexistent user", "inexistent password"); - restClient.authenticateUser(inexistentUser).withCoreAPI().usingAuthUser().deleteSiteMembershipRequest(siteModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } -} diff --git a/e2e-test/java/org/alfresco/rest/sites/membershipRequests/DeleteSiteMembershipRequestTests.java b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/DeleteSiteMembershipRequestTests.java new file mode 100644 index 000000000..e3d7e1059 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/DeleteSiteMembershipRequestTests.java @@ -0,0 +1,319 @@ +package org.alfresco.rest.sites.membershipRequests; + +import org.alfresco.dataprep.SiteService.Visibility; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestSiteMembershipRequestModelsCollection; +import org.alfresco.rest.model.RestTaskModel; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.data.RandomData; +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.report.Bug; +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 DeleteSiteMembershipRequestTests extends RestTest +{ + UserModel siteCreator, adminUserModel, secondSiteCreator, siteMember; + SiteModel moderatedSite, secondModeratedSite, publicSite; + private ListUserWithRoles usersWithRoles; + RestSiteMembershipRequestModelsCollection siteMembershipRequests; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + siteCreator = dataUser.createRandomTestUser(); + secondSiteCreator = dataUser.createRandomTestUser(); + String siteId = RandomData.getRandomName("site"); + moderatedSite = dataSite.usingUser(siteCreator).createSite(new SiteModel(Visibility.MODERATED, siteId, siteId, siteId, siteId)); + usersWithRoles = dataUser.addUsersWithRolesToSite(moderatedSite, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + + dataUser.addUserToSite(adminUserModel, moderatedSite, UserRole.SiteManager); + secondModeratedSite = dataSite.usingUser(secondSiteCreator).createModeratedRandomSite(); + publicSite = dataSite.usingUser(siteCreator).createPublicRandomSite(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify one user is able to delete his one site memebership request") + public void userCanDeleteHisOwnSiteMembershipRequest() throws Exception + { + restClient.authenticateUser(secondSiteCreator).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.withCoreAPI().usingUser(secondSiteCreator).deleteSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site manager is able to delete site membership request") + public void managerCanDeleteSiteMembershipRequest() throws Exception + { + siteMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(siteMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingUser(siteMember) + .deleteSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingUser(siteMember).getSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, siteMember.getUsername(), moderatedSite.getTitle())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin user is able to delete site memebership request") + public void adminUserCanDeleteSiteMembershipRequest() throws Exception + { + siteMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(siteMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(siteMember).deleteSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @Bug(id = "REPO-1946") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify collaborator user is not able to delete site memebership request") + public void collaboratorCannotDeleteSiteMembershipRequest() throws Exception + { + siteMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(siteMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingUser(siteMember) + .deleteSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @Bug(id = "REPO-1946") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify contributor user is not able to delete site memebership request") + public void contributorCannotDeleteSiteMembershipRequest() throws Exception + { + siteMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(siteMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingUser(siteMember) + .deleteSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @Bug(id = "REPO-1946") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify consumer user is not able to delete site memebership request") + public void consumerCannotDeleteSiteMembershipRequest() throws Exception + { + siteMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(siteMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingUser(siteMember) + .deleteSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @Bug(id = "REPO-1946") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify random user is not able to delete site memebership request") + public void randomUserCanNotDeleteSiteMembershipRequest() throws Exception + { + siteMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(siteMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + + restClient.authenticateUser(dataUser.createRandomTestUser()).withCoreAPI().usingUser(siteMember).deleteSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, 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") + public void unauthenticatedUserIsNotAuthorizedToDeleteSiteMmebershipRequest() throws Exception + { + restClient.authenticateUser(dataUser.createRandomTestUser()).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + UserModel inexistentUser = new UserModel("inexistent user", "inexistent password"); + restClient.authenticateUser(inexistentUser).withCoreAPI().usingAuthUser().deleteSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify user is able to remove his own site memebership request using '-me-' in place of personId and response is successful (204)") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void userCanDeleteHisOwnSiteMembershipRequestUsingMeAsPersonId() throws Exception + { + restClient.authenticateUser(secondSiteCreator).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + restClient.withCoreAPI().usingMe().deleteSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify user is not able to remove a site memebership request of an inexistent user and response is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void adminIsNotAbleToDeleteSiteMembershipRequestOfAnInexistentUser() throws Exception + { + UserModel inexistentUser = new UserModel("inexistenUser", "password"); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(inexistentUser).deleteSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, inexistentUser.getUsername())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify user is not able to remove a site memebership request to an inexistent site and response is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void adminIsNotAbleToDeleteSiteMembershipRequestToAnInexistentSite() throws Exception + { + SiteModel inexistentSite = new SiteModel("inexistentSite"); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).deleteSiteMembershipRequest(inexistentSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, adminUserModel.getUsername(), inexistentSite.getId())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify user is not able to remove a site memebership request to an empty site id and response is 405") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void adminIsNotAbleToDeleteSiteMembershipRequestWithEmptySiteId() throws Exception + { + SiteModel inexistentSite = new SiteModel(""); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).deleteSiteMembershipRequest(inexistentSite); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.DELETE_EMPTY_ARGUMENT); + } + + @Bug(id = "REPO-1946") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify contributor user is not able to remove a site memebership request of admin to a moderated site and response is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void contributorIsNotAbleToDeleteSiteMembershipRequestOfAdminToAModeratedSite() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingUser(adminUserModel).deleteSiteMembershipRequest(secondModeratedSite); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify manager is able to remove a site memebership request of admin to a moderated site and response is 204") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void managerUserIsAbleToDeleteSiteMembershipRequestOfAdminToAModeratedSite() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteMembershipRequest(secondModeratedSite); + restClient.authenticateUser(secondSiteCreator).withCoreAPI().usingUser(adminUserModel).deleteSiteMembershipRequest(secondModeratedSite); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify manager is not able to remove a site memebership request if it was already approved and response is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void managerUserIsNotAbleToDeleteASiteMembershipRequestIfItWasAlreadyApproved() throws Exception + { + siteMember.setUserRole(UserRole.SiteCollaborator); + restClient.authenticateUser(siteMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(secondModeratedSite); + RestTaskModel taskModel = restClient.authenticateUser(siteMember).withWorkflowAPI().getTasks().getTaskModelByDescription(secondModeratedSite); + workflow.approveSiteMembershipRequest(secondSiteCreator.getUsername(), secondSiteCreator.getPassword(), taskModel.getId(), true, "Approve"); + + restClient.authenticateUser(secondSiteCreator).withCoreAPI().usingUser(siteMember).deleteSiteMembershipRequest(secondModeratedSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, siteMember.getUsername(), secondModeratedSite.getId())); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify manager is not able to remove an inexitent site memebership request and response is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void managerUserIsNotAbleToDeleteAnInexistentSiteMembershipRequest() throws Exception + { + restClient.authenticateUser(secondSiteCreator).withCoreAPI().usingUser(adminUserModel).deleteSiteMembershipRequest(secondModeratedSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, adminUserModel.getUsername(), secondModeratedSite.getId())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify collaborator user is not able to remove a site memebership request of admin to a public site and response is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void collaboratorIsNotAbleToDeleteSiteMembershipRequestOfAdminToAPublicSite() throws Exception + { + UserModel userCollaborator = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); + restClient.authenticateUser(siteMember).withCoreAPI().usingSite(publicSite).addPerson(userCollaborator); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteMembershipRequest(publicSite); + + restClient.authenticateUser(userCollaborator).withCoreAPI().usingUser(adminUserModel).deleteSiteMembershipRequest(publicSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, adminUserModel.getUsername(), publicSite.getId())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Delete a rejected site membership request.") + public void deleteARejectedSiteMembershipRequest() throws Exception + { + UserModel userWithRejectedRequests = dataUser.createRandomTestUser(); + restClient.authenticateUser(userWithRejectedRequests).withCoreAPI().usingAuthUser().addSiteMembershipRequest(secondModeratedSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestTaskModel taskModel = restClient.authenticateUser(userWithRejectedRequests).withWorkflowAPI().getTasks() + .getTaskModelByDescription(secondModeratedSite); + workflow.approveSiteMembershipRequest(secondSiteCreator.getUsername(), secondSiteCreator.getPassword(), taskModel.getId(), false, "Rejected"); + + siteMembershipRequests = restClient.authenticateUser(userWithRejectedRequests).withCoreAPI().usingMe().getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembershipRequests.assertThat().entriesListDoesNotContain("id", secondModeratedSite.getId()); + + restClient.authenticateUser(secondSiteCreator).withCoreAPI().usingUser(userWithRejectedRequests).deleteSiteMembershipRequest(secondModeratedSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, userWithRejectedRequests.getUsername(), secondModeratedSite.getId())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Bug(id="ACE-2413") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify user is not able to remove a site memebership request- empty person id and response is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void adminIsNotAbleToDeleteSiteMembershipRequestEmptyPersonID() throws Exception + { + UserModel emptyPersonId = new UserModel("", "password"); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(emptyPersonId).deleteSiteMembershipRequest(moderatedSite); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .containsSummary(RestErrorModel.ENTITY_NOT_FOUND) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify manager removes/cancel twice same site memebership request and response is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void managerCancelsTwiceSiteMembershipRequestModeratedSite() throws Exception + { + siteMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(siteMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + + restClient.authenticateUser(siteCreator).withCoreAPI().usingUser(siteMember).deleteSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withCoreAPI().usingUser(siteMember).deleteSiteMembershipRequest(moderatedSite); + + restClient.withCoreAPI().usingUser(siteMember).getSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, siteMember.getUsername(), moderatedSite.getTitle())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } +} diff --git a/e2e-test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestCoreTests.java deleted file mode 100644 index fdfcad18d..000000000 --- a/e2e-test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestCoreTests.java +++ /dev/null @@ -1,144 +0,0 @@ -package org.alfresco.rest.sites.membershipRequests; - -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -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.report.Bug; -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; - -/** - * Tests for getSiteMembershipRequests (get /people/{personId}/site-membership-requests) RestAPI call - * - * @author Bogdan Bocancea - */ - -public class GetSiteMembershipRequestCoreTests extends RestTest -{ - UserModel userModel; - SiteModel siteModel; - UserModel newMember; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createModeratedRandomSite(); - newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(siteModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify contributor user fails to get all site membership requests of a specific person with Rest API when the authentication fails (401)") - public void unauthorizedContributorUserFailsToGetSiteMembershipRequests() throws Exception - { - UserModel contributor = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(contributor, siteModel, UserRole.SiteContributor); - contributor.setPassword("newpassword"); - restClient.authenticateUser(contributor).withCoreAPI().usingUser(newMember).getSiteMembershipRequest(siteModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError().containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify collaborator user fails to get all site membership requests of a specific person with Rest API when the authentication fails (401)") - @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void unauthorizedCollaboratorUserFailsToGetSiteMembershipRequests() throws Exception - { - UserModel collaborator = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(collaborator, siteModel, UserRole.SiteContributor); - collaborator.setPassword("newpassword"); - restClient.authenticateUser(collaborator).withCoreAPI().usingUser(newMember).getSiteMembershipRequest(siteModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify consumer user fails to get all site membership requests of a specific person with Rest API when the authentication fails (401)") - @Bug(id = "MNT-16904", description = "It fails only on environment with tenants") - public void unauthorizedConsumerUserFailsToGetSiteMembershipRequests() throws Exception - { - UserModel consumer = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(consumer, siteModel, UserRole.SiteContributor); - consumer.setPassword("newpassword"); - restClient.authenticateUser(consumer).withCoreAPI().usingUser(newMember).getSiteMembershipRequest(siteModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify a user gets all its own site membership requests using '-me-' with Rest API and response is successful (200)") - public void usingMeGetSiteMembershipRequestsWithSuccess() throws Exception - { - restClient.authenticateUser(newMember).withCoreAPI().usingMe().getSiteMembershipRequest(siteModel).assertThat().field("id").is(siteModel.getId()); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site manager can't get site membership requests for inexistent user and response is not found (404)") - public void siteManagerCantGetSiteMembershipRequestsInexistentUser() throws Exception - { - restClient.authenticateUser(newMember).withCoreAPI().usingUser(UserModel.getRandomUserModel()).getSiteMembershipRequest(siteModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user can get site membership requests on site with no requests and response is successful (200)") - public void userCantGetSiteMembershipRequestsWithNoRequests() throws Exception - { - UserModel noRequestUser = dataUser.createRandomTestUser(); - restClient.authenticateUser(noRequestUser).withCoreAPI().usingMe().getSiteMembershipRequest(siteModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, noRequestUser.getUsername(), siteModel.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site manager can't get site membership requests on public site and response is not found (404)") - public void siteManagerCantGetPublicSiteMembershipRequests() throws Exception - { - UserModel publicUser = dataUser.createRandomTestUser(); - SiteModel publicSite = dataSite.usingUser(userModel).createPublicRandomSite(); - restClient.authenticateUser(publicUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(publicSite); - restClient.authenticateUser(userModel).withCoreAPI().usingUser(publicUser).getSiteMembershipRequest(publicSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, publicUser.getUsername(), publicSite.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site manager can't get site membership requests on private site and response is not found (404)") - public void siteManagerCantGetPrivateSiteMembershipRequests() throws Exception - { - UserModel privateUser = dataUser.createRandomTestUser(); - SiteModel privateSite = dataSite.usingUser(userModel).createPrivateRandomSite(); - restClient.authenticateUser(privateUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(privateSite); - restClient.authenticateUser(userModel).withCoreAPI().usingUser(privateUser).getSiteMembershipRequest(privateSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, privateUser.getUsername(), privateSite.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site manager can't get site membership requests for inexistent site and response is not found (404)") - public void siteManagerCantGetSiteMembershipRequestsForInexistentSite() throws Exception - { - SiteModel inexistentSite = SiteModel.getRandomSiteModel(); - restClient.authenticateUser(userModel).withCoreAPI().usingMe().getSiteMembershipRequest(inexistentSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, userModel.getUsername(), inexistentSite.getId())); - } -} diff --git a/e2e-test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestFullTests.java b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestFullTests.java deleted file mode 100644 index f4c4102d7..000000000 --- a/e2e-test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestFullTests.java +++ /dev/null @@ -1,285 +0,0 @@ -package org.alfresco.rest.sites.membershipRequests; - -import org.alfresco.dataprep.SiteService.Visibility; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestSiteMembershipRequestModel; -import org.alfresco.rest.model.RestTaskModel; -import org.alfresco.utility.constants.UserRole; -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.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class GetSiteMembershipRequestFullTests extends RestTest -{ - UserModel userModel, newMember, adminUser, userCollaborator, userConsumer, adminTenantUser, adminTenantUser2, - tenantUser, tenantUserAssignee; - SiteModel moderatedSite, secondModeratedSite; - RestSiteMembershipRequestModel returnedModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userModel = dataUser.createRandomTestUser(); - moderatedSite = dataSite.usingUser(userModel).createModeratedRandomSite(); - newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify site manager can get site membership requests on moderated site and response is successful (200)") - public void siteManagerCanGetModeratedSiteMembershipRequests() throws Exception - { - UserModel moderatedUser = dataUser.createRandomTestUser(); - SiteModel moderatedSite = dataSite.usingUser(userModel).createModeratedRandomSite(); - restClient.authenticateUser(moderatedUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - returnedModel = restClient.authenticateUser(userModel).withCoreAPI().usingUser(moderatedUser).getSiteMembershipRequest(moderatedSite); - - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedModel.assertThat().field("id").is(moderatedSite.getId()) - .and().field("message").is("Please accept me") - .and().field("site.title").is(moderatedSite.getTitle()) - .and().field("site.visibility").is(Visibility.MODERATED.toString()) - .and().field("site.guid").isNotEmpty() - .and().field("site.description").is(moderatedSite.getDescription()) - .and().field("site.preset").is("site-dashboard"); - } - - @Bug(id = "ACE-2413") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify if person ID field is empty user can't get site membership requests on moderated site and response is not found (400)") - public void emptyPersonIdCantGetModeratedSiteMembershipRequests() throws Exception - { - UserModel emptyUser = new UserModel("", "password"); - restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - restClient.authenticateUser(userModel).withCoreAPI().usingUser(emptyUser).getSiteMembershipRequest(moderatedSite); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .containsSummary(String.format("The entity with id: personId is null. was not found")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Approve site membership request then verify get site membership requests - response is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - public void approveRequestThenGetSiteMembershipRequest() throws JsonToModelConversionException, DataPreparationException, Exception - { - UserModel userWithApprovedRequests = dataUser.createRandomTestUser(); - restClient.authenticateUser(userWithApprovedRequests).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestTaskModel taskModel = restClient.authenticateUser(userWithApprovedRequests).withWorkflowAPI().getTasks().getTaskModelByDescription(moderatedSite); - workflow.approveSiteMembershipRequest(userModel.getUsername(), userModel.getPassword(), taskModel.getId(), true, "Approve"); - - returnedModel = restClient.authenticateUser(userWithApprovedRequests).withCoreAPI().usingMe().getSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, userWithApprovedRequests.getUsername(), moderatedSite.getId())) - .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Reject site membership request then verify get site membership requests - response is 404") - public void rejectRequestThenGetSiteMembershipRequest() throws Exception - { - UserModel userWithRejectedRequests = dataUser.createRandomTestUser(); - restClient.authenticateUser(userWithRejectedRequests).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestTaskModel taskModel = restClient.authenticateUser(userWithRejectedRequests).withWorkflowAPI().getTasks().getTaskModelByDescription(moderatedSite); - workflow.approveSiteMembershipRequest(userModel.getUsername(), userModel.getPassword(), taskModel.getId(), false, "Rejected"); - - returnedModel = restClient.authenticateUser(userWithRejectedRequests).withCoreAPI().usingMe().getSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, userWithRejectedRequests.getUsername(), moderatedSite.getId())) - .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify entry details for get site favorite response with Rest API") - public void checkResponseSchemaForGetSiteMembershipRequest() throws Exception - { - dataUser.usingUser(userModel).addUserToSite(newMember, moderatedSite, UserRole.SiteContributor); - returnedModel = restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().getSiteMembershipRequest(moderatedSite); - - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedModel.assertThat().field("id").is(moderatedSite.getId()) - .and().field("message").is("Please accept me") - .and().field("site.title").is(moderatedSite.getTitle()) - .and().field("site.visibility").is(Visibility.MODERATED.toString()) - .and().field("site.guid").isNotEmpty() - .and().field("site.description").is(moderatedSite.getDescription()) - .and().field("site.preset").is("site-dashboard") - .and().field("site.role").is("SiteContributor"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify that getFavoriteSites request applies valid properties param") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - public void getSiteMembershipRequestWithValidPropertiesParam() throws Exception - { - RestSiteMembershipRequestModel returnedModel = restClient.authenticateUser(newMember).withParams("properties=message").withCoreAPI().usingAuthUser() - .getSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedModel.assertThat().fieldsCount().is(1).assertThat().field("message").isNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify that getFavoriteSites request returns status 200 when using valid parameters") - public void getSiteMembershipRequestUsingParameters() throws Exception - { - RestSiteMembershipRequestModel returnedModel = restClient.withParams("message=Please accept me") - .authenticateUser(newMember).withCoreAPI().usingMe() - .getSiteMembershipRequest(moderatedSite); - - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedModel.assertThat().field("id").is(moderatedSite.getId()).and().field("site.title").is(moderatedSite.getTitle()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify user doesn't have permission to get site membership request of admin with membership request with Rest API and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - public void userIsNotAbleToGetSiteMembershipRequestOfAdminWithRequest() throws JsonToModelConversionException, Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - - returnedModel = restClient.authenticateUser(adminUser).withCoreAPI().usingUser(newMember).getSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedModel.assertThat().field("id").is(moderatedSite.getId()) - .and().field("message").is("Please accept me") - .and().field("site.title").is(moderatedSite.getTitle()) - .and().field("site.visibility").is(Visibility.MODERATED.toString()) - .and().field("site.guid").isNotEmpty() - .and().field("site.description").is(moderatedSite.getDescription()) - .and().field("site.preset").is("site-dashboard"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify user doesn't have permission to get site membership request of admin without membership request with Rest API and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - public void userIsNotAbleToGetSiteMembershipRequestOfAdminWithoutRequest() throws JsonToModelConversionException, Exception - { - SiteModel moderatedSite = dataSite.usingUser(userModel).createModeratedRandomSite(); - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - - returnedModel = restClient.authenticateUser(newMember).withCoreAPI().usingUser(adminUser).getSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, adminUser.getUsername(), moderatedSite.getId())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER).stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify admin user doesn't have permission to get site membership request of another user with Rest API and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - public void adminIsNotAbleToGetSiteMembershipRequestOfUser() throws JsonToModelConversionException, Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - - returnedModel = restClient.authenticateUser(newMember).withCoreAPI().usingUser(adminUser).getSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, adminUser.getUsername(), moderatedSite.getId())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify admin user doesn't have permission to get site membership request of another user with Rest API and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - public void userIsNotAbleToGetSiteMembershipRequestOfAnotherUser() throws JsonToModelConversionException, Exception - { - userCollaborator = dataUser.createRandomTestUser(); - userConsumer = dataUser.createRandomTestUser(); - restClient.authenticateUser(userConsumer).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - dataUser.usingUser(userModel).addUserToSite(userConsumer, moderatedSite, UserRole.SiteConsumer); - restClient.authenticateUser(userCollaborator).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - dataUser.usingUser(userModel).addUserToSite(userCollaborator, moderatedSite, UserRole.SiteCollaborator); - - returnedModel = restClient.authenticateUser(userCollaborator).withCoreAPI().usingUser(userConsumer).getSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, userConsumer.getUsername(), moderatedSite.getId())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Add process item using by the admin in same network.") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL, TestGroup.NETWORKS }) - public void getSiteMembershipRequestByAdminSameNetwork() throws Exception - { - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser); - tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - - moderatedSite = dataSite.usingUser(adminTenantUser).createModeratedRandomSite(); - restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - - returnedModel = restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().getSiteMembershipRequest(moderatedSite); - - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedModel.assertThat().field("id").is(moderatedSite.getId()) - .and().field("message").is("Please accept me") - .and().field("site.title").is(moderatedSite.getTitle()) - .and().field("site.visibility").is(Visibility.MODERATED.toString()) - .and().field("site.guid").isNotEmpty() - .and().field("site.description").is(moderatedSite.getDescription()) - .and().field("site.preset").is("site-dashboard"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Add process item using by admin in other network.") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL, TestGroup.NETWORKS }) - public void getSiteMembershipRequestByAdminInOtherNetwork() throws Exception - { - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser); - tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); - - adminTenantUser2 = UserModel.getAdminTenantUser(); - restClient.usingTenant().createTenant(adminTenantUser2); - moderatedSite = dataSite.usingUser(adminTenantUser2).createModeratedRandomSite(); - - restClient.authenticateUser(adminTenantUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - returnedModel = restClient.authenticateUser(adminTenantUser2).withCoreAPI().usingAuthUser().getSiteMembershipRequest(moderatedSite); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, adminTenantUser2.getUsername().toLowerCase(), moderatedSite.getId())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - -} diff --git a/e2e-test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestSanityTests.java deleted file mode 100644 index 5b38be20a..000000000 --- a/e2e-test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestSanityTests.java +++ /dev/null @@ -1,119 +0,0 @@ -package org.alfresco.rest.sites.membershipRequests; - -import org.alfresco.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataSite; -import org.alfresco.utility.data.DataUser; -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.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class GetSiteMembershipRequestSanityTests extends RestTest -{ - @Autowired - DataUser dataUser; - - @Autowired - DataSite dataSite; - - private SiteModel siteModel; - - private ListUserWithRoles usersWithRoles; - - private UserModel adminUser; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws DataPreparationException - { - adminUser = dataUser.getAdminUser(); - siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site manager is able to retrieve site membership request") - @Bug(id = "MNT-16557") - public void siteManagerIsAbleToRetrieveSiteMembershipRequest() throws JsonToModelConversionException, Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingUser(newMember) - .addSiteMembershipRequest(siteModel); - - restClient.withCoreAPI().usingUser(newMember).getSiteMembershipRequest(siteModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site collaborator is able to retrieve site membership request") - @Bug(id = "MNT-16557") - public void siteCollaboratorIsAbleToRetrieveSiteMembershipRequest() throws JsonToModelConversionException, Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingUser(newMember) - .addSiteMembershipRequest(siteModel); - - restClient.withCoreAPI().usingUser(newMember).getSiteMembershipRequest(siteModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site contributor is able to retrieve site membership request") - @Bug(id = "MNT-16557") - public void siteContributorIsAbleToRetrieveSiteMembershipRequest() throws JsonToModelConversionException, Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingUser(newMember) - .addSiteMembershipRequest(siteModel); - - restClient.withCoreAPI().usingUser(newMember).getSiteMembershipRequest(siteModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site consumer is able to retrieve site membership request") - @Bug(id = "MNT-16557") - public void siteConsumerIsAbleToRetrieveSiteMembershipRequest() throws JsonToModelConversionException, Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingUser(newMember) - .addSiteMembershipRequest(siteModel); - - restClient.withCoreAPI().usingUser(newMember).getSiteMembershipRequest(siteModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify admin user is able to retrieve site membership request") - @Bug(id = "MNT-16557") - public void adminIsAbleToRetrieveSiteMembershipRequest() throws JsonToModelConversionException, Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(adminUser).withCoreAPI().usingUser(newMember).addSiteMembershipRequest(siteModel); - - restClient.withCoreAPI().usingUser(newMember).getSiteMembershipRequest(siteModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to retrieve site membership request") - @Bug(id = "MNT-16557") - public void unauthenticatedUserIsNotAbleToRetrieveSiteMembershipRequest() throws JsonToModelConversionException, Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(new UserModel("random user", "random password")).withCoreAPI().usingUser(newMember).addSiteMembershipRequest(siteModel); - - restClient.withCoreAPI().usingUser(newMember).getSiteMembershipRequest(siteModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString()); - } -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestTests.java b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestTests.java new file mode 100644 index 000000000..72b9fe4ce --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestTests.java @@ -0,0 +1,380 @@ +package org.alfresco.rest.sites.membershipRequests; + +import org.alfresco.dataprep.SiteService; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestSiteMembershipRequestModel; +import org.alfresco.rest.model.RestTaskModel; +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.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class GetSiteMembershipRequestTests extends RestTest +{ + private SiteModel publicSite, moderatedSite; + private ListUserWithRoles usersWithRoles; + private UserModel adminUser, siteCreator, newMember; + private RestSiteMembershipRequestModel returnedModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + publicSite = dataSite.usingUser(adminUser).createPublicRandomSite(); + + siteCreator = dataUser.createRandomTestUser(); + moderatedSite = dataSite.usingUser(siteCreator).createModeratedRandomSite(); + + usersWithRoles = dataUser.addUsersWithRolesToSite(moderatedSite, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + + newMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site manager is able to retrieve site membership request") + public void siteManagerIsAbleToRetrieveSiteMembershipRequest() throws Exception + { + returnedModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingUser(newMember).getSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedModel.assertThat().field("id").is(moderatedSite.getId()) + .and().field("message").is("Please accept me") + .and().field("site.title").is(moderatedSite.getTitle()) + .and().field("site.visibility").is(SiteService.Visibility.MODERATED.toString()) + .and().field("site.guid").isNotEmpty() + .and().field("site.description").is(moderatedSite.getDescription()) + .and().field("site.preset").is("site-dashboard"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site collaborator is able to retrieve site membership request") + public void siteCollaboratorIsNotAbleToRetrieveSiteMembershipRequest() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingUser(newMember).getSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site contributor is able to retrieve site membership request") + public void siteContributorIsNotAbleToRetrieveSiteMembershipRequest() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingUser(newMember).getSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site consumer is able to retrieve site membership request") + public void siteConsumerIsNotAbleToRetrieveSiteMembershipRequest() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingUser(newMember).getSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin user is able to retrieve site membership request") + public void adminIsAbleToRetrieveSiteMembershipRequest() throws Exception + { + returnedModel = restClient.authenticateUser(adminUser).withCoreAPI().usingUser(newMember).getSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedModel.assertThat().field("id").is(moderatedSite.getId()) + .and().field("message").is("Please accept me") + .and().field("site.title").is(moderatedSite.getTitle()) + .and().field("site.visibility").is(SiteService.Visibility.MODERATED.toString()) + .and().field("site.guid").isNotEmpty() + .and().field("site.description").is(moderatedSite.getDescription()) + .and().field("site.preset").is("site-dashboard"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, + description = "Verify user fails to get all site membership requests of a specific person with Rest API when the authentication fails (401)") + public void unauthorizedUserFailsToGetSiteMembershipRequests() throws Exception + { + UserModel manager = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(siteCreator).addUserToSite(manager, moderatedSite, UserRole.SiteManager); + manager.setPassword("newpassword"); + restClient.authenticateUser(manager).withCoreAPI().usingUser(newMember).getSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError().containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify a user gets all its own site membership requests using '-me-' with Rest API and response is successful (200)") + public void usingMeGetSiteMembershipRequestsWithSuccess() throws Exception + { + restClient.authenticateUser(newMember).withCoreAPI().usingMe().getSiteMembershipRequest(moderatedSite).assertThat().field("id").is(moderatedSite.getId()); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site manager can't get site membership requests for inexistent user and response is not found (404)") + public void siteManagerCantGetSiteMembershipRequestsInexistentUser() throws Exception + { + restClient.authenticateUser(newMember).withCoreAPI().usingUser(UserModel.getRandomUserModel()).getSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user can get site membership requests on site with no requests and response is successful (200)") + public void userWithNoRequestsCantGetSiteMembershipRequests() throws Exception + { + UserModel noRequestUser = dataUser.createRandomTestUser(); + restClient.authenticateUser(noRequestUser).withCoreAPI().usingMe().getSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, noRequestUser.getUsername(), moderatedSite.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site manager can't get site membership requests on public site and response is not found (404)") + public void siteManagerCantGetPublicSiteMembershipRequests() throws Exception + { + UserModel publicUser = dataUser.createRandomTestUser(); + restClient.authenticateUser(publicUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(publicSite); + restClient.authenticateUser(adminUser).withCoreAPI() + .usingUser(publicUser).getSiteMembershipRequest(publicSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, publicUser.getUsername(), publicSite.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site manager can't get site membership requests on private site and response is not found (404)") + public void siteManagerCantGetPrivateSiteMembershipRequests() throws Exception + { + UserModel privateUser = dataUser.createRandomTestUser(); + SiteModel privateSite = dataSite.usingUser(siteCreator).createPrivateRandomSite(); + restClient.authenticateUser(privateUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(privateSite); + restClient.authenticateUser(siteCreator).withCoreAPI().usingUser(privateUser).getSiteMembershipRequest(privateSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, privateUser.getUsername(), privateSite.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site manager can't get site membership requests for inexistent site and response is not found (404)") + public void siteManagerCantGetSiteMembershipRequestsForInexistentSite() throws Exception + { + SiteModel inexistentSite = SiteModel.getRandomSiteModel(); + restClient.authenticateUser(siteCreator).withCoreAPI().usingMe().getSiteMembershipRequest(inexistentSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, siteCreator.getUsername(), inexistentSite.getId())); + } + + @Bug(id = "ACE-2413") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify if person ID field is empty user can't get site membership requests on moderated site and response is not found (400)") + public void emptyPersonIdCantGetModeratedSiteMembershipRequests() throws Exception + { + UserModel emptyUser = new UserModel("", "password"); + restClient.authenticateUser(siteCreator).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + restClient.authenticateUser(siteCreator).withCoreAPI().usingUser(emptyUser).getSiteMembershipRequest(moderatedSite); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .containsSummary(String.format("The entity with id: personId is null. was not found")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Approve site membership request then verify get site membership requests - response is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void approveRequestThenGetSiteMembershipRequest() throws Exception + { + UserModel userWithApprovedRequests = dataUser.createRandomTestUser(); + restClient.authenticateUser(userWithApprovedRequests).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestTaskModel taskModel = restClient.authenticateUser(userWithApprovedRequests).withWorkflowAPI().getTasks().getTaskModelByDescription(moderatedSite); + workflow.approveSiteMembershipRequest(siteCreator.getUsername(), siteCreator.getPassword(), taskModel.getId(), true, "Approve"); + + returnedModel = restClient.authenticateUser(userWithApprovedRequests).withCoreAPI().usingMe().getSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, userWithApprovedRequests.getUsername(), moderatedSite.getId())) + .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Reject site membership request then verify get site membership requests - response is 404") + public void rejectRequestThenGetSiteMembershipRequest() throws Exception + { + UserModel userWithRejectedRequests = dataUser.createRandomTestUser(); + restClient.authenticateUser(userWithRejectedRequests).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestTaskModel taskModel = restClient.authenticateUser(userWithRejectedRequests).withWorkflowAPI().getTasks().getTaskModelByDescription(moderatedSite); + workflow.approveSiteMembershipRequest(siteCreator.getUsername(), siteCreator.getPassword(), taskModel.getId(), false, "Rejected"); + + returnedModel = restClient.authenticateUser(userWithRejectedRequests).withCoreAPI().usingMe().getSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, userWithRejectedRequests.getUsername(), moderatedSite.getId())) + .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @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 site favorite response with Rest API") + public void checkResponseSchemaForGetSiteMembershipRequest() throws Exception + { + dataUser.usingUser(siteCreator).addUserToSite(newMember, moderatedSite, UserRole.SiteContributor); + returnedModel = restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().getSiteMembershipRequest(moderatedSite); + + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedModel.assertThat().field("id").is(moderatedSite.getId()) + .and().field("message").is("Please accept me") + .and().field("site.title").is(moderatedSite.getTitle()) + .and().field("site.visibility").is(SiteService.Visibility.MODERATED.toString()) + .and().field("site.guid").isNotEmpty() + .and().field("site.description").is(moderatedSite.getDescription()) + .and().field("site.preset").is("site-dashboard") + .and().field("site.role").is("SiteContributor"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify that getFavoriteSites request applies valid properties param") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void getSiteMembershipRequestWithValidPropertiesParam() throws Exception + { + RestSiteMembershipRequestModel returnedModel = restClient.authenticateUser(newMember).withParams("properties=message").withCoreAPI().usingAuthUser() + .getSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedModel.assertThat().fieldsCount().is(1).assertThat().field("message").isNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify that getFavoriteSites request returns status 200 when using valid parameters") + public void getSiteMembershipRequestUsingParameters() throws Exception + { + RestSiteMembershipRequestModel returnedModel = restClient.withParams("message=Please accept me") + .authenticateUser(newMember).withCoreAPI().usingMe() + .getSiteMembershipRequest(moderatedSite); + + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedModel.assertThat().field("id").is(moderatedSite.getId()).and().field("site.title").is(moderatedSite.getTitle()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify user doesn't have permission to get site membership request of admin without membership request with Rest API and status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void userIsNotAbleToGetSiteMembershipRequestOfAdminWithoutRequest() throws Exception + { + returnedModel = restClient.authenticateUser(newMember).withCoreAPI().usingUser(adminUser).getSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, adminUser.getUsername(), moderatedSite.getId())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER).stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify user doesn't have permission to get site membership request of admin with requests with Rest API and status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void userIsNotAbleToGetSiteMembershipRequestOfAdminWithRequest() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + + returnedModel = restClient.authenticateUser(newMember).withCoreAPI().usingUser(adminUser).getSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, adminUser.getUsername(), moderatedSite.getId())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify admin user doesn't have permission to get site membership request of another user with Rest API and status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void userIsNotAbleToGetSiteMembershipRequestOfAnotherUser() throws Exception + { + UserModel userCollaborator = dataUser.createRandomTestUser(); + UserModel userConsumer = dataUser.createRandomTestUser(); + restClient.authenticateUser(userConsumer).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + dataUser.usingUser(siteCreator).addUserToSite(userConsumer, moderatedSite, UserRole.SiteConsumer); + restClient.authenticateUser(userCollaborator).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + dataUser.usingUser(siteCreator).addUserToSite(userCollaborator, moderatedSite, UserRole.SiteCollaborator); + + returnedModel = restClient.authenticateUser(userCollaborator).withCoreAPI().usingUser(userConsumer).getSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, userConsumer.getUsername(), moderatedSite.getId())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Add process item using by the admin in same network.") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void getSiteMembershipRequestByAdminSameNetwork() throws Exception + { + UserModel adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser); + UserModel tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + + moderatedSite = dataSite.usingUser(adminTenantUser).createModeratedRandomSite(); + restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + + returnedModel = restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().getSiteMembershipRequest(moderatedSite); + + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedModel.assertThat().field("id").is(moderatedSite.getId()) + .and().field("message").is("Please accept me") + .and().field("site.title").is(moderatedSite.getTitle()) + .and().field("site.visibility").is(SiteService.Visibility.MODERATED.toString()) + .and().field("site.guid").isNotEmpty() + .and().field("site.description").is(moderatedSite.getDescription()) + .and().field("site.preset").is("site-dashboard"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Add process item using by admin in other network.") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void getSiteMembershipRequestByAdminInOtherNetwork() throws Exception + { + UserModel adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser); + + UserModel adminTenantUser2 = UserModel.getAdminTenantUser(); + restClient.usingTenant().createTenant(adminTenantUser2); + moderatedSite = dataSite.usingUser(adminTenantUser2).createModeratedRandomSite(); + + restClient.authenticateUser(adminTenantUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + returnedModel = restClient.authenticateUser(adminTenantUser2).withCoreAPI().usingAuthUser().getSiteMembershipRequest(moderatedSite); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, adminTenantUser2.getUsername().toLowerCase(), moderatedSite.getId())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } +} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestsCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestsCoreTests.java deleted file mode 100644 index c99d29a58..000000000 --- a/e2e-test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestsCoreTests.java +++ /dev/null @@ -1,167 +0,0 @@ -package org.alfresco.rest.sites.membershipRequests; - -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestSiteMembershipRequestModelsCollection; -import org.alfresco.rest.model.RestTaskModel; -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; - -/** - * Tests for getSiteMembershipRequests (get - * /people/{personId}/site-membership-requests) Core-RestAPI call - * - * @author Andrei Rusu - */ - -public class GetSiteMembershipRequestsCoreTests extends RestTest -{ - UserModel newMember, newMember1, meUser, adminUser; - SiteModel moderatedSite, publicSite; - RestSiteMembershipRequestModelsCollection returnedCollection; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - moderatedSite = dataSite.usingAdmin().createModeratedRandomSite(); - publicSite = dataSite.usingAdmin().createPublicRandomSite(); - newMember = dataUser.createRandomTestUser(); - - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, - description = "Verify that for invalid maxItems parameter status code returned is 400.") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - public void checkInvalidMaxItemsStatusCode() throws Exception - { - restClient.authenticateUser(adminUser).withParams("maxItems=AB") - .withCoreAPI().usingUser(newMember).getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "AB")); - - restClient.authenticateUser(adminUser).withParams("maxItems=0") - .withCoreAPI().usingUser(newMember).getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, - description = "Verify that for invalid skipCount parameter status code returned is 400.") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - public void checkInvalidSkipCountStatusCode() throws Exception - { - restClient.authenticateUser(adminUser).withParams("skipCount=AB") - .withCoreAPI().usingUser(newMember).getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "AB")); - - restClient.authenticateUser(adminUser).withParams("skipCount=-1") - .withCoreAPI().usingUser(newMember).getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, - description = "Verify that if personId does not exist status code returned is 404.") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - public void ifPersonIdDoesNotExist() throws Exception - { - UserModel nonexistentUser = dataUser.createRandomTestUser(); - nonexistentUser.setUsername("nonexistent"); - - restClient.authenticateUser(adminUser).withCoreAPI().usingUser(nonexistentUser).getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "nonexistent")) - .statusCodeIs(HttpStatus.NOT_FOUND) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, - description = "Specify -me- string in place of for request.") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - public void replacePersonIdWithMeRequest() throws Exception - { - meUser = dataUser.createRandomTestUser(); - restClient.authenticateUser(meUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - returnedCollection = restClient.authenticateUser(meUser).withCoreAPI().usingMe().getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat().entriesListContains("id", moderatedSite.getId()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, - description = "Verify that if empty personId is used status code returned is 404.") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - public void useEmptyPersonId() throws Exception - { - UserModel emptyNameMember = dataUser.createRandomTestUser(); - emptyNameMember.setUsername(" "); - - restClient.authenticateUser(adminUser).withCoreAPI().usingUser(emptyNameMember).getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, emptyNameMember.getUsername())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, - description = "Get site membership requests to a public site.") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - public void getRequestsToPublicSite() throws Exception - { - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(publicSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedCollection = restClient.withCoreAPI().usingAuthUser().getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat().entriesListDoesNotContain("id", publicSite.getId()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, - description = "Get site membership requests to a moderated site.") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - public void getRequestsToModeratedSite() throws Exception - { - newMember1 = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember1).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - returnedCollection = restClient.authenticateUser(newMember1).withCoreAPI().usingUser(newMember1).getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat().entriesListContains("id", moderatedSite.getId()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, - description = "Approve request then get requests.") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - public void approveRequestThenGetRequests() throws Exception - { - UserModel siteManager = dataUser.createRandomTestUser(); - - moderatedSite = dataSite.usingUser(siteManager).createModeratedRandomSite(); - restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestTaskModel taskModel = restClient.authenticateUser(newMember).withWorkflowAPI().getTasks().getTaskModelByDescription(moderatedSite); - workflow.approveSiteMembershipRequest(siteManager.getUsername(), siteManager.getPassword(), taskModel.getId(), true, "Approve"); - - returnedCollection = restClient.authenticateUser(newMember).withCoreAPI().usingMe().getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat().entriesListDoesNotContain("id", moderatedSite.getId()); - } - -} diff --git a/e2e-test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestsFullTests.java b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestsFullTests.java deleted file mode 100644 index d2cb8c720..000000000 --- a/e2e-test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestsFullTests.java +++ /dev/null @@ -1,172 +0,0 @@ -package org.alfresco.rest.sites.membershipRequests; - -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestSiteMembershipRequestModel; -import org.alfresco.rest.model.RestSiteMembershipRequestModelsCollection; -import org.alfresco.rest.model.RestTaskModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Created by Claudia Agache on 1/10/2017. - */ -public class GetSiteMembershipRequestsFullTests extends RestTest -{ - UserModel siteManager, newMember, adminUser, regularUser; - SiteModel moderatedSite1, moderatedSite2, publicSite, privateSite; - RestSiteMembershipRequestModelsCollection siteMembershipRequests; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - siteManager = dataUser.createRandomTestUser(); - publicSite = dataSite.usingUser(siteManager).createPublicRandomSite(); - moderatedSite1 = dataSite.usingUser(siteManager).createModeratedRandomSite(); - moderatedSite2 = dataSite.usingUser(siteManager).createModeratedRandomSite(); - privateSite = dataSite.usingUser(siteManager).createPrivateRandomSite(); - - adminUser = dataUser.getAdminUser(); - newMember = dataUser.createRandomTestUser(); - regularUser = dataUser.createRandomTestUser(); - - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite1); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite1); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, - description = "Verify admin user gets all its own site membership requests with Rest API and response is successful (200)") - public void adminGetsItsOwnSiteMembershipRequestsWithSuccess() throws Exception - { - siteMembershipRequests = restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.OK); - siteMembershipRequests.assertThat().entriesListContains("id", moderatedSite1.getId()) - .assertThat().entriesListContains("id", moderatedSite2.getId()); - } - - @Bug(id = "MNT-16557") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, - description = "Verify regular user fails to get all site membership requests of another user with Rest API (403)") - public void regularUserFailsToGetSiteMembershipRequestsOfAnotherUser() throws Exception - { - restClient.authenticateUser(regularUser).withCoreAPI() - .usingUser(newMember).getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Bug(id = "MNT-16557") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, - description = "Verify regular user fails to get all site membership requests of admin with Rest API (403)") - public void regularUserFailsToGetSiteMembershipRequestsOfAdmin() throws Exception - { - restClient.authenticateUser(regularUser).withCoreAPI() - .usingUser(adminUser).getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, - description = "Verify regular user is able to get his site membership requests with, but skip the first one") - public void getSiteMembershipRequestsButSkipTheFirstOne() throws Exception - { - siteMembershipRequests = restClient.authenticateUser(newMember).withParams("orderBy=id ASC").withCoreAPI() - .usingMe().getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.OK); - siteMembershipRequests.assertThat().entriesListContains("id", moderatedSite1.getId()) - .assertThat().entriesListContains("id", moderatedSite2.getId()); - - RestSiteMembershipRequestModel firstSiteMembershipRequest = siteMembershipRequests.getEntries().get(0).onModel(); - RestSiteMembershipRequestModel secondSiteMembershipRequest = siteMembershipRequests.getEntries().get(1).onModel(); - - siteMembershipRequests = restClient.authenticateUser(newMember).withParams("orderBy=id ASC&skipCount=1").withCoreAPI() - .usingMe().getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.OK); - siteMembershipRequests.assertThat().entriesListDoesNotContain("id", firstSiteMembershipRequest.getId()) - .assertThat().entriesListContains("id", secondSiteMembershipRequest.getId()) - .assertThat().entriesListContains("id", secondSiteMembershipRequest.getSite().getId()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, - description = "Verify regular user is able to get his site membership requests with higher skipCount than number of requests") - public void getSiteMembershipRequestsWithHighSkipCount() throws Exception - { - siteMembershipRequests = restClient.authenticateUser(newMember).withParams("skipCount=3").withCoreAPI() - .usingMe().getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.OK); - siteMembershipRequests.assertThat().entriesListIsEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, - description = "Verify get site membership requests returns an empty list where there are no requests") - public void getSiteMembershipRequestsWhereThereAreNoRequests() throws Exception - { - siteMembershipRequests = restClient.authenticateUser(regularUser).withCoreAPI().usingMe().getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.OK); - siteMembershipRequests.assertThat().entriesListIsEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, - description = "Reject request then get site membership requests.") - public void rejectRequestThenGetSiteMembershipRequests() throws Exception - { - UserModel userWithRejectedRequests = dataUser.createRandomTestUser(); - - restClient.authenticateUser(userWithRejectedRequests).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite1); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestTaskModel taskModel = restClient.authenticateUser(userWithRejectedRequests).withWorkflowAPI().getTasks().getTaskModelByDescription(moderatedSite1); - workflow.approveSiteMembershipRequest(siteManager.getUsername(), siteManager.getPassword(), taskModel.getId(), false, "Rejected"); - - siteMembershipRequests = restClient.authenticateUser(userWithRejectedRequests).withCoreAPI().usingMe().getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.OK); - siteMembershipRequests.assertThat().entriesListDoesNotContain("id", moderatedSite1.getId()) - .assertThat().entriesListContains("id", moderatedSite2.getId()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, - description = "Check get site membership requests when properties parameter is used") - public void getSiteMembershipRequestsWithProperties() throws Exception - { - siteMembershipRequests = restClient.authenticateUser(newMember).withParams("properties=id") - .withCoreAPI().usingAuthUser().getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.OK); - siteMembershipRequests.assertThat().entriesListContains("id", moderatedSite1.getId()) - .assertThat().entriesListContains("id", moderatedSite2.getId()); - RestSiteMembershipRequestModel siteMembershipRequest = siteMembershipRequests.getOneRandomEntry().onModel(); - siteMembershipRequest.assertThat().fieldsCount().is(1); - } - -} diff --git a/e2e-test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestsSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestsSanityTests.java deleted file mode 100644 index cde5142ad..000000000 --- a/e2e-test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestsSanityTests.java +++ /dev/null @@ -1,121 +0,0 @@ -package org.alfresco.rest.sites.membershipRequests; - -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestSiteMembershipRequestModelsCollection; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Tests for getSiteMembershipRequests (get /people/{personId}/site-membership-requests) RestAPI call - * - * @author Cristina Axinte - */ - -public class GetSiteMembershipRequestsSanityTests extends RestTest -{ - UserModel siteManager, newMember; - DataUser.ListUserWithRoles usersWithRoles; - SiteModel moderatedSite; - RestSiteMembershipRequestModelsCollection siteMembershipRequests; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - siteManager = dataUser.createRandomTestUser(); - moderatedSite = dataSite.usingUser(siteManager).createModeratedRandomSite(); - newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - usersWithRoles = dataUser.addUsersWithRolesToSite(moderatedSite, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @Bug(id = "MNT-16557") - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user gets all site membership requests of a specific person with Rest API and response is successful (200)") - public void managerUserGetsSiteMembershipRequestsWithSuccess() throws Exception - { - siteMembershipRequests = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI() - .usingUser(newMember).getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.OK); - siteMembershipRequests.assertThat().entriesListIsNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @Bug(id = "MNT-16557") - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify collaborator user fails to get all site membership requests of another user with Rest API (403)") - public void collaboratorUserFailsToGetSiteMembershipRequestsOfAnotherUser() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI() - .usingUser(newMember).getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @Bug(id = "MNT-16557") - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify contributor user fails to get all site membership requests of another user with Rest API (403)") - public void contributorUserFailsToGetSiteMembershipRequestsOfAnotherUser() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI() - .usingUser(newMember).getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @Bug(id = "MNT-16557") - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify consumer user fails to get all site membership requests of another user with Rest API (403)") - public void consumerUserFailsToGetSiteMembershipRequestsOfAnotherUser() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingUser(newMember).getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @Bug(id = "MNT-16557") - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify admin user gets all site membership requests of a specific person with Rest API and response is successful (200)") - public void adminUserGetsSiteMembershipRequestsWithSuccess() throws Exception - { - siteMembershipRequests = restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI() - .usingUser(newMember).getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.OK); - siteMembershipRequests.assertThat().entriesListIsNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @Bug(id = "MNT-16904", description = "It fails only on environment with tenants") - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user fails to get all site membership requests of a specific person with Rest API when the authentication fails (401)") - public void unauthorizedUserFailsToGetSiteMembershipRequests() throws Exception - { - restClient.authenticateUser(new UserModel("random user", "random password")).withCoreAPI() - .usingAuthUser().getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify a user gets all its own site membership requests with Rest API and response is successful (200)") - public void oneUserGetsItsOwnSiteMembershipRequestsWithSuccess() throws Exception - { - siteMembershipRequests = restClient.authenticateUser(newMember).withCoreAPI().usingUser(newMember).getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.OK); - siteMembershipRequests.assertThat().entriesListContains("id", moderatedSite.getId()) - .assertThat().entriesListContains("message", "Please accept me") - .assertThat().entriesListCountIs(1); - siteMembershipRequests.getEntries().get(0).onModel().getSite() - .assertThat().field("visibility").is(moderatedSite.getVisibility()) - .assertThat().field("guid").is(moderatedSite.getGuid()) - .assertThat().field("description").is(moderatedSite.getDescription()) - .assertThat().field("id").is(moderatedSite.getId()) - .assertThat().field("title").is(moderatedSite.getTitle()); - } -} diff --git a/e2e-test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestsTests.java b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestsTests.java new file mode 100644 index 000000000..13a2d0e6b --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestsTests.java @@ -0,0 +1,371 @@ +package org.alfresco.rest.sites.membershipRequests; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestSiteMembershipRequestModel; +import org.alfresco.rest.model.RestSiteMembershipRequestModelsCollection; +import org.alfresco.rest.model.RestTaskModel; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Tests for getSiteMembershipRequests (get /people/{personId}/site-membership-requests) RestAPI call + * + * @author Cristina Axinte + */ + +public class GetSiteMembershipRequestsTests extends RestTest +{ + UserModel siteManager, newMember, adminUser, regularUser; + DataUser.ListUserWithRoles usersWithRoles; + SiteModel moderatedSite1, moderatedSite2; + RestSiteMembershipRequestModelsCollection siteMembershipRequests; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + siteManager = dataUser.createRandomTestUser(); + newMember = dataUser.createRandomTestUser(); + regularUser = dataUser.createRandomTestUser(); + + moderatedSite1 = dataSite.usingUser(siteManager).createModeratedRandomSite(); + moderatedSite2 = dataSite.usingUser(siteManager).createModeratedRandomSite(); + + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite1); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite1); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + usersWithRoles = dataUser.addUsersWithRolesToSite(moderatedSite1, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @Bug(id = "MNT-16557") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user gets all site membership requests of a specific person with Rest API and response is successful (200)") + public void managerUserGetsSiteMembershipRequestsWithSuccess() throws Exception + { + siteMembershipRequests = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI() + .usingUser(newMember).getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembershipRequests.assertThat().entriesListIsNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @Bug(id = "MNT-16557") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify collaborator user fails to get all site membership requests of another user with Rest API (403)") + public void collaboratorUserFailsToGetSiteMembershipRequestsOfAnotherUser() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI() + .usingUser(newMember).getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @Bug(id = "MNT-16557") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify contributor user fails to get all site membership requests of another user with Rest API (403)") + public void contributorUserFailsToGetSiteMembershipRequestsOfAnotherUser() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI() + .usingUser(newMember).getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @Bug(id = "MNT-16557") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify consumer user fails to get all site membership requests of another user with Rest API (403)") + public void consumerUserFailsToGetSiteMembershipRequestsOfAnotherUser() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingUser(newMember).getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @Bug(id = "MNT-16557") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin user gets all site membership requests of a specific person with Rest API and response is successful (200)") + public void adminGetsSiteMembershipRequestsOfanotherUserWithSuccess() throws Exception + { + siteMembershipRequests = restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI() + .usingUser(newMember).getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembershipRequests.assertThat().entriesListIsNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) +// @Bug(id = "MNT-16904", description = "It fails only on environment with tenants") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user fails to get all site membership requests of a specific person with Rest API when the authentication fails (401)") + public void unauthorizedUserFailsToGetSiteMembershipRequests() throws Exception + { + restClient.authenticateUser(new UserModel("random user", "random password")).withCoreAPI() + .usingAuthUser().getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify a user gets all its own site membership requests with Rest API and response is successful (200)") + public void oneUserGetsItsOwnSiteMembershipRequestsWithSuccess() throws Exception + { + siteMembershipRequests = restClient.authenticateUser(newMember).withCoreAPI().usingUser(newMember).getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembershipRequests.assertThat().entriesListContains("id", moderatedSite1.getId()) + .assertThat().entriesListContains("message", "Please accept me") + .assertThat().entriesListCountIs(2); + siteMembershipRequests.getEntries().get(0).onModel().getSite() + .assertThat().field("visibility").is(moderatedSite1.getVisibility()) + .assertThat().field("guid").is(moderatedSite1.getGuid()) + .assertThat().field("description").is(moderatedSite1.getDescription()) + .assertThat().field("id").is(moderatedSite1.getId()) + .assertThat().field("title").is(moderatedSite1.getTitle()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, + description = "Verify that for invalid maxItems parameter status code returned is 400.") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void checkInvalidMaxItemsStatusCode() throws Exception + { + restClient.authenticateUser(adminUser).withParams("maxItems=AB") + .withCoreAPI().usingUser(newMember).getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "AB")); + + restClient.authenticateUser(adminUser).withParams("maxItems=0") + .withCoreAPI().usingUser(newMember).getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, + description = "Verify that for invalid skipCount parameter status code returned is 400.") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void checkInvalidSkipCountStatusCode() throws Exception + { + restClient.authenticateUser(adminUser).withParams("skipCount=AB") + .withCoreAPI().usingUser(newMember).getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "AB")); + + restClient.authenticateUser(adminUser).withParams("skipCount=-1") + .withCoreAPI().usingUser(newMember).getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, + description = "Verify that if personId does not exist status code returned is 404.") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void ifPersonIdDoesNotExist() throws Exception + { + UserModel nonexistentUser = dataUser.createRandomTestUser(); + nonexistentUser.setUsername("nonexistent"); + + restClient.authenticateUser(adminUser).withCoreAPI().usingUser(nonexistentUser).getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "nonexistent")) + .statusCodeIs(HttpStatus.NOT_FOUND) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, + description = "Specify -me- string in place of for request.") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void replacePersonIdWithMeRequest() throws Exception + { + UserModel meUser = dataUser.createRandomTestUser(); + restClient.authenticateUser(meUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite1); + siteMembershipRequests = restClient.authenticateUser(meUser).withCoreAPI().usingMe().getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembershipRequests.assertThat().entriesListContains("id", moderatedSite1.getId()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, + description = "Verify that if empty personId is used status code returned is 404.") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void useEmptyPersonId() throws Exception + { + UserModel emptyNameMember = dataUser.createRandomTestUser(); + emptyNameMember.setUsername(" "); + + restClient.authenticateUser(adminUser).withCoreAPI().usingUser(emptyNameMember).getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, emptyNameMember.getUsername())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, + description = "Get site membership requests to a public site.") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void getRequestsToPublicSite() throws Exception + { + SiteModel publicSite = dataSite.usingAdmin().createPublicRandomSite(); + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(publicSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + siteMembershipRequests = restClient.withCoreAPI().usingAuthUser().getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembershipRequests.assertThat().entriesListDoesNotContain("id", publicSite.getId()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, + description = "Approve request then get requests.") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void approveRequestThenGetRequests() throws Exception + { + UserModel siteManager = dataUser.createRandomTestUser(); + + SiteModel moderatedSite = dataSite.usingUser(siteManager).createModeratedRandomSite(); + restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestTaskModel taskModel = restClient.authenticateUser(newMember).withWorkflowAPI().getTasks().getTaskModelByDescription(moderatedSite); + workflow.approveSiteMembershipRequest(siteManager.getUsername(), siteManager.getPassword(), taskModel.getId(), true, "Approve"); + + siteMembershipRequests = restClient.authenticateUser(newMember).withCoreAPI().usingMe().getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembershipRequests.assertThat().entriesListDoesNotContain("id", moderatedSite.getId()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, + description = "Verify admin user gets all its own site membership requests with Rest API and response is successful (200)") + public void adminGetsItsOwnSiteMembershipRequestsWithSuccess() throws Exception + { + siteMembershipRequests = restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembershipRequests.assertThat().entriesListContains("id", moderatedSite1.getId()) + .assertThat().entriesListContains("id", moderatedSite2.getId()); + } + + @Bug(id = "MNT-16557") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, + description = "Verify regular user fails to get all site membership requests of another user with Rest API (403)") + public void regularUserFailsToGetSiteMembershipRequestsOfAnotherUser() throws Exception + { + restClient.authenticateUser(regularUser).withCoreAPI() + .usingUser(newMember).getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Bug(id = "MNT-16557") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, + description = "Verify regular user fails to get all site membership requests of admin with Rest API (403)") + public void regularUserFailsToGetSiteMembershipRequestsOfAdmin() throws Exception + { + restClient.authenticateUser(regularUser).withCoreAPI() + .usingUser(adminUser).getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, + description = "Verify regular user is able to get his site membership requests with, but skip the first one") + public void getSiteMembershipRequestsButSkipTheFirstOne() throws Exception + { + siteMembershipRequests = restClient.authenticateUser(newMember).withParams("orderBy=id ASC").withCoreAPI() + .usingMe().getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembershipRequests.assertThat().entriesListContains("id", moderatedSite1.getId()) + .assertThat().entriesListContains("id", moderatedSite2.getId()); + + RestSiteMembershipRequestModel firstSiteMembershipRequest = siteMembershipRequests.getEntries().get(0).onModel(); + RestSiteMembershipRequestModel secondSiteMembershipRequest = siteMembershipRequests.getEntries().get(1).onModel(); + + siteMembershipRequests = restClient.authenticateUser(newMember).withParams("orderBy=id ASC&skipCount=1").withCoreAPI() + .usingMe().getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembershipRequests.assertThat().entriesListDoesNotContain("id", firstSiteMembershipRequest.getId()) + .assertThat().entriesListContains("id", secondSiteMembershipRequest.getId()) + .assertThat().entriesListContains("id", secondSiteMembershipRequest.getSite().getId()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, + description = "Verify regular user is able to get his site membership requests with higher skipCount than number of requests") + public void getSiteMembershipRequestsWithHighSkipCount() throws Exception + { + siteMembershipRequests = restClient.authenticateUser(newMember).withParams("skipCount=3").withCoreAPI() + .usingMe().getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembershipRequests.assertThat().entriesListIsEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, + description = "Verify get site membership requests returns an empty list where there are no requests") + public void getSiteMembershipRequestsWhereThereAreNoRequests() throws Exception + { + siteMembershipRequests = restClient.authenticateUser(regularUser).withCoreAPI().usingMe().getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembershipRequests.assertThat().entriesListIsEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, + description = "Reject request then get site membership requests.") + public void rejectRequestThenGetSiteMembershipRequests() throws Exception + { + UserModel userWithRejectedRequests = dataUser.createRandomTestUser(); + + restClient.authenticateUser(userWithRejectedRequests).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite1); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestTaskModel taskModel = restClient.authenticateUser(userWithRejectedRequests).withWorkflowAPI().getTasks().getTaskModelByDescription(moderatedSite1); + workflow.approveSiteMembershipRequest(siteManager.getUsername(), siteManager.getPassword(), taskModel.getId(), false, "Rejected"); + + siteMembershipRequests = restClient.authenticateUser(userWithRejectedRequests).withCoreAPI().usingMe().getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembershipRequests.assertThat().entriesListDoesNotContain("id", moderatedSite1.getId()) + .assertThat().entriesListContains("id", moderatedSite2.getId()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, + description = "Check get site membership requests when properties parameter is used") + public void getSiteMembershipRequestsWithProperties() throws Exception + { + siteMembershipRequests = restClient.authenticateUser(newMember).withParams("properties=id") + .withCoreAPI().usingAuthUser().getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembershipRequests.assertThat().entriesListContains("id", moderatedSite1.getId()) + .assertThat().entriesListContains("id", moderatedSite2.getId()); + RestSiteMembershipRequestModel siteMembershipRequest = siteMembershipRequests.getOneRandomEntry().onModel(); + siteMembershipRequest.assertThat().fieldsCount().is(1); + } +} diff --git a/e2e-test/java/org/alfresco/rest/sites/membershipRequests/UpdateSiteMembershipRequestCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/UpdateSiteMembershipRequestCoreTests.java deleted file mode 100644 index eb814966a..000000000 --- a/e2e-test/java/org/alfresco/rest/sites/membershipRequests/UpdateSiteMembershipRequestCoreTests.java +++ /dev/null @@ -1,134 +0,0 @@ -package org.alfresco.rest.sites.membershipRequests; - -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestSiteMembershipRequestModel; -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.Assert; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class UpdateSiteMembershipRequestCoreTests extends RestTest -{ - private SiteModel siteModel; - private UserModel managerUser; - private String updatedMessage; - private RestSiteMembershipRequestModel returnedResponse; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws DataPreparationException - { - managerUser = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(managerUser).createModeratedRandomSite(); - updatedMessage = "Please review my request"; - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify unauthorized user is not able to update user site membership request") - public void unauthorizedUserIsNotAbleToUpdateSiteMembershipRequest() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(siteModel); - newMember.setPassword("fakePass"); - restClient.withCoreAPI().usingUser(newMember).updateSiteMembershipRequest(siteModel, updatedMessage); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError().containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is able to update its own site membership request using -me-") - public void usingMeUpdateSiteMembershipRequest() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(siteModel); - returnedResponse = restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(siteModel, updatedMessage); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedResponse.assertMembershipRequestMessageIs(updatedMessage).and().field("id").is(siteModel.getId()).and().field("modifiedAt").isNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify inexistent user is not able to update its own site membership request") - public void inexistentUserCannotUpdateSiteMembershipRequest() throws Exception - { - UserModel inexistentUser = UserModel.getRandomUserModel(); - restClient.authenticateUser(managerUser).withCoreAPI().usingUser(inexistentUser).updateSiteMembershipRequest(siteModel, updatedMessage); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, inexistentUser.getUsername())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to update its own site membership request for inexistent site") - public void userCannotUpdateSiteMembershipRequestForInexistentSite() throws Exception - { - SiteModel randomSite = SiteModel.getRandomSiteModel(); - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingMe().updateSiteMembershipRequest(randomSite, updatedMessage); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, newMember.getUsername(), randomSite.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is able not to update its own site membership request for public site") - public void userCannotUpdateSiteMembershipRequestForPublicSite() throws Exception - { - SiteModel publicSite = dataSite.usingUser(managerUser).createPublicRandomSite(); - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(publicSite); - restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(publicSite, updatedMessage); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, newMember.getUsername(), publicSite.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to update its own site membership request for private site") - public void userCannotUpdateSiteMembershipRequestForPrivateSite() throws Exception - { - SiteModel privateSite = dataSite.usingUser(managerUser).createPrivateRandomSite(); - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(privateSite); - restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(privateSite, updatedMessage); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, newMember.getUsername(), privateSite.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is able to update its own site membership request with initial message") - public void userCanUpdateSiteMembershipRequestWithInitialMessage() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(updatedMessage, siteModel, "Accept me"); - returnedResponse = restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(siteModel, updatedMessage); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedResponse.assertMembershipRequestMessageIs(updatedMessage).and().field("id").is(siteModel.getId()).and().field("modifiedAt").isNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is able to update its own site membership request with different message") - public void userCanUpdateSiteMembershipRequestWithDifferentMessage() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest("", siteModel, "Accept me"); - returnedResponse = restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(siteModel, updatedMessage); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedResponse.assertMembershipRequestMessageIs(updatedMessage).and().field("id").is(siteModel.getId()).and().field("modifiedAt").isNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify modifiedAt field for update siteMembership request call") - public void verifyModifiedAtForUpdateSiteMembershipRequest() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(siteModel); - String firstModifiedAt = restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(siteModel, "first message").getModifiedAt(); - String secondModifiedAt = restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(siteModel, "second message").getModifiedAt(); - Assert.assertNotEquals(firstModifiedAt, secondModifiedAt); - restClient.assertStatusCodeIs(HttpStatus.OK); - } -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/sites/membershipRequests/UpdateSiteMembershipRequestFullTests.java b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/UpdateSiteMembershipRequestFullTests.java deleted file mode 100644 index c62ca1c1d..000000000 --- a/e2e-test/java/org/alfresco/rest/sites/membershipRequests/UpdateSiteMembershipRequestFullTests.java +++ /dev/null @@ -1,508 +0,0 @@ -package org.alfresco.rest.sites.membershipRequests; - -import org.alfresco.rest.RestTest; -import org.alfresco.rest.core.RestRequest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestSiteMembershipRequestModel; -import org.alfresco.rest.model.RestTaskModel; -import org.alfresco.utility.constants.UserRole; -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.HttpMethod; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class UpdateSiteMembershipRequestFullTests extends RestTest -{ - private SiteModel moderatedSite; - private UserModel managerUser, adminUser, newMember, regularUser; - private String updatedMessage, moderatedSiteId; - private RestSiteMembershipRequestModel requestUpdateModel, requestGetModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - managerUser = dataUser.createRandomTestUser(); - moderatedSite = dataSite.usingUser(managerUser).createModeratedRandomSite(); - updatedMessage = "Please review my request"; - - newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - moderatedSiteId = moderatedSite.getId(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify user is not able to update membership request of admin") - public void userIsNotAbleToUpdateSiteMembershipRequestOfAdmin() throws JsonToModelConversionException, Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser() - .addSiteMembershipRequest(moderatedSite); - - restClient.authenticateUser(newMember).withCoreAPI().usingUser(adminUser) - .updateSiteMembershipRequest(moderatedSite, updatedMessage); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format("The entity with id: " + RestErrorModel.ENTITY_NOT_FOUND, adminUser.getUsername())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify user is able to update site membership request for moderated site") - public void userCanUpdateSiteMembershipRequestForModeratedSite() throws Exception - { - SiteModel moderatedSite = dataSite.usingUser(managerUser).createModeratedRandomSite(); - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser() - .addSiteMembershipRequest(moderatedSite); - - requestUpdateModel = restClient.withCoreAPI().usingMe() - .updateSiteMembershipRequest(moderatedSite, updatedMessage); - restClient.assertStatusCodeIs(HttpStatus.OK); - - requestUpdateModel.assertThat().field("id").is(moderatedSite.getId()) - .assertThat().field("message").is(updatedMessage) - .assertThat().field("site").isNotEmpty() - .assertThat().field("modifiedAt").isNotEmpty() - .assertThat().field("createdAt").isNotEmpty(); - requestUpdateModel.getSite().assertThat().field("visibility").is(moderatedSite.getVisibility()) - .assertThat().field("guid").is(moderatedSite.getGuid()) - .assertThat().field("description").is(moderatedSite.getDescription()) - .assertThat().field("id").is(moderatedSite.getId()) - .assertThat().field("preset").is("site-dashboard") - .assertThat().field("title").is(moderatedSite.getTitle()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify site collaborator is able to update site membership request") - public void siteCollaboratorIsAbleToUpdateSiteMembershipRequest() throws JsonToModelConversionException, Exception - { - dataUser.usingUser(managerUser).addUserToSite(newMember, moderatedSite, UserRole.SiteCollaborator); - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser() - .addSiteMembershipRequest(moderatedSite); - requestUpdateModel = restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser() - .updateSiteMembershipRequest(moderatedSite, updatedMessage); - - restClient.assertStatusCodeIs(HttpStatus.OK); - requestUpdateModel.assertThat().field("id").is(moderatedSite.getId()) - .assertThat().field("message").is(updatedMessage) - .assertThat().field("modifiedAt").isNotEmpty() - .assertThat().field("createdAt").isNotEmpty(); - requestUpdateModel.getSite().assertThat().field("role").is(UserRole.SiteCollaborator) - .assertThat().field("visibility").is(moderatedSite.getVisibility()) - .assertThat().field("guid").is(moderatedSite.getGuid()) - .assertThat().field("description").is(moderatedSite.getDescription()) - .assertThat().field("id").is(moderatedSite.getId()) - .assertThat().field("preset").is("site-dashboard") - .assertThat().field("title").is(moderatedSite.getTitle()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify site contributor is able to update site membership request") - public void siteContributorIsAbleToUpdateSiteMembershipRequest() throws JsonToModelConversionException, Exception - { - newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser() - .addSiteMembershipRequest(moderatedSite); - dataUser.usingUser(managerUser).addUserToSite(newMember, moderatedSite, UserRole.SiteContributor); - requestUpdateModel = restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser() - .updateSiteMembershipRequest(moderatedSite, updatedMessage); - - restClient.assertStatusCodeIs(HttpStatus.OK); - requestUpdateModel.assertThat().field("id").is(moderatedSite.getId()) - .assertThat().field("message").is(updatedMessage) - .assertThat().field("modifiedAt").isNotEmpty() - .assertThat().field("createdAt").isNotEmpty(); - requestUpdateModel.getSite().assertThat().field("role").is(UserRole.SiteContributor) - .assertThat().field("visibility").is(moderatedSite.getVisibility()) - .assertThat().field("guid").is(moderatedSite.getGuid()) - .assertThat().field("description").is(moderatedSite.getDescription()) - .assertThat().field("id").is(moderatedSite.getId()) - .assertThat().field("preset").is("site-dashboard") - .assertThat().field("title").is(moderatedSite.getTitle()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify site consumer is able to update site membership request") - public void siteConsumerIsAbleToUpdateSiteMembershipRequest() throws JsonToModelConversionException, Exception - { - newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser() - .addSiteMembershipRequest(moderatedSite); - dataUser.usingUser(managerUser).addUserToSite(newMember, moderatedSite, UserRole.SiteConsumer); - requestUpdateModel = restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser() - .updateSiteMembershipRequest(moderatedSite, updatedMessage); - - restClient.assertStatusCodeIs(HttpStatus.OK); - requestUpdateModel.assertThat().field("id").is(moderatedSite.getId()) - .assertThat().field("message").is(updatedMessage) - .assertThat().field("modifiedAt").isNotEmpty() - .assertThat().field("createdAt").isNotEmpty(); - requestUpdateModel.getSite().assertThat().field("role").is(UserRole.SiteConsumer) - .assertThat().field("visibility").is(moderatedSite.getVisibility()) - .assertThat().field("guid").is(moderatedSite.getGuid()) - .assertThat().field("description").is(moderatedSite.getDescription()) - .assertThat().field("id").is(moderatedSite.getId()) - .assertThat().field("preset").is("site-dashboard") - .assertThat().field("title").is(moderatedSite.getTitle()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify site manager is able to update site membership request") - public void siteManagerIsAbleToUpdateSiteMembershipRequest() throws JsonToModelConversionException, Exception - { - newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser() - .addSiteMembershipRequest(moderatedSite); - dataUser.usingUser(managerUser).addUserToSite(newMember, moderatedSite, UserRole.SiteManager); - requestUpdateModel = restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser() - .updateSiteMembershipRequest(moderatedSite, updatedMessage); - - restClient.assertStatusCodeIs(HttpStatus.OK); - requestUpdateModel.assertThat().field("id").is(moderatedSite.getId()) - .assertThat().field("message").is(updatedMessage) - .assertThat().field("modifiedAt").isNotEmpty() - .assertThat().field("createdAt").isNotEmpty(); - requestUpdateModel.getSite().assertThat().field("role").is(UserRole.SiteManager) - .assertThat().field("visibility").is(moderatedSite.getVisibility()) - .assertThat().field("guid").is(moderatedSite.getGuid()) - .assertThat().field("description").is(moderatedSite.getDescription()) - .assertThat().field("id").is(moderatedSite.getId()) - .assertThat().field("preset").is("site-dashboard") - .assertThat().field("title").is(moderatedSite.getTitle()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify admin is able to update site membership request") - public void adminIsAbleToRetrieveSiteMembershipRequest() throws JsonToModelConversionException, Exception - { - regularUser = dataUser.createRandomTestUser(); - SiteModel anotherModeratedSite = dataSite.usingUser(regularUser).createModeratedRandomSite(); - requestUpdateModel = restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser() - .addSiteMembershipRequest(anotherModeratedSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - requestUpdateModel = restClient.withCoreAPI().usingAuthUser() - .updateSiteMembershipRequest(anotherModeratedSite, updatedMessage); - - restClient.assertStatusCodeIs(HttpStatus.OK); - requestUpdateModel.assertThat().field("id").is(anotherModeratedSite.getId()) - .assertThat().field("message").is("Please review my request") - .assertThat().field("modifiedAt").isNotEmpty() - .assertThat().field("createdAt").isNotEmpty(); - requestUpdateModel.getSite().assertThat().field("visibility").is(anotherModeratedSite.getVisibility()) - .assertThat().field("guid").is(anotherModeratedSite.getGuid()) - .assertThat().field("description").is(anotherModeratedSite.getDescription()) - .assertThat().field("id").is(anotherModeratedSite.getId()) - .assertThat().field("preset").is("site-dashboard") - .assertThat().field("title").is(anotherModeratedSite.getTitle()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify user update site membership request with no message then adds a new message") - public void userUpdateSiteMembershipRequestWithNoMessageThenAddsNewMessage() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - requestUpdateModel = restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser() - .addSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - requestUpdateModel.assertThat().field("id").is(moderatedSite.getId()) - .assertThat().field("message").is("Please accept me"); - - requestUpdateModel = restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(moderatedSite, ""); - restClient.assertStatusCodeIs(HttpStatus.OK); - requestUpdateModel.assertThat().field("id").is(moderatedSite.getId()) - .and().field("modifiedAt").isNotEmpty() - .assertThat().field("message").isNull(); - - requestUpdateModel = restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(moderatedSite, updatedMessage); - requestUpdateModel.assertThat().field("id").is(moderatedSite.getId()) - .assertThat().field("message").is(updatedMessage) - .assertThat().field("modifiedAt").isNotEmpty() - .assertThat().field("createdAt").isNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify user updates site membership request and verifies 'ModifiedAt' field using GET") - public void userUpdateSiteMembershipRequestAndCheckModifiedAtWithGet() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - requestUpdateModel = restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser() - .addSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - requestUpdateModel.assertThat().field("id").is(moderatedSite.getId()) - .assertThat().field("message").is("Please accept me"); - - requestUpdateModel = restClient.withCoreAPI().usingAuthUser().updateSiteMembershipRequest(moderatedSite, updatedMessage); - requestGetModel = restClient.withCoreAPI().usingAuthUser().getSiteMembershipRequest(moderatedSite); - - restClient.assertStatusCodeIs(HttpStatus.OK); - requestGetModel.assertThat().field("id").is(requestUpdateModel.getId()) - .and().field("modifiedAt").is(requestUpdateModel.getModifiedAt()) - .assertThat().field("message").is(requestUpdateModel.getMessage()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Update membership request - empty body") - public void emptyBodyUpdateSiteMembershipRequest() throws Exception - { - restClient.authenticateUser(adminUser).withCoreAPI(); - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"\": \"\",\"\": \"\", \"\": \"\"}", - "people/{personId}/site-membership-requests/{siteId}", adminUser.getUsername(), moderatedSite.getId()); - restClient.processModel(RestSiteMembershipRequestModel.class, request); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.NO_CONTENT, "Unrecognized field " + "\"\"")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Update membership request - missing 'Title' field from Json") - public void missingTitleFieldBodyUpdateSiteMembershipRequest() throws Exception - { - SiteModel moderatedSite = dataSite.usingUser(managerUser).createModeratedRandomSite(); - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser() - .addSiteMembershipRequest(moderatedSite); - - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, - "{\"message\":\"Please review my request\",\"id\":\"" + moderatedSite.getId() + "\"}", - "people/{personId}/site-membership-requests/{siteId}", - newMember.getUsername(), moderatedSite.getId()); - requestUpdateModel = restClient.processModel(RestSiteMembershipRequestModel.class, request); - - restClient.assertStatusCodeIs(HttpStatus.OK); - requestUpdateModel.assertThat().field("id").is(moderatedSite.getId()) - .assertThat().field("message").is(updatedMessage) - .assertThat().field("site").isNotEmpty() - .assertThat().field("modifiedAt").isNotEmpty() - .assertThat().field("createdAt").isNotEmpty(); - requestUpdateModel.getSite().assertThat().field("visibility").is(moderatedSite.getVisibility()) - .assertThat().field("guid").is(moderatedSite.getGuid()) - .assertThat().field("description").is(moderatedSite.getDescription()) - .assertThat().field("id").is(moderatedSite.getId()) - .assertThat().field("preset").is("site-dashboard") - .assertThat().field("title").is(moderatedSite.getTitle()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Update site membership request - missing JSON body") - public void missingJsonFieldBodyUpdateSiteMembershipRequest() throws Exception - { - SiteModel moderatedSite = dataSite.usingUser(managerUser).createModeratedRandomSite(); - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser() - .addSiteMembershipRequest(moderatedSite); - - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "", - "people/{personId}/site-membership-requests/{siteId}", newMember.getUsername(), - moderatedSite.getId()); - requestUpdateModel = restClient.processModel(RestSiteMembershipRequestModel.class, request); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsSummary(String.format(RestErrorModel.NO_CONTENT, "No content to map to Object due to end of input")) - .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "No content to map to Object due to end of input")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Update site membership request - empty JSON body") - public void emptyJsonFieldBodyUpdateSiteMembershipRequest() throws Exception - { - SiteModel moderatedSite = dataSite.usingUser(managerUser).createModeratedRandomSite(); - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser() - .addSiteMembershipRequest(moderatedSite); - - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{}", - "people/{personId}/site-membership-requests/{siteId}", newMember.getUsername(), - moderatedSite.getId()); - requestUpdateModel = restClient.processModel(RestSiteMembershipRequestModel.class, request); - - restClient.assertStatusCodeIs(HttpStatus.OK); - requestUpdateModel.assertThat().field("id").is(moderatedSite.getId()) - .assertThat().field("message").isNull() - .assertThat().field("site").isNotEmpty() - .assertThat().field("modifiedAt").isNotEmpty() - .assertThat().field("createdAt").isNotEmpty(); - requestUpdateModel.getSite().assertThat().field("visibility").is(moderatedSite.getVisibility()) - .assertThat().field("guid").is(moderatedSite.getGuid()) - .assertThat().field("description").is(moderatedSite.getDescription()) - .assertThat().field("id").is(moderatedSite.getId()) - .assertThat().field("preset").is("site-dashboard") - .assertThat().field("title").is(moderatedSite.getTitle()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Update site membership request - invalid SiteId") - public void invalidSiteIdUpdateSiteMembershipRequest() throws Exception - { - moderatedSite.setId("invalidSiteId"); - restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser() - .updateSiteMembershipRequest(moderatedSite, updatedMessage); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, managerUser.getUsername(), moderatedSite.getId())); - - moderatedSite.setId(moderatedSiteId); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Update site membership request - empty SiteId") - public void emptySiteIdUpdateSiteMembershipRequest() throws Exception - { - moderatedSite.setId(""); - restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser() - .updateSiteMembershipRequest(moderatedSite, updatedMessage); - - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) - .assertLastError() - .containsSummary(RestErrorModel.PUT_EMPTY_ARGUMENT) - .containsErrorKey(RestErrorModel.PUT_EMPTY_ARGUMENT) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - - moderatedSite.setId(moderatedSiteId); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify inexistent user is not able to update site membership request") - public void emptyUserCannotUpdateSiteMembershipRequest() throws Exception - { - UserModel emptyUser = new UserModel("", "password"); - restClient.authenticateUser(emptyUser).withCoreAPI().usingAuthUser() - .updateSiteMembershipRequest(moderatedSite, updatedMessage); - - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Update site membership request - rejected Request") - public void rejectRequestTheUpdateSiteMembershipRequest() throws Exception - { - UserModel userWithRejectedRequests = dataUser.createRandomTestUser(); - restClient.authenticateUser(userWithRejectedRequests).withCoreAPI().usingAuthUser() - .addSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - RestTaskModel taskModel = restClient.authenticateUser(userWithRejectedRequests).withWorkflowAPI().getTasks() - .getTaskModelByDescription(moderatedSite); - workflow.approveSiteMembershipRequest(managerUser.getUsername(), managerUser.getPassword(), taskModel.getId(), false, "Rejected"); - - requestUpdateModel = restClient.authenticateUser(userWithRejectedRequests).withCoreAPI().usingMe() - .updateSiteMembershipRequest(moderatedSite, updatedMessage); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, userWithRejectedRequests.getUsername(), moderatedSite.getId())) - .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Update site membership request - approved Request") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - public void approveRequestTheUpdateSiteMembershipRequest() throws JsonToModelConversionException, DataPreparationException, Exception - { - UserModel userWithApprovedRequests = dataUser.createRandomTestUser(); - restClient.authenticateUser(userWithApprovedRequests).withCoreAPI().usingAuthUser() - .addSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - RestTaskModel taskModel = restClient.authenticateUser(userWithApprovedRequests).withWorkflowAPI().getTasks().getTaskModelByDescription(moderatedSite); - workflow.approveSiteMembershipRequest(managerUser.getUsername(), managerUser.getPassword(), taskModel.getId(), true, "Approve"); - - requestUpdateModel = restClient.authenticateUser(userWithApprovedRequests).withCoreAPI().usingMe() - .updateSiteMembershipRequest(moderatedSite, updatedMessage); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, userWithApprovedRequests.getUsername(), moderatedSite.getId())) - .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE}, executionType = ExecutionType.REGRESSION, - description = "Update site membership request using invalid network") - public void updateSiteMembershipRequestUsingInvalidNetwork() throws Exception - { - UserModel invalidUserNetwork = dataUser.createRandomTestUser(); - SiteModel site = dataSite.usingUser(invalidUserNetwork).createModeratedRandomSite(); - dataSite.usingUser(invalidUserNetwork).usingSite(site).addSiteToFavorites(); - invalidUserNetwork.setDomain("invalidNetwork"); - - requestUpdateModel = restClient.authenticateUser(invalidUserNetwork).withCoreAPI().usingMe() - .updateSiteMembershipRequest(site, updatedMessage); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE}, executionType = ExecutionType.REGRESSION, - description = "Verify user is not able to update an inexitent site membership request") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) - public void userIsNotAbleToUpdateAnInexistentSiteMembershipRequest() throws JsonToModelConversionException, DataPreparationException, Exception - { - SiteModel moderatedSite = dataSite.usingUser(managerUser).createModeratedRandomSite(); - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser() - .updateSiteMembershipRequest(moderatedSite, updatedMessage); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, newMember.getUsername(), moderatedSite.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE}, executionType = ExecutionType.REGRESSION, - description = "Verify user is not able to update a deleted site membership request") - public void userCantUpdateSiteMembershipRequestForDeletedRequest() throws Exception - { - SiteModel moderatedSite = dataSite.usingUser(managerUser).createModeratedRandomSite(); - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser() - .addSiteMembershipRequest(moderatedSite); - - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser() - .deleteSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - requestUpdateModel = restClient.withCoreAPI().usingAuthUser() - .updateSiteMembershipRequest(moderatedSite, updatedMessage); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, newMember.getUsername(), moderatedSite.getId())); - } - -} diff --git a/e2e-test/java/org/alfresco/rest/sites/membershipRequests/UpdateSiteMembershipRequestSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/UpdateSiteMembershipRequestSanityTests.java deleted file mode 100644 index b4474ce5f..000000000 --- a/e2e-test/java/org/alfresco/rest/sites/membershipRequests/UpdateSiteMembershipRequestSanityTests.java +++ /dev/null @@ -1,145 +0,0 @@ -package org.alfresco.rest.sites.membershipRequests; - -import org.alfresco.dataprep.SiteService.Visibility; -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.data.RandomData; -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; - -public class UpdateSiteMembershipRequestSanityTests extends RestTest -{ - private SiteModel siteModel; - private ListUserWithRoles usersWithRoles; - private UserModel adminUser; - private String updatedMessage; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws DataPreparationException - { - adminUser = dataUser.getAdminUser(); - String siteId = RandomData.getRandomName("site"); - siteModel = dataSite.usingUser(adminUser).createSite(new SiteModel(Visibility.MODERATED, siteId, siteId, siteId, siteId)); - - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - updatedMessage = "Please review my request"; - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify user is able to update its own site membership request") - public void userIsAbleToUpdateItsOwnSiteMembershipRequest() throws JsonToModelConversionException, Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(siteModel); - restClient.withCoreAPI().usingUser(newMember).updateSiteMembershipRequest(siteModel, updatedMessage).assertMembershipRequestMessageIs(updatedMessage) - .and().field("id").is(siteModel.getId()).and().field("modifiedAt").isNotEmpty(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site manager is not able to update membership request of another user") -// @Bug(id = "MNT-16919", description = "Not a bug, The presence of the personId in the URL does not mean it should be possible to act on any other users behalf.") - public void siteManagerIsNotAbleToUpdateSiteMembershipRequestOfAnotherUser() throws JsonToModelConversionException, Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(siteModel); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingUser(newMember) - .updateSiteMembershipRequest(siteModel, updatedMessage); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site collaborator is not able to update membership request of another user") - // @Bug(id = "MNT-16919", description = "Not a bug, The presence of the personId in the URL does not mean it should be possible to act on any other users behalf.") - public void siteCollaboratorIsNotAbleToUpdateSiteMembershipRequestOfAnotherUser() throws JsonToModelConversionException, Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(siteModel); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingUser(newMember) - .updateSiteMembershipRequest(siteModel, updatedMessage); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site contributor is not able to update membership request of another user") - // @Bug(id = "MNT-16919", description = "Not a bug, The presence of the personId in the URL does not mean it should be possible to act on any other users behalf.") - public void siteContributorIsNotAbleToUpdateSiteMembershipRequestOfAnotherUser() throws JsonToModelConversionException, Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(siteModel); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingUser(newMember) - .updateSiteMembershipRequest(siteModel, updatedMessage); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site consumer is not able to update membership request of another user") - // @Bug(id = "MNT-16919", description = "Not a bug, The presence of the personId in the URL does not mean it should be possible to act on any other users behalf.") - public void siteConsumerIsNotAbleToUpdateSiteMembershipRequestOfAnotherUser() throws JsonToModelConversionException, Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(siteModel); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingUser(newMember) - .updateSiteMembershipRequest(siteModel, updatedMessage); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify one user is not able to update membership request of another user") - // @Bug(id = "MNT-16919", description = "Not a bug, The presence of the personId in the URL does not mean it should be possible to act on any other users behalf.") - public void oneUserIsNotAbleToUpdateSiteMembershipRequestOfAnotherUser() throws JsonToModelConversionException, Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - UserModel otherMember = dataUser.createRandomTestUser(); - - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(siteModel); - - restClient.authenticateUser(otherMember).withCoreAPI().usingUser(newMember).updateSiteMembershipRequest(siteModel, updatedMessage); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify admin is not able to update membership request of another user") - // @Bug(id = "MNT-16919", description = "Not a bug, The presence of the personId in the URL does not mean it should be possible to act on any other users behalf.") - public void adminIsNotAbleToUpdateSiteMembershipRequestOfAnotherUser() throws JsonToModelConversionException, Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(siteModel); - - restClient.authenticateUser(adminUser).withCoreAPI().usingUser(newMember).updateSiteMembershipRequest(siteModel, updatedMessage); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); - } -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/sites/membershipRequests/UpdateSiteMembershipRequestTests.java b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/UpdateSiteMembershipRequestTests.java new file mode 100644 index 000000000..0aa579c2d --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/UpdateSiteMembershipRequestTests.java @@ -0,0 +1,610 @@ +package org.alfresco.rest.sites.membershipRequests; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestSiteMembershipRequestModel; +import org.alfresco.rest.model.RestTaskModel; +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.HttpMethod; +import org.springframework.http.HttpStatus; +import org.testng.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class UpdateSiteMembershipRequestTests extends RestTest +{ + private SiteModel moderatedSite; + private ListUserWithRoles usersWithRoles; + private UserModel adminUser, managerUser; + private String updatedMessage, moderatedSiteId; + private RestSiteMembershipRequestModel requestUpdateModel, requestGetModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws DataPreparationException + { + adminUser = dataUser.getAdminUser(); + managerUser = dataUser.createRandomTestUser(); + moderatedSite = dataSite.usingUser(managerUser).createModeratedRandomSite(); + + usersWithRoles = dataUser.addUsersWithRolesToSite(moderatedSite, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + updatedMessage = "Please review my request"; + moderatedSiteId = moderatedSite.getId(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify user is able to update its own site membership request") + public void userIsAbleToUpdateItsOwnSiteMembershipRequest() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + requestUpdateModel = restClient.withCoreAPI().usingUser(newMember).updateSiteMembershipRequest(moderatedSite, updatedMessage); + restClient.assertStatusCodeIs(HttpStatus.OK); + + requestUpdateModel.assertThat().field("id").is(moderatedSite.getId()) + .assertThat().field("message").is(updatedMessage) + .assertThat().field("site").isNotEmpty() + .assertThat().field("modifiedAt").isNotEmpty() + .assertThat().field("createdAt").isNotEmpty(); + requestUpdateModel.getSite().assertThat().field("visibility").is(moderatedSite.getVisibility()) + .assertThat().field("guid").is(moderatedSite.getGuid()) + .assertThat().field("description").is(moderatedSite.getDescription()) + .assertThat().field("id").is(moderatedSite.getId()) + .assertThat().field("preset").is("site-dashboard") + .assertThat().field("title").is(moderatedSite.getTitle()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site manager is not able to update membership request of another user") +// @Bug(id = "MNT-16919", description = "Not a bug, The presence of the personId in the URL does not mean it should be possible to act on any other users behalf.") + public void siteManagerIsNotAbleToUpdateSiteMembershipRequestOfAnotherUser() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingUser(newMember) + .updateSiteMembershipRequest(moderatedSite, updatedMessage); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site collaborator is not able to update membership request of another user") + // @Bug(id = "MNT-16919", description = "Not a bug, The presence of the personId in the URL does not mean it should be possible to act on any other users behalf.") + public void siteCollaboratorIsNotAbleToUpdateSiteMembershipRequestOfAnotherUser() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingUser(newMember) + .updateSiteMembershipRequest(moderatedSite, updatedMessage); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site contributor is not able to update membership request of another user") + // @Bug(id = "MNT-16919", description = "Not a bug, The presence of the personId in the URL does not mean it should be possible to act on any other users behalf.") + public void siteContributorIsNotAbleToUpdateSiteMembershipRequestOfAnotherUser() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingUser(newMember) + .updateSiteMembershipRequest(moderatedSite, updatedMessage); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site consumer is not able to update membership request of another user") + // @Bug(id = "MNT-16919", description = "Not a bug, The presence of the personId in the URL does not mean it should be possible to act on any other users behalf.") + public void siteConsumerIsNotAbleToUpdateSiteMembershipRequestOfAnotherUser() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingUser(newMember) + .updateSiteMembershipRequest(moderatedSite, updatedMessage); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify one user is not able to update membership request of another user") + // @Bug(id = "MNT-16919", description = "Not a bug, The presence of the personId in the URL does not mean it should be possible to act on any other users behalf.") + public void regularUserIsNotAbleToUpdateSiteMembershipRequestOfAnotherUser() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + UserModel otherMember = dataUser.createRandomTestUser(); + + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + + restClient.authenticateUser(otherMember).withCoreAPI().usingUser(newMember).updateSiteMembershipRequest(moderatedSite, updatedMessage); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is not able to update membership request of another user") + // @Bug(id = "MNT-16919", description = "Not a bug, The presence of the personId in the URL does not mean it should be possible to act on any other users behalf.") + public void adminIsNotAbleToUpdateSiteMembershipRequestOfAnotherUser() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + + restClient.authenticateUser(adminUser).withCoreAPI().usingUser(newMember).updateSiteMembershipRequest(moderatedSite, updatedMessage); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify unauthorized user is not able to update user site membership request") + public void unauthorizedUserIsNotAbleToUpdateSiteMembershipRequest() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + newMember.setPassword("fakePass"); + restClient.withCoreAPI().usingUser(newMember).updateSiteMembershipRequest(moderatedSite, updatedMessage); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError().containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is able to update its own site membership request using -me-") + public void usingMeUpdateSiteMembershipRequest() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + requestUpdateModel = restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(moderatedSite, updatedMessage); + restClient.assertStatusCodeIs(HttpStatus.OK); + requestUpdateModel.assertMembershipRequestMessageIs(updatedMessage).and().field("id").is(moderatedSite.getId()).and().field("modifiedAt").isNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify inexistent user is not able to update its own site membership request") + public void inexistentUserCannotUpdateSiteMembershipRequest() throws Exception + { + UserModel inexistentUser = UserModel.getRandomUserModel(); + restClient.authenticateUser(managerUser).withCoreAPI().usingUser(inexistentUser).updateSiteMembershipRequest(moderatedSite, updatedMessage); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, inexistentUser.getUsername())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to update its own site membership request for inexistent site") + public void userCannotUpdateSiteMembershipRequestForInexistentSite() throws Exception + { + SiteModel randomSite = SiteModel.getRandomSiteModel(); + UserModel newMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(newMember).withCoreAPI().usingMe().updateSiteMembershipRequest(randomSite, updatedMessage); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, newMember.getUsername(), randomSite.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is able not to update its own site membership request for public site") + public void userCannotUpdateSiteMembershipRequestForPublicSite() throws Exception + { + SiteModel publicSite = dataSite.usingUser(managerUser).createPublicRandomSite(); + UserModel newMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(publicSite); + restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(publicSite, updatedMessage); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, newMember.getUsername(), publicSite.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to update its own site membership request for private site") + public void userCannotUpdateSiteMembershipRequestForPrivateSite() throws Exception + { + SiteModel privateSite = dataSite.usingUser(managerUser).createPrivateRandomSite(); + UserModel newMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(privateSite); + restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(privateSite, updatedMessage); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, newMember.getUsername(), privateSite.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is able to update its own site membership request with initial message") + public void userCanUpdateSiteMembershipRequestWithInitialMessage() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(updatedMessage, moderatedSite, "Accept me"); + requestUpdateModel = restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(moderatedSite, updatedMessage); + restClient.assertStatusCodeIs(HttpStatus.OK); + requestUpdateModel.assertMembershipRequestMessageIs(updatedMessage).and().field("id").is(moderatedSite.getId()).and().field("modifiedAt").isNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is able to update its own site membership request with different message") + public void userCanUpdateSiteMembershipRequestWithDifferentMessage() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest("", moderatedSite, "Accept me"); + requestUpdateModel = restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(moderatedSite, updatedMessage); + restClient.assertStatusCodeIs(HttpStatus.OK); + requestUpdateModel.assertMembershipRequestMessageIs(updatedMessage).and().field("id").is(moderatedSite.getId()).and().field("modifiedAt").isNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify modifiedAt field for update siteMembership request call") + public void verifyModifiedAtForUpdateSiteMembershipRequest() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + String firstModifiedAt = restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(moderatedSite, "first message").getModifiedAt(); + String secondModifiedAt = restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(moderatedSite, "second message").getModifiedAt(); + Assert.assertNotEquals(firstModifiedAt, secondModifiedAt); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify user is not able to update membership request of admin") + public void userIsNotAbleToUpdateSiteMembershipRequestOfAdmin() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser() + .addSiteMembershipRequest(moderatedSite); + + restClient.authenticateUser(newMember).withCoreAPI().usingUser(adminUser) + .updateSiteMembershipRequest(moderatedSite, updatedMessage); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format("The entity with id: " + RestErrorModel.ENTITY_NOT_FOUND, adminUser.getUsername())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify site manager is able to update site membership request") + public void updateSiteMembershipRequestAfterUserIsAddedAsMember() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser() + .addSiteMembershipRequest(moderatedSite); + dataUser.usingUser(managerUser).addUserToSite(newMember, moderatedSite, UserRole.SiteManager); + requestUpdateModel = restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser() + .updateSiteMembershipRequest(moderatedSite, updatedMessage); + + restClient.assertStatusCodeIs(HttpStatus.OK); + requestUpdateModel.assertThat().field("id").is(moderatedSite.getId()) + .assertThat().field("message").is(updatedMessage) + .assertThat().field("modifiedAt").isNotEmpty() + .assertThat().field("createdAt").isNotEmpty(); + requestUpdateModel.getSite().assertThat().field("role").is(UserRole.SiteManager) + .assertThat().field("visibility").is(moderatedSite.getVisibility()) + .assertThat().field("guid").is(moderatedSite.getGuid()) + .assertThat().field("description").is(moderatedSite.getDescription()) + .assertThat().field("id").is(moderatedSite.getId()) + .assertThat().field("preset").is("site-dashboard") + .assertThat().field("title").is(moderatedSite.getTitle()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify admin is able to update site membership request") + public void adminIsAbleToUpdateHisSiteMembershipRequest() throws Exception + { + UserModel regularUser = dataUser.createRandomTestUser(); + SiteModel anotherModeratedSite = dataSite.usingUser(regularUser).createModeratedRandomSite(); + requestUpdateModel = restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser() + .addSiteMembershipRequest(anotherModeratedSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + requestUpdateModel = restClient.withCoreAPI().usingAuthUser() + .updateSiteMembershipRequest(anotherModeratedSite, updatedMessage); + + restClient.assertStatusCodeIs(HttpStatus.OK); + requestUpdateModel.assertThat().field("id").is(anotherModeratedSite.getId()) + .assertThat().field("message").is("Please review my request") + .assertThat().field("modifiedAt").isNotEmpty() + .assertThat().field("createdAt").isNotEmpty(); + requestUpdateModel.getSite().assertThat().field("visibility").is(anotherModeratedSite.getVisibility()) + .assertThat().field("guid").is(anotherModeratedSite.getGuid()) + .assertThat().field("description").is(anotherModeratedSite.getDescription()) + .assertThat().field("id").is(anotherModeratedSite.getId()) + .assertThat().field("preset").is("site-dashboard") + .assertThat().field("title").is(anotherModeratedSite.getTitle()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify user update site membership request with no message then adds a new message") + public void userUpdateSiteMembershipRequestWithNoMessageThenAddsNewMessage() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + requestUpdateModel = restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser() + .addSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + requestUpdateModel.assertThat().field("id").is(moderatedSite.getId()) + .assertThat().field("message").is("Please accept me"); + + requestUpdateModel = restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(moderatedSite, ""); + restClient.assertStatusCodeIs(HttpStatus.OK); + requestUpdateModel.assertThat().field("id").is(moderatedSite.getId()) + .and().field("modifiedAt").isNotEmpty() + .assertThat().field("message").isNull(); + + requestUpdateModel = restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(moderatedSite, updatedMessage); + requestUpdateModel.assertThat().field("id").is(moderatedSite.getId()) + .assertThat().field("message").is(updatedMessage) + .assertThat().field("modifiedAt").isNotEmpty() + .assertThat().field("createdAt").isNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify user updates site membership request and verifies 'ModifiedAt' field using GET") + public void userUpdateSiteMembershipRequestAndCheckModifiedAtWithGet() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + requestUpdateModel = restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser() + .addSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + requestUpdateModel.assertThat().field("id").is(moderatedSite.getId()) + .assertThat().field("message").is("Please accept me"); + + requestUpdateModel = restClient.withCoreAPI().usingAuthUser().updateSiteMembershipRequest(moderatedSite, updatedMessage); + requestGetModel = restClient.withCoreAPI().usingAuthUser().getSiteMembershipRequest(moderatedSite); + + restClient.assertStatusCodeIs(HttpStatus.OK); + requestGetModel.assertThat().field("id").is(requestUpdateModel.getId()) + .and().field("modifiedAt").is(requestUpdateModel.getModifiedAt()) + .assertThat().field("message").is(requestUpdateModel.getMessage()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Update membership request - empty body") + public void emptyBodyUpdateSiteMembershipRequest() throws Exception + { + restClient.authenticateUser(adminUser).withCoreAPI(); + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"\": \"\",\"\": \"\", \"\": \"\"}", + "people/{personId}/site-membership-requests/{siteId}", adminUser.getUsername(), moderatedSite.getId()); + restClient.processModel(RestSiteMembershipRequestModel.class, request); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.NO_CONTENT, "Unrecognized field " + "\"\"")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Update membership request - missing 'Title' field from Json") + public void missingTitleFieldBodyUpdateSiteMembershipRequest() throws Exception + { + SiteModel moderatedSite = dataSite.usingUser(managerUser).createModeratedRandomSite(); + UserModel newMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser() + .addSiteMembershipRequest(moderatedSite); + + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, + "{\"message\":\"Please review my request\",\"id\":\"" + moderatedSite.getId() + "\"}", + "people/{personId}/site-membership-requests/{siteId}", + newMember.getUsername(), moderatedSite.getId()); + requestUpdateModel = restClient.processModel(RestSiteMembershipRequestModel.class, request); + + restClient.assertStatusCodeIs(HttpStatus.OK); + requestUpdateModel.assertThat().field("id").is(moderatedSite.getId()) + .assertThat().field("message").is(updatedMessage) + .assertThat().field("site").isNotEmpty() + .assertThat().field("modifiedAt").isNotEmpty() + .assertThat().field("createdAt").isNotEmpty(); + requestUpdateModel.getSite().assertThat().field("visibility").is(moderatedSite.getVisibility()) + .assertThat().field("guid").is(moderatedSite.getGuid()) + .assertThat().field("description").is(moderatedSite.getDescription()) + .assertThat().field("id").is(moderatedSite.getId()) + .assertThat().field("preset").is("site-dashboard") + .assertThat().field("title").is(moderatedSite.getTitle()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Update site membership request - missing JSON body") + public void missingJsonFieldBodyUpdateSiteMembershipRequest() throws Exception + { + SiteModel moderatedSite = dataSite.usingUser(managerUser).createModeratedRandomSite(); + UserModel newMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser() + .addSiteMembershipRequest(moderatedSite); + + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "", + "people/{personId}/site-membership-requests/{siteId}", newMember.getUsername(), + moderatedSite.getId()); + requestUpdateModel = restClient.processModel(RestSiteMembershipRequestModel.class, request); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsSummary(String.format(RestErrorModel.NO_CONTENT, "No content to map to Object due to end of input")) + .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "No content to map to Object due to end of input")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Update site membership request - empty JSON body") + public void emptyJsonFieldBodyUpdateSiteMembershipRequest() throws Exception + { + SiteModel moderatedSite = dataSite.usingUser(managerUser).createModeratedRandomSite(); + UserModel newMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser() + .addSiteMembershipRequest(moderatedSite); + + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{}", + "people/{personId}/site-membership-requests/{siteId}", newMember.getUsername(), + moderatedSite.getId()); + requestUpdateModel = restClient.processModel(RestSiteMembershipRequestModel.class, request); + + restClient.assertStatusCodeIs(HttpStatus.OK); + requestUpdateModel.assertThat().field("id").is(moderatedSite.getId()) + .assertThat().field("message").isNull() + .assertThat().field("site").isNotEmpty() + .assertThat().field("modifiedAt").isNotEmpty() + .assertThat().field("createdAt").isNotEmpty(); + requestUpdateModel.getSite().assertThat().field("visibility").is(moderatedSite.getVisibility()) + .assertThat().field("guid").is(moderatedSite.getGuid()) + .assertThat().field("description").is(moderatedSite.getDescription()) + .assertThat().field("id").is(moderatedSite.getId()) + .assertThat().field("preset").is("site-dashboard") + .assertThat().field("title").is(moderatedSite.getTitle()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Update site membership request - invalid SiteId") + public void invalidSiteIdUpdateSiteMembershipRequest() throws Exception + { + moderatedSite.setId("invalidSiteId"); + restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser() + .updateSiteMembershipRequest(moderatedSite, updatedMessage); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, managerUser.getUsername(), moderatedSite.getId())); + + moderatedSite.setId(moderatedSiteId); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Update site membership request - empty SiteId") + public void emptySiteIdUpdateSiteMembershipRequest() throws Exception + { + moderatedSite.setId(""); + restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser() + .updateSiteMembershipRequest(moderatedSite, updatedMessage); + + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) + .assertLastError() + .containsSummary(RestErrorModel.PUT_EMPTY_ARGUMENT) + .containsErrorKey(RestErrorModel.PUT_EMPTY_ARGUMENT) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + + moderatedSite.setId(moderatedSiteId); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify inexistent user is not able to update site membership request") + public void emptyUserCannotUpdateSiteMembershipRequest() throws Exception + { + UserModel emptyUser = new UserModel("", "password"); + restClient.authenticateUser(emptyUser).withCoreAPI().usingAuthUser() + .updateSiteMembershipRequest(moderatedSite, updatedMessage); + + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Update site membership request - rejected Request") + public void rejectRequestThenUpdateSiteMembershipRequest() throws Exception + { + UserModel userWithRejectedRequests = dataUser.createRandomTestUser(); + restClient.authenticateUser(userWithRejectedRequests).withCoreAPI().usingAuthUser() + .addSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + RestTaskModel taskModel = restClient.authenticateUser(userWithRejectedRequests).withWorkflowAPI().getTasks() + .getTaskModelByDescription(moderatedSite); + workflow.approveSiteMembershipRequest(managerUser.getUsername(), managerUser.getPassword(), taskModel.getId(), false, "Rejected"); + + requestUpdateModel = restClient.authenticateUser(userWithRejectedRequests).withCoreAPI().usingMe() + .updateSiteMembershipRequest(moderatedSite, updatedMessage); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, userWithRejectedRequests.getUsername(), moderatedSite.getId())) + .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Update site membership request - approved Request") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void approveRequestThenUpdateSiteMembershipRequest() throws Exception + { + UserModel userWithApprovedRequests = dataUser.createRandomTestUser(); + restClient.authenticateUser(userWithApprovedRequests).withCoreAPI().usingAuthUser() + .addSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + RestTaskModel taskModel = restClient.authenticateUser(userWithApprovedRequests).withWorkflowAPI().getTasks().getTaskModelByDescription(moderatedSite); + workflow.approveSiteMembershipRequest(managerUser.getUsername(), managerUser.getPassword(), taskModel.getId(), true, "Approve"); + + requestUpdateModel = restClient.authenticateUser(userWithApprovedRequests).withCoreAPI().usingMe() + .updateSiteMembershipRequest(moderatedSite, updatedMessage); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, userWithApprovedRequests.getUsername(), moderatedSite.getId())) + .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE}, executionType = ExecutionType.REGRESSION, + description = "Update site membership request using invalid network") + public void updateSiteMembershipRequestUsingInvalidNetwork() throws Exception + { + UserModel invalidUserNetwork = dataUser.createRandomTestUser(); + SiteModel site = dataSite.usingUser(invalidUserNetwork).createModeratedRandomSite(); + dataSite.usingUser(invalidUserNetwork).usingSite(site).addSiteToFavorites(); + invalidUserNetwork.setDomain("invalidNetwork"); + + requestUpdateModel = restClient.authenticateUser(invalidUserNetwork).withCoreAPI().usingMe() + .updateSiteMembershipRequest(site, updatedMessage); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE}, executionType = ExecutionType.REGRESSION, + description = "Verify user is not able to update a deleted site membership request") + public void userCantUpdateSiteMembershipRequestForDeletedRequest() throws Exception + { + SiteModel moderatedSite = dataSite.usingUser(managerUser).createModeratedRandomSite(); + UserModel newMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser() + .addSiteMembershipRequest(moderatedSite); + + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser() + .deleteSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + requestUpdateModel = restClient.withCoreAPI().usingAuthUser() + .updateSiteMembershipRequest(moderatedSite, updatedMessage); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, newMember.getUsername(), moderatedSite.getId())); + } +} \ No newline at end of file From 856fac7edfdab81e98e8e0c3f8dbc2ea1b2ea3b4 Mon Sep 17 00:00:00 2001 From: cagache Date: Mon, 9 Oct 2017 16:31:57 +0300 Subject: [PATCH 1236/1491] REPO-2755 / REPO-2251: changed CORE and FULL groups with REGRESSION in networks package --- .../networks/RestGetNetworkCoreTests.java | 41 -- .../RestGetNetworkForPersonCoreTests.java | 88 ----- .../RestGetNetworkForPersonFullTests.java | 70 ---- ...java => RestGetNetworkForPersonTests.java} | 335 ++++++++++------ .../networks/RestGetNetworkFullTests.java | 101 ----- ...ityTests.java => RestGetNetworkTests.java} | 102 ++++- .../RestGetNetworksForPersonCoreTests.java | 80 ---- .../RestGetNetworksForPersonFullTests.java | 88 ----- ...ava => RestGetNetworksForPersonTests.java} | 373 +++++++++++------- 9 files changed, 533 insertions(+), 745 deletions(-) delete mode 100644 e2e-test/java/org/alfresco/rest/networks/RestGetNetworkCoreTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonCoreTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonFullTests.java rename e2e-test/java/org/alfresco/rest/networks/{RestGetNetworkForPersonSanityTests.java => RestGetNetworkForPersonTests.java} (52%) delete mode 100644 e2e-test/java/org/alfresco/rest/networks/RestGetNetworkFullTests.java rename e2e-test/java/org/alfresco/rest/networks/{RestGetNetworkSanityTests.java => RestGetNetworkTests.java} (66%) delete mode 100644 e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonCoreTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonFullTests.java rename e2e-test/java/org/alfresco/rest/networks/{RestGetNetworksForPersonSanityTests.java => RestGetNetworksForPersonTests.java} (50%) diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkCoreTests.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkCoreTests.java deleted file mode 100644 index cdb116035..000000000 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkCoreTests.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.alfresco.rest.networks; - -import org.alfresco.rest.RestTest; -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 Cristina Axinte - * - */ -public class RestGetNetworkCoreTests extends RestTest -{ - UserModel adminTenantUser; - UserModel tenantUser; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - UserModel adminuser = dataUser.getAdminUser(); - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminuser); - restClient.usingTenant().createTenant(adminTenantUser); - tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Verify tenant admin user gets non existing network with Rest API and checks the not found status") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.CORE }) - public void adminTenantChecksIfNonExistingNetworkIsNotFound() throws Exception - { - restClient.authenticateUser(adminTenantUser); - restClient.withCoreAPI().usingNetworks().getNetwork(UserModel.getRandomTenantUser()); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } -} diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonCoreTests.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonCoreTests.java deleted file mode 100644 index 7c5bab860..000000000 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonCoreTests.java +++ /dev/null @@ -1,88 +0,0 @@ -package org.alfresco.rest.networks; - -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestNetworkModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Tests for /people/{personId}/networks - */ -public class RestGetNetworkForPersonCoreTests extends RestTest -{ - UserModel adminUser; - UserModel adminTenantUser; - UserModel tenantUser; - UserModel randomTestUser; - RestNetworkModel restNetworkModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser); - restClient.usingTenant().createTenant(adminTenantUser); - tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - randomTestUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("randomTestUser"); - } - - @Bug(id = "needs to be checked") - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Verify getNetwork request status code is 200 if a user tries to get network information of another user") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.CORE }) - public void verifyGetNetworkByAUserForAnotherUser() throws Exception - { - restNetworkModel = restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().getNetwork(randomTestUser); - restClient.assertStatusCodeIs(HttpStatus.OK); - restNetworkModel.assertThat().field("id").is(tenantUser.getDomain()); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that getNetwork status code is 404 for a personId that does not exist") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.CORE }) - public void verifyThatGetNetworkStatusIs404ForAPersonIdThatDoesNotExist() throws Exception - { - UserModel invalidUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("validUsername"); - invalidUser.setUsername("invalidUsername"); - - restClient.authenticateUser(adminTenantUser).withCoreAPI().usingUser(invalidUser).getNetwork(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, invalidUser.getUsername())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that getNetwork status code is 404 for a networkId that does not exist") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.CORE }) - public void verifyThatGetNetworkStatusIs404ForANetworkIdThatDoesNotExist() throws Exception - { - UserModel invalidUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("invalidNetworkId"); - invalidUser.setDomain("invalidNetworkId"); - - restClient.authenticateUser(adminTenantUser).withCoreAPI().usingUser(invalidUser).getNetwork(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, invalidUser.getUsername())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Verify getNetwork request that is made using -me- instead of personId") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.CORE }) - public void verifyGetNetworkRequestUsingMeInsteadOfPersonId() throws Exception - { - restClient.authenticateUser(adminTenantUser).withCoreAPI().usingMe().getNetwork(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonFullTests.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonFullTests.java deleted file mode 100644 index 3ce6393f9..000000000 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonFullTests.java +++ /dev/null @@ -1,70 +0,0 @@ -package org.alfresco.rest.networks; - -import java.util.ArrayList; - -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestNetworkModel; -import org.alfresco.rest.model.RestNetworkQuotaModel; -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; - -/** - * Tests for /people/{personId}/networks - */ -public class RestGetNetworkForPersonFullTests extends RestTest -{ - UserModel adminUser; - UserModel adminTenantUser; - UserModel secondAdminTenantUser; - UserModel tenantUser; - RestNetworkModel restNetworkModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - adminTenantUser = UserModel.getAdminTenantUser(); - secondAdminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser); - restClient.usingTenant().createTenant(secondAdminTenantUser); - tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Verify getNetwork request response entry details") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.FULL }) - public void verifyGetNetworkRequestResponseEntryDetails() throws Exception - { - restNetworkModel = restClient.authenticateUser(adminTenantUser).withCoreAPI().usingMe().getNetwork(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restNetworkModel.assertThat().field("quotas").is(new ArrayList()) - .assertThat().field("isEnabled").is("true") - .assertThat().field("homeNetwork").is("true") - .assertThat().field("id").is(adminTenantUser.getDomain().toLowerCase()); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that properties parameter is applied to getNetwork request") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.FULL }) - public void verifyPropertiesParameterIsAppliedToGetNetworkRequest() throws Exception - { - restNetworkModel = restClient.authenticateUser(adminTenantUser).withParams("properties=id").withCoreAPI().usingMe().getNetwork(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restNetworkModel.assertThat().field("id").is(adminTenantUser.getDomain().toLowerCase()); - // TODO add assert that entry has only 1 field - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Verify getNetwork request status code is 404 for a network to which user does not belong") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.FULL }) - public void verifyGetNetworkRequestStatusCodeIs404ForANetworkToWhichTheUserDoesNotBelong() throws Exception - { - restClient.authenticateUser(adminTenantUser).withCoreAPI().usingAuthUser().getNetwork(secondAdminTenantUser); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } -} diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonTests.java similarity index 52% rename from e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java rename to e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonTests.java index 908d7991f..11d744596 100644 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonTests.java @@ -1,125 +1,210 @@ -package org.alfresco.rest.networks; - -import org.alfresco.rest.RestTest; -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.report.Bug; -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; - -/** - * Tests for /people/{personId}/networks - */ -public class RestGetNetworkForPersonSanityTests extends RestTest -{ - UserModel adminUserModel; - UserModel adminTenantUser; - UserModel tenantUser; - UserModel tenantSiteManager; - UserModel tenantSiteCollaborator; - UserModel tenantSiteContributor; - UserModel tenantSiteConsumer; - SiteModel tenantSite; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUserModel); - restClient.usingTenant().createTenant(adminTenantUser); - tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - tenantSiteManager = dataUser.usingUser(adminTenantUser).createUserWithTenant("tenantSiteManager"); - tenantSiteCollaborator = dataUser.usingUser(adminTenantUser).createUserWithTenant("tenantSiteCollaborator"); - tenantSiteContributor = dataUser.usingUser(adminTenantUser).createUserWithTenant("tenantSiteContributor"); - tenantSiteConsumer = dataUser.usingUser(adminTenantUser).createUserWithTenant("tenantSiteConsumer"); - tenantSite = dataSite.usingUser(tenantSiteManager).createPublicRandomSite(); - dataUser.usingUser(tenantSiteManager).addUserToSite(tenantSiteCollaborator, tenantSite, UserRole.SiteCollaborator); - dataUser.usingUser(tenantSiteManager).addUserToSite(tenantSiteContributor, tenantSite, UserRole.SiteContributor); - dataUser.usingUser(tenantSiteManager).addUserToSite(tenantSiteConsumer, tenantSite, UserRole.SiteConsumer); - } - - @Bug(id = "MNT-16904") - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, - description = "Verify non existing user gets another existing network with Rest API and checks the forbidden status") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) - public void nonExistingTenantUserIsNotAuthorizedToRequest() throws Exception - { - UserModel tenantUser = new UserModel("nonexisting", "password"); - tenantUser.setDomain(adminTenantUser.getDomain()); - restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().getNetwork(adminTenantUser); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, - description = "Verify tenant admin user gets specific network with Rest API and response is not empty") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) - public void adminTenantChecksIfNetworkIsPresent() throws Exception - { - restClient.authenticateUser(adminTenantUser).withCoreAPI().usingUser(adminTenantUser).getNetwork(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Bug(id = "needs to be checked") - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, - description = "Verify tenant user check network of admin user with Rest API") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) - public void tenantUserIsNotAuthorizedToCheckNetworkOfAdminUser() throws Exception - { - restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().getNetwork(adminTenantUser); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, - description = "Verify admin tenant user is not authorized to check network of another user with Rest API and checks the forbidden status") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) - public void adminTenantUserIsNotAuthorizedToCheckNetworkOfAnotherUser() throws Exception - { - UserModel secondAdminTenantUser = UserModel.getAdminTenantUser(); - restClient.usingTenant().createTenant(secondAdminTenantUser); - UserModel secondTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("anotherTenant"); - restClient.authenticateUser(adminTenantUser).withCoreAPI().usingAuthUser().getNetwork(secondTenantUser); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, - description = "Verify site manager user gets specific network with Rest API and response is not empty") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) - public void siteManagerChecksIfNetworkIsPresent() throws Exception - { - restClient.authenticateUser(tenantSiteManager).withCoreAPI().usingAuthUser().getNetwork(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, - description = "Verify site collaborator user gets specific network with Rest API and response is not empty") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) - public void siteCollaboratorChecksIfNetworkIsPresent() throws Exception - { - restClient.authenticateUser(tenantSiteCollaborator).withCoreAPI().usingAuthUser().getNetwork(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, - description = "Verify site contributor user gets specific network with Rest API and response is not empty") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) - public void siteContributorChecksIfNetworkIsPresent() throws Exception - { - restClient.authenticateUser(tenantSiteContributor).withCoreAPI().usingAuthUser().getNetwork(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, - description = "Verify site consumer user gets specific network with Rest API and response is not empty") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) - public void siteConsumerChecksIfNetworkIsPresent() throws Exception - { - restClient.authenticateUser(tenantSiteConsumer).withCoreAPI().usingAuthUser().getNetwork(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } -} +package org.alfresco.rest.networks; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestNetworkModel; +import org.alfresco.rest.model.RestNetworkQuotaModel; +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.report.Bug; +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; + +import java.util.ArrayList; + +/** + * Tests for /people/{personId}/networks + */ +public class RestGetNetworkForPersonTests extends RestTest +{ + UserModel adminUserModel; + UserModel adminTenantUser; + UserModel tenantUser; + UserModel tenantSiteManager; + UserModel tenantSiteCollaborator; + UserModel tenantSiteContributor; + UserModel tenantSiteConsumer; + SiteModel tenantSite; + RestNetworkModel restNetworkModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUserModel); + restClient.usingTenant().createTenant(adminTenantUser); + tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + tenantSiteManager = dataUser.usingUser(adminTenantUser).createUserWithTenant("tenantSiteManager"); + tenantSiteCollaborator = dataUser.usingUser(adminTenantUser).createUserWithTenant("tenantSiteCollaborator"); + tenantSiteContributor = dataUser.usingUser(adminTenantUser).createUserWithTenant("tenantSiteContributor"); + tenantSiteConsumer = dataUser.usingUser(adminTenantUser).createUserWithTenant("tenantSiteConsumer"); + tenantSite = dataSite.usingUser(tenantSiteManager).createPublicRandomSite(); + dataUser.usingUser(tenantSiteManager).addUserToSite(tenantSiteCollaborator, tenantSite, UserRole.SiteCollaborator); + dataUser.usingUser(tenantSiteManager).addUserToSite(tenantSiteContributor, tenantSite, UserRole.SiteContributor); + dataUser.usingUser(tenantSiteManager).addUserToSite(tenantSiteConsumer, tenantSite, UserRole.SiteConsumer); + } + + @Bug(id = "MNT-16904") + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify non existing user gets another existing network with Rest API and checks the forbidden status") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) + public void nonExistingTenantUserIsNotAuthorizedToRequest() throws Exception + { + UserModel tenantUser = new UserModel("nonexisting", "password"); + tenantUser.setDomain(adminTenantUser.getDomain()); + restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().getNetwork(adminTenantUser); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, + description = "Verify tenant admin user gets specific network with Rest API and response is not empty") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) + public void adminTenantChecksIfNetworkIsPresent() throws Exception + { + restClient.authenticateUser(adminTenantUser).withCoreAPI().usingUser(adminTenantUser).getNetwork(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Bug(id = "needs to be checked") + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify tenant user check network of admin user with Rest API") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) + public void tenantUserIsNotAuthorizedToCheckNetworkOfAdminUser() throws Exception + { + restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().getNetwork(adminTenantUser); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify admin tenant user is not authorized to check network of another user with Rest API and checks the forbidden status") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) + public void adminTenantUserIsNotAuthorizedToCheckNetworkOfAnotherUser() throws Exception + { + UserModel secondAdminTenantUser = UserModel.getAdminTenantUser(); + restClient.usingTenant().createTenant(secondAdminTenantUser); + UserModel secondTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("anotherTenant"); + restClient.authenticateUser(adminTenantUser).withCoreAPI().usingAuthUser().getNetwork(secondTenantUser); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, + description = "Verify site manager user gets specific network with Rest API and response is not empty") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) + public void siteManagerChecksIfNetworkIsPresent() throws Exception + { + restClient.authenticateUser(tenantSiteManager).withCoreAPI().usingAuthUser().getNetwork(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify site collaborator user gets specific network with Rest API and response is not empty") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) + public void siteCollaboratorChecksIfNetworkIsPresent() throws Exception + { + restClient.authenticateUser(tenantSiteCollaborator).withCoreAPI().usingAuthUser().getNetwork(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify site contributor user gets specific network with Rest API and response is not empty") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) + public void siteContributorChecksIfNetworkIsPresent() throws Exception + { + restClient.authenticateUser(tenantSiteContributor).withCoreAPI().usingAuthUser().getNetwork(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify site consumer user gets specific network with Rest API and response is not empty") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) + public void siteConsumerChecksIfNetworkIsPresent() throws Exception + { + restClient.authenticateUser(tenantSiteConsumer).withCoreAPI().usingAuthUser().getNetwork(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Bug(id = "needs to be checked") + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify getNetwork request status code is 200 if a user tries to get network information of another user") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) + public void verifyGetNetworkByAUserForAnotherUser() throws Exception + { + UserModel randomTestUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("randomTestUser"); + restNetworkModel = restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().getNetwork(randomTestUser); + restClient.assertStatusCodeIs(HttpStatus.OK); + restNetworkModel.assertThat().field("id").is(tenantUser.getDomain()); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that getNetwork status code is 404 for a personId that does not exist") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) + public void verifyThatGetNetworkStatusIs404ForAPersonIdThatDoesNotExist() throws Exception + { + UserModel invalidUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("validUsername"); + invalidUser.setUsername("invalidUsername"); + + restClient.authenticateUser(adminTenantUser).withCoreAPI().usingUser(invalidUser).getNetwork(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, invalidUser.getUsername())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that getNetwork status code is 404 for a networkId that does not exist") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) + public void verifyThatGetNetworkStatusIs404ForANetworkIdThatDoesNotExist() throws Exception + { + UserModel invalidUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("invalidNetworkId"); + invalidUser.setDomain("invalidNetworkId"); + + restClient.authenticateUser(adminTenantUser).withCoreAPI().usingUser(invalidUser).getNetwork(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, invalidUser.getUsername())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify getNetwork request that is made using -me- instead of personId") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) + public void verifyGetNetworkRequestUsingMeInsteadOfPersonId() throws Exception + { + restNetworkModel = restClient.authenticateUser(adminTenantUser).withCoreAPI().usingMe().getNetwork(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restNetworkModel.assertThat().field("quotas").is(new ArrayList()) + .assertThat().field("isEnabled").is("true") + .assertThat().field("homeNetwork").is("true") + .assertThat().field("id").is(adminTenantUser.getDomain().toLowerCase()); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that properties parameter is applied to getNetwork request") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) + public void verifyPropertiesParameterIsAppliedToGetNetworkRequest() throws Exception + { + restNetworkModel = restClient.authenticateUser(adminTenantUser).withParams("properties=id").withCoreAPI().usingMe().getNetwork(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restNetworkModel.assertThat().field("id").is(adminTenantUser.getDomain().toLowerCase()); + restNetworkModel.assertThat().fieldsCount().is(1); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify getNetwork request status code is 404 for a network to which user does not belong") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) + public void verifyGetNetworkRequestStatusCodeIs404ForANetworkToWhichTheUserDoesNotBelong() throws Exception + { + UserModel secondAdminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUserModel).usingTenant().createTenant(secondAdminTenantUser); + restClient.authenticateUser(adminTenantUser).withCoreAPI().usingAuthUser().getNetwork(secondAdminTenantUser); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } +} diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkFullTests.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkFullTests.java deleted file mode 100644 index 4b39e7d72..000000000 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkFullTests.java +++ /dev/null @@ -1,101 +0,0 @@ -package org.alfresco.rest.networks; - -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestNetworkModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.json.JSONException; -import org.json.JSONObject; -import org.springframework.http.HttpStatus; -import org.testng.Assert; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * - * @author Cristina Axinte - * - */ -public class RestGetNetworkFullTests extends RestTest -{ - UserModel adminTenantUser, adminuser; - UserModel adminAnotherTenantUser; - SiteModel site; - UserModel tenantUser; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminuser = dataUser.getAdminUser(); - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminuser); - restClient.usingTenant().createTenant(adminTenantUser); - - adminAnotherTenantUser = UserModel.getAdminTenantUser(); - restClient.usingTenant().createTenant(adminAnotherTenantUser); - - tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("userTenant1"); - site = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); - } - - @Bug(id = "ACE-5738") - @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Verify tenant admin user gets an invalid network with Rest API and checks the not found status") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.FULL }) - public void adminTenantGetsInvalidNetwork() throws Exception - { - restClient.authenticateUser(adminAnotherTenantUser); - adminAnotherTenantUser.setDomain("tenant.@%"); - - restClient.withCoreAPI().usingNetworks().getNetwork(adminAnotherTenantUser); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.UNEXPECTED_TENANT, adminTenantUser.getDomain(), "@")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Bug(id = "ACE-5745") - @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Verify admin user gets an existing network successfully with Rest API") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.FULL }) - public void adminUserGetsExistingNetwork() throws Exception - { - RestNetworkModel restNetworkModel = restClient.authenticateUser(adminuser).withCoreAPI().usingNetworks().getNetwork(adminTenantUser); - restClient.assertStatusCodeIs(HttpStatus.OK); - restNetworkModel.assertThat().fieldsCount().is("1"); - restNetworkModel.assertThat().field("id").is(adminTenantUser.getDomain()) - .and().field("homeNetwork").isNull() - .and().field("isEnabled").is("true"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Verify tenant admin user gets network using properties parameter successfully with Rest API") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.FULL }) - public void adminTenantGetsNetworkUsingPropertiesParameter() throws Exception - { - JSONObject entryResponse= restClient.authenticateUser(tenantUser).withCoreAPI().usingNetworks().usingParams("properties=id").getNetworkWithParams(adminTenantUser); - restClient.assertStatusCodeIs(HttpStatus.OK); - Assert.assertTrue(entryResponse.get("id").equals(adminTenantUser.getDomain().toLowerCase())); - assertJsonResponseDoesnotContainField(entryResponse, "homeNetwork"); - assertJsonResponseDoesnotContainField(entryResponse, "isEnabled"); - } - - private void assertJsonResponseDoesnotContainField(JSONObject entryResponse, String field) - { - try{ - entryResponse.get(field); - } - catch(JSONException ex) - { - Assert.assertTrue(ex.getMessage().equals(String.format("JSONObject[\"%s\"] not found.", field))); - } - } - - -} diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkSanityTests.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkTests.java similarity index 66% rename from e2e-test/java/org/alfresco/rest/networks/RestGetNetworkSanityTests.java rename to e2e-test/java/org/alfresco/rest/networks/RestGetNetworkTests.java index a56e2cc0b..fb4b99c3c 100644 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkTests.java @@ -1,6 +1,8 @@ package org.alfresco.rest.networks; import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestNetworkModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; @@ -8,24 +10,28 @@ import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; +import org.json.JSONException; +import org.json.JSONObject; import org.springframework.http.HttpStatus; +import org.testng.Assert; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; /** * Created by Cristina Axinte on 9/26/2016. */ -public class RestGetNetworkSanityTests extends RestTest +public class RestGetNetworkTests extends RestTest { UserModel adminTenantUser; UserModel adminAnotherTenantUser; SiteModel site; UserModel tenantUser; + UserModel adminuser; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception { - UserModel adminuser = dataUser.getAdminUser(); + adminuser = dataUser.getAdminUser(); adminTenantUser = UserModel.getAdminTenantUser(); restClient.authenticateUser(adminuser); restClient.usingTenant().createTenant(adminTenantUser); @@ -68,9 +74,9 @@ public class RestGetNetworkSanityTests extends RestTest restClient.withCoreAPI().usingNetworks().getNetwork().assertNetworkHasName(adminTenantUser).assertNetworkIsEnabled(); } - @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, description = "Verify tenant admin user gets another existing network with Rest API and checks the forbidden status") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) public void adminTenantChecksIfAnotherExistingNetworkIsForbidden() throws Exception { restClient.authenticateUser(adminTenantUser); @@ -97,9 +103,9 @@ public class RestGetNetworkSanityTests extends RestTest restClient.withCoreAPI().usingNetworks().getNetwork(adminTenantUser).assertNetworkHasName(adminTenantUser).assertNetworkIsEnabled(); } - @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, description = "Verify any tenant user gets non existing network with Rest API and checks the not found status") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) public void userTenantChecksIfNonExistingNetworkIsNotFound() throws Exception { restClient.authenticateUser(tenantUser); @@ -107,9 +113,9 @@ public class RestGetNetworkSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); } - @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, description = "Verify any tenant user gets another existing network with Rest API and checks the forbidden status") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) public void userTenantChecksIfAnotherExistingNetworkIsForbidden() throws Exception { restClient.authenticateUser(tenantUser); @@ -117,9 +123,9 @@ public class RestGetNetworkSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); } - @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, description = "Verify manager tenant user gets its network with Rest API and response is not empty") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) public void tenantManagerUserChecksIfNetworkIsPresent() throws Exception { UserModel managerTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("manTenant"); @@ -130,9 +136,9 @@ public class RestGetNetworkSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, description = "Verify collaborator tenant user gets its network with Rest API and response is not empty") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) public void tenantCollaboratorUserChecksIfNetworkIsPresent() throws Exception { UserModel collaboratorTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("colTenant"); @@ -143,9 +149,9 @@ public class RestGetNetworkSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, description = "Verify consumer tenant user gets its network with Rest API and response is not empty") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) public void tenantConsumerUserChecksIfNetworkIsPresent() throws Exception { UserModel consumerTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("consTenant"); @@ -156,9 +162,9 @@ public class RestGetNetworkSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, description = "Verify contributor tenant user gets its network with Rest API and response is not empty") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) public void tenantContributorUserChecksIfItsNetworkIsPresent() throws Exception { UserModel contributorTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("contTenant"); @@ -168,4 +174,68 @@ public class RestGetNetworkSanityTests extends RestTest restClient.withCoreAPI().usingNetworks().getNetwork(adminTenantUser); restClient.assertStatusCodeIs(HttpStatus.OK); } + + @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify tenant admin user gets non existing network with Rest API and checks the not found status") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) + public void adminTenantChecksIfNonExistingNetworkIsNotFound() throws Exception + { + restClient.authenticateUser(adminTenantUser); + restClient.withCoreAPI().usingNetworks().getNetwork(UserModel.getRandomTenantUser()); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } + + @Bug(id = "ACE-5738") + @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify tenant admin user gets an invalid network with Rest API and checks the not found status") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) + public void adminTenantGetsInvalidNetwork() throws Exception + { + restClient.authenticateUser(adminAnotherTenantUser); + adminAnotherTenantUser.setDomain("tenant.@%"); + + restClient.withCoreAPI().usingNetworks().getNetwork(adminAnotherTenantUser); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.UNEXPECTED_TENANT, adminTenantUser.getDomain(), "@")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Bug(id = "ACE-5745") + @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify admin user gets an existing network successfully with Rest API") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) + public void adminUserGetsExistingNetwork() throws Exception + { + RestNetworkModel restNetworkModel = restClient.authenticateUser(adminuser).withCoreAPI().usingNetworks().getNetwork(adminTenantUser); + restClient.assertStatusCodeIs(HttpStatus.OK); + restNetworkModel.assertThat().fieldsCount().is("1"); + restNetworkModel.assertThat().field("id").is(adminTenantUser.getDomain()) + .and().field("homeNetwork").isNull() + .and().field("isEnabled").is("true"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify tenant admin user gets network using properties parameter successfully with Rest API") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) + public void adminTenantGetsNetworkUsingPropertiesParameter() throws Exception + { + JSONObject entryResponse= restClient.authenticateUser(tenantUser).withCoreAPI().usingNetworks().usingParams("properties=id").getNetworkWithParams(adminTenantUser); + restClient.assertStatusCodeIs(HttpStatus.OK); + Assert.assertTrue(entryResponse.get("id").equals(adminTenantUser.getDomain().toLowerCase())); + assertJsonResponseDoesnotContainField(entryResponse, "homeNetwork"); + assertJsonResponseDoesnotContainField(entryResponse, "isEnabled"); + } + + private void assertJsonResponseDoesnotContainField(JSONObject entryResponse, String field) + { + try{ + entryResponse.get(field); + } + catch(JSONException ex) + { + Assert.assertTrue(ex.getMessage().equals(String.format("JSONObject[\"%s\"] not found.", field))); + } + } } diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonCoreTests.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonCoreTests.java deleted file mode 100644 index 8f1bd55fe..000000000 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonCoreTests.java +++ /dev/null @@ -1,80 +0,0 @@ -package org.alfresco.rest.networks; - -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestNetworkModelsCollection; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class RestGetNetworksForPersonCoreTests extends RestTest -{ - private UserModel adminUserModel; - UserModel adminTenantUser; - UserModel tenantUser; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUserModel); - restClient.usingTenant().createTenant(adminTenantUser); - tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Get tenant user networks using invalid value for skipCount") - @Test(groups = {TestGroup.REST_API, TestGroup.CORE, TestGroup.NETWORKS }) - public void invalidValueForSkipCountTest() throws Exception - { - restClient.authenticateUser(adminTenantUser).withParams("skipCount=abc").withCoreAPI().usingAuthUser().getNetworks(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "abc")); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Get tenant user networks using invalid value for maxItems") - @Test(groups = {TestGroup.REST_API, TestGroup.CORE, TestGroup.NETWORKS }) - public void invalidValueForMaxItemsTest() throws Exception - { - restClient.authenticateUser(adminTenantUser).withParams("maxItems=abc").withCoreAPI().usingAuthUser().getNetworks(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "abc")); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Get tenant user networks using personId that does not exist") - @Test(groups = {TestGroup.REST_API, TestGroup.CORE, TestGroup.NETWORKS }) - public void inexistentTenantTest() throws Exception - { - restClient.authenticateUser(adminTenantUser).withCoreAPI().usingUser(new UserModel("invalidTenantUser", "password")).getNetworks(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidTenantUser")); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Get tenant user networks using -me- instead of personId") - @Test(groups = {TestGroup.REST_API, TestGroup.CORE, TestGroup.NETWORKS }) - public void specifyMeInsteadOfPersonIdTest() throws Exception - { - RestNetworkModelsCollection networks = restClient.authenticateUser(adminTenantUser).withCoreAPI().usingMe().getNetworks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - networks.getOneRandomEntry().onModel().assertNetworkIsEnabled().and().field("id").is(adminTenantUser.getDomain().toLowerCase()); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Get tenant user networks and validate network entry") - @Test(groups = {TestGroup.REST_API, TestGroup.CORE, TestGroup.NETWORKS }) - public void checkNetworkEntryTest() throws Exception - { - RestNetworkModelsCollection networks = restClient.authenticateUser(adminTenantUser).withCoreAPI().usingAuthUser().getNetworks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - networks.getOneRandomEntry().onModel().assertNetworkIsEnabled() - .and().field("id").is(adminTenantUser.getDomain().toLowerCase()) - .and().field("quotas").is("[]") - .and().field("homeNetwork").is("false"); - } - -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonFullTests.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonFullTests.java deleted file mode 100644 index 6a4232416..000000000 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonFullTests.java +++ /dev/null @@ -1,88 +0,0 @@ -package org.alfresco.rest.networks; - -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestNetworkModelsCollection; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class RestGetNetworksForPersonFullTests extends RestTest -{ - private UserModel adminUserModel; - private UserModel adminTenantUser; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUserModel); - restClient.usingTenant().createTenant(adminTenantUser); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Check default error schema for get networks for member") - @Test(groups = { TestGroup.REST_API, TestGroup.FULL, TestGroup.NETWORKS }) - public void getNetworksAndCheckErrorSchema() throws Exception - { - restClient.authenticateUser(adminTenantUser).withCoreAPI().usingUser(new UserModel("invalidUser", "invalidPassword")).getNetworks(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidUser")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Check default error schema for get networks for member") - @Test(groups = { TestGroup.REST_API, TestGroup.FULL, TestGroup.NETWORKS }) - public void getNetworksAndCheckPropertiesParameter() throws Exception - { - RestNetworkModelsCollection networks = restClient.authenticateUser(adminTenantUser).withParams("properties=isEnabled,id").withCoreAPI().usingAuthUser().getNetworks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - networks.getOneRandomEntry().onModel().assertThat().field("homeNetwork").is("false") - .and().field("quotas").isNull() - .and().field("isEnabled").is("true") - .and().field("id").is(adminTenantUser.getDomain().toLowerCase()); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Check that skipCount parameter is applied") - @Test(groups = { TestGroup.REST_API, TestGroup.FULL, TestGroup.NETWORKS }) - public void checkThatSkipCountParameterIsApplied() throws Exception - { - RestNetworkModelsCollection networks = restClient.authenticateUser(adminTenantUser).withParams("skipCount=1").withCoreAPI().usingAuthUser().getNetworks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - networks.assertThat().entriesListIsEmpty(); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Check that high skipCount parameter is applied") - @Test(groups = { TestGroup.REST_API, TestGroup.FULL, TestGroup.NETWORKS }) - public void checkThatHighSkipCountParameterIsApplied() throws Exception - { - RestNetworkModelsCollection networks = restClient.authenticateUser(adminTenantUser).withParams("skipCount=100").withCoreAPI().usingAuthUser().getNetworks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - networks.assertThat().entriesListIsEmpty(); - networks.assertThat().paginationField("skipCount").is("100"); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Check that maxItems parameter is applied") - @Test(groups = { TestGroup.REST_API, TestGroup.FULL, TestGroup.NETWORKS }) - public void checkThatMaxItemsParameterIsApplied() throws Exception - { - RestNetworkModelsCollection networks = restClient.authenticateUser(adminTenantUser).withParams("maxItems=1").withCoreAPI().usingAuthUser().getNetworks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - networks.getOneRandomEntry().onModel().assertThat().field("homeNetwork").is("false") - .and().field("quotas").is("[]") - .and().field("isEnabled").is("true") - .and().field("id").is(adminTenantUser.getDomain().toLowerCase()); - networks.assertThat().paginationField("maxItems").is("1"); - } - -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonSanityTests.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonTests.java similarity index 50% rename from e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonSanityTests.java rename to e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonTests.java index 4f46e7402..0bb738882 100644 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonTests.java @@ -1,137 +1,238 @@ -package org.alfresco.rest.networks; - -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestNetworkModelsCollection; -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.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class RestGetNetworksForPersonSanityTests extends RestTest -{ - private UserModel adminUserModel; - private UserModel adminTenantUser; - private UserModel tenantUser; - private SiteModel siteModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUserModel); - restClient.usingTenant().createTenant(adminTenantUser); - tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); - } - - @Bug(id = "MNT-16904") - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, - description = "Verify non existing user gets another exisiting network with Rest API and checks the unauthorized status") - @Test(groups = { TestGroup.REST_API, TestGroup.SANITY, TestGroup.NETWORKS }) - public void nonExistingTenantUserIsNotAuthorizedToRequest() throws Exception - { - UserModel tenantUser = new UserModel("nonexisting", "password"); - tenantUser.setDomain(adminTenantUser.getDomain()); - restClient.authenticateUser(tenantUser); - restClient.withCoreAPI().usingAuthUser().getNetworks(adminTenantUser); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, - description = "Verify tenant admin user gets specific network with Rest API and response is not empty") - @Test(groups = {TestGroup.REST_API, TestGroup.SANITY, TestGroup.NETWORKS }) - public void adminTenantChecksIfNetworkIsPresent() throws Exception - { - restClient.authenticateUser(adminTenantUser); - restClient.withCoreAPI().usingAuthUser().getNetworks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, - description = "Verify tenant user is not authorized to check network of admin user with Rest API and checks the forbidden status") - @Test(groups = {TestGroup.REST_API, TestGroup.SANITY, TestGroup.NETWORKS }) - public void tenantUserIsNotAuthorizedToCheckNetworkOfAdminUser() throws Exception - { - restClient.authenticateUser(tenantUser); - restClient.withCoreAPI().usingAuthUser().getNetworks(adminTenantUser); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, - description = "Verify admin tenant user is not authorized to check network of another user with Rest API and checks the forbidden status") - @Test(groups = {TestGroup.REST_API, TestGroup.SANITY, TestGroup.NETWORKS }) - public void adminTenantUserIsNotAuthorizedToCheckNetworkOfAnotherUser() throws Exception - { - UserModel secondAdminTenantUser = UserModel.getAdminTenantUser(); - restClient.usingTenant().createTenant(secondAdminTenantUser); - UserModel secondTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("anotherTenant"); - restClient.authenticateUser(secondAdminTenantUser); - restClient.withCoreAPI().usingAuthUser().getNetworks(secondTenantUser); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, - description = "Verify tenant manager user gets specific network with Rest API and response is not empty") - @Test(groups = {TestGroup.REST_API, TestGroup.SANITY, TestGroup.NETWORKS }) - public void managerTenantChecksIfNetworkIsPresent() throws Exception - { - UserModel managerTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("managerTenant"); - dataUser.usingUser(adminTenantUser).addUserToSite(managerTenantUser, siteModel, UserRole.SiteManager); - - restClient.authenticateUser(managerTenantUser); - RestNetworkModelsCollection networks = restClient.withCoreAPI().usingAuthUser().getNetworks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - networks.getOneRandomEntry().onModel().assertNetworkIsEnabled().and().field("id").is(managerTenantUser.getDomain().toLowerCase()); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, - description = "Verify tenant collaborator user gets specific network with Rest API and response is not empty") - @Test(groups = {TestGroup.REST_API, TestGroup.SANITY, TestGroup.NETWORKS }) - public void collaboratorTenantChecksIfNetworkIsPresent() throws Exception - { - UserModel collaboratorTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("collaboratorTenant"); - dataUser.usingUser(adminTenantUser).addUserToSite(collaboratorTenantUser, siteModel, UserRole.SiteCollaborator); - - restClient.authenticateUser(collaboratorTenantUser); - RestNetworkModelsCollection networks = restClient.withCoreAPI().usingAuthUser().getNetworks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - networks.getOneRandomEntry().onModel().assertNetworkIsEnabled().and().field("id").is(collaboratorTenantUser.getDomain().toLowerCase()); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, - description = "Verify tenant contributor user gets specific network with Rest API and response is not empty") - @Test(groups = {TestGroup.REST_API, TestGroup.SANITY, TestGroup.NETWORKS }) - public void contributorTenantChecksIfNetworkIsPresent() throws Exception - { - UserModel contributorTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("contributorTenant"); - dataUser.usingUser(adminTenantUser).addUserToSite(contributorTenantUser, siteModel, UserRole.SiteContributor); - - restClient.authenticateUser(contributorTenantUser); - RestNetworkModelsCollection networks = restClient.withCoreAPI().usingAuthUser().getNetworks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - networks.getOneRandomEntry().onModel().assertNetworkIsEnabled().and().field("id").is(contributorTenantUser.getDomain().toLowerCase()); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, - description = "Verify tenant consumer user gets specific network with Rest API and response is not empty") - @Test(groups = {TestGroup.REST_API, TestGroup.SANITY, TestGroup.NETWORKS }) - public void consumerTenantChecksIfNetworkIsPresent() throws Exception - { - UserModel consumerTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("consumerTenant"); - dataUser.usingUser(adminTenantUser).addUserToSite(consumerTenantUser, siteModel, UserRole.SiteConsumer); - - restClient.authenticateUser(consumerTenantUser); - RestNetworkModelsCollection networks = restClient.withCoreAPI().usingAuthUser().getNetworks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - networks.getOneRandomEntry().onModel().assertNetworkIsEnabled().and().field("id").is(consumerTenantUser.getDomain().toLowerCase()); - } +package org.alfresco.rest.networks; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestNetworkModelsCollection; +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.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class RestGetNetworksForPersonTests extends RestTest +{ + private UserModel adminUserModel; + private UserModel adminTenantUser; + private UserModel tenantUser; + private SiteModel siteModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUserModel); + restClient.usingTenant().createTenant(adminTenantUser); + tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); + } + + @Bug(id = "MNT-16904") + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, + description = "Verify non existing user gets another exisiting network with Rest API and checks the unauthorized status") + @Test(groups = { TestGroup.REST_API, TestGroup.SANITY, TestGroup.NETWORKS }) + public void nonExistingTenantUserIsNotAuthorizedToRequest() throws Exception + { + UserModel tenantUser = new UserModel("nonexisting", "password"); + tenantUser.setDomain(adminTenantUser.getDomain()); + restClient.authenticateUser(tenantUser); + restClient.withCoreAPI().usingAuthUser().getNetworks(adminTenantUser); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, + description = "Verify tenant admin user gets specific network with Rest API and response is not empty") + @Test(groups = {TestGroup.REST_API, TestGroup.SANITY, TestGroup.NETWORKS }) + public void adminTenantChecksIfNetworkIsPresent() throws Exception + { + restClient.authenticateUser(adminTenantUser); + restClient.withCoreAPI().usingAuthUser().getNetworks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify tenant user is not authorized to check network of admin user with Rest API and checks the forbidden status") + @Test(groups = {TestGroup.REST_API, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void tenantUserIsNotAuthorizedToCheckNetworkOfAdminUser() throws Exception + { + restClient.authenticateUser(tenantUser); + restClient.withCoreAPI().usingAuthUser().getNetworks(adminTenantUser); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify admin tenant user is not authorized to check network of another user with Rest API and checks the forbidden status") + @Test(groups = {TestGroup.REST_API, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void adminTenantUserIsNotAuthorizedToCheckNetworkOfAnotherUser() throws Exception + { + UserModel secondAdminTenantUser = UserModel.getAdminTenantUser(); + restClient.usingTenant().createTenant(secondAdminTenantUser); + UserModel secondTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("anotherTenant"); + restClient.authenticateUser(secondAdminTenantUser); + restClient.withCoreAPI().usingAuthUser().getNetworks(secondTenantUser); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, + description = "Verify tenant manager user gets specific network with Rest API and response is not empty") + @Test(groups = {TestGroup.REST_API, TestGroup.SANITY, TestGroup.NETWORKS }) + public void managerTenantChecksIfNetworkIsPresent() throws Exception + { + UserModel managerTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("managerTenant"); + dataUser.usingUser(adminTenantUser).addUserToSite(managerTenantUser, siteModel, UserRole.SiteManager); + + restClient.authenticateUser(managerTenantUser); + RestNetworkModelsCollection networks = restClient.withCoreAPI().usingAuthUser().getNetworks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + networks.getOneRandomEntry().onModel().assertNetworkIsEnabled().and().field("id").is(managerTenantUser.getDomain().toLowerCase()); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify tenant collaborator user gets specific network with Rest API and response is not empty") + @Test(groups = {TestGroup.REST_API, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void collaboratorTenantChecksIfNetworkIsPresent() throws Exception + { + UserModel collaboratorTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("collaboratorTenant"); + dataUser.usingUser(adminTenantUser).addUserToSite(collaboratorTenantUser, siteModel, UserRole.SiteCollaborator); + + restClient.authenticateUser(collaboratorTenantUser); + RestNetworkModelsCollection networks = restClient.withCoreAPI().usingAuthUser().getNetworks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + networks.getOneRandomEntry().onModel().assertNetworkIsEnabled().and().field("id").is(collaboratorTenantUser.getDomain().toLowerCase()); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify tenant contributor user gets specific network with Rest API and response is not empty") + @Test(groups = {TestGroup.REST_API, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void contributorTenantChecksIfNetworkIsPresent() throws Exception + { + UserModel contributorTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("contributorTenant"); + dataUser.usingUser(adminTenantUser).addUserToSite(contributorTenantUser, siteModel, UserRole.SiteContributor); + + restClient.authenticateUser(contributorTenantUser); + RestNetworkModelsCollection networks = restClient.withCoreAPI().usingAuthUser().getNetworks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + networks.getOneRandomEntry().onModel().assertNetworkIsEnabled().and().field("id").is(contributorTenantUser.getDomain().toLowerCase()); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify tenant consumer user gets specific network with Rest API and response is not empty") + @Test(groups = {TestGroup.REST_API, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void consumerTenantChecksIfNetworkIsPresent() throws Exception + { + UserModel consumerTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("consumerTenant"); + dataUser.usingUser(adminTenantUser).addUserToSite(consumerTenantUser, siteModel, UserRole.SiteConsumer); + + restClient.authenticateUser(consumerTenantUser); + RestNetworkModelsCollection networks = restClient.withCoreAPI().usingAuthUser().getNetworks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + networks.getOneRandomEntry().onModel().assertNetworkIsEnabled().and().field("id").is(consumerTenantUser.getDomain().toLowerCase()); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Get tenant user networks using invalid value for skipCount") + @Test(groups = {TestGroup.REST_API, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void invalidValueForSkipCountTest() throws Exception + { + restClient.authenticateUser(adminTenantUser).withParams("skipCount=abc").withCoreAPI().usingAuthUser().getNetworks(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "abc")); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Get tenant user networks using invalid value for maxItems") + @Test(groups = {TestGroup.REST_API, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void invalidValueForMaxItemsTest() throws Exception + { + restClient.authenticateUser(adminTenantUser).withParams("maxItems=abc").withCoreAPI().usingAuthUser().getNetworks(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "abc")); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Get tenant user networks using personId that does not exist") + @Test(groups = {TestGroup.REST_API, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void inexistentTenantTest() throws Exception + { + restClient.authenticateUser(adminTenantUser).withCoreAPI().usingUser(new UserModel("invalidTenantUser", "password")).getNetworks(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidTenantUser")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Get tenant user networks using -me- instead of personId") + @Test(groups = {TestGroup.REST_API, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void specifyMeInsteadOfPersonIdTest() throws Exception + { + RestNetworkModelsCollection networks = restClient.authenticateUser(adminTenantUser).withCoreAPI().usingMe().getNetworks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + networks.getOneRandomEntry().onModel().assertNetworkIsEnabled().and().field("id").is(adminTenantUser.getDomain().toLowerCase()); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Get tenant user networks and validate network entry") + @Test(groups = {TestGroup.REST_API, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void checkNetworkEntryTest() throws Exception + { + RestNetworkModelsCollection networks = restClient.authenticateUser(adminTenantUser).withCoreAPI().usingAuthUser().getNetworks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + networks.getOneRandomEntry().onModel().assertNetworkIsEnabled() + .and().field("id").is(adminTenantUser.getDomain().toLowerCase()) + .and().field("quotas").is("[]") + .and().field("homeNetwork").is("false"); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Check default error schema for get networks for member") + @Test(groups = { TestGroup.REST_API, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void getNetworksAndCheckPropertiesParameter() throws Exception + { + RestNetworkModelsCollection networks = restClient.authenticateUser(adminTenantUser).withParams("properties=isEnabled,id").withCoreAPI().usingAuthUser().getNetworks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + networks.getOneRandomEntry().onModel().assertThat().field("homeNetwork").is("false") + .and().field("quotas").isNull() + .and().field("isEnabled").is("true") + .and().field("id").is(adminTenantUser.getDomain().toLowerCase()); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Check that skipCount parameter is applied") + @Test(groups = { TestGroup.REST_API, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void checkThatSkipCountParameterIsApplied() throws Exception + { + RestNetworkModelsCollection networks = restClient.authenticateUser(adminTenantUser).withParams("skipCount=1").withCoreAPI().usingAuthUser().getNetworks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + networks.assertThat().entriesListIsEmpty(); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Check that high skipCount parameter is applied") + @Test(groups = { TestGroup.REST_API, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void checkThatHighSkipCountParameterIsApplied() throws Exception + { + RestNetworkModelsCollection networks = restClient.authenticateUser(adminTenantUser).withParams("skipCount=100").withCoreAPI().usingAuthUser().getNetworks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + networks.assertThat().entriesListIsEmpty(); + networks.assertThat().paginationField("skipCount").is("100"); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Check that maxItems parameter is applied") + @Test(groups = { TestGroup.REST_API, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void checkThatMaxItemsParameterIsApplied() throws Exception + { + RestNetworkModelsCollection networks = restClient.authenticateUser(adminTenantUser).withParams("maxItems=1").withCoreAPI().usingAuthUser().getNetworks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + networks.getOneRandomEntry().onModel().assertThat().field("homeNetwork").is("false") + .and().field("quotas").is("[]") + .and().field("isEnabled").is("true") + .and().field("id").is(adminTenantUser.getDomain().toLowerCase()); + networks.assertThat().paginationField("maxItems").is("1"); + } } \ No newline at end of file From cdcb90c1ba7bc3ce9f21b32a2477b3af89af8558 Mon Sep 17 00:00:00 2001 From: cagache Date: Tue, 10 Oct 2017 10:38:48 +0300 Subject: [PATCH 1237/1491] REPO-2755 / REPO-2251: changed CORE and FULL groups with REGRESSION in tasks package --- .../alfresco/rest/FunctionalCasesTests.java | 38 +- .../rest/workflow/tasks/GetTaskCoreTests.java | 90 - .../tasks/GetTaskFormModelCoreTests.java | 104 - .../tasks/GetTaskFormModelSanityTests.java | 75 - ...lTests.java => GetTaskFormModelTests.java} | 133 +- .../rest/workflow/tasks/GetTaskFullTests.java | 143 -- .../workflow/tasks/GetTaskSanityTests.java | 120 -- .../rest/workflow/tasks/GetTaskTests.java | 263 +++ .../workflow/tasks/GetTasksCoreTests.java | 110 -- .../workflow/tasks/GetTasksFullTests.java | 150 -- .../workflow/tasks/GetTasksSanityTests.java | 110 -- .../rest/workflow/tasks/GetTasksTests.java | 292 +++ .../workflow/tasks/UpdateTaskCoreTests.java | 205 -- .../tasks/UpdateTaskCoreTestsBulk2.java | 362 ---- .../tasks/UpdateTaskCoreTestsBulk3.java | 128 -- .../tasks/UpdateTaskFullTestsBulk1.java | 742 ------- .../tasks/UpdateTaskFullTestsBulk2.java | 446 ----- .../workflow/tasks/UpdateTaskSanityTests.java | 104 - .../rest/workflow/tasks/UpdateTaskTests.java | 1722 +++++++++++++++++ .../GetTaskCandidatesCoreTests.java | 108 -- ... => GetTaskCandidatesRegressionTests.java} | 95 +- ...yTests.java => AddTaskItemTestsBulk1.java} | 22 +- ...eTests.java => AddTaskItemTestsBulk2.java} | 24 +- ...lTests.java => AddTaskItemTestsBulk3.java} | 11 +- .../tasks/items/GetTaskItemsCoreTests.java | 160 -- .../tasks/items/GetTaskItemsFullTests.java | 199 -- .../items/GetTaskItemsRegressionTests.java | 324 ++++ .../tasks/items/RemoveTaskItemCoreTests.java | 154 -- .../tasks/items/RemoveTaskItemFullTests.java | 97 - .../items/RemoveTaskItemSanityTests.java | 86 - .../tasks/items/RemoveTaskItemTests.java | 253 +++ ...s.java => AddTaskVariablesTestsBulk1.java} | 22 +- ...s.java => AddTaskVariablesTestsBulk2.java} | 34 +- ...s.java => AddTaskVariablesTestsBulk3.java} | 24 +- .../DeleteTaskVariableCoreTests.java | 126 -- .../DeleteTaskVariableSanityTests.java | 67 - ...ests.java => DeleteTaskVariableTests.java} | 141 +- .../variables/GetTaskVariablesCoreTests.java | 116 -- .../GetTaskVariablesSanityTests.java | 87 - ...lTests.java => GetTaskVariablesTests.java} | 143 +- ...java => UpdateTaskVariableTestsBulk1.java} | 6 +- ...java => UpdateTaskVariableTestsBulk2.java} | 22 +- ...java => UpdateTaskVariableTestsBulk3.java} | 26 +- 43 files changed, 3428 insertions(+), 4256 deletions(-) delete mode 100644 e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCoreTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelCoreTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelSanityTests.java rename e2e-test/java/org/alfresco/rest/workflow/tasks/{GetTaskFormModelFullTests.java => GetTaskFormModelTests.java} (56%) delete mode 100644 e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFullTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskSanityTests.java create mode 100644 e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksCoreTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksFullTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksSanityTests.java create mode 100644 e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTestsBulk2.java delete mode 100644 e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTestsBulk3.java delete mode 100644 e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk1.java delete mode 100644 e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk2.java delete mode 100644 e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskSanityTests.java create mode 100644 e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/workflow/tasks/candidates/GetTaskCandidatesCoreTests.java rename e2e-test/java/org/alfresco/rest/workflow/tasks/candidates/{GetTaskCandidatesFullTests.java => GetTaskCandidatesRegressionTests.java} (74%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/items/{AddTaskItemSanityTests.java => AddTaskItemTestsBulk1.java} (95%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/items/{AddTaskItemCoreTests.java => AddTaskItemTestsBulk2.java} (94%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/items/{AddTaskItemFullTests.java => AddTaskItemTestsBulk3.java} (98%) delete mode 100644 e2e-test/java/org/alfresco/rest/workflow/tasks/items/GetTaskItemsCoreTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/workflow/tasks/items/GetTaskItemsFullTests.java create mode 100644 e2e-test/java/org/alfresco/rest/workflow/tasks/items/GetTaskItemsRegressionTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/workflow/tasks/items/RemoveTaskItemCoreTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/workflow/tasks/items/RemoveTaskItemFullTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/workflow/tasks/items/RemoveTaskItemSanityTests.java create mode 100644 e2e-test/java/org/alfresco/rest/workflow/tasks/items/RemoveTaskItemTests.java rename e2e-test/java/org/alfresco/rest/workflow/tasks/variables/{AddTaskVariablesSanityTests.java => AddTaskVariablesTestsBulk1.java} (95%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/variables/{AddTaskVariablesCoreTests.java => AddTaskVariablesTestsBulk2.java} (95%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/variables/{AddTaskVariablesFullTests.java => AddTaskVariablesTestsBulk3.java} (96%) delete mode 100644 e2e-test/java/org/alfresco/rest/workflow/tasks/variables/DeleteTaskVariableCoreTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/workflow/tasks/variables/DeleteTaskVariableSanityTests.java rename e2e-test/java/org/alfresco/rest/workflow/tasks/variables/{DeleteTaskVariableFullTests.java => DeleteTaskVariableTests.java} (54%) delete mode 100644 e2e-test/java/org/alfresco/rest/workflow/tasks/variables/GetTaskVariablesCoreTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/workflow/tasks/variables/GetTaskVariablesSanityTests.java rename e2e-test/java/org/alfresco/rest/workflow/tasks/variables/{GetTaskVariablesFullTests.java => GetTaskVariablesTests.java} (55%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/variables/{UpdateTaskVariableSanityTests.java => UpdateTaskVariableTestsBulk1.java} (96%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/variables/{UpdateTaskVariableCoreTests.java => UpdateTaskVariableTestsBulk2.java} (95%) rename e2e-test/java/org/alfresco/rest/workflow/tasks/variables/{UpdateTaskVariableFullTests.java => UpdateTaskVariableTestsBulk3.java} (97%) diff --git a/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java b/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java index 2477c46df..ae2d5425b 100644 --- a/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java +++ b/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java @@ -59,7 +59,7 @@ public class FunctionalCasesTests extends RestTest * 3. Update it's role to Contributor * 4. Update it's role to Consumer */ - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Verify that manager is able to update manager with different roles and gets status code CREATED (201)") public void managerIsAbleToUpdateManagerWithDifferentRoles() throws Exception @@ -97,7 +97,7 @@ public class FunctionalCasesTests extends RestTest * 3. Update it's role to Collaborator * 4. Update it's role to Manager */ - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Verify that manager is able to update consumer with different roles and gets status code CREATED (201)") public void managerIsAbleToUpdateConsumerWithDifferentRoles() throws Exception @@ -137,7 +137,7 @@ public class FunctionalCasesTests extends RestTest */ @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Approve request, add site to favorites, then delete it from favorites") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) public void approveRequestAddAndDeleteSiteFromFavorites() throws Exception { UserModel newMember = dataUser.createRandomTestUser(); @@ -170,7 +170,7 @@ public class FunctionalCasesTests extends RestTest */ @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Reject request, add moderated site to favorites, create request again and approve it") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) public void rejectRequestAddModeratedSiteToFavorites() throws Exception { UserModel newMember = dataUser.createRandomTestUser(); @@ -205,7 +205,7 @@ public class FunctionalCasesTests extends RestTest * 1. Add file * 2. Check file is included in person activities list */ - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Add a file and check that activity is included in person activities") public void addFileThenGetPersonActivities() throws Exception @@ -223,7 +223,7 @@ public class FunctionalCasesTests extends RestTest * 1. Add a comment to a file * 2. Check that comment is included in person activities list */ - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Add a comment to a file and check that activity is included in person activities") public void addCommentThenGetPersonActivities() throws Exception @@ -242,7 +242,7 @@ public class FunctionalCasesTests extends RestTest * 1. Add file then delete it * 2. Check action is included in person activities list */ - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Add a file, delete it and check that activity is included in person activities") public void addFileDeleteItThenGetPersonActivities() throws Exception @@ -263,7 +263,7 @@ public class FunctionalCasesTests extends RestTest * 4. Get again comment details * 5. Delete comment */ - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Add comment to a file, then get comment details. Update it and check that get comment returns updated details. Delete comment then check that file has no comments.") @@ -297,7 +297,7 @@ public class FunctionalCasesTests extends RestTest * 2. Delete comment * 3. Post the same comment again */ - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Add a comment to a file, delete it, then added the same comment again.") @@ -334,7 +334,7 @@ public class FunctionalCasesTests extends RestTest * @throws Exception */ - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Create an user, join the user to a site and check that activity is included in person activities") public void joinUserToSiteThenGetPersonActivities() throws Exception @@ -357,7 +357,7 @@ public class FunctionalCasesTests extends RestTest */ @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify membership request by user after it was removed from site gets status code 404") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) public void userCanNotCreateMembershipRequestIfItWasRemovedFromPrivateSite() throws Exception { UserModel newMember = dataUser.createRandomTestUser(); @@ -384,7 +384,7 @@ public class FunctionalCasesTests extends RestTest */ @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user can be added back after if was removed from site") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) public void userCanBeAddedAfterItWasRemovedFromSite() throws Exception { UserModel newMember = dataUser.createRandomTestUser(); @@ -415,7 +415,7 @@ public class FunctionalCasesTests extends RestTest */ @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Check that a comment of a document was also removed after deleting the document") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) public void checkTheCommentOfADocumentThatWasDeletedDoesNotExist() throws Exception { file = dataContent.usingSite(publicSite).usingUser(adminUser).createContent(CMISUtil.DocumentType.TEXT_PLAIN); @@ -442,7 +442,7 @@ public class FunctionalCasesTests extends RestTest */ @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Check that a comment of a document from a private site is not deleted after user is removed") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) public void checkThatCommentIsNotDeletedWhenPrivateSiteMemberIsRemoved() throws Exception { UserModel newUser = dataUser.createRandomTestUser(); @@ -474,7 +474,7 @@ public class FunctionalCasesTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Add one file to favorites then add a comment to this file") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) public void commentAFavoriteFile() throws Exception { file = dataContent.usingSite(publicSite).usingUser(adminUser).createContent(CMISUtil.DocumentType.TEXT_PLAIN); @@ -496,7 +496,7 @@ public class FunctionalCasesTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Remove one file from favorites then add a comment to this file") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) public void commentFileRemovedFromFavorites() throws Exception { file = dataContent.usingSite(publicSite).usingUser(adminUser).createContent(CMISUtil.DocumentType.TEXT_PLAIN); @@ -525,7 +525,7 @@ public class FunctionalCasesTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Check favorite sites after a favorite site visibility is changed") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) public void changeFavoriteSiteVisibilityThenCheckFavorites() throws Exception { SiteModel favoriteSite = dataSite.usingUser(manager).createPublicRandomSite(); @@ -577,7 +577,7 @@ public class FunctionalCasesTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Check that a user who joins a moderated site as manager is able to comment, rate, tag an existing file from the site, add site to favorites, add and remove site members.") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) public void checkNewManagerActions() throws Exception { UserModel newMember = dataUser.createRandomTestUser(); @@ -655,7 +655,7 @@ public class FunctionalCasesTests extends RestTest * @throws Exception */ @Bug(id="REPO-1830") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its activities with Rest API and response is successful") public void userGetsItsPeopleActivities() throws Exception { diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCoreTests.java deleted file mode 100644 index dd2b8906e..000000000 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCoreTests.java +++ /dev/null @@ -1,90 +0,0 @@ -package org.alfresco.rest.workflow.tasks; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.core.RestRequest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.model.RestTaskModel; -import org.alfresco.rest.model.RestTaskModelsCollection; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TaskModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.apache.commons.lang.RandomStringUtils; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class GetTaskCoreTests extends RestTest -{ - UserModel userModel, assigneeUser; - UserModel adminTenantUser, tenantUser, tenantUserAssignee, adminUser; - SiteModel siteModel; - FileModel fileModel; - TaskModel taskModel; - RestTaskModel restTaskModel, tenantTask; - RestTaskModelsCollection taskModels; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - assigneeUser = dataUser.createRandomTestUser(); - taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify if using invalid taskId status code 404 is returned.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void invalidTaskId() throws Exception - { - taskModel.setId(RandomStringUtils.randomAlphanumeric(20)); - restTaskModel = restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).getTask(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, taskModel.getId())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify if using empty taskId status code 200 is returned.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void emptyTaskId() throws Exception - { - restClient.authenticateUser(userModel).withWorkflowAPI(); - RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "tasks/{taskId}", ""); - taskModels = restClient.processModels(RestTaskModelsCollection.class, request); - restClient.assertStatusCodeIs(HttpStatus.OK); - taskModels.assertThat().entriesListIsNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify that in a network only tasks inside network are returned.") - @Test(groups = {TestGroup.NETWORKS,TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void tasksInsideNetworkReturned() throws Exception - { - restClient.authenticateUser(adminUser); - - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.usingTenant().createTenant(adminTenantUser); - - tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("userTenant"); - tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("userTenantAssignee"); - - RestProcessModel addedProcess = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee, false, - Priority.Normal); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - taskModel = restClient.withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess); - tenantTask = restClient.authenticateUser(tenantUserAssignee).withWorkflowAPI().usingTask(taskModel).getTask(); - restClient.assertStatusCodeIs(HttpStatus.OK); - tenantTask.assertThat().field("assignee").is(String.format("userTenantAssignee@%s", tenantUserAssignee.getDomain().toLowerCase())).and() - .field("processId").is(addedProcess.getId()); - } -} diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelCoreTests.java deleted file mode 100644 index 366a60ead..000000000 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelCoreTests.java +++ /dev/null @@ -1,104 +0,0 @@ -package org.alfresco.rest.workflow.tasks; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestFormModelsCollection; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TaskModel; -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 bogdan.bocancea - * - */ -public class GetTaskFormModelCoreTests extends RestTest -{ - UserModel userModel; - SiteModel siteModel; - FileModel fileModel; - TaskModel taskModel; - RestFormModelsCollection returnedCollection; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, - executionType = ExecutionType.REGRESSION, - description = "Verify that non involved user in task cannot get form models with Rest API and response is FORBIDDEN (403)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void nonInvolvedUserCannotGetTaskFormModels() throws Exception - { - taskModel = dataWorkflow.usingUser(userModel) - .usingSite(siteModel) - .usingResource(fileModel).createNewTaskAndAssignTo(userModel); - UserModel nonInvolvedUser = dataUser.createRandomTestUser(); - restClient.authenticateUser(nonInvolvedUser); - restClient.withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, - executionType = ExecutionType.REGRESSION, - description = "Verify user involved in task cannot get task form models with invalid task id") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void getTaskFormModelsInvalidTaskId() throws Exception - { - taskModel = dataWorkflow.usingUser(userModel) - .usingSite(siteModel) - .usingResource(fileModel).createNewTaskAndAssignTo(userModel); - taskModel.setId("0000"); - restClient.authenticateUser(userModel); - restClient.withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "0000")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, - executionType = ExecutionType.REGRESSION, - description = "Verify user involved in task cannot get task form models with invalid task id") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void getTaskFormModelsEmptyTaskId() throws Exception - { - taskModel = dataWorkflow.usingUser(userModel) - .usingSite(siteModel) - .usingResource(fileModel).createNewTaskAndAssignTo(userModel); - taskModel.setId(""); - restClient.authenticateUser(userModel); - restClient.withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, - executionType = ExecutionType.REGRESSION, - description = "Verify user involved in task can get completed task form models") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void getTaskFormModelsForCompletedTask() throws Exception - { - UserModel assignedUser = dataUser.createRandomTestUser(); - taskModel = dataWorkflow.usingUser(userModel) - .usingSite(siteModel) - .usingResource(fileModel).createNewTaskAndAssignTo(assignedUser); - dataWorkflow.usingUser(assignedUser).taskDone(taskModel); - dataWorkflow.usingUser(userModel).taskDone(taskModel); - restClient.authenticateUser(userModel); - returnedCollection = restClient.withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat().entriesListIsNotEmpty(); - } -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelSanityTests.java deleted file mode 100644 index 36a98a800..000000000 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelSanityTests.java +++ /dev/null @@ -1,75 +0,0 @@ -package org.alfresco.rest.workflow.tasks; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestFormModelsCollection; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TaskModel; -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; - -/** - * Created by Claudia Agache on 10/20/2016. - */ - -public class GetTaskFormModelSanityTests extends RestTest -{ - UserModel userModel; - SiteModel siteModel; - FileModel fileModel; - TaskModel taskModel; - RestFormModelsCollection returnedCollection; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(userModel); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, - executionType = ExecutionType.SANITY, description = "Verify admin user gets all task form models with Rest API and response is successful (200)") - public void adminGetsTaskFormModels() throws Exception - { - returnedCollection = restClient.authenticateUser(dataUser.getAdminUser()).withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat().entriesListIsNotEmpty(); - - String[] qualifiedNames = { - "{http://www.alfresco.org/model/bpm/1.0}percentComplete", - "{http://www.alfresco.org/model/bpm/1.0}context", - "{http://www.alfresco.org/model/bpm/1.0}completedItems", - "{http://www.alfresco.org/model/content/1.0}name", - "{http://www.alfresco.org/model/bpm/1.0}packageActionGroup", - "{http://www.alfresco.org/model/bpm/1.0}reassignable", - "{http://www.alfresco.org/model/content/1.0}owner", - "{http://www.alfresco.org/model/bpm/1.0}outcome", - "{http://www.alfresco.org/model/bpm/1.0}taskId", - "{http://www.alfresco.org/model/bpm/1.0}packageItemActionGroup", - "{http://www.alfresco.org/model/bpm/1.0}completionDate"}; - - for(String formQualifiedName : qualifiedNames) - { - returnedCollection.assertThat().entriesListContains("qualifiedName", formQualifiedName); - } - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, - executionType = ExecutionType.SANITY, description = "Verify user involved in task gets all the task form models with Rest API and response is successful (200)") - public void involvedUserGetsTaskFormModels() throws Exception - { - returnedCollection = restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat().entriesListIsNotEmpty(); - } -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelTests.java similarity index 56% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelFullTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelTests.java index d9b501d60..b7359652b 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelTests.java @@ -14,7 +14,7 @@ import org.testng.annotations.Test; /** * Created by Claudia Agache on 2/3/2017. */ -public class GetTaskFormModelFullTests extends RestTest +public class GetTaskFormModelTests extends RestTest { UserModel userModel, adminUser; SiteModel siteModel; @@ -29,14 +29,120 @@ public class GetTaskFormModelFullTests extends RestTest userModel = dataUser.createRandomTestUser(); siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); fileModel = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(userModel); } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, + executionType = ExecutionType.SANITY, description = "Verify admin user gets all task form models with Rest API and response is successful (200)") + public void adminGetsTaskFormModels() throws Exception + { + taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(userModel); + returnedCollection = restClient.authenticateUser(dataUser.getAdminUser()).withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat().entriesListIsNotEmpty(); + + String[] qualifiedNames = { + "{http://www.alfresco.org/model/bpm/1.0}percentComplete", + "{http://www.alfresco.org/model/bpm/1.0}context", + "{http://www.alfresco.org/model/bpm/1.0}completedItems", + "{http://www.alfresco.org/model/content/1.0}name", + "{http://www.alfresco.org/model/bpm/1.0}packageActionGroup", + "{http://www.alfresco.org/model/bpm/1.0}reassignable", + "{http://www.alfresco.org/model/content/1.0}owner", + "{http://www.alfresco.org/model/bpm/1.0}outcome", + "{http://www.alfresco.org/model/bpm/1.0}taskId", + "{http://www.alfresco.org/model/bpm/1.0}packageItemActionGroup", + "{http://www.alfresco.org/model/bpm/1.0}completionDate"}; + + for(String formQualifiedName : qualifiedNames) + { + returnedCollection.assertThat().entriesListContains("qualifiedName", formQualifiedName); + } + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, + executionType = ExecutionType.SANITY, description = "Verify user involved in task gets all the task form models with Rest API and response is successful (200)") + public void involvedUserGetsTaskFormModels() throws Exception + { + taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(userModel); + returnedCollection = restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat().entriesListIsNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, + executionType = ExecutionType.REGRESSION, + description = "Verify that non involved user in task cannot get form models with Rest API and response is FORBIDDEN (403)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void nonInvolvedUserCannotGetTaskFormModels() throws Exception + { + taskModel = dataWorkflow.usingUser(userModel) + .usingSite(siteModel) + .usingResource(fileModel).createNewTaskAndAssignTo(userModel); + UserModel nonInvolvedUser = dataUser.createRandomTestUser(); + restClient.authenticateUser(nonInvolvedUser); + restClient.withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, + executionType = ExecutionType.REGRESSION, + description = "Verify user involved in task cannot get task form models with invalid task id") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void getTaskFormModelsInvalidTaskId() throws Exception + { + taskModel = dataWorkflow.usingUser(userModel) + .usingSite(siteModel) + .usingResource(fileModel).createNewTaskAndAssignTo(userModel); + taskModel.setId("0000"); + restClient.authenticateUser(userModel); + restClient.withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "0000")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, + executionType = ExecutionType.REGRESSION, + description = "Verify user involved in task cannot get task form models with invalid task id") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void getTaskFormModelsEmptyTaskId() throws Exception + { + taskModel = dataWorkflow.usingUser(userModel) + .usingSite(siteModel) + .usingResource(fileModel).createNewTaskAndAssignTo(userModel); + taskModel.setId(""); + restClient.authenticateUser(userModel); + restClient.withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, + executionType = ExecutionType.REGRESSION, + description = "Verify user involved in task can get completed task form models") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void getTaskFormModelsForCompletedTask() throws Exception + { + UserModel assignedUser = dataUser.createRandomTestUser(); + taskModel = dataWorkflow.usingUser(userModel) + .usingSite(siteModel) + .usingResource(fileModel).createNewTaskAndAssignTo(assignedUser); + dataWorkflow.usingUser(assignedUser).taskDone(taskModel); + dataWorkflow.usingUser(userModel).taskDone(taskModel); + restClient.authenticateUser(userModel); + returnedCollection = restClient.withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat().entriesListIsNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify admin user gets all task form models with properties parameter applied and response is successful (200)") public void adminGetsTaskFormModelsWithPropertiesParameter() throws Exception { + taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(userModel); returnedCollection = restClient.authenticateUser(adminUser).withParams("properties=qualifiedName,required").withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); restClient.assertStatusCodeIs(HttpStatus.OK); returnedCollection.assertThat().entriesListIsNotEmpty(); @@ -55,9 +161,10 @@ public class GetTaskFormModelFullTests extends RestTest @Bug(id = "MNT-17438") @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify admin gets task form model with valid skipCount parameter applied using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) public void getTaskFormModelWithValidSkipCount() throws Exception { + taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(userModel); returnedCollection = restClient.authenticateUser(adminUser) .withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -75,9 +182,10 @@ public class GetTaskFormModelFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify admin doesn't get task form model with negative skipCount parameter applied using REST API") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) public void getTaskFormModelWithNegativeSkipCount() throws Exception { + taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(userModel); restClient.authenticateUser(adminUser).withParams("skipCount=-1").withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() .containsSummary(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT) @@ -89,9 +197,10 @@ public class GetTaskFormModelFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify admin doesn't get task form model with non numeric skipCount parameter applied using REST API") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) public void getTaskFormModelWithNonNumericSkipCount() throws Exception { + taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(userModel); restClient.authenticateUser(adminUser).withParams("skipCount=A").withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() .containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "A")); @@ -100,9 +209,10 @@ public class GetTaskFormModelFullTests extends RestTest @Bug(id = "MNT-17438") @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify admin gets task form model with valid maxItems parameter applied using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) public void getTaskFormModelWithValidMaxItems() throws Exception { + taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(userModel); returnedCollection = restClient.authenticateUser(adminUser) .withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -120,9 +230,10 @@ public class GetTaskFormModelFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify admin doesn't get task form model with negative maxItems parameter applied using REST API") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) public void getTaskFormModelWithNegativeMaxItems() throws Exception { + taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(userModel); restClient.authenticateUser(adminUser).withParams("maxItems=-1").withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() .containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) @@ -134,19 +245,21 @@ public class GetTaskFormModelFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify admin doesn't get task form model with non numeric maxItems parameter applied using REST API") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) public void getTaskFormModelWithNonNumericMaxItems() throws Exception { + taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(userModel); restClient.authenticateUser(adminUser).withParams("maxItems=A").withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() .containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "A")); } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL, TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify network admin user gets all task form models inside his network with Rest API and response is successful (200)") public void networkAdminGetsTaskFormModels() throws Exception { + taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(userModel); UserModel adminTenantUser = UserModel.getAdminTenantUser(); restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser); UserModel tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant1"); diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFullTests.java deleted file mode 100644 index 9bba5e6c9..000000000 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFullTests.java +++ /dev/null @@ -1,143 +0,0 @@ -package org.alfresco.rest.workflow.tasks; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.core.RestRequest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.model.RestTaskModel; -import org.alfresco.rest.model.RestTaskModelsCollection; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.ProcessModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TaskModel; -import org.alfresco.utility.model.TestGroup; -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.BeforeMethod; -import org.testng.annotations.Test; - -/** - * - * @author Cristina Axinte - * - */ -public class GetTaskFullTests extends RestTest -{ - UserModel userModel; - SiteModel siteModel; - UserModel candidateUser; - FileModel fileModel; - UserModel assigneeUser; - TaskModel taskModel; - RestTaskModel restTaskModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - assigneeUser = dataUser.createRandomTestUser(); - } - - @BeforeMethod(alwaysRun=true) - public void createTask() throws Exception - { - taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, - executionType = ExecutionType.REGRESSION, description = "Verify user who started a task gets the task with empty taskId with Rest API") - public void starterUserGetsTaskWithEmptyTaskId() throws Exception - { - restClient.authenticateUser(userModel).withWorkflowAPI(); - RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "tasks/{taskId}", ""); - RestTaskModelsCollection tasks = restClient.processModels(RestTaskModelsCollection.class, request); - - restClient.assertStatusCodeIs(HttpStatus.OK); - tasks.assertThat().entriesListIsNotEmpty() - .and().entriesListCountIs(1) - .and().entriesListContains("id", taskModel.getId()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, - executionType = ExecutionType.REGRESSION, description = "Verify user who started a task gets the task with properties parameter with Rest API") - public void starterUserGetsTaskWithPropertiesParameter() throws Exception - { - restTaskModel = restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).usingParams("properties=id,assignee,formResourceKey").getTask(); - - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().fieldsCount().is(3) - .and().field("id").is(taskModel.getId()) - .and().field("assignee").is(taskModel.getAssignee()) - .and().field("formResourceKey").is("wf:adhocTask") - .and().field("processDefinitionId").isNull() - .and().field("processId").isNull(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, - executionType = ExecutionType.REGRESSION, description = "Verify user who started a task gets the task after it is deleted with Rest API") - public void starterUserGetsDeletedTask() throws Exception - { - restTaskModel = restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).getTask(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()); - - ProcessModel process = new ProcessModel(); - process.setId(taskModel.getProcessId()); - dataWorkflow.usingUser(userModel).deleteProcess(process); - - restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).getTask(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, taskModel.getId())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, - executionType = ExecutionType.REGRESSION, description = "Check that for admin network gets task only from its network.") - public void adminTenantGetsTaskOnlyFromItsNetwork() throws Exception - { - UserModel adminUser = dataUser.getAdminUser(); - restClient.authenticateUser(adminUser); - - UserModel adminTenant1 = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenant1); - - UserModel tenantUser1 = dataUser.usingUser(adminTenant1).createUserWithTenant("userTenant1"); - UserModel tenantUserAssignee1 = dataUser.usingUser(adminTenant1).createUserWithTenant("userTenantAssignee1"); - - RestProcessModel processOnTenant1 = restClient.authenticateUser(tenantUser1).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee1, false, Priority.Low); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - UserModel adminTenant2 = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenant2); - - UserModel tenantUser2 = dataUser.usingUser(adminTenant2).createUserWithTenant("userTenant2"); - UserModel tenantUserAssignee2 = dataUser.usingUser(adminTenant2).createUserWithTenant("userTenantAssignee2"); - - RestProcessModel processOnTenant2 = restClient.authenticateUser(tenantUser2).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee2, false, Priority.Normal); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestTaskModelsCollection tenantTasks2 = restClient.authenticateUser(tenantUser2).withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - tenantTasks2.assertThat().entriesListIsNotEmpty() - .and().entriesListCountIs(1) - .and().entriesListContains("assignee", String.format("userTenantAssignee2@%s", tenantUserAssignee2.getDomain().toLowerCase())) - .and().entriesListContains("processId", processOnTenant2.getId()) - .and().entriesListDoesNotContain("assignee", String.format("userTenantAssignee1@%s", tenantUserAssignee1.getDomain().toLowerCase())) - .and().entriesListDoesNotContain("processId", processOnTenant1.getId()); - - } -} diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskSanityTests.java deleted file mode 100644 index 9f7f638bd..000000000 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskSanityTests.java +++ /dev/null @@ -1,120 +0,0 @@ - -package org.alfresco.rest.workflow.tasks; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestTaskModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.GroupModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TaskModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - - -public class GetTaskSanityTests extends RestTest -{ - UserModel userModel; - SiteModel siteModel; - UserModel candidateUser; - FileModel fileModel; - UserModel assigneeUser; - TaskModel taskModel; - RestTaskModel restTaskModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - assigneeUser = dataUser.createRandomTestUser(); - taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify admin user gets any existing task with Rest API and response is successfull (200)") - public void adminUserGetsAnyTaskWithSuccess() throws Exception - { - UserModel adminUser = dataUser.getAdminUser(); - - restTaskModel = restClient.authenticateUser(adminUser).withWorkflowAPI().usingTask(taskModel).getTask(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("description").is(taskModel.getMessage()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify assignee user gets its assigned task with Rest API and response is successfull (200)") - public void assigneeUserGetsItsTaskWithSuccess() throws Exception - { - restTaskModel = restClient.authenticateUser(assigneeUser).withWorkflowAPI().usingTask(taskModel).getTask(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("description").is(taskModel.getMessage()).and().field("assignee") - .is(assigneeUser.getUsername()); - - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify user that started the task gets the started task with Rest API and response is successfull (200)") - public void starterUserGetsItsTaskWithSuccess() throws Exception - { - restTaskModel = restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).getTask(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("description").is(taskModel.getMessage()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify any user with no relation to task id forbidden to get other task with Rest API (403)") - public void anyUserIsForbiddenToGetOtherTask() throws Exception - { - UserModel anyUser = dataUser.createRandomTestUser(); - - restTaskModel = restClient.authenticateUser(anyUser).withWorkflowAPI().usingTask(taskModel).getTask(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify candidate user gets its specific task and no other user claimed the task with Rest API and response is successfull (200)") - public void candidateUserGetsItsTasks() throws Exception - { - UserModel userModel1 = dataUser.createRandomTestUser(); - UserModel userModel2 = dataUser.createRandomTestUser(); - GroupModel group = dataGroup.createRandomGroup(); - dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); - TaskModel taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); - - restTaskModel = restClient.authenticateUser(userModel1).withWorkflowAPI().usingTask(taskModel).getTask(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("description").is(taskModel.getMessage()); - - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @Bug(id = "MNT-17051") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify involved user in a task without claim it gets the task with Rest API and response is successfull (200)") - public void involvedUserWithoutClaimTaskGetsTask() throws Exception - { - UserModel userModel1 = dataUser.createRandomTestUser(); - UserModel userModel2 = dataUser.createRandomTestUser(); - GroupModel group = dataGroup.createRandomGroup(); - dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); - TaskModel taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); - dataWorkflow.usingUser(userModel1).claimTask(taskModel); - - restTaskModel = restClient.authenticateUser(userModel2).withWorkflowAPI().usingTask(taskModel).getTask(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("description").is(taskModel.getMessage()); - } -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskTests.java new file mode 100644 index 000000000..a0f25e0fe --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskTests.java @@ -0,0 +1,263 @@ +package org.alfresco.rest.workflow.tasks; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.dataprep.CMISUtil.Priority; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestTaskModel; +import org.alfresco.rest.model.RestTaskModelsCollection; +import org.alfresco.utility.model.*; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.apache.commons.lang.RandomStringUtils; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +/** + * + * @author Cristina Axinte + * + */ +public class GetTaskTests extends RestTest +{ + UserModel userModel, assigneeUser; + UserModel adminTenantUser, tenantUser, tenantUserAssignee, adminUser; + SiteModel siteModel; + FileModel fileModel; + TaskModel taskModel; + RestTaskModel restTaskModel, tenantTask; + RestTaskModelsCollection taskModels; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + assigneeUser = dataUser.createRandomTestUser(); + } + + @BeforeMethod(alwaysRun=true) + public void createTask() throws Exception + { + taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify admin user gets any existing task with Rest API and response is successfull (200)") + public void adminUserGetsAnyTaskWithSuccess() throws Exception + { + restTaskModel = restClient.authenticateUser(adminUser).withWorkflowAPI().usingTask(taskModel).getTask(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("description").is(taskModel.getMessage()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify assignee user gets its assigned task with Rest API and response is successfull (200)") + public void assigneeUserGetsItsTaskWithSuccess() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser).withWorkflowAPI().usingTask(taskModel).getTask(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("description").is(taskModel.getMessage()).and().field("assignee") + .is(assigneeUser.getUsername()); + + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify user that started the task gets the started task with Rest API and response is successfull (200)") + public void starterUserGetsItsTaskWithSuccess() throws Exception + { + restTaskModel = restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).getTask(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("description").is(taskModel.getMessage()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify any user with no relation to task id forbidden to get other task with Rest API (403)") + public void anyUserIsForbiddenToGetOtherTask() throws Exception + { + UserModel anyUser = dataUser.createRandomTestUser(); + + restTaskModel = restClient.authenticateUser(anyUser).withWorkflowAPI().usingTask(taskModel).getTask(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify candidate user gets its specific task and no other user claimed the task with Rest API and response is successfull (200)") + public void candidateUserGetsItsTasks() throws Exception + { + UserModel userModel1 = dataUser.createRandomTestUser(); + UserModel userModel2 = dataUser.createRandomTestUser(); + GroupModel group = dataGroup.createRandomGroup(); + dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); + TaskModel taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); + + restTaskModel = restClient.authenticateUser(userModel1).withWorkflowAPI().usingTask(taskModel).getTask(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("description").is(taskModel.getMessage()); + + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @Bug(id = "MNT-17051") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify involved user in a task without claim it gets the task with Rest API and response is successfull (200)") + public void involvedUserWithoutClaimTaskGetsTask() throws Exception + { + UserModel userModel1 = dataUser.createRandomTestUser(); + UserModel userModel2 = dataUser.createRandomTestUser(); + GroupModel group = dataGroup.createRandomGroup(); + dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); + TaskModel taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); + dataWorkflow.usingUser(userModel1).claimTask(taskModel); + + restTaskModel = restClient.authenticateUser(userModel2).withWorkflowAPI().usingTask(taskModel).getTask(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("description").is(taskModel.getMessage()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, + executionType = ExecutionType.REGRESSION, description = "Verify user who started a task gets the task with empty taskId with Rest API") + public void starterUserGetsTaskWithEmptyTaskId() throws Exception + { + restClient.authenticateUser(userModel).withWorkflowAPI(); + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "tasks/{taskId}", ""); + RestTaskModelsCollection tasks = restClient.processModels(RestTaskModelsCollection.class, request); + + restClient.assertStatusCodeIs(HttpStatus.OK); + tasks.assertThat().entriesListIsNotEmpty() + .and().entriesListCountIs(1) + .and().entriesListContains("id", taskModel.getId()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, + executionType = ExecutionType.REGRESSION, description = "Verify user who started a task gets the task with properties parameter with Rest API") + public void starterUserGetsTaskWithPropertiesParameter() throws Exception + { + restTaskModel = restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).usingParams("properties=id,assignee,formResourceKey").getTask(); + + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().fieldsCount().is(3) + .and().field("id").is(taskModel.getId()) + .and().field("assignee").is(taskModel.getAssignee()) + .and().field("formResourceKey").is("wf:adhocTask") + .and().field("processDefinitionId").isNull() + .and().field("processId").isNull(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, + executionType = ExecutionType.REGRESSION, description = "Verify user who started a task gets the task after it is deleted with Rest API") + public void starterUserGetsDeletedTask() throws Exception + { + restTaskModel = restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).getTask(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()); + + ProcessModel process = new ProcessModel(); + process.setId(taskModel.getProcessId()); + dataWorkflow.usingUser(userModel).deleteProcess(process); + + restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).getTask(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, taskModel.getId())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, + executionType = ExecutionType.REGRESSION, description = "Check that for admin network gets task only from its network.") + public void adminTenantGetsTaskOnlyFromItsNetwork() throws Exception + { + restClient.authenticateUser(adminUser); + + UserModel adminTenant1 = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenant1); + + UserModel tenantUser1 = dataUser.usingUser(adminTenant1).createUserWithTenant("userTenant1"); + UserModel tenantUserAssignee1 = dataUser.usingUser(adminTenant1).createUserWithTenant("userTenantAssignee1"); + + RestProcessModel processOnTenant1 = restClient.authenticateUser(tenantUser1).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee1, false, Priority.Low); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + UserModel adminTenant2 = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenant2); + + UserModel tenantUser2 = dataUser.usingUser(adminTenant2).createUserWithTenant("userTenant2"); + UserModel tenantUserAssignee2 = dataUser.usingUser(adminTenant2).createUserWithTenant("userTenantAssignee2"); + + RestProcessModel processOnTenant2 = restClient.authenticateUser(tenantUser2).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee2, false, Priority.Normal); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestTaskModelsCollection tenantTasks2 = restClient.authenticateUser(tenantUser2).withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + tenantTasks2.assertThat().entriesListIsNotEmpty() + .and().entriesListCountIs(1) + .and().entriesListContains("assignee", String.format("userTenantAssignee2@%s", tenantUserAssignee2.getDomain().toLowerCase())) + .and().entriesListContains("processId", processOnTenant2.getId()) + .and().entriesListDoesNotContain("assignee", String.format("userTenantAssignee1@%s", tenantUserAssignee1.getDomain().toLowerCase())) + .and().entriesListDoesNotContain("processId", processOnTenant1.getId()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify if using invalid taskId status code 404 is returned.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void invalidTaskId() throws Exception + { + taskModel.setId(RandomStringUtils.randomAlphanumeric(20)); + restTaskModel = restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).getTask(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, taskModel.getId())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify if using empty taskId status code 200 is returned.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void emptyTaskId() throws Exception + { + restClient.authenticateUser(userModel).withWorkflowAPI(); + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "tasks/{taskId}", ""); + taskModels = restClient.processModels(RestTaskModelsCollection.class, request); + restClient.assertStatusCodeIs(HttpStatus.OK); + taskModels.assertThat().entriesListIsNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify that in a network only tasks inside network are returned.") + @Test(groups = {TestGroup.NETWORKS,TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void tasksInsideNetworkReturned() throws Exception + { + restClient.authenticateUser(adminUser); + + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.usingTenant().createTenant(adminTenantUser); + + tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("userTenant"); + tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("userTenantAssignee"); + + RestProcessModel addedProcess = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee, false, + Priority.Normal); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + taskModel = restClient.withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess); + tenantTask = restClient.authenticateUser(tenantUserAssignee).withWorkflowAPI().usingTask(taskModel).getTask(); + restClient.assertStatusCodeIs(HttpStatus.OK); + tenantTask.assertThat().field("assignee").is(String.format("userTenantAssignee@%s", tenantUserAssignee.getDomain().toLowerCase())).and() + .field("processId").is(addedProcess.getId()); + } +} diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksCoreTests.java deleted file mode 100644 index f60f151ee..000000000 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksCoreTests.java +++ /dev/null @@ -1,110 +0,0 @@ -package org.alfresco.rest.workflow.tasks; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestTaskModelsCollection; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class GetTasksCoreTests extends RestTest -{ - UserModel userModel, userNotInvolved, candidateUser, assigneeUser, adminUser; - UserModel adminTenantUser, tenantUser, tenantUserAssignee; - SiteModel siteModel; - FileModel fileModel; - RestTaskModelsCollection taskModels, tenantTask; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userModel = dataUser.createRandomTestUser(); - userNotInvolved = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - - assigneeUser = dataUser.createRandomTestUser(); - dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify the request in case of any user which is not involved.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void requestWithUserNotInvolved() throws Exception - { - taskModels = restClient.authenticateUser(userNotInvolved).withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - taskModels.assertThat().entriesListIsEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check that orderBy parameter is applied.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void orderByParameterApplied() throws Exception - { - taskModels = restClient.authenticateUser(dataUser.getAdminUser()).withParams("orderBy=id").withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - taskModels.assertThat().entriesListIsNotEmpty(). - and().entriesListIsSortedAscBy("id"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check that orderBy parameter is applied and supports only one parameter.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void orderByParameterSupportsOnlyOneParameter() throws Exception - { - taskModels = restClient.authenticateUser(dataUser.getAdminUser()).withParams("orderBy=id,processDefinitionId").withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Only one order by parameter is supported"); - taskModels.assertThat().entriesListIsEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check that where parameter is applied.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void whereParameterApplied() throws Exception - { - taskModels = restClient.authenticateUser(dataUser.getAdminUser()).withParams("where=(assignee='" + assigneeUser.getUsername() + "')").withWorkflowAPI() - .getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - taskModels.assertThat().entriesListIsNotEmpty().and().entriesListContains("assignee", assigneeUser.getUsername()).and().entriesListCountIs(1); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check that invalid orderBy parameter applied returns 400 status code.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void invalidOrderByParameterApplied() throws Exception - { - restClient.authenticateUser(dataUser.getAdminUser()).withParams("orderBy=invalidParameter").withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("invalidParameter is not supported"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check that for network enabled only that network tasks are returned.") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.CORE }) - public void networkEnabledTasksReturned() throws Exception - { - restClient.authenticateUser(adminUser); - - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.usingTenant().createTenant(adminTenantUser); - - tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("userTenant"); - tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("userTenantAssignee"); - - restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee, false, Priority.Normal); - - tenantTask = restClient.authenticateUser(tenantUserAssignee).withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - tenantTask.assertThat().entriesListIsNotEmpty().and().entriesListCountIs(1).and().entriesListContains("assignee", - String.format("userTenantAssignee@%s", tenantUserAssignee.getDomain().toLowerCase())); - - } -} diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksFullTests.java deleted file mode 100644 index b1fa28ff2..000000000 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksFullTests.java +++ /dev/null @@ -1,150 +0,0 @@ -package org.alfresco.rest.workflow.tasks; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.model.RestTaskModel; -import org.alfresco.rest.model.RestTaskModelsCollection; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class GetTasksFullTests extends RestTest -{ - UserModel userModel, adminUser; - SiteModel siteModel; - UserModel candidateUser; - FileModel fileModel; - UserModel assigneeUser; - RestTaskModelsCollection taskModels, taskCollections; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - adminUser = dataUser.getAdminUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - assigneeUser = dataUser.createRandomTestUser(); - dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check that skipCount parameter is applied.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void skipCountParameterApplied() throws Exception - { - taskCollections = restClient.authenticateUser(dataUser.getAdminUser()).withParams("orderBy=description ASC").withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - RestTaskModel firstTask = taskCollections.getEntries().get(0).onModel(); - RestTaskModel secondTask = taskCollections.getEntries().get(1).onModel(); - - taskModels = restClient.withParams("orderBy=description ASC&skipCount=2").withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - taskModels.assertThat().entriesListDoesNotContain("id", firstTask.getId()) - .assertThat().entriesListDoesNotContain("id", secondTask.getId()); - taskModels.assertThat().paginationField("skipCount").is("2"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check that maxItems parameter is applied.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void maxItemsParameterApplied() throws Exception - { - restClient.authenticateUser(userModel).withWorkflowAPI().addProcess("activitiAdhoc", assigneeUser, false, Priority.Low); - restClient.authenticateUser(userModel).withWorkflowAPI().addProcess("activitiAdhoc", adminUser, false, Priority.Low); - taskCollections = restClient.authenticateUser(userModel).withParams("orderBy=assignee ASC").withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - taskModels = restClient.withParams("orderBy=startedAt DESC&maxItems=2").withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - taskModels.assertThat().entriesListIsNotEmpty() - .assertThat().entriesListContains("assignee", assigneeUser.getUsername()) - .assertThat().entriesListDoesNotContain("assignee", userModel.getUsername()); - taskModels.assertThat().paginationField("maxItems").is("2"); - taskModels.assertThat().paginationField("count").is("2"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check that properties parameter is applied.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void propertiesParameterApplied() throws Exception - { - taskModels = restClient.authenticateUser(dataUser.getAdminUser()).withParams("properties=name,description").withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - taskModels.assertThat().entriesListIsNotEmpty() - .assertThat().entriesListContains("name") - .assertThat().entriesListContains("description") - .assertThat().entriesListDoesNotContain("processDefinitionId") - .assertThat().entriesListDoesNotContain("processId") - .assertThat().entriesListDoesNotContain("startedAt") - .assertThat().entriesListDoesNotContain("id") - .assertThat().entriesListDoesNotContain("state") - .assertThat().entriesListDoesNotContain("activityDefinitionId") - .assertThat().entriesListDoesNotContain("priority") - .assertThat().entriesListDoesNotContain("formResourceKey"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Use invalid where parameter. Check default error model schema.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void invalidWhereParameterCheckDefaultErrorModelSchema() throws Exception - { - restClient.authenticateUser(dataUser.getAdminUser()).where("assignee AND '" + assigneeUser.getUsername() + "'").withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(RestErrorModel.INVALID_QUERY_ERRORKEY) - .containsSummary(String.format(RestErrorModel.INVALID_WHERE_QUERY, "(assignee AND '" + assigneeUser.getUsername() + "')")) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, - executionType = ExecutionType.REGRESSION, description = "Check that for admin network gets tasks only from its network.") - public void adminTenantGetsTasksOnlyFromItsNetwork() throws Exception - { - UserModel adminTenant1 = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenant1); - - UserModel adminTenant2 = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenant2); - - UserModel tenantUser1 = dataUser.usingUser(adminTenant1).createUserWithTenant("userTenant1"); - UserModel tenantUserAssignee1 = dataUser.usingUser(adminTenant1).createUserWithTenant("userTenantAssignee1"); - - UserModel tenantUser2 = dataUser.usingUser(adminTenant2).createUserWithTenant("userTenant2"); - UserModel tenantUserAssignee2 = dataUser.usingUser(adminTenant2).createUserWithTenant("userTenantAssignee2"); - - RestProcessModel processOnTenant1 = restClient.authenticateUser(tenantUser1).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee1, false, Priority.Low); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestProcessModel processOnTenant2 = restClient.authenticateUser(tenantUser2).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee2, false, Priority.Normal); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestTaskModelsCollection tenantTasks1 = restClient.authenticateUser(adminTenant1).withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - tenantTasks1.assertThat().entriesListIsNotEmpty() - .and().entriesListCountIs(1) - .and().entriesListContains("assignee", String.format("userTenantAssignee1@%s", tenantUserAssignee1.getDomain().toLowerCase())) - .and().entriesListContains("processId", processOnTenant1.getId()) - .and().entriesListDoesNotContain("assignee", String.format("userTenantAssignee2@%s", tenantUserAssignee2.getDomain().toLowerCase())) - .and().entriesListDoesNotContain("processId", processOnTenant2.getId()); - - RestTaskModelsCollection tenantTasks2 = restClient.authenticateUser(adminTenant2).withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - tenantTasks2.assertThat().entriesListIsNotEmpty() - .and().entriesListCountIs(1) - .and().entriesListContains("assignee", String.format("userTenantAssignee2@%s", tenantUserAssignee2.getDomain().toLowerCase())) - .and().entriesListContains("processId", processOnTenant2.getId()) - .and().entriesListDoesNotContain("assignee", String.format("userTenantAssignee1@%s", tenantUserAssignee1.getDomain().toLowerCase())) - .and().entriesListDoesNotContain("processId", processOnTenant1.getId()); - } -} diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksSanityTests.java deleted file mode 100644 index 18f26dc24..000000000 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksSanityTests.java +++ /dev/null @@ -1,110 +0,0 @@ - - -package org.alfresco.rest.workflow.tasks; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestTaskModelsCollection; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.GroupModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TaskModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - - -public class GetTasksSanityTests extends RestTest -{ - UserModel userModel; - SiteModel siteModel; - UserModel candidateUser; - FileModel fileModel; - UserModel assigneeUser; - RestTaskModelsCollection taskModels; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - assigneeUser = dataUser.createRandomTestUser(); - dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify admin user gets all existing tasks with Rest API and response is successfull (200)") - public void adminUserGetsAllTasks() throws Exception - { - UserModel adminUser = dataUser.getAdminUser(); - - taskModels = restClient.authenticateUser(adminUser).withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - taskModels.assertThat().entriesListIsNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify asignee user gets its existing tasks with Rest API and response is successfull (200)") - public void asigneeUserGetsItsTasks() throws Exception - { - taskModels = restClient.authenticateUser(assigneeUser).withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - taskModels.assertThat().entriesListIsNotEmpty().and().entriesListCountIs(1).and().entriesListContains("assignee", assigneeUser.getUsername()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify candidate user that claims the task gets its existing tasks with Rest API and response is successfull (200)") - @Bug(id = "MNT-16967") - public void candidateUserGetsItsTasks() throws Exception - { - UserModel userModel1 = dataUser.createRandomTestUser(); - UserModel userModel2 = dataUser.createRandomTestUser(); - GroupModel group = dataGroup.createRandomGroup(); - - dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); - dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); - - taskModels = restClient.authenticateUser(userModel1).withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - taskModels.assertThat().entriesListIsNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify candidate user that claims the task gets its existing tasks with Rest API and response is successfull (200)") - public void candidateUserThatClaimsTaskGetsItsTasks() throws Exception - { - UserModel userModel1 = dataUser.createRandomTestUser(); - UserModel userModel2 = dataUser.createRandomTestUser(); - GroupModel group = dataGroup.createRandomGroup(); - dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); - TaskModel taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); - dataWorkflow.usingUser(userModel1).claimTask(taskModel); - - taskModels = restClient.authenticateUser(userModel1).withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - taskModels.assertThat().entriesListIsNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify candidate user without claim gets no tasks with Rest API and response is successfull (200)") - public void candidateUserWithoutClaimTaskGetsNoTasks() throws Exception - { - UserModel userModel1 = dataUser.createRandomTestUser(); - UserModel userModel2 = dataUser.createRandomTestUser(); - GroupModel group = dataGroup.createRandomGroup(); - - dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); - TaskModel taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); - dataWorkflow.usingUser(userModel1).claimTask(taskModel); - - taskModels = restClient.authenticateUser(userModel2).withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - taskModels.assertThat().entriesListIsEmpty(); - } -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksTests.java new file mode 100644 index 000000000..1eb18a4ae --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksTests.java @@ -0,0 +1,292 @@ +package org.alfresco.rest.workflow.tasks; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.dataprep.CMISUtil.Priority; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestTaskModel; +import org.alfresco.rest.model.RestTaskModelsCollection; +import org.alfresco.utility.model.*; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class GetTasksTests extends RestTest +{ + UserModel userModel, userNotInvolved, assigneeUser, adminUser; + UserModel adminTenantUser, tenantUser, tenantUserAssignee; + SiteModel siteModel; + FileModel fileModel; + RestTaskModelsCollection taskModels, taskCollections, tenantTask; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userModel = dataUser.createRandomTestUser(); + userNotInvolved = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + + assigneeUser = dataUser.createRandomTestUser(); + dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify admin user gets all existing tasks with Rest API and response is successfull (200)") + public void adminUserGetsAllTasks() throws Exception + { + UserModel adminUser = dataUser.getAdminUser(); + + taskModels = restClient.authenticateUser(adminUser).withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + taskModels.assertThat().entriesListIsNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify asignee user gets its existing tasks with Rest API and response is successfull (200)") + public void assigneeUserGetsItsTasks() throws Exception + { + taskModels = restClient.authenticateUser(assigneeUser).withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + taskModels.assertThat().entriesListIsNotEmpty().and().entriesListCountIs(1).and().entriesListContains("assignee", assigneeUser.getUsername()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify candidate user that claims the task gets its existing tasks with Rest API and response is successfull (200)") + @Bug(id = "MNT-16967") + public void candidateUserGetsItsTasks() throws Exception + { + UserModel userModel1 = dataUser.createRandomTestUser(); + UserModel userModel2 = dataUser.createRandomTestUser(); + GroupModel group = dataGroup.createRandomGroup(); + + dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); + dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); + + taskModels = restClient.authenticateUser(userModel1).withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + taskModels.assertThat().entriesListIsNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify candidate user that claims the task gets its existing tasks with Rest API and response is successfull (200)") + public void candidateUserThatClaimsTaskGetsItsTasks() throws Exception + { + UserModel userModel1 = dataUser.createRandomTestUser(); + UserModel userModel2 = dataUser.createRandomTestUser(); + GroupModel group = dataGroup.createRandomGroup(); + dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); + TaskModel taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); + dataWorkflow.usingUser(userModel1).claimTask(taskModel); + + taskModels = restClient.authenticateUser(userModel1).withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + taskModels.assertThat().entriesListIsNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify candidate user without claim gets no tasks with Rest API and response is successfull (200)") + public void candidateUserWithoutClaimTaskGetsNoTasks() throws Exception + { + UserModel userModel1 = dataUser.createRandomTestUser(); + UserModel userModel2 = dataUser.createRandomTestUser(); + GroupModel group = dataGroup.createRandomGroup(); + + dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); + TaskModel taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); + dataWorkflow.usingUser(userModel1).claimTask(taskModel); + + taskModels = restClient.authenticateUser(userModel2).withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + taskModels.assertThat().entriesListIsEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check that skipCount parameter is applied.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void skipCountParameterApplied() throws Exception + { + taskCollections = restClient.authenticateUser(dataUser.getAdminUser()).withParams("orderBy=description ASC").withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + RestTaskModel firstTask = taskCollections.getEntries().get(0).onModel(); + RestTaskModel secondTask = taskCollections.getEntries().get(1).onModel(); + + taskModels = restClient.withParams("orderBy=description ASC&skipCount=2").withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + taskModels.assertThat().entriesListDoesNotContain("id", firstTask.getId()) + .assertThat().entriesListDoesNotContain("id", secondTask.getId()); + taskModels.assertThat().paginationField("skipCount").is("2"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check that maxItems parameter is applied.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void maxItemsParameterApplied() throws Exception + { + restClient.authenticateUser(userModel).withWorkflowAPI().addProcess("activitiAdhoc", assigneeUser, false, Priority.Low); + restClient.authenticateUser(userModel).withWorkflowAPI().addProcess("activitiAdhoc", adminUser, false, Priority.Low); + taskCollections = restClient.authenticateUser(userModel).withParams("orderBy=assignee ASC").withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + taskModels = restClient.withParams("orderBy=startedAt DESC&maxItems=2").withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + taskModels.assertThat().entriesListIsNotEmpty() + .assertThat().entriesListContains("assignee", assigneeUser.getUsername()) + .assertThat().entriesListDoesNotContain("assignee", userModel.getUsername()); + taskModels.assertThat().paginationField("maxItems").is("2"); + taskModels.assertThat().paginationField("count").is("2"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check that properties parameter is applied.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void propertiesParameterApplied() throws Exception + { + taskModels = restClient.authenticateUser(dataUser.getAdminUser()).withParams("properties=name,description").withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + taskModels.assertThat().entriesListIsNotEmpty() + .assertThat().entriesListContains("name") + .assertThat().entriesListContains("description") + .assertThat().entriesListDoesNotContain("processDefinitionId") + .assertThat().entriesListDoesNotContain("processId") + .assertThat().entriesListDoesNotContain("startedAt") + .assertThat().entriesListDoesNotContain("id") + .assertThat().entriesListDoesNotContain("state") + .assertThat().entriesListDoesNotContain("activityDefinitionId") + .assertThat().entriesListDoesNotContain("priority") + .assertThat().entriesListDoesNotContain("formResourceKey"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Use invalid where parameter. Check default error model schema.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void invalidWhereParameterCheckDefaultErrorModelSchema() throws Exception + { + restClient.authenticateUser(dataUser.getAdminUser()).where("assignee AND '" + assigneeUser.getUsername() + "'").withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(RestErrorModel.INVALID_QUERY_ERRORKEY) + .containsSummary(String.format(RestErrorModel.INVALID_WHERE_QUERY, "(assignee AND '" + assigneeUser.getUsername() + "')")) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, + executionType = ExecutionType.REGRESSION, description = "Check that for admin network gets tasks only from its network.") + public void adminTenantGetsTasksOnlyFromItsNetwork() throws Exception + { + UserModel adminTenant1 = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenant1); + + UserModel adminTenant2 = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenant2); + + UserModel tenantUser1 = dataUser.usingUser(adminTenant1).createUserWithTenant("userTenant1"); + UserModel tenantUserAssignee1 = dataUser.usingUser(adminTenant1).createUserWithTenant("userTenantAssignee1"); + + UserModel tenantUser2 = dataUser.usingUser(adminTenant2).createUserWithTenant("userTenant2"); + UserModel tenantUserAssignee2 = dataUser.usingUser(adminTenant2).createUserWithTenant("userTenantAssignee2"); + + RestProcessModel processOnTenant1 = restClient.authenticateUser(tenantUser1).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee1, false, Priority.Low); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestProcessModel processOnTenant2 = restClient.authenticateUser(tenantUser2).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee2, false, Priority.Normal); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestTaskModelsCollection tenantTasks1 = restClient.authenticateUser(adminTenant1).withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + tenantTasks1.assertThat().entriesListIsNotEmpty() + .and().entriesListCountIs(1) + .and().entriesListContains("assignee", String.format("userTenantAssignee1@%s", tenantUserAssignee1.getDomain().toLowerCase())) + .and().entriesListContains("processId", processOnTenant1.getId()) + .and().entriesListDoesNotContain("assignee", String.format("userTenantAssignee2@%s", tenantUserAssignee2.getDomain().toLowerCase())) + .and().entriesListDoesNotContain("processId", processOnTenant2.getId()); + + RestTaskModelsCollection tenantTasks2 = restClient.authenticateUser(adminTenant2).withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + tenantTasks2.assertThat().entriesListIsNotEmpty() + .and().entriesListCountIs(1) + .and().entriesListContains("assignee", String.format("userTenantAssignee2@%s", tenantUserAssignee2.getDomain().toLowerCase())) + .and().entriesListContains("processId", processOnTenant2.getId()) + .and().entriesListDoesNotContain("assignee", String.format("userTenantAssignee1@%s", tenantUserAssignee1.getDomain().toLowerCase())) + .and().entriesListDoesNotContain("processId", processOnTenant1.getId()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify the request in case of any user which is not involved.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void requestWithUserNotInvolved() throws Exception + { + taskModels = restClient.authenticateUser(userNotInvolved).withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + taskModels.assertThat().entriesListIsEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check that orderBy parameter is applied.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void orderByParameterApplied() throws Exception + { + taskModels = restClient.authenticateUser(dataUser.getAdminUser()).withParams("orderBy=id").withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + taskModels.assertThat().entriesListIsNotEmpty(). + and().entriesListIsSortedAscBy("id"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check that orderBy parameter is applied and supports only one parameter.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void orderByParameterSupportsOnlyOneParameter() throws Exception + { + taskModels = restClient.authenticateUser(dataUser.getAdminUser()).withParams("orderBy=id,processDefinitionId").withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Only one order by parameter is supported"); + taskModels.assertThat().entriesListIsEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check that where parameter is applied.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void whereParameterApplied() throws Exception + { + taskModels = restClient.authenticateUser(dataUser.getAdminUser()).withParams("where=(assignee='" + assigneeUser.getUsername() + "')").withWorkflowAPI() + .getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + taskModels.assertThat().entriesListIsNotEmpty().and().entriesListContains("assignee", assigneeUser.getUsername()).and().entriesListCountIs(1); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check that invalid orderBy parameter applied returns 400 status code.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void invalidOrderByParameterApplied() throws Exception + { + restClient.authenticateUser(dataUser.getAdminUser()).withParams("orderBy=invalidParameter").withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("invalidParameter is not supported"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check that for network enabled only that network tasks are returned.") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) + public void networkEnabledTasksReturned() throws Exception + { + restClient.authenticateUser(adminUser); + + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.usingTenant().createTenant(adminTenantUser); + + tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("userTenant"); + tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("userTenantAssignee"); + + restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee, false, Priority.Normal); + + tenantTask = restClient.authenticateUser(tenantUserAssignee).withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + tenantTask.assertThat().entriesListIsNotEmpty().and().entriesListCountIs(1).and().entriesListContains("assignee", + String.format("userTenantAssignee@%s", tenantUserAssignee.getDomain().toLowerCase())); + + } +} diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTests.java deleted file mode 100644 index cdfbaffdd..000000000 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTests.java +++ /dev/null @@ -1,205 +0,0 @@ -package org.alfresco.rest.workflow.tasks; - -import java.util.HashMap; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.core.JsonBodyGenerator; -import org.alfresco.rest.core.RestRequest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestTaskModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TaskModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -public class UpdateTaskCoreTests extends RestTest -{ - UserModel userModel; - SiteModel siteModel; - SiteModel tenantSiteModel; - UserModel candidateUser; - FileModel fileModel; - UserModel assigneeUser; - TaskModel taskModel; - TaskModel tenantTask; - RestTaskModel restTaskModel; - UserModel adminUser; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - - assigneeUser = dataUser.createRandomTestUser(); - } - - @BeforeMethod(alwaysRun = true) - public void createTask() throws Exception - { - taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can not update task from completed to claimed and response is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void taskOwnerCanNotUpdateTaskFromCompletedToClaimed() throws Exception - { - restTaskModel = restClient.authenticateUser(userModel).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("completed"); - restTaskModel = restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() - .containsSummary(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can not update task from completed to unclaimed and response is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void taskOwnerCanNotUpdateTaskFromCompletedToUnclaimed() throws Exception - { - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("completed"); - restTaskModel = restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() - .containsSummary(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can not update task from completed to completed and response is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void taskOwnerCanNotUpdateTaskWithCompleteStateTwice() throws Exception - { - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("completed"); - restClient.authenticateUser(userModel).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() - .containsSummary(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can update task from claimed to completed and response is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void taskOwnerCanUpdateTaskFromClaimedToCompleted() throws Exception - { - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("claimed"); - restTaskModel = restClient.authenticateUser(userModel).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("completed"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify user can update task from claimed to claimed and response is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void userCanUpdateTaskWithClaimedStateTwice() throws Exception - { - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("claimed"); - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("claimed"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can update task from unclaimed to completed and response is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void taskOwnerCanUpdateTaskFromUnclaimedToCompleted() throws Exception - { - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); - restTaskModel = restClient.authenticateUser(userModel).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("completed"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can not update task from unclaimed to unclaimed and response is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void taskOwnerCanNotUpdateTaskWithUnclaimedStateTwice() throws Exception - { - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); - restTaskModel = restClient.authenticateUser(userModel).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); - } - - @Bug(id = "REPO-1924") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can not update task from delegated to completed and response is 422") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void taskOwnerCanNotUpdateTaskFromDelegatedToCompleted() throws Exception - { - restClient.authenticateUser(userModel).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel); - HashMap body = new HashMap(); - body.put("state", "delegated"); - body.put("assignee", assigneeUser.getUsername()); - String postBody = JsonBodyGenerator.keyValueJson(body); - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), - restClient.getParameters()); - restTaskModel = restClient.processModel(RestTaskModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated").and().field("assignee") - .is(assigneeUser.getUsername()); - - restClient.authenticateUser(userModel).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(RestErrorModel.DELEGATED_TASK_CAN_NOT_BE_COMPLETED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can not update task from delegated to delegated and response is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void taskOwnerCanNotUpdateTaskWithDelegatedStateTwice() throws Exception - { - restClient.authenticateUser(userModel).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel); - HashMap body = new HashMap(); - body.put("state", "delegated"); - body.put("assignee", assigneeUser.getUsername()); - String postBody = JsonBodyGenerator.keyValueJson(body); - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), - restClient.getParameters()); - restTaskModel = restClient.processModel(RestTaskModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated").and().field("assignee") - .is(assigneeUser.getUsername()); - - request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); - restTaskModel = restClient.processModel(RestTaskModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated").and().field("assignee") - .is(assigneeUser.getUsername()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can update task from resolved to completed and response is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void taskOwnerCanUpdateTaskFromResolvedToCompleted() throws Exception - { - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("resolved"); - - restTaskModel = restClient.authenticateUser(userModel).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("completed"); - } -} diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTestsBulk2.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTestsBulk2.java deleted file mode 100644 index 469e4b5b9..000000000 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTestsBulk2.java +++ /dev/null @@ -1,362 +0,0 @@ -package org.alfresco.rest.workflow.tasks; - -import javax.json.JsonObject; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.core.JsonBodyGenerator; -import org.alfresco.rest.core.RestRequest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestTaskModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TaskModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -/** - * - * @author Cristina Axinte - * - */ -public class UpdateTaskCoreTestsBulk2 extends RestTest -{ - UserModel owner; - SiteModel siteModel; - UserModel candidateUser; - FileModel fileModel; - UserModel assigneeUser; - TaskModel taskModel; - RestTaskModel restTaskModel; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - owner = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(owner).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - assigneeUser = dataUser.createRandomTestUser(); - taskModel = dataWorkflow.usingUser(owner).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - } - - @BeforeMethod(alwaysRun=true) - public void createTask() throws Exception - { - taskModel = dataWorkflow.usingUser(owner).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task owner can update twice task with status resolve successfully (200)") - public void taskOwnerCanUpdateTaskWithResolveStateTwice() throws Exception - { - restTaskModel = restClient.authenticateUser(assigneeUser) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("resolved"); - - restClient.authenticateUser(owner) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task asignee cannot update twice task with status resolve - Forbidden (403)") - public void taskAssigneeCanNotUpdateTaskWithResolveStateTwice() throws Exception - { - restTaskModel = restClient.authenticateUser(assigneeUser) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("resolved"); - - restClient.authenticateUser(assigneeUser) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task cannot be update using a invalid json body property - Bad Request (400)") - public void taskCanNotBeUpdatedWithInvalidJsonBodyProperty() throws Exception - { - String invalidJsonProperty= "states"; - restClient.authenticateUser(assigneeUser) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel); - String postBody = JsonBodyGenerator.keyValueJson(invalidJsonProperty, "completed"); - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); - restClient.processModel(RestTaskModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.NO_CONTENT, "Unrecognized field \""+invalidJsonProperty+"\"")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task cannot be update using a invalid state - Bad Request (400)") - public void taskCanNotBeUpdatedWithInvalidState() throws Exception - { - restTaskModel = restClient.authenticateUser(assigneeUser) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("continued"); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_VALUE, "task state", "continued")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task cannot be update using a invalid property - Bad Request (400)") - public void taskCanNotBeUpdatedWithInvalidSelectProperty() throws Exception - { - String invalidProperty= "states"; - restClient.authenticateUser(assigneeUser) - .withParams("select=" + invalidProperty).withWorkflowAPI().usingTask(taskModel); - String postBody = JsonBodyGenerator.keyValueJson("state", "completed"); - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); - restClient.processModel(RestTaskModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.PROPERTY_DOES_NOT_EXIST, invalidProperty)); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task can be update using multiple select values successfully (200)") - public void taskCanBeUpdatedWithMultipleSelectValues() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("state", "resolved") - .add("assignee", "admin").build(); - - restTaskModel = restClient.authenticateUser(assigneeUser) - .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("resolved"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task assignee can complete task successfully (200)") - public void taskAssigneeCanCompleteTask() throws Exception - { - restTaskModel = restClient.authenticateUser(assigneeUser) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("completed"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task owner can complete task successfully (200))") - public void taskOwnerCanCompleteTask() throws Exception - { - restTaskModel = restClient.authenticateUser(assigneeUser) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("completed"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify any user cannot complete task - Forbidden (403))") - public void anyUserCannotCompleteTask() throws Exception - { - UserModel anyUser = dataUser.createRandomTestUser(); - - restTaskModel = restClient.authenticateUser(anyUser) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @Bug(id = "REPO-2062") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task owner cannot complete task with invalid name - Bad Request(400))") - public void taskOwnerCannotCompleteTaskWithInvalidName() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("state", "completed") - .add("variables", JsonBodyGenerator.defineJSONArray() - .add(JsonBodyGenerator.defineJSON() - .add("name", "bpmx_priorityx") - .add("type", "d:int") - .add("value", 1) - .add("scope", "global").build()) - ).build(); - - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state,variables").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.UNSUPPORTED_TYPE,"bpm_priorityx")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task owner cannot complete task with invalid Type - Bad Request(400))") - public void taskOwnerCannotCompleteTaskWithInvalidType() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("state", "completed") - .add("variables", JsonBodyGenerator.defineJSONArray() - .add(JsonBodyGenerator.defineJSON() - .add("name", "bpmx_priority") - .add("type", "d_int") - .add("value", 1) - .add("scope", "global").build()) - ).build(); - - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state,variables").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.UNSUPPORTED_TYPE,"d_int")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @Bug(id = "REPO-2062") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task owner cannot complete task with invalid value - Bad Request(400))") - public void taskOwnerCannotCompleteTaskWithInvalidValue() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("state", "completed") - .add("variables", JsonBodyGenerator.defineJSONArray() - .add(JsonBodyGenerator.defineJSON() - .add("name", "bpmx_priority") - .add("type", "d:int") - .add("value", "text") - .add("scope", "global").build()) - ).build(); - - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state,variables").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.UNSUPPORTED_TYPE, "text")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task owner cannot complete task with invalid scope - Bad Request(400))") - public void taskOwnerCannotCompleteTaskWithInvalidScope() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("state", "completed") - .add("variables", JsonBodyGenerator.defineJSONArray() - .add(JsonBodyGenerator.defineJSON() - .add("name", "bpmx_priority") - .add("type", "d:int") - .add("value", 1) - .add("scope", "globalscope").build()) - ).build(); - - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state,variables").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.ILLEGAL_SCOPE, "globalscope")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task assignee can claim task successfully (200)") - public void taskAssigneeCanClaimTask() throws Exception - { - restTaskModel = restClient.authenticateUser(assigneeUser) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("claimed"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task assignee can unclaim task successfully (200)") - public void taskAssigneeCanUnclaimTask() throws Exception - { - restTaskModel = restClient.authenticateUser(assigneeUser) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("unclaimed"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task assignee can delegate task successfully (200)") - public void taskAssigneeCanDelegateTask() throws Exception - { - UserModel delagateToUser = dataUser.createRandomTestUser(); - - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("state", "delegated") - .add("assignee", delagateToUser.getUsername()).build(); - - restTaskModel = restClient.authenticateUser(assigneeUser) - .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("delegated") - .and().field("assignee").is(delagateToUser.getUsername()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task owner can delegate task to same assignee successfully (200)") - public void taskOwnerCanDelegateTaskToSameAssignee() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("state", "delegated") - .add("assignee", assigneeUser.getUsername()).build(); - - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("delegated") - .and().field("assignee").is(assigneeUser.getUsername()); - } - - - @Bug(id = "REPO-2063") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task assignee cannot delegate task to task owner - (400)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void taskAssigneeCannotDelegateTaskToTaskOwner() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("state", "delegated") - .add("assignee", owner.getUsername()).build(); - - restTaskModel = restClient.authenticateUser(assigneeUser) - .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @Bug(id = "REPO-2063") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task assignee cannot delegate task to invalid assignee - (400)") - public void taskAssigneeCannotDelegateTaskToInvalidAssignee() throws Exception - { - UserModel invalidAssignee = new UserModel("invalidAssignee", "password"); - - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("state", "delegated") - .add("assignee", invalidAssignee.getUsername()).build(); - - restTaskModel = restClient.authenticateUser(assigneeUser) - .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - } -} diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTestsBulk3.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTestsBulk3.java deleted file mode 100644 index d6e53b4e7..000000000 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTestsBulk3.java +++ /dev/null @@ -1,128 +0,0 @@ -package org.alfresco.rest.workflow.tasks; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.core.RestRequest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestTaskModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TaskModel; -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; - -/** - * Created by Claudia Agache on 12/9/2016. - */ -public class UpdateTaskCoreTestsBulk3 extends RestTest -{ - UserModel owner; - SiteModel siteModel; - UserModel candidateUser; - FileModel fileModel; - UserModel assigneeUser; - TaskModel taskModel; - RestTaskModel restTaskModel; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - owner = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(owner).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - assigneeUser = dataUser.createRandomTestUser(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task assignee can update task with status resolve") - public void resolveTaskAsCurrentAssignee() throws Exception - { - taskModel = dataWorkflow.usingUser(owner).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - restTaskModel = restClient.authenticateUser(assigneeUser) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("resolved"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify update task using invalid taskId") - public void updateTaskUsingInvalidTaskId() throws Exception - { - taskModel = dataWorkflow.usingUser(owner).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - taskModel.setId("invalidId"); - - restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidId")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify update task using another name") - public void updateTaskUsingAnotherName() throws Exception - { - taskModel = dataWorkflow.usingUser(owner).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - - restClient.authenticateUser(owner).withParams("select=name").withWorkflowAPI().usingTask(taskModel); - String postBody = "{\"name\":\"newNameTask\"}"; - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); - restTaskModel = restClient.processModel(RestTaskModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("name").is("newNameTask"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify update task using another description") - public void updateTaskUsingAnotherDescription() throws Exception - { - taskModel = dataWorkflow.usingUser(owner).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - - restClient.authenticateUser(owner).withParams("select=description").withWorkflowAPI().usingTask(taskModel); - String postBody = "{\"description\":\"newDescription\"}"; - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); - restTaskModel = restClient.processModel(RestTaskModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("description").is("newDescription"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify update task using another priority") - public void updateTaskUsingAnotherPriority() throws Exception - { - taskModel = dataWorkflow.usingUser(owner).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - - restClient.authenticateUser(owner).withParams("select=priority").withWorkflowAPI().usingTask(taskModel); - String postBody = "{\"priority\":3}"; - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); - restTaskModel = restClient.processModel(RestTaskModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("priority").is(CMISUtil.Priority.Low.getLevel()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify update task using another priority") - public void updateTaskUsingAnotherOwner() throws Exception - { - taskModel = dataWorkflow.usingUser(owner).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - UserModel newOwner = dataUser.createRandomTestUser(); - - restClient.authenticateUser(owner).withParams("select=owner").withWorkflowAPI().usingTask(taskModel); - String postBody = "{\"owner\":\""+newOwner.getUsername()+"\"}"; - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); - restTaskModel = restClient.processModel(RestTaskModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("owner").is(newOwner.getUsername()); - } -} diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk1.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk1.java deleted file mode 100644 index e3ee74d64..000000000 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk1.java +++ /dev/null @@ -1,742 +0,0 @@ -package org.alfresco.rest.workflow.tasks; - -import javax.json.JsonObject; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.core.JsonBodyGenerator; -import org.alfresco.rest.core.RestRequest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestProcessDefinitionModel; -import org.alfresco.rest.model.RestTaskModel; -import org.alfresco.rest.model.RestVariableModelsCollection; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.ProcessModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TaskModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -/** - * - * @author Cristina Axinte - * - */ -public class UpdateTaskFullTestsBulk1 extends RestTest -{ - UserModel owner, anyUser; - SiteModel siteModel; - UserModel candidateUser; - FileModel fileModel; - UserModel assigneeUser; - TaskModel taskModel; - RestTaskModel restTaskModel; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - anyUser = dataUser.createRandomTestUser(); - owner = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(owner).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - assigneeUser = dataUser.createRandomTestUser(); - } - - @BeforeMethod(alwaysRun=true) - public void createTask() throws Exception - { - taskModel = dataWorkflow.usingUser(owner).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL, TestGroup.NETWORKS }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify tenant user that created the task can update task only in its network and response is 200, for other networks is 403") - public void ownerTenantCanUpdatedTaskOnlyInItsNetwork() throws Exception - { - UserModel adminUser = dataUser.getAdminUser(); - restClient.authenticateUser(adminUser); - - UserModel adminTenant1 = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenant1); - - UserModel ownerTenant1 = dataUser.usingUser(adminTenant1).createUserWithTenant("ownerTenant1"); - UserModel assigneeTenant1 = dataUser.usingUser(adminTenant1).createUserWithTenant("assigneeTenant1"); - SiteModel siteModel1 = dataSite.usingUser(ownerTenant1).createPublicRandomSite(); - FileModel fileModel1 = dataContent.usingUser(ownerTenant1).usingSite(siteModel1).createContent(DocumentType.TEXT_PLAIN); - RestProcessDefinitionModel def1 = restClient.authenticateUser(ownerTenant1).withWorkflowAPI().getAllProcessDefinitions().getEntries().get(0).onModel(); - TaskModel taskModel1 = dataWorkflow.usingUser(ownerTenant1).usingSite(siteModel1).usingResource(fileModel1) - .createTaskWithProcessDefAndAssignTo(def1.getId(), assigneeTenant1); - - UserModel adminTenant2 = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenant2); - - UserModel ownerTenant2 = dataUser.usingUser(adminTenant2).createUserWithTenant("ownerTenant2"); - UserModel assigneeTenant2 = dataUser.usingUser(adminTenant2).createUserWithTenant("userTenantAssignee2"); - SiteModel siteModel2 = dataSite.usingUser(ownerTenant2).createPublicRandomSite(); - FileModel fileModel2 = dataContent.usingUser(ownerTenant2).usingSite(siteModel2).createContent(DocumentType.TEXT_PLAIN); - RestProcessDefinitionModel def2 = restClient.authenticateUser(ownerTenant2).withWorkflowAPI().getAllProcessDefinitions().getEntries().get(0).onModel(); - TaskModel taskModel2 = dataWorkflow.usingUser(ownerTenant2).usingSite(siteModel2).usingResource(fileModel2) - .createTaskWithProcessDefAndAssignTo(def2.getId(), assigneeTenant2); - - restTaskModel = restClient.authenticateUser(ownerTenant2).withParams("select=state").withWorkflowAPI().usingTask(taskModel2).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel2.getId()) - .and().field("state").is("completed"); - - restTaskModel = restClient.authenticateUser(ownerTenant2).withParams("select=state").withWorkflowAPI().usingTask(taskModel1).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - - } - - @Bug(id = "REPO-1980") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL, TestGroup.NETWORKS }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify tenant admin can update only task from its network and response is 200") - public void adminTenantCanUpdateOnlyTaskInItsNetwork() throws Exception - { - UserModel adminUser = dataUser.getAdminUser(); - restClient.authenticateUser(adminUser); - - UserModel adminTenant1 = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenant1); - - UserModel ownerTenant1 = dataUser.usingUser(adminTenant1).createUserWithTenant("ownerTenant1"); - UserModel assigneeTenant1 = dataUser.usingUser(adminTenant1).createUserWithTenant("assigneeTenant1"); - SiteModel siteModel1 = dataSite.usingUser(ownerTenant1).createPublicRandomSite(); - FileModel fileModel1 = dataContent.usingUser(ownerTenant1).usingSite(siteModel1).createContent(DocumentType.TEXT_PLAIN); - RestProcessDefinitionModel def1 = restClient.authenticateUser(ownerTenant1).withWorkflowAPI().getAllProcessDefinitions().getEntries().get(0).onModel(); - TaskModel taskModel1 = dataWorkflow.usingUser(ownerTenant1).usingSite(siteModel1).usingResource(fileModel1) - .createTaskWithProcessDefAndAssignTo(def1.getId(), assigneeTenant1); - - UserModel adminTenant2 = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenant2); - - UserModel ownerTenant2 = dataUser.usingUser(adminTenant2).createUserWithTenant("ownerTenant2"); - UserModel assigneeTenant2 = dataUser.usingUser(adminTenant2).createUserWithTenant("userTenantAssignee2"); - SiteModel siteModel2 = dataSite.usingUser(ownerTenant2).createPublicRandomSite(); - FileModel fileModel2 = dataContent.usingUser(ownerTenant2).usingSite(siteModel2).createContent(DocumentType.TEXT_PLAIN); - RestProcessDefinitionModel def2 = restClient.authenticateUser(ownerTenant2).withWorkflowAPI().getAllProcessDefinitions().getEntries().get(0).onModel(); - TaskModel taskModel2 = dataWorkflow.usingUser(ownerTenant2).usingSite(siteModel2).usingResource(fileModel2) - .createTaskWithProcessDefAndAssignTo(def2.getId(), assigneeTenant2); - - restTaskModel = restClient.authenticateUser(adminTenant2).withParams("select=state").withWorkflowAPI().usingTask(taskModel2).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel2.getId()) - .and().field("state").is("completed"); - - restTaskModel = restClient.authenticateUser(adminTenant2).withParams("select=state").withWorkflowAPI().usingTask(taskModel1).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify owner cannot update task from status completed to delegated and response is 404") - public void ownerCannotUpdateTaskFromCompletedToDelegated() throws Exception - { - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("completed"); - - restClient.authenticateUser(owner) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("delegated"); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() - .containsErrorKey(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) - .containsSummary(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify assignee cannot update task from status completed to delegated and response is 404") - public void assigneeCannotUpdateTaskFromCompletedToDelegated() throws Exception - { - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("completed"); - - restClient.authenticateUser(assigneeUser) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("delegated"); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() - .containsErrorKey(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) - .containsSummary(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify owner cannot update task from status completed to resolved and response is 404") - public void ownerCannotUpdateTaskFromCompletedToResolved() throws Exception - { - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("completed"); - - restClient.authenticateUser(owner) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() - .containsErrorKey(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) - .containsSummary(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify assignee cannot update task from status completed to resolved and response is 404") - public void assigneeCannotUpdateTaskFromCompletedToResolved() throws Exception - { - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("completed"); - - restClient.authenticateUser(assigneeUser) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() - .containsErrorKey(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) - .containsSummary(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify owner cannot update task from status completed to completed and response is 404") - public void ownerCannotUpdateTaskFromCompletedToCompleted() throws Exception - { - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("completed"); - - restClient.authenticateUser(owner) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() - .containsErrorKey(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) - .containsSummary(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify assignee cannot update task from status completed to completed and response is 404") - public void assigneeCannotUpdateTaskFromCompletedToCompleted() throws Exception - { - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("completed"); - - restClient.authenticateUser(assigneeUser) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() - .containsErrorKey(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) - .containsSummary(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify owner can update task from status claimed to unclaimed and response is 200") - public void ownerCanUpdateTaskFromClaimedToUnclaimed() throws Exception - { - restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).getTask(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("claimed"); - - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("unclaimed"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify assignee can update task from status claimed to unclaimed and response is 200") - public void assigneeCanUpdateTaskFromClaimedToUnclaimed() throws Exception - { - restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).getTask(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("claimed"); - - restTaskModel = restClient.authenticateUser(assigneeUser) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("unclaimed"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify owner can update task from status claimed to delegated and response is 200") - public void ownerCanUpdateTaskFromClaimedToDelegated() throws Exception - { - restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).getTask(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("claimed"); - - UserModel newAssignee = dataUser.createRandomTestUser(); - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("state", "delegated") - .add("assignee", newAssignee.getUsername()).build(); - - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("delegated") - .and().field("assignee").is(newAssignee.getUsername()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify assignee can update task from status claimed to delegated and response is 200") - public void assigneeCanUpdateTaskFromClaimedToDelegated() throws Exception - { - restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).getTask(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("claimed"); - - UserModel newAssignee = dataUser.createRandomTestUser(); - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("state", "delegated") - .add("assignee", newAssignee.getUsername()).build(); - - restTaskModel = restClient.authenticateUser(assigneeUser) - .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("delegated") - .and().field("assignee").is(newAssignee.getUsername()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify owner can update task from status claimed to resolved and response is 200") - public void ownerCanUpdateTaskFromClaimedToResolved() throws Exception - { - restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).getTask(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("claimed"); - - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("resolved"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify assignee can update task from status claimed to resolved and response is 200") - public void assigneeCanUpdateTaskFromClaimedToResolved() throws Exception - { - restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).getTask(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("claimed"); - - restTaskModel = restClient.authenticateUser(assigneeUser) - .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("resolved"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify owner cannot update task from status claimed to claimed and response is 409") - public void ownerCannotUpdateTaskFromClaimedToClaimed() throws Exception - { - restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).getTask(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("claimed"); - - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); - restClient.assertStatusCodeIs(HttpStatus.CONFLICT).assertLastError() - .containsErrorKey(RestErrorModel.TASK_ALREADY_CLAIMED) - .containsSummary(RestErrorModel.TASK_ALREADY_CLAIMED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify assignee can update task from status claimed to claimed and response is 200") - public void assigneeCanUpdateTaskFromClaimedToClaimed() throws Exception - { - restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).getTask(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("claimed"); - - restTaskModel = restClient.authenticateUser(assigneeUser) - .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("claimed"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task owner can complete task with valid variables and response is 200") - public void taskOwnerCanCompleteTaskWithValidVariables() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("state", "completed") - .add("variables", JsonBodyGenerator.defineJSONArray() - .add(JsonBodyGenerator.defineJSON() - .add("name", "bpm_priority") - .add("type", "d:int") - .add("value", 3) - .add("scope", "global").build()) - ).build(); - - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state,variables").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("priority").is(1) - .and().field("state").is("completed") - .and().field("assignee").is(taskModel.getAssignee()); - RestVariableModelsCollection variables = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(restTaskModel).getTaskVariables(); - restClient.assertStatusCodeIs(HttpStatus.OK); - variables.getVariableByName("bpm_priority").assertThat().field("scope").is("global") - .and().field("name").is("bpm_priority") - .and().field("type").is("d:int") - .and().field("value").is(3); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task owner cannot complete task with empty variables array and response is 200") - public void taskOwnerCannotUpdateTaskWithEmptyVariablesArray() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("state", "completed") - .add("variables", JsonBodyGenerator.defineJSONArray() - ).build(); - - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state,variables").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("priority").is(1) - .and().field("state").is("completed") - .and().field("assignee").is(taskModel.getAssignee()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task owner cannot complete task with empty variables json body and response is 200") - public void taskOwnerCannotUpdateTaskWithEmptyVariablesJsonBody() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("state", "completed") - .add("variables", JsonBodyGenerator.defineJSONArray() - .add(JsonBodyGenerator.defineJSON().build()) - ).build(); - - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state,variables").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(RestErrorModel.VARIABLE_NAME_REQUIRED) - .containsSummary(RestErrorModel.VARIABLE_NAME_REQUIRED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify any user with no relation to task is forbidden to delegate other task with Rest API (403)") - public void anyUserIsForbiddenToDelegateOtherTask() throws Exception - { - UserModel anyUser= dataUser.createRandomTestUser(); - - restTaskModel = restClient.authenticateUser(anyUser).withWorkflowAPI().usingTask(taskModel).updateTask("delegated"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify any user with no relation to task is forbidden to resolve other task with Rest API (403)") - public void anyUserIsForbiddenToResolveOtherTask() throws Exception - { - UserModel anyUser= dataUser.createRandomTestUser(); - - restTaskModel = restClient.authenticateUser(anyUser).withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify any user with no relation to task is forbidden to claim other task with Rest API (403)") - public void anyUserIsForbiddenToClaimOtherTask() throws Exception - { - UserModel anyUser= dataUser.createRandomTestUser(); - - restTaskModel = restClient.authenticateUser(anyUser).withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify any user with no relation to task is forbidden to unclaim other task with Rest API (403)") - public void anyUserIsForbiddenToUnclaimOtherTask() throws Exception - { - UserModel anyUser= dataUser.createRandomTestUser(); - - restTaskModel = restClient.authenticateUser(anyUser).withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify user cannot delegate task with emty assignee name and response is 400") - public void updateTaskWithEmptyAssigneeValue() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("state", "delegated") - .add("assignee", "") - .build(); - - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(RestErrorModel.DELEGATING_ASSIGNEE_PROVIDED) - .containsSummary(RestErrorModel.DELEGATING_ASSIGNEE_PROVIDED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify owner can resolve task when assignee is the owner and response is 200") - public void taskOwnerUpdateTaskResolveStateAndOwnerAssignee() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("state", "resolved") - .add("assignee", owner.getUsername()) - .build(); - - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("state").is("resolved") - .and().field("assignee").isNull(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify owner cannot update task after it was deleted and response is 404") - public void updateTaskAfterItWasDeleted() throws Exception - { - ProcessModel process = new ProcessModel(); - process.setId(taskModel.getProcessId()); - dataWorkflow.usingUser(owner).deleteProcess(process); - - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.ENTITY_WAS_NOT_FOUND, taskModel.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task owner cannot update task with empty input body and response is 400") - public void taskOwnerCannotUpdateTaskWithEmptyInputBody() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON().build(); - - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(String.format(RestErrorModel.TASK_INVALID_STATE, "null")) - .containsSummary(String.format(RestErrorModel.TASK_INVALID_STATE, "null")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify any user cannot update task using another name") - public void anyUserCannotUpdateTaskUsingAnotherName() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("name", "Review Task-updated") - .build(); - - restClient.authenticateUser(anyUser).withParams("select=name").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify any user cannot update task using another description") - public void anyUserCannotUpdateTaskUsingAnotherDescription() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("description", "description updated") - .build(); - - restClient.authenticateUser(anyUser).withParams("select=description").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify any user cannot update task using another dueAt") - public void anyUserCannotUpdateTaskUsingAnotherDueAt() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("dueAt", "2025-01-01T11:57:32.000+0000") - .build(); - - restClient.authenticateUser(anyUser).withParams("select=dueAt").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify any user cannot update task using another priority") - public void anyUserCannotUpdateTaskUsingAnotherPriority() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("priority", 3) - .build(); - - restClient.authenticateUser(anyUser).withParams("select=priority").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify any user cannot update task using another priority") - public void anyUserCannotUpdateTaskUsingAnotherOwner() throws Exception - { - UserModel newOwner = dataUser.createRandomTestUser(); - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("owner", newOwner.getUsername()) - .build(); - - - restClient.authenticateUser(anyUser).withParams("select=owner").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify any user cannot update task using invalid name") - public void anyUserCannotUpdateTaskUsingInvalidName() throws Exception - { - restClient.authenticateUser(owner).withParams("select=name").withWorkflowAPI().usingTask(taskModel); - String postBody = "{\"name\":\"invalid-\"a\"}"; - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); - restTaskModel = restClient.processModel(RestTaskModel.class, request); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "Unexpected character ('a'")) - .containsSummary(String.format(RestErrorModel.NO_CONTENT, "Unexpected character ('a'")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify any user cannot update task using invalid description") - public void anyUserCannotUpdateTaskUsingInvalidDescription() throws Exception - { - restClient.authenticateUser(owner).withParams("select=description").withWorkflowAPI().usingTask(taskModel); - String postBody = "{\"description\":\"invalid-\"a\"}"; - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); - restTaskModel = restClient.processModel(RestTaskModel.class, request); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "Unexpected character ('a'")) - .containsSummary(String.format(RestErrorModel.NO_CONTENT, "Unexpected character ('a'")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify any user cannot update task using invalid dueAt") - public void anyUserCannotUpdateTaskUsingInvalidDueAt() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("dueAt", "invalid-date") - .build(); - - restClient.authenticateUser(anyUser).withParams("select=dueAt").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "Can not construct instance of java.util.Date from String value 'invalid-date'")) - .containsSummary(String.format(RestErrorModel.NO_CONTENT, "Can not construct instance of java.util.Date from String value 'invalid-date'")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify any user cannot update task using invalid priority") - public void anyUserCannotUpdateTaskUsingInvalidPriority() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("priority", "a") - .build(); - - restClient.authenticateUser(anyUser).withParams("select=priority").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "Can not construct instance of int from String value 'a'")) - .containsSummary(String.format(RestErrorModel.NO_CONTENT, "Can not construct instance of int from String value 'a'")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify any user cannot update task using invalid priority") - public void anyUserCannotUpdateTaskUsingInvalidOwner() throws Exception - { - restClient.authenticateUser(owner).withParams("select=owner").withWorkflowAPI().usingTask(taskModel); - String postBody = "{\"owner\":\"invalid-\"a\"}"; - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); - restTaskModel = restClient.processModel(RestTaskModel.class, request); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "Unexpected character ('a'")) - .containsSummary(String.format(RestErrorModel.NO_CONTENT, "Unexpected character ('a'")); - } -} diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk2.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk2.java deleted file mode 100644 index 22f741646..000000000 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk2.java +++ /dev/null @@ -1,446 +0,0 @@ -package org.alfresco.rest.workflow.tasks; - -import javax.json.JsonObject; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.core.JsonBodyGenerator; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestTaskModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TaskModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -public class UpdateTaskFullTestsBulk2 extends RestTest -{ - private UserModel taskCreator; - private SiteModel siteModel; - private FileModel fileModel; - private UserModel assigneeUser; - private TaskModel taskModel; - private RestTaskModel restTaskModel; - private UserModel adminUser; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - taskCreator = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - assigneeUser = dataUser.createRandomTestUser(); - } - - @BeforeMethod(alwaysRun = true) - public void createTask() throws Exception - { - taskModel = dataWorkflow.usingUser(taskCreator).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from unclaimed to claimed by task creator") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void taskCreatorCanUpdateTaskFromUnclaimedToClaimed() throws Exception - { - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); - restTaskModel = restClient.authenticateUser(taskCreator).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("claimed"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task cannot be updated from unclaimed to claimed by a regular user not connected to the task") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void regularUserCannotUpdateTaskFromUnclaimedToClaimed() throws Exception - { - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from unclaimed to delegated by task creator") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void taskCreatorCanUpdateTaskFromUnclaimedToDelegated() throws Exception - { - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); - - JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", taskCreator.getUsername()).build(); - - restTaskModel = restClient.authenticateUser(taskCreator).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task cannot be updated from unclaimed to delegated by a regular user not connected to the task") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void regularUserCannotUpdateTaskFromUnclaimedToDelegated() throws Exception - { - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); - - JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); - - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from unclaimed to resolved by task creator") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void taskCreatorCanUpdateTaskFromUnclaimedToResolved() throws Exception - { - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); - restTaskModel = restClient.authenticateUser(taskCreator).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("resolved"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from unclaimed to resolved by a regular user not connected to the task") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void regularCanUpdateTaskFromUnclaimedToResolved() throws Exception - { - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from unclaimed to unclaimed by task creator") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void taskCreatorCanUpdateTaskFromUnclaimedToUnclaimed() throws Exception - { - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); - restTaskModel = restClient.authenticateUser(taskCreator).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from unclaimed to unclaimed by a regular user not connected to the task") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void regularUserCannotUpdateTaskFromUnclaimedToUnclaimed() throws Exception - { - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Bug(id = "REPO-1982") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from delegated to unclaimed by task creator") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void taskCreatorCanUpdateTaskFromDelegatedToUnclaimed() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); - - restTaskModel = restClient.authenticateUser(taskCreator).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); - } - - @Bug(id = "REPO-1982") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from delegated to unclaimed by task assignee") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void taskAssigneeCanUpdateTaskFromDelegatedToUnclaimed() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); - - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task cannot be updated from delegated to claimed since it is already claimed by task creator") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void taskCreatorCannotUpdateTaskFromDelegatedToClaimed() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); - - restTaskModel = restClient.authenticateUser(taskCreator).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); - restClient.assertStatusCodeIs(HttpStatus.CONFLICT).assertLastError() - .containsErrorKey(RestErrorModel.TASK_ALREADY_CLAIMED) - .containsSummary(RestErrorModel.TASK_ALREADY_CLAIMED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from delegated to claimed since it is already claimed by task assignee") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void taskAssigneeCanUpdateTaskFromDelegatedToClaimed() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); - - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); - } - - @Bug(id = "REPO-1924") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from delegated to completed by task creator") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void taskCreatorCanUpdateTaskFromDelegatedToCompleted() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); - - restTaskModel = restClient.authenticateUser(taskCreator).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() - .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .containsSummary(RestErrorModel.DELEGATED_TASK_CAN_NOT_BE_COMPLETED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Bug(id = "REPO-1924") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from delegated to completed by task assignee") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void taskAssigneeCanUpdateTaskFromDelegatedToCompleted() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); - - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() - .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .containsSummary(RestErrorModel.DELEGATED_TASK_CAN_NOT_BE_COMPLETED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from delegated to resolved") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void taskCreatorCanUpdateTaskFromDelegatedToResolved() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); - - restTaskModel = restClient.authenticateUser(taskCreator).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("resolved"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from delegated to resolved by task assignee") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void taskAssigneeCanUpdateTaskFromDelegatedToResolved() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); - - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("resolved"); - } - - @Bug(id = "REPO-1982") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from resolved to unclaimed by task creator") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void taskCreatorCanUpdateTaskFromResolvedToUnclaimed() throws Exception - { - restTaskModel = restClient.authenticateUser(taskCreator).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - - restTaskModel = restClient.authenticateUser(taskCreator).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("resolved"); - } - - @Bug(id = "REPO-1982") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task cannot be updated from resolved to unclaimed by task assignee") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void taskAssigneeCannotUpdateTaskFromResolvedToUnclaimed() throws Exception - { - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Bug(id = "REPO-1982") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task cannot be updated from resolved to claimed by task owner") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void taskOwnerCanUpdateTaskFromResolvedToClaimed() throws Exception - { - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - - restTaskModel = restClient.authenticateUser(taskCreator).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("resolved"); - } - - @Bug(id = "REPO-1982") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task cannot be updated from resolved to claimed by task assignee") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void taskAssigneeCanUpdateTaskFromResolvedToClaimed() throws Exception - { - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Bug(id = "REPO-1982") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from resolved to delegated by task creator") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void taskCreatorCannotUpdateTaskFromResolvedToDelegated() throws Exception - { - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - - JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); - restTaskModel = restClient.authenticateUser(taskCreator).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from resolved to delegated by task assignee") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void taskAssigneeCannotUpdateTaskFromResolvedToDelegated() throws Exception - { - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - - JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Bug(id = "REPO-1982") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from resolved to resolved by task creator") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void taskCreatorCannotUpdateTaskFromResolvedToResolved() throws Exception - { - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - - restTaskModel = restClient.authenticateUser(taskCreator).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("resolved"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from resolved to resolved by task assignee") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void taskAssigneeCannotUpdateTaskFromResolvedToResolved() throws Exception - { - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Bug(id = "REPO-1982") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Update task by providing empty select value") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void updateTaskByProvidingEmptySelectValue() throws Exception - { - restTaskModel = restClient.authenticateUser(taskCreator).withParams("select=").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(RestErrorModel.INVALID_SELECT_ERRORKEY) - .containsSummary(RestErrorModel.INVALID_SELECT) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Update task by providing empty state value") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void updateTaskByProvidingEmptyStateValue() throws Exception - { - restTaskModel = restClient.authenticateUser(taskCreator).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask(" "); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(String.format(RestErrorModel.TASK_INVALID_STATE, " ")) - .containsSummary(String.format(RestErrorModel.TASK_INVALID_STATE, " ")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskSanityTests.java deleted file mode 100644 index edb4670ef..000000000 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskSanityTests.java +++ /dev/null @@ -1,104 +0,0 @@ -package org.alfresco.rest.workflow.tasks; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestTaskModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.GroupModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TaskModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - - -public class UpdateTaskSanityTests extends RestTest -{ - UserModel userModel; - SiteModel siteModel; - UserModel candidateUser; - FileModel fileModel; - UserModel assigneeUser; - TaskModel taskModel; - RestTaskModel restTaskModel; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - assigneeUser = dataUser.createRandomTestUser(); - taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify admin user updates task with Rest API and response is successfull (200)") - public void adminUserUpdatesAnyTaskWithSuccess() throws Exception - { - UserModel adminUser = dataUser.getAdminUser(); - - restTaskModel = restClient.authenticateUser(adminUser).withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("description").is(taskModel.getMessage()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify assignee user updates its assigned task with Rest API and response is successfull (200)") - public void assigneeUserUpdatesItsTaskWithSuccess() throws Exception - { - restTaskModel = restClient.authenticateUser(assigneeUser).withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("description").is(taskModel.getMessage()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify user that started the task updates the started task with Rest API and response is successfull (200)") - public void starterUserUpdatesItsTaskWithSuccess() throws Exception - { - restTaskModel = restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify any user with no relation to task is forbidden to update other task with Rest API (403)") - public void anyUserIsForbiddenToUpdateOtherTask() throws Exception - { - UserModel anyUser= dataUser.createRandomTestUser(); - - restTaskModel = restClient.authenticateUser(anyUser).withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify candidate user updates its specific task and no other user claimed the task with Rest API and response is successfull (200)") - public void candidateUserUpdatesItsTasks() throws Exception - { - UserModel userModel1 = dataUser.createRandomTestUser(); - UserModel userModel2 = dataUser.createRandomTestUser(); - GroupModel group = dataGroup.createRandomGroup(); - dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); - TaskModel taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); - - restTaskModel = restClient.authenticateUser(userModel1).withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat() - .field("dueAt").isNotEmpty() - .and().field("processDefinitionId").is("activitiReviewPooled:1:12") - .and().field("processId").is(taskModel.getProcessId()) - .and().field("name").is("Review Task") - .and().field("description").is(taskModel.getMessage()) - .and().field("startedAt").isNotEmpty() - .and().field("id").is(taskModel.getId()) - .and().field("state").is("unclaimed") - .and().field("activityDefinitionId").is("reviewTask") - .and().field("priority").is(taskModel.getPriority().getLevel()) - .and().field("formResourceKey").is("wf:activitiReviewTask"); - } -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskTests.java new file mode 100644 index 000000000..4db6b0a89 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskTests.java @@ -0,0 +1,1722 @@ +package org.alfresco.rest.workflow.tasks; + +import java.util.HashMap; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.JsonBodyGenerator; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestProcessDefinitionModel; +import org.alfresco.rest.model.RestTaskModel; +import org.alfresco.rest.model.RestVariableModelsCollection; +import org.alfresco.utility.model.*; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import javax.json.JsonObject; + +public class UpdateTaskTests extends RestTest +{ + UserModel owner, anyUser; + SiteModel siteModel; + FileModel fileModel; + UserModel assigneeUser; + TaskModel taskModel; + RestTaskModel restTaskModel; + UserModel adminUser; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + owner = dataUser.createRandomTestUser(); + anyUser = dataUser.createRandomTestUser(); + assigneeUser = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); + fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + } + + @BeforeMethod(alwaysRun = true) + public void createTask() throws Exception + { + taskModel = dataWorkflow.usingUser(owner).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify admin user updates task with Rest API and response is successfull (200)") + public void adminUserUpdatesAnyTaskWithSuccess() throws Exception + { + restTaskModel = restClient.authenticateUser(adminUser).withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("description").is(taskModel.getMessage()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify assignee user updates its assigned task with Rest API and response is successfull (200)") + public void assigneeUserUpdatesItsTaskWithSuccess() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser).withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("description").is(taskModel.getMessage()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify user that started the task updates the started task with Rest API and response is successfull (200)") + public void starterUserUpdatesItsTaskWithSuccess() throws Exception + { + restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify any user with no relation to task is forbidden to update other task with Rest API (403)") + public void anyUserIsForbiddenToUpdateOtherTask() throws Exception + { + restTaskModel = restClient.authenticateUser(anyUser).withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify candidate user updates its specific task and no other user claimed the task with Rest API and response is successfull (200)") + public void candidateUserUpdatesItsTasks() throws Exception + { + UserModel userModel1 = dataUser.createRandomTestUser(); + UserModel userModel2 = dataUser.createRandomTestUser(); + GroupModel group = dataGroup.createRandomGroup(); + dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); + TaskModel taskModel = dataWorkflow.usingUser(owner).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); + + restTaskModel = restClient.authenticateUser(userModel1).withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat() + .field("dueAt").isNotEmpty() + .and().field("processDefinitionId").is("activitiReviewPooled:1:12") + .and().field("processId").is(taskModel.getProcessId()) + .and().field("name").is("Review Task") + .and().field("description").is(taskModel.getMessage()) + .and().field("startedAt").isNotEmpty() + .and().field("id").is(taskModel.getId()) + .and().field("state").is("unclaimed") + .and().field("activityDefinitionId").is("reviewTask") + .and().field("priority").is(taskModel.getPriority().getLevel()) + .and().field("formResourceKey").is("wf:activitiReviewTask"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task owner can update twice task with status resolve successfully (200)") + public void taskOwnerCanUpdateTaskWithResolveStateTwice() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("resolved"); + + restClient.authenticateUser(owner) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task asignee cannot update twice task with status resolve - Forbidden (403)") + public void taskAssigneeCanNotUpdateTaskWithResolveStateTwice() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("resolved"); + + restClient.authenticateUser(assigneeUser) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task cannot be update using a invalid json body property - Bad Request (400)") + public void taskCanNotBeUpdatedWithInvalidJsonBodyProperty() throws Exception + { + String invalidJsonProperty= "states"; + restClient.authenticateUser(assigneeUser) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel); + String postBody = JsonBodyGenerator.keyValueJson(invalidJsonProperty, "completed"); + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); + restClient.processModel(RestTaskModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.NO_CONTENT, "Unrecognized field \""+invalidJsonProperty+"\"")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task cannot be update using a invalid state - Bad Request (400)") + public void taskCanNotBeUpdatedWithInvalidState() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("continued"); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_VALUE, "task state", "continued")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task cannot be update using a invalid property - Bad Request (400)") + public void taskCanNotBeUpdatedWithInvalidSelectProperty() throws Exception + { + String invalidProperty= "states"; + restClient.authenticateUser(assigneeUser) + .withParams("select=" + invalidProperty).withWorkflowAPI().usingTask(taskModel); + String postBody = JsonBodyGenerator.keyValueJson("state", "completed"); + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); + restClient.processModel(RestTaskModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.PROPERTY_DOES_NOT_EXIST, invalidProperty)); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task can be update using multiple select values successfully (200)") + public void taskCanBeUpdatedWithMultipleSelectValues() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("state", "resolved") + .add("assignee", "admin").build(); + + restTaskModel = restClient.authenticateUser(assigneeUser) + .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("resolved"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Verify task assignee can complete task successfully (200)") + public void taskAssigneeCanCompleteTask() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("completed"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Verify task owner can complete task successfully (200))") + public void taskOwnerCanCompleteTask() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("completed"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify any user cannot complete task - Forbidden (403))") + public void anyUserCannotCompleteTask() throws Exception + { + UserModel anyUser = dataUser.createRandomTestUser(); + + restTaskModel = restClient.authenticateUser(anyUser) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @Bug(id = "REPO-2062") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task owner cannot complete task with invalid name - Bad Request(400))") + public void taskOwnerCannotCompleteTaskWithInvalidName() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("state", "completed") + .add("variables", JsonBodyGenerator.defineJSONArray() + .add(JsonBodyGenerator.defineJSON() + .add("name", "bpmx_priorityx") + .add("type", "d:int") + .add("value", 1) + .add("scope", "global").build()) + ).build(); + + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state,variables").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.UNSUPPORTED_TYPE,"bpm_priorityx")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task owner cannot complete task with invalid Type - Bad Request(400))") + public void taskOwnerCannotCompleteTaskWithInvalidType() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("state", "completed") + .add("variables", JsonBodyGenerator.defineJSONArray() + .add(JsonBodyGenerator.defineJSON() + .add("name", "bpmx_priority") + .add("type", "d_int") + .add("value", 1) + .add("scope", "global").build()) + ).build(); + + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state,variables").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.UNSUPPORTED_TYPE,"d_int")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @Bug(id = "REPO-2062") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task owner cannot complete task with invalid value - Bad Request(400))") + public void taskOwnerCannotCompleteTaskWithInvalidValue() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("state", "completed") + .add("variables", JsonBodyGenerator.defineJSONArray() + .add(JsonBodyGenerator.defineJSON() + .add("name", "bpmx_priority") + .add("type", "d:int") + .add("value", "text") + .add("scope", "global").build()) + ).build(); + + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state,variables").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.UNSUPPORTED_TYPE, "text")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task owner cannot complete task with invalid scope - Bad Request(400))") + public void taskOwnerCannotCompleteTaskWithInvalidScope() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("state", "completed") + .add("variables", JsonBodyGenerator.defineJSONArray() + .add(JsonBodyGenerator.defineJSON() + .add("name", "bpmx_priority") + .add("type", "d:int") + .add("value", 1) + .add("scope", "globalscope").build()) + ).build(); + + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state,variables").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.ILLEGAL_SCOPE, "globalscope")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task assignee can claim task successfully (200)") + public void taskAssigneeCanClaimTask() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("claimed"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task assignee can unclaim task successfully (200)") + public void taskAssigneeCanUnclaimTask() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("unclaimed"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task assignee can delegate task successfully (200)") + public void taskAssigneeCanDelegateTask() throws Exception + { + UserModel delagateToUser = dataUser.createRandomTestUser(); + + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("state", "delegated") + .add("assignee", delagateToUser.getUsername()).build(); + + restTaskModel = restClient.authenticateUser(assigneeUser) + .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("delegated") + .and().field("assignee").is(delagateToUser.getUsername()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task owner can delegate task to same assignee successfully (200)") + public void taskOwnerCanDelegateTaskToSameAssignee() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("state", "delegated") + .add("assignee", assigneeUser.getUsername()).build(); + + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("delegated") + .and().field("assignee").is(assigneeUser.getUsername()); + } + + + @Bug(id = "REPO-2063") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task assignee cannot delegate task to task owner - (400)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskAssigneeCannotDelegateTaskToTaskOwner() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("state", "delegated") + .add("assignee", owner.getUsername()).build(); + + restTaskModel = restClient.authenticateUser(assigneeUser) + .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @Bug(id = "REPO-2063") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task assignee cannot delegate task to invalid assignee - (400)") + public void taskAssigneeCannotDelegateTaskToInvalidAssignee() throws Exception + { + UserModel invalidAssignee = new UserModel("invalidAssignee", "password"); + + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("state", "delegated") + .add("assignee", invalidAssignee.getUsername()).build(); + + restTaskModel = restClient.authenticateUser(assigneeUser) + .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task assignee can update task with status resolve") + public void resolveTaskAsCurrentAssignee() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("resolved"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify update task using invalid taskId") + public void updateTaskUsingInvalidTaskId() throws Exception + { + taskModel.setId("invalidId"); + + restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidId")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify update task using another name") + public void updateTaskUsingAnotherName() throws Exception + { + restClient.authenticateUser(owner).withParams("select=name").withWorkflowAPI().usingTask(taskModel); + String postBody = "{\"name\":\"newNameTask\"}"; + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); + restTaskModel = restClient.processModel(RestTaskModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("name").is("newNameTask"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify update task using another description") + public void updateTaskUsingAnotherDescription() throws Exception + { + restClient.authenticateUser(owner).withParams("select=description").withWorkflowAPI().usingTask(taskModel); + String postBody = "{\"description\":\"newDescription\"}"; + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); + restTaskModel = restClient.processModel(RestTaskModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("description").is("newDescription"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify update task using another priority") + public void updateTaskUsingAnotherPriority() throws Exception + { + restClient.authenticateUser(owner).withParams("select=priority").withWorkflowAPI().usingTask(taskModel); + String postBody = "{\"priority\":3}"; + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); + restTaskModel = restClient.processModel(RestTaskModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("priority").is(CMISUtil.Priority.Low.getLevel()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify update task using another priority") + public void updateTaskUsingAnotherOwner() throws Exception + { + UserModel newOwner = dataUser.createRandomTestUser(); + + restClient.authenticateUser(owner).withParams("select=owner").withWorkflowAPI().usingTask(taskModel); + String postBody = "{\"owner\":\""+newOwner.getUsername()+"\"}"; + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); + restTaskModel = restClient.processModel(RestTaskModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("owner").is(newOwner.getUsername()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can not update task from completed to claimed and response is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskOwnerCanNotUpdateTaskFromCompletedToClaimed() throws Exception + { + restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("completed"); + restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() + .containsSummary(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can not update task from completed to unclaimed and response is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskOwnerCanNotUpdateTaskFromCompletedToUnclaimed() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("completed"); + restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() + .containsSummary(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can not update task from completed to completed and response is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskOwnerCanNotUpdateTaskWithCompleteStateTwice() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("completed"); + restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() + .containsSummary(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can update task from claimed to completed and response is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskOwnerCanUpdateTaskFromClaimedToCompleted() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("claimed"); + restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("completed"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify user can update task from claimed to claimed and response is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void userCanUpdateTaskWithClaimedStateTwice() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("claimed"); + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("claimed"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can update task from unclaimed to completed and response is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskOwnerCanUpdateTaskFromUnclaimedToCompleted() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); + restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("completed"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can not update task from unclaimed to unclaimed and response is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskOwnerCanNotUpdateTaskWithUnclaimedStateTwice() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); + restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); + } + + @Bug(id = "REPO-1924") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can not update task from delegated to completed and response is 422") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskOwnerCanNotUpdateTaskFromDelegatedToCompleted() throws Exception + { + restClient.authenticateUser(owner).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel); + HashMap body = new HashMap(); + body.put("state", "delegated"); + body.put("assignee", assigneeUser.getUsername()); + String postBody = JsonBodyGenerator.keyValueJson(body); + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), + restClient.getParameters()); + restTaskModel = restClient.processModel(RestTaskModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated").and().field("assignee") + .is(assigneeUser.getUsername()); + + restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(RestErrorModel.DELEGATED_TASK_CAN_NOT_BE_COMPLETED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can not update task from delegated to delegated and response is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskOwnerCanNotUpdateTaskWithDelegatedStateTwice() throws Exception + { + restClient.authenticateUser(owner).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel); + HashMap body = new HashMap(); + body.put("state", "delegated"); + body.put("assignee", assigneeUser.getUsername()); + String postBody = JsonBodyGenerator.keyValueJson(body); + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), + restClient.getParameters()); + restTaskModel = restClient.processModel(RestTaskModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated").and().field("assignee") + .is(assigneeUser.getUsername()); + + request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); + restTaskModel = restClient.processModel(RestTaskModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated").and().field("assignee") + .is(assigneeUser.getUsername()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can update task from resolved to completed and response is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskOwnerCanUpdateTaskFromResolvedToCompleted() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("resolved"); + + restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("completed"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify tenant user that created the task can update task only in its network and response is 200, for other networks is 403") + public void ownerTenantCanUpdatedTaskOnlyInItsNetwork() throws Exception + { + restClient.authenticateUser(adminUser); + + UserModel adminTenant1 = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenant1); + + UserModel ownerTenant1 = dataUser.usingUser(adminTenant1).createUserWithTenant("ownerTenant1"); + UserModel assigneeTenant1 = dataUser.usingUser(adminTenant1).createUserWithTenant("assigneeTenant1"); + SiteModel siteModel1 = dataSite.usingUser(ownerTenant1).createPublicRandomSite(); + FileModel fileModel1 = dataContent.usingUser(ownerTenant1).usingSite(siteModel1).createContent(DocumentType.TEXT_PLAIN); + RestProcessDefinitionModel def1 = restClient.authenticateUser(ownerTenant1).withWorkflowAPI().getAllProcessDefinitions().getEntries().get(0).onModel(); + TaskModel taskModel1 = dataWorkflow.usingUser(ownerTenant1).usingSite(siteModel1).usingResource(fileModel1) + .createTaskWithProcessDefAndAssignTo(def1.getId(), assigneeTenant1); + + UserModel adminTenant2 = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenant2); + + UserModel ownerTenant2 = dataUser.usingUser(adminTenant2).createUserWithTenant("ownerTenant2"); + UserModel assigneeTenant2 = dataUser.usingUser(adminTenant2).createUserWithTenant("userTenantAssignee2"); + SiteModel siteModel2 = dataSite.usingUser(ownerTenant2).createPublicRandomSite(); + FileModel fileModel2 = dataContent.usingUser(ownerTenant2).usingSite(siteModel2).createContent(DocumentType.TEXT_PLAIN); + RestProcessDefinitionModel def2 = restClient.authenticateUser(ownerTenant2).withWorkflowAPI().getAllProcessDefinitions().getEntries().get(0).onModel(); + TaskModel taskModel2 = dataWorkflow.usingUser(ownerTenant2).usingSite(siteModel2).usingResource(fileModel2) + .createTaskWithProcessDefAndAssignTo(def2.getId(), assigneeTenant2); + + restTaskModel = restClient.authenticateUser(ownerTenant2).withParams("select=state").withWorkflowAPI().usingTask(taskModel2).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel2.getId()) + .and().field("state").is("completed"); + + restTaskModel = restClient.authenticateUser(ownerTenant2).withParams("select=state").withWorkflowAPI().usingTask(taskModel1).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + + } + + @Bug(id = "REPO-1980") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify tenant admin can update only task from its network and response is 200") + public void adminTenantCanUpdateOnlyTaskInItsNetwork() throws Exception + { + restClient.authenticateUser(adminUser); + + UserModel adminTenant1 = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenant1); + + UserModel ownerTenant1 = dataUser.usingUser(adminTenant1).createUserWithTenant("ownerTenant1"); + UserModel assigneeTenant1 = dataUser.usingUser(adminTenant1).createUserWithTenant("assigneeTenant1"); + SiteModel siteModel1 = dataSite.usingUser(ownerTenant1).createPublicRandomSite(); + FileModel fileModel1 = dataContent.usingUser(ownerTenant1).usingSite(siteModel1).createContent(DocumentType.TEXT_PLAIN); + RestProcessDefinitionModel def1 = restClient.authenticateUser(ownerTenant1).withWorkflowAPI().getAllProcessDefinitions().getEntries().get(0).onModel(); + TaskModel taskModel1 = dataWorkflow.usingUser(ownerTenant1).usingSite(siteModel1).usingResource(fileModel1) + .createTaskWithProcessDefAndAssignTo(def1.getId(), assigneeTenant1); + + UserModel adminTenant2 = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenant2); + + UserModel ownerTenant2 = dataUser.usingUser(adminTenant2).createUserWithTenant("ownerTenant2"); + UserModel assigneeTenant2 = dataUser.usingUser(adminTenant2).createUserWithTenant("userTenantAssignee2"); + SiteModel siteModel2 = dataSite.usingUser(ownerTenant2).createPublicRandomSite(); + FileModel fileModel2 = dataContent.usingUser(ownerTenant2).usingSite(siteModel2).createContent(DocumentType.TEXT_PLAIN); + RestProcessDefinitionModel def2 = restClient.authenticateUser(ownerTenant2).withWorkflowAPI().getAllProcessDefinitions().getEntries().get(0).onModel(); + TaskModel taskModel2 = dataWorkflow.usingUser(ownerTenant2).usingSite(siteModel2).usingResource(fileModel2) + .createTaskWithProcessDefAndAssignTo(def2.getId(), assigneeTenant2); + + restTaskModel = restClient.authenticateUser(adminTenant2).withParams("select=state").withWorkflowAPI().usingTask(taskModel2).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel2.getId()) + .and().field("state").is("completed"); + + restTaskModel = restClient.authenticateUser(adminTenant2).withParams("select=state").withWorkflowAPI().usingTask(taskModel1).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify owner cannot update task from status completed to delegated and response is 404") + public void ownerCannotUpdateTaskFromCompletedToDelegated() throws Exception + { + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("completed"); + + restClient.authenticateUser(owner) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("delegated"); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() + .containsErrorKey(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) + .containsSummary(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify assignee cannot update task from status completed to delegated and response is 404") + public void assigneeCannotUpdateTaskFromCompletedToDelegated() throws Exception + { + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("completed"); + + restClient.authenticateUser(assigneeUser) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("delegated"); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() + .containsErrorKey(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) + .containsSummary(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify owner cannot update task from status completed to resolved and response is 404") + public void ownerCannotUpdateTaskFromCompletedToResolved() throws Exception + { + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("completed"); + + restClient.authenticateUser(owner) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() + .containsErrorKey(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) + .containsSummary(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify assignee cannot update task from status completed to resolved and response is 404") + public void assigneeCannotUpdateTaskFromCompletedToResolved() throws Exception + { + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("completed"); + + restClient.authenticateUser(assigneeUser) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() + .containsErrorKey(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) + .containsSummary(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify owner cannot update task from status completed to completed and response is 404") + public void ownerCannotUpdateTaskFromCompletedToCompleted() throws Exception + { + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("completed"); + + restClient.authenticateUser(owner) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() + .containsErrorKey(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) + .containsSummary(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify assignee cannot update task from status completed to completed and response is 404") + public void assigneeCannotUpdateTaskFromCompletedToCompleted() throws Exception + { + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("completed"); + + restClient.authenticateUser(assigneeUser) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() + .containsErrorKey(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) + .containsSummary(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify owner can update task from status claimed to unclaimed and response is 200") + public void ownerCanUpdateTaskFromClaimedToUnclaimed() throws Exception + { + restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).getTask(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("claimed"); + + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("unclaimed"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify assignee can update task from status claimed to unclaimed and response is 200") + public void assigneeCanUpdateTaskFromClaimedToUnclaimed() throws Exception + { + restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).getTask(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("claimed"); + + restTaskModel = restClient.authenticateUser(assigneeUser) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("unclaimed"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify owner can update task from status claimed to delegated and response is 200") + public void ownerCanUpdateTaskFromClaimedToDelegated() throws Exception + { + restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).getTask(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("claimed"); + + UserModel newAssignee = dataUser.createRandomTestUser(); + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("state", "delegated") + .add("assignee", newAssignee.getUsername()).build(); + + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("delegated") + .and().field("assignee").is(newAssignee.getUsername()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify assignee can update task from status claimed to delegated and response is 200") + public void assigneeCanUpdateTaskFromClaimedToDelegated() throws Exception + { + restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).getTask(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("claimed"); + + UserModel newAssignee = dataUser.createRandomTestUser(); + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("state", "delegated") + .add("assignee", newAssignee.getUsername()).build(); + + restTaskModel = restClient.authenticateUser(assigneeUser) + .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("delegated") + .and().field("assignee").is(newAssignee.getUsername()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify owner can update task from status claimed to resolved and response is 200") + public void ownerCanUpdateTaskFromClaimedToResolved() throws Exception + { + restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).getTask(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("claimed"); + + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("resolved"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify assignee can update task from status claimed to resolved and response is 200") + public void assigneeCanUpdateTaskFromClaimedToResolved() throws Exception + { + restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).getTask(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("claimed"); + + restTaskModel = restClient.authenticateUser(assigneeUser) + .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("resolved"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify owner cannot update task from status claimed to claimed and response is 409") + public void ownerCannotUpdateTaskFromClaimedToClaimed() throws Exception + { + restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).getTask(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("claimed"); + + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); + restClient.assertStatusCodeIs(HttpStatus.CONFLICT).assertLastError() + .containsErrorKey(RestErrorModel.TASK_ALREADY_CLAIMED) + .containsSummary(RestErrorModel.TASK_ALREADY_CLAIMED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify assignee can update task from status claimed to claimed and response is 200") + public void assigneeCanUpdateTaskFromClaimedToClaimed() throws Exception + { + restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).getTask(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("claimed"); + + restTaskModel = restClient.authenticateUser(assigneeUser) + .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("claimed"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task owner can complete task with valid variables and response is 200") + public void taskOwnerCanCompleteTaskWithValidVariables() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("state", "completed") + .add("variables", JsonBodyGenerator.defineJSONArray() + .add(JsonBodyGenerator.defineJSON() + .add("name", "bpm_priority") + .add("type", "d:int") + .add("value", 3) + .add("scope", "global").build()) + ).build(); + + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state,variables").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("priority").is(1) + .and().field("state").is("completed") + .and().field("assignee").is(taskModel.getAssignee()); + RestVariableModelsCollection variables = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(restTaskModel).getTaskVariables(); + restClient.assertStatusCodeIs(HttpStatus.OK); + variables.getVariableByName("bpm_priority").assertThat().field("scope").is("global") + .and().field("name").is("bpm_priority") + .and().field("type").is("d:int") + .and().field("value").is(3); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task owner cannot complete task with empty variables array and response is 200") + public void taskOwnerCannotUpdateTaskWithEmptyVariablesArray() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("state", "completed") + .add("variables", JsonBodyGenerator.defineJSONArray() + ).build(); + + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state,variables").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("priority").is(1) + .and().field("state").is("completed") + .and().field("assignee").is(taskModel.getAssignee()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task owner cannot complete task with empty variables json body and response is 200") + public void taskOwnerCannotUpdateTaskWithEmptyVariablesJsonBody() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("state", "completed") + .add("variables", JsonBodyGenerator.defineJSONArray() + .add(JsonBodyGenerator.defineJSON().build()) + ).build(); + + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state,variables").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(RestErrorModel.VARIABLE_NAME_REQUIRED) + .containsSummary(RestErrorModel.VARIABLE_NAME_REQUIRED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify any user with no relation to task is forbidden to delegate other task with Rest API (403)") + public void anyUserIsForbiddenToDelegateOtherTask() throws Exception + { + restTaskModel = restClient.authenticateUser(anyUser).withWorkflowAPI().usingTask(taskModel).updateTask("delegated"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify any user with no relation to task is forbidden to resolve other task with Rest API (403)") + public void anyUserIsForbiddenToResolveOtherTask() throws Exception + { + restTaskModel = restClient.authenticateUser(anyUser).withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify any user with no relation to task is forbidden to claim other task with Rest API (403)") + public void anyUserIsForbiddenToClaimOtherTask() throws Exception + { + restTaskModel = restClient.authenticateUser(anyUser).withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify any user with no relation to task is forbidden to unclaim other task with Rest API (403)") + public void anyUserIsForbiddenToUnclaimOtherTask() throws Exception + { + restTaskModel = restClient.authenticateUser(anyUser).withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify user cannot delegate task with emty assignee name and response is 400") + public void updateTaskWithEmptyAssigneeValue() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("state", "delegated") + .add("assignee", "") + .build(); + + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(RestErrorModel.DELEGATING_ASSIGNEE_PROVIDED) + .containsSummary(RestErrorModel.DELEGATING_ASSIGNEE_PROVIDED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify owner can resolve task when assignee is the owner and response is 200") + public void taskOwnerUpdateTaskResolveStateAndOwnerAssignee() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("state", "resolved") + .add("assignee", owner.getUsername()) + .build(); + + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("state").is("resolved") + .and().field("assignee").isNull(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify owner cannot update task after it was deleted and response is 404") + public void updateTaskAfterItWasDeleted() throws Exception + { + ProcessModel process = new ProcessModel(); + process.setId(taskModel.getProcessId()); + dataWorkflow.usingUser(owner).deleteProcess(process); + + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.ENTITY_WAS_NOT_FOUND, taskModel.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task owner cannot update task with empty input body and response is 400") + public void taskOwnerCannotUpdateTaskWithEmptyInputBody() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON().build(); + + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(String.format(RestErrorModel.TASK_INVALID_STATE, "null")) + .containsSummary(String.format(RestErrorModel.TASK_INVALID_STATE, "null")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify any user cannot update task using another name") + public void anyUserCannotUpdateTaskUsingAnotherName() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("name", "Review Task-updated") + .build(); + + restClient.authenticateUser(anyUser).withParams("select=name").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify any user cannot update task using another description") + public void anyUserCannotUpdateTaskUsingAnotherDescription() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("description", "description updated") + .build(); + + restClient.authenticateUser(anyUser).withParams("select=description").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify any user cannot update task using another dueAt") + public void anyUserCannotUpdateTaskUsingAnotherDueAt() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("dueAt", "2025-01-01T11:57:32.000+0000") + .build(); + + restClient.authenticateUser(anyUser).withParams("select=dueAt").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify any user cannot update task using another priority") + public void anyUserCannotUpdateTaskUsingAnotherPriority() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("priority", 3) + .build(); + + restClient.authenticateUser(anyUser).withParams("select=priority").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify any user cannot update task using another priority") + public void anyUserCannotUpdateTaskUsingAnotherOwner() throws Exception + { + UserModel newOwner = dataUser.createRandomTestUser(); + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("owner", newOwner.getUsername()) + .build(); + + + restClient.authenticateUser(anyUser).withParams("select=owner").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify any user cannot update task using invalid name") + public void anyUserCannotUpdateTaskUsingInvalidName() throws Exception + { + restClient.authenticateUser(owner).withParams("select=name").withWorkflowAPI().usingTask(taskModel); + String postBody = "{\"name\":\"invalid-\"a\"}"; + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); + restTaskModel = restClient.processModel(RestTaskModel.class, request); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "Unexpected character ('a'")) + .containsSummary(String.format(RestErrorModel.NO_CONTENT, "Unexpected character ('a'")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify any user cannot update task using invalid description") + public void anyUserCannotUpdateTaskUsingInvalidDescription() throws Exception + { + restClient.authenticateUser(owner).withParams("select=description").withWorkflowAPI().usingTask(taskModel); + String postBody = "{\"description\":\"invalid-\"a\"}"; + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); + restTaskModel = restClient.processModel(RestTaskModel.class, request); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "Unexpected character ('a'")) + .containsSummary(String.format(RestErrorModel.NO_CONTENT, "Unexpected character ('a'")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify any user cannot update task using invalid dueAt") + public void anyUserCannotUpdateTaskUsingInvalidDueAt() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("dueAt", "invalid-date") + .build(); + + restClient.authenticateUser(anyUser).withParams("select=dueAt").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "Can not construct instance of java.util.Date from String value 'invalid-date'")) + .containsSummary(String.format(RestErrorModel.NO_CONTENT, "Can not construct instance of java.util.Date from String value 'invalid-date'")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify any user cannot update task using invalid priority") + public void anyUserCannotUpdateTaskUsingInvalidPriority() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("priority", "a") + .build(); + + restClient.authenticateUser(anyUser).withParams("select=priority").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "Can not construct instance of int from String value 'a'")) + .containsSummary(String.format(RestErrorModel.NO_CONTENT, "Can not construct instance of int from String value 'a'")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify any user cannot update task using invalid priority") + public void anyUserCannotUpdateTaskUsingInvalidOwner() throws Exception + { + restClient.authenticateUser(owner).withParams("select=owner").withWorkflowAPI().usingTask(taskModel); + String postBody = "{\"owner\":\"invalid-\"a\"}"; + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); + restTaskModel = restClient.processModel(RestTaskModel.class, request); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "Unexpected character ('a'")) + .containsSummary(String.format(RestErrorModel.NO_CONTENT, "Unexpected character ('a'")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from unclaimed to claimed by task creator") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskCreatorCanUpdateTaskFromUnclaimedToClaimed() throws Exception + { + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); + restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("claimed"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task cannot be updated from unclaimed to claimed by a regular user not connected to the task") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void regularUserCannotUpdateTaskFromUnclaimedToClaimed() throws Exception + { + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from unclaimed to delegated by task creator") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskCreatorCanUpdateTaskFromUnclaimedToDelegated() throws Exception + { + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); + + JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", owner.getUsername()).build(); + + restTaskModel = restClient.authenticateUser(owner).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task cannot be updated from unclaimed to delegated by a regular user not connected to the task") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void regularUserCannotUpdateTaskFromUnclaimedToDelegated() throws Exception + { + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); + + JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); + + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from unclaimed to resolved by task creator") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskCreatorCanUpdateTaskFromUnclaimedToResolved() throws Exception + { + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); + restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("resolved"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from unclaimed to resolved by a regular user not connected to the task") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void regularCanNotUpdateTaskFromUnclaimedToResolved() throws Exception + { + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from unclaimed to unclaimed by task creator") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskCreatorCanUpdateTaskFromUnclaimedToUnclaimed() throws Exception + { + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); + restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from unclaimed to unclaimed by a regular user not connected to the task") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void regularUserCannotUpdateTaskFromUnclaimedToUnclaimed() throws Exception + { + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Bug(id = "REPO-1982") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from delegated to unclaimed by task creator") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskCreatorCanUpdateTaskFromDelegatedToUnclaimed() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); + + restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); + } + + @Bug(id = "REPO-1982") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from delegated to unclaimed by task assignee") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskAssigneeCanUpdateTaskFromDelegatedToUnclaimed() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); + + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task cannot be updated from delegated to claimed since it is already claimed by task creator") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskCreatorCannotUpdateTaskFromDelegatedToClaimed() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); + + restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); + restClient.assertStatusCodeIs(HttpStatus.CONFLICT).assertLastError() + .containsErrorKey(RestErrorModel.TASK_ALREADY_CLAIMED) + .containsSummary(RestErrorModel.TASK_ALREADY_CLAIMED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from delegated to claimed since it is already claimed by task assignee") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskAssigneeCanUpdateTaskFromDelegatedToClaimed() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); + + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); + } + + @Bug(id = "REPO-1924") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from delegated to completed by task creator") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskCreatorCanUpdateTaskFromDelegatedToCompleted() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); + + restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() + .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .containsSummary(RestErrorModel.DELEGATED_TASK_CAN_NOT_BE_COMPLETED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Bug(id = "REPO-1924") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from delegated to completed by task assignee") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskAssigneeCanUpdateTaskFromDelegatedToCompleted() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); + + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() + .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .containsSummary(RestErrorModel.DELEGATED_TASK_CAN_NOT_BE_COMPLETED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from delegated to resolved") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskCreatorCanUpdateTaskFromDelegatedToResolved() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); + + restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("resolved"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from delegated to resolved by task assignee") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskAssigneeCanUpdateTaskFromDelegatedToResolved() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); + + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("resolved"); + } + + @Bug(id = "REPO-1982") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from resolved to unclaimed by task creator") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskCreatorCanUpdateTaskFromResolvedToUnclaimed() throws Exception + { + restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + + restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("resolved"); + } + + @Bug(id = "REPO-1982") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task cannot be updated from resolved to unclaimed by task assignee") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskAssigneeCannotUpdateTaskFromResolvedToUnclaimed() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Bug(id = "REPO-1982") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task cannot be updated from resolved to claimed by task owner") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskOwnerCanUpdateTaskFromResolvedToClaimed() throws Exception + { + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + + restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("resolved"); + } + + @Bug(id = "REPO-1982") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task cannot be updated from resolved to claimed by task assignee") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskAssigneeCanUpdateTaskFromResolvedToClaimed() throws Exception + { + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Bug(id = "REPO-1982") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from resolved to delegated by task creator") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskCreatorCannotUpdateTaskFromResolvedToDelegated() throws Exception + { + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + + JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); + restTaskModel = restClient.authenticateUser(owner).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from resolved to delegated by task assignee") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskAssigneeCannotUpdateTaskFromResolvedToDelegated() throws Exception + { + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + + JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Bug(id = "REPO-1982") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from resolved to resolved by task creator") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskCreatorCannotUpdateTaskFromResolvedToResolved() throws Exception + { + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + + restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("resolved"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from resolved to resolved by task assignee") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskAssigneeCannotUpdateTaskFromResolvedToResolved() throws Exception + { + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Bug(id = "REPO-1982") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Update task by providing empty select value") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void updateTaskByProvidingEmptySelectValue() throws Exception + { + restTaskModel = restClient.authenticateUser(owner).withParams("select=").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(RestErrorModel.INVALID_SELECT_ERRORKEY) + .containsSummary(RestErrorModel.INVALID_SELECT) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Update task by providing empty state value") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void updateTaskByProvidingEmptyStateValue() throws Exception + { + restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask(" "); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(String.format(RestErrorModel.TASK_INVALID_STATE, " ")) + .containsSummary(String.format(RestErrorModel.TASK_INVALID_STATE, " ")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } +} diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/candidates/GetTaskCandidatesCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/candidates/GetTaskCandidatesCoreTests.java deleted file mode 100644 index eaa4bcf0f..000000000 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/candidates/GetTaskCandidatesCoreTests.java +++ /dev/null @@ -1,108 +0,0 @@ -package org.alfresco.rest.workflow.tasks.candidates; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.GroupModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TaskModel; -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 bogdan.bocancea - * - */ - -public class GetTaskCandidatesCoreTests extends RestTest -{ - private UserModel userModel, userModel1, userModel2; - private SiteModel siteModel; - private FileModel fileModel; - private TaskModel taskModel; - private GroupModel group; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - userModel1 = dataUser.createRandomTestUser(); - userModel2 = dataUser.createRandomTestUser(); - group = dataGroup.createRandomGroup(); - dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify get task candidates with invalid task id") - public void getTaskCandidatesWithInvalidTaskId() throws Exception - { - taskModel = dataWorkflow.usingUser(userModel) - .usingSite(siteModel) - .usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); - taskModel.setId("invalid-id"); - restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).getTaskCandidates(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalid-id")); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify get task candidates with empty task id") - public void getTaskCandidatesWithEmptyTaskId() throws Exception - { - taskModel = dataWorkflow.usingUser(userModel) - .usingSite(siteModel) - .usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); - taskModel.setId(""); - restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).getTaskCandidates(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify get task candidates for completed task") - public void getTaskCandidatesForCompletedTask() throws Exception - { - taskModel = dataWorkflow.usingUser(userModel) - .usingSite(siteModel) - .usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); - - restClient.authenticateUser(userModel1).withWorkflowAPI().usingTask(taskModel).getTaskCandidates(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - dataWorkflow.usingUser(userModel1).taskDone(taskModel); - - restClient.authenticateUser(userModel1).withWorkflowAPI().usingTask(taskModel).getTaskCandidates(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, taskModel.getId())); - - restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).getTaskCandidates(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, taskModel.getId())); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify get task candidates by non candidate user") - public void getTaskCandidatesByNonCandidateUser() throws Exception - { - UserModel outsider = dataUser.createRandomTestUser(); - taskModel = dataWorkflow.usingUser(userModel) - .usingSite(siteModel) - .usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); - restClient.authenticateUser(outsider).withWorkflowAPI().usingTask(taskModel).getTaskCandidates(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/candidates/GetTaskCandidatesFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/candidates/GetTaskCandidatesRegressionTests.java similarity index 74% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/candidates/GetTaskCandidatesFullTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/candidates/GetTaskCandidatesRegressionTests.java index aebaa0707..353e3bff6 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/candidates/GetTaskCandidatesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/candidates/GetTaskCandidatesRegressionTests.java @@ -22,7 +22,7 @@ import org.testng.annotations.Test; * @author bogdan.bocancea * */ -public class GetTaskCandidatesFullTests extends RestTest +public class GetTaskCandidatesRegressionTests extends RestTest { private UserModel userModel, userModel1, userModel2; private SiteModel siteModel; @@ -43,6 +43,71 @@ public class GetTaskCandidatesFullTests extends RestTest dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); } + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify get task candidates with invalid task id") + public void getTaskCandidatesWithInvalidTaskId() throws Exception + { + taskModel = dataWorkflow.usingUser(userModel) + .usingSite(siteModel) + .usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); + taskModel.setId("invalid-id"); + restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).getTaskCandidates(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalid-id")); + } + + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify get task candidates with empty task id") + public void getTaskCandidatesWithEmptyTaskId() throws Exception + { + taskModel = dataWorkflow.usingUser(userModel) + .usingSite(siteModel) + .usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); + taskModel.setId(""); + restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).getTaskCandidates(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); + } + + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify get task candidates for completed task") + public void getTaskCandidatesForCompletedTask() throws Exception + { + taskModel = dataWorkflow.usingUser(userModel) + .usingSite(siteModel) + .usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); + + restClient.authenticateUser(userModel1).withWorkflowAPI().usingTask(taskModel).getTaskCandidates(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + dataWorkflow.usingUser(userModel1).taskDone(taskModel); + + restClient.authenticateUser(userModel1).withWorkflowAPI().usingTask(taskModel).getTaskCandidates(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, taskModel.getId())); + + restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).getTaskCandidates(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, taskModel.getId())); + } + + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify get task candidates by non candidate user") + public void getTaskCandidatesByNonCandidateUser() throws Exception + { + UserModel outsider = dataUser.createRandomTestUser(); + taskModel = dataWorkflow.usingUser(userModel) + .usingSite(siteModel) + .usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); + restClient.authenticateUser(outsider).withWorkflowAPI().usingTask(taskModel).getTaskCandidates(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check default error model schema for get task candidates") @@ -59,7 +124,7 @@ public class GetTaskCandidatesFullTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE) .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); } - + @Bug(id="MNT-17438") @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, @@ -76,7 +141,7 @@ public class GetTaskCandidatesFullTests extends RestTest .entriesListIsNotEmpty() .and().paginationField("count").is("0"); } - + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Get task candidates with max items parameter set to 0") @@ -93,7 +158,7 @@ public class GetTaskCandidatesFullTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE) .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); } - + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Get task candidates with max items parameter") @@ -109,7 +174,7 @@ public class GetTaskCandidatesFullTests extends RestTest .entriesListIsNotEmpty() .and().paginationField("count").is("1"); } - + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Get task candidates with properties") @@ -125,7 +190,7 @@ public class GetTaskCandidatesFullTests extends RestTest .field("candidateId").contains(group.getGroupIdentifier()).and() .field("candidateType").isNull(); } - + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Get task candidates with invalid properties") @@ -140,7 +205,7 @@ public class GetTaskCandidatesFullTests extends RestTest candidateModels.getEntries().get(0).onModel().assertThat() .fieldsCount().is(0).and(); } - + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Get task candidates by deleted candidate") @@ -152,9 +217,9 @@ public class GetTaskCandidatesFullTests extends RestTest restClient.authenticateUser(userModel1).withWorkflowAPI() .usingTask(taskModel).getTaskCandidates(); restClient.assertStatusCodeIs(HttpStatus.OK); - + dataUser.usingAdmin().deleteUser(userModel1); - + restClient.authenticateUser(userModel1).withWorkflowAPI() .usingTask(taskModel).getTaskCandidates(); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) @@ -163,7 +228,7 @@ public class GetTaskCandidatesFullTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE) .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); } - + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Get task candidates by deleted group") @@ -178,9 +243,9 @@ public class GetTaskCandidatesFullTests extends RestTest restClient.authenticateUser(newUser).withWorkflowAPI() .usingTask(taskModel).getTaskCandidates(); restClient.assertStatusCodeIs(HttpStatus.OK); - + dataGroup.usingAdmin().deleteGroup(deletedGroup); - + restClient.authenticateUser(newUser).withWorkflowAPI() .usingTask(taskModel).getTaskCandidates(); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) @@ -188,7 +253,7 @@ public class GetTaskCandidatesFullTests extends RestTest .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) .stackTraceIs(RestErrorModel.STACKTRACE); } - + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Get task candidates by user that was removed from group") @@ -202,9 +267,9 @@ public class GetTaskCandidatesFullTests extends RestTest restClient.authenticateUser(newUser).withWorkflowAPI() .usingTask(taskModel).getTaskCandidates(); restClient.assertStatusCodeIs(HttpStatus.OK); - + dataGroup.usingAdmin().removeUserFromGroup(group, newUser); - + restClient.authenticateUser(newUser).withWorkflowAPI() .usingTask(taskModel).getTaskCandidates(); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemTestsBulk1.java similarity index 95% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemSanityTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemTestsBulk1.java index 6e5b66bc7..f44a27c38 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemTestsBulk1.java @@ -21,7 +21,7 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -public class AddTaskItemSanityTests extends RestTest +public class AddTaskItemTestsBulk1 extends RestTest { private UserModel userModel, userWhoStartsTask, assigneeUser; private SiteModel siteModel; @@ -96,9 +96,9 @@ public class AddTaskItemSanityTests extends RestTest .assertThat().field("mimeType").is(taskItems.getEntries().get(1).onModel().getMimeType()); } - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @Bug(id = "MNT-16966") - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify that in case task item exists the request fails") public void createTaskItemThatAlreadyExists() throws Exception { @@ -122,9 +122,9 @@ public class AddTaskItemSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); } - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @Bug(id = "MNT-16966") - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify that in case task item exists the request fails") public void createMultipleTaskItemThatAlreadyExists() throws Exception { @@ -160,10 +160,10 @@ public class AddTaskItemSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); } - @Test(groups = { TestGroup.NETWORKS,TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + @Test(groups = { TestGroup.NETWORKS,TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add task item using admin user from same network") - public void addTaskItemByAdminSameNetwork() throws JsonToModelConversionException, Exception + public void addTaskItemByAdminSameNetwork() throws Exception { UserModel adminUser = dataUser.getAdminUser(); restClient.authenticateUser(adminUser); @@ -190,10 +190,10 @@ public class AddTaskItemSanityTests extends RestTest .and().field("mimeType").is(taskItem.getMimeType()); } - @Test(groups = { TestGroup.NETWORKS,TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + @Test(groups = { TestGroup.NETWORKS,TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add task item using admin user from same network") - public void addMultipleTaskItemByAdminSameNetwork() throws JsonToModelConversionException, Exception + public void addMultipleTaskItemByAdminSameNetwork() throws Exception { UserModel adminUser = dataUser.getAdminUser(); restClient.authenticateUser(adminUser); diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemTestsBulk2.java similarity index 94% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemCoreTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemTestsBulk2.java index 911725f2b..2b1d0b5eb 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemTestsBulk2.java @@ -19,7 +19,7 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -public class AddTaskItemCoreTests extends RestTest +public class AddTaskItemTestsBulk2 extends RestTest { private UserModel userModel, assigneeUser, anotherUser; private SiteModel siteModel; @@ -40,10 +40,10 @@ public class AddTaskItemCoreTests extends RestTest taskId = taskModel.getId(); } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Add task item using random user.") - public void addTaskItemByRandomUser() throws JsonToModelConversionException, Exception + public void addTaskItemByRandomUser() throws Exception { anotherUser = dataUser.createRandomTestUser(); restClient.authenticateUser(anotherUser).withWorkflowAPI().usingTask(taskModel).addTaskItem(fileModel); @@ -56,10 +56,10 @@ public class AddTaskItemCoreTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE); } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Add multiple task item using random user.") - public void addMultipleTaskItemByRandomUser() throws JsonToModelConversionException, Exception + public void addMultipleTaskItemByRandomUser() throws Exception { anotherUser = dataUser.createRandomTestUser(); restClient.authenticateUser(anotherUser).withWorkflowAPI().usingTask(taskModel) @@ -73,7 +73,7 @@ public class AddTaskItemCoreTests extends RestTest } @Bug(id = "ACE-5683") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task item, is falling in case invalid itemBody is provided") public void failedAddingTaskItemIfInvalidItemBodyIsProvided() throws Exception @@ -89,7 +89,7 @@ public class AddTaskItemCoreTests extends RestTest } @Bug(id = "ACE-5683") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding multiple task item, is falling in case invalid itemBody is provided") public void failedAddingMultipleTaskItemIfInvalidItemBodyIsProvided() throws Exception @@ -106,7 +106,7 @@ public class AddTaskItemCoreTests extends RestTest } @Bug(id = "ACE-5675") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task item is falling in case empty item body is provided") public void failedAddingTaskItemIfEmptyItemBodyIsProvided() throws Exception @@ -119,7 +119,7 @@ public class AddTaskItemCoreTests extends RestTest } @Bug(id = "ACE-5675") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding multiple task item is falling in case empty item body is provided") public void failedAddingMultipleTaskItemIfEmptyItemBodyIsProvided() throws Exception @@ -131,7 +131,7 @@ public class AddTaskItemCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(""); } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task item is falling in case invalid task id is provided") public void failedAddingTaskItemIfInvalidTaskIdIsProvided() throws Exception @@ -146,7 +146,7 @@ public class AddTaskItemCoreTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE);; } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task item is falling in case invalid task id is provided") public void failedAddingMultipleTaskItemIfInvalidTaskIdIsProvided() throws Exception @@ -162,7 +162,7 @@ public class AddTaskItemCoreTests extends RestTest } @Bug(id = "ACE-5675") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task item is falling in case incomplete body type is provided") public void failedAddingTaskVariableIfIncompleteBodyIsProvided() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemTestsBulk3.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemFullTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemTestsBulk3.java index c929d2652..447d0d27d 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemTestsBulk3.java @@ -20,7 +20,7 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -public class AddTaskItemFullTests extends RestTest +public class AddTaskItemTestsBulk3 extends RestTest { private UserModel userModel, adminUser,userWhoStartsTask, assigneeUser; private SiteModel siteModel; @@ -44,7 +44,7 @@ public class AddTaskItemFullTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Add task item using random user.") - public void addTaskItemByTheUserThatStartedTheProcess() throws JsonToModelConversionException, Exception + public void addTaskItemByTheUserThatStartedTheProcess() throws Exception { taskItem = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingTask(taskModel).addTaskItem(fileModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); @@ -62,7 +62,7 @@ public class AddTaskItemFullTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Add multiple task item using random user.") - public void addMultipleTaskItemByTheUserThatStartedTheProcess() throws JsonToModelConversionException, Exception + public void addMultipleTaskItemByTheUserThatStartedTheProcess() throws Exception { fileModel1 = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); taskItems = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingTask(taskModel) @@ -168,7 +168,7 @@ public class AddTaskItemFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Delete multiple task item then create it again") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL}) - public void deleteMultipleTaskItemThenCreateItAgain() throws Exception + public void deleteMultipleTaskItemsThenCreateThemAgain() throws Exception { taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel) .createNewTaskAndAssignTo(assigneeUser); @@ -187,5 +187,4 @@ public class AddTaskItemFullTests extends RestTest restClient.withWorkflowAPI().usingTask(taskModel).addTaskItems(document2, document1, document3); restClient.assertStatusCodeIs(HttpStatus.CREATED); } - - } +} diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/items/GetTaskItemsCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/items/GetTaskItemsCoreTests.java deleted file mode 100644 index 8b853dac7..000000000 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/items/GetTaskItemsCoreTests.java +++ /dev/null @@ -1,160 +0,0 @@ -package org.alfresco.rest.workflow.tasks.items; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestItemModel; -import org.alfresco.rest.model.RestItemModelsCollection; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.model.RestTaskModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TaskModel; -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; - -/** - * Created by Claudia Agache on 12/8/2016. - */ -public class GetTaskItemsCoreTests extends RestTest -{ - private UserModel adminUser, userWhoStartsTask, assignee; - private SiteModel siteModel; - private FileModel fileModel; - private TaskModel taskModel; - private RestItemModelsCollection itemModels; - private RestProcessModel addedProcess; - private RestTaskModel addedTask; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - userWhoStartsTask = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - adminUser = dataUser.getAdminUser(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify if get task items call return status code 404 when invalid taskId is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void getTaskItemsUsingInvalidTaskId() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); - taskModel.setId("invalidId"); - - restClient.authenticateUser(assignee).withWorkflowAPI() - .usingTask(taskModel).getTaskItems(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidId")); - - taskModel.setId(""); - - restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() - .usingTask(taskModel).getTaskItems(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, - executionType = ExecutionType.REGRESSION, - description = "Verify if get task items request returns status code 200 after the task is finished.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void getTaskItemsAfterFinishingTask() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); - dataWorkflow.usingUser(assignee).taskDone(taskModel); - restClient.authenticateUser(userWhoStartsTask); - itemModels = restClient.withWorkflowAPI().usingTask(taskModel).getTaskItems(); - restClient.assertStatusCodeIs(HttpStatus.OK); - itemModels.assertThat().entriesListIsNotEmpty().and().entriesListContains("name", fileModel.getName()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, - executionType = ExecutionType.REGRESSION, - description = "Verify if get task items request returns status code 200 after the process is deleted (Task state is now completed.)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void getTaskItemsAfterDeletingProcess() throws Exception - { - addedProcess = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); - addedTask = restClient.withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess); - restClient.withWorkflowAPI().usingTask(addedTask).addTaskItem(fileModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.withWorkflowAPI().usingProcess(addedProcess).deleteProcess(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - itemModels = restClient.withWorkflowAPI().usingTask(addedTask).getTaskItems(); - restClient.assertStatusCodeIs(HttpStatus.OK); - itemModels.assertThat().entriesListIsNotEmpty().and().entriesListContains("name", fileModel.getName()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify gets task items call with admin from different network") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE, TestGroup.NETWORKS }) - public void getTaskItemsByAdminFromAnotherNetwork() throws Exception - { - UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); - UserModel adminTenantUser2 = UserModel.getAdminTenantUser(); - - restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser1); - restClient.usingTenant().createTenant(adminTenantUser2); - - UserModel tenantUser1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenant"); - UserModel tenantUserAssignee1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenantAssignee"); - - siteModel = dataSite.usingUser(adminTenantUser1).createPublicRandomSite(); - fileModel = dataContent.usingUser(adminTenantUser1).usingSite(siteModel).createContent(DocumentType.XML); - addedProcess = restClient.authenticateUser(tenantUser1).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee1, false, Priority.Normal); - addedTask = restClient.withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess); - restClient.withWorkflowAPI().usingTask(addedTask).addTaskItem(fileModel); - - restClient.authenticateUser(adminTenantUser2).withWorkflowAPI().usingTask(addedTask).getTaskItems(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify gets task items call returns only task items inside network") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE, TestGroup.NETWORKS }) - public void getTaskItemsReturnsOnlyItemsFromThatNetwork() throws Exception - { - UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); - UserModel adminTenantUser2 = UserModel.getAdminTenantUser(); - - restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser1); - restClient.usingTenant().createTenant(adminTenantUser2); - - UserModel tenantUser1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenant1"); - UserModel tenantUser2 = dataUser.usingUser(adminTenantUser2).createUserWithTenant("uTenant2"); - - SiteModel siteModel1 = dataSite.usingUser(adminTenantUser1).createPublicRandomSite(); - FileModel fileModel1 = dataContent.usingUser(adminTenantUser1).usingSite(siteModel1).createContent(DocumentType.XML); - - RestProcessModel addedProcess1 = restClient.authenticateUser(adminTenantUser1).withWorkflowAPI().addProcess("activitiAdhoc", tenantUser1, false, Priority.Normal); - RestTaskModel addedTask1 = restClient.withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess1); - RestItemModel taskItem1 = restClient.withWorkflowAPI().usingTask(addedTask1).addTaskItem(fileModel1); - - SiteModel siteModel2 = dataSite.usingUser(adminTenantUser2).createPublicRandomSite(); - FileModel fileModel2 = dataContent.usingUser(adminTenantUser2).usingSite(siteModel2).createContent(DocumentType.XML); - - RestProcessModel addedProcess2 = restClient.authenticateUser(adminTenantUser2).withWorkflowAPI().addProcess("activitiAdhoc", tenantUser2, false, Priority.Normal); - RestTaskModel addedTask2 = restClient.withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess2); - RestItemModel taskItem2 = restClient.withWorkflowAPI().usingTask(addedTask2).addTaskItem(fileModel2); - - itemModels = restClient.withWorkflowAPI().usingTask(addedTask2).getTaskItems(); - restClient.assertStatusCodeIs(HttpStatus.OK); - itemModels.assertThat() - .entriesListIsNotEmpty().and() - .entriesListContains("id", taskItem2.getId()).and() - .entriesListContains("name", fileModel2.getName()).and() - .entriesListDoesNotContain("id", taskItem1.getId()).and() - .entriesListDoesNotContain("name", fileModel1.getName()); - } -} diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/items/GetTaskItemsFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/items/GetTaskItemsFullTests.java deleted file mode 100644 index 9bc9d7046..000000000 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/items/GetTaskItemsFullTests.java +++ /dev/null @@ -1,199 +0,0 @@ -package org.alfresco.rest.workflow.tasks.items; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestItemModel; -import org.alfresco.rest.model.RestItemModelsCollection; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TaskModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class GetTaskItemsFullTests extends RestTest -{ - private UserModel userWhoStartsTask, assignee; - private SiteModel siteModel; - private FileModel fileModel; - private TaskModel taskModel; - private RestItemModelsCollection itemModels; - private RestItemModel taskItem; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - userWhoStartsTask = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Check default error model schema for get task items api call") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void getTaskItemsUsingCheckErrorModel() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); - taskModel.setId("invalidId"); - restClient.authenticateUser(assignee).withWorkflowAPI() - .usingTask(taskModel).getTaskItems(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidId")) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin user can get task items") - public void getTaskItemsByAdminUser() throws Exception - { - restClient.authenticateUser(userWhoStartsTask); - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); - taskItem = restClient.withWorkflowAPI().usingTask(taskModel).getTaskItems().getOneRandomEntry(); - - itemModels = restClient.authenticateUser(dataUser.getAdminUser()).withWorkflowAPI().usingTask(taskModel).getTaskItems(); - restClient.assertStatusCodeIs(HttpStatus.OK); - itemModels.assertThat() - .entriesListIsNotEmpty().and() - .entriesListContains("id", taskItem.onModel().getId()).and() - .entriesListContains("name", taskItem.onModel().getName()) - .getEntries().get(0).onModel() - .assertThat().field("createdAt").isNotNull() - .assertThat().field("size").isNotNull() - .assertThat().field("createdBy").contains(dataUser.getAdminUser().getUsername()) - .assertThat().field("modifiedAt").isNotNull() - .assertThat().field("name").contains(fileModel.getName()) - .assertThat().field("modifiedBy").contains(userWhoStartsTask.getUsername()) - .assertThat().field("id").contains(fileModel.getNodeRef().split(";")[0]) - .assertThat().field("mimeType").contains(fileModel.getFileType().mimeType); - } - - @Bug(id="MNT-17438") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that user who started the process can get task items with skip count parameter") - public void getTaskItemsWithSkipCount() throws Exception - { - restClient.authenticateUser(userWhoStartsTask); - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); - FileModel document1 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document1); - itemModels = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() - .usingParams("skipCount=1").usingTask(taskModel).getTaskItems(); - restClient.assertStatusCodeIs(HttpStatus.OK); - itemModels.assertThat() - .entriesListIsNotEmpty() - .and().paginationField("count").is("1"); - } - - @Bug(id="MNT-17438") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that user who started the process can get task items with max items parameter") - public void getTaskItemsWithMaxItems() throws Exception - { - restClient.authenticateUser(userWhoStartsTask); - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); - FileModel document1 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document1); - itemModels = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() - .usingParams("maxItems=1").usingTask(taskModel).getTaskItems(); - restClient.assertStatusCodeIs(HttpStatus.OK); - itemModels.assertThat() - .entriesListIsNotEmpty() - .and().paginationField("count").is("1"); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that user who started the process can get task items with valid properties") - public void getTaskItemsWithValidProperties() throws Exception - { - restClient.authenticateUser(userWhoStartsTask); - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); - taskItem = restClient.withWorkflowAPI().usingTask(taskModel).getTaskItems().getOneRandomEntry(); - itemModels = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() - .usingParams("properties=createdAt,createdBy,id,size").usingTask(taskModel).getTaskItems(); - restClient.assertStatusCodeIs(HttpStatus.OK); - itemModels.getOneRandomEntry().onModel().assertThat() - .fieldsCount().is(4).and() - .field("createdAt").isNotNull().and() - .field("size").isNotNull().and() - .field("createdBy").isNotNull().and() - .field("modifiedAt").isNull().and() - .field("name").isNull().and() - .field("modifiedBy").isNull().and() - .field("id").isNotNull().and() - .field("mimeType").isNull(); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that user who started the process can get task items with an invalid property") - public void getTaskItemsWithInvalidProperties() throws Exception - { - restClient.authenticateUser(userWhoStartsTask); - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); - taskItem = restClient.withWorkflowAPI().usingTask(taskModel).getTaskItems().getOneRandomEntry(); - itemModels = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() - .usingParams("properties=size,fake-prop").usingTask(taskModel).getTaskItems(); - restClient.assertStatusCodeIs(HttpStatus.OK); - itemModels.getOneRandomEntry().onModel().assertThat() - .fieldsCount().is(1).and() - .field("createdAt").isNull().and() - .field("size").isNotNull().and() - .field("createdBy").isNull().and() - .field("modifiedAt").isNull().and() - .field("name").isNull().and() - .field("modifiedBy").isNull().and() - .field("id").isNull().and() - .field("mimeType").isNull(); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that involved user in process that was deleted cannot get task items") - public void getTaskItemsByDeletedUserInvolvedInProcess() throws Exception - { - UserModel assigneeDeleted = dataUser.createRandomTestUser(); - restClient.authenticateUser(userWhoStartsTask); - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeDeleted); - - dataUser.usingAdmin().deleteUser(assigneeDeleted); - - itemModels = restClient.authenticateUser(assigneeDeleted).withWorkflowAPI().usingTask(taskModel).getTaskItems(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError().containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that involved user in process that was disabled cannot get task items") - public void getTaskItemsByDisabledUserInvolvedInProcess() throws Exception - { - UserModel assigneeDisabled = dataUser.createRandomTestUser(); - restClient.authenticateUser(userWhoStartsTask); - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeDisabled); - - dataUser.usingAdmin().disableUser(assigneeDisabled); - - itemModels = restClient.authenticateUser(assigneeDisabled).withWorkflowAPI().usingTask(taskModel).getTaskItems(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError().containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } -} diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/items/GetTaskItemsRegressionTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/items/GetTaskItemsRegressionTests.java new file mode 100644 index 000000000..74bc978b7 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/items/GetTaskItemsRegressionTests.java @@ -0,0 +1,324 @@ +package org.alfresco.rest.workflow.tasks.items; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.dataprep.CMISUtil.Priority; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestItemModel; +import org.alfresco.rest.model.RestItemModelsCollection; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestTaskModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TaskModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Created by Claudia Agache on 12/8/2016. + */ +public class GetTaskItemsRegressionTests extends RestTest +{ + private UserModel adminUser, userWhoStartsTask, assignee; + private SiteModel siteModel; + private FileModel fileModel; + private TaskModel taskModel; + private RestItemModelsCollection itemModels; + private RestProcessModel addedProcess; + private RestTaskModel addedTask; + private RestItemModel taskItem; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + userWhoStartsTask = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); + fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + adminUser = dataUser.getAdminUser(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify if get task items call return status code 404 when invalid taskId is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void getTaskItemsUsingInvalidTaskId() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); + taskModel.setId("invalidId"); + + restClient.authenticateUser(assignee).withWorkflowAPI() + .usingTask(taskModel).getTaskItems(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidId")); + + taskModel.setId(""); + + restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() + .usingTask(taskModel).getTaskItems(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, + executionType = ExecutionType.REGRESSION, + description = "Verify if get task items request returns status code 200 after the task is finished.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void getTaskItemsAfterFinishingTask() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); + dataWorkflow.usingUser(assignee).taskDone(taskModel); + restClient.authenticateUser(userWhoStartsTask); + itemModels = restClient.withWorkflowAPI().usingTask(taskModel).getTaskItems(); + restClient.assertStatusCodeIs(HttpStatus.OK); + itemModels.assertThat().entriesListIsNotEmpty().and().entriesListContains("name", fileModel.getName()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, + executionType = ExecutionType.REGRESSION, + description = "Verify if get task items request returns status code 200 after the process is deleted (Task state is now completed.)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void getTaskItemsAfterDeletingProcess() throws Exception + { + addedProcess = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); + addedTask = restClient.withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess); + restClient.withWorkflowAPI().usingTask(addedTask).addTaskItem(fileModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.withWorkflowAPI().usingProcess(addedProcess).deleteProcess(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + itemModels = restClient.withWorkflowAPI().usingTask(addedTask).getTaskItems(); + restClient.assertStatusCodeIs(HttpStatus.OK); + itemModels.assertThat().entriesListIsNotEmpty().and().entriesListContains("name", fileModel.getName()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify gets task items call with admin from different network") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void getTaskItemsByAdminFromAnotherNetwork() throws Exception + { + UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); + UserModel adminTenantUser2 = UserModel.getAdminTenantUser(); + + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser1); + restClient.usingTenant().createTenant(adminTenantUser2); + + UserModel tenantUser1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenant"); + UserModel tenantUserAssignee1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenantAssignee"); + + siteModel = dataSite.usingUser(adminTenantUser1).createPublicRandomSite(); + fileModel = dataContent.usingUser(adminTenantUser1).usingSite(siteModel).createContent(DocumentType.XML); + addedProcess = restClient.authenticateUser(tenantUser1).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee1, false, Priority.Normal); + addedTask = restClient.withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess); + restClient.withWorkflowAPI().usingTask(addedTask).addTaskItem(fileModel); + + restClient.authenticateUser(adminTenantUser2).withWorkflowAPI().usingTask(addedTask).getTaskItems(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify gets task items call returns only task items inside network") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void getTaskItemsReturnsOnlyItemsFromThatNetwork() throws Exception + { + UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); + UserModel adminTenantUser2 = UserModel.getAdminTenantUser(); + + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser1); + restClient.usingTenant().createTenant(adminTenantUser2); + + UserModel tenantUser1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenant1"); + UserModel tenantUser2 = dataUser.usingUser(adminTenantUser2).createUserWithTenant("uTenant2"); + + SiteModel siteModel1 = dataSite.usingUser(adminTenantUser1).createPublicRandomSite(); + FileModel fileModel1 = dataContent.usingUser(adminTenantUser1).usingSite(siteModel1).createContent(DocumentType.XML); + + RestProcessModel addedProcess1 = restClient.authenticateUser(adminTenantUser1).withWorkflowAPI().addProcess("activitiAdhoc", tenantUser1, false, Priority.Normal); + RestTaskModel addedTask1 = restClient.withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess1); + RestItemModel taskItem1 = restClient.withWorkflowAPI().usingTask(addedTask1).addTaskItem(fileModel1); + + SiteModel siteModel2 = dataSite.usingUser(adminTenantUser2).createPublicRandomSite(); + FileModel fileModel2 = dataContent.usingUser(adminTenantUser2).usingSite(siteModel2).createContent(DocumentType.XML); + + RestProcessModel addedProcess2 = restClient.authenticateUser(adminTenantUser2).withWorkflowAPI().addProcess("activitiAdhoc", tenantUser2, false, Priority.Normal); + RestTaskModel addedTask2 = restClient.withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess2); + RestItemModel taskItem2 = restClient.withWorkflowAPI().usingTask(addedTask2).addTaskItem(fileModel2); + + itemModels = restClient.withWorkflowAPI().usingTask(addedTask2).getTaskItems(); + restClient.assertStatusCodeIs(HttpStatus.OK); + itemModels.assertThat() + .entriesListIsNotEmpty().and() + .entriesListContains("id", taskItem2.getId()).and() + .entriesListContains("name", fileModel2.getName()).and() + .entriesListDoesNotContain("id", taskItem1.getId()).and() + .entriesListDoesNotContain("name", fileModel1.getName()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Check default error model schema for get task items api call") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void getTaskItemsUsingCheckErrorModel() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); + taskModel.setId("invalidId"); + restClient.authenticateUser(assignee).withWorkflowAPI() + .usingTask(taskModel).getTaskItems(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidId")) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } + + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin user can get task items") + public void getTaskItemsByAdminUser() throws Exception + { + restClient.authenticateUser(userWhoStartsTask); + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); + taskItem = restClient.withWorkflowAPI().usingTask(taskModel).getTaskItems().getOneRandomEntry(); + + itemModels = restClient.authenticateUser(dataUser.getAdminUser()).withWorkflowAPI().usingTask(taskModel).getTaskItems(); + restClient.assertStatusCodeIs(HttpStatus.OK); + itemModels.assertThat() + .entriesListIsNotEmpty().and() + .entriesListContains("id", taskItem.onModel().getId()).and() + .entriesListContains("name", taskItem.onModel().getName()) + .getEntries().get(0).onModel() + .assertThat().field("createdAt").isNotNull() + .assertThat().field("size").isNotNull() + .assertThat().field("createdBy").contains(dataUser.getAdminUser().getUsername()) + .assertThat().field("modifiedAt").isNotNull() + .assertThat().field("name").contains(fileModel.getName()) + .assertThat().field("modifiedBy").contains(userWhoStartsTask.getUsername()) + .assertThat().field("id").contains(fileModel.getNodeRef().split(";")[0]) + .assertThat().field("mimeType").contains(fileModel.getFileType().mimeType); + } + + @Bug(id="MNT-17438") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that user who started the process can get task items with skip count parameter") + public void getTaskItemsWithSkipCount() throws Exception + { + restClient.authenticateUser(userWhoStartsTask); + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); + FileModel document1 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document1); + itemModels = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() + .usingParams("skipCount=1").usingTask(taskModel).getTaskItems(); + restClient.assertStatusCodeIs(HttpStatus.OK); + itemModels.assertThat() + .entriesListIsNotEmpty() + .and().paginationField("count").is("1"); + } + + @Bug(id="MNT-17438") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that user who started the process can get task items with max items parameter") + public void getTaskItemsWithMaxItems() throws Exception + { + restClient.authenticateUser(userWhoStartsTask); + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); + FileModel document1 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document1); + itemModels = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() + .usingParams("maxItems=1").usingTask(taskModel).getTaskItems(); + restClient.assertStatusCodeIs(HttpStatus.OK); + itemModels.assertThat() + .entriesListIsNotEmpty() + .and().paginationField("count").is("1"); + } + + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that user who started the process can get task items with valid properties") + public void getTaskItemsWithValidProperties() throws Exception + { + restClient.authenticateUser(userWhoStartsTask); + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); + taskItem = restClient.withWorkflowAPI().usingTask(taskModel).getTaskItems().getOneRandomEntry(); + itemModels = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() + .usingParams("properties=createdAt,createdBy,id,size").usingTask(taskModel).getTaskItems(); + restClient.assertStatusCodeIs(HttpStatus.OK); + itemModels.getOneRandomEntry().onModel().assertThat() + .fieldsCount().is(4).and() + .field("createdAt").isNotNull().and() + .field("size").isNotNull().and() + .field("createdBy").isNotNull().and() + .field("modifiedAt").isNull().and() + .field("name").isNull().and() + .field("modifiedBy").isNull().and() + .field("id").isNotNull().and() + .field("mimeType").isNull(); + } + + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that user who started the process can get task items with an invalid property") + public void getTaskItemsWithInvalidProperties() throws Exception + { + restClient.authenticateUser(userWhoStartsTask); + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); + taskItem = restClient.withWorkflowAPI().usingTask(taskModel).getTaskItems().getOneRandomEntry(); + itemModels = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() + .usingParams("properties=size,fake-prop").usingTask(taskModel).getTaskItems(); + restClient.assertStatusCodeIs(HttpStatus.OK); + itemModels.getOneRandomEntry().onModel().assertThat() + .fieldsCount().is(1).and() + .field("createdAt").isNull().and() + .field("size").isNotNull().and() + .field("createdBy").isNull().and() + .field("modifiedAt").isNull().and() + .field("name").isNull().and() + .field("modifiedBy").isNull().and() + .field("id").isNull().and() + .field("mimeType").isNull(); + } + + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that involved user in process that was deleted cannot get task items") + public void getTaskItemsByDeletedUserInvolvedInProcess() throws Exception + { + UserModel assigneeDeleted = dataUser.createRandomTestUser(); + restClient.authenticateUser(userWhoStartsTask); + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeDeleted); + + dataUser.usingAdmin().deleteUser(assigneeDeleted); + + itemModels = restClient.authenticateUser(assigneeDeleted).withWorkflowAPI().usingTask(taskModel).getTaskItems(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError().containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } + + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that involved user in process that was disabled cannot get task items") + public void getTaskItemsByDisabledUserInvolvedInProcess() throws Exception + { + UserModel assigneeDisabled = dataUser.createRandomTestUser(); + restClient.authenticateUser(userWhoStartsTask); + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeDisabled); + + dataUser.usingAdmin().disableUser(assigneeDisabled); + + itemModels = restClient.authenticateUser(assigneeDisabled).withWorkflowAPI().usingTask(taskModel).getTaskItems(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError().containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } +} diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/items/RemoveTaskItemCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/items/RemoveTaskItemCoreTests.java deleted file mode 100644 index b72978e0e..000000000 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/items/RemoveTaskItemCoreTests.java +++ /dev/null @@ -1,154 +0,0 @@ -package org.alfresco.rest.workflow.tasks.items; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestItemModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.GroupModel; -import org.alfresco.utility.model.ProcessModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TaskModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * @author bogdan.bocancea - */ -public class RemoveTaskItemCoreTests extends RestTest -{ - private UserModel userWhoStartsTask, assigneeUser; - private SiteModel siteModel; - private FileModel fileModel, document2; - private TaskModel taskModel; - private RestItemModel taskItem; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - userWhoStartsTask = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - assigneeUser = dataUser.createRandomTestUser(); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Delete existing task item with empty task id") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void deleteTaskItemEmptyTaskId() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - restClient.authenticateUser(userWhoStartsTask); - document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); - taskModel.setId(""); - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Delete existing task item with empty item id") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void deleteTaskItemEmptyItemId() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - restClient.authenticateUser(userWhoStartsTask); - document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); - taskItem.setId(""); - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) - .assertLastError().containsSummary(RestErrorModel.DELETE_EMPTY_ARGUMENT); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Delete existing task item for completed task") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void deleteTaskItemForCompletedTask() throws Exception - { - TaskModel completedTask = dataWorkflow.usingUser(userWhoStartsTask) - .usingSite(siteModel) - .usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - restClient.authenticateUser(userWhoStartsTask); - document2 = dataContent.usingUser(userWhoStartsTask).usingSite(siteModel).createContent(DocumentType.XML); - taskItem = restClient.withWorkflowAPI().usingTask(completedTask).addTaskItem(document2); - dataWorkflow.usingUser(assigneeUser).taskDone(completedTask); - dataWorkflow.usingUser(userWhoStartsTask).taskDone(completedTask); - restClient.withWorkflowAPI().usingTask(completedTask).deleteTaskItem(taskItem); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, completedTask.getId())); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Delete existing task item with candidate user") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void deleteTaskItemWithCandidateUser() throws Exception - { - GroupModel group = dataGroup.createRandomGroup(); - dataGroup.addListOfUsersToGroup(group, assigneeUser); - TaskModel groupTask = dataWorkflow.usingUser(userWhoStartsTask) - .usingSite(siteModel) - .usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); - - restClient.authenticateUser(userWhoStartsTask); - document2 = dataContent.usingUser(userWhoStartsTask).usingSite(siteModel).createContent(DocumentType.XML); - taskItem = restClient.withWorkflowAPI().usingTask(groupTask).addTaskItem(document2); - restClient.authenticateUser(assigneeUser) - .withWorkflowAPI().usingTask(groupTask).deleteTaskItem(taskItem); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Delete existing task item with unauthorized user") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void deleteTaskItemWithUnauthorizedUser() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - UserModel unauthorizedUser = dataUser.createRandomTestUser(); - document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - taskItem = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); - restClient.authenticateUser(unauthorizedUser).withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Delete existing task item with inexistent user") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void deleteTaskItemWithInexistentUser() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - taskItem = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); - restClient.authenticateUser(UserModel.getRandomUserModel()).withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Delete existing task item for deleted task") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void deleteTaskItemFromDeletedProcess() throws Exception - { - ProcessModel deletedProcess = dataWorkflow.usingUser(userWhoStartsTask) - .usingSite(siteModel) - .usingResource(fileModel).createMoreReviewersWorkflowAndAssignTo(assigneeUser); - TaskModel task = restClient.authenticateUser(userWhoStartsTask) - .withWorkflowAPI().usingProcess(deletedProcess).getProcessTasks().getEntries().get(0).onModel(); - - document2 = dataContent.usingUser(userWhoStartsTask).usingSite(siteModel).createContent(DocumentType.XML); - taskItem = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingTask(task).addTaskItem(document2); - dataWorkflow.usingUser(userWhoStartsTask).deleteProcess(deletedProcess); - restClient.withWorkflowAPI().usingTask(task).deleteTaskItem(taskItem); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, task.getId())); - } -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/items/RemoveTaskItemFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/items/RemoveTaskItemFullTests.java deleted file mode 100644 index 8d334062d..000000000 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/items/RemoveTaskItemFullTests.java +++ /dev/null @@ -1,97 +0,0 @@ -package org.alfresco.rest.workflow.tasks.items; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestItemModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TaskModel; -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 bogdan.bocancea - */ -public class RemoveTaskItemFullTests extends RestTest -{ - private UserModel userWhoStartsTask, assigneeUser; - private SiteModel siteModel; - private FileModel fileModel, document2; - private TaskModel taskModel; - private RestItemModel taskItem; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - userWhoStartsTask = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - assigneeUser = dataUser.createRandomTestUser(); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Delete task item twice") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void deleteTaskItemTwice() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - restClient.authenticateUser(userWhoStartsTask); - document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); - - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.PROCESS_ENTITY_NOT_FOUND, document2.getNodeRefWithoutVersion())) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Delete task item with locked document") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void deleteTaskItemWithLockedDocument() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - restClient.authenticateUser(userWhoStartsTask); - document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); - - dataContent.usingUser(userWhoStartsTask).usingResource(document2).checkOutDocument(); - - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); - restClient.assertStatusCodeIs(HttpStatus.CONFLICT) - .assertLastError().containsSummary(String.format(RestErrorModel.LOCKED_NODE_OPERATION, document2.getNodeRefWithoutVersion())) - .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Delete task item with deleted document") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void deleteTaskItemWithDeletedDocument() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - restClient.authenticateUser(userWhoStartsTask); - document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); - - dataContent.usingUser(userWhoStartsTask).usingResource(document2).deleteContent(); - - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.PROCESS_ENTITY_NOT_FOUND, document2.getNodeRefWithoutVersion())) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/items/RemoveTaskItemSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/items/RemoveTaskItemSanityTests.java deleted file mode 100644 index 4bff98e35..000000000 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/items/RemoveTaskItemSanityTests.java +++ /dev/null @@ -1,86 +0,0 @@ -package org.alfresco.rest.workflow.tasks.items; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestItemModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TaskModel; -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 RemoveTaskItemSanityTests extends RestTest -{ - private UserModel adminUser, userModel, userWhoStartsTask, assigneeUser; - private SiteModel siteModel; - private FileModel fileModel, document2; - private TaskModel taskModel; - - private RestItemModel taskItem; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - userWhoStartsTask = dataUser.createRandomTestUser(); - assigneeUser = dataUser.createRandomTestUser(); - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, - description = "Delete existing task item") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - public void deleteTaskItem() throws Exception - { - restClient.authenticateUser(adminUser); - document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - - taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withWorkflowAPI().usingTask(taskModel).getTaskItems() - .assertThat().entriesListDoesNotContain("id", taskItem.getId()).and() - .entriesListDoesNotContain("name", document2.getName()); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, - description = "Try to Delete existing task item using invalid taskId") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - public void deleteTaskItemUsingInvalidTaskId() throws Exception - { - restClient.authenticateUser(adminUser); - document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - - taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); - taskModel.setId("invalidTaskId"); - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidTaskId")); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, - description = "Try to Delete existing task item using invalid itemId") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - public void deleteTaskItemUsingInvalidItemId() throws Exception - { - restClient.authenticateUser(adminUser); - document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); - taskItem.setId("incorrectItemId"); - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.PROCESS_ENTITY_NOT_FOUND, "incorrectItemId")); - } -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/items/RemoveTaskItemTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/items/RemoveTaskItemTests.java new file mode 100644 index 000000000..d31b5469b --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/items/RemoveTaskItemTests.java @@ -0,0 +1,253 @@ +package org.alfresco.rest.workflow.tasks.items; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestItemModel; +import org.alfresco.utility.model.*; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * @author bogdan.bocancea + */ +public class RemoveTaskItemTests extends RestTest +{ + private UserModel adminUser, userWhoStartsTask, assigneeUser; + private SiteModel siteModel; + private FileModel fileModel, document2; + private TaskModel taskModel; + private RestItemModel taskItem; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userWhoStartsTask = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); + fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + assigneeUser = dataUser.createRandomTestUser(); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Delete existing task item") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + public void deleteTaskItem() throws Exception + { + restClient.authenticateUser(adminUser); + document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + + taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingTask(taskModel).getTaskItems() + .assertThat().entriesListDoesNotContain("id", taskItem.getId()).and() + .entriesListDoesNotContain("name", document2.getName()); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Try to Delete existing task item using invalid taskId") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void deleteTaskItemUsingInvalidTaskId() throws Exception + { + restClient.authenticateUser(adminUser); + document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + + taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); + taskModel.setId("invalidTaskId"); + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidTaskId")); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Try to Delete existing task item using invalid itemId") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void deleteTaskItemUsingInvalidItemId() throws Exception + { + restClient.authenticateUser(adminUser); + document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); + taskItem.setId("incorrectItemId"); + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.PROCESS_ENTITY_NOT_FOUND, "incorrectItemId")); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Delete existing task item with empty task id") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void deleteTaskItemEmptyTaskId() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + restClient.authenticateUser(userWhoStartsTask); + document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); + taskModel.setId(""); + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Delete existing task item with empty item id") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void deleteTaskItemEmptyItemId() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + restClient.authenticateUser(userWhoStartsTask); + document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); + taskItem.setId(""); + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) + .assertLastError().containsSummary(RestErrorModel.DELETE_EMPTY_ARGUMENT); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Delete existing task item for completed task") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void deleteTaskItemForCompletedTask() throws Exception + { + TaskModel completedTask = dataWorkflow.usingUser(userWhoStartsTask) + .usingSite(siteModel) + .usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + restClient.authenticateUser(userWhoStartsTask); + document2 = dataContent.usingUser(userWhoStartsTask).usingSite(siteModel).createContent(DocumentType.XML); + taskItem = restClient.withWorkflowAPI().usingTask(completedTask).addTaskItem(document2); + dataWorkflow.usingUser(assigneeUser).taskDone(completedTask); + dataWorkflow.usingUser(userWhoStartsTask).taskDone(completedTask); + restClient.withWorkflowAPI().usingTask(completedTask).deleteTaskItem(taskItem); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, completedTask.getId())); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Delete existing task item with candidate user") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + public void deleteTaskItemWithCandidateUser() throws Exception + { + GroupModel group = dataGroup.createRandomGroup(); + dataGroup.addListOfUsersToGroup(group, assigneeUser); + TaskModel groupTask = dataWorkflow.usingUser(userWhoStartsTask) + .usingSite(siteModel) + .usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); + + restClient.authenticateUser(userWhoStartsTask); + document2 = dataContent.usingUser(userWhoStartsTask).usingSite(siteModel).createContent(DocumentType.XML); + taskItem = restClient.withWorkflowAPI().usingTask(groupTask).addTaskItem(document2); + restClient.authenticateUser(assigneeUser) + .withWorkflowAPI().usingTask(groupTask).deleteTaskItem(taskItem); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Delete existing task item with unauthorized user") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void deleteTaskItemWithUnauthorizedUser() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + UserModel unauthorizedUser = dataUser.createRandomTestUser(); + document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + taskItem = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); + restClient.authenticateUser(unauthorizedUser).withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Delete existing task item with inexistent user") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) +// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") + public void deleteTaskItemWithInexistentUser() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + taskItem = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); + restClient.authenticateUser(UserModel.getRandomUserModel()).withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Delete existing task item for deleted task") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void deleteTaskItemFromDeletedProcess() throws Exception + { + ProcessModel deletedProcess = dataWorkflow.usingUser(userWhoStartsTask) + .usingSite(siteModel) + .usingResource(fileModel).createMoreReviewersWorkflowAndAssignTo(assigneeUser); + TaskModel task = restClient.authenticateUser(userWhoStartsTask) + .withWorkflowAPI().usingProcess(deletedProcess).getProcessTasks().getEntries().get(0).onModel(); + + document2 = dataContent.usingUser(userWhoStartsTask).usingSite(siteModel).createContent(DocumentType.XML); + taskItem = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingTask(task).addTaskItem(document2); + dataWorkflow.usingUser(userWhoStartsTask).deleteProcess(deletedProcess); + restClient.withWorkflowAPI().usingTask(task).deleteTaskItem(taskItem); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, task.getId())); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Delete task item twice") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void deleteTaskItemTwice() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + restClient.authenticateUser(userWhoStartsTask); + document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); + + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.PROCESS_ENTITY_NOT_FOUND, document2.getNodeRefWithoutVersion())) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Delete task item with locked document") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void deleteTaskItemWithLockedDocument() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + restClient.authenticateUser(userWhoStartsTask); + document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); + + dataContent.usingUser(userWhoStartsTask).usingResource(document2).checkOutDocument(); + + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); + restClient.assertStatusCodeIs(HttpStatus.CONFLICT) + .assertLastError().containsSummary(String.format(RestErrorModel.LOCKED_NODE_OPERATION, document2.getNodeRefWithoutVersion())) + .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Delete task item with deleted document") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void deleteTaskItemWithDeletedDocument() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + restClient.authenticateUser(userWhoStartsTask); + document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); + + dataContent.usingUser(userWhoStartsTask).usingResource(document2).deleteContent(); + + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.PROCESS_ENTITY_NOT_FOUND, document2.getNodeRefWithoutVersion())) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } +} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk1.java similarity index 95% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesSanityTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk1.java index 86cd6c2cb..03dac2155 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk1.java @@ -19,7 +19,7 @@ import org.testng.annotations.Test; * @author iulia.cojocea */ -public class AddTaskVariablesSanityTests extends RestTest +public class AddTaskVariablesTestsBulk1 extends RestTest { private UserModel userModel, userWhoStartsTask; private SiteModel siteModel; @@ -59,8 +59,8 @@ public class AddTaskVariablesSanityTests extends RestTest .and().field("type").is(variableModel.getType()); } - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Create non-existing task variable with admin") public void createMultipleTaskVariablesWithAdmin() throws Exception { @@ -103,8 +103,8 @@ public class AddTaskVariablesSanityTests extends RestTest restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables().assertThat().entriesListContains("name", variableModel.getName()); } - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Create multiple non-existing task variable with involved user") public void createMultipleTaskVariableWithInvolvedUser() throws Exception { @@ -144,8 +144,8 @@ public class AddTaskVariablesSanityTests extends RestTest .and().field("type").is(variableModel.getType()); } - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Create multiple non-existing task variable with task owner") public void createMultipleTaskVariableWithTaskOwner() throws Exception { @@ -169,8 +169,8 @@ public class AddTaskVariablesSanityTests extends RestTest .and().field("type").is(variableModel1.getType()); } - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Create non-existing task variable with any user") public void createTaskVariableWithRandomUser() throws Exception { @@ -182,8 +182,8 @@ public class AddTaskVariablesSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); } - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Create multiple non-existing task variable with any user") public void createMultipleTaskVariableWithRandomUser() throws Exception { diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk2.java similarity index 95% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesCoreTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk2.java index 9efbdd957..fd2704692 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk2.java @@ -19,7 +19,7 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -public class AddTaskVariablesCoreTests extends RestTest +public class AddTaskVariablesTestsBulk2 extends RestTest { private UserModel userWhoStartsTask, adminUser; private SiteModel siteModel; @@ -44,7 +44,7 @@ public class AddTaskVariablesCoreTests extends RestTest restClient.authenticateUser(adminUser); } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case invalid variableBody is provided") public void failedAddingTaskVariableIfInvalidBodyIsProvided() throws Exception { @@ -54,7 +54,7 @@ public class AddTaskVariablesCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Illegal value for variable scope: 'instance'."); } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding multiple task variable is falling in case invalid variableBody is provided") public void failedAddingMultipleTaskVariableIfInvalidBodyIsProvided() throws Exception @@ -66,7 +66,7 @@ public class AddTaskVariablesCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Illegal value for variable scope: 'instance'."); } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case empty body type is provided") public void failedAddingTaskVariableIfEmptyBodyIsProvided() throws Exception { @@ -77,7 +77,7 @@ public class AddTaskVariablesCoreTests extends RestTest .containsSummary("Variable scope is required and can only be 'local' or 'global'."); } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding multiple task variable is falling in case empty body type is provided") public void failedAddingMultipleTaskVariableIfEmptyBodyIsProvided() throws Exception @@ -90,7 +90,7 @@ public class AddTaskVariablesCoreTests extends RestTest .containsSummary("Variable scope is required and can only be 'local' or 'global'."); } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case incomplete body type is provided") public void failedAddingTaskVariableIfIncompleteBodyIsProvided() throws Exception { @@ -102,7 +102,7 @@ public class AddTaskVariablesCoreTests extends RestTest .containsSummary("Variable scope is required and can only be 'local' or 'global'."); } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case incomplete body - missing required: name type is provided") public void failedAddingTaskVariableIfIncompleteRequiredBodyIsProvided() throws Exception { @@ -113,7 +113,7 @@ public class AddTaskVariablesCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Variable name is required."); } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case invalid type is provided") public void failedAddingTaskVariableIfInvalidTypeIsProvided() throws Exception { @@ -124,7 +124,7 @@ public class AddTaskVariablesCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Unsupported type of variable: 'd:char'."); } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding multiple task variable is falling in case invalid type is provided") public void failedAddingMultipleTaskVariableIfInvalidTypeIsProvided() throws Exception @@ -138,7 +138,7 @@ public class AddTaskVariablesCoreTests extends RestTest } @Bug(id = "ACE-5674") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case invalid type prefix is provided") public void failedAddingTaskVariableIfInvalidTypePrefixIsProvided() throws Exception { @@ -150,7 +150,7 @@ public class AddTaskVariablesCoreTests extends RestTest } @Bug(id = "ACE-5674") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding multiple task variable is falling in case invalid type prefix is provided") public void failedAddingMultipleTaskVariableIfInvalidTypePrefixIsProvided() throws Exception @@ -164,7 +164,7 @@ public class AddTaskVariablesCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Namespace prefix ddm is not mapped to a namespace URI"); } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case invalid scope is provided") public void failedAddingTaskVariableIfInvalidScopeIsProvided() throws Exception { @@ -175,7 +175,7 @@ public class AddTaskVariablesCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Illegal value for variable scope: 'instance'."); } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding multiple task variable is falling in case invalid scope is provided") public void failedAddingMultipleTaskVariableIfInvalidScopeIsProvided() throws Exception @@ -189,7 +189,7 @@ public class AddTaskVariablesCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Illegal value for variable scope: 'instance'."); } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case invalid task id is provided") public void failedAddingTaskVariableIfInvalidTaskIdIsProvided() throws Exception { @@ -201,7 +201,7 @@ public class AddTaskVariablesCoreTests extends RestTest .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, taskModel.getId())); } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding multiple task variable is falling in case invalid task id is provided") public void failedAddingMultipleTaskVariableIfInvalidTaskIdIsProvided() throws Exception @@ -215,7 +215,7 @@ public class AddTaskVariablesCoreTests extends RestTest .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, taskModel.getId())); } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case invalid task id is provided") public void failedAddingTaskVariableIfInvalidValueIsProvided() throws Exception { @@ -226,7 +226,7 @@ public class AddTaskVariablesCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("For input string: \"invalidValue\""); } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding multiple task variable is falling in case invalid task id is provided") public void failedAddingMultipleTaskVariableIfInvalidValueIsProvided() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk3.java similarity index 96% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesFullTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk3.java index a2fbf7b95..b82b8f675 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk3.java @@ -22,7 +22,7 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -public class AddTaskVariablesFullTests extends RestTest +public class AddTaskVariablesTestsBulk3 extends RestTest { private UserModel userWhoStartsTask, adminUser; private SiteModel siteModel; @@ -46,7 +46,7 @@ public class AddTaskVariablesFullTests extends RestTest taskId = taskModel.getId(); } - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Create task variable with name containing symbols") public void createTaskVariableWithSymbolsInName() throws Exception @@ -64,7 +64,7 @@ public class AddTaskVariablesFullTests extends RestTest .and().field("type").is(variableModel.getType()); } - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Create multiple task variable with name containing symbols") public void createMultipleTaskVariableWithSymbolsInName() throws Exception @@ -90,7 +90,7 @@ public class AddTaskVariablesFullTests extends RestTest .and().field("type").is(variableModel1.getType()); } - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Create task variable with empty name") public void createTaskVariableWithEmptyName() throws Exception @@ -109,7 +109,7 @@ public class AddTaskVariablesFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Update task variable with invalid variable name") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) public void createTaskVariableWithInvalidVariableName() throws Exception { restClient.authenticateUser(adminUser).withWorkflowAPI(); @@ -124,7 +124,7 @@ public class AddTaskVariablesFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Create task variable with invalid name") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) public void createTaskVariableWithInvalidName() throws Exception { restClient.authenticateUser(adminUser).withWorkflowAPI(); @@ -137,10 +137,10 @@ public class AddTaskVariablesFullTests extends RestTest .containsSummary(String.format(RestErrorModel.NO_CONTENT,"Unexpected character " + "('''")); } - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Create task variable with empty name") - public void failledCreatingMultipleTaskVariableWithEmptyName() throws Exception + public void failedCreatingMultipleTaskVariableWithEmptyName() throws Exception { UserModel adminUser = dataUser.getAdminUser(); restClient.authenticateUser(adminUser); @@ -156,7 +156,7 @@ public class AddTaskVariablesFullTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE); } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL, TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify that admin from the same network is able to add task variables") public void addTaskVariablesByTenantAdmin() throws Exception @@ -182,7 +182,7 @@ public class AddTaskVariablesFullTests extends RestTest .and().field("type").is(variableModel.getType()); } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL, TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify that admin from the same network is able to add multiple task variables") public void addMultipleTaskVariablesByTenantAdmin() throws Exception @@ -216,7 +216,7 @@ public class AddTaskVariablesFullTests extends RestTest .and().field("type").is(variableModel1.getType()); } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL, TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify that admin from another network is not able to add task variables") public void addTaskVariablesByTenantFromAnotherNetwork() throws Exception @@ -242,7 +242,7 @@ public class AddTaskVariablesFullTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE); } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL, TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify that admin from another network is not able to add multiple task variables") public void addMultipleTaskVariablesByTenantFromAnotherNetwork() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/DeleteTaskVariableCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/DeleteTaskVariableCoreTests.java deleted file mode 100644 index 6b475c6db..000000000 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/DeleteTaskVariableCoreTests.java +++ /dev/null @@ -1,126 +0,0 @@ -package org.alfresco.rest.workflow.tasks.variables; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestVariableModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TaskModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * @author bogdan.bocancea - */ -public class DeleteTaskVariableCoreTests extends RestTest -{ - private UserModel userModel; - private SiteModel siteModel; - private FileModel fileModel; - private TaskModel taskModel; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(userModel); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Delete task variable with any user") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void deleteTaskVariableByAnyUser() throws Exception - { - restClient.authenticateUser(userModel); - RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - - restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables() - .assertThat().entriesListDoesNotContain("name", variableModel.getName()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Delete task variable with invalid type") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void deleteTaskVariableInvalidType() throws Exception - { - restClient.authenticateUser(userModel); - RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); - variableModel.setType("invalid-type"); - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables() - . assertThat().entriesListDoesNotContain("name", variableModel.getName()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Delete task variable with invalid name") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void deleteTaskVariableInvalidName() throws Exception - { - restClient.authenticateUser(userModel); - RestVariableModel variableModel = new RestVariableModel("local", "<>.,;/|-+=%", "d:text", "invalid name"); - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Create, update, delete task variable with any user") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void createUpdateDeleteTaskVarialbleByAnyUser() throws Exception - { - restClient.authenticateUser(userModel); - RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - - restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); - variableModel.setName("new-variable"); - restClient.withWorkflowAPI().usingTask(taskModel).updateTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables() - .assertThat().entriesListDoesNotContain("name", variableModel.getName()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Delete task variable by non assigned user") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void deleteTaskVariableByNonAssignedUser() throws Exception - { - UserModel nonAssigned = dataUser.createRandomTestUser(); - RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - - restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); - restClient.authenticateUser(nonAssigned).withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Delete task variable by inexistent user") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void deleteTaskVariableByInexistentUser() throws Exception - { - RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); - restClient.authenticateUser(UserModel.getRandomUserModel()) - .withWorkflowAPI() - .usingTask(taskModel) - .deleteTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } -} diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/DeleteTaskVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/DeleteTaskVariableSanityTests.java deleted file mode 100644 index ba8ae1e73..000000000 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/DeleteTaskVariableSanityTests.java +++ /dev/null @@ -1,67 +0,0 @@ -package org.alfresco.rest.workflow.tasks.variables; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestVariableModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TaskModel; -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 DeleteTaskVariableSanityTests extends RestTest -{ - private UserModel userModel, adminUser; - private SiteModel siteModel; - private FileModel fileModel; - private UserModel assigneeUser; - private TaskModel taskModel; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - assigneeUser = dataUser.createRandomTestUser(); - taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, - description = "Delete existing task variable") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - public void deleteTaskVariable() throws Exception - { - restClient.authenticateUser(adminUser); - RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - - restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables() - .assertThat().entriesListDoesNotContain("name", variableModel.getName()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, - description = "Try to delete existing task variable using invalid task id") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - public void tryToDeleteTaskVariableUsingInvalidTaskId() throws Exception - { - restClient.authenticateUser(adminUser); - RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - - restClient.withWorkflowAPI().usingTask(taskModel).updateTaskVariable(variableModel); - taskModel.setId("incorrectTaskId"); - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } -} diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/DeleteTaskVariableFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/DeleteTaskVariableTests.java similarity index 54% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/variables/DeleteTaskVariableFullTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/variables/DeleteTaskVariableTests.java index e405a0278..e0c5f8e0d 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/DeleteTaskVariableFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/DeleteTaskVariableTests.java @@ -12,6 +12,7 @@ import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TaskModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -21,9 +22,9 @@ import org.testng.annotations.Test; /** * @author bogdan.bocancea */ -public class DeleteTaskVariableFullTests extends RestTest +public class DeleteTaskVariableTests extends RestTest { - private UserModel userModel; + private UserModel userModel, assigneeUser, adminUser; private SiteModel siteModel; private FileModel fileModel; private TaskModel taskModel; @@ -31,15 +32,135 @@ public class DeleteTaskVariableFullTests extends RestTest @BeforeClass(alwaysRun=true) public void dataPreparation() throws Exception { + adminUser = dataUser.getAdminUser(); userModel = dataUser.createRandomTestUser(); + assigneeUser = dataUser.createRandomTestUser(); siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(userModel); + taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); } - + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Delete existing task variable") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + public void deleteTaskVariable() throws Exception + { + restClient.authenticateUser(adminUser); + RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + + restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables() + .assertThat().entriesListDoesNotContain("name", variableModel.getName()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Try to delete existing task variable using invalid task id") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void tryToDeleteTaskVariableUsingInvalidTaskId() throws Exception + { + restClient.authenticateUser(adminUser); + RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + + restClient.withWorkflowAPI().usingTask(taskModel).updateTaskVariable(variableModel); + taskModel.setId("incorrectTaskId"); + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Delete task variable with any user") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + public void deleteTaskVariableByAnyUser() throws Exception + { + restClient.authenticateUser(userModel); + RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + + restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables() + .assertThat().entriesListDoesNotContain("name", variableModel.getName()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Delete task variable with invalid type") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void deleteTaskVariableInvalidType() throws Exception + { + restClient.authenticateUser(userModel); + RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); + variableModel.setType("invalid-type"); + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables() + . assertThat().entriesListDoesNotContain("name", variableModel.getName()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Delete task variable with invalid name") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void deleteTaskVariableInvalidName() throws Exception + { + restClient.authenticateUser(userModel); + RestVariableModel variableModel = new RestVariableModel("local", "<>.,;/|-+=%", "d:text", "invalid name"); + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Create, update, delete task variable with any user") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void createUpdateDeleteTaskVariableByAnyUser() throws Exception + { + restClient.authenticateUser(userModel); + RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + + restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); + variableModel.setName("new-variable"); + restClient.withWorkflowAPI().usingTask(taskModel).updateTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables() + .assertThat().entriesListDoesNotContain("name", variableModel.getName()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Delete task variable by non assigned user") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void deleteTaskVariableByNonAssignedUser() throws Exception + { + UserModel nonAssigned = dataUser.createRandomTestUser(); + RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + + restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); + restClient.authenticateUser(nonAssigned).withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Delete task variable by inexistent user") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @Bug(id="MNT-16904", description = "It fails only on environment with tenants") + public void deleteTaskVariableByInexistentUser() throws Exception + { + RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); + restClient.authenticateUser(UserModel.getRandomUserModel()) + .withWorkflowAPI() + .usingTask(taskModel) + .deleteTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Delete task variable twice") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) public void deleteTaskVariableTwice() throws Exception { restClient.authenticateUser(userModel); @@ -61,7 +182,7 @@ public class DeleteTaskVariableFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Delete task variable with empty variable name") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) public void deleteTaskEmptyVariableName() throws Exception { restClient.authenticateUser(userModel); @@ -79,7 +200,7 @@ public class DeleteTaskVariableFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Delete task variable with empty variable scope") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) public void deleteTaskEmptyVariableScope() throws Exception { restClient.authenticateUser(userModel); @@ -96,7 +217,7 @@ public class DeleteTaskVariableFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Delete task variable with invalid variable name") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) public void deleteTaskInvalidVariableName() throws Exception { restClient.authenticateUser(userModel); @@ -112,7 +233,7 @@ public class DeleteTaskVariableFullTests extends RestTest .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL, TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify that admin from the same network is able to remove task variables") public void addTaskVariablesByTenantAdmin() throws Exception @@ -136,7 +257,7 @@ public class DeleteTaskVariableFullTests extends RestTest } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL, TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify that admin from the other network is not able to remove task variables") public void addTaskVariablesByTenantAdminOtherNetwork() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/GetTaskVariablesCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/GetTaskVariablesCoreTests.java deleted file mode 100644 index d0e788191..000000000 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/GetTaskVariablesCoreTests.java +++ /dev/null @@ -1,116 +0,0 @@ -package org.alfresco.rest.workflow.tasks.variables; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.model.RestTaskModel; -import org.alfresco.rest.model.RestVariableModelsCollection; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TaskModel; -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; - -/** - * Created by Claudia Agache on 12/7/2016. - */ - -public class GetTaskVariablesCoreTests extends RestTest -{ - private UserModel userWhoStartsTask, assignee; - private SiteModel siteModel; - private FileModel fileModel; - private TaskModel taskModel; - private RestVariableModelsCollection variableModels; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - userWhoStartsTask = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify if get task variables request returns status code 404 when invalid taskId is used") - public void getTaskVariablesUsingInvalidTaskId() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); - taskModel.setId("invalidId"); - - restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingTask(taskModel).getTaskVariables(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidId")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify if get task variables request returns status code 404 when empty taskId is used") - public void getTaskVariablesUsingEmptyTaskId() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); - taskModel.setId(""); - - restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingTask(taskModel).getTaskVariables(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify if get task variables request returns status code 200 after the task is finished.") - public void getTaskVariablesAfterFinishingTask() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); - dataWorkflow.usingUser(assignee).taskDone(taskModel); - - variableModels = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingTask(taskModel).getTaskVariables(); - restClient.assertStatusCodeIs(HttpStatus.OK); - variableModels.assertThat().entriesListIsNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify if get task variables request returns status code 200 after the process is deleted (Task state is now completed.)") - public void getTaskVariablesAfterDeletingProcess() throws Exception - { - RestProcessModel addedProcess = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.Normal); - RestTaskModel addedTask = restClient.withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess); - restClient.withWorkflowAPI().usingProcess(addedProcess).deleteProcess(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - variableModels = restClient.withWorkflowAPI().usingTask(addedTask).getTaskVariables(); - restClient.assertStatusCodeIs(HttpStatus.OK); - variableModels.assertThat().entriesListIsNotEmpty(); - } - - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify user gets task variables that matches a where clause.") - public void getTaskVariablesWithWhereClauseAsParameter() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); - variableModels = restClient.authenticateUser(userWhoStartsTask).where("scope='local'") - .withWorkflowAPI().usingTask(taskModel).getTaskVariables(); - restClient.assertStatusCodeIs(HttpStatus.OK); - variableModels.assertThat().entriesListIsNotEmpty() - .and().entriesListDoesNotContain("scope", "global") - .and().paginationField("totalItems").is("8"); - - variableModels = restClient.authenticateUser(userWhoStartsTask) - .withWorkflowAPI().usingTask(taskModel).getTaskVariables(); - restClient.assertStatusCodeIs(HttpStatus.OK); - variableModels.assertThat().entriesListContains("scope", "global") - .and().paginationField("totalItems").is("30"); - } - -} diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/GetTaskVariablesSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/GetTaskVariablesSanityTests.java deleted file mode 100644 index f6d249f05..000000000 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/GetTaskVariablesSanityTests.java +++ /dev/null @@ -1,87 +0,0 @@ -package org.alfresco.rest.workflow.tasks.variables; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestVariableModelsCollection; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TaskModel; -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 GetTaskVariablesSanityTests extends RestTest -{ - private UserModel userModel, userWhoStartsTask, assignee; - private SiteModel siteModel; - private FileModel fileModel; - private TaskModel taskModel; - private RestVariableModelsCollection variableModels; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - userWhoStartsTask = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, - description = "Verify that user that started the process gets task variables") - public void getTaskVariablesByUserWhoStartedProcess() throws Exception - { - restClient.authenticateUser(userWhoStartsTask); - variableModels = restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables(); - restClient.assertStatusCodeIs(HttpStatus.OK); - variableModels.assertThat().entriesListIsNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, - description = "Verify that user that is involved in the process gets task variables") - public void getTaskVariablesByUserInvolvedInProcess() throws Exception - { - restClient.authenticateUser(assignee); - variableModels = restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables(); - restClient.assertStatusCodeIs(HttpStatus.OK); - variableModels.assertThat().entriesListIsNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, - description = "Verify that user that is not involved in the process gets task variables") - public void getTaskVariablesUsingAnyUser() throws Exception - { - UserModel randomUser = dataUser.createRandomTestUser(); - - restClient.authenticateUser(randomUser); - restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, - description = "Verify that admin is able to task variables") - public void getTaskVariablesUsingAdmin() throws Exception - { - UserModel adminUser = dataUser.getAdminUser(); - - restClient.authenticateUser(adminUser); - variableModels = restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables(); - restClient.assertStatusCodeIs(HttpStatus.OK); - variableModels.assertThat().entriesListIsNotEmpty(); - } -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/GetTaskVariablesFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/GetTaskVariablesTests.java similarity index 55% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/variables/GetTaskVariablesFullTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/variables/GetTaskVariablesTests.java index 7ee844cbd..45ffc0dcb 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/GetTaskVariablesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/GetTaskVariablesTests.java @@ -18,7 +18,7 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -public class GetTaskVariablesFullTests extends RestTest +public class GetTaskVariablesTests extends RestTest { private UserModel userWhoStartsTask, assignee; private SiteModel siteModel; @@ -35,26 +35,135 @@ public class GetTaskVariablesFullTests extends RestTest fileModel = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Verify that user that started the process gets task variables") + public void getTaskVariablesByUserWhoStartedProcess() throws Exception + { + restClient.authenticateUser(userWhoStartsTask); + variableModels = restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables(); + restClient.assertStatusCodeIs(HttpStatus.OK); + variableModels.assertThat().entriesListIsNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Verify that user that is involved in the process gets task variables") + public void getTaskVariablesByUserInvolvedInProcess() throws Exception + { + restClient.authenticateUser(assignee); + variableModels = restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables(); + restClient.assertStatusCodeIs(HttpStatus.OK); + variableModels.assertThat().entriesListIsNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Verify that user that is not involved in the process gets task variables") + public void getTaskVariablesUsingAnyUser() throws Exception + { + UserModel randomUser = dataUser.createRandomTestUser(); + + restClient.authenticateUser(randomUser); + restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Verify that admin is able to task variables") + public void getTaskVariablesUsingAdmin() throws Exception + { + UserModel adminUser = dataUser.getAdminUser(); + + restClient.authenticateUser(adminUser); + variableModels = restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables(); + restClient.assertStatusCodeIs(HttpStatus.OK); + variableModels.assertThat().entriesListIsNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify default error shema for get task variables") - public void getTaskVariablesCheckDefaultErrorSchema() throws Exception + description = "Verify if get task variables request returns status code 404 when invalid taskId is used") + public void getTaskVariablesUsingInvalidTaskId() throws Exception { taskModel = dataWorkflow.usingUser(userWhoStartsTask) - .usingSite(siteModel).usingResource(fileModel) - .createNewTaskAndAssignTo(assignee); + .usingSite(siteModel).usingResource(fileModel) + .createNewTaskAndAssignTo(assignee); taskModel.setId("invalidId"); restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingTask(taskModel).getTaskVariables(); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidId")) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidId")) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify if get task variables request returns status code 404 when empty taskId is used") + public void getTaskVariablesUsingEmptyTaskId() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); + taskModel.setId(""); + + restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingTask(taskModel).getTaskVariables(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify if get task variables request returns status code 200 after the task is finished.") + public void getTaskVariablesAfterFinishingTask() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); + dataWorkflow.usingUser(assignee).taskDone(taskModel); + + variableModels = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingTask(taskModel).getTaskVariables(); + restClient.assertStatusCodeIs(HttpStatus.OK); + variableModels.assertThat().entriesListIsNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify if get task variables request returns status code 200 after the process is deleted (Task state is now completed.)") + public void getTaskVariablesAfterDeletingProcess() throws Exception + { + RestProcessModel addedProcess = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.Normal); + RestTaskModel addedTask = restClient.withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess); + restClient.withWorkflowAPI().usingProcess(addedProcess).deleteProcess(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + variableModels = restClient.withWorkflowAPI().usingTask(addedTask).getTaskVariables(); + restClient.assertStatusCodeIs(HttpStatus.OK); + variableModels.assertThat().entriesListIsNotEmpty(); + } + + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify user gets task variables that matches a where clause.") + public void getTaskVariablesWithWhereClauseAsParameter() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); + variableModels = restClient.authenticateUser(userWhoStartsTask).where("scope='local'") + .withWorkflowAPI().usingTask(taskModel).getTaskVariables(); + restClient.assertStatusCodeIs(HttpStatus.OK); + variableModels.assertThat().entriesListIsNotEmpty() + .and().entriesListDoesNotContain("scope", "global") + .and().paginationField("totalItems").is("8"); + + variableModels = restClient.authenticateUser(userWhoStartsTask) + .withWorkflowAPI().usingTask(taskModel).getTaskVariables(); + restClient.assertStatusCodeIs(HttpStatus.OK); + variableModels.assertThat().entriesListContains("scope", "global") + .and().paginationField("totalItems").is("30"); } @Bug(id="MNT-17438") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify user gets task with 'maxItems' parameter") public void getTaskVariablesWithMaxItems() throws Exception @@ -68,7 +177,7 @@ public class GetTaskVariablesFullTests extends RestTest } @Bug(id="MNT-17438") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify user gets task with 'skipCount' parameter") public void getTaskVariablesWithSkipCount() throws Exception @@ -81,7 +190,7 @@ public class GetTaskVariablesFullTests extends RestTest .and().paginationField("count").is("20"); } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot get task variables with invalid where clause.") public void getTaskVariablesWithInvalidWhereClauseAsParameter() throws Exception @@ -96,7 +205,7 @@ public class GetTaskVariablesFullTests extends RestTest .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify user gets tasks variables with 'properties' parameter") public void getTaskVariablesWithValidProperties() throws Exception @@ -114,7 +223,7 @@ public class GetTaskVariablesFullTests extends RestTest .field("name").isNotEmpty(); } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot get tasks variables with invalid 'properties' parameter") public void getTaskVariablesWithInvalidProperties() throws Exception @@ -131,7 +240,7 @@ public class GetTaskVariablesFullTests extends RestTest .field("name").isNull(); } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL, TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify that admin from the same network is able to retrieve network task variables") public void getTaskVariablesByTenantAdmin() throws Exception @@ -150,7 +259,7 @@ public class GetTaskVariablesFullTests extends RestTest variableModels.assertThat().entriesListIsNotEmpty(); } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL, TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify that admin from another network is not able to retrieve network task variables") public void getTaskVariablesByTenantFromAnotherNetwork() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk1.java similarity index 96% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableSanityTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk1.java index f98157164..f39fc152b 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk1.java @@ -20,7 +20,7 @@ import org.testng.annotations.Test; /** * @author iulia.cojocea */ -public class UpdateTaskVariableSanityTests extends RestTest +public class UpdateTaskVariableTestsBulk1 extends RestTest { private UserModel userModel; private UserModel adminUser; @@ -80,8 +80,8 @@ public class UpdateTaskVariableSanityTests extends RestTest taskVariable.assertThat().field("value").is("updatedValue"); } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY, TestGroup.NETWORKS}) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS}) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Update existing task variable by admin in the same network") public void updateTaskVariableByAdminInSameNetwork() throws Exception { diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk2.java similarity index 95% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableCoreTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk2.java index d29930dd8..5c5252071 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk2.java @@ -19,7 +19,7 @@ import org.testng.annotations.Test; /** * @author bogdan.bocancea */ -public class UpdateTaskVariableCoreTests extends RestTest +public class UpdateTaskVariableTestsBulk2 extends RestTest { private UserModel userModel; private SiteModel siteModel; @@ -39,9 +39,9 @@ public class UpdateTaskVariableCoreTests extends RestTest taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); } - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Update task variable by user who started the process") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) public void updateTaskVariableByUserWhoStartedProcess() throws Exception { variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); @@ -59,7 +59,7 @@ public class UpdateTaskVariableCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Update task variable with symbols in name") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) public void updateTaskVariableWithSymbolsInName() throws Exception { String symbolName = "<>.,;-'+=%|[]#*&-+"; @@ -76,7 +76,7 @@ public class UpdateTaskVariableCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Update task variable with invalid task id") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) public void updateTaskVariableWithInvalidTaskId() throws Exception { TaskModel invalidTask = new TaskModel(userModel.getUsername()); @@ -90,7 +90,7 @@ public class UpdateTaskVariableCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Update task variable with invalid scope") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) public void updateTaskVariableWithInvalidScope() throws Exception { variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); @@ -106,7 +106,7 @@ public class UpdateTaskVariableCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Update task variable with invalid type") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) public void updateTaskVariableWithInvalidType() throws Exception { variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); @@ -122,7 +122,7 @@ public class UpdateTaskVariableCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Update task variable with symbols in value") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) public void updateTaskVariableWithSymbolsInValue() throws Exception { String symbolValue = "<>.,;-'+=%|[]#*&-+/\\#!@"; @@ -139,7 +139,7 @@ public class UpdateTaskVariableCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Update task variable by non assigned user") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) public void updateTaskVariableByNonAssignedUser() throws Exception { UserModel nonAssigned = dataUser.createRandomTestUser(); @@ -156,9 +156,9 @@ public class UpdateTaskVariableCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Update task variable by inexistent user") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void updateTaskVariableByInexistentser() throws Exception + public void updateTaskVariableByNonexistentUser() throws Exception { variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); taskVariable = restClient.authenticateUser(userModel) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk3.java similarity index 97% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableFullTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk3.java index e8ab9696f..9602fbf32 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk3.java @@ -20,7 +20,7 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -public class UpdateTaskVariableFullTests extends RestTest +public class UpdateTaskVariableTestsBulk3 extends RestTest { private SiteModel siteModel; private FileModel fileModel; @@ -39,7 +39,7 @@ public class UpdateTaskVariableFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Update task variable with invalid name - PUT call") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) public void updateTaskVariableWithInvalidVariableName() throws Exception { taskVariable = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); @@ -58,7 +58,7 @@ public class UpdateTaskVariableFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Update task variable with invalid name - PUT call") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) public void updateTaskVariableWithInvalidVariableValue() throws Exception { taskVariable = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); @@ -77,7 +77,7 @@ public class UpdateTaskVariableFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Update task variable with invalid name - PUT call") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) public void updateTaskVariableWithEmptyVariableName() throws Exception { taskVariable = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); @@ -96,7 +96,7 @@ public class UpdateTaskVariableFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Update task variable with empty name - PUT call") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) public void updateTaskVariableWithEmptyName() throws Exception { taskVariable = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); @@ -114,7 +114,7 @@ public class UpdateTaskVariableFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Update task variable with empty name - PUT call") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) public void updateTaskVariableWithInvalidName() throws Exception { taskVariable = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); @@ -132,7 +132,7 @@ public class UpdateTaskVariableFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Update task variable with empty name - PUT call") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) public void updateTaskVariableWithInvalidValue() throws Exception { taskVariable = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); @@ -150,7 +150,7 @@ public class UpdateTaskVariableFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Update task variable with empty name - PUT call") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) public void updateTaskVariableWithMissingType() throws Exception { taskVariable = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); @@ -170,7 +170,7 @@ public class UpdateTaskVariableFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Update task variable with empty name - PUT call") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) public void updateTaskVariableWithMissingTypeAndValue() throws Exception { taskVariable = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); @@ -189,7 +189,7 @@ public class UpdateTaskVariableFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Update task variable with invalid name - PUT call") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) public void updateTaskVariableWithEmptyBody() throws Exception { taskVariable = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); @@ -209,7 +209,7 @@ public class UpdateTaskVariableFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Update task variable with invalid name - PUT call") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) public void updateTaskVariableWithInvalidBody() throws Exception { taskVariable = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); @@ -228,7 +228,7 @@ public class UpdateTaskVariableFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Update task variable with empty name - PUT call") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) public void updateTwiceInARowSameTaskVariable() throws Exception { taskVariable = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); @@ -248,7 +248,7 @@ public class UpdateTaskVariableFullTests extends RestTest updatedTaskVariable.assertThat().field("name").is("newName"); } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL, TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify that admin from another network is not able to update task variables") public void updateTaskVariablesByTenantFromAnotherNetwork() throws Exception From 6731b3053c3115ca9047cf6761613f1cd7602fbf Mon Sep 17 00:00:00 2001 From: Alexandru-Eusebiu Epure Date: Tue, 10 Oct 2017 14:57:10 +0300 Subject: [PATCH 1238/1491] REPO-2755 : REST API & CMIS TAS sanity builds Change testgroup from CORE to REGRESSION for workflow (items + tasks + variables) --- .../DeleteDeploymentCoreFullTests.java | 4 +- .../DeleteDeploymentSanityTests.java | 2 +- .../deployments/GetDeploymentCoreTests.java | 6 +- .../deployments/GetDeploymentFullTests.java | 6 +- .../deployments/GetDeploymentsCoreTests.java | 6 +- .../deployments/GetDeploymentsFullTests.java | 18 +- .../GetProcessDefinitionCoreTests.java | 6 +- .../GetProcessDefinitionFullTests.java | 6 +- .../GetProcessDefinitionImageCoreTests.java | 8 +- .../GetProcessDefinitionImageFullTests.java | 6 +- ...cessDefinitionStartFormModelCoreTests.java | 12 +- ...cessDefinitionStartFormModelFullTests.java | 6 +- .../GetProcessDefinitionsCoreTests.java | 29 +-- .../GetProcessDefinitionsFullTests.java | 22 +- .../GetProcessDefinitionsSanityTests.java | 17 +- .../processes/AddProcessCoreTests.java | 24 +- .../processes/AddProcessFullTests.java | 16 +- .../processes/AddProcessSanityTests.java | 1 + .../processes/DeleteProcessCoreTests.java | 6 +- .../processes/DeleteProcessFullTests.java | 2 +- .../processes/GetProcessCoreTests.java | 16 +- .../processes/GetProcessFullTests.java | 18 +- .../processes/GetProcessesCoreTests.java | 12 +- .../processes/GetProcessesFullTests.java | 34 +-- .../items/AddProcessItemCoreTests.java | 26 +-- .../items/AddProcessItemFullTests.java | 12 +- .../items/AddProcessItemSanityTests.java | 4 +- .../items/DeleteProcessItemCoreTests.java | 6 +- .../items/DeleteProcessItemFullTests.java | 22 +- .../items/GetProcessItemsCoreTests.java | 6 +- .../items/GetProcessItemsFullTests.java | 25 +-- .../tasks/GetProcessTasksCoreTests.java | 12 +- .../tasks/GetProcessTasksFullTests.java | 23 +- .../AddProcessVariableCoreTests.java | 25 +-- .../AddProcessVariableFullTests.java | 34 +-- .../AddProcessVariablesCoreTests.java | 100 +-------- .../AddProcessVariablesFullTests.java | 208 +++++++++--------- .../DeleteProcessVariableCoreTests.java | 26 +-- .../DeleteProcessVariableFullTests.java | 92 +++----- .../DeleteProcessVariableSanityTests.java | 2 +- .../GetProcessVariablesCoreTests.java | 10 +- .../GetProcessVariablesFullTests.java | 18 +- .../variables/UpdateProcessVariableTests.java | 6 +- 43 files changed, 405 insertions(+), 535 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentCoreFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentCoreFullTests.java index b389c17ea..cee3854cf 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentCoreFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentCoreFullTests.java @@ -28,7 +28,7 @@ public class DeleteDeploymentCoreFullTests extends RestTest @Bug(id = "MNT-16996") @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify deleteDeployment is unsupported for empty deployment id with REST API and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.DEPLOYMENTS, TestGroup.CORE, TestGroup.WORKFLOW }) + @Test(groups = { TestGroup.REST_API, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION, TestGroup.WORKFLOW }) public void deleteDeploymentIsUnsupportedForEmptyId() throws Exception { deployment = restClient.authenticateUser(adminUser).withWorkflowAPI().getDeployments().getOneRandomEntry().onModel(); @@ -41,7 +41,7 @@ public class DeleteDeploymentCoreFullTests extends RestTest @Bug(id = "MNT-16996") @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify deleteDeployment is forbidden using non admin user or different user than creator with REST API and status code is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.DEPLOYMENTS, TestGroup.CORE, TestGroup.WORKFLOW }) + @Test(groups = { TestGroup.REST_API, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION, TestGroup.WORKFLOW }) public void deleteDeploymentUsingNonAdminUser() throws Exception { deployment = restClient.authenticateUser(adminUser).withWorkflowAPI().getDeployments().getOneRandomEntry().onModel(); diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java index a433d2609..b3e8d26ce 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java @@ -102,7 +102,7 @@ public class DeleteDeploymentSanityTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE); } - @Bug(id = "MNT-16996") +// @Bug(id = "MNT-16996") @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.SANITY, description = "Verify admin user cannot delete an inexistent deployment using REST API and status code is successful (204)") @Test(groups = { TestGroup.REST_API, TestGroup.DEPLOYMENTS, TestGroup.SANITY, TestGroup.WORKFLOW }, priority = 100) diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentCoreTests.java index 68dabae09..1e37d91a7 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentCoreTests.java @@ -28,7 +28,7 @@ public class GetDeploymentCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify if get deployment request returns status code 404 when invalid deploymentId is used.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION }) public void getNonNetworkDeploymentUsingInvalidDeploymentId() throws Exception { expectedDeployment = restClient.authenticateUser(adminUser).withWorkflowAPI().getDeployments().getOneRandomEntry().onModel(); @@ -42,7 +42,7 @@ public class GetDeploymentCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify if network admin user gets a network deployment using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.CORE, TestGroup.NETWORKS}) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION, TestGroup.NETWORKS}) public void adminGetsNetworkDeploymentWithSuccess() throws Exception { adminTenantUser = UserModel.getAdminTenantUser(); @@ -60,7 +60,7 @@ public class GetDeploymentCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify non admin user is forbidden to get a network deployment using REST API (403)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.CORE, TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION, TestGroup.NETWORKS }) public void nonAdminUserIsForbiddenToGetNetworkDeployment() throws Exception { adminTenantUser = UserModel.getAdminTenantUser(); diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentFullTests.java index a13c4a50f..590f0f2f3 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentFullTests.java @@ -31,7 +31,7 @@ public class GetDeploymentFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify if get deployment request returns all deployments if empty deploymentId is used.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION }) public void getNonNetworkDeploymentUsingEmptyDeploymentId() throws Exception { restClient.authenticateUser(adminUser).withWorkflowAPI(); @@ -43,7 +43,7 @@ public class GetDeploymentFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Admin user gets non-network deployments with properties parameter applied using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.FULL}) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION}) public void getNonNetworkDeploymentsWithValidProperties() throws Exception { expectedDeployment = restClient.authenticateUser(adminUser).withWorkflowAPI().getDeployments().getOneRandomEntry().onModel(); @@ -59,7 +59,7 @@ public class GetDeploymentFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify that network admin user is not able to get a deployment from other network using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.FULL, TestGroup.NETWORKS}) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION, TestGroup.NETWORKS}) public void adminDoesNotGetDeploymentFromOtherNetwork() throws Exception { UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsCoreTests.java index d2542f4b9..000a7f8d0 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsCoreTests.java @@ -32,7 +32,7 @@ public class GetDeploymentsCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify non admin user is not able to get non-network deployments using REST API and status code is Forbidden") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.CORE}) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION}) public void nonAdminUserCanNotGetNonNetworkDeployments() throws Exception { UserModel userModel = dataUser.createRandomTestUser(); @@ -44,7 +44,7 @@ public class GetDeploymentsCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify non admin user is not able to get network deployments using REST API and status code is Forbidden") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.CORE, TestGroup.NETWORKS}) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION, TestGroup.NETWORKS}) public void nonAdminUserCanNotGetNetworkDeployments() throws Exception { adminTenantUser = UserModel.getAdminTenantUser(); @@ -61,7 +61,7 @@ public class GetDeploymentsCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify get deployments returns an empty list after deleting all network deployments.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.CORE, TestGroup.NETWORKS}) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION, TestGroup.NETWORKS}) public void getNetworkDeploymentsAfterDeletingAllNetworkDeployments() throws Exception { adminTenantUser = UserModel.getAdminTenantUser(); diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsFullTests.java index d6ab2eaec..697f9978c 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsFullTests.java @@ -30,7 +30,7 @@ public class GetDeploymentsFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Admin user gets non-network deployments with skipCount parameter applied using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.FULL}) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION}) public void getNonNetworkDeploymentsWithValidSkipCount() throws JsonToModelConversionException, Exception { deployments = restClient.withWorkflowAPI().getDeployments(); @@ -48,7 +48,7 @@ public class GetDeploymentsFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Admin user doesn't get non-network deployments when negative skipCount parameter is applied using REST API and status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.FULL}) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION}) public void getNonNetworkDeploymentsWithNegativeSkipCount() throws JsonToModelConversionException, Exception { restClient.withParams("skipCount=-1").withWorkflowAPI().getDeployments(); @@ -62,7 +62,7 @@ public class GetDeploymentsFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Admin user doesn't get non-network deployments when non numeric skipCount parameter is applied using REST API and status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.FULL}) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION}) public void getNonNetworkDeploymentsWithNotNumericSkipCount() throws JsonToModelConversionException, Exception { restClient.withParams("skipCount=A").withWorkflowAPI().getDeployments(); @@ -73,7 +73,7 @@ public class GetDeploymentsFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Admin user gets non-network deployments with maxItems parameter applied using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.FULL}) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION}) public void getNonNetworkDeploymentsWithValidMaxItems() throws JsonToModelConversionException, Exception { deployments = restClient.withWorkflowAPI().getDeployments(); @@ -91,7 +91,7 @@ public class GetDeploymentsFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Admin user doesn't get non-network deployments when negative maxItems parameter is applied using REST API and status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.FULL}) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION}) public void getNonNetworkDeploymentsWithNegativeMaxItems() throws JsonToModelConversionException, Exception { restClient.withParams("maxItems=-1").withWorkflowAPI().getDeployments(); @@ -105,7 +105,7 @@ public class GetDeploymentsFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Admin user doesn't get non-network deployments when non numeric maxItems parameter is applied using REST API and status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.FULL}) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION}) public void getNonNetworkDeploymentsWithNotNumericMaxItems() throws JsonToModelConversionException, Exception { restClient.withParams("maxItems=A").withWorkflowAPI().getDeployments(); @@ -115,7 +115,7 @@ public class GetDeploymentsFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Admin user gets non-network deployments with properties parameter applied using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.FULL}) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION}) public void getNonNetworkDeploymentsWithValidProperties() throws JsonToModelConversionException, Exception { deployments = restClient.withParams("properties=name").withWorkflowAPI().getDeployments(); @@ -130,7 +130,7 @@ public class GetDeploymentsFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Admin user gets non-network deployments with non existing properties parameter applied using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.FULL}) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION}) public void getNonNetworkDeploymentsWithNonExistingProperties() throws JsonToModelConversionException, Exception { deployments = restClient.withParams("properties=TAS").withWorkflowAPI().getDeployments(); @@ -146,7 +146,7 @@ public class GetDeploymentsFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify that network admin user is not able to get a deployment from other network using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.FULL, TestGroup.NETWORKS}) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION, TestGroup.NETWORKS}) public void adminDoesNotGetDeploymentsFromOtherNetwork() throws Exception { UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionCoreTests.java index 9f9dc621a..db94b2011 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionCoreTests.java @@ -28,7 +28,7 @@ public class GetProcessDefinitionCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify if get process definition returns status code 404 when invalid processDefinitionId is used") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) public void getProcessDefinitionUsingInvalidProcessDefinitionId() throws Exception { restClient.authenticateUser(adminUser); @@ -46,7 +46,7 @@ public class GetProcessDefinitionCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify network admin is able to get a process definition using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.CORE, TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION, TestGroup.NETWORKS }) public void networkAdminGetProcessDefinition() throws Exception { adminTenantUser = UserModel.getAdminTenantUser(); @@ -61,7 +61,7 @@ public class GetProcessDefinitionCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify network user is able to get a process definition using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.CORE, TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION, TestGroup.NETWORKS }) public void networkUserGetProcessDefinition() throws Exception { adminTenantUser = UserModel.getAdminTenantUser(); diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionFullTests.java index 53721b10d..390f9845c 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionFullTests.java @@ -31,7 +31,7 @@ public class GetProcessDefinitionFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify if get process definition returns all process definitions when empty processDefinitionId is used") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) public void getProcessDefinitionUsingEmptyProcessDefinitionId() throws Exception { restClient.authenticateUser(adminUser).withWorkflowAPI(); @@ -44,7 +44,7 @@ public class GetProcessDefinitionFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify Admin user gets a process definition with properties parameter applied using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) public void getProcessDefinitionWithValidProperties() throws Exception { randomProcessDefinition = restClient.authenticateUser(adminUser).withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry().onModel(); @@ -69,7 +69,7 @@ public class GetProcessDefinitionFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify Network user is not able to get a process definition from another network") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.NETWORKS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.NETWORKS, TestGroup.REGRESSION }) public void getProcessDefinitionFromAnotherNetwork() throws Exception { UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageCoreTests.java index dfe7f05c2..125c749d5 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageCoreTests.java @@ -29,7 +29,7 @@ public class GetProcessDefinitionImageCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify if get process definition image returns status code 404 when invalid processDefinitionId is used") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) public void getProcessDefinitionImageUsingInvalidProcessDefinitionId() throws Exception { restClient.authenticateUser(adminUser); @@ -48,7 +48,7 @@ public class GetProcessDefinitionImageCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify network admin is able to get a process definition image using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.CORE, TestGroup.NETWORKS}) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION, TestGroup.NETWORKS}) @Bug(id = "MNT-17243") public void networkAdminGetProcessDefinitionImage() throws Exception { @@ -65,8 +65,8 @@ public class GetProcessDefinitionImageCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify network user is able to get a process definition image using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.CORE, TestGroup.NETWORKS}) - @Bug(id = "MNT-17243") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION, TestGroup.NETWORKS}) +// @Bug(id = "MNT-17243") public void networkUserGetProcessDefinitionImage() throws Exception { adminTenantUser = UserModel.getAdminTenantUser(); diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageFullTests.java index a43f77700..13775051b 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageFullTests.java @@ -26,11 +26,11 @@ public class GetProcessDefinitionImageFullTests extends RestTest adminUser = dataUser.getAdminUser(); } - @Bug(id = "REPO-1911") +// @Bug(id = "REPO-1911") @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify if get process definition image returns status code 404 when empty processDefinitionId is used") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) public void getProcessDefinitionImageUsingEmptyProcessDefinitionId() throws Exception { restClient.authenticateUser(adminUser); @@ -44,7 +44,7 @@ public class GetProcessDefinitionImageFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify Tenant User doesn't get process definition image for another network deployment using REST API") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.FULL, TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION, TestGroup.NETWORKS }) public void networkUserIsNotAbleToGetProcessDefinitionImageForAnotherNetwork() throws Exception { UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java index 5322dd11f..37bf1fa99 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java @@ -32,7 +32,7 @@ public class GetProcessDefinitionStartFormModelCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify any user gets a model of the start form type definition for non-network deployments using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) public void nonNetworkUserGetsStartFormModel() throws Exception { UserModel nonNetworkUser = dataUser.createRandomTestUser(); @@ -43,11 +43,11 @@ public class GetProcessDefinitionStartFormModelCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); } - @Bug(id = "ALF-20187") +// @Bug(id = "ALF-20187") @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify if get request returns status code 404 when invalid processDefinitionId is used") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) public void getStartFormModelUsingInvalidProcessDefinitionId() throws Exception { randomProcessDefinition = allProcessDefinitions.getOneRandomEntry().onModel(); @@ -62,11 +62,11 @@ public class GetProcessDefinitionStartFormModelCoreTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE); } - @Bug(id = "ALF-20187") +// @Bug(id = "ALF-20187") @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify if get request returns status code 404 when empty processDefinitionId is used") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) public void getStartFormModelUsingEmptyProcessDefinitionId() throws Exception { randomProcessDefinition = allProcessDefinitions.getOneRandomEntry().onModel(); @@ -81,7 +81,7 @@ public class GetProcessDefinitionStartFormModelCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify Tenant User gets a model of the start form type definition for network deployments using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.CORE, TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION, TestGroup.NETWORKS }) public void networkUserGetsStartFormModel() throws Exception { adminTenantUser = UserModel.getAdminTenantUser(); diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelFullTests.java index c7bfcc303..735af3df4 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelFullTests.java @@ -33,7 +33,7 @@ public class GetProcessDefinitionStartFormModelFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify admin gets a model of the start form type definition for specific process definition using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) public void adminGetsStartFormModelForActivitiAdhocProcessDefinition() throws Exception { returnedResponse = restClient.authenticateUser(adminUser).withWorkflowAPI() @@ -52,7 +52,7 @@ public class GetProcessDefinitionStartFormModelFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify admin gets a model of the start form type definition with properties parameter applied using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) public void adminGetsStartFormModelWithPropertiesParameterApplied() throws Exception { returnedResponse = restClient.authenticateUser(adminUser).withParams("properties=qualifiedName,dataType,title").withWorkflowAPI() @@ -73,7 +73,7 @@ public class GetProcessDefinitionStartFormModelFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify Tenant User doesn't get a model of the start form type definition for another network deployment using REST API") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.FULL, TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION, TestGroup.NETWORKS }) public void networkUserIsNotAbleToGetStartFormModelForAnotherNetwork() throws Exception { UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsCoreTests.java index d1c9729f8..09d5ebf65 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsCoreTests.java @@ -2,7 +2,6 @@ package org.alfresco.rest.workflow.processDefinitions; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestProcessDefinitionModelsCollection; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; @@ -26,31 +25,9 @@ public class GetProcessDefinitionsCoreTests extends RestTest adminTenantUser = UserModel.getAdminTenantUser(); } - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, - description = "Verify any user gets process definitions for non-network deployments using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.CORE }) - public void nonNetworkUserGetsProcessDefinitions() throws Exception - { - RestProcessDefinitionModelsCollection processDefinitions = restClient.authenticateUser(userModel) - .withWorkflowAPI() - .getAllProcessDefinitions(); - restClient.assertStatusCodeIs(HttpStatus.OK); - processDefinitions.assertThat().entriesListIsNotEmpty(); - processDefinitions.getProcessDefinitionByDeploymentId("1").assertThat() - .field("name").is("Adhoc Activiti Process").and() - .field("description").is("Assign a new task to yourself or a colleague").and() - .field("id").is("activitiAdhoc:1:4").and() - .field("startFormResourceKey").is("wf:submitAdhocTask").and() - .field("category").is("http://alfresco.org").and() - .field("title").is("New Task").and() - .field("version").is("1").and() - .field("graphicNotationDefined").is("true").and() - .field("key").is("activitiAdhoc"); - } - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify get process definitions using any network user for network enabled deployments with REST API status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.CORE, TestGroup.NETWORKS}) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION, TestGroup.NETWORKS}) public void networkUserGetsProcessDefinitions() throws Exception { restClient.authenticateUser(adminUserModel).usingTenant().createTenant(adminTenantUser); @@ -64,7 +41,7 @@ public class GetProcessDefinitionsCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify call to get process definitions with invalid orderBy parameter with REST API and status code is BAD_REQUEST (400)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) public void userGetProcessDefinitionsWithInvalidOrderBy() throws Exception { restClient.authenticateUser(userModel) @@ -78,7 +55,7 @@ public class GetProcessDefinitionsCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify call to get process definitions with invalid where parameter with REST API and status code is BAD_REQUEST (400)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) public void userGetProcessDefinitionsWithInvalidWhere() throws Exception { restClient.authenticateUser(userModel) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsFullTests.java index 3c9a370d8..47f2525da 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsFullTests.java @@ -28,7 +28,7 @@ public class GetProcessDefinitionsFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify admin gets process definitions with valid skipCount parameter applied using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) public void getProcessDefinitionsWithValidSkipCount() throws Exception { processDefinitions = restClient.authenticateUser(adminUserModel) @@ -48,7 +48,7 @@ public class GetProcessDefinitionsFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify admin doesn't get process definitions with negative skipCount parameter applied using REST API") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) public void getProcessDefinitionsWithNegativeSkipCount() throws Exception { restClient.authenticateUser(adminUserModel).withParams("skipCount=-1").withWorkflowAPI().getAllProcessDefinitions(); @@ -62,7 +62,7 @@ public class GetProcessDefinitionsFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify admin doesn't get process definitions with non numeric skipCount parameter applied using REST API") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) public void getProcessDefinitionsWithNonNumericSkipCount() throws Exception { restClient.authenticateUser(adminUserModel).withParams("skipCount=A").withWorkflowAPI().getAllProcessDefinitions(); @@ -72,7 +72,7 @@ public class GetProcessDefinitionsFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify admin gets process definitions with valid maxItems parameter applied using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) public void getProcessDefinitionsWithValidMaxItems() throws Exception { processDefinitions = restClient.authenticateUser(adminUserModel) @@ -92,7 +92,7 @@ public class GetProcessDefinitionsFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify admin doesn't get process definitions with negative maxItems parameter applied using REST API") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) public void getProcessDefinitionsWithNegativeMaxItems() throws Exception { restClient.authenticateUser(adminUserModel).withParams("maxItems=-1").withWorkflowAPI().getAllProcessDefinitions(); @@ -106,7 +106,7 @@ public class GetProcessDefinitionsFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify admin doesn't get process definitions with non numeric maxItems parameter applied using REST API") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) public void getProcessDefinitionsWithNonNumericMaxItems() throws Exception { restClient.authenticateUser(adminUserModel).withParams("maxItems=A").withWorkflowAPI().getAllProcessDefinitions(); @@ -116,7 +116,7 @@ public class GetProcessDefinitionsFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify Admin user gets process definitions with properties parameter applied using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) public void getProcessDefinitionsWithValidProperties() throws Exception { processDefinitions =restClient.authenticateUser(adminUserModel).withParams("properties=name,graphicNotationDefined,version").withWorkflowAPI().getAllProcessDefinitions(); @@ -138,7 +138,7 @@ public class GetProcessDefinitionsFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify admin gets process definitions ordered by name ascendant using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) public void getProcessDefinitionsOrderedByNameAsc() throws Exception { processDefinitions = restClient.authenticateUser(adminUserModel) @@ -149,7 +149,7 @@ public class GetProcessDefinitionsFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify admin doesn't get process definitions when many fields are used for orderBy parameter") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) public void getProcessDefinitionsOrderedByManyFields() throws Exception { restClient.authenticateUser(adminUserModel) @@ -160,7 +160,7 @@ public class GetProcessDefinitionsFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify admin gets process definitions when where parameter is applied") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) public void getProcessDefinitionsFilteredByKey() throws Exception { processDefinitions = restClient.authenticateUser(adminUserModel) @@ -174,7 +174,7 @@ public class GetProcessDefinitionsFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify Tenant User doesn't get process definitions for another network deployment using REST API") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.FULL, TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION, TestGroup.NETWORKS }) public void networkUserIsNotAbleToGetProcessDefinitionsForAnotherNetwork() throws Exception { UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java index 02f49ff44..1dc68b58c 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java @@ -1,6 +1,7 @@ package org.alfresco.rest.workflow.processDefinitions; import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestProcessDefinitionModelsCollection; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; @@ -29,9 +30,21 @@ public class GetProcessDefinitionsSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY }) public void nonNetworkAdminGetsProcessDefinitions() throws Exception { - restClient.authenticateUser(adminUserModel); - restClient.withWorkflowAPI().getAllProcessDefinitions().assertThat().entriesListIsNotEmpty(); + RestProcessDefinitionModelsCollection processDefinitions = restClient.authenticateUser(adminUserModel) + .withWorkflowAPI() + .getAllProcessDefinitions(); restClient.assertStatusCodeIs(HttpStatus.OK); + processDefinitions.assertThat().entriesListIsNotEmpty(); + processDefinitions.getProcessDefinitionByDeploymentId("1").assertThat() + .field("name").is("Adhoc Activiti Process").and() + .field("description").is("Assign a new task to yourself or a colleague").and() + .field("id").is("activitiAdhoc:1:4").and() + .field("startFormResourceKey").is("wf:submitAdhocTask").and() + .field("category").is("http://alfresco.org").and() + .field("title").is("New Task").and() + .field("version").is("1").and() + .field("graphicNotationDefined").is("true").and() + .field("key").is("activitiAdhoc"); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessCoreTests.java index 0af7b1302..deee29c55 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessCoreTests.java @@ -29,7 +29,7 @@ public class AddProcessCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify non network admin is able to start new process using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void nonNetworkAdminUserStartsNewProcess() throws JsonToModelConversionException, Exception { adminUser = dataUser.getAdminUser(); @@ -49,10 +49,10 @@ public class AddProcessCoreTests extends RestTest .assertThat().entriesListContains("completed", "false") .assertThat().entriesListContains("processDefinitionKey", "activitiAdhoc"); } - + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify start new process with empty request body using REST API returns status code is Bad Request (400)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void startNewProcessWithEmptyProcessBody() throws JsonToModelConversionException, Exception { adminUser = dataUser.getAdminUser(); @@ -64,11 +64,11 @@ public class AddProcessCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) .assertLastError().containsSummary(String.format(RestErrorModel.NO_CONTENT, "No content to map to Object due to end of input")); } - - @Bug(id = "ACE-5671") + +// @Bug(id = "ACE-5671") @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify start new process with invalid request body using REST API returns status code is Bad Request (400)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void startNewProcessWithInvalidProcessDefInProcessBody() throws JsonToModelConversionException, Exception { adminUser = dataUser.getAdminUser(); @@ -79,10 +79,10 @@ public class AddProcessCoreTests extends RestTest restClient.processModel(RestProcessModel.class, request); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); } - + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify start new process with invalid request body using REST API returns status code is Bad Request (400)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void startNewProcessWithInvalidVariablesInProcessBody1() throws JsonToModelConversionException, Exception { adminUser = dataUser.getAdminUser(); @@ -94,10 +94,10 @@ public class AddProcessCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) .assertLastError().containsSummary("Either processDefinitionId or processDefinitionKey is required"); } - + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify start new process with invalid request body using REST API returns status code is Bad Request (400)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void startNewProcessWithInvalidVariablesInProcessBody2() throws JsonToModelConversionException, Exception { adminUser = dataUser.getAdminUser(); @@ -109,10 +109,10 @@ public class AddProcessCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) .assertLastError().containsSummary("Either processDefinitionId or processDefinitionKey is required"); } - + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify start new process with invalid request body using REST API returns status code is Bad Request (400)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void startNewProcessWithInvalidVariablesInProcessBody3() throws JsonToModelConversionException, Exception { adminUser = dataUser.getAdminUser(); diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessFullTests.java index 44ce78d45..fbe203654 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessFullTests.java @@ -36,7 +36,7 @@ public class AddProcessFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify network user cannot start new process with processDefinitionKey from another network using REST API and status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL, TestGroup.NETWORKS}) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS}) public void networkUserCannotStartNewProcessWithProcessDefinitionFromAnotherNetwork() throws JsonToModelConversionException, Exception { UserModel adminTenant1 = UserModel.getAdminTenantUser(); @@ -58,7 +58,7 @@ public class AddProcessFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify network user can start new process with processDefinitionKey from same network using REST API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL, TestGroup.NETWORKS}) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS}) public void networkUserCanStartNewProcessWithProcessDefinitionFromSameNetwork() throws JsonToModelConversionException, Exception { UserModel adminTenant1 = UserModel.getAdminTenantUser(); @@ -79,7 +79,7 @@ public class AddProcessFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot start new process with invalid processDefinitionKey using REST API and status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void userStartsNewProcessWithInvalidProcessDefinitionKey() throws JsonToModelConversionException, Exception { userWhoStartsProcess = dataUser.createRandomTestUser(); @@ -95,7 +95,7 @@ public class AddProcessFullTests extends RestTest @Bug(id = "REPO-1970") @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot start new process with invalid processDefinitionKey using REST API and status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void userStartsNewProcessWithEmptyVariablesBody() throws JsonToModelConversionException, Exception { userWhoStartsProcess = dataUser.createRandomTestUser(); @@ -113,7 +113,7 @@ public class AddProcessFullTests extends RestTest @Bug(id = "REPO-1970") @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot start new process with invalid processDefinitionKey using REST API and status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void userStartsNewProcessWithNoAssigneeInVariablesBody() throws JsonToModelConversionException, Exception { userWhoStartsProcess = dataUser.createRandomTestUser(); @@ -132,7 +132,7 @@ public class AddProcessFullTests extends RestTest @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot start new process with invalid assignee using REST API and status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void userStartsNewProcessWithInvalidAssignee() throws JsonToModelConversionException, Exception { userWhoStartsProcess = dataUser.createRandomTestUser(); @@ -149,7 +149,7 @@ public class AddProcessFullTests extends RestTest @Bug(id = "REPO-1970") @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot start new process with invalid sendEMailNotifications value using REST API and status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void userStartsNewProcessWithInvalidEmailNotification() throws JsonToModelConversionException, Exception { userWhoStartsProcess = dataUser.createRandomTestUser(); @@ -172,7 +172,7 @@ public class AddProcessFullTests extends RestTest @Bug(id = "REPO-1970") @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot start new process with invalid priority using REST API and status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void userStartsNewProcessWithInvalidPriority() throws JsonToModelConversionException, Exception { userWhoStartsProcess = dataUser.createRandomTestUser(); diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessSanityTests.java index 9990d4ad4..f84a3938b 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessSanityTests.java @@ -39,6 +39,7 @@ public class AddProcessSanityTests extends RestTest processes = restClient.withWorkflowAPI().getProcesses(); restClient.assertStatusCodeIs(HttpStatus.OK); processes.assertThat().entriesListContains("id", addedProcess.getId()); + } @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW, diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessCoreTests.java index 944c6a234..26253d2b1 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessCoreTests.java @@ -27,7 +27,7 @@ public class DeleteProcessCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify admin user is able to delete a process started by another user.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void deleteProcessByAdminUser() throws Exception { process = restClient.authenticateUser(userWhoAddsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); @@ -42,7 +42,7 @@ public class DeleteProcessCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify User is not able to delete process with invalid id") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void deleteProcessWithInvalidId() throws Exception { process = restClient.authenticateUser(userWhoAddsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); @@ -56,7 +56,7 @@ public class DeleteProcessCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify User is not able to delete process with empty id") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void deleteProcessWithEmptyId() throws Exception { process = restClient.authenticateUser(userWhoAddsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessFullTests.java index 3487bd5f8..e1c295f72 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessFullTests.java @@ -31,7 +31,7 @@ public class DeleteProcessFullTests extends RestTest @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify user is NOT able to delete process started by him twice using REST API and status code is NOT FOUND (404)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void deleteProcessByUserWhoStartedProcessTwice() throws Exception { process = restClient.authenticateUser(userWhoAddsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessCoreTests.java index 7dbfd4c1d..6bdec6537 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessCoreTests.java @@ -28,7 +28,7 @@ public class GetProcessCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify that using invalid process ID returns status code 404") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE}) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION}) public void invalidProcessIdTest() throws Exception { RestProcessModel newProcess = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.High); @@ -43,11 +43,11 @@ public class GetProcessCoreTests extends RestTest .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) .stackTraceIs(RestErrorModel.STACKTRACE); } - + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES}, executionType = ExecutionType.REGRESSION, description = "Verify that tenant user cannot get process from another network") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE, TestGroup.NETWORKS }) - @Bug(id = "MNT-17238") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) +// @Bug(id = "MNT-17238") public void tenantUserCannotGetProcessFromAnotherNetwork() throws Exception { UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); @@ -66,10 +66,10 @@ public class GetProcessCoreTests extends RestTest .assertLastError().containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } - + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify that tenant user can get process from the same network") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE, TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) public void tenantUserCanGetProcessFromTheSameNetwork() throws Exception { UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); @@ -86,8 +86,8 @@ public class GetProcessCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES}, executionType = ExecutionType.REGRESSION, description = "Verify that non network user cannot get process from a network") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE, TestGroup.NETWORKS }) - @Bug(id = "MNT-17238") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) +// @Bug(id = "MNT-17238") public void nonNetworkUserCannotAccessNetworkprocess() throws Exception { UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessFullTests.java index 2282fc002..7dd629602 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessFullTests.java @@ -28,10 +28,10 @@ public class GetProcessFullTests extends RestTest assignee = dataUser.createRandomTestUser(); addedProcess = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.High); } - + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify that admin user can get process started by a network user") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL, TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) public void adminUserCanGetProcessFromANetwork() throws Exception { UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); @@ -39,7 +39,7 @@ public class GetProcessFullTests extends RestTest UserModel tenantUser1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("utenant1"); RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser1).withWorkflowAPI().addProcess("activitiReview", adminTenantUser1, false, CMISUtil.Priority.High); - + restClient.authenticateUser(dataUser.getAdminUser()).withWorkflowAPI().usingProcess(networkProcess1).getProcess(); restClient.assertStatusCodeIs(HttpStatus.OK); networkProcess1.assertThat().field("processDefinitionId").contains(String.format("@%s%s", tenantUser1.getDomain().toLowerCase(), "@activitiReview:1")) @@ -53,7 +53,7 @@ public class GetProcessFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify user is able to get the process with properties parameter applied using REST API") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void getProcessWithPropertiesParameter() throws Exception { process = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingParams("properties=startUserId,id").usingProcess(addedProcess).getProcess(); @@ -63,14 +63,14 @@ public class GetProcessFullTests extends RestTest .and().field("id").is(addedProcess.getId()) .and().field("processDefinitionKey").isNull(); } - + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify user is able to get a process that was deleted, but it has 'deleted through REST API call' deleteReason") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void getDeletedProcess() throws Exception { addedProcess = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.High); - + process = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingProcess(addedProcess).getProcess(); restClient.assertStatusCodeIs(HttpStatus.OK); process.assertThat() @@ -84,7 +84,7 @@ public class GetProcessFullTests extends RestTest restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingProcess(addedProcess).deleteProcess(); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - + process = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingProcess(addedProcess).getProcess(); restClient.assertStatusCodeIs(HttpStatus.OK); process.assertThat() @@ -98,7 +98,7 @@ public class GetProcessFullTests extends RestTest .and().field("completed").is(true) .and().field("deleteReason").is("deleted through REST API call") .and().field("processDefinitionKey").is("activitiAdhoc"); - + restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().assertThat().entriesListDoesNotContain("id", process.getId()); } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesCoreTests.java index e8c78309e..628721598 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesCoreTests.java @@ -45,10 +45,10 @@ public class GetProcessesCoreTests extends RestTest task2 = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(adminUser); process3 = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createSingleReviewerTaskAndAssignTo(assignee); } - + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify admin gets all processes from same network") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE, TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) public void getProcessFromSameNetworkUsingAdmin() throws Exception { adminTenantUser = UserModel.getAdminTenantUser(); @@ -62,10 +62,10 @@ public class GetProcessesCoreTests extends RestTest tenantProcesses.assertThat().entriesListContains("id", process.getId()); } - + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets all processes started by him ordered descending by id") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void getProcessesOrderedByIdDESC() throws Exception { RestProcessModelsCollection processes = restClient.authenticateUser(userWhoStartsTask).withParams("orderBy=id DESC") @@ -77,10 +77,10 @@ public class GetProcessesCoreTests extends RestTest processesList.get(1).onModel().assertThat().field("id").is(task2.getProcessId()); processesList.get(2).onModel().assertThat().field("id").is(task1.getProcessId()); } - + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets processes that matches a where clause") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void getProcessesWithWhereClauseAsParameter() throws JsonToModelConversionException, Exception { RestProcessModelsCollection processes = restClient.authenticateUser(userWhoStartsTask).where("processDefinitionKey='activitiReview'") diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesFullTests.java index a69c672d0..afeb7fb51 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesFullTests.java @@ -46,10 +46,10 @@ public class GetProcessesFullTests extends RestTest task2 = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(adminUser); process3 = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createSingleReviewerTaskAndAssignTo(assignee); } - + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify any user cannot get processes from same network") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL, TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) public void getProcessFromSameNetworkUsingAnyUser() throws Exception { UserModel adminTenantUser = UserModel.getAdminTenantUser(); @@ -63,10 +63,10 @@ public class GetProcessesFullTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); tenantProcesses.assertThat().entriesListIsEmpty().and().paginationField("count").is("0"); } - + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets processes when skipCount parameter is applied") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void getProcessesWithSkipCountParameter() throws Exception { RestProcessModelsCollection processes = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getProcesses(); @@ -75,7 +75,7 @@ public class GetProcessesFullTests extends RestTest RestProcessModel process1 = processes.getEntries().get(0).onModel(); RestProcessModel process2 = processes.getEntries().get(1).onModel(); RestProcessModel process3 = processes.getEntries().get(2).onModel(); - + processes = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingParams("skipCount=2").getProcesses(); restClient.assertStatusCodeIs(HttpStatus.OK); processes.assertThat().paginationField("count").is("1"); @@ -84,10 +84,10 @@ public class GetProcessesFullTests extends RestTest processes.assertThat().entriesListDoesNotContain("id", process2.getId()); processes.getEntries().get(0).onModel().assertThat().field("id").is(process3.getId()); } - + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets processes when maxItems parameter is applied") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void getProcessesWithMaxItemsParameter() throws Exception { RestProcessModelsCollection processes = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getProcesses(); @@ -96,7 +96,7 @@ public class GetProcessesFullTests extends RestTest RestProcessModel process1 = processes.getEntries().get(0).onModel(); RestProcessModel process2 = processes.getEntries().get(1).onModel(); RestProcessModel process3 = processes.getEntries().get(2).onModel(); - + processes = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingParams("maxItems=2").getProcesses(); restClient.assertStatusCodeIs(HttpStatus.OK); processes.assertThat().paginationField("count").is("2"); @@ -105,10 +105,10 @@ public class GetProcessesFullTests extends RestTest processes.getEntries().get(0).onModel().assertThat().field("id").is(process1.getId()); processes.getEntries().get(1).onModel().assertThat().field("id").is(process2.getId()); } - + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets processes when properties parameter is applied") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void getProcessesWithPropertiesParameter() throws Exception { RestProcessModelsCollection processes = restClient.authenticateUser(userWhoStartsTask).withParams("properties=id") @@ -132,11 +132,11 @@ public class GetProcessesFullTests extends RestTest .and().entriesListContains("id", task2.getProcessId()) .and().entriesListContains("id", task1.getProcessId()); } - - @Bug(id = "REPO-1958") + +// @Bug(id = "REPO-1958") @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot get processes when using an invalid orderBy parameter") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void getProcessesWithInvalidOrderByParameter() throws Exception { restClient.authenticateUser(userWhoStartsTask).withParams("orderBy=test") @@ -147,10 +147,10 @@ public class GetProcessesFullTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE) .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); } - + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot get processes when using an invalid parameter in where clause") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void getProcessesWithInvalidWhereParameter() throws Exception { restClient.authenticateUser(userWhoStartsTask).where("startUserIdd='" + userWhoStartsTask.getUsername() + "'") @@ -161,10 +161,10 @@ public class GetProcessesFullTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE) .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); } - + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot get processes when using an invalid where clause expression") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void getProcessesWithInvalidWhereClauseExpression() throws Exception { restClient.authenticateUser(userWhoStartsTask).where("startUserId AND '" + userWhoStartsTask.getUsername() + "'") diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemCoreTests.java index 5a4f65317..03aee5064 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemCoreTests.java @@ -44,7 +44,7 @@ public class AddProcessItemCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add process item using by the user who started the process.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void addProcessItemByUserThatStartedTheProcess() throws Exception { processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); @@ -58,7 +58,7 @@ public class AddProcessItemCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add multiple process items using by the user who started the process.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void addMultipleProcessItemsByUserThatStartedTheProcess() throws Exception { processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); @@ -87,7 +87,7 @@ public class AddProcessItemCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add process item by a random user.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void addProcessItemByAnyUser() throws Exception { anotherUser = dataUser.createRandomTestUser(); @@ -118,7 +118,7 @@ public class AddProcessItemCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add process item using by the admin in same network.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE, TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) public void addProcessItemByAdminSameNetwork() throws Exception { adminTenantUser = UserModel.getAdminTenantUser(); @@ -139,7 +139,7 @@ public class AddProcessItemCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add multiple process items using by the admin in same network.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE, TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) public void addMultipleProcessItemsByAdminSameNetwork() throws Exception { adminTenantUser = UserModel.getAdminTenantUser(); @@ -176,7 +176,7 @@ public class AddProcessItemCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add process item using by admin in other network.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE, TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) public void addProcessItemByAdminInOtherNetwork() throws Exception { adminTenantUser = UserModel.getAdminTenantUser(); @@ -194,7 +194,7 @@ public class AddProcessItemCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add multiple process items using by admin in other network.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE, TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) public void addMultipleProcessItemsByAdminInOtherNetwork() throws Exception { adminTenantUser = UserModel.getAdminTenantUser(); @@ -215,7 +215,7 @@ public class AddProcessItemCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process item is falling in case of invalid process id is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void failedAddingProcessItemIfInvalidProcessIdIsProvided() throws Exception { RestProcessModelsCollection processes = restClient.authenticateUser(adminUser).withParams("maxItems=1").withWorkflowAPI().getProcesses(); @@ -230,7 +230,7 @@ public class AddProcessItemCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding multiple process items is falling in case of invalid process id is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void failedAddingMultipleProcessItemsIfInvalidProcessIdIsProvided() throws Exception { RestProcessModelsCollection processes = restClient.authenticateUser(adminUser).withParams("maxItems=1").withWorkflowAPI().getProcesses(); @@ -243,10 +243,10 @@ public class AddProcessItemCoreTests extends RestTest .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidProcessId")); } - @Bug(id = "ACE-5683") +// @Bug(id = "ACE-5683") @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process item is falling in case of invalid body item is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void failedAddingProcessItemIfInvalidItemBodyIsProvided() throws Exception { document.setNodeRef("invalidNodeRef"); @@ -256,7 +256,7 @@ public class AddProcessItemCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding multiple process items is falling in case of empty body item value is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void failedAddingMultipleProcessItemIfEmptyItemBodyIsProvided() throws Exception { processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); @@ -268,7 +268,7 @@ public class AddProcessItemCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process item is falling in case of incomplete body (empty) is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void failedAddingProcessItemIfIncompleteBodyIsProvided() throws Exception { processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemFullTests.java index c6142cab0..202fcf554 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemFullTests.java @@ -39,7 +39,7 @@ public class AddProcessItemFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding multiple process items is falling in case of empty process id is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void failedAddingMultipleProcessItemsIfEmptyProcessIdIsProvided() throws Exception { processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); @@ -53,7 +53,7 @@ public class AddProcessItemFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process items is falling in case of empty process id is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void failedAddingProcessItemsIfEmptyProcessIdIsProvided() throws Exception { processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); @@ -67,7 +67,7 @@ public class AddProcessItemFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process item is falling in case of empty body item value is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void failedAddingProcessItemIfEmptyItemBodyIsProvided() throws Exception { processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); @@ -78,7 +78,7 @@ public class AddProcessItemFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding multiple process items is falling in case of empty body item value is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void failedAddingMultipleProcessItemsIfEmptyItemBodyIsProvided() throws Exception { processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); @@ -90,7 +90,7 @@ public class AddProcessItemFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add a new process item, update the item and then delete.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void createDeleteCreateMultipleProcessItems() throws Exception { processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); @@ -110,7 +110,7 @@ public class AddProcessItemFullTests extends RestTest @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add a new process item, delete the item and create it again.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void createDeleteCreateProcessItem() throws Exception { processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemSanityTests.java index 51fcf800d..6b43a81c6 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemSanityTests.java @@ -104,7 +104,7 @@ public class AddProcessItemSanityTests extends RestTest .assertThat().entriesListContains("id", processItems.getEntries().get(1).onModel().getId()); } - @Bug(id= "MNT-16966") +// @Bug(id= "MNT-16966") @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Add process item that already exists") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY}) @@ -131,7 +131,7 @@ public class AddProcessItemSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); } - @Bug(id= "MNT-16966") +// @Bug(id= "MNT-16966") @TestRail(section = {TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Add process item that already exists") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY}) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/items/DeleteProcessItemCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/items/DeleteProcessItemCoreTests.java index 167984a4a..ca7a5a308 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/items/DeleteProcessItemCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/items/DeleteProcessItemCoreTests.java @@ -39,7 +39,7 @@ public class DeleteProcessItemCoreTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Delete process item with invalid id") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void deleteProcessItemWithInvalidItemId() throws Exception { restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() @@ -54,7 +54,7 @@ public class DeleteProcessItemCoreTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Delete process item with empty id") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void deleteProcessItemWithEmptyItemId() throws Exception { restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() @@ -69,7 +69,7 @@ public class DeleteProcessItemCoreTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Delete process item twice") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void deleteProcessItemTwice() throws Exception { restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/items/DeleteProcessItemFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/items/DeleteProcessItemFullTests.java index f67e9e9a2..a21099ff7 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/items/DeleteProcessItemFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/items/DeleteProcessItemFullTests.java @@ -40,7 +40,7 @@ public class DeleteProcessItemFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Try to delete existing process item using empty processId") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void deleteProcessItemUsingEmptyProcessId() throws Exception { processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI() @@ -61,7 +61,7 @@ public class DeleteProcessItemFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add a new process item, update the item and then delete.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void createUpdateDeleteProcessItem() throws Exception { processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI() @@ -81,7 +81,7 @@ public class DeleteProcessItemFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Delete process item using any user.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void deleteProcessItemByAnyUser() throws Exception { anotherUser = dataUser.createRandomTestUser(); @@ -102,7 +102,7 @@ public class DeleteProcessItemFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Delete process item with admin.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void deleteProcessItemWithAdmin() throws Exception { processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI() @@ -121,7 +121,7 @@ public class DeleteProcessItemFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Delete process item by the user who is involved in the process.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void deleteProcessItemByUserInvolvedInTheProcess() throws Exception { processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI() @@ -139,7 +139,7 @@ public class DeleteProcessItemFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Delete process item by the user who started the process.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void deleteProcessItemByUserThatStartedTheProcess() throws Exception { processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI() @@ -156,7 +156,7 @@ public class DeleteProcessItemFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Delete process item for a deleted process.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void deleteProcessItemsForDeletedProcess() throws Exception { processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI() @@ -178,7 +178,7 @@ public class DeleteProcessItemFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Delete process item by inexistent user.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void deleteProcessItemByInexistentUser() throws Exception { processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI() @@ -199,7 +199,7 @@ public class DeleteProcessItemFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Delete process item for process without items.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL}, + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION}, expectedExceptions = EmptyRestModelCollectionException.class) public void deleteProcessItemsForProcessWithoutItems() throws Exception { @@ -216,7 +216,7 @@ public class DeleteProcessItemFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Delete process item using by the admin in same network.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL, TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) public void deleteProcessItemByAdminSameNetwork() throws Exception { adminTenantUser = UserModel.getAdminTenantUser(); @@ -239,7 +239,7 @@ public class DeleteProcessItemFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Delete process item using by admin in other network.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE, TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) public void deleteProcessItemByAdminInOtherNetwork() throws Exception { adminTenantUser = UserModel.getAdminTenantUser(); diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/items/GetProcessItemsCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/items/GetProcessItemsCoreTests.java index b0bce742c..918af8111 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/items/GetProcessItemsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/items/GetProcessItemsCoreTests.java @@ -34,7 +34,7 @@ public class GetProcessItemsCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify that admin calling getProcessItems can see anything with REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void getProcessItemsAsAdminReturnsAnything() throws Exception { processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); @@ -46,7 +46,7 @@ public class GetProcessItemsCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify getProcessItems for invalid processId with REST API and status code is NOT_FOUND (404)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void getProcessItemsForInvalidProcessId() throws Exception { processModel = restClient.authenticateUser(assignee).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); @@ -58,7 +58,7 @@ public class GetProcessItemsCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify getProcessItems for empty processId with REST API and status code is NOT_FOUND (404)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void getProcessItemsForEmptyProcessId() throws Exception { processModel = restClient.authenticateUser(assignee).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/items/GetProcessItemsFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/items/GetProcessItemsFullTests.java index e4f4db5a9..0305970be 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/items/GetProcessItemsFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/items/GetProcessItemsFullTests.java @@ -40,7 +40,7 @@ public class GetProcessItemsFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Get process items using admin from different network") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL, TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) public void getProcessItemsUsingAdminUserFromDifferentNetwork() throws Exception { adminTenantUser = UserModel.getAdminTenantUser(); @@ -64,7 +64,7 @@ public class GetProcessItemsFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Get process items using admin from different network") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL, TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) public void getProcessItemsReturnsOnlyItemsInsideNetwork() throws Exception { adminTenantUser = UserModel.getAdminTenantUser(); @@ -94,7 +94,7 @@ public class GetProcessItemsFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Get process items for process without items") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL}) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION}) public void getProcessItemsForProcessWithoutItems() throws Exception { processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.Normal); @@ -103,10 +103,10 @@ public class GetProcessItemsFullTests extends RestTest items.assertThat().entriesListIsEmpty(); } - @Bug(id = "MNT-17438") +// @Bug(id = "MNT-17438") @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Get process items for process with valid skipCount parameter") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL}) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION}) public void getProcessItemsWithValidSkipCount() throws Exception { processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.Normal); @@ -128,7 +128,7 @@ public class GetProcessItemsFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Get process items for process with negative skipCount") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL}) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION}) public void getProcessItemsWithNegativeSkipCount() throws Exception { processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.Normal); @@ -143,7 +143,7 @@ public class GetProcessItemsFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Get process items for process with non numeric skipCount") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL}) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION}) public void getProcessItemsWithNonNumericSkipCount() throws Exception { processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.Normal); @@ -155,7 +155,7 @@ public class GetProcessItemsFullTests extends RestTest @Bug(id = "MNT-17438") @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Get process items for process with valid maxItems parameter") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL}) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION}) public void getProcessItemsWithValidMaxItems() throws Exception { processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.Normal); @@ -177,7 +177,7 @@ public class GetProcessItemsFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Get process items for process with negative maxItems") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL}) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION}) public void getProcessItemsWithNegativeMaxItems() throws Exception { processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.Normal); @@ -192,7 +192,7 @@ public class GetProcessItemsFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Get process items for process with non numeric maxItems") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL}) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION}) public void getProcessItemsWithNonNumericMaxItems() throws Exception { processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.Normal); @@ -203,7 +203,7 @@ public class GetProcessItemsFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify get all process items with properties parameter.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void getProcessItemsWithPropertiesParameter() throws Exception { processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.Normal); @@ -224,10 +224,9 @@ public class GetProcessItemsFullTests extends RestTest .assertThat().fieldsCount().is(4); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify get all process items after process is deleted.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void getProcessItemsAfterDeletingProcess() throws Exception { processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.Normal); diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/tasks/GetProcessTasksCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/tasks/GetProcessTasksCoreTests.java index 482dd0db7..6d779373e 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/tasks/GetProcessTasksCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/tasks/GetProcessTasksCoreTests.java @@ -45,7 +45,7 @@ public class GetProcessTasksCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "getProcessTasks with user that is candidate with REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void getProcessTasksWithUserThatIsCandidate() throws Exception { ProcessModel processModel = dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document1) @@ -59,7 +59,7 @@ public class GetProcessTasksCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify getProcessTasks using admin from same network with REST API and status code is OK") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE, TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) public void getProcessTasksWithAdminFromSameNetwork() throws Exception { UserModel adminTenant = UserModel.getAdminTenantUser(); @@ -77,7 +77,7 @@ public class GetProcessTasksCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify getProcessTasks using admin from different network with REST API and status code is FORBIDDEN (403)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE, TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) public void getProcessTasksWithAdminFromDifferentNetwork() throws Exception { UserModel adminTenant, secondAdminTenant, tenantAssignee; @@ -99,7 +99,7 @@ public class GetProcessTasksCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "getProcessTasks for invalid processId with REST API and status code is NOT_FOUND (404)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void getProcessTasksUsingInvalidProcessId() throws Exception { ProcessModel processModel = process; @@ -112,7 +112,7 @@ public class GetProcessTasksCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "getProcessTasks for empty processId with REST API and status code is NOT_FOUND (404)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void getProcessTasksUsingEmptyProcessId() throws Exception { ProcessModel processModel = process; @@ -125,7 +125,7 @@ public class GetProcessTasksCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "User completes task then getProcessTasks with REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void completeTaskThenGetProcessTasks() throws Exception { ProcessModel processModel = dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document2) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/tasks/GetProcessTasksFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/tasks/GetProcessTasksFullTests.java index 11f820f71..5c7a98d65 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/tasks/GetProcessTasksFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/tasks/GetProcessTasksFullTests.java @@ -40,7 +40,7 @@ public class GetProcessTasksFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify admin user is able to getProcessTasks even if he wasn't involved in process. Check status code is OK") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void getProcessTasksWithAdmin() throws Exception { processTasks = restClient.authenticateUser(adminUser).withWorkflowAPI() @@ -52,7 +52,7 @@ public class GetProcessTasksFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Get process tasks with valid skipCount parameter applied") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL}) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION}) public void getProcessTasksWithValidSkipCount() throws Exception { processTasks = restClient.authenticateUser(userWhoStartsProcess) @@ -68,7 +68,7 @@ public class GetProcessTasksFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Get process tasks with negative skipCount parameter applied") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL}) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION}) public void getProcessTasksWithNegativeSkipCount() throws Exception { restClient.authenticateUser(userWhoStartsProcess) @@ -84,7 +84,7 @@ public class GetProcessTasksFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Get process tasks with non numeric skipCount parameter applied") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL}) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION}) public void getProcessTasksWithNonNumericSkipCount() throws Exception { restClient.authenticateUser(userWhoStartsProcess) @@ -96,7 +96,7 @@ public class GetProcessTasksFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Get process tasks with valid maxItems parameter applied") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL}) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION}) public void getProcessTasksWithValidMaxItems() throws Exception { processTasks = restClient.authenticateUser(userWhoStartsProcess) @@ -112,7 +112,7 @@ public class GetProcessTasksFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Get process tasks with negative maxItems parameter applied") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL}) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION}) public void getProcessTasksWithNegativeMaxItems() throws Exception { restClient.authenticateUser(userWhoStartsProcess) @@ -128,7 +128,7 @@ public class GetProcessTasksFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Get process tasks with non numeric maxItems parameter applied") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL}) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION}) public void getProcessTasksWithNonNumericMaxItems() throws Exception { restClient.authenticateUser(userWhoStartsProcess) @@ -140,7 +140,7 @@ public class GetProcessTasksFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify getProcessTasks with properties parameter") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void getProcessTasksWithPropertiesParameter() throws Exception { processTasks = restClient.authenticateUser(adminUser) @@ -165,7 +165,7 @@ public class GetProcessTasksFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify admin gets Process Tasks ordered by assignee ascendant using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void getProcessTasksOrderedByAssignee() throws Exception { processTasks = restClient.authenticateUser(adminUser) @@ -177,7 +177,7 @@ public class GetProcessTasksFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify admin doesn't get Process Tasks ordered by many fields") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void getProcessTasksOrderedByMultipleFields() throws Exception { restClient.authenticateUser(adminUser) @@ -189,7 +189,7 @@ public class GetProcessTasksFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify get all process tasks after process is deleted.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void getProcessTasksAfterDeletingProcess() throws Exception { ProcessModel processModel = dataWorkflow.usingUser(userWhoStartsProcess).usingSite(publicSite).usingResource(document) @@ -204,5 +204,4 @@ public class GetProcessTasksFullTests extends RestTest processTasks.assertThat().entriesListIsEmpty(); } - } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariableCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariableCoreTests.java index e22fb34f3..7113b8907 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariableCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariableCoreTests.java @@ -11,7 +11,6 @@ import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpMethod; @@ -41,7 +40,7 @@ public class AddProcessVariableCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add process variable using by the user who started the process.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void addProcessVariableByUserThatStartedTheProcess() throws Exception { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); @@ -56,7 +55,7 @@ public class AddProcessVariableCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add process variable using by a random user.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void addProcessVariableByAnyUser() throws Exception { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); @@ -68,10 +67,10 @@ public class AddProcessVariableCoreTests extends RestTest .and().field("type").is(variableModel.getType()) .and().field("value").is(variableModel.getValue()); } - + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process variable is falling in case invalid type is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void failedAddingProcessVariableIfInvalidTypeIsProvided() throws Exception { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:textarea"); @@ -87,10 +86,10 @@ public class AddProcessVariableCoreTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE); } - @Bug(id = "REPO-1938") +// @Bug(id = "REPO-1938") @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process variable is falling in case invalid type prefix is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void failedAddingProcessVariableIfInvalidTypePrefixIsProvided() throws Exception { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("ddt:text"); @@ -108,7 +107,7 @@ public class AddProcessVariableCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process variable is falling in case invalid value is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void failedAddingProcessVariableIfInvalidValueIsProvided() throws Exception { RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:int"); @@ -127,7 +126,7 @@ public class AddProcessVariableCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process variable is falling in case missing required variable body (name) is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void failedAddingProcessVariableIfMissingRequiredVariableNameBodyIsProvided() throws Exception { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); @@ -147,7 +146,7 @@ public class AddProcessVariableCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process variable is falling in case invalid variableBody (adding extra parameter in body) is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void failedAddingProcessVariableIfInvalidBodyIsProvided() throws Exception { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); @@ -167,7 +166,7 @@ public class AddProcessVariableCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process variable is falling in case empty name is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void failedAddingProcessVariableIfEmptyNameIsProvided() throws Exception { processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); @@ -184,10 +183,10 @@ public class AddProcessVariableCoreTests extends RestTest .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) .stackTraceIs(RestErrorModel.STACKTRACE); } - + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add process variable using by admin in other network.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE, TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) public void addProcessVariableByAdminInOtherNetwork() throws Exception { adminTenantUser = UserModel.getAdminTenantUser(); diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariableFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariableFullTests.java index 2685475e9..b9962d9e1 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariableFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariableFullTests.java @@ -35,10 +35,10 @@ public class AddProcessVariableFullTests extends RestTest document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); } - + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify addProcessVariable by any user for invalid processID with REST API and status code is NOT_FOUND (404)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void addProcessVariableWithInvalidProcessId() throws Exception { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); @@ -53,7 +53,7 @@ public class AddProcessVariableFullTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify addProcessVariable by any user for empty processID with REST API and status code is NOT_FOUND (404)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void addProcessVariableWithEmptyProcessId() throws Exception { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); @@ -65,10 +65,10 @@ public class AddProcessVariableFullTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); } - + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process variable is falling in case of empty value is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void failedAddingProcessVariableIfEmptyValueIsProvided() throws Exception { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:int"); @@ -84,10 +84,10 @@ public class AddProcessVariableFullTests extends RestTest .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) .stackTraceIs(RestErrorModel.STACKTRACE); } - + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process variable in case of having only 'name' field is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void addingProcessVariableWithOnlyNameProvided() throws Exception { processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); @@ -100,10 +100,10 @@ public class AddProcessVariableFullTests extends RestTest .and().field("type").is("d:any") .and().field("value").isNull(); } - + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process variable in case of missing type field is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void addingProcessVariableIfMissingValueIsProvided() throws Exception { processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); @@ -116,10 +116,10 @@ public class AddProcessVariableFullTests extends RestTest .and().field("type").is("d:text") .and().field("value").isNull(); } - + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process variable in case of missing type field is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void addingProcessVariableIfMissingTypeIsProvided() throws Exception { processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); @@ -132,10 +132,10 @@ public class AddProcessVariableFullTests extends RestTest .and().field("type").is("d:text") .and().field("value").is("variableValue"); } - + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process variable is case of empty type value is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void addingProcessVariableIfEmptyTypeIsProvided() throws Exception { variableModel = RestProcessVariableModel.getRandomProcessVariableModel(""); @@ -148,10 +148,10 @@ public class AddProcessVariableFullTests extends RestTest .and().field("type").is("d:text") .and().field("value").is(variableModel.getValue()); } - + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process variable in case of empty body field is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void addingProcessVariableWithEmptyBodyProvided() throws Exception { variableModel = RestProcessVariableModel.getRandomProcessVariableModel(""); @@ -168,10 +168,10 @@ public class AddProcessVariableFullTests extends RestTest .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) .stackTraceIs(RestErrorModel.STACKTRACE); } - + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Update twice in a row the same variable.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void updateTwiceInARowSameProcessVariable() throws Exception { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesCoreTests.java index fc34db68d..bfbd047df 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesCoreTests.java @@ -35,55 +35,9 @@ public class AddProcessVariablesCoreTests extends RestTest dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); } - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify addProcessVariable by any user with REST API and status code is CREATED (201)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) - public void addProcessVariableByAnyUser() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - - processVariable = restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(processModel) - .addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - processVariable.assertThat().field("name").is(variableModel.getName()) - .and().field("type").is(variableModel.getType()) - .and().field("value").is(variableModel.getValue()); - - restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() - .assertThat().entriesListContains("name", variableModel.getName()); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify multiple addProcessVariable by any user with REST API and status code is CREATED (201)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) - public void addMultipleProcessVariableByAnyUser() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - variableModel1 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - - processVariableCollection = restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(processModel) - .addProcessVariables(variableModel, variableModel1); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - processVariableCollection.getEntries().get(0).onModel() - .assertThat().field("name").is(variableModel.getName()) - .and().field("type").is(variableModel.getType()) - .and().field("value").is(variableModel.getValue()); - processVariableCollection.getEntries().get(1).onModel() - .assertThat().field("name").is(variableModel1.getName()) - .and().field("type").is(variableModel1.getType()) - .and().field("value").is(variableModel1.getValue()); - - restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() - .assertThat().entriesListContains("name",variableModel.getName()) - .assertThat().entriesListContains("name",variableModel1.getName()); - } - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify addProcessVariable by any user for invalid processID with REST API and status code is NOT_FOUND (404)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void addProcessVariableForInvalidProcessIdIsNotFound() throws Exception { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); @@ -98,7 +52,7 @@ public class AddProcessVariablesCoreTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify addProcessVariable by any user for empty processID with REST API and status code is NOT_FOUND (404)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void addProcessVariableForEmptyProcessIdIsEmpty() throws Exception { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); @@ -110,56 +64,10 @@ public class AddProcessVariablesCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Add process variables using by the user who started the process.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) - public void addProcessVariableByUserThatStartedTheProcess() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - processVariable = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingProcess(processModel) - .addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - processVariable.assertThat().field("name").is(variableModel.getName()) - .and().field("type").is(variableModel.getType()) - .and().field("value").is(variableModel.getValue()); - - restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() - .assertThat().entriesListContains("name", variableModel.getName()); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Add multiple process variables using by the user who started the process.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) - public void addMultipleProcessVariableByUserThatStartedTheProcess() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - variableModel1 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - - processVariableCollection = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingProcess(processModel) - .addProcessVariables(variableModel, variableModel1); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - processVariableCollection.getEntries().get(0).onModel() - .assertThat().field("name").is(variableModel.getName()) - .and().field("type").is(variableModel.getType()) - .and().field("value").is(variableModel.getValue()); - - processVariableCollection.getEntries().get(1).onModel() - .assertThat().field("name").is(variableModel1.getName()) - .and().field("type").is(variableModel1.getType()) - .and().field("value").is(variableModel1.getValue()); - - restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() - .assertThat().entriesListContains("name", variableModel.getName()) - .assertThat().entriesListContains("name", variableModel1.getName()); - } - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding multiple process variables is falling in case invalid process id is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void addMultipleProcessVariablesInvalidProcessId() throws Exception { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:int"); @@ -177,7 +85,7 @@ public class AddProcessVariablesCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding multiple process variables is falling in case empty process id is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void addMultipleProcessVariablesEmptyProcessId() throws Exception { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:int"); diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesFullTests.java index 30056bb6f..aba6b88f5 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesFullTests.java @@ -41,17 +41,17 @@ public class AddProcessVariablesFullTests extends RestTest document = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); processModel = dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document).createSingleReviewerTaskAndAssignTo(assignee); } - + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add process variables using by the user involved in the process.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void addProcessVariableByUserInvolvedTheProcess() throws Exception { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); restProcessModel = restClient.authenticateUser(assignee).withWorkflowAPI().getProcesses() .getProcessModelByProcessDefId(processModel.getId()); - processVariable = restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(restProcessModel) + processVariable = restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(restProcessModel) .addProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); processVariable.assertThat().field("name").is(variableModel.getName()) @@ -59,23 +59,23 @@ public class AddProcessVariablesFullTests extends RestTest .and().field("value").is(variableModel.getValue()); restClient.withWorkflowAPI().usingProcess(restProcessModel).getProcessVariables() - .assertThat().entriesListContains("name", variableModel.getName()); + .assertThat().entriesListContains("name", variableModel.getName()); } - + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add process variables using by the user involved in the process.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void addMultipleProcessVariableByUserInvolvedTheProcess() throws Exception { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); variableModel1 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); restProcessModel = restClient.authenticateUser(assignee).withWorkflowAPI().getProcesses() .getProcessModelByProcessDefId(processModel.getId()); - + processVariableCollection = restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(restProcessModel) .addProcessVariables(variableModel, variableModel1); restClient.assertStatusCodeIs(HttpStatus.CREATED); - + processVariableCollection.getEntries().get(0).onModel() .assertThat().field("name").is(variableModel.getName()) .and().field("type").is(variableModel.getType()) @@ -88,42 +88,42 @@ public class AddProcessVariablesFullTests extends RestTest restClient.withWorkflowAPI().usingProcess(restProcessModel).getProcessVariables() .assertThat().entriesListContains("name", variableModel.getName()) - .assertThat().entriesListContains("name", variableModel1.getName()); + .assertThat().entriesListContains("name", variableModel1.getName()); } - + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add process variables using by inexistent user.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void addProcessVariableByInexistentUser() throws Exception { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); restProcessModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses() .getProcessModelByProcessDefId(processModel.getId()); - + processVariable = restClient.authenticateUser(UserModel.getRandomUserModel()).withWorkflowAPI() - .usingProcess(restProcessModel) - .addProcessVariable(variableModel); + .usingProcess(restProcessModel) + .addProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) .assertLastError() .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) .stackTraceIs(RestErrorModel.STACKTRACE); - } - + } + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add multiple process variables using by inexistent user.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void addMultipleProcessVariableByInexistentUser() throws Exception { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - variableModel1 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + variableModel1 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); restProcessModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses() .getProcessModelByProcessDefId(processModel.getId()); processVariableCollection = restClient.authenticateUser(UserModel.getRandomUserModel()).withWorkflowAPI() - .usingProcess(restProcessModel) - .addProcessVariables(variableModel,variableModel1); + .usingProcess(restProcessModel) + .addProcessVariables(variableModel,variableModel1); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) .assertLastError() .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) @@ -131,16 +131,16 @@ public class AddProcessVariablesFullTests extends RestTest .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) .stackTraceIs(RestErrorModel.STACKTRACE); } - + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process variables is falling in case invalid type is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void failedAddingProcessVariableIfInvalidTypeIsProvided() throws Exception { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:textarea"); restProcessModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses() .getProcessModelByProcessDefId(processModel.getId()); - + restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) .assertLastError().containsSummary( @@ -150,16 +150,16 @@ public class AddProcessVariablesFullTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE); } - @Bug(id = "REPO-1938") +// @Bug(id = "REPO-1938") @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process variables is falling in case invalid type prefix is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void failedAddingProcessVariableIfInvalidTypePrefixIsProvided() throws Exception { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("ddt:text"); restProcessModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses() .getProcessModelByProcessDefId(processModel.getId()); - + restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) .assertLastError() @@ -168,17 +168,17 @@ public class AddProcessVariablesFullTests extends RestTest .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) .stackTraceIs(RestErrorModel.STACKTRACE); } - + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process variables is falling in case invalid value is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void failedAddingProcessVariableIfInvalidValueIsProvided() throws Exception { RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:int"); variableModel.setValue("invalidValue"); restProcessModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses() - .getProcessModelByProcessDefId(processModel.getId()); - + .getProcessModelByProcessDefId(processModel.getId()); + restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) .assertLastError() @@ -190,12 +190,12 @@ public class AddProcessVariablesFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process variables is falling in case invalid variableBody (adding extra parameter in body:scope) is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void failedAddingProcessVariableIfInvalidBodyIsProvided() throws Exception { restProcessModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses() - .getProcessModelByProcessDefId(processModel.getId()); - + .getProcessModelByProcessDefId(processModel.getId()); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{\"name\": \"variableName\",\"scope\": \"local\",\"value\": \"testing\",\"type\": \"d:text\"}", "processes/{processId}/variables", processModel.getId()); restClient.processModel(RestProcessVariableModel.class, request); @@ -206,19 +206,19 @@ public class AddProcessVariablesFullTests extends RestTest .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) .stackTraceIs(RestErrorModel.STACKTRACE); } - + //@Bug(id="REPO-1985") @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process variables is falling in case empty name is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void failedAddingProcessVariableIfEmptyNameIsProvided() throws Exception - { + { processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); restProcessModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses() - .getProcessModelByProcessDefId(processModel.getId()); + .getProcessModelByProcessDefId(processModel.getId()); RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - variableModel.setName(""); - + variableModel.setName(""); + restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) .assertLastError() @@ -227,41 +227,41 @@ public class AddProcessVariablesFullTests extends RestTest .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) .stackTraceIs(RestErrorModel.STACKTRACE); } - + //@Bug(id="REPO-1985") @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process variables is falling in case invalid name is provided: ony white spaces") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void failedAddingProcessVariableUsingOnlyWhiteSpaceInName() throws Exception { processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); restProcessModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses() - .getProcessModelByProcessDefId(processModel.getId()); + .getProcessModelByProcessDefId(processModel.getId()); variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); variableModel.setName(" "); - processVariable = restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); + processVariable = restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); processVariable.assertThat().field("name").isNull() .and().field("type").is(variableModel.getType()) .and().field("value").is(variableModel.getValue()); restClient.withWorkflowAPI().usingProcess(restProcessModel).getProcessVariables() - .assertThat().entriesListContains("value", variableModel.getValue()); + .assertThat().entriesListContains("value", variableModel.getValue()); } - - @Bug(id="REPO-1987") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + +// @Bug(id="REPO-1987") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process variables is falling in case invalid name is provided: symbols") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void failedAddingProcessVariableWithSymbolsInName() throws Exception { restProcessModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses() - .getProcessModelByProcessDefId(processModel.getId()); + .getProcessModelByProcessDefId(processModel.getId()); variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); variableModel.setName("123_%^&: õÈ,Ì,Ò"); - - processVariable = restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); + + processVariable = restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); processVariable.assertThat().field("name").is(variableModel.getName()) .and().field("type").is(variableModel.getType()) @@ -269,27 +269,27 @@ public class AddProcessVariablesFullTests extends RestTest restClient.withWorkflowAPI().usingProcess(restProcessModel).getProcessVariables() .assertThat().entriesListContains("name", variableModel.getName()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add two process variables using by the user involved in the process.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void addingMultipleValidProcessVariables() throws Exception - { + { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); variableModel2 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); variableModel3 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); restProcessModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses() - .getProcessModelByProcessDefId(processModel.getId()); + .getProcessModelByProcessDefId(processModel.getId()); - processVariableCollection = restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(restProcessModel) - .addProcessVariables(variableModel, variableModel2, variableModel3); + processVariableCollection = restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(restProcessModel) + .addProcessVariables(variableModel, variableModel2, variableModel3); restClient.assertStatusCodeIs(HttpStatus.CREATED); - + processVariableCollection.assertThat().entriesListContains("name", variableModel.getName()) .assertThat().entriesListContains("name", variableModel2.getName()) .assertThat().entriesListContains("name", variableModel3.getName()); - + processVariableCollection.getEntries().get(0).onModel().assertThat() .field("name").is(variableModel.getName()).and() .field("value").is(variableModel.getValue()).and() @@ -303,54 +303,54 @@ public class AddProcessVariablesFullTests extends RestTest .field("value").is(variableModel3.getValue()).and() .field("type").is(variableModel3.getType()); } - + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add two process variables using by the user involved in the process.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void failedAddingMultipleProcessVariablesInvalidType() throws Exception - { + { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); variableModel.setType("d:string"); variableModel2 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); restProcessModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses() - .getProcessModelByProcessDefId(processModel.getId()); + .getProcessModelByProcessDefId(processModel.getId()); + + processVariableCollection = restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(restProcessModel) + .addProcessVariables(variableModel, variableModel2); - processVariableCollection = restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(restProcessModel) - .addProcessVariables(variableModel, variableModel2); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) .assertLastError().containsSummary(String.format(RestErrorModel.UNSUPPORTED_TYPE, "d:string")) .containsErrorKey(String.format(RestErrorModel.UNSUPPORTED_TYPE, "d:string")) .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); + .stackTraceIs(RestErrorModel.STACKTRACE); } - + @Bug(id = "REPO-1938") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add two process variables using by the user involved in the process.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void failledAddingMultipleProcessVariablesInvalidTypePrefix() throws Exception - { + { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); variableModel.setType("e:text"); variableModel2 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); restProcessModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses() - .getProcessModelByProcessDefId(processModel.getId()); + .getProcessModelByProcessDefId(processModel.getId()); + + processVariableCollection = restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(restProcessModel) + .addProcessVariables(variableModel, variableModel2); - processVariableCollection = restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(restProcessModel) - .addProcessVariables(variableModel, variableModel2); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) .assertLastError() .containsSummary(String.format(RestErrorModel.INVALID_NAMEPACE_PREFIX, "e")) .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); + .stackTraceIs(RestErrorModel.STACKTRACE); } - + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process variables is falling in case invalid value is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void failledAddingMultipleProcessVariablesInvalidValue() throws Exception { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:int"); @@ -358,9 +358,9 @@ public class AddProcessVariablesFullTests extends RestTest variableModel1 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); variableModel2 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); restProcessModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses() - .getProcessModelByProcessDefId(processModel.getId()); - - processVariableCollection = restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(restProcessModel) + .getProcessModelByProcessDefId(processModel.getId()); + + processVariableCollection = restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(restProcessModel) .addProcessVariables(variableModel, variableModel1, variableModel2); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) .assertLastError() @@ -369,10 +369,10 @@ public class AddProcessVariablesFullTests extends RestTest .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) .stackTraceIs(RestErrorModel.STACKTRACE); } - + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process variables is falling in case invalid value is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void failledAddingMultipleInvalidProcessVariables() throws Exception { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:int"); @@ -380,9 +380,9 @@ public class AddProcessVariablesFullTests extends RestTest variableModel1 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); variableModel1.setType(""); restProcessModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses() - .getProcessModelByProcessDefId(processModel.getId()); - - processVariableCollection = restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(restProcessModel) + .getProcessModelByProcessDefId(processModel.getId()); + + processVariableCollection = restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(restProcessModel) .addProcessVariables(variableModel1, variableModel); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) .assertLastError() @@ -391,29 +391,29 @@ public class AddProcessVariablesFullTests extends RestTest .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) .stackTraceIs(RestErrorModel.STACKTRACE); } - + @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES}, executionType = ExecutionType.REGRESSION, description = "Add process variables using by Admin in other network.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL, TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) public void addProcessVariablesByAdminInOtherNetwork() throws Exception { adminTenantUser = UserModel.getAdminTenantUser(); restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser); tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - + adminTenantUser2 = UserModel.getAdminTenantUser(); restClient.usingTenant().createTenant(adminTenantUser2); siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); dataWorkflow.usingUser(tenantUser).usingSite(siteModel).usingResource(document) .createNewTaskAndAssignTo(tenantUserAssignee); - + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); processModel = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee, false, Priority.Normal); - processVariable = restClient.authenticateUser(adminTenantUser2).withWorkflowAPI().usingProcess(processModel) + processVariable = restClient.authenticateUser(adminTenantUser2).withWorkflowAPI().usingProcess(processModel) .addProcessVariable(variableModel); - + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) .assertLastError() .containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT) @@ -421,30 +421,30 @@ public class AddProcessVariablesFullTests extends RestTest .containsErrorKey(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT) .stackTraceIs(RestErrorModel.STACKTRACE); } - + @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW,TestGroup.PROCESSES}, executionType = ExecutionType.REGRESSION, description = "Add multiple process variables using by Admin in other network.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL, TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) public void addMultipleProcessVariablesByAdminInOtherNetwork() throws Exception - { + { adminTenantUser = UserModel.getAdminTenantUser(); restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser); tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - + adminTenantUser2 = UserModel.getAdminTenantUser(); restClient.usingTenant().createTenant(adminTenantUser2); - + siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); dataWorkflow.usingUser(tenantUser).usingSite(siteModel).usingResource(document) .createNewTaskAndAssignTo(tenantUserAssignee); - + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); variableModel1 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); processModel = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee, false, Priority.Normal); - restClient.authenticateUser(adminTenantUser2).withWorkflowAPI().usingProcess(processModel) + restClient.authenticateUser(adminTenantUser2).withWorkflowAPI().usingProcess(processModel) .addProcessVariables(variableModel, variableModel1); - + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) .assertLastError() .containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/DeleteProcessVariableCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/DeleteProcessVariableCoreTests.java index 172988a65..031f749b4 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/DeleteProcessVariableCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/DeleteProcessVariableCoreTests.java @@ -45,7 +45,7 @@ public class DeleteProcessVariableCoreTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Delete invalid process variable") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void deleteInvalidProcessVariable() throws Exception { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("x:InvalidVar"); @@ -57,11 +57,11 @@ public class DeleteProcessVariableCoreTests extends RestTest .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) .stackTraceIs(RestErrorModel.STACKTRACE); - } - + } + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Delete process variable twice") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void deleteProcessVariableTwice() throws Exception { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); @@ -75,10 +75,10 @@ public class DeleteProcessVariableCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, variableModel.getName())); } - + @TestRail(section = {TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Remove process variables with empty processId") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void deleteProcessVariableEmptyProcessId() throws JsonToModelConversionException, Exception { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); @@ -89,17 +89,17 @@ public class DeleteProcessVariableCoreTests extends RestTest restProcessModel.setId(""); restClient.withWorkflowAPI().usingProcess(restProcessModel).deleteProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) .assertLastError() .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")) .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) .stackTraceIs(RestErrorModel.STACKTRACE); - } + } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Delete process variable with admin.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void deleteProcessVariableWithAdmin() throws Exception { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); @@ -107,12 +107,12 @@ public class DeleteProcessVariableCoreTests extends RestTest .getProcesses().getProcessModelByProcessDefId(processModel.getId()); restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); - + restClient.authenticateUser(adminUser).withWorkflowAPI().usingProcess(processModel) .deleteProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() - .assertThat().entriesListDoesNotContain("name", variableModel.getName()); - } - + .assertThat().entriesListDoesNotContain("name", variableModel.getName()); + } + } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/DeleteProcessVariableFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/DeleteProcessVariableFullTests.java index edbb5d714..62461361e 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/DeleteProcessVariableFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/DeleteProcessVariableFullTests.java @@ -39,7 +39,7 @@ public class DeleteProcessVariableFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Delete empty process variable") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void deleteEmptyProcessVariable() throws Exception { variableModel = new RestProcessVariableModel("", "", "bpm:workflowPackage"); @@ -55,36 +55,10 @@ public class DeleteProcessVariableFullTests extends RestTest .containsErrorKey(RestErrorModel.DELETE_EMPTY_ARGUMENT) .stackTraceIs(RestErrorModel.STACKTRACE); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Add a new process varaiables, update the variable and then delete.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) - public void createUpdateDeleteProcessVariable() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getProcesses() - .getProcessModelByProcessDefId(processModel.getId()); - restClient.withWorkflowAPI().usingProcess(restProcessModel) - .addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - variableModel.setValue("newValue"); - updatedVariable = restClient.withWorkflowAPI().usingProcess(processModel) - .updateProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedVariable.assertThat().field("value").is("newValue"); - - restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingProcess(processModel) - .deleteProcessVariable(updatedVariable); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() - .assertThat() - .entriesListDoesNotContain("name", updatedVariable.getName()); - } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Delete process then delete process variables, status OK should be returned") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void deleteProcessVariablesForADeletedProcess() throws Exception { UserModel userWhoStartsTask = dataUser.createRandomTestUser(); @@ -92,7 +66,7 @@ public class DeleteProcessVariableFullTests extends RestTest RestProcessModel processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() .addProcess("activitiAdhoc", assignee, false, Priority.Normal); - + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() .getProcesses().getProcessModelByProcessDefId(processModel.getId()); @@ -110,11 +84,11 @@ public class DeleteProcessVariableFullTests extends RestTest .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) .stackTraceIs(RestErrorModel.STACKTRACE); - } - + } + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Delete process variable using by the user who started the process.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void deleteProcessVariableByUserThatStartedTheProcess() throws Exception { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); @@ -133,21 +107,21 @@ public class DeleteProcessVariableFullTests extends RestTest .assertThat() .entriesListDoesNotContain("name", variableModel.getName()); } - + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Delete process variable using by the user involved in the process.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void deleteProcessVariableByUserInvolvedInTheProcess() throws Exception { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() .addProcess("activitiAdhoc", assignee, false, Priority.Normal); - + restProcessModel = restClient.withWorkflowAPI().getProcesses() .getProcessModelByProcessDefId(processModel.getId()); restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); - + restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(processModel) .deleteProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); @@ -155,29 +129,29 @@ public class DeleteProcessVariableFullTests extends RestTest .assertThat() .entriesListDoesNotContain("name", variableModel.getName()); } - + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Delete process variable with invalid type") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void deleteProcessVariableInvalidType() throws Exception - { + { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() .getProcesses().getProcessModelByProcessDefId(processModel.getId()); restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); - - variableModel.setType("invalid-type"); + + variableModel.setType("invalid-type"); restClient.withWorkflowAPI().usingProcess(restProcessModel).deleteProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() .assertThat() .entriesListDoesNotContain("name", variableModel.getName()); } - + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Delete process variable by non assigned user") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void deleteProcessVarialbleByNonAssignedUser() throws Exception { UserModel nonAssigned = dataUser.createRandomTestUser(); @@ -186,20 +160,20 @@ public class DeleteProcessVariableFullTests extends RestTest .getProcesses().getProcessModelByProcessDefId(processModel.getId()); restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); - + restClient.authenticateUser(nonAssigned).withWorkflowAPI().usingProcess(restProcessModel) .deleteProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) .assertLastError() .containsSummary(String.format(RestErrorModel.ACCESS_INFORMATION_NOT_ALLOWED, processModel.getId())) .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) .containsErrorKey(String.format(RestErrorModel.ACCESS_INFORMATION_NOT_ALLOWED, processModel.getId())) .stackTraceIs(RestErrorModel.STACKTRACE); } - + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Delete process variable by inexistent user") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void deleteProcessVarialbleByInexistentUser() throws Exception { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); @@ -209,36 +183,36 @@ public class DeleteProcessVariableFullTests extends RestTest .getProcesses().getProcessModelByProcessDefId(processModel.getId()); restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); - + restClient.authenticateUser(UserModel.getRandomUserModel()).withWorkflowAPI() .usingProcess(restProcessModel) .deleteProcessVariable(variableModel); - + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) .assertLastError() .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) .stackTraceIs(RestErrorModel.STACKTRACE); - } + } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, description = "Verify that admin from the same network is able to delete network process variables") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL, TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) public void deleteProcessVariablesWithAdminFromSameNetwork() throws Exception { UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser1); + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser1); UserModel tenantUser1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenant1"); - + RestProcessModel processModel = restClient.authenticateUser(adminTenantUser1).withWorkflowAPI() - .addProcess("activitiAdhoc", tenantUser1, false, Priority.Normal); + .addProcess("activitiAdhoc", tenantUser1, false, Priority.Normal); variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser1).withWorkflowAPI() .getProcesses().getProcessModelByProcessDefId(processModel.getId()); restClient.withWorkflowAPI().usingProcess(networkProcess1).addProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); - + restClient.authenticateUser(adminTenantUser1).withWorkflowAPI().usingProcess(networkProcess1) .deleteProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); @@ -249,7 +223,7 @@ public class DeleteProcessVariableFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, description = "Verify that admin from different network is not able to delete network process variables") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL, TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) public void deleteProcessVariablesWithAdminFromDifferentNetwork() throws Exception { UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); @@ -257,10 +231,10 @@ public class DeleteProcessVariableFullTests extends RestTest UserModel tenantUser1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenant1"); RestProcessModel processModel = restClient.authenticateUser(adminTenantUser1).withWorkflowAPI() - .addProcess("activitiAdhoc", tenantUser1, false, Priority.Normal); + .addProcess("activitiAdhoc", tenantUser1, false, Priority.Normal); variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser1).withWorkflowAPI() - .getProcesses().getProcessModelByProcessDefId(processModel.getId()); + .getProcesses().getProcessModelByProcessDefId(processModel.getId()); restClient.withWorkflowAPI().usingProcess(networkProcess1).addProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); @@ -271,7 +245,7 @@ public class DeleteProcessVariableFullTests extends RestTest .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) .containsErrorKey(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT) .stackTraceIs(RestErrorModel.STACKTRACE); - + restClient.authenticateUser(tenantUser1).withWorkflowAPI().usingProcess(networkProcess1).getProcessVariables().assertThat() .entriesListContains("name", variableModel.getName()); } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/DeleteProcessVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/DeleteProcessVariableSanityTests.java index d89bc5937..cb43c40c8 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/DeleteProcessVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/DeleteProcessVariableSanityTests.java @@ -44,7 +44,7 @@ public class DeleteProcessVariableSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) public void deleteProcessVariable() throws Exception { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); restClient.withWorkflowAPI().usingProcess(processModel).deleteProcessVariable(variableModel); diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/GetProcessVariablesCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/GetProcessVariablesCoreTests.java index 370aee125..bd2b1c3e5 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/GetProcessVariablesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/GetProcessVariablesCoreTests.java @@ -40,7 +40,7 @@ public class GetProcessVariablesCoreTests extends RestTest @TestRail(section = {TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify that admin from the same network is able to retrieve network process variables") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE, TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) public void getProcessVariablesWithAdminFromSameNetwork() throws Exception { UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); @@ -57,7 +57,7 @@ public class GetProcessVariablesCoreTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify that admin from different network is not able to retrieve network process variables") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE, TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) public void getProcessVariablesWithAdminFromDifferentNetwork() throws Exception { UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); @@ -73,7 +73,7 @@ public class GetProcessVariablesCoreTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Get process variables using invalid process ID") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void getProcessVariablesUsingInvalidProcessId() throws Exception { restClient.authenticateUser(userWhoStartsTask).withParams("maxItems=2").withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); @@ -92,7 +92,7 @@ public class GetProcessVariablesCoreTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Get process variables using empty process ID") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void getProcessVariablesUsingEmptyProcessId() throws Exception { processModel = restClient.authenticateUser(userWhoStartsTask).withParams("maxItems=2").withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); @@ -103,7 +103,7 @@ public class GetProcessVariablesCoreTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Delete process then get process variables, status OK should be returned") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void getProcessVariablesForADeletedProcess() throws Exception { UserModel userWhoStartsTask = dataUser.createRandomTestUser(); diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/GetProcessVariablesFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/GetProcessVariablesFullTests.java index 0eb5e8c93..91e7f5fa4 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/GetProcessVariablesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/GetProcessVariablesFullTests.java @@ -34,7 +34,7 @@ public class GetProcessVariablesFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify get all process variables call using admin user. Admin can see the process even if he isn't involved in it.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void getProcessVariablesUsingAdmin() throws Exception { variables = restClient.authenticateUser(admin).withWorkflowAPI().usingProcess(processModel).getProcessVariables(); @@ -58,10 +58,10 @@ public class GetProcessVariablesFullTests extends RestTest .assertThat().field("value").is(CMISUtil.Priority.Normal.getLevel()); } - @Bug(id = "MNT-17438") +// @Bug(id = "MNT-17438") @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify get all process variables with valid skip count parameter applied.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void getProcessVariablesWithValidSkipCount() throws Exception { variables = restClient.authenticateUser(admin).withWorkflowAPI().usingProcess(processModel).getProcessVariables(); @@ -79,7 +79,7 @@ public class GetProcessVariablesFullTests extends RestTest @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify get all process variables with negative skip count parameter applied.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void getProcessVariablesWithNegativeSkipCount() throws Exception { restClient.authenticateUser(admin).withParams("skipCount=-2").withWorkflowAPI().usingProcess(processModel).getProcessVariables(); @@ -93,7 +93,7 @@ public class GetProcessVariablesFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify get all process variables with not numeric skip count parameter applied.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void getProcessVariablesWithNonNumericSkipCount() throws Exception { restClient.authenticateUser(admin).withParams("skipCount=A").withWorkflowAPI().usingProcess(processModel).getProcessVariables(); @@ -104,7 +104,7 @@ public class GetProcessVariablesFullTests extends RestTest @Bug(id = "MNT-17438") @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify get all process variables with valid maxItems parameter applied.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void getProcessVariablesWithValidMaxItems() throws Exception { variables = restClient.authenticateUser(admin).withWorkflowAPI().usingProcess(processModel).getProcessVariables(); @@ -122,7 +122,7 @@ public class GetProcessVariablesFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify get all process variables with negative maxItems parameter applied.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void getProcessVariablesWithNegativeMaxItems() throws Exception { restClient.authenticateUser(admin).withParams("maxItems=-2").withWorkflowAPI().usingProcess(processModel).getProcessVariables(); @@ -136,7 +136,7 @@ public class GetProcessVariablesFullTests extends RestTest @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify get all process variables with not numeric maxItems parameter applied.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void getProcessVariablesWithNonNumericMaxItems() throws Exception { restClient.authenticateUser(admin).withParams("maxItems=A").withWorkflowAPI().usingProcess(processModel).getProcessVariables(); @@ -146,7 +146,7 @@ public class GetProcessVariablesFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify get all process variables with properties parameter.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void getProcessVariablesWithPropertiesParameter() throws Exception { variables = restClient.authenticateUser(admin).withParams("properties=name").withWorkflowAPI().usingProcess(processModel).getProcessVariables(); diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/UpdateProcessVariableTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/UpdateProcessVariableTests.java index a9d9ef814..140966bce 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/UpdateProcessVariableTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/UpdateProcessVariableTests.java @@ -36,7 +36,7 @@ public class UpdateProcessVariableTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Update existing variable using PUT call - invalid type") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void updateProcessVariableInvalidType() throws Exception { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); @@ -56,7 +56,7 @@ public class UpdateProcessVariableTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Update existing variable using PUT call - invalid type") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void updateProcessVariableTwoUsers() throws Exception { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:any"); @@ -89,7 +89,7 @@ public class UpdateProcessVariableTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Update existing variable using PUT call - name") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void updateProcessVariableName() throws Exception { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); From 662b9349d942f6af41239e7de6f17f16154e2db6 Mon Sep 17 00:00:00 2001 From: cagache Date: Tue, 10 Oct 2017 16:46:14 +0300 Subject: [PATCH 1239/1491] fixed NPE in GetTaskVariablesTests --- .../tasks/variables/GetTaskVariablesTests.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/GetTaskVariablesTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/GetTaskVariablesTests.java index 45ffc0dcb..b608ca888 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/GetTaskVariablesTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/GetTaskVariablesTests.java @@ -40,6 +40,9 @@ public class GetTaskVariablesTests extends RestTest description = "Verify that user that started the process gets task variables") public void getTaskVariablesByUserWhoStartedProcess() throws Exception { + taskModel = dataWorkflow.usingUser(userWhoStartsTask) + .usingSite(siteModel).usingResource(fileModel) + .createNewTaskAndAssignTo(assignee); restClient.authenticateUser(userWhoStartsTask); variableModels = restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables(); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -51,6 +54,9 @@ public class GetTaskVariablesTests extends RestTest description = "Verify that user that is involved in the process gets task variables") public void getTaskVariablesByUserInvolvedInProcess() throws Exception { + taskModel = dataWorkflow.usingUser(userWhoStartsTask) + .usingSite(siteModel).usingResource(fileModel) + .createNewTaskAndAssignTo(assignee); restClient.authenticateUser(assignee); variableModels = restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables(); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -63,7 +69,9 @@ public class GetTaskVariablesTests extends RestTest public void getTaskVariablesUsingAnyUser() throws Exception { UserModel randomUser = dataUser.createRandomTestUser(); - + taskModel = dataWorkflow.usingUser(userWhoStartsTask) + .usingSite(siteModel).usingResource(fileModel) + .createNewTaskAndAssignTo(assignee); restClient.authenticateUser(randomUser); restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables(); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); @@ -75,7 +83,9 @@ public class GetTaskVariablesTests extends RestTest public void getTaskVariablesUsingAdmin() throws Exception { UserModel adminUser = dataUser.getAdminUser(); - + taskModel = dataWorkflow.usingUser(userWhoStartsTask) + .usingSite(siteModel).usingResource(fileModel) + .createNewTaskAndAssignTo(assignee); restClient.authenticateUser(adminUser); variableModels = restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables(); restClient.assertStatusCodeIs(HttpStatus.OK); From d3c69110a73155f630ba5f0b860812febac7a7ba Mon Sep 17 00:00:00 2001 From: cagache Date: Tue, 10 Oct 2017 16:58:43 +0300 Subject: [PATCH 1240/1491] REPO-2755 / REPO-2251: fixed NPE in RemoveTaskItemTests --- .../rest/workflow/tasks/items/RemoveTaskItemTests.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/items/RemoveTaskItemTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/items/RemoveTaskItemTests.java index d31b5469b..7eeb25407 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/items/RemoveTaskItemTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/items/RemoveTaskItemTests.java @@ -37,6 +37,7 @@ public class RemoveTaskItemTests extends RestTest @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) public void deleteTaskItem() throws Exception { + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); restClient.authenticateUser(adminUser); document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); @@ -53,6 +54,7 @@ public class RemoveTaskItemTests extends RestTest @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) public void deleteTaskItemUsingInvalidTaskId() throws Exception { + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); restClient.authenticateUser(adminUser); document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); @@ -68,6 +70,7 @@ public class RemoveTaskItemTests extends RestTest @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) public void deleteTaskItemUsingInvalidItemId() throws Exception { + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); restClient.authenticateUser(adminUser); document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); From fe7d64c68b01ebebc5a4426e0c239acd0638e949 Mon Sep 17 00:00:00 2001 From: cagache Date: Tue, 10 Oct 2017 17:11:00 +0300 Subject: [PATCH 1241/1491] REPO-2755 / REPO-2251: fixed GetTasksTests#whereParameterApplied test --- .../org/alfresco/rest/workflow/tasks/GetTasksTests.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksTests.java index 1eb18a4ae..59c50d15a 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksTests.java @@ -253,10 +253,12 @@ public class GetTasksTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) public void whereParameterApplied() throws Exception { - taskModels = restClient.authenticateUser(dataUser.getAdminUser()).withParams("where=(assignee='" + assigneeUser.getUsername() + "')").withWorkflowAPI() + UserModel anotherAssignee = dataUser.createRandomTestUser(); + dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(anotherAssignee); + taskModels = restClient.authenticateUser(dataUser.getAdminUser()).withParams("where=(assignee='" + anotherAssignee.getUsername() + "')").withWorkflowAPI() .getTasks(); restClient.assertStatusCodeIs(HttpStatus.OK); - taskModels.assertThat().entriesListIsNotEmpty().and().entriesListContains("assignee", assigneeUser.getUsername()).and().entriesListCountIs(1); + taskModels.assertThat().entriesListIsNotEmpty().and().entriesListContains("assignee", anotherAssignee.getUsername()).and().entriesListCountIs(1); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, From d24494361d176c9d85bd9be50c9713335abe7465 Mon Sep 17 00:00:00 2001 From: cagache Date: Tue, 10 Oct 2017 17:14:04 +0300 Subject: [PATCH 1242/1491] REPO-2755 / REPO-2251: fixed GetTaskTests#starterUserGetsTaskWithEmptyTaskId test --- .../java/org/alfresco/rest/workflow/tasks/GetTaskTests.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskTests.java index a0f25e0fe..213230a66 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskTests.java @@ -133,7 +133,10 @@ public class GetTaskTests extends RestTest executionType = ExecutionType.REGRESSION, description = "Verify user who started a task gets the task with empty taskId with Rest API") public void starterUserGetsTaskWithEmptyTaskId() throws Exception { - restClient.authenticateUser(userModel).withWorkflowAPI(); + UserModel userWhoStartsTask = dataUser.createRandomTestUser(); + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(userWhoStartsTask); + + restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI(); RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "tasks/{taskId}", ""); RestTaskModelsCollection tasks = restClient.processModels(RestTaskModelsCollection.class, request); From b36105c95dd852fa9e0c587149635a0e1556fd4e Mon Sep 17 00:00:00 2001 From: cagache Date: Tue, 10 Oct 2017 17:47:04 +0300 Subject: [PATCH 1243/1491] REPO-2755 / REPO-2251: commented MNT-16904 bug for not network tests --- .../java/org/alfresco/rest/comments/DeleteCommentTests.java | 2 +- e2e-test/java/org/alfresco/rest/comments/GetCommentsTests.java | 2 +- .../java/org/alfresco/rest/comments/UpdateCommentTests.java | 2 +- .../java/org/alfresco/rest/favorites/AddFavoritesTests.java | 2 +- .../org/alfresco/rest/people/GetSiteMembershipSanityTests.java | 2 +- .../rest/people/GetSitesMembershipInformationSanityTests.java | 2 +- .../rest/people/preferences/GetPeoplePreferenceSanityTests.java | 2 +- .../people/preferences/GetPeoplePreferencesSanityTests.java | 2 +- .../rest/workflow/tasks/variables/DeleteTaskVariableTests.java | 2 +- .../workflow/tasks/variables/UpdateTaskVariableTestsBulk2.java | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentTests.java b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentTests.java index e05b22c72..c11c95fe1 100644 --- a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentTests.java @@ -54,7 +54,7 @@ public class DeleteCommentTests extends RestTest @TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify User gets status code 401 if authentication call fails") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) - @Bug(id="MNT-16904", description = "It fails only on environment with tenants") +// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") public void userIsNotAbleToDeleteCommentIfAuthenticationFails() throws Exception { restClient.authenticateUser(adminUserModel); diff --git a/e2e-test/java/org/alfresco/rest/comments/GetCommentsTests.java b/e2e-test/java/org/alfresco/rest/comments/GetCommentsTests.java index 0420ca6bf..6c8f07af2 100644 --- a/e2e-test/java/org/alfresco/rest/comments/GetCommentsTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/GetCommentsTests.java @@ -64,7 +64,7 @@ public class GetCommentsTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.SANITY, description= "Verify Manager user gets status code 401 if authentication call fails") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) - @Bug(id="MNT-16904", description = "It fails only on environment with tenants") +// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") public void managerIsNotAbleToRetrieveCommentIfAuthenticationFails() throws Exception { UserModel nonexistentModel = new UserModel("nonexistentUser", "nonexistentPassword"); diff --git a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentTests.java b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentTests.java index 9a669351c..10a7aa534 100644 --- a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentTests.java @@ -62,7 +62,7 @@ public class UpdateCommentTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user gets status code 401 on update comment call") @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) - @Bug(id = "MNT-16904", description = "fails only on environment with tenants") +// @Bug(id = "MNT-16904", description = "fails only on environment with tenants") public void unauthenticatedUserIsNotAbleToUpdateComment() throws Exception { restClient.authenticateUser(adminUserModel); diff --git a/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesTests.java b/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesTests.java index 0b42e72c4..4c4c7a642 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesTests.java @@ -436,7 +436,7 @@ public class AddFavoritesTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify the post favorites request when network id is invalid for tenant user") @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION, TestGroup.NETWORKS}) - public void addFavoriteSitesWhenNetworkIdIsInvalid() throws JsonToModelConversionException, Exception + public void addFavoriteSitesWhenNetworkIdIsInvalid() throws Exception { UserModel adminTenantUser = UserModel.getAdminTenantUser(); restClient.authenticateUser(adminUserModel); diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java index 04766c5d1..4b6709246 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java @@ -80,7 +80,7 @@ public class GetSiteMembershipSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to retrieve site membership information of another user") - @Bug(id="MNT-16904", description = "It fails only on environment with tenants") +// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") public void unauthenticatedUserCannotRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception { restClient.authenticateUser(new UserModel("random user", "random password")).withCoreAPI() diff --git a/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java index 685d06aee..24f066060 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java @@ -78,7 +78,7 @@ public class GetSitesMembershipInformationSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify that unauthenticated user is not able to retrieve sites membership information") - @Bug(id="MNT-16904", description = "It fails only on environment with tenants") +// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") public void unauthenticatedUserCannotRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception { UserModel inexistentUser = new UserModel("inexistent user", "wrong password"); diff --git a/e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferenceSanityTests.java b/e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferenceSanityTests.java index 1a5d5194d..53e2967dc 100644 --- a/e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferenceSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferenceSanityTests.java @@ -105,7 +105,7 @@ public class GetPeoplePreferenceSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized to get a specific preference with Rest API when authentication fails (401)") - @Bug(id = "MNT-16904", description = "fails only on environment with tenants") +// @Bug(id = "MNT-16904", description = "fails only on environment with tenants") public void managerUserNotAuthorizedFailsToGetsAPreference() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); diff --git a/e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferencesSanityTests.java b/e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferencesSanityTests.java index 813af4f38..49d8fb03d 100644 --- a/e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferencesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferencesSanityTests.java @@ -107,7 +107,7 @@ public class GetPeoplePreferencesSanityTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized to gets its preferences with Rest API when authentication fails(401)") - @Bug(id = "MNT-16904", description = "It fails only on environment with tenants") +// @Bug(id = "MNT-16904", description = "It fails only on environment with tenants") public void managerUserGetsPeoplePreferencesIsNotAuthorized() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/DeleteTaskVariableTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/DeleteTaskVariableTests.java index e0c5f8e0d..554d0ee7b 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/DeleteTaskVariableTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/DeleteTaskVariableTests.java @@ -145,7 +145,7 @@ public class DeleteTaskVariableTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Delete task variable by inexistent user") @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @Bug(id="MNT-16904", description = "It fails only on environment with tenants") +// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") public void deleteTaskVariableByInexistentUser() throws Exception { RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk2.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk2.java index 5c5252071..fe2ffc814 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk2.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk2.java @@ -157,7 +157,7 @@ public class UpdateTaskVariableTestsBulk2 extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Update task variable by inexistent user") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @Bug(id="MNT-16904", description = "It fails only on environment with tenants") +// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") public void updateTaskVariableByNonexistentUser() throws Exception { variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); From cdf7a7debf65c785c69a7e321f3d0714f759c8c3 Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 11 Oct 2017 09:43:32 +0300 Subject: [PATCH 1244/1491] REPO-2755 / REPO-2251: uncommented bugs --- .../people/preferences/GetPeoplePreferencesFullTests.java | 2 +- .../workflow/deployments/DeleteDeploymentSanityTests.java | 4 ++-- .../GetProcessDefinitionImageCoreTests.java | 2 +- .../GetProcessDefinitionStartFormModelCoreTests.java | 4 ++-- .../rest/workflow/processes/AddProcessCoreTests.java | 2 +- .../rest/workflow/processes/GetProcessCoreTests.java | 7 +++---- .../rest/workflow/processes/GetProcessesFullTests.java | 2 +- .../processes/items/AddProcessItemSanityTests.java | 2 +- .../workflow/processes/items/GetProcessItemsFullTests.java | 2 +- .../processes/variables/AddProcessVariableCoreTests.java | 3 ++- .../processes/variables/AddProcessVariablesFullTests.java | 2 +- .../processes/variables/GetProcessVariablesFullTests.java | 2 +- 12 files changed, 17 insertions(+), 17 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferencesFullTests.java b/e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferencesFullTests.java index 1ad0050d1..28de256d3 100644 --- a/e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferencesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferencesFullTests.java @@ -97,7 +97,7 @@ public class GetPeoplePreferencesFullTests extends RestTest restPreferenceModelsCollection.assertThat().entriesListIsEmpty(); } -// @Bug(id = "REPO-1911") + @Bug(id = "REPO-1911") @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot get preferences for empty user with Rest API and response is 400") public void userGetsItsPeoplePreferencesForEmptyPersonId() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java index b3e8d26ce..2301d5e45 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java @@ -37,7 +37,7 @@ public class DeleteDeploymentSanityTests extends RestTest adminUser = dataUser.getAdminUser(); } - @Bug(id = "MNT-16996") + @Bug(id = "REPO-1930") @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.SANITY, description = "Verify admin user deletes a specific deployment using REST API and status code is successful (204)") @Test(groups = { TestGroup.REST_API, TestGroup.DEPLOYMENTS, TestGroup.SANITY, TestGroup.WORKFLOW }, priority = 100) @@ -102,7 +102,7 @@ public class DeleteDeploymentSanityTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE); } -// @Bug(id = "MNT-16996") + @Bug(id = "REPO-1930") @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.SANITY, description = "Verify admin user cannot delete an inexistent deployment using REST API and status code is successful (204)") @Test(groups = { TestGroup.REST_API, TestGroup.DEPLOYMENTS, TestGroup.SANITY, TestGroup.WORKFLOW }, priority = 100) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageCoreTests.java index 125c749d5..1aa871cd9 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageCoreTests.java @@ -66,7 +66,7 @@ public class GetProcessDefinitionImageCoreTests extends RestTest executionType = ExecutionType.REGRESSION, description = "Verify network user is able to get a process definition image using REST API and status code is OK (200)") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION, TestGroup.NETWORKS}) -// @Bug(id = "MNT-17243") + @Bug(id = "MNT-17243") public void networkUserGetProcessDefinitionImage() throws Exception { adminTenantUser = UserModel.getAdminTenantUser(); diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java index 37bf1fa99..9ba813044 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java @@ -43,7 +43,7 @@ public class GetProcessDefinitionStartFormModelCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); } -// @Bug(id = "ALF-20187") + @Bug(id = "ALF-20187") @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify if get request returns status code 404 when invalid processDefinitionId is used") @@ -62,7 +62,7 @@ public class GetProcessDefinitionStartFormModelCoreTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE); } -// @Bug(id = "ALF-20187") + @Bug(id = "ALF-20187") @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify if get request returns status code 404 when empty processDefinitionId is used") diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessCoreTests.java index deee29c55..c818fd7ee 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessCoreTests.java @@ -65,7 +65,7 @@ public class AddProcessCoreTests extends RestTest .assertLastError().containsSummary(String.format(RestErrorModel.NO_CONTENT, "No content to map to Object due to end of input")); } -// @Bug(id = "ACE-5671") + @Bug(id = "REPO-1936") @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify start new process with invalid request body using REST API returns status code is Bad Request (400)") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessCoreTests.java index 6bdec6537..3a162070e 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessCoreTests.java @@ -47,7 +47,7 @@ public class GetProcessCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES}, executionType = ExecutionType.REGRESSION, description = "Verify that tenant user cannot get process from another network") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) -// @Bug(id = "MNT-17238") + @Bug(id = "REPO-2092") public void tenantUserCannotGetProcessFromAnotherNetwork() throws Exception { UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); @@ -87,8 +87,8 @@ public class GetProcessCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES}, executionType = ExecutionType.REGRESSION, description = "Verify that non network user cannot get process from a network") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) -// @Bug(id = "MNT-17238") - public void nonNetworkUserCannotAccessNetworkprocess() throws Exception + @Bug(id = "REPO-2092") + public void nonNetworkUserCannotAccessNetworkProcess() throws Exception { UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser1); @@ -101,5 +101,4 @@ public class GetProcessCoreTests extends RestTest .assertLastError().containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } - } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesFullTests.java index afeb7fb51..1afb42225 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesFullTests.java @@ -133,7 +133,7 @@ public class GetProcessesFullTests extends RestTest .and().entriesListContains("id", task1.getProcessId()); } -// @Bug(id = "REPO-1958") + @Bug(id = "REPO-1958") @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot get processes when using an invalid orderBy parameter") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemSanityTests.java index 6b43a81c6..a3432f0f3 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemSanityTests.java @@ -131,7 +131,7 @@ public class AddProcessItemSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); } -// @Bug(id= "MNT-16966") + @Bug(id= "REPO-1927") @TestRail(section = {TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Add process item that already exists") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY}) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/items/GetProcessItemsFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/items/GetProcessItemsFullTests.java index 0305970be..400f11d33 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/items/GetProcessItemsFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/items/GetProcessItemsFullTests.java @@ -103,7 +103,7 @@ public class GetProcessItemsFullTests extends RestTest items.assertThat().entriesListIsEmpty(); } -// @Bug(id = "MNT-17438") + @Bug(id = "REPO-1989") @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Get process items for process with valid skipCount parameter") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION}) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariableCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariableCoreTests.java index 7113b8907..8563d1676 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariableCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariableCoreTests.java @@ -11,6 +11,7 @@ import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpMethod; @@ -86,7 +87,7 @@ public class AddProcessVariableCoreTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE); } -// @Bug(id = "REPO-1938") + @Bug(id = "REPO-1938") @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process variable is falling in case invalid type prefix is provided") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesFullTests.java index aba6b88f5..4a428037b 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesFullTests.java @@ -250,7 +250,7 @@ public class AddProcessVariablesFullTests extends RestTest .assertThat().entriesListContains("value", variableModel.getValue()); } -// @Bug(id="REPO-1987") + @Bug(id="REPO-1987") @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process variables is falling in case invalid name is provided: symbols") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/GetProcessVariablesFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/GetProcessVariablesFullTests.java index 91e7f5fa4..e7c841cd3 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/GetProcessVariablesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/GetProcessVariablesFullTests.java @@ -58,7 +58,7 @@ public class GetProcessVariablesFullTests extends RestTest .assertThat().field("value").is(CMISUtil.Priority.Normal.getLevel()); } -// @Bug(id = "MNT-17438") + @Bug(id = "MNT-17438") @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify get all process variables with valid skip count parameter applied.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) From fbb9dfe0d4f20082e475c0c855fca9a8aaebf12d Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 11 Oct 2017 09:56:48 +0300 Subject: [PATCH 1245/1491] REPO-2755 / REPO-2251: compacted DeleteDeployment classes --- .../DeleteDeploymentCoreFullTests.java | 52 ------------------- ...yTests.java => DeleteDeploymentTests.java} | 30 ++++++++++- 2 files changed, 28 insertions(+), 54 deletions(-) delete mode 100644 e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentCoreFullTests.java rename e2e-test/java/org/alfresco/rest/workflow/deployments/{DeleteDeploymentSanityTests.java => DeleteDeploymentTests.java} (77%) diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentCoreFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentCoreFullTests.java deleted file mode 100644 index cee3854cf..000000000 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentCoreFullTests.java +++ /dev/null @@ -1,52 +0,0 @@ -package org.alfresco.rest.workflow.deployments; - -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestDeploymentModel; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class DeleteDeploymentCoreFullTests extends RestTest -{ - private UserModel adminUser; - private UserModel userModel; - private RestDeploymentModel deployment; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userModel = dataUser.createRandomTestUser(); - } - - @Bug(id = "MNT-16996") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, - description = "Verify deleteDeployment is unsupported for empty deployment id with REST API and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION, TestGroup.WORKFLOW }) - public void deleteDeploymentIsUnsupportedForEmptyId() throws Exception - { - deployment = restClient.authenticateUser(adminUser).withWorkflowAPI().getDeployments().getOneRandomEntry().onModel(); - deployment.setId(""); - restClient.withWorkflowAPI().usingDeployment(deployment).deleteDeployment(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); - } - - @Bug(id = "MNT-16996") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, - description = "Verify deleteDeployment is forbidden using non admin user or different user than creator with REST API and status code is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION, TestGroup.WORKFLOW }) - public void deleteDeploymentUsingNonAdminUser() throws Exception - { - deployment = restClient.authenticateUser(adminUser).withWorkflowAPI().getDeployments().getOneRandomEntry().onModel(); - restClient.authenticateUser(userModel).withWorkflowAPI().usingDeployment(deployment).deleteDeployment(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } -} diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentTests.java similarity index 77% rename from e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java rename to e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentTests.java index 2301d5e45..0a929fd0e 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentTests.java @@ -26,15 +26,16 @@ import org.testng.annotations.Test; * @author Cristina Axinte * */ -public class DeleteDeploymentSanityTests extends RestTest +public class DeleteDeploymentTests extends RestTest { - private UserModel adminUser; + private UserModel adminUser, userModel; private RestDeploymentModel deployment; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception { adminUser = dataUser.getAdminUser(); + userModel = dataUser.createRandomTestUser(); } @Bug(id = "REPO-1930") @@ -115,4 +116,29 @@ public class DeleteDeploymentSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "1000")); } + + @Bug(id = "REPO-1930") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, + description = "Verify deleteDeployment is unsupported for empty deployment id with REST API and status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION, TestGroup.WORKFLOW }) + public void deleteDeploymentIsUnsupportedForEmptyId() throws Exception + { + deployment = restClient.authenticateUser(adminUser).withWorkflowAPI().getDeployments().getOneRandomEntry().onModel(); + deployment.setId(""); + restClient.withWorkflowAPI().usingDeployment(deployment).deleteDeployment(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); + } + + @Bug(id = "REPO-1930") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, + description = "Verify deleteDeployment is forbidden using non admin user or different user than creator with REST API and status code is 403") + @Test(groups = { TestGroup.REST_API, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION, TestGroup.WORKFLOW }) + public void deleteDeploymentUsingNonAdminUser() throws Exception + { + deployment = restClient.authenticateUser(adminUser).withWorkflowAPI().getDeployments().getOneRandomEntry().onModel(); + restClient.authenticateUser(userModel).withWorkflowAPI().usingDeployment(deployment).deleteDeployment(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } } From 77604878e2b071d6702541eeac4a6cf597df2140 Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 11 Oct 2017 12:00:56 +0300 Subject: [PATCH 1246/1491] REPO-2755 / REPO-2251: changed FULL group with REGRESSION --- .../sites/members/RemoveSiteMemberTests.java | 18 +++++------ .../sites/members/UpdateSiteMemberTests.java | 32 +++++++++---------- .../UpdateSiteMembershipRequestTests.java | 2 +- .../items/AddProcessItemCoreTests.java | 2 +- .../GetTaskCandidatesRegressionTests.java | 18 +++++------ .../tasks/items/AddTaskItemTestsBulk3.java | 12 +++---- 6 files changed, 42 insertions(+), 42 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/sites/members/RemoveSiteMemberTests.java b/e2e-test/java/org/alfresco/rest/sites/members/RemoveSiteMemberTests.java index cfca3e3d5..fca039386 100644 --- a/e2e-test/java/org/alfresco/rest/sites/members/RemoveSiteMemberTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/members/RemoveSiteMemberTests.java @@ -353,7 +353,7 @@ public class RemoveSiteMemberTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Verify that admin can delete a site member with Contributor role and gets status code 204") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) public void adminIsAbleToDeleteSiteMemberWithContributorRole() throws Exception { restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel) @@ -364,7 +364,7 @@ public class RemoveSiteMemberTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Verify that admin can delete site member with Manager role and gets status code 204") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) public void aminIsAbleToDeleteSiteMemberWithManagerRole() throws Exception { restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel) @@ -375,7 +375,7 @@ public class RemoveSiteMemberTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Verify that admin can delete site member with Consumer role and gets status code 204") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) public void adminIsAbleToDeleteSiteMemberWithConsumerRole() throws Exception { restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel) @@ -386,7 +386,7 @@ public class RemoveSiteMemberTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Verify that admin can delete a site member with Collaborator role and gets status code 204") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) public void adminIsAbleToDeleteSiteMemberWithCollaboratorRole() throws Exception { restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel) @@ -397,7 +397,7 @@ public class RemoveSiteMemberTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Verify that admin can delete a site member of moderated site and gets status code 204") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) public void adminIsAbleToDeleteModeratedSiteMember() throws Exception { UserModel newMember = dataUser.createRandomTestUser(); @@ -410,7 +410,7 @@ public class RemoveSiteMemberTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Verify that admin can delete a site member of private site and gets status code 204") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) public void adminIsAbleToDeletePrivateSiteMember() throws Exception { UserModel newMember = dataUser.createRandomTestUser(); @@ -423,7 +423,7 @@ public class RemoveSiteMemberTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Verify that regular user can not delete admin and gets status code 422") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) public void regularUserIsNotAbleToDeleteASiteMember() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingSite(publicSiteModel) @@ -437,7 +437,7 @@ public class RemoveSiteMemberTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Verify that admin can not delete a site member twice and gets status code 404 for the second attempt") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) @Bug(id="ACE-5447") public void adminIsNotAbleToRemoveSiteMemberTwice() throws Exception { @@ -453,7 +453,7 @@ public class RemoveSiteMemberTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Verify admin is not able to remove from site a user that created a member request that was not accepted yet") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) @Bug(id="ACE-5447") public void adminIsNotAbleToRemoveFromSiteANonExistingMember() throws Exception { diff --git a/e2e-test/java/org/alfresco/rest/sites/members/UpdateSiteMemberTests.java b/e2e-test/java/org/alfresco/rest/sites/members/UpdateSiteMemberTests.java index 4325a7746..4afb9dde2 100644 --- a/e2e-test/java/org/alfresco/rest/sites/members/UpdateSiteMemberTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/members/UpdateSiteMemberTests.java @@ -300,7 +300,7 @@ public class UpdateSiteMemberTests extends RestTest .and().field("role").is(siteManager.getUserRole()); } - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if manager is able to update another site manager to site contributor") public void managerUpdateSiteManagerToSiteContributor() throws Exception @@ -315,7 +315,7 @@ public class UpdateSiteMemberTests extends RestTest updatedMember.assertThat().field("id").is(siteManager.getUsername()).and().field("role").is(siteManager.getUserRole()); } - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if manager is able to update another site manager to site consumer") public void managerUpdateSiteManagerToSiteConsumer() throws Exception @@ -330,7 +330,7 @@ public class UpdateSiteMemberTests extends RestTest updatedMember.assertThat().field("id").is(siteManager.getUsername()).and().field("role").is(siteManager.getUserRole()); } - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if manager is able to update site contributor to site collaborator") public void managerUpdateSiteContributorToSiteCollaborator() throws Exception @@ -345,7 +345,7 @@ public class UpdateSiteMemberTests extends RestTest updatedMember.assertThat().field("id").is(siteContributor.getUsername()).and().field("role").is(siteContributor.getUserRole()); } - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if manager is able to update site contributor to site consumer") public void managerUpdateSiteContributorToSiteConsumer() throws Exception @@ -360,7 +360,7 @@ public class UpdateSiteMemberTests extends RestTest updatedMember.assertThat().field("id").is(siteContributor.getUsername()).and().field("role").is(siteContributor.getUserRole()); } - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if manager is able to update site collaborator to site contributor") public void managerUpdateSiteCollaboratorToSiteContributor() throws Exception @@ -375,7 +375,7 @@ public class UpdateSiteMemberTests extends RestTest updatedMember.assertThat().field("id").is(siteCollaborator.getUsername()).and().field("role").is(siteCollaborator.getUserRole()); } - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if manager is able to update site collaborator to site consumer") public void managerUpdateSiteCollaboratorToSiteConsumer() throws Exception @@ -390,7 +390,7 @@ public class UpdateSiteMemberTests extends RestTest updatedMember.assertThat().field("id").is(siteCollaborator.getUsername()).and().field("role").is(siteCollaborator.getUserRole()); } - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if manager is able to update site consumer to site collaborator") public void managerUpdateSiteConsumerToSiteCollaborator() throws Exception @@ -405,7 +405,7 @@ public class UpdateSiteMemberTests extends RestTest updatedMember.assertThat().field("id").is(siteConsumer.getUsername()).and().field("role").is(siteConsumer.getUserRole()); } - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if manager is able to update site consumer to site contributor") public void managerUpdateSiteConsumerToSiteContributor() throws Exception @@ -420,7 +420,7 @@ public class UpdateSiteMemberTests extends RestTest updatedMember.assertThat().field("id").is(siteConsumer.getUsername()).and().field("role").is(siteConsumer.getUserRole()); } - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if manager is able to update another site manager to site manager") public void managerUpdateSiteManagerToSiteManager() throws Exception @@ -435,7 +435,7 @@ public class UpdateSiteMemberTests extends RestTest updatedMember.assertThat().field("id").is(siteManager.getUsername()).and().field("role").is(siteManager.getUserRole()); } - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if manager is able to update site collaborator to site collaborator") public void managerUpdateSiteCollaboratorToSiteCollaborator() throws Exception @@ -450,7 +450,7 @@ public class UpdateSiteMemberTests extends RestTest updatedMember.assertThat().field("id").is(siteCollaborator.getUsername()).and().field("role").is(siteCollaborator.getUserRole()); } - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if manager is able to update site contributor to site contributor") public void managerUpdateSiteContributorToSiteContributor() throws Exception @@ -465,7 +465,7 @@ public class UpdateSiteMemberTests extends RestTest updatedMember.assertThat().field("id").is(siteContributor.getUsername()).and().field("role").is(siteContributor.getUserRole()); } - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if manager is able to update site consumer to site consumer") public void managerUpdateSiteConsumerToSiteConsumer() throws Exception @@ -480,7 +480,7 @@ public class UpdateSiteMemberTests extends RestTest updatedMember.assertThat().field("id").is(siteConsumer.getUsername()).and().field("role").is(siteConsumer.getUserRole()); } - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if manager of a private site is able to downgrade his role") public void privateSiteManagerDowngradesRole() throws Exception @@ -495,7 +495,7 @@ public class UpdateSiteMemberTests extends RestTest updatedMember.assertThat().field("id").is(siteManager.getUsername()).and().field("role").is(siteManager.getUserRole()); } - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if manager of a moderated site is able to downgrade his role") public void moderatedSiteManagerDowngradesRole() throws Exception @@ -512,7 +512,7 @@ public class UpdateSiteMemberTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify the response of updating a site member with empty body at request") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) public void managerCanNotUpdateSiteMemberWithEmptyBody() throws Exception { restClient.authenticateUser(siteCreator).withCoreAPI(); @@ -529,7 +529,7 @@ public class UpdateSiteMemberTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE); } - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if manager is able to update a user that has created a site membership request, but it's not a member of the site yet") public void managerCanNotUpdateUserWithSiteMembershipRequest() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/sites/membershipRequests/UpdateSiteMembershipRequestTests.java b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/UpdateSiteMembershipRequestTests.java index 0aa579c2d..9bff0d17b 100644 --- a/e2e-test/java/org/alfresco/rest/sites/membershipRequests/UpdateSiteMembershipRequestTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/UpdateSiteMembershipRequestTests.java @@ -509,7 +509,7 @@ public class UpdateSiteMembershipRequestTests extends RestTest moderatedSite.setId(moderatedSiteId); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify inexistent user is not able to update site membership request") public void emptyUserCannotUpdateSiteMembershipRequest() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemCoreTests.java index 03aee5064..2e3ceb3de 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemCoreTests.java @@ -102,7 +102,7 @@ public class AddProcessItemCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add multiple process item by a random user.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) public void addMultipleProcessItemByAnyUser() throws Exception { anotherUser = dataUser.createRandomTestUser(); diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/candidates/GetTaskCandidatesRegressionTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/candidates/GetTaskCandidatesRegressionTests.java index 353e3bff6..c5dd2551e 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/candidates/GetTaskCandidatesRegressionTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/candidates/GetTaskCandidatesRegressionTests.java @@ -108,7 +108,7 @@ public class GetTaskCandidatesRegressionTests extends RestTest .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check default error model schema for get task candidates") public void getTaskCandidatesErrorSchemaCheck() throws Exception @@ -126,7 +126,7 @@ public class GetTaskCandidatesRegressionTests extends RestTest } @Bug(id="MNT-17438") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Get task candidates with skip count parameter") public void getTaskCandidatesWithSkipCount() throws Exception @@ -142,7 +142,7 @@ public class GetTaskCandidatesRegressionTests extends RestTest .and().paginationField("count").is("0"); } - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Get task candidates with max items parameter set to 0") public void getTaskCandidatesWithZeroMaxItems() throws Exception @@ -159,7 +159,7 @@ public class GetTaskCandidatesRegressionTests extends RestTest .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); } - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Get task candidates with max items parameter") public void getTaskCandidatesWithMaxItems() throws Exception @@ -175,7 +175,7 @@ public class GetTaskCandidatesRegressionTests extends RestTest .and().paginationField("count").is("1"); } - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Get task candidates with properties") public void getTaskCandidatesWithProperties() throws Exception @@ -191,7 +191,7 @@ public class GetTaskCandidatesRegressionTests extends RestTest .field("candidateType").isNull(); } - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Get task candidates with invalid properties") public void getTaskCandidatesWithInvalidProperties() throws Exception @@ -206,7 +206,7 @@ public class GetTaskCandidatesRegressionTests extends RestTest .fieldsCount().is(0).and(); } - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Get task candidates by deleted candidate") public void getTaskCandidatesByDeletedCandidate() throws Exception @@ -229,7 +229,7 @@ public class GetTaskCandidatesRegressionTests extends RestTest .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); } - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Get task candidates by deleted group") public void getTaskCandidatesByDeletedGroup() throws Exception @@ -254,7 +254,7 @@ public class GetTaskCandidatesRegressionTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE); } - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Get task candidates by user that was removed from group") public void getTaskCandidatesByUserRemovedFromGroup() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemTestsBulk3.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemTestsBulk3.java index 447d0d27d..7ffa95ead 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemTestsBulk3.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemTestsBulk3.java @@ -41,7 +41,7 @@ public class AddTaskItemTestsBulk3 extends RestTest taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Add task item using random user.") public void addTaskItemByTheUserThatStartedTheProcess() throws Exception @@ -59,7 +59,7 @@ public class AddTaskItemTestsBulk3 extends RestTest .and().field("mimeType").is(taskItem.getMimeType()); } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Add multiple task item using random user.") public void addMultipleTaskItemByTheUserThatStartedTheProcess() throws Exception @@ -92,7 +92,7 @@ public class AddTaskItemTestsBulk3 extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Add task item using by admin in other network.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL, TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) public void addTaskItemByAdminInOtherNetwork() throws Exception { UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); @@ -119,7 +119,7 @@ public class AddTaskItemTestsBulk3 extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Add multiple task item using by admin in other network.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL, TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) public void addMultipleTaskItemByAdminInOtherNetwork() throws Exception { UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); @@ -148,7 +148,7 @@ public class AddTaskItemTestsBulk3 extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Delete task item then create it again") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL}) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION}) public void deleteTaskItemThenCreateItAgain() throws Exception { taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel) @@ -167,7 +167,7 @@ public class AddTaskItemTestsBulk3 extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Delete multiple task item then create it again") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL}) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION}) public void deleteMultipleTaskItemsThenCreateThemAgain() throws Exception { taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel) From f0a3a62ce60401d2bd23586c6326d9fa705b515b Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 11 Oct 2017 12:11:04 +0300 Subject: [PATCH 1247/1491] REPO-2755 / REPO-2251: uncommented bugs --- .../processDefinitions/GetProcessDefinitionImageFullTests.java | 2 +- .../rest/workflow/processes/items/AddProcessItemCoreTests.java | 2 +- .../workflow/processes/items/AddProcessItemSanityTests.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageFullTests.java index 13775051b..b0c091dae 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageFullTests.java @@ -26,7 +26,7 @@ public class GetProcessDefinitionImageFullTests extends RestTest adminUser = dataUser.getAdminUser(); } -// @Bug(id = "REPO-1911") + @Bug(id = "REPO-1911") @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, description = "Verify if get process definition image returns status code 404 when empty processDefinitionId is used") diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemCoreTests.java index 2e3ceb3de..8d3846e57 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemCoreTests.java @@ -243,7 +243,7 @@ public class AddProcessItemCoreTests extends RestTest .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidProcessId")); } -// @Bug(id = "ACE-5683") + @Bug(id = "REPO-1937") @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process item is falling in case of invalid body item is provided") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemSanityTests.java index a3432f0f3..797936ceb 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemSanityTests.java @@ -104,7 +104,7 @@ public class AddProcessItemSanityTests extends RestTest .assertThat().entriesListContains("id", processItems.getEntries().get(1).onModel().getId()); } -// @Bug(id= "MNT-16966") + @Bug(id= "REPO-1927") @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Add process item that already exists") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY}) From 49121390d4deae1ed2253b8187c8a5ef48cc2916 Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 11 Oct 2017 13:13:28 +0300 Subject: [PATCH 1248/1491] REPO-2755 / REPO-2251: fix for verifyPropertiesParameterIsAppliedToGetNetworkRequest --- .../RestGetNetworkForPersonTests.java | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonTests.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonTests.java index 11d744596..0f9bb44c7 100644 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonTests.java +++ b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonTests.java @@ -40,14 +40,14 @@ public class RestGetNetworkForPersonTests extends RestTest restClient.authenticateUser(adminUserModel); restClient.usingTenant().createTenant(adminTenantUser); tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - tenantSiteManager = dataUser.usingUser(adminTenantUser).createUserWithTenant("tenantSiteManager"); - tenantSiteCollaborator = dataUser.usingUser(adminTenantUser).createUserWithTenant("tenantSiteCollaborator"); - tenantSiteContributor = dataUser.usingUser(adminTenantUser).createUserWithTenant("tenantSiteContributor"); - tenantSiteConsumer = dataUser.usingUser(adminTenantUser).createUserWithTenant("tenantSiteConsumer"); - tenantSite = dataSite.usingUser(tenantSiteManager).createPublicRandomSite(); - dataUser.usingUser(tenantSiteManager).addUserToSite(tenantSiteCollaborator, tenantSite, UserRole.SiteCollaborator); - dataUser.usingUser(tenantSiteManager).addUserToSite(tenantSiteContributor, tenantSite, UserRole.SiteContributor); - dataUser.usingUser(tenantSiteManager).addUserToSite(tenantSiteConsumer, tenantSite, UserRole.SiteConsumer); +// tenantSiteManager = dataUser.usingUser(adminTenantUser).createUserWithTenant("tenantSiteManager"); +// tenantSiteCollaborator = dataUser.usingUser(adminTenantUser).createUserWithTenant("tenantSiteCollaborator"); +// tenantSiteContributor = dataUser.usingUser(adminTenantUser).createUserWithTenant("tenantSiteContributor"); +// tenantSiteConsumer = dataUser.usingUser(adminTenantUser).createUserWithTenant("tenantSiteConsumer"); +// tenantSite = dataSite.usingUser(tenantSiteManager).createPublicRandomSite(); +// dataUser.usingUser(tenantSiteManager).addUserToSite(tenantSiteCollaborator, tenantSite, UserRole.SiteCollaborator); +// dataUser.usingUser(tenantSiteManager).addUserToSite(tenantSiteContributor, tenantSite, UserRole.SiteContributor); +// dataUser.usingUser(tenantSiteManager).addUserToSite(tenantSiteConsumer, tenantSite, UserRole.SiteConsumer); } @Bug(id = "MNT-16904") @@ -191,10 +191,14 @@ public class RestGetNetworkForPersonTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) public void verifyPropertiesParameterIsAppliedToGetNetworkRequest() throws Exception { - restNetworkModel = restClient.authenticateUser(adminTenantUser).withParams("properties=id").withCoreAPI().usingMe().getNetwork(); + restNetworkModel = restClient.authenticateUser(adminTenantUser).withParams("properties=id,isEnabled,homeNetwork,paidNetwork").withCoreAPI().usingMe().getNetwork(); restClient.assertStatusCodeIs(HttpStatus.OK); - restNetworkModel.assertThat().field("id").is(adminTenantUser.getDomain().toLowerCase()); - restNetworkModel.assertThat().fieldsCount().is(1); + restNetworkModel.assertThat().field("id").is(adminTenantUser.getDomain().toLowerCase()) + .assertThat().field("isEnabled").is("true") + .assertThat().field("homeNetwork").is("true") + .assertThat().field("paidNetwork").is("false") + .assertThat().field("quotas").isNull(); + restNetworkModel.assertThat().fieldsCount().is(4); } @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, From 4ef65dfb1f792997bbda48f9a3c67dbd9b7754b9 Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 11 Oct 2017 13:29:43 +0300 Subject: [PATCH 1249/1491] REPO-2755 / REPO-2251: uncommented bugs --- .../rest/people/preferences/GetPeoplePreferenceFullTests.java | 2 +- .../processes/variables/AddProcessVariablesFullTests.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferenceFullTests.java b/e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferenceFullTests.java index d760c3d1c..647c562e8 100644 --- a/e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferenceFullTests.java +++ b/e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferenceFullTests.java @@ -137,7 +137,7 @@ public class GetPeoplePreferenceFullTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Change one preference for an user then perform get call") -// @Bug(id = "ACE-5736") + @Bug(id = "REPO-1922") public void changePreferenceThenPerformGetPreferenceCall() throws Exception { UserModel newUser = dataUser.createRandomTestUser(); diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesFullTests.java index 4a428037b..6d8008d15 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesFullTests.java @@ -150,7 +150,7 @@ public class AddProcessVariablesFullTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE); } -// @Bug(id = "REPO-1938") + @Bug(id = "REPO-1938") @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process variables is falling in case invalid type prefix is provided") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) From fdfc91055dd1f81491234e1fe304128f4b9fe2b8 Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 11 Oct 2017 14:05:44 +0300 Subject: [PATCH 1250/1491] REPO-2755 / REPO-2251: uncommented precondition --- .../networks/RestGetNetworkForPersonTests.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonTests.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonTests.java index 0f9bb44c7..f7ac80adb 100644 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonTests.java +++ b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonTests.java @@ -40,14 +40,14 @@ public class RestGetNetworkForPersonTests extends RestTest restClient.authenticateUser(adminUserModel); restClient.usingTenant().createTenant(adminTenantUser); tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); -// tenantSiteManager = dataUser.usingUser(adminTenantUser).createUserWithTenant("tenantSiteManager"); -// tenantSiteCollaborator = dataUser.usingUser(adminTenantUser).createUserWithTenant("tenantSiteCollaborator"); -// tenantSiteContributor = dataUser.usingUser(adminTenantUser).createUserWithTenant("tenantSiteContributor"); -// tenantSiteConsumer = dataUser.usingUser(adminTenantUser).createUserWithTenant("tenantSiteConsumer"); -// tenantSite = dataSite.usingUser(tenantSiteManager).createPublicRandomSite(); -// dataUser.usingUser(tenantSiteManager).addUserToSite(tenantSiteCollaborator, tenantSite, UserRole.SiteCollaborator); -// dataUser.usingUser(tenantSiteManager).addUserToSite(tenantSiteContributor, tenantSite, UserRole.SiteContributor); -// dataUser.usingUser(tenantSiteManager).addUserToSite(tenantSiteConsumer, tenantSite, UserRole.SiteConsumer); + tenantSiteManager = dataUser.usingUser(adminTenantUser).createUserWithTenant("tenantSiteManager"); + tenantSiteCollaborator = dataUser.usingUser(adminTenantUser).createUserWithTenant("tenantSiteCollaborator"); + tenantSiteContributor = dataUser.usingUser(adminTenantUser).createUserWithTenant("tenantSiteContributor"); + tenantSiteConsumer = dataUser.usingUser(adminTenantUser).createUserWithTenant("tenantSiteConsumer"); + tenantSite = dataSite.usingUser(tenantSiteManager).createPublicRandomSite(); + dataUser.usingUser(tenantSiteManager).addUserToSite(tenantSiteCollaborator, tenantSite, UserRole.SiteCollaborator); + dataUser.usingUser(tenantSiteManager).addUserToSite(tenantSiteContributor, tenantSite, UserRole.SiteContributor); + dataUser.usingUser(tenantSiteManager).addUserToSite(tenantSiteConsumer, tenantSite, UserRole.SiteConsumer); } @Bug(id = "MNT-16904") From 0261da42e3a872e1d764643d07618d23e6d128db Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 11 Oct 2017 14:51:13 +0300 Subject: [PATCH 1251/1491] REPO-2755 / REPO-2251: deleted duplicates from network package --- .../RestGetNetworkForPersonTests.java | 154 ++++++------------ .../rest/networks/RestGetNetworkTests.java | 86 +--------- .../RestGetNetworksForPersonTests.java | 93 ++--------- 3 files changed, 70 insertions(+), 263 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonTests.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonTests.java index f7ac80adb..7119f9379 100644 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonTests.java +++ b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonTests.java @@ -4,8 +4,6 @@ import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestNetworkModel; import org.alfresco.rest.model.RestNetworkQuotaModel; -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.report.Bug; @@ -22,14 +20,9 @@ import java.util.ArrayList; */ public class RestGetNetworkForPersonTests extends RestTest { - UserModel adminUserModel; + UserModel adminUserModel, secondAdminTenantUser; UserModel adminTenantUser; UserModel tenantUser; - UserModel tenantSiteManager; - UserModel tenantSiteCollaborator; - UserModel tenantSiteContributor; - UserModel tenantSiteConsumer; - SiteModel tenantSite; RestNetworkModel restNetworkModel; @BeforeClass(alwaysRun = true) @@ -40,19 +33,13 @@ public class RestGetNetworkForPersonTests extends RestTest restClient.authenticateUser(adminUserModel); restClient.usingTenant().createTenant(adminTenantUser); tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - tenantSiteManager = dataUser.usingUser(adminTenantUser).createUserWithTenant("tenantSiteManager"); - tenantSiteCollaborator = dataUser.usingUser(adminTenantUser).createUserWithTenant("tenantSiteCollaborator"); - tenantSiteContributor = dataUser.usingUser(adminTenantUser).createUserWithTenant("tenantSiteContributor"); - tenantSiteConsumer = dataUser.usingUser(adminTenantUser).createUserWithTenant("tenantSiteConsumer"); - tenantSite = dataSite.usingUser(tenantSiteManager).createPublicRandomSite(); - dataUser.usingUser(tenantSiteManager).addUserToSite(tenantSiteCollaborator, tenantSite, UserRole.SiteCollaborator); - dataUser.usingUser(tenantSiteManager).addUserToSite(tenantSiteContributor, tenantSite, UserRole.SiteContributor); - dataUser.usingUser(tenantSiteManager).addUserToSite(tenantSiteConsumer, tenantSite, UserRole.SiteConsumer); + secondAdminTenantUser = UserModel.getAdminTenantUser(); + restClient.usingTenant().createTenant(secondAdminTenantUser); } @Bug(id = "MNT-16904") - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Verify non existing user gets another existing network with Rest API and checks the forbidden status") + @TestRail(section = { TestGroup.REST_API, + TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, description = "Verify non existing user gets another existing network with Rest API and checks the forbidden status") @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) public void nonExistingTenantUserIsNotAuthorizedToRequest() throws Exception { @@ -62,8 +49,8 @@ public class RestGetNetworkForPersonTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, - description = "Verify tenant admin user gets specific network with Rest API and response is not empty") + @TestRail(section = { TestGroup.REST_API, + TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify tenant admin user gets specific network with Rest API and response is not empty") @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) public void adminTenantChecksIfNetworkIsPresent() throws Exception { @@ -71,67 +58,28 @@ public class RestGetNetworkForPersonTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); } + @TestRail(section = { TestGroup.REST_API, + TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify tenant user gets specific network with Rest API and response is not empty") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) + public void tenantUserChecksIfNetworkIsPresent() throws Exception + { + restClient.authenticateUser(tenantUser).withCoreAPI().usingUser(tenantUser).getNetwork(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + @Bug(id = "needs to be checked") - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Verify tenant user check network of admin user with Rest API") + @TestRail(section = { TestGroup.REST_API, + TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, description = "Verify tenant user check network of admin user with Rest API") @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) public void tenantUserIsNotAuthorizedToCheckNetworkOfAdminUser() throws Exception - { + { restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().getNetwork(adminTenantUser); restClient.assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Verify admin tenant user is not authorized to check network of another user with Rest API and checks the forbidden status") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) - public void adminTenantUserIsNotAuthorizedToCheckNetworkOfAnotherUser() throws Exception - { - UserModel secondAdminTenantUser = UserModel.getAdminTenantUser(); - restClient.usingTenant().createTenant(secondAdminTenantUser); - UserModel secondTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("anotherTenant"); - restClient.authenticateUser(adminTenantUser).withCoreAPI().usingAuthUser().getNetwork(secondTenantUser); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, - description = "Verify site manager user gets specific network with Rest API and response is not empty") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) - public void siteManagerChecksIfNetworkIsPresent() throws Exception - { - restClient.authenticateUser(tenantSiteManager).withCoreAPI().usingAuthUser().getNetwork(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Verify site collaborator user gets specific network with Rest API and response is not empty") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) - public void siteCollaboratorChecksIfNetworkIsPresent() throws Exception - { - restClient.authenticateUser(tenantSiteCollaborator).withCoreAPI().usingAuthUser().getNetwork(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Verify site contributor user gets specific network with Rest API and response is not empty") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) - public void siteContributorChecksIfNetworkIsPresent() throws Exception - { - restClient.authenticateUser(tenantSiteContributor).withCoreAPI().usingAuthUser().getNetwork(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Verify site consumer user gets specific network with Rest API and response is not empty") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) - public void siteConsumerChecksIfNetworkIsPresent() throws Exception - { - restClient.authenticateUser(tenantSiteConsumer).withCoreAPI().usingAuthUser().getNetwork(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - @Bug(id = "needs to be checked") - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Verify getNetwork request status code is 200 if a user tries to get network information of another user") + @TestRail(section = { TestGroup.REST_API, + TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, description = "Verify getNetwork request status code is 200 if a user tries to get network information of another user") @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) public void verifyGetNetworkByAUserForAnotherUser() throws Exception { @@ -141,8 +89,8 @@ public class RestGetNetworkForPersonTests extends RestTest restNetworkModel.assertThat().field("id").is(tenantUser.getDomain()); } - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that getNetwork status code is 404 for a personId that does not exist") + @TestRail(section = { TestGroup.REST_API, + TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, description = "Verify that getNetwork status code is 404 for a personId that does not exist") @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) public void verifyThatGetNetworkStatusIs404ForAPersonIdThatDoesNotExist() throws Exception { @@ -150,15 +98,13 @@ public class RestGetNetworkForPersonTests extends RestTest invalidUser.setUsername("invalidUsername"); restClient.authenticateUser(adminTenantUser).withCoreAPI().usingUser(invalidUser).getNetwork(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, invalidUser.getUsername())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, invalidUser.getUsername())).descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) .stackTraceIs(RestErrorModel.STACKTRACE); } - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that getNetwork status code is 404 for a networkId that does not exist") + @TestRail(section = { TestGroup.REST_API, + TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, description = "Verify that getNetwork status code is 404 for a networkId that does not exist") @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) public void verifyThatGetNetworkStatusIs404ForANetworkIdThatDoesNotExist() throws Exception { @@ -166,49 +112,51 @@ public class RestGetNetworkForPersonTests extends RestTest invalidUser.setDomain("invalidNetworkId"); restClient.authenticateUser(adminTenantUser).withCoreAPI().usingUser(invalidUser).getNetwork(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, invalidUser.getUsername())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, invalidUser.getUsername())).descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) .stackTraceIs(RestErrorModel.STACKTRACE); } - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Verify getNetwork request that is made using -me- instead of personId") + @TestRail(section = { TestGroup.REST_API, + TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, description = "Verify getNetwork request that is made using -me- instead of personId") @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) public void verifyGetNetworkRequestUsingMeInsteadOfPersonId() throws Exception { restNetworkModel = restClient.authenticateUser(adminTenantUser).withCoreAPI().usingMe().getNetwork(); restClient.assertStatusCodeIs(HttpStatus.OK); - restNetworkModel.assertThat().field("quotas").is(new ArrayList()) - .assertThat().field("isEnabled").is("true") - .assertThat().field("homeNetwork").is("true") - .assertThat().field("id").is(adminTenantUser.getDomain().toLowerCase()); + restNetworkModel.assertThat().field("quotas").is(new ArrayList()).assertThat().field("isEnabled").is("true").assertThat() + .field("homeNetwork").is("true").assertThat().field("id").is(adminTenantUser.getDomain().toLowerCase()); } - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that properties parameter is applied to getNetwork request") + @TestRail(section = { TestGroup.REST_API, + TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, description = "Verify that properties parameter is applied to getNetwork request") @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) public void verifyPropertiesParameterIsAppliedToGetNetworkRequest() throws Exception { - restNetworkModel = restClient.authenticateUser(adminTenantUser).withParams("properties=id,isEnabled,homeNetwork,paidNetwork").withCoreAPI().usingMe().getNetwork(); + restNetworkModel = restClient.authenticateUser(adminTenantUser).withParams("properties=id,isEnabled,homeNetwork,paidNetwork").withCoreAPI().usingMe() + .getNetwork(); restClient.assertStatusCodeIs(HttpStatus.OK); - restNetworkModel.assertThat().field("id").is(adminTenantUser.getDomain().toLowerCase()) - .assertThat().field("isEnabled").is("true") - .assertThat().field("homeNetwork").is("true") - .assertThat().field("paidNetwork").is("false") - .assertThat().field("quotas").isNull(); + restNetworkModel.assertThat().field("id").is(adminTenantUser.getDomain().toLowerCase()).assertThat().field("isEnabled").is("true").assertThat() + .field("homeNetwork").is("true").assertThat().field("paidNetwork").is("false").assertThat().field("quotas").isNull(); restNetworkModel.assertThat().fieldsCount().is(4); } - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Verify getNetwork request status code is 404 for a network to which user does not belong") + @TestRail(section = { TestGroup.REST_API, + TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, description = "Verify getNetwork request status code is 404 for a network to which user does not belong") @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) public void verifyGetNetworkRequestStatusCodeIs404ForANetworkToWhichTheUserDoesNotBelong() throws Exception { - UserModel secondAdminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUserModel).usingTenant().createTenant(secondAdminTenantUser); restClient.authenticateUser(adminTenantUser).withCoreAPI().usingAuthUser().getNetwork(secondAdminTenantUser); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, description = "Verify admin tenant user is not authorized to check network of another user with Rest API and checks the forbidden status") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) + public void adminTenantUserIsNotAuthorizedToCheckNetworkOfAnotherUser() throws Exception + { + UserModel secondTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("anotherTenant"); + restClient.authenticateUser(secondAdminTenantUser).withCoreAPI().usingAuthUser().getNetwork(secondTenantUser); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } } diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkTests.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkTests.java index fb4b99c3c..689b9011b 100644 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkTests.java +++ b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkTests.java @@ -24,7 +24,6 @@ public class RestGetNetworkTests extends RestTest { UserModel adminTenantUser; UserModel adminAnotherTenantUser; - SiteModel site; UserModel tenantUser; UserModel adminuser; @@ -39,7 +38,6 @@ public class RestGetNetworkTests extends RestTest restClient.usingTenant().createTenant(adminAnotherTenantUser); tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - site = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); } @Bug(id = "MNT-16904") @@ -59,19 +57,10 @@ public class RestGetNetworkTests extends RestTest description = "Verify tenant admin user gets specific network with Rest API and response is not empty") @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) public void adminTenantChecksIfNetworkIsPresent() throws Exception - { - restClient.authenticateUser(adminTenantUser); - restClient.withCoreAPI().usingNetworks().getNetwork(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, - description = "Verify tenant admin user gets specific network with Rest API and checks response parameters are correct") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) - public void adminTenantChecksNetworkParamsAreCorrect() throws Exception { restClient.authenticateUser(adminTenantUser); restClient.withCoreAPI().usingNetworks().getNetwork().assertNetworkHasName(adminTenantUser).assertNetworkIsEnabled(); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, @@ -88,19 +77,10 @@ public class RestGetNetworkTests extends RestTest description = "Verify any tenant user gets its network with Rest API and response is not empty") @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) public void userTenantChecksIfNetworkIsPresent() throws Exception - { - restClient.authenticateUser(tenantUser); - restClient.withCoreAPI().usingNetworks().getNetwork(adminTenantUser); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, - description = "Verify any tenant user gets specific network with Rest API and checks response parameters are correct") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) - public void userTenantChecksNetworkParamsAreCorrect() throws Exception { restClient.authenticateUser(tenantUser); restClient.withCoreAPI().usingNetworks().getNetwork(adminTenantUser).assertNetworkHasName(adminTenantUser).assertNetworkIsEnabled(); + restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, @@ -123,68 +103,6 @@ public class RestGetNetworkTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); } - @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Verify manager tenant user gets its network with Rest API and response is not empty") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) - public void tenantManagerUserChecksIfNetworkIsPresent() throws Exception - { - UserModel managerTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("manTenant"); - dataUser.usingUser(adminTenantUser).addUserToSite(managerTenantUser, site, UserRole.SiteManager); - - restClient.authenticateUser(managerTenantUser); - restClient.withCoreAPI().usingNetworks().getNetwork(adminTenantUser); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Verify collaborator tenant user gets its network with Rest API and response is not empty") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) - public void tenantCollaboratorUserChecksIfNetworkIsPresent() throws Exception - { - UserModel collaboratorTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("colTenant"); - dataUser.usingUser(adminTenantUser).addUserToSite(collaboratorTenantUser, site, UserRole.SiteCollaborator); - - restClient.authenticateUser(collaboratorTenantUser); - restClient.withCoreAPI().usingNetworks().getNetwork(adminTenantUser); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Verify consumer tenant user gets its network with Rest API and response is not empty") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) - public void tenantConsumerUserChecksIfNetworkIsPresent() throws Exception - { - UserModel consumerTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("consTenant"); - dataUser.usingUser(adminTenantUser).addUserToSite(consumerTenantUser, site, UserRole.SiteConsumer); - - restClient.authenticateUser(consumerTenantUser); - restClient.withCoreAPI().usingNetworks().getNetwork(adminTenantUser); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Verify contributor tenant user gets its network with Rest API and response is not empty") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) - public void tenantContributorUserChecksIfItsNetworkIsPresent() throws Exception - { - UserModel contributorTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("contTenant"); - dataUser.usingUser(adminTenantUser).addUserToSite(contributorTenantUser, site, UserRole.SiteContributor); - - restClient.authenticateUser(contributorTenantUser); - restClient.withCoreAPI().usingNetworks().getNetwork(adminTenantUser); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Verify tenant admin user gets non existing network with Rest API and checks the not found status") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) - public void adminTenantChecksIfNonExistingNetworkIsNotFound() throws Exception - { - restClient.authenticateUser(adminTenantUser); - restClient.withCoreAPI().usingNetworks().getNetwork(UserModel.getRandomTenantUser()); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } - @Bug(id = "ACE-5738") @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, description = "Verify tenant admin user gets an invalid network with Rest API and checks the not found status") diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonTests.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonTests.java index 0bb738882..c5d90c144 100644 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonTests.java +++ b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonTests.java @@ -16,10 +16,9 @@ import org.testng.annotations.Test; public class RestGetNetworksForPersonTests extends RestTest { - private UserModel adminUserModel; + private UserModel adminUserModel, secondAdminTenantUser; private UserModel adminTenantUser; private UserModel tenantUser; - private SiteModel siteModel; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception @@ -29,7 +28,8 @@ public class RestGetNetworksForPersonTests extends RestTest restClient.authenticateUser(adminUserModel); restClient.usingTenant().createTenant(adminTenantUser); tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); + secondAdminTenantUser = UserModel.getAdminTenantUser(); + restClient.usingTenant().createTenant(secondAdminTenantUser); } @Bug(id = "MNT-16904") @@ -51,8 +51,20 @@ public class RestGetNetworksForPersonTests extends RestTest @Test(groups = {TestGroup.REST_API, TestGroup.SANITY, TestGroup.NETWORKS }) public void adminTenantChecksIfNetworkIsPresent() throws Exception { - restClient.authenticateUser(adminTenantUser); - restClient.withCoreAPI().usingAuthUser().getNetworks(); + RestNetworkModelsCollection networks = restClient.authenticateUser(adminTenantUser).withCoreAPI().usingAuthUser().getNetworks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + networks.getOneRandomEntry().onModel().assertNetworkIsEnabled() + .and().field("id").is(adminTenantUser.getDomain().toLowerCase()) + .and().field("quotas").is("[]") + .and().field("homeNetwork").is("false"); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, + description = "Verify tenant user gets specific network with Rest API and response is not empty") + @Test(groups = {TestGroup.REST_API, TestGroup.SANITY, TestGroup.NETWORKS }) + public void tenantUserChecksIfNetworkIsPresent() throws Exception + { + restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().getNetworks(); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -71,69 +83,11 @@ public class RestGetNetworksForPersonTests extends RestTest @Test(groups = {TestGroup.REST_API, TestGroup.REGRESSION, TestGroup.NETWORKS }) public void adminTenantUserIsNotAuthorizedToCheckNetworkOfAnotherUser() throws Exception { - UserModel secondAdminTenantUser = UserModel.getAdminTenantUser(); - restClient.usingTenant().createTenant(secondAdminTenantUser); UserModel secondTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("anotherTenant"); restClient.authenticateUser(secondAdminTenantUser); restClient.withCoreAPI().usingAuthUser().getNetworks(secondTenantUser); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, - description = "Verify tenant manager user gets specific network with Rest API and response is not empty") - @Test(groups = {TestGroup.REST_API, TestGroup.SANITY, TestGroup.NETWORKS }) - public void managerTenantChecksIfNetworkIsPresent() throws Exception - { - UserModel managerTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("managerTenant"); - dataUser.usingUser(adminTenantUser).addUserToSite(managerTenantUser, siteModel, UserRole.SiteManager); - - restClient.authenticateUser(managerTenantUser); - RestNetworkModelsCollection networks = restClient.withCoreAPI().usingAuthUser().getNetworks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - networks.getOneRandomEntry().onModel().assertNetworkIsEnabled().and().field("id").is(managerTenantUser.getDomain().toLowerCase()); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Verify tenant collaborator user gets specific network with Rest API and response is not empty") - @Test(groups = {TestGroup.REST_API, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void collaboratorTenantChecksIfNetworkIsPresent() throws Exception - { - UserModel collaboratorTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("collaboratorTenant"); - dataUser.usingUser(adminTenantUser).addUserToSite(collaboratorTenantUser, siteModel, UserRole.SiteCollaborator); - - restClient.authenticateUser(collaboratorTenantUser); - RestNetworkModelsCollection networks = restClient.withCoreAPI().usingAuthUser().getNetworks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - networks.getOneRandomEntry().onModel().assertNetworkIsEnabled().and().field("id").is(collaboratorTenantUser.getDomain().toLowerCase()); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Verify tenant contributor user gets specific network with Rest API and response is not empty") - @Test(groups = {TestGroup.REST_API, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void contributorTenantChecksIfNetworkIsPresent() throws Exception - { - UserModel contributorTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("contributorTenant"); - dataUser.usingUser(adminTenantUser).addUserToSite(contributorTenantUser, siteModel, UserRole.SiteContributor); - - restClient.authenticateUser(contributorTenantUser); - RestNetworkModelsCollection networks = restClient.withCoreAPI().usingAuthUser().getNetworks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - networks.getOneRandomEntry().onModel().assertNetworkIsEnabled().and().field("id").is(contributorTenantUser.getDomain().toLowerCase()); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Verify tenant consumer user gets specific network with Rest API and response is not empty") - @Test(groups = {TestGroup.REST_API, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void consumerTenantChecksIfNetworkIsPresent() throws Exception - { - UserModel consumerTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("consumerTenant"); - dataUser.usingUser(adminTenantUser).addUserToSite(consumerTenantUser, siteModel, UserRole.SiteConsumer); - - restClient.authenticateUser(consumerTenantUser); - RestNetworkModelsCollection networks = restClient.withCoreAPI().usingAuthUser().getNetworks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - networks.getOneRandomEntry().onModel().assertNetworkIsEnabled().and().field("id").is(consumerTenantUser.getDomain().toLowerCase()); - } @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, description = "Get tenant user networks using invalid value for skipCount") @@ -175,19 +129,6 @@ public class RestGetNetworksForPersonTests extends RestTest networks.getOneRandomEntry().onModel().assertNetworkIsEnabled().and().field("id").is(adminTenantUser.getDomain().toLowerCase()); } - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Get tenant user networks and validate network entry") - @Test(groups = {TestGroup.REST_API, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void checkNetworkEntryTest() throws Exception - { - RestNetworkModelsCollection networks = restClient.authenticateUser(adminTenantUser).withCoreAPI().usingAuthUser().getNetworks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - networks.getOneRandomEntry().onModel().assertNetworkIsEnabled() - .and().field("id").is(adminTenantUser.getDomain().toLowerCase()) - .and().field("quotas").is("[]") - .and().field("homeNetwork").is("false"); - } - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, description = "Check default error schema for get networks for member") @Test(groups = { TestGroup.REST_API, TestGroup.REGRESSION, TestGroup.NETWORKS }) From b17dc941480650a0e33f6718998d9373a4b8b229 Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 11 Oct 2017 15:37:29 +0300 Subject: [PATCH 1252/1491] REPO-2755 / REPO-2251: fixed GetTaskCandidatesRegressionTests# getTaskCandidatesForCompletedTask --- .../GetTaskCandidatesRegressionTests.java | 30 ++++++------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/candidates/GetTaskCandidatesRegressionTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/candidates/GetTaskCandidatesRegressionTests.java index c5dd2551e..5e8d3d09f 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/candidates/GetTaskCandidatesRegressionTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/candidates/GetTaskCandidatesRegressionTests.java @@ -54,7 +54,10 @@ public class GetTaskCandidatesRegressionTests extends RestTest taskModel.setId("invalid-id"); restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).getTaskCandidates(); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalid-id")); + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalid-id")) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); } @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @@ -108,23 +111,6 @@ public class GetTaskCandidatesRegressionTests extends RestTest .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Check default error model schema for get task candidates") - public void getTaskCandidatesErrorSchemaCheck() throws Exception - { - taskModel = dataWorkflow.usingUser(userModel) - .usingSite(siteModel) - .usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); - taskModel.setId("invalid-id"); - restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).getTaskCandidates(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalid-id")) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } - @Bug(id="MNT-17438") @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, @@ -211,16 +197,18 @@ public class GetTaskCandidatesRegressionTests extends RestTest description = "Get task candidates by deleted candidate") public void getTaskCandidatesByDeletedCandidate() throws Exception { + UserModel newUser = dataUser.createRandomTestUser(); + dataGroup.addListOfUsersToGroup(group, newUser); taskModel = dataWorkflow.usingUser(userModel) .usingSite(siteModel) .usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); - restClient.authenticateUser(userModel1).withWorkflowAPI() + restClient.authenticateUser(newUser).withWorkflowAPI() .usingTask(taskModel).getTaskCandidates(); restClient.assertStatusCodeIs(HttpStatus.OK); - dataUser.usingAdmin().deleteUser(userModel1); + dataUser.usingAdmin().deleteUser(newUser); - restClient.authenticateUser(userModel1).withWorkflowAPI() + restClient.authenticateUser(newUser).withWorkflowAPI() .usingTask(taskModel).getTaskCandidates(); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) .assertLastError().containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) From 0a45e9d8513cdb116b93c0b3f60a5f2a7fa4b0e7 Mon Sep 17 00:00:00 2001 From: cagache Date: Mon, 16 Oct 2017 11:38:01 +0300 Subject: [PATCH 1253/1491] REPO-2755 / REPO-2251: deleted duplicate test and change wait for 60 sec until new tags are returned with while --- .../org/alfresco/rest/tags/GetTagsTests.java | 33 +++++++++---------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/tags/GetTagsTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagsTests.java index 2882b9ba1..ac453c9cb 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetTagsTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetTagsTests.java @@ -41,16 +41,26 @@ public class GetTagsTests extends RestTest document = dataContent.usingUser(adminUserModel).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); folder = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); + returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); + int noTagsBefore = returnedCollection.getEntries().size(); tagValue = RandomData.getRandomName("tag"); tagValue2 = RandomData.getRandomName("tag"); tagValue3 = RandomData.getRandomName("tag"); restClient.withCoreAPI().usingResource(document).addTags(tagValue, tagValue2); restClient.withCoreAPI().usingResource(folder).addTags(tagValue3); - - Utility.waitToLoopTime(60); + + returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); + int noTagsAfter = returnedCollection.getEntries().size(); + int retry = 0; + while(noTagsAfter < noTagsBefore + 3 && retry < 60) + { + Utility.waitToLoopTime(1); + returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); + noTagsAfter = returnedCollection.getEntries().size(); + retry++; + } } - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role gets tags using REST API and status code is OK (200)") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) public void getTagsWithManagerRole() throws Exception @@ -98,19 +108,7 @@ public class GetTagsTests extends RestTest .and().entriesListContains("tag", tagValue.toLowerCase()) .and().entriesListContains("tag", tagValue2.toLowerCase()); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify Admin user gets tags using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void getTagsWithAdminUser() throws Exception - { - restClient.authenticateUser(adminUserModel); - returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat().entriesListIsNotEmpty() - .and().entriesListContains("tag", tagValue.toLowerCase()) - .and().entriesListContains("tag", tagValue2.toLowerCase()); - } - + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Failed authentication get tags call returns status code 401 with Manager role") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) // @Bug(id="MNT-16904", description = "It fails only on environment with tenants") @@ -153,7 +151,8 @@ public class GetTagsTests extends RestTest returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); restClient.assertStatusCodeIs(HttpStatus.OK); returnedCollection.assertThat().entriesListIsNotEmpty() - .and().entriesListContains("tag", tagValue.toLowerCase()); + .and().entriesListContains("tag", tagValue.toLowerCase()) + .and().entriesListContains("tag", tagValue2.toLowerCase()); } @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, From 99731d736409811327c9719cf509e8c7c5ebc708 Mon Sep 17 00:00:00 2001 From: cagache Date: Mon, 16 Oct 2017 12:22:23 +0300 Subject: [PATCH 1254/1491] REPO-2755 / REPO-2251: deleted duplicate test --- .../preferences/GetPeoplePreferenceCoreTests.java | 9 +++++++-- .../preferences/GetPeoplePreferenceFullTests.java | 15 --------------- 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferenceCoreTests.java b/e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferenceCoreTests.java index c67870cec..4e02b7025 100644 --- a/e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferenceCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferenceCoreTests.java @@ -1,6 +1,7 @@ package org.alfresco.rest.people.preferences; import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.constants.PreferenceName; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; @@ -41,8 +42,12 @@ public class GetPeoplePreferenceCoreTests extends RestTest { restClient.authenticateUser(userModel).withCoreAPI().usingUser(new UserModel("invalidPersonID", "password")) .getPersonPreferenceInformation(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - restClient.assertLastError().containsSummary("The entity with id: invalidPersonID was not found"); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidPersonID")) + .statusCodeIs(HttpStatus.NOT_FOUND) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) diff --git a/e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferenceFullTests.java b/e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferenceFullTests.java index 647c562e8..5c874d427 100644 --- a/e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferenceFullTests.java +++ b/e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferenceFullTests.java @@ -34,21 +34,6 @@ public class GetPeoplePreferenceFullTests extends RestTest dataSite.usingUser(userModel).usingSite(siteModel).addSiteToFavorites(); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, - description = "Check default error schema in case of failure") - public void checkDefaultErrorSchema() throws Exception - { - restClient.authenticateUser(userModel).withCoreAPI().usingUser(new UserModel("invalidPersonID", "password")) - .getPersonPreferenceInformation(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidPersonID")) - .statusCodeIs(HttpStatus.NOT_FOUND) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY); - } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Check that properties parameter is applied") From 5b19cc559ebb03ff5d8bd7ddc94df18fce5ab38d Mon Sep 17 00:00:00 2001 From: Alexandru-Eusebiu Epure Date: Mon, 16 Oct 2017 17:29:01 +0300 Subject: [PATCH 1255/1491] REPO-2251 : REST API: Reliable TAS REST API & CMIS build plans (5.2.N & 5.1.N) Refactor all Network tests: Group network tests into related class (removed from previous class designed for each endpoint) Add abstract class NetworkDataPrep on which are created tenants and other resources shared for these tests (high cost) NOTE: Some test still need fixing. --- .../org/alfresco/rest/NetworkDataPrep.java | 66 ++ .../rest/favorites/AddFavoriteSiteTests.java | 83 +-- .../rest/favorites/AddFavoritesTests.java | 17 - .../favorites/DeleteFavoriteSiteTests.java | 67 -- .../rest/favorites/DeleteFavoriteTests.java | 75 +-- .../rest/favorites/FavoritesNetworkTests.java | 294 +++++++++ .../rest/favorites/GetFavoriteSitesTests.java | 1 - .../rest/favorites/GetFavoriteTests.java | 38 -- .../rest/favorites/GetFavoritesTests.java | 20 - .../RestGetNetworkForPersonTests.java | 21 +- .../rest/networks/RestGetNetworkTests.java | 32 +- .../RestGetNetworksForPersonTests.java | 20 +- .../rest/sites/SitesNetworkTests.java | 83 +++ .../AddSiteMembershipRequestTests.java | 31 - .../DeleteSiteMembershipRequestTests.java | 2 - .../GetSiteMembershipRequestTests.java | 48 -- .../WorkflowNetworkDeploymentsTests.java | 124 ++++ ...orkflowNetworkProcessDefinitionsTests.java | 221 +++++++ .../WorkflowNetworkProcessesTests.java | 529 ++++++++++++++++ .../workflow/WorkflowNetworkTasksTests.java | 575 ++++++++++++++++++ .../deployments/GetDeploymentCoreTests.java | 38 +- .../deployments/GetDeploymentFullTests.java | 23 - .../deployments/GetDeploymentsCoreTests.java | 51 -- .../deployments/GetDeploymentsFullTests.java | 17 - .../GetDeploymentsSanityTests.java | 13 +- .../GetProcessDefinitionCoreTests.java | 37 +- .../GetProcessDefinitionFullTests.java | 23 - .../GetProcessDefinitionImageCoreTests.java | 39 +- .../GetProcessDefinitionImageFullTests.java | 20 - ...cessDefinitionStartFormModelCoreTests.java | 20 +- ...cessDefinitionStartFormModelFullTests.java | 21 - ...ssDefinitionStartFormModelSanityTests.java | 16 +- .../GetProcessDefinitionsCoreTests.java | 19 - .../GetProcessDefinitionsFullTests.java | 19 - .../GetProcessDefinitionsSanityTests.java | 14 +- .../processes/AddProcessFullTests.java | 44 -- .../processes/AddProcessSanityTests.java | 22 - .../processes/GetProcessCoreTests.java | 62 +- .../processes/GetProcessFullTests.java | 22 - .../processes/GetProcessesCoreTests.java | 20 +- .../processes/GetProcessesFullTests.java | 18 - .../items/AddProcessItemCoreTests.java | 100 +-- .../items/DeleteProcessItemFullTests.java | 56 +- .../items/GetProcessItemsFullTests.java | 56 +- .../items/GetProcessItemsSanityTests.java | 25 +- .../tasks/GetProcessTasksCoreTests.java | 44 +- .../AddProcessVariableCoreTests.java | 24 +- .../AddProcessVariableSanityTests.java | 24 +- .../AddProcessVariablesCoreTests.java | 3 +- .../AddProcessVariablesFullTests.java | 63 +- .../AddProcessVariablesSanityTests.java | 56 +- .../DeleteProcessVariableFullTests.java | 61 +- .../GetProcessVariablesCoreTests.java | 35 +- .../workflow/tasks/GetTaskFormModelTests.java | 23 - .../rest/workflow/tasks/GetTaskTests.java | 68 +-- .../rest/workflow/tasks/GetTasksTests.java | 72 +-- .../rest/workflow/tasks/UpdateTaskTests.java | 100 +-- .../tasks/items/AddTaskItemTestsBulk1.java | 79 +-- .../tasks/items/AddTaskItemTestsBulk2.java | 1 - .../tasks/items/AddTaskItemTestsBulk3.java | 64 +- .../items/GetTaskItemsRegressionTests.java | 66 +- .../tasks/items/GetTaskItemsSanityTests.java | 30 - .../variables/AddTaskVariablesTestsBulk3.java | 118 ---- .../variables/DeleteTaskVariableTests.java | 56 -- .../variables/GetTaskVariablesTests.java | 43 -- .../UpdateTaskVariableTestsBulk1.java | 31 - .../UpdateTaskVariableTestsBulk2.java | 1 - .../UpdateTaskVariableTestsBulk3.java | 34 -- 68 files changed, 1977 insertions(+), 2261 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/NetworkDataPrep.java create mode 100644 e2e-test/java/org/alfresco/rest/favorites/FavoritesNetworkTests.java create mode 100644 e2e-test/java/org/alfresco/rest/sites/SitesNetworkTests.java create mode 100644 e2e-test/java/org/alfresco/rest/workflow/WorkflowNetworkDeploymentsTests.java create mode 100644 e2e-test/java/org/alfresco/rest/workflow/WorkflowNetworkProcessDefinitionsTests.java create mode 100644 e2e-test/java/org/alfresco/rest/workflow/WorkflowNetworkProcessesTests.java create mode 100644 e2e-test/java/org/alfresco/rest/workflow/WorkflowNetworkTasksTests.java diff --git a/e2e-test/java/org/alfresco/rest/NetworkDataPrep.java b/e2e-test/java/org/alfresco/rest/NetworkDataPrep.java new file mode 100644 index 000000000..f3e6f894c --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/NetworkDataPrep.java @@ -0,0 +1,66 @@ +package org.alfresco.rest; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.model.RestNetworkModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; + +public abstract class NetworkDataPrep extends RestTest +{ + protected static UserModel adminUserModel; + protected static UserModel adminTenantUser, secondAdminTenantUser; + protected static UserModel tenantUser, secondTenantUser, differentNetworkTenantUser; + protected static UserModel tenantUserWithBad; + protected static UserModel userModel; + protected static RestNetworkModel restNetworkModel; + protected static String tenantDomain; + protected static SiteModel siteModel; + protected static FileModel document, document2; + private static boolean isInitialized = false; + + public void init() + { + if(isInitialized) + { + + } + else + { + isInitialized = true; + try + { + initialization(); + } + catch (Exception e) + { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + + public void initialization() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + //create first tenant Admin User. + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUserModel); + restClient.usingTenant().createTenant(adminTenantUser); + + tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + secondTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("sTenant"); + //create second tenant Admin User. + secondAdminTenantUser = UserModel.getAdminTenantUser(); + restClient.usingTenant().createTenant(secondAdminTenantUser); + + tenantDomain = tenantUser.getDomain(); + differentNetworkTenantUser = dataUser.usingUser(secondAdminTenantUser).createUserWithTenant("dTenant"); + + userModel = dataUser.createRandomTestUser(); + + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + document2 = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + } +} diff --git a/e2e-test/java/org/alfresco/rest/favorites/AddFavoriteSiteTests.java b/e2e-test/java/org/alfresco/rest/favorites/AddFavoriteSiteTests.java index f2266a93b..efc505218 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/AddFavoriteSiteTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/AddFavoriteSiteTests.java @@ -3,10 +3,19 @@ package org.alfresco.rest.favorites; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; import org.alfresco.rest.core.RestRequest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.*; +import org.alfresco.rest.model.RestCommentModel; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestFavoriteSiteModel; +import org.alfresco.rest.model.RestPersonFavoritesModel; +import org.alfresco.rest.model.RestPersonFavoritesModelsCollection; +import org.alfresco.rest.model.RestTagModel; import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.model.*; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.LinkModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; @@ -17,7 +26,7 @@ import org.testng.annotations.Test; public class AddFavoriteSiteTests extends RestTest { - private UserModel userModel, adminUser, adminTenantUser, tenantUser; + private UserModel userModel, adminUser; private SiteModel publicSite, privateSite, moderatedSite; private FileModel document; private FolderModel folder; @@ -475,70 +484,4 @@ public class AddFavoriteSiteTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, site.getId().split("/")[3])); } - - @Bug(id="MNT-16904") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.NETWORKS, TestGroup.REGRESSION}) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Verify tenant user is not able to delete favorites using an invalid network ID - status code (401)") - public void tenantIsNotAbleToDeleteFavoriteSiteWithInvalidNetworkID() throws Exception - { - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser); - tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - publicSite = dataSite.usingUser(tenantUser).createPublicRandomSite(); - - restClient.authenticateUser(tenantUser).withCoreAPI(); - tenantUser.setDomain("invalidNetwork"); - - restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(publicSite); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.NETWORKS, TestGroup.REGRESSION}) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE}, executionType = ExecutionType.REGRESSION, - description = "Verify tenant user is able to add to favorites his site and status code is (201)") - public void tenantAddFavoriteSiteValidNetwork() throws Exception - { - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser); - tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - publicSite = dataSite.usingUser(tenantUser).createPublicRandomSite(); - - restClient.authenticateUser(tenantUser).withCoreAPI(); - tenantUser.setDomain(tenantUser.getDomain()); - - restClient.withCoreAPI() - .usingAuthUser().addSiteToFavorites(publicSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.withCoreAPI().usingAuthUser().getFavorites() - .assertThat() - .entriesListContains("targetGuid", publicSite.getGuidWithoutVersion()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.NETWORKS, TestGroup.REGRESSION}) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE}, executionType = ExecutionType.REGRESSION, - description = "Verify tenant user is able to add to favorites a site created by admin tenant - same network and status code is (201)") - public void tenantUserIsAbleToAddFavoriteSiteAddedByAdminSameNetwork() throws Exception - { - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser); - tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - publicSite = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); - - restClient.authenticateUser(tenantUser).withCoreAPI(); - tenantUser.setDomain(adminTenantUser.getDomain()); - - restClient.withCoreAPI().usingAuthUser().addFavoriteSite(publicSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.withCoreAPI().usingAuthUser().getFavorites() - .assertThat() - .entriesListContains("targetGuid", publicSite.getGuidWithoutVersion()); - } } diff --git a/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesTests.java b/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesTests.java index 4c4c7a642..e135bfac9 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesTests.java @@ -432,23 +432,6 @@ public class AddFavoritesTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE); } - @Bug(id = "MNT-16904") - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify the post favorites request when network id is invalid for tenant user") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION, TestGroup.NETWORKS}) - public void addFavoriteSitesWhenNetworkIdIsInvalid() throws Exception - { - UserModel adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUserModel); - restClient.usingTenant().createTenant(adminTenantUser); - UserModel tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - - tenantUser.setDomain("invalidNetwork"); - restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify the response of favorite a sie with empty body at request") @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) diff --git a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteSiteTests.java b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteSiteTests.java index c9b52a4bd..9292c361d 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteSiteTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteSiteTests.java @@ -1,7 +1,6 @@ package org.alfresco.rest.favorites; 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; @@ -363,70 +362,4 @@ public class DeleteFavoriteSiteTests extends RestTest .assertLastError() .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } - - @Bug(id="MNT-16904") - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE}, executionType = ExecutionType.REGRESSION, - description = "Verify tenant user is not able to delete favorites using an invalid network ID") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.NETWORKS, TestGroup.REGRESSION }) - public void tenantIsNotAbleToDeleteFavoriteSiteWithInvalidNetworkID() throws Exception - { - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUserModel).usingTenant().createTenant(adminTenantUser); - tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - SiteModel siteModel = dataSite.usingUser(tenantUser).createPublicRandomSite(); - siteModel.setGuid(restClient.authenticateUser(tenantUser).withCoreAPI().usingSite(siteModel).getSite().getGuid()); - restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - tenantUser.setDomain("invalidNetwork"); - - restClient.withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE}, executionType = ExecutionType.REGRESSION, - description = "Verify tenant user deletes favorites site and status code is (204)") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.NETWORKS, TestGroup.REGRESSION }) - public void tenantDeleteFavoriteSiteValidNetwork() throws Exception - { - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUserModel).usingTenant().createTenant(adminTenantUser); - tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - SiteModel siteModel = dataSite.usingUser(tenantUser).createPublicRandomSite(); - siteModel.setGuid(restClient.authenticateUser(tenantUser).withCoreAPI().usingSite(siteModel).getSite().getGuid()); - restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - tenantUser.setDomain(tenantUser.getDomain()); - - restClient.withCoreAPI() - .usingAuthUser().removeFavoriteSite(siteModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingAuthUser().getFavorites() - .assertThat() - .entriesListDoesNotContain("targetGuid", siteModel.getGuidWithoutVersion()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE}, executionType = ExecutionType.REGRESSION, - description = "Verify tenant user deletes favorites site created by admin tenant - same network and status code is (204)") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.NETWORKS, TestGroup.REGRESSION }) - public void tenantUserIsAbleToDeleteFavoriteSiteAddedByAdminSameNetwork() throws Exception - { - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUserModel).usingTenant().createTenant(adminTenantUser); - tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - SiteModel siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); - siteModel.setGuid(restClient.authenticateUser(adminTenantUser).withCoreAPI().usingSite(siteModel).getSite().getGuid()); - restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - tenantUser.setDomain(adminTenantUser.getDomain()); - - restClient.withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingAuthUser().getFavorites() - .assertThat() - .entriesListDoesNotContain("targetGuid", siteModel.getGuidWithoutVersion()); - } } diff --git a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteTests.java b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteTests.java index 5c3bb952a..172724298 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteTests.java @@ -2,11 +2,14 @@ package org.alfresco.rest.favorites; import org.alfresco.dataprep.CMISUtil; 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.model.*; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; @@ -406,72 +409,4 @@ public class DeleteFavoriteTests extends RestTest .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) .stackTraceIs(RestErrorModel.STACKTRACE); } - - @Bug(id="MNT-16904") - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify tenant user is not able to delete favorites using an invalid network ID") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES,TestGroup.NETWORKS, TestGroup.REGRESSION }) - public void tenantIsNotAbleToDeleteFavoriteSiteWithInvalidNetworkID() throws Exception - { - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUserModel).usingTenant().createTenant(adminTenantUser); - tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - siteModel = dataSite.usingUser(tenantUser).createPublicRandomSite(); - siteModel.setGuid(restClient.authenticateUser(tenantUser).withCoreAPI().usingSite(siteModel).getSite().getGuid()); - restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - tenantUser.setDomain("invalidNetwork"); - - restClient.withCoreAPI() - .usingAuthUser().deleteSiteFromFavorites(siteModel) - .assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES}, executionType = ExecutionType.REGRESSION, - description = "Verify tenant user deletes favorites site and status code is (204)") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES,TestGroup.NETWORKS, TestGroup.REGRESSION }) - public void tenantDeleteFavoriteSiteValidNetwork() throws Exception - { - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUserModel).usingTenant().createTenant(adminTenantUser); - tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - siteModel = dataSite.usingUser(tenantUser).createPublicRandomSite(); - siteModel.setGuid(restClient.authenticateUser(tenantUser).withCoreAPI().usingSite(siteModel).getSite().getGuid()); - restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - tenantUser.setDomain(tenantUser.getDomain()); - - restClient.withCoreAPI() - .usingAuthUser().deleteSiteFromFavorites(siteModel) - .assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingAuthUser().getFavorites() - .assertThat() - .entriesListDoesNotContain("targetGuid", siteModel.getGuidWithoutVersion()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES}, executionType = ExecutionType.REGRESSION, - description = "Verify tenant user deletes favorites site created by admin tenant - same network and status code is (204)") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES,TestGroup.NETWORKS, TestGroup.REGRESSION }) - public void tenantUserIsAbleToDeleteFavoriteSiteAddedByAdminSameNetwork() throws Exception - { - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUserModel).usingTenant().createTenant(adminTenantUser); - tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); - siteModel.setGuid(restClient.authenticateUser(adminTenantUser).withCoreAPI().usingSite(siteModel).getSite().getGuid()); - restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - tenantUser.setDomain(adminTenantUser.getDomain()); - - restClient.withCoreAPI() - .usingAuthUser().deleteSiteFromFavorites(siteModel) - .assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingAuthUser().getFavorites() - .assertThat() - .entriesListDoesNotContain("targetGuid", siteModel.getGuidWithoutVersion()); - } } diff --git a/e2e-test/java/org/alfresco/rest/favorites/FavoritesNetworkTests.java b/e2e-test/java/org/alfresco/rest/favorites/FavoritesNetworkTests.java new file mode 100644 index 000000000..34464acd1 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/favorites/FavoritesNetworkTests.java @@ -0,0 +1,294 @@ +package org.alfresco.rest.favorites; + +import org.alfresco.rest.NetworkDataPrep; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class FavoritesNetworkTests extends NetworkDataPrep +{ + private SiteModel publicSite; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + init(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.NETWORKS, TestGroup.REGRESSION}) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE}, executionType = ExecutionType.REGRESSION, + description = "Verify tenant user is able to add to favorites his site and status code is (201)") + public void tenantAddFavoriteSiteValidNetwork() throws Exception + { + publicSite = dataSite.usingUser(tenantUser).createPublicRandomSite(); + + restClient.authenticateUser(tenantUser).withCoreAPI(); + + restClient.withCoreAPI() + .usingAuthUser().addSiteToFavorites(publicSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.withCoreAPI().usingAuthUser().getFavorites() + .assertThat() + .entriesListContains("targetGuid", publicSite.getGuidWithoutVersion()); + } + + @Bug(id="MNT-16904") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.NETWORKS, TestGroup.REGRESSION}) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify tenant user is not able to add favorites using an invalid network ID - status code (401)") + public void tenantIsNotAbleToAddFavoriteSiteWithInvalidNetworkID() throws Exception + { + publicSite = dataSite.usingUser(tenantUser).createPublicRandomSite(); + + restClient.authenticateUser(tenantUser).withCoreAPI(); + String domain = tenantUser.getDomain(); + try + { + tenantUser.setDomain("invalidNetwork"); + + restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(publicSite); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + finally + { + tenantUser.setDomain(domain); + } + } + + @Bug(id="MNT-16904") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE}, executionType = ExecutionType.REGRESSION, + description = "Verify tenant user is not able to remove favorites using an invalid network ID") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.NETWORKS, TestGroup.REGRESSION }) + public void tenantIsNotAbleToRemoveFavoriteSiteWithInvalidNetworkID() throws Exception + { + SiteModel siteModel = dataSite.usingUser(tenantUser).createPublicRandomSite(); + + restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + String domain = tenantUser.getDomain(); + try + { + tenantUser.setDomain("invalidNetwork"); + + restClient.withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + finally + { + tenantUser.setDomain(domain); + } + } + + @Bug(id="MNT-16904") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify tenant user is not able to delete favorites using an invalid network ID") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES,TestGroup.NETWORKS, TestGroup.REGRESSION }) + public void tenantIsNotAbleToDeleteFavoriteSiteWithInvalidNetworkID() throws Exception + { + siteModel = dataSite.usingUser(tenantUser).createPublicRandomSite(); + restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + String domain = tenantUser.getDomain(); + try + { + tenantUser.setDomain("invalidNetwork"); + + restClient.withCoreAPI() + .usingAuthUser().deleteSiteFromFavorites(siteModel) + .assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + finally + { + tenantUser.setDomain(domain); + } + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.NETWORKS, TestGroup.REGRESSION}) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE}, executionType = ExecutionType.REGRESSION, + description = "Verify tenant user is able to add to favorites a site created by admin tenant - same network and status code is (201)") + public void tenantUserIsAbleToAddFavoriteSiteAddedByAdminSameNetwork() throws Exception + { + publicSite = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); + + restClient.authenticateUser(tenantUser).withCoreAPI(); + tenantUser.setDomain(adminTenantUser.getDomain()); + + restClient.withCoreAPI().usingAuthUser().addFavoriteSite(publicSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.withCoreAPI().usingAuthUser().getFavorites() + .assertThat() + .entriesListContains("targetGuid", publicSite.getGuidWithoutVersion()); + } + + @Bug(id = "MNT-16904") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify the get favorites request when network id is invalid for tenant user") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION, TestGroup.NETWORKS}) + public void getFavoriteSitesWhenNetworkIdIsInvalid() throws Exception + { + SiteModel firstSiteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + + restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); + + String domain = tenantUser.getDomain(); + try + { + tenantUser.setDomain("invalidNetwork"); + restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + finally + { + tenantUser.setDomain(domain); + } + } + + @Bug(id = "MNT-16904") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify the post favorites request when network id is invalid for tenant user") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION, TestGroup.NETWORKS}) + public void addFavoriteSitesWhenNetworkIdIsInvalid() throws Exception + { + String domain = tenantUser.getDomain(); + try + { + tenantUser.setDomain("invalidNetwork"); + restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + finally{ + tenantUser.setDomain(domain); + } + } + + @Bug(id = "MNT-16904") + @TestRail(section = { TestGroup.REST_API, + TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify the get favorite request for invalid network id") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void getFavoriteSiteWithInvalidNetworkId() throws Exception + { + siteModel = dataSite.usingUser(tenantUser).createPublicRandomSite(); + restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + + String domain = tenantUser.getDomain(); + try + { + tenantUser.setDomain("invalidNetwork"); + restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().getFavorite(siteModel.getGuid()); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + finally + { + tenantUser.setDomain(domain); + } + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify the get favorite request with tenant user") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void getFavoriteSiteWithTenantUser() throws Exception + { + siteModel = dataSite.usingUser(tenantUser).createPublicRandomSite(); + restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + + restClient.withCoreAPI().usingAuthUser().getFavorite(siteModel.getGuid()); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE}, executionType = ExecutionType.REGRESSION, + description = "Verify tenant user deletes favorites site and status code is (204)") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.NETWORKS, TestGroup.REGRESSION }) + public void tenantRemoveFavoriteSiteValidNetwork() throws Exception + { + SiteModel siteModel = dataSite.usingUser(tenantUser).createPublicRandomSite(); + restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + + restClient.withCoreAPI() + .usingAuthUser().removeFavoriteSite(siteModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingAuthUser().getFavorites() + .assertThat() + .entriesListDoesNotContain("targetGuid", siteModel.getGuidWithoutVersion()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES}, executionType = ExecutionType.REGRESSION, + description = "Verify tenant user deletes favorites site and status code is (204)") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES,TestGroup.NETWORKS, TestGroup.REGRESSION }) + public void tenantDeleteFavoriteSiteValidNetwork() throws Exception + { + siteModel = dataSite.usingUser(tenantUser).createPublicRandomSite(); + + restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + + restClient.withCoreAPI() + .usingAuthUser().deleteSiteFromFavorites(siteModel) + .assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingAuthUser().getFavorites() + .assertThat() + .entriesListDoesNotContain("targetGuid", siteModel.getGuidWithoutVersion()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE}, executionType = ExecutionType.REGRESSION, + description = "Verify tenant user remove favorites site created by admin tenant - same network and status code is (204)") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.NETWORKS, TestGroup.REGRESSION }) + public void tenantUserIsAbleToRemoveFavoriteSiteAddedByAdminSameNetwork() throws Exception + { + SiteModel siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); + + restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + tenantUser.setDomain(adminTenantUser.getDomain()); + + restClient.withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingAuthUser().getFavorites() + .assertThat() + .entriesListDoesNotContain("targetGuid", siteModel.getGuidWithoutVersion()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES}, executionType = ExecutionType.REGRESSION, + description = "Verify tenant user deletes favorites site created by admin tenant - same network and status code is (204)") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES,TestGroup.NETWORKS, TestGroup.REGRESSION }) + public void tenantUserIsAbleToDeleteFavoriteSiteAddedByAdminSameNetwork() throws Exception + { + siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); + + restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + tenantUser.setDomain(adminTenantUser.getDomain()); + + restClient.withCoreAPI() + .usingAuthUser().deleteSiteFromFavorites(siteModel) + .assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingAuthUser().getFavorites() + .assertThat() + .entriesListDoesNotContain("targetGuid", siteModel.getGuidWithoutVersion()); + } +} diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSitesTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSitesTests.java index d656d44f0..bc9b0dda8 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSitesTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSitesTests.java @@ -10,7 +10,6 @@ import org.alfresco.utility.data.RandomData; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteTests.java index dadce6174..c5ededc33 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteTests.java @@ -3,7 +3,6 @@ package org.alfresco.rest.favorites; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.SiteService; import org.alfresco.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestPersonFavoritesModel; import org.alfresco.utility.constants.UserRole; @@ -478,41 +477,4 @@ public class GetFavoriteTests extends RestTest .and().field("target.folder.modifiedBy").is(adminUserModel.getUsername()) .and().field("target.folder.id").is(folderModel.getNodeRef()); } - - @Bug(id = "MNT-16904") - @TestRail(section = { TestGroup.REST_API, - TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify the get favorite request for invalid network id") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void getFavoriteSiteWithInvalidNetworkId() throws Exception - { - UserModel adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUserModel); - restClient.usingTenant().createTenant(adminTenantUser); - UserModel tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - - siteModel = dataSite.usingUser(tenantUser).createPublicRandomSite(); - restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - - tenantUser.setDomain("invalidNetwork"); - restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().getFavorite(siteModel.getGuid()); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify the get favorite request with tenant user") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void getFavoriteSiteWithTenantUser() throws Exception - { - UserModel adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUserModel).usingTenant().createTenant(adminTenantUser); - UserModel tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - - siteModel = dataSite.usingUser(tenantUser).createPublicRandomSite(); - restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - - restClient.withCoreAPI().usingAuthUser().getFavorite(siteModel.getGuid()); - restClient.assertStatusCodeIs(HttpStatus.OK); - } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesTests.java index fbb9672a0..3009cc03c 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesTests.java @@ -2,7 +2,6 @@ package org.alfresco.rest.favorites; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestPersonFavoritesModel; import org.alfresco.rest.model.RestPersonFavoritesModelsCollection; @@ -14,7 +13,6 @@ import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -527,24 +525,6 @@ public class GetFavoritesTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, " ")); } - @Bug(id = "MNT-16904") - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify the get favorites request when network id is invalid for tenant user") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION, TestGroup.NETWORKS}) - public void getFavoriteSitesWhenNetworkIdIsInvalid() throws Exception - { - UserModel adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUserModel); - restClient.usingTenant().createTenant(adminTenantUser); - UserModel tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); - - tenantUser.setDomain("invalidNetwork"); - restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify the get favorites request for a high value for skipCount parameter") @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonTests.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonTests.java index 7119f9379..384edd07f 100644 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonTests.java +++ b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonTests.java @@ -1,8 +1,9 @@ package org.alfresco.rest.networks; -import org.alfresco.rest.RestTest; +import java.util.ArrayList; + +import org.alfresco.rest.NetworkDataPrep; import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestNetworkModel; import org.alfresco.rest.model.RestNetworkQuotaModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; @@ -13,28 +14,16 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import java.util.ArrayList; - /** * Tests for /people/{personId}/networks */ -public class RestGetNetworkForPersonTests extends RestTest +public class RestGetNetworkForPersonTests extends NetworkDataPrep { - UserModel adminUserModel, secondAdminTenantUser; - UserModel adminTenantUser; - UserModel tenantUser; - RestNetworkModel restNetworkModel; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception { - adminUserModel = dataUser.getAdminUser(); - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUserModel); - restClient.usingTenant().createTenant(adminTenantUser); - tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - secondAdminTenantUser = UserModel.getAdminTenantUser(); - restClient.usingTenant().createTenant(secondAdminTenantUser); + init(); } @Bug(id = "MNT-16904") diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkTests.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkTests.java index 689b9011b..e872aa0da 100644 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkTests.java +++ b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkTests.java @@ -1,10 +1,8 @@ package org.alfresco.rest.networks; -import org.alfresco.rest.RestTest; +import org.alfresco.rest.NetworkDataPrep; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestNetworkModel; -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.report.Bug; @@ -20,24 +18,12 @@ import org.testng.annotations.Test; /** * Created by Cristina Axinte on 9/26/2016. */ -public class RestGetNetworkTests extends RestTest +public class RestGetNetworkTests extends NetworkDataPrep { - UserModel adminTenantUser; - UserModel adminAnotherTenantUser; - UserModel tenantUser; - UserModel adminuser; - @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception { - adminuser = dataUser.getAdminUser(); - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminuser); - restClient.usingTenant().createTenant(adminTenantUser); - adminAnotherTenantUser = UserModel.getAdminTenantUser(); - restClient.usingTenant().createTenant(adminAnotherTenantUser); - - tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + init(); } @Bug(id = "MNT-16904") @@ -69,7 +55,7 @@ public class RestGetNetworkTests extends RestTest public void adminTenantChecksIfAnotherExistingNetworkIsForbidden() throws Exception { restClient.authenticateUser(adminTenantUser); - restClient.withCoreAPI().usingNetworks().getNetwork(adminAnotherTenantUser); + restClient.withCoreAPI().usingNetworks().getNetwork(secondAdminTenantUser); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); } @@ -99,7 +85,7 @@ public class RestGetNetworkTests extends RestTest public void userTenantChecksIfAnotherExistingNetworkIsForbidden() throws Exception { restClient.authenticateUser(tenantUser); - restClient.withCoreAPI().usingNetworks().getNetwork(adminAnotherTenantUser); + restClient.withCoreAPI().usingNetworks().getNetwork(secondAdminTenantUser); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); } @@ -109,10 +95,10 @@ public class RestGetNetworkTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) public void adminTenantGetsInvalidNetwork() throws Exception { - restClient.authenticateUser(adminAnotherTenantUser); - adminAnotherTenantUser.setDomain("tenant.@%"); + restClient.authenticateUser(secondAdminTenantUser); + secondAdminTenantUser.setDomain("tenant.@%"); - restClient.withCoreAPI().usingNetworks().getNetwork(adminAnotherTenantUser); + restClient.withCoreAPI().usingNetworks().getNetwork(secondAdminTenantUser); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) .assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) .containsSummary(String.format(RestErrorModel.UNEXPECTED_TENANT, adminTenantUser.getDomain(), "@")) @@ -126,7 +112,7 @@ public class RestGetNetworkTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) public void adminUserGetsExistingNetwork() throws Exception { - RestNetworkModel restNetworkModel = restClient.authenticateUser(adminuser).withCoreAPI().usingNetworks().getNetwork(adminTenantUser); + RestNetworkModel restNetworkModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingNetworks().getNetwork(adminTenantUser); restClient.assertStatusCodeIs(HttpStatus.OK); restNetworkModel.assertThat().fieldsCount().is("1"); restNetworkModel.assertThat().field("id").is(adminTenantUser.getDomain()) diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonTests.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonTests.java index c5d90c144..1b0c2ca94 100644 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonTests.java +++ b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonTests.java @@ -1,10 +1,8 @@ package org.alfresco.rest.networks; -import org.alfresco.rest.RestTest; +import org.alfresco.rest.NetworkDataPrep; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestNetworkModelsCollection; -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.report.Bug; @@ -14,24 +12,14 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -public class RestGetNetworksForPersonTests extends RestTest +public class RestGetNetworksForPersonTests extends NetworkDataPrep { - private UserModel adminUserModel, secondAdminTenantUser; - private UserModel adminTenantUser; - private UserModel tenantUser; - @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception { - adminUserModel = dataUser.getAdminUser(); - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUserModel); - restClient.usingTenant().createTenant(adminTenantUser); - tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - secondAdminTenantUser = UserModel.getAdminTenantUser(); - restClient.usingTenant().createTenant(secondAdminTenantUser); + init(); } - + @Bug(id = "MNT-16904") @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify non existing user gets another exisiting network with Rest API and checks the unauthorized status") diff --git a/e2e-test/java/org/alfresco/rest/sites/SitesNetworkTests.java b/e2e-test/java/org/alfresco/rest/sites/SitesNetworkTests.java new file mode 100644 index 000000000..4605a44cf --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/sites/SitesNetworkTests.java @@ -0,0 +1,83 @@ +package org.alfresco.rest.sites; + +import org.alfresco.dataprep.SiteService; +import org.alfresco.rest.NetworkDataPrep; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestSiteMembershipRequestModel; +import org.alfresco.utility.model.SiteModel; +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.BeforeClass; +import org.testng.annotations.Test; + +public class SitesNetworkTests extends NetworkDataPrep +{ + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + init(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION, TestGroup.NETWORKS }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify create site membership request returns status code 404 when personId is not member of the domain.") + public void addSiteMembershipRequestWhenPersonIdIsNotInTheDomain() throws Exception + { + restClient.authenticateUser(adminTenantUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(siteModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, adminTenantUser.getUsername().toLowerCase(), siteModel.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION, TestGroup.NETWORKS }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify create site membership request returns status code 200 with tenant.") + public void addSiteMembershipRequestWithTenant() throws Exception + { + SiteModel tenantPublicSite = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); + RestSiteMembershipRequestModel siteMembershipRequest = restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(tenantPublicSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + siteMembershipRequest.assertThat().field("id").is(tenantPublicSite.getId()) + .assertThat().field("site").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Add process item using by admin in other network.") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void getSiteMembershipRequestByAdminInOtherNetwork() throws Exception + { + SiteModel moderatedSite = dataSite.usingUser(secondAdminTenantUser).createModeratedRandomSite(); + + restClient.authenticateUser(adminTenantUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + restClient.authenticateUser(secondAdminTenantUser).withCoreAPI().usingAuthUser().getSiteMembershipRequest(moderatedSite); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, secondAdminTenantUser.getUsername().toLowerCase(), moderatedSite.getId())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Add process item using by the admin in same network.") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void getSiteMembershipRequestByAdminSameNetwork() throws Exception + { + SiteModel moderatedSite = dataSite.usingUser(adminTenantUser).createModeratedRandomSite(); + restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + + RestSiteMembershipRequestModel returnedModel = restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().getSiteMembershipRequest(moderatedSite); + + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedModel.assertThat().field("id").is(moderatedSite.getId()) + .and().field("message").is("Please accept me") + .and().field("site.title").is(moderatedSite.getTitle()) + .and().field("site.visibility").is(SiteService.Visibility.MODERATED.toString()) + .and().field("site.guid").isNotEmpty() + .and().field("site.description").is(moderatedSite.getDescription()) + .and().field("site.preset").is("site-dashboard"); + } +} diff --git a/e2e-test/java/org/alfresco/rest/sites/membershipRequests/AddSiteMembershipRequestTests.java b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/AddSiteMembershipRequestTests.java index 793a6ffd3..296d3ee51 100644 --- a/e2e-test/java/org/alfresco/rest/sites/membershipRequests/AddSiteMembershipRequestTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/AddSiteMembershipRequestTests.java @@ -2,7 +2,6 @@ package org.alfresco.rest.sites.membershipRequests; import org.alfresco.dataprep.SiteService; import org.alfresco.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestSiteEntry; import org.alfresco.rest.model.RestSiteMembershipRequestModel; @@ -389,36 +388,6 @@ public class AddSiteMembershipRequestTests extends RestTest siteMembershipRequests.assertThat().entriesListContains("id", anotherModeratedSite.getId()); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION, TestGroup.NETWORKS }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify create site membership request returns status code 404 when personId is not member of the domain.") - public void addSiteMembershipRequestWhenPersonIdIsNotInTheDomain() throws Exception - { - UserModel adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser) - .usingTenant().createTenant(adminTenantUser); - restClient.authenticateUser(adminTenantUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(publicSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, adminTenantUser.getUsername().toLowerCase(), publicSite.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION, TestGroup.NETWORKS }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify create site membership request returns status code 200 with tenant.") - public void addSiteMembershipRequestWithTenant() throws Exception - { - UserModel adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser) - .usingTenant().createTenant(adminTenantUser); - UserModel tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - - SiteModel tenantPublicSite = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); - siteMembershipRequest = restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(tenantPublicSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - siteMembershipRequest.assertThat().field("id").is(tenantPublicSite.getId()) - .assertThat().field("site").isNotEmpty(); - } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site membership request is automatically rejected when a site is switched from moderated to private") diff --git a/e2e-test/java/org/alfresco/rest/sites/membershipRequests/DeleteSiteMembershipRequestTests.java b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/DeleteSiteMembershipRequestTests.java index e3d7e1059..c1da58fb1 100644 --- a/e2e-test/java/org/alfresco/rest/sites/membershipRequests/DeleteSiteMembershipRequestTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/DeleteSiteMembershipRequestTests.java @@ -2,14 +2,12 @@ package org.alfresco.rest.sites.membershipRequests; import org.alfresco.dataprep.SiteService.Visibility; import org.alfresco.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestSiteMembershipRequestModelsCollection; import org.alfresco.rest.model.RestTaskModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; diff --git a/e2e-test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestTests.java b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestTests.java index 72b9fe4ce..fba1deab0 100644 --- a/e2e-test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestTests.java @@ -2,13 +2,11 @@ package org.alfresco.rest.sites.membershipRequests; import org.alfresco.dataprep.SiteService; import org.alfresco.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestSiteMembershipRequestModel; import org.alfresco.rest.model.RestTaskModel; 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; @@ -331,50 +329,4 @@ public class GetSiteMembershipRequestTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Add process item using by the admin in same network.") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void getSiteMembershipRequestByAdminSameNetwork() throws Exception - { - UserModel adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser); - UserModel tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - - moderatedSite = dataSite.usingUser(adminTenantUser).createModeratedRandomSite(); - restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - - returnedModel = restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().getSiteMembershipRequest(moderatedSite); - - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedModel.assertThat().field("id").is(moderatedSite.getId()) - .and().field("message").is("Please accept me") - .and().field("site.title").is(moderatedSite.getTitle()) - .and().field("site.visibility").is(SiteService.Visibility.MODERATED.toString()) - .and().field("site.guid").isNotEmpty() - .and().field("site.description").is(moderatedSite.getDescription()) - .and().field("site.preset").is("site-dashboard"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Add process item using by admin in other network.") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void getSiteMembershipRequestByAdminInOtherNetwork() throws Exception - { - UserModel adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser); - - UserModel adminTenantUser2 = UserModel.getAdminTenantUser(); - restClient.usingTenant().createTenant(adminTenantUser2); - moderatedSite = dataSite.usingUser(adminTenantUser2).createModeratedRandomSite(); - - restClient.authenticateUser(adminTenantUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - returnedModel = restClient.authenticateUser(adminTenantUser2).withCoreAPI().usingAuthUser().getSiteMembershipRequest(moderatedSite); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, adminTenantUser2.getUsername().toLowerCase(), moderatedSite.getId())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/workflow/WorkflowNetworkDeploymentsTests.java b/e2e-test/java/org/alfresco/rest/workflow/WorkflowNetworkDeploymentsTests.java new file mode 100644 index 000000000..8a255fd0b --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/WorkflowNetworkDeploymentsTests.java @@ -0,0 +1,124 @@ +package org.alfresco.rest.workflow; + +import java.util.List; + +import org.alfresco.rest.NetworkDataPrep; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestDeploymentModel; +import org.alfresco.rest.model.RestDeploymentModelsCollection; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class WorkflowNetworkDeploymentsTests extends NetworkDataPrep +{ + private RestDeploymentModel expectedDeployment, actualDeployment; + private RestDeploymentModelsCollection deployments; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + init(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, + executionType = ExecutionType.REGRESSION, + description = "Verify if network admin user gets a network deployment using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION, TestGroup.NETWORKS}) + public void adminGetsNetworkDeploymentWithSuccess() throws Exception + { + + expectedDeployment = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getDeployments().getOneRandomEntry().onModel(); + actualDeployment = restClient.withWorkflowAPI().usingDeployment(expectedDeployment).getDeployment(); + restClient.assertStatusCodeIs(HttpStatus.OK); + actualDeployment.assertThat().field("deployedAt").isNotEmpty() + .and().field("name").is(expectedDeployment.getName()) + .and().field("id").is(expectedDeployment.getId()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, + executionType = ExecutionType.REGRESSION, + description = "Verify non admin user is forbidden to get a network deployment using REST API (403)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void nonAdminUserIsForbiddenToGetNetworkDeployment() throws Exception + { + expectedDeployment = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getDeployments().getOneRandomEntry().onModel(); + + restClient.authenticateUser(tenantUser).withWorkflowAPI().usingDeployment(expectedDeployment).getDeployment(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Bug(id = "MNT-16996") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, + executionType = ExecutionType.REGRESSION, + description = "Verify get deployments returns an empty list after deleting all network deployments.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION, TestGroup.NETWORKS}) + public void getNetworkDeploymentsAfterDeletingAllNetworkDeployments() throws Exception + { + + List networkDeployments = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getDeployments().getEntries(); + for (RestDeploymentModel networkDeployment: networkDeployments) + { + restClient.withWorkflowAPI().usingDeployment(networkDeployment.onModel()).deleteDeployment(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + deployments = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getDeployments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + deployments.assertThat().entriesListIsEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, + executionType = ExecutionType.REGRESSION, + description = "Verify non admin user is not able to get network deployments using REST API and status code is Forbidden") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION, TestGroup.NETWORKS}) + public void nonAdminUserCanNotGetNetworkDeployments() throws Exception + { + restClient.authenticateUser(tenantUser).withWorkflowAPI().getDeployments(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, + executionType = ExecutionType.REGRESSION, + description = "Verify that network admin user is not able to get a deployment from other network using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION, TestGroup.NETWORKS}) + public void adminDoesNotGetDeploymentFromOtherNetwork() throws Exception + { + expectedDeployment = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getDeployments().getOneRandomEntry().onModel(); + actualDeployment = restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().usingDeployment(expectedDeployment).getDeployment(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, expectedDeployment.getId())) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, + executionType = ExecutionType.REGRESSION, + description = "Verify that network admin user is not able to get a deployment from other network using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION, TestGroup.NETWORKS}) + public void adminDoesNotGetDeploymentsFromOtherNetwork() throws Exception + { + RestDeploymentModel deployment = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getDeployments().getOneRandomEntry().onModel(); + deployments = restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().getDeployments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + deployments.assertThat().entriesListDoesNotContain("id", deployment.getId()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.SANITY, + description = "Verify Tenant Admin user gets network deployments using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.SANITY, TestGroup.NETWORKS}) + public void getNetworkDeploymentsWithAdmin() throws JsonToModelConversionException, Exception + { + deployments = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getDeployments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + deployments.assertThat().entriesListIsNotEmpty(); + } +} diff --git a/e2e-test/java/org/alfresco/rest/workflow/WorkflowNetworkProcessDefinitionsTests.java b/e2e-test/java/org/alfresco/rest/workflow/WorkflowNetworkProcessDefinitionsTests.java new file mode 100644 index 000000000..038681aef --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/WorkflowNetworkProcessDefinitionsTests.java @@ -0,0 +1,221 @@ +package org.alfresco.rest.workflow; + +import org.alfresco.dataprep.CMISUtil.Priority; +import org.alfresco.rest.NetworkDataPrep; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestProcessDefinitionModel; +import org.alfresco.rest.model.RestProcessDefinitionModelsCollection; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class WorkflowNetworkProcessDefinitionsTests extends NetworkDataPrep +{ + private RestProcessDefinitionModel randomProcessDefinition, returnedProcessDefinition; + private RestProcessModel addedProcess; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + init(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, + executionType = ExecutionType.REGRESSION, + description = "Verify network admin is able to get a process definition using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void networkAdminGetProcessDefinition() throws Exception + { + randomProcessDefinition = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry().onModel(); + returnedProcessDefinition = restClient.withWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinition(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedProcessDefinition.assertThat().field("name").is(randomProcessDefinition.getName()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, + executionType = ExecutionType.REGRESSION, + description = "Verify network user is able to get a process definition using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void networkUserGetProcessDefinition() throws Exception + { + randomProcessDefinition = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() + .getAllProcessDefinitions().getOneRandomEntry().onModel(); + returnedProcessDefinition = restClient.authenticateUser(tenantUser).withWorkflowAPI() + .usingProcessDefinitions(randomProcessDefinition).getProcessDefinition(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedProcessDefinition.assertThat().field("name").is(randomProcessDefinition.getName()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, + description = "Verify get process definitions using any network user for network enabled deployments with REST API status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION, TestGroup.NETWORKS}) + public void networkUserGetsProcessDefinitions() throws Exception + { + restClient.authenticateUser(tenantUser) + .withWorkflowAPI() + .getAllProcessDefinitions() + .assertThat().entriesListIsNotEmpty(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, + executionType = ExecutionType.REGRESSION, + description = "Verify Network user is not able to get a process definition from another network") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.NETWORKS, TestGroup.REGRESSION }) + public void getProcessDefinitionFromAnotherNetwork() throws Exception + { + randomProcessDefinition = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() + .getAllProcessDefinitions().getOneRandomEntry().onModel(); + restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI() + .usingProcessDefinitions(randomProcessDefinition).getProcessDefinition(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, randomProcessDefinition.getId())) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, + executionType = ExecutionType.REGRESSION, + description = "Verify Tenant User doesn't get process definitions for another network deployment using REST API") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void networkUserIsNotAbleToGetProcessDefinitionsForAnotherNetwork() throws Exception + { + RestProcessDefinitionModel randomProcessDefinitionTenant1 = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() + .getAllProcessDefinitions().getOneRandomEntry().onModel(); + RestProcessDefinitionModelsCollection processDefinitionsTenant2 = restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI() + .getAllProcessDefinitions(); + restClient.assertStatusCodeIs(HttpStatus.OK); + processDefinitionsTenant2.assertThat().entriesListDoesNotContain("id", randomProcessDefinitionTenant1.getId()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, + executionType = ExecutionType.REGRESSION, + description = "Verify network admin is able to get a process definition image using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION, TestGroup.NETWORKS}) + @Bug(id = "MNT-17243") + public void networkAdminGetProcessDefinitionImage() throws Exception + { + randomProcessDefinition = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry().onModel(); + restClient.withWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionImage() + .assertResponseContainsImage(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESS_DEFINITION }, + executionType = ExecutionType.REGRESSION, + description = "Verify network user is able to get a process definition image using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION, TestGroup.NETWORKS}) + @Bug(id = "MNT-17243") + public void networkUserGetProcessDefinitionImage() throws Exception + { + randomProcessDefinition = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() + .getAllProcessDefinitions().getOneRandomEntry().onModel(); + restClient.authenticateUser(tenantUser).withWorkflowAPI() + .usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionImage() + .assertResponseContainsImage(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, + executionType = ExecutionType.SANITY, description = "Verify Tenant Admin user gets process definitions for network deployments using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY, TestGroup.NETWORKS}) + public void networkAdminGetsProcessDefinitions() throws Exception + { + restClient.authenticateUser(adminTenantUser); + restClient.withWorkflowAPI().getAllProcessDefinitions().assertThat().entriesListIsNotEmpty(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, + executionType = ExecutionType.REGRESSION, + description = "Verify Tenant User doesn't get process definition image for another network deployment using REST API") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void networkUserIsNotAbleToGetProcessDefinitionImageForAnotherNetwork() throws Exception + { + RestProcessDefinitionModel randomProcessDefinition = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() + .getAllProcessDefinitions().getOneRandomEntry().onModel(); + restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI() + .usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionImage(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, randomProcessDefinition.getId())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, + executionType = ExecutionType.REGRESSION, + description = "Verify Tenant User gets a model of the start form type definition for network deployments using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void networkUserGetsStartFormModel() throws Exception + { + randomProcessDefinition = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() + .getAllProcessDefinitions().getOneRandomEntry().onModel(); + restClient.authenticateUser(tenantUser).withWorkflowAPI() + .usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionStartFormModel() + .assertThat().entriesListIsNotEmpty(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, + executionType = ExecutionType.REGRESSION, + description = "Verify Tenant User doesn't get a model of the start form type definition for another network deployment using REST API") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void networkUserIsNotAbleToGetStartFormModelForAnotherNetwork() throws Exception + { + RestProcessDefinitionModel randomProcessDefinition = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() + .getAllProcessDefinitions().getOneRandomEntry().onModel(); + restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI() + .usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionStartFormModel(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, randomProcessDefinition.getId())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, + executionType = ExecutionType.SANITY, + description = "Verify Tenant Admin gets a model of the start form type definition for network deployments using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY, TestGroup.NETWORKS }) + public void networkAdminGetsStartFormModel() throws Exception + { + restClient.authenticateUser(adminTenantUser); + randomProcessDefinition = restClient.withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry().onModel(); + restClient.withWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionStartFormModel().assertThat().entriesListIsNotEmpty(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify network user can start new process with processDefinitionKey from same network using REST API and status code is 201") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS}) + public void networkUserCanStartNewProcessWithProcessDefinitionFromSameNetwork() throws JsonToModelConversionException, Exception + { + RestProcessDefinitionModel firstProcessDefTenant1 = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getAllProcessDefinitions().getEntries().get(0).onModel(); + + String processDefinitionKey = firstProcessDefTenant1.getKey(); + addedProcess = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess(processDefinitionKey, secondTenantUser, false, Priority.Normal); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + addedProcess.assertThat().field("processDefinitionId").is(firstProcessDefTenant1.getId()) + .and().field("startUserId").is(tenantUser.getEmailAddress().substring(0,2)+tenantUser.getEmailAddress().substring(2).toLowerCase()) + .and().field("processDefinitionKey").is(processDefinitionKey); + } + + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify network user cannot start new process with processDefinitionKey from another network using REST API and status code is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS}) + public void networkUserCannotStartNewProcessWithProcessDefinitionFromAnotherNetwork() throws JsonToModelConversionException, Exception + { + RestProcessDefinitionModel firstProcessDefTenant1 = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getAllProcessDefinitions().getEntries().get(0).onModel(); + + String processDefinitionKey = firstProcessDefTenant1.getId().substring(0,firstProcessDefTenant1.getId().indexOf(":")); + addedProcess = restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().addProcess(processDefinitionKey, differentNetworkTenantUser, false, Priority.Normal); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(String.format(RestErrorModel.NO_WORKFLOW_DEFINITION_FOUND, processDefinitionKey)) + .containsSummary(String.format(RestErrorModel.NO_WORKFLOW_DEFINITION_FOUND, processDefinitionKey)) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } +} diff --git a/e2e-test/java/org/alfresco/rest/workflow/WorkflowNetworkProcessesTests.java b/e2e-test/java/org/alfresco/rest/workflow/WorkflowNetworkProcessesTests.java new file mode 100644 index 000000000..fbf342ee0 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/WorkflowNetworkProcessesTests.java @@ -0,0 +1,529 @@ +package org.alfresco.rest.workflow; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.dataprep.CMISUtil.Priority; +import org.alfresco.rest.NetworkDataPrep; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestItemModel; +import org.alfresco.rest.model.RestItemModelsCollection; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestProcessModelsCollection; +import org.alfresco.rest.model.RestProcessVariableCollection; +import org.alfresco.rest.model.RestProcessVariableModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class WorkflowNetworkProcessesTests extends NetworkDataPrep +{ + private RestProcessModel processModel; + private RestProcessModelsCollection processes; + private RestItemModel processItem; + private RestItemModelsCollection processItems; + private RestProcessVariableModel variableModel, processVariable; + private RestProcessVariableCollection variables; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + init(); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW, + TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Verify network user is able to start new process using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY, TestGroup.NETWORKS }) + public void networkUserStartsNewProcess() throws JsonToModelConversionException, Exception + { + processModel = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + processModel.assertThat().field("id").is(processModel.getId()) + .and().field("startUserId").is(processModel.getStartUserId()); + + processes = restClient.withWorkflowAPI().getProcesses(); + restClient.assertStatusCodeIs(HttpStatus.OK); + processes.assertThat().entriesListContains("id", processModel.getId()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES}, executionType = ExecutionType.REGRESSION, + description = "Verify that non network user cannot get process from a network") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) + @Bug(id = "REPO-2092") + public void nonNetworkUserCannotAccessNetworkProcess() throws Exception + { + RestProcessModel networkProcess1 = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().addProcess("activitiReview", tenantUser, false, CMISUtil.Priority.High); + + restClient.authenticateUser(adminUserModel).withWorkflowAPI().usingProcess(networkProcess1).getProcess(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError().containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify that tenant user can get process from the same network") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void tenantUserCanGetProcessFromTheSameNetwork() throws Exception + { + RestProcessModel networkProcess1 = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().addProcess("activitiReview", tenantUser, false, CMISUtil.Priority.High); + + restClient.authenticateUser(tenantUser).withWorkflowAPI().usingProcess(networkProcess1).getProcess(); + restClient.assertStatusCodeIs(HttpStatus.OK); + networkProcess1.assertThat().field("id").is(networkProcess1.getId()) + .and().field("startUserId").is(networkProcess1.getStartUserId());; + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES}, executionType = ExecutionType.REGRESSION, + description = "Verify that tenant user cannot get process from another network") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) + @Bug(id = "REPO-2092") + public void tenantUserCannotGetProcessFromAnotherNetwork() throws Exception + { + RestProcessModel networkProcess1 = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().addProcess("activitiReview", tenantUser, false, CMISUtil.Priority.High); + + restClient.authenticateUser(differentNetworkTenantUser).withWorkflowAPI().usingProcess(networkProcess1).getProcess(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError().containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin user can get process started by a network user") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void adminUserCanGetProcessFromANetwork() throws Exception + { + RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiReview", adminTenantUser, false, CMISUtil.Priority.High); + + restClient.authenticateUser(dataUser.getAdminUser()).withWorkflowAPI().usingProcess(networkProcess1).getProcess(); + restClient.assertStatusCodeIs(HttpStatus.OK); + networkProcess1.assertThat().field("processDefinitionId").contains(String.format("@%s%s", tenantUser.getDomain().toLowerCase(), "@activitiReview:1")) + .and().field("startUserId").is(tenantUser.getEmailAddress().toLowerCase()) + .and().field("startActivityId").is("start") + .and().field("startedAt").isNotEmpty() + .and().field("id").is(networkProcess1.getId()) + .and().field("completed").is(false) + .and().field("processDefinitionKey").is("activitiReview"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Add multiple process items using by admin in other network.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void addMultipleProcessItemsByAdminInOtherNetwork() throws Exception + { + processModel = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUser, false, Priority.Normal); + restClient.authenticateUser(secondAdminTenantUser); + + processItems = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItems(document, document2); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError() + .containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Add multiple process items using by the admin in same network.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void addMultipleProcessItemsByAdminSameNetwork() throws Exception + { + processModel = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); + processItems = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().usingProcess(processModel).addProcessItems(document, document2); + + restClient.assertStatusCodeIs(HttpStatus.CREATED); + processItems.getEntries().get(0).onModel().assertThat() + .field("createdAt").isNotEmpty().and() + .field("size").is("19").and() + .field("createdBy").is(adminTenantUser.getUsername().toLowerCase()).and() + .field("modifiedAt").isNotEmpty().and() + .field("name").is(document.getName()).and() + .field("modifiedBy").is(adminTenantUser.getUsername().toLowerCase()).and() + .field("id").isNotEmpty().and() + .field("mimeType").is(document.getFileType().mimeType); + processItems.getEntries().get(1).onModel().assertThat() + .field("createdAt").isNotEmpty().and() + .field("size").is("19").and() + .field("createdBy").is(adminTenantUser.getUsername().toLowerCase()).and() + .field("modifiedAt").isNotEmpty().and() + .field("name").is(document2.getName()).and() + .field("modifiedBy").is(adminTenantUser.getUsername().toLowerCase()).and() + .field("id").isNotEmpty().and() + .field("mimeType").is(document2.getFileType().mimeType); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Add process item using by admin in other network.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void addProcessItemByAdminInOtherNetwork() throws Exception + { + processModel = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUser, false, Priority.Normal); + restClient.authenticateUser(secondAdminTenantUser); + processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Add process item using by the admin in same network.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void addProcessItemByAdminSameNetwork() throws Exception + { + processModel = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); + + processItem = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().usingProcess(processModel).addProcessItem(document); + + restClient.assertStatusCodeIs(HttpStatus.CREATED); + processItem.assertThat().field("createdAt").isNotEmpty().and().field("size").is("19").and().field("createdBy").is(adminTenantUser.getUsername().toLowerCase()).and() + .field("modifiedAt").isNotEmpty().and().field("name").is(document.getName()).and().field("modifiedBy").is(adminTenantUser.getUsername().toLowerCase()).and() + .field("id").isNotEmpty().and().field("mimeType").is(document.getFileType().mimeType); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Delete process item using by admin in other network.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void deleteProcessItemByAdminInOtherNetwork() throws Exception + { + processModel = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, CMISUtil.Priority.Normal); + processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().usingProcess(processModel) + .deleteProcessItem(processItem); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError() + .containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .containsErrorKey(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT) + .stackTraceIs(RestErrorModel.STACKTRACE); + + //restore document + document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Delete process item using by the admin in same network.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void deleteProcessItemByAdminSameNetwork() throws Exception + { + processModel = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, CMISUtil.Priority.Normal); + + processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(adminTenantUser).withWorkflowAPI().usingProcess(processModel) + .deleteProcessItem(processItem); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() + .assertThat().entriesListDoesNotContain("name", processItem.getName()); + + //restore document + document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Get process items using admin from different network") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void getProcessItemsReturnsOnlyItemsInsideNetwork() throws Exception + { + processModel = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, CMISUtil.Priority.Normal); + + siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); + document = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestProcessModel processModel2 = restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondAdminTenantUser, false, CMISUtil.Priority.Normal); + + SiteModel siteModel2 = dataSite.usingUser(secondAdminTenantUser).createPublicRandomSite(); + document2 = dataContent.usingUser(secondAdminTenantUser).usingSite(siteModel2).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().usingProcess(processModel2).addProcessItem(document2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + processItems = restClient.withWorkflowAPI().usingProcess(processModel2).getProcessItems(); + restClient.assertStatusCodeIs(HttpStatus.OK); + processItems.assertThat().entriesListDoesNotContain("name", document.getName()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Get process items using admin from different network") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void getProcessItemsUsingAdminUserFromDifferentNetwork() throws Exception + { + processModel = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, CMISUtil.Priority.Normal); + + siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); + document = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().usingProcess(processModel).getProcessItems(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Add process variable using by admin in other network.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void addProcessVariableByAdminInOtherNetwork() throws Exception + { + processModel = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); + + restClient.authenticateUser(secondAdminTenantUser); + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError() + .containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Add process variable using admin user from same network") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY, TestGroup.NETWORKS }) + public void addProcessVariableByAdmin() throws Exception + { + restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + + processVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + processVariable.assertThat().field("name").is(variableModel.getName()) + .and().field("type").is(variableModel.getType()) + .and().field("value").is(variableModel.getValue()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin from different network is not able to delete network process variables") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void deleteProcessVariablesWithAdminFromDifferentNetwork() throws Exception + { + RestProcessModel processModel = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() + .addProcess("activitiAdhoc", tenantUser, false, Priority.Normal); + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser).withWorkflowAPI() + .getProcesses().getProcessModelByProcessDefId(processModel.getId()); + restClient.withWorkflowAPI().usingProcess(networkProcess1).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(adminUserModel).withWorkflowAPI().usingProcess(networkProcess1) + .deleteProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + restClient.assertLastError().containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .containsErrorKey(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT) + .stackTraceIs(RestErrorModel.STACKTRACE); + + restClient.authenticateUser(tenantUser).withWorkflowAPI().usingProcess(networkProcess1).getProcessVariables().assertThat() + .entriesListContains("name", variableModel.getName()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin from the same network is able to delete network process variables") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void deleteProcessVariablesWithAdminFromSameNetwork() throws Exception + { + RestProcessModel processModel = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() + .addProcess("activitiAdhoc", tenantUser, false, Priority.Normal); + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser).withWorkflowAPI() + .getProcesses().getProcessModelByProcessDefId(processModel.getId()); + restClient.withWorkflowAPI().usingProcess(networkProcess1).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(adminTenantUser).withWorkflowAPI().usingProcess(networkProcess1) + .deleteProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingProcess(networkProcess1).getProcessVariables() + .assertThat() + .entriesListDoesNotContain("name", variableModel.getName()); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin from different network is not able to retrieve network process variables") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void getProcessVariablesWithAdminFromDifferentNetwork() throws Exception + { + RestProcessModel networkProcess1 = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() + .addProcess("activitiReview", tenantUser, false, CMISUtil.Priority.High); + + variables = restClient.authenticateUser(adminUserModel).withWorkflowAPI().usingProcess(networkProcess1).getProcessVariables(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT); + } + + @TestRail(section = {TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin from the same network is able to retrieve network process variables") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void getProcessVariablesWithAdminFromSameNetwork() throws Exception + { + RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser).withWorkflowAPI() + .addProcess("activitiReview", tenantUser, false, CMISUtil.Priority.High); + + variables = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().usingProcess(networkProcess1).getProcessVariables(); + restClient.assertStatusCodeIs(HttpStatus.OK); + variables.assertThat().entriesListIsNotEmpty(); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify admin gets all processes from same network") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void getProcessFromSameNetworkUsingAdmin() throws Exception + { + RestProcessModel process = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); + + RestProcessModelsCollection tenantProcesses = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getProcesses(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + tenantProcesses.assertThat().entriesListContains("id", process.getId()); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Get process items using admin from same network") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY, TestGroup.NETWORKS }) + public void getProcessItemsUsingAdminUserFromSameNetwork() throws Exception + { + processModel = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); + + siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); + document = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); + + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + processItems = restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems(); + restClient.assertStatusCodeIs(HttpStatus.OK); + processItems.assertThat().entriesListContains("name", document.getName()); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Add multiple process variables using admin user from same network") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY, TestGroup.NETWORKS }) + public void addMultipleProcessVariablesByAdminSameNetwork() throws Exception + { + restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processVariable = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + + variables = restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariables(variableModel, processVariable); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + variables.assertThat().entriesListContains("name", variableModel.getName()) + .assertThat().entriesListContains("name", processVariable.getName()); + + variables.getEntries().get(0).onModel().assertThat() + .field("name").is(variableModel.getName()).and() + .field("value").is(variableModel.getValue()).and() + .field("type").is(variableModel.getType()); + variables.getEntries().get(1).onModel().assertThat() + .field("name").is(processVariable.getName()).and() + .field("value").is(processVariable.getValue()).and() + .field("type").is(processVariable.getType()); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Add process variables using admin user from same network") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY, TestGroup.NETWORKS }) + public void addProcessVariableByAdminSameNetwork() throws Exception + { + restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + + processVariable = restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + processVariable.assertThat().field("name").is(variableModel.getName()) + .and().field("type").is(variableModel.getType()) + .and().field("value").is(variableModel.getValue()); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify any user cannot get processes from same network") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void getProcessFromSameNetworkUsingAnyUser() throws Exception + { + restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); + + RestProcessModelsCollection tenantProcesses = restClient.authenticateUser(tenantUser).withWorkflowAPI().getProcesses(); + restClient.assertStatusCodeIs(HttpStatus.OK); + tenantProcesses.assertThat().entriesListIsEmpty().and().paginationField("count").is("0"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify getProcessTasks using admin from different network with REST API and status code is FORBIDDEN (403)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void getProcessTasksWithAdminFromDifferentNetwork() throws Exception + { + siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); + dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + RestProcessModel processModel = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, CMISUtil.Priority.Normal); + + restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI() + .usingProcess(processModel).getProcessTasks().assertThat().entriesListIsEmpty(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify getProcessTasks using admin from same network with REST API and status code is OK") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void getProcessTasksWithAdminFromSameNetwork() throws Exception + { + siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); + dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + + RestProcessModel processModel = restClient.authenticateUser(secondTenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, CMISUtil.Priority.Normal); + + restClient.authenticateUser(adminTenantUser).withWorkflowAPI() + .usingProcess(processModel).getProcessTasks().assertThat().entriesListIsNotEmpty(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW,TestGroup.PROCESSES}, executionType = ExecutionType.REGRESSION, + description = "Add multiple process variables using by Admin in other network.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void addMultipleProcessVariablesByAdminInOtherNetwork() throws Exception + { + + siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); + dataWorkflow.usingUser(tenantUser).usingSite(siteModel).usingResource(document) + .createNewTaskAndAssignTo(secondTenantUser); + + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processVariable = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); + restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().usingProcess(processModel) + .addProcessVariables(variableModel, processVariable); + + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError() + .containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .containsErrorKey(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES}, executionType = ExecutionType.REGRESSION, + description = "Add process variables using by Admin in other network.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void addProcessVariablesByAdminInOtherNetwork() throws Exception + { + siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); + dataWorkflow.usingUser(tenantUser).usingSite(siteModel).usingResource(document) + .createNewTaskAndAssignTo(secondTenantUser); + + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); + processVariable = restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().usingProcess(processModel) + .addProcessVariable(variableModel); + + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError() + .containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .containsErrorKey(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + +} diff --git a/e2e-test/java/org/alfresco/rest/workflow/WorkflowNetworkTasksTests.java b/e2e-test/java/org/alfresco/rest/workflow/WorkflowNetworkTasksTests.java new file mode 100644 index 000000000..d5259d091 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/WorkflowNetworkTasksTests.java @@ -0,0 +1,575 @@ +package org.alfresco.rest.workflow; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.dataprep.CMISUtil.Priority; +import org.alfresco.rest.NetworkDataPrep; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestFormModelsCollection; +import org.alfresco.rest.model.RestItemModel; +import org.alfresco.rest.model.RestItemModelsCollection; +import org.alfresco.rest.model.RestProcessDefinitionModel; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestTaskModel; +import org.alfresco.rest.model.RestTaskModelsCollection; +import org.alfresco.rest.model.RestVariableModel; +import org.alfresco.rest.model.RestVariableModelsCollection; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TaskModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class WorkflowNetworkTasksTests extends NetworkDataPrep +{ + private TaskModel taskModel; + private RestFormModelsCollection returnedCollection; + private RestTaskModel restTaskModel; + private RestTaskModelsCollection taskModels; + private RestVariableModel variableModel, variableModel1; + private RestVariableModelsCollection restVariableCollection; + private RestProcessModel restProcessModel; + private RestItemModelsCollection itemModels; + private RestItemModel restTaskItem; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + init(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, + executionType = ExecutionType.REGRESSION, description = "Verify network admin user gets all task form models inside his network with Rest API and response is successful (200)") + public void networkAdminGetsTaskFormModels() throws Exception + { + FileModel fileModel = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(userModel); + + RestProcessModel networkProcess = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() + .addProcess("activitiReview", tenantUser, false, CMISUtil.Priority.High); + RestTaskModel networkTask = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() + .usingProcess(networkProcess).getProcessTasks().getOneRandomEntry().onModel(); + + restClient.authenticateUser(adminUserModel).withWorkflowAPI().usingTask(networkTask).getTaskFormModel(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + + returnedCollection = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().usingTask(networkTask).getTaskFormModel(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat().entriesListIsNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Add multiple task item using by admin in other network.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void addMultipleTaskItemByAdminInOtherNetwork() throws Exception + { + + document = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(DocumentType.XML); + document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + + RestProcessModel addedProcess = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); + RestTaskModel addedTask = restClient.withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess); + restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().usingTask(addedTask).addTaskItems(document, document2); + + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .stackTraceIs(RestErrorModel.STACKTRACE);; + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Add task item using by admin in other network.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void addTaskItemByAdminInOtherNetwork() throws Exception + { + document = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(DocumentType.XML); + RestProcessModel addedProcess = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); + RestTaskModel addedTask = restClient.withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess); + restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().usingTask(addedTask).addTaskItem(document); + + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Bug(id = "REPO-1980") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify tenant admin can update only task from its network and response is 200") + public void adminTenantCanUpdateOnlyTaskInItsNetwork() throws Exception + { + FileModel fileModel1 = dataContent.usingUser(tenantUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + RestProcessDefinitionModel def1 = restClient.authenticateUser(tenantUser).withWorkflowAPI().getAllProcessDefinitions().getEntries().get(0).onModel(); + TaskModel taskModel1 = dataWorkflow.usingUser(tenantUser).usingSite(siteModel).usingResource(fileModel1) + .createTaskWithProcessDefAndAssignTo(def1.getId(), secondTenantUser); + + SiteModel siteModel2 = dataSite.usingUser(differentNetworkTenantUser).createPublicRandomSite(); + FileModel fileModel2 = dataContent.usingUser(differentNetworkTenantUser).usingSite(siteModel2).createContent(DocumentType.TEXT_PLAIN); + RestProcessDefinitionModel def2 = restClient.authenticateUser(differentNetworkTenantUser).withWorkflowAPI().getAllProcessDefinitions().getEntries().get(0).onModel(); + TaskModel taskModel2 = dataWorkflow.usingUser(differentNetworkTenantUser).usingSite(siteModel2).usingResource(fileModel2) + .createTaskWithProcessDefAndAssignTo(def2.getId(), secondAdminTenantUser); + + restTaskModel = restClient.authenticateUser(secondAdminTenantUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel2).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel2.getId()) + .and().field("state").is("completed"); + + restTaskModel = restClient.authenticateUser(secondAdminTenantUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel1).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin from the same network is able to add multiple task variables") + public void addMultipleTaskVariablesByTenantAdmin() throws Exception + { + RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser).withWorkflowAPI() + .addProcess("activitiReview", tenantUser, false, CMISUtil.Priority.High); + RestTaskModel task = restClient.authenticateUser(adminTenantUser) + .withWorkflowAPI().usingProcess(networkProcess1).getProcessTasks().getOneRandomEntry(); + restClient.authenticateUser(adminTenantUser); + + variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + variableModel1 = RestVariableModel.getRandomTaskVariableModel("global", "d:text"); + + restVariableCollection = restClient.withWorkflowAPI().usingTask(task.onModel()) + .addTaskVariables(variableModel, variableModel1); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restVariableCollection.getEntries().get(0).onModel().assertThat() + .field("scope").is(variableModel.getScope()) + .and().field("name").is(variableModel.getName()) + .and().field("value").is(variableModel.getValue()) + .and().field("type").is(variableModel.getType()); + + restVariableCollection.getEntries().get(1).onModel().assertThat() + .field("scope").is(variableModel1.getScope()) + .and().field("name").is(variableModel1.getName()) + .and().field("value").is(variableModel1.getValue()) + .and().field("type").is(variableModel1.getType()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin from the same network is able to add and remove task variables") + public void addAndRemoveTaskVariablesByTenantAdmin() throws Exception + { + RestProcessModel networkProcess1 = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() + .addProcess("activitiReview", adminTenantUser, false, CMISUtil.Priority.High); + RestTaskModel task = restClient.authenticateUser(adminTenantUser) + .withWorkflowAPI().usingProcess(networkProcess1).getProcessTasks().getOneRandomEntry(); + restClient.authenticateUser(adminTenantUser); + RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + variableModel = restClient.withWorkflowAPI() + .usingTask(task.onModel()) + .addTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + variableModel.assertThat() + .field("scope").is(variableModel.getScope()) + .and().field("name").is(variableModel.getName()) + .and().field("value").is(variableModel.getValue()) + .and().field("type").is(variableModel.getType()); + + restClient.withWorkflowAPI().usingTask(task.onModel()).deleteTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingTask(task.onModel()).getTaskVariables() + .assertThat().entriesListDoesNotContain("name", variableModel.getName()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin from the other network is not able to remove task variables") + public void addTaskVariablesByTenantAdminOtherNetwork() throws Exception + { + RestProcessModel networkProcess1 = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() + .addProcess("activitiReview", adminTenantUser, false, CMISUtil.Priority.High); + RestTaskModel task = restClient.authenticateUser(adminTenantUser) + .withWorkflowAPI().usingProcess(networkProcess1).getProcessTasks().getOneRandomEntry(); + restClient.authenticateUser(adminTenantUser); + RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + restClient.withWorkflowAPI() + .usingTask(task.onModel()) + .addTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().usingTask(task.onModel()).deleteTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin from another network is not able to add task variables") + public void addTaskVariablesByTenantFromAnotherNetwork() throws Exception + { + RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser).withWorkflowAPI() + .addProcess("activitiReview", tenantUser, false, CMISUtil.Priority.High); + RestTaskModel task = restClient.authenticateUser(adminTenantUser) + .withWorkflowAPI().usingProcess(networkProcess1).getProcessTasks().getOneRandomEntry(); + RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + variableModel = restClient.authenticateUser(secondTenantUser).withWorkflowAPI() + .usingTask(task.onModel()) + .addTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin from another network is not able to add multiple task variables") + public void addMultipleTaskVariablesByTenantFromAnotherNetwork() throws Exception + { + RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser).withWorkflowAPI() + .addProcess("activitiReview", tenantUser, false, CMISUtil.Priority.High); + RestTaskModel task = restClient.authenticateUser(adminTenantUser) + .withWorkflowAPI().usingProcess(networkProcess1).getProcessTasks().getOneRandomEntry(); + restClient.authenticateUser(adminTenantUser); + + variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + variableModel1 = RestVariableModel.getRandomTaskVariableModel("global", "d:text"); + restVariableCollection = restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI() + .usingTask(task.onModel()) + .addTaskVariables(variableModel,variableModel1); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin from another network is not able to update task variables") + public void updateTaskVariablesByTenantFromAnotherNetwork() throws Exception + { + RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser).withWorkflowAPI() + .addProcess("activitiReview", tenantUser, false, CMISUtil.Priority.High); + RestTaskModel task = restClient.authenticateUser(adminTenantUser) + .withWorkflowAPI().usingProcess(networkProcess1).getProcessTasks().getOneRandomEntry(); + restClient.authenticateUser(adminTenantUser); + RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + variableModel = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().usingTask(task.onModel()) + .addTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().usingTask(task.onModel()) + .updateTaskVariable(variableModel); + + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, + executionType = ExecutionType.REGRESSION, description = "Check that for admin network gets tasks only from its network.") + public void adminTenantGetsTasksOnlyFromItsNetwork() throws Exception + { + RestProcessModel processOnTenant1 = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Low); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestProcessModel processOnTenant2 = restClient.authenticateUser(differentNetworkTenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondAdminTenantUser, false, Priority.Normal); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestTaskModelsCollection tenantTasks1 = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + tenantTasks1.assertThat().entriesListIsNotEmpty() + .and().entriesListCountIs(1) + .and().entriesListContains("assignee", String.format("userTenantAssignee1@%s", secondTenantUser.getDomain().toLowerCase())) + .and().entriesListContains("processId", processOnTenant1.getId()) + .and().entriesListDoesNotContain("assignee", String.format("userTenantAssignee2@%s", secondAdminTenantUser.getDomain().toLowerCase())) + .and().entriesListDoesNotContain("processId", processOnTenant2.getId()); + + RestTaskModelsCollection tenantTasks2 = restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + tenantTasks2.assertThat().entriesListIsNotEmpty() + .and().entriesListCountIs(1) + .and().entriesListContains("assignee", String.format("userTenantAssignee2@%s", secondAdminTenantUser.getDomain().toLowerCase())) + .and().entriesListContains("processId", processOnTenant2.getId()) + .and().entriesListDoesNotContain("assignee", String.format("userTenantAssignee1@%s", secondTenantUser.getDomain().toLowerCase())) + .and().entriesListDoesNotContain("processId", processOnTenant1.getId()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check that for network enabled only that network tasks are returned.") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) + public void networkEnabledTasksReturned() throws Exception + { + restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); + + taskModels = restClient.authenticateUser(secondTenantUser).withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + taskModels.assertThat().entriesListIsNotEmpty().and().entriesListCountIs(1).and().entriesListContains("assignee", + String.format("userTenantAssignee@%s", secondTenantUser.getDomain().toLowerCase())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify gets task items call with admin from different network") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void getTaskItemsByAdminFromAnotherNetwork() throws Exception + { + + siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); + document = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(DocumentType.XML); + restProcessModel = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); + restTaskModel = restClient.withWorkflowAPI().getTasks().getTaskModelByProcess(restProcessModel); + restClient.withWorkflowAPI().usingTask(restTaskModel).addTaskItem(document); + + restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().usingTask(restTaskModel).getTaskItems(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify gets task items call returns only task items inside network") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void getTaskItemsReturnsOnlyItemsFromThatNetwork() throws Exception + { + SiteModel siteModel1 = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); + FileModel fileModel1 = dataContent.usingUser(adminTenantUser).usingSite(siteModel1).createContent(DocumentType.XML); + + RestProcessModel addedProcess1 = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUser, false, Priority.Normal); + RestTaskModel addedTask1 = restClient.withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess1); + RestItemModel taskItem1 = restClient.withWorkflowAPI().usingTask(addedTask1).addTaskItem(fileModel1); + + SiteModel siteModel2 = dataSite.usingUser(secondAdminTenantUser).createPublicRandomSite(); + FileModel fileModel2 = dataContent.usingUser(secondAdminTenantUser).usingSite(siteModel2).createContent(DocumentType.XML); + + RestProcessModel addedProcess2 = restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().addProcess("activitiAdhoc", differentNetworkTenantUser, false, Priority.Normal); + RestTaskModel addedTask2 = restClient.withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess2); + RestItemModel taskItem2 = restClient.withWorkflowAPI().usingTask(addedTask2).addTaskItem(fileModel2); + + itemModels = restClient.withWorkflowAPI().usingTask(addedTask2).getTaskItems(); + restClient.assertStatusCodeIs(HttpStatus.OK); + itemModels.assertThat() + .entriesListIsNotEmpty().and() + .entriesListContains("id", taskItem2.getId()).and() + .entriesListContains("name", fileModel2.getName()).and() + .entriesListDoesNotContain("id", taskItem1.getId()).and() + .entriesListDoesNotContain("name", fileModel1.getName()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, + executionType = ExecutionType.REGRESSION, description = "Check that for admin network gets task only from its network.") + public void adminTenantGetsTaskOnlyFromItsNetwork() throws Exception + { + RestProcessModel processOnTenant1 = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Low); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestProcessModel processOnTenant2 = restClient.authenticateUser(differentNetworkTenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondAdminTenantUser, false, Priority.Normal); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestTaskModelsCollection tenantTasks2 = restClient.authenticateUser(differentNetworkTenantUser).withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + tenantTasks2.assertThat().entriesListIsNotEmpty() + .and().entriesListCountIs(1) + .and().entriesListContains("assignee", String.format("admin@%s", secondAdminTenantUser.getDomain().toLowerCase())) + .and().entriesListContains("processId", processOnTenant2.getId()) + .and().entriesListDoesNotContain("assignee", String.format("admin@%s", secondTenantUser.getDomain().toLowerCase())) + .and().entriesListDoesNotContain("processId", processOnTenant1.getId()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify that in a network only tasks inside network are returned.") + @Test(groups = {TestGroup.NETWORKS,TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void tasksInsideNetworkReturned() throws Exception + { + + RestProcessModel addedProcess = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, + Priority.Normal); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + taskModel = restClient.withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess); + restTaskModel = restClient.authenticateUser(secondTenantUser).withWorkflowAPI().usingTask(taskModel).getTask(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("assignee").is(String.format("sTenant@%s", secondTenantUser.getDomain().toLowerCase())).and() + .field("processId").is(addedProcess.getId()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Verify that user that started the process gets task items") + @Test(groups = { TestGroup.NETWORKS,TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY}) + public void getTaskItemsByAdminInSameNetwork() throws Exception + { + + siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); + document = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(DocumentType.XML); + RestProcessModel addedProcess = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); + RestTaskModel addedTask = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess); + restTaskItem = restClient.withWorkflowAPI().usingTask(addedTask).addTaskItem(document); + + itemModels = restClient.withWorkflowAPI().usingTask(addedTask).getTaskItems(); + restClient.assertStatusCodeIs(HttpStatus.OK); + itemModels.assertThat() + .entriesListIsNotEmpty().and() + .entriesListContains("id", restTaskItem.getId()).and() + .entriesListContains("name", document.getName()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin from the same network is able to retrieve network task variables") + public void getTaskVariablesByTenantAdmin() throws Exception + { + RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser).withWorkflowAPI() + .addProcess("activitiReview", tenantUser, false, CMISUtil.Priority.High); + RestTaskModel task = restClient.authenticateUser(adminTenantUser) + .withWorkflowAPI().usingProcess(networkProcess1).getProcessTasks().getOneRandomEntry(); + + restVariableCollection = restClient.withWorkflowAPI().usingTask(task.onModel()).getTaskVariables(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restVariableCollection.assertThat().entriesListIsNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin from another network is not able to retrieve network task variables") + public void getTaskVariablesByTenantFromAnotherNetwork() throws Exception + { + RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser).withWorkflowAPI() + .addProcess("activitiReview", tenantUser, false, CMISUtil.Priority.High); + RestTaskModel task = restClient.authenticateUser(adminTenantUser) + .withWorkflowAPI().usingProcess(networkProcess1).getProcessTasks().getOneRandomEntry(); + + restVariableCollection = restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().usingTask(task.onModel()).getTaskVariables(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } + + @Test(groups = { TestGroup.NETWORKS,TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Add task item using admin user from same network") + public void addMultipleTaskItemByAdminSameNetwork() throws Exception + { + + siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); + document = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(DocumentType.XML); + document2 = dataContent.usingUser(adminTenantUser).usingUser(adminTenantUser).usingSite(siteModel).createContent(DocumentType.XML); + RestProcessModel addedProcess = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); + RestTaskModel addedTask = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess); + + itemModels = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().usingTask(addedTask) + .addTaskItems(document2,document); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + itemModels.getEntries().get(0).onModel() + .assertThat().field("createdAt").is(itemModels.getEntries().get(0).onModel().getCreatedAt()) + .assertThat().field("size").is(itemModels.getEntries().get(0).onModel().getSize()) + .assertThat().field("createdBy").is(itemModels.getEntries().get(0).onModel().getCreatedBy()) + .assertThat().field("modifiedAt").is(itemModels.getEntries().get(0).onModel().getModifiedAt()) + .assertThat().field("name").is(itemModels.getEntries().get(0).onModel().getName()) + .assertThat().field("modifiedBy").is(itemModels.getEntries().get(0).onModel().getModifiedBy()) + .assertThat().field("id").is(itemModels.getEntries().get(0).onModel().getId()) + .assertThat().field("mimeType").is(itemModels.getEntries().get(0).onModel().getMimeType()); + + itemModels.getEntries().get(1).onModel() + .assertThat().field("createdAt").is(itemModels.getEntries().get(1).onModel().getCreatedAt()) + .assertThat().field("size").is(itemModels.getEntries().get(1).onModel().getSize()) + .assertThat().field("createdBy").is(itemModels.getEntries().get(1).onModel().getCreatedBy()) + .assertThat().field("modifiedAt").is(itemModels.getEntries().get(1).onModel().getModifiedAt()) + .assertThat().field("name").is(itemModels.getEntries().get(1).onModel().getName()) + .assertThat().field("modifiedBy").is(itemModels.getEntries().get(1).onModel().getModifiedBy()) + .assertThat().field("id").is(itemModels.getEntries().get(1).onModel().getId()); + } + + @Test(groups = { TestGroup.NETWORKS,TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Add task item using admin user from same network") + public void addTaskItemByAdminSameNetwork() throws Exception + { + siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); + document = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(DocumentType.XML); + RestProcessModel addedProcess = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); + RestTaskModel addedTask = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess); + + restTaskItem = restClient.withWorkflowAPI().usingTask(addedTask).addTaskItem(document); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restTaskItem.assertThat().field("createdAt").is(restTaskItem.getCreatedAt()) + .and().field("size").is(restTaskItem.getSize()) + .and().field("createdBy").is(restTaskItem.getCreatedBy()) + .and().field("modifiedAt").is(restTaskItem.getModifiedAt()) + .and().field("name").is(restTaskItem.getName()) + .and().field("modifiedBy").is(restTaskItem.getModifiedBy()) + .and().field("id").is(restTaskItem.getId()) + .and().field("mimeType").is(restTaskItem.getMimeType()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS}) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Update existing task variable by admin in the same network") + public void updateTaskVariableByAdminInSameNetwork() throws Exception + { + RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser).withWorkflowAPI() + .addProcess("activitiReview", tenantUser, false, CMISUtil.Priority.High); + RestTaskModel task = restClient.authenticateUser(adminTenantUser) + .withWorkflowAPI().usingProcess(networkProcess1).getProcessTasks().getOneRandomEntry(); + + variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + variableModel1 = restClient.withWorkflowAPI().usingTask(task.onModel()) + .updateTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + variableModel1.assertThat().field("scope").is(variableModel1.getScope()) + .and().field("name").is(variableModel1.getName()) + .and().field("type").is(variableModel1.getType()) + .and().field("value").is(variableModel1.getValue()); + + variableModel.setValue("updatedValue"); + variableModel1 = restClient.withWorkflowAPI().usingTask(task.onModel()).updateTaskVariable(variableModel).and().field("value").is("updatedValue"); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify tenant user that created the task can update task only in its network and response is 200, for other networks is 403") + public void ownerTenantCanUpdatedTaskOnlyInItsNetwork() throws Exception + { + + + SiteModel siteModel1 = dataSite.usingUser(tenantUser).createPublicRandomSite(); + FileModel fileModel1 = dataContent.usingUser(tenantUser).usingSite(siteModel1).createContent(DocumentType.TEXT_PLAIN); + RestProcessDefinitionModel def1 = restClient.authenticateUser(tenantUser).withWorkflowAPI().getAllProcessDefinitions().getEntries().get(0).onModel(); + TaskModel taskModel1 = dataWorkflow.usingUser(tenantUser).usingSite(siteModel1).usingResource(fileModel1) + .createTaskWithProcessDefAndAssignTo(def1.getId(), secondTenantUser); + + SiteModel siteModel2 = dataSite.usingUser(differentNetworkTenantUser).createPublicRandomSite(); + FileModel fileModel2 = dataContent.usingUser(differentNetworkTenantUser).usingSite(siteModel2).createContent(DocumentType.TEXT_PLAIN); + RestProcessDefinitionModel def2 = restClient.authenticateUser(differentNetworkTenantUser).withWorkflowAPI().getAllProcessDefinitions().getEntries().get(0).onModel(); + TaskModel taskModel2 = dataWorkflow.usingUser(differentNetworkTenantUser).usingSite(siteModel2).usingResource(fileModel2) + .createTaskWithProcessDefAndAssignTo(def2.getId(), secondAdminTenantUser); + + restTaskModel = restClient.authenticateUser(differentNetworkTenantUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel2).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel2.getId()) + .and().field("state").is("completed"); + + restTaskModel = restClient.authenticateUser(differentNetworkTenantUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel1).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + + } +} diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentCoreTests.java index 1e37d91a7..df2aae3a0 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentCoreTests.java @@ -16,8 +16,8 @@ import org.testng.annotations.Test; */ public class GetDeploymentCoreTests extends RestTest { - private UserModel adminUser, adminTenantUser; - private RestDeploymentModel expectedDeployment, actualDeployment; + private UserModel adminUser; + private RestDeploymentModel expectedDeployment; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception @@ -39,38 +39,4 @@ public class GetDeploymentCoreTests extends RestTest .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidId")); } - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, - executionType = ExecutionType.REGRESSION, - description = "Verify if network admin user gets a network deployment using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION, TestGroup.NETWORKS}) - public void adminGetsNetworkDeploymentWithSuccess() throws Exception - { - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser) - .usingTenant().createTenant(adminTenantUser); - - expectedDeployment = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getDeployments().getOneRandomEntry().onModel(); - actualDeployment = restClient.withWorkflowAPI().usingDeployment(expectedDeployment).getDeployment(); - restClient.assertStatusCodeIs(HttpStatus.OK); - actualDeployment.assertThat().field("deployedAt").isNotEmpty() - .and().field("name").is(expectedDeployment.getName()) - .and().field("id").is(expectedDeployment.getId()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, - executionType = ExecutionType.REGRESSION, - description = "Verify non admin user is forbidden to get a network deployment using REST API (403)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void nonAdminUserIsForbiddenToGetNetworkDeployment() throws Exception - { - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser) - .usingTenant().createTenant(adminTenantUser); - expectedDeployment = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getDeployments().getOneRandomEntry().onModel(); - UserModel tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - - restClient.authenticateUser(tenantUser).withWorkflowAPI().usingDeployment(expectedDeployment).getDeployment(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentFullTests.java index 590f0f2f3..cea14ceca 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentFullTests.java @@ -4,7 +4,6 @@ import org.alfresco.rest.RestTest; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.model.RestDeploymentModel; import org.alfresco.rest.model.RestDeploymentModelsCollection; -import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; @@ -55,26 +54,4 @@ public class GetDeploymentFullTests extends RestTest .field("deployedAt").isNull().and() .field("name").is(expectedDeployment.getName()); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, - executionType = ExecutionType.REGRESSION, - description = "Verify that network admin user is not able to get a deployment from other network using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION, TestGroup.NETWORKS}) - public void adminDoesNotGetDeploymentFromOtherNetwork() throws Exception - { - UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); - UserModel adminTenantUser2 = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser1); - restClient.usingTenant().createTenant(adminTenantUser2); - - expectedDeployment = restClient.authenticateUser(adminTenantUser1).withWorkflowAPI().getDeployments().getOneRandomEntry().onModel(); - actualDeployment = restClient.authenticateUser(adminTenantUser2).withWorkflowAPI().usingDeployment(expectedDeployment).getDeployment(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, expectedDeployment.getId())) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - } diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsCoreTests.java index 000a7f8d0..f35f882a4 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsCoreTests.java @@ -1,18 +1,12 @@ package org.alfresco.rest.workflow.deployments; -import java.util.List; - import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestDeploymentModel; -import org.alfresco.rest.model.RestDeploymentModelsCollection; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; /** @@ -20,14 +14,6 @@ import org.testng.annotations.Test; */ public class GetDeploymentsCoreTests extends RestTest { - private UserModel adminUser, adminTenantUser; - private RestDeploymentModelsCollection deployments; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, @@ -41,41 +27,4 @@ public class GetDeploymentsCoreTests extends RestTest .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, - executionType = ExecutionType.REGRESSION, - description = "Verify non admin user is not able to get network deployments using REST API and status code is Forbidden") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION, TestGroup.NETWORKS}) - public void nonAdminUserCanNotGetNetworkDeployments() throws Exception - { - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser) - .usingTenant().createTenant(adminTenantUser); - - UserModel tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - restClient.authenticateUser(tenantUser).withWorkflowAPI().getDeployments(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Bug(id = "MNT-16996") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, - executionType = ExecutionType.REGRESSION, - description = "Verify get deployments returns an empty list after deleting all network deployments.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION, TestGroup.NETWORKS}) - public void getNetworkDeploymentsAfterDeletingAllNetworkDeployments() throws Exception - { - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser) - .usingTenant().createTenant(adminTenantUser); - List networkDeployments = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getDeployments().getEntries(); - for (RestDeploymentModel networkDeployment: networkDeployments) - { - restClient.withWorkflowAPI().usingDeployment(networkDeployment.onModel()).deleteDeployment(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - deployments = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getDeployments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - deployments.assertThat().entriesListIsEmpty(); - } - } diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsFullTests.java index 697f9978c..6ba152e46 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsFullTests.java @@ -143,21 +143,4 @@ public class GetDeploymentsFullTests extends RestTest .field("name").isNull(); } - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, - executionType = ExecutionType.REGRESSION, - description = "Verify that network admin user is not able to get a deployment from other network using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION, TestGroup.NETWORKS}) - public void adminDoesNotGetDeploymentsFromOtherNetwork() throws Exception - { - UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); - UserModel adminTenantUser2 = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUserModel).usingTenant().createTenant(adminTenantUser1); - restClient.usingTenant().createTenant(adminTenantUser2); - - RestDeploymentModel deployment = restClient.authenticateUser(adminTenantUser1).withWorkflowAPI().getDeployments().getOneRandomEntry().onModel(); - deployments = restClient.authenticateUser(adminTenantUser2).withWorkflowAPI().getDeployments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - deployments.assertThat().entriesListDoesNotContain("id", deployment.getId()); - } - } diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsSanityTests.java index 6eab0bae6..9d1a4025f 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsSanityTests.java @@ -16,14 +16,13 @@ import org.testng.annotations.Test; */ public class GetDeploymentsSanityTests extends RestTest { - private UserModel adminUserModel, adminTenantUser; + private UserModel adminUserModel; private RestDeploymentModelsCollection deployments; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception { adminUserModel = dataUser.getAdminUser(); - adminTenantUser = UserModel.getAdminTenantUser(); restClient.authenticateUser(adminUserModel); } @@ -42,14 +41,4 @@ public class GetDeploymentsSanityTests extends RestTest .field("name").isNotEmpty(); } - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.SANITY, - description = "Verify Tenant Admin user gets network deployments using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.SANITY, TestGroup.NETWORKS}) - public void getNetworkDeploymentsWithAdmin() throws JsonToModelConversionException, Exception - { - restClient.usingTenant().createTenant(adminTenantUser); - deployments = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getDeployments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - deployments.assertThat().entriesListIsNotEmpty(); - } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionCoreTests.java index db94b2011..3edb7e020 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionCoreTests.java @@ -16,8 +16,8 @@ import org.testng.annotations.Test; */ public class GetProcessDefinitionCoreTests extends RestTest { - private UserModel adminUser, adminTenantUser; - private RestProcessDefinitionModel randomProcessDefinition, returnedProcessDefinition; + private UserModel adminUser; + private RestProcessDefinitionModel randomProcessDefinition; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception @@ -42,37 +42,4 @@ public class GetProcessDefinitionCoreTests extends RestTest .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) .stackTraceIs(RestErrorModel.STACKTRACE); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, - executionType = ExecutionType.REGRESSION, - description = "Verify network admin is able to get a process definition using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void networkAdminGetProcessDefinition() throws Exception - { - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser) - .usingTenant().createTenant(adminTenantUser); - randomProcessDefinition = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry().onModel(); - returnedProcessDefinition = restClient.withWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinition(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedProcessDefinition.assertThat().field("name").is(randomProcessDefinition.getName()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, - executionType = ExecutionType.REGRESSION, - description = "Verify network user is able to get a process definition using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void networkUserGetProcessDefinition() throws Exception - { - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser) - .usingTenant().createTenant(adminTenantUser); - UserModel tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - randomProcessDefinition = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() - .getAllProcessDefinitions().getOneRandomEntry().onModel(); - returnedProcessDefinition = restClient.authenticateUser(tenantUser).withWorkflowAPI() - .usingProcessDefinitions(randomProcessDefinition).getProcessDefinition(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedProcessDefinition.assertThat().field("name").is(randomProcessDefinition.getName()); - } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionFullTests.java index 390f9845c..17c2b6972 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionFullTests.java @@ -2,7 +2,6 @@ package org.alfresco.rest.workflow.processDefinitions; import org.alfresco.rest.RestTest; import org.alfresco.rest.core.RestRequest; -import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessDefinitionModel; import org.alfresco.rest.model.RestProcessDefinitionModelsCollection; import org.alfresco.utility.model.TestGroup; @@ -65,26 +64,4 @@ public class GetProcessDefinitionFullTests extends RestTest .field("key").isNull().and() .field("name").is(randomProcessDefinition.getName()); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, - executionType = ExecutionType.REGRESSION, - description = "Verify Network user is not able to get a process definition from another network") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.NETWORKS, TestGroup.REGRESSION }) - public void getProcessDefinitionFromAnotherNetwork() throws Exception - { - UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); - UserModel adminTenantUser2 = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser1); - restClient.usingTenant().createTenant(adminTenantUser2); - - randomProcessDefinition = restClient.authenticateUser(adminTenantUser1).withWorkflowAPI() - .getAllProcessDefinitions().getOneRandomEntry().onModel(); - restClient.authenticateUser(adminTenantUser2).withWorkflowAPI() - .usingProcessDefinitions(randomProcessDefinition).getProcessDefinition(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, randomProcessDefinition.getId())) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageCoreTests.java index 1aa871cd9..2fe6f5f3c 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageCoreTests.java @@ -5,7 +5,6 @@ import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessDefinitionModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -17,7 +16,7 @@ import org.testng.annotations.Test; */ public class GetProcessDefinitionImageCoreTests extends RestTest { - private UserModel adminUser, adminTenantUser; + private UserModel adminUser; private RestProcessDefinitionModel randomProcessDefinition; @BeforeClass(alwaysRun = true) @@ -44,40 +43,4 @@ public class GetProcessDefinitionImageCoreTests extends RestTest .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) .stackTraceIs(RestErrorModel.STACKTRACE); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, - executionType = ExecutionType.REGRESSION, - description = "Verify network admin is able to get a process definition image using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION, TestGroup.NETWORKS}) - @Bug(id = "MNT-17243") - public void networkAdminGetProcessDefinitionImage() throws Exception - { - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser) - .usingTenant().createTenant(adminTenantUser); - - randomProcessDefinition = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry().onModel(); - restClient.withWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionImage() - .assertResponseContainsImage(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESS_DEFINITION }, - executionType = ExecutionType.REGRESSION, - description = "Verify network user is able to get a process definition image using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION, TestGroup.NETWORKS}) - @Bug(id = "MNT-17243") - public void networkUserGetProcessDefinitionImage() throws Exception - { - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser) - .usingTenant().createTenant(adminTenantUser); - UserModel tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - randomProcessDefinition = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() - .getAllProcessDefinitions().getOneRandomEntry().onModel(); - restClient.authenticateUser(tenantUser).withWorkflowAPI() - .usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionImage() - .assertResponseContainsImage(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageFullTests.java index b0c091dae..9c37e7c46 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageFullTests.java @@ -1,7 +1,6 @@ package org.alfresco.rest.workflow.processDefinitions; import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessDefinitionModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; @@ -40,23 +39,4 @@ public class GetProcessDefinitionImageFullTests extends RestTest .usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionImage(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, - executionType = ExecutionType.REGRESSION, - description = "Verify Tenant User doesn't get process definition image for another network deployment using REST API") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void networkUserIsNotAbleToGetProcessDefinitionImageForAnotherNetwork() throws Exception - { - UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); - UserModel adminTenantUser2 = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser1); - restClient.usingTenant().createTenant(adminTenantUser2); - - RestProcessDefinitionModel randomProcessDefinition = restClient.authenticateUser(adminTenantUser1).withWorkflowAPI() - .getAllProcessDefinitions().getOneRandomEntry().onModel(); - restClient.authenticateUser(adminTenantUser2).withWorkflowAPI() - .usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionImage(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, randomProcessDefinition.getId())); - } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java index 9ba813044..6290ad9f6 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java @@ -18,7 +18,7 @@ import org.testng.annotations.Test; */ public class GetProcessDefinitionStartFormModelCoreTests extends RestTest { - private UserModel adminUser, adminTenantUser; + private UserModel adminUser; private RestProcessDefinitionModel randomProcessDefinition; private RestProcessDefinitionModelsCollection allProcessDefinitions; @@ -77,22 +77,4 @@ public class GetProcessDefinitionStartFormModelCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) .assertLastError().containsSummary("no deployed process definition found with id ''"); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, - executionType = ExecutionType.REGRESSION, - description = "Verify Tenant User gets a model of the start form type definition for network deployments using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void networkUserGetsStartFormModel() throws Exception - { - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser) - .usingTenant().createTenant(adminTenantUser); - UserModel tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - randomProcessDefinition = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() - .getAllProcessDefinitions().getOneRandomEntry().onModel(); - restClient.authenticateUser(tenantUser).withWorkflowAPI() - .usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionStartFormModel() - .assertThat().entriesListIsNotEmpty(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelFullTests.java index 735af3df4..fa77452a4 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelFullTests.java @@ -3,7 +3,6 @@ package org.alfresco.rest.workflow.processDefinitions; import java.util.Arrays; import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestFormModelsCollection; import org.alfresco.rest.model.RestProcessDefinitionModel; import org.alfresco.utility.model.TestGroup; @@ -69,24 +68,4 @@ public class GetProcessDefinitionStartFormModelFullTests extends RestTest .and().field("required").isNull() .and().field("allowedValues").isNull(); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, - executionType = ExecutionType.REGRESSION, - description = "Verify Tenant User doesn't get a model of the start form type definition for another network deployment using REST API") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void networkUserIsNotAbleToGetStartFormModelForAnotherNetwork() throws Exception - { - UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); - UserModel adminTenantUser2 = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser1); - restClient.usingTenant().createTenant(adminTenantUser2); - - RestProcessDefinitionModel randomProcessDefinition = restClient.authenticateUser(adminTenantUser1).withWorkflowAPI() - .getAllProcessDefinitions().getOneRandomEntry().onModel(); - restClient.authenticateUser(adminTenantUser2).withWorkflowAPI() - .usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionStartFormModel(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, randomProcessDefinition.getId())); - } - } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java index 3c35bd28b..7b3d98aef 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java @@ -15,14 +15,13 @@ import org.testng.annotations.Test; */ public class GetProcessDefinitionStartFormModelSanityTests extends RestTest { - private UserModel adminUserModel, adminTenantUser; + private UserModel adminUserModel; private RestProcessDefinitionModel randomProcessDefinition; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception { adminUserModel = dataUser.getAdminUser(); - adminTenantUser = UserModel.getAdminTenantUser(); restClient.authenticateUser(adminUserModel); } @@ -36,17 +35,4 @@ public class GetProcessDefinitionStartFormModelSanityTests extends RestTest restClient.withWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionStartFormModel().assertThat().entriesListIsNotEmpty(); restClient.assertStatusCodeIs(HttpStatus.OK); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, - executionType = ExecutionType.SANITY, - description = "Verify Tenant Admin gets a model of the start form type definition for network deployments using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY, TestGroup.NETWORKS }) - public void networkAdminGetsStartFormModel() throws Exception - { - restClient.usingTenant().createTenant(adminTenantUser); - restClient.authenticateUser(adminTenantUser); - randomProcessDefinition = restClient.withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry().onModel(); - restClient.withWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionStartFormModel().assertThat().entriesListIsNotEmpty(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsCoreTests.java index 09d5ebf65..6d4e492ff 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsCoreTests.java @@ -12,31 +12,12 @@ import org.testng.annotations.Test; public class GetProcessDefinitionsCoreTests extends RestTest { - private UserModel adminUserModel; private UserModel userModel; - private UserModel adminTenantUser; - private UserModel tenantUser; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception { - adminUserModel = dataUser.getAdminUser(); userModel = dataUser.createRandomTestUser(); - adminTenantUser = UserModel.getAdminTenantUser(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, - description = "Verify get process definitions using any network user for network enabled deployments with REST API status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION, TestGroup.NETWORKS}) - public void networkUserGetsProcessDefinitions() throws Exception - { - restClient.authenticateUser(adminUserModel).usingTenant().createTenant(adminTenantUser); - tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - restClient.authenticateUser(tenantUser) - .withWorkflowAPI() - .getAllProcessDefinitions() - .assertThat().entriesListIsNotEmpty(); - restClient.assertStatusCodeIs(HttpStatus.OK); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsFullTests.java index 47f2525da..6d4f929e7 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsFullTests.java @@ -171,23 +171,4 @@ public class GetProcessDefinitionsFullTests extends RestTest .assertThat().entriesListContains("key", "activitiParallelGroupReview"); } - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, - executionType = ExecutionType.REGRESSION, - description = "Verify Tenant User doesn't get process definitions for another network deployment using REST API") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void networkUserIsNotAbleToGetProcessDefinitionsForAnotherNetwork() throws Exception - { - UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); - UserModel adminTenantUser2 = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUserModel).usingTenant().createTenant(adminTenantUser1); - restClient.usingTenant().createTenant(adminTenantUser2); - - RestProcessDefinitionModel randomProcessDefinitionTenant1 = restClient.authenticateUser(adminTenantUser1).withWorkflowAPI() - .getAllProcessDefinitions().getOneRandomEntry().onModel(); - RestProcessDefinitionModelsCollection processDefinitionsTenant2 = restClient.authenticateUser(adminTenantUser2).withWorkflowAPI() - .getAllProcessDefinitions(); - restClient.assertStatusCodeIs(HttpStatus.OK); - processDefinitionsTenant2.assertThat().entriesListDoesNotContain("id", randomProcessDefinitionTenant1.getId()); - } - } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java index 1dc68b58c..f0a330d7c 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java @@ -15,13 +15,12 @@ import org.testng.annotations.Test; */ public class GetProcessDefinitionsSanityTests extends RestTest { - private UserModel adminUserModel, adminTenantUser; + private UserModel adminUserModel; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception { adminUserModel = dataUser.getAdminUser(); - adminTenantUser = UserModel.getAdminTenantUser(); restClient.authenticateUser(adminUserModel); } @@ -46,15 +45,4 @@ public class GetProcessDefinitionsSanityTests extends RestTest .field("graphicNotationDefined").is("true").and() .field("key").is("activitiAdhoc"); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, - executionType = ExecutionType.SANITY, description = "Verify Tenant Admin user gets process definitions for network deployments using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY, TestGroup.NETWORKS}) - public void networkAdminGetsProcessDefinitions() throws Exception - { - restClient.usingTenant().createTenant(adminTenantUser); - restClient.authenticateUser(adminTenantUser); - restClient.withWorkflowAPI().getAllProcessDefinitions().assertThat().entriesListIsNotEmpty(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessFullTests.java index fbe203654..c1eb6b24a 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessFullTests.java @@ -7,7 +7,6 @@ import org.alfresco.rest.RestTest; import org.alfresco.rest.core.JsonBodyGenerator; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestProcessDefinitionModel; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; @@ -33,50 +32,7 @@ public class AddProcessFullTests extends RestTest { assignee = dataUser.createRandomTestUser(); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify network user cannot start new process with processDefinitionKey from another network using REST API and status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS}) - public void networkUserCannotStartNewProcessWithProcessDefinitionFromAnotherNetwork() throws JsonToModelConversionException, Exception - { - UserModel adminTenant1 = UserModel.getAdminTenantUser(); - restClient.authenticateUser(dataUser.getAdminUser()).usingTenant().createTenant(adminTenant1); - RestProcessDefinitionModel firstProcessDefTenant1 = restClient.authenticateUser(adminTenant1).withWorkflowAPI().getAllProcessDefinitions().getEntries().get(0).onModel(); - - UserModel adminTenant2 = UserModel.getAdminTenantUser(); - restClient.authenticateUser(dataUser.getAdminUser()).usingTenant().createTenant(adminTenant2); - UserModel assigneeTenant2 = dataUser.usingUser(adminTenant2).createUserWithTenant("assigneeT2"); - String processDefinitionKey = firstProcessDefTenant1.getId().substring(0,firstProcessDefTenant1.getId().indexOf(":")); - addedProcess = restClient.authenticateUser(adminTenant2).withWorkflowAPI().addProcess(processDefinitionKey, assigneeTenant2, false, Priority.Normal); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(String.format(RestErrorModel.NO_WORKFLOW_DEFINITION_FOUND, processDefinitionKey)) - .containsSummary(String.format(RestErrorModel.NO_WORKFLOW_DEFINITION_FOUND, processDefinitionKey)) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify network user can start new process with processDefinitionKey from same network using REST API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS}) - public void networkUserCanStartNewProcessWithProcessDefinitionFromSameNetwork() throws JsonToModelConversionException, Exception - { - UserModel adminTenant1 = UserModel.getAdminTenantUser(); - restClient.authenticateUser(dataUser.getAdminUser()).usingTenant().createTenant(adminTenant1); - RestProcessDefinitionModel firstProcessDefTenant1 = restClient.authenticateUser(adminTenant1).withWorkflowAPI().getAllProcessDefinitions().getEntries().get(0).onModel(); - - UserModel processStarterTenant1 = dataUser.usingUser(adminTenant1).createUserWithTenant("startert1"); - UserModel assigneeTenant1 = dataUser.usingUser(adminTenant1).createUserWithTenant("assigneet1"); - - - String processDefinitionKey = firstProcessDefTenant1.getKey(); - addedProcess = restClient.authenticateUser(processStarterTenant1).withWorkflowAPI().addProcess(processDefinitionKey, assigneeTenant1, false, Priority.Normal); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - addedProcess.assertThat().field("processDefinitionId").is(firstProcessDefTenant1.getId()) - .and().field("startUserId").is(processStarterTenant1.getEmailAddress().toLowerCase()) - .and().field("processDefinitionKey").is(processDefinitionKey); - } - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot start new process with invalid processDefinitionKey using REST API and status code is 400") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessSanityTests.java index f84a3938b..e43e59203 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessSanityTests.java @@ -18,7 +18,6 @@ import org.testng.annotations.Test; public class AddProcessSanityTests extends RestTest { private UserModel userWhoStartsProcess, assignee; - private UserModel adminTenantUser, tenantUserWhoStartsProcess, tenantAssignee; private RestProcessModel addedProcess; private RestProcessModelsCollection processes; @@ -42,25 +41,4 @@ public class AddProcessSanityTests extends RestTest } - @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW, - TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Verify network user is able to start new process using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY, TestGroup.NETWORKS }) - public void networkUserStartsNewProcess() throws JsonToModelConversionException, Exception - { - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(dataUser.getAdminUser()) - .usingTenant().createTenant(adminTenantUser); - tenantUserWhoStartsProcess = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - tenantAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("u2Tenant"); - - addedProcess = restClient.authenticateUser(tenantUserWhoStartsProcess).withWorkflowAPI().addProcess("activitiAdhoc", tenantAssignee, false, Priority.Normal); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - addedProcess.assertThat().field("id").is(addedProcess.getId()) - .and().field("startUserId").is(addedProcess.getStartUserId()); - - processes = restClient.withWorkflowAPI().getProcesses(); - restClient.assertStatusCodeIs(HttpStatus.OK); - processes.assertThat().entriesListContains("id", addedProcess.getId()); - } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessCoreTests.java index 3a162070e..9e7076603 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessCoreTests.java @@ -6,7 +6,6 @@ import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.apache.commons.lang.RandomStringUtils; @@ -16,12 +15,11 @@ import org.testng.annotations.Test; public class GetProcessCoreTests extends RestTest { - private UserModel userWhoStartsProcess, assignee, adminUser; + private UserModel userWhoStartsProcess, assignee; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception { - adminUser = dataUser.getAdminUser(); userWhoStartsProcess = dataUser.createRandomTestUser(); assignee = dataUser.createRandomTestUser(); } @@ -43,62 +41,4 @@ public class GetProcessCoreTests extends RestTest .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) .stackTraceIs(RestErrorModel.STACKTRACE); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES}, executionType = ExecutionType.REGRESSION, - description = "Verify that tenant user cannot get process from another network") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - @Bug(id = "REPO-2092") - public void tenantUserCannotGetProcessFromAnotherNetwork() throws Exception - { - UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser1); - - UserModel adminTenantUser2 = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser2); - - UserModel tenantUser1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenant1"); - UserModel tenantUser2 = dataUser.usingUser(adminTenantUser2).createUserWithTenant("uTenant2"); - - RestProcessModel networkProcess1 = restClient.authenticateUser(adminTenantUser1).withWorkflowAPI().addProcess("activitiReview", tenantUser1, false, CMISUtil.Priority.High); - - restClient.authenticateUser(tenantUser2).withWorkflowAPI().usingProcess(networkProcess1).getProcess(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError().containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify that tenant user can get process from the same network") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void tenantUserCanGetProcessFromTheSameNetwork() throws Exception - { - UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser1); - UserModel tenantUser1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenant1"); - - RestProcessModel networkProcess1 = restClient.authenticateUser(adminTenantUser1).withWorkflowAPI().addProcess("activitiReview", tenantUser1, false, CMISUtil.Priority.High); - - restClient.authenticateUser(tenantUser1).withWorkflowAPI().usingProcess(networkProcess1).getProcess(); - restClient.assertStatusCodeIs(HttpStatus.OK); - networkProcess1.assertThat().field("id").is(networkProcess1.getId()) - .and().field("startUserId").is(networkProcess1.getStartUserId());; - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES}, executionType = ExecutionType.REGRESSION, - description = "Verify that non network user cannot get process from a network") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - @Bug(id = "REPO-2092") - public void nonNetworkUserCannotAccessNetworkProcess() throws Exception - { - UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser1); - UserModel tenantUser1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenant1"); - - RestProcessModel networkProcess1 = restClient.authenticateUser(adminTenantUser1).withWorkflowAPI().addProcess("activitiReview", tenantUser1, false, CMISUtil.Priority.High); - - restClient.authenticateUser(adminUser).withWorkflowAPI().usingProcess(networkProcess1).getProcess(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError().containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessFullTests.java index 7dd629602..933e66829 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessFullTests.java @@ -29,28 +29,6 @@ public class GetProcessFullTests extends RestTest addedProcess = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.High); } - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin user can get process started by a network user") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void adminUserCanGetProcessFromANetwork() throws Exception - { - UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); - restClient.authenticateUser(dataUser.getAdminUser()).usingTenant().createTenant(adminTenantUser1); - UserModel tenantUser1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("utenant1"); - - RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser1).withWorkflowAPI().addProcess("activitiReview", adminTenantUser1, false, CMISUtil.Priority.High); - - restClient.authenticateUser(dataUser.getAdminUser()).withWorkflowAPI().usingProcess(networkProcess1).getProcess(); - restClient.assertStatusCodeIs(HttpStatus.OK); - networkProcess1.assertThat().field("processDefinitionId").contains(String.format("@%s%s", tenantUser1.getDomain().toLowerCase(), "@activitiReview:1")) - .and().field("startUserId").is(tenantUser1.getEmailAddress().toLowerCase()) - .and().field("startActivityId").is("start") - .and().field("startedAt").isNotEmpty() - .and().field("id").is(networkProcess1.getId()) - .and().field("completed").is(false) - .and().field("processDefinitionKey").is("activitiReview"); - } - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify user is able to get the process with properties parameter applied using REST API") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesCoreTests.java index 628721598..f45147d00 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesCoreTests.java @@ -3,7 +3,6 @@ package org.alfresco.rest.workflow.processes; import java.util.List; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.dataprep.CMISUtil.Priority; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestProcessModel; @@ -29,7 +28,7 @@ public class GetProcessesCoreTests extends RestTest { private FileModel document; private SiteModel siteModel; - private UserModel adminUser, userWhoStartsTask, assignee, adminTenantUser; + private UserModel adminUser, userWhoStartsTask, assignee ; private TaskModel task1, task2; private ProcessModel process3; @@ -46,23 +45,6 @@ public class GetProcessesCoreTests extends RestTest process3 = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createSingleReviewerTaskAndAssignTo(assignee); } - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify admin gets all processes from same network") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void getProcessFromSameNetworkUsingAdmin() throws Exception - { - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser); - UserModel tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - UserModel tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); - RestProcessModel process = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee, false, Priority.Normal); - - RestProcessModelsCollection tenantProcesses = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getProcesses(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - tenantProcesses.assertThat().entriesListContains("id", process.getId()); - } - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets all processes started by him ordered descending by id") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesFullTests.java index 1afb42225..c4595920e 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesFullTests.java @@ -3,7 +3,6 @@ package org.alfresco.rest.workflow.processes; import java.util.List; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.dataprep.CMISUtil.Priority; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessModel; @@ -47,23 +46,6 @@ public class GetProcessesFullTests extends RestTest process3 = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createSingleReviewerTaskAndAssignTo(assignee); } - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify any user cannot get processes from same network") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void getProcessFromSameNetworkUsingAnyUser() throws Exception - { - UserModel adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser); - UserModel tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - UserModel tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); - restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee, false, Priority.Normal); - - UserModel otherTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("otherTenant"); - RestProcessModelsCollection tenantProcesses = restClient.authenticateUser(otherTenantUser).withWorkflowAPI().getProcesses(); - restClient.assertStatusCodeIs(HttpStatus.OK); - tenantProcesses.assertThat().entriesListIsEmpty().and().paginationField("count").is("0"); - } - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets processes when skipCount parameter is applied") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemCoreTests.java index 8d3846e57..9eaa02099 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemCoreTests.java @@ -1,7 +1,6 @@ package org.alfresco.rest.workflow.processes.items; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.dataprep.CMISUtil.Priority; import org.alfresco.rest.RestTest; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.model.RestErrorModel; @@ -25,7 +24,7 @@ public class AddProcessItemCoreTests extends RestTest { private FileModel document, document2; private SiteModel siteModel; - private UserModel userWhoStartsProcess, assignee, adminUser, anotherUser, adminTenantUser, tenantUserAssignee, adminTenantUser2, tenantUser; + private UserModel userWhoStartsProcess, assignee, adminUser, anotherUser; private RestProcessModel processModel; private RestItemModel processItem; private RestItemModelsCollection processItems; @@ -116,103 +115,6 @@ public class AddProcessItemCoreTests extends RestTest .containsSummary(String.format(RestErrorModel.ACCESS_INFORMATION_NOT_ALLOWED, processModel.getId())); } - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Add process item using by the admin in same network.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void addProcessItemByAdminSameNetwork() throws Exception - { - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(dataUser.getAdminUser()).usingTenant().createTenant(adminTenantUser); - tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); - processModel = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee, false, Priority.Normal); - - siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); - document = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - processItem = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().usingProcess(processModel).addProcessItem(document); - - restClient.assertStatusCodeIs(HttpStatus.CREATED); - processItem.assertThat().field("createdAt").isNotEmpty().and().field("size").is("19").and().field("createdBy").is(adminTenantUser.getUsername().toLowerCase()).and() - .field("modifiedAt").isNotEmpty().and().field("name").is(document.getName()).and().field("modifiedBy").is(adminTenantUser.getUsername().toLowerCase()).and() - .field("id").isNotEmpty().and().field("mimeType").is(document.getFileType().mimeType); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Add multiple process items using by the admin in same network.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void addMultipleProcessItemsByAdminSameNetwork() throws Exception - { - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(dataUser.getAdminUser()).usingTenant().createTenant(adminTenantUser); - tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); - processModel = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee, false, Priority.Normal); - - siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); - document = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - document2 = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - processItems = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().usingProcess(processModel).addProcessItems(document, document2); - - restClient.assertStatusCodeIs(HttpStatus.CREATED); - processItems.getEntries().get(0).onModel().assertThat() - .field("createdAt").isNotEmpty().and() - .field("size").is("19").and() - .field("createdBy").is(adminTenantUser.getUsername().toLowerCase()).and() - .field("modifiedAt").isNotEmpty().and() - .field("name").is(document.getName()).and() - .field("modifiedBy").is(adminTenantUser.getUsername().toLowerCase()).and() - .field("id").isNotEmpty().and() - .field("mimeType").is(document.getFileType().mimeType); - processItems.getEntries().get(1).onModel().assertThat() - .field("createdAt").isNotEmpty().and() - .field("size").is("19").and() - .field("createdBy").is(adminTenantUser.getUsername().toLowerCase()).and() - .field("modifiedAt").isNotEmpty().and() - .field("name").is(document2.getName()).and() - .field("modifiedBy").is(adminTenantUser.getUsername().toLowerCase()).and() - .field("id").isNotEmpty().and() - .field("mimeType").is(document2.getFileType().mimeType); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Add process item using by admin in other network.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void addProcessItemByAdminInOtherNetwork() throws Exception - { - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser); - tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); - - adminTenantUser2 = UserModel.getAdminTenantUser(); - restClient.usingTenant().createTenant(adminTenantUser2); - - processModel = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee, false, Priority.Normal); - restClient.authenticateUser(adminTenantUser2); - processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Add multiple process items using by admin in other network.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void addMultipleProcessItemsByAdminInOtherNetwork() throws Exception - { - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser); - tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); - - adminTenantUser2 = UserModel.getAdminTenantUser(); - restClient.usingTenant().createTenant(adminTenantUser2); - - processModel = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee, false, Priority.Normal); - restClient.authenticateUser(adminTenantUser2); - - processItems = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItems(document, document2); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError() - .containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT); - } - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process item is falling in case of invalid process id is provided") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/items/DeleteProcessItemFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/items/DeleteProcessItemFullTests.java index a21099ff7..3afd2e31c 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/items/DeleteProcessItemFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/items/DeleteProcessItemFullTests.java @@ -1,6 +1,5 @@ package org.alfresco.rest.workflow.processes.items; -import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.CMISUtil.Priority; import org.alfresco.rest.RestTest; @@ -23,7 +22,7 @@ public class DeleteProcessItemFullTests extends RestTest { private FileModel document, document2; private SiteModel siteModel; - private UserModel userWhoStartsProcess, assignee, adminUser, anotherUser, adminTenantUser, tenantUser, tenantUserAssignee, adminTenantUser2; + private UserModel userWhoStartsProcess, assignee, adminUser, anotherUser; private ProcessModel processModel; private RestItemModelsCollection items; private RestItemModel processItem; @@ -213,57 +212,4 @@ public class DeleteProcessItemFullTests extends RestTest restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingProcess(processModel) .deleteProcessItem(items.getOneRandomEntry()); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Delete process item using by the admin in same network.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void deleteProcessItemByAdminSameNetwork() throws Exception - { - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(dataUser.getAdminUser()).usingTenant().createTenant(adminTenantUser); - tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); - processModel = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee, false, CMISUtil.Priority.Normal); - - siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); - document = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(adminTenantUser).withWorkflowAPI().usingProcess(processModel) - .deleteProcessItem(processItem); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() - .assertThat().entriesListDoesNotContain("name", processItem.getName()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Delete process item using by admin in other network.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void deleteProcessItemByAdminInOtherNetwork() throws Exception - { - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser); - tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); - - adminTenantUser2 = UserModel.getAdminTenantUser(); - restClient.authenticateUser(dataUser.getAdminUser()).usingTenant().createTenant(adminTenantUser2); - - processModel = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee, false, CMISUtil.Priority.Normal); - siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); - document = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(adminTenantUser2).withWorkflowAPI().usingProcess(processModel) - .deleteProcessItem(processItem); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError() - .containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .containsErrorKey(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/items/GetProcessItemsFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/items/GetProcessItemsFullTests.java index 400f11d33..c81c5c3f4 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/items/GetProcessItemsFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/items/GetProcessItemsFullTests.java @@ -23,7 +23,7 @@ public class GetProcessItemsFullTests extends RestTest { private FileModel document1, document2, document3; private SiteModel siteModel; - private UserModel userWhoStartsTask, assignee, adminTenantUser, tenantUser, tenantUserAssignee; + private UserModel userWhoStartsTask, assignee; private RestProcessModel processModel; private RestItemModelsCollection items; @@ -38,60 +38,6 @@ public class GetProcessItemsFullTests extends RestTest document3 = dataContent.usingUser(userWhoStartsTask).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Get process items using admin from different network") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void getProcessItemsUsingAdminUserFromDifferentNetwork() throws Exception - { - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(dataUser.getAdminUser()).usingTenant().createTenant(adminTenantUser); - tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); - processModel = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee, false, CMISUtil.Priority.Normal); - - siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); - document1 = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document1); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - UserModel adminTenantUser2 = UserModel.getAdminTenantUser(); - restClient.authenticateUser(dataUser.getAdminUser()).usingTenant().createTenant(adminTenantUser2); - - restClient.authenticateUser(adminTenantUser2).withWorkflowAPI().usingProcess(processModel).getProcessItems(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Get process items using admin from different network") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void getProcessItemsReturnsOnlyItemsInsideNetwork() throws Exception - { - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(dataUser.getAdminUser()).usingTenant().createTenant(adminTenantUser); - tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); - processModel = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee, false, CMISUtil.Priority.Normal); - - siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); - document1 = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document1); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - UserModel adminTenantUser2 = UserModel.getAdminTenantUser(); - restClient.authenticateUser(dataUser.getAdminUser()).usingTenant().createTenant(adminTenantUser2); - RestProcessModel processModel2 = restClient.authenticateUser(adminTenantUser2).withWorkflowAPI().addProcess("activitiAdhoc", adminTenantUser2, false, CMISUtil.Priority.Normal); - - SiteModel siteModel2 = dataSite.usingUser(adminTenantUser2).createPublicRandomSite(); - document2 = dataContent.usingUser(adminTenantUser2).usingSite(siteModel2).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - restClient.authenticateUser(adminTenantUser2).withWorkflowAPI().usingProcess(processModel2).addProcessItem(document2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - items = restClient.withWorkflowAPI().usingProcess(processModel2).getProcessItems(); - restClient.assertStatusCodeIs(HttpStatus.OK); - items.assertThat().entriesListDoesNotContain("name", document1.getName()); - } - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Get process items for process without items") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION}) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/items/GetProcessItemsSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/items/GetProcessItemsSanityTests.java index 68ba5ceae..6c0ce3764 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/items/GetProcessItemsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/items/GetProcessItemsSanityTests.java @@ -1,7 +1,6 @@ package org.alfresco.rest.workflow.processes.items; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.dataprep.CMISUtil.Priority; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestItemModelsCollection; import org.alfresco.rest.model.RestProcessModel; @@ -22,7 +21,7 @@ public class GetProcessItemsSanityTests extends RestTest { private FileModel document; private SiteModel siteModel; - private UserModel userWhoStartsTask, assignee, adminTenantUser, tenantUser, tenantUserAssignee; + private UserModel userWhoStartsTask, assignee; private RestProcessModel processModel; private RestItemModelsCollection items; @@ -57,26 +56,4 @@ public class GetProcessItemsSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); items.assertThat().entriesListIsNotEmpty(); } - - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Get process items using admin from same network") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY, TestGroup.NETWORKS }) - public void getProcessItemsUsingAdminUserFromSameNetwork() throws Exception - { - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(dataUser.getAdminUser()).usingTenant().createTenant(adminTenantUser); - tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); - processModel = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee, false, Priority.Normal); - - siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); - document = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); - - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - items = restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems(); - restClient.assertStatusCodeIs(HttpStatus.OK); - items.assertThat().entriesListContains("name", document.getName()); - } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/tasks/GetProcessTasksCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/tasks/GetProcessTasksCoreTests.java index 6d779373e..93bb26a4b 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/tasks/GetProcessTasksCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/tasks/GetProcessTasksCoreTests.java @@ -3,7 +3,6 @@ package org.alfresco.rest.workflow.processes.tasks; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestProcessModel; import org.alfresco.rest.model.RestTaskModel; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.GroupModel; @@ -21,14 +20,13 @@ public class GetProcessTasksCoreTests extends RestTest { private FileModel document, document1, document2; private SiteModel siteModel; - private UserModel adminUser, userWhoStartsProcess, candidate, anotherAssignee, assignee; + private UserModel userWhoStartsProcess, candidate, anotherAssignee, assignee; private ProcessModel process; private GroupModel group; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception { - adminUser = dataUser.getAdminUser(); userWhoStartsProcess = dataUser.createRandomTestUser(); candidate = dataUser.createRandomTestUser(); anotherAssignee = dataUser.createRandomTestUser(); @@ -57,46 +55,6 @@ public class GetProcessTasksCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify getProcessTasks using admin from same network with REST API and status code is OK") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void getProcessTasksWithAdminFromSameNetwork() throws Exception - { - UserModel adminTenant = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenant); - SiteModel siteModel = dataSite.usingUser(adminTenant).createPublicRandomSite(); - UserModel tenantAssignee = dataUser.usingUser(adminTenant).createUserWithTenant("uTenant"); - dataContent.usingUser(adminTenant).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - - RestProcessModel processModel = restClient.authenticateUser(tenantAssignee).withWorkflowAPI().addProcess("activitiAdhoc", tenantAssignee, false, CMISUtil.Priority.Normal); - - restClient.authenticateUser(adminTenant).withWorkflowAPI() - .usingProcess(processModel).getProcessTasks().assertThat().entriesListIsNotEmpty(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify getProcessTasks using admin from different network with REST API and status code is FORBIDDEN (403)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void getProcessTasksWithAdminFromDifferentNetwork() throws Exception - { - UserModel adminTenant, secondAdminTenant, tenantAssignee; - adminTenant = UserModel.getAdminTenantUser(); - secondAdminTenant = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenant); - - SiteModel siteModel = dataSite.usingUser(adminTenant).createPublicRandomSite(); - dataContent.usingUser(adminTenant).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - tenantAssignee = dataUser.usingUser(adminTenant).createUserWithTenant("uTenant"); - RestProcessModel processModel = restClient.authenticateUser(adminTenant).withWorkflowAPI().addProcess("activitiAdhoc", tenantAssignee, false, CMISUtil.Priority.Normal); - - restClient.authenticateUser(adminUser).usingTenant().createTenant(secondAdminTenant); - restClient.authenticateUser(secondAdminTenant).withWorkflowAPI() - .usingProcess(processModel).getProcessTasks().assertThat().entriesListIsEmpty(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT); - } - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "getProcessTasks for invalid processId with REST API and status code is NOT_FOUND (404)") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariableCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariableCoreTests.java index 8563d1676..d1dc33782 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariableCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariableCoreTests.java @@ -23,7 +23,7 @@ public class AddProcessVariableCoreTests extends RestTest { private FileModel document; private SiteModel siteModel; - private UserModel userWhoStartsProcess, assignee, adminUser, anotherUser, adminTenantUser, adminTenantUser2, tenantUserAssignee; + private UserModel userWhoStartsProcess, assignee, adminUser, anotherUser; private RestProcessModel processModel; private RestProcessVariableModel variableModel, processVariable; @@ -185,26 +185,4 @@ public class AddProcessVariableCoreTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE); } - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Add process variable using by admin in other network.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void addProcessVariableByAdminInOtherNetwork() throws Exception - { - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser); - tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); - - adminTenantUser2 = UserModel.getAdminTenantUser(); - restClient.usingTenant().createTenant(adminTenantUser2); - - processModel = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee, false, Priority.Normal); - - restClient.authenticateUser(adminTenantUser2); - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError() - .containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT); - } - } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariableSanityTests.java index f53d84f18..fed3c5c70 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariableSanityTests.java @@ -1,7 +1,6 @@ package org.alfresco.rest.workflow.processes.variables; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.dataprep.CMISUtil.Priority; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessModel; @@ -24,7 +23,7 @@ public class AddProcessVariableSanityTests extends RestTest { private FileModel document; private SiteModel siteModel; - private UserModel userWhoStartsTask, assignee, adminUser, adminTenantUser, tenantUser, tenantUserAssignee; + private UserModel userWhoStartsTask, assignee, adminUser; private RestProcessModel processModel; private RestProcessVariableModel variableModel, processVariable; @@ -77,27 +76,6 @@ public class AddProcessVariableSanityTests extends RestTest processVariable.assertThat().field("value").is(newValue); } - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Add process variable using admin user from same network") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY, TestGroup.NETWORKS }) - public void addProcessVariableByAdmin() throws Exception - { - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser); - tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); - - restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee, false, Priority.Normal); - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - - processVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - processVariable.assertThat().field("name").is(variableModel.getName()) - .and().field("type").is(variableModel.getType()) - .and().field("value").is(variableModel.getValue()); - } - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Adding process variable is falling in case invalid variableBody is provided") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesCoreTests.java index bfbd047df..e597ddd50 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesCoreTests.java @@ -4,7 +4,6 @@ import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.model.RestProcessVariableCollection; import org.alfresco.rest.model.RestProcessVariableModel; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; @@ -23,7 +22,7 @@ public class AddProcessVariablesCoreTests extends RestTest private UserModel userWhoStartsProcess, assignee; private RestProcessModel processModel; private RestProcessVariableModel variableModel, processVariable, variableModel1; - private RestProcessVariableCollection processVariableCollection; + @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesFullTests.java index 6d8008d15..ba28bd516 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesFullTests.java @@ -25,7 +25,7 @@ public class AddProcessVariablesFullTests extends RestTest { private FileModel document; private SiteModel siteModel; - private UserModel userWhoStartsProcess, assignee, adminUser, adminTenantUser, adminTenantUser2, tenantUser, tenantUserAssignee; + private UserModel userWhoStartsProcess, assignee, adminUser; private ProcessModel processModel; private RestProcessModel restProcessModel; private RestProcessVariableModel variableModel, processVariable, variableModel1, variableModel2, variableModel3; @@ -392,65 +392,4 @@ public class AddProcessVariablesFullTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE); } - @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES}, executionType = ExecutionType.REGRESSION, - description = "Add process variables using by Admin in other network.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void addProcessVariablesByAdminInOtherNetwork() throws Exception - { - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser); - tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); - tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - - adminTenantUser2 = UserModel.getAdminTenantUser(); - restClient.usingTenant().createTenant(adminTenantUser2); - - siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); - dataWorkflow.usingUser(tenantUser).usingSite(siteModel).usingResource(document) - .createNewTaskAndAssignTo(tenantUserAssignee); - - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee, false, Priority.Normal); - processVariable = restClient.authenticateUser(adminTenantUser2).withWorkflowAPI().usingProcess(processModel) - .addProcessVariable(variableModel); - - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError() - .containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .containsErrorKey(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW,TestGroup.PROCESSES}, executionType = ExecutionType.REGRESSION, - description = "Add multiple process variables using by Admin in other network.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void addMultipleProcessVariablesByAdminInOtherNetwork() throws Exception - { - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser); - tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); - tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - - adminTenantUser2 = UserModel.getAdminTenantUser(); - restClient.usingTenant().createTenant(adminTenantUser2); - - siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); - dataWorkflow.usingUser(tenantUser).usingSite(siteModel).usingResource(document) - .createNewTaskAndAssignTo(tenantUserAssignee); - - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - variableModel1 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee, false, Priority.Normal); - restClient.authenticateUser(adminTenantUser2).withWorkflowAPI().usingProcess(processModel) - .addProcessVariables(variableModel, variableModel1); - - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError() - .containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .containsErrorKey(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesSanityTests.java index 88670aff0..26ce6bd8d 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesSanityTests.java @@ -1,7 +1,6 @@ package org.alfresco.rest.workflow.processes.variables; import org.alfresco.dataprep.CMISUtil; -import org.alfresco.dataprep.CMISUtil.Priority; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.rest.model.RestProcessVariableCollection; @@ -21,7 +20,7 @@ public class AddProcessVariablesSanityTests extends RestTest { private FileModel document; private SiteModel siteModel; - private UserModel userWhoStartsProcess, assignee, adminUser, adminTenantUser, tenantUserAssignee, tenantUser; + private UserModel userWhoStartsProcess, assignee, adminUser; private RestProcessModel processModel; private RestProcessVariableModel variableModel, variableModel1, variableModel2, processVariable; private RestProcessVariableCollection processVariableCollection; @@ -156,57 +155,4 @@ public class AddProcessVariablesSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) .assertLastError().containsSummary("Unsupported type of variable: 'incorrect type'."); } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Add process variables using admin user from same network") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY, TestGroup.NETWORKS }) - public void addProcessVariableByAdminSameNetwork() throws Exception - { - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser); - tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); - - restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee, false, Priority.Normal); - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - - processVariable = restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - processVariable.assertThat().field("name").is(variableModel.getName()) - .and().field("type").is(variableModel.getType()) - .and().field("value").is(variableModel.getValue()); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Add multiple process variables using admin user from same network") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY, TestGroup.NETWORKS }) - public void addMultipleProcessVariablesByAdminSameNetwork() throws Exception - { - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser); - tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee"); - - restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee, false, Priority.Normal); - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - variableModel1 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - - processVariableCollection = restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariables(variableModel, variableModel1); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - processVariableCollection.assertThat().entriesListContains("name", variableModel.getName()) - .assertThat().entriesListContains("name", variableModel1.getName()); - - processVariableCollection.getEntries().get(0).onModel().assertThat() - .field("name").is(variableModel.getName()).and() - .field("value").is(variableModel.getValue()).and() - .field("type").is(variableModel.getType()); - processVariableCollection.getEntries().get(1).onModel().assertThat() - .field("name").is(variableModel1.getName()).and() - .field("value").is(variableModel1.getValue()).and() - .field("type").is(variableModel1.getType()); - } - } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/DeleteProcessVariableFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/DeleteProcessVariableFullTests.java index 62461361e..9def8ff2b 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/DeleteProcessVariableFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/DeleteProcessVariableFullTests.java @@ -21,15 +21,13 @@ public class DeleteProcessVariableFullTests extends RestTest { private FileModel document; private SiteModel siteModel; - private UserModel userWhoStartsTask, assignee, adminUser; + private UserModel userWhoStartsTask, assignee; private RestProcessModel restProcessModel; private ProcessModel processModel; - private RestProcessVariableModel variableModel, updatedVariable; - + private RestProcessVariableModel variableModel; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception { - adminUser = dataUser.getAdminUser(); userWhoStartsTask = dataUser.createRandomTestUser(); assignee = dataUser.createRandomTestUser(); siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); @@ -195,59 +193,4 @@ public class DeleteProcessVariableFullTests extends RestTest .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) .stackTraceIs(RestErrorModel.STACKTRACE); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin from the same network is able to delete network process variables") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void deleteProcessVariablesWithAdminFromSameNetwork() throws Exception - { - UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser1); - UserModel tenantUser1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenant1"); - - RestProcessModel processModel = restClient.authenticateUser(adminTenantUser1).withWorkflowAPI() - .addProcess("activitiAdhoc", tenantUser1, false, Priority.Normal); - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser1).withWorkflowAPI() - .getProcesses().getProcessModelByProcessDefId(processModel.getId()); - restClient.withWorkflowAPI().usingProcess(networkProcess1).addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(adminTenantUser1).withWorkflowAPI().usingProcess(networkProcess1) - .deleteProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withWorkflowAPI().usingProcess(networkProcess1).getProcessVariables() - .assertThat() - .entriesListDoesNotContain("name", variableModel.getName()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin from different network is not able to delete network process variables") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void deleteProcessVariablesWithAdminFromDifferentNetwork() throws Exception - { - UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser1); - UserModel tenantUser1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenant1"); - - RestProcessModel processModel = restClient.authenticateUser(adminTenantUser1).withWorkflowAPI() - .addProcess("activitiAdhoc", tenantUser1, false, Priority.Normal); - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser1).withWorkflowAPI() - .getProcesses().getProcessModelByProcessDefId(processModel.getId()); - restClient.withWorkflowAPI().usingProcess(networkProcess1).addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(adminUser).withWorkflowAPI().usingProcess(networkProcess1) - .deleteProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - restClient.assertLastError().containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .containsErrorKey(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT) - .stackTraceIs(RestErrorModel.STACKTRACE); - - restClient.authenticateUser(tenantUser1).withWorkflowAPI().usingProcess(networkProcess1).getProcessVariables().assertThat() - .entriesListContains("name", variableModel.getName()); - } - } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/GetProcessVariablesCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/GetProcessVariablesCoreTests.java index bd2b1c3e5..0799d10d4 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/GetProcessVariablesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/GetProcessVariablesCoreTests.java @@ -1,6 +1,5 @@ package org.alfresco.rest.workflow.processes.variables; -import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.CMISUtil.Priority; import org.alfresco.rest.RestTest; @@ -27,6 +26,7 @@ public class GetProcessVariablesCoreTests extends RestTest private RestProcessModel processModel; private RestProcessVariableCollection variables; + @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception { @@ -38,39 +38,6 @@ public class GetProcessVariablesCoreTests extends RestTest dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); } - @TestRail(section = {TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin from the same network is able to retrieve network process variables") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void getProcessVariablesWithAdminFromSameNetwork() throws Exception - { - UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); - restClient.authenticateUser(admin).usingTenant().createTenant(adminTenantUser1); - UserModel tenantUser1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenant1"); - - RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser1).withWorkflowAPI() - .addProcess("activitiReview", tenantUser1, false, CMISUtil.Priority.High); - - variables = restClient.authenticateUser(adminTenantUser1).withWorkflowAPI().usingProcess(networkProcess1).getProcessVariables(); - restClient.assertStatusCodeIs(HttpStatus.OK); - variables.assertThat().entriesListIsNotEmpty(); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin from different network is not able to retrieve network process variables") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void getProcessVariablesWithAdminFromDifferentNetwork() throws Exception - { - UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); - restClient.authenticateUser(admin).usingTenant().createTenant(adminTenantUser1); - UserModel tenantUser1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenant1"); - - RestProcessModel networkProcess1 = restClient.authenticateUser(adminTenantUser1).withWorkflowAPI() - .addProcess("activitiReview", tenantUser1, false, CMISUtil.Priority.High); - - variables = restClient.authenticateUser(admin).withWorkflowAPI().usingProcess(networkProcess1).getProcessVariables(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT); - } - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Get process variables using invalid process ID") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelTests.java index b7359652b..dec930fdb 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelTests.java @@ -253,27 +253,4 @@ public class GetTaskFormModelTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() .containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "A")); } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, - executionType = ExecutionType.REGRESSION, description = "Verify network admin user gets all task form models inside his network with Rest API and response is successful (200)") - public void networkAdminGetsTaskFormModels() throws Exception - { - taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(userModel); - UserModel adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser); - UserModel tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant1"); - - RestProcessModel networkProcess = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() - .addProcess("activitiReview", tenantUser, false, CMISUtil.Priority.High); - RestTaskModel networkTask = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() - .usingProcess(networkProcess).getProcessTasks().getOneRandomEntry().onModel(); - - restClient.authenticateUser(adminUser).withWorkflowAPI().usingTask(networkTask).getTaskFormModel(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - - returnedCollection = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().usingTask(networkTask).getTaskFormModel(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat().entriesListIsNotEmpty(); - } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskTests.java index 213230a66..b88e1a02a 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskTests.java @@ -1,14 +1,18 @@ package org.alfresco.rest.workflow.tasks; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.dataprep.CMISUtil.Priority; import org.alfresco.rest.RestTest; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestProcessModel; import org.alfresco.rest.model.RestTaskModel; import org.alfresco.rest.model.RestTaskModelsCollection; -import org.alfresco.utility.model.*; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.GroupModel; +import org.alfresco.utility.model.ProcessModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TaskModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; @@ -182,41 +186,6 @@ public class GetTaskTests extends RestTest .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) .stackTraceIs(RestErrorModel.STACKTRACE); } - - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, - executionType = ExecutionType.REGRESSION, description = "Check that for admin network gets task only from its network.") - public void adminTenantGetsTaskOnlyFromItsNetwork() throws Exception - { - restClient.authenticateUser(adminUser); - - UserModel adminTenant1 = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenant1); - - UserModel tenantUser1 = dataUser.usingUser(adminTenant1).createUserWithTenant("userTenant1"); - UserModel tenantUserAssignee1 = dataUser.usingUser(adminTenant1).createUserWithTenant("userTenantAssignee1"); - - RestProcessModel processOnTenant1 = restClient.authenticateUser(tenantUser1).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee1, false, Priority.Low); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - UserModel adminTenant2 = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenant2); - - UserModel tenantUser2 = dataUser.usingUser(adminTenant2).createUserWithTenant("userTenant2"); - UserModel tenantUserAssignee2 = dataUser.usingUser(adminTenant2).createUserWithTenant("userTenantAssignee2"); - - RestProcessModel processOnTenant2 = restClient.authenticateUser(tenantUser2).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee2, false, Priority.Normal); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestTaskModelsCollection tenantTasks2 = restClient.authenticateUser(tenantUser2).withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - tenantTasks2.assertThat().entriesListIsNotEmpty() - .and().entriesListCountIs(1) - .and().entriesListContains("assignee", String.format("userTenantAssignee2@%s", tenantUserAssignee2.getDomain().toLowerCase())) - .and().entriesListContains("processId", processOnTenant2.getId()) - .and().entriesListDoesNotContain("assignee", String.format("userTenantAssignee1@%s", tenantUserAssignee1.getDomain().toLowerCase())) - .and().entriesListDoesNotContain("processId", processOnTenant1.getId()); - } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify if using invalid taskId status code 404 is returned.") @@ -240,27 +209,4 @@ public class GetTaskTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); taskModels.assertThat().entriesListIsNotEmpty(); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify that in a network only tasks inside network are returned.") - @Test(groups = {TestGroup.NETWORKS,TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void tasksInsideNetworkReturned() throws Exception - { - restClient.authenticateUser(adminUser); - - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.usingTenant().createTenant(adminTenantUser); - - tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("userTenant"); - tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("userTenantAssignee"); - - RestProcessModel addedProcess = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee, false, - Priority.Normal); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - taskModel = restClient.withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess); - tenantTask = restClient.authenticateUser(tenantUserAssignee).withWorkflowAPI().usingTask(taskModel).getTask(); - restClient.assertStatusCodeIs(HttpStatus.OK); - tenantTask.assertThat().field("assignee").is(String.format("userTenantAssignee@%s", tenantUserAssignee.getDomain().toLowerCase())).and() - .field("processId").is(addedProcess.getId()); - } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksTests.java index 59c50d15a..eb28d7c31 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksTests.java @@ -4,10 +4,14 @@ import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.CMISUtil.Priority; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestProcessModel; import org.alfresco.rest.model.RestTaskModel; import org.alfresco.rest.model.RestTaskModelsCollection; -import org.alfresco.utility.model.*; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.GroupModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TaskModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; @@ -175,48 +179,6 @@ public class GetTasksTests extends RestTest .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); } - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, - executionType = ExecutionType.REGRESSION, description = "Check that for admin network gets tasks only from its network.") - public void adminTenantGetsTasksOnlyFromItsNetwork() throws Exception - { - UserModel adminTenant1 = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenant1); - - UserModel adminTenant2 = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenant2); - - UserModel tenantUser1 = dataUser.usingUser(adminTenant1).createUserWithTenant("userTenant1"); - UserModel tenantUserAssignee1 = dataUser.usingUser(adminTenant1).createUserWithTenant("userTenantAssignee1"); - - UserModel tenantUser2 = dataUser.usingUser(adminTenant2).createUserWithTenant("userTenant2"); - UserModel tenantUserAssignee2 = dataUser.usingUser(adminTenant2).createUserWithTenant("userTenantAssignee2"); - - RestProcessModel processOnTenant1 = restClient.authenticateUser(tenantUser1).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee1, false, Priority.Low); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestProcessModel processOnTenant2 = restClient.authenticateUser(tenantUser2).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee2, false, Priority.Normal); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestTaskModelsCollection tenantTasks1 = restClient.authenticateUser(adminTenant1).withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - tenantTasks1.assertThat().entriesListIsNotEmpty() - .and().entriesListCountIs(1) - .and().entriesListContains("assignee", String.format("userTenantAssignee1@%s", tenantUserAssignee1.getDomain().toLowerCase())) - .and().entriesListContains("processId", processOnTenant1.getId()) - .and().entriesListDoesNotContain("assignee", String.format("userTenantAssignee2@%s", tenantUserAssignee2.getDomain().toLowerCase())) - .and().entriesListDoesNotContain("processId", processOnTenant2.getId()); - - RestTaskModelsCollection tenantTasks2 = restClient.authenticateUser(adminTenant2).withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - tenantTasks2.assertThat().entriesListIsNotEmpty() - .and().entriesListCountIs(1) - .and().entriesListContains("assignee", String.format("userTenantAssignee2@%s", tenantUserAssignee2.getDomain().toLowerCase())) - .and().entriesListContains("processId", processOnTenant2.getId()) - .and().entriesListDoesNotContain("assignee", String.format("userTenantAssignee1@%s", tenantUserAssignee1.getDomain().toLowerCase())) - .and().entriesListDoesNotContain("processId", processOnTenant1.getId()); - } - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify the request in case of any user which is not involved.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @@ -269,26 +231,4 @@ public class GetTasksTests extends RestTest restClient.authenticateUser(dataUser.getAdminUser()).withParams("orderBy=invalidParameter").withWorkflowAPI().getTasks(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("invalidParameter is not supported"); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check that for network enabled only that network tasks are returned.") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) - public void networkEnabledTasksReturned() throws Exception - { - restClient.authenticateUser(adminUser); - - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.usingTenant().createTenant(adminTenantUser); - - tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("userTenant"); - tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("userTenantAssignee"); - - restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee, false, Priority.Normal); - - tenantTask = restClient.authenticateUser(tenantUserAssignee).withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - tenantTask.assertThat().entriesListIsNotEmpty().and().entriesListCountIs(1).and().entriesListContains("assignee", - String.format("userTenantAssignee@%s", tenantUserAssignee.getDomain().toLowerCase())); - - } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskTests.java index 4db6b0a89..2e822fb34 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskTests.java @@ -2,16 +2,23 @@ package org.alfresco.rest.workflow.tasks; import java.util.HashMap; +import javax.json.JsonObject; + import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.core.JsonBodyGenerator; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestProcessDefinitionModel; import org.alfresco.rest.model.RestTaskModel; import org.alfresco.rest.model.RestVariableModelsCollection; -import org.alfresco.utility.model.*; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.GroupModel; +import org.alfresco.utility.model.ProcessModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TaskModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; @@ -21,8 +28,6 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import javax.json.JsonObject; - public class UpdateTaskTests extends RestTest { UserModel owner, anyUser; @@ -648,93 +653,6 @@ public class UpdateTaskTests extends RestTest restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("completed"); } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify tenant user that created the task can update task only in its network and response is 200, for other networks is 403") - public void ownerTenantCanUpdatedTaskOnlyInItsNetwork() throws Exception - { - restClient.authenticateUser(adminUser); - - UserModel adminTenant1 = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenant1); - - UserModel ownerTenant1 = dataUser.usingUser(adminTenant1).createUserWithTenant("ownerTenant1"); - UserModel assigneeTenant1 = dataUser.usingUser(adminTenant1).createUserWithTenant("assigneeTenant1"); - SiteModel siteModel1 = dataSite.usingUser(ownerTenant1).createPublicRandomSite(); - FileModel fileModel1 = dataContent.usingUser(ownerTenant1).usingSite(siteModel1).createContent(DocumentType.TEXT_PLAIN); - RestProcessDefinitionModel def1 = restClient.authenticateUser(ownerTenant1).withWorkflowAPI().getAllProcessDefinitions().getEntries().get(0).onModel(); - TaskModel taskModel1 = dataWorkflow.usingUser(ownerTenant1).usingSite(siteModel1).usingResource(fileModel1) - .createTaskWithProcessDefAndAssignTo(def1.getId(), assigneeTenant1); - - UserModel adminTenant2 = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenant2); - - UserModel ownerTenant2 = dataUser.usingUser(adminTenant2).createUserWithTenant("ownerTenant2"); - UserModel assigneeTenant2 = dataUser.usingUser(adminTenant2).createUserWithTenant("userTenantAssignee2"); - SiteModel siteModel2 = dataSite.usingUser(ownerTenant2).createPublicRandomSite(); - FileModel fileModel2 = dataContent.usingUser(ownerTenant2).usingSite(siteModel2).createContent(DocumentType.TEXT_PLAIN); - RestProcessDefinitionModel def2 = restClient.authenticateUser(ownerTenant2).withWorkflowAPI().getAllProcessDefinitions().getEntries().get(0).onModel(); - TaskModel taskModel2 = dataWorkflow.usingUser(ownerTenant2).usingSite(siteModel2).usingResource(fileModel2) - .createTaskWithProcessDefAndAssignTo(def2.getId(), assigneeTenant2); - - restTaskModel = restClient.authenticateUser(ownerTenant2).withParams("select=state").withWorkflowAPI().usingTask(taskModel2).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel2.getId()) - .and().field("state").is("completed"); - - restTaskModel = restClient.authenticateUser(ownerTenant2).withParams("select=state").withWorkflowAPI().usingTask(taskModel1).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - - } - - @Bug(id = "REPO-1980") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify tenant admin can update only task from its network and response is 200") - public void adminTenantCanUpdateOnlyTaskInItsNetwork() throws Exception - { - restClient.authenticateUser(adminUser); - - UserModel adminTenant1 = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenant1); - - UserModel ownerTenant1 = dataUser.usingUser(adminTenant1).createUserWithTenant("ownerTenant1"); - UserModel assigneeTenant1 = dataUser.usingUser(adminTenant1).createUserWithTenant("assigneeTenant1"); - SiteModel siteModel1 = dataSite.usingUser(ownerTenant1).createPublicRandomSite(); - FileModel fileModel1 = dataContent.usingUser(ownerTenant1).usingSite(siteModel1).createContent(DocumentType.TEXT_PLAIN); - RestProcessDefinitionModel def1 = restClient.authenticateUser(ownerTenant1).withWorkflowAPI().getAllProcessDefinitions().getEntries().get(0).onModel(); - TaskModel taskModel1 = dataWorkflow.usingUser(ownerTenant1).usingSite(siteModel1).usingResource(fileModel1) - .createTaskWithProcessDefAndAssignTo(def1.getId(), assigneeTenant1); - - UserModel adminTenant2 = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenant2); - - UserModel ownerTenant2 = dataUser.usingUser(adminTenant2).createUserWithTenant("ownerTenant2"); - UserModel assigneeTenant2 = dataUser.usingUser(adminTenant2).createUserWithTenant("userTenantAssignee2"); - SiteModel siteModel2 = dataSite.usingUser(ownerTenant2).createPublicRandomSite(); - FileModel fileModel2 = dataContent.usingUser(ownerTenant2).usingSite(siteModel2).createContent(DocumentType.TEXT_PLAIN); - RestProcessDefinitionModel def2 = restClient.authenticateUser(ownerTenant2).withWorkflowAPI().getAllProcessDefinitions().getEntries().get(0).onModel(); - TaskModel taskModel2 = dataWorkflow.usingUser(ownerTenant2).usingSite(siteModel2).usingResource(fileModel2) - .createTaskWithProcessDefAndAssignTo(def2.getId(), assigneeTenant2); - - restTaskModel = restClient.authenticateUser(adminTenant2).withParams("select=state").withWorkflowAPI().usingTask(taskModel2).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel2.getId()) - .and().field("state").is("completed"); - - restTaskModel = restClient.authenticateUser(adminTenant2).withParams("select=state").withWorkflowAPI().usingTask(taskModel1).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - - } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner cannot update task from status completed to delegated and response is 404") diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemTestsBulk1.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemTestsBulk1.java index f44a27c38..e0bb0e483 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemTestsBulk1.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemTestsBulk1.java @@ -1,13 +1,9 @@ package org.alfresco.rest.workflow.tasks.items; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.dataprep.CMISUtil.Priority; import org.alfresco.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestItemModel; import org.alfresco.rest.model.RestItemModelsCollection; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.model.RestTaskModel; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TaskModel; @@ -25,7 +21,7 @@ public class AddTaskItemTestsBulk1 extends RestTest { private UserModel userModel, userWhoStartsTask, assigneeUser; private SiteModel siteModel; - private FileModel fileModel, document2, document3, document4; + private FileModel fileModel, document2, document3; private TaskModel taskModel; private RestItemModelsCollection taskItems; private RestItemModel taskItem; @@ -159,77 +155,4 @@ public class AddTaskItemTestsBulk1 extends RestTest taskItems = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItems(document3, document2); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); } - - @Test(groups = { TestGroup.NETWORKS,TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Add task item using admin user from same network") - public void addTaskItemByAdminSameNetwork() throws Exception - { - UserModel adminUser = dataUser.getAdminUser(); - restClient.authenticateUser(adminUser); - UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser1); - - UserModel tenantUser1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenant"); - UserModel tenantUserAssignee1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenantAssignee"); - - siteModel = dataSite.usingUser(adminTenantUser1).createPublicRandomSite(); - document4 = dataContent.usingUser(adminTenantUser1).usingSite(siteModel).createContent(DocumentType.XML); - RestProcessModel addedProcess = restClient.authenticateUser(tenantUser1).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee1, false, Priority.Normal); - RestTaskModel addedTask = restClient.authenticateUser(adminTenantUser1).withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess); - - taskItem = restClient.withWorkflowAPI().usingTask(addedTask).addTaskItem(document4); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - taskItem.assertThat().field("createdAt").is(taskItem.getCreatedAt()) - .and().field("size").is(taskItem.getSize()) - .and().field("createdBy").is(taskItem.getCreatedBy()) - .and().field("modifiedAt").is(taskItem.getModifiedAt()) - .and().field("name").is(taskItem.getName()) - .and().field("modifiedBy").is(taskItem.getModifiedBy()) - .and().field("id").is(taskItem.getId()) - .and().field("mimeType").is(taskItem.getMimeType()); - } - - @Test(groups = { TestGroup.NETWORKS,TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Add task item using admin user from same network") - public void addMultipleTaskItemByAdminSameNetwork() throws Exception - { - UserModel adminUser = dataUser.getAdminUser(); - restClient.authenticateUser(adminUser); - UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser1); - - UserModel tenantUser1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenant"); - UserModel tenantUserAssignee1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenantAssignee"); - - siteModel = dataSite.usingUser(adminTenantUser1).createPublicRandomSite(); - document3 = dataContent.usingUser(adminTenantUser1).usingSite(siteModel).createContent(DocumentType.XML); - document4 = dataContent.usingUser(adminTenantUser1).usingUser(adminTenantUser1).usingSite(siteModel).createContent(DocumentType.XML); - RestProcessModel addedProcess = restClient.authenticateUser(tenantUser1).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee1, false, Priority.Normal); - RestTaskModel addedTask = restClient.authenticateUser(adminTenantUser1).withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess); - - taskItems = restClient.authenticateUser(adminTenantUser1).withWorkflowAPI().usingTask(addedTask) - .addTaskItems(document4,document3); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - taskItems.getEntries().get(0).onModel() - .assertThat().field("createdAt").is(taskItems.getEntries().get(0).onModel().getCreatedAt()) - .assertThat().field("size").is(taskItems.getEntries().get(0).onModel().getSize()) - .assertThat().field("createdBy").is(taskItems.getEntries().get(0).onModel().getCreatedBy()) - .assertThat().field("modifiedAt").is(taskItems.getEntries().get(0).onModel().getModifiedAt()) - .assertThat().field("name").is(taskItems.getEntries().get(0).onModel().getName()) - .assertThat().field("modifiedBy").is(taskItems.getEntries().get(0).onModel().getModifiedBy()) - .assertThat().field("id").is(taskItems.getEntries().get(0).onModel().getId()) - .assertThat().field("mimeType").is(taskItems.getEntries().get(0).onModel().getMimeType()); - - taskItems.getEntries().get(1).onModel() - .assertThat().field("createdAt").is(taskItems.getEntries().get(1).onModel().getCreatedAt()) - .assertThat().field("size").is(taskItems.getEntries().get(1).onModel().getSize()) - .assertThat().field("createdBy").is(taskItems.getEntries().get(1).onModel().getCreatedBy()) - .assertThat().field("modifiedAt").is(taskItems.getEntries().get(1).onModel().getModifiedAt()) - .assertThat().field("name").is(taskItems.getEntries().get(1).onModel().getName()) - .assertThat().field("modifiedBy").is(taskItems.getEntries().get(1).onModel().getModifiedBy()) - .assertThat().field("id").is(taskItems.getEntries().get(1).onModel().getId()); - } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemTestsBulk2.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemTestsBulk2.java index 2b1d0b5eb..b54d54193 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemTestsBulk2.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemTestsBulk2.java @@ -3,7 +3,6 @@ package org.alfresco.rest.workflow.tasks.items; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.core.RestRequest; -import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestVariableModel; import org.alfresco.utility.model.FileModel; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemTestsBulk3.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemTestsBulk3.java index 7ffa95ead..fd6a130c5 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemTestsBulk3.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemTestsBulk3.java @@ -1,14 +1,9 @@ package org.alfresco.rest.workflow.tasks.items; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.dataprep.CMISUtil.Priority; import org.alfresco.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestItemModel; import org.alfresco.rest.model.RestItemModelsCollection; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.model.RestTaskModel; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TaskModel; @@ -22,7 +17,7 @@ import org.testng.annotations.Test; public class AddTaskItemTestsBulk3 extends RestTest { - private UserModel userModel, adminUser,userWhoStartsTask, assigneeUser; + private UserModel userModel,userWhoStartsTask, assigneeUser; private SiteModel siteModel; private FileModel fileModel, fileModel1, document1, document2,document3; private TaskModel taskModel; @@ -32,7 +27,6 @@ public class AddTaskItemTestsBulk3 extends RestTest @BeforeClass(alwaysRun=true) public void dataPreparation() throws Exception { - adminUser = dataUser.getAdminUser(); userModel = dataUser.createRandomTestUser(); siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); @@ -89,63 +83,7 @@ public class AddTaskItemTestsBulk3 extends RestTest .assertThat().field("id").is(taskItems.getEntries().get(1).onModel().getId()) .assertThat().field("mimeType").is(taskItems.getEntries().get(1).onModel().getMimeType()); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Add task item using by admin in other network.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void addTaskItemByAdminInOtherNetwork() throws Exception - { - UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); - UserModel adminTenantUser2 = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser1); - restClient.usingTenant().createTenant(adminTenantUser2); - - UserModel tenantUser1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenant"); - UserModel tenantUserAssignee1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenantAssignee"); - - siteModel = dataSite.usingUser(adminTenantUser1).createPublicRandomSite(); - fileModel = dataContent.usingUser(adminTenantUser1).usingSite(siteModel).createContent(DocumentType.XML); - RestProcessModel addedProcess = restClient.authenticateUser(tenantUser1).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee1, false, Priority.Normal); - RestTaskModel addedTask = restClient.withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess); - restClient.authenticateUser(adminTenantUser2).withWorkflowAPI().usingTask(addedTask).addTaskItem(fileModel); - - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Add multiple task item using by admin in other network.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void addMultipleTaskItemByAdminInOtherNetwork() throws Exception - { - UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); - UserModel adminTenantUser2 = UserModel.getAdminTenantUser(); - - restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser1); - restClient.usingTenant().createTenant(adminTenantUser2); - - UserModel tenantUser1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenant"); - UserModel tenantUserAssignee1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenantAssignee"); - - siteModel = dataSite.usingUser(adminTenantUser1).createPublicRandomSite(); - document1 = dataContent.usingUser(adminTenantUser1).usingSite(siteModel).createContent(DocumentType.XML); - document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - - RestProcessModel addedProcess = restClient.authenticateUser(tenantUser1).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee1, false, Priority.Normal); - RestTaskModel addedTask = restClient.withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess); - restClient.authenticateUser(adminTenantUser2).withWorkflowAPI().usingTask(addedTask).addTaskItems(document1, document2); - - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .stackTraceIs(RestErrorModel.STACKTRACE);; - } - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Delete task item then create it again") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION}) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/items/GetTaskItemsRegressionTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/items/GetTaskItemsRegressionTests.java index 74bc978b7..e8841828f 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/items/GetTaskItemsRegressionTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/items/GetTaskItemsRegressionTests.java @@ -25,7 +25,7 @@ import org.testng.annotations.Test; */ public class GetTaskItemsRegressionTests extends RestTest { - private UserModel adminUser, userWhoStartsTask, assignee; + private UserModel userWhoStartsTask, assignee; private SiteModel siteModel; private FileModel fileModel; private TaskModel taskModel; @@ -41,7 +41,6 @@ public class GetTaskItemsRegressionTests extends RestTest assignee = dataUser.createRandomTestUser(); siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - adminUser = dataUser.getAdminUser(); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, @@ -97,69 +96,6 @@ public class GetTaskItemsRegressionTests extends RestTest itemModels.assertThat().entriesListIsNotEmpty().and().entriesListContains("name", fileModel.getName()); } - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify gets task items call with admin from different network") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void getTaskItemsByAdminFromAnotherNetwork() throws Exception - { - UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); - UserModel adminTenantUser2 = UserModel.getAdminTenantUser(); - - restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser1); - restClient.usingTenant().createTenant(adminTenantUser2); - - UserModel tenantUser1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenant"); - UserModel tenantUserAssignee1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenantAssignee"); - - siteModel = dataSite.usingUser(adminTenantUser1).createPublicRandomSite(); - fileModel = dataContent.usingUser(adminTenantUser1).usingSite(siteModel).createContent(DocumentType.XML); - addedProcess = restClient.authenticateUser(tenantUser1).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee1, false, Priority.Normal); - addedTask = restClient.withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess); - restClient.withWorkflowAPI().usingTask(addedTask).addTaskItem(fileModel); - - restClient.authenticateUser(adminTenantUser2).withWorkflowAPI().usingTask(addedTask).getTaskItems(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify gets task items call returns only task items inside network") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void getTaskItemsReturnsOnlyItemsFromThatNetwork() throws Exception - { - UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); - UserModel adminTenantUser2 = UserModel.getAdminTenantUser(); - - restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser1); - restClient.usingTenant().createTenant(adminTenantUser2); - - UserModel tenantUser1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenant1"); - UserModel tenantUser2 = dataUser.usingUser(adminTenantUser2).createUserWithTenant("uTenant2"); - - SiteModel siteModel1 = dataSite.usingUser(adminTenantUser1).createPublicRandomSite(); - FileModel fileModel1 = dataContent.usingUser(adminTenantUser1).usingSite(siteModel1).createContent(DocumentType.XML); - - RestProcessModel addedProcess1 = restClient.authenticateUser(adminTenantUser1).withWorkflowAPI().addProcess("activitiAdhoc", tenantUser1, false, Priority.Normal); - RestTaskModel addedTask1 = restClient.withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess1); - RestItemModel taskItem1 = restClient.withWorkflowAPI().usingTask(addedTask1).addTaskItem(fileModel1); - - SiteModel siteModel2 = dataSite.usingUser(adminTenantUser2).createPublicRandomSite(); - FileModel fileModel2 = dataContent.usingUser(adminTenantUser2).usingSite(siteModel2).createContent(DocumentType.XML); - - RestProcessModel addedProcess2 = restClient.authenticateUser(adminTenantUser2).withWorkflowAPI().addProcess("activitiAdhoc", tenantUser2, false, Priority.Normal); - RestTaskModel addedTask2 = restClient.withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess2); - RestItemModel taskItem2 = restClient.withWorkflowAPI().usingTask(addedTask2).addTaskItem(fileModel2); - - itemModels = restClient.withWorkflowAPI().usingTask(addedTask2).getTaskItems(); - restClient.assertStatusCodeIs(HttpStatus.OK); - itemModels.assertThat() - .entriesListIsNotEmpty().and() - .entriesListContains("id", taskItem2.getId()).and() - .entriesListContains("name", fileModel2.getName()).and() - .entriesListDoesNotContain("id", taskItem1.getId()).and() - .entriesListDoesNotContain("name", fileModel1.getName()); - } - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check default error model schema for get task items api call") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/items/GetTaskItemsSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/items/GetTaskItemsSanityTests.java index 04b9e05ee..594ea0449 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/items/GetTaskItemsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/items/GetTaskItemsSanityTests.java @@ -1,12 +1,9 @@ package org.alfresco.rest.workflow.tasks.items; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.dataprep.CMISUtil.Priority; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestItemModel; import org.alfresco.rest.model.RestItemModelsCollection; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.model.RestTaskModel; import org.alfresco.utility.Utility; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; @@ -75,31 +72,4 @@ public class GetTaskItemsSanityTests extends RestTest .entriesListContains("name", document1.getName()); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, - description = "Verify that user that started the process gets task items") - @Test(groups = { TestGroup.NETWORKS,TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY}) - public void getTaskItemsByAdminInSameNetwork() throws Exception - { - UserModel adminUser = dataUser.getAdminUser(); - restClient.authenticateUser(adminUser); - UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser1); - - UserModel tenantUser1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenant"); - UserModel tenantUserAssignee1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenantAssignee"); - - siteModel = dataSite.usingUser(adminTenantUser1).createPublicRandomSite(); - document1 = dataContent.usingUser(adminTenantUser1).usingSite(siteModel).createContent(DocumentType.XML); - RestProcessModel addedProcess = restClient.authenticateUser(tenantUser1).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee1, false, Priority.Normal); - RestTaskModel addedTask = restClient.authenticateUser(adminTenantUser1).withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess); - taskItem = restClient.withWorkflowAPI().usingTask(addedTask).addTaskItem(document1); - - itemModels = restClient.withWorkflowAPI().usingTask(addedTask).getTaskItems(); - restClient.assertStatusCodeIs(HttpStatus.OK); - itemModels.assertThat() - .entriesListIsNotEmpty().and() - .entriesListContains("id", taskItem.getId()).and() - .entriesListContains("name", document1.getName()); - } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk3.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk3.java index b82b8f675..e81e3f0b5 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk3.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk3.java @@ -1,12 +1,9 @@ package org.alfresco.rest.workflow.tasks.variables; -import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.model.RestTaskModel; import org.alfresco.rest.model.RestVariableModel; import org.alfresco.rest.model.RestVariableModelsCollection; import org.alfresco.utility.model.FileModel; @@ -155,119 +152,4 @@ public class AddTaskVariablesTestsBulk3 extends RestTest .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) .stackTraceIs(RestErrorModel.STACKTRACE); } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin from the same network is able to add task variables") - public void addTaskVariablesByTenantAdmin() throws Exception - { - UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); - restClient.authenticateUser(dataUser.getAdminUser()).usingTenant().createTenant(adminTenantUser1); - UserModel tenantUser1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenant1"); - - RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser1).withWorkflowAPI() - .addProcess("activitiReview", tenantUser1, false, CMISUtil.Priority.High); - RestTaskModel task = restClient.authenticateUser(adminTenantUser1) - .withWorkflowAPI().usingProcess(networkProcess1).getProcessTasks().getOneRandomEntry(); - restClient.authenticateUser(adminTenantUser1); - RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - restVariablemodel = restClient.withWorkflowAPI() - .usingTask(task.onModel()) - .addTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restVariablemodel.assertThat() - .field("scope").is(variableModel.getScope()) - .and().field("name").is(variableModel.getName()) - .and().field("value").is(variableModel.getValue()) - .and().field("type").is(variableModel.getType()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin from the same network is able to add multiple task variables") - public void addMultipleTaskVariablesByTenantAdmin() throws Exception - { - UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); - restClient.authenticateUser(dataUser.getAdminUser()).usingTenant().createTenant(adminTenantUser1); - UserModel tenantUser1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenant1"); - - RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser1).withWorkflowAPI() - .addProcess("activitiReview", tenantUser1, false, CMISUtil.Priority.High); - RestTaskModel task = restClient.authenticateUser(adminTenantUser1) - .withWorkflowAPI().usingProcess(networkProcess1).getProcessTasks().getOneRandomEntry(); - restClient.authenticateUser(adminTenantUser1); - - variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - variableModel1 = RestVariableModel.getRandomTaskVariableModel("global", "d:text"); - - restVariableCollection = restClient.withWorkflowAPI().usingTask(task.onModel()) - .addTaskVariables(variableModel, variableModel1); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restVariableCollection.getEntries().get(0).onModel().assertThat() - .field("scope").is(variableModel.getScope()) - .and().field("name").is(variableModel.getName()) - .and().field("value").is(variableModel.getValue()) - .and().field("type").is(variableModel.getType()); - - restVariableCollection.getEntries().get(1).onModel().assertThat() - .field("scope").is(variableModel1.getScope()) - .and().field("name").is(variableModel1.getName()) - .and().field("value").is(variableModel1.getValue()) - .and().field("type").is(variableModel1.getType()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin from another network is not able to add task variables") - public void addTaskVariablesByTenantFromAnotherNetwork() throws Exception - { - UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); - UserModel adminTenantUser2 = UserModel.getAdminTenantUser(); - restClient.authenticateUser(dataUser.getAdminUser()).usingTenant().createTenant(adminTenantUser1); - restClient.authenticateUser(dataUser.getAdminUser()).usingTenant().createTenant(adminTenantUser2); - UserModel tenantUser1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenant1"); - - RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser1).withWorkflowAPI() - .addProcess("activitiReview", tenantUser1, false, CMISUtil.Priority.High); - RestTaskModel task = restClient.authenticateUser(adminTenantUser1) - .withWorkflowAPI().usingProcess(networkProcess1).getProcessTasks().getOneRandomEntry(); - RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - restVariablemodel = restClient.authenticateUser(adminTenantUser2).withWorkflowAPI() - .usingTask(task.onModel()) - .addTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin from another network is not able to add multiple task variables") - public void addMultipleTaskVariablesByTenantFromAnotherNetwork() throws Exception - { - UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); - UserModel adminTenantUser2 = UserModel.getAdminTenantUser(); - restClient.authenticateUser(dataUser.getAdminUser()).usingTenant().createTenant(adminTenantUser1); - restClient.authenticateUser(dataUser.getAdminUser()).usingTenant().createTenant(adminTenantUser2); - UserModel tenantUser1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenant1"); - - RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser1).withWorkflowAPI() - .addProcess("activitiReview", tenantUser1, false, CMISUtil.Priority.High); - RestTaskModel task = restClient.authenticateUser(adminTenantUser1) - .withWorkflowAPI().usingProcess(networkProcess1).getProcessTasks().getOneRandomEntry(); - restClient.authenticateUser(adminTenantUser1); - - variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - variableModel1 = RestVariableModel.getRandomTaskVariableModel("global", "d:text"); - restVariableCollection = restClient.authenticateUser(adminTenantUser2).withWorkflowAPI() - .usingTask(task.onModel()) - .addTaskVariables(variableModel,variableModel1); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/DeleteTaskVariableTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/DeleteTaskVariableTests.java index 554d0ee7b..4a046ce6d 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/DeleteTaskVariableTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/DeleteTaskVariableTests.java @@ -1,18 +1,14 @@ package org.alfresco.rest.workflow.tasks.variables; -import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.model.RestTaskModel; import org.alfresco.rest.model.RestVariableModel; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TaskModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -232,56 +228,4 @@ public class DeleteTaskVariableTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE) .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin from the same network is able to remove task variables") - public void addTaskVariablesByTenantAdmin() throws Exception - { - UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); - restClient.authenticateUser(dataUser.getAdminUser()).usingTenant().createTenant(adminTenantUser1); - RestProcessModel networkProcess1 = restClient.authenticateUser(adminTenantUser1).withWorkflowAPI() - .addProcess("activitiReview", adminTenantUser1, false, CMISUtil.Priority.High); - RestTaskModel task = restClient.authenticateUser(adminTenantUser1) - .withWorkflowAPI().usingProcess(networkProcess1).getProcessTasks().getOneRandomEntry(); - restClient.authenticateUser(adminTenantUser1); - RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - restClient.withWorkflowAPI() - .usingTask(task.onModel()) - .addTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.withWorkflowAPI().usingTask(task.onModel()).deleteTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withWorkflowAPI().usingTask(task.onModel()).getTaskVariables() - .assertThat().entriesListDoesNotContain("name", variableModel.getName()); - } - - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin from the other network is not able to remove task variables") - public void addTaskVariablesByTenantAdminOtherNetwork() throws Exception - { - UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); - UserModel adminTenantUser2 = UserModel.getAdminTenantUser(); - restClient.authenticateUser(dataUser.getAdminUser()).usingTenant().createTenant(adminTenantUser1); - restClient.authenticateUser(dataUser.getAdminUser()).usingTenant().createTenant(adminTenantUser2); - - RestProcessModel networkProcess1 = restClient.authenticateUser(adminTenantUser1).withWorkflowAPI() - .addProcess("activitiReview", adminTenantUser1, false, CMISUtil.Priority.High); - RestTaskModel task = restClient.authenticateUser(adminTenantUser1) - .withWorkflowAPI().usingProcess(networkProcess1).getProcessTasks().getOneRandomEntry(); - restClient.authenticateUser(adminTenantUser1); - RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - restClient.withWorkflowAPI() - .usingTask(task.onModel()) - .addTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.authenticateUser(adminTenantUser2).withWorkflowAPI().usingTask(task.onModel()).deleteTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/GetTaskVariablesTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/GetTaskVariablesTests.java index b608ca888..90a07ba9d 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/GetTaskVariablesTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/GetTaskVariablesTests.java @@ -249,47 +249,4 @@ public class GetTaskVariablesTests extends RestTest .field("scope").isNull().and() .field("name").isNull(); } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin from the same network is able to retrieve network task variables") - public void getTaskVariablesByTenantAdmin() throws Exception - { - UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); - restClient.authenticateUser(dataUser.getAdminUser()).usingTenant().createTenant(adminTenantUser1); - UserModel tenantUser1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenant1"); - - RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser1).withWorkflowAPI() - .addProcess("activitiReview", tenantUser1, false, CMISUtil.Priority.High); - RestTaskModel task = restClient.authenticateUser(adminTenantUser1) - .withWorkflowAPI().usingProcess(networkProcess1).getProcessTasks().getOneRandomEntry(); - - variableModels = restClient.withWorkflowAPI().usingTask(task.onModel()).getTaskVariables(); - restClient.assertStatusCodeIs(HttpStatus.OK); - variableModels.assertThat().entriesListIsNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin from another network is not able to retrieve network task variables") - public void getTaskVariablesByTenantFromAnotherNetwork() throws Exception - { - UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); - UserModel adminTenantUser2= UserModel.getAdminTenantUser(); - restClient.authenticateUser(dataUser.getAdminUser()).usingTenant().createTenant(adminTenantUser1); - restClient.authenticateUser(dataUser.getAdminUser()).usingTenant().createTenant(adminTenantUser2); - UserModel tenantUser1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenant1"); - - RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser1).withWorkflowAPI() - .addProcess("activitiReview", tenantUser1, false, CMISUtil.Priority.High); - RestTaskModel task = restClient.authenticateUser(adminTenantUser1) - .withWorkflowAPI().usingProcess(networkProcess1).getProcessTasks().getOneRandomEntry(); - - variableModels = restClient.authenticateUser(adminTenantUser2).withWorkflowAPI().usingTask(task.onModel()).getTaskVariables(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk1.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk1.java index f39fc152b..c3718b38f 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk1.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk1.java @@ -1,10 +1,7 @@ package org.alfresco.rest.workflow.tasks.variables; -import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.model.RestTaskModel; import org.alfresco.rest.model.RestVariableModel; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; @@ -79,32 +76,4 @@ public class UpdateTaskVariableTestsBulk1 extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); taskVariable.assertThat().field("value").is("updatedValue"); } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS}) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Update existing task variable by admin in the same network") - public void updateTaskVariableByAdminInSameNetwork() throws Exception - { - UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); - restClient.authenticateUser(dataUser.getAdminUser()).usingTenant().createTenant(adminTenantUser1); - UserModel tenantUser1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenant1"); - - RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser1).withWorkflowAPI() - .addProcess("activitiReview", tenantUser1, false, CMISUtil.Priority.High); - RestTaskModel task = restClient.authenticateUser(adminTenantUser1) - .withWorkflowAPI().usingProcess(networkProcess1).getProcessTasks().getOneRandomEntry(); - - variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - taskVariable = restClient.withWorkflowAPI().usingTask(task.onModel()) - .updateTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - taskVariable.assertThat().field("scope").is(taskVariable.getScope()) - .and().field("name").is(taskVariable.getName()) - .and().field("type").is(taskVariable.getType()) - .and().field("value").is(taskVariable.getValue()); - - variableModel.setValue("updatedValue"); - taskVariable = restClient.withWorkflowAPI().usingTask(task.onModel()).updateTaskVariable(variableModel).and().field("value").is("updatedValue"); - restClient.assertStatusCodeIs(HttpStatus.OK); - } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk2.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk2.java index fe2ffc814..53fe2f6a2 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk2.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk2.java @@ -9,7 +9,6 @@ import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TaskModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk3.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk3.java index 9602fbf32..156be6a2e 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk3.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk3.java @@ -1,12 +1,9 @@ package org.alfresco.rest.workflow.tasks.variables; -import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.model.RestTaskModel; import org.alfresco.rest.model.RestVariableModel; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; @@ -247,35 +244,4 @@ public class UpdateTaskVariableTestsBulk3 extends RestTest updatedTaskVariable.assertThat().field("scope").is("global"); updatedTaskVariable.assertThat().field("name").is("newName"); } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin from another network is not able to update task variables") - public void updateTaskVariablesByTenantFromAnotherNetwork() throws Exception - { - UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); - UserModel adminTenantUser2 = UserModel.getAdminTenantUser(); - restClient.authenticateUser(dataUser.getAdminUser()).usingTenant().createTenant(adminTenantUser1); - restClient.authenticateUser(dataUser.getAdminUser()).usingTenant().createTenant(adminTenantUser2); - UserModel tenantUser1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenant1"); - - RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser1).withWorkflowAPI() - .addProcess("activitiReview", tenantUser1, false, CMISUtil.Priority.High); - RestTaskModel task = restClient.authenticateUser(adminTenantUser1) - .withWorkflowAPI().usingProcess(networkProcess1).getProcessTasks().getOneRandomEntry(); - restClient.authenticateUser(adminTenantUser1); - RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - taskVariable = restClient.authenticateUser(adminTenantUser1).withWorkflowAPI().usingTask(task.onModel()) - .addTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(adminTenantUser2).withWorkflowAPI().usingTask(task.onModel()) - .updateTaskVariable(taskVariable); - - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } } From 6afb9fa7033df403c9ca74d7502bbf66a247a9e8 Mon Sep 17 00:00:00 2001 From: cagache Date: Mon, 16 Oct 2017 17:31:56 +0300 Subject: [PATCH 1256/1491] REPO-2755 / REPO-2251: fix for oneUserGetsItsOwnSiteMembershipRequestsWithSuccess which is random failing --- .../GetSiteMembershipRequestsTests.java | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestsTests.java b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestsTests.java index 13a2d0e6b..ee224a7d2 100644 --- a/e2e-test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestsTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestsTests.java @@ -1,10 +1,7 @@ package org.alfresco.rest.sites.membershipRequests; import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestSiteMembershipRequestModel; -import org.alfresco.rest.model.RestSiteMembershipRequestModelsCollection; -import org.alfresco.rest.model.RestTaskModel; +import org.alfresco.rest.model.*; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.model.SiteModel; @@ -126,12 +123,23 @@ public class GetSiteMembershipRequestsTests extends RestTest siteMembershipRequests.assertThat().entriesListContains("id", moderatedSite1.getId()) .assertThat().entriesListContains("message", "Please accept me") .assertThat().entriesListCountIs(2); - siteMembershipRequests.getEntries().get(0).onModel().getSite() - .assertThat().field("visibility").is(moderatedSite1.getVisibility()) - .assertThat().field("guid").is(moderatedSite1.getGuid()) - .assertThat().field("description").is(moderatedSite1.getDescription()) - .assertThat().field("id").is(moderatedSite1.getId()) - .assertThat().field("title").is(moderatedSite1.getTitle()); + RestSiteModel firstSite = siteMembershipRequests.getEntries().get(0).onModel().getSite(); + if (firstSite.getId().equals(moderatedSite1.getId())) + { + firstSite.assertThat().field("visibility").is(moderatedSite1.getVisibility()) + .assertThat().field("guid").is(moderatedSite1.getGuid()) + .assertThat().field("description").is(moderatedSite1.getDescription()) + .assertThat().field("id").is(moderatedSite1.getId()) + .assertThat().field("title").is(moderatedSite1.getTitle()); + } + else + { + firstSite.assertThat().field("visibility").is(moderatedSite2.getVisibility()) + .assertThat().field("guid").is(moderatedSite2.getGuid()) + .assertThat().field("description").is(moderatedSite2.getDescription()) + .assertThat().field("id").is(moderatedSite2.getId()) + .assertThat().field("title").is(moderatedSite2.getTitle()); + } } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, From 00e17486da0ef282742186334dd049d751ce51c4 Mon Sep 17 00:00:00 2001 From: Alexandru-Eusebiu Epure Date: Tue, 17 Oct 2017 10:01:56 +0300 Subject: [PATCH 1257/1491] REPO-2251 : REST API: Reliable TAS REST API & CMIS build plans (5.2.N & 5.1.N) Fixed few network failing tests. Remove from NetworkDataPrep creation of sites/documents and add them to each NetworkTestsClass according to the tests requirements. --- .../java/org/alfresco/rest/NetworkDataPrep.java | 9 --------- .../rest/favorites/FavoritesNetworkTests.java | 10 ++++------ .../networks/RestGetNetworksForPersonTests.java | 1 - .../org/alfresco/rest/sites/SitesNetworkTests.java | 2 ++ .../workflow/WorkflowNetworkProcessesTests.java | 14 +++++++++++++- .../rest/workflow/WorkflowNetworkTasksTests.java | 5 +++++ 6 files changed, 24 insertions(+), 17 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/NetworkDataPrep.java b/e2e-test/java/org/alfresco/rest/NetworkDataPrep.java index f3e6f894c..635be0106 100644 --- a/e2e-test/java/org/alfresco/rest/NetworkDataPrep.java +++ b/e2e-test/java/org/alfresco/rest/NetworkDataPrep.java @@ -1,9 +1,6 @@ package org.alfresco.rest; -import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.model.RestNetworkModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; public abstract class NetworkDataPrep extends RestTest @@ -15,8 +12,6 @@ public abstract class NetworkDataPrep extends RestTest protected static UserModel userModel; protected static RestNetworkModel restNetworkModel; protected static String tenantDomain; - protected static SiteModel siteModel; - protected static FileModel document, document2; private static boolean isInitialized = false; public void init() @@ -58,9 +53,5 @@ public abstract class NetworkDataPrep extends RestTest differentNetworkTenantUser = dataUser.usingUser(secondAdminTenantUser).createUserWithTenant("dTenant"); userModel = dataUser.createRandomTestUser(); - - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - document2 = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); } } diff --git a/e2e-test/java/org/alfresco/rest/favorites/FavoritesNetworkTests.java b/e2e-test/java/org/alfresco/rest/favorites/FavoritesNetworkTests.java index 34464acd1..6690a75ed 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/FavoritesNetworkTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/FavoritesNetworkTests.java @@ -13,12 +13,13 @@ import org.testng.annotations.Test; public class FavoritesNetworkTests extends NetworkDataPrep { - private SiteModel publicSite; + private SiteModel publicSite, siteModel; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception { init(); + siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.NETWORKS, TestGroup.REGRESSION}) @@ -101,7 +102,6 @@ public class FavoritesNetworkTests extends NetworkDataPrep @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES,TestGroup.NETWORKS, TestGroup.REGRESSION }) public void tenantIsNotAbleToDeleteFavoriteSiteWithInvalidNetworkID() throws Exception { - siteModel = dataSite.usingUser(tenantUser).createPublicRandomSite(); restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); String domain = tenantUser.getDomain(); try @@ -190,7 +190,6 @@ public class FavoritesNetworkTests extends NetworkDataPrep @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION, TestGroup.NETWORKS }) public void getFavoriteSiteWithInvalidNetworkId() throws Exception { - siteModel = dataSite.usingUser(tenantUser).createPublicRandomSite(); restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); String domain = tenantUser.getDomain(); @@ -213,7 +212,6 @@ public class FavoritesNetworkTests extends NetworkDataPrep @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION, TestGroup.NETWORKS }) public void getFavoriteSiteWithTenantUser() throws Exception { - siteModel = dataSite.usingUser(tenantUser).createPublicRandomSite(); restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); restClient.withCoreAPI().usingAuthUser().getFavorite(siteModel.getGuid()); @@ -242,7 +240,6 @@ public class FavoritesNetworkTests extends NetworkDataPrep @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES,TestGroup.NETWORKS, TestGroup.REGRESSION }) public void tenantDeleteFavoriteSiteValidNetwork() throws Exception { - siteModel = dataSite.usingUser(tenantUser).createPublicRandomSite(); restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); @@ -253,6 +250,7 @@ public class FavoritesNetworkTests extends NetworkDataPrep restClient.withCoreAPI().usingAuthUser().getFavorites() .assertThat() .entriesListDoesNotContain("targetGuid", siteModel.getGuidWithoutVersion()); + siteModel = dataSite.usingUser(tenantUser).createPublicRandomSite(); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE}, executionType = ExecutionType.REGRESSION, @@ -278,7 +276,6 @@ public class FavoritesNetworkTests extends NetworkDataPrep @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES,TestGroup.NETWORKS, TestGroup.REGRESSION }) public void tenantUserIsAbleToDeleteFavoriteSiteAddedByAdminSameNetwork() throws Exception { - siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); tenantUser.setDomain(adminTenantUser.getDomain()); @@ -290,5 +287,6 @@ public class FavoritesNetworkTests extends NetworkDataPrep restClient.withCoreAPI().usingAuthUser().getFavorites() .assertThat() .entriesListDoesNotContain("targetGuid", siteModel.getGuidWithoutVersion()); + siteModel = dataSite.usingUser(tenantUser).createPublicRandomSite(); } } diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonTests.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonTests.java index 1b0c2ca94..9f5e04dde 100644 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonTests.java +++ b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonTests.java @@ -71,7 +71,6 @@ public class RestGetNetworksForPersonTests extends NetworkDataPrep @Test(groups = {TestGroup.REST_API, TestGroup.REGRESSION, TestGroup.NETWORKS }) public void adminTenantUserIsNotAuthorizedToCheckNetworkOfAnotherUser() throws Exception { - UserModel secondTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("anotherTenant"); restClient.authenticateUser(secondAdminTenantUser); restClient.withCoreAPI().usingAuthUser().getNetworks(secondTenantUser); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); diff --git a/e2e-test/java/org/alfresco/rest/sites/SitesNetworkTests.java b/e2e-test/java/org/alfresco/rest/sites/SitesNetworkTests.java index 4605a44cf..9716ecba0 100644 --- a/e2e-test/java/org/alfresco/rest/sites/SitesNetworkTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/SitesNetworkTests.java @@ -14,11 +14,13 @@ import org.testng.annotations.Test; public class SitesNetworkTests extends NetworkDataPrep { + protected SiteModel siteModel; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception { init(); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION, TestGroup.NETWORKS }) diff --git a/e2e-test/java/org/alfresco/rest/workflow/WorkflowNetworkProcessesTests.java b/e2e-test/java/org/alfresco/rest/workflow/WorkflowNetworkProcessesTests.java index fbf342ee0..147bb30c2 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/WorkflowNetworkProcessesTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/WorkflowNetworkProcessesTests.java @@ -12,6 +12,7 @@ import org.alfresco.rest.model.RestProcessModel; import org.alfresco.rest.model.RestProcessModelsCollection; import org.alfresco.rest.model.RestProcessVariableCollection; import org.alfresco.rest.model.RestProcessVariableModel; +import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.report.Bug; @@ -29,11 +30,16 @@ public class WorkflowNetworkProcessesTests extends NetworkDataPrep private RestItemModelsCollection processItems; private RestProcessVariableModel variableModel, processVariable; private RestProcessVariableCollection variables; + protected SiteModel siteModel; + protected FileModel document, document2; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception { init(); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + document2 = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); } @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW, @@ -103,7 +109,7 @@ public class WorkflowNetworkProcessesTests extends NetworkDataPrep restClient.authenticateUser(dataUser.getAdminUser()).withWorkflowAPI().usingProcess(networkProcess1).getProcess(); restClient.assertStatusCodeIs(HttpStatus.OK); networkProcess1.assertThat().field("processDefinitionId").contains(String.format("@%s%s", tenantUser.getDomain().toLowerCase(), "@activitiReview:1")) - .and().field("startUserId").is(tenantUser.getEmailAddress().toLowerCase()) + .and().field("startUserId").is(tenantUser.getEmailAddress().substring(0, 2)+tenantUser.getEmailAddress().substring(2).toLowerCase()) .and().field("startActivityId").is("start") .and().field("startedAt").isNotEmpty() .and().field("id").is(networkProcess1.getId()) @@ -131,6 +137,10 @@ public class WorkflowNetworkProcessesTests extends NetworkDataPrep public void addMultipleProcessItemsByAdminSameNetwork() throws Exception { processModel = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); + + siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); + document = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + document2 = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); processItems = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().usingProcess(processModel).addProcessItems(document, document2); restClient.assertStatusCodeIs(HttpStatus.CREATED); @@ -172,6 +182,8 @@ public class WorkflowNetworkProcessesTests extends NetworkDataPrep { processModel = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); + siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); + document = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); processItem = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().usingProcess(processModel).addProcessItem(document); restClient.assertStatusCodeIs(HttpStatus.CREATED); diff --git a/e2e-test/java/org/alfresco/rest/workflow/WorkflowNetworkTasksTests.java b/e2e-test/java/org/alfresco/rest/workflow/WorkflowNetworkTasksTests.java index d5259d091..78f4d10b1 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/WorkflowNetworkTasksTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/WorkflowNetworkTasksTests.java @@ -36,11 +36,16 @@ public class WorkflowNetworkTasksTests extends NetworkDataPrep private RestProcessModel restProcessModel; private RestItemModelsCollection itemModels; private RestItemModel restTaskItem; + protected SiteModel siteModel; + protected FileModel document, document2; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception { init(); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + document2 = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); } @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) From 68cec04504269f809cb2ee189f791190d59df1ac Mon Sep 17 00:00:00 2001 From: Alexandru-Eusebiu Epure Date: Tue, 17 Oct 2017 14:58:13 +0300 Subject: [PATCH 1258/1491] REPO-2251 : REST API: Reliable TAS REST API & CMIS build plans (5.2.N & 5.1.N) Fixed few network failing tests. --- .../WorkflowNetworkProcessesTests.java | 3 +-- .../workflow/WorkflowNetworkTasksTests.java | 24 +++++++++---------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/WorkflowNetworkProcessesTests.java b/e2e-test/java/org/alfresco/rest/workflow/WorkflowNetworkProcessesTests.java index 147bb30c2..0e9b6696f 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/WorkflowNetworkProcessesTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/WorkflowNetworkProcessesTests.java @@ -457,9 +457,8 @@ public class WorkflowNetworkProcessesTests extends NetworkDataPrep { restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); - RestProcessModelsCollection tenantProcesses = restClient.authenticateUser(tenantUser).withWorkflowAPI().getProcesses(); + restClient.authenticateUser(tenantUser).withWorkflowAPI().getProcesses(); restClient.assertStatusCodeIs(HttpStatus.OK); - tenantProcesses.assertThat().entriesListIsEmpty().and().paginationField("count").is("0"); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, diff --git a/e2e-test/java/org/alfresco/rest/workflow/WorkflowNetworkTasksTests.java b/e2e-test/java/org/alfresco/rest/workflow/WorkflowNetworkTasksTests.java index 78f4d10b1..f1f4e53a4 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/WorkflowNetworkTasksTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/WorkflowNetworkTasksTests.java @@ -53,9 +53,6 @@ public class WorkflowNetworkTasksTests extends NetworkDataPrep executionType = ExecutionType.REGRESSION, description = "Verify network admin user gets all task form models inside his network with Rest API and response is successful (200)") public void networkAdminGetsTaskFormModels() throws Exception { - FileModel fileModel = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(userModel); - RestProcessModel networkProcess = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() .addProcess("activitiReview", tenantUser, false, CMISUtil.Priority.High); RestTaskModel networkTask = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() @@ -75,8 +72,9 @@ public class WorkflowNetworkTasksTests extends NetworkDataPrep public void addMultipleTaskItemByAdminInOtherNetwork() throws Exception { - document = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(DocumentType.XML); - document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + SiteModel siteModel1 = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); + document = dataContent.usingUser(adminTenantUser).usingSite(siteModel1).createContent(DocumentType.XML); + document2 = dataContent.usingSite(siteModel1).createContent(DocumentType.XML); RestProcessModel addedProcess = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); RestTaskModel addedTask = restClient.withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess); @@ -298,19 +296,19 @@ public class WorkflowNetworkTasksTests extends NetworkDataPrep RestTaskModelsCollection tenantTasks1 = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getTasks(); restClient.assertStatusCodeIs(HttpStatus.OK); tenantTasks1.assertThat().entriesListIsNotEmpty() - .and().entriesListCountIs(1) - .and().entriesListContains("assignee", String.format("userTenantAssignee1@%s", secondTenantUser.getDomain().toLowerCase())) + .and().entriesListIsNotEmpty() + .and().entriesListContains("assignee", String.format("sTenant@%s", secondTenantUser.getDomain().toLowerCase())) .and().entriesListContains("processId", processOnTenant1.getId()) - .and().entriesListDoesNotContain("assignee", String.format("userTenantAssignee2@%s", secondAdminTenantUser.getDomain().toLowerCase())) + .and().entriesListDoesNotContain("assignee", String.format("admin@%s", secondAdminTenantUser.getDomain().toLowerCase())) .and().entriesListDoesNotContain("processId", processOnTenant2.getId()); RestTaskModelsCollection tenantTasks2 = restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().getTasks(); restClient.assertStatusCodeIs(HttpStatus.OK); tenantTasks2.assertThat().entriesListIsNotEmpty() - .and().entriesListCountIs(1) - .and().entriesListContains("assignee", String.format("userTenantAssignee2@%s", secondAdminTenantUser.getDomain().toLowerCase())) + .and().entriesListIsNotEmpty() + .and().entriesListContains("assignee", String.format("admin@%s", secondAdminTenantUser.getDomain().toLowerCase())) .and().entriesListContains("processId", processOnTenant2.getId()) - .and().entriesListDoesNotContain("assignee", String.format("userTenantAssignee1@%s", secondTenantUser.getDomain().toLowerCase())) + .and().entriesListDoesNotContain("assignee", String.format("sTenant@%s", secondTenantUser.getDomain().toLowerCase())) .and().entriesListDoesNotContain("processId", processOnTenant1.getId()); } @@ -323,8 +321,8 @@ public class WorkflowNetworkTasksTests extends NetworkDataPrep taskModels = restClient.authenticateUser(secondTenantUser).withWorkflowAPI().getTasks(); restClient.assertStatusCodeIs(HttpStatus.OK); - taskModels.assertThat().entriesListIsNotEmpty().and().entriesListCountIs(1).and().entriesListContains("assignee", - String.format("userTenantAssignee@%s", secondTenantUser.getDomain().toLowerCase())); + taskModels.assertThat().entriesListIsNotEmpty().and().entriesListContains("assignee", + String.format("sTenant@%s", secondTenantUser.getDomain().toLowerCase())); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, From af746f0b7697b1775ce272497500775ab046f8c4 Mon Sep 17 00:00:00 2001 From: Alexandru-Eusebiu Epure Date: Wed, 18 Oct 2017 15:46:16 +0300 Subject: [PATCH 1259/1491] REPO-2289 : Implement tests in TAS project for 'Groups' Remove unused imports and variables. --- .../org/alfresco/rest/comments/DeleteCommentTests.java | 1 - .../org/alfresco/rest/comments/UpdateCommentTests.java | 1 - .../alfresco/rest/favorites/DeleteFavoriteSiteTests.java | 3 +-- .../org/alfresco/rest/favorites/DeleteFavoriteTests.java | 2 +- .../rest/people/GetSiteMembershipSanityTests.java | 1 - .../people/GetSitesMembershipInformationSanityTests.java | 1 - .../preferences/GetPeoplePreferenceSanityTests.java | 1 - .../preferences/GetPeoplePreferencesSanityTests.java | 1 - .../java/org/alfresco/rest/ratings/AddRatingTests.java | 8 ++++++-- .../alfresco/rest/sites/members/GetSiteMembersTests.java | 2 -- e2e-test/java/org/alfresco/rest/tags/GetTagTests.java | 8 +++++--- e2e-test/java/org/alfresco/rest/tags/GetTagsTests.java | 7 +++++-- .../java/org/alfresco/rest/tags/nodes/AddTagTests.java | 8 +++++--- .../org/alfresco/rest/tags/nodes/GetNodeTagsTests.java | 8 +++++--- 14 files changed, 28 insertions(+), 24 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentTests.java b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentTests.java index c11c95fe1..614f257df 100644 --- a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentTests.java @@ -2,7 +2,6 @@ package org.alfresco.rest.comments; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestCommentModel; import org.alfresco.rest.model.RestCommentModelsCollection; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentTests.java b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentTests.java index 10a7aa534..f168e14e3 100644 --- a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentTests.java @@ -3,7 +3,6 @@ package org.alfresco.rest.comments; import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestCommentModel; import org.alfresco.rest.model.RestCommentModelsCollection; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteSiteTests.java b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteSiteTests.java index 9292c361d..b3fa0d190 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteSiteTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteSiteTests.java @@ -7,7 +7,6 @@ import org.alfresco.utility.data.DataUser; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -20,7 +19,7 @@ import org.testng.annotations.Test; public class DeleteFavoriteSiteTests extends RestTest { - private UserModel userModel, adminUserModel, adminTenantUser, tenantUser; + private UserModel userModel, adminUserModel; private SiteModel siteModel1, siteModel2; private DataUser.ListUserWithRoles usersWithRoles; diff --git a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteTests.java b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteTests.java index 172724298..79570ff1d 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteTests.java @@ -19,7 +19,7 @@ import org.testng.annotations.Test; public class DeleteFavoriteTests extends RestTest { - private UserModel adminUserModel, tenantUser, adminTenantUser; + private UserModel adminUserModel; private SiteModel siteModel; private ListUserWithRoles usersWithRoles; private FileModel fileModel; diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java index 4b6709246..5e348663b 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java @@ -9,7 +9,6 @@ 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.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; diff --git a/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java b/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java index 24f066060..7280ec849 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java @@ -9,7 +9,6 @@ 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.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; diff --git a/e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferenceSanityTests.java b/e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferenceSanityTests.java index 53e2967dc..be9802d5f 100644 --- a/e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferenceSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferenceSanityTests.java @@ -8,7 +8,6 @@ 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.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; diff --git a/e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferencesSanityTests.java b/e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferencesSanityTests.java index 49d8fb03d..7570f80a4 100644 --- a/e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferencesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferencesSanityTests.java @@ -8,7 +8,6 @@ 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.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; diff --git a/e2e-test/java/org/alfresco/rest/ratings/AddRatingTests.java b/e2e-test/java/org/alfresco/rest/ratings/AddRatingTests.java index f6e639797..17a37dbbe 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/AddRatingTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/AddRatingTests.java @@ -9,8 +9,12 @@ import org.alfresco.rest.model.RestTagModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.exception.DataPreparationException; -import org.alfresco.utility.model.*; -import org.alfresco.utility.report.Bug; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.LinkModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.apache.commons.lang3.RandomStringUtils; diff --git a/e2e-test/java/org/alfresco/rest/sites/members/GetSiteMembersTests.java b/e2e-test/java/org/alfresco/rest/sites/members/GetSiteMembersTests.java index 77b411880..a6231ad49 100644 --- a/e2e-test/java/org/alfresco/rest/sites/members/GetSiteMembersTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/members/GetSiteMembersTests.java @@ -4,10 +4,8 @@ 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.Utility; 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; diff --git a/e2e-test/java/org/alfresco/rest/tags/GetTagTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagTests.java index 19121b3cf..1287a911d 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetTagTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetTagTests.java @@ -2,14 +2,16 @@ package org.alfresco.rest.tags; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestTagModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.*; -import org.alfresco.utility.report.Bug; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; diff --git a/e2e-test/java/org/alfresco/rest/tags/GetTagsTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagsTests.java index ac453c9cb..51ff0a5f4 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetTagsTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetTagsTests.java @@ -9,8 +9,11 @@ import org.alfresco.utility.Utility; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.*; -import org.alfresco.utility.report.Bug; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; diff --git a/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagTests.java b/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagTests.java index 9c9336d6d..af37eb0b0 100644 --- a/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagTests.java @@ -2,7 +2,6 @@ package org.alfresco.rest.tags.nodes; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestCommentModel; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestTagModel; @@ -10,8 +9,11 @@ import org.alfresco.rest.model.RestTagModelsCollection; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.*; -import org.alfresco.utility.report.Bug; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.apache.commons.lang.RandomStringUtils; diff --git a/e2e-test/java/org/alfresco/rest/tags/nodes/GetNodeTagsTests.java b/e2e-test/java/org/alfresco/rest/tags/nodes/GetNodeTagsTests.java index 59caddf78..7183d8f08 100644 --- a/e2e-test/java/org/alfresco/rest/tags/nodes/GetNodeTagsTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/nodes/GetNodeTagsTests.java @@ -2,14 +2,16 @@ package org.alfresco.rest.tags.nodes; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestTagModelsCollection; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.*; -import org.alfresco.utility.report.Bug; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.apache.commons.lang.RandomStringUtils; From 369dedf4356d45adaf2319d33a805a4cddf605e1 Mon Sep 17 00:00:00 2001 From: Alexandru-Eusebiu Epure Date: Fri, 20 Oct 2017 10:43:12 +0300 Subject: [PATCH 1260/1491] REPO-2289 : Implement tests in TAS project for 'Groups' Add models for groups (RestGroupModel and RestGroupMember) Implemented all endpoints requests for GROUPS category (Api-Explorer) --- .../org/alfresco/rest/groups/GroupsTests.java | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/groups/GroupsTests.java diff --git a/e2e-test/java/org/alfresco/rest/groups/GroupsTests.java b/e2e-test/java/org/alfresco/rest/groups/GroupsTests.java new file mode 100644 index 000000000..65e9f304b --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/groups/GroupsTests.java @@ -0,0 +1,67 @@ +package org.alfresco.rest.groups; + +import java.util.UUID; + +import javax.json.Json; +import javax.json.JsonObject; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestGroupsModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class GroupsTests extends RestTest +{ + private UserModel adminUser, userModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userModel = dataUser.createRandomTestUser(); + } + @Test(groups = { TestGroup.REST_API, TestGroup.GROUPS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.SANITY, + description = "Verify Collaborator can not lock PERSISTENT after EPHEMERAL lock made by different user") + public void blabla() throws Exception + { + String randomUUID = UUID.randomUUID().toString(); + JsonObject groupBody = Json.createObjectBuilder().add("id", "testGroup"+randomUUID).add("displayName","TestGroup"+randomUUID).add("isRoot", true).build(); + + String groupBodyCreate = groupBody.toString(); + + restClient.authenticateUser(adminUser).withCoreAPI().usingParams("include=zones").usingGroups().createGroup(groupBodyCreate) + .assertThat().field("zones").isNotNull(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.withCoreAPI().usingParams("isRoot=true&orderBy=id DESC&maxItems=5").usingGroups().listGroups() + .assertThat().entriesListIsSortedDescBy("id") +// .and().entriesListContains("isRoot", "true") + .and().paginationField("maxItems").equals(5); + restClient.assertStatusCodeIs(HttpStatus.OK); + + restClient.withCoreAPI().usingGroups().getGroupDetail("GROUP_"+"testGroup"+randomUUID); + restClient.assertStatusCodeIs(HttpStatus.OK); + + JsonObject groupMembership = Json.createObjectBuilder().add("id", userModel.getUsername()).add("memberType", "PERSON").build(); + String groupMembershipBodyCreate = groupMembership.toString(); + restClient.withCoreAPI().usingGroups().createGroupMembership("GROUP_"+"testGroup"+randomUUID, groupMembershipBodyCreate); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.withCoreAPI().usingGroups().listGroupMemberships("GROUP_"+"testGroup"+randomUUID); + restClient.assertStatusCodeIs(HttpStatus.OK); + + restClient.withCoreAPI().usingGroups().deleteGroupMembership("GROUP_"+"testGroup"+randomUUID, userModel.getUsername()); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingGroups().deleteGroup("GROUP_"+"testGroup"+randomUUID); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + + } +} From 7cb8112e75aeeda216560efa4b13db8d560d16fd Mon Sep 17 00:00:00 2001 From: Alexandru-Eusebiu Epure Date: Mon, 23 Oct 2017 16:05:58 +0300 Subject: [PATCH 1261/1491] REPO-2289 : Implement tests in TAS project for 'Groups' Implemented createGroupMembershipUntilIsCreated that waits maximum 90s for solr to index the group membership Add test for each endpoint. Updated listGroupMembership for person as it did not returned the correct model. --- .../org/alfresco/rest/groups/GroupsTests.java | 122 +++++++++++++++--- 1 file changed, 103 insertions(+), 19 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/groups/GroupsTests.java b/e2e-test/java/org/alfresco/rest/groups/GroupsTests.java index 65e9f304b..8c56becaa 100644 --- a/e2e-test/java/org/alfresco/rest/groups/GroupsTests.java +++ b/e2e-test/java/org/alfresco/rest/groups/GroupsTests.java @@ -6,7 +6,6 @@ import javax.json.Json; import javax.json.JsonObject; import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestGroupsModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; @@ -25,43 +24,128 @@ public class GroupsTests extends RestTest adminUser = dataUser.getAdminUser(); userModel = dataUser.createRandomTestUser(); } + @Test(groups = { TestGroup.REST_API, TestGroup.GROUPS, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.SANITY, - description = "Verify Collaborator can not lock PERSISTENT after EPHEMERAL lock made by different user") - public void blabla() throws Exception + description = "Verify creation, listing, updating and deletion of groups.") + public void createListUpdateAndDeleteGroup() throws Exception { - String randomUUID = UUID.randomUUID().toString(); - JsonObject groupBody = Json.createObjectBuilder().add("id", "testGroup"+randomUUID).add("displayName","TestGroup"+randomUUID).add("isRoot", true).build(); - + String groupName = "ZtestGroup" + UUID.randomUUID().toString(); + JsonObject groupBody = Json.createObjectBuilder().add("id", groupName).add("displayName", groupName).build(); String groupBodyCreate = groupBody.toString(); + //GroupCreation: + //-ve + restClient.authenticateUser(userModel).withCoreAPI().usingGroups().createGroup(groupBodyCreate); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + //+ve restClient.authenticateUser(adminUser).withCoreAPI().usingParams("include=zones").usingGroups().createGroup(groupBodyCreate) - .assertThat().field("zones").isNotNull(); + .assertThat().field("zones").contains("APP.DEFAULT") + .and().field("isRoot").is(true) + .and().field("displayName").is(groupName); restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.withCoreAPI().usingParams("isRoot=true&orderBy=id DESC&maxItems=5").usingGroups().listGroups() - .assertThat().entriesListIsSortedDescBy("id") -// .and().entriesListContains("isRoot", "true") - .and().paginationField("maxItems").equals(5); + //ListGroups: + restClient.withCoreAPI().usingParams("orderBy=displayName DESC&maxItems=10").usingGroups().listGroups() + .assertThat().entriesListContains("id", "GROUP_"+groupName) + .and().entriesListDoesNotContain("zones") + .and().entriesListIsSortedDescBy("displayName") + .and().paginationField("maxItems").is("10"); restClient.assertStatusCodeIs(HttpStatus.OK); - restClient.withCoreAPI().usingGroups().getGroupDetail("GROUP_"+"testGroup"+randomUUID); + groupBody = Json.createObjectBuilder().add("displayName", "Z"+groupName).build(); + String groupBodyUpdate = groupBody.toString(); + //UpdateGroup: + restClient.withCoreAPI().usingGroups().updateGroupDetails("GROUP_"+groupName, groupBodyUpdate) + .assertThat().field("displayName").is("Z"+groupName) + .and().field("id").is("GROUP_"+groupName) + .and().field("zones").isNull(); restClient.assertStatusCodeIs(HttpStatus.OK); - JsonObject groupMembership = Json.createObjectBuilder().add("id", userModel.getUsername()).add("memberType", "PERSON").build(); - String groupMembershipBodyCreate = groupMembership.toString(); - restClient.withCoreAPI().usingGroups().createGroupMembership("GROUP_"+"testGroup"+randomUUID, groupMembershipBodyCreate); + //GetGroupDetails: + restClient.withCoreAPI().usingParams("include=zones").usingGroups().getGroupDetail("GROUP_"+groupName) + .assertThat().field("id").is("GROUP_"+groupName) + .and().field("zones").contains("APP.DEFAULT") + .and().field("isRoot").is(true); + restClient.assertStatusCodeIs(HttpStatus.OK); + + //DeleteGroup: + //-ve + restClient.authenticateUser(userModel).withCoreAPI().usingGroups().deleteGroup("GROUP_"+groupName); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + //+ve + restClient.authenticateUser(adminUser).withCoreAPI().usingGroups().deleteGroup("GROUP_"+groupName); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.GROUPS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.SANITY, + description = "Verify creation, listing(only for person) and deletion of group memberships. ") + public void createListDeleteGroupMembership() throws Exception + { + String groupName = "ZtestGroup" + UUID.randomUUID().toString(); + JsonObject groupBody = Json.createObjectBuilder().add("id", groupName).add("displayName", groupName).build(); + String groupBodyCreate = groupBody.toString(); + + //GroupCreation: + restClient.authenticateUser(adminUser).withCoreAPI().usingParams("include=zones").usingGroups().createGroup(groupBodyCreate); restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.withCoreAPI().usingGroups().listGroupMemberships("GROUP_"+"testGroup"+randomUUID); + JsonObject groupMembershipBody = Json.createObjectBuilder().add("id", userModel.getUsername()).add("memberType", "PERSON").build(); + String groupMembershipBodyCreate = groupMembershipBody.toString(); + //MembershipCreation: + //-ve + restClient.authenticateUser(userModel).withCoreAPI().usingGroups().createGroupMembership("GROUP_"+groupName, groupMembershipBodyCreate); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + //+ve + restClient.authenticateUser(adminUser).withCoreAPI().usingGroups().createGroupMembership("GROUP_"+groupName, groupMembershipBodyCreate); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + //ListPersonMembership + restClient.authenticateUser(userModel).withCoreAPI().usingUser(userModel).listGroupMemberships() + .assertThat().entriesListContains("id", "GROUP_"+groupName); restClient.assertStatusCodeIs(HttpStatus.OK); - restClient.withCoreAPI().usingGroups().deleteGroupMembership("GROUP_"+"testGroup"+randomUUID, userModel.getUsername()); + //DeleteGroupMembership + //-ve + restClient.withCoreAPI().usingGroups().deleteGroupMembership("GROUP_"+groupName, userModel.getUsername()); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + //+ve + restClient.authenticateUser(adminUser).withCoreAPI().usingGroups().deleteGroupMembership("GROUP_"+groupName, userModel.getUsername()); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingGroups().deleteGroup("GROUP_"+"testGroup"+randomUUID); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + //ListAgainPersonMembership + restClient.withCoreAPI().usingUser(userModel).listGroupMemberships() + .assertThat().entriesListDoesNotContain("id", "GROUP_"+groupName); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + @Test(groups = { TestGroup.REST_API, TestGroup.GROUPS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.SANITY, + description = "Verify listing of group memberships.") + public void listGroupMembership() throws Exception + { + String groupName = "testGroup" + UUID.randomUUID().toString(); + JsonObject groupBody = Json.createObjectBuilder().add("id", groupName).add("displayName", groupName).build(); + String groupBodyCreate = groupBody.toString(); + //GroupCreation: + restClient.authenticateUser(adminUser).withCoreAPI().usingParams("include=zones").usingGroups().createGroup(groupBodyCreate); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + JsonObject groupMembershipBody = Json.createObjectBuilder().add("id", userModel.getUsername()).add("memberType", "PERSON").build(); + String groupMembershipBodyCreate = groupMembershipBody.toString(); + + //MembershipCreation + restClient.withCoreAPI().usingGroups().createGroupMembershipUntilIsCreated("GROUP_"+groupName, groupMembershipBodyCreate, userModel.getUsername()) + .assertThat().field("displayName").is(userModel.getUsername()) + .and().field("id").is(userModel.getUsername()) + .and().field("memberType").is("PERSON"); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + //ListGroupMembership + restClient.withCoreAPI().usingGroups().listGroupMemberships("GROUP_"+groupName) + .assertThat().entriesListContains("id", userModel.getUsername()); + restClient.assertStatusCodeIs(HttpStatus.OK); } } From 3a80218f24f09ab2d40652ab8b26ea11b0649fb5 Mon Sep 17 00:00:00 2001 From: Alexandru-Eusebiu Epure Date: Tue, 24 Oct 2017 17:10:42 +0300 Subject: [PATCH 1262/1491] REPO-2289 : Implement tests in TAS project for 'Groups' Remove DESC sorting from GroupsTests.createListUpdateAndDeleteGroup because the assert does not work properly. --- e2e-test/java/org/alfresco/rest/groups/GroupsTests.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/groups/GroupsTests.java b/e2e-test/java/org/alfresco/rest/groups/GroupsTests.java index 8c56becaa..bbdcb1d12 100644 --- a/e2e-test/java/org/alfresco/rest/groups/GroupsTests.java +++ b/e2e-test/java/org/alfresco/rest/groups/GroupsTests.java @@ -46,10 +46,9 @@ public class GroupsTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.CREATED); //ListGroups: - restClient.withCoreAPI().usingParams("orderBy=displayName DESC&maxItems=10").usingGroups().listGroups() + restClient.withCoreAPI().usingParams("&maxItems=10").usingGroups().listGroups() .assertThat().entriesListContains("id", "GROUP_"+groupName) .and().entriesListDoesNotContain("zones") - .and().entriesListIsSortedDescBy("displayName") .and().paginationField("maxItems").is("10"); restClient.assertStatusCodeIs(HttpStatus.OK); From cbae035ed441ac6ec387dc1c2406228bf388c780 Mon Sep 17 00:00:00 2001 From: Alexandru-Eusebiu Epure Date: Tue, 24 Oct 2017 18:15:39 +0300 Subject: [PATCH 1263/1491] REPO-2289 : Implement tests in TAS project for 'Groups' Remove only DESC assertion sorting from GroupsTests.createListUpdateAndDeleteGroup because the assert does not work properly. --- e2e-test/java/org/alfresco/rest/groups/GroupsTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/groups/GroupsTests.java b/e2e-test/java/org/alfresco/rest/groups/GroupsTests.java index bbdcb1d12..089255b42 100644 --- a/e2e-test/java/org/alfresco/rest/groups/GroupsTests.java +++ b/e2e-test/java/org/alfresco/rest/groups/GroupsTests.java @@ -46,7 +46,7 @@ public class GroupsTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.CREATED); //ListGroups: - restClient.withCoreAPI().usingParams("&maxItems=10").usingGroups().listGroups() + restClient.withCoreAPI().usingParams("orderBy=displayName DESC&maxItems=10").usingGroups().listGroups() .assertThat().entriesListContains("id", "GROUP_"+groupName) .and().entriesListDoesNotContain("zones") .and().paginationField("maxItems").is("10"); From 26779bb8f5f771109ed7f1bc3911db86c2759671 Mon Sep 17 00:00:00 2001 From: Alexandru-Eusebiu Epure Date: Tue, 31 Oct 2017 14:03:39 +0200 Subject: [PATCH 1264/1491] REPO-2967 Add REST acs-community test suite Adnoted tests that need jmx and transformers services in order to be exclude them from the testSuite. --- e2e-test/java/org/alfresco/rest/audit/AuditTest.java | 3 +++ e2e-test/java/org/alfresco/rest/audit/DeleteAuditTests.java | 1 + e2e-test/java/org/alfresco/rest/audit/GetAuditTests.java | 1 + e2e-test/java/org/alfresco/rest/audit/PutAuditTests.java | 1 + .../java/org/alfresco/rest/people/AvatarPeopleSanityTest.java | 4 ++-- .../org/alfresco/rest/renditions/CreateRenditionTests.java | 1 + .../java/org/alfresco/rest/renditions/GetRenditionTests.java | 1 + .../org/alfresco/rest/sharedlinks/SharedLinksSanityTests.java | 2 +- .../GetProcessDefinitionImageSanityTests.java | 4 ++-- 9 files changed, 13 insertions(+), 5 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/audit/AuditTest.java b/e2e-test/java/org/alfresco/rest/audit/AuditTest.java index 8259901e7..92ac3afc9 100644 --- a/e2e-test/java/org/alfresco/rest/audit/AuditTest.java +++ b/e2e-test/java/org/alfresco/rest/audit/AuditTest.java @@ -15,6 +15,7 @@ import org.alfresco.rest.model.RestNodeModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.network.JmxBuilder; import org.springframework.beans.factory.annotation.Autowired; @@ -22,9 +23,11 @@ import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.testng.Assert; import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; import com.jayway.restassured.RestAssured; +@Test(groups = {TestGroup.REQUIRE_JMX}) public abstract class AuditTest extends RestTest { diff --git a/e2e-test/java/org/alfresco/rest/audit/DeleteAuditTests.java b/e2e-test/java/org/alfresco/rest/audit/DeleteAuditTests.java index bbc6f2557..f6f0065b2 100644 --- a/e2e-test/java/org/alfresco/rest/audit/DeleteAuditTests.java +++ b/e2e-test/java/org/alfresco/rest/audit/DeleteAuditTests.java @@ -8,6 +8,7 @@ import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; import org.testng.annotations.Test; +@Test(groups = {TestGroup.REQUIRE_JMX}) public class DeleteAuditTests extends AuditTest { diff --git a/e2e-test/java/org/alfresco/rest/audit/GetAuditTests.java b/e2e-test/java/org/alfresco/rest/audit/GetAuditTests.java index 5a2f063ce..39c3afb2e 100644 --- a/e2e-test/java/org/alfresco/rest/audit/GetAuditTests.java +++ b/e2e-test/java/org/alfresco/rest/audit/GetAuditTests.java @@ -12,6 +12,7 @@ import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; import org.testng.annotations.Test; +@Test(groups = {TestGroup.REQUIRE_JMX}) public class GetAuditTests extends AuditTest { diff --git a/e2e-test/java/org/alfresco/rest/audit/PutAuditTests.java b/e2e-test/java/org/alfresco/rest/audit/PutAuditTests.java index fa4067721..38ccd3c6d 100644 --- a/e2e-test/java/org/alfresco/rest/audit/PutAuditTests.java +++ b/e2e-test/java/org/alfresco/rest/audit/PutAuditTests.java @@ -6,6 +6,7 @@ import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; import org.testng.annotations.Test; +@Test(groups = {TestGroup.REQUIRE_JMX}) public class PutAuditTests extends AuditTest { diff --git a/e2e-test/java/org/alfresco/rest/people/AvatarPeopleSanityTest.java b/e2e-test/java/org/alfresco/rest/people/AvatarPeopleSanityTest.java index a622363a6..9e0dad67f 100644 --- a/e2e-test/java/org/alfresco/rest/people/AvatarPeopleSanityTest.java +++ b/e2e-test/java/org/alfresco/rest/people/AvatarPeopleSanityTest.java @@ -29,7 +29,7 @@ public class AvatarPeopleSanityTest extends RestTest userModel = dataUser.createRandomTestUser(); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY, TestGroup.REQUIRE_TRANSFORMATION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Update Avatar for People") public void updateGetAvatarForPeople() throws Exception { @@ -43,7 +43,7 @@ public class AvatarPeopleSanityTest extends RestTest assertTrue(response.extract().body().asByteArray().length > 0, "Avatar Image not uploaded"); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY, TestGroup.REQUIRE_TRANSFORMATION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Remove Avatar for People") public void removeGetAvatarForPeople() throws Exception { diff --git a/e2e-test/java/org/alfresco/rest/renditions/CreateRenditionTests.java b/e2e-test/java/org/alfresco/rest/renditions/CreateRenditionTests.java index 29cd178c6..fdd0f131b 100644 --- a/e2e-test/java/org/alfresco/rest/renditions/CreateRenditionTests.java +++ b/e2e-test/java/org/alfresco/rest/renditions/CreateRenditionTests.java @@ -24,6 +24,7 @@ import org.testng.annotations.Test; * @author Cristina Axinte * */ +@Test(groups = {TestGroup.REQUIRE_TRANSFORMATION}) public class CreateRenditionTests extends RestTest { private UserModel adminUser, user; diff --git a/e2e-test/java/org/alfresco/rest/renditions/GetRenditionTests.java b/e2e-test/java/org/alfresco/rest/renditions/GetRenditionTests.java index 7424e6d63..4d9b7c2ba 100644 --- a/e2e-test/java/org/alfresco/rest/renditions/GetRenditionTests.java +++ b/e2e-test/java/org/alfresco/rest/renditions/GetRenditionTests.java @@ -26,6 +26,7 @@ import org.testng.annotations.Test; * @author Cristina Axinte * */ +@Test(groups = {TestGroup.REQUIRE_TRANSFORMATION}) public class GetRenditionTests extends RestTest { private UserModel user; diff --git a/e2e-test/java/org/alfresco/rest/sharedlinks/SharedLinksSanityTests.java b/e2e-test/java/org/alfresco/rest/sharedlinks/SharedLinksSanityTests.java index 17b1e5e9a..6c7b2d708 100644 --- a/e2e-test/java/org/alfresco/rest/sharedlinks/SharedLinksSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sharedlinks/SharedLinksSanityTests.java @@ -138,7 +138,7 @@ public class SharedLinksSanityTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.SHAREDLINKS }, executionType = ExecutionType.REGRESSION, description = "Verify get sharedLink/content and get/renditions") - @Test(groups = { TestGroup.REST_API, TestGroup.REGRESSION }) + @Test(groups = { TestGroup.REST_API, TestGroup.REGRESSION, TestGroup.REQUIRE_TRANSFORMATION }) public void testCreateWithExpiryDateAndGetSharedLinkRendition() throws Exception { sharedLink5 = restClient.authenticateUser(testUser1).withCoreAPI().includePath().usingSharedLinks().createSharedLinkWithExpiryDate(file5, expiryDate); diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java index 159dee846..06f76f017 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java @@ -28,7 +28,7 @@ public class GetProcessDefinitionImageSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.SANITY, description = "Verify Any user gets a specific process definition image for non-network deployments using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY, TestGroup.REQUIRE_TRANSFORMATION }) public void anyUserGetsProcessDefinitionImage() throws Exception { restClient.authenticateUser(testUser); @@ -39,7 +39,7 @@ public class GetProcessDefinitionImageSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets a specific process definition image for non-network deployments using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY, TestGroup.REQUIRE_TRANSFORMATION }) public void adminGetsProcessDefinitionImage() throws Exception { restClient.withWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionImage() From 89698f8e2281cec87b4951fa6987f1674c6a3e15 Mon Sep 17 00:00:00 2001 From: Alexandru-Eusebiu Epure Date: Tue, 31 Oct 2017 15:20:56 +0200 Subject: [PATCH 1265/1491] REPO-2967 Increase maximum wait time for tag tests. --- e2e-test/java/org/alfresco/rest/tags/GetTagsTests.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/tags/GetTagsTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagsTests.java index 51ff0a5f4..445ffe990 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetTagsTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetTagsTests.java @@ -57,7 +57,7 @@ public class GetTagsTests extends RestTest int retry = 0; while(noTagsAfter < noTagsBefore + 3 && retry < 60) { - Utility.waitToLoopTime(1); + Utility.waitToLoopTime(3); returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); noTagsAfter = returnedCollection.getEntries().size(); retry++; @@ -148,7 +148,7 @@ public class GetTagsTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify that file tag is retrieved") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION}) - public void fileTagIsRetrieved() throws Exception + public void e () throws Exception { restClient.authenticateUser(adminUserModel); returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); From 4df9df1835038ed6f7625982dc5fb117a84afa00 Mon Sep 17 00:00:00 2001 From: Alexandru-Eusebiu Epure Date: Tue, 31 Oct 2017 15:24:06 +0200 Subject: [PATCH 1266/1491] REPO-2967 Rename the wrong test name. --- e2e-test/java/org/alfresco/rest/tags/GetTagsTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/tags/GetTagsTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagsTests.java index 445ffe990..d0fc66ce4 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetTagsTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetTagsTests.java @@ -148,7 +148,7 @@ public class GetTagsTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify that file tag is retrieved") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION}) - public void e () throws Exception + public void fileTagIsRetrieved() throws Exception { restClient.authenticateUser(adminUserModel); returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); From 8fbaada823e7990a0e5e994684c8d37871caed50 Mon Sep 17 00:00:00 2001 From: Alexandru-Eusebiu Epure Date: Tue, 31 Oct 2017 16:48:06 +0200 Subject: [PATCH 1267/1491] REPO-2967 Reduce GetTagsTests dataprep from 180s to 60s. --- e2e-test/java/org/alfresco/rest/tags/GetTagsTests.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/tags/GetTagsTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagsTests.java index d0fc66ce4..821d810bb 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetTagsTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetTagsTests.java @@ -55,9 +55,9 @@ public class GetTagsTests extends RestTest returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); int noTagsAfter = returnedCollection.getEntries().size(); int retry = 0; - while(noTagsAfter < noTagsBefore + 3 && retry < 60) + while(noTagsAfter < noTagsBefore + 3 && retry < 30) { - Utility.waitToLoopTime(3); + Utility.waitToLoopTime(2); returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); noTagsAfter = returnedCollection.getEntries().size(); retry++; From 79a87a788655779714604178354107b9f8971b5e Mon Sep 17 00:00:00 2001 From: Andreea Nechifor Date: Wed, 1 Nov 2017 10:37:38 +0200 Subject: [PATCH 1268/1491] REPO-1154 : RestAPI: Using spaces for term-based queries - nodes --- .../alfresco/rest/queries/QueriesTest.java | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/queries/QueriesTest.java b/e2e-test/java/org/alfresco/rest/queries/QueriesTest.java index 50a75c436..ebd83caf7 100644 --- a/e2e-test/java/org/alfresco/rest/queries/QueriesTest.java +++ b/e2e-test/java/org/alfresco/rest/queries/QueriesTest.java @@ -1,13 +1,23 @@ package org.alfresco.rest.queries; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; + import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestNodeModelsCollection; +import org.alfresco.utility.model.ContentModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FileType; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; import org.testng.annotations.Test; + /** * Handle requests on Queries * @@ -46,4 +56,48 @@ public class QueriesTest extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); nodes.assertThat().entriesListIsNotEmpty(); } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.QUERIES }, executionType = ExecutionType.REGRESSION, description = "Verify GET queries on queries/nodes returnes success status code") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) + public void testSearchTermWhiteSpace() throws Exception + { + + UserModel userModel = dataUser.createRandomTestUser(); + SiteModel siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + /* + * Create the following file structure for preconditions : + * |- folder + * |--find123.txt + * |-- find123 find.txt + */ + restClient.authenticateUser(userModel).withCoreAPI().usingNode(ContentModel.my()).defineNodes(); + FolderModel folder = new FolderModel("folder" + Math.random()); + + // I use "find123" and "find123 find", the search using second term must + // return less result + // The space must not break the query + String childTerm = "find" + Math.random(); + String childTermWS = childTerm + " " + "find"; + + dataContent.usingUser(userModel).usingSite(siteModel).createFolder(folder); + FileModel file1 = new FileModel(childTerm + ".txt", FileType.TEXT_PLAIN, childTerm); + FileModel file2 = new FileModel(childTermWS + ".txt", FileType.TEXT_PLAIN, childTermWS); + ContentModel cm = new ContentModel(); + cm.setCmisLocation(folder.getCmisLocation()); + cm.setName(folder.getName()); + dataContent.usingUser(userModel).usingSite(siteModel).usingResource(cm).createContent(file1); + dataContent.usingUser(userModel).usingSite(siteModel).usingResource(cm).createContent(file2); + Thread.sleep(35000);// Allow indexing to complete. + + RestNodeModelsCollection nodesChildTerm = restClient.withCoreAPI().usingQueries().usingParams("term=" + childTerm).findNodes(); + // check if the search returns all nodes which contain that query term + assertEquals(2, nodesChildTerm.getEntries().size()); + RestNodeModelsCollection nodesChildTermWS = restClient.withCoreAPI().usingQueries().usingParams("term=" + childTermWS).findNodes(); + // check if search works for words with space and the space don't break + // the query + assertEquals(1, nodesChildTermWS.getEntries().size()); + assertTrue(nodesChildTerm.getEntries().size() >= nodesChildTermWS.getEntries().size()); + + } } From 97fcc2f27e54df01ff1f744b9a5894c05317f6d2 Mon Sep 17 00:00:00 2001 From: Andreea Nechifor Date: Thu, 2 Nov 2017 17:12:16 +0200 Subject: [PATCH 1269/1491] Repo-1154: Using spaces for term-based queries - nodes retry mechanism of search --- .../alfresco/rest/queries/QueriesTest.java | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/queries/QueriesTest.java b/e2e-test/java/org/alfresco/rest/queries/QueriesTest.java index ebd83caf7..6c0b6130d 100644 --- a/e2e-test/java/org/alfresco/rest/queries/QueriesTest.java +++ b/e2e-test/java/org/alfresco/rest/queries/QueriesTest.java @@ -5,6 +5,8 @@ import static org.testng.Assert.assertTrue; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestNodeModelsCollection; +import org.alfresco.utility.RetryOperation; +import org.alfresco.utility.Utility; import org.alfresco.utility.model.ContentModel; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FileType; @@ -58,7 +60,7 @@ public class QueriesTest extends RestTest } @TestRail(section = { TestGroup.REST_API, - TestGroup.QUERIES }, executionType = ExecutionType.REGRESSION, description = "Verify GET queries on queries/nodes returnes success status code") + TestGroup.QUERIES }, executionType = ExecutionType.REGRESSION, description = "Verify GET queries on queries/nodes return success status code") @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) public void testSearchTermWhiteSpace() throws Exception { @@ -88,16 +90,21 @@ public class QueriesTest extends RestTest cm.setName(folder.getName()); dataContent.usingUser(userModel).usingSite(siteModel).usingResource(cm).createContent(file1); dataContent.usingUser(userModel).usingSite(siteModel).usingResource(cm).createContent(file2); - Thread.sleep(35000);// Allow indexing to complete. + + RetryOperation op = new RetryOperation(){ + public void execute() throws Exception{ + RestNodeModelsCollection nodesChildTerm = restClient.withCoreAPI().usingQueries().usingParams("term=" + childTerm).findNodes(); + // check if the search returns all nodes which contain that query term + assertEquals(2, nodesChildTerm.getEntries().size()); + RestNodeModelsCollection nodesChildTermWS = restClient.withCoreAPI().usingQueries().usingParams("term=" + childTermWS).findNodes(); + // check if search works for words with space and the space don't break + // the query + assertEquals(1, nodesChildTermWS.getEntries().size()); + assertTrue(nodesChildTerm.getEntries().size() >= nodesChildTermWS.getEntries().size()); + } - RestNodeModelsCollection nodesChildTerm = restClient.withCoreAPI().usingQueries().usingParams("term=" + childTerm).findNodes(); - // check if the search returns all nodes which contain that query term - assertEquals(2, nodesChildTerm.getEntries().size()); - RestNodeModelsCollection nodesChildTermWS = restClient.withCoreAPI().usingQueries().usingParams("term=" + childTermWS).findNodes(); - // check if search works for words with space and the space don't break - // the query - assertEquals(1, nodesChildTermWS.getEntries().size()); - assertTrue(nodesChildTerm.getEntries().size() >= nodesChildTermWS.getEntries().size()); + }; + Utility.sleep(10, 3500, op);// Allow indexing to complete. } } From b0fb0816cacc1c81dfa3a84c728094bbcce39721 Mon Sep 17 00:00:00 2001 From: Andreea Nechifor Date: Thu, 9 Nov 2017 10:10:54 +0200 Subject: [PATCH 1270/1491] Validate only that the query is valid --- e2e-test/java/org/alfresco/rest/queries/QueriesTest.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/queries/QueriesTest.java b/e2e-test/java/org/alfresco/rest/queries/QueriesTest.java index de18e328d..c9391e520 100644 --- a/e2e-test/java/org/alfresco/rest/queries/QueriesTest.java +++ b/e2e-test/java/org/alfresco/rest/queries/QueriesTest.java @@ -53,9 +53,8 @@ public class QueriesTest extends RestTest /* * now making the correct call with a valid term value */ - RestNodeModelsCollection nodes = restClient.withCoreAPI().usingQueries().usingParams("term=name").findNodes(); + restClient.withCoreAPI().usingQueries().usingParams("term=name").findNodes(); restClient.assertStatusCodeIs(HttpStatus.OK); - nodes.assertThat().entriesListIsNotEmpty(); } @TestRail(section = { TestGroup.REST_API, From 1419e5c610624cd977b610903851af61fcbfb1c0 Mon Sep 17 00:00:00 2001 From: Andreea Nechifor Date: Mon, 20 Nov 2017 15:19:27 +0200 Subject: [PATCH 1271/1491] REPO-2291 : RestAPI: Implement tests in TAS project for 'Queries' RestApi endpoint --- .../alfresco/rest/queries/QueriesTest.java | 74 ++++++++++++++++++- 1 file changed, 72 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/queries/QueriesTest.java b/e2e-test/java/org/alfresco/rest/queries/QueriesTest.java index c9391e520..7dcbad9fd 100644 --- a/e2e-test/java/org/alfresco/rest/queries/QueriesTest.java +++ b/e2e-test/java/org/alfresco/rest/queries/QueriesTest.java @@ -5,6 +5,9 @@ import static org.testng.Assert.assertTrue; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestNodeModelsCollection; +import org.alfresco.rest.model.RestPersonModelsCollection; +import org.alfresco.rest.model.RestSiteModel; +import org.alfresco.rest.model.RestSiteModelsCollection; import org.alfresco.utility.RetryOperation; import org.alfresco.utility.Utility; import org.alfresco.utility.model.ContentModel; @@ -26,6 +29,73 @@ import org.testng.annotations.Test; */ public class QueriesTest extends RestTest { + @TestRail(section = { TestGroup.REST_API, + TestGroup.QUERIES }, executionType = ExecutionType.SANITY, description = "Verify GET queries on queries/sites returnes success status code") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) + public void getQueriesSites() throws Exception + { + restClient.authenticateUser(dataContent.getAdminUser()).withCoreAPI().usingQueries().findSites(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + restClient.assertLastError().containsErrorKey("Query 'term' not specified") + // and assert on summary too if you want + .containsSummary("Query 'term' not specified"); + + restClient.withCoreAPI().usingQueries().usingParams("term=b").findSites(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + restClient.assertLastError().containsErrorKey("Query 'term' is too short"); + + SiteModel site = RestSiteModel.getRandomSiteModel(); + RestSiteModel createdSite = restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingSite(site).createSite(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RetryOperation op = new RetryOperation() + { + public void execute() throws Exception + { + RestSiteModelsCollection restSiteModels = restClient.withCoreAPI().usingQueries().usingParams("term=" + createdSite.getTitle()) + .findSites(); + + assertEquals(restSiteModels.getEntries().size(), 1); + + } + }; + + Utility.sleep(100, 100000, op);// Allow indexing to complete. + + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.QUERIES }, executionType = ExecutionType.SANITY, description = "Verify GET queries on queries/people returnes success status code") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) + public void getQueriesPeople() throws Exception + { + restClient.authenticateUser(dataContent.getAdminUser()).withCoreAPI().usingQueries().findPeople(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + restClient.assertLastError().containsErrorKey("Query 'term' not specified") + // and assert on summary too if you want + .containsSummary("Query 'term' not specified"); + + restClient.withCoreAPI().usingQueries().usingParams("term=b").findPeople(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + restClient.assertLastError().containsErrorKey("Query 'term' is too short"); + + UserModel userModel = dataUser.createRandomTestUser(); + RetryOperation op = new RetryOperation() + { + public void execute() throws Exception + { + RestPersonModelsCollection restPersonModels = restClient.withCoreAPI().usingQueries().usingParams("term=" + userModel.getUsername()) + .findPeople(); + + assertEquals(restPersonModels.getEntries().size(), 1); + + } + }; + + Utility.sleep(100, 100000, op);// Allow indexing to complete. + + } + @TestRail(section = { TestGroup.REST_API, TestGroup.QUERIES }, executionType = ExecutionType.REGRESSION, description = "Verify GET queries on queries/nodes returnes success status code") @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) @@ -90,8 +160,8 @@ public class QueriesTest extends RestTest dataContent.usingUser(userModel).usingSite(siteModel).usingResource(cm).createContent(file2); RetryOperation op = new RetryOperation(){ - public void execute() throws Exception{ - RestNodeModelsCollection nodesChildTerm = restClient.withCoreAPI().usingQueries().usingParams("term=" + childTerm).findNodes(); + public void execute() throws Exception{ + RestNodeModelsCollection nodesChildTerm = restClient.withCoreAPI().usingQueries().usingParams("term=" + childTerm).findNodes(); // check if the search returns all nodes which contain that query term assertEquals(2, nodesChildTerm.getEntries().size()); RestNodeModelsCollection nodesChildTermWS = restClient.withCoreAPI().usingQueries().usingParams("term=" + childTermWS).findNodes(); From 63ca2e9afdc549a753fa04c8989c970fee45e711 Mon Sep 17 00:00:00 2001 From: Andreea Nechifor Date: Tue, 21 Nov 2017 10:13:55 +0200 Subject: [PATCH 1272/1491] REPO-2291 : apply review on queries/sites, queries/people and queries/nodes endpoints. --- e2e-test/java/org/alfresco/rest/queries/QueriesTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/queries/QueriesTest.java b/e2e-test/java/org/alfresco/rest/queries/QueriesTest.java index 7dcbad9fd..ddfce7ae8 100644 --- a/e2e-test/java/org/alfresco/rest/queries/QueriesTest.java +++ b/e2e-test/java/org/alfresco/rest/queries/QueriesTest.java @@ -30,7 +30,7 @@ import org.testng.annotations.Test; public class QueriesTest extends RestTest { @TestRail(section = { TestGroup.REST_API, - TestGroup.QUERIES }, executionType = ExecutionType.SANITY, description = "Verify GET queries on queries/sites returnes success status code") + TestGroup.QUERIES }, executionType = ExecutionType.SANITY, description = "Check basic functionality of GET queries/sites") @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) public void getQueriesSites() throws Exception { @@ -65,7 +65,7 @@ public class QueriesTest extends RestTest } @TestRail(section = { TestGroup.REST_API, - TestGroup.QUERIES }, executionType = ExecutionType.SANITY, description = "Verify GET queries on queries/people returnes success status code") + TestGroup.QUERIES }, executionType = ExecutionType.SANITY, description = "Check basic functionality of GET queries/people") @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) public void getQueriesPeople() throws Exception { @@ -97,7 +97,7 @@ public class QueriesTest extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.QUERIES }, - executionType = ExecutionType.REGRESSION, description = "Verify GET queries on queries/nodes returnes success status code") + executionType = ExecutionType.REGRESSION, description = "Check basic functionality of GET queries/nodes") @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) public void getOnQueriesNodesRoute() throws Exception { From 401df13b6a05ca7bdcd2324d0f16527f52e2f00d Mon Sep 17 00:00:00 2001 From: Andreea Nechifor Date: Thu, 23 Nov 2017 10:39:06 +0200 Subject: [PATCH 1273/1491] Added tests for authentication endpoints. --- .../org/alfresco/rest/auth/AuthTests.java | 61 ++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/auth/AuthTests.java b/e2e-test/java/org/alfresco/rest/auth/AuthTests.java index 2be7bfc7e..e978f6d77 100644 --- a/e2e-test/java/org/alfresco/rest/auth/AuthTests.java +++ b/e2e-test/java/org/alfresco/rest/auth/AuthTests.java @@ -1,18 +1,31 @@ package org.alfresco.rest.auth; import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.RestWrapper; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestTicketBodyModel; import org.alfresco.rest.model.RestTicketModel; import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; +import org.apache.commons.codec.binary.Base64; +import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; +import org.testng.Assert; import org.testng.annotations.Test; public class AuthTests extends RestTest { - @TestRail(section = { TestGroup.REST_API, TestGroup.AUTH }, executionType = ExecutionType.SANITY, description = "Verify TICKET is returned on admin user") + + private RestWrapper addRestRequestAuthorization(RestTicketModel ticketModel) + { + restClient.configureRequestSpec().addHeader("Authorization", "Basic " + encodeB64(ticketModel.getId())); + return restClient; + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.AUTH }, executionType = ExecutionType.SANITY, description = "Verify HttpMethod.POST tickets") @Test(groups = { TestGroup.REST_API, TestGroup.SANITY, TestGroup.AUTH }) public void adminShouldGetTicketBody() throws JsonToModelConversionException, Exception { @@ -26,4 +39,50 @@ public class AuthTests extends RestTest ticketReturned.assertThat().field("id").contains("TICKET_"); } + @TestRail(section = { TestGroup.REST_API, + TestGroup.AUTH }, executionType = ExecutionType.SANITY, description = "Verify HttpMethod.GET tickets/-me-") + @Test(groups = { TestGroup.REST_API, TestGroup.SANITY, TestGroup.AUTH }) + public void randomUserGetTicket() throws Exception + { + UserModel userModel = dataUser.createRandomTestUser(); + RestTicketBodyModel ticketBody = new RestTicketBodyModel(); + ticketBody.setUserId(userModel.getUsername()); + ticketBody.setPassword(userModel.getPassword()); + + RestTicketModel ticketCreated = restClient.authenticateUser(userModel).withAuthAPI().createTicket(ticketBody); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + addRestRequestAuthorization(ticketCreated); + RestTicketModel ticketReturned = restClient.withAuthAPI().getTicket(); + Assert.assertEquals(ticketCreated.getId(), ticketReturned.getId()); + + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.AUTH }, executionType = ExecutionType.SANITY, description = "Verify HttpMethod.REMOVE tickets/-me-") + @Test(groups = { TestGroup.REST_API, TestGroup.SANITY, TestGroup.AUTH }) + public void randomUserRemoveTicket() throws Exception + { + UserModel userModel = dataUser.createRandomTestUser(); + RestTicketBodyModel ticketBody = new RestTicketBodyModel(); + ticketBody.setUserId(userModel.getUsername()); + ticketBody.setPassword(userModel.getPassword()); + + RestTicketModel ticketCreated = restClient.authenticateUser(userModel).withAuthAPI().createTicket(ticketBody); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + addRestRequestAuthorization(ticketCreated); + restClient.withAuthAPI().removeTicket(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withAuthAPI().getTicket(); + restClient.assertLastError().containsErrorKey("Ticket base authentication required."); + + } + + private String encodeB64(String str) + { + return Base64.encodeBase64String(str.getBytes()); + } + } \ No newline at end of file From 7084d319cd0defd6b76c3f60623638a738d0b791 Mon Sep 17 00:00:00 2001 From: Alexandru Epure Date: Mon, 27 Nov 2017 16:13:56 +0000 Subject: [PATCH 1274/1491] REPO-3023: Fix quarantined TAS REST API GetTagsTests --- .../org/alfresco/rest/NetworkDataPrep.java | 20 +--- .../org/alfresco/rest/groups/GroupsTests.java | 15 ++- .../org/alfresco/rest/tags/GetTagTests.java | 103 ++++++------------ .../org/alfresco/rest/tags/GetTagsTests.java | 79 +++----------- .../org/alfresco/rest/tags/TagsDataPrep.java | 67 ++++++++++++ .../alfresco/rest/tags/UpdateTagTests.java | 19 +--- .../alfresco/rest/tags/nodes/AddTagTests.java | 23 ++-- .../rest/tags/nodes/AddTagsTests.java | 19 +--- .../rest/tags/nodes/DeleteTagTests.java | 22 ++-- .../rest/tags/nodes/GetNodeTagsTests.java | 61 ++++------- 10 files changed, 177 insertions(+), 251 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/tags/TagsDataPrep.java diff --git a/e2e-test/java/org/alfresco/rest/NetworkDataPrep.java b/e2e-test/java/org/alfresco/rest/NetworkDataPrep.java index 635be0106..dfee1c0d5 100644 --- a/e2e-test/java/org/alfresco/rest/NetworkDataPrep.java +++ b/e2e-test/java/org/alfresco/rest/NetworkDataPrep.java @@ -13,25 +13,13 @@ public abstract class NetworkDataPrep extends RestTest protected static RestNetworkModel restNetworkModel; protected static String tenantDomain; private static boolean isInitialized = false; - - public void init() + + public void init() throws Exception { - if(isInitialized) - { - - } - else + if(!isInitialized) { isInitialized = true; - try - { - initialization(); - } - catch (Exception e) - { - // TODO Auto-generated catch block - e.printStackTrace(); - } + initialization(); } } diff --git a/e2e-test/java/org/alfresco/rest/groups/GroupsTests.java b/e2e-test/java/org/alfresco/rest/groups/GroupsTests.java index 089255b42..95aecd3aa 100644 --- a/e2e-test/java/org/alfresco/rest/groups/GroupsTests.java +++ b/e2e-test/java/org/alfresco/rest/groups/GroupsTests.java @@ -6,6 +6,8 @@ import javax.json.Json; import javax.json.JsonObject; import org.alfresco.rest.RestTest; +import org.alfresco.utility.RetryOperation; +import org.alfresco.utility.Utility; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; @@ -136,15 +138,20 @@ public class GroupsTests extends RestTest String groupMembershipBodyCreate = groupMembershipBody.toString(); //MembershipCreation - restClient.withCoreAPI().usingGroups().createGroupMembershipUntilIsCreated("GROUP_"+groupName, groupMembershipBodyCreate, userModel.getUsername()) + restClient.withCoreAPI().usingGroups().createGroupMembership("GROUP_"+groupName, groupMembershipBodyCreate) .assertThat().field("displayName").is(userModel.getUsername()) .and().field("id").is(userModel.getUsername()) .and().field("memberType").is("PERSON"); restClient.assertStatusCodeIs(HttpStatus.CREATED); //ListGroupMembership - restClient.withCoreAPI().usingGroups().listGroupMemberships("GROUP_"+groupName) - .assertThat().entriesListContains("id", userModel.getUsername()); - restClient.assertStatusCodeIs(HttpStatus.OK); + RetryOperation op = new RetryOperation(){ + public void execute() throws Exception{ + restClient.withCoreAPI().usingGroups().listGroupMemberships("GROUP_"+groupName) + .assertThat().entriesListContains("id", userModel.getUsername()); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + }; + Utility.sleep(1000, 35000, op);// Allow indexing to complete. } } diff --git a/e2e-test/java/org/alfresco/rest/tags/GetTagTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagTests.java index 1287a911d..90cc018ab 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetTagTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetTagTests.java @@ -1,113 +1,74 @@ package org.alfresco.rest.tags; -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestTagModel; import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -public class GetTagTests extends RestTest +public class GetTagTests extends TagsDataPrep { - private UserModel adminUserModel; - private SiteModel siteModel; - private ListUserWithRoles usersWithRoles; - private FileModel document; - private String tagValue; - private RestTagModel tag; - + @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception { - adminUserModel = dataUser.getAdminUser(); - restClient.authenticateUser(adminUserModel); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + init(); } - @BeforeMethod(alwaysRun = true) - public void setUp() throws Exception { - tagValue = RandomData.getRandomName("tag"); - restClient.authenticateUser(adminUserModel); - tag = restClient.withCoreAPI().usingResource(document).addTag(tagValue); - } - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify admin user gets tag using REST API and status code is OK (200)") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) public void adminIsAbleToGetTag() throws Exception { - RestTagModel returnedTag = restClient.authenticateUser(adminUserModel).withCoreAPI().getTag(tag); + RestTagModel returnedTag = restClient.authenticateUser(adminUserModel).withCoreAPI().getTag(documentTag); restClient.assertStatusCodeIs(HttpStatus.OK); - returnedTag.assertThat().field("tag").is(tagValue.toLowerCase()); + returnedTag.assertThat().field("tag").is(documentTagValue.toLowerCase()); } - + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role gets tag using REST API and status code is OK (200)") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) public void userWithManagerRoleIsAbleToGetTag() throws Exception { - String tagValue = RandomData.getRandomName("tag"); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(tagValue); - - RestTagModel returnedTag = restClient.withCoreAPI().getTag(tag); + + RestTagModel returnedTag = restClient.withCoreAPI().getTag(documentTag); restClient.assertStatusCodeIs(HttpStatus.OK); - returnedTag.assertThat().field("tag").is(tagValue.toLowerCase()) - .assertThat().field("id").is(tag.getId()); + returnedTag.assertThat().field("tag").is(documentTagValue.toLowerCase()) + .assertThat().field("id").is(documentTag.getId()); } - + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify user with Collaborator role gets tag using REST API and status code is OK (200)") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) public void userWithCollaboratorRoleIsAbleToGetTag() throws Exception { - String tagValue = RandomData.getRandomName("tag"); restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(tagValue); - - RestTagModel returnedTag = restClient.withCoreAPI().getTag(tag); + RestTagModel returnedTag = restClient.withCoreAPI().getTag(documentTag); restClient.assertStatusCodeIs(HttpStatus.OK); - returnedTag.assertThat().field("tag").is(tagValue.toLowerCase()); + returnedTag.assertThat().field("tag").is(documentTagValue.toLowerCase()); } - + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify user with Contributor role gets tag using REST API and status code is OK (200)") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) public void userWithContributorRoleIsAbleToGetTag() throws Exception { - String tagValue = RandomData.getRandomName("tag"); - restClient.authenticateUser(adminUserModel); - RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(tagValue); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - RestTagModel returnedTag = restClient.withCoreAPI().getTag(tag); + RestTagModel returnedTag = restClient.withCoreAPI().getTag(documentTag); restClient.assertStatusCodeIs(HttpStatus.OK); - returnedTag.assertThat().field("tag").is(tagValue.toLowerCase()); + returnedTag.assertThat().field("tag").is(documentTagValue.toLowerCase()); } @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify user with Consumer role gets tag using REST API and status code is OK (200)") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) public void userWithConsumerRoleIsAbleToGetTag() throws Exception { - String tagValue = RandomData.getRandomName("tag"); - restClient.authenticateUser(adminUserModel); - RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(tagValue); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - RestTagModel returnedTag = restClient.withCoreAPI().getTag(tag); + RestTagModel returnedTag = restClient.withCoreAPI().getTag(documentTag); restClient.assertStatusCodeIs(HttpStatus.OK); - returnedTag.assertThat().field("tag").is(tagValue.toLowerCase()); + returnedTag.assertThat().field("tag").is(documentTagValue.toLowerCase()); } @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Manager user gets status code 401 if authentication call fails") @@ -116,9 +77,11 @@ public class GetTagTests extends RestTest public void managerIsNotAbleToGetTagIfAuthenticationFails() throws Exception { UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); + String managerPassword = managerUser.getPassword(); dataUser.addUserToSite(managerUser, siteModel, UserRole.SiteManager); managerUser.setPassword("wrongPassword"); - restClient.authenticateUser(managerUser).withCoreAPI().getTag(tag); + restClient.authenticateUser(managerUser).withCoreAPI().getTag(documentTag); + managerUser.setPassword(managerPassword); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } @@ -128,9 +91,11 @@ public class GetTagTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) public void invalidTagIdTest() throws Exception { - tag.setId("random_tag_value"); - restClient.withCoreAPI().getTag(tag); + String tagId = documentTag.getId(); + documentTag.setId("random_tag_value"); + restClient.authenticateUser(adminUserModel).withCoreAPI().getTag(documentTag); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "random_tag_value")); + documentTag.setId(tagId); } @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, @@ -139,10 +104,10 @@ public class GetTagTests extends RestTest public void checkPropertiesFilterIsApplied() throws Exception { RestTagModel returnedTag = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withParams("properties=id,tag").withCoreAPI().getTag(tag); + .withParams("properties=id,tag").withCoreAPI().getTag(documentTag); restClient.assertStatusCodeIs(HttpStatus.OK); - returnedTag.assertThat().field("id").is(tag.getId()) - .assertThat().field("tag").is(tag.getTag().toLowerCase()) + returnedTag.assertThat().field("id").is(documentTag.getId()) + .assertThat().field("tag").is(documentTag.getTag().toLowerCase()) .assertThat().fieldsCount().is(2); } @@ -151,16 +116,10 @@ public class GetTagTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) public void getTagOfAFolder() throws Exception { - String tagValue = RandomData.getRandomName("tagFolder"); - FolderModel folder = dataContent.usingAdmin().usingSite(siteModel).createFolder(); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - RestTagModel tag = restClient.withCoreAPI().usingResource(folder).addTag(tagValue); - RestTagModel returnedTag = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().getTag(tag); + .withCoreAPI().getTag(folderTag); restClient.assertStatusCodeIs(HttpStatus.OK); - returnedTag.assertThat().field("tag").is(tagValue.toLowerCase()); + returnedTag.assertThat().field("tag").is(folderTagValue.toLowerCase()); } @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, @@ -169,7 +128,7 @@ public class GetTagTests extends RestTest public void checkDefaultErrorModelSchema() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withParams("skipCount=abc").withCoreAPI().getTag(tag); + .withParams("skipCount=abc").withCoreAPI().getTag(documentTag); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() .containsErrorKey(String.format(RestErrorModel.INVALID_SKIPCOUNT, "abc")) .containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "abc")) diff --git a/e2e-test/java/org/alfresco/rest/tags/GetTagsTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagsTests.java index 821d810bb..5dee733c6 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetTagsTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetTagsTests.java @@ -1,69 +1,26 @@ package org.alfresco.rest.tags; -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestTagModel; import org.alfresco.rest.model.RestTagModelsCollection; -import org.alfresco.utility.Utility; import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -public class GetTagsTests extends RestTest +public class GetTagsTests extends TagsDataPrep { - private UserModel adminUserModel; - private UserModel userModel; - private SiteModel siteModel; - private ListUserWithRoles usersWithRoles; - private RestTagModelsCollection returnedCollection; - - private String tagValue; - private String tagValue2; - private String tagValue3; - private FileModel document; - private FolderModel folder; - - @BeforeClass(alwaysRun=true) + + @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception { - adminUserModel = dataUser.getAdminUser(); - restClient.authenticateUser(adminUserModel); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); - document = dataContent.usingUser(adminUserModel).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - folder = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); - - returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); - int noTagsBefore = returnedCollection.getEntries().size(); - tagValue = RandomData.getRandomName("tag"); - tagValue2 = RandomData.getRandomName("tag"); - tagValue3 = RandomData.getRandomName("tag"); - restClient.withCoreAPI().usingResource(document).addTags(tagValue, tagValue2); - restClient.withCoreAPI().usingResource(folder).addTags(tagValue3); - - returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); - int noTagsAfter = returnedCollection.getEntries().size(); - int retry = 0; - while(noTagsAfter < noTagsBefore + 3 && retry < 30) - { - Utility.waitToLoopTime(2); - returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); - noTagsAfter = returnedCollection.getEntries().size(); - retry++; - } + init(); } - + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role gets tags using REST API and status code is OK (200)") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) public void getTagsWithManagerRole() throws Exception @@ -72,8 +29,8 @@ public class GetTagsTests extends RestTest returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); restClient.assertStatusCodeIs(HttpStatus.OK); returnedCollection.assertThat().entriesListIsNotEmpty() - .and().entriesListContains("tag", tagValue.toLowerCase()) - .and().entriesListContains("tag", tagValue2.toLowerCase()); + .and().entriesListContains("tag", documentTagValue.toLowerCase()) + .and().entriesListContains("tag", documentTagValue2.toLowerCase()); } @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify user with Collaborator role gets tags using REST API and status code is OK (200)") @@ -84,8 +41,8 @@ public class GetTagsTests extends RestTest returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); restClient.assertStatusCodeIs(HttpStatus.OK); returnedCollection.assertThat().entriesListIsNotEmpty() - .and().entriesListContains("tag", tagValue.toLowerCase()) - .and().entriesListContains("tag", tagValue2.toLowerCase()); + .and().entriesListContains("tag", documentTagValue.toLowerCase()) + .and().entriesListContains("tag", documentTagValue2.toLowerCase()); } @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify user with Contributor role gets tags using REST API and status code is OK (200)") @@ -96,8 +53,8 @@ public class GetTagsTests extends RestTest returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); restClient.assertStatusCodeIs(HttpStatus.OK); returnedCollection.assertThat().entriesListIsNotEmpty() - .and().entriesListContains("tag", tagValue.toLowerCase()) - .and().entriesListContains("tag", tagValue2.toLowerCase()); + .and().entriesListContains("tag", documentTagValue.toLowerCase()) + .and().entriesListContains("tag", documentTagValue2.toLowerCase()); } @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify user with Consumer role gets tags using REST API and status code is OK (200)") @@ -108,8 +65,8 @@ public class GetTagsTests extends RestTest returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); restClient.assertStatusCodeIs(HttpStatus.OK); returnedCollection.assertThat().entriesListIsNotEmpty() - .and().entriesListContains("tag", tagValue.toLowerCase()) - .and().entriesListContains("tag", tagValue2.toLowerCase()); + .and().entriesListContains("tag", documentTagValue.toLowerCase()) + .and().entriesListContains("tag", documentTagValue2.toLowerCase()); } @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Failed authentication get tags call returns status code 401 with Manager role") @@ -154,8 +111,8 @@ public class GetTagsTests extends RestTest returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); restClient.assertStatusCodeIs(HttpStatus.OK); returnedCollection.assertThat().entriesListIsNotEmpty() - .and().entriesListContains("tag", tagValue.toLowerCase()) - .and().entriesListContains("tag", tagValue2.toLowerCase()); + .and().entriesListContains("tag", documentTagValue.toLowerCase()) + .and().entriesListContains("tag", documentTagValue2.toLowerCase()); } @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, @@ -167,7 +124,7 @@ public class GetTagsTests extends RestTest returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); restClient.assertStatusCodeIs(HttpStatus.OK); returnedCollection.assertThat().entriesListIsNotEmpty() - .and().entriesListContains("tag", tagValue3.toLowerCase()); + .and().entriesListContains("tag", folderTagValue.toLowerCase()); } @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, @@ -180,8 +137,8 @@ public class GetTagsTests extends RestTest .withParams("maxItems=5000&properties=tag").withCoreAPI().getTags(); restClient.assertStatusCodeIs(HttpStatus.OK); returnedCollection.assertThat().entriesListIsNotEmpty() - .and().entriesListContains("tag", tagValue.toLowerCase()) - .and().entriesListContains("tag", tagValue2.toLowerCase()) + .and().entriesListContains("tag", documentTagValue.toLowerCase()) + .and().entriesListContains("tag", documentTagValue2.toLowerCase()) .and().entriesListDoesNotContain("id"); } diff --git a/e2e-test/java/org/alfresco/rest/tags/TagsDataPrep.java b/e2e-test/java/org/alfresco/rest/tags/TagsDataPrep.java new file mode 100644 index 000000000..565f1985f --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/tags/TagsDataPrep.java @@ -0,0 +1,67 @@ +package org.alfresco.rest.tags; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestTagModel; +import org.alfresco.rest.model.RestTagModelsCollection; +import org.alfresco.utility.Utility; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.data.RandomData; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; + +public class TagsDataPrep extends RestTest +{ + + protected static UserModel adminUserModel; + protected static UserModel userModel; + protected static ListUserWithRoles usersWithRoles; + protected static SiteModel siteModel; + protected static FileModel document; + protected static FolderModel folder; + protected static String documentTagValue, documentTagValue2, folderTagValue; + protected static RestTagModel documentTag, documentTag2, folderTag, returnedModel; + protected static RestTagModelsCollection returnedCollection; + private static boolean isInitialized = false; + + public void init() throws Exception + { + if(!isInitialized) + { + isInitialized = true; + initialization(); + } + } + + public void initialization() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + //Create public site + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + usersWithRoles = dataUser.usingAdmin().addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + document = dataContent.usingUser(adminUserModel).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + folder = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); + + documentTagValue = RandomData.getRandomName("tag"); + documentTagValue2 = RandomData.getRandomName("tag"); + folderTagValue = RandomData.getRandomName("tag"); + + restClient.authenticateUser(adminUserModel); + documentTag = restClient.withCoreAPI().usingResource(document).addTag(documentTagValue); + documentTag2 = restClient.withCoreAPI().usingResource(document).addTag(documentTagValue2); + folderTag = restClient.withCoreAPI().usingResource(folder).addTag(folderTagValue); + + // Allow indexing to complete. + Utility.sleep(1000, 35000, () -> + { + returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); + returnedCollection.assertThat().entriesListContains("tag", documentTagValue.toLowerCase()) + .and().entriesListContains("tag", documentTagValue2.toLowerCase()) + .and().entriesListContains("tag", folderTagValue.toLowerCase()); + }); + + } +} diff --git a/e2e-test/java/org/alfresco/rest/tags/UpdateTagTests.java b/e2e-test/java/org/alfresco/rest/tags/UpdateTagTests.java index cd5da20b1..923ee714e 100644 --- a/e2e-test/java/org/alfresco/rest/tags/UpdateTagTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/UpdateTagTests.java @@ -1,15 +1,10 @@ package org.alfresco.rest.tags; -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestTagModel; import org.alfresco.utility.Utility; import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; @@ -24,23 +19,15 @@ import org.testng.annotations.Test; /** * Created by Claudia Agache on 10/4/2016. */ -public class UpdateTagTests extends RestTest +public class UpdateTagTests extends TagsDataPrep { - private UserModel adminUserModel; - private FileModel document; - private SiteModel siteModel; private RestTagModel oldTag; - private DataUser.ListUserWithRoles usersWithRoles; private String randomTag = ""; - private RestTagModel returnedModel; @BeforeClass(alwaysRun=true) public void dataPreparation() throws Exception { - adminUserModel = dataUser.getAdminUser(); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + init(); } @BeforeMethod(alwaysRun=true) @@ -112,9 +99,11 @@ public class UpdateTagTests extends RestTest public void userIsNotAbleToUpdateTagIfAuthenticationFails() throws Exception { UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); + String managerPassword = siteManager.getPassword(); siteManager.setPassword("wrongPassword"); restClient.authenticateUser(siteManager); restClient.withCoreAPI().usingTag(oldTag).update(randomTag); + siteManager.setPassword(managerPassword); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } diff --git a/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagTests.java b/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagTests.java index af37eb0b0..288416e03 100644 --- a/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagTests.java @@ -1,17 +1,15 @@ package org.alfresco.rest.tags.nodes; import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestCommentModel; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestTagModel; import org.alfresco.rest.model.RestTagModelsCollection; +import org.alfresco.rest.tags.TagsDataPrep; import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.RandomData; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; @@ -25,12 +23,8 @@ import org.testng.annotations.Test; /** * Created by Claudia Agache on 10/3/2016. */ -public class AddTagTests extends RestTest +public class AddTagTests extends TagsDataPrep { - private UserModel adminUserModel, userModel; - private FileModel document; - private SiteModel siteModel; - private DataUser.ListUserWithRoles usersWithRoles; private String tagValue; private RestTagModel returnedModel; private RestCommentModel returnedModelComment; @@ -39,11 +33,7 @@ public class AddTagTests extends RestTest @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception { - adminUserModel = dataUser.getAdminUser(); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + init(); } @BeforeMethod(alwaysRun = true) @@ -129,11 +119,13 @@ public class AddTagTests extends RestTest public void userIsNotAbleToAddTagIfAuthenticationFails() throws Exception { UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); + String managerPassword = siteManager.getPassword(); siteManager.setPassword("wrongPassword"); restClient.authenticateUser(siteManager); restClient.withCoreAPI().usingResource(document).addTag("tagUnauthorized"); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + siteManager.setPassword(managerPassword); } @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, @@ -161,14 +153,14 @@ public class AddTagTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) public void addTagToInexistentNode() throws Exception { - FileModel document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - + String oldNodeRef = document.getNodeRef(); String nodeRef = RandomStringUtils.randomAlphanumeric(10); document.setNodeRef(nodeRef); restClient.authenticateUser(adminUserModel); returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, nodeRef)); + document.setNodeRef(oldNodeRef); } @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, @@ -189,7 +181,6 @@ public class AddTagTests extends RestTest public void addTagToATaggedFile() throws Exception { restClient.authenticateUser(adminUserModel); - document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue); restClient.assertStatusCodeIs(HttpStatus.CREATED); diff --git a/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagsTests.java b/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagsTests.java index 313bc3747..b1ebd8419 100644 --- a/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagsTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagsTests.java @@ -1,14 +1,12 @@ package org.alfresco.rest.tags.nodes; import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestTagModelsCollection; +import org.alfresco.rest.tags.TagsDataPrep; import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.RandomData; import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; @@ -21,23 +19,16 @@ import org.testng.annotations.Test; /** * Created by Claudia Agache on 10/7/2016. */ -public class AddTagsTests extends RestTest +public class AddTagsTests extends TagsDataPrep { - private UserModel adminUserModel, userModel; - private FileModel document, contributorDoc; - private SiteModel siteModel; - private DataUser.ListUserWithRoles usersWithRoles; + private FileModel contributorDoc; private String tag1, tag2; private RestTagModelsCollection returnedCollection; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception { - adminUserModel = dataUser.getAdminUser(); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + init(); } @BeforeMethod(alwaysRun = true) @@ -123,9 +114,11 @@ public class AddTagsTests extends RestTest public void userIsNotAbleToAddTagsIfAuthenticationFails() throws Exception { UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); + String managerPassword = siteManager.getPassword(); siteManager.setPassword("wrongPassword"); restClient.authenticateUser(siteManager).withCoreAPI().usingResource(document).addTags(tag1, tag2); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + siteManager.setPassword(managerPassword); } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/tags/nodes/DeleteTagTests.java b/e2e-test/java/org/alfresco/rest/tags/nodes/DeleteTagTests.java index 34ea4fd51..d90f289b7 100644 --- a/e2e-test/java/org/alfresco/rest/tags/nodes/DeleteTagTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/nodes/DeleteTagTests.java @@ -1,13 +1,15 @@ package org.alfresco.rest.tags.nodes; import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestTagModel; +import org.alfresco.rest.tags.TagsDataPrep; import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.*; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; @@ -19,21 +21,15 @@ import org.testng.annotations.Test; /** * Created by Claudia Agache on 10/4/2016. */ -public class DeleteTagTests extends RestTest +public class DeleteTagTests extends TagsDataPrep { - private UserModel adminUserModel, userModel; - private SiteModel siteModel; - private DataUser.ListUserWithRoles usersWithRoles; private RestTagModel tag; - private FileModel document, contributorDoc; + private FileModel contributorDoc; @BeforeClass(alwaysRun=true) public void dataPreparation() throws Exception { - adminUserModel = dataUser.getAdminUser(); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + init(); } @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, @@ -126,11 +122,13 @@ public class DeleteTagTests extends RestTest tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); + String managerPassword = siteManager.getPassword(); siteManager.setPassword("wrongPassword"); restClient.authenticateUser(siteManager); restClient.withCoreAPI().usingResource(document).deleteTag(tag); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + siteManager.setPassword(managerPassword); } @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, diff --git a/e2e-test/java/org/alfresco/rest/tags/nodes/GetNodeTagsTests.java b/e2e-test/java/org/alfresco/rest/tags/nodes/GetNodeTagsTests.java index 7183d8f08..f5a15f675 100644 --- a/e2e-test/java/org/alfresco/rest/tags/nodes/GetNodeTagsTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/nodes/GetNodeTagsTests.java @@ -1,12 +1,9 @@ package org.alfresco.rest.tags.nodes; import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestTagModelsCollection; +import org.alfresco.rest.tags.TagsDataPrep; import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.data.RandomData; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; @@ -19,32 +16,17 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -public class GetNodeTagsTests extends RestTest +public class GetNodeTagsTests extends TagsDataPrep { - private UserModel adminUserModel; - private SiteModel siteModel; - private ListUserWithRoles usersWithRoles; - private FileModel document; - private RestTagModelsCollection returnedCollection; private String tagValue; private String tagValue2; @BeforeClass(alwaysRun=true) public void dataPreparation() throws Exception { - adminUserModel = dataUser.getAdminUser(); - restClient.authenticateUser(adminUserModel); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, - UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); - document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - - tagValue = RandomData.getRandomName("tag"); - restClient.withCoreAPI().usingResource(document).addTag(tagValue); - - tagValue2 = RandomData.getRandomName("tag"); - restClient.withCoreAPI().usingResource(document).addTag(tagValue2); + init(); + tagValue = documentTagValue; + tagValue2 = documentTagValue2; } @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, @@ -53,7 +35,7 @@ public class GetNodeTagsTests extends RestTest public void siteManagerIsAbleToRetrieveNodeTags() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - + returnedCollection = restClient.withCoreAPI().usingResource(document).getNodeTags(); restClient.assertStatusCodeIs(HttpStatus.OK); returnedCollection.assertThat() @@ -67,7 +49,7 @@ public class GetNodeTagsTests extends RestTest public void siteCollaboratorIsAbleToRetrieveNodeTags() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - + returnedCollection = restClient.withCoreAPI().usingResource(document).getNodeTags(); restClient.assertStatusCodeIs(HttpStatus.OK); returnedCollection.assertThat() @@ -81,7 +63,7 @@ public class GetNodeTagsTests extends RestTest public void siteContributorIsAbleToRetrieveNodeTags() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - + returnedCollection = restClient.withCoreAPI().usingResource(document).getNodeTags(); restClient.assertStatusCodeIs(HttpStatus.OK); returnedCollection.assertThat() @@ -95,7 +77,7 @@ public class GetNodeTagsTests extends RestTest public void siteConsumerIsAbleToRetrieveNodeTags() throws Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - + returnedCollection = restClient.withCoreAPI().usingResource(document).getNodeTags(); restClient.assertStatusCodeIs(HttpStatus.OK); returnedCollection.assertThat() @@ -157,12 +139,10 @@ public class GetNodeTagsTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION}) public void userWithoutPermissionsTest() throws Exception { - SiteModel site = dataSite.usingUser(adminUserModel).createModeratedRandomSite(); - FileModel document = dataContent.usingSite(site).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - String tagValue = RandomData.getRandomName("tag"); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).addTag(tagValue); + SiteModel moderatedSite = dataSite.usingUser(adminUserModel).createModeratedRandomSite(); + FileModel moderatedDocument = dataContent.usingSite(moderatedSite).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - restClient.authenticateUser(dataUser.createRandomTestUser()).withCoreAPI().usingResource(document).getNodeTags(); + restClient.authenticateUser(dataUser.createRandomTestUser()).withCoreAPI().usingResource(moderatedDocument).getNodeTags(); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) @@ -174,11 +154,11 @@ public class GetNodeTagsTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION}) public void nonexistentNodeTest() throws Exception { - FileModel document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + FileModel badDocument = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); String nodeRef = RandomStringUtils.randomAlphanumeric(10); - document.setNodeRef(nodeRef); + badDocument.setNodeRef(nodeRef); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getNodeTags(); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(badDocument).getNodeTags(); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, nodeRef)); } @@ -187,10 +167,10 @@ public class GetNodeTagsTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION}) public void emptyNodeIdTest() throws Exception { - FileModel document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - document.setNodeRef(""); + FileModel badDocument = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + badDocument.setNodeRef(""); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getNodeTags(); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(badDocument).getNodeTags(); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); } @@ -247,8 +227,7 @@ public class GetNodeTagsTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); returnedCollection.getPagination().assertThat().field("maxItems").is(100) .and().field("hasMoreItems").is("false") - .and().field("totalItems").is(2) - .and().field("count").is("1"); + .and().field("count").isGreaterThan(1); } @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, @@ -261,7 +240,6 @@ public class GetNodeTagsTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); returnedCollection.getPagination().assertThat().field("maxItems").is(1) .and().field("hasMoreItems").is("true") - .and().field("totalItems").is("2") .and().field("count").is("1") .and().field("skipCount").is("0"); } @@ -333,7 +311,6 @@ public class GetNodeTagsTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); returnedCollection.getPagination().assertThat().field("maxItems").is(100) .and().field("hasMoreItems").is("false") - .and().field("totalItems").is("2") .and().field("count").is("0") .and().field("skipCount").is("10000"); returnedCollection.assertThat().entriesListCountIs(0); From 048f4bd8182ddc90f0696c05f259975cdef33980 Mon Sep 17 00:00:00 2001 From: Andrei Forascu Date: Mon, 27 Nov 2017 19:04:39 +0200 Subject: [PATCH 1275/1491] REPO-2948 - S3 IA: Update AWS Quick Start and include S3 IA configuration: - fixed a test that was failing intermittently on AWS QS build --- .../nodes/NodesContentAndVersioningTests.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/nodes/NodesContentAndVersioningTests.java b/e2e-test/java/org/alfresco/rest/nodes/NodesContentAndVersioningTests.java index d5f433dd6..9618e8e10 100644 --- a/e2e-test/java/org/alfresco/rest/nodes/NodesContentAndVersioningTests.java +++ b/e2e-test/java/org/alfresco/rest/nodes/NodesContentAndVersioningTests.java @@ -212,12 +212,17 @@ public class NodesContentAndVersioningTests extends RestTest assertEquals(version.getName(),version11.getName()); STEP("5. Retrieve version 2.0 content GET /nodes/{nodeId}/versions/{versionId}/content"); - RestResponse versionContent = restClient.withCoreAPI().usingNode(file2).getVersionContent("2.0"); - restClient.assertStatusCodeIs(HttpStatus.OK); //verify the content is the same as the uploaded file and check in headers for Content-Disposition to validate the download as attachment and fileName. - assertEquals("Sample text.\n", versionContent.getResponse().body().asString()); - restClient.assertHeaderValueContains("Content-Disposition", "attachment"); - restClient.assertHeaderValueContains("Content-Disposition", String.format("filename=\"%s\"", file2.getName())); + Utility.sleep(500, 10000, () -> + { + RestResponse versionContent = restClient.withCoreAPI().usingNode(file2).getVersionContent("2.0"); + restClient.assertStatusCodeIs(HttpStatus.OK); + + assertEquals("Sample text.\n", versionContent.getResponse().body().asString()); + restClient.assertHeaderValueContains("Content-Disposition", "attachment"); + restClient.assertHeaderValueContains("Content-Disposition", String.format("filename=\"%s\"", file2.getName())); + }); + } @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY }) From 1b77baac54c7a8b98c8c54794351ff1ef5092b20 Mon Sep 17 00:00:00 2001 From: Andreea Nechifor Date: Tue, 28 Nov 2017 10:42:18 +0200 Subject: [PATCH 1276/1491] Create branch REPO-1868 Retrieve list of publicly available actions for a node --- .../nodes/NodesActionDefinitionTests.java | 87 +++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/nodes/NodesActionDefinitionTests.java diff --git a/e2e-test/java/org/alfresco/rest/nodes/NodesActionDefinitionTests.java b/e2e-test/java/org/alfresco/rest/nodes/NodesActionDefinitionTests.java new file mode 100644 index 000000000..94f82db31 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/nodes/NodesActionDefinitionTests.java @@ -0,0 +1,87 @@ +package org.alfresco.rest.nodes; + + +import static org.testng.Assert.assertFalse; + +import org.alfresco.rest.RestTest; + +import org.alfresco.rest.model.RestActionDefinitionModelsCollection; +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.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.Test; + +public class NodesActionDefinitionTests extends RestTest +{ + + + @TestRail(section = { TestGroup.REST_API,TestGroup.NODES }, executionType = ExecutionType.SANITY, + description = "Verify actions") + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY}) + public void testActionDefinition() throws Exception + { + restClient.authenticateUser(dataContent.getAdminUser()); + + /* + * Create the following file structure for preconditions : + * - sourceFolder + * - file + */ + NodesBuilder nodesBuilder = restClient.withCoreAPI().usingNode(ContentModel.my()).defineNodes(); + NodeDetail sourceFolder = nodesBuilder.folder("sourceFolder"); + NodeDetail file = sourceFolder.file("file"); + ContentModel fileActionDefinitions = new ContentModel(); + fileActionDefinitions.setNodeRef(file.getId()); + + RestActionDefinitionModelsCollection restActionDefinitions = restClient.withParams("autoRename=true").withCoreAPI().usingNode(fileActionDefinitions).getActionDefinitions(); + restClient.assertStatusCodeIs(HttpStatus.OK); + assertFalse(restActionDefinitions.isEmpty()); + restActionDefinitions.assertThat().entriesListContains("name", "copy"); + restActionDefinitions.assertThat().entriesListContains("name", "move"); + restActionDefinitions.assertThat().entriesListContains("name", "check-out"); + restActionDefinitions.assertThat().entriesListContains("name", "check-in"); + + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NODES }, executionType = ExecutionType.SANITY, + description = "Verify actions negative request") + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY}) + public void testActionDefinitionNegative() throws Exception{ + + NodesBuilder nodesBuilder = restClient.withCoreAPI().usingNode(ContentModel.my()).defineNodes(); + NodeDetail sourceFolder = nodesBuilder.folder("sourceFolder"); + ContentModel validNode = new ContentModel(); + validNode.setNodeRef(sourceFolder.getId()); + + // Non-existent node ID + { + ContentModel fakeNode = new ContentModel(); + fakeNode.setNodeRef("750a2867-ecfa-478c-8343-fa0e39d27be3"); + restClient.authenticateUser(dataContent.getAdminUser()).withCoreAPI().usingNode(fakeNode).getActionDefinitions(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } + + // Badly formed request -> 400 + { + restClient.authenticateUser(dataContent.getAdminUser()).withParams("skipCount=-1").withCoreAPI().usingNode(validNode) + .getActionDefinitions(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + + } + + // Unauthorized -> 401 + { + + UserModel userUnauthorized = new UserModel("invalid-user", "invalid-pasword"); + restClient.authenticateUser(userUnauthorized).withCoreAPI().usingNode(validNode).getActionDefinitions(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + + } + } + +} From 3212214024827fddc74cadaf41824c22df350198 Mon Sep 17 00:00:00 2001 From: Andrei Forascu Date: Tue, 28 Nov 2017 11:35:14 +0200 Subject: [PATCH 1277/1491] REPO-2948 - S3 IA: Update AWS Quick Start and include S3 IA configuration: - increased wait time for tests to run on AWS QS --- .../alfresco/rest/nodes/NodesContentAndVersioningTests.java | 3 ++- e2e-test/java/org/alfresco/rest/tags/TagsDataPrep.java | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/nodes/NodesContentAndVersioningTests.java b/e2e-test/java/org/alfresco/rest/nodes/NodesContentAndVersioningTests.java index 9618e8e10..61cda4ec6 100644 --- a/e2e-test/java/org/alfresco/rest/nodes/NodesContentAndVersioningTests.java +++ b/e2e-test/java/org/alfresco/rest/nodes/NodesContentAndVersioningTests.java @@ -213,7 +213,8 @@ public class NodesContentAndVersioningTests extends RestTest STEP("5. Retrieve version 2.0 content GET /nodes/{nodeId}/versions/{versionId}/content"); //verify the content is the same as the uploaded file and check in headers for Content-Disposition to validate the download as attachment and fileName. - Utility.sleep(500, 10000, () -> + //wait for content to be picked up on AWS QS stacks + Utility.sleep(1000, 60000, () -> { RestResponse versionContent = restClient.withCoreAPI().usingNode(file2).getVersionContent("2.0"); restClient.assertStatusCodeIs(HttpStatus.OK); diff --git a/e2e-test/java/org/alfresco/rest/tags/TagsDataPrep.java b/e2e-test/java/org/alfresco/rest/tags/TagsDataPrep.java index 565f1985f..c5e2e49a1 100644 --- a/e2e-test/java/org/alfresco/rest/tags/TagsDataPrep.java +++ b/e2e-test/java/org/alfresco/rest/tags/TagsDataPrep.java @@ -55,7 +55,7 @@ public class TagsDataPrep extends RestTest folderTag = restClient.withCoreAPI().usingResource(folder).addTag(folderTagValue); // Allow indexing to complete. - Utility.sleep(1000, 35000, () -> + Utility.sleep(1000, 60000, () -> { returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); returnedCollection.assertThat().entriesListContains("tag", documentTagValue.toLowerCase()) From f0a9b001b00b52166275b202e8254b44f18a31e5 Mon Sep 17 00:00:00 2001 From: Andreea Nechifor Date: Tue, 28 Nov 2017 13:38:15 +0200 Subject: [PATCH 1278/1491] REPO-1868: Retrieve list of publicly available actions for a node --- .../org/alfresco/rest/nodes/NodesActionDefinitionTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/nodes/NodesActionDefinitionTests.java b/e2e-test/java/org/alfresco/rest/nodes/NodesActionDefinitionTests.java index 94f82db31..63ed0bd54 100644 --- a/e2e-test/java/org/alfresco/rest/nodes/NodesActionDefinitionTests.java +++ b/e2e-test/java/org/alfresco/rest/nodes/NodesActionDefinitionTests.java @@ -38,7 +38,7 @@ public class NodesActionDefinitionTests extends RestTest ContentModel fileActionDefinitions = new ContentModel(); fileActionDefinitions.setNodeRef(file.getId()); - RestActionDefinitionModelsCollection restActionDefinitions = restClient.withParams("autoRename=true").withCoreAPI().usingNode(fileActionDefinitions).getActionDefinitions(); + RestActionDefinitionModelsCollection restActionDefinitions = restClient.withCoreAPI().usingNode(fileActionDefinitions).getActionDefinitions(); restClient.assertStatusCodeIs(HttpStatus.OK); assertFalse(restActionDefinitions.isEmpty()); restActionDefinitions.assertThat().entriesListContains("name", "copy"); From 35dab3d49f95bc38ae173ff7229d790e32a91d40 Mon Sep 17 00:00:00 2001 From: Andrei Forascu Date: Wed, 29 Nov 2017 11:24:08 +0200 Subject: [PATCH 1279/1491] REPO-2948 - S3 IA: Update AWS Quick Start and include S3 IA configuration: - added AWS QS sanity suite with only content related tests - modified negative action definition tests to be included in Regression test suite --- .../org/alfresco/rest/nodes/NodesActionDefinitionTests.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/nodes/NodesActionDefinitionTests.java b/e2e-test/java/org/alfresco/rest/nodes/NodesActionDefinitionTests.java index 63ed0bd54..596ebf72c 100644 --- a/e2e-test/java/org/alfresco/rest/nodes/NodesActionDefinitionTests.java +++ b/e2e-test/java/org/alfresco/rest/nodes/NodesActionDefinitionTests.java @@ -48,9 +48,9 @@ public class NodesActionDefinitionTests extends RestTest } - @TestRail(section = { TestGroup.REST_API,TestGroup.NODES }, executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API,TestGroup.NODES }, executionType = ExecutionType.REGRESSION, description = "Verify actions negative request") - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY}) + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION}) public void testActionDefinitionNegative() throws Exception{ NodesBuilder nodesBuilder = restClient.withCoreAPI().usingNode(ContentModel.my()).defineNodes(); From b364a0ebff1b3d775d6550021edb29c3533218f7 Mon Sep 17 00:00:00 2001 From: Andrei Forascu Date: Wed, 29 Nov 2017 16:18:21 +0200 Subject: [PATCH 1280/1491] REPO-2267 - RestAPI: Implement tests in TAS project for 'Shared-links' RestApi endpoint - part 1: - added a test for GET /shared-links endpoint - moved tests with includePath to regression category --- .../rest/sharedlinks/SharedLinksSanityTests.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/sharedlinks/SharedLinksSanityTests.java b/e2e-test/java/org/alfresco/rest/sharedlinks/SharedLinksSanityTests.java index 6c7b2d708..c98de5d47 100644 --- a/e2e-test/java/org/alfresco/rest/sharedlinks/SharedLinksSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sharedlinks/SharedLinksSanityTests.java @@ -3,6 +3,7 @@ package org.alfresco.rest.sharedlinks; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestSharedLinksModel; +import org.alfresco.rest.model.RestSharedLinksModelCollection; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; @@ -41,6 +42,8 @@ public class SharedLinksSanityTests extends RestTest private RestSharedLinksModel sharedLink4; private RestSharedLinksModel sharedLink5; + private RestSharedLinksModelCollection sharedLinksCollection; + private String expiryDate = "2027-03-23T23:00:00.000+0000"; @BeforeClass(alwaysRun = true) @@ -65,7 +68,7 @@ public class SharedLinksSanityTests extends RestTest file5 = dataContent.usingUser(adminUser).usingResource(folder1).createContent(DocumentType.TEXT_PLAIN); } - @TestRail(section = { TestGroup.REST_API, TestGroup.SHAREDLINKS }, executionType = ExecutionType.SANITY, description = "Verify create sharedLinks with and without Path") + @TestRail(section = { TestGroup.REST_API, TestGroup.SHAREDLINKS }, executionType = ExecutionType.SANITY, description = "Verify create sharedLinks without Path") @Test(groups = { TestGroup.REST_API, TestGroup.SANITY }) public void testCreateAndGetSharedLinks() throws Exception { @@ -89,6 +92,16 @@ public class SharedLinksSanityTests extends RestTest restClient.onResponse().assertThat().body("entry.id", org.hamcrest.Matchers.equalTo(sharedLink1.getId())); restClient.onResponse().assertThat().body("entry.path", org.hamcrest.Matchers.nullValue()); + // Get all shared-links + sharedLinksCollection = restClient.withCoreAPI().usingSharedLinks().getSharedLinks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + sharedLinksCollection.assertThat().entriesListIsNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.SHAREDLINKS }, executionType = ExecutionType.REGRESSION, description = "Verify create sharedLinks with Path") + @Test(groups = { TestGroup.REST_API, TestGroup.REGRESSION }) + public void testCreateAndGetSharedLinksWithInclude() throws Exception + { // Post with includePath sharedLink2 = restClient.authenticateUser(testUser1).withCoreAPI().includePath().usingSharedLinks().createSharedLink(file2); restClient.assertStatusCodeIs(HttpStatus.CREATED); From d3c5b5026877ca63f72f21efdafe27e35b150608 Mon Sep 17 00:00:00 2001 From: Matt Ward Date: Fri, 1 Dec 2017 15:35:15 +0000 Subject: [PATCH 1281/1491] REPO-1308: added simple 'GET /action-definitions' sanity test Added an Actions API representation and an ActionsTests class containing a simple sanity test. --- .../alfresco/rest/actions/ActionsTests.java | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/actions/ActionsTests.java diff --git a/e2e-test/java/org/alfresco/rest/actions/ActionsTests.java b/e2e-test/java/org/alfresco/rest/actions/ActionsTests.java new file mode 100644 index 000000000..577f30b2e --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/actions/ActionsTests.java @@ -0,0 +1,31 @@ +package org.alfresco.rest.actions; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestActionDefinitionModelsCollection; +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; + +import static org.testng.Assert.assertFalse; + +public class ActionsTests extends RestTest +{ + // TODO: TestGroup.ACTIONS not TestGroup.NODES + @TestRail(section = { TestGroup.REST_API,TestGroup.NODES }, executionType = ExecutionType.SANITY, + description = "Verify actions") + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY}) + public void testActionDefinitions() throws Exception + { + restClient.authenticateUser(dataContent.getAdminUser()); + + RestActionDefinitionModelsCollection restActionDefinitions = restClient.withCoreAPI().usingActions().listActionDefinitions(); + restClient.assertStatusCodeIs(HttpStatus.OK); + assertFalse(restActionDefinitions.isEmpty()); + restActionDefinitions.assertThat().entriesListContains("name", "copy"); + restActionDefinitions.assertThat().entriesListContains("name", "move"); + restActionDefinitions.assertThat().entriesListContains("name", "check-out"); + restActionDefinitions.assertThat().entriesListContains("name", "check-in"); + } +} From d7efa10b654387facb2d630c0dbcb01de6045cb5 Mon Sep 17 00:00:00 2001 From: Matt Ward Date: Fri, 1 Dec 2017 16:47:02 +0000 Subject: [PATCH 1282/1491] REPO-1308: added 'GET /action-definitions' error status checks Added a couple of error code checks: 400 (bad request) and 401 (unauthorised) - the latter actually fails and raises the question of whether the actions API implmentation or the TAS test framework are wrong. Committing to capture the test code, but will sort it out one way or another. --- .../alfresco/rest/actions/ActionsTests.java | 35 ++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/actions/ActionsTests.java b/e2e-test/java/org/alfresco/rest/actions/ActionsTests.java index 577f30b2e..a4523de61 100644 --- a/e2e-test/java/org/alfresco/rest/actions/ActionsTests.java +++ b/e2e-test/java/org/alfresco/rest/actions/ActionsTests.java @@ -3,6 +3,7 @@ package org.alfresco.rest.actions; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestActionDefinitionModelsCollection; 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; @@ -20,7 +21,11 @@ public class ActionsTests extends RestTest { restClient.authenticateUser(dataContent.getAdminUser()); - RestActionDefinitionModelsCollection restActionDefinitions = restClient.withCoreAPI().usingActions().listActionDefinitions(); + RestActionDefinitionModelsCollection restActionDefinitions = restClient. + withCoreAPI(). + usingActions(). + listActionDefinitions(); + restClient.assertStatusCodeIs(HttpStatus.OK); assertFalse(restActionDefinitions.isEmpty()); restActionDefinitions.assertThat().entriesListContains("name", "copy"); @@ -28,4 +33,32 @@ public class ActionsTests extends RestTest restActionDefinitions.assertThat().entriesListContains("name", "check-out"); restActionDefinitions.assertThat().entriesListContains("name", "check-in"); } + + // TODO: TestGroup.ACTIONS not TestGroup.NODES + @TestRail(section = { TestGroup.REST_API,TestGroup.NODES }, executionType = ExecutionType.REGRESSION, + description = "Verify actions error conditions") + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION}) + public void testActionDefinitionsNegative() throws Exception{ + // Badly formed request -> 400 + { + restClient.authenticateUser(dataContent.getAdminUser()). + // invalid skipCount + withParams("skipCount=-1"). + withCoreAPI(). + usingActions(). + listActionDefinitions(); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + + } + + // Unauthorized -> 401 + { + + UserModel userUnauthorized = new UserModel("invalid-user", "invalid-pasword"); + restClient.authenticateUser(userUnauthorized).withCoreAPI().usingActions().listActionDefinitions(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + + } + } } From 6f7bfa41ad88235b8f0022f523815d472afbbc20 Mon Sep 17 00:00:00 2001 From: Andrei Forascu Date: Mon, 4 Dec 2017 10:38:55 +0200 Subject: [PATCH 1283/1491] REPO-2267 - RestAPI: Implement tests in TAS project for 'Shared-links' RestApi endpoint - part 1: - check that the created shared-link is displayed - added a retry / wait clause to allow indexing to finish --- .../rest/sharedlinks/SharedLinksSanityTests.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/sharedlinks/SharedLinksSanityTests.java b/e2e-test/java/org/alfresco/rest/sharedlinks/SharedLinksSanityTests.java index c98de5d47..684fe70f7 100644 --- a/e2e-test/java/org/alfresco/rest/sharedlinks/SharedLinksSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sharedlinks/SharedLinksSanityTests.java @@ -4,6 +4,7 @@ import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestSharedLinksModel; import org.alfresco.rest.model.RestSharedLinksModelCollection; +import org.alfresco.utility.Utility; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; @@ -92,10 +93,17 @@ public class SharedLinksSanityTests extends RestTest restClient.onResponse().assertThat().body("entry.id", org.hamcrest.Matchers.equalTo(sharedLink1.getId())); restClient.onResponse().assertThat().body("entry.path", org.hamcrest.Matchers.nullValue()); - // Get all shared-links - sharedLinksCollection = restClient.withCoreAPI().usingSharedLinks().getSharedLinks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - sharedLinksCollection.assertThat().entriesListIsNotEmpty(); + /* + * Get all shared-links while allowing indexing to complete and check + * that the created shared-link is displayed + */ + Utility.sleep(1000, 30000, () -> + { + sharedLinksCollection = restClient.withCoreAPI().usingSharedLinks().getSharedLinks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + sharedLinksCollection.assertThat().entriesListContains("id", sharedLink1.getId()).and() + .entriesListContains("nodeId", sharedLink1.getNodeId()); + }); } @TestRail(section = { TestGroup.REST_API, TestGroup.SHAREDLINKS }, executionType = ExecutionType.REGRESSION, description = "Verify create sharedLinks with Path") From d80e953cf54afd1fe45cb7b7483f5c07d8dfacb2 Mon Sep 17 00:00:00 2001 From: Matt Ward Date: Mon, 4 Dec 2017 11:56:07 +0000 Subject: [PATCH 1284/1491] REPO-1308: fix 401 response test The listActions API wrapper was expecting JSON to be present, but for a 401 it is not. --- .../org/alfresco/rest/actions/ActionsTests.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/actions/ActionsTests.java b/e2e-test/java/org/alfresco/rest/actions/ActionsTests.java index a4523de61..8e69e9179 100644 --- a/e2e-test/java/org/alfresco/rest/actions/ActionsTests.java +++ b/e2e-test/java/org/alfresco/rest/actions/ActionsTests.java @@ -1,6 +1,7 @@ package org.alfresco.rest.actions; import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.EmptyJsonResponseException; import org.alfresco.rest.model.RestActionDefinitionModelsCollection; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; @@ -9,6 +10,7 @@ import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; import org.testng.annotations.Test; +import static junit.framework.TestCase.fail; import static org.testng.Assert.assertFalse; public class ActionsTests extends RestTest @@ -56,9 +58,17 @@ public class ActionsTests extends RestTest { UserModel userUnauthorized = new UserModel("invalid-user", "invalid-pasword"); - restClient.authenticateUser(userUnauthorized).withCoreAPI().usingActions().listActionDefinitions(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); - + try + { + restClient.authenticateUser(userUnauthorized).withCoreAPI().usingActions().listActionDefinitions(); + fail("Expected an empty JSON response exception"); + } + catch (EmptyJsonResponseException e) + { + // Since there is no JSON for a 401, the processModels directive + // will throw the EmptyJsonResponseException + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + } } } } From aca6d62548690d6192ce7ee7f15b498ae5c45976 Mon Sep 17 00:00:00 2001 From: Matt Ward Date: Mon, 4 Dec 2017 13:02:30 +0000 Subject: [PATCH 1285/1491] REPO-1308: use TestGroup.ACTIONS instead of TestGroup.NODES --- .../java/org/alfresco/rest/actions/ActionsTests.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/actions/ActionsTests.java b/e2e-test/java/org/alfresco/rest/actions/ActionsTests.java index 8e69e9179..0905f0eb5 100644 --- a/e2e-test/java/org/alfresco/rest/actions/ActionsTests.java +++ b/e2e-test/java/org/alfresco/rest/actions/ActionsTests.java @@ -15,10 +15,9 @@ import static org.testng.Assert.assertFalse; public class ActionsTests extends RestTest { - // TODO: TestGroup.ACTIONS not TestGroup.NODES - @TestRail(section = { TestGroup.REST_API,TestGroup.NODES }, executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API,TestGroup.ACTIONS }, executionType = ExecutionType.SANITY, description = "Verify actions") - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY}) + @Test(groups = { TestGroup.REST_API, TestGroup.ACTIONS, TestGroup.SANITY}) public void testActionDefinitions() throws Exception { restClient.authenticateUser(dataContent.getAdminUser()); @@ -35,11 +34,10 @@ public class ActionsTests extends RestTest restActionDefinitions.assertThat().entriesListContains("name", "check-out"); restActionDefinitions.assertThat().entriesListContains("name", "check-in"); } - - // TODO: TestGroup.ACTIONS not TestGroup.NODES - @TestRail(section = { TestGroup.REST_API,TestGroup.NODES }, executionType = ExecutionType.REGRESSION, + + @TestRail(section = { TestGroup.REST_API,TestGroup.ACTIONS }, executionType = ExecutionType.REGRESSION, description = "Verify actions error conditions") - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION}) + @Test(groups = { TestGroup.REST_API, TestGroup.ACTIONS, TestGroup.REGRESSION}) public void testActionDefinitionsNegative() throws Exception{ // Badly formed request -> 400 { From b2e9149d64f3ecfd67369f6c86c38dac61a33248 Mon Sep 17 00:00:00 2001 From: Matt Ward Date: Tue, 5 Dec 2017 13:39:53 +0000 Subject: [PATCH 1286/1491] REPO-1308: use method chaining for assertions As per review feedback in: https://git.alfresco.com/tas/alfresco-tas-restapi-test/merge_requests/39#note_13621 --- .../java/org/alfresco/rest/actions/ActionsTests.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/actions/ActionsTests.java b/e2e-test/java/org/alfresco/rest/actions/ActionsTests.java index 0905f0eb5..a05ce82f3 100644 --- a/e2e-test/java/org/alfresco/rest/actions/ActionsTests.java +++ b/e2e-test/java/org/alfresco/rest/actions/ActionsTests.java @@ -29,10 +29,11 @@ public class ActionsTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); assertFalse(restActionDefinitions.isEmpty()); - restActionDefinitions.assertThat().entriesListContains("name", "copy"); - restActionDefinitions.assertThat().entriesListContains("name", "move"); - restActionDefinitions.assertThat().entriesListContains("name", "check-out"); - restActionDefinitions.assertThat().entriesListContains("name", "check-in"); + restActionDefinitions.assertThat(). + entriesListContains("name", "copy"). + and().entriesListContains("name", "move"). + and().entriesListContains("name", "check-out"). + and().entriesListContains("name", "check-in"); } @TestRail(section = { TestGroup.REST_API,TestGroup.ACTIONS }, executionType = ExecutionType.REGRESSION, From b00811bd999a1e0e9c48b610ec2ed5b0e0e4a522 Mon Sep 17 00:00:00 2001 From: Andrei Forascu Date: Wed, 6 Dec 2017 10:01:33 +0000 Subject: [PATCH 1287/1491] Feature/repo 2268 sharedlinkspart2 --- .../sharedlinks/GetSharedLinksFullTests.java | 2 +- .../sharedlinks/SharedLinksSanityTests.java | 39 +++++++++++++++++-- 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/sharedlinks/GetSharedLinksFullTests.java b/e2e-test/java/org/alfresco/rest/sharedlinks/GetSharedLinksFullTests.java index 706963b02..ea227d4dd 100644 --- a/e2e-test/java/org/alfresco/rest/sharedlinks/GetSharedLinksFullTests.java +++ b/e2e-test/java/org/alfresco/rest/sharedlinks/GetSharedLinksFullTests.java @@ -36,7 +36,7 @@ public class GetSharedLinksFullTests extends RestTest @Bug(id="REPO-2365") @TestRail(section = { TestGroup.REST_API, TestGroup.SHAREDLINKS }, executionType = ExecutionType.REGRESSION, description = "Verify that a user with permission can get allowableOperations on sharedLinks") - @Test(groups = { TestGroup.REST_API, TestGroup.REGRESSION }) + @Test(groups = { TestGroup.REST_API, TestGroup.SHAREDLINKS, TestGroup.REGRESSION }) public void getSharedLinksWithAllowableOperations() throws Exception { file = dataContent.usingUser(adminUser).usingSite(privateSite).createContent(DocumentType.TEXT_PLAIN); diff --git a/e2e-test/java/org/alfresco/rest/sharedlinks/SharedLinksSanityTests.java b/e2e-test/java/org/alfresco/rest/sharedlinks/SharedLinksSanityTests.java index 684fe70f7..643eae3b5 100644 --- a/e2e-test/java/org/alfresco/rest/sharedlinks/SharedLinksSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sharedlinks/SharedLinksSanityTests.java @@ -1,5 +1,7 @@ package org.alfresco.rest.sharedlinks; +import javax.json.Json; + import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestSharedLinksModel; @@ -36,12 +38,14 @@ public class SharedLinksSanityTests extends RestTest private FileModel file3; private FileModel file4; private FileModel file5; + private FileModel file6; private RestSharedLinksModel sharedLink1; private RestSharedLinksModel sharedLink2; private RestSharedLinksModel sharedLink3; private RestSharedLinksModel sharedLink4; private RestSharedLinksModel sharedLink5; + private RestSharedLinksModel sharedLink6; private RestSharedLinksModelCollection sharedLinksCollection; @@ -67,10 +71,15 @@ public class SharedLinksSanityTests extends RestTest file3 = dataContent.usingUser(adminUser).usingResource(folder1).createContent(DocumentType.TEXT_PLAIN); file4 = dataContent.usingUser(adminUser).usingResource(folder1).createContent(DocumentType.TEXT_PLAIN); file5 = dataContent.usingUser(adminUser).usingResource(folder1).createContent(DocumentType.TEXT_PLAIN); + + // Create file6 based on existing resource + FileModel newFile = FileModel.getFileModelBasedOnTestDataFile("sampleContent.txt"); + newFile.setName("sampleContent.txt"); + file6 = dataContent.usingUser(adminUser).usingResource(folder1).createContent(newFile); } @TestRail(section = { TestGroup.REST_API, TestGroup.SHAREDLINKS }, executionType = ExecutionType.SANITY, description = "Verify create sharedLinks without Path") - @Test(groups = { TestGroup.REST_API, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.SHAREDLINKS, TestGroup.SANITY }) public void testCreateAndGetSharedLinks() throws Exception { // Post without includePath @@ -107,7 +116,7 @@ public class SharedLinksSanityTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.SHAREDLINKS }, executionType = ExecutionType.REGRESSION, description = "Verify create sharedLinks with Path") - @Test(groups = { TestGroup.REST_API, TestGroup.REGRESSION }) + @Test(groups = { TestGroup.REST_API, TestGroup.SHAREDLINKS, TestGroup.REGRESSION }) public void testCreateAndGetSharedLinksWithInclude() throws Exception { // Post with includePath @@ -146,7 +155,7 @@ public class SharedLinksSanityTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.SHAREDLINKS }, executionType = ExecutionType.SANITY, description = "Verify delete sharedLinks with and without Path") - @Test(groups = { TestGroup.REST_API, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.SHAREDLINKS, TestGroup.SANITY}) public void testDeleteSharedLinks() throws Exception { sharedLink3 = restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().createSharedLink(file3); @@ -158,8 +167,30 @@ public class SharedLinksSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } + @TestRail(section = { TestGroup.REST_API, TestGroup.SHAREDLINKS }, executionType = ExecutionType.SANITY, description = "Sanity tests for GET {sharedId}/content and POST {sharedId}/email endpoints") + @Test(groups = { TestGroup.REST_API, TestGroup.SHAREDLINKS, TestGroup.SANITY }) + public void testGetSharedLinkContentAndPostEmail() throws Exception + { + // Create shared-link + sharedLink6 = restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().createSharedLink(file6); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + // Make GET {sharedId}/content and check file content + restClient.withCoreAPI().usingSharedLinks().getSharedLinkContent(sharedLink6); + restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.assertHeaderValueContains("Content-Disposition", file6.getName()); + restClient.onResponse().getResponse().body().asString().contains("Sample text."); + + // Make POST {sharedId}/email to send email with created shared-link + String postBody = Json.createObjectBuilder().add("client", "share") + .add("recipientEmails", "john.doe@acme.com") + .build().toString(); + restClient.withCoreAPI().usingSharedLinks().sendSharedLinkEmail(sharedLink6, postBody); + restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); + } + @TestRail(section = { TestGroup.REST_API, TestGroup.SHAREDLINKS }, executionType = ExecutionType.REGRESSION, description = "Verify get sharedLink/content and get/renditions") - @Test(groups = { TestGroup.REST_API, TestGroup.REGRESSION, TestGroup.REQUIRE_TRANSFORMATION }) + @Test(groups = { TestGroup.REST_API, TestGroup.SHAREDLINKS, TestGroup.REGRESSION, TestGroup.REQUIRE_TRANSFORMATION }) public void testCreateWithExpiryDateAndGetSharedLinkRendition() throws Exception { sharedLink5 = restClient.authenticateUser(testUser1).withCoreAPI().includePath().usingSharedLinks().createSharedLinkWithExpiryDate(file5, expiryDate); From 2f1227815b5f76a8cda97122dd588b8f87cecad2 Mon Sep 17 00:00:00 2001 From: Andrei Forascu Date: Thu, 7 Dec 2017 16:32:29 +0200 Subject: [PATCH 1288/1491] REPO-2270 - RestAPI: Implement tests in TAS project for 'Shared-links' RestApi endpoint - part 3: - added sanity tests for GET /shared-links/{sharedId}/renditions, GET /shared-links/{sharedId}/renditions/{renditionId}, GET /shared-links/{sharedId}/renditions/{renditionId}/content --- .../sharedlinks/SharedLinksSanityTests.java | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/sharedlinks/SharedLinksSanityTests.java b/e2e-test/java/org/alfresco/rest/sharedlinks/SharedLinksSanityTests.java index 643eae3b5..6e266836c 100644 --- a/e2e-test/java/org/alfresco/rest/sharedlinks/SharedLinksSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sharedlinks/SharedLinksSanityTests.java @@ -1,9 +1,13 @@ package org.alfresco.rest.sharedlinks; +import static org.testng.Assert.assertEquals; + import javax.json.Json; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestRenditionInfoModel; +import org.alfresco.rest.model.RestRenditionInfoModelCollection; import org.alfresco.rest.model.RestSharedLinksModel; import org.alfresco.rest.model.RestSharedLinksModelCollection; import org.alfresco.utility.Utility; @@ -39,6 +43,7 @@ public class SharedLinksSanityTests extends RestTest private FileModel file4; private FileModel file5; private FileModel file6; + private FileModel file7; private RestSharedLinksModel sharedLink1; private RestSharedLinksModel sharedLink2; @@ -46,8 +51,12 @@ public class SharedLinksSanityTests extends RestTest private RestSharedLinksModel sharedLink4; private RestSharedLinksModel sharedLink5; private RestSharedLinksModel sharedLink6; + private RestSharedLinksModel sharedLink7; + + private RestRenditionInfoModel nodeRenditionInfo; private RestSharedLinksModelCollection sharedLinksCollection; + private RestRenditionInfoModelCollection nodeRenditionInfoCollection; private String expiryDate = "2027-03-23T23:00:00.000+0000"; @@ -71,6 +80,7 @@ public class SharedLinksSanityTests extends RestTest file3 = dataContent.usingUser(adminUser).usingResource(folder1).createContent(DocumentType.TEXT_PLAIN); file4 = dataContent.usingUser(adminUser).usingResource(folder1).createContent(DocumentType.TEXT_PLAIN); file5 = dataContent.usingUser(adminUser).usingResource(folder1).createContent(DocumentType.TEXT_PLAIN); + file7 = dataContent.usingUser(adminUser).usingResource(folder1).createContent(DocumentType.TEXT_PLAIN); // Create file6 based on existing resource FileModel newFile = FileModel.getFileModelBasedOnTestDataFile("sampleContent.txt"); @@ -205,4 +215,43 @@ public class SharedLinksSanityTests extends RestTest restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().getSharedLinkRendition(sharedLink5, "doclib"); restClient.assertStatusCodeIs(HttpStatus.OK); } + + @TestRail(section = { TestGroup.REST_API, TestGroup.SHAREDLINKS }, executionType = ExecutionType.SANITY, description = "Sanity tests for GET /renditions, GET /renditions/{renditionId} and GET /renditions/{renditionId}/content endpoints") + @Test(groups = { TestGroup.REST_API, TestGroup.SHAREDLINKS, TestGroup.SANITY, TestGroup.REQUIRE_TRANSFORMATION }) + public void testGetSharedLinkRendition() throws Exception + { + /* + * Create shared-link and generate renditions for node "doclib"; + * rendition is automatically created when creating "pdf" rendition + */ + sharedLink7 = restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().createSharedLink(file7); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.withCoreAPI().usingNode(file7).createNodeRendition("pdf"); + restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); + + // GET /renditions: wait until all renditions are created and GET all entries + Utility.sleep(1000, 30000, () -> + { + nodeRenditionInfoCollection = restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().getSharedLinkRenditions(sharedLink7); + restClient.assertStatusCodeIs(HttpStatus.OK); + + nodeRenditionInfoCollection.assertThat().entriesListCountIs(2); + nodeRenditionInfoCollection.getEntryByIndex(0).assertThat().field("id").is("doclib").and() + .field("status").is("CREATED"); + nodeRenditionInfoCollection.getEntryByIndex(1).assertThat().field("id").is("pdf").and() + .field("status").is("CREATED"); + }); + + // GET /renditions/{renditionId}: get specific rendition information for the file with shared link + nodeRenditionInfo = restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().getSharedLinkRendition(sharedLink7, "pdf"); + restClient.assertStatusCodeIs(HttpStatus.OK); + nodeRenditionInfo.assertThat().field("id").is("pdf").and() + .field("status").is("CREATED"); + + // GET /renditions/{renditionId}/content: get the rendition content for file with shared link + restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().getSharedLinkRenditionContent(sharedLink7, "pdf"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.assertHeaderValueContains("Content-Type","application/pdf;charset=UTF-8"); + Assert.assertTrue(restClient.onResponse().getResponse().body().asInputStream().available() > 0); + } } \ No newline at end of file From 19056c5c838539892d5828830e873feeea83c972 Mon Sep 17 00:00:00 2001 From: Andrei Forascu Date: Fri, 8 Dec 2017 16:21:27 +0200 Subject: [PATCH 1289/1491] REPO-2266 / REPO-2275: Implement tests in TAS project for 'Trashcan' RestApi endpoint - part 1/2 - implement sanity tests for GET /deleted-nodes, GET /deleted-nodes/{nodeId}, DELETE /deleted-nodes/{nodeId}, POST /deleted-nodes/{nodeId}/restore endpoints - code formatting --- .../rest/trashcan/GetDeletedNodesTests.java | 130 +++++++++++++----- 1 file changed, 99 insertions(+), 31 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/trashcan/GetDeletedNodesTests.java b/e2e-test/java/org/alfresco/rest/trashcan/GetDeletedNodesTests.java index d59596b1e..cae75997a 100644 --- a/e2e-test/java/org/alfresco/rest/trashcan/GetDeletedNodesTests.java +++ b/e2e-test/java/org/alfresco/rest/trashcan/GetDeletedNodesTests.java @@ -15,74 +15,142 @@ package org.alfresco.rest.trashcan; - +import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestNodeModel; import org.alfresco.rest.model.RestNodeModelsCollection; import org.alfresco.utility.exception.DataPreparationException; +import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; - /** * Tests for /api-explorer/#!/trashcan/listDeletedNodes + * /api-explorer/#!/trashcan/deleteDeletedNode + * /api-explorer/#!/trashcan/getDeletedNode + * /api-explorer/#!/trashcan/restoreDeletedNode * * @author jcule * */ -public class GetDeletedNodesTests extends RestTest +public class GetDeletedNodesTests extends RestTest { - private UserModel adminUserModel; - private SiteModel deleteNodesSiteModel; - private FolderModel deleteNodesFolder1, deleteNodesFolder2, deleteNodesFolder3; - - @BeforeClass(alwaysRun=true) + private UserModel adminUserModel; + private SiteModel deleteNodesSiteModel; + private FolderModel deleteNodesFolder1, deleteNodesFolder2, deleteNodesFolder3, deleteNodesFolder4, deleteNodesFolder5; + private FileModel file, file1; + + private RestNodeModelsCollection deletedNodes, deletedNodesMaxItem; + private RestNodeModel node; + + @BeforeClass(alwaysRun = true) public void dataPreparation() throws DataPreparationException { adminUserModel = dataUser.getAdminUser(); - restClient.authenticateUser(adminUserModel); + restClient.authenticateUser(adminUserModel); deleteNodesSiteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); } - - @AfterClass(alwaysRun=true) + + @AfterClass(alwaysRun = true) public void cleanup() throws Exception { dataSite.usingAdmin().deleteSite(deleteNodesSiteModel); } - + @Test(groups = { TestGroup.REST_API, TestGroup.REGRESSION }) public void testDeletedNodesBiggerThanMaxCount() throws Exception { - //get the number of item in the trashcan - RestNodeModelsCollection deletedNodes = restClient.withCoreAPI().usingTrashcan().findDeletedNodes(); - int count = deletedNodes.getPagination().getCount(); - int totalItems = deletedNodes.getPagination().getTotalItems(); - - //create folders - deleteNodesFolder1 = dataContent.usingUser(adminUserModel).usingSite(deleteNodesSiteModel).createFolder(); - deleteNodesFolder2 = dataContent.usingUser(adminUserModel).usingSite(deleteNodesSiteModel).createFolder(); - deleteNodesFolder3 = dataContent.usingUser(adminUserModel).usingSite(deleteNodesSiteModel).createFolder(); - - //delete folders + // get the number of item in the trashcan + deletedNodes = restClient.withCoreAPI().usingTrashcan().findDeletedNodes(); + int count = deletedNodes.getPagination().getCount(); + int totalItems = deletedNodes.getPagination().getTotalItems(); + + // create folders + deleteNodesFolder1 = dataContent.usingUser(adminUserModel).usingSite(deleteNodesSiteModel).createFolder(); + deleteNodesFolder2 = dataContent.usingUser(adminUserModel).usingSite(deleteNodesSiteModel).createFolder(); + deleteNodesFolder3 = dataContent.usingUser(adminUserModel).usingSite(deleteNodesSiteModel).createFolder(); + + // delete folders dataContent.usingUser(adminUserModel).usingResource(deleteNodesFolder1).deleteContent(); dataContent.usingUser(adminUserModel).usingResource(deleteNodesFolder2).deleteContent(); dataContent.usingUser(adminUserModel).usingResource(deleteNodesFolder3).deleteContent(); - + int maxItems = count + 1; - RestNodeModelsCollection deletedNodesMaxItem = restClient.withCoreAPI().usingTrashcan().usingParams(String.format("maxItems=%s", maxItems)).findDeletedNodes(); - - String countMaxItem = Integer.toString(maxItems); - String totalItemsMaxItem = Integer.toString(totalItems + 3); - String hasMoreItemsMaxItem = Boolean.toString(deletedNodesMaxItem.getPagination().isHasMoreItems()); - String skipCount = Integer.toString(deletedNodesMaxItem.getPagination().getSkipCount()); - + deletedNodesMaxItem = restClient.withCoreAPI().usingTrashcan().usingParams(String.format("maxItems=%s", maxItems)).findDeletedNodes(); + + String countMaxItem = Integer.toString(maxItems); + String totalItemsMaxItem = Integer.toString(totalItems + 3); + String hasMoreItemsMaxItem = Boolean.toString(deletedNodesMaxItem.getPagination().isHasMoreItems()); + String skipCount = Integer.toString(deletedNodesMaxItem.getPagination().getSkipCount()); + restClient.assertStatusCodeIs(HttpStatus.OK); deletedNodesMaxItem.getPagination().assertThat().field("totalItems").is(totalItemsMaxItem).and().field("count").is(countMaxItem); deletedNodesMaxItem.getPagination().assertThat().field("hasMoreItems").is(hasMoreItemsMaxItem).and().field("skipCount").is(skipCount); } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TRASHCAN }, executionType = ExecutionType.SANITY, description = "Sanity tests for GET /deleted-nodes and GET /deleted-nodes/{nodeId}") + @Test(groups = { TestGroup.REST_API, TestGroup.TRASHCAN, TestGroup.SANITY }) + public void testGetDeletedNodesFromTrashcan() throws Exception + { + // Create a folder and a file + deleteNodesFolder4 = dataContent.usingUser(adminUserModel).usingSite(deleteNodesSiteModel).createFolder(); + file = dataContent.usingUser(adminUserModel).usingSite(deleteNodesSiteModel).createContent(DocumentType.TEXT_PLAIN); + + // Delete file and folder + dataContent.usingUser(adminUserModel).usingResource(deleteNodesFolder4).deleteContent(); + dataContent.usingUser(adminUserModel).usingResource(file).deleteContent(); + + // GET /deleted-nodes: deleted file and folder are in the trashcan list + deletedNodes = restClient.withCoreAPI().usingTrashcan().findDeletedNodes(); + restClient.assertStatusCodeIs(HttpStatus.OK); + deletedNodes.getEntryByIndex(0).assertThat().field("name").is(file.getName()).and() + .field("id").is(file.getNodeRefWithoutVersion()); + deletedNodes.getEntryByIndex(1).assertThat().field("name").is(deleteNodesFolder4.getName()).and() + .field("id").is(deleteNodesFolder4.getNodeRefWithoutVersion()); + + // GET /deleted-nodes/{nodeId}: check a single deleted object + node = restClient.withCoreAPI().usingTrashcan().findDeletedNode(deleteNodesFolder4); + restClient.assertStatusCodeIs(HttpStatus.OK); + node.assertThat().field("name").is(deleteNodesFolder4.getName()).and() + .field("id").is(deleteNodesFolder4.getNodeRefWithoutVersion()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TRASHCAN }, executionType = ExecutionType.SANITY, description = "Sanity tests for DELETE /deleted-nodes/{nodeId} and POST /deleted-nodes/{nodeId}/restore") + @Test(groups = { TestGroup.REST_API, TestGroup.TRASHCAN, TestGroup.SANITY }) + public void testDeleteAndRestoreNodeFromTrashcan() throws Exception + { + // Create a folder and a file + deleteNodesFolder5 = dataContent.usingUser(adminUserModel).usingSite(deleteNodesSiteModel).createFolder(); + String docLibNodeRef = dataContent.usingUser(adminUserModel).usingSite(deleteNodesSiteModel).getNodeRef(); + file1 = dataContent.usingUser(adminUserModel).usingSite(deleteNodesSiteModel).createContent(DocumentType.TEXT_PLAIN); + + // Delete file and folder + dataContent.usingUser(adminUserModel).usingResource(deleteNodesFolder5).deleteContent(); + dataContent.usingUser(adminUserModel).usingResource(file1).deleteContent(); + + // DELETE /deleted-nodes/{nodeId}: delete an object from trashcan + restClient.withCoreAPI().usingTrashcan().deleteNodeFromTrashcan(file1); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingTrashcan().findDeletedNode(file1); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + + // POST /deleted-nodes/{nodeId}/restore: restore to repository a deleted object + node = restClient.withCoreAPI().usingTrashcan().restoreNodeFromTrashcan(deleteNodesFolder5); + restClient.assertStatusCodeIs(HttpStatus.OK); + node.assertThat().field("id").is(deleteNodesFolder5.getNodeRefWithoutVersion()).and() + .field("parentId").is(docLibNodeRef); + + // Checks that the node was removed from trashcan + restClient.withCoreAPI().usingTrashcan().findDeletedNode(deleteNodesFolder5); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } } From abd23873c1bfe9d3681893e451815c6c8ba30853 Mon Sep 17 00:00:00 2001 From: Andrei Forascu Date: Tue, 12 Dec 2017 16:00:24 +0200 Subject: [PATCH 1290/1491] REPO-1564 - Retrieve content/rendition for node in trashcan: - added sanity tests for the following endpoints: GET /deleted-nodes/{nodeId}/content, GET /deleted-nodes/{nodeId}/renditions, GET /deleted-nodes/{nodeId}/renditions/{renditionId}, GET /deleted-nodes/{nodeId}/renditions/{renditionId}/content --- .../rest/trashcan/GetDeletedNodesTests.java | 68 ++++++++++++++++++- 1 file changed, 67 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/trashcan/GetDeletedNodesTests.java b/e2e-test/java/org/alfresco/rest/trashcan/GetDeletedNodesTests.java index cae75997a..9121ad647 100644 --- a/e2e-test/java/org/alfresco/rest/trashcan/GetDeletedNodesTests.java +++ b/e2e-test/java/org/alfresco/rest/trashcan/GetDeletedNodesTests.java @@ -19,6 +19,9 @@ import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestNodeModel; import org.alfresco.rest.model.RestNodeModelsCollection; +import org.alfresco.rest.model.RestRenditionInfoModel; +import org.alfresco.rest.model.RestRenditionInfoModelCollection; +import org.alfresco.utility.Utility; import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FolderModel; @@ -28,6 +31,7 @@ import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; +import org.testng.Assert; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -46,11 +50,14 @@ public class GetDeletedNodesTests extends RestTest private UserModel adminUserModel; private SiteModel deleteNodesSiteModel; private FolderModel deleteNodesFolder1, deleteNodesFolder2, deleteNodesFolder3, deleteNodesFolder4, deleteNodesFolder5; - private FileModel file, file1; + private FileModel file, file1, file2, file3; private RestNodeModelsCollection deletedNodes, deletedNodesMaxItem; private RestNodeModel node; + private RestRenditionInfoModelCollection nodeRenditionInfoCollection; + private RestRenditionInfoModel nodeRenditionInfo; + @BeforeClass(alwaysRun = true) public void dataPreparation() throws DataPreparationException { @@ -153,4 +160,63 @@ public class GetDeletedNodesTests extends RestTest restClient.withCoreAPI().usingTrashcan().findDeletedNode(deleteNodesFolder5); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TRASHCAN }, executionType = ExecutionType.SANITY, description = "Sanity tests for GET /deleted-nodes/{nodeId}/content") + @Test(groups = { TestGroup.REST_API, TestGroup.TRASHCAN, TestGroup.SANITY }) + public void testGetDeletedNodesContent() throws Exception + { + // Create file2 based on existing resource + FileModel newFile = FileModel.getFileModelBasedOnTestDataFile("sampleContent.txt"); + newFile.setName("sampleContent.txt"); + file2 = dataContent.usingUser(adminUserModel).usingSite(deleteNodesSiteModel).createContent(newFile); + + // Delete file2 to be moved in trashcan + dataContent.usingUser(adminUserModel).usingResource(file2).deleteContent(); + + // Make GET /deleted-nodes/{nodeId}/content and check file content + restClient.withCoreAPI().usingTrashcan().getDeletedNodeContent(file2); + restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.assertHeaderValueContains("Content-Disposition", file2.getName()); + restClient.onResponse().getResponse().body().asString().contains("Sample text."); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TRASHCAN }, executionType = ExecutionType.SANITY, + description = "Sanity tests for GET /deleted-nodes/{nodeId}/renditions, GET /deleted-nodes/{nodeId}/renditions/{renditionId}, GET /deleted-nodes/{nodeId}/renditions/{renditionId}/content") + @Test(groups = { TestGroup.REST_API, TestGroup.TRASHCAN, TestGroup.SANITY }) + public void testGetDeletedNodesRenditions() throws Exception + { + // Create file3 based on existing resource + file3 = dataContent.usingUser(adminUserModel).usingSite(deleteNodesSiteModel).createContent(DocumentType.TEXT_PLAIN); + + // Create rendition and delete file3 to be moved in trashcan + restClient.withCoreAPI().usingNode(file3).createNodeRendition("pdf"); + restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); + dataContent.usingUser(adminUserModel).usingResource(file3).deleteContent(); + + // GET /deleted-nodes/{nodeId}/renditions + Utility.sleep(1000, 30000, () -> + { + nodeRenditionInfoCollection = restClient.authenticateUser(adminUserModel).withCoreAPI().usingTrashcan().usingParams("where=(status='CREATED')").getDeletedNodeRenditions(file3); + restClient.assertStatusCodeIs(HttpStatus.OK); + + // All renditions, created or not are retrieved. List is ordered + nodeRenditionInfoCollection.assertThat().entriesListCountIs(2); + nodeRenditionInfoCollection.getEntryByIndex(0).assertThat().field("id").is("doclib").and() + .field("status").is("CREATED"); + nodeRenditionInfoCollection.getEntryByIndex(1).assertThat().field("id").is("pdf").and() + .field("status").is("CREATED"); + }); + + // GET /deleted-nodes/{nodeId}/renditions/{id} + nodeRenditionInfo = restClient.authenticateUser(adminUserModel).withCoreAPI().usingTrashcan().getDeletedNodeRendition(file3, "pdf"); + restClient.assertStatusCodeIs(HttpStatus.OK); + nodeRenditionInfo.assertThat().field("id").is("pdf").and() + .field("status").is("CREATED"); + + // GET /deleted-nodes/{nodeId}/renditions/{id}/content + restClient.authenticateUser(adminUserModel).withCoreAPI().usingTrashcan().getDeletedNodeRenditionContent(file3, "pdf"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.assertHeaderValueContains("Content-Type","application/pdf;charset=UTF-8"); + Assert.assertTrue(restClient.onResponse().getResponse().body().asInputStream().available() > 0); + } } From 60970324ed2d8ce106f91fcf8ae8324863218dbb Mon Sep 17 00:00:00 2001 From: Alex Mukha Date: Fri, 15 Dec 2017 11:06:42 +0000 Subject: [PATCH 1291/1491] REPO-3097 Update error messages after jackson upgrade --- .../org/alfresco/rest/favorites/AddFavoritesTests.java | 2 +- .../java/org/alfresco/rest/ratings/AddRatingTests.java | 5 +++-- .../alfresco/rest/sites/members/AddSiteMemberTests.java | 8 ++++---- .../rest/sites/members/UpdateSiteMemberTests.java | 4 ++-- .../membershipRequests/AddSiteMembershipRequestTests.java | 2 +- .../UpdateSiteMembershipRequestTests.java | 4 ++-- 6 files changed, 13 insertions(+), 12 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesTests.java b/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesTests.java index e135bfac9..0797eadee 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesTests.java @@ -441,6 +441,6 @@ public class AddFavoritesTests extends RestTest RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "", "people/{personId}/favorites", adminUserModel.getUsername()); restClient.processModel(RestPersonFavoritesModel.class, request); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.NO_CONTENT, "No content to map to Object due to end of input"));; + .containsSummary(String.format(RestErrorModel.NO_CONTENT, "No content to map due to end-of-input")); } } diff --git a/e2e-test/java/org/alfresco/rest/ratings/AddRatingTests.java b/e2e-test/java/org/alfresco/rest/ratings/AddRatingTests.java index 17a37dbbe..72e3595a4 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/AddRatingTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/AddRatingTests.java @@ -371,7 +371,7 @@ public class AddRatingTests extends RestTest restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating(""); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.NO_CONTENT, "No content to map to Object due to end of input")); + .containsSummary(String.format(RestErrorModel.NO_CONTENT, "No content to map due to end-of-input")); } @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, @@ -384,7 +384,8 @@ public class AddRatingTests extends RestTest restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"\"}"); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.NO_CONTENT, "N/A (through reference chain: org.alfresco.rest.api.model.NodeRating[\"id\"])")); + // The message is shortened for comparison as there is a Java object id in the message (random) + .containsSummary(String.format(RestErrorModel.NO_CONTENT, "N/A")); } @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, diff --git a/e2e-test/java/org/alfresco/rest/sites/members/AddSiteMemberTests.java b/e2e-test/java/org/alfresco/rest/sites/members/AddSiteMemberTests.java index ecfa79db5..51cab086f 100644 --- a/e2e-test/java/org/alfresco/rest/sites/members/AddSiteMemberTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/members/AddSiteMemberTests.java @@ -417,8 +417,8 @@ public class AddSiteMemberTests extends RestTest publicSiteModel.getId(), restClient.getParameters()); restClient.processModel(RestSiteMemberModel.class, request); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.NO_CONTENT, "No content to map to Object due to end of input")) - .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "No content to map to Object due to end of input")) + .containsSummary(String.format(RestErrorModel.NO_CONTENT, "No content to map due to end-of-input")) + .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "No content to map due to end-of-input")) .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) .stackTraceIs(RestErrorModel.STACKTRACE); } @@ -463,8 +463,8 @@ public class AddSiteMemberTests extends RestTest RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, json, "sites/{siteId}/members?{parameters}", publicSiteModel.getId(), restClient.getParameters()); restClient.processModel(RestSiteMemberModel.class, request); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "N/A (through reference chain: org.alfresco.rest.api.model.SiteMember[\"role\"])")) - .containsSummary(String.format(RestErrorModel.NO_CONTENT, "N/A (through reference chain: org.alfresco.rest.api.model.SiteMember[\"role\"])")) + .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "N/A")) + .containsSummary(String.format(RestErrorModel.NO_CONTENT, "N/A")) .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) .stackTraceIs(RestErrorModel.STACKTRACE); } diff --git a/e2e-test/java/org/alfresco/rest/sites/members/UpdateSiteMemberTests.java b/e2e-test/java/org/alfresco/rest/sites/members/UpdateSiteMemberTests.java index 4afb9dde2..3b98afebb 100644 --- a/e2e-test/java/org/alfresco/rest/sites/members/UpdateSiteMemberTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/members/UpdateSiteMemberTests.java @@ -523,8 +523,8 @@ public class UpdateSiteMemberTests extends RestTest RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "", "sites/{siteId}/members/{personId}", publicSite.getId(), siteCollaborator.getUsername()); restClient.processModel(RestSiteMemberModel.class, request); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.NO_CONTENT, "No content to map to Object due to end of input")) - .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "No content to map to Object due to end of input")) + .containsSummary(String.format(RestErrorModel.NO_CONTENT, "No content to map due to end-of-input")) + .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "No content to map due to end-of-input")) .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) .stackTraceIs(RestErrorModel.STACKTRACE); } diff --git a/e2e-test/java/org/alfresco/rest/sites/membershipRequests/AddSiteMembershipRequestTests.java b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/AddSiteMembershipRequestTests.java index 296d3ee51..a6f155cf6 100644 --- a/e2e-test/java/org/alfresco/rest/sites/membershipRequests/AddSiteMembershipRequestTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/AddSiteMembershipRequestTests.java @@ -146,7 +146,7 @@ public class AddSiteMembershipRequestTests extends RestTest UserModel newMember = dataUser.createRandomTestUser(); restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest(""); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.NO_CONTENT, "No content to map to Object due to end of input")); + .assertLastError().containsSummary(String.format(RestErrorModel.NO_CONTENT, "No content to map due to end-of-input")); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) diff --git a/e2e-test/java/org/alfresco/rest/sites/membershipRequests/UpdateSiteMembershipRequestTests.java b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/UpdateSiteMembershipRequestTests.java index 9bff0d17b..c40d3a2b5 100644 --- a/e2e-test/java/org/alfresco/rest/sites/membershipRequests/UpdateSiteMembershipRequestTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/UpdateSiteMembershipRequestTests.java @@ -439,8 +439,8 @@ public class UpdateSiteMembershipRequestTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) .assertLastError() - .containsSummary(String.format(RestErrorModel.NO_CONTENT, "No content to map to Object due to end of input")) - .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "No content to map to Object due to end of input")) + .containsSummary(String.format(RestErrorModel.NO_CONTENT, "No content to map due to end-of-input")) + .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "No content to map due to end-of-input")) .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) .stackTraceIs(RestErrorModel.STACKTRACE); } From 683370ff36fa1ac9060a7252e87d98585828c576 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Mon, 23 Oct 2017 13:34:11 +0300 Subject: [PATCH 1292/1491] reset default properties --- e2e-test/resources/default.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/resources/default.properties b/e2e-test/resources/default.properties index 2e4c58893..c88f53cea 100644 --- a/e2e-test/resources/default.properties +++ b/e2e-test/resources/default.properties @@ -14,7 +14,7 @@ jmx.useJolokiaAgent=false # Server Health section # in ServerHealth#isServerReachable() - could also be shown. # enable this option to view if on server there are tenants or not -serverHealth.showTenants=true +serverHealth.showTenants=false # TEST MANAGEMENT SECTION - Test Rail # From e7840dc49b2e70dccab8cef7a41bed7c622b5e1d Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Mon, 23 Oct 2017 15:52:21 +0300 Subject: [PATCH 1293/1491] update sync-service test --- .../sync/service/SyncServiceAPITests.java | 178 ++++++++++++++++++ 1 file changed, 178 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/sync/service/SyncServiceAPITests.java diff --git a/e2e-test/java/org/alfresco/rest/sync/service/SyncServiceAPITests.java b/e2e-test/java/org/alfresco/rest/sync/service/SyncServiceAPITests.java new file mode 100644 index 000000000..89a5f8964 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/sync/service/SyncServiceAPITests.java @@ -0,0 +1,178 @@ +package org.alfresco.rest.sync.service; + +import java.util.LinkedList; +import java.util.List; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestSubscriberModel; +import org.alfresco.rest.model.RestSubscriberModelCollection; +import org.alfresco.rest.model.RestSyncNodeSubscriptionModel; +import org.alfresco.rest.model.RestSyncNodeSubscriptionModelCollection; +import org.alfresco.rest.model.RestSyncSetChangesModel; +import org.alfresco.rest.model.RestSyncSetGetModel; +import org.alfresco.rest.model.RestSyncSetRequestModel; +import org.alfresco.rest.requests.privateAPI.Subscriber; +import org.alfresco.utility.LogFactory; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.slf4j.Logger; +import org.springframework.http.HttpStatus; +import org.testng.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Sanity tests for Testing Sync Service APIs + * + * @author mbhave + */ +@Test(groups = TestGroup.SYNC_API) +public class SyncServiceAPITests extends RestTest +{ + private static Logger LOG = LogFactory.getLogger(); + + private UserModel adminUserModel; + private SiteModel siteModel; + private FolderModel targetFolder1; + private FolderModel targetFolder2; + + private RestSyncNodeSubscriptionModelCollection nodeSubscriptions; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + restClient.authenticateUser(adminUserModel); + + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + + targetFolder1 = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); + + targetFolder2 = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); + + siteModel.setGuid(restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(siteModel).getSite().getGuidWithoutVersion()); + + } + + public void test01_SyncDeviceSubscription() throws Exception + { + // Register Device + RestSubscriberModel deviceSubscription = restClient.authenticateUser(adminUserModel).withPrivateAPI().withSubscribers().subscribeDevice("windows", "2.1"); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.onResponse().assertThat().body("entry.id", org.hamcrest.Matchers.notNullValue()); + restClient.onResponse().assertThat().body("entry.id", org.hamcrest.Matchers.equalTo(deviceSubscription.getId())); + + // Get Registered Devices + RestSubscriberModelCollection deviceSubscriptions = restClient.authenticateUser(adminUserModel).withPrivateAPI().withSubscribers().getSubscribers(); + + restClient.onResponse().assertThat().body("list.entries.entry", org.hamcrest.Matchers.notNullValue()); + int noOfSubscriptions = deviceSubscriptions.getEntries().size(); + Assert.assertTrue(noOfSubscriptions > 0, "No Device subscriptions found when expected"); + LOG.info("Subscribers: " + deviceSubscriptions); + Assert.assertTrue(deviceSubscriptions.getEntries().get(noOfSubscriptions - 1).onModel().getId().equals(deviceSubscription.getId())); + + } + + public void test02_SyncNodeSyncSubscription() throws Exception + { + // Register Device + RestSubscriberModel deviceSubscription = restClient.authenticateUser(adminUserModel).withPrivateAPI().withSubscribers().subscribeDevice("windows", + "1.2"); + + // Subscribe to a node + RestSyncNodeSubscriptionModel nodeSubscription = restClient.withPrivateAPI().withSubscriber(deviceSubscription) + .subscribeToNode(targetFolder1.getNodeRefWithoutVersion(), Subscriber.TYPE.BOTH); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.onResponse().assertThat().body("entry.deviceSubscriptionId", org.hamcrest.Matchers.notNullValue()); + restClient.onResponse().assertThat().body("entry.deviceSubscriptionId", org.hamcrest.Matchers.equalTo(deviceSubscription.getId())); + + restClient.onResponse().assertThat().body("entry.targetNodeId", org.hamcrest.Matchers.notNullValue()); + restClient.onResponse().assertThat().body("entry.targetNodeId", org.hamcrest.Matchers.equalTo(targetFolder1.getNodeRefWithoutVersion())); + + restClient.onResponse().assertThat().body("entry.id", org.hamcrest.Matchers.notNullValue()); + restClient.onResponse().assertThat().body("entry.id", org.hamcrest.Matchers.equalTo(nodeSubscription.getId())); + + // Get Sync Node Subscriptions + nodeSubscriptions = restClient.withPrivateAPI().withSubscriber(deviceSubscription).getSubscriptions(); + + nodeSubscriptions.assertThat().entriesListContains("id", nodeSubscription.getId()); + + restClient.onResponse().assertThat().body("list.entries.entry", org.hamcrest.Matchers.notNullValue()); + + int noOfSubscriptions = nodeSubscriptions.getEntries().size(); + Assert.assertTrue(noOfSubscriptions > 0, "No Sync subscriptions found when expected"); + LOG.info("Subscriptions: " + nodeSubscriptions); + Assert.assertEquals(nodeSubscriptions.getEntries().get(noOfSubscriptions - 1).onModel().getId(), nodeSubscription.getId()); + Assert.assertEquals(nodeSubscriptions.getEntries().get(noOfSubscriptions - 1).onModel().getDeviceSubscriptionId(), + nodeSubscription.getDeviceSubscriptionId()); + + // Get Sync Node Subscription by subscriptionId + RestSyncNodeSubscriptionModel subscription = restClient.withPrivateAPI().withSubscriber(deviceSubscription) + .getSubscriptionFromNode(nodeSubscription.getId()); + + subscription.assertThat().field("id").isNotNull().assertThat().field("id").is(nodeSubscription.getId()).assertThat().field("deviceSubscriptionId") + .isNotNull().assertThat().field("deviceSubscriptionId").is(nodeSubscription.getDeviceSubscriptionId()); + } + + public void test03_SyncNodeSyncSubscriptions() throws Exception + { + // Register Device + RestSubscriberModel deviceSubscription = restClient.authenticateUser(adminUserModel).withPrivateAPI().withSubscribers().subscribeDevice("windows", + "1.2"); + + // Subscribe to a node + restClient.withPrivateAPI().withSubscriber(deviceSubscription).subscribeToNodes(siteModel.getGuid(), targetFolder1.getNodeRefWithoutVersion(), + targetFolder2.getNodeRefWithoutVersion()); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + // Get Sync Node Subscriptions + RestSyncNodeSubscriptionModelCollection subscriptionList = restClient.withPrivateAPI().withSubscriber(deviceSubscription).getSubscriptions(); + + int countOfEntries = subscriptionList.getEntries().size(); + Assert.assertTrue(countOfEntries == 3, "Node subscriptions NOT found when expected"); + } + + public void test04_SyncNodeSyncProcess() throws Exception + { + // Register Device + List clientChanges = new LinkedList<>(); + RestSubscriberModel deviceSubscription = restClient.authenticateUser(adminUserModel).withPrivateAPI().withSubscribers().subscribeDevice("windows", + "1.2"); + + // Subscribe to a node + RestSyncNodeSubscriptionModel nodeSubscription = restClient.withPrivateAPI().withSubscriber(deviceSubscription) + .subscribeToNode(targetFolder1.getNodeRefWithoutVersion(), Subscriber.TYPE.BOTH); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + // Start Sync + RestSyncSetRequestModel syncRequest = restClient.authenticateUser(adminUserModel) + .withPrivateAPI().withSubscriber(deviceSubscription).startSyncOnNode(nodeSubscription, clientChanges); + + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + Assert.assertNotNull(syncRequest.getSyncId(), "Sync Id not expected to be null"); + String syncId = syncRequest.getSyncId(); + Assert.assertNotNull(syncRequest.getUrl(), "Sync URL not expected to be null"); + Assert.assertTrue(syncRequest.getUrl().endsWith(syncId), "Incorrect Sync URL, expected to end with syncId: " + syncId); + Assert.assertEquals(syncRequest.getStatus(), "ok", "Sync Status not ok. Actual: " + syncRequest.getStatus()); + Assert.assertNull(syncRequest.getMessage(), "Sync Message was expected to be null. Actual: " + syncRequest.getMessage()); + Assert.assertNull(syncRequest.getError(), "Sync Error expected to be null. Actual: " + syncRequest.getError()); + + // Get Sync Changes + RestSyncSetGetModel changeSet = restClient.withPrivateAPI().withSubscriber(deviceSubscription).getNodeSyncChangeSet(nodeSubscription, syncRequest); + + restClient.assertStatusCodeIs(HttpStatus.OK); + Assert.assertNotNull(changeSet.getSyncId(), "Sync Id not expected to be null"); + Assert.assertTrue(changeSet.getSyncId().equals(syncId), "Incorrect SyncId in the response"); + Assert.assertNotNull(changeSet.getMoreChanges(), "MoreChanges expected to be true or false. It's null"); + + // End Sync + restClient.withPrivateAPI().withSubscriber(deviceSubscription).endSyncOnNode(nodeSubscription,syncRequest); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + +} From 6bc389a0c3fce326ee64c8dde52acc761b997664 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Mon, 23 Oct 2017 16:26:26 +0300 Subject: [PATCH 1294/1491] adding test group --- .../SyncServiceAPITests.java | 43 +++++++++++-------- 1 file changed, 25 insertions(+), 18 deletions(-) rename e2e-test/java/org/alfresco/rest/{sync/service => syncService}/SyncServiceAPITests.java (84%) diff --git a/e2e-test/java/org/alfresco/rest/sync/service/SyncServiceAPITests.java b/e2e-test/java/org/alfresco/rest/syncService/SyncServiceAPITests.java similarity index 84% rename from e2e-test/java/org/alfresco/rest/sync/service/SyncServiceAPITests.java rename to e2e-test/java/org/alfresco/rest/syncService/SyncServiceAPITests.java index 89a5f8964..8cf0f4ee1 100644 --- a/e2e-test/java/org/alfresco/rest/sync/service/SyncServiceAPITests.java +++ b/e2e-test/java/org/alfresco/rest/syncService/SyncServiceAPITests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sync.service; +package org.alfresco.rest.syncService; import java.util.LinkedList; import java.util.List; @@ -28,7 +28,7 @@ import org.testng.annotations.Test; * * @author mbhave */ -@Test(groups = TestGroup.SYNC_API) +@Test(groups = {TestGroup.SYNC_API, TestGroup.REQUIRES_AMP}) public class SyncServiceAPITests extends RestTest { private static Logger LOG = LogFactory.getLogger(); @@ -47,7 +47,7 @@ public class SyncServiceAPITests extends RestTest restClient.authenticateUser(adminUserModel); siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - + targetFolder1 = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); targetFolder2 = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); @@ -56,10 +56,10 @@ public class SyncServiceAPITests extends RestTest } - public void test01_SyncDeviceSubscription() throws Exception + public void testTahtNewDevicesAreAbleToSubscribe() throws Exception { // Register Device - RestSubscriberModel deviceSubscription = restClient.authenticateUser(adminUserModel).withPrivateAPI().withSubscribers().subscribeDevice("windows", "2.1"); + RestSubscriberModel deviceSubscription = restClient.authenticateUser(adminUserModel).withPrivateAPI().withSubscribers().registerDevice("windows", "2.1"); restClient.assertStatusCodeIs(HttpStatus.CREATED); restClient.onResponse().assertThat().body("entry.id", org.hamcrest.Matchers.notNullValue()); @@ -76,15 +76,17 @@ public class SyncServiceAPITests extends RestTest } - public void test02_SyncNodeSyncSubscription() throws Exception + public void testDeviceSubcriptionToNode() throws Exception { // Register Device - RestSubscriberModel deviceSubscription = restClient.authenticateUser(adminUserModel).withPrivateAPI().withSubscribers().subscribeDevice("windows", + RestSubscriberModel deviceSubscription = restClient.authenticateUser(adminUserModel).withPrivateAPI().withSubscribers().registerDevice("windows", "1.2"); // Subscribe to a node - RestSyncNodeSubscriptionModel nodeSubscription = restClient.withPrivateAPI().withSubscriber(deviceSubscription) - .subscribeToNode(targetFolder1.getNodeRefWithoutVersion(), Subscriber.TYPE.BOTH); + RestSyncNodeSubscriptionModel nodeSubscription = restClient + .withPrivateAPI() + .withSubscriber(deviceSubscription) + .subscribeToNode(targetFolder1.getNodeRefWithoutVersion(), Subscriber.TYPE.BOTH); restClient.assertStatusCodeIs(HttpStatus.CREATED); restClient.onResponse().assertThat().body("entry.deviceSubscriptionId", org.hamcrest.Matchers.notNullValue()); @@ -118,10 +120,10 @@ public class SyncServiceAPITests extends RestTest .isNotNull().assertThat().field("deviceSubscriptionId").is(nodeSubscription.getDeviceSubscriptionId()); } - public void test03_SyncNodeSyncSubscriptions() throws Exception + public void testDeviceSubcriptionToMultipleNodes() throws Exception { // Register Device - RestSubscriberModel deviceSubscription = restClient.authenticateUser(adminUserModel).withPrivateAPI().withSubscribers().subscribeDevice("windows", + RestSubscriberModel deviceSubscription = restClient.authenticateUser(adminUserModel).withPrivateAPI().withSubscribers().registerDevice("windows", "1.2"); // Subscribe to a node @@ -136,21 +138,27 @@ public class SyncServiceAPITests extends RestTest Assert.assertTrue(countOfEntries == 3, "Node subscriptions NOT found when expected"); } - public void test04_SyncNodeSyncProcess() throws Exception + @Test(enabled=false) + public void testSyncProcess() throws Exception { // Register Device List clientChanges = new LinkedList<>(); - RestSubscriberModel deviceSubscription = restClient.authenticateUser(adminUserModel).withPrivateAPI().withSubscribers().subscribeDevice("windows", - "1.2"); + RestSubscriberModel deviceSubscription = restClient.authenticateUser(adminUserModel) + .withPrivateAPI() + .withSubscribers() + .registerDevice("windows","1.2"); // Subscribe to a node - RestSyncNodeSubscriptionModel nodeSubscription = restClient.withPrivateAPI().withSubscriber(deviceSubscription) - .subscribeToNode(targetFolder1.getNodeRefWithoutVersion(), Subscriber.TYPE.BOTH); + RestSyncNodeSubscriptionModel nodeSubscription = restClient.withPrivateAPI() + .withSubscriber(deviceSubscription) + .subscribeToNode(targetFolder1.getNodeRefWithoutVersion(), Subscriber.TYPE.BOTH); restClient.assertStatusCodeIs(HttpStatus.CREATED); // Start Sync RestSyncSetRequestModel syncRequest = restClient.authenticateUser(adminUserModel) - .withPrivateAPI().withSubscriber(deviceSubscription).startSyncOnNode(nodeSubscription, clientChanges); + .withPrivateAPI() + .withSubscriber(nodeSubscription.getDeviceSubscriptionId()) + .startSyncOnNode(nodeSubscription, clientChanges); restClient.assertStatusCodeIs(HttpStatus.CREATED); @@ -174,5 +182,4 @@ public class SyncServiceAPITests extends RestTest restClient.withPrivateAPI().withSubscriber(deviceSubscription).endSyncOnNode(nodeSubscription,syncRequest); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } - } From a77f02d5207d76113495bc934e4b0f3731a800db Mon Sep 17 00:00:00 2001 From: mbhave Date: Tue, 7 Nov 2017 14:56:12 +0000 Subject: [PATCH 1295/1491] resolve conflicts --- .../rest/syncService/SyncServiceAPITests.java | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/syncService/SyncServiceAPITests.java b/e2e-test/java/org/alfresco/rest/syncService/SyncServiceAPITests.java index 8cf0f4ee1..b758ddad6 100644 --- a/e2e-test/java/org/alfresco/rest/syncService/SyncServiceAPITests.java +++ b/e2e-test/java/org/alfresco/rest/syncService/SyncServiceAPITests.java @@ -12,6 +12,7 @@ import org.alfresco.rest.model.RestSyncSetChangesModel; import org.alfresco.rest.model.RestSyncSetGetModel; import org.alfresco.rest.model.RestSyncSetRequestModel; import org.alfresco.rest.requests.privateAPI.Subscriber; +import org.alfresco.rest.requests.privateAPI.SyncServiceHealthcheck; import org.alfresco.utility.LogFactory; import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; @@ -55,8 +56,19 @@ public class SyncServiceAPITests extends RestTest siteModel.setGuid(restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(siteModel).getSite().getGuidWithoutVersion()); } + + @Test(priority = 1) + public void testSyncServiceHealthCheck() throws Exception + { + // Register Device + SyncServiceHealthcheck healthCheck = restClient.authenticateUser(adminUserModel).withPrivateAPI().performHealthCheck(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + Assert.assertTrue(healthCheck.getHealthcheck().getActiveMQConnection().getHealthy()); + } - public void testTahtNewDevicesAreAbleToSubscribe() throws Exception + @Test(priority = 2) + public void testNewDeviceSubscription() throws Exception { // Register Device RestSubscriberModel deviceSubscription = restClient.authenticateUser(adminUserModel).withPrivateAPI().withSubscribers().registerDevice("windows", "2.1"); @@ -76,6 +88,7 @@ public class SyncServiceAPITests extends RestTest } + @Test(priority = 3) public void testDeviceSubcriptionToNode() throws Exception { // Register Device @@ -120,6 +133,7 @@ public class SyncServiceAPITests extends RestTest .isNotNull().assertThat().field("deviceSubscriptionId").is(nodeSubscription.getDeviceSubscriptionId()); } + @Test(priority = 4) public void testDeviceSubcriptionToMultipleNodes() throws Exception { // Register Device @@ -138,7 +152,8 @@ public class SyncServiceAPITests extends RestTest Assert.assertTrue(countOfEntries == 3, "Node subscriptions NOT found when expected"); } - @Test(enabled=false) + + @Test(priority = 5) public void testSyncProcess() throws Exception { // Register Device From 6a577ad1fde05ed7d762c46fefa585233c685f37 Mon Sep 17 00:00:00 2001 From: mbhave Date: Tue, 7 Nov 2017 17:05:59 +0000 Subject: [PATCH 1296/1491] resolve merge conflicts on sync code --- .../java/org/alfresco/rest/syncService/SyncServiceAPITests.java | 1 - 1 file changed, 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/syncService/SyncServiceAPITests.java b/e2e-test/java/org/alfresco/rest/syncService/SyncServiceAPITests.java index b758ddad6..49d0d114e 100644 --- a/e2e-test/java/org/alfresco/rest/syncService/SyncServiceAPITests.java +++ b/e2e-test/java/org/alfresco/rest/syncService/SyncServiceAPITests.java @@ -152,7 +152,6 @@ public class SyncServiceAPITests extends RestTest Assert.assertTrue(countOfEntries == 3, "Node subscriptions NOT found when expected"); } - @Test(priority = 5) public void testSyncProcess() throws Exception { From e777162e6337e41d9f4bcc7b9fa0a6fd92fad015 Mon Sep 17 00:00:00 2001 From: mbhave Date: Wed, 6 Dec 2017 09:51:51 +0000 Subject: [PATCH 1297/1491] Implemented Healthcheck api, test and refactoring to cleanup the issues during merge --- .../rest/syncService/SyncServiceAPITests.java | 35 ++++++++++--------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/syncService/SyncServiceAPITests.java b/e2e-test/java/org/alfresco/rest/syncService/SyncServiceAPITests.java index 49d0d114e..77f1770e7 100644 --- a/e2e-test/java/org/alfresco/rest/syncService/SyncServiceAPITests.java +++ b/e2e-test/java/org/alfresco/rest/syncService/SyncServiceAPITests.java @@ -11,8 +11,8 @@ import org.alfresco.rest.model.RestSyncNodeSubscriptionModelCollection; import org.alfresco.rest.model.RestSyncSetChangesModel; import org.alfresco.rest.model.RestSyncSetGetModel; import org.alfresco.rest.model.RestSyncSetRequestModel; -import org.alfresco.rest.requests.privateAPI.Subscriber; -import org.alfresco.rest.requests.privateAPI.SyncServiceHealthcheck; +import org.alfresco.rest.requests.syncServiceAPI.Healthcheck; +import org.alfresco.rest.requests.syncServiceAPI.Subscriptions.TYPE; import org.alfresco.utility.LogFactory; import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; @@ -40,6 +40,8 @@ public class SyncServiceAPITests extends RestTest private FolderModel targetFolder2; private RestSyncNodeSubscriptionModelCollection nodeSubscriptions; + + private String clientVersion; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception @@ -54,14 +56,15 @@ public class SyncServiceAPITests extends RestTest targetFolder2 = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); siteModel.setGuid(restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(siteModel).getSite().getGuidWithoutVersion()); - + + clientVersion = "1.1"; } @Test(priority = 1) public void testSyncServiceHealthCheck() throws Exception { // Register Device - SyncServiceHealthcheck healthCheck = restClient.authenticateUser(adminUserModel).withPrivateAPI().performHealthCheck(); + Healthcheck healthCheck = restClient.authenticateUser(adminUserModel).withPrivateAPI().doHealthCheck(); restClient.assertStatusCodeIs(HttpStatus.OK); Assert.assertTrue(healthCheck.getHealthcheck().getActiveMQConnection().getHealthy()); @@ -71,20 +74,19 @@ public class SyncServiceAPITests extends RestTest public void testNewDeviceSubscription() throws Exception { // Register Device - RestSubscriberModel deviceSubscription = restClient.authenticateUser(adminUserModel).withPrivateAPI().withSubscribers().registerDevice("windows", "2.1"); + RestSubscriberModel deviceSubscription = restClient.authenticateUser(adminUserModel).withPrivateAPI().withSubscribers().registerDevice("windows", clientVersion); restClient.assertStatusCodeIs(HttpStatus.CREATED); restClient.onResponse().assertThat().body("entry.id", org.hamcrest.Matchers.notNullValue()); restClient.onResponse().assertThat().body("entry.id", org.hamcrest.Matchers.equalTo(deviceSubscription.getId())); // Get Registered Devices - RestSubscriberModelCollection deviceSubscriptions = restClient.authenticateUser(adminUserModel).withPrivateAPI().withSubscribers().getSubscribers(); + RestSubscriberModelCollection deviceSubscriptions = restClient.authenticateUser(adminUserModel).withParams("maxItems=500").withPrivateAPI().withSubscribers().getSubscribers(); restClient.onResponse().assertThat().body("list.entries.entry", org.hamcrest.Matchers.notNullValue()); int noOfSubscriptions = deviceSubscriptions.getEntries().size(); Assert.assertTrue(noOfSubscriptions > 0, "No Device subscriptions found when expected"); - LOG.info("Subscribers: " + deviceSubscriptions); - Assert.assertTrue(deviceSubscriptions.getEntries().get(noOfSubscriptions - 1).onModel().getId().equals(deviceSubscription.getId())); + Assert.assertTrue(deviceSubscriptions.getEntries().get(noOfSubscriptions - 1).onModel().getId().equals(deviceSubscription.getId()),"Not found: " + deviceSubscription.getId()); } @@ -93,13 +95,13 @@ public class SyncServiceAPITests extends RestTest { // Register Device RestSubscriberModel deviceSubscription = restClient.authenticateUser(adminUserModel).withPrivateAPI().withSubscribers().registerDevice("windows", - "1.2"); + clientVersion); // Subscribe to a node RestSyncNodeSubscriptionModel nodeSubscription = restClient .withPrivateAPI() .withSubscriber(deviceSubscription) - .subscribeToNode(targetFolder1.getNodeRefWithoutVersion(), Subscriber.TYPE.BOTH); + .subscribeToNode(targetFolder1.getNodeRefWithoutVersion(), TYPE.BOTH); restClient.assertStatusCodeIs(HttpStatus.CREATED); restClient.onResponse().assertThat().body("entry.deviceSubscriptionId", org.hamcrest.Matchers.notNullValue()); @@ -126,8 +128,7 @@ public class SyncServiceAPITests extends RestTest nodeSubscription.getDeviceSubscriptionId()); // Get Sync Node Subscription by subscriptionId - RestSyncNodeSubscriptionModel subscription = restClient.withPrivateAPI().withSubscriber(deviceSubscription) - .getSubscriptionFromNode(nodeSubscription.getId()); + RestSyncNodeSubscriptionModel subscription = restClient.withPrivateAPI().withSubscriber(deviceSubscription).getSubscription(nodeSubscription.getId()); subscription.assertThat().field("id").isNotNull().assertThat().field("id").is(nodeSubscription.getId()).assertThat().field("deviceSubscriptionId") .isNotNull().assertThat().field("deviceSubscriptionId").is(nodeSubscription.getDeviceSubscriptionId()); @@ -165,14 +166,14 @@ public class SyncServiceAPITests extends RestTest // Subscribe to a node RestSyncNodeSubscriptionModel nodeSubscription = restClient.withPrivateAPI() .withSubscriber(deviceSubscription) - .subscribeToNode(targetFolder1.getNodeRefWithoutVersion(), Subscriber.TYPE.BOTH); + .subscribeToNode(targetFolder1.getNodeRefWithoutVersion(), TYPE.BOTH); restClient.assertStatusCodeIs(HttpStatus.CREATED); // Start Sync RestSyncSetRequestModel syncRequest = restClient.authenticateUser(adminUserModel) .withPrivateAPI() - .withSubscriber(nodeSubscription.getDeviceSubscriptionId()) - .startSyncOnNode(nodeSubscription, clientChanges); + .withSubscription(nodeSubscription) + .startSync(nodeSubscription, clientChanges, clientVersion); restClient.assertStatusCodeIs(HttpStatus.CREATED); @@ -185,7 +186,7 @@ public class SyncServiceAPITests extends RestTest Assert.assertNull(syncRequest.getError(), "Sync Error expected to be null. Actual: " + syncRequest.getError()); // Get Sync Changes - RestSyncSetGetModel changeSet = restClient.withPrivateAPI().withSubscriber(deviceSubscription).getNodeSyncChangeSet(nodeSubscription, syncRequest); + RestSyncSetGetModel changeSet = restClient.withPrivateAPI().withSubscription(nodeSubscription).getSync(nodeSubscription, syncRequest); restClient.assertStatusCodeIs(HttpStatus.OK); Assert.assertNotNull(changeSet.getSyncId(), "Sync Id not expected to be null"); @@ -193,7 +194,7 @@ public class SyncServiceAPITests extends RestTest Assert.assertNotNull(changeSet.getMoreChanges(), "MoreChanges expected to be true or false. It's null"); // End Sync - restClient.withPrivateAPI().withSubscriber(deviceSubscription).endSyncOnNode(nodeSubscription,syncRequest); + restClient.withPrivateAPI().withSubscription(nodeSubscription).endSync(nodeSubscription,syncRequest); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } } From 87058b5a992397694480a15de8b2dffd44f34472 Mon Sep 17 00:00:00 2001 From: mbhave Date: Wed, 6 Dec 2017 10:50:10 +0000 Subject: [PATCH 1298/1491] Added assertions for checking all components of healthCheck --- .../rest/syncService/SyncServiceAPITests.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/syncService/SyncServiceAPITests.java b/e2e-test/java/org/alfresco/rest/syncService/SyncServiceAPITests.java index 77f1770e7..2bad98400 100644 --- a/e2e-test/java/org/alfresco/rest/syncService/SyncServiceAPITests.java +++ b/e2e-test/java/org/alfresco/rest/syncService/SyncServiceAPITests.java @@ -8,6 +8,7 @@ import org.alfresco.rest.model.RestSubscriberModel; import org.alfresco.rest.model.RestSubscriberModelCollection; import org.alfresco.rest.model.RestSyncNodeSubscriptionModel; import org.alfresco.rest.model.RestSyncNodeSubscriptionModelCollection; +import org.alfresco.rest.model.RestSyncServiceHealthCheckModel; import org.alfresco.rest.model.RestSyncSetChangesModel; import org.alfresco.rest.model.RestSyncSetGetModel; import org.alfresco.rest.model.RestSyncSetRequestModel; @@ -67,7 +68,15 @@ public class SyncServiceAPITests extends RestTest Healthcheck healthCheck = restClient.authenticateUser(adminUserModel).withPrivateAPI().doHealthCheck(); restClient.assertStatusCodeIs(HttpStatus.OK); - Assert.assertTrue(healthCheck.getHealthcheck().getActiveMQConnection().getHealthy()); + RestSyncServiceHealthCheckModel syncServiceHealthCheck = healthCheck.getHealthcheck(); + + Assert.assertTrue(syncServiceHealthCheck.getActiveMQConnection().getHealthy()); + Assert.assertTrue(syncServiceHealthCheck.getDatabaseConnection().getHealthy()); + Assert.assertTrue(syncServiceHealthCheck.getRepositoryConnection().getHealthy()); + Assert.assertTrue(syncServiceHealthCheck.getDeadlocks().getHealthy()); + Assert.assertTrue(syncServiceHealthCheck.getEventsHealthCheck().getHealthy()); + Assert.assertTrue(syncServiceHealthCheck.getSyncServiceIdCheck().getHealthy()); + Assert.assertTrue(syncServiceHealthCheck.getVersionCheck().getHealthy()); } @Test(priority = 2) From ae962c5cbe6ece4376b73a121448b2a8aa21914a Mon Sep 17 00:00:00 2001 From: mbhave Date: Tue, 9 Jan 2018 17:29:16 +0000 Subject: [PATCH 1299/1491] Added default sync service settings to properties file --- e2e-test/resources/default.properties | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/e2e-test/resources/default.properties b/e2e-test/resources/default.properties index c88f53cea..7c7516125 100644 --- a/e2e-test/resources/default.properties +++ b/e2e-test/resources/default.properties @@ -3,6 +3,11 @@ alfresco.scheme=http alfresco.server=localhost alfresco.port=8080 +# sync service related +sync.scheme=http +sync.server=localhost +sync.port=9090 + # credentials admin.user=admin admin.password=admin From 1c1058e0b7f54e047b2b85d0e76e53d56de72908 Mon Sep 17 00:00:00 2001 From: Andrei Forascu Date: Thu, 11 Jan 2018 14:41:03 +0200 Subject: [PATCH 1300/1491] REPO-2313: RestAPI: Implement tests in TAS project for 'Discovery' RestApi endpoint - added TAS sanity tests for GET /discovery endpoint --- .../rest/discovery/DiscoveryTests.java | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/discovery/DiscoveryTests.java diff --git a/e2e-test/java/org/alfresco/rest/discovery/DiscoveryTests.java b/e2e-test/java/org/alfresco/rest/discovery/DiscoveryTests.java new file mode 100644 index 000000000..451569967 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/discovery/DiscoveryTests.java @@ -0,0 +1,50 @@ +package org.alfresco.rest.discovery; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.RestResponse; +import org.alfresco.rest.model.RestDiscoveryModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class DiscoveryTests extends RestTest +{ + private UserModel adminModel, userModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminModel = dataUser.getAdminUser(); + userModel = dataUser.createRandomTestUser(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.DISCOVERY, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.DISCOVERY }, executionType = ExecutionType.SANITY, + description = "Sanity tests for GET /discovery endpoint") + public void getRepositoryInformation() throws Exception + { + // Get repository info from admin console + RestResponse adminConsoleRepoInfo = restClient.authenticateUser(adminModel).withAdminConsole().getAdminConsoleRepoInfo(); + String edition = adminConsoleRepoInfo.getResponse().getBody().path("data.edition"); + String schema = adminConsoleRepoInfo.getResponse().getBody().path("data.schema"); + String version = adminConsoleRepoInfo.getResponse().getBody().path("data.version"); + + // Get repository info using Discovery API + RestDiscoveryModel response = restClient.authenticateUser(userModel).withDiscoveryAPI().getRepositoryInfo(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + // Compare information + response.getRepository().getVersion().assertThat().field("major").is(version.charAt(0)); + response.getRepository().getVersion().assertThat().field("minor").is(version.charAt(2)); + response.getRepository().getVersion().assertThat().field("patch").is(version.charAt(4)); + response.getRepository().getVersion().assertThat().field("schema").is(schema); + response.getRepository().getEdition().equals(edition); + response.getRepository().getLicense().assertThat().field("expiresAt").isNotEmpty().and() + .field("remainingDays").isGreaterThan(0); + response.getRepository().getStatus().assertThat().field("isReadOnly").is(false); + } +} From 33fdba093eff404300ca1ebbaee9bfb95173e668 Mon Sep 17 00:00:00 2001 From: Andrei Forascu Date: Mon, 22 Jan 2018 15:14:11 +0200 Subject: [PATCH 1301/1491] REPO-2313: remove license check as license is not set on Community --- e2e-test/java/org/alfresco/rest/discovery/DiscoveryTests.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/discovery/DiscoveryTests.java b/e2e-test/java/org/alfresco/rest/discovery/DiscoveryTests.java index 451569967..ae6271040 100644 --- a/e2e-test/java/org/alfresco/rest/discovery/DiscoveryTests.java +++ b/e2e-test/java/org/alfresco/rest/discovery/DiscoveryTests.java @@ -43,8 +43,6 @@ public class DiscoveryTests extends RestTest response.getRepository().getVersion().assertThat().field("patch").is(version.charAt(4)); response.getRepository().getVersion().assertThat().field("schema").is(schema); response.getRepository().getEdition().equals(edition); - response.getRepository().getLicense().assertThat().field("expiresAt").isNotEmpty().and() - .field("remainingDays").isGreaterThan(0); response.getRepository().getStatus().assertThat().field("isReadOnly").is(false); } } From bce794fbfc0c70b5b7e0c2674dec638ebbd2500f Mon Sep 17 00:00:00 2001 From: Codrin Chirica Date: Tue, 23 Jan 2018 10:29:38 +0000 Subject: [PATCH 1302/1491] REPO-1869: Retrieve action details --- .../alfresco/rest/actions/ActionsTests.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/actions/ActionsTests.java b/e2e-test/java/org/alfresco/rest/actions/ActionsTests.java index a05ce82f3..94e61200a 100644 --- a/e2e-test/java/org/alfresco/rest/actions/ActionsTests.java +++ b/e2e-test/java/org/alfresco/rest/actions/ActionsTests.java @@ -2,6 +2,7 @@ package org.alfresco.rest.actions; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.EmptyJsonResponseException; +import org.alfresco.rest.model.RestActionDefinitionModel; import org.alfresco.rest.model.RestActionDefinitionModelsCollection; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; @@ -70,4 +71,24 @@ public class ActionsTests extends RestTest } } } + + @TestRail(section = { TestGroup.REST_API,TestGroup.ACTIONS }, executionType = ExecutionType.SANITY, + description = "Sanity test for ACTIONS endpoint GET action-definitions/{actionDefinitionId}") + @Test(groups = { TestGroup.REST_API, TestGroup.ACTIONS, TestGroup.SANITY}) + public void testGetActionDefinitionById() throws Exception + { + restClient.authenticateUser(dataContent.getAdminUser()); + + RestActionDefinitionModel restActionDefinition = restClient. + withCoreAPI(). + usingActions(). + getActionDefinitionById("add-features"); + + restClient.assertStatusCodeIs(HttpStatus.OK); + assertFalse(restActionDefinition.getId().isEmpty()); + restActionDefinition.getId().equals("add-features"); + restActionDefinition.getDescription().equals("This will add an aspect to the matched item."); + restActionDefinition.getTitle().equals("Add aspect"); + } + } From 106804933fe0021364448b6a305d61354e610592 Mon Sep 17 00:00:00 2001 From: Andrei Forascu Date: Tue, 23 Jan 2018 14:07:59 +0200 Subject: [PATCH 1303/1491] REPO-1869 - Retrieve action details - fix negative test --- .../org/alfresco/rest/actions/ActionsTests.java | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/actions/ActionsTests.java b/e2e-test/java/org/alfresco/rest/actions/ActionsTests.java index 94e61200a..4d87dcfae 100644 --- a/e2e-test/java/org/alfresco/rest/actions/ActionsTests.java +++ b/e2e-test/java/org/alfresco/rest/actions/ActionsTests.java @@ -58,17 +58,9 @@ public class ActionsTests extends RestTest { UserModel userUnauthorized = new UserModel("invalid-user", "invalid-pasword"); - try - { - restClient.authenticateUser(userUnauthorized).withCoreAPI().usingActions().listActionDefinitions(); - fail("Expected an empty JSON response exception"); - } - catch (EmptyJsonResponseException e) - { - // Since there is no JSON for a 401, the processModels directive - // will throw the EmptyJsonResponseException - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); - } + restClient.authenticateUser(userUnauthorized).withCoreAPI().usingActions().listActionDefinitions(); + + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } } From 5e67dc9f32d403eb9e03c2e222001b2de679cb59 Mon Sep 17 00:00:00 2001 From: Andrei Forascu Date: Tue, 23 Jan 2018 13:10:45 +0000 Subject: [PATCH 1304/1491] REPO-1309 - Execute an action asynchronously: --- .../alfresco/rest/actions/ActionsTests.java | 48 +++++++++++++++++-- 1 file changed, 44 insertions(+), 4 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/actions/ActionsTests.java b/e2e-test/java/org/alfresco/rest/actions/ActionsTests.java index 4d87dcfae..f85d9d8ae 100644 --- a/e2e-test/java/org/alfresco/rest/actions/ActionsTests.java +++ b/e2e-test/java/org/alfresco/rest/actions/ActionsTests.java @@ -1,21 +1,40 @@ package org.alfresco.rest.actions; +import static junit.framework.Assert.fail; +import static org.testng.Assert.assertFalse; + +import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.EmptyJsonResponseException; import org.alfresco.rest.model.RestActionDefinitionModel; import org.alfresco.rest.model.RestActionDefinitionModelsCollection; +import org.alfresco.rest.model.RestNodeModel; +import org.alfresco.utility.Utility; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; +import org.json.JSONObject; import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import static junit.framework.TestCase.fail; -import static org.testng.Assert.assertFalse; - public class ActionsTests extends RestTest { + private UserModel adminUser; + private FileModel document; + private SiteModel publicSite; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + publicSite = dataSite.createPublicRandomSite(); + document = dataContent.usingSite(publicSite).usingUser(adminUser).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + } + @TestRail(section = { TestGroup.REST_API,TestGroup.ACTIONS }, executionType = ExecutionType.SANITY, description = "Verify actions") @Test(groups = { TestGroup.REST_API, TestGroup.ACTIONS, TestGroup.SANITY}) @@ -64,6 +83,28 @@ public class ActionsTests extends RestTest } } + @TestRail(section = { TestGroup.REST_API,TestGroup.ACTIONS }, executionType = ExecutionType.SANITY, + description = "Sanity test for POST /action-executions") + @Test(groups = { TestGroup.REST_API, TestGroup.ACTIONS, TestGroup.SANITY}) + public void executeAction() throws Exception + { + JSONObject response = restClient.authenticateUser(adminUser).withCoreAPI().usingActions().executeAction("add-features", document, "aspect-name", "cm:versionable"); + restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); + + assertFalse(response.getString("id").isEmpty()); + + /* + * Get all node properties and check that action was executed and + * cm:versionable aspect was added + */ + Utility.sleep(500, 20000, () -> { + RestNodeModel fileModel = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(document).getNode(); + + restClient.assertStatusCodeIs(HttpStatus.OK); + fileModel.assertThat().field("aspectNames").contains("cm:versionable"); + }); + } + @TestRail(section = { TestGroup.REST_API,TestGroup.ACTIONS }, executionType = ExecutionType.SANITY, description = "Sanity test for ACTIONS endpoint GET action-definitions/{actionDefinitionId}") @Test(groups = { TestGroup.REST_API, TestGroup.ACTIONS, TestGroup.SANITY}) @@ -82,5 +123,4 @@ public class ActionsTests extends RestTest restActionDefinition.getDescription().equals("This will add an aspect to the matched item."); restActionDefinition.getTitle().equals("Add aspect"); } - } From 68e3afd78b82fedd45c94860d6c93248a4cf9994 Mon Sep 17 00:00:00 2001 From: mbhave Date: Thu, 25 Jan 2018 15:22:57 +0000 Subject: [PATCH 1305/1491] Corrected Formatting --- .../rest/syncService/SyncServiceAPITests.java | 71 +++++++++---------- 1 file changed, 33 insertions(+), 38 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/syncService/SyncServiceAPITests.java b/e2e-test/java/org/alfresco/rest/syncService/SyncServiceAPITests.java index 2bad98400..58dacb907 100644 --- a/e2e-test/java/org/alfresco/rest/syncService/SyncServiceAPITests.java +++ b/e2e-test/java/org/alfresco/rest/syncService/SyncServiceAPITests.java @@ -30,7 +30,7 @@ import org.testng.annotations.Test; * * @author mbhave */ -@Test(groups = {TestGroup.SYNC_API, TestGroup.REQUIRES_AMP}) +@Test(groups = { TestGroup.SYNC_API, TestGroup.REQUIRES_AMP }) public class SyncServiceAPITests extends RestTest { private static Logger LOG = LogFactory.getLogger(); @@ -41,7 +41,7 @@ public class SyncServiceAPITests extends RestTest private FolderModel targetFolder2; private RestSyncNodeSubscriptionModelCollection nodeSubscriptions; - + private String clientVersion; @BeforeClass(alwaysRun = true) @@ -51,25 +51,24 @@ public class SyncServiceAPITests extends RestTest restClient.authenticateUser(adminUserModel); siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - + targetFolder1 = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); targetFolder2 = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); siteModel.setGuid(restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(siteModel).getSite().getGuidWithoutVersion()); - + clientVersion = "1.1"; } @Test(priority = 1) public void testSyncServiceHealthCheck() throws Exception { - // Register Device + // Perform HealthCheck Healthcheck healthCheck = restClient.authenticateUser(adminUserModel).withPrivateAPI().doHealthCheck(); - restClient.assertStatusCodeIs(HttpStatus.OK); - + RestSyncServiceHealthCheckModel syncServiceHealthCheck = healthCheck.getHealthcheck(); - + Assert.assertTrue(syncServiceHealthCheck.getActiveMQConnection().getHealthy()); Assert.assertTrue(syncServiceHealthCheck.getDatabaseConnection().getHealthy()); Assert.assertTrue(syncServiceHealthCheck.getRepositoryConnection().getHealthy()); @@ -78,39 +77,40 @@ public class SyncServiceAPITests extends RestTest Assert.assertTrue(syncServiceHealthCheck.getSyncServiceIdCheck().getHealthy()); Assert.assertTrue(syncServiceHealthCheck.getVersionCheck().getHealthy()); } - + @Test(priority = 2) public void testNewDeviceSubscription() throws Exception { // Register Device - RestSubscriberModel deviceSubscription = restClient.authenticateUser(adminUserModel).withPrivateAPI().withSubscribers().registerDevice("windows", clientVersion); + RestSubscriberModel deviceSubscription = restClient.authenticateUser(adminUserModel).withPrivateAPI().withSubscribers() + .registerDevice("windows", clientVersion); restClient.assertStatusCodeIs(HttpStatus.CREATED); restClient.onResponse().assertThat().body("entry.id", org.hamcrest.Matchers.notNullValue()); restClient.onResponse().assertThat().body("entry.id", org.hamcrest.Matchers.equalTo(deviceSubscription.getId())); // Get Registered Devices - RestSubscriberModelCollection deviceSubscriptions = restClient.authenticateUser(adminUserModel).withParams("maxItems=500").withPrivateAPI().withSubscribers().getSubscribers(); + RestSubscriberModelCollection deviceSubscriptions = restClient.authenticateUser(adminUserModel).withParams("maxItems=500").withPrivateAPI() + .withSubscribers().getSubscribers(); restClient.onResponse().assertThat().body("list.entries.entry", org.hamcrest.Matchers.notNullValue()); int noOfSubscriptions = deviceSubscriptions.getEntries().size(); Assert.assertTrue(noOfSubscriptions > 0, "No Device subscriptions found when expected"); - Assert.assertTrue(deviceSubscriptions.getEntries().get(noOfSubscriptions - 1).onModel().getId().equals(deviceSubscription.getId()),"Not found: " + deviceSubscription.getId()); + Assert.assertTrue(deviceSubscriptions.getEntries().get(noOfSubscriptions - 1).onModel().getId().equals(deviceSubscription.getId()), "Not found: " + + deviceSubscription.getId()); } - + @Test(priority = 3) public void testDeviceSubcriptionToNode() throws Exception { // Register Device - RestSubscriberModel deviceSubscription = restClient.authenticateUser(adminUserModel).withPrivateAPI().withSubscribers().registerDevice("windows", - clientVersion); + RestSubscriberModel deviceSubscription = restClient.authenticateUser(adminUserModel).withPrivateAPI().withSubscribers() + .registerDevice("windows", clientVersion); // Subscribe to a node - RestSyncNodeSubscriptionModel nodeSubscription = restClient - .withPrivateAPI() - .withSubscriber(deviceSubscription) - .subscribeToNode(targetFolder1.getNodeRefWithoutVersion(), TYPE.BOTH); + RestSyncNodeSubscriptionModel nodeSubscription = restClient.withPrivateAPI().withSubscriber(deviceSubscription) + .subscribeToNode(targetFolder1.getNodeRefWithoutVersion(), TYPE.BOTH); restClient.assertStatusCodeIs(HttpStatus.CREATED); restClient.onResponse().assertThat().body("entry.deviceSubscriptionId", org.hamcrest.Matchers.notNullValue()); @@ -142,17 +142,17 @@ public class SyncServiceAPITests extends RestTest subscription.assertThat().field("id").isNotNull().assertThat().field("id").is(nodeSubscription.getId()).assertThat().field("deviceSubscriptionId") .isNotNull().assertThat().field("deviceSubscriptionId").is(nodeSubscription.getDeviceSubscriptionId()); } - + @Test(priority = 4) public void testDeviceSubcriptionToMultipleNodes() throws Exception { // Register Device - RestSubscriberModel deviceSubscription = restClient.authenticateUser(adminUserModel).withPrivateAPI().withSubscribers().registerDevice("windows", - "1.2"); + RestSubscriberModel deviceSubscription = restClient.authenticateUser(adminUserModel).withPrivateAPI().withSubscribers() + .registerDevice("windows", "1.2"); // Subscribe to a node - restClient.withPrivateAPI().withSubscriber(deviceSubscription).subscribeToNodes(siteModel.getGuid(), targetFolder1.getNodeRefWithoutVersion(), - targetFolder2.getNodeRefWithoutVersion()); + restClient.withPrivateAPI().withSubscriber(deviceSubscription) + .subscribeToNodes(siteModel.getGuid(), targetFolder1.getNodeRefWithoutVersion(), targetFolder2.getNodeRefWithoutVersion()); restClient.assertStatusCodeIs(HttpStatus.CREATED); // Get Sync Node Subscriptions @@ -167,23 +167,18 @@ public class SyncServiceAPITests extends RestTest { // Register Device List clientChanges = new LinkedList<>(); - RestSubscriberModel deviceSubscription = restClient.authenticateUser(adminUserModel) - .withPrivateAPI() - .withSubscribers() - .registerDevice("windows","1.2"); + RestSubscriberModel deviceSubscription = restClient.authenticateUser(adminUserModel).withPrivateAPI().withSubscribers() + .registerDevice("windows", "1.2"); // Subscribe to a node - RestSyncNodeSubscriptionModel nodeSubscription = restClient.withPrivateAPI() - .withSubscriber(deviceSubscription) - .subscribeToNode(targetFolder1.getNodeRefWithoutVersion(), TYPE.BOTH); + RestSyncNodeSubscriptionModel nodeSubscription = restClient.withPrivateAPI().withSubscriber(deviceSubscription) + .subscribeToNode(targetFolder1.getNodeRefWithoutVersion(), TYPE.BOTH); restClient.assertStatusCodeIs(HttpStatus.CREATED); // Start Sync - RestSyncSetRequestModel syncRequest = restClient.authenticateUser(adminUserModel) - .withPrivateAPI() - .withSubscription(nodeSubscription) - .startSync(nodeSubscription, clientChanges, clientVersion); - + RestSyncSetRequestModel syncRequest = restClient.authenticateUser(adminUserModel).withPrivateAPI().withSubscription(nodeSubscription) + .startSync(nodeSubscription, clientChanges, clientVersion); + restClient.assertStatusCodeIs(HttpStatus.CREATED); Assert.assertNotNull(syncRequest.getSyncId(), "Sync Id not expected to be null"); @@ -196,14 +191,14 @@ public class SyncServiceAPITests extends RestTest // Get Sync Changes RestSyncSetGetModel changeSet = restClient.withPrivateAPI().withSubscription(nodeSubscription).getSync(nodeSubscription, syncRequest); - + restClient.assertStatusCodeIs(HttpStatus.OK); Assert.assertNotNull(changeSet.getSyncId(), "Sync Id not expected to be null"); Assert.assertTrue(changeSet.getSyncId().equals(syncId), "Incorrect SyncId in the response"); Assert.assertNotNull(changeSet.getMoreChanges(), "MoreChanges expected to be true or false. It's null"); // End Sync - restClient.withPrivateAPI().withSubscription(nodeSubscription).endSync(nodeSubscription,syncRequest); + restClient.withPrivateAPI().withSubscription(nodeSubscription).endSync(nodeSubscription, syncRequest); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } } From 49448493d3181d139b6f327ceb23c5a3494101fe Mon Sep 17 00:00:00 2001 From: Tuna Aksoy Date: Fri, 26 Jan 2018 13:37:17 +0000 Subject: [PATCH 1306/1491] SEARCH-574 (Add publc admin API to expose index shard status) --- .../alfresco/rest/search/ShardInfoTest.java | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/search/ShardInfoTest.java diff --git a/e2e-test/java/org/alfresco/rest/search/ShardInfoTest.java b/e2e-test/java/org/alfresco/rest/search/ShardInfoTest.java new file mode 100644 index 000000000..190fa1b8f --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/search/ShardInfoTest.java @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2005-2018 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.rest.search; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertTrue; + +import java.util.List; + +import org.alfresco.utility.model.TestGroup; +import org.springframework.http.HttpStatus; +import org.testng.annotations.Test; + +/** + * Shard info end point REST API test. + * + * @author Tuna Aksoy + */ +public class ShardInfoTest extends AbstractSearchTest +{ + @Test(groups={TestGroup.SEARCH, TestGroup.REST_API}) + public void getShardInfoWithAdminAuthority() throws Exception + { + RestShardInfoModelCollection info = restClient.authenticateUser(dataUser.getAdminUser()).withShardInfoAPI().getInfo(); + restClient.assertStatusCodeIs(HttpStatus.OK); + info.assertThat().entriesListIsNotEmpty(); + RestShardInfoModel shardInfoModel = info.getEntryByIndex(0); + assertEquals(shardInfoModel.getTemplate(), "rerank"); + assertEquals(shardInfoModel.getMode(), "MASTER"); + assertEquals(shardInfoModel.getShardMethod(), "DB_ID"); + assertTrue(shardInfoModel.getHasContent()); + List shards = shardInfoModel.getShards(); + assertNotNull(shards); + RestShardModel shard = shards.iterator().next(); + assertNotNull(shard); + List instances = shard.getInstances(); + assertNotNull(instances); + RestInstanceModel instance = instances.iterator().next(); + assertNotNull(instance); + assertEquals(instance.getBaseUrl(), "/solr/archive"); + assertEquals(instance.getHost(), "localhost"); + assertEquals(instance.getPort().intValue(), 8983); + assertEquals(instance.getState(), "ACTIVE"); + assertEquals(instance.getMode(), "MASTER"); + } + + @Test(groups={TestGroup.SEARCH, TestGroup.REST_API}) + public void getShardInfoWithoutAdminAuthority() throws Exception + { + restClient.authenticateUser(dataUser.createRandomTestUser()).withShardInfoAPI().getInfo(); + restClient.assertStatusCodeIs(HttpStatus.INTERNAL_SERVER_ERROR); + } +} From 9e7a2688e8e5d2ed41e7f963355f942634419a25 Mon Sep 17 00:00:00 2001 From: Cristian Turlica Date: Tue, 30 Jan 2018 13:40:54 +0200 Subject: [PATCH 1307/1491] REPO-2372: Add repository ID to the discovery API - added test --- e2e-test/java/org/alfresco/rest/discovery/DiscoveryTests.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/discovery/DiscoveryTests.java b/e2e-test/java/org/alfresco/rest/discovery/DiscoveryTests.java index ae6271040..66b7329fc 100644 --- a/e2e-test/java/org/alfresco/rest/discovery/DiscoveryTests.java +++ b/e2e-test/java/org/alfresco/rest/discovery/DiscoveryTests.java @@ -29,6 +29,7 @@ public class DiscoveryTests extends RestTest { // Get repository info from admin console RestResponse adminConsoleRepoInfo = restClient.authenticateUser(adminModel).withAdminConsole().getAdminConsoleRepoInfo(); + String id = adminConsoleRepoInfo.getResponse().getBody().path("data.id"); String edition = adminConsoleRepoInfo.getResponse().getBody().path("data.edition"); String schema = adminConsoleRepoInfo.getResponse().getBody().path("data.schema"); String version = adminConsoleRepoInfo.getResponse().getBody().path("data.version"); @@ -42,6 +43,7 @@ public class DiscoveryTests extends RestTest response.getRepository().getVersion().assertThat().field("minor").is(version.charAt(2)); response.getRepository().getVersion().assertThat().field("patch").is(version.charAt(4)); response.getRepository().getVersion().assertThat().field("schema").is(schema); + response.getRepository().getId().equals(id); response.getRepository().getEdition().equals(edition); response.getRepository().getStatus().assertThat().field("isReadOnly").is(false); } From c5fe8b9e5bf4d9293551669e1ed48aa9cf7b345c Mon Sep 17 00:00:00 2001 From: Tuna Aksoy Date: Tue, 30 Jan 2018 16:38:59 +0000 Subject: [PATCH 1308/1491] SEARCH-574: Addressed review comments --- .../alfresco/rest/search/ShardInfoTest.java | 52 ++++++++++++------- 1 file changed, 33 insertions(+), 19 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/ShardInfoTest.java b/e2e-test/java/org/alfresco/rest/search/ShardInfoTest.java index 190fa1b8f..d7075f41b 100644 --- a/e2e-test/java/org/alfresco/rest/search/ShardInfoTest.java +++ b/e2e-test/java/org/alfresco/rest/search/ShardInfoTest.java @@ -22,8 +22,12 @@ import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertTrue; +import java.util.Arrays; import java.util.List; +import com.fasterxml.jackson.core.JsonProcessingException; + +import org.alfresco.rest.exception.EmptyRestModelCollectionException; import org.alfresco.utility.model.TestGroup; import org.springframework.http.HttpStatus; import org.testng.annotations.Test; @@ -36,29 +40,39 @@ import org.testng.annotations.Test; public class ShardInfoTest extends AbstractSearchTest { @Test(groups={TestGroup.SEARCH, TestGroup.REST_API}) - public void getShardInfoWithAdminAuthority() throws Exception + public void getShardInfoWithAdminAuthority() throws JsonProcessingException, EmptyRestModelCollectionException { RestShardInfoModelCollection info = restClient.authenticateUser(dataUser.getAdminUser()).withShardInfoAPI().getInfo(); restClient.assertStatusCodeIs(HttpStatus.OK); info.assertThat().entriesListIsNotEmpty(); - RestShardInfoModel shardInfoModel = info.getEntryByIndex(0); - assertEquals(shardInfoModel.getTemplate(), "rerank"); - assertEquals(shardInfoModel.getMode(), "MASTER"); - assertEquals(shardInfoModel.getShardMethod(), "DB_ID"); - assertTrue(shardInfoModel.getHasContent()); - List shards = shardInfoModel.getShards(); - assertNotNull(shards); - RestShardModel shard = shards.iterator().next(); - assertNotNull(shard); - List instances = shard.getInstances(); - assertNotNull(instances); - RestInstanceModel instance = instances.iterator().next(); - assertNotNull(instance); - assertEquals(instance.getBaseUrl(), "/solr/archive"); - assertEquals(instance.getHost(), "localhost"); - assertEquals(instance.getPort().intValue(), 8983); - assertEquals(instance.getState(), "ACTIVE"); - assertEquals(instance.getMode(), "MASTER"); + assertEquals(info.getPagination().getTotalItems().intValue(), 2); + + List stores = Arrays.asList("workspace://SpacesStore", "archive://SpacesStore"); + List baseUrls = Arrays.asList("/solr/alfresco", "/solr/archive"); + + List entries = info.getEntries(); + for (RestShardInfoModel shardInfoModel : entries) + { + RestShardInfoModel model = shardInfoModel.getModel(); + assertEquals(model.getTemplate(), "rerank"); + assertEquals(model.getMode(), "MASTER"); + assertEquals(model.getShardMethod(), "DB_ID"); + assertTrue(model.getHasContent()); + stores.contains(model.getStores()); + List shards = model.getShards(); + assertNotNull(shards); + RestShardModel shard = shards.iterator().next(); + assertNotNull(shard); + List instances = shard.getInstances(); + assertNotNull(instances); + RestInstanceModel instance = instances.iterator().next(); + assertNotNull(instance); + baseUrls.contains(instance.getBaseUrl()); + assertEquals(instance.getHost(), "localhost"); + assertEquals(instance.getPort().intValue(), 8983); + assertEquals(instance.getState(), "ACTIVE"); + assertEquals(instance.getMode(), "MASTER"); + } } @Test(groups={TestGroup.SEARCH, TestGroup.REST_API}) From 503b9b121c66d9088702e7f3ea3512c5e03535ed Mon Sep 17 00:00:00 2001 From: Tuna Aksoy Date: Tue, 30 Jan 2018 17:01:12 +0000 Subject: [PATCH 1309/1491] SEARCH-574: Annotated the tests as it depends on an open issue. --- e2e-test/java/org/alfresco/rest/search/ShardInfoTest.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/search/ShardInfoTest.java b/e2e-test/java/org/alfresco/rest/search/ShardInfoTest.java index d7075f41b..abc59ff03 100644 --- a/e2e-test/java/org/alfresco/rest/search/ShardInfoTest.java +++ b/e2e-test/java/org/alfresco/rest/search/ShardInfoTest.java @@ -29,6 +29,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import org.alfresco.rest.exception.EmptyRestModelCollectionException; import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.report.Bug; import org.springframework.http.HttpStatus; import org.testng.annotations.Test; @@ -39,6 +40,7 @@ import org.testng.annotations.Test; */ public class ShardInfoTest extends AbstractSearchTest { + @Bug(id="DELENG-1", status=Bug.Status.OPENED) @Test(groups={TestGroup.SEARCH, TestGroup.REST_API}) public void getShardInfoWithAdminAuthority() throws JsonProcessingException, EmptyRestModelCollectionException { @@ -75,6 +77,7 @@ public class ShardInfoTest extends AbstractSearchTest } } + @Bug(id="DELENG-1", status=Bug.Status.OPENED) @Test(groups={TestGroup.SEARCH, TestGroup.REST_API}) public void getShardInfoWithoutAdminAuthority() throws Exception { From 9d6ceca536d304ca39a9fd8cd1efb0281b829c7d Mon Sep 17 00:00:00 2001 From: Andrei Forascu Date: Wed, 31 Jan 2018 15:25:40 +0200 Subject: [PATCH 1310/1491] REPO-2279 / REPO-2284: RestAPI: Implement tests in TAS project for 'Downloads' RestApi endpoint - part 1/2 - added TAS sanity tests for GET /downloads/{downloadId}, POST /downloads and DELETE /downloads/{downloadId} - to test DELETE /downloads/{downloadId} we use a large pdf file (27 MB) which was added in shared-resources --- .../rest/downloads/DownloadsTests.java | 106 ++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/downloads/DownloadsTests.java diff --git a/e2e-test/java/org/alfresco/rest/downloads/DownloadsTests.java b/e2e-test/java/org/alfresco/rest/downloads/DownloadsTests.java new file mode 100644 index 000000000..054801807 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/downloads/DownloadsTests.java @@ -0,0 +1,106 @@ +package org.alfresco.rest.downloads; + +import javax.json.JsonObject; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.JsonBodyGenerator; +import org.alfresco.rest.model.RestDownloadsModel; +import org.alfresco.utility.Utility; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class DownloadsTests extends RestTest +{ + private UserModel adminModel; + private FileModel document, document1; + private FolderModel folder; + private SiteModel siteModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminModel = dataUser.getAdminUser(); + siteModel = dataSite.usingUser(adminModel).createPrivateRandomSite(); + folder = dataContent.usingUser(adminModel).usingSite(siteModel).createFolder(); + document = dataContent.usingSite(siteModel).usingUser(adminModel).createContent(DocumentType.TEXT_PLAIN); + + // Create document1 based on existing resource + FileModel newFile = FileModel.getFileModelBasedOnTestDataFile("larger.pdf"); + newFile.setName("larger.pdf"); + document1 = dataContent.usingUser(adminModel).usingResource(folder).createContent(newFile); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.DOWNLOADS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.DOWNLOADS }, executionType = ExecutionType.SANITY, + description = "Sanity tests for GET /downloads/{downloadId} and POST /downloads") + public void createDownloadNodeAndGetInfo() throws Exception + { + // POST /downloads + JsonObject postBody = JsonBodyGenerator.defineJSON() + .add("nodeIds", JsonBodyGenerator.defineJSONArray().add(document.getNodeRefWithoutVersion())) + .build(); + RestDownloadsModel downloadModel = restClient.authenticateUser(adminModel).withCoreAPI().usingDownloads().createDownload(postBody.toString()); + restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); + downloadModel.assertThat().fieldsCount().is(6).and() + .field("id").isNotEmpty(); + + // GET /downloads/{downloadId} + Utility.sleep(500, 10000, () -> { + RestDownloadsModel downloadModel1 = restClient.authenticateUser(adminModel).withCoreAPI().usingDownloads(downloadModel).getDownload(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + downloadModel1.assertThat().fieldsCount().is(6).and() + .field("id").is(downloadModel.getId()).and() + .field("filesAdded").isGreaterThan(0).and() + .field("bytesAdded").isGreaterThan(0).and() + .field("totalBytes").isGreaterThan(0).and() + .field("totalFiles").isGreaterThan(0).and() + .field("status").is("DONE"); + }); + + // Check that download node has content + restClient.authenticateUser(adminModel).withCoreAPI().usingNode().getNodeContent(downloadModel.getId()); + + restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.assertHeaderValueContains("Content-Type","application/octet-stream;charset=UTF-8"); + restClient.assertHeaderValueContains("Content-disposition",".zip"); + Assert.assertTrue(restClient.onResponse().getResponse().body().asInputStream().available() > 0); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.DOWNLOADS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.DOWNLOADS }, executionType = ExecutionType.SANITY, + description = "Sanity tests for DELETE /downloads/{downloadId}") + public void cancelDownloadNode() throws Exception + { + // POST /downloads + String postBody = JsonBodyGenerator.defineJSON() + .add("nodeIds", JsonBodyGenerator.defineJSONArray().add(document1.getNodeRefWithoutVersion())) + .build().toString(); + RestDownloadsModel downloadModel = restClient.authenticateUser(adminModel).withCoreAPI().usingDownloads().createDownload(postBody); + + /* + * DELETE /downloads/{downloadId} + * Download canceling is async and it works only if download status is not "DONE" + * To have this case, a large pdf file was used that takes a longer time to download + */ + restClient.authenticateUser(adminModel).withCoreAPI().usingDownloads(downloadModel).cancelDownload(); + restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); + + // GET /downloads/{downloadId} to check that the download is canceled + Utility.sleep(500, 10000, () -> { + RestDownloadsModel downloadModel1 = restClient.authenticateUser(adminModel).withCoreAPI().usingDownloads(downloadModel).getDownload(); + restClient.assertStatusCodeIs(HttpStatus.OK); + downloadModel1.assertThat().field("status").is("CANCELLED"); + }); + } +} From ee2121591aaf75e6701137edd21568b76b2505d6 Mon Sep 17 00:00:00 2001 From: Andrei Bazavan Date: Fri, 9 Feb 2018 11:43:21 +0000 Subject: [PATCH 1311/1491] Feature/REPO-3206: Lucene based tests for lock service impl test --- .../alfresco/rest/nodes/NodesLockTests.java | 96 ++++++++++++++++++- 1 file changed, 94 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/nodes/NodesLockTests.java b/e2e-test/java/org/alfresco/rest/nodes/NodesLockTests.java index e5eb760a9..2e2d50bd5 100644 --- a/e2e-test/java/org/alfresco/rest/nodes/NodesLockTests.java +++ b/e2e-test/java/org/alfresco/rest/nodes/NodesLockTests.java @@ -1,14 +1,18 @@ package org.alfresco.rest.nodes; -import static org.alfresco.utility.report.log.Step.STEP; - import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestNodeModel; import org.alfresco.rest.model.body.RestNodeLockBodyModel; +import org.alfresco.rest.search.RestRequestFilterQueryModel; +import org.alfresco.rest.search.RestRequestQueryModel; +import org.alfresco.rest.search.SearchRequest; +import org.alfresco.rest.search.SearchResponse; +import org.alfresco.utility.Utility; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; @@ -20,6 +24,8 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import static org.alfresco.utility.report.log.Step.STEP; + public class NodesLockTests extends RestTest { private UserModel user1, user2, adminUser; @@ -666,4 +672,90 @@ public class NodesLockTests extends RestTest .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); } + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, + description = "Verify that child nodes can be locked differently and unlocked") + public void testLockUnlockParentChild() throws Exception + { + STEP("1. Create user, site, parent node and children nodes."); + SiteModel siteLock = dataSite.usingUser(adminUser).createPublicRandomSite(); + FolderModel parentNode = dataContent.usingUser(adminUser).usingSite(siteLock).createFolder(); + FileModel childNode1 = dataContent.usingUser(adminUser).usingSite(siteLock).usingResource(parentNode).createContent(DocumentType.TEXT_PLAIN); + FileModel childNode2 = dataContent.usingUser(adminUser).usingSite(siteLock).usingResource(parentNode).createContent(DocumentType.TEXT_PLAIN); + + STEP("2. Verify with admin that the file is not locked."); + RestNodeModel restNodeResponse = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(parentNode).usingParams("include=isLocked").getNode(); + restNodeResponse.assertThat().field("isLocked").is(false); + + restNodeResponse = restClient.withCoreAPI().usingNode(childNode1).usingParams("include=isLocked").getNode(); + restNodeResponse.assertThat().field("isLocked").is(false); + + restNodeResponse = restClient.withCoreAPI().usingNode(childNode2).usingParams("include=isLocked").getNode(); + restNodeResponse.assertThat().field("isLocked").is(false); + + STEP("3. Lock childNode1 using mode PERSISTENT with adminUser (POST nodes/{nodeId}/lock)."); + RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); + lockBodyModel.setLifetime("PERSISTENT"); + lockBodyModel.setTimeToExpire(0); + lockBodyModel.setType("ALLOW_OWNER_CHANGES"); + restNodeResponse = restClient.withCoreAPI().usingNode(childNode1).usingParams("include=isLocked").lockNode(lockBodyModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + restNodeResponse.assertThat().field("aspectNames").contains("cm:lockable") + .assertThat().field("isLocked").is(true) + .assertThat().field("properties").contains("lockLifetime=PERSISTENT") + .assertThat().field("properties").contains("lockType=WRITE_LOCK"); + + STEP("4. Lock childNode2 using mode PERSISTENT with adminUser (POST nodes/{nodeId}/lock)."); + lockBodyModel = new RestNodeLockBodyModel(); + lockBodyModel.setLifetime("PERSISTENT"); + lockBodyModel.setTimeToExpire(0); + lockBodyModel.setType("FULL"); + restNodeResponse = restClient.withCoreAPI().usingNode(childNode2).usingParams("include=isLocked").lockNode(lockBodyModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + restNodeResponse.assertThat().field("aspectNames").contains("cm:lockable") + .assertThat().field("isLocked").is(true) + .assertThat().field("properties").contains("lockLifetime=PERSISTENT") + .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); + + STEP("5. Verify that childNode1 and childNode 2 are locked."); + SearchRequest query = new SearchRequest(); + RestRequestQueryModel queryReq = new RestRequestQueryModel(); + RestRequestFilterQueryModel queryFilters = new RestRequestFilterQueryModel(); + queryFilters.setQuery("cm:lockOwner:\'admin\'"); + queryReq.setQuery("ASPECT:\'cm:lockable\'"); + query.setQuery(queryReq); + query.setFilterQueries(queryFilters); + query.setIncludeRequest(false); + + // Allow indexing to complete. + Utility.sleep(1000, 60000, () -> + { + SearchResponse response = query(query); + restClient.assertStatusCodeIs(HttpStatus.OK); + response.assertThat().entriesListContains("id",childNode1.getNodeRefWithoutVersion()); + response.assertThat().entriesListContains("id",childNode2.getNodeRefWithoutVersion()); + }); + + STEP("6. Unlock the nodes."); + restNodeResponse = restClient.withCoreAPI().usingNode(childNode1).usingParams("include=isLocked").unlockNode(); + restNodeResponse.assertThat().field("isLocked").is(false); + + restNodeResponse = restClient.withCoreAPI().usingNode(childNode2).usingParams("include=isLocked").unlockNode(); + restNodeResponse.assertThat().field("isLocked").is(false); + + STEP("7. Verify that childNode1 and childNode2 are not found in the query results."); + // Allow indexing to complete. + Utility.sleep(1000, 60000, () -> + { + SearchResponse response = query(query); + restClient.assertStatusCodeIs(HttpStatus.OK); + response.assertThat().entriesListDoesNotContain("id",childNode1.getNodeRefWithoutVersion()); + response.assertThat().entriesListDoesNotContain("id",childNode2.getNodeRefWithoutVersion()); + }); + } + + protected SearchResponse query(SearchRequest query) throws Exception + { + return restClient.authenticateUser(dataUser.getAdminUser()).withSearchAPI().search(query); + } } From 5272ff4b446b470f432ccc0d64548955da73659c Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Fri, 9 Feb 2018 15:09:01 +0200 Subject: [PATCH 1312/1491] fix package naming --- .../org/alfresco/rest/sharedlinks/GetSharedLinksFullTests.java | 2 +- .../org/alfresco/rest/sharedlinks/SharedLinksSanityTests.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/sharedlinks/GetSharedLinksFullTests.java b/e2e-test/java/org/alfresco/rest/sharedlinks/GetSharedLinksFullTests.java index ea227d4dd..c2e3627a6 100644 --- a/e2e-test/java/org/alfresco/rest/sharedlinks/GetSharedLinksFullTests.java +++ b/e2e-test/java/org/alfresco/rest/sharedlinks/GetSharedLinksFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sharedlinks; +package org.alfresco.rest.sharedLinks; import javax.json.Json; import javax.json.JsonObject; diff --git a/e2e-test/java/org/alfresco/rest/sharedlinks/SharedLinksSanityTests.java b/e2e-test/java/org/alfresco/rest/sharedlinks/SharedLinksSanityTests.java index 6e266836c..cb707a713 100644 --- a/e2e-test/java/org/alfresco/rest/sharedlinks/SharedLinksSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sharedlinks/SharedLinksSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sharedlinks; +package org.alfresco.rest.sharedLinks; import static org.testng.Assert.assertEquals; From 6605c0fbdc590a5359aa61f25b9b308ae404c750 Mon Sep 17 00:00:00 2001 From: "andrei.bazavan" Date: Fri, 9 Feb 2018 15:28:02 +0200 Subject: [PATCH 1313/1491] Rewrite Lucene-based Tests in TAS for LockServiceImplTest: testEphemeralLockIndexing and testGetLocks in testLockUnlockParentChild --- e2e-test/java/org/alfresco/rest/nodes/NodesLockTests.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/nodes/NodesLockTests.java b/e2e-test/java/org/alfresco/rest/nodes/NodesLockTests.java index 2e2d50bd5..e02401e6f 100644 --- a/e2e-test/java/org/alfresco/rest/nodes/NodesLockTests.java +++ b/e2e-test/java/org/alfresco/rest/nodes/NodesLockTests.java @@ -728,7 +728,7 @@ public class NodesLockTests extends RestTest query.setIncludeRequest(false); // Allow indexing to complete. - Utility.sleep(1000, 60000, () -> + Utility.sleep(1000, 180000, () -> { SearchResponse response = query(query); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -745,7 +745,7 @@ public class NodesLockTests extends RestTest STEP("7. Verify that childNode1 and childNode2 are not found in the query results."); // Allow indexing to complete. - Utility.sleep(1000, 60000, () -> + Utility.sleep(1000, 180000, () -> { SearchResponse response = query(query); restClient.assertStatusCodeIs(HttpStatus.OK); From 0ae01930412df0ef0e3cb96055c6b99b0dd48cab Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Fri, 9 Feb 2018 16:32:27 +0200 Subject: [PATCH 1314/1491] update package on sharedLinkes --- .../{sharedlinks => sharedLinks}/GetSharedLinksFullTests.java | 0 .../rest/{sharedlinks => sharedLinks}/SharedLinksSanityTests.java | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename e2e-test/java/org/alfresco/rest/{sharedlinks => sharedLinks}/GetSharedLinksFullTests.java (100%) rename e2e-test/java/org/alfresco/rest/{sharedlinks => sharedLinks}/SharedLinksSanityTests.java (100%) diff --git a/e2e-test/java/org/alfresco/rest/sharedlinks/GetSharedLinksFullTests.java b/e2e-test/java/org/alfresco/rest/sharedLinks/GetSharedLinksFullTests.java similarity index 100% rename from e2e-test/java/org/alfresco/rest/sharedlinks/GetSharedLinksFullTests.java rename to e2e-test/java/org/alfresco/rest/sharedLinks/GetSharedLinksFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/sharedlinks/SharedLinksSanityTests.java b/e2e-test/java/org/alfresco/rest/sharedLinks/SharedLinksSanityTests.java similarity index 100% rename from e2e-test/java/org/alfresco/rest/sharedlinks/SharedLinksSanityTests.java rename to e2e-test/java/org/alfresco/rest/sharedLinks/SharedLinksSanityTests.java From 7a5693f675f2535f11841064ea20256202e69ffa Mon Sep 17 00:00:00 2001 From: Andrei Forascu Date: Wed, 14 Feb 2018 13:28:48 +0000 Subject: [PATCH 1315/1491] REPO-3206 - Rewrite Lucene-based Tests in TAS for LockServiceImplTest --- .../rest/favorites/GetFavoriteSiteTests.java | 13 ------------- .../rest/favorites/GetFavoriteSitesTests.java | 18 ------------------ .../rest/favorites/GetFavoritesTests.java | 13 ------------- .../org/alfresco/rest/groups/GroupsTests.java | 1 + .../alfresco/rest/nodes/NodesLockTests.java | 6 +++--- .../rest/people/GetPeopleFullTests.java | 16 ---------------- .../org/alfresco/rest/tags/GetTagTests.java | 1 + .../org/alfresco/rest/tags/GetTagsTests.java | 1 + .../org/alfresco/rest/tags/TagsDataPrep.java | 3 +++ .../org/alfresco/rest/tags/UpdateTagTests.java | 1 + .../alfresco/rest/tags/nodes/AddTagTests.java | 1 + .../alfresco/rest/tags/nodes/AddTagsTests.java | 1 + .../rest/tags/nodes/DeleteTagTests.java | 1 + .../rest/tags/nodes/GetNodeTagsTests.java | 1 + .../rest/trashcan/GetDeletedNodesTests.java | 12 +++++------- 15 files changed, 19 insertions(+), 70 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSiteTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSiteTests.java index 4c5803c6d..4accab458 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSiteTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSiteTests.java @@ -174,19 +174,6 @@ public class GetFavoriteSiteTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify invalid request returns status 404 when personId is invalid") - public void getFavoriteSiteWithInvalidPersonId() throws Exception - { - UserModel userSpecialChars = dataUser.usingAdmin().createUser(RandomStringUtils.randomAlphabetic(2) + "~!@#$%^&*()_+[]{}|;'d", "password"); - userSpecialChars.setUsername(RandomStringUtils.randomAlphabetic(2) + "~!%40%23%24%25%5E%26*()_%2B%5B%5D%7B%7D%7C%5C%3B%27%3A%22%2C.%2F%3C%3E"); - - restClient.authenticateUser(userModel).withCoreAPI().usingUser(userSpecialChars).getFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, userSpecialChars.getUsername())); - } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify request with empty site id") diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSitesTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSitesTests.java index bc9b0dda8..db6dd2f90 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSitesTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSitesTests.java @@ -287,24 +287,6 @@ public class GetFavoriteSitesTests extends RestTest .assertThat().paginationField("skipCount").is("999999999"); } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify admin gets favorite sites for username with special chars with Rest API and response status is NOT_FOUND (404)") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void getFavoriteSitesRequestForPersonIDWithSpecialCharacters() throws Exception - { - String randomData = RandomData.getRandomAlphanumeric(); - UserModel userSpecialChars = dataUser.usingAdmin().createUser(randomData + "~!@#$%^&[]{}|\\;':\",./<>", "password"); - //setting the encoded text for username - userSpecialChars.setUsername(randomData + "~!%40%23%24%25%5E%26%5B%5D%7B%7D%7C%5C%3B%27%3A%22%2C.%2F%3C%3E"); - - restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingUser(userSpecialChars).getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, randomData + "~!%40%23%24%25%5E%26%5B%5D%7B%7D%7C%5C%3B%27%3A%22%2C.%2F%3C%3E")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify that user can retrieve the last 2 favorite sites") @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesTests.java index 3009cc03c..f12845720 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesTests.java @@ -451,19 +451,6 @@ public class GetFavoritesTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, networkUserModel.getUsername())); } - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify get favorites using special chars in where parameter for request") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void userIsNotAbleToGetFavoritesWhenUsingSpecialCharsInWhereParameter() throws Exception - { - userFavorites = restClient.withCoreAPI().usingAuthUser().where().invalidWhereParameter("~!%40%23%24%25%5E%26*()_%2B%5B%5D%7B%7D%7C%5C%3B%27%3A%22%2C.%2F%3C%3E").getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_ARGUMENT, "WHERE query")) - .containsErrorKey(RestErrorModel.INVALID_QUERY_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify get favorites using AND instead of OR in where parameter for request") @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) diff --git a/e2e-test/java/org/alfresco/rest/groups/GroupsTests.java b/e2e-test/java/org/alfresco/rest/groups/GroupsTests.java index 95aecd3aa..5eb3fa562 100644 --- a/e2e-test/java/org/alfresco/rest/groups/GroupsTests.java +++ b/e2e-test/java/org/alfresco/rest/groups/GroupsTests.java @@ -16,6 +16,7 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +@Test(groups = {TestGroup.REQUIRE_SOLR}) public class GroupsTests extends RestTest { private UserModel adminUser, userModel; diff --git a/e2e-test/java/org/alfresco/rest/nodes/NodesLockTests.java b/e2e-test/java/org/alfresco/rest/nodes/NodesLockTests.java index e02401e6f..ce19991f6 100644 --- a/e2e-test/java/org/alfresco/rest/nodes/NodesLockTests.java +++ b/e2e-test/java/org/alfresco/rest/nodes/NodesLockTests.java @@ -672,7 +672,7 @@ public class NodesLockTests extends RestTest .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); } - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION, TestGroup.REQUIRE_SOLR }) @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, description = "Verify that child nodes can be locked differently and unlocked") public void testLockUnlockParentChild() throws Exception @@ -728,7 +728,7 @@ public class NodesLockTests extends RestTest query.setIncludeRequest(false); // Allow indexing to complete. - Utility.sleep(1000, 180000, () -> + Utility.sleep(1000, 60000, () -> { SearchResponse response = query(query); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -745,7 +745,7 @@ public class NodesLockTests extends RestTest STEP("7. Verify that childNode1 and childNode2 are not found in the query results."); // Allow indexing to complete. - Utility.sleep(1000, 180000, () -> + Utility.sleep(1000, 60000, () -> { SearchResponse response = query(query); restClient.assertStatusCodeIs(HttpStatus.OK); diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleFullTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleFullTests.java index b3e51ece1..ef080a29a 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleFullTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleFullTests.java @@ -64,22 +64,6 @@ public class GetPeopleFullTests extends RestTest .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 special chars in username with Rest API and response is not found") - public void userChecksIfPersonWithSpecilCharsInUsernameIsNotFound() throws Exception - { - UserModel userSpecialChars = dataUser.usingAdmin().createUser(RandomStringUtils.randomAlphabetic(2) + "~!@#$%^&*()_+[]{}|\\;':\",./<>", "password"); - //setting the encoded text for username - userSpecialChars.setUsername(RandomStringUtils.randomAlphabetic(2) + "~!%40%23%24%25%5E%26*()_%2B%5B%5D%7B%7D%7C%5C%3B%27%3A%22%2C.%2F%3C%3E"); - - personModel = restClient.authenticateUser(managerUser).withCoreAPI().usingUser(userSpecialChars).getPerson(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, userSpecialChars.getUsername())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - @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 diff --git a/e2e-test/java/org/alfresco/rest/tags/GetTagTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagTests.java index 90cc018ab..99bb12b8a 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetTagTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetTagTests.java @@ -11,6 +11,7 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +@Test(groups = {TestGroup.REQUIRE_SOLR}) public class GetTagTests extends TagsDataPrep { diff --git a/e2e-test/java/org/alfresco/rest/tags/GetTagsTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagsTests.java index 5dee733c6..5c3b49ff9 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetTagsTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetTagsTests.java @@ -12,6 +12,7 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +@Test(groups = {TestGroup.REQUIRE_SOLR}) public class GetTagsTests extends TagsDataPrep { diff --git a/e2e-test/java/org/alfresco/rest/tags/TagsDataPrep.java b/e2e-test/java/org/alfresco/rest/tags/TagsDataPrep.java index c5e2e49a1..a499ab15b 100644 --- a/e2e-test/java/org/alfresco/rest/tags/TagsDataPrep.java +++ b/e2e-test/java/org/alfresco/rest/tags/TagsDataPrep.java @@ -11,8 +11,11 @@ import org.alfresco.utility.data.RandomData; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; +import org.testng.annotations.Test; +@Test(groups = {TestGroup.REQUIRE_SOLR}) public class TagsDataPrep extends RestTest { diff --git a/e2e-test/java/org/alfresco/rest/tags/UpdateTagTests.java b/e2e-test/java/org/alfresco/rest/tags/UpdateTagTests.java index 923ee714e..2237314f1 100644 --- a/e2e-test/java/org/alfresco/rest/tags/UpdateTagTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/UpdateTagTests.java @@ -19,6 +19,7 @@ import org.testng.annotations.Test; /** * Created by Claudia Agache on 10/4/2016. */ +@Test(groups = {TestGroup.REQUIRE_SOLR}) public class UpdateTagTests extends TagsDataPrep { private RestTagModel oldTag; diff --git a/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagTests.java b/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagTests.java index 288416e03..2100b3ab3 100644 --- a/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagTests.java @@ -23,6 +23,7 @@ import org.testng.annotations.Test; /** * Created by Claudia Agache on 10/3/2016. */ +@Test(groups = {TestGroup.REQUIRE_SOLR}) public class AddTagTests extends TagsDataPrep { private String tagValue; diff --git a/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagsTests.java b/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagsTests.java index b1ebd8419..7b0d5fd8f 100644 --- a/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagsTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagsTests.java @@ -19,6 +19,7 @@ import org.testng.annotations.Test; /** * Created by Claudia Agache on 10/7/2016. */ +@Test(groups = {TestGroup.REQUIRE_SOLR}) public class AddTagsTests extends TagsDataPrep { private FileModel contributorDoc; diff --git a/e2e-test/java/org/alfresco/rest/tags/nodes/DeleteTagTests.java b/e2e-test/java/org/alfresco/rest/tags/nodes/DeleteTagTests.java index d90f289b7..28f42e67a 100644 --- a/e2e-test/java/org/alfresco/rest/tags/nodes/DeleteTagTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/nodes/DeleteTagTests.java @@ -21,6 +21,7 @@ import org.testng.annotations.Test; /** * Created by Claudia Agache on 10/4/2016. */ +@Test(groups = {TestGroup.REQUIRE_SOLR}) public class DeleteTagTests extends TagsDataPrep { private RestTagModel tag; diff --git a/e2e-test/java/org/alfresco/rest/tags/nodes/GetNodeTagsTests.java b/e2e-test/java/org/alfresco/rest/tags/nodes/GetNodeTagsTests.java index f5a15f675..8cfd84379 100644 --- a/e2e-test/java/org/alfresco/rest/tags/nodes/GetNodeTagsTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/nodes/GetNodeTagsTests.java @@ -16,6 +16,7 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +@Test(groups = {TestGroup.REQUIRE_SOLR}) public class GetNodeTagsTests extends TagsDataPrep { private String tagValue; diff --git a/e2e-test/java/org/alfresco/rest/trashcan/GetDeletedNodesTests.java b/e2e-test/java/org/alfresco/rest/trashcan/GetDeletedNodesTests.java index 9121ad647..5cf7a6759 100644 --- a/e2e-test/java/org/alfresco/rest/trashcan/GetDeletedNodesTests.java +++ b/e2e-test/java/org/alfresco/rest/trashcan/GetDeletedNodesTests.java @@ -180,7 +180,7 @@ public class GetDeletedNodesTests extends RestTest restClient.onResponse().getResponse().body().asString().contains("Sample text."); } - @TestRail(section = { TestGroup.REST_API, TestGroup.TRASHCAN }, executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API, TestGroup.TRASHCAN, TestGroup.REQUIRE_SOLR }, executionType = ExecutionType.SANITY, description = "Sanity tests for GET /deleted-nodes/{nodeId}/renditions, GET /deleted-nodes/{nodeId}/renditions/{renditionId}, GET /deleted-nodes/{nodeId}/renditions/{renditionId}/content") @Test(groups = { TestGroup.REST_API, TestGroup.TRASHCAN, TestGroup.SANITY }) public void testGetDeletedNodesRenditions() throws Exception @@ -196,14 +196,12 @@ public class GetDeletedNodesTests extends RestTest // GET /deleted-nodes/{nodeId}/renditions Utility.sleep(1000, 30000, () -> { - nodeRenditionInfoCollection = restClient.authenticateUser(adminUserModel).withCoreAPI().usingTrashcan().usingParams("where=(status='CREATED')").getDeletedNodeRenditions(file3); + nodeRenditionInfoCollection = restClient.authenticateUser(adminUserModel).withCoreAPI().usingTrashcan().getDeletedNodeRenditions(file3); restClient.assertStatusCodeIs(HttpStatus.OK); - // All renditions, created or not are retrieved. List is ordered - nodeRenditionInfoCollection.assertThat().entriesListCountIs(2); - nodeRenditionInfoCollection.getEntryByIndex(0).assertThat().field("id").is("doclib").and() - .field("status").is("CREATED"); - nodeRenditionInfoCollection.getEntryByIndex(1).assertThat().field("id").is("pdf").and() + // Check if renditions are retrieved, created or not. Entries are ordered + nodeRenditionInfoCollection.assertThat().entriesListContains("id", "doclib"); + nodeRenditionInfoCollection.getEntryByIndex(5).assertThat().field("id").is("pdf").and() .field("status").is("CREATED"); }); From f0761e5debc310eaf48be2035f05a8e62c90002e Mon Sep 17 00:00:00 2001 From: Andrei Bazavan Date: Tue, 20 Feb 2018 14:46:37 +0000 Subject: [PATCH 1316/1491] Feature/REPO 3211: Rewrite Lucene-based Tests in TAS for Action --- .../alfresco/rest/actions/ActionsTests.java | 120 ++++++++++++------ 1 file changed, 81 insertions(+), 39 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/actions/ActionsTests.java b/e2e-test/java/org/alfresco/rest/actions/ActionsTests.java index f85d9d8ae..261a5d3ca 100644 --- a/e2e-test/java/org/alfresco/rest/actions/ActionsTests.java +++ b/e2e-test/java/org/alfresco/rest/actions/ActionsTests.java @@ -1,16 +1,20 @@ package org.alfresco.rest.actions; -import static junit.framework.Assert.fail; +import static org.alfresco.utility.report.log.Step.STEP; import static org.testng.Assert.assertFalse; +import java.util.Arrays; +import java.util.List; + import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; -import org.alfresco.rest.exception.EmptyJsonResponseException; import org.alfresco.rest.model.RestActionDefinitionModel; import org.alfresco.rest.model.RestActionDefinitionModelsCollection; import org.alfresco.rest.model.RestNodeModel; +import org.alfresco.rest.model.RestTagModelsCollection; import org.alfresco.utility.Utility; import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; @@ -35,40 +39,30 @@ public class ActionsTests extends RestTest document = dataContent.usingSite(publicSite).usingUser(adminUser).createContent(CMISUtil.DocumentType.TEXT_PLAIN); } - @TestRail(section = { TestGroup.REST_API,TestGroup.ACTIONS }, executionType = ExecutionType.SANITY, - description = "Verify actions") - @Test(groups = { TestGroup.REST_API, TestGroup.ACTIONS, TestGroup.SANITY}) + @TestRail(section = { TestGroup.REST_API, TestGroup.ACTIONS }, executionType = ExecutionType.SANITY, description = "Verify actions") + @Test(groups = { TestGroup.REST_API, TestGroup.ACTIONS, TestGroup.SANITY }) public void testActionDefinitions() throws Exception { restClient.authenticateUser(dataContent.getAdminUser()); - RestActionDefinitionModelsCollection restActionDefinitions = restClient. - withCoreAPI(). - usingActions(). - listActionDefinitions(); - + RestActionDefinitionModelsCollection restActionDefinitions = restClient.withCoreAPI().usingActions().listActionDefinitions(); + restClient.assertStatusCodeIs(HttpStatus.OK); assertFalse(restActionDefinitions.isEmpty()); - restActionDefinitions.assertThat(). - entriesListContains("name", "copy"). - and().entriesListContains("name", "move"). - and().entriesListContains("name", "check-out"). - and().entriesListContains("name", "check-in"); + restActionDefinitions.assertThat().entriesListContains("name", "copy").and().entriesListContains("name", "move").and().entriesListContains("name", "check-out").and() + .entriesListContains("name", "check-in"); } - - @TestRail(section = { TestGroup.REST_API,TestGroup.ACTIONS }, executionType = ExecutionType.REGRESSION, - description = "Verify actions error conditions") - @Test(groups = { TestGroup.REST_API, TestGroup.ACTIONS, TestGroup.REGRESSION}) - public void testActionDefinitionsNegative() throws Exception{ + + @TestRail(section = { TestGroup.REST_API, TestGroup.ACTIONS }, executionType = ExecutionType.REGRESSION, description = "Verify actions error conditions") + @Test(groups = { TestGroup.REST_API, TestGroup.ACTIONS, TestGroup.REGRESSION }) + public void testActionDefinitionsNegative() throws Exception + { // Badly formed request -> 400 { restClient.authenticateUser(dataContent.getAdminUser()). - // invalid skipCount - withParams("skipCount=-1"). - withCoreAPI(). - usingActions(). - listActionDefinitions(); - + // invalid skipCount + withParams("skipCount=-1").withCoreAPI().usingActions().listActionDefinitions(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); } @@ -83,9 +77,8 @@ public class ActionsTests extends RestTest } } - @TestRail(section = { TestGroup.REST_API,TestGroup.ACTIONS }, executionType = ExecutionType.SANITY, - description = "Sanity test for POST /action-executions") - @Test(groups = { TestGroup.REST_API, TestGroup.ACTIONS, TestGroup.SANITY}) + @TestRail(section = { TestGroup.REST_API, TestGroup.ACTIONS }, executionType = ExecutionType.SANITY, description = "Sanity test for POST /action-executions") + @Test(groups = { TestGroup.REST_API, TestGroup.ACTIONS, TestGroup.SANITY }) public void executeAction() throws Exception { JSONObject response = restClient.authenticateUser(adminUser).withCoreAPI().usingActions().executeAction("add-features", document, "aspect-name", "cm:versionable"); @@ -94,8 +87,8 @@ public class ActionsTests extends RestTest assertFalse(response.getString("id").isEmpty()); /* - * Get all node properties and check that action was executed and - * cm:versionable aspect was added + * Get all node properties and check that action was executed and cm:versionable + * aspect was added */ Utility.sleep(500, 20000, () -> { RestNodeModel fileModel = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(document).getNode(); @@ -105,22 +98,71 @@ public class ActionsTests extends RestTest }); } - @TestRail(section = { TestGroup.REST_API,TestGroup.ACTIONS }, executionType = ExecutionType.SANITY, - description = "Sanity test for ACTIONS endpoint GET action-definitions/{actionDefinitionId}") - @Test(groups = { TestGroup.REST_API, TestGroup.ACTIONS, TestGroup.SANITY}) + @TestRail(section = { TestGroup.REST_API, + TestGroup.ACTIONS }, executionType = ExecutionType.SANITY, description = "Sanity test for ACTIONS endpoint GET action-definitions/{actionDefinitionId}") + @Test(groups = { TestGroup.REST_API, TestGroup.ACTIONS, TestGroup.SANITY }) public void testGetActionDefinitionById() throws Exception { restClient.authenticateUser(dataContent.getAdminUser()); - RestActionDefinitionModel restActionDefinition = restClient. - withCoreAPI(). - usingActions(). - getActionDefinitionById("add-features"); - + RestActionDefinitionModel restActionDefinition = restClient.withCoreAPI().usingActions().getActionDefinitionById("add-features"); + restClient.assertStatusCodeIs(HttpStatus.OK); assertFalse(restActionDefinition.getId().isEmpty()); restActionDefinition.getId().equals("add-features"); restActionDefinition.getDescription().equals("This will add an aspect to the matched item."); restActionDefinition.getTitle().equals("Add aspect"); } + + @TestRail(section = { TestGroup.REST_API, TestGroup.ACTIONS }, executionType = ExecutionType.REGRESSION, description = "Verify actions on Content Metadata Extracter") + @Test(groups = { TestGroup.REST_API, TestGroup.ACTIONS, TestGroup.REGRESSION, TestGroup.REQUIRE_SOLR }) + public void testContentMetadataExtracter() throws Exception + { + STEP("1. Authenticate as a system user."); + restClient.authenticateUser(dataContent.getAdminUser()); + + STEP("2. Create a folder and files with tags."); + FolderModel folder = FolderModel.getRandomFolderModel(); + folder = dataContent.usingUser(adminUser).usingSite(publicSite).createFolder(folder); + // Create files with tags + restClient.configureRequestSpec().addMultiPart("filedata", Utility.getResourceTestDataFile("quickIPTC.jpg")); + RestNodeModel fileNode1 = restClient.withCoreAPI().usingNode(folder).createNode(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.configureRequestSpec().addMultiPart("filedata", Utility.getResourceTestDataFile("quickIPTC2.jpg")); + RestNodeModel fileNode2 = restClient.withCoreAPI().usingNode(folder).createNode(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.configureRequestSpec().addMultiPart("filedata", Utility.getResourceTestDataFile("quickIPTC3.jpg")); + RestNodeModel fileNode3 = restClient.withCoreAPI().usingNode(folder).createNode(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + STEP("3. Extract and check tags."); + extractAndCheckTags(fileNode1, Arrays.asList("fox", "dog", "lazy", "jumping")); + extractAndCheckTags(fileNode2, Arrays.asList("k1", "k2", "k3")); + extractAndCheckTags(fileNode3, Arrays.asList("keyword1", "keyword2", "keyword3", "keyword4")); + } + + /** + * Extract using Action Executer and check the tags from created nodes + * + * @param fileNode + * @param expectedTags + * @throws Exception + */ + private void extractAndCheckTags(RestNodeModel fileNode, List expectedTags) throws Exception + { + JSONObject response = restClient.authenticateUser(adminUser).withCoreAPI().usingActions().executeAction("extract-metadata", fileNode.getId(), null, null); + restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); + // Allow indexing to complete. + Utility.sleep(1000, 30000, () -> { + RestTagModelsCollection returnedCollection = restClient.withCoreAPI().usingNode().getNodeTags(fileNode.getId()); + restClient.assertStatusCodeIs(HttpStatus.OK); + + for (String expectedTag : expectedTags) + { + returnedCollection.assertThat().entriesListContains("tag", expectedTag); + } + }); + } } From 9711d604ae97fa969ec98b846cd4f653cc88ac5c Mon Sep 17 00:00:00 2001 From: Andrei Bazavan Date: Thu, 22 Feb 2018 09:36:13 +0000 Subject: [PATCH 1317/1491] Revert "Merge branch 'feature/REPO-3211' into 'master'" This reverts merge request !60 --- .../alfresco/rest/actions/ActionsTests.java | 120 ++++++------------ 1 file changed, 39 insertions(+), 81 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/actions/ActionsTests.java b/e2e-test/java/org/alfresco/rest/actions/ActionsTests.java index 261a5d3ca..f85d9d8ae 100644 --- a/e2e-test/java/org/alfresco/rest/actions/ActionsTests.java +++ b/e2e-test/java/org/alfresco/rest/actions/ActionsTests.java @@ -1,20 +1,16 @@ package org.alfresco.rest.actions; -import static org.alfresco.utility.report.log.Step.STEP; +import static junit.framework.Assert.fail; import static org.testng.Assert.assertFalse; -import java.util.Arrays; -import java.util.List; - import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.EmptyJsonResponseException; import org.alfresco.rest.model.RestActionDefinitionModel; import org.alfresco.rest.model.RestActionDefinitionModelsCollection; import org.alfresco.rest.model.RestNodeModel; -import org.alfresco.rest.model.RestTagModelsCollection; import org.alfresco.utility.Utility; import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; @@ -39,30 +35,40 @@ public class ActionsTests extends RestTest document = dataContent.usingSite(publicSite).usingUser(adminUser).createContent(CMISUtil.DocumentType.TEXT_PLAIN); } - @TestRail(section = { TestGroup.REST_API, TestGroup.ACTIONS }, executionType = ExecutionType.SANITY, description = "Verify actions") - @Test(groups = { TestGroup.REST_API, TestGroup.ACTIONS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API,TestGroup.ACTIONS }, executionType = ExecutionType.SANITY, + description = "Verify actions") + @Test(groups = { TestGroup.REST_API, TestGroup.ACTIONS, TestGroup.SANITY}) public void testActionDefinitions() throws Exception { restClient.authenticateUser(dataContent.getAdminUser()); - RestActionDefinitionModelsCollection restActionDefinitions = restClient.withCoreAPI().usingActions().listActionDefinitions(); - + RestActionDefinitionModelsCollection restActionDefinitions = restClient. + withCoreAPI(). + usingActions(). + listActionDefinitions(); + restClient.assertStatusCodeIs(HttpStatus.OK); assertFalse(restActionDefinitions.isEmpty()); - restActionDefinitions.assertThat().entriesListContains("name", "copy").and().entriesListContains("name", "move").and().entriesListContains("name", "check-out").and() - .entriesListContains("name", "check-in"); + restActionDefinitions.assertThat(). + entriesListContains("name", "copy"). + and().entriesListContains("name", "move"). + and().entriesListContains("name", "check-out"). + and().entriesListContains("name", "check-in"); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.ACTIONS }, executionType = ExecutionType.REGRESSION, description = "Verify actions error conditions") - @Test(groups = { TestGroup.REST_API, TestGroup.ACTIONS, TestGroup.REGRESSION }) - public void testActionDefinitionsNegative() throws Exception - { + + @TestRail(section = { TestGroup.REST_API,TestGroup.ACTIONS }, executionType = ExecutionType.REGRESSION, + description = "Verify actions error conditions") + @Test(groups = { TestGroup.REST_API, TestGroup.ACTIONS, TestGroup.REGRESSION}) + public void testActionDefinitionsNegative() throws Exception{ // Badly formed request -> 400 { restClient.authenticateUser(dataContent.getAdminUser()). - // invalid skipCount - withParams("skipCount=-1").withCoreAPI().usingActions().listActionDefinitions(); - + // invalid skipCount + withParams("skipCount=-1"). + withCoreAPI(). + usingActions(). + listActionDefinitions(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); } @@ -77,8 +83,9 @@ public class ActionsTests extends RestTest } } - @TestRail(section = { TestGroup.REST_API, TestGroup.ACTIONS }, executionType = ExecutionType.SANITY, description = "Sanity test for POST /action-executions") - @Test(groups = { TestGroup.REST_API, TestGroup.ACTIONS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API,TestGroup.ACTIONS }, executionType = ExecutionType.SANITY, + description = "Sanity test for POST /action-executions") + @Test(groups = { TestGroup.REST_API, TestGroup.ACTIONS, TestGroup.SANITY}) public void executeAction() throws Exception { JSONObject response = restClient.authenticateUser(adminUser).withCoreAPI().usingActions().executeAction("add-features", document, "aspect-name", "cm:versionable"); @@ -87,8 +94,8 @@ public class ActionsTests extends RestTest assertFalse(response.getString("id").isEmpty()); /* - * Get all node properties and check that action was executed and cm:versionable - * aspect was added + * Get all node properties and check that action was executed and + * cm:versionable aspect was added */ Utility.sleep(500, 20000, () -> { RestNodeModel fileModel = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(document).getNode(); @@ -98,71 +105,22 @@ public class ActionsTests extends RestTest }); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.ACTIONS }, executionType = ExecutionType.SANITY, description = "Sanity test for ACTIONS endpoint GET action-definitions/{actionDefinitionId}") - @Test(groups = { TestGroup.REST_API, TestGroup.ACTIONS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API,TestGroup.ACTIONS }, executionType = ExecutionType.SANITY, + description = "Sanity test for ACTIONS endpoint GET action-definitions/{actionDefinitionId}") + @Test(groups = { TestGroup.REST_API, TestGroup.ACTIONS, TestGroup.SANITY}) public void testGetActionDefinitionById() throws Exception { restClient.authenticateUser(dataContent.getAdminUser()); - RestActionDefinitionModel restActionDefinition = restClient.withCoreAPI().usingActions().getActionDefinitionById("add-features"); - + RestActionDefinitionModel restActionDefinition = restClient. + withCoreAPI(). + usingActions(). + getActionDefinitionById("add-features"); + restClient.assertStatusCodeIs(HttpStatus.OK); assertFalse(restActionDefinition.getId().isEmpty()); restActionDefinition.getId().equals("add-features"); restActionDefinition.getDescription().equals("This will add an aspect to the matched item."); restActionDefinition.getTitle().equals("Add aspect"); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.ACTIONS }, executionType = ExecutionType.REGRESSION, description = "Verify actions on Content Metadata Extracter") - @Test(groups = { TestGroup.REST_API, TestGroup.ACTIONS, TestGroup.REGRESSION, TestGroup.REQUIRE_SOLR }) - public void testContentMetadataExtracter() throws Exception - { - STEP("1. Authenticate as a system user."); - restClient.authenticateUser(dataContent.getAdminUser()); - - STEP("2. Create a folder and files with tags."); - FolderModel folder = FolderModel.getRandomFolderModel(); - folder = dataContent.usingUser(adminUser).usingSite(publicSite).createFolder(folder); - // Create files with tags - restClient.configureRequestSpec().addMultiPart("filedata", Utility.getResourceTestDataFile("quickIPTC.jpg")); - RestNodeModel fileNode1 = restClient.withCoreAPI().usingNode(folder).createNode(); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.configureRequestSpec().addMultiPart("filedata", Utility.getResourceTestDataFile("quickIPTC2.jpg")); - RestNodeModel fileNode2 = restClient.withCoreAPI().usingNode(folder).createNode(); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.configureRequestSpec().addMultiPart("filedata", Utility.getResourceTestDataFile("quickIPTC3.jpg")); - RestNodeModel fileNode3 = restClient.withCoreAPI().usingNode(folder).createNode(); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - STEP("3. Extract and check tags."); - extractAndCheckTags(fileNode1, Arrays.asList("fox", "dog", "lazy", "jumping")); - extractAndCheckTags(fileNode2, Arrays.asList("k1", "k2", "k3")); - extractAndCheckTags(fileNode3, Arrays.asList("keyword1", "keyword2", "keyword3", "keyword4")); - } - - /** - * Extract using Action Executer and check the tags from created nodes - * - * @param fileNode - * @param expectedTags - * @throws Exception - */ - private void extractAndCheckTags(RestNodeModel fileNode, List expectedTags) throws Exception - { - JSONObject response = restClient.authenticateUser(adminUser).withCoreAPI().usingActions().executeAction("extract-metadata", fileNode.getId(), null, null); - restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); - // Allow indexing to complete. - Utility.sleep(1000, 30000, () -> { - RestTagModelsCollection returnedCollection = restClient.withCoreAPI().usingNode().getNodeTags(fileNode.getId()); - restClient.assertStatusCodeIs(HttpStatus.OK); - - for (String expectedTag : expectedTags) - { - returnedCollection.assertThat().entriesListContains("tag", expectedTag); - } - }); - } } From 8dbec91fcd7988ebc65de2a27d615458d91d8f9c Mon Sep 17 00:00:00 2001 From: Andreea Nechifor Date: Tue, 6 Mar 2018 13:55:13 +0200 Subject: [PATCH 1318/1491] REPO -2247: Tags: GET tags endpoint should provide aggregation info --- .../rest/tags/nodes/AddTagsTests.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagsTests.java b/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagsTests.java index 7b0d5fd8f..546550885 100644 --- a/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagsTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagsTests.java @@ -2,6 +2,7 @@ package org.alfresco.rest.tags.nodes; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestTagModel; import org.alfresco.rest.model.RestTagModelsCollection; import org.alfresco.rest.tags.TagsDataPrep; import org.alfresco.utility.constants.UserRole; @@ -12,6 +13,7 @@ import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; +import org.testng.Assert; import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -122,4 +124,30 @@ public class AddTagsTests extends TagsDataPrep .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); siteManager.setPassword(managerPassword); } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify include count parameter") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void getTagsUsingCountParam() throws Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + String tagName = RandomData.getRandomName("tag"); + restClient.authenticateUser(adminUserModel); + returnedModel = restClient.withCoreAPI().usingResource(file).addTag(RandomData.getRandomName("tag")); + file.setNodeRef(returnedModel.getId()); + RestTagModelsCollection tagsWithIncludeParamCount = restClient.withParams("include=count").withCoreAPI().getTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + for (RestTagModel tagModel : tagsWithIncludeParamCount.getEntries()) + { + if (tagModel != null && tagModel.getTag() != null) + { + if (tagModel.getTag().equals(tagName)) + { + Assert.assertEquals(tagModel.getCount().intValue(), 1); + } + } + } + + } } \ No newline at end of file From f0ec18e86284623ea58c8e497d4f5ab0fe40c279 Mon Sep 17 00:00:00 2001 From: Andreea Nechifor Date: Tue, 6 Mar 2018 14:55:22 +0200 Subject: [PATCH 1319/1491] REPO-2247: nodeRef redundant set. --- e2e-test/java/org/alfresco/rest/tags/nodes/AddTagsTests.java | 1 - 1 file changed, 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagsTests.java b/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagsTests.java index 546550885..5bb4908c2 100644 --- a/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagsTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagsTests.java @@ -134,7 +134,6 @@ public class AddTagsTests extends TagsDataPrep String tagName = RandomData.getRandomName("tag"); restClient.authenticateUser(adminUserModel); returnedModel = restClient.withCoreAPI().usingResource(file).addTag(RandomData.getRandomName("tag")); - file.setNodeRef(returnedModel.getId()); RestTagModelsCollection tagsWithIncludeParamCount = restClient.withParams("include=count").withCoreAPI().getTags(); restClient.assertStatusCodeIs(HttpStatus.OK); From ff6d68256b582530c1ed2b4cd497e7036fbcc110 Mon Sep 17 00:00:00 2001 From: Andreea Nechifor Date: Tue, 6 Mar 2018 15:01:47 +0200 Subject: [PATCH 1320/1491] REPO:2247 Tags: GET tags endpoint should provide aggregation info. added changes after review. --- e2e-test/java/org/alfresco/rest/tags/nodes/AddTagsTests.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagsTests.java b/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagsTests.java index 5bb4908c2..25063550e 100644 --- a/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagsTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagsTests.java @@ -132,11 +132,9 @@ public class AddTagsTests extends TagsDataPrep { FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); String tagName = RandomData.getRandomName("tag"); - restClient.authenticateUser(adminUserModel); - returnedModel = restClient.withCoreAPI().usingResource(file).addTag(RandomData.getRandomName("tag")); + returnedModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addTag(RandomData.getRandomName("tag")); RestTagModelsCollection tagsWithIncludeParamCount = restClient.withParams("include=count").withCoreAPI().getTags(); restClient.assertStatusCodeIs(HttpStatus.OK); - for (RestTagModel tagModel : tagsWithIncludeParamCount.getEntries()) { if (tagModel != null && tagModel.getTag() != null) From 9fac02eb55786a8c4d0158b7db7cd5fbea8e23e2 Mon Sep 17 00:00:00 2001 From: Andrei Forascu Date: Fri, 9 Mar 2018 17:28:07 +0200 Subject: [PATCH 1321/1491] REPO-2093 - Allow site managers to accept and reject site invitations: - added test for the following endpoints: GET /site-membership-requests, POST /sites/{siteId}/site-membership-requests/{inviteeId}/approve, POST /sites/{siteId}/site-membership-requests/{inviteeId}/reject --- .../GetSiteMembershipRequestsTests.java | 46 ++++++++++++++++++- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestsTests.java b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestsTests.java index ee224a7d2..470b118dd 100644 --- a/e2e-test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestsTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestsTests.java @@ -1,5 +1,7 @@ package org.alfresco.rest.sites.membershipRequests; +import static org.alfresco.utility.report.log.Step.STEP; + import org.alfresco.rest.RestTest; import org.alfresco.rest.model.*; import org.alfresco.utility.constants.UserRole; @@ -15,14 +17,18 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; /** - * Tests for getSiteMembershipRequests (get /people/{personId}/site-membership-requests) RestAPI call + * Tests for + * GET /people/{personId}/site-membership-requests + * GET /site-membership-requests + * POST /sites/{siteId}/site-membership-requests/{inviteeId}/approve + * POST /sites/{siteId}/site-membership-requests/{inviteeId}/reject * * @author Cristina Axinte */ public class GetSiteMembershipRequestsTests extends RestTest { - UserModel siteManager, newMember, adminUser, regularUser; + UserModel siteManager, newMember, adminUser, regularUser, testUser, testUser1; DataUser.ListUserWithRoles usersWithRoles; SiteModel moderatedSite1, moderatedSite2; RestSiteMembershipRequestModelsCollection siteMembershipRequests; @@ -34,6 +40,11 @@ public class GetSiteMembershipRequestsTests extends RestTest siteManager = dataUser.createRandomTestUser(); newMember = dataUser.createRandomTestUser(); regularUser = dataUser.createRandomTestUser(); + + testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteConsumer); + testUser1 = dataUser.createRandomTestUser("testUser1"); + testUser1.setUserRole(UserRole.SiteConsumer); moderatedSite1 = dataSite.usingUser(siteManager).createModeratedRandomSite(); moderatedSite2 = dataSite.usingUser(siteManager).createModeratedRandomSite(); @@ -376,4 +387,35 @@ public class GetSiteMembershipRequestsTests extends RestTest RestSiteMembershipRequestModel siteMembershipRequest = siteMembershipRequests.getOneRandomEntry().onModel(); siteMembershipRequest.assertThat().fieldsCount().is(1); } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Sanity test for endpoints: GET /site-membership-requests, POST /sites/{siteId}/site-membership-requests/{inviteeId}/approve, POST /sites/{siteId}/site-membership-requests/{inviteeId}/reject") + public void approveRejectSiteMembership() throws Exception + { + STEP("1. Make membership requests for 2 users on moderatedSite."); + restClient.authenticateUser(testUser).withCoreAPI().usingMe().addSiteMembershipRequest(moderatedSite1); + restClient.authenticateUser(testUser1).withCoreAPI().usingMe().addSiteMembershipRequest(moderatedSite1); + + STEP("2. Get site memberships and filter using username and siteId "); + RestSitePersonMembershipRequestModelsCollection membership = restClient.authenticateUser(siteManager) + .withParams("where=(personId='" + testUser.getUsername() + "' AND siteId='" + moderatedSite1.getId() + "')").withCoreAPI() + .usingSite(moderatedSite1).getSiteMemberships(); + + restClient.assertStatusCodeIs(HttpStatus.OK); + membership.getEntryByIndex(0).getSite().assertThat().field("id").is(moderatedSite1.getId()); + membership.getEntryByIndex(0).getPersonModel().assertThat().field("id").is(testUser.getUsername()); + + STEP("3. Approve site membership for one of the users. Check that the user is now a member of the site"); + restClient.authenticateUser(siteManager).withCoreAPI().usingSite(moderatedSite1).approveSiteMembership(testUser); + restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.withCoreAPI().usingSite(moderatedSite1).getSiteMember(testUser).assertThat().field("id").is(testUser.getUsername()).and().field("role") + .is(testUser.getUserRole()); + + STEP("4. Reject site membership for the second user. Check that the user is not a member of the site"); + restClient.authenticateUser(siteManager).withCoreAPI().usingSite(moderatedSite1).rejectSiteMembership(testUser1); + restClient.assertStatusCodeIs(HttpStatus.OK); + RestSiteMemberModelsCollection memberList = restClient.withCoreAPI().usingSite(moderatedSite1).getSiteMembers(); + memberList.assertThat().entriesListDoesNotContain("id", testUser1.getUsername()); + } } From e372e0fe74cfd4bde9c50f57dbfa4f8ea9f01eda Mon Sep 17 00:00:00 2001 From: Andrei Bazavan Date: Mon, 12 Mar 2018 09:16:59 +0000 Subject: [PATCH 1322/1491] REPO-3271: Range Request Documentation --- .../nodes/NodesContentAndVersioningTests.java | 91 +++++++++++-------- .../rest/renditions/GetRenditionTests.java | 22 +++++ .../sharedLinks/SharedLinksSanityTests.java | 25 ++++- .../rest/trashcan/GetDeletedNodesTests.java | 29 +++++- 4 files changed, 123 insertions(+), 44 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/nodes/NodesContentAndVersioningTests.java b/e2e-test/java/org/alfresco/rest/nodes/NodesContentAndVersioningTests.java index 61cda4ec6..f9eb55734 100644 --- a/e2e-test/java/org/alfresco/rest/nodes/NodesContentAndVersioningTests.java +++ b/e2e-test/java/org/alfresco/rest/nodes/NodesContentAndVersioningTests.java @@ -33,6 +33,7 @@ import org.json.JSONObject; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; + /** * * @author mpopa @@ -46,7 +47,7 @@ public class NodesContentAndVersioningTests extends RestTest @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception - { + { user1 = dataUser.createRandomTestUser(); user2 = dataUser.createRandomTestUser(); site1 = dataSite.usingUser(user1).createPublicRandomSite(); @@ -54,21 +55,23 @@ public class NodesContentAndVersioningTests extends RestTest file1 = dataContent.usingUser(user1).usingSite(site1).createContent(DocumentType.TEXT_PLAIN); file2 = dataContent.usingUser(user2).usingSite(site2).createContent(DocumentType.TEXT_PLAIN); } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NODES }, executionType = ExecutionType.SANITY, - description = "Verify file name in Content-Disposition header") - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY}) + + @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.SANITY, description = "Verify file name in Content-Disposition header") + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY }) public void checkFileNameWithRegularCharsInHeader() throws Exception { restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("attachment=false").getNodeContent(); restClient.assertStatusCodeIs(HttpStatus.OK); restClient.assertHeaderValueContains("Content-Disposition", String.format("filename=\"%s\"", file1.getName())); } - - @Bug(id="MNT-17545", description = "HTTP Header Injection in ContentStreamer", status = Bug.Status.FIXED) - @TestRail(section = { TestGroup.REST_API,TestGroup.NODES }, executionType = ExecutionType.REGRESSION, - description = "Verify file name with special chars is escaped in Content-Disposition header") - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION}) + + + + + @Bug(id = "MNT-17545", description = "HTTP Header Injection in ContentStreamer", status = Bug.Status.FIXED) + @TestRail(section = { TestGroup.REST_API, + TestGroup.NODES }, executionType = ExecutionType.REGRESSION, description = "Verify file name with special chars is escaped in Content-Disposition header") + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) public void checkFileNameWithSpecialCharsInHeader() throws Exception { char c1 = 127; @@ -77,7 +80,7 @@ public class NodesContentAndVersioningTests extends RestTest FileModel file = dataContent.usingUser(user2).usingSite(site2).createContent(new FileModel("\ntest" + c1 + c2 + c3, FileType.TEXT_PLAIN)); restClient.authenticateUser(user2).withCoreAPI().usingNode(file).usingParams("attachment=false").getNodeContent(); restClient.assertStatusCodeIs(HttpStatus.OK); - restClient.assertHeaderValueContains("Content-Disposition","filename=\" test .txt\""); + restClient.assertHeaderValueContains("Content-Disposition", "filename=\" test .txt\""); } @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY }) @@ -86,8 +89,8 @@ public class NodesContentAndVersioningTests extends RestTest public void verifyFileEncodingUsingRestAPI() throws Exception { STEP("1. Create a folder, two text file templates and define the expected encoding."); - FileModel utf8File = new FileModel("utf8File",FileType.TEXT_PLAIN); - FileModel iso8859File = new FileModel("iso8859File",FileType.TEXT_PLAIN); + FileModel utf8File = new FileModel("utf8File", FileType.TEXT_PLAIN); + FileModel iso8859File = new FileModel("iso8859File", FileType.TEXT_PLAIN); FolderModel folder = dataContent.usingUser(user1).usingSite(site1).createFolder(FolderModel.getRandomFolderModel()); String utf8Type = "text/plain;charset=UTF-8"; String iso8859Type = "text/plain;charset=ISO-8859-1"; @@ -110,8 +113,7 @@ public class NodesContentAndVersioningTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.NODES }, executionType = ExecutionType.SANITY, description = "Verify updating a node content.") + @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.SANITY, description = "Verify updating a node content.") public void testUpdateNodeContent() throws Exception { STEP("1. Retrieve the node in order to get data to compare after update GET /nodes/{nodeId}?include=path."); @@ -129,13 +131,12 @@ public class NodesContentAndVersioningTests extends RestTest assertNotSame(initialNode.getName(), updatedBodyNode.getName()); String initialNodeVersion = new JSONObject(initialNode.toJson()).getJSONObject("properties").getString("cm:versionLabel"); - String updatedBodyNodeVersion = new JSONObject(updatedBodyNode.toJson()).getJSONObject("properties").getString("cm:versionLabel"); + String updatedBodyNodeVersion = new JSONObject(updatedBodyNode.toJson()).getJSONObject("properties").getString("cm:versionLabel"); assertTrue(updatedBodyNodeVersion.charAt(0) > initialNodeVersion.charAt(0)); } @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.NODES }, executionType = ExecutionType.SANITY, description = "Test copy a node.") + @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.SANITY, description = "Test copy a node.") public void testCopyNode() throws Exception { STEP("1. Create a lock and lock the node POST /nodes/{nodeId}/lock?include=path,isLocked."); @@ -148,8 +149,7 @@ public class NodesContentAndVersioningTests extends RestTest STEP("2. With another user(that has access to the file), copy the node to another path POST /nodes/{nodeId}/copy?include=path,isLocked."); String postBody = JsonBodyGenerator.keyValueJson("targetParentId", site2.getGuid()); - RestNodeModel copiedNode = restClient.authenticateUser(user2).withCoreAPI().usingNode(file1).usingParams("include=path,isLocked") - .copyNode(postBody); + RestNodeModel copiedNode = restClient.authenticateUser(user2).withCoreAPI().usingNode(file1).usingParams("include=path,isLocked").copyNode(postBody); restClient.assertStatusCodeIs(HttpStatus.CREATED); STEP("3. ParentId, createdAt, path and lock are different, but the nodes have the same contentSize."); @@ -175,25 +175,25 @@ public class NodesContentAndVersioningTests extends RestTest File sampleFile = Utility.getResourceTestDataFile("sampleContent.txt"); STEP("1. Update the node content in order to increase version(one minor and one major) PUT /nodes/{nodeId}/content."); - //minor version update + // minor version update restClient.authenticateUser(user2).withCoreAPI().usingNode(file2).updateNodeContent(sampleFile); restClient.assertStatusCodeIs(HttpStatus.OK); - //major version update + // major version update restClient.authenticateUser(user2).withCoreAPI().usingParams("majorVersion=true").usingNode(file2).updateNodeContent(sampleFile); restClient.assertStatusCodeIs(HttpStatus.OK); STEP("2. List node version history GET /nodes/{nodeId}/versions. And verify that first (in the list) version is 2.0 and last is 1.0."); RestVersionModelsCollection versionListing = restClient.withCoreAPI().usingNode(file2).listVersionHistory(); restClient.assertStatusCodeIs(HttpStatus.OK); - //additional check that the properties are not displayed by default. - assertEquals(versionListing.getEntries().get(versionListing.getPagination().getCount()-1).onModel().getId(),"1.0"); - assertEquals(versionListing.getEntries().get(0).onModel().getId(),"2.0"); + // additional check that the properties are not displayed by default. + assertEquals(versionListing.getEntries().get(versionListing.getPagination().getCount() - 1).onModel().getId(), "1.0"); + assertEquals(versionListing.getEntries().get(0).onModel().getId(), "2.0"); assertNull(versionListing.getEntries().get(0).onModel().getProperties()); STEP("3. List node version using skipCount(1),maxItems(1) and include(properties) GET /nodes/{nodeId}/versions?include=properties&skipCount=1&maxItems=1"); versionListing = restClient.withCoreAPI().usingParams("include=properties&skipCount=1&maxItems=1").usingNode(file2).listVersionHistory(); restClient.assertStatusCodeIs(HttpStatus.OK); - //we expect only version 1.1 to be retrieved with the value for properties. + // we expect only version 1.1 to be retrieved with the value for properties. RestVersionModel version = versionListing.getEntries().get(0).onModel(); assertNotNull(version.getProperties()); assertEquals(version.getId(), "1.1"); @@ -204,18 +204,20 @@ public class NodesContentAndVersioningTests extends RestTest STEP("4. Get version information for version 1.1 GET /nodes/{nodeId}/versions/{versionId} ."); RestVersionModel version11 = restClient.withCoreAPI().usingNode(file2).getVersionInformation("1.1"); restClient.assertStatusCodeIs(HttpStatus.OK); - //aspectNames and properties are displayed by default. We compare id,contentSize and name with the values from v1.1, taken from listing all versions. + // aspectNames and properties are displayed by default. We compare + // id,contentSize and name with the values from v1.1, taken from listing all + // versions. assertNotNull(version11.getAspectNames()); assertNotNull(version11.getProperties()); - assertEquals(version.getId(),version11.getId()); - assertEquals(version.getContent().getSizeInBytes(),version11.getContent().getSizeInBytes()); - assertEquals(version.getName(),version11.getName()); + assertEquals(version.getId(), version11.getId()); + assertEquals(version.getContent().getSizeInBytes(), version11.getContent().getSizeInBytes()); + assertEquals(version.getName(), version11.getName()); STEP("5. Retrieve version 2.0 content GET /nodes/{nodeId}/versions/{versionId}/content"); - //verify the content is the same as the uploaded file and check in headers for Content-Disposition to validate the download as attachment and fileName. - //wait for content to be picked up on AWS QS stacks - Utility.sleep(1000, 60000, () -> - { + // verify the content is the same as the uploaded file and check in headers for + // Content-Disposition to validate the download as attachment and fileName. + // wait for content to be picked up on AWS QS stacks + Utility.sleep(1000, 60000, () -> { RestResponse versionContent = restClient.withCoreAPI().usingNode(file2).getVersionContent("2.0"); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -223,27 +225,25 @@ public class NodesContentAndVersioningTests extends RestTest restClient.assertHeaderValueContains("Content-Disposition", "attachment"); restClient.assertHeaderValueContains("Content-Disposition", String.format("filename=\"%s\"", file2.getName())); }); - } @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.NODES }, executionType = ExecutionType.SANITY, description = "Test revert and delete a node version.") + @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.SANITY, description = "Test revert and delete a node version.") public void testRevertDeleteVersion() throws Exception { STEP("1. Revert to version 1.0 POST /nodes/{nodeId}/versions/{versionId}/revert"); RestVersionModel version = restClient.authenticateUser(user2).withCoreAPI().usingNode(file2).revertVersion("1.0", new String("{}")); restClient.assertStatusCodeIs(HttpStatus.OK); String nodeVersionType = new JSONObject(version.toJson()).getJSONObject("properties").getString("cm:versionType"); - assertEquals(nodeVersionType , "MINOR"); + assertEquals(nodeVersionType, "MINOR"); String nodeVersion = version.getId(); STEP("2. Revert to last minor version /nodes/{nodeId}/versions/{versionId}/revert"); version = restClient.withCoreAPI().usingNode(file2).revertVersion(nodeVersion, new String("{\"majorVersion\": true}")); restClient.assertStatusCodeIs(HttpStatus.OK); nodeVersionType = new JSONObject(version.toJson()).getJSONObject("properties").getString("cm:versionType"); - assertEquals(nodeVersionType , "MAJOR"); - assertTrue(nodeVersion.charAt(0)+1 == version.getId().charAt(0)); + assertEquals(nodeVersionType, "MAJOR"); + assertTrue(nodeVersion.charAt(0) + 1 == version.getId().charAt(0)); STEP("3. Delete last MINOR version DELETE /nodes/{nodeId}/versions/{versionId}"); restClient.withCoreAPI().usingNode(file2).deleteNodeVersion(nodeVersion); @@ -251,4 +251,15 @@ public class NodesContentAndVersioningTests extends RestTest restClient.withCoreAPI().usingNode(file2).getVersionInformation(nodeVersion); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); } + + @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.SANITY, description = "Verify file name in Content Range header") + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY }) + public void checkFileNameContentRangeHeader() throws Exception + { + restClient.configureRequestSpec().addHeader("content-range", "bytes=1-10"); + restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).getNodeContent(); + restClient.assertStatusCodeIs(HttpStatus.PARTIAL_CONTENT); + restClient.assertHeaderValueContains("content-range", "bytes 1-10"); + restClient.assertHeaderValueContains("content-length", String.valueOf(10)); + } } diff --git a/e2e-test/java/org/alfresco/rest/renditions/GetRenditionTests.java b/e2e-test/java/org/alfresco/rest/renditions/GetRenditionTests.java index 4d9b7c2ba..5fcad7e79 100644 --- a/e2e-test/java/org/alfresco/rest/renditions/GetRenditionTests.java +++ b/e2e-test/java/org/alfresco/rest/renditions/GetRenditionTests.java @@ -2,6 +2,8 @@ package org.alfresco.rest.renditions; import static org.alfresco.utility.report.log.Step.STEP; +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.core.RestResponse; import org.alfresco.rest.model.RestNodeModel; @@ -31,12 +33,14 @@ public class GetRenditionTests extends RestTest { private UserModel user; private SiteModel site; + private FileModel file1; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception { user = dataUser.createRandomTestUser(); site = dataSite.usingUser(user).createPublicRandomSite(); + file1 = dataContent.usingUser(user).usingSite(site).createContent(DocumentType.TEXT_PLAIN); } @Bug(id = "REPO-2449", status = Status.FIXED) @@ -132,5 +136,23 @@ public class GetRenditionTests extends RestTest Assert.assertTrue(restResponse.getResponse().body().asInputStream().available() > 0); } + @Test(groups = {TestGroup.REST_API, TestGroup.RENDITIONS, TestGroup.SANITY}) + @TestRail(section = {TestGroup.REST_API, TestGroup.RENDITIONS}, executionType = ExecutionType.SANITY, + description = "Verify the Range request header using GET /nodes/{nodeId}/renditions/{renditionId}/content") + public void getVerifyRangeRequestHeader() throws Exception + { + STEP("1. Create thumbnail on file"); + restClient.authenticateUser(user).withCoreAPI().usingNode(file1).createNodeRendition("pdf"); + restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); + + STEP("2. Make GET rendition content using content-range header"); + Utility.sleep(1000, 30000, () -> { + restClient.configureRequestSpec().addHeader("content-range", "bytes=1-10"); + restClient.authenticateUser(user).withCoreAPI().usingNode(file1).getNodeRenditionContent("pdf"); + restClient.assertStatusCodeIs(HttpStatus.PARTIAL_CONTENT); + restClient.assertHeaderValueContains("content-range", "bytes 1-10"); + restClient.assertHeaderValueContains("content-length", String.valueOf(10)); + }); + } } diff --git a/e2e-test/java/org/alfresco/rest/sharedLinks/SharedLinksSanityTests.java b/e2e-test/java/org/alfresco/rest/sharedLinks/SharedLinksSanityTests.java index cb707a713..d41f2d646 100644 --- a/e2e-test/java/org/alfresco/rest/sharedLinks/SharedLinksSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sharedLinks/SharedLinksSanityTests.java @@ -44,6 +44,7 @@ public class SharedLinksSanityTests extends RestTest private FileModel file5; private FileModel file6; private FileModel file7; + private FileModel file8; private RestSharedLinksModel sharedLink1; private RestSharedLinksModel sharedLink2; @@ -52,7 +53,7 @@ public class SharedLinksSanityTests extends RestTest private RestSharedLinksModel sharedLink5; private RestSharedLinksModel sharedLink6; private RestSharedLinksModel sharedLink7; - + private RestSharedLinksModel sharedLink8; private RestRenditionInfoModel nodeRenditionInfo; private RestSharedLinksModelCollection sharedLinksCollection; @@ -81,7 +82,7 @@ public class SharedLinksSanityTests extends RestTest file4 = dataContent.usingUser(adminUser).usingResource(folder1).createContent(DocumentType.TEXT_PLAIN); file5 = dataContent.usingUser(adminUser).usingResource(folder1).createContent(DocumentType.TEXT_PLAIN); file7 = dataContent.usingUser(adminUser).usingResource(folder1).createContent(DocumentType.TEXT_PLAIN); - + file8 = dataContent.usingUser(adminUser).usingResource(folder1).createContent(DocumentType.TEXT_PLAIN); // Create file6 based on existing resource FileModel newFile = FileModel.getFileModelBasedOnTestDataFile("sampleContent.txt"); newFile.setName("sampleContent.txt"); @@ -254,4 +255,24 @@ public class SharedLinksSanityTests extends RestTest restClient.assertHeaderValueContains("Content-Type","application/pdf;charset=UTF-8"); Assert.assertTrue(restClient.onResponse().getResponse().body().asInputStream().available() > 0); } + + @TestRail(section = { TestGroup.REST_API, TestGroup.SHAREDLINKS }, executionType = ExecutionType.SANITY, description = "Sanity tests for Range reuest header on GET shared-links/{sharedId}/renditions/{renditionId}/content endpoints") + @Test(groups = { TestGroup.REST_API, TestGroup.SHAREDLINKS, TestGroup.SANITY, TestGroup.REQUIRE_TRANSFORMATION }) + public void testGetVerifyRangeReguestOnSharedLinks() throws Exception + { + sharedLink8 = restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().createSharedLink(file8); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.withCoreAPI().usingNode(file8).createNodeRendition("pdf"); + restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); + + // GET /renditions/{renditionId}/content: get the Range request header for file with shared links endpoints. + Utility.sleep(1000, 30000, () -> + { + restClient.configureRequestSpec().addHeader("content-range", "bytes=1-10"); + restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().getSharedLinkRenditionContent(sharedLink8, "pdf"); + restClient.assertStatusCodeIs(HttpStatus.PARTIAL_CONTENT); + restClient.assertHeaderValueContains("Content-Type","application/pdf;charset=UTF-8"); + restClient.assertHeaderValueContains("content-range", "bytes 1-10"); + }); + } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/trashcan/GetDeletedNodesTests.java b/e2e-test/java/org/alfresco/rest/trashcan/GetDeletedNodesTests.java index 5cf7a6759..553b044d1 100644 --- a/e2e-test/java/org/alfresco/rest/trashcan/GetDeletedNodesTests.java +++ b/e2e-test/java/org/alfresco/rest/trashcan/GetDeletedNodesTests.java @@ -49,8 +49,8 @@ public class GetDeletedNodesTests extends RestTest { private UserModel adminUserModel; private SiteModel deleteNodesSiteModel; - private FolderModel deleteNodesFolder1, deleteNodesFolder2, deleteNodesFolder3, deleteNodesFolder4, deleteNodesFolder5; - private FileModel file, file1, file2, file3; + private FolderModel deleteNodesFolder1, deleteNodesFolder2, deleteNodesFolder3, deleteNodesFolder4, deleteNodesFolder5, getDeleteNodesFolder6; + private FileModel file, file1, file2, file3, file4; private RestNodeModelsCollection deletedNodes, deletedNodesMaxItem; private RestNodeModel node; @@ -217,4 +217,29 @@ public class GetDeletedNodesTests extends RestTest restClient.assertHeaderValueContains("Content-Type","application/pdf;charset=UTF-8"); Assert.assertTrue(restClient.onResponse().getResponse().body().asInputStream().available() > 0); } + + @TestRail(section = {TestGroup.REST_API, TestGroup.TRASHCAN, TestGroup.REQUIRE_SOLR}, executionType = ExecutionType.SANITY, + description = "Sanity test to verify Range request header on GET /deleted-nodes/{nodeId}/renditions/{renditionId}/content endpoint") + @Test(groups = {TestGroup.REST_API, TestGroup.TRASHCAN, TestGroup.SANITY}) + public void testGetDeletedNodesRenditionsandVerifyRangeRequestheader() throws Exception + { + // Create file4 based on existing resource + file4 = dataContent.usingUser(adminUserModel).usingSite(deleteNodesSiteModel).createContent(DocumentType.TEXT_PLAIN); + + // Create rendition and delete file4 to be moved in trashcan + restClient.withCoreAPI().usingNode(file4).createNodeRendition("pdf"); + restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); + dataContent.usingUser(adminUserModel).usingResource(file4).deleteContent(); + + // GET /deleted-nodes/{nodeId}/renditions/{id}/content and verify range request header + Utility.sleep(1000, 30000, () -> + { + restClient.configureRequestSpec().addHeader("content-range", "bytes=1-10"); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingTrashcan().getDeletedNodeRenditionContent(file4, "pdf"); + restClient.assertStatusCodeIs(HttpStatus.PARTIAL_CONTENT); + restClient.assertHeaderValueContains("Content-Type", "application/pdf;charset=UTF-8"); + restClient.assertHeaderValueContains("content-range", "bytes 1-10"); + restClient.assertHeaderValueContains("content-length", String.valueOf(10)); + }); + } } From dd3bb2ec283074f49d1d561c7f86b1c6980790cf Mon Sep 17 00:00:00 2001 From: Raluca Munteanu Date: Wed, 14 Mar 2018 15:37:32 +0200 Subject: [PATCH 1323/1491] REPO-3344: Web Api Parameter `required` is not being used - Fixed error message. --- e2e-test/java/org/alfresco/rest/ratings/AddRatingTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/ratings/AddRatingTests.java b/e2e-test/java/org/alfresco/rest/ratings/AddRatingTests.java index 72e3595a4..7a9b7bf2a 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/AddRatingTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/AddRatingTests.java @@ -371,7 +371,7 @@ public class AddRatingTests extends RestTest restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating(""); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.NO_CONTENT, "No content to map due to end-of-input")); + .containsSummary(String.format(RestErrorModel.NO_CONTENT, "No content to map to Object due to end of input")); } @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, From e9f445bf4b6a0c4f6afd1c1a7639570410e3a6b9 Mon Sep 17 00:00:00 2001 From: Raluca Munteanu Date: Thu, 15 Mar 2018 14:04:57 +0000 Subject: [PATCH 1324/1491] Revert "Merge branch 'fix/REPO-3344_webApiParam_required_notUsed' into 'master'" This reverts merge request !65 --- e2e-test/java/org/alfresco/rest/ratings/AddRatingTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/ratings/AddRatingTests.java b/e2e-test/java/org/alfresco/rest/ratings/AddRatingTests.java index 7a9b7bf2a..72e3595a4 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/AddRatingTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/AddRatingTests.java @@ -371,7 +371,7 @@ public class AddRatingTests extends RestTest restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating(""); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.NO_CONTENT, "No content to map to Object due to end of input")); + .containsSummary(String.format(RestErrorModel.NO_CONTENT, "No content to map due to end-of-input")); } @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, From 1c7f2a663418d7d63afcca99dab9b4bd62469c70 Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Mon, 26 Mar 2018 13:16:28 +0100 Subject: [PATCH 1325/1491] Added SearchSuite.xml for easy running SearchTests on CI --- e2e-test/resources/SearchSuite.xml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 e2e-test/resources/SearchSuite.xml diff --git a/e2e-test/resources/SearchSuite.xml b/e2e-test/resources/SearchSuite.xml new file mode 100644 index 000000000..6c4166b94 --- /dev/null +++ b/e2e-test/resources/SearchSuite.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + From ec9fcb906088df8157ff365e3aee17e248b63232 Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Tue, 27 Mar 2018 18:18:48 +0100 Subject: [PATCH 1326/1491] BeforeClass changed to BeforeSuite to run data creation just once per Test Suite --- .../rest/search/AbstractSearchTest.java | 58 ++++++++-- .../rest/search/FacetedSearchTest.java | 106 ++++++++++-------- .../alfresco/rest/search/SearchAPATHTest.java | 4 +- .../sharedLinks/SharedLinksSanityTests.java | 2 - 4 files changed, 106 insertions(+), 64 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java index 4eeb2abc6..da422b633 100644 --- a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java @@ -18,15 +18,18 @@ */ package org.alfresco.rest.search; +import org.alfresco.dataprep.SiteService.Visibility; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.builder.NodesBuilder; +import org.alfresco.utility.Utility; +import org.alfresco.utility.data.RandomData; import org.alfresco.utility.model.ContentModel; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FileType; import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; -import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeSuite; /** * Abstract Search test class that contains useful methods @@ -40,37 +43,68 @@ import org.testng.annotations.BeforeClass; */ public class AbstractSearchTest extends RestTest { - protected static final String SEARCH_DATA_SAMPLE_FOLDER = "folder"; - UserModel userModel, adminUserModel; + protected static final String SEARCH_DATA_SAMPLE_FOLDER = "FolderSearch"; + protected static final String SEARCH_SITE_PUBLIC = RandomData.getRandomName("SiteSearch"); + protected static final String SEARCH_USER1 = "UserSearch1"; + protected static final String SEARCH_USER2 = "UserSearch2"; + protected static String unique_searchString; + + UserModel userModel, adminUserModel, userModel2; SiteModel siteModel; UserModel searchedUser; NodesBuilder nodesBuilder; - protected FileModel file,file2; - @BeforeClass(alwaysRun = true) + protected FileModel file, file2, file3, file4; + + @BeforeSuite(alwaysRun = true) public void dataPreparation() throws Exception { adminUserModel = dataUser.getAdminUser(); - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + userModel = dataUser.createRandomTestUser(SEARCH_USER1); + userModel2 = dataUser.createRandomTestUser(SEARCH_USER2); + + siteModel = new SiteModel(RandomData.getRandomName(SEARCH_SITE_PUBLIC)); + siteModel.setVisibility(Visibility.PUBLIC); + + siteModel = dataSite.usingUser(userModel).createSite(siteModel); + + unique_searchString = siteModel.getTitle(); //userModel.getUsername(); + /* * Create the following file structure for preconditions : * |- folder * |-- pangram.txt - * |-- cars.pdf + * |-- cars.txt + * |-- alfresco.txt */ nodesBuilder = restClient.authenticateUser(userModel).withCoreAPI().usingNode(ContentModel.my()).defineNodes(); FolderModel folder = new FolderModel(SEARCH_DATA_SAMPLE_FOLDER); dataContent.usingUser(userModel).usingSite(siteModel).createFolder(folder); + //Create files - file = new FileModel("pangram.txt", FileType.TEXT_PLAIN, "The quick brown fox jumps over the lazy dog"); - file2 = new FileModel("cars.txt", FileType.TEXT_PLAIN, "The landrover discovery is not a sports car"); + String title = "Title: " + unique_searchString; + String description = "Description: File is created for search tests by Author: " + unique_searchString + " . "; + + file = new FileModel("pangram.txt", "pangram" + title, description, FileType.TEXT_PLAIN, description + " The quick brown fox jumps over the lazy dog"); + + file2 = new FileModel("cars.txt", "cars" + title, description, FileType.TEXT_PLAIN, "The landrover discovery is not a sports car "); + + file3 = new FileModel("alfresco.txt", "alfresco" + title, description, FileType.TEXT_PLAIN, "Alfresco text file for search "); + + file4 = new FileModel(unique_searchString, "unique" + title, description, FileType.TEXT_PLAIN, "Unique text file for search "); + ContentModel cm = new ContentModel(); cm.setCmisLocation(folder.getCmisLocation()); cm.setName(folder.getName()); - dataContent.usingUser(userModel).usingSite(siteModel).usingResource(cm).createContent(file); - dataContent.usingUser(userModel).usingSite(siteModel).usingResource(cm).createContent(file2); + + dataContent.usingUser(userModel).usingSite(siteModel).usingResource(folder).createContent(file); + dataContent.usingUser(userModel).usingSite(siteModel).usingResource(folder).createContent(file2); + dataContent.usingUser(userModel).usingSite(siteModel).usingResource(folder).createContent(file3); + dataContent.usingUser(userModel).usingSite(siteModel).usingResource(folder).createContent(file4); + + Utility.waitToLoopTime(60, "Wait For Index"); } + /** * Helper method which create an http post request to Search API end point. * @param term String search term diff --git a/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java b/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java index a8eccf613..8722f10a3 100644 --- a/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java @@ -36,9 +36,6 @@ import org.testng.annotations.Test; public class FacetedSearchTest extends AbstractSearchTest { - @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, - description = "Checks facet queries for the Search api") /** * Perform the below facet query. * { @@ -89,13 +86,16 @@ public class FacetedSearchTest extends AbstractSearchTest * }} * @throws Exception */ + + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) + @TestRail(section = { TestGroup.REST_API, TestGroup.SEARCH, + TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, description = "Checks facet queries for the Search api") public void searchWithQueryFaceting() throws Exception - { + { SearchRequest query = new SearchRequest(); - RestRequestQueryModel queryReq = new RestRequestQueryModel(); + RestRequestQueryModel queryReq = new RestRequestQueryModel(); queryReq.setQuery("cars"); query.setQuery(queryReq); - List facets = new ArrayList(); facets.add(new FacetQuery("content.size:[0 TO 102400]", "small")); @@ -109,9 +109,11 @@ public class FacetedSearchTest extends AbstractSearchTest query.setFacetFields(facetFields); query.setIncludeRequest(true); - SearchResponse response = query(query); + SearchResponse response = query(query); + response.assertThat().entriesListIsNotEmpty(); response.getContext().assertThat().field("facetQueries").isNotEmpty(); + FacetFieldBucket facet = response.getContext().getFacetQueries().get(0); facet.assertThat().field("label").contains("small").and().field("count").isGreaterThan(0); facet.assertThat().field("label").contains("small").and().field("filterQuery").is("content.size:[0 TO 102400]"); @@ -173,52 +175,53 @@ public class FacetedSearchTest extends AbstractSearchTest public void searchQueryFacetingWithGroup() throws Exception { SearchRequest query = new SearchRequest(); - RestRequestQueryModel queryReq = new RestRequestQueryModel(); + RestRequestQueryModel queryReq = new RestRequestQueryModel(); queryReq.setQuery("cars"); query.setQuery(queryReq); List facets = new ArrayList(); facets.add(new FacetQuery("content.size:[0 TO 102400]", "small", "foo")); - facets.add(new FacetQuery("content.size:[102400 TO 1048576]", "medium","foo")); - facets.add(new FacetQuery("content.size:[1048576 TO 16777216]", "large","foo")); + facets.add(new FacetQuery("content.size:[102400 TO 1048576]", "medium", "foo")); + facets.add(new FacetQuery("content.size:[1048576 TO 16777216]", "large", "foo")); query.setFacetQueries(facets); - + RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); List list = new ArrayList<>(); list.add(new RestRequestFacetFieldModel("'content.size'")); facetFields.setFacets(list); - query.setFacetFields(facetFields); - SearchResponse response = query(query); - //We don't expect to see the FacetQueries if group is being used. + + SearchResponse response = query(query); + + // We don't expect to see the FacetQueries if group is being used. Assert.assertTrue(response.getContext().getFacetQueries() == null); - //Validate the facet field structure is correct. + // Validate the facet field structure is correct. Assert.assertFalse(response.getContext().getFacets().isEmpty()); Assert.assertEquals(response.getContext().getFacets().get(0).getLabel(), "foo"); - + RestGenericBucketModel bucket = response.getContext().getFacets().get(0).getBuckets().get(0); bucket.assertThat().field("label").isNotEmpty(); - Assert.assertEquals( bucket.getMetrics().get(0).getType(), "count"); - Assert.assertNotEquals( bucket.getMetrics().get(0).getValue(), ""); + Assert.assertEquals(bucket.getMetrics().get(0).getType(), "count"); + Assert.assertNotEquals(bucket.getMetrics().get(0).getValue(), ""); bucket.assertThat().field("filterQuery").isNotEmpty(); response.getContext().getFacets().get(0).getBuckets().forEach(action -> { switch (action.getLabel()) { - case "small": - Assert.assertEquals(action.getFilterQuery(), "content.size:[0 TO 102400]"); - break; - case "medium": - Assert.assertEquals(action.getFilterQuery(), "content.size:[102400 TO 1048576]"); - break; - case "large": - Assert.assertEquals(action.getFilterQuery(), "content.size:[1048576 TO 16777216]"); - break; + case "small": + Assert.assertEquals(action.getFilterQuery(), "content.size:[0 TO 102400]"); + break; + case "medium": + Assert.assertEquals(action.getFilterQuery(), "content.size:[102400 TO 1048576]"); + break; + case "large": + Assert.assertEquals(action.getFilterQuery(), "content.size:[1048576 TO 16777216]"); + break; - default: - throw new TestException("Unexpected value returned"); + default: + throw new TestException("Unexpected value returned"); } }); - + } @Test @@ -235,29 +238,34 @@ public class FacetedSearchTest extends AbstractSearchTest public void searchWithFactedFields() throws Exception { SearchRequest query = new SearchRequest(); - RestRequestQueryModel queryReq = new RestRequestQueryModel(); - queryReq.setQuery("*"); + RestRequestQueryModel queryReq = new RestRequestQueryModel(); + queryReq.setQuery(unique_searchString); query.setQuery(queryReq); + RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); - Listfacets = new ArrayList(); + List facets = new ArrayList(); facets.add(new RestRequestFacetFieldModel("cm:mimetype")); facets.add(new RestRequestFacetFieldModel("modifier")); facetFields.setFacets(facets); query.setFacetFields(facetFields); - SearchResponse response = query(query); + + SearchResponse response = query(query); + Assert.assertFalse(response.getContext().getFacetsFields().isEmpty()); Assert.assertNull(response.getContext().getFacetQueries()); Assert.assertNull(response.getContext().getFacets()); + RestResultBucketsModel model = response.getContext().getFacetsFields().get(0); Assert.assertEquals(model.getLabel(), "modifier"); - + model.assertThat().field("label").is("modifier"); FacetFieldBucket bucket1 = model.getBuckets().get(0); - bucket1.assertThat().field("label").is("System"); - bucket1.assertThat().field("display").is("System"); - bucket1.assertThat().field("filterQuery").is("modifier:\"System\""); - bucket1.assertThat().field("count").is(684); + bucket1.assertThat().field("label").is(userModel.getUsername()); + bucket1.assertThat().field("display").is(userModel.getUsername() + " FirstName LN-" + userModel.getUsername()); + bucket1.assertThat().field("filterQuery").is("modifier:\"" + userModel.getUsername() + "\""); + bucket1.assertThat().field("count").is(1); } + @Test /** * Test that items returned are in the format of generic facets. @@ -274,29 +282,31 @@ public class FacetedSearchTest extends AbstractSearchTest public void searchWithFactedFieldsFacetFormatV2() throws Exception { SearchRequest query = new SearchRequest(); - RestRequestQueryModel queryReq = new RestRequestQueryModel(); - queryReq.setQuery("*"); + RestRequestQueryModel queryReq = new RestRequestQueryModel(); + queryReq.setQuery(unique_searchString); query.setQuery(queryReq); query.setFacetFormat("V2"); RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); - Listfacets = new ArrayList(); + List facets = new ArrayList(); facets.add(new RestRequestFacetFieldModel("cm:mimetype")); facets.add(new RestRequestFacetFieldModel("modifier")); facetFields.setFacets(facets); query.setFacetFields(facetFields); - SearchResponse response = query(query); + + SearchResponse response = query(query); + Assert.assertNull(response.getContext().getFacetsFields()); Assert.assertNull(response.getContext().getFacetQueries()); Assert.assertFalse(response.getContext().getFacets().isEmpty()); RestGenericFacetResponseModel model = response.getContext().getFacets().get(0); Assert.assertEquals(model.getLabel(), "modifier"); - + model.assertThat().field("label").is("modifier"); RestGenericBucketModel bucket1 = model.getBuckets().get(0); - bucket1.assertThat().field("label").is("System"); - bucket1.assertThat().field("display").isNull(); - bucket1.assertThat().field("filterQuery").is("modifier:\"System\""); - bucket1.assertThat().field("metrics").is("[{entry=null, type=count, value={count=684}}]"); + bucket1.assertThat().field("label").is(userModel.getUsername()); + bucket1.assertThat().field("display").is(userModel.getUsername() + " FirstName LN-" + userModel.getUsername()); + bucket1.assertThat().field("filterQuery").is("modifier:\"" + userModel.getUsername() + "\""); + bucket1.assertThat().field("metrics").is("[{entry=null, type=count, value={count=1}}]"); } } diff --git a/e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java b/e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java index 030494997..eb5564d5a 100644 --- a/e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java +++ b/e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java @@ -121,7 +121,7 @@ public class SearchAPATHTest extends AbstractSearchTest { SearchRequest searchQuery = new SearchRequest(); RestRequestQueryModel queryReq = new RestRequestQueryModel(); - queryReq.setQuery("name:*"); + queryReq.setQuery("name:cars*"); searchQuery.setQuery(queryReq); RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); @@ -151,7 +151,7 @@ public class SearchAPATHTest extends AbstractSearchTest */ searchQuery = new SearchRequest(); queryReq = new RestRequestQueryModel(); - queryReq.setQuery("name:*"); + queryReq.setQuery("name:cars*"); searchQuery.setQuery(queryReq); facetFields = new RestRequestFacetFieldsModel(); list.remove(0); diff --git a/e2e-test/java/org/alfresco/rest/sharedLinks/SharedLinksSanityTests.java b/e2e-test/java/org/alfresco/rest/sharedLinks/SharedLinksSanityTests.java index d41f2d646..c9dbc91fe 100644 --- a/e2e-test/java/org/alfresco/rest/sharedLinks/SharedLinksSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sharedLinks/SharedLinksSanityTests.java @@ -1,7 +1,5 @@ package org.alfresco.rest.sharedLinks; -import static org.testng.Assert.assertEquals; - import javax.json.Json; import org.alfresco.dataprep.CMISUtil.DocumentType; From 7eb79ccfbfe6e7361348c71edc8d81a12ece3ec4 Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Thu, 29 Mar 2018 09:36:10 +0100 Subject: [PATCH 1327/1491] Search-771: Added ShardInfo Search Tests in the new TestGroup ACS 6.0, Structured SearchSuite.xml --- .../alfresco/rest/search/ShardInfoTest.java | 4 +-- e2e-test/resources/SearchSuite.xml | 29 +++++++++++++++---- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/ShardInfoTest.java b/e2e-test/java/org/alfresco/rest/search/ShardInfoTest.java index abc59ff03..cedca8032 100644 --- a/e2e-test/java/org/alfresco/rest/search/ShardInfoTest.java +++ b/e2e-test/java/org/alfresco/rest/search/ShardInfoTest.java @@ -41,7 +41,7 @@ import org.testng.annotations.Test; public class ShardInfoTest extends AbstractSearchTest { @Bug(id="DELENG-1", status=Bug.Status.OPENED) - @Test(groups={TestGroup.SEARCH, TestGroup.REST_API}) + @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ACS_60n}) public void getShardInfoWithAdminAuthority() throws JsonProcessingException, EmptyRestModelCollectionException { RestShardInfoModelCollection info = restClient.authenticateUser(dataUser.getAdminUser()).withShardInfoAPI().getInfo(); @@ -78,7 +78,7 @@ public class ShardInfoTest extends AbstractSearchTest } @Bug(id="DELENG-1", status=Bug.Status.OPENED) - @Test(groups={TestGroup.SEARCH, TestGroup.REST_API}) + @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ACS_60n}) public void getShardInfoWithoutAdminAuthority() throws Exception { restClient.authenticateUser(dataUser.createRandomTestUser()).withShardInfoAPI().getInfo(); diff --git a/e2e-test/resources/SearchSuite.xml b/e2e-test/resources/SearchSuite.xml index 6c4166b94..34bc53bb6 100644 --- a/e2e-test/resources/SearchSuite.xml +++ b/e2e-test/resources/SearchSuite.xml @@ -7,10 +7,29 @@ - - - - + + + + + + + + + + + + + + + + + + + + + + + + - From b135a09b5c4668658119276beb0b78f47e6d308a Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Wed, 18 Apr 2018 13:21:04 +0100 Subject: [PATCH 1328/1491] Removed the extra space in basePath for search api, adding Fingerprint test setup to run always --- e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java b/e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java index 675d5da3c..fd3381b3d 100644 --- a/e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java @@ -35,7 +35,7 @@ import org.testng.annotations.Test; public class FingerPrintTest extends AbstractSearchTest { private FileModel file1,file2,file3,file4; - @BeforeClass + @BeforeClass(alwaysRun=true) public void indexSimilarFile() throws Exception { adminUserModel = dataUser.getAdminUser(); From 97bec655ccde8705d262625dc3773151b334920d Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Thu, 19 Apr 2018 15:05:01 +0100 Subject: [PATCH 1329/1491] Putting back BeforeClass annotation to perform dataprep per test class --- .../java/org/alfresco/rest/search/AbstractSearchTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java index da422b633..e6f1ee90b 100644 --- a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java @@ -29,7 +29,7 @@ import org.alfresco.utility.model.FileType; import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; -import org.testng.annotations.BeforeSuite; +import org.testng.annotations.BeforeClass; /** * Abstract Search test class that contains useful methods @@ -56,7 +56,7 @@ public class AbstractSearchTest extends RestTest protected FileModel file, file2, file3, file4; - @BeforeSuite(alwaysRun = true) + @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception { adminUserModel = dataUser.getAdminUser(); From 19f29f7076bde6077878a56a9c2312b64d5a429b Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Wed, 25 Apr 2018 14:10:00 +0100 Subject: [PATCH 1330/1491] Search-811 --- .../java/org/alfresco/rest/search/AbstractSearchTest.java | 4 ++-- .../java/org/alfresco/rest/search/SearchSpellCheckTest.java | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java index e6f1ee90b..0d7508a40 100644 --- a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 Alfresco Software Limited. + * Copyright (C) 2018 Alfresco Software Limited. * * This file is part of Alfresco * @@ -89,7 +89,7 @@ public class AbstractSearchTest extends RestTest file2 = new FileModel("cars.txt", "cars" + title, description, FileType.TEXT_PLAIN, "The landrover discovery is not a sports car "); - file3 = new FileModel("alfresco.txt", "alfresco" + title, description, FileType.TEXT_PLAIN, "Alfresco text file for search "); + file3 = new FileModel("alfresco.txt", "alfresco " + title, "alfresco " + description, FileType.TEXT_PLAIN, "Alfresco text file for search "); file4 = new FileModel(unique_searchString, "unique" + title, description, FileType.TEXT_PLAIN, "Unique text file for search "); diff --git a/e2e-test/java/org/alfresco/rest/search/SearchSpellCheckTest.java b/e2e-test/java/org/alfresco/rest/search/SearchSpellCheckTest.java index a13e447fb..6fec23292 100644 --- a/e2e-test/java/org/alfresco/rest/search/SearchSpellCheckTest.java +++ b/e2e-test/java/org/alfresco/rest/search/SearchSpellCheckTest.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 Alfresco Software Limited. + * Copyright (C) 2018 Alfresco Software Limited. * * This file is part of Alfresco * @@ -78,6 +78,7 @@ public class SearchSpellCheckTest extends AbstractSearchTest nodes.getContext().assertThat().field("spellCheck").isNotEmpty(); nodes.getContext().getSpellCheck().assertThat().field("suggestions").contains("alfresco"); } + @Test /** * Perform alternative way by setting the value in spellcheck object. @@ -103,6 +104,7 @@ public class SearchSpellCheckTest extends AbstractSearchTest searchReq.setSpellcheck(spellCheck); assertResponse(query(searchReq)); } + @Test public void searchWithSpellcheckerAndCorrectSpelling() throws Exception { @@ -113,7 +115,7 @@ public class SearchSpellCheckTest extends AbstractSearchTest searchReq.setQuery(queryReq); searchReq.setSpellcheck(new RestRequestSpellcheckModel()); SearchResponse res = query(searchReq); - Assert.assertNull(res.getContext()); + Assert.assertNull(res.getContext().getSpellCheck()); res.assertThat().entriesListIsNotEmpty(); } } From 2cd682d1b4dc9c4879e7c5b0945b2f342a7a73d0 Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Thu, 26 Apr 2018 09:53:25 +0100 Subject: [PATCH 1331/1491] Search-811: Test Issue Fixed --- e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java index 0d7508a40..9bedb0c6f 100644 --- a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java @@ -89,7 +89,7 @@ public class AbstractSearchTest extends RestTest file2 = new FileModel("cars.txt", "cars" + title, description, FileType.TEXT_PLAIN, "The landrover discovery is not a sports car "); - file3 = new FileModel("alfresco.txt", "alfresco " + title, "alfresco " + description, FileType.TEXT_PLAIN, "Alfresco text file for search "); + file3 = new FileModel("alfresco.txt", "alfresco", "alfresco", FileType.TEXT_PLAIN, "Alfresco text file for search "); file4 = new FileModel(unique_searchString, "unique" + title, description, FileType.TEXT_PLAIN, "Unique text file for search "); From fdef0db9caa21aaefac33ee5efbb9dd6847ba86a Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Thu, 26 Apr 2018 11:15:02 +0100 Subject: [PATCH 1332/1491] Search-811: Test Coverage added for SpellCheck Tests to cover name, description, content, spellcheck type --- e2e-test/java/org/alfresco/rest/RestTest.java | 6 ++ .../rest/search/AbstractSearchTest.java | 2 +- .../rest/search/SearchSpellCheckTest.java | 71 +++++++++++++++++-- e2e-test/resources/default.properties | 3 + 4 files changed, 75 insertions(+), 7 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/RestTest.java b/e2e-test/java/org/alfresco/rest/RestTest.java index 0358a948d..76963a8dc 100644 --- a/e2e-test/java/org/alfresco/rest/RestTest.java +++ b/e2e-test/java/org/alfresco/rest/RestTest.java @@ -7,6 +7,7 @@ import org.alfresco.rest.core.RestProperties; import org.alfresco.rest.core.RestWrapper; import org.alfresco.utility.LogFactory; import org.alfresco.utility.TasProperties; +import org.alfresco.utility.Utility; import org.alfresco.utility.data.DataContent; import org.alfresco.utility.data.DataDiscussion; import org.alfresco.utility.data.DataGroup; @@ -85,4 +86,9 @@ public abstract class RestTest extends AbstractTestNGSpringContextTests { LOG.info(String.format("*** ENDING Test: [%s] ***", method.getName())); } + + public void waitForIndexing() + { + Utility.waitToLoopTime(properties.getSolrWaitTimeInSeconds(), "Wait For Index"); + } } diff --git a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java index 9bedb0c6f..062640a51 100644 --- a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java @@ -102,7 +102,7 @@ public class AbstractSearchTest extends RestTest dataContent.usingUser(userModel).usingSite(siteModel).usingResource(folder).createContent(file3); dataContent.usingUser(userModel).usingSite(siteModel).usingResource(folder).createContent(file4); - Utility.waitToLoopTime(60, "Wait For Index"); + waitForIndexing(); } /** diff --git a/e2e-test/java/org/alfresco/rest/search/SearchSpellCheckTest.java b/e2e-test/java/org/alfresco/rest/search/SearchSpellCheckTest.java index 6fec23292..a1d663830 100644 --- a/e2e-test/java/org/alfresco/rest/search/SearchSpellCheckTest.java +++ b/e2e-test/java/org/alfresco/rest/search/SearchSpellCheckTest.java @@ -19,6 +19,8 @@ package org.alfresco.rest.search; import org.alfresco.rest.model.RestRequestSpellcheckModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FileType; import org.alfresco.utility.model.TestGroup; import org.junit.Assert; import org.testng.annotations.Test; @@ -30,6 +32,8 @@ import org.testng.annotations.Test; */ public class SearchSpellCheckTest extends AbstractSearchTest { + protected FileModel file = new FileModel("alfesco.txt", "alfesco", "alfesco", FileType.TEXT_PLAIN, "alfesco text file for search "); + /** * Perform the below query * { @@ -61,25 +65,48 @@ public class SearchSpellCheckTest extends AbstractSearchTest * * @throws Exception */ - @Test(groups={TestGroup.SEARCH, TestGroup.REST_API}) - public void searchMissSpelled() throws Exception + @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ACS_60n}, priority=1) + public void testSearchMissSpelled() throws Exception { + // Name SearchRequest searchReq = new SearchRequest(); RestRequestQueryModel queryReq = new RestRequestQueryModel(); + queryReq.setQuery("cm:name:alfrezco"); + queryReq.setUserQuery("alfrezco"); + searchReq.setQuery(queryReq); + searchReq.setSpellcheck(new RestRequestSpellcheckModel()); + assertResponse(query(searchReq)); + + // Title queryReq.setQuery("cm:title:alfrezco"); queryReq.setUserQuery("alfrezco"); searchReq.setQuery(queryReq); searchReq.setSpellcheck(new RestRequestSpellcheckModel()); assertResponse(query(searchReq)); + + // Description + queryReq.setQuery("cm:description:alfrezco"); + queryReq.setUserQuery("alfrezco"); + searchReq.setQuery(queryReq); + searchReq.setSpellcheck(new RestRequestSpellcheckModel()); + assertResponse(query(searchReq)); + + // Content + queryReq.setQuery("cm:content:alfrezco"); + queryReq.setUserQuery("alfrezco"); + searchReq.setQuery(queryReq); + searchReq.setSpellcheck(new RestRequestSpellcheckModel()); + assertResponse(query(searchReq)); } + private void assertResponse(SearchResponse nodes) throws Exception { nodes.assertThat().entriesListIsNotEmpty(); nodes.getContext().assertThat().field("spellCheck").isNotEmpty(); nodes.getContext().getSpellCheck().assertThat().field("suggestions").contains("alfresco"); + nodes.getContext().getSpellCheck().assertThat().field("type").is("searchInsteadFor"); } - @Test /** * Perform alternative way by setting the value in spellcheck object. * @@ -92,7 +119,8 @@ public class SearchSpellCheckTest extends AbstractSearchTest * } * @throws Exception */ - public void searchMissSpelledVersion2() throws Exception + @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ACS_60n}, priority=2) + public void testSearchMissSpelledVersion2() throws Exception { SearchRequest searchReq = new SearchRequest(); RestRequestQueryModel queryReq = new RestRequestQueryModel(); @@ -105,8 +133,8 @@ public class SearchSpellCheckTest extends AbstractSearchTest assertResponse(query(searchReq)); } - @Test - public void searchWithSpellcheckerAndCorrectSpelling() throws Exception + @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ACS_60n}, priority=3) + public void testSearchWithSpellcheckerAndCorrectSpelling() throws Exception { SearchRequest searchReq = new SearchRequest(); RestRequestQueryModel queryReq = new RestRequestQueryModel(); @@ -118,4 +146,35 @@ public class SearchSpellCheckTest extends AbstractSearchTest Assert.assertNull(res.getContext().getSpellCheck()); res.assertThat().entriesListIsNotEmpty(); } + + @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ACS_60n}, priority=4) + public void testSpellCheckType() throws Exception + { + try + { + // Create a file with mis-spelt name, expect spellcheck type = didYouMean + dataContent.usingUser(userModel).usingSite(siteModel).createContent(file); + + waitForIndexing(); + + // Search + SearchRequest searchReq = new SearchRequest(); + RestRequestQueryModel queryReq = new RestRequestQueryModel(); + queryReq.setQuery("cm:name:alfesco"); + queryReq.setUserQuery("alfesco"); + searchReq.setQuery(queryReq); + searchReq.setSpellcheck(new RestRequestSpellcheckModel()); + SearchResponse nodes = query(searchReq); + + nodes.assertThat().entriesListIsNotEmpty(); + nodes.getContext().assertThat().field("spellCheck").isNotEmpty(); + nodes.getContext().getSpellCheck().assertThat().field("suggestions").contains("alfresco"); + nodes.getContext().getSpellCheck().assertThat().field("type").is("didYouMean"); + } + finally + { + // Delete this file, else it will cause incorrect results for other spell-check tests when rerunning on the same environment + dataContent.usingUser(userModel).usingSite(siteModel).usingResource(file).deleteContent(); + } + } } diff --git a/e2e-test/resources/default.properties b/e2e-test/resources/default.properties index 7c7516125..1ad5a1d61 100644 --- a/e2e-test/resources/default.properties +++ b/e2e-test/resources/default.properties @@ -8,6 +8,9 @@ sync.scheme=http sync.server=localhost sync.port=9090 +#Solr Indexing Time +solrWaitTimeInSeconds=60 + # credentials admin.user=admin admin.password=admin From 65c9e45c5465ef8ca6c66f9e1c529d8d3b58d264 Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Fri, 27 Apr 2018 13:20:58 +0100 Subject: [PATCH 1333/1491] Amended the tas-utility snapshot version --- e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java index 062640a51..df0b00e41 100644 --- a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java @@ -21,7 +21,6 @@ package org.alfresco.rest.search; import org.alfresco.dataprep.SiteService.Visibility; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.builder.NodesBuilder; -import org.alfresco.utility.Utility; import org.alfresco.utility.data.RandomData; import org.alfresco.utility.model.ContentModel; import org.alfresco.utility.model.FileModel; From 1ac1d78b9bf9fbdbd4a282bf99ef6e222a82fd31 Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Mon, 30 Apr 2018 12:08:48 +0100 Subject: [PATCH 1334/1491] Removed unnecessary changes in dataprep --- .../rest/search/AbstractSearchTest.java | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java index df0b00e41..d5b2014c0 100644 --- a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java @@ -42,32 +42,28 @@ import org.testng.annotations.BeforeClass; */ public class AbstractSearchTest extends RestTest { + protected static final String SEARCH_DATA_SAMPLE_FOLDER = "FolderSearch"; - protected static final String SEARCH_SITE_PUBLIC = RandomData.getRandomName("SiteSearch"); - protected static final String SEARCH_USER1 = "UserSearch1"; - protected static final String SEARCH_USER2 = "UserSearch2"; - protected static String unique_searchString; - - UserModel userModel, adminUserModel, userModel2; + UserModel userModel, adminUserModel; SiteModel siteModel; UserModel searchedUser; NodesBuilder nodesBuilder; - protected FileModel file, file2, file3, file4; + + protected static String unique_searchString; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception { adminUserModel = dataUser.getAdminUser(); - userModel = dataUser.createRandomTestUser(SEARCH_USER1); - userModel2 = dataUser.createRandomTestUser(SEARCH_USER2); + userModel = dataUser.createRandomTestUser("UserSearch"); - siteModel = new SiteModel(RandomData.getRandomName(SEARCH_SITE_PUBLIC)); - siteModel.setVisibility(Visibility.PUBLIC); + siteModel = new SiteModel(RandomData.getRandomName("SiteSearch")); + siteModel.setVisibility(Visibility.PRIVATE); siteModel = dataSite.usingUser(userModel).createSite(siteModel); - unique_searchString = siteModel.getTitle(); //userModel.getUsername(); + unique_searchString = siteModel.getTitle(); /* * Create the following file structure for preconditions : @@ -75,6 +71,7 @@ public class AbstractSearchTest extends RestTest * |-- pangram.txt * |-- cars.txt * |-- alfresco.txt + * |-- */ nodesBuilder = restClient.authenticateUser(userModel).withCoreAPI().usingNode(ContentModel.my()).defineNodes(); FolderModel folder = new FolderModel(SEARCH_DATA_SAMPLE_FOLDER); @@ -141,7 +138,7 @@ public class AbstractSearchTest extends RestTest */ protected SearchResponse query(SearchRequest query) throws Exception { - return restClient.authenticateUser(dataUser.getAdminUser()).withSearchAPI().search(query); + return restClient.authenticateUser(userModel).withSearchAPI().search(query); } protected SearchRequest createQuery(String term) { From b6b032cf04f88ebc90ded073b23754c750e4ce4f Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Mon, 30 Apr 2018 13:16:13 +0100 Subject: [PATCH 1335/1491] Fixed the bucket size assert and Removed system.out.println --- .../java/org/alfresco/rest/search/SearchAPATHTest.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java b/e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java index eb5564d5a..eab9130dc 100644 --- a/e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java +++ b/e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java @@ -116,6 +116,7 @@ public class SearchAPATHTest extends AbstractSearchTest Assert.assertEquals(4,fresponse.getBuckets().size()); fresponse.getBuckets().get(0).assertThat().field("label").contains("1/"); } + @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_1}) public void searchLevel2() throws Exception { @@ -131,6 +132,7 @@ public class SearchAPATHTest extends AbstractSearchTest searchQuery.setFacetFields(facetFields); SearchResponse response = query(searchQuery); + RestResultBucketsModel fresponse = response.getContext().getFacetsFields().get(0); String path = fresponse.getBuckets().get(0).getLabel().replace("1/", "2/"); list.remove(0); @@ -140,7 +142,7 @@ public class SearchAPATHTest extends AbstractSearchTest searchQuery.setFacetFields(facetFields); response = query(searchQuery); fresponse = response.getContext().getFacetsFields().get(0); - Assert.assertEquals(fresponse.getBuckets().size(),3); + Assert.assertTrue(fresponse.getBuckets().size() >= 1); fresponse.getBuckets().get(0).assertThat().field("label").contains("2/"); fresponse.getBuckets().get(0).assertThat().field("label").contains(path); /** @@ -160,8 +162,7 @@ public class SearchAPATHTest extends AbstractSearchTest searchQuery.setFacetFields(facetFields); response = query(searchQuery); fresponse = response.getContext().getFacetsFields().get(0); - System.out.println(response); - Assert.assertTrue(fresponse.getBuckets().size() > 5); + Assert.assertTrue(fresponse.getBuckets().size() >= 1); fresponse.getBuckets().get(0).assertThat().field("label").contains("3/"); } } From 03dd502ca1ed21014a4af427e80e0056e2da6d0f Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Mon, 30 Apr 2018 14:23:27 +0100 Subject: [PATCH 1336/1491] Removed the overriding of dataPreperation from faceted search tests --- .../java/org/alfresco/rest/search/FacetRangeSearchTest.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java b/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java index d4ae6bfa7..2b77bef20 100644 --- a/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java @@ -61,11 +61,7 @@ import org.testng.annotations.Test; */ public class FacetRangeSearchTest extends AbstractSearchTest { - @Override - public void dataPreparation() throws Exception - { - //Skip setup - } + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, description = "Check facet intervals mandatory fields") From 6ae3acab951ad1759921eda746aef783f877d6d1 Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Mon, 30 Apr 2018 16:24:35 +0100 Subject: [PATCH 1337/1491] Removed unused variables --- .../rest/search/FacetIntervalSearchTest.java | 14 ++++++++------ .../alfresco/rest/search/FacetRangeSearchTest.java | 14 ++++++++++---- .../rest/search/PivotFacetedSearchTest.java | 7 +++++-- 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/FacetIntervalSearchTest.java b/e2e-test/java/org/alfresco/rest/search/FacetIntervalSearchTest.java index 9d8d74b37..d32f3ebe9 100644 --- a/e2e-test/java/org/alfresco/rest/search/FacetIntervalSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FacetIntervalSearchTest.java @@ -48,23 +48,23 @@ public class FacetIntervalSearchTest extends AbstractSearchTest facetIntervalsModel.setIntervals(Arrays.asList(facetInterval)); query.setFacetIntervals(facetIntervalsModel); - SearchResponse response = query(query); + query(query); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() .containsSummary(String.format(RestErrorModel.MANDATORY_PARAM, "facetIntervals intervals field")); facetInterval.setField("created"); - response = query(query); + query(query); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() .containsSummary(String.format(RestErrorModel.MANDATORY_COLLECTION, "facetIntervals intervals sets")); RestRequestFacetSetModel restFacetSetModel = new RestRequestFacetSetModel(); restFacetSetModel.setLabel("theRest"); facetInterval.setSets(Arrays.asList(restFacetSetModel)); - response = query(query); + query(query); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() .containsSummary(String.format(RestErrorModel.MANDATORY_PARAM, "facetIntervals intervals created sets start")); restFacetSetModel.setStart("A"); - response = query(query); + query(query); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() .containsSummary(String.format(RestErrorModel.MANDATORY_PARAM, "facetIntervals intervals created sets end")); @@ -74,7 +74,8 @@ public class FacetIntervalSearchTest extends AbstractSearchTest duplicate.setLabel("theRest"); duplicate.setStart("A"); duplicate.setEnd("C"); - response = query(query); + + query(query); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() .containsSummary("duplicate set interval label [theRest=2]"); @@ -83,7 +84,8 @@ public class FacetIntervalSearchTest extends AbstractSearchTest FacetInterval duplicateLabel = new FacetInterval("creator", "thesame", Arrays.asList(duplicate)); facetIntervalsModel.setIntervals(Arrays.asList(facetInterval, duplicateLabel)); query.setFacetIntervals(facetIntervalsModel); - response = query(query); + + query(query); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() .containsSummary("duplicate interval label [thesame=2]"); diff --git a/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java b/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java index 2b77bef20..1add86965 100644 --- a/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java @@ -72,7 +72,7 @@ public class FacetRangeSearchTest extends AbstractSearchTest RestRequestRangesModel facetRangeModel = new RestRequestRangesModel(); ranges.add(facetRangeModel); query.setRanges(ranges); - SearchResponse response = query(query); + query(query); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() .containsSummary(String.format(RestErrorModel.MANDATORY_PARAM, "field")); @@ -80,21 +80,27 @@ public class FacetRangeSearchTest extends AbstractSearchTest facetRangeModel.setField("content.size"); ranges.add(facetRangeModel); query.setRanges(ranges); - response = query(query); + + query(query); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() .containsSummary(String.format(RestErrorModel.MANDATORY_PARAM, "start")); facetRangeModel.setStart("0"); ranges.clear(); ranges.add(facetRangeModel); query.setRanges(ranges); - response = query(query); + + query(query); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() .containsSummary(String.format(RestErrorModel.MANDATORY_PARAM, "end")); facetRangeModel.setEnd("400"); query.setRanges(ranges); ranges.clear(); ranges.add(facetRangeModel); - response = query(query); + + query(query); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() .containsSummary(String.format(RestErrorModel.MANDATORY_PARAM, "gap")); diff --git a/e2e-test/java/org/alfresco/rest/search/PivotFacetedSearchTest.java b/e2e-test/java/org/alfresco/rest/search/PivotFacetedSearchTest.java index bc54be77d..c21b9e2c7 100644 --- a/e2e-test/java/org/alfresco/rest/search/PivotFacetedSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/PivotFacetedSearchTest.java @@ -60,12 +60,15 @@ public class PivotFacetedSearchTest extends AbstractSearchTest pivotModelList.add(pivots); query.setPivots(pivotModelList); - SearchResponse response = query(query); + query(query); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() .containsSummary(String.format(RestErrorModel.MANDATORY_PARAM, "pivot key")); pivots.setKey("none_like_this"); - response = query(query); + + query(query); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) .assertLastError().containsSummary("invalid argument was received") .containsSummary("Pivot parameter none_like_this does not reference"); From 209477ade1d9f2936e5b1f279365f91ccf857a7f Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Mon, 30 Apr 2018 17:10:05 +0100 Subject: [PATCH 1338/1491] Fixed issue with the test class Updated tas-utility snapshot to include insight engine tag. --- .../rest/search/sql/SearchSQLTest.java | 101 ++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/search/sql/SearchSQLTest.java diff --git a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLTest.java b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLTest.java new file mode 100644 index 000000000..e080c74e5 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLTest.java @@ -0,0 +1,101 @@ +/* + * Copyright (C) 2017 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.rest.search.sql; + +import static org.junit.Assert.assertNotNull; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.Properties; + +import org.alfresco.dataprep.SiteService.Visibility; +import org.alfresco.rest.search.AbstractSearchTest; +import org.alfresco.utility.data.RandomData; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Search SQL end point Public API test. + * @author Michael Suzuki + * + */ +public class SearchSQLTest extends AbstractSearchTest +{ + UserModel userModel, adminUser, managerUser; + SiteModel siteModel; + FileModel document; + String connectionString; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + + connectionString = properties.getFullServerUrl() + "/alfresco/api/-default-/public/search/versions/1"; + + adminUser = dataUser.getAdminUser(); + userModel = dataUser.createRandomTestUser("UserSearch"); + managerUser = dataUser.createRandomTestUser("UserSearchMgr"); + + //Create site + adminUser = dataUser.getAdminUser(); + restClient.authenticateUser(adminUser); + + siteModel = new SiteModel(RandomData.getRandomName("SiteSearch")); + siteModel.setVisibility(Visibility.PRIVATE); + + siteModel = dataSite.usingUser(userModel).createSite(siteModel); + } + + @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10}) + public void queryTest() throws SQLException + { + String sql = "select SITE, CM_OWNER from alfresco group by SITE,CM_OWNER"; + Properties props = new Properties(); + props.put("user", adminUser.getUsername()); + props.put("password", adminUser.getPassword()); + Connection con = null; + Statement stmt = null; + ResultSet rs = null; + try + { + con = DriverManager.getConnection(connectionString, props); + stmt = con.createStatement(); + rs = stmt.executeQuery(sql); + int i=0; + while (rs.next()) + { + ++i; + assertNotNull(rs.getString("SITE")); + } + } + finally + { + rs.close(); + stmt.close(); + con.close(); + } + } +} \ No newline at end of file From 1b5c2b64e6ca8f2dcfe10a261d406dbd0bee2585 Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Tue, 1 May 2018 14:33:17 +0100 Subject: [PATCH 1339/1491] Simplified query parameters --- e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java b/e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java index eab9130dc..4f5dc97d2 100644 --- a/e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java +++ b/e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java @@ -120,9 +120,11 @@ public class SearchAPATHTest extends AbstractSearchTest @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_1}) public void searchLevel2() throws Exception { + String queryString = "name:"+ "cars"; + SearchRequest searchQuery = new SearchRequest(); RestRequestQueryModel queryReq = new RestRequestQueryModel(); - queryReq.setQuery("name:cars*"); + queryReq.setQuery(queryString); searchQuery.setQuery(queryReq); RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); @@ -153,7 +155,7 @@ public class SearchAPATHTest extends AbstractSearchTest */ searchQuery = new SearchRequest(); queryReq = new RestRequestQueryModel(); - queryReq.setQuery("name:cars*"); + queryReq.setQuery(queryString); searchQuery.setQuery(queryReq); facetFields = new RestRequestFacetFieldsModel(); list.remove(0); From dacc280be22683b69f4e0b8495536316bec70464 Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Tue, 1 May 2018 15:41:23 +0100 Subject: [PATCH 1340/1491] Changed solr host to in line with docker compose for SearchServices --- e2e-test/java/org/alfresco/rest/search/ShardInfoTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/search/ShardInfoTest.java b/e2e-test/java/org/alfresco/rest/search/ShardInfoTest.java index cedca8032..d4c5678c1 100644 --- a/e2e-test/java/org/alfresco/rest/search/ShardInfoTest.java +++ b/e2e-test/java/org/alfresco/rest/search/ShardInfoTest.java @@ -70,7 +70,8 @@ public class ShardInfoTest extends AbstractSearchTest RestInstanceModel instance = instances.iterator().next(); assertNotNull(instance); baseUrls.contains(instance.getBaseUrl()); - assertEquals(instance.getHost(), "localhost"); + // TODO: Ideally Solr Host and Port should be Parameterised + assertEquals(instance.getHost(), "search"); assertEquals(instance.getPort().intValue(), 8983); assertEquals(instance.getState(), "ACTIVE"); assertEquals(instance.getMode(), "MASTER"); From 273406a7e492b2732997811bacf01bf54c14a889 Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Tue, 1 May 2018 15:42:26 +0100 Subject: [PATCH 1341/1491] Search-812 Fixed the test --- e2e-test/java/org/alfresco/rest/search/SearchTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/SearchTest.java b/e2e-test/java/org/alfresco/rest/search/SearchTest.java index 5f038dfc6..f90bc361f 100644 --- a/e2e-test/java/org/alfresco/rest/search/SearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/SearchTest.java @@ -36,14 +36,14 @@ public class SearchTest extends AbstractSearchTest @Test(groups={TestGroup.SEARCH, TestGroup.REST_API}) public void searchOnIndexedData() throws Exception { - SearchResponse nodes = query("ipsum"); + SearchResponse nodes = query(unique_searchString); restClient.assertStatusCodeIs(HttpStatus.OK); nodes.assertThat().entriesListIsNotEmpty(); SearchNodeModel entity = nodes.getEntryByIndex(0); entity.assertThat().field("search").contains("score"); entity.getSearch().assertThat().field("score").isNotEmpty(); - Assert.assertEquals("Project Overview.ppt",entity.getName()); + Assert.assertEquals("pangram.txt",entity.getName()); } @Test(groups={TestGroup.SEARCH,TestGroup.REST_API}) From 6c155c0c18b35dfcfa30ece84c2a988ab1136513 Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Tue, 1 May 2018 16:45:37 +0100 Subject: [PATCH 1342/1491] WaitForIndexing approach implemented as discussed --- e2e-test/java/org/alfresco/rest/RestTest.java | 6 +-- .../rest/search/AbstractSearchTest.java | 47 ++++++++++++++++++- .../rest/search/SearchSpellCheckTest.java | 2 +- e2e-test/resources/default.properties | 2 +- 4 files changed, 49 insertions(+), 8 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/RestTest.java b/e2e-test/java/org/alfresco/rest/RestTest.java index 76963a8dc..d78baac57 100644 --- a/e2e-test/java/org/alfresco/rest/RestTest.java +++ b/e2e-test/java/org/alfresco/rest/RestTest.java @@ -86,9 +86,5 @@ public abstract class RestTest extends AbstractTestNGSpringContextTests { LOG.info(String.format("*** ENDING Test: [%s] ***", method.getName())); } - - public void waitForIndexing() - { - Utility.waitToLoopTime(properties.getSolrWaitTimeInSeconds(), "Wait For Index"); - } + } diff --git a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java index d5b2014c0..fd43b8f00 100644 --- a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java @@ -21,6 +21,7 @@ package org.alfresco.rest.search; import org.alfresco.dataprep.SiteService.Visibility; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.builder.NodesBuilder; +import org.alfresco.utility.Utility; import org.alfresco.utility.data.RandomData; import org.alfresco.utility.model.ContentModel; import org.alfresco.utility.model.FileModel; @@ -98,7 +99,7 @@ public class AbstractSearchTest extends RestTest dataContent.usingUser(userModel).usingSite(siteModel).usingResource(folder).createContent(file3); dataContent.usingUser(userModel).usingSite(siteModel).usingResource(folder).createContent(file4); - waitForIndexing(); + waitForIndexing(unique_searchString, true); } /** @@ -152,4 +153,48 @@ public class AbstractSearchTest extends RestTest { return createQuery("cars"); } + + /** + * Wait for Solr to finish indexing: Indexing has caught up = true if search returns appropriate results + * @param userQuery: string to search for, unique search string will guarantee accurate results + * @param expectedInResults, true if entry is expected in the results set + * @return true (indexing is finished) if search returns appropriate results + * @throws Exception + */ + public boolean waitForIndexing(String userQuery, Boolean expectedInResults) throws Exception + { + Boolean found = false; + Boolean resultAsExpected = false; + + SearchRequest searchRequest = createQuery(userQuery); + SearchResponse response = query(searchRequest); + + // Repeat search until the element is found or Timeout is hit + for (int searchCount = 1; searchCount <= 3; searchCount++) + { + if (searchCount > 1) + { + // Wait for the solr indexing. + Utility.waitToLoopTime(properties.getSolrWaitTimeInSeconds(), "Wait For Indexing"); + } + + if (response.getEntries().size() >= 1) + { + found = true; + } + else + { + found = false; + } + + // Loop again if result is not as expected: To cater for solr lag: eventual consistency + resultAsExpected = (expectedInResults.equals(found)); + if (resultAsExpected) + { + break; + } + } + + return resultAsExpected; + } } diff --git a/e2e-test/java/org/alfresco/rest/search/SearchSpellCheckTest.java b/e2e-test/java/org/alfresco/rest/search/SearchSpellCheckTest.java index a1d663830..c8f96ae93 100644 --- a/e2e-test/java/org/alfresco/rest/search/SearchSpellCheckTest.java +++ b/e2e-test/java/org/alfresco/rest/search/SearchSpellCheckTest.java @@ -155,7 +155,7 @@ public class SearchSpellCheckTest extends AbstractSearchTest // Create a file with mis-spelt name, expect spellcheck type = didYouMean dataContent.usingUser(userModel).usingSite(siteModel).createContent(file); - waitForIndexing(); + waitForIndexing(file.getName(), true); // Search SearchRequest searchReq = new SearchRequest(); diff --git a/e2e-test/resources/default.properties b/e2e-test/resources/default.properties index 1ad5a1d61..b44ef9b4a 100644 --- a/e2e-test/resources/default.properties +++ b/e2e-test/resources/default.properties @@ -9,7 +9,7 @@ sync.server=localhost sync.port=9090 #Solr Indexing Time -solrWaitTimeInSeconds=60 +solrWaitTimeInSeconds=20 # credentials admin.user=admin From 989369ef73923896f6d8754ec12ac6803d46a2cc Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Tue, 1 May 2018 16:49:40 +0100 Subject: [PATCH 1343/1491] Simplified dataprep, SpellCheck test, removed unnecessary code --- .../rest/search/AbstractSearchTest.java | 17 ++++++---------- .../rest/search/SearchSpellCheckTest.java | 20 ++++++------------- 2 files changed, 12 insertions(+), 25 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java index fd43b8f00..5d2e6e020 100644 --- a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java @@ -48,7 +48,6 @@ public class AbstractSearchTest extends RestTest UserModel userModel, adminUserModel; SiteModel siteModel; UserModel searchedUser; - NodesBuilder nodesBuilder; protected FileModel file, file2, file3, file4; protected static String unique_searchString; @@ -64,7 +63,7 @@ public class AbstractSearchTest extends RestTest siteModel = dataSite.usingUser(userModel).createSite(siteModel); - unique_searchString = siteModel.getTitle(); + unique_searchString = siteModel.getTitle().replace("SiteSearch", "Unique"); /* * Create the following file structure for preconditions : @@ -74,7 +73,7 @@ public class AbstractSearchTest extends RestTest * |-- alfresco.txt * |-- */ - nodesBuilder = restClient.authenticateUser(userModel).withCoreAPI().usingNode(ContentModel.my()).defineNodes(); + FolderModel folder = new FolderModel(SEARCH_DATA_SAMPLE_FOLDER); dataContent.usingUser(userModel).usingSite(siteModel).createFolder(folder); @@ -88,18 +87,14 @@ public class AbstractSearchTest extends RestTest file3 = new FileModel("alfresco.txt", "alfresco", "alfresco", FileType.TEXT_PLAIN, "Alfresco text file for search "); - file4 = new FileModel(unique_searchString, "unique" + title, description, FileType.TEXT_PLAIN, "Unique text file for search "); - - ContentModel cm = new ContentModel(); - cm.setCmisLocation(folder.getCmisLocation()); - cm.setName(folder.getName()); + file4 = new FileModel(unique_searchString + ".txt", "uniquee" + title, description, FileType.TEXT_PLAIN, "Unique text file for search "); dataContent.usingUser(userModel).usingSite(siteModel).usingResource(folder).createContent(file); dataContent.usingUser(userModel).usingSite(siteModel).usingResource(folder).createContent(file2); dataContent.usingUser(userModel).usingSite(siteModel).usingResource(folder).createContent(file3); dataContent.usingUser(userModel).usingSite(siteModel).usingResource(folder).createContent(file4); - waitForIndexing(unique_searchString, true); + waitForIndexing(file4.getName(), true); } /** @@ -115,7 +110,7 @@ public class AbstractSearchTest extends RestTest queryReq.setLanguage("afts"); queryReq.setQuery(term); SearchRequest query = new SearchRequest(queryReq); - return restClient.authenticateUser(dataUser.getAdminUser()).withSearchAPI().search(query); + return restClient.authenticateUser(userModel).withSearchAPI().search(query); } /** * Helper method which create an http post request to Search API end point. @@ -128,7 +123,7 @@ public class AbstractSearchTest extends RestTest { SearchRequest query = new SearchRequest(queryReq); query.setHighlight(highlight); - return restClient.authenticateUser(dataUser.getAdminUser()).withSearchAPI().search(query); + return restClient.authenticateUser(userModel).withSearchAPI().search(query); } /** * Helper method which create an http post request to Search API end point. diff --git a/e2e-test/java/org/alfresco/rest/search/SearchSpellCheckTest.java b/e2e-test/java/org/alfresco/rest/search/SearchSpellCheckTest.java index c8f96ae93..70e6c7297 100644 --- a/e2e-test/java/org/alfresco/rest/search/SearchSpellCheckTest.java +++ b/e2e-test/java/org/alfresco/rest/search/SearchSpellCheckTest.java @@ -32,7 +32,6 @@ import org.testng.annotations.Test; */ public class SearchSpellCheckTest extends AbstractSearchTest { - protected FileModel file = new FileModel("alfesco.txt", "alfesco", "alfesco", FileType.TEXT_PLAIN, "alfesco text file for search "); /** * Perform the below query @@ -149,32 +148,25 @@ public class SearchSpellCheckTest extends AbstractSearchTest @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ACS_60n}, priority=4) public void testSpellCheckType() throws Exception - { - try - { + { // Create a file with mis-spelt name, expect spellcheck type = didYouMean + FileModel file = new FileModel(unique_searchString + "-1.txt", "uniquee" + "uniquee", "uniquee", FileType.TEXT_PLAIN, "Unique text file for search "); dataContent.usingUser(userModel).usingSite(siteModel).createContent(file); - + waitForIndexing(file.getName(), true); // Search SearchRequest searchReq = new SearchRequest(); RestRequestQueryModel queryReq = new RestRequestQueryModel(); - queryReq.setQuery("cm:name:alfesco"); - queryReq.setUserQuery("alfesco"); + queryReq.setQuery("cm:title:uniquee"); + queryReq.setUserQuery("uniquee"); searchReq.setQuery(queryReq); searchReq.setSpellcheck(new RestRequestSpellcheckModel()); SearchResponse nodes = query(searchReq); nodes.assertThat().entriesListIsNotEmpty(); nodes.getContext().assertThat().field("spellCheck").isNotEmpty(); - nodes.getContext().getSpellCheck().assertThat().field("suggestions").contains("alfresco"); + nodes.getContext().getSpellCheck().assertThat().field("suggestions").contains("unique"); nodes.getContext().getSpellCheck().assertThat().field("type").is("didYouMean"); - } - finally - { - // Delete this file, else it will cause incorrect results for other spell-check tests when rerunning on the same environment - dataContent.usingUser(userModel).usingSite(siteModel).usingResource(file).deleteContent(); - } } } From 709f237161c6332b46c188ab9e4f94029338c71c Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Tue, 1 May 2018 16:50:28 +0100 Subject: [PATCH 1344/1491] Simplified dataprep, removed thread.sleep and other unnecessary code --- .../alfresco/rest/search/FingerPrintTest.java | 42 +++++++++++++------ 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java b/e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java index fd3381b3d..19f4f41fd 100644 --- a/e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java @@ -18,10 +18,13 @@ */ package org.alfresco.rest.search; +import org.alfresco.dataprep.SiteService.Visibility; +import org.alfresco.utility.data.RandomData; import org.alfresco.utility.model.ContentModel; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FileType; import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.testng.Assert; import org.testng.annotations.BeforeClass; @@ -35,33 +38,43 @@ import org.testng.annotations.Test; public class FingerPrintTest extends AbstractSearchTest { private FileModel file1,file2,file3,file4; + @BeforeClass(alwaysRun=true) public void indexSimilarFile() throws Exception { adminUserModel = dataUser.getAdminUser(); userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + + siteModel = new SiteModel(RandomData.getRandomName("SiteSearch")); + siteModel.setVisibility(Visibility.PRIVATE); + + siteModel = dataSite.usingUser(userModel).createSite(siteModel); + /* * Create the following file structure for preconditions : * |- folder - * |-- fox.txt + * |-- pangram-banana.txt + * |-- pangram-taco.txt + * |-- pangram-cat.txt + * |-- dog.txt */ - nodesBuilder = restClient.authenticateUser(userModel).withCoreAPI().usingNode(ContentModel.my()).defineNodes(); + FolderModel folder = new FolderModel(SEARCH_DATA_SAMPLE_FOLDER); dataContent.usingUser(userModel).usingSite(siteModel).createFolder(folder); + file1 = new FileModel("pangram-banana.txt", FileType.TEXT_PLAIN, "The quick brown fox jumps over the lazy banana"); file2 = new FileModel("pangram-taco.txt", FileType.TEXT_PLAIN, "The quick brown fox jumps over the lazy dog that ate the taco"); file3 = new FileModel("pangram-cat.txt", FileType.TEXT_PLAIN, "The quick brown fox jumps over the lazy cat"); file4 = new FileModel("dog.txt", FileType.TEXT_PLAIN, "The quick brown fox ate the lazy dog"); - ContentModel cm = new ContentModel(); - cm.setCmisLocation(folder.getCmisLocation()); - cm.setName(folder.getName()); - dataContent.usingUser(userModel).usingSite(siteModel).usingResource(cm).createContent(file1); - dataContent.usingUser(userModel).usingSite(siteModel).usingResource(cm).createContent(file2); - dataContent.usingUser(userModel).usingSite(siteModel).usingResource(cm).createContent(file3); - dataContent.usingUser(userModel).usingSite(siteModel).usingResource(cm).createContent(file4); - Thread.sleep(35000);//Allow indexing to complete. + + dataContent.usingUser(userModel).usingSite(siteModel).usingResource(folder).createContent(file1); + dataContent.usingUser(userModel).usingSite(siteModel).usingResource(folder).createContent(file2); + dataContent.usingUser(userModel).usingSite(siteModel).usingResource(folder).createContent(file3); + dataContent.usingUser(userModel).usingSite(siteModel).usingResource(folder).createContent(file4); + + waitForIndexing(file4.getName(), true); } + /** * Search similar document based on document finger print. * The data prep should have loaded 2 files which one is similar @@ -99,16 +112,20 @@ public class FingerPrintTest extends AbstractSearchTest m.getModel().assertThat().field("name").isNot("cars.txt"); } } + @Test(groups= {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1}) public void searchSimilar() throws Exception { String uuid = file2.getNodeRefWithoutVersion(); Assert.assertNotNull(uuid); - // In the response eneity there is a score of each doc, change below threshold to bring more like or less. + + // In the response entity there is a score of each doc, change below threshold to bring more like or less. String fingerprint = String.format("FINGERPRINT:%s_68", uuid); SearchResponse response = query(fingerprint); + int count = response.getEntries().size(); Assert.assertTrue(count > 1); + for(SearchNodeModel m :response.getEntries()) { switch (m.getModel().getName()) @@ -126,6 +143,7 @@ public class FingerPrintTest extends AbstractSearchTest m.getModel().assertThat().field("name").isNot("cars.txt"); } } + @Test(groups= {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1}) public void searchSimilar67Percent() throws Exception { From 602f46debfb113b51cd20f02ed3fea286f5625cb Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Wed, 2 May 2018 11:19:30 +0100 Subject: [PATCH 1345/1491] Fixed FingurePrint Test to work with recent changes --- .../org/alfresco/rest/search/FingerPrintTest.java | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java b/e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java index 19f4f41fd..1e86378f0 100644 --- a/e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java @@ -18,13 +18,9 @@ */ package org.alfresco.rest.search; -import org.alfresco.dataprep.SiteService.Visibility; -import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.ContentModel; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FileType; import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.testng.Assert; import org.testng.annotations.BeforeClass; @@ -42,13 +38,6 @@ public class FingerPrintTest extends AbstractSearchTest @BeforeClass(alwaysRun=true) public void indexSimilarFile() throws Exception { - adminUserModel = dataUser.getAdminUser(); - userModel = dataUser.createRandomTestUser(); - - siteModel = new SiteModel(RandomData.getRandomName("SiteSearch")); - siteModel.setVisibility(Visibility.PRIVATE); - - siteModel = dataSite.usingUser(userModel).createSite(siteModel); /* * Create the following file structure for preconditions : @@ -59,7 +48,7 @@ public class FingerPrintTest extends AbstractSearchTest * |-- dog.txt */ - FolderModel folder = new FolderModel(SEARCH_DATA_SAMPLE_FOLDER); + FolderModel folder = new FolderModel("The quick brown fox jumps over"); dataContent.usingUser(userModel).usingSite(siteModel).createFolder(folder); file1 = new FileModel("pangram-banana.txt", FileType.TEXT_PLAIN, "The quick brown fox jumps over the lazy banana"); From 97e38e58dc34f29cc14b0a7acc48b6e5437e8071 Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Wed, 2 May 2018 11:24:27 +0100 Subject: [PATCH 1346/1491] Formatting changes --- .../alfresco/rest/search/FingerPrintTest.java | 100 +++++++++--------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java b/e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java index 1e86378f0..2bc30ef37 100644 --- a/e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java @@ -33,24 +33,24 @@ import org.testng.annotations.Test; */ public class FingerPrintTest extends AbstractSearchTest { - private FileModel file1,file2,file3,file4; - - @BeforeClass(alwaysRun=true) + private FileModel file1, file2, file3, file4; + + @BeforeClass(alwaysRun = true) public void indexSimilarFile() throws Exception { - + /* - * Create the following file structure for preconditions : - * |- folder - * |-- pangram-banana.txt - * |-- pangram-taco.txt - * |-- pangram-cat.txt - * |-- dog.txt + * Create the following file structure in the same Site : In addition to the preconditions created in dataPreparation + * |- folder + * |-- pangram-banana.txt + * |-- pangram-taco.txt + * |-- pangram-cat.txt + * |-- dog.txt */ - + FolderModel folder = new FolderModel("The quick brown fox jumps over"); dataContent.usingUser(userModel).usingSite(siteModel).createFolder(folder); - + file1 = new FileModel("pangram-banana.txt", FileType.TEXT_PLAIN, "The quick brown fox jumps over the lazy banana"); file2 = new FileModel("pangram-taco.txt", FileType.TEXT_PLAIN, "The quick brown fox jumps over the lazy dog that ate the taco"); file3 = new FileModel("pangram-cat.txt", FileType.TEXT_PLAIN, "The quick brown fox jumps over the lazy cat"); @@ -60,10 +60,10 @@ public class FingerPrintTest extends AbstractSearchTest dataContent.usingUser(userModel).usingSite(siteModel).usingResource(folder).createContent(file2); dataContent.usingUser(userModel).usingSite(siteModel).usingResource(folder).createContent(file3); dataContent.usingUser(userModel).usingSite(siteModel).usingResource(folder).createContent(file4); - + waitForIndexing(file4.getName(), true); } - + /** * Search similar document based on document finger print. * The data prep should have loaded 2 files which one is similar @@ -72,7 +72,7 @@ public class FingerPrintTest extends AbstractSearchTest * * @throws Exception */ - @Test(groups= {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1}) + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) public void search() throws Exception { String uuid = file1.getNodeRefWithoutVersion(); @@ -81,50 +81,50 @@ public class FingerPrintTest extends AbstractSearchTest SearchResponse response = query(fingerprint); int count = response.getEntries().size(); Assert.assertTrue(count > 1); - for(SearchNodeModel m :response.getEntries()) + for (SearchNodeModel m : response.getEntries()) { String match = m.getModel().getName(); switch (match) { - case "pangram.txt": - break; - case "pangram-banana.txt": - break; - case "pangram-taco.txt": - break; - case "pangram-cat.txt": - break; - default: - throw new AssertionError("Not a match to an expected file: " + m.getModel().getName()); + case "pangram.txt": + break; + case "pangram-banana.txt": + break; + case "pangram-taco.txt": + break; + case "pangram-cat.txt": + break; + default: + throw new AssertionError("Not a match to an expected file: " + m.getModel().getName()); } m.getModel().assertThat().field("name").isNot("dog.txt"); m.getModel().assertThat().field("name").isNot("cars.txt"); } } - - @Test(groups= {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1}) + + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) public void searchSimilar() throws Exception { String uuid = file2.getNodeRefWithoutVersion(); Assert.assertNotNull(uuid); - + // In the response entity there is a score of each doc, change below threshold to bring more like or less. - String fingerprint = String.format("FINGERPRINT:%s_68", uuid); + String fingerprint = String.format("FINGERPRINT:%s_68", uuid); SearchResponse response = query(fingerprint); - + int count = response.getEntries().size(); Assert.assertTrue(count > 1); - - for(SearchNodeModel m :response.getEntries()) + + for (SearchNodeModel m : response.getEntries()) { switch (m.getModel().getName()) { - case "pangram.txt": - break; - case "pangram-taco.txt": - break; - default: - throw new AssertionError("Not a match to an expected file: " + m.getModel().getName()); + case "pangram.txt": + break; + case "pangram-taco.txt": + break; + default: + throw new AssertionError("Not a match to an expected file: " + m.getModel().getName()); } m.getModel().assertThat().field("name").isNot("pangram-banana.txt"); m.getModel().assertThat().field("name").isNot("pangram-cat.txt"); @@ -132,8 +132,8 @@ public class FingerPrintTest extends AbstractSearchTest m.getModel().assertThat().field("name").isNot("cars.txt"); } } - - @Test(groups= {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1}) + + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) public void searchSimilar67Percent() throws Exception { String uuid = file2.getNodeRefWithoutVersion(); @@ -142,18 +142,18 @@ public class FingerPrintTest extends AbstractSearchTest SearchResponse response = query(fingerprint); int count = response.getEntries().size(); Assert.assertTrue(count > 1); - for(SearchNodeModel m :response.getEntries()) + for (SearchNodeModel m : response.getEntries()) { switch (m.getModel().getName()) { - case "pangram.txt": - break; - case "pangram-taco.txt": - break; - case "pangram-cat.txt": - break; - default: - throw new AssertionError("Not a match to an expected file: " + m.getModel().getName()); + case "pangram.txt": + break; + case "pangram-taco.txt": + break; + case "pangram-cat.txt": + break; + default: + throw new AssertionError("Not a match to an expected file: " + m.getModel().getName()); } m.getModel().assertThat().field("name").isNot("pangram-banana.txt"); m.getModel().assertThat().field("name").isNot("dog.txt"); From 76491b4432b726248e9e729e83cba4575cc43629 Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Wed, 2 May 2018 11:46:32 +0100 Subject: [PATCH 1347/1491] Removed unused dependencies and updated copyright info for amended files --- e2e-test/java/org/alfresco/rest/RestTest.java | 1 - e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java | 2 -- e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java | 2 +- e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java | 2 +- e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java | 2 +- .../java/org/alfresco/rest/search/SearchSpellCheckTest.java | 2 +- e2e-test/java/org/alfresco/rest/search/SearchTest.java | 2 +- 7 files changed, 5 insertions(+), 8 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/RestTest.java b/e2e-test/java/org/alfresco/rest/RestTest.java index d78baac57..ccd8ba6eb 100644 --- a/e2e-test/java/org/alfresco/rest/RestTest.java +++ b/e2e-test/java/org/alfresco/rest/RestTest.java @@ -7,7 +7,6 @@ import org.alfresco.rest.core.RestProperties; import org.alfresco.rest.core.RestWrapper; import org.alfresco.utility.LogFactory; import org.alfresco.utility.TasProperties; -import org.alfresco.utility.Utility; import org.alfresco.utility.data.DataContent; import org.alfresco.utility.data.DataDiscussion; import org.alfresco.utility.data.DataGroup; diff --git a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java index 5d2e6e020..bb8842ec3 100644 --- a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java @@ -20,10 +20,8 @@ package org.alfresco.rest.search; import org.alfresco.dataprep.SiteService.Visibility; import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.builder.NodesBuilder; import org.alfresco.utility.Utility; import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.ContentModel; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FileType; import org.alfresco.utility.model.FolderModel; diff --git a/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java b/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java index 8722f10a3..351281858 100644 --- a/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 Alfresco Software Limited. + * Copyright (C) 2018 Alfresco Software Limited. * * This file is part of Alfresco * diff --git a/e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java b/e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java index 2bc30ef37..04e0e57bf 100644 --- a/e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 Alfresco Software Limited. + * Copyright (C) 2018 Alfresco Software Limited. * * This file is part of Alfresco * diff --git a/e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java b/e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java index 4f5dc97d2..0a2b9c762 100644 --- a/e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java +++ b/e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 Alfresco Software Limited. + * Copyright (C) 2018 Alfresco Software Limited. * * This file is part of Alfresco * diff --git a/e2e-test/java/org/alfresco/rest/search/SearchSpellCheckTest.java b/e2e-test/java/org/alfresco/rest/search/SearchSpellCheckTest.java index 70e6c7297..c55d0b215 100644 --- a/e2e-test/java/org/alfresco/rest/search/SearchSpellCheckTest.java +++ b/e2e-test/java/org/alfresco/rest/search/SearchSpellCheckTest.java @@ -28,7 +28,7 @@ import org.testng.annotations.Test; /** * Search end point Public API test with spell checking enabled. * @author Michael Suzuki - *5 + * @author Meenal Bhave */ public class SearchSpellCheckTest extends AbstractSearchTest { diff --git a/e2e-test/java/org/alfresco/rest/search/SearchTest.java b/e2e-test/java/org/alfresco/rest/search/SearchTest.java index f90bc361f..b1a285c6c 100644 --- a/e2e-test/java/org/alfresco/rest/search/SearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/SearchTest.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 Alfresco Software Limited. + * Copyright (C) 2018 Alfresco Software Limited. * * This file is part of Alfresco * From c792aff063e3f5e8b62f2016250fd778df88de31 Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Wed, 2 May 2018 11:50:03 +0100 Subject: [PATCH 1348/1491] Removed unnecessary empty line --- e2e-test/java/org/alfresco/rest/RestTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/RestTest.java b/e2e-test/java/org/alfresco/rest/RestTest.java index ccd8ba6eb..0358a948d 100644 --- a/e2e-test/java/org/alfresco/rest/RestTest.java +++ b/e2e-test/java/org/alfresco/rest/RestTest.java @@ -85,5 +85,4 @@ public abstract class RestTest extends AbstractTestNGSpringContextTests { LOG.info(String.format("*** ENDING Test: [%s] ***", method.getName())); } - } From 7421ad2cd8ddb7ac03c7dd710049a89b47407a00 Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Wed, 2 May 2018 12:38:17 +0100 Subject: [PATCH 1349/1491] Corrected the comment --- e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java index bb8842ec3..560f385dd 100644 --- a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java @@ -37,6 +37,7 @@ import org.testng.annotations.BeforeClass; *
    • Preparing search requests. * * @author Michael Suzuki + * @author Meenal Bhave * */ public class AbstractSearchTest extends RestTest @@ -162,7 +163,7 @@ public class AbstractSearchTest extends RestTest SearchRequest searchRequest = createQuery(userQuery); SearchResponse response = query(searchRequest); - // Repeat search until the element is found or Timeout is hit + // Repeat search until the query results are as expected or Search Retry count is hit for (int searchCount = 1; searchCount <= 3; searchCount++) { if (searchCount > 1) From 01022f7e1dc36dc60e05e8aa59f5c968e9f9e08d Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 2 May 2018 21:07:46 +0100 Subject: [PATCH 1350/1491] Search-741, sql rest api test using the jdbc driver --- .../rest/search/sql/SearchSQLTest.java | 115 +++++++++++++----- 1 file changed, 83 insertions(+), 32 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLTest.java b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLTest.java index e080c74e5..d25412594 100644 --- a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLTest.java +++ b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLTest.java @@ -19,12 +19,17 @@ package org.alfresco.rest.search.sql; import static org.junit.Assert.assertNotNull; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertNotEquals; +import static org.testng.Assert.assertTrue; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; +import java.util.ArrayList; +import java.util.List; import java.util.Properties; import org.alfresco.dataprep.SiteService.Visibility; @@ -34,7 +39,9 @@ import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; +import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; /** @@ -48,54 +55,98 @@ public class SearchSQLTest extends AbstractSearchTest SiteModel siteModel; FileModel document; String connectionString; - + private Connection con; + private Statement stmt; + private ResultSet rs; + List sites; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception { - connectionString = properties.getFullServerUrl() + "/alfresco/api/-default-/public/search/versions/1"; - + connectionString = properties.getFullServerUrl() + "/alfresco/api/-default-/public/search/versions/1/sql"; + //Prepare users, one with full access and one with limited access. adminUser = dataUser.getAdminUser(); userModel = dataUser.createRandomTestUser("UserSearch"); - managerUser = dataUser.createRandomTestUser("UserSearchMgr"); - - //Create site - adminUser = dataUser.getAdminUser(); - restClient.authenticateUser(adminUser); - + managerUser = dataUser.createRandomTestUser("UserSearch"); + //Create a private site siteModel = new SiteModel(RandomData.getRandomName("SiteSearch")); siteModel.setVisibility(Visibility.PRIVATE); - - siteModel = dataSite.usingUser(userModel).createSite(siteModel); + siteModel = dataSite.usingUser(managerUser).createSite(siteModel); + //Allow tracker to index. } - + @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10}) - public void queryTest() throws SQLException + public void queryPublicSiteWithSimpleUser() throws SQLException { - String sql = "select SITE, CM_OWNER from alfresco group by SITE,CM_OWNER"; - Properties props = new Properties(); - props.put("user", adminUser.getUsername()); - props.put("password", adminUser.getPassword()); - Connection con = null; - Statement stmt = null; - ResultSet rs = null; - try + String sql = "select SITE,CM_OWNER from alfresco group by SITE,CM_OWNER"; + rs = executeSql(userModel.getUsername(), userModel.getPassword(), sql); + while (rs.next()) { - con = DriverManager.getConnection(connectionString, props); - stmt = con.createStatement(); - rs = stmt.executeQuery(sql); - int i=0; - while (rs.next()) - { - ++i; - assertNotNull(rs.getString("SITE")); - } - } - finally + assertNotNull(rs.getString("SITE")); + //Check for the private site which was created + assertNotNull(rs.getString("CM_OWNER")); + } + } + @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10}) + public void queryMyCreatedPrivateSite() throws SQLException + { + String sql = "select SITE from alfresco where SITE ='" + siteModel.getTitle() + "'"; + rs = executeSql(managerUser.getUsername(), managerUser.getPassword(), sql); + while (rs.next()) + { + assertNotNull(rs.getString("SITE")); + assertTrue(siteModel.getTitle().equalsIgnoreCase(rs.getString("SITE"))); + } + } + @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10}) + public void queryPrivateSiteWithSuperUser() throws SQLException + { + String sql = "select SITE from alfresco where SITE ='" + siteModel.getTitle() + "'"; + rs = executeSql(adminUser.getUsername(), adminUser.getPassword(), sql); + while (rs.next()) + { + assertNotNull(rs.getString("SITE")); + assertTrue(siteModel.getTitle().equalsIgnoreCase(rs.getString("SITE"))); + } + } + @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10}) + public void queryPrivateSiteWithSimpleUser() throws SQLException + { + String sql = "select SITE from alfresco where SITE = '" + siteModel.getTitle() +"'"; + rs = executeSql(userModel.getUsername(), userModel.getPassword(), sql); + assertFalse(rs.next()); + } + @AfterMethod + public void close() + { + sites = null; + try { rs.close(); stmt.close(); con.close(); } + catch (SQLException e) + { + // TODO: handle exception + } + } + @BeforeMethod + public void prep() + { + sites = new ArrayList(); + } + private Connection getConnection(String username, String password) throws SQLException + { + Properties props = new Properties(); + props.put("user", username); + props.put("password", password); + return DriverManager.getConnection(connectionString, props); + } + private ResultSet executeSql(String username, String password, String sql) throws SQLException + { + con = getConnection(username, password); + stmt = con.createStatement(); + return stmt.executeQuery(sql); } } \ No newline at end of file From bbd5f4fe1c597aaa9b4de78ead90ccafe141fd58 Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Thu, 3 May 2018 11:14:40 +0100 Subject: [PATCH 1351/1491] Search 829 Fix TAS Rest API Search Tests --- .../rest/search/AbstractSearchTest.java | 109 +++++++++++++---- .../rest/search/FacetIntervalSearchTest.java | 14 ++- .../rest/search/FacetRangeSearchTest.java | 20 ++-- .../rest/search/FacetedSearchTest.java | 108 +++++++++-------- .../alfresco/rest/search/FingerPrintTest.java | 111 ++++++++++-------- .../rest/search/PivotFacetedSearchTest.java | 7 +- .../alfresco/rest/search/SearchAPATHTest.java | 15 ++- .../rest/search/SearchSpellCheckTest.java | 71 +++++++++-- .../org/alfresco/rest/search/SearchTest.java | 6 +- .../alfresco/rest/search/ShardInfoTest.java | 7 +- .../sharedLinks/SharedLinksSanityTests.java | 2 - e2e-test/resources/SearchSuite.xml | 35 ++++++ e2e-test/resources/default.properties | 3 + 13 files changed, 347 insertions(+), 161 deletions(-) create mode 100644 e2e-test/resources/SearchSuite.xml diff --git a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java index 4eeb2abc6..560f385dd 100644 --- a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 Alfresco Software Limited. + * Copyright (C) 2018 Alfresco Software Limited. * * This file is part of Alfresco * @@ -18,9 +18,10 @@ */ package org.alfresco.rest.search; +import org.alfresco.dataprep.SiteService.Visibility; import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.builder.NodesBuilder; -import org.alfresco.utility.model.ContentModel; +import org.alfresco.utility.Utility; +import org.alfresco.utility.data.RandomData; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FileType; import org.alfresco.utility.model.FolderModel; @@ -36,41 +37,65 @@ import org.testng.annotations.BeforeClass; *
    • Preparing search requests. * * @author Michael Suzuki + * @author Meenal Bhave * */ public class AbstractSearchTest extends RestTest { - protected static final String SEARCH_DATA_SAMPLE_FOLDER = "folder"; + + protected static final String SEARCH_DATA_SAMPLE_FOLDER = "FolderSearch"; UserModel userModel, adminUserModel; SiteModel siteModel; UserModel searchedUser; - NodesBuilder nodesBuilder; - protected FileModel file,file2; + protected FileModel file, file2, file3, file4; + + protected static String unique_searchString; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception { adminUserModel = dataUser.getAdminUser(); - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + userModel = dataUser.createRandomTestUser("UserSearch"); + + siteModel = new SiteModel(RandomData.getRandomName("SiteSearch")); + siteModel.setVisibility(Visibility.PRIVATE); + + siteModel = dataSite.usingUser(userModel).createSite(siteModel); + + unique_searchString = siteModel.getTitle().replace("SiteSearch", "Unique"); + /* * Create the following file structure for preconditions : * |- folder * |-- pangram.txt - * |-- cars.pdf + * |-- cars.txt + * |-- alfresco.txt + * |-- */ - nodesBuilder = restClient.authenticateUser(userModel).withCoreAPI().usingNode(ContentModel.my()).defineNodes(); + FolderModel folder = new FolderModel(SEARCH_DATA_SAMPLE_FOLDER); dataContent.usingUser(userModel).usingSite(siteModel).createFolder(folder); + //Create files - file = new FileModel("pangram.txt", FileType.TEXT_PLAIN, "The quick brown fox jumps over the lazy dog"); - file2 = new FileModel("cars.txt", FileType.TEXT_PLAIN, "The landrover discovery is not a sports car"); - ContentModel cm = new ContentModel(); - cm.setCmisLocation(folder.getCmisLocation()); - cm.setName(folder.getName()); - dataContent.usingUser(userModel).usingSite(siteModel).usingResource(cm).createContent(file); - dataContent.usingUser(userModel).usingSite(siteModel).usingResource(cm).createContent(file2); + String title = "Title: " + unique_searchString; + String description = "Description: File is created for search tests by Author: " + unique_searchString + " . "; + + file = new FileModel("pangram.txt", "pangram" + title, description, FileType.TEXT_PLAIN, description + " The quick brown fox jumps over the lazy dog"); + + file2 = new FileModel("cars.txt", "cars" + title, description, FileType.TEXT_PLAIN, "The landrover discovery is not a sports car "); + + file3 = new FileModel("alfresco.txt", "alfresco", "alfresco", FileType.TEXT_PLAIN, "Alfresco text file for search "); + + file4 = new FileModel(unique_searchString + ".txt", "uniquee" + title, description, FileType.TEXT_PLAIN, "Unique text file for search "); + + dataContent.usingUser(userModel).usingSite(siteModel).usingResource(folder).createContent(file); + dataContent.usingUser(userModel).usingSite(siteModel).usingResource(folder).createContent(file2); + dataContent.usingUser(userModel).usingSite(siteModel).usingResource(folder).createContent(file3); + dataContent.usingUser(userModel).usingSite(siteModel).usingResource(folder).createContent(file4); + + waitForIndexing(file4.getName(), true); } + /** * Helper method which create an http post request to Search API end point. * @param term String search term @@ -84,7 +109,7 @@ public class AbstractSearchTest extends RestTest queryReq.setLanguage("afts"); queryReq.setQuery(term); SearchRequest query = new SearchRequest(queryReq); - return restClient.authenticateUser(dataUser.getAdminUser()).withSearchAPI().search(query); + return restClient.authenticateUser(userModel).withSearchAPI().search(query); } /** * Helper method which create an http post request to Search API end point. @@ -97,7 +122,7 @@ public class AbstractSearchTest extends RestTest { SearchRequest query = new SearchRequest(queryReq); query.setHighlight(highlight); - return restClient.authenticateUser(dataUser.getAdminUser()).withSearchAPI().search(query); + return restClient.authenticateUser(userModel).withSearchAPI().search(query); } /** * Helper method which create an http post request to Search API end point. @@ -108,7 +133,7 @@ public class AbstractSearchTest extends RestTest */ protected SearchResponse query(SearchRequest query) throws Exception { - return restClient.authenticateUser(dataUser.getAdminUser()).withSearchAPI().search(query); + return restClient.authenticateUser(userModel).withSearchAPI().search(query); } protected SearchRequest createQuery(String term) { @@ -122,4 +147,48 @@ public class AbstractSearchTest extends RestTest { return createQuery("cars"); } + + /** + * Wait for Solr to finish indexing: Indexing has caught up = true if search returns appropriate results + * @param userQuery: string to search for, unique search string will guarantee accurate results + * @param expectedInResults, true if entry is expected in the results set + * @return true (indexing is finished) if search returns appropriate results + * @throws Exception + */ + public boolean waitForIndexing(String userQuery, Boolean expectedInResults) throws Exception + { + Boolean found = false; + Boolean resultAsExpected = false; + + SearchRequest searchRequest = createQuery(userQuery); + SearchResponse response = query(searchRequest); + + // Repeat search until the query results are as expected or Search Retry count is hit + for (int searchCount = 1; searchCount <= 3; searchCount++) + { + if (searchCount > 1) + { + // Wait for the solr indexing. + Utility.waitToLoopTime(properties.getSolrWaitTimeInSeconds(), "Wait For Indexing"); + } + + if (response.getEntries().size() >= 1) + { + found = true; + } + else + { + found = false; + } + + // Loop again if result is not as expected: To cater for solr lag: eventual consistency + resultAsExpected = (expectedInResults.equals(found)); + if (resultAsExpected) + { + break; + } + } + + return resultAsExpected; + } } diff --git a/e2e-test/java/org/alfresco/rest/search/FacetIntervalSearchTest.java b/e2e-test/java/org/alfresco/rest/search/FacetIntervalSearchTest.java index 9d8d74b37..d32f3ebe9 100644 --- a/e2e-test/java/org/alfresco/rest/search/FacetIntervalSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FacetIntervalSearchTest.java @@ -48,23 +48,23 @@ public class FacetIntervalSearchTest extends AbstractSearchTest facetIntervalsModel.setIntervals(Arrays.asList(facetInterval)); query.setFacetIntervals(facetIntervalsModel); - SearchResponse response = query(query); + query(query); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() .containsSummary(String.format(RestErrorModel.MANDATORY_PARAM, "facetIntervals intervals field")); facetInterval.setField("created"); - response = query(query); + query(query); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() .containsSummary(String.format(RestErrorModel.MANDATORY_COLLECTION, "facetIntervals intervals sets")); RestRequestFacetSetModel restFacetSetModel = new RestRequestFacetSetModel(); restFacetSetModel.setLabel("theRest"); facetInterval.setSets(Arrays.asList(restFacetSetModel)); - response = query(query); + query(query); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() .containsSummary(String.format(RestErrorModel.MANDATORY_PARAM, "facetIntervals intervals created sets start")); restFacetSetModel.setStart("A"); - response = query(query); + query(query); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() .containsSummary(String.format(RestErrorModel.MANDATORY_PARAM, "facetIntervals intervals created sets end")); @@ -74,7 +74,8 @@ public class FacetIntervalSearchTest extends AbstractSearchTest duplicate.setLabel("theRest"); duplicate.setStart("A"); duplicate.setEnd("C"); - response = query(query); + + query(query); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() .containsSummary("duplicate set interval label [theRest=2]"); @@ -83,7 +84,8 @@ public class FacetIntervalSearchTest extends AbstractSearchTest FacetInterval duplicateLabel = new FacetInterval("creator", "thesame", Arrays.asList(duplicate)); facetIntervalsModel.setIntervals(Arrays.asList(facetInterval, duplicateLabel)); query.setFacetIntervals(facetIntervalsModel); - response = query(query); + + query(query); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() .containsSummary("duplicate interval label [thesame=2]"); diff --git a/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java b/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java index d4ae6bfa7..1add86965 100644 --- a/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java @@ -61,11 +61,7 @@ import org.testng.annotations.Test; */ public class FacetRangeSearchTest extends AbstractSearchTest { - @Override - public void dataPreparation() throws Exception - { - //Skip setup - } + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, description = "Check facet intervals mandatory fields") @@ -76,7 +72,7 @@ public class FacetRangeSearchTest extends AbstractSearchTest RestRequestRangesModel facetRangeModel = new RestRequestRangesModel(); ranges.add(facetRangeModel); query.setRanges(ranges); - SearchResponse response = query(query); + query(query); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() .containsSummary(String.format(RestErrorModel.MANDATORY_PARAM, "field")); @@ -84,21 +80,27 @@ public class FacetRangeSearchTest extends AbstractSearchTest facetRangeModel.setField("content.size"); ranges.add(facetRangeModel); query.setRanges(ranges); - response = query(query); + + query(query); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() .containsSummary(String.format(RestErrorModel.MANDATORY_PARAM, "start")); facetRangeModel.setStart("0"); ranges.clear(); ranges.add(facetRangeModel); query.setRanges(ranges); - response = query(query); + + query(query); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() .containsSummary(String.format(RestErrorModel.MANDATORY_PARAM, "end")); facetRangeModel.setEnd("400"); query.setRanges(ranges); ranges.clear(); ranges.add(facetRangeModel); - response = query(query); + + query(query); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() .containsSummary(String.format(RestErrorModel.MANDATORY_PARAM, "gap")); diff --git a/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java b/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java index a8eccf613..351281858 100644 --- a/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 Alfresco Software Limited. + * Copyright (C) 2018 Alfresco Software Limited. * * This file is part of Alfresco * @@ -36,9 +36,6 @@ import org.testng.annotations.Test; public class FacetedSearchTest extends AbstractSearchTest { - @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, - description = "Checks facet queries for the Search api") /** * Perform the below facet query. * { @@ -89,13 +86,16 @@ public class FacetedSearchTest extends AbstractSearchTest * }} * @throws Exception */ + + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) + @TestRail(section = { TestGroup.REST_API, TestGroup.SEARCH, + TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, description = "Checks facet queries for the Search api") public void searchWithQueryFaceting() throws Exception - { + { SearchRequest query = new SearchRequest(); - RestRequestQueryModel queryReq = new RestRequestQueryModel(); + RestRequestQueryModel queryReq = new RestRequestQueryModel(); queryReq.setQuery("cars"); query.setQuery(queryReq); - List facets = new ArrayList(); facets.add(new FacetQuery("content.size:[0 TO 102400]", "small")); @@ -109,9 +109,11 @@ public class FacetedSearchTest extends AbstractSearchTest query.setFacetFields(facetFields); query.setIncludeRequest(true); - SearchResponse response = query(query); + SearchResponse response = query(query); + response.assertThat().entriesListIsNotEmpty(); response.getContext().assertThat().field("facetQueries").isNotEmpty(); + FacetFieldBucket facet = response.getContext().getFacetQueries().get(0); facet.assertThat().field("label").contains("small").and().field("count").isGreaterThan(0); facet.assertThat().field("label").contains("small").and().field("filterQuery").is("content.size:[0 TO 102400]"); @@ -173,52 +175,53 @@ public class FacetedSearchTest extends AbstractSearchTest public void searchQueryFacetingWithGroup() throws Exception { SearchRequest query = new SearchRequest(); - RestRequestQueryModel queryReq = new RestRequestQueryModel(); + RestRequestQueryModel queryReq = new RestRequestQueryModel(); queryReq.setQuery("cars"); query.setQuery(queryReq); List facets = new ArrayList(); facets.add(new FacetQuery("content.size:[0 TO 102400]", "small", "foo")); - facets.add(new FacetQuery("content.size:[102400 TO 1048576]", "medium","foo")); - facets.add(new FacetQuery("content.size:[1048576 TO 16777216]", "large","foo")); + facets.add(new FacetQuery("content.size:[102400 TO 1048576]", "medium", "foo")); + facets.add(new FacetQuery("content.size:[1048576 TO 16777216]", "large", "foo")); query.setFacetQueries(facets); - + RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); List list = new ArrayList<>(); list.add(new RestRequestFacetFieldModel("'content.size'")); facetFields.setFacets(list); - query.setFacetFields(facetFields); - SearchResponse response = query(query); - //We don't expect to see the FacetQueries if group is being used. + + SearchResponse response = query(query); + + // We don't expect to see the FacetQueries if group is being used. Assert.assertTrue(response.getContext().getFacetQueries() == null); - //Validate the facet field structure is correct. + // Validate the facet field structure is correct. Assert.assertFalse(response.getContext().getFacets().isEmpty()); Assert.assertEquals(response.getContext().getFacets().get(0).getLabel(), "foo"); - + RestGenericBucketModel bucket = response.getContext().getFacets().get(0).getBuckets().get(0); bucket.assertThat().field("label").isNotEmpty(); - Assert.assertEquals( bucket.getMetrics().get(0).getType(), "count"); - Assert.assertNotEquals( bucket.getMetrics().get(0).getValue(), ""); + Assert.assertEquals(bucket.getMetrics().get(0).getType(), "count"); + Assert.assertNotEquals(bucket.getMetrics().get(0).getValue(), ""); bucket.assertThat().field("filterQuery").isNotEmpty(); response.getContext().getFacets().get(0).getBuckets().forEach(action -> { switch (action.getLabel()) { - case "small": - Assert.assertEquals(action.getFilterQuery(), "content.size:[0 TO 102400]"); - break; - case "medium": - Assert.assertEquals(action.getFilterQuery(), "content.size:[102400 TO 1048576]"); - break; - case "large": - Assert.assertEquals(action.getFilterQuery(), "content.size:[1048576 TO 16777216]"); - break; + case "small": + Assert.assertEquals(action.getFilterQuery(), "content.size:[0 TO 102400]"); + break; + case "medium": + Assert.assertEquals(action.getFilterQuery(), "content.size:[102400 TO 1048576]"); + break; + case "large": + Assert.assertEquals(action.getFilterQuery(), "content.size:[1048576 TO 16777216]"); + break; - default: - throw new TestException("Unexpected value returned"); + default: + throw new TestException("Unexpected value returned"); } }); - + } @Test @@ -235,29 +238,34 @@ public class FacetedSearchTest extends AbstractSearchTest public void searchWithFactedFields() throws Exception { SearchRequest query = new SearchRequest(); - RestRequestQueryModel queryReq = new RestRequestQueryModel(); - queryReq.setQuery("*"); + RestRequestQueryModel queryReq = new RestRequestQueryModel(); + queryReq.setQuery(unique_searchString); query.setQuery(queryReq); + RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); - Listfacets = new ArrayList(); + List facets = new ArrayList(); facets.add(new RestRequestFacetFieldModel("cm:mimetype")); facets.add(new RestRequestFacetFieldModel("modifier")); facetFields.setFacets(facets); query.setFacetFields(facetFields); - SearchResponse response = query(query); + + SearchResponse response = query(query); + Assert.assertFalse(response.getContext().getFacetsFields().isEmpty()); Assert.assertNull(response.getContext().getFacetQueries()); Assert.assertNull(response.getContext().getFacets()); + RestResultBucketsModel model = response.getContext().getFacetsFields().get(0); Assert.assertEquals(model.getLabel(), "modifier"); - + model.assertThat().field("label").is("modifier"); FacetFieldBucket bucket1 = model.getBuckets().get(0); - bucket1.assertThat().field("label").is("System"); - bucket1.assertThat().field("display").is("System"); - bucket1.assertThat().field("filterQuery").is("modifier:\"System\""); - bucket1.assertThat().field("count").is(684); + bucket1.assertThat().field("label").is(userModel.getUsername()); + bucket1.assertThat().field("display").is(userModel.getUsername() + " FirstName LN-" + userModel.getUsername()); + bucket1.assertThat().field("filterQuery").is("modifier:\"" + userModel.getUsername() + "\""); + bucket1.assertThat().field("count").is(1); } + @Test /** * Test that items returned are in the format of generic facets. @@ -274,29 +282,31 @@ public class FacetedSearchTest extends AbstractSearchTest public void searchWithFactedFieldsFacetFormatV2() throws Exception { SearchRequest query = new SearchRequest(); - RestRequestQueryModel queryReq = new RestRequestQueryModel(); - queryReq.setQuery("*"); + RestRequestQueryModel queryReq = new RestRequestQueryModel(); + queryReq.setQuery(unique_searchString); query.setQuery(queryReq); query.setFacetFormat("V2"); RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); - Listfacets = new ArrayList(); + List facets = new ArrayList(); facets.add(new RestRequestFacetFieldModel("cm:mimetype")); facets.add(new RestRequestFacetFieldModel("modifier")); facetFields.setFacets(facets); query.setFacetFields(facetFields); - SearchResponse response = query(query); + + SearchResponse response = query(query); + Assert.assertNull(response.getContext().getFacetsFields()); Assert.assertNull(response.getContext().getFacetQueries()); Assert.assertFalse(response.getContext().getFacets().isEmpty()); RestGenericFacetResponseModel model = response.getContext().getFacets().get(0); Assert.assertEquals(model.getLabel(), "modifier"); - + model.assertThat().field("label").is("modifier"); RestGenericBucketModel bucket1 = model.getBuckets().get(0); - bucket1.assertThat().field("label").is("System"); - bucket1.assertThat().field("display").isNull(); - bucket1.assertThat().field("filterQuery").is("modifier:\"System\""); - bucket1.assertThat().field("metrics").is("[{entry=null, type=count, value={count=684}}]"); + bucket1.assertThat().field("label").is(userModel.getUsername()); + bucket1.assertThat().field("display").is(userModel.getUsername() + " FirstName LN-" + userModel.getUsername()); + bucket1.assertThat().field("filterQuery").is("modifier:\"" + userModel.getUsername() + "\""); + bucket1.assertThat().field("metrics").is("[{entry=null, type=count, value={count=1}}]"); } } diff --git a/e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java b/e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java index 675d5da3c..04e0e57bf 100644 --- a/e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 Alfresco Software Limited. + * Copyright (C) 2018 Alfresco Software Limited. * * This file is part of Alfresco * @@ -18,7 +18,6 @@ */ package org.alfresco.rest.search; -import org.alfresco.utility.model.ContentModel; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FileType; import org.alfresco.utility.model.FolderModel; @@ -34,34 +33,37 @@ import org.testng.annotations.Test; */ public class FingerPrintTest extends AbstractSearchTest { - private FileModel file1,file2,file3,file4; - @BeforeClass + private FileModel file1, file2, file3, file4; + + @BeforeClass(alwaysRun = true) public void indexSimilarFile() throws Exception { - adminUserModel = dataUser.getAdminUser(); - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + /* - * Create the following file structure for preconditions : - * |- folder - * |-- fox.txt + * Create the following file structure in the same Site : In addition to the preconditions created in dataPreparation + * |- folder + * |-- pangram-banana.txt + * |-- pangram-taco.txt + * |-- pangram-cat.txt + * |-- dog.txt */ - nodesBuilder = restClient.authenticateUser(userModel).withCoreAPI().usingNode(ContentModel.my()).defineNodes(); - FolderModel folder = new FolderModel(SEARCH_DATA_SAMPLE_FOLDER); + + FolderModel folder = new FolderModel("The quick brown fox jumps over"); dataContent.usingUser(userModel).usingSite(siteModel).createFolder(folder); + file1 = new FileModel("pangram-banana.txt", FileType.TEXT_PLAIN, "The quick brown fox jumps over the lazy banana"); file2 = new FileModel("pangram-taco.txt", FileType.TEXT_PLAIN, "The quick brown fox jumps over the lazy dog that ate the taco"); file3 = new FileModel("pangram-cat.txt", FileType.TEXT_PLAIN, "The quick brown fox jumps over the lazy cat"); file4 = new FileModel("dog.txt", FileType.TEXT_PLAIN, "The quick brown fox ate the lazy dog"); - ContentModel cm = new ContentModel(); - cm.setCmisLocation(folder.getCmisLocation()); - cm.setName(folder.getName()); - dataContent.usingUser(userModel).usingSite(siteModel).usingResource(cm).createContent(file1); - dataContent.usingUser(userModel).usingSite(siteModel).usingResource(cm).createContent(file2); - dataContent.usingUser(userModel).usingSite(siteModel).usingResource(cm).createContent(file3); - dataContent.usingUser(userModel).usingSite(siteModel).usingResource(cm).createContent(file4); - Thread.sleep(35000);//Allow indexing to complete. + + dataContent.usingUser(userModel).usingSite(siteModel).usingResource(folder).createContent(file1); + dataContent.usingUser(userModel).usingSite(siteModel).usingResource(folder).createContent(file2); + dataContent.usingUser(userModel).usingSite(siteModel).usingResource(folder).createContent(file3); + dataContent.usingUser(userModel).usingSite(siteModel).usingResource(folder).createContent(file4); + + waitForIndexing(file4.getName(), true); } + /** * Search similar document based on document finger print. * The data prep should have loaded 2 files which one is similar @@ -70,7 +72,7 @@ public class FingerPrintTest extends AbstractSearchTest * * @throws Exception */ - @Test(groups= {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1}) + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) public void search() throws Exception { String uuid = file1.getNodeRefWithoutVersion(); @@ -79,46 +81,50 @@ public class FingerPrintTest extends AbstractSearchTest SearchResponse response = query(fingerprint); int count = response.getEntries().size(); Assert.assertTrue(count > 1); - for(SearchNodeModel m :response.getEntries()) + for (SearchNodeModel m : response.getEntries()) { String match = m.getModel().getName(); switch (match) { - case "pangram.txt": - break; - case "pangram-banana.txt": - break; - case "pangram-taco.txt": - break; - case "pangram-cat.txt": - break; - default: - throw new AssertionError("Not a match to an expected file: " + m.getModel().getName()); + case "pangram.txt": + break; + case "pangram-banana.txt": + break; + case "pangram-taco.txt": + break; + case "pangram-cat.txt": + break; + default: + throw new AssertionError("Not a match to an expected file: " + m.getModel().getName()); } m.getModel().assertThat().field("name").isNot("dog.txt"); m.getModel().assertThat().field("name").isNot("cars.txt"); } } - @Test(groups= {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1}) + + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) public void searchSimilar() throws Exception { String uuid = file2.getNodeRefWithoutVersion(); Assert.assertNotNull(uuid); - // In the response eneity there is a score of each doc, change below threshold to bring more like or less. - String fingerprint = String.format("FINGERPRINT:%s_68", uuid); + + // In the response entity there is a score of each doc, change below threshold to bring more like or less. + String fingerprint = String.format("FINGERPRINT:%s_68", uuid); SearchResponse response = query(fingerprint); + int count = response.getEntries().size(); Assert.assertTrue(count > 1); - for(SearchNodeModel m :response.getEntries()) + + for (SearchNodeModel m : response.getEntries()) { switch (m.getModel().getName()) { - case "pangram.txt": - break; - case "pangram-taco.txt": - break; - default: - throw new AssertionError("Not a match to an expected file: " + m.getModel().getName()); + case "pangram.txt": + break; + case "pangram-taco.txt": + break; + default: + throw new AssertionError("Not a match to an expected file: " + m.getModel().getName()); } m.getModel().assertThat().field("name").isNot("pangram-banana.txt"); m.getModel().assertThat().field("name").isNot("pangram-cat.txt"); @@ -126,7 +132,8 @@ public class FingerPrintTest extends AbstractSearchTest m.getModel().assertThat().field("name").isNot("cars.txt"); } } - @Test(groups= {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1}) + + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) public void searchSimilar67Percent() throws Exception { String uuid = file2.getNodeRefWithoutVersion(); @@ -135,18 +142,18 @@ public class FingerPrintTest extends AbstractSearchTest SearchResponse response = query(fingerprint); int count = response.getEntries().size(); Assert.assertTrue(count > 1); - for(SearchNodeModel m :response.getEntries()) + for (SearchNodeModel m : response.getEntries()) { switch (m.getModel().getName()) { - case "pangram.txt": - break; - case "pangram-taco.txt": - break; - case "pangram-cat.txt": - break; - default: - throw new AssertionError("Not a match to an expected file: " + m.getModel().getName()); + case "pangram.txt": + break; + case "pangram-taco.txt": + break; + case "pangram-cat.txt": + break; + default: + throw new AssertionError("Not a match to an expected file: " + m.getModel().getName()); } m.getModel().assertThat().field("name").isNot("pangram-banana.txt"); m.getModel().assertThat().field("name").isNot("dog.txt"); diff --git a/e2e-test/java/org/alfresco/rest/search/PivotFacetedSearchTest.java b/e2e-test/java/org/alfresco/rest/search/PivotFacetedSearchTest.java index bc54be77d..c21b9e2c7 100644 --- a/e2e-test/java/org/alfresco/rest/search/PivotFacetedSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/PivotFacetedSearchTest.java @@ -60,12 +60,15 @@ public class PivotFacetedSearchTest extends AbstractSearchTest pivotModelList.add(pivots); query.setPivots(pivotModelList); - SearchResponse response = query(query); + query(query); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() .containsSummary(String.format(RestErrorModel.MANDATORY_PARAM, "pivot key")); pivots.setKey("none_like_this"); - response = query(query); + + query(query); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) .assertLastError().containsSummary("invalid argument was received") .containsSummary("Pivot parameter none_like_this does not reference"); diff --git a/e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java b/e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java index 030494997..0a2b9c762 100644 --- a/e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java +++ b/e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 Alfresco Software Limited. + * Copyright (C) 2018 Alfresco Software Limited. * * This file is part of Alfresco * @@ -116,12 +116,15 @@ public class SearchAPATHTest extends AbstractSearchTest Assert.assertEquals(4,fresponse.getBuckets().size()); fresponse.getBuckets().get(0).assertThat().field("label").contains("1/"); } + @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_1}) public void searchLevel2() throws Exception { + String queryString = "name:"+ "cars"; + SearchRequest searchQuery = new SearchRequest(); RestRequestQueryModel queryReq = new RestRequestQueryModel(); - queryReq.setQuery("name:*"); + queryReq.setQuery(queryString); searchQuery.setQuery(queryReq); RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); @@ -131,6 +134,7 @@ public class SearchAPATHTest extends AbstractSearchTest searchQuery.setFacetFields(facetFields); SearchResponse response = query(searchQuery); + RestResultBucketsModel fresponse = response.getContext().getFacetsFields().get(0); String path = fresponse.getBuckets().get(0).getLabel().replace("1/", "2/"); list.remove(0); @@ -140,7 +144,7 @@ public class SearchAPATHTest extends AbstractSearchTest searchQuery.setFacetFields(facetFields); response = query(searchQuery); fresponse = response.getContext().getFacetsFields().get(0); - Assert.assertEquals(fresponse.getBuckets().size(),3); + Assert.assertTrue(fresponse.getBuckets().size() >= 1); fresponse.getBuckets().get(0).assertThat().field("label").contains("2/"); fresponse.getBuckets().get(0).assertThat().field("label").contains(path); /** @@ -151,7 +155,7 @@ public class SearchAPATHTest extends AbstractSearchTest */ searchQuery = new SearchRequest(); queryReq = new RestRequestQueryModel(); - queryReq.setQuery("name:*"); + queryReq.setQuery(queryString); searchQuery.setQuery(queryReq); facetFields = new RestRequestFacetFieldsModel(); list.remove(0); @@ -160,8 +164,7 @@ public class SearchAPATHTest extends AbstractSearchTest searchQuery.setFacetFields(facetFields); response = query(searchQuery); fresponse = response.getContext().getFacetsFields().get(0); - System.out.println(response); - Assert.assertTrue(fresponse.getBuckets().size() > 5); + Assert.assertTrue(fresponse.getBuckets().size() >= 1); fresponse.getBuckets().get(0).assertThat().field("label").contains("3/"); } } diff --git a/e2e-test/java/org/alfresco/rest/search/SearchSpellCheckTest.java b/e2e-test/java/org/alfresco/rest/search/SearchSpellCheckTest.java index a13e447fb..c55d0b215 100644 --- a/e2e-test/java/org/alfresco/rest/search/SearchSpellCheckTest.java +++ b/e2e-test/java/org/alfresco/rest/search/SearchSpellCheckTest.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 Alfresco Software Limited. + * Copyright (C) 2018 Alfresco Software Limited. * * This file is part of Alfresco * @@ -19,6 +19,8 @@ package org.alfresco.rest.search; import org.alfresco.rest.model.RestRequestSpellcheckModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FileType; import org.alfresco.utility.model.TestGroup; import org.junit.Assert; import org.testng.annotations.Test; @@ -26,10 +28,11 @@ import org.testng.annotations.Test; /** * Search end point Public API test with spell checking enabled. * @author Michael Suzuki - *5 + * @author Meenal Bhave */ public class SearchSpellCheckTest extends AbstractSearchTest { + /** * Perform the below query * { @@ -61,24 +64,48 @@ public class SearchSpellCheckTest extends AbstractSearchTest * * @throws Exception */ - @Test(groups={TestGroup.SEARCH, TestGroup.REST_API}) - public void searchMissSpelled() throws Exception + @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ACS_60n}, priority=1) + public void testSearchMissSpelled() throws Exception { + // Name SearchRequest searchReq = new SearchRequest(); RestRequestQueryModel queryReq = new RestRequestQueryModel(); + queryReq.setQuery("cm:name:alfrezco"); + queryReq.setUserQuery("alfrezco"); + searchReq.setQuery(queryReq); + searchReq.setSpellcheck(new RestRequestSpellcheckModel()); + assertResponse(query(searchReq)); + + // Title queryReq.setQuery("cm:title:alfrezco"); queryReq.setUserQuery("alfrezco"); searchReq.setQuery(queryReq); searchReq.setSpellcheck(new RestRequestSpellcheckModel()); assertResponse(query(searchReq)); + + // Description + queryReq.setQuery("cm:description:alfrezco"); + queryReq.setUserQuery("alfrezco"); + searchReq.setQuery(queryReq); + searchReq.setSpellcheck(new RestRequestSpellcheckModel()); + assertResponse(query(searchReq)); + + // Content + queryReq.setQuery("cm:content:alfrezco"); + queryReq.setUserQuery("alfrezco"); + searchReq.setQuery(queryReq); + searchReq.setSpellcheck(new RestRequestSpellcheckModel()); + assertResponse(query(searchReq)); } + private void assertResponse(SearchResponse nodes) throws Exception { nodes.assertThat().entriesListIsNotEmpty(); nodes.getContext().assertThat().field("spellCheck").isNotEmpty(); nodes.getContext().getSpellCheck().assertThat().field("suggestions").contains("alfresco"); + nodes.getContext().getSpellCheck().assertThat().field("type").is("searchInsteadFor"); } - @Test + /** * Perform alternative way by setting the value in spellcheck object. * @@ -91,7 +118,8 @@ public class SearchSpellCheckTest extends AbstractSearchTest * } * @throws Exception */ - public void searchMissSpelledVersion2() throws Exception + @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ACS_60n}, priority=2) + public void testSearchMissSpelledVersion2() throws Exception { SearchRequest searchReq = new SearchRequest(); RestRequestQueryModel queryReq = new RestRequestQueryModel(); @@ -103,8 +131,9 @@ public class SearchSpellCheckTest extends AbstractSearchTest searchReq.setSpellcheck(spellCheck); assertResponse(query(searchReq)); } - @Test - public void searchWithSpellcheckerAndCorrectSpelling() throws Exception + + @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ACS_60n}, priority=3) + public void testSearchWithSpellcheckerAndCorrectSpelling() throws Exception { SearchRequest searchReq = new SearchRequest(); RestRequestQueryModel queryReq = new RestRequestQueryModel(); @@ -113,7 +142,31 @@ public class SearchSpellCheckTest extends AbstractSearchTest searchReq.setQuery(queryReq); searchReq.setSpellcheck(new RestRequestSpellcheckModel()); SearchResponse res = query(searchReq); - Assert.assertNull(res.getContext()); + Assert.assertNull(res.getContext().getSpellCheck()); res.assertThat().entriesListIsNotEmpty(); } + + @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ACS_60n}, priority=4) + public void testSpellCheckType() throws Exception + { + // Create a file with mis-spelt name, expect spellcheck type = didYouMean + FileModel file = new FileModel(unique_searchString + "-1.txt", "uniquee" + "uniquee", "uniquee", FileType.TEXT_PLAIN, "Unique text file for search "); + dataContent.usingUser(userModel).usingSite(siteModel).createContent(file); + + waitForIndexing(file.getName(), true); + + // Search + SearchRequest searchReq = new SearchRequest(); + RestRequestQueryModel queryReq = new RestRequestQueryModel(); + queryReq.setQuery("cm:title:uniquee"); + queryReq.setUserQuery("uniquee"); + searchReq.setQuery(queryReq); + searchReq.setSpellcheck(new RestRequestSpellcheckModel()); + SearchResponse nodes = query(searchReq); + + nodes.assertThat().entriesListIsNotEmpty(); + nodes.getContext().assertThat().field("spellCheck").isNotEmpty(); + nodes.getContext().getSpellCheck().assertThat().field("suggestions").contains("unique"); + nodes.getContext().getSpellCheck().assertThat().field("type").is("didYouMean"); + } } diff --git a/e2e-test/java/org/alfresco/rest/search/SearchTest.java b/e2e-test/java/org/alfresco/rest/search/SearchTest.java index 5f038dfc6..b1a285c6c 100644 --- a/e2e-test/java/org/alfresco/rest/search/SearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/SearchTest.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 Alfresco Software Limited. + * Copyright (C) 2018 Alfresco Software Limited. * * This file is part of Alfresco * @@ -36,14 +36,14 @@ public class SearchTest extends AbstractSearchTest @Test(groups={TestGroup.SEARCH, TestGroup.REST_API}) public void searchOnIndexedData() throws Exception { - SearchResponse nodes = query("ipsum"); + SearchResponse nodes = query(unique_searchString); restClient.assertStatusCodeIs(HttpStatus.OK); nodes.assertThat().entriesListIsNotEmpty(); SearchNodeModel entity = nodes.getEntryByIndex(0); entity.assertThat().field("search").contains("score"); entity.getSearch().assertThat().field("score").isNotEmpty(); - Assert.assertEquals("Project Overview.ppt",entity.getName()); + Assert.assertEquals("pangram.txt",entity.getName()); } @Test(groups={TestGroup.SEARCH,TestGroup.REST_API}) diff --git a/e2e-test/java/org/alfresco/rest/search/ShardInfoTest.java b/e2e-test/java/org/alfresco/rest/search/ShardInfoTest.java index abc59ff03..d4c5678c1 100644 --- a/e2e-test/java/org/alfresco/rest/search/ShardInfoTest.java +++ b/e2e-test/java/org/alfresco/rest/search/ShardInfoTest.java @@ -41,7 +41,7 @@ import org.testng.annotations.Test; public class ShardInfoTest extends AbstractSearchTest { @Bug(id="DELENG-1", status=Bug.Status.OPENED) - @Test(groups={TestGroup.SEARCH, TestGroup.REST_API}) + @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ACS_60n}) public void getShardInfoWithAdminAuthority() throws JsonProcessingException, EmptyRestModelCollectionException { RestShardInfoModelCollection info = restClient.authenticateUser(dataUser.getAdminUser()).withShardInfoAPI().getInfo(); @@ -70,7 +70,8 @@ public class ShardInfoTest extends AbstractSearchTest RestInstanceModel instance = instances.iterator().next(); assertNotNull(instance); baseUrls.contains(instance.getBaseUrl()); - assertEquals(instance.getHost(), "localhost"); + // TODO: Ideally Solr Host and Port should be Parameterised + assertEquals(instance.getHost(), "search"); assertEquals(instance.getPort().intValue(), 8983); assertEquals(instance.getState(), "ACTIVE"); assertEquals(instance.getMode(), "MASTER"); @@ -78,7 +79,7 @@ public class ShardInfoTest extends AbstractSearchTest } @Bug(id="DELENG-1", status=Bug.Status.OPENED) - @Test(groups={TestGroup.SEARCH, TestGroup.REST_API}) + @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ACS_60n}) public void getShardInfoWithoutAdminAuthority() throws Exception { restClient.authenticateUser(dataUser.createRandomTestUser()).withShardInfoAPI().getInfo(); diff --git a/e2e-test/java/org/alfresco/rest/sharedLinks/SharedLinksSanityTests.java b/e2e-test/java/org/alfresco/rest/sharedLinks/SharedLinksSanityTests.java index d41f2d646..c9dbc91fe 100644 --- a/e2e-test/java/org/alfresco/rest/sharedLinks/SharedLinksSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sharedLinks/SharedLinksSanityTests.java @@ -1,7 +1,5 @@ package org.alfresco.rest.sharedLinks; -import static org.testng.Assert.assertEquals; - import javax.json.Json; import org.alfresco.dataprep.CMISUtil.DocumentType; diff --git a/e2e-test/resources/SearchSuite.xml b/e2e-test/resources/SearchSuite.xml new file mode 100644 index 000000000..34bc53bb6 --- /dev/null +++ b/e2e-test/resources/SearchSuite.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/e2e-test/resources/default.properties b/e2e-test/resources/default.properties index 7c7516125..b44ef9b4a 100644 --- a/e2e-test/resources/default.properties +++ b/e2e-test/resources/default.properties @@ -8,6 +8,9 @@ sync.scheme=http sync.server=localhost sync.port=9090 +#Solr Indexing Time +solrWaitTimeInSeconds=20 + # credentials admin.user=admin admin.password=admin From efea12cfb9c562b73aad1ee4ec5f69ebdc9c1075 Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Mon, 14 May 2018 18:02:05 +0100 Subject: [PATCH 1352/1491] Search-741, SEARCH-844: Added new api \sql for Insight engine + sanity tests --- .../rest/search/AbstractSearchTest.java | 47 +++++--- .../rest/search/sql/SearchSQLAPITest.java | 103 ++++++++++++++++++ 2 files changed, 136 insertions(+), 14 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/search/sql/SearchSQLAPITest.java diff --git a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java index 560f385dd..c8463c0ac 100644 --- a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java @@ -18,8 +18,11 @@ */ package org.alfresco.rest.search; +import javax.naming.AuthenticationException; + import org.alfresco.dataprep.SiteService.Visibility; import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.RestResponse; import org.alfresco.utility.Utility; import org.alfresco.utility.data.RandomData; import org.alfresco.utility.model.FileModel; @@ -27,6 +30,7 @@ import org.alfresco.utility.model.FileType; import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; +import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; /** @@ -44,9 +48,9 @@ public class AbstractSearchTest extends RestTest { protected static final String SEARCH_DATA_SAMPLE_FOLDER = "FolderSearch"; - UserModel userModel, adminUserModel; - SiteModel siteModel; - UserModel searchedUser; + protected UserModel userModel, adminUserModel; + protected SiteModel siteModel; + protected UserModel searchedUser; protected FileModel file, file2, file3, file4; protected static String unique_searchString; @@ -135,6 +139,7 @@ public class AbstractSearchTest extends RestTest { return restClient.authenticateUser(userModel).withSearchAPI().search(query); } + protected SearchRequest createQuery(String term) { SearchRequest query = new SearchRequest(); @@ -148,8 +153,14 @@ public class AbstractSearchTest extends RestTest return createQuery("cars"); } + protected RestResponse searchSql(SearchSqlRequest searchSqlRequest) throws Exception + { + return restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(searchSqlRequest); + } + /** * Wait for Solr to finish indexing: Indexing has caught up = true if search returns appropriate results + * * @param userQuery: string to search for, unique search string will guarantee accurate results * @param expectedInResults, true if entry is expected in the results set * @return true (indexing is finished) if search returns appropriate results @@ -159,6 +170,7 @@ public class AbstractSearchTest extends RestTest { Boolean found = false; Boolean resultAsExpected = false; + String expectedStatusCode = HttpStatus.OK.toString(); SearchRequest searchRequest = createQuery(userQuery); SearchResponse response = query(searchRequest); @@ -172,23 +184,30 @@ public class AbstractSearchTest extends RestTest Utility.waitToLoopTime(properties.getSolrWaitTimeInSeconds(), "Wait For Indexing"); } - if (response.getEntries().size() >= 1) + if (restClient.getStatusCode().matches(expectedStatusCode)) { - found = true; + if (response.getEntries().size() >= 1) + { + found = true; + } + else + { + found = false; + } + + // Loop again if result is not as expected: To cater for solr lag: eventual consistency + resultAsExpected = (expectedInResults.equals(found)); + if (resultAsExpected) + { + break; + } } else { - found = false; - } - - // Loop again if result is not as expected: To cater for solr lag: eventual consistency - resultAsExpected = (expectedInResults.equals(found)); - if (resultAsExpected) - { - break; + throw new AuthenticationException("API returned status code:" + restClient.getStatusCode() + " Expected: " + expectedStatusCode); } } return resultAsExpected; } -} +} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLAPITest.java b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLAPITest.java new file mode 100644 index 000000000..36e59760d --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLAPITest.java @@ -0,0 +1,103 @@ +/* + * Copyright (C) 2018 Alfresco Software Limited. + * This file is part of Alfresco + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.rest.search.sql; + +import org.alfresco.rest.search.AbstractSearchTest; +import org.alfresco.rest.search.SearchSqlRequest; +import org.alfresco.utility.model.TestGroup; +import org.springframework.http.HttpStatus; +import org.testng.annotations.Test; + +/** + * Tests for /sql end point Search API. + * + * @author Meenal Bhave + */ +public class SearchSQLAPITest extends AbstractSearchTest +{ + String sql = "select SITE, CM_OWNER from alfresco group by SITE,CM_OWNER"; + String[] locales = { "en-US" }; + String solrFormat = "solr"; + + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 01) + public void queryTestWithSolr() throws Exception + { + SearchSqlRequest sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql(sql); + sqlRequest.setFormat(solrFormat); + sqlRequest.setLocales(locales); + + restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest); + restClient.assertStatusCodeIs(HttpStatus.OK); + + restClient.onResponse().assertThat().body("result-set", org.hamcrest.Matchers.notNullValue()); + restClient.onResponse().assertThat().body("result-set.docs", org.hamcrest.Matchers.notNullValue()); + } + + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 02) + public void queryTestWithJson() throws Exception + { + SearchSqlRequest sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql(sql); + sqlRequest.setLocales(locales); + // Format not set + + restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest); + restClient.assertStatusCodeIs(HttpStatus.OK); + + restClient.onResponse().assertThat().body("result-set", org.hamcrest.Matchers.nullValue()); + restClient.onResponse().assertThat().body("list.entries", org.hamcrest.Matchers.notNullValue()); + + sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql(sql); + sqlRequest.setLocales(locales); + sqlRequest.setFormat("json"); // Format json + + restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest); + restClient.assertStatusCodeIs(HttpStatus.OK); + + restClient.onResponse().assertThat().body("result-set", org.hamcrest.Matchers.nullValue()); + restClient.onResponse().assertThat().body("list.entries", org.hamcrest.Matchers.notNullValue()); + + sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql(sql); + sqlRequest.setLocales(locales); + sqlRequest.setFormat("abcd"); // Format any other than solr + + restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest); + restClient.assertStatusCodeIs(HttpStatus.OK); + + restClient.onResponse().assertThat().body("result-set", org.hamcrest.Matchers.nullValue()); + restClient.onResponse().assertThat().body("list.entries", org.hamcrest.Matchers.notNullValue()); + } + + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 03) + public void queryTestWithSolrIncludeMetadata() throws Exception + { + SearchSqlRequest sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql(sql); + sqlRequest.setFormat(solrFormat); + sqlRequest.setLocales(locales); + sqlRequest.setIncludeMetadata(true); + + searchSql(sqlRequest); + + restClient.assertStatusCodeIs(HttpStatus.OK); + + restClient.onResponse().assertThat().body("result-set", org.hamcrest.Matchers.notNullValue()); + restClient.onResponse().assertThat().body("result-set.docs", org.hamcrest.Matchers.notNullValue()); + restClient.onResponse().assertThat().body("result-set.docs[0].isMetadata", org.hamcrest.Matchers.is(true)); + } +} \ No newline at end of file From 3e853c22027b66097e0a1ba3bf17265d1677e031 Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Tue, 15 May 2018 10:54:44 +0100 Subject: [PATCH 1353/1491] Search-741 Added API post body and respose example --- .../rest/search/sql/SearchSQLAPITest.java | 192 +++++++++++++++++- 1 file changed, 189 insertions(+), 3 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLAPITest.java b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLAPITest.java index 36e59760d..f7dbc66bd 100644 --- a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLAPITest.java +++ b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLAPITest.java @@ -31,8 +31,38 @@ public class SearchSQLAPITest extends AbstractSearchTest String[] locales = { "en-US" }; String solrFormat = "solr"; + /** + * API post: + * { + * "stmt": "select SITE from alfresco", + * "locales" : ["en_US"], + * "format" : "solr", + * "timezone":"", + * "includeMetadata":false + * } + * Example Response: In Solr Format + * { + * "result-set": + * { + * "docs": + * [ + * { + * "SITE": + * [ + * "swsdp" + * ] + * }, + * { + * "SITE": + * [ + * "swsdp" + * ] + * } + * ] + * } + */ @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 01) - public void queryTestWithSolr() throws Exception + public void testWithSolr() throws Exception { SearchSqlRequest sqlRequest = new SearchSqlRequest(); sqlRequest.setSql(sql); @@ -46,8 +76,46 @@ public class SearchSQLAPITest extends AbstractSearchTest restClient.onResponse().assertThat().body("result-set.docs", org.hamcrest.Matchers.notNullValue()); } + /** + * API post example: + * { + * "stmt": "select SITE from alfresco", + * "locales" : ["en_US"], + * "format" : "json", + * "timezone":"", + * "includeMetadata":false + * } + * Example Response: In json Format + * { + * "list": + * { + * "pagination": + * { + "count": 103, + "hasMoreItems": false, + "totalItems": 103, + "skipCount": 0, + "maxItems": 1000 + }, + * "entries": + * [ + * "entry": [ + { + "label": "SITE", + "value": "[\"swsdp\"]" + } + ], + "entry": [ + { + "label": "SITE", + "value": "[\"swsdp\"]" + } + ] + * ] + * } + */ @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 02) - public void queryTestWithJson() throws Exception + public void testWithJson() throws Exception { SearchSqlRequest sqlRequest = new SearchSqlRequest(); sqlRequest.setSql(sql); @@ -83,8 +151,48 @@ public class SearchSQLAPITest extends AbstractSearchTest restClient.onResponse().assertThat().body("list.entries", org.hamcrest.Matchers.notNullValue()); } + /** + * API post: + * { + * "stmt": "select SITE from alfresco", + * "locales" : ["en_US"], + * "format" : "solr", + * "timezone":"", + * "includeMetadata":true + * } + * Example Response: In Solr Format: Includes metadata: aliases, fields, isMetadata=true + * { + * "result-set": { + * "docs": [ + * { + * "aliases": { + * "SITE": "SITE" + * }, + * "isMetadata": true, + * "fields": [ + * "SITE" + * ] + * }, + * { + * "SITE": [ + * "swsdp" + * ] + * }, + * { + * "SITE": [ + * "swsdp" + * ] + * }, + * { + * "RESPONSE_TIME": 79, + * "EOF": true + * } + * ] + * } + * } + */ @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 03) - public void queryTestWithSolrIncludeMetadata() throws Exception + public void testWithSolrIncludeMetadata() throws Exception { SearchSqlRequest sqlRequest = new SearchSqlRequest(); sqlRequest.setSql(sql); @@ -98,6 +206,84 @@ public class SearchSQLAPITest extends AbstractSearchTest restClient.onResponse().assertThat().body("result-set", org.hamcrest.Matchers.notNullValue()); restClient.onResponse().assertThat().body("result-set.docs", org.hamcrest.Matchers.notNullValue()); + restClient.onResponse().assertThat().body("result-set.docs[0].aliases.SITE", org.hamcrest.Matchers.equalToIgnoringCase("SITE")); restClient.onResponse().assertThat().body("result-set.docs[0].isMetadata", org.hamcrest.Matchers.is(true)); + restClient.onResponse().assertThat().body("result-set.docs[0].fields[0]", org.hamcrest.Matchers.equalToIgnoringCase("SITE")); + } + + /** + * API post example: + * { + * "stmt": "select SITE from alfresco limit 2", + * "locales" : ["en_US"], + * "format" : "json", + * "timezone":"", + * "includeMetadata":false + * } + * Example Response: In json Format + * { + * "list": + * { + * "pagination": + * { + "count": 3, + "hasMoreItems": false, + "totalItems": 3, + "skipCount": 0, + "maxItems": 1000 + }, + * "entries": + * [ + * "entry": [ + { + "label": "aliases", + "value": "{\"SITE\":\"SITE\"}" + }, + { + "label": "isMetadata", + "value": "true" + }, + { + "label": "fields", + "value": "[\"SITE\"]" + } + ] + }, + * "entry": [ + { + "label": "SITE", + "value": "[\"swsdp\"]" + } + ], + "entry": [ + { + "label": "SITE", + "value": "[\"swsdp\"]" + } + ] + * ] + * } + */ + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 04) + public void testWithJsonIncludeMetadata() throws Exception + { + SearchSqlRequest sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql(sql); + sqlRequest.setFormat(""); + sqlRequest.setLocales(locales); + sqlRequest.setIncludeMetadata(true); + + searchSql(sqlRequest); + + restClient.assertStatusCodeIs(HttpStatus.OK); + + restClient.onResponse().assertThat().body("result-set", org.hamcrest.Matchers.nullValue()); + restClient.onResponse().assertThat().body("list.entries", org.hamcrest.Matchers.notNullValue()); + restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", org.hamcrest.Matchers.equalToIgnoringCase("aliases")); + restClient.onResponse().assertThat().body("list.entries.entry[0][0].value", org.hamcrest.Matchers.equalToIgnoringCase("{\"SITE\":\"SITE\",\"cm_owner\":\"CM_OWNER\"}")); + restClient.onResponse().assertThat().body("list.entries.entry[0][1].label", org.hamcrest.Matchers.equalToIgnoringCase("isMetadata")); + restClient.onResponse().assertThat().body("list.entries.entry[0][1].value", org.hamcrest.Matchers.is("true")); + restClient.onResponse().assertThat().body("list.entries.entry[0][2].label", org.hamcrest.Matchers.equalToIgnoringCase("fields")); + restClient.onResponse().assertThat().body("list.entries.entry[0][2].value", org.hamcrest.Matchers.equalToIgnoringCase("[\"SITE\",\"cm_owner\"]")); } } \ No newline at end of file From c8798703fc2f159bad73baf7c2e7813505a6d26b Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Tue, 15 May 2018 11:07:31 +0100 Subject: [PATCH 1354/1491] Search 741 Imported org.hamcrest.Matchers --- .../rest/search/sql/SearchSQLAPITest.java | 43 ++++++++++--------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLAPITest.java b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLAPITest.java index f7dbc66bd..bd0c9e0a0 100644 --- a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLAPITest.java +++ b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLAPITest.java @@ -19,6 +19,7 @@ import org.alfresco.rest.search.SearchSqlRequest; import org.alfresco.utility.model.TestGroup; import org.springframework.http.HttpStatus; import org.testng.annotations.Test; +import org.hamcrest.Matchers; /** * Tests for /sql end point Search API. @@ -72,8 +73,8 @@ public class SearchSQLAPITest extends AbstractSearchTest restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest); restClient.assertStatusCodeIs(HttpStatus.OK); - restClient.onResponse().assertThat().body("result-set", org.hamcrest.Matchers.notNullValue()); - restClient.onResponse().assertThat().body("result-set.docs", org.hamcrest.Matchers.notNullValue()); + restClient.onResponse().assertThat().body("result-set", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("result-set.docs", Matchers.notNullValue()); } /** @@ -125,8 +126,8 @@ public class SearchSQLAPITest extends AbstractSearchTest restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest); restClient.assertStatusCodeIs(HttpStatus.OK); - restClient.onResponse().assertThat().body("result-set", org.hamcrest.Matchers.nullValue()); - restClient.onResponse().assertThat().body("list.entries", org.hamcrest.Matchers.notNullValue()); + restClient.onResponse().assertThat().body("result-set", Matchers.nullValue()); + restClient.onResponse().assertThat().body("list.entries", Matchers.notNullValue()); sqlRequest = new SearchSqlRequest(); sqlRequest.setSql(sql); @@ -136,8 +137,8 @@ public class SearchSQLAPITest extends AbstractSearchTest restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest); restClient.assertStatusCodeIs(HttpStatus.OK); - restClient.onResponse().assertThat().body("result-set", org.hamcrest.Matchers.nullValue()); - restClient.onResponse().assertThat().body("list.entries", org.hamcrest.Matchers.notNullValue()); + restClient.onResponse().assertThat().body("result-set", Matchers.nullValue()); + restClient.onResponse().assertThat().body("list.entries", Matchers.notNullValue()); sqlRequest = new SearchSqlRequest(); sqlRequest.setSql(sql); @@ -147,8 +148,8 @@ public class SearchSQLAPITest extends AbstractSearchTest restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest); restClient.assertStatusCodeIs(HttpStatus.OK); - restClient.onResponse().assertThat().body("result-set", org.hamcrest.Matchers.nullValue()); - restClient.onResponse().assertThat().body("list.entries", org.hamcrest.Matchers.notNullValue()); + restClient.onResponse().assertThat().body("result-set", Matchers.nullValue()); + restClient.onResponse().assertThat().body("list.entries", Matchers.notNullValue()); } /** @@ -204,11 +205,11 @@ public class SearchSQLAPITest extends AbstractSearchTest restClient.assertStatusCodeIs(HttpStatus.OK); - restClient.onResponse().assertThat().body("result-set", org.hamcrest.Matchers.notNullValue()); - restClient.onResponse().assertThat().body("result-set.docs", org.hamcrest.Matchers.notNullValue()); - restClient.onResponse().assertThat().body("result-set.docs[0].aliases.SITE", org.hamcrest.Matchers.equalToIgnoringCase("SITE")); - restClient.onResponse().assertThat().body("result-set.docs[0].isMetadata", org.hamcrest.Matchers.is(true)); - restClient.onResponse().assertThat().body("result-set.docs[0].fields[0]", org.hamcrest.Matchers.equalToIgnoringCase("SITE")); + restClient.onResponse().assertThat().body("result-set", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("result-set.docs", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("result-set.docs[0].aliases.SITE", Matchers.equalToIgnoringCase("SITE")); + restClient.onResponse().assertThat().body("result-set.docs[0].isMetadata", Matchers.is(true)); + restClient.onResponse().assertThat().body("result-set.docs[0].fields[0]", Matchers.equalToIgnoringCase("SITE")); } /** @@ -277,13 +278,13 @@ public class SearchSQLAPITest extends AbstractSearchTest restClient.assertStatusCodeIs(HttpStatus.OK); - restClient.onResponse().assertThat().body("result-set", org.hamcrest.Matchers.nullValue()); - restClient.onResponse().assertThat().body("list.entries", org.hamcrest.Matchers.notNullValue()); - restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", org.hamcrest.Matchers.equalToIgnoringCase("aliases")); - restClient.onResponse().assertThat().body("list.entries.entry[0][0].value", org.hamcrest.Matchers.equalToIgnoringCase("{\"SITE\":\"SITE\",\"cm_owner\":\"CM_OWNER\"}")); - restClient.onResponse().assertThat().body("list.entries.entry[0][1].label", org.hamcrest.Matchers.equalToIgnoringCase("isMetadata")); - restClient.onResponse().assertThat().body("list.entries.entry[0][1].value", org.hamcrest.Matchers.is("true")); - restClient.onResponse().assertThat().body("list.entries.entry[0][2].label", org.hamcrest.Matchers.equalToIgnoringCase("fields")); - restClient.onResponse().assertThat().body("list.entries.entry[0][2].value", org.hamcrest.Matchers.equalToIgnoringCase("[\"SITE\",\"cm_owner\"]")); + restClient.onResponse().assertThat().body("result-set", Matchers.nullValue()); + restClient.onResponse().assertThat().body("list.entries", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", Matchers.equalToIgnoringCase("aliases")); + restClient.onResponse().assertThat().body("list.entries.entry[0][0].value", Matchers.equalToIgnoringCase("{\"SITE\":\"SITE\",\"cm_owner\":\"CM_OWNER\"}")); + restClient.onResponse().assertThat().body("list.entries.entry[0][1].label", Matchers.equalToIgnoringCase("isMetadata")); + restClient.onResponse().assertThat().body("list.entries.entry[0][1].value", Matchers.is("true")); + restClient.onResponse().assertThat().body("list.entries.entry[0][2].label", Matchers.equalToIgnoringCase("fields")); + restClient.onResponse().assertThat().body("list.entries.entry[0][2].value", Matchers.equalToIgnoringCase("[\"SITE\",\"cm_owner\"]")); } } \ No newline at end of file From 031cd2b9b69e2bded1101ed1cf221860dc33e294 Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Tue, 15 May 2018 12:19:12 +0100 Subject: [PATCH 1355/1491] Search-741 Added tests to ensure metadata is not included when not specified as true --- .../rest/search/sql/SearchSQLAPITest.java | 61 ++++++++++++++++++- 1 file changed, 59 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLAPITest.java b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLAPITest.java index bd0c9e0a0..c680541e9 100644 --- a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLAPITest.java +++ b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLAPITest.java @@ -128,7 +128,7 @@ public class SearchSQLAPITest extends AbstractSearchTest restClient.onResponse().assertThat().body("result-set", Matchers.nullValue()); restClient.onResponse().assertThat().body("list.entries", Matchers.notNullValue()); - + sqlRequest = new SearchSqlRequest(); sqlRequest.setSql(sql); sqlRequest.setLocales(locales); @@ -139,7 +139,7 @@ public class SearchSQLAPITest extends AbstractSearchTest restClient.onResponse().assertThat().body("result-set", Matchers.nullValue()); restClient.onResponse().assertThat().body("list.entries", Matchers.notNullValue()); - + sqlRequest = new SearchSqlRequest(); sqlRequest.setSql(sql); sqlRequest.setLocales(locales); @@ -287,4 +287,61 @@ public class SearchSQLAPITest extends AbstractSearchTest restClient.onResponse().assertThat().body("list.entries.entry[0][2].label", Matchers.equalToIgnoringCase("fields")); restClient.onResponse().assertThat().body("list.entries.entry[0][2].value", Matchers.equalToIgnoringCase("[\"SITE\",\"cm_owner\"]")); } + + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 05) + public void testIncludeMetadataFalse() throws Exception + { + SearchSqlRequest sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql(sql); + sqlRequest.setFormat("solr"); //Format solr + sqlRequest.setIncludeMetadata(false); + + restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest); + restClient.assertStatusCodeIs(HttpStatus.OK); + + restClient.onResponse().assertThat().body("result-set", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("result-set.docs", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("result-set.docs[0].aliases", Matchers.nullValue()); + restClient.onResponse().assertThat().body("result-set.docs[0].isMetadata", Matchers.nullValue()); + restClient.onResponse().assertThat().body("result-set.docs[0].fields", Matchers.nullValue()); + + sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql(sql); + sqlRequest.setIncludeMetadata(false); + sqlRequest.setFormat("json"); // Format json + + restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest); + restClient.assertStatusCodeIs(HttpStatus.OK); + + restClient.onResponse().assertThat().body("result-set", Matchers.nullValue()); + restClient.onResponse().assertThat().body("list.entries", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", Matchers.not("aliases")); + + + sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql(sql); + sqlRequest.setIncludeMetadata(false); //Format not set + + restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest); + restClient.assertStatusCodeIs(HttpStatus.OK); + + restClient.onResponse().assertThat().body("result-set", Matchers.nullValue()); + restClient.onResponse().assertThat().body("list.entries", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", Matchers.not("aliases")); + + sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql(sql); + sqlRequest.setFormat(solrFormat); // IncludeMetadata = false when not specified + + restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest); + restClient.assertStatusCodeIs(HttpStatus.OK); + + restClient.onResponse().assertThat().body("result-set", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("result-set.docs", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("result-set.docs[0].aliases", Matchers.nullValue()); + restClient.onResponse().assertThat().body("result-set.docs[0].isMetadata", Matchers.nullValue()); + restClient.onResponse().assertThat().body("result-set.docs[0].fields", Matchers.nullValue()); + } } \ No newline at end of file From 979a74e07f8c27abdb6ac9716fb8089a44428e35 Mon Sep 17 00:00:00 2001 From: Andrei Forascu Date: Fri, 18 May 2018 15:06:59 +0100 Subject: [PATCH 1356/1491] REPO-3294: 6.0: Module Compatibility Tests --- .../rest/discovery/DiscoveryTests.java | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/discovery/DiscoveryTests.java b/e2e-test/java/org/alfresco/rest/discovery/DiscoveryTests.java index 66b7329fc..4c0244e99 100644 --- a/e2e-test/java/org/alfresco/rest/discovery/DiscoveryTests.java +++ b/e2e-test/java/org/alfresco/rest/discovery/DiscoveryTests.java @@ -1,5 +1,11 @@ package org.alfresco.rest.discovery; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; + +import java.util.Collections; +import java.util.List; + import org.alfresco.rest.RestTest; import org.alfresco.rest.core.RestResponse; import org.alfresco.rest.model.RestDiscoveryModel; @@ -47,4 +53,30 @@ public class DiscoveryTests extends RestTest response.getRepository().getEdition().equals(edition); response.getRepository().getStatus().assertThat().field("isReadOnly").is(false); } + + @Test(groups = { TestGroup.REST_API, TestGroup.DISCOVERY, TestGroup.ALL_AMPS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.DISCOVERY }, executionType = ExecutionType.SANITY, + description = "Sanity tests for GET /discovery endpoint") + public void getRepositoryInstalledModules() throws Exception + { + // Get repository info using Discovery API + restClient.authenticateUser(userModel).withDiscoveryAPI().getRepositoryInfo(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + // Check that all modules are present + List modules = restClient.onResponse().getResponse().jsonPath().getList("entry.repository.modules.id", String.class); + assertTrue(modules.contains("alfresco-aos-module")); + assertTrue(modules.contains("org.alfresco.integrations.google.docs")); + assertTrue(modules.contains("org_alfresco_integrations_S3Connector")); + assertTrue(modules.contains("org_alfresco_module_xamconnector")); + assertTrue(modules.contains("org.alfresco.module.KofaxAddon")); + assertTrue(modules.contains("alfresco-content-connector-for-salesforce-repo")); + assertTrue(modules.contains("alfresco-share-services")); + assertTrue(modules.contains("alfresco-saml-repo")); + assertTrue(modules.contains("org_alfresco_device_sync_repo")); + + // Check that all installed modules are in INSTALLED state + List modulesStates = restClient.onResponse().getResponse().jsonPath().getList("entry.repository.modules.installState", String.class); + assertEquals(Collections.frequency(modulesStates, "INSTALLED"), 9); + } } From a108209f01db98770f8e9f5835569448f882287a Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Fri, 18 May 2018 17:16:14 +0100 Subject: [PATCH 1357/1491] Search 741 Implemented Tests for Parameters, Auth, Permissions and Errors --- .../rest/search/sql/SearchSQLAPITest.java | 275 +++++++++++++++++- 1 file changed, 265 insertions(+), 10 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLAPITest.java b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLAPITest.java index c680541e9..b18985de9 100644 --- a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLAPITest.java +++ b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLAPITest.java @@ -14,9 +14,12 @@ */ package org.alfresco.rest.search.sql; +import org.alfresco.rest.core.RestResponse; import org.alfresco.rest.search.AbstractSearchTest; import org.alfresco.rest.search.SearchSqlRequest; +import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; import org.springframework.http.HttpStatus; import org.testng.annotations.Test; import org.hamcrest.Matchers; @@ -267,15 +270,15 @@ public class SearchSQLAPITest extends AbstractSearchTest */ @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 04) public void testWithJsonIncludeMetadata() throws Exception - { + { SearchSqlRequest sqlRequest = new SearchSqlRequest(); sqlRequest.setSql(sql); sqlRequest.setFormat(""); sqlRequest.setLocales(locales); sqlRequest.setIncludeMetadata(true); - + searchSql(sqlRequest); - + restClient.assertStatusCodeIs(HttpStatus.OK); restClient.onResponse().assertThat().body("result-set", Matchers.nullValue()); @@ -283,17 +286,17 @@ public class SearchSQLAPITest extends AbstractSearchTest restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", Matchers.equalToIgnoringCase("aliases")); restClient.onResponse().assertThat().body("list.entries.entry[0][0].value", Matchers.equalToIgnoringCase("{\"SITE\":\"SITE\",\"cm_owner\":\"CM_OWNER\"}")); restClient.onResponse().assertThat().body("list.entries.entry[0][1].label", Matchers.equalToIgnoringCase("isMetadata")); - restClient.onResponse().assertThat().body("list.entries.entry[0][1].value", Matchers.is("true")); + restClient.onResponse().assertThat().body("list.entries.entry[0][1].value", Matchers.is("true")); restClient.onResponse().assertThat().body("list.entries.entry[0][2].label", Matchers.equalToIgnoringCase("fields")); restClient.onResponse().assertThat().body("list.entries.entry[0][2].value", Matchers.equalToIgnoringCase("[\"SITE\",\"cm_owner\"]")); } - + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 05) public void testIncludeMetadataFalse() throws Exception { SearchSqlRequest sqlRequest = new SearchSqlRequest(); sqlRequest.setSql(sql); - sqlRequest.setFormat("solr"); //Format solr + sqlRequest.setFormat("solr"); // Format solr sqlRequest.setIncludeMetadata(false); restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest); @@ -318,10 +321,9 @@ public class SearchSQLAPITest extends AbstractSearchTest restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", Matchers.notNullValue()); restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", Matchers.not("aliases")); - sqlRequest = new SearchSqlRequest(); sqlRequest.setSql(sql); - sqlRequest.setIncludeMetadata(false); //Format not set + sqlRequest.setIncludeMetadata(false); // Format not set restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -330,11 +332,11 @@ public class SearchSQLAPITest extends AbstractSearchTest restClient.onResponse().assertThat().body("list.entries", Matchers.notNullValue()); restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", Matchers.notNullValue()); restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", Matchers.not("aliases")); - + sqlRequest = new SearchSqlRequest(); sqlRequest.setSql(sql); sqlRequest.setFormat(solrFormat); // IncludeMetadata = false when not specified - + restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -344,4 +346,257 @@ public class SearchSQLAPITest extends AbstractSearchTest restClient.onResponse().assertThat().body("result-set.docs[0].isMetadata", Matchers.nullValue()); restClient.onResponse().assertThat().body("result-set.docs[0].fields", Matchers.nullValue()); } + + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 06) + public void testLocales() throws Exception + { + String[] noLocales = {}; // Not specified + + SearchSqlRequest sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql(sql); + sqlRequest.setLocales(noLocales); + + searchSql(sqlRequest); + + restClient.assertStatusCodeIs(HttpStatus.OK); + + String[] singleLocale = { "en-Uk" }; + + sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql(sql); + sqlRequest.setLocales(singleLocale); + + searchSql(sqlRequest); + + restClient.assertStatusCodeIs(HttpStatus.OK); + + String[] multipleLocales = { "en-US", "ja" }; + + sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql(sql); + sqlRequest.setLocales(multipleLocales); + + searchSql(sqlRequest); + + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 07) + public void testTimezone() throws Exception + { + String timezone = ""; // Not specified + + SearchSqlRequest sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql(sql); + sqlRequest.setTimezone(timezone); + + searchSql(sqlRequest); + + restClient.assertStatusCodeIs(HttpStatus.OK); + + timezone = "UTC"; // UTC + + sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql(sql); + sqlRequest.setTimezone(timezone); + + searchSql(sqlRequest); + + restClient.assertStatusCodeIs(HttpStatus.OK); + + timezone = "false"; // Invalid timezone is ignored + + sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql(sql); + sqlRequest.setTimezone(timezone); + + searchSql(sqlRequest); + + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 8) + public void testAggregateSQL() throws Exception + { + String agSql = "select count(*) FROM alfresco where TYPE='cm:content'"; + + SearchSqlRequest sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql(agSql); + + RestResponse response = searchSql(sqlRequest); + + restClient.assertStatusCodeIs(HttpStatus.OK); + response.assertThat().body("list.entries", Matchers.notNullValue()); + response.assertThat().body("list.entries.entry[0][0].value", Matchers.not("0")); + } + + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 9) + public void testLimit() throws Exception + { + Integer defaultLimit = 1000; + + Integer limit = null; // Limit defaults to the default setting when null + + SearchSqlRequest sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql(sql); + sqlRequest.setLimit(limit); + + RestResponse response = searchSql(sqlRequest); + + restClient.assertStatusCodeIs(HttpStatus.OK); + response.assertThat().body("list.pagination.maxItems", Matchers.equalTo(defaultLimit)); + + limit = 0; // Limit defaults to the default setting when 0 + sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql(sql); + sqlRequest.setLimit(limit); + + response = searchSql(sqlRequest); + + restClient.assertStatusCodeIs(HttpStatus.OK); + response.assertThat().body("list.pagination.maxItems", Matchers.equalTo(defaultLimit)); + + limit = 100; // Limit is applied correctly, with maxItems = limit + sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql(sql); + sqlRequest.setLimit(limit); + + response = searchSql(sqlRequest); + + restClient.assertStatusCodeIs(HttpStatus.OK); + response.assertThat().body("list.pagination.maxItems", Matchers.equalTo(limit)); + } + + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 10) + public void testAuthenticationError() throws Exception + { + UserModel dummyUser = dataUser.createRandomTestUser("UserSearchDummy"); + dummyUser.setPassword("incorrect-password"); + + SearchSqlRequest sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql(sql); + sqlRequest.setLocales(locales); + + restClient.authenticateUser(dummyUser).withSearchSqlAPI().searchSql(sqlRequest); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + } + + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 11) + public void testPermissions() throws Exception + { + UserModel userNoPerm = dataUser.createRandomTestUser("UserSearchNoPerm"); + UserModel userPerm = dataUser.createRandomTestUser("UserSearchPerm"); + + dataUser.addUserToSite(userPerm, siteModel, UserRole.SiteContributor); + + String siteSQL = "select SITE, CM_OWNER from alfresco where SITE='" + siteModel.getId() + "'"; + SearchSqlRequest sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql(siteSQL); + + // 0 results expected for query as User does not have access to the private site + restClient.authenticateUser(userNoPerm).withSearchSqlAPI().searchSql(sqlRequest); + restClient.assertStatusCodeIs(HttpStatus.OK); + + restClient.onResponse().assertThat().body("list.pagination.count", Matchers.is(0)); + restClient.onResponse().assertThat().body("list.pagination.totalItems", Matchers.is(0)); + restClient.onResponse().assertThat().body("list.pagination.hasMoreItems", Matchers.is(false)); + restClient.onResponse().assertThat().body("list.entries", Matchers.empty()); + + // Results expected for query as User does has access to the private site + restClient.authenticateUser(userPerm).withSearchSqlAPI().searchSql(sqlRequest); + restClient.assertStatusCodeIs(HttpStatus.OK); + + restClient.onResponse().assertThat().body("list.pagination.count", Matchers.greaterThan(0)); + restClient.onResponse().assertThat().body("list.pagination.totalItems", Matchers.greaterThan(0)); + restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", Matchers.equalToIgnoringCase("SITE")); + restClient.onResponse().assertThat().body("list.entries.entry[0][0].value", Matchers.equalToIgnoringCase("[\"" + siteModel.getId() + "\"]")); + } + + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 12) + public void testErrors() throws Exception + { + String incorrectSQL = ""; // Missing SQL + + SearchSqlRequest sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql(incorrectSQL); + + restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + restClient.onResponse().assertThat().body("error.briefSummary", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("error.briefSummary", Matchers.containsString("Required stmt parameter is missing")); + + incorrectSQL = "select SITE from unknownTable"; // Wrong table name + + sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql(incorrectSQL); + + restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + restClient.onResponse().assertThat().body("error.briefSummary", Matchers.notNullValue()); + // restClient.onResponse().assertThat().body("error.briefSummary", Matchers.containsString("Table 'unknownTable' not found")); + + incorrectSQL = "select Column1 from alfresco"; // Wrong ColumnName + + sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql(incorrectSQL); + + restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + restClient.onResponse().assertThat().body("error.briefSummary", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("error.briefSummary", Matchers.containsString("Column 'Column1' not found")); + + incorrectSQL = "select SITE alfresco"; // BAD SQL Grammar: from missing + + sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql(incorrectSQL); + + restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + restClient.onResponse().assertThat().body("error.briefSummary", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("error.briefSummary", Matchers.containsString("Unable to execute the query")); + + incorrectSQL = "select SITE, CM_OWNER from alfresco group by SITE"; // BAD SQL Grammar: CM_OWNER is not being grouped + + sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql(incorrectSQL); + + restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + restClient.onResponse().assertThat().body("error.briefSummary", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("error.briefSummary", Matchers.containsString("Expression 'CM_OWNER' is not being grouped")); + + incorrectSQL = "delete SITE from alfresco"; // BAD SQL Grammar + + sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql(incorrectSQL); + + restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + restClient.onResponse().assertThat().body("error.briefSummary", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("error.briefSummary", Matchers.containsString("Was expecting one of")); + } + + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API }, priority = 13) + public void testErrorForSQLAPIWithASS() throws Exception + { + String acsVersion = serverHealth.getAlfrescoVersion(); + HttpStatus expectedStatus = HttpStatus.OK; + + SearchSqlRequest sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql(sql); + sqlRequest.setLocales(locales); + + // Set expected result based on ACS Version and ASS Version + if (!acsVersion.startsWith("6")) + { + expectedStatus = HttpStatus.NOT_FOUND; + } + else + { + expectedStatus = HttpStatus.BAD_REQUEST; + } + + restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest); + restClient.assertStatusCodeIs(expectedStatus); + } } \ No newline at end of file From bbffd3293f88addad1b8c6675a2f2853ecf132e4 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 22 May 2018 11:14:50 +0100 Subject: [PATCH 1358/1491] Search-752, fix after method npe --- .../alfresco/rest/search/sql/SearchSQLTest.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLTest.java b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLTest.java index d25412594..8340373eb 100644 --- a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLTest.java +++ b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLTest.java @@ -20,7 +20,6 @@ package org.alfresco.rest.search.sql; import static org.junit.Assert.assertNotNull; import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotEquals; import static org.testng.Assert.assertTrue; import java.sql.Connection; @@ -122,9 +121,18 @@ public class SearchSQLTest extends AbstractSearchTest sites = null; try { - rs.close(); - stmt.close(); - con.close(); + if(rs != null) + { + rs.close(); + } + if(stmt != null) + { + stmt.close(); + } + if(con != null) + { + con.close(); + } } catch (SQLException e) { From 07994d09add8aeb2c3b377bb54b58d3938e5b01b Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 22 May 2018 11:36:20 +0100 Subject: [PATCH 1359/1491] Search-752, updated to use correct jdbc setup --- .../java/org/alfresco/rest/search/sql/SearchSQLTest.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLTest.java b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLTest.java index 8340373eb..e2b15b85a 100644 --- a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLTest.java +++ b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLTest.java @@ -58,11 +58,13 @@ public class SearchSQLTest extends AbstractSearchTest private Statement stmt; private ResultSet rs; List sites; + @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception { - - connectionString = properties.getFullServerUrl() + "/alfresco/api/-default-/public/search/versions/1/sql"; + connectionString = String.format("jdbc:alfresco://%s:%s?collection=alfresco", + properties.getServer(), + properties.getPort()); //Prepare users, one with full access and one with limited access. adminUser = dataUser.getAdminUser(); userModel = dataUser.createRandomTestUser("UserSearch"); From 125ae5fbc946fd68df632f84b4c94aed48623bc0 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 23 May 2018 17:42:37 +0100 Subject: [PATCH 1360/1491] Search-752, resolved library dependency issue --- e2e-test/java/org/alfresco/rest/search/sql/SearchSQLTest.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLTest.java b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLTest.java index e2b15b85a..7bb10615d 100644 --- a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLTest.java +++ b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLTest.java @@ -117,6 +117,8 @@ public class SearchSQLTest extends AbstractSearchTest rs = executeSql(userModel.getUsername(), userModel.getPassword(), sql); assertFalse(rs.next()); } + + @AfterMethod public void close() { From 2a2b49dab58ed1d8eca3f53da7487cf5f66afda0 Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Fri, 25 May 2018 12:19:37 +0100 Subject: [PATCH 1361/1491] Search-752 Test for error added, format updated to be consistent with other rest api tests --- .../rest/search/sql/SearchSQLTest.java | 164 ------------------ .../rest/search/sql/SearchSQLViaJDBCTest.java | 153 ++++++++++++++++ 2 files changed, 153 insertions(+), 164 deletions(-) delete mode 100644 e2e-test/java/org/alfresco/rest/search/sql/SearchSQLTest.java create mode 100644 e2e-test/java/org/alfresco/rest/search/sql/SearchSQLViaJDBCTest.java diff --git a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLTest.java b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLTest.java deleted file mode 100644 index 7bb10615d..000000000 --- a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLTest.java +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Copyright (C) 2017 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.rest.search.sql; - -import static org.junit.Assert.assertNotNull; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertTrue; - -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; -import java.util.ArrayList; -import java.util.List; -import java.util.Properties; - -import org.alfresco.dataprep.SiteService.Visibility; -import org.alfresco.rest.search.AbstractSearchTest; -import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -/** - * Search SQL end point Public API test. - * @author Michael Suzuki - * - */ -public class SearchSQLTest extends AbstractSearchTest -{ - UserModel userModel, adminUser, managerUser; - SiteModel siteModel; - FileModel document; - String connectionString; - private Connection con; - private Statement stmt; - private ResultSet rs; - List sites; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - connectionString = String.format("jdbc:alfresco://%s:%s?collection=alfresco", - properties.getServer(), - properties.getPort()); - //Prepare users, one with full access and one with limited access. - adminUser = dataUser.getAdminUser(); - userModel = dataUser.createRandomTestUser("UserSearch"); - managerUser = dataUser.createRandomTestUser("UserSearch"); - //Create a private site - siteModel = new SiteModel(RandomData.getRandomName("SiteSearch")); - siteModel.setVisibility(Visibility.PRIVATE); - siteModel = dataSite.usingUser(managerUser).createSite(siteModel); - //Allow tracker to index. - } - - @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10}) - public void queryPublicSiteWithSimpleUser() throws SQLException - { - String sql = "select SITE,CM_OWNER from alfresco group by SITE,CM_OWNER"; - rs = executeSql(userModel.getUsername(), userModel.getPassword(), sql); - while (rs.next()) - { - assertNotNull(rs.getString("SITE")); - //Check for the private site which was created - assertNotNull(rs.getString("CM_OWNER")); - } - } - @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10}) - public void queryMyCreatedPrivateSite() throws SQLException - { - String sql = "select SITE from alfresco where SITE ='" + siteModel.getTitle() + "'"; - rs = executeSql(managerUser.getUsername(), managerUser.getPassword(), sql); - while (rs.next()) - { - assertNotNull(rs.getString("SITE")); - assertTrue(siteModel.getTitle().equalsIgnoreCase(rs.getString("SITE"))); - } - } - @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10}) - public void queryPrivateSiteWithSuperUser() throws SQLException - { - String sql = "select SITE from alfresco where SITE ='" + siteModel.getTitle() + "'"; - rs = executeSql(adminUser.getUsername(), adminUser.getPassword(), sql); - while (rs.next()) - { - assertNotNull(rs.getString("SITE")); - assertTrue(siteModel.getTitle().equalsIgnoreCase(rs.getString("SITE"))); - } - } - @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10}) - public void queryPrivateSiteWithSimpleUser() throws SQLException - { - String sql = "select SITE from alfresco where SITE = '" + siteModel.getTitle() +"'"; - rs = executeSql(userModel.getUsername(), userModel.getPassword(), sql); - assertFalse(rs.next()); - } - - - @AfterMethod - public void close() - { - sites = null; - try - { - if(rs != null) - { - rs.close(); - } - if(stmt != null) - { - stmt.close(); - } - if(con != null) - { - con.close(); - } - } - catch (SQLException e) - { - // TODO: handle exception - } - } - @BeforeMethod - public void prep() - { - sites = new ArrayList(); - } - private Connection getConnection(String username, String password) throws SQLException - { - Properties props = new Properties(); - props.put("user", username); - props.put("password", password); - return DriverManager.getConnection(connectionString, props); - } - private ResultSet executeSql(String username, String password, String sql) throws SQLException - { - con = getConnection(username, password); - stmt = con.createStatement(); - return stmt.executeQuery(sql); - } -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLViaJDBCTest.java b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLViaJDBCTest.java new file mode 100644 index 000000000..65e31e15e --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLViaJDBCTest.java @@ -0,0 +1,153 @@ +/* + * Copyright (C) 2018 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.rest.search.sql; + +import static org.testng.Assert.*; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; + +import org.alfresco.dataprep.SiteService.Visibility; +import org.alfresco.rest.requests.search.SearchSQLJDBC; +import org.alfresco.rest.search.AbstractSearchTest; +import org.alfresco.rest.search.SearchSqlJDBCRequest; +import org.alfresco.utility.data.RandomData; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.junit.Assert; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.Test; + +/** + * Search SQL end point test via JDBC. + * @author MSuzuki + * @author Meenal Bhave + * + */ +public class SearchSQLViaJDBCTest extends AbstractSearchTest +{ + List sites = new ArrayList(); + SearchSQLJDBC searchSql; + SearchSqlJDBCRequest sqlRequest = new SearchSqlJDBCRequest(); + + @AfterMethod + public void cleanUp() throws SQLException + { + restClient.withSearchSqlViaJDBC().clearSearchQuery(sqlRequest); + sqlRequest = new SearchSqlJDBCRequest(); + sites = new ArrayList(); + } + + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority=01) + public void testQueryPublicSite() throws SQLException + { + + SiteModel publicSite = new SiteModel(RandomData.getRandomName("SiteSearch")); + publicSite.setVisibility(Visibility.PUBLIC); + + publicSite = dataSite.usingUser(adminUserModel).createSite(publicSite); + + String sql = "select SITE,CM_OWNER from alfresco where SITE ='" + publicSite.getTitle() + "' group by SITE,CM_OWNER"; + sqlRequest.setSql(sql); + sqlRequest.setAuthUser(userModel); + + ResultSet rs = restClient.withSearchSqlViaJDBC().executeQueryViaJDBC(sqlRequest); + + while (rs.next()) + { + // User can see the Public Site created by other user + Assert.assertNotNull(rs.getString("SITE")); + assertTrue(publicSite.getTitle().equalsIgnoreCase(rs.getString("SITE"))); + + Assert.assertNotNull(rs.getString("CM_OWNER")); + Assert.assertTrue(rs.getString("CM_OWNER").contains(adminUserModel.getUsername())); + } + } + + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority=02) + public void testQueryMyCreatedPrivateSite() throws SQLException + { + String sql = "select distinct SITE from alfresco where SITE ='" + siteModel.getTitle() + "'"; + sqlRequest.setSql(sql); + sqlRequest.setAuthUser(userModel); + + ResultSet rs = restClient.withSearchSqlViaJDBC().executeQueryViaJDBC(sqlRequest); + + while (rs.next()) + { + // User can see Own Private Site + Assert.assertNotNull(rs.getString("SITE")); + Assert.assertTrue(siteModel.getTitle().equalsIgnoreCase(rs.getString("SITE"))); + } + } + + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority=03) + public void testQueryPrivateSiteWithSuperUser() throws SQLException + { + String sql = "select distinct SITE from alfresco where SITE ='" + siteModel.getTitle() + "'"; + sqlRequest.setSql(sql); + sqlRequest.setAuthUser(adminUserModel); + + ResultSet rs = restClient.withSearchSqlViaJDBC().executeQueryViaJDBC(sqlRequest); + + while (rs.next()) + { + // Super user can see Private Site created by other user + Assert.assertNotNull(rs.getString("SITE")); + Assert.assertTrue(siteModel.getTitle().equalsIgnoreCase(rs.getString("SITE"))); + } + } + + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority=04) + public void testQueryPrivateSiteWithSimpleUser() throws SQLException + { + UserModel managerUser = dataUser.createRandomTestUser("UserSearchMgr"); + + String sql = "select SITE from alfresco where SITE = '" + siteModel.getTitle() + "'"; + sqlRequest.setSql(sql); + sqlRequest.setAuthUser(managerUser); + + // Non admin user can NOT see Private Site created by other user + ResultSet rs = restClient.withSearchSqlViaJDBC().executeQueryViaJDBC(sqlRequest); + Assert.assertFalse(rs.next()); + } + + + + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority=05) + public void testQueryErrorReturned() throws SQLException + { + String expectedError = "Column 'SITE1' not found"; + + String sql = "select SITE1 from alfresco"; + sqlRequest.setSql(sql); + sqlRequest.setAuthUser(userModel); + + // Appropriate error is retrieved when SQL is incorrect + ResultSet rs = restClient.withSearchSqlViaJDBC().executeQueryViaJDBC(sqlRequest); + assertNull(rs); + + String error = sqlRequest.getErrorDetails(); + Assert.assertNotNull(error); + Assert.assertTrue("Error shown: " + error + " Error expected: " + expectedError, error.contains(expectedError)); + } +} \ No newline at end of file From 5534ed5f21a0ce51d015605bf38bef90033556c9 Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Fri, 25 May 2018 12:21:35 +0100 Subject: [PATCH 1362/1491] Search-846 Test annotated with a non for insight engine test group, pom updated with new version of tas-utility --- .../java/org/alfresco/rest/search/sql/SearchSQLAPITest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLAPITest.java b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLAPITest.java index b18985de9..ef6e9fe51 100644 --- a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLAPITest.java +++ b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLAPITest.java @@ -576,7 +576,7 @@ public class SearchSQLAPITest extends AbstractSearchTest restClient.onResponse().assertThat().body("error.briefSummary", Matchers.containsString("Was expecting one of")); } - @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API }, priority = 13) + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.NOT_INSIGHT_ENGINE }, priority = 13) public void testErrorForSQLAPIWithASS() throws Exception { String acsVersion = serverHealth.getAlfrescoVersion(); From 69e8972fb755c2d8783e1bf736f7ba2d145159a6 Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Fri, 25 May 2018 16:32:54 +0100 Subject: [PATCH 1363/1491] Search-752 Implemented formatting correction and removed * imports --- .../alfresco/rest/search/sql/SearchSQLViaJDBCTest.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLViaJDBCTest.java b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLViaJDBCTest.java index 65e31e15e..46d34ed2f 100644 --- a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLViaJDBCTest.java +++ b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLViaJDBCTest.java @@ -18,8 +18,6 @@ */ package org.alfresco.rest.search.sql; -import static org.testng.Assert.*; - import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; @@ -33,9 +31,9 @@ import org.alfresco.utility.data.RandomData; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; -import org.junit.Assert; import org.testng.annotations.AfterMethod; import org.testng.annotations.Test; +import org.testng.Assert; /** * Search SQL end point test via JDBC. @@ -76,7 +74,7 @@ public class SearchSQLViaJDBCTest extends AbstractSearchTest { // User can see the Public Site created by other user Assert.assertNotNull(rs.getString("SITE")); - assertTrue(publicSite.getTitle().equalsIgnoreCase(rs.getString("SITE"))); + Assert.assertTrue(publicSite.getTitle().equalsIgnoreCase(rs.getString("SITE"))); Assert.assertNotNull(rs.getString("CM_OWNER")); Assert.assertTrue(rs.getString("CM_OWNER").contains(adminUserModel.getUsername())); @@ -144,10 +142,10 @@ public class SearchSQLViaJDBCTest extends AbstractSearchTest // Appropriate error is retrieved when SQL is incorrect ResultSet rs = restClient.withSearchSqlViaJDBC().executeQueryViaJDBC(sqlRequest); - assertNull(rs); + Assert.assertNull(rs); String error = sqlRequest.getErrorDetails(); Assert.assertNotNull(error); - Assert.assertTrue("Error shown: " + error + " Error expected: " + expectedError, error.contains(expectedError)); + Assert.assertTrue(error.contains(expectedError), "Error shown: " + error + " Error expected: " + expectedError); } } \ No newline at end of file From 8ebf922323491607cade28fa75128c4ac759e8a7 Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Fri, 1 Jun 2018 12:30:48 +0100 Subject: [PATCH 1364/1491] Search-876: Added after method to run always --- .../java/org/alfresco/rest/search/sql/SearchSQLViaJDBCTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLViaJDBCTest.java b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLViaJDBCTest.java index 46d34ed2f..2a4fa1cfd 100644 --- a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLViaJDBCTest.java +++ b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLViaJDBCTest.java @@ -47,7 +47,7 @@ public class SearchSQLViaJDBCTest extends AbstractSearchTest SearchSQLJDBC searchSql; SearchSqlJDBCRequest sqlRequest = new SearchSqlJDBCRequest(); - @AfterMethod + @AfterMethod(alwaysRun=true) public void cleanUp() throws SQLException { restClient.withSearchSqlViaJDBC().clearSearchQuery(sqlRequest); From 9687ae2ffb99f1be90bdff6966d0256b7e190a3d Mon Sep 17 00:00:00 2001 From: Andrei Forascu Date: Mon, 4 Jun 2018 18:40:03 +0300 Subject: [PATCH 1365/1491] REPO-3294: added media management to checklist --- e2e-test/java/org/alfresco/rest/discovery/DiscoveryTests.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/discovery/DiscoveryTests.java b/e2e-test/java/org/alfresco/rest/discovery/DiscoveryTests.java index 4c0244e99..2328c3182 100644 --- a/e2e-test/java/org/alfresco/rest/discovery/DiscoveryTests.java +++ b/e2e-test/java/org/alfresco/rest/discovery/DiscoveryTests.java @@ -74,9 +74,10 @@ public class DiscoveryTests extends RestTest assertTrue(modules.contains("alfresco-share-services")); assertTrue(modules.contains("alfresco-saml-repo")); assertTrue(modules.contains("org_alfresco_device_sync_repo")); + assertTrue(modules.contains("org_alfresco_mm_repo")); // Check that all installed modules are in INSTALLED state List modulesStates = restClient.onResponse().getResponse().jsonPath().getList("entry.repository.modules.installState", String.class); - assertEquals(Collections.frequency(modulesStates, "INSTALLED"), 9); + assertEquals(Collections.frequency(modulesStates, "INSTALLED"), 10); } } From 0bd10dc033b624a50b544d121c31ef18b6d41a87 Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Tue, 5 Jun 2018 10:04:30 +0100 Subject: [PATCH 1366/1491] Search-876: Moved Error checking assert before recordset --- .../org/alfresco/rest/search/sql/SearchSQLViaJDBCTest.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLViaJDBCTest.java b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLViaJDBCTest.java index 2a4fa1cfd..a53b347fa 100644 --- a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLViaJDBCTest.java +++ b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLViaJDBCTest.java @@ -142,10 +142,12 @@ public class SearchSQLViaJDBCTest extends AbstractSearchTest // Appropriate error is retrieved when SQL is incorrect ResultSet rs = restClient.withSearchSqlViaJDBC().executeQueryViaJDBC(sqlRequest); - Assert.assertNull(rs); String error = sqlRequest.getErrorDetails(); Assert.assertNotNull(error); Assert.assertTrue(error.contains(expectedError), "Error shown: " + error + " Error expected: " + expectedError); + + // Record set is null + Assert.assertNull(rs); } } \ No newline at end of file From 99d8b945c069cf4978f817f679358d3a6f8137e5 Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Tue, 5 Jun 2018 10:06:53 +0100 Subject: [PATCH 1367/1491] Search-876 After method to run always --- .../org/alfresco/rest/search/sql/SearchSQLViaJDBCTest.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLViaJDBCTest.java b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLViaJDBCTest.java index 46d34ed2f..a53b347fa 100644 --- a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLViaJDBCTest.java +++ b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLViaJDBCTest.java @@ -47,7 +47,7 @@ public class SearchSQLViaJDBCTest extends AbstractSearchTest SearchSQLJDBC searchSql; SearchSqlJDBCRequest sqlRequest = new SearchSqlJDBCRequest(); - @AfterMethod + @AfterMethod(alwaysRun=true) public void cleanUp() throws SQLException { restClient.withSearchSqlViaJDBC().clearSearchQuery(sqlRequest); @@ -142,10 +142,12 @@ public class SearchSQLViaJDBCTest extends AbstractSearchTest // Appropriate error is retrieved when SQL is incorrect ResultSet rs = restClient.withSearchSqlViaJDBC().executeQueryViaJDBC(sqlRequest); - Assert.assertNull(rs); String error = sqlRequest.getErrorDetails(); Assert.assertNotNull(error); Assert.assertTrue(error.contains(expectedError), "Error shown: " + error + " Error expected: " + expectedError); + + // Record set is null + Assert.assertNull(rs); } } \ No newline at end of file From 3630f3632638afa17b4c15f15a8d59e22cf524e8 Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Tue, 5 Jun 2018 10:07:23 +0100 Subject: [PATCH 1368/1491] Search-634 Tests implemented for select star via sql api and jdbc --- .../rest/search/sql/SearchSQLAPITest.java | 27 +++++++++++++ .../rest/search/sql/SearchSQLViaJDBCTest.java | 40 +++++++++++++++++++ 2 files changed, 67 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLAPITest.java b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLAPITest.java index ef6e9fe51..8f1b2037a 100644 --- a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLAPITest.java +++ b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLAPITest.java @@ -599,4 +599,31 @@ public class SearchSQLAPITest extends AbstractSearchTest restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest); restClient.assertStatusCodeIs(expectedStatus); } + + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 14) + public void testSelectStar() throws Exception + { + // Select * with Limit, json format + SearchSqlRequest sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql("select * from alfresco"); + sqlRequest.setLimit(1); + + RestResponse response = searchSql(sqlRequest); + + restClient.assertStatusCodeIs(HttpStatus.OK); + response.assertThat().body("list.pagination.maxItems", Matchers.equalTo(1)); + restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", Matchers.equalToIgnoringCase("PATH")); + + // Select * with Limit, solr format: Also covered in JDBC + sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql("select * from alfresco"); + sqlRequest.setFormat("solr"); + sqlRequest.setIncludeMetadata(true); + sqlRequest.setLimit(1); + + response = searchSql(sqlRequest); + + restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.onResponse().assertThat().body("result-set.docs[0].aliases.PATH", Matchers.notNullValue()); + } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLViaJDBCTest.java b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLViaJDBCTest.java index a53b347fa..25a1f01ca 100644 --- a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLViaJDBCTest.java +++ b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLViaJDBCTest.java @@ -150,4 +150,44 @@ public class SearchSQLViaJDBCTest extends AbstractSearchTest // Record set is null Assert.assertNull(rs); } + + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 06) + public void testQuerySelectStar() throws SQLException + { + // Select * query with limit clause + String sql = "select * from alfresco limit 5"; + sqlRequest.setSql(sql); + sqlRequest.setAuthUser(userModel); + + // Select * with limit clause works: No error is retrieved + ResultSet rs = restClient.withSearchSqlViaJDBC().executeQueryViaJDBC(sqlRequest); + Assert.assertNotNull(rs); + Assert.assertNull(sqlRequest.getErrorDetails()); + + while (rs.next()) + { + // Field values are retrieved + Assert.assertNotNull(rs.getString("PATH")); + Assert.assertNotNull(rs.getString("DBID")); + Assert.assertNotNull(rs.getString("cm_name")); + } + + // Select * query Without limit clause: No error is retrieved + sql = "select * from alfresco"; + sqlRequest.setSql(sql); + sqlRequest.setAuthUser(userModel); + + // No error is retrieved when SQL is incorrect + rs = restClient.withSearchSqlViaJDBC().executeQueryViaJDBC(sqlRequest); + Assert.assertNotNull(rs); + Assert.assertNull(sqlRequest.getErrorDetails()); + + while (rs.next()) + { + // Field values are retrieved + Assert.assertNotNull(rs.getString("PATH")); + Assert.assertNotNull(rs.getString("DBID")); + Assert.assertNotNull(rs.getString("cm_name")); + } + } } \ No newline at end of file From 337384b117ac92fc532e910d1d3320191f1dad8e Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Tue, 5 Jun 2018 10:07:23 +0100 Subject: [PATCH 1369/1491] Search-634 Tests implemented for select star via sql api and jdbc (cherry picked from commit 7f3e7ad1aaea2f47934f7c8aef91b7e356a26a25) --- .../rest/search/sql/SearchSQLAPITest.java | 27 +++++++++++++ .../rest/search/sql/SearchSQLViaJDBCTest.java | 40 +++++++++++++++++++ 2 files changed, 67 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLAPITest.java b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLAPITest.java index ef6e9fe51..8f1b2037a 100644 --- a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLAPITest.java +++ b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLAPITest.java @@ -599,4 +599,31 @@ public class SearchSQLAPITest extends AbstractSearchTest restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest); restClient.assertStatusCodeIs(expectedStatus); } + + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 14) + public void testSelectStar() throws Exception + { + // Select * with Limit, json format + SearchSqlRequest sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql("select * from alfresco"); + sqlRequest.setLimit(1); + + RestResponse response = searchSql(sqlRequest); + + restClient.assertStatusCodeIs(HttpStatus.OK); + response.assertThat().body("list.pagination.maxItems", Matchers.equalTo(1)); + restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", Matchers.equalToIgnoringCase("PATH")); + + // Select * with Limit, solr format: Also covered in JDBC + sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql("select * from alfresco"); + sqlRequest.setFormat("solr"); + sqlRequest.setIncludeMetadata(true); + sqlRequest.setLimit(1); + + response = searchSql(sqlRequest); + + restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.onResponse().assertThat().body("result-set.docs[0].aliases.PATH", Matchers.notNullValue()); + } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLViaJDBCTest.java b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLViaJDBCTest.java index a53b347fa..25a1f01ca 100644 --- a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLViaJDBCTest.java +++ b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLViaJDBCTest.java @@ -150,4 +150,44 @@ public class SearchSQLViaJDBCTest extends AbstractSearchTest // Record set is null Assert.assertNull(rs); } + + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 06) + public void testQuerySelectStar() throws SQLException + { + // Select * query with limit clause + String sql = "select * from alfresco limit 5"; + sqlRequest.setSql(sql); + sqlRequest.setAuthUser(userModel); + + // Select * with limit clause works: No error is retrieved + ResultSet rs = restClient.withSearchSqlViaJDBC().executeQueryViaJDBC(sqlRequest); + Assert.assertNotNull(rs); + Assert.assertNull(sqlRequest.getErrorDetails()); + + while (rs.next()) + { + // Field values are retrieved + Assert.assertNotNull(rs.getString("PATH")); + Assert.assertNotNull(rs.getString("DBID")); + Assert.assertNotNull(rs.getString("cm_name")); + } + + // Select * query Without limit clause: No error is retrieved + sql = "select * from alfresco"; + sqlRequest.setSql(sql); + sqlRequest.setAuthUser(userModel); + + // No error is retrieved when SQL is incorrect + rs = restClient.withSearchSqlViaJDBC().executeQueryViaJDBC(sqlRequest); + Assert.assertNotNull(rs); + Assert.assertNull(sqlRequest.getErrorDetails()); + + while (rs.next()) + { + // Field values are retrieved + Assert.assertNotNull(rs.getString("PATH")); + Assert.assertNotNull(rs.getString("DBID")); + Assert.assertNotNull(rs.getString("cm_name")); + } + } } \ No newline at end of file From ee75aacad0405e00b721d5b9614476f5740e24b4 Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Mon, 18 Jun 2018 17:47:21 +0100 Subject: [PATCH 1370/1491] Search-904 Test added for select distinct --- .../rest/search/sql/SearchSQLAPITest.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLAPITest.java b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLAPITest.java index 8f1b2037a..c251a9892 100644 --- a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLAPITest.java +++ b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLAPITest.java @@ -626,4 +626,29 @@ public class SearchSQLAPITest extends AbstractSearchTest restClient.assertStatusCodeIs(HttpStatus.OK); restClient.onResponse().assertThat().body("result-set.docs[0].aliases.PATH", Matchers.notNullValue()); } + + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 15) + public void testDistinct() throws Exception + { + // Select distinct site: json format + SearchSqlRequest sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql("select distinct Site from alfresco"); + sqlRequest.setLimit(10); + + RestResponse response = searchSql(sqlRequest); + + restClient.assertStatusCodeIs(HttpStatus.OK); + response.assertThat().body("list.pagination.maxItems", Matchers.equalTo(10)); + restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", Matchers.equalToIgnoringCase("site")); + + // Select distinct cm_name: solr format + sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql("select distinct cm_name from alfresco limit 5"); + sqlRequest.setFormat("solr"); + + response = searchSql(sqlRequest); + + restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.onResponse().assertThat().body("result-set.docs[0].cm_name", Matchers.notNullValue()); + } } \ No newline at end of file From 1aacc28dd86aa9707d6e36712c8acc702e11b71b Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Mon, 25 Jun 2018 11:27:34 +0100 Subject: [PATCH 1371/1491] Search-904 Test added for select distinct via JDBC --- .../rest/search/sql/SearchSQLViaJDBCTest.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLViaJDBCTest.java b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLViaJDBCTest.java index 25a1f01ca..eed0bb445 100644 --- a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLViaJDBCTest.java +++ b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLViaJDBCTest.java @@ -190,4 +190,24 @@ public class SearchSQLViaJDBCTest extends AbstractSearchTest Assert.assertNotNull(rs.getString("cm_name")); } } + + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 07) + public void testQuerySelectDistinct() throws SQLException + { + // Select distinct query with limit clause + String sql = "select distinct cm_name from alfresco limit 5"; + sqlRequest.setSql(sql); + sqlRequest.setAuthUser(adminUserModel); + + // Select distinct with limit clause works: No error is retrieved + ResultSet rs = restClient.withSearchSqlViaJDBC().executeQueryViaJDBC(sqlRequest); + Assert.assertNotNull(rs); + Assert.assertNull(sqlRequest.getErrorDetails()); + + while (rs.next()) + { + // Field values are retrieved + Assert.assertNotNull(rs.getString("cm_name")); + } + } } \ No newline at end of file From f1753e86e8f5d1548018191af5da4b9f5490e61b Mon Sep 17 00:00:00 2001 From: Alexandru Epure Date: Tue, 26 Jun 2018 21:28:59 +0300 Subject: [PATCH 1372/1491] REPO-3518 : Check AMPs are included in repository image Add DiscoveryTests#getDefaultRepositoryInstalledModules in order to verify that reference deployment (docker images) contain AOS, Share-services and google-docs AMPs Exclude core testgroup from restapi-acs-all-amps-suite.xml because DiscoveryTests#getDefaultRepositoryInstalledModules conflicts with DiscoveryTests#getRepositoryInstalledModules as they are ment to test different enviroments. --- .../rest/discovery/DiscoveryTests.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/discovery/DiscoveryTests.java b/e2e-test/java/org/alfresco/rest/discovery/DiscoveryTests.java index 2328c3182..bb87dcec4 100644 --- a/e2e-test/java/org/alfresco/rest/discovery/DiscoveryTests.java +++ b/e2e-test/java/org/alfresco/rest/discovery/DiscoveryTests.java @@ -80,4 +80,24 @@ public class DiscoveryTests extends RestTest List modulesStates = restClient.onResponse().getResponse().jsonPath().getList("entry.repository.modules.installState", String.class); assertEquals(Collections.frequency(modulesStates, "INSTALLED"), 10); } + + @Test(groups = { TestGroup.REST_API, TestGroup.DISCOVERY, TestGroup.SANITY, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.DISCOVERY }, executionType = ExecutionType.SANITY, + description = "Sanity tests for GET /discovery endpoint") + public void getDefaultRepositoryInstalledModules() throws Exception + { + // Get repository info using Discovery API + restClient.authenticateUser(userModel).withDiscoveryAPI().getRepositoryInfo(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + // Check that all modules are present + List modules = restClient.onResponse().getResponse().jsonPath().getList("entry.repository.modules.id", String.class); + assertTrue(modules.contains("alfresco-aos-module")); + assertTrue(modules.contains("org.alfresco.integrations.google.docs")); + assertTrue(modules.contains("alfresco-share-services")); + + // Check that all installed modules are in INSTALLED state + List modulesStates = restClient.onResponse().getResponse().jsonPath().getList("entry.repository.modules.installState", String.class); + assertEquals(Collections.frequency(modulesStates, "INSTALLED"), 3); + } } From b3b6dcbd8b1ab24587622cc0608865357f7e6645 Mon Sep 17 00:00:00 2001 From: Andrei Forascu Date: Mon, 2 Jul 2018 17:27:21 +0300 Subject: [PATCH 1373/1491] REPO-3590: updated all-amps tests to include Document Transformation Server amp --- e2e-test/java/org/alfresco/rest/discovery/DiscoveryTests.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/discovery/DiscoveryTests.java b/e2e-test/java/org/alfresco/rest/discovery/DiscoveryTests.java index bb87dcec4..b6a1911c0 100644 --- a/e2e-test/java/org/alfresco/rest/discovery/DiscoveryTests.java +++ b/e2e-test/java/org/alfresco/rest/discovery/DiscoveryTests.java @@ -75,10 +75,11 @@ public class DiscoveryTests extends RestTest assertTrue(modules.contains("alfresco-saml-repo")); assertTrue(modules.contains("org_alfresco_device_sync_repo")); assertTrue(modules.contains("org_alfresco_mm_repo")); + assertTrue(modules.contains("org.alfresco.module.TransformationServer")); // Check that all installed modules are in INSTALLED state List modulesStates = restClient.onResponse().getResponse().jsonPath().getList("entry.repository.modules.installState", String.class); - assertEquals(Collections.frequency(modulesStates, "INSTALLED"), 10); + assertEquals(Collections.frequency(modulesStates, "INSTALLED"), 11); } @Test(groups = { TestGroup.REST_API, TestGroup.DISCOVERY, TestGroup.SANITY, TestGroup.CORE }) From fba3dd84a42dbfef0ac38cd72a23537204278db3 Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Mon, 2 Jul 2018 16:56:47 +0100 Subject: [PATCH 1374/1491] Search-940 Tests implemented for Phrase Searching (Search-852) via search /sql api and JDBC --- .../rest/search/sql/SearchSQLPhraseTest.java | 242 ++++++++++++++++++ 1 file changed, 242 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/search/sql/SearchSQLPhraseTest.java diff --git a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLPhraseTest.java b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLPhraseTest.java new file mode 100644 index 000000000..7d49d152e --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLPhraseTest.java @@ -0,0 +1,242 @@ +/* + * Copyright (C) 2018 Alfresco Software Limited. + * This file is part of Alfresco + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.rest.search.sql; + +import java.sql.ResultSet; + +import org.alfresco.rest.core.RestResponse; +import org.alfresco.rest.search.AbstractSearchTest; +import org.alfresco.rest.search.SearchSqlJDBCRequest; +import org.alfresco.rest.search.SearchSqlRequest; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FileType; +import org.alfresco.utility.model.TestGroup; +import org.springframework.http.HttpStatus; +import org.testng.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; +import org.hamcrest.Matchers; + +/** + * Tests for /sql end point Search API. + * + * @author Meenal Bhave + */ +public class SearchSQLPhraseTest extends AbstractSearchTest +{ + FileModel fileBanana, fileYellowBanana, fileBigYellowBanana, fileBigBananaBoat, fileYellowBananaBigBoat, fileBigYellowBoat; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + super.dataPreparation(); + + // Create files with different phrases + fileBanana = new FileModel(unique_searchString + "-1.txt", "phrase searching", "", FileType.TEXT_PLAIN, "banana"); + dataContent.usingUser(userModel).usingSite(siteModel).createContent(fileBanana); + + fileYellowBanana = new FileModel(unique_searchString + "-2.txt", "phrase searching", "", FileType.TEXT_PLAIN, "yellow banana"); + dataContent.usingUser(userModel).usingSite(siteModel).createContent(fileYellowBanana); + + fileBigYellowBanana = new FileModel(unique_searchString + "-3.txt", "phrase searching", "", FileType.TEXT_PLAIN, "big yellow banana"); + dataContent.usingUser(userModel).usingSite(siteModel).createContent(fileBigYellowBanana); + + fileBigBananaBoat = new FileModel(unique_searchString + "-4.txt", "", "phrase searching", FileType.TEXT_PLAIN, "big boat"); + dataContent.usingUser(userModel).usingSite(siteModel).createContent(fileBigBananaBoat); + + fileYellowBananaBigBoat = new FileModel(unique_searchString + "-5.txt", "", "phrase searching", FileType.TEXT_PLAIN, "yellow banana big boat"); + dataContent.usingUser(userModel).usingSite(siteModel).createContent(fileYellowBananaBigBoat); + + fileBigYellowBoat = new FileModel(unique_searchString + "-6.txt", "", "phrase searching", FileType.TEXT_PLAIN, "big yellow boat"); + dataContent.usingUser(userModel).usingSite(siteModel).createContent(fileBigYellowBoat); + + waitForIndexing(fileBigYellowBoat.getName(), true); + } + + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 1) + public void testPhraseQueries() throws Exception + { + // yellow banana: 5 results expected + SearchSqlRequest sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql("select cm_name, cm_content from alfresco where cm_content = '(yellow banana)'"); + sqlRequest.setLimit(10); + + RestResponse response = searchSql(sqlRequest); + + restClient.assertStatusCodeIs(HttpStatus.OK); + response.assertThat().body("list.pagination.count", Matchers.equalTo(5)); + restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", Matchers.equalToIgnoringCase("cm_content")); + restClient.onResponse().assertThat().body("list.entries.entry[0][0].value", Matchers.equalToIgnoringCase(fileYellowBanana.getContent())); + restClient.onResponse().assertThat().body("list.entries.entry[0][1].label", Matchers.equalToIgnoringCase("cm_name")); + restClient.onResponse().assertThat().body("list.entries.entry[0][1].value", Matchers.equalToIgnoringCase(fileYellowBanana.getName())); + + // yellow banana big boat: 6 results expected + sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql("select cm_name, cm_content from alfresco where cm_content = '(yellow banana big boat)'"); + sqlRequest.setLimit(10); + + response = searchSql(sqlRequest); + + restClient.assertStatusCodeIs(HttpStatus.OK); + response.assertThat().body("list.pagination.count", Matchers.equalTo(6)); + restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", Matchers.equalToIgnoringCase("cm_content")); + restClient.onResponse().assertThat().body("list.entries.entry[0][0].value", Matchers.equalToIgnoringCase(fileYellowBananaBigBoat.getContent())); + restClient.onResponse().assertThat().body("list.entries.entry[0][1].label", Matchers.equalToIgnoringCase("cm_name")); + restClient.onResponse().assertThat().body("list.entries.entry[0][1].value", Matchers.equalToIgnoringCase(fileYellowBananaBigBoat.getName())); + + // yellow banana big boat: 4 results expected + sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql("select cm_name, cm_content from alfresco where cm_content = '(big boat)'"); + sqlRequest.setLimit(10); + + response = searchSql(sqlRequest); + + restClient.assertStatusCodeIs(HttpStatus.OK); + response.assertThat().body("list.pagination.count", Matchers.equalTo(4)); + restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", Matchers.equalToIgnoringCase("cm_content")); + restClient.onResponse().assertThat().body("list.entries.entry[0][0].value", Matchers.equalToIgnoringCase(fileBigBananaBoat.getContent())); + restClient.onResponse().assertThat().body("list.entries.entry[0][1].label", Matchers.equalToIgnoringCase("cm_name")); + restClient.onResponse().assertThat().body("list.entries.entry[0][1].value", Matchers.equalToIgnoringCase(fileBigBananaBoat.getName())); + } + + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 2) + public void testPhraseQueriesViaJDBC() throws Exception + { + // yellow banana: 5 results expected + SearchSqlJDBCRequest sqlRequest = new SearchSqlJDBCRequest(); + String sql = "select cm_name, cm_content from alfresco where cm_content = '(yellow banana)'"; + sqlRequest.setSql(sql); + sqlRequest.setAuthUser(userModel); + + ResultSet rs = restClient.withSearchSqlViaJDBC().executeQueryViaJDBC(sqlRequest); + Assert.assertNotNull(rs); + Assert.assertNull(sqlRequest.getErrorDetails()); + + // Set expected Results + Integer expectedCount = 5; + String firstResultFileName = fileYellowBanana.getName(); + String firstResultContent = fileYellowBanana.getContent(); + + Integer i = 1; + while (rs.next()) + { + // Field values are retrieved + Assert.assertNotNull(rs.getString("cm_name")); + Assert.assertNotNull(rs.getString("cm_content")); + + if(i == 1) + { + Assert.assertEquals(rs.getString("cm_name"), firstResultFileName); + Assert.assertEquals(rs.getString("cm_content"), firstResultContent); + } + + i++; + } + + Assert.assertEquals(i, expectedCount); + + // yellow banana big boat: 6 results expected + sql = "select cm_name, cm_content from alfresco where cm_content = '(yellow banana big boat)'"; + sqlRequest.setSql(sql); + sqlRequest.setAuthUser(userModel); + + rs = restClient.withSearchSqlViaJDBC().executeQueryViaJDBC(sqlRequest); + Assert.assertNotNull(rs); + Assert.assertNull(sqlRequest.getErrorDetails()); + + expectedCount = 6; + firstResultFileName = fileYellowBananaBigBoat.getName(); + firstResultContent = fileYellowBananaBigBoat.getContent(); + + i = 1; + while (rs.next()) + { + // Field values are retrieved + Assert.assertNotNull(rs.getString("cm_name")); + Assert.assertNotNull(rs.getString("cm_content")); + + if(i == 1) + { + Assert.assertEquals(rs.getString("cm_name"), firstResultFileName); + Assert.assertEquals(rs.getString("cm_content"), firstResultContent); + } + + i++; + } + + Assert.assertEquals(i, expectedCount); + + // yellow banana big boat: 6 results expected + sql = "select cm_name, cm_content from alfresco where cm_content = '(yellow banana big boat)'"; + sqlRequest.setSql(sql); + sqlRequest.setAuthUser(userModel); + + rs = restClient.withSearchSqlViaJDBC().executeQueryViaJDBC(sqlRequest); + Assert.assertNotNull(rs); + Assert.assertNull(sqlRequest.getErrorDetails()); + + expectedCount = 6; + firstResultFileName = fileYellowBananaBigBoat.getName(); + firstResultContent = fileYellowBananaBigBoat.getContent(); + + i = 1; + while (rs.next()) + { + // Field values are retrieved + Assert.assertNotNull(rs.getString("cm_name")); + Assert.assertNotNull(rs.getString("cm_content")); + + if(i == 1) + { + Assert.assertEquals(rs.getString("cm_name"), firstResultFileName); + Assert.assertEquals(rs.getString("cm_content"), firstResultContent); + } + + i++; + } + + Assert.assertEquals(i, expectedCount); + + // big boat: 4 results expected + sql = "select cm_name, cm_content from alfresco where cm_content = '(big boat)'"; + sqlRequest.setSql(sql); + sqlRequest.setAuthUser(userModel); + + rs = restClient.withSearchSqlViaJDBC().executeQueryViaJDBC(sqlRequest); + Assert.assertNotNull(rs); + Assert.assertNull(sqlRequest.getErrorDetails()); + + expectedCount = 4; + firstResultFileName = fileBigBananaBoat.getName(); + firstResultContent = fileBigBananaBoat.getContent(); + i = 1; + while (rs.next()) + { + // Field values are retrieved + Assert.assertNotNull(rs.getString("cm_name")); + Assert.assertNotNull(rs.getString("cm_content")); + + if(i == 1) + { + Assert.assertEquals(rs.getString("cm_name"), firstResultFileName); + Assert.assertEquals(rs.getString("cm_content"), firstResultContent); + } + + i++; + } + + Assert.assertEquals(i, expectedCount); + } +} \ No newline at end of file From 426496aaa0a32c31aef8af0001e9e1effa7cbc0e Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Tue, 3 Jul 2018 12:03:17 +0100 Subject: [PATCH 1375/1491] Search-940 Corrected Tests --- .../rest/search/sql/SearchSQLPhraseTest.java | 55 ++++--------------- 1 file changed, 12 insertions(+), 43 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLPhraseTest.java b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLPhraseTest.java index 7d49d152e..a2d0cd75c 100644 --- a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLPhraseTest.java +++ b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLPhraseTest.java @@ -44,22 +44,22 @@ public class SearchSQLPhraseTest extends AbstractSearchTest super.dataPreparation(); // Create files with different phrases - fileBanana = new FileModel(unique_searchString + "-1.txt", "phrase searching", "", FileType.TEXT_PLAIN, "banana"); + fileBanana = new FileModel(unique_searchString + "-1.txt", "banana", "phrase searching", FileType.TEXT_PLAIN, "banana"); dataContent.usingUser(userModel).usingSite(siteModel).createContent(fileBanana); - fileYellowBanana = new FileModel(unique_searchString + "-2.txt", "phrase searching", "", FileType.TEXT_PLAIN, "yellow banana"); + fileYellowBanana = new FileModel(unique_searchString + "-2.txt", "yellow banana", "phrase searching", FileType.TEXT_PLAIN, "yellow banana"); dataContent.usingUser(userModel).usingSite(siteModel).createContent(fileYellowBanana); - fileBigYellowBanana = new FileModel(unique_searchString + "-3.txt", "phrase searching", "", FileType.TEXT_PLAIN, "big yellow banana"); + fileBigYellowBanana = new FileModel(unique_searchString + "-3.txt", "big yellow banana", "phrase searching", FileType.TEXT_PLAIN, "big yellow banana"); dataContent.usingUser(userModel).usingSite(siteModel).createContent(fileBigYellowBanana); - fileBigBananaBoat = new FileModel(unique_searchString + "-4.txt", "", "phrase searching", FileType.TEXT_PLAIN, "big boat"); + fileBigBananaBoat = new FileModel(unique_searchString + "-4.txt", "big boat", "phrase searching", FileType.TEXT_PLAIN, "big boat"); dataContent.usingUser(userModel).usingSite(siteModel).createContent(fileBigBananaBoat); - fileYellowBananaBigBoat = new FileModel(unique_searchString + "-5.txt", "", "phrase searching", FileType.TEXT_PLAIN, "yellow banana big boat"); + fileYellowBananaBigBoat = new FileModel(unique_searchString + "-5.txt", "yellow banana big boat", "phrase searching", FileType.TEXT_PLAIN, "yellow banana big boat"); dataContent.usingUser(userModel).usingSite(siteModel).createContent(fileYellowBananaBigBoat); - fileBigYellowBoat = new FileModel(unique_searchString + "-6.txt", "", "phrase searching", FileType.TEXT_PLAIN, "big yellow boat"); + fileBigYellowBoat = new FileModel(unique_searchString + "-6.txt", "big yellow boat", "phrase searching", FileType.TEXT_PLAIN, "big yellow boat"); dataContent.usingUser(userModel).usingSite(siteModel).createContent(fileBigYellowBoat); waitForIndexing(fileBigYellowBoat.getName(), true); @@ -129,45 +129,14 @@ public class SearchSQLPhraseTest extends AbstractSearchTest String firstResultFileName = fileYellowBanana.getName(); String firstResultContent = fileYellowBanana.getContent(); - Integer i = 1; + Integer i = 0; while (rs.next()) { // Field values are retrieved Assert.assertNotNull(rs.getString("cm_name")); Assert.assertNotNull(rs.getString("cm_content")); - if(i == 1) - { - Assert.assertEquals(rs.getString("cm_name"), firstResultFileName); - Assert.assertEquals(rs.getString("cm_content"), firstResultContent); - } - - i++; - } - - Assert.assertEquals(i, expectedCount); - - // yellow banana big boat: 6 results expected - sql = "select cm_name, cm_content from alfresco where cm_content = '(yellow banana big boat)'"; - sqlRequest.setSql(sql); - sqlRequest.setAuthUser(userModel); - - rs = restClient.withSearchSqlViaJDBC().executeQueryViaJDBC(sqlRequest); - Assert.assertNotNull(rs); - Assert.assertNull(sqlRequest.getErrorDetails()); - - expectedCount = 6; - firstResultFileName = fileYellowBananaBigBoat.getName(); - firstResultContent = fileYellowBananaBigBoat.getContent(); - - i = 1; - while (rs.next()) - { - // Field values are retrieved - Assert.assertNotNull(rs.getString("cm_name")); - Assert.assertNotNull(rs.getString("cm_content")); - - if(i == 1) + if(i == 0) { Assert.assertEquals(rs.getString("cm_name"), firstResultFileName); Assert.assertEquals(rs.getString("cm_content"), firstResultContent); @@ -191,14 +160,14 @@ public class SearchSQLPhraseTest extends AbstractSearchTest firstResultFileName = fileYellowBananaBigBoat.getName(); firstResultContent = fileYellowBananaBigBoat.getContent(); - i = 1; + i = 0; while (rs.next()) { // Field values are retrieved Assert.assertNotNull(rs.getString("cm_name")); Assert.assertNotNull(rs.getString("cm_content")); - if(i == 1) + if(i == 0) { Assert.assertEquals(rs.getString("cm_name"), firstResultFileName); Assert.assertEquals(rs.getString("cm_content"), firstResultContent); @@ -221,14 +190,14 @@ public class SearchSQLPhraseTest extends AbstractSearchTest expectedCount = 4; firstResultFileName = fileBigBananaBoat.getName(); firstResultContent = fileBigBananaBoat.getContent(); - i = 1; + i = 0; while (rs.next()) { // Field values are retrieved Assert.assertNotNull(rs.getString("cm_name")); Assert.assertNotNull(rs.getString("cm_content")); - if(i == 1) + if(i == 0) { Assert.assertEquals(rs.getString("cm_name"), firstResultFileName); Assert.assertEquals(rs.getString("cm_content"), firstResultContent); From c2a223e37f28d4b086f1ef9e44eec95220fba6c1 Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Wed, 4 Jul 2018 17:28:05 +0100 Subject: [PATCH 1376/1491] Search-940 Amended Tests to check all the results, rather than the top ranked result as discussed --- .../rest/search/sql/SearchSQLPhraseTest.java | 195 +++++++++++------- 1 file changed, 117 insertions(+), 78 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLPhraseTest.java b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLPhraseTest.java index a2d0cd75c..c72b0666a 100644 --- a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLPhraseTest.java +++ b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLPhraseTest.java @@ -15,6 +15,11 @@ package org.alfresco.rest.search.sql; import java.sql.ResultSet; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import java.util.Map; import org.alfresco.rest.core.RestResponse; import org.alfresco.rest.search.AbstractSearchTest; @@ -37,7 +42,9 @@ import org.hamcrest.Matchers; public class SearchSQLPhraseTest extends AbstractSearchTest { FileModel fileBanana, fileYellowBanana, fileBigYellowBanana, fileBigBananaBoat, fileYellowBananaBigBoat, fileBigYellowBoat; - + + List expectedContent = new ArrayList(); + @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception { @@ -65,58 +72,90 @@ public class SearchSQLPhraseTest extends AbstractSearchTest waitForIndexing(fileBigYellowBoat.getName(), true); } + @SuppressWarnings("unchecked") @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 1) public void testPhraseQueries() throws Exception { // yellow banana: 5 results expected SearchSqlRequest sqlRequest = new SearchSqlRequest(); - sqlRequest.setSql("select cm_name, cm_content from alfresco where cm_content = '(yellow banana)'"); + sqlRequest.setSql("select cm_content from alfresco where cm_content = '(yellow banana)'"); sqlRequest.setLimit(10); RestResponse response = searchSql(sqlRequest); restClient.assertStatusCodeIs(HttpStatus.OK); - response.assertThat().body("list.pagination.count", Matchers.equalTo(5)); - restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", Matchers.equalToIgnoringCase("cm_content")); - restClient.onResponse().assertThat().body("list.entries.entry[0][0].value", Matchers.equalToIgnoringCase(fileYellowBanana.getContent())); - restClient.onResponse().assertThat().body("list.entries.entry[0][1].label", Matchers.equalToIgnoringCase("cm_name")); - restClient.onResponse().assertThat().body("list.entries.entry[0][1].value", Matchers.equalToIgnoringCase(fileYellowBanana.getName())); + + // Set Expected Result + expectedContent = new ArrayList(); + expectedContent.add(Arrays.asList(fileBanana.getContent())); + expectedContent.add(Arrays.asList(fileYellowBanana.getContent())); + expectedContent.add(Arrays.asList(fileBigYellowBanana.getContent())); + expectedContent.add(Arrays.asList(fileYellowBananaBigBoat.getContent())); + expectedContent.add(Arrays.asList(fileBigYellowBoat.getContent())); + + // Check Result count matches + response.assertThat().body("list.pagination.count", Matchers.equalTo(expectedContent.size())); + + // Check Results match + Collection> actualResult = response.getResponse().body().jsonPath().get("list.entries.entry.value"); + Assert.assertTrue(actualResult.containsAll(expectedContent), "Phrase Search Results are not as expected"); // yellow banana big boat: 6 results expected sqlRequest = new SearchSqlRequest(); - sqlRequest.setSql("select cm_name, cm_content from alfresco where cm_content = '(yellow banana big boat)'"); + sqlRequest.setSql("select cm_content from alfresco where cm_content = '(yellow banana big boat)'"); sqlRequest.setLimit(10); response = searchSql(sqlRequest); restClient.assertStatusCodeIs(HttpStatus.OK); - response.assertThat().body("list.pagination.count", Matchers.equalTo(6)); - restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", Matchers.equalToIgnoringCase("cm_content")); - restClient.onResponse().assertThat().body("list.entries.entry[0][0].value", Matchers.equalToIgnoringCase(fileYellowBananaBigBoat.getContent())); - restClient.onResponse().assertThat().body("list.entries.entry[0][1].label", Matchers.equalToIgnoringCase("cm_name")); - restClient.onResponse().assertThat().body("list.entries.entry[0][1].value", Matchers.equalToIgnoringCase(fileYellowBananaBigBoat.getName())); + + // Set Expected Result + expectedContent = new ArrayList(); + expectedContent.add(Arrays.asList(fileBanana.getContent())); + expectedContent.add(Arrays.asList(fileYellowBanana.getContent())); + expectedContent.add(Arrays.asList(fileBigYellowBanana.getContent())); + expectedContent.add(Arrays.asList(fileYellowBananaBigBoat.getContent())); + expectedContent.add(Arrays.asList(fileBigYellowBoat.getContent())); + expectedContent.add(Arrays.asList(fileBigBananaBoat.getContent())); + + // Check Result count matches + response.assertThat().body("list.pagination.count", Matchers.equalTo(expectedContent.size())); + + // Check Results match + actualResult = response.getResponse().body().jsonPath().get("list.entries.entry.value"); + Assert.assertTrue(actualResult.containsAll(expectedContent), "Phrase Search Results are not as expected"); // yellow banana big boat: 4 results expected sqlRequest = new SearchSqlRequest(); - sqlRequest.setSql("select cm_name, cm_content from alfresco where cm_content = '(big boat)'"); + sqlRequest.setSql("select cm_content from alfresco where cm_content = '(big boat)'"); sqlRequest.setLimit(10); response = searchSql(sqlRequest); restClient.assertStatusCodeIs(HttpStatus.OK); - response.assertThat().body("list.pagination.count", Matchers.equalTo(4)); - restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", Matchers.equalToIgnoringCase("cm_content")); - restClient.onResponse().assertThat().body("list.entries.entry[0][0].value", Matchers.equalToIgnoringCase(fileBigBananaBoat.getContent())); - restClient.onResponse().assertThat().body("list.entries.entry[0][1].label", Matchers.equalToIgnoringCase("cm_name")); - restClient.onResponse().assertThat().body("list.entries.entry[0][1].value", Matchers.equalToIgnoringCase(fileBigBananaBoat.getName())); + + // Set Expected Result + expectedContent = new ArrayList(); + expectedContent.add(Arrays.asList(fileBigYellowBanana.getContent())); + expectedContent.add(Arrays.asList(fileYellowBananaBigBoat.getContent())); + expectedContent.add(Arrays.asList(fileBigYellowBoat.getContent())); + expectedContent.add(Arrays.asList(fileBigBananaBoat.getContent())); + + // Check Result count matches + response.assertThat().body("list.pagination.count", Matchers.equalTo(expectedContent.size())); + + // Check Results match + actualResult = response.getResponse().body().jsonPath().get("list.entries.entry.value"); + Assert.assertTrue(actualResult.containsAll(expectedContent), "Phrase Search Results are not as expected"); } + @SuppressWarnings("unchecked") @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 2) public void testPhraseQueriesViaJDBC() throws Exception { // yellow banana: 5 results expected SearchSqlJDBCRequest sqlRequest = new SearchSqlJDBCRequest(); - String sql = "select cm_name, cm_content from alfresco where cm_content = '(yellow banana)'"; + String sql = "select cm_content from alfresco where cm_content = '(yellow banana)'"; sqlRequest.setSql(sql); sqlRequest.setAuthUser(userModel); @@ -124,31 +163,62 @@ public class SearchSQLPhraseTest extends AbstractSearchTest Assert.assertNotNull(rs); Assert.assertNull(sqlRequest.getErrorDetails()); - // Set expected Results - Integer expectedCount = 5; - String firstResultFileName = fileYellowBanana.getName(); - String firstResultContent = fileYellowBanana.getContent(); + // Set Expected Result + expectedContent = new ArrayList(); + expectedContent.add(Arrays.asList(fileBanana.getContent())); + expectedContent.add(Arrays.asList(fileYellowBanana.getContent())); + expectedContent.add(Arrays.asList(fileBigYellowBanana.getContent())); + expectedContent.add(Arrays.asList(fileYellowBananaBigBoat.getContent())); + expectedContent.add(Arrays.asList(fileBigYellowBoat.getContent())); Integer i = 0; + List actualContent = new ArrayList(); + while (rs.next()) { // Field values are retrieved - Assert.assertNotNull(rs.getString("cm_name")); Assert.assertNotNull(rs.getString("cm_content")); - - if(i == 0) - { - Assert.assertEquals(rs.getString("cm_name"), firstResultFileName); - Assert.assertEquals(rs.getString("cm_content"), firstResultContent); - } - + actualContent.add(Arrays.asList(rs.getString("cm_content"))); i++; } + + Assert.assertTrue(i == expectedContent.size()); + Assert.assertTrue(actualContent.containsAll(expectedContent), "Phrase Search Results are not as expected"); - Assert.assertEquals(i, expectedCount); + // yellow banana big boat: 6 results expected + sql = "select cm_content from alfresco where cm_content = '(yellow banana big boat)'"; + sqlRequest.setSql(sql); + sqlRequest.setAuthUser(userModel); + + rs = restClient.withSearchSqlViaJDBC().executeQueryViaJDBC(sqlRequest); + Assert.assertNotNull(rs); + Assert.assertNull(sqlRequest.getErrorDetails()); - // yellow banana big boat: 6 results expected - sql = "select cm_name, cm_content from alfresco where cm_content = '(yellow banana big boat)'"; + // Set Expected Result + expectedContent = new ArrayList(); + expectedContent.add(Arrays.asList(fileBanana.getContent())); + expectedContent.add(Arrays.asList(fileYellowBanana.getContent())); + expectedContent.add(Arrays.asList(fileBigYellowBanana.getContent())); + expectedContent.add(Arrays.asList(fileYellowBananaBigBoat.getContent())); + expectedContent.add(Arrays.asList(fileBigYellowBoat.getContent())); + expectedContent.add(Arrays.asList(fileBigBananaBoat.getContent())); + + i = 0; + actualContent = new ArrayList(); + + while (rs.next()) + { + // Field values are retrieved + Assert.assertNotNull(rs.getString("cm_content")); + actualContent.add(Arrays.asList(rs.getString("cm_content"))); + i++; + } + + Assert.assertTrue(i == expectedContent.size()); + Assert.assertTrue(actualContent.containsAll(expectedContent), "Phrase Search Results are not as expected"); + + // big boat: 4 results expected + sql = "select cm_content from alfresco where cm_content = '(big boat)'"; sqlRequest.setSql(sql); sqlRequest.setAuthUser(userModel); @@ -156,56 +226,25 @@ public class SearchSQLPhraseTest extends AbstractSearchTest Assert.assertNotNull(rs); Assert.assertNull(sqlRequest.getErrorDetails()); - expectedCount = 6; - firstResultFileName = fileYellowBananaBigBoat.getName(); - firstResultContent = fileYellowBananaBigBoat.getContent(); - + // Set Expected Result + expectedContent = new ArrayList(); + expectedContent.add(Arrays.asList(fileBigYellowBanana.getContent())); + expectedContent.add(Arrays.asList(fileYellowBananaBigBoat.getContent())); + expectedContent.add(Arrays.asList(fileBigYellowBoat.getContent())); + expectedContent.add(Arrays.asList(fileBigBananaBoat.getContent())); + i = 0; + actualContent = new ArrayList(); + while (rs.next()) { // Field values are retrieved - Assert.assertNotNull(rs.getString("cm_name")); Assert.assertNotNull(rs.getString("cm_content")); - - if(i == 0) - { - Assert.assertEquals(rs.getString("cm_name"), firstResultFileName); - Assert.assertEquals(rs.getString("cm_content"), firstResultContent); - } - + actualContent.add(Arrays.asList(rs.getString("cm_content"))); i++; } - - Assert.assertEquals(i, expectedCount); - - // big boat: 4 results expected - sql = "select cm_name, cm_content from alfresco where cm_content = '(big boat)'"; - sqlRequest.setSql(sql); - sqlRequest.setAuthUser(userModel); - rs = restClient.withSearchSqlViaJDBC().executeQueryViaJDBC(sqlRequest); - Assert.assertNotNull(rs); - Assert.assertNull(sqlRequest.getErrorDetails()); - - expectedCount = 4; - firstResultFileName = fileBigBananaBoat.getName(); - firstResultContent = fileBigBananaBoat.getContent(); - i = 0; - while (rs.next()) - { - // Field values are retrieved - Assert.assertNotNull(rs.getString("cm_name")); - Assert.assertNotNull(rs.getString("cm_content")); - - if(i == 0) - { - Assert.assertEquals(rs.getString("cm_name"), firstResultFileName); - Assert.assertEquals(rs.getString("cm_content"), firstResultContent); - } - - i++; - } - - Assert.assertEquals(i, expectedCount); + Assert.assertTrue(i == expectedContent.size()); + Assert.assertTrue(actualContent.containsAll(expectedContent), "Phrase Search Results are not as expected"); } } \ No newline at end of file From b51d55ad86a60ec4df24d5f7604eb3a8b9495746 Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Wed, 4 Jul 2018 17:39:19 +0100 Subject: [PATCH 1377/1491] Removed from this branch as it should be part of a seperate branch --- .../rest/search/sql/SearchSQLPhraseTest.java | 250 ------------------ 1 file changed, 250 deletions(-) delete mode 100644 e2e-test/java/org/alfresco/rest/search/sql/SearchSQLPhraseTest.java diff --git a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLPhraseTest.java b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLPhraseTest.java deleted file mode 100644 index c72b0666a..000000000 --- a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLPhraseTest.java +++ /dev/null @@ -1,250 +0,0 @@ -/* - * Copyright (C) 2018 Alfresco Software Limited. - * This file is part of Alfresco - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.rest.search.sql; - -import java.sql.ResultSet; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import org.alfresco.rest.core.RestResponse; -import org.alfresco.rest.search.AbstractSearchTest; -import org.alfresco.rest.search.SearchSqlJDBCRequest; -import org.alfresco.rest.search.SearchSqlRequest; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FileType; -import org.alfresco.utility.model.TestGroup; -import org.springframework.http.HttpStatus; -import org.testng.Assert; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; -import org.hamcrest.Matchers; - -/** - * Tests for /sql end point Search API. - * - * @author Meenal Bhave - */ -public class SearchSQLPhraseTest extends AbstractSearchTest -{ - FileModel fileBanana, fileYellowBanana, fileBigYellowBanana, fileBigBananaBoat, fileYellowBananaBigBoat, fileBigYellowBoat; - - List expectedContent = new ArrayList(); - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - super.dataPreparation(); - - // Create files with different phrases - fileBanana = new FileModel(unique_searchString + "-1.txt", "banana", "phrase searching", FileType.TEXT_PLAIN, "banana"); - dataContent.usingUser(userModel).usingSite(siteModel).createContent(fileBanana); - - fileYellowBanana = new FileModel(unique_searchString + "-2.txt", "yellow banana", "phrase searching", FileType.TEXT_PLAIN, "yellow banana"); - dataContent.usingUser(userModel).usingSite(siteModel).createContent(fileYellowBanana); - - fileBigYellowBanana = new FileModel(unique_searchString + "-3.txt", "big yellow banana", "phrase searching", FileType.TEXT_PLAIN, "big yellow banana"); - dataContent.usingUser(userModel).usingSite(siteModel).createContent(fileBigYellowBanana); - - fileBigBananaBoat = new FileModel(unique_searchString + "-4.txt", "big boat", "phrase searching", FileType.TEXT_PLAIN, "big boat"); - dataContent.usingUser(userModel).usingSite(siteModel).createContent(fileBigBananaBoat); - - fileYellowBananaBigBoat = new FileModel(unique_searchString + "-5.txt", "yellow banana big boat", "phrase searching", FileType.TEXT_PLAIN, "yellow banana big boat"); - dataContent.usingUser(userModel).usingSite(siteModel).createContent(fileYellowBananaBigBoat); - - fileBigYellowBoat = new FileModel(unique_searchString + "-6.txt", "big yellow boat", "phrase searching", FileType.TEXT_PLAIN, "big yellow boat"); - dataContent.usingUser(userModel).usingSite(siteModel).createContent(fileBigYellowBoat); - - waitForIndexing(fileBigYellowBoat.getName(), true); - } - - @SuppressWarnings("unchecked") - @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 1) - public void testPhraseQueries() throws Exception - { - // yellow banana: 5 results expected - SearchSqlRequest sqlRequest = new SearchSqlRequest(); - sqlRequest.setSql("select cm_content from alfresco where cm_content = '(yellow banana)'"); - sqlRequest.setLimit(10); - - RestResponse response = searchSql(sqlRequest); - - restClient.assertStatusCodeIs(HttpStatus.OK); - - // Set Expected Result - expectedContent = new ArrayList(); - expectedContent.add(Arrays.asList(fileBanana.getContent())); - expectedContent.add(Arrays.asList(fileYellowBanana.getContent())); - expectedContent.add(Arrays.asList(fileBigYellowBanana.getContent())); - expectedContent.add(Arrays.asList(fileYellowBananaBigBoat.getContent())); - expectedContent.add(Arrays.asList(fileBigYellowBoat.getContent())); - - // Check Result count matches - response.assertThat().body("list.pagination.count", Matchers.equalTo(expectedContent.size())); - - // Check Results match - Collection> actualResult = response.getResponse().body().jsonPath().get("list.entries.entry.value"); - Assert.assertTrue(actualResult.containsAll(expectedContent), "Phrase Search Results are not as expected"); - - // yellow banana big boat: 6 results expected - sqlRequest = new SearchSqlRequest(); - sqlRequest.setSql("select cm_content from alfresco where cm_content = '(yellow banana big boat)'"); - sqlRequest.setLimit(10); - - response = searchSql(sqlRequest); - - restClient.assertStatusCodeIs(HttpStatus.OK); - - // Set Expected Result - expectedContent = new ArrayList(); - expectedContent.add(Arrays.asList(fileBanana.getContent())); - expectedContent.add(Arrays.asList(fileYellowBanana.getContent())); - expectedContent.add(Arrays.asList(fileBigYellowBanana.getContent())); - expectedContent.add(Arrays.asList(fileYellowBananaBigBoat.getContent())); - expectedContent.add(Arrays.asList(fileBigYellowBoat.getContent())); - expectedContent.add(Arrays.asList(fileBigBananaBoat.getContent())); - - // Check Result count matches - response.assertThat().body("list.pagination.count", Matchers.equalTo(expectedContent.size())); - - // Check Results match - actualResult = response.getResponse().body().jsonPath().get("list.entries.entry.value"); - Assert.assertTrue(actualResult.containsAll(expectedContent), "Phrase Search Results are not as expected"); - - // yellow banana big boat: 4 results expected - sqlRequest = new SearchSqlRequest(); - sqlRequest.setSql("select cm_content from alfresco where cm_content = '(big boat)'"); - sqlRequest.setLimit(10); - - response = searchSql(sqlRequest); - - restClient.assertStatusCodeIs(HttpStatus.OK); - - // Set Expected Result - expectedContent = new ArrayList(); - expectedContent.add(Arrays.asList(fileBigYellowBanana.getContent())); - expectedContent.add(Arrays.asList(fileYellowBananaBigBoat.getContent())); - expectedContent.add(Arrays.asList(fileBigYellowBoat.getContent())); - expectedContent.add(Arrays.asList(fileBigBananaBoat.getContent())); - - // Check Result count matches - response.assertThat().body("list.pagination.count", Matchers.equalTo(expectedContent.size())); - - // Check Results match - actualResult = response.getResponse().body().jsonPath().get("list.entries.entry.value"); - Assert.assertTrue(actualResult.containsAll(expectedContent), "Phrase Search Results are not as expected"); - } - - @SuppressWarnings("unchecked") - @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 2) - public void testPhraseQueriesViaJDBC() throws Exception - { - // yellow banana: 5 results expected - SearchSqlJDBCRequest sqlRequest = new SearchSqlJDBCRequest(); - String sql = "select cm_content from alfresco where cm_content = '(yellow banana)'"; - sqlRequest.setSql(sql); - sqlRequest.setAuthUser(userModel); - - ResultSet rs = restClient.withSearchSqlViaJDBC().executeQueryViaJDBC(sqlRequest); - Assert.assertNotNull(rs); - Assert.assertNull(sqlRequest.getErrorDetails()); - - // Set Expected Result - expectedContent = new ArrayList(); - expectedContent.add(Arrays.asList(fileBanana.getContent())); - expectedContent.add(Arrays.asList(fileYellowBanana.getContent())); - expectedContent.add(Arrays.asList(fileBigYellowBanana.getContent())); - expectedContent.add(Arrays.asList(fileYellowBananaBigBoat.getContent())); - expectedContent.add(Arrays.asList(fileBigYellowBoat.getContent())); - - Integer i = 0; - List actualContent = new ArrayList(); - - while (rs.next()) - { - // Field values are retrieved - Assert.assertNotNull(rs.getString("cm_content")); - actualContent.add(Arrays.asList(rs.getString("cm_content"))); - i++; - } - - Assert.assertTrue(i == expectedContent.size()); - Assert.assertTrue(actualContent.containsAll(expectedContent), "Phrase Search Results are not as expected"); - - // yellow banana big boat: 6 results expected - sql = "select cm_content from alfresco where cm_content = '(yellow banana big boat)'"; - sqlRequest.setSql(sql); - sqlRequest.setAuthUser(userModel); - - rs = restClient.withSearchSqlViaJDBC().executeQueryViaJDBC(sqlRequest); - Assert.assertNotNull(rs); - Assert.assertNull(sqlRequest.getErrorDetails()); - - // Set Expected Result - expectedContent = new ArrayList(); - expectedContent.add(Arrays.asList(fileBanana.getContent())); - expectedContent.add(Arrays.asList(fileYellowBanana.getContent())); - expectedContent.add(Arrays.asList(fileBigYellowBanana.getContent())); - expectedContent.add(Arrays.asList(fileYellowBananaBigBoat.getContent())); - expectedContent.add(Arrays.asList(fileBigYellowBoat.getContent())); - expectedContent.add(Arrays.asList(fileBigBananaBoat.getContent())); - - i = 0; - actualContent = new ArrayList(); - - while (rs.next()) - { - // Field values are retrieved - Assert.assertNotNull(rs.getString("cm_content")); - actualContent.add(Arrays.asList(rs.getString("cm_content"))); - i++; - } - - Assert.assertTrue(i == expectedContent.size()); - Assert.assertTrue(actualContent.containsAll(expectedContent), "Phrase Search Results are not as expected"); - - // big boat: 4 results expected - sql = "select cm_content from alfresco where cm_content = '(big boat)'"; - sqlRequest.setSql(sql); - sqlRequest.setAuthUser(userModel); - - rs = restClient.withSearchSqlViaJDBC().executeQueryViaJDBC(sqlRequest); - Assert.assertNotNull(rs); - Assert.assertNull(sqlRequest.getErrorDetails()); - - // Set Expected Result - expectedContent = new ArrayList(); - expectedContent.add(Arrays.asList(fileBigYellowBanana.getContent())); - expectedContent.add(Arrays.asList(fileYellowBananaBigBoat.getContent())); - expectedContent.add(Arrays.asList(fileBigYellowBoat.getContent())); - expectedContent.add(Arrays.asList(fileBigBananaBoat.getContent())); - - i = 0; - actualContent = new ArrayList(); - - while (rs.next()) - { - // Field values are retrieved - Assert.assertNotNull(rs.getString("cm_content")); - actualContent.add(Arrays.asList(rs.getString("cm_content"))); - i++; - } - - Assert.assertTrue(i == expectedContent.size()); - Assert.assertTrue(actualContent.containsAll(expectedContent), "Phrase Search Results are not as expected"); - } -} \ No newline at end of file From fa482ef229218a4be9d62e43d4766011b43823fd Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Mon, 9 Jul 2018 17:28:05 +0100 Subject: [PATCH 1378/1491] Search-904 Added Tests Select distinct for /sql api --- .../rest/search/sql/SearchSQLAPITest.java | 25 +++++++++++++++++++ .../rest/search/sql/SearchSQLViaJDBCTest.java | 20 +++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLAPITest.java b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLAPITest.java index 8f1b2037a..c251a9892 100644 --- a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLAPITest.java +++ b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLAPITest.java @@ -626,4 +626,29 @@ public class SearchSQLAPITest extends AbstractSearchTest restClient.assertStatusCodeIs(HttpStatus.OK); restClient.onResponse().assertThat().body("result-set.docs[0].aliases.PATH", Matchers.notNullValue()); } + + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 15) + public void testDistinct() throws Exception + { + // Select distinct site: json format + SearchSqlRequest sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql("select distinct Site from alfresco"); + sqlRequest.setLimit(10); + + RestResponse response = searchSql(sqlRequest); + + restClient.assertStatusCodeIs(HttpStatus.OK); + response.assertThat().body("list.pagination.maxItems", Matchers.equalTo(10)); + restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", Matchers.equalToIgnoringCase("site")); + + // Select distinct cm_name: solr format + sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql("select distinct cm_name from alfresco limit 5"); + sqlRequest.setFormat("solr"); + + response = searchSql(sqlRequest); + + restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.onResponse().assertThat().body("result-set.docs[0].cm_name", Matchers.notNullValue()); + } } \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLViaJDBCTest.java b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLViaJDBCTest.java index 25a1f01ca..eed0bb445 100644 --- a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLViaJDBCTest.java +++ b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLViaJDBCTest.java @@ -190,4 +190,24 @@ public class SearchSQLViaJDBCTest extends AbstractSearchTest Assert.assertNotNull(rs.getString("cm_name")); } } + + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 07) + public void testQuerySelectDistinct() throws SQLException + { + // Select distinct query with limit clause + String sql = "select distinct cm_name from alfresco limit 5"; + sqlRequest.setSql(sql); + sqlRequest.setAuthUser(adminUserModel); + + // Select distinct with limit clause works: No error is retrieved + ResultSet rs = restClient.withSearchSqlViaJDBC().executeQueryViaJDBC(sqlRequest); + Assert.assertNotNull(rs); + Assert.assertNull(sqlRequest.getErrorDetails()); + + while (rs.next()) + { + // Field values are retrieved + Assert.assertNotNull(rs.getString("cm_name")); + } + } } \ No newline at end of file From 9f0b10a2f34325e702fa124269b84d3b83458827 Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Tue, 10 Jul 2018 12:05:04 +0100 Subject: [PATCH 1379/1491] Search 940 --- .../rest/search/sql/SearchSQLPhraseTest.java | 256 ++++++++++++++++++ 1 file changed, 256 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/search/sql/SearchSQLPhraseTest.java diff --git a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLPhraseTest.java b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLPhraseTest.java new file mode 100644 index 000000000..86551eb09 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLPhraseTest.java @@ -0,0 +1,256 @@ +/* + * Copyright (C) 2018 Alfresco Software Limited. + * This file is part of Alfresco + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.rest.search.sql; + +import java.sql.ResultSet; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import java.util.Map; + +import org.alfresco.rest.core.RestResponse; +import org.alfresco.rest.search.AbstractSearchTest; +import org.alfresco.rest.search.SearchSqlJDBCRequest; +import org.alfresco.rest.search.SearchSqlRequest; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FileType; +import org.alfresco.utility.model.TestGroup; +import org.springframework.http.HttpStatus; +import org.testng.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; +import org.hamcrest.Matchers; + +/** + * Tests for /sql end point Search API: Phrase Searching. + * + * @author Meenal Bhave + */ +public class SearchSQLPhraseTest extends AbstractSearchTest +{ + FileModel fileBanana, fileYellowBanana, fileBigYellowBanana, fileBigBananaBoat, fileYellowBananaBigBoat, fileBigYellowBoat; + + List expectedContent = new ArrayList(); + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + super.dataPreparation(); + + // Create files with different phrases + fileBanana = new FileModel(unique_searchString + "-1.txt", "banana", "phrase searching", FileType.TEXT_PLAIN, "banana"); + dataContent.usingUser(userModel).usingSite(siteModel).createContent(fileBanana); + + fileYellowBanana = new FileModel(unique_searchString + "-2.txt", "yellow banana", "phrase searching", FileType.TEXT_PLAIN, "yellow banana"); + dataContent.usingUser(userModel).usingSite(siteModel).createContent(fileYellowBanana); + + fileBigYellowBanana = new FileModel(unique_searchString + "-3.txt", "big yellow banana", "phrase searching", FileType.TEXT_PLAIN, "big yellow banana"); + dataContent.usingUser(userModel).usingSite(siteModel).createContent(fileBigYellowBanana); + + fileBigBananaBoat = new FileModel(unique_searchString + "-4.txt", "big boat", "phrase searching", FileType.TEXT_PLAIN, "big boat"); + dataContent.usingUser(userModel).usingSite(siteModel).createContent(fileBigBananaBoat); + + fileYellowBananaBigBoat = new FileModel(unique_searchString + "-5.txt", "yellow banana big boat", "phrase searching", FileType.TEXT_PLAIN, "yellow banana big boat"); + dataContent.usingUser(userModel).usingSite(siteModel).createContent(fileYellowBananaBigBoat); + + fileBigYellowBoat = new FileModel(unique_searchString + "-6.txt", "big yellow boat", "phrase searching", FileType.TEXT_PLAIN, "big yellow boat"); + dataContent.usingUser(userModel).usingSite(siteModel).createContent(fileBigYellowBoat); + + waitForIndexing(fileBigYellowBoat.getName(), true); + } + + @SuppressWarnings("unchecked") + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 1) + public void testPhraseQueries() throws Exception + { + // yellow banana: 5 results expected + SearchSqlRequest sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql("select cm_content from alfresco where cm_content = '(yellow banana)'"); + sqlRequest.setLimit(10); + + RestResponse response = searchSql(sqlRequest); + + restClient.assertStatusCodeIs(HttpStatus.OK); + + // Set Expected Result + expectedContent = new ArrayList(); + expectedContent.add(Arrays.asList(fileBanana.getContent())); + expectedContent.add(Arrays.asList(fileYellowBanana.getContent())); + expectedContent.add(Arrays.asList(fileBigYellowBanana.getContent())); + expectedContent.add(Arrays.asList(fileYellowBananaBigBoat.getContent())); + expectedContent.add(Arrays.asList(fileBigYellowBoat.getContent())); + + // Check Result count matches + response.assertThat().body("list.pagination.count", Matchers.equalTo(expectedContent.size())); + + // Check Results match + Collection> actualContent = response.getResponse().body().jsonPath().get("list.entries.entry.value"); + Assert.assertTrue(actualContent.containsAll(expectedContent), String.format("Phrase Search Results expected: %s Actual: %s", expectedContent.toString(), actualContent.toString())); + Assert.assertTrue(expectedContent.containsAll(actualContent), String.format("Phrase Search Results expected: %s Actual: %s", expectedContent.toString(), actualContent.toString())); + + // yellow banana big boat: 6 results expected + sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql("select cm_content from alfresco where cm_content = '(yellow banana big boat)'"); + sqlRequest.setLimit(10); + + response = searchSql(sqlRequest); + + restClient.assertStatusCodeIs(HttpStatus.OK); + + // Set Expected Result + expectedContent = new ArrayList(); + expectedContent.add(Arrays.asList(fileBanana.getContent())); + expectedContent.add(Arrays.asList(fileYellowBanana.getContent())); + expectedContent.add(Arrays.asList(fileBigYellowBanana.getContent())); + expectedContent.add(Arrays.asList(fileYellowBananaBigBoat.getContent())); + expectedContent.add(Arrays.asList(fileBigYellowBoat.getContent())); + expectedContent.add(Arrays.asList(fileBigBananaBoat.getContent())); + + // Check Result count matches + response.assertThat().body("list.pagination.count", Matchers.equalTo(expectedContent.size())); + + // Check Results match + actualContent = response.getResponse().body().jsonPath().get("list.entries.entry.value"); + Assert.assertTrue(actualContent.containsAll(expectedContent), String.format("Phrase Search Results expected: %s Actual: %s", expectedContent.toString(), actualContent.toString())); + Assert.assertTrue(expectedContent.containsAll(actualContent), String.format("Phrase Search Results expected: %s Actual: %s", expectedContent.toString(), actualContent.toString())); + + // yellow banana big boat: 4 results expected + sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql("select cm_content from alfresco where cm_content = '(big boat)'"); + sqlRequest.setLimit(10); + + response = searchSql(sqlRequest); + + restClient.assertStatusCodeIs(HttpStatus.OK); + + // Set Expected Result + expectedContent = new ArrayList(); + expectedContent.add(Arrays.asList(fileBigYellowBanana.getContent())); + expectedContent.add(Arrays.asList(fileYellowBananaBigBoat.getContent())); + expectedContent.add(Arrays.asList(fileBigYellowBoat.getContent())); + expectedContent.add(Arrays.asList(fileBigBananaBoat.getContent())); + + // Check Result count matches + response.assertThat().body("list.pagination.count", Matchers.equalTo(expectedContent.size())); + + // Check Results match + actualContent = response.getResponse().body().jsonPath().get("list.entries.entry.value"); + Assert.assertTrue(actualContent.containsAll(expectedContent), String.format("Phrase Search Results expected: %s Actual: %s", expectedContent.toString(), actualContent.toString())); + Assert.assertTrue(expectedContent.containsAll(actualContent), String.format("Phrase Search Results expected: %s Actual: %s", expectedContent.toString(), actualContent.toString())); + } + + @SuppressWarnings("unchecked") + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 2) + public void testPhraseQueriesViaJDBC() throws Exception + { + // yellow banana: 5 results expected + SearchSqlJDBCRequest sqlRequest = new SearchSqlJDBCRequest(); + String sql = "select cm_content from alfresco where cm_content = '(yellow banana)'"; + sqlRequest.setSql(sql); + sqlRequest.setAuthUser(userModel); + + ResultSet rs = restClient.withSearchSqlViaJDBC().executeQueryViaJDBC(sqlRequest); + Assert.assertNotNull(rs); + Assert.assertNull(sqlRequest.getErrorDetails()); + + // Set Expected Result + expectedContent = new ArrayList(); + expectedContent.add(Arrays.asList(fileBanana.getContent())); + expectedContent.add(Arrays.asList(fileYellowBanana.getContent())); + expectedContent.add(Arrays.asList(fileBigYellowBanana.getContent())); + expectedContent.add(Arrays.asList(fileYellowBananaBigBoat.getContent())); + expectedContent.add(Arrays.asList(fileBigYellowBoat.getContent())); + + Integer i = 0; + List actualContent = new ArrayList(); + + while (rs.next()) + { + // Field values are retrieved + Assert.assertNotNull(rs.getString("cm_content")); + actualContent.add(Arrays.asList(rs.getString("cm_content"))); + i++; + } + + Assert.assertTrue(i == expectedContent.size()); + Assert.assertTrue(actualContent.containsAll(expectedContent), String.format("Phrase Search Results expected: %s Actual: %s", expectedContent.toString(), actualContent.toString())); + Assert.assertTrue(expectedContent.containsAll(actualContent), String.format("Phrase Search Results expected: %s Actual: %s", expectedContent.toString(), actualContent.toString())); + + // yellow banana big boat: 6 results expected + sql = "select cm_content from alfresco where cm_content = '(yellow banana big boat)'"; + sqlRequest.setSql(sql); + sqlRequest.setAuthUser(userModel); + + rs = restClient.withSearchSqlViaJDBC().executeQueryViaJDBC(sqlRequest); + Assert.assertNotNull(rs); + Assert.assertNull(sqlRequest.getErrorDetails()); + + // Set Expected Result + expectedContent = new ArrayList(); + expectedContent.add(Arrays.asList(fileBanana.getContent())); + expectedContent.add(Arrays.asList(fileYellowBanana.getContent())); + expectedContent.add(Arrays.asList(fileBigYellowBanana.getContent())); + expectedContent.add(Arrays.asList(fileYellowBananaBigBoat.getContent())); + expectedContent.add(Arrays.asList(fileBigYellowBoat.getContent())); + expectedContent.add(Arrays.asList(fileBigBananaBoat.getContent())); + + i = 0; + actualContent = new ArrayList(); + + while (rs.next()) + { + // Field values are retrieved + Assert.assertNotNull(rs.getString("cm_content")); + actualContent.add(Arrays.asList(rs.getString("cm_content"))); + i++; + } + + Assert.assertTrue(i == expectedContent.size()); + Assert.assertTrue(actualContent.containsAll(expectedContent), String.format("Phrase Search Results expected: %s Actual: %s", expectedContent.toString(), actualContent.toString())); + Assert.assertTrue(expectedContent.containsAll(actualContent), String.format("Phrase Search Results expected: %s Actual: %s", expectedContent.toString(), actualContent.toString())); + + // big boat: 4 results expected + sql = "select cm_content from alfresco where cm_content = '(big boat)'"; + sqlRequest.setSql(sql); + sqlRequest.setAuthUser(userModel); + + rs = restClient.withSearchSqlViaJDBC().executeQueryViaJDBC(sqlRequest); + Assert.assertNotNull(rs); + Assert.assertNull(sqlRequest.getErrorDetails()); + + // Set Expected Result + expectedContent = new ArrayList(); + expectedContent.add(Arrays.asList(fileBigYellowBanana.getContent())); + expectedContent.add(Arrays.asList(fileYellowBananaBigBoat.getContent())); + expectedContent.add(Arrays.asList(fileBigYellowBoat.getContent())); + expectedContent.add(Arrays.asList(fileBigBananaBoat.getContent())); + + i = 0; + actualContent = new ArrayList(); + + while (rs.next()) + { + // Field values are retrieved + Assert.assertNotNull(rs.getString("cm_content")); + actualContent.add(Arrays.asList(rs.getString("cm_content"))); + i++; + } + + Assert.assertTrue(i == expectedContent.size()); + Assert.assertTrue(actualContent.containsAll(expectedContent), String.format("Phrase Search Results expected: %s Actual: %s", expectedContent.toString(), actualContent.toString())); + Assert.assertTrue(expectedContent.containsAll(actualContent), String.format("Phrase Search Results expected: %s Actual: %s", expectedContent.toString(), actualContent.toString())); + } +} \ No newline at end of file From f130c1990a03335fa26a49e204a3255d21e9bcb7 Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Fri, 13 Jul 2018 16:26:50 +0100 Subject: [PATCH 1380/1491] Ameded the bug status as Search build plan now runs on Alfresco Enterprise --- e2e-test/java/org/alfresco/rest/search/ShardInfoTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/ShardInfoTest.java b/e2e-test/java/org/alfresco/rest/search/ShardInfoTest.java index d4c5678c1..1922137ef 100644 --- a/e2e-test/java/org/alfresco/rest/search/ShardInfoTest.java +++ b/e2e-test/java/org/alfresco/rest/search/ShardInfoTest.java @@ -40,7 +40,7 @@ import org.testng.annotations.Test; */ public class ShardInfoTest extends AbstractSearchTest { - @Bug(id="DELENG-1", status=Bug.Status.OPENED) + @Bug(id="DELENG-1", status=Bug.Status.FIXED) @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ACS_60n}) public void getShardInfoWithAdminAuthority() throws JsonProcessingException, EmptyRestModelCollectionException { @@ -78,7 +78,7 @@ public class ShardInfoTest extends AbstractSearchTest } } - @Bug(id="DELENG-1", status=Bug.Status.OPENED) + @Bug(id="DELENG-1", status=Bug.Status.FIXED) @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ACS_60n}) public void getShardInfoWithoutAdminAuthority() throws Exception { From f3185db181dffdced11f56a76f86f51373d4e045 Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Tue, 24 Jul 2018 16:29:05 +0100 Subject: [PATCH 1381/1491] Search-874 Test Added to test that selected set of fields appear in select * queries --- .../rest/search/sql/SearchSQLAPITest.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLAPITest.java b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLAPITest.java index c251a9892..6cdedf75e 100644 --- a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLAPITest.java +++ b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLAPITest.java @@ -21,6 +21,7 @@ import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.springframework.http.HttpStatus; +import org.testng.Assert; import org.testng.annotations.Test; import org.hamcrest.Matchers; @@ -624,7 +625,34 @@ public class SearchSQLAPITest extends AbstractSearchTest response = searchSql(sqlRequest); restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.onResponse().assertThat().body("result-set.docs[0].aliases.cm_name", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("result-set.docs[0].aliases.cm_created", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("result-set.docs[0].aliases.cm_creator", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("result-set.docs[0].aliases.cm_modified", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("result-set.docs[0].aliases.cm_modifier", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("result-set.docs[0].aliases.cm_owner", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("result-set.docs[0].aliases.OWNER", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("result-set.docs[0].aliases.TYPE", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("result-set.docs[0].aliases.LID", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("result-set.docs[0].aliases.DBID", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("result-set.docs[0].aliases.cm_title", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("result-set.docs[0].aliases.cm_description", Matchers.notNullValue()); + + // This type of assertion is required because of a '.' in the field name + Assert.assertTrue(response.getResponse().body().jsonPath().get("result-set.docs[0].aliases").toString().contains("cm_content.size=cm_content.size")); + Assert.assertTrue(response.getResponse().body().jsonPath().get("result-set.docs[0].aliases").toString().contains("cm_content.mimetype=cm_content.mimetype")); + Assert.assertTrue(response.getResponse().body().jsonPath().get("result-set.docs[0].aliases").toString().contains("cm_content.encoding=cm_content.encoding")); + Assert.assertTrue(response.getResponse().body().jsonPath().get("result-set.docs[0].aliases").toString().contains("cm_content.locale=cm_content.locale")); + + restClient.onResponse().assertThat().body("result-set.docs[0].aliases.cm_lockOwner", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("result-set.docs[0].aliases.SITE", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("result-set.docs[0].aliases.PARENT", Matchers.notNullValue()); restClient.onResponse().assertThat().body("result-set.docs[0].aliases.PATH", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("result-set.docs[0].aliases.PRIMARYPARENT", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("result-set.docs[0].aliases.ASPECT", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("result-set.docs[0].aliases.QNAME", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("result-set.docs[0].aliases.cm_content", Matchers.nullValue()); + restClient.onResponse().assertThat().body("result-set.docs[0].aliases.RandomNonExistentField", Matchers.nullValue()); } @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 15) From d2461300da7149b8edee7b39bb14e91b5604471a Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Tue, 24 Jul 2018 16:34:23 +0100 Subject: [PATCH 1382/1491] Search-874 Comment added --- .../java/org/alfresco/rest/search/sql/SearchSQLAPITest.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLAPITest.java b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLAPITest.java index 6cdedf75e..20c23179e 100644 --- a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLAPITest.java +++ b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLAPITest.java @@ -651,6 +651,8 @@ public class SearchSQLAPITest extends AbstractSearchTest restClient.onResponse().assertThat().body("result-set.docs[0].aliases.PRIMARYPARENT", Matchers.notNullValue()); restClient.onResponse().assertThat().body("result-set.docs[0].aliases.ASPECT", Matchers.notNullValue()); restClient.onResponse().assertThat().body("result-set.docs[0].aliases.QNAME", Matchers.notNullValue()); + + // Test that cm_content and any other random field does not appear in the response restClient.onResponse().assertThat().body("result-set.docs[0].aliases.cm_content", Matchers.nullValue()); restClient.onResponse().assertThat().body("result-set.docs[0].aliases.RandomNonExistentField", Matchers.nullValue()); } From d9dcb487c5f5e539d75cdb09f62109e8f01840d3 Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Mon, 30 Jul 2018 12:22:16 +0100 Subject: [PATCH 1383/1491] Search-744 Removed the annotation @Bug, as the related issue is fixed --- e2e-test/java/org/alfresco/rest/search/ShardInfoTest.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/ShardInfoTest.java b/e2e-test/java/org/alfresco/rest/search/ShardInfoTest.java index 1922137ef..7e9242f8c 100644 --- a/e2e-test/java/org/alfresco/rest/search/ShardInfoTest.java +++ b/e2e-test/java/org/alfresco/rest/search/ShardInfoTest.java @@ -40,7 +40,6 @@ import org.testng.annotations.Test; */ public class ShardInfoTest extends AbstractSearchTest { - @Bug(id="DELENG-1", status=Bug.Status.FIXED) @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ACS_60n}) public void getShardInfoWithAdminAuthority() throws JsonProcessingException, EmptyRestModelCollectionException { @@ -78,7 +77,6 @@ public class ShardInfoTest extends AbstractSearchTest } } - @Bug(id="DELENG-1", status=Bug.Status.FIXED) @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ACS_60n}) public void getShardInfoWithoutAdminAuthority() throws Exception { From ef7528dbfaa930e8672c4007e5d73d353e01805e Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Mon, 30 Jul 2018 12:25:37 +0100 Subject: [PATCH 1384/1491] Revert "Search-744 Removed the annotation @Bug, as the related issue is fixed" This reverts commit 5148303ac4f6aac2e60722b50a285b31e88969c1. --- e2e-test/java/org/alfresco/rest/search/ShardInfoTest.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/search/ShardInfoTest.java b/e2e-test/java/org/alfresco/rest/search/ShardInfoTest.java index 7e9242f8c..1922137ef 100644 --- a/e2e-test/java/org/alfresco/rest/search/ShardInfoTest.java +++ b/e2e-test/java/org/alfresco/rest/search/ShardInfoTest.java @@ -40,6 +40,7 @@ import org.testng.annotations.Test; */ public class ShardInfoTest extends AbstractSearchTest { + @Bug(id="DELENG-1", status=Bug.Status.FIXED) @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ACS_60n}) public void getShardInfoWithAdminAuthority() throws JsonProcessingException, EmptyRestModelCollectionException { @@ -77,6 +78,7 @@ public class ShardInfoTest extends AbstractSearchTest } } + @Bug(id="DELENG-1", status=Bug.Status.FIXED) @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ACS_60n}) public void getShardInfoWithoutAdminAuthority() throws Exception { From 24d1db3ba3774ee394c239c006cc07b4377e130b Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Mon, 30 Jul 2018 12:26:38 +0100 Subject: [PATCH 1385/1491] Search-744 Removed the annotation @Bug, as the related issue is fixed --- e2e-test/java/org/alfresco/rest/search/ShardInfoTest.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/ShardInfoTest.java b/e2e-test/java/org/alfresco/rest/search/ShardInfoTest.java index 1922137ef..7e9242f8c 100644 --- a/e2e-test/java/org/alfresco/rest/search/ShardInfoTest.java +++ b/e2e-test/java/org/alfresco/rest/search/ShardInfoTest.java @@ -40,7 +40,6 @@ import org.testng.annotations.Test; */ public class ShardInfoTest extends AbstractSearchTest { - @Bug(id="DELENG-1", status=Bug.Status.FIXED) @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ACS_60n}) public void getShardInfoWithAdminAuthority() throws JsonProcessingException, EmptyRestModelCollectionException { @@ -78,7 +77,6 @@ public class ShardInfoTest extends AbstractSearchTest } } - @Bug(id="DELENG-1", status=Bug.Status.FIXED) @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ACS_60n}) public void getShardInfoWithoutAdminAuthority() throws Exception { From 9954d01ac76ec71f08dd791565e296ee7252e77b Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Tue, 7 Aug 2018 16:36:57 +0100 Subject: [PATCH 1386/1491] Search-744 Removing unused imports --- e2e-test/java/org/alfresco/rest/search/ShardInfoTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/search/ShardInfoTest.java b/e2e-test/java/org/alfresco/rest/search/ShardInfoTest.java index 7e9242f8c..410779581 100644 --- a/e2e-test/java/org/alfresco/rest/search/ShardInfoTest.java +++ b/e2e-test/java/org/alfresco/rest/search/ShardInfoTest.java @@ -29,7 +29,6 @@ import com.fasterxml.jackson.core.JsonProcessingException; import org.alfresco.rest.exception.EmptyRestModelCollectionException; import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.report.Bug; import org.springframework.http.HttpStatus; import org.testng.annotations.Test; From 7d8bf95dd051698ce1c2369903a32dd0e68624d3 Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Wed, 8 Aug 2018 16:18:04 +0100 Subject: [PATCH 1387/1491] Added missing step to repeat search --- e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java index c8463c0ac..bf6fc30f7 100644 --- a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java @@ -182,6 +182,9 @@ public class AbstractSearchTest extends RestTest { // Wait for the solr indexing. Utility.waitToLoopTime(properties.getSolrWaitTimeInSeconds(), "Wait For Indexing"); + + // Repeat Search + response = query(searchRequest); } if (restClient.getStatusCode().matches(expectedStatusCode)) From d0fc3c1683975c5e566913d82be99af1f1cf0f4f Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Thu, 9 Aug 2018 15:05:05 +0100 Subject: [PATCH 1388/1491] Search-999 Simplified repeat search --- .../rest/search/AbstractSearchTest.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java index c8463c0ac..4fb099fe4 100644 --- a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java @@ -166,23 +166,17 @@ public class AbstractSearchTest extends RestTest * @return true (indexing is finished) if search returns appropriate results * @throws Exception */ - public boolean waitForIndexing(String userQuery, Boolean expectedInResults) throws Exception + public boolean waitForIndexing(String userQuery, boolean expectedInResults) throws Exception { - Boolean found = false; - Boolean resultAsExpected = false; + boolean found = false; + boolean resultAsExpected = false; String expectedStatusCode = HttpStatus.OK.toString(); - SearchRequest searchRequest = createQuery(userQuery); - SearchResponse response = query(searchRequest); - // Repeat search until the query results are as expected or Search Retry count is hit for (int searchCount = 1; searchCount <= 3; searchCount++) { - if (searchCount > 1) - { - // Wait for the solr indexing. - Utility.waitToLoopTime(properties.getSolrWaitTimeInSeconds(), "Wait For Indexing"); - } + SearchRequest searchRequest = createQuery(userQuery); + SearchResponse response = query(searchRequest); if (restClient.getStatusCode().matches(expectedStatusCode)) { @@ -196,11 +190,17 @@ public class AbstractSearchTest extends RestTest } // Loop again if result is not as expected: To cater for solr lag: eventual consistency - resultAsExpected = (expectedInResults.equals(found)); + resultAsExpected = (expectedInResults == found); + if (resultAsExpected) { break; } + else + { + // Wait for the solr indexing. + Utility.waitToLoopTime(properties.getSolrWaitTimeInSeconds(), "Wait For Indexing"); + } } else { From 228efef0da1a7f00cd63d2c81a032d19f68fdf4b Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Thu, 9 Aug 2018 15:54:40 +0100 Subject: [PATCH 1389/1491] Revert "Search-999 Simplified repeat search" This reverts commit 100dc80a9601b90f2098b73c2c6ac0da77ecce5f. --- .../rest/search/AbstractSearchTest.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java index 4fb099fe4..c8463c0ac 100644 --- a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java @@ -166,17 +166,23 @@ public class AbstractSearchTest extends RestTest * @return true (indexing is finished) if search returns appropriate results * @throws Exception */ - public boolean waitForIndexing(String userQuery, boolean expectedInResults) throws Exception + public boolean waitForIndexing(String userQuery, Boolean expectedInResults) throws Exception { - boolean found = false; - boolean resultAsExpected = false; + Boolean found = false; + Boolean resultAsExpected = false; String expectedStatusCode = HttpStatus.OK.toString(); + SearchRequest searchRequest = createQuery(userQuery); + SearchResponse response = query(searchRequest); + // Repeat search until the query results are as expected or Search Retry count is hit for (int searchCount = 1; searchCount <= 3; searchCount++) { - SearchRequest searchRequest = createQuery(userQuery); - SearchResponse response = query(searchRequest); + if (searchCount > 1) + { + // Wait for the solr indexing. + Utility.waitToLoopTime(properties.getSolrWaitTimeInSeconds(), "Wait For Indexing"); + } if (restClient.getStatusCode().matches(expectedStatusCode)) { @@ -190,17 +196,11 @@ public class AbstractSearchTest extends RestTest } // Loop again if result is not as expected: To cater for solr lag: eventual consistency - resultAsExpected = (expectedInResults == found); - + resultAsExpected = (expectedInResults.equals(found)); if (resultAsExpected) { break; } - else - { - // Wait for the solr indexing. - Utility.waitToLoopTime(properties.getSolrWaitTimeInSeconds(), "Wait For Indexing"); - } } else { From bc349c128dbf67d7d7664c914fdd9fa585afd2ef Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Thu, 9 Aug 2018 16:01:08 +0100 Subject: [PATCH 1390/1491] Search-999 Simplified waitForIndexing --- .../rest/search/AbstractSearchTest.java | 26 ++++++++----------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java index bf6fc30f7..e8a0f955c 100644 --- a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java @@ -166,26 +166,17 @@ public class AbstractSearchTest extends RestTest * @return true (indexing is finished) if search returns appropriate results * @throws Exception */ - public boolean waitForIndexing(String userQuery, Boolean expectedInResults) throws Exception + public boolean waitForIndexing(String userQuery, boolean expectedInResults) throws Exception { - Boolean found = false; - Boolean resultAsExpected = false; + boolean found = false; + boolean resultAsExpected = false; String expectedStatusCode = HttpStatus.OK.toString(); - SearchRequest searchRequest = createQuery(userQuery); - SearchResponse response = query(searchRequest); - // Repeat search until the query results are as expected or Search Retry count is hit for (int searchCount = 1; searchCount <= 3; searchCount++) { - if (searchCount > 1) - { - // Wait for the solr indexing. - Utility.waitToLoopTime(properties.getSolrWaitTimeInSeconds(), "Wait For Indexing"); - - // Repeat Search - response = query(searchRequest); - } + SearchRequest searchRequest = createQuery(userQuery); + SearchResponse response = query(searchRequest); if (restClient.getStatusCode().matches(expectedStatusCode)) { @@ -199,11 +190,16 @@ public class AbstractSearchTest extends RestTest } // Loop again if result is not as expected: To cater for solr lag: eventual consistency - resultAsExpected = (expectedInResults.equals(found)); + resultAsExpected = (expectedInResults == found); if (resultAsExpected) { break; } + else + { + // Wait for the solr indexing. + Utility.waitToLoopTime(properties.getSolrWaitTimeInSeconds(), "Wait For Indexing"); + } } else { From c85c9563cff266ea89c96cb059ef44b66ed86418 Mon Sep 17 00:00:00 2001 From: Alex Mukha Date: Thu, 20 Sep 2018 23:03:51 +0100 Subject: [PATCH 1391/1491] REPO-3766 Make avatar check async --- .../org/alfresco/rest/people/AvatarPeopleSanityTest.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/AvatarPeopleSanityTest.java b/e2e-test/java/org/alfresco/rest/people/AvatarPeopleSanityTest.java index 9e0dad67f..2476373a0 100644 --- a/e2e-test/java/org/alfresco/rest/people/AvatarPeopleSanityTest.java +++ b/e2e-test/java/org/alfresco/rest/people/AvatarPeopleSanityTest.java @@ -37,8 +37,12 @@ public class AvatarPeopleSanityTest extends RestTest restClient.authenticateUser(userModel); ValidatableResponse response = restClient.withCoreAPI().usingAuthUser() .uploadAvatarContent(restProperties.envProperty().getFullServerUrl(), avatarFile).statusCode(200); - restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().downloadAvatarContent(); - restClient.assertStatusCodeIs(HttpStatus.OK); + // Renditions are async + Utility.sleep(200, 2000, () -> + { + restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().downloadAvatarContent(); + restClient.assertStatusCodeIs(HttpStatus.OK); + }); assertNotNull(response.extract().body().asByteArray()); assertTrue(response.extract().body().asByteArray().length > 0, "Avatar Image not uploaded"); } From 283e2c550a58a5451a01020b803590db34eb5d20 Mon Sep 17 00:00:00 2001 From: Alex Mukha Date: Sat, 22 Sep 2018 11:22:54 +0100 Subject: [PATCH 1392/1491] REPO-3766 Disable test for MM --- .../java/org/alfresco/rest/discovery/DiscoveryTests.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/discovery/DiscoveryTests.java b/e2e-test/java/org/alfresco/rest/discovery/DiscoveryTests.java index b6a1911c0..76a9e3639 100644 --- a/e2e-test/java/org/alfresco/rest/discovery/DiscoveryTests.java +++ b/e2e-test/java/org/alfresco/rest/discovery/DiscoveryTests.java @@ -74,12 +74,13 @@ public class DiscoveryTests extends RestTest assertTrue(modules.contains("alfresco-share-services")); assertTrue(modules.contains("alfresco-saml-repo")); assertTrue(modules.contains("org_alfresco_device_sync_repo")); - assertTrue(modules.contains("org_alfresco_mm_repo")); + // The MM does not support new RenditionService2 +// assertTrue(modules.contains("org_alfresco_mm_repo")); assertTrue(modules.contains("org.alfresco.module.TransformationServer")); // Check that all installed modules are in INSTALLED state List modulesStates = restClient.onResponse().getResponse().jsonPath().getList("entry.repository.modules.installState", String.class); - assertEquals(Collections.frequency(modulesStates, "INSTALLED"), 11); + assertEquals(Collections.frequency(modulesStates, "INSTALLED"), 10); } @Test(groups = { TestGroup.REST_API, TestGroup.DISCOVERY, TestGroup.SANITY, TestGroup.CORE }) From 9d27f88a2df274f18b0bddada5c3ba44dd670abe Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Thu, 27 Sep 2018 11:52:43 +0100 Subject: [PATCH 1393/1491] Search-999 Added missing step to repeat search --- .../rest/search/AbstractSearchTest.java | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java index c8463c0ac..e8a0f955c 100644 --- a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java @@ -166,23 +166,17 @@ public class AbstractSearchTest extends RestTest * @return true (indexing is finished) if search returns appropriate results * @throws Exception */ - public boolean waitForIndexing(String userQuery, Boolean expectedInResults) throws Exception + public boolean waitForIndexing(String userQuery, boolean expectedInResults) throws Exception { - Boolean found = false; - Boolean resultAsExpected = false; + boolean found = false; + boolean resultAsExpected = false; String expectedStatusCode = HttpStatus.OK.toString(); - SearchRequest searchRequest = createQuery(userQuery); - SearchResponse response = query(searchRequest); - // Repeat search until the query results are as expected or Search Retry count is hit for (int searchCount = 1; searchCount <= 3; searchCount++) { - if (searchCount > 1) - { - // Wait for the solr indexing. - Utility.waitToLoopTime(properties.getSolrWaitTimeInSeconds(), "Wait For Indexing"); - } + SearchRequest searchRequest = createQuery(userQuery); + SearchResponse response = query(searchRequest); if (restClient.getStatusCode().matches(expectedStatusCode)) { @@ -196,11 +190,16 @@ public class AbstractSearchTest extends RestTest } // Loop again if result is not as expected: To cater for solr lag: eventual consistency - resultAsExpected = (expectedInResults.equals(found)); + resultAsExpected = (expectedInResults == found); if (resultAsExpected) { break; } + else + { + // Wait for the solr indexing. + Utility.waitToLoopTime(properties.getSolrWaitTimeInSeconds(), "Wait For Indexing"); + } } else { From 4a0fc8ce1a868b72bfc7be2c4d921c9474b54dc1 Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Thu, 27 Sep 2018 15:36:00 +0100 Subject: [PATCH 1394/1491] Search-646: Implemented support to fields required for Search-646 + test --- .../org/alfresco/rest/search/SearchTest.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/search/SearchTest.java b/e2e-test/java/org/alfresco/rest/search/SearchTest.java index b1a285c6c..76cf231d9 100644 --- a/e2e-test/java/org/alfresco/rest/search/SearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/SearchTest.java @@ -18,9 +18,13 @@ */ package org.alfresco.rest.search; +import java.util.ArrayList; +import java.util.List; + import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; +import org.hamcrest.Matchers; import org.springframework.http.HttpStatus; import org.testng.annotations.Test; @@ -70,5 +74,30 @@ public class SearchTest extends AbstractSearchTest response.getContext().assertThat().field("request").isNotEmpty(); } + + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) + @TestRail(section = { TestGroup.REST_API, TestGroup.SEARCH, + TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, description = "Checks that only restricted fields appear in the response") + public void searchWithFields() throws Exception + { + SearchRequest query = new SearchRequest(); + RestRequestQueryModel queryReq = new RestRequestQueryModel(); + queryReq.setQuery("alfresco"); + query.setQuery(queryReq); + + // Restrict to fields + List fields = new ArrayList(); + fields.add("parentId"); + query.setFields(fields); + + query(query); + restClient.assertStatusCodeIs(HttpStatus.OK); + + // Only Field parentId is included in the response + restClient.onResponse().assertThat().body("list.entries.entry[0].parentId", Matchers.notNullValue()); + // Usual Fields such as 'name, id' aren't included in the response + restClient.onResponse().assertThat().body("list.entries.entry[0].name", Matchers.nullValue()); + restClient.onResponse().assertThat().body("list.entries.entry[0].id", Matchers.nullValue()); + } } From aa1affdf1d5b4ce2b748492dbca351f78df001de Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Thu, 27 Sep 2018 15:44:31 +0100 Subject: [PATCH 1395/1491] Comment added, Removed the TestRail annotation as not required --- e2e-test/java/org/alfresco/rest/search/SearchTest.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/SearchTest.java b/e2e-test/java/org/alfresco/rest/search/SearchTest.java index 76cf231d9..37a8d0fd0 100644 --- a/e2e-test/java/org/alfresco/rest/search/SearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/SearchTest.java @@ -75,9 +75,8 @@ public class SearchTest extends AbstractSearchTest response.getContext().assertThat().field("request").isNotEmpty(); } + // Test that when fields parameter is set, only restricted fields appear in the response @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) - @TestRail(section = { TestGroup.REST_API, TestGroup.SEARCH, - TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, description = "Checks that only restricted fields appear in the response") public void searchWithFields() throws Exception { SearchRequest query = new SearchRequest(); @@ -85,7 +84,7 @@ public class SearchTest extends AbstractSearchTest queryReq.setQuery("alfresco"); query.setQuery(queryReq); - // Restrict to fields + // Restrict to fields: parentId List fields = new ArrayList(); fields.add("parentId"); query.setFields(fields); From 36e7bb7f4df04d64e32edd52a4b0ce4b14194e3b Mon Sep 17 00:00:00 2001 From: Tuna Aksoy Date: Mon, 1 Oct 2018 10:18:04 +0100 Subject: [PATCH 1396/1491] Search 1076 --- .../rest/search/solr/SearchSolrAPITest.java | 121 ++++++++++++++++++ e2e-test/resources/SearchSuite.xml | 14 ++ e2e-test/resources/default.properties | 5 + 3 files changed, 140 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/search/solr/SearchSolrAPITest.java diff --git a/e2e-test/java/org/alfresco/rest/search/solr/SearchSolrAPITest.java b/e2e-test/java/org/alfresco/rest/search/solr/SearchSolrAPITest.java new file mode 100644 index 000000000..77dee8757 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/search/solr/SearchSolrAPITest.java @@ -0,0 +1,121 @@ +/* + * Copyright (C) 2018 Alfresco Software Limited. + * This file is part of Alfresco + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.rest.search.solr; + +import java.net.URLEncoder; + +import javax.json.JsonArrayBuilder; + +import org.alfresco.rest.core.JsonBodyGenerator; +import org.alfresco.rest.model.RestTextResponse; +import org.alfresco.rest.search.AbstractSearchTest; +import org.alfresco.utility.model.TestGroup; +import org.hamcrest.Matchers; +import org.springframework.http.HttpStatus; +import org.testng.annotations.Test; + +import junit.framework.Assert; + +/** + * Tests for solr/alfresco Solr API. + * + * @author Meenal Bhave + */ +public class SearchSolrAPITest extends AbstractSearchTest +{ + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API }, priority = 01) + public void testGetSolrConfig() throws Exception + { + RestTextResponse response = restClient.authenticateUser(adminUserModel).withSolrAPI().getConfig(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + restClient.onResponse().assertThat().content(Matchers.containsString("config")); + Assert.assertNotNull(response.getJsonValueByPath("config.requestHandler")); + Assert.assertNotNull(response.getJsonObjectByPath("config.requestHandler")); + + // TODO: Following asserts fail with error: + /* + * java.lang.IllegalStateException: Expected response body to be verified as JSON, HTML or XML but content-type 'text/plain' is not supported out of the box. + * Try registering a custom parser using: RestAssured.registerParser("text/plain", ); + */ + + // response.assertThat().body("config.requestHandler", Matchers.notNullValue()); + // restClient.onResponse().assertThat().body("config.requestHandler",Matchers.notNullValue()); + } + + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API }, priority = 02) + public void testEditSolrConfig() throws Exception + { + String expectedError = "solrconfig editing is not enabled due to disable.configEdit"; + + JsonArrayBuilder argsArray = JsonBodyGenerator.defineJSONArray(); + argsArray.add("ANYARGS"); + + String postBody = JsonBodyGenerator.defineJSON() + .add("add-listener", JsonBodyGenerator.defineJSON() + .add("event", "postCommit") + .add("name", "newlistener") + .add("class", "solr.RunExecutableListener") + .add("exe", "ANYCOMMAND") + .add("dir", "/usr/bin/") + .add("args", argsArray)).build().toString(); + + // RestTextResponse response = + restClient.authenticateUser(adminUserModel).withSolrAPI().postConfig(postBody); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + + restClient.onResponse().assertThat().content(Matchers.containsString(expectedError)); + + // TODO: Following asserts fail with error: + /* + * java.lang.IllegalStateException: Expected response body to be verified as JSON, HTML or XML but content-type 'text/plain' is not supported out of the box. + * Try registering a custom parser using: RestAssured.registerParser("text/plain", ); + */ + + // response.assertThat().body("error.msg", Matchers.contains(expectedError)); + } + + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API }, priority = 03) + public void testGetSolrConfigOverlay() throws Exception + { + restClient.authenticateUser(adminUserModel).withSolrAPI().getConfigOverlay(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + restClient.onResponse().assertThat().content(Matchers.containsString("overlay")); + } + + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API }, priority = 04) + public void testGetSolrConfigParams() throws Exception + { + restClient.authenticateUser(adminUserModel).withSolrAPI().getConfigParams(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + restClient.onResponse().assertThat().content(Matchers.containsString("response")); + } + + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API }, priority = 05) + public void testGetSolrSelect() throws Exception + { + String queryParams = "{!xmlparser v=''}"; + + String encodedQueryParams = URLEncoder.encode(queryParams, "UTF-8"); + + restClient.authenticateUser(dataContent.getAdminUser()).withParams(encodedQueryParams).withSolrAPI().getSelectQuery(); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + String errorMsg = "No QueryObjectBuilder defined for node a in {q={!xmlparser"; + Assert.assertTrue(restClient.onResponse().getResponse().body().xmlPath().getString("response").contains(errorMsg)); + } +} \ No newline at end of file diff --git a/e2e-test/resources/SearchSuite.xml b/e2e-test/resources/SearchSuite.xml index 34bc53bb6..9bfd55eea 100644 --- a/e2e-test/resources/SearchSuite.xml +++ b/e2e-test/resources/SearchSuite.xml @@ -32,4 +32,18 @@ + + + + + + + + + + + + + + diff --git a/e2e-test/resources/default.properties b/e2e-test/resources/default.properties index b44ef9b4a..40fcb40dc 100644 --- a/e2e-test/resources/default.properties +++ b/e2e-test/resources/default.properties @@ -8,6 +8,11 @@ sync.scheme=http sync.server=localhost sync.port=9090 +# Solr Server Settings +solr.scheme=http +solr.server=localhost +solr.port=8083 + #Solr Indexing Time solrWaitTimeInSeconds=20 From defd7342909879fcdc4830dea59e491de39284d0 Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Mon, 1 Oct 2018 11:00:43 +0100 Subject: [PATCH 1397/1491] Search:1076: Annotated tests that need min version as ASS 1.1.2 --- .../alfresco/rest/search/solr/SearchSolrAPITest.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/solr/SearchSolrAPITest.java b/e2e-test/java/org/alfresco/rest/search/solr/SearchSolrAPITest.java index 77dee8757..1aaeb6dab 100644 --- a/e2e-test/java/org/alfresco/rest/search/solr/SearchSolrAPITest.java +++ b/e2e-test/java/org/alfresco/rest/search/solr/SearchSolrAPITest.java @@ -35,7 +35,7 @@ import junit.framework.Assert; */ public class SearchSolrAPITest extends AbstractSearchTest { - @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API }, priority = 01) + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_112 }, priority = 01) public void testGetSolrConfig() throws Exception { RestTextResponse response = restClient.authenticateUser(adminUserModel).withSolrAPI().getConfig(); @@ -55,7 +55,7 @@ public class SearchSolrAPITest extends AbstractSearchTest // restClient.onResponse().assertThat().body("config.requestHandler",Matchers.notNullValue()); } - @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API }, priority = 02) + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_112 }, priority = 02) public void testEditSolrConfig() throws Exception { String expectedError = "solrconfig editing is not enabled due to disable.configEdit"; @@ -87,7 +87,7 @@ public class SearchSolrAPITest extends AbstractSearchTest // response.assertThat().body("error.msg", Matchers.contains(expectedError)); } - @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API }, priority = 03) + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_112 }, priority = 03) public void testGetSolrConfigOverlay() throws Exception { restClient.authenticateUser(adminUserModel).withSolrAPI().getConfigOverlay(); @@ -96,7 +96,7 @@ public class SearchSolrAPITest extends AbstractSearchTest restClient.onResponse().assertThat().content(Matchers.containsString("overlay")); } - @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API }, priority = 04) + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_112 }, priority = 04) public void testGetSolrConfigParams() throws Exception { restClient.authenticateUser(adminUserModel).withSolrAPI().getConfigParams(); @@ -105,7 +105,7 @@ public class SearchSolrAPITest extends AbstractSearchTest restClient.onResponse().assertThat().content(Matchers.containsString("response")); } - @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API }, priority = 05) + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_112 }, priority = 05) public void testGetSolrSelect() throws Exception { String queryParams = "{!xmlparser v=''}"; From 4e10666bd9acc83c003a16fc1cac63f2c7f54a5f Mon Sep 17 00:00:00 2001 From: Alan Davis Date: Fri, 12 Oct 2018 09:18:01 +0100 Subject: [PATCH 1398/1491] REPO-3690 TAS tests need to wait longer for renditions as they are async and can be more than 2 seconds if done by Transform Service. --- .../alfresco/rest/people/AvatarPeopleSanityTest.java | 2 +- .../rest/renditions/CreateRenditionTests.java | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/AvatarPeopleSanityTest.java b/e2e-test/java/org/alfresco/rest/people/AvatarPeopleSanityTest.java index 2476373a0..73aae3bdf 100644 --- a/e2e-test/java/org/alfresco/rest/people/AvatarPeopleSanityTest.java +++ b/e2e-test/java/org/alfresco/rest/people/AvatarPeopleSanityTest.java @@ -38,7 +38,7 @@ public class AvatarPeopleSanityTest extends RestTest ValidatableResponse response = restClient.withCoreAPI().usingAuthUser() .uploadAvatarContent(restProperties.envProperty().getFullServerUrl(), avatarFile).statusCode(200); // Renditions are async - Utility.sleep(200, 2000, () -> + Utility.sleep(500, 60000, () -> { restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().downloadAvatarContent(); restClient.assertStatusCodeIs(HttpStatus.OK); diff --git a/e2e-test/java/org/alfresco/rest/renditions/CreateRenditionTests.java b/e2e-test/java/org/alfresco/rest/renditions/CreateRenditionTests.java index fdd0f131b..a63661f0c 100644 --- a/e2e-test/java/org/alfresco/rest/renditions/CreateRenditionTests.java +++ b/e2e-test/java/org/alfresco/rest/renditions/CreateRenditionTests.java @@ -19,6 +19,8 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; +import static java.lang.Thread.sleep; + /** * Handles tests related to POST api-explorer/#!/renditions * @author Cristina Axinte @@ -90,8 +92,12 @@ public class CreateRenditionTests extends RestTest restClient.authenticateUser(user).withCoreAPI().usingNode(document).createNodeRendition("doclib"); restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); - - restClient.withCoreAPI().usingNode(document).getNodeRenditionUntilIsCreated("doclib") - .assertThat().field("status").is("CREATED"); + + // Renditions are async + Utility.sleep(500, 60000, () -> + { + restClient.withCoreAPI().usingNode(document).getNodeRenditionUntilIsCreated("doclib") + .assertThat().field("status").is("CREATED"); + } } } From c27379d8793ef2e242cd8c82b4db41f87549b000 Mon Sep 17 00:00:00 2001 From: Alexandru Epure Date: Fri, 12 Oct 2018 13:09:19 +0100 Subject: [PATCH 1399/1491] =?UTF-8?q?Revert=20"REPO-3690=20TAS=20tests=20n?= =?UTF-8?q?eed=20to=20wait=20longer=20for=20renditions=20as=20they=20are?= =?UTF-8?q?=20async=20and=20can=E2=80=A6"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 385f002eba84be6e8e43b9ac16d9a7db65b6c4a6 --- .../alfresco/rest/people/AvatarPeopleSanityTest.java | 2 +- .../rest/renditions/CreateRenditionTests.java | 12 +++--------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/AvatarPeopleSanityTest.java b/e2e-test/java/org/alfresco/rest/people/AvatarPeopleSanityTest.java index 73aae3bdf..2476373a0 100644 --- a/e2e-test/java/org/alfresco/rest/people/AvatarPeopleSanityTest.java +++ b/e2e-test/java/org/alfresco/rest/people/AvatarPeopleSanityTest.java @@ -38,7 +38,7 @@ public class AvatarPeopleSanityTest extends RestTest ValidatableResponse response = restClient.withCoreAPI().usingAuthUser() .uploadAvatarContent(restProperties.envProperty().getFullServerUrl(), avatarFile).statusCode(200); // Renditions are async - Utility.sleep(500, 60000, () -> + Utility.sleep(200, 2000, () -> { restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().downloadAvatarContent(); restClient.assertStatusCodeIs(HttpStatus.OK); diff --git a/e2e-test/java/org/alfresco/rest/renditions/CreateRenditionTests.java b/e2e-test/java/org/alfresco/rest/renditions/CreateRenditionTests.java index a63661f0c..fdd0f131b 100644 --- a/e2e-test/java/org/alfresco/rest/renditions/CreateRenditionTests.java +++ b/e2e-test/java/org/alfresco/rest/renditions/CreateRenditionTests.java @@ -19,8 +19,6 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import static java.lang.Thread.sleep; - /** * Handles tests related to POST api-explorer/#!/renditions * @author Cristina Axinte @@ -92,12 +90,8 @@ public class CreateRenditionTests extends RestTest restClient.authenticateUser(user).withCoreAPI().usingNode(document).createNodeRendition("doclib"); restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); - - // Renditions are async - Utility.sleep(500, 60000, () -> - { - restClient.withCoreAPI().usingNode(document).getNodeRenditionUntilIsCreated("doclib") - .assertThat().field("status").is("CREATED"); - } + + restClient.withCoreAPI().usingNode(document).getNodeRenditionUntilIsCreated("doclib") + .assertThat().field("status").is("CREATED"); } } From 42f945f1785dc25e32dc86bf96056304c4bc7b68 Mon Sep 17 00:00:00 2001 From: Andrei Zapodeanu Date: Mon, 15 Oct 2018 09:40:01 +0100 Subject: [PATCH 1400/1491] REPO-3718 Service Pack: MNT-19833: Download via v1 REST API loaded in memory --- .../nodes/NodesContentAndVersioningTests.java | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/nodes/NodesContentAndVersioningTests.java b/e2e-test/java/org/alfresco/rest/nodes/NodesContentAndVersioningTests.java index f9eb55734..2b66113bd 100644 --- a/e2e-test/java/org/alfresco/rest/nodes/NodesContentAndVersioningTests.java +++ b/e2e-test/java/org/alfresco/rest/nodes/NodesContentAndVersioningTests.java @@ -10,6 +10,8 @@ import static org.testng.Assert.assertSame; import static org.testng.Assert.assertTrue; import java.io.File; +import java.io.IOException; +import java.io.RandomAccessFile; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; @@ -19,6 +21,7 @@ import org.alfresco.rest.model.RestNodeModel; import org.alfresco.rest.model.RestVersionModel; import org.alfresco.rest.model.RestVersionModelsCollection; import org.alfresco.rest.model.body.RestNodeLockBodyModel; +import org.alfresco.util.TempFileProvider; import org.alfresco.utility.Utility; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FileType; @@ -30,6 +33,7 @@ import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.json.JSONObject; +import org.junit.Ignore; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -112,6 +116,37 @@ public class NodesContentAndVersioningTests extends RestTest restClient.withCoreAPI().usingNode(iso8859File).getNodeContent().assertThat().contentType(iso8859Type); } + + @Ignore("This test takes around 30 minutes to complete so it will be ignored by default.") + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, + executionType = ExecutionType.REGRESSION, description = "Verify that the node content is streamed directly to the client and not buffered in memory.") + public void verifyUploadDownloadLargeFileUsingRestAPI() throws Exception + { + Integer largeFileSizeBytes = Integer.MAX_VALUE; + String largeFileName = "largeFile.tmp"; + String tempFolderPath = TempFileProvider.getTempDir().getAbsolutePath(); + + STEP("1. Create a folder and a large file"); + FolderModel folder = dataContent.usingUser(user1).usingSite(site1).createFolder(FolderModel.getRandomFolderModel()); + createRandomFileInDirectory(tempFolderPath, largeFileName, largeFileSizeBytes); + + STEP("2. Using multipart data upload for the large file (POST nodes/{nodeId}/children)."); + File largeFile = new File(tempFolderPath, largeFileName); + FileModel largeFileModel = new FileModel(largeFileName, FileType.UNDEFINED); + restClient.authenticateUser(user1).configureRequestSpec().addMultiPart("filedata", largeFile); + RestNodeModel fileNode = restClient.withCoreAPI().usingNode(folder).createNode(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + largeFileModel.setNodeRef(fileNode.getId()); + + STEP("3. Retrieve the content of the node without running out of memory (GET nodes/{nodeId}/content)."); + RestResponse nodeContent = restClient.withCoreAPI().usingNode(largeFileModel).getNodeContent(); + restClient.assertStatusCodeIs(HttpStatus.OK); + assertEquals(Integer.valueOf(nodeContent.getResponse().getHeader("Content-Length")), largeFileSizeBytes); + + largeFile.delete(); + } + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY }) @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.SANITY, description = "Verify updating a node content.") public void testUpdateNodeContent() throws Exception @@ -262,4 +297,13 @@ public class NodesContentAndVersioningTests extends RestTest restClient.assertHeaderValueContains("content-range", "bytes 1-10"); restClient.assertHeaderValueContains("content-length", String.valueOf(10)); } + + + private void createRandomFileInDirectory(String path, String fileName, int size) throws IOException { + String fullPath = new File(path, fileName).getPath(); + + RandomAccessFile file = new RandomAccessFile(fullPath,"rw"); + file.setLength(size); + file.close(); + } } From e71f74ab20c6d626d98464e229f0ee93b70b7d57 Mon Sep 17 00:00:00 2001 From: Andrei Zapodeanu Date: Mon, 15 Oct 2018 14:43:14 +0300 Subject: [PATCH 1401/1491] REPO-3718: MNT-19833: Download via v1 REST API loaded in memory -- ignored the test for TestNG --- .../alfresco/rest/nodes/NodesContentAndVersioningTests.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/nodes/NodesContentAndVersioningTests.java b/e2e-test/java/org/alfresco/rest/nodes/NodesContentAndVersioningTests.java index 2b66113bd..8a31ff183 100644 --- a/e2e-test/java/org/alfresco/rest/nodes/NodesContentAndVersioningTests.java +++ b/e2e-test/java/org/alfresco/rest/nodes/NodesContentAndVersioningTests.java @@ -117,8 +117,8 @@ public class NodesContentAndVersioningTests extends RestTest } - @Ignore("This test takes around 30 minutes to complete so it will be ignored by default.") - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) + // This test takes around 30 minutes to complete so it will be ignored by default + @Test(enabled=false, groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, description = "Verify that the node content is streamed directly to the client and not buffered in memory.") public void verifyUploadDownloadLargeFileUsingRestAPI() throws Exception From 4bf2f8e6da91e5b8fa6e0413d5878c7eea4a054d Mon Sep 17 00:00:00 2001 From: Alan Davis Date: Mon, 15 Oct 2018 22:37:25 +0100 Subject: [PATCH 1402/1491] REPO-3690 TAS tests need to wait longer for renditions as they are async and can be more than 2 seconds if done by Transform Service. --- .../alfresco/rest/people/AvatarPeopleSanityTest.java | 2 +- .../alfresco/rest/renditions/CreateRenditionTests.java | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/AvatarPeopleSanityTest.java b/e2e-test/java/org/alfresco/rest/people/AvatarPeopleSanityTest.java index 2476373a0..73aae3bdf 100644 --- a/e2e-test/java/org/alfresco/rest/people/AvatarPeopleSanityTest.java +++ b/e2e-test/java/org/alfresco/rest/people/AvatarPeopleSanityTest.java @@ -38,7 +38,7 @@ public class AvatarPeopleSanityTest extends RestTest ValidatableResponse response = restClient.withCoreAPI().usingAuthUser() .uploadAvatarContent(restProperties.envProperty().getFullServerUrl(), avatarFile).statusCode(200); // Renditions are async - Utility.sleep(200, 2000, () -> + Utility.sleep(500, 60000, () -> { restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().downloadAvatarContent(); restClient.assertStatusCodeIs(HttpStatus.OK); diff --git a/e2e-test/java/org/alfresco/rest/renditions/CreateRenditionTests.java b/e2e-test/java/org/alfresco/rest/renditions/CreateRenditionTests.java index fdd0f131b..4c8964aee 100644 --- a/e2e-test/java/org/alfresco/rest/renditions/CreateRenditionTests.java +++ b/e2e-test/java/org/alfresco/rest/renditions/CreateRenditionTests.java @@ -90,8 +90,12 @@ public class CreateRenditionTests extends RestTest restClient.authenticateUser(user).withCoreAPI().usingNode(document).createNodeRendition("doclib"); restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); - - restClient.withCoreAPI().usingNode(document).getNodeRenditionUntilIsCreated("doclib") - .assertThat().field("status").is("CREATED"); + + // Renditions are async + Utility.sleep(500, 60000, () -> + { + restClient.withCoreAPI().usingNode(document).getNodeRenditionUntilIsCreated("doclib") + .assertThat().field("status").is("CREATED"); + }); } } From 9a54e558749b128b87a328fd113fd261a3b3d7cc Mon Sep 17 00:00:00 2001 From: agazzarini Date: Tue, 16 Oct 2018 11:23:53 +0200 Subject: [PATCH 1403/1491] [ SEARCH-828 ] APATH faceting integration test fix --- .../alfresco/rest/search/SearchAPATHTest.java | 168 +++++++++--------- 1 file changed, 86 insertions(+), 82 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java b/e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java index 0a2b9c762..3b093af4a 100644 --- a/e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java +++ b/e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java @@ -18,13 +18,13 @@ */ package org.alfresco.rest.search; +import java.util.Collections; +import java.util.List; + import org.alfresco.utility.model.TestGroup; import org.testng.Assert; import org.testng.annotations.Test; -import java.util.ArrayList; -import java.util.List; - /** * Tests the search functionality using an ancestor path. * Using the category as an example, it is a node that is located @@ -32,7 +32,7 @@ import java.util.List; * so that we can return all the child elements of our target path. * A search on root/rootCategory/classifiable should return Regions, Languages * as they are the child elements of the given path. - * + * * @author Michael Suzuki * */ @@ -77,94 +77,98 @@ public class SearchAPATHTest extends AbstractSearchTest * "consistency": {"lastTxId": 89} * } *}} - * + * */ public void searchLevel0() throws Exception { - SearchRequest searchQuery = new SearchRequest(); - RestRequestQueryModel queryReq = new RestRequestQueryModel(); - queryReq.setQuery("name:*"); - searchQuery.setQuery(queryReq); - - RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); - List list = new ArrayList<>(); - list.add(new RestRequestFacetFieldModel("APATH","0")); - facetFields.setFacets(list); - searchQuery.setFacetFields(facetFields); - SearchResponse response = query(searchQuery); - RestResultBucketsModel fresponse = response.getContext().getFacetsFields().get(0); - fresponse.assertThat().field("buckets").isNotEmpty(); - Assert.assertEquals(2,fresponse.getBuckets().size()); - fresponse.getBuckets().get(0).assertThat().field("label").contains("0/"); - fresponse.getBuckets().get(1).assertThat().field("label").is("0/"); + final SearchRequest searchQuery = searchRequestWithAPATHFacet("name:*", "0"); + final SearchResponse response = query(searchQuery); + + buckets(response, 2) + .forEach(bucket -> bucket.assertThat().field("label").contains("0/")); } + @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_1}) public void searchLevel0andIncludeSubLevel1() throws Exception { - SearchRequest searchQuery = new SearchRequest(); - RestRequestQueryModel queryReq = new RestRequestQueryModel(); - queryReq.setQuery("name:*"); - searchQuery.setQuery(queryReq); - - RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); - List list = new ArrayList<>(); - list.add(new RestRequestFacetFieldModel("APATH","1")); - facetFields.setFacets(list); - searchQuery.setFacetFields(facetFields); - SearchResponse response = query(searchQuery); - RestResultBucketsModel fresponse = response.getContext().getFacetsFields().get(0); - Assert.assertEquals(4,fresponse.getBuckets().size()); - fresponse.getBuckets().get(0).assertThat().field("label").contains("1/"); + final SearchRequest searchQuery = searchRequestWithAPATHFacet("name:*", "1/"); + final SearchResponse response = query(searchQuery); + + bucket(response).assertThat().field("label").contains("1/"); } @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_1}) public void searchLevel2() throws Exception { - String queryString = "name:"+ "cars"; - - SearchRequest searchQuery = new SearchRequest(); - RestRequestQueryModel queryReq = new RestRequestQueryModel(); - queryReq.setQuery(queryString); - searchQuery.setQuery(queryReq); - - RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); - List list = new ArrayList<>(); - list.add(new RestRequestFacetFieldModel("APATH","1/")); - facetFields.setFacets(list); - searchQuery.setFacetFields(facetFields); - - SearchResponse response = query(searchQuery); - - RestResultBucketsModel fresponse = response.getContext().getFacetsFields().get(0); - String path = fresponse.getBuckets().get(0).getLabel().replace("1/", "2/"); - list.remove(0); - list.add(new RestRequestFacetFieldModel("APATH", path)); - - facetFields.setFacets(list); - searchQuery.setFacetFields(facetFields); - response = query(searchQuery); - fresponse = response.getContext().getFacetsFields().get(0); - Assert.assertTrue(fresponse.getBuckets().size() >= 1); - fresponse.getBuckets().get(0).assertThat().field("label").contains("2/"); - fresponse.getBuckets().get(0).assertThat().field("label").contains(path); - /** - * To return the contents of the path and its sub directory change the prefix - * Below 2/path/path -> will return whats in path/path only - * if 3/path/path -> will return contents from path/path/path - * @throws Exception - */ - searchQuery = new SearchRequest(); - queryReq = new RestRequestQueryModel(); - queryReq.setQuery(queryString); - searchQuery.setQuery(queryReq); - facetFields = new RestRequestFacetFieldsModel(); - list.remove(0); - list.add(new RestRequestFacetFieldModel("APATH",path.replace("2/", "3/"))); - facetFields.setFacets(list); - searchQuery.setFacetFields(facetFields); - response = query(searchQuery); - fresponse = response.getContext().getFacetsFields().get(0); - Assert.assertTrue(fresponse.getBuckets().size() >= 1); - fresponse.getBuckets().get(0).assertThat().field("label").contains("3/"); + final String queryString = "name:cars"; + + final SearchRequest l1Request = searchRequestWithAPATHFacet(queryString, "1/"); + final SearchResponse l1Response = query(l1Request); + + final String l2Prefix = bucket(l1Response).getLabel().replaceFirst("^1/", "2/"); + + final SearchRequest l2Request = searchRequestWithAPATHFacet(queryString, l2Prefix); + final SearchResponse l2Response = query(l2Request); + + final FacetFieldBucket bucket = bucket(l2Response); + bucket.assertThat().field("label").contains(l2Prefix); + + final String l3Prefix = bucket.getLabel().replaceFirst("^2/", "3/"); + + final SearchRequest l3Request = searchRequestWithAPATHFacet(queryString, l3Prefix); + final SearchResponse l3response = query(l3Request); + + bucket(l3response).assertThat().field("label").contains(l3Prefix); } -} + + /** + * Creates a new {@link SearchRequest} for this test case. + * + * @param queryString the query string. + * @param facetPrefix the facet prefix. + * @return a new {@link SearchRequest} for this test case. + */ + private SearchRequest searchRequestWithAPATHFacet(final String queryString, final String facetPrefix) + { + final SearchRequest searchRequest = new SearchRequest(); + + final RestRequestQueryModel query = new RestRequestQueryModel(); + query.setQuery(queryString); + searchRequest.setQuery(query); + + final RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); + facetFields.setFacets(Collections.singletonList(new RestRequestFacetFieldModel("APATH", facetPrefix))); + searchRequest.setFacetFields(facetFields); + + return searchRequest; + } + + /** + * Extracts the first bucket from the given response. + * + * @param response the results of a query execution. + * @return the first bucket included in the search response. + */ + private FacetFieldBucket bucket(final SearchResponse response) + { + return buckets(response, 1).iterator().next(); + } + + /** + * Extracts the buckets from the given response. + * The method also makes sure the buckets list is not empty in the input response. + * + * @param response the results of a query execution. + * @return the buckets included in the search response. + */ + private List buckets(final SearchResponse response, final int minExpectedSize) + { + Assert.assertNotNull(response.getContext().getFacetsFields()); + Assert.assertTrue(response.getContext().getFacetsFields().size() >= 1); + + Assert.assertNotNull(response.getContext().getFacetsFields().iterator().next().getBuckets()); + Assert.assertTrue(response.getContext().getFacetsFields().iterator().next().getBuckets().size() >= minExpectedSize); + + return response.getContext().getFacetsFields().iterator().next().getBuckets(); + } +} \ No newline at end of file From e81c044f4caec586cade323103046f6e8437ca86 Mon Sep 17 00:00:00 2001 From: Erik Knizat Date: Fri, 19 Oct 2018 16:14:32 +0100 Subject: [PATCH 1404/1491] REPO-3690: Add rendition integration tests --- .../renditions/RenditionIntegrationTests.java | 165 ++++++++++++++++++ 1 file changed, 165 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/renditions/RenditionIntegrationTests.java diff --git a/e2e-test/java/org/alfresco/rest/renditions/RenditionIntegrationTests.java b/e2e-test/java/org/alfresco/rest/renditions/RenditionIntegrationTests.java new file mode 100644 index 000000000..59b838511 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/renditions/RenditionIntegrationTests.java @@ -0,0 +1,165 @@ +package org.alfresco.rest.renditions; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.RestResponse; +import org.alfresco.rest.model.RestNodeModel; +import org.alfresco.rest.model.RestRenditionInfoModel; +import org.alfresco.rest.model.RestRenditionInfoModelCollection; +import org.alfresco.utility.Utility; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; +import java.util.Arrays; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + +/** + * + * Sanity check for renditions through REST API.
      + * Tests upload files and then request renditions for those files.
      + * Renditions are requested based on supported renditions according to GET '/nodes/{nodeId}/renditions'.
      + */ +@Test(groups = {TestGroup.REQUIRE_TRANSFORMATION, TestGroup.RENDITIONS_REGRESSION}) +public class RenditionIntegrationTests extends RestTest +{ + + private UserModel user; + private SiteModel site; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + user = dataUser.createRandomTestUser(); + site = dataSite.usingUser(user).createPublicRandomSite(); + } + + /** + * Check that a particular rendition can be created for the file and that it has the expected Mime type + */ + @Test(dataProvider = "RenditionTestDataProvider", groups = {TestGroup.REST_API, TestGroup.RENDITIONS, TestGroup.SANITY}) + @TestRail(section = { TestGroup.REST_API, TestGroup.RENDITIONS }, executionType = ExecutionType.SANITY, + description = "Verify renditions created for a selection of test files via POST nodes/{nodeId}/renditions") + public void supportedRenditionTest(String fileName, String renditionId, String expectedMimeType, String nodeId) throws Exception + { + FileModel file = new FileModel(fileName); + file.setNodeRef(nodeId); + + // 1. Create a rendition of the file using RESTAPI + restClient.withCoreAPI().usingNode(file).createNodeRendition(renditionId); + Assert.assertEquals(restClient.getStatusCode(), HttpStatus.ACCEPTED.toString(), + "Failed to submit a request for rendition. [" + fileName+ ", " + renditionId+"] [source file, rendition ID]. "); + + // 2. Verify that a rendition of the file is created and has content using RESTAPI + RestResponse restResponse = restClient.withCoreAPI().usingNode(file).getNodeRenditionContentUntilIsCreated(renditionId); + Assert.assertEquals(restClient.getStatusCode(), HttpStatus.OK.toString(), + "Failed to produce rendition. [" + fileName+ ", " + renditionId+"] [source file, rendition ID] "); + + // 3. Check the returned content type + Assert.assertEquals(restClient.getResponseHeaders().getValue("Content-Type"), expectedMimeType+";charset=UTF-8", + "Rendition was created but it has the wrong Content-Type. [" + fileName+ ", " + renditionId + "] [source file, rendition ID]"); + + + Assert.assertTrue((restResponse.getResponse().body().asInputStream().available() > 0), + "Rendition was created but its content is empty. [" + fileName+ ", " + renditionId+"] [source file, rendition ID] "); + } + + @DataProvider(name = "RenditionTestDataProvider") + protected Iterator renditionTestDataProvider() throws Exception + { + List toTest = Arrays.asList("doc", "xls", "ppt", "docx", "xlsx", "pptx", "msg", "png", "gif", "jpg", "pdf", "txt"); // "tiff" + + List renditionsForFiles = new LinkedList<>(); + + for (String extensions : toTest) + { + String sourceFile = "quick/quick." + extensions; + renditionsForFiles.addAll(uploadFileAndGetAvailableRenditions(sourceFile)); + } + + return renditionsForFiles.iterator(); + } + + /** + * Upload a source file, get all supported renditions for it. + */ + private List uploadFileAndGetAvailableRenditions(String sourceFile) throws Exception + { + + // Create folder & upload file + FolderModel folder = FolderModel.getRandomFolderModel(); + folder = dataContent.usingUser(user).usingSite(site).createFolder(folder); + restClient.authenticateUser(user).configureRequestSpec() + .addMultiPart("filedata", Utility.getResourceTestDataFile(sourceFile)); + RestNodeModel fileNode = restClient.authenticateUser(user).withCoreAPI().usingNode(folder).createNode(); + + Assert.assertEquals(restClient.getStatusCode(), HttpStatus.CREATED.toString(), + "Failed to created a node for rendition tests using file " + sourceFile); + + FileModel file = new FileModel(sourceFile); + file.setNodeRef(fileNode.getId()); + + List renditionsForFile = new LinkedList<>(); + + // Get supported renditions + RestRenditionInfoModelCollection renditionsInfo = restClient.withCoreAPI().usingNode(file).getNodeRenditionsInfo(); + for (RestRenditionInfoModel m : renditionsInfo.getEntries()) + { + RestRenditionInfoModel renditionInfo = m.onModel(); + String renditionId = renditionInfo.getId(); + String targetMimeType = renditionInfo.getContent().getMimeType(); + + renditionsForFile.add(new Object[]{sourceFile, renditionId, targetMimeType, fileNode.getId()}); + + } + + return renditionsForFile; + } + + @Test(dataProvider = "UnsupportedRenditionTestDataProvider",groups = {TestGroup.REST_API, TestGroup.RENDITIONS, TestGroup.SANITY}) + @TestRail(section = { TestGroup.REST_API, TestGroup.RENDITIONS }, executionType = ExecutionType.SANITY, + description = "Verify that requests for unsupported renditions return 400 ") + public void unsupportedRenditionTest(String sourceFile, String renditionId) throws Exception + { + // 1. Create a folder in existing site" + FolderModel folder = FolderModel.getRandomFolderModel(); + folder = dataContent.usingUser(user).usingSite(site).createFolder(folder); + + // 2. Upload a local file using RESTAPI + restClient.authenticateUser(user).configureRequestSpec().addMultiPart("filedata", Utility.getResourceTestDataFile(sourceFile)); + RestNodeModel fileNode = restClient.authenticateUser(user).withCoreAPI().usingNode(folder).createNode(); + Assert.assertEquals(restClient.getStatusCode(), HttpStatus.CREATED.toString(), + "Failed to created a node for rendition tests using file " + sourceFile); + + // 3. Request rendition of the file using RESTAPI + FileModel file = new FileModel(sourceFile); + file.setNodeRef(fileNode.getId()); + restClient.withCoreAPI().usingNode(file).createNodeRendition(renditionId); + + Assert.assertEquals(restClient.getStatusCode(), HttpStatus.BAD_REQUEST.toString(), + "Expected to see the rendition rejected. [" + sourceFile + ", " + renditionId + "] [source file, rendition ID] "); + } + + @DataProvider(name = "UnsupportedRenditionTestDataProvider") + protected Iterator unsupportedRenditionTestDataProvider() throws Exception + { + String renditionId = "pdf"; + + List toTest = new LinkedList<>(); + toTest.add(new Object[]{"quick/quick.png", renditionId}); + toTest.add(new Object[]{"quick/quick.gif", renditionId}); + toTest.add(new Object[]{"quick/quick.jpg", renditionId}); + toTest.add(new Object[]{"quick/quick.pdf", renditionId}); + + return toTest.iterator(); + } +} From 1a2b0e84d7da1d404c6c582a0e92557a243d5c04 Mon Sep 17 00:00:00 2001 From: Erik Knizat Date: Mon, 22 Oct 2018 12:44:42 +0100 Subject: [PATCH 1405/1491] REPO-3690: Add integration tests * Prepare for addition of new tests specific to the transformation switches --- .../renditions/AvailableRenditionTests.java | 114 ++++++++++++++++ .../renditions/RenditionIntegrationTests.java | 122 +++--------------- 2 files changed, 133 insertions(+), 103 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/renditions/AvailableRenditionTests.java diff --git a/e2e-test/java/org/alfresco/rest/renditions/AvailableRenditionTests.java b/e2e-test/java/org/alfresco/rest/renditions/AvailableRenditionTests.java new file mode 100644 index 000000000..ba6cb59af --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/renditions/AvailableRenditionTests.java @@ -0,0 +1,114 @@ +package org.alfresco.rest.renditions; + +import org.alfresco.rest.model.RestNodeModel; +import org.alfresco.rest.model.RestRenditionInfoModel; +import org.alfresco.rest.model.RestRenditionInfoModelCollection; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.Assert; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +import java.util.Arrays; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + +/** + * + * Sanity check for renditions through REST API.
      + * Tests upload files and then request renditions for those files.
      + * Renditions are requested based on supported renditions according to GET '/nodes/{nodeId}/renditions'.
      + */ +@Test(groups = {TestGroup.REQUIRE_TRANSFORMATION, TestGroup.RENDITIONS_REGRESSION}) +public class AvailableRenditionTests extends RenditionIntegrationTests +{ + + /** + * Check that a particular rendition can be created for the file and that it has the expected Mime type + */ + @Test(dataProvider = "RenditionTestDataProvider", groups = {TestGroup.REST_API, TestGroup.RENDITIONS, TestGroup.SANITY}) + @TestRail(section = { TestGroup.REST_API, TestGroup.RENDITIONS }, executionType = ExecutionType.SANITY, + description = "Verify renditions created for a selection of test files via POST nodes/{nodeId}/renditions") + public void supportedRenditionTest(String fileName, String renditionId, String expectedMimeType, String nodeId) throws Exception + { + checkRendition(fileName, nodeId, renditionId, expectedMimeType); + } + + @DataProvider(name = "RenditionTestDataProvider") + protected Iterator renditionTestDataProvider() throws Exception + { + List toTest = Arrays.asList("doc", "xls", "ppt", "docx", "xlsx", "pptx", "msg", "pdf", "png", "gif", "jpg"); + + List renditionsForFiles = new LinkedList<>(); + + for (String extensions : toTest) + { + String sourceFile = "quick/quick." + extensions; + renditionsForFiles.addAll(uploadFileAndGetAvailableRenditions(sourceFile)); + } + + return renditionsForFiles.iterator(); + } + /** + * Upload a source file, get all supported renditions for it. + */ + private List uploadFileAndGetAvailableRenditions(String sourceFile) throws Exception + { + + // Create folder & upload file + RestNodeModel fileNode = uploadFile(sourceFile); + FileModel file = new FileModel(); + file.setNodeRef(fileNode.getId()); + + List renditionsForFile = new LinkedList<>(); + + // Get supported renditions + RestRenditionInfoModelCollection renditionsInfo = restClient.withCoreAPI().usingNode(file).getNodeRenditionsInfo(); + for (RestRenditionInfoModel m : renditionsInfo.getEntries()) + { + RestRenditionInfoModel renditionInfo = m.onModel(); + String renditionId = renditionInfo.getId(); + String targetMimeType = renditionInfo.getContent().getMimeType(); + + renditionsForFile.add(new Object[]{sourceFile, renditionId, targetMimeType, fileNode.getId()}); + + } + + return renditionsForFile; + } + + @Test(dataProvider = "UnsupportedRenditionTestDataProvider",groups = {TestGroup.REST_API, TestGroup.RENDITIONS, TestGroup.SANITY}) + @TestRail(section = { TestGroup.REST_API, TestGroup.RENDITIONS }, executionType = ExecutionType.SANITY, + description = "Verify that requests for unsupported renditions return 400 ") + public void unsupportedRenditionTest(String sourceFile, String renditionId) throws Exception + { + RestNodeModel fileNode = uploadFile(sourceFile); + + // 2. Request rendition of the file using RESTAPI + FileModel file = new FileModel(sourceFile); + file.setNodeRef(fileNode.getId()); + restClient.withCoreAPI().usingNode(file).createNodeRendition(renditionId); + + Assert.assertEquals(restClient.getStatusCode(), HttpStatus.BAD_REQUEST.toString(), + "Expected to see the rendition rejected. [" + sourceFile + ", " + renditionId + "] [source file, rendition ID] "); + } + + @DataProvider(name = "UnsupportedRenditionTestDataProvider") + protected Iterator unsupportedRenditionTestDataProvider() throws Exception + { + String renditionId = "pdf"; + + List toTest = new LinkedList<>(); + toTest.add(new Object[]{"quick/quick.png", renditionId}); + toTest.add(new Object[]{"quick/quick.gif", renditionId}); + toTest.add(new Object[]{"quick/quick.jpg", renditionId}); + toTest.add(new Object[]{"quick/quick.pdf", renditionId}); + + return toTest.iterator(); + } +} + diff --git a/e2e-test/java/org/alfresco/rest/renditions/RenditionIntegrationTests.java b/e2e-test/java/org/alfresco/rest/renditions/RenditionIntegrationTests.java index 59b838511..2423613ca 100644 --- a/e2e-test/java/org/alfresco/rest/renditions/RenditionIntegrationTests.java +++ b/e2e-test/java/org/alfresco/rest/renditions/RenditionIntegrationTests.java @@ -3,38 +3,22 @@ package org.alfresco.rest.renditions; import org.alfresco.rest.RestTest; import org.alfresco.rest.core.RestResponse; import org.alfresco.rest.model.RestNodeModel; -import org.alfresco.rest.model.RestRenditionInfoModel; -import org.alfresco.rest.model.RestRenditionInfoModelCollection; import org.alfresco.utility.Utility; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; + import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; + import org.springframework.http.HttpStatus; import org.testng.Assert; import org.testng.annotations.BeforeClass; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; -import java.util.Arrays; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -/** - * - * Sanity check for renditions through REST API.
      - * Tests upload files and then request renditions for those files.
      - * Renditions are requested based on supported renditions according to GET '/nodes/{nodeId}/renditions'.
      - */ -@Test(groups = {TestGroup.REQUIRE_TRANSFORMATION, TestGroup.RENDITIONS_REGRESSION}) -public class RenditionIntegrationTests extends RestTest +public abstract class RenditionIntegrationTests extends RestTest { - private UserModel user; - private SiteModel site; + protected UserModel user; + protected SiteModel site; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception @@ -44,14 +28,16 @@ public class RenditionIntegrationTests extends RestTest } /** - * Check that a particular rendition can be created for the file and that it has the expected Mime type + * Check that a rendition can be created for the specified node id + * @param fileName + * @param nodeId + * @param renditionId + * @param expectedMimeType + * @throws Exception */ - @Test(dataProvider = "RenditionTestDataProvider", groups = {TestGroup.REST_API, TestGroup.RENDITIONS, TestGroup.SANITY}) - @TestRail(section = { TestGroup.REST_API, TestGroup.RENDITIONS }, executionType = ExecutionType.SANITY, - description = "Verify renditions created for a selection of test files via POST nodes/{nodeId}/renditions") - public void supportedRenditionTest(String fileName, String renditionId, String expectedMimeType, String nodeId) throws Exception + protected void checkRendition(String fileName, String nodeId, String renditionId, String expectedMimeType) throws Exception { - FileModel file = new FileModel(fileName); + FileModel file = new FileModel(); file.setNodeRef(nodeId); // 1. Create a rendition of the file using RESTAPI @@ -73,29 +59,14 @@ public class RenditionIntegrationTests extends RestTest "Rendition was created but its content is empty. [" + fileName+ ", " + renditionId+"] [source file, rendition ID] "); } - @DataProvider(name = "RenditionTestDataProvider") - protected Iterator renditionTestDataProvider() throws Exception - { - List toTest = Arrays.asList("doc", "xls", "ppt", "docx", "xlsx", "pptx", "msg", "png", "gif", "jpg", "pdf", "txt"); // "tiff" - - List renditionsForFiles = new LinkedList<>(); - - for (String extensions : toTest) - { - String sourceFile = "quick/quick." + extensions; - renditionsForFiles.addAll(uploadFileAndGetAvailableRenditions(sourceFile)); - } - - return renditionsForFiles.iterator(); - } - /** - * Upload a source file, get all supported renditions for it. + * Upload a file and return its node id + * @param sourceFile + * @return + * @throws Exception */ - private List uploadFileAndGetAvailableRenditions(String sourceFile) throws Exception + protected RestNodeModel uploadFile(String sourceFile) throws Exception { - - // Create folder & upload file FolderModel folder = FolderModel.getRandomFolderModel(); folder = dataContent.usingUser(user).usingSite(site).createFolder(folder); restClient.authenticateUser(user).configureRequestSpec() @@ -105,61 +76,6 @@ public class RenditionIntegrationTests extends RestTest Assert.assertEquals(restClient.getStatusCode(), HttpStatus.CREATED.toString(), "Failed to created a node for rendition tests using file " + sourceFile); - FileModel file = new FileModel(sourceFile); - file.setNodeRef(fileNode.getId()); - - List renditionsForFile = new LinkedList<>(); - - // Get supported renditions - RestRenditionInfoModelCollection renditionsInfo = restClient.withCoreAPI().usingNode(file).getNodeRenditionsInfo(); - for (RestRenditionInfoModel m : renditionsInfo.getEntries()) - { - RestRenditionInfoModel renditionInfo = m.onModel(); - String renditionId = renditionInfo.getId(); - String targetMimeType = renditionInfo.getContent().getMimeType(); - - renditionsForFile.add(new Object[]{sourceFile, renditionId, targetMimeType, fileNode.getId()}); - - } - - return renditionsForFile; - } - - @Test(dataProvider = "UnsupportedRenditionTestDataProvider",groups = {TestGroup.REST_API, TestGroup.RENDITIONS, TestGroup.SANITY}) - @TestRail(section = { TestGroup.REST_API, TestGroup.RENDITIONS }, executionType = ExecutionType.SANITY, - description = "Verify that requests for unsupported renditions return 400 ") - public void unsupportedRenditionTest(String sourceFile, String renditionId) throws Exception - { - // 1. Create a folder in existing site" - FolderModel folder = FolderModel.getRandomFolderModel(); - folder = dataContent.usingUser(user).usingSite(site).createFolder(folder); - - // 2. Upload a local file using RESTAPI - restClient.authenticateUser(user).configureRequestSpec().addMultiPart("filedata", Utility.getResourceTestDataFile(sourceFile)); - RestNodeModel fileNode = restClient.authenticateUser(user).withCoreAPI().usingNode(folder).createNode(); - Assert.assertEquals(restClient.getStatusCode(), HttpStatus.CREATED.toString(), - "Failed to created a node for rendition tests using file " + sourceFile); - - // 3. Request rendition of the file using RESTAPI - FileModel file = new FileModel(sourceFile); - file.setNodeRef(fileNode.getId()); - restClient.withCoreAPI().usingNode(file).createNodeRendition(renditionId); - - Assert.assertEquals(restClient.getStatusCode(), HttpStatus.BAD_REQUEST.toString(), - "Expected to see the rendition rejected. [" + sourceFile + ", " + renditionId + "] [source file, rendition ID] "); - } - - @DataProvider(name = "UnsupportedRenditionTestDataProvider") - protected Iterator unsupportedRenditionTestDataProvider() throws Exception - { - String renditionId = "pdf"; - - List toTest = new LinkedList<>(); - toTest.add(new Object[]{"quick/quick.png", renditionId}); - toTest.add(new Object[]{"quick/quick.gif", renditionId}); - toTest.add(new Object[]{"quick/quick.jpg", renditionId}); - toTest.add(new Object[]{"quick/quick.pdf", renditionId}); - - return toTest.iterator(); + return fileNode; } } From 7fec0c864673ae8797e3272f9982099fc5c72fac Mon Sep 17 00:00:00 2001 From: Erik Knizat Date: Mon, 22 Oct 2018 15:17:24 +0100 Subject: [PATCH 1406/1491] REPO-3690: Add test for no available renditions --- .../renditions/AvailableRenditionTests.java | 54 +++++++++++++------ 1 file changed, 37 insertions(+), 17 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/renditions/AvailableRenditionTests.java b/e2e-test/java/org/alfresco/rest/renditions/AvailableRenditionTests.java index ba6cb59af..70f1d79d5 100644 --- a/e2e-test/java/org/alfresco/rest/renditions/AvailableRenditionTests.java +++ b/e2e-test/java/org/alfresco/rest/renditions/AvailableRenditionTests.java @@ -9,10 +9,12 @@ import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; import org.testng.Assert; +import org.testng.annotations.BeforeClass; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; import java.util.Arrays; +import java.util.Collections; import java.util.Iterator; import java.util.LinkedList; import java.util.List; @@ -26,35 +28,28 @@ import java.util.List; @Test(groups = {TestGroup.REQUIRE_TRANSFORMATION, TestGroup.RENDITIONS_REGRESSION}) public class AvailableRenditionTests extends RenditionIntegrationTests { + /** List of parameters used as an input to supportedRenditionTest - fileName, nodeId, renditionId, expectedMimeType **/ + private List renditionsToTest; - /** - * Check that a particular rendition can be created for the file and that it has the expected Mime type - */ - @Test(dataProvider = "RenditionTestDataProvider", groups = {TestGroup.REST_API, TestGroup.RENDITIONS, TestGroup.SANITY}) - @TestRail(section = { TestGroup.REST_API, TestGroup.RENDITIONS }, executionType = ExecutionType.SANITY, - description = "Verify renditions created for a selection of test files via POST nodes/{nodeId}/renditions") - public void supportedRenditionTest(String fileName, String renditionId, String expectedMimeType, String nodeId) throws Exception + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception { - checkRendition(fileName, nodeId, renditionId, expectedMimeType); - } + super.dataPreparation(); - @DataProvider(name = "RenditionTestDataProvider") - protected Iterator renditionTestDataProvider() throws Exception - { + // Upload files and get available renditions for each file List toTest = Arrays.asList("doc", "xls", "ppt", "docx", "xlsx", "pptx", "msg", "pdf", "png", "gif", "jpg"); - List renditionsForFiles = new LinkedList<>(); - for (String extensions : toTest) { String sourceFile = "quick/quick." + extensions; renditionsForFiles.addAll(uploadFileAndGetAvailableRenditions(sourceFile)); } - return renditionsForFiles.iterator(); + renditionsToTest = Collections.unmodifiableList(renditionsForFiles); } + /** - * Upload a source file, get all supported renditions for it. + * Upload a source file and get all supported renditions for it. */ private List uploadFileAndGetAvailableRenditions(String sourceFile) throws Exception { @@ -74,13 +69,38 @@ public class AvailableRenditionTests extends RenditionIntegrationTests String renditionId = renditionInfo.getId(); String targetMimeType = renditionInfo.getContent().getMimeType(); - renditionsForFile.add(new Object[]{sourceFile, renditionId, targetMimeType, fileNode.getId()}); + renditionsForFile.add(new Object[]{sourceFile, fileNode.getId(), renditionId, targetMimeType}); } return renditionsForFile; } + /** + * Check that a particular rendition can be created for the file and that it has the expected Mime type + */ + @Test(dataProvider = "RenditionTestDataProvider", groups = {TestGroup.REST_API, TestGroup.RENDITIONS, TestGroup.SANITY}) + @TestRail(section = { TestGroup.REST_API, TestGroup.RENDITIONS }, executionType = ExecutionType.SANITY, + description = "Verify renditions created for a selection of test files via POST nodes/{nodeId}/renditions") + public void supportedRenditionTest(String fileName, String nodeId, String renditionId, String expectedMimeType) throws Exception + { + checkRendition(fileName, nodeId, renditionId, expectedMimeType); + } + + @DataProvider(name = "RenditionTestDataProvider") + protected Iterator renditionTestDataProvider() throws Exception + { + return renditionsToTest.iterator(); + } + + @Test(groups = {TestGroup.REST_API, TestGroup.RENDITIONS, TestGroup.SANITY}) + @TestRail(section = { TestGroup.REST_API, TestGroup.RENDITIONS }, executionType = ExecutionType.SANITY, + description = "Verify that there are some available renditions.") + public void renditionsAvailableTest() + { + Assert.assertFalse(renditionsToTest.isEmpty(), "No available renditions were reported for any of the test files."); + } + @Test(dataProvider = "UnsupportedRenditionTestDataProvider",groups = {TestGroup.REST_API, TestGroup.RENDITIONS, TestGroup.SANITY}) @TestRail(section = { TestGroup.REST_API, TestGroup.RENDITIONS }, executionType = ExecutionType.SANITY, description = "Verify that requests for unsupported renditions return 400 ") From 0502465f9d5efcd8bb2fdaa41a9c9bbffb290efd Mon Sep 17 00:00:00 2001 From: Rodica Sutu Date: Wed, 24 Oct 2018 14:38:37 +0300 Subject: [PATCH 1407/1491] add the possibility to execute an action without setting the params attribute --- .../alfresco/rest/actions/ActionsTests.java | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/actions/ActionsTests.java b/e2e-test/java/org/alfresco/rest/actions/ActionsTests.java index f85d9d8ae..78ed3b53e 100644 --- a/e2e-test/java/org/alfresco/rest/actions/ActionsTests.java +++ b/e2e-test/java/org/alfresco/rest/actions/ActionsTests.java @@ -1,11 +1,9 @@ package org.alfresco.rest.actions; -import static junit.framework.Assert.fail; import static org.testng.Assert.assertFalse; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; -import org.alfresco.rest.exception.EmptyJsonResponseException; import org.alfresco.rest.model.RestActionDefinitionModel; import org.alfresco.rest.model.RestActionDefinitionModelsCollection; import org.alfresco.rest.model.RestNodeModel; @@ -105,6 +103,30 @@ public class ActionsTests extends RestTest }); } + @TestRail (section = { TestGroup.REST_API, TestGroup.ACTIONS }, executionType = ExecutionType.SANITY, + description = "Sanity test for POST /action-executions") + @Test (groups = { TestGroup.REST_API, TestGroup.ACTIONS, TestGroup.SANITY }) + public void executeActionWithoutParam() throws Exception + { + JSONObject response = restClient.authenticateUser(adminUser).withCoreAPI().usingActions().executeAction + ("check-out", document); + restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); + + assertFalse(response.getString("id").isEmpty()); + + /* + * Get all node properties and check that action was executed and + * cm:checkedOut aspect was added + */ + Utility.sleep(500, 20000, () -> { + RestNodeModel fileModel = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(document) + .getNode(); + + restClient.assertStatusCodeIs(HttpStatus.OK); + fileModel.assertThat().field("aspectNames").contains("cm:checkedOut"); + }); + } + @TestRail(section = { TestGroup.REST_API,TestGroup.ACTIONS }, executionType = ExecutionType.SANITY, description = "Sanity test for ACTIONS endpoint GET action-definitions/{actionDefinitionId}") @Test(groups = { TestGroup.REST_API, TestGroup.ACTIONS, TestGroup.SANITY}) From 220e77e3893f5692d49c26161e03ffa8215fe455 Mon Sep 17 00:00:00 2001 From: Lucian Tuca Date: Mon, 29 Oct 2018 11:10:00 +0200 Subject: [PATCH 1408/1491] MM-763 : Renditions: Release MM 1.3.0-RC1 for ACS 6.1 (~ supported version) - introduced tests after fresh release --- e2e-test/java/org/alfresco/rest/discovery/DiscoveryTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/discovery/DiscoveryTests.java b/e2e-test/java/org/alfresco/rest/discovery/DiscoveryTests.java index 76a9e3639..271b45433 100644 --- a/e2e-test/java/org/alfresco/rest/discovery/DiscoveryTests.java +++ b/e2e-test/java/org/alfresco/rest/discovery/DiscoveryTests.java @@ -75,7 +75,7 @@ public class DiscoveryTests extends RestTest assertTrue(modules.contains("alfresco-saml-repo")); assertTrue(modules.contains("org_alfresco_device_sync_repo")); // The MM does not support new RenditionService2 -// assertTrue(modules.contains("org_alfresco_mm_repo")); + assertTrue(modules.contains("org_alfresco_mm_repo")); assertTrue(modules.contains("org.alfresco.module.TransformationServer")); // Check that all installed modules are in INSTALLED state From 8a818b5db34f56132e9a8ba897d71731812c7d8b Mon Sep 17 00:00:00 2001 From: Lucian Tuca Date: Mon, 29 Oct 2018 12:00:03 +0200 Subject: [PATCH 1409/1491] MM-763 : Renditions: Release MM 1.3.0-RC1 for ACS 6.1 (~ supported version) - updated number of modules --- e2e-test/java/org/alfresco/rest/discovery/DiscoveryTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/discovery/DiscoveryTests.java b/e2e-test/java/org/alfresco/rest/discovery/DiscoveryTests.java index 271b45433..273d07f27 100644 --- a/e2e-test/java/org/alfresco/rest/discovery/DiscoveryTests.java +++ b/e2e-test/java/org/alfresco/rest/discovery/DiscoveryTests.java @@ -80,7 +80,7 @@ public class DiscoveryTests extends RestTest // Check that all installed modules are in INSTALLED state List modulesStates = restClient.onResponse().getResponse().jsonPath().getList("entry.repository.modules.installState", String.class); - assertEquals(Collections.frequency(modulesStates, "INSTALLED"), 10); + assertEquals(Collections.frequency(modulesStates, "INSTALLED"), 11); } @Test(groups = { TestGroup.REST_API, TestGroup.DISCOVERY, TestGroup.SANITY, TestGroup.CORE }) From f74e3899d59c1834b5a5623ff6fd1829cad0866e Mon Sep 17 00:00:00 2001 From: Lucian Tuca Date: Mon, 29 Oct 2018 12:16:39 +0200 Subject: [PATCH 1410/1491] MM-763 : Renditions: Release MM 1.3.0-RC1 for ACS 6.1 (~ supported version) - minor tweak --- e2e-test/java/org/alfresco/rest/discovery/DiscoveryTests.java | 1 - 1 file changed, 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/discovery/DiscoveryTests.java b/e2e-test/java/org/alfresco/rest/discovery/DiscoveryTests.java index 273d07f27..b6a1911c0 100644 --- a/e2e-test/java/org/alfresco/rest/discovery/DiscoveryTests.java +++ b/e2e-test/java/org/alfresco/rest/discovery/DiscoveryTests.java @@ -74,7 +74,6 @@ public class DiscoveryTests extends RestTest assertTrue(modules.contains("alfresco-share-services")); assertTrue(modules.contains("alfresco-saml-repo")); assertTrue(modules.contains("org_alfresco_device_sync_repo")); - // The MM does not support new RenditionService2 assertTrue(modules.contains("org_alfresco_mm_repo")); assertTrue(modules.contains("org.alfresco.module.TransformationServer")); From 51de9741717616d25d3af2a8d86c9ac16c170179 Mon Sep 17 00:00:00 2001 From: agazzarini Date: Tue, 30 Oct 2018 12:13:01 +0100 Subject: [PATCH 1411/1491] [ SEARCH-1063] Custom (test) model + Integration test --- .../sql/SearchSQLWithQuotedIdentifiers.java | 108 ++++++++++++++++++ e2e-test/resources/models/SEARCH-1063.xml | 43 +++++++ 2 files changed, 151 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/search/sql/SearchSQLWithQuotedIdentifiers.java create mode 100755 e2e-test/resources/models/SEARCH-1063.xml diff --git a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLWithQuotedIdentifiers.java b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLWithQuotedIdentifiers.java new file mode 100644 index 000000000..168a2122c --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLWithQuotedIdentifiers.java @@ -0,0 +1,108 @@ +/* + * Copyright (C) 2018 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.rest.search.sql; + +import org.alfresco.rest.core.RestResponse; +import org.alfresco.rest.search.AbstractSearchTest; +import org.alfresco.rest.search.SearchSqlRequest; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.CustomObjectTypeProperties; +import org.alfresco.utility.model.*; +import org.alfresco.utility.report.Bug; +import org.apache.chemistry.opencmis.commons.PropertyIds; +import org.hamcrest.Matchers; +import org.springframework.http.HttpStatus; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Tests for /sql end point Search API when a custom model contains identifiers that need to be quoted in queries. + * While it seems there is not an ANSI standard for naming database objects, on the other side the most popular + * databases don't like columns starting with a number. + * In those cases, the column identifier need to be quoted. How to quote a given object identifier (a column name, in + * this case) depends on the specific database lexicon: Oracle uses double quotes ("), MySQL uses back quotes(`). + * + * At time of writing, the lexicon used by the /sql endpoint is MySql so queries that use column names starting with + * a number need to be quoted with back quotes. + * + */ +public class SearchSQLWithQuotedIdentifiers extends AbstractSearchTest +{ + private final String songName = "Got a match?"; + private final String genre = "Fusion"; + + /** + * Setup fixture for this test case. + * Overrides the superlayer method because the data preparation requires a bit different preconditions. + * + * @throws Exception hopefully never, otherwise the test fails. + */ + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + + dataContent.usingAdmin().deployContentModel("models/SEARCH-1063.xml"); + + userModel = dataUser.createRandomTestUser(); + + dataUser.addUserToSite(userModel, testSite, UserRole.SiteContributor); + + final FolderModel testFolder = dataContent.usingSite(testSite).usingUser(userModel).createFolder(); + + file = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "Some text content."); + + final CustomObjectTypeProperties attributes = new CustomObjectTypeProperties(); +// attributes.addProperty(PropertyIds.NAME, file.getName()); + attributes.addProperty("1:name", songName); + attributes.addProperty("1:genre", genre); + + final ContentModel content = + dataContent.usingUser(userModel) + .usingResource(testFolder) + .createCustomContent(file, "D:1:song", attributes); + + waitForIndexing(content.getName(), true); + } + + @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_1}) + @Bug(id = "SEARCH-1063") + public void testSearchUsingCustomAttributeStartingWithNumber() throws Exception + { + final SearchSqlRequest sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql("select cm_name, `1_name`, `1_genre` from alfresco where TYPE='1:song'"); + sqlRequest.setFormat("solr"); + sqlRequest.setLocales(new String[] { "en-US" }); + sqlRequest.setIncludeMetadata(false); + + restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest); + restClient.assertStatusCodeIs(HttpStatus.OK); + + restClient.onResponse().assertThat().body("result-set.docs[0].cm_name", Matchers.equalTo(file.getName())); + restClient.onResponse().assertThat().body("result-set.docs[0].1_name", Matchers.equalTo(songName)); + restClient.onResponse().assertThat().body("result-set.docs[0].1_genre", Matchers.equalTo(genre)); + } + + @AfterClass(alwaysRun = true) + public void tearDown() throws Exception + { + dataContent.usingSite(testSite).usingUser(dataUser.getAdminUser()).deleteSite(testSite); + } +} \ No newline at end of file diff --git a/e2e-test/resources/models/SEARCH-1063.xml b/e2e-test/resources/models/SEARCH-1063.xml new file mode 100755 index 000000000..3ba275d19 --- /dev/null +++ b/e2e-test/resources/models/SEARCH-1063.xml @@ -0,0 +1,43 @@ + + + Administrator admin user + + + + + + + + + + + + song + cm:content + + + name + d:text + false + + TRUE + false + + + + genre + d:text + false + + TRUE + false + + + + + + + + + + \ No newline at end of file From 61b0ae3541a087d8447706ef71420ee13044a30f Mon Sep 17 00:00:00 2001 From: agazzarini Date: Wed, 31 Oct 2018 14:53:00 +0100 Subject: [PATCH 1412/1491] [ SEARCH-1063] Custom (test) model + Integration test for numeric prefixes in columns --- .../rest/search/sql/SearchSQLWithQuotedIdentifiers.java | 1 - e2e-test/resources/models/SEARCH-1063.xml | 6 ++++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLWithQuotedIdentifiers.java b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLWithQuotedIdentifiers.java index 168a2122c..bf88ea9b7 100644 --- a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLWithQuotedIdentifiers.java +++ b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLWithQuotedIdentifiers.java @@ -70,7 +70,6 @@ public class SearchSQLWithQuotedIdentifiers extends AbstractSearchTest file = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "Some text content."); final CustomObjectTypeProperties attributes = new CustomObjectTypeProperties(); -// attributes.addProperty(PropertyIds.NAME, file.getName()); attributes.addProperty("1:name", songName); attributes.addProperty("1:genre", genre); diff --git a/e2e-test/resources/models/SEARCH-1063.xml b/e2e-test/resources/models/SEARCH-1063.xml index 3ba275d19..97c4f0882 100755 --- a/e2e-test/resources/models/SEARCH-1063.xml +++ b/e2e-test/resources/models/SEARCH-1063.xml @@ -20,7 +20,8 @@ d:text false - TRUE + true + BOTH false @@ -29,7 +30,8 @@ d:text false - TRUE + true + BOTH false From 69a9866ad89b24ed9e6c1ecc727ceb59a16cb0bf Mon Sep 17 00:00:00 2001 From: agazzarini Date: Sun, 4 Nov 2018 09:55:59 +0100 Subject: [PATCH 1413/1491] [ SEARCH-1063] more tests + review fixes --- .../sql/SearchSQLWithQuotedIdentifiers.java | 172 +++++++++++++++--- e2e-test/resources/models/SEARCH-1063.xml | 119 +++++++++++- 2 files changed, 262 insertions(+), 29 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLWithQuotedIdentifiers.java b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLWithQuotedIdentifiers.java index bf88ea9b7..71f472efa 100644 --- a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLWithQuotedIdentifiers.java +++ b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLWithQuotedIdentifiers.java @@ -18,17 +18,17 @@ */ package org.alfresco.rest.search.sql; -import org.alfresco.rest.core.RestResponse; +import java.util.UUID; + +import org.alfresco.rest.RestTest; import org.alfresco.rest.search.AbstractSearchTest; import org.alfresco.rest.search.SearchSqlRequest; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.CustomObjectTypeProperties; import org.alfresco.utility.model.*; import org.alfresco.utility.report.Bug; -import org.apache.chemistry.opencmis.commons.PropertyIds; import org.hamcrest.Matchers; import org.springframework.http.HttpStatus; -import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -45,63 +45,181 @@ import org.testng.annotations.Test; */ public class SearchSQLWithQuotedIdentifiers extends AbstractSearchTest { - private final String songName = "Got a match?"; - private final String genre = "Fusion"; + + private String songName; + private String genre; + private String coProducer; + + private String artistName; + private String voiceType; + + private String bassistName; + private String drummerName; + private String saxophonistName; + + private FileModel file5; /** * Setup fixture for this test case. * Overrides the superlayer method because the data preparation requires a bit different preconditions. + * The method uses a transient test site created in the {@link RestTest#checkServerHealth()} and on top of that: * + *
        + *
      • It adds a user which is added to the site as contributor
      • + *
      • + * It deploys a custom model which declares a set of prefixes composed by a combination of digits, hyphens + * and underscores. Those prefixes are associated with four entities (song, artist, bassist, drummer and + * sax) with their corresponding attributes. + *
      • + *
      • + * It creates a folder with 5 files associated with the types declared in the model. + * That allows those files to have a value for the properties/attributes included in the model definition. + *
      • + *
      + * + * @see RestTest#checkServerHealth() * @throws Exception hopefully never, otherwise the test fails. */ @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception { + songName = "The Dry Cleaner from Des Moines "; + genre = "Jazz, vocal jazz "; + coProducer = "Roberta Joan Mitchell "; + + artistName = "Joni Mitchell " + UUID.randomUUID(); + voiceType = "Blue Mezzo (1965-1984) / Cloudy Contralto (1985-present) "; + + bassistName = "Jaco Pastorius"; + drummerName = "Peter Erskine"; + saxophonistName = "Wayne Shorter"; + userModel = dataUser.createRandomTestUser(); dataContent.usingAdmin().deployContentModel("models/SEARCH-1063.xml"); - userModel = dataUser.createRandomTestUser(); - dataUser.addUserToSite(userModel, testSite, UserRole.SiteContributor); - final FolderModel testFolder = dataContent.usingSite(testSite).usingUser(userModel).createFolder(); + FolderModel testFolder = dataContent.usingSite(testSite).usingUser(userModel).createFolder(); - file = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "Some text content."); + file = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); + file2 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); + file3 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); + file4 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); + file5 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); - final CustomObjectTypeProperties attributes = new CustomObjectTypeProperties(); - attributes.addProperty("1:name", songName); - attributes.addProperty("1:genre", genre); + dataContent.usingUser(userModel) + .usingResource(testFolder) + .createCustomContent( + file, + "D:1:song", + new CustomObjectTypeProperties() + .addProperty("1:name", songName) + .addProperty("1:genre", genre) + .addProperty("1:co-producer", coProducer)); - final ContentModel content = + dataContent.usingUser(userModel) + .usingResource(testFolder) + .createCustomContent( + file2, + "D:123:artist", + new CustomObjectTypeProperties() + .addProperty("123:name", artistName) + .addProperty("123:voice_type", voiceType)); + + dataContent.usingUser(userModel) + .usingResource(testFolder) + .createCustomContent( + file3, + "D:1_2_3:bassist", + new CustomObjectTypeProperties() + .addProperty("1_2_3:name", bassistName)); + + dataContent.usingUser(userModel) + .usingResource(testFolder) + .createCustomContent( + file4, + "D:1-2-3:drummer", + new CustomObjectTypeProperties() + .addProperty("1-2-3:name", drummerName)); + + ContentModel content = dataContent.usingUser(userModel) - .usingResource(testFolder) - .createCustomContent(file, "D:1:song", attributes); + .usingResource(testFolder) + .createCustomContent( + file5, + "D:1-2_3_saxophonist", + new CustomObjectTypeProperties() + .addProperty("1-2_3:name", saxophonistName)); waitForIndexing(content.getName(), true); } @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_1}) @Bug(id = "SEARCH-1063") - public void testSearchUsingCustomAttributeStartingWithNumber() throws Exception + public void prefixIsComposedByOneNumber() throws Exception { - final SearchSqlRequest sqlRequest = new SearchSqlRequest(); - sqlRequest.setSql("select cm_name, `1_name`, `1_genre` from alfresco where TYPE='1:song'"); - sqlRequest.setFormat("solr"); - sqlRequest.setLocales(new String[] { "en-US" }); - sqlRequest.setIncludeMetadata(false); - - restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest); - restClient.assertStatusCodeIs(HttpStatus.OK); + executeQuery("select cm_name, `1_name`, `1_genre`, `1_co-producer` from alfresco where TYPE='1:song'"); restClient.onResponse().assertThat().body("result-set.docs[0].cm_name", Matchers.equalTo(file.getName())); restClient.onResponse().assertThat().body("result-set.docs[0].1_name", Matchers.equalTo(songName)); restClient.onResponse().assertThat().body("result-set.docs[0].1_genre", Matchers.equalTo(genre)); + restClient.onResponse().assertThat().body("result-set.docs[0].1_co-producer", Matchers.equalTo(coProducer)); } - @AfterClass(alwaysRun = true) - public void tearDown() throws Exception + @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_1}) + @Bug(id = "SEARCH-1063") + public void prefixIsComposedByMultipleNumbers() throws Exception { - dataContent.usingSite(testSite).usingUser(dataUser.getAdminUser()).deleteSite(testSite); + executeQuery("select cm_name, `123_name`, `123_voice_type` from alfresco where TYPE='123:artist'"); + + restClient.onResponse().assertThat().body("result-set.docs[0].cm_name", Matchers.equalTo(file2.getName())); + restClient.onResponse().assertThat().body("result-set.docs[0].123_name", Matchers.equalTo(artistName)); + restClient.onResponse().assertThat().body("result-set.docs[0].123_voice_type", Matchers.equalTo(voiceType)); + } + + @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_1}) + @Bug(id = "SEARCH-1063") + public void prefixIncludesUnderscore() throws Exception + { + executeQuery("select cm_name, `1_2_3_name` from alfresco where TYPE='1_2_3:bassist'"); + + restClient.onResponse().assertThat().body("result-set.docs[0].cm_name", Matchers.equalTo(file3.getName())); + restClient.onResponse().assertThat().body("result-set.docs[0].1_2_3_name", Matchers.equalTo(bassistName)); + } + + @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_1}) + @Bug(id = "SEARCH-1063") + public void prefixIncludesHyphen() throws Exception + { + executeQuery("select cm_name, `1-2-3_name` from alfresco where TYPE='1-2-3:drummer'"); + + restClient.onResponse().assertThat().body("result-set.docs[0].cm_name", Matchers.equalTo(file4.getName())); + restClient.onResponse().assertThat().body("result-set.docs[0].1-2-3_name", Matchers.equalTo(drummerName)); + } + + @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_1}) + @Bug(id = "SEARCH-1063") + public void prefixIncludesHyphenAndUnderscore() throws Exception + { + executeQuery("select cm_name, `1-2_3_name` from alfresco where TYPE='1-2_3:saxophonist'"); + + restClient.onResponse().assertThat().body("result-set.docs[0].cm_name", Matchers.equalTo(file5.getName())); + restClient.onResponse().assertThat().body("result-set.docs[0].1-2_3_name", Matchers.equalTo(saxophonistName)); + } + + /** + * Internal method for executing a SQL Query. + * + * TODO: maybe would be better to move this method (and similar methods) on a SQL supertype layer (e.g. AbstractSqlSearchTest) + * + * @param sql the SQL statement. + */ + private void executeQuery(String sql) throws Exception + { + SearchSqlRequest sqlRequest = new SearchSqlRequest(sql, "solr"); + + restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest); + restClient.assertStatusCodeIs(HttpStatus.OK); } } \ No newline at end of file diff --git a/e2e-test/resources/models/SEARCH-1063.xml b/e2e-test/resources/models/SEARCH-1063.xml index 97c4f0882..2e647e150 100755 --- a/e2e-test/resources/models/SEARCH-1063.xml +++ b/e2e-test/resources/models/SEARCH-1063.xml @@ -6,7 +6,24 @@ + + + + + @@ -16,7 +33,7 @@ cm:content - name + Name d:text false @@ -26,7 +43,105 @@ - genre + Genre + d:text + false + + true + BOTH + false + + + + Producer + d:text + false + + true + BOTH + false + + + + + + + + + Artist + cm:content + + + Name + d:text + false + + true + BOTH + false + + + + + + Voice Type + d:text + false + + true + BOTH + false + + + + + + + + + Bassist + cm:content + + + Name + d:text + false + + true + BOTH + false + + + + + + + + + Drummer + cm:content + + + Name + d:text + false + + true + BOTH + false + + + + + + + + + Sax + cm:content + + + Name d:text false From 139c5b29aa252f88b14625096d4d239a0ab6f546 Mon Sep 17 00:00:00 2001 From: agazzarini Date: Sun, 4 Nov 2018 18:52:24 +0100 Subject: [PATCH 1414/1491] [ issue MNT-19952 ] Fixed errors on multi-type model --- .../rest/search/sql/SearchSQLWithQuotedIdentifiers.java | 2 +- e2e-test/resources/models/SEARCH-1063.xml | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLWithQuotedIdentifiers.java b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLWithQuotedIdentifiers.java index 71f472efa..50b2a7c80 100644 --- a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLWithQuotedIdentifiers.java +++ b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLWithQuotedIdentifiers.java @@ -148,7 +148,7 @@ public class SearchSQLWithQuotedIdentifiers extends AbstractSearchTest .usingResource(testFolder) .createCustomContent( file5, - "D:1-2_3_saxophonist", + "D:1-2_3:saxophonist", new CustomObjectTypeProperties() .addProperty("1-2_3:name", saxophonistName)); diff --git a/e2e-test/resources/models/SEARCH-1063.xml b/e2e-test/resources/models/SEARCH-1063.xml index 2e647e150..816afd2bc 100755 --- a/e2e-test/resources/models/SEARCH-1063.xml +++ b/e2e-test/resources/models/SEARCH-1063.xml @@ -22,7 +22,7 @@ - + @@ -81,8 +81,6 @@ false - - Voice Type d:text @@ -98,11 +96,12 @@ + Bassist cm:content - + Name d:text false @@ -140,7 +139,7 @@ Sax cm:content - + Name d:text false From 5be15c2f22e09d6bf4a7ac845bac2be96406ad91 Mon Sep 17 00:00:00 2001 From: agazzarini Date: Sun, 4 Nov 2018 19:46:20 +0100 Subject: [PATCH 1415/1491] [ issue MNT-19952 ] added a SITE filter to test SQL statements --- .../search/sql/SearchSQLWithQuotedIdentifiers.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLWithQuotedIdentifiers.java b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLWithQuotedIdentifiers.java index 50b2a7c80..239013988 100644 --- a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLWithQuotedIdentifiers.java +++ b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLWithQuotedIdentifiers.java @@ -159,7 +159,7 @@ public class SearchSQLWithQuotedIdentifiers extends AbstractSearchTest @Bug(id = "SEARCH-1063") public void prefixIsComposedByOneNumber() throws Exception { - executeQuery("select cm_name, `1_name`, `1_genre`, `1_co-producer` from alfresco where TYPE='1:song'"); + executeQuery("select cm_name, `1_name`, `1_genre`, `1_co-producer` from alfresco where TYPE='1:song' and SITE='" + testSite.getId() + "'"); restClient.onResponse().assertThat().body("result-set.docs[0].cm_name", Matchers.equalTo(file.getName())); restClient.onResponse().assertThat().body("result-set.docs[0].1_name", Matchers.equalTo(songName)); @@ -171,7 +171,7 @@ public class SearchSQLWithQuotedIdentifiers extends AbstractSearchTest @Bug(id = "SEARCH-1063") public void prefixIsComposedByMultipleNumbers() throws Exception { - executeQuery("select cm_name, `123_name`, `123_voice_type` from alfresco where TYPE='123:artist'"); + executeQuery("select cm_name, `123_name`, `123_voice_type` from alfresco where TYPE='123:artist' and SITE='" + testSite.getId() + "'"); restClient.onResponse().assertThat().body("result-set.docs[0].cm_name", Matchers.equalTo(file2.getName())); restClient.onResponse().assertThat().body("result-set.docs[0].123_name", Matchers.equalTo(artistName)); @@ -182,7 +182,7 @@ public class SearchSQLWithQuotedIdentifiers extends AbstractSearchTest @Bug(id = "SEARCH-1063") public void prefixIncludesUnderscore() throws Exception { - executeQuery("select cm_name, `1_2_3_name` from alfresco where TYPE='1_2_3:bassist'"); + executeQuery("select cm_name, `1_2_3_name` from alfresco where TYPE='1_2_3:bassist' and SITE='" + testSite.getId() + "'"); restClient.onResponse().assertThat().body("result-set.docs[0].cm_name", Matchers.equalTo(file3.getName())); restClient.onResponse().assertThat().body("result-set.docs[0].1_2_3_name", Matchers.equalTo(bassistName)); @@ -192,7 +192,7 @@ public class SearchSQLWithQuotedIdentifiers extends AbstractSearchTest @Bug(id = "SEARCH-1063") public void prefixIncludesHyphen() throws Exception { - executeQuery("select cm_name, `1-2-3_name` from alfresco where TYPE='1-2-3:drummer'"); + executeQuery("select cm_name, `1-2-3_name` from alfresco where TYPE='1-2-3:drummer' and SITE='" + testSite.getId() + "'"); restClient.onResponse().assertThat().body("result-set.docs[0].cm_name", Matchers.equalTo(file4.getName())); restClient.onResponse().assertThat().body("result-set.docs[0].1-2-3_name", Matchers.equalTo(drummerName)); @@ -202,7 +202,7 @@ public class SearchSQLWithQuotedIdentifiers extends AbstractSearchTest @Bug(id = "SEARCH-1063") public void prefixIncludesHyphenAndUnderscore() throws Exception { - executeQuery("select cm_name, `1-2_3_name` from alfresco where TYPE='1-2_3:saxophonist'"); + executeQuery("select cm_name, `1-2_3_name` from alfresco where TYPE='1-2_3:saxophonist' and SITE='" + testSite.getId() + "'"); restClient.onResponse().assertThat().body("result-set.docs[0].cm_name", Matchers.equalTo(file5.getName())); restClient.onResponse().assertThat().body("result-set.docs[0].1-2_3_name", Matchers.equalTo(saxophonistName)); From a2fbc0943a69a7613aac3e97a5fb04f6d8afc835 Mon Sep 17 00:00:00 2001 From: Alessandro Benedetti Date: Mon, 5 Nov 2018 10:54:29 +0000 Subject: [PATCH 1416/1491] Fix/mnt 19952 permissions islocked includes --- .../rest/search/AbstractSearchTest.java | 19 +++- .../org/alfresco/rest/search/SearchTest.java | 93 +++++++++++++++++-- 2 files changed, 101 insertions(+), 11 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java index e8a0f955c..1d3a31b99 100644 --- a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java @@ -18,8 +18,6 @@ */ package org.alfresco.rest.search; -import javax.naming.AuthenticationException; - import org.alfresco.dataprep.SiteService.Visibility; import org.alfresco.rest.RestTest; import org.alfresco.rest.core.RestResponse; @@ -33,6 +31,8 @@ import org.alfresco.utility.model.UserModel; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; +import javax.naming.AuthenticationException; + /** * Abstract Search test class that contains useful methods * such as: @@ -129,15 +129,23 @@ public class AbstractSearchTest extends RestTest return restClient.authenticateUser(userModel).withSearchAPI().search(query); } /** + * * Helper method which create an http post request to Search API end point. - * @param term String search term + * Executes the given search request without throwing checked exceptions (a {@link RuntimeException} will be thrown in case). + * @param query the search request. * @return {@link SearchResponse} response. - * @throws Exception if error * */ protected SearchResponse query(SearchRequest query) throws Exception { - return restClient.authenticateUser(userModel).withSearchAPI().search(query); + try + { + return restClient.authenticateUser(userModel).withSearchAPI().search(query); + } + catch (final Exception exception) + { + throw new RuntimeException(exception); + } } protected SearchRequest createQuery(String term) @@ -148,6 +156,7 @@ public class AbstractSearchTest extends RestTest query.setQuery(queryReq); return query; } + protected SearchRequest carsQuery() { return createQuery("cars"); diff --git a/e2e-test/java/org/alfresco/rest/search/SearchTest.java b/e2e-test/java/org/alfresco/rest/search/SearchTest.java index 37a8d0fd0..feeec129e 100644 --- a/e2e-test/java/org/alfresco/rest/search/SearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/SearchTest.java @@ -18,9 +18,8 @@ */ package org.alfresco.rest.search; -import java.util.ArrayList; -import java.util.List; - +import junit.framework.Assert; +import org.alfresco.rest.model.body.RestNodeLockBodyModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; @@ -28,7 +27,14 @@ import org.hamcrest.Matchers; import org.springframework.http.HttpStatus; import org.testng.annotations.Test; -import junit.framework.Assert; +import java.util.ArrayList; +import java.util.List; + +import static org.codehaus.groovy.runtime.InvokerHelper.asList; +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.notNullValue; +import static org.hamcrest.Matchers.nullValue; /** * Search end point Public API test. @@ -74,7 +80,83 @@ public class SearchTest extends AbstractSearchTest response.getContext().assertThat().field("request").isNotEmpty(); } - + + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ACS_61n }) @TestRail(section = { + TestGroup.REST_API, TestGroup.SEARCH, + TestGroup.ACS_61n }, executionType = ExecutionType.REGRESSION, description = "Checks the \"include\" request parameter support the 'permissions' option") public void searchQuery_includePermissions_shouldReturnNodeWithPermissionsInformation() + throws Exception + { + String query = "fox"; + String include = "permissions"; + + SearchRequest retrievalQueryIncludingPermissionsInformation = createQuery(query); + retrievalQueryIncludingPermissionsInformation.setInclude(asList(include)); + + query(retrievalQueryIncludingPermissionsInformation); + + restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.onResponse().assertThat().body("list.entries[0].entry.permissions", notNullValue()); + + SearchRequest retrievalQueryNotIncludingLockInformation = createQuery(query); + + query(retrievalQueryNotIncludingLockInformation); + + restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.onResponse().assertThat().body("list.entries[0].entry.permissions", nullValue()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ACS_61n }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ACS_61n }, executionType = ExecutionType.REGRESSION, + description = "Checks the \"include\" request parameter support the 'isLocked' option") + public void searchQuery_includeIsLocked_shouldReturnNodeWithLockInformation() throws Exception { + String query = "fox"; + String include = "isLocked"; + + SearchRequest retrievalQueryIncludingLockInformation = createQuery(query); + retrievalQueryIncludingLockInformation.setInclude(asList(include)); + + query(retrievalQueryIncludingLockInformation); + + restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.onResponse().assertThat().body("list.entries[0].entry.isLocked", equalTo(false)); + + RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); + lockBodyModel.setLifetime("EPHEMERAL"); + lockBodyModel.setTimeToExpire(20); + lockBodyModel.setType("FULL"); + restClient.authenticateUser(userModel).withCoreAPI().usingNode(file).usingParams("include=isLocked").lockNode(lockBodyModel); + + query(retrievalQueryIncludingLockInformation); + + restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.onResponse().assertThat().body("list.entries[0].entry.isLocked", equalTo(true)); + + SearchRequest retrievalQueryNotIncludingLockInformation = createQuery(query); + + query(retrievalQueryNotIncludingLockInformation); + + restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.onResponse().assertThat().body("list.entries[0].entry.isLocked", nullValue()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ACS_61n }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ACS_61n }, executionType = ExecutionType.REGRESSION, + description = "Checks the \"include\" request parameter does not support the 'notValid' option") + public void searchQuery_includeInvalid_shouldReturnBadResponse() + { + String query = "fox"; + String notValidInclude = "notValid"; + SearchRequest permissionsRetrieval = createQuery(query); + permissionsRetrieval.setInclude(asList(notValidInclude)); + + query(permissionsRetrieval); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + restClient.onResponse() + .assertThat() + .body("error.briefSummary", containsString("An invalid argument was received "+notValidInclude)); + } + // Test that when fields parameter is set, only restricted fields appear in the response @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) public void searchWithFields() throws Exception @@ -98,5 +180,4 @@ public class SearchTest extends AbstractSearchTest restClient.onResponse().assertThat().body("list.entries.entry[0].name", Matchers.nullValue()); restClient.onResponse().assertThat().body("list.entries.entry[0].id", Matchers.nullValue()); } - } From aac75965550a0905a2595661962b54b0151fd6bd Mon Sep 17 00:00:00 2001 From: agazzarini Date: Mon, 5 Nov 2018 12:00:09 +0100 Subject: [PATCH 1417/1491] [ issue MNT-19952 ] moved SQL query execution on AbstractSearchTest --- .../rest/search/AbstractSearchTest.java | 17 ++++++++++++- .../sql/SearchSQLWithQuotedIdentifiers.java | 25 ++++--------------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java index e8a0f955c..fac5b3db3 100644 --- a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java @@ -139,7 +139,22 @@ public class AbstractSearchTest extends RestTest { return restClient.authenticateUser(userModel).withSearchAPI().search(query); } - + + /** + * Executes an SQL Query using "solr" as output format. + * + * @param sql the SQL statement. + */ + protected void executeSqlAsSolr(String sql) throws Exception + { + SearchSqlRequest sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql(sql); + sqlRequest.setFormat("solr"); + + restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + protected SearchRequest createQuery(String term) { SearchRequest query = new SearchRequest(); diff --git a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLWithQuotedIdentifiers.java b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLWithQuotedIdentifiers.java index 239013988..2c368361a 100644 --- a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLWithQuotedIdentifiers.java +++ b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLWithQuotedIdentifiers.java @@ -159,7 +159,7 @@ public class SearchSQLWithQuotedIdentifiers extends AbstractSearchTest @Bug(id = "SEARCH-1063") public void prefixIsComposedByOneNumber() throws Exception { - executeQuery("select cm_name, `1_name`, `1_genre`, `1_co-producer` from alfresco where TYPE='1:song' and SITE='" + testSite.getId() + "'"); + executeSqlAsSolr("select cm_name, `1_name`, `1_genre`, `1_co-producer` from alfresco where TYPE='1:song' and SITE='" + testSite.getId() + "'"); restClient.onResponse().assertThat().body("result-set.docs[0].cm_name", Matchers.equalTo(file.getName())); restClient.onResponse().assertThat().body("result-set.docs[0].1_name", Matchers.equalTo(songName)); @@ -171,7 +171,7 @@ public class SearchSQLWithQuotedIdentifiers extends AbstractSearchTest @Bug(id = "SEARCH-1063") public void prefixIsComposedByMultipleNumbers() throws Exception { - executeQuery("select cm_name, `123_name`, `123_voice_type` from alfresco where TYPE='123:artist' and SITE='" + testSite.getId() + "'"); + executeSqlAsSolr("select cm_name, `123_name`, `123_voice_type` from alfresco where TYPE='123:artist' and SITE='" + testSite.getId() + "'"); restClient.onResponse().assertThat().body("result-set.docs[0].cm_name", Matchers.equalTo(file2.getName())); restClient.onResponse().assertThat().body("result-set.docs[0].123_name", Matchers.equalTo(artistName)); @@ -182,7 +182,7 @@ public class SearchSQLWithQuotedIdentifiers extends AbstractSearchTest @Bug(id = "SEARCH-1063") public void prefixIncludesUnderscore() throws Exception { - executeQuery("select cm_name, `1_2_3_name` from alfresco where TYPE='1_2_3:bassist' and SITE='" + testSite.getId() + "'"); + executeSqlAsSolr("select cm_name, `1_2_3_name` from alfresco where TYPE='1_2_3:bassist' and SITE='" + testSite.getId() + "'"); restClient.onResponse().assertThat().body("result-set.docs[0].cm_name", Matchers.equalTo(file3.getName())); restClient.onResponse().assertThat().body("result-set.docs[0].1_2_3_name", Matchers.equalTo(bassistName)); @@ -192,7 +192,7 @@ public class SearchSQLWithQuotedIdentifiers extends AbstractSearchTest @Bug(id = "SEARCH-1063") public void prefixIncludesHyphen() throws Exception { - executeQuery("select cm_name, `1-2-3_name` from alfresco where TYPE='1-2-3:drummer' and SITE='" + testSite.getId() + "'"); + executeSqlAsSolr("select cm_name, `1-2-3_name` from alfresco where TYPE='1-2-3:drummer' and SITE='" + testSite.getId() + "'"); restClient.onResponse().assertThat().body("result-set.docs[0].cm_name", Matchers.equalTo(file4.getName())); restClient.onResponse().assertThat().body("result-set.docs[0].1-2-3_name", Matchers.equalTo(drummerName)); @@ -202,24 +202,9 @@ public class SearchSQLWithQuotedIdentifiers extends AbstractSearchTest @Bug(id = "SEARCH-1063") public void prefixIncludesHyphenAndUnderscore() throws Exception { - executeQuery("select cm_name, `1-2_3_name` from alfresco where TYPE='1-2_3:saxophonist' and SITE='" + testSite.getId() + "'"); + executeSqlAsSolr("select cm_name, `1-2_3_name` from alfresco where TYPE='1-2_3:saxophonist' and SITE='" + testSite.getId() + "'"); restClient.onResponse().assertThat().body("result-set.docs[0].cm_name", Matchers.equalTo(file5.getName())); restClient.onResponse().assertThat().body("result-set.docs[0].1-2_3_name", Matchers.equalTo(saxophonistName)); } - - /** - * Internal method for executing a SQL Query. - * - * TODO: maybe would be better to move this method (and similar methods) on a SQL supertype layer (e.g. AbstractSqlSearchTest) - * - * @param sql the SQL statement. - */ - private void executeQuery(String sql) throws Exception - { - SearchSqlRequest sqlRequest = new SearchSqlRequest(sql, "solr"); - - restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest); - restClient.assertStatusCodeIs(HttpStatus.OK); - } } \ No newline at end of file From ac16b4a9621acb17ea37000c24805f87da7008fd Mon Sep 17 00:00:00 2001 From: Alex Mukha Date: Mon, 5 Nov 2018 13:20:25 +0000 Subject: [PATCH 1418/1491] Fix compilation after MNT-19952 changes --- e2e-test/java/org/alfresco/rest/search/SearchTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/search/SearchTest.java b/e2e-test/java/org/alfresco/rest/search/SearchTest.java index feeec129e..8d6d97a28 100644 --- a/e2e-test/java/org/alfresco/rest/search/SearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/SearchTest.java @@ -142,7 +142,7 @@ public class SearchTest extends AbstractSearchTest @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ACS_61n }) @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ACS_61n }, executionType = ExecutionType.REGRESSION, description = "Checks the \"include\" request parameter does not support the 'notValid' option") - public void searchQuery_includeInvalid_shouldReturnBadResponse() + public void searchQuery_includeInvalid_shouldReturnBadResponse() throws Exception { String query = "fox"; String notValidInclude = "notValid"; From ca9b66634058c1a39b1e8592424456be1189d8e6 Mon Sep 17 00:00:00 2001 From: agazzarini Date: Tue, 6 Nov 2018 14:14:27 +0100 Subject: [PATCH 1419/1491] [ SEARCH-828 ] bucket, buckets methods renaming --- .../alfresco/rest/search/SearchAPATHTest.java | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java b/e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java index 3b093af4a..4d25bb591 100644 --- a/e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java +++ b/e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java @@ -62,7 +62,7 @@ public class SearchAPATHTest extends AbstractSearchTest * }, * "context": { * "facetsFields": [{ - * "buckets": [ + * "getBuckets": [ * { * "count": 913, * "label": "0/5c09534f-3ca2-4272-bc25-064a7c1762b4" @@ -84,8 +84,7 @@ public class SearchAPATHTest extends AbstractSearchTest final SearchRequest searchQuery = searchRequestWithAPATHFacet("name:*", "0"); final SearchResponse response = query(searchQuery); - buckets(response, 2) - .forEach(bucket -> bucket.assertThat().field("label").contains("0/")); + getBuckets(response).forEach(bucket -> bucket.assertThat().field("label").contains("0/")); } @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_1}) @@ -94,7 +93,7 @@ public class SearchAPATHTest extends AbstractSearchTest final SearchRequest searchQuery = searchRequestWithAPATHFacet("name:*", "1/"); final SearchResponse response = query(searchQuery); - bucket(response).assertThat().field("label").contains("1/"); + getFirstBucket(response).assertThat().field("label").contains("1/"); } @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_1}) @@ -105,12 +104,12 @@ public class SearchAPATHTest extends AbstractSearchTest final SearchRequest l1Request = searchRequestWithAPATHFacet(queryString, "1/"); final SearchResponse l1Response = query(l1Request); - final String l2Prefix = bucket(l1Response).getLabel().replaceFirst("^1/", "2/"); + final String l2Prefix = getFirstBucket(l1Response).getLabel().replaceFirst("^1/", "2/"); final SearchRequest l2Request = searchRequestWithAPATHFacet(queryString, l2Prefix); final SearchResponse l2Response = query(l2Request); - final FacetFieldBucket bucket = bucket(l2Response); + final FacetFieldBucket bucket = getFirstBucket(l2Response); bucket.assertThat().field("label").contains(l2Prefix); final String l3Prefix = bucket.getLabel().replaceFirst("^2/", "3/"); @@ -118,7 +117,7 @@ public class SearchAPATHTest extends AbstractSearchTest final SearchRequest l3Request = searchRequestWithAPATHFacet(queryString, l3Prefix); final SearchResponse l3response = query(l3Request); - bucket(l3response).assertThat().field("label").contains(l3Prefix); + getFirstBucket(l3response).assertThat().field("label").contains(l3Prefix); } /** @@ -149,9 +148,9 @@ public class SearchAPATHTest extends AbstractSearchTest * @param response the results of a query execution. * @return the first bucket included in the search response. */ - private FacetFieldBucket bucket(final SearchResponse response) + protected FacetFieldBucket getFirstBucket(SearchResponse response) { - return buckets(response, 1).iterator().next(); + return getBuckets(response).iterator().next(); } /** @@ -159,15 +158,18 @@ public class SearchAPATHTest extends AbstractSearchTest * The method also makes sure the buckets list is not empty in the input response. * * @param response the results of a query execution. - * @return the buckets included in the search response. + * @return the getBuckets included in the search response. */ - private List buckets(final SearchResponse response, final int minExpectedSize) + protected List getBuckets(SearchResponse response) { Assert.assertNotNull(response.getContext().getFacetsFields()); - Assert.assertTrue(response.getContext().getFacetsFields().size() >= 1); + + response.getContext().getFacetsFields().stream().iterator().next().getBuckets(); + + Assert.assertTrue(response.getContext().getFacetsFields().size() > 0); Assert.assertNotNull(response.getContext().getFacetsFields().iterator().next().getBuckets()); - Assert.assertTrue(response.getContext().getFacetsFields().iterator().next().getBuckets().size() >= minExpectedSize); + Assert.assertTrue(response.getContext().getFacetsFields().iterator().next().getBuckets().size() > 0); return response.getContext().getFacetsFields().iterator().next().getBuckets(); } From 336aeac07103dd67115c97837b7b79218bca614b Mon Sep 17 00:00:00 2001 From: agazzarini Date: Tue, 6 Nov 2018 14:26:25 +0100 Subject: [PATCH 1420/1491] [ SEARCH-1063 ] minor refactoring on executeSqlAsSolr method --- .../java/org/alfresco/rest/search/AbstractSearchTest.java | 6 ++---- .../rest/search/sql/SearchSQLWithQuotedIdentifiers.java | 5 +++++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java index fac5b3db3..151c7c547 100644 --- a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java @@ -145,14 +145,12 @@ public class AbstractSearchTest extends RestTest * * @param sql the SQL statement. */ - protected void executeSqlAsSolr(String sql) throws Exception + protected RestResponse executeSqlAsSolr(String sql) throws Exception { SearchSqlRequest sqlRequest = new SearchSqlRequest(); sqlRequest.setSql(sql); sqlRequest.setFormat("solr"); - - restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest); - restClient.assertStatusCodeIs(HttpStatus.OK); + return searchSql(sqlRequest); } protected SearchRequest createQuery(String term) diff --git a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLWithQuotedIdentifiers.java b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLWithQuotedIdentifiers.java index 2c368361a..dca6d1793 100644 --- a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLWithQuotedIdentifiers.java +++ b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLWithQuotedIdentifiers.java @@ -161,6 +161,7 @@ public class SearchSQLWithQuotedIdentifiers extends AbstractSearchTest { executeSqlAsSolr("select cm_name, `1_name`, `1_genre`, `1_co-producer` from alfresco where TYPE='1:song' and SITE='" + testSite.getId() + "'"); + restClient.assertStatusCodeIs(HttpStatus.OK); restClient.onResponse().assertThat().body("result-set.docs[0].cm_name", Matchers.equalTo(file.getName())); restClient.onResponse().assertThat().body("result-set.docs[0].1_name", Matchers.equalTo(songName)); restClient.onResponse().assertThat().body("result-set.docs[0].1_genre", Matchers.equalTo(genre)); @@ -173,6 +174,7 @@ public class SearchSQLWithQuotedIdentifiers extends AbstractSearchTest { executeSqlAsSolr("select cm_name, `123_name`, `123_voice_type` from alfresco where TYPE='123:artist' and SITE='" + testSite.getId() + "'"); + restClient.assertStatusCodeIs(HttpStatus.OK); restClient.onResponse().assertThat().body("result-set.docs[0].cm_name", Matchers.equalTo(file2.getName())); restClient.onResponse().assertThat().body("result-set.docs[0].123_name", Matchers.equalTo(artistName)); restClient.onResponse().assertThat().body("result-set.docs[0].123_voice_type", Matchers.equalTo(voiceType)); @@ -184,6 +186,7 @@ public class SearchSQLWithQuotedIdentifiers extends AbstractSearchTest { executeSqlAsSolr("select cm_name, `1_2_3_name` from alfresco where TYPE='1_2_3:bassist' and SITE='" + testSite.getId() + "'"); + restClient.assertStatusCodeIs(HttpStatus.OK); restClient.onResponse().assertThat().body("result-set.docs[0].cm_name", Matchers.equalTo(file3.getName())); restClient.onResponse().assertThat().body("result-set.docs[0].1_2_3_name", Matchers.equalTo(bassistName)); } @@ -194,6 +197,7 @@ public class SearchSQLWithQuotedIdentifiers extends AbstractSearchTest { executeSqlAsSolr("select cm_name, `1-2-3_name` from alfresco where TYPE='1-2-3:drummer' and SITE='" + testSite.getId() + "'"); + restClient.assertStatusCodeIs(HttpStatus.OK); restClient.onResponse().assertThat().body("result-set.docs[0].cm_name", Matchers.equalTo(file4.getName())); restClient.onResponse().assertThat().body("result-set.docs[0].1-2-3_name", Matchers.equalTo(drummerName)); } @@ -204,6 +208,7 @@ public class SearchSQLWithQuotedIdentifiers extends AbstractSearchTest { executeSqlAsSolr("select cm_name, `1-2_3_name` from alfresco where TYPE='1-2_3:saxophonist' and SITE='" + testSite.getId() + "'"); + restClient.assertStatusCodeIs(HttpStatus.OK); restClient.onResponse().assertThat().body("result-set.docs[0].cm_name", Matchers.equalTo(file5.getName())); restClient.onResponse().assertThat().body("result-set.docs[0].1-2_3_name", Matchers.equalTo(saxophonistName)); } From af301c164dc10655e23e5e8fcdc51e814faabe59 Mon Sep 17 00:00:00 2001 From: agazzarini Date: Tue, 6 Nov 2018 14:53:26 +0100 Subject: [PATCH 1421/1491] [ SEARCH-828 ] bucket size assertions on test methods --- .../org/alfresco/rest/search/SearchAPATHTest.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java b/e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java index 4d25bb591..149bc6fc9 100644 --- a/e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java +++ b/e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java @@ -18,6 +18,7 @@ */ package org.alfresco.rest.search; + import java.util.Collections; import java.util.List; @@ -84,7 +85,10 @@ public class SearchAPATHTest extends AbstractSearchTest final SearchRequest searchQuery = searchRequestWithAPATHFacet("name:*", "0"); final SearchResponse response = query(searchQuery); - getBuckets(response).forEach(bucket -> bucket.assertThat().field("label").contains("0/")); + List buckets = getBuckets(response); + Assert.assertEquals(2, buckets.size()); + + buckets.forEach(bucket -> bucket.assertThat().field("label").contains("0/")); } @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_1}) @@ -93,6 +97,9 @@ public class SearchAPATHTest extends AbstractSearchTest final SearchRequest searchQuery = searchRequestWithAPATHFacet("name:*", "1/"); final SearchResponse response = query(searchQuery); + List buckets = getBuckets(response); + Assert.assertEquals(4, buckets.size()); + getFirstBucket(response).assertThat().field("label").contains("1/"); } @@ -117,6 +124,9 @@ public class SearchAPATHTest extends AbstractSearchTest final SearchRequest l3Request = searchRequestWithAPATHFacet(queryString, l3Prefix); final SearchResponse l3response = query(l3Request); + List buckets = getBuckets(l3response); + Assert.assertEquals(3, buckets.size()); + getFirstBucket(l3response).assertThat().field("label").contains(l3Prefix); } From 640382538c231047bd7b4e00c92fbca8fb247891 Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Tue, 6 Nov 2018 15:58:19 +0000 Subject: [PATCH 1422/1491] Search-828: Corrected the fieldname in SearchResponse, reset in error --- e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java b/e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java index 149bc6fc9..2556da37b 100644 --- a/e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java +++ b/e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java @@ -63,7 +63,7 @@ public class SearchAPATHTest extends AbstractSearchTest * }, * "context": { * "facetsFields": [{ - * "getBuckets": [ + * "buckets": [ * { * "count": 913, * "label": "0/5c09534f-3ca2-4272-bc25-064a7c1762b4" From 9b58718e6bb6bab5f4feacd4a7cb6088aa481ef2 Mon Sep 17 00:00:00 2001 From: agazzarini Date: Tue, 6 Nov 2018 17:30:13 +0100 Subject: [PATCH 1423/1491] [ SEARCH-828 ] improved readability of getBuckets method --- .../alfresco/rest/search/SearchAPATHTest.java | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java b/e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java index 2556da37b..815018325 100644 --- a/e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java +++ b/e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java @@ -158,7 +158,7 @@ public class SearchAPATHTest extends AbstractSearchTest * @param response the results of a query execution. * @return the first bucket included in the search response. */ - protected FacetFieldBucket getFirstBucket(SearchResponse response) + private FacetFieldBucket getFirstBucket(SearchResponse response) { return getBuckets(response).iterator().next(); } @@ -170,17 +170,16 @@ public class SearchAPATHTest extends AbstractSearchTest * @param response the results of a query execution. * @return the getBuckets included in the search response. */ - protected List getBuckets(SearchResponse response) + private List getBuckets(SearchResponse response) { - Assert.assertNotNull(response.getContext().getFacetsFields()); + List facetFields = response.getContext().getFacetsFields(); + Assert.assertNotNull(facetFields); + Assert.assertFalse(facetFields.isEmpty()); - response.getContext().getFacetsFields().stream().iterator().next().getBuckets(); + List buckets = facetFields.iterator().next().getBuckets(); + Assert.assertNotNull(buckets); + Assert.assertFalse(buckets.isEmpty()); - Assert.assertTrue(response.getContext().getFacetsFields().size() > 0); - - Assert.assertNotNull(response.getContext().getFacetsFields().iterator().next().getBuckets()); - Assert.assertTrue(response.getContext().getFacetsFields().iterator().next().getBuckets().size() > 0); - - return response.getContext().getFacetsFields().iterator().next().getBuckets(); + return buckets; } } \ No newline at end of file From c5e8dd157a06c69389b94207edfa4964f7a66702 Mon Sep 17 00:00:00 2001 From: agazzarini Date: Tue, 6 Nov 2018 17:38:07 +0100 Subject: [PATCH 1424/1491] [ SEARCH-828 ] final keyword removed --- .../alfresco/rest/search/SearchAPATHTest.java | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java b/e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java index 815018325..d138d98bc 100644 --- a/e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java +++ b/e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java @@ -82,8 +82,8 @@ public class SearchAPATHTest extends AbstractSearchTest */ public void searchLevel0() throws Exception { - final SearchRequest searchQuery = searchRequestWithAPATHFacet("name:*", "0"); - final SearchResponse response = query(searchQuery); + SearchRequest searchQuery = searchRequestWithAPATHFacet("name:*", "0"); + SearchResponse response = query(searchQuery); List buckets = getBuckets(response); Assert.assertEquals(2, buckets.size()); @@ -94,8 +94,8 @@ public class SearchAPATHTest extends AbstractSearchTest @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_1}) public void searchLevel0andIncludeSubLevel1() throws Exception { - final SearchRequest searchQuery = searchRequestWithAPATHFacet("name:*", "1/"); - final SearchResponse response = query(searchQuery); + SearchRequest searchQuery = searchRequestWithAPATHFacet("name:*", "1/"); + SearchResponse response = query(searchQuery); List buckets = getBuckets(response); Assert.assertEquals(4, buckets.size()); @@ -106,23 +106,23 @@ public class SearchAPATHTest extends AbstractSearchTest @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_1}) public void searchLevel2() throws Exception { - final String queryString = "name:cars"; + String queryString = "name:cars"; - final SearchRequest l1Request = searchRequestWithAPATHFacet(queryString, "1/"); - final SearchResponse l1Response = query(l1Request); + SearchRequest l1Request = searchRequestWithAPATHFacet(queryString, "1/"); + SearchResponse l1Response = query(l1Request); - final String l2Prefix = getFirstBucket(l1Response).getLabel().replaceFirst("^1/", "2/"); + String l2Prefix = getFirstBucket(l1Response).getLabel().replaceFirst("^1/", "2/"); - final SearchRequest l2Request = searchRequestWithAPATHFacet(queryString, l2Prefix); - final SearchResponse l2Response = query(l2Request); + SearchRequest l2Request = searchRequestWithAPATHFacet(queryString, l2Prefix); + SearchResponse l2Response = query(l2Request); - final FacetFieldBucket bucket = getFirstBucket(l2Response); + FacetFieldBucket bucket = getFirstBucket(l2Response); bucket.assertThat().field("label").contains(l2Prefix); - final String l3Prefix = bucket.getLabel().replaceFirst("^2/", "3/"); + String l3Prefix = bucket.getLabel().replaceFirst("^2/", "3/"); - final SearchRequest l3Request = searchRequestWithAPATHFacet(queryString, l3Prefix); - final SearchResponse l3response = query(l3Request); + SearchRequest l3Request = searchRequestWithAPATHFacet(queryString, l3Prefix); + SearchResponse l3response = query(l3Request); List buckets = getBuckets(l3response); Assert.assertEquals(3, buckets.size()); @@ -137,15 +137,15 @@ public class SearchAPATHTest extends AbstractSearchTest * @param facetPrefix the facet prefix. * @return a new {@link SearchRequest} for this test case. */ - private SearchRequest searchRequestWithAPATHFacet(final String queryString, final String facetPrefix) + private SearchRequest searchRequestWithAPATHFacet(String queryString, String facetPrefix) { - final SearchRequest searchRequest = new SearchRequest(); + SearchRequest searchRequest = new SearchRequest(); - final RestRequestQueryModel query = new RestRequestQueryModel(); + RestRequestQueryModel query = new RestRequestQueryModel(); query.setQuery(queryString); searchRequest.setQuery(query); - final RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); + RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); facetFields.setFacets(Collections.singletonList(new RestRequestFacetFieldModel("APATH", facetPrefix))); searchRequest.setFacetFields(facetFields); From 3b15dd669e6d3420a12d331986a32d953d7cfb4b Mon Sep 17 00:00:00 2001 From: agazzarini Date: Tue, 6 Nov 2018 21:09:24 +0100 Subject: [PATCH 1425/1491] [ SEARCH-1063] fixed wrong assertion on test method --- e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java b/e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java index d138d98bc..6a50ecdfc 100644 --- a/e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java +++ b/e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java @@ -125,7 +125,7 @@ public class SearchAPATHTest extends AbstractSearchTest SearchResponse l3response = query(l3Request); List buckets = getBuckets(l3response); - Assert.assertEquals(3, buckets.size()); + Assert.assertTrue(buckets.size() >= 1); getFirstBucket(l3response).assertThat().field("label").contains(l3Prefix); } From b6956f4e65ab907f5fe63d9ca0fd63d9872614bd Mon Sep 17 00:00:00 2001 From: agazzarini Date: Wed, 7 Nov 2018 13:55:13 +0100 Subject: [PATCH 1426/1491] [ SEARCH-1063] assertEquals replaced assertTrue because better readability --- e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java b/e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java index 6a50ecdfc..a045144f9 100644 --- a/e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java +++ b/e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java @@ -125,7 +125,7 @@ public class SearchAPATHTest extends AbstractSearchTest SearchResponse l3response = query(l3Request); List buckets = getBuckets(l3response); - Assert.assertTrue(buckets.size() >= 1); + Assert.assertEquals(1, buckets.size()); getFirstBucket(l3response).assertThat().field("label").contains(l3Prefix); } From 3043409ec776538f1f552274a39f529d44494c09 Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Fri, 9 Nov 2018 17:36:44 +0000 Subject: [PATCH 1427/1491] MNT-19537 Test Added for Content with Special characters --- .../org/alfresco/rest/search/SearchTest.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/search/SearchTest.java b/e2e-test/java/org/alfresco/rest/search/SearchTest.java index 8d6d97a28..438f25a19 100644 --- a/e2e-test/java/org/alfresco/rest/search/SearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/SearchTest.java @@ -20,6 +20,8 @@ package org.alfresco.rest.search; import junit.framework.Assert; import org.alfresco.rest.model.body.RestNodeLockBodyModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FileType; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; @@ -180,4 +182,24 @@ public class SearchTest extends AbstractSearchTest restClient.onResponse().assertThat().body("list.entries.entry[0].name", Matchers.nullValue()); restClient.onResponse().assertThat().body("list.entries.entry[0].id", Matchers.nullValue()); } + + @Test(groups={TestGroup.SEARCH,TestGroup.REST_API}) + public void searchSpecialCharacters() throws Exception + { + // Create a file with Special Characters + String specialCharfileName = "è¥äæ§ç§-åæ.pdf"; + FileModel file = new FileModel(specialCharfileName, "è¥äæ§ç§-忬¯¸" + "è¥äæ§ç§-忬¯¸", "è¥äæ§ç§-忬¯¸", FileType.TEXT_PLAIN, "Text file with Special Characters: " + specialCharfileName); + dataContent.usingUser(userModel).usingSite(siteModel).createContent(file); + + waitForIndexing(file.getName(), true); + + // Search + SearchRequest searchReq = createQuery("name:'" + specialCharfileName + "'"); + SearchResponse nodes = query(searchReq); + + restClient.assertStatusCodeIs(HttpStatus.OK); + nodes.assertThat().entriesListIsNotEmpty(); + + restClient.onResponse().assertThat().body("list.entries.entry[0].name", Matchers.equalToIgnoringCase(specialCharfileName)); + } } From 383c18e27927166fcaad029003aae1ecfc236bfd Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Fri, 9 Nov 2018 17:38:43 +0000 Subject: [PATCH 1428/1491] Formatting fixes --- .../java/org/alfresco/rest/search/SearchTest.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/SearchTest.java b/e2e-test/java/org/alfresco/rest/search/SearchTest.java index 438f25a19..5f902ff40 100644 --- a/e2e-test/java/org/alfresco/rest/search/SearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/SearchTest.java @@ -183,20 +183,21 @@ public class SearchTest extends AbstractSearchTest restClient.onResponse().assertThat().body("list.entries.entry[0].id", Matchers.nullValue()); } - @Test(groups={TestGroup.SEARCH,TestGroup.REST_API}) + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API }) public void searchSpecialCharacters() throws Exception - { + { // Create a file with Special Characters String specialCharfileName = "è¥äæ§ç§-åæ.pdf"; - FileModel file = new FileModel(specialCharfileName, "è¥äæ§ç§-忬¯¸" + "è¥äæ§ç§-忬¯¸", "è¥äæ§ç§-忬¯¸", FileType.TEXT_PLAIN, "Text file with Special Characters: " + specialCharfileName); + FileModel file = new FileModel(specialCharfileName, "è¥äæ§ç§-忬¯¸" + "è¥äæ§ç§-忬¯¸", "è¥äæ§ç§-忬¯¸", FileType.TEXT_PLAIN, + "Text file with Special Characters: " + specialCharfileName); dataContent.usingUser(userModel).usingSite(siteModel).createContent(file); waitForIndexing(file.getName(), true); - + // Search SearchRequest searchReq = createQuery("name:'" + specialCharfileName + "'"); SearchResponse nodes = query(searchReq); - + restClient.assertStatusCodeIs(HttpStatus.OK); nodes.assertThat().entriesListIsNotEmpty(); From 46ed5b3899aec7f5251e736deeba372f65433b66 Mon Sep 17 00:00:00 2001 From: cagache Date: Tue, 13 Nov 2018 14:06:28 +0200 Subject: [PATCH 1429/1491] Added support to execute actions with multiple parameters --- e2e-test/java/org/alfresco/rest/actions/ActionsTests.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/actions/ActionsTests.java b/e2e-test/java/org/alfresco/rest/actions/ActionsTests.java index 78ed3b53e..df822111d 100644 --- a/e2e-test/java/org/alfresco/rest/actions/ActionsTests.java +++ b/e2e-test/java/org/alfresco/rest/actions/ActionsTests.java @@ -2,6 +2,8 @@ package org.alfresco.rest.actions; import static org.testng.Assert.assertFalse; +import com.google.common.collect.ImmutableMap; + import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestActionDefinitionModel; @@ -86,7 +88,8 @@ public class ActionsTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.ACTIONS, TestGroup.SANITY}) public void executeAction() throws Exception { - JSONObject response = restClient.authenticateUser(adminUser).withCoreAPI().usingActions().executeAction("add-features", document, "aspect-name", "cm:versionable"); + JSONObject response = restClient.authenticateUser(adminUser).withCoreAPI().usingActions().executeAction + ("add-features", document, ImmutableMap.of("aspect-name", "cm:versionable")); restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); assertFalse(response.getString("id").isEmpty()); From fb7edee2d8ffb77b006b05ae372bd024f142bc50 Mon Sep 17 00:00:00 2001 From: cagache Date: Thu, 6 Dec 2018 09:41:18 +0200 Subject: [PATCH 1430/1491] Update getRepositoryInstalledModules test to check that the glacier connector module is also installed --- .../rest/discovery/DiscoveryTests.java | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/discovery/DiscoveryTests.java b/e2e-test/java/org/alfresco/rest/discovery/DiscoveryTests.java index b6a1911c0..e3ba0fc60 100644 --- a/e2e-test/java/org/alfresco/rest/discovery/DiscoveryTests.java +++ b/e2e-test/java/org/alfresco/rest/discovery/DiscoveryTests.java @@ -3,6 +3,7 @@ package org.alfresco.rest.discovery; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; +import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -65,21 +66,18 @@ public class DiscoveryTests extends RestTest // Check that all modules are present List modules = restClient.onResponse().getResponse().jsonPath().getList("entry.repository.modules.id", String.class); - assertTrue(modules.contains("alfresco-aos-module")); - assertTrue(modules.contains("org.alfresco.integrations.google.docs")); - assertTrue(modules.contains("org_alfresco_integrations_S3Connector")); - assertTrue(modules.contains("org_alfresco_module_xamconnector")); - assertTrue(modules.contains("org.alfresco.module.KofaxAddon")); - assertTrue(modules.contains("alfresco-content-connector-for-salesforce-repo")); - assertTrue(modules.contains("alfresco-share-services")); - assertTrue(modules.contains("alfresco-saml-repo")); - assertTrue(modules.contains("org_alfresco_device_sync_repo")); - assertTrue(modules.contains("org_alfresco_mm_repo")); - assertTrue(modules.contains("org.alfresco.module.TransformationServer")); + List expectedModules = Arrays.asList("alfresco-aos-module", "org.alfresco.integrations.google.docs", + "org_alfresco_integrations_S3Connector", "org_alfresco_module_xamconnector", + "org.alfresco.module.KofaxAddon", "alfresco-content-connector-for-salesforce-repo", + "alfresco-share-services", "alfresco-saml-repo", "org_alfresco_device_sync_repo", + "org_alfresco_mm_repo", "org.alfresco.module.TransformationServer", "alfresco-glacier-connector-repo"); + + expectedModules.forEach(module -> + assertTrue(modules.contains(module), String.format("Expected module %s is not installed", module))); // Check that all installed modules are in INSTALLED state List modulesStates = restClient.onResponse().getResponse().jsonPath().getList("entry.repository.modules.installState", String.class); - assertEquals(Collections.frequency(modulesStates, "INSTALLED"), 11); + assertEquals(Collections.frequency(modulesStates, "INSTALLED"), expectedModules.size()); } @Test(groups = { TestGroup.REST_API, TestGroup.DISCOVERY, TestGroup.SANITY, TestGroup.CORE }) From 16c42a831efce9a098d86f6a5f72130c24e33308 Mon Sep 17 00:00:00 2001 From: agazzarini Date: Fri, 7 Dec 2018 08:43:33 +0100 Subject: [PATCH 1431/1491] [ MNT-19763 ] Sort integration tests --- .../org/alfresco/rest/search/SearchTest.java | 107 +++++++++++++++++- 1 file changed, 101 insertions(+), 6 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/SearchTest.java b/e2e-test/java/org/alfresco/rest/search/SearchTest.java index 5f902ff40..d3158b337 100644 --- a/e2e-test/java/org/alfresco/rest/search/SearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/SearchTest.java @@ -18,6 +18,15 @@ */ package org.alfresco.rest.search; +import static org.codehaus.groovy.runtime.InvokerHelper.asList; +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.notNullValue; +import static org.hamcrest.Matchers.nullValue; +import static org.testng.AssertJUnit.assertEquals; +import static java.util.Collections.reverse; +import static java.util.Arrays.asList; + import junit.framework.Assert; import org.alfresco.rest.model.body.RestNodeLockBodyModel; import org.alfresco.utility.model.FileModel; @@ -31,12 +40,7 @@ import org.testng.annotations.Test; import java.util.ArrayList; import java.util.List; - -import static org.codehaus.groovy.runtime.InvokerHelper.asList; -import static org.hamcrest.Matchers.containsString; -import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.notNullValue; -import static org.hamcrest.Matchers.nullValue; +import java.util.stream.Collectors; /** * Search end point Public API test. @@ -83,6 +87,97 @@ public class SearchTest extends AbstractSearchTest response.getContext().assertThat().field("request").isNotEmpty(); } + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, + description = "Tests a search request containing a sort clause.") + public void searchWithOneSortClause() throws Exception + { + // Tests the ascending order first + List expectedOrder = asList("alfresco.txt", "cars.txt", "pangram.txt"); + + SearchRequest searchRequest = createQuery("cm_name:alfresco\\.txt cm_name:cars\\.txt cm_name:pangram\\.txt"); + searchRequest.addSortClause("FIELD", "name", true); + + RestRequestFilterQueryModel filters = new RestRequestFilterQueryModel(); + filters.setQuery("SITE:'" + siteModel.getId() + "'"); + searchRequest.setFilterQueries(filters); + + SearchResponse responseWithAscendingOrder = query(searchRequest); + + restClient.assertStatusCodeIs(HttpStatus.OK); + + assertEquals( + expectedOrder, + responseWithAscendingOrder.getEntries().stream() + .map(SearchNodeModel::getModel) + .map(SearchNodeModel::getName) + .collect(Collectors.toList())); + + // Reverts the expected order... + reverse(expectedOrder); + + // ...and test the descending order + searchRequest.getSort().clear(); + searchRequest.addSortClause("FIELD", "name", false); + + SearchResponse responseWithDescendingOrder = query(searchRequest); + assertEquals( + expectedOrder, + responseWithDescendingOrder.getEntries().stream() + .map(SearchNodeModel::getModel) + .map(SearchNodeModel::getName) + .collect(Collectors.toList())); + } + + /** + * Tests the query execution with two sort clauses. + * The first clause has always the same value for all matches so the test makes sure the request is correctly + * processed and the returned order is determined by the second clause. + */ + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, + description = "Tests a search request containing a sort clause.") + public void searchWithTwoSortClauses() throws Exception + { + // Tests the ascending order first + List expectedOrder = asList("alfresco.txt", "cars.txt", "pangram.txt"); + + SearchRequest searchRequest = createQuery("cm_name:alfresco\\.txt cm_name:cars\\.txt cm_name:pangram\\.txt"); + searchRequest.addSortClause("FIELD", "name", true); + searchRequest.addSortClause("FIELD", "createdByUser.id", true); + + RestRequestFilterQueryModel filters = new RestRequestFilterQueryModel(); + filters.setQuery("SITE:'" + siteModel.getId() + "'"); + searchRequest.setFilterQueries(filters); + + SearchResponse responseWithAscendingOrder = query(searchRequest); + + restClient.assertStatusCodeIs(HttpStatus.OK); + + assertEquals( + expectedOrder, + responseWithAscendingOrder.getEntries().stream() + .map(SearchNodeModel::getModel) + .map(SearchNodeModel::getName) + .collect(Collectors.toList())); + + // Reverts the expected order... + reverse(expectedOrder); + + // ...and test the descending order + searchRequest.getSort().clear(); + searchRequest.addSortClause("FIELD", "name", false); + searchRequest.addSortClause("FIELD", "createdByUser.id", true); + + SearchResponse responseWithDescendingOrder = query(searchRequest); + assertEquals( + expectedOrder, + responseWithDescendingOrder.getEntries().stream() + .map(SearchNodeModel::getModel) + .map(SearchNodeModel::getName) + .collect(Collectors.toList())); + } + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ACS_61n }) @TestRail(section = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ACS_61n }, executionType = ExecutionType.REGRESSION, description = "Checks the \"include\" request parameter support the 'permissions' option") public void searchQuery_includePermissions_shouldReturnNodeWithPermissionsInformation() From 8966fe6e551bf939282960ed5ca497aa8b68f446 Mon Sep 17 00:00:00 2001 From: Tom Page Date: Fri, 21 Dec 2018 14:41:03 +0000 Subject: [PATCH 1432/1491] SEARCH-1351 Add REST API tests for sql filter queries. --- .../rest/search/AbstractSearchTest.java | 12 +--- .../rest/search/sql/SearchSQLAPITest.java | 69 ++++++++++++++++++- 2 files changed, 70 insertions(+), 11 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java index 1b63456e7..08a60b281 100644 --- a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java @@ -96,7 +96,7 @@ public class AbstractSearchTest extends RestTest dataContent.usingUser(userModel).usingSite(siteModel).usingResource(folder).createContent(file2); dataContent.usingUser(userModel).usingSite(siteModel).usingResource(folder).createContent(file3); dataContent.usingUser(userModel).usingSite(siteModel).usingResource(folder).createContent(file4); - + waitForIndexing(file4.getName(), true); } @@ -190,7 +190,6 @@ public class AbstractSearchTest extends RestTest */ public boolean waitForIndexing(String userQuery, boolean expectedInResults) throws Exception { - boolean found = false; boolean resultAsExpected = false; String expectedStatusCode = HttpStatus.OK.toString(); @@ -202,14 +201,7 @@ public class AbstractSearchTest extends RestTest if (restClient.getStatusCode().matches(expectedStatusCode)) { - if (response.getEntries().size() >= 1) - { - found = true; - } - else - { - found = false; - } + boolean found = !response.getEntries().isEmpty(); // Loop again if result is not as expected: To cater for solr lag: eventual consistency resultAsExpected = (expectedInResults == found); diff --git a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLAPITest.java b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLAPITest.java index 20c23179e..db06022c7 100644 --- a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLAPITest.java +++ b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLAPITest.java @@ -681,4 +681,71 @@ public class SearchSQLAPITest extends AbstractSearchTest restClient.assertStatusCodeIs(HttpStatus.OK); restClient.onResponse().assertThat().body("result-set.docs[0].cm_name", Matchers.notNullValue()); } -} \ No newline at end of file + + /** Check that a filter query can affect which results are included. */ + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_11 }, priority = 16) + public void testFilterQuery() throws Exception + { + UserModel userPerm = dataUser.createRandomTestUser("UserSearchPerm"); + + dataUser.addUserToSite(userPerm, siteModel, UserRole.SiteContributor); + + String siteSQL = "select SITE, CM_OWNER from alfresco where SITE='" + siteModel.getId() + "'"; + SearchSqlRequest sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql(siteSQL); + + // Add a filter query to only include results from inside the site (i.e. all results). + String[] filterQuery = { "SITE:'" + siteModel.getId() + "'" }; + sqlRequest.setFilterQuery(filterQuery); + + // Results expected for query as User does has access to the private site + restClient.authenticateUser(userPerm).withSearchSqlAPI().searchSql(sqlRequest); + restClient.assertStatusCodeIs(HttpStatus.OK); + + restClient.onResponse().assertThat().body("list.pagination.count", Matchers.greaterThan(0)); + restClient.onResponse().assertThat().body("list.pagination.totalItems", Matchers.greaterThan(0)); + restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", Matchers.equalToIgnoringCase("SITE")); + restClient.onResponse().assertThat().body("list.entries.entry[0][0].value", Matchers.equalToIgnoringCase("[\"" + siteModel.getId() + "\"]")); + + // Now try instead removing everything from the site (i.e. all results). + String[] inverseFilterQuery = { "-SITE:'" + siteModel.getId() + "'" }; + sqlRequest.setFilterQuery(inverseFilterQuery); + + restClient.authenticateUser(userPerm).withSearchSqlAPI().searchSql(sqlRequest); + restClient.assertStatusCodeIs(HttpStatus.OK); + + restClient.onResponse().assertThat().body("list.pagination.count", Matchers.is(0)); + restClient.onResponse().assertThat().body("list.pagination.totalItems", Matchers.is(0)); + restClient.onResponse().assertThat().body("list.pagination.hasMoreItems", Matchers.is(false)); + restClient.onResponse().assertThat().body("list.entries", Matchers.empty()); + } + + /** Check that the combination of multiple filter queries produce the intersection of results. */ + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_11 }, priority = 17) + public void testCombiningFilterQueries() throws Exception + { + UserModel userPerm = dataUser.createRandomTestUser("UserSearchPerm"); + dataUser.addUserToSite(userPerm, siteModel, UserRole.SiteContributor); + + String siteSQL = "select cm_name from alfresco where SITE='" + siteModel.getId() + "'"; + SearchSqlRequest sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql(siteSQL); + + // Add a filter query to only include results from inside the site (i.e. all results). + String[] filterQueries = { "-cm_name:'cars'", "-cm_name:'pangram'" }; + sqlRequest.setFilterQuery(filterQueries); + + // Results expected for query as User does has access to the private site + restClient.authenticateUser(userPerm).withSearchSqlAPI().searchSql(sqlRequest); + restClient.assertStatusCodeIs(HttpStatus.OK); + + restClient.onResponse().assertThat().body("list.pagination.count", Matchers.greaterThan(0)); + restClient.onResponse().assertThat().body("list.pagination.totalItems", Matchers.greaterThan(0)); + restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", Matchers.equalToIgnoringCase("cm_name")); + // Check that pangram.txt and cars.txt were both filtered out. + restClient.onResponse().assertThat().body("list.entries.entry[0][0].value", + Matchers.not(Matchers.equalToIgnoringCase("pangram.txt"))); + restClient.onResponse().assertThat().body("list.entries.entry[0][0].value", + Matchers.not(Matchers.equalToIgnoringCase("cars.txt"))); + } +} From 22e1cae35b1c34fe98ab16ce9509dbb21c098f93 Mon Sep 17 00:00:00 2001 From: Alessandro Benedetti Date: Wed, 2 Jan 2019 11:11:57 +0000 Subject: [PATCH 1433/1491] [SEARCH-1346]Fix tas tests in accordance with mincount forced to be >0 --- .../rest/search/FacetRangeSearchTest.java | 19 +++++++------------ .../rest/search/PivotFacetedSearchTest.java | 2 -- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java b/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java index 1add86965..5a3d38299 100644 --- a/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java @@ -31,6 +31,9 @@ import org.springframework.http.HttpStatus; import org.testng.Assert; import org.testng.annotations.Test; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.Is.is; + /** * Faceted Range Search Query for numeric range * { @@ -239,8 +242,11 @@ public class FacetRangeSearchTest extends AbstractSearchTest response.assertThat().entriesListIsNotEmpty(); response.getContext().assertThat().field("facets").isNotEmpty(); RestGenericFacetResponseModel facetResponseModel = response.getContext().getFacets().get(0); + + List buckets = facetResponseModel.getBuckets(); + assertThat(buckets.size(),is(1)); - RestGenericBucketModel bucket = facetResponseModel.getBuckets().get(0); + RestGenericBucketModel bucket = buckets.get(0); bucket.assertThat().field("label").is("[2015-09-29T10:45:15.729Z - 2016-07-05T10:45:15.729Z)"); bucket.assertThat().field("filterQuery").is("created:[\"2015-09-29T10:45:15.729Z\" TO \"2016-07-05T10:45:15.729Z\">"); bucket.getMetrics().get(0).assertThat().field("value").is("{count=1}"); @@ -250,17 +256,6 @@ public class FacetRangeSearchTest extends AbstractSearchTest Assert.assertNull(info.get("count"),"1"); Assert.assertEquals(info.get("startInclusive"),"true"); Assert.assertEquals(info.get("endInclusive"),"false"); - - bucket = facetResponseModel.getBuckets().get(1); - bucket.assertThat().field("label").is("[2016-07-05T10:45:15.729Z - 2017-04-11T10:45:15.729Z]"); - bucket.assertThat().field("filterQuery").is("created:[\"2016-07-05T10:45:15.729Z\" TO \"2017-04-11T10:45:15.729Z\"]"); - bucket.getMetrics().get(0).assertThat().field("value").is("{count=0}"); - info = (Map) bucket.getBucketInfo(); - Assert.assertEquals(info.get("start"),"2016-07-05T10:45:15.729Z"); - Assert.assertEquals(info.get("end"),"2017-04-11T10:45:15.729Z"); - Assert.assertNull(info.get("count"),"0"); - Assert.assertEquals(info.get("startInclusive"),"true"); - Assert.assertEquals(info.get("endInclusive"),"true"); } @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) diff --git a/e2e-test/java/org/alfresco/rest/search/PivotFacetedSearchTest.java b/e2e-test/java/org/alfresco/rest/search/PivotFacetedSearchTest.java index c21b9e2c7..1d85e5f5b 100644 --- a/e2e-test/java/org/alfresco/rest/search/PivotFacetedSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/PivotFacetedSearchTest.java @@ -204,8 +204,6 @@ public class PivotFacetedSearchTest extends AbstractSearchTest RestGenericBucketModel bucket = facetResponseModel.getBuckets().get(0); RestGenericFacetResponseModel rangeResponse = bucket.getFacets().get(0); rangeResponse.assertThat().field("type").is("range"); - assertTrue(rangeResponse.getBuckets().size()>0); - } private void assertPivotResponse(SearchResponse response, String field, String alabel) throws Exception From f979e17a68d927128dd2d65d91ec2c20b355ae46 Mon Sep 17 00:00:00 2001 From: Alessandro Benedetti Date: Thu, 3 Jan 2019 12:29:43 +0000 Subject: [PATCH 1434/1491] [SEARCH-1346]Fix tas tests in accordance with mincount forced to be >0 --- .../org/alfresco/rest/search/FacetRangeSearchTest.java | 6 +++--- .../org/alfresco/rest/search/PivotFacetedSearchTest.java | 9 ++++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java b/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java index 5a3d38299..94778377a 100644 --- a/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java @@ -247,12 +247,12 @@ public class FacetRangeSearchTest extends AbstractSearchTest assertThat(buckets.size(),is(1)); RestGenericBucketModel bucket = buckets.get(0); - bucket.assertThat().field("label").is("[2015-09-29T10:45:15.729Z - 2016-07-05T10:45:15.729Z)"); - bucket.assertThat().field("filterQuery").is("created:[\"2015-09-29T10:45:15.729Z\" TO \"2016-07-05T10:45:15.729Z\">"); + bucket.assertThat().field("label").is("[2015-09-29T10:45:15.729Z - 2017-04-11T10:45:15.729Z)"); + bucket.assertThat().field("filterQuery").is("created:[\"2015-09-29T10:45:15.729Z\" TO \"2017-04-11T10:45:15.729Z\">"); bucket.getMetrics().get(0).assertThat().field("value").is("{count=1}"); Map info = (Map) bucket.getBucketInfo(); Assert.assertEquals(info.get("start"),"2015-09-29T10:45:15.729Z"); - Assert.assertEquals(info.get("end"),"2016-07-05T10:45:15.729Z"); + Assert.assertEquals(info.get("end"),"2017-04-11T10:45:15.729Z"); Assert.assertNull(info.get("count"),"1"); Assert.assertEquals(info.get("startInclusive"),"true"); Assert.assertEquals(info.get("endInclusive"),"false"); diff --git a/e2e-test/java/org/alfresco/rest/search/PivotFacetedSearchTest.java b/e2e-test/java/org/alfresco/rest/search/PivotFacetedSearchTest.java index 1d85e5f5b..070a7b9ed 100644 --- a/e2e-test/java/org/alfresco/rest/search/PivotFacetedSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/PivotFacetedSearchTest.java @@ -18,8 +18,8 @@ */ package org.alfresco.rest.search; -import static org.junit.Assert.assertTrue; - +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -167,6 +167,9 @@ public class PivotFacetedSearchTest extends AbstractSearchTest public void searchWithRangePivoting() throws Exception { SearchRequest query = carsQuery(); + + String endDate = LocalDateTime.now() + .format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss'Z'")); //the car document is created at runtime, so to include it in range facets end date must be now Pagination pagination = new Pagination(); pagination.setMaxItems(2); @@ -181,7 +184,7 @@ public class PivotFacetedSearchTest extends AbstractSearchTest RestRequestRangesModel facetRangeModel = new RestRequestRangesModel(); facetRangeModel.setField("created"); facetRangeModel.setStart("2015-09-29T10:45:15.729Z"); - facetRangeModel.setEnd("2016-09-29T10:45:15.729Z"); + facetRangeModel.setEnd(endDate); facetRangeModel.setGap("+280DAY"); facetRangeModel.setLabel("aRange"); List ranges = new ArrayList(); From 03aac3097a936d9454e7647247e525f5a7f4ca64 Mon Sep 17 00:00:00 2001 From: Andrei Forascu Date: Mon, 7 Jan 2019 14:47:16 +0000 Subject: [PATCH 1435/1491] REPO-4133: 6.1: ACE-5938: REST-API Workflow tests are failing on ACS 6.1 --- .../processes/AddProcessCoreTests.java | 3 +-- .../AddProcessVariableFullTests.java | 19 ------------------- .../rest/workflow/tasks/UpdateTaskTests.java | 8 ++------ 3 files changed, 3 insertions(+), 27 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessCoreTests.java index c818fd7ee..5b187039f 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessCoreTests.java @@ -61,8 +61,7 @@ public class AddProcessCoreTests extends RestTest restClient.authenticateUser(adminUser).withWorkflowAPI(); RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "", "processes"); restClient.processModel(RestProcessModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.NO_CONTENT, "No content to map to Object due to end of input")); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); } @Bug(id = "REPO-1936") diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariableFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariableFullTests.java index b9962d9e1..098a0658d 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariableFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariableFullTests.java @@ -66,25 +66,6 @@ public class AddProcessVariableFullTests extends RestTest .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); } - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding process variable is falling in case of empty value is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void failedAddingProcessVariableIfEmptyValueIsProvided() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:int"); - variableModel.setValue(""); - - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .containsSummary(String.format(RestErrorModel.FOR_INPUT_STRING, "")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process variable in case of having only 'name' field is provided") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskTests.java index 2e822fb34..744773f3a 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskTests.java @@ -1205,9 +1205,7 @@ public class UpdateTaskTests extends RestTest .build(); restClient.authenticateUser(anyUser).withParams("select=dueAt").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "Can not construct instance of java.util.Date from String value 'invalid-date'")) - .containsSummary(String.format(RestErrorModel.NO_CONTENT, "Can not construct instance of java.util.Date from String value 'invalid-date'")); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); } @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @@ -1220,9 +1218,7 @@ public class UpdateTaskTests extends RestTest .build(); restClient.authenticateUser(anyUser).withParams("select=priority").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "Can not construct instance of int from String value 'a'")) - .containsSummary(String.format(RestErrorModel.NO_CONTENT, "Can not construct instance of int from String value 'a'")); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); } @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) From 4ea5c77757f4c0b1f07bca642f291f83377655be Mon Sep 17 00:00:00 2001 From: Alessandro Benedetti Date: Tue, 8 Jan 2019 18:48:09 +0000 Subject: [PATCH 1436/1491] [SEARCH-1346]Minor Fix tas test in accordance with mincount forced to be >0 --- .../java/org/alfresco/rest/search/FacetRangeSearchTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java b/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java index 94778377a..379dce91f 100644 --- a/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java @@ -247,8 +247,8 @@ public class FacetRangeSearchTest extends AbstractSearchTest assertThat(buckets.size(),is(1)); RestGenericBucketModel bucket = buckets.get(0); - bucket.assertThat().field("label").is("[2015-09-29T10:45:15.729Z - 2017-04-11T10:45:15.729Z)"); - bucket.assertThat().field("filterQuery").is("created:[\"2015-09-29T10:45:15.729Z\" TO \"2017-04-11T10:45:15.729Z\">"); + bucket.assertThat().field("label").is("[2015-09-29T10:45:15.729Z - 2017-04-11T10:45:15.729Z]"); + bucket.assertThat().field("filterQuery").is("created:[\"2015-09-29T10:45:15.729Z\" TO \"2017-04-11T10:45:15.729Z\"]"); bucket.getMetrics().get(0).assertThat().field("value").is("{count=1}"); Map info = (Map) bucket.getBucketInfo(); Assert.assertEquals(info.get("start"),"2015-09-29T10:45:15.729Z"); From 9782d300d728e90f15f496b5209cf401801e65cb Mon Sep 17 00:00:00 2001 From: Tuna Aksoy Date: Tue, 8 Jan 2019 22:42:54 +0000 Subject: [PATCH 1437/1491] Removed junit as a dependency to fix the hamcrest Matchers issue. All the Assert class references from junit has been replaced with testng.Assert --- .../nodes/NodesContentAndVersioningTests.java | 1 - .../rest/search/FacetRangeSearchTest.java | 6 +++--- .../rest/search/SearchSpellCheckTest.java | 2 +- .../java/org/alfresco/rest/search/SearchTest.java | 15 ++++++++------- .../rest/search/solr/SearchSolrAPITest.java | 3 +-- 5 files changed, 13 insertions(+), 14 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/nodes/NodesContentAndVersioningTests.java b/e2e-test/java/org/alfresco/rest/nodes/NodesContentAndVersioningTests.java index 8a31ff183..a3770353a 100644 --- a/e2e-test/java/org/alfresco/rest/nodes/NodesContentAndVersioningTests.java +++ b/e2e-test/java/org/alfresco/rest/nodes/NodesContentAndVersioningTests.java @@ -33,7 +33,6 @@ import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.json.JSONObject; -import org.junit.Ignore; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; diff --git a/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java b/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java index 379dce91f..bf6ea9b78 100644 --- a/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java @@ -18,6 +18,9 @@ */ package org.alfresco.rest.search; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.Is.is; + import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -31,9 +34,6 @@ import org.springframework.http.HttpStatus; import org.testng.Assert; import org.testng.annotations.Test; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.core.Is.is; - /** * Faceted Range Search Query for numeric range * { diff --git a/e2e-test/java/org/alfresco/rest/search/SearchSpellCheckTest.java b/e2e-test/java/org/alfresco/rest/search/SearchSpellCheckTest.java index c55d0b215..6e1031f85 100644 --- a/e2e-test/java/org/alfresco/rest/search/SearchSpellCheckTest.java +++ b/e2e-test/java/org/alfresco/rest/search/SearchSpellCheckTest.java @@ -22,7 +22,7 @@ import org.alfresco.rest.model.RestRequestSpellcheckModel; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FileType; import org.alfresco.utility.model.TestGroup; -import org.junit.Assert; +import org.testng.Assert; import org.testng.annotations.Test; /** diff --git a/e2e-test/java/org/alfresco/rest/search/SearchTest.java b/e2e-test/java/org/alfresco/rest/search/SearchTest.java index d3158b337..57b4dde70 100644 --- a/e2e-test/java/org/alfresco/rest/search/SearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/SearchTest.java @@ -18,16 +18,20 @@ */ package org.alfresco.rest.search; +import static java.util.Arrays.asList; +import static java.util.Collections.reverse; + import static org.codehaus.groovy.runtime.InvokerHelper.asList; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.notNullValue; import static org.hamcrest.Matchers.nullValue; import static org.testng.AssertJUnit.assertEquals; -import static java.util.Collections.reverse; -import static java.util.Arrays.asList; -import junit.framework.Assert; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + import org.alfresco.rest.model.body.RestNodeLockBodyModel; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FileType; @@ -36,12 +40,9 @@ import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.hamcrest.Matchers; import org.springframework.http.HttpStatus; +import org.testng.Assert; import org.testng.annotations.Test; -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Collectors; - /** * Search end point Public API test. * @author Michael Suzuki diff --git a/e2e-test/java/org/alfresco/rest/search/solr/SearchSolrAPITest.java b/e2e-test/java/org/alfresco/rest/search/solr/SearchSolrAPITest.java index 1aaeb6dab..0f1ed9f06 100644 --- a/e2e-test/java/org/alfresco/rest/search/solr/SearchSolrAPITest.java +++ b/e2e-test/java/org/alfresco/rest/search/solr/SearchSolrAPITest.java @@ -24,10 +24,9 @@ import org.alfresco.rest.search.AbstractSearchTest; import org.alfresco.utility.model.TestGroup; import org.hamcrest.Matchers; import org.springframework.http.HttpStatus; +import org.testng.Assert; import org.testng.annotations.Test; -import junit.framework.Assert; - /** * Tests for solr/alfresco Solr API. * From e7b26ffc58a811c30567736364e3fca05bede5ea Mon Sep 17 00:00:00 2001 From: Alessandro Benedetti Date: Wed, 9 Jan 2019 11:15:17 +0000 Subject: [PATCH 1438/1491] [SEARCH-1346]Minor Fix tas test in accordance with mincount forced to be >0 --- .../java/org/alfresco/rest/search/FacetRangeSearchTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java b/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java index bf6ea9b78..a1ff0d517 100644 --- a/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java @@ -255,7 +255,7 @@ public class FacetRangeSearchTest extends AbstractSearchTest Assert.assertEquals(info.get("end"),"2017-04-11T10:45:15.729Z"); Assert.assertNull(info.get("count"),"1"); Assert.assertEquals(info.get("startInclusive"),"true"); - Assert.assertEquals(info.get("endInclusive"),"false"); + Assert.assertEquals(info.get("endInclusive"),"true"); } @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) From ddcee8904bc77b2b9cb9c41c67d1693129591450 Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Thu, 10 Jan 2019 19:20:28 +0000 Subject: [PATCH 1439/1491] Search-1346: New test added to test faceting Related changes --- .../rest/search/AbstractSearchTest.java | 2 +- .../rest/search/FacetedSearchTest.java | 160 ++++++++++++++++++ 2 files changed, 161 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java index 1b63456e7..ea5141c76 100644 --- a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java @@ -197,7 +197,7 @@ public class AbstractSearchTest extends RestTest // Repeat search until the query results are as expected or Search Retry count is hit for (int searchCount = 1; searchCount <= 3; searchCount++) { - SearchRequest searchRequest = createQuery(userQuery); + SearchRequest searchRequest = createQuery("name:" + userQuery); SearchResponse response = query(searchRequest); if (restClient.getStatusCode().matches(expectedStatusCode)) diff --git a/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java b/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java index 351281858..a017466f3 100644 --- a/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java @@ -21,7 +21,14 @@ package org.alfresco.rest.search; import java.util.ArrayList; import java.util.List; +import javax.json.Json; +import javax.json.JsonObject; + +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FileType; +import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.testng.Assert; @@ -309,4 +316,157 @@ public class FacetedSearchTest extends AbstractSearchTest bucket1.assertThat().field("metrics").is("[{entry=null, type=count, value={count=1}}]"); } + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_13 }) + public void searchWithFactedFieldsWithACLs() throws Exception + { + String fname = unique_searchString + "facet"; + + // Create another user who would not have access to the Private Site created by userModel + UserModel user2 = dataUser.createRandomTestUser("UserSearch2"); + UserModel user3 = dataUser.createRandomTestUser("UserSearch3"); + + // Create a folder and a file as test User + FolderModel folder = new FolderModel(fname); + dataContent.usingUser(userModel).usingSite(siteModel).createFolder(folder); + + FileModel file = new FileModel(fname + "-1.txt", fname, fname, FileType.TEXT_PLAIN, fname + " file for search "); + dataContent.usingUser(userModel).usingSite(siteModel).createContent(file); + + FileModel file2 = new FileModel(fname + "-2.html", fname, fname, FileType.HTML, fname + " file 2 for search "); + dataContent.usingUser(userModel).usingSite(siteModel).createContent(file2); + + // Set Node Permissions to allow access for user3 user for text File + JsonObject userPermission = Json.createObjectBuilder() + .add("permissions", Json.createObjectBuilder().add("isInheritanceEnabled", false) + .add("locallySet",Json.createObjectBuilder().add("authorityId", user3.getUsername()) + .add("name", "SiteConsumer").add("accessStatus", "ALLOWED"))) + .build(); + String putBody = userPermission.toString(); + + restClient.authenticateUser(userModel).withCoreAPI().usingNode(file).updateNode(putBody); + + waitForIndexing(file.getName(), true); + + // FacetField: Site Name + + SearchRequest query = new SearchRequest(); + RestRequestQueryModel queryReq = new RestRequestQueryModel(); + queryReq.setQuery("name:" + fname); + query.setQuery(queryReq); + + RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); + List facets = new ArrayList(); + + RestRequestFacetFieldModel facetName = new RestRequestFacetFieldModel("SITE"); + facetName.setLabel("SEARCH.FACET_FIELDS.SITE"); + facetName.setMincount(0); // MinCount = 0 + facets.add(facetName); + + facetName = new RestRequestFacetFieldModel("cm:content.mimetype"); + facetName.setLabel("Mimetype"); + facetName.setMincount(2); // MinCount = 2 + facets.add(facetName); + + facetFields.setFacets(facets); + query.setFacetFields(facetFields); + + // Search query using user who created site: Expect Only 1 Facet bucket to be retrieved + SearchResponse response = query(query); + + Assert.assertFalse(response.getContext().getFacetsFields().isEmpty()); + Assert.assertEquals(response.getContext().getFacetsFields().size(), 1); + + RestResultBucketsModel facetFieldList = response.getContext().getFacetsFields().get(0); + Assert.assertEquals(facetFieldList.getLabel(), "SEARCH.FACET_FIELDS.SITE"); + Assert.assertEquals(facetFieldList.getBuckets().size(), 1); //MimeType bucket won't be shown as minCount = 2 won't be reached + + FacetFieldBucket bucket1 = facetFieldList.getBuckets().get(0); + bucket1.assertThat().field("label").is(siteModel.getId()); + bucket1.assertThat().field("filterQuery").contains(siteModel.getId()); + bucket1.assertThat().field("count").is(3); //One folder and 2 files created above + + // MinCount 1 or not set: Defaults to 1 + query = new SearchRequest(); + queryReq = new RestRequestQueryModel(); + queryReq.setQuery("name:" + fname); + query.setQuery(queryReq); + + facetFields = new RestRequestFacetFieldsModel(); + facets = new ArrayList(); + + facetName = new RestRequestFacetFieldModel("SITE"); + facetName.setLabel("SEARCH.FACET_FIELD1.SITE"); + // MinCount Not set + facets.add(facetName); + + facetName = new RestRequestFacetFieldModel("cm:content.mimetype"); + facetName.setLabel("SEARCH.FACET_FIELD2.Mimetype"); + facetName.setMincount(1); // MinCount = 1 + facets.add(facetName); + + facetFields.setFacets(facets); + query.setFacetFields(facetFields); + + // Search query using user who created site: Expect 2 Facet buckets to be retrieved + response = query(query); + + Assert.assertFalse(response.getContext().getFacetsFields().isEmpty()); + Assert.assertEquals(response.getContext().getFacetsFields().size(), 2); + + List facetFieldBucketsList = response.getContext().getFacetsFields(); + facetFieldList = facetFieldBucketsList.get(0); + Assert.assertEquals(facetFieldList.getLabel(), "SEARCH.FACET_FIELD1.SITE"); + + bucket1 = facetFieldList.getBuckets().get(0); + bucket1.assertThat().field("label").is(siteModel.getId()); + bucket1.assertThat().field("filterQuery").contains(siteModel.getId()); + bucket1.assertThat().field("count").is(3); + + facetFieldList = facetFieldBucketsList.get(1); + Assert.assertEquals(facetFieldList.getLabel(), "SEARCH.FACET_FIELD2.Mimetype"); + Assert.assertEquals(facetFieldList.getBuckets().size(), 2); //MimeType bucket will be shown with 2 buckets + + bucket1 = facetFieldList.getBuckets().get(0); + bucket1.assertThat().field("label").is("text/html"); + bucket1.assertThat().field("filterQuery").contains("text/html"); + bucket1.assertThat().field("count").is(1); + bucket1.assertThat().field("display").is("HTML"); + + bucket1 = facetFieldList.getBuckets().get(1); + bucket1.assertThat().field("label").is("text/plain"); + bucket1.assertThat().field("filterQuery").contains("text/plain"); + bucket1.assertThat().field("count").is(1); + bucket1.assertThat().field("display").is("Plain Text"); + + // Search query using other user: No access hence no buckets expected + response = restClient.authenticateUser(user2).withSearchAPI().search(query); + Assert.assertNull(response.getContext().getFacetsFields()); + + // Search query using user3 + response = restClient.authenticateUser(user3).withSearchAPI().search(query); + Assert.assertFalse(response.getContext().getFacetsFields().isEmpty()); + Assert.assertEquals(response.getContext().getFacetsFields().size(), 2); + + facetFieldBucketsList = response.getContext().getFacetsFields(); + facetFieldList = facetFieldBucketsList.get(0); + + Assert.assertEquals(facetFieldList.getLabel(), "SEARCH.FACET_FIELD1.SITE"); + + bucket1 = facetFieldList.getBuckets().get(0); + bucket1.assertThat().field("label").is(siteModel.getId()); + bucket1.assertThat().field("filterQuery").contains(siteModel.getId()); + bucket1.assertThat().field("count").is(1); + + facetFieldList = facetFieldBucketsList.get(1); + Assert.assertEquals(facetFieldList.getLabel(), "SEARCH.FACET_FIELD2.Mimetype"); + Assert.assertEquals(facetFieldList.getBuckets().size(), 1); //MimeType bucket will be shown with 1 bucket only + + bucket1 = facetFieldList.getBuckets().get(0); + bucket1.assertThat().field("label").is("text/plain"); + bucket1.assertThat().field("label").isNot("text/html"); + bucket1.assertThat().field("filterQuery").contains("text/plain"); + bucket1.assertThat().field("count").is(1); + bucket1.assertThat().field("display").is("Plain Text"); + } + } From e941ca771d5cd01b182133bc0f0533ab52d0a118 Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Thu, 10 Jan 2019 19:22:31 +0000 Subject: [PATCH 1440/1491] Search-1346: Updated comment --- e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java b/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java index a017466f3..0ae52460d 100644 --- a/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java @@ -347,7 +347,7 @@ public class FacetedSearchTest extends AbstractSearchTest waitForIndexing(file.getName(), true); - // FacetField: Site Name + // Create Query with FacetFields: Site and Content MimeType SearchRequest query = new SearchRequest(); RestRequestQueryModel queryReq = new RestRequestQueryModel(); From e6da7e33e194e33ff2f24c68e4a67e380de2405d Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Fri, 11 Jan 2019 13:54:22 +0000 Subject: [PATCH 1441/1491] Search-1346: Updated comments and simplified code based on review comments --- .../rest/search/FacetedSearchTest.java | 85 ++++++++----------- 1 file changed, 36 insertions(+), 49 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java b/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java index 0ae52460d..ed773d311 100644 --- a/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java @@ -344,11 +344,10 @@ public class FacetedSearchTest extends AbstractSearchTest String putBody = userPermission.toString(); restClient.authenticateUser(userModel).withCoreAPI().usingNode(file).updateNode(putBody); - + waitForIndexing(file.getName(), true); - - // Create Query with FacetFields: Site and Content MimeType - + + // Create Query with FacetFields: Site and Content MimeType SearchRequest query = new SearchRequest(); RestRequestQueryModel queryReq = new RestRequestQueryModel(); queryReq.setQuery("name:" + fname); @@ -356,17 +355,10 @@ public class FacetedSearchTest extends AbstractSearchTest RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); List facets = new ArrayList(); - - RestRequestFacetFieldModel facetName = new RestRequestFacetFieldModel("SITE"); - facetName.setLabel("SEARCH.FACET_FIELDS.SITE"); - facetName.setMincount(0); // MinCount = 0 - facets.add(facetName); - - facetName = new RestRequestFacetFieldModel("cm:content.mimetype"); - facetName.setLabel("Mimetype"); - facetName.setMincount(2); // MinCount = 2 - facets.add(facetName); - + + facets.add(new RestRequestFacetFieldModel("SITE", "SEARCH.FACET_FIELDS.SITE", 0)); // MinCount = 0 + facets.add(new RestRequestFacetFieldModel("cm:content.mimetype", "Mimetype", 2)); // MinCount = 2 + facetFields.setFacets(facets); query.setFacetFields(facetFields); @@ -375,16 +367,16 @@ public class FacetedSearchTest extends AbstractSearchTest Assert.assertFalse(response.getContext().getFacetsFields().isEmpty()); Assert.assertEquals(response.getContext().getFacetsFields().size(), 1); - + RestResultBucketsModel facetFieldList = response.getContext().getFacetsFields().get(0); Assert.assertEquals(facetFieldList.getLabel(), "SEARCH.FACET_FIELDS.SITE"); - Assert.assertEquals(facetFieldList.getBuckets().size(), 1); //MimeType bucket won't be shown as minCount = 2 won't be reached - + Assert.assertEquals(facetFieldList.getBuckets().size(), 1); // MimeType bucket won't be shown as minCount = 2 won't be reached + FacetFieldBucket bucket1 = facetFieldList.getBuckets().get(0); bucket1.assertThat().field("label").is(siteModel.getId()); bucket1.assertThat().field("filterQuery").contains(siteModel.getId()); - bucket1.assertThat().field("count").is(3); //One folder and 2 files created above - + bucket1.assertThat().field("count").is(3); // One folder and 2 files created above + // MinCount 1 or not set: Defaults to 1 query = new SearchRequest(); queryReq = new RestRequestQueryModel(); @@ -393,39 +385,31 @@ public class FacetedSearchTest extends AbstractSearchTest facetFields = new RestRequestFacetFieldsModel(); facets = new ArrayList(); - - facetName = new RestRequestFacetFieldModel("SITE"); - facetName.setLabel("SEARCH.FACET_FIELD1.SITE"); - // MinCount Not set - facets.add(facetName); - - facetName = new RestRequestFacetFieldModel("cm:content.mimetype"); - facetName.setLabel("SEARCH.FACET_FIELD2.Mimetype"); - facetName.setMincount(1); // MinCount = 1 - facets.add(facetName); - + + facets.add(new RestRequestFacetFieldModel("SITE", "SEARCH.FACET_FIELD1.SITE", null)); // MinCount Not set + facets.add(new RestRequestFacetFieldModel("cm:content.mimetype", "SEARCH.FACET_FIELD2.Mimetype", 1)); // MinCount = 1 + facetFields.setFacets(facets); query.setFacetFields(facetFields); // Search query using user who created site: Expect 2 Facet buckets to be retrieved response = query(query); - - Assert.assertFalse(response.getContext().getFacetsFields().isEmpty()); - Assert.assertEquals(response.getContext().getFacetsFields().size(), 2); - + List facetFieldBucketsList = response.getContext().getFacetsFields(); + Assert.assertEquals(facetFieldBucketsList.size(), 2, "FacetField"); + facetFieldList = facetFieldBucketsList.get(0); Assert.assertEquals(facetFieldList.getLabel(), "SEARCH.FACET_FIELD1.SITE"); - + bucket1 = facetFieldList.getBuckets().get(0); bucket1.assertThat().field("label").is(siteModel.getId()); bucket1.assertThat().field("filterQuery").contains(siteModel.getId()); bucket1.assertThat().field("count").is(3); - + facetFieldList = facetFieldBucketsList.get(1); Assert.assertEquals(facetFieldList.getLabel(), "SEARCH.FACET_FIELD2.Mimetype"); - Assert.assertEquals(facetFieldList.getBuckets().size(), 2); //MimeType bucket will be shown with 2 buckets - + Assert.assertEquals(facetFieldList.getBuckets().size(), 2); // MimeType bucket will be shown with 2 buckets + bucket1 = facetFieldList.getBuckets().get(0); bucket1.assertThat().field("label").is("text/html"); bucket1.assertThat().field("filterQuery").contains("text/html"); @@ -437,30 +421,34 @@ public class FacetedSearchTest extends AbstractSearchTest bucket1.assertThat().field("filterQuery").contains("text/plain"); bucket1.assertThat().field("count").is(1); bucket1.assertThat().field("display").is("Plain Text"); - + // Search query using other user: No access hence no buckets expected response = restClient.authenticateUser(user2).withSearchAPI().search(query); Assert.assertNull(response.getContext().getFacetsFields()); // Search query using user3 response = restClient.authenticateUser(user3).withSearchAPI().search(query); - Assert.assertFalse(response.getContext().getFacetsFields().isEmpty()); - Assert.assertEquals(response.getContext().getFacetsFields().size(), 2); - + facetFieldBucketsList = response.getContext().getFacetsFields(); + Assert.assertEquals(facetFieldBucketsList.size(), 2); + + // Check FacetField 1 facetFieldList = facetFieldBucketsList.get(0); - + + // User3 has granular permissions to content within this private site, so expect the Site bucket Assert.assertEquals(facetFieldList.getLabel(), "SEARCH.FACET_FIELD1.SITE"); - + bucket1 = facetFieldList.getBuckets().get(0); bucket1.assertThat().field("label").is(siteModel.getId()); bucket1.assertThat().field("filterQuery").contains(siteModel.getId()); bucket1.assertThat().field("count").is(1); - + + // Check FacetField 2 facetFieldList = facetFieldBucketsList.get(1); Assert.assertEquals(facetFieldList.getLabel(), "SEARCH.FACET_FIELD2.Mimetype"); - Assert.assertEquals(facetFieldList.getBuckets().size(), 1); //MimeType bucket will be shown with 1 bucket only - + Assert.assertEquals(facetFieldList.getBuckets().size(), 1); // MimeType bucket will be shown with 1 bucket only + + // User3 has access to text file alone, so expect bucket for text/plain and not for html content. bucket1 = facetFieldList.getBuckets().get(0); bucket1.assertThat().field("label").is("text/plain"); bucket1.assertThat().field("label").isNot("text/html"); @@ -468,5 +456,4 @@ public class FacetedSearchTest extends AbstractSearchTest bucket1.assertThat().field("count").is(1); bucket1.assertThat().field("display").is("Plain Text"); } - } From e443eddce45e05e946885ae0d565b359582275a4 Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Fri, 11 Jan 2019 16:17:32 +0000 Subject: [PATCH 1442/1491] Search-1346: Amended usernames to improve test readability --- .../org/alfresco/rest/search/FacetedSearchTest.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java b/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java index ed773d311..d6dc1855e 100644 --- a/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java @@ -322,8 +322,8 @@ public class FacetedSearchTest extends AbstractSearchTest String fname = unique_searchString + "facet"; // Create another user who would not have access to the Private Site created by userModel - UserModel user2 = dataUser.createRandomTestUser("UserSearch2"); - UserModel user3 = dataUser.createRandomTestUser("UserSearch3"); + UserModel userWithNoAccess = dataUser.createRandomTestUser("UserSearch2"); + UserModel userCanAccessTextFile = dataUser.createRandomTestUser("UserSearch3"); // Create a folder and a file as test User FolderModel folder = new FolderModel(fname); @@ -338,7 +338,7 @@ public class FacetedSearchTest extends AbstractSearchTest // Set Node Permissions to allow access for user3 user for text File JsonObject userPermission = Json.createObjectBuilder() .add("permissions", Json.createObjectBuilder().add("isInheritanceEnabled", false) - .add("locallySet",Json.createObjectBuilder().add("authorityId", user3.getUsername()) + .add("locallySet",Json.createObjectBuilder().add("authorityId", userCanAccessTextFile.getUsername()) .add("name", "SiteConsumer").add("accessStatus", "ALLOWED"))) .build(); String putBody = userPermission.toString(); @@ -423,11 +423,11 @@ public class FacetedSearchTest extends AbstractSearchTest bucket1.assertThat().field("display").is("Plain Text"); // Search query using other user: No access hence no buckets expected - response = restClient.authenticateUser(user2).withSearchAPI().search(query); + response = restClient.authenticateUser(userWithNoAccess).withSearchAPI().search(query); Assert.assertNull(response.getContext().getFacetsFields()); // Search query using user3 - response = restClient.authenticateUser(user3).withSearchAPI().search(query); + response = restClient.authenticateUser(userCanAccessTextFile).withSearchAPI().search(query); facetFieldBucketsList = response.getContext().getFacetsFields(); Assert.assertEquals(facetFieldBucketsList.size(), 2); From 68f51416f4977a05bc2ffb56e6c371d23ffa7cd9 Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Fri, 11 Jan 2019 17:02:44 +0000 Subject: [PATCH 1443/1491] Search-1346: Moved the FacetFields test to its own class, so that the tests could be split meaningfully --- .../rest/search/FacetFieldsSearchTest.java | 246 ++++++++++++++++++ .../rest/search/FacetedSearchTest.java | 141 ---------- e2e-test/resources/SearchSuite.xml | 1 + 3 files changed, 247 insertions(+), 141 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/search/FacetFieldsSearchTest.java diff --git a/e2e-test/java/org/alfresco/rest/search/FacetFieldsSearchTest.java b/e2e-test/java/org/alfresco/rest/search/FacetFieldsSearchTest.java new file mode 100644 index 000000000..504636be3 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/search/FacetFieldsSearchTest.java @@ -0,0 +1,246 @@ +/* + * Copyright (C) 2019 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.rest.search; + +import java.util.ArrayList; +import java.util.List; + +import javax.json.Json; +import javax.json.JsonObject; + +import org.alfresco.dataprep.SiteService.Visibility; +import org.alfresco.utility.data.RandomData; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FileType; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.testng.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Faceted search test with FacetFields + * @author Meenal Bhave + * + */ +public class FacetFieldsSearchTest extends AbstractSearchTest +{ + private UserModel userWithNoAccess, userCanAccessTextFile; + private SiteModel testSite; + private FolderModel testFolder; + private FileModel textFile, htmlFile; + private String fname; + + @BeforeClass(alwaysRun = true) + public void setupEnvironment() throws Exception + { + serverHealth.assertServerIsOnline(); + + fname = unique_searchString + "facet"; + + testSite = new SiteModel(RandomData.getRandomName("SiteSearch")); + testSite.setVisibility(Visibility.PRIVATE); + + testSite = dataSite.usingUser(userModel).createSite(testSite); + + // Create another user who would not have access to the Private Site created by userModel + userWithNoAccess = dataUser.createRandomTestUser("UserSearch2"); + userCanAccessTextFile = dataUser.createRandomTestUser("UserSearch3"); + + testFolder = dataContent.usingSite(testSite).usingUser(userModel).createFolder(); + // Create a folder and a file as test User + FolderModel folder = new FolderModel(fname); + dataContent.usingUser(userModel).usingSite(testSite).createFolder(folder); + + textFile = new FileModel(fname + "-1.txt", fname, fname, FileType.TEXT_PLAIN, fname + " file for search "); + dataContent.usingUser(userModel).usingSite(testSite).createContent(textFile); + + htmlFile = new FileModel(fname + "-2.html", fname, fname, FileType.HTML, fname + " file 2 for search "); + dataContent.usingUser(userModel).usingSite(testSite).createContent(htmlFile); + + // Set Node Permissions to allow access for user3 user for text File + JsonObject userPermission = Json.createObjectBuilder() + .add("permissions", Json.createObjectBuilder().add("isInheritanceEnabled", false) + .add("locallySet",Json.createObjectBuilder().add("authorityId", userCanAccessTextFile.getUsername()) + .add("name", "SiteConsumer").add("accessStatus", "ALLOWED"))) + .build(); + String putBody = userPermission.toString(); + + restClient.authenticateUser(userModel).withCoreAPI().usingNode(textFile).updateNode(putBody); + + // Wait for the file to be indexed + waitForIndexing(htmlFile.getName(), true); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_13 }) + public void testSearchFacetFieldsBucketExcludedWhenMinCount2() throws Exception + { + // Create Query with FacetFields: Site and Content MimeType + SearchRequest query = new SearchRequest(); + RestRequestQueryModel queryReq = new RestRequestQueryModel(); + queryReq.setQuery("name:" + fname); + query.setQuery(queryReq); + + RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); + List facets = new ArrayList(); + + facets.add(new RestRequestFacetFieldModel("SITE", "SEARCH.FACET_FIELDS.SITE", 0)); // MinCount = 0 + facets.add(new RestRequestFacetFieldModel("cm:content.mimetype", "Mimetype", 2)); // MinCount = 2 + + facetFields.setFacets(facets); + query.setFacetFields(facetFields); + + // Search query using user who created site: Expect Only 1 Facet bucket to be retrieved + SearchResponse response = query(query); + + Assert.assertFalse(response.getContext().getFacetsFields().isEmpty()); + Assert.assertEquals(response.getContext().getFacetsFields().size(), 1); + + RestResultBucketsModel facetFieldList = response.getContext().getFacetsFields().get(0); + Assert.assertEquals(facetFieldList.getLabel(), "SEARCH.FACET_FIELDS.SITE"); + Assert.assertEquals(facetFieldList.getBuckets().size(), 1); // MimeType bucket won't be shown as minCount = 2 won't be reached + + FacetFieldBucket bucket1 = facetFieldList.getBuckets().get(0); + bucket1.assertThat().field("label").is(testSite.getId()); + bucket1.assertThat().field("filterQuery").contains(testSite.getId()); + bucket1.assertThat().field("count").is(3); // One folder and 2 files created above + + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_13 }) + public void testSearchWithFacetFieldsMinCountChecks() throws Exception + { + // MinCount 1 or not set: Defaults to 1 + SearchRequest query = new SearchRequest(); + RestRequestQueryModel queryReq = new RestRequestQueryModel(); + queryReq.setQuery("name:" + fname); + query.setQuery(queryReq); + + RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); + List facets = new ArrayList(); + + facets.add(new RestRequestFacetFieldModel("SITE", "SEARCH.FACET_FIELD1.SITE", null)); // MinCount Not set + facets.add(new RestRequestFacetFieldModel("cm:content.mimetype", "SEARCH.FACET_FIELD2.Mimetype", 1)); // MinCount = 1 + + facetFields.setFacets(facets); + query.setFacetFields(facetFields); + + // Search query using user who created site: Expect 2 Facet buckets to be retrieved + SearchResponse response = query(query); + + List facetFieldBucketsList = response.getContext().getFacetsFields(); + Assert.assertEquals(facetFieldBucketsList.size(), 2, "FacetField"); + + RestResultBucketsModel facetFieldList = facetFieldBucketsList.get(0); + Assert.assertEquals(facetFieldList.getLabel(), "SEARCH.FACET_FIELD1.SITE"); + + FacetFieldBucket bucket1 = facetFieldList.getBuckets().get(0); + bucket1.assertThat().field("label").is(testSite.getId()); + bucket1.assertThat().field("filterQuery").contains(testSite.getId()); + bucket1.assertThat().field("count").is(3); + + facetFieldList = facetFieldBucketsList.get(1); + Assert.assertEquals(facetFieldList.getLabel(), "SEARCH.FACET_FIELD2.Mimetype"); + Assert.assertEquals(facetFieldList.getBuckets().size(), 2); // MimeType bucket will be shown with 2 buckets + + bucket1 = facetFieldList.getBuckets().get(0); + bucket1.assertThat().field("label").is("text/html"); + bucket1.assertThat().field("filterQuery").contains("text/html"); + bucket1.assertThat().field("count").is(1); + bucket1.assertThat().field("display").is("HTML"); + + bucket1 = facetFieldList.getBuckets().get(1); + bucket1.assertThat().field("label").is("text/plain"); + bucket1.assertThat().field("filterQuery").contains("text/plain"); + bucket1.assertThat().field("count").is(1); + bucket1.assertThat().field("display").is("Plain Text"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_13 }) + public void testSearchWithFacetFieldsNoFacetsWhenNoAccess() throws Exception + { + SearchRequest query = new SearchRequest(); + RestRequestQueryModel queryReq = new RestRequestQueryModel(); + queryReq.setQuery("name:" + fname); + query.setQuery(queryReq); + + RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); + List facets = new ArrayList(); + + facets.add(new RestRequestFacetFieldModel("SITE", "SEARCH.FACET_FIELD1.SITE", null)); // MinCount Not set + facets.add(new RestRequestFacetFieldModel("cm:content.mimetype", "SEARCH.FACET_FIELD2.Mimetype", 1)); // MinCount = 1 + + facetFields.setFacets(facets); + query.setFacetFields(facetFields); + + // Search query using other user: No access hence no buckets expected + SearchResponse response = restClient.authenticateUser(userWithNoAccess).withSearchAPI().search(query); + Assert.assertNull(response.getContext().getFacetsFields()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_13 }) + public void testSearchWithFacetFieldsOnlyFacetsWhereAccess() throws Exception + { + SearchRequest query = new SearchRequest(); + RestRequestQueryModel queryReq = new RestRequestQueryModel(); + queryReq.setQuery("name:" + fname); + query.setQuery(queryReq); + + RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); + List facets = new ArrayList(); + + facets.add(new RestRequestFacetFieldModel("SITE", "SEARCH.FACET_FIELD1.SITE", null)); // MinCount Not set + facets.add(new RestRequestFacetFieldModel("cm:content.mimetype", "SEARCH.FACET_FIELD2.Mimetype", 1)); // MinCount = 1 + + facetFields.setFacets(facets); + query.setFacetFields(facetFields); + // Search query using user3 + SearchResponse response = restClient.authenticateUser(userCanAccessTextFile).withSearchAPI().search(query); + + List facetFieldBucketsList = response.getContext().getFacetsFields(); + Assert.assertFalse(facetFieldBucketsList.isEmpty()); + Assert.assertEquals(facetFieldBucketsList.size(), 2); + + // Check FacetField 1 + RestResultBucketsModel facetFieldList = facetFieldBucketsList.get(0); + + // User3 has granular permissions to content within this private site, so expect the Site bucket + Assert.assertEquals(facetFieldList.getLabel(), "SEARCH.FACET_FIELD1.SITE"); + + FacetFieldBucket bucket1 = facetFieldList.getBuckets().get(0); + bucket1.assertThat().field("label").is(testSite.getId()); + bucket1.assertThat().field("filterQuery").contains(testSite.getId()); + bucket1.assertThat().field("count").is(1); + + // Check FacetField 2 + facetFieldList = facetFieldBucketsList.get(1); + Assert.assertEquals(facetFieldList.getLabel(), "SEARCH.FACET_FIELD2.Mimetype"); + Assert.assertEquals(facetFieldList.getBuckets().size(), 1); // MimeType bucket will be shown with 1 bucket only + + // User3 has access to text file alone, so expect bucket for text/plain and not for html content. + bucket1 = facetFieldList.getBuckets().get(0); + bucket1.assertThat().field("label").is("text/plain"); + bucket1.assertThat().field("label").isNot("text/html"); + bucket1.assertThat().field("filterQuery").contains("text/plain"); + bucket1.assertThat().field("count").is(1); + bucket1.assertThat().field("display").is("Plain Text"); + } +} diff --git a/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java b/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java index d6dc1855e..595b3cc83 100644 --- a/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java @@ -315,145 +315,4 @@ public class FacetedSearchTest extends AbstractSearchTest bucket1.assertThat().field("filterQuery").is("modifier:\"" + userModel.getUsername() + "\""); bucket1.assertThat().field("metrics").is("[{entry=null, type=count, value={count=1}}]"); } - - @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_13 }) - public void searchWithFactedFieldsWithACLs() throws Exception - { - String fname = unique_searchString + "facet"; - - // Create another user who would not have access to the Private Site created by userModel - UserModel userWithNoAccess = dataUser.createRandomTestUser("UserSearch2"); - UserModel userCanAccessTextFile = dataUser.createRandomTestUser("UserSearch3"); - - // Create a folder and a file as test User - FolderModel folder = new FolderModel(fname); - dataContent.usingUser(userModel).usingSite(siteModel).createFolder(folder); - - FileModel file = new FileModel(fname + "-1.txt", fname, fname, FileType.TEXT_PLAIN, fname + " file for search "); - dataContent.usingUser(userModel).usingSite(siteModel).createContent(file); - - FileModel file2 = new FileModel(fname + "-2.html", fname, fname, FileType.HTML, fname + " file 2 for search "); - dataContent.usingUser(userModel).usingSite(siteModel).createContent(file2); - - // Set Node Permissions to allow access for user3 user for text File - JsonObject userPermission = Json.createObjectBuilder() - .add("permissions", Json.createObjectBuilder().add("isInheritanceEnabled", false) - .add("locallySet",Json.createObjectBuilder().add("authorityId", userCanAccessTextFile.getUsername()) - .add("name", "SiteConsumer").add("accessStatus", "ALLOWED"))) - .build(); - String putBody = userPermission.toString(); - - restClient.authenticateUser(userModel).withCoreAPI().usingNode(file).updateNode(putBody); - - waitForIndexing(file.getName(), true); - - // Create Query with FacetFields: Site and Content MimeType - SearchRequest query = new SearchRequest(); - RestRequestQueryModel queryReq = new RestRequestQueryModel(); - queryReq.setQuery("name:" + fname); - query.setQuery(queryReq); - - RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); - List facets = new ArrayList(); - - facets.add(new RestRequestFacetFieldModel("SITE", "SEARCH.FACET_FIELDS.SITE", 0)); // MinCount = 0 - facets.add(new RestRequestFacetFieldModel("cm:content.mimetype", "Mimetype", 2)); // MinCount = 2 - - facetFields.setFacets(facets); - query.setFacetFields(facetFields); - - // Search query using user who created site: Expect Only 1 Facet bucket to be retrieved - SearchResponse response = query(query); - - Assert.assertFalse(response.getContext().getFacetsFields().isEmpty()); - Assert.assertEquals(response.getContext().getFacetsFields().size(), 1); - - RestResultBucketsModel facetFieldList = response.getContext().getFacetsFields().get(0); - Assert.assertEquals(facetFieldList.getLabel(), "SEARCH.FACET_FIELDS.SITE"); - Assert.assertEquals(facetFieldList.getBuckets().size(), 1); // MimeType bucket won't be shown as minCount = 2 won't be reached - - FacetFieldBucket bucket1 = facetFieldList.getBuckets().get(0); - bucket1.assertThat().field("label").is(siteModel.getId()); - bucket1.assertThat().field("filterQuery").contains(siteModel.getId()); - bucket1.assertThat().field("count").is(3); // One folder and 2 files created above - - // MinCount 1 or not set: Defaults to 1 - query = new SearchRequest(); - queryReq = new RestRequestQueryModel(); - queryReq.setQuery("name:" + fname); - query.setQuery(queryReq); - - facetFields = new RestRequestFacetFieldsModel(); - facets = new ArrayList(); - - facets.add(new RestRequestFacetFieldModel("SITE", "SEARCH.FACET_FIELD1.SITE", null)); // MinCount Not set - facets.add(new RestRequestFacetFieldModel("cm:content.mimetype", "SEARCH.FACET_FIELD2.Mimetype", 1)); // MinCount = 1 - - facetFields.setFacets(facets); - query.setFacetFields(facetFields); - - // Search query using user who created site: Expect 2 Facet buckets to be retrieved - response = query(query); - - List facetFieldBucketsList = response.getContext().getFacetsFields(); - Assert.assertEquals(facetFieldBucketsList.size(), 2, "FacetField"); - - facetFieldList = facetFieldBucketsList.get(0); - Assert.assertEquals(facetFieldList.getLabel(), "SEARCH.FACET_FIELD1.SITE"); - - bucket1 = facetFieldList.getBuckets().get(0); - bucket1.assertThat().field("label").is(siteModel.getId()); - bucket1.assertThat().field("filterQuery").contains(siteModel.getId()); - bucket1.assertThat().field("count").is(3); - - facetFieldList = facetFieldBucketsList.get(1); - Assert.assertEquals(facetFieldList.getLabel(), "SEARCH.FACET_FIELD2.Mimetype"); - Assert.assertEquals(facetFieldList.getBuckets().size(), 2); // MimeType bucket will be shown with 2 buckets - - bucket1 = facetFieldList.getBuckets().get(0); - bucket1.assertThat().field("label").is("text/html"); - bucket1.assertThat().field("filterQuery").contains("text/html"); - bucket1.assertThat().field("count").is(1); - bucket1.assertThat().field("display").is("HTML"); - - bucket1 = facetFieldList.getBuckets().get(1); - bucket1.assertThat().field("label").is("text/plain"); - bucket1.assertThat().field("filterQuery").contains("text/plain"); - bucket1.assertThat().field("count").is(1); - bucket1.assertThat().field("display").is("Plain Text"); - - // Search query using other user: No access hence no buckets expected - response = restClient.authenticateUser(userWithNoAccess).withSearchAPI().search(query); - Assert.assertNull(response.getContext().getFacetsFields()); - - // Search query using user3 - response = restClient.authenticateUser(userCanAccessTextFile).withSearchAPI().search(query); - - facetFieldBucketsList = response.getContext().getFacetsFields(); - Assert.assertEquals(facetFieldBucketsList.size(), 2); - - // Check FacetField 1 - facetFieldList = facetFieldBucketsList.get(0); - - // User3 has granular permissions to content within this private site, so expect the Site bucket - Assert.assertEquals(facetFieldList.getLabel(), "SEARCH.FACET_FIELD1.SITE"); - - bucket1 = facetFieldList.getBuckets().get(0); - bucket1.assertThat().field("label").is(siteModel.getId()); - bucket1.assertThat().field("filterQuery").contains(siteModel.getId()); - bucket1.assertThat().field("count").is(1); - - // Check FacetField 2 - facetFieldList = facetFieldBucketsList.get(1); - Assert.assertEquals(facetFieldList.getLabel(), "SEARCH.FACET_FIELD2.Mimetype"); - Assert.assertEquals(facetFieldList.getBuckets().size(), 1); // MimeType bucket will be shown with 1 bucket only - - // User3 has access to text file alone, so expect bucket for text/plain and not for html content. - bucket1 = facetFieldList.getBuckets().get(0); - bucket1.assertThat().field("label").is("text/plain"); - bucket1.assertThat().field("label").isNot("text/html"); - bucket1.assertThat().field("filterQuery").contains("text/plain"); - bucket1.assertThat().field("count").is(1); - bucket1.assertThat().field("display").is("Plain Text"); - } } diff --git a/e2e-test/resources/SearchSuite.xml b/e2e-test/resources/SearchSuite.xml index 9bfd55eea..425276be0 100644 --- a/e2e-test/resources/SearchSuite.xml +++ b/e2e-test/resources/SearchSuite.xml @@ -13,6 +13,7 @@ + From 19e91ee3c0d97364126b99cf9450f508923d741b Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Fri, 11 Jan 2019 17:06:39 +0000 Subject: [PATCH 1444/1491] Search-1346: Removed folder that wasn't used --- .../org/alfresco/rest/search/FacetFieldsSearchTest.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/FacetFieldsSearchTest.java b/e2e-test/java/org/alfresco/rest/search/FacetFieldsSearchTest.java index 504636be3..36ddf868f 100644 --- a/e2e-test/java/org/alfresco/rest/search/FacetFieldsSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FacetFieldsSearchTest.java @@ -64,12 +64,11 @@ public class FacetFieldsSearchTest extends AbstractSearchTest // Create another user who would not have access to the Private Site created by userModel userWithNoAccess = dataUser.createRandomTestUser("UserSearch2"); userCanAccessTextFile = dataUser.createRandomTestUser("UserSearch3"); - - testFolder = dataContent.usingSite(testSite).usingUser(userModel).createFolder(); - // Create a folder and a file as test User - FolderModel folder = new FolderModel(fname); - dataContent.usingUser(userModel).usingSite(testSite).createFolder(folder); + // Create a folder and a file as test User + testFolder = new FolderModel(fname); + dataContent.usingUser(userModel).usingSite(testSite).createFolder(testFolder); + textFile = new FileModel(fname + "-1.txt", fname, fname, FileType.TEXT_PLAIN, fname + " file for search "); dataContent.usingUser(userModel).usingSite(testSite).createContent(textFile); From febb8b6c0fd9a473cc03d40b40d576a995b4c2c4 Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Mon, 14 Jan 2019 10:07:40 +0000 Subject: [PATCH 1445/1491] Search-1346: Amended comments --- .../java/org/alfresco/rest/search/FacetFieldsSearchTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/search/FacetFieldsSearchTest.java b/e2e-test/java/org/alfresco/rest/search/FacetFieldsSearchTest.java index 36ddf868f..7fb78bf8e 100644 --- a/e2e-test/java/org/alfresco/rest/search/FacetFieldsSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FacetFieldsSearchTest.java @@ -75,7 +75,7 @@ public class FacetFieldsSearchTest extends AbstractSearchTest htmlFile = new FileModel(fname + "-2.html", fname, fname, FileType.HTML, fname + " file 2 for search "); dataContent.usingUser(userModel).usingSite(testSite).createContent(htmlFile); - // Set Node Permissions to allow access for user3 user for text File + // Set Node Permissions to allow access for user for text File JsonObject userPermission = Json.createObjectBuilder() .add("permissions", Json.createObjectBuilder().add("isInheritanceEnabled", false) .add("locallySet",Json.createObjectBuilder().add("authorityId", userCanAccessTextFile.getUsername()) From 7ad8efe6b561040207756a8e17ec6ae3cdf4b2c3 Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Mon, 14 Jan 2019 10:07:58 +0000 Subject: [PATCH 1446/1491] Search-1346: Amended comments --- .../rest/search/FacetFieldsSearchTest.java | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/FacetFieldsSearchTest.java b/e2e-test/java/org/alfresco/rest/search/FacetFieldsSearchTest.java index 7fb78bf8e..0cd0789d5 100644 --- a/e2e-test/java/org/alfresco/rest/search/FacetFieldsSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FacetFieldsSearchTest.java @@ -107,15 +107,15 @@ public class FacetFieldsSearchTest extends AbstractSearchTest facetFields.setFacets(facets); query.setFacetFields(facetFields); - // Search query using user who created site: Expect Only 1 Facet bucket to be retrieved + // Search query using user who created site SearchResponse response = query(query); - - Assert.assertFalse(response.getContext().getFacetsFields().isEmpty()); + + // Expect MimeType bucket with size 1 is excluded as minCount = 2 won't be reached Assert.assertEquals(response.getContext().getFacetsFields().size(), 1); RestResultBucketsModel facetFieldList = response.getContext().getFacetsFields().get(0); Assert.assertEquals(facetFieldList.getLabel(), "SEARCH.FACET_FIELDS.SITE"); - Assert.assertEquals(facetFieldList.getBuckets().size(), 1); // MimeType bucket won't be shown as minCount = 2 won't be reached + Assert.assertEquals(facetFieldList.getBuckets().size(), 1); FacetFieldBucket bucket1 = facetFieldList.getBuckets().get(0); bucket1.assertThat().field("label").is(testSite.getId()); @@ -142,9 +142,10 @@ public class FacetFieldsSearchTest extends AbstractSearchTest facetFields.setFacets(facets); query.setFacetFields(facetFields); - // Search query using user who created site: Expect 2 Facet buckets to be retrieved + // Search query using user who created site SearchResponse response = query(query); + // Expect 2 Facet buckets to be retrieved: MinCount when not set defaults to 1 List facetFieldBucketsList = response.getContext().getFacetsFields(); Assert.assertEquals(facetFieldBucketsList.size(), 2, "FacetField"); @@ -156,9 +157,10 @@ public class FacetFieldsSearchTest extends AbstractSearchTest bucket1.assertThat().field("filterQuery").contains(testSite.getId()); bucket1.assertThat().field("count").is(3); + // MimeType bucket will be shown with 2 buckets facetFieldList = facetFieldBucketsList.get(1); Assert.assertEquals(facetFieldList.getLabel(), "SEARCH.FACET_FIELD2.Mimetype"); - Assert.assertEquals(facetFieldList.getBuckets().size(), 2); // MimeType bucket will be shown with 2 buckets + Assert.assertEquals(facetFieldList.getBuckets().size(), 2); bucket1 = facetFieldList.getBuckets().get(0); bucket1.assertThat().field("label").is("text/html"); @@ -190,8 +192,10 @@ public class FacetFieldsSearchTest extends AbstractSearchTest facetFields.setFacets(facets); query.setFacetFields(facetFields); - // Search query using other user: No access hence no buckets expected + // Search query using other user SearchResponse response = restClient.authenticateUser(userWithNoAccess).withSearchAPI().search(query); + + // User has No access to matching content hence no buckets expected Assert.assertNull(response.getContext().getFacetsFields()); } @@ -211,7 +215,8 @@ public class FacetFieldsSearchTest extends AbstractSearchTest facetFields.setFacets(facets); query.setFacetFields(facetFields); - // Search query using user3 + + // Search query using user SearchResponse response = restClient.authenticateUser(userCanAccessTextFile).withSearchAPI().search(query); List facetFieldBucketsList = response.getContext().getFacetsFields(); @@ -221,7 +226,7 @@ public class FacetFieldsSearchTest extends AbstractSearchTest // Check FacetField 1 RestResultBucketsModel facetFieldList = facetFieldBucketsList.get(0); - // User3 has granular permissions to content within this private site, so expect the Site bucket + // User has granular permissions to content within this private site, so expect the Site bucket Assert.assertEquals(facetFieldList.getLabel(), "SEARCH.FACET_FIELD1.SITE"); FacetFieldBucket bucket1 = facetFieldList.getBuckets().get(0); @@ -229,12 +234,12 @@ public class FacetFieldsSearchTest extends AbstractSearchTest bucket1.assertThat().field("filterQuery").contains(testSite.getId()); bucket1.assertThat().field("count").is(1); - // Check FacetField 2 + // Expect MimeType bucket shows only1 bucket where user has access to content facetFieldList = facetFieldBucketsList.get(1); Assert.assertEquals(facetFieldList.getLabel(), "SEARCH.FACET_FIELD2.Mimetype"); - Assert.assertEquals(facetFieldList.getBuckets().size(), 1); // MimeType bucket will be shown with 1 bucket only + Assert.assertEquals(facetFieldList.getBuckets().size(), 1); - // User3 has access to text file alone, so expect bucket for text/plain and not for html content. + // User has access to text file alone, so expect bucket for text/plain and not for html content. bucket1 = facetFieldList.getBuckets().get(0); bucket1.assertThat().field("label").is("text/plain"); bucket1.assertThat().field("label").isNot("text/html"); From a226a74f78fc3e60042eced2f22b35c6838680f2 Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Thu, 17 Jan 2019 17:22:49 +0000 Subject: [PATCH 1447/1491] Search-1346: Remove unused imports --- .../java/org/alfresco/rest/search/FacetedSearchTest.java | 7 ------- 1 file changed, 7 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java b/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java index 595b3cc83..935ca16ea 100644 --- a/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java @@ -21,14 +21,7 @@ package org.alfresco.rest.search; import java.util.ArrayList; import java.util.List; -import javax.json.Json; -import javax.json.JsonObject; - -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FileType; -import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.testng.Assert; From 2c51e39b2e91d1680fe714758db3156325ba439b Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Thu, 17 Jan 2019 17:30:52 +0000 Subject: [PATCH 1448/1491] Search-1346: Removed isEmpty Check and updated comments --- .../org/alfresco/rest/search/FacetFieldsSearchTest.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/FacetFieldsSearchTest.java b/e2e-test/java/org/alfresco/rest/search/FacetFieldsSearchTest.java index 0cd0789d5..8648242ac 100644 --- a/e2e-test/java/org/alfresco/rest/search/FacetFieldsSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FacetFieldsSearchTest.java @@ -113,6 +113,7 @@ public class FacetFieldsSearchTest extends AbstractSearchTest // Expect MimeType bucket with size 1 is excluded as minCount = 2 won't be reached Assert.assertEquals(response.getContext().getFacetsFields().size(), 1); + // Expect SITE bucket is included and MinCount defaults to 1 RestResultBucketsModel facetFieldList = response.getContext().getFacetsFields().get(0); Assert.assertEquals(facetFieldList.getLabel(), "SEARCH.FACET_FIELDS.SITE"); Assert.assertEquals(facetFieldList.getBuckets().size(), 1); @@ -127,7 +128,6 @@ public class FacetFieldsSearchTest extends AbstractSearchTest @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_13 }) public void testSearchWithFacetFieldsMinCountChecks() throws Exception { - // MinCount 1 or not set: Defaults to 1 SearchRequest query = new SearchRequest(); RestRequestQueryModel queryReq = new RestRequestQueryModel(); queryReq.setQuery("name:" + fname); @@ -136,6 +136,7 @@ public class FacetFieldsSearchTest extends AbstractSearchTest RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); List facets = new ArrayList(); + // MinCount not set facets.add(new RestRequestFacetFieldModel("SITE", "SEARCH.FACET_FIELD1.SITE", null)); // MinCount Not set facets.add(new RestRequestFacetFieldModel("cm:content.mimetype", "SEARCH.FACET_FIELD2.Mimetype", 1)); // MinCount = 1 @@ -216,11 +217,10 @@ public class FacetFieldsSearchTest extends AbstractSearchTest facetFields.setFacets(facets); query.setFacetFields(facetFields); - // Search query using user + // Search query using user that can access 1 text file SearchResponse response = restClient.authenticateUser(userCanAccessTextFile).withSearchAPI().search(query); List facetFieldBucketsList = response.getContext().getFacetsFields(); - Assert.assertFalse(facetFieldBucketsList.isEmpty()); Assert.assertEquals(facetFieldBucketsList.size(), 2); // Check FacetField 1 @@ -234,7 +234,7 @@ public class FacetFieldsSearchTest extends AbstractSearchTest bucket1.assertThat().field("filterQuery").contains(testSite.getId()); bucket1.assertThat().field("count").is(1); - // Expect MimeType bucket shows only1 bucket where user has access to content + // Expect MimeType bucket shows only 1 bucket where user has access to content facetFieldList = facetFieldBucketsList.get(1); Assert.assertEquals(facetFieldList.getLabel(), "SEARCH.FACET_FIELD2.Mimetype"); Assert.assertEquals(facetFieldList.getBuckets().size(), 1); From cda70976be7673a32adc378ecf1f538c062cee00 Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Mon, 21 Jan 2019 21:38:42 +0000 Subject: [PATCH 1449/1491] Search-1346: Updated utility to allow for complex filenames --- e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java index ea5141c76..a473044d7 100644 --- a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java @@ -197,7 +197,7 @@ public class AbstractSearchTest extends RestTest // Repeat search until the query results are as expected or Search Retry count is hit for (int searchCount = 1; searchCount <= 3; searchCount++) { - SearchRequest searchRequest = createQuery("name:" + userQuery); + SearchRequest searchRequest = createQuery("name:'" + userQuery + "'"); SearchResponse response = query(searchRequest); if (restClient.getStatusCode().matches(expectedStatusCode)) From 947222e3334149d5dce3d8c2b23bec3f7462d9e7 Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Tue, 22 Jan 2019 13:24:51 +0000 Subject: [PATCH 1450/1491] SEARCH-1437: Resetting waitForIndexing query back to original --- e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java index a473044d7..1b63456e7 100644 --- a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java @@ -197,7 +197,7 @@ public class AbstractSearchTest extends RestTest // Repeat search until the query results are as expected or Search Retry count is hit for (int searchCount = 1; searchCount <= 3; searchCount++) { - SearchRequest searchRequest = createQuery("name:'" + userQuery + "'"); + SearchRequest searchRequest = createQuery(userQuery); SearchResponse response = query(searchRequest); if (restClient.getStatusCode().matches(expectedStatusCode)) From 80d1cb0240da909184ad25063df382aecd511736 Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Tue, 22 Jan 2019 15:38:12 +0000 Subject: [PATCH 1451/1491] Search-1437: Updated the test group to 121 --- .../org/alfresco/rest/search/FacetFieldsSearchTest.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/FacetFieldsSearchTest.java b/e2e-test/java/org/alfresco/rest/search/FacetFieldsSearchTest.java index 8648242ac..279715700 100644 --- a/e2e-test/java/org/alfresco/rest/search/FacetFieldsSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FacetFieldsSearchTest.java @@ -89,7 +89,7 @@ public class FacetFieldsSearchTest extends AbstractSearchTest waitForIndexing(htmlFile.getName(), true); } - @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_13 }) + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_121 }) public void testSearchFacetFieldsBucketExcludedWhenMinCount2() throws Exception { // Create Query with FacetFields: Site and Content MimeType @@ -125,7 +125,7 @@ public class FacetFieldsSearchTest extends AbstractSearchTest } - @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_13 }) + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_121 }) public void testSearchWithFacetFieldsMinCountChecks() throws Exception { SearchRequest query = new SearchRequest(); @@ -176,7 +176,7 @@ public class FacetFieldsSearchTest extends AbstractSearchTest bucket1.assertThat().field("display").is("Plain Text"); } - @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_13 }) + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_121 }) public void testSearchWithFacetFieldsNoFacetsWhenNoAccess() throws Exception { SearchRequest query = new SearchRequest(); @@ -200,7 +200,7 @@ public class FacetFieldsSearchTest extends AbstractSearchTest Assert.assertNull(response.getContext().getFacetsFields()); } - @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_13 }) + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_121 }) public void testSearchWithFacetFieldsOnlyFacetsWhereAccess() throws Exception { SearchRequest query = new SearchRequest(); From 22c7e27b878065a33338f9e853edad8f3022db77 Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Mon, 28 Jan 2019 17:26:23 +0000 Subject: [PATCH 1452/1491] Search 1438: Improved use of waitForIndexing methods --- .../rest/search/AbstractSearchTest.java | 47 +++++++++++++++++-- .../rest/search/FacetIntervalSearchTest.java | 6 +++ .../rest/search/FacetedSearchTest.java | 9 +++- .../alfresco/rest/search/FingerPrintTest.java | 3 +- .../rest/search/PivotFacetedSearchTest.java | 6 +++ .../rest/search/SearchHighLightTest.java | 3 ++ .../rest/search/SearchSpellCheckTest.java | 2 + .../org/alfresco/rest/search/SearchTest.java | 7 +++ .../alfresco/rest/search/StatsSearchTest.java | 6 +++ 9 files changed, 84 insertions(+), 5 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java index 1b63456e7..3f4b71a12 100644 --- a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java @@ -97,7 +97,7 @@ public class AbstractSearchTest extends RestTest dataContent.usingUser(userModel).usingSite(siteModel).usingResource(folder).createContent(file3); dataContent.usingUser(userModel).usingSite(siteModel).usingResource(folder).createContent(file4); - waitForIndexing(file4.getName(), true); + waitForMetadataIndexing(file4.getName(), true); } /** @@ -183,21 +183,62 @@ public class AbstractSearchTest extends RestTest /** * Wait for Solr to finish indexing: Indexing has caught up = true if search returns appropriate results * - * @param userQuery: string to search for, unique search string will guarantee accurate results + * @param userQuery: search query, this can include the fieldname, unique search string will guarantee accurate results * @param expectedInResults, true if entry is expected in the results set * @return true (indexing is finished) if search returns appropriate results * @throws Exception */ public boolean waitForIndexing(String userQuery, boolean expectedInResults) throws Exception + { + // Use the search query as is: fieldname(s) may or may not be specified within the userQuery + return waitForIndexing(null, userQuery, expectedInResults); + } + + /** + * waitForIndexing method that matches / waits for filename, metadata to be indexed. + * @param userQuery + * @param expectedInResults + * @return + * @throws Exception + */ + public boolean waitForMetadataIndexing(String userQuery, boolean expectedInResults) throws Exception + { + return waitForIndexing("name", userQuery, expectedInResults); + } + + /** + * waitForIndexing method that matches / waits for content to be indexed, this can take longer than metadata indexing. + * Since Metadata is indexed first, use this method where tests, queries need content to be indexed too. + * @param userQuery + * @param expectedInResults + * @return + * @throws Exception + */ + public boolean waitForContentIndexing(String userQuery, boolean expectedInResults) throws Exception + { + return waitForIndexing("cm:content", userQuery, expectedInResults); + } + + /** + * Wait for Solr to finish indexing: Indexing has caught up = true if search returns appropriate results + * + * @param fieldName: specific field to search for, e.g. name. When specified, the query will become: name:'userQuery' + * @param userQuery: search string, unique search string will guarantee accurate results + * @param expectedInResults, true if entry is expected in the results set + * @return true (indexing is finished) if search returns appropriate results + * @throws Exception + */ + private boolean waitForIndexing(String fieldName, String userQuery, boolean expectedInResults) throws Exception { boolean found = false; boolean resultAsExpected = false; String expectedStatusCode = HttpStatus.OK.toString(); + String query = (fieldName == null)? userQuery: String.format("%s:'%s'", fieldName, userQuery); // Repeat search until the query results are as expected or Search Retry count is hit for (int searchCount = 1; searchCount <= 3; searchCount++) { - SearchRequest searchRequest = createQuery(userQuery); + SearchRequest searchRequest = createQuery(query); SearchResponse response = query(searchRequest); if (restClient.getStatusCode().matches(expectedStatusCode)) diff --git a/e2e-test/java/org/alfresco/rest/search/FacetIntervalSearchTest.java b/e2e-test/java/org/alfresco/rest/search/FacetIntervalSearchTest.java index d32f3ebe9..ef9f579dd 100644 --- a/e2e-test/java/org/alfresco/rest/search/FacetIntervalSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FacetIntervalSearchTest.java @@ -24,6 +24,7 @@ import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; import org.testng.Assert; +import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import java.util.Arrays; @@ -35,6 +36,11 @@ import java.util.Arrays; */ public class FacetIntervalSearchTest extends AbstractSearchTest { + @BeforeClass(alwaysRun = true) + public void setupEnvironment() throws Exception + { + waitForContentIndexing(file4.getContent(), true); + } @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, diff --git a/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java b/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java index 935ca16ea..7d991e477 100644 --- a/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java @@ -26,6 +26,7 @@ import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.testng.Assert; import org.testng.TestException; +import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; /** @@ -86,7 +87,13 @@ public class FacetedSearchTest extends AbstractSearchTest * }} * @throws Exception */ - + + @BeforeClass(alwaysRun = true) + public void setupEnvironment() throws Exception + { + waitForContentIndexing(file4.getContent(), true); + } + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) @TestRail(section = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, description = "Checks facet queries for the Search api") diff --git a/e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java b/e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java index 04e0e57bf..0247ebb0e 100644 --- a/e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java @@ -61,7 +61,8 @@ public class FingerPrintTest extends AbstractSearchTest dataContent.usingUser(userModel).usingSite(siteModel).usingResource(folder).createContent(file3); dataContent.usingUser(userModel).usingSite(siteModel).usingResource(folder).createContent(file4); - waitForIndexing(file4.getName(), true); + waitForContentIndexing(file4.getContent(), true); + waitForIndexing("FINGERPRINT:" + file3.getNodeRefWithoutVersion(), true); } /** diff --git a/e2e-test/java/org/alfresco/rest/search/PivotFacetedSearchTest.java b/e2e-test/java/org/alfresco/rest/search/PivotFacetedSearchTest.java index 070a7b9ed..fae882339 100644 --- a/e2e-test/java/org/alfresco/rest/search/PivotFacetedSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/PivotFacetedSearchTest.java @@ -31,6 +31,7 @@ import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; import org.testng.Assert; +import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; /** @@ -40,6 +41,11 @@ import org.testng.annotations.Test; */ public class PivotFacetedSearchTest extends AbstractSearchTest { + @BeforeClass(alwaysRun = true) + public void setupEnvironment() throws Exception + { + waitForContentIndexing(file4.getContent(), true); + } @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, diff --git a/e2e-test/java/org/alfresco/rest/search/SearchHighLightTest.java b/e2e-test/java/org/alfresco/rest/search/SearchHighLightTest.java index 91f082957..06528e684 100644 --- a/e2e-test/java/org/alfresco/rest/search/SearchHighLightTest.java +++ b/e2e-test/java/org/alfresco/rest/search/SearchHighLightTest.java @@ -23,6 +23,7 @@ import java.util.List; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.report.Bug; +import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; /** @@ -36,6 +37,8 @@ public class SearchHighLightTest extends AbstractSearchTest @Bug(id = "TAS-3220") public void searchWithHighLight() throws Exception { + waitForContentIndexing(file2.getContent(), true); + RestRequestQueryModel queryReq = new RestRequestQueryModel(); queryReq.setQuery("cm:content:cars"); queryReq.setUserQuery("cars"); diff --git a/e2e-test/java/org/alfresco/rest/search/SearchSpellCheckTest.java b/e2e-test/java/org/alfresco/rest/search/SearchSpellCheckTest.java index 6e1031f85..9be9d7fd7 100644 --- a/e2e-test/java/org/alfresco/rest/search/SearchSpellCheckTest.java +++ b/e2e-test/java/org/alfresco/rest/search/SearchSpellCheckTest.java @@ -67,6 +67,8 @@ public class SearchSpellCheckTest extends AbstractSearchTest @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ACS_60n}, priority=1) public void testSearchMissSpelled() throws Exception { + waitForContentIndexing(file4.getContent(), true); + // Name SearchRequest searchReq = new SearchRequest(); RestRequestQueryModel queryReq = new RestRequestQueryModel(); diff --git a/e2e-test/java/org/alfresco/rest/search/SearchTest.java b/e2e-test/java/org/alfresco/rest/search/SearchTest.java index 57b4dde70..8db269fd4 100644 --- a/e2e-test/java/org/alfresco/rest/search/SearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/SearchTest.java @@ -41,6 +41,7 @@ import org.alfresco.utility.testrail.annotation.TestRail; import org.hamcrest.Matchers; import org.springframework.http.HttpStatus; import org.testng.Assert; +import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; /** @@ -50,6 +51,12 @@ import org.testng.annotations.Test; */ public class SearchTest extends AbstractSearchTest { + @BeforeClass(alwaysRun = true) + public void setupEnvironment() throws Exception + { + waitForContentIndexing(file4.getContent(), true); + } + @Test(groups={TestGroup.SEARCH, TestGroup.REST_API}) public void searchOnIndexedData() throws Exception { diff --git a/e2e-test/java/org/alfresco/rest/search/StatsSearchTest.java b/e2e-test/java/org/alfresco/rest/search/StatsSearchTest.java index 8e39d9ac8..594bb47b6 100644 --- a/e2e-test/java/org/alfresco/rest/search/StatsSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/StatsSearchTest.java @@ -34,6 +34,7 @@ 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.BeforeClass; import org.testng.annotations.Test; /** @@ -43,6 +44,11 @@ import org.testng.annotations.Test; */ public class StatsSearchTest extends AbstractSearchTest { + @BeforeClass(alwaysRun = true) + public void setupEnvironment() throws Exception + { + waitForContentIndexing(file2.getContent(), true); + } @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, From e7a568fe940bec8470d20a05facc45e4578c8c15 Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Wed, 30 Jan 2019 10:58:39 +0000 Subject: [PATCH 1453/1491] SEARCH-1448: Removed incorrectly set field title and description for html file from test dataprep --- .../java/org/alfresco/rest/search/FacetFieldsSearchTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/search/FacetFieldsSearchTest.java b/e2e-test/java/org/alfresco/rest/search/FacetFieldsSearchTest.java index 279715700..190d66112 100644 --- a/e2e-test/java/org/alfresco/rest/search/FacetFieldsSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FacetFieldsSearchTest.java @@ -72,7 +72,7 @@ public class FacetFieldsSearchTest extends AbstractSearchTest textFile = new FileModel(fname + "-1.txt", fname, fname, FileType.TEXT_PLAIN, fname + " file for search "); dataContent.usingUser(userModel).usingSite(testSite).createContent(textFile); - htmlFile = new FileModel(fname + "-2.html", fname, fname, FileType.HTML, fname + " file 2 for search "); + htmlFile = new FileModel(fname + "-2.html", FileType.HTML, fname + " file 2 for search "); dataContent.usingUser(userModel).usingSite(testSite).createContent(htmlFile); // Set Node Permissions to allow access for user for text File From 3d9dce598e15ce368cb8f04aff313ad955921a25 Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Wed, 30 Jan 2019 17:09:24 +0000 Subject: [PATCH 1454/1491] Search-1438: Additional wait implemented to reduce inconsistent failures --- e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java b/e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java index 0247ebb0e..26874a90a 100644 --- a/e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java @@ -62,6 +62,8 @@ public class FingerPrintTest extends AbstractSearchTest dataContent.usingUser(userModel).usingSite(siteModel).usingResource(folder).createContent(file4); waitForContentIndexing(file4.getContent(), true); + // Additional wait implemented to remove inconsistent failures. Ref: Search-1438 for details + waitForIndexing("FINGERPRINT:" + file2.getNodeRefWithoutVersion(), true); waitForIndexing("FINGERPRINT:" + file3.getNodeRefWithoutVersion(), true); } From 6d7a521cbe0a0a3d671a212de2e1f8f947ad4d45 Mon Sep 17 00:00:00 2001 From: Tom Page Date: Fri, 8 Feb 2019 16:50:43 +0000 Subject: [PATCH 1455/1491] SEARCH-1351 Add test for an empty filter query list. Also make some use of static imports to tidy the tests a little. --- .../rest/search/sql/SearchSQLAPITest.java | 144 +++++++++++------- 1 file changed, 87 insertions(+), 57 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLAPITest.java b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLAPITest.java index db06022c7..3335e85c5 100644 --- a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLAPITest.java +++ b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLAPITest.java @@ -14,16 +14,27 @@ */ package org.alfresco.rest.search.sql; +import static java.util.Arrays.asList; + +import static org.hamcrest.Matchers.containsInAnyOrder; +import static org.hamcrest.Matchers.empty; +import static org.hamcrest.Matchers.equalToIgnoringCase; +import static org.hamcrest.Matchers.everyItem; +import static org.hamcrest.Matchers.greaterThan; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.isIn; +import static org.hamcrest.Matchers.not; + import org.alfresco.rest.core.RestResponse; import org.alfresco.rest.search.AbstractSearchTest; import org.alfresco.rest.search.SearchSqlRequest; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; +import org.hamcrest.Matchers; import org.springframework.http.HttpStatus; import org.testng.Assert; import org.testng.annotations.Test; -import org.hamcrest.Matchers; /** * Tests for /sql end point Search API. @@ -32,6 +43,21 @@ import org.hamcrest.Matchers; */ public class SearchSQLAPITest extends AbstractSearchTest { + /** + * Path selector to get the values of all cm_name entries for returned search results. + *

      + * For example it will retrieve the "alfresco.txt" from: + *

      +     * {"list": {
      +     *    "entries": [
      +     *       {"entry": [{
      +     *          "label": "cm_name",
      +     *          "value": "alfresco.txt"
      +     *       }]},
      +     *       ...
      +     * 
      + */ + private static final String CM_NAME_VALUES = "list.entries.collect {it.entry.findAll {it.label == 'cm_name'}}.flatten().value"; String sql = "select SITE, CM_OWNER from alfresco group by SITE,CM_OWNER"; String[] locales = { "en-US" }; String solrFormat = "solr"; @@ -211,9 +237,9 @@ public class SearchSQLAPITest extends AbstractSearchTest restClient.onResponse().assertThat().body("result-set", Matchers.notNullValue()); restClient.onResponse().assertThat().body("result-set.docs", Matchers.notNullValue()); - restClient.onResponse().assertThat().body("result-set.docs[0].aliases.SITE", Matchers.equalToIgnoringCase("SITE")); - restClient.onResponse().assertThat().body("result-set.docs[0].isMetadata", Matchers.is(true)); - restClient.onResponse().assertThat().body("result-set.docs[0].fields[0]", Matchers.equalToIgnoringCase("SITE")); + restClient.onResponse().assertThat().body("result-set.docs[0].aliases.SITE", equalToIgnoringCase("SITE")); + restClient.onResponse().assertThat().body("result-set.docs[0].isMetadata", is(true)); + restClient.onResponse().assertThat().body("result-set.docs[0].fields[0]", equalToIgnoringCase("SITE")); } /** @@ -284,12 +310,12 @@ public class SearchSQLAPITest extends AbstractSearchTest restClient.onResponse().assertThat().body("result-set", Matchers.nullValue()); restClient.onResponse().assertThat().body("list.entries", Matchers.notNullValue()); - restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", Matchers.equalToIgnoringCase("aliases")); - restClient.onResponse().assertThat().body("list.entries.entry[0][0].value", Matchers.equalToIgnoringCase("{\"SITE\":\"SITE\",\"cm_owner\":\"CM_OWNER\"}")); - restClient.onResponse().assertThat().body("list.entries.entry[0][1].label", Matchers.equalToIgnoringCase("isMetadata")); - restClient.onResponse().assertThat().body("list.entries.entry[0][1].value", Matchers.is("true")); - restClient.onResponse().assertThat().body("list.entries.entry[0][2].label", Matchers.equalToIgnoringCase("fields")); - restClient.onResponse().assertThat().body("list.entries.entry[0][2].value", Matchers.equalToIgnoringCase("[\"SITE\",\"cm_owner\"]")); + restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", equalToIgnoringCase("aliases")); + restClient.onResponse().assertThat().body("list.entries.entry[0][0].value", equalToIgnoringCase("{\"SITE\":\"SITE\",\"cm_owner\":\"CM_OWNER\"}")); + restClient.onResponse().assertThat().body("list.entries.entry[0][1].label", equalToIgnoringCase("isMetadata")); + restClient.onResponse().assertThat().body("list.entries.entry[0][1].value", is("true")); + restClient.onResponse().assertThat().body("list.entries.entry[0][2].label", equalToIgnoringCase("fields")); + restClient.onResponse().assertThat().body("list.entries.entry[0][2].value", equalToIgnoringCase("[\"SITE\",\"cm_owner\"]")); } @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 05) @@ -320,7 +346,7 @@ public class SearchSQLAPITest extends AbstractSearchTest restClient.onResponse().assertThat().body("result-set", Matchers.nullValue()); restClient.onResponse().assertThat().body("list.entries", Matchers.notNullValue()); restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", Matchers.notNullValue()); - restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", Matchers.not("aliases")); + restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", not("aliases")); sqlRequest = new SearchSqlRequest(); sqlRequest.setSql(sql); @@ -332,7 +358,7 @@ public class SearchSQLAPITest extends AbstractSearchTest restClient.onResponse().assertThat().body("result-set", Matchers.nullValue()); restClient.onResponse().assertThat().body("list.entries", Matchers.notNullValue()); restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", Matchers.notNullValue()); - restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", Matchers.not("aliases")); + restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", not("aliases")); sqlRequest = new SearchSqlRequest(); sqlRequest.setSql(sql); @@ -428,7 +454,7 @@ public class SearchSQLAPITest extends AbstractSearchTest restClient.assertStatusCodeIs(HttpStatus.OK); response.assertThat().body("list.entries", Matchers.notNullValue()); - response.assertThat().body("list.entries.entry[0][0].value", Matchers.not("0")); + response.assertThat().body("list.entries.entry[0][0].value", not("0")); } @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 9) @@ -498,19 +524,19 @@ public class SearchSQLAPITest extends AbstractSearchTest restClient.authenticateUser(userNoPerm).withSearchSqlAPI().searchSql(sqlRequest); restClient.assertStatusCodeIs(HttpStatus.OK); - restClient.onResponse().assertThat().body("list.pagination.count", Matchers.is(0)); - restClient.onResponse().assertThat().body("list.pagination.totalItems", Matchers.is(0)); - restClient.onResponse().assertThat().body("list.pagination.hasMoreItems", Matchers.is(false)); - restClient.onResponse().assertThat().body("list.entries", Matchers.empty()); + restClient.onResponse().assertThat().body("list.pagination.count", is(0)); + restClient.onResponse().assertThat().body("list.pagination.totalItems", is(0)); + restClient.onResponse().assertThat().body("list.pagination.hasMoreItems", is(false)); + restClient.onResponse().assertThat().body("list.entries", empty()); // Results expected for query as User does has access to the private site restClient.authenticateUser(userPerm).withSearchSqlAPI().searchSql(sqlRequest); restClient.assertStatusCodeIs(HttpStatus.OK); - restClient.onResponse().assertThat().body("list.pagination.count", Matchers.greaterThan(0)); - restClient.onResponse().assertThat().body("list.pagination.totalItems", Matchers.greaterThan(0)); - restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", Matchers.equalToIgnoringCase("SITE")); - restClient.onResponse().assertThat().body("list.entries.entry[0][0].value", Matchers.equalToIgnoringCase("[\"" + siteModel.getId() + "\"]")); + restClient.onResponse().assertThat().body("list.pagination.count", greaterThan(0)); + restClient.onResponse().assertThat().body("list.pagination.totalItems", greaterThan(0)); + restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", equalToIgnoringCase("SITE")); + restClient.onResponse().assertThat().body("list.entries.entry[0][0].value", equalToIgnoringCase("[\"" + siteModel.getId() + "\"]")); } @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 12) @@ -613,7 +639,7 @@ public class SearchSQLAPITest extends AbstractSearchTest restClient.assertStatusCodeIs(HttpStatus.OK); response.assertThat().body("list.pagination.maxItems", Matchers.equalTo(1)); - restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", Matchers.equalToIgnoringCase("PATH")); + restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", equalToIgnoringCase("PATH")); // Select * with Limit, solr format: Also covered in JDBC sqlRequest = new SearchSqlRequest(); @@ -669,14 +695,14 @@ public class SearchSQLAPITest extends AbstractSearchTest restClient.assertStatusCodeIs(HttpStatus.OK); response.assertThat().body("list.pagination.maxItems", Matchers.equalTo(10)); - restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", Matchers.equalToIgnoringCase("site")); + restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", equalToIgnoringCase("site")); // Select distinct cm_name: solr format sqlRequest = new SearchSqlRequest(); sqlRequest.setSql("select distinct cm_name from alfresco limit 5"); sqlRequest.setFormat("solr"); - response = searchSql(sqlRequest); + searchSql(sqlRequest); restClient.assertStatusCodeIs(HttpStatus.OK); restClient.onResponse().assertThat().body("result-set.docs[0].cm_name", Matchers.notNullValue()); @@ -686,66 +712,70 @@ public class SearchSQLAPITest extends AbstractSearchTest @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_11 }, priority = 16) public void testFilterQuery() throws Exception { - UserModel userPerm = dataUser.createRandomTestUser("UserSearchPerm"); - - dataUser.addUserToSite(userPerm, siteModel, UserRole.SiteContributor); - - String siteSQL = "select SITE, CM_OWNER from alfresco where SITE='" + siteModel.getId() + "'"; SearchSqlRequest sqlRequest = new SearchSqlRequest(); + String siteSQL = "select SITE, CM_OWNER from alfresco where SITE='" + siteModel.getId() + "'"; sqlRequest.setSql(siteSQL); - // Add a filter query to only include results from inside the site (i.e. all results). String[] filterQuery = { "SITE:'" + siteModel.getId() + "'" }; sqlRequest.setFilterQuery(filterQuery); - // Results expected for query as User does has access to the private site - restClient.authenticateUser(userPerm).withSearchSqlAPI().searchSql(sqlRequest); - restClient.assertStatusCodeIs(HttpStatus.OK); + searchSql(sqlRequest); - restClient.onResponse().assertThat().body("list.pagination.count", Matchers.greaterThan(0)); - restClient.onResponse().assertThat().body("list.pagination.totalItems", Matchers.greaterThan(0)); - restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", Matchers.equalToIgnoringCase("SITE")); - restClient.onResponse().assertThat().body("list.entries.entry[0][0].value", Matchers.equalToIgnoringCase("[\"" + siteModel.getId() + "\"]")); + restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.onResponse().assertThat().body("list.pagination.count", greaterThan(0)); + restClient.onResponse().assertThat().body("list.pagination.totalItems", greaterThan(0)); + restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", equalToIgnoringCase("SITE")); + restClient.onResponse().assertThat().body("list.entries.entry[0][0].value", equalToIgnoringCase("[\"" + siteModel.getId() + "\"]")); // Now try instead removing everything from the site (i.e. all results). String[] inverseFilterQuery = { "-SITE:'" + siteModel.getId() + "'" }; sqlRequest.setFilterQuery(inverseFilterQuery); - restClient.authenticateUser(userPerm).withSearchSqlAPI().searchSql(sqlRequest); - restClient.assertStatusCodeIs(HttpStatus.OK); + searchSql(sqlRequest); - restClient.onResponse().assertThat().body("list.pagination.count", Matchers.is(0)); - restClient.onResponse().assertThat().body("list.pagination.totalItems", Matchers.is(0)); - restClient.onResponse().assertThat().body("list.pagination.hasMoreItems", Matchers.is(false)); - restClient.onResponse().assertThat().body("list.entries", Matchers.empty()); + restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.onResponse().assertThat().body("list.pagination.count", is(0)); + restClient.onResponse().assertThat().body("list.pagination.totalItems", is(0)); + restClient.onResponse().assertThat().body("list.pagination.hasMoreItems", is(false)); + restClient.onResponse().assertThat().body("list.entries", empty()); } /** Check that the combination of multiple filter queries produce the intersection of results. */ @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_11 }, priority = 17) public void testCombiningFilterQueries() throws Exception { - UserModel userPerm = dataUser.createRandomTestUser("UserSearchPerm"); - dataUser.addUserToSite(userPerm, siteModel, UserRole.SiteContributor); - String siteSQL = "select cm_name from alfresco where SITE='" + siteModel.getId() + "'"; SearchSqlRequest sqlRequest = new SearchSqlRequest(); sqlRequest.setSql(siteSQL); - // Add a filter query to only include results from inside the site (i.e. all results). String[] filterQueries = { "-cm_name:'cars'", "-cm_name:'pangram'" }; sqlRequest.setFilterQuery(filterQueries); - // Results expected for query as User does has access to the private site - restClient.authenticateUser(userPerm).withSearchSqlAPI().searchSql(sqlRequest); - restClient.assertStatusCodeIs(HttpStatus.OK); + searchSql(sqlRequest); - restClient.onResponse().assertThat().body("list.pagination.count", Matchers.greaterThan(0)); - restClient.onResponse().assertThat().body("list.pagination.totalItems", Matchers.greaterThan(0)); - restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", Matchers.equalToIgnoringCase("cm_name")); + restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.onResponse().assertThat().body("list.pagination.count", greaterThan(0)); + restClient.onResponse().assertThat().body("list.pagination.totalItems", greaterThan(0)); // Check that pangram.txt and cars.txt were both filtered out. - restClient.onResponse().assertThat().body("list.entries.entry[0][0].value", - Matchers.not(Matchers.equalToIgnoringCase("pangram.txt"))); - restClient.onResponse().assertThat().body("list.entries.entry[0][0].value", - Matchers.not(Matchers.equalToIgnoringCase("cars.txt"))); + restClient.onResponse().assertThat() + .body(CM_NAME_VALUES, everyItem(not(isIn(asList("pangram.txt", "cars.txt"))))); + } + + /** Check that an empty list of filter queries doesn't remove anything from the results. */ + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_11 }, priority = 18) + public void testEmptyFilterQuery() throws Exception + { + String siteSQL = "select cm_name from alfresco where SITE='" + siteModel.getId() + "'"; + SearchSqlRequest sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql(siteSQL); + // Add an empty list of filter queries. + sqlRequest.setFilterQuery(new String[]{}); + + searchSql(sqlRequest); + + restClient.assertStatusCodeIs(HttpStatus.OK); + // Check that the cm_names of all nodes in the site are returned. + restClient.onResponse().assertThat() + .body(CM_NAME_VALUES, containsInAnyOrder("documentLibrary", SEARCH_DATA_SAMPLE_FOLDER, "pangram.txt", "cars.txt", "alfresco.txt", unique_searchString + ".txt")); } } From ddcba37bf2e0b830dc356ca8a77b6a71a7f6f9c5 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Mon, 14 Jan 2019 19:28:16 +0200 Subject: [PATCH 1456/1491] TAS-3987: adding support for starting ACS with docker via Makefile --- e2e-test/resources/default.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/resources/default.properties b/e2e-test/resources/default.properties index 40fcb40dc..08d38d82f 100644 --- a/e2e-test/resources/default.properties +++ b/e2e-test/resources/default.properties @@ -1,7 +1,7 @@ # dataprep related alfresco.scheme=http alfresco.server=localhost -alfresco.port=8080 +alfresco.port=8081 # sync service related sync.scheme=http From fd11360ef813b88b7d9f7d7f7aad1b998e456d24 Mon Sep 17 00:00:00 2001 From: Andrei Zapodeanu Date: Mon, 4 Mar 2019 11:59:35 +0200 Subject: [PATCH 1457/1491] REPO-1835 Add displayName property to person representation -- fixed a test --- e2e-test/java/org/alfresco/rest/people/GetPeopleFullTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleFullTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleFullTests.java index ef080a29a..6b2362eaa 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleFullTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleFullTests.java @@ -40,7 +40,7 @@ public class GetPeopleFullTests extends RestTest @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"); + RestPersonModel newUser = RestPersonModel.getRandomPersonModel("aspectNames", "avatarId", "statusUpdatedAt","displayName"); newUser = restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().createPerson(newUser); restClient.assertStatusCodeIs(HttpStatus.CREATED); From 40454ee4f6dc49757f103f5bfeb6400b6e955914 Mon Sep 17 00:00:00 2001 From: Andrei Rebegea Date: Mon, 4 Mar 2019 13:49:52 +0000 Subject: [PATCH 1458/1491] REPO-4135: Libraries: Upgrade Hazelcast for Java 11 compatibility See also MM-785 and REPO-4233 --- .../java/org/alfresco/rest/discovery/DiscoveryTests.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/discovery/DiscoveryTests.java b/e2e-test/java/org/alfresco/rest/discovery/DiscoveryTests.java index e3ba0fc60..359f63ad1 100644 --- a/e2e-test/java/org/alfresco/rest/discovery/DiscoveryTests.java +++ b/e2e-test/java/org/alfresco/rest/discovery/DiscoveryTests.java @@ -69,8 +69,13 @@ public class DiscoveryTests extends RestTest List expectedModules = Arrays.asList("alfresco-aos-module", "org.alfresco.integrations.google.docs", "org_alfresco_integrations_S3Connector", "org_alfresco_module_xamconnector", "org.alfresco.module.KofaxAddon", "alfresco-content-connector-for-salesforce-repo", - "alfresco-share-services", "alfresco-saml-repo", "org_alfresco_device_sync_repo", - "org_alfresco_mm_repo", "org.alfresco.module.TransformationServer", "alfresco-glacier-connector-repo"); + "alfresco-share-services", + // uncomment when REPO-4233 is fixed + // "alfresco-saml-repo", + "org_alfresco_device_sync_repo", + // uncomment when MM-785 is fixed: + // "org_alfresco_mm_repo", + "org.alfresco.module.TransformationServer", "alfresco-glacier-connector-repo"); expectedModules.forEach(module -> assertTrue(modules.contains(module), String.format("Expected module %s is not installed", module))); From 5e0b967727ff590948761eddd3b2be7211e260c4 Mon Sep 17 00:00:00 2001 From: Andrei Rebegea Date: Mon, 4 Mar 2019 16:24:49 +0000 Subject: [PATCH 1459/1491] REPO-4135: realized that other branches on older versions still use the master of tas This change needs to be reverted when REPO-4233 and MM-785 is fixed --- e2e-test/java/org/alfresco/rest/discovery/DiscoveryTests.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/discovery/DiscoveryTests.java b/e2e-test/java/org/alfresco/rest/discovery/DiscoveryTests.java index 359f63ad1..f4011a4c5 100644 --- a/e2e-test/java/org/alfresco/rest/discovery/DiscoveryTests.java +++ b/e2e-test/java/org/alfresco/rest/discovery/DiscoveryTests.java @@ -82,7 +82,8 @@ public class DiscoveryTests extends RestTest // Check that all installed modules are in INSTALLED state List modulesStates = restClient.onResponse().getResponse().jsonPath().getList("entry.repository.modules.installState", String.class); - assertEquals(Collections.frequency(modulesStates, "INSTALLED"), expectedModules.size()); + //change back to assertEquals after REPO-4233 and MM-785 is fixed + assertTrue(Collections.frequency(modulesStates, "INSTALLED") >= expectedModules.size(), "Number of amps installed should match expected"); } @Test(groups = { TestGroup.REST_API, TestGroup.DISCOVERY, TestGroup.SANITY, TestGroup.CORE }) From a42e753ff2fed16b21cd388387e8d371bfd3ac94 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Mon, 4 Mar 2019 17:18:01 +0000 Subject: [PATCH 1460/1491] TAS-3987 ability to execute TAS RestAPI on java11 --- .../java/org/alfresco/rest/auth/AuthTests.java | 1 - .../rest/comments/AddCommentTests.java | 2 +- .../rest/comments/AddCommentsTests.java | 2 +- .../rest/comments/UpdateCommentTests.java | 2 +- .../rest/favorites/GetFavoriteSiteTests.java | 7 +++++-- .../rest/people/GetPeopleFullTests.java | 2 -- .../alfresco/rest/ratings/GetRatingTests.java | 2 +- .../alfresco/rest/ratings/GetRatingsTests.java | 2 +- .../rest/renditions/GetRenditionTests.java | 1 - .../rest/search/FacetRangeSearchTest.java | 18 +++++++++--------- .../sql/SearchSQLWithQuotedIdentifiers.java | 7 +++++-- .../org/alfresco/rest/tags/UpdateTagTests.java | 2 +- .../alfresco/rest/tags/nodes/AddTagTests.java | 2 +- .../rest/tags/nodes/DeleteTagTests.java | 4 ++-- .../rest/tags/nodes/GetNodeTagsTests.java | 2 +- .../processes/GetProcessCoreTests.java | 2 +- .../GetProcessVariablesCoreTests.java | 2 +- .../rest/workflow/tasks/GetTaskTests.java | 2 +- 18 files changed, 32 insertions(+), 30 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/auth/AuthTests.java b/e2e-test/java/org/alfresco/rest/auth/AuthTests.java index e978f6d77..70826fe4c 100644 --- a/e2e-test/java/org/alfresco/rest/auth/AuthTests.java +++ b/e2e-test/java/org/alfresco/rest/auth/AuthTests.java @@ -10,7 +10,6 @@ import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.apache.commons.codec.binary.Base64; -import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.testng.Assert; import org.testng.annotations.Test; diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentTests.java b/e2e-test/java/org/alfresco/rest/comments/AddCommentTests.java index fbd7cde34..aeaa95869 100644 --- a/e2e-test/java/org/alfresco/rest/comments/AddCommentTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/AddCommentTests.java @@ -19,7 +19,7 @@ import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; -import org.apache.commons.lang.RandomStringUtils; +import org.apache.commons.lang3.RandomStringUtils; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentsTests.java b/e2e-test/java/org/alfresco/rest/comments/AddCommentsTests.java index c00ddf436..7f28fd249 100644 --- a/e2e-test/java/org/alfresco/rest/comments/AddCommentsTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/AddCommentsTests.java @@ -24,7 +24,7 @@ import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; -import org.apache.commons.lang.RandomStringUtils; +import org.apache.commons.lang3.RandomStringUtils; import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; diff --git a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentTests.java b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentTests.java index f168e14e3..aad251918 100644 --- a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentTests.java @@ -18,7 +18,7 @@ import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; -import org.apache.commons.lang.RandomStringUtils; +import org.apache.commons.lang3.RandomStringUtils; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSiteTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSiteTests.java index 4accab458..9cdc776aa 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSiteTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSiteTests.java @@ -9,10 +9,13 @@ import org.alfresco.rest.model.RestSiteModel; import org.alfresco.rest.model.RestSiteModelsCollection; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; -import org.alfresco.utility.model.*; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; -import org.apache.commons.lang3.RandomStringUtils; import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleFullTests.java b/e2e-test/java/org/alfresco/rest/people/GetPeopleFullTests.java index 6b2362eaa..a447bd1d5 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleFullTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetPeopleFullTests.java @@ -2,7 +2,6 @@ package org.alfresco.rest.people; import org.alfresco.rest.RestTest; import org.alfresco.rest.core.RestRequest; -import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestPersonModel; import org.alfresco.rest.model.RestPersonModelsCollection; import org.alfresco.utility.constants.UserRole; @@ -11,7 +10,6 @@ import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; -import org.apache.commons.lang3.RandomStringUtils; import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; diff --git a/e2e-test/java/org/alfresco/rest/ratings/GetRatingTests.java b/e2e-test/java/org/alfresco/rest/ratings/GetRatingTests.java index 3e7d5c9e4..9cb42f8f7 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/GetRatingTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/GetRatingTests.java @@ -15,7 +15,7 @@ import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; -import org.apache.commons.lang.RandomStringUtils; +import org.apache.commons.lang3.RandomStringUtils; import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; diff --git a/e2e-test/java/org/alfresco/rest/ratings/GetRatingsTests.java b/e2e-test/java/org/alfresco/rest/ratings/GetRatingsTests.java index 70b205162..ca4469a85 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/GetRatingsTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/GetRatingsTests.java @@ -16,7 +16,7 @@ import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; -import org.apache.commons.lang.RandomStringUtils; +import org.apache.commons.lang3.RandomStringUtils; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; diff --git a/e2e-test/java/org/alfresco/rest/renditions/GetRenditionTests.java b/e2e-test/java/org/alfresco/rest/renditions/GetRenditionTests.java index 5fcad7e79..bbeda974c 100644 --- a/e2e-test/java/org/alfresco/rest/renditions/GetRenditionTests.java +++ b/e2e-test/java/org/alfresco/rest/renditions/GetRenditionTests.java @@ -2,7 +2,6 @@ package org.alfresco.rest.renditions; import static org.alfresco.utility.report.log.Step.STEP; -import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.core.RestResponse; diff --git a/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java b/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java index a1ff0d517..1ca43bbeb 100644 --- a/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java @@ -134,7 +134,7 @@ public class FacetRangeSearchTest extends AbstractSearchTest bucket.assertThat().field("label").is("[0 - 200)"); bucket.assertThat().field("filterQuery").is("content.size:[\"0\" TO \"200\">"); Map metric = (Map) bucket.getMetrics().get(0).getValue(); - Assert.assertTrue(new Integer(metric.get("count")) >= 4); + Assert.assertTrue(Integer.valueOf(metric.get("count")) >= 4); Map info = (Map) bucket.getBucketInfo(); Assert.assertEquals(info.get("start"),"0"); Assert.assertEquals(info.get("end"),"200"); @@ -146,7 +146,7 @@ public class FacetRangeSearchTest extends AbstractSearchTest bucket.assertThat().field("label").is("[200 - 400)"); bucket.assertThat().field("filterQuery").is("content.size:[\"200\" TO \"400\">"); metric = (Map) bucket.getMetrics().get(0).getValue(); - Integer count = new Integer(metric.get("count")); + Integer count = Integer.valueOf(metric.get("count")); Assert.assertTrue(count >= 4); info = (Map) bucket.getBucketInfo(); Assert.assertEquals(info.get("start"),"200"); @@ -158,7 +158,7 @@ public class FacetRangeSearchTest extends AbstractSearchTest bucket.assertThat().field("label").is("[400 - 600]"); bucket.assertThat().field("filterQuery").is("content.size:[\"400\" TO \"600\"]"); metric = (Map) bucket.getMetrics().get(0).getValue(); - Assert.assertTrue(new Integer(metric.get("count")) >= 7); + Assert.assertTrue(Integer.valueOf(metric.get("count")) >= 7); info = (Map) bucket.getBucketInfo(); Assert.assertEquals(info.get("start"),"400"); Assert.assertEquals(info.get("end"),"600"); @@ -191,7 +191,7 @@ public class FacetRangeSearchTest extends AbstractSearchTest bucket.assertThat().field("label").is("[0 - 200)"); bucket.assertThat().field("filterQuery").is("content.size:[\"0\" TO \"200\">"); Map metric = (Map) bucket.getMetrics().get(0).getValue(); - Assert.assertTrue(new Integer(metric.get("count")) >= 4); + Assert.assertTrue(Integer.valueOf(metric.get("count")) >= 4); Map info = (Map) bucket.getBucketInfo(); Assert.assertEquals(info.get("start"),"0"); Assert.assertEquals(info.get("end"),"200"); @@ -206,7 +206,7 @@ public class FacetRangeSearchTest extends AbstractSearchTest Assert.assertEquals(info.get("start"),"200"); Assert.assertEquals(info.get("end"),"400"); metric = (Map) bucket.getMetrics().get(0).getValue(); - Assert.assertTrue(new Integer(metric.get("count")) >= 4); + Assert.assertTrue(Integer.valueOf(metric.get("count")) >= 4); Assert.assertNull(info.get("count")); Assert.assertEquals(info.get("startInclusive"),"true"); Assert.assertEquals(info.get("endInclusive"),"false"); @@ -215,7 +215,7 @@ public class FacetRangeSearchTest extends AbstractSearchTest bucket.assertThat().field("label").is("[400 - 500]"); bucket.assertThat().field("filterQuery").is("content.size:[\"400\" TO \"500\"]"); metric = (Map) bucket.getMetrics().get(0).getValue(); - Assert.assertTrue(new Integer(metric.get("count")) >= 3); + Assert.assertTrue(Integer.valueOf(metric.get("count")) >= 3); info = (Map) bucket.getBucketInfo(); Assert.assertEquals(info.get("start"),"400"); Assert.assertEquals(info.get("end"),"500"); @@ -307,7 +307,7 @@ public class FacetRangeSearchTest extends AbstractSearchTest bucket.assertThat().field("label").is("(0 - 200]"); bucket.assertThat().field("filterQuery").is("content.size:<\"0\" TO \"200\"]"); Map metric = (Map) bucket.getMetrics().get(0).getValue(); - Assert.assertTrue(new Integer(metric.get("count")) >= 4); + Assert.assertTrue(Integer.valueOf(metric.get("count")) >= 4); Map info = (Map) bucket.getBucketInfo(); Assert.assertEquals(info.get("start"),"0"); Assert.assertEquals(info.get("end"),"200"); @@ -319,7 +319,7 @@ public class FacetRangeSearchTest extends AbstractSearchTest bucket.assertThat().field("label").is("(200 - 400]"); bucket.assertThat().field("filterQuery").is("content.size:<\"200\" TO \"400\"]"); metric = (Map) bucket.getMetrics().get(0).getValue(); - Integer count = new Integer(metric.get("count")); + Integer count = Integer.valueOf(metric.get("count")); Assert.assertTrue(count >= 4); info = (Map) bucket.getBucketInfo(); Assert.assertEquals(info.get("start"),"200"); @@ -331,7 +331,7 @@ public class FacetRangeSearchTest extends AbstractSearchTest bucket.assertThat().field("label").is("(400 - 600]"); bucket.assertThat().field("filterQuery").is("content.size:<\"400\" TO \"600\"]"); metric = (Map) bucket.getMetrics().get(0).getValue(); - Assert.assertTrue(new Integer(metric.get("count")) >= 7); + Assert.assertTrue(Integer.valueOf(metric.get("count")) >= 7); info = (Map) bucket.getBucketInfo(); Assert.assertEquals(info.get("start"),"400"); Assert.assertEquals(info.get("end"),"600"); diff --git a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLWithQuotedIdentifiers.java b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLWithQuotedIdentifiers.java index dca6d1793..30f773d53 100644 --- a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLWithQuotedIdentifiers.java +++ b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLWithQuotedIdentifiers.java @@ -22,10 +22,13 @@ import java.util.UUID; import org.alfresco.rest.RestTest; import org.alfresco.rest.search.AbstractSearchTest; -import org.alfresco.rest.search.SearchSqlRequest; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.CustomObjectTypeProperties; -import org.alfresco.utility.model.*; +import org.alfresco.utility.model.ContentModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FileType; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.report.Bug; import org.hamcrest.Matchers; import org.springframework.http.HttpStatus; diff --git a/e2e-test/java/org/alfresco/rest/tags/UpdateTagTests.java b/e2e-test/java/org/alfresco/rest/tags/UpdateTagTests.java index 2237314f1..21f506483 100644 --- a/e2e-test/java/org/alfresco/rest/tags/UpdateTagTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/UpdateTagTests.java @@ -10,7 +10,7 @@ import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; -import org.apache.commons.lang.RandomStringUtils; +import org.apache.commons.lang3.RandomStringUtils; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; diff --git a/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagTests.java b/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagTests.java index 2100b3ab3..c0606d3dc 100644 --- a/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagTests.java @@ -14,7 +14,7 @@ import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; -import org.apache.commons.lang.RandomStringUtils; +import org.apache.commons.lang3.RandomStringUtils; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; diff --git a/e2e-test/java/org/alfresco/rest/tags/nodes/DeleteTagTests.java b/e2e-test/java/org/alfresco/rest/tags/nodes/DeleteTagTests.java index 28f42e67a..ec77b8fc7 100644 --- a/e2e-test/java/org/alfresco/rest/tags/nodes/DeleteTagTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/nodes/DeleteTagTests.java @@ -226,7 +226,7 @@ public class DeleteTagTests extends TagsDataPrep @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) public void userCollaboratorCanDeleteLongTag() throws Exception { - String longTag = org.apache.commons.lang.RandomStringUtils.randomAlphanumeric(800); + String longTag = RandomStringUtils.randomAlphanumeric(800); tag = restClient.authenticateUser(adminUserModel) .withCoreAPI().usingResource(document).addTag(longTag); @@ -241,7 +241,7 @@ public class DeleteTagTests extends TagsDataPrep @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) public void managerCanDeleteShortTag() throws Exception { - String shortTag = org.apache.commons.lang.RandomStringUtils.randomAlphanumeric(10); + String shortTag = RandomStringUtils.randomAlphanumeric(10); tag = restClient.authenticateUser(adminUserModel) .withCoreAPI().usingResource(document).addTag(shortTag); diff --git a/e2e-test/java/org/alfresco/rest/tags/nodes/GetNodeTagsTests.java b/e2e-test/java/org/alfresco/rest/tags/nodes/GetNodeTagsTests.java index 8cfd84379..f38e20d64 100644 --- a/e2e-test/java/org/alfresco/rest/tags/nodes/GetNodeTagsTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/nodes/GetNodeTagsTests.java @@ -11,7 +11,7 @@ import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; -import org.apache.commons.lang.RandomStringUtils; +import org.apache.commons.lang3.RandomStringUtils; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessCoreTests.java index 9e7076603..418e4b8a0 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessCoreTests.java @@ -8,7 +8,7 @@ import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; -import org.apache.commons.lang.RandomStringUtils; +import org.apache.commons.lang3.RandomStringUtils; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/GetProcessVariablesCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/GetProcessVariablesCoreTests.java index 0799d10d4..0b8c721b6 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/GetProcessVariablesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/variables/GetProcessVariablesCoreTests.java @@ -13,7 +13,7 @@ import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; -import org.apache.commons.lang.RandomStringUtils; +import org.apache.commons.lang3.RandomStringUtils; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskTests.java index b88e1a02a..1aec76b5d 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskTests.java @@ -16,7 +16,7 @@ import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; -import org.apache.commons.lang.RandomStringUtils; +import org.apache.commons.lang3.RandomStringUtils; import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; From 52193edf4758cb58200ee5034abe6cbb3ff2648a Mon Sep 17 00:00:00 2001 From: Alex Mukha Date: Mon, 4 Mar 2019 23:33:40 +0000 Subject: [PATCH 1461/1491] REPO-3235 Remove discussions --- .../containers/GetSiteContainerTests.java | 35 ++++++---------- .../containers/GetSiteContainersTests.java | 41 ++++++++----------- 2 files changed, 29 insertions(+), 47 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/sites/containers/GetSiteContainerTests.java b/e2e-test/java/org/alfresco/rest/sites/containers/GetSiteContainerTests.java index a77ef8d8b..2ca445467 100644 --- a/e2e-test/java/org/alfresco/rest/sites/containers/GetSiteContainerTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/containers/GetSiteContainerTests.java @@ -43,14 +43,10 @@ public class GetSiteContainerTests extends RestTest UserRole.SiteContributor); dataLink.usingAdmin().usingSite(publicSiteModel).createRandomLink(); - dataDiscussion.usingAdmin().usingSite(publicSiteModel).createRandomDiscussion(); - - dataLink.usingUser(testUser).usingSite(moderatedSiteModel).createRandomLink(); dataLink.usingAdmin().usingSite(adminPrivateSiteModel).createRandomLink(); dataLink.usingUser(testUser).usingSite(privateSiteModel).createRandomLink(); - dataDiscussion.usingUser(testUser).usingSite(privateSiteModel).createRandomDiscussion(); } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) @@ -140,9 +136,9 @@ public class GetSiteContainerTests extends RestTest public void getContainerWithNonExistentSite() throws Exception { restClient.authenticateUser(testUser) - .withCoreAPI().usingSite("NonExistentSiteId").getSiteContainer(ContainerName.discussions.toString()); + .withCoreAPI().usingSite("NonExistentSiteId").getSiteContainer(ContainerName.links.toString()); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, "NonExistentSiteId", ContainerName.discussions.toString())); + .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, "NonExistentSiteId", ContainerName.links.toString())); } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) @@ -161,11 +157,6 @@ public class GetSiteContainerTests extends RestTest description= "Verify regular user can get container for public site and request returns status 200") public void getContainerForPublicSite() throws Exception { - restClient.authenticateUser(testUser) - .withCoreAPI().usingSite(publicSiteModel).getSiteContainer(ContainerName.discussions.toString()) - .assertThat().field("folderId").is(ContainerName.discussions.toString()); - restClient.assertStatusCodeIs(HttpStatus.OK); - restClient.authenticateUser(testUser) .withCoreAPI().usingSite(publicSiteModel).getSiteContainer(ContainerName.links.toString()) .assertThat().field("folderId").is(ContainerName.links.toString()); @@ -178,8 +169,8 @@ public class GetSiteContainerTests extends RestTest public void getContainerForPrivateSite() throws Exception { restClient.authenticateUser(testUser) - .withCoreAPI().usingSite(privateSiteModel).getSiteContainer(ContainerName.discussions.toString()) - .assertThat().field("folderId").is(ContainerName.discussions.toString()); + .withCoreAPI().usingSite(privateSiteModel).getSiteContainer(ContainerName.links.toString()) + .assertThat().field("folderId").is(ContainerName.links.toString()); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -189,8 +180,8 @@ public class GetSiteContainerTests extends RestTest public void getContainerForModeratedSite() throws Exception { restClient.authenticateUser(testUser) - .withCoreAPI().usingSite(moderatedSiteModel).getSiteContainer(ContainerName.links.toString()) - .assertThat().field("folderId").is(ContainerName.links.toString()); + .withCoreAPI().usingSite(moderatedSiteModel).getSiteContainer(ContainerName.documentLibrary.toString()) + .assertThat().field("folderId").is(ContainerName.documentLibrary.toString()); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -200,7 +191,7 @@ public class GetSiteContainerTests extends RestTest public void getContainerUsingPropertiesParameter() throws Exception { restClient.authenticateUser(testUser) - .withCoreAPI().usingSite(publicSiteModel).usingParams("properties=id").getSiteContainer(ContainerName.discussions.toString()) + .withCoreAPI().usingSite(publicSiteModel).usingParams("properties=id").getSiteContainer(ContainerName.links.toString()) .assertThat().fieldsCount().is(1) .and().field("id").isNotEmpty() .and().field("folderId").isNull(); @@ -213,10 +204,10 @@ public class GetSiteContainerTests extends RestTest public void getContainerThatDoesNotBelongToSite() throws Exception { restClient.authenticateUser(testUser) - .withCoreAPI().usingSite(moderatedSiteModel).getSiteContainer(ContainerName.discussions.toString()); + .withCoreAPI().usingSite(moderatedSiteModel).getSiteContainer(ContainerName.links.toString()); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) .assertLastError().containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, moderatedSiteModel.getId(), ContainerName.discussions.toString())) + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, moderatedSiteModel.getId(), ContainerName.links.toString())) .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) .stackTraceIs(RestErrorModel.STACKTRACE); } @@ -227,10 +218,10 @@ public class GetSiteContainerTests extends RestTest public void getContainerForEmptySiteId() throws Exception { restClient.authenticateUser(testUser) - .withCoreAPI().usingSite("").getSiteContainer(ContainerName.discussions.toString()); + .withCoreAPI().usingSite("").getSiteContainer(ContainerName.links.toString()); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) .assertLastError().containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, "", ContainerName.discussions.toString())) + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, "", ContainerName.links.toString())) .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) .stackTraceIs(RestErrorModel.STACKTRACE); } @@ -267,8 +258,8 @@ public class GetSiteContainerTests extends RestTest public void adminCanGetContainerForPrivateSiteCreatedByUser() throws Exception { restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingSite(privateSiteModel).getSiteContainer(ContainerName.discussions.toString()) - .assertThat().field("folderId").is(ContainerName.discussions.toString()) + .withCoreAPI().usingSite(privateSiteModel).getSiteContainer(ContainerName.links.toString()) + .assertThat().field("folderId").is(ContainerName.links.toString()) .and().field("id").isNotEmpty(); restClient.assertStatusCodeIs(HttpStatus.OK); } diff --git a/e2e-test/java/org/alfresco/rest/sites/containers/GetSiteContainersTests.java b/e2e-test/java/org/alfresco/rest/sites/containers/GetSiteContainersTests.java index 09cfc15cf..2822239eb 100644 --- a/e2e-test/java/org/alfresco/rest/sites/containers/GetSiteContainersTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/containers/GetSiteContainersTests.java @@ -44,14 +44,10 @@ public class GetSiteContainersTests extends RestTest UserRole.SiteContributor); dataLink.usingAdmin().usingSite(publicSiteWithContainers).createRandomLink(); - dataDiscussion.usingAdmin().usingSite(publicSiteWithContainers).createRandomDiscussion(); dataLink.usingAdmin().usingSite(moderatedSiteModel).createRandomLink(); - dataDiscussion.usingAdmin().usingSite(moderatedSiteModel).createRandomDiscussion(); dataLink.usingAdmin().usingSite(privateSiteModel).createRandomLink(); - dataDiscussion.usingAdmin().usingSite(privateSiteModel).createRandomDiscussion(); - restSiteContainers = restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteManager)) .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers(); @@ -146,10 +142,9 @@ public class GetSiteContainersTests extends RestTest restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteManager)) .withParams("maxItems=5") .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() - .assertThat().entriesListCountIs(3) + .assertThat().entriesListCountIs(2) .and().entriesListContains("folderId" , ContainerName.documentLibrary.toString()) - .and().entriesListContains("folderId", ContainerName.links.toString()) - .and().entriesListContains("folderId", ContainerName.discussions.toString()); + .and().entriesListContains("folderId", ContainerName.links.toString()); restClient.assertStatusCodeIs(HttpStatus.OK); restClient.withParams("maxItems=1") @@ -195,7 +190,7 @@ public class GetSiteContainersTests extends RestTest restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteCollaborator)) .withParams("maxItems=000007") .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() - .assertThat().entriesListCountIs(3); + .assertThat().entriesListCountIs(2); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -211,17 +206,17 @@ public class GetSiteContainersTests extends RestTest restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteCollaborator)).withParams("skipCount=1") .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() - .assertThat().entriesListCountIs(2); + .assertThat().entriesListCountIs(1); restClient.assertStatusCodeIs(HttpStatus.OK); restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteConsumer)).withParams("skipCount=2") .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() - .assertThat().entriesListCountIs(1); + .assertThat().entriesListCountIs(0); restClient.assertStatusCodeIs(HttpStatus.OK); restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteCollaborator)).withParams("skipCount=0") .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() - .assertThat().entriesListCountIs(3); + .assertThat().entriesListCountIs(2); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -243,7 +238,7 @@ public class GetSiteContainersTests extends RestTest { restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)).withParams("skipCount=00002") .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() - .assertThat().entriesListCountIs(1); + .assertThat().entriesListCountIs(0); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -265,7 +260,7 @@ public class GetSiteContainersTests extends RestTest { restClient.authenticateUser(adminUserModel) .withCoreAPI().usingSite(privateSiteModel).getSiteContainers() - .assertThat().entriesListCountIs(3); + .assertThat().entriesListCountIs(2); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -276,7 +271,7 @@ public class GetSiteContainersTests extends RestTest { restClient.authenticateUser(adminUserModel) .withCoreAPI().usingSite(moderatedSiteModel).getSiteContainers() - .assertThat().entriesListCountIs(3); + .assertThat().entriesListCountIs(2); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -287,10 +282,9 @@ public class GetSiteContainersTests extends RestTest { restClient.authenticateUser(adminUserModel) .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() - .assertThat().entriesListCountIs(3) + .assertThat().entriesListCountIs(2) .and().entriesListContains("folderId" ,ContainerName.documentLibrary.toString()) - .and().entriesListContains("folderId", ContainerName.links.toString()) - .and().entriesListContains("folderId", ContainerName.discussions.toString()); + .and().entriesListContains("folderId", ContainerName.links.toString()); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -313,8 +307,7 @@ public class GetSiteContainersTests extends RestTest { restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteManager)) .withCoreAPI().usingSite(publicSiteWithContainers).usingParams("properties=folderId").getSiteContainers() - .assertThat().entriesListCountIs(3) - .and().entriesListContains("folderId", ContainerName.discussions.toString()) + .assertThat().entriesListCountIs(2) .and().entriesListContains("folderId", ContainerName.documentLibrary.toString()) .and().entriesListContains("folderId", ContainerName.links.toString()) .and().entriesListDoesNotContain("id"); @@ -328,7 +321,7 @@ public class GetSiteContainersTests extends RestTest { restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteManager)) .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() - .assertThat().entriesListCountIs(3) + .assertThat().entriesListCountIs(2) .and().entriesListContains("folderId", ContainerName.documentLibrary.toString()); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -340,10 +333,9 @@ public class GetSiteContainersTests extends RestTest { restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteCollaborator)) .withParams("skipCount=1").withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() - .assertThat().entriesListCountIs(2) + .assertThat().entriesListCountIs(1) .and().entriesListDoesNotContain("folderId", restSiteContainers.getEntries().get(0).onModel().getFolderId()) - .and().entriesListContains("folderId", restSiteContainers.getEntries().get(1).onModel().getFolderId()) - .and().entriesListContains("folderId", restSiteContainers.getEntries().get(2).onModel().getFolderId()); + .and().entriesListContains("folderId", restSiteContainers.getEntries().get(1).onModel().getFolderId()); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -356,8 +348,7 @@ public class GetSiteContainersTests extends RestTest .withParams("skipCount=" + String.valueOf(totalItems-1)).withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() .assertThat().entriesListCountIs(1) .and().entriesListDoesNotContain("folderId", restSiteContainers.getEntries().get(0).onModel().getFolderId()) - .and().entriesListDoesNotContain("folderId", restSiteContainers.getEntries().get(1).onModel().getFolderId()) - .and().entriesListContains("folderId", restSiteContainers.getEntries().get(2).onModel().getFolderId()); + .and().entriesListContains("folderId", restSiteContainers.getEntries().get(1).onModel().getFolderId()); restClient.assertStatusCodeIs(HttpStatus.OK); } From ad36da9a575e2044e2b94f2f050ac1773afd7629 Mon Sep 17 00:00:00 2001 From: "meenal.bhave@alfresco.com" Date: Thu, 7 Mar 2019 13:39:06 +0000 Subject: [PATCH 1462/1491] Search-1532: Amended the Search version Facet Search test --- .../java/org/alfresco/rest/search/FacetRangeSearchTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java b/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java index 1ca43bbeb..3cbe95684 100644 --- a/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java @@ -110,8 +110,8 @@ public class FacetRangeSearchTest extends AbstractSearchTest facetRangeModel.setGap("100"); } - @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_121 }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_121 }, executionType = ExecutionType.REGRESSION, description = "Check basic facet range search api") public void searchWithRange()throws Exception { From 9c75c67f5bdec7586c54f061a73e9ce0b1d777da Mon Sep 17 00:00:00 2001 From: "meenal.bhave@alfresco.com" Date: Thu, 7 Mar 2019 16:41:01 +0000 Subject: [PATCH 1463/1491] Search-1532: Amended the Search version Facet Search test for the right test --- .../org/alfresco/rest/search/FacetRangeSearchTest.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java b/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java index 3cbe95684..b3c518445 100644 --- a/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java @@ -110,8 +110,8 @@ public class FacetRangeSearchTest extends AbstractSearchTest facetRangeModel.setGap("100"); } - @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_121 }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_121 }, executionType = ExecutionType.REGRESSION, + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, description = "Check basic facet range search api") public void searchWithRange()throws Exception { @@ -223,8 +223,8 @@ public class FacetRangeSearchTest extends AbstractSearchTest Assert.assertEquals(info.get("startInclusive"),"true"); Assert.assertEquals(info.get("endInclusive"),"true"); } - @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_121 }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_121 }, executionType = ExecutionType.REGRESSION, description = "Check date facet intervals search api") public void searchDateRange()throws Exception { From d5385b52b8213098642ddd9ba03543db8ac25d38 Mon Sep 17 00:00:00 2001 From: Andrei Forascu Date: Wed, 13 Mar 2019 15:34:10 +0200 Subject: [PATCH 1464/1491] REPO-4243 / MNT-20407: Rest-Api Workflow processes and task tests are failing on ACS 6.0.1.1 - update utility version - cherry-pick 910508a22ce5367dfc91a1bcaa3696f1cc69135f from 6.1.N --- .../rest/workflow/processes/AddProcessCoreTests.java | 6 +++++- .../rest/workflow/processes/GetProcessFullTests.java | 7 +++++-- .../rest/workflow/processes/GetProcessesCoreTests.java | 10 ++++++++-- .../alfresco/rest/workflow/tasks/UpdateTaskTests.java | 5 ++++- 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessCoreTests.java index 5b187039f..8a2eac446 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessCoreTests.java @@ -5,6 +5,8 @@ import org.alfresco.rest.RestTest; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestProcessDefinitionModel; +import org.alfresco.rest.model.RestProcessDefinitionModelsCollection; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.rest.model.RestProcessModelsCollection; import org.alfresco.utility.model.TestGroup; @@ -26,6 +28,7 @@ public class AddProcessCoreTests extends RestTest private UserModel assignee, adminUser; private RestProcessModel addedProcess; private RestProcessModelsCollection processes; + private RestProcessDefinitionModel processDefinition; @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify non network admin is able to start new process using REST API and status code is OK (200)") @@ -40,10 +43,11 @@ public class AddProcessCoreTests extends RestTest addedProcess.assertThat().field("id").is(addedProcess.getId()) .and().field("startUserId").is(adminUser.getUsername()); + processDefinition = restClient.authenticateUser(adminUser).withWorkflowAPI().getAllProcessDefinitions().getProcessDefinitionByKey("activitiAdhoc"); processes = restClient.withWorkflowAPI().getProcesses(); restClient.assertStatusCodeIs(HttpStatus.OK); processes.assertThat().entriesListContains("id", addedProcess.getId()) - .assertThat().entriesListContains("processDefinitionId", "activitiAdhoc:1:4") + .assertThat().entriesListContains("processDefinitionId", processDefinition.getId()) .assertThat().entriesListContains("startUserId", adminUser.getUsername()) .assertThat().entriesListContains("startActivityId", "start") .assertThat().entriesListContains("completed", "false") diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessFullTests.java index 933e66829..01c11e8a2 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessFullTests.java @@ -2,6 +2,7 @@ package org.alfresco.rest.workflow.processes; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestProcessDefinitionModel; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; @@ -20,6 +21,7 @@ public class GetProcessFullTests extends RestTest { private UserModel userWhoStartsProcess, assignee; private RestProcessModel addedProcess, process; + private RestProcessDefinitionModel adhocProcessDefinition; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception @@ -27,6 +29,7 @@ public class GetProcessFullTests extends RestTest userWhoStartsProcess = dataUser.createRandomTestUser(); assignee = dataUser.createRandomTestUser(); addedProcess = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.High); + adhocProcessDefinition = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getAllProcessDefinitions().getProcessDefinitionByKey("activitiAdhoc"); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, @@ -52,7 +55,7 @@ public class GetProcessFullTests extends RestTest process = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingProcess(addedProcess).getProcess(); restClient.assertStatusCodeIs(HttpStatus.OK); process.assertThat() - .field("processDefinitionId").is("activitiAdhoc:1:4") + .field("processDefinitionId").is(adhocProcessDefinition.getId()) .and().field("startUserId").is(addedProcess.getStartUserId()) .and().field("startActivityId").is("start") .and().field("startedAt").isNotEmpty() @@ -66,7 +69,7 @@ public class GetProcessFullTests extends RestTest process = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingProcess(addedProcess).getProcess(); restClient.assertStatusCodeIs(HttpStatus.OK); process.assertThat() - .field("processDefinitionId").is("activitiAdhoc:1:4") + .field("processDefinitionId").is(adhocProcessDefinition.getId()) .and().field("durationInMs").isNotNull() .and().field("startUserId").is(addedProcess.getStartUserId()) .and().field("startActivityId").is("start") diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesCoreTests.java index f45147d00..5a5c5fd5d 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesCoreTests.java @@ -5,6 +5,7 @@ import java.util.List; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestProcessDefinitionModel; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.rest.model.RestProcessModelsCollection; import org.alfresco.utility.model.FileModel; @@ -31,6 +32,8 @@ public class GetProcessesCoreTests extends RestTest private UserModel adminUser, userWhoStartsTask, assignee ; private TaskModel task1, task2; private ProcessModel process3; + private RestProcessDefinitionModel adhocProcessDefinition; + private RestProcessDefinitionModel activitiReviewProcessDefinition; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception @@ -43,6 +46,8 @@ public class GetProcessesCoreTests extends RestTest task1 = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); task2 = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(adminUser); process3 = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createSingleReviewerTaskAndAssignTo(assignee); + adhocProcessDefinition = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getAllProcessDefinitions().getProcessDefinitionByKey("activitiAdhoc"); + activitiReviewProcessDefinition = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getAllProcessDefinitions().getProcessDefinitionByKey("activitiReview"); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, @@ -68,7 +73,8 @@ public class GetProcessesCoreTests extends RestTest RestProcessModelsCollection processes = restClient.authenticateUser(userWhoStartsTask).where("processDefinitionKey='activitiReview'") .withWorkflowAPI().getProcesses(); restClient.assertStatusCodeIs(HttpStatus.OK); - processes.assertThat().entriesListIsNotEmpty().and().entriesListContains("processDefinitionId", "activitiReview:1:8") - .and().entriesListDoesNotContain("processDefinitionId", "activitiAdhoc:1:4"); + + processes.assertThat().entriesListIsNotEmpty().and().entriesListContains("processDefinitionId", activitiReviewProcessDefinition.getId()) + .and().entriesListDoesNotContain("processDefinitionId", adhocProcessDefinition.getId()); } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskTests.java index 744773f3a..6f069d2ff 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskTests.java @@ -10,6 +10,7 @@ import org.alfresco.rest.RestTest; import org.alfresco.rest.core.JsonBodyGenerator; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestProcessDefinitionModel; import org.alfresco.rest.model.RestTaskModel; import org.alfresco.rest.model.RestVariableModelsCollection; import org.alfresco.utility.model.FileModel; @@ -37,6 +38,7 @@ public class UpdateTaskTests extends RestTest TaskModel taskModel; RestTaskModel restTaskModel; UserModel adminUser; + RestProcessDefinitionModel activitiReviewProcessDefinition; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception @@ -47,6 +49,7 @@ public class UpdateTaskTests extends RestTest assigneeUser = dataUser.createRandomTestUser(); siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + activitiReviewProcessDefinition = restClient.authenticateUser(adminUser).withWorkflowAPI().getAllProcessDefinitions().getProcessDefinitionByKey("activitiReviewPooled"); } @BeforeMethod(alwaysRun = true) @@ -105,7 +108,7 @@ public class UpdateTaskTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); restTaskModel.assertThat() .field("dueAt").isNotEmpty() - .and().field("processDefinitionId").is("activitiReviewPooled:1:12") + .and().field("processDefinitionId").is(activitiReviewProcessDefinition.getId()) .and().field("processId").is(taskModel.getProcessId()) .and().field("name").is("Review Task") .and().field("description").is(taskModel.getMessage()) From f2630fa1e044da966480010c9c2478d5d1806964 Mon Sep 17 00:00:00 2001 From: Tom Page Date: Wed, 13 Mar 2019 15:53:35 +0000 Subject: [PATCH 1465/1491] Revert "REPO-4243 / MNT-20407: Rest-Api Workflow processes and task tests are failing on ACS 6.0.1.1" This reverts commit abaee3c526b5ec99bc342b002fe3d562fb03a563. The code did not compile with these changes: cannot find symbol: class DataDiscussion. --- .../rest/workflow/processes/AddProcessCoreTests.java | 6 +----- .../rest/workflow/processes/GetProcessFullTests.java | 7 ++----- .../rest/workflow/processes/GetProcessesCoreTests.java | 10 ++-------- .../alfresco/rest/workflow/tasks/UpdateTaskTests.java | 5 +---- 4 files changed, 6 insertions(+), 22 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessCoreTests.java index 8a2eac446..5b187039f 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessCoreTests.java @@ -5,8 +5,6 @@ import org.alfresco.rest.RestTest; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestProcessDefinitionModel; -import org.alfresco.rest.model.RestProcessDefinitionModelsCollection; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.rest.model.RestProcessModelsCollection; import org.alfresco.utility.model.TestGroup; @@ -28,7 +26,6 @@ public class AddProcessCoreTests extends RestTest private UserModel assignee, adminUser; private RestProcessModel addedProcess; private RestProcessModelsCollection processes; - private RestProcessDefinitionModel processDefinition; @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify non network admin is able to start new process using REST API and status code is OK (200)") @@ -43,11 +40,10 @@ public class AddProcessCoreTests extends RestTest addedProcess.assertThat().field("id").is(addedProcess.getId()) .and().field("startUserId").is(adminUser.getUsername()); - processDefinition = restClient.authenticateUser(adminUser).withWorkflowAPI().getAllProcessDefinitions().getProcessDefinitionByKey("activitiAdhoc"); processes = restClient.withWorkflowAPI().getProcesses(); restClient.assertStatusCodeIs(HttpStatus.OK); processes.assertThat().entriesListContains("id", addedProcess.getId()) - .assertThat().entriesListContains("processDefinitionId", processDefinition.getId()) + .assertThat().entriesListContains("processDefinitionId", "activitiAdhoc:1:4") .assertThat().entriesListContains("startUserId", adminUser.getUsername()) .assertThat().entriesListContains("startActivityId", "start") .assertThat().entriesListContains("completed", "false") diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessFullTests.java index 01c11e8a2..933e66829 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessFullTests.java @@ -2,7 +2,6 @@ package org.alfresco.rest.workflow.processes; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestProcessDefinitionModel; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; @@ -21,7 +20,6 @@ public class GetProcessFullTests extends RestTest { private UserModel userWhoStartsProcess, assignee; private RestProcessModel addedProcess, process; - private RestProcessDefinitionModel adhocProcessDefinition; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception @@ -29,7 +27,6 @@ public class GetProcessFullTests extends RestTest userWhoStartsProcess = dataUser.createRandomTestUser(); assignee = dataUser.createRandomTestUser(); addedProcess = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.High); - adhocProcessDefinition = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getAllProcessDefinitions().getProcessDefinitionByKey("activitiAdhoc"); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, @@ -55,7 +52,7 @@ public class GetProcessFullTests extends RestTest process = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingProcess(addedProcess).getProcess(); restClient.assertStatusCodeIs(HttpStatus.OK); process.assertThat() - .field("processDefinitionId").is(adhocProcessDefinition.getId()) + .field("processDefinitionId").is("activitiAdhoc:1:4") .and().field("startUserId").is(addedProcess.getStartUserId()) .and().field("startActivityId").is("start") .and().field("startedAt").isNotEmpty() @@ -69,7 +66,7 @@ public class GetProcessFullTests extends RestTest process = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingProcess(addedProcess).getProcess(); restClient.assertStatusCodeIs(HttpStatus.OK); process.assertThat() - .field("processDefinitionId").is(adhocProcessDefinition.getId()) + .field("processDefinitionId").is("activitiAdhoc:1:4") .and().field("durationInMs").isNotNull() .and().field("startUserId").is(addedProcess.getStartUserId()) .and().field("startActivityId").is("start") diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesCoreTests.java index 5a5c5fd5d..f45147d00 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesCoreTests.java @@ -5,7 +5,6 @@ import java.util.List; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestProcessDefinitionModel; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.rest.model.RestProcessModelsCollection; import org.alfresco.utility.model.FileModel; @@ -32,8 +31,6 @@ public class GetProcessesCoreTests extends RestTest private UserModel adminUser, userWhoStartsTask, assignee ; private TaskModel task1, task2; private ProcessModel process3; - private RestProcessDefinitionModel adhocProcessDefinition; - private RestProcessDefinitionModel activitiReviewProcessDefinition; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception @@ -46,8 +43,6 @@ public class GetProcessesCoreTests extends RestTest task1 = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); task2 = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(adminUser); process3 = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createSingleReviewerTaskAndAssignTo(assignee); - adhocProcessDefinition = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getAllProcessDefinitions().getProcessDefinitionByKey("activitiAdhoc"); - activitiReviewProcessDefinition = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getAllProcessDefinitions().getProcessDefinitionByKey("activitiReview"); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, @@ -73,8 +68,7 @@ public class GetProcessesCoreTests extends RestTest RestProcessModelsCollection processes = restClient.authenticateUser(userWhoStartsTask).where("processDefinitionKey='activitiReview'") .withWorkflowAPI().getProcesses(); restClient.assertStatusCodeIs(HttpStatus.OK); - - processes.assertThat().entriesListIsNotEmpty().and().entriesListContains("processDefinitionId", activitiReviewProcessDefinition.getId()) - .and().entriesListDoesNotContain("processDefinitionId", adhocProcessDefinition.getId()); + processes.assertThat().entriesListIsNotEmpty().and().entriesListContains("processDefinitionId", "activitiReview:1:8") + .and().entriesListDoesNotContain("processDefinitionId", "activitiAdhoc:1:4"); } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskTests.java index 6f069d2ff..744773f3a 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskTests.java @@ -10,7 +10,6 @@ import org.alfresco.rest.RestTest; import org.alfresco.rest.core.JsonBodyGenerator; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestProcessDefinitionModel; import org.alfresco.rest.model.RestTaskModel; import org.alfresco.rest.model.RestVariableModelsCollection; import org.alfresco.utility.model.FileModel; @@ -38,7 +37,6 @@ public class UpdateTaskTests extends RestTest TaskModel taskModel; RestTaskModel restTaskModel; UserModel adminUser; - RestProcessDefinitionModel activitiReviewProcessDefinition; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception @@ -49,7 +47,6 @@ public class UpdateTaskTests extends RestTest assigneeUser = dataUser.createRandomTestUser(); siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - activitiReviewProcessDefinition = restClient.authenticateUser(adminUser).withWorkflowAPI().getAllProcessDefinitions().getProcessDefinitionByKey("activitiReviewPooled"); } @BeforeMethod(alwaysRun = true) @@ -108,7 +105,7 @@ public class UpdateTaskTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); restTaskModel.assertThat() .field("dueAt").isNotEmpty() - .and().field("processDefinitionId").is(activitiReviewProcessDefinition.getId()) + .and().field("processDefinitionId").is("activitiReviewPooled:1:12") .and().field("processId").is(taskModel.getProcessId()) .and().field("name").is("Review Task") .and().field("description").is(taskModel.getMessage()) From dfd2340aecdafefbb76ad79531dbc609f7c2b5e6 Mon Sep 17 00:00:00 2001 From: Andrei Forascu Date: Thu, 14 Mar 2019 13:53:25 +0200 Subject: [PATCH 1466/1491] Revert "Revert "REPO-4243 / MNT-20407: Rest-Api Workflow processes and task tests are failing on ACS 6.0.1.1"" This reverts commit 998d918de6685a100093555207fcc2ab22b1ed0b. --- .../rest/workflow/processes/AddProcessCoreTests.java | 6 +++++- .../rest/workflow/processes/GetProcessFullTests.java | 7 +++++-- .../rest/workflow/processes/GetProcessesCoreTests.java | 10 ++++++++-- .../alfresco/rest/workflow/tasks/UpdateTaskTests.java | 5 ++++- 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessCoreTests.java index 5b187039f..8a2eac446 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessCoreTests.java @@ -5,6 +5,8 @@ import org.alfresco.rest.RestTest; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestProcessDefinitionModel; +import org.alfresco.rest.model.RestProcessDefinitionModelsCollection; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.rest.model.RestProcessModelsCollection; import org.alfresco.utility.model.TestGroup; @@ -26,6 +28,7 @@ public class AddProcessCoreTests extends RestTest private UserModel assignee, adminUser; private RestProcessModel addedProcess; private RestProcessModelsCollection processes; + private RestProcessDefinitionModel processDefinition; @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Verify non network admin is able to start new process using REST API and status code is OK (200)") @@ -40,10 +43,11 @@ public class AddProcessCoreTests extends RestTest addedProcess.assertThat().field("id").is(addedProcess.getId()) .and().field("startUserId").is(adminUser.getUsername()); + processDefinition = restClient.authenticateUser(adminUser).withWorkflowAPI().getAllProcessDefinitions().getProcessDefinitionByKey("activitiAdhoc"); processes = restClient.withWorkflowAPI().getProcesses(); restClient.assertStatusCodeIs(HttpStatus.OK); processes.assertThat().entriesListContains("id", addedProcess.getId()) - .assertThat().entriesListContains("processDefinitionId", "activitiAdhoc:1:4") + .assertThat().entriesListContains("processDefinitionId", processDefinition.getId()) .assertThat().entriesListContains("startUserId", adminUser.getUsername()) .assertThat().entriesListContains("startActivityId", "start") .assertThat().entriesListContains("completed", "false") diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessFullTests.java index 933e66829..01c11e8a2 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessFullTests.java @@ -2,6 +2,7 @@ package org.alfresco.rest.workflow.processes; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestProcessDefinitionModel; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; @@ -20,6 +21,7 @@ public class GetProcessFullTests extends RestTest { private UserModel userWhoStartsProcess, assignee; private RestProcessModel addedProcess, process; + private RestProcessDefinitionModel adhocProcessDefinition; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception @@ -27,6 +29,7 @@ public class GetProcessFullTests extends RestTest userWhoStartsProcess = dataUser.createRandomTestUser(); assignee = dataUser.createRandomTestUser(); addedProcess = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.High); + adhocProcessDefinition = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getAllProcessDefinitions().getProcessDefinitionByKey("activitiAdhoc"); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, @@ -52,7 +55,7 @@ public class GetProcessFullTests extends RestTest process = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingProcess(addedProcess).getProcess(); restClient.assertStatusCodeIs(HttpStatus.OK); process.assertThat() - .field("processDefinitionId").is("activitiAdhoc:1:4") + .field("processDefinitionId").is(adhocProcessDefinition.getId()) .and().field("startUserId").is(addedProcess.getStartUserId()) .and().field("startActivityId").is("start") .and().field("startedAt").isNotEmpty() @@ -66,7 +69,7 @@ public class GetProcessFullTests extends RestTest process = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingProcess(addedProcess).getProcess(); restClient.assertStatusCodeIs(HttpStatus.OK); process.assertThat() - .field("processDefinitionId").is("activitiAdhoc:1:4") + .field("processDefinitionId").is(adhocProcessDefinition.getId()) .and().field("durationInMs").isNotNull() .and().field("startUserId").is(addedProcess.getStartUserId()) .and().field("startActivityId").is("start") diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesCoreTests.java index f45147d00..5a5c5fd5d 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesCoreTests.java @@ -5,6 +5,7 @@ import java.util.List; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestProcessDefinitionModel; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.rest.model.RestProcessModelsCollection; import org.alfresco.utility.model.FileModel; @@ -31,6 +32,8 @@ public class GetProcessesCoreTests extends RestTest private UserModel adminUser, userWhoStartsTask, assignee ; private TaskModel task1, task2; private ProcessModel process3; + private RestProcessDefinitionModel adhocProcessDefinition; + private RestProcessDefinitionModel activitiReviewProcessDefinition; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception @@ -43,6 +46,8 @@ public class GetProcessesCoreTests extends RestTest task1 = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); task2 = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(adminUser); process3 = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createSingleReviewerTaskAndAssignTo(assignee); + adhocProcessDefinition = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getAllProcessDefinitions().getProcessDefinitionByKey("activitiAdhoc"); + activitiReviewProcessDefinition = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getAllProcessDefinitions().getProcessDefinitionByKey("activitiReview"); } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, @@ -68,7 +73,8 @@ public class GetProcessesCoreTests extends RestTest RestProcessModelsCollection processes = restClient.authenticateUser(userWhoStartsTask).where("processDefinitionKey='activitiReview'") .withWorkflowAPI().getProcesses(); restClient.assertStatusCodeIs(HttpStatus.OK); - processes.assertThat().entriesListIsNotEmpty().and().entriesListContains("processDefinitionId", "activitiReview:1:8") - .and().entriesListDoesNotContain("processDefinitionId", "activitiAdhoc:1:4"); + + processes.assertThat().entriesListIsNotEmpty().and().entriesListContains("processDefinitionId", activitiReviewProcessDefinition.getId()) + .and().entriesListDoesNotContain("processDefinitionId", adhocProcessDefinition.getId()); } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskTests.java index 744773f3a..6f069d2ff 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskTests.java @@ -10,6 +10,7 @@ import org.alfresco.rest.RestTest; import org.alfresco.rest.core.JsonBodyGenerator; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestProcessDefinitionModel; import org.alfresco.rest.model.RestTaskModel; import org.alfresco.rest.model.RestVariableModelsCollection; import org.alfresco.utility.model.FileModel; @@ -37,6 +38,7 @@ public class UpdateTaskTests extends RestTest TaskModel taskModel; RestTaskModel restTaskModel; UserModel adminUser; + RestProcessDefinitionModel activitiReviewProcessDefinition; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception @@ -47,6 +49,7 @@ public class UpdateTaskTests extends RestTest assigneeUser = dataUser.createRandomTestUser(); siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + activitiReviewProcessDefinition = restClient.authenticateUser(adminUser).withWorkflowAPI().getAllProcessDefinitions().getProcessDefinitionByKey("activitiReviewPooled"); } @BeforeMethod(alwaysRun = true) @@ -105,7 +108,7 @@ public class UpdateTaskTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); restTaskModel.assertThat() .field("dueAt").isNotEmpty() - .and().field("processDefinitionId").is("activitiReviewPooled:1:12") + .and().field("processDefinitionId").is(activitiReviewProcessDefinition.getId()) .and().field("processId").is(taskModel.getProcessId()) .and().field("name").is("Review Task") .and().field("description").is(taskModel.getMessage()) From a32cf785b8ce537bf25202fbe31f8d3ac41c6f31 Mon Sep 17 00:00:00 2001 From: Andrei Forascu Date: Thu, 14 Mar 2019 14:05:22 +0200 Subject: [PATCH 1467/1491] REPO-3235: - remove some leftovers from RestTest --- e2e-test/java/org/alfresco/rest/RestTest.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/RestTest.java b/e2e-test/java/org/alfresco/rest/RestTest.java index 0358a948d..1c6953576 100644 --- a/e2e-test/java/org/alfresco/rest/RestTest.java +++ b/e2e-test/java/org/alfresco/rest/RestTest.java @@ -8,7 +8,6 @@ import org.alfresco.rest.core.RestWrapper; import org.alfresco.utility.LogFactory; import org.alfresco.utility.TasProperties; import org.alfresco.utility.data.DataContent; -import org.alfresco.utility.data.DataDiscussion; import org.alfresco.utility.data.DataGroup; import org.alfresco.utility.data.DataLink; import org.alfresco.utility.data.DataSite; @@ -59,8 +58,6 @@ public abstract class RestTest extends AbstractTestNGSpringContextTests @Autowired protected DataLink dataLink; - @Autowired - protected DataDiscussion dataDiscussion; @Autowired protected WorkflowService workflow; From 4f3592d0c13bf335583c7384477fb7fdbec54afe Mon Sep 17 00:00:00 2001 From: Keerat Date: Fri, 15 Mar 2019 14:22:01 +0000 Subject: [PATCH 1468/1491] Search-1486 --- e2e-test/pom.xml | 2 + .../org/alfresco/cmis/CmisProperties.java | 55 + .../java/org/alfresco/cmis/CmisWrapper.java | 1119 ++++++++++++++++ .../org/alfresco/cmis/dsl/BaseObjectType.java | 185 +++ .../java/org/alfresco/cmis/dsl/CheckIn.java | 78 ++ .../org/alfresco/cmis/dsl/CmisAssertion.java | 1153 +++++++++++++++++ .../java/org/alfresco/cmis/dsl/CmisUtil.java | 743 +++++++++++ .../alfresco/cmis/dsl/DocumentVersioning.java | 137 ++ .../java/org/alfresco/cmis/dsl/JmxUtil.java | 39 + .../org/alfresco/cmis/dsl/QueryExecutor.java | 166 +++ .../exception/InvalidCmisObjectException.java | 10 + .../cmis/exception/UnrecognizedBinding.java | 12 + .../src/main/resources/model/tas-model.xml | 151 +++ .../resources/testdata/search-by-aspect.xml | 264 ++++ .../main/resources/testdata/search-by-id.xml | 118 ++ .../resources/testdata/search-by-path.xml | 97 ++ .../resources/testdata/search-by-property.xml | 225 ++++ .../resources/testdata/search-in-folder.xml | 24 + .../resources/testdata/search-in-tree.xml | 23 + .../org/alfresco/service/search/CmisTest.java | 69 + .../search/cmis/SolrSearchByAspectTests.java | 63 + .../search/cmis/SolrSearchByIdTests.java | 62 + .../search/cmis/SolrSearchByPathTests.java | 59 + .../cmis/SolrSearchByPropertyTests.java | 62 + .../search/cmis/SolrSearchInFolderTests.java | 70 + .../search/cmis/SolrSearchInTreeTests.java | 75 ++ .../cmis/SorlSearchSimpleQueryTests.java | 14 + .../test/resources/alfresco-cmis-context.xml | 19 + 28 files changed, 5094 insertions(+) create mode 100644 e2e-test/src/main/java/org/alfresco/cmis/CmisProperties.java create mode 100644 e2e-test/src/main/java/org/alfresco/cmis/CmisWrapper.java create mode 100644 e2e-test/src/main/java/org/alfresco/cmis/dsl/BaseObjectType.java create mode 100644 e2e-test/src/main/java/org/alfresco/cmis/dsl/CheckIn.java create mode 100644 e2e-test/src/main/java/org/alfresco/cmis/dsl/CmisAssertion.java create mode 100644 e2e-test/src/main/java/org/alfresco/cmis/dsl/CmisUtil.java create mode 100644 e2e-test/src/main/java/org/alfresco/cmis/dsl/DocumentVersioning.java create mode 100644 e2e-test/src/main/java/org/alfresco/cmis/dsl/JmxUtil.java create mode 100644 e2e-test/src/main/java/org/alfresco/cmis/dsl/QueryExecutor.java create mode 100644 e2e-test/src/main/java/org/alfresco/cmis/exception/InvalidCmisObjectException.java create mode 100644 e2e-test/src/main/java/org/alfresco/cmis/exception/UnrecognizedBinding.java create mode 100644 e2e-test/src/main/resources/model/tas-model.xml create mode 100644 e2e-test/src/main/resources/testdata/search-by-aspect.xml create mode 100644 e2e-test/src/main/resources/testdata/search-by-id.xml create mode 100644 e2e-test/src/main/resources/testdata/search-by-path.xml create mode 100644 e2e-test/src/main/resources/testdata/search-by-property.xml create mode 100644 e2e-test/src/main/resources/testdata/search-in-folder.xml create mode 100644 e2e-test/src/main/resources/testdata/search-in-tree.xml create mode 100644 e2e-test/src/test/java/org/alfresco/service/search/CmisTest.java create mode 100644 e2e-test/src/test/java/org/alfresco/service/search/cmis/SolrSearchByAspectTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/service/search/cmis/SolrSearchByIdTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/service/search/cmis/SolrSearchByPathTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/service/search/cmis/SolrSearchByPropertyTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/service/search/cmis/SolrSearchInFolderTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/service/search/cmis/SolrSearchInTreeTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/service/search/cmis/SorlSearchSimpleQueryTests.java create mode 100644 e2e-test/src/test/resources/alfresco-cmis-context.xml diff --git a/e2e-test/pom.xml b/e2e-test/pom.xml index dd26657f6..be3e26fba 100644 --- a/e2e-test/pom.xml +++ b/e2e-test/pom.xml @@ -19,6 +19,8 @@ 11 + ${java.version} + ${java.version} 3.8.0
      diff --git a/e2e-test/src/main/java/org/alfresco/cmis/CmisProperties.java b/e2e-test/src/main/java/org/alfresco/cmis/CmisProperties.java new file mode 100644 index 000000000..ed711e1f9 --- /dev/null +++ b/e2e-test/src/main/java/org/alfresco/cmis/CmisProperties.java @@ -0,0 +1,55 @@ +package org.alfresco.cmis; + +import org.alfresco.utility.TasProperties; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; +import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; + +@Configuration +@PropertySource("classpath:default.properties") +@PropertySource(value = "classpath:${environment}.properties", ignoreResourceNotFound = true) +public class CmisProperties +{ + @Autowired + private TasProperties properties; + + public TasProperties envProperty() + { + return properties; + } + + @Bean + public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() + { + return new PropertySourcesPlaceholderConfigurer(); + } + + @Value("${cmis.binding}") + private String cmisBinding; + + @Value("${cmis.basePath}") + private String basePath; + + public String getCmisBinding() + { + return cmisBinding; + } + + public String getBasePath() + { + return basePath; + } + + public void setBasePath(String basePath) + { + this.basePath = basePath; + } + + public void setCmisBinding(String cmisBinding) + { + this.cmisBinding = cmisBinding; + } +} diff --git a/e2e-test/src/main/java/org/alfresco/cmis/CmisWrapper.java b/e2e-test/src/main/java/org/alfresco/cmis/CmisWrapper.java new file mode 100644 index 000000000..4c1b0e8a0 --- /dev/null +++ b/e2e-test/src/main/java/org/alfresco/cmis/CmisWrapper.java @@ -0,0 +1,1119 @@ +package org.alfresco.cmis; + +import static org.alfresco.utility.Utility.checkObjectIsInitialized; +import static org.alfresco.utility.report.log.Step.STEP; + +import java.io.File; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.alfresco.cmis.dsl.BaseObjectType; +import org.alfresco.cmis.dsl.CheckIn; +import org.alfresco.cmis.dsl.CmisAssertion; +import org.alfresco.cmis.dsl.CmisUtil; +import org.alfresco.cmis.dsl.DocumentVersioning; +import org.alfresco.cmis.dsl.JmxUtil; +import org.alfresco.cmis.dsl.QueryExecutor; +import org.alfresco.utility.LogFactory; +import org.alfresco.utility.Utility; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.dsl.DSLContentModelAction; +import org.alfresco.utility.dsl.DSLFile; +import org.alfresco.utility.dsl.DSLFolder; +import org.alfresco.utility.dsl.DSLProtocol; +import org.alfresco.utility.exception.TestConfigurationException; +import org.alfresco.utility.model.ContentModel; +import org.alfresco.utility.model.DataListItemModel; +import org.alfresco.utility.model.DataListModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.GroupModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; +import org.apache.chemistry.opencmis.client.api.CmisObject; +import org.apache.chemistry.opencmis.client.api.Document; +import org.apache.chemistry.opencmis.client.api.FileableCmisObject; +import org.apache.chemistry.opencmis.client.api.Folder; +import org.apache.chemistry.opencmis.client.api.ObjectId; +import org.apache.chemistry.opencmis.client.api.Repository; +import org.apache.chemistry.opencmis.client.api.SecondaryType; +import org.apache.chemistry.opencmis.client.api.Session; +import org.apache.chemistry.opencmis.client.api.SessionFactory; +import org.apache.chemistry.opencmis.client.runtime.SessionFactoryImpl; +import org.apache.chemistry.opencmis.commons.PropertyIds; +import org.apache.chemistry.opencmis.commons.SessionParameter; +import org.apache.chemistry.opencmis.commons.data.AclCapabilities; +import org.apache.chemistry.opencmis.commons.data.ContentStream; +import org.apache.chemistry.opencmis.commons.data.PermissionMapping; +import org.apache.chemistry.opencmis.commons.data.RepositoryInfo; +import org.apache.chemistry.opencmis.commons.enums.AclPropagation; +import org.apache.chemistry.opencmis.commons.enums.BaseTypeId; +import org.apache.chemistry.opencmis.commons.enums.BindingType; +import org.apache.chemistry.opencmis.commons.enums.UnfileObject; +import org.apache.chemistry.opencmis.commons.enums.VersioningState; +import org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException; +import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException; +import org.apache.chemistry.opencmis.commons.exceptions.CmisStorageException; +import org.apache.chemistry.opencmis.commons.exceptions.CmisVersioningException; +import org.slf4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Service; + +@Service +@Scope(value = "prototype") +public class CmisWrapper extends DSLProtocol implements DSLContentModelAction, DSLFile, DSLFolder +{ + protected Logger LOG = LogFactory.getLogger(); + public static String STEP_PREFIX = "CMIS:"; + + private Session session; + + @Autowired + public + CmisProperties cmisProperties; + + public List deleteTreeFailedObjects = new ArrayList(); + + @Override + public CmisWrapper authenticateUser(UserModel userModel) + { + disconnect(); + STEP(String.format("%s Connect with %s/%s", STEP_PREFIX, userModel.getUsername(), userModel.getPassword())); + SessionFactory factory = SessionFactoryImpl.newInstance(); + Map parameter = new HashMap(); + parameter.put(SessionParameter.USER, userModel.getUsername()); + parameter.put(SessionParameter.PASSWORD, userModel.getPassword()); + String binding = cmisProperties.getCmisBinding().toLowerCase(); + String cmisURLPath = cmisProperties.envProperty().getFullServerUrl() + cmisProperties.getBasePath(); + if (binding.equals(BindingType.BROWSER.value())) + { + parameter.put(SessionParameter.BROWSER_URL, cmisURLPath); + parameter.put(SessionParameter.BINDING_TYPE, BindingType.BROWSER.value()); + LOG.info("Using binding type [{}] to [{}] and credentials: {}", BindingType.BROWSER.value(), cmisURLPath, userModel.toString()); + } + else if (binding.equals(BindingType.ATOMPUB.value().replace("pub", ""))) + { + parameter.put(SessionParameter.ATOMPUB_URL, cmisURLPath); + parameter.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value()); + LOG.info("Using binding type [{}] to [{}] and credentials: {}", BindingType.ATOMPUB.value(), cmisURLPath, userModel.toString()); + } + parameter.put(SessionParameter.CONNECT_TIMEOUT, "20000"); + parameter.put(SessionParameter.READ_TIMEOUT, "60000"); + List repositories = factory.getRepositories(parameter); + parameter.put(SessionParameter.REPOSITORY_ID, repositories.get(0).getId()); + session = repositories.get(0).createSession(); + setTestUser(userModel); + return this; + } + + public CmisWrapper authUserUsingBrowserUrlAndBindingType(UserModel userModel, String urlPath, String bindingType) + { + STEP(String.format("%s Setting binding type %s to %s", STEP_PREFIX, bindingType, urlPath)); + STEP(String.format("%s Connect with %s/%s", STEP_PREFIX, userModel.getUsername(), userModel.getPassword())); + SessionFactory factory = SessionFactoryImpl.newInstance(); + Map parameter = new HashMap(); + parameter.put(SessionParameter.USER, userModel.getUsername()); + parameter.put(SessionParameter.PASSWORD, userModel.getPassword()); + parameter.put(SessionParameter.BROWSER_URL, urlPath); + parameter.put(SessionParameter.BINDING_TYPE, bindingType); + LOG.info("Using binding type [{}] to [{}] and credentials: {}", bindingType, urlPath, userModel.toString()); + List repositories = factory.getRepositories(parameter); + parameter.put(SessionParameter.REPOSITORY_ID, repositories.get(0).getId()); + session = repositories.get(0).createSession(); + setTestUser(userModel); + return this; + } + + @Override + public CmisWrapper disconnect() + { + if (session != null) + { + getSession().clear(); + } + return this; + } + + @Override + public String buildPath(String parent, String... paths) + { + return Utility.convertBackslashToSlash(super.buildPath(parent, paths)).replace("//", "/"); + } + + /** + * Get the current session + * + * @return Session + */ + public synchronized Session getSession() + { + return session; + } + + @Override + public CmisWrapper createFile(FileModel fileModel) throws Exception + { + return createFile(fileModel, BaseTypeId.CMIS_DOCUMENT.value(), VersioningState.MAJOR); + } + + /** + * Create a new file + * + * @param fileModel {@link FileModel} file model to be created + * @param versioningState {@link VersioningState} + * @return CmisWrapper + * @throws Exception if error + */ + public CmisWrapper createFile(FileModel fileModel, VersioningState versioningState) throws Exception + { + return createFile(fileModel, BaseTypeId.CMIS_DOCUMENT.value(), versioningState); + } + + /** + * Create a new file + * + * @param fileModel {@link FileModel} file model to be created + * @param cmisBaseTypeId base type id (e.g. 'cmis:document') + * @param versioningState {@link VersioningState} + * @return CmisWrapper + * @throws Exception if error + */ + public CmisWrapper createFile(FileModel fileModel, String cmisBaseTypeId, VersioningState versioningState) throws Exception + { + return createFile(fileModel, withCMISUtil().getProperties(fileModel, cmisBaseTypeId), versioningState); + } + + public CmisWrapper createFile(FileModel fileModel, Map properties, VersioningState versioningState) throws Exception + { + ContentStream contentStream = dataContent.getContentStream(fileModel.getName(), fileModel.getContent()); + STEP(String.format("%s Create file '%s' in '%s'", STEP_PREFIX, fileModel.getName(), getCurrentSpace())); + Document doc = null; + try + { + doc = withCMISUtil().getCmisFolder(getCurrentSpace()).createDocument(properties, contentStream, versioningState); + } + catch (CmisStorageException | CmisRuntimeException re) + { + doc = withCMISUtil().getCmisFolder(getCurrentSpace()).createDocument(properties, contentStream, versioningState); + } + fileModel.setNodeRef(doc.getId()); + String location = buildPath(getCurrentSpace(), fileModel.getName()); + setLastResource(location); + fileModel.setProtocolLocation(location); + fileModel.setCmisLocation(location); + dataContent.closeContentStream(contentStream); + return this; + } + + /** + * Create new file from existing one (that was set in last resource) + * + * @param newfileModel {@link FileModel} file model to be created + * @param sourceFileModel {@link ContentModel} source file model + * @return CmisWrapper + * @throws Exception if error + */ + public CmisWrapper createFileFromSource(FileModel newfileModel, ContentModel sourceFileModel) throws Exception + { + return createFileFromSource(newfileModel, sourceFileModel, BaseTypeId.CMIS_DOCUMENT.value()); + } + + /** + * Create new file from existing one with versioning state set to Major(that was set in last resource) + * + * @param newfileModel {@link FileModel} file model to be created + * @param sourceFileModel {@link ContentModel} source file model + * @param cmisBaseTypeId base type id (e.g. 'cmis:document') + * @return CmisWrapper + * @throws Exception if error + */ + public CmisWrapper createFileFromSource(FileModel newfileModel, ContentModel sourceFileModel, String cmisBaseTypeId) throws Exception + { + return createFileFromSource(newfileModel, sourceFileModel, cmisBaseTypeId, VersioningState.MAJOR); + } + + /** + * Create new file from existing one (that was set in last resource) + * + * @param newfileModel {@link FileModel} file model to be created + * @param sourceFileModel {@link ContentModel} source file model + * @param versioningState version(e.g. 'VersioningState.MAJOR') + * @return CmisWrapper + * @throws Exception if error + */ + public CmisWrapper createFileFromSource(FileModel newfileModel, ContentModel sourceFileModel, VersioningState versioningState) throws Exception + { + return createFileFromSource(newfileModel, sourceFileModel, BaseTypeId.CMIS_DOCUMENT.value(), versioningState); + } + + /** + * Create new file from existing one (that was set in last resource) + * + * @param newfileModel {@link FileModel} file model to be created + * @param sourceFileModel {@link ContentModel} source file model + * @param cmisBaseTypeId base type id (e.g. 'cmis:document') + * @param versioningState (e.g. 'VersioningState.MAJOR') + * @return CmisWrapper + * @throws Exception if error + */ + public CmisWrapper createFileFromSource(FileModel newfileModel, ContentModel sourceFileModel, String cmisBaseTypeId, VersioningState versioningState) + throws Exception + { + String resourcePath = getLastResource(); + STEP(String.format("%s Create new file '%s' from source '%s' in '%s'", STEP_PREFIX, newfileModel.getName(), sourceFileModel.getName(), resourcePath)); + Document source = withCMISUtil().getCmisDocument(sourceFileModel.getCmisLocation()); + Map properties = withCMISUtil().getProperties(newfileModel, cmisBaseTypeId); + Document doc = withCMISUtil().getCmisFolder(resourcePath).createDocumentFromSource(source, properties, versioningState); + doc.refresh(); + newfileModel.setNodeRef(doc.getId()); + String location = buildPath(resourcePath, doc.getName()); + setLastResource(location); + newfileModel.setProtocolLocation(location); + newfileModel.setCmisLocation(location); + return this; + } + + @Override + public CmisWrapper createFolder(FolderModel folderModel) throws Exception + { + return createFolder(folderModel, BaseTypeId.CMIS_FOLDER.value()); + } + + public CmisWrapper createFolder(FolderModel folderModel, String cmisBaseTypeId) throws Exception + { + Map properties = withCMISUtil().getProperties(folderModel, cmisBaseTypeId); + createFolder(folderModel, properties); + return this; + } + + public CmisWrapper createFolder(FolderModel folderModel, Map properties) throws Exception + { + STEP(String.format("%s Create folder '%s' in '%s'", STEP_PREFIX, folderModel.getName(), getCurrentSpace())); + Folder folder = withCMISUtil().getCmisFolder(getCurrentSpace()).createFolder(properties); + String location = buildPath(getCurrentSpace(), folderModel.getName()); + setLastResource(location); + folderModel.setProtocolLocation(location); + folderModel.setCmisLocation(location); + folderModel.setNodeRef(folder.getId()); + return this; + } + + /** + * Deletes this folder and all subfolders with all versions and continue on failure + * + * @return current wrapper + * @throws Exception + */ + public CmisWrapper deleteFolderTree() throws Exception + { + return deleteFolderTree(true, UnfileObject.DELETE, true); + } + + /** + * Deletes this folder and all subfolders with specific parameters + * + * @param allVersions + * @param unfile {@link UnfileObject} + * @param continueOnFailure + * @return current wrapper + * @throws Exception + */ + public CmisWrapper deleteFolderTree(boolean allVersions, UnfileObject unfile, boolean continueOnFailure) throws Exception + { + String path = getLastResource(); + Folder parent = withCMISUtil().getCmisFolder(Utility.convertBackslashToSlash(new File(path).getParent())); + STEP(String.format("%s Delete parent folder from '%s'", STEP_PREFIX, path)); + Folder folder = withCMISUtil().getCmisFolder(path); + folder.refresh(); + deleteTreeFailedObjects.clear(); + deleteTreeFailedObjects = folder.deleteTree(allVersions, unfile, continueOnFailure); + for (String failedObj : deleteTreeFailedObjects) + { + LOG.error(String.format("Failed to delete object %s", failedObj)); + } + if (!deleteTreeFailedObjects.isEmpty()) + { + LOG.info(String.format("Retry: delete parent folder from %s", path)); + Utility.waitToLoopTime(2); + folder.refresh(); + folder.deleteTree(allVersions, unfile, continueOnFailure); + } + else + { + parent.refresh(); + dataContent.waitUntilContentIsDeleted(path); + } + return this; + } + + @Override + public String getRootPath() throws TestConfigurationException + { + return "/"; + } + + @Override + public String getSitesPath() throws TestConfigurationException + { + return String.format("%s/%s", getPrefixSpace(), "Sites"); + } + + @Override + public String getUserHomesPath() throws TestConfigurationException + { + return String.format("%s/%s", getPrefixSpace(), "User Homes"); + } + + @Override + public String getDataDictionaryPath() throws TestConfigurationException + { + return String.format("%s/%s", getPrefixSpace(), "Data Dictionary"); + } + + public String getSharedPath() throws TestConfigurationException + { + return String.format("%s/%s", getPrefixSpace(), "Shared"); + } + + @Override + public CmisWrapper usingSite(String siteId) throws Exception + { + STEP(String.format("%s Navigate to site '%s/%s'", STEP_PREFIX, siteId, "documentLibrary")); + checkObjectIsInitialized(siteId, "SiteID"); + setCurrentSpace(buildSiteDocumentLibraryPath(siteId, "")); + return this; + } + + @Override + public CmisWrapper usingSite(SiteModel siteModel) throws Exception + { + STEP(String.format("%s Navigate to site '%s/%s'", STEP_PREFIX, siteModel.getId(), "documentLibrary")); + checkObjectIsInitialized(siteModel, "SiteModel"); + String path = buildSiteDocumentLibraryPath(siteModel.getId(), ""); + setCurrentSpace(path); + return this; + } + + @Override + public CmisWrapper usingUserHome(String username) throws Exception + { + STEP(String.format("%s Navigate to 'User Home' folder", STEP_PREFIX)); + checkObjectIsInitialized(username, "username"); + setCurrentSpace(buildUserHomePath(username, "")); + return this; + } + + @Override + public CmisWrapper usingUserHome() throws Exception + { + STEP(String.format("%s Navigate to 'User Home' folder", STEP_PREFIX)); + checkObjectIsInitialized(getTestUser().getUsername(), "username"); + setCurrentSpace(buildUserHomePath(getTestUser().getUsername(), "")); + return this; + } + + public CmisWrapper usingShared() throws Exception + { + STEP(String.format("%s Navigate to 'Shared' folder", STEP_PREFIX)); + setCurrentSpace(getSharedPath()); + return this; + } + + @Override + public CmisWrapper usingResource(ContentModel model) throws Exception + { + STEP(String.format("%s Navigate to '%s'", STEP_PREFIX, model.getName())); + checkObjectIsInitialized(model, "contentName"); + setCurrentSpace(model.getCmisLocation()); + return this; + } + + @Override + protected String getProtocolJMXConfigurationStatus() throws Exception + { + return ""; + } + + @Override + public String getPrefixSpace() + { + return ""; + } + + @Override + public CmisWrapper rename(String newName) throws Exception + { + String resourcePath = getLastResource(); + CmisObject objToRename = withCMISUtil().getCmisObject(resourcePath); + STEP(String.format("%s Rename '%s' to '%s'", STEP_PREFIX, objToRename.getName(), newName)); + objToRename.rename(newName); + setLastResource(buildPath(new File(resourcePath).getParent(), newName)); + return this; + } + + @Override + public CmisWrapper update(String content) throws Exception + { + return update(content, true); + } + + public CmisWrapper update(String content, boolean isLastChunk) throws Exception + { + Document doc = withCMISUtil().getCmisDocument(getLastResource()); + doc.refresh(); + Utility.waitToLoopTime(2); + STEP(String.format("%s Update content from '%s' by appending '%s'", STEP_PREFIX, doc.getName(), content)); + ContentStream contentStream = dataContent.getContentStream(doc.getName(), content); + doc.appendContentStream(contentStream, isLastChunk); + dataContent.closeContentStream(contentStream); + return this; + } + + /** + * Update the properties of the last resource {@link ContentModel}. + * Example updateProperty("cmis:name", "test1234") + * + * @param property + * @param value + * @return + * @throws Exception + */ + public CmisWrapper updateProperty(String property, Object value) throws Exception + { + String lastResource = getLastResource(); + CmisObject objSource = withCMISUtil().getCmisObject(lastResource); + STEP(String.format("%s Update '%s' property for '%s'", STEP_PREFIX, property, objSource.getName())); + Map properties = new HashMap<>(); + properties.put(property, value); + objSource.updateProperties(properties, true); + + if (property.equals("cmis:name")) + { + if (objSource instanceof Document) + { + setLastResource(buildPath(new File(getLastResource()).getParent(), objSource.getName())); + } + else if (objSource instanceof Folder) + { + setLastResource(buildPath(((Folder) objSource).getFolderParent().getPath(), value.toString())); + } + } + return this; + } + + @Override + public CmisWrapper delete() throws Exception + { + String resourcePath = getLastResource(); + STEP(String.format("%s Delete content from '%s'", STEP_PREFIX, resourcePath)); + withCMISUtil().getCmisObject(resourcePath).delete(); + return this; + } + + /** + * Deletes all versions if parameter is set to true, otherwise deletes only last version + * + * @param allVersions + * @return + * @throws Exception + */ + public CmisWrapper deleteAllVersions(boolean allVersions) throws Exception + { + String resourcePath = getLastResource(); + if (allVersions) + STEP(String.format("%s Delete all content '%s' versions", STEP_PREFIX, resourcePath)); + else + STEP(String.format("%s Delete only the last content '%s' version", STEP_PREFIX, resourcePath)); + withCMISUtil().getCmisObject(getLastResource()).delete(allVersions); + return this; + } + + /** + * Delete content stream + * + * @return + * @throws Exception + */ + public CmisWrapper deleteContent() throws Exception + { + String resourcePath = getLastResource(); + STEP(String.format("%s Delete document content from '%s'", STEP_PREFIX, resourcePath)); + withCMISUtil().getCmisDocument(getLastResource()).deleteContentStream(); + return this; + } + + /** + * Delete content stream and refresh document + * + * @param refresh boolean refresh resource + * @return + * @throws Exception + */ + public CmisWrapper deleteContent(boolean refresh) throws Exception + { + String resourcePath = getLastResource(); + STEP(String.format("%s Delete document content from '%s'", STEP_PREFIX, resourcePath)); + withCMISUtil().getCmisDocument(getLastResource()).deleteContentStream(refresh); + return this; + } + + /** + * Set the content stream for a document + * + * @param content String content to set + * @param overwrite + * @return + * @throws Exception + */ + public CmisWrapper setContent(String content, boolean overwrite) throws Exception + { + Utility.waitToLoopTime(1); + Document doc = withCMISUtil().getCmisDocument(getLastResource()); + doc.refresh(); + STEP(String.format("%s Set '%s' content to '%s' - node: %s", STEP_PREFIX, content, doc.getName(), doc.getId())); + ContentStream contentStream = dataContent.getContentStream(doc.getName(), content); + try + { + doc.setContentStream(contentStream, overwrite, true); + } + catch (CmisStorageException cs) + { + doc.setContentStream(contentStream, overwrite, true); + } + dataContent.closeContentStream(contentStream); + return this; + } + + /** + * Set the content stream for a document with overwrite set to TRUE + * + * @param content + * @return + * @throws Exception + */ + public CmisWrapper setContent(String content) throws Exception + { + return setContent(content, true); + } + + /** + * Create a 'R:cm:basis' relationship between a source document and a target document + * + * @param targetContent + * @return + * @throws Exception + */ + public CmisWrapper createRelationshipWith(ContentModel targetContent) throws Exception + { + return createRelationshipWith(targetContent, "R:cm:basis"); + } + + /** + * Create relationship between a source document and a target document + * + * @param targetContent {@link ContentModel} + * @param relationType + * @return + * @throws Exception + */ + public CmisWrapper createRelationshipWith(ContentModel targetContent, String relationType) throws Exception + { + STEP(String.format("%s Set %s relationship between source from '%s' and target '%s'", STEP_PREFIX, relationType, getLastResource(), + targetContent.getName())); + Map properties = new HashMap<>(); + properties.put(PropertyIds.OBJECT_TYPE_ID, relationType); + properties.put(PropertyIds.SOURCE_ID, withCMISUtil().getCmisObject(getLastResource()).getId()); + properties.put(PropertyIds.TARGET_ID, targetContent.getNodeRef()); + getSession().createRelationship(properties); + return this; + } + + /** + * Method allows you to file a document object in more than one folder. + * + * @param destination - the destination folder to which this document will be added + * @param allVersions - if this parameter is true, then all versions of the document will be added to the destination folder + * @return + * @throws Exception + */ + public CmisWrapper addDocumentToFolder(FolderModel destination, boolean allVersions) throws Exception + { + CmisObject objSource = withCMISUtil().getCmisObject(getLastResource()); + Folder objDestination = withCMISUtil().getCmisFolder(destination.getCmisLocation()); + STEP(String.format("%s Add object '%s' to '%s'", STEP_PREFIX, objSource.getName(), destination.getCmisLocation())); + ((FileableCmisObject) objSource).addToFolder(objDestination, allVersions); + setLastResource(buildPath(destination.getCmisLocation(), objSource.getName())); + return this; + } + + /** + * Method allows you to remove a document object from the given folder. + * + * @param parentFolder - the folder from which this object should be removed + * @return + * @throws Exception + */ + public CmisWrapper removeDocumentFromFolder(FolderModel parentFolder) throws Exception + { + CmisObject objSource = withCMISUtil().getCmisObject(getLastResource()); + Folder parentObj = withCMISUtil().getCmisFolder(parentFolder.getCmisLocation()); + STEP(String.format("%s Remove object '%s' from '%s'", STEP_PREFIX, objSource.getName(), parentFolder.getCmisLocation())); + ((FileableCmisObject) objSource).removeFromFolder(parentObj); + return this; + } + + /** + * Get child folders from a parent folder + * + * @return List + */ + @Override + public List getFolders() throws Exception + { + STEP(String.format("%s Get the folder children from '%s'", STEP_PREFIX, getLastResource())); + return withCMISUtil().getFolders(); + } + + /** + * Get child documents from a parent folder + * + * @return List + */ + @Override + public List getFiles() throws Exception + { + STEP(String.format("%s Get the file children from '%s'", STEP_PREFIX, getLastResource())); + return withCMISUtil().getFiles(); + } + + @Override + public CmisWrapper copyTo(ContentModel destination) throws Exception + { + String source = getLastResource(); + String sourceName = new File(source).getName(); + STEP(String.format("%s Copy '%s' to '%s'", STEP_PREFIX, sourceName, destination.getCmisLocation())); + CmisObject objSource = withCMISUtil().getCmisObject(source); + + CmisObject objDestination = withCMISUtil().getCmisObject(destination.getCmisLocation()); + if (objSource instanceof Document) + { + Document d = (Document) objSource; + d.copy(objDestination); + } + else if (objSource instanceof Folder) + { + Folder fFrom = (Folder) objSource; + Folder toFolder = (Folder) objDestination; + withCMISUtil().copyFolder(fFrom, toFolder); + } + setLastResource(buildPath(destination.getCmisLocation(), sourceName)); + return this; + } + + @Override + public CmisWrapper moveTo(ContentModel destination) throws Exception + { + String source = getLastResource(); + String sourceName = new File(source).getName(); + STEP(String.format("%s Move '%s' to '%s'", STEP_PREFIX, sourceName, destination.getCmisLocation())); + CmisObject objSource = withCMISUtil().getCmisObject(source); + CmisObject objDestination = withCMISUtil().getCmisObject(destination.getCmisLocation()); + if (objSource instanceof Document) + { + Document d = (Document) objSource; + List parents = d.getParents(); + CmisObject parent = getSession().getObject(parents.get(0).getId()); + d.move(parent, objDestination); + } + else if (objSource instanceof Folder) + { + Folder f = (Folder) objSource; + List parents = f.getParents(); + CmisObject parent = getSession().getObject(parents.get(0).getId()); + f.move(parent, objDestination); + } + setLastResource(buildPath(destination.getCmisLocation(), sourceName)); + return this; + } + + public RepositoryInfo getRepositoryInfo() + { + STEP(String.format("Get repository information for user %s", getCurrentUser().getUsername())); + return getSession().getRepositoryInfo(); + } + + public AclCapabilities getAclCapabilities() + { + return getRepositoryInfo().getAclCapabilities(); + } + + /** + * Checks out the document + */ + public CmisWrapper checkOut() + { + Document document = withCMISUtil().getCmisDocument(getLastResource()); + STEP(String.format("%s Check out document '%s'", STEP_PREFIX, document.getName())); + try + { + document.checkOut(); + } + catch (CmisRuntimeException e) + { + document.checkOut(); + } + return this; + } + + /** + * If this is a PWC (private working copy) the check out will be reversed. + */ + public CmisWrapper cancelCheckOut() + { + Document document = withCMISUtil().getCmisDocument(getLastResource()); + STEP(String.format("%s Cancel document '%s' check out", STEP_PREFIX, document.getName())); + document.cancelCheckOut(); + return this; + } + + /** + * Starts the process to check in a document + */ + public CheckIn prepareDocumentForCheckIn() + { + return new CheckIn(this); + } + + /** + * Reloads the resource from the repository + */ + public CmisWrapper refreshResource() + { + CmisObject cmisObject = withCMISUtil().getCmisObject(getLastResource()); + STEP(String.format("%s Reload '%s'", STEP_PREFIX, cmisObject.getName())); + cmisObject.refresh(); + return this; + } + + /** + * @return utilities that are used by CMIS + */ + public CmisUtil withCMISUtil() + { + return new CmisUtil(this); + } + + /** + * @return JMX DSL for this wrapper + */ + public JmxUtil withJMX() + { + return new JmxUtil(this, jmxBuilder.getJmxClient()); + } + + @Override + public CmisAssertion assertThat() + { + return new CmisAssertion(this); + } + + /** + * Starts the process to work with a version of a document + */ + public DocumentVersioning usingVersion() + { + return new DocumentVersioning(this, withCMISUtil().getCmisObject(getLastResource())); + } + + /** + * Add new permission for user + * + * @param user UserModel user + * @param role UserRole role to add + * @param aclPropagation AclPropagation propagation + * @return + */ + public CmisWrapper addAcl(UserModel user, UserRole role, AclPropagation aclPropagation) + { + STEP(String.format("%s Add permission '%s' for user %s ", STEP_PREFIX, role.name(), user.getUsername())); + withCMISUtil().getCmisObject(getLastResource(), withCMISUtil().setIncludeAclContext()).addAcl(withCMISUtil().createAce(user, role), aclPropagation); + return this; + } + + /** + * Add new permission for a group + * + * @param group GroupModel group + * @param role UserRole role to add + * @param aclPropagation AclPropagation propagation + * @return + */ + public CmisWrapper addAcl(GroupModel group, UserRole role, AclPropagation aclPropagation) + { + STEP(String.format("%s Add permission '%s' for user %s ", STEP_PREFIX, role.name(), group.getDisplayName())); + withCMISUtil().getCmisObject(getLastResource(), withCMISUtil().setIncludeAclContext()).addAcl(withCMISUtil().createAce(group, role), aclPropagation); + return this; + } + + /** + * Add new permission for a group + * + * @param group GroupModel group + * @param role UserRole role to add + * @return + */ + public CmisWrapper addAcl(GroupModel group, UserRole role) + { + return addAcl(group, role, null); + } + + /** + * Add new permissions to user + * + * @param user {@link UserModel} + * @param permissions to add ({@link PermissionMapping} can be used) + * @return + */ + public CmisWrapper addAcl(UserModel user, String... permissions) + { + withCMISUtil().getCmisObject(getLastResource(), withCMISUtil().setIncludeAclContext()).addAcl(withCMISUtil().createAce(user, permissions), null); + return this; + } + + /** + * Add new permission for user + * + * @param user UserModel user + * @param role UserRole role to add + * @return + */ + public CmisWrapper addAcl(UserModel user, UserRole role) + { + return addAcl(user, role, null); + } + + /** + * Update permission for user. + * If the role to remove is invalid a {@link CmisConstraintException} is thrown. + * + * @param user UserModel user + * @param newRole UserRole new role to add + * @param removeRole UserRole remove already added role + * @param aclPropagation AclPropagation + * @return + */ + public CmisWrapper applyAcl(UserModel user, UserRole newRole, UserRole removeRole, AclPropagation aclPropagation) + { + STEP(String.format("%s Edit permission for user %s from %s to %s ", STEP_PREFIX, user.getUsername(), removeRole.name(), newRole.name())); + withCMISUtil().getCmisObject(getLastResource(), withCMISUtil().setIncludeAclContext()).applyAcl(withCMISUtil().createAce(user, newRole), + withCMISUtil().createAce(user, removeRole), aclPropagation); + return this; + } + + /** + * Update permission for user. + * If the role to remove is invalid a {@link CmisConstraintException} is thrown. + * + * @param user UserModel user + * @param newRole UserRole new role to add + * @param removeRole UserRole remove already added role + * @return + */ + public CmisWrapper applyAcl(UserModel user, UserRole newRole, UserRole removeRole) + { + return applyAcl(user, newRole, removeRole, null); + } + + /** + * Update permission for user. + * If the permission to remove is invalid a {@link CmisConstraintException} is thrown. + * + * @param user {@link UserModel } + * @param newPermission permissions to add ({@link PermissionMapping} can be used) + * @param removePermission permissions to remove ({@link PermissionMapping} can be used) + * @return + */ + public CmisWrapper applyAcl(UserModel user, String newPermission, String removePermission) + { + STEP(String.format("%s Edit permission for user %s from %s to %s ", STEP_PREFIX, user.getUsername(), removePermission, newPermission)); + withCMISUtil().getCmisObject(getLastResource(), withCMISUtil().setIncludeAclContext()).applyAcl(withCMISUtil().createAce(user, newPermission), + withCMISUtil().createAce(user, removePermission), null); + return this; + } + + /** + * Remove permission from user + * + * @param user UserModel user + * @param removeRole UserRole role to remove + * @param aclPropagation AclPropagation + * @return + */ + public CmisWrapper removeAcl(UserModel user, UserRole removeRole, AclPropagation aclPropagation) + { + STEP(String.format("%s Remove permission '%s' from user %s ", STEP_PREFIX, removeRole.name(), user.getUsername())); + withCMISUtil().getCmisObject(getLastResource(), withCMISUtil().setIncludeAclContext()).removeAcl(withCMISUtil().createAce(user, removeRole), + aclPropagation); + return this; + } + + /** + * Remove permission from user + * + * @param user UserModel user + * @param removeRole UserRole role to remove + * @return + */ + public CmisWrapper removeAcl(UserModel user, UserRole removeRole) + { + return removeAcl(user, removeRole, null); + } + + public CmisWrapper removeAcl(UserModel user, String permissionToRemove) + { + STEP(String.format("%s Remove permission '%s' from user %s ", STEP_PREFIX, permissionToRemove, user.getUsername())); + withCMISUtil().getCmisObject(getLastResource(), withCMISUtil().setIncludeAclContext()).removeAcl(withCMISUtil().createAce(user, permissionToRemove), + null); + return this; + } + + /** + * Pass a string CMIS query, that will be handled by {@link QueryExecutor} using {@link org.apache.chemistry.opencmis.client.api.Session#query(String, boolean)} + * + * @param query + * @return {@link QueryExecutor} will all DSL assertions on returned restult + */ + public QueryExecutor withQuery(String query) + { + return new QueryExecutor(this, query); + } + + /** + * Use this method if the document is checked out. If not {@link CmisVersioningException} will be thrown. + * + * @return + * @throws Exception + */ + public CmisWrapper usingPWCDocument() throws Exception + { + STEP(String.format("%s Navigate to private working copy of content '%s'", STEP_PREFIX, withCMISUtil().getPWCFileModel().getName())); + setCurrentSpace(withCMISUtil().getPWCFileModel().getCmisLocation()); + return this; + } + + /** + * @param baseType + * @return the DSL of asserting BaseObject type children for example. + */ + public BaseObjectType usingObjectType(String baseType) + { + return new BaseObjectType(this, baseType); + } + + /** + * Create a new data list type + * + * @param dataListModel {@link DataListModel} + * @return + * @throws Exception + */ + public CmisWrapper createDataList(DataListModel dataListModel) throws Exception + { + Map properties = withCMISUtil().getProperties(dataListModel, "F:dl:dataList"); + properties.put("dl:dataListItemType", dataListModel.getDataListItemType()); + Folder folder = withCMISUtil().getCmisFolder(getCurrentSpace()).createFolder(properties); + String location = buildPath(getCurrentSpace(), dataListModel.getName()); + setLastResource(location); + dataListModel.setProtocolLocation(location); + dataListModel.setCmisLocation(location); + dataListModel.setNodeRef(folder.getId()); + return this; + } + + /** + * Create new data list item + * + * @param itemModel {@link DataListItemModel} + * @return + * @throws Exception + */ + public CmisWrapper createDataListItem(DataListItemModel itemModel) throws Exception + { + Map propertyMap = itemModel.getItemProperties(); + String name = (String) propertyMap.get(PropertyIds.NAME); + STEP(String.format("%s Create new data list item %s (type: %s)", STEP_PREFIX, name, propertyMap.get(PropertyIds.OBJECT_TYPE_ID))); + ObjectId itemId = getSession().createDocument(propertyMap, withCMISUtil().getCmisObject(getLastResource()), null, null); + String path = buildPath(getCurrentSpace(), name); + itemModel.setName(name); + itemModel.setCmisLocation(path); + itemModel.setProtocolLocation(path); + itemModel.setNodeRef(itemId.getId()); + setLastResource(path); + return this; + } + + /** + * Attach documents to existent item set in last resource + * + * @param documents {@link ContentModel} list of content to attach + * @return + */ + public CmisWrapper attachDocument(ContentModel... contents) + { + String itemId = withCMISUtil().getCmisObject(getLastResource()).getId(); + for (ContentModel content : contents) + { + STEP(String.format("Attach document %s to item %s", content.getName(), itemId)); + Map relProps = new HashMap(); + relProps.put(PropertyIds.OBJECT_TYPE_ID, "R:cm:attachments"); + relProps.put(PropertyIds.SOURCE_ID, itemId); + relProps.put(PropertyIds.TARGET_ID, content.getNodeRef()); + getSession().createRelationship(relProps); + } + return this; + } + + /** + * Assign user to existent item set in last resource + * + * @param user {@link UserModel} + * @param relationType e.g. R:dl:issueAssignedTo, R:dl:assignee, R:dl:taskAssignee + * @return + */ + public CmisWrapper assignToUser(UserModel user, String relationType) + { + Map relProps = new HashMap(); + relProps.put(PropertyIds.OBJECT_TYPE_ID, relationType); + relProps.put(PropertyIds.SOURCE_ID, withCMISUtil().getCmisObject(getLastResource()).getId()); + relProps.put(PropertyIds.TARGET_ID, withCMISUtil().getUserNodeRef(user)); + getSession().createRelationship(relProps); + return this; + } + + /** + * Add new secondary types + * + * @param secondaryTypes e.g. P:cm:effectivity, P:audio:audio, P:cm:dublincore + * @return + */ + public CmisWrapper addSecondaryTypes(String...secondaryTypes) + { + CmisObject object = withCMISUtil().getCmisObject(getLastResource()); + List secondaryTypesNew = new ArrayList(); + for(SecondaryType oldType : object.getSecondaryTypes()) + { + secondaryTypesNew.add(oldType.getId()); + } + for(String newType : secondaryTypes) + { + secondaryTypesNew.add(newType); + } + Map properties = new HashMap(); + properties.put(PropertyIds.SECONDARY_OBJECT_TYPE_IDS, secondaryTypesNew); + object.updateProperties(properties); + return this; + } +} diff --git a/e2e-test/src/main/java/org/alfresco/cmis/dsl/BaseObjectType.java b/e2e-test/src/main/java/org/alfresco/cmis/dsl/BaseObjectType.java new file mode 100644 index 000000000..b5f1787f0 --- /dev/null +++ b/e2e-test/src/main/java/org/alfresco/cmis/dsl/BaseObjectType.java @@ -0,0 +1,185 @@ +package org.alfresco.cmis.dsl; + +import static org.alfresco.utility.report.log.Step.STEP; + +import java.util.Iterator; +import java.util.List; + +import org.alfresco.cmis.CmisWrapper; +import org.alfresco.utility.LogFactory; +import org.apache.chemistry.opencmis.client.api.ItemIterable; +import org.apache.chemistry.opencmis.client.api.ObjectType; +import org.apache.chemistry.opencmis.client.api.Tree; +import org.apache.chemistry.opencmis.client.runtime.objecttype.ObjectTypeHelper; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import org.slf4j.Logger; +import org.testng.Assert; + +/** + * DSL for preparing calls on getting the type children of a type. + */ +public class BaseObjectType +{ + private CmisWrapper cmisAPI; + private String baseTypeID; + private boolean includePropertyDefinition = false; + private Logger LOG = LogFactory.getLogger(); + + public BaseObjectType(CmisWrapper cmisAPI, String baseTypeID) + { + this.cmisAPI = cmisAPI; + this.baseTypeID = baseTypeID; + } + + public BaseObjectType withPropertyDefinitions() + { + this.includePropertyDefinition = true; + return this; + } + + public BaseObjectType withoutPropertyDefinitions() + { + this.includePropertyDefinition = false; + return this; + } + + /** + * Example of objectTypeID: + * "D:trx:transferReport" - see {@link ObjectTypeHelper} "D:trx:tempTransferStore" + * "D:imap:imapAttach" + * + * @param objectTypeID + */ + public PropertyDefinitionObject hasChildren(String objectTypeID) + { + return checkChildren(objectTypeID, true); + } + + /** + * Example of objectTypeID: + * "D:trx:transferReport" - see {@link ObjectTypeHelper} "D:trx:tempTransferStore" + * "D:imap:imapAttach" + * + * @param objectTypeID + */ + public CmisWrapper doesNotHaveChildren(String objectTypeID) + { + checkChildren(objectTypeID, false); + return cmisAPI; + } + + /** + * Example of objectTypeID: + * "D:trx:transferReport" - see {@link ObjectTypeHelper} "D:trx:tempTransferStore" + * "D:imap:imapAttach" + * + * @param objectTypeID + */ + private PropertyDefinitionObject checkChildren(String objectTypeID, boolean exist) + { + ItemIterable values = cmisAPI.withCMISUtil().getTypeChildren(this.baseTypeID, includePropertyDefinition); + boolean foundChild = false; + PropertyDefinitionObject propDefinition = null; + for (Iterator iterator = values.iterator(); iterator.hasNext();) + { + ObjectType type = (ObjectType) iterator.next(); + LOG.info("Found child Object Type: {}", ToStringBuilder.reflectionToString(type, ToStringStyle.MULTI_LINE_STYLE)); + if (type.getId().equals(objectTypeID)) + { + foundChild = true; + propDefinition = new PropertyDefinitionObject(type); + break; + } + } + Assert.assertEquals(foundChild, exist, + String.format("Object Type with ID[%s] is found as children for Parent Type: [%s]", objectTypeID, this.baseTypeID)); + return propDefinition; + } + + public class PropertyDefinitionObject + { + ObjectType type; + + public PropertyDefinitionObject(ObjectType type) + { + this.type = type; + } + + public PropertyDefinitionObject propertyDefinitionIsEmpty() + { + STEP(String.format("%s Verify that property definitions map is empty.", CmisWrapper.STEP_PREFIX)); + Assert.assertTrue(type.getPropertyDefinitions().isEmpty(), "Property definitions is empty."); + return this; + } + + public PropertyDefinitionObject propertyDefinitionIsNotEmpty() + { + STEP(String.format("%s Verify that property definitions map is not empty.", CmisWrapper.STEP_PREFIX)); + Assert.assertFalse(type.getPropertyDefinitions().isEmpty(), "Property definitions is not empty."); + return this; + } + } + + private CmisWrapper checkDescendents(int depth, boolean exist, String... objectTypeIDs) + { + List> values = cmisAPI.withCMISUtil().getTypeDescendants(this.baseTypeID, depth, includePropertyDefinition); + for (String objectTypeID : objectTypeIDs) + { + boolean foundChild = false; + for (Tree tree : values) + { + if (tree.getItem().getId().equals(objectTypeID)) + { + foundChild = true; + break; + } + } + Assert.assertEquals(foundChild, exist, + String.format("Assert %b: Descendant [%s] is found as descendant for Type: [%s]", exist, objectTypeID, this.baseTypeID)); + + if (foundChild) + { + STEP(String.format("%s Cmis object '%s' is found as descendant.", CmisWrapper.STEP_PREFIX, objectTypeID)); + } + else + { + STEP(String.format("%s Cmis object '%s' is NOT found as descendant.", CmisWrapper.STEP_PREFIX, objectTypeID)); + } + } + return cmisAPI; + } + + /** + * Assert that specified descendantType is present in the depth of tree + * Depth can be -1 or >= 1 + * Example of objectTypeID: + * "D:trx:transferReport" - see {@link ObjectTypeHelper} "D:trx:tempTransferStore" + * "D:imap:imapAttach" + * + * @param objectTypeID + * @param depth + * @return + */ + public CmisWrapper hasDescendantType(int depth, String... objectTypeIDs) + { + return checkDescendents(depth, true, objectTypeIDs); + } + + /** + * Assert that specified descendantType is NOT present in the depth of tree + * Depth can be -1 or >= 1 + * Example of objectTypeID: + * "D:trx:transferReport" - see {@link ObjectTypeHelper} "D:trx:tempTransferStore" + * "D:imap:imapAttach" + * + * @param objectTypeID + * @param depth + * @return + */ + public CmisWrapper doesNotHaveDescendantType(int depth, String... objectTypeIDs) + { + checkDescendents(depth, false, objectTypeIDs); + return cmisAPI; + } +} diff --git a/e2e-test/src/main/java/org/alfresco/cmis/dsl/CheckIn.java b/e2e-test/src/main/java/org/alfresco/cmis/dsl/CheckIn.java new file mode 100644 index 000000000..1dbcc3f3d --- /dev/null +++ b/e2e-test/src/main/java/org/alfresco/cmis/dsl/CheckIn.java @@ -0,0 +1,78 @@ +package org.alfresco.cmis.dsl; + +import org.alfresco.cmis.CmisWrapper; +import org.alfresco.utility.Utility; +import org.apache.chemistry.opencmis.client.api.Document; +import org.apache.chemistry.opencmis.commons.data.ContentStream; +import org.apache.chemistry.opencmis.commons.exceptions.CmisStorageException; + +import java.util.Map; + +/** + * DSL pertaining only to check in a {@link Document} + */ +public class CheckIn +{ + private CmisWrapper cmisWrapper; + private boolean version; + private Map properties; + private String content; + private String comment; + + public CheckIn(CmisWrapper cmisWrapper) + { + this.cmisWrapper = cmisWrapper; + } + + public CheckIn withMajorVersion() + { + this.version = true; + return this; + } + + public CheckIn withMinorVersion() + { + this.version = false; + return this; + } + + public CheckIn withContent(String content) + { + this.content = content; + return this; + } + + public CheckIn withoutComment() + { + this.comment = null; + return this; + } + + public CheckIn withComment(String comment) + { + this.comment = comment; + return this; + } + + public CmisWrapper checkIn() throws Exception + { + return checkIn(properties); + } + + public CmisWrapper checkIn(Map properties) throws Exception + { + ContentStream contentStream = cmisWrapper.withCMISUtil().getContentStream(content); + try + { + Document pwc = cmisWrapper.withCMISUtil().getPWCDocument(); + pwc.refresh(); + Utility.waitToLoopTime(2); + pwc.checkIn(version, properties, contentStream, comment); + } + catch(CmisStorageException st) + { + cmisWrapper.withCMISUtil().getPWCDocument().checkIn(version, properties, contentStream, comment); + } + return cmisWrapper; + } +} diff --git a/e2e-test/src/main/java/org/alfresco/cmis/dsl/CmisAssertion.java b/e2e-test/src/main/java/org/alfresco/cmis/dsl/CmisAssertion.java new file mode 100644 index 000000000..8fd4267fd --- /dev/null +++ b/e2e-test/src/main/java/org/alfresco/cmis/dsl/CmisAssertion.java @@ -0,0 +1,1153 @@ +package org.alfresco.cmis.dsl; + +import static org.alfresco.utility.report.log.Step.STEP; + +import java.io.File; +import java.util.ArrayList; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.alfresco.cmis.CmisWrapper; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.dsl.DSLAssertion; +import org.alfresco.utility.exception.TestConfigurationException; +import org.alfresco.utility.model.ContentModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.GroupModel; +import org.alfresco.utility.model.UserModel; +import org.apache.chemistry.opencmis.client.api.ChangeEvent; +import org.apache.chemistry.opencmis.client.api.CmisObject; +import org.apache.chemistry.opencmis.client.api.Document; +import org.apache.chemistry.opencmis.client.api.Folder; +import org.apache.chemistry.opencmis.client.api.ItemIterable; +import org.apache.chemistry.opencmis.client.api.ObjectType; +import org.apache.chemistry.opencmis.client.api.OperationContext; +import org.apache.chemistry.opencmis.client.api.Property; +import org.apache.chemistry.opencmis.client.api.Relationship; +import org.apache.chemistry.opencmis.client.api.Rendition; +import org.apache.chemistry.opencmis.client.api.SecondaryType; +import org.apache.chemistry.opencmis.client.api.Session; +import org.apache.chemistry.opencmis.client.runtime.OperationContextImpl; +import org.apache.chemistry.opencmis.commons.data.Ace; +import org.apache.chemistry.opencmis.commons.data.Acl; +import org.apache.chemistry.opencmis.commons.data.CmisExtensionElement; +import org.apache.chemistry.opencmis.commons.enums.Action; +import org.apache.chemistry.opencmis.commons.enums.ChangeType; +import org.apache.chemistry.opencmis.commons.enums.ExtensionLevel; +import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships; +import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException; +import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException; +import org.apache.commons.lang3.StringUtils; +import org.testng.Assert; + +/** + * DSL with all assertion available for {@link CmisWrapper} + */ +public class CmisAssertion extends DSLAssertion +{ + public static String STEP_PREFIX = "CMIS:"; + + public CmisAssertion(CmisWrapper cmisAPI) + { + super(cmisAPI); + } + + public CmisWrapper cmisAPI() + { + return getProtocol(); + } + + @Override + public CmisWrapper existsInRepo() + { + STEP(String.format("CMIS: Assert that content '%s' exists in repository", cmisAPI().getLastResource())); + Assert.assertTrue(!cmisAPI().withCMISUtil().getCmisObject(cmisAPI().getLastResource()).getId().isEmpty(), + String.format("Content {%s} was found in repository", cmisAPI().getLastResource())); + return cmisAPI(); + } + + @Override + public CmisWrapper doesNotExistInRepo() + { + STEP(String.format("CMIS: Assert that content '%s' does not exist in repository", cmisAPI().getLastResource())); + boolean notFound = false; + try + { + cmisAPI().getSession().clear(); + cmisAPI().withCMISUtil().getCmisObject(cmisAPI().getLastResource()); + } + catch (CmisObjectNotFoundException | CmisRuntimeException e) + { + notFound = true; + } + Assert.assertTrue(notFound, String.format("Content {%s} was NOT found in repository", cmisAPI().getLastResource())); + return cmisAPI(); + } + + /** + * Verify changes for a specific object from cmis log + * + * @param model {@link ContentModel} + * @param changeTypes {@link ChangeType} + * @return + * @throws Exception + */ + public CmisWrapper contentModelHasChanges(ContentModel model, ChangeType... changeTypes) throws Exception + { + String token = cmisAPI().getRepositoryInfo().getLatestChangeLogToken(); + if (StringUtils.isEmpty(token)) + { + throw new TestConfigurationException("Please enable CMIS audit"); + } + ItemIterable events = cmisAPI().getSession().getContentChanges(token, true); + String lastObjectId = model.getNodeRef(); + boolean isChange = false; + for (ChangeType changeType : changeTypes) + { + STEP(String.format("%s Verify action %s for content: %s", CmisWrapper.STEP_PREFIX, changeType, model.getName())); + isChange = false; + for (ChangeEvent event : events) + { + if (event.getObjectId().equals(lastObjectId)) + { + if (changeType == event.getChangeType()) + { + isChange = true; + break; + } + } + } + Assert.assertTrue(isChange, String.format("Action %s for content: '%s' was found", changeType, model.getName())); + } + return cmisAPI(); + } + + /** + * Verify that a specific object does not have changes from cmis log + * + * @param model {@link ContentModel} + * @param changeTypes {@link ChangeType} + * @return + * @throws Exception + */ + public CmisWrapper contentModelDoesnotHaveChangesWithWrongToken(ContentModel model, ChangeType... changeTypes) throws Exception + { + String token = cmisAPI().getRepositoryInfo().getLatestChangeLogToken(); + if (StringUtils.isEmpty(token)) + { + throw new TestConfigurationException("Please enable CMIS audit"); + } + ItemIterable events = cmisAPI().getSession().getContentChanges(token + 1, true); + String lastObjectId = model.getNodeRef(); + boolean isChange = false; + for (ChangeType changeType : changeTypes) + { + STEP(String.format("%s Verify action %s for content: %s", CmisWrapper.STEP_PREFIX, changeType, model.getName())); + isChange = false; + for (ChangeEvent event : events) + { + if (event.getObjectId().equals(lastObjectId)) + { + if (changeType == event.getChangeType()) + { + isChange = true; + break; + } + } + } + Assert.assertFalse(isChange, String.format("Action %s for content: '%s' was found", changeType, model.getName())); + } + return cmisAPI(); + } + + /** + * Check if the {@link #getLastResource()} has the list of {@link Action} Example: + * {code} + * .hasAllowableActions(Action.CAN_CREATE_FOLDER); + * {code} + * + * @param actions + * @return + */ + public CmisWrapper hasAllowableActions(Action... actions) + { + CmisObject cmisObject = cmisAPI().withCMISUtil().getCmisObject(cmisAPI().getLastResource()); + for (Action action : actions) + { + STEP(String.format("%s Verify if object %s has allowable action %s", CmisWrapper.STEP_PREFIX, cmisObject.getName(), action.name())); + Assert.assertTrue(cmisObject.hasAllowableAction(action), String.format("Object %s does not have action %s", cmisObject.getName(), action.name())); + } + return cmisAPI(); + } + + /** + * Check if {@link #getLastResource()} object has actions returned + * from {@link org.apache.chemistry.opencmis.client.api.CmisObject#getAllowableActions()} + * + * @param actions + * @return + */ + public CmisWrapper isAllowableActionInList(Action... actions) + { + List currentActions = cmisAPI().withCMISUtil().getAllowableActions(); + for (Action action : actions) + { + STEP(String.format("%s Verify that action '%s' exists", CmisWrapper.STEP_PREFIX, action.name())); + Assert.assertTrue(currentActions.contains(action), String.format("Action %s was found", action.name())); + } + return cmisAPI(); + } + + /** + * Check if the {@link #getLastResource()) does not have the list of {@link Action} Example: + * {code} + * .doesNotHaveAllowableActions(Action.CAN_CREATE_FOLDER); + * {code} + * + * @param actions + * @return + */ + public CmisWrapper doesNotHaveAllowableActions(Action... actions) + { + CmisObject cmisObject = cmisAPI().withCMISUtil().getCmisObject(cmisAPI().getLastResource()); + for (Action action : actions) + { + STEP(String.format("%s Verify if object %s does not have allowable action %s", CmisWrapper.STEP_PREFIX, cmisObject.getName(), action.name())); + Assert.assertFalse(cmisObject.hasAllowableAction(action), String.format("Object %s does not have action %s", cmisObject.getName(), action.name())); + } + return cmisAPI(); + } + + /** + * Verify document content + * + * @param content String expected content + * @return + * @throws Exception + */ + public CmisWrapper contentIs(String content) throws Exception + { + STEP(String.format("%s Verify if content '%s' is the expected one", CmisWrapper.STEP_PREFIX, content)); + Assert.assertEquals(cmisAPI().withCMISUtil().getDocumentContent(), content, + String.format("The content of file %s - is the expected one", cmisAPI().getLastResource())); + return cmisAPI(); + } + + /** + * Verify document content contains specific details + * + * @param content String expected content + * @return + * @throws Exception + */ + public CmisWrapper contentContains(String content) throws Exception + { + STEP(String.format("%s Verify if content '%s' is the expected one", CmisWrapper.STEP_PREFIX, content)); + Assert.assertTrue(cmisAPI().withCMISUtil().getDocumentContent().contains(content), + String.format("The content of file %s - is the expected one", cmisAPI().getLastResource())); + return cmisAPI(); + } + + /** + * Verify if current resource has the id given + * + * @param id - expected object id + * @return + */ + public CmisWrapper objectIdIs(String id) + { + CmisObject objSource = cmisAPI().withCMISUtil().getCmisObject(cmisAPI().getLastResource()); + STEP(String.format("%s Verify if '%s' object has '%s' id", CmisWrapper.STEP_PREFIX, objSource.getName(), id)); + Assert.assertEquals(objSource.getId(), id, "Object has id."); + return cmisAPI(); + } + + /** + * Verify the value of the given property + * + * @param property - the property id + * @param value - expected property value + * @return + */ + public CmisWrapper contentPropertyHasValue(String property, String value) + { + CmisObject objSource = cmisAPI().withCMISUtil().getCmisObject(cmisAPI().getLastResource()); + STEP(String.format("%s Verify if '%s' property for '%s' content has '%s' value", CmisWrapper.STEP_PREFIX, property, objSource.getName(), value)); + Object propertyValue = objSource.getPropertyValue(property); + if (propertyValue instanceof ArrayList) + { + @SuppressWarnings({ "unchecked", "rawtypes" }) + ArrayList values = (ArrayList) propertyValue; + Assert.assertEquals(values.get(0).toString(), value, "Property has value."); + } + else + { + Assert.assertEquals(propertyValue.toString(), value, "Property has value."); + } + return cmisAPI(); + } + + /** + * Verify if {@link Document} is checked out + * + * @return + */ + public CmisWrapper documentIsCheckedOut() + { + Document document = cmisAPI().withCMISUtil().getCmisDocument(cmisAPI().getLastResource()); + STEP(String.format("%s Verify if document '%s' is checked out", CmisWrapper.STEP_PREFIX, document.getName())); + Assert.assertTrue(document.isVersionSeriesCheckedOut(), "Document is checkedout"); + return cmisAPI(); + } + + /** + * Verify if {@link Document} is private working copy (pwc) + * + * @return + */ + public CmisWrapper isPrivateWorkingCopy() + { + Document document = cmisAPI().withCMISUtil().getCmisDocument(cmisAPI().getLastResource()); + STEP(String.format("%s Verify if document '%s' is private working copy", CmisWrapper.STEP_PREFIX, document.getName())); + Assert.assertTrue(cmisAPI().withCMISUtil().isPrivateWorkingCopy()); + return cmisAPI(); + } + + /** + * Verify that {@link Document} is not private working copy (pwc) + * + * @return + */ + public CmisWrapper isNotPrivateWorkingCopy() + { + Document document = cmisAPI().withCMISUtil().getCmisDocument(cmisAPI().getLastResource()); + STEP(String.format("%s Verify if document '%s' PWC is not private working copy", CmisWrapper.STEP_PREFIX, document.getName())); + Assert.assertFalse(cmisAPI().withCMISUtil().isPrivateWorkingCopy()); + return cmisAPI(); + } + + /** + * Verify that {@link Document} is not checked out + * + * @return + */ + public CmisWrapper documentIsNotCheckedOut() + { + Document document = cmisAPI().withCMISUtil().getCmisDocument(cmisAPI().getLastResource()); + STEP(String.format("%s Verify if document '%s' is not checked out", CmisWrapper.STEP_PREFIX, document.getName())); + Assert.assertFalse(document.isVersionSeriesCheckedOut(), "Document is not checked out"); + return cmisAPI(); + } + + /** + * Verify if there is a relationship between current resource and the given target + * + * @param targetContent + * @return + */ + public CmisWrapper objectHasRelationshipWith(ContentModel targetContent) + { + OperationContext oc = new OperationContextImpl(); + oc.setIncludeRelationships(IncludeRelationships.SOURCE); + + CmisObject source = cmisAPI().withCMISUtil().getCmisObject(cmisAPI().getLastResource(), oc); + CmisObject target = cmisAPI().withCMISUtil().getCmisObject(targetContent.getCmisLocation()); + + STEP(String.format("%s Verify if source '%s' has relationship with '%s'", CmisWrapper.STEP_PREFIX, source.getName(), target.getName())); + List relTargetIds = new ArrayList<>(); + for (Relationship rel : source.getRelationships()) + { + relTargetIds.add(rel.getTarget().getId()); + } + Assert.assertTrue(relTargetIds.contains(target.getId()), + String.format("Relationship is created between source '%s' and target '%s'.", source.getName(), target.getName())); + return cmisAPI(); + } + + /** + * Verify document has version + * + * @param version String expected version + * @return + * @throws Exception + */ + public CmisWrapper documentHasVersion(double version) throws Exception + { + Document document = cmisAPI().withCMISUtil().getCmisDocument(cmisAPI().getLastResource()); + document.refresh(); + STEP(String.format("%s Verify if document '%s' has version '%s'", CmisWrapper.STEP_PREFIX, document.getName(), version)); + Assert.assertEquals(Double.parseDouble(document.getVersionLabel()), version, "File has version"); + return cmisAPI(); + } + + /** + * Verify parent from the {@link Folder} set as last resource + * + * @param contentModel + * @return + */ + public CmisWrapper folderHasParent(ContentModel contentModel) + { + STEP(String.format("%s Verify folder %s has parent %s", CmisWrapper.STEP_PREFIX, cmisAPI().getLastResource(), contentModel.getName())); + Assert.assertEquals(cmisAPI().withCMISUtil().getFolderParent().getName(), contentModel.getName(), "Folder name is not the expected one"); + return cmisAPI(); + } + + /** + * Verify base type id + * + * @param baseTypeId String expected object type value + * @return + * @throws Exception + */ + public CmisWrapper baseTypeIdIs(String baseTypeId) throws Exception + { + STEP(String.format("%s Verify if base object type '%s' is the expected one", CmisWrapper.STEP_PREFIX, baseTypeId)); + String actualBaseTypeIdValue = cmisAPI().withCMISUtil().getCmisObject(cmisAPI().getLastResource()).getType().getBaseTypeId().value(); + Assert.assertEquals(actualBaseTypeIdValue, baseTypeId, "Object type is the expected one"); + return cmisAPI(); + } + + /** + * Verify object type id + * + * @param objectTypeId String expected object type value + * @return + * @throws Exception + */ + public CmisWrapper objectTypeIdIs(String objectTypeId) throws Exception + { + STEP(String.format("%s Verify if object type id '%s' is the expected one", CmisWrapper.STEP_PREFIX, objectTypeId)); + String typeId = cmisAPI().withCMISUtil().getCmisObject(cmisAPI().getLastResource()).getType().getId(); + if (StringUtils.isEmpty(typeId)) + { + typeId = ""; + } + Assert.assertEquals(cmisAPI().withCMISUtil().getCmisObject(cmisAPI().getLastResource()).getType().getId(), objectTypeId, + "Object type id is the expected one"); + return cmisAPI(); + } + + /** + * Verify a specific object property + * + * @param propertyId + * @param value + * @return + */ + public CmisWrapper objectHasProperty(String propertyId, Object value) + { + CmisObject cmisObject = cmisAPI().withCMISUtil().getCmisObject(cmisAPI().getLastResource()); + STEP(String.format("%s Verify if object %s has property %s ", CmisWrapper.STEP_PREFIX, cmisObject.getName(), propertyId)); + Property property = cmisAPI().withCMISUtil().getProperty(propertyId); + Object propValue = property.getValue(); + if(propValue instanceof GregorianCalendar) + { + Date date = (Date) value; + long longDate = date.getTime(); + long actualDate = ((GregorianCalendar) propValue).getTimeInMillis(); + Assert.assertEquals(actualDate, longDate); + } + else + { + if (propValue == null) + { + propValue = ""; + } + Assert.assertEquals(property.getValue().toString(), value.toString(), String.format("Found property value %s", value)); + } + return cmisAPI(); + } + + /** + * Check if CMIS object contains a property. + * Example: + * ...assertObjectHasProperty("cmis:secondaryObjectTypeIds", "Secondary Object Type Ids","secondaryObjectTypeIds", "cmis:secondaryObjectTypeIds", + * "P:cm:titled", "P:sys:localized"); + * + * @param propertyId + * @param displayName + * @param localName + * @param queryName + * @param values + * @return + */ + public CmisWrapper objectHasProperty(String propertyId, String displayName, String localName, String queryName, String... values) + { + CmisObject cmisObject = cmisAPI().withCMISUtil().getCmisObject(cmisAPI().getLastResource()); + STEP(String.format("%s Verify if object %s has property %s ", CmisWrapper.STEP_PREFIX, cmisObject.getName(), propertyId)); + Property property = cmisAPI().withCMISUtil().getProperty(propertyId); + if (property != null) + { + Assert.assertEquals(property.getDisplayName(), displayName, "Property displayName"); + Assert.assertEquals(property.getLocalName(), localName, "Property localName"); + Assert.assertEquals(property.getQueryName(), queryName, "Property queryName"); + for (String value : values) + { + Assert.assertTrue(property.getValues().contains(value), "Property value"); + } + } + else + { + Assert.assertFalse(false, String.format("Object %s does not have property %s", cmisObject.getName(), propertyId)); + } + return cmisAPI(); + } + + /** + * Assert if the {@link #getLastResource()) has the latest major version set + */ + public CmisWrapper isLatestMajorVersion() + { + String path = cmisAPI().getLastResource(); + STEP(String.format("%s Verify that document from '%s' is latest major version", CmisWrapper.STEP_PREFIX, path)); + Assert.assertTrue(cmisAPI().withCMISUtil().getCmisDocument(path).isLatestMajorVersion(), String.format("Document from %s is last major version", path)); + return cmisAPI(); + } + + /** + * Verify that {@link Document} is not latest major version. + * + * @return + */ + public CmisWrapper isNotLatestMajorVersion() + { + String path = cmisAPI().getLastResource(); + STEP(String.format("%s Verify that document from '%s' is not latest major version", CmisWrapper.STEP_PREFIX, path)); + Assert.assertFalse(cmisAPI().withCMISUtil().getCmisDocument(path).isLatestMajorVersion(), + String.format("Document from %s is last major version", path)); + return cmisAPI(); + } + + /** + * Verify that renditions are available + */ + public CmisWrapper renditionIsAvailable() + { + STEP(String.format("%s Verify if renditions are available for %s", CmisWrapper.STEP_PREFIX, cmisAPI().getLastResource())); + List renditions = cmisAPI().withCMISUtil().getRenditions(); + Assert.assertTrue(renditions != null && !renditions.isEmpty()); + return cmisAPI(); + } + + /** + * Verify that thumbnail rendition is available + * + * @return + */ + public CmisWrapper thumbnailRenditionIsAvailable() + { + boolean found = false; + STEP(String.format("%s Verify if thumbnail rendition is available for %s", CmisWrapper.STEP_PREFIX, cmisAPI().getLastResource())); + List renditions = cmisAPI().withCMISUtil().getRenditions(); + for (Rendition rendition : renditions) + { + if (rendition.getKind().equals("cmis:thumbnail")) + { + found = true; + } + } + Assert.assertTrue(found, String.format("Thumbnail rendition found for", cmisAPI().getLastResource())); + return cmisAPI(); + } + + private boolean isSecondaryTypeAvailable(String secondaryTypeId) + { + boolean found = false; + List secondaryTypes = cmisAPI().withCMISUtil().getSecondaryTypes(); + for (SecondaryType type : secondaryTypes) + { + if (type.getId().equals(secondaryTypeId)) + { + found = true; + break; + } + } + + return found; + } + + /** + * Verify secondary type for specific {@link CmisObject} + * + * @param secondaryTypeId + * @return + */ + public CmisWrapper secondaryTypeIsAvailable(String secondaryTypeId) + { + STEP(String.format("%s Verify if '%s' secondary type is available for '%s'", CmisWrapper.STEP_PREFIX, secondaryTypeId, + new File(cmisAPI().getLastResource()).getName())); + Assert.assertTrue(isSecondaryTypeAvailable(secondaryTypeId), String.format("%s is available for %s", secondaryTypeId, cmisAPI().getLastResource())); + return cmisAPI(); + } + + /** + * Verify secondary type is not available for specific {@link CmisObject} + * + * @param secondaryTypeId + * @return + */ + public CmisWrapper secondaryTypeIsNotAvailable(String secondaryTypeId) + { + STEP(String.format("%s Verify if '%s' aspect is NOT available for %s", CmisWrapper.STEP_PREFIX, secondaryTypeId, cmisAPI().getLastResource())); + Assert.assertFalse(isSecondaryTypeAvailable(secondaryTypeId), + String.format("%s is NOT available for %s", secondaryTypeId, cmisAPI().getLastResource())); + return cmisAPI(); + } + + /** + * Verify document content length + * + * @param contentLength String expected content length + * @return + * @throws Exception + */ + public CmisWrapper contentLengthIs(long contentLength) throws Exception + { + STEP(String.format("%s Verify if content length '%s' is the expected one", CmisWrapper.STEP_PREFIX, contentLength)); + Document lastVersion = cmisAPI().withCMISUtil().getCmisDocument(cmisAPI().getLastResource()); + lastVersion.refresh(); + Assert.assertEquals(lastVersion.getContentStreamLength(), contentLength, "File content is the expected one"); + return cmisAPI(); + } + + /** + * e.g. assertFolderHasDescendant(1, file1) will verify if file1 is a direct descendant of {@link #getLastResource()} + * + * @param depth {@link #getFolderDescendants(int)} + * @param contentModels {@link #getCmisObjectsFromContentModels(ContentModel...)} + */ + public void hasDescendants(int depth, ContentModel... contentModels) + { + STEP(String.format("%s Assert that folder %s has descendants in depth %d:", STEP_PREFIX, getProtocol().getLastResource(), depth)); + CmisObject currentCmisObject = getProtocol().withCMISUtil().getCmisObject(getProtocol().getLastResource()); + List cmisObjects = getProtocol().withCMISUtil().getCmisObjectsFromContentModels(contentModels); + List folderDescendants = getProtocol().withCMISUtil().getFolderDescendants(depth); + for (CmisObject cmisObject : cmisObjects) + { + boolean found = false; + STEP(String.format("%s Verify that folder '%s' has descendant %s", CmisWrapper.STEP_PREFIX, currentCmisObject.getName(), cmisObject.getName())); + for (CmisObject folderDescendant : folderDescendants) + if (folderDescendant.getId().equals(cmisObject.getId())) + { + found = true; + break; + } + Assert.assertTrue(found, String.format("Folder %s does not have descendant %s", currentCmisObject.getName(), cmisObject)); + } + } + + public void doesNotHaveDescendants(int depth) + { + STEP(String.format("%s Assert that folder %s does not have descendants in depth %d:", STEP_PREFIX, getProtocol().getLastResource(), depth)); + CmisObject currentCmisObject = getProtocol().withCMISUtil().getCmisObject(getProtocol().getLastResource()); + List folderDescendants = getProtocol().withCMISUtil().getFolderDescendants(depth); + Assert.assertTrue(folderDescendants.isEmpty(), String.format("Folder %s should not have descendants", currentCmisObject.getName())); + } + + /** + * Verify that {@link CmisObject} has ACLs (Access Control Lists) + * + * @return + */ + public CmisWrapper hasAcls() + { + STEP(String.format("%s Verify that %s has acls", CmisWrapper.STEP_PREFIX, cmisAPI().getLastResource())); + String path = cmisAPI().getLastResource(); + STEP(String.format("%s Get Acls for %s", CmisWrapper.STEP_PREFIX, path)); + Assert.assertNotNull(cmisAPI().withCMISUtil().getAcls(), String.format("Acls found for %s", path)); + return cmisAPI(); + } + + /** + * Depending on the specified depth, checks that all the contents from contentModels list are present in the current folder tree structure + * + * @param depth the depth of the tree to check, must be -1 or >= 1 + * @param contentModels expected list of contents to be found in the tree + * @return + */ + public CmisWrapper hasFolderTree(int depth, ContentModel... contentModels) + { + CmisObject currentCmisObject = getProtocol().withCMISUtil().getCmisObject(getProtocol().getLastResource()); + List cmisObjects = getProtocol().withCMISUtil().getCmisObjectsFromContentModels(contentModels); + List folderDescendants = getProtocol().withCMISUtil().getFolderTree(depth); + for (CmisObject cmisObject : cmisObjects) + { + boolean found = false; + STEP(String.format("%s Verify that folder '%s' has folder tree %s", CmisWrapper.STEP_PREFIX, currentCmisObject.getName(), cmisObject.getName())); + for (CmisObject folderDescendant : folderDescendants) + if (folderDescendant.getId().equals(cmisObject.getId())) + found = true; + Assert.assertTrue(found, String.format("Folder %s does not have folder tree %s", currentCmisObject.getName(), cmisObject)); + } + return cmisAPI(); + } + + /** + * Verify the permission for a specific user from the last resource object + * + * @param userModel {@link UserModel} user to verify + * @param role {@link UserRole} user role to verify + * @return + */ + public CmisWrapper permissionIsSetForUser(UserModel userModel, UserRole role) + { + STEP(String.format("%s Verify that user %s has role %s set to content %s", CmisWrapper.STEP_PREFIX, userModel.getUsername(), role.name(), + cmisAPI().getLastResource())); + Assert.assertTrue(checkPermission(userModel.getUsername(), role.getRoleId()), + String.format("User %s has permission %s", userModel.getUsername(), role.name())); + return cmisAPI(); + } + + /** + * Verify the permission for a specific group of users from the last resource object + * + * @param groupModel {@link GroupModel} group to verify + * @param role {@link UserRole} user role to verify + * @return + */ + public CmisWrapper permissionIsSetForGrup(GroupModel groupModel, UserRole role) + { + STEP(String.format("%s Verify that user %s has role %s set to content %s", CmisWrapper.STEP_PREFIX, groupModel.getDisplayName(), role.name(), + cmisAPI().getLastResource())); + Assert.assertTrue(checkPermission(groupModel.getDisplayName(), role.getRoleId()), + String.format("User %s has permission %s", groupModel.getDisplayName(), role.name())); + return cmisAPI(); + } + + private boolean checkPermission(String user, String permission) + { + Acl acl = cmisAPI().withCMISUtil().getAcls(); + if (acl == null) + { + throw new CmisRuntimeException(String.format("No acls returned for '%s'", cmisAPI().getLastResource())); + } + List aces = acl.getAces(); + boolean found = false; + for (Ace ace : aces) + { + if (ace.getPrincipalId().equals(user) && ace.getPermissions().get(0).equals(permission)) + { + found = true; + break; + } + } + return found; + } + + /** + * Verify the permission for a specific user from the last resource object + * + * @param userModel {@link UserModel} + * @param permission to verify + * @return + */ + public CmisWrapper permissionIsSetForUser(UserModel userModel, String permission) + { + STEP(String.format("%s Verify that user %s has role %s set to content %s", CmisWrapper.STEP_PREFIX, userModel.getUsername(), permission, + cmisAPI().getLastResource())); + Assert.assertTrue(checkPermission(userModel.getUsername(), permission), + String.format("User %s has permission %s", userModel.getUsername(), permission)); + return cmisAPI(); + } + + /** + * Verify that permission is not set for a specific user from the last resource object + * + * @param userModel {@link UserModel} user to verify + * @param role {@link UserRole} user role to verify + * @return + */ + public CmisWrapper permissionIsNotSetForUser(UserModel userModel, UserRole role) + { + STEP(String.format("%s Verify that user %s doesn't have role %s set to content %s", CmisWrapper.STEP_PREFIX, userModel.getUsername(), role.name(), + cmisAPI().getLastResource())); + Assert.assertFalse(checkPermission(userModel.getUsername(), role.getRoleId()), + String.format("User %s has permission %s", userModel.getUsername(), role.name())); + return cmisAPI(); + } + + /** + * Verify that permission is not set for a specific user from the last resource object + * + * @param userModel {@link UserModel} user to verify + * @param permission to verify + * @return + */ + public CmisWrapper permissionIsNotSetForUser(UserModel userModel, String permission) + { + STEP(String.format("%s Verify that user %s doesn't have permission %s set to content %s", CmisWrapper.STEP_PREFIX, userModel.getUsername(), permission, + cmisAPI().getLastResource())); + Assert.assertFalse(checkPermission(userModel.getUsername(), permission), + String.format("User %s has permission %s", userModel.getUsername(), permission)); + return cmisAPI(); + } + + public CmisWrapper typeDefinitionIs(ContentModel contentModel) + { + CmisObject cmisObject = cmisAPI().withCMISUtil().getCmisObject(contentModel.getCmisLocation()); + STEP(String.format("%s Verify that object '%s' type definition matches '%s' type definition", CmisWrapper.STEP_PREFIX, cmisObject.getName(), + cmisAPI().withCMISUtil().getTypeDefinition().getId())); + Assert.assertTrue(cmisAPI().withCMISUtil().getTypeDefinition().equals(cmisObject.getType()), String.format( + "Object '%s' type definition does not match '%s' type definition", cmisObject.getName(), cmisAPI().withCMISUtil().getTypeDefinition().getId())); + return cmisAPI(); + } + + /** + * Verify that a specific folder(set by calling {@link org.alfresco.cmis.CmisWrapper#usingResource(ContentModel)}) + * contains checked out documents + * + * @param contentModels checked out documents to verify + * @return + */ + public CmisWrapper folderHasCheckedOutDocument(ContentModel... contentModels) + { + List cmisObjectList = cmisAPI().withCMISUtil().getCmisObjectsFromContentModels(contentModels); + List cmisCheckedOutDocuments = cmisAPI().withCMISUtil().getCheckedOutDocumentsFromFolder(); + for (CmisObject cmisObject : cmisObjectList) + { + Assert.assertTrue(cmisAPI().withCMISUtil().isCmisObjectContainedInCmisCheckedOutDocumentsList(cmisObject, cmisCheckedOutDocuments), + String.format("Folder %s does not contain checked out document %s", cmisAPI().getLastResource(), cmisObject)); + } + return cmisAPI(); + } + + /** + * Verify that a specific folder(set by calling {@link org.alfresco.cmis.CmisWrapper#usingResource(ContentModel)}) + * contains checked out documents in a specific order. + * + * @param context {@link OperationContext} + * @param contentModels documents to verify in the order returned by the {@link OperationContext} + * @return + */ + public CmisWrapper folderHasCheckedOutDocument(OperationContext context, ContentModel... contentModels) + { + List cmisObjectList = cmisAPI().withCMISUtil().getCmisObjectsFromContentModels(contentModels); + List cmisCheckedOutDocuments = cmisAPI().withCMISUtil().getCheckedOutDocumentsFromFolder(context); + for (int i = 0; i < cmisObjectList.size(); i++) + { + Assert.assertEquals(cmisObjectList.get(i).getId().split(";")[0], cmisCheckedOutDocuments.get(i).getId().split(";")[0], + String.format("Folder %s does not contain checked out document %s", cmisAPI().getLastResource(), cmisObjectList.get(i).getName())); + } + return cmisAPI(); + } + + /** + * Verify checked out documents from {@link Session} + * + * @param contentModels documents to verify + * @return + */ + public CmisWrapper sessionHasCheckedOutDocument(ContentModel... contentModels) + { + List cmisObjectList = cmisAPI().withCMISUtil().getCmisObjectsFromContentModels(contentModels); + List cmisCheckedOutDocuments = cmisAPI().withCMISUtil().getCheckedOutDocumentsFromSession(); + for (CmisObject cmisObject : cmisObjectList) + { + Assert.assertTrue(cmisAPI().withCMISUtil().isCmisObjectContainedInCmisCheckedOutDocumentsList(cmisObject, cmisCheckedOutDocuments), + String.format("Session does not contain checked out document %s", cmisObject)); + } + return cmisAPI(); + } + + /** + * Verify checked out documents from {@link Session} in a specific order set in {@link OperationContext} + * + * @param context {@link OperationContext} + * @param contentModels documents to verify + * @return + */ + public CmisWrapper sessionHasCheckedOutDocument(OperationContext context, ContentModel... contentModels) + { + List cmisObjectList = cmisAPI().withCMISUtil().getCmisObjectsFromContentModels(contentModels); + List cmisCheckedOutDocuments = cmisAPI().withCMISUtil().getCheckedOutDocumentsFromSession(context); + for (int i = 0; i < cmisObjectList.size(); i++) + { + Assert.assertEquals(cmisObjectList.get(i).getId().split(";")[0], cmisCheckedOutDocuments.get(i).getId().split(";")[0], + String.format("Session does not contain checked out document %s", cmisObjectList.get(i).getName())); + } + return cmisAPI(); + } + + /** + * Verify that checked out documents are not found in {@link Session} + * + * @param contentModels documents to verify + * @return + */ + public CmisWrapper sessioDoesNotHaveCheckedOutDocument(ContentModel... contentModels) + { + List cmisObjectList = cmisAPI().withCMISUtil().getCmisObjectsFromContentModels(contentModels); + List cmisCheckedOutDocuments = cmisAPI().withCMISUtil().getCheckedOutDocumentsFromSession(); + for (CmisObject cmisObject : cmisObjectList) + { + Assert.assertFalse(cmisAPI().withCMISUtil().isCmisObjectContainedInCmisCheckedOutDocumentsList(cmisObject, cmisCheckedOutDocuments), + String.format("Session does contain checked out document %s", cmisObject)); + } + return cmisAPI(); + } + + /** + * Verify that {@link CmisObject} has a specific aspect extension + * + * @param aspectId + * @return + */ + public CmisWrapper hasAspectExtension(String aspectId) + { + STEP(String.format("Verify that aspect %s is applied to %s", aspectId, cmisAPI().getLastResource())); + boolean found = false; + List extensions = cmisAPI().withCMISUtil().getCmisObject(cmisAPI().getLastResource()).getExtensions(ExtensionLevel.PROPERTIES); + for (CmisExtensionElement extElement : extensions) + { + if (extElement.getName().equals("aspects")) + { + List aspects = extElement.getChildren(); + for (CmisExtensionElement aspect : aspects) + { + if (aspect.getValue() != null) + { + if (aspect.getValue().equals(aspectId)) + { + found = true; + } + } + } + } + } + Assert.assertTrue(found, String.format("Aspect extension %s for %s was found", aspectId, cmisAPI().getLastResource())); + return cmisAPI(); + } + + /** + * Verify the parents for a {@link CmisObject} + * + * @param parentsList + * @return + */ + public CmisWrapper hasParents(String... parentsList) + { + List folderNames = new ArrayList<>(); + List parents = new ArrayList<>(); + String source = cmisAPI().getLastResource(); + CmisObject objSource = cmisAPI().withCMISUtil().getCmisObject(source); + STEP(String.format("%s Verify the parents for '%s'.", CmisWrapper.STEP_PREFIX, objSource.getName())); + if (objSource instanceof Document) + { + Document d = (Document) objSource; + parents = d.getParents(); + } + else if (objSource instanceof Folder) + { + Folder f = (Folder) objSource; + parents = f.getParents(); + } + for (Folder folder : parents) + { + folderNames.add(folder.getName()); + } + Assert.assertEqualsNoOrder(folderNames.toArray(), parentsList, "Parents list is the expected one."); + return cmisAPI(); + } + + public CmisWrapper descriptionIs(String description) + { + String source = cmisAPI().getLastResource(); + STEP(String.format("%s Verify object '%s' description is '%s'", CmisWrapper.STEP_PREFIX, source, description)); + CmisObject cmisObject = cmisAPI().withCMISUtil().getCmisObject(source); + Assert.assertEquals(description, cmisObject.getDescription()); + return cmisAPI(); + } + + /** + * Verify if folder children exist in parent folder + * + * @param fileModel children files + * @return + * @throws Exception + */ + public CmisWrapper hasFolders(FolderModel... folderModel) throws Exception + { + String currentSpace = cmisAPI().getCurrentSpace(); + List folders = cmisAPI().getFolders(); + for (FolderModel folder : folderModel) + { + STEP(String.format("%s Verify that folder %s is in %s", CmisWrapper.STEP_PREFIX, folder.getName(), currentSpace)); + Assert.assertTrue(cmisAPI().withCMISUtil().isFolderInList(folder, folders), String.format("Folder %s is in %s", folder.getName(), currentSpace)); + } + return cmisAPI(); + } + + /** + * Verify if file children exist in parent folder + * + * @param fileModel children files + * @return + * @throws Exception + */ + public CmisWrapper hasFiles(FileModel... fileModel) throws Exception + { + String currentSpace = cmisAPI().getLastResource(); + List files = cmisAPI().getFiles(); + for (FileModel file : fileModel) + { + STEP(String.format("%s Verify that file '%s' is in '%s'", CmisWrapper.STEP_PREFIX, file.getName(), currentSpace)); + Assert.assertTrue(cmisAPI().withCMISUtil().isFileInList(file, files), String.format("File %s is in %s", file.getName(), currentSpace)); + } + return cmisAPI(); + } + + /** + * Verify if file(s) children exist in parent folder + * + * @param fileModels children files + * @return + * @throws Exception + */ + public CmisWrapper doesNotHaveFile(FileModel... fileModels) throws Exception + { + String currentSpace = cmisAPI().getLastResource(); + List files = cmisAPI().getFiles(); + for (FileModel fileModel : fileModels) + { + STEP(String.format("%s Verify that file '%s' is not in '%s'", CmisWrapper.STEP_PREFIX, fileModel.getName(), currentSpace)); + Assert.assertFalse(cmisAPI().withCMISUtil().isFileInList(fileModel, files), String.format("File %s is in %s", fileModel.getName(), currentSpace)); + } + return cmisAPI(); + } + + /** + * Verify if folder(s) children exist in parent folder + * + * @param folderModels children files + * @return + * @throws Exception + */ + public CmisWrapper doesNotHaveFolder(FolderModel... folderModels) throws Exception + { + String currentSpace = cmisAPI().getLastResource(); + List folders = cmisAPI().getFolders(); + for (FolderModel folderModel : folderModels) + { + STEP(String.format("%s Verify that folder '%s' is not in '%s'", CmisWrapper.STEP_PREFIX, folderModel.getName(), currentSpace)); + Assert.assertFalse(cmisAPI().withCMISUtil().isFolderInList(folderModel, folders), + String.format("File %s is in %s", folderModel.getName(), currentSpace)); + } + return cmisAPI(); + } + + /** + * Verify the children(files and folders) from a parent folder + * + * @param contentModel children + * @return + * @throws Exception + */ + public CmisWrapper hasChildren(ContentModel... contentModel) throws Exception + { + String currentSpace = cmisAPI().getCurrentSpace(); + Map mapContents = cmisAPI().withCMISUtil().getChildren(); + List contents = new ArrayList(); + for (Map.Entry entry : mapContents.entrySet()) + { + contents.add(entry.getKey()); + } + for (ContentModel content : contentModel) + { + STEP(String.format("%s Verify that file %s is in %s", CmisWrapper.STEP_PREFIX, content.getName(), currentSpace)); + Assert.assertTrue(cmisAPI().withCMISUtil().isContentInList(content, contents), + String.format("Content %s is in %s", content.getName(), currentSpace)); + } + return cmisAPI(); + } + + + public CmisWrapper hasUniqueChildren(int numberOfChildren) throws Exception + { + STEP(String.format("%s Verify that current folder has %d unique children", CmisWrapper.STEP_PREFIX, numberOfChildren)); + Map mapContents = cmisAPI().withCMISUtil().getChildren(); + + Set documentIds = new HashSet(); + for (ContentModel key : mapContents.keySet()) + { + documentIds.add(key.getName()); + } + Assert.assertTrue(numberOfChildren==documentIds.size(), String.format("Current folder contains %d unique children, but expected is %d", documentIds.size(), numberOfChildren)); + return cmisAPI(); + } + + /** + * Get check in comment for last document version + * + * @param comment to verify + * @return + */ + public CmisWrapper hasCheckInCommentLastVersion(String comment) + { + String source = cmisAPI().getLastResource(); + STEP(String.format("%s Verify check in comment for last version of %s", CmisWrapper.STEP_PREFIX, source)); + Document document = cmisAPI().withCMISUtil().getCmisDocument(source); + Assert.assertEquals(comment, document.getCheckinComment(), String.format("Document %s has check in comment %s", document.getName(), comment)); + return cmisAPI(); + } + + /** + * Get check in comment for a specific document version + * + * @param documentVersion version of document + * @param comment to verify + * @return + */ + public CmisWrapper hasCheckInCommentForVersion(double documentVersion, String comment) + { + String source = cmisAPI().getLastResource(); + STEP(String.format("%s Verify check in comment for version %s of %s", CmisWrapper.STEP_PREFIX, documentVersion, source)); + String documentId = cmisAPI().withCMISUtil().getObjectId(source).split(";")[0]; + documentId = documentId + ";" + documentVersion; + Document document = (Document) cmisAPI().withCMISUtil().getCmisObjectById(documentId); + Assert.assertEquals(comment, document.getCheckinComment(), String.format("Document %s has check in comment %s", document.getName(), comment)); + return cmisAPI(); + } + + /** + * Verify failed deleted objects after delete tree action + * + * @param nodeRef objects to verify + * @return + */ + public CmisWrapper hasFailedDeletedObject(String nodeRef) + { + STEP(String.format("%s Verify failed deleted object from %s", CmisWrapper.STEP_PREFIX, cmisAPI().getLastResource())); + Assert.assertTrue(cmisAPI().deleteTreeFailedObjects.contains(nodeRef), String.format("Object %s found after delete", nodeRef)); + return cmisAPI(); + } + + /** + * Verify if there is a relationship between current resource and the given target + * + * @param user + * @return + */ + public CmisWrapper userIsAssigned(UserModel user) + { + OperationContext oc = new OperationContextImpl(); + oc.setIncludeRelationships(IncludeRelationships.SOURCE); + CmisObject source = cmisAPI().withCMISUtil().getCmisObject(cmisAPI().getLastResource(), oc); + String userNodeRef = cmisAPI().withCMISUtil().getUserNodeRef(user); + + STEP(String.format("%s Verify if user '%s' has relationship with '%s'", CmisWrapper.STEP_PREFIX, user.getUsername(), source.getName())); + List relTargetIds = new ArrayList<>(); + for (Relationship rel : source.getRelationships()) + { + relTargetIds.add(rel.getTarget().getId()); + } + Assert.assertTrue(relTargetIds.contains(userNodeRef), + String.format("Relationship is created between source '%s' and target '%s'.", source.getName(), user.getUsername())); + return cmisAPI(); + } +} diff --git a/e2e-test/src/main/java/org/alfresco/cmis/dsl/CmisUtil.java b/e2e-test/src/main/java/org/alfresco/cmis/dsl/CmisUtil.java new file mode 100644 index 000000000..d9176ad8e --- /dev/null +++ b/e2e-test/src/main/java/org/alfresco/cmis/dsl/CmisUtil.java @@ -0,0 +1,743 @@ +package org.alfresco.cmis.dsl; + +import static org.alfresco.utility.report.log.Step.STEP; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +import org.alfresco.cmis.CmisWrapper; +import org.alfresco.cmis.exception.InvalidCmisObjectException; +import org.alfresco.utility.LogFactory; +import org.alfresco.utility.Utility; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.model.ContentModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.GroupModel; +import org.alfresco.utility.model.UserModel; +import org.apache.chemistry.opencmis.client.api.CmisObject; +import org.apache.chemistry.opencmis.client.api.Document; +import org.apache.chemistry.opencmis.client.api.FileableCmisObject; +import org.apache.chemistry.opencmis.client.api.Folder; +import org.apache.chemistry.opencmis.client.api.ItemIterable; +import org.apache.chemistry.opencmis.client.api.ObjectType; +import org.apache.chemistry.opencmis.client.api.OperationContext; +import org.apache.chemistry.opencmis.client.api.Property; +import org.apache.chemistry.opencmis.client.api.QueryResult; +import org.apache.chemistry.opencmis.client.api.Rendition; +import org.apache.chemistry.opencmis.client.api.SecondaryType; +import org.apache.chemistry.opencmis.client.api.Tree; +import org.apache.chemistry.opencmis.commons.PropertyIds; +import org.apache.chemistry.opencmis.commons.data.Ace; +import org.apache.chemistry.opencmis.commons.data.Acl; +import org.apache.chemistry.opencmis.commons.data.AclCapabilities; +import org.apache.chemistry.opencmis.commons.data.ContentStream; +import org.apache.chemistry.opencmis.commons.data.PermissionMapping; +import org.apache.chemistry.opencmis.commons.data.PropertyData; +import org.apache.chemistry.opencmis.commons.data.RepositoryInfo; +import org.apache.chemistry.opencmis.commons.enums.Action; +import org.apache.chemistry.opencmis.commons.enums.BaseTypeId; +import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException; +import org.apache.chemistry.opencmis.commons.exceptions.CmisVersioningException; +import org.apache.commons.io.IOUtils; +import org.slf4j.Logger; +import org.testng.collections.Lists; + +/** + * DSL utility for managing CMIS objects + */ +public class CmisUtil +{ + private CmisWrapper cmisAPI; + private Logger LOG = LogFactory.getLogger(); + + public CmisUtil(CmisWrapper cmisAPI) + { + this.cmisAPI = cmisAPI; + } + + /** + * Get cmis object by object id + * + * @param objectId cmis object id + * @return CmisObject cmis object + */ + public CmisObject getCmisObjectById(String objectId) + { + LOG.debug("Get CMIS object by ID {}", objectId); + if (cmisAPI.getSession() == null) + { + throw new CmisRuntimeException("Please authenticate user, call: cmisAPI.authenticate(..)!"); + } + if (objectId == null) + { + throw new InvalidCmisObjectException("Invalid content id"); + } + return cmisAPI.getSession().getObject(objectId); + } + + /** + * Get cmis object by object id with OperationContext + * + * @param objectId cmis object id + * @param context OperationContext + * @return CmisObject cmis object + */ + public CmisObject getCmisObjectById(String objectId, OperationContext context) + { + if (cmisAPI.getSession() == null) + { + throw new CmisRuntimeException("Please authenticate user, call: cmisAPI.authenticate(..)!"); + } + if (objectId == null) + { + throw new InvalidCmisObjectException("Invalid content id"); + } + return cmisAPI.getSession().getObject(objectId, context); + } + + /** + * Get cmis object by path + * + * @param pathToItem String path to item + * @return CmisObject cmis object + */ + public CmisObject getCmisObject(String pathToItem) + { + if (cmisAPI.getSession() == null) + { + throw new CmisRuntimeException("Please authenticate user, call: cmisAPI.authenticate(..)!"); + } + if (pathToItem == null) + { + throw new InvalidCmisObjectException("Invalid path set for content"); + } + CmisObject cmisObject = cmisAPI.getSession().getObjectByPath(Utility.removeLastSlash(pathToItem)); + if (cmisObject instanceof Document) + { + if (!((Document) cmisObject).getVersionLabel().contentEquals("pwc")) + { + // get last version of document + cmisObject = ((Document) cmisObject).getObjectOfLatestVersion(false); + } + else + { + // get pwc document + cmisObject = cmisAPI.getSession().getObject(((Document) cmisObject).getObjectOfLatestVersion(false).getVersionSeriesCheckedOutId()); + } + } + return cmisObject; + } + + /** + * Get cmis object by path with context + * + * @param pathToItem String path to item + * @param context OperationContext + * @return CmisObject cmis object + */ + public CmisObject getCmisObject(String pathToItem, OperationContext context) + { + if (cmisAPI.getSession() == null) + { + throw new CmisRuntimeException("Please authenticate user!"); + } + if (pathToItem == null) + { + throw new InvalidCmisObjectException("Invalid path set for content"); + } + CmisObject cmisObject = cmisAPI.getSession().getObjectByPath(Utility.removeLastSlash(pathToItem), context); + if (cmisObject instanceof Document) + { + if (!((Document) cmisObject).getVersionLabel().contentEquals("pwc")) + { + // get last version of document + cmisObject = ((Document) cmisObject).getObjectOfLatestVersion(false, context); + } + else + { + // get pwc document + cmisObject = cmisAPI.getSession().getObject(((Document) cmisObject).getObjectOfLatestVersion(false, context).getVersionSeriesCheckedOutId()); + } + } + return cmisObject; + } + + /** + * Get Document object for a file + * + * @param path String path to document + * @return {@link Document} object + */ + public Document getCmisDocument(final String path) + { + LOG.debug("Get CMIS Document by path {}", path); + Document d = null; + CmisObject docObj = getCmisObject(path); + if (docObj instanceof Document) + { + d = (Document) docObj; + } + else if (docObj instanceof Folder) + { + throw new InvalidCmisObjectException("Content at " + path + " is not a file"); + } + return d; + } + + /** + * Get Folder object for a folder + * + * @param path String path to folder + * @return {@link Folder} object + */ + public Folder getCmisFolder(final String path) + { + Folder f = null; + CmisObject folderObj = getCmisObject(path); + if (folderObj instanceof Folder) + { + f = (Folder) folderObj; + } + else if (folderObj instanceof Document) + { + throw new InvalidCmisObjectException("Content at " + path + " is not a folder"); + } + return f; + } + + /** + * Helper method to get the contents of a stream + * + * @param stream + * @return + * @throws IOException + */ + protected String getContentAsString(ContentStream stream) throws Exception + { + LOG.debug("Get Content as String {}", stream); + InputStream inputStream = stream.getStream(); + String result = IOUtils.toString(inputStream, StandardCharsets.UTF_8); + IOUtils.closeQuietly(inputStream); + return result; + } + + /** + * Copy all the children of the source folder to the target folder + * + * @param sourceFolder + * @param targetFolder + */ + protected void copyChildrenFromFolder(Folder sourceFolder, Folder targetFolder) + { + for (Tree t : sourceFolder.getDescendants(-1)) + { + CmisObject obj = t.getItem(); + if (obj instanceof Document) + { + Document d = (Document) obj; + d.copy(targetFolder); + } + else if (obj instanceof Folder) + { + copyFolder((Folder) obj, targetFolder); + } + } + } + + /** + * Copy folder with all children + * + * @param sourceFolder source folder + * @param targetFolder target folder + * @return CmisObject of new created folder + */ + public CmisObject copyFolder(Folder sourceFolder, Folder targetFolder) + { + Map folderProperties = new HashMap(2); + folderProperties.put(PropertyIds.NAME, sourceFolder.getName()); + folderProperties.put(PropertyIds.OBJECT_TYPE_ID, sourceFolder.getBaseTypeId().value()); + Folder newFolder = targetFolder.createFolder(folderProperties); + copyChildrenFromFolder(sourceFolder, newFolder); + return newFolder; + } + + protected boolean isPrivateWorkingCopy() + { + boolean result = false; + try + { + result = getPWCDocument().isPrivateWorkingCopy(); + } + catch (CmisVersioningException cmisVersioningException) + { + result = false; + } + return result; + } + + /** + * Returns the PWC (private working copy) ID of the document version series + */ + public Document getPWCDocument() + { + Document document = getCmisDocument(cmisAPI.getLastResource()); + String pwcId = document.getVersionSeriesCheckedOutId(); + if (pwcId != null) + { + return (Document) cmisAPI.getSession().getObject(pwcId); + } + else + { + throw new CmisVersioningException(String.format("Document %s is not checked out", document.getName())); + } + } + + public FileModel getPWCFileModel() + { + Document document = getPWCDocument(); + String[] pathTokens = cmisAPI.getLastResource().split("/"); + String path = ""; + for (int i = 0; i < pathTokens.length - 1; i++) + path = Utility.buildPath(path, pathTokens[i]); + path = Utility.buildPath(path, document.getName()); + + FileModel fileModel = new FileModel(); + fileModel.setName(document.getName()); + fileModel.setCmisLocation(path); + return fileModel; + } + + protected Folder getFolderParent() + { + return getCmisFolder(cmisAPI.getLastResource()).getFolderParent(); + } + + /** + * @return List of allowable actions for the current object + */ + protected List getAllowableActions() + { + return Lists.newArrayList(getCmisObject(cmisAPI.getLastResource()).getAllowableActions().getAllowableActions()); + } + + /** + * Returns the requested property. If the property is not available, null is returned + * + * @param propertyId + * @return CMIS Property + */ + protected Property getProperty(String propertyId) + { + CmisObject cmisObject = getCmisObject(cmisAPI.getLastResource()); + return cmisObject.getProperty(propertyId); + } + + protected List getRenditions() + { + OperationContext operationContext = cmisAPI.getSession().createOperationContext(); + operationContext.setRenditionFilterString("*"); + CmisObject obj = cmisAPI.getSession().getObjectByPath(cmisAPI.getLastResource(), operationContext); + obj.refresh(); + List renditions = obj.getRenditions(); + int retry = 0; + while ((renditions == null || renditions.isEmpty()) && retry < Utility.retryCountSeconds) + { + Utility.waitToLoopTime(1); + obj.refresh(); + renditions = obj.getRenditions(); + retry++; + } + return obj.getRenditions(); + } + + protected List getSecondaryTypes() + { + CmisObject obj = getCmisObject(cmisAPI.getLastResource()); + obj.refresh(); + return obj.getSecondaryTypes(); + } + + /** + * Get the children from a parent folder + * + * @return Map + */ + public Map getChildren() + { + String folderParent = cmisAPI.getLastResource(); + ItemIterable children = cmisAPI.withCMISUtil().getCmisFolder(folderParent).getChildren(); + Map contents = new HashMap(); + for (CmisObject o : children) + { + ContentModel content = new ContentModel(o.getName()); + content.setNodeRef(o.getId()); + content.setDescription(o.getDescription()); + content.setCmisLocation(Utility.buildPath(folderParent, o.getName())); + contents.put(content, o.getType()); + } + return contents; + } + + /** + * Gets the folder descendants starting with the current folder + * + * @param depth level of the tree that you want to go to + * - currentFolder + * -- file1.txt + * -- file2.txt + * -- folderB + * --- file3.txt + * --- file4.txt + * e.g. A depth of 1 will give you just the current folder descendants (file1.txt, file2.txt, folder1) + * e.g. A depth of -1 will return all the descendants (file1.txt, file2.txt, folder1, file3.txt and file4.txt) + */ + public List getFolderDescendants(int depth) + { + return getFolderTreeCmisObjects(getCmisFolder(cmisAPI.getLastResource()).getDescendants(depth)); + } + + /** + * Returns a list of Cmis objects for the provided Content Models + * + * @param contentModels + */ + public List getCmisObjectsFromContentModels(ContentModel... contentModels) + { + List cmisObjects = new ArrayList<>(); + for (ContentModel contentModel : contentModels) + cmisObjects.add(getCmisObject(contentModel.getCmisLocation())); + return cmisObjects; + } + + public ContentStream getContentStream(String content) throws Exception + { + String fileName = getCmisDocument(cmisAPI.getLastResource()).getName(); + + return cmisAPI.getDataContentService().getContentStream(fileName, content); + } + + public Acl getAcls() + { + OperationContext context = cmisAPI.getSession().createOperationContext(); + context.setIncludeAcls(true); + return getCmisObject(cmisAPI.getLastResource(), context).getAcl(); + } + + /** + * Gets only the folder descendants for the {@link #getLastResource()} folder + * + * @param depth level of the tree that you want to go to + * - currentFolder + * -- folderB + * -- folderC + * --- folderD + * e.g. A depth of 1 will give you just the current folder descendants (folderB, folderC) + * e.g. A depth of -1 will return all the descendants (folderB, folderC, folderD) + */ + public List getFolderTree(int depth) + { + return getFolderTreeCmisObjects(getCmisFolder(cmisAPI.getLastResource()).getFolderTree(depth)); + } + + /** + * Helper method for getFolderTree and getFolderDescendants that cycles threw the folder descendants and returns List + */ + private List getFolderTreeCmisObjects(List> descendants) + { + List cmisObjectList = new ArrayList<>(); + for (Tree descendant : descendants) + { + cmisObjectList.add(descendant.getItem()); + cmisObjectList.addAll(descendant.getChildren().stream().map(Tree::getItem).collect(Collectors.toList())); + } + return cmisObjectList; + } + + protected List getAllDocumentVersions() + { + return getCmisDocument(cmisAPI.getLastResource()).getAllVersions(); + } + + public List getAllDocumentVersionsBy(OperationContext context) + { + return getCmisDocument(cmisAPI.getLastResource()).getAllVersions(context); + } + + public List getCheckedOutDocumentsFromSession() + { + return com.google.common.collect.Lists.newArrayList(cmisAPI.getSession().getCheckedOutDocs()); + } + + public List getCheckedOutDocumentsFromSession(OperationContext context) + { + return com.google.common.collect.Lists.newArrayList(cmisAPI.getSession().getCheckedOutDocs(context)); + } + + public List getCheckedOutDocumentsFromFolder() + { + Folder folder = cmisAPI.withCMISUtil().getCmisFolder(cmisAPI.getLastResource()); + return com.google.common.collect.Lists.newArrayList(folder.getCheckedOutDocs()); + } + + public List getCheckedOutDocumentsFromFolder(OperationContext context) + { + Folder folder = cmisAPI.withCMISUtil().getCmisFolder(cmisAPI.getLastResource()); + return com.google.common.collect.Lists.newArrayList(folder.getCheckedOutDocs(context)); + } + + protected boolean isCmisObjectContainedInCmisCheckedOutDocumentsList(CmisObject cmisObject, List cmisCheckedOutDocuments) + { + for (Document cmisCheckedOutDocument : cmisCheckedOutDocuments) + if (cmisObject.getId().split(";")[0].equals(cmisCheckedOutDocument.getId().split(";")[0])) + return true; + return false; + } + + public Map getProperties(ContentModel contentModel, String baseTypeId) + { + List aspects = new ArrayList(); + aspects.add("P:cm:titled"); + Map properties = new HashMap(); + properties.put(PropertyIds.OBJECT_TYPE_ID, baseTypeId); + properties.put(PropertyIds.NAME, contentModel.getName()); + properties.put(PropertyIds.SECONDARY_OBJECT_TYPE_IDS, aspects); + properties.put("cm:title", contentModel.getTitle()); + properties.put("cm:description", contentModel.getDescription()); + return properties; + } + + public OperationContext setIncludeAclContext() + { + OperationContext context = cmisAPI.getSession().createOperationContext(); + context.setIncludeAcls(true); + return context; + } + + public List createAce(UserModel user, UserRole role) + { + List addPermission = new ArrayList(); + addPermission.add(role.getRoleId()); + Ace addAce = cmisAPI.getSession().getObjectFactory().createAce(user.getUsername(), addPermission); + List addAces = new ArrayList(); + addAces.add(addAce); + return addAces; + } + + public List createAce(GroupModel group, UserRole role) + { + List addPermission = new ArrayList(); + addPermission.add(role.getRoleId()); + Ace addAce = cmisAPI.getSession().getObjectFactory().createAce(group.getDisplayName(), addPermission); + List addAces = new ArrayList(); + addAces.add(addAce); + return addAces; + } + + public List createAce(UserModel user, String... permissions) + { + List addAces = new ArrayList(); + RepositoryInfo repositoryInfo = cmisAPI.getSession().getRepositoryInfo(); + AclCapabilities aclCapabilities = repositoryInfo.getAclCapabilities(); + Map permissionMappings = aclCapabilities.getPermissionMapping(); + for (String perm : permissions) + { + STEP(String.format("%s Add permission '%s' for user %s ", CmisWrapper.STEP_PREFIX, perm, user.getUsername())); + PermissionMapping permissionMapping = permissionMappings.get(perm); + List permissionsList = permissionMapping.getPermissions(); + Ace addAce = cmisAPI.getSession().getObjectFactory().createAce(user.getUsername(), permissionsList); + addAces.add(addAce); + } + return addAces; + } + + public ObjectType getTypeDefinition() + { + CmisObject cmisObject = cmisAPI.withCMISUtil().getCmisObject(cmisAPI.getLastResource()); + return cmisAPI.getSession().getTypeDefinition(cmisObject.getBaseTypeId().value()); + } + + public ItemIterable getTypeChildren(String baseType, boolean includePropertyDefinitions) + { + STEP(String.format("%s Get type children for '%s' and includePropertyDefinitions set to '%s'", CmisWrapper.STEP_PREFIX, baseType, + includePropertyDefinitions)); + return cmisAPI.getSession().getTypeChildren(baseType, includePropertyDefinitions); + } + + public List> getTypeDescendants(String baseTypeId, int depth, boolean includePropertyDefinitions) + { + STEP(String.format("%s Get type descendants for '%s' with depth set to %d and includePropertyDefinitions set to '%s'", CmisWrapper.STEP_PREFIX, + baseTypeId, depth, includePropertyDefinitions)); + return cmisAPI.getSession().getTypeDescendants(baseTypeId, depth, includePropertyDefinitions); + } + + public String getObjectId(String pathToObject) + { + return getCmisObject(pathToObject).getId(); + } + + /** + * Update property for last resource cmis object + * + * @param propertyName String property name (e.g. cmis:name) + * @param propertyValue Object property value + */ + public void updateProperties(String propertyName, Object propertyValue) + { + Map props = new HashMap(); + props.put(propertyName, propertyValue); + getCmisObject(cmisAPI.getLastResource()).updateProperties(props); + } + + protected boolean isFolderInList(FolderModel folderModel, List folders) + { + for (FolderModel folder : folders) + { + if (folderModel.getName().equals(folder.getName())) + { + return true; + } + } + return false; + } + + protected boolean isFileInList(FileModel fileModel, List files) + { + for (FileModel file : files) + { + if (fileModel.getName().equals(file.getName())) + { + return true; + } + } + return false; + } + + protected boolean isContentInList(ContentModel contentModel, List contents) + { + for (ContentModel content : contents) + { + if (content.getName().equals(content.getName())) + { + return true; + } + } + return false; + } + + /** + * Get children folders from a parent folder + * + * @return List + */ + public List getFolders() throws Exception + { + STEP(String.format("%s Get the folder children from '%s'", CmisWrapper.STEP_PREFIX, cmisAPI.getLastResource())); + Map children = getChildren(); + List folders = new ArrayList(); + for (Map.Entry entry : children.entrySet()) + { + if (entry.getValue().getId().equals(BaseTypeId.CMIS_FOLDER.value())) + { + FolderModel folder = new FolderModel(entry.getKey().getName()); + folder.setNodeRef(entry.getKey().getNodeRef()); + folder.setDescription(entry.getKey().getDescription()); + folder.setCmisLocation(entry.getKey().getCmisLocation()); + folder.setProtocolLocation(entry.getKey().getCmisLocation()); + folders.add(folder); + } + } + return folders; + } + + /** + * Get children documents from a parent folder + * + * @return List + */ + public List getFiles() throws Exception + { + STEP(String.format("%s Get the file children from '%s'", CmisWrapper.STEP_PREFIX, cmisAPI.getLastResource())); + Map children = getChildren(); + List files = new ArrayList(); + for (Map.Entry entry : children.entrySet()) + { + if (entry.getValue().getId().equals(BaseTypeId.CMIS_DOCUMENT.value())) + { + FileModel file = new FileModel(entry.getKey().getName()); + file.setNodeRef(entry.getKey().getNodeRef()); + file.setDescription(entry.getKey().getDescription()); + file.setCmisLocation(entry.getKey().getCmisLocation()); + file.setProtocolLocation(entry.getKey().getCmisLocation()); + files.add(file); + } + } + return files; + } + + /* + * Get document(set as last resource) content + */ + public String getDocumentContent() throws Exception + { + Utility.waitToLoopTime(2); + Document lastVersion = getCmisDocument(cmisAPI.getLastResource()); + lastVersion.refresh(); + LOG.info(String.format("Get the content from %s - node: %s", lastVersion.getName(), lastVersion.getId())); + ContentStream contentStream = lastVersion.getContentStream(); + String actualContent = ""; + if (contentStream != null) + { + actualContent = getContentAsString(contentStream); + } + else + { + lastVersion = getCmisDocument(cmisAPI.getLastResource()); + lastVersion.refresh(); + LOG.info(String.format("Retry get content stream for %s node: %s", lastVersion.getName(), lastVersion.getId())); + contentStream = lastVersion.getContentStream(); + if (contentStream != null) + { + actualContent = getContentAsString(contentStream); + } + } + if(actualContent.isEmpty()) + { + Utility.waitToLoopTime(2); + Document retryDoc = getCmisDocument(cmisAPI.getLastResource()); + retryDoc.refresh(); + LOG.info(String.format("Retry get content stream for %s node: %s", retryDoc.getName(), retryDoc.getId())); + contentStream = retryDoc.getContentStream(); + if (contentStream != null) + { + actualContent = getContentAsString(contentStream); + } + } + return actualContent; + } + + /** + * Get user noderef + * + * @param user {@link UserModel} + */ + public String getUserNodeRef(UserModel user) + { + String objectId = ""; + ItemIterable results = cmisAPI.getSession().query("select cmis:objectId from cm:person where cm:userName = '" + user.getUsername() + "'", + false); + for (QueryResult qResult : results) + { + PropertyData propData = qResult.getPropertyById("cmis:objectId"); + objectId = (String) propData.getFirstValue(); + } + return objectId; + } +} diff --git a/e2e-test/src/main/java/org/alfresco/cmis/dsl/DocumentVersioning.java b/e2e-test/src/main/java/org/alfresco/cmis/dsl/DocumentVersioning.java new file mode 100644 index 000000000..e772aec0a --- /dev/null +++ b/e2e-test/src/main/java/org/alfresco/cmis/dsl/DocumentVersioning.java @@ -0,0 +1,137 @@ +package org.alfresco.cmis.dsl; + +import static org.alfresco.utility.report.log.Step.STEP; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.alfresco.cmis.CmisWrapper; +import org.apache.chemistry.opencmis.client.api.CmisObject; +import org.apache.chemistry.opencmis.client.api.Document; +import org.apache.chemistry.opencmis.client.api.OperationContext; +import org.testng.Assert; + +/** + * DSL utility for verifying a document version {@link Document} + */ +public class DocumentVersioning +{ + private CmisWrapper cmisWrapper; + private CmisObject cmisObject; + private boolean majorVersion; + private Object versionLabel; + private List versions; + + public DocumentVersioning(CmisWrapper cmisWrapper, CmisObject cmisObject) + { + this.cmisWrapper = cmisWrapper; + this.cmisObject = cmisObject; + } + + private DocumentVersioning withLatestMajorVersion() + { + this.majorVersion = true; + return this; + } + + private DocumentVersioning withLatestMinorVersion() + { + this.majorVersion = false; + return this; + } + + private Document getVersionOfDocument() + { + Document document = (Document) cmisObject; + if (versionLabel != null) + { + List documents = document.getAllVersions(); + for (Document documentVersion : documents) + if (documentVersion.getVersionLabel().equals(versionLabel.toString())) + return documentVersion; + } + else + { + return document.getObjectOfLatestVersion(majorVersion); + } + return document; + } + + private List getDocumentVersions(List documentList) + { + List versions = new ArrayList(); + for (Document document : documentList) + { + versions.add(document.getVersionLabel()); + } + return versions; + } + + public CmisWrapper assertVersionIs(Double expectedVersion) + { + STEP(String.format("%s Verify if document '%s' has version '%s'", cmisWrapper.getProtocolName(), cmisObject.getName(), expectedVersion)); + Assert.assertEquals(getVersionOfDocument().getVersionLabel(), expectedVersion.toString(), "File has version"); + return cmisWrapper; + } + + public CmisWrapper assertLatestMajorVersionIs(Double expectedVersion) + { + STEP(String.format("%s Verify if latest major version of document '%s' is '%s'", cmisWrapper.getProtocolName(), cmisObject.getName(), expectedVersion)); + Assert.assertEquals(withLatestMajorVersion().getVersionOfDocument().getVersionLabel(), expectedVersion.toString(), "File has version"); + return cmisWrapper; + } + + public CmisWrapper assertLatestMinorVersionIs(Double expectedVersion) + { + STEP(String.format("%s Verify if latest minor version of document '%s' is '%s'", cmisWrapper.getProtocolName(), cmisObject.getName(), expectedVersion)); + Assert.assertEquals(withLatestMinorVersion().getVersionOfDocument().getVersionLabel(), expectedVersion.toString(), "File has version"); + return cmisWrapper; + } + + public DocumentVersioning getAllDocumentVersions() + { + setVersions(getDocumentVersions(cmisWrapper.withCMISUtil().getAllDocumentVersions())); + return this; + } + + public CmisWrapper assertHasVersions(Object... versions) + { + setVersions(getDocumentVersions(cmisWrapper.withCMISUtil().getAllDocumentVersions())); + List documentVersions = getVersions(); + for (Object version : versions) + { + STEP(String.format("%s Verify if document '%s' has version '%s'", cmisWrapper.getProtocolName(), cmisObject.getName(), version)); + Assert.assertTrue(documentVersions.contains(version.toString()), + String.format("Document %s does not have version %s", cmisObject.getName(), version)); + } + return cmisWrapper; + } + + public DocumentVersioning getAllDocumentVersionsBy(OperationContext context) + { + setVersions(getDocumentVersions(cmisWrapper.withCMISUtil().getAllDocumentVersionsBy(context))); + return this; + } + + public CmisWrapper assertHasVersionsInOrder(Object... versions) + { + List documentVersions = getVersions(); + List expectedVersions = Arrays.asList(versions); + STEP(String.format("%s Verify if document '%s' has versions in this order '%s'", cmisWrapper.getProtocolName(), cmisObject.getName(), + Arrays.toString(expectedVersions.toArray()))); + Assert.assertTrue(documentVersions.toString().equals(expectedVersions.toString()), + String.format("Document %s does not have versions in this order %s", cmisObject.getName(), Arrays.toString(expectedVersions.toArray()))); + return cmisWrapper; + } + + public List getVersions() + { + return versions; + } + + public void setVersions(List versions) + { + this.versions = versions; + } +} diff --git a/e2e-test/src/main/java/org/alfresco/cmis/dsl/JmxUtil.java b/e2e-test/src/main/java/org/alfresco/cmis/dsl/JmxUtil.java new file mode 100644 index 000000000..40666d1cb --- /dev/null +++ b/e2e-test/src/main/java/org/alfresco/cmis/dsl/JmxUtil.java @@ -0,0 +1,39 @@ +package org.alfresco.cmis.dsl; + +import org.alfresco.cmis.CmisWrapper; +import org.alfresco.utility.network.Jmx; +import org.alfresco.utility.network.JmxClient; +import org.alfresco.utility.network.JmxJolokiaProxyClient; + +/** + * DSL for interacting with JMX (using direct JMX call see {@link JmxClient} or {@link JmxJolokiaProxyClient} + */ +public class JmxUtil +{ + @SuppressWarnings("unused") + private CmisWrapper cmisWrapper; + private Jmx jmx; + private final String jmxAuditObjectName = "Alfresco:Type=Configuration,Category=Audit,id1=default"; + + public JmxUtil(CmisWrapper cmisWrapper, Jmx jmx) + { + this.cmisWrapper = cmisWrapper; + this.jmx = jmx; + } + + public void enableCMISAudit() throws Exception + { + if(jmx.readProperty(jmxAuditObjectName, "audit.enabled").equals(String.valueOf(false))) + { + jmx.writeProperty(jmxAuditObjectName, "audit.enabled", String.valueOf(true)); + } + jmx.writeProperty(jmxAuditObjectName, "audit.cmischangelog.enabled", String.valueOf(true)); + jmx.writeProperty(jmxAuditObjectName, "audit.alfresco-access.enabled", String.valueOf(true)); + } + + public void disableCMISAudit() throws Exception + { + jmx.writeProperty(jmxAuditObjectName, "audit.cmischangelog.enabled", String.valueOf(false)); + jmx.writeProperty(jmxAuditObjectName, "audit.alfresco-access.enabled", String.valueOf(false)); + } +} diff --git a/e2e-test/src/main/java/org/alfresco/cmis/dsl/QueryExecutor.java b/e2e-test/src/main/java/org/alfresco/cmis/dsl/QueryExecutor.java new file mode 100644 index 000000000..7d93ceb2a --- /dev/null +++ b/e2e-test/src/main/java/org/alfresco/cmis/dsl/QueryExecutor.java @@ -0,0 +1,166 @@ +package org.alfresco.cmis.dsl; + +import static org.alfresco.utility.report.log.Step.STEP; + +import java.util.ArrayList; +import java.util.List; + +import org.alfresco.cmis.CmisWrapper; +import org.alfresco.utility.LogFactory; +import org.alfresco.utility.data.provider.XMLTestData; +import org.alfresco.utility.exception.TestConfigurationException; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestModel; +import org.apache.chemistry.opencmis.client.api.ItemIterable; +import org.apache.chemistry.opencmis.client.api.QueryResult; +import org.apache.chemistry.opencmis.client.api.Session; +import org.slf4j.Logger; +import org.testng.Assert; + +/** + * DSL for CMIS Queries + * This will also handle execution of CMIS queries + */ +public class QueryExecutor +{ + static Logger LOG = LogFactory.getLogger(); + + CmisWrapper cmisWrapper; + private long returnedResults = -1; + private String currentQuery = ""; + + public QueryExecutor(CmisWrapper cmisWrapper, String query) + { + this.cmisWrapper = cmisWrapper; + currentQuery = query; + } + + public QueryResultAssertion assertResultsCount() throws Exception + { + returnedResults = executeQuery(currentQuery).getPageNumItems(); + return new QueryResultAssertion(); + } + + private ItemIterable executeQuery(String query) throws Exception + { + Session session = cmisWrapper.getSession(); + if (session == null) + throw new Exception("You need to authenticate first using "); + + return session.query(query, false); + } + + /** + * Call getNodeRef on each test data item used in test and replace that with NODE_REF keywords in your Query + * + * @param testData + * @return + * @throws Exception + */ + public QueryExecutor applyNodeRefsFrom(XMLTestData testData) throws Exception + { + List dataItems = extractKeywords("NODE_REF"); + if (dataItems.isEmpty()) + return this; + + List nodeRefs = new ArrayList(); + for (String dataItemName : dataItems) + { + currentQuery = currentQuery.replace(String.format("NODE_REF[%s]", dataItemName), "%s"); + TestModel model = testData.getTestDataItemWithId(dataItemName).getModel(); + if (model == null) + throw new TestConfigurationException("No TestData with ID: " + dataItemName + " found in your XML file."); + + if (model instanceof SiteModel) + { + nodeRefs.add(cmisWrapper.getDataContentService().usingAdmin().usingSite((SiteModel) model).getNodeRef()); + } + else if (model instanceof FolderModel) + { + nodeRefs.add(((FolderModel) model).getNodeRef()); + } + else if (model instanceof FileModel) + { + nodeRefs.add(((FileModel) model).getNodeRef()); + } + } + + try + { + currentQuery = String.format(currentQuery, nodeRefs.toArray()); + LOG.info("Injecting nodeRef IDs \n\tQuery: [{}]", currentQuery); + } + catch (Exception e) + { + throw new TestConfigurationException( + "You passed multiple keywords to your search query, please re-analyze your query search format: " + e.getMessage()); + } + return this; + } + + /** + * if you have in your search 'SELECT * from cmis:document where workspace://SpacesStore/NODE_REF[site1] or workspace://SpacesStore/NODE_REF[site2]' + * and pass key="NODE_REF" this method will get "site1" and "site2" as values + * + * @param key + * @return + * @throws TestConfigurationException + */ + private List extractKeywords(String key) throws TestConfigurationException + { + String[] lines = currentQuery.split(key); + List keywords = new ArrayList(); + + for (int i = 0; i < lines.length; i++) + { + if (lines[i].startsWith("[")) + { + String keyValue = ""; + for (int j = 1; j < lines[i].length() - 1; j++) + { + String tmp = Character.toString(lines[i].charAt(j)); + if (tmp.equals("]")) + break; + keyValue += tmp; + } + keywords.add(keyValue); + } + } + return keywords; + } + + public class QueryResultAssertion + { + public QueryResultAssertion equals(long expectedValue) + { + STEP(String.format("Verify that query: '%s' has %d results count returned", currentQuery, expectedValue)); + Assert.assertEquals(returnedResults, expectedValue, showErrorMessage()); + return this; + } + + public QueryResultAssertion isGreaterThan(long expectedValue) + { + STEP(String.format("Verify that query: '%s' has more than %d results count returned", currentQuery, expectedValue)); + if (expectedValue <= returnedResults) + Assert.fail(String.format("%s expected to have more than %d results, but found %d", showErrorMessage(), expectedValue, returnedResults)); + + return this; + } + + public QueryResultAssertion isLowerThan(long expectedValue) + { + STEP(String.format("Verify that query: '%s' has more than %d results count returned", currentQuery, expectedValue)); + if (returnedResults >= expectedValue) + Assert.fail(String.format("%s expected to have less than %d results, but found %d", showErrorMessage(), expectedValue, returnedResults)); + + return this; + } + + private String showErrorMessage() + { + return String.format("Returned results count of Query [%s] is not the expected one:", currentQuery); + } + } +} diff --git a/e2e-test/src/main/java/org/alfresco/cmis/exception/InvalidCmisObjectException.java b/e2e-test/src/main/java/org/alfresco/cmis/exception/InvalidCmisObjectException.java new file mode 100644 index 000000000..9bc532652 --- /dev/null +++ b/e2e-test/src/main/java/org/alfresco/cmis/exception/InvalidCmisObjectException.java @@ -0,0 +1,10 @@ +package org.alfresco.cmis.exception; + +public class InvalidCmisObjectException extends RuntimeException +{ + private static final long serialVersionUID = 1L; + public InvalidCmisObjectException(String reason) + { + super(reason); + } +} diff --git a/e2e-test/src/main/java/org/alfresco/cmis/exception/UnrecognizedBinding.java b/e2e-test/src/main/java/org/alfresco/cmis/exception/UnrecognizedBinding.java new file mode 100644 index 000000000..cf1dcaf25 --- /dev/null +++ b/e2e-test/src/main/java/org/alfresco/cmis/exception/UnrecognizedBinding.java @@ -0,0 +1,12 @@ +package org.alfresco.cmis.exception; + +public class UnrecognizedBinding extends Exception +{ + private static final long serialVersionUID = 1L; + private static final String DEFAULT_MESSAGE = "Unrecognized CMIS Binding [%s]. Available binding options: BROWSER or ATOM"; + + public UnrecognizedBinding(String binding) + { + super(String.format(DEFAULT_MESSAGE, binding)); + } +} diff --git a/e2e-test/src/main/resources/model/tas-model.xml b/e2e-test/src/main/resources/model/tas-model.xml new file mode 100644 index 000000000..892027f9c --- /dev/null +++ b/e2e-test/src/main/resources/model/tas-model.xml @@ -0,0 +1,151 @@ + + + + + Alfresco TAS custom model + Bogdan + 1.0 + + + + + + + + + + + + + CMIS TAS Content + cm:content + + + Text + d:text + + + Datetime + d:datetime + + + Integer + d:int + + + Long + d:long + + + Multiply String + d:text + true + true + + + + + + + false + false + + + cm:content + false + false + + + + + + + CMIS TAS Folder + cm:folder + + + Text + d:text + + + Datetime + d:datetime + + + Integer + d:int + + + Multiply String + d:text + true + true + + + + + + + false + false + + + cm:folder + false + false + + + + + + + + + TAS Content Aspect + + + Aspect Text + d:text + + + Aspect Datetime + d:datetime + + + Aspect Integer + d:int + + + Aspect Multiply String + d:text + true + true + + + + + + TAS Folder Aspect + + + Aspect Text + d:text + + + Aspect Datetime + d:datetime + + + Aspect Integer + d:int + + + Aspect Multiply String + d:text + true + true + + + + + \ No newline at end of file diff --git a/e2e-test/src/main/resources/testdata/search-by-aspect.xml b/e2e-test/src/main/resources/testdata/search-by-aspect.xml new file mode 100644 index 000000000..60afe36cb --- /dev/null +++ b/e2e-test/src/main/resources/testdata/search-by-aspect.xml @@ -0,0 +1,264 @@ + + + + + + + + + + + + + + + + + + + + + + content sub-file 1 + + + + + + + + + + + + + + + + + content sub-file 2 + + + + + + + + + + + + + + + + + content sub-file 3 + + + + + + + + + + + content sub-file 4 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + file 1 content + + + file 2 content + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/e2e-test/src/main/resources/testdata/search-by-id.xml b/e2e-test/src/main/resources/testdata/search-by-id.xml new file mode 100644 index 000000000..93dc64811 --- /dev/null +++ b/e2e-test/src/main/resources/testdata/search-by-id.xml @@ -0,0 +1,118 @@ + + + + + + + + + + + + + + content sub-file 1 + + + + + + + + content sub-file 2 + + + + + + + + content sub-file 3 + + + + + + + + content sub-file 4 + + + + + + + + + + + + + + + + + + + + + + file 1 content + + + file 2 content + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/e2e-test/src/main/resources/testdata/search-by-path.xml b/e2e-test/src/main/resources/testdata/search-by-path.xml new file mode 100644 index 000000000..b8388a1d9 --- /dev/null +++ b/e2e-test/src/main/resources/testdata/search-by-path.xml @@ -0,0 +1,97 @@ + + + + + + + + + + + + content sub-file 1 + + + content sub-file 2 + + + content sub-file 3 + + + content sub-file 4 + + + + + + + + + + + + + file 1 content + + + file 2 content + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/e2e-test/src/main/resources/testdata/search-by-property.xml b/e2e-test/src/main/resources/testdata/search-by-property.xml new file mode 100644 index 000000000..11a09aa15 --- /dev/null +++ b/e2e-test/src/main/resources/testdata/search-by-property.xml @@ -0,0 +1,225 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + content guestc + + + + + + + + + content restc + + + + + + + + + content tesc + + + + + + + + + content testtttc + + + + + + + + + content testc + + + + + + + + + content testc1 + + + + + + + + + content testc2 + + + + + + + + + content testc3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/e2e-test/src/main/resources/testdata/search-in-folder.xml b/e2e-test/src/main/resources/testdata/search-in-folder.xml new file mode 100644 index 000000000..b86957a34 --- /dev/null +++ b/e2e-test/src/main/resources/testdata/search-in-folder.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/e2e-test/src/main/resources/testdata/search-in-tree.xml b/e2e-test/src/main/resources/testdata/search-in-tree.xml new file mode 100644 index 000000000..bb580a9d2 --- /dev/null +++ b/e2e-test/src/main/resources/testdata/search-in-tree.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/e2e-test/src/test/java/org/alfresco/service/search/CmisTest.java b/e2e-test/src/test/java/org/alfresco/service/search/CmisTest.java new file mode 100644 index 000000000..33d4b926d --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/service/search/CmisTest.java @@ -0,0 +1,69 @@ +package org.alfresco.service.search; + +import org.alfresco.cmis.CmisWrapper; + +import java.lang.reflect.Method; + +import org.alfresco.utility.LogFactory; +import org.alfresco.utility.data.DataContent; +import org.alfresco.utility.data.DataSite; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.network.ServerHealth; +import org.slf4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.BeforeSuite; + +@ContextConfiguration("classpath:alfresco-cmis-context.xml") +@Component +@Scope(value = "prototype") +public abstract class CmisTest extends AbstractTestNGSpringContextTests +{ + private static Logger LOG = LogFactory.getLogger(); + + @Autowired + protected CmisWrapper cmisApi; + + @Autowired + protected DataUser dataUser; + + @Autowired + protected DataSite dataSite; + + @Autowired + protected DataContent dataContent; + + @Autowired + ServerHealth serverHealth; + + public String documentContent = "CMIS document content"; + + @BeforeSuite(alwaysRun = true) + public void checkServerHealth() throws Exception + { + super.springTestContextPrepareTestInstance(); + serverHealth.assertServerIsOnline(); + } + + @BeforeMethod(alwaysRun = true) + public void showStartTestInfo(Method method) + { + LOG.info(String.format("*** STARTING Test: [%s] ***", method.getName())); + } + + @AfterMethod(alwaysRun = true) + public void showEndTestInfo(Method method) + { + LOG.info(String.format("*** ENDING Test: [%s] ***", method.getName())); + } + + public Integer getSolrWaitTimeInSeconds() + { + return cmisApi.cmisProperties.envProperty().getSolrWaitTimeInSeconds(); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/cmis/SolrSearchByAspectTests.java b/e2e-test/src/test/java/org/alfresco/service/search/cmis/SolrSearchByAspectTests.java new file mode 100644 index 000000000..354755fed --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/service/search/cmis/SolrSearchByAspectTests.java @@ -0,0 +1,63 @@ +package org.alfresco.service.search.cmis; + +import org.alfresco.service.search.CmisTest; + +import org.alfresco.utility.Utility; +import org.alfresco.utility.data.provider.XMLDataConfig; +import org.alfresco.utility.data.provider.XMLTestData; +import org.alfresco.utility.data.provider.XMLTestDataProvider; +import org.alfresco.utility.exception.TestConfigurationException; +import org.alfresco.utility.model.QueryModel; +import org.alfresco.utility.model.TestGroup; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class SolrSearchByAspectTests extends CmisTest +{ + /** Logger for the class. */ + private static Logger LOGGER = LoggerFactory.getLogger(SolrSearchByAspectTests.class); + private XMLTestData testData; + + @BeforeClass(alwaysRun = true) + public void deployCustomModel() throws TestConfigurationException + { + dataContent.deployContentModel("model/tas-model.xml"); + cmisApi.authenticateUser(dataUser.getAdminUser()); + } + + @AfterClass(alwaysRun = true) + public void cleanupEnvironment() + { + if (testData != null) + { + testData.cleanup(dataContent); + } + else + { + LOGGER.warn("testData is inexplicably null - skipping clean up."); + } + } + + @Test(dataProviderClass = XMLTestDataProvider.class, dataProvider = "getAllData") + @XMLDataConfig(file = "src/main/resources/testdata/search-by-aspect.xml") + public void prepareDataForAspectSearch(XMLTestData testData) throws Exception + { + this.testData = testData; + this.testData.createUsers(dataUser); + this.testData.createSitesStructure(dataSite, dataContent, dataUser); + // wait for solr index + Utility.waitToLoopTime(getSolrWaitTimeInSeconds()); + } + + @Test(groups = { TestGroup.CMIS, TestGroup.QUERIES }, + dataProviderClass = XMLTestDataProvider.class, dataProvider = "getQueriesData", dependsOnMethods = "prepareDataForAspectSearch") + @XMLDataConfig(file = "src/main/resources/testdata/search-by-aspect.xml") + public void executeSearchByAspect(QueryModel query) throws Exception + { + cmisApi.withQuery(query.getValue()) + .applyNodeRefsFrom(testData).assertResultsCount().equals(query.getResults()); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/cmis/SolrSearchByIdTests.java b/e2e-test/src/test/java/org/alfresco/service/search/cmis/SolrSearchByIdTests.java new file mode 100644 index 000000000..f46b78a12 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/service/search/cmis/SolrSearchByIdTests.java @@ -0,0 +1,62 @@ +package org.alfresco.service.search.cmis; + +import org.alfresco.service.search.CmisTest; +import org.alfresco.utility.Utility; +import org.alfresco.utility.data.provider.XMLDataConfig; +import org.alfresco.utility.data.provider.XMLTestData; +import org.alfresco.utility.data.provider.XMLTestDataProvider; +import org.alfresco.utility.exception.TestConfigurationException; +import org.alfresco.utility.model.QueryModel; +import org.alfresco.utility.model.TestGroup; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class SolrSearchByIdTests extends CmisTest +{ + /** Logger for the class. */ + private static Logger LOGGER = LoggerFactory.getLogger(SolrSearchByIdTests.class); + private XMLTestData testData; + + @BeforeClass(alwaysRun = true) + public void deployCustomModel() throws TestConfigurationException + { + dataContent.deployContentModel("model/tas-model.xml"); + cmisApi.authenticateUser(dataUser.getAdminUser()); + } + + @AfterClass(alwaysRun = true) + public void cleanupEnvironment() + { + if (testData != null) + { + testData.cleanup(dataContent); + } + else + { + LOGGER.warn("testData is inexplicably null - skipping clean up."); + } + } + + @Test(dataProviderClass = XMLTestDataProvider.class, dataProvider = "getAllData") + @XMLDataConfig(file = "src/main/resources/testdata/search-by-id.xml") + public void prepareDataForSearchById(XMLTestData testData) throws Exception + { + this.testData = testData; + this.testData.createUsers(dataUser); + this.testData.createSitesStructure(dataSite, dataContent, dataUser); + // wait for solr index + Utility.waitToLoopTime(getSolrWaitTimeInSeconds()); + } + + @Test(groups = { TestGroup.CMIS, TestGroup.QUERIES }, + dataProviderClass = XMLTestDataProvider.class, dataProvider = "getQueriesData", dependsOnMethods = "prepareDataForSearchById") + @XMLDataConfig(file = "src/main/resources/testdata/search-by-id.xml") + public void executeSortedSearchByID(QueryModel query) throws Exception + { + cmisApi.withQuery(query.getValue()) + .applyNodeRefsFrom(testData).assertResultsCount().equals(query.getResults()); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/cmis/SolrSearchByPathTests.java b/e2e-test/src/test/java/org/alfresco/service/search/cmis/SolrSearchByPathTests.java new file mode 100644 index 000000000..4ee8a2f14 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/service/search/cmis/SolrSearchByPathTests.java @@ -0,0 +1,59 @@ +package org.alfresco.service.search.cmis; + +import org.alfresco.service.search.CmisTest; +import org.alfresco.utility.Utility; +import org.alfresco.utility.data.provider.XMLDataConfig; +import org.alfresco.utility.data.provider.XMLTestData; +import org.alfresco.utility.data.provider.XMLTestDataProvider; +import org.alfresco.utility.model.QueryModel; +import org.alfresco.utility.model.TestGroup; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class SolrSearchByPathTests extends CmisTest +{ + /** Logger for the class. */ + private static Logger LOGGER = LoggerFactory.getLogger(SolrSearchByPathTests.class); + private XMLTestData testData; + + @BeforeClass(alwaysRun = true) + public void readTestDataFile() + { + cmisApi.authenticateUser(dataUser.getAdminUser()); + } + + @AfterClass(alwaysRun = true) + public void cleanupEnvironment() + { + if (testData != null) + { + testData.cleanup(dataContent); + } + else + { + LOGGER.warn("testData is inexplicably null - skipping clean up."); + } + } + + @Test(dataProviderClass = XMLTestDataProvider.class, dataProvider = "getAllData") + @XMLDataConfig(file = "src/main/resources/testdata/search-by-path.xml") + public void prepareDataForSearchByPath(XMLTestData testData) throws Exception + { + this.testData = testData; + testData.createUsers(dataUser); + testData.createSitesStructure(dataSite, dataContent, dataUser); + // wait for solr index + Utility.waitToLoopTime(getSolrWaitTimeInSeconds()); + } + + @Test(groups = { TestGroup.CMIS, TestGroup.QUERIES }, + dependsOnMethods = "prepareDataForSearchByPath", dataProviderClass = XMLTestDataProvider.class, dataProvider = "getQueriesData") + @XMLDataConfig(file = "src/main/resources/testdata/search-by-path.xml") + public void executeSearchByPathQueries(QueryModel query) throws Exception + { + cmisApi.withQuery(query.getValue()).assertResultsCount().equals(query.getResults()); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/cmis/SolrSearchByPropertyTests.java b/e2e-test/src/test/java/org/alfresco/service/search/cmis/SolrSearchByPropertyTests.java new file mode 100644 index 000000000..c8e0c298c --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/service/search/cmis/SolrSearchByPropertyTests.java @@ -0,0 +1,62 @@ +package org.alfresco.service.search.cmis; + +import org.alfresco.service.search.CmisTest; +import org.alfresco.utility.Utility; +import org.alfresco.utility.data.provider.XMLDataConfig; +import org.alfresco.utility.data.provider.XMLTestData; +import org.alfresco.utility.data.provider.XMLTestDataProvider; +import org.alfresco.utility.exception.TestConfigurationException; +import org.alfresco.utility.model.QueryModel; +import org.alfresco.utility.model.TestGroup; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class SolrSearchByPropertyTests extends CmisTest +{ + /** Logger for the class. */ + private static Logger LOGGER = LoggerFactory.getLogger(SolrSearchByPropertyTests.class); + private XMLTestData testData; + + @BeforeClass(alwaysRun = true) + public void deployCustomModel() throws TestConfigurationException + { + dataContent.deployContentModel("model/tas-model.xml"); + cmisApi.authenticateUser(dataUser.getAdminUser()); + } + + @AfterClass(alwaysRun = true) + public void cleanupEnvironment() + { + if (testData != null) + { + testData.cleanup(dataContent); + } + else + { + LOGGER.warn("testData is inexplicably null - skipping clean up."); + } + } + + @Test(dataProviderClass = XMLTestDataProvider.class, dataProvider = "getAllData") + @XMLDataConfig(file = "src/main/resources/testdata/search-by-property.xml") + public void prepareDataForSearchWithProperty(XMLTestData testData) throws Exception + { + this.testData = testData; + this.testData.createUsers(dataUser); + this.testData.createSitesStructure(dataSite, dataContent, dataUser); + // wait for solr index + Utility.waitToLoopTime(getSolrWaitTimeInSeconds()); + } + + @Test(groups = { TestGroup.CMIS, TestGroup.QUERIES }, + dataProviderClass = XMLTestDataProvider.class, dataProvider = "getQueriesData", dependsOnMethods = "prepareDataForSearchWithProperty") + @XMLDataConfig(file = "src/main/resources/testdata/search-by-property.xml") + public void executeSortedSearchByID(QueryModel query) throws Exception + { + cmisApi.withQuery(query.getValue()) + .applyNodeRefsFrom(testData).assertResultsCount().equals(query.getResults()); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/cmis/SolrSearchInFolderTests.java b/e2e-test/src/test/java/org/alfresco/service/search/cmis/SolrSearchInFolderTests.java new file mode 100644 index 000000000..9edcb509e --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/service/search/cmis/SolrSearchInFolderTests.java @@ -0,0 +1,70 @@ +package org.alfresco.service.search.cmis; + +import org.alfresco.service.search.CmisTest; +import org.alfresco.utility.Utility; +import org.alfresco.utility.data.provider.XMLDataConfig; +import org.alfresco.utility.data.provider.XMLTestData; +import org.alfresco.utility.data.provider.XMLTestDataProvider; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FileType; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.QueryModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class SolrSearchInFolderTests extends CmisTest +{ + private UserModel testUser; + private SiteModel testSite; + private FolderModel parentFolder, subFolder1, subFolder2, subFolder3; + private FileModel subFile1, subFile2, subFile3, subFile4, subFile5; + + @BeforeClass(alwaysRun = true) + public void createTestData() throws Exception + { + // create input data + parentFolder = FolderModel.getRandomFolderModel(); + subFolder1 = FolderModel.getRandomFolderModel(); + subFolder2 = FolderModel.getRandomFolderModel(); + subFolder3 = new FolderModel("subFolder"); + subFile5 = new FileModel("fifthFile.txt",FileType.TEXT_PLAIN, "fifthFile content"); + subFile1 = new FileModel("firstFile", FileType.MSEXCEL); + subFile2 = FileModel.getRandomFileModel(FileType.MSPOWERPOINT2007); + subFile3 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); + subFile4 = new FileModel("fourthFile", "fourthFileTitle", "fourthFileDescription", FileType.MSWORD2007); + + testUser = dataUser.createRandomTestUser(); + testSite = dataSite.usingUser(testUser).createPublicRandomSite(); + cmisApi.authenticateUser(testUser).usingSite(testSite).createFolder(parentFolder) + .then().usingResource(parentFolder) + .createFile(subFile5).assertThat().contentIs("fifthFile content") + .createFolder(subFolder1) + .createFolder(subFolder2) + .createFolder(subFolder3) + .createFile(subFile1) + .createFile(subFile2) + .createFile(subFile3) + .createFile(subFile4); + // wait for solr index + Utility.waitToLoopTime(getSolrWaitTimeInSeconds()); + } + + @AfterClass(alwaysRun = true) + public void cleanupEnvironment() + { + dataContent.deleteSite(testSite); + } + + @Test(groups = { TestGroup.CMIS, TestGroup.QUERIES }, + dataProviderClass = XMLTestDataProvider.class, dataProvider = "getQueriesData") + @XMLDataConfig(file = "src/main/resources/testdata/search-in-folder.xml") + public void executeCMISQuery(QueryModel query) throws Exception + { + String currentQuery = String.format(query.getValue(), parentFolder.getNodeRef()); + cmisApi.withQuery(currentQuery).assertResultsCount().equals(query.getResults()); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/cmis/SolrSearchInTreeTests.java b/e2e-test/src/test/java/org/alfresco/service/search/cmis/SolrSearchInTreeTests.java new file mode 100644 index 000000000..ad5944a2b --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/service/search/cmis/SolrSearchInTreeTests.java @@ -0,0 +1,75 @@ +package org.alfresco.service.search.cmis; + +import org.alfresco.service.search.CmisTest; +import org.alfresco.utility.Utility; +import org.alfresco.utility.data.provider.XMLDataConfig; +import org.alfresco.utility.data.provider.XMLTestData; +import org.alfresco.utility.data.provider.XMLTestDataProvider; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FileType; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.QueryModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class SolrSearchInTreeTests extends CmisTest +{ + private UserModel testUser; + private SiteModel testSite; + private FolderModel parentFolder, subFolder1, subFolder2, subFolder3; + private FileModel subFile1, subFile2, subFile3, subFile4, subFile5, subFile6; + + @BeforeClass(alwaysRun = true) + public void createTestData() throws Exception + { + // create input data + parentFolder = FolderModel.getRandomFolderModel(); + subFolder1 = FolderModel.getRandomFolderModel(); + subFolder2 = FolderModel.getRandomFolderModel(); + subFolder3 = new FolderModel("subFolder-3"); + subFile5 = new FileModel("fifthFile.txt",FileType.TEXT_PLAIN, "fifthFile content"); + subFile1 = new FileModel("firstFile", FileType.MSEXCEL); + subFile2 = FileModel.getRandomFileModel(FileType.MSPOWERPOINT2007); + subFile3 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); + subFile4 = new FileModel("fourthFile", "fourthFileTitle", "fourthFileDescription", FileType.MSWORD2007); + subFile6 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); + + testUser = dataUser.createRandomTestUser(); + testSite = dataSite.usingUser(testUser).createPublicRandomSite(); + cmisApi.authenticateUser(testUser).usingSite(testSite).createFolder(parentFolder) + .then().usingResource(parentFolder) + .createFile(subFile5).assertThat().contentIs("fifthFile content") + .createFolder(subFolder1) + .createFolder(subFolder2) + .createFolder(subFolder3) + .createFile(subFile1) + .createFile(subFile2) + .createFile(subFile3) + .createFile(subFile4) + .then().usingResource(subFolder1) + .createFile(subFile6) + .createFolder(FolderModel.getRandomFolderModel()); + // wait for solr index + Utility.waitToLoopTime(getSolrWaitTimeInSeconds()); + } + + @AfterClass(alwaysRun = true) + public void cleanupEnvironment() + { + dataContent.deleteSite(testSite); + } + + @Test(groups = { TestGroup.CMIS, TestGroup.QUERIES }, + dataProviderClass = XMLTestDataProvider.class, dataProvider = "getQueriesData") + @XMLDataConfig(file = "src/main/resources/testdata/search-in-tree.xml") + public void executeCMISQuery(QueryModel query) throws Exception + { + String currentQuery = String.format(query.getValue(), parentFolder.getNodeRef()); + cmisApi.withQuery(currentQuery) + .assertResultsCount().equals(query.getResults()); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/cmis/SorlSearchSimpleQueryTests.java b/e2e-test/src/test/java/org/alfresco/service/search/cmis/SorlSearchSimpleQueryTests.java new file mode 100644 index 000000000..fd8f232da --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/service/search/cmis/SorlSearchSimpleQueryTests.java @@ -0,0 +1,14 @@ +package org.alfresco.service.search.cmis; + +import org.alfresco.service.search.CmisTest; +import org.testng.annotations.Test; + +public class SorlSearchSimpleQueryTests extends CmisTest +{ + @Test + public void simpleQueryOnFolderDesc() throws Exception + { + cmisApi.authenticateUser(dataUser.getAdminUser()) + .withQuery("SELECT * FROM cmis:folder ORDER BY cmis:createdBy DESC").assertResultsCount().isLowerThan(101); + } +} diff --git a/e2e-test/src/test/resources/alfresco-cmis-context.xml b/e2e-test/src/test/resources/alfresco-cmis-context.xml new file mode 100644 index 000000000..f5465c071 --- /dev/null +++ b/e2e-test/src/test/resources/alfresco-cmis-context.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + From 5be73c86327a19d3b49cd367e45a2ec1971d279d Mon Sep 17 00:00:00 2001 From: Keerat Date: Mon, 18 Mar 2019 09:26:20 +0000 Subject: [PATCH 1469/1491] Search-1486 v1 --- e2e-test/src/main/resources/cmis-search.xml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 e2e-test/src/main/resources/cmis-search.xml diff --git a/e2e-test/src/main/resources/cmis-search.xml b/e2e-test/src/main/resources/cmis-search.xml new file mode 100644 index 000000000..cd6c6d881 --- /dev/null +++ b/e2e-test/src/main/resources/cmis-search.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + From fb4f2f0c1659073d0dbd569f21f95734c19b3187 Mon Sep 17 00:00:00 2001 From: Keerat Date: Mon, 18 Mar 2019 14:11:44 +0000 Subject: [PATCH 1470/1491] Search-1485 v1.2 --- .../org/alfresco/cmis/CmisProperties.java | 55 - .../java/org/alfresco/cmis/CmisWrapper.java | 1119 ---------------- .../org/alfresco/cmis/dsl/BaseObjectType.java | 185 --- .../java/org/alfresco/cmis/dsl/CheckIn.java | 78 -- .../org/alfresco/cmis/dsl/CmisAssertion.java | 1153 ----------------- .../java/org/alfresco/cmis/dsl/CmisUtil.java | 743 ----------- .../alfresco/cmis/dsl/DocumentVersioning.java | 137 -- .../java/org/alfresco/cmis/dsl/JmxUtil.java | 39 - .../org/alfresco/cmis/dsl/QueryExecutor.java | 166 --- .../exception/InvalidCmisObjectException.java | 10 - .../cmis/exception/UnrecognizedBinding.java | 12 - .../service/search/{ => cmis}/CmisTest.java | 8 +- .../search/cmis/SolrSearchByAspectTests.java | 2 - .../search/cmis/SolrSearchByIdTests.java | 1 - .../search/cmis/SolrSearchByPathTests.java | 1 - .../cmis/SolrSearchByPropertyTests.java | 1 - .../search/cmis/SolrSearchInFolderTests.java | 1 - .../search/cmis/SolrSearchInTreeTests.java | 1 - .../cmis/SorlSearchSimpleQueryTests.java | 1 - .../{main => test}/resources/cmis-search.xml | 0 20 files changed, 6 insertions(+), 3707 deletions(-) delete mode 100644 e2e-test/src/main/java/org/alfresco/cmis/CmisProperties.java delete mode 100644 e2e-test/src/main/java/org/alfresco/cmis/CmisWrapper.java delete mode 100644 e2e-test/src/main/java/org/alfresco/cmis/dsl/BaseObjectType.java delete mode 100644 e2e-test/src/main/java/org/alfresco/cmis/dsl/CheckIn.java delete mode 100644 e2e-test/src/main/java/org/alfresco/cmis/dsl/CmisAssertion.java delete mode 100644 e2e-test/src/main/java/org/alfresco/cmis/dsl/CmisUtil.java delete mode 100644 e2e-test/src/main/java/org/alfresco/cmis/dsl/DocumentVersioning.java delete mode 100644 e2e-test/src/main/java/org/alfresco/cmis/dsl/JmxUtil.java delete mode 100644 e2e-test/src/main/java/org/alfresco/cmis/dsl/QueryExecutor.java delete mode 100644 e2e-test/src/main/java/org/alfresco/cmis/exception/InvalidCmisObjectException.java delete mode 100644 e2e-test/src/main/java/org/alfresco/cmis/exception/UnrecognizedBinding.java rename e2e-test/src/test/java/org/alfresco/service/search/{ => cmis}/CmisTest.java (89%) rename e2e-test/src/{main => test}/resources/cmis-search.xml (100%) diff --git a/e2e-test/src/main/java/org/alfresco/cmis/CmisProperties.java b/e2e-test/src/main/java/org/alfresco/cmis/CmisProperties.java deleted file mode 100644 index ed711e1f9..000000000 --- a/e2e-test/src/main/java/org/alfresco/cmis/CmisProperties.java +++ /dev/null @@ -1,55 +0,0 @@ -package org.alfresco.cmis; - -import org.alfresco.utility.TasProperties; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.PropertySource; -import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; - -@Configuration -@PropertySource("classpath:default.properties") -@PropertySource(value = "classpath:${environment}.properties", ignoreResourceNotFound = true) -public class CmisProperties -{ - @Autowired - private TasProperties properties; - - public TasProperties envProperty() - { - return properties; - } - - @Bean - public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() - { - return new PropertySourcesPlaceholderConfigurer(); - } - - @Value("${cmis.binding}") - private String cmisBinding; - - @Value("${cmis.basePath}") - private String basePath; - - public String getCmisBinding() - { - return cmisBinding; - } - - public String getBasePath() - { - return basePath; - } - - public void setBasePath(String basePath) - { - this.basePath = basePath; - } - - public void setCmisBinding(String cmisBinding) - { - this.cmisBinding = cmisBinding; - } -} diff --git a/e2e-test/src/main/java/org/alfresco/cmis/CmisWrapper.java b/e2e-test/src/main/java/org/alfresco/cmis/CmisWrapper.java deleted file mode 100644 index 4c1b0e8a0..000000000 --- a/e2e-test/src/main/java/org/alfresco/cmis/CmisWrapper.java +++ /dev/null @@ -1,1119 +0,0 @@ -package org.alfresco.cmis; - -import static org.alfresco.utility.Utility.checkObjectIsInitialized; -import static org.alfresco.utility.report.log.Step.STEP; - -import java.io.File; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.alfresco.cmis.dsl.BaseObjectType; -import org.alfresco.cmis.dsl.CheckIn; -import org.alfresco.cmis.dsl.CmisAssertion; -import org.alfresco.cmis.dsl.CmisUtil; -import org.alfresco.cmis.dsl.DocumentVersioning; -import org.alfresco.cmis.dsl.JmxUtil; -import org.alfresco.cmis.dsl.QueryExecutor; -import org.alfresco.utility.LogFactory; -import org.alfresco.utility.Utility; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.dsl.DSLContentModelAction; -import org.alfresco.utility.dsl.DSLFile; -import org.alfresco.utility.dsl.DSLFolder; -import org.alfresco.utility.dsl.DSLProtocol; -import org.alfresco.utility.exception.TestConfigurationException; -import org.alfresco.utility.model.ContentModel; -import org.alfresco.utility.model.DataListItemModel; -import org.alfresco.utility.model.DataListModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.GroupModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.UserModel; -import org.apache.chemistry.opencmis.client.api.CmisObject; -import org.apache.chemistry.opencmis.client.api.Document; -import org.apache.chemistry.opencmis.client.api.FileableCmisObject; -import org.apache.chemistry.opencmis.client.api.Folder; -import org.apache.chemistry.opencmis.client.api.ObjectId; -import org.apache.chemistry.opencmis.client.api.Repository; -import org.apache.chemistry.opencmis.client.api.SecondaryType; -import org.apache.chemistry.opencmis.client.api.Session; -import org.apache.chemistry.opencmis.client.api.SessionFactory; -import org.apache.chemistry.opencmis.client.runtime.SessionFactoryImpl; -import org.apache.chemistry.opencmis.commons.PropertyIds; -import org.apache.chemistry.opencmis.commons.SessionParameter; -import org.apache.chemistry.opencmis.commons.data.AclCapabilities; -import org.apache.chemistry.opencmis.commons.data.ContentStream; -import org.apache.chemistry.opencmis.commons.data.PermissionMapping; -import org.apache.chemistry.opencmis.commons.data.RepositoryInfo; -import org.apache.chemistry.opencmis.commons.enums.AclPropagation; -import org.apache.chemistry.opencmis.commons.enums.BaseTypeId; -import org.apache.chemistry.opencmis.commons.enums.BindingType; -import org.apache.chemistry.opencmis.commons.enums.UnfileObject; -import org.apache.chemistry.opencmis.commons.enums.VersioningState; -import org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException; -import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException; -import org.apache.chemistry.opencmis.commons.exceptions.CmisStorageException; -import org.apache.chemistry.opencmis.commons.exceptions.CmisVersioningException; -import org.slf4j.Logger; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Scope; -import org.springframework.stereotype.Service; - -@Service -@Scope(value = "prototype") -public class CmisWrapper extends DSLProtocol implements DSLContentModelAction, DSLFile, DSLFolder -{ - protected Logger LOG = LogFactory.getLogger(); - public static String STEP_PREFIX = "CMIS:"; - - private Session session; - - @Autowired - public - CmisProperties cmisProperties; - - public List deleteTreeFailedObjects = new ArrayList(); - - @Override - public CmisWrapper authenticateUser(UserModel userModel) - { - disconnect(); - STEP(String.format("%s Connect with %s/%s", STEP_PREFIX, userModel.getUsername(), userModel.getPassword())); - SessionFactory factory = SessionFactoryImpl.newInstance(); - Map parameter = new HashMap(); - parameter.put(SessionParameter.USER, userModel.getUsername()); - parameter.put(SessionParameter.PASSWORD, userModel.getPassword()); - String binding = cmisProperties.getCmisBinding().toLowerCase(); - String cmisURLPath = cmisProperties.envProperty().getFullServerUrl() + cmisProperties.getBasePath(); - if (binding.equals(BindingType.BROWSER.value())) - { - parameter.put(SessionParameter.BROWSER_URL, cmisURLPath); - parameter.put(SessionParameter.BINDING_TYPE, BindingType.BROWSER.value()); - LOG.info("Using binding type [{}] to [{}] and credentials: {}", BindingType.BROWSER.value(), cmisURLPath, userModel.toString()); - } - else if (binding.equals(BindingType.ATOMPUB.value().replace("pub", ""))) - { - parameter.put(SessionParameter.ATOMPUB_URL, cmisURLPath); - parameter.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value()); - LOG.info("Using binding type [{}] to [{}] and credentials: {}", BindingType.ATOMPUB.value(), cmisURLPath, userModel.toString()); - } - parameter.put(SessionParameter.CONNECT_TIMEOUT, "20000"); - parameter.put(SessionParameter.READ_TIMEOUT, "60000"); - List repositories = factory.getRepositories(parameter); - parameter.put(SessionParameter.REPOSITORY_ID, repositories.get(0).getId()); - session = repositories.get(0).createSession(); - setTestUser(userModel); - return this; - } - - public CmisWrapper authUserUsingBrowserUrlAndBindingType(UserModel userModel, String urlPath, String bindingType) - { - STEP(String.format("%s Setting binding type %s to %s", STEP_PREFIX, bindingType, urlPath)); - STEP(String.format("%s Connect with %s/%s", STEP_PREFIX, userModel.getUsername(), userModel.getPassword())); - SessionFactory factory = SessionFactoryImpl.newInstance(); - Map parameter = new HashMap(); - parameter.put(SessionParameter.USER, userModel.getUsername()); - parameter.put(SessionParameter.PASSWORD, userModel.getPassword()); - parameter.put(SessionParameter.BROWSER_URL, urlPath); - parameter.put(SessionParameter.BINDING_TYPE, bindingType); - LOG.info("Using binding type [{}] to [{}] and credentials: {}", bindingType, urlPath, userModel.toString()); - List repositories = factory.getRepositories(parameter); - parameter.put(SessionParameter.REPOSITORY_ID, repositories.get(0).getId()); - session = repositories.get(0).createSession(); - setTestUser(userModel); - return this; - } - - @Override - public CmisWrapper disconnect() - { - if (session != null) - { - getSession().clear(); - } - return this; - } - - @Override - public String buildPath(String parent, String... paths) - { - return Utility.convertBackslashToSlash(super.buildPath(parent, paths)).replace("//", "/"); - } - - /** - * Get the current session - * - * @return Session - */ - public synchronized Session getSession() - { - return session; - } - - @Override - public CmisWrapper createFile(FileModel fileModel) throws Exception - { - return createFile(fileModel, BaseTypeId.CMIS_DOCUMENT.value(), VersioningState.MAJOR); - } - - /** - * Create a new file - * - * @param fileModel {@link FileModel} file model to be created - * @param versioningState {@link VersioningState} - * @return CmisWrapper - * @throws Exception if error - */ - public CmisWrapper createFile(FileModel fileModel, VersioningState versioningState) throws Exception - { - return createFile(fileModel, BaseTypeId.CMIS_DOCUMENT.value(), versioningState); - } - - /** - * Create a new file - * - * @param fileModel {@link FileModel} file model to be created - * @param cmisBaseTypeId base type id (e.g. 'cmis:document') - * @param versioningState {@link VersioningState} - * @return CmisWrapper - * @throws Exception if error - */ - public CmisWrapper createFile(FileModel fileModel, String cmisBaseTypeId, VersioningState versioningState) throws Exception - { - return createFile(fileModel, withCMISUtil().getProperties(fileModel, cmisBaseTypeId), versioningState); - } - - public CmisWrapper createFile(FileModel fileModel, Map properties, VersioningState versioningState) throws Exception - { - ContentStream contentStream = dataContent.getContentStream(fileModel.getName(), fileModel.getContent()); - STEP(String.format("%s Create file '%s' in '%s'", STEP_PREFIX, fileModel.getName(), getCurrentSpace())); - Document doc = null; - try - { - doc = withCMISUtil().getCmisFolder(getCurrentSpace()).createDocument(properties, contentStream, versioningState); - } - catch (CmisStorageException | CmisRuntimeException re) - { - doc = withCMISUtil().getCmisFolder(getCurrentSpace()).createDocument(properties, contentStream, versioningState); - } - fileModel.setNodeRef(doc.getId()); - String location = buildPath(getCurrentSpace(), fileModel.getName()); - setLastResource(location); - fileModel.setProtocolLocation(location); - fileModel.setCmisLocation(location); - dataContent.closeContentStream(contentStream); - return this; - } - - /** - * Create new file from existing one (that was set in last resource) - * - * @param newfileModel {@link FileModel} file model to be created - * @param sourceFileModel {@link ContentModel} source file model - * @return CmisWrapper - * @throws Exception if error - */ - public CmisWrapper createFileFromSource(FileModel newfileModel, ContentModel sourceFileModel) throws Exception - { - return createFileFromSource(newfileModel, sourceFileModel, BaseTypeId.CMIS_DOCUMENT.value()); - } - - /** - * Create new file from existing one with versioning state set to Major(that was set in last resource) - * - * @param newfileModel {@link FileModel} file model to be created - * @param sourceFileModel {@link ContentModel} source file model - * @param cmisBaseTypeId base type id (e.g. 'cmis:document') - * @return CmisWrapper - * @throws Exception if error - */ - public CmisWrapper createFileFromSource(FileModel newfileModel, ContentModel sourceFileModel, String cmisBaseTypeId) throws Exception - { - return createFileFromSource(newfileModel, sourceFileModel, cmisBaseTypeId, VersioningState.MAJOR); - } - - /** - * Create new file from existing one (that was set in last resource) - * - * @param newfileModel {@link FileModel} file model to be created - * @param sourceFileModel {@link ContentModel} source file model - * @param versioningState version(e.g. 'VersioningState.MAJOR') - * @return CmisWrapper - * @throws Exception if error - */ - public CmisWrapper createFileFromSource(FileModel newfileModel, ContentModel sourceFileModel, VersioningState versioningState) throws Exception - { - return createFileFromSource(newfileModel, sourceFileModel, BaseTypeId.CMIS_DOCUMENT.value(), versioningState); - } - - /** - * Create new file from existing one (that was set in last resource) - * - * @param newfileModel {@link FileModel} file model to be created - * @param sourceFileModel {@link ContentModel} source file model - * @param cmisBaseTypeId base type id (e.g. 'cmis:document') - * @param versioningState (e.g. 'VersioningState.MAJOR') - * @return CmisWrapper - * @throws Exception if error - */ - public CmisWrapper createFileFromSource(FileModel newfileModel, ContentModel sourceFileModel, String cmisBaseTypeId, VersioningState versioningState) - throws Exception - { - String resourcePath = getLastResource(); - STEP(String.format("%s Create new file '%s' from source '%s' in '%s'", STEP_PREFIX, newfileModel.getName(), sourceFileModel.getName(), resourcePath)); - Document source = withCMISUtil().getCmisDocument(sourceFileModel.getCmisLocation()); - Map properties = withCMISUtil().getProperties(newfileModel, cmisBaseTypeId); - Document doc = withCMISUtil().getCmisFolder(resourcePath).createDocumentFromSource(source, properties, versioningState); - doc.refresh(); - newfileModel.setNodeRef(doc.getId()); - String location = buildPath(resourcePath, doc.getName()); - setLastResource(location); - newfileModel.setProtocolLocation(location); - newfileModel.setCmisLocation(location); - return this; - } - - @Override - public CmisWrapper createFolder(FolderModel folderModel) throws Exception - { - return createFolder(folderModel, BaseTypeId.CMIS_FOLDER.value()); - } - - public CmisWrapper createFolder(FolderModel folderModel, String cmisBaseTypeId) throws Exception - { - Map properties = withCMISUtil().getProperties(folderModel, cmisBaseTypeId); - createFolder(folderModel, properties); - return this; - } - - public CmisWrapper createFolder(FolderModel folderModel, Map properties) throws Exception - { - STEP(String.format("%s Create folder '%s' in '%s'", STEP_PREFIX, folderModel.getName(), getCurrentSpace())); - Folder folder = withCMISUtil().getCmisFolder(getCurrentSpace()).createFolder(properties); - String location = buildPath(getCurrentSpace(), folderModel.getName()); - setLastResource(location); - folderModel.setProtocolLocation(location); - folderModel.setCmisLocation(location); - folderModel.setNodeRef(folder.getId()); - return this; - } - - /** - * Deletes this folder and all subfolders with all versions and continue on failure - * - * @return current wrapper - * @throws Exception - */ - public CmisWrapper deleteFolderTree() throws Exception - { - return deleteFolderTree(true, UnfileObject.DELETE, true); - } - - /** - * Deletes this folder and all subfolders with specific parameters - * - * @param allVersions - * @param unfile {@link UnfileObject} - * @param continueOnFailure - * @return current wrapper - * @throws Exception - */ - public CmisWrapper deleteFolderTree(boolean allVersions, UnfileObject unfile, boolean continueOnFailure) throws Exception - { - String path = getLastResource(); - Folder parent = withCMISUtil().getCmisFolder(Utility.convertBackslashToSlash(new File(path).getParent())); - STEP(String.format("%s Delete parent folder from '%s'", STEP_PREFIX, path)); - Folder folder = withCMISUtil().getCmisFolder(path); - folder.refresh(); - deleteTreeFailedObjects.clear(); - deleteTreeFailedObjects = folder.deleteTree(allVersions, unfile, continueOnFailure); - for (String failedObj : deleteTreeFailedObjects) - { - LOG.error(String.format("Failed to delete object %s", failedObj)); - } - if (!deleteTreeFailedObjects.isEmpty()) - { - LOG.info(String.format("Retry: delete parent folder from %s", path)); - Utility.waitToLoopTime(2); - folder.refresh(); - folder.deleteTree(allVersions, unfile, continueOnFailure); - } - else - { - parent.refresh(); - dataContent.waitUntilContentIsDeleted(path); - } - return this; - } - - @Override - public String getRootPath() throws TestConfigurationException - { - return "/"; - } - - @Override - public String getSitesPath() throws TestConfigurationException - { - return String.format("%s/%s", getPrefixSpace(), "Sites"); - } - - @Override - public String getUserHomesPath() throws TestConfigurationException - { - return String.format("%s/%s", getPrefixSpace(), "User Homes"); - } - - @Override - public String getDataDictionaryPath() throws TestConfigurationException - { - return String.format("%s/%s", getPrefixSpace(), "Data Dictionary"); - } - - public String getSharedPath() throws TestConfigurationException - { - return String.format("%s/%s", getPrefixSpace(), "Shared"); - } - - @Override - public CmisWrapper usingSite(String siteId) throws Exception - { - STEP(String.format("%s Navigate to site '%s/%s'", STEP_PREFIX, siteId, "documentLibrary")); - checkObjectIsInitialized(siteId, "SiteID"); - setCurrentSpace(buildSiteDocumentLibraryPath(siteId, "")); - return this; - } - - @Override - public CmisWrapper usingSite(SiteModel siteModel) throws Exception - { - STEP(String.format("%s Navigate to site '%s/%s'", STEP_PREFIX, siteModel.getId(), "documentLibrary")); - checkObjectIsInitialized(siteModel, "SiteModel"); - String path = buildSiteDocumentLibraryPath(siteModel.getId(), ""); - setCurrentSpace(path); - return this; - } - - @Override - public CmisWrapper usingUserHome(String username) throws Exception - { - STEP(String.format("%s Navigate to 'User Home' folder", STEP_PREFIX)); - checkObjectIsInitialized(username, "username"); - setCurrentSpace(buildUserHomePath(username, "")); - return this; - } - - @Override - public CmisWrapper usingUserHome() throws Exception - { - STEP(String.format("%s Navigate to 'User Home' folder", STEP_PREFIX)); - checkObjectIsInitialized(getTestUser().getUsername(), "username"); - setCurrentSpace(buildUserHomePath(getTestUser().getUsername(), "")); - return this; - } - - public CmisWrapper usingShared() throws Exception - { - STEP(String.format("%s Navigate to 'Shared' folder", STEP_PREFIX)); - setCurrentSpace(getSharedPath()); - return this; - } - - @Override - public CmisWrapper usingResource(ContentModel model) throws Exception - { - STEP(String.format("%s Navigate to '%s'", STEP_PREFIX, model.getName())); - checkObjectIsInitialized(model, "contentName"); - setCurrentSpace(model.getCmisLocation()); - return this; - } - - @Override - protected String getProtocolJMXConfigurationStatus() throws Exception - { - return ""; - } - - @Override - public String getPrefixSpace() - { - return ""; - } - - @Override - public CmisWrapper rename(String newName) throws Exception - { - String resourcePath = getLastResource(); - CmisObject objToRename = withCMISUtil().getCmisObject(resourcePath); - STEP(String.format("%s Rename '%s' to '%s'", STEP_PREFIX, objToRename.getName(), newName)); - objToRename.rename(newName); - setLastResource(buildPath(new File(resourcePath).getParent(), newName)); - return this; - } - - @Override - public CmisWrapper update(String content) throws Exception - { - return update(content, true); - } - - public CmisWrapper update(String content, boolean isLastChunk) throws Exception - { - Document doc = withCMISUtil().getCmisDocument(getLastResource()); - doc.refresh(); - Utility.waitToLoopTime(2); - STEP(String.format("%s Update content from '%s' by appending '%s'", STEP_PREFIX, doc.getName(), content)); - ContentStream contentStream = dataContent.getContentStream(doc.getName(), content); - doc.appendContentStream(contentStream, isLastChunk); - dataContent.closeContentStream(contentStream); - return this; - } - - /** - * Update the properties of the last resource {@link ContentModel}. - * Example updateProperty("cmis:name", "test1234") - * - * @param property - * @param value - * @return - * @throws Exception - */ - public CmisWrapper updateProperty(String property, Object value) throws Exception - { - String lastResource = getLastResource(); - CmisObject objSource = withCMISUtil().getCmisObject(lastResource); - STEP(String.format("%s Update '%s' property for '%s'", STEP_PREFIX, property, objSource.getName())); - Map properties = new HashMap<>(); - properties.put(property, value); - objSource.updateProperties(properties, true); - - if (property.equals("cmis:name")) - { - if (objSource instanceof Document) - { - setLastResource(buildPath(new File(getLastResource()).getParent(), objSource.getName())); - } - else if (objSource instanceof Folder) - { - setLastResource(buildPath(((Folder) objSource).getFolderParent().getPath(), value.toString())); - } - } - return this; - } - - @Override - public CmisWrapper delete() throws Exception - { - String resourcePath = getLastResource(); - STEP(String.format("%s Delete content from '%s'", STEP_PREFIX, resourcePath)); - withCMISUtil().getCmisObject(resourcePath).delete(); - return this; - } - - /** - * Deletes all versions if parameter is set to true, otherwise deletes only last version - * - * @param allVersions - * @return - * @throws Exception - */ - public CmisWrapper deleteAllVersions(boolean allVersions) throws Exception - { - String resourcePath = getLastResource(); - if (allVersions) - STEP(String.format("%s Delete all content '%s' versions", STEP_PREFIX, resourcePath)); - else - STEP(String.format("%s Delete only the last content '%s' version", STEP_PREFIX, resourcePath)); - withCMISUtil().getCmisObject(getLastResource()).delete(allVersions); - return this; - } - - /** - * Delete content stream - * - * @return - * @throws Exception - */ - public CmisWrapper deleteContent() throws Exception - { - String resourcePath = getLastResource(); - STEP(String.format("%s Delete document content from '%s'", STEP_PREFIX, resourcePath)); - withCMISUtil().getCmisDocument(getLastResource()).deleteContentStream(); - return this; - } - - /** - * Delete content stream and refresh document - * - * @param refresh boolean refresh resource - * @return - * @throws Exception - */ - public CmisWrapper deleteContent(boolean refresh) throws Exception - { - String resourcePath = getLastResource(); - STEP(String.format("%s Delete document content from '%s'", STEP_PREFIX, resourcePath)); - withCMISUtil().getCmisDocument(getLastResource()).deleteContentStream(refresh); - return this; - } - - /** - * Set the content stream for a document - * - * @param content String content to set - * @param overwrite - * @return - * @throws Exception - */ - public CmisWrapper setContent(String content, boolean overwrite) throws Exception - { - Utility.waitToLoopTime(1); - Document doc = withCMISUtil().getCmisDocument(getLastResource()); - doc.refresh(); - STEP(String.format("%s Set '%s' content to '%s' - node: %s", STEP_PREFIX, content, doc.getName(), doc.getId())); - ContentStream contentStream = dataContent.getContentStream(doc.getName(), content); - try - { - doc.setContentStream(contentStream, overwrite, true); - } - catch (CmisStorageException cs) - { - doc.setContentStream(contentStream, overwrite, true); - } - dataContent.closeContentStream(contentStream); - return this; - } - - /** - * Set the content stream for a document with overwrite set to TRUE - * - * @param content - * @return - * @throws Exception - */ - public CmisWrapper setContent(String content) throws Exception - { - return setContent(content, true); - } - - /** - * Create a 'R:cm:basis' relationship between a source document and a target document - * - * @param targetContent - * @return - * @throws Exception - */ - public CmisWrapper createRelationshipWith(ContentModel targetContent) throws Exception - { - return createRelationshipWith(targetContent, "R:cm:basis"); - } - - /** - * Create relationship between a source document and a target document - * - * @param targetContent {@link ContentModel} - * @param relationType - * @return - * @throws Exception - */ - public CmisWrapper createRelationshipWith(ContentModel targetContent, String relationType) throws Exception - { - STEP(String.format("%s Set %s relationship between source from '%s' and target '%s'", STEP_PREFIX, relationType, getLastResource(), - targetContent.getName())); - Map properties = new HashMap<>(); - properties.put(PropertyIds.OBJECT_TYPE_ID, relationType); - properties.put(PropertyIds.SOURCE_ID, withCMISUtil().getCmisObject(getLastResource()).getId()); - properties.put(PropertyIds.TARGET_ID, targetContent.getNodeRef()); - getSession().createRelationship(properties); - return this; - } - - /** - * Method allows you to file a document object in more than one folder. - * - * @param destination - the destination folder to which this document will be added - * @param allVersions - if this parameter is true, then all versions of the document will be added to the destination folder - * @return - * @throws Exception - */ - public CmisWrapper addDocumentToFolder(FolderModel destination, boolean allVersions) throws Exception - { - CmisObject objSource = withCMISUtil().getCmisObject(getLastResource()); - Folder objDestination = withCMISUtil().getCmisFolder(destination.getCmisLocation()); - STEP(String.format("%s Add object '%s' to '%s'", STEP_PREFIX, objSource.getName(), destination.getCmisLocation())); - ((FileableCmisObject) objSource).addToFolder(objDestination, allVersions); - setLastResource(buildPath(destination.getCmisLocation(), objSource.getName())); - return this; - } - - /** - * Method allows you to remove a document object from the given folder. - * - * @param parentFolder - the folder from which this object should be removed - * @return - * @throws Exception - */ - public CmisWrapper removeDocumentFromFolder(FolderModel parentFolder) throws Exception - { - CmisObject objSource = withCMISUtil().getCmisObject(getLastResource()); - Folder parentObj = withCMISUtil().getCmisFolder(parentFolder.getCmisLocation()); - STEP(String.format("%s Remove object '%s' from '%s'", STEP_PREFIX, objSource.getName(), parentFolder.getCmisLocation())); - ((FileableCmisObject) objSource).removeFromFolder(parentObj); - return this; - } - - /** - * Get child folders from a parent folder - * - * @return List - */ - @Override - public List getFolders() throws Exception - { - STEP(String.format("%s Get the folder children from '%s'", STEP_PREFIX, getLastResource())); - return withCMISUtil().getFolders(); - } - - /** - * Get child documents from a parent folder - * - * @return List - */ - @Override - public List getFiles() throws Exception - { - STEP(String.format("%s Get the file children from '%s'", STEP_PREFIX, getLastResource())); - return withCMISUtil().getFiles(); - } - - @Override - public CmisWrapper copyTo(ContentModel destination) throws Exception - { - String source = getLastResource(); - String sourceName = new File(source).getName(); - STEP(String.format("%s Copy '%s' to '%s'", STEP_PREFIX, sourceName, destination.getCmisLocation())); - CmisObject objSource = withCMISUtil().getCmisObject(source); - - CmisObject objDestination = withCMISUtil().getCmisObject(destination.getCmisLocation()); - if (objSource instanceof Document) - { - Document d = (Document) objSource; - d.copy(objDestination); - } - else if (objSource instanceof Folder) - { - Folder fFrom = (Folder) objSource; - Folder toFolder = (Folder) objDestination; - withCMISUtil().copyFolder(fFrom, toFolder); - } - setLastResource(buildPath(destination.getCmisLocation(), sourceName)); - return this; - } - - @Override - public CmisWrapper moveTo(ContentModel destination) throws Exception - { - String source = getLastResource(); - String sourceName = new File(source).getName(); - STEP(String.format("%s Move '%s' to '%s'", STEP_PREFIX, sourceName, destination.getCmisLocation())); - CmisObject objSource = withCMISUtil().getCmisObject(source); - CmisObject objDestination = withCMISUtil().getCmisObject(destination.getCmisLocation()); - if (objSource instanceof Document) - { - Document d = (Document) objSource; - List parents = d.getParents(); - CmisObject parent = getSession().getObject(parents.get(0).getId()); - d.move(parent, objDestination); - } - else if (objSource instanceof Folder) - { - Folder f = (Folder) objSource; - List parents = f.getParents(); - CmisObject parent = getSession().getObject(parents.get(0).getId()); - f.move(parent, objDestination); - } - setLastResource(buildPath(destination.getCmisLocation(), sourceName)); - return this; - } - - public RepositoryInfo getRepositoryInfo() - { - STEP(String.format("Get repository information for user %s", getCurrentUser().getUsername())); - return getSession().getRepositoryInfo(); - } - - public AclCapabilities getAclCapabilities() - { - return getRepositoryInfo().getAclCapabilities(); - } - - /** - * Checks out the document - */ - public CmisWrapper checkOut() - { - Document document = withCMISUtil().getCmisDocument(getLastResource()); - STEP(String.format("%s Check out document '%s'", STEP_PREFIX, document.getName())); - try - { - document.checkOut(); - } - catch (CmisRuntimeException e) - { - document.checkOut(); - } - return this; - } - - /** - * If this is a PWC (private working copy) the check out will be reversed. - */ - public CmisWrapper cancelCheckOut() - { - Document document = withCMISUtil().getCmisDocument(getLastResource()); - STEP(String.format("%s Cancel document '%s' check out", STEP_PREFIX, document.getName())); - document.cancelCheckOut(); - return this; - } - - /** - * Starts the process to check in a document - */ - public CheckIn prepareDocumentForCheckIn() - { - return new CheckIn(this); - } - - /** - * Reloads the resource from the repository - */ - public CmisWrapper refreshResource() - { - CmisObject cmisObject = withCMISUtil().getCmisObject(getLastResource()); - STEP(String.format("%s Reload '%s'", STEP_PREFIX, cmisObject.getName())); - cmisObject.refresh(); - return this; - } - - /** - * @return utilities that are used by CMIS - */ - public CmisUtil withCMISUtil() - { - return new CmisUtil(this); - } - - /** - * @return JMX DSL for this wrapper - */ - public JmxUtil withJMX() - { - return new JmxUtil(this, jmxBuilder.getJmxClient()); - } - - @Override - public CmisAssertion assertThat() - { - return new CmisAssertion(this); - } - - /** - * Starts the process to work with a version of a document - */ - public DocumentVersioning usingVersion() - { - return new DocumentVersioning(this, withCMISUtil().getCmisObject(getLastResource())); - } - - /** - * Add new permission for user - * - * @param user UserModel user - * @param role UserRole role to add - * @param aclPropagation AclPropagation propagation - * @return - */ - public CmisWrapper addAcl(UserModel user, UserRole role, AclPropagation aclPropagation) - { - STEP(String.format("%s Add permission '%s' for user %s ", STEP_PREFIX, role.name(), user.getUsername())); - withCMISUtil().getCmisObject(getLastResource(), withCMISUtil().setIncludeAclContext()).addAcl(withCMISUtil().createAce(user, role), aclPropagation); - return this; - } - - /** - * Add new permission for a group - * - * @param group GroupModel group - * @param role UserRole role to add - * @param aclPropagation AclPropagation propagation - * @return - */ - public CmisWrapper addAcl(GroupModel group, UserRole role, AclPropagation aclPropagation) - { - STEP(String.format("%s Add permission '%s' for user %s ", STEP_PREFIX, role.name(), group.getDisplayName())); - withCMISUtil().getCmisObject(getLastResource(), withCMISUtil().setIncludeAclContext()).addAcl(withCMISUtil().createAce(group, role), aclPropagation); - return this; - } - - /** - * Add new permission for a group - * - * @param group GroupModel group - * @param role UserRole role to add - * @return - */ - public CmisWrapper addAcl(GroupModel group, UserRole role) - { - return addAcl(group, role, null); - } - - /** - * Add new permissions to user - * - * @param user {@link UserModel} - * @param permissions to add ({@link PermissionMapping} can be used) - * @return - */ - public CmisWrapper addAcl(UserModel user, String... permissions) - { - withCMISUtil().getCmisObject(getLastResource(), withCMISUtil().setIncludeAclContext()).addAcl(withCMISUtil().createAce(user, permissions), null); - return this; - } - - /** - * Add new permission for user - * - * @param user UserModel user - * @param role UserRole role to add - * @return - */ - public CmisWrapper addAcl(UserModel user, UserRole role) - { - return addAcl(user, role, null); - } - - /** - * Update permission for user. - * If the role to remove is invalid a {@link CmisConstraintException} is thrown. - * - * @param user UserModel user - * @param newRole UserRole new role to add - * @param removeRole UserRole remove already added role - * @param aclPropagation AclPropagation - * @return - */ - public CmisWrapper applyAcl(UserModel user, UserRole newRole, UserRole removeRole, AclPropagation aclPropagation) - { - STEP(String.format("%s Edit permission for user %s from %s to %s ", STEP_PREFIX, user.getUsername(), removeRole.name(), newRole.name())); - withCMISUtil().getCmisObject(getLastResource(), withCMISUtil().setIncludeAclContext()).applyAcl(withCMISUtil().createAce(user, newRole), - withCMISUtil().createAce(user, removeRole), aclPropagation); - return this; - } - - /** - * Update permission for user. - * If the role to remove is invalid a {@link CmisConstraintException} is thrown. - * - * @param user UserModel user - * @param newRole UserRole new role to add - * @param removeRole UserRole remove already added role - * @return - */ - public CmisWrapper applyAcl(UserModel user, UserRole newRole, UserRole removeRole) - { - return applyAcl(user, newRole, removeRole, null); - } - - /** - * Update permission for user. - * If the permission to remove is invalid a {@link CmisConstraintException} is thrown. - * - * @param user {@link UserModel } - * @param newPermission permissions to add ({@link PermissionMapping} can be used) - * @param removePermission permissions to remove ({@link PermissionMapping} can be used) - * @return - */ - public CmisWrapper applyAcl(UserModel user, String newPermission, String removePermission) - { - STEP(String.format("%s Edit permission for user %s from %s to %s ", STEP_PREFIX, user.getUsername(), removePermission, newPermission)); - withCMISUtil().getCmisObject(getLastResource(), withCMISUtil().setIncludeAclContext()).applyAcl(withCMISUtil().createAce(user, newPermission), - withCMISUtil().createAce(user, removePermission), null); - return this; - } - - /** - * Remove permission from user - * - * @param user UserModel user - * @param removeRole UserRole role to remove - * @param aclPropagation AclPropagation - * @return - */ - public CmisWrapper removeAcl(UserModel user, UserRole removeRole, AclPropagation aclPropagation) - { - STEP(String.format("%s Remove permission '%s' from user %s ", STEP_PREFIX, removeRole.name(), user.getUsername())); - withCMISUtil().getCmisObject(getLastResource(), withCMISUtil().setIncludeAclContext()).removeAcl(withCMISUtil().createAce(user, removeRole), - aclPropagation); - return this; - } - - /** - * Remove permission from user - * - * @param user UserModel user - * @param removeRole UserRole role to remove - * @return - */ - public CmisWrapper removeAcl(UserModel user, UserRole removeRole) - { - return removeAcl(user, removeRole, null); - } - - public CmisWrapper removeAcl(UserModel user, String permissionToRemove) - { - STEP(String.format("%s Remove permission '%s' from user %s ", STEP_PREFIX, permissionToRemove, user.getUsername())); - withCMISUtil().getCmisObject(getLastResource(), withCMISUtil().setIncludeAclContext()).removeAcl(withCMISUtil().createAce(user, permissionToRemove), - null); - return this; - } - - /** - * Pass a string CMIS query, that will be handled by {@link QueryExecutor} using {@link org.apache.chemistry.opencmis.client.api.Session#query(String, boolean)} - * - * @param query - * @return {@link QueryExecutor} will all DSL assertions on returned restult - */ - public QueryExecutor withQuery(String query) - { - return new QueryExecutor(this, query); - } - - /** - * Use this method if the document is checked out. If not {@link CmisVersioningException} will be thrown. - * - * @return - * @throws Exception - */ - public CmisWrapper usingPWCDocument() throws Exception - { - STEP(String.format("%s Navigate to private working copy of content '%s'", STEP_PREFIX, withCMISUtil().getPWCFileModel().getName())); - setCurrentSpace(withCMISUtil().getPWCFileModel().getCmisLocation()); - return this; - } - - /** - * @param baseType - * @return the DSL of asserting BaseObject type children for example. - */ - public BaseObjectType usingObjectType(String baseType) - { - return new BaseObjectType(this, baseType); - } - - /** - * Create a new data list type - * - * @param dataListModel {@link DataListModel} - * @return - * @throws Exception - */ - public CmisWrapper createDataList(DataListModel dataListModel) throws Exception - { - Map properties = withCMISUtil().getProperties(dataListModel, "F:dl:dataList"); - properties.put("dl:dataListItemType", dataListModel.getDataListItemType()); - Folder folder = withCMISUtil().getCmisFolder(getCurrentSpace()).createFolder(properties); - String location = buildPath(getCurrentSpace(), dataListModel.getName()); - setLastResource(location); - dataListModel.setProtocolLocation(location); - dataListModel.setCmisLocation(location); - dataListModel.setNodeRef(folder.getId()); - return this; - } - - /** - * Create new data list item - * - * @param itemModel {@link DataListItemModel} - * @return - * @throws Exception - */ - public CmisWrapper createDataListItem(DataListItemModel itemModel) throws Exception - { - Map propertyMap = itemModel.getItemProperties(); - String name = (String) propertyMap.get(PropertyIds.NAME); - STEP(String.format("%s Create new data list item %s (type: %s)", STEP_PREFIX, name, propertyMap.get(PropertyIds.OBJECT_TYPE_ID))); - ObjectId itemId = getSession().createDocument(propertyMap, withCMISUtil().getCmisObject(getLastResource()), null, null); - String path = buildPath(getCurrentSpace(), name); - itemModel.setName(name); - itemModel.setCmisLocation(path); - itemModel.setProtocolLocation(path); - itemModel.setNodeRef(itemId.getId()); - setLastResource(path); - return this; - } - - /** - * Attach documents to existent item set in last resource - * - * @param documents {@link ContentModel} list of content to attach - * @return - */ - public CmisWrapper attachDocument(ContentModel... contents) - { - String itemId = withCMISUtil().getCmisObject(getLastResource()).getId(); - for (ContentModel content : contents) - { - STEP(String.format("Attach document %s to item %s", content.getName(), itemId)); - Map relProps = new HashMap(); - relProps.put(PropertyIds.OBJECT_TYPE_ID, "R:cm:attachments"); - relProps.put(PropertyIds.SOURCE_ID, itemId); - relProps.put(PropertyIds.TARGET_ID, content.getNodeRef()); - getSession().createRelationship(relProps); - } - return this; - } - - /** - * Assign user to existent item set in last resource - * - * @param user {@link UserModel} - * @param relationType e.g. R:dl:issueAssignedTo, R:dl:assignee, R:dl:taskAssignee - * @return - */ - public CmisWrapper assignToUser(UserModel user, String relationType) - { - Map relProps = new HashMap(); - relProps.put(PropertyIds.OBJECT_TYPE_ID, relationType); - relProps.put(PropertyIds.SOURCE_ID, withCMISUtil().getCmisObject(getLastResource()).getId()); - relProps.put(PropertyIds.TARGET_ID, withCMISUtil().getUserNodeRef(user)); - getSession().createRelationship(relProps); - return this; - } - - /** - * Add new secondary types - * - * @param secondaryTypes e.g. P:cm:effectivity, P:audio:audio, P:cm:dublincore - * @return - */ - public CmisWrapper addSecondaryTypes(String...secondaryTypes) - { - CmisObject object = withCMISUtil().getCmisObject(getLastResource()); - List secondaryTypesNew = new ArrayList(); - for(SecondaryType oldType : object.getSecondaryTypes()) - { - secondaryTypesNew.add(oldType.getId()); - } - for(String newType : secondaryTypes) - { - secondaryTypesNew.add(newType); - } - Map properties = new HashMap(); - properties.put(PropertyIds.SECONDARY_OBJECT_TYPE_IDS, secondaryTypesNew); - object.updateProperties(properties); - return this; - } -} diff --git a/e2e-test/src/main/java/org/alfresco/cmis/dsl/BaseObjectType.java b/e2e-test/src/main/java/org/alfresco/cmis/dsl/BaseObjectType.java deleted file mode 100644 index b5f1787f0..000000000 --- a/e2e-test/src/main/java/org/alfresco/cmis/dsl/BaseObjectType.java +++ /dev/null @@ -1,185 +0,0 @@ -package org.alfresco.cmis.dsl; - -import static org.alfresco.utility.report.log.Step.STEP; - -import java.util.Iterator; -import java.util.List; - -import org.alfresco.cmis.CmisWrapper; -import org.alfresco.utility.LogFactory; -import org.apache.chemistry.opencmis.client.api.ItemIterable; -import org.apache.chemistry.opencmis.client.api.ObjectType; -import org.apache.chemistry.opencmis.client.api.Tree; -import org.apache.chemistry.opencmis.client.runtime.objecttype.ObjectTypeHelper; -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.commons.lang3.builder.ToStringStyle; -import org.slf4j.Logger; -import org.testng.Assert; - -/** - * DSL for preparing calls on getting the type children of a type. - */ -public class BaseObjectType -{ - private CmisWrapper cmisAPI; - private String baseTypeID; - private boolean includePropertyDefinition = false; - private Logger LOG = LogFactory.getLogger(); - - public BaseObjectType(CmisWrapper cmisAPI, String baseTypeID) - { - this.cmisAPI = cmisAPI; - this.baseTypeID = baseTypeID; - } - - public BaseObjectType withPropertyDefinitions() - { - this.includePropertyDefinition = true; - return this; - } - - public BaseObjectType withoutPropertyDefinitions() - { - this.includePropertyDefinition = false; - return this; - } - - /** - * Example of objectTypeID: - * "D:trx:transferReport" - see {@link ObjectTypeHelper} "D:trx:tempTransferStore" - * "D:imap:imapAttach" - * - * @param objectTypeID - */ - public PropertyDefinitionObject hasChildren(String objectTypeID) - { - return checkChildren(objectTypeID, true); - } - - /** - * Example of objectTypeID: - * "D:trx:transferReport" - see {@link ObjectTypeHelper} "D:trx:tempTransferStore" - * "D:imap:imapAttach" - * - * @param objectTypeID - */ - public CmisWrapper doesNotHaveChildren(String objectTypeID) - { - checkChildren(objectTypeID, false); - return cmisAPI; - } - - /** - * Example of objectTypeID: - * "D:trx:transferReport" - see {@link ObjectTypeHelper} "D:trx:tempTransferStore" - * "D:imap:imapAttach" - * - * @param objectTypeID - */ - private PropertyDefinitionObject checkChildren(String objectTypeID, boolean exist) - { - ItemIterable values = cmisAPI.withCMISUtil().getTypeChildren(this.baseTypeID, includePropertyDefinition); - boolean foundChild = false; - PropertyDefinitionObject propDefinition = null; - for (Iterator iterator = values.iterator(); iterator.hasNext();) - { - ObjectType type = (ObjectType) iterator.next(); - LOG.info("Found child Object Type: {}", ToStringBuilder.reflectionToString(type, ToStringStyle.MULTI_LINE_STYLE)); - if (type.getId().equals(objectTypeID)) - { - foundChild = true; - propDefinition = new PropertyDefinitionObject(type); - break; - } - } - Assert.assertEquals(foundChild, exist, - String.format("Object Type with ID[%s] is found as children for Parent Type: [%s]", objectTypeID, this.baseTypeID)); - return propDefinition; - } - - public class PropertyDefinitionObject - { - ObjectType type; - - public PropertyDefinitionObject(ObjectType type) - { - this.type = type; - } - - public PropertyDefinitionObject propertyDefinitionIsEmpty() - { - STEP(String.format("%s Verify that property definitions map is empty.", CmisWrapper.STEP_PREFIX)); - Assert.assertTrue(type.getPropertyDefinitions().isEmpty(), "Property definitions is empty."); - return this; - } - - public PropertyDefinitionObject propertyDefinitionIsNotEmpty() - { - STEP(String.format("%s Verify that property definitions map is not empty.", CmisWrapper.STEP_PREFIX)); - Assert.assertFalse(type.getPropertyDefinitions().isEmpty(), "Property definitions is not empty."); - return this; - } - } - - private CmisWrapper checkDescendents(int depth, boolean exist, String... objectTypeIDs) - { - List> values = cmisAPI.withCMISUtil().getTypeDescendants(this.baseTypeID, depth, includePropertyDefinition); - for (String objectTypeID : objectTypeIDs) - { - boolean foundChild = false; - for (Tree tree : values) - { - if (tree.getItem().getId().equals(objectTypeID)) - { - foundChild = true; - break; - } - } - Assert.assertEquals(foundChild, exist, - String.format("Assert %b: Descendant [%s] is found as descendant for Type: [%s]", exist, objectTypeID, this.baseTypeID)); - - if (foundChild) - { - STEP(String.format("%s Cmis object '%s' is found as descendant.", CmisWrapper.STEP_PREFIX, objectTypeID)); - } - else - { - STEP(String.format("%s Cmis object '%s' is NOT found as descendant.", CmisWrapper.STEP_PREFIX, objectTypeID)); - } - } - return cmisAPI; - } - - /** - * Assert that specified descendantType is present in the depth of tree - * Depth can be -1 or >= 1 - * Example of objectTypeID: - * "D:trx:transferReport" - see {@link ObjectTypeHelper} "D:trx:tempTransferStore" - * "D:imap:imapAttach" - * - * @param objectTypeID - * @param depth - * @return - */ - public CmisWrapper hasDescendantType(int depth, String... objectTypeIDs) - { - return checkDescendents(depth, true, objectTypeIDs); - } - - /** - * Assert that specified descendantType is NOT present in the depth of tree - * Depth can be -1 or >= 1 - * Example of objectTypeID: - * "D:trx:transferReport" - see {@link ObjectTypeHelper} "D:trx:tempTransferStore" - * "D:imap:imapAttach" - * - * @param objectTypeID - * @param depth - * @return - */ - public CmisWrapper doesNotHaveDescendantType(int depth, String... objectTypeIDs) - { - checkDescendents(depth, false, objectTypeIDs); - return cmisAPI; - } -} diff --git a/e2e-test/src/main/java/org/alfresco/cmis/dsl/CheckIn.java b/e2e-test/src/main/java/org/alfresco/cmis/dsl/CheckIn.java deleted file mode 100644 index 1dbcc3f3d..000000000 --- a/e2e-test/src/main/java/org/alfresco/cmis/dsl/CheckIn.java +++ /dev/null @@ -1,78 +0,0 @@ -package org.alfresco.cmis.dsl; - -import org.alfresco.cmis.CmisWrapper; -import org.alfresco.utility.Utility; -import org.apache.chemistry.opencmis.client.api.Document; -import org.apache.chemistry.opencmis.commons.data.ContentStream; -import org.apache.chemistry.opencmis.commons.exceptions.CmisStorageException; - -import java.util.Map; - -/** - * DSL pertaining only to check in a {@link Document} - */ -public class CheckIn -{ - private CmisWrapper cmisWrapper; - private boolean version; - private Map properties; - private String content; - private String comment; - - public CheckIn(CmisWrapper cmisWrapper) - { - this.cmisWrapper = cmisWrapper; - } - - public CheckIn withMajorVersion() - { - this.version = true; - return this; - } - - public CheckIn withMinorVersion() - { - this.version = false; - return this; - } - - public CheckIn withContent(String content) - { - this.content = content; - return this; - } - - public CheckIn withoutComment() - { - this.comment = null; - return this; - } - - public CheckIn withComment(String comment) - { - this.comment = comment; - return this; - } - - public CmisWrapper checkIn() throws Exception - { - return checkIn(properties); - } - - public CmisWrapper checkIn(Map properties) throws Exception - { - ContentStream contentStream = cmisWrapper.withCMISUtil().getContentStream(content); - try - { - Document pwc = cmisWrapper.withCMISUtil().getPWCDocument(); - pwc.refresh(); - Utility.waitToLoopTime(2); - pwc.checkIn(version, properties, contentStream, comment); - } - catch(CmisStorageException st) - { - cmisWrapper.withCMISUtil().getPWCDocument().checkIn(version, properties, contentStream, comment); - } - return cmisWrapper; - } -} diff --git a/e2e-test/src/main/java/org/alfresco/cmis/dsl/CmisAssertion.java b/e2e-test/src/main/java/org/alfresco/cmis/dsl/CmisAssertion.java deleted file mode 100644 index 8fd4267fd..000000000 --- a/e2e-test/src/main/java/org/alfresco/cmis/dsl/CmisAssertion.java +++ /dev/null @@ -1,1153 +0,0 @@ -package org.alfresco.cmis.dsl; - -import static org.alfresco.utility.report.log.Step.STEP; - -import java.io.File; -import java.util.ArrayList; -import java.util.Date; -import java.util.GregorianCalendar; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.alfresco.cmis.CmisWrapper; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.dsl.DSLAssertion; -import org.alfresco.utility.exception.TestConfigurationException; -import org.alfresco.utility.model.ContentModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.GroupModel; -import org.alfresco.utility.model.UserModel; -import org.apache.chemistry.opencmis.client.api.ChangeEvent; -import org.apache.chemistry.opencmis.client.api.CmisObject; -import org.apache.chemistry.opencmis.client.api.Document; -import org.apache.chemistry.opencmis.client.api.Folder; -import org.apache.chemistry.opencmis.client.api.ItemIterable; -import org.apache.chemistry.opencmis.client.api.ObjectType; -import org.apache.chemistry.opencmis.client.api.OperationContext; -import org.apache.chemistry.opencmis.client.api.Property; -import org.apache.chemistry.opencmis.client.api.Relationship; -import org.apache.chemistry.opencmis.client.api.Rendition; -import org.apache.chemistry.opencmis.client.api.SecondaryType; -import org.apache.chemistry.opencmis.client.api.Session; -import org.apache.chemistry.opencmis.client.runtime.OperationContextImpl; -import org.apache.chemistry.opencmis.commons.data.Ace; -import org.apache.chemistry.opencmis.commons.data.Acl; -import org.apache.chemistry.opencmis.commons.data.CmisExtensionElement; -import org.apache.chemistry.opencmis.commons.enums.Action; -import org.apache.chemistry.opencmis.commons.enums.ChangeType; -import org.apache.chemistry.opencmis.commons.enums.ExtensionLevel; -import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships; -import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException; -import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException; -import org.apache.commons.lang3.StringUtils; -import org.testng.Assert; - -/** - * DSL with all assertion available for {@link CmisWrapper} - */ -public class CmisAssertion extends DSLAssertion -{ - public static String STEP_PREFIX = "CMIS:"; - - public CmisAssertion(CmisWrapper cmisAPI) - { - super(cmisAPI); - } - - public CmisWrapper cmisAPI() - { - return getProtocol(); - } - - @Override - public CmisWrapper existsInRepo() - { - STEP(String.format("CMIS: Assert that content '%s' exists in repository", cmisAPI().getLastResource())); - Assert.assertTrue(!cmisAPI().withCMISUtil().getCmisObject(cmisAPI().getLastResource()).getId().isEmpty(), - String.format("Content {%s} was found in repository", cmisAPI().getLastResource())); - return cmisAPI(); - } - - @Override - public CmisWrapper doesNotExistInRepo() - { - STEP(String.format("CMIS: Assert that content '%s' does not exist in repository", cmisAPI().getLastResource())); - boolean notFound = false; - try - { - cmisAPI().getSession().clear(); - cmisAPI().withCMISUtil().getCmisObject(cmisAPI().getLastResource()); - } - catch (CmisObjectNotFoundException | CmisRuntimeException e) - { - notFound = true; - } - Assert.assertTrue(notFound, String.format("Content {%s} was NOT found in repository", cmisAPI().getLastResource())); - return cmisAPI(); - } - - /** - * Verify changes for a specific object from cmis log - * - * @param model {@link ContentModel} - * @param changeTypes {@link ChangeType} - * @return - * @throws Exception - */ - public CmisWrapper contentModelHasChanges(ContentModel model, ChangeType... changeTypes) throws Exception - { - String token = cmisAPI().getRepositoryInfo().getLatestChangeLogToken(); - if (StringUtils.isEmpty(token)) - { - throw new TestConfigurationException("Please enable CMIS audit"); - } - ItemIterable events = cmisAPI().getSession().getContentChanges(token, true); - String lastObjectId = model.getNodeRef(); - boolean isChange = false; - for (ChangeType changeType : changeTypes) - { - STEP(String.format("%s Verify action %s for content: %s", CmisWrapper.STEP_PREFIX, changeType, model.getName())); - isChange = false; - for (ChangeEvent event : events) - { - if (event.getObjectId().equals(lastObjectId)) - { - if (changeType == event.getChangeType()) - { - isChange = true; - break; - } - } - } - Assert.assertTrue(isChange, String.format("Action %s for content: '%s' was found", changeType, model.getName())); - } - return cmisAPI(); - } - - /** - * Verify that a specific object does not have changes from cmis log - * - * @param model {@link ContentModel} - * @param changeTypes {@link ChangeType} - * @return - * @throws Exception - */ - public CmisWrapper contentModelDoesnotHaveChangesWithWrongToken(ContentModel model, ChangeType... changeTypes) throws Exception - { - String token = cmisAPI().getRepositoryInfo().getLatestChangeLogToken(); - if (StringUtils.isEmpty(token)) - { - throw new TestConfigurationException("Please enable CMIS audit"); - } - ItemIterable events = cmisAPI().getSession().getContentChanges(token + 1, true); - String lastObjectId = model.getNodeRef(); - boolean isChange = false; - for (ChangeType changeType : changeTypes) - { - STEP(String.format("%s Verify action %s for content: %s", CmisWrapper.STEP_PREFIX, changeType, model.getName())); - isChange = false; - for (ChangeEvent event : events) - { - if (event.getObjectId().equals(lastObjectId)) - { - if (changeType == event.getChangeType()) - { - isChange = true; - break; - } - } - } - Assert.assertFalse(isChange, String.format("Action %s for content: '%s' was found", changeType, model.getName())); - } - return cmisAPI(); - } - - /** - * Check if the {@link #getLastResource()} has the list of {@link Action} Example: - * {code} - * .hasAllowableActions(Action.CAN_CREATE_FOLDER); - * {code} - * - * @param actions - * @return - */ - public CmisWrapper hasAllowableActions(Action... actions) - { - CmisObject cmisObject = cmisAPI().withCMISUtil().getCmisObject(cmisAPI().getLastResource()); - for (Action action : actions) - { - STEP(String.format("%s Verify if object %s has allowable action %s", CmisWrapper.STEP_PREFIX, cmisObject.getName(), action.name())); - Assert.assertTrue(cmisObject.hasAllowableAction(action), String.format("Object %s does not have action %s", cmisObject.getName(), action.name())); - } - return cmisAPI(); - } - - /** - * Check if {@link #getLastResource()} object has actions returned - * from {@link org.apache.chemistry.opencmis.client.api.CmisObject#getAllowableActions()} - * - * @param actions - * @return - */ - public CmisWrapper isAllowableActionInList(Action... actions) - { - List currentActions = cmisAPI().withCMISUtil().getAllowableActions(); - for (Action action : actions) - { - STEP(String.format("%s Verify that action '%s' exists", CmisWrapper.STEP_PREFIX, action.name())); - Assert.assertTrue(currentActions.contains(action), String.format("Action %s was found", action.name())); - } - return cmisAPI(); - } - - /** - * Check if the {@link #getLastResource()) does not have the list of {@link Action} Example: - * {code} - * .doesNotHaveAllowableActions(Action.CAN_CREATE_FOLDER); - * {code} - * - * @param actions - * @return - */ - public CmisWrapper doesNotHaveAllowableActions(Action... actions) - { - CmisObject cmisObject = cmisAPI().withCMISUtil().getCmisObject(cmisAPI().getLastResource()); - for (Action action : actions) - { - STEP(String.format("%s Verify if object %s does not have allowable action %s", CmisWrapper.STEP_PREFIX, cmisObject.getName(), action.name())); - Assert.assertFalse(cmisObject.hasAllowableAction(action), String.format("Object %s does not have action %s", cmisObject.getName(), action.name())); - } - return cmisAPI(); - } - - /** - * Verify document content - * - * @param content String expected content - * @return - * @throws Exception - */ - public CmisWrapper contentIs(String content) throws Exception - { - STEP(String.format("%s Verify if content '%s' is the expected one", CmisWrapper.STEP_PREFIX, content)); - Assert.assertEquals(cmisAPI().withCMISUtil().getDocumentContent(), content, - String.format("The content of file %s - is the expected one", cmisAPI().getLastResource())); - return cmisAPI(); - } - - /** - * Verify document content contains specific details - * - * @param content String expected content - * @return - * @throws Exception - */ - public CmisWrapper contentContains(String content) throws Exception - { - STEP(String.format("%s Verify if content '%s' is the expected one", CmisWrapper.STEP_PREFIX, content)); - Assert.assertTrue(cmisAPI().withCMISUtil().getDocumentContent().contains(content), - String.format("The content of file %s - is the expected one", cmisAPI().getLastResource())); - return cmisAPI(); - } - - /** - * Verify if current resource has the id given - * - * @param id - expected object id - * @return - */ - public CmisWrapper objectIdIs(String id) - { - CmisObject objSource = cmisAPI().withCMISUtil().getCmisObject(cmisAPI().getLastResource()); - STEP(String.format("%s Verify if '%s' object has '%s' id", CmisWrapper.STEP_PREFIX, objSource.getName(), id)); - Assert.assertEquals(objSource.getId(), id, "Object has id."); - return cmisAPI(); - } - - /** - * Verify the value of the given property - * - * @param property - the property id - * @param value - expected property value - * @return - */ - public CmisWrapper contentPropertyHasValue(String property, String value) - { - CmisObject objSource = cmisAPI().withCMISUtil().getCmisObject(cmisAPI().getLastResource()); - STEP(String.format("%s Verify if '%s' property for '%s' content has '%s' value", CmisWrapper.STEP_PREFIX, property, objSource.getName(), value)); - Object propertyValue = objSource.getPropertyValue(property); - if (propertyValue instanceof ArrayList) - { - @SuppressWarnings({ "unchecked", "rawtypes" }) - ArrayList values = (ArrayList) propertyValue; - Assert.assertEquals(values.get(0).toString(), value, "Property has value."); - } - else - { - Assert.assertEquals(propertyValue.toString(), value, "Property has value."); - } - return cmisAPI(); - } - - /** - * Verify if {@link Document} is checked out - * - * @return - */ - public CmisWrapper documentIsCheckedOut() - { - Document document = cmisAPI().withCMISUtil().getCmisDocument(cmisAPI().getLastResource()); - STEP(String.format("%s Verify if document '%s' is checked out", CmisWrapper.STEP_PREFIX, document.getName())); - Assert.assertTrue(document.isVersionSeriesCheckedOut(), "Document is checkedout"); - return cmisAPI(); - } - - /** - * Verify if {@link Document} is private working copy (pwc) - * - * @return - */ - public CmisWrapper isPrivateWorkingCopy() - { - Document document = cmisAPI().withCMISUtil().getCmisDocument(cmisAPI().getLastResource()); - STEP(String.format("%s Verify if document '%s' is private working copy", CmisWrapper.STEP_PREFIX, document.getName())); - Assert.assertTrue(cmisAPI().withCMISUtil().isPrivateWorkingCopy()); - return cmisAPI(); - } - - /** - * Verify that {@link Document} is not private working copy (pwc) - * - * @return - */ - public CmisWrapper isNotPrivateWorkingCopy() - { - Document document = cmisAPI().withCMISUtil().getCmisDocument(cmisAPI().getLastResource()); - STEP(String.format("%s Verify if document '%s' PWC is not private working copy", CmisWrapper.STEP_PREFIX, document.getName())); - Assert.assertFalse(cmisAPI().withCMISUtil().isPrivateWorkingCopy()); - return cmisAPI(); - } - - /** - * Verify that {@link Document} is not checked out - * - * @return - */ - public CmisWrapper documentIsNotCheckedOut() - { - Document document = cmisAPI().withCMISUtil().getCmisDocument(cmisAPI().getLastResource()); - STEP(String.format("%s Verify if document '%s' is not checked out", CmisWrapper.STEP_PREFIX, document.getName())); - Assert.assertFalse(document.isVersionSeriesCheckedOut(), "Document is not checked out"); - return cmisAPI(); - } - - /** - * Verify if there is a relationship between current resource and the given target - * - * @param targetContent - * @return - */ - public CmisWrapper objectHasRelationshipWith(ContentModel targetContent) - { - OperationContext oc = new OperationContextImpl(); - oc.setIncludeRelationships(IncludeRelationships.SOURCE); - - CmisObject source = cmisAPI().withCMISUtil().getCmisObject(cmisAPI().getLastResource(), oc); - CmisObject target = cmisAPI().withCMISUtil().getCmisObject(targetContent.getCmisLocation()); - - STEP(String.format("%s Verify if source '%s' has relationship with '%s'", CmisWrapper.STEP_PREFIX, source.getName(), target.getName())); - List relTargetIds = new ArrayList<>(); - for (Relationship rel : source.getRelationships()) - { - relTargetIds.add(rel.getTarget().getId()); - } - Assert.assertTrue(relTargetIds.contains(target.getId()), - String.format("Relationship is created between source '%s' and target '%s'.", source.getName(), target.getName())); - return cmisAPI(); - } - - /** - * Verify document has version - * - * @param version String expected version - * @return - * @throws Exception - */ - public CmisWrapper documentHasVersion(double version) throws Exception - { - Document document = cmisAPI().withCMISUtil().getCmisDocument(cmisAPI().getLastResource()); - document.refresh(); - STEP(String.format("%s Verify if document '%s' has version '%s'", CmisWrapper.STEP_PREFIX, document.getName(), version)); - Assert.assertEquals(Double.parseDouble(document.getVersionLabel()), version, "File has version"); - return cmisAPI(); - } - - /** - * Verify parent from the {@link Folder} set as last resource - * - * @param contentModel - * @return - */ - public CmisWrapper folderHasParent(ContentModel contentModel) - { - STEP(String.format("%s Verify folder %s has parent %s", CmisWrapper.STEP_PREFIX, cmisAPI().getLastResource(), contentModel.getName())); - Assert.assertEquals(cmisAPI().withCMISUtil().getFolderParent().getName(), contentModel.getName(), "Folder name is not the expected one"); - return cmisAPI(); - } - - /** - * Verify base type id - * - * @param baseTypeId String expected object type value - * @return - * @throws Exception - */ - public CmisWrapper baseTypeIdIs(String baseTypeId) throws Exception - { - STEP(String.format("%s Verify if base object type '%s' is the expected one", CmisWrapper.STEP_PREFIX, baseTypeId)); - String actualBaseTypeIdValue = cmisAPI().withCMISUtil().getCmisObject(cmisAPI().getLastResource()).getType().getBaseTypeId().value(); - Assert.assertEquals(actualBaseTypeIdValue, baseTypeId, "Object type is the expected one"); - return cmisAPI(); - } - - /** - * Verify object type id - * - * @param objectTypeId String expected object type value - * @return - * @throws Exception - */ - public CmisWrapper objectTypeIdIs(String objectTypeId) throws Exception - { - STEP(String.format("%s Verify if object type id '%s' is the expected one", CmisWrapper.STEP_PREFIX, objectTypeId)); - String typeId = cmisAPI().withCMISUtil().getCmisObject(cmisAPI().getLastResource()).getType().getId(); - if (StringUtils.isEmpty(typeId)) - { - typeId = ""; - } - Assert.assertEquals(cmisAPI().withCMISUtil().getCmisObject(cmisAPI().getLastResource()).getType().getId(), objectTypeId, - "Object type id is the expected one"); - return cmisAPI(); - } - - /** - * Verify a specific object property - * - * @param propertyId - * @param value - * @return - */ - public CmisWrapper objectHasProperty(String propertyId, Object value) - { - CmisObject cmisObject = cmisAPI().withCMISUtil().getCmisObject(cmisAPI().getLastResource()); - STEP(String.format("%s Verify if object %s has property %s ", CmisWrapper.STEP_PREFIX, cmisObject.getName(), propertyId)); - Property property = cmisAPI().withCMISUtil().getProperty(propertyId); - Object propValue = property.getValue(); - if(propValue instanceof GregorianCalendar) - { - Date date = (Date) value; - long longDate = date.getTime(); - long actualDate = ((GregorianCalendar) propValue).getTimeInMillis(); - Assert.assertEquals(actualDate, longDate); - } - else - { - if (propValue == null) - { - propValue = ""; - } - Assert.assertEquals(property.getValue().toString(), value.toString(), String.format("Found property value %s", value)); - } - return cmisAPI(); - } - - /** - * Check if CMIS object contains a property. - * Example: - * ...assertObjectHasProperty("cmis:secondaryObjectTypeIds", "Secondary Object Type Ids","secondaryObjectTypeIds", "cmis:secondaryObjectTypeIds", - * "P:cm:titled", "P:sys:localized"); - * - * @param propertyId - * @param displayName - * @param localName - * @param queryName - * @param values - * @return - */ - public CmisWrapper objectHasProperty(String propertyId, String displayName, String localName, String queryName, String... values) - { - CmisObject cmisObject = cmisAPI().withCMISUtil().getCmisObject(cmisAPI().getLastResource()); - STEP(String.format("%s Verify if object %s has property %s ", CmisWrapper.STEP_PREFIX, cmisObject.getName(), propertyId)); - Property property = cmisAPI().withCMISUtil().getProperty(propertyId); - if (property != null) - { - Assert.assertEquals(property.getDisplayName(), displayName, "Property displayName"); - Assert.assertEquals(property.getLocalName(), localName, "Property localName"); - Assert.assertEquals(property.getQueryName(), queryName, "Property queryName"); - for (String value : values) - { - Assert.assertTrue(property.getValues().contains(value), "Property value"); - } - } - else - { - Assert.assertFalse(false, String.format("Object %s does not have property %s", cmisObject.getName(), propertyId)); - } - return cmisAPI(); - } - - /** - * Assert if the {@link #getLastResource()) has the latest major version set - */ - public CmisWrapper isLatestMajorVersion() - { - String path = cmisAPI().getLastResource(); - STEP(String.format("%s Verify that document from '%s' is latest major version", CmisWrapper.STEP_PREFIX, path)); - Assert.assertTrue(cmisAPI().withCMISUtil().getCmisDocument(path).isLatestMajorVersion(), String.format("Document from %s is last major version", path)); - return cmisAPI(); - } - - /** - * Verify that {@link Document} is not latest major version. - * - * @return - */ - public CmisWrapper isNotLatestMajorVersion() - { - String path = cmisAPI().getLastResource(); - STEP(String.format("%s Verify that document from '%s' is not latest major version", CmisWrapper.STEP_PREFIX, path)); - Assert.assertFalse(cmisAPI().withCMISUtil().getCmisDocument(path).isLatestMajorVersion(), - String.format("Document from %s is last major version", path)); - return cmisAPI(); - } - - /** - * Verify that renditions are available - */ - public CmisWrapper renditionIsAvailable() - { - STEP(String.format("%s Verify if renditions are available for %s", CmisWrapper.STEP_PREFIX, cmisAPI().getLastResource())); - List renditions = cmisAPI().withCMISUtil().getRenditions(); - Assert.assertTrue(renditions != null && !renditions.isEmpty()); - return cmisAPI(); - } - - /** - * Verify that thumbnail rendition is available - * - * @return - */ - public CmisWrapper thumbnailRenditionIsAvailable() - { - boolean found = false; - STEP(String.format("%s Verify if thumbnail rendition is available for %s", CmisWrapper.STEP_PREFIX, cmisAPI().getLastResource())); - List renditions = cmisAPI().withCMISUtil().getRenditions(); - for (Rendition rendition : renditions) - { - if (rendition.getKind().equals("cmis:thumbnail")) - { - found = true; - } - } - Assert.assertTrue(found, String.format("Thumbnail rendition found for", cmisAPI().getLastResource())); - return cmisAPI(); - } - - private boolean isSecondaryTypeAvailable(String secondaryTypeId) - { - boolean found = false; - List secondaryTypes = cmisAPI().withCMISUtil().getSecondaryTypes(); - for (SecondaryType type : secondaryTypes) - { - if (type.getId().equals(secondaryTypeId)) - { - found = true; - break; - } - } - - return found; - } - - /** - * Verify secondary type for specific {@link CmisObject} - * - * @param secondaryTypeId - * @return - */ - public CmisWrapper secondaryTypeIsAvailable(String secondaryTypeId) - { - STEP(String.format("%s Verify if '%s' secondary type is available for '%s'", CmisWrapper.STEP_PREFIX, secondaryTypeId, - new File(cmisAPI().getLastResource()).getName())); - Assert.assertTrue(isSecondaryTypeAvailable(secondaryTypeId), String.format("%s is available for %s", secondaryTypeId, cmisAPI().getLastResource())); - return cmisAPI(); - } - - /** - * Verify secondary type is not available for specific {@link CmisObject} - * - * @param secondaryTypeId - * @return - */ - public CmisWrapper secondaryTypeIsNotAvailable(String secondaryTypeId) - { - STEP(String.format("%s Verify if '%s' aspect is NOT available for %s", CmisWrapper.STEP_PREFIX, secondaryTypeId, cmisAPI().getLastResource())); - Assert.assertFalse(isSecondaryTypeAvailable(secondaryTypeId), - String.format("%s is NOT available for %s", secondaryTypeId, cmisAPI().getLastResource())); - return cmisAPI(); - } - - /** - * Verify document content length - * - * @param contentLength String expected content length - * @return - * @throws Exception - */ - public CmisWrapper contentLengthIs(long contentLength) throws Exception - { - STEP(String.format("%s Verify if content length '%s' is the expected one", CmisWrapper.STEP_PREFIX, contentLength)); - Document lastVersion = cmisAPI().withCMISUtil().getCmisDocument(cmisAPI().getLastResource()); - lastVersion.refresh(); - Assert.assertEquals(lastVersion.getContentStreamLength(), contentLength, "File content is the expected one"); - return cmisAPI(); - } - - /** - * e.g. assertFolderHasDescendant(1, file1) will verify if file1 is a direct descendant of {@link #getLastResource()} - * - * @param depth {@link #getFolderDescendants(int)} - * @param contentModels {@link #getCmisObjectsFromContentModels(ContentModel...)} - */ - public void hasDescendants(int depth, ContentModel... contentModels) - { - STEP(String.format("%s Assert that folder %s has descendants in depth %d:", STEP_PREFIX, getProtocol().getLastResource(), depth)); - CmisObject currentCmisObject = getProtocol().withCMISUtil().getCmisObject(getProtocol().getLastResource()); - List cmisObjects = getProtocol().withCMISUtil().getCmisObjectsFromContentModels(contentModels); - List folderDescendants = getProtocol().withCMISUtil().getFolderDescendants(depth); - for (CmisObject cmisObject : cmisObjects) - { - boolean found = false; - STEP(String.format("%s Verify that folder '%s' has descendant %s", CmisWrapper.STEP_PREFIX, currentCmisObject.getName(), cmisObject.getName())); - for (CmisObject folderDescendant : folderDescendants) - if (folderDescendant.getId().equals(cmisObject.getId())) - { - found = true; - break; - } - Assert.assertTrue(found, String.format("Folder %s does not have descendant %s", currentCmisObject.getName(), cmisObject)); - } - } - - public void doesNotHaveDescendants(int depth) - { - STEP(String.format("%s Assert that folder %s does not have descendants in depth %d:", STEP_PREFIX, getProtocol().getLastResource(), depth)); - CmisObject currentCmisObject = getProtocol().withCMISUtil().getCmisObject(getProtocol().getLastResource()); - List folderDescendants = getProtocol().withCMISUtil().getFolderDescendants(depth); - Assert.assertTrue(folderDescendants.isEmpty(), String.format("Folder %s should not have descendants", currentCmisObject.getName())); - } - - /** - * Verify that {@link CmisObject} has ACLs (Access Control Lists) - * - * @return - */ - public CmisWrapper hasAcls() - { - STEP(String.format("%s Verify that %s has acls", CmisWrapper.STEP_PREFIX, cmisAPI().getLastResource())); - String path = cmisAPI().getLastResource(); - STEP(String.format("%s Get Acls for %s", CmisWrapper.STEP_PREFIX, path)); - Assert.assertNotNull(cmisAPI().withCMISUtil().getAcls(), String.format("Acls found for %s", path)); - return cmisAPI(); - } - - /** - * Depending on the specified depth, checks that all the contents from contentModels list are present in the current folder tree structure - * - * @param depth the depth of the tree to check, must be -1 or >= 1 - * @param contentModels expected list of contents to be found in the tree - * @return - */ - public CmisWrapper hasFolderTree(int depth, ContentModel... contentModels) - { - CmisObject currentCmisObject = getProtocol().withCMISUtil().getCmisObject(getProtocol().getLastResource()); - List cmisObjects = getProtocol().withCMISUtil().getCmisObjectsFromContentModels(contentModels); - List folderDescendants = getProtocol().withCMISUtil().getFolderTree(depth); - for (CmisObject cmisObject : cmisObjects) - { - boolean found = false; - STEP(String.format("%s Verify that folder '%s' has folder tree %s", CmisWrapper.STEP_PREFIX, currentCmisObject.getName(), cmisObject.getName())); - for (CmisObject folderDescendant : folderDescendants) - if (folderDescendant.getId().equals(cmisObject.getId())) - found = true; - Assert.assertTrue(found, String.format("Folder %s does not have folder tree %s", currentCmisObject.getName(), cmisObject)); - } - return cmisAPI(); - } - - /** - * Verify the permission for a specific user from the last resource object - * - * @param userModel {@link UserModel} user to verify - * @param role {@link UserRole} user role to verify - * @return - */ - public CmisWrapper permissionIsSetForUser(UserModel userModel, UserRole role) - { - STEP(String.format("%s Verify that user %s has role %s set to content %s", CmisWrapper.STEP_PREFIX, userModel.getUsername(), role.name(), - cmisAPI().getLastResource())); - Assert.assertTrue(checkPermission(userModel.getUsername(), role.getRoleId()), - String.format("User %s has permission %s", userModel.getUsername(), role.name())); - return cmisAPI(); - } - - /** - * Verify the permission for a specific group of users from the last resource object - * - * @param groupModel {@link GroupModel} group to verify - * @param role {@link UserRole} user role to verify - * @return - */ - public CmisWrapper permissionIsSetForGrup(GroupModel groupModel, UserRole role) - { - STEP(String.format("%s Verify that user %s has role %s set to content %s", CmisWrapper.STEP_PREFIX, groupModel.getDisplayName(), role.name(), - cmisAPI().getLastResource())); - Assert.assertTrue(checkPermission(groupModel.getDisplayName(), role.getRoleId()), - String.format("User %s has permission %s", groupModel.getDisplayName(), role.name())); - return cmisAPI(); - } - - private boolean checkPermission(String user, String permission) - { - Acl acl = cmisAPI().withCMISUtil().getAcls(); - if (acl == null) - { - throw new CmisRuntimeException(String.format("No acls returned for '%s'", cmisAPI().getLastResource())); - } - List aces = acl.getAces(); - boolean found = false; - for (Ace ace : aces) - { - if (ace.getPrincipalId().equals(user) && ace.getPermissions().get(0).equals(permission)) - { - found = true; - break; - } - } - return found; - } - - /** - * Verify the permission for a specific user from the last resource object - * - * @param userModel {@link UserModel} - * @param permission to verify - * @return - */ - public CmisWrapper permissionIsSetForUser(UserModel userModel, String permission) - { - STEP(String.format("%s Verify that user %s has role %s set to content %s", CmisWrapper.STEP_PREFIX, userModel.getUsername(), permission, - cmisAPI().getLastResource())); - Assert.assertTrue(checkPermission(userModel.getUsername(), permission), - String.format("User %s has permission %s", userModel.getUsername(), permission)); - return cmisAPI(); - } - - /** - * Verify that permission is not set for a specific user from the last resource object - * - * @param userModel {@link UserModel} user to verify - * @param role {@link UserRole} user role to verify - * @return - */ - public CmisWrapper permissionIsNotSetForUser(UserModel userModel, UserRole role) - { - STEP(String.format("%s Verify that user %s doesn't have role %s set to content %s", CmisWrapper.STEP_PREFIX, userModel.getUsername(), role.name(), - cmisAPI().getLastResource())); - Assert.assertFalse(checkPermission(userModel.getUsername(), role.getRoleId()), - String.format("User %s has permission %s", userModel.getUsername(), role.name())); - return cmisAPI(); - } - - /** - * Verify that permission is not set for a specific user from the last resource object - * - * @param userModel {@link UserModel} user to verify - * @param permission to verify - * @return - */ - public CmisWrapper permissionIsNotSetForUser(UserModel userModel, String permission) - { - STEP(String.format("%s Verify that user %s doesn't have permission %s set to content %s", CmisWrapper.STEP_PREFIX, userModel.getUsername(), permission, - cmisAPI().getLastResource())); - Assert.assertFalse(checkPermission(userModel.getUsername(), permission), - String.format("User %s has permission %s", userModel.getUsername(), permission)); - return cmisAPI(); - } - - public CmisWrapper typeDefinitionIs(ContentModel contentModel) - { - CmisObject cmisObject = cmisAPI().withCMISUtil().getCmisObject(contentModel.getCmisLocation()); - STEP(String.format("%s Verify that object '%s' type definition matches '%s' type definition", CmisWrapper.STEP_PREFIX, cmisObject.getName(), - cmisAPI().withCMISUtil().getTypeDefinition().getId())); - Assert.assertTrue(cmisAPI().withCMISUtil().getTypeDefinition().equals(cmisObject.getType()), String.format( - "Object '%s' type definition does not match '%s' type definition", cmisObject.getName(), cmisAPI().withCMISUtil().getTypeDefinition().getId())); - return cmisAPI(); - } - - /** - * Verify that a specific folder(set by calling {@link org.alfresco.cmis.CmisWrapper#usingResource(ContentModel)}) - * contains checked out documents - * - * @param contentModels checked out documents to verify - * @return - */ - public CmisWrapper folderHasCheckedOutDocument(ContentModel... contentModels) - { - List cmisObjectList = cmisAPI().withCMISUtil().getCmisObjectsFromContentModels(contentModels); - List cmisCheckedOutDocuments = cmisAPI().withCMISUtil().getCheckedOutDocumentsFromFolder(); - for (CmisObject cmisObject : cmisObjectList) - { - Assert.assertTrue(cmisAPI().withCMISUtil().isCmisObjectContainedInCmisCheckedOutDocumentsList(cmisObject, cmisCheckedOutDocuments), - String.format("Folder %s does not contain checked out document %s", cmisAPI().getLastResource(), cmisObject)); - } - return cmisAPI(); - } - - /** - * Verify that a specific folder(set by calling {@link org.alfresco.cmis.CmisWrapper#usingResource(ContentModel)}) - * contains checked out documents in a specific order. - * - * @param context {@link OperationContext} - * @param contentModels documents to verify in the order returned by the {@link OperationContext} - * @return - */ - public CmisWrapper folderHasCheckedOutDocument(OperationContext context, ContentModel... contentModels) - { - List cmisObjectList = cmisAPI().withCMISUtil().getCmisObjectsFromContentModels(contentModels); - List cmisCheckedOutDocuments = cmisAPI().withCMISUtil().getCheckedOutDocumentsFromFolder(context); - for (int i = 0; i < cmisObjectList.size(); i++) - { - Assert.assertEquals(cmisObjectList.get(i).getId().split(";")[0], cmisCheckedOutDocuments.get(i).getId().split(";")[0], - String.format("Folder %s does not contain checked out document %s", cmisAPI().getLastResource(), cmisObjectList.get(i).getName())); - } - return cmisAPI(); - } - - /** - * Verify checked out documents from {@link Session} - * - * @param contentModels documents to verify - * @return - */ - public CmisWrapper sessionHasCheckedOutDocument(ContentModel... contentModels) - { - List cmisObjectList = cmisAPI().withCMISUtil().getCmisObjectsFromContentModels(contentModels); - List cmisCheckedOutDocuments = cmisAPI().withCMISUtil().getCheckedOutDocumentsFromSession(); - for (CmisObject cmisObject : cmisObjectList) - { - Assert.assertTrue(cmisAPI().withCMISUtil().isCmisObjectContainedInCmisCheckedOutDocumentsList(cmisObject, cmisCheckedOutDocuments), - String.format("Session does not contain checked out document %s", cmisObject)); - } - return cmisAPI(); - } - - /** - * Verify checked out documents from {@link Session} in a specific order set in {@link OperationContext} - * - * @param context {@link OperationContext} - * @param contentModels documents to verify - * @return - */ - public CmisWrapper sessionHasCheckedOutDocument(OperationContext context, ContentModel... contentModels) - { - List cmisObjectList = cmisAPI().withCMISUtil().getCmisObjectsFromContentModels(contentModels); - List cmisCheckedOutDocuments = cmisAPI().withCMISUtil().getCheckedOutDocumentsFromSession(context); - for (int i = 0; i < cmisObjectList.size(); i++) - { - Assert.assertEquals(cmisObjectList.get(i).getId().split(";")[0], cmisCheckedOutDocuments.get(i).getId().split(";")[0], - String.format("Session does not contain checked out document %s", cmisObjectList.get(i).getName())); - } - return cmisAPI(); - } - - /** - * Verify that checked out documents are not found in {@link Session} - * - * @param contentModels documents to verify - * @return - */ - public CmisWrapper sessioDoesNotHaveCheckedOutDocument(ContentModel... contentModels) - { - List cmisObjectList = cmisAPI().withCMISUtil().getCmisObjectsFromContentModels(contentModels); - List cmisCheckedOutDocuments = cmisAPI().withCMISUtil().getCheckedOutDocumentsFromSession(); - for (CmisObject cmisObject : cmisObjectList) - { - Assert.assertFalse(cmisAPI().withCMISUtil().isCmisObjectContainedInCmisCheckedOutDocumentsList(cmisObject, cmisCheckedOutDocuments), - String.format("Session does contain checked out document %s", cmisObject)); - } - return cmisAPI(); - } - - /** - * Verify that {@link CmisObject} has a specific aspect extension - * - * @param aspectId - * @return - */ - public CmisWrapper hasAspectExtension(String aspectId) - { - STEP(String.format("Verify that aspect %s is applied to %s", aspectId, cmisAPI().getLastResource())); - boolean found = false; - List extensions = cmisAPI().withCMISUtil().getCmisObject(cmisAPI().getLastResource()).getExtensions(ExtensionLevel.PROPERTIES); - for (CmisExtensionElement extElement : extensions) - { - if (extElement.getName().equals("aspects")) - { - List aspects = extElement.getChildren(); - for (CmisExtensionElement aspect : aspects) - { - if (aspect.getValue() != null) - { - if (aspect.getValue().equals(aspectId)) - { - found = true; - } - } - } - } - } - Assert.assertTrue(found, String.format("Aspect extension %s for %s was found", aspectId, cmisAPI().getLastResource())); - return cmisAPI(); - } - - /** - * Verify the parents for a {@link CmisObject} - * - * @param parentsList - * @return - */ - public CmisWrapper hasParents(String... parentsList) - { - List folderNames = new ArrayList<>(); - List parents = new ArrayList<>(); - String source = cmisAPI().getLastResource(); - CmisObject objSource = cmisAPI().withCMISUtil().getCmisObject(source); - STEP(String.format("%s Verify the parents for '%s'.", CmisWrapper.STEP_PREFIX, objSource.getName())); - if (objSource instanceof Document) - { - Document d = (Document) objSource; - parents = d.getParents(); - } - else if (objSource instanceof Folder) - { - Folder f = (Folder) objSource; - parents = f.getParents(); - } - for (Folder folder : parents) - { - folderNames.add(folder.getName()); - } - Assert.assertEqualsNoOrder(folderNames.toArray(), parentsList, "Parents list is the expected one."); - return cmisAPI(); - } - - public CmisWrapper descriptionIs(String description) - { - String source = cmisAPI().getLastResource(); - STEP(String.format("%s Verify object '%s' description is '%s'", CmisWrapper.STEP_PREFIX, source, description)); - CmisObject cmisObject = cmisAPI().withCMISUtil().getCmisObject(source); - Assert.assertEquals(description, cmisObject.getDescription()); - return cmisAPI(); - } - - /** - * Verify if folder children exist in parent folder - * - * @param fileModel children files - * @return - * @throws Exception - */ - public CmisWrapper hasFolders(FolderModel... folderModel) throws Exception - { - String currentSpace = cmisAPI().getCurrentSpace(); - List folders = cmisAPI().getFolders(); - for (FolderModel folder : folderModel) - { - STEP(String.format("%s Verify that folder %s is in %s", CmisWrapper.STEP_PREFIX, folder.getName(), currentSpace)); - Assert.assertTrue(cmisAPI().withCMISUtil().isFolderInList(folder, folders), String.format("Folder %s is in %s", folder.getName(), currentSpace)); - } - return cmisAPI(); - } - - /** - * Verify if file children exist in parent folder - * - * @param fileModel children files - * @return - * @throws Exception - */ - public CmisWrapper hasFiles(FileModel... fileModel) throws Exception - { - String currentSpace = cmisAPI().getLastResource(); - List files = cmisAPI().getFiles(); - for (FileModel file : fileModel) - { - STEP(String.format("%s Verify that file '%s' is in '%s'", CmisWrapper.STEP_PREFIX, file.getName(), currentSpace)); - Assert.assertTrue(cmisAPI().withCMISUtil().isFileInList(file, files), String.format("File %s is in %s", file.getName(), currentSpace)); - } - return cmisAPI(); - } - - /** - * Verify if file(s) children exist in parent folder - * - * @param fileModels children files - * @return - * @throws Exception - */ - public CmisWrapper doesNotHaveFile(FileModel... fileModels) throws Exception - { - String currentSpace = cmisAPI().getLastResource(); - List files = cmisAPI().getFiles(); - for (FileModel fileModel : fileModels) - { - STEP(String.format("%s Verify that file '%s' is not in '%s'", CmisWrapper.STEP_PREFIX, fileModel.getName(), currentSpace)); - Assert.assertFalse(cmisAPI().withCMISUtil().isFileInList(fileModel, files), String.format("File %s is in %s", fileModel.getName(), currentSpace)); - } - return cmisAPI(); - } - - /** - * Verify if folder(s) children exist in parent folder - * - * @param folderModels children files - * @return - * @throws Exception - */ - public CmisWrapper doesNotHaveFolder(FolderModel... folderModels) throws Exception - { - String currentSpace = cmisAPI().getLastResource(); - List folders = cmisAPI().getFolders(); - for (FolderModel folderModel : folderModels) - { - STEP(String.format("%s Verify that folder '%s' is not in '%s'", CmisWrapper.STEP_PREFIX, folderModel.getName(), currentSpace)); - Assert.assertFalse(cmisAPI().withCMISUtil().isFolderInList(folderModel, folders), - String.format("File %s is in %s", folderModel.getName(), currentSpace)); - } - return cmisAPI(); - } - - /** - * Verify the children(files and folders) from a parent folder - * - * @param contentModel children - * @return - * @throws Exception - */ - public CmisWrapper hasChildren(ContentModel... contentModel) throws Exception - { - String currentSpace = cmisAPI().getCurrentSpace(); - Map mapContents = cmisAPI().withCMISUtil().getChildren(); - List contents = new ArrayList(); - for (Map.Entry entry : mapContents.entrySet()) - { - contents.add(entry.getKey()); - } - for (ContentModel content : contentModel) - { - STEP(String.format("%s Verify that file %s is in %s", CmisWrapper.STEP_PREFIX, content.getName(), currentSpace)); - Assert.assertTrue(cmisAPI().withCMISUtil().isContentInList(content, contents), - String.format("Content %s is in %s", content.getName(), currentSpace)); - } - return cmisAPI(); - } - - - public CmisWrapper hasUniqueChildren(int numberOfChildren) throws Exception - { - STEP(String.format("%s Verify that current folder has %d unique children", CmisWrapper.STEP_PREFIX, numberOfChildren)); - Map mapContents = cmisAPI().withCMISUtil().getChildren(); - - Set documentIds = new HashSet(); - for (ContentModel key : mapContents.keySet()) - { - documentIds.add(key.getName()); - } - Assert.assertTrue(numberOfChildren==documentIds.size(), String.format("Current folder contains %d unique children, but expected is %d", documentIds.size(), numberOfChildren)); - return cmisAPI(); - } - - /** - * Get check in comment for last document version - * - * @param comment to verify - * @return - */ - public CmisWrapper hasCheckInCommentLastVersion(String comment) - { - String source = cmisAPI().getLastResource(); - STEP(String.format("%s Verify check in comment for last version of %s", CmisWrapper.STEP_PREFIX, source)); - Document document = cmisAPI().withCMISUtil().getCmisDocument(source); - Assert.assertEquals(comment, document.getCheckinComment(), String.format("Document %s has check in comment %s", document.getName(), comment)); - return cmisAPI(); - } - - /** - * Get check in comment for a specific document version - * - * @param documentVersion version of document - * @param comment to verify - * @return - */ - public CmisWrapper hasCheckInCommentForVersion(double documentVersion, String comment) - { - String source = cmisAPI().getLastResource(); - STEP(String.format("%s Verify check in comment for version %s of %s", CmisWrapper.STEP_PREFIX, documentVersion, source)); - String documentId = cmisAPI().withCMISUtil().getObjectId(source).split(";")[0]; - documentId = documentId + ";" + documentVersion; - Document document = (Document) cmisAPI().withCMISUtil().getCmisObjectById(documentId); - Assert.assertEquals(comment, document.getCheckinComment(), String.format("Document %s has check in comment %s", document.getName(), comment)); - return cmisAPI(); - } - - /** - * Verify failed deleted objects after delete tree action - * - * @param nodeRef objects to verify - * @return - */ - public CmisWrapper hasFailedDeletedObject(String nodeRef) - { - STEP(String.format("%s Verify failed deleted object from %s", CmisWrapper.STEP_PREFIX, cmisAPI().getLastResource())); - Assert.assertTrue(cmisAPI().deleteTreeFailedObjects.contains(nodeRef), String.format("Object %s found after delete", nodeRef)); - return cmisAPI(); - } - - /** - * Verify if there is a relationship between current resource and the given target - * - * @param user - * @return - */ - public CmisWrapper userIsAssigned(UserModel user) - { - OperationContext oc = new OperationContextImpl(); - oc.setIncludeRelationships(IncludeRelationships.SOURCE); - CmisObject source = cmisAPI().withCMISUtil().getCmisObject(cmisAPI().getLastResource(), oc); - String userNodeRef = cmisAPI().withCMISUtil().getUserNodeRef(user); - - STEP(String.format("%s Verify if user '%s' has relationship with '%s'", CmisWrapper.STEP_PREFIX, user.getUsername(), source.getName())); - List relTargetIds = new ArrayList<>(); - for (Relationship rel : source.getRelationships()) - { - relTargetIds.add(rel.getTarget().getId()); - } - Assert.assertTrue(relTargetIds.contains(userNodeRef), - String.format("Relationship is created between source '%s' and target '%s'.", source.getName(), user.getUsername())); - return cmisAPI(); - } -} diff --git a/e2e-test/src/main/java/org/alfresco/cmis/dsl/CmisUtil.java b/e2e-test/src/main/java/org/alfresco/cmis/dsl/CmisUtil.java deleted file mode 100644 index d9176ad8e..000000000 --- a/e2e-test/src/main/java/org/alfresco/cmis/dsl/CmisUtil.java +++ /dev/null @@ -1,743 +0,0 @@ -package org.alfresco.cmis.dsl; - -import static org.alfresco.utility.report.log.Step.STEP; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.nio.charset.StandardCharsets; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -import org.alfresco.cmis.CmisWrapper; -import org.alfresco.cmis.exception.InvalidCmisObjectException; -import org.alfresco.utility.LogFactory; -import org.alfresco.utility.Utility; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.model.ContentModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.GroupModel; -import org.alfresco.utility.model.UserModel; -import org.apache.chemistry.opencmis.client.api.CmisObject; -import org.apache.chemistry.opencmis.client.api.Document; -import org.apache.chemistry.opencmis.client.api.FileableCmisObject; -import org.apache.chemistry.opencmis.client.api.Folder; -import org.apache.chemistry.opencmis.client.api.ItemIterable; -import org.apache.chemistry.opencmis.client.api.ObjectType; -import org.apache.chemistry.opencmis.client.api.OperationContext; -import org.apache.chemistry.opencmis.client.api.Property; -import org.apache.chemistry.opencmis.client.api.QueryResult; -import org.apache.chemistry.opencmis.client.api.Rendition; -import org.apache.chemistry.opencmis.client.api.SecondaryType; -import org.apache.chemistry.opencmis.client.api.Tree; -import org.apache.chemistry.opencmis.commons.PropertyIds; -import org.apache.chemistry.opencmis.commons.data.Ace; -import org.apache.chemistry.opencmis.commons.data.Acl; -import org.apache.chemistry.opencmis.commons.data.AclCapabilities; -import org.apache.chemistry.opencmis.commons.data.ContentStream; -import org.apache.chemistry.opencmis.commons.data.PermissionMapping; -import org.apache.chemistry.opencmis.commons.data.PropertyData; -import org.apache.chemistry.opencmis.commons.data.RepositoryInfo; -import org.apache.chemistry.opencmis.commons.enums.Action; -import org.apache.chemistry.opencmis.commons.enums.BaseTypeId; -import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException; -import org.apache.chemistry.opencmis.commons.exceptions.CmisVersioningException; -import org.apache.commons.io.IOUtils; -import org.slf4j.Logger; -import org.testng.collections.Lists; - -/** - * DSL utility for managing CMIS objects - */ -public class CmisUtil -{ - private CmisWrapper cmisAPI; - private Logger LOG = LogFactory.getLogger(); - - public CmisUtil(CmisWrapper cmisAPI) - { - this.cmisAPI = cmisAPI; - } - - /** - * Get cmis object by object id - * - * @param objectId cmis object id - * @return CmisObject cmis object - */ - public CmisObject getCmisObjectById(String objectId) - { - LOG.debug("Get CMIS object by ID {}", objectId); - if (cmisAPI.getSession() == null) - { - throw new CmisRuntimeException("Please authenticate user, call: cmisAPI.authenticate(..)!"); - } - if (objectId == null) - { - throw new InvalidCmisObjectException("Invalid content id"); - } - return cmisAPI.getSession().getObject(objectId); - } - - /** - * Get cmis object by object id with OperationContext - * - * @param objectId cmis object id - * @param context OperationContext - * @return CmisObject cmis object - */ - public CmisObject getCmisObjectById(String objectId, OperationContext context) - { - if (cmisAPI.getSession() == null) - { - throw new CmisRuntimeException("Please authenticate user, call: cmisAPI.authenticate(..)!"); - } - if (objectId == null) - { - throw new InvalidCmisObjectException("Invalid content id"); - } - return cmisAPI.getSession().getObject(objectId, context); - } - - /** - * Get cmis object by path - * - * @param pathToItem String path to item - * @return CmisObject cmis object - */ - public CmisObject getCmisObject(String pathToItem) - { - if (cmisAPI.getSession() == null) - { - throw new CmisRuntimeException("Please authenticate user, call: cmisAPI.authenticate(..)!"); - } - if (pathToItem == null) - { - throw new InvalidCmisObjectException("Invalid path set for content"); - } - CmisObject cmisObject = cmisAPI.getSession().getObjectByPath(Utility.removeLastSlash(pathToItem)); - if (cmisObject instanceof Document) - { - if (!((Document) cmisObject).getVersionLabel().contentEquals("pwc")) - { - // get last version of document - cmisObject = ((Document) cmisObject).getObjectOfLatestVersion(false); - } - else - { - // get pwc document - cmisObject = cmisAPI.getSession().getObject(((Document) cmisObject).getObjectOfLatestVersion(false).getVersionSeriesCheckedOutId()); - } - } - return cmisObject; - } - - /** - * Get cmis object by path with context - * - * @param pathToItem String path to item - * @param context OperationContext - * @return CmisObject cmis object - */ - public CmisObject getCmisObject(String pathToItem, OperationContext context) - { - if (cmisAPI.getSession() == null) - { - throw new CmisRuntimeException("Please authenticate user!"); - } - if (pathToItem == null) - { - throw new InvalidCmisObjectException("Invalid path set for content"); - } - CmisObject cmisObject = cmisAPI.getSession().getObjectByPath(Utility.removeLastSlash(pathToItem), context); - if (cmisObject instanceof Document) - { - if (!((Document) cmisObject).getVersionLabel().contentEquals("pwc")) - { - // get last version of document - cmisObject = ((Document) cmisObject).getObjectOfLatestVersion(false, context); - } - else - { - // get pwc document - cmisObject = cmisAPI.getSession().getObject(((Document) cmisObject).getObjectOfLatestVersion(false, context).getVersionSeriesCheckedOutId()); - } - } - return cmisObject; - } - - /** - * Get Document object for a file - * - * @param path String path to document - * @return {@link Document} object - */ - public Document getCmisDocument(final String path) - { - LOG.debug("Get CMIS Document by path {}", path); - Document d = null; - CmisObject docObj = getCmisObject(path); - if (docObj instanceof Document) - { - d = (Document) docObj; - } - else if (docObj instanceof Folder) - { - throw new InvalidCmisObjectException("Content at " + path + " is not a file"); - } - return d; - } - - /** - * Get Folder object for a folder - * - * @param path String path to folder - * @return {@link Folder} object - */ - public Folder getCmisFolder(final String path) - { - Folder f = null; - CmisObject folderObj = getCmisObject(path); - if (folderObj instanceof Folder) - { - f = (Folder) folderObj; - } - else if (folderObj instanceof Document) - { - throw new InvalidCmisObjectException("Content at " + path + " is not a folder"); - } - return f; - } - - /** - * Helper method to get the contents of a stream - * - * @param stream - * @return - * @throws IOException - */ - protected String getContentAsString(ContentStream stream) throws Exception - { - LOG.debug("Get Content as String {}", stream); - InputStream inputStream = stream.getStream(); - String result = IOUtils.toString(inputStream, StandardCharsets.UTF_8); - IOUtils.closeQuietly(inputStream); - return result; - } - - /** - * Copy all the children of the source folder to the target folder - * - * @param sourceFolder - * @param targetFolder - */ - protected void copyChildrenFromFolder(Folder sourceFolder, Folder targetFolder) - { - for (Tree t : sourceFolder.getDescendants(-1)) - { - CmisObject obj = t.getItem(); - if (obj instanceof Document) - { - Document d = (Document) obj; - d.copy(targetFolder); - } - else if (obj instanceof Folder) - { - copyFolder((Folder) obj, targetFolder); - } - } - } - - /** - * Copy folder with all children - * - * @param sourceFolder source folder - * @param targetFolder target folder - * @return CmisObject of new created folder - */ - public CmisObject copyFolder(Folder sourceFolder, Folder targetFolder) - { - Map folderProperties = new HashMap(2); - folderProperties.put(PropertyIds.NAME, sourceFolder.getName()); - folderProperties.put(PropertyIds.OBJECT_TYPE_ID, sourceFolder.getBaseTypeId().value()); - Folder newFolder = targetFolder.createFolder(folderProperties); - copyChildrenFromFolder(sourceFolder, newFolder); - return newFolder; - } - - protected boolean isPrivateWorkingCopy() - { - boolean result = false; - try - { - result = getPWCDocument().isPrivateWorkingCopy(); - } - catch (CmisVersioningException cmisVersioningException) - { - result = false; - } - return result; - } - - /** - * Returns the PWC (private working copy) ID of the document version series - */ - public Document getPWCDocument() - { - Document document = getCmisDocument(cmisAPI.getLastResource()); - String pwcId = document.getVersionSeriesCheckedOutId(); - if (pwcId != null) - { - return (Document) cmisAPI.getSession().getObject(pwcId); - } - else - { - throw new CmisVersioningException(String.format("Document %s is not checked out", document.getName())); - } - } - - public FileModel getPWCFileModel() - { - Document document = getPWCDocument(); - String[] pathTokens = cmisAPI.getLastResource().split("/"); - String path = ""; - for (int i = 0; i < pathTokens.length - 1; i++) - path = Utility.buildPath(path, pathTokens[i]); - path = Utility.buildPath(path, document.getName()); - - FileModel fileModel = new FileModel(); - fileModel.setName(document.getName()); - fileModel.setCmisLocation(path); - return fileModel; - } - - protected Folder getFolderParent() - { - return getCmisFolder(cmisAPI.getLastResource()).getFolderParent(); - } - - /** - * @return List of allowable actions for the current object - */ - protected List getAllowableActions() - { - return Lists.newArrayList(getCmisObject(cmisAPI.getLastResource()).getAllowableActions().getAllowableActions()); - } - - /** - * Returns the requested property. If the property is not available, null is returned - * - * @param propertyId - * @return CMIS Property - */ - protected Property getProperty(String propertyId) - { - CmisObject cmisObject = getCmisObject(cmisAPI.getLastResource()); - return cmisObject.getProperty(propertyId); - } - - protected List getRenditions() - { - OperationContext operationContext = cmisAPI.getSession().createOperationContext(); - operationContext.setRenditionFilterString("*"); - CmisObject obj = cmisAPI.getSession().getObjectByPath(cmisAPI.getLastResource(), operationContext); - obj.refresh(); - List renditions = obj.getRenditions(); - int retry = 0; - while ((renditions == null || renditions.isEmpty()) && retry < Utility.retryCountSeconds) - { - Utility.waitToLoopTime(1); - obj.refresh(); - renditions = obj.getRenditions(); - retry++; - } - return obj.getRenditions(); - } - - protected List getSecondaryTypes() - { - CmisObject obj = getCmisObject(cmisAPI.getLastResource()); - obj.refresh(); - return obj.getSecondaryTypes(); - } - - /** - * Get the children from a parent folder - * - * @return Map - */ - public Map getChildren() - { - String folderParent = cmisAPI.getLastResource(); - ItemIterable children = cmisAPI.withCMISUtil().getCmisFolder(folderParent).getChildren(); - Map contents = new HashMap(); - for (CmisObject o : children) - { - ContentModel content = new ContentModel(o.getName()); - content.setNodeRef(o.getId()); - content.setDescription(o.getDescription()); - content.setCmisLocation(Utility.buildPath(folderParent, o.getName())); - contents.put(content, o.getType()); - } - return contents; - } - - /** - * Gets the folder descendants starting with the current folder - * - * @param depth level of the tree that you want to go to - * - currentFolder - * -- file1.txt - * -- file2.txt - * -- folderB - * --- file3.txt - * --- file4.txt - * e.g. A depth of 1 will give you just the current folder descendants (file1.txt, file2.txt, folder1) - * e.g. A depth of -1 will return all the descendants (file1.txt, file2.txt, folder1, file3.txt and file4.txt) - */ - public List getFolderDescendants(int depth) - { - return getFolderTreeCmisObjects(getCmisFolder(cmisAPI.getLastResource()).getDescendants(depth)); - } - - /** - * Returns a list of Cmis objects for the provided Content Models - * - * @param contentModels - */ - public List getCmisObjectsFromContentModels(ContentModel... contentModels) - { - List cmisObjects = new ArrayList<>(); - for (ContentModel contentModel : contentModels) - cmisObjects.add(getCmisObject(contentModel.getCmisLocation())); - return cmisObjects; - } - - public ContentStream getContentStream(String content) throws Exception - { - String fileName = getCmisDocument(cmisAPI.getLastResource()).getName(); - - return cmisAPI.getDataContentService().getContentStream(fileName, content); - } - - public Acl getAcls() - { - OperationContext context = cmisAPI.getSession().createOperationContext(); - context.setIncludeAcls(true); - return getCmisObject(cmisAPI.getLastResource(), context).getAcl(); - } - - /** - * Gets only the folder descendants for the {@link #getLastResource()} folder - * - * @param depth level of the tree that you want to go to - * - currentFolder - * -- folderB - * -- folderC - * --- folderD - * e.g. A depth of 1 will give you just the current folder descendants (folderB, folderC) - * e.g. A depth of -1 will return all the descendants (folderB, folderC, folderD) - */ - public List getFolderTree(int depth) - { - return getFolderTreeCmisObjects(getCmisFolder(cmisAPI.getLastResource()).getFolderTree(depth)); - } - - /** - * Helper method for getFolderTree and getFolderDescendants that cycles threw the folder descendants and returns List - */ - private List getFolderTreeCmisObjects(List> descendants) - { - List cmisObjectList = new ArrayList<>(); - for (Tree descendant : descendants) - { - cmisObjectList.add(descendant.getItem()); - cmisObjectList.addAll(descendant.getChildren().stream().map(Tree::getItem).collect(Collectors.toList())); - } - return cmisObjectList; - } - - protected List getAllDocumentVersions() - { - return getCmisDocument(cmisAPI.getLastResource()).getAllVersions(); - } - - public List getAllDocumentVersionsBy(OperationContext context) - { - return getCmisDocument(cmisAPI.getLastResource()).getAllVersions(context); - } - - public List getCheckedOutDocumentsFromSession() - { - return com.google.common.collect.Lists.newArrayList(cmisAPI.getSession().getCheckedOutDocs()); - } - - public List getCheckedOutDocumentsFromSession(OperationContext context) - { - return com.google.common.collect.Lists.newArrayList(cmisAPI.getSession().getCheckedOutDocs(context)); - } - - public List getCheckedOutDocumentsFromFolder() - { - Folder folder = cmisAPI.withCMISUtil().getCmisFolder(cmisAPI.getLastResource()); - return com.google.common.collect.Lists.newArrayList(folder.getCheckedOutDocs()); - } - - public List getCheckedOutDocumentsFromFolder(OperationContext context) - { - Folder folder = cmisAPI.withCMISUtil().getCmisFolder(cmisAPI.getLastResource()); - return com.google.common.collect.Lists.newArrayList(folder.getCheckedOutDocs(context)); - } - - protected boolean isCmisObjectContainedInCmisCheckedOutDocumentsList(CmisObject cmisObject, List cmisCheckedOutDocuments) - { - for (Document cmisCheckedOutDocument : cmisCheckedOutDocuments) - if (cmisObject.getId().split(";")[0].equals(cmisCheckedOutDocument.getId().split(";")[0])) - return true; - return false; - } - - public Map getProperties(ContentModel contentModel, String baseTypeId) - { - List aspects = new ArrayList(); - aspects.add("P:cm:titled"); - Map properties = new HashMap(); - properties.put(PropertyIds.OBJECT_TYPE_ID, baseTypeId); - properties.put(PropertyIds.NAME, contentModel.getName()); - properties.put(PropertyIds.SECONDARY_OBJECT_TYPE_IDS, aspects); - properties.put("cm:title", contentModel.getTitle()); - properties.put("cm:description", contentModel.getDescription()); - return properties; - } - - public OperationContext setIncludeAclContext() - { - OperationContext context = cmisAPI.getSession().createOperationContext(); - context.setIncludeAcls(true); - return context; - } - - public List createAce(UserModel user, UserRole role) - { - List addPermission = new ArrayList(); - addPermission.add(role.getRoleId()); - Ace addAce = cmisAPI.getSession().getObjectFactory().createAce(user.getUsername(), addPermission); - List addAces = new ArrayList(); - addAces.add(addAce); - return addAces; - } - - public List createAce(GroupModel group, UserRole role) - { - List addPermission = new ArrayList(); - addPermission.add(role.getRoleId()); - Ace addAce = cmisAPI.getSession().getObjectFactory().createAce(group.getDisplayName(), addPermission); - List addAces = new ArrayList(); - addAces.add(addAce); - return addAces; - } - - public List createAce(UserModel user, String... permissions) - { - List addAces = new ArrayList(); - RepositoryInfo repositoryInfo = cmisAPI.getSession().getRepositoryInfo(); - AclCapabilities aclCapabilities = repositoryInfo.getAclCapabilities(); - Map permissionMappings = aclCapabilities.getPermissionMapping(); - for (String perm : permissions) - { - STEP(String.format("%s Add permission '%s' for user %s ", CmisWrapper.STEP_PREFIX, perm, user.getUsername())); - PermissionMapping permissionMapping = permissionMappings.get(perm); - List permissionsList = permissionMapping.getPermissions(); - Ace addAce = cmisAPI.getSession().getObjectFactory().createAce(user.getUsername(), permissionsList); - addAces.add(addAce); - } - return addAces; - } - - public ObjectType getTypeDefinition() - { - CmisObject cmisObject = cmisAPI.withCMISUtil().getCmisObject(cmisAPI.getLastResource()); - return cmisAPI.getSession().getTypeDefinition(cmisObject.getBaseTypeId().value()); - } - - public ItemIterable getTypeChildren(String baseType, boolean includePropertyDefinitions) - { - STEP(String.format("%s Get type children for '%s' and includePropertyDefinitions set to '%s'", CmisWrapper.STEP_PREFIX, baseType, - includePropertyDefinitions)); - return cmisAPI.getSession().getTypeChildren(baseType, includePropertyDefinitions); - } - - public List> getTypeDescendants(String baseTypeId, int depth, boolean includePropertyDefinitions) - { - STEP(String.format("%s Get type descendants for '%s' with depth set to %d and includePropertyDefinitions set to '%s'", CmisWrapper.STEP_PREFIX, - baseTypeId, depth, includePropertyDefinitions)); - return cmisAPI.getSession().getTypeDescendants(baseTypeId, depth, includePropertyDefinitions); - } - - public String getObjectId(String pathToObject) - { - return getCmisObject(pathToObject).getId(); - } - - /** - * Update property for last resource cmis object - * - * @param propertyName String property name (e.g. cmis:name) - * @param propertyValue Object property value - */ - public void updateProperties(String propertyName, Object propertyValue) - { - Map props = new HashMap(); - props.put(propertyName, propertyValue); - getCmisObject(cmisAPI.getLastResource()).updateProperties(props); - } - - protected boolean isFolderInList(FolderModel folderModel, List folders) - { - for (FolderModel folder : folders) - { - if (folderModel.getName().equals(folder.getName())) - { - return true; - } - } - return false; - } - - protected boolean isFileInList(FileModel fileModel, List files) - { - for (FileModel file : files) - { - if (fileModel.getName().equals(file.getName())) - { - return true; - } - } - return false; - } - - protected boolean isContentInList(ContentModel contentModel, List contents) - { - for (ContentModel content : contents) - { - if (content.getName().equals(content.getName())) - { - return true; - } - } - return false; - } - - /** - * Get children folders from a parent folder - * - * @return List - */ - public List getFolders() throws Exception - { - STEP(String.format("%s Get the folder children from '%s'", CmisWrapper.STEP_PREFIX, cmisAPI.getLastResource())); - Map children = getChildren(); - List folders = new ArrayList(); - for (Map.Entry entry : children.entrySet()) - { - if (entry.getValue().getId().equals(BaseTypeId.CMIS_FOLDER.value())) - { - FolderModel folder = new FolderModel(entry.getKey().getName()); - folder.setNodeRef(entry.getKey().getNodeRef()); - folder.setDescription(entry.getKey().getDescription()); - folder.setCmisLocation(entry.getKey().getCmisLocation()); - folder.setProtocolLocation(entry.getKey().getCmisLocation()); - folders.add(folder); - } - } - return folders; - } - - /** - * Get children documents from a parent folder - * - * @return List - */ - public List getFiles() throws Exception - { - STEP(String.format("%s Get the file children from '%s'", CmisWrapper.STEP_PREFIX, cmisAPI.getLastResource())); - Map children = getChildren(); - List files = new ArrayList(); - for (Map.Entry entry : children.entrySet()) - { - if (entry.getValue().getId().equals(BaseTypeId.CMIS_DOCUMENT.value())) - { - FileModel file = new FileModel(entry.getKey().getName()); - file.setNodeRef(entry.getKey().getNodeRef()); - file.setDescription(entry.getKey().getDescription()); - file.setCmisLocation(entry.getKey().getCmisLocation()); - file.setProtocolLocation(entry.getKey().getCmisLocation()); - files.add(file); - } - } - return files; - } - - /* - * Get document(set as last resource) content - */ - public String getDocumentContent() throws Exception - { - Utility.waitToLoopTime(2); - Document lastVersion = getCmisDocument(cmisAPI.getLastResource()); - lastVersion.refresh(); - LOG.info(String.format("Get the content from %s - node: %s", lastVersion.getName(), lastVersion.getId())); - ContentStream contentStream = lastVersion.getContentStream(); - String actualContent = ""; - if (contentStream != null) - { - actualContent = getContentAsString(contentStream); - } - else - { - lastVersion = getCmisDocument(cmisAPI.getLastResource()); - lastVersion.refresh(); - LOG.info(String.format("Retry get content stream for %s node: %s", lastVersion.getName(), lastVersion.getId())); - contentStream = lastVersion.getContentStream(); - if (contentStream != null) - { - actualContent = getContentAsString(contentStream); - } - } - if(actualContent.isEmpty()) - { - Utility.waitToLoopTime(2); - Document retryDoc = getCmisDocument(cmisAPI.getLastResource()); - retryDoc.refresh(); - LOG.info(String.format("Retry get content stream for %s node: %s", retryDoc.getName(), retryDoc.getId())); - contentStream = retryDoc.getContentStream(); - if (contentStream != null) - { - actualContent = getContentAsString(contentStream); - } - } - return actualContent; - } - - /** - * Get user noderef - * - * @param user {@link UserModel} - */ - public String getUserNodeRef(UserModel user) - { - String objectId = ""; - ItemIterable results = cmisAPI.getSession().query("select cmis:objectId from cm:person where cm:userName = '" + user.getUsername() + "'", - false); - for (QueryResult qResult : results) - { - PropertyData propData = qResult.getPropertyById("cmis:objectId"); - objectId = (String) propData.getFirstValue(); - } - return objectId; - } -} diff --git a/e2e-test/src/main/java/org/alfresco/cmis/dsl/DocumentVersioning.java b/e2e-test/src/main/java/org/alfresco/cmis/dsl/DocumentVersioning.java deleted file mode 100644 index e772aec0a..000000000 --- a/e2e-test/src/main/java/org/alfresco/cmis/dsl/DocumentVersioning.java +++ /dev/null @@ -1,137 +0,0 @@ -package org.alfresco.cmis.dsl; - -import static org.alfresco.utility.report.log.Step.STEP; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.alfresco.cmis.CmisWrapper; -import org.apache.chemistry.opencmis.client.api.CmisObject; -import org.apache.chemistry.opencmis.client.api.Document; -import org.apache.chemistry.opencmis.client.api.OperationContext; -import org.testng.Assert; - -/** - * DSL utility for verifying a document version {@link Document} - */ -public class DocumentVersioning -{ - private CmisWrapper cmisWrapper; - private CmisObject cmisObject; - private boolean majorVersion; - private Object versionLabel; - private List versions; - - public DocumentVersioning(CmisWrapper cmisWrapper, CmisObject cmisObject) - { - this.cmisWrapper = cmisWrapper; - this.cmisObject = cmisObject; - } - - private DocumentVersioning withLatestMajorVersion() - { - this.majorVersion = true; - return this; - } - - private DocumentVersioning withLatestMinorVersion() - { - this.majorVersion = false; - return this; - } - - private Document getVersionOfDocument() - { - Document document = (Document) cmisObject; - if (versionLabel != null) - { - List documents = document.getAllVersions(); - for (Document documentVersion : documents) - if (documentVersion.getVersionLabel().equals(versionLabel.toString())) - return documentVersion; - } - else - { - return document.getObjectOfLatestVersion(majorVersion); - } - return document; - } - - private List getDocumentVersions(List documentList) - { - List versions = new ArrayList(); - for (Document document : documentList) - { - versions.add(document.getVersionLabel()); - } - return versions; - } - - public CmisWrapper assertVersionIs(Double expectedVersion) - { - STEP(String.format("%s Verify if document '%s' has version '%s'", cmisWrapper.getProtocolName(), cmisObject.getName(), expectedVersion)); - Assert.assertEquals(getVersionOfDocument().getVersionLabel(), expectedVersion.toString(), "File has version"); - return cmisWrapper; - } - - public CmisWrapper assertLatestMajorVersionIs(Double expectedVersion) - { - STEP(String.format("%s Verify if latest major version of document '%s' is '%s'", cmisWrapper.getProtocolName(), cmisObject.getName(), expectedVersion)); - Assert.assertEquals(withLatestMajorVersion().getVersionOfDocument().getVersionLabel(), expectedVersion.toString(), "File has version"); - return cmisWrapper; - } - - public CmisWrapper assertLatestMinorVersionIs(Double expectedVersion) - { - STEP(String.format("%s Verify if latest minor version of document '%s' is '%s'", cmisWrapper.getProtocolName(), cmisObject.getName(), expectedVersion)); - Assert.assertEquals(withLatestMinorVersion().getVersionOfDocument().getVersionLabel(), expectedVersion.toString(), "File has version"); - return cmisWrapper; - } - - public DocumentVersioning getAllDocumentVersions() - { - setVersions(getDocumentVersions(cmisWrapper.withCMISUtil().getAllDocumentVersions())); - return this; - } - - public CmisWrapper assertHasVersions(Object... versions) - { - setVersions(getDocumentVersions(cmisWrapper.withCMISUtil().getAllDocumentVersions())); - List documentVersions = getVersions(); - for (Object version : versions) - { - STEP(String.format("%s Verify if document '%s' has version '%s'", cmisWrapper.getProtocolName(), cmisObject.getName(), version)); - Assert.assertTrue(documentVersions.contains(version.toString()), - String.format("Document %s does not have version %s", cmisObject.getName(), version)); - } - return cmisWrapper; - } - - public DocumentVersioning getAllDocumentVersionsBy(OperationContext context) - { - setVersions(getDocumentVersions(cmisWrapper.withCMISUtil().getAllDocumentVersionsBy(context))); - return this; - } - - public CmisWrapper assertHasVersionsInOrder(Object... versions) - { - List documentVersions = getVersions(); - List expectedVersions = Arrays.asList(versions); - STEP(String.format("%s Verify if document '%s' has versions in this order '%s'", cmisWrapper.getProtocolName(), cmisObject.getName(), - Arrays.toString(expectedVersions.toArray()))); - Assert.assertTrue(documentVersions.toString().equals(expectedVersions.toString()), - String.format("Document %s does not have versions in this order %s", cmisObject.getName(), Arrays.toString(expectedVersions.toArray()))); - return cmisWrapper; - } - - public List getVersions() - { - return versions; - } - - public void setVersions(List versions) - { - this.versions = versions; - } -} diff --git a/e2e-test/src/main/java/org/alfresco/cmis/dsl/JmxUtil.java b/e2e-test/src/main/java/org/alfresco/cmis/dsl/JmxUtil.java deleted file mode 100644 index 40666d1cb..000000000 --- a/e2e-test/src/main/java/org/alfresco/cmis/dsl/JmxUtil.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.alfresco.cmis.dsl; - -import org.alfresco.cmis.CmisWrapper; -import org.alfresco.utility.network.Jmx; -import org.alfresco.utility.network.JmxClient; -import org.alfresco.utility.network.JmxJolokiaProxyClient; - -/** - * DSL for interacting with JMX (using direct JMX call see {@link JmxClient} or {@link JmxJolokiaProxyClient} - */ -public class JmxUtil -{ - @SuppressWarnings("unused") - private CmisWrapper cmisWrapper; - private Jmx jmx; - private final String jmxAuditObjectName = "Alfresco:Type=Configuration,Category=Audit,id1=default"; - - public JmxUtil(CmisWrapper cmisWrapper, Jmx jmx) - { - this.cmisWrapper = cmisWrapper; - this.jmx = jmx; - } - - public void enableCMISAudit() throws Exception - { - if(jmx.readProperty(jmxAuditObjectName, "audit.enabled").equals(String.valueOf(false))) - { - jmx.writeProperty(jmxAuditObjectName, "audit.enabled", String.valueOf(true)); - } - jmx.writeProperty(jmxAuditObjectName, "audit.cmischangelog.enabled", String.valueOf(true)); - jmx.writeProperty(jmxAuditObjectName, "audit.alfresco-access.enabled", String.valueOf(true)); - } - - public void disableCMISAudit() throws Exception - { - jmx.writeProperty(jmxAuditObjectName, "audit.cmischangelog.enabled", String.valueOf(false)); - jmx.writeProperty(jmxAuditObjectName, "audit.alfresco-access.enabled", String.valueOf(false)); - } -} diff --git a/e2e-test/src/main/java/org/alfresco/cmis/dsl/QueryExecutor.java b/e2e-test/src/main/java/org/alfresco/cmis/dsl/QueryExecutor.java deleted file mode 100644 index 7d93ceb2a..000000000 --- a/e2e-test/src/main/java/org/alfresco/cmis/dsl/QueryExecutor.java +++ /dev/null @@ -1,166 +0,0 @@ -package org.alfresco.cmis.dsl; - -import static org.alfresco.utility.report.log.Step.STEP; - -import java.util.ArrayList; -import java.util.List; - -import org.alfresco.cmis.CmisWrapper; -import org.alfresco.utility.LogFactory; -import org.alfresco.utility.data.provider.XMLTestData; -import org.alfresco.utility.exception.TestConfigurationException; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestModel; -import org.apache.chemistry.opencmis.client.api.ItemIterable; -import org.apache.chemistry.opencmis.client.api.QueryResult; -import org.apache.chemistry.opencmis.client.api.Session; -import org.slf4j.Logger; -import org.testng.Assert; - -/** - * DSL for CMIS Queries - * This will also handle execution of CMIS queries - */ -public class QueryExecutor -{ - static Logger LOG = LogFactory.getLogger(); - - CmisWrapper cmisWrapper; - private long returnedResults = -1; - private String currentQuery = ""; - - public QueryExecutor(CmisWrapper cmisWrapper, String query) - { - this.cmisWrapper = cmisWrapper; - currentQuery = query; - } - - public QueryResultAssertion assertResultsCount() throws Exception - { - returnedResults = executeQuery(currentQuery).getPageNumItems(); - return new QueryResultAssertion(); - } - - private ItemIterable executeQuery(String query) throws Exception - { - Session session = cmisWrapper.getSession(); - if (session == null) - throw new Exception("You need to authenticate first using "); - - return session.query(query, false); - } - - /** - * Call getNodeRef on each test data item used in test and replace that with NODE_REF keywords in your Query - * - * @param testData - * @return - * @throws Exception - */ - public QueryExecutor applyNodeRefsFrom(XMLTestData testData) throws Exception - { - List dataItems = extractKeywords("NODE_REF"); - if (dataItems.isEmpty()) - return this; - - List nodeRefs = new ArrayList(); - for (String dataItemName : dataItems) - { - currentQuery = currentQuery.replace(String.format("NODE_REF[%s]", dataItemName), "%s"); - TestModel model = testData.getTestDataItemWithId(dataItemName).getModel(); - if (model == null) - throw new TestConfigurationException("No TestData with ID: " + dataItemName + " found in your XML file."); - - if (model instanceof SiteModel) - { - nodeRefs.add(cmisWrapper.getDataContentService().usingAdmin().usingSite((SiteModel) model).getNodeRef()); - } - else if (model instanceof FolderModel) - { - nodeRefs.add(((FolderModel) model).getNodeRef()); - } - else if (model instanceof FileModel) - { - nodeRefs.add(((FileModel) model).getNodeRef()); - } - } - - try - { - currentQuery = String.format(currentQuery, nodeRefs.toArray()); - LOG.info("Injecting nodeRef IDs \n\tQuery: [{}]", currentQuery); - } - catch (Exception e) - { - throw new TestConfigurationException( - "You passed multiple keywords to your search query, please re-analyze your query search format: " + e.getMessage()); - } - return this; - } - - /** - * if you have in your search 'SELECT * from cmis:document where workspace://SpacesStore/NODE_REF[site1] or workspace://SpacesStore/NODE_REF[site2]' - * and pass key="NODE_REF" this method will get "site1" and "site2" as values - * - * @param key - * @return - * @throws TestConfigurationException - */ - private List extractKeywords(String key) throws TestConfigurationException - { - String[] lines = currentQuery.split(key); - List keywords = new ArrayList(); - - for (int i = 0; i < lines.length; i++) - { - if (lines[i].startsWith("[")) - { - String keyValue = ""; - for (int j = 1; j < lines[i].length() - 1; j++) - { - String tmp = Character.toString(lines[i].charAt(j)); - if (tmp.equals("]")) - break; - keyValue += tmp; - } - keywords.add(keyValue); - } - } - return keywords; - } - - public class QueryResultAssertion - { - public QueryResultAssertion equals(long expectedValue) - { - STEP(String.format("Verify that query: '%s' has %d results count returned", currentQuery, expectedValue)); - Assert.assertEquals(returnedResults, expectedValue, showErrorMessage()); - return this; - } - - public QueryResultAssertion isGreaterThan(long expectedValue) - { - STEP(String.format("Verify that query: '%s' has more than %d results count returned", currentQuery, expectedValue)); - if (expectedValue <= returnedResults) - Assert.fail(String.format("%s expected to have more than %d results, but found %d", showErrorMessage(), expectedValue, returnedResults)); - - return this; - } - - public QueryResultAssertion isLowerThan(long expectedValue) - { - STEP(String.format("Verify that query: '%s' has more than %d results count returned", currentQuery, expectedValue)); - if (returnedResults >= expectedValue) - Assert.fail(String.format("%s expected to have less than %d results, but found %d", showErrorMessage(), expectedValue, returnedResults)); - - return this; - } - - private String showErrorMessage() - { - return String.format("Returned results count of Query [%s] is not the expected one:", currentQuery); - } - } -} diff --git a/e2e-test/src/main/java/org/alfresco/cmis/exception/InvalidCmisObjectException.java b/e2e-test/src/main/java/org/alfresco/cmis/exception/InvalidCmisObjectException.java deleted file mode 100644 index 9bc532652..000000000 --- a/e2e-test/src/main/java/org/alfresco/cmis/exception/InvalidCmisObjectException.java +++ /dev/null @@ -1,10 +0,0 @@ -package org.alfresco.cmis.exception; - -public class InvalidCmisObjectException extends RuntimeException -{ - private static final long serialVersionUID = 1L; - public InvalidCmisObjectException(String reason) - { - super(reason); - } -} diff --git a/e2e-test/src/main/java/org/alfresco/cmis/exception/UnrecognizedBinding.java b/e2e-test/src/main/java/org/alfresco/cmis/exception/UnrecognizedBinding.java deleted file mode 100644 index cf1dcaf25..000000000 --- a/e2e-test/src/main/java/org/alfresco/cmis/exception/UnrecognizedBinding.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.alfresco.cmis.exception; - -public class UnrecognizedBinding extends Exception -{ - private static final long serialVersionUID = 1L; - private static final String DEFAULT_MESSAGE = "Unrecognized CMIS Binding [%s]. Available binding options: BROWSER or ATOM"; - - public UnrecognizedBinding(String binding) - { - super(String.format(DEFAULT_MESSAGE, binding)); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/CmisTest.java b/e2e-test/src/test/java/org/alfresco/service/search/cmis/CmisTest.java similarity index 89% rename from e2e-test/src/test/java/org/alfresco/service/search/CmisTest.java rename to e2e-test/src/test/java/org/alfresco/service/search/cmis/CmisTest.java index 33d4b926d..2493f61f9 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/CmisTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/cmis/CmisTest.java @@ -1,5 +1,6 @@ -package org.alfresco.service.search; +package org.alfresco.service.search.cmis; +import org.alfresco.cmis.CmisProperties; import org.alfresco.cmis.CmisWrapper; import java.lang.reflect.Method; @@ -28,6 +29,9 @@ public abstract class CmisTest extends AbstractTestNGSpringContextTests @Autowired protected CmisWrapper cmisApi; + + @Autowired + protected CmisProperties cmisProperties; @Autowired protected DataUser dataUser; @@ -64,6 +68,6 @@ public abstract class CmisTest extends AbstractTestNGSpringContextTests public Integer getSolrWaitTimeInSeconds() { - return cmisApi.cmisProperties.envProperty().getSolrWaitTimeInSeconds(); + return cmisProperties.envProperty().getSolrWaitTimeInSeconds(); } } diff --git a/e2e-test/src/test/java/org/alfresco/service/search/cmis/SolrSearchByAspectTests.java b/e2e-test/src/test/java/org/alfresco/service/search/cmis/SolrSearchByAspectTests.java index 354755fed..c08fb6e90 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/cmis/SolrSearchByAspectTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/cmis/SolrSearchByAspectTests.java @@ -1,7 +1,5 @@ package org.alfresco.service.search.cmis; -import org.alfresco.service.search.CmisTest; - import org.alfresco.utility.Utility; import org.alfresco.utility.data.provider.XMLDataConfig; import org.alfresco.utility.data.provider.XMLTestData; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/cmis/SolrSearchByIdTests.java b/e2e-test/src/test/java/org/alfresco/service/search/cmis/SolrSearchByIdTests.java index f46b78a12..dc03ae4df 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/cmis/SolrSearchByIdTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/cmis/SolrSearchByIdTests.java @@ -1,6 +1,5 @@ package org.alfresco.service.search.cmis; -import org.alfresco.service.search.CmisTest; import org.alfresco.utility.Utility; import org.alfresco.utility.data.provider.XMLDataConfig; import org.alfresco.utility.data.provider.XMLTestData; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/cmis/SolrSearchByPathTests.java b/e2e-test/src/test/java/org/alfresco/service/search/cmis/SolrSearchByPathTests.java index 4ee8a2f14..d72c43617 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/cmis/SolrSearchByPathTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/cmis/SolrSearchByPathTests.java @@ -1,6 +1,5 @@ package org.alfresco.service.search.cmis; -import org.alfresco.service.search.CmisTest; import org.alfresco.utility.Utility; import org.alfresco.utility.data.provider.XMLDataConfig; import org.alfresco.utility.data.provider.XMLTestData; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/cmis/SolrSearchByPropertyTests.java b/e2e-test/src/test/java/org/alfresco/service/search/cmis/SolrSearchByPropertyTests.java index c8e0c298c..54715531f 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/cmis/SolrSearchByPropertyTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/cmis/SolrSearchByPropertyTests.java @@ -1,6 +1,5 @@ package org.alfresco.service.search.cmis; -import org.alfresco.service.search.CmisTest; import org.alfresco.utility.Utility; import org.alfresco.utility.data.provider.XMLDataConfig; import org.alfresco.utility.data.provider.XMLTestData; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/cmis/SolrSearchInFolderTests.java b/e2e-test/src/test/java/org/alfresco/service/search/cmis/SolrSearchInFolderTests.java index 9edcb509e..f2d58b959 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/cmis/SolrSearchInFolderTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/cmis/SolrSearchInFolderTests.java @@ -1,6 +1,5 @@ package org.alfresco.service.search.cmis; -import org.alfresco.service.search.CmisTest; import org.alfresco.utility.Utility; import org.alfresco.utility.data.provider.XMLDataConfig; import org.alfresco.utility.data.provider.XMLTestData; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/cmis/SolrSearchInTreeTests.java b/e2e-test/src/test/java/org/alfresco/service/search/cmis/SolrSearchInTreeTests.java index ad5944a2b..b21fc8b02 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/cmis/SolrSearchInTreeTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/cmis/SolrSearchInTreeTests.java @@ -1,6 +1,5 @@ package org.alfresco.service.search.cmis; -import org.alfresco.service.search.CmisTest; import org.alfresco.utility.Utility; import org.alfresco.utility.data.provider.XMLDataConfig; import org.alfresco.utility.data.provider.XMLTestData; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/cmis/SorlSearchSimpleQueryTests.java b/e2e-test/src/test/java/org/alfresco/service/search/cmis/SorlSearchSimpleQueryTests.java index fd8f232da..c4ab2b9a1 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/cmis/SorlSearchSimpleQueryTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/cmis/SorlSearchSimpleQueryTests.java @@ -1,6 +1,5 @@ package org.alfresco.service.search.cmis; -import org.alfresco.service.search.CmisTest; import org.testng.annotations.Test; public class SorlSearchSimpleQueryTests extends CmisTest diff --git a/e2e-test/src/main/resources/cmis-search.xml b/e2e-test/src/test/resources/cmis-search.xml similarity index 100% rename from e2e-test/src/main/resources/cmis-search.xml rename to e2e-test/src/test/resources/cmis-search.xml From 16126a5b6b26604b65394c00fd2c5ad6b434566d Mon Sep 17 00:00:00 2001 From: Keerat Date: Wed, 20 Mar 2019 13:15:50 +0000 Subject: [PATCH 1471/1491] Search-1485, modified changes from Meenal --- .../test/resources/alfresco-cmis-context.xml | 19 ------------------- e2e-test/src/test/resources/cmis-search.xml | 2 +- .../resources/testdata/for-upgrade.xml | 0 .../resources/testdata/search-by-aspect.xml | 0 .../resources/testdata/search-by-id.xml | 0 .../resources/testdata/search-by-path.xml | 0 .../resources/testdata/search-by-property.xml | 0 .../resources/testdata/search-in-folder.xml | 0 .../resources/testdata/search-in-tree.xml | 0 9 files changed, 1 insertion(+), 20 deletions(-) delete mode 100644 e2e-test/src/test/resources/alfresco-cmis-context.xml rename e2e-test/src/{main => test}/resources/testdata/for-upgrade.xml (100%) rename e2e-test/src/{main => test}/resources/testdata/search-by-aspect.xml (100%) rename e2e-test/src/{main => test}/resources/testdata/search-by-id.xml (100%) rename e2e-test/src/{main => test}/resources/testdata/search-by-path.xml (100%) rename e2e-test/src/{main => test}/resources/testdata/search-by-property.xml (100%) rename e2e-test/src/{main => test}/resources/testdata/search-in-folder.xml (100%) rename e2e-test/src/{main => test}/resources/testdata/search-in-tree.xml (100%) diff --git a/e2e-test/src/test/resources/alfresco-cmis-context.xml b/e2e-test/src/test/resources/alfresco-cmis-context.xml deleted file mode 100644 index f5465c071..000000000 --- a/e2e-test/src/test/resources/alfresco-cmis-context.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - diff --git a/e2e-test/src/test/resources/cmis-search.xml b/e2e-test/src/test/resources/cmis-search.xml index cd6c6d881..20edb63b5 100644 --- a/e2e-test/src/test/resources/cmis-search.xml +++ b/e2e-test/src/test/resources/cmis-search.xml @@ -1,6 +1,6 @@ - + diff --git a/e2e-test/src/main/resources/testdata/for-upgrade.xml b/e2e-test/src/test/resources/testdata/for-upgrade.xml similarity index 100% rename from e2e-test/src/main/resources/testdata/for-upgrade.xml rename to e2e-test/src/test/resources/testdata/for-upgrade.xml diff --git a/e2e-test/src/main/resources/testdata/search-by-aspect.xml b/e2e-test/src/test/resources/testdata/search-by-aspect.xml similarity index 100% rename from e2e-test/src/main/resources/testdata/search-by-aspect.xml rename to e2e-test/src/test/resources/testdata/search-by-aspect.xml diff --git a/e2e-test/src/main/resources/testdata/search-by-id.xml b/e2e-test/src/test/resources/testdata/search-by-id.xml similarity index 100% rename from e2e-test/src/main/resources/testdata/search-by-id.xml rename to e2e-test/src/test/resources/testdata/search-by-id.xml diff --git a/e2e-test/src/main/resources/testdata/search-by-path.xml b/e2e-test/src/test/resources/testdata/search-by-path.xml similarity index 100% rename from e2e-test/src/main/resources/testdata/search-by-path.xml rename to e2e-test/src/test/resources/testdata/search-by-path.xml diff --git a/e2e-test/src/main/resources/testdata/search-by-property.xml b/e2e-test/src/test/resources/testdata/search-by-property.xml similarity index 100% rename from e2e-test/src/main/resources/testdata/search-by-property.xml rename to e2e-test/src/test/resources/testdata/search-by-property.xml diff --git a/e2e-test/src/main/resources/testdata/search-in-folder.xml b/e2e-test/src/test/resources/testdata/search-in-folder.xml similarity index 100% rename from e2e-test/src/main/resources/testdata/search-in-folder.xml rename to e2e-test/src/test/resources/testdata/search-in-folder.xml diff --git a/e2e-test/src/main/resources/testdata/search-in-tree.xml b/e2e-test/src/test/resources/testdata/search-in-tree.xml similarity index 100% rename from e2e-test/src/main/resources/testdata/search-in-tree.xml rename to e2e-test/src/test/resources/testdata/search-in-tree.xml From d8758852bae9ff6d11f05a381af3e26cd0ff693e Mon Sep 17 00:00:00 2001 From: Keerat Date: Fri, 22 Mar 2019 08:47:46 +0000 Subject: [PATCH 1472/1491] Search-1485 cmistest modified --- .../test/java/org/alfresco/service/search/cmis/CmisTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/src/test/java/org/alfresco/service/search/cmis/CmisTest.java b/e2e-test/src/test/java/org/alfresco/service/search/cmis/CmisTest.java index 2493f61f9..bac864409 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/cmis/CmisTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/cmis/CmisTest.java @@ -20,7 +20,7 @@ import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.BeforeSuite; -@ContextConfiguration("classpath:alfresco-cmis-context.xml") +@ContextConfiguration("classpath:alfresco-search-e2e-context.xml") @Component @Scope(value = "prototype") public abstract class CmisTest extends AbstractTestNGSpringContextTests From 22eeec2841119e650cf03f17bb42f63d8335c22e Mon Sep 17 00:00:00 2001 From: Keerat Date: Fri, 22 Mar 2019 12:09:48 +0000 Subject: [PATCH 1473/1491] Search-1485 --- .../alfresco/service/search/cmis/SolrSearchByAspectTests.java | 4 ++-- .../org/alfresco/service/search/cmis/SolrSearchByIdTests.java | 4 ++-- .../alfresco/service/search/cmis/SolrSearchByPathTests.java | 4 ++-- .../service/search/cmis/SolrSearchByPropertyTests.java | 4 ++-- .../alfresco/service/search/cmis/SolrSearchInFolderTests.java | 2 +- .../alfresco/service/search/cmis/SolrSearchInTreeTests.java | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/e2e-test/src/test/java/org/alfresco/service/search/cmis/SolrSearchByAspectTests.java b/e2e-test/src/test/java/org/alfresco/service/search/cmis/SolrSearchByAspectTests.java index c08fb6e90..045557cce 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/cmis/SolrSearchByAspectTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/cmis/SolrSearchByAspectTests.java @@ -40,7 +40,7 @@ public class SolrSearchByAspectTests extends CmisTest } @Test(dataProviderClass = XMLTestDataProvider.class, dataProvider = "getAllData") - @XMLDataConfig(file = "src/main/resources/testdata/search-by-aspect.xml") + @XMLDataConfig(file = "src/test/resources/testdata/search-by-aspect.xml") public void prepareDataForAspectSearch(XMLTestData testData) throws Exception { this.testData = testData; @@ -52,7 +52,7 @@ public class SolrSearchByAspectTests extends CmisTest @Test(groups = { TestGroup.CMIS, TestGroup.QUERIES }, dataProviderClass = XMLTestDataProvider.class, dataProvider = "getQueriesData", dependsOnMethods = "prepareDataForAspectSearch") - @XMLDataConfig(file = "src/main/resources/testdata/search-by-aspect.xml") + @XMLDataConfig(file = "src/test/resources/testdata/search-by-aspect.xml") public void executeSearchByAspect(QueryModel query) throws Exception { cmisApi.withQuery(query.getValue()) diff --git a/e2e-test/src/test/java/org/alfresco/service/search/cmis/SolrSearchByIdTests.java b/e2e-test/src/test/java/org/alfresco/service/search/cmis/SolrSearchByIdTests.java index dc03ae4df..458eea9a8 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/cmis/SolrSearchByIdTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/cmis/SolrSearchByIdTests.java @@ -40,7 +40,7 @@ public class SolrSearchByIdTests extends CmisTest } @Test(dataProviderClass = XMLTestDataProvider.class, dataProvider = "getAllData") - @XMLDataConfig(file = "src/main/resources/testdata/search-by-id.xml") + @XMLDataConfig(file = "src/test/resources/testdata/search-by-id.xml") public void prepareDataForSearchById(XMLTestData testData) throws Exception { this.testData = testData; @@ -52,7 +52,7 @@ public class SolrSearchByIdTests extends CmisTest @Test(groups = { TestGroup.CMIS, TestGroup.QUERIES }, dataProviderClass = XMLTestDataProvider.class, dataProvider = "getQueriesData", dependsOnMethods = "prepareDataForSearchById") - @XMLDataConfig(file = "src/main/resources/testdata/search-by-id.xml") + @XMLDataConfig(file = "src/test/resources/testdata/search-by-id.xml") public void executeSortedSearchByID(QueryModel query) throws Exception { cmisApi.withQuery(query.getValue()) diff --git a/e2e-test/src/test/java/org/alfresco/service/search/cmis/SolrSearchByPathTests.java b/e2e-test/src/test/java/org/alfresco/service/search/cmis/SolrSearchByPathTests.java index d72c43617..e0da6e600 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/cmis/SolrSearchByPathTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/cmis/SolrSearchByPathTests.java @@ -38,7 +38,7 @@ public class SolrSearchByPathTests extends CmisTest } @Test(dataProviderClass = XMLTestDataProvider.class, dataProvider = "getAllData") - @XMLDataConfig(file = "src/main/resources/testdata/search-by-path.xml") + @XMLDataConfig(file = "src/test/resources/testdata/search-by-path.xml") public void prepareDataForSearchByPath(XMLTestData testData) throws Exception { this.testData = testData; @@ -50,7 +50,7 @@ public class SolrSearchByPathTests extends CmisTest @Test(groups = { TestGroup.CMIS, TestGroup.QUERIES }, dependsOnMethods = "prepareDataForSearchByPath", dataProviderClass = XMLTestDataProvider.class, dataProvider = "getQueriesData") - @XMLDataConfig(file = "src/main/resources/testdata/search-by-path.xml") + @XMLDataConfig(file = "src/test/resources/testdata/search-by-path.xml") public void executeSearchByPathQueries(QueryModel query) throws Exception { cmisApi.withQuery(query.getValue()).assertResultsCount().equals(query.getResults()); diff --git a/e2e-test/src/test/java/org/alfresco/service/search/cmis/SolrSearchByPropertyTests.java b/e2e-test/src/test/java/org/alfresco/service/search/cmis/SolrSearchByPropertyTests.java index 54715531f..e43e900a5 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/cmis/SolrSearchByPropertyTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/cmis/SolrSearchByPropertyTests.java @@ -40,7 +40,7 @@ public class SolrSearchByPropertyTests extends CmisTest } @Test(dataProviderClass = XMLTestDataProvider.class, dataProvider = "getAllData") - @XMLDataConfig(file = "src/main/resources/testdata/search-by-property.xml") + @XMLDataConfig(file = "src/test/resources/testdata/search-by-property.xml") public void prepareDataForSearchWithProperty(XMLTestData testData) throws Exception { this.testData = testData; @@ -52,7 +52,7 @@ public class SolrSearchByPropertyTests extends CmisTest @Test(groups = { TestGroup.CMIS, TestGroup.QUERIES }, dataProviderClass = XMLTestDataProvider.class, dataProvider = "getQueriesData", dependsOnMethods = "prepareDataForSearchWithProperty") - @XMLDataConfig(file = "src/main/resources/testdata/search-by-property.xml") + @XMLDataConfig(file = "src/test/resources/testdata/search-by-property.xml") public void executeSortedSearchByID(QueryModel query) throws Exception { cmisApi.withQuery(query.getValue()) diff --git a/e2e-test/src/test/java/org/alfresco/service/search/cmis/SolrSearchInFolderTests.java b/e2e-test/src/test/java/org/alfresco/service/search/cmis/SolrSearchInFolderTests.java index f2d58b959..595be9f11 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/cmis/SolrSearchInFolderTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/cmis/SolrSearchInFolderTests.java @@ -60,7 +60,7 @@ public class SolrSearchInFolderTests extends CmisTest @Test(groups = { TestGroup.CMIS, TestGroup.QUERIES }, dataProviderClass = XMLTestDataProvider.class, dataProvider = "getQueriesData") - @XMLDataConfig(file = "src/main/resources/testdata/search-in-folder.xml") + @XMLDataConfig(file = "src/test/resources/testdata/search-in-folder.xml") public void executeCMISQuery(QueryModel query) throws Exception { String currentQuery = String.format(query.getValue(), parentFolder.getNodeRef()); diff --git a/e2e-test/src/test/java/org/alfresco/service/search/cmis/SolrSearchInTreeTests.java b/e2e-test/src/test/java/org/alfresco/service/search/cmis/SolrSearchInTreeTests.java index b21fc8b02..4cbb4914e 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/cmis/SolrSearchInTreeTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/cmis/SolrSearchInTreeTests.java @@ -64,7 +64,7 @@ public class SolrSearchInTreeTests extends CmisTest @Test(groups = { TestGroup.CMIS, TestGroup.QUERIES }, dataProviderClass = XMLTestDataProvider.class, dataProvider = "getQueriesData") - @XMLDataConfig(file = "src/main/resources/testdata/search-in-tree.xml") + @XMLDataConfig(file = "src/test/resources/testdata/search-in-tree.xml") public void executeCMISQuery(QueryModel query) throws Exception { String currentQuery = String.format(query.getValue(), parentFolder.getNodeRef()); From 8e9db6b95f79ad105976b136df85cc664faa5e55 Mon Sep 17 00:00:00 2001 From: Keerat Date: Fri, 22 Mar 2019 15:34:47 +0000 Subject: [PATCH 1474/1491] Search-1485 --- .../java/org/alfresco/rest/search/FacetedSearchTest.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java b/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java index 7d991e477..4c1d54339 100644 --- a/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java +++ b/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java @@ -231,7 +231,9 @@ public class FacetedSearchTest extends AbstractSearchTest } - @Test + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH , TestGroup.ASS_1}) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH ,TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, + description = "Checks facet queries for the Search api") /** * { * "query": { @@ -273,7 +275,9 @@ public class FacetedSearchTest extends AbstractSearchTest bucket1.assertThat().field("count").is(1); } - @Test + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH , TestGroup.ASS_1}) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH ,TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, + description = "Checks facet queries for the Search api") /** * Test that items returned are in the format of generic facets. * { From 4ccf6c1dbed6a4bd9a00003b31911defc259345c Mon Sep 17 00:00:00 2001 From: agazzarini Date: Thu, 28 Mar 2019 14:39:46 +0100 Subject: [PATCH 1475/1491] Retain only test resources --- .../alfresco/rest/FunctionalCasesTests.java | 701 +++++++ .../org/alfresco/rest/NetworkDataPrep.java | 45 + .../test/java/org/alfresco/rest/RestTest.java | 85 + .../alfresco/rest/actions/ActionsTests.java | 151 ++ .../org/alfresco/rest/aos/AosApiTest.java | 24 + .../org/alfresco/rest/audit/AuditTest.java | 112 ++ .../alfresco/rest/audit/DeleteAuditTests.java | 66 + .../alfresco/rest/audit/GetAuditTests.java | 357 ++++ .../alfresco/rest/audit/PutAuditTests.java | 111 ++ .../org/alfresco/rest/auth/AuthTests.java | 87 + .../alfresco/rest/cmis/CmisBrowserTest.java | 25 + .../rest/comments/AddCommentTests.java | 260 +++ .../rest/comments/AddCommentsTests.java | 377 ++++ .../rest/comments/DeleteCommentTests.java | 295 +++ .../rest/comments/GetCommentsTests.java | 422 +++++ .../rest/comments/UpdateCommentTests.java | 461 +++++ .../org/alfresco/rest/demo/RestDemoTests.java | 104 ++ .../rest/demo/SampleCommentsTests.java | 56 + .../alfresco/rest/demo/SamplePeopleTests.java | 32 + .../alfresco/rest/demo/SampleSitesTests.java | 79 + .../rest/demo/workshop/RestApiDemoTests.java | 52 + .../demo/workshop/RestApiWorkshopTests.java | 38 + .../rest/discovery/DiscoveryTests.java | 108 ++ .../rest/downloads/DownloadsTests.java | 106 ++ .../rest/favorites/AddFavoriteSiteTests.java | 487 +++++ .../rest/favorites/AddFavoritesTests.java | 446 +++++ .../favorites/DeleteFavoriteSiteTests.java | 364 ++++ .../rest/favorites/DeleteFavoriteTests.java | 412 +++++ .../favorites/FavoritesIncludePathTests.java | 143 ++ .../rest/favorites/FavoritesNetworkTests.java | 292 +++ .../rest/favorites/GetFavoriteSiteTests.java | 292 +++ .../rest/favorites/GetFavoriteSitesTests.java | 325 ++++ .../rest/favorites/GetFavoriteTests.java | 480 +++++ .../rest/favorites/GetFavoritesTests.java | 555 ++++++ .../org/alfresco/rest/groups/GroupsTests.java | 158 ++ .../RestGetNetworkForPersonTests.java | 151 ++ .../rest/networks/RestGetNetworkTests.java | 145 ++ .../RestGetNetworksForPersonTests.java | 166 ++ .../nodes/NodesActionDefinitionTests.java | 87 + .../nodes/NodesContentAndVersioningTests.java | 308 ++++ .../alfresco/rest/nodes/NodesLockTests.java | 761 ++++++++ .../rest/nodes/NodesParentChildrenTests.java | 205 +++ .../rest/nodes/NodesTargetSourcesTests.java | 120 ++ .../org/alfresco/rest/nodes/NodesTests.java | 56 + .../alfresco/rest/nodes/NodesUnlockTests.java | 112 ++ .../rest/people/AvatarPeopleSanityTest.java | 66 + .../people/DeleteSiteMemberCoreTests.java | 229 +++ .../people/DeleteSiteMemberFullTests.java | 207 +++ .../people/DeleteSiteMemberSanityTests.java | 111 ++ .../rest/people/GetPeopleCoreTests.java | 57 + .../rest/people/GetPeopleFullTests.java | 88 + .../rest/people/GetPeopleSanityTests.java | 110 ++ .../people/GetSiteMembershipCoreTests.java | 114 ++ .../people/GetSiteMembershipFullTests.java | 138 ++ .../people/GetSiteMembershipSanityTests.java | 90 + ...etSitesMembershipInformationCoreTests.java | 136 ++ ...etSitesMembershipInformationFullTests.java | 205 +++ ...SitesMembershipInformationSanityTests.java | 89 + .../GetPeopleActivitiesCoreTests.java | 126 ++ .../GetPeopleActivitiesFullTests.java | 184 ++ .../GetPeopleActivitiesSanityTests.java | 111 ++ .../GetPeoplePreferenceCoreTests.java | 78 + .../GetPeoplePreferenceFullTests.java | 194 ++ .../GetPeoplePreferenceSanityTests.java | 120 ++ .../GetPeoplePreferencesCoreTests.java | 123 ++ .../GetPeoplePreferencesFullTests.java | 114 ++ .../GetPeoplePreferencesSanityTests.java | 121 ++ .../alfresco/rest/queries/QueriesTest.java | 178 ++ .../alfresco/rest/ratings/AddRatingTests.java | 818 ++++++++ .../rest/ratings/DeleteRatingTests.java | 525 ++++++ .../alfresco/rest/ratings/GetRatingTests.java | 438 +++++ .../rest/ratings/GetRatingsTests.java | 313 ++++ .../renditions/AvailableRenditionTests.java | 134 ++ .../rest/renditions/CreateRenditionTests.java | 101 + .../rest/renditions/GetRenditionTests.java | 157 ++ .../renditions/RenditionIntegrationTests.java | 81 + .../rest/search/AbstractSearchTest.java | 267 +++ .../rest/search/FacetFieldsSearchTest.java | 250 +++ .../rest/search/FacetIntervalSearchTest.java | 189 ++ .../rest/search/FacetRangeSearchTest.java | 342 ++++ .../rest/search/FacetedSearchTest.java | 322 ++++ .../alfresco/rest/search/FingerPrintTest.java | 166 ++ .../rest/search/PivotFacetedSearchTest.java | 273 +++ .../alfresco/rest/search/SearchAPATHTest.java | 185 ++ .../rest/search/SearchHighLightTest.java | 76 + .../rest/search/SearchSpellCheckTest.java | 174 ++ .../org/alfresco/rest/search/SearchTest.java | 309 ++++ .../alfresco/rest/search/ShardInfoTest.java | 85 + .../alfresco/rest/search/StatsSearchTest.java | 320 ++++ .../rest/search/solr/SearchSolrAPITest.java | 120 ++ .../rest/search/sql/SearchSQLAPITest.java | 781 ++++++++ .../rest/search/sql/SearchSQLPhraseTest.java | 256 +++ .../rest/search/sql/SearchSQLViaJDBCTest.java | 213 +++ .../sql/SearchSQLWithQuotedIdentifiers.java | 218 +++ .../sharedLinks/GetSharedLinksFullTests.java | 75 + .../sharedLinks/SharedLinksSanityTests.java | 276 +++ .../org/alfresco/rest/sites/GetSiteTests.java | 362 ++++ .../alfresco/rest/sites/GetSitesTests.java | 484 +++++ .../rest/sites/SitesNetworkTests.java | 85 + .../org/alfresco/rest/sites/SitesTests.java | 36 + .../containers/GetSiteContainerTests.java | 304 +++ .../containers/GetSiteContainersTests.java | 381 ++++ .../sites/members/AddSiteMemberTests.java | 589 ++++++ .../sites/members/GetSiteMemberTests.java | 396 ++++ .../sites/members/GetSiteMembersTests.java | 355 ++++ .../sites/members/RemoveSiteMemberTests.java | 467 +++++ .../sites/members/UpdateSiteMemberTests.java | 546 ++++++ .../AddSiteMembershipRequestTests.java | 409 ++++ .../DeleteSiteMembershipRequestTests.java | 317 ++++ .../GetSiteMembershipRequestTests.java | 332 ++++ .../GetSiteMembershipRequestsTests.java | 421 +++++ .../UpdateSiteMembershipRequestTests.java | 610 ++++++ .../rest/syncService/SyncServiceAPITests.java | 204 ++ .../org/alfresco/rest/tags/GetTagTests.java | 139 ++ .../org/alfresco/rest/tags/GetTagsTests.java | 230 +++ .../org/alfresco/rest/tags/TagsDataPrep.java | 70 + .../alfresco/rest/tags/UpdateTagTests.java | 269 +++ .../alfresco/rest/tags/nodes/AddTagTests.java | 337 ++++ .../rest/tags/nodes/AddTagsTests.java | 150 ++ .../rest/tags/nodes/DeleteTagTests.java | 287 +++ .../rest/tags/nodes/GetNodeTagsTests.java | 319 ++++ .../rest/trashcan/GetDeletedNodesTests.java | 245 +++ .../WorkflowNetworkDeploymentsTests.java | 124 ++ ...orkflowNetworkProcessDefinitionsTests.java | 221 +++ .../WorkflowNetworkProcessesTests.java | 540 ++++++ .../workflow/WorkflowNetworkTasksTests.java | 578 ++++++ .../deployments/DeleteDeploymentTests.java | 144 ++ .../deployments/GetDeploymentCoreTests.java | 42 + .../deployments/GetDeploymentFullTests.java | 57 + .../deployments/GetDeploymentSanityTests.java | 57 + .../deployments/GetDeploymentsCoreTests.java | 30 + .../deployments/GetDeploymentsFullTests.java | 146 ++ .../GetDeploymentsSanityTests.java | 44 + .../GetProcessDefinitionCoreTests.java | 45 + .../GetProcessDefinitionFullTests.java | 67 + .../GetProcessDefinitionImageCoreTests.java | 46 + .../GetProcessDefinitionImageFullTests.java | 42 + .../GetProcessDefinitionImageSanityTests.java | 49 + .../GetProcessDefinitionSanityTests.java | 62 + ...cessDefinitionStartFormModelCoreTests.java | 80 + ...cessDefinitionStartFormModelFullTests.java | 71 + ...ssDefinitionStartFormModelSanityTests.java | 38 + .../GetProcessDefinitionsCoreTests.java | 53 + .../GetProcessDefinitionsFullTests.java | 174 ++ .../GetProcessDefinitionsSanityTests.java | 48 + .../processes/AddProcessCoreTests.java | 130 ++ .../processes/AddProcessFullTests.java | 150 ++ .../processes/AddProcessSanityTests.java | 44 + .../processes/DeleteProcessCoreTests.java | 69 + .../processes/DeleteProcessFullTests.java | 52 + .../processes/DeleteProcessSanityTests.java | 69 + .../processes/GetProcessCoreTests.java | 44 + .../processes/GetProcessFullTests.java | 85 + .../processes/GetProcessSanityTests.java | 62 + .../processes/GetProcessesCoreTests.java | 80 + .../processes/GetProcessesFullTests.java | 160 ++ .../processes/GetProcessesSanityTests.java | 78 + .../items/AddProcessItemCoreTests.java | 181 ++ .../items/AddProcessItemFullTests.java | 131 ++ .../items/AddProcessItemSanityTests.java | 175 ++ .../items/DeleteProcessItemCoreTests.java | 85 + .../items/DeleteProcessItemFullTests.java | 215 +++ .../items/DeleteProcessItemSanityTests.java | 67 + .../items/GetProcessItemsCoreTests.java | 70 + .../items/GetProcessItemsFullTests.java | 198 ++ .../items/GetProcessItemsSanityTests.java | 59 + .../tasks/GetProcessTasksCoreTests.java | 98 + .../tasks/GetProcessTasksFullTests.java | 207 +++ .../tasks/GetProcessTasksSanityTests.java | 86 + .../AddProcessVariableCoreTests.java | 188 ++ .../AddProcessVariableFullTests.java | 182 ++ .../AddProcessVariableSanityTests.java | 95 + .../AddProcessVariablesCoreTests.java | 101 + .../AddProcessVariablesFullTests.java | 395 ++++ .../AddProcessVariablesSanityTests.java | 158 ++ .../DeleteProcessVariableCoreTests.java | 118 ++ .../DeleteProcessVariableFullTests.java | 196 ++ .../DeleteProcessVariableSanityTests.java | 69 + .../GetProcessVariablesCoreTests.java | 88 + .../GetProcessVariablesFullTests.java | 161 ++ .../GetProcessVariablesSanityTests.java | 60 + .../variables/UpdateProcessVariableTests.java | 139 ++ .../workflow/tasks/GetTaskFormModelTests.java | 256 +++ .../rest/workflow/tasks/GetTaskTests.java | 212 +++ .../rest/workflow/tasks/GetTasksTests.java | 234 +++ .../rest/workflow/tasks/UpdateTaskTests.java | 1639 +++++++++++++++++ .../GetTaskCandidatesRegressionTests.java | 268 +++ .../GetTaskCandidatesSanityTests.java | 79 + .../tasks/items/AddTaskItemTestsBulk1.java | 158 ++ .../tasks/items/AddTaskItemTestsBulk2.java | 175 ++ .../tasks/items/AddTaskItemTestsBulk3.java | 128 ++ .../items/GetTaskItemsRegressionTests.java | 260 +++ .../tasks/items/GetTaskItemsSanityTests.java | 75 + .../tasks/items/RemoveTaskItemTests.java | 256 +++ .../variables/AddTaskVariablesTestsBulk1.java | 198 ++ .../variables/AddTaskVariablesTestsBulk2.java | 241 +++ .../variables/AddTaskVariablesTestsBulk3.java | 155 ++ .../variables/DeleteTaskVariableTests.java | 231 +++ .../variables/GetTaskVariablesTests.java | 252 +++ .../UpdateTaskVariableTestsBulk1.java | 79 + .../UpdateTaskVariableTestsBulk2.java | 173 ++ .../UpdateTaskVariableTestsBulk3.java | 247 +++ e2e-test/src/test/resources/SearchSuite.xml | 50 + .../resources/alfresco-restapi-context.xml | 17 + .../src/test/resources/default.properties | 84 + e2e-test/src/test/resources/log4j.properties | 26 + .../src/test/resources/models/SEARCH-1063.xml | 159 ++ 207 files changed, 41971 insertions(+) create mode 100644 e2e-test/src/test/java/org/alfresco/rest/FunctionalCasesTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/NetworkDataPrep.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/RestTest.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/actions/ActionsTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/aos/AosApiTest.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/audit/AuditTest.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/audit/DeleteAuditTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/audit/GetAuditTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/audit/PutAuditTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/auth/AuthTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/cmis/CmisBrowserTest.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/comments/AddCommentTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/comments/AddCommentsTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/comments/DeleteCommentTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/comments/GetCommentsTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/comments/UpdateCommentTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/demo/RestDemoTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/demo/SampleCommentsTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/demo/SamplePeopleTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/demo/SampleSitesTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/demo/workshop/RestApiDemoTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/demo/workshop/RestApiWorkshopTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/discovery/DiscoveryTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/downloads/DownloadsTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/favorites/AddFavoriteSiteTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/favorites/AddFavoritesTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/favorites/DeleteFavoriteSiteTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/favorites/DeleteFavoriteTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/favorites/FavoritesIncludePathTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/favorites/FavoritesNetworkTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/favorites/GetFavoriteSiteTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/favorites/GetFavoriteSitesTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/favorites/GetFavoriteTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/favorites/GetFavoritesTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/groups/GroupsTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/networks/RestGetNetworkForPersonTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/networks/RestGetNetworkTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/networks/RestGetNetworksForPersonTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/nodes/NodesActionDefinitionTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/nodes/NodesContentAndVersioningTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/nodes/NodesLockTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/nodes/NodesParentChildrenTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/nodes/NodesTargetSourcesTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/nodes/NodesTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/nodes/NodesUnlockTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/people/AvatarPeopleSanityTest.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/people/DeleteSiteMemberCoreTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/people/DeleteSiteMemberFullTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/people/GetPeopleCoreTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/people/GetPeopleFullTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/people/GetPeopleSanityTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/people/GetSiteMembershipCoreTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/people/GetSiteMembershipFullTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/people/GetSitesMembershipInformationCoreTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/people/GetSitesMembershipInformationFullTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/people/activities/GetPeopleActivitiesCoreTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/people/activities/GetPeopleActivitiesFullTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/people/activities/GetPeopleActivitiesSanityTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/people/preferences/GetPeoplePreferenceCoreTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/people/preferences/GetPeoplePreferenceFullTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/people/preferences/GetPeoplePreferenceSanityTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/people/preferences/GetPeoplePreferencesCoreTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/people/preferences/GetPeoplePreferencesFullTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/people/preferences/GetPeoplePreferencesSanityTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/queries/QueriesTest.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/ratings/AddRatingTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/ratings/DeleteRatingTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/ratings/GetRatingTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/ratings/GetRatingsTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/renditions/AvailableRenditionTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/renditions/CreateRenditionTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/renditions/GetRenditionTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/renditions/RenditionIntegrationTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/search/AbstractSearchTest.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/search/FacetFieldsSearchTest.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/search/FacetIntervalSearchTest.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/search/FacetRangeSearchTest.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/search/FacetedSearchTest.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/search/FingerPrintTest.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/search/PivotFacetedSearchTest.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/search/SearchAPATHTest.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/search/SearchHighLightTest.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/search/SearchSpellCheckTest.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/search/SearchTest.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/search/ShardInfoTest.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/search/StatsSearchTest.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/search/solr/SearchSolrAPITest.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/search/sql/SearchSQLAPITest.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/search/sql/SearchSQLPhraseTest.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/search/sql/SearchSQLViaJDBCTest.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/search/sql/SearchSQLWithQuotedIdentifiers.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/sharedLinks/GetSharedLinksFullTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/sharedLinks/SharedLinksSanityTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/sites/GetSiteTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/sites/GetSitesTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/sites/SitesNetworkTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/sites/SitesTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/sites/containers/GetSiteContainerTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/sites/containers/GetSiteContainersTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/sites/members/AddSiteMemberTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/sites/members/GetSiteMemberTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/sites/members/GetSiteMembersTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/sites/members/RemoveSiteMemberTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/sites/members/UpdateSiteMemberTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/sites/membershipRequests/AddSiteMembershipRequestTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/sites/membershipRequests/DeleteSiteMembershipRequestTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestsTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/sites/membershipRequests/UpdateSiteMembershipRequestTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/syncService/SyncServiceAPITests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/tags/GetTagTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/tags/GetTagsTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/tags/TagsDataPrep.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/tags/UpdateTagTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/tags/nodes/AddTagTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/tags/nodes/AddTagsTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/tags/nodes/DeleteTagTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/tags/nodes/GetNodeTagsTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/trashcan/GetDeletedNodesTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/WorkflowNetworkDeploymentsTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/WorkflowNetworkProcessDefinitionsTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/WorkflowNetworkProcessesTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/WorkflowNetworkTasksTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/deployments/GetDeploymentCoreTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/deployments/GetDeploymentFullTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/deployments/GetDeploymentSanityTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsCoreTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsFullTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsSanityTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionCoreTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionFullTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageCoreTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageFullTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelFullTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsCoreTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsFullTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/processes/AddProcessCoreTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/processes/AddProcessFullTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/processes/AddProcessSanityTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/processes/DeleteProcessCoreTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/processes/DeleteProcessFullTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/processes/GetProcessCoreTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/processes/GetProcessFullTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/processes/GetProcessSanityTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/processes/GetProcessesCoreTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/processes/GetProcessesFullTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemCoreTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemFullTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemSanityTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/processes/items/DeleteProcessItemCoreTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/processes/items/DeleteProcessItemFullTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/processes/items/DeleteProcessItemSanityTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/processes/items/GetProcessItemsCoreTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/processes/items/GetProcessItemsFullTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/processes/items/GetProcessItemsSanityTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/processes/tasks/GetProcessTasksCoreTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/processes/tasks/GetProcessTasksFullTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/processes/tasks/GetProcessTasksSanityTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariableCoreTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariableFullTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariableSanityTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesCoreTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesFullTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesSanityTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/DeleteProcessVariableCoreTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/DeleteProcessVariableFullTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/DeleteProcessVariableSanityTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/GetProcessVariablesCoreTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/GetProcessVariablesFullTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/GetProcessVariablesSanityTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/UpdateProcessVariableTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/GetTaskTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/GetTasksTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/UpdateTaskTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/candidates/GetTaskCandidatesRegressionTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/candidates/GetTaskCandidatesSanityTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemTestsBulk1.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemTestsBulk2.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemTestsBulk3.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/items/GetTaskItemsRegressionTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/items/GetTaskItemsSanityTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/items/RemoveTaskItemTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk1.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk2.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk3.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/variables/DeleteTaskVariableTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/variables/GetTaskVariablesTests.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk1.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk2.java create mode 100644 e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk3.java create mode 100644 e2e-test/src/test/resources/SearchSuite.xml create mode 100644 e2e-test/src/test/resources/alfresco-restapi-context.xml create mode 100644 e2e-test/src/test/resources/default.properties create mode 100644 e2e-test/src/test/resources/log4j.properties create mode 100755 e2e-test/src/test/resources/models/SEARCH-1063.xml diff --git a/e2e-test/src/test/java/org/alfresco/rest/FunctionalCasesTests.java b/e2e-test/src/test/java/org/alfresco/rest/FunctionalCasesTests.java new file mode 100644 index 000000000..ae2d5425b --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/FunctionalCasesTests.java @@ -0,0 +1,701 @@ +package org.alfresco.rest; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.dataprep.SiteService.Visibility; +import org.alfresco.rest.model.RestActivityModelsCollection; +import org.alfresco.rest.model.RestCommentModel; +import org.alfresco.rest.model.RestCommentModelsCollection; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestFavoriteSiteModel; +import org.alfresco.rest.model.RestPersonFavoritesModelsCollection; +import org.alfresco.rest.model.RestRatingModel; +import org.alfresco.rest.model.RestSiteMemberModel; +import org.alfresco.rest.model.RestSiteMembershipRequestModelsCollection; +import org.alfresco.rest.model.RestTagModel; +import org.alfresco.rest.model.RestTaskModel; +import org.alfresco.utility.constants.ActivityType; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class FunctionalCasesTests extends RestTest +{ + private UserModel adminUser, manager; + private SiteModel publicSite, moderatedSite, privateSite; + private RestSiteMemberModel updatedMember; + private RestSiteMembershipRequestModelsCollection returnedCollection; + private RestFavoriteSiteModel restFavoriteSiteModel; + private RestActivityModelsCollection activities; + private FileModel file; + private RestActivityModelsCollection restActivityModelsCollection; + + private FileModel fileInSite; + private RestCommentModel commentModel; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + manager = dataUser.createRandomTestUser(); + publicSite = dataSite.usingUser(adminUser).createPublicRandomSite(); + dataUser.addUserToSite(manager, publicSite, UserRole.SiteManager); + moderatedSite = dataSite.usingUser(adminUser).createModeratedRandomSite(); + privateSite = dataSite.usingUser(adminUser).createPrivateRandomSite(); + } + + /** + * Scenario: + * 1. Add a site member as Manager + * 2. Update it's role to Collaborator + * 3. Update it's role to Contributor + * 4. Update it's role to Consumer + */ + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that manager is able to update manager with different roles and gets status code CREATED (201)") + public void managerIsAbleToUpdateManagerWithDifferentRoles() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteManager); + restClient.authenticateUser(adminUser).withCoreAPI().usingSite(publicSite).addPerson(testUser) + .assertThat().field("id").is(testUser.getUsername()) + .and().field("role").is(testUser.getUserRole()); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + testUser.setUserRole(UserRole.SiteCollaborator); + updatedMember = restClient.withCoreAPI() + .usingSite(publicSite).updateSiteMember(testUser); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedMember.assertThat().field("id").is(testUser.getUsername()).and().field("role").is(testUser.getUserRole()); + + testUser.setUserRole(UserRole.SiteContributor); + updatedMember = restClient.withCoreAPI() + .usingSite(publicSite).updateSiteMember(testUser); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedMember.assertThat().field("id").is(testUser.getUsername()).and().field("role").is(testUser.getUserRole()); + + testUser.setUserRole(UserRole.SiteConsumer); + updatedMember = restClient.withCoreAPI() + .usingSite(publicSite).updateSiteMember(testUser); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedMember.assertThat().field("id").is(testUser.getUsername()).and().field("role").is(testUser.getUserRole()); + } + + /** + * Scenario: + * 1. Add a site member as Consumer + * 2. Update it's role to Contributor + * 3. Update it's role to Collaborator + * 4. Update it's role to Manager + */ + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that manager is able to update consumer with different roles and gets status code CREATED (201)") + public void managerIsAbleToUpdateConsumerWithDifferentRoles() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteConsumer); + restClient.authenticateUser(adminUser).withCoreAPI().usingSite(publicSite).addPerson(testUser) + .assertThat().field("id").is(testUser.getUsername()) + .and().field("role").is(testUser.getUserRole()); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + testUser.setUserRole(UserRole.SiteContributor); + updatedMember = restClient.withCoreAPI() + .usingSite(publicSite).updateSiteMember(testUser); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedMember.assertThat().field("id").is(testUser.getUsername()).and().field("role").is(testUser.getUserRole()); + + testUser.setUserRole(UserRole.SiteCollaborator); + updatedMember = restClient.withCoreAPI() + .usingSite(publicSite).updateSiteMember(testUser); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedMember.assertThat().field("id").is(testUser.getUsername()).and().field("role").is(testUser.getUserRole()); + + testUser.setUserRole(UserRole.SiteManager); + updatedMember = restClient.withCoreAPI() + .usingSite(publicSite).updateSiteMember(testUser); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedMember.assertThat().field("id").is(testUser.getUsername()).and().field("role").is(testUser.getUserRole()); + } + + /** + * Scenario: + * 1. Create site membership request + * 2. Approve site membership request + * 3. Add site to Favorites + * 4. Delete site from Favorites + */ + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, description = "Approve request, add site to favorites, then delete it from favorites") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void approveRequestAddAndDeleteSiteFromFavorites() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + + restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestTaskModel taskModel = restClient.authenticateUser(newMember).withWorkflowAPI().getTasks().getTaskModelByDescription(moderatedSite); + workflow.approveSiteMembershipRequest(adminUser.getUsername(), adminUser.getPassword(), taskModel.getId(), true, "Approve"); + returnedCollection = restClient.authenticateUser(newMember).withCoreAPI().usingMe().getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat().entriesListDoesNotContain("id", moderatedSite.getId()); + + restFavoriteSiteModel = restClient.authenticateUser(newMember).withCoreAPI().usingUser(newMember).addFavoriteSite(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restFavoriteSiteModel.assertThat().field("id").is(moderatedSite.getId()); + + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().removeFavoriteSite(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + /** + * Scenario: + * 1. Create site membership request + * 2. Reject site membership request + * 3. Add moderated site to Favorites + * 4. Create site membership request again + * 5. Approve site membership request + * 6. Delete member from site + */ + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, description = "Reject request, add moderated site to favorites, create request again and approve it") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void rejectRequestAddModeratedSiteToFavorites() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + + restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestTaskModel taskModel = restClient.authenticateUser(newMember).withWorkflowAPI().getTasks().getTaskModelByDescription(moderatedSite); + workflow.approveSiteMembershipRequest(adminUser.getUsername(), adminUser.getPassword(), taskModel.getId(), false, "Rejected"); + returnedCollection = restClient.authenticateUser(newMember).withCoreAPI().usingMe().getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat().entriesListDoesNotContain("id", moderatedSite.getId()); + + restFavoriteSiteModel = restClient.authenticateUser(newMember).withCoreAPI().usingUser(newMember).addFavoriteSite(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restFavoriteSiteModel.assertThat().field("id").is(moderatedSite.getId()); + + restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + taskModel = restClient.authenticateUser(newMember).withWorkflowAPI().getTasks().getTaskModelByDescription(moderatedSite); + workflow.approveSiteMembershipRequest(adminUser.getUsername(), adminUser.getPassword(), taskModel.getId(), true, "Accept"); + + restClient.authenticateUser(adminUser).withCoreAPI().usingUser(newMember).deleteSiteMember(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingSite(moderatedSite).getSiteMembers().assertThat().entriesListDoesNotContain("id", newMember.getUsername()); + } + + /** + * Scenario: + * 1. Add file + * 2. Check file is included in person activities list + */ + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Add a file and check that activity is included in person activities") + public void addFileThenGetPersonActivities() throws Exception + { + file = dataContent.usingUser(manager).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); + activities = restClient.authenticateUser(manager).withCoreAPI().usingAuthUser().getPersonActivitiesUntilEntriesCountIs(2); + activities.assertThat().entriesListIsNotEmpty() + .and().entriesListContains("siteId", publicSite.getId()) + .and().entriesListContains("activityType", "org.alfresco.documentlibrary.file-added") + .and().entriesListContains("activitySummary.objectId", file.getNodeRefWithoutVersion()); + } + + /** + * Scenario: + * 1. Add a comment to a file + * 2. Check that comment is included in person activities list + */ + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Add a comment to a file and check that activity is included in person activities") + public void addCommentThenGetPersonActivities() throws Exception + { + file = dataContent.usingUser(manager).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(manager).withCoreAPI().usingResource(file).addComment("new comment"); + activities = restClient.authenticateUser(manager).withCoreAPI().usingAuthUser().getPersonActivitiesUntilEntriesCountIs(3); + activities.assertThat().entriesListIsNotEmpty() + .and().entriesListContains("siteId", publicSite.getId()) + .and().entriesListContains("activityType", "org.alfresco.comments.comment-created") + .and().entriesListContains("activitySummary.objectId", file.getNodeRefWithoutVersion()); + } + + /** + * Scenario: + * 1. Add file then delete it + * 2. Check action is included in person activities list + */ + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Add a file, delete it and check that activity is included in person activities") + public void addFileDeleteItThenGetPersonActivities() throws Exception + { + file = dataContent.usingUser(manager).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); + dataContent.usingUser(manager).usingResource(file).deleteContent(); + activities = restClient.authenticateUser(manager).withCoreAPI().usingAuthUser().getPersonActivitiesUntilEntriesCountIs(2); + activities.assertThat().entriesListIsNotEmpty() + .and().entriesListContains("siteId", publicSite.getId()) + .and().entriesListContains("activityType", "org.alfresco.documentlibrary.file-deleted") + .and().entriesListContains("activitySummary.objectId", file.getNodeRefWithoutVersion()); + } + + /** + * 1. Post one comment + * 2. Get comment details + * 3. Update comment + * 4. Get again comment details + * 5. Delete comment + */ + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, + executionType = ExecutionType.REGRESSION, + description = "Add comment to a file, then get comment details. Update it and check that get comment returns updated details. Delete comment then check that file has no comments.") + public void addUpdateDeleteCommentThenGetCommentDetails() throws Exception + { + file = dataContent.usingUser(manager).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); + RestCommentModel newComment = restClient.authenticateUser(manager).withCoreAPI().usingResource(file).addComment("new comment"); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestCommentModelsCollection fileComments = restClient.withCoreAPI().usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + fileComments.assertThat().entriesListContains("content", newComment.getContent()); + + RestCommentModel updatedComment = restClient.withCoreAPI().usingResource(file).updateComment(newComment, "updated comment"); + restClient.assertStatusCodeIs(HttpStatus.OK); + + fileComments = restClient.withCoreAPI().usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + fileComments.assertThat().entriesListContains("content", updatedComment.getContent()).assertThat().entriesListDoesNotContain("content", newComment.getContent()); + + restClient.withCoreAPI().usingResource(file).deleteComment(updatedComment); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + fileComments = restClient.withCoreAPI().usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + fileComments.assertThat().entriesListIsEmpty(); + } + + /** + * 1. Post one comment + * 2. Delete comment + * 3. Post the same comment again + */ + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, + executionType = ExecutionType.REGRESSION, + description = "Add a comment to a file, delete it, then added the same comment again.") + public void checkThatADeletedCommentCanBePostedAgain() throws Exception + { + file = dataContent.usingUser(manager).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); + RestCommentModel newComment = restClient.authenticateUser(manager).withCoreAPI().usingResource(file).addComment("new comment"); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestCommentModelsCollection fileComments = restClient.withCoreAPI().usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + fileComments.assertThat().entriesListContains("content", newComment.getContent()); + + restClient.withCoreAPI().usingResource(file).deleteComment(newComment); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + fileComments = restClient.withCoreAPI().usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + fileComments.assertThat().entriesListIsEmpty(); + + restClient.authenticateUser(manager).withCoreAPI().usingResource(file).addComment("new comment"); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + fileComments = restClient.withCoreAPI().usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + fileComments.assertThat().entriesListContains("content", newComment.getContent()); + } + + /** + * Scenario: + * 1. join an user to a site + * 2. Check action is included in person activities list + * + * @throws Exception + */ + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Create an user, join the user to a site and check that activity is included in person activities") + public void joinUserToSiteThenGetPersonActivities() throws Exception + { + UserModel userJoinSite = dataUser.createRandomTestUser(); + + restClient.authenticateUser(userJoinSite).withCoreAPI().usingMe().addSiteMembershipRequest(publicSite); + activities = restClient.withCoreAPI().usingAuthUser().getPersonActivitiesUntilEntriesCountIs(2); + activities.assertThat().entriesListIsNotEmpty().and() + .entriesListContains("siteId", publicSite.getId()).and() + .entriesListContains("activityType", "org.alfresco.site.user-joined").and() + .entriesListContains("activitySummary.memberPersonId", userJoinSite.getUsername()); + } + + /** + * Scenario: + * 1. Add user to private site + * 2. Remove user from private site + * 3. User creates membership request to the same private site + */ + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, description = "Verify membership request by user after it was removed from site gets status code 404") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void userCanNotCreateMembershipRequestIfItWasRemovedFromPrivateSite() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + newMember.setUserRole(UserRole.SiteCollaborator); + + restClient.authenticateUser(adminUser).withCoreAPI().usingSite(privateSite).addPerson(newMember) + .assertThat().field("id").is(newMember.getUsername()); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(adminUser).withCoreAPI().usingUser(newMember).deleteSiteMember(privateSite); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest(privateSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, newMember.getUsername(), privateSite.getTitle())); + } + + /** + * Scenario: + * 1. User creates membership request to moderated site + * 2. Accept membership request + * 3. Remove user from moderated site + * 4. Add user on moderated site + */ + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, description = "Verify user can be added back after if was removed from site") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void userCanBeAddedAfterItWasRemovedFromSite() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + newMember.setUserRole(UserRole.SiteCollaborator); + + restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestTaskModel taskModel = restClient.authenticateUser(newMember).withWorkflowAPI().getTasks().getTaskModelByDescription(moderatedSite); + workflow.approveSiteMembershipRequest(adminUser.getUsername(), adminUser.getPassword(), taskModel.getId(), true, "Accept"); + + restClient.authenticateUser(adminUser).withCoreAPI().usingUser(newMember).deleteSiteMember(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withCoreAPI().usingSite(moderatedSite).getSiteMembers().assertThat().entriesListDoesNotContain("id", newMember.getUsername()); + + restClient.authenticateUser(adminUser).withCoreAPI().usingSite(moderatedSite).addPerson(newMember) + .assertThat().field("id").is(newMember.getUsername()); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.withCoreAPI().usingSite(moderatedSite).getSiteMembers().assertThat().entriesListContains("id", newMember.getUsername()); + } + + /** + * Scenario: + * 1. Create document in site + * 2. Add comment + * 3. Delete document + * 4. Get comments and check if the above comment was deleted + */ + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, + executionType = ExecutionType.REGRESSION, description = "Check that a comment of a document was also removed after deleting the document") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void checkTheCommentOfADocumentThatWasDeletedDoesNotExist() throws Exception + { + file = dataContent.usingSite(publicSite).usingUser(adminUser).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + String newContent = "This is a new comment added by " + adminUser.getUsername(); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(file).addComment(newContent) + .assertThat().field("content").isNotEmpty() + .and().field("content").is(newContent); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + dataContent.usingUser(adminUser).usingResource(file).deleteContent(); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary((String.format(RestErrorModel.ENTITY_WAS_NOT_FOUND, file.getNodeRefWithoutVersion()))); + } + + /** + * Scenario: + * 1. Add user to private site + * 2. Add comment to a document of private site + * 3. Remove user from site + * 4. Get comments and check if the above comment was deleted + */ + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, + executionType = ExecutionType.REGRESSION, description = "Check that a comment of a document from a private site is not deleted after user is removed") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void checkThatCommentIsNotDeletedWhenPrivateSiteMemberIsRemoved() throws Exception + { + UserModel newUser = dataUser.createRandomTestUser(); + newUser.setUserRole(UserRole.SiteManager); + restClient.authenticateUser(adminUser).withCoreAPI().usingSite(privateSite).addPerson(newUser); + + file = dataContent.usingSite(privateSite).usingUser(adminUser).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + String newContent = "This is a new comment added by " + newUser.getUsername(); + + restClient.authenticateUser(newUser).withCoreAPI().usingResource(file).addComment(newContent) + .assertThat().field("content").isNotEmpty() + .and().field("content").is(newContent); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(adminUser).withCoreAPI().usingSite(privateSite).deleteSiteMember(newUser); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withCoreAPI().usingSite(privateSite).getSiteMembers().assertThat().entriesListDoesNotContain("id", newUser.getUsername()); + + RestCommentModelsCollection comments = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", newContent) + .and().entriesListContains("createdBy.id", newUser.getUsername()); + } + + /** + * Scenario: + * 1. Add one file to favorites then add a comment to this file + */ + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, + executionType = ExecutionType.REGRESSION, + description = "Add one file to favorites then add a comment to this file") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void commentAFavoriteFile() throws Exception + { + file = dataContent.usingSite(publicSite).usingUser(adminUser).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + restClient.authenticateUser(manager).withCoreAPI().usingMe().addFileToFavorites(file); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.withCoreAPI().usingAuthUser().getFavorites() + .assertThat().entriesListContains("targetGuid", file.getNodeRefWithoutVersion()); + + RestCommentModel comment = restClient.withCoreAPI().usingResource(file).addComment("new comment"); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + comment.assertThat().field("content").is("new comment"); + } + + /** + * Scenario: + * 1. Remove one file from favorites then add a comment to this file + */ + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, + executionType = ExecutionType.REGRESSION, + description = "Remove one file from favorites then add a comment to this file") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void commentFileRemovedFromFavorites() throws Exception + { + file = dataContent.usingSite(publicSite).usingUser(adminUser).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + restClient.authenticateUser(manager).withCoreAPI().usingMe().addFileToFavorites(file); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.withCoreAPI().usingMe().deleteFileFromFavorites(file); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingAuthUser().getFavorites() + .assertThat().entriesListDoesNotContain("targetGuid", file.getNodeRefWithoutVersion()); + + RestCommentModel comment = restClient.withCoreAPI().usingResource(file).addComment("new comment"); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + comment.assertThat().field("content").is("new comment"); + } + + /** + * Scenario: + * 1. Add public site to favorites + * 2. Change site visibility to moderated + * 3. Check favorites + * 4. Change site visibility to private + * 5. Check favorites + */ + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, + executionType = ExecutionType.REGRESSION, + description = "Check favorite sites after a favorite site visibility is changed") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void changeFavoriteSiteVisibilityThenCheckFavorites() throws Exception + { + SiteModel favoriteSite = dataSite.usingUser(manager).createPublicRandomSite(); + UserModel regularUser = dataUser.createRandomTestUser(); + + restClient.authenticateUser(regularUser).withCoreAPI().usingAuthUser().addSiteToFavorites(favoriteSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestPersonFavoritesModelsCollection userFavoriteSites = restClient.withCoreAPI().usingAuthUser().where().targetSiteExist().getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + userFavoriteSites.assertThat().entriesListContains("targetGuid", favoriteSite.getGuid()) + .assertThat().entriesListContains("target.site.visibility", favoriteSite.getVisibility().name()) + .assertThat().entriesListContains("target.site.id", favoriteSite.getId()); + + dataSite.usingUser(manager).updateSiteVisibility(favoriteSite, Visibility.MODERATED); + + userFavoriteSites = restClient.authenticateUser(regularUser).withCoreAPI().usingAuthUser().where().targetSiteExist().getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + userFavoriteSites.assertThat().entriesListContains("targetGuid", favoriteSite.getGuid()) + .assertThat().entriesListContains("target.site.visibility", "MODERATED") + .assertThat().entriesListContains("target.site.id", favoriteSite.getId()); + + dataSite.usingUser(manager).updateSiteVisibility(favoriteSite, Visibility.PRIVATE); + + userFavoriteSites = restClient.authenticateUser(regularUser).withCoreAPI().usingAuthUser().where().targetSiteExist().getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + userFavoriteSites.assertThat().entriesListIsEmpty(); + + dataSite.usingUser(manager).updateSiteVisibility(favoriteSite, Visibility.PUBLIC); + + userFavoriteSites = restClient.authenticateUser(regularUser).withCoreAPI().usingAuthUser().where().targetSiteExist().getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + userFavoriteSites.assertThat().entriesListContains("targetGuid", favoriteSite.getGuid()) + .assertThat().entriesListContains("target.site.visibility", favoriteSite.getVisibility().name()) + .assertThat().entriesListContains("target.site.id", favoriteSite.getId()); + } + + /** + * Scenario: + * 1. Regular user adds moderated site membership request + * 2. Site manager approves the request + * 3. Site manager updates the new member role to Manager + * 4. New member adds comment to a file on site + * 5. New member likes and rate one file + * 6. New member adds tags to a file + * 7. New member adds site to favorite + * 8. New member adds, then deletes a site member + */ + @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, + executionType = ExecutionType.REGRESSION, + description = "Check that a user who joins a moderated site as manager is able to comment, rate, tag an existing file from the site, add site to favorites, add and remove site members.") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + public void checkNewManagerActions() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + file = dataContent.usingSite(moderatedSite).usingUser(adminUser).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestTaskModel taskModel = restClient.withWorkflowAPI().getTasks().getTaskModelByDescription(moderatedSite); + workflow.approveSiteMembershipRequest(adminUser.getUsername(), adminUser.getPassword(), taskModel.getId(), true, "Approve"); + returnedCollection = restClient.withCoreAPI().usingMe().getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat().entriesListDoesNotContain("id", moderatedSite.getId()); + + newMember.setUserRole(UserRole.SiteManager); + restClient.authenticateUser(adminUser).withCoreAPI().usingSite(moderatedSite).updateSiteMember(newMember) + .assertThat().field("id").is(newMember.getUsername()) + .and().field("role").is(newMember.getUserRole()); + restClient.assertStatusCodeIs(HttpStatus.OK); + + RestCommentModel comment = restClient.authenticateUser(newMember).withCoreAPI().usingResource(file).addComment("new comment"); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + comment.assertThat().field("content").is("new comment"); + + RestRatingModel returnedRatingModel = restClient.withCoreAPI().usingResource(file).likeDocument(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedRatingModel.assertThat().field("myRating").is("true") + .and().field("id").is("likes") + .and().field("aggregate").isNotEmpty(); + + returnedRatingModel = restClient.withCoreAPI().usingResource(file).rateStarsToDocument(5); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedRatingModel.assertThat().field("myRating").is("5") + .and().field("id").is("fiveStar") + .and().field("aggregate").isNotEmpty(); + + RestTagModel tag = restClient.withCoreAPI().usingResource(file).addTag("filetag"); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + tag.assertThat().field("tag").is("filetag") + .and().field("id").isNotEmpty(); + + restFavoriteSiteModel = restClient.withCoreAPI().usingAuthUser().addFavoriteSite(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restFavoriteSiteModel.assertThat().field("id").is(moderatedSite.getId()); + + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteManager); + restClient.withCoreAPI().usingSite(moderatedSite).addPerson(testUser) + .assertThat().field("id").is(testUser.getUsername()) + .and().field("role").is(testUser.getUserRole()); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.withCoreAPI().usingSite(moderatedSite).deleteSiteMember(testUser); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingSite(moderatedSite).getSiteMembers() + .assertThat().entriesListDoesNotContain("id", testUser.getUsername()); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + /** + * Scenario: + * 1. Add user to site + * 2. Create folder + * 3. Create document + * 4. Add comment to the document + * 5. Like document + * 6. Update Comment + * 7. Update user role + * 8. Delete like rating + * 9. Delete site member + * 10. Delete comment + * 11. Get Activities + * + * @throws Exception + */ + @Bug(id="REPO-1830") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its activities with Rest API and response is successful") + public void userGetsItsPeopleActivities() throws Exception + { + UserModel newUser = dataUser.createRandomTestUser(); + SiteModel userSiteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); + + dataUser.addUserToSite(newUser, userSiteModel, UserRole.SiteCollaborator); + dataContent.usingUser(newUser).usingSite(userSiteModel).createFolder(); + + fileInSite = dataContent.usingUser(newUser).usingSite(userSiteModel).createContent(DocumentType.TEXT_PLAIN); + String newContent = "This is a new comment added by " + newUser.getUsername(); + commentModel = restClient.authenticateUser(newUser).withCoreAPI().usingResource(fileInSite).addComment(newContent); + restClient.authenticateUser(newUser).withCoreAPI().usingResource(fileInSite).likeDocument(); + + restClient.withCoreAPI().usingResource(fileInSite).updateComment(commentModel, "new Content"); + newUser.setUserRole(UserRole.SiteManager); + restClient.authenticateUser(adminUser).withCoreAPI().usingSite(userSiteModel).updateSiteMember(newUser); + + restClient.authenticateUser(newUser).withCoreAPI().usingResource(fileInSite).deleteLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withCoreAPI().usingResource(fileInSite).deleteComment(commentModel); + restClient.authenticateUser(adminUser).withCoreAPI().usingSite(userSiteModel).deleteSiteMember(newUser); + + restActivityModelsCollection = restClient.authenticateUser(newUser).withCoreAPI().usingMe().getPersonActivitiesUntilEntriesCountIs(10); + restClient.assertStatusCodeIs(HttpStatus.OK); + restActivityModelsCollection.assertThat().paginationField("count").is("10"); + + restActivityModelsCollection = restClient.authenticateUser(newUser).withCoreAPI().usingMe().getPersonActivities(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restActivityModelsCollection.assertThat().paginationField("count").is("10"); + + restActivityModelsCollection.assertThat().entriesListContains("activityType", ActivityType.USER_JOINED.toString()).assertThat() + .entriesListContains("activityType", ActivityType.FILE_ADDED.toString()).assertThat() + .entriesListContains("activityType", ActivityType.FOLDER_ADDED.toString()).assertThat() + .entriesListContains("activityType", ActivityType.COMMENT_CREATED.toString()).assertThat() + .entriesListContains("activityType", ActivityType.FILE_LIKED.toString()).assertThat() + .entriesListContains("activityType", ActivityType.COMMENT_UPDATED.toString()).assertThat() + .entriesListContains("activityType", ActivityType.USER_ROLE_CHANGED.toString()).assertThat() + .entriesListContains("activityType", ActivityType.COMMENT_DELETED.toString()).assertThat() + .entriesListContains("activityType", ActivityType.USER_LEFT.toString()); + } + +} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/rest/NetworkDataPrep.java b/e2e-test/src/test/java/org/alfresco/rest/NetworkDataPrep.java new file mode 100644 index 000000000..dfee1c0d5 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/NetworkDataPrep.java @@ -0,0 +1,45 @@ +package org.alfresco.rest; + +import org.alfresco.rest.model.RestNetworkModel; +import org.alfresco.utility.model.UserModel; + +public abstract class NetworkDataPrep extends RestTest +{ + protected static UserModel adminUserModel; + protected static UserModel adminTenantUser, secondAdminTenantUser; + protected static UserModel tenantUser, secondTenantUser, differentNetworkTenantUser; + protected static UserModel tenantUserWithBad; + protected static UserModel userModel; + protected static RestNetworkModel restNetworkModel; + protected static String tenantDomain; + private static boolean isInitialized = false; + + public void init() throws Exception + { + if(!isInitialized) + { + isInitialized = true; + initialization(); + } + } + + public void initialization() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + //create first tenant Admin User. + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUserModel); + restClient.usingTenant().createTenant(adminTenantUser); + + tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + secondTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("sTenant"); + //create second tenant Admin User. + secondAdminTenantUser = UserModel.getAdminTenantUser(); + restClient.usingTenant().createTenant(secondAdminTenantUser); + + tenantDomain = tenantUser.getDomain(); + differentNetworkTenantUser = dataUser.usingUser(secondAdminTenantUser).createUserWithTenant("dTenant"); + + userModel = dataUser.createRandomTestUser(); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/RestTest.java b/e2e-test/src/test/java/org/alfresco/rest/RestTest.java new file mode 100644 index 000000000..1c6953576 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/RestTest.java @@ -0,0 +1,85 @@ +package org.alfresco.rest; + +import java.lang.reflect.Method; + +import org.alfresco.dataprep.WorkflowService; +import org.alfresco.rest.core.RestProperties; +import org.alfresco.rest.core.RestWrapper; +import org.alfresco.utility.LogFactory; +import org.alfresco.utility.TasProperties; +import org.alfresco.utility.data.DataContent; +import org.alfresco.utility.data.DataGroup; +import org.alfresco.utility.data.DataLink; +import org.alfresco.utility.data.DataSite; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.data.DataWorkflow; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.network.ServerHealth; +import org.slf4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.BeforeSuite; + +@ContextConfiguration("classpath:alfresco-restapi-context.xml") +public abstract class RestTest extends AbstractTestNGSpringContextTests +{ + private static Logger LOG = LogFactory.getLogger(); + + @Autowired + protected RestProperties restProperties; + + @Autowired + protected TasProperties properties; + + @Autowired + protected ServerHealth serverHealth; + + @Autowired + protected RestWrapper restClient; + + @Autowired + protected DataUser dataUser; + + @Autowired + protected DataSite dataSite; + + @Autowired + protected DataContent dataContent; + + @Autowired + protected DataGroup dataGroup; + + @Autowired + protected DataWorkflow dataWorkflow; + + @Autowired + protected DataLink dataLink; + + @Autowired + protected WorkflowService workflow; + + protected SiteModel testSite; + + @BeforeSuite(alwaysRun = true) + public void checkServerHealth() throws Exception + { + super.springTestContextPrepareTestInstance(); + serverHealth.assertServerIsOnline(); + testSite = dataSite.createPublicRandomSite(); + } + + @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/e2e-test/src/test/java/org/alfresco/rest/actions/ActionsTests.java b/e2e-test/src/test/java/org/alfresco/rest/actions/ActionsTests.java new file mode 100644 index 000000000..df822111d --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/actions/ActionsTests.java @@ -0,0 +1,151 @@ +package org.alfresco.rest.actions; + +import static org.testng.Assert.assertFalse; + +import com.google.common.collect.ImmutableMap; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestActionDefinitionModel; +import org.alfresco.rest.model.RestActionDefinitionModelsCollection; +import org.alfresco.rest.model.RestNodeModel; +import org.alfresco.utility.Utility; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.json.JSONObject; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class ActionsTests extends RestTest +{ + private UserModel adminUser; + private FileModel document; + private SiteModel publicSite; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + publicSite = dataSite.createPublicRandomSite(); + document = dataContent.usingSite(publicSite).usingUser(adminUser).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.ACTIONS }, executionType = ExecutionType.SANITY, + description = "Verify actions") + @Test(groups = { TestGroup.REST_API, TestGroup.ACTIONS, TestGroup.SANITY}) + public void testActionDefinitions() throws Exception + { + restClient.authenticateUser(dataContent.getAdminUser()); + + RestActionDefinitionModelsCollection restActionDefinitions = restClient. + withCoreAPI(). + usingActions(). + listActionDefinitions(); + + restClient.assertStatusCodeIs(HttpStatus.OK); + assertFalse(restActionDefinitions.isEmpty()); + restActionDefinitions.assertThat(). + entriesListContains("name", "copy"). + and().entriesListContains("name", "move"). + and().entriesListContains("name", "check-out"). + and().entriesListContains("name", "check-in"); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.ACTIONS }, executionType = ExecutionType.REGRESSION, + description = "Verify actions error conditions") + @Test(groups = { TestGroup.REST_API, TestGroup.ACTIONS, TestGroup.REGRESSION}) + public void testActionDefinitionsNegative() throws Exception{ + // Badly formed request -> 400 + { + restClient.authenticateUser(dataContent.getAdminUser()). + // invalid skipCount + withParams("skipCount=-1"). + withCoreAPI(). + usingActions(). + listActionDefinitions(); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + + } + + // Unauthorized -> 401 + { + + UserModel userUnauthorized = new UserModel("invalid-user", "invalid-pasword"); + restClient.authenticateUser(userUnauthorized).withCoreAPI().usingActions().listActionDefinitions(); + + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + } + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.ACTIONS }, executionType = ExecutionType.SANITY, + description = "Sanity test for POST /action-executions") + @Test(groups = { TestGroup.REST_API, TestGroup.ACTIONS, TestGroup.SANITY}) + public void executeAction() throws Exception + { + JSONObject response = restClient.authenticateUser(adminUser).withCoreAPI().usingActions().executeAction + ("add-features", document, ImmutableMap.of("aspect-name", "cm:versionable")); + restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); + + assertFalse(response.getString("id").isEmpty()); + + /* + * Get all node properties and check that action was executed and + * cm:versionable aspect was added + */ + Utility.sleep(500, 20000, () -> { + RestNodeModel fileModel = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(document).getNode(); + + restClient.assertStatusCodeIs(HttpStatus.OK); + fileModel.assertThat().field("aspectNames").contains("cm:versionable"); + }); + } + + @TestRail (section = { TestGroup.REST_API, TestGroup.ACTIONS }, executionType = ExecutionType.SANITY, + description = "Sanity test for POST /action-executions") + @Test (groups = { TestGroup.REST_API, TestGroup.ACTIONS, TestGroup.SANITY }) + public void executeActionWithoutParam() throws Exception + { + JSONObject response = restClient.authenticateUser(adminUser).withCoreAPI().usingActions().executeAction + ("check-out", document); + restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); + + assertFalse(response.getString("id").isEmpty()); + + /* + * Get all node properties and check that action was executed and + * cm:checkedOut aspect was added + */ + Utility.sleep(500, 20000, () -> { + RestNodeModel fileModel = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(document) + .getNode(); + + restClient.assertStatusCodeIs(HttpStatus.OK); + fileModel.assertThat().field("aspectNames").contains("cm:checkedOut"); + }); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.ACTIONS }, executionType = ExecutionType.SANITY, + description = "Sanity test for ACTIONS endpoint GET action-definitions/{actionDefinitionId}") + @Test(groups = { TestGroup.REST_API, TestGroup.ACTIONS, TestGroup.SANITY}) + public void testGetActionDefinitionById() throws Exception + { + restClient.authenticateUser(dataContent.getAdminUser()); + + RestActionDefinitionModel restActionDefinition = restClient. + withCoreAPI(). + usingActions(). + getActionDefinitionById("add-features"); + + restClient.assertStatusCodeIs(HttpStatus.OK); + assertFalse(restActionDefinition.getId().isEmpty()); + restActionDefinition.getId().equals("add-features"); + restActionDefinition.getDescription().equals("This will add an aspect to the matched item."); + restActionDefinition.getTitle().equals("Add aspect"); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/aos/AosApiTest.java b/e2e-test/src/test/java/org/alfresco/rest/aos/AosApiTest.java new file mode 100644 index 000000000..6223db2f7 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/aos/AosApiTest.java @@ -0,0 +1,24 @@ +package org.alfresco.rest.aos; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.RestRequest; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.testng.annotations.Test; + +public class AosApiTest extends RestTest +{ + /* + * @author: Catalin Gornea + * + * simple test for demo purposes on how to use Aos with Rest + */ + @Test(enabled=false) + public void assertResponsIsSuccesufulWhenGetRootDirectory() throws Exception + { + restClient.authenticateUser(dataUser.getAdminUser()).withAosAPI(); + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, ""); + restClient.process(request); + restClient.assertStatusCodeIs(HttpStatus.OK); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/audit/AuditTest.java b/e2e-test/src/test/java/org/alfresco/rest/audit/AuditTest.java new file mode 100644 index 000000000..92ac3afc9 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/audit/AuditTest.java @@ -0,0 +1,112 @@ +package org.alfresco.rest.audit; + +import static org.hamcrest.Matchers.is; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +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.RestAuditAppModel; +import org.alfresco.rest.model.RestAuditAppModelsCollection; +import org.alfresco.rest.model.RestAuditEntryModel; +import org.alfresco.rest.model.RestAuditEntryModelsCollection; +import org.alfresco.rest.model.RestNodeModel; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.network.JmxBuilder; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.testng.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import com.jayway.restassured.RestAssured; + +@Test(groups = {TestGroup.REQUIRE_JMX}) +public abstract class AuditTest extends RestTest +{ + + @Autowired + protected RestWrapper restAPI; + + @Autowired + protected JmxBuilder jmxBuilder; + + protected UserModel userModel, userModel1, adminUser; + protected RestAuditAppModelsCollection restAuditCollection; + protected RestAuditAppModel restAuditAppModel; + protected RestAuditEntryModel restAuditEntryModel; + protected RestAuditEntryModelsCollection restAuditEntryCollection; + protected RestAuditAppModel syncRestAuditAppModel; + protected RestAuditAppModel taggingRestAuditAppModel; + protected RestNodeModel node; + protected FileModel file; + protected SiteModel privateTestSite; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + //Audit API is designed for users with admin rights (except /nodes/{nodeId}/audit-entries) + //Create users and add userModel as SiteCollaborator on private site + userModel = dataUser.createRandomTestUser(); + userModel1 = dataUser.createRandomTestUser(); + adminUser = dataUser.getAdminUser(); + privateTestSite = dataSite.createPrivateRandomSite(); + + dataUser.addUserToSite(userModel, privateTestSite, UserRole.SiteCollaborator); + userModel.setUserRole(UserRole.SiteCollaborator); + + //Enable alfresco-access audit application. + jmxBuilder.getJmxClient().writeProperty("Alfresco:Type=Configuration,Category=Audit,id1=default", "audit.alfresco-access.enabled", Boolean.TRUE.toString()); + String alfrescoAccessEnabled = jmxBuilder.getJmxClient().readProperty("Alfresco:Type=Configuration,Category=Audit,id1=default", "audit.alfresco-access.enabled").toString(); + Assert.assertEquals(alfrescoAccessEnabled, Boolean.TRUE.toString(), String.format("Property audit.alfresco-access.enabled is [%s]", alfrescoAccessEnabled)); + + //GET /alfresco/service/api/audit/control to verify if Audit is enabled on the system. + RestAssured.basePath = ""; + restAPI.configureRequestSpec().setBasePath(RestAssured.basePath); + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "alfresco/service/api/audit/control"); + RestResponse response = restAPI.authenticateUser(adminUser).process(request); + response.assertThat().body("enabled", is(true)); + + //GET /audit-applications and verify that there are audit applications in the system. + restAuditCollection = restClient.authenticateUser(adminUser).withCoreAPI().usingAudit().getAuditApplications(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restAuditCollection.assertThat().entriesListIsNotEmpty(); + + //Find alfresco-access audit application in the list of audit applications. + int i = 0; + do + { + restAuditAppModel = restAuditCollection.getEntries().get(i++).onModel(); + } while (!restAuditAppModel.getName().equals("alfresco-access")); + + //Create new file + file = dataContent.usingUser(adminUser).usingSite(privateTestSite).createContent(DocumentType.TEXT_PLAIN); + node = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file).usingParams("include=isLocked").getNode(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + protected RestAuditAppModel getSyncRestAuditAppModel(UserModel userModel) throws Exception + { + restAuditCollection = restClient.authenticateUser(userModel).withCoreAPI().usingAudit().getAuditApplications(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restAuditCollection.assertThat().entriesListIsNotEmpty(); + RestAuditAppModel syncRestAuditAppModel = restAuditCollection.getEntries().get(0).onModel(); + return syncRestAuditAppModel; + } + + protected RestAuditAppModel getTaggingRestAuditAppModel(UserModel userModel) throws Exception + { + restAuditCollection = restClient.authenticateUser(userModel).withCoreAPI().usingAudit().getAuditApplications(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restAuditCollection.assertThat().entriesListIsNotEmpty(); + RestAuditAppModel taggingRestAuditAppModel = restAuditCollection.getEntries().get(1).onModel(); + return taggingRestAuditAppModel; + } + +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/audit/DeleteAuditTests.java b/e2e-test/src/test/java/org/alfresco/rest/audit/DeleteAuditTests.java new file mode 100644 index 000000000..f6f0065b2 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/audit/DeleteAuditTests.java @@ -0,0 +1,66 @@ +package org.alfresco.rest.audit; + +import static org.testng.Assert.assertEquals; + +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; + +@Test(groups = {TestGroup.REQUIRE_JMX}) +public class DeleteAuditTests extends AuditTest +{ + + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if deleting an audit entry for an application is only for admin user, and status code is 204") + public void deleteAuditEntry() throws Exception + { + restAuditEntryCollection = restClient.authenticateUser(adminUser).withParams("maxItems=10").withCoreAPI().usingAudit() + .listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); + restClient.assertStatusCodeIs(HttpStatus.OK); + String entryId = restAuditEntryCollection.getEntries().get(restAuditEntryCollection.getPagination().getCount() - 1) + .onModel().getId(); + + restClient.authenticateUser(userModel).withCoreAPI().usingAudit() + .deleteAuditEntryForAnAuditApplication(restAuditAppModel.getId(), entryId); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + + restClient.authenticateUser(adminUser).withCoreAPI().usingAudit() + .deleteAuditEntryForAnAuditApplication(restAuditAppModel.getId(), entryId); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restAuditEntryModel = restClient.authenticateUser(adminUser).withCoreAPI().usingAudit() + .getAuditEntryForAnAuditApplication(restAuditAppModel.getId(), entryId); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if deleting a set of audit entries for an application is only for admin user, and status code is 204") + public void deleteAuditEntriesForAnAuditApplication() throws Exception + { + restAuditEntryCollection = restClient.authenticateUser(adminUser).withParams("maxItems=4").withCoreAPI().usingAudit() + .listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); + restClient.assertStatusCodeIs(HttpStatus.OK); + + String firstId = restAuditEntryCollection.getEntries().get(0).onModel().getId(); + String secondId = restAuditEntryCollection.getEntries().get(restAuditEntryCollection.getPagination().getCount() - 1) + .onModel().getId(); + + restClient.authenticateUser(userModel).withParams("where=(id BETWEEN (" + firstId + "," + secondId + "))").withCoreAPI() + .usingAudit().deleteAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + + restClient.authenticateUser(adminUser).withParams("where=(id BETWEEN (" + firstId + "," + secondId + "))").withCoreAPI() + .usingAudit().deleteAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restAuditEntryCollection = restClient.authenticateUser(adminUser).withParams("where=(id BETWEEN ("+firstId+","+secondId+"))").withCoreAPI().usingAudit() + .listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); + restClient.assertStatusCodeIs(HttpStatus.OK); + assertEquals(restAuditEntryCollection.getPagination().getCount(), 0); + } + +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/audit/GetAuditTests.java b/e2e-test/src/test/java/org/alfresco/rest/audit/GetAuditTests.java new file mode 100644 index 000000000..39c3afb2e --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/audit/GetAuditTests.java @@ -0,0 +1,357 @@ +package org.alfresco.rest.audit; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertTrue; + +import java.util.ArrayList; + +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; + +@Test(groups = {TestGroup.REQUIRE_JMX}) +public class GetAuditTests extends AuditTest +{ + + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if the admin user gets audit application info") + public void getAuditApplicationInfoWithAdminUser() throws Exception + { + restAuditAppModel.assertThat().field("isEnabled").is(true); + restAuditAppModel.assertThat().field("name").is("alfresco-access"); + restAuditAppModel.assertThat().field("id").is("alfresco-access"); + + syncRestAuditAppModel = getSyncRestAuditAppModel(adminUser); + syncRestAuditAppModel.assertThat().field("isEnabled").is(true); + syncRestAuditAppModel.assertThat().field("name").is("Alfresco Sync Service"); + syncRestAuditAppModel.assertThat().field("id").is("sync"); + + taggingRestAuditAppModel = getTaggingRestAuditAppModel(adminUser); + taggingRestAuditAppModel.assertThat().field("isEnabled").is(true); + taggingRestAuditAppModel.assertThat().field("name").is("Alfresco Tagging Service"); + taggingRestAuditAppModel.assertThat().field("id").is("tagging"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if a normal user gets a list of audit applications and status code is 403") + public void getAuditApplicationsWithNormalUser() throws Exception + { + restAuditCollection = restClient.authenticateUser(userModel).withCoreAPI().usingAudit().getAuditApplications(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + restAuditCollection.assertThat().entriesListIsEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.AUDIT }, executionType = ExecutionType.REGRESSION, description = "Verify if the admin user gets a list of audit applications using skipCount and status code is 200") + public void getAuditApplicationsWithAdminUserUsingValidSkipCount() throws Exception + { + restAuditCollection = restClient.authenticateUser(adminUser).withParams("skipCount=1").withCoreAPI() + .usingAudit().getAuditApplications(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restAuditCollection.getPagination().assertThat().field("totalItems").isNotNull().and().field("totalItems") + .isGreaterThan(0).and().field("skipCount").is("1"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.AUDIT }, executionType = ExecutionType.REGRESSION, description = "Verify if the admin user gets a list of audit applications using invalid skipCount and status code is 400") + public void getAuditApplicationsWithAdminUserUsingInvalidSkipCount() throws Exception + { + restClient.authenticateUser(adminUser).withParams("skipCount=-1").withCoreAPI().usingAudit() + .getAuditApplications(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.AUDIT }, executionType = ExecutionType.REGRESSION, description = "Verify if the admin user gets a list of audit applications using maxItems and status code is 200") + public void getAuditApplicationsWithAdminUserUsingValidMaxItems() throws Exception + { + restAuditCollection = restClient.authenticateUser(adminUser).withParams("maxItems=1").withCoreAPI() + .usingAudit().getAuditApplications(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restAuditCollection.getPagination().assertThat().field("totalItems").isNotNull().and().field("totalItems") + .isGreaterThan(0).and().field("maxItems").is("1"); + assertEquals(restAuditCollection.getEntries().size(), 1); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.AUDIT }, executionType = ExecutionType.REGRESSION, description = "Verify if the admin user gets a list of audit applications using invalid maxItems and status code is 400") + public void getAuditApplicationsWithAdminUserUsingInvalidMaxItems() throws Exception + { + restClient.authenticateUser(adminUser).withParams("maxItems=-1").withCoreAPI().usingAudit() + .getAuditApplications(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + + restClient.authenticateUser(adminUser).withParams("maxItems=0").withCoreAPI().usingAudit() + .getAuditApplications(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + + } + + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if the admin user gets a list of audit applications using skipCount and maxItems and status code is 200") + public void getAuditApplicationsWithAdminUserUsingValidSkipCountAndMaxItems() throws Exception + { + restAuditCollection = restClient.authenticateUser(adminUser).withParams("skipCount=1&maxItems=1") + .withCoreAPI().usingAudit().getAuditApplications(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restAuditCollection.getPagination().assertThat().field("totalItems").isNotNull().and().field("totalItems") + .isGreaterThan(0).and().field("maxItems").is("1").and().field("skipCount").is("1"); + assertEquals(restAuditCollection.getEntries().size(), 1); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.AUDIT }, executionType = ExecutionType.REGRESSION, description = "Verify if the admin user gets a list of audit applications using invalid skipCount and/or invalid maxItems and status code is 400") + public void getAuditApplicationsWithAdminUserUsingInvalidSkipCountAndMaxItems() throws Exception + { + restClient.authenticateUser(adminUser).withParams("skipCount=-1&maxItems=1").withCoreAPI().usingAudit() + .getAuditApplications(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + + restClient.authenticateUser(adminUser).withParams("skipCount=-1&maxItems=-1").withCoreAPI().usingAudit() + .getAuditApplications(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + + restClient.authenticateUser(adminUser).withParams("skipCount=-1&maxItems=0").withCoreAPI().usingAudit() + .getAuditApplications(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + + restClient.authenticateUser(adminUser).withParams("skipCount=1&maxItems=-1").withCoreAPI().usingAudit() + .getAuditApplications(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if a normal user gets a list of audit entries for audit application auditApplicationId and status code is 403") + public void getAuditEntriesWithNormalUser() throws Exception + { + restClient.authenticateUser(userModel).withCoreAPI().usingAudit() + .listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if the admin user gets a list of audit entries using invalid skipCount and/or invalid maxItems and status code is 400") + public void getAuditEntriesWithAdminUserUsingInvalidSkipCountAndMaxItems() throws Exception + { + restClient.authenticateUser(adminUser).withParams("skipCount=-1&maxItems=1").withCoreAPI().usingAudit() + .listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + + restClient.authenticateUser(adminUser).withParams("skipCount=-1&maxItems=-1").withCoreAPI().usingAudit() + .listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + + restClient.authenticateUser(adminUser).withParams("skipCount=-1&maxItems=0").withCoreAPI().usingAudit() + .listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + + restClient.authenticateUser(adminUser).withParams("skipCount=1&maxItems=-1").withCoreAPI().usingAudit() + .listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if the admin user gets a list of audit entries using valid skipCount and maxItems and status code is 200") + public void getAuditEntriesWithAdminUserUsingValidSkipCountAndMaxItems() throws Exception + { + restAuditEntryCollection = restClient.authenticateUser(adminUser).withParams("skipCount=1&maxItems=1") + .withCoreAPI().usingAudit().listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); + restClient.assertStatusCodeIs(HttpStatus.OK); + restAuditEntryCollection.getPagination().assertThat().field("totalItems").isNotNull().and().field("totalItems") + .isGreaterThan(0).and().field("maxItems").is("1").and().field("skipCount").is("1"); + assertEquals(restAuditEntryCollection.getEntries().size(), 1); + + // Testing Pagination + restAuditEntryCollection = restClient.authenticateUser(adminUser).withParams("maxItems=10").withCoreAPI().usingAudit() + .listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); + restClient.assertStatusCodeIs(HttpStatus.OK); + ArrayList ids = new ArrayList<>(); + int numberOfElements = restAuditEntryCollection.getPagination().getCount(); + for (int i = 0; i < numberOfElements; i++) + { + ids.add(restAuditEntryCollection.getEntries().get(i).onModel().getId()); + } + + int skipCount = 0; + do + { + restAuditEntryCollection = restClient.authenticateUser(adminUser).withParams("maxItems=1&skipCount=" + skipCount) + .withCoreAPI().usingAudit().listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); + restClient.assertStatusCodeIs(HttpStatus.OK); + assertEquals(restAuditEntryCollection.getEntries().size(), 1); + assertEquals(restAuditEntryCollection.getPagination().getCount(), 1); + assertEquals(restAuditEntryCollection.getPagination().getSkipCount(), skipCount); + assertEquals(restAuditEntryCollection.getEntries().get(0).onModel().getId(), ids.get(skipCount)); + skipCount++; + } while (skipCount < numberOfElements); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.AUDIT }, executionType = ExecutionType.REGRESSION, description = "Verify if the admin user gets a list of audit entries using orderBy and status code is 200") + public void getAuditEntriesWithAdminUserUsingOrderBy() throws Exception + { + restAuditEntryCollection = restClient.authenticateUser(adminUser).withParams("orderBy=createdAt ASC&maxItems=10") + .withCoreAPI().usingAudit().listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); + restClient.assertStatusCodeIs(HttpStatus.OK); + + String ascId = restAuditEntryCollection.getEntries().get(1).onModel().getId(); + + restAuditEntryCollection = restClient.authenticateUser(adminUser).withParams("orderBy=createdAt DESC&maxItems=10") + .withCoreAPI().usingAudit().listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); + restClient.assertStatusCodeIs(HttpStatus.OK); + + assertTrue(Integer.parseInt(restAuditEntryCollection.getEntries().get(1).onModel().getId()) > Integer.parseInt(ascId)); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.AUDIT }, executionType = ExecutionType.REGRESSION, description = "Verify if the admin user gets a list of audit entries using the where parameter to and status code is 200") + public void getAuditEntriesWithAdminUserUsingWhere() throws Exception + { + int expectedNumberOfItems; + String id1,id2; + restAuditEntryCollection = restClient.authenticateUser(adminUser).withParams("maxItems=2").withCoreAPI().usingAudit().listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); + restClient.assertStatusCodeIs(HttpStatus.OK); + + if (restAuditEntryCollection.getPagination().getCount() == 2) + { + id1 = restAuditEntryCollection.getEntries().get(0).onModel().getId(); + id2 = restAuditEntryCollection.getEntries().get(1).onModel().getId(); + expectedNumberOfItems = 2; + } + else + { + id1 = id2 = restAuditEntryCollection.getEntries().get(0).onModel().getId(); + expectedNumberOfItems = 1; + } + + restAuditEntryCollection = restClient.authenticateUser(adminUser).withParams("where=(id BETWEEN ("+id1+","+id2+"))") + .withCoreAPI().usingAudit().listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); + restClient.assertStatusCodeIs(HttpStatus.OK); + + restAuditEntryCollection.assertThat().entriesListCountIs(expectedNumberOfItems); + assertEquals(id1, restAuditEntryCollection.getEntries().get(0).onModel().getId()); + if (!id1.equals(id2)) + { + assertEquals(id2, restAuditEntryCollection.getEntries().get(1).onModel().getId()); + } + } + + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if retrieving an audit entry for an audit application is only for admin user, with and without the include=values paramater and status code is 200") + public void getAuditEntry() throws Exception + { + restAuditEntryCollection = restClient.authenticateUser(adminUser).withParams("maxItems=10").withCoreAPI().usingAudit() + .listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); + restClient.assertStatusCodeIs(HttpStatus.OK); + String entryId = restAuditEntryCollection.getEntries().get(restAuditEntryCollection.getPagination().getCount() - 1) + .onModel().getId(); + String entryApplicationId = restAuditEntryCollection.getEntries() + .get(restAuditEntryCollection.getPagination().getCount() - 1).onModel().getAuditApplicationId(); + + restAuditEntryModel = restClient.authenticateUser(userModel).withCoreAPI().usingAudit() + .getAuditEntryForAnAuditApplication(restAuditAppModel.getId(), entryId); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + + restAuditEntryModel = restClient.authenticateUser(adminUser).withCoreAPI().usingAudit() + .getAuditEntryForAnAuditApplication(restAuditAppModel.getId(), entryId); + restClient.assertStatusCodeIs(HttpStatus.OK); + assertEquals(entryId, restAuditEntryModel.getId()); + assertEquals(entryApplicationId, restAuditEntryModel.getAuditApplicationId()); + // Values are displayed by default for single audit application entry + assertNotNull(restAuditEntryModel.getValues()); + + restAuditEntryModel = restClient.authenticateUser(adminUser).withParams("include=values").withCoreAPI().usingAudit() + .getAuditEntryForAnAuditApplication(restAuditAppModel.getId(), entryId); + restClient.assertStatusCodeIs(HttpStatus.OK); + assertEquals(entryId, restAuditEntryModel.getId()); + assertEquals(entryApplicationId, restAuditEntryModel.getAuditApplicationId()); + assertNotNull(restAuditEntryModel.getValues()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if the admin user gets a list of audit entries for node id nodeId using 'where' and 'maxItems' param and status code is 200") + public void getAuditEntriesForNodeUsingMaxItemsAndWhereParam() throws Exception + { + String createdAt1, createdAt2; + int expectedNumberOfItems; + + // Get the node id + String nodeId = node.getId(); + + // Add comments for a node (to create audit entries) + restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file).addComment("This is the first comment"); + restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file).addComment("This is the second comment"); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + // Get maxium two audit entries for the node using 'maxItems' param on /nodes/{nodeId}/audit-entries + restAuditEntryCollection = restClient.authenticateUser(adminUser).withParams("maxItems=2").withCoreAPI().usingAudit().listAuditEntriesForNode(nodeId); + restClient.assertStatusCodeIs(HttpStatus.OK); + restAuditEntryCollection.assertThat().entriesListIsNotEmpty(); + + if (restAuditEntryCollection.getPagination().getCount() == 2) + { + createdAt1 = restAuditEntryCollection.getEntries().get(0).onModel().getCreatedAt(); + createdAt2 = restAuditEntryCollection.getEntries().get(1).onModel().getCreatedAt(); + expectedNumberOfItems = 2; + } + else + { + createdAt1 = createdAt2 = restAuditEntryCollection.getEntries().get(0).onModel().getCreatedAt(); + expectedNumberOfItems = 1; + } + + // Get audit entries between ids for the node using 'where' clause on /nodes/{nodeId}/audit-entries + restAuditEntryCollection = restClient.authenticateUser(adminUser).withParams("where=(createdAt BETWEEN ('" + createdAt1 + "','" + createdAt2 + "'))") + .withCoreAPI().usingAudit().listAuditEntriesForNode(nodeId); + restClient.assertStatusCodeIs(HttpStatus.OK); + + restAuditEntryCollection.assertThat().entriesListCountIs(expectedNumberOfItems); + assertEquals(createdAt1, restAuditEntryCollection.getEntries().get(0).onModel().getCreatedAt()); + if (!createdAt1.equals(createdAt2)) + { + assertEquals(createdAt2, restAuditEntryCollection.getEntries().get(1).onModel().getCreatedAt()); + } + } + + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if user with permissions can get a list of audit entries for node and status code is 200") + public void getAuditEntriesForNodeUsingUserWithPermissions() throws Exception + { + // Get the node id + String nodeId = node.getId(); + + // Add comments for a node using user with permissions (to create audit entries and check if user can view/edit the node) + restClient.authenticateUser(userModel).withCoreAPI().usingNode(file).addComment("This is a comment"); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + // Get audit entries for the node using a user with permissions and /nodes/{nodeId}/audit-entries + restAuditEntryCollection = restClient.authenticateUser(userModel).withCoreAPI().usingAudit().listAuditEntriesForNode(nodeId); + restClient.assertStatusCodeIs(HttpStatus.OK); + restAuditEntryCollection.assertThat().entriesListIsNotEmpty(); + + // Check that a user that doesn't have access to node, doesn't have access to audit entries for node + restClient.authenticateUser(userModel1).withCoreAPI().usingNode(file).getNode(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + restClient.authenticateUser(userModel1).withCoreAPI().usingAudit().listAuditEntriesForNode(nodeId); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/audit/PutAuditTests.java b/e2e-test/src/test/java/org/alfresco/rest/audit/PutAuditTests.java new file mode 100644 index 000000000..38ccd3c6d --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/audit/PutAuditTests.java @@ -0,0 +1,111 @@ +package org.alfresco.rest.audit; + +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; + +@Test(groups = {TestGroup.REQUIRE_JMX}) +public class PutAuditTests extends AuditTest +{ + + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.AUDIT }, executionType = ExecutionType.REGRESSION, description = "Verify that the admin user can enable/disable sync application auditing") + public void enableDisableSyncApplicationAuditingAsAdminUser() throws Exception + { + // disable sync audit app + syncRestAuditAppModel = getSyncRestAuditAppModel(adminUser); + restClient.authenticateUser(adminUser).withCoreAPI().usingAudit().updateAuditApp(syncRestAuditAppModel, "isEnabled", + "false"); + + // check isEnabled=false + syncRestAuditAppModel = getSyncRestAuditAppModel(adminUser); + syncRestAuditAppModel.assertThat().field("isEnabled").is(false); + syncRestAuditAppModel.assertThat().field("name").is("Alfresco Sync Service"); + syncRestAuditAppModel.assertThat().field("id").is("sync"); + + // enable sync audit app + restClient.authenticateUser(adminUser).withCoreAPI().usingAudit().updateAuditApp(syncRestAuditAppModel, "isEnabled", + "true"); + + // check isEnabled=true + syncRestAuditAppModel = getSyncRestAuditAppModel(adminUser); + syncRestAuditAppModel.assertThat().field("isEnabled").is(true); + syncRestAuditAppModel.assertThat().field("name").is("Alfresco Sync Service"); + syncRestAuditAppModel.assertThat().field("id").is("sync"); + + } + + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify that the admin user can enable/disable tagging application auditing") + public void enableDisableTaggingApplicationAuditingAsAdminUser() throws Exception + { + // disable tagging audit app + taggingRestAuditAppModel = getTaggingRestAuditAppModel(adminUser); + restClient.authenticateUser(adminUser).withCoreAPI().usingAudit().updateAuditApp(taggingRestAuditAppModel, "isEnabled", + "false"); + + // check isEnabled=false + taggingRestAuditAppModel = getTaggingRestAuditAppModel(adminUser); + taggingRestAuditAppModel.assertThat().field("isEnabled").is(false); + taggingRestAuditAppModel.assertThat().field("name").is("Alfresco Tagging Service"); + taggingRestAuditAppModel.assertThat().field("id").is("tagging"); + + // enable tagging audit app + restClient.authenticateUser(adminUser).withCoreAPI().usingAudit().updateAuditApp(taggingRestAuditAppModel, "isEnabled", + "true"); + + // check isEnabled=true + taggingRestAuditAppModel = getTaggingRestAuditAppModel(adminUser); + taggingRestAuditAppModel.assertThat().field("isEnabled").is(true); + taggingRestAuditAppModel.assertThat().field("name").is("Alfresco Tagging Service"); + taggingRestAuditAppModel.assertThat().field("id").is("tagging"); + + } + + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.AUDIT }, executionType = ExecutionType.REGRESSION, description = "Verify that the normal user can't enable/disable sync application auditing") + public void enableDisableSyncApplicationAuditingAsNormalUser() throws Exception + { + // disable sync audit app + syncRestAuditAppModel = getSyncRestAuditAppModel(adminUser); + restClient.authenticateUser(userModel).withCoreAPI().usingAudit().updateAuditApp(syncRestAuditAppModel, "isEnabled", + "false"); + + // permission denied + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + + // enable sync audit app + restClient.authenticateUser(userModel).withCoreAPI().usingAudit().updateAuditApp(syncRestAuditAppModel, "isEnabled", + "true"); + + // permission denied + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify that the normal user can't enable/disable tagging application auditing") + public void enableDisableTaggingApplicationAuditingAsNormalUser() throws Exception + { + // disable tagging audit app + taggingRestAuditAppModel = getTaggingRestAuditAppModel(adminUser); + restClient.authenticateUser(userModel).withCoreAPI().usingAudit().updateAuditApp(taggingRestAuditAppModel, "isEnabled", + "false"); + + // permission denied + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + + // disable tagging audit app + restClient.authenticateUser(userModel).withCoreAPI().usingAudit().updateAuditApp(taggingRestAuditAppModel, "isEnabled", + "true"); + + // permission denied + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + } + +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/auth/AuthTests.java b/e2e-test/src/test/java/org/alfresco/rest/auth/AuthTests.java new file mode 100644 index 000000000..70826fe4c --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/auth/AuthTests.java @@ -0,0 +1,87 @@ +package org.alfresco.rest.auth; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.RestWrapper; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestTicketBodyModel; +import org.alfresco.rest.model.RestTicketModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.apache.commons.codec.binary.Base64; +import org.springframework.http.HttpStatus; +import org.testng.Assert; +import org.testng.annotations.Test; + +public class AuthTests extends RestTest +{ + + private RestWrapper addRestRequestAuthorization(RestTicketModel ticketModel) + { + restClient.configureRequestSpec().addHeader("Authorization", "Basic " + encodeB64(ticketModel.getId())); + return restClient; + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.AUTH }, executionType = ExecutionType.SANITY, description = "Verify HttpMethod.POST tickets") + @Test(groups = { TestGroup.REST_API, TestGroup.SANITY, TestGroup.AUTH }) + public void adminShouldGetTicketBody() throws JsonToModelConversionException, Exception + { + RestTicketBodyModel ticketBody = new RestTicketBodyModel(); + ticketBody.setUserId("admin"); + ticketBody.setPassword("admin"); + + RestTicketModel ticketReturned = restClient.authenticateUser(dataContent.getAdminUser()).withAuthAPI().createTicket(ticketBody); + + restClient.assertStatusCodeIs(HttpStatus.CREATED); + ticketReturned.assertThat().field("id").contains("TICKET_"); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.AUTH }, executionType = ExecutionType.SANITY, description = "Verify HttpMethod.GET tickets/-me-") + @Test(groups = { TestGroup.REST_API, TestGroup.SANITY, TestGroup.AUTH }) + public void randomUserGetTicket() throws Exception + { + UserModel userModel = dataUser.createRandomTestUser(); + RestTicketBodyModel ticketBody = new RestTicketBodyModel(); + ticketBody.setUserId(userModel.getUsername()); + ticketBody.setPassword(userModel.getPassword()); + + RestTicketModel ticketCreated = restClient.authenticateUser(userModel).withAuthAPI().createTicket(ticketBody); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + addRestRequestAuthorization(ticketCreated); + RestTicketModel ticketReturned = restClient.withAuthAPI().getTicket(); + Assert.assertEquals(ticketCreated.getId(), ticketReturned.getId()); + + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.AUTH }, executionType = ExecutionType.SANITY, description = "Verify HttpMethod.REMOVE tickets/-me-") + @Test(groups = { TestGroup.REST_API, TestGroup.SANITY, TestGroup.AUTH }) + public void randomUserRemoveTicket() throws Exception + { + UserModel userModel = dataUser.createRandomTestUser(); + RestTicketBodyModel ticketBody = new RestTicketBodyModel(); + ticketBody.setUserId(userModel.getUsername()); + ticketBody.setPassword(userModel.getPassword()); + + RestTicketModel ticketCreated = restClient.authenticateUser(userModel).withAuthAPI().createTicket(ticketBody); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + addRestRequestAuthorization(ticketCreated); + restClient.withAuthAPI().removeTicket(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withAuthAPI().getTicket(); + restClient.assertLastError().containsErrorKey("Ticket base authentication required."); + + } + + private String encodeB64(String str) + { + return Base64.encodeBase64String(str.getBytes()); + } + +} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/rest/cmis/CmisBrowserTest.java b/e2e-test/src/test/java/org/alfresco/rest/cmis/CmisBrowserTest.java new file mode 100644 index 000000000..1e9afbab7 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/cmis/CmisBrowserTest.java @@ -0,0 +1,25 @@ +package org.alfresco.rest.cmis; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.RestResponse; +import org.alfresco.utility.model.FileModel; +import org.testng.annotations.Test; + +public class CmisBrowserTest extends RestTest +{ + /* + * @author: Paul Brodner + * simple test for demo purposes on how to use CMIS browser binding with Rest + */ + @Test(enabled=false) + public void assertContentDispositionHeaderOnCmisFile() throws Exception + { + FileModel document = dataContent.usingUser(dataUser.getAdminUser()) + .usingSite(testSite).createContent(DocumentType.HTML); + + RestResponse response = restClient.authenticateUser(dataUser.getAdminUser()).withCMISApi().getRootObjectByID(document); + response.assertThat().header("Content-Disposition", String.format("attachment; filename=%s", document.getName())); + } + +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/comments/AddCommentTests.java b/e2e-test/src/test/java/org/alfresco/rest/comments/AddCommentTests.java new file mode 100644 index 000000000..aeaa95869 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/comments/AddCommentTests.java @@ -0,0 +1,260 @@ +package org.alfresco.rest.comments; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestCommentModel; +import org.alfresco.rest.model.RestCommentModelsCollection; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestTagModel; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.RandomData; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FileType; +import org.alfresco.utility.model.LinkModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.apache.commons.lang3.RandomStringUtils; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class AddCommentTests extends RestTest +{ + private UserModel adminUserModel; + private FileModel document; + private SiteModel siteModel; + private ListUserWithRoles usersWithRoles; + private String comment; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + restClient.authenticateUser(adminUserModel); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify admin user adds comments with Rest API and status code is 201") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) + public void adminIsAbleToAddComment() throws Exception + { + restClient.authenticateUser(adminUserModel); + String newContent = "This is a new comment added by " + adminUserModel.getUsername(); + restClient.withCoreAPI().usingResource(document).addComment(newContent) + .assertThat().field("content").isNotEmpty() + .and().field("content").is(newContent); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.onResponse().assertThat().body("entry.edited", org.hamcrest.Matchers.is(false)); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, + description = "Verify that comment can be retrieved after it is added") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) + public void addCommentThenRetrieveComment() throws Exception + { + comment = RandomData.getRandomName("comment1"); + restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingResource(document).addComment(comment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestCommentModelsCollection comments = restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingResource(document).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + comments.assertThat().entriesListContains("content", comment); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user gets status code 401 on post comments call") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) +// @Bug(id = "MNT-16904", description = "It fails only on environment with tenants") + public void unauthenticatedUserIsNotAbleToAddComment() throws Exception + { + restClient.authenticateUser(new UserModel("random user", "random password")); + restClient.withCoreAPI().usingResource(document).addComment("This is a new comment"); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Manager user adds comments with Rest API and status code is 201") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void managerIsAbleToAddComment() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + String contentSiteManger = "This is a new comment added by user with role: " + UserRole.SiteManager; + RestCommentModel createdComment = restClient.withCoreAPI().usingResource(document).addComment(contentSiteManger); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + createdComment.assertThat().field("content").isNotEmpty() + .and().field("content").is(contentSiteManger); + + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Contributor user adds comments with Rest API and status code is 201") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + @Bug(id="ACE-4614") + public void contributorIsAbleToAddComment() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + String contentSiteContributor = "This is a new comment added by user with role" + UserRole.SiteContributor; + RestCommentModel createdComment = restClient.withCoreAPI().usingResource(document).addComment(contentSiteContributor); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + createdComment.assertThat().field("content").isNotEmpty() + .and().field("content").is(contentSiteContributor); + + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user adds comments with Rest API and status code is 201") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void collaboratorIsAbleToAddComment() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + String contentSiteCollaborator = "This is a new comment added by user with role: " + UserRole.SiteCollaborator; + restClient.withCoreAPI().usingResource(document).addComment(contentSiteCollaborator) + .assertThat().field("content").isNotEmpty() + .and().field("content").is(contentSiteCollaborator); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Consumer user can't add comments with Rest API and status code is 403") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void consumerIsNotAbleToAddComment() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + String contentSiteConsumer = "This is a new comment added by user with role: " + UserRole.SiteConsumer; + restClient.withCoreAPI().usingResource(document).addComment(contentSiteConsumer); + restClient + .assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, + description = "Verify that invalid request returns status code 404 for nodeId that does not exist") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void addCommentUsingInvalidNodeId() throws Exception + { + comment = RandomData.getRandomName("comment1"); + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + file.setNodeRef(RandomStringUtils.randomAlphanumeric(20)); + + restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingResource(file).addComment(comment); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, file.getNodeRef())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, + description = "Verify that request using nodeId that is neither document or folder returns 405") + @Bug(id = "MNT-16904") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void addCommentUsingResourceThatIsNotFileOrFolder() throws Exception + { + comment = RandomData.getRandomName("comment1"); + LinkModel link = dataLink.usingAdmin().usingSite(siteModel).createRandomLink(); + FileModel fileWithNodeRefFromLink = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); + fileWithNodeRefFromLink = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + fileWithNodeRefFromLink.setNodeRef(link.getNodeRef()); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(fileWithNodeRefFromLink).addComment(comment); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, + description = "Verify that adding comment using empty content returns 400 status code") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void addCommentUsingEmptyContent() throws Exception + { + restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingResource(document).addComment(""); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.NULL_ARGUMENT, "comment")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, + description = "Verify adding comment with the same content as one existing comment") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void addCommentTwice() throws Exception + { + comment = RandomData.getRandomName("comment1"); + restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingResource(document).addComment(comment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingResource(document).addComment(comment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.withCoreAPI().usingResource(document).getNodeComments() + .assertThat().entriesListContains("content", comment); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, + description = "Verify comment cannot be added if user is not member of private site") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void addCommentWithNonMemberOfPrivateSite() throws Exception + { + comment = RandomData.getRandomName("comment1"); + UserModel member = dataUser.createRandomTestUser(); + SiteModel privateSite = dataSite.usingUser(adminUserModel).createPrivateRandomSite(); + FileModel file = dataContent.usingSite(privateSite).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(member) + .withCoreAPI().usingResource(file).addComment(comment); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, + description = "Verify comment cannot be added if empty network ID is provided") +// @Bug(id = "MNT-16904", description = "It fails only on environment with tenants") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void addCommentUsingEmptyNetworkId() throws Exception + { + comment = RandomData.getRandomName("comment1"); + UserModel member = dataUser.createRandomTestUser(); + member.setDomain(""); + + restClient.authenticateUser(member) + .withCoreAPI().usingResource(document).addComment(comment); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, + description = "Verify that comment cannot be added to another comment") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void addCommentToAComment() throws Exception + { + comment = RandomData.getRandomName("comment1"); + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + RestCommentModel commentEntry = restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingResource(file).addComment(comment); + file.setNodeRef(commentEntry.getId()); + + restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingResource(file).addComment(comment); + + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.CANNOT_COMMENT); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, + description = "Verify that comment cannot be added to a tag") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void addCommentToATag() throws Exception + { + comment = RandomData.getRandomName("comment1"); + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag("randomTag"); + + file.setNodeRef(tag.getId()); + + restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingResource(file).addComment(comment); + + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.CANNOT_COMMENT); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/comments/AddCommentsTests.java b/e2e-test/src/test/java/org/alfresco/rest/comments/AddCommentsTests.java new file mode 100644 index 000000000..7f28fd249 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/comments/AddCommentsTests.java @@ -0,0 +1,377 @@ +package org.alfresco.rest.comments; + +import java.util.List; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.JsonBodyGenerator; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestCommentModel; +import org.alfresco.rest.model.RestCommentModelsCollection; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestTagModel; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.data.RandomData; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FileType; +import org.alfresco.utility.model.LinkModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.apache.commons.lang3.RandomStringUtils; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +/** + * Created by Claudia Agache on 10/10/2016. + */ +public class AddCommentsTests extends RestTest +{ + private UserModel adminUserModel, networkUserModel; + private FileModel document; + private SiteModel siteModel; + private DataUser.ListUserWithRoles usersWithRoles; + private RestCommentModelsCollection comments; + private String comment1, comment2; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + networkUserModel = dataUser.createRandomTestUser(); + restClient.authenticateUser(adminUserModel); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + } + + @BeforeMethod(alwaysRun = true) + public void generateRandomComments() + { + comment1 = RandomData.getRandomName("comment1"); + comment2 = RandomData.getRandomName("comment2"); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify admin user adds multiple comments with Rest API and status code is 201") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) + public void adminIsAbleToAddComments() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingResource(document).addComments(comment1, comment2) + .assertThat().entriesListIsNotEmpty() + .and().entriesListContains("content", comment1) + .and().entriesListContains("content", comment2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user gets status code 401 on post multiple comments call") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) + public void unauthenticatedUserIsNotAbleToAddComments() throws JsonToModelConversionException, Exception + { + restClient.noAuthentication() + .withCoreAPI().usingResource(document).addComments(comment1, comment2); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Manager user adds multiple comments with Rest API and status code is 201") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void managerIsAbleToAddComments() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(document).addComments(comment1, comment2) + .assertThat().entriesListIsNotEmpty() + .and().entriesListContains("content", comment1) + .and().entriesListContains("content", comment2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Contributor user adds multiple comments with Rest API and status code is 201") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void contributorIsAbleToAddComments() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) + .withCoreAPI().usingResource(document).addComments(comment1, comment2) + .assertThat().entriesListIsNotEmpty() + .and().entriesListContains("content", comment1) + .and().entriesListContains("content", comment2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user adds multiple comments with Rest API and status code is 201") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void collaboratorIsAbleToAddComments() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingResource(document).addComments(comment1, comment2) + .assertThat().paginationExist().and().entriesListIsNotEmpty() + .and().entriesListContains("content", comment1) + .and().entriesListContains("content", comment2); + + restClient.assertStatusCodeIs(HttpStatus.CREATED); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Consumer user adds multiple comments with Rest API and status code is 201") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void consumerIsAbleToAddComments() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + .withCoreAPI().usingResource(document).addComments(comment1, comment2); + + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify User can not add comments to a not joined private site. Status code returned is 403") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void userCanNotAddCommentsToANotJoinedPrivateSite() throws Exception + { + SiteModel sitePrivateNotJoined = dataSite.createPrivateRandomSite(); + FileModel file = dataContent.usingSite(sitePrivateNotJoined).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(file).addComments(comment1, comment2); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify User can't add comments to a node with ID that does not exist and status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void userCanNotAddCommentsOnNonexistentFile() throws Exception + { + FileModel nonexistentFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); + + nonexistentFile.setNodeRef("ABC"); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(nonexistentFile).addComments(comment1,comment2); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, nonexistentFile.getNodeRef())); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify User can't add comments to a node that exists but is not a document or a folder and status code is 405") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + @Bug(id = "MNT-16904") + public void userCanNotAddCommentsOnLink() throws Exception + { + LinkModel link = dataLink.usingAdmin().usingSite(siteModel).createRandomLink(); + FileModel fileWithNodeRefFromLink = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); + fileWithNodeRefFromLink.setNodeRef(link.getNodeRef()); + + restClient.authenticateUser(adminUserModel).withCoreAPI() + .usingResource(fileWithNodeRefFromLink).addComments(comment1,comment2); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(RestErrorModel.UNABLE_TO_LOCATE); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify User can add comments with the same content as one existing comment") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void userCanAddCommentWithTheSameContentAsExistingOne() throws Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + String sameComment = comment1; + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(file).addComments(comment1, sameComment) + .assertThat().paginationExist().and().entriesListIsNotEmpty() + .and().entriesListContains("content", comment1) + .and().entriesListContains("content", sameComment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + comments = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI() + .usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListIsNotEmpty(); + List commentsList = comments.getEntries(); + commentsList.get(0).onModel().assertThat().field("content").is(comment1); + commentsList.get(1).onModel().assertThat().field("content").is(sameComment); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify add comments from node with invalid network id returns status code 401") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void addCommentsWithInvalidNetworkId() throws Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + + networkUserModel.setDomain("invalidNetwork"); + restClient.authenticateUser(networkUserModel).withCoreAPI().usingResource(file).addComments(comment1,comment2); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify add comments from node with empty network id returns status code 401") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void addCommentsWithEmptyNetworkId() throws Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + + networkUserModel.setDomain(""); + restClient.authenticateUser(networkUserModel).withCoreAPI().usingResource(file).addComments(comment1,comment2); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, + description = "Verify that comments cannot be added to another comment") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void addCommentsToAComment() throws JsonToModelConversionException, Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + RestCommentModel commentEntry = restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingResource(file).addComment(comment1); + file.setNodeRef(commentEntry.getId()); + + restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingResource(file).addComments(comment1, comment2); + + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.CANNOT_COMMENT); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, + description = "Verify that comments cannot be added to a tag") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void addCommentsToATag() throws JsonToModelConversionException, Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + RestTagModel tag = restClient.withCoreAPI().usingResource(file).addTag("randomTag"); + + file.setNodeRef(tag.getId()); + + restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingResource(file).addComments(comment1, comment2); + + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.CANNOT_COMMENT); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Using Manager user verify that you can provide a large string for one comment") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void addLongCommentsWithManagerAndCheckThatCommentIsReturned() throws Exception + { + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + String longString = RandomStringUtils.randomAlphanumeric(10000); + String longString1 = RandomStringUtils.randomAlphanumeric(90000); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(document).addComments(longString, longString1); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", longString); + comments.assertThat().entriesListContains("content", longString1); + comments.assertThat().paginationField("totalItems").is("2"); + comments.assertThat().paginationField("count").is("2"); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Using Manager user verify that you can provide a short string for one comment") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void addShortCommentsWithManagerAndCheckThatCommentIsReturned() throws Exception + { + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + String shortString = RandomStringUtils.randomAlphanumeric(2); + String shortString1 = RandomStringUtils.randomAlphanumeric(1); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(document).addComments(shortString, shortString1); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", shortString); + comments.assertThat().entriesListContains("content", shortString1); + comments.assertThat().paginationField("totalItems").is("2"); + comments.assertThat().paginationField("count").is("2"); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Using Collaborator user verify that you can provide a string with special characters for one comment") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void addCommentsWithSpecialCharsWithCollaboratorCheckCommentIsReturned() throws Exception + { + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + String specialCharsString = "!@#$%^&*()'\".,<>-_+=|\\"; + String shortString = RandomStringUtils.randomAlphanumeric(2); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingResource(document).addComments(specialCharsString, shortString); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", specialCharsString); + comments.assertThat().entriesListContains("content", shortString); + comments.assertThat().paginationField("totalItems").is("2"); + comments.assertThat().paginationField("count").is("2"); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Using Manager user verify that you can not provide an empty string for one comment") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void addEmptyStringCommentsWithManagerCheckCommentIsReturned() throws Exception + { + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + String emptyString = ""; + String spaceString = " "; + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(document).addComments(emptyString, spaceString); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(RestErrorModel.NON_NULL_COMMENT); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Using Collaborator user verify that you can provide several comments in one request") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void addSeveralCommentsWithCollaboratorCheckCommentsAreReturned() throws Exception + { + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + String charString = RandomStringUtils.randomAlphanumeric(10); + String charString1 = RandomStringUtils.randomAlphanumeric(10); + String charString2 = RandomStringUtils.randomAlphanumeric(10); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingResource(document).addComments(comment1, comment2, charString, charString1, charString2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", comment1); + comments.assertThat().paginationField("totalItems").is("5"); + comments.assertThat().paginationField("count").is("5"); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Provide invalid request body parameter and check default error model schema") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void invalidRequestBodyParameterCheckErrorModelSchema() throws Exception + { + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(adminUserModel).withCoreAPI(); + String postBody = JsonBodyGenerator.keyValueJson("content2", comment1); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, postBody, "nodes/{nodeId}/comments", document.getNodeRef()); + restClient.processModel(RestCommentModel.class, request); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + restClient.assertLastError().containsErrorKey(String.format(RestErrorModel.UNRECOGNIZED_FIELD, "content2")); + restClient.assertLastError().containsSummary(String.format(RestErrorModel.UNRECOGNIZED_FIELD, "content2")); + restClient.assertLastError().descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + restClient.assertLastError().stackTraceIs(RestErrorModel.STACKTRACE); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/comments/DeleteCommentTests.java b/e2e-test/src/test/java/org/alfresco/rest/comments/DeleteCommentTests.java new file mode 100644 index 000000000..614f257df --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/comments/DeleteCommentTests.java @@ -0,0 +1,295 @@ +package org.alfresco.rest.comments; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestCommentModel; +import org.alfresco.rest.model.RestCommentModelsCollection; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class DeleteCommentTests extends RestTest +{ + private UserModel adminUserModel, networkUserModel; + + private FileModel document; + private SiteModel siteModel; + private RestCommentModelsCollection comments; + private RestCommentModel commentModel; + private ListUserWithRoles usersWithRoles; + private String commentText = "This is a new comment"; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + networkUserModel = dataUser.createRandomTestUser(); + restClient.authenticateUser(adminUserModel); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Admin user deletes comments with Rest API and status code is 204") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) + public void adminIsAbleToDeleteComments() throws Exception + { + restClient.authenticateUser(adminUserModel); + commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment"); + restClient.withCoreAPI().usingResource(document).deleteComment(commentModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify User gets status code 401 if authentication call fails") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) +// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") + public void userIsNotAbleToDeleteCommentIfAuthenticationFails() throws Exception + { + restClient.authenticateUser(adminUserModel); + commentModel = restClient.withCoreAPI().usingResource(document).addComment("New comment addded by admin"); + UserModel nonexistentModel = new UserModel("nonexistentUser", "nonexistentPassword"); + restClient.authenticateUser(nonexistentModel); + restClient.withCoreAPI().usingResource(document).deleteComment(commentModel); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Manager user deletes own comments and status code is 204") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void managerIsAbleToDeleteComments() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + commentModel = restClient.withCoreAPI().usingResource(document).addComment("New comment added by Manager"); + restClient.withCoreAPI().usingResource(document).deleteComment(commentModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user deletes own comments and status code is 204") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void collaboratorIsAbleToDeleteComments() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + commentModel = restClient.withCoreAPI().usingResource(document).addComment("New comment added by Collaborator"); + restClient.withCoreAPI().usingResource(document).deleteComment(commentModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Contributor user deletes own comments and status code is 204") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void contributorIsAbleToDeleteComments() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + commentModel = restClient.withCoreAPI().usingResource(document).addComment("New comment added by Contributor"); + restClient.withCoreAPI().usingResource(document).deleteComment(commentModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Consumer user can't delete comments created by admin user and status code is 403") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void consumerIsNotAbleToDeleteComments() throws Exception + { + restClient.authenticateUser(adminUserModel); + commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment"); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + restClient.withCoreAPI().usingResource(document).deleteComment(commentModel); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Admin user can't delete comments with inexistent ID and status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void userIsNotAbleToDeleteInexistentComment() throws Exception + { + restClient.authenticateUser(adminUserModel); + commentModel = new RestCommentModel(); + commentModel.setId("inexistent"); + restClient.withCoreAPI().usingResource(document).deleteComment(commentModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Admin user can't delete comments with inexistend NodeId and status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void userIsNotAbleToDeleteCommentWithInexistentNodeId() throws Exception + { + restClient.authenticateUser(adminUserModel); + commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment"); + FileModel inexistentDocument = new FileModel(); + inexistentDocument.setNodeRef("inexistent"); + restClient.withCoreAPI().usingResource(inexistentDocument).deleteComment(commentModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Admin user can't delete deleted comments and status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void userIsNotAbleToDeleteDeletedComment() throws Exception + { + restClient.authenticateUser(adminUserModel); + commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment"); + restClient.withCoreAPI().usingResource(document).deleteComment(commentModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withCoreAPI().usingResource(document).deleteComment(commentModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS }, + executionType = ExecutionType.REGRESSION, description = "Verify Manager user deletes comment created by admin" + + " and status code is 204. Check with getComments for validation") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void managerIsAbleToDeleteCommentCreatedByOthers() throws Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + + commentModel = restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingResource(file).addComment(commentText); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(file).deleteComment(commentModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListDoesNotContain("content", commentText); + comments.getPagination().assertThat().field("totalItems").is("0").and().field("count").is("0"); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS }, + executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user can delete comment created by self" + + " and status code is 204. Check with getComments for validation") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void collaboratorIsAbleToDeleteCommentCreatedBySelf() throws Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + + commentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingResource(file).addComment(commentText); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.withCoreAPI().usingResource(file).deleteComment(commentModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListDoesNotContain("content", commentText); + comments.getPagination().assertThat().field("totalItems").is("0").and().field("count").is("0"); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS }, + executionType = ExecutionType.REGRESSION, description = "Verify Contributor user deletes comment created by self" + + " and status code is 204. Check with getComments for validation") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + @Bug(id = "ACE-4614") + public void contributorIsAbleToDeleteCommentCreatedBySelf() throws Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + + commentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) + .withCoreAPI().usingResource(file).addComment(commentText); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.withCoreAPI().usingResource(file).deleteComment(commentModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListDoesNotContain("content", commentText); + comments.getPagination().assertThat().field("totalItems").is("0").and().field("count").is("0"); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS }, + executionType = ExecutionType.REGRESSION, description = "Verify Consumer user cannot delete comment created by admin" + + " and status code is 403. Check with getComments for validation and check default error model schema.") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void consumerIsNotAbleToDeleteCommentCreatedByOthersDefaultErrorModelSchema() throws Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + + commentModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(commentText); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + .withCoreAPI().usingResource(file).deleteComment(commentModel); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .statusCodeIs(HttpStatus.FORBIDDEN) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE) + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY); + + comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", commentText); + comments.getPagination().assertThat().field("totalItems").is("1").and().field("count").is("1"); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS }, + executionType = ExecutionType.REGRESSION, description = "Verify Manager can delete comment with version number") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void usingManagerDeleteCommentWithVersionNumber() throws Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + dataContent.usingAdmin().usingResource(file).updateContent("updated content to increase version number"); + + commentModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(commentText); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(file).deleteComment(commentModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS }, + executionType = ExecutionType.REGRESSION, description = "Verify Manager user cannot delete comment with invalid node " + + "and status code is 404. Check with getComments for validation") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void usingManagerDeleteCommentWithInvalidNode() throws Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + + commentModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(commentText); + file.setNodeRef("invalid"); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(file).deleteComment(commentModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(file.getNodeRef() + " was not found"); + + comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(file.getNodeRef() + " was not found"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS}, executionType = ExecutionType.REGRESSION, + description = "Verify deleteComment from node with invalid network id returns status code 401") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void deleteCommentWithInvalidNetworkId() throws Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + + commentModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(commentText); + networkUserModel.setDomain("invalidNetwork"); + restClient.authenticateUser(networkUserModel).withCoreAPI().usingResource(file).deleteComment(commentModel); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS }, + executionType = ExecutionType.REGRESSION, description = "Verify deleteComment from node with empty network id returns status code 401") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void deleteCommentWithEmptyNetworkId() throws Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + + commentModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(commentText); + networkUserModel.setDomain(""); + restClient.authenticateUser(networkUserModel).withCoreAPI().usingResource(file).deleteComment(commentModel); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/comments/GetCommentsTests.java b/e2e-test/src/test/java/org/alfresco/rest/comments/GetCommentsTests.java new file mode 100644 index 000000000..6c8f07af2 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/comments/GetCommentsTests.java @@ -0,0 +1,422 @@ +package org.alfresco.rest.comments; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestCommentModelsCollection; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FileType; +import org.alfresco.utility.model.LinkModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class GetCommentsTests extends RestTest +{ + private FileModel file, document, document1; + private SiteModel siteModel, privateSiteModel; + private UserModel adminUserModel, userModel, networkUserModel; + private ListUserWithRoles usersWithRoles; + private String comment = "This is a new comment"; + private String comment2 = "This is a 2nd comment"; + private String comment3 = "This is a 3rd comment"; + private RestCommentModelsCollection comments; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + networkUserModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + privateSiteModel = dataSite.usingUser(adminUserModel).createPrivateRandomSite(); + document = dataContent.usingSite(privateSiteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + document1 = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(adminUserModel).withCoreAPI() + .usingResource(document1).addComment(comment); + restClient.withCoreAPI().usingResource(document).addComment(comment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.withCoreAPI().usingResource(document).addComment(comment2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.withCoreAPI().usingResource(document).addComment(comment3); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.SANITY, + description= "Verify Admin user gets comments with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) + public void adminIsAbleToRetrieveComments() throws Exception + { + comments = restClient.authenticateUser(adminUserModel).withCoreAPI() + .usingResource(document1).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", comment); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.SANITY, + description= "Verify Manager user gets status code 401 if authentication call fails") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) +// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") + public void managerIsNotAbleToRetrieveCommentIfAuthenticationFails() throws Exception + { + UserModel nonexistentModel = new UserModel("nonexistentUser", "nonexistentPassword"); + restClient.authenticateUser(nonexistentModel).withCoreAPI() + .usingResource(document1).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify Manager user gets comments created by admin user with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void managerIsAbleToRetrieveComments() throws Exception + { + comments = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI() + .usingResource(document1).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", comment); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify Contributor user gets comments created by admin user with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void contributorIsAbleToRetrieveComments() throws Exception + { + comments = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI() + .usingResource(document1).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", comment); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify Collaborator user gets comments created by admin user with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void collaboratorIsAbleToRetrieveComments() throws Exception + { + comments = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI() + .usingResource(document1).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", comment); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify Consumer user gets comments created by admin user with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void consumerIsAbleToRetrieveComments() throws Exception + { + comments = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI() + .usingResource(document1).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", comment); + } + + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify Manager user gets comments created by another user and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void managerIsAbleToRetrieveCommentsCreatedByAnotherUser() throws Exception + { + userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); + String contentManager = "This is a new comment added by " + userModel.getUsername(); + restClient.authenticateUser(userModel).withCoreAPI() + .usingResource(document1).addComment(contentManager); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + comments = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI() + .usingResource(document1).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", contentManager) + .and().entriesListContains("content", comment); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify admin user gets comments created by another user and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void adminIsAbleToRetrieveCommentsCreatedByAnotherUser() throws Exception + { + userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); + String contentCollaborator = "This is a new comment added by " + userModel.getUsername(); + restClient.authenticateUser(userModel).withCoreAPI() + .usingResource(document1).addComment(contentCollaborator); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + comments = restClient.authenticateUser(adminUserModel).withCoreAPI() + .usingResource(document1).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", contentCollaborator) + .and().entriesListContains("content", comment); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify request returns status 403 if the user does not have permission read comments on the node") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void uninvitedUserCanNotGetCommentsFromPrivateSite() throws Exception + { + restClient.authenticateUser(userModel).withCoreAPI() + .usingResource(document).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify user gets comments without the first 2 and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void skipFirst2Comments() throws Exception + { + comments = restClient.authenticateUser(adminUserModel).withParams("skipCount=2") + .withCoreAPI().usingResource(document).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", comment) + .and().paginationField("count").is("1"); + comments.assertThat().paginationField("skipCount").is("2"); + comments.assertThat().paginationField("totalItems").is("3"); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify invalid request returns status code 400 for invalid maxItems or skipCount") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void checkStatusCodeForInvalidMaxItems() throws Exception + { + restClient.authenticateUser(adminUserModel).withParams("maxItems=0") + .withCoreAPI().usingResource(document).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary("Only positive values supported for maxItems"); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify User can't get comments for node with ID that does not exist and status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void userCanNotGetCommentsOnNonExistentFile() throws Exception + { + FileModel nonexistentFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); + nonexistentFile.setNodeRef("ABC"); + restClient.authenticateUser(adminUserModel).withCoreAPI() + .usingResource(nonexistentFile).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, nonexistentFile.getNodeRef())); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify User can't get comments for node that exists but is not a document or a folder and status code is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void userCanNotGetCommentsOnLink() throws Exception + { + LinkModel link = dataLink.usingAdmin().usingSite(siteModel).createRandomLink(); + FileModel fileWithNodeRefFromLink = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); + fileWithNodeRefFromLink.setNodeRef(link.getNodeRef().replace("workspace://SpacesStore/", "workspace%3A%2F%2FSpacesStore%2F")); + restClient.authenticateUser(adminUserModel).withCoreAPI() + .usingResource(fileWithNodeRefFromLink).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, fileWithNodeRefFromLink.getNodeRef())) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify get comments from node with invalid network id returns status code 401") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void getCommentsWithInvalidNetwork() throws Exception + { + networkUserModel.setDomain("invalidNetwork"); + restClient.authenticateUser(networkUserModel).withCoreAPI().usingResource(document).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify get comments from node with empty network id returns status code 401") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void getCommentsWithEmptyNetwork() throws Exception + { + networkUserModel.setDomain(""); + restClient.authenticateUser(networkUserModel).withCoreAPI().usingResource(document).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify that if manager adds one comment, it will be returned in getComments response") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void addCommentWithManagerAndCheckThatCommentIsReturned() throws Exception + { + file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(file).addComment(comment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", comment) + .getPagination().assertThat().field("totalItems").is("1") + .assertThat().field("count").is("1"); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify that if collaborator adds one comment, it will be returned in getComments response") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void addCommentWithCollaboratorAndCheckThatCommentIsReturned() throws Exception + { + file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingResource(file).addComment(comment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", comment) + .getPagination().assertThat().field("totalItems").is("1") + .assertThat().field("count").is("1"); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify that if contributor adds one comment, it will be returned in getComments response") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + @Bug(id = "ACE-4614") + public void addCommentWithContributorAndCheckThatCommentIsReturned() throws Exception + { + file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) + .withCoreAPI().usingResource(file).addComment(comment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", comment) + .getPagination().assertThat().field("totalItems").is("1") + .assertThat().field("count").is("1"); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify that consumer cannot add a comment and no comments will be returned in getComments response") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void addCommentWithConsumerAndCheckThatCommentIsNotReturned() throws Exception + { + file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + .withCoreAPI().usingResource(file).addComment(comment); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + + comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().paginationField("totalItems").is("0"); + comments.assertThat().paginationField("count").is("0"); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Add one comment with Manager and check that returned person is the right one") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void addCommentWithManagerCheckReturnedPersonIsTheRightOne() throws Exception + { + file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + UserModel user1 = dataUser.createRandomTestUser(); + dataUser.addUserToSite(user1, siteModel, UserRole.SiteManager); + + restClient.authenticateUser(user1).withCoreAPI().usingResource(file).addComment(comment); + comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); + comments.getOneRandomEntry().onModel().getCreatedBy().assertThat().field("firstName").is(user1.getUsername() + " FirstName") + .assertThat().field("lastName").is("LN-" + user1.getUsername()); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Add one comment with Collaborator and check that returned company details are correct") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void addCommentWithCollaboratorCheckReturnedCompanyDetails() throws Exception + { + file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(file).addComment(comment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); + comments.getOneRandomEntry().onModel().getCreatedBy().getCompany() + .assertThat().field("organization").isNull() + .assertThat().field("address1").isNull() + .assertThat().field("address2").isNull() + .assertThat().field("address3").isNull() + .assertThat().field("postcode").isNull() + .assertThat().field("telephone").isNull() + .assertThat().field("fax").isNull() + .assertThat().field("email").isNull(); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Add 2 comments with Manager and Collaborator users and verify valid request using skipCount. Check that param is applied") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void addTwoCommentsWithManagerCollaboratorVerifySkipCountParamIsApplied() throws Exception + { + file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(file).addComment(comment); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(file).addComment(comment2); + + comments = restClient.authenticateUser(adminUserModel).withParams("skipCount=1") + .withCoreAPI().usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", comment) + .and().paginationField("count").is("1"); + comments.assertThat().paginationField("skipCount").is("1"); + comments.assertThat().paginationField("totalItems").is("2"); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Add 2 comments with Admin and Collaborator users and verify valid request using maxItems. Check that param is applied") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void addTwoCommentsWithAdminCollaboratorVerifyMaxItemsParamIsApplied() throws Exception + { + file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(comment); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(file).addComment(comment2); + + comments = restClient.authenticateUser(adminUserModel).withParams("maxItems=1") + .withCoreAPI().usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", comment2) + .and().paginationField("count").is("1"); + comments.assertThat().paginationField("totalItems").is("2"); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Add 2 comments with Manager and Admin users and verify valid request using properties. Check that param is applied") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void addTwoCommentsWithAdminManagerVerifyPropertiesParamIsApplied() throws Exception + { + file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(comment); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(file).addComment(comment2); + + comments = restClient.authenticateUser(adminUserModel).withParams("properties=createdBy,modifiedBy") + .withCoreAPI().usingResource(file).getNodeComments(); + comments.assertThat().entriesListIsNotEmpty() + .and().paginationField("count").is("2"); + comments.assertThat().paginationField("totalItems").is("2"); + + comments.getEntries().get(0).onModel().getCreatedBy() + .assertThat().field("firstName").is(usersWithRoles.getOneUserWithRole(UserRole.SiteManager).getUsername() + " FirstName") + .assertThat().field("lastName").is("LN-" + usersWithRoles.getOneUserWithRole(UserRole.SiteManager).getUsername()); + + comments.getEntries().get(1).onModel().getCreatedBy() + .assertThat().field("firstName").is("Administrator") + .assertThat().field("id").is("admin"); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Check default error model schema") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void addTwoCommentsWithManagerCheckDefaultErrorModelSchema() throws Exception + { + file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(file).addComments(comment, comment2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).usingParams("maxItems=0").getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); + restClient.assertLastError().containsErrorKey(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); + restClient.assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); + restClient.assertLastError().descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + restClient.assertLastError().stackTraceIs(RestErrorModel.STACKTRACE); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/comments/UpdateCommentTests.java b/e2e-test/src/test/java/org/alfresco/rest/comments/UpdateCommentTests.java new file mode 100644 index 000000000..aad251918 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/comments/UpdateCommentTests.java @@ -0,0 +1,461 @@ +package org.alfresco.rest.comments; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestCommentModel; +import org.alfresco.rest.model.RestCommentModelsCollection; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FileType; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.LinkModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.apache.commons.lang3.RandomStringUtils; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class UpdateCommentTests extends RestTest +{ + private UserModel adminUserModel, networkUserModel; + private FileModel document; + private SiteModel siteModel; + private RestCommentModel commentModel, returnedCommentModel; + private RestCommentModelsCollection comments;; + private ListUserWithRoles usersWithRoles; + private String firstComment = "This is a new comment"; + private String updatedComment = "This is the updated comment"; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + restClient.authenticateUser(adminUserModel); + networkUserModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Admin user updates comments and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) + public void adminIsAbleToUpdateHisComment() throws Exception + { + restClient.authenticateUser(adminUserModel); + commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by admin"); + String updatedContent = "This is the updated comment with admin user"; + restClient.withCoreAPI().usingResource(document).updateComment(commentModel, updatedContent) + .assertThat().field("content").isNotEmpty() + .and().field("content").is(updatedContent); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user gets status code 401 on update comment call") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) +// @Bug(id = "MNT-16904", description = "fails only on environment with tenants") + public void unauthenticatedUserIsNotAbleToUpdateComment() throws Exception + { + restClient.authenticateUser(adminUserModel); + commentModel = restClient.withCoreAPI().usingResource(document).addComment("To be updated by unauthenticated user."); + UserModel incorrectUserModel = new UserModel("userName", "password"); + restClient.authenticateUser(incorrectUserModel) + .withCoreAPI().usingResource(document).updateComment(commentModel, "try to update"); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify entry content in response") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) + public void checkEntryContentInResponse() throws Exception + { + restClient.authenticateUser(adminUserModel); + commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by admin"); + commentModel = restClient.withCoreAPI().usingResource(document).updateComment(commentModel, "This is the updated comment with admin user"); + restClient.assertStatusCodeIs(HttpStatus.OK); + commentModel.assertThat().field("content").is("This is the updated comment with admin user"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Manager user updates comments created by admin user and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void managerIsAbleToUpdateHisComment() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by manager"); + restClient.withCoreAPI().usingResource(document).updateComment(commentModel, "This is the updated comment with Manager user") + .and().field("content").is("This is the updated comment with Manager user") + .and().field("canEdit").is(true) + .and().field("canDelete").is(true); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Contributor user can update his own comment and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void contributorIsAbleToUpdateHisComment() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by contributor"); + String updatedContent = "This is the updated comment with Contributor user"; + restClient.withCoreAPI().usingResource(document).updateComment(commentModel, updatedContent); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Consumer user can not update comments created by admin user and status code is 403") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void consumerIsNotAbleToUpdateComment() throws Exception + { + restClient.authenticateUser(adminUserModel); + commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by admin"); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + restClient.withCoreAPI().usingResource(document).updateComment(commentModel, "This is the updated comment with Consumer user"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user can update his own comment and status code is 200") +// @Bug(id="REPO-1011") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void collaboratorIsAbleToUpdateHisComment() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by collaborator"); + restClient.withCoreAPI().usingResource(document).updateComment(commentModel, "This is the updated comment with Collaborator user"); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user can not update comments of another user and status code is 200") +// @Bug(id="MNT-2502",description="seems it's one old issue: also logged as MNT-2502, MNT-2346") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void collaboratorIsNotAbleToUpdateCommentOfAnotherUser() throws Exception + { + restClient.authenticateUser(adminUserModel); + commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by admin"); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingResource(document).updateComment(commentModel, "This is the updated comment with Collaborator user"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify update comment with inexistent nodeId returns status code 404") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void canNotUpdateCommentIfNodeIdIsNotSet() throws Exception + { + restClient.authenticateUser(adminUserModel); + + FolderModel content = FolderModel.getRandomFolderModel(); + content.setNodeRef("node ref that does not exist"); + commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment"); + restClient.withCoreAPI().usingResource(content).updateComment(commentModel, "This is the updated comment."); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary("node ref that does not exist was not found"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify if commentId is not set the status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void canNotUpdateCommentIfCommentIdIsNotSet() throws Exception + { + restClient.authenticateUser(adminUserModel); + + RestCommentModel comment = new RestCommentModel(); + String id = "comment id that does not exist"; + comment.setId(id); + restClient.withCoreAPI().usingResource(document).updateComment(comment, "This is the updated comment."); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, id)); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify can not update comment if NodeId is neither document or folder and returns status code 405") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void canNotUpdateCommentIfNodeIdIsNeitherDocumentOrFolder() throws Exception + { + FileModel content = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); + content = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(adminUserModel); + commentModel = restClient.withCoreAPI().usingResource(content).addComment("This is a new comment"); + + LinkModel link = dataLink.usingAdmin().usingSite(siteModel).createRandomLink(); + content.setNodeRef(link.getNodeRef().replace("workspace://SpacesStore/", "workspace%3A%2F%2FSpacesStore%2F")); + + restClient.withCoreAPI().usingResource(content).updateComment(commentModel, "This is the updated comment."); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, content.getNodeRef())) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Admin user is not able to update with empty comment body and status code is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void adminIsNotAbleToUpdateWithEmptyCommentBody() throws Exception + { + restClient.authenticateUser(adminUserModel); + commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by admin"); + restClient.withCoreAPI().usingResource(document).updateComment(commentModel, ""); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary("An invalid argument was received"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify updated comment by Manager is listed when calling getComments and status code is 200") +// @Bug(id="REPO-1011") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void updatedCommentByManagerIsListed() throws Exception + { + commentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingResource(document).addComment("This is a new comment added by collaborator"); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI() + .usingResource(document).updateComment(commentModel, "This is the updated comment with Manager user"); + comments = restClient.withCoreAPI().usingResource(document).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", "This is the updated comment with Manager user"); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify Manager user can update a comment with a large string") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void managerIsAbleToUpdateACommentWithALargeString() throws Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + String longString = RandomStringUtils.randomAlphanumeric(10000); + + commentModel = restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingResource(file).addComment(firstComment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedCommentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(file).updateComment(commentModel, longString); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCommentModel.assertThat().field("content").is(longString); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify Manager user can update a comment with a short string") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void managerIsAbleToUpdateACommentWithAShortString() throws Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + String shortString = RandomStringUtils.randomAlphanumeric(2); + + commentModel = restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingResource(file).addComment(firstComment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedCommentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(file).updateComment(commentModel, shortString); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCommentModel.assertThat().field("content").is(shortString); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify Collaborator user can update a comment with special characters") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void collaboratorIsAbleToUpdateACommentThatContainsSpecialChars() throws Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + String specialChars = "!@#$%^&*()'\".,<>-_+=|\\"; + + commentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingResource(file).addComment(firstComment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedCommentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingResource(file).updateComment(commentModel, specialChars); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCommentModel.assertThat().field("content").is(specialChars); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Check that you cannot update comment with Consumer then call getComments and check new comment is not listed") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void cannotUpdateCommentWithConsumerCallGetComments() throws Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + + commentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingResource(file).addComment(firstComment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingResource(file).updateComment(commentModel, updatedComment); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + + comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", firstComment) + .and().entriesListDoesNotContain("content", updatedComment) + .and().paginationField("totalItems").is("1"); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Update comment with Contributor then call getComments and check new comment is listed") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + @Bug(id = "ACE-4614") + public void updateCommentWithContributorCallGetComments() throws Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + + commentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) + .withCoreAPI().usingResource(file).addComment(firstComment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingResource(file).updateComment(commentModel, updatedComment); + restClient.assertStatusCodeIs(HttpStatus.OK); + + comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", updatedComment) + .and().entriesListDoesNotContain("content", firstComment) + .and().paginationField("totalItems").is("1"); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Update comment with Collaborator then call getComments and check new comment is listed") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void updateCommentWithCollaboratorCallGetComments() throws Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + + commentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingResource(file).addComment(firstComment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(file).updateComment(commentModel, updatedComment); + restClient.assertStatusCodeIs(HttpStatus.OK); + + comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + comments.assertThat().entriesListContains("content", updatedComment) + .and().entriesListDoesNotContain("content", firstComment) + .and().paginationField("totalItems").is("1"); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Update comment with Manager then check modified by information in response") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void updateCommentWithManagerCheckModifiedBy() throws Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + UserModel manager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); + + commentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingResource(file).addComment(firstComment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedCommentModel = restClient.authenticateUser(manager).withCoreAPI().usingResource(file).updateComment(commentModel, updatedComment); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCommentModel.assertThat().field("modifiedBy.id").is(manager.getUsername()) + .and().field("content").is(updatedComment); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Delete comment with Admin then try to update it") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void deleteCommentThenTryToUpdateIt() throws Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + + commentModel = restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingResource(file).addComment(firstComment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.withCoreAPI().usingResource(file).deleteComment(commentModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingResource(file).updateComment(commentModel, updatedComment); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify Manager user can update a comment with multi byte content") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void managerIsAbleToUpdateACommentWithMultiByteContent() throws Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + String multiByte = "\ufeff\u6768\u6728\u91d1"; + + commentModel = restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingResource(file).addComment(firstComment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedCommentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(file).updateComment(commentModel, multiByte); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCommentModel.assertThat().field("content").is(multiByte); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify Admin user can update a comment with properties parameter") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void adminIsAbleToUpdateACommentWithPropertiesParameter() throws Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + + commentModel = restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingResource(file).addComment(firstComment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + UserModel manager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); + + returnedCommentModel = restClient.authenticateUser(manager) + .withParams("properties=createdBy,modifiedBy,canEdit,canDelete").withCoreAPI().usingResource(file).updateComment(commentModel, updatedComment); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCommentModel.assertThat().field("createdBy.id").is(adminUserModel.getUsername()) + .assertThat().field("modifiedBy.id").is(manager.getUsername()) + .assertThat().fieldsCount().is(4); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, + description = "Update comment with invalid node") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void updateCommentUsingInvalidNodeId() throws Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + + commentModel = restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingResource(file).addComment(firstComment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + file.setNodeRef(RandomStringUtils.randomAlphanumeric(20)); + restClient.withCoreAPI().usingResource(file).updateComment(commentModel, updatedComment); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, file.getNodeRef())); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, + description= "Verify update comment from node with invalid network id returns status code 401") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void updateCommentWithInvalidNetworkId() throws Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + + commentModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(firstComment); + networkUserModel.setDomain("invalidNetwork"); + restClient.authenticateUser(networkUserModel).withCoreAPI().usingResource(file).updateComment(commentModel, updatedComment); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify User can not update comment to a not joined private site. Status code returned is 403") + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) + public void userCanNotUpdateCommentToANotJoinedPrivateSiteDefaultErrorModelSchema() throws Exception + { + UserModel newUser = dataUser.createRandomTestUser(); + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + + commentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(file).addComment(firstComment); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(newUser).withCoreAPI().usingResource(file).updateComment(commentModel, updatedComment); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE) + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/demo/RestDemoTests.java b/e2e-test/src/test/java/org/alfresco/rest/demo/RestDemoTests.java new file mode 100644 index 000000000..80ba29199 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/demo/RestDemoTests.java @@ -0,0 +1,104 @@ +package org.alfresco.rest.demo; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.dataprep.SiteService.Visibility; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.exception.DataPreparationException; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class RestDemoTests extends RestTest +{ + private UserModel userModel; + private SiteModel siteModel; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws DataPreparationException + { + userModel = dataUser.getAdminUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + restClient.authenticateUser(userModel); + } + + /** + * Data preparation – create site with custom details
      + * Perform GET sites call using admin user
      + * Check that created site is included in response
      + * Perform GET site call, validate that site title, description and visibility are correct
      + * + * @throws JsonToModelConversionException + * @throws Exception + */ + @Test(groups = { "demo" }) + public void adminRetrievesCorrectSiteDetails() throws JsonToModelConversionException, Exception + { + restClient.withCoreAPI().getSites().assertThat() + .entriesListContains("id", siteModel.getId()); + + restClient.withCoreAPI().usingSite(siteModel).getSite() + .assertThat().field("id").isNotNull() + .assertThat().field("description").is(siteModel.getDescription()) + .assertThat().field("title").is(siteModel.getTitle()) + .assertThat().field("visibility").is(Visibility.PUBLIC); + } + + /** + * Data preparation – create site and document on server
      + * POST one comment to file using admin user
      + * Perform GET comments, check the new one is listed
      + * Update existing comment using PUT call, check that comment content is updated
      + * @throws Exception + */ + @Test(groups = { "demo" }) + public void adminCanPostAndUpdateComments() throws Exception + { + FileModel fileModel = dataContent.usingUser(userModel) + .usingResource(FolderModel.getSharedFolderModel()) + .createContent(DocumentType.TEXT_PLAIN); + // add new comment + restClient.withCoreAPI().usingResource(fileModel).addComment("This is a new comment"); + restClient.withCoreAPI().usingResource(fileModel).getNodeComments() + .assertThat().entriesListIsNotEmpty().and() + .entriesListContains("content", "This is a new comment"); + } + + /** + * Data preparation – create site and a new user
      + * As admin, add user as Consumer to site as a new site member using POST call
      + * Update site member role to Manager using PUT call
      + * Delete site member using DELETE call
      + * + * @throws DataPreparationException + * @throws JsonToModelConversionException + */ + @Test(groups = { "demo" }) + public void adminCanAddAndUpdateSiteMemberDetails() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteConsumer); + + // add user as Consumer to site + restClient.withCoreAPI().usingSite(siteModel).addPerson(testUser); + restClient.withCoreAPI().usingSite(siteModel).getSiteMembers().assertThat().entriesListContains("id", testUser.getUsername()) + .when().getSiteMember(testUser.getUsername()) + .assertSiteMemberHasRole(UserRole.SiteConsumer); + + // update site member to Manager + testUser.setUserRole(UserRole.SiteCollaborator); + restClient.withCoreAPI().usingSite(siteModel).updateSiteMember(testUser); + restClient.withCoreAPI().usingSite(siteModel).getSiteMembers().and() + .entriesListContains("id", testUser.getUsername()) + .when().getSiteMember(testUser.getUsername()) + .assertSiteMemberHasRole(UserRole.SiteCollaborator); + + restClient.withCoreAPI().usingSite(siteModel).deleteSiteMember(testUser); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } +} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/rest/demo/SampleCommentsTests.java b/e2e-test/src/test/java/org/alfresco/rest/demo/SampleCommentsTests.java new file mode 100644 index 000000000..1151d4c2e --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/demo/SampleCommentsTests.java @@ -0,0 +1,56 @@ +package org.alfresco.rest.demo; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestCommentModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + + +public class SampleCommentsTests extends RestTest +{ + private UserModel userModel; + private FolderModel folderModel; + private SiteModel siteModel; + private FileModel document; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + userModel = dataUser.getAdminUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + restClient.authenticateUser(userModel); + document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + } + + @Test(groups = { "demo" }) + public void admiShouldAddComment() throws JsonToModelConversionException, Exception + { + restClient.withCoreAPI().usingResource(document).addComment("This is a new comment"); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + } + + @Test(groups = { "demo" }) + public void admiShouldRetrieveComments() throws Exception + { + restClient.withCoreAPI().usingResource(document).getNodeComments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { "demo" }) + public void adminShouldUpdateComment() throws JsonToModelConversionException, Exception + { + RestCommentModel commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment"); + + restClient.withCoreAPI().usingResource(document).updateComment(commentModel, "This is the updated comment with Collaborator user") + .assertThat().field("content").is("This is the updated comment with Collaborator user"); + } + +} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/rest/demo/SamplePeopleTests.java b/e2e-test/src/test/java/org/alfresco/rest/demo/SamplePeopleTests.java new file mode 100644 index 000000000..6c0a2ff18 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/demo/SamplePeopleTests.java @@ -0,0 +1,32 @@ +package org.alfresco.rest.demo; + +import org.alfresco.rest.RestTest; +import org.alfresco.utility.exception.DataPreparationException; +import org.alfresco.utility.model.UserModel; +import org.apache.commons.lang3.RandomStringUtils; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + + +public class SamplePeopleTests extends RestTest +{ + private UserModel userModel; + private UserModel adminUser; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws DataPreparationException + { + userModel = dataUser.createUser(RandomStringUtils.randomAlphanumeric(20)); + adminUser = dataUser.getAdminUser(); + restClient.authenticateUser(adminUser); + } + + @Test(groups = { "demo" }) + public void adminShouldRetrievePerson() throws Exception + { + restClient.withCoreAPI().usingUser(userModel).getPerson().assertThat().field("id").isNotEmpty(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + +} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/rest/demo/SampleSitesTests.java b/e2e-test/src/test/java/org/alfresco/rest/demo/SampleSitesTests.java new file mode 100644 index 000000000..f5c59e8a8 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/demo/SampleSitesTests.java @@ -0,0 +1,79 @@ +package org.alfresco.rest.demo; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.exception.DataPreparationException; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + + +public class SampleSitesTests extends RestTest +{ + private UserModel userModel; + private SiteModel siteModel; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws DataPreparationException + { + userModel = dataUser.getAdminUser(); + restClient.authenticateUser(userModel); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + } + + @Test(groups = { "demo" }) + public void adminShouldGetSiteDetails() throws JsonToModelConversionException, Exception + { + restClient.withCoreAPI().usingSite(siteModel).getSite() + .assertThat().field("id").isNotNull(); + } + + @Test(groups = { "demo" }) + public void adminShouldGetSites() throws JsonToModelConversionException, Exception + { + restClient.withCoreAPI().usingSite(siteModel).getSite(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { "demo" }) + public void adminShouldAccessSites() throws JsonToModelConversionException, Exception + { + restClient.withCoreAPI().getSites().assertThat().entriesListIsNotEmpty(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { "demo" }) + public void adminShouldAccessResponsePagination() throws JsonToModelConversionException, Exception + { + restClient.withCoreAPI().getSites().assertThat().paginationExist(); + } + + @Test(groups = { "demo" }) + public void adminShouldAddNewSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteConsumer); + restClient.withCoreAPI().usingSite(siteModel).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + } + + @Test(groups = { "demo" }) + public void adminShouldGetSiteFromSitesList() throws JsonToModelConversionException, Exception + { + restClient.withCoreAPI().getSites().assertThat().entriesListContains("id", siteModel.getId()); + } + + @Test(groups = { "demo" }) + public void adminShouldAccessSiteDetails() throws JsonToModelConversionException, Exception + { + restClient.withCoreAPI().usingSite(siteModel).getSite() + .assertThat().field("id").isNotNull() + .and().field("description").is(siteModel.getDescription()) + .and().field("title").is(siteModel.getTitle()) + .and().field("visibility").is(siteModel.getVisibility()); + } + +} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/rest/demo/workshop/RestApiDemoTests.java b/e2e-test/src/test/java/org/alfresco/rest/demo/workshop/RestApiDemoTests.java new file mode 100644 index 000000000..7492d8023 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/demo/workshop/RestApiDemoTests.java @@ -0,0 +1,52 @@ +package org.alfresco.rest.demo.workshop; + +import org.alfresco.rest.RestTest; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; +import org.testng.annotations.Test; + +public class RestApiDemoTests extends RestTest +{ + /* + * Test steps: + * 1. create a user + * 2. create a site + * 3. create a second user + * 4. add the second user to site with a user role + * 5. call rest api call " GET sites/{siteId}/members" with first user authenticated + * Expected: the response contains the user added as a member to the site + */ + @Test(groups = { "demo" }) + public void verifyGetSiteMembersRestApiCall() throws Exception + { + UserModel user = dataUser.createRandomTestUser(); + SiteModel site = dataSite.usingUser(user).createPublicRandomSite(); + UserModel member = dataUser.createRandomTestUser(); + dataUser.usingUser(user).addUserToSite(member, site, UserRole.SiteCollaborator); + + //add here code for step 5 + + } + + /* + * Test steps: + * 1. create a user + * 2. create a site + * 3. create a second user + * 4. add the second user to site with a user role + * 5. call rest api call " GET sites/{siteId}/members/{personId}" with first user authenticated + * Expected: the response contains the user added as a member to the site + */ + + @Test(groups = { "demo" }) + public void verifyGetASiteMemberApiCall() throws Exception + { + UserModel user = dataUser.createRandomTestUser(); + SiteModel site = dataSite.usingUser(user).createPublicRandomSite(); + UserModel member = dataUser.createRandomTestUser(); + dataUser.usingUser(user).addUserToSite(member, site, UserRole.SiteCollaborator); + + //add here code for step 5 + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/demo/workshop/RestApiWorkshopTests.java b/e2e-test/src/test/java/org/alfresco/rest/demo/workshop/RestApiWorkshopTests.java new file mode 100644 index 000000000..88484bf66 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/demo/workshop/RestApiWorkshopTests.java @@ -0,0 +1,38 @@ +package org.alfresco.rest.demo.workshop; + +import org.alfresco.rest.RestTest; +import org.testng.annotations.Test; + +/** + * + * Demo workshop for RestAPI test + * + */ +public class RestApiWorkshopTests extends RestTest +{ + @Test(groups = { "demo" }) + public void verifyGetSitesRestApiCall() throws Exception + { + // creating a random user in repository + + // create a new random site using your UserModel from above + + // using "siteApi", call get "/sites" Rest API and verify created site is present + + // verify status is OK + + } + + @Test(groups = { "demo" }) + public void verifyGetASiteRestApiCall() throws Exception + { + // creating a random user in repository + + // create a new random site using your UserModel from above + + // using "siteApi", call get "/sites/{siteId}" Rest API + // using "siteApi", verify created site is present + + // verify status is OK + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/discovery/DiscoveryTests.java b/e2e-test/src/test/java/org/alfresco/rest/discovery/DiscoveryTests.java new file mode 100644 index 000000000..f4011a4c5 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/discovery/DiscoveryTests.java @@ -0,0 +1,108 @@ +package org.alfresco.rest.discovery; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.RestResponse; +import org.alfresco.rest.model.RestDiscoveryModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class DiscoveryTests extends RestTest +{ + private UserModel adminModel, userModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminModel = dataUser.getAdminUser(); + userModel = dataUser.createRandomTestUser(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.DISCOVERY, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.DISCOVERY }, executionType = ExecutionType.SANITY, + description = "Sanity tests for GET /discovery endpoint") + public void getRepositoryInformation() throws Exception + { + // Get repository info from admin console + RestResponse adminConsoleRepoInfo = restClient.authenticateUser(adminModel).withAdminConsole().getAdminConsoleRepoInfo(); + String id = adminConsoleRepoInfo.getResponse().getBody().path("data.id"); + String edition = adminConsoleRepoInfo.getResponse().getBody().path("data.edition"); + String schema = adminConsoleRepoInfo.getResponse().getBody().path("data.schema"); + String version = adminConsoleRepoInfo.getResponse().getBody().path("data.version"); + + // Get repository info using Discovery API + RestDiscoveryModel response = restClient.authenticateUser(userModel).withDiscoveryAPI().getRepositoryInfo(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + // Compare information + response.getRepository().getVersion().assertThat().field("major").is(version.charAt(0)); + response.getRepository().getVersion().assertThat().field("minor").is(version.charAt(2)); + response.getRepository().getVersion().assertThat().field("patch").is(version.charAt(4)); + response.getRepository().getVersion().assertThat().field("schema").is(schema); + response.getRepository().getId().equals(id); + response.getRepository().getEdition().equals(edition); + response.getRepository().getStatus().assertThat().field("isReadOnly").is(false); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.DISCOVERY, TestGroup.ALL_AMPS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.DISCOVERY }, executionType = ExecutionType.SANITY, + description = "Sanity tests for GET /discovery endpoint") + public void getRepositoryInstalledModules() throws Exception + { + // Get repository info using Discovery API + restClient.authenticateUser(userModel).withDiscoveryAPI().getRepositoryInfo(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + // Check that all modules are present + List modules = restClient.onResponse().getResponse().jsonPath().getList("entry.repository.modules.id", String.class); + List expectedModules = Arrays.asList("alfresco-aos-module", "org.alfresco.integrations.google.docs", + "org_alfresco_integrations_S3Connector", "org_alfresco_module_xamconnector", + "org.alfresco.module.KofaxAddon", "alfresco-content-connector-for-salesforce-repo", + "alfresco-share-services", + // uncomment when REPO-4233 is fixed + // "alfresco-saml-repo", + "org_alfresco_device_sync_repo", + // uncomment when MM-785 is fixed: + // "org_alfresco_mm_repo", + "org.alfresco.module.TransformationServer", "alfresco-glacier-connector-repo"); + + expectedModules.forEach(module -> + assertTrue(modules.contains(module), String.format("Expected module %s is not installed", module))); + + // Check that all installed modules are in INSTALLED state + List modulesStates = restClient.onResponse().getResponse().jsonPath().getList("entry.repository.modules.installState", String.class); + //change back to assertEquals after REPO-4233 and MM-785 is fixed + assertTrue(Collections.frequency(modulesStates, "INSTALLED") >= expectedModules.size(), "Number of amps installed should match expected"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.DISCOVERY, TestGroup.SANITY, TestGroup.CORE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.DISCOVERY }, executionType = ExecutionType.SANITY, + description = "Sanity tests for GET /discovery endpoint") + public void getDefaultRepositoryInstalledModules() throws Exception + { + // Get repository info using Discovery API + restClient.authenticateUser(userModel).withDiscoveryAPI().getRepositoryInfo(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + // Check that all modules are present + List modules = restClient.onResponse().getResponse().jsonPath().getList("entry.repository.modules.id", String.class); + assertTrue(modules.contains("alfresco-aos-module")); + assertTrue(modules.contains("org.alfresco.integrations.google.docs")); + assertTrue(modules.contains("alfresco-share-services")); + + // Check that all installed modules are in INSTALLED state + List modulesStates = restClient.onResponse().getResponse().jsonPath().getList("entry.repository.modules.installState", String.class); + assertEquals(Collections.frequency(modulesStates, "INSTALLED"), 3); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/downloads/DownloadsTests.java b/e2e-test/src/test/java/org/alfresco/rest/downloads/DownloadsTests.java new file mode 100644 index 000000000..054801807 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/downloads/DownloadsTests.java @@ -0,0 +1,106 @@ +package org.alfresco.rest.downloads; + +import javax.json.JsonObject; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.JsonBodyGenerator; +import org.alfresco.rest.model.RestDownloadsModel; +import org.alfresco.utility.Utility; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class DownloadsTests extends RestTest +{ + private UserModel adminModel; + private FileModel document, document1; + private FolderModel folder; + private SiteModel siteModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminModel = dataUser.getAdminUser(); + siteModel = dataSite.usingUser(adminModel).createPrivateRandomSite(); + folder = dataContent.usingUser(adminModel).usingSite(siteModel).createFolder(); + document = dataContent.usingSite(siteModel).usingUser(adminModel).createContent(DocumentType.TEXT_PLAIN); + + // Create document1 based on existing resource + FileModel newFile = FileModel.getFileModelBasedOnTestDataFile("larger.pdf"); + newFile.setName("larger.pdf"); + document1 = dataContent.usingUser(adminModel).usingResource(folder).createContent(newFile); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.DOWNLOADS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.DOWNLOADS }, executionType = ExecutionType.SANITY, + description = "Sanity tests for GET /downloads/{downloadId} and POST /downloads") + public void createDownloadNodeAndGetInfo() throws Exception + { + // POST /downloads + JsonObject postBody = JsonBodyGenerator.defineJSON() + .add("nodeIds", JsonBodyGenerator.defineJSONArray().add(document.getNodeRefWithoutVersion())) + .build(); + RestDownloadsModel downloadModel = restClient.authenticateUser(adminModel).withCoreAPI().usingDownloads().createDownload(postBody.toString()); + restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); + downloadModel.assertThat().fieldsCount().is(6).and() + .field("id").isNotEmpty(); + + // GET /downloads/{downloadId} + Utility.sleep(500, 10000, () -> { + RestDownloadsModel downloadModel1 = restClient.authenticateUser(adminModel).withCoreAPI().usingDownloads(downloadModel).getDownload(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + downloadModel1.assertThat().fieldsCount().is(6).and() + .field("id").is(downloadModel.getId()).and() + .field("filesAdded").isGreaterThan(0).and() + .field("bytesAdded").isGreaterThan(0).and() + .field("totalBytes").isGreaterThan(0).and() + .field("totalFiles").isGreaterThan(0).and() + .field("status").is("DONE"); + }); + + // Check that download node has content + restClient.authenticateUser(adminModel).withCoreAPI().usingNode().getNodeContent(downloadModel.getId()); + + restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.assertHeaderValueContains("Content-Type","application/octet-stream;charset=UTF-8"); + restClient.assertHeaderValueContains("Content-disposition",".zip"); + Assert.assertTrue(restClient.onResponse().getResponse().body().asInputStream().available() > 0); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.DOWNLOADS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.DOWNLOADS }, executionType = ExecutionType.SANITY, + description = "Sanity tests for DELETE /downloads/{downloadId}") + public void cancelDownloadNode() throws Exception + { + // POST /downloads + String postBody = JsonBodyGenerator.defineJSON() + .add("nodeIds", JsonBodyGenerator.defineJSONArray().add(document1.getNodeRefWithoutVersion())) + .build().toString(); + RestDownloadsModel downloadModel = restClient.authenticateUser(adminModel).withCoreAPI().usingDownloads().createDownload(postBody); + + /* + * DELETE /downloads/{downloadId} + * Download canceling is async and it works only if download status is not "DONE" + * To have this case, a large pdf file was used that takes a longer time to download + */ + restClient.authenticateUser(adminModel).withCoreAPI().usingDownloads(downloadModel).cancelDownload(); + restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); + + // GET /downloads/{downloadId} to check that the download is canceled + Utility.sleep(500, 10000, () -> { + RestDownloadsModel downloadModel1 = restClient.authenticateUser(adminModel).withCoreAPI().usingDownloads(downloadModel).getDownload(); + restClient.assertStatusCodeIs(HttpStatus.OK); + downloadModel1.assertThat().field("status").is("CANCELLED"); + }); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/favorites/AddFavoriteSiteTests.java b/e2e-test/src/test/java/org/alfresco/rest/favorites/AddFavoriteSiteTests.java new file mode 100644 index 000000000..efc505218 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/favorites/AddFavoriteSiteTests.java @@ -0,0 +1,487 @@ +package org.alfresco.rest.favorites; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.model.RestCommentModel; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestFavoriteSiteModel; +import org.alfresco.rest.model.RestPersonFavoritesModel; +import org.alfresco.rest.model.RestPersonFavoritesModelsCollection; +import org.alfresco.rest.model.RestTagModel; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.LinkModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class AddFavoriteSiteTests extends RestTest +{ + private UserModel userModel, adminUser; + private SiteModel publicSite, privateSite, moderatedSite; + private FileModel document; + private FolderModel folder; + private RestFavoriteSiteModel restFavoriteSiteModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userModel = dataUser.createRandomTestUser(); + + publicSite = dataSite.usingUser(userModel).createPublicRandomSite(); + privateSite = dataSite.usingUser(userModel).createPrivateRandomSite(); + moderatedSite = dataSite.usingUser(userModel).createModeratedRandomSite(); + + document = dataContent.usingSite(publicSite).usingUser(adminUser).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + folder = dataContent.usingSite(publicSite).usingUser(adminUser).createFolder(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user add a favorite site with Rest API and response is successful (201)") + public void managerUserAddFavoriteSiteWithSuccess() throws Exception + { + UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(managerUser, publicSite, UserRole.SiteManager); + + restFavoriteSiteModel = restClient.authenticateUser(managerUser).withCoreAPI().usingUser(managerUser).addFavoriteSite(publicSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restFavoriteSiteModel.assertThat().field("id").is(publicSite.getId()); + + restClient.withCoreAPI().usingUser(managerUser).addFavoriteSite(publicSite); + restClient.assertStatusCodeIs(HttpStatus.CONFLICT); + restClient.assertLastError().containsSummary(String.format("%s is already a favourite site", publicSite.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify a manager user is NOT Authorized to add a favorite site with Rest API when authentication fails (401)") +// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") + public void managerUserNotAuthorizedFailsToAddFavoriteSite() throws Exception + { + UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(managerUser, publicSite, UserRole.SiteManager); + managerUser.setPassword("newpassword"); + + restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().addFavoriteSite(publicSite); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify collaborator user add a favorite site with Rest API and response is successful (201)") + public void collaboratorUserAddFavoriteSiteWithSuccess() throws Exception + { + UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(collaboratorUser, publicSite, UserRole.SiteCollaborator); + + restFavoriteSiteModel = restClient.authenticateUser(collaboratorUser).withCoreAPI().usingAuthUser().addFavoriteSite(publicSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restFavoriteSiteModel.assertThat().field("id").is(publicSite.getId()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify contributor user add a favorite site with Rest API and response is successful (201)") + public void contributorUserAddFavoriteSiteWithSuccess() throws Exception + { + UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(contributorUser, publicSite, UserRole.SiteContributor); + + restFavoriteSiteModel = restClient.authenticateUser(contributorUser).withCoreAPI().usingAuthUser().addFavoriteSite(publicSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restFavoriteSiteModel.assertThat().field("id").is(publicSite.getId()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify consumer user add a favorite site with Rest API and response is successful (201)") + public void consumerUserAddFavoriteSiteWithSuccess() throws Exception + { + UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(consumerUser, publicSite, UserRole.SiteConsumer); + + restFavoriteSiteModel = restClient.authenticateUser(consumerUser).withCoreAPI().usingAuthUser().addFavoriteSite(publicSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restFavoriteSiteModel.assertThat().field("id").is(publicSite.getId()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin user add a favorite site with Rest API and response is successful (201)") + public void adminUserAddFavoriteSiteWithSuccess() throws Exception + { + restFavoriteSiteModel = restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().addFavoriteSite(publicSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restFavoriteSiteModel.assertThat().field("id").is(publicSite.getId()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify manager user is not able to add a favorite site when the site is already favorite - status code (409)") + public void managerUserAddFavoriteSiteAlreadyAFavoriteSite() throws Exception + { + publicSite = dataSite.usingUser(userModel).createPublicRandomSite(); + UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(managerUser, publicSite, UserRole.SiteManager); + + restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().addFavoriteSite(publicSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.withCoreAPI().usingUser(managerUser).addFavoriteSite(publicSite); + restClient.assertStatusCodeIs(HttpStatus.CONFLICT); + restClient.assertLastError() + .containsSummary(String.format("%s is already a favourite site", publicSite.getId())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE) + .containsErrorKey(String.format("Site %s is already a favourite site", publicSite.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify user doesn't have permission to delete favorites of admin user with Rest API and status code is 403") + public void userIsNotAbleToAddFavoriteSiteOfAnotherUser() throws Exception + { + publicSite = dataSite.usingUser(userModel).createPublicRandomSite(); + UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(contributorUser, publicSite, UserRole.SiteContributor); + UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(consumerUser, publicSite, UserRole.SiteConsumer); + + restClient.authenticateUser(consumerUser).withCoreAPI() + .usingUser(contributorUser).addFavoriteSite(publicSite); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError() + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify manager user is able to add as favorite a private site.") + public void managerAddsPrivateSiteAsFavorite() throws Exception + { + UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(managerUser, privateSite, UserRole.SiteManager); + + restClient.authenticateUser(managerUser).withCoreAPI().usingUser(managerUser).addFavoriteSite(privateSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestPersonFavoritesModelsCollection favorites = restClient.withCoreAPI().usingAuthUser().getFavorites(); + favorites.assertThat().entriesListContains("targetGuid", privateSite.getGuidWithoutVersion()) + .and().paginationField("totalItems").is("1"); + favorites.getOneRandomEntry().onModel().getTarget().getSite() + .assertThat() + .field("description").is(privateSite.getDescription()) + .and().field("id").is(privateSite.getId()) + .and().field("visibility").is(privateSite.getVisibility().toString()) + .and().field("title").is(privateSite.getTitle()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify manager user is able to add as favorite a moderated site.") + public void managerAddsModeratedSiteAsFavorite() throws Exception + { + UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(managerUser, moderatedSite, UserRole.SiteManager); + + restClient.authenticateUser(managerUser).withCoreAPI().usingUser(managerUser).addFavoriteSite(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestPersonFavoritesModelsCollection favorites = restClient.withCoreAPI().usingAuthUser().getFavorites(); + favorites.assertThat().entriesListContains("targetGuid", moderatedSite.getGuidWithoutVersion()) + .and().paginationField("totalItems").is("1"); + favorites.getOneRandomEntry().onModel().getTarget().getSite() + .assertThat() + .field("description").is(moderatedSite.getDescription()) + .and().field("id").is(moderatedSite.getId()) + .and().field("visibility").is(moderatedSite.getVisibility().toString()) + .and().field("title").is(moderatedSite.getTitle()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify user removes a site from favorites using '-me-' in place of personId with Rest API and response is successful (201)") + public void addFavoriteSiteWithSuccessUsingMeAsPersonId() throws Exception + { + restClient.authenticateUser(adminUser).withCoreAPI().usingMe().addFavoriteSite(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify manager user removes a site from its favorites and adds it again and response is successful (204)") + public void managerUserRemovesFavoriteSiteAndAddItAgain() throws Exception + { + UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(managerUser, publicSite, UserRole.SiteManager); + dataSite.usingUser(managerUser).usingSite(publicSite).addSiteToFavorites(); + + restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().removeFavoriteSite(publicSite); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingUser(managerUser).addSiteToFavorites(publicSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + } + + @Bug(id="ACE-2413") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify empty user is not able to add a site from favorites and response is (400)") + public void emptyUserIsNotAbleToRemoveFavoriteSite() throws Exception + { + UserModel emptyUser = new UserModel("", "password"); + restClient.authenticateUser(adminUser).withCoreAPI().usingUser(emptyUser).addFavoriteSite(publicSite); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "emptyUser")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify inexistent user is not able to add a site from favorites and response is (404)") + public void inexistentUserIsNotAbleToRemoveFavoriteSite() throws Exception + { + UserModel inexistentUser = new UserModel("inexistentUser", "password"); + restClient.authenticateUser(adminUser).withCoreAPI().usingUser(inexistentUser).addFavoriteSite(publicSite); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "inexistentUser")) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Bug(id="REPO-1827") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify user is not able to add a favorite site when the 'id' is empty - status code (400)") + public void userAddFavoriteSiteWithEmptySiteId() throws Exception + { + publicSite.setId(""); + restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().addFavoriteSite(publicSite); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + restClient.assertLastError() + .containsSummary("siteId is null") + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify admin user doesn't have permission to add a favorite site of another user with Rest API and status code is 403") + public void adminIsNotAbleToAddFavoriteSiteOfAnotherUser() throws Exception + { + UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(collaboratorUser, publicSite, UserRole.SiteCollaborator); + restClient.authenticateUser(collaboratorUser) + .withCoreAPI().usingUser(adminUser).addFavoriteSite(publicSite); + + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError() + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Bug(id="MNT-17338") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify admin user doesn't have permission to add a favorite site of another user with Rest API and status code is 403") + public void userIsNotAbleToAddFavoriteSiteOfAdmin() throws Exception + { + UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(consumerUser, publicSite, UserRole.SiteConsumer); + restClient.authenticateUser(adminUser) + .withCoreAPI().usingUser(consumerUser).addFavoriteSite(publicSite); + + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError() + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify add favorite site using empty body - status code is 400") + public void addFavoriteSiteWithEmptyBody() throws Exception + { + restClient.authenticateUser(adminUser).withCoreAPI(); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{\"ids\": \"local\"}" , + "people/{personId}/favorite-sites", adminUser.getUsername()); + restClient.processModel(RestPersonFavoritesModel.class, request); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsSummary(String.format(RestErrorModel.NO_CONTENT, "Unrecognized field " + "\"ids\"")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify add favorite site using empty body - status code is 400") + public void addFavoriteSiteWithEmptyRequiredFieldsBody() throws Exception + { + restClient.authenticateUser(adminUser).withCoreAPI(); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{\"\": \"\"}", + "people/{personId}/favorite-sites", adminUser.getUsername()); + restClient.processModel(RestPersonFavoritesModel.class, request); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsSummary(String.format(RestErrorModel.NO_CONTENT, "Unrecognized field " + "\"\"")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify non member user is not able to add a private favorite site - status code is 404") + public void userAddFavoriteSiteUserNotMemberOfPrivateSite() throws Exception + { + UserModel user = dataUser.usingAdmin().createRandomTestUser(); + restClient.authenticateUser(user).withCoreAPI() + .usingAuthUser().addFavoriteSite(privateSite); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, privateSite.getId())) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify non member user is able to add a moderated favorite site") + public void userAddFavoriteSiteUserNotMemberOfModeratedSite() throws Exception + { + UserModel user = dataUser.usingAdmin().createRandomTestUser(); + restClient.authenticateUser(user).withCoreAPI().usingAuthUser() + .addFavoriteSite(moderatedSite); + + RestPersonFavoritesModelsCollection favorites = restClient.withCoreAPI().usingAuthUser().getFavorites(); + favorites.assertThat().entriesListContains("targetGuid", moderatedSite.getGuidWithoutVersion()) + .and().paginationField("totalItems").is("1"); + favorites.getOneRandomEntry().onModel().getTarget().getSite() + .assertThat() + .field("description").is(moderatedSite.getDescription()) + .and().field("id").is(moderatedSite.getId()) + .and().field("visibility").is(moderatedSite.getVisibility().toString()) + .and().field("title").is(moderatedSite.getTitle()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify non member user is able to add a public favorite site") + public void userAddFavoriteSiteUserNotMemberOfPublicSite() throws Exception + { + UserModel user = dataUser.usingAdmin().createRandomTestUser(); + restFavoriteSiteModel = restClient.authenticateUser(user).withCoreAPI().usingAuthUser().addFavoriteSite(publicSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restFavoriteSiteModel.assertThat().field("id").is(publicSite.getId()); + + RestPersonFavoritesModelsCollection favorites = restClient.withCoreAPI().usingAuthUser().getFavorites(); + favorites.assertThat().entriesListContains("targetGuid", publicSite.getGuidWithoutVersion()) + .and().paginationField("totalItems").is("1"); + favorites.getOneRandomEntry().onModel().getTarget().getSite() + .assertThat() + .field("description").is(publicSite.getDescription()) + .and().field("id").is(publicSite.getId()) + .and().field("visibility").is(publicSite.getVisibility().toString()) + .and().field("title").is(publicSite.getTitle()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Check that if id does not exist, status code is 404") + public void addFavoriteSiteUsingInvalidId() throws Exception + { + SiteModel site = dataSite.usingUser(adminUser).createPublicRandomSite(); + String id = publicSite.getId(); + site.setId("invalidID"); + + restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().addFavoriteSite(site); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidID")); + + publicSite.setId(id); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Check that if user provides site in id but id is of a file status code is 404") + public void addSiteToFavoritesUsingFileId() throws Exception + { + String id = publicSite.getId(); + publicSite.setId(document.getNodeRefWithoutVersion()); + + restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().addFavoriteSite(publicSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, document.getNodeRefWithoutVersion())); + + publicSite.setId(id); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Check that if user provides site in id but id is of a folder status code is 404") + public void addSiteToFavoritesUsingFolderId() throws Exception + { + String id = publicSite.getId(); + publicSite.setId(folder.getNodeRefWithoutVersion()); + + restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().addFavoriteSite(publicSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, folder.getNodeRefWithoutVersion())); + + publicSite.setId(id); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Check that if user provides site in id but id is of a comment status code is 404") + public void addSiteToFavoriteUsingCommentId() throws Exception + { + publicSite = dataSite.usingUser(userModel).createPublicRandomSite(); + String id = publicSite.getId(); + FileModel file = dataContent.usingSite(publicSite).usingUser(adminUser).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + RestCommentModel comment = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(file).addComment("This is a comment"); + file.setNodeRef(comment.getId()); + publicSite.setId(comment.getId()); + + restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().addFavoriteSite(publicSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + publicSite.setId(id); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Check that if user provides site in id but id is of a tag status code is 404") + public void addSiteFavoriteUsingTagId() throws Exception + { + FileModel file = dataContent.usingSite(publicSite).usingUser(adminUser).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + RestTagModel returnedModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(file).addTag("random_tag"); + file.setNodeRef(returnedModel.getId()); + publicSite.setId(returnedModel.getId()); + + restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().addFavoriteSite(publicSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, returnedModel.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION}) + @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Check that if id does not describe a site, file, or folder status code is 400") + public void addFavoriteUsingInvalidGuid() throws Exception + { + LinkModel link = dataLink.usingAdmin().usingSite(publicSite).createRandomLink(); + SiteModel site = dataSite.usingUser(adminUser).createPublicRandomSite(); + site.setId(link.getNodeRef()); + + restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().addFavoriteSite(site); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, site.getId().split("/")[3])); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/favorites/AddFavoritesTests.java b/e2e-test/src/test/java/org/alfresco/rest/favorites/AddFavoritesTests.java new file mode 100644 index 000000000..0797eadee --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/favorites/AddFavoritesTests.java @@ -0,0 +1,446 @@ +package org.alfresco.rest.favorites; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.*; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.model.*; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class AddFavoritesTests extends RestTest +{ + private UserModel adminUserModel; + private SiteModel siteModel; + private ListUserWithRoles usersWithRoles; + private RestPersonFavoritesModel restPersonFavoritesModel; + private FileModel document; + private FolderModel folder; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + folder = dataContent.usingSite(siteModel).usingUser(adminUserModel).createFolder(); + } + + // @Bug(id="MNT-16904", description = "It fails only on environment with tenants") + @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, + description = "Verify Manager user gets status code 401 if authentication call fails") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) + public void managerIsNotAbleToAddToFavoritesIfAuthenticationFails() throws Exception + { + UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); + siteManager.setPassword("wrongPassword"); + restClient.authenticateUser(siteManager).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify Collaborator user add site to favorites with Rest API and status code is 201") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void collaboratorIsAbleToAddToFavorites() throws Exception + { + restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restPersonFavoritesModel.and().field("targetGuid").is(siteModel.getGuid()); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify Contributor user add site to favorites with Rest API and status code is 201") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void contributorIsAbleToAddToFavorites() throws JsonToModelConversionException, Exception + { + restPersonFavoritesModel= restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) + .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restPersonFavoritesModel.and().field("targetGuid").is(siteModel.getGuid()); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify Consumer user add site to favorites with Rest API and status code is 201") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void consumerIsAbleToAddToFavorites() throws Exception + { + restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restPersonFavoritesModel.and().field("targetGuid").is(siteModel.getGuid()); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify Admin user add site to favorites with Rest API and status code is 201") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void adminIsAbleToAddToFavorites() throws Exception + { + restPersonFavoritesModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restPersonFavoritesModel.assertThat().field("targetGuid").is(siteModel.getGuid()); + } + + @Bug(id = "MNT-17157") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Check that if a favorite already exists with the specified id status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void addFavoriteTwice() throws Exception + { + SiteModel site = dataSite.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).createPublicRandomSite(); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteToFavorites(site); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(site); + restClient.assertStatusCodeIs(HttpStatus.CONFLICT); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, + description = "Add to favorites a file for a Manager, check it was added") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) + public void managerIsAbleToAddFileToFavorites() throws Exception + { + restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingAuthUser().addFileToFavorites(document); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restPersonFavoritesModel.assertThat().field("targetGuid").is(document.getNodeRefWithoutVersion()); + + RestFileModel restFileModel = restPersonFavoritesModel.getTarget().getFile(); + restFileModel.assertThat().field("mimeType").is("text/plain").and() + .field("isFile").is("true").and() + .field("isFolder").is("false").and() + .field("createdBy").is(adminUserModel.getUsername()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, + description = "Add to favorites a folder for a Manager, check it was added") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) + public void managerIsAbleToAddFolderToFavorites() throws Exception + { + restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingAuthUser().addFolderToFavorites(folder); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restPersonFavoritesModel.assertThat().field("targetGuid").is(folder.getNodeRefWithoutVersion()); + + RestFolderModel restFolderModel = restPersonFavoritesModel.getTarget().getFolder(); + restFolderModel.assertThat().field("isFile").is("false").and() + .field("isFolder").is("true").and() + .field("createdBy").is(adminUserModel.getUsername()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, + description = "Add to favorites a site for a Manager, check it was added") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) + public void managerIsAbleToAddSiteToFavorites() throws Exception + { + restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restPersonFavoritesModel.assertThat().field("targetGuid").is(siteModel.getGuid()); + + RestSiteModel restSiteModel = restPersonFavoritesModel.getTarget().getSite(); + restSiteModel.assertThat().field("visibility").is(siteModel.getVisibility()).and() + .field("guid").is(siteModel.getGuid()).and() + .field("description").is(siteModel.getDescription()).and() + .field("id").is(siteModel.getId()).and() + .field("title").is(siteModel.getTitle()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify add favorite specifying -me- string in place of for request") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void userIsAbleToAddFavoriteWhenUsingMeAsUsername() throws Exception + { + UserModel user = dataUser.createRandomTestUser(); + restPersonFavoritesModel = restClient.authenticateUser(user) + .withCoreAPI().usingMe().addSiteToFavorites(siteModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restPersonFavoritesModel.assertThat().field("targetGuid").is(siteModel.getGuid()); + + restClient.authenticateUser(user).withCoreAPI().usingAuthUser().getFavoriteSites().assertThat().entriesListContains("guid", siteModel.getGuid()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Add to favorites a file for a Collaborator, check it was added") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void collaboratorIsAbleToAddFileToFavorites() throws Exception + { + restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingAuthUser().addFileToFavorites(document); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restPersonFavoritesModel.assertThat().field("targetGuid").is(document.getNodeRefWithoutVersion()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Add to favorites a file for a Contributor, check it was added") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void contributorIsAbleToAddFileToFavorites() throws Exception + { + restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) + .withCoreAPI().usingAuthUser().addFileToFavorites(document); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restPersonFavoritesModel.assertThat().field("targetGuid").is(document.getNodeRefWithoutVersion()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Add to favorites a file for a Consumer, check it was added") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void consumerIsAbleToAddFileToFavorites() throws Exception + { + restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + .withCoreAPI().usingAuthUser().addFileToFavorites(document); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restPersonFavoritesModel.assertThat().field("targetGuid").is(document.getNodeRefWithoutVersion()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Add to favorites a folder for a Collaborator, check it was added") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void collaboratorIsAbleToAddFolderToFavorites() throws Exception + { + restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).addFolderToFavorites(folder); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restPersonFavoritesModel.assertThat().field("targetGuid").is(folder.getNodeRefWithoutVersion()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Add to favorites a folder for a Contributor, check it was added") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void contributorIsAbleToAddFolderToFavorites() throws Exception + { + restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) + .withCoreAPI().usingAuthUser().addFolderToFavorites(folder); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restPersonFavoritesModel.assertThat().field("targetGuid").is(folder.getNodeRefWithoutVersion()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Add to favorites a folder for a Consumer, check it was added") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void consumerIsAbleToAddFolderToFavorites() throws Exception + { + restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + .withCoreAPI().usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).addFolderToFavorites(folder); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restPersonFavoritesModel.assertThat().field("targetGuid").is(folder.getNodeRefWithoutVersion()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Add to favorites a site for a Collaborator, check it was added") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void collaboratorIsAbleToAddSiteToFavorites() throws Exception + { + restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restPersonFavoritesModel.assertThat().field("targetGuid").is(siteModel.getGuid()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Add to favorites a site for a Contributor, check it was added") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void contributorIsAbleToAddSiteToFavorites() throws Exception + { + restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) + .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restPersonFavoritesModel.assertThat().field("targetGuid").is(siteModel.getGuid()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Add to favorites a site for a Consumer, check it was added") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void consumerIsAbleToAddSiteToFavorites() throws Exception + { + restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restPersonFavoritesModel.assertThat().field("targetGuid").is(siteModel.getGuid()); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Check that if target guid does not describe a site, file, or folder status code is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void addFavoriteUsingInvalidGuid() throws Exception + { + LinkModel link = dataLink.usingAdmin().usingSite(siteModel).createRandomLink(); + SiteModel site = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + site.setGuid(link.getNodeRef()); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteToFavorites(site); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, site.getGuid().split("/")[3])); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Check that if personId does not exist, status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void addFavoriteUsingInexistentUser() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(new UserModel("random_user", "random_password")).addSiteToFavorites(siteModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "random_user")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Check that if target guid does not exist, status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void addFavoriteUsingInexistentGuid() throws Exception + { + SiteModel site = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + site.setGuid("random_guid"); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteToFavorites(site); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "random_guid")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Check that if user provides file in target but guid is of a folder status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void addFileToFavoritesUsingFolderGuid() throws Exception + { + String nodeRef = document.getNodeRef(); + document.setNodeRef(folder.getNodeRef()); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFileToFavorites(document); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, + adminUserModel.getUsername(), folder.getNodeRefWithoutVersion())); + + document.setNodeRef(nodeRef); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify add favorite, perform getFavorites call, check value is updated") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void verifyGetFavoritesAfterFavoritingSite() throws Exception + { + UserModel user = dataUser.createRandomTestUser(); + restPersonFavoritesModel = restClient.authenticateUser(user) + .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(user).withCoreAPI().usingAuthUser().getFavoriteSites() + .assertThat().entriesListContains("guid", siteModel.getGuid()); + } + + // @Bug(id = "MNT-17158", description="Not a bug, If we need to stop comments from being favorited then an improvement/enhancement request should be raised against the platform.") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify add file favorite with comment id returns status code 201") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void addFileFavoriteUsingCommentId() throws Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + RestCommentModel comment = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment("This is a comment"); + file.setNodeRef(comment.getId()); + + restPersonFavoritesModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFileToFavorites(file); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restPersonFavoritesModel.assertThat().field("targetGuid").is(file.getNodeRef()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify add file favorite with tag id returns status code 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void addFileFavoriteUsingTagId() throws Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + RestTagModel returnedModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addTag("random_tag"); + file.setNodeRef(returnedModel.getId()); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFileToFavorites(file); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, + adminUserModel.getUsername(), returnedModel.getId())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Check that if user provides site in target but id is of a file status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void addSiteToFavoritesUsingFileId() throws Exception + { + String guid = siteModel.getGuid(); + siteModel.setGuid(document.getNodeRefWithoutVersion()); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, document.getNodeRefWithoutVersion())); + + siteModel.setGuid(guid); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Check that if user provides folder in target but guid is of a file status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void addFolderToFavoritesUsingFileGuid() throws Exception + { + String nodeRef = folder.getNodeRef(); + folder.setNodeRef(document.getNodeRef()); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFolderToFavorites(folder); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, document.getNodeRef())); + + folder.setNodeRef(nodeRef); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Check that if user provides file in target but guid is of a site status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void addSiteToFavoritesUsingFolderId() throws Exception + { + SiteModel newSiteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + newSiteModel.setGuid(folder.getNodeRef()); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteToFavorites(newSiteModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, folder.getNodeRef())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Check that if user provides folder in target but guid is of a site status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void addFolderToFavoritesUsingSiteId() throws Exception + { + FolderModel newFolder = dataContent.usingSite(siteModel).usingUser(adminUserModel).createFolder(); + newFolder.setNodeRef(siteModel.getGuid()); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFolderToFavorites(newFolder); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, + adminUserModel.getUsername(), siteModel.getGuid())); + } + + @Bug(id = "REPO-1061") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Check that if user does not have permission to favorite a site status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void verifyFavoriteASiteIfTheUserDoesNotHavePermission() throws Exception + { + SiteModel privateSite = dataSite.usingUser(adminUserModel).createPrivateRandomSite(); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingAuthUser().addSiteToFavorites(privateSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, privateSite.getGuid())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .containsErrorKey(RestErrorModel.NOT_FOUND_ERRORKEY) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify the response of favorite a sie with empty body at request") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void verifyFavoriteASiteWithEmptyBody() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI(); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "", "people/{personId}/favorites", adminUserModel.getUsername()); + restClient.processModel(RestPersonFavoritesModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.NO_CONTENT, "No content to map due to end-of-input")); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/favorites/DeleteFavoriteSiteTests.java b/e2e-test/src/test/java/org/alfresco/rest/favorites/DeleteFavoriteSiteTests.java new file mode 100644 index 000000000..b3fa0d190 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/favorites/DeleteFavoriteSiteTests.java @@ -0,0 +1,364 @@ +package org.alfresco.rest.favorites; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser; +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 Cristina Axinte + */ + +public class DeleteFavoriteSiteTests extends RestTest +{ + private UserModel userModel, adminUserModel; + private SiteModel siteModel1, siteModel2; + private DataUser.ListUserWithRoles usersWithRoles; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + siteModel1 = dataSite.usingUser(userModel).createPublicRandomSite(); + siteModel2 = dataSite.usingUser(userModel).createPublicRandomSite(); + adminUserModel = dataUser.getAdminUser(); + + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel1, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, + description = "Verify manager user removes a site from its favorite sites list with Rest API and response is successful (204)") + public void managerUserRemovesFavoriteSiteWithSuccess() throws Exception + { + UserModel managerUser = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); + dataSite.usingUser(managerUser).usingSite(siteModel1).addSiteToFavorites(); + dataSite.usingUser(managerUser).usingSite(siteModel2).addSiteToFavorites(); + + restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel1); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingAuthUser().getFavorites() + .assertThat() + .entriesListDoesNotContain("targetGuid", siteModel1.getGuid()) + .and().entriesListDoesNotContain("id", siteModel1.getId()) + .and().entriesListDoesNotContain("description", siteModel1.getDescription()) + .and().entriesListDoesNotContain("visibility", siteModel1.getVisibility().toString()) + .and().entriesListDoesNotContain("title", siteModel1.getTitle()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, + description = "Verify manager user is NOT Authorized to remove a site from its favorite sites list with Rest API when authentication fails (401)") + public void managerUserNotAuthorizedFailsToRemoveFavoriteSite() throws Exception + { + UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel1, UserRole.SiteManager); + dataSite.usingUser(managerUser).usingSite(siteModel1).addSiteToFavorites(); + dataSite.usingUser(managerUser).usingSite(siteModel2).addSiteToFavorites(); + managerUser.setPassword("newpassword"); + + restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel1); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE) + .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify collaborator user removes a site from its favorite sites list with Rest API and response is successful (204)") + public void collaboratorUserRemovesFavoriteSiteWithSuccess() throws Exception + { + UserModel collaboratorUser = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); + dataSite.usingUser(collaboratorUser).usingSite(siteModel1).addSiteToFavorites(); + dataSite.usingUser(collaboratorUser).usingSite(siteModel2).addSiteToFavorites(); + + restClient.authenticateUser(collaboratorUser).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel1); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingAuthUser().getFavorites() + .assertThat() + .entriesListDoesNotContain("targetGuid", siteModel1.getGuid()) + .and().entriesListDoesNotContain("id", siteModel1.getId()) + .and().entriesListDoesNotContain("description", siteModel1.getDescription()) + .and().entriesListDoesNotContain("visibility", siteModel1.getVisibility().toString()) + .and().entriesListDoesNotContain("title", siteModel1.getTitle()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify contributor user removes a site from its favorite sites list with Rest API and response is successful (204)") + public void contributorUserRemovesFavoriteSiteWithSuccess() throws Exception + { + UserModel contributorUser = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); + dataSite.usingUser(contributorUser).usingSite(siteModel1).addSiteToFavorites(); + dataSite.usingUser(contributorUser).usingSite(siteModel2).addSiteToFavorites(); + + restClient.authenticateUser(contributorUser).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel1); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingAuthUser().getFavorites() + .assertThat() + .entriesListDoesNotContain("targetGuid", siteModel1.getGuid()) + .and().entriesListDoesNotContain("id", siteModel1.getId()) + .and().entriesListDoesNotContain("description", siteModel1.getDescription()) + .and().entriesListDoesNotContain("visibility", siteModel1.getVisibility().toString()) + .and().entriesListDoesNotContain("title", siteModel1.getTitle()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify consumer user removes a site from its favorite sites list with Rest API and response is successful (204)") + public void consumerUserRemovesFavoriteSiteWithSuccess() throws Exception + { + UserModel consumerUser = usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer); + dataSite.usingUser(consumerUser).usingSite(siteModel1).addSiteToFavorites(); + dataSite.usingUser(consumerUser).usingSite(siteModel2).addSiteToFavorites(); + + restClient.authenticateUser(consumerUser).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel1); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingAuthUser().getFavorites() + .assertThat() + .entriesListDoesNotContain("targetGuid", siteModel1.getGuid()) + .and().entriesListDoesNotContain("id", siteModel1.getId()) + .and().entriesListDoesNotContain("description", siteModel1.getDescription()) + .and().entriesListDoesNotContain("visibility", siteModel1.getVisibility().toString()) + .and().entriesListDoesNotContain("title", siteModel1.getTitle()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify admin user removes a site from any user's favorite sites list with Rest API and response is successful (204)") + public void adminUserRemovesAnyFavoriteSiteWithSuccess() throws Exception + { + UserModel anyUser = dataUser.usingAdmin().createRandomTestUser(); + dataSite.usingUser(anyUser).usingSite(siteModel1).addSiteToFavorites(); + dataSite.usingUser(anyUser).usingSite(siteModel2).addSiteToFavorites(); + + restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingUser(anyUser).removeFavoriteSite(siteModel1); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE , TestGroup.REGRESSION}) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify a user removes a site from another user's favorite sites list with Rest API and response is permission denied (403)") + public void userCannotRemoveAnotherUserFavoriteSite() throws Exception + { + UserModel userAuth = dataUser.usingAdmin().createRandomTestUser(); + UserModel anotherUser = dataUser.usingAdmin().createRandomTestUser(); + dataSite.usingUser(anotherUser).usingSite(siteModel1).addSiteToFavorites(); + dataSite.usingUser(anotherUser).usingSite(siteModel2).addSiteToFavorites(); + + restClient.authenticateUser(userAuth).withCoreAPI().usingUser(anotherUser).removeFavoriteSite(siteModel1); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError() + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE) + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify uninvited user can delete favorite public site and response is 204") + public void uninvitedUserCanDeleteFavoritePublicSite() throws Exception + { + SiteModel publicSiteModel = dataSite.usingAdmin().createPublicRandomSite(); + restClient.authenticateUser(userModel).withCoreAPI().usingUser(userModel).addFavoriteSite(publicSiteModel); + + restClient.withCoreAPI().usingAuthUser() + .removeFavoriteSite(publicSiteModel); + + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withCoreAPI().usingAuthUser().getFavoriteSites() + .assertThat().entriesListDoesNotContain("id", publicSiteModel.getId()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify uninvited user can delete favorite moderated site and response is 204") + public void uninvitedUserCanDeleteFavoriteModeratedSite() throws Exception + { + SiteModel moderatedSiteModel = dataSite.usingAdmin().createModeratedRandomSite(); + restClient.authenticateUser(userModel).withCoreAPI().usingUser(userModel).addFavoriteSite(moderatedSiteModel); + + restClient.withCoreAPI().usingAuthUser() + .removeFavoriteSite(moderatedSiteModel); + + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withCoreAPI().usingAuthUser().getFavoriteSites() + .assertThat().entriesListDoesNotContain("id", moderatedSiteModel.getId()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify user can delete favorite private site and response is 204") + public void userCanDeleteFavoritePrivateSite() throws Exception + { + SiteModel privateSiteModel = dataSite.usingUser(userModel).createPrivateRandomSite(); + restClient.authenticateUser(userModel).withCoreAPI().usingUser(userModel).addFavoriteSite(privateSiteModel); + + restClient.withCoreAPI().usingAuthUser() + .removeFavoriteSite(privateSiteModel); + + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withCoreAPI().usingAuthUser().getFavoriteSites() + .assertThat().entriesListDoesNotContain("id", privateSiteModel.getId()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify manager user removes a site from its favorites and adds it again and response is successful (204)") + public void managerUserRemovesFavoriteSiteAndAddItAgain() throws Exception + { + UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel1, UserRole.SiteManager); + dataSite.usingUser(managerUser).usingSite(siteModel1).addSiteToFavorites(); + + restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser() + .removeFavoriteSite(siteModel1); + + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withCoreAPI().usingUser(managerUser).addFavoriteSite(siteModel1); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify user removes a site from favorites using '-me-' in place of personId with Rest API and response is successful (204)") + public void removeFavoriteSiteWithSuccessUsingMeAsPersonId() throws Exception + { + restClient.authenticateUser(adminUserModel); + dataSite.usingUser(adminUserModel).usingSite(siteModel1).addSiteToFavorites(); + + restClient.withCoreAPI().usingMe().removeFavoriteSite(siteModel1); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) +// @Bug(id = "REPO-1642", description = "reproduced on 5.2.1 only, it works on 5.2.0") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify inexistent user is not able to remove a site from favorites and response is 404") + public void inexistentUserIsNotAbleToRemoveFavoriteSite() throws Exception + { + UserModel inexistentUser = new UserModel("inexistenUser", "password"); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(inexistentUser) + .removeFavoriteSite(siteModel1); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "inexistenUser")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify user is not able to remove from favorites a site with inexistent id and response is 404") + public void userIsNotAbleToRemoveFavoriteSiteWithInexistentId() throws Exception + { + SiteModel inexistentSite = new SiteModel("inexistentSite"); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel) + .removeFavoriteSite(inexistentSite); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, + adminUserModel.getUsername(), inexistentSite.getTitle())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE) + .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "User is not able to remove a favorite site of admin user") + public void userIsNotAbleToDeleteFavoritesOfAdmin() throws Exception + { + UserModel contributor = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); + dataSite.usingUser(adminUserModel).usingSite(siteModel1).addSiteToFavorites(); + + restClient.authenticateUser(contributor) + .withCoreAPI().usingUser(adminUserModel).removeFavoriteSite(siteModel1); + + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError() + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Users removed twice from favorites same site.") + public void managerUserRemovesDeletedFavoriteSite() throws Exception + { + UserModel managerUser = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); + dataSite.usingUser(managerUser).usingSite(siteModel1).addSiteToFavorites(); + + restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel1); + restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel1); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.NOT_FAVOURITE_SITE, siteModel1.getTitle())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Users removes from favorite a site that is already deleted.") + public void consumerUserRemovesDeletedFavoriteSite() throws Exception + { + SiteModel siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel, UserRole.SiteConsumer); + dataSite.usingUser(consumerUser).usingSite(siteModel).addSiteToFavorites(); + + dataSite.usingAdmin().deleteSite(siteModel); + restClient.authenticateUser(consumerUser).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, + consumerUser.getUsername(), siteModel.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Delete favorite site that is NOT favorite.") + public void adminUserRemovesDeletedFavoriteSiteThatIsNotFavorite() throws Exception + { + SiteModel siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.NOT_FAVOURITE_SITE, siteModel.getTitle())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify user doesn't have permission to delete favorites of another user with Rest API and status code is 403") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void siteMemberIsNotAbleToDeleteFavoritesOfAnotherSiteMember() throws Exception + { + UserModel siteCollaborator = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); + dataSite.usingUser(siteCollaborator).usingSite(siteModel1).addSiteToFavorites(); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + .withCoreAPI() + .usingUser(siteCollaborator) + .removeFavoriteSite(siteModel1); + + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError() + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/favorites/DeleteFavoriteTests.java b/e2e-test/src/test/java/org/alfresco/rest/favorites/DeleteFavoriteTests.java new file mode 100644 index 000000000..79570ff1d --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/favorites/DeleteFavoriteTests.java @@ -0,0 +1,412 @@ +package org.alfresco.rest.favorites; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class DeleteFavoriteTests extends RestTest +{ + private UserModel adminUserModel; + private SiteModel siteModel; + private ListUserWithRoles usersWithRoles; + private FileModel fileModel; + private FolderModel folderModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + siteModel.setGuid(restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(siteModel).getSite().getGuid()); + + fileModel = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + folderModel = dataContent.usingSite(siteModel).usingUser(adminUserModel).createFolder(); + + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, + description = "Verify Manager user deletes site from favorites with Rest API and status code is 204") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) + public void managerIsAbleToDeleteFavorites() throws Exception + { + UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); + restClient.authenticateUser(siteManager).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + + restClient.withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel).assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withCoreAPI().usingAuthUser().getFavorites() + .assertThat() + .entriesListDoesNotContain("targetGuid", siteModel.getGuid()) + .and().entriesListDoesNotContain("id", siteModel.getId()) + .and().entriesListDoesNotContain("description", siteModel.getDescription()) + .and().entriesListDoesNotContain("visibility", siteModel.getVisibility().toString()) + .and().entriesListDoesNotContain("title", siteModel.getTitle()); + } + + // @Bug(id = "MNT-16904", description = "It fails only on environment with tenants") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, + description = "Verify user gets status code 401 if authentication call fails") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) + public void userIsNotAbleToDeleteFavoritesIfAuthenticationFails() throws Exception + { + UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); + siteManager.setPassword("wrongPassword"); + restClient.authenticateUser(siteManager).withCoreAPI().usingAuthUser() + .deleteSiteFromFavorites(siteModel).assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify Collaborator user deletes site from favorites with Rest API and status code is 204") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void collaboratorIsAbleToDeleteFavorites() throws Exception + { + UserModel siteCollaborator = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); + restClient.authenticateUser(siteCollaborator).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + + restClient.withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel).assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withCoreAPI().usingAuthUser().getFavorites() + .assertThat() + .entriesListDoesNotContain("targetGuid", siteModel.getGuid()) + .and().entriesListDoesNotContain("id", siteModel.getId()) + .and().entriesListDoesNotContain("description", siteModel.getDescription()) + .and().entriesListDoesNotContain("visibility", siteModel.getVisibility().toString()) + .and().entriesListDoesNotContain("title", siteModel.getTitle()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify Contributor user deletes site from favorites with Rest API and status code is 204") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void contributorIsAbleToDeleteFavorites() throws Exception + { + UserModel siteContributor = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); + restClient.authenticateUser(siteContributor).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + + restClient.withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel).assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withCoreAPI().usingAuthUser().getFavorites() + .assertThat() + .entriesListDoesNotContain("targetGuid", siteModel.getGuid()) + .and().entriesListDoesNotContain("id", siteModel.getId()) + .and().entriesListDoesNotContain("description", siteModel.getDescription()) + .and().entriesListDoesNotContain("visibility", siteModel.getVisibility().toString()) + .and().entriesListDoesNotContain("title", siteModel.getTitle()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify Consumer user delets site from favorites with Rest API and status code is 204") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void consumerIsAbleToDeleteFavorites() throws Exception + { + UserModel siteConsumer = usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer); + restClient.authenticateUser(siteConsumer).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + + restClient.withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel).assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withCoreAPI().usingAuthUser().getFavorites() + .assertThat() + .entriesListDoesNotContain("targetGuid", siteModel.getGuid()) + .and().entriesListDoesNotContain("id", siteModel.getId()) + .and().entriesListDoesNotContain("description", siteModel.getDescription()) + .and().entriesListDoesNotContain("visibility", siteModel.getVisibility().toString()) + .and().entriesListDoesNotContain("title", siteModel.getTitle()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify Admin user deletes site from favorites with Rest API and status code is 204") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void adminIsAbleToDeleteFavorites() throws Exception + { + restClient.withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); + + restClient.withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel).assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withCoreAPI().usingAuthUser().getFavorites().assertThat().entriesListDoesNotContain("targetGuid", siteModel.getGuid()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify admin deletes files from favorites with Rest API and status code is (204)") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void adminIsAbleToDeleteFavoriteFile() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFileToFavorites(fileModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.withCoreAPI().usingAuthUser().deleteFileFromFavorites(fileModel).assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withCoreAPI().usingAuthUser().getFavorites() + .assertThat() + .entriesListDoesNotContain("targetGuid", fileModel.getNodeRefWithoutVersion()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify admin deletes folder from favorites with Rest API and status code is (204)") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void adminIsAbleToDeleteFavoriteFolder() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFolderToFavorites(folderModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.withCoreAPI().usingAuthUser().deleteFolderFromFavorites(folderModel) + .assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withCoreAPI().usingAuthUser().getFavorites() + .assertThat() + .entriesListDoesNotContain("targetGuid", fileModel.getNodeRefWithoutVersion()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify user removes a site from favorites using '-me-' in place of personId with Rest API and response is successful (204)") + public void deleteFavoriteSiteWithSuccessUsingMeAsPersonId() throws Exception + { + siteModel.setGuid(restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(siteModel).getSite().getGuid()); + restClient.withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); + + restClient.withCoreAPI().usingMe().deleteSiteFromFavorites(siteModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @Bug(id="ACE-5588") + @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify user doesn't have permission to delete favorites of admin user with Rest API and status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void userIsNotAbleToDeleteFavoritesOfAdminUser() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + .withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel) + .assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Bug(id="ACE-5588") + @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify admin user doesn't have permission to delete favorites of another user with Rest API and status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void adminIsNotAbleToDeleteFavoritesOfASiteMember() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + + restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel) + .assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError() + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Bug(id="ACE-5588") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify user doesn't have permission to delete favorites of another user with Rest API and status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void consumerIsNotAbleToDeleteFavoritesOfAnotherUser() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI() + .usingAuthUser().addSiteToFavorites(siteModel); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI() + .usingAuthUser().deleteSiteFromFavorites(siteModel) + .assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Bug(id="ACE-5588") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify consumer user doesn't have permission to delete favorites of another user with Rest API and status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void collaboratorIsNotAbleToDeleteFavoriteOfAnotherUser() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI() + .usingAuthUser().addSiteToFavorites(siteModel); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI() + .usingAuthUser().deleteSiteFromFavorites(siteModel) + .assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError() + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Bug(id="ACE-5588") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify contributor user doesn't have permission to delete favorites of another user with Rest API and status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void contributorIsNotAbleToDeleteFavoriteOfAnotherUser() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI() + .usingAuthUser().addSiteToFavorites(siteModel); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI() + .usingAuthUser().deleteSiteFromFavorites(siteModel) + .assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError() + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Bug(id="ACE-5588") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify contributor user doesn't have permission to delete favorites of another user with Rest API and status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void adminIsNotAbleToDeleteFavoriteOfAnotherUser() throws Exception + { + UserModel user = dataUser.createRandomTestUser(); + restClient.authenticateUser(user).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + + restClient.authenticateUser(adminUserModel).withCoreAPI() + .usingAuthUser().deleteSiteFromFavorites(siteModel) + .assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError() + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that status code is 404 if PersonID is incorrect - favorite file.") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION}) + public void deleteFavoriteIfPersonIdNotExists() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); + restClient.withCoreAPI().usingAuthUser().addFileToFavorites(fileModel); + + restClient.withCoreAPI().usingUser(new UserModel("inexistent", "inexistent")) + .deleteFileFromFavorites(fileModel).assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "inexistent")); + } + + @Bug(id="ACE-2413") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that status code is 404 if PersonID is empty - favorite file.") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION}) + public void deleteFavoriteIfPersonIdIsEmpty() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); + restClient.withCoreAPI().usingAuthUser().addFileToFavorites(fileModel); + + restClient.withCoreAPI().usingUser(new UserModel ("", "")) + .deleteFileFromFavorites(fileModel).assertStatusCodeIs(HttpStatus.BAD_REQUEST); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that status code is 404 if FavoriteID is incorrect - favorite file.") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION}) + public void deleteFavoriteFileIfFavoriteIdIsIncorrect() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFileToFavorites(fileModel); + + fileModel.setNodeRef("wrongFavoriteId"); + restClient.withCoreAPI().usingAuthUser() + .deleteFileFromFavorites(fileModel).assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "wrongFavoriteId")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that status code is 404 if FavoriteID is incorrect - favorite file.") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION}) + public void deleteFavoriteFileIfFavoriteIdNotExists() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFileToFavorites(fileModel); + FileModel inexistentDocument = new FileModel(); + inexistentDocument.setNodeRef("inexistent"); + + restClient.withCoreAPI().usingAuthUser() + .deleteFileFromFavorites(inexistentDocument).assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "inexistent")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that status code is 404 if FavoriteID is incorrect - favorite site.") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION}) + public void deleteFavoriteSiteIfFavoriteIdNotExists() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); + siteModel.setGuid("wrongFavoriteId"); + + restClient.withCoreAPI().usingAuthUser() + .deleteSiteFromFavorites(siteModel).assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "wrongFavoriteId")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that status code is 404 if FavoriteID is incorrect - favorite folder.") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION}) + public void deleteFavoriteFolderIfFavoriteIdNotExists() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); + restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(folderModel); + + folderModel.setNodeRef("wrongFavoriteId"); + restClient.withCoreAPI().usingAuthUser() + .deleteFolderFromFavorites(folderModel).assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "wrongFavoriteId")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify admin is not able to deletes files from favorites that were already deleted with Rest API and status code is (404)") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void adminIsNotAbleToDeleteADeletedFavoriteFile() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFileToFavorites(fileModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.withCoreAPI().usingAuthUser().deleteFileFromFavorites(fileModel).assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withCoreAPI().usingAuthUser().getFavorites() + .assertThat() + .entriesListDoesNotContain("targetGuid", fileModel.getNodeRefWithoutVersion()); + + restClient.withCoreAPI().usingAuthUser().deleteFileFromFavorites(fileModel) + .assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, + adminUserModel.getUsername(), fileModel.getNodeRef())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify user can't delete favorites using an invalid network ID.") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void userIsNotAbleToDeleteFavoriteSiteWithInvalidNetworkID() throws Exception + { + UserModel networkUserModel = dataUser.createRandomTestUser(); + restClient.authenticateUser(networkUserModel).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + networkUserModel.setDomain("invalidNetwork"); + + restClient.withCoreAPI() + .usingAuthUser().deleteSiteFromFavorites(siteModel) + .assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) + .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify contributor user doesn't have permission to delete favorites of another user with Rest API and status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void adminDeletesFavoriteForNotFavouriteFile() throws Exception + { + fileModel = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser() + .deleteFileFromFavorites(fileModel) + .assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, + adminUserModel.getUsername(), fileModel.getNodeRef())) + .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/favorites/FavoritesIncludePathTests.java b/e2e-test/src/test/java/org/alfresco/rest/favorites/FavoritesIncludePathTests.java new file mode 100644 index 000000000..dcbba231f --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/favorites/FavoritesIncludePathTests.java @@ -0,0 +1,143 @@ +package org.alfresco.rest.favorites; + +import static org.alfresco.utility.report.log.Step.STEP; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Class includes Sanity tests for the favorites api. Detailed tests would be covered in the alfresco-remote-api test project + * + * @author meenal bhave + */ +public class FavoritesIncludePathTests extends RestTest +{ + private UserModel adminUser; + private UserModel testUser1; + + private SiteModel siteModel1; + + private FolderModel folder1; + + private FileModel file1; + + private FolderModel subFolder1; + private FileModel fileInSubFolder; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + restClient.authenticateUser(adminUser); + + // Create Standard User + testUser1 = dataUser.usingUser(adminUser).createRandomTestUser(); + + // Create Site + siteModel1 = dataSite.usingUser(testUser1).createPublicRandomSite(); + + folder1 = dataContent.usingUser(adminUser).usingSite(siteModel1).createFolder(); + subFolder1 = dataContent.usingUser(adminUser).usingResource(folder1).createFolder(); + file1 = dataContent.usingUser(adminUser).usingResource(folder1).createContent(DocumentType.TEXT_PLAIN); + fileInSubFolder = dataContent.usingUser(adminUser).usingResource(subFolder1).createContent(DocumentType.TEXT_PLAIN); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify that get favorite site request does not include Path") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION}) + public void testGetFavoriteIncludePathForSite() throws Exception + { + restClient.authenticateUser(testUser1).withCoreAPI().usingAuthUser().includePath().getFavorite(siteModel1.getGuid()); + restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.onResponse().assertThat().body("entry.target.site.id", org.hamcrest.Matchers.equalTo(siteModel1.getId()));//(org.hamcrest.Matchers.nullValue())); + restClient.onResponse().assertThat().body("entry.target.site.path", org.hamcrest.Matchers.is(org.hamcrest.Matchers.nullValue())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify that get favorite file or folder request includes path when requested") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION}) + public void testGetFavouriteIncludePathForFileFolder() throws Exception + { + STEP("1. Favourite Folder and File"); + restClient.authenticateUser(testUser1).withCoreAPI().usingAuthUser().addFolderToFavorites(folder1); + restClient.authenticateUser(testUser1).withCoreAPI().usingAuthUser().addFileToFavorites(file1); + + STEP("2. Check Path for Folder: Displayed when requested"); + restClient.authenticateUser(testUser1).withCoreAPI().usingAuthUser().includePath().getFavorite(folder1.getNodeRefWithoutVersion()); + restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.onResponse().assertThat().body("entry.target.folder.id", org.hamcrest.Matchers.equalTo(folder1.getNodeRefWithoutVersion())); + restClient.onResponse().assertThat().body("entry.target.folder.path", org.hamcrest.Matchers.notNullValue()); + + STEP("3. Check Path for file: Displayed when requested"); + restClient.authenticateUser(testUser1).withCoreAPI().usingAuthUser().includePath().getFavorite(file1.getNodeRefWithoutVersion()); + restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.onResponse().assertThat().body("entry.target.file.id", org.hamcrest.Matchers.equalTo(file1.getNodeRefWithoutVersion())); + restClient.onResponse().assertThat().body("entry.target.file.path", org.hamcrest.Matchers.notNullValue()); + + STEP("4. Check Path for Folder: Not Displayed when not requested"); + restClient.authenticateUser(testUser1).withCoreAPI().usingAuthUser().getFavorite(folder1.getNodeRefWithoutVersion()); + restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.onResponse().assertThat().body("entry.target.folder.id", org.hamcrest.Matchers.equalTo(folder1.getNodeRefWithoutVersion())); + restClient.onResponse().assertThat().body("entry.target.folder.path", org.hamcrest.Matchers.nullValue()); + + STEP("5. Check Path for file: Not Displayed when not requested"); + restClient.authenticateUser(testUser1).withCoreAPI().usingAuthUser().getFavorite(file1.getNodeRefWithoutVersion()); + restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.onResponse().assertThat().body("entry.target.file.id", org.hamcrest.Matchers.equalTo(file1.getNodeRefWithoutVersion())); + restClient.onResponse().assertThat().body("entry.target.file.path", org.hamcrest.Matchers.nullValue()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify path in get favorites") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION}) + public void testGetFavouritesIncludePath() throws Exception + { + STEP("1. Favourite Folder and File"); + restClient.authenticateUser(testUser1).withCoreAPI().usingAuthUser().addFolderToFavorites(folder1); + restClient.authenticateUser(testUser1).withCoreAPI().usingAuthUser().addFileToFavorites(file1); + + STEP("2. Check Path: Displayed when appropriate"); + restClient.authenticateUser(testUser1).withCoreAPI().usingAuthUser().includePath().getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + // Folder + restClient.onResponse().assertThat().body("list.entries.entry.target.folder.id", org.hamcrest.Matchers.contains(folder1.getNodeRefWithoutVersion())); + restClient.onResponse().assertThat().body("list.entries.entry.target.folder.path", org.hamcrest.Matchers.notNullValue()); + // File + restClient.onResponse().assertThat().body("list.entries.entry.target.file.id", org.hamcrest.Matchers.contains(file1.getNodeRefWithoutVersion())); + restClient.onResponse().assertThat().body("list.entries.entry.target.file.path", org.hamcrest.Matchers.notNullValue()); + // Site + restClient.onResponse().assertThat().body("list.entries.entry.target.site.id", org.hamcrest.Matchers.contains(siteModel1.getId())); + restClient.onResponse().assertThat().body("list.entries.entry.target.site.path", org.hamcrest.Matchers.contains(org.hamcrest.Matchers.nullValue())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify path in post favorites") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION}) + public void testPostFavouritesIncludePath() throws Exception + { + STEP("1. Favourite Site"); + restClient.authenticateUser(testUser1).withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel1); + restClient.authenticateUser(testUser1).withCoreAPI().usingAuthUser().usingParams("include=path").addFavoriteSite(siteModel1); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.onResponse().assertThat().body("entry.id", org.hamcrest.Matchers.equalTo(siteModel1.getId())); + restClient.onResponse().assertThat().body("entry.path", org.hamcrest.Matchers.nullValue()); + + STEP("2. Favourite Folder"); + restClient.authenticateUser(testUser1).withCoreAPI().usingAuthUser().usingParams("include=path").addFolderToFavorites(subFolder1); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.onResponse().assertThat().body("entry.target.folder.id", org.hamcrest.Matchers.equalTo(subFolder1.getNodeRefWithoutVersion())); + restClient.onResponse().assertThat().body("entry.target.folder.path", org.hamcrest.Matchers.notNullValue()); + + STEP("3. Favourite File"); + restClient.authenticateUser(testUser1).withCoreAPI().usingAuthUser().includePath().addFileToFavorites(fileInSubFolder); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.onResponse().assertThat().body("entry.target.file.id", org.hamcrest.Matchers.equalTo(fileInSubFolder.getNodeRefWithoutVersion())); + restClient.onResponse().assertThat().body("entry.target.file.path", org.hamcrest.Matchers.notNullValue()); + } +} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/rest/favorites/FavoritesNetworkTests.java b/e2e-test/src/test/java/org/alfresco/rest/favorites/FavoritesNetworkTests.java new file mode 100644 index 000000000..6690a75ed --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/favorites/FavoritesNetworkTests.java @@ -0,0 +1,292 @@ +package org.alfresco.rest.favorites; + +import org.alfresco.rest.NetworkDataPrep; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class FavoritesNetworkTests extends NetworkDataPrep +{ + private SiteModel publicSite, siteModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + init(); + siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.NETWORKS, TestGroup.REGRESSION}) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE}, executionType = ExecutionType.REGRESSION, + description = "Verify tenant user is able to add to favorites his site and status code is (201)") + public void tenantAddFavoriteSiteValidNetwork() throws Exception + { + publicSite = dataSite.usingUser(tenantUser).createPublicRandomSite(); + + restClient.authenticateUser(tenantUser).withCoreAPI(); + + restClient.withCoreAPI() + .usingAuthUser().addSiteToFavorites(publicSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.withCoreAPI().usingAuthUser().getFavorites() + .assertThat() + .entriesListContains("targetGuid", publicSite.getGuidWithoutVersion()); + } + + @Bug(id="MNT-16904") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.NETWORKS, TestGroup.REGRESSION}) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify tenant user is not able to add favorites using an invalid network ID - status code (401)") + public void tenantIsNotAbleToAddFavoriteSiteWithInvalidNetworkID() throws Exception + { + publicSite = dataSite.usingUser(tenantUser).createPublicRandomSite(); + + restClient.authenticateUser(tenantUser).withCoreAPI(); + String domain = tenantUser.getDomain(); + try + { + tenantUser.setDomain("invalidNetwork"); + + restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(publicSite); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + finally + { + tenantUser.setDomain(domain); + } + } + + @Bug(id="MNT-16904") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE}, executionType = ExecutionType.REGRESSION, + description = "Verify tenant user is not able to remove favorites using an invalid network ID") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.NETWORKS, TestGroup.REGRESSION }) + public void tenantIsNotAbleToRemoveFavoriteSiteWithInvalidNetworkID() throws Exception + { + SiteModel siteModel = dataSite.usingUser(tenantUser).createPublicRandomSite(); + + restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + String domain = tenantUser.getDomain(); + try + { + tenantUser.setDomain("invalidNetwork"); + + restClient.withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + finally + { + tenantUser.setDomain(domain); + } + } + + @Bug(id="MNT-16904") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify tenant user is not able to delete favorites using an invalid network ID") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES,TestGroup.NETWORKS, TestGroup.REGRESSION }) + public void tenantIsNotAbleToDeleteFavoriteSiteWithInvalidNetworkID() throws Exception + { + restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + String domain = tenantUser.getDomain(); + try + { + tenantUser.setDomain("invalidNetwork"); + + restClient.withCoreAPI() + .usingAuthUser().deleteSiteFromFavorites(siteModel) + .assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + finally + { + tenantUser.setDomain(domain); + } + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.NETWORKS, TestGroup.REGRESSION}) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE}, executionType = ExecutionType.REGRESSION, + description = "Verify tenant user is able to add to favorites a site created by admin tenant - same network and status code is (201)") + public void tenantUserIsAbleToAddFavoriteSiteAddedByAdminSameNetwork() throws Exception + { + publicSite = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); + + restClient.authenticateUser(tenantUser).withCoreAPI(); + tenantUser.setDomain(adminTenantUser.getDomain()); + + restClient.withCoreAPI().usingAuthUser().addFavoriteSite(publicSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.withCoreAPI().usingAuthUser().getFavorites() + .assertThat() + .entriesListContains("targetGuid", publicSite.getGuidWithoutVersion()); + } + + @Bug(id = "MNT-16904") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify the get favorites request when network id is invalid for tenant user") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION, TestGroup.NETWORKS}) + public void getFavoriteSitesWhenNetworkIdIsInvalid() throws Exception + { + SiteModel firstSiteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + + restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); + + String domain = tenantUser.getDomain(); + try + { + tenantUser.setDomain("invalidNetwork"); + restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + finally + { + tenantUser.setDomain(domain); + } + } + + @Bug(id = "MNT-16904") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify the post favorites request when network id is invalid for tenant user") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION, TestGroup.NETWORKS}) + public void addFavoriteSitesWhenNetworkIdIsInvalid() throws Exception + { + String domain = tenantUser.getDomain(); + try + { + tenantUser.setDomain("invalidNetwork"); + restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + finally{ + tenantUser.setDomain(domain); + } + } + + @Bug(id = "MNT-16904") + @TestRail(section = { TestGroup.REST_API, + TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify the get favorite request for invalid network id") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void getFavoriteSiteWithInvalidNetworkId() throws Exception + { + restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + + String domain = tenantUser.getDomain(); + try + { + tenantUser.setDomain("invalidNetwork"); + restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().getFavorite(siteModel.getGuid()); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + finally + { + tenantUser.setDomain(domain); + } + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify the get favorite request with tenant user") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void getFavoriteSiteWithTenantUser() throws Exception + { + restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + + restClient.withCoreAPI().usingAuthUser().getFavorite(siteModel.getGuid()); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE}, executionType = ExecutionType.REGRESSION, + description = "Verify tenant user deletes favorites site and status code is (204)") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.NETWORKS, TestGroup.REGRESSION }) + public void tenantRemoveFavoriteSiteValidNetwork() throws Exception + { + SiteModel siteModel = dataSite.usingUser(tenantUser).createPublicRandomSite(); + restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + + restClient.withCoreAPI() + .usingAuthUser().removeFavoriteSite(siteModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingAuthUser().getFavorites() + .assertThat() + .entriesListDoesNotContain("targetGuid", siteModel.getGuidWithoutVersion()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES}, executionType = ExecutionType.REGRESSION, + description = "Verify tenant user deletes favorites site and status code is (204)") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES,TestGroup.NETWORKS, TestGroup.REGRESSION }) + public void tenantDeleteFavoriteSiteValidNetwork() throws Exception + { + + restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + + restClient.withCoreAPI() + .usingAuthUser().deleteSiteFromFavorites(siteModel) + .assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingAuthUser().getFavorites() + .assertThat() + .entriesListDoesNotContain("targetGuid", siteModel.getGuidWithoutVersion()); + siteModel = dataSite.usingUser(tenantUser).createPublicRandomSite(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE}, executionType = ExecutionType.REGRESSION, + description = "Verify tenant user remove favorites site created by admin tenant - same network and status code is (204)") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.NETWORKS, TestGroup.REGRESSION }) + public void tenantUserIsAbleToRemoveFavoriteSiteAddedByAdminSameNetwork() throws Exception + { + SiteModel siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); + + restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + tenantUser.setDomain(adminTenantUser.getDomain()); + + restClient.withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingAuthUser().getFavorites() + .assertThat() + .entriesListDoesNotContain("targetGuid", siteModel.getGuidWithoutVersion()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES}, executionType = ExecutionType.REGRESSION, + description = "Verify tenant user deletes favorites site created by admin tenant - same network and status code is (204)") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES,TestGroup.NETWORKS, TestGroup.REGRESSION }) + public void tenantUserIsAbleToDeleteFavoriteSiteAddedByAdminSameNetwork() throws Exception + { + + restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + tenantUser.setDomain(adminTenantUser.getDomain()); + + restClient.withCoreAPI() + .usingAuthUser().deleteSiteFromFavorites(siteModel) + .assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingAuthUser().getFavorites() + .assertThat() + .entriesListDoesNotContain("targetGuid", siteModel.getGuidWithoutVersion()); + siteModel = dataSite.usingUser(tenantUser).createPublicRandomSite(); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/favorites/GetFavoriteSiteTests.java b/e2e-test/src/test/java/org/alfresco/rest/favorites/GetFavoriteSiteTests.java new file mode 100644 index 000000000..9cdc776aa --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/favorites/GetFavoriteSiteTests.java @@ -0,0 +1,292 @@ +package org.alfresco.rest.favorites; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.dataprep.SiteService; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestSiteModel; +import org.alfresco.rest.model.RestSiteModelsCollection; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Tests for Get Favorite Sites (/people/{personId}/preferences) RestAPI call + * + * @author Cristina Axinte + */ + +public class GetFavoriteSiteTests extends RestTest +{ + private UserModel userModel; + private SiteModel siteModel1; + private SiteModel siteModel2; + private RestSiteModel restSiteModel; + private DataUser.ListUserWithRoles usersWithRoles; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + siteModel1 = dataSite.usingUser(userModel).createPublicRandomSite(); + siteModel2 = dataSite.usingUser(userModel).createPublicRandomSite(); + + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel1, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + + dataSite.usingUser(userModel).usingSite(siteModel1).addSiteToFavorites(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user gets its specific favorite site with Rest API and response is successful (200)") + public void managerUserGetsFavoriteSiteWithSuccess() throws Exception + { + UserModel managerUser = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); + + dataSite.usingUser(managerUser).usingSite(siteModel1).addSiteToFavorites(); + dataSite.usingUser(managerUser).usingSite(siteModel2).addSiteToFavorites(); + + restSiteModel = restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().getFavoriteSite(siteModel1); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteModel.assertThat().field("id").is(siteModel1.getId()).and().field("title").isNotNull(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify collaborator user gets its specific favorite site with Rest API and response is successful (200)") + public void collaboratorUserGetsFavoriteSiteWithSuccess() throws Exception + { + UserModel collaboratorUser = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); + + dataSite.usingUser(collaboratorUser).usingSite(siteModel1).addSiteToFavorites(); + dataSite.usingUser(collaboratorUser).usingSite(siteModel2).addSiteToFavorites(); + + restSiteModel = restClient.authenticateUser(collaboratorUser).withCoreAPI().usingAuthUser().getFavoriteSite(siteModel1); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteModel.assertThat().field("id").is(siteModel1.getId()).and().field("title").isNotNull(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify contributor user gets its specific favorite site with Rest API and response is successful (200)") + public void contributorUserGetsFavoriteSiteWithSuccess() throws Exception + { + UserModel contributorUser = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); + + dataSite.usingUser(contributorUser).usingSite(siteModel1).addSiteToFavorites(); + dataSite.usingUser(contributorUser).usingSite(siteModel2).addSiteToFavorites(); + + restSiteModel = restClient.authenticateUser(contributorUser).withCoreAPI().usingAuthUser().getFavoriteSite(siteModel1); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteModel.assertThat().field("id").is(siteModel1.getId()).and().field("title").isNotNull(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify consumer user gets its specific favorite site with Rest API and response is successful (200)") + public void consumerUserGetsFavoriteSiteWithSuccess() throws Exception + { + UserModel consumerUser = usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer); + + dataSite.usingUser(consumerUser).usingSite(siteModel1).addSiteToFavorites(); + dataSite.usingUser(consumerUser).usingSite(siteModel2).addSiteToFavorites(); + + restSiteModel = restClient.authenticateUser(consumerUser).withCoreAPI().usingAuthUser().getFavoriteSite(siteModel1); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteModel.assertThat().field("id").is(siteModel1.getId()).and().field("title").isNotNull(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin user gets specific favorite site of any user with Rest API and response is successful (200)") + public void adminUserGetsAnyFavoriteSiteWithSuccess() throws Exception + { + UserModel adminUser = dataUser.getAdminUser(); + UserModel anyUser = dataUser.usingAdmin().createRandomTestUser(); + dataSite.usingUser(anyUser).usingSite(siteModel1).addSiteToFavorites(); + dataSite.usingUser(anyUser).usingSite(siteModel2).addSiteToFavorites(); + + restSiteModel = restClient.authenticateUser(adminUser).withCoreAPI().usingUser(anyUser).getFavoriteSite(siteModel1); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteModel.assertThat().field("id").is(siteModel1.getId()).and().field("title").isNotNull(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify manager user fails to get specific favorite site of another user with Rest API and response is successful (403)") + public void managerUserFailsToGetFavoriteSiteOfAnotherUser() throws Exception + { + UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel1, UserRole.SiteManager); + dataSite.usingUser(managerUser).usingSite(siteModel1).addSiteToFavorites(); + dataSite.usingUser(managerUser).usingSite(siteModel2).addSiteToFavorites(); + + restClient.authenticateUser(managerUser).withCoreAPI().usingUser(userModel).getFavoriteSite(siteModel1); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized gets its specific favorite site with Rest API when authentication fails (401)") +// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") + public void managerUserNotAuthorizedFailsToGetFavoriteSite() throws Exception + { + UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel1, UserRole.SiteManager); + dataSite.usingUser(managerUser).usingSite(siteModel1).addSiteToFavorites(); + dataSite.usingUser(managerUser).usingSite(siteModel2).addSiteToFavorites(); + managerUser.setPassword("newpassword"); + + restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().getFavoriteSite(siteModel1); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify invalid request returns status 404 when personId does not exist") + public void getFavoriteSiteWithNonExistentPersonId() throws Exception + { + UserModel someUser = new UserModel("someUser", DataUser.PASSWORD); + + restClient.authenticateUser(userModel).withCoreAPI().usingUser(someUser).getFavoriteSite(siteModel1); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "someUser")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify invalid request returns status 404 when siteId does not exist") + public void getFavoriteSiteWithNonExistentSiteId() throws Exception + { + SiteModel nonExistentSite = new SiteModel("nonExistentSite"); + + restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().getFavoriteSite(nonExistentSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, userModel.getUsername(), nonExistentSite.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify User fails to get specific favorite site of admin with Rest API and response is 403") + public void userFailsToGetFavoriteSiteOfAdmin() throws Exception + { + restClient.authenticateUser(userModel).withCoreAPI().usingUser(dataUser.getAdminUser()).getFavoriteSite(siteModel1); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify request with empty site id") + public void getFavoriteSiteWithEmptySiteId() throws Exception + { + restClient.authenticateUser(userModel).withCoreAPI(); + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "people/{personId}/favorite-sites/{siteId}?{parameters}", + userModel.getUsername(), "", restClient.getParameters()); + RestSiteModelsCollection sites = restClient.processModels(RestSiteModelsCollection.class, request); + restClient.assertStatusCodeIs(HttpStatus.OK); + sites.assertThat().entriesListIsNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify invalid request returns status 401 when user is empty") + public void getFavoriteSiteWithEmptyPersonId() throws Exception + { + UserModel emptyUser = new UserModel("", "password"); + restClient.authenticateUser(emptyUser).withCoreAPI().usingAuthUser().getFavoriteSite(siteModel1); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify invalid request returns status 404 when another user get favorite site of an user") + public void getFavoriteSiteWithAnotherUser() throws Exception + { + UserModel user = dataUser.createRandomTestUser(); + restClient.authenticateUser(user).withCoreAPI().usingAuthUser().getFavoriteSite(siteModel1); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, user.getUsername(), siteModel1.getId())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE) + .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify request returns status 200 when using -me-") + public void getFavoriteSiteUsingMe() throws Exception + { + restSiteModel = restClient.authenticateUser(userModel).withCoreAPI().usingMe().getFavoriteSite(siteModel1); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteModel.assertThat().field("id").is(siteModel1.getId()) + .and().field("title").is(siteModel1.getTitle()) + .and().field("role").is(UserRole.SiteManager.toString()) + .and().field("visibility").is(SiteService.Visibility.PUBLIC.toString()) + .and().field("guid").isNotEmpty() + .and().field("description").is(siteModel1.getDescription()) + .and().field("preset").is("site-dashboard"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify invalid request returns status 404 when providing folder name instead of site id") + public void getFavoriteSiteUsingFolder() throws Exception + { + FolderModel folder = dataContent.usingUser(userModel).usingSite(siteModel1).createFolder(); + SiteModel siteFolder = new SiteModel(folder.getName()); + restSiteModel = restClient.authenticateUser(userModel).withCoreAPI().usingMe().getFavoriteSite(siteFolder); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, userModel.getUsername(), folder.getName())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify invalid request returns status 404 when providing file name instead of site id") + public void getFavoriteSiteUsingFile() throws Exception + { + FileModel file = dataContent.usingSite(siteModel1).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + SiteModel siteFolder = new SiteModel(file.getName()); + restSiteModel = restClient.authenticateUser(userModel).withCoreAPI().usingMe().getFavoriteSite(siteFolder); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, userModel.getUsername(), file.getName())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify request returns status 200 when using valid parameters") + public void getFavoriteSiteUsingParameters() throws Exception + { + restSiteModel = restClient.withParams("maxItems=100").authenticateUser(userModel).withCoreAPI().usingMe().getFavoriteSite(siteModel1); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteModel.assertThat().field("id").is(siteModel1.getId()) + .and().field("title").is(siteModel1.getTitle()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify request returns status 400 when using maxItems=0") + public void getFavoriteSiteUsingInvalidMaxItems() throws Exception + { + restSiteModel = restClient.withParams("maxItems=0").authenticateUser(userModel).withCoreAPI().usingMe().getFavoriteSite(siteModel1); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify request returns status 401 when using invalid network") + public void getFavoriteSiteUsingInvalidNetwork() throws Exception + { + UserModel invalidUserNetwork = dataUser.createRandomTestUser(); + SiteModel site = dataSite.usingUser(invalidUserNetwork).createPublicRandomSite(); + dataSite.usingUser(invalidUserNetwork).usingSite(site).addSiteToFavorites(); + invalidUserNetwork.setDomain("invalidNetwork"); + restSiteModel = restClient.authenticateUser(invalidUserNetwork).withCoreAPI().usingMe().getFavoriteSite(site); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/favorites/GetFavoriteSitesTests.java b/e2e-test/src/test/java/org/alfresco/rest/favorites/GetFavoriteSitesTests.java new file mode 100644 index 000000000..db6dd2f90 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/favorites/GetFavoriteSitesTests.java @@ -0,0 +1,325 @@ +package org.alfresco.rest.favorites; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestSiteModel; +import org.alfresco.rest.model.RestSiteModelsCollection; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.data.RandomData; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class GetFavoriteSitesTests extends RestTest +{ + private UserModel userModel, testUser1; + private SiteModel siteModel, testSite1, testSite2, testSite3; + private RestSiteModelsCollection restSiteModelsCollection; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + testUser1 = dataUser.createRandomTestUser(); + + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + testSite1 = new SiteModel("A-" + RandomData.getRandomAlphanumeric()); + testSite2 = new SiteModel("B-" + RandomData.getRandomAlphanumeric()); + testSite3 = new SiteModel("C-" + RandomData.getRandomAlphanumeric()); + + dataSite.usingUser(userModel).usingSite(siteModel).addSiteToFavorites(); + + dataSite.usingUser(testUser1).createSite(testSite1); + dataSite.usingUser(testUser1).createSite(testSite2); + dataSite.usingUser(testUser1).createSite(testSite3); + + dataSite.usingUser(testUser1).usingSite(testSite3).addSiteToFavorites(); + dataSite.usingUser(testUser1).usingSite(testSite2).addSiteToFavorites(); + dataSite.usingUser(testUser1).usingSite(testSite1).addSiteToFavorites(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify manager user fails to get an user favorite sites with Rest API (403)") + public void managerUserFailsToGetAnUserFavoriteSites() throws Exception + { + UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); + UserModel anotherUser = dataUser.usingAdmin().createRandomTestUser(); + dataSite.usingUser(anotherUser).usingSite(siteModel).addSiteToFavorites(); + + restClient.authenticateUser(managerUser).withCoreAPI().usingUser(anotherUser).getFavoriteSites(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify collaborator user fails to get an user favorite sites with Rest API (403)") + public void collaboratorUserFailsToGetAnUserFavoriteSites() throws Exception + { + UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(collaboratorUser, siteModel, UserRole.SiteCollaborator); + UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(contributorUser, siteModel, UserRole.SiteContributor); + dataSite.usingUser(contributorUser).usingSite(siteModel).addSiteToFavorites(); + + restClient.authenticateUser(collaboratorUser).withCoreAPI().usingUser(contributorUser).getFavoriteSites(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify contributor user fails to get an user favorite sites with Rest API (403)") + public void contributorUserFailsToGetAnUserFavoriteSites() throws Exception + { + UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); + UserModel contributorUser2 = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(contributorUser, siteModel, UserRole.SiteContributor); + dataUser.usingUser(userModel).addUserToSite(contributorUser2, siteModel, UserRole.SiteContributor); + dataSite.usingUser(contributorUser2).usingSite(siteModel).addSiteToFavorites(); + + restClient.authenticateUser(contributorUser).withCoreAPI().usingUser(contributorUser2).getFavoriteSites(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify consumer user fails to get an user favorite sites with Rest API (403)") + public void consumerUserFailsToGetAnUserFavoriteSites() throws Exception + { + UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); + UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel, UserRole.SiteConsumer); + dataUser.usingUser(collaboratorUser).addUserToSite(collaboratorUser, siteModel, UserRole.SiteCollaborator); + dataSite.usingUser(collaboratorUser).usingSite(siteModel).addSiteToFavorites(); + + restClient.authenticateUser(consumerUser).withCoreAPI().usingUser(collaboratorUser).getFavoriteSites(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify any user gets its own user favorite sites with Rest API and response is successful (200)") + public void anyUserGetsHisFavoriteSites() throws Exception + { + UserModel anyUser = dataUser.usingAdmin().createRandomTestUser(); + dataSite.usingUser(anyUser).usingSite(siteModel).addSiteToFavorites(); + + restSiteModelsCollection = restClient.authenticateUser(anyUser).withCoreAPI().usingAuthUser().getFavoriteSites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteModelsCollection.assertThat().entriesListIsNotEmpty().and().entriesListContains("id", siteModel.getId()).and().paginationExist(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify any user is NOT Authorized to get its favorite sites with Rest API when authentication fails (401)") +// @Bug(id = "MNT-16904", description = "It fails only on environment with tenants") + public void unauthenticatedUserIsNotAuthorizedToGetFavoriteSites() throws Exception + { + UserModel anyUser = dataUser.usingAdmin().createRandomTestUser(); + dataSite.usingUser(anyUser).usingSite(siteModel).addSiteToFavorites(); + anyUser.setPassword("newpassword"); + + restClient.authenticateUser(anyUser).withCoreAPI().usingAuthUser().getFavoriteSites(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify that getFavoriteSites request status code is 404 for a personId that does not exist") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void getFavoriteSitesReturns404ForAPersonIdThatDoesNotExist() throws Exception + { + UserModel invalidUser = new UserModel(RandomData.getRandomName("User"), DataUser.PASSWORD); + + restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingUser(invalidUser).getFavoriteSites(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, invalidUser.getUsername())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify that getFavoriteSites request status code is 403 if the user doesn't have access to the person favorite sites") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void userCannotGetFavoriteSitesForAnotherUser() throws Exception + { + restClient.authenticateUser(userModel).withCoreAPI().usingUser(testUser1).getFavoriteSites(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin has access to regular user site favorites") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void adminCanGetFavoriteSitesForARegularUser() throws Exception + { + restSiteModelsCollection = restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingUser(userModel).getFavoriteSites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteModelsCollection.assertThat().entriesListIsNotEmpty() + .assertThat().entriesListContains("id", siteModel.getId()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify that regular user can not see admin user site favorites") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void regularUserCannotGetFavoriteSitesForAdminUser() throws Exception + { + restClient.authenticateUser(testUser1).withCoreAPI().usingUser(dataUser.getAdminUser()).getFavoriteSites(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify that favorite site can be removed") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void verifyThatFavoriteSiteCanBeRemoved() throws Exception + { + UserModel randomTestUser = dataUser.createRandomTestUser(); + dataSite.usingUser(randomTestUser).usingSite(siteModel).addSiteToFavorites(); + + restSiteModelsCollection = restClient.authenticateUser(randomTestUser).withCoreAPI().usingAuthUser().getFavoriteSites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteModelsCollection.assertThat().entriesListIsNotEmpty() + .assertThat().entriesListContains("id", siteModel.getId()); + + dataSite.usingUser(randomTestUser).usingSite(siteModel).removeSiteFromFavorites(); + restSiteModelsCollection = restClient.withCoreAPI().usingAuthUser().getFavoriteSites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteModelsCollection.assertThat().entriesListIsEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify that if maxItems param is invalid status code returned is BAD_REQUEST (400)") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void getFavoriteSitesMaxItemsInvalidValueTest() throws Exception + { + restClient.authenticateUser(userModel).withParams("maxItems=-1").withCoreAPI().usingAuthUser().getFavoriteSites(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); + + restClient.authenticateUser(userModel).withParams("maxItems=abc").withCoreAPI().usingAuthUser().getFavoriteSites(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "abc")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify that if skipCount param is invalid status code returned is BAD_REQUEST (400)") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void getFavoriteSitesSkipCountInvalidValueTest() throws Exception + { + restClient.authenticateUser(userModel).withParams("skipCount=-1").withCoreAPI().usingAuthUser().getFavoriteSites(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT); + + restClient.authenticateUser(userModel).withParams("skipCount=abc").withCoreAPI().usingAuthUser().getFavoriteSites(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "abc")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify that getFavoriteSites request response status using -me- string in place of personId is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void userGetsFavoriteSiteWithSuccessUsingMEForRequest() throws Exception + { + restSiteModelsCollection = restClient.authenticateUser(testUser1).withCoreAPI().usingMe().getFavoriteSites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteModelsCollection.assertThat().entriesListIsNotEmpty() + .and().entriesListContains("id", testSite1.getId()) + .and().paginationExist(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify that getFavoriteSites request response status for a user that has no favorite sites is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void getFavoriteSiteRequestForUserWithNoFavoriteSitesIsSuccessful() throws Exception + { + UserModel randomTestUser = dataUser.createRandomTestUser(); + + restSiteModelsCollection = restClient.authenticateUser(randomTestUser).withCoreAPI().usingMe().getFavoriteSites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteModelsCollection.assertThat().entriesListIsEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify that getFavoriteSites request response status for a user with several favorite sites is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void getFavoriteSiteRequestForUserWithSeveralFavoriteSitesIsSuccessful() throws Exception + { + restSiteModelsCollection = restClient.authenticateUser(testUser1).withCoreAPI().usingAuthUser().getFavoriteSites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteModelsCollection.assertThat().entriesListIsNotEmpty() + .and().entriesListContains("id", testSite1.getId()) + .and().entriesListContains("id", testSite2.getId()) + .and().entriesListContains("id", testSite3.getId()) + .and().paginationExist(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify that getFavoriteSites request can only be called with a positive maxItems param") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void userCanNotGetFavoriteSitesWith0MaxItems() throws Exception + { + restClient.authenticateUser(testUser1).withParams("maxItems=0").withCoreAPI().usingAuthUser().getFavoriteSites(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsErrorKey(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) + .containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify that getFavoriteSites request response status code for a high skipCount param is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void userCanGetFavoriteSitesWithHighSkipCount() throws Exception + { + restSiteModelsCollection = restClient.authenticateUser(testUser1).withParams("skipCount=999999999").withCoreAPI().usingAuthUser().getFavoriteSites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteModelsCollection.assertThat().entriesListIsEmpty() + .assertThat().paginationField("skipCount").is("999999999"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify that user can retrieve the last 2 favorite sites") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void userCanRetrieveLast2FavoriteSites() throws Exception + { + restSiteModelsCollection = restClient.authenticateUser(testUser1).withParams("skipCount=1&maxCount=2"). + withCoreAPI().usingAuthUser().getFavoriteSites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteModelsCollection.assertThat().entriesListIsNotEmpty() + .assertThat().entriesListCountIs(2) + .assertThat().entriesListContains("id", testSite2.getId()) + .assertThat().entriesListContains("id", testSite3.getId()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify that getFavoriteSites request applies valid properties param") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void getFavoriteSitesRequestWithValidPropertiesParam() throws Exception + { + RestSiteModel restSiteModel = restClient.authenticateUser(testUser1).withParams("properties=title") + .withCoreAPI().usingAuthUser().getFavoriteSites().getOneRandomEntry().onModel(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteModel.assertThat().fieldsCount().is(1) + .assertThat().field("title").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify that getFavoriteSites request applies invalid properties param") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void getFavoriteSitesRequestWithInvalidPropertiesParam() throws Exception + { + restClient.authenticateUser(testUser1).withParams("properties=tas").withCoreAPI().usingAuthUser() + .getFavoriteSites().getOneRandomEntry().onModel().assertThat().fieldsCount().is(0); + restClient.assertStatusCodeIs(HttpStatus.OK); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/favorites/GetFavoriteTests.java b/e2e-test/src/test/java/org/alfresco/rest/favorites/GetFavoriteTests.java new file mode 100644 index 000000000..c5ededc33 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/favorites/GetFavoriteTests.java @@ -0,0 +1,480 @@ +package org.alfresco.rest.favorites; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.dataprep.SiteService; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestPersonFavoritesModel; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class GetFavoriteTests extends RestTest +{ + private UserModel adminUserModel; + private SiteModel siteModel; + private FolderModel folderModel; + private FileModel fileModel; + private ListUserWithRoles usersWithRoles; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + + folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); + fileModel = dataContent.usingUser(adminUserModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, + description = "Verify Manager user gets favorite site with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) + public void managerIsAbleToRetrieveFavoriteSite() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + + RestPersonFavoritesModel favSite = restClient.withCoreAPI().usingAuthUser().getFavorite(siteModel.getGuid()); + restClient.assertStatusCodeIs(HttpStatus.OK); + favSite.assertThat().field("targetGuid").is(siteModel.getGuid()); + + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, + description = "Verify Manager user gets favorite folder with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) + public void managerIsAbleToRetrieveFavoriteFolder() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(folderModel); + + RestPersonFavoritesModel favoriteFolder = restClient.withCoreAPI().usingAuthUser().getFavorite(folderModel.getNodeRef()); + restClient.assertStatusCodeIs(HttpStatus.OK); + favoriteFolder.assertThat().field("targetGuid").is(folderModel.getNodeRef()); + + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, + description = "Verify Manager user gets favorite file with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) + public void managerIsAbleToRetrieveFavoriteFile() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + restClient.withCoreAPI().usingAuthUser().addFileToFavorites(fileModel); + + RestPersonFavoritesModel favoriteFile = restClient.withCoreAPI().usingAuthUser().getFavorite(fileModel.getNodeRefWithoutVersion()); + restClient.assertStatusCodeIs(HttpStatus.OK); + favoriteFile.assertThat().field("targetGuid").is(fileModel.getNodeRefWithoutVersion()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, + description = "Verify user gets status code 401 if authentication call fails") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) +// @Bug(id = "MNT-16904", description = "fails only on environment with tenants") + public void userIsNotAbleToRetrieveFavoriteSiteIfAuthenticationFails() throws Exception + { + UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); + siteManager.setPassword("wrongPassword"); + restClient.authenticateUser(siteManager).withCoreAPI() + .usingUser(siteManager).getFavorite(siteModel.getGuid()); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify Admin user gets favorite site with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void adminIsAbleToRetrieveFavoritesSite() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); + + RestPersonFavoritesModel favoriteSite = restClient.withCoreAPI().usingUser(adminUserModel).getFavorite(siteModel.getGuid()); + restClient.assertStatusCodeIs(HttpStatus.OK); + favoriteSite.assertThat().field("targetGuid").is(siteModel.getGuid()); + favoriteSite.getTarget().getSite() + .assertThat().field("guid").is(siteModel.getGuid()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify Admin user gets favorite folder with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void adminIsAbleToRetrieveFavoritesFolder() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).addFolderToFavorites(folderModel); + + RestPersonFavoritesModel favoriteFolder = restClient.withCoreAPI().usingUser(adminUserModel).getFavorite(folderModel.getNodeRef()); + restClient.assertStatusCodeIs(HttpStatus.OK); + favoriteFolder.assertThat().field("targetGuid").is(folderModel.getNodeRef()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify Admin user gets favorite file with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void adminIsAbleToRetrieveFavoritesFile() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).addFileToFavorites(fileModel); + + RestPersonFavoritesModel favoriteFile = restClient.withCoreAPI().usingUser(adminUserModel).getFavorite(fileModel.getNodeRefWithoutVersion()); + restClient.assertStatusCodeIs(HttpStatus.OK); + favoriteFile.assertThat().field("targetGuid").is(fileModel.getNodeRefWithoutVersion()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify Collaborator user gets favorite site with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void collaboratorIsAbleToRetrieveFavoriteSite() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + + RestPersonFavoritesModel favSite = restClient.withCoreAPI().usingAuthUser().getFavorite(siteModel.getGuid()); + restClient.assertStatusCodeIs(HttpStatus.OK); + favSite.assertThat().field("targetGuid").is(siteModel.getGuid()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify collaborator user gets favorite folder with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void collaboratorIsAbleToRetrieveFavoriteFolder() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(folderModel); + + RestPersonFavoritesModel favoriteFolder = restClient.withCoreAPI().usingAuthUser().getFavorite(folderModel.getNodeRef()); + restClient.assertStatusCodeIs(HttpStatus.OK); + favoriteFolder.assertThat().field("targetGuid").is(folderModel.getNodeRef()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify collaborator user gets favorite file with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void collaboratorIsAbleToRetrieveFavoriteFile() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + restClient.withCoreAPI().usingAuthUser().addFileToFavorites(fileModel); + + RestPersonFavoritesModel favoriteFile = restClient.withCoreAPI().usingAuthUser().getFavorite(fileModel.getNodeRefWithoutVersion()); + restClient.assertStatusCodeIs(HttpStatus.OK); + favoriteFile.assertThat().field("targetGuid").is(fileModel.getNodeRefWithoutVersion()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify Contributor user gets favorite site with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void contributorIsAbleToRetrieveFavoriteSite() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + + RestPersonFavoritesModel favSite = restClient.withCoreAPI().usingAuthUser().getFavorite(siteModel.getGuid()); + restClient.assertStatusCodeIs(HttpStatus.OK); + favSite.assertThat().field("targetGuid").is(siteModel.getGuid()); ; + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify contributor user gets favorite folder with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void contributorIsAbleToRetrieveFavoriteFolder() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(folderModel); + + RestPersonFavoritesModel favoriteFolder = restClient.withCoreAPI().usingAuthUser().getFavorite(folderModel.getNodeRef()); + restClient.assertStatusCodeIs(HttpStatus.OK); + favoriteFolder.assertThat().field("targetGuid").is(folderModel.getNodeRef()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify contributor user gets favorite file with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void contributorIsAbleToRetrieveFavoriteFile() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + restClient.withCoreAPI().usingAuthUser().addFileToFavorites(fileModel); + + RestPersonFavoritesModel favoriteFile = restClient.withCoreAPI().usingAuthUser().getFavorite(fileModel.getNodeRefWithoutVersion()); + restClient.assertStatusCodeIs(HttpStatus.OK); + favoriteFile.assertThat().field("targetGuid").is(fileModel.getNodeRefWithoutVersion()); + } + + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify Consumer user gets favorite site with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void consumerIsAbleToRetrieveFavorites() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + + RestPersonFavoritesModel favSite = restClient.withCoreAPI().usingAuthUser().getFavorite(siteModel.getGuid()); + restClient.assertStatusCodeIs(HttpStatus.OK); + favSite.assertThat().field("targetGuid").is(siteModel.getGuid()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify consumer user gets favorite folder with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void consumerIsAbleToRetrieveFavoriteFolder() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(folderModel); + + RestPersonFavoritesModel favoriteFolder = restClient.withCoreAPI().usingAuthUser().getFavorite(folderModel.getNodeRef()); + restClient.assertStatusCodeIs(HttpStatus.OK); + favoriteFolder.assertThat().field("targetGuid").is(folderModel.getNodeRef()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify consumer user gets favorite file with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void consumerIsAbleToRetrieveFavoriteFile() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + restClient.withCoreAPI().usingAuthUser().addFileToFavorites(fileModel); + + RestPersonFavoritesModel favoriteFile = restClient.withCoreAPI().usingAuthUser().getFavorite(fileModel.getNodeRefWithoutVersion()); + restClient.assertStatusCodeIs(HttpStatus.OK); + favoriteFile.assertThat().field("targetGuid").is(fileModel.getNodeRefWithoutVersion()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify user doesn't get favorite site of another user with Rest API and status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void userIsNotAbleToRetrieveFavoriteSiteOfAnotherSiteMember() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + restClient.withCoreAPI().usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .getFavorite(siteModel.getGuid()); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator).getUsername())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify user doesn't get favorite site of admin user with Rest API and status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void userIsNotAbleToRetrieveFavoritesOfAdminUser() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + .withCoreAPI().usingUser(adminUserModel).getFavorite(siteModel.getGuid()); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, adminUserModel.getUsername())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify admin user doesn't get favorite site of another user with Rest API and status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void adminIsNotAbleToRetrieveFavoritesOfAnotherUser() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI() + .usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).getFavorite(siteModel.getGuid()); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator).getUsername())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, + executionType = ExecutionType.REGRESSION, description = "Verify get favorite user doesn't have any favorite site, file or folder") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void getFavoriteSiteForUserWithoutAnyFavorites() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + restClient.withCoreAPI().usingAuthUser().getFavorite(siteModel.getGuid()); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, usersWithRoles.getOneUserWithRole(UserRole.SiteManager).getUsername(), siteModel.getGuid())) + .statusCodeIs(HttpStatus.NOT_FOUND) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE) + .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify get favorite site for -me-") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void getFavoriteSiteUsingMe() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); + + RestPersonFavoritesModel favoriteSite = restClient.withCoreAPI().usingMe().getFavorite(siteModel.getGuid()); + restClient.assertStatusCodeIs(HttpStatus.OK); + favoriteSite.assertThat().field("targetGuid").is(siteModel.getGuid()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify get favorite site for -me-") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void getFavoriteFileUsingMe() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingAuthUser().addFileToFavorites(fileModel); + + RestPersonFavoritesModel favoriteFile = restClient.withCoreAPI().usingMe().getFavorite(fileModel.getNodeRefWithoutVersion()); + restClient.assertStatusCodeIs(HttpStatus.OK); + favoriteFile.assertThat().field("targetGuid").is(fileModel.getNodeRefWithoutVersion()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, + executionType = ExecutionType.REGRESSION, description = "Verify get favorite site when person id does't exist") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void getFavoriteSiteWhenPersonIdNotExist() throws Exception { + + restClient.withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); + UserModel someUser = new UserModel("invalidUser", DataUser.PASSWORD); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(someUser).getFavorite(siteModel.getGuid()); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, someUser.getUsername())) + .statusCodeIs(HttpStatus.NOT_FOUND) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY); + } + + @Bug(id = "ACE-2413") + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, + executionType = ExecutionType.REGRESSION, description = "Verify get favorite site when person id is empty") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void getFavoriteSiteWithEmptyUserId() throws Exception { + + restClient.withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); + UserModel someUser = new UserModel("", DataUser.PASSWORD); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(someUser).getFavorite(siteModel.getGuid()); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, someUser.getUsername())) + .statusCodeIs(HttpStatus.BAD_REQUEST); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, + executionType = ExecutionType.REGRESSION, description = "Verify get favorite site when favorite id does't exist") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void getFavoriteSiteWhenFavoriteIdNotExist() throws Exception { + + restClient.withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).getFavorite("invalidId"); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidId")) + .statusCodeIs(HttpStatus.NOT_FOUND) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify Admin user gets favorite site with properties filter") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void verifyRequestForGetFavoriteSiteWithProperties() throws Exception + { + UserModel collaborator = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); + restClient.authenticateUser(collaborator); + restClient.withCoreAPI().usingUser(collaborator).addSiteToFavorites(siteModel); + + RestPersonFavoritesModel favoriteSite = restClient.authenticateUser(collaborator).withParams("properties=targetGuid") + .withCoreAPI().usingAuthUser().getFavorite(siteModel.getGuid()); + restClient.assertStatusCodeIs(HttpStatus.OK); + favoriteSite.assertThat().field("targetGuid").is(siteModel.getGuid()); + favoriteSite.assertThat().fieldsCount().is(1); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify Admin user gets favorite site with inccorect properties filter") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void verifyRequestForGetFavoriteSiteWithInvalidProperties() throws Exception + { + UserModel collaborator = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); + restClient.authenticateUser(collaborator); + restClient.withCoreAPI().usingUser(collaborator).addFileToFavorites(fileModel); + + RestPersonFavoritesModel favoriteFile = restClient.authenticateUser(collaborator).withParams("properties=tas") + .withCoreAPI().usingAuthUser().getFavorite(fileModel.getNodeRefWithoutVersion()); + restClient.assertStatusCodeIs(HttpStatus.OK); + favoriteFile.assertThat().fieldsCount().is(0); + } + + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify all values from get favorite rest api for a file") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void verifyRequestFieldsForGetFavoriteFile() throws Exception + { + UserModel contributor = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); + restClient.authenticateUser(contributor); + restClient.withCoreAPI().usingUser(contributor).addFileToFavorites(fileModel); + + RestPersonFavoritesModel favoriteFile = restClient.authenticateUser(contributor) + .withCoreAPI().usingAuthUser().getFavorite(fileModel.getNodeRefWithoutVersion()); + restClient.assertStatusCodeIs(HttpStatus.OK); + + favoriteFile.assertThat().field("targetGuid").is(fileModel.getNodeRefWithoutVersion()) + .and().field("target.file.isFile").is("true") + .and().field("target.file.mimeType").is("text/plain") + .and().field("target.file.isFolder").is("false") + .and().field("target.file.createdBy").is(adminUserModel.getUsername()) + .and().field("target.file.versionLabel").is("1.0") + .and().field("target.file.name").is(fileModel.getName()) + .and().field("target.file.parentId").is(folderModel.getNodeRef()) + .and().field("target.file.guid").is(fileModel.getNodeRefWithoutVersion()) + .and().field("target.file.modifiedBy").is(adminUserModel.getUsername()) + .and().field("target.file.id").is(fileModel.getNodeRefWithoutVersion()); + } + + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify all values from get favorite rest api for a site") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void verifyRequestFieldsForGetFavoriteSite() throws Exception + { + UserModel contributor = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); + restClient.authenticateUser(contributor); + restClient.withCoreAPI().usingUser(contributor).addFavoriteSite(siteModel); + + RestPersonFavoritesModel favoriteSite = restClient.authenticateUser(contributor) + .withCoreAPI().usingAuthUser().getFavorite(siteModel.getGuid()); + restClient.assertStatusCodeIs(HttpStatus.OK); + + favoriteSite.assertThat().field("targetGuid").is(siteModel.getGuid()) + .and().field("target.site.role").is(UserRole.SiteContributor.toString()) + .and().field("target.site.visibility").is(SiteService.Visibility.PUBLIC.toString()) + .and().field("target.site.guid").is(siteModel.getGuid()) + .and().field("target.site.description").is(siteModel.getDescription()) + .and().field("target.site.id").is(siteModel.getId()) + .and().field("target.site.preset").is("site-dashboard") + .and().field("target.site.title").is(siteModel.getTitle()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify all values from get favorite rest api for a folder") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void verifyRequestFieldsForGetFavoriteFolder() throws Exception + { + UserModel contributor = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); + restClient.authenticateUser(contributor); + restClient.withCoreAPI().usingUser(contributor).addFolderToFavorites(folderModel); + + RestPersonFavoritesModel favoriteFolder = restClient.authenticateUser(contributor) + .withCoreAPI().usingAuthUser().getFavorite(folderModel.getNodeRef()); + restClient.assertStatusCodeIs(HttpStatus.OK); + + favoriteFolder.assertThat().field("targetGuid").is(folderModel.getNodeRef()) + .and().field("target.folder.isFile").is("false") + .and().field("target.folder.isFolder").is("true") + .and().field("target.folder.createdBy").is(adminUserModel.getUsername()) + .and().field("target.folder.name").is(folderModel.getName()) + .and().field("target.folder.guid").is(folderModel.getNodeRef()) + .and().field("target.folder.modifiedBy").is(adminUserModel.getUsername()) + .and().field("target.folder.id").is(folderModel.getNodeRef()); + } +} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/rest/favorites/GetFavoritesTests.java b/e2e-test/src/test/java/org/alfresco/rest/favorites/GetFavoritesTests.java new file mode 100644 index 000000000..f12845720 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/favorites/GetFavoritesTests.java @@ -0,0 +1,555 @@ +package org.alfresco.rest.favorites; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestPersonFavoritesModel; +import org.alfresco.rest.model.RestPersonFavoritesModelsCollection; +import org.alfresco.rest.model.RestSiteModel; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class GetFavoritesTests extends RestTest +{ + private UserModel adminUserModel, userModel; + private SiteModel firstSiteModel; + private SiteModel secondSiteModel; + private SiteModel thirdSiteModel; + private FileModel firstFileModel; + private FileModel secondFileModel; + private FolderModel firstFolderModel; + private FolderModel secondFolderModel; + private ListUserWithRoles firstSiteUsers, secondSiteUsers; + private RestPersonFavoritesModelsCollection userFavorites; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + userModel = dataUser.createRandomTestUser(); + + firstSiteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + secondSiteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + thirdSiteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + firstFolderModel = dataContent.usingUser(adminUserModel).usingSite(firstSiteModel).createFolder(); + secondFolderModel = dataContent.usingUser(adminUserModel).usingSite(firstSiteModel).createFolder(); + firstFileModel = dataContent.usingUser(adminUserModel).usingResource(firstFolderModel).createContent(DocumentType.TEXT_PLAIN); + secondFileModel = dataContent.usingUser(adminUserModel).usingResource(firstFolderModel).createContent(DocumentType.TEXT_PLAIN); + + firstSiteUsers = dataUser.addUsersWithRolesToSite(firstSiteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + secondSiteUsers = dataUser.addUsersWithRolesToSite(secondSiteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + + restClient.authenticateUser(userModel); + restClient.withCoreAPI().usingUser(userModel).addSiteToFavorites(firstSiteModel); + restClient.withCoreAPI().usingUser(userModel).addSiteToFavorites(secondSiteModel); + restClient.withCoreAPI().usingUser(userModel).addSiteToFavorites(thirdSiteModel); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, + description = "Verify Manager user gets favorites with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) + public void managerIsAbleToRetrieveFavorites() throws Exception + { + restClient.authenticateUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteManager)); + restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); + restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(secondSiteModel); + + userFavorites = restClient.withCoreAPI().usingAuthUser().getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + userFavorites.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) + .assertThat().entriesListContains("targetGuid", secondSiteModel.getGuid()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, + description = "Verify user gets status code 401 if authentication call fails") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) +// @Bug(id = "MNT-16904", description = "It fails only on environment with tenants") + public void userIsNotAbleToRetrieveFavoritesIfAuthenticationFails() throws Exception + { + UserModel siteManager = firstSiteUsers.getOneUserWithRole(UserRole.SiteManager); + siteManager.setPassword("wrongPassword"); + restClient.authenticateUser(siteManager).withCoreAPI().usingAuthUser().getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify Admin user gets favorites sites with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void adminIsAbleToRetrieveFavoritesSites() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(firstSiteModel); + restClient.withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(secondSiteModel); + + userFavorites = restClient.withCoreAPI() + .usingAuthUser().where().targetSiteExist().getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + userFavorites.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) + .and().entriesListContains("targetGuid", secondSiteModel.getGuid()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify Admin user gets favorites folders with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void adminIsAbleToRetrieveFavoritesFolders() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).addFolderToFavorites(firstFolderModel); + restClient.withCoreAPI().usingUser(adminUserModel).addFolderToFavorites(secondFolderModel); + + userFavorites = restClient.withCoreAPI() + .usingAuthUser().where().targetFolderExist().getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + userFavorites.assertThat().entriesListContains("targetGuid", firstFolderModel.getNodeRef()) + .and().entriesListContains("targetGuid", secondFolderModel.getNodeRef()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify Admin user gets favorites files with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void adminIsAbleToRetrieveFavoritesFiles() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).addFileToFavorites(firstFileModel); + restClient.withCoreAPI().usingUser(adminUserModel).addFileToFavorites(secondFileModel); + + userFavorites = restClient.withCoreAPI() + .usingAuthUser().where().targetFileExist().getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + userFavorites.assertThat().entriesListContains("targetGuid", firstFileModel.getNodeRefWithoutVersion()) + .and().entriesListContains("targetGuid", secondFileModel.getNodeRefWithoutVersion()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify Collaborator user gets favorites with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void collaboratorIsAbleToRetrieveFavorites() throws Exception + { + restClient.authenticateUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); + restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(secondSiteModel); + + userFavorites = restClient.withCoreAPI().usingAuthUser().getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + userFavorites.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) + .and().entriesListContains("targetGuid", secondSiteModel.getGuid()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify Contributor user gets favorites with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void contributorIsAbleToRetrieveFavorites() throws Exception + { + restClient.authenticateUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteContributor)) + .withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); + restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(secondSiteModel); + + userFavorites = restClient.withCoreAPI().usingAuthUser().getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + userFavorites.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()).and() + .entriesListContains("targetGuid", secondSiteModel.getGuid()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify Consumer user gets favorites with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void consumerIsAbleToRetrieveFavorites() throws Exception + { + restClient.authenticateUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteConsumer)) + .withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); + restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(secondSiteModel); + + userFavorites = restClient.withCoreAPI().usingAuthUser().getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + userFavorites.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) + .assertThat().entriesListContains("targetGuid", secondSiteModel.getGuid()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify user doesn't have permission to get favorites of another user with Rest API and status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void userIsNotAbleToRetrieveFavoritesOfAnotherUser() throws Exception + { + restClient.authenticateUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteConsumer)) + .withCoreAPI().usingUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)).getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, firstSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator).getUsername())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify user doesn't have permission to get favorites of admin user with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void userIsNotAbleToRetrieveFavoritesOfAdminUser() throws Exception + { + restClient.authenticateUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI() + .usingUser(adminUserModel).getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, adminUserModel.getUsername())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify admin user doesn't have permission to get favorites of another user with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void adminIsNotAbleToRetrieveFavoritesOfAnotherUser() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)) + .getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, firstSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator).getUsername())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify User gets only favorites sites with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void userIsAbleToRetrieveOnlyFavoritesSites() throws Exception + { + restClient.authenticateUser(secondSiteUsers.getOneUserWithRole(UserRole.SiteManager)); + restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); + restClient.withCoreAPI().usingAuthUser().addFileToFavorites(firstFileModel); + restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(firstFolderModel); + + userFavorites = restClient.withCoreAPI().usingAuthUser().where().targetSiteExist().getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + userFavorites.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) + .and().entriesListDoesNotContain("targetGuid", secondSiteModel.getGuid()) + .and().entriesListDoesNotContain("targetGuid", firstFileModel.getNodeRefWithoutVersion()) + .and().entriesListDoesNotContain("targetGuid", firstFolderModel.getNodeRef()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify User gets only favorites files with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void userIsAbleToRetrieveOnlyFavoritesFiles() throws Exception + { + restClient.authenticateUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)); + restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); + restClient.withCoreAPI().usingAuthUser().addFileToFavorites(firstFileModel); + restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(firstFolderModel); + + userFavorites = restClient.withCoreAPI().usingAuthUser().where().targetFileExist().getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + userFavorites.assertThat().entriesListContains("targetGuid", firstFileModel.getNodeRefWithoutVersion()) + .and().entriesListDoesNotContain("targetGuid", secondFileModel.getNodeRefWithoutVersion()) + .and().entriesListDoesNotContain("targetGuid", firstSiteModel.getGuid()) + .and().entriesListDoesNotContain("targetGuid", firstFolderModel.getNodeRef()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify User gets only favorites folders with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void userIsAbleToRetrieveOnlyFavoritesFolders() throws Exception + { + restClient.authenticateUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)); + restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); + restClient.withCoreAPI().usingAuthUser().addFileToFavorites(firstFileModel); + restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(firstFolderModel); + + userFavorites = restClient.withCoreAPI().usingAuthUser().where().targetFolderExist().getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + userFavorites.assertThat().entriesListContains("targetGuid", firstFolderModel.getNodeRef()) + .and().entriesListDoesNotContain("targetGuid", secondFolderModel.getNodeRef()) + .and().entriesListDoesNotContain("targetGuid", firstSiteModel.getGuid()) + .and().entriesListDoesNotContain("targetGuid", firstFileModel.getNodeRefWithoutVersion()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify User gets only favorites files or folders with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void userIsAbleToRetrieveFavoritesFilesOrFolders() throws Exception + { + restClient.authenticateUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteConsumer)); + restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); + restClient.withCoreAPI().usingAuthUser().addFileToFavorites(firstFileModel); + restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(firstFolderModel); + + userFavorites = restClient.withCoreAPI().usingAuthUser() + .where().targetFolderExist().or().targetFileExist() + .getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + userFavorites.assertThat().entriesListContains("targetGuid", firstFolderModel.getNodeRef()) + .and().entriesListContains("targetGuid", firstFileModel.getNodeRefWithoutVersion()) + .and().entriesListDoesNotContain("targetGuid", secondFolderModel.getNodeRef()) + .and().entriesListDoesNotContain("targetGuid", secondFileModel.getNodeRefWithoutVersion()) + .and().entriesListDoesNotContain("targetGuid", firstSiteModel.getGuid()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify User gets only favorites files or sites with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void userIsAbleToRetrieveFavoritesFilesOrSites() throws Exception + { + restClient.authenticateUser(secondSiteUsers.getOneUserWithRole(UserRole.SiteManager)); + restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); + restClient.withCoreAPI().usingAuthUser().addFileToFavorites(firstFileModel); + restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(firstFolderModel); + + userFavorites = restClient.withCoreAPI().usingAuthUser() + .where().targetSiteExist().or().targetFileExist() + .getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + userFavorites.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) + .and().entriesListContains("targetGuid", firstFileModel.getNodeRefWithoutVersion()) + .and().entriesListDoesNotContain("targetGuid", secondSiteModel.getGuid()) + .and().entriesListDoesNotContain("targetGuid", secondFileModel.getNodeRefWithoutVersion()) + .and().entriesListDoesNotContain("targetGuid", firstFolderModel.getNodeRef()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify User gets only favorites folders or sites with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void userIsAbleToRetrieveFavoritesFoldersOrSites() throws Exception + { + restClient.authenticateUser(secondSiteUsers.getOneUserWithRole(UserRole.SiteManager)); + restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); + restClient.withCoreAPI().usingAuthUser().addFileToFavorites(firstFileModel); + restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(firstFolderModel); + + userFavorites = restClient.withCoreAPI().usingAuthUser() + .where().targetSiteExist().or().targetFolderExist() + .getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + userFavorites.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) + .and().entriesListContains("targetGuid", firstFolderModel.getNodeRef()) + .and().entriesListDoesNotContain("targetGuid", secondSiteModel.getGuid()) + .and().entriesListDoesNotContain("targetGuid", secondFolderModel.getNodeRef()) + .and().entriesListDoesNotContain("targetGuid", firstFileModel.getNodeRefWithoutVersion()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify User gets all favorites with Rest API and status code is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void userIsAbleToRetrieveAllFavorites() throws Exception + { + restClient.authenticateUser(secondSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)); + restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); + restClient.withCoreAPI().usingAuthUser().addFileToFavorites(firstFileModel); + restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(firstFolderModel); + + userFavorites = restClient.withCoreAPI().usingAuthUser() + .where().targetSiteExist().or().targetFolderExist().or().targetFileExist() + .getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + userFavorites.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) + .and().entriesListContains("targetGuid", firstFolderModel.getNodeRef()) + .and().entriesListContains("targetGuid", firstFileModel.getNodeRefWithoutVersion()) + .and().entriesListDoesNotContain("targetGuid", secondSiteModel.getGuid()) + .and().entriesListDoesNotContain("targetGuid", secondFolderModel.getNodeRef()) + .and().entriesListDoesNotContain("targetGuid", secondFileModel.getNodeRefWithoutVersion()); + + userFavorites = restClient.withCoreAPI().usingAuthUser().getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + userFavorites.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) + .and().entriesListContains("targetGuid", firstFolderModel.getNodeRef()) + .and().entriesListContains("targetGuid", firstFileModel.getNodeRefWithoutVersion()) + .and().entriesListDoesNotContain("targetGuid", secondSiteModel.getGuid()) + .and().entriesListDoesNotContain("targetGuid", secondFolderModel.getNodeRef()) + .and().entriesListDoesNotContain("targetGuid", secondFileModel.getNodeRefWithoutVersion()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify request for a user with no favorites returns status 200") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void userHasNoFavorites() throws Exception + { + restClient.authenticateUser(secondSiteUsers.getOneUserWithRole(UserRole.SiteContributor)); + + userFavorites = restClient.withCoreAPI().usingAuthUser().getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + userFavorites.assertThat().entriesListIsEmpty().and().paginationField("totalItems").is("0"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify request using invalid where parameter returns status 400") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void getFavoritesUsingInvalidWhereParameter() throws Exception + { + restClient.authenticateUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteConsumer)); + restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); + restClient.withCoreAPI().usingAuthUser().addFileToFavorites(firstFileModel); + restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(firstFolderModel); + + userFavorites = restClient.withCoreAPI().usingAuthUser() + .where().or().getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_ARGUMENT, "WHERE query")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify User gets correct favorites after deleting a favorite") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void checkFavoriteFolderIsRemoved() throws Exception + { + restClient.authenticateUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteManager)); + restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); + restClient.withCoreAPI().usingAuthUser().addFileToFavorites(firstFileModel); + restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(firstFolderModel); + + restClient.withCoreAPI().usingAuthUser().deleteFolderFromFavorites(firstFolderModel); + + userFavorites = restClient.withCoreAPI().usingAuthUser().getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + userFavorites.assertThat().entriesListDoesNotContain("targetGuid", firstFolderModel.getNodeRef()) + .and().paginationField("totalItems").is("2"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify get favorites specifying -me- string in place of for request") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void userIsAbleToGetFavoritesWhenUsingMeAsUsername() throws Exception + { + userFavorites = restClient.authenticateUser(userModel).withCoreAPI().usingMe().getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + userFavorites.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()).and().entriesListContains("targetGuid", secondSiteModel.getGuid()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify get favorites using empty for where parameter for request") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void userIsAbleToGetFavoritesWhenUsingEmptyWhereParameter() throws Exception + { + userFavorites = restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().where().getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_ARGUMENT, "WHERE query")); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that for invalid maxItems parameter status code returned is 400.") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void checkInvalidMaxItemsStatusCode() throws Exception + { + restClient.authenticateUser(adminUserModel).withParams("maxItems=AB").withCoreAPI().usingUser(adminUserModel).getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Invalid paging parameter"); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that for invalid skipCount parameter status code returned is 400.") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void checkInvalidSkipCountStatusCode() throws Exception + { + restClient.authenticateUser(adminUserModel).withParams("skipCount=AB").withCoreAPI().usingUser(adminUserModel).getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Invalid paging parameter"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify get favorites when using invalid network id for non-tenant user") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void getFavoritesWhenNetworkIdIsInvalid() throws Exception + { + UserModel networkUserModel = dataUser.createRandomTestUser(); + networkUserModel.setDomain("invalidNetwork"); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(networkUserModel).where().targetSiteExist().getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, networkUserModel.getUsername())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify get favorites using AND instead of OR in where parameter for request") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void userIsNotAbleToGetFavoritesWhenUsingANDInWhereParameter() throws Exception + { + userFavorites = restClient.withCoreAPI().usingAuthUser().where().targetFolderExist().invalidWhereParameter("AND").targetFileExist().getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_ARGUMENT, "WHERE query")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify get favorites using wrong name instead of EXISTS in where parameter for request") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void userIsNotAbleToGetFavoritesWhenUsingWrongWhereParameter() throws Exception + { + userFavorites = restClient.withCoreAPI().usingAuthUser().where().invalidWhereParameter("EXIST((target/site))").targetFileExist().getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_ARGUMENT, "WHERE query")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify get favorites except the first one for request") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void userIsAbleToGetFavoritesExceptTheFirstOne() throws Exception + { + userFavorites = restClient.authenticateUser(userModel).withParams("skipCount=1").withCoreAPI().usingUser(userModel).getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + userFavorites.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) + .and().entriesListContains("targetGuid", secondSiteModel.getGuid()) + .and().entriesListDoesNotContain("targetGuid", thirdSiteModel.getGuid()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify get first two favorites sites") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void userIsAbleToGetFirstTwoFavorites() throws Exception + { + userFavorites = restClient.authenticateUser(userModel).withParams("maxItems=2").withCoreAPI().usingUser(userModel).getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + userFavorites.assertThat().entriesListContains("targetGuid", thirdSiteModel.getGuid()) + .and().entriesListContains("targetGuid", secondSiteModel.getGuid()) + .and().entriesListDoesNotContain("targetGuid", firstSiteModel.getGuid()) + .getPagination().assertThat().field("maxItems").is("2") + .and().field("hasMoreItems").is("true") + .and().field("count").is("2"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify get favorites sites when using empty values for skipCount and maxItems") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void userIsAbleToGetFavoritesWhenSkipCountAndMaxItemsAreEmpty() throws Exception + { + restClient.authenticateUser(userModel).withParams("skipCount= ").withCoreAPI().usingUser(userModel).getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, " ")); + + restClient.authenticateUser(userModel).withParams("maxItems= ").withCoreAPI().usingUser(userModel).getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, " ")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify the get favorites request for a high value for skipCount parameter") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void userIsAbleToGetFavoritesWithHighSkipCount() throws Exception + { + userFavorites = restClient.authenticateUser(userModel).withParams("skipCount=999999999").withCoreAPI().usingUser(userModel).getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + userFavorites.assertThat().entriesListIsEmpty().assertThat().paginationField("skipCount").is("999999999"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify the get favorites request with properties parameter applied") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void userIsAbleToGetFavoritesWithPropertiesParamApplied() throws Exception + { + userFavorites = restClient.authenticateUser(userModel).withParams("properties=targetGuid").withCoreAPI().usingUser(userModel).getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + RestPersonFavoritesModel restPersonFavoritesModel = userFavorites.getEntries().get(0).onModel(); + restPersonFavoritesModel.assertThat().field("targetGuid").is(thirdSiteModel.getGuid()).and().field("createdAt").isNull(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify entry details for get favorites response with Rest API") + public void checkResponseSchemaForGetFavorites() throws Exception + { + userFavorites = restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().getFavorites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + RestPersonFavoritesModel restPersonFavoritesModel = userFavorites.getEntries().get(0).onModel(); + restPersonFavoritesModel.assertThat().field("targetGuid").is(thirdSiteModel.getGuid()); + + RestSiteModel restSiteModel = restPersonFavoritesModel.getTarget().getSite(); + restSiteModel.assertThat().field("visibility").is(thirdSiteModel.getVisibility()).and() + .field("guid").is(thirdSiteModel.getGuid()).and() + .field("description").is(thirdSiteModel.getDescription()).and() + .field("id").is(thirdSiteModel.getId()).and() + .field("title").is(thirdSiteModel.getTitle()); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/groups/GroupsTests.java b/e2e-test/src/test/java/org/alfresco/rest/groups/GroupsTests.java new file mode 100644 index 000000000..5eb3fa562 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/groups/GroupsTests.java @@ -0,0 +1,158 @@ +package org.alfresco.rest.groups; + +import java.util.UUID; + +import javax.json.Json; +import javax.json.JsonObject; + +import org.alfresco.rest.RestTest; +import org.alfresco.utility.RetryOperation; +import org.alfresco.utility.Utility; +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; + +@Test(groups = {TestGroup.REQUIRE_SOLR}) +public class GroupsTests extends RestTest +{ + private UserModel adminUser, userModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userModel = dataUser.createRandomTestUser(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.GROUPS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.SANITY, + description = "Verify creation, listing, updating and deletion of groups.") + public void createListUpdateAndDeleteGroup() throws Exception + { + String groupName = "ZtestGroup" + UUID.randomUUID().toString(); + JsonObject groupBody = Json.createObjectBuilder().add("id", groupName).add("displayName", groupName).build(); + String groupBodyCreate = groupBody.toString(); + + //GroupCreation: + //-ve + restClient.authenticateUser(userModel).withCoreAPI().usingGroups().createGroup(groupBodyCreate); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + //+ve + restClient.authenticateUser(adminUser).withCoreAPI().usingParams("include=zones").usingGroups().createGroup(groupBodyCreate) + .assertThat().field("zones").contains("APP.DEFAULT") + .and().field("isRoot").is(true) + .and().field("displayName").is(groupName); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + //ListGroups: + restClient.withCoreAPI().usingParams("orderBy=displayName DESC&maxItems=10").usingGroups().listGroups() + .assertThat().entriesListContains("id", "GROUP_"+groupName) + .and().entriesListDoesNotContain("zones") + .and().paginationField("maxItems").is("10"); + restClient.assertStatusCodeIs(HttpStatus.OK); + + groupBody = Json.createObjectBuilder().add("displayName", "Z"+groupName).build(); + String groupBodyUpdate = groupBody.toString(); + //UpdateGroup: + restClient.withCoreAPI().usingGroups().updateGroupDetails("GROUP_"+groupName, groupBodyUpdate) + .assertThat().field("displayName").is("Z"+groupName) + .and().field("id").is("GROUP_"+groupName) + .and().field("zones").isNull(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + //GetGroupDetails: + restClient.withCoreAPI().usingParams("include=zones").usingGroups().getGroupDetail("GROUP_"+groupName) + .assertThat().field("id").is("GROUP_"+groupName) + .and().field("zones").contains("APP.DEFAULT") + .and().field("isRoot").is(true); + restClient.assertStatusCodeIs(HttpStatus.OK); + + //DeleteGroup: + //-ve + restClient.authenticateUser(userModel).withCoreAPI().usingGroups().deleteGroup("GROUP_"+groupName); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + //+ve + restClient.authenticateUser(adminUser).withCoreAPI().usingGroups().deleteGroup("GROUP_"+groupName); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.GROUPS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.SANITY, + description = "Verify creation, listing(only for person) and deletion of group memberships. ") + public void createListDeleteGroupMembership() throws Exception + { + String groupName = "ZtestGroup" + UUID.randomUUID().toString(); + JsonObject groupBody = Json.createObjectBuilder().add("id", groupName).add("displayName", groupName).build(); + String groupBodyCreate = groupBody.toString(); + + //GroupCreation: + restClient.authenticateUser(adminUser).withCoreAPI().usingParams("include=zones").usingGroups().createGroup(groupBodyCreate); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + JsonObject groupMembershipBody = Json.createObjectBuilder().add("id", userModel.getUsername()).add("memberType", "PERSON").build(); + String groupMembershipBodyCreate = groupMembershipBody.toString(); + //MembershipCreation: + //-ve + restClient.authenticateUser(userModel).withCoreAPI().usingGroups().createGroupMembership("GROUP_"+groupName, groupMembershipBodyCreate); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + //+ve + restClient.authenticateUser(adminUser).withCoreAPI().usingGroups().createGroupMembership("GROUP_"+groupName, groupMembershipBodyCreate); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + //ListPersonMembership + restClient.authenticateUser(userModel).withCoreAPI().usingUser(userModel).listGroupMemberships() + .assertThat().entriesListContains("id", "GROUP_"+groupName); + restClient.assertStatusCodeIs(HttpStatus.OK); + + //DeleteGroupMembership + //-ve + restClient.withCoreAPI().usingGroups().deleteGroupMembership("GROUP_"+groupName, userModel.getUsername()); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + //+ve + restClient.authenticateUser(adminUser).withCoreAPI().usingGroups().deleteGroupMembership("GROUP_"+groupName, userModel.getUsername()); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + //ListAgainPersonMembership + restClient.withCoreAPI().usingUser(userModel).listGroupMemberships() + .assertThat().entriesListDoesNotContain("id", "GROUP_"+groupName); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.GROUPS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.SANITY, + description = "Verify listing of group memberships.") + public void listGroupMembership() throws Exception + { + String groupName = "testGroup" + UUID.randomUUID().toString(); + JsonObject groupBody = Json.createObjectBuilder().add("id", groupName).add("displayName", groupName).build(); + String groupBodyCreate = groupBody.toString(); + + //GroupCreation: + restClient.authenticateUser(adminUser).withCoreAPI().usingParams("include=zones").usingGroups().createGroup(groupBodyCreate); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + JsonObject groupMembershipBody = Json.createObjectBuilder().add("id", userModel.getUsername()).add("memberType", "PERSON").build(); + String groupMembershipBodyCreate = groupMembershipBody.toString(); + + //MembershipCreation + restClient.withCoreAPI().usingGroups().createGroupMembership("GROUP_"+groupName, groupMembershipBodyCreate) + .assertThat().field("displayName").is(userModel.getUsername()) + .and().field("id").is(userModel.getUsername()) + .and().field("memberType").is("PERSON"); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + //ListGroupMembership + RetryOperation op = new RetryOperation(){ + public void execute() throws Exception{ + restClient.withCoreAPI().usingGroups().listGroupMemberships("GROUP_"+groupName) + .assertThat().entriesListContains("id", userModel.getUsername()); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + }; + Utility.sleep(1000, 35000, op);// Allow indexing to complete. + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/networks/RestGetNetworkForPersonTests.java b/e2e-test/src/test/java/org/alfresco/rest/networks/RestGetNetworkForPersonTests.java new file mode 100644 index 000000000..384edd07f --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/networks/RestGetNetworkForPersonTests.java @@ -0,0 +1,151 @@ +package org.alfresco.rest.networks; + +import java.util.ArrayList; + +import org.alfresco.rest.NetworkDataPrep; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestNetworkQuotaModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Tests for /people/{personId}/networks + */ +public class RestGetNetworkForPersonTests extends NetworkDataPrep +{ + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + init(); + } + + @Bug(id = "MNT-16904") + @TestRail(section = { TestGroup.REST_API, + TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, description = "Verify non existing user gets another existing network with Rest API and checks the forbidden status") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) + public void nonExistingTenantUserIsNotAuthorizedToRequest() throws Exception + { + UserModel tenantUser = new UserModel("nonexisting", "password"); + tenantUser.setDomain(adminTenantUser.getDomain()); + restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().getNetwork(adminTenantUser); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify tenant admin user gets specific network with Rest API and response is not empty") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) + public void adminTenantChecksIfNetworkIsPresent() throws Exception + { + restClient.authenticateUser(adminTenantUser).withCoreAPI().usingUser(adminTenantUser).getNetwork(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify tenant user gets specific network with Rest API and response is not empty") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) + public void tenantUserChecksIfNetworkIsPresent() throws Exception + { + restClient.authenticateUser(tenantUser).withCoreAPI().usingUser(tenantUser).getNetwork(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Bug(id = "needs to be checked") + @TestRail(section = { TestGroup.REST_API, + TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, description = "Verify tenant user check network of admin user with Rest API") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) + public void tenantUserIsNotAuthorizedToCheckNetworkOfAdminUser() throws Exception + { + restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().getNetwork(adminTenantUser); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Bug(id = "needs to be checked") + @TestRail(section = { TestGroup.REST_API, + TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, description = "Verify getNetwork request status code is 200 if a user tries to get network information of another user") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) + public void verifyGetNetworkByAUserForAnotherUser() throws Exception + { + UserModel randomTestUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("randomTestUser"); + restNetworkModel = restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().getNetwork(randomTestUser); + restClient.assertStatusCodeIs(HttpStatus.OK); + restNetworkModel.assertThat().field("id").is(tenantUser.getDomain()); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, description = "Verify that getNetwork status code is 404 for a personId that does not exist") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) + public void verifyThatGetNetworkStatusIs404ForAPersonIdThatDoesNotExist() throws Exception + { + UserModel invalidUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("validUsername"); + invalidUser.setUsername("invalidUsername"); + + restClient.authenticateUser(adminTenantUser).withCoreAPI().usingUser(invalidUser).getNetwork(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, invalidUser.getUsername())).descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, description = "Verify that getNetwork status code is 404 for a networkId that does not exist") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) + public void verifyThatGetNetworkStatusIs404ForANetworkIdThatDoesNotExist() throws Exception + { + UserModel invalidUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("invalidNetworkId"); + invalidUser.setDomain("invalidNetworkId"); + + restClient.authenticateUser(adminTenantUser).withCoreAPI().usingUser(invalidUser).getNetwork(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, invalidUser.getUsername())).descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, description = "Verify getNetwork request that is made using -me- instead of personId") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) + public void verifyGetNetworkRequestUsingMeInsteadOfPersonId() throws Exception + { + restNetworkModel = restClient.authenticateUser(adminTenantUser).withCoreAPI().usingMe().getNetwork(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restNetworkModel.assertThat().field("quotas").is(new ArrayList()).assertThat().field("isEnabled").is("true").assertThat() + .field("homeNetwork").is("true").assertThat().field("id").is(adminTenantUser.getDomain().toLowerCase()); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, description = "Verify that properties parameter is applied to getNetwork request") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) + public void verifyPropertiesParameterIsAppliedToGetNetworkRequest() throws Exception + { + restNetworkModel = restClient.authenticateUser(adminTenantUser).withParams("properties=id,isEnabled,homeNetwork,paidNetwork").withCoreAPI().usingMe() + .getNetwork(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restNetworkModel.assertThat().field("id").is(adminTenantUser.getDomain().toLowerCase()).assertThat().field("isEnabled").is("true").assertThat() + .field("homeNetwork").is("true").assertThat().field("paidNetwork").is("false").assertThat().field("quotas").isNull(); + restNetworkModel.assertThat().fieldsCount().is(4); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, description = "Verify getNetwork request status code is 404 for a network to which user does not belong") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) + public void verifyGetNetworkRequestStatusCodeIs404ForANetworkToWhichTheUserDoesNotBelong() throws Exception + { + restClient.authenticateUser(adminTenantUser).withCoreAPI().usingAuthUser().getNetwork(secondAdminTenantUser); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, description = "Verify admin tenant user is not authorized to check network of another user with Rest API and checks the forbidden status") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) + public void adminTenantUserIsNotAuthorizedToCheckNetworkOfAnotherUser() throws Exception + { + UserModel secondTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("anotherTenant"); + restClient.authenticateUser(secondAdminTenantUser).withCoreAPI().usingAuthUser().getNetwork(secondTenantUser); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/networks/RestGetNetworkTests.java b/e2e-test/src/test/java/org/alfresco/rest/networks/RestGetNetworkTests.java new file mode 100644 index 000000000..e872aa0da --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/networks/RestGetNetworkTests.java @@ -0,0 +1,145 @@ +package org.alfresco.rest.networks; + +import org.alfresco.rest.NetworkDataPrep; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestNetworkModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.json.JSONException; +import org.json.JSONObject; +import org.springframework.http.HttpStatus; +import org.testng.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Created by Cristina Axinte on 9/26/2016. + */ +public class RestGetNetworkTests extends NetworkDataPrep +{ + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + init(); + } + + @Bug(id = "MNT-16904") + @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, + description = "Verify non existing user gets another exisiting network with Rest API and checks the forbidden status") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY}) + public void nonExistingTenantUserIsNotAuthorizedToRequest() throws Exception + { + UserModel tenantUser = new UserModel("nonexisting", "password"); + tenantUser.setDomain(adminTenantUser.getDomain()); + restClient.authenticateUser(tenantUser); + restClient.withCoreAPI().usingNetworks().getNetwork(adminTenantUser); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, + description = "Verify tenant admin user gets specific network with Rest API and response is not empty") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) + public void adminTenantChecksIfNetworkIsPresent() throws Exception + { + restClient.authenticateUser(adminTenantUser); + restClient.withCoreAPI().usingNetworks().getNetwork().assertNetworkHasName(adminTenantUser).assertNetworkIsEnabled(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify tenant admin user gets another existing network with Rest API and checks the forbidden status") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) + public void adminTenantChecksIfAnotherExistingNetworkIsForbidden() throws Exception + { + restClient.authenticateUser(adminTenantUser); + restClient.withCoreAPI().usingNetworks().getNetwork(secondAdminTenantUser); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, + description = "Verify any tenant user gets its network with Rest API and response is not empty") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) + public void userTenantChecksIfNetworkIsPresent() throws Exception + { + restClient.authenticateUser(tenantUser); + restClient.withCoreAPI().usingNetworks().getNetwork(adminTenantUser).assertNetworkHasName(adminTenantUser).assertNetworkIsEnabled(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify any tenant user gets non existing network with Rest API and checks the not found status") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) + public void userTenantChecksIfNonExistingNetworkIsNotFound() throws Exception + { + restClient.authenticateUser(tenantUser); + restClient.withCoreAPI().usingNetworks().getNetwork(UserModel.getRandomTenantUser()); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify any tenant user gets another existing network with Rest API and checks the forbidden status") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) + public void userTenantChecksIfAnotherExistingNetworkIsForbidden() throws Exception + { + restClient.authenticateUser(tenantUser); + restClient.withCoreAPI().usingNetworks().getNetwork(secondAdminTenantUser); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + } + + @Bug(id = "ACE-5738") + @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify tenant admin user gets an invalid network with Rest API and checks the not found status") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) + public void adminTenantGetsInvalidNetwork() throws Exception + { + restClient.authenticateUser(secondAdminTenantUser); + secondAdminTenantUser.setDomain("tenant.@%"); + + restClient.withCoreAPI().usingNetworks().getNetwork(secondAdminTenantUser); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.UNEXPECTED_TENANT, adminTenantUser.getDomain(), "@")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Bug(id = "ACE-5745") + @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify admin user gets an existing network successfully with Rest API") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) + public void adminUserGetsExistingNetwork() throws Exception + { + RestNetworkModel restNetworkModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingNetworks().getNetwork(adminTenantUser); + restClient.assertStatusCodeIs(HttpStatus.OK); + restNetworkModel.assertThat().fieldsCount().is("1"); + restNetworkModel.assertThat().field("id").is(adminTenantUser.getDomain()) + .and().field("homeNetwork").isNull() + .and().field("isEnabled").is("true"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify tenant admin user gets network using properties parameter successfully with Rest API") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) + public void adminTenantGetsNetworkUsingPropertiesParameter() throws Exception + { + JSONObject entryResponse= restClient.authenticateUser(tenantUser).withCoreAPI().usingNetworks().usingParams("properties=id").getNetworkWithParams(adminTenantUser); + restClient.assertStatusCodeIs(HttpStatus.OK); + Assert.assertTrue(entryResponse.get("id").equals(adminTenantUser.getDomain().toLowerCase())); + assertJsonResponseDoesnotContainField(entryResponse, "homeNetwork"); + assertJsonResponseDoesnotContainField(entryResponse, "isEnabled"); + } + + private void assertJsonResponseDoesnotContainField(JSONObject entryResponse, String field) + { + try{ + entryResponse.get(field); + } + catch(JSONException ex) + { + Assert.assertTrue(ex.getMessage().equals(String.format("JSONObject[\"%s\"] not found.", field))); + } + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/networks/RestGetNetworksForPersonTests.java b/e2e-test/src/test/java/org/alfresco/rest/networks/RestGetNetworksForPersonTests.java new file mode 100644 index 000000000..9f5e04dde --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/networks/RestGetNetworksForPersonTests.java @@ -0,0 +1,166 @@ +package org.alfresco.rest.networks; + +import org.alfresco.rest.NetworkDataPrep; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestNetworkModelsCollection; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class RestGetNetworksForPersonTests extends NetworkDataPrep +{ + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + init(); + } + + @Bug(id = "MNT-16904") + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, + description = "Verify non existing user gets another exisiting network with Rest API and checks the unauthorized status") + @Test(groups = { TestGroup.REST_API, TestGroup.SANITY, TestGroup.NETWORKS }) + public void nonExistingTenantUserIsNotAuthorizedToRequest() throws Exception + { + UserModel tenantUser = new UserModel("nonexisting", "password"); + tenantUser.setDomain(adminTenantUser.getDomain()); + restClient.authenticateUser(tenantUser); + restClient.withCoreAPI().usingAuthUser().getNetworks(adminTenantUser); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, + description = "Verify tenant admin user gets specific network with Rest API and response is not empty") + @Test(groups = {TestGroup.REST_API, TestGroup.SANITY, TestGroup.NETWORKS }) + public void adminTenantChecksIfNetworkIsPresent() throws Exception + { + RestNetworkModelsCollection networks = restClient.authenticateUser(adminTenantUser).withCoreAPI().usingAuthUser().getNetworks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + networks.getOneRandomEntry().onModel().assertNetworkIsEnabled() + .and().field("id").is(adminTenantUser.getDomain().toLowerCase()) + .and().field("quotas").is("[]") + .and().field("homeNetwork").is("false"); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, + description = "Verify tenant user gets specific network with Rest API and response is not empty") + @Test(groups = {TestGroup.REST_API, TestGroup.SANITY, TestGroup.NETWORKS }) + public void tenantUserChecksIfNetworkIsPresent() throws Exception + { + restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().getNetworks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify tenant user is not authorized to check network of admin user with Rest API and checks the forbidden status") + @Test(groups = {TestGroup.REST_API, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void tenantUserIsNotAuthorizedToCheckNetworkOfAdminUser() throws Exception + { + restClient.authenticateUser(tenantUser); + restClient.withCoreAPI().usingAuthUser().getNetworks(adminTenantUser); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify admin tenant user is not authorized to check network of another user with Rest API and checks the forbidden status") + @Test(groups = {TestGroup.REST_API, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void adminTenantUserIsNotAuthorizedToCheckNetworkOfAnotherUser() throws Exception + { + restClient.authenticateUser(secondAdminTenantUser); + restClient.withCoreAPI().usingAuthUser().getNetworks(secondTenantUser); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Get tenant user networks using invalid value for skipCount") + @Test(groups = {TestGroup.REST_API, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void invalidValueForSkipCountTest() throws Exception + { + restClient.authenticateUser(adminTenantUser).withParams("skipCount=abc").withCoreAPI().usingAuthUser().getNetworks(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "abc")); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Get tenant user networks using invalid value for maxItems") + @Test(groups = {TestGroup.REST_API, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void invalidValueForMaxItemsTest() throws Exception + { + restClient.authenticateUser(adminTenantUser).withParams("maxItems=abc").withCoreAPI().usingAuthUser().getNetworks(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "abc")); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Get tenant user networks using personId that does not exist") + @Test(groups = {TestGroup.REST_API, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void inexistentTenantTest() throws Exception + { + restClient.authenticateUser(adminTenantUser).withCoreAPI().usingUser(new UserModel("invalidTenantUser", "password")).getNetworks(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidTenantUser")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Get tenant user networks using -me- instead of personId") + @Test(groups = {TestGroup.REST_API, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void specifyMeInsteadOfPersonIdTest() throws Exception + { + RestNetworkModelsCollection networks = restClient.authenticateUser(adminTenantUser).withCoreAPI().usingMe().getNetworks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + networks.getOneRandomEntry().onModel().assertNetworkIsEnabled().and().field("id").is(adminTenantUser.getDomain().toLowerCase()); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Check default error schema for get networks for member") + @Test(groups = { TestGroup.REST_API, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void getNetworksAndCheckPropertiesParameter() throws Exception + { + RestNetworkModelsCollection networks = restClient.authenticateUser(adminTenantUser).withParams("properties=isEnabled,id").withCoreAPI().usingAuthUser().getNetworks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + networks.getOneRandomEntry().onModel().assertThat().field("homeNetwork").is("false") + .and().field("quotas").isNull() + .and().field("isEnabled").is("true") + .and().field("id").is(adminTenantUser.getDomain().toLowerCase()); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Check that skipCount parameter is applied") + @Test(groups = { TestGroup.REST_API, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void checkThatSkipCountParameterIsApplied() throws Exception + { + RestNetworkModelsCollection networks = restClient.authenticateUser(adminTenantUser).withParams("skipCount=1").withCoreAPI().usingAuthUser().getNetworks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + networks.assertThat().entriesListIsEmpty(); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Check that high skipCount parameter is applied") + @Test(groups = { TestGroup.REST_API, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void checkThatHighSkipCountParameterIsApplied() throws Exception + { + RestNetworkModelsCollection networks = restClient.authenticateUser(adminTenantUser).withParams("skipCount=100").withCoreAPI().usingAuthUser().getNetworks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + networks.assertThat().entriesListIsEmpty(); + networks.assertThat().paginationField("skipCount").is("100"); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Check that maxItems parameter is applied") + @Test(groups = { TestGroup.REST_API, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void checkThatMaxItemsParameterIsApplied() throws Exception + { + RestNetworkModelsCollection networks = restClient.authenticateUser(adminTenantUser).withParams("maxItems=1").withCoreAPI().usingAuthUser().getNetworks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + networks.getOneRandomEntry().onModel().assertThat().field("homeNetwork").is("false") + .and().field("quotas").is("[]") + .and().field("isEnabled").is("true") + .and().field("id").is(adminTenantUser.getDomain().toLowerCase()); + networks.assertThat().paginationField("maxItems").is("1"); + } +} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/rest/nodes/NodesActionDefinitionTests.java b/e2e-test/src/test/java/org/alfresco/rest/nodes/NodesActionDefinitionTests.java new file mode 100644 index 000000000..596ebf72c --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/nodes/NodesActionDefinitionTests.java @@ -0,0 +1,87 @@ +package org.alfresco.rest.nodes; + + +import static org.testng.Assert.assertFalse; + +import org.alfresco.rest.RestTest; + +import org.alfresco.rest.model.RestActionDefinitionModelsCollection; +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.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.Test; + +public class NodesActionDefinitionTests extends RestTest +{ + + + @TestRail(section = { TestGroup.REST_API,TestGroup.NODES }, executionType = ExecutionType.SANITY, + description = "Verify actions") + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY}) + public void testActionDefinition() throws Exception + { + restClient.authenticateUser(dataContent.getAdminUser()); + + /* + * Create the following file structure for preconditions : + * - sourceFolder + * - file + */ + NodesBuilder nodesBuilder = restClient.withCoreAPI().usingNode(ContentModel.my()).defineNodes(); + NodeDetail sourceFolder = nodesBuilder.folder("sourceFolder"); + NodeDetail file = sourceFolder.file("file"); + ContentModel fileActionDefinitions = new ContentModel(); + fileActionDefinitions.setNodeRef(file.getId()); + + RestActionDefinitionModelsCollection restActionDefinitions = restClient.withCoreAPI().usingNode(fileActionDefinitions).getActionDefinitions(); + restClient.assertStatusCodeIs(HttpStatus.OK); + assertFalse(restActionDefinitions.isEmpty()); + restActionDefinitions.assertThat().entriesListContains("name", "copy"); + restActionDefinitions.assertThat().entriesListContains("name", "move"); + restActionDefinitions.assertThat().entriesListContains("name", "check-out"); + restActionDefinitions.assertThat().entriesListContains("name", "check-in"); + + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NODES }, executionType = ExecutionType.REGRESSION, + description = "Verify actions negative request") + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION}) + public void testActionDefinitionNegative() throws Exception{ + + NodesBuilder nodesBuilder = restClient.withCoreAPI().usingNode(ContentModel.my()).defineNodes(); + NodeDetail sourceFolder = nodesBuilder.folder("sourceFolder"); + ContentModel validNode = new ContentModel(); + validNode.setNodeRef(sourceFolder.getId()); + + // Non-existent node ID + { + ContentModel fakeNode = new ContentModel(); + fakeNode.setNodeRef("750a2867-ecfa-478c-8343-fa0e39d27be3"); + restClient.authenticateUser(dataContent.getAdminUser()).withCoreAPI().usingNode(fakeNode).getActionDefinitions(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } + + // Badly formed request -> 400 + { + restClient.authenticateUser(dataContent.getAdminUser()).withParams("skipCount=-1").withCoreAPI().usingNode(validNode) + .getActionDefinitions(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + + } + + // Unauthorized -> 401 + { + + UserModel userUnauthorized = new UserModel("invalid-user", "invalid-pasword"); + restClient.authenticateUser(userUnauthorized).withCoreAPI().usingNode(validNode).getActionDefinitions(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + + } + } + +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/nodes/NodesContentAndVersioningTests.java b/e2e-test/src/test/java/org/alfresco/rest/nodes/NodesContentAndVersioningTests.java new file mode 100644 index 000000000..a3770353a --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/nodes/NodesContentAndVersioningTests.java @@ -0,0 +1,308 @@ +package org.alfresco.rest.nodes; + +import static org.alfresco.utility.report.log.Step.STEP; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertNotSame; +import static org.testng.Assert.assertNull; +import static org.testng.Assert.assertSame; +import static org.testng.Assert.assertTrue; + +import java.io.File; +import java.io.IOException; +import java.io.RandomAccessFile; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.JsonBodyGenerator; +import org.alfresco.rest.core.RestResponse; +import org.alfresco.rest.model.RestNodeModel; +import org.alfresco.rest.model.RestVersionModel; +import org.alfresco.rest.model.RestVersionModelsCollection; +import org.alfresco.rest.model.body.RestNodeLockBodyModel; +import org.alfresco.util.TempFileProvider; +import org.alfresco.utility.Utility; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FileType; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.json.JSONObject; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * + * @author mpopa + * + */ +public class NodesContentAndVersioningTests extends RestTest +{ + private UserModel user1, user2; + private SiteModel site1, site2; + private FileModel file1, file2; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + user1 = dataUser.createRandomTestUser(); + user2 = dataUser.createRandomTestUser(); + site1 = dataSite.usingUser(user1).createPublicRandomSite(); + site2 = dataSite.usingUser(user2).createPublicRandomSite(); + file1 = dataContent.usingUser(user1).usingSite(site1).createContent(DocumentType.TEXT_PLAIN); + file2 = dataContent.usingUser(user2).usingSite(site2).createContent(DocumentType.TEXT_PLAIN); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.SANITY, description = "Verify file name in Content-Disposition header") + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY }) + public void checkFileNameWithRegularCharsInHeader() throws Exception + { + restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("attachment=false").getNodeContent(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.assertHeaderValueContains("Content-Disposition", String.format("filename=\"%s\"", file1.getName())); + } + + + + + @Bug(id = "MNT-17545", description = "HTTP Header Injection in ContentStreamer", status = Bug.Status.FIXED) + @TestRail(section = { TestGroup.REST_API, + TestGroup.NODES }, executionType = ExecutionType.REGRESSION, description = "Verify file name with special chars is escaped in Content-Disposition header") + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) + public void checkFileNameWithSpecialCharsInHeader() throws Exception + { + char c1 = 127; + char c2 = 31; + char c3 = 256; + FileModel file = dataContent.usingUser(user2).usingSite(site2).createContent(new FileModel("\ntest" + c1 + c2 + c3, FileType.TEXT_PLAIN)); + restClient.authenticateUser(user2).withCoreAPI().usingNode(file).usingParams("attachment=false").getNodeContent(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.assertHeaderValueContains("Content-Disposition", "filename=\" test .txt\""); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.NODES }, executionType = ExecutionType.SANITY, description = "Verify that alfresco returns the correct encoding for files created via REST.") + public void verifyFileEncodingUsingRestAPI() throws Exception + { + STEP("1. Create a folder, two text file templates and define the expected encoding."); + FileModel utf8File = new FileModel("utf8File", FileType.TEXT_PLAIN); + FileModel iso8859File = new FileModel("iso8859File", FileType.TEXT_PLAIN); + FolderModel folder = dataContent.usingUser(user1).usingSite(site1).createFolder(FolderModel.getRandomFolderModel()); + String utf8Type = "text/plain;charset=UTF-8"; + String iso8859Type = "text/plain;charset=ISO-8859-1"; + + STEP("2. Using multipart data upload (POST nodes/{nodeId}/children) the UTF-8 encoded file."); + restClient.authenticateUser(user1).configureRequestSpec().addMultiPart("filedata", Utility.getResourceTestDataFile("UTF-8File.txt")); + RestNodeModel fileNode = restClient.withCoreAPI().usingNode(folder).createNode(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + utf8File.setNodeRef(fileNode.getId()); + + STEP("3. Using multipart data upload (POST nodes/{nodeId}/children) the ISO-8859-1 file."); + restClient.configureRequestSpec().addMultiPart("filedata", Utility.getResourceTestDataFile("iso8859File.txt")); + fileNode = restClient.withCoreAPI().usingNode(folder).createNode(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + iso8859File.setNodeRef(fileNode.getId()); + + STEP("4. Retrieve the nodes and verify that the content type is the expected one (GET nodes/{nodeId})."); + restClient.withCoreAPI().usingNode(utf8File).getNodeContent().assertThat().contentType(utf8Type); + restClient.withCoreAPI().usingNode(iso8859File).getNodeContent().assertThat().contentType(iso8859Type); + } + + + // This test takes around 30 minutes to complete so it will be ignored by default + @Test(enabled=false, groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, + executionType = ExecutionType.REGRESSION, description = "Verify that the node content is streamed directly to the client and not buffered in memory.") + public void verifyUploadDownloadLargeFileUsingRestAPI() throws Exception + { + Integer largeFileSizeBytes = Integer.MAX_VALUE; + String largeFileName = "largeFile.tmp"; + String tempFolderPath = TempFileProvider.getTempDir().getAbsolutePath(); + + STEP("1. Create a folder and a large file"); + FolderModel folder = dataContent.usingUser(user1).usingSite(site1).createFolder(FolderModel.getRandomFolderModel()); + createRandomFileInDirectory(tempFolderPath, largeFileName, largeFileSizeBytes); + + STEP("2. Using multipart data upload for the large file (POST nodes/{nodeId}/children)."); + File largeFile = new File(tempFolderPath, largeFileName); + FileModel largeFileModel = new FileModel(largeFileName, FileType.UNDEFINED); + restClient.authenticateUser(user1).configureRequestSpec().addMultiPart("filedata", largeFile); + RestNodeModel fileNode = restClient.withCoreAPI().usingNode(folder).createNode(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + largeFileModel.setNodeRef(fileNode.getId()); + + STEP("3. Retrieve the content of the node without running out of memory (GET nodes/{nodeId}/content)."); + RestResponse nodeContent = restClient.withCoreAPI().usingNode(largeFileModel).getNodeContent(); + restClient.assertStatusCodeIs(HttpStatus.OK); + assertEquals(Integer.valueOf(nodeContent.getResponse().getHeader("Content-Length")), largeFileSizeBytes); + + largeFile.delete(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.SANITY, description = "Verify updating a node content.") + public void testUpdateNodeContent() throws Exception + { + STEP("1. Retrieve the node in order to get data to compare after update GET /nodes/{nodeId}?include=path."); + RestNodeModel initialNode = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=path").getNode(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + STEP("2. Update the node content (different from the initial one) PUT /nodes/{nodeId}/content?majorVersion=true&name=newfile.txt."); + File updatedConentFile = Utility.getResourceTestDataFile("sampleContent.txt"); + RestNodeModel updatedBodyNode = restClient.withCoreAPI().usingNode(file1).usingParams("majorVersion=true&name=newfile.txt").updateNodeContent(updatedConentFile); + restClient.assertStatusCodeIs(HttpStatus.OK); + + STEP("3. Compare contentSize, modifiedAt, name and version, they should be different."); + assertNotSame(initialNode.getContent().getSizeInBytes(), updatedBodyNode.getContent().getSizeInBytes()); + assertNotSame(initialNode.getModifiedAt(), updatedBodyNode.getModifiedAt()); + assertNotSame(initialNode.getName(), updatedBodyNode.getName()); + + String initialNodeVersion = new JSONObject(initialNode.toJson()).getJSONObject("properties").getString("cm:versionLabel"); + String updatedBodyNodeVersion = new JSONObject(updatedBodyNode.toJson()).getJSONObject("properties").getString("cm:versionLabel"); + assertTrue(updatedBodyNodeVersion.charAt(0) > initialNodeVersion.charAt(0)); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.SANITY, description = "Test copy a node.") + public void testCopyNode() throws Exception + { + STEP("1. Create a lock and lock the node POST /nodes/{nodeId}/lock?include=path,isLocked."); + RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); + lockBodyModel.setLifetime("EPHEMERAL"); + lockBodyModel.setTimeToExpire(20); + lockBodyModel.setType("FULL"); + RestNodeModel initialNode = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=path,isLocked").lockNode(lockBodyModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + + STEP("2. With another user(that has access to the file), copy the node to another path POST /nodes/{nodeId}/copy?include=path,isLocked."); + String postBody = JsonBodyGenerator.keyValueJson("targetParentId", site2.getGuid()); + RestNodeModel copiedNode = restClient.authenticateUser(user2).withCoreAPI().usingNode(file1).usingParams("include=path,isLocked").copyNode(postBody); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + STEP("3. ParentId, createdAt, path and lock are different, but the nodes have the same contentSize."); + assertNotSame(copiedNode.getParentId(), initialNode.getParentId()); + assertNotSame(copiedNode.getCreatedAt(), initialNode.getCreatedAt()); + assertNotSame(copiedNode.getPath(), initialNode.getPath()); + assertTrue(initialNode.getIsLocked()); + assertSame(copiedNode.getContent().getSizeInBytes(), initialNode.getContent().getSizeInBytes()); + assertFalse(copiedNode.getIsLocked()); + + STEP("4. Unlock the node (this node may be used in the next tests)."); + initialNode = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").unlockNode(); + restClient.assertStatusCodeIs(HttpStatus.OK); + assertFalse(initialNode.getIsLocked()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.NODES }, executionType = ExecutionType.SANITY, description = "Test retrieving node versions, a specific version and version content.") + public void testGetVersionContent() throws Exception + { + file2 = dataContent.usingUser(user2).usingSite(site2).createContent(DocumentType.TEXT_PLAIN); + File sampleFile = Utility.getResourceTestDataFile("sampleContent.txt"); + + STEP("1. Update the node content in order to increase version(one minor and one major) PUT /nodes/{nodeId}/content."); + // minor version update + restClient.authenticateUser(user2).withCoreAPI().usingNode(file2).updateNodeContent(sampleFile); + restClient.assertStatusCodeIs(HttpStatus.OK); + // major version update + restClient.authenticateUser(user2).withCoreAPI().usingParams("majorVersion=true").usingNode(file2).updateNodeContent(sampleFile); + restClient.assertStatusCodeIs(HttpStatus.OK); + + STEP("2. List node version history GET /nodes/{nodeId}/versions. And verify that first (in the list) version is 2.0 and last is 1.0."); + RestVersionModelsCollection versionListing = restClient.withCoreAPI().usingNode(file2).listVersionHistory(); + restClient.assertStatusCodeIs(HttpStatus.OK); + // additional check that the properties are not displayed by default. + assertEquals(versionListing.getEntries().get(versionListing.getPagination().getCount() - 1).onModel().getId(), "1.0"); + assertEquals(versionListing.getEntries().get(0).onModel().getId(), "2.0"); + assertNull(versionListing.getEntries().get(0).onModel().getProperties()); + + STEP("3. List node version using skipCount(1),maxItems(1) and include(properties) GET /nodes/{nodeId}/versions?include=properties&skipCount=1&maxItems=1"); + versionListing = restClient.withCoreAPI().usingParams("include=properties&skipCount=1&maxItems=1").usingNode(file2).listVersionHistory(); + restClient.assertStatusCodeIs(HttpStatus.OK); + // we expect only version 1.1 to be retrieved with the value for properties. + RestVersionModel version = versionListing.getEntries().get(0).onModel(); + assertNotNull(version.getProperties()); + assertEquals(version.getId(), "1.1"); + assertEquals(versionListing.getPagination().getMaxItems(), 1); + assertEquals(versionListing.getPagination().getSkipCount(), 1); + assertEquals(versionListing.getPagination().getCount(), 1); + + STEP("4. Get version information for version 1.1 GET /nodes/{nodeId}/versions/{versionId} ."); + RestVersionModel version11 = restClient.withCoreAPI().usingNode(file2).getVersionInformation("1.1"); + restClient.assertStatusCodeIs(HttpStatus.OK); + // aspectNames and properties are displayed by default. We compare + // id,contentSize and name with the values from v1.1, taken from listing all + // versions. + assertNotNull(version11.getAspectNames()); + assertNotNull(version11.getProperties()); + assertEquals(version.getId(), version11.getId()); + assertEquals(version.getContent().getSizeInBytes(), version11.getContent().getSizeInBytes()); + assertEquals(version.getName(), version11.getName()); + + STEP("5. Retrieve version 2.0 content GET /nodes/{nodeId}/versions/{versionId}/content"); + // verify the content is the same as the uploaded file and check in headers for + // Content-Disposition to validate the download as attachment and fileName. + // wait for content to be picked up on AWS QS stacks + Utility.sleep(1000, 60000, () -> { + RestResponse versionContent = restClient.withCoreAPI().usingNode(file2).getVersionContent("2.0"); + restClient.assertStatusCodeIs(HttpStatus.OK); + + assertEquals("Sample text.\n", versionContent.getResponse().body().asString()); + restClient.assertHeaderValueContains("Content-Disposition", "attachment"); + restClient.assertHeaderValueContains("Content-Disposition", String.format("filename=\"%s\"", file2.getName())); + }); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.SANITY, description = "Test revert and delete a node version.") + public void testRevertDeleteVersion() throws Exception + { + STEP("1. Revert to version 1.0 POST /nodes/{nodeId}/versions/{versionId}/revert"); + RestVersionModel version = restClient.authenticateUser(user2).withCoreAPI().usingNode(file2).revertVersion("1.0", new String("{}")); + restClient.assertStatusCodeIs(HttpStatus.OK); + String nodeVersionType = new JSONObject(version.toJson()).getJSONObject("properties").getString("cm:versionType"); + assertEquals(nodeVersionType, "MINOR"); + String nodeVersion = version.getId(); + + STEP("2. Revert to last minor version /nodes/{nodeId}/versions/{versionId}/revert"); + version = restClient.withCoreAPI().usingNode(file2).revertVersion(nodeVersion, new String("{\"majorVersion\": true}")); + restClient.assertStatusCodeIs(HttpStatus.OK); + nodeVersionType = new JSONObject(version.toJson()).getJSONObject("properties").getString("cm:versionType"); + assertEquals(nodeVersionType, "MAJOR"); + assertTrue(nodeVersion.charAt(0) + 1 == version.getId().charAt(0)); + + STEP("3. Delete last MINOR version DELETE /nodes/{nodeId}/versions/{versionId}"); + restClient.withCoreAPI().usingNode(file2).deleteNodeVersion(nodeVersion); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withCoreAPI().usingNode(file2).getVersionInformation(nodeVersion); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.SANITY, description = "Verify file name in Content Range header") + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY }) + public void checkFileNameContentRangeHeader() throws Exception + { + restClient.configureRequestSpec().addHeader("content-range", "bytes=1-10"); + restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).getNodeContent(); + restClient.assertStatusCodeIs(HttpStatus.PARTIAL_CONTENT); + restClient.assertHeaderValueContains("content-range", "bytes 1-10"); + restClient.assertHeaderValueContains("content-length", String.valueOf(10)); + } + + + private void createRandomFileInDirectory(String path, String fileName, int size) throws IOException { + String fullPath = new File(path, fileName).getPath(); + + RandomAccessFile file = new RandomAccessFile(fullPath,"rw"); + file.setLength(size); + file.close(); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/nodes/NodesLockTests.java b/e2e-test/src/test/java/org/alfresco/rest/nodes/NodesLockTests.java new file mode 100644 index 000000000..ce19991f6 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/nodes/NodesLockTests.java @@ -0,0 +1,761 @@ +package org.alfresco.rest.nodes; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestNodeModel; +import org.alfresco.rest.model.body.RestNodeLockBodyModel; +import org.alfresco.rest.search.RestRequestFilterQueryModel; +import org.alfresco.rest.search.RestRequestQueryModel; +import org.alfresco.rest.search.SearchRequest; +import org.alfresco.rest.search.SearchResponse; +import org.alfresco.utility.Utility; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.report.Bug.Status; +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; + +import static org.alfresco.utility.report.log.Step.STEP; + +public class NodesLockTests extends RestTest +{ + private UserModel user1, user2, adminUser; + private SiteModel publicSite; + private FileModel file1; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + publicSite = dataSite.usingUser(adminUser).createPublicRandomSite(); + user1 = dataUser.createRandomTestUser(); + user2 = dataUser.createRandomTestUser(); + dataUser.addUserToSite(user1, publicSite, UserRole.SiteCollaborator); + user1.setUserRole(UserRole.SiteCollaborator); + dataUser.addUserToSite(user2, publicSite, UserRole.SiteCollaborator); + user2.setUserRole(UserRole.SiteCollaborator); + + } + + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, + description = "Verify Collaborator can not lock PERSISTENT after EPHEMERAL lock made by different user") + public void lockEphemeralAndRelockPersistentDifferentUser() throws Exception + { + STEP("1. Administrator adds a file in the site."); + file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); + + STEP("2. Verify with admin that the file is not locked."); + RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); + file1Model1.assertThat().field("isLocked").is(false); + + STEP("3. Lock the file using mode EPHEMERAL for 20 seconds with user1 (POST nodes/{nodeId}/lock)."); + RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); + lockBodyModel.setLifetime("EPHEMERAL"); + lockBodyModel.setTimeToExpire(20); + lockBodyModel.setType("FULL"); + restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").lockNode(lockBodyModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + + STEP("4. Verify with user1 that the file is locked."); + RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); + file1Model2.assertThat().field("isLocked").is(true) + .assertThat().field("properties").contains("lockLifetime=EPHEMERAL") + .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); + + STEP("5. Cannot lock the file using mode PERSISTENT with user2 while the file is still locked"); + RestNodeLockBodyModel lockBodyModel2 = new RestNodeLockBodyModel(); + lockBodyModel2.setLifetime("PERSISTENT"); + lockBodyModel2.setTimeToExpire(20); + lockBodyModel2.setType("ALLOW_OWNER_CHANGES"); + restClient.authenticateUser(user2).withCoreAPI().usingNode(file1).usingParams("include=isLocked").lockNode(lockBodyModel2); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() + .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .containsSummary(String.format(RestErrorModel.LOCKED_NODE_SUMMARY, file1.getNodeRefWithoutVersion())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, + description = "Verify Collaborator can not lock EPHEMERAL after EPHEMERAL lock made by different user") + public void lockEphemeralAndRelockEphemeralDifferentUser() throws Exception + { + STEP("1. Adds a file in the site by administrator."); + file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); + + STEP("2. Verify with admin that the file is not locked."); + RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); + file1Model1.assertThat().field("isLocked").is(false); + + STEP("3. Lock the file using mode EPHEMERAL with user1 (POST nodes/{nodeId}/lock)."); + RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); + lockBodyModel.setLifetime("EPHEMERAL"); + lockBodyModel.setTimeToExpire(20); + lockBodyModel.setType("FULL"); + restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + + STEP("4. Verify with user1 that the file is locked."); + RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); + file1Model2.assertThat().field("isLocked").is(true) + .assertThat().field("properties").contains("lockLifetime=EPHEMERAL") + .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); + + STEP("5. Cannot lock the file using mode EPHEMERAL with user2 while the file is still locked"); + RestNodeLockBodyModel lockBodyModel2 = new RestNodeLockBodyModel(); + lockBodyModel2.setLifetime("EPHEMERAL"); + lockBodyModel2.setTimeToExpire(20); + lockBodyModel2.setType("FULL"); + restClient.authenticateUser(user2).withCoreAPI().usingNode(file1).usingParams("include=isLocked").lockNode(lockBodyModel2); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() + .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .containsSummary(String.format(RestErrorModel.LOCKED_NODE_SUMMARY, file1.getNodeRefWithoutVersion())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, + description = "Verify Collaborator can lock EPHEMERAL after EPHEMERAL lock made by same user") + public void lockEphemeralAndRelockEphemeralSameUser() throws Exception + { + STEP("1. Adds a file in the site by administrator."); + file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); + + STEP("2. Verify with admin that the file is not locked."); + RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); + file1Model1.assertThat().field("isLocked").is(false); + + STEP("3. Lock the file using mode EPHEMERAL with user1 (POST nodes/{nodeId}/lock)."); + RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); + lockBodyModel.setLifetime("EPHEMERAL"); + lockBodyModel.setTimeToExpire(20); + lockBodyModel.setType("FULL"); + restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + + STEP("4. Verify with user1 that the file is locked."); + RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); + file1Model2.assertThat().field("isLocked").is(true) + .assertThat().field("properties").contains("lockLifetime=EPHEMERAL") + .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); + + STEP("5. Lock the file using mode EPHEMERAL with user1 while the file is still locked"); + RestNodeLockBodyModel lockBodyModel2 = new RestNodeLockBodyModel(); + lockBodyModel2.setLifetime("EPHEMERAL"); + lockBodyModel2.setTimeToExpire(20); + lockBodyModel2.setType("FULL"); + RestNodeModel file1Model3 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").lockNode(lockBodyModel2); + restClient.assertStatusCodeIs(HttpStatus.OK); + file1Model3.assertThat().field("isLocked").is(true) + .assertThat().field("properties").contains("lockLifetime=EPHEMERAL") + .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); + } + + @Bug(id = "MNT-17612", status = Status.FIXED, description = "AccessDeniedException in AOS Edit Offline Upload New Version") + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, + description = "Verify Collaborator can lock PERSISTENT after EPHEMERAL lock made by same user") + public void lockEphemeralAndRelockPersistentSameUser() throws Exception + { + STEP("1. Adds a file in the site by administrator."); + file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); + + STEP("2. Verify with admin that the file is not locked."); + RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); + file1Model1.assertThat().field("isLocked").is(false); + + STEP("3. Lock the file using mode EPHEMERAL with user1 (POST nodes/{nodeId}/lock)."); + RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); + lockBodyModel.setLifetime("EPHEMERAL"); + lockBodyModel.setTimeToExpire(2); + lockBodyModel.setType("FULL"); + restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + + STEP("4. Verify with user1 that the file is locked."); + RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); + file1Model2.assertThat().field("isLocked").is(true) + .assertThat().field("properties").contains("lockLifetime=EPHEMERAL") + .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); + + STEP("5. Lock the file using mode PERSISTENT with user1 while the file is still locked"); + RestNodeLockBodyModel lockBodyModel2 = new RestNodeLockBodyModel(); + lockBodyModel2.setLifetime("PERSISTENT"); + lockBodyModel2.setTimeToExpire(20); + lockBodyModel2.setType("ALLOW_OWNER_CHANGES"); + RestNodeModel file1Model3 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").lockNode(lockBodyModel2); + restClient.assertStatusCodeIs(HttpStatus.OK); + file1Model3.assertThat().field("isLocked").is(true) + .assertThat().field("properties").contains("lockLifetime=EPHEMERAL") + .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); + + STEP("6. Verify that the file is locked PERSISTENT only after EPHEMERAL lock has expired"); + try{Thread.sleep(2500);}finally{} + RestNodeModel file1Model4 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); + file1Model4.assertThat().field("isLocked").is(true) + .assertThat().field("properties").contains("lockLifetime=PERSISTENT") + .assertThat().field("properties").contains("lockType=WRITE_LOCK"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, + description = "Verify Collaborator can not lock EPHEMERAL after PERSISTENT lock made by different user") + public void lockPersistentAndRelockEphemeralDifferentUser() throws Exception + { + STEP("1. Adds a file in the site by administrator."); + file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); + + STEP("2. Verify with admin that the file is not locked."); + RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); + file1Model1.assertThat().field("isLocked").is(false); + + STEP("3. Lock the file using mode PERSISTENT with user1 (POST nodes/{nodeId}/lock)."); + RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); + lockBodyModel.setLifetime("PERSISTENT"); + lockBodyModel.setTimeToExpire(20); + lockBodyModel.setType("ALLOW_OWNER_CHANGES"); + restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + + STEP("4. Verify with user1 that the file is locked."); + RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); + file1Model2.assertThat().field("isLocked").is(true) + .assertThat().field("properties").contains("lockLifetime=PERSISTENT") + .assertThat().field("properties").contains("lockType=WRITE_LOCK"); + + STEP("5. Cannot lock the file using mode EPHEMERAL with user2 while the file is still locked"); + RestNodeLockBodyModel lockBodyModel2 = new RestNodeLockBodyModel(); + lockBodyModel2.setLifetime("EPHEMERAL"); + lockBodyModel2.setTimeToExpire(20); + lockBodyModel2.setType("FULL"); + restClient.authenticateUser(user2).withCoreAPI().usingNode(file1).usingParams("include=isLocked").lockNode(lockBodyModel2); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() + .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .containsSummary(String.format(RestErrorModel.LOCKED_NODE_SUMMARY, file1.getNodeRefWithoutVersion())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, + description = "Verify Collaborator can not lock PERSISTENT after PERSISTENT lock made by different user") + public void lockPersistentAndRelockPersistentDifferentUser() throws Exception + { + STEP("1. Adds a file in the site by administrator."); + file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); + + STEP("2. Verify with admin that the file is not locked."); + RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); + file1Model1.assertThat().field("isLocked").is(false); + + STEP("3. Lock the file using mode PERSISTENT with user1 (POST nodes/{nodeId}/lock)."); + RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); + lockBodyModel.setLifetime("PERSISTENT"); + lockBodyModel.setTimeToExpire(20); + lockBodyModel.setType("ALLOW_OWNER_CHANGES"); + restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + + STEP("4. Verify with user1 that the file is locked."); + RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); + file1Model2.assertThat().field("isLocked").is(true) + .assertThat().field("properties").contains("lockLifetime=PERSISTENT") + .assertThat().field("properties").contains("lockType=WRITE_LOCK"); + + STEP("5. Cannot lock the file using mode PERSISTENT with user2 while the file is still locked"); + RestNodeLockBodyModel lockBodyModel2 = new RestNodeLockBodyModel(); + lockBodyModel2.setLifetime("PERSISTENT"); + lockBodyModel2.setTimeToExpire(20); + lockBodyModel2.setType("ALLOW_OWNER_CHANGES"); + restClient.authenticateUser(user2).withCoreAPI().usingNode(file1).usingParams("include=isLocked").lockNode(lockBodyModel2); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() + .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .containsSummary(String.format(RestErrorModel.LOCKED_NODE_SUMMARY, file1.getNodeRefWithoutVersion())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, + description = "Verify Collaborator can lock EPHEMERAL after PERSISTENT lock made by different user is expired") + public void lockPersistentAndRelockEphemeralAfterExpiredLockDifferentUser() throws Exception + { + STEP("1. Adds a file in the site by administrator."); + file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); + + STEP("2. Verify with admin that the file is not locked."); + RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); + file1Model1.assertThat().field("isLocked").is(false); + + STEP("3. Lock the file using mode PERSISTENT with user1 (POST nodes/{nodeId}/lock)."); + RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); + lockBodyModel.setLifetime("PERSISTENT"); + lockBodyModel.setTimeToExpire(1); + lockBodyModel.setType("ALLOW_OWNER_CHANGES"); + restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + + STEP("4. Verify with admin that the file is locked."); + RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); + file1Model2.assertThat().field("isLocked").is(true) + .assertThat().field("properties").contains("lockLifetime=PERSISTENT") + .assertThat().field("properties").contains("lockType=WRITE_LOCK"); + + STEP("5. Lock the file using mode EPHEMERAL with user2 while the first lock has expired"); + RestNodeLockBodyModel lockBodyModel2 = new RestNodeLockBodyModel(); + lockBodyModel2.setLifetime("EPHEMERAL"); + lockBodyModel2.setTimeToExpire(20); + lockBodyModel2.setType("FULL"); + try{Thread.sleep(1500);}finally{} + RestNodeModel file1Model3 = restClient.authenticateUser(user2).withCoreAPI().usingNode(file1).usingParams("include=isLocked").lockNode(lockBodyModel2); + restClient.assertStatusCodeIs(HttpStatus.OK); + file1Model3.assertThat().field("isLocked").is(true) + .assertThat().field("properties").contains("lockLifetime=EPHEMERAL") + .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); + } + + @Bug(id = "MNT-17612", status = Status.FIXED, description = "AccessDeniedException in AOS Edit Offline Upload New Version") + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, + description = "Verify Collaborator can lock PERSISTENT after EPHEMERAL lock made by another user is expired") + public void lockEphemeralAndRelockPersistentAfterExpiredLockDifferentUser() throws Exception + { + STEP("1. Adds a file in the site by administrator."); + file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); + + STEP("2. Verify with admin that the file is not locked."); + RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); + file1Model1.assertThat().field("isLocked").is(false); + + STEP("3. Lock the file using mode EPHEMERAL with user1 (POST nodes/{nodeId}/lock)."); + RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); + lockBodyModel.setLifetime("EPHEMERAL"); + lockBodyModel.setTimeToExpire(1); + lockBodyModel.setType("FULL"); + restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + + STEP("4. Verify with user1 that the file is locked."); + RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); + file1Model2.assertThat().field("isLocked").is(true) + .assertThat().field("properties").contains("lockLifetime=EPHEMERAL") + .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); + + STEP("5. Lock the file using mode PERSISTENT with user2 after the first lock has expired"); + RestNodeLockBodyModel lockBodyModel2 = new RestNodeLockBodyModel(); + lockBodyModel2.setLifetime("PERSISTENT"); + lockBodyModel2.setTimeToExpire(20); + lockBodyModel2.setType("ALLOW_OWNER_CHANGES"); + try{Thread.sleep(1500);}finally{} + RestNodeModel file1Model3 = restClient.authenticateUser(user2).withCoreAPI().usingNode(file1).usingParams("include=isLocked").lockNode(lockBodyModel2); + restClient.assertStatusCodeIs(HttpStatus.OK); + file1Model3.assertThat().field("isLocked").is(true) + .assertThat().field("properties").contains("lockLifetime=PERSISTENT") + .assertThat().field("properties").contains("lockType=WRITE_LOCK"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, + description = "Verify Collaborator can lock EPHEMERAL after EPHEMERAL lock made by another user is expired") + public void lockEphemeralAndRelockEphemeralAfterExpiredLockDifferentUser() throws Exception + { + STEP("1. Adds a file in the site by administrator."); + file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); + + STEP("2. Verify with admin that the file is not locked."); + RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); + file1Model1.assertThat().field("isLocked").is(false); + + STEP("3. Lock the file using mode EPHEMERAL with user1 (POST nodes/{nodeId}/lock)."); + RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); + lockBodyModel.setLifetime("EPHEMERAL"); + lockBodyModel.setTimeToExpire(1); + lockBodyModel.setType("FULL"); + restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + + STEP("4. Verify with user1 that the file is locked."); + RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); + file1Model2.assertThat().field("isLocked").is(true) + .assertThat().field("properties").contains("lockLifetime=EPHEMERAL") + .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); + + STEP("5. Lock the file using mode EPHEMERAL with user2 while the first lock has expired"); + RestNodeLockBodyModel lockBodyModel2 = new RestNodeLockBodyModel(); + lockBodyModel2.setLifetime("EPHEMERAL"); + lockBodyModel2.setTimeToExpire(20); + lockBodyModel2.setType("FULL"); + try{Thread.sleep(1500);}finally{} + RestNodeModel file1Model3 = restClient.authenticateUser(user2).withCoreAPI().usingNode(file1).usingParams("include=isLocked").lockNode(lockBodyModel2); + restClient.assertStatusCodeIs(HttpStatus.OK); + file1Model3.assertThat().field("isLocked").is(true) + .assertThat().field("properties").contains("lockLifetime=EPHEMERAL") + .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, + description = "Verify Collaborator can lock PERSISTENT after PERSISTENT lock made by different user is expired") + public void lockPersistentAndRelockPersistentAfterExpiredLockDifferentUser() throws Exception + { + STEP("1. Adds a file in the site by administrator."); + file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); + + STEP("2. Verify with admin that the file is not locked."); + RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); + file1Model1.assertThat().field("isLocked").is(false); + + STEP("3. Lock the file using mode PERSISTENT with user1 (POST nodes/{nodeId}/lock)."); + RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); + lockBodyModel.setLifetime("PERSISTENT"); + lockBodyModel.setTimeToExpire(1); + lockBodyModel.setType("ALLOW_OWNER_CHANGES"); + restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + + STEP("4. Verify with admin that the file is locked."); + RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); + file1Model2.assertThat().field("isLocked").is(true) + .assertThat().field("properties").contains("lockLifetime=PERSISTENT") + .assertThat().field("properties").contains("lockType=WRITE_LOCK"); + + STEP("5. Lock the file using mode PERSISTENT with user2 after the first lock has expired"); + RestNodeLockBodyModel lockBodyModel2 = new RestNodeLockBodyModel(); + lockBodyModel2.setLifetime("PERSISTENT"); + lockBodyModel2.setTimeToExpire(20); + lockBodyModel2.setType("ALLOW_OWNER_CHANGES"); + try{Thread.sleep(1500);}finally{} + RestNodeModel file1Model3 = restClient.authenticateUser(user2).withCoreAPI().usingNode(file1).usingParams("include=isLocked").lockNode(lockBodyModel2); + restClient.assertStatusCodeIs(HttpStatus.OK); + file1Model3.assertThat().field("isLocked").is(true) + .assertThat().field("properties").contains("lockLifetime=PERSISTENT") + .assertThat().field("properties").contains("lockType=WRITE_LOCK"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, + description = "Verify Collaborator can lock EPHEMERAL after EPHEMERAL lock made by same user is expired") + public void lockEphemeralAndRelockEphemeralAfterExpiredLockSameUser() throws Exception + { + STEP("1. Adds a file in the site by administrator."); + file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); + + STEP("2. Verify with admin that the file is not locked."); + RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); + file1Model1.assertThat().field("isLocked").is(false); + + STEP("3. Lock the file using mode EPHEMERAL with user1 (POST nodes/{nodeId}/lock)."); + RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); + lockBodyModel.setLifetime("EPHEMERAL"); + lockBodyModel.setTimeToExpire(1); + lockBodyModel.setType("FULL"); + restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + + STEP("4. Verify with user1 that the file is locked."); + RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); + file1Model2.assertThat().field("isLocked").is(true) + .assertThat().field("properties").contains("lockLifetime=EPHEMERAL") + .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); + + STEP("5. Lock the file using mode EPHEMERAL with user1 after the first lock has expired"); + RestNodeLockBodyModel lockBodyModel2 = new RestNodeLockBodyModel(); + lockBodyModel2.setLifetime("EPHEMERAL"); + lockBodyModel2.setTimeToExpire(20); + lockBodyModel2.setType("FULL"); + try{Thread.sleep(1500);}finally{} + RestNodeModel file1Model3 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").lockNode(lockBodyModel2); + restClient.assertStatusCodeIs(HttpStatus.OK); + file1Model3.assertThat().field("isLocked").is(true) + .assertThat().field("properties").contains("lockLifetime=EPHEMERAL") + .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, + description = "Verify Collaborator can lock PERSISTENT after PERSISTENT lock made by same user is expired") + public void lockPersistentAndRelockPersistentAfterExpiredLockSameUser() throws Exception + { + STEP("1. Adds a file in the site by administrator."); + file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); + + STEP("2. Verify with admin that the file is not locked."); + RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); + file1Model1.assertThat().field("isLocked").is(false); + + STEP("3. Lock the file using mode PERSISTENT with user1 (POST nodes/{nodeId}/lock)."); + RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); + lockBodyModel.setLifetime("PERSISTENT"); + lockBodyModel.setTimeToExpire(1); + lockBodyModel.setType("ALLOW_OWNER_CHANGES"); + restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + + STEP("4. Verify with user1 that the file is locked."); + RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); + file1Model2.assertThat().field("isLocked").is(true); + file1Model2.assertThat().field("properties").contains("lockLifetime=PERSISTENT"); + + STEP("5. Lock the file using mode PERSISTENT with user1 while the first lock has expired"); + RestNodeLockBodyModel lockBodyModel2 = new RestNodeLockBodyModel(); + lockBodyModel2.setLifetime("PERSISTENT"); + lockBodyModel2.setTimeToExpire(20); + lockBodyModel2.setType("ALLOW_OWNER_CHANGES"); + try{Thread.sleep(1500);}finally{} + RestNodeModel file1Model3 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").lockNode(lockBodyModel2); + restClient.assertStatusCodeIs(HttpStatus.OK); + file1Model3.assertThat().field("isLocked").is(true) + .assertThat().field("properties").contains("lockLifetime=PERSISTENT") + .assertThat().field("properties").contains("lockType=WRITE_LOCK"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, + description = "Verify Collaborator can lock EPHEMERAL after PERSISTENT lock made by same user is expired") + public void lockPersistentAndRelockEphemeralAfterExpiredLockSameUser() throws Exception + { + STEP("1. Adds a file in the site by administrator."); + file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); + + STEP("2. Verify with admin that the file is not locked."); + RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); + file1Model1.assertThat().field("isLocked").is(false); + + STEP("3. Lock the file using mode PERSISTENT with user1 (POST nodes/{nodeId}/lock)."); + RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); + lockBodyModel.setLifetime("PERSISTENT"); + lockBodyModel.setTimeToExpire(1); + lockBodyModel.setType("ALLOW_OWNER_CHANGES"); + restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + + STEP("4. Verify with admin that the file is locked."); + RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); + file1Model2.assertThat().field("isLocked").is(true) + .assertThat().field("properties").contains("lockLifetime=PERSISTENT") + .assertThat().field("properties").contains("lockType=WRITE_LOCK"); + + STEP("5. Lock the file using mode EPHEMERAL with user1 while the first lock has expired"); + RestNodeLockBodyModel lockBodyModel2 = new RestNodeLockBodyModel(); + lockBodyModel2.setLifetime("EPHEMERAL"); + lockBodyModel2.setTimeToExpire(20); + lockBodyModel2.setType("FULL"); + try{Thread.sleep(1500);}finally{} + RestNodeModel file1Model3 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").lockNode(lockBodyModel2); + restClient.assertStatusCodeIs(HttpStatus.OK); + file1Model3.assertThat().field("isLocked").is(true) + .assertThat().field("properties").contains("lockLifetime=EPHEMERAL") + .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); + } + + @Bug(id = "MNT-17612", status = Status.FIXED, description = "AccessDeniedException in AOS Edit Offline Upload New Version") + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, + description = "Verify Collaborator can lock PERSISTENT after EPHEMERAL lock made by same user is expired") + public void lockEphemeralAndRelockPersistentAfterExpiredLockSameUser() throws Exception + { + STEP("1. Adds a file in the site by administrator."); + file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); + + STEP("2. Verify with admin that the file is not locked."); + RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1) + .usingParams("include=isLocked").getNode(); + file1Model1.assertThat().field("isLocked").is(false); + + STEP("3. Lock the file using mode EPHEMERAL with user1 (POST nodes/{nodeId}/lock)."); + RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); + lockBodyModel.setLifetime("EPHEMERAL"); + lockBodyModel.setTimeToExpire(1); + lockBodyModel.setType("FULL"); + restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + + STEP("4. Verify with useer1 that the file is locked."); + RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); + file1Model2.assertThat().field("isLocked").is(true) + .assertThat().field("properties").contains("lockLifetime=EPHEMERAL") + .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); + + STEP("5. Lock the file using mode PERSISTENT with user1 while the first lock has expired"); + RestNodeLockBodyModel lockBodyModel2 = new RestNodeLockBodyModel(); + lockBodyModel2.setLifetime("PERSISTENT"); + lockBodyModel2.setTimeToExpire(20); + lockBodyModel2.setType("ALLOW_OWNER_CHANGES"); + try{Thread.sleep(1500);}finally{} + RestNodeModel file1Model3 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").lockNode(lockBodyModel2); + restClient.assertStatusCodeIs(HttpStatus.OK); + file1Model3.assertThat().field("isLocked").is(true) + .assertThat().field("properties").contains("lockLifetime=PERSISTENT") + .assertThat().field("properties").contains("lockType=WRITE_LOCK"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, + description = "Verify Collaborator can lock PERSISTENT after PERSISTENT lock made by same user") + public void lockPersistentAndRelockPersistentSameUser() throws Exception + { + STEP("1. Adds a file in the site by administrator."); + file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); + + STEP("2. Verify with admin that the file is not locked."); + RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); + file1Model1.assertThat().field("isLocked").is(false); + + STEP("3. Lock the file using mode PERSISTENT with user1 (POST nodes/{nodeId}/lock)."); + RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); + lockBodyModel.setLifetime("PERSISTENT"); + lockBodyModel.setTimeToExpire(20); + lockBodyModel.setType("ALLOW_OWNER_CHANGES"); + restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + + STEP("4. Verify with user1 that the file is locked."); + RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); + file1Model2.assertThat().field("isLocked").is(true) + .assertThat().field("properties").contains("lockLifetime=PERSISTENT") + .assertThat().field("properties").contains("lockType=WRITE_LOCK"); + + STEP("5. Lock the file using mode PERSISTENT with user1 while the file is still locked"); + RestNodeLockBodyModel lockBodyModel2 = new RestNodeLockBodyModel(); + lockBodyModel2.setLifetime("PERSISTENT"); + lockBodyModel2.setTimeToExpire(20); + lockBodyModel2.setType("ALLOW_OWNER_CHANGES"); + RestNodeModel file1Model3 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").lockNode(lockBodyModel2); + restClient.assertStatusCodeIs(HttpStatus.OK); + file1Model3.assertThat().field("isLocked").is(true); + file1Model3.assertThat().field("properties").contains("lockLifetime=PERSISTENT") + .assertThat().field("properties").contains("lockType=WRITE_LOCK"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, + description = "Verify Collaborator can lock EPHERMERAL after PERSISTENT lock made by same user") + public void lockPersistentAndRelockEphemeralSameUser() throws Exception + { + STEP("1. Adds a file in the site by administrator."); + file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); + + STEP("2. Verify with admin that the file is not locked."); + RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); + file1Model1.assertThat().field("isLocked").is(false); + + STEP("3. Lock the file using mode PERSISTENT with user1 (POST nodes/{nodeId}/lock)."); + RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); + lockBodyModel.setLifetime("PERSISTENT"); + lockBodyModel.setTimeToExpire(1); + lockBodyModel.setType("ALLOW_OWNER_CHANGES"); + restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + + STEP("4. Verify with user1 that the file is locked."); + RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); + file1Model2.assertThat().field("isLocked").is(true) + .assertThat().field("properties").contains("lockLifetime=PERSISTENT") + .assertThat().field("properties").contains("lockType=WRITE_LOCK"); + + STEP("5. Lock the file using mode EPHERMERAL with user1 while the file is still locked"); + RestNodeLockBodyModel lockBodyModel2 = new RestNodeLockBodyModel(); + lockBodyModel2.setLifetime("EPHEMERAL"); + lockBodyModel2.setTimeToExpire(20); + lockBodyModel2.setType("FULL"); + RestNodeModel file1Model3 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").lockNode(lockBodyModel2); + restClient.assertStatusCodeIs(HttpStatus.OK); + file1Model3.assertThat().field("isLocked").is(true); + file1Model3.assertThat().field("properties").contains("lockLifetime=EPHEMERAL") + .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION, TestGroup.REQUIRE_SOLR }) + @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, + description = "Verify that child nodes can be locked differently and unlocked") + public void testLockUnlockParentChild() throws Exception + { + STEP("1. Create user, site, parent node and children nodes."); + SiteModel siteLock = dataSite.usingUser(adminUser).createPublicRandomSite(); + FolderModel parentNode = dataContent.usingUser(adminUser).usingSite(siteLock).createFolder(); + FileModel childNode1 = dataContent.usingUser(adminUser).usingSite(siteLock).usingResource(parentNode).createContent(DocumentType.TEXT_PLAIN); + FileModel childNode2 = dataContent.usingUser(adminUser).usingSite(siteLock).usingResource(parentNode).createContent(DocumentType.TEXT_PLAIN); + + STEP("2. Verify with admin that the file is not locked."); + RestNodeModel restNodeResponse = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(parentNode).usingParams("include=isLocked").getNode(); + restNodeResponse.assertThat().field("isLocked").is(false); + + restNodeResponse = restClient.withCoreAPI().usingNode(childNode1).usingParams("include=isLocked").getNode(); + restNodeResponse.assertThat().field("isLocked").is(false); + + restNodeResponse = restClient.withCoreAPI().usingNode(childNode2).usingParams("include=isLocked").getNode(); + restNodeResponse.assertThat().field("isLocked").is(false); + + STEP("3. Lock childNode1 using mode PERSISTENT with adminUser (POST nodes/{nodeId}/lock)."); + RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); + lockBodyModel.setLifetime("PERSISTENT"); + lockBodyModel.setTimeToExpire(0); + lockBodyModel.setType("ALLOW_OWNER_CHANGES"); + restNodeResponse = restClient.withCoreAPI().usingNode(childNode1).usingParams("include=isLocked").lockNode(lockBodyModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + restNodeResponse.assertThat().field("aspectNames").contains("cm:lockable") + .assertThat().field("isLocked").is(true) + .assertThat().field("properties").contains("lockLifetime=PERSISTENT") + .assertThat().field("properties").contains("lockType=WRITE_LOCK"); + + STEP("4. Lock childNode2 using mode PERSISTENT with adminUser (POST nodes/{nodeId}/lock)."); + lockBodyModel = new RestNodeLockBodyModel(); + lockBodyModel.setLifetime("PERSISTENT"); + lockBodyModel.setTimeToExpire(0); + lockBodyModel.setType("FULL"); + restNodeResponse = restClient.withCoreAPI().usingNode(childNode2).usingParams("include=isLocked").lockNode(lockBodyModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + restNodeResponse.assertThat().field("aspectNames").contains("cm:lockable") + .assertThat().field("isLocked").is(true) + .assertThat().field("properties").contains("lockLifetime=PERSISTENT") + .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); + + STEP("5. Verify that childNode1 and childNode 2 are locked."); + SearchRequest query = new SearchRequest(); + RestRequestQueryModel queryReq = new RestRequestQueryModel(); + RestRequestFilterQueryModel queryFilters = new RestRequestFilterQueryModel(); + queryFilters.setQuery("cm:lockOwner:\'admin\'"); + queryReq.setQuery("ASPECT:\'cm:lockable\'"); + query.setQuery(queryReq); + query.setFilterQueries(queryFilters); + query.setIncludeRequest(false); + + // Allow indexing to complete. + Utility.sleep(1000, 60000, () -> + { + SearchResponse response = query(query); + restClient.assertStatusCodeIs(HttpStatus.OK); + response.assertThat().entriesListContains("id",childNode1.getNodeRefWithoutVersion()); + response.assertThat().entriesListContains("id",childNode2.getNodeRefWithoutVersion()); + }); + + STEP("6. Unlock the nodes."); + restNodeResponse = restClient.withCoreAPI().usingNode(childNode1).usingParams("include=isLocked").unlockNode(); + restNodeResponse.assertThat().field("isLocked").is(false); + + restNodeResponse = restClient.withCoreAPI().usingNode(childNode2).usingParams("include=isLocked").unlockNode(); + restNodeResponse.assertThat().field("isLocked").is(false); + + STEP("7. Verify that childNode1 and childNode2 are not found in the query results."); + // Allow indexing to complete. + Utility.sleep(1000, 60000, () -> + { + SearchResponse response = query(query); + restClient.assertStatusCodeIs(HttpStatus.OK); + response.assertThat().entriesListDoesNotContain("id",childNode1.getNodeRefWithoutVersion()); + response.assertThat().entriesListDoesNotContain("id",childNode2.getNodeRefWithoutVersion()); + }); + } + + protected SearchResponse query(SearchRequest query) throws Exception + { + return restClient.authenticateUser(dataUser.getAdminUser()).withSearchAPI().search(query); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/nodes/NodesParentChildrenTests.java b/e2e-test/src/test/java/org/alfresco/rest/nodes/NodesParentChildrenTests.java new file mode 100644 index 000000000..417eb99d1 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/nodes/NodesParentChildrenTests.java @@ -0,0 +1,205 @@ +package org.alfresco.rest.nodes; + +import static org.alfresco.utility.report.log.Step.STEP; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestNodeBodyModel; +import org.alfresco.rest.model.RestNodeChildAssocModelCollection; +import org.alfresco.rest.model.RestNodeChildAssociationModel; +import org.alfresco.rest.model.RestNodeModel; +import org.alfresco.rest.model.RestNodeModelsCollection; +import org.alfresco.rest.model.RestNodeAssociationModelCollection; +import org.alfresco.rest.model.builder.NodesBuilder; +import org.alfresco.utility.Utility; +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/children + * api-explorer/#!/nodes/secondary-children + * api-explorer/#!/nodes/parents + */ +public class NodesParentChildrenTests extends RestTest +{ + @TestRail(section = { TestGroup.REST_API,TestGroup.NODES }, executionType = ExecutionType.SANITY, + description = "Verify new folder node is created as children on -my- posting as JSON content type") + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY}) + public void createNewFolderNodeViaJason() throws Exception + { + restClient.authenticateUser(dataContent.getAdminUser()); + + RestNodeBodyModel node = new RestNodeBodyModel(); + node.setName("My Folder"); + node.setNodeType("cm:folder"); + + RestNodeModel newNode = restClient.withParams("autoRename=true").withCoreAPI().usingNode(ContentModel.my()).createNode(node); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + newNode.assertThat().field("aspectNames").contains("cm:auditable") + .assertThat().field("isFolder").is(true) + .assertThat().field("isFile").is(false) + .assertThat().field("name").contains(node.getName()); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NODES }, executionType = ExecutionType.REGRESSION, + description = "Verify new folder node is created as children on -my- posting as MultiPart content type") + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION}) + public void createNewFolderNodeWithMultiPartForms() throws Exception + { + //configuring multipart form + restClient.authenticateUser(dataContent.getAdminUser()) + .configureRequestSpec() + .addMultiPart("filedata", Utility.getResourceTestDataFile("restapi-resource")) + .addFormParam("renditions", "doclib") + .addFormParam("autoRename", true); + + RestNodeModel newNode = restClient.withCoreAPI().usingNode(ContentModel.my()).createNode(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + newNode.assertThat().field("aspectNames").contains("cm:auditable") + .assertThat().field("isFolder").is(false) + .assertThat().field("isFile").is(true) + .assertThat().field("name").contains("restapi-resource"); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NODES }, executionType = ExecutionType.SANITY, + description = "Verify list children when listing with relativePath and pagination") + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY}) + public void checkRelativePathAndPaginationOnCreateChildrenNode() throws Exception + { + /* + * Given we have a folder hierarchy folder1/folder2/folder3 and folder3 containing 3 files file1, file2, and file3 + */ + NodesBuilder nodesBuilder = restClient.authenticateUser(dataUser.getAdminUser()) + .withCoreAPI().usingNode(ContentModel.my()) + .defineNodes(); + nodesBuilder + .folder("F1") + .folder("F2") + .folder("F3") + .file("f1") + .file("f2") + .file("f3"); + + RestNodeModelsCollection returnedFiles = restClient.withParams("maxItems=2", + "skipCount=1", + String.format("relativePath=%s/%s", nodesBuilder.getNode("F2").getName(), nodesBuilder.getNode("F3").getName())) + .withCoreAPI().usingNode(nodesBuilder.getNode("F1").toContentModel()).listChildren(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + /* + * Then I receive file2 and file3 + */ + returnedFiles.assertThat().entriesListCountIs(2); + returnedFiles.getEntries().get(0).onModel().assertThat().field("id").is(nodesBuilder.getNode("f2").getId()); + returnedFiles.getEntries().get(1).onModel().assertThat().field("id").is(nodesBuilder.getNode("f3").getId()); + } + + /** + * Sanity check for the following api endpoints + * POST /nodes/{nodeId}/secondary-children + * GET /nodes/{nodeId}/secondary-children + * DELETE /nodes/{nodeId}/secondary-children/{childId} + */ + @TestRail(section = { TestGroup.REST_API, + TestGroup.NODES }, executionType = ExecutionType.SANITY, description = "Check /secondary-children (create, list, delete) api calls") + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY }) + public void checkSecondaryChildrenApi() throws Exception + { + STEP("1. Create a folder hierarchy folder1/folder2, with folder2 containing 3 files: f1, f2, and f3"); + NodesBuilder nodesBuilder = restClient.authenticateUser(dataUser.getAdminUser()) + .withCoreAPI().usingNode(ContentModel.my()) + .defineNodes(); + nodesBuilder + .folder("F1") + .folder("F2") + .file("f1") + .file("f2") + .file("f3"); + + STEP("2. Create secondary child associations model objects"); + RestNodeChildAssociationModel childAssoc1 = new RestNodeChildAssociationModel(nodesBuilder.getNode("f1").getId(), "cm:contains"); + RestNodeChildAssociationModel childAssoc2 = new RestNodeChildAssociationModel(nodesBuilder.getNode("f2").getId(), "cm:contains"); + RestNodeChildAssociationModel childAssoc3 = new RestNodeChildAssociationModel(nodesBuilder.getNode("f3").getId(), "cm:preferenceImage"); + String secondaryChildrenBody = "[" + childAssoc1.toJson() + "," + childAssoc2.toJson() + "," + childAssoc3.toJson() + "]"; + + STEP("3. Create secondary child associations using POST /nodes/{nodeId}/secondary-children"); + RestNodeChildAssocModelCollection secondaryChildAssoc = restClient.withCoreAPI().usingNode(nodesBuilder.getNode("F1").toContentModel()) + .createSecondaryChildren(secondaryChildrenBody); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + secondaryChildAssoc.getEntryByIndex(0).assertThat().field("childId").is(childAssoc1.getChildId()); + secondaryChildAssoc.getEntryByIndex(1).assertThat().field("childId").is(childAssoc2.getChildId()); + secondaryChildAssoc.getEntryByIndex(2).assertThat().field("childId").is(childAssoc3.getChildId()); + + STEP("4. Check using GET /nodes/{nodeId}/secondary-children that the secondary 'cm:contains' child associations were created"); + RestNodeAssociationModelCollection secondaryChildren = restClient.withParams("where=(assocType='cm:contains')").withCoreAPI() + .usingNode(nodesBuilder.getNode("F1").toContentModel()).getSecondaryChildren(); + restClient.assertStatusCodeIs(HttpStatus.OK); + secondaryChildren.assertThat().entriesListCountIs(2); + + STEP("5. Check using DELETE /nodes/{nodeId}/secondary-children/{childId} that a secondary child can be deleted"); + restClient.withCoreAPI().usingNode(nodesBuilder.getNode("F1").toContentModel()).deleteSecondaryChild(secondaryChildren.getEntryByIndex(0)); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + STEP("6. Check using GET /nodes/{nodeId}/secondary-children that a secondary child association was deleted"); + secondaryChildren = restClient.withCoreAPI().usingNode(nodesBuilder.getNode("F1").toContentModel()) + .getSecondaryChildren(); + restClient.assertStatusCodeIs(HttpStatus.OK); + secondaryChildren.assertThat().entriesListCountIs(2); + secondaryChildren.getEntryByIndex(0).assertThat() + .field("id").is(secondaryChildAssoc.getEntryByIndex(1).getChildId()).and() + .field("parentId").is(nodesBuilder.getNode("F2").getId()) + .getAssociation().assertThat() + .field("isPrimary").is(false).and() + .field("assocType").is("cm:contains"); + secondaryChildren.getEntryByIndex(1).assertThat() + .field("id").is(secondaryChildAssoc.getEntryByIndex(2).getChildId()) + .getAssociation().assertThat() + .field("assocType").is("cm:preferenceImage"); + } + + /** + * Sanity check for the following api endpoint + * GET /nodes/{nodeId}/parents + */ + @TestRail(section = { TestGroup.REST_API, + TestGroup.NODES }, executionType = ExecutionType.SANITY, description = "Check that GET /parents retrieves primary and secondary parents for a node") + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY }) + public void checkGetNodeParents() throws Exception + { + STEP("1. Create a folder hierarchy folder1/folder2, with folder2 containing file f1"); + NodesBuilder nodesBuilder = restClient.authenticateUser(dataUser.getAdminUser()) + .withCoreAPI().usingNode(ContentModel.my()) + .defineNodes(); + nodesBuilder + .folder("F1") + .folder("F2") + .file("f1"); + + STEP("2. Create secondary child associations using POST /nodes/{nodeId}/secondary-children"); + RestNodeChildAssociationModel childAssoc = new RestNodeChildAssociationModel(nodesBuilder.getNode("f1").getId(), "cm:contains"); + restClient.withCoreAPI().usingNode(nodesBuilder.getNode("F1").toContentModel()).createSecondaryChildren(childAssoc.toJson()); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + STEP("3. Get all parents for file 'f1' - both primary and secondary"); + RestNodeAssociationModelCollection parents = restClient.withCoreAPI().usingNode(nodesBuilder.getNode("f1").toContentModel()).getParents(); + restClient.assertStatusCodeIs(HttpStatus.OK); + parents.assertThat().entriesListCountIs(2); + + STEP("4. Check using GET /nodes/{nodeId}/parents that the parent (not primary) for f1 is found"); + parents = restClient.withParams("where=(isPrimary=false)").withCoreAPI().usingNode(nodesBuilder.getNode("f1").toContentModel()).getParents(); + restClient.assertStatusCodeIs(HttpStatus.OK); + parents.assertThat().entriesListCountIs(1); + parents.getEntryByIndex(0).assertThat() + .field("isFolder").is("true").and() + .field("isFile").is(false).and() + .field("name").is(nodesBuilder.getNode("F1").getName()) + .getAssociation().assertThat() + .field("isPrimary").is(false).and() + .field("assocType").is("cm:contains"); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/nodes/NodesTargetSourcesTests.java b/e2e-test/src/test/java/org/alfresco/rest/nodes/NodesTargetSourcesTests.java new file mode 100644 index 000000000..83863ad59 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/nodes/NodesTargetSourcesTests.java @@ -0,0 +1,120 @@ +package org.alfresco.rest.nodes; + +import static org.alfresco.utility.report.log.Step.STEP; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestNodeAssocTargetModel; +import org.alfresco.rest.model.RestNodeAssociationModelCollection; +import org.alfresco.rest.model.builder.NodesBuilder; +import org.alfresco.utility.model.ContentModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class NodesTargetSourcesTests extends RestTest +{ + + private UserModel adminUserModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + } + + /** + * Sanity check for the following api endpoints + * POST /nodes/{nodeId}/targets + * GET /nodes/{nodeId}/targets + * DELETE /nodes/{nodeId}/targets/{targetId} + */ + + @TestRail(section = { TestGroup.REST_API, + TestGroup.NODES }, executionType = ExecutionType.SANITY, description = "Check /targets (create, list, delete) api calls") + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY }) + public void checkTargetsNodeApi() throws Exception + { + STEP("1.Create folder1 which contains 3 files: f1, f2, and f3"); + NodesBuilder nodesBuilder = restClient.authenticateUser(adminUserModel).withCoreAPI().usingNode(ContentModel.my()).defineNodes(); + nodesBuilder.folder("F1").file("f1").file("f2").file("f3"); + + STEP("2. Create target associations model objects"); + RestNodeAssocTargetModel assocDocTarget1 = new RestNodeAssocTargetModel(nodesBuilder.getNode("f2").toContentModel().getNodeRef(), "cm:references"); + RestNodeAssocTargetModel assocDocTarget2 = new RestNodeAssocTargetModel(nodesBuilder.getNode("f3").toContentModel().getNodeRef(), "cm:references"); + + STEP("3. Create target associations using POST /nodes/{nodeId}/targets"); + restClient.withCoreAPI().usingResource(nodesBuilder.getNode("f1").toContentModel()).createTargetForNode(assocDocTarget1); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.withCoreAPI().usingResource(nodesBuilder.getNode("f1").toContentModel()).createTargetForNode(assocDocTarget2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + STEP("4. Check using GET /nodes/{nodeId}/targets targets associations were created"); + RestNodeAssociationModelCollection targetsRes = restClient.withParams("where=(assocType='cm:references')").withCoreAPI().usingResource(nodesBuilder.getNode("f1").toContentModel()).getNodeTargets(); + restClient.assertStatusCodeIs(HttpStatus.OK); + targetsRes.assertThat().entriesListCountIs(2); + targetsRes.getEntryByIndex(0).assertThat().field("association.assocType").is("cm:references").and().field("name") + .is(nodesBuilder.getNode("f2").getName()); + targetsRes.getEntryByIndex(1).assertThat().field("association.assocType").is("cm:references").and().field("name") + .is(nodesBuilder.getNode("f3").getName()); + + STEP("5. Check using DELETE /nodes/{nodeId}/targets/{targetId} that a target can be deleted"); + restClient.authenticateUser(adminUserModel); + restClient.withCoreAPI().usingResource(nodesBuilder.getNode("f1").toContentModel()).deleteTarget(assocDocTarget1); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + STEP("6. Check using GET /nodes/{nodeId}/targets that target association was deleted"); + targetsRes = restClient.withParams("where=(assocType='cm:references')").withCoreAPI() + .usingResource(nodesBuilder.getNode("f1").toContentModel()).getNodeTargets(); + restClient.assertStatusCodeIs(HttpStatus.OK); + targetsRes.assertThat().entriesListCountIs(1); + targetsRes.getEntryByIndex(0).assertThat().field("association.assocType").is("cm:references"); + } + + /** + * Sanity check for the following api endpoint + * GET /nodes/{nodeId}/sources + */ + @TestRail(section = { TestGroup.REST_API, + TestGroup.NODES }, executionType = ExecutionType.SANITY, description = "Check that source objects are retrieved using GET /nodes/{nodeId}/sources") + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY }) + public void checkGetNodeSources() throws Exception + { + STEP("1.Create a folder hierarchy folder1 containing 4 files: f1, f2, and f3"); + NodesBuilder nodesBuilder = restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingNode(ContentModel.my()).defineNodes(); + nodesBuilder.folder("F1").file("f1").file("f2").file("f3"); + + STEP("2. Create target associations model objects"); + RestNodeAssocTargetModel assocDocTarget1 = new RestNodeAssocTargetModel(nodesBuilder.getNode("f3").toContentModel().getNodeRef(), "cm:references"); + RestNodeAssocTargetModel assocDocTarget2 = new RestNodeAssocTargetModel(nodesBuilder.getNode("f3").toContentModel().getNodeRef(), "cm:preferenceImage"); + + STEP("3. Create target associations using POST /nodes/{nodeId}/targets"); + restClient.authenticateUser(adminUserModel); + restClient.withCoreAPI().usingResource(nodesBuilder.getNode("f1").toContentModel()).createTargetForNode(assocDocTarget1); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.withCoreAPI().usingResource(nodesBuilder.getNode("f2").toContentModel()).createTargetForNode(assocDocTarget2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + STEP("4. Check using GET /nodes/{nodeId}/sources that all source associations are displayed"); + RestNodeAssociationModelCollection sources = restClient.withCoreAPI().usingResource(nodesBuilder.getNode("f3").toContentModel()).getNodeSources(); + restClient.assertStatusCodeIs(HttpStatus.OK); + sources.assertThat().entriesListCountIs(2); + + STEP("5. Check using GET /nodes/{nodeId}/sources with params that sources and fields can be filtered in the response"); + sources = restClient.withParams("where=(assocType='cm:references')", "fields=isFile,name,association,id,nodeType,parentId").withCoreAPI().usingResource(nodesBuilder.getNode("f3").toContentModel()).getNodeSources(); + restClient.assertStatusCodeIs(HttpStatus.OK); + sources.assertThat().entriesListCountIs(1); + + sources.getEntryByIndex(0).assertThat() + .field("isFile").is(true).and() + .field("name").is(nodesBuilder.getNode("f1").getName()).and() + .field("id").is(nodesBuilder.getNode("f1").getId()).and() + .field("id").is(nodesBuilder.getNode("f1").getId()).and() + .field("nodeType").is("cm:content") + .getAssociation().assertThat() + .field("assocType").is("cm:references"); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/nodes/NodesTests.java b/e2e-test/src/test/java/org/alfresco/rest/nodes/NodesTests.java new file mode 100644 index 000000000..b122296c6 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/nodes/NodesTests.java @@ -0,0 +1,56 @@ +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()); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/nodes/NodesUnlockTests.java b/e2e-test/src/test/java/org/alfresco/rest/nodes/NodesUnlockTests.java new file mode 100644 index 000000000..ca10a5c59 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/nodes/NodesUnlockTests.java @@ -0,0 +1,112 @@ +package org.alfresco.rest.nodes; + +import static org.alfresco.utility.report.log.Step.STEP; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestNodeModel; +import org.alfresco.rest.model.body.RestNodeLockBodyModel; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class NodesUnlockTests extends RestTest +{ + private UserModel user1, user2, adminUser; + private SiteModel publicSite; + private FileModel file1; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + publicSite = dataSite.usingUser(adminUser).createPublicRandomSite(); + user1 = dataUser.createRandomTestUser(); + user2 = dataUser.createRandomTestUser(); + dataUser.addUserToSite(user1, publicSite, UserRole.SiteCollaborator); + user1.setUserRole(UserRole.SiteCollaborator); + dataUser.addUserToSite(user2, publicSite, UserRole.SiteCollaborator); + user2.setUserRole(UserRole.SiteCollaborator); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY }) + @TestRail(section={TestGroup.REST_API, TestGroup.NODES}, executionType= ExecutionType.SANITY, + description= "Verify Collaborator canot unlock EPHEMERAL lock made by different user, but can unlock EPHEMERAL lock made by same user") + public void lockEphemeralAndUnlock() throws Exception + { + STEP("1. Add user(s) as collaborators to the site created by administrator and add a file in this site."); + file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); + + STEP("2. Verify with user1 that the file is not locked."); + RestNodeModel file1Model1 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); + file1Model1.assertThat().field("isLocked").is(false); + + STEP("3. Lock the file using mode EPHEMERAL with user1 (POST nodes/{nodeId}/lock)."); + RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); + lockBodyModel.setLifetime("EPHEMERAL"); + lockBodyModel.setTimeToExpire(20); + restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + + STEP("4. Verify with user1 that the file is locked."); + RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); + file1Model2.assertThat().field("isLocked").is(true); + + STEP("5. Cannot unlock the file with user2 while the file is still locked"); + restClient.authenticateUser(user2).withCoreAPI().usingNode(file1).usingParams("include=isLocked").unlockNode(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError() + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + + STEP("6. Unlock the file with user1 while the file is still locked"); + RestNodeModel file1Model3 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").unlockNode(); + file1Model3.assertThat().field("isLocked").is(false); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY }) + @TestRail(section={TestGroup.REST_API, TestGroup.NODES}, executionType= ExecutionType.SANITY, + description= "Verify Collaborator canot unlock PERSISTENT lock made by different user, but can unlock PERSISTENT lock made by same user") + public void lockPersistentAndUnlock() throws Exception{ + + STEP("1. Add user(s) as collaborators to the site created by administrator and add a file in this site."); + file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); + + STEP("2. Verify with admin that the file is not locked."); + RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); + file1Model1.assertThat().field("isLocked").is(false); + + STEP("3. Lock the file using mode PERSISTENT with user1 (POST nodes/{nodeId}/lock)."); + RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); + lockBodyModel.setLifetime("PERSISTENT"); + lockBodyModel.setTimeToExpire(20); + restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + + STEP("4. Verify with user1 that the file is locked."); + RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); + file1Model2.assertThat().field("isLocked").is(true); + + STEP("5. Cannot unlock the file with user2 while the file is still locked"); + restClient.authenticateUser(user2).withCoreAPI().usingNode(file1).usingParams("include=isLocked").unlockNode(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError() + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + + STEP("6. Unlock the file with user1 while the file is still locked"); + RestNodeModel file1Model3 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").unlockNode(); + file1Model3.assertThat().field("isLocked").is(false); + } + +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/people/AvatarPeopleSanityTest.java b/e2e-test/src/test/java/org/alfresco/rest/people/AvatarPeopleSanityTest.java new file mode 100644 index 000000000..73aae3bdf --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/people/AvatarPeopleSanityTest.java @@ -0,0 +1,66 @@ +package org.alfresco.rest.people; + +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertTrue; + +import java.io.File; + +import org.alfresco.rest.RestTest; +import org.alfresco.utility.Utility; +import org.alfresco.utility.exception.DataPreparationException; +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; + +import com.jayway.restassured.response.ValidatableResponse; + +public class AvatarPeopleSanityTest extends RestTest +{ + + private UserModel userModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws DataPreparationException + { + userModel = dataUser.createRandomTestUser(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY, TestGroup.REQUIRE_TRANSFORMATION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Update Avatar for People") + public void updateGetAvatarForPeople() throws Exception + { + File avatarFile = Utility.getResourceTestDataFile("avatar.jpg"); + restClient.authenticateUser(userModel); + ValidatableResponse response = restClient.withCoreAPI().usingAuthUser() + .uploadAvatarContent(restProperties.envProperty().getFullServerUrl(), avatarFile).statusCode(200); + // Renditions are async + Utility.sleep(500, 60000, () -> + { + restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().downloadAvatarContent(); + restClient.assertStatusCodeIs(HttpStatus.OK); + }); + assertNotNull(response.extract().body().asByteArray()); + assertTrue(response.extract().body().asByteArray().length > 0, "Avatar Image not uploaded"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY, TestGroup.REQUIRE_TRANSFORMATION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Remove Avatar for People") + public void removeGetAvatarForPeople() throws Exception + { + File avatarFile = Utility.getResourceTestDataFile("avatar.jpg"); + restClient.authenticateUser(userModel); + restClient.withCoreAPI().usingAuthUser().uploadAvatarContent(restProperties.envProperty().getFullServerUrl(), avatarFile).statusCode(200); + + restClient.authenticateUser(userModel); + restClient.withCoreAPI().usingAuthUser().resetAvatarImageRequest(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().downloadAvatarContent(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } + +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/people/DeleteSiteMemberCoreTests.java b/e2e-test/src/test/java/org/alfresco/rest/people/DeleteSiteMemberCoreTests.java new file mode 100644 index 000000000..71c5eb18a --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/people/DeleteSiteMemberCoreTests.java @@ -0,0 +1,229 @@ +package org.alfresco.rest.people; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +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.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class DeleteSiteMemberCoreTests extends RestTest +{ + private UserModel userModel; + private UserModel managerModel; + private SiteModel publicSiteModel; + private SiteModel moderatedSiteModel; + private SiteModel privateSiteModel; + private UserModel adminUserModel; + private UserModel secondUserModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + secondUserModel = dataUser.createRandomTestUser(); + secondUserModel.setUserRole(UserRole.SiteCollaborator); + userModel = dataUser.createRandomTestUser(); + userModel.setUserRole(UserRole.SiteCollaborator); + managerModel = dataUser.createRandomTestUser(); + managerModel.setUserRole(UserRole.SiteManager); + adminUserModel = dataUser.getAdminUser(); + publicSiteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + moderatedSiteModel = dataSite.usingUser(adminUserModel).createModeratedRandomSite(); + privateSiteModel = dataSite.usingUser(adminUserModel).createPrivateRandomSite(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user removes a site member using '-me-' in place of personId and response is successful (204)") + public void removeSiteMemberWithSuccessUsingMeAsPersonId() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(userModel); + + restClient.authenticateUser(userModel).withCoreAPI().usingMe().deleteSiteMember(publicSiteModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user can't remove a site membership of an inexistent uer and response is 404") + public void userIsNotAbleToRemoveInexistentSiteMember() throws Exception + { + UserModel inexistentUser = new UserModel("inexistenUser", "password"); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(inexistentUser).deleteSiteMember(publicSiteModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, inexistentUser.getUsername())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove a member of an inexistent site and response is 404") + public void userIsNotAbleToRemoveMembershipOfInexistentSite() throws Exception + { + SiteModel inexistentSite = new SiteModel("inexistentSite"); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(userModel).deleteSiteMember(inexistentSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, userModel.getUsername(), inexistentSite.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove a member of an empty site id and response is 404") + public void userIsNotAbleToRemoveMembershipOfEmptySiteId() throws Exception + { + SiteModel inexistentSite = new SiteModel(""); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(userModel).deleteSiteMember(inexistentSite); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.DELETE_EMPTY_ARGUMENT); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove a regular member a moderated site and response is 422") + public void regularUserIsNotAbleToRemoveRegularUserSiteMembershipFromModeratedSite() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(secondUserModel); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(userModel); + restClient.authenticateUser(secondUserModel).withCoreAPI().usingUser(userModel).deleteSiteMember(moderatedSiteModel); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() + .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, moderatedSiteModel.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove a regular member of a private site and response is 422") + public void regularUserIsNotAbleToRemoveRegularUserSiteMembershipFromPrivateSite() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(userModel); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(secondUserModel); + restClient.authenticateUser(secondUserModel).withCoreAPI().usingUser(userModel).deleteSiteMember(privateSiteModel); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() + .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, privateSiteModel.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove a regular member of a moderated site and response is 204") + public void adminIsAbleToRemoveRegularUserSiteMembershipFromModeratedSite() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(userModel); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(userModel).deleteSiteMember(moderatedSiteModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove a regular member of a private site and response is 204") + public void adminIsAbleToRemoveRegularUserSiteMembershipFromPrivateSite() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(userModel); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(userModel).deleteSiteMember(privateSiteModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove admin membership from public site and response is 422") + public void regularUserIsNotAbleToRemoveAdminSiteMembershipFromPublicSite() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(managerModel); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(userModel); + restClient.authenticateUser(userModel).withCoreAPI().usingUser(adminUserModel).deleteSiteMember(publicSiteModel); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() + .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove admin membership from moderated site and response is 422") + public void regularUserIsNotAbleToRemoveAdminSiteMembershipFromModeratedSite() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(managerModel); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(userModel); + restClient.authenticateUser(userModel).withCoreAPI().usingUser(adminUserModel).deleteSiteMember(moderatedSiteModel); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() + .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, moderatedSiteModel.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove admin membership from private site and response is 422") + public void regularUserIsNotAbleToRemoveAdminSiteMembershipFromPrivateSite() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(managerModel); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(userModel); + restClient.authenticateUser(userModel).withCoreAPI().usingUser(adminUserModel).deleteSiteMember(privateSiteModel); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() + .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, privateSiteModel.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove the membership of a manager from a public site and response is 204") + public void adminIsAbleToRemoveManagerSiteMembershipOfPublicSite() throws Exception + { + UserModel secondManager = dataUser.createRandomTestUser(); + secondManager.setUserRole(UserRole.SiteManager); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(secondManager); + restClient.withCoreAPI().usingSite(publicSiteModel).addPerson(managerModel); + restClient.withCoreAPI().usingUser(managerModel).deleteSiteMember(publicSiteModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove the membership of a manager from a moderated site and response is 204") + public void adminIsAbleToRemoveManagerSiteMembershipOfModeratedSite() throws Exception + { + UserModel secondManager = dataUser.createRandomTestUser(); + secondManager.setUserRole(UserRole.SiteManager); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(secondManager); + restClient.withCoreAPI().usingSite(moderatedSiteModel).addPerson(managerModel); + restClient.withCoreAPI().usingUser(managerModel).deleteSiteMember(moderatedSiteModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove the membership of a manager from a private site and response is 204") + public void adminIsAbleToRemoveManagerSiteMembershipOfPrivateSite() throws Exception + { + UserModel secondManager = dataUser.createRandomTestUser(); + secondManager.setUserRole(UserRole.SiteManager); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(secondManager); + restClient.withCoreAPI().usingSite(privateSiteModel).addPerson(managerModel); + restClient.withCoreAPI().usingUser(managerModel).deleteSiteMember(privateSiteModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify collaborator is not able to remove the membership of a manager from a public site and response is 204") + public void userIsNotAbleToRemoveManagerSiteMembershipOfPublicSite() throws Exception + { + UserModel secondManager = dataUser.createRandomTestUser(); + secondManager.setUserRole(UserRole.SiteManager); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(secondManager); + restClient.withCoreAPI().usingSite(publicSiteModel).addPerson(userModel); + restClient.withCoreAPI().usingSite(publicSiteModel).addPerson(managerModel); + restClient.authenticateUser(userModel).withCoreAPI().usingUser(managerModel).deleteSiteMember(publicSiteModel); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() + .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify collaborator is not able to remove the membership of a manager from a moderated site and response is 204") + public void userIsNotAbleToRemoveManagerSiteMembershipOfModeratedSite() throws Exception + { + UserModel secondManager = dataUser.createRandomTestUser(); + secondManager.setUserRole(UserRole.SiteManager); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(secondManager); + restClient.withCoreAPI().usingSite(publicSiteModel).addPerson(userModel); + restClient.withCoreAPI().usingSite(moderatedSiteModel).addPerson(managerModel); + restClient.authenticateUser(userModel).withCoreAPI().usingUser(managerModel).deleteSiteMember(moderatedSiteModel); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() + .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, moderatedSiteModel.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify collaborator is not able to remove the membership of a manager from a private site and response is 204") + public void userIsNotAbleToRemoveManagerSiteMembershipOfPrivateSite() throws Exception + { + UserModel secondManager = dataUser.createRandomTestUser(); + secondManager.setUserRole(UserRole.SiteManager); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(secondManager); + restClient.withCoreAPI().usingSite(privateSiteModel).addPerson(userModel); + restClient.withCoreAPI().usingSite(privateSiteModel).addPerson(managerModel); + restClient.authenticateUser(userModel).withCoreAPI().usingUser(managerModel).deleteSiteMember(privateSiteModel); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() + .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, privateSiteModel.getId())); + } +} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/rest/people/DeleteSiteMemberFullTests.java b/e2e-test/src/test/java/org/alfresco/rest/people/DeleteSiteMemberFullTests.java new file mode 100644 index 000000000..85315e3a4 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/people/DeleteSiteMemberFullTests.java @@ -0,0 +1,207 @@ +package org.alfresco.rest.people; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +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.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class DeleteSiteMemberFullTests extends RestTest +{ + private SiteModel publicSiteModel; + private SiteModel moderatedSiteModel; + private SiteModel privateSiteModel; + private UserModel adminUserModel; + private ListUserWithRoles usersWithRolesPublicSite; + private ListUserWithRoles usersWithRolesModeratedSite; + private ListUserWithRoles usersWithRolesPrivateSite; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + adminUserModel.setUserRole(UserRole.SiteManager); + publicSiteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + moderatedSiteModel = dataSite.usingUser(adminUserModel).createModeratedRandomSite(); + privateSiteModel = dataSite.usingUser(adminUserModel).createPrivateRandomSite(); + + usersWithRolesPublicSite = dataUser.addUsersWithRolesToSite(publicSiteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + usersWithRolesModeratedSite = dataUser.addUsersWithRolesToSite(moderatedSiteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + usersWithRolesPrivateSite = dataUser.addUsersWithRolesToSite(privateSiteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove collaborator member of a public site") + public void adminIsAbleToRemoveCollaboratorSiteMembershipFromPublicSite() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteCollaborator)).deleteSiteMember(publicSiteModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteCollaborator)); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove contributor member of a public site") + public void adminIsAbleToRemoveContributorSiteMembershipFromPublicSite() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteContributor)).deleteSiteMember(publicSiteModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteContributor)); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove contributor member of a public site and response is 422") + public void userIsNotAbleToRemoveContributorSiteMembershipFromPublicSite() throws Exception + { + restClient.authenticateUser(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingUser(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteContributor)).deleteSiteMember(publicSiteModel); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() + .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove consumer member of a public site and response is 422") + public void userIsNotAbleToRemoveConsumerSiteMembershipFromPublicSite() throws Exception + { + restClient.authenticateUser(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingUser(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteConsumer)).deleteSiteMember(publicSiteModel); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() + .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove collaborator member of a moderated site") + public void adminIsAbleToRemoveCollaboratorSiteMembershipFromModeratedSite() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(usersWithRolesModeratedSite.getOneUserWithRole(UserRole.SiteCollaborator)).deleteSiteMember(moderatedSiteModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(usersWithRolesModeratedSite.getOneUserWithRole(UserRole.SiteCollaborator)); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove contributor member of a moderated site") + public void adminIsAbleToRemoveContributorSiteMembershipFromModeratedSite() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(usersWithRolesModeratedSite.getOneUserWithRole(UserRole.SiteContributor)).deleteSiteMember(moderatedSiteModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(usersWithRolesModeratedSite.getOneUserWithRole(UserRole.SiteContributor)); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove contributor member of a moderated site and response is 422") + public void userIsNotAbleToRemoveContributorSiteMembershipFromModeratedSite() throws Exception + { + restClient.authenticateUser(usersWithRolesModeratedSite.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingUser(usersWithRolesModeratedSite.getOneUserWithRole(UserRole.SiteContributor)).deleteSiteMember(moderatedSiteModel); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() + .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, moderatedSiteModel.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove consumer member of a moderated site and response is 422") + public void userIsNotAbleToRemoveConsumerSiteMembershipFromModeratedSite() throws Exception + { + restClient.authenticateUser(usersWithRolesModeratedSite.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingUser(usersWithRolesModeratedSite.getOneUserWithRole(UserRole.SiteConsumer)).deleteSiteMember(moderatedSiteModel); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() + .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, moderatedSiteModel.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove collaborator member of a private site") + public void adminIsAbleToRemoveCollaboratorSiteMembershipFromPrivateSite() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(usersWithRolesPrivateSite.getOneUserWithRole(UserRole.SiteCollaborator)).deleteSiteMember(privateSiteModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(usersWithRolesPrivateSite.getOneUserWithRole(UserRole.SiteCollaborator)); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove contributor member of a private site") + public void adminIsAbleToRemoveContributorSiteMembershipFromPrivateSite() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(usersWithRolesPrivateSite.getOneUserWithRole(UserRole.SiteContributor)).deleteSiteMember(privateSiteModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(usersWithRolesPrivateSite.getOneUserWithRole(UserRole.SiteContributor)); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove contributor member of a private site and response is 422") + public void userIsNotAbleToRemoveContributorSiteMembershipFromPrivateSite() throws Exception + { + restClient.authenticateUser(usersWithRolesPrivateSite.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingUser(usersWithRolesPrivateSite.getOneUserWithRole(UserRole.SiteContributor)).deleteSiteMember(privateSiteModel); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() + .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, privateSiteModel.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove consumer member of a private site and response is 422") + public void userIsNotAbleToRemoveConsumerSiteMembershipFromPrivateSite() throws Exception + { + restClient.authenticateUser(usersWithRolesPrivateSite.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingUser(usersWithRolesPrivateSite.getOneUserWithRole(UserRole.SiteConsumer)).deleteSiteMember(privateSiteModel); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() + .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, privateSiteModel.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is not able to remove same user twice and response is 400") + @Bug(id="ACE-5447") + public void adminIsNotAbleToRemoveSameUserTwice() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteCollaborator)).deleteSiteMember(publicSiteModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteCollaborator)).deleteSiteMember(publicSiteModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(RestErrorModel.ENTITY_NOT_FOUND); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteCollaborator)); + restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMembers().assertThat().entriesListContains("id", usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteCollaborator).getUsername()) + .when().getSiteMember(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteCollaborator).getUsername()) + .assertSiteMemberHasRole(UserRole.SiteCollaborator); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify single manager is not able to delete himself and response is 400") + public void lastManagerIsNotAbleToDeleteHimself() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteManager)).deleteSiteMember(publicSiteModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withCoreAPI().usingUser(adminUserModel).deleteSiteMember(publicSiteModel); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.DELETE_LAST_MANAGER, publicSiteModel.getTitle())) + .containsErrorKey(String.format(RestErrorModel.DELETE_LAST_MANAGER, publicSiteModel.getTitle())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER).stackTraceIs(RestErrorModel.STACKTRACE); + + restClient.withCoreAPI().usingSite(publicSiteModel).addPerson(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteManager)); + restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMembers() + .assertThat().entriesListContains("id", usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteManager).getUsername()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site creator can be deleted") + public void siteCreatorCanBeDeleted() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).deleteSiteMember(publicSiteModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.authenticateUser(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingSite(publicSiteModel).addPerson(adminUserModel); + restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMembers().assertThat().entriesListContains("id", adminUserModel.getUsername()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is not able to remove from site a user that created a member request that was not accepted yet") + @Bug(id="ACE-5447") + public void adminIsNotAbleToRemoveFromSiteANonExistingMember() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSiteModel); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(newMember).deleteSiteMember(moderatedSiteModel); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(RestErrorModel.ENTITY_NOT_FOUND); + } + +} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java b/e2e-test/src/test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java new file mode 100644 index 000000000..589c4b6ef --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java @@ -0,0 +1,111 @@ +package org.alfresco.rest.people; + +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; + +public class DeleteSiteMemberSanityTests extends RestTest +{ + private SiteModel siteModel; + private UserModel adminUser; + private ListUserWithRoles usersWithRoles; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws DataPreparationException + { + adminUser = dataUser.getAdminUser(); + siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); + + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site manager is able to delete another member of the site") + public void siteManagerCanDeleteSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception + { + UserModel newUser = dataUser.createRandomTestUser("testUser"); + newUser.setUserRole(UserRole.SiteCollaborator); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingSite(siteModel).addPerson(newUser); + + restClient.withCoreAPI().usingUser(newUser).deleteSiteMember(siteModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify admin user is able to delete another member of the site") + public void adminIsAbleToDeleteSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception + { + UserModel newUser = dataUser.createRandomTestUser("testUser"); + newUser.setUserRole(UserRole.SiteCollaborator); + restClient.authenticateUser(adminUser).withCoreAPI().usingSite(siteModel).addPerson(newUser); + + restClient.withCoreAPI().usingUser(newUser).deleteSiteMember(siteModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site collaborator does not have permission to delete another member of the site") + public void siteCollaboratorIsNotAbleToDeleteSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception + { + UserModel newUser = dataUser.createRandomTestUser("testUser"); + newUser.setUserRole(UserRole.SiteCollaborator); + restClient.authenticateUser(adminUser).withCoreAPI().usingSite(siteModel).addPerson(newUser); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + + restClient.withCoreAPI().usingUser(newUser).deleteSiteMember(siteModel); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() + .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site contributor does not have permission to delete another member of the site") + public void siteContributorIsNotAbleToDeleteSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception + { + UserModel newUser = dataUser.createRandomTestUser("testUser"); + newUser.setUserRole(UserRole.SiteCollaborator); + restClient.authenticateUser(adminUser).withCoreAPI().usingSite(siteModel).addPerson(newUser); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + + restClient.withCoreAPI().usingUser(newUser).deleteSiteMember(siteModel); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() + .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site consumer does not have permission to delete another member of the site") + public void siteConsumerIsNotAbleToDeleteSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception + { + UserModel newUser = dataUser.createRandomTestUser("testUser"); + newUser.setUserRole(UserRole.SiteCollaborator); + restClient.authenticateUser(adminUser).withCoreAPI().usingSite(siteModel).addPerson(newUser); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + + restClient.withCoreAPI().usingUser(newUser).deleteSiteMember(siteModel); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() + .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify unauthenticated user is not able to delete another member of the site") + public void unauthenticatedUserIsNotAbleToDeleteSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception + { + restClient.authenticateUser(new UserModel("random user", "random password")); + + restClient.withCoreAPI().usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).deleteSiteMember(siteModel); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError().containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED);; + } +} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/rest/people/GetPeopleCoreTests.java b/e2e-test/src/test/java/org/alfresco/rest/people/GetPeopleCoreTests.java new file mode 100644 index 000000000..a209dc427 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/people/GetPeopleCoreTests.java @@ -0,0 +1,57 @@ +package org.alfresco.rest.people; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +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.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * + * @author Cristina Axinte + * + */ +public class GetPeopleCoreTests extends RestTest +{ + UserModel userModel; + SiteModel siteModel; + UserModel searchedUser; + UserModel adminUser, managerUser; + UserModel inexistentUser; + + @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); + inexistentUser = new UserModel("inexistentUser", "password"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify inexistent user cannot get a person with Rest API and response is 401") + public void inexistentUserIsUnauthorizedToGetPerson() throws Exception + { + restClient.authenticateUser(inexistentUser).withCoreAPI().usingUser(searchedUser).getPerson(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot get a person that doesn't exists with Rest API and response is 404") + public void userCannotGetInexistentPerson() throws Exception + { + restClient.authenticateUser(managerUser).withCoreAPI().usingUser(inexistentUser).getPerson(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + restClient.assertLastError().containsSummary(String.format(inexistentUser.getUsername(), RestErrorModel.ENTITY_NOT_FOUND)); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/people/GetPeopleFullTests.java b/e2e-test/src/test/java/org/alfresco/rest/people/GetPeopleFullTests.java new file mode 100644 index 000000000..a447bd1d5 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/people/GetPeopleFullTests.java @@ -0,0 +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"); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/people/GetPeopleSanityTests.java b/e2e-test/src/test/java/org/alfresco/rest/people/GetPeopleSanityTests.java new file mode 100644 index 000000000..2678895a5 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/people/GetPeopleSanityTests.java @@ -0,0 +1,110 @@ +package org.alfresco.rest.people; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestPersonModel; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class GetPeopleSanityTests extends RestTest +{ + UserModel userModel; + SiteModel siteModel; + UserModel searchedUser; + UserModel adminUser; + private RestPersonModel personModel; + private String domain = "@tas-automation.org"; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + searchedUser = dataUser.createRandomTestUser(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user gets a person with Rest API and response is successful") + public void managerUserChecksIfPersonIsPresent() throws Exception + { + UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); + + personModel = restClient.authenticateUser(managerUser).withCoreAPI().usingUser(searchedUser).getPerson(); + restClient.assertStatusCodeIs(HttpStatus.OK); + personModel.assertThat().field("id").is(searchedUser.getUsername()).assertThat().field("firstName").is(searchedUser.getUsername() + " FirstName").and() + .field("email").is(searchedUser.getUsername() + domain).and().field("emailNotificationsEnabled").is("true"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify collaborator user gets a person with Rest API and response is successful") + public void collaboratorUserChecksIfPersonIsPresent() throws Exception + { + UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(collaboratorUser, siteModel, UserRole.SiteCollaborator); + + personModel = restClient.authenticateUser(collaboratorUser).withCoreAPI().usingUser(searchedUser).getPerson(); + restClient.assertStatusCodeIs(HttpStatus.OK); + personModel.assertThat().field("id").is(searchedUser.getUsername()).assertThat().field("firstName").is(searchedUser.getUsername() + " FirstName").and() + .field("email").is(searchedUser.getUsername() + domain).and().field("emailNotificationsEnabled").is("true"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.COMMENTS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify contributor user gets a person with Rest API and response is successful") + public void contributorUserChecksIfPersonIsPresent() throws Exception + { + UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(contributorUser, siteModel, UserRole.SiteContributor); + + personModel = restClient.authenticateUser(contributorUser).withCoreAPI().usingUser(searchedUser).getPerson(); + restClient.assertStatusCodeIs(HttpStatus.OK); + personModel.assertThat().field("id").is(searchedUser.getUsername()).assertThat().field("firstName").is(searchedUser.getUsername() + " FirstName").and() + .field("email").is(searchedUser.getUsername() + domain).and().field("emailNotificationsEnabled").is("true"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify consumer user gets a person with Rest API and response is successful") + public void consumerUserChecksIfPersonIsPresent() throws Exception + { + UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel, UserRole.SiteConsumer); + + personModel = restClient.authenticateUser(consumerUser).withCoreAPI().usingUser(searchedUser).getPerson(); + restClient.assertStatusCodeIs(HttpStatus.OK); + personModel.assertThat().field("id").is(searchedUser.getUsername()).assertThat().field("firstName").is(searchedUser.getUsername() + " FirstName").and() + .field("email").is(searchedUser.getUsername() + domain).and().field("emailNotificationsEnabled").is("true"); + ; + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify admin user gets a person with Rest API and response is successful") + public void adminUserChecksIfPersonIsPresent() throws Exception + { + personModel = restClient.authenticateUser(adminUser).withCoreAPI().usingUser(searchedUser).getPerson(); + restClient.assertStatusCodeIs(HttpStatus.OK); + personModel.assertThat().field("id").is(searchedUser.getUsername()).assertThat().field("firstName").is(searchedUser.getUsername() + " FirstName").and() + .field("email").is(searchedUser.getUsername() + domain).and().field("emailNotificationsEnabled").is("true"); + ; + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user gets a non existing person with Rest API and person is not found") + public void managerUserChecksIfNonExistingPersonIsPresent() throws Exception + { + UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); + UserModel searchedNonUser = new UserModel("nonexistinguser", DataUser.PASSWORD); + + restClient.authenticateUser(managerUser).withCoreAPI().usingUser(searchedNonUser).getPerson(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); + } +} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/rest/people/GetSiteMembershipCoreTests.java b/e2e-test/src/test/java/org/alfresco/rest/people/GetSiteMembershipCoreTests.java new file mode 100644 index 000000000..a1ed9384e --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/people/GetSiteMembershipCoreTests.java @@ -0,0 +1,114 @@ +package org.alfresco.rest.people; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestSiteEntry; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser; +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; + +/** + * Created by Claudia Agache on 11/28/2016. + */ + +public class GetSiteMembershipCoreTests extends RestTest +{ + UserModel regularUser, publicSiteManager, privateSiteManager, moderatedSiteManager, adminUser; + SiteModel publicSite, privateSite, moderatedSite; + private DataUser.ListUserWithRoles publicSiteUsers; + private RestSiteEntry restSiteEntry; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + regularUser = dataUser.createRandomTestUser(); + privateSiteManager = dataUser.createRandomTestUser(); + moderatedSiteManager = dataUser.createRandomTestUser(); + publicSite = dataSite.usingAdmin().createPublicRandomSite(); + privateSite = dataSite.usingAdmin().createPrivateRandomSite(); + moderatedSite = dataSite.usingAdmin().createModeratedRandomSite(); + + publicSiteUsers = dataUser.addUsersWithRolesToSite(publicSite, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + publicSiteManager = publicSiteUsers.getOneUserWithRole(UserRole.SiteManager); + dataUser.usingAdmin().addUserToSite(privateSiteManager, privateSite, UserRole.SiteManager); + dataUser.usingAdmin().addUserToSite(moderatedSiteManager, moderatedSite, UserRole.SiteManager); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) +// @Bug(id = "REPO-1642", description = "reproduced on 5.2.1 only, it works on 5.2.0") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify get site membership for a site returns status 404 when personId does not exist.") + public void getSiteMembershipUsingNonExistentPersonId() throws Exception + { + UserModel someUser = new UserModel("someUser", DataUser.PASSWORD); + + restClient.authenticateUser(regularUser).withCoreAPI().usingUser(someUser).getSiteMembership(publicSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "someUser")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify get site membership for a site returns status 404 when siteId does not exist.") + public void getSiteMembershipUsingNonExistentSiteId() throws Exception + { + SiteModel someSite = new SiteModel("someSite"); + + restClient.authenticateUser(regularUser).withCoreAPI().usingAuthUser().getSiteMembership(someSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, regularUser.getUsername(), "someSite")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify get site membership for a site returns status 404 when personId is not a site member.") + public void getSiteMembershipForPersonThatIsNotSiteMember() throws Exception + { + restClient.authenticateUser(publicSiteManager).withCoreAPI().usingUser(regularUser).getSiteMembership(publicSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, regularUser.getUsername(), publicSite.getTitle())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify regular user is not able to retrieve site membership information of a private site member.") + public void regularUserIsNotAbleToRetrieveSiteMembershipForPrivateSiteManager() throws Exception + { + restClient.authenticateUser(regularUser).withCoreAPI().usingUser(privateSiteManager).getSiteMembership(privateSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, privateSiteManager.getUsername(), privateSite.getTitle())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify regular user is able to retrieve site membership information of a moderated site member.") + public void regularUserGetsSiteMembershipForModeratedSiteMember() throws Exception + { + restSiteEntry = restClient.authenticateUser(regularUser).withCoreAPI().usingUser(moderatedSiteManager).getSiteMembership(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteEntry.assertThat().field("role").is(UserRole.SiteManager).and().field("id").is(moderatedSite.getId()).and().field("site").isNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify if Admin user is able to retrieve site membership information of him.") + public void adminGetsSiteMembershipForHim() throws Exception + { + restSiteEntry = restClient.authenticateUser(adminUser).withCoreAPI().usingUser(adminUser).getSiteMembership(privateSite); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteEntry.assertThat().field("role").is(UserRole.SiteManager).and().field("id").is(privateSite.getId()).and().field("site").isNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify if Admin user is able to retrieve site membership information of him.") + public void getSiteMembershipAfterRemovingASiteMember() throws Exception + { + UserModel publicSiteConsumer = publicSiteUsers.getOneUserWithRole(UserRole.SiteConsumer); + restClient.authenticateUser(publicSiteManager).withCoreAPI().usingSite(publicSite).deleteSiteMember(publicSiteConsumer); + restClient.authenticateUser(publicSiteManager).withCoreAPI().usingUser(publicSiteConsumer).getSiteMembership(publicSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, publicSiteConsumer.getUsername(), publicSite.getTitle())); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/people/GetSiteMembershipFullTests.java b/e2e-test/src/test/java/org/alfresco/rest/people/GetSiteMembershipFullTests.java new file mode 100644 index 000000000..7ad0ae6f9 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/people/GetSiteMembershipFullTests.java @@ -0,0 +1,138 @@ +package org.alfresco.rest.people; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestSiteEntry; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class GetSiteMembershipFullTests extends RestTest +{ + UserModel regularUser, adminUser; + SiteModel publicSite, moderatedSite; + private DataUser.ListUserWithRoles publicSiteUsers; + private RestSiteEntry restSiteEntry; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + regularUser = dataUser.createRandomTestUser(); + publicSite = dataSite.usingAdmin().createPublicRandomSite(); + moderatedSite = dataSite.usingAdmin().createModeratedRandomSite(); + + publicSiteUsers = dataUser.addUsersWithRolesToSite(publicSite, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify that properties parameter is applied.") + public void checkThatPropertiesParameterIsApplied() throws Exception + { + restSiteEntry = restClient.authenticateUser(regularUser).withCoreAPI().usingParams("properties=site,role,id") + .usingUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteManager)).getSiteMembership(publicSite); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteEntry.assertThat().field("role").is(UserRole.SiteManager) + .and().field("id").is(publicSite.getId()) + .and().field("site").isNotEmpty() + .and().field("guid").isNull(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify that regular user " + + "is able to retrieve site membership information of admin.") + public void regularUserGetsSiteMembershipForAdmin() throws Exception + { + restSiteEntry = restClient.authenticateUser(regularUser).withCoreAPI().usingUser(adminUser).getSiteMembership(publicSite); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteEntry.assertThat().field("role").is(UserRole.SiteManager) + .and().field("id").is(publicSite.getId()) + .and().field("site.id").is(publicSite.getId()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify that regular user " + + "is able to retrieve site membership details for a Collaborator role.") + public void getSiteMembershipDetailsForACollaboratorRole() throws Exception + { + restSiteEntry = restClient.authenticateUser(regularUser).withCoreAPI() + .usingUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)).getSiteMembership(publicSite); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteEntry.assertThat().field("role").is(UserRole.SiteCollaborator) + .and().field("guid").is(publicSite.getGuid()) + .and().field("id").is(publicSite.getId()) + .and().field("site.visibility").is(publicSite.getVisibility().toString()) + .and().field("site.guid").is(publicSite.getGuid()) + .and().field("site.description").is(publicSite.getDescription()) + .and().field("site.id").is(publicSite.getId()) + .and().field("site.preset").is("site-dashboard") + .and().field("site.title").is(publicSite.getTitle()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify that regular user " + + "is able to retrieve site membership details for a Contributor role.") + public void getSiteMembershipDetailsForAContributorRole() throws Exception + { + restSiteEntry = restClient.authenticateUser(regularUser).withCoreAPI() + .usingUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteContributor)).getSiteMembership(publicSite); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteEntry.assertThat().field("role").is(UserRole.SiteContributor) + .and().field("id").is(publicSite.getId()) + .and().field("site").isNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify that regular user " + + "is able to retrieve site membership details for a Consumer role.") + public void getSiteMembershipDetailsForAConsumerRole() throws Exception + { + restSiteEntry = restClient.authenticateUser(regularUser).withCoreAPI() + .usingUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteConsumer)).getSiteMembership(publicSite); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteEntry.assertThat().field("role").is(UserRole.SiteConsumer) + .and().field("id").is(publicSite.getId()) + .and().field("site").isNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "As regular user make a request to join a moderated site." + + " The request is pending. Check membership details.") + public void pendingRequestToASiteCheckMembershipDetails() throws Exception + { + restClient.authenticateUser(regularUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restSiteEntry = restClient.authenticateUser(adminUser).withCoreAPI() + .usingUser(regularUser).getSiteMembership(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, regularUser.getUsername(), moderatedSite.getTitle())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "As Collaborator user leave site and perform get call." + + "Check default error model schema.") + public void leaveSiteAndPerformGetCallCheckDefaultErrorModelSchema() throws Exception + { + UserModel leaveSiteUser = dataUser.createRandomTestUser(); + dataUser.addUserToSite(leaveSiteUser, publicSite, UserRole.SiteCollaborator); + restClient.authenticateUser(leaveSiteUser).withCoreAPI().usingAuthUser().deleteSiteMember(publicSite); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restSiteEntry = restClient.authenticateUser(adminUser).withCoreAPI() + .usingUser(leaveSiteUser).getSiteMembership(publicSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, leaveSiteUser.getUsername(), publicSite.getTitle())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java b/e2e-test/src/test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java new file mode 100644 index 000000000..5e348663b --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java @@ -0,0 +1,90 @@ +package org.alfresco.rest.people; + +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; + +public class GetSiteMembershipSanityTests extends RestTest +{ + private SiteModel siteModel; + private UserModel adminUser; + private ListUserWithRoles usersWithRoles; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws DataPreparationException + { + adminUser = dataUser.getAdminUser(); + siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); + + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site manager is able to retrieve site membership information of another user") + public void siteManagerCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingUser(adminUser).getSiteMembership(siteModel) + .assertThat().field("role").is(UserRole.SiteManager).and().field("id").is(siteModel.getId()).and().field("site").isNotEmpty(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site collaborator is able to retrieve site membership information of another user") + public void siteCollaboratorCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingUser(adminUser) + .getSiteMembership(siteModel).onSite().assertThat().field("role").is(UserRole.SiteCollaborator).and().field("id").is(siteModel.getId()); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site contributor is able to retrieve site membership information of another user") + public void siteContributorCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingUser(adminUser) + .getSiteMembership(siteModel).assertThat().field("role").is(UserRole.SiteManager).and().field("id").is(siteModel.getId()).and().field("site") + .isNotEmpty(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site consumer is able to retrieve site membership information of another user") + public void siteConsumerCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingUser(adminUser).getSiteMembership(siteModel) + .assertThat().field("role").is(UserRole.SiteManager).and().field("id").is(siteModel.getId()).and().field("site").isNotEmpty(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify admin user is able to retrieve site membership information of another user") + public void adminCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUser).withCoreAPI().usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).getSiteMembership(siteModel) + .assertThat().field("role").is(UserRole.SiteManager).and().field("id").is(siteModel.getId()).and().field("site").isNotEmpty(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to retrieve site membership information of another user") +// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") + public void unauthenticatedUserCannotRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(new UserModel("random user", "random password")).withCoreAPI() + .usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).getSiteMembership(siteModel); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } +} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/rest/people/GetSitesMembershipInformationCoreTests.java b/e2e-test/src/test/java/org/alfresco/rest/people/GetSitesMembershipInformationCoreTests.java new file mode 100644 index 000000000..16a91b969 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/people/GetSitesMembershipInformationCoreTests.java @@ -0,0 +1,136 @@ +package org.alfresco.rest.people; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.utility.constants.UserRole; +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; + +public class GetSitesMembershipInformationCoreTests extends RestTest +{ + private SiteModel publicSiteModel; + private SiteModel moderatedSiteModel; + private SiteModel privateSiteModel; + private UserModel userModel; + UserModel leaveSiteUserModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws DataPreparationException + { + userModel = dataUser.createRandomTestUser(); + leaveSiteUserModel = dataUser.createRandomTestUser(); + publicSiteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + moderatedSiteModel = dataSite.usingUser(userModel).createModeratedRandomSite(); + privateSiteModel = dataSite.usingUser(userModel).createPrivateRandomSite(); + dataUser.addUserToSite(leaveSiteUserModel, publicSiteModel, UserRole.SiteCollaborator); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site manager is not able to retrieve site membership information for a personId that does not exist") + public void siteManagerCantRetrieveSiteMembershipInformationForAPersonIdThatDoesNotExist() throws Exception + { + restClient.authenticateUser(userModel).withCoreAPI().usingUser(new UserModel("invalidPersonId", "password")).getSitesMembershipInformation() + .assertThat().entriesListIsEmpty(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + restClient.assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidPersonId")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify if get site membership information request returns status code 400 when invalid maxItems parameter is used") + public void getSiteMembershipInformationRequestReturns400ForInvalidMaxItemsParameter() throws Exception + { + restClient.authenticateUser(userModel).withParams("maxItems=0").withCoreAPI().usingAuthUser().getSitesMembershipInformation().assertThat() + .entriesListIsEmpty(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + restClient.assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); + + restClient.withParams("maxItems=-1").withCoreAPI().usingAuthUser().getSitesMembershipInformation().assertThat().entriesListIsEmpty(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + restClient.assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); + + restClient.withParams("maxItems=test").withCoreAPI().usingAuthUser().getSitesMembershipInformation().assertThat().entriesListIsEmpty(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + restClient.assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "test")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify if get site membership information request returns status code 200 for valid maxItems parameter") + public void getSiteMembershipInformationRequestReturns200ForValidMaxItemsParameter() throws Exception + { + restClient.authenticateUser(userModel).withParams("maxItems=5").withCoreAPI().usingAuthUser().getSitesMembershipInformation().assertThat() + .entriesListIsNotEmpty().getPagination().assertThat().field("maxItems").is("5"); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify if get site membership information request returns status code 400 when invalid skipCount parameter is used") + public void getSiteMembershipInformationRequestReturns400ForInvalidSkipCountParameter() throws Exception + { + restClient.authenticateUser(userModel).withParams("skipCount=-1").withCoreAPI().usingAuthUser().getSitesMembershipInformation().assertThat() + .entriesListIsEmpty(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + restClient.assertLastError().containsSummary(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT); + + restClient.withParams("skipCount=test").withCoreAPI().usingAuthUser().getSitesMembershipInformation().assertThat().entriesListIsEmpty(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + restClient.assertLastError().containsErrorKey(String.format(RestErrorModel.INVALID_SKIPCOUNT, "test")) + .containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "test")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify if get site membership information request returns status code 200 for valid skipCount parameter") + public void getSiteMembershipInformationRequestReturns200ForValidSkipCountParameter() throws Exception + { + restClient.authenticateUser(userModel).withParams("skipCount=1").withCoreAPI().usingAuthUser().getSitesMembershipInformation().assertThat() + .entriesListIsNotEmpty().getPagination().assertThat().field("skipCount").is("1"); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site manager is able to retrieve public sites") + public void siteManagerCheckThatPublicSitesAreRetrieved() throws Exception + { + restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().getSitesMembershipInformation().assertThat() + .entriesListContains("id", publicSiteModel.getId()); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site manager is able to retrieve moderated sites") + public void siteManagerCheckThatModeratedSitesAreRetrieved() throws Exception + { + restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().getSitesMembershipInformation().assertThat() + .entriesListContains("id", moderatedSiteModel.getId()); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site manager is able to retrieve private sites") + public void siteManagerCheckThatPrivateSitesAreRetrieved() throws Exception + { + restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().getSitesMembershipInformation().assertThat() + .entriesListContains("id", privateSiteModel.getId()); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site member is able to leave site") + public void siteMemberIsAbleToLeaveSite() throws Exception + { + restClient.authenticateUser(leaveSiteUserModel).withCoreAPI().usingAuthUser().deleteSiteMember(publicSiteModel); + restClient.authenticateUser(leaveSiteUserModel).withCoreAPI().usingAuthUser().getSitesMembershipInformation().assertThat().entriesListIsEmpty(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/people/GetSitesMembershipInformationFullTests.java b/e2e-test/src/test/java/org/alfresco/rest/people/GetSitesMembershipInformationFullTests.java new file mode 100644 index 000000000..856f8bf28 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/people/GetSitesMembershipInformationFullTests.java @@ -0,0 +1,205 @@ +package org.alfresco.rest.people; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestSiteMembershipModelsCollection; +import org.alfresco.rest.model.RestTaskModel; +import org.alfresco.utility.constants.UserRole; +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 Cristina Axinte + * + */ +public class GetSitesMembershipInformationFullTests extends RestTest +{ + private SiteModel publicSiteModel; + private SiteModel moderatedSiteModel; + private SiteModel privateSiteModel; + private SiteModel anotherUserSite; + private UserModel userModel, adminUser, anotherUserModel; + private RestSiteMembershipModelsCollection sitesMembershipInformation; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws DataPreparationException + { + adminUser = dataUser.getAdminUser(); + anotherUserSite = dataSite.usingUser(adminUser).createPublicRandomSite(); + userModel = dataUser.createRandomTestUser(); + anotherUserModel = dataUser.createRandomTestUser(); + publicSiteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); + dataUser.addUserToSite(userModel, publicSiteModel, UserRole.SiteCollaborator); + moderatedSiteModel = dataSite.usingUser(adminUser).createModeratedRandomSite(); + dataUser.addUserToSite(userModel, moderatedSiteModel, UserRole.SiteConsumer); + privateSiteModel = dataSite.usingUser(userModel).createPrivateRandomSite(); + dataUser.addUserToSite(anotherUserModel, anotherUserSite, UserRole.SiteCollaborator); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify if get site membership information request returns status code 200 for valid properties parameter") + public void getSiteMembershipInformationUsingPropertiesParameter() throws Exception + { + sitesMembershipInformation = restClient.authenticateUser(userModel).withParams("properties=id").withCoreAPI().usingAuthUser().getSitesMembershipInformation(); + restClient.assertStatusCodeIs(HttpStatus.OK); + sitesMembershipInformation.assertThat().entriesListIsNotEmpty().getPagination().assertThat().field("count").is("3"); + sitesMembershipInformation.assertThat().entriesListContains("id", publicSiteModel.getId()) + .and().entriesListContains("id", moderatedSiteModel.getId()) + .and().entriesListContains("id", privateSiteModel.getId()) + .and().entriesListDoesNotContain("site") + .and().entriesListDoesNotContain("role") + .and().entriesListDoesNotContain("guid"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify if get site membership information request returns status code 200 for order ASC by parameter") + public void getSiteMembershipInformationUsingOrderAscByParameter() throws Exception + { + sitesMembershipInformation = restClient.authenticateUser(userModel).withParams("orderBy=id ASC").withCoreAPI().usingAuthUser().getSitesMembershipInformation(); + restClient.assertStatusCodeIs(HttpStatus.OK); + sitesMembershipInformation.assertThat().entriesListIsNotEmpty().getPagination().assertThat().field("count").is("3"); + sitesMembershipInformation.assertThat().entriesListIsSortedAscBy("id"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify if get site membership information request returns status code 200 for order DESC by parameter") + public void getSiteMembershipInformationUsingOrderDescByParameter() throws Exception + { + sitesMembershipInformation = restClient.authenticateUser(userModel).withParams("orderBy=id Desc").withCoreAPI().usingAuthUser().getSitesMembershipInformation(); + restClient.assertStatusCodeIs(HttpStatus.OK); + sitesMembershipInformation.assertThat().entriesListIsNotEmpty().getPagination().assertThat().field("count").is("3"); + sitesMembershipInformation.assertThat().entriesListIsSortedDescBy("id"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify if get site membership information request returns status code 200 for order by role parameter") + public void getSiteMembershipInformationUsingOrderByRoleParameter() throws Exception + { + sitesMembershipInformation = restClient.authenticateUser(userModel).withParams("orderBy=role").withCoreAPI().usingAuthUser().getSitesMembershipInformation(); + restClient.assertStatusCodeIs(HttpStatus.OK); + sitesMembershipInformation.assertThat().entriesListIsNotEmpty().getPagination().assertThat().field("count").is("3"); + sitesMembershipInformation.assertThat().entriesListIsSortedAscBy("role"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify if user gets site membership information of another user successfully") + public void userCanGetSiteMembershipInformationOfAnotherUser() throws Exception + { + sitesMembershipInformation = restClient.authenticateUser(userModel).withCoreAPI().usingUser(anotherUserModel).getSitesMembershipInformation(); + restClient.assertStatusCodeIs(HttpStatus.OK); + sitesMembershipInformation.assertThat().entriesListIsNotEmpty().getPagination().assertThat().field("count").is("1"); + sitesMembershipInformation.getEntries().get(0).onModel() + .assertThat().field("site.visibility").is(anotherUserSite.getVisibility().toString()) + .and().field("site.guid").is(anotherUserSite.getGuid()) + .and().field("site.description").is(anotherUserSite.getDescription()) + .and().field("site.id").is(anotherUserSite.getId()) + .and().field("site.preset").is("site-dashboard") + .and().field("site.title").is(anotherUserSite.getTitle()) + .and().field("id").is(anotherUserSite.getId()) + .and().field("guid").is(anotherUserSite.getGuid()) + .and().field("role").is(UserRole.SiteCollaborator.toString()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify if get site membership information request returns status code 200 for relations parameter") + public void getSiteMembershipInformationUsingRelationsParameter() throws Exception + { + sitesMembershipInformation = restClient.authenticateUser(userModel).withParams("relations=site-membership-requests").withCoreAPI().usingAuthUser().getSitesMembershipInformation(); + restClient.assertStatusCodeIs(HttpStatus.OK); + sitesMembershipInformation.assertThat().entriesListIsNotEmpty().getPagination().assertThat().field("count").is("3"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify get site membership information request when a site membership request is rejected") + public void getSiteMembershipInformationWhenASiteRequestIsRejected() throws Exception + { + UserModel userWithRequests = dataUser.createRandomTestUser(); + + restClient.authenticateUser(userWithRequests).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSiteModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + sitesMembershipInformation = restClient.authenticateUser(adminUser).withCoreAPI().usingUser(userWithRequests).getSitesMembershipInformation(); + restClient.assertStatusCodeIs(HttpStatus.OK); + sitesMembershipInformation.assertThat().entriesListIsEmpty() + .and().paginationField("count").is("0"); + + RestTaskModel taskModel = restClient.authenticateUser(userWithRequests).withWorkflowAPI().getTasks().getTaskModelByDescription(moderatedSiteModel); + workflow.approveSiteMembershipRequest(adminUser.getUsername(), adminUser.getPassword(), taskModel.getId(), false, "Rejected"); + + sitesMembershipInformation = restClient.authenticateUser(adminUser).withCoreAPI().usingUser(userWithRequests).getSitesMembershipInformation(); + restClient.assertStatusCodeIs(HttpStatus.OK); + sitesMembershipInformation.assertThat().entriesListIsEmpty() + .and().paginationField("count").is("0"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify get site membership information request when a site membership request is approved") + public void getSiteMembershipInformationWhenASiteRequestIsAppropved() throws Exception + { + UserModel userWithRequests = dataUser.createRandomTestUser(); + + restClient.authenticateUser(userWithRequests).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSiteModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + sitesMembershipInformation = restClient.authenticateUser(adminUser).withCoreAPI().usingUser(userWithRequests).getSitesMembershipInformation(); + restClient.assertStatusCodeIs(HttpStatus.OK); + sitesMembershipInformation.assertThat().entriesListIsEmpty() + .and().paginationField("count").is("0"); + + RestTaskModel taskModel = restClient.authenticateUser(userWithRequests).withWorkflowAPI().getTasks().getTaskModelByDescription(moderatedSiteModel); + workflow.approveSiteMembershipRequest(adminUser.getUsername(), adminUser.getPassword(), taskModel.getId(), true, "Approve"); + + sitesMembershipInformation = restClient.authenticateUser(adminUser).withCoreAPI().usingUser(userWithRequests).getSitesMembershipInformation(); + restClient.assertStatusCodeIs(HttpStatus.OK); + sitesMembershipInformation.assertThat().entriesListIsNotEmpty() + .and().entriesListContains("role", UserRole.SiteConsumer.toString()) + .and().entriesListContains("guid", moderatedSiteModel.getGuid()) + .and().entriesListContains("id", moderatedSiteModel.getId()) + .and().paginationField("count").is("1"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify if get site membership information request returns status code 200 for valid maxItems parameter") + public void getSiteMembershipInformationUsingMaxItemsParameter() throws Exception + { + sitesMembershipInformation = restClient.authenticateUser(userModel).withParams("maxItems=2").withCoreAPI().usingAuthUser().getSitesMembershipInformation(); + restClient.assertStatusCodeIs(HttpStatus.OK); + sitesMembershipInformation.assertThat().entriesListCountIs(2) + .getPagination().assertThat().field("count").is("2") + .and().field("hasMoreItems").is("true") + .and().field("totalItems").is("3") + .and().field("skipCount").is("0") + .and().field("maxItems").is("2"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify if get site membership information request returns status code 200 for valid skipCount parameter") + public void getSiteMembershipInformationUsingSkipCountParameter() throws Exception + { + sitesMembershipInformation = restClient.authenticateUser(userModel).withParams("skipCount=2").withCoreAPI().usingAuthUser().getSitesMembershipInformation(); + restClient.assertStatusCodeIs(HttpStatus.OK); + sitesMembershipInformation.assertThat().entriesListCountIs(1) + .getPagination().assertThat().field("count").is("1") + .and().field("hasMoreItems").is("false") + .and().field("totalItems").is("3") + .and().field("skipCount").is("2") + .and().field("maxItems").is("100"); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java b/e2e-test/src/test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java new file mode 100644 index 000000000..7280ec849 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java @@ -0,0 +1,89 @@ +package org.alfresco.rest.people; + +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; + +public class GetSitesMembershipInformationSanityTests extends RestTest +{ + private SiteModel siteModel; + private UserModel adminUser; + private ListUserWithRoles usersWithRoles; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws DataPreparationException + { + adminUser = dataUser.getAdminUser(); + siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site manager is able to retrieve sites membership information of another user") + public void siteManagerIsAbleToRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingUser(adminUser).getSitesMembershipInformation() + .assertThat().entriesListIsNotEmpty().and().paginationExist().and().paginationField("count").isNot("0"); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site collaborator is able to retrieve sites membership information of another user") + public void siteCollaboratorIsAbleToRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingUser(adminUser) + .getSitesMembershipInformation().assertThat().entriesListIsNotEmpty().and().paginationExist().and().paginationField("count").isNot("0"); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site contributor is able to retrieve sites membership information of another user") + public void siteContributorIsAbleToRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingUser(adminUser) + .getSitesMembershipInformation().assertThat().entriesListIsNotEmpty().and().paginationExist().and().paginationField("count").isNot("0"); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site consumer is able to retrieve sites membership information of another user") + public void siteConsumerIsAbleToRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingUser(adminUser) + .getSitesMembershipInformation().assertThat().entriesListIsNotEmpty().and().paginationExist().and().paginationField("count").isNot("0"); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify admin is able to retrieve sites membership information of another user") + public void siteAdminIsAbleToRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUser).withCoreAPI().usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).getSitesMembershipInformation() + .assertThat().entriesListIsNotEmpty().and().paginationExist().and().paginationField("count").isNot("0"); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify that unauthenticated user is not able to retrieve sites membership information") +// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") + public void unauthenticatedUserCannotRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception + { + UserModel inexistentUser = new UserModel("inexistent user", "wrong password"); + restClient.authenticateUser(inexistentUser).withCoreAPI().usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .getSitesMembershipInformation(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } +} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/rest/people/activities/GetPeopleActivitiesCoreTests.java b/e2e-test/src/test/java/org/alfresco/rest/people/activities/GetPeopleActivitiesCoreTests.java new file mode 100644 index 000000000..bdc7d7dd6 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/people/activities/GetPeopleActivitiesCoreTests.java @@ -0,0 +1,126 @@ +package org.alfresco.rest.people.activities; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestActivityModelsCollection; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * + * @author Cristina Axinte + * + */ +public class GetPeopleActivitiesCoreTests extends RestTest +{ + UserModel userModel, adminUser, managerUser; + SiteModel siteModel1, siteModel2; + FileModel fileInSite1, fileInSite2; + FolderModel folderInSite2; + private RestActivityModelsCollection restActivityModelsCollection; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userModel = dataUser.createRandomTestUser(); + siteModel1 = dataSite.usingUser(userModel).createPublicRandomSite(); + fileInSite1 = dataContent.usingUser(userModel).usingSite(siteModel1).createContent(DocumentType.TEXT_PLAIN); + + siteModel2 = dataSite.usingUser(userModel).createPublicRandomSite(); + folderInSite2 = dataContent.usingUser(userModel).usingSite(siteModel2).createFolder(); + fileInSite2 = dataContent.usingAdmin().usingSite(siteModel2).createContent(DocumentType.TEXT_PLAIN); + + managerUser = dataUser.createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel2, UserRole.SiteManager); + + // only once the activity list is checked with retry in order not to wait the entire list in each test + restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingMe().getPersonActivitiesUntilEntriesCountIs(4); + restClient.assertStatusCodeIs(HttpStatus.OK); + restActivityModelsCollection.assertThat().paginationField("count").is("4"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot get activities for inexistent user with Rest API and response is 404") + public void userCannotGetPeopleActivitiesForInexistentPersonId() throws Exception + { + UserModel inexistentUserName = new UserModel("inexistent", "password"); + + restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingUser(inexistentUserName).getPersonActivities(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, inexistentUserName.getUsername())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its activities for inexistent siteId with Rest API and response is 404") + public void userGetItsPeopleActivitiesForInexistentSite() throws Exception + { + restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingUser(userModel).usingParams(String.format("siteId=inexistent")).getPersonActivities(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "inexistent")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities with invald skipCount parameter with Rest API and response is 400") + public void userGetPeopleActivitiesUsingInvalidSkipCountParameter() throws Exception + { + restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingMe().usingParams("skipCount=-1").getPersonActivities(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsErrorKey(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT) + .containsSummary(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities with invalid maxItems parameter with Rest API and response is 400") + public void userGetPeopleActivitiesUsingInvalidMaxItemsParameter() throws Exception + { + restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingMe().usingParams("maxItems=0").getPersonActivities(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsErrorKey(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) + .containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities using invalid value for parameter 'who'with Rest API and response is 400") + public void userGetsPeopleActivitiesUsingInvalidValueForWhoParameter() throws Exception + { + restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingUser(userModel).usingParams("who=mee").getPersonActivities(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsErrorKey(RestErrorModel.INVALID_PARAMETER_WHO) + .containsSummary(RestErrorModel.INVALID_PARAMETER_WHO) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities successfully using parameter 'who' with 'others' value with Rest API") + public void userGetsPeopleActivitiesUsingOthersForWhoParameter() throws Exception + { + restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingUser(userModel).usingParams("who=others").getPersonActivities(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restActivityModelsCollection.assertThat().paginationField("count").is("2"); + restActivityModelsCollection.assertThat().entriesListDoesNotContain("postPersonId", userModel.getUsername().toLowerCase()) + .and().entriesListContains("postPersonId", adminUser.getUsername().toLowerCase()) + .and().entriesListContains("postPersonId", managerUser.getUsername().toLowerCase()); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/people/activities/GetPeopleActivitiesFullTests.java b/e2e-test/src/test/java/org/alfresco/rest/people/activities/GetPeopleActivitiesFullTests.java new file mode 100644 index 000000000..1abd5a4e7 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/people/activities/GetPeopleActivitiesFullTests.java @@ -0,0 +1,184 @@ +package org.alfresco.rest.people.activities; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestActivityModel; +import org.alfresco.rest.model.RestActivityModelsCollection; +import org.alfresco.rest.model.RestActivitySummaryModel; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +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 Cristina Axinte + * + */ +public class GetPeopleActivitiesFullTests extends RestTest +{ + UserModel userModel, adminUser, managerUser; + SiteModel siteModel1, siteModel2; + FileModel fileInSite1, fileInSite2; + FolderModel folderInSite2; + private RestActivityModelsCollection restActivityModelsCollection; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userModel = dataUser.createRandomTestUser(); + siteModel1 = dataSite.usingUser(userModel).createPublicRandomSite(); + fileInSite1 = dataContent.usingUser(userModel).usingSite(siteModel1).createContent(DocumentType.TEXT_PLAIN); + + siteModel2 = dataSite.usingUser(userModel).createPublicRandomSite(); + folderInSite2 = dataContent.usingUser(userModel).usingSite(siteModel2).createFolder(); + fileInSite2 = dataContent.usingAdmin().usingSite(siteModel2).createContent(DocumentType.TEXT_PLAIN); + + managerUser = dataUser.createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel2, UserRole.SiteManager); + + // only once the activity list is checked with retry in order not to wait the entire list in each test + restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingMe().getPersonActivitiesUntilEntriesCountIs(4); + restClient.assertStatusCodeIs(HttpStatus.OK); + restActivityModelsCollection.assertThat().paginationField("count").is("4"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify activity summary from user gets activities response with Rest API") + public void userGetPeopleActivitiesWithActivitySummaryCheck() throws Exception + { + restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingMe().usingParams(String.format("siteId=%s", siteModel1.getId())).getPersonActivities(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restActivityModelsCollection.assertThat().paginationField("count").is("1"); + RestActivitySummaryModel summary = restActivityModelsCollection.getEntries().get(0).onModel().getActivitySummary(); + summary.assertThat().field("firstName").is(userModel.getUsername() + " FirstName") + .and().field("lastName").is("LN-" + userModel.getUsername()) + .and().field("title").is(fileInSite1.getName()) + .and().field("objectId").is(fileInSite1.getNodeRefWithoutVersion()); + } + + @Bug(id = "REPO-1911") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE,TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot get activities for empty user with Rest API and response is 400") + public void userCannotGetPeopleActivitiesForEmptyPersonId() throws Exception + { + UserModel emptyUserName = new UserModel("", "password"); + + restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingUser(emptyUserName).getPersonActivities(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .containsSummary(RestErrorModel.LOCAL_NAME_CONSISTANCE) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE,TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its activities for siteId specified in siteId parameter using me with Rest API and response is successful") + public void userGetItsPeopleActivitiesForASpecificSite() throws Exception + { + restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingUser(userModel).usingParams(String.format("siteId=%s", siteModel1.getId())).getPersonActivities(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restActivityModelsCollection.assertThat().paginationField("count").is("1"); + restActivityModelsCollection.assertThat().entriesListContains("siteId", siteModel1.getId()) + .and().entriesListDoesNotContain("siteId", siteModel2.getId()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities for user with no activities with Rest API and response is successful") + public void userGetPeopleActivitiesForUserWithNoActivities() throws Exception + { + UserModel userNoActivities = dataUser.createRandomTestUser(); + dataSite.usingUser(userNoActivities).createPublicRandomSite(); + + restActivityModelsCollection = restClient.authenticateUser(adminUser).withCoreAPI().usingUser(userNoActivities).getPersonActivities(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restActivityModelsCollection.assertThat().paginationField("count").is("0"); + restActivityModelsCollection.assertThat().entriesListIsEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot get activities for siteId that user doesn't have access to with Rest API and response is not found") + public void userGetPeopleActivitiesForASiteWithNoAccess() throws Exception + { + SiteModel siteNoAccess = dataSite.usingUser(managerUser).createPrivateRandomSite(); + + restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingUser(userModel).usingParams(String.format("siteId=%s", siteNoAccess.getId())).getPersonActivities(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + restClient.assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, siteNoAccess.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot get activities for another user with Rest API and response is permission denied") + public void userGetPeopleActivitiesForAnotherUser() throws Exception + { + restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingUser(managerUser).getPersonActivities(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + restClient.assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities with properties parameter applied with Rest API and response is successful") + public void userGetPeopleActivitiesUsingPropertiesParameter() throws Exception + { + restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingMe().usingParams("properties=postPersonId").getPersonActivities(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restActivityModelsCollection.assertThat().paginationField("count").is("4"); + restActivityModelsCollection.assertThat().entriesListContains("postPersonId", userModel.getUsername().toLowerCase()) + .and().entriesListContains("postPersonId", adminUser.getUsername().toLowerCase()) + .and().entriesListContains("postPersonId", managerUser.getUsername().toLowerCase()) + .and().entriesListDoesNotContain("postedAt") + .and().entriesListDoesNotContain("feedPersonId") + .and().entriesListDoesNotContain("siteId") + .and().entriesListDoesNotContain("activitySummary") + .and().entriesListDoesNotContain("id") + .and().entriesListDoesNotContain("activityType"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities with skipCount parameter applied with Rest API and response is successful") + public void userGetPeopleActivitiesUsingSkipCountParameter() throws Exception + { + restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingMe().getPersonActivities(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restActivityModelsCollection.assertThat().paginationField("count").is("4"); + RestActivityModel expectedRestActivity3 = restActivityModelsCollection.getEntries().get(2).onModel(); + RestActivityModel expectedRestActivity4 = restActivityModelsCollection.getEntries().get(3).onModel(); + + restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingMe().usingParams("skipCount=2").getPersonActivities(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restActivityModelsCollection.assertThat().paginationField("count").is("2"); + restActivityModelsCollection.getEntries().get(0).onModel().assertThat().field("postPersonId").is(expectedRestActivity3.getPostPersonId()) + .and().field("activityType").is(expectedRestActivity3.getActivityType()); + restActivityModelsCollection.getEntries().get(1).onModel().assertThat().field("postPersonId").is(expectedRestActivity4.getPostPersonId()) + .and().field("activityType").is(expectedRestActivity4.getActivityType()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities with maxItems parameter applied with Rest API and response is successful") + public void userGetPeopleActivitiesUsingMaxItemsParameter() throws Exception + { + restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingMe().getPersonActivities(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restActivityModelsCollection.assertThat().paginationField("count").is("4"); + RestActivityModel expectedRestActivity1 = restActivityModelsCollection.getEntries().get(0).onModel(); + RestActivityModel expectedRestActivity2 = restActivityModelsCollection.getEntries().get(1).onModel(); + + restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingMe().usingParams("maxItems=2").getPersonActivities(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restActivityModelsCollection.assertThat().paginationField("count").is("2"); + restActivityModelsCollection.getEntries().get(0).onModel().assertThat().field("postPersonId").is(expectedRestActivity1.getPostPersonId()) + .and().field("activityType").is(expectedRestActivity1.getActivityType()); + restActivityModelsCollection.getEntries().get(1).onModel().assertThat().field("postPersonId").is(expectedRestActivity2.getPostPersonId()) + .and().field("activityType").is(expectedRestActivity2.getActivityType()); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/people/activities/GetPeopleActivitiesSanityTests.java b/e2e-test/src/test/java/org/alfresco/rest/people/activities/GetPeopleActivitiesSanityTests.java new file mode 100644 index 000000000..468f13bfa --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/people/activities/GetPeopleActivitiesSanityTests.java @@ -0,0 +1,111 @@ +package org.alfresco.rest.people.activities; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestActivityModelsCollection; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser; +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 Cristina Axinte + * Tests for getActivities (/people/{personId}/activities) RestAPI call + */ + +public class GetPeopleActivitiesSanityTests extends RestTest +{ + UserModel userModel, unauthenticatedUser; + SiteModel siteModel; + private DataUser.ListUserWithRoles usersWithRoles; + private RestActivityModelsCollection restActivityModelsCollection; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + unauthenticatedUser = dataUser.usingAdmin().createRandomTestUser(); + unauthenticatedUser.setPassword("newpassword"); + + // only once the activity list is checked with retry in order not to wait the entire list in each test + restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().getPersonActivitiesUntilEntriesCountIs(5); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.SANITY, description = "Verify manager user gets its activities with Rest API and response is successful") + public void managerUserShouldGetPeopleActivitiesList() throws Exception + { + UserModel managerUser = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); + dataContent.usingUser(managerUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + + restActivityModelsCollection = restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().getPersonActivities(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restActivityModelsCollection.assertThat().entriesListIsNotEmpty().and().entriesListContains("siteId", siteModel.getId()).and().paginationExist(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.SANITY, description = "Verify collaborator user gets its activities with Rest API and response is successful") + public void collaboratorUserShouldGetPeopleActivitiesList() throws Exception + { + UserModel collaboratorUser = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); + dataContent.usingUser(collaboratorUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + + restActivityModelsCollection = restClient.authenticateUser(collaboratorUser).withCoreAPI().usingAuthUser().getPersonActivities(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restActivityModelsCollection.assertThat().entriesListIsNotEmpty().and().entriesListContains("siteId", siteModel.getId()).and().paginationExist(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.ACTIVITIES }, executionType = ExecutionType.SANITY, description = "Verify contributor user gets its activities with Rest API and response is successful") + public void contributorUserShouldGetPeopleActivitiesList() throws Exception + { + UserModel contributorUser = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); + dataContent.usingUser(contributorUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + + restActivityModelsCollection = restClient.authenticateUser(contributorUser).withCoreAPI().usingAuthUser().getPersonActivities(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restActivityModelsCollection.assertThat().entriesListIsNotEmpty().and().entriesListContains("siteId", siteModel.getId()).and().paginationExist(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.ACTIVITIES }, executionType = ExecutionType.SANITY, description = "Verify consumer user gets its activities with Rest API and response is successful") + public void consumerUserShouldGetPeopleActivitiesList() throws Exception + { + UserModel consumerUser = usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer); + + restActivityModelsCollection = restClient.authenticateUser(consumerUser).withCoreAPI().usingAuthUser().getPersonActivities(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restActivityModelsCollection.assertThat().entriesListIsNotEmpty().and().entriesListContains("siteId", siteModel.getId()).and().paginationExist(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.ACTIVITIES }, executionType = ExecutionType.SANITY, description = "Verify admin user gets another user activities with Rest API and response is successful") + public void adminUserShouldGetPeopleActivitiesList() throws Exception + { + restActivityModelsCollection = restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingUser(userModel).getPersonActivities(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restActivityModelsCollection.assertThat().entriesListIsNotEmpty().and().entriesListContains("siteId", siteModel.getId()).and().paginationExist(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.ACTIVITIES }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is NOT Authorized to gets another user activities with Rest API") + public void unauthenticatedUserShouldNotGetPeopleActivitiesList() throws Exception + { + restClient.authenticateUser(unauthenticatedUser).withCoreAPI().usingUser(userModel).getPersonActivities(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError().containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/people/preferences/GetPeoplePreferenceCoreTests.java b/e2e-test/src/test/java/org/alfresco/rest/people/preferences/GetPeoplePreferenceCoreTests.java new file mode 100644 index 000000000..4e02b7025 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/people/preferences/GetPeoplePreferenceCoreTests.java @@ -0,0 +1,78 @@ +package org.alfresco.rest.people.preferences; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.utility.constants.PreferenceName; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class GetPeoplePreferenceCoreTests extends RestTest +{ + UserModel userModel; + SiteModel siteModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + dataSite.usingUser(userModel).usingSite(siteModel).addSiteToFavorites(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user is Forbidden to get a specific preference for another user with Rest API and response is 403") + public void userDoesNotHaveAccessToFavoriteSitesOfAnotherUser() throws Exception + { + UserModel secondUser = dataUser.createRandomTestUser(); + restClient.authenticateUser(secondUser).withCoreAPI().usingUser(userModel) + .getPersonPreferenceInformation(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + restClient.assertLastError().containsSummary("Permission was denied"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify manager fails to get a specific preference for an invalid user with Rest API and response is 404") + public void statusNotFoundIsReturnedForAPersonIDThatDoesNotExist() throws Exception + { + restClient.authenticateUser(userModel).withCoreAPI().usingUser(new UserModel("invalidPersonID", "password")) + .getPersonPreferenceInformation(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidPersonID")) + .statusCodeIs(HttpStatus.NOT_FOUND) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify manager fails to get a specific preference for an invalid preference with Rest API and response is 404") + public void statusNotFoundIsReturnedForAPreferenceNameThatDoesNotExist() throws Exception + { + restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().getPersonPreferenceInformation("invalidPreferenceName"); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + restClient.assertLastError().containsSummary( + String.format("The relationship resource was not found for the" + " entity with id: %s and a relationship id of invalidPreferenceName", + userModel.getUsername())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify manager fails to get a specific preference for removed preference with Rest API and response is 404") + public void statusNotFoundIsReturnedForAPreferenceNameThatHasBeenRemoved() throws Exception + { + SiteModel preferenceSite = dataSite.usingUser(userModel).createPublicRandomSite(); + dataSite.usingUser(userModel).usingSite(preferenceSite).addSiteToFavorites(); + dataSite.usingUser(userModel).usingSite(preferenceSite).removeSiteFromFavorites(); + restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser() + .getPersonPreferenceInformation(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), preferenceSite.getId())); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + restClient.assertLastError().containsSummary( + String.format("The relationship resource was not found for the" + " entity with id: %s and a relationship id of %s", userModel.getUsername(), + String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), preferenceSite.getId()))); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/people/preferences/GetPeoplePreferenceFullTests.java b/e2e-test/src/test/java/org/alfresco/rest/people/preferences/GetPeoplePreferenceFullTests.java new file mode 100644 index 000000000..5c874d427 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/people/preferences/GetPeoplePreferenceFullTests.java @@ -0,0 +1,194 @@ +package org.alfresco.rest.people.preferences; + +import java.nio.file.Paths; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestPreferenceModel; +import org.alfresco.utility.Utility; +import org.alfresco.utility.constants.PreferenceName; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FileType; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class GetPeoplePreferenceFullTests extends RestTest +{ + private UserModel userModel; + private SiteModel siteModel; + private RestPreferenceModel restPreferenceModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + dataSite.usingUser(userModel).usingSite(siteModel).addSiteToFavorites(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, + description = "Check that properties parameter is applied") + public void propertiesParameterIsAppliedWhenRetrievingPreference() throws Exception + { + restPreferenceModel = restClient.authenticateUser(userModel).withParams("properties=id").withCoreAPI().usingUser(userModel) + .getPersonPreferenceInformation(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())); + restClient.assertStatusCodeIs(HttpStatus.OK); + restPreferenceModel.assertThat().field("id").is(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())) + .and().field("value").isNull(); + + restPreferenceModel = restClient.authenticateUser(userModel).withParams("properties=id,value").withCoreAPI().usingUser(userModel) + .getPersonPreferenceInformation(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())); + restClient.assertStatusCodeIs(HttpStatus.OK); + restPreferenceModel.assertThat().field("id").is(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())) + .and().field("value").is("true"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, + description = "Validate ID element in get site preference response") + public void validateIdElementInGetSitePreferenceResponse() throws Exception + { + restPreferenceModel = restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser() + .getPersonPreferenceInformation(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())); + restPreferenceModel.assertThat().field("id").is(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())) + .and().field("value").is("true"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, + description = "Validate ID element in get folder preference response") + public void validateIdElementInGetFolderPreferenceResponse() throws Exception + { + FolderModel folderFavorite = new FolderModel("favoriteFolder"); + folderFavorite = dataContent.usingSite(siteModel).createFolder(folderFavorite); + dataContent.getContentActions().setFolderAsFavorite(userModel.getUsername(), userModel.getPassword(), siteModel.getId(), folderFavorite.getName()); + + restPreferenceModel = restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser() + .getPersonPreferenceInformation(PreferenceName.FOLDERS_FAVORITES_PREFIX.toString()); + restPreferenceModel.assertThat().field("id").is(PreferenceName.FOLDERS_FAVORITES_PREFIX) + .and().field("value").is(Utility.removeLastSlash(Utility.buildPath("workspace://SpacesStore", folderFavorite.getNodeRef()))); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, + description = "Validate ID element in get file preference response") + public void validateIdElementInGetFilePreferenceResponse() throws Exception + { + FileModel fileFavorite = new FileModel("favoriteFile", FileType.TEXT_PLAIN); + fileFavorite = dataContent.usingSite(siteModel).createContent(fileFavorite); + dataContent.getContentActions().setFileAsFavorite(userModel.getUsername(), userModel.getPassword(), siteModel.getId(), String.format("%s.%s", fileFavorite.getName(), fileFavorite.getFileType().extention)); + + restPreferenceModel = restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser() + .getPersonPreferenceInformation(PreferenceName.DOCUMENTS_FAVORITES_PREFIX.toString()); + restPreferenceModel.assertThat().field("id").is(PreferenceName.DOCUMENTS_FAVORITES_PREFIX) + .and().field("value").is(Utility.removeLastSlash(Utility.buildPath("workspace://SpacesStore", fileFavorite.getNodeRefWithoutVersion()))); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, + description = "Get preference of an user that has no preferences") + public void getPreferenceForUserWithoutPreferences() throws Exception + { + UserModel newUser = dataUser.createRandomTestUser(); + + restPreferenceModel = restClient.authenticateUser(newUser).withCoreAPI().usingAuthUser() + .getPersonPreferenceInformation(PreferenceName.DOCUMENTS_FAVORITES_PREFIX.toString()); + restClient.assertLastError().containsSummary( + String.format("The relationship resource was not found for the" + " entity with id: %s and a relationship id of %s", newUser.getUsername(), + PreferenceName.DOCUMENTS_FAVORITES_PREFIX.toString())); + + restPreferenceModel = restClient.authenticateUser(newUser).withCoreAPI().usingAuthUser() + .getPersonPreferenceInformation(PreferenceName.FOLDERS_FAVORITES_PREFIX.toString()); + restClient.assertLastError().containsSummary( + String.format("The relationship resource was not found for the" + " entity with id: %s and a relationship id of %s", newUser.getUsername(), + PreferenceName.FOLDERS_FAVORITES_PREFIX.toString())); + + restPreferenceModel = restClient.authenticateUser(newUser).withCoreAPI().usingAuthUser() + .getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX.toString()); + restClient.assertLastError().containsSummary( + String.format("The relationship resource was not found for the" + " entity with id: %s and a relationship id of %s", newUser.getUsername(), + PreferenceName.SITES_FAVORITES_PREFIX.toString())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, + description = "Change one preference for an user then perform get call") + @Bug(id = "REPO-1922") + public void changePreferenceThenPerformGetPreferenceCall() throws Exception + { + UserModel newUser = dataUser.createRandomTestUser(); + SiteModel site = dataSite.usingUser(newUser).createPublicRandomSite(); + + dataSite.usingUser(newUser).usingSite(site).addSiteToFavorites(); + + FileModel fileFavorite = new FileModel("favoriteFile", FileType.TEXT_PLAIN); + fileFavorite = dataContent.usingSite(site).createContent(fileFavorite); + dataContent.getContentActions().setFileAsFavorite(newUser.getUsername(), newUser.getPassword(), site.getId(), String.format("%s.%s", fileFavorite.getName(), fileFavorite.getFileType().extention)); + + FolderModel folderFavorite = new FolderModel("favoriteFolder"); + folderFavorite = dataContent.usingSite(site).createFolder(folderFavorite); + dataContent.getContentActions().setFolderAsFavorite(newUser.getUsername(), newUser.getPassword(), site.getId(), folderFavorite.getName()); + + dataSite.usingUser(newUser).usingSite(site).removeSiteFromFavorites(); + dataContent.getContentActions().removeFavorite(newUser.getUsername(), newUser.getPassword(), site.getId(), folderFavorite.getName()); + dataContent.getContentActions().removeFavorite(newUser.getUsername(), newUser.getPassword(), site.getId(), Paths.get(fileFavorite.getCmisLocation()).getFileName().toString()); + + restPreferenceModel = restClient.authenticateUser(newUser).withCoreAPI().usingAuthUser() + .getPersonPreferenceInformation(PreferenceName.FOLDERS_FAVORITES_PREFIX.toString()); + restClient.assertLastError().containsSummary( + String.format("The relationship resource was not found for the" + " entity with id: %s and a relationship id of %s", newUser.getUsername(), + PreferenceName.FOLDERS_FAVORITES_PREFIX.toString())); + + restPreferenceModel = restClient.authenticateUser(newUser).withCoreAPI().usingAuthUser() + .getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX.toString()); + restClient.assertLastError().containsSummary( + String.format("The relationship resource was not found for the" + " entity with id: %s and a relationship id of %s", newUser.getUsername(), + PreferenceName.SITES_FAVORITES_PREFIX.toString())); + + restPreferenceModel = restClient.authenticateUser(newUser).withCoreAPI().usingAuthUser() + .getPersonPreferenceInformation(PreferenceName.DOCUMENTS_FAVORITES_PREFIX.toString()); + restClient.assertLastError().containsSummary( + String.format("The relationship resource was not found for the" + " entity with id: %s and a relationship id of %s", newUser.getUsername(), + PreferenceName.DOCUMENTS_FAVORITES_PREFIX.toString())); + + restPreferenceModel = restClient.authenticateUser(newUser).withCoreAPI().usingAuthUser() + .getPersonPreferenceInformation(PreferenceName.FOLDERS_FAVORITES_PREFIX.toString()); + restClient.assertLastError().containsSummary( + String.format("The relationship resource was not found for the" + " entity with id: %s and a relationship id of %s", newUser.getUsername(), + PreferenceName.FOLDERS_FAVORITES_PREFIX.toString())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, + description = "Verify admin is able to get preference of another user") + public void adminIsAbleToGetOtherUserPreference() throws Exception + { + restPreferenceModel = restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingUser(userModel) + .getPersonPreferenceInformation(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())); + restClient.assertStatusCodeIs(HttpStatus.OK); + restPreferenceModel.assertThat().field("id").is(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())).and().field("value").is("true"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, + description = "Verify regular user is not able to get preference of admin user") + public void regularUserIsNotAbleToGetAdminPreference() throws Exception + { + SiteModel newSite = dataSite.usingUser(dataUser.getAdminUser()).createPublicRandomSite(); + dataSite.usingUser(dataUser.getAdminUser()).usingSite(newSite).addSiteToFavorites(); + + restClient.authenticateUser(userModel).withCoreAPI().usingUser(dataUser.getAdminUser()) + .getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + newSite.getId()); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + restClient.assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } +} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/rest/people/preferences/GetPeoplePreferenceSanityTests.java b/e2e-test/src/test/java/org/alfresco/rest/people/preferences/GetPeoplePreferenceSanityTests.java new file mode 100644 index 000000000..be9802d5f --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/people/preferences/GetPeoplePreferenceSanityTests.java @@ -0,0 +1,120 @@ +package org.alfresco.rest.people.preferences; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestPreferenceModel; +import org.alfresco.utility.constants.PreferenceName; +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.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Tests for Get a Peference (/people/{personId}/preferences/{preferenceName}) RestAPI call + * + * @author Cristina Axinte + */ + +public class GetPeoplePreferenceSanityTests extends RestTest +{ + UserModel userModel; + SiteModel siteModel; + private RestPreferenceModel restPreferenceModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify manager user gets a specific preference with Rest API and response is successful (200)") + public void managerUserGetsAPreferenceWithSuccess() throws Exception + { + UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); + dataSite.usingUser(managerUser).usingSite(siteModel).addSiteToFavorites(); + + restPreferenceModel = restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser() + .getPersonPreferenceInformation(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())); + restClient.assertStatusCodeIs(HttpStatus.OK); + restPreferenceModel.assertThat().field("id").is(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())).and().field("value").is("true"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify collaborator user gets a specific preference with Rest API and response is successful (200)") + public void collaboratorUserGetsAPreferenceWithSuccess() throws Exception + { + UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(collaboratorUser, siteModel, UserRole.SiteCollaborator); + dataSite.usingUser(collaboratorUser).usingSite(siteModel).addSiteToFavorites(); + + restPreferenceModel = restClient.authenticateUser(collaboratorUser).withCoreAPI().usingAuthUser() + .getPersonPreferenceInformation(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())); + restClient.assertStatusCodeIs(HttpStatus.OK); + restPreferenceModel.assertThat().field("id").is(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())).and().field("value").is("true"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify contributor user gets a specific preference with Rest API and response is successful (200)") + public void contributorUserGetsAPreferenceWithSuccess() throws Exception + { + UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(contributorUser, siteModel, UserRole.SiteContributor); + dataSite.usingUser(contributorUser).usingSite(siteModel).addSiteToFavorites(); + + restPreferenceModel = restClient.authenticateUser(contributorUser).withCoreAPI().usingAuthUser() + .getPersonPreferenceInformation(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())); + restClient.assertStatusCodeIs(HttpStatus.OK); + restPreferenceModel.assertThat().field("id").is(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())).and().field("value").is("true"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify consumer user gets a specific preference with Rest API and response is successful (200)") + public void consumerUserGetsAPreferenceWithSuccess() throws Exception + { + UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel, UserRole.SiteConsumer); + dataSite.usingUser(consumerUser).usingSite(siteModel).addSiteToFavorites(); + + restPreferenceModel = restClient.authenticateUser(consumerUser).withCoreAPI().usingAuthUser() + .getPersonPreferenceInformation(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(),siteModel.getId())); + restClient.assertStatusCodeIs(HttpStatus.OK); + restPreferenceModel.assertThat().field("id").is(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(),siteModel.getId())).and().field("value").is("true"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify admin user gets a specific preference with Rest API and response is successful (200)") + public void adminUserGetsAPreferenceWithSuccess() throws Exception + { + UserModel adminUser = dataUser.getAdminUser(); + dataSite.usingUser(adminUser).usingSite(siteModel).addSiteToFavorites(); + + restPreferenceModel = restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser() + .getPersonPreferenceInformation(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())); + restClient.assertStatusCodeIs(HttpStatus.OK); + restPreferenceModel.assertThat().field("id").is(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())).and().field("value").is("true"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized to get a specific preference with Rest API when authentication fails (401)") +// @Bug(id = "MNT-16904", description = "fails only on environment with tenants") + public void managerUserNotAuthorizedFailsToGetsAPreference() throws Exception + { + UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); + dataSite.usingUser(managerUser).usingSite(siteModel).addSiteToFavorites(); + managerUser.setPassword("newpassword"); + + restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser() + .getPersonPreferenceInformation(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/people/preferences/GetPeoplePreferencesCoreTests.java b/e2e-test/src/test/java/org/alfresco/rest/people/preferences/GetPeoplePreferencesCoreTests.java new file mode 100644 index 000000000..f4b42e8c7 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/people/preferences/GetPeoplePreferencesCoreTests.java @@ -0,0 +1,123 @@ +package org.alfresco.rest.people.preferences; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestPreferenceModelsCollection; +import org.alfresco.utility.constants.PreferenceName; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * + * @author Cristina Axinte + * + */ +public class GetPeoplePreferencesCoreTests extends RestTest +{ + UserModel userModel, user1, user2, adminUser; + SiteModel siteModel; + FolderModel folderModel; + private RestPreferenceModelsCollection restPreferenceModelsCollection; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + + user1 = dataUser.createRandomTestUser(); + dataSite.usingUser(user1).usingSite(siteModel).addSiteToFavorites(); + dataContent.usingUser(user1).usingSite(siteModel).addFolderToFavorites(folderModel); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its preferences with invalid maxItems parameter with Rest API and response is 400") + public void userGetsPeoplePreferencesUsingInvalidMaxItemsParameter() throws Exception + { + restPreferenceModelsCollection = restClient.authenticateUser(user1).withCoreAPI().usingMe().usingParams("maxItems=0").getPersonPreferences(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsErrorKey(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) + .containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its preferences with skipCount parameter applied with Rest API and response is successful") + public void userGetsPeoplePreferencesUsingInvalidSkipCountParameter() throws Exception + { + restPreferenceModelsCollection = restClient.authenticateUser(user1).withCoreAPI().usingMe().usingParams("skipCount=-1").getPersonPreferences(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsErrorKey(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT) + .containsSummary(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user which doesn't have access to another user preferences fails to get its preferences with Rest API and response is permission denied") + public void userWithNoAccessToOtherUserPreferencesIsForbiddenToGetItsPreferences() throws Exception + { + UserModel noAccessUser = dataUser.createRandomTestUser(); + dataSite.usingUser(noAccessUser).usingSite(siteModel).addSiteToFavorites(); + + restPreferenceModelsCollection = restClient.authenticateUser(user1).withCoreAPI().usingUser(noAccessUser).getPersonPreferences(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + restClient.assertLastError().containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user fails to get preferences for inexistent personId with Rest API and response is 404") + public void userCannotGetPeoplePreferencesForInexistentPersonId() throws Exception + { + UserModel inexistentUserName = new UserModel("inexistent", "password"); + + restPreferenceModelsCollection = restClient.authenticateUser(user1).withCoreAPI().usingUser(inexistentUserName).getPersonPreferences(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + restClient.assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, inexistentUserName.getUsername())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user get preferences for a user with no preferences with Rest API and response is empty") + public void userGetsPeoplePreferencesForUserWithNoPreferences() throws Exception + { + UserModel userNoActivities = dataUser.createRandomTestUser(); + + restPreferenceModelsCollection = restClient.authenticateUser(adminUser).withCoreAPI().usingUser(userNoActivities).getPersonPreferences(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restPreferenceModelsCollection.assertThat().paginationField("count").is("0"); + restPreferenceModelsCollection.assertThat().entriesListIsEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user fails to get preferences for a removed preference with Rest API and response is 404") + public void userFailsToGetPeoplePreferencesIfPreferenceWasRemoved() throws Exception + { + SiteModel preferenceSite = dataSite.usingUser(user1).createPublicRandomSite(); + dataSite.usingUser(user1).usingSite(preferenceSite).addSiteToFavorites(); + restPreferenceModelsCollection = restClient.authenticateUser(user1).withCoreAPI().usingAuthUser().getPersonPreferences(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restPreferenceModelsCollection.assertThat().paginationField("count").is("6"); + + dataSite.usingUser(user1).usingSite(preferenceSite).removeSiteFromFavorites(); + restPreferenceModelsCollection = restClient.authenticateUser(user1).withCoreAPI().usingAuthUser().getPersonPreferences(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restPreferenceModelsCollection.assertThat().paginationField("count").is("5"); + restPreferenceModelsCollection.assertThat().entriesListDoesNotContain("id", String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), preferenceSite.getId())); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/people/preferences/GetPeoplePreferencesFullTests.java b/e2e-test/src/test/java/org/alfresco/rest/people/preferences/GetPeoplePreferencesFullTests.java new file mode 100644 index 000000000..28de256d3 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/people/preferences/GetPeoplePreferencesFullTests.java @@ -0,0 +1,114 @@ +package org.alfresco.rest.people.preferences; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestPreferenceModelsCollection; +import org.alfresco.utility.constants.PreferenceName; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * + * @author Cristina Axinte + * + */ +public class GetPeoplePreferencesFullTests extends RestTest +{ + UserModel userModel, user1, user2, adminUser; + SiteModel siteModel; + FolderModel folderModel; + private RestPreferenceModelsCollection restPreferenceModelsCollection; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + + user1 = dataUser.createRandomTestUser(); + dataSite.usingUser(user1).usingSite(siteModel).addSiteToFavorites(); + dataContent.usingUser(user1).usingSite(siteModel).addFolderToFavorites(folderModel); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its preferences with skipCount parameter applied with Rest API and response is successful") + public void userGetsItsPeoplePreferencesUsingSkipCountParameter() throws Exception + { + restPreferenceModelsCollection = restClient.authenticateUser(user1).withCoreAPI().usingMe().usingParams("skipCount=2").getPersonPreferences(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restPreferenceModelsCollection.assertThat().paginationField("count").is("2"); + restPreferenceModelsCollection.assertThat().paginationField("skipCount").is("2"); + restPreferenceModelsCollection.assertThat().entriesListIsNotEmpty() + .and().entriesListDoesNotContain("id", String.format(PreferenceName.EXT_FOLDERS_FAVORITES_PREFIX.toString(), "workspace://SpacesStore/" + folderModel.getNodeRef())) + .and().entriesListDoesNotContain("id", String.format(PreferenceName.EXT_SITES_FAVORITES_PREFIX.toString(), siteModel.getId())) + .and().entriesListContains("id", PreferenceName.FOLDERS_FAVORITES_PREFIX.toString()) + .and().entriesListContains("value", "workspace://SpacesStore/" + folderModel.getNodeRef()) + .and().entriesListContains("id", String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())) + .and().entriesListContains("value", "true"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its preferences with maxItems parameter applied with Rest API and response is successful") + public void userGetsItsPeoplePreferencesUsingMaxItemsParameter() throws Exception + { + restPreferenceModelsCollection = restClient.authenticateUser(user1).withCoreAPI().usingMe().usingParams("maxItems=1").getPersonPreferences(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restPreferenceModelsCollection.assertThat().paginationField("count").is("1"); + restPreferenceModelsCollection.assertThat().paginationField("maxItems").is("1"); + restPreferenceModelsCollection.assertThat().entriesListIsNotEmpty() + .and().entriesListContains("id", String.format(PreferenceName.EXT_FOLDERS_FAVORITES_PREFIX.toString(), "workspace://SpacesStore/" + folderModel.getNodeRef())) + .and().entriesListDoesNotContain("id", String.format(PreferenceName.EXT_SITES_FAVORITES_PREFIX.toString(), siteModel.getId())) + .and().entriesListDoesNotContain("id", PreferenceName.FOLDERS_FAVORITES_PREFIX.toString()) + .and().entriesListDoesNotContain("value", "workspace://SpacesStore/" + folderModel.getNodeRef()) + .and().entriesListDoesNotContain("id", String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())) + .and().entriesListDoesNotContain("value", "true"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets admin preferences with Rest API and response is permission denied") + public void userIsForbiddenToGetAdminPreferences() throws Exception + { + restPreferenceModelsCollection = restClient.authenticateUser(user1).withCoreAPI().usingUser(adminUser).getPersonPreferences(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + restClient.assertLastError().containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its preferences with skipCount parameter higher then no of entries with Rest API and response is empty") + public void userGetsItsPeoplePreferencesUsingHighSkipCount() throws Exception + { + restPreferenceModelsCollection = restClient.authenticateUser(user1).withCoreAPI().usingMe().usingParams("skipCount=100").getPersonPreferences(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restPreferenceModelsCollection.assertThat().paginationField("count").is("0"); + restPreferenceModelsCollection.assertThat().paginationField("skipCount").is("100"); + restPreferenceModelsCollection.assertThat().entriesListIsEmpty(); + } + + @Bug(id = "REPO-1911") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot get preferences for empty user with Rest API and response is 400") + public void userGetsItsPeoplePreferencesForEmptyPersonId() throws Exception + { + UserModel emptyUserName = new UserModel("", "password"); + + restPreferenceModelsCollection = restClient.authenticateUser(user1).withCoreAPI().usingUser(emptyUserName).getPersonPreferences(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .containsSummary(RestErrorModel.LOCAL_NAME_CONSISTANCE) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/people/preferences/GetPeoplePreferencesSanityTests.java b/e2e-test/src/test/java/org/alfresco/rest/people/preferences/GetPeoplePreferencesSanityTests.java new file mode 100644 index 000000000..7570f80a4 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/people/preferences/GetPeoplePreferencesSanityTests.java @@ -0,0 +1,121 @@ +package org.alfresco.rest.people.preferences; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestPreferenceModelsCollection; +import org.alfresco.utility.constants.PreferenceName; +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.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Tests for Get Peferences (/people/{personId}/preferences) RestAPI call + * + * @author Cristina Axinte + */ + +public class GetPeoplePreferencesSanityTests extends RestTest +{ + UserModel userModel; + SiteModel siteModel; + private RestPreferenceModelsCollection restPreferenceModelsCollection; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify manager user gets its preferences with Rest API and response is successful (200)") + public void managerUserGetsPeoplePreferencesWithSuccess() throws Exception + { + UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); + dataSite.usingUser(managerUser).usingSite(siteModel).addSiteToFavorites(); + + restPreferenceModelsCollection = restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().getPersonPreferences(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restPreferenceModelsCollection.assertThat().entriesListIsNotEmpty().assertThat().paginationExist().and() + .entriesListContains("id", String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify collaborator user gets its preferences with Rest API and response is successful (200)") + public void collaboratorUserGetsPeoplePreferencesWithSuccess() throws Exception + { + UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(collaboratorUser, siteModel, UserRole.SiteCollaborator); + dataSite.usingUser(collaboratorUser).usingSite(siteModel).addSiteToFavorites(); + + restPreferenceModelsCollection = restClient.authenticateUser(collaboratorUser).withCoreAPI().usingAuthUser().getPersonPreferences(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restPreferenceModelsCollection.assertThat().entriesListIsNotEmpty().assertThat().paginationExist().and() + .entriesListContains("id", String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify contributor user gets its preferences with Rest API and response is successful (200)") + public void contributorUserGetsPeoplePreferencesWithSuccess() throws Exception + { + UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(contributorUser, siteModel, UserRole.SiteContributor); + dataSite.usingUser(contributorUser).usingSite(siteModel).addSiteToFavorites(); + + restPreferenceModelsCollection = restClient.authenticateUser(contributorUser).withCoreAPI().usingAuthUser().getPersonPreferences(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restPreferenceModelsCollection.assertThat().entriesListIsNotEmpty().assertThat().paginationExist().and() + .entriesListContains("id", String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify consumer user gets its preferences with Rest API and response is successful (200)") + public void consumerUserGetsPeoplePreferencesWithSuccess() throws Exception + { + UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel, UserRole.SiteConsumer); + dataSite.usingUser(consumerUser).usingSite(siteModel).addSiteToFavorites(); + + restPreferenceModelsCollection = restClient.authenticateUser(consumerUser).withCoreAPI().usingAuthUser().getPersonPreferences(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restPreferenceModelsCollection.assertThat().entriesListIsNotEmpty().assertThat().paginationExist().and() + .entriesListContains("id", String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify admin user gets another user preferences with Rest API and response is successful (200)") + public void adminUserGetsPeoplePreferencesWithSuccess() throws Exception + { + UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); + dataSite.usingUser(managerUser).usingSite(siteModel).addSiteToFavorites(); + UserModel adminUser = dataUser.getAdminUser(); + + restPreferenceModelsCollection = restClient.authenticateUser(adminUser).withCoreAPI().usingUser(managerUser).getPersonPreferences(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restPreferenceModelsCollection.assertThat().entriesListIsNotEmpty().assertThat().paginationExist().and() + .entriesListContains("id", String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized to gets its preferences with Rest API when authentication fails(401)") +// @Bug(id = "MNT-16904", description = "It fails only on environment with tenants") + public void managerUserGetsPeoplePreferencesIsNotAuthorized() throws Exception + { + UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); + dataSite.usingUser(managerUser).usingSite(siteModel).addSiteToFavorites(); + managerUser.setPassword("newpassword"); + + restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().getPersonPreferences(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/queries/QueriesTest.java b/e2e-test/src/test/java/org/alfresco/rest/queries/QueriesTest.java new file mode 100644 index 000000000..ddfce7ae8 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/queries/QueriesTest.java @@ -0,0 +1,178 @@ +package org.alfresco.rest.queries; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestNodeModelsCollection; +import org.alfresco.rest.model.RestPersonModelsCollection; +import org.alfresco.rest.model.RestSiteModel; +import org.alfresco.rest.model.RestSiteModelsCollection; +import org.alfresco.utility.RetryOperation; +import org.alfresco.utility.Utility; +import org.alfresco.utility.model.ContentModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FileType; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.Test; + + +/** + * Handle requests on Queries + * + */ +public class QueriesTest extends RestTest +{ + @TestRail(section = { TestGroup.REST_API, + TestGroup.QUERIES }, executionType = ExecutionType.SANITY, description = "Check basic functionality of GET queries/sites") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) + public void getQueriesSites() throws Exception + { + restClient.authenticateUser(dataContent.getAdminUser()).withCoreAPI().usingQueries().findSites(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + restClient.assertLastError().containsErrorKey("Query 'term' not specified") + // and assert on summary too if you want + .containsSummary("Query 'term' not specified"); + + restClient.withCoreAPI().usingQueries().usingParams("term=b").findSites(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + restClient.assertLastError().containsErrorKey("Query 'term' is too short"); + + SiteModel site = RestSiteModel.getRandomSiteModel(); + RestSiteModel createdSite = restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingSite(site).createSite(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RetryOperation op = new RetryOperation() + { + public void execute() throws Exception + { + RestSiteModelsCollection restSiteModels = restClient.withCoreAPI().usingQueries().usingParams("term=" + createdSite.getTitle()) + .findSites(); + + assertEquals(restSiteModels.getEntries().size(), 1); + + } + }; + + Utility.sleep(100, 100000, op);// Allow indexing to complete. + + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.QUERIES }, executionType = ExecutionType.SANITY, description = "Check basic functionality of GET queries/people") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) + public void getQueriesPeople() throws Exception + { + restClient.authenticateUser(dataContent.getAdminUser()).withCoreAPI().usingQueries().findPeople(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + restClient.assertLastError().containsErrorKey("Query 'term' not specified") + // and assert on summary too if you want + .containsSummary("Query 'term' not specified"); + + restClient.withCoreAPI().usingQueries().usingParams("term=b").findPeople(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + restClient.assertLastError().containsErrorKey("Query 'term' is too short"); + + UserModel userModel = dataUser.createRandomTestUser(); + RetryOperation op = new RetryOperation() + { + public void execute() throws Exception + { + RestPersonModelsCollection restPersonModels = restClient.withCoreAPI().usingQueries().usingParams("term=" + userModel.getUsername()) + .findPeople(); + + assertEquals(restPersonModels.getEntries().size(), 1); + + } + }; + + Utility.sleep(100, 100000, op);// Allow indexing to complete. + + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.QUERIES }, + executionType = ExecutionType.REGRESSION, description = "Check basic functionality of GET queries/nodes") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void getOnQueriesNodesRoute() throws Exception + { + restClient.authenticateUser(dataContent.getAdminUser()) + .withCoreAPI() + .usingQueries().findNodes(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + + restClient.assertLastError() + .containsErrorKey("Query 'term' not specified") + //and assert on summary too if you want + .containsSummary("Query 'term' not specified"); + + restClient.withCoreAPI() + .usingQueries() + .usingParams("term=ab") + .findNodes(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + + restClient.assertLastError() + .containsErrorKey("Query 'term' is too short"); + + /* + * now making the correct call with a valid term value + */ + restClient.withCoreAPI().usingQueries().usingParams("term=name").findNodes(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.QUERIES }, executionType = ExecutionType.REGRESSION, description = "Verify GET queries on queries/nodes return success status code") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) + public void testSearchTermWhiteSpace() throws Exception + { + + UserModel userModel = dataUser.createRandomTestUser(); + SiteModel siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + /* + * Create the following file structure for preconditions : + * |- folder + * |--find123.txt + * |-- find123 find.txt + */ + restClient.authenticateUser(userModel).withCoreAPI().usingNode(ContentModel.my()).defineNodes(); + FolderModel folder = new FolderModel("folder" + Math.random()); + + // I use "find123" and "find123 find", the search using second term must + // return less result + // The space must not break the query + String childTerm = "find" + Math.random(); + String childTermWS = childTerm + " " + "find"; + + dataContent.usingUser(userModel).usingSite(siteModel).createFolder(folder); + FileModel file1 = new FileModel(childTerm + ".txt", FileType.TEXT_PLAIN, childTerm); + FileModel file2 = new FileModel(childTermWS + ".txt", FileType.TEXT_PLAIN, childTermWS); + ContentModel cm = new ContentModel(); + cm.setCmisLocation(folder.getCmisLocation()); + cm.setName(folder.getName()); + dataContent.usingUser(userModel).usingSite(siteModel).usingResource(cm).createContent(file1); + dataContent.usingUser(userModel).usingSite(siteModel).usingResource(cm).createContent(file2); + + RetryOperation op = new RetryOperation(){ + public void execute() throws Exception{ + RestNodeModelsCollection nodesChildTerm = restClient.withCoreAPI().usingQueries().usingParams("term=" + childTerm).findNodes(); + // check if the search returns all nodes which contain that query term + assertEquals(2, nodesChildTerm.getEntries().size()); + RestNodeModelsCollection nodesChildTermWS = restClient.withCoreAPI().usingQueries().usingParams("term=" + childTermWS).findNodes(); + // check if search works for words with space and the space don't break + // the query + assertEquals(1, nodesChildTermWS.getEntries().size()); + assertTrue(nodesChildTerm.getEntries().size() >= nodesChildTermWS.getEntries().size()); + } + + }; + Utility.sleep(10, 3500, op);// Allow indexing to complete. + + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/ratings/AddRatingTests.java b/e2e-test/src/test/java/org/alfresco/rest/ratings/AddRatingTests.java new file mode 100644 index 000000000..72e3595a4 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/ratings/AddRatingTests.java @@ -0,0 +1,818 @@ +package org.alfresco.rest.ratings; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestCommentModel; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestRatingModel; +import org.alfresco.rest.model.RestTagModel; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.exception.DataPreparationException; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.LinkModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.apache.commons.lang3.RandomStringUtils; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + + +public class AddRatingTests extends RestTest +{ + private UserModel userModel; + private SiteModel siteModel; + private UserModel adminUser; + private ListUserWithRoles usersWithRoles; + private RestRatingModel returnedRatingModel; // placeholder for returned model + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws DataPreparationException + { + userModel = dataUser.createRandomTestUser(); + adminUser = dataUser.getAdminUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.SANITY, description = "Verify user with Manager role is able to post like rating to a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) + public void managerIsAbleToLikeDocument() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(document) + .likeDocument(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Verify user with Collaborator role is able to post like rating to a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void collaboratorIsAbleToLikeDocument() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(document) + .likeDocument(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Verify user with Contributor role is able to post like rating to a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void contributorIsAbleToLikeDocument() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingResource(document) + .likeDocument(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Verify user with Consumer role is able to post like rating to a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void consumerIsAbleToLikeDocument() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingResource(document) + .likeDocument(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Verify admin user is able to post like rating to a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void adminIsAbleToLikeDocument() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + returnedRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to post like rating to a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) +// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") + public void unauthenticatedUserIsNotAbleToLikeDocument() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(new UserModel("random user", "random password")).withCoreAPI().usingResource(document).likeDocument(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.SANITY, description = "Verify user with Manager role is able to post stars rating to a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) + public void managerIsAbleToAddStarsToDocument() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(document) + .rateStarsToDocument(5); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Verify user with Collaborator role is able to post stars rating to a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void collaboratorIsAbleToAddStarsToDocument() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(document) + .rateStarsToDocument(5); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); + + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Verify user with Contributor role is able to post stars rating to a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void contributorIsAbleToAddStarsToDocument() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingResource(document) + .rateStarsToDocument(5); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Verify user with Consumer role is able to post stars rating to a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void consumerIsAbleToAddStarsToDocument() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingResource(document) + .rateStarsToDocument(5); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.REGRESSION }, + executionType = ExecutionType.SANITY, description = "Verify admin user is able to post stars rating to a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void adminIsAbleToAddStarsToDocument() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + returnedRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).rateStarsToDocument(3); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedRatingModel.assertThat().field("myRating").is("3").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to post stars rating to a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) +// @Bug(id="MNT-16904", description = "fails only on environment with tenants") + public void unauthenticatedUserIsNotAbleToRateStarsToDocument() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(new UserModel("random user", "random password")).withCoreAPI().usingResource(document).rateStarsToDocument(5); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Verify that if unknown rating scheme is provided status code is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void unknownRatingSchemeReturnsBadRequest() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"invalidRate\"}"); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsSummary(String.format(RestErrorModel.INVALID_RATING, "invalidRate")) + .containsErrorKey(String.format(RestErrorModel.INVALID_RATING, "invalidRate")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Verify that if nodeId does not exist status code 404 is returned") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void invalidNodeIdReturnsNotFound() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + document.setNodeRef(RandomStringUtils.randomAlphanumeric(10)); + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, document.getNodeRef())) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Verify that if nodeId provided cannot be rated 405 status code is returned") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void likeResourceThatCannotBeRated() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + LinkModel link = dataLink.usingAdmin().usingSite(siteModel).createRandomLink(); + document.setNodeRef(link.getNodeRef().replace("workspace://SpacesStore/", "workspace%3A%2F%2FSpacesStore%2F")); + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, document.getNodeRef())) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.SANITY, description = "Verify that manager is able to like a folder") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) + public void managerIsAbleToLikeAFolder() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(folderModel) + .likeDocument(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.SANITY, description = "Verify that manager is able to like a site") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) + public void managerIsAbleToLikeASite() throws Exception + { + FolderModel folderModel = new FolderModel(); + folderModel.setNodeRef(siteModel.getGuid()); + + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(folderModel) + .likeDocument(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty(); + + restClient.withCoreAPI().usingResource(folderModel).getRatings() + .assertNodeIsLiked(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.SANITY, description = "Verify that manager is able to rate a folder") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) + public void managerIsAbleToRateAFolder() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(folderModel) + .rateStarsToDocument(5); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.SANITY }, + executionType = ExecutionType.REGRESSION, description = "Verify that manager is able to rate a site") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) + public void managerIsAbleToRateASite() throws Exception + { + FolderModel folderModel = new FolderModel(); + folderModel.setNodeRef(siteModel.getGuid()); + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(folderModel) + .rateStarsToDocument(5); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); + + restClient.withCoreAPI().usingResource(folderModel).getRatings() + .assertNodeHasFiveStarRating(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Verify that adding like again has no effect on a file") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void fileCanBeLikedTwice() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Verify that adding rate again has no effect on a file") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void fileCanBeRatedTwice() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).rateStarsToDocument(5); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).rateStarsToDocument(5); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Verify that rate is not added if empty rating object is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void addRateUsingEmptyRatingObject() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating(""); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.NO_CONTENT, "No content to map due to end-of-input")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Verify that if empty rate id is provided status code is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void addRateUsingEmptyValueForId() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"\"}"); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + // The message is shortened for comparison as there is a Java object id in the message (random) + .containsSummary(String.format(RestErrorModel.NO_CONTENT, "N/A")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Verify that if empty rating is provided status code is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void addRateUsingEmptyValueForMyRating() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"likes\", \"myRating\":\"\"}"); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.NULL_LIKE_RATING)); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"fiveStar\", \"myRating\":\"\"}"); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.NULL_FIVESTAR_RATING)); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Verify that user is not able to rate a comment") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void addRatingToAComment() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + RestCommentModel comment = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addComment("This is a comment"); + document.setNodeRef(comment.getId()); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) + .assertLastError() + .containsSummary(String.format(RestErrorModel.CANNOT_RATE)) + .containsErrorKey(RestErrorModel.CANNOT_RATE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).rateStarsToDocument(5); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(String.format(RestErrorModel.CANNOT_RATE)); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Verify that user is not able to rate a tag") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void addRatingToATag() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + RestTagModel tag = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addTag("randomTag"); + document.setNodeRef(tag.getId()); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(String.format(RestErrorModel.CANNOT_RATE)); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).rateStarsToDocument(5); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(String.format(RestErrorModel.CANNOT_RATE)); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that Contributor is able to like a folder") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void contributorIsAbleToLikeAFolder() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI() + .usingResource(folderModel) + .likeDocument(); + + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedRatingModel.assertThat().field("myRating").is("true") + .and().field("id").is("likes") + .and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that Collaborator is able to like a folder") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void collaboratorIsAbleToLikeAFolder() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI() + .usingResource(folderModel) + .likeDocument(); + + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedRatingModel.assertThat().field("myRating").is("true") + .and().field("id").is("likes") + .and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that Consumer is able to like a folder") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void consumerIsAbleToLikeAFolder() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI() + .usingResource(folderModel) + .likeDocument(); + + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedRatingModel.assertThat().field("myRating").is("true") + .and().field("id").is("likes") + .and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that Contributor is able to rate a folder") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void contributorIsAbleToRateAFolder() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI() + .usingResource(folderModel) + .rateStarsToDocument(5); + + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedRatingModel.assertThat().field("myRating").is("5") + .and().field("id").is("fiveStar") + .and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that Collaborator is able to rate a folder") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void collaboratorIsAbleToRateAFolder() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI() + .usingResource(folderModel) + .rateStarsToDocument(5); + + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedRatingModel.assertThat().field("myRating").is("5") + .and().field("id").is("fiveStar") + .and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that Consumer is able to rate a folder") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void consumerIsAbleToRateAFolder() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI() + .usingResource(folderModel) + .rateStarsToDocument(5); + + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedRatingModel.assertThat().field("myRating").is("5") + .and().field("id").is("fiveStar") + .and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that adding like again has no effect on a folder") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void folderCanBeLikedTwice() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folderModel).likeDocument(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folderModel).likeDocument(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("true") + .and().field("id").is("likes") + .and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that adding rate again has no effect on a folder") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void folderCanBeRatedTwice() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folderModel).rateStarsToDocument(5); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folderModel).rateStarsToDocument(5); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("5") + .and().field("id").is("fiveStar") + .and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that if invalid rate id is provided status code is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void addRateUsingInvalidValueForId() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"like\"}"); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsSummary(String.format(RestErrorModel.INVALID_RATING, "like")) + .containsErrorKey(String.format(RestErrorModel.INVALID_RATING, "like")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that rate id is case sensitive is provided status code is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void addRateUsingInvalidValueForIdCaseSensitive() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"Likes\"}"); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsSummary(String.format(RestErrorModel.INVALID_RATING, "Likes")) + .containsErrorKey(String.format(RestErrorModel.INVALID_RATING, "Likes")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"FiveStar\"}"); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsSummary(String.format(RestErrorModel.INVALID_RATING, "FiveStar")) + .containsErrorKey(String.format(RestErrorModel.INVALID_RATING, "FiveStar")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that if invalid rating is provided status code is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void addRateUsingInvalidValueForMyRating() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"likes\", \"myRating\":\"skiped\"}"); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsSummary(String.format(RestErrorModel.NULL_LIKE_RATING)); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"fiveStar\", \"myRating\":\"string\"}"); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsSummary(String.format(RestErrorModel.NULL_FIVESTAR_RATING)); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Like file created by a different user") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void addLikeToAnotherUserFile() throws Exception + { + UserModel user = dataUser.usingAdmin().createRandomTestUser(); + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + returnedRatingModel = restClient.authenticateUser(user).withCoreAPI().usingResource(document).likeDocument(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedRatingModel.assertThat().field("myRating").is("true") + .and().field("id").is("likes") + .and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Rate a file created by a different user") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void addRatingToAnotherUserFile() throws Exception + { + UserModel user = dataUser.usingAdmin().createRandomTestUser(); + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + returnedRatingModel = restClient.authenticateUser(user).withCoreAPI().usingResource(document).rateStarsToDocument(5); + returnedRatingModel.assertThat().field("myRating").is("5") + .and().field("id").is("fiveStar") + .and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Add Rate Using Boolean Value For 'myRating'") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void addRateUsingBooleanValueForMyRating() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"fiveStar\", \"myRating\":\"true\"}"); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsSummary(RestErrorModel.NULL_FIVESTAR_RATING) + .containsErrorKey(RestErrorModel.NULL_FIVESTAR_RATING) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Add Like Using Integer Value For 'myRating'") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void addLikeUsingIntegerValueForMyRating() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"likes\", \"myRating\":\"2\"}"); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsSummary(RestErrorModel.NULL_LIKE_RATING) + .containsErrorKey(RestErrorModel.NULL_LIKE_RATING) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that user is not able to like his own comment") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void userCannotLikeHisOwnComment() throws Exception + { + UserModel user = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); + FolderModel folderModel = dataContent.usingUser(user).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(user).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + RestCommentModel comment = restClient.authenticateUser(user).withCoreAPI().usingResource(document).addComment("This is a comment"); + document.setNodeRef(comment.getId()); + + returnedRatingModel = restClient.authenticateUser(user).withCoreAPI().usingResource(document).likeDocument(); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) + .assertLastError() + .containsSummary(String.format(RestErrorModel.CANNOT_RATE)) + .containsErrorKey(RestErrorModel.CANNOT_RATE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER).stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that user is not able to rate his own comment") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void userCannotRateHisOwnComment() throws Exception + { + UserModel user = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); + FolderModel folderModel = dataContent.usingUser(user).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(user).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + RestCommentModel comment = restClient.authenticateUser(user).withCoreAPI().usingResource(document).addComment("This is a comment"); + document.setNodeRef(comment.getId()); + + returnedRatingModel = restClient.authenticateUser(user).withCoreAPI().usingResource(document).rateStarsToDocument(5); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) + .assertLastError() + .containsSummary(String.format(RestErrorModel.CANNOT_RATE)) + .containsErrorKey(RestErrorModel.CANNOT_RATE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that Collaborator is NOT able to add a negative rating to a file") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void collaboratorIsNotAbleToAddANegativeRatingToAFile() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI() + .usingResource(document) + .rateStarsToDocument(-5); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsSummary(RestErrorModel.RATING_OUT_OF_BOUNDS) + .containsErrorKey(RestErrorModel.RATING_OUT_OF_BOUNDS) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that Collaborator is NOT able to add a high rating to a file") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void collaboratorIsNotAbleToAddAHighRatingToAFile() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI() + .usingResource(document) + .rateStarsToDocument(10); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsSummary(RestErrorModel.RATING_OUT_OF_BOUNDS) + .containsErrorKey(RestErrorModel.RATING_OUT_OF_BOUNDS) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + // @Bug(id = "MNT-17375", description = "Won't Fix, the error message is not ideal and a little cryptic but it does provide the reason i.e. ratingSchemeId is null.") + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Do not provide field - 'id'") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void notProvideIdLikeFile() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"myRating\":\"true\"}"); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsSummary(String.format(RestErrorModel.INVALID_RATING, "null")) + .containsErrorKey(String.format(RestErrorModel.INVALID_RATING, "null")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Do not provide field - 'myRating'") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void notProvideMyRatingRateFile() throws Exception + { + FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"likes\"}"); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsSummary(RestErrorModel.NULL_LIKE_RATING) + .containsErrorKey(RestErrorModel.NULL_LIKE_RATING) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } +} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/rest/ratings/DeleteRatingTests.java b/e2e-test/src/test/java/org/alfresco/rest/ratings/DeleteRatingTests.java new file mode 100644 index 000000000..1edea1c5d --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/ratings/DeleteRatingTests.java @@ -0,0 +1,525 @@ +package org.alfresco.rest.ratings; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestRatingModel; +import org.alfresco.rest.model.RestRatingModelsCollection; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.exception.DataPreparationException; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class DeleteRatingTests extends RestTest +{ + private SiteModel siteModel; + private UserModel adminUser; + private ListUserWithRoles usersWithRoles; + private RestRatingModelsCollection returnedRatingModelCollection; + private RestRatingModel returnedRatingModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws DataPreparationException + { + adminUser = dataUser.getAdminUser(); + siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); + + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.SANITY, description = "Verify user with Manager role is able to remove its own rating of a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) + public void managerIsAbleToDeleteItsOwnRatings() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + restClient.withCoreAPI().usingResource(document).likeDocument(); + restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); + + restClient.withCoreAPI().usingResource(document).deleteLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + returnedRatingModelCollection = restClient.withCoreAPI().usingResource(document).getRatings(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedRatingModelCollection.assertNodeIsNotLiked().assertNodeHasNoFiveStarRating().and().entriesListIsNotEmpty().and().paginationExist(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Verify user with Collaborator role is able to remove its own rating of a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void collaboratorIsAbleToDeleteItsOwnRatings() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + + restClient.withCoreAPI().usingResource(document).likeDocument(); + restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); + + restClient.withCoreAPI().usingResource(document).deleteLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + returnedRatingModelCollection = restClient.withCoreAPI().usingResource(document).getRatings(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedRatingModelCollection.assertNodeIsNotLiked().assertNodeHasNoFiveStarRating().and().entriesListIsNotEmpty().and().paginationExist(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Verify user with Contributor role is able to remove its own rating of a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void contributorIsAbleToDeleteItsOwnRatings() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + + restClient.withCoreAPI().usingResource(document).likeDocument(); + restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); + + restClient.withCoreAPI().usingResource(document).deleteLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + returnedRatingModelCollection = restClient.withCoreAPI().usingResource(document).getRatings(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedRatingModelCollection.assertNodeIsNotLiked().assertNodeHasNoFiveStarRating().and().entriesListIsNotEmpty().and().paginationExist(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Verify user with Consumer role is able to remove its own rating of a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void consumerIsAbleToDeleteItsOwnRatings() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + + restClient.withCoreAPI().usingResource(document).likeDocument(); + restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); + + restClient.withCoreAPI().usingResource(document).deleteLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + returnedRatingModelCollection = restClient.withCoreAPI().usingResource(document).getRatings(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedRatingModelCollection.assertNodeIsNotLiked().assertNodeHasNoFiveStarRating().and().entriesListIsNotEmpty().and().paginationExist(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Verify admin user is able to remove its own rating of a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void adminIsAbleToDeleteItsOwnRatings() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + document = dataContent.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).usingResource(folderModel) + .createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(adminUser); + + restClient.withCoreAPI().usingResource(document).likeDocument(); + restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); + + restClient.withCoreAPI().usingResource(document).deleteLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + returnedRatingModelCollection = restClient.withCoreAPI().usingResource(document).getRatings(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedRatingModelCollection.assertNodeIsNotLiked().assertNodeHasNoFiveStarRating().and().entriesListIsNotEmpty().and().paginationExist(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to remove its own rating of a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) +// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") + public void unauthenticatedUserIsNotAbleToDeleteRatings() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + document = dataContent.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).usingResource(folderModel) + .createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(adminUser); + + restClient.withCoreAPI().usingResource(document).likeDocument(); + restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); + + restClient.authenticateUser(new UserModel("random user", "random password")); + + restClient.withCoreAPI().usingResource(document).deleteLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + + restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Verify one user is not able to remove rating added by another user") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + @Bug(id = "ACE-5459") + public void oneUserIsNotAbleToDeleteRatingsOfAnotherUser() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + UserModel userA = dataUser.createRandomTestUser(); + UserModel userB = dataUser.createRandomTestUser(); + + restClient.authenticateUser(userA); + + restClient.withCoreAPI().usingResource(document).likeDocument(); + restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); + + restClient.authenticateUser(userB); + + restClient.withCoreAPI().usingResource(document).deleteLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + + restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + restClient.withCoreAPI().usingResource(document).getRatings() + .assertNodeIsLiked() + .assertNodeHasFiveStarRating(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Verify that if ratingId provided is unknown status code returned is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void deleteInvalidRating() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).deleteInvalidRating("random_rating"); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsSummary(String.format(RestErrorModel.INVALID_RATING, "random_rating")) + .containsErrorKey(String.format(RestErrorModel.INVALID_RATING, "random_rating")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Verify that if nodeId does not exist status code returned is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void deleteRatingUsingInvalidDocument() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + document.setNodeRef("random_value"); + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).deleteLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "random_value")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Delete rating stars for a document that was not rated") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + @Bug(id = "MNT-17181") + public void deleteStarsForANotRatedDocument() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).deleteFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Delete like rating for a document that was not liked") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + @Bug(id = "MNT-17181") + public void deleteLikeForANotLikedDocument() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).deleteLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Delete like for a file then add it again") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void likeDocumentAfterLikeRatingIsDeleted() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); + restClient.withCoreAPI().usingResource(document).deleteLikeRating(); + returnedRatingModel = restClient.withCoreAPI().usingResource(document).likeDocument(); + + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Delete stars for a file then add them again") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void addStarsToDocumentAfterRatingIsDeleted() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(document).rateStarsToDocument(5); + restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + returnedRatingModel = restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); + + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Verify site manager is not able to remove rating added by another user") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + @Bug(id = "ACE-5459") + public void deleteDocumentRatingUsingManager() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(document).rateStarsToDocument(5); + restClient.withCoreAPI().usingResource(document).likeDocument(); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(document).deleteFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + restClient.withCoreAPI().usingResource(document).deleteLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + + restClient.withCoreAPI().usingResource(document).getRatings() + .assertNodeIsLiked() + .assertNodeHasFiveStarRating(); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Verify site contributor is not able to remove rating added by another user") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + @Bug(id = "ACE-5459") + public void contributorIsNotAbleToDeleteRatingsOfAnotherUser() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(document).rateStarsToDocument(5); + restClient.withCoreAPI().usingResource(document).likeDocument(); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingResource(document).deleteFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + restClient.withCoreAPI().usingResource(document).deleteLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + + restClient.withCoreAPI().usingResource(document).getRatings() + .assertNodeIsLiked() + .assertNodeHasFiveStarRating(); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Verify site collaborator is not able to remove rating added by another user") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + @Bug(id = "ACE-5459") + public void collaboratorIsNotAbleToDeleteRatingsOfAnotherUser() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(document).rateStarsToDocument(5); + restClient.withCoreAPI().usingResource(document).likeDocument(); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(document).deleteFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + restClient.withCoreAPI().usingResource(document).deleteLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + + restClient.withCoreAPI().usingResource(document).getRatings() + .assertNodeIsLiked() + .assertNodeHasFiveStarRating(); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Verify site consumer is not able to remove rating added by another user") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + @Bug(id = "ACE-5459") + public void consumerIsNotAbleToDeleteRatingsOfAnotherUser() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(document).rateStarsToDocument(5); + restClient.withCoreAPI().usingResource(document).likeDocument(); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingResource(document).deleteFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + restClient.withCoreAPI().usingResource(document).deleteLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + + restClient.withCoreAPI().usingResource(document).getRatings() + .assertNodeIsLiked() + .assertNodeHasFiveStarRating(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Delete rating stars twice") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + @Bug(id = "MNT-17181") + public void deleteStarsTwice() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(document).rateStarsToDocument(5); + + restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + returnedRatingModelCollection = restClient.withCoreAPI().usingResource(document).getRatings(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedRatingModelCollection.assertNodeHasNoFiveStarRating(); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).deleteFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Delete like rating twice") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + @Bug(id = "MNT-17181") + public void deleteLikeTwice() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + restClient.withCoreAPI().usingResource(document).likeDocument(); + + restClient.withCoreAPI().usingResource(document).deleteLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + returnedRatingModelCollection = restClient.withCoreAPI().usingResource(document).getRatings(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedRatingModelCollection.assertNodeIsNotLiked(); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).deleteLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Delete like for a folder then add it again") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void likeFolderAfterLikeRatingIsDeleted() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folderModel).likeDocument(); + restClient.withCoreAPI().usingResource(folderModel).deleteLikeRating(); + returnedRatingModel = restClient.withCoreAPI().usingResource(folderModel).likeDocument(); + + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Delete stars for a folder then add them again") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void addStarsToFolderAfterRatingIsDeleted() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(folderModel).rateStarsToDocument(5); + restClient.withCoreAPI().usingResource(folderModel).deleteFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + returnedRatingModel = restClient.withCoreAPI().usingResource(folderModel).rateStarsToDocument(5); + + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Delete like for a site then add it again") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void likeSiteAfterLikeRatingIsDeleted() throws Exception + { + FolderModel folderModel = new FolderModel(); + folderModel.setNodeRef(siteModel.getGuid()); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folderModel).likeDocument(); + restClient.withCoreAPI().usingResource(folderModel).deleteLikeRating(); + returnedRatingModel = restClient.withCoreAPI().usingResource(folderModel).likeDocument(); + + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Delete stars for a site then add them again") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void addStarsToSiteAfterRatingIsDeleted() throws Exception + { + FolderModel folderModel = new FolderModel(); + folderModel.setNodeRef(siteModel.getGuid()); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(folderModel).rateStarsToDocument(5); + restClient.withCoreAPI().usingResource(folderModel).deleteFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + returnedRatingModel = restClient.withCoreAPI().usingResource(folderModel).rateStarsToDocument(5); + + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Verify user with Manager role is able to remove one star rating of a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void removeOneStarRating() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + restClient.withCoreAPI().usingResource(document).rateStarsToDocument(1); + + restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + returnedRatingModelCollection = restClient.withCoreAPI().usingResource(document).getRatings(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedRatingModelCollection.assertNodeIsNotLiked().assertNodeHasNoFiveStarRating().and().entriesListIsNotEmpty().and().paginationExist(); + } +} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/rest/ratings/GetRatingTests.java b/e2e-test/src/test/java/org/alfresco/rest/ratings/GetRatingTests.java new file mode 100644 index 000000000..9cb42f8f7 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/ratings/GetRatingTests.java @@ -0,0 +1,438 @@ +package org.alfresco.rest.ratings; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestRatingModel; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.exception.DataPreparationException; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.apache.commons.lang3.RandomStringUtils; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +public class GetRatingTests extends RestTest +{ + private SiteModel siteModel; + private UserModel adminUser, userModel, managerUser; + private FileModel document; + private ListUserWithRoles usersWithRoles; + private RestRatingModel restRatingModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws DataPreparationException + { + adminUser = dataUser.getAdminUser(); + userModel = dataUser.createRandomTestUser(); + managerUser = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); + + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + + dataUser.addUserToSite(managerUser, siteModel, UserRole.SiteManager); + } + + @BeforeMethod(alwaysRun = true) + public void setUp() throws Exception + { + document = dataContent.usingSite(siteModel).usingAdmin().createContent(DocumentType.TEXT_PLAIN); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.SANITY, description = "Verify user with Manager role is able to retrieve rating of a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) + public void managerIsAbleToRetrieveRating() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + + restClient.withCoreAPI().usingResource(document).likeDocument(); + restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); + + restRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); + + restRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").is("5"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Verify user with Collaborator role is able to retrieve rating of a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void collaboratorIsAbleToRetrieveRating() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + + restClient.withCoreAPI().usingResource(document).likeDocument(); + restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); + + restRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); + + restRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").is("5"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Verify user with Contributor role is able to retrieve rating of a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void contributorIsAbleToRetrieveRating() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + + restClient.withCoreAPI().usingResource(document).likeDocument(); + restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); + + restRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); + + restRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").is("5"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Verify user with Consumer role is able to retrieve rating of a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void consumerIsAbleToRetrieveRating() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + + restClient.withCoreAPI().usingResource(document).likeDocument(); + restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); + + restRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); + + restRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").is("5"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Verify admin user is able to retrieve rating of a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void adminIsAbleToRetrieveRating() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + FileModel document = dataContent.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingResource(folderModel) + .createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(adminUser); + restClient.withCoreAPI().usingResource(document).likeDocument(); + restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); + + restRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); + + restRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").is("5"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to retrieve rating of a document") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) +// @Bug(id = "MNT-16904", description = "It fails only on environment with tenants") + public void unauthenticatedUserIsNotAbleToRetrieveRating() throws Exception + { + restClient.authenticateUser(adminUser); + restClient.withCoreAPI().usingResource(document).likeDocument(); + restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); + + restClient.authenticateUser(new UserModel("random user", "random password")); + + restClient.withCoreAPI().usingResource(document).getLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + + restClient.withCoreAPI().usingResource(document).getFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Check that using invalid ratingId for get rating call returns status code 400.") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void checkInvalidRatingIdStatusCode() throws Exception + { + restClient.authenticateUser(adminUser).withCoreAPI(); + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "nodes/{nodeId}/ratings/{ratingId}", document.getNodeRef(), "invalid ratingId"); + restClient.processModel(RestRatingModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.INVALID_RATING, "invalid ratingId")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Check that using invalid node ID for get rating call returns status code 404.") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void getRatingUsingInvalidNodeId() throws Exception + { + document.setNodeRef(RandomStringUtils.randomAlphanumeric(20)); + restRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).getFiveStarRating(); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, document.getNodeRef())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Get rating of a file that has only likes.") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void getRatingOfFileThatHasOnlyLikes() throws Exception + { + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); + + restRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); + restRatingModel.getAggregate().assertThat().field("numberOfRatings").is("1"); + + restRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restRatingModel.getAggregate().assertThat().field("numberOfRatings").is("0"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Get rating of a file that has only stars.") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void getRatingOfFileThatHasOnlyStars() throws Exception + { + restClient.authenticateUser(userModel).withCoreAPI().usingResource(document).rateStarsToDocument(5); + + restRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); + restRatingModel.getAggregate().assertThat().field("numberOfRatings").is("1"); + + restRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restRatingModel.getAggregate().assertThat().field("numberOfRatings").is("0"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Get rating of a file that has likes and stars.") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void getRatingOfFileThatHasLikesAndStars() throws Exception + { + restClient.authenticateUser(userModel).withCoreAPI().usingResource(document).likeDocument(); + restClient.authenticateUser(userModel).withCoreAPI().usingResource(document).rateStarsToDocument(5); + + restRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); + restRatingModel.getAggregate().assertThat().field("numberOfRatings").is("1"); + + restRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); + restRatingModel.getAggregate().assertThat().field("numberOfRatings").is("1"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Get rating of a folder that has only likes.") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void getRatingOfFolderThatHasOnlyLikes() throws Exception + { + FolderModel firstFolderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(firstFolderModel).likeDocument(); + + restRatingModel = restClient.withCoreAPI().usingResource(firstFolderModel).getLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); + restRatingModel.getAggregate().assertThat().field("numberOfRatings").is("1"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Get rating of a file that has no ratings.") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void getRatingOfFileThatHasNoRatings() throws Exception + { + restRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).getLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restRatingModel.getAggregate().assertThat().field("numberOfRatings").is("0"); + + restRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restRatingModel.getAggregate().assertThat().field("numberOfRatings").is("0"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Check default error schema") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void checkDefaultErrorSchema() throws Exception + { + FileModel document = dataContent.usingSite(siteModel).usingAdmin().createContent(DocumentType.TEXT_PLAIN); + String randomNodeRef = RandomStringUtils.randomAlphanumeric(10); + document.setNodeRef(randomNodeRef); + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).getLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, randomNodeRef)) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Get rating of a folder that has only stars") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void getRatingOfFolderThatHasOnlyStars() throws Exception + { + FolderModel folder = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + restClient.authenticateUser(managerUser).withCoreAPI().usingResource(folder).rateStarsToDocument(3); + restRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folder).getFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restRatingModel.assertThat().field("id").is("fiveStar") + .getAggregate().assertThat().field("numberOfRatings").is("1") + .assertThat().field("average").is("3.0"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Get rating of a folder that has both likes and stars") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void getRatingOfFolderThatHasLikedAndStars() throws Exception + { + FolderModel folder = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + restClient.authenticateUser(managerUser).withCoreAPI().usingResource(folder).rateStarsToDocument(3); + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folder).likeDocument(); + + restRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folder).getFiveStarRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restRatingModel.assertThat().field("id").is("fiveStar") + .getAggregate().assertThat().field("numberOfRatings").is("1") + .assertThat().field("average").is("3.0"); + + restRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folder).getLikeRating(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restRatingModel.assertThat().field("id").is("likes") + .assertThat().field("myRating").is("true"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Get rating of a folder that has no ratings") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void getRatingOfFolderThatHasNoRatings() throws Exception + { + FolderModel folder = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + + restRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folder).getFiveStarRating(); + restRatingModel.getAggregate().assertThat().field("numberOfRatings").is("0"); + + restRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folder).getLikeRating(); + restRatingModel.getAggregate().assertThat().field("numberOfRatings").is("0"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Get rating of a folder after rating was deleted") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void getDeletedRatingOfAFolder() throws Exception + { + FolderModel folder = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + restClient.authenticateUser(managerUser).withCoreAPI().usingResource(folder).rateStarsToDocument(3); + restClient.authenticateUser(managerUser).withCoreAPI().usingResource(folder).deleteFiveStarRating(); + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folder).likeDocument(); + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folder).deleteLikeRating(); + + restRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folder).getFiveStarRating(); + restRatingModel.assertThat().field("id").is("fiveStar").getAggregate().assertThat().field("numberOfRatings").is("0") + .assertThat().field("average").isNull(); + + restRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folder).getLikeRating(); + restRatingModel.assertThat().field("id").is("likes").assertThat().field("myRating").isNull() + .getAggregate().assertThat().field("numberOfRatings").is("0"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Get rating of a file after rating was deleted") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void getDeletedRatingOfAFile() throws Exception + { + FileModel file = dataContent.usingUser(adminUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(managerUser).withCoreAPI().usingResource(file).rateStarsToDocument(3); + restClient.authenticateUser(managerUser).withCoreAPI().usingResource(file).deleteFiveStarRating(); + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(file).likeDocument(); + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(file).deleteLikeRating(); + + restRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(file).getFiveStarRating(); + restRatingModel.assertThat().field("id").is("fiveStar").getAggregate().assertThat().field("numberOfRatings").is("0") + .assertThat().field("average").isNull(); + + restRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(file).getLikeRating(); + restRatingModel.assertThat().field("id").is("likes").assertThat().field("myRating").isNull() + .getAggregate().assertThat().field("numberOfRatings").is("0"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Get rating of another user as admin") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void getRatingOfAnotherUserAsAdmin() throws Exception + { + FileModel file = dataContent.usingUser(adminUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(managerUser).withCoreAPI().usingResource(file).rateStarsToDocument(3); + restClient.authenticateUser(managerUser).withCoreAPI().usingResource(file).likeDocument(); + + restRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(file).getFiveStarRating(); + restRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").isNull() + .getAggregate().assertThat().field("numberOfRatings").is("1").assertThat().field("average").is("3.0"); + + restRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(file).getLikeRating(); + restRatingModel.assertThat().field("id").is("likes").assertThat().field("myRating").isNull() + .getAggregate().assertThat().field("numberOfRatings").is("1"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Get rating of admin with another user") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void getRatingOfAdminWithAnotherUser() throws Exception + { + FileModel file = dataContent.usingUser(managerUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(file).rateStarsToDocument(3); + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(file).likeDocument(); + + restRatingModel = restClient.authenticateUser(managerUser).withCoreAPI().usingResource(file).getFiveStarRating(); + restRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").isNull() + .getAggregate().assertThat().field("numberOfRatings").is("1").assertThat().field("average").is("3.0"); + + restRatingModel = restClient.authenticateUser(managerUser).withCoreAPI().usingResource(file).getLikeRating(); + restRatingModel.assertThat().field("id").is("likes").assertThat().field("myRating").isNull() + .getAggregate().assertThat().field("numberOfRatings").is("1"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Get five star rating") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void getFiveStarRating() throws Exception + { + FileModel file = dataContent.usingUser(managerUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(file).rateStarsToDocument(5); + + restRatingModel = restClient.authenticateUser(managerUser).withCoreAPI().usingResource(file).getFiveStarRating(); + restRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").isNull() + .getAggregate().assertThat().field("numberOfRatings").is("1").assertThat().field("average").is("5.0"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Get one star rating") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void getOneStarRating() throws Exception + { + FileModel file = dataContent.usingUser(managerUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(file).rateStarsToDocument(1); + + restRatingModel = restClient.authenticateUser(managerUser).withCoreAPI().usingResource(file).getFiveStarRating(); + restRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").isNull() + .getAggregate().assertThat().field("numberOfRatings").is("1").assertThat().field("average").is("1.0"); + } +} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/rest/ratings/GetRatingsTests.java b/e2e-test/src/test/java/org/alfresco/rest/ratings/GetRatingsTests.java new file mode 100644 index 000000000..ca4469a85 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/ratings/GetRatingsTests.java @@ -0,0 +1,313 @@ +package org.alfresco.rest.ratings; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestRatingModelsCollection; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.exception.DataPreparationException; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.apache.commons.lang3.RandomStringUtils; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class GetRatingsTests extends RestTest +{ + private SiteModel siteModel; + private UserModel adminUser, userModel; + private ListUserWithRoles usersWithRoles; + private RestRatingModelsCollection restRatingModelsCollection; + private FileModel document; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws DataPreparationException + { + adminUser = dataUser.getAdminUser(); + userModel = dataUser.createRandomTestUser(); + + siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); + + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.SANITY, description = "Manager is able to retrieve document ratings") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) + public void managerIsAbleToRetrieveDocumentRatings() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + + restClient.withCoreAPI().usingResource(document).likeDocument(); + restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); + + restRatingModelsCollection = restClient.withCoreAPI().usingResource(document).getRatings(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restRatingModelsCollection.assertNodeHasFiveStarRating().assertNodeIsLiked(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Collaborator is able to retrieve document ratings") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void collaboratorIsAbleToRetrieveDocumentRatings() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + + restClient.withCoreAPI().usingResource(document).likeDocument(); + restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); + + restRatingModelsCollection = restClient.withCoreAPI().usingResource(document).getRatings(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restRatingModelsCollection.assertNodeHasFiveStarRating().assertNodeIsLiked(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Contributor is able to retrieve document ratings") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void contributorIsAbleToRetrieveDocumentRatings() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + + restClient.withCoreAPI().usingResource(document).likeDocument(); + restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); + + restRatingModelsCollection = restClient.withCoreAPI().usingResource(document).getRatings(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restRatingModelsCollection.assertNodeHasFiveStarRating().assertNodeIsLiked(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Consumer is able to retrieve document ratings") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void consumerIsAbleToRetrieveDocumentRatings() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + + restClient.withCoreAPI().usingResource(document).likeDocument(); + restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); + + restRatingModelsCollection = restClient.withCoreAPI().usingResource(document).getRatings(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restRatingModelsCollection.assertNodeHasFiveStarRating().assertNodeIsLiked(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.REGRESSION, description = "Admin user is able to retrieve document ratings") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void adminIsAbleToRetrieveDocumentRatings() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + document = dataContent.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingResource(folderModel) + .createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(adminUser); + restClient.withCoreAPI().usingResource(document).likeDocument(); + restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); + + restRatingModelsCollection = restClient.withCoreAPI().usingResource(document).getRatings(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restRatingModelsCollection.assertNodeHasFiveStarRating().assertNodeIsLiked(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, + executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to retrieve document ratings") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) +// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") + public void unauthenticatedUserIsNotAbleToRetrieveRatings() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); + document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(adminUser); + restClient.withCoreAPI().usingResource(document).likeDocument(); + restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); + + restClient.authenticateUser(new UserModel("random user", "random password")); + + restClient.withCoreAPI().usingResource(document).getRatings(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Check that rating for invalid maxItems status code is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void checkInvalidMaxItemsStatusCode() throws Exception + { + document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); + restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).rateStarsToDocument(5); + restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).likeDocument(); + + restClient.authenticateUser(adminUser).withParams("maxItems=0").withCoreAPI().usingResource(document).getRatings(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Only positive values supported for maxItems"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Check that rating for invalid skipCount status code is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void checkInvalidSkipCountStatusCode() throws Exception + { + document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); + restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).rateStarsToDocument(5); + restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).likeDocument(); + + restClient.authenticateUser(adminUser).withParams("skipCount=AB").withCoreAPI().usingResource(document).getRatings(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Invalid paging parameter skipCount:AB"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "If nodeId does not exist status code is 404 when a document is liked") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void addLikeUsingInvalidNodeId() throws Exception + { + document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); + restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).rateStarsToDocument(5); + restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).likeDocument(); + document.setNodeRef(RandomStringUtils.randomAlphanumeric(20)); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).getRatings(); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, document.getNodeRef())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Check that rating value is TRUE for a like rating") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void checkRatingValueIsTrueForLikedDoc() throws Exception + { + document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); + restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).rateStarsToDocument(5); + restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).likeDocument(); + + restRatingModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingResource(document).getRatings(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + restRatingModelsCollection.assertThat().entriesListContains("myRating", "true") + .assertThat().entriesListContains("id", "likes"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Check that rating value is an INTEGER value for stars rating") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void checkRatingValueIsIntegerForStarsRating() throws Exception + { + document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); + restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).rateStarsToDocument(5); + restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).likeDocument(); + + restRatingModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingResource(document).getRatings(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + restRatingModelsCollection.assertThat().entriesListContains("myRating", "5") + .assertThat().entriesListContains("id", "fiveStar"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Check default error schema in case of failure") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void checkDefaultErrorSchema() throws Exception + { + FileModel document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); + document.setNodeRef("abc"); + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).getRatings(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "abc")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Check maxItems and skipCount parameters") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void checkMaxItemsAndSkipCountParameters() throws Exception + { + document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); + restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).rateStarsToDocument(5); + restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).likeDocument(); + + restRatingModelsCollection = restClient.authenticateUser(adminUser).withParams("maxItems=1", "skipCount=1").withCoreAPI().usingResource(document).getRatings(); + restRatingModelsCollection.assertThat().entriesListCountIs(1); + restRatingModelsCollection.getPagination().assertThat().field("maxItems").is("1") + .and().field("skipCount").is("1"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Check totalItems and hasMoreitems parameters") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void checkTotalItemsAndHasMoreItemsParameters() throws Exception + { + document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); + restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).rateStarsToDocument(5); + restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).likeDocument(); + + restRatingModelsCollection = restClient.authenticateUser(adminUser).withParams("maxItems=1").withCoreAPI().usingResource(document).getRatings(); + restRatingModelsCollection.assertThat().entriesListCountIs(1); + restRatingModelsCollection.getPagination().assertThat().field("hasMoreItems").is("true") + .and().field("count").is("1").and().field("maxItems").is("1"); + } + + @Bug(id = "REPO-1831") + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Get ratings for a document to which authenticated user does not have access") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void userIsNotAbleToGetRatingsOfDocumentToWhichItHasNoAccess() throws Exception + { + SiteModel privateSite = dataSite.usingAdmin().createPrivateRandomSite(); + FileModel file = dataContent.usingSite(privateSite).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); + restRatingModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingResource(file).getRatings(); + restRatingModelsCollection.assertThat().entriesListIsEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Check high value for skipCount parameter") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void getRatingsUsingHighValueForSkipCount() throws Exception + { + document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); + restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).rateStarsToDocument(5); + restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).likeDocument(); + + restRatingModelsCollection = restClient.authenticateUser(adminUser).withParams("skipCount=100").withCoreAPI().usingResource(document).getRatings(); + restRatingModelsCollection.getPagination().assertThat().field("skipCount").is("100"); + restRatingModelsCollection.assertThat().entriesListIsEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Get ratings using site id instead of node id") + @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) + public void getRatingsUsingSiteId() throws Exception + { + FileModel document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); + document.setNodeRef(siteModel.getId()); + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).getRatings(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, siteModel.getId())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } +} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/rest/renditions/AvailableRenditionTests.java b/e2e-test/src/test/java/org/alfresco/rest/renditions/AvailableRenditionTests.java new file mode 100644 index 000000000..70f1d79d5 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/renditions/AvailableRenditionTests.java @@ -0,0 +1,134 @@ +package org.alfresco.rest.renditions; + +import org.alfresco.rest.model.RestNodeModel; +import org.alfresco.rest.model.RestRenditionInfoModel; +import org.alfresco.rest.model.RestRenditionInfoModelCollection; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +import java.util.Arrays; +import java.util.Collections; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + +/** + * + * Sanity check for renditions through REST API.
      + * Tests upload files and then request renditions for those files.
      + * Renditions are requested based on supported renditions according to GET '/nodes/{nodeId}/renditions'.
      + */ +@Test(groups = {TestGroup.REQUIRE_TRANSFORMATION, TestGroup.RENDITIONS_REGRESSION}) +public class AvailableRenditionTests extends RenditionIntegrationTests +{ + /** List of parameters used as an input to supportedRenditionTest - fileName, nodeId, renditionId, expectedMimeType **/ + private List renditionsToTest; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + super.dataPreparation(); + + // Upload files and get available renditions for each file + List toTest = Arrays.asList("doc", "xls", "ppt", "docx", "xlsx", "pptx", "msg", "pdf", "png", "gif", "jpg"); + List renditionsForFiles = new LinkedList<>(); + for (String extensions : toTest) + { + String sourceFile = "quick/quick." + extensions; + renditionsForFiles.addAll(uploadFileAndGetAvailableRenditions(sourceFile)); + } + + renditionsToTest = Collections.unmodifiableList(renditionsForFiles); + } + + /** + * Upload a source file and get all supported renditions for it. + */ + private List uploadFileAndGetAvailableRenditions(String sourceFile) throws Exception + { + + // Create folder & upload file + RestNodeModel fileNode = uploadFile(sourceFile); + FileModel file = new FileModel(); + file.setNodeRef(fileNode.getId()); + + List renditionsForFile = new LinkedList<>(); + + // Get supported renditions + RestRenditionInfoModelCollection renditionsInfo = restClient.withCoreAPI().usingNode(file).getNodeRenditionsInfo(); + for (RestRenditionInfoModel m : renditionsInfo.getEntries()) + { + RestRenditionInfoModel renditionInfo = m.onModel(); + String renditionId = renditionInfo.getId(); + String targetMimeType = renditionInfo.getContent().getMimeType(); + + renditionsForFile.add(new Object[]{sourceFile, fileNode.getId(), renditionId, targetMimeType}); + + } + + return renditionsForFile; + } + + /** + * Check that a particular rendition can be created for the file and that it has the expected Mime type + */ + @Test(dataProvider = "RenditionTestDataProvider", groups = {TestGroup.REST_API, TestGroup.RENDITIONS, TestGroup.SANITY}) + @TestRail(section = { TestGroup.REST_API, TestGroup.RENDITIONS }, executionType = ExecutionType.SANITY, + description = "Verify renditions created for a selection of test files via POST nodes/{nodeId}/renditions") + public void supportedRenditionTest(String fileName, String nodeId, String renditionId, String expectedMimeType) throws Exception + { + checkRendition(fileName, nodeId, renditionId, expectedMimeType); + } + + @DataProvider(name = "RenditionTestDataProvider") + protected Iterator renditionTestDataProvider() throws Exception + { + return renditionsToTest.iterator(); + } + + @Test(groups = {TestGroup.REST_API, TestGroup.RENDITIONS, TestGroup.SANITY}) + @TestRail(section = { TestGroup.REST_API, TestGroup.RENDITIONS }, executionType = ExecutionType.SANITY, + description = "Verify that there are some available renditions.") + public void renditionsAvailableTest() + { + Assert.assertFalse(renditionsToTest.isEmpty(), "No available renditions were reported for any of the test files."); + } + + @Test(dataProvider = "UnsupportedRenditionTestDataProvider",groups = {TestGroup.REST_API, TestGroup.RENDITIONS, TestGroup.SANITY}) + @TestRail(section = { TestGroup.REST_API, TestGroup.RENDITIONS }, executionType = ExecutionType.SANITY, + description = "Verify that requests for unsupported renditions return 400 ") + public void unsupportedRenditionTest(String sourceFile, String renditionId) throws Exception + { + RestNodeModel fileNode = uploadFile(sourceFile); + + // 2. Request rendition of the file using RESTAPI + FileModel file = new FileModel(sourceFile); + file.setNodeRef(fileNode.getId()); + restClient.withCoreAPI().usingNode(file).createNodeRendition(renditionId); + + Assert.assertEquals(restClient.getStatusCode(), HttpStatus.BAD_REQUEST.toString(), + "Expected to see the rendition rejected. [" + sourceFile + ", " + renditionId + "] [source file, rendition ID] "); + } + + @DataProvider(name = "UnsupportedRenditionTestDataProvider") + protected Iterator unsupportedRenditionTestDataProvider() throws Exception + { + String renditionId = "pdf"; + + List toTest = new LinkedList<>(); + toTest.add(new Object[]{"quick/quick.png", renditionId}); + toTest.add(new Object[]{"quick/quick.gif", renditionId}); + toTest.add(new Object[]{"quick/quick.jpg", renditionId}); + toTest.add(new Object[]{"quick/quick.pdf", renditionId}); + + return toTest.iterator(); + } +} + diff --git a/e2e-test/src/test/java/org/alfresco/rest/renditions/CreateRenditionTests.java b/e2e-test/src/test/java/org/alfresco/rest/renditions/CreateRenditionTests.java new file mode 100644 index 000000000..4c8964aee --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/renditions/CreateRenditionTests.java @@ -0,0 +1,101 @@ +package org.alfresco.rest.renditions; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestNodeModel; +import org.alfresco.utility.Utility; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.report.Bug.Status; +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.BeforeMethod; +import org.testng.annotations.Test; + +/** + * Handles tests related to POST api-explorer/#!/renditions + * @author Cristina Axinte + * + */ +@Test(groups = {TestGroup.REQUIRE_TRANSFORMATION}) +public class CreateRenditionTests extends RestTest +{ + private UserModel adminUser, user; + private SiteModel site; + private FileModel document; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + user = dataUser.createRandomTestUser(); + site = dataSite.usingUser(user).createPublicRandomSite(); + } + + @BeforeMethod(alwaysRun = true) + public void createDocument() throws Exception + { + document = dataContent.usingUser(user).usingSite(site).createContent(DocumentType.TEXT_PLAIN); + } + + @Bug(id = "REPO-2042", description = "Should fail only on MAC OS System and Linux", status = Status.FIXED ) + @TestRail(section = { TestGroup.REST_API, TestGroup.RENDITIONS }, executionType = ExecutionType.SANITY, + description = "Verify admin user creates rendition with Rest API and status code is 202") + @Test(groups = { TestGroup.REST_API, TestGroup.RENDITIONS, TestGroup.SANITY }) + public void adminCanCreateRenditionToExistingNode() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUser).withCoreAPI().usingNode(document).createNodeRendition("pdf"); + restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); + + restClient.withCoreAPI().usingNode(document).getNodeRenditionUntilIsCreated("pdf") + .assertThat().field("status").is("CREATED"); + } + + @Bug(id = "REPO-2042", description = "Should fail only on MAC OS System and Linux", status = Status.FIXED ) + @TestRail(section = { TestGroup.REST_API, TestGroup.RENDITIONS }, executionType = ExecutionType.REGRESSION, + description = "Verify user that created the document can also creates 'pdf' rendition for it with Rest API and status code is 202") + @Test(groups = { TestGroup.REST_API, TestGroup.RENDITIONS, TestGroup.REGRESSION }) + public void userThatCreatedFileCanCreatePdfRenditionForIt() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(user).withCoreAPI().usingNode(document).createNodeRendition("pdf"); + restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); + + restClient.withCoreAPI().usingNode(document).getNodeRenditionUntilIsCreated("pdf") + .assertThat().field("status").is("CREATED"); + } + + @Bug(id = "REPO-2042", description = "Should fail only on MAC OS System and Linux", status = Status.FIXED ) + @TestRail(section = { TestGroup.REST_API, TestGroup.RENDITIONS }, executionType = ExecutionType.REGRESSION, + description = "Verify user that created the document can also creates 'doclib' rendition for it with Rest API and status code is 202") + @Test(groups = { TestGroup.REST_API, TestGroup.RENDITIONS, TestGroup.REGRESSION }) + public void userThatCreatedFileCanCreateDoclibRenditionForIt() throws JsonToModelConversionException, Exception + { + FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder(); + restClient.authenticateUser(user) + .configureRequestSpec() + .addMultiPart("filedata", Utility.getResourceTestDataFile("my-file.tif")); + + RestNodeModel fileNode = restClient.authenticateUser(user).withCoreAPI().usingResource(folder).createNode(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + document = new FileModel("my-file.tif"); + document.setCmisLocation(folder.getCmisLocation() + "/my-file.tif"); + document.setNodeRef(fileNode.getId()); + + restClient.authenticateUser(user).withCoreAPI().usingNode(document).createNodeRendition("doclib"); + restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); + + // Renditions are async + Utility.sleep(500, 60000, () -> + { + restClient.withCoreAPI().usingNode(document).getNodeRenditionUntilIsCreated("doclib") + .assertThat().field("status").is("CREATED"); + }); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/renditions/GetRenditionTests.java b/e2e-test/src/test/java/org/alfresco/rest/renditions/GetRenditionTests.java new file mode 100644 index 000000000..bbeda974c --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/renditions/GetRenditionTests.java @@ -0,0 +1,157 @@ +package org.alfresco.rest.renditions; + +import static org.alfresco.utility.report.log.Step.STEP; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.RestResponse; +import org.alfresco.rest.model.RestNodeModel; +import org.alfresco.rest.model.RestRenditionInfoModel; +import org.alfresco.utility.Utility; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.report.Bug.Status; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Handles tests related to GET api-explorer/#!/renditions + * @author Cristina Axinte + * + */ +@Test(groups = {TestGroup.REQUIRE_TRANSFORMATION}) +public class GetRenditionTests extends RestTest +{ + private UserModel user; + private SiteModel site; + private FileModel file1; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + user = dataUser.createRandomTestUser(); + site = dataSite.usingUser(user).createPublicRandomSite(); + file1 = dataContent.usingUser(user).usingSite(site).createContent(DocumentType.TEXT_PLAIN); + } + + @Bug(id = "REPO-2449", status = Status.FIXED) + @Test(groups = { TestGroup.REST_API, TestGroup.RENDITIONS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.RENDITIONS }, executionType = ExecutionType.SANITY, + description = "Verify that ZIP document preview is rendered") + public void verifyPreviewOfZipFile() throws Exception + { + STEP("1. Create a folder in existing site"); + FolderModel folder = FolderModel.getRandomFolderModel(); + folder = dataContent.usingUser(user).usingSite(site).createFolder(folder); + + STEP("2. Upload a local ZIP file using RESTAPI"); + restClient.authenticateUser(user).configureRequestSpec().addMultiPart("filedata", Utility.getResourceTestDataFile("content-zip-test.zip")); + + RestNodeModel fileNode = restClient.authenticateUser(user).withCoreAPI().usingNode(folder).createNode(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + FileModel file = new FileModel("content-zip-test.zip"); + file.setCmisLocation(folder.getCmisLocation() + "/content-zip-test.zip"); + file.setNodeRef(fileNode.getId()); + + STEP("3. Create preview of ZIP file using RESTAPI"); + restClient.withCoreAPI().usingNode(file).createNodeRendition("pdf"); + restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); + + STEP("4. Verify preview of ZIP file is created using RESTAPI"); + RestRenditionInfoModel renditionInfo = restClient.withCoreAPI().usingNode(file).getNodeRenditionUntilIsCreated("pdf"); + restClient.assertStatusCodeIs(HttpStatus.OK); + renditionInfo.assertThat().field("status").is("CREATED"); + } + + @Bug(id = "REPO-2485", status = Status.FIXED) + @Test(groups = { TestGroup.REST_API, TestGroup.RENDITIONS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.RENDITIONS }, executionType = ExecutionType.SANITY, + description = "Verify that ZIP document thumbnail is rendered") + public void verifyThumbnailOfZipFile() throws Exception + { + STEP("1. Create a folder in existing site"); + FolderModel folder = FolderModel.getRandomFolderModel(); + folder = dataContent.usingUser(user).usingSite(site).createFolder(folder); + + STEP("2. Upload a local ZIP file using RESTAPI"); + restClient.authenticateUser(user).configureRequestSpec().addMultiPart("filedata", Utility.getResourceTestDataFile("content-zip-test.zip")); + + RestNodeModel fileNode = restClient.authenticateUser(user).withCoreAPI().usingNode(folder).createNode(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + FileModel file = new FileModel("content-zip-test.zip"); + file.setCmisLocation(folder.getCmisLocation() + "/content-zip-test.zip"); + file.setNodeRef(fileNode.getId()); + + STEP("3. Create thumbnail of ZIP file using RESTAPI"); + restClient.withCoreAPI().usingNode(file).createNodeRendition("doclib"); + restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); + + STEP("4. Verify thumbnail of ZIP file is created and has content using RESTAPI"); + RestRenditionInfoModel renditionInfo = restClient.withCoreAPI().usingNode(file).getNodeRenditionUntilIsCreated("doclib"); + restClient.assertStatusCodeIs(HttpStatus.OK); + renditionInfo.assertThat().field("status").is("CREATED"); + renditionInfo.assertThat().field("content.sizeInBytes").isGreaterThan(120); + } + + /** + * Sanity test for the following endpoint: + * GET /nodes/{nodeId}/renditions/{renditionId}/content + * @throws Exception + */ + @Test(groups = { TestGroup.REST_API, TestGroup.RENDITIONS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.RENDITIONS }, executionType = ExecutionType.SANITY, + description = "Verify that the rendition content can be downloaded using GET /nodes/{nodeId}/renditions/{renditionId}/content") + public void getRenditionContent() throws Exception + { + STEP("1. Create a folder in existing site"); + FolderModel folder = FolderModel.getRandomFolderModel(); + folder = dataContent.usingUser(user).usingSite(site).createFolder(folder); + + STEP("2. Upload a local txt file using RESTAPI"); + restClient.authenticateUser(user).configureRequestSpec().addMultiPart("filedata", Utility.getResourceTestDataFile("iso8859File.txt")); + + RestNodeModel fileNode = restClient.authenticateUser(user).withCoreAPI().usingNode(folder).createNode(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + FileModel file = new FileModel("iso8859File.txt"); + file.setCmisLocation(folder.getCmisLocation() + "/iso8859File.txt"); + file.setNodeRef(fileNode.getId()); + + STEP("3. Create thumbnail of txt file using RESTAPI"); + restClient.withCoreAPI().usingNode(file).createNodeRendition("doclib"); + restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); + + STEP("4. Verify thumbnail of txt file is created and has content using RESTAPI"); + RestResponse restResponse = restClient.withCoreAPI().usingNode(file).getNodeRenditionContentUntilIsCreated("doclib"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.assertHeaderValueContains("Content-Type","image/png;charset=UTF-8"); + Assert.assertTrue(restResponse.getResponse().body().asInputStream().available() > 0); + } + + @Test(groups = {TestGroup.REST_API, TestGroup.RENDITIONS, TestGroup.SANITY}) + @TestRail(section = {TestGroup.REST_API, TestGroup.RENDITIONS}, executionType = ExecutionType.SANITY, + description = "Verify the Range request header using GET /nodes/{nodeId}/renditions/{renditionId}/content") + public void getVerifyRangeRequestHeader() throws Exception + { + STEP("1. Create thumbnail on file"); + restClient.authenticateUser(user).withCoreAPI().usingNode(file1).createNodeRendition("pdf"); + restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); + + STEP("2. Make GET rendition content using content-range header"); + Utility.sleep(1000, 30000, () -> { + restClient.configureRequestSpec().addHeader("content-range", "bytes=1-10"); + restClient.authenticateUser(user).withCoreAPI().usingNode(file1).getNodeRenditionContent("pdf"); + restClient.assertStatusCodeIs(HttpStatus.PARTIAL_CONTENT); + restClient.assertHeaderValueContains("content-range", "bytes 1-10"); + restClient.assertHeaderValueContains("content-length", String.valueOf(10)); + }); + } +} + diff --git a/e2e-test/src/test/java/org/alfresco/rest/renditions/RenditionIntegrationTests.java b/e2e-test/src/test/java/org/alfresco/rest/renditions/RenditionIntegrationTests.java new file mode 100644 index 000000000..2423613ca --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/renditions/RenditionIntegrationTests.java @@ -0,0 +1,81 @@ +package org.alfresco.rest.renditions; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.RestResponse; +import org.alfresco.rest.model.RestNodeModel; +import org.alfresco.utility.Utility; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; + +import org.alfresco.utility.model.UserModel; + +import org.springframework.http.HttpStatus; +import org.testng.Assert; +import org.testng.annotations.BeforeClass; + +public abstract class RenditionIntegrationTests extends RestTest +{ + + protected UserModel user; + protected SiteModel site; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + user = dataUser.createRandomTestUser(); + site = dataSite.usingUser(user).createPublicRandomSite(); + } + + /** + * Check that a rendition can be created for the specified node id + * @param fileName + * @param nodeId + * @param renditionId + * @param expectedMimeType + * @throws Exception + */ + protected void checkRendition(String fileName, String nodeId, String renditionId, String expectedMimeType) throws Exception + { + FileModel file = new FileModel(); + file.setNodeRef(nodeId); + + // 1. Create a rendition of the file using RESTAPI + restClient.withCoreAPI().usingNode(file).createNodeRendition(renditionId); + Assert.assertEquals(restClient.getStatusCode(), HttpStatus.ACCEPTED.toString(), + "Failed to submit a request for rendition. [" + fileName+ ", " + renditionId+"] [source file, rendition ID]. "); + + // 2. Verify that a rendition of the file is created and has content using RESTAPI + RestResponse restResponse = restClient.withCoreAPI().usingNode(file).getNodeRenditionContentUntilIsCreated(renditionId); + Assert.assertEquals(restClient.getStatusCode(), HttpStatus.OK.toString(), + "Failed to produce rendition. [" + fileName+ ", " + renditionId+"] [source file, rendition ID] "); + + // 3. Check the returned content type + Assert.assertEquals(restClient.getResponseHeaders().getValue("Content-Type"), expectedMimeType+";charset=UTF-8", + "Rendition was created but it has the wrong Content-Type. [" + fileName+ ", " + renditionId + "] [source file, rendition ID]"); + + + Assert.assertTrue((restResponse.getResponse().body().asInputStream().available() > 0), + "Rendition was created but its content is empty. [" + fileName+ ", " + renditionId+"] [source file, rendition ID] "); + } + + /** + * Upload a file and return its node id + * @param sourceFile + * @return + * @throws Exception + */ + protected RestNodeModel uploadFile(String sourceFile) throws Exception + { + FolderModel folder = FolderModel.getRandomFolderModel(); + folder = dataContent.usingUser(user).usingSite(site).createFolder(folder); + restClient.authenticateUser(user).configureRequestSpec() + .addMultiPart("filedata", Utility.getResourceTestDataFile(sourceFile)); + RestNodeModel fileNode = restClient.authenticateUser(user).withCoreAPI().usingNode(folder).createNode(); + + Assert.assertEquals(restClient.getStatusCode(), HttpStatus.CREATED.toString(), + "Failed to created a node for rendition tests using file " + sourceFile); + + return fileNode; + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/search/AbstractSearchTest.java b/e2e-test/src/test/java/org/alfresco/rest/search/AbstractSearchTest.java new file mode 100644 index 000000000..8ec3643ae --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/search/AbstractSearchTest.java @@ -0,0 +1,267 @@ +/* + * Copyright (C) 2018 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.rest.search; + +import org.alfresco.dataprep.SiteService.Visibility; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.RestResponse; +import org.alfresco.utility.Utility; +import org.alfresco.utility.data.RandomData; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FileType; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; + +import javax.naming.AuthenticationException; + +/** + * Abstract Search test class that contains useful methods + * such as: + *
        + *
      • Preparing the data to index. + *
      • Preparing search requests. + * + * @author Michael Suzuki + * @author Meenal Bhave + * + */ +public class AbstractSearchTest extends RestTest +{ + + protected static final String SEARCH_DATA_SAMPLE_FOLDER = "FolderSearch"; + protected UserModel userModel, adminUserModel; + protected SiteModel siteModel; + protected UserModel searchedUser; + protected FileModel file, file2, file3, file4; + + protected static String unique_searchString; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + userModel = dataUser.createRandomTestUser("UserSearch"); + + siteModel = new SiteModel(RandomData.getRandomName("SiteSearch")); + siteModel.setVisibility(Visibility.PRIVATE); + + siteModel = dataSite.usingUser(userModel).createSite(siteModel); + + unique_searchString = siteModel.getTitle().replace("SiteSearch", "Unique"); + + /* + * Create the following file structure for preconditions : + * |- folder + * |-- pangram.txt + * |-- cars.txt + * |-- alfresco.txt + * |-- + */ + + FolderModel folder = new FolderModel(SEARCH_DATA_SAMPLE_FOLDER); + dataContent.usingUser(userModel).usingSite(siteModel).createFolder(folder); + + //Create files + String title = "Title: " + unique_searchString; + String description = "Description: File is created for search tests by Author: " + unique_searchString + " . "; + + file = new FileModel("pangram.txt", "pangram" + title, description, FileType.TEXT_PLAIN, description + " The quick brown fox jumps over the lazy dog"); + + file2 = new FileModel("cars.txt", "cars" + title, description, FileType.TEXT_PLAIN, "The landrover discovery is not a sports car "); + + file3 = new FileModel("alfresco.txt", "alfresco", "alfresco", FileType.TEXT_PLAIN, "Alfresco text file for search "); + + file4 = new FileModel(unique_searchString + ".txt", "uniquee" + title, description, FileType.TEXT_PLAIN, "Unique text file for search "); + + dataContent.usingUser(userModel).usingSite(siteModel).usingResource(folder).createContent(file); + dataContent.usingUser(userModel).usingSite(siteModel).usingResource(folder).createContent(file2); + dataContent.usingUser(userModel).usingSite(siteModel).usingResource(folder).createContent(file3); + dataContent.usingUser(userModel).usingSite(siteModel).usingResource(folder).createContent(file4); + + waitForMetadataIndexing(file4.getName(), true); + } + + /** + * Helper method which create an http post request to Search API end point. + * @param term String search term + * @return {@link SearchResponse} response. + * @throws Exception if error + * + */ + protected SearchResponse query(String term) throws Exception + { + RestRequestQueryModel queryReq = new RestRequestQueryModel(); + queryReq.setLanguage("afts"); + queryReq.setQuery(term); + SearchRequest query = new SearchRequest(queryReq); + return restClient.authenticateUser(userModel).withSearchAPI().search(query); + } + /** + * Helper method which create an http post request to Search API end point. + * @param term String search term + * @return {@link SearchResponse} response. + * @throws Exception if error + * + */ + protected SearchResponse query(RestRequestQueryModel queryReq,RestRequestHighlightModel highlight) throws Exception + { + SearchRequest query = new SearchRequest(queryReq); + query.setHighlight(highlight); + return restClient.authenticateUser(userModel).withSearchAPI().search(query); + } + /** + * + * Helper method which create an http post request to Search API end point. + * Executes the given search request without throwing checked exceptions (a {@link RuntimeException} will be thrown in case). + * @param query the search request. + * @return {@link SearchResponse} response. + * + */ + protected SearchResponse query(SearchRequest query) throws Exception + { + try + { + return restClient.authenticateUser(userModel).withSearchAPI().search(query); + } + catch (final Exception exception) + { + throw new RuntimeException(exception); + } + } + + /** + * Executes an SQL Query using "solr" as output format. + * + * @param sql the SQL statement. + */ + protected RestResponse executeSqlAsSolr(String sql) throws Exception + { + SearchSqlRequest sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql(sql); + sqlRequest.setFormat("solr"); + return searchSql(sqlRequest); + } + + protected SearchRequest createQuery(String term) + { + SearchRequest query = new SearchRequest(); + RestRequestQueryModel queryReq = new RestRequestQueryModel(); + queryReq.setQuery(term); + query.setQuery(queryReq); + return query; + } + + protected SearchRequest carsQuery() + { + return createQuery("cars"); + } + + protected RestResponse searchSql(SearchSqlRequest searchSqlRequest) throws Exception + { + return restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(searchSqlRequest); + } + + /** + * Wait for Solr to finish indexing: Indexing has caught up = true if search returns appropriate results + * + * @param userQuery: search query, this can include the fieldname, unique search string will guarantee accurate results + * @param expectedInResults, true if entry is expected in the results set + * @return true (indexing is finished) if search returns appropriate results + * @throws Exception + */ + public boolean waitForIndexing(String userQuery, boolean expectedInResults) throws Exception + { + // Use the search query as is: fieldname(s) may or may not be specified within the userQuery + return waitForIndexing(null, userQuery, expectedInResults); + } + + /** + * waitForIndexing method that matches / waits for filename, metadata to be indexed. + * @param userQuery + * @param expectedInResults + * @return + * @throws Exception + */ + public boolean waitForMetadataIndexing(String userQuery, boolean expectedInResults) throws Exception + { + return waitForIndexing("name", userQuery, expectedInResults); + } + + /** + * waitForIndexing method that matches / waits for content to be indexed, this can take longer than metadata indexing. + * Since Metadata is indexed first, use this method where tests, queries need content to be indexed too. + * @param userQuery + * @param expectedInResults + * @return + * @throws Exception + */ + public boolean waitForContentIndexing(String userQuery, boolean expectedInResults) throws Exception + { + return waitForIndexing("cm:content", userQuery, expectedInResults); + } + + /** + * Wait for Solr to finish indexing: Indexing has caught up = true if search returns appropriate results + * + * @param fieldName: specific field to search for, e.g. name. When specified, the query will become: name:'userQuery' + * @param userQuery: search string, unique search string will guarantee accurate results + * @param expectedInResults, true if entry is expected in the results set + * @return true (indexing is finished) if search returns appropriate results + * @throws Exception + */ + private boolean waitForIndexing(String fieldName, String userQuery, boolean expectedInResults) throws Exception + { + boolean resultAsExpected = false; + String expectedStatusCode = HttpStatus.OK.toString(); + String query = (fieldName == null)? userQuery: String.format("%s:'%s'", fieldName, userQuery); + + // Repeat search until the query results are as expected or Search Retry count is hit + for (int searchCount = 1; searchCount <= 3; searchCount++) + { + SearchRequest searchRequest = createQuery(query); + SearchResponse response = query(searchRequest); + + if (restClient.getStatusCode().matches(expectedStatusCode)) + { + boolean found = !response.getEntries().isEmpty(); + + // Loop again if result is not as expected: To cater for solr lag: eventual consistency + resultAsExpected = (expectedInResults == found); + if (resultAsExpected) + { + break; + } + else + { + // Wait for the solr indexing. + Utility.waitToLoopTime(properties.getSolrWaitTimeInSeconds(), "Wait For Indexing"); + } + } + else + { + throw new AuthenticationException("API returned status code:" + restClient.getStatusCode() + " Expected: " + expectedStatusCode); + } + } + + return resultAsExpected; + } +} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/rest/search/FacetFieldsSearchTest.java b/e2e-test/src/test/java/org/alfresco/rest/search/FacetFieldsSearchTest.java new file mode 100644 index 000000000..190d66112 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/search/FacetFieldsSearchTest.java @@ -0,0 +1,250 @@ +/* + * Copyright (C) 2019 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.rest.search; + +import java.util.ArrayList; +import java.util.List; + +import javax.json.Json; +import javax.json.JsonObject; + +import org.alfresco.dataprep.SiteService.Visibility; +import org.alfresco.utility.data.RandomData; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FileType; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.testng.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Faceted search test with FacetFields + * @author Meenal Bhave + * + */ +public class FacetFieldsSearchTest extends AbstractSearchTest +{ + private UserModel userWithNoAccess, userCanAccessTextFile; + private SiteModel testSite; + private FolderModel testFolder; + private FileModel textFile, htmlFile; + private String fname; + + @BeforeClass(alwaysRun = true) + public void setupEnvironment() throws Exception + { + serverHealth.assertServerIsOnline(); + + fname = unique_searchString + "facet"; + + testSite = new SiteModel(RandomData.getRandomName("SiteSearch")); + testSite.setVisibility(Visibility.PRIVATE); + + testSite = dataSite.usingUser(userModel).createSite(testSite); + + // Create another user who would not have access to the Private Site created by userModel + userWithNoAccess = dataUser.createRandomTestUser("UserSearch2"); + userCanAccessTextFile = dataUser.createRandomTestUser("UserSearch3"); + + // Create a folder and a file as test User + testFolder = new FolderModel(fname); + dataContent.usingUser(userModel).usingSite(testSite).createFolder(testFolder); + + textFile = new FileModel(fname + "-1.txt", fname, fname, FileType.TEXT_PLAIN, fname + " file for search "); + dataContent.usingUser(userModel).usingSite(testSite).createContent(textFile); + + htmlFile = new FileModel(fname + "-2.html", FileType.HTML, fname + " file 2 for search "); + dataContent.usingUser(userModel).usingSite(testSite).createContent(htmlFile); + + // Set Node Permissions to allow access for user for text File + JsonObject userPermission = Json.createObjectBuilder() + .add("permissions", Json.createObjectBuilder().add("isInheritanceEnabled", false) + .add("locallySet",Json.createObjectBuilder().add("authorityId", userCanAccessTextFile.getUsername()) + .add("name", "SiteConsumer").add("accessStatus", "ALLOWED"))) + .build(); + String putBody = userPermission.toString(); + + restClient.authenticateUser(userModel).withCoreAPI().usingNode(textFile).updateNode(putBody); + + // Wait for the file to be indexed + waitForIndexing(htmlFile.getName(), true); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_121 }) + public void testSearchFacetFieldsBucketExcludedWhenMinCount2() throws Exception + { + // Create Query with FacetFields: Site and Content MimeType + SearchRequest query = new SearchRequest(); + RestRequestQueryModel queryReq = new RestRequestQueryModel(); + queryReq.setQuery("name:" + fname); + query.setQuery(queryReq); + + RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); + List facets = new ArrayList(); + + facets.add(new RestRequestFacetFieldModel("SITE", "SEARCH.FACET_FIELDS.SITE", 0)); // MinCount = 0 + facets.add(new RestRequestFacetFieldModel("cm:content.mimetype", "Mimetype", 2)); // MinCount = 2 + + facetFields.setFacets(facets); + query.setFacetFields(facetFields); + + // Search query using user who created site + SearchResponse response = query(query); + + // Expect MimeType bucket with size 1 is excluded as minCount = 2 won't be reached + Assert.assertEquals(response.getContext().getFacetsFields().size(), 1); + + // Expect SITE bucket is included and MinCount defaults to 1 + RestResultBucketsModel facetFieldList = response.getContext().getFacetsFields().get(0); + Assert.assertEquals(facetFieldList.getLabel(), "SEARCH.FACET_FIELDS.SITE"); + Assert.assertEquals(facetFieldList.getBuckets().size(), 1); + + FacetFieldBucket bucket1 = facetFieldList.getBuckets().get(0); + bucket1.assertThat().field("label").is(testSite.getId()); + bucket1.assertThat().field("filterQuery").contains(testSite.getId()); + bucket1.assertThat().field("count").is(3); // One folder and 2 files created above + + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_121 }) + public void testSearchWithFacetFieldsMinCountChecks() throws Exception + { + SearchRequest query = new SearchRequest(); + RestRequestQueryModel queryReq = new RestRequestQueryModel(); + queryReq.setQuery("name:" + fname); + query.setQuery(queryReq); + + RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); + List facets = new ArrayList(); + + // MinCount not set + facets.add(new RestRequestFacetFieldModel("SITE", "SEARCH.FACET_FIELD1.SITE", null)); // MinCount Not set + facets.add(new RestRequestFacetFieldModel("cm:content.mimetype", "SEARCH.FACET_FIELD2.Mimetype", 1)); // MinCount = 1 + + facetFields.setFacets(facets); + query.setFacetFields(facetFields); + + // Search query using user who created site + SearchResponse response = query(query); + + // Expect 2 Facet buckets to be retrieved: MinCount when not set defaults to 1 + List facetFieldBucketsList = response.getContext().getFacetsFields(); + Assert.assertEquals(facetFieldBucketsList.size(), 2, "FacetField"); + + RestResultBucketsModel facetFieldList = facetFieldBucketsList.get(0); + Assert.assertEquals(facetFieldList.getLabel(), "SEARCH.FACET_FIELD1.SITE"); + + FacetFieldBucket bucket1 = facetFieldList.getBuckets().get(0); + bucket1.assertThat().field("label").is(testSite.getId()); + bucket1.assertThat().field("filterQuery").contains(testSite.getId()); + bucket1.assertThat().field("count").is(3); + + // MimeType bucket will be shown with 2 buckets + facetFieldList = facetFieldBucketsList.get(1); + Assert.assertEquals(facetFieldList.getLabel(), "SEARCH.FACET_FIELD2.Mimetype"); + Assert.assertEquals(facetFieldList.getBuckets().size(), 2); + + bucket1 = facetFieldList.getBuckets().get(0); + bucket1.assertThat().field("label").is("text/html"); + bucket1.assertThat().field("filterQuery").contains("text/html"); + bucket1.assertThat().field("count").is(1); + bucket1.assertThat().field("display").is("HTML"); + + bucket1 = facetFieldList.getBuckets().get(1); + bucket1.assertThat().field("label").is("text/plain"); + bucket1.assertThat().field("filterQuery").contains("text/plain"); + bucket1.assertThat().field("count").is(1); + bucket1.assertThat().field("display").is("Plain Text"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_121 }) + public void testSearchWithFacetFieldsNoFacetsWhenNoAccess() throws Exception + { + SearchRequest query = new SearchRequest(); + RestRequestQueryModel queryReq = new RestRequestQueryModel(); + queryReq.setQuery("name:" + fname); + query.setQuery(queryReq); + + RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); + List facets = new ArrayList(); + + facets.add(new RestRequestFacetFieldModel("SITE", "SEARCH.FACET_FIELD1.SITE", null)); // MinCount Not set + facets.add(new RestRequestFacetFieldModel("cm:content.mimetype", "SEARCH.FACET_FIELD2.Mimetype", 1)); // MinCount = 1 + + facetFields.setFacets(facets); + query.setFacetFields(facetFields); + + // Search query using other user + SearchResponse response = restClient.authenticateUser(userWithNoAccess).withSearchAPI().search(query); + + // User has No access to matching content hence no buckets expected + Assert.assertNull(response.getContext().getFacetsFields()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_121 }) + public void testSearchWithFacetFieldsOnlyFacetsWhereAccess() throws Exception + { + SearchRequest query = new SearchRequest(); + RestRequestQueryModel queryReq = new RestRequestQueryModel(); + queryReq.setQuery("name:" + fname); + query.setQuery(queryReq); + + RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); + List facets = new ArrayList(); + + facets.add(new RestRequestFacetFieldModel("SITE", "SEARCH.FACET_FIELD1.SITE", null)); // MinCount Not set + facets.add(new RestRequestFacetFieldModel("cm:content.mimetype", "SEARCH.FACET_FIELD2.Mimetype", 1)); // MinCount = 1 + + facetFields.setFacets(facets); + query.setFacetFields(facetFields); + + // Search query using user that can access 1 text file + SearchResponse response = restClient.authenticateUser(userCanAccessTextFile).withSearchAPI().search(query); + + List facetFieldBucketsList = response.getContext().getFacetsFields(); + Assert.assertEquals(facetFieldBucketsList.size(), 2); + + // Check FacetField 1 + RestResultBucketsModel facetFieldList = facetFieldBucketsList.get(0); + + // User has granular permissions to content within this private site, so expect the Site bucket + Assert.assertEquals(facetFieldList.getLabel(), "SEARCH.FACET_FIELD1.SITE"); + + FacetFieldBucket bucket1 = facetFieldList.getBuckets().get(0); + bucket1.assertThat().field("label").is(testSite.getId()); + bucket1.assertThat().field("filterQuery").contains(testSite.getId()); + bucket1.assertThat().field("count").is(1); + + // Expect MimeType bucket shows only 1 bucket where user has access to content + facetFieldList = facetFieldBucketsList.get(1); + Assert.assertEquals(facetFieldList.getLabel(), "SEARCH.FACET_FIELD2.Mimetype"); + Assert.assertEquals(facetFieldList.getBuckets().size(), 1); + + // User has access to text file alone, so expect bucket for text/plain and not for html content. + bucket1 = facetFieldList.getBuckets().get(0); + bucket1.assertThat().field("label").is("text/plain"); + bucket1.assertThat().field("label").isNot("text/html"); + bucket1.assertThat().field("filterQuery").contains("text/plain"); + bucket1.assertThat().field("count").is(1); + bucket1.assertThat().field("display").is("Plain Text"); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/search/FacetIntervalSearchTest.java b/e2e-test/src/test/java/org/alfresco/rest/search/FacetIntervalSearchTest.java new file mode 100644 index 000000000..ef9f579dd --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/search/FacetIntervalSearchTest.java @@ -0,0 +1,189 @@ +/* + * Copyright (C) 2017 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.rest.search; + +import org.alfresco.rest.model.RestErrorModel; +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.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import java.util.Arrays; + +/** + * Faceted Intervals Search Test + * @author Gethin James + * + */ +public class FacetIntervalSearchTest extends AbstractSearchTest +{ + @BeforeClass(alwaysRun = true) + public void setupEnvironment() throws Exception + { + waitForContentIndexing(file4.getContent(), true); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, + description = "Check facet intervals mandatory fields") + public void checkingFacetsMandatoryErrorMessages()throws Exception + { + SearchRequest query = carsQuery(); + + RestRequestFacetIntervalsModel facetIntervalsModel = new RestRequestFacetIntervalsModel(); + FacetInterval facetInterval = new FacetInterval(null, null, null); + facetIntervalsModel.setIntervals(Arrays.asList(facetInterval)); + query.setFacetIntervals(facetIntervalsModel); + + query(query); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.MANDATORY_PARAM, "facetIntervals intervals field")); + facetInterval.setField("created"); + query(query); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.MANDATORY_COLLECTION, "facetIntervals intervals sets")); + + RestRequestFacetSetModel restFacetSetModel = new RestRequestFacetSetModel(); + restFacetSetModel.setLabel("theRest"); + facetInterval.setSets(Arrays.asList(restFacetSetModel)); + query(query); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.MANDATORY_PARAM, "facetIntervals intervals created sets start")); + + restFacetSetModel.setStart("A"); + query(query); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.MANDATORY_PARAM, "facetIntervals intervals created sets end")); + + restFacetSetModel.setEnd("B"); + RestRequestFacetSetModel duplicate = new RestRequestFacetSetModel(); + facetInterval.setSets(Arrays.asList(restFacetSetModel,duplicate)); + duplicate.setLabel("theRest"); + duplicate.setStart("A"); + duplicate.setEnd("C"); + + query(query); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary("duplicate set interval label [theRest=2]"); + + facetInterval.setSets(Arrays.asList(restFacetSetModel)); + facetInterval.setLabel("thesame"); + FacetInterval duplicateLabel = new FacetInterval("creator", "thesame", Arrays.asList(duplicate)); + facetIntervalsModel.setIntervals(Arrays.asList(facetInterval, duplicateLabel)); + query.setFacetIntervals(facetIntervalsModel); + + query(query); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary("duplicate interval label [thesame=2]"); + + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, + description = "Check basic facet intervals search api") + public void searchWithBasicInterval()throws Exception + { + SearchRequest query = carsQuery(); + + RestRequestFacetIntervalsModel facetIntervalsModel = new RestRequestFacetIntervalsModel(); + RestRequestFacetSetModel restRequestFacetSetModel = new RestRequestFacetSetModel(); + restRequestFacetSetModel.setStart("a"); + restRequestFacetSetModel.setEnd("user"); + restRequestFacetSetModel.setLabel("aUser"); + + RestRequestFacetSetModel restFacetSetModel = new RestRequestFacetSetModel(); + restFacetSetModel.setStart("user"); + restFacetSetModel.setEnd("z"); + restFacetSetModel.setStartInclusive(false); + restFacetSetModel.setLabel("theRest"); + + FacetInterval facetInterval = new FacetInterval("creator", null, Arrays.asList(restRequestFacetSetModel, restFacetSetModel)); + facetIntervalsModel.setIntervals(Arrays.asList(facetInterval)); + query.setFacetIntervals(facetIntervalsModel); + + SearchResponse response = query(query); + response.assertThat().entriesListIsNotEmpty(); + response.getContext().assertThat().field("facets").isNotEmpty(); + RestGenericFacetResponseModel facetResponseModel = response.getContext().getFacets().get(0); + + RestGenericBucketModel bucket = facetResponseModel.getBuckets().get(0); + Assert.assertEquals(facetResponseModel.getBuckets().size(), 2); + bucket.assertThat().field("label").is("aUser"); + bucket.assertThat().field("filterQuery").is("creator:[\"a\" TO \"user\"]"); + bucket.getMetrics().get(0).assertThat().field("type").is("count"); + bucket.getMetrics().get(0).assertThat().field("value").contains("{count="); + + bucket = facetResponseModel.getBuckets().get(1); + + bucket.assertThat().field("label").is("theRest"); + bucket.assertThat().field("filterQuery").is("creator:<\"user\" TO \"z\"]"); + bucket.getMetrics().get(0).assertThat().field("type").is("count"); + bucket.getMetrics().get(0).assertThat().field("value").is("{count=0}"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, + description = "Check date facet intervals search api") + public void searchWithDates() throws Exception + { + SearchRequest query = carsQuery(); + + RestRequestFacetIntervalsModel facetIntervalsModel = new RestRequestFacetIntervalsModel(); + RestRequestFacetSetModel restRequestFacetSetModel = new RestRequestFacetSetModel(); + restRequestFacetSetModel.setStart("*"); + restRequestFacetSetModel.setEnd("2016"); + restRequestFacetSetModel.setEndInclusive(false); + restRequestFacetSetModel.setLabel("Before2016"); + + RestRequestFacetSetModel restFacetSetModel = new RestRequestFacetSetModel(); + restFacetSetModel.setStart("2016"); + restFacetSetModel.setEnd("now"); + restFacetSetModel.setLabel("From2016"); + + FacetInterval facetInterval = new FacetInterval("cm:modified", "modified", Arrays.asList(restRequestFacetSetModel, restFacetSetModel)); + facetIntervalsModel.setIntervals(Arrays.asList(facetInterval)); + query.setFacetIntervals(facetIntervalsModel); + + SearchResponse response = query(query); + response.assertThat().entriesListIsNotEmpty(); + response.getContext().assertThat().field("facets").isNotEmpty(); + RestGenericFacetResponseModel facetResponseModel = response.getContext().getFacets().get(0); + + facetResponseModel.assertThat().field("label").is("modified"); + RestGenericBucketModel bucket = facetResponseModel.getBuckets().get(0); + Assert.assertEquals(facetResponseModel.getBuckets().size(), 2); + + bucket.assertThat().field("label").is("From2016"); + bucket.assertThat().field("filterQuery").is("cm:modified:[\"2016\" TO \"now\"]"); + bucket.getMetrics().get(0).assertThat().field("type").is("count"); + bucket.getMetrics().get(0).assertThat().field("value").contains("{count="); + + + bucket = facetResponseModel.getBuckets().get(1); + + bucket.assertThat().field("label").is("Before2016"); + bucket.assertThat().field("filterQuery").is("cm:modified:[\"*\" TO \"2016\">"); + bucket.getMetrics().get(0).assertThat().field("type").is("count"); + bucket.getMetrics().get(0).assertThat().field("value").is("{count=0}"); + } + +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/search/FacetRangeSearchTest.java b/e2e-test/src/test/java/org/alfresco/rest/search/FacetRangeSearchTest.java new file mode 100644 index 000000000..b3c518445 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/search/FacetRangeSearchTest.java @@ -0,0 +1,342 @@ +/* + * Copyright (C) 2017 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.rest.search; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.Is.is; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestRequestRangesModel; +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.Assert; +import org.testng.annotations.Test; + +/** + * Faceted Range Search Query for numeric range + * { + * "query": { + * "query": "name:A*" + * }, + * "range": { + * "field": "content.size", + * "start": "0", + * "end": "400", + * "gap": "100" + * } + * } + * Date range query: + * { + * "query": { + * "query": "name:A*" + * }, + * "range": { + * "field": "created", + * "start": "2015-09-29T10:45:15.729Z", + * "end": "2016-09-29T10:45:15.729Z", + * "gap": "+100DAY" + * } + * } + * @author Michael Suzuki + * + */ +public class FacetRangeSearchTest extends AbstractSearchTest +{ + + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, + description = "Check facet intervals mandatory fields") + public void checkingFacetsMandatoryErrorMessages()throws Exception + { + SearchRequest query = carsQuery(); + List ranges = new ArrayList(); + RestRequestRangesModel facetRangeModel = new RestRequestRangesModel(); + ranges.add(facetRangeModel); + query.setRanges(ranges); + query(query); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.MANDATORY_PARAM, "field")); + ranges.clear(); + facetRangeModel.setField("content.size"); + ranges.add(facetRangeModel); + query.setRanges(ranges); + + query(query); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.MANDATORY_PARAM, "start")); + facetRangeModel.setStart("0"); + ranges.clear(); + ranges.add(facetRangeModel); + query.setRanges(ranges); + + query(query); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.MANDATORY_PARAM, "end")); + facetRangeModel.setEnd("400"); + query.setRanges(ranges); + ranges.clear(); + ranges.add(facetRangeModel); + + query(query); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.MANDATORY_PARAM, "gap")); + + facetRangeModel.setGap("100"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, + description = "Check basic facet range search api") + public void searchWithRange()throws Exception + { + SearchRequest query = createQuery("A*"); + + RestRequestRangesModel facetRangeModel = new RestRequestRangesModel(); + facetRangeModel.setField("content.size"); + facetRangeModel.setStart("0"); + facetRangeModel.setEnd("500"); + facetRangeModel.setGap("200"); + List ranges = new ArrayList(); + ranges.add(facetRangeModel); + query.setRanges(ranges); + SearchResponse response = query(query); + response.assertThat().entriesListIsNotEmpty(); + response.getContext().assertThat().field("facets").isNotEmpty(); + RestGenericFacetResponseModel facetResponseModel = response.getContext().getFacets().get(0); + + RestGenericBucketModel bucket = facetResponseModel.getBuckets().get(0); + bucket.assertThat().field("label").is("[0 - 200)"); + bucket.assertThat().field("filterQuery").is("content.size:[\"0\" TO \"200\">"); + Map metric = (Map) bucket.getMetrics().get(0).getValue(); + Assert.assertTrue(Integer.valueOf(metric.get("count")) >= 4); + Map info = (Map) bucket.getBucketInfo(); + Assert.assertEquals(info.get("start"),"0"); + Assert.assertEquals(info.get("end"),"200"); + Assert.assertNull(info.get("count")); + Assert.assertEquals(info.get("startInclusive"),"true"); + Assert.assertEquals(info.get("endInclusive"),"false"); + + bucket = facetResponseModel.getBuckets().get(1); + bucket.assertThat().field("label").is("[200 - 400)"); + bucket.assertThat().field("filterQuery").is("content.size:[\"200\" TO \"400\">"); + metric = (Map) bucket.getMetrics().get(0).getValue(); + Integer count = Integer.valueOf(metric.get("count")); + Assert.assertTrue(count >= 4); + info = (Map) bucket.getBucketInfo(); + Assert.assertEquals(info.get("start"),"200"); + Assert.assertEquals(info.get("end"),"400"); + Assert.assertEquals(info.get("startInclusive"),"true"); + Assert.assertEquals(info.get("endInclusive"),"false"); + + bucket = facetResponseModel.getBuckets().get(2); + bucket.assertThat().field("label").is("[400 - 600]"); + bucket.assertThat().field("filterQuery").is("content.size:[\"400\" TO \"600\"]"); + metric = (Map) bucket.getMetrics().get(0).getValue(); + Assert.assertTrue(Integer.valueOf(metric.get("count")) >= 7); + info = (Map) bucket.getBucketInfo(); + Assert.assertEquals(info.get("start"),"400"); + Assert.assertEquals(info.get("end"),"600"); + Assert.assertEquals(info.get("startInclusive"),"true"); + Assert.assertEquals(info.get("endInclusive"),"true"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, + description = "Check date facet intervals search api") + public void searchWithRangeHardend()throws Exception + { + SearchRequest query = createQuery("A*"); + + RestRequestRangesModel facetRangeModel = new RestRequestRangesModel(); + facetRangeModel.setField("content.size"); + facetRangeModel.setStart("0"); + facetRangeModel.setEnd("500"); + facetRangeModel.setGap("200"); + facetRangeModel.setHardend(true); + List ranges = new ArrayList(); + ranges.add(facetRangeModel); + query.setRanges(ranges); + SearchResponse response = query(query); + response.assertThat().entriesListIsNotEmpty(); + response.getContext().assertThat().field("facets").isNotEmpty(); + RestGenericFacetResponseModel facetResponseModel = response.getContext().getFacets().get(0); + + RestGenericBucketModel bucket = facetResponseModel.getBuckets().get(0); + bucket.assertThat().field("label").is("[0 - 200)"); + bucket.assertThat().field("filterQuery").is("content.size:[\"0\" TO \"200\">"); + Map metric = (Map) bucket.getMetrics().get(0).getValue(); + Assert.assertTrue(Integer.valueOf(metric.get("count")) >= 4); + Map info = (Map) bucket.getBucketInfo(); + Assert.assertEquals(info.get("start"),"0"); + Assert.assertEquals(info.get("end"),"200"); + Assert.assertEquals(info.get("startInclusive"),"true"); + Assert.assertEquals(info.get("endInclusive"),"false"); + Assert.assertNull(info.get("count")); + + bucket = facetResponseModel.getBuckets().get(1); + bucket.assertThat().field("label").is("[200 - 400)"); + bucket.assertThat().field("filterQuery").is("content.size:[\"200\" TO \"400\">"); + info = (Map) bucket.getBucketInfo(); + Assert.assertEquals(info.get("start"),"200"); + Assert.assertEquals(info.get("end"),"400"); + metric = (Map) bucket.getMetrics().get(0).getValue(); + Assert.assertTrue(Integer.valueOf(metric.get("count")) >= 4); + Assert.assertNull(info.get("count")); + Assert.assertEquals(info.get("startInclusive"),"true"); + Assert.assertEquals(info.get("endInclusive"),"false"); + + bucket = facetResponseModel.getBuckets().get(2); + bucket.assertThat().field("label").is("[400 - 500]"); + bucket.assertThat().field("filterQuery").is("content.size:[\"400\" TO \"500\"]"); + metric = (Map) bucket.getMetrics().get(0).getValue(); + Assert.assertTrue(Integer.valueOf(metric.get("count")) >= 3); + info = (Map) bucket.getBucketInfo(); + Assert.assertEquals(info.get("start"),"400"); + Assert.assertEquals(info.get("end"),"500"); + Assert.assertNull(info.get("count")); + Assert.assertEquals(info.get("startInclusive"),"true"); + Assert.assertEquals(info.get("endInclusive"),"true"); + } + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_121 }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_121 }, executionType = ExecutionType.REGRESSION, + description = "Check date facet intervals search api") + public void searchDateRange()throws Exception + { + SearchRequest query = createQuery("name:A*"); + + RestRequestRangesModel facetRangeModel = new RestRequestRangesModel(); + facetRangeModel.setField("created"); + facetRangeModel.setStart("2015-09-29T10:45:15.729Z"); + facetRangeModel.setEnd("2016-09-29T10:45:15.729Z"); + facetRangeModel.setGap("+280DAY"); + List ranges = new ArrayList(); + ranges.add(facetRangeModel); + query.setRanges(ranges); + SearchResponse response = query(query); + response.assertThat().entriesListIsNotEmpty(); + response.getContext().assertThat().field("facets").isNotEmpty(); + RestGenericFacetResponseModel facetResponseModel = response.getContext().getFacets().get(0); + + List buckets = facetResponseModel.getBuckets(); + assertThat(buckets.size(),is(1)); + + RestGenericBucketModel bucket = buckets.get(0); + bucket.assertThat().field("label").is("[2015-09-29T10:45:15.729Z - 2017-04-11T10:45:15.729Z]"); + bucket.assertThat().field("filterQuery").is("created:[\"2015-09-29T10:45:15.729Z\" TO \"2017-04-11T10:45:15.729Z\"]"); + bucket.getMetrics().get(0).assertThat().field("value").is("{count=1}"); + Map info = (Map) bucket.getBucketInfo(); + Assert.assertEquals(info.get("start"),"2015-09-29T10:45:15.729Z"); + Assert.assertEquals(info.get("end"),"2017-04-11T10:45:15.729Z"); + Assert.assertNull(info.get("count"),"1"); + Assert.assertEquals(info.get("startInclusive"),"true"); + Assert.assertEquals(info.get("endInclusive"),"true"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, + description = "Check date facet intervals search api") + public void searchDateAndSizeRanges()throws Exception + { + SearchRequest query = createQuery("name:A*"); + List ranges = new ArrayList(); + RestRequestRangesModel facetRangeModel = new RestRequestRangesModel(); + facetRangeModel.setField("created"); + facetRangeModel.setStart("2015-09-29T10:45:15.729Z"); + facetRangeModel.setEnd("2016-09-29T10:45:15.729Z"); + facetRangeModel.setGap("+280DAY"); + ranges.add(facetRangeModel); + RestRequestRangesModel facetCountRangeModel = new RestRequestRangesModel(); + facetCountRangeModel.setField("content.size"); + facetCountRangeModel.setStart("0"); + facetCountRangeModel.setEnd("500"); + facetCountRangeModel.setGap("200"); + ranges.add(facetCountRangeModel); + query.setRanges(ranges); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, + description = "Check basic facet range search api") + public void searchWithRangeAndIncludeUpperBound()throws Exception + { + SearchRequest query = createQuery("A*"); + + RestRequestRangesModel facetRangeModel = new RestRequestRangesModel(); + facetRangeModel.setField("content.size"); + facetRangeModel.setStart("0"); + facetRangeModel.setEnd("500"); + facetRangeModel.setGap("200"); + List include = new ArrayList(); + include.add("upper"); + facetRangeModel.setInclude(include); + List ranges = new ArrayList(); + ranges.add(facetRangeModel); + query.setRanges(ranges); + SearchResponse response = query(query); + response.assertThat().entriesListIsNotEmpty(); + response.getContext().assertThat().field("facets").isNotEmpty(); + RestGenericFacetResponseModel facetResponseModel = response.getContext().getFacets().get(0); + + RestGenericBucketModel bucket = facetResponseModel.getBuckets().get(0); + bucket.assertThat().field("label").is("(0 - 200]"); + bucket.assertThat().field("filterQuery").is("content.size:<\"0\" TO \"200\"]"); + Map metric = (Map) bucket.getMetrics().get(0).getValue(); + Assert.assertTrue(Integer.valueOf(metric.get("count")) >= 4); + Map info = (Map) bucket.getBucketInfo(); + Assert.assertEquals(info.get("start"),"0"); + Assert.assertEquals(info.get("end"),"200"); + Assert.assertNull(info.get("count")); + Assert.assertEquals(info.get("startInclusive"),"false"); + Assert.assertEquals(info.get("endInclusive"),"true"); + + bucket = facetResponseModel.getBuckets().get(1); + bucket.assertThat().field("label").is("(200 - 400]"); + bucket.assertThat().field("filterQuery").is("content.size:<\"200\" TO \"400\"]"); + metric = (Map) bucket.getMetrics().get(0).getValue(); + Integer count = Integer.valueOf(metric.get("count")); + Assert.assertTrue(count >= 4); + info = (Map) bucket.getBucketInfo(); + Assert.assertEquals(info.get("start"),"200"); + Assert.assertEquals(info.get("end"),"400"); + Assert.assertEquals(info.get("startInclusive"),"false"); + Assert.assertEquals(info.get("endInclusive"),"true"); + + bucket = facetResponseModel.getBuckets().get(2); + bucket.assertThat().field("label").is("(400 - 600]"); + bucket.assertThat().field("filterQuery").is("content.size:<\"400\" TO \"600\"]"); + metric = (Map) bucket.getMetrics().get(0).getValue(); + Assert.assertTrue(Integer.valueOf(metric.get("count")) >= 7); + info = (Map) bucket.getBucketInfo(); + Assert.assertEquals(info.get("start"),"400"); + Assert.assertEquals(info.get("end"),"600"); + Assert.assertEquals(info.get("startInclusive"),"false"); + Assert.assertEquals(info.get("endInclusive"),"true"); + } + +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/search/FacetedSearchTest.java b/e2e-test/src/test/java/org/alfresco/rest/search/FacetedSearchTest.java new file mode 100644 index 000000000..4c1d54339 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/search/FacetedSearchTest.java @@ -0,0 +1,322 @@ +/* + * Copyright (C) 2018 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.rest.search; + +import java.util.ArrayList; +import java.util.List; + +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.testng.Assert; +import org.testng.TestException; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Faceted search test. + * @author Michael Suzuki + * + */ +public class FacetedSearchTest extends AbstractSearchTest +{ + + /** + * Perform the below facet query. + * { + * "query": { + * "query": "cars", + * "language": "afts" + * }, + * "facetQueries": [ + * {"query": "content.size:[o TO 102400]", "label": "small"}, + * {"query": "content.size:[102400 TO 1048576]", "label": "medium"}, + * {"query": "content.size:[1048576 TO 16777216]", "label": "large"} + * ], + * "facetFields": {"facets": [{"field": "'content.size'"}]} + * } + * + * Expected response + * {"list": { + * "entries": [... All the results], + * "pagination": { + * "maxItems": 100, + * "hasMoreItems": false, + * "totalItems": 61, + * "count": 61, + * "skipCount": 0 + * }, + * "facetsFields": [ + * { + * "type": "query", + * "label": "foo", + * "buckets": [ + * { + * "label": "small", + * "filterQuery": "content.size:[0 TO 102400]", + * "display": 1 + * }, + * { + * "label": "large", + * "filterQuery": "content.size:[1048576 TO 16777216]", + * "metrics": [ + * { + * "type": "count", + * "value": { + * "count": 0 + * } + * } + * ] + * }, + * }} + * @throws Exception + */ + + @BeforeClass(alwaysRun = true) + public void setupEnvironment() throws Exception + { + waitForContentIndexing(file4.getContent(), true); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) + @TestRail(section = { TestGroup.REST_API, TestGroup.SEARCH, + TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, description = "Checks facet queries for the Search api") + public void searchWithQueryFaceting() throws Exception + { + SearchRequest query = new SearchRequest(); + RestRequestQueryModel queryReq = new RestRequestQueryModel(); + queryReq.setQuery("cars"); + query.setQuery(queryReq); + + List facets = new ArrayList(); + facets.add(new FacetQuery("content.size:[0 TO 102400]", "small")); + facets.add(new FacetQuery("content.size:[102400 TO 1048576]", "medium")); + facets.add(new FacetQuery("content.size:[1048576 TO 16777216]", "large")); + query.setFacetQueries(facets); + RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); + List list = new ArrayList<>(); + list.add(new RestRequestFacetFieldModel("'content.size'")); + facetFields.setFacets(list); + query.setFacetFields(facetFields); + query.setIncludeRequest(true); + + SearchResponse response = query(query); + + response.assertThat().entriesListIsNotEmpty(); + response.getContext().assertThat().field("facetQueries").isNotEmpty(); + + FacetFieldBucket facet = response.getContext().getFacetQueries().get(0); + facet.assertThat().field("label").contains("small").and().field("count").isGreaterThan(0); + facet.assertThat().field("label").contains("small").and().field("filterQuery").is("content.size:[0 TO 102400]"); + response.getContext().getFacetQueries().get(1).assertThat().field("label").contains("large") + .and().field("count").isLessThan(1) + .and().field("filterQuery").is("content.size:[1048576 TO 16777216]"); + response.getContext().getFacetQueries().get(2).assertThat().field("label").contains("medium") + .and().field("count").isLessThan(1) + .and().field("filterQuery").is("content.size:[102400 TO 1048576]"); + //We don't expect to see the FacetFields if group is being used. + Assert.assertNull(response.getContext().getFacetsFields()); + Assert.assertNull(response.getContext().getFacets()); + } + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH , TestGroup.ASS_1}) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH ,TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, + description = "Checks facet queries for the Search api") + /** + * * Perform a group by faceting, below test groups the facet by group name foo. + * { + * "query": { + * "query": "cars", + * "language": "afts" + * }, + * "facetQueries": [ + * {"query": "content.size:[o TO 102400]", "label": "small","group":"foo"}, + * {"query": "content.size:[102400 TO 1048576]", "label": "medium","group":"foo"}, + * {"query": "content.size:[1048576 TO 16777216]", "label": "large","group":"foo"} + * ], + * "facetFields": {"facets": [{"field": "'content.size'"}]} + * } + * + * Expected response + * {"list": { + * "entries": [... All the results], + * "pagination": { + * "maxItems": 100, + * "hasMoreItems": false, + * "totalItems": 61, + * "count": 61, + * "skipCount": 0 + * }, + * "context": { + * "consistency": {"lastTxId": 512}, + * //Added below as part of SEARCH-374 + * "facets": [ + * { "label": "foo", + * "buckets": [ + * { "label": "small", "count": 61, "filterQuery": "content.size:[o TO 102400]"}, + * { "label": "large", "count": 0, "filterQuery": "content.size:[1048576 TO 16777216]"}, + * { "label": "medium", "count": 61, "filterQuery": "content.size:[102400 TO 1048576]"} + * ] + * } + * } + * }} + * + * + * @throws Exception + */ + public void searchQueryFacetingWithGroup() throws Exception + { + SearchRequest query = new SearchRequest(); + RestRequestQueryModel queryReq = new RestRequestQueryModel(); + queryReq.setQuery("cars"); + query.setQuery(queryReq); + + List facets = new ArrayList(); + facets.add(new FacetQuery("content.size:[0 TO 102400]", "small", "foo")); + facets.add(new FacetQuery("content.size:[102400 TO 1048576]", "medium", "foo")); + facets.add(new FacetQuery("content.size:[1048576 TO 16777216]", "large", "foo")); + query.setFacetQueries(facets); + + RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); + List list = new ArrayList<>(); + list.add(new RestRequestFacetFieldModel("'content.size'")); + facetFields.setFacets(list); + query.setFacetFields(facetFields); + + SearchResponse response = query(query); + + // We don't expect to see the FacetQueries if group is being used. + Assert.assertTrue(response.getContext().getFacetQueries() == null); + // Validate the facet field structure is correct. + Assert.assertFalse(response.getContext().getFacets().isEmpty()); + Assert.assertEquals(response.getContext().getFacets().get(0).getLabel(), "foo"); + + RestGenericBucketModel bucket = response.getContext().getFacets().get(0).getBuckets().get(0); + bucket.assertThat().field("label").isNotEmpty(); + Assert.assertEquals(bucket.getMetrics().get(0).getType(), "count"); + Assert.assertNotEquals(bucket.getMetrics().get(0).getValue(), ""); + bucket.assertThat().field("filterQuery").isNotEmpty(); + response.getContext().getFacets().get(0).getBuckets().forEach(action -> { + switch (action.getLabel()) + { + case "small": + Assert.assertEquals(action.getFilterQuery(), "content.size:[0 TO 102400]"); + break; + case "medium": + Assert.assertEquals(action.getFilterQuery(), "content.size:[102400 TO 1048576]"); + break; + case "large": + Assert.assertEquals(action.getFilterQuery(), "content.size:[1048576 TO 16777216]"); + break; + + default: + throw new TestException("Unexpected value returned"); + } + }); + + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH , TestGroup.ASS_1}) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH ,TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, + description = "Checks facet queries for the Search api") + /** + * { + * "query": { + * "query": "*" + * }, + * "facetFields": { + * "facets": [{"field": "cm:mimetype"},{"field": "modifier"}] + * } + * } + */ + public void searchWithFactedFields() throws Exception + { + SearchRequest query = new SearchRequest(); + RestRequestQueryModel queryReq = new RestRequestQueryModel(); + queryReq.setQuery(unique_searchString); + query.setQuery(queryReq); + + RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); + List facets = new ArrayList(); + facets.add(new RestRequestFacetFieldModel("cm:mimetype")); + facets.add(new RestRequestFacetFieldModel("modifier")); + facetFields.setFacets(facets); + query.setFacetFields(facetFields); + + SearchResponse response = query(query); + + Assert.assertFalse(response.getContext().getFacetsFields().isEmpty()); + Assert.assertNull(response.getContext().getFacetQueries()); + Assert.assertNull(response.getContext().getFacets()); + + RestResultBucketsModel model = response.getContext().getFacetsFields().get(0); + Assert.assertEquals(model.getLabel(), "modifier"); + + model.assertThat().field("label").is("modifier"); + FacetFieldBucket bucket1 = model.getBuckets().get(0); + bucket1.assertThat().field("label").is(userModel.getUsername()); + bucket1.assertThat().field("display").is(userModel.getUsername() + " FirstName LN-" + userModel.getUsername()); + bucket1.assertThat().field("filterQuery").is("modifier:\"" + userModel.getUsername() + "\""); + bucket1.assertThat().field("count").is(1); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH , TestGroup.ASS_1}) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH ,TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, + description = "Checks facet queries for the Search api") + /** + * Test that items returned are in the format of generic facets. + * { + * "query": { + * "query": "*" + * }, + * "facetFields": { + * "facets": [{"field": "cm:mimetype"},{"field": "modifier"}] + * }, + * "facetFormat":"V2" + * } + */ + public void searchWithFactedFieldsFacetFormatV2() throws Exception + { + SearchRequest query = new SearchRequest(); + RestRequestQueryModel queryReq = new RestRequestQueryModel(); + queryReq.setQuery(unique_searchString); + query.setQuery(queryReq); + query.setFacetFormat("V2"); + RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); + List facets = new ArrayList(); + facets.add(new RestRequestFacetFieldModel("cm:mimetype")); + facets.add(new RestRequestFacetFieldModel("modifier")); + facetFields.setFacets(facets); + query.setFacetFields(facetFields); + + SearchResponse response = query(query); + + Assert.assertNull(response.getContext().getFacetsFields()); + Assert.assertNull(response.getContext().getFacetQueries()); + Assert.assertFalse(response.getContext().getFacets().isEmpty()); + RestGenericFacetResponseModel model = response.getContext().getFacets().get(0); + Assert.assertEquals(model.getLabel(), "modifier"); + + model.assertThat().field("label").is("modifier"); + RestGenericBucketModel bucket1 = model.getBuckets().get(0); + bucket1.assertThat().field("label").is(userModel.getUsername()); + bucket1.assertThat().field("display").is(userModel.getUsername() + " FirstName LN-" + userModel.getUsername()); + bucket1.assertThat().field("filterQuery").is("modifier:\"" + userModel.getUsername() + "\""); + bucket1.assertThat().field("metrics").is("[{entry=null, type=count, value={count=1}}]"); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/search/FingerPrintTest.java b/e2e-test/src/test/java/org/alfresco/rest/search/FingerPrintTest.java new file mode 100644 index 000000000..26874a90a --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/search/FingerPrintTest.java @@ -0,0 +1,166 @@ +/* + * Copyright (C) 2018 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.rest.search; + +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FileType; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.TestGroup; +import org.testng.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Search end point Public API test with finger print. + * @author Michael Suzuki + * + */ +public class FingerPrintTest extends AbstractSearchTest +{ + private FileModel file1, file2, file3, file4; + + @BeforeClass(alwaysRun = true) + public void indexSimilarFile() throws Exception + { + + /* + * Create the following file structure in the same Site : In addition to the preconditions created in dataPreparation + * |- folder + * |-- pangram-banana.txt + * |-- pangram-taco.txt + * |-- pangram-cat.txt + * |-- dog.txt + */ + + FolderModel folder = new FolderModel("The quick brown fox jumps over"); + dataContent.usingUser(userModel).usingSite(siteModel).createFolder(folder); + + file1 = new FileModel("pangram-banana.txt", FileType.TEXT_PLAIN, "The quick brown fox jumps over the lazy banana"); + file2 = new FileModel("pangram-taco.txt", FileType.TEXT_PLAIN, "The quick brown fox jumps over the lazy dog that ate the taco"); + file3 = new FileModel("pangram-cat.txt", FileType.TEXT_PLAIN, "The quick brown fox jumps over the lazy cat"); + file4 = new FileModel("dog.txt", FileType.TEXT_PLAIN, "The quick brown fox ate the lazy dog"); + + dataContent.usingUser(userModel).usingSite(siteModel).usingResource(folder).createContent(file1); + dataContent.usingUser(userModel).usingSite(siteModel).usingResource(folder).createContent(file2); + dataContent.usingUser(userModel).usingSite(siteModel).usingResource(folder).createContent(file3); + dataContent.usingUser(userModel).usingSite(siteModel).usingResource(folder).createContent(file4); + + waitForContentIndexing(file4.getContent(), true); + // Additional wait implemented to remove inconsistent failures. Ref: Search-1438 for details + waitForIndexing("FINGERPRINT:" + file2.getNodeRefWithoutVersion(), true); + waitForIndexing("FINGERPRINT:" + file3.getNodeRefWithoutVersion(), true); + } + + /** + * Search similar document based on document finger print. + * The data prep should have loaded 2 files which one is similar + * to the files loaded as part of this test. + * Note that for fingerprint to work it need a 5 word sequence. + * + * @throws Exception + */ + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) + public void search() throws Exception + { + String uuid = file1.getNodeRefWithoutVersion(); + Assert.assertNotNull(uuid); + String fingerprint = String.format("FINGERPRINT:%s", uuid); + SearchResponse response = query(fingerprint); + int count = response.getEntries().size(); + Assert.assertTrue(count > 1); + for (SearchNodeModel m : response.getEntries()) + { + String match = m.getModel().getName(); + switch (match) + { + case "pangram.txt": + break; + case "pangram-banana.txt": + break; + case "pangram-taco.txt": + break; + case "pangram-cat.txt": + break; + default: + throw new AssertionError("Not a match to an expected file: " + m.getModel().getName()); + } + m.getModel().assertThat().field("name").isNot("dog.txt"); + m.getModel().assertThat().field("name").isNot("cars.txt"); + } + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) + public void searchSimilar() throws Exception + { + String uuid = file2.getNodeRefWithoutVersion(); + Assert.assertNotNull(uuid); + + // In the response entity there is a score of each doc, change below threshold to bring more like or less. + String fingerprint = String.format("FINGERPRINT:%s_68", uuid); + SearchResponse response = query(fingerprint); + + int count = response.getEntries().size(); + Assert.assertTrue(count > 1); + + for (SearchNodeModel m : response.getEntries()) + { + switch (m.getModel().getName()) + { + case "pangram.txt": + break; + case "pangram-taco.txt": + break; + default: + throw new AssertionError("Not a match to an expected file: " + m.getModel().getName()); + } + m.getModel().assertThat().field("name").isNot("pangram-banana.txt"); + m.getModel().assertThat().field("name").isNot("pangram-cat.txt"); + m.getModel().assertThat().field("name").isNot("dog.txt"); + m.getModel().assertThat().field("name").isNot("cars.txt"); + } + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) + public void searchSimilar67Percent() throws Exception + { + String uuid = file2.getNodeRefWithoutVersion(); + Assert.assertNotNull(uuid); + String fingerprint = String.format("FINGERPRINT:%s_68", uuid); + SearchResponse response = query(fingerprint); + int count = response.getEntries().size(); + Assert.assertTrue(count > 1); + for (SearchNodeModel m : response.getEntries()) + { + switch (m.getModel().getName()) + { + case "pangram.txt": + break; + case "pangram-taco.txt": + break; + case "pangram-cat.txt": + break; + default: + throw new AssertionError("Not a match to an expected file: " + m.getModel().getName()); + } + m.getModel().assertThat().field("name").isNot("pangram-banana.txt"); + m.getModel().assertThat().field("name").isNot("dog.txt"); + m.getModel().assertThat().field("name").isNot("cars.txt"); + } + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/search/PivotFacetedSearchTest.java b/e2e-test/src/test/java/org/alfresco/rest/search/PivotFacetedSearchTest.java new file mode 100644 index 000000000..fae882339 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/search/PivotFacetedSearchTest.java @@ -0,0 +1,273 @@ +/* + * Copyright (C) 2017 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.rest.search; + +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestRequestRangesModel; +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.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Faceted search test. + * @author Gethin James + * + */ +public class PivotFacetedSearchTest extends AbstractSearchTest +{ + @BeforeClass(alwaysRun = true) + public void setupEnvironment() throws Exception + { + waitForContentIndexing(file4.getContent(), true); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, + executionType = ExecutionType.REGRESSION, + description = "Checks errors with pivot using Search api") + public void searchWithPivotingErrors() throws Exception + { + SearchRequest query = carsQuery(); + + RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); + List list = new ArrayList<>(); + list.add(new RestRequestFacetFieldModel("'creator'")); + facetFields.setFacets(list); + query.setFacetFields(facetFields); + query.setIncludeRequest(false); + List pivotModelList = new ArrayList<>(); + RestRequestPivotModel pivots = new RestRequestPivotModel(); + pivotModelList.add(pivots); + query.setPivots(pivotModelList); + + query(query); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.MANDATORY_PARAM, "pivot key")); + + pivots.setKey("none_like_this"); + + query(query); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary("invalid argument was received") + .containsSummary("Pivot parameter none_like_this does not reference"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, + executionType = ExecutionType.REGRESSION, + description = "Checks with pivot using Search api") + public void searchWithPivoting() throws Exception + { + SearchRequest query = carsQuery(); + + RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); + List list = new ArrayList<>(); + list.add(new RestRequestFacetFieldModel("creator")); + facetFields.setFacets(list); + query.setFacetFields(facetFields); + query.setIncludeRequest(false); + + SearchResponse response = query(query); + response.getContext().assertThat().field("facetsFields").isNotNull(); + + List pivotModelList = new ArrayList<>(); + RestRequestPivotModel pivots = new RestRequestPivotModel(); + pivots.setKey("creator"); + pivotModelList.add(pivots); + query.setPivots(pivotModelList); + response = query(query); + + //Pivot key has matched facet field so there is no longer a facet fields response + assertPivotResponse(response, "creator", null); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, + executionType = ExecutionType.REGRESSION, + description = "Checks nested pivot using Search api") + public void searchWithNestedPivoting() throws Exception + { + SearchRequest query = carsQuery(); + + RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); + List list = new ArrayList<>(); + RestRequestFacetFieldModel restRequestFacetFieldModel = new RestRequestFacetFieldModel("SITE"); + restRequestFacetFieldModel.setLabel("site"); + list.add(restRequestFacetFieldModel); + list.add(new RestRequestFacetFieldModel("creator")); + list.add(new RestRequestFacetFieldModel("modifier")); + facetFields.setFacets(list); + query.setFacetFields(facetFields); + query.setIncludeRequest(false); + + List pivotModelList = new ArrayList<>(); + RestRequestPivotModel sitepivots = new RestRequestPivotModel(); + sitepivots.setKey("site"); + RestRequestPivotModel creatorpivot = new RestRequestPivotModel(); + creatorpivot.setKey("creator"); + RestRequestPivotModel modifierpivot = new RestRequestPivotModel(); + modifierpivot.setKey("modifier"); + sitepivots.setPivots(Arrays.asList(creatorpivot, modifierpivot)); + pivotModelList.add(sitepivots); + query.setPivots(pivotModelList); + + SearchResponse response = query(query); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary("invalid argument was received") + .containsSummary("Currently only 1 nested pivot is supported, you have 2"); + + pivotModelList = new ArrayList<>(); + sitepivots = new RestRequestPivotModel(); + sitepivots.setKey("site"); + sitepivots.setPivots(Arrays.asList(modifierpivot)); + pivotModelList.add(sitepivots); + pivotModelList.add(creatorpivot); + query.setPivots(pivotModelList); + + response = query(query); + assertPivotResponse(response, "SITE", "site"); + + RestGenericFacetResponseModel siteResponse = response.getContext().getFacets().get(0); + RestGenericBucketModel bucket = siteResponse.getBuckets().get(0); + RestGenericFacetResponseModel modifiedResponse = bucket.getFacets().get(0); + modifiedResponse.assertThat().field("type").is("pivot"); + modifiedResponse.assertThat().field("label").is("modifier"); + + RestGenericFacetResponseModel creatorResponse = response.getContext().getFacets().get(1); + creatorResponse.assertThat().field("type").is("pivot"); + creatorResponse.assertThat().field("label").is("creator"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, + executionType = ExecutionType.REGRESSION, + description = "Checks range pivots using Search api") + public void searchWithRangePivoting() throws Exception + { + SearchRequest query = carsQuery(); + + String endDate = LocalDateTime.now() + .format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss'Z'")); //the car document is created at runtime, so to include it in range facets end date must be now + + Pagination pagination = new Pagination(); + pagination.setMaxItems(2); + query.setPaging(pagination); + RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); + List list = new ArrayList<>(); + list.add(new RestRequestFacetFieldModel("creator")); + facetFields.setFacets(list); + query.setFacetFields(facetFields); + query.setIncludeRequest(false); + + RestRequestRangesModel facetRangeModel = new RestRequestRangesModel(); + facetRangeModel.setField("created"); + facetRangeModel.setStart("2015-09-29T10:45:15.729Z"); + facetRangeModel.setEnd(endDate); + facetRangeModel.setGap("+280DAY"); + facetRangeModel.setLabel("aRange"); + List ranges = new ArrayList(); + ranges.add(facetRangeModel); + query.setRanges(ranges); + + List pivotModelList = new ArrayList<>(); + RestRequestPivotModel creatorpivot = new RestRequestPivotModel(); + creatorpivot.setKey("creator"); + RestRequestPivotModel rangepivot = new RestRequestPivotModel(); + rangepivot.setKey("aRange"); + creatorpivot.setPivots(Arrays.asList(rangepivot)); + pivotModelList.add(creatorpivot); + query.setPivots(pivotModelList); + + SearchResponse response = query(query); + RestGenericFacetResponseModel facetResponseModel = response.getContext().getFacets().get(1); + facetResponseModel.assertThat().field("type").is("pivot"); + facetResponseModel.assertThat().field("label").is("creator"); + RestGenericBucketModel bucket = facetResponseModel.getBuckets().get(0); + RestGenericFacetResponseModel rangeResponse = bucket.getFacets().get(0); + rangeResponse.assertThat().field("type").is("range"); + } + + private void assertPivotResponse(SearchResponse response, String field, String alabel) throws Exception + { + String label = alabel!=null?alabel:field; + response.getContext().assertThat().field("facetsFields").isNull(); + response.getContext().assertThat().field("facets").isNotEmpty(); + RestGenericFacetResponseModel facetResponseModel = response.getContext().getFacets().get(0); + facetResponseModel.assertThat().field("type").is("pivot"); + facetResponseModel.assertThat().field("label").is(label); + RestGenericBucketModel bucket = facetResponseModel.getBuckets().get(0); + bucket.assertThat().field("label").isNotEmpty(); + bucket.assertThat().field("filterQuery").is(field+":\""+bucket.getLabel()+"\""); + Assert.assertEquals("count", bucket.getMetrics().get(0).getType()); + Assert.assertTrue(bucket.getMetrics().get(0).getValue().toString().contains("{count=")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, + executionType = ExecutionType.REGRESSION, + description = "Checks with pivot using Search api and a label as a key") + public void searchWithPivotingUsingLabel() throws Exception + { + SearchRequest query = carsQuery(); + RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); + List list = new ArrayList<>(); + RestRequestFacetFieldModel creatorFacetFieldModel = new RestRequestFacetFieldModel("creator"); + creatorFacetFieldModel.setLabel("create"); + list.add(creatorFacetFieldModel); + RestRequestFacetFieldModel restRequestFacetFieldModel = new RestRequestFacetFieldModel("modifier"); + restRequestFacetFieldModel.setLabel("aLabel"); + list.add(restRequestFacetFieldModel); + facetFields.setFacets(list); + query.setFacetFields(facetFields); + query.setIncludeRequest(false); + RestRequestPivotModel pivots = new RestRequestPivotModel(); + pivots.setKey("create"); + RestRequestPivotModel pivotmod = new RestRequestPivotModel(); + pivotmod.setKey("aLabel"); + + List pivotModelList = new ArrayList<>(); + pivotModelList.add(pivots); + pivotModelList.add(pivotmod); + query.setPivots(pivotModelList); + SearchResponse response = query(query); + assertPivotResponse(response, "creator", "create"); + + //Now check the nesting + RestGenericFacetResponseModel labelResponseModel = response.getContext().getFacets().get(1); + labelResponseModel.assertThat().field("type").is("pivot"); + labelResponseModel.assertThat().field("label").isNotEmpty(); + labelResponseModel.assertThat().field("label").is("aLabel"); + RestGenericBucketModel bucket = labelResponseModel.getBuckets().get(0); + bucket.assertThat().field("filterQuery").is("modifier:\""+bucket.getLabel()+"\""); + Assert.assertEquals("count", bucket.getMetrics().get(0).getType()); + Assert.assertTrue(bucket.getMetrics().get(0).getValue().toString().contains("{count=")); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/search/SearchAPATHTest.java b/e2e-test/src/test/java/org/alfresco/rest/search/SearchAPATHTest.java new file mode 100644 index 000000000..a045144f9 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/search/SearchAPATHTest.java @@ -0,0 +1,185 @@ +/* + * Copyright (C) 2018 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.rest.search; + + +import java.util.Collections; +import java.util.List; + +import org.alfresco.utility.model.TestGroup; +import org.testng.Assert; +import org.testng.annotations.Test; + +/** + * Tests the search functionality using an ancestor path. + * Using the category as an example, it is a node that is located + * in root/rootCategory/classifiable. We now provide the ability to search by path + * so that we can return all the child elements of our target path. + * A search on root/rootCategory/classifiable should return Regions, Languages + * as they are the child elements of the given path. + * + * @author Michael Suzuki + * + */ +public class SearchAPATHTest extends AbstractSearchTest +{ + + @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_1}) + /** + * { + * "query": { + * "query": "name:*" + * }, + * "facetFields": { + * "facets": [ + * {"field": "APATH", "prefix": "0" } + * ] + * } + * } + * Expected result + * entries[], + * "pagination": { + * "maxItems": 100, + * "hasMoreItems": true, + * "totalItems": 914, + * "count": 100, + * "skipCount": 0 + * }, + * "context": { + * "facetsFields": [{ + * "buckets": [ + * { + * "count": 913, + * "label": "0/5c09534f-3ca2-4272-bc25-064a7c1762b4" + * }, + * { + * "count": 2, + * "label": "0/" + * } + * ], + * "label": "APATH" + * }], + * "consistency": {"lastTxId": 89} + * } + *}} + * + */ + public void searchLevel0() throws Exception + { + SearchRequest searchQuery = searchRequestWithAPATHFacet("name:*", "0"); + SearchResponse response = query(searchQuery); + + List buckets = getBuckets(response); + Assert.assertEquals(2, buckets.size()); + + buckets.forEach(bucket -> bucket.assertThat().field("label").contains("0/")); + } + + @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_1}) + public void searchLevel0andIncludeSubLevel1() throws Exception + { + SearchRequest searchQuery = searchRequestWithAPATHFacet("name:*", "1/"); + SearchResponse response = query(searchQuery); + + List buckets = getBuckets(response); + Assert.assertEquals(4, buckets.size()); + + getFirstBucket(response).assertThat().field("label").contains("1/"); + } + + @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_1}) + public void searchLevel2() throws Exception + { + String queryString = "name:cars"; + + SearchRequest l1Request = searchRequestWithAPATHFacet(queryString, "1/"); + SearchResponse l1Response = query(l1Request); + + String l2Prefix = getFirstBucket(l1Response).getLabel().replaceFirst("^1/", "2/"); + + SearchRequest l2Request = searchRequestWithAPATHFacet(queryString, l2Prefix); + SearchResponse l2Response = query(l2Request); + + FacetFieldBucket bucket = getFirstBucket(l2Response); + bucket.assertThat().field("label").contains(l2Prefix); + + String l3Prefix = bucket.getLabel().replaceFirst("^2/", "3/"); + + SearchRequest l3Request = searchRequestWithAPATHFacet(queryString, l3Prefix); + SearchResponse l3response = query(l3Request); + + List buckets = getBuckets(l3response); + Assert.assertEquals(1, buckets.size()); + + getFirstBucket(l3response).assertThat().field("label").contains(l3Prefix); + } + + /** + * Creates a new {@link SearchRequest} for this test case. + * + * @param queryString the query string. + * @param facetPrefix the facet prefix. + * @return a new {@link SearchRequest} for this test case. + */ + private SearchRequest searchRequestWithAPATHFacet(String queryString, String facetPrefix) + { + SearchRequest searchRequest = new SearchRequest(); + + RestRequestQueryModel query = new RestRequestQueryModel(); + query.setQuery(queryString); + searchRequest.setQuery(query); + + RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); + facetFields.setFacets(Collections.singletonList(new RestRequestFacetFieldModel("APATH", facetPrefix))); + searchRequest.setFacetFields(facetFields); + + return searchRequest; + } + + /** + * Extracts the first bucket from the given response. + * + * @param response the results of a query execution. + * @return the first bucket included in the search response. + */ + private FacetFieldBucket getFirstBucket(SearchResponse response) + { + return getBuckets(response).iterator().next(); + } + + /** + * Extracts the buckets from the given response. + * The method also makes sure the buckets list is not empty in the input response. + * + * @param response the results of a query execution. + * @return the getBuckets included in the search response. + */ + private List getBuckets(SearchResponse response) + { + List facetFields = response.getContext().getFacetsFields(); + Assert.assertNotNull(facetFields); + Assert.assertFalse(facetFields.isEmpty()); + + List buckets = facetFields.iterator().next().getBuckets(); + Assert.assertNotNull(buckets); + Assert.assertFalse(buckets.isEmpty()); + + return buckets; + } +} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/rest/search/SearchHighLightTest.java b/e2e-test/src/test/java/org/alfresco/rest/search/SearchHighLightTest.java new file mode 100644 index 000000000..06528e684 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/search/SearchHighLightTest.java @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2017 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.rest.search; + +import java.util.ArrayList; +import java.util.List; + +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.report.Bug; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Search high lighting test. + * @author Michael Suzuki + * + */ +public class SearchHighLightTest extends AbstractSearchTest +{ + @Test(groups={TestGroup.SEARCH,TestGroup.REST_API}) + @Bug(id = "TAS-3220") + public void searchWithHighLight() throws Exception + { + waitForContentIndexing(file2.getContent(), true); + + RestRequestQueryModel queryReq = new RestRequestQueryModel(); + queryReq.setQuery("cm:content:cars"); + queryReq.setUserQuery("cars"); + + RestRequestHighlightModel highlight = new RestRequestHighlightModel(); + highlight.setPrefix("¿"); + highlight.setPostfix("?"); + highlight.setMergeContiguous(true); + List fields = new ArrayList(); + fields.add(new RestRequestFieldsModel("cm:content")); + highlight.setFields(fields); + SearchResponse nodes = query(queryReq, highlight); + nodes.assertThat().entriesListIsNotEmpty(); + ResponseHighLightModel hl = nodes.getEntryByIndex(0).getSearch().getHighlight().get(0); + hl.assertThat().field("snippets").contains( "The landrover discovery is not a sports ¿car?"); + } + + @Test(groups={TestGroup.SEARCH,TestGroup.REST_API}) + public void searchNonIndexedData() throws Exception + { + RestRequestQueryModel queryReq = new RestRequestQueryModel(); + queryReq.setQuery("cm:title"); + queryReq.setUserQuery("zoro"); + + RestRequestHighlightModel highlight = new RestRequestHighlightModel(); + highlight.setPrefix("¿"); + highlight.setPostfix("?"); + highlight.setMergeContiguous(true); + List fields = new ArrayList(); + fields.add(new RestRequestFieldsModel("cm:title")); + highlight.setFields(fields); + SearchResponse nodes = query(queryReq, highlight); + nodes.assertThat().entriesListDoesNotContain("highlight"); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/search/SearchSpellCheckTest.java b/e2e-test/src/test/java/org/alfresco/rest/search/SearchSpellCheckTest.java new file mode 100644 index 000000000..9be9d7fd7 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/search/SearchSpellCheckTest.java @@ -0,0 +1,174 @@ +/* + * Copyright (C) 2018 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.rest.search; + +import org.alfresco.rest.model.RestRequestSpellcheckModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FileType; +import org.alfresco.utility.model.TestGroup; +import org.testng.Assert; +import org.testng.annotations.Test; + +/** + * Search end point Public API test with spell checking enabled. + * @author Michael Suzuki + * @author Meenal Bhave + */ +public class SearchSpellCheckTest extends AbstractSearchTest +{ + + /** + * Perform the below query + * { + * "spellcheck" : { }, + * "query" : { + * "userQuery" : "alfrezco", + * "query" : "cm:title:alfrezco" + * } + * to yeild the following result. + * { + * "list": { + * "pagination": { + * "count": 22, + * "hasMoreItems": false, + * "totalItems": 22, + * "skipCount": 0, + * "maxItems": 100 + * }, + * "context": { + * "spellCheck": { + * "type": "searchInsteadFor", + * "suggestions": [ + * "alfresco" + * ] + * } + * }, + * "entries": [...] + * } + * + * @throws Exception + */ + @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ACS_60n}, priority=1) + public void testSearchMissSpelled() throws Exception + { + waitForContentIndexing(file4.getContent(), true); + + // Name + SearchRequest searchReq = new SearchRequest(); + RestRequestQueryModel queryReq = new RestRequestQueryModel(); + queryReq.setQuery("cm:name:alfrezco"); + queryReq.setUserQuery("alfrezco"); + searchReq.setQuery(queryReq); + searchReq.setSpellcheck(new RestRequestSpellcheckModel()); + assertResponse(query(searchReq)); + + // Title + queryReq.setQuery("cm:title:alfrezco"); + queryReq.setUserQuery("alfrezco"); + searchReq.setQuery(queryReq); + searchReq.setSpellcheck(new RestRequestSpellcheckModel()); + assertResponse(query(searchReq)); + + // Description + queryReq.setQuery("cm:description:alfrezco"); + queryReq.setUserQuery("alfrezco"); + searchReq.setQuery(queryReq); + searchReq.setSpellcheck(new RestRequestSpellcheckModel()); + assertResponse(query(searchReq)); + + // Content + queryReq.setQuery("cm:content:alfrezco"); + queryReq.setUserQuery("alfrezco"); + searchReq.setQuery(queryReq); + searchReq.setSpellcheck(new RestRequestSpellcheckModel()); + assertResponse(query(searchReq)); + } + + private void assertResponse(SearchResponse nodes) throws Exception + { + nodes.assertThat().entriesListIsNotEmpty(); + nodes.getContext().assertThat().field("spellCheck").isNotEmpty(); + nodes.getContext().getSpellCheck().assertThat().field("suggestions").contains("alfresco"); + nodes.getContext().getSpellCheck().assertThat().field("type").is("searchInsteadFor"); + } + + /** + * Perform alternative way by setting the value in spellcheck object. + * + * { + * "query": { + * "query": "cm:title:alfrezco", + * "language": "afts" + * }, + * "spellcheck": {"query": "alfrezco"} + * } + * @throws Exception + */ + @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ACS_60n}, priority=2) + public void testSearchMissSpelledVersion2() throws Exception + { + SearchRequest searchReq = new SearchRequest(); + RestRequestQueryModel queryReq = new RestRequestQueryModel(); + queryReq.setQuery("cm:title:alfrezco"); + searchReq.setQuery(queryReq); + + RestRequestSpellcheckModel spellCheck = new RestRequestSpellcheckModel(); + spellCheck.setQuery("alfrezco"); + searchReq.setSpellcheck(spellCheck); + assertResponse(query(searchReq)); + } + + @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ACS_60n}, priority=3) + public void testSearchWithSpellcheckerAndCorrectSpelling() throws Exception + { + SearchRequest searchReq = new SearchRequest(); + RestRequestQueryModel queryReq = new RestRequestQueryModel(); + queryReq.setQuery("cm:title:alfresco"); + queryReq.setUserQuery("alfresco"); + searchReq.setQuery(queryReq); + searchReq.setSpellcheck(new RestRequestSpellcheckModel()); + SearchResponse res = query(searchReq); + Assert.assertNull(res.getContext().getSpellCheck()); + res.assertThat().entriesListIsNotEmpty(); + } + + @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ACS_60n}, priority=4) + public void testSpellCheckType() throws Exception + { + // Create a file with mis-spelt name, expect spellcheck type = didYouMean + FileModel file = new FileModel(unique_searchString + "-1.txt", "uniquee" + "uniquee", "uniquee", FileType.TEXT_PLAIN, "Unique text file for search "); + dataContent.usingUser(userModel).usingSite(siteModel).createContent(file); + + waitForIndexing(file.getName(), true); + + // Search + SearchRequest searchReq = new SearchRequest(); + RestRequestQueryModel queryReq = new RestRequestQueryModel(); + queryReq.setQuery("cm:title:uniquee"); + queryReq.setUserQuery("uniquee"); + searchReq.setQuery(queryReq); + searchReq.setSpellcheck(new RestRequestSpellcheckModel()); + SearchResponse nodes = query(searchReq); + + nodes.assertThat().entriesListIsNotEmpty(); + nodes.getContext().assertThat().field("spellCheck").isNotEmpty(); + nodes.getContext().getSpellCheck().assertThat().field("suggestions").contains("unique"); + nodes.getContext().getSpellCheck().assertThat().field("type").is("didYouMean"); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/search/SearchTest.java b/e2e-test/src/test/java/org/alfresco/rest/search/SearchTest.java new file mode 100644 index 000000000..8db269fd4 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/search/SearchTest.java @@ -0,0 +1,309 @@ +/* + * Copyright (C) 2018 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.rest.search; + +import static java.util.Arrays.asList; +import static java.util.Collections.reverse; + +import static org.codehaus.groovy.runtime.InvokerHelper.asList; +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.notNullValue; +import static org.hamcrest.Matchers.nullValue; +import static org.testng.AssertJUnit.assertEquals; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +import org.alfresco.rest.model.body.RestNodeLockBodyModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FileType; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.hamcrest.Matchers; +import org.springframework.http.HttpStatus; +import org.testng.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Search end point Public API test. + * @author Michael Suzuki + * + */ +public class SearchTest extends AbstractSearchTest +{ + @BeforeClass(alwaysRun = true) + public void setupEnvironment() throws Exception + { + waitForContentIndexing(file4.getContent(), true); + } + + @Test(groups={TestGroup.SEARCH, TestGroup.REST_API}) + public void searchOnIndexedData() throws Exception + { + SearchResponse nodes = query(unique_searchString); + restClient.assertStatusCodeIs(HttpStatus.OK); + nodes.assertThat().entriesListIsNotEmpty(); + + SearchNodeModel entity = nodes.getEntryByIndex(0); + entity.assertThat().field("search").contains("score"); + entity.getSearch().assertThat().field("score").isNotEmpty(); + Assert.assertEquals("pangram.txt",entity.getName()); + } + + @Test(groups={TestGroup.SEARCH,TestGroup.REST_API}) + public void searchNonIndexedData() throws Exception + { + SearchResponse nodes = query("yeti"); + restClient.assertStatusCodeIs(HttpStatus.OK); + nodes.assertThat().entriesListIsEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, + description = "Checks its possible to include the original request in the response") + public void searchWithRequest() throws Exception + { + SearchRequest query = new SearchRequest(); + RestRequestQueryModel queryReq = new RestRequestQueryModel(); + queryReq.setQuery("fox"); + query.setQuery(queryReq); + query.setIncludeRequest(true); + + SearchResponse response = query(query); + restClient.assertStatusCodeIs(HttpStatus.OK); + + response.getContext().assertThat().field("request").isNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, + description = "Tests a search request containing a sort clause.") + public void searchWithOneSortClause() throws Exception + { + // Tests the ascending order first + List expectedOrder = asList("alfresco.txt", "cars.txt", "pangram.txt"); + + SearchRequest searchRequest = createQuery("cm_name:alfresco\\.txt cm_name:cars\\.txt cm_name:pangram\\.txt"); + searchRequest.addSortClause("FIELD", "name", true); + + RestRequestFilterQueryModel filters = new RestRequestFilterQueryModel(); + filters.setQuery("SITE:'" + siteModel.getId() + "'"); + searchRequest.setFilterQueries(filters); + + SearchResponse responseWithAscendingOrder = query(searchRequest); + + restClient.assertStatusCodeIs(HttpStatus.OK); + + assertEquals( + expectedOrder, + responseWithAscendingOrder.getEntries().stream() + .map(SearchNodeModel::getModel) + .map(SearchNodeModel::getName) + .collect(Collectors.toList())); + + // Reverts the expected order... + reverse(expectedOrder); + + // ...and test the descending order + searchRequest.getSort().clear(); + searchRequest.addSortClause("FIELD", "name", false); + + SearchResponse responseWithDescendingOrder = query(searchRequest); + assertEquals( + expectedOrder, + responseWithDescendingOrder.getEntries().stream() + .map(SearchNodeModel::getModel) + .map(SearchNodeModel::getName) + .collect(Collectors.toList())); + } + + /** + * Tests the query execution with two sort clauses. + * The first clause has always the same value for all matches so the test makes sure the request is correctly + * processed and the returned order is determined by the second clause. + */ + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, + description = "Tests a search request containing a sort clause.") + public void searchWithTwoSortClauses() throws Exception + { + // Tests the ascending order first + List expectedOrder = asList("alfresco.txt", "cars.txt", "pangram.txt"); + + SearchRequest searchRequest = createQuery("cm_name:alfresco\\.txt cm_name:cars\\.txt cm_name:pangram\\.txt"); + searchRequest.addSortClause("FIELD", "name", true); + searchRequest.addSortClause("FIELD", "createdByUser.id", true); + + RestRequestFilterQueryModel filters = new RestRequestFilterQueryModel(); + filters.setQuery("SITE:'" + siteModel.getId() + "'"); + searchRequest.setFilterQueries(filters); + + SearchResponse responseWithAscendingOrder = query(searchRequest); + + restClient.assertStatusCodeIs(HttpStatus.OK); + + assertEquals( + expectedOrder, + responseWithAscendingOrder.getEntries().stream() + .map(SearchNodeModel::getModel) + .map(SearchNodeModel::getName) + .collect(Collectors.toList())); + + // Reverts the expected order... + reverse(expectedOrder); + + // ...and test the descending order + searchRequest.getSort().clear(); + searchRequest.addSortClause("FIELD", "name", false); + searchRequest.addSortClause("FIELD", "createdByUser.id", true); + + SearchResponse responseWithDescendingOrder = query(searchRequest); + assertEquals( + expectedOrder, + responseWithDescendingOrder.getEntries().stream() + .map(SearchNodeModel::getModel) + .map(SearchNodeModel::getName) + .collect(Collectors.toList())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ACS_61n }) @TestRail(section = { + TestGroup.REST_API, TestGroup.SEARCH, + TestGroup.ACS_61n }, executionType = ExecutionType.REGRESSION, description = "Checks the \"include\" request parameter support the 'permissions' option") public void searchQuery_includePermissions_shouldReturnNodeWithPermissionsInformation() + throws Exception + { + String query = "fox"; + String include = "permissions"; + + SearchRequest retrievalQueryIncludingPermissionsInformation = createQuery(query); + retrievalQueryIncludingPermissionsInformation.setInclude(asList(include)); + + query(retrievalQueryIncludingPermissionsInformation); + + restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.onResponse().assertThat().body("list.entries[0].entry.permissions", notNullValue()); + + SearchRequest retrievalQueryNotIncludingLockInformation = createQuery(query); + + query(retrievalQueryNotIncludingLockInformation); + + restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.onResponse().assertThat().body("list.entries[0].entry.permissions", nullValue()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ACS_61n }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ACS_61n }, executionType = ExecutionType.REGRESSION, + description = "Checks the \"include\" request parameter support the 'isLocked' option") + public void searchQuery_includeIsLocked_shouldReturnNodeWithLockInformation() throws Exception { + String query = "fox"; + String include = "isLocked"; + + SearchRequest retrievalQueryIncludingLockInformation = createQuery(query); + retrievalQueryIncludingLockInformation.setInclude(asList(include)); + + query(retrievalQueryIncludingLockInformation); + + restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.onResponse().assertThat().body("list.entries[0].entry.isLocked", equalTo(false)); + + RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); + lockBodyModel.setLifetime("EPHEMERAL"); + lockBodyModel.setTimeToExpire(20); + lockBodyModel.setType("FULL"); + restClient.authenticateUser(userModel).withCoreAPI().usingNode(file).usingParams("include=isLocked").lockNode(lockBodyModel); + + query(retrievalQueryIncludingLockInformation); + + restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.onResponse().assertThat().body("list.entries[0].entry.isLocked", equalTo(true)); + + SearchRequest retrievalQueryNotIncludingLockInformation = createQuery(query); + + query(retrievalQueryNotIncludingLockInformation); + + restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.onResponse().assertThat().body("list.entries[0].entry.isLocked", nullValue()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ACS_61n }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ACS_61n }, executionType = ExecutionType.REGRESSION, + description = "Checks the \"include\" request parameter does not support the 'notValid' option") + public void searchQuery_includeInvalid_shouldReturnBadResponse() throws Exception + { + String query = "fox"; + String notValidInclude = "notValid"; + SearchRequest permissionsRetrieval = createQuery(query); + permissionsRetrieval.setInclude(asList(notValidInclude)); + + query(permissionsRetrieval); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + restClient.onResponse() + .assertThat() + .body("error.briefSummary", containsString("An invalid argument was received "+notValidInclude)); + } + + // Test that when fields parameter is set, only restricted fields appear in the response + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) + public void searchWithFields() throws Exception + { + SearchRequest query = new SearchRequest(); + RestRequestQueryModel queryReq = new RestRequestQueryModel(); + queryReq.setQuery("alfresco"); + query.setQuery(queryReq); + + // Restrict to fields: parentId + List fields = new ArrayList(); + fields.add("parentId"); + query.setFields(fields); + + query(query); + restClient.assertStatusCodeIs(HttpStatus.OK); + + // Only Field parentId is included in the response + restClient.onResponse().assertThat().body("list.entries.entry[0].parentId", Matchers.notNullValue()); + // Usual Fields such as 'name, id' aren't included in the response + restClient.onResponse().assertThat().body("list.entries.entry[0].name", Matchers.nullValue()); + restClient.onResponse().assertThat().body("list.entries.entry[0].id", Matchers.nullValue()); + } + + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API }) + public void searchSpecialCharacters() throws Exception + { + // Create a file with Special Characters + String specialCharfileName = "è¥äæ§ç§-åæ.pdf"; + FileModel file = new FileModel(specialCharfileName, "è¥äæ§ç§-忬¯¸" + "è¥äæ§ç§-忬¯¸", "è¥äæ§ç§-忬¯¸", FileType.TEXT_PLAIN, + "Text file with Special Characters: " + specialCharfileName); + dataContent.usingUser(userModel).usingSite(siteModel).createContent(file); + + waitForIndexing(file.getName(), true); + + // Search + SearchRequest searchReq = createQuery("name:'" + specialCharfileName + "'"); + SearchResponse nodes = query(searchReq); + + restClient.assertStatusCodeIs(HttpStatus.OK); + nodes.assertThat().entriesListIsNotEmpty(); + + restClient.onResponse().assertThat().body("list.entries.entry[0].name", Matchers.equalToIgnoringCase(specialCharfileName)); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/search/ShardInfoTest.java b/e2e-test/src/test/java/org/alfresco/rest/search/ShardInfoTest.java new file mode 100644 index 000000000..410779581 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/search/ShardInfoTest.java @@ -0,0 +1,85 @@ +/* + * Copyright (C) 2005-2018 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.rest.search; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertTrue; + +import java.util.Arrays; +import java.util.List; + +import com.fasterxml.jackson.core.JsonProcessingException; + +import org.alfresco.rest.exception.EmptyRestModelCollectionException; +import org.alfresco.utility.model.TestGroup; +import org.springframework.http.HttpStatus; +import org.testng.annotations.Test; + +/** + * Shard info end point REST API test. + * + * @author Tuna Aksoy + */ +public class ShardInfoTest extends AbstractSearchTest +{ + @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ACS_60n}) + public void getShardInfoWithAdminAuthority() throws JsonProcessingException, EmptyRestModelCollectionException + { + RestShardInfoModelCollection info = restClient.authenticateUser(dataUser.getAdminUser()).withShardInfoAPI().getInfo(); + restClient.assertStatusCodeIs(HttpStatus.OK); + info.assertThat().entriesListIsNotEmpty(); + assertEquals(info.getPagination().getTotalItems().intValue(), 2); + + List stores = Arrays.asList("workspace://SpacesStore", "archive://SpacesStore"); + List baseUrls = Arrays.asList("/solr/alfresco", "/solr/archive"); + + List entries = info.getEntries(); + for (RestShardInfoModel shardInfoModel : entries) + { + RestShardInfoModel model = shardInfoModel.getModel(); + assertEquals(model.getTemplate(), "rerank"); + assertEquals(model.getMode(), "MASTER"); + assertEquals(model.getShardMethod(), "DB_ID"); + assertTrue(model.getHasContent()); + stores.contains(model.getStores()); + List shards = model.getShards(); + assertNotNull(shards); + RestShardModel shard = shards.iterator().next(); + assertNotNull(shard); + List instances = shard.getInstances(); + assertNotNull(instances); + RestInstanceModel instance = instances.iterator().next(); + assertNotNull(instance); + baseUrls.contains(instance.getBaseUrl()); + // TODO: Ideally Solr Host and Port should be Parameterised + assertEquals(instance.getHost(), "search"); + assertEquals(instance.getPort().intValue(), 8983); + assertEquals(instance.getState(), "ACTIVE"); + assertEquals(instance.getMode(), "MASTER"); + } + } + + @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ACS_60n}) + public void getShardInfoWithoutAdminAuthority() throws Exception + { + restClient.authenticateUser(dataUser.createRandomTestUser()).withShardInfoAPI().getInfo(); + restClient.assertStatusCodeIs(HttpStatus.INTERNAL_SERVER_ERROR); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/search/StatsSearchTest.java b/e2e-test/src/test/java/org/alfresco/rest/search/StatsSearchTest.java new file mode 100644 index 000000000..594bb47b6 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/search/StatsSearchTest.java @@ -0,0 +1,320 @@ +/* + * Copyright (C) 2017 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.rest.search; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertTrue; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + +import org.alfresco.rest.model.RestErrorModel; +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.BeforeClass; +import org.testng.annotations.Test; + +/** + * Stats search test. + * @author Gethin James + * + */ +public class StatsSearchTest extends AbstractSearchTest +{ + @BeforeClass(alwaysRun = true) + public void setupEnvironment() throws Exception + { + waitForContentIndexing(file2.getContent(), true); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, + executionType = ExecutionType.REGRESSION, + description = "Checks errors with stats using Search api") + public void searchWithBasicStats() throws Exception + { + SearchRequest query = carsQuery(); + Pagination pagination = new Pagination(); + pagination.setMaxItems(2); + List statsModels = new ArrayList<>(); + RestRequestStatsModel statsModel1 = new RestRequestStatsModel(); + statsModels.add(statsModel1); + query.setStats(statsModels); + query.setPaging(pagination); + + SearchResponse response = query(query); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.MANDATORY_PARAM, "stats field")); + + statsModel1.setField("DBID"); + response = query(query); + //8 metrics by default for a numeric field + Set metricTypes = assertStatsFacetedResponse(response, "DBID", 8); + assertTrue(metricTypes.containsAll(Arrays.asList("missing", "countValues", "sum","min","max", "sumOfSquares", "mean", "stddev"))); + + statsModel1.setField("creator"); + response = query(query); + //4 metrics by default for a string field + metricTypes = assertStatsFacetedResponse(response, "creator", 4); + assertTrue(metricTypes.containsAll(Arrays.asList("missing", "countValues", "min","max"))); + + statsModel1.setField("modified"); + response = query(query); + //8 metrics by default for a date field + metricTypes = assertStatsFacetedResponse(response, "modified", 8); + assertTrue(metricTypes.containsAll(Arrays.asList("missing", "countValues", "sum","min","max", "sumOfSquares", "mean", "stddev"))); + + statsModel1.setField("modifier"); + statsModel1.setMin(false); + statsModel1.setMax(false); + statsModel1.setMissing(false); + response = query(query); + metricTypes = assertStatsFacetedResponse(response, "modifier", 1); + assertFalse(metricTypes.containsAll(Arrays.asList("missing", "min","max"))); + + statsModel1.setField("DBID"); + statsModel1.setMin(true); + statsModel1.setMax(true); + statsModel1.setCountValues(false); + statsModel1.setMissing(false); + statsModel1.setSum(false); + statsModel1.setSumOfSquares(false); + statsModel1.setMean(false); + statsModel1.setStddev(false); + response = query(query); + metricTypes = assertStatsFacetedResponse(response, "DBID", 2); + assertTrue(metricTypes.containsAll(Arrays.asList("min","max"))); + assertFalse(metricTypes.containsAll(Arrays.asList("missing", "countValues", "sum","sumOfSquares", "mean", "stddev"))); + + statsModel1.setField("modifier"); + statsModel1.setMin(false); + statsModel1.setMax(false); + statsModel1.setCountDistinct(true); + statsModel1.setDistinctValues(true); + statsModel1.setCardinality(true); + response = query(query); + metricTypes = assertStatsFacetedResponse(response, "modifier", 3); + assertTrue(metricTypes.containsAll(Arrays.asList("countDistinct", "distinctValues", "cardinality"))); + + statsModel1.setField("DBID"); + statsModel1.setPercentiles(Arrays.asList(1,75,99,99.9)); + statsModel1.setCountDistinct(false); + statsModel1.setDistinctValues(false); + statsModel1.setCardinality(false); + response = query(query); + assertStatsFacetedResponse(response, "DBID", 1); + RestGenericMetricModel percMetric = response.getContext().getFacets().get(0).getBuckets().get(0).getMetrics().get(0); + assertEquals(percMetric.getType(),"percentiles"); + Map percVal = (Map) percMetric.getValue(); + Map percentiles = (Map) percVal.get("percentiles"); + assertEquals(percentiles.size(),4); + assertTrue(percentiles.keySet().containsAll(Arrays.asList("1.0","75.0","99.0","99.9"))); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, + executionType = ExecutionType.REGRESSION, + description = "Checks errors with stats labels using Search api") + public void searchWithStatsLabel() throws Exception + { + SearchRequest query = carsQuery(); + Pagination pagination = new Pagination(); + pagination.setMaxItems(2); + List statsModels = new ArrayList<>(); + RestRequestStatsModel statsModel1 = new RestRequestStatsModel(); + statsModel1.setField("modified"); + statsModel1.setLabel("DateChanged"); + statsModels.add(statsModel1); + query.setStats(statsModels); + query.setPaging(pagination); + SearchResponse response = query(query); + assertStatsFacetedResponse(response, "DateChanged", 8); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, + executionType = ExecutionType.REGRESSION, + description = "Checks errors with stats fitlers using Search api") + public void searchWithStatsFilters() throws Exception + { + SearchRequest query = new SearchRequest(); + RestRequestQueryModel queryReq = new RestRequestQueryModel(); + queryReq.setQuery("content.mimetype:text/plain"); + query.setQuery(queryReq); + List statsModels = new ArrayList<>(); + RestRequestStatsModel statsModel1 = new RestRequestStatsModel(); + statsModel1.setField("creator"); + statsModel1.setMin(false); + statsModel1.setMax(false); + statsModel1.setMissing(false); + statsModels.add(statsModel1); + query.setFilterQueries(new RestRequestFilterQueryModel("cars", Arrays.asList("justCars"))); + query.setStats(statsModels); + SearchResponse response = query(query); + assertStatsFacetedResponse(response, "creator", 1); + RestGenericMetricModel countMetric = response.getContext().getFacets().get(0).getBuckets().get(0).getMetrics().get(0); + Integer count = response.getPagination().getTotalItems(); + Map metricCount = (Map) countMetric.getValue(); + assertEquals(count, metricCount.get("countValues")); + + statsModel1.setExcludeFilters(Arrays.asList("justCars")); + response = query(query); + assertStatsFacetedResponse(response, "creator", 1); + countMetric = response.getContext().getFacets().get(0).getBuckets().get(0).getMetrics().get(0); + count = response.getEntries().size(); + metricCount = (Map) countMetric.getValue(); + assertTrue((Integer)metricCount.get("countValues") > count, "With the exclude filter there will be more documents than returned"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, + executionType = ExecutionType.REGRESSION, + description = "Checks errors with stats with Pivot using Search api") + public void searchWithStatsAndMutlilevelPivot() throws Exception + { + SearchRequest query = carsQuery(); + + Pagination pagination = new Pagination(); + pagination.setMaxItems(1); + query.setPaging(pagination); + RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); + List list = new ArrayList<>(); + RestRequestFacetFieldModel b0 = new RestRequestFacetFieldModel("SITE"); + b0.setLabel("b0"); + list.add(b0); + list.add(new RestRequestFacetFieldModel("created")); + RestRequestFacetFieldModel b2 = new RestRequestFacetFieldModel("modifier"); + b2.setLabel("b2"); + list.add(b2); + facetFields.setFacets(list); + query.setFacetFields(facetFields); + query.setIncludeRequest(false); + + List pivotModelList = new ArrayList<>(); + RestRequestPivotModel pivots = new RestRequestPivotModel(); + pivots.setKey("b0"); + RestRequestPivotModel pivotn = new RestRequestPivotModel(); + pivotn.setKey("created"); + RestRequestPivotModel pivot2 = new RestRequestPivotModel(); + pivot2.setKey("aNumber"); + + pivotn.setPivots(Arrays.asList(pivot2)); + pivots.setPivots(Arrays.asList(pivotn)); + pivotModelList.add(pivots); + query.setPivots(pivotModelList); + + List statsModels = new ArrayList<>(); + RestRequestStatsModel statsModel1 = new RestRequestStatsModel(); + statsModels.add(statsModel1); + query.setStats(statsModels); + statsModel1.setField("DBID"); + statsModel1.setLabel("aNumber"); + + SearchResponse response = query(query); + response.getContext().assertThat().field("facetsFields").isNotNull(); + response.getContext().assertThat().field("facets").isNotEmpty(); + assertEquals(response.getContext().getFacetsFields().size(), 1, "There should be 1 facet field for modifier"); + assertEquals(response.getContext().getFacets().size(), 2, "There should be 1 pivot facet with stats on the end and a high level stats facet"); + + RestGenericFacetResponseModel facetResponseModel = response.getContext().getFacets().get(0); + facetResponseModel.assertThat().field("type").is("pivot"); + facetResponseModel.assertThat().field("label").is("b0"); + + //pivot created + RestGenericFacetResponseModel created = facetResponseModel.getBuckets().get(0).getFacets().get(0); + created.assertThat().field("type").is("pivot"); + created.assertThat().field("label").is("created"); + //Another nested stats + assertEquals(created.getBuckets().get(0).getMetrics().size(), 9, "Metrics are on the end of a pivot bucket"); + + } + + + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, + executionType = ExecutionType.REGRESSION, + description = "Checks errors with stats with Pivot using Search api") + public void searchWithStatsAndPivot() throws Exception + { + SearchRequest query = carsQuery(); + + Pagination pagination = new Pagination(); + pagination.setMaxItems(2); + query.setPaging(pagination); + RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); + List list = new ArrayList<>(); + list.add(new RestRequestFacetFieldModel("creator")); + facetFields.setFacets(list); + query.setFacetFields(facetFields); + query.setIncludeRequest(false); + + SearchResponse response = query(query); + response.getContext().assertThat().field("facetsFields").isNotNull(); + + List pivotModelList = new ArrayList<>(); + RestRequestPivotModel pivots = new RestRequestPivotModel(); + pivots.setKey("creator"); + RestRequestPivotModel pivotn = new RestRequestPivotModel(); + pivotn.setKey("numericId"); + + pivots.setPivots(Arrays.asList(pivotn)); + pivotModelList.add(pivots); + query.setPivots(pivotModelList); + + List statsModels = new ArrayList<>(); + RestRequestStatsModel statsModel1 = new RestRequestStatsModel(); + statsModels.add(statsModel1); + query.setStats(statsModels); + statsModel1.setField("DBID"); + statsModel1.setLabel("numericId"); + + response = query(query); + + response.getContext().assertThat().field("facets").isNotEmpty(); + assertEquals(response.getContext().getFacets().size(), 2, "There should be 1 pivot facet with stats on the end and a high level stats facet"); + RestGenericFacetResponseModel facetResponseModel = response.getContext().getFacets().get(0); + facetResponseModel.assertThat().field("type").is("pivot"); + facetResponseModel.assertThat().field("label").is("creator"); + assertEquals(facetResponseModel.getBuckets().get(0).getMetrics().size(), 9, "Metrics are on the end of a pivot bucket"); + RestGenericFacetResponseModel statsFacet = response.getContext().getFacets().get(1); + statsFacet.assertThat().field("type").is("stats"); + statsFacet.assertThat().field("label").is("numericId"); + + } + + private Set assertStatsFacetedResponse(SearchResponse response, String label, int metricsCount) throws Exception + { + response.getContext().assertThat().field("facets").isNotEmpty(); + RestGenericFacetResponseModel facetResponseModel = response.getContext().getFacets().get(0); + facetResponseModel.assertThat().field("type").is("stats"); + facetResponseModel.assertThat().field("label").is(label); + RestGenericBucketModel bucket = facetResponseModel.getBuckets().get(0); + List metrics = bucket.getMetrics(); + assertEquals(metrics.size(),metricsCount); + return metrics.stream().map(m -> m.getType()).collect(Collectors.toSet()); + } + +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/search/solr/SearchSolrAPITest.java b/e2e-test/src/test/java/org/alfresco/rest/search/solr/SearchSolrAPITest.java new file mode 100644 index 000000000..0f1ed9f06 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/search/solr/SearchSolrAPITest.java @@ -0,0 +1,120 @@ +/* + * Copyright (C) 2018 Alfresco Software Limited. + * This file is part of Alfresco + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.rest.search.solr; + +import java.net.URLEncoder; + +import javax.json.JsonArrayBuilder; + +import org.alfresco.rest.core.JsonBodyGenerator; +import org.alfresco.rest.model.RestTextResponse; +import org.alfresco.rest.search.AbstractSearchTest; +import org.alfresco.utility.model.TestGroup; +import org.hamcrest.Matchers; +import org.springframework.http.HttpStatus; +import org.testng.Assert; +import org.testng.annotations.Test; + +/** + * Tests for solr/alfresco Solr API. + * + * @author Meenal Bhave + */ +public class SearchSolrAPITest extends AbstractSearchTest +{ + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_112 }, priority = 01) + public void testGetSolrConfig() throws Exception + { + RestTextResponse response = restClient.authenticateUser(adminUserModel).withSolrAPI().getConfig(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + restClient.onResponse().assertThat().content(Matchers.containsString("config")); + Assert.assertNotNull(response.getJsonValueByPath("config.requestHandler")); + Assert.assertNotNull(response.getJsonObjectByPath("config.requestHandler")); + + // TODO: Following asserts fail with error: + /* + * java.lang.IllegalStateException: Expected response body to be verified as JSON, HTML or XML but content-type 'text/plain' is not supported out of the box. + * Try registering a custom parser using: RestAssured.registerParser("text/plain", ); + */ + + // response.assertThat().body("config.requestHandler", Matchers.notNullValue()); + // restClient.onResponse().assertThat().body("config.requestHandler",Matchers.notNullValue()); + } + + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_112 }, priority = 02) + public void testEditSolrConfig() throws Exception + { + String expectedError = "solrconfig editing is not enabled due to disable.configEdit"; + + JsonArrayBuilder argsArray = JsonBodyGenerator.defineJSONArray(); + argsArray.add("ANYARGS"); + + String postBody = JsonBodyGenerator.defineJSON() + .add("add-listener", JsonBodyGenerator.defineJSON() + .add("event", "postCommit") + .add("name", "newlistener") + .add("class", "solr.RunExecutableListener") + .add("exe", "ANYCOMMAND") + .add("dir", "/usr/bin/") + .add("args", argsArray)).build().toString(); + + // RestTextResponse response = + restClient.authenticateUser(adminUserModel).withSolrAPI().postConfig(postBody); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + + restClient.onResponse().assertThat().content(Matchers.containsString(expectedError)); + + // TODO: Following asserts fail with error: + /* + * java.lang.IllegalStateException: Expected response body to be verified as JSON, HTML or XML but content-type 'text/plain' is not supported out of the box. + * Try registering a custom parser using: RestAssured.registerParser("text/plain", ); + */ + + // response.assertThat().body("error.msg", Matchers.contains(expectedError)); + } + + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_112 }, priority = 03) + public void testGetSolrConfigOverlay() throws Exception + { + restClient.authenticateUser(adminUserModel).withSolrAPI().getConfigOverlay(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + restClient.onResponse().assertThat().content(Matchers.containsString("overlay")); + } + + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_112 }, priority = 04) + public void testGetSolrConfigParams() throws Exception + { + restClient.authenticateUser(adminUserModel).withSolrAPI().getConfigParams(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + restClient.onResponse().assertThat().content(Matchers.containsString("response")); + } + + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_112 }, priority = 05) + public void testGetSolrSelect() throws Exception + { + String queryParams = "{!xmlparser v=''}"; + + String encodedQueryParams = URLEncoder.encode(queryParams, "UTF-8"); + + restClient.authenticateUser(dataContent.getAdminUser()).withParams(encodedQueryParams).withSolrAPI().getSelectQuery(); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + String errorMsg = "No QueryObjectBuilder defined for node a in {q={!xmlparser"; + Assert.assertTrue(restClient.onResponse().getResponse().body().xmlPath().getString("response").contains(errorMsg)); + } +} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/rest/search/sql/SearchSQLAPITest.java b/e2e-test/src/test/java/org/alfresco/rest/search/sql/SearchSQLAPITest.java new file mode 100644 index 000000000..3335e85c5 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/search/sql/SearchSQLAPITest.java @@ -0,0 +1,781 @@ +/* + * Copyright (C) 2018 Alfresco Software Limited. + * This file is part of Alfresco + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.rest.search.sql; + +import static java.util.Arrays.asList; + +import static org.hamcrest.Matchers.containsInAnyOrder; +import static org.hamcrest.Matchers.empty; +import static org.hamcrest.Matchers.equalToIgnoringCase; +import static org.hamcrest.Matchers.everyItem; +import static org.hamcrest.Matchers.greaterThan; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.isIn; +import static org.hamcrest.Matchers.not; + +import org.alfresco.rest.core.RestResponse; +import org.alfresco.rest.search.AbstractSearchTest; +import org.alfresco.rest.search.SearchSqlRequest; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.hamcrest.Matchers; +import org.springframework.http.HttpStatus; +import org.testng.Assert; +import org.testng.annotations.Test; + +/** + * Tests for /sql end point Search API. + * + * @author Meenal Bhave + */ +public class SearchSQLAPITest extends AbstractSearchTest +{ + /** + * Path selector to get the values of all cm_name entries for returned search results. + *

        + * For example it will retrieve the "alfresco.txt" from: + *

        +     * {"list": {
        +     *    "entries": [
        +     *       {"entry": [{
        +     *          "label": "cm_name",
        +     *          "value": "alfresco.txt"
        +     *       }]},
        +     *       ...
        +     * 
        + */ + private static final String CM_NAME_VALUES = "list.entries.collect {it.entry.findAll {it.label == 'cm_name'}}.flatten().value"; + String sql = "select SITE, CM_OWNER from alfresco group by SITE,CM_OWNER"; + String[] locales = { "en-US" }; + String solrFormat = "solr"; + + /** + * API post: + * { + * "stmt": "select SITE from alfresco", + * "locales" : ["en_US"], + * "format" : "solr", + * "timezone":"", + * "includeMetadata":false + * } + * Example Response: In Solr Format + * { + * "result-set": + * { + * "docs": + * [ + * { + * "SITE": + * [ + * "swsdp" + * ] + * }, + * { + * "SITE": + * [ + * "swsdp" + * ] + * } + * ] + * } + */ + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 01) + public void testWithSolr() throws Exception + { + SearchSqlRequest sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql(sql); + sqlRequest.setFormat(solrFormat); + sqlRequest.setLocales(locales); + + restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest); + restClient.assertStatusCodeIs(HttpStatus.OK); + + restClient.onResponse().assertThat().body("result-set", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("result-set.docs", Matchers.notNullValue()); + } + + /** + * API post example: + * { + * "stmt": "select SITE from alfresco", + * "locales" : ["en_US"], + * "format" : "json", + * "timezone":"", + * "includeMetadata":false + * } + * Example Response: In json Format + * { + * "list": + * { + * "pagination": + * { + "count": 103, + "hasMoreItems": false, + "totalItems": 103, + "skipCount": 0, + "maxItems": 1000 + }, + * "entries": + * [ + * "entry": [ + { + "label": "SITE", + "value": "[\"swsdp\"]" + } + ], + "entry": [ + { + "label": "SITE", + "value": "[\"swsdp\"]" + } + ] + * ] + * } + */ + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 02) + public void testWithJson() throws Exception + { + SearchSqlRequest sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql(sql); + sqlRequest.setLocales(locales); + // Format not set + + restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest); + restClient.assertStatusCodeIs(HttpStatus.OK); + + restClient.onResponse().assertThat().body("result-set", Matchers.nullValue()); + restClient.onResponse().assertThat().body("list.entries", Matchers.notNullValue()); + + sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql(sql); + sqlRequest.setLocales(locales); + sqlRequest.setFormat("json"); // Format json + + restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest); + restClient.assertStatusCodeIs(HttpStatus.OK); + + restClient.onResponse().assertThat().body("result-set", Matchers.nullValue()); + restClient.onResponse().assertThat().body("list.entries", Matchers.notNullValue()); + + sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql(sql); + sqlRequest.setLocales(locales); + sqlRequest.setFormat("abcd"); // Format any other than solr + + restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest); + restClient.assertStatusCodeIs(HttpStatus.OK); + + restClient.onResponse().assertThat().body("result-set", Matchers.nullValue()); + restClient.onResponse().assertThat().body("list.entries", Matchers.notNullValue()); + } + + /** + * API post: + * { + * "stmt": "select SITE from alfresco", + * "locales" : ["en_US"], + * "format" : "solr", + * "timezone":"", + * "includeMetadata":true + * } + * Example Response: In Solr Format: Includes metadata: aliases, fields, isMetadata=true + * { + * "result-set": { + * "docs": [ + * { + * "aliases": { + * "SITE": "SITE" + * }, + * "isMetadata": true, + * "fields": [ + * "SITE" + * ] + * }, + * { + * "SITE": [ + * "swsdp" + * ] + * }, + * { + * "SITE": [ + * "swsdp" + * ] + * }, + * { + * "RESPONSE_TIME": 79, + * "EOF": true + * } + * ] + * } + * } + */ + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 03) + public void testWithSolrIncludeMetadata() throws Exception + { + SearchSqlRequest sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql(sql); + sqlRequest.setFormat(solrFormat); + sqlRequest.setLocales(locales); + sqlRequest.setIncludeMetadata(true); + + searchSql(sqlRequest); + + restClient.assertStatusCodeIs(HttpStatus.OK); + + restClient.onResponse().assertThat().body("result-set", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("result-set.docs", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("result-set.docs[0].aliases.SITE", equalToIgnoringCase("SITE")); + restClient.onResponse().assertThat().body("result-set.docs[0].isMetadata", is(true)); + restClient.onResponse().assertThat().body("result-set.docs[0].fields[0]", equalToIgnoringCase("SITE")); + } + + /** + * API post example: + * { + * "stmt": "select SITE from alfresco limit 2", + * "locales" : ["en_US"], + * "format" : "json", + * "timezone":"", + * "includeMetadata":false + * } + * Example Response: In json Format + * { + * "list": + * { + * "pagination": + * { + "count": 3, + "hasMoreItems": false, + "totalItems": 3, + "skipCount": 0, + "maxItems": 1000 + }, + * "entries": + * [ + * "entry": [ + { + "label": "aliases", + "value": "{\"SITE\":\"SITE\"}" + }, + { + "label": "isMetadata", + "value": "true" + }, + { + "label": "fields", + "value": "[\"SITE\"]" + } + ] + }, + * "entry": [ + { + "label": "SITE", + "value": "[\"swsdp\"]" + } + ], + "entry": [ + { + "label": "SITE", + "value": "[\"swsdp\"]" + } + ] + * ] + * } + */ + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 04) + public void testWithJsonIncludeMetadata() throws Exception + { + SearchSqlRequest sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql(sql); + sqlRequest.setFormat(""); + sqlRequest.setLocales(locales); + sqlRequest.setIncludeMetadata(true); + + searchSql(sqlRequest); + + restClient.assertStatusCodeIs(HttpStatus.OK); + + restClient.onResponse().assertThat().body("result-set", Matchers.nullValue()); + restClient.onResponse().assertThat().body("list.entries", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", equalToIgnoringCase("aliases")); + restClient.onResponse().assertThat().body("list.entries.entry[0][0].value", equalToIgnoringCase("{\"SITE\":\"SITE\",\"cm_owner\":\"CM_OWNER\"}")); + restClient.onResponse().assertThat().body("list.entries.entry[0][1].label", equalToIgnoringCase("isMetadata")); + restClient.onResponse().assertThat().body("list.entries.entry[0][1].value", is("true")); + restClient.onResponse().assertThat().body("list.entries.entry[0][2].label", equalToIgnoringCase("fields")); + restClient.onResponse().assertThat().body("list.entries.entry[0][2].value", equalToIgnoringCase("[\"SITE\",\"cm_owner\"]")); + } + + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 05) + public void testIncludeMetadataFalse() throws Exception + { + SearchSqlRequest sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql(sql); + sqlRequest.setFormat("solr"); // Format solr + sqlRequest.setIncludeMetadata(false); + + restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest); + restClient.assertStatusCodeIs(HttpStatus.OK); + + restClient.onResponse().assertThat().body("result-set", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("result-set.docs", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("result-set.docs[0].aliases", Matchers.nullValue()); + restClient.onResponse().assertThat().body("result-set.docs[0].isMetadata", Matchers.nullValue()); + restClient.onResponse().assertThat().body("result-set.docs[0].fields", Matchers.nullValue()); + + sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql(sql); + sqlRequest.setIncludeMetadata(false); + sqlRequest.setFormat("json"); // Format json + + restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest); + restClient.assertStatusCodeIs(HttpStatus.OK); + + restClient.onResponse().assertThat().body("result-set", Matchers.nullValue()); + restClient.onResponse().assertThat().body("list.entries", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", not("aliases")); + + sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql(sql); + sqlRequest.setIncludeMetadata(false); // Format not set + + restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest); + restClient.assertStatusCodeIs(HttpStatus.OK); + + restClient.onResponse().assertThat().body("result-set", Matchers.nullValue()); + restClient.onResponse().assertThat().body("list.entries", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", not("aliases")); + + sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql(sql); + sqlRequest.setFormat(solrFormat); // IncludeMetadata = false when not specified + + restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest); + restClient.assertStatusCodeIs(HttpStatus.OK); + + restClient.onResponse().assertThat().body("result-set", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("result-set.docs", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("result-set.docs[0].aliases", Matchers.nullValue()); + restClient.onResponse().assertThat().body("result-set.docs[0].isMetadata", Matchers.nullValue()); + restClient.onResponse().assertThat().body("result-set.docs[0].fields", Matchers.nullValue()); + } + + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 06) + public void testLocales() throws Exception + { + String[] noLocales = {}; // Not specified + + SearchSqlRequest sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql(sql); + sqlRequest.setLocales(noLocales); + + searchSql(sqlRequest); + + restClient.assertStatusCodeIs(HttpStatus.OK); + + String[] singleLocale = { "en-Uk" }; + + sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql(sql); + sqlRequest.setLocales(singleLocale); + + searchSql(sqlRequest); + + restClient.assertStatusCodeIs(HttpStatus.OK); + + String[] multipleLocales = { "en-US", "ja" }; + + sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql(sql); + sqlRequest.setLocales(multipleLocales); + + searchSql(sqlRequest); + + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 07) + public void testTimezone() throws Exception + { + String timezone = ""; // Not specified + + SearchSqlRequest sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql(sql); + sqlRequest.setTimezone(timezone); + + searchSql(sqlRequest); + + restClient.assertStatusCodeIs(HttpStatus.OK); + + timezone = "UTC"; // UTC + + sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql(sql); + sqlRequest.setTimezone(timezone); + + searchSql(sqlRequest); + + restClient.assertStatusCodeIs(HttpStatus.OK); + + timezone = "false"; // Invalid timezone is ignored + + sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql(sql); + sqlRequest.setTimezone(timezone); + + searchSql(sqlRequest); + + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 8) + public void testAggregateSQL() throws Exception + { + String agSql = "select count(*) FROM alfresco where TYPE='cm:content'"; + + SearchSqlRequest sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql(agSql); + + RestResponse response = searchSql(sqlRequest); + + restClient.assertStatusCodeIs(HttpStatus.OK); + response.assertThat().body("list.entries", Matchers.notNullValue()); + response.assertThat().body("list.entries.entry[0][0].value", not("0")); + } + + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 9) + public void testLimit() throws Exception + { + Integer defaultLimit = 1000; + + Integer limit = null; // Limit defaults to the default setting when null + + SearchSqlRequest sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql(sql); + sqlRequest.setLimit(limit); + + RestResponse response = searchSql(sqlRequest); + + restClient.assertStatusCodeIs(HttpStatus.OK); + response.assertThat().body("list.pagination.maxItems", Matchers.equalTo(defaultLimit)); + + limit = 0; // Limit defaults to the default setting when 0 + sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql(sql); + sqlRequest.setLimit(limit); + + response = searchSql(sqlRequest); + + restClient.assertStatusCodeIs(HttpStatus.OK); + response.assertThat().body("list.pagination.maxItems", Matchers.equalTo(defaultLimit)); + + limit = 100; // Limit is applied correctly, with maxItems = limit + sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql(sql); + sqlRequest.setLimit(limit); + + response = searchSql(sqlRequest); + + restClient.assertStatusCodeIs(HttpStatus.OK); + response.assertThat().body("list.pagination.maxItems", Matchers.equalTo(limit)); + } + + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 10) + public void testAuthenticationError() throws Exception + { + UserModel dummyUser = dataUser.createRandomTestUser("UserSearchDummy"); + dummyUser.setPassword("incorrect-password"); + + SearchSqlRequest sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql(sql); + sqlRequest.setLocales(locales); + + restClient.authenticateUser(dummyUser).withSearchSqlAPI().searchSql(sqlRequest); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + } + + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 11) + public void testPermissions() throws Exception + { + UserModel userNoPerm = dataUser.createRandomTestUser("UserSearchNoPerm"); + UserModel userPerm = dataUser.createRandomTestUser("UserSearchPerm"); + + dataUser.addUserToSite(userPerm, siteModel, UserRole.SiteContributor); + + String siteSQL = "select SITE, CM_OWNER from alfresco where SITE='" + siteModel.getId() + "'"; + SearchSqlRequest sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql(siteSQL); + + // 0 results expected for query as User does not have access to the private site + restClient.authenticateUser(userNoPerm).withSearchSqlAPI().searchSql(sqlRequest); + restClient.assertStatusCodeIs(HttpStatus.OK); + + restClient.onResponse().assertThat().body("list.pagination.count", is(0)); + restClient.onResponse().assertThat().body("list.pagination.totalItems", is(0)); + restClient.onResponse().assertThat().body("list.pagination.hasMoreItems", is(false)); + restClient.onResponse().assertThat().body("list.entries", empty()); + + // Results expected for query as User does has access to the private site + restClient.authenticateUser(userPerm).withSearchSqlAPI().searchSql(sqlRequest); + restClient.assertStatusCodeIs(HttpStatus.OK); + + restClient.onResponse().assertThat().body("list.pagination.count", greaterThan(0)); + restClient.onResponse().assertThat().body("list.pagination.totalItems", greaterThan(0)); + restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", equalToIgnoringCase("SITE")); + restClient.onResponse().assertThat().body("list.entries.entry[0][0].value", equalToIgnoringCase("[\"" + siteModel.getId() + "\"]")); + } + + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 12) + public void testErrors() throws Exception + { + String incorrectSQL = ""; // Missing SQL + + SearchSqlRequest sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql(incorrectSQL); + + restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + restClient.onResponse().assertThat().body("error.briefSummary", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("error.briefSummary", Matchers.containsString("Required stmt parameter is missing")); + + incorrectSQL = "select SITE from unknownTable"; // Wrong table name + + sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql(incorrectSQL); + + restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + restClient.onResponse().assertThat().body("error.briefSummary", Matchers.notNullValue()); + // restClient.onResponse().assertThat().body("error.briefSummary", Matchers.containsString("Table 'unknownTable' not found")); + + incorrectSQL = "select Column1 from alfresco"; // Wrong ColumnName + + sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql(incorrectSQL); + + restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + restClient.onResponse().assertThat().body("error.briefSummary", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("error.briefSummary", Matchers.containsString("Column 'Column1' not found")); + + incorrectSQL = "select SITE alfresco"; // BAD SQL Grammar: from missing + + sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql(incorrectSQL); + + restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + restClient.onResponse().assertThat().body("error.briefSummary", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("error.briefSummary", Matchers.containsString("Unable to execute the query")); + + incorrectSQL = "select SITE, CM_OWNER from alfresco group by SITE"; // BAD SQL Grammar: CM_OWNER is not being grouped + + sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql(incorrectSQL); + + restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + restClient.onResponse().assertThat().body("error.briefSummary", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("error.briefSummary", Matchers.containsString("Expression 'CM_OWNER' is not being grouped")); + + incorrectSQL = "delete SITE from alfresco"; // BAD SQL Grammar + + sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql(incorrectSQL); + + restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + restClient.onResponse().assertThat().body("error.briefSummary", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("error.briefSummary", Matchers.containsString("Was expecting one of")); + } + + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.NOT_INSIGHT_ENGINE }, priority = 13) + public void testErrorForSQLAPIWithASS() throws Exception + { + String acsVersion = serverHealth.getAlfrescoVersion(); + HttpStatus expectedStatus = HttpStatus.OK; + + SearchSqlRequest sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql(sql); + sqlRequest.setLocales(locales); + + // Set expected result based on ACS Version and ASS Version + if (!acsVersion.startsWith("6")) + { + expectedStatus = HttpStatus.NOT_FOUND; + } + else + { + expectedStatus = HttpStatus.BAD_REQUEST; + } + + restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest); + restClient.assertStatusCodeIs(expectedStatus); + } + + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 14) + public void testSelectStar() throws Exception + { + // Select * with Limit, json format + SearchSqlRequest sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql("select * from alfresco"); + sqlRequest.setLimit(1); + + RestResponse response = searchSql(sqlRequest); + + restClient.assertStatusCodeIs(HttpStatus.OK); + response.assertThat().body("list.pagination.maxItems", Matchers.equalTo(1)); + restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", equalToIgnoringCase("PATH")); + + // Select * with Limit, solr format: Also covered in JDBC + sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql("select * from alfresco"); + sqlRequest.setFormat("solr"); + sqlRequest.setIncludeMetadata(true); + sqlRequest.setLimit(1); + + response = searchSql(sqlRequest); + + restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.onResponse().assertThat().body("result-set.docs[0].aliases.cm_name", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("result-set.docs[0].aliases.cm_created", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("result-set.docs[0].aliases.cm_creator", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("result-set.docs[0].aliases.cm_modified", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("result-set.docs[0].aliases.cm_modifier", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("result-set.docs[0].aliases.cm_owner", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("result-set.docs[0].aliases.OWNER", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("result-set.docs[0].aliases.TYPE", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("result-set.docs[0].aliases.LID", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("result-set.docs[0].aliases.DBID", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("result-set.docs[0].aliases.cm_title", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("result-set.docs[0].aliases.cm_description", Matchers.notNullValue()); + + // This type of assertion is required because of a '.' in the field name + Assert.assertTrue(response.getResponse().body().jsonPath().get("result-set.docs[0].aliases").toString().contains("cm_content.size=cm_content.size")); + Assert.assertTrue(response.getResponse().body().jsonPath().get("result-set.docs[0].aliases").toString().contains("cm_content.mimetype=cm_content.mimetype")); + Assert.assertTrue(response.getResponse().body().jsonPath().get("result-set.docs[0].aliases").toString().contains("cm_content.encoding=cm_content.encoding")); + Assert.assertTrue(response.getResponse().body().jsonPath().get("result-set.docs[0].aliases").toString().contains("cm_content.locale=cm_content.locale")); + + restClient.onResponse().assertThat().body("result-set.docs[0].aliases.cm_lockOwner", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("result-set.docs[0].aliases.SITE", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("result-set.docs[0].aliases.PARENT", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("result-set.docs[0].aliases.PATH", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("result-set.docs[0].aliases.PRIMARYPARENT", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("result-set.docs[0].aliases.ASPECT", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("result-set.docs[0].aliases.QNAME", Matchers.notNullValue()); + + // Test that cm_content and any other random field does not appear in the response + restClient.onResponse().assertThat().body("result-set.docs[0].aliases.cm_content", Matchers.nullValue()); + restClient.onResponse().assertThat().body("result-set.docs[0].aliases.RandomNonExistentField", Matchers.nullValue()); + } + + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 15) + public void testDistinct() throws Exception + { + // Select distinct site: json format + SearchSqlRequest sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql("select distinct Site from alfresco"); + sqlRequest.setLimit(10); + + RestResponse response = searchSql(sqlRequest); + + restClient.assertStatusCodeIs(HttpStatus.OK); + response.assertThat().body("list.pagination.maxItems", Matchers.equalTo(10)); + restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", equalToIgnoringCase("site")); + + // Select distinct cm_name: solr format + sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql("select distinct cm_name from alfresco limit 5"); + sqlRequest.setFormat("solr"); + + searchSql(sqlRequest); + + restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.onResponse().assertThat().body("result-set.docs[0].cm_name", Matchers.notNullValue()); + } + + /** Check that a filter query can affect which results are included. */ + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_11 }, priority = 16) + public void testFilterQuery() throws Exception + { + SearchSqlRequest sqlRequest = new SearchSqlRequest(); + String siteSQL = "select SITE, CM_OWNER from alfresco where SITE='" + siteModel.getId() + "'"; + sqlRequest.setSql(siteSQL); + // Add a filter query to only include results from inside the site (i.e. all results). + String[] filterQuery = { "SITE:'" + siteModel.getId() + "'" }; + sqlRequest.setFilterQuery(filterQuery); + + searchSql(sqlRequest); + + restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.onResponse().assertThat().body("list.pagination.count", greaterThan(0)); + restClient.onResponse().assertThat().body("list.pagination.totalItems", greaterThan(0)); + restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", equalToIgnoringCase("SITE")); + restClient.onResponse().assertThat().body("list.entries.entry[0][0].value", equalToIgnoringCase("[\"" + siteModel.getId() + "\"]")); + + // Now try instead removing everything from the site (i.e. all results). + String[] inverseFilterQuery = { "-SITE:'" + siteModel.getId() + "'" }; + sqlRequest.setFilterQuery(inverseFilterQuery); + + searchSql(sqlRequest); + + restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.onResponse().assertThat().body("list.pagination.count", is(0)); + restClient.onResponse().assertThat().body("list.pagination.totalItems", is(0)); + restClient.onResponse().assertThat().body("list.pagination.hasMoreItems", is(false)); + restClient.onResponse().assertThat().body("list.entries", empty()); + } + + /** Check that the combination of multiple filter queries produce the intersection of results. */ + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_11 }, priority = 17) + public void testCombiningFilterQueries() throws Exception + { + String siteSQL = "select cm_name from alfresco where SITE='" + siteModel.getId() + "'"; + SearchSqlRequest sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql(siteSQL); + // Add a filter query to only include results from inside the site (i.e. all results). + String[] filterQueries = { "-cm_name:'cars'", "-cm_name:'pangram'" }; + sqlRequest.setFilterQuery(filterQueries); + + searchSql(sqlRequest); + + restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.onResponse().assertThat().body("list.pagination.count", greaterThan(0)); + restClient.onResponse().assertThat().body("list.pagination.totalItems", greaterThan(0)); + // Check that pangram.txt and cars.txt were both filtered out. + restClient.onResponse().assertThat() + .body(CM_NAME_VALUES, everyItem(not(isIn(asList("pangram.txt", "cars.txt"))))); + } + + /** Check that an empty list of filter queries doesn't remove anything from the results. */ + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_11 }, priority = 18) + public void testEmptyFilterQuery() throws Exception + { + String siteSQL = "select cm_name from alfresco where SITE='" + siteModel.getId() + "'"; + SearchSqlRequest sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql(siteSQL); + // Add an empty list of filter queries. + sqlRequest.setFilterQuery(new String[]{}); + + searchSql(sqlRequest); + + restClient.assertStatusCodeIs(HttpStatus.OK); + // Check that the cm_names of all nodes in the site are returned. + restClient.onResponse().assertThat() + .body(CM_NAME_VALUES, containsInAnyOrder("documentLibrary", SEARCH_DATA_SAMPLE_FOLDER, "pangram.txt", "cars.txt", "alfresco.txt", unique_searchString + ".txt")); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/search/sql/SearchSQLPhraseTest.java b/e2e-test/src/test/java/org/alfresco/rest/search/sql/SearchSQLPhraseTest.java new file mode 100644 index 000000000..86551eb09 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/search/sql/SearchSQLPhraseTest.java @@ -0,0 +1,256 @@ +/* + * Copyright (C) 2018 Alfresco Software Limited. + * This file is part of Alfresco + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.rest.search.sql; + +import java.sql.ResultSet; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import java.util.Map; + +import org.alfresco.rest.core.RestResponse; +import org.alfresco.rest.search.AbstractSearchTest; +import org.alfresco.rest.search.SearchSqlJDBCRequest; +import org.alfresco.rest.search.SearchSqlRequest; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FileType; +import org.alfresco.utility.model.TestGroup; +import org.springframework.http.HttpStatus; +import org.testng.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; +import org.hamcrest.Matchers; + +/** + * Tests for /sql end point Search API: Phrase Searching. + * + * @author Meenal Bhave + */ +public class SearchSQLPhraseTest extends AbstractSearchTest +{ + FileModel fileBanana, fileYellowBanana, fileBigYellowBanana, fileBigBananaBoat, fileYellowBananaBigBoat, fileBigYellowBoat; + + List expectedContent = new ArrayList(); + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + super.dataPreparation(); + + // Create files with different phrases + fileBanana = new FileModel(unique_searchString + "-1.txt", "banana", "phrase searching", FileType.TEXT_PLAIN, "banana"); + dataContent.usingUser(userModel).usingSite(siteModel).createContent(fileBanana); + + fileYellowBanana = new FileModel(unique_searchString + "-2.txt", "yellow banana", "phrase searching", FileType.TEXT_PLAIN, "yellow banana"); + dataContent.usingUser(userModel).usingSite(siteModel).createContent(fileYellowBanana); + + fileBigYellowBanana = new FileModel(unique_searchString + "-3.txt", "big yellow banana", "phrase searching", FileType.TEXT_PLAIN, "big yellow banana"); + dataContent.usingUser(userModel).usingSite(siteModel).createContent(fileBigYellowBanana); + + fileBigBananaBoat = new FileModel(unique_searchString + "-4.txt", "big boat", "phrase searching", FileType.TEXT_PLAIN, "big boat"); + dataContent.usingUser(userModel).usingSite(siteModel).createContent(fileBigBananaBoat); + + fileYellowBananaBigBoat = new FileModel(unique_searchString + "-5.txt", "yellow banana big boat", "phrase searching", FileType.TEXT_PLAIN, "yellow banana big boat"); + dataContent.usingUser(userModel).usingSite(siteModel).createContent(fileYellowBananaBigBoat); + + fileBigYellowBoat = new FileModel(unique_searchString + "-6.txt", "big yellow boat", "phrase searching", FileType.TEXT_PLAIN, "big yellow boat"); + dataContent.usingUser(userModel).usingSite(siteModel).createContent(fileBigYellowBoat); + + waitForIndexing(fileBigYellowBoat.getName(), true); + } + + @SuppressWarnings("unchecked") + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 1) + public void testPhraseQueries() throws Exception + { + // yellow banana: 5 results expected + SearchSqlRequest sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql("select cm_content from alfresco where cm_content = '(yellow banana)'"); + sqlRequest.setLimit(10); + + RestResponse response = searchSql(sqlRequest); + + restClient.assertStatusCodeIs(HttpStatus.OK); + + // Set Expected Result + expectedContent = new ArrayList(); + expectedContent.add(Arrays.asList(fileBanana.getContent())); + expectedContent.add(Arrays.asList(fileYellowBanana.getContent())); + expectedContent.add(Arrays.asList(fileBigYellowBanana.getContent())); + expectedContent.add(Arrays.asList(fileYellowBananaBigBoat.getContent())); + expectedContent.add(Arrays.asList(fileBigYellowBoat.getContent())); + + // Check Result count matches + response.assertThat().body("list.pagination.count", Matchers.equalTo(expectedContent.size())); + + // Check Results match + Collection> actualContent = response.getResponse().body().jsonPath().get("list.entries.entry.value"); + Assert.assertTrue(actualContent.containsAll(expectedContent), String.format("Phrase Search Results expected: %s Actual: %s", expectedContent.toString(), actualContent.toString())); + Assert.assertTrue(expectedContent.containsAll(actualContent), String.format("Phrase Search Results expected: %s Actual: %s", expectedContent.toString(), actualContent.toString())); + + // yellow banana big boat: 6 results expected + sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql("select cm_content from alfresco where cm_content = '(yellow banana big boat)'"); + sqlRequest.setLimit(10); + + response = searchSql(sqlRequest); + + restClient.assertStatusCodeIs(HttpStatus.OK); + + // Set Expected Result + expectedContent = new ArrayList(); + expectedContent.add(Arrays.asList(fileBanana.getContent())); + expectedContent.add(Arrays.asList(fileYellowBanana.getContent())); + expectedContent.add(Arrays.asList(fileBigYellowBanana.getContent())); + expectedContent.add(Arrays.asList(fileYellowBananaBigBoat.getContent())); + expectedContent.add(Arrays.asList(fileBigYellowBoat.getContent())); + expectedContent.add(Arrays.asList(fileBigBananaBoat.getContent())); + + // Check Result count matches + response.assertThat().body("list.pagination.count", Matchers.equalTo(expectedContent.size())); + + // Check Results match + actualContent = response.getResponse().body().jsonPath().get("list.entries.entry.value"); + Assert.assertTrue(actualContent.containsAll(expectedContent), String.format("Phrase Search Results expected: %s Actual: %s", expectedContent.toString(), actualContent.toString())); + Assert.assertTrue(expectedContent.containsAll(actualContent), String.format("Phrase Search Results expected: %s Actual: %s", expectedContent.toString(), actualContent.toString())); + + // yellow banana big boat: 4 results expected + sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql("select cm_content from alfresco where cm_content = '(big boat)'"); + sqlRequest.setLimit(10); + + response = searchSql(sqlRequest); + + restClient.assertStatusCodeIs(HttpStatus.OK); + + // Set Expected Result + expectedContent = new ArrayList(); + expectedContent.add(Arrays.asList(fileBigYellowBanana.getContent())); + expectedContent.add(Arrays.asList(fileYellowBananaBigBoat.getContent())); + expectedContent.add(Arrays.asList(fileBigYellowBoat.getContent())); + expectedContent.add(Arrays.asList(fileBigBananaBoat.getContent())); + + // Check Result count matches + response.assertThat().body("list.pagination.count", Matchers.equalTo(expectedContent.size())); + + // Check Results match + actualContent = response.getResponse().body().jsonPath().get("list.entries.entry.value"); + Assert.assertTrue(actualContent.containsAll(expectedContent), String.format("Phrase Search Results expected: %s Actual: %s", expectedContent.toString(), actualContent.toString())); + Assert.assertTrue(expectedContent.containsAll(actualContent), String.format("Phrase Search Results expected: %s Actual: %s", expectedContent.toString(), actualContent.toString())); + } + + @SuppressWarnings("unchecked") + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 2) + public void testPhraseQueriesViaJDBC() throws Exception + { + // yellow banana: 5 results expected + SearchSqlJDBCRequest sqlRequest = new SearchSqlJDBCRequest(); + String sql = "select cm_content from alfresco where cm_content = '(yellow banana)'"; + sqlRequest.setSql(sql); + sqlRequest.setAuthUser(userModel); + + ResultSet rs = restClient.withSearchSqlViaJDBC().executeQueryViaJDBC(sqlRequest); + Assert.assertNotNull(rs); + Assert.assertNull(sqlRequest.getErrorDetails()); + + // Set Expected Result + expectedContent = new ArrayList(); + expectedContent.add(Arrays.asList(fileBanana.getContent())); + expectedContent.add(Arrays.asList(fileYellowBanana.getContent())); + expectedContent.add(Arrays.asList(fileBigYellowBanana.getContent())); + expectedContent.add(Arrays.asList(fileYellowBananaBigBoat.getContent())); + expectedContent.add(Arrays.asList(fileBigYellowBoat.getContent())); + + Integer i = 0; + List actualContent = new ArrayList(); + + while (rs.next()) + { + // Field values are retrieved + Assert.assertNotNull(rs.getString("cm_content")); + actualContent.add(Arrays.asList(rs.getString("cm_content"))); + i++; + } + + Assert.assertTrue(i == expectedContent.size()); + Assert.assertTrue(actualContent.containsAll(expectedContent), String.format("Phrase Search Results expected: %s Actual: %s", expectedContent.toString(), actualContent.toString())); + Assert.assertTrue(expectedContent.containsAll(actualContent), String.format("Phrase Search Results expected: %s Actual: %s", expectedContent.toString(), actualContent.toString())); + + // yellow banana big boat: 6 results expected + sql = "select cm_content from alfresco where cm_content = '(yellow banana big boat)'"; + sqlRequest.setSql(sql); + sqlRequest.setAuthUser(userModel); + + rs = restClient.withSearchSqlViaJDBC().executeQueryViaJDBC(sqlRequest); + Assert.assertNotNull(rs); + Assert.assertNull(sqlRequest.getErrorDetails()); + + // Set Expected Result + expectedContent = new ArrayList(); + expectedContent.add(Arrays.asList(fileBanana.getContent())); + expectedContent.add(Arrays.asList(fileYellowBanana.getContent())); + expectedContent.add(Arrays.asList(fileBigYellowBanana.getContent())); + expectedContent.add(Arrays.asList(fileYellowBananaBigBoat.getContent())); + expectedContent.add(Arrays.asList(fileBigYellowBoat.getContent())); + expectedContent.add(Arrays.asList(fileBigBananaBoat.getContent())); + + i = 0; + actualContent = new ArrayList(); + + while (rs.next()) + { + // Field values are retrieved + Assert.assertNotNull(rs.getString("cm_content")); + actualContent.add(Arrays.asList(rs.getString("cm_content"))); + i++; + } + + Assert.assertTrue(i == expectedContent.size()); + Assert.assertTrue(actualContent.containsAll(expectedContent), String.format("Phrase Search Results expected: %s Actual: %s", expectedContent.toString(), actualContent.toString())); + Assert.assertTrue(expectedContent.containsAll(actualContent), String.format("Phrase Search Results expected: %s Actual: %s", expectedContent.toString(), actualContent.toString())); + + // big boat: 4 results expected + sql = "select cm_content from alfresco where cm_content = '(big boat)'"; + sqlRequest.setSql(sql); + sqlRequest.setAuthUser(userModel); + + rs = restClient.withSearchSqlViaJDBC().executeQueryViaJDBC(sqlRequest); + Assert.assertNotNull(rs); + Assert.assertNull(sqlRequest.getErrorDetails()); + + // Set Expected Result + expectedContent = new ArrayList(); + expectedContent.add(Arrays.asList(fileBigYellowBanana.getContent())); + expectedContent.add(Arrays.asList(fileYellowBananaBigBoat.getContent())); + expectedContent.add(Arrays.asList(fileBigYellowBoat.getContent())); + expectedContent.add(Arrays.asList(fileBigBananaBoat.getContent())); + + i = 0; + actualContent = new ArrayList(); + + while (rs.next()) + { + // Field values are retrieved + Assert.assertNotNull(rs.getString("cm_content")); + actualContent.add(Arrays.asList(rs.getString("cm_content"))); + i++; + } + + Assert.assertTrue(i == expectedContent.size()); + Assert.assertTrue(actualContent.containsAll(expectedContent), String.format("Phrase Search Results expected: %s Actual: %s", expectedContent.toString(), actualContent.toString())); + Assert.assertTrue(expectedContent.containsAll(actualContent), String.format("Phrase Search Results expected: %s Actual: %s", expectedContent.toString(), actualContent.toString())); + } +} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/rest/search/sql/SearchSQLViaJDBCTest.java b/e2e-test/src/test/java/org/alfresco/rest/search/sql/SearchSQLViaJDBCTest.java new file mode 100644 index 000000000..eed0bb445 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/search/sql/SearchSQLViaJDBCTest.java @@ -0,0 +1,213 @@ +/* + * Copyright (C) 2018 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.rest.search.sql; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; + +import org.alfresco.dataprep.SiteService.Visibility; +import org.alfresco.rest.requests.search.SearchSQLJDBC; +import org.alfresco.rest.search.AbstractSearchTest; +import org.alfresco.rest.search.SearchSqlJDBCRequest; +import org.alfresco.utility.data.RandomData; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.Test; +import org.testng.Assert; + +/** + * Search SQL end point test via JDBC. + * @author MSuzuki + * @author Meenal Bhave + * + */ +public class SearchSQLViaJDBCTest extends AbstractSearchTest +{ + List sites = new ArrayList(); + SearchSQLJDBC searchSql; + SearchSqlJDBCRequest sqlRequest = new SearchSqlJDBCRequest(); + + @AfterMethod(alwaysRun=true) + public void cleanUp() throws SQLException + { + restClient.withSearchSqlViaJDBC().clearSearchQuery(sqlRequest); + sqlRequest = new SearchSqlJDBCRequest(); + sites = new ArrayList(); + } + + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority=01) + public void testQueryPublicSite() throws SQLException + { + + SiteModel publicSite = new SiteModel(RandomData.getRandomName("SiteSearch")); + publicSite.setVisibility(Visibility.PUBLIC); + + publicSite = dataSite.usingUser(adminUserModel).createSite(publicSite); + + String sql = "select SITE,CM_OWNER from alfresco where SITE ='" + publicSite.getTitle() + "' group by SITE,CM_OWNER"; + sqlRequest.setSql(sql); + sqlRequest.setAuthUser(userModel); + + ResultSet rs = restClient.withSearchSqlViaJDBC().executeQueryViaJDBC(sqlRequest); + + while (rs.next()) + { + // User can see the Public Site created by other user + Assert.assertNotNull(rs.getString("SITE")); + Assert.assertTrue(publicSite.getTitle().equalsIgnoreCase(rs.getString("SITE"))); + + Assert.assertNotNull(rs.getString("CM_OWNER")); + Assert.assertTrue(rs.getString("CM_OWNER").contains(adminUserModel.getUsername())); + } + } + + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority=02) + public void testQueryMyCreatedPrivateSite() throws SQLException + { + String sql = "select distinct SITE from alfresco where SITE ='" + siteModel.getTitle() + "'"; + sqlRequest.setSql(sql); + sqlRequest.setAuthUser(userModel); + + ResultSet rs = restClient.withSearchSqlViaJDBC().executeQueryViaJDBC(sqlRequest); + + while (rs.next()) + { + // User can see Own Private Site + Assert.assertNotNull(rs.getString("SITE")); + Assert.assertTrue(siteModel.getTitle().equalsIgnoreCase(rs.getString("SITE"))); + } + } + + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority=03) + public void testQueryPrivateSiteWithSuperUser() throws SQLException + { + String sql = "select distinct SITE from alfresco where SITE ='" + siteModel.getTitle() + "'"; + sqlRequest.setSql(sql); + sqlRequest.setAuthUser(adminUserModel); + + ResultSet rs = restClient.withSearchSqlViaJDBC().executeQueryViaJDBC(sqlRequest); + + while (rs.next()) + { + // Super user can see Private Site created by other user + Assert.assertNotNull(rs.getString("SITE")); + Assert.assertTrue(siteModel.getTitle().equalsIgnoreCase(rs.getString("SITE"))); + } + } + + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority=04) + public void testQueryPrivateSiteWithSimpleUser() throws SQLException + { + UserModel managerUser = dataUser.createRandomTestUser("UserSearchMgr"); + + String sql = "select SITE from alfresco where SITE = '" + siteModel.getTitle() + "'"; + sqlRequest.setSql(sql); + sqlRequest.setAuthUser(managerUser); + + // Non admin user can NOT see Private Site created by other user + ResultSet rs = restClient.withSearchSqlViaJDBC().executeQueryViaJDBC(sqlRequest); + Assert.assertFalse(rs.next()); + } + + + + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority=05) + public void testQueryErrorReturned() throws SQLException + { + String expectedError = "Column 'SITE1' not found"; + + String sql = "select SITE1 from alfresco"; + sqlRequest.setSql(sql); + sqlRequest.setAuthUser(userModel); + + // Appropriate error is retrieved when SQL is incorrect + ResultSet rs = restClient.withSearchSqlViaJDBC().executeQueryViaJDBC(sqlRequest); + + String error = sqlRequest.getErrorDetails(); + Assert.assertNotNull(error); + Assert.assertTrue(error.contains(expectedError), "Error shown: " + error + " Error expected: " + expectedError); + + // Record set is null + Assert.assertNull(rs); + } + + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 06) + public void testQuerySelectStar() throws SQLException + { + // Select * query with limit clause + String sql = "select * from alfresco limit 5"; + sqlRequest.setSql(sql); + sqlRequest.setAuthUser(userModel); + + // Select * with limit clause works: No error is retrieved + ResultSet rs = restClient.withSearchSqlViaJDBC().executeQueryViaJDBC(sqlRequest); + Assert.assertNotNull(rs); + Assert.assertNull(sqlRequest.getErrorDetails()); + + while (rs.next()) + { + // Field values are retrieved + Assert.assertNotNull(rs.getString("PATH")); + Assert.assertNotNull(rs.getString("DBID")); + Assert.assertNotNull(rs.getString("cm_name")); + } + + // Select * query Without limit clause: No error is retrieved + sql = "select * from alfresco"; + sqlRequest.setSql(sql); + sqlRequest.setAuthUser(userModel); + + // No error is retrieved when SQL is incorrect + rs = restClient.withSearchSqlViaJDBC().executeQueryViaJDBC(sqlRequest); + Assert.assertNotNull(rs); + Assert.assertNull(sqlRequest.getErrorDetails()); + + while (rs.next()) + { + // Field values are retrieved + Assert.assertNotNull(rs.getString("PATH")); + Assert.assertNotNull(rs.getString("DBID")); + Assert.assertNotNull(rs.getString("cm_name")); + } + } + + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 07) + public void testQuerySelectDistinct() throws SQLException + { + // Select distinct query with limit clause + String sql = "select distinct cm_name from alfresco limit 5"; + sqlRequest.setSql(sql); + sqlRequest.setAuthUser(adminUserModel); + + // Select distinct with limit clause works: No error is retrieved + ResultSet rs = restClient.withSearchSqlViaJDBC().executeQueryViaJDBC(sqlRequest); + Assert.assertNotNull(rs); + Assert.assertNull(sqlRequest.getErrorDetails()); + + while (rs.next()) + { + // Field values are retrieved + Assert.assertNotNull(rs.getString("cm_name")); + } + } +} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/rest/search/sql/SearchSQLWithQuotedIdentifiers.java b/e2e-test/src/test/java/org/alfresco/rest/search/sql/SearchSQLWithQuotedIdentifiers.java new file mode 100644 index 000000000..30f773d53 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/search/sql/SearchSQLWithQuotedIdentifiers.java @@ -0,0 +1,218 @@ +/* + * Copyright (C) 2018 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.rest.search.sql; + +import java.util.UUID; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.search.AbstractSearchTest; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.CustomObjectTypeProperties; +import org.alfresco.utility.model.ContentModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FileType; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.report.Bug; +import org.hamcrest.Matchers; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Tests for /sql end point Search API when a custom model contains identifiers that need to be quoted in queries. + * While it seems there is not an ANSI standard for naming database objects, on the other side the most popular + * databases don't like columns starting with a number. + * In those cases, the column identifier need to be quoted. How to quote a given object identifier (a column name, in + * this case) depends on the specific database lexicon: Oracle uses double quotes ("), MySQL uses back quotes(`). + * + * At time of writing, the lexicon used by the /sql endpoint is MySql so queries that use column names starting with + * a number need to be quoted with back quotes. + * + */ +public class SearchSQLWithQuotedIdentifiers extends AbstractSearchTest +{ + + private String songName; + private String genre; + private String coProducer; + + private String artistName; + private String voiceType; + + private String bassistName; + private String drummerName; + private String saxophonistName; + + private FileModel file5; + + /** + * Setup fixture for this test case. + * Overrides the superlayer method because the data preparation requires a bit different preconditions. + * The method uses a transient test site created in the {@link RestTest#checkServerHealth()} and on top of that: + * + *
          + *
        • It adds a user which is added to the site as contributor
        • + *
        • + * It deploys a custom model which declares a set of prefixes composed by a combination of digits, hyphens + * and underscores. Those prefixes are associated with four entities (song, artist, bassist, drummer and + * sax) with their corresponding attributes. + *
        • + *
        • + * It creates a folder with 5 files associated with the types declared in the model. + * That allows those files to have a value for the properties/attributes included in the model definition. + *
        • + *
        + * + * @see RestTest#checkServerHealth() + * @throws Exception hopefully never, otherwise the test fails. + */ + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + songName = "The Dry Cleaner from Des Moines "; + genre = "Jazz, vocal jazz "; + coProducer = "Roberta Joan Mitchell "; + + artistName = "Joni Mitchell " + UUID.randomUUID(); + voiceType = "Blue Mezzo (1965-1984) / Cloudy Contralto (1985-present) "; + + bassistName = "Jaco Pastorius"; + drummerName = "Peter Erskine"; + saxophonistName = "Wayne Shorter"; + + userModel = dataUser.createRandomTestUser(); + + dataContent.usingAdmin().deployContentModel("models/SEARCH-1063.xml"); + + dataUser.addUserToSite(userModel, testSite, UserRole.SiteContributor); + + FolderModel testFolder = dataContent.usingSite(testSite).usingUser(userModel).createFolder(); + + file = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); + file2 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); + file3 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); + file4 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); + file5 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); + + dataContent.usingUser(userModel) + .usingResource(testFolder) + .createCustomContent( + file, + "D:1:song", + new CustomObjectTypeProperties() + .addProperty("1:name", songName) + .addProperty("1:genre", genre) + .addProperty("1:co-producer", coProducer)); + + dataContent.usingUser(userModel) + .usingResource(testFolder) + .createCustomContent( + file2, + "D:123:artist", + new CustomObjectTypeProperties() + .addProperty("123:name", artistName) + .addProperty("123:voice_type", voiceType)); + + dataContent.usingUser(userModel) + .usingResource(testFolder) + .createCustomContent( + file3, + "D:1_2_3:bassist", + new CustomObjectTypeProperties() + .addProperty("1_2_3:name", bassistName)); + + dataContent.usingUser(userModel) + .usingResource(testFolder) + .createCustomContent( + file4, + "D:1-2-3:drummer", + new CustomObjectTypeProperties() + .addProperty("1-2-3:name", drummerName)); + + ContentModel content = + dataContent.usingUser(userModel) + .usingResource(testFolder) + .createCustomContent( + file5, + "D:1-2_3:saxophonist", + new CustomObjectTypeProperties() + .addProperty("1-2_3:name", saxophonistName)); + + waitForIndexing(content.getName(), true); + } + + @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_1}) + @Bug(id = "SEARCH-1063") + public void prefixIsComposedByOneNumber() throws Exception + { + executeSqlAsSolr("select cm_name, `1_name`, `1_genre`, `1_co-producer` from alfresco where TYPE='1:song' and SITE='" + testSite.getId() + "'"); + + restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.onResponse().assertThat().body("result-set.docs[0].cm_name", Matchers.equalTo(file.getName())); + restClient.onResponse().assertThat().body("result-set.docs[0].1_name", Matchers.equalTo(songName)); + restClient.onResponse().assertThat().body("result-set.docs[0].1_genre", Matchers.equalTo(genre)); + restClient.onResponse().assertThat().body("result-set.docs[0].1_co-producer", Matchers.equalTo(coProducer)); + } + + @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_1}) + @Bug(id = "SEARCH-1063") + public void prefixIsComposedByMultipleNumbers() throws Exception + { + executeSqlAsSolr("select cm_name, `123_name`, `123_voice_type` from alfresco where TYPE='123:artist' and SITE='" + testSite.getId() + "'"); + + restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.onResponse().assertThat().body("result-set.docs[0].cm_name", Matchers.equalTo(file2.getName())); + restClient.onResponse().assertThat().body("result-set.docs[0].123_name", Matchers.equalTo(artistName)); + restClient.onResponse().assertThat().body("result-set.docs[0].123_voice_type", Matchers.equalTo(voiceType)); + } + + @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_1}) + @Bug(id = "SEARCH-1063") + public void prefixIncludesUnderscore() throws Exception + { + executeSqlAsSolr("select cm_name, `1_2_3_name` from alfresco where TYPE='1_2_3:bassist' and SITE='" + testSite.getId() + "'"); + + restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.onResponse().assertThat().body("result-set.docs[0].cm_name", Matchers.equalTo(file3.getName())); + restClient.onResponse().assertThat().body("result-set.docs[0].1_2_3_name", Matchers.equalTo(bassistName)); + } + + @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_1}) + @Bug(id = "SEARCH-1063") + public void prefixIncludesHyphen() throws Exception + { + executeSqlAsSolr("select cm_name, `1-2-3_name` from alfresco where TYPE='1-2-3:drummer' and SITE='" + testSite.getId() + "'"); + + restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.onResponse().assertThat().body("result-set.docs[0].cm_name", Matchers.equalTo(file4.getName())); + restClient.onResponse().assertThat().body("result-set.docs[0].1-2-3_name", Matchers.equalTo(drummerName)); + } + + @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_1}) + @Bug(id = "SEARCH-1063") + public void prefixIncludesHyphenAndUnderscore() throws Exception + { + executeSqlAsSolr("select cm_name, `1-2_3_name` from alfresco where TYPE='1-2_3:saxophonist' and SITE='" + testSite.getId() + "'"); + + restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.onResponse().assertThat().body("result-set.docs[0].cm_name", Matchers.equalTo(file5.getName())); + restClient.onResponse().assertThat().body("result-set.docs[0].1-2_3_name", Matchers.equalTo(saxophonistName)); + } +} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/rest/sharedLinks/GetSharedLinksFullTests.java b/e2e-test/src/test/java/org/alfresco/rest/sharedLinks/GetSharedLinksFullTests.java new file mode 100644 index 000000000..c2e3627a6 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/sharedLinks/GetSharedLinksFullTests.java @@ -0,0 +1,75 @@ +package org.alfresco.rest.sharedLinks; + +import javax.json.Json; +import javax.json.JsonObject; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestNodeModel; +import org.alfresco.rest.model.RestSharedLinksModelCollection; +import org.alfresco.utility.exception.DataPreparationException; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class GetSharedLinksFullTests extends RestTest +{ + private SiteModel privateSite; + private UserModel adminUser, userModel; + protected FileModel file; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws DataPreparationException + { + adminUser = dataUser.getAdminUser(); + userModel = dataUser.createRandomTestUser(); + privateSite = dataSite.usingUser(adminUser).createPrivateRandomSite(); + } + + @Bug(id="REPO-2365") + @TestRail(section = { TestGroup.REST_API, + TestGroup.SHAREDLINKS }, executionType = ExecutionType.REGRESSION, description = "Verify that a user with permission can get allowableOperations on sharedLinks") + @Test(groups = { TestGroup.REST_API, TestGroup.SHAREDLINKS, TestGroup.REGRESSION }) + public void getSharedLinksWithAllowableOperations() throws Exception + { + file = dataContent.usingUser(adminUser).usingSite(privateSite).createContent(DocumentType.TEXT_PLAIN); + + /* + * { "permissions": { "isInheritanceEnabled": true, "locallySet": { "authorityId": "userModel.getUsername()", + * "name": "SiteConsumer", "accessStatus":"ALLOWED" } } } + */ + JsonObject userPermission = Json.createObjectBuilder().add("permissions", + Json.createObjectBuilder().add("isInheritanceEnabled", true).add("locallySet", Json.createObjectBuilder() + .add("authorityId", userModel.getUsername()).add("name", "SiteConsumer").add("accessStatus", "ALLOWED"))) + .build(); + String putBody = userPermission.toString(); + restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file).updateNode(putBody); + restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.authenticateUser(adminUser).withCoreAPI().usingSharedLinks().createSharedLink(file); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + // verify that the permision exists + RestNodeModel permissionsRequest = restClient.authenticateUser(userModel).withCoreAPI().usingNode(file) + .usingParams("include=permissions").getNode(); + permissionsRequest.assertThat().field("permissions.locallySet.authorityId").is("[" + userModel.getUsername() + "]"); + + // because the sharedLink take time to be created, we may need to wait for solr to index it. + int numberOfTries = 0; + RestSharedLinksModelCollection operationsRequest; + do + { + Thread.sleep(1000); + numberOfTries++; + operationsRequest = restClient.authenticateUser(userModel).withCoreAPI().usingSharedLinks().usingParams("include=allowableOperations").getSharedLinks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } while (operationsRequest.getPagination().getCount() == 0 && numberOfTries < 15); + operationsRequest.getPagination().assertThat().field("count").is(1); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/sharedLinks/SharedLinksSanityTests.java b/e2e-test/src/test/java/org/alfresco/rest/sharedLinks/SharedLinksSanityTests.java new file mode 100644 index 000000000..c9dbc91fe --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/sharedLinks/SharedLinksSanityTests.java @@ -0,0 +1,276 @@ +package org.alfresco.rest.sharedLinks; + +import javax.json.Json; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestRenditionInfoModel; +import org.alfresco.rest.model.RestRenditionInfoModelCollection; +import org.alfresco.rest.model.RestSharedLinksModel; +import org.alfresco.rest.model.RestSharedLinksModelCollection; +import org.alfresco.utility.Utility; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Class includes Sanity tests for the shared-links api. Detailed tests would be covered in the alfresco-remote-api test project + * + * @author meenal bhave + */ +public class SharedLinksSanityTests extends RestTest +{ + private UserModel adminUser; + private UserModel testUser1; + + private SiteModel siteModel1; + + private FolderModel folder1; + + private FileModel file1; + private FileModel file2; + private FileModel file3; + private FileModel file4; + private FileModel file5; + private FileModel file6; + private FileModel file7; + private FileModel file8; + + private RestSharedLinksModel sharedLink1; + private RestSharedLinksModel sharedLink2; + private RestSharedLinksModel sharedLink3; + private RestSharedLinksModel sharedLink4; + private RestSharedLinksModel sharedLink5; + private RestSharedLinksModel sharedLink6; + private RestSharedLinksModel sharedLink7; + private RestSharedLinksModel sharedLink8; + private RestRenditionInfoModel nodeRenditionInfo; + + private RestSharedLinksModelCollection sharedLinksCollection; + private RestRenditionInfoModelCollection nodeRenditionInfoCollection; + + private String expiryDate = "2027-03-23T23:00:00.000+0000"; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + + adminUser = dataUser.getAdminUser(); + restClient.authenticateUser(adminUser); + + // Create Standard User + testUser1 = dataUser.usingUser(adminUser).createRandomTestUser(); + + // Create Site + siteModel1 = dataSite.usingUser(testUser1).createPublicRandomSite(); + + folder1 = dataContent.usingUser(adminUser).usingSite(siteModel1).createFolder(); + + file1 = dataContent.usingUser(adminUser).usingResource(folder1).createContent(DocumentType.TEXT_PLAIN); + file2 = dataContent.usingUser(adminUser).usingResource(folder1).createContent(DocumentType.TEXT_PLAIN); + file3 = dataContent.usingUser(adminUser).usingResource(folder1).createContent(DocumentType.TEXT_PLAIN); + file4 = dataContent.usingUser(adminUser).usingResource(folder1).createContent(DocumentType.TEXT_PLAIN); + file5 = dataContent.usingUser(adminUser).usingResource(folder1).createContent(DocumentType.TEXT_PLAIN); + file7 = dataContent.usingUser(adminUser).usingResource(folder1).createContent(DocumentType.TEXT_PLAIN); + file8 = dataContent.usingUser(adminUser).usingResource(folder1).createContent(DocumentType.TEXT_PLAIN); + // Create file6 based on existing resource + FileModel newFile = FileModel.getFileModelBasedOnTestDataFile("sampleContent.txt"); + newFile.setName("sampleContent.txt"); + file6 = dataContent.usingUser(adminUser).usingResource(folder1).createContent(newFile); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.SHAREDLINKS }, executionType = ExecutionType.SANITY, description = "Verify create sharedLinks without Path") + @Test(groups = { TestGroup.REST_API, TestGroup.SHAREDLINKS, TestGroup.SANITY }) + public void testCreateAndGetSharedLinks() throws Exception + { + // Post without includePath + sharedLink1 = restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().createSharedLink(file1); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.onResponse().assertThat().body("entry.nodeId", org.hamcrest.Matchers.equalTo(file1.getNodeRefWithoutVersion())); + restClient.onResponse().assertThat().body("entry.name", org.hamcrest.Matchers.equalTo(file1.getName())); + restClient.onResponse().assertThat().body("entry.id", org.hamcrest.Matchers.equalTo(sharedLink1.getId())); + restClient.onResponse().assertThat().body("entry.path", org.hamcrest.Matchers.nullValue()); + + // Same Checks above using sharedLink methods: GET sharedLink: without includePath + Assert.assertEquals(sharedLink1.getNodeId(), file1.getNodeRefWithoutVersion()); + Assert.assertEquals(sharedLink1.getName(), file1.getName()); + Assert.assertNull(sharedLink1.getPath(), "Path is expected to be null for noauth api: Response shows: " + sharedLink1.toJson()); + + // Get without includePath + restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().getSharedLink(sharedLink1); + restClient.onResponse().assertThat().body("entry.nodeId", org.hamcrest.Matchers.equalTo(file1.getNodeRefWithoutVersion())); + restClient.onResponse().assertThat().body("entry.name", org.hamcrest.Matchers.equalTo(file1.getName())); + restClient.onResponse().assertThat().body("entry.id", org.hamcrest.Matchers.equalTo(sharedLink1.getId())); + restClient.onResponse().assertThat().body("entry.path", org.hamcrest.Matchers.nullValue()); + + /* + * Get all shared-links while allowing indexing to complete and check + * that the created shared-link is displayed + */ + Utility.sleep(1000, 30000, () -> + { + sharedLinksCollection = restClient.withCoreAPI().usingSharedLinks().getSharedLinks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + sharedLinksCollection.assertThat().entriesListContains("id", sharedLink1.getId()).and() + .entriesListContains("nodeId", sharedLink1.getNodeId()); + }); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.SHAREDLINKS }, executionType = ExecutionType.REGRESSION, description = "Verify create sharedLinks with Path") + @Test(groups = { TestGroup.REST_API, TestGroup.SHAREDLINKS, TestGroup.REGRESSION }) + public void testCreateAndGetSharedLinksWithInclude() throws Exception + { + // Post with includePath + sharedLink2 = restClient.authenticateUser(testUser1).withCoreAPI().includePath().usingSharedLinks().createSharedLink(file2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.onResponse().assertThat().body("entry.nodeId", org.hamcrest.Matchers.equalTo(file2.getNodeRefWithoutVersion())); + restClient.onResponse().assertThat().body("entry.name", org.hamcrest.Matchers.equalTo(file2.getName())); + restClient.onResponse().assertThat().body("entry.id", org.hamcrest.Matchers.equalTo(sharedLink2.getId())); + restClient.onResponse().assertThat().body("entry.path", org.hamcrest.Matchers.notNullValue()); + + // Same Checks above using sharedLink methods: POST sharedLink: includePath + Assert.assertEquals(sharedLink2.getNodeId(), file2.getNodeRefWithoutVersion()); + Assert.assertEquals(sharedLink2.getName(), file2.getName()); + Assert.assertNotNull(sharedLink2.getPath(), "Path not expected to be null for noauth api: Response shows: " + sharedLink1.toJson()); + + // Get with includePath + restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().getSharedLink(sharedLink2); + restClient.onResponse().assertThat().body("entry.nodeId", org.hamcrest.Matchers.equalTo(file2.getNodeRefWithoutVersion())); + restClient.onResponse().assertThat().body("entry.name", org.hamcrest.Matchers.equalTo(file2.getName())); + restClient.onResponse().assertThat().body("entry.id", org.hamcrest.Matchers.equalTo(sharedLink2.getId())); + // Verify that path is null since includePath is not supported for this noAuth api + restClient.onResponse().assertThat().body("entry.path", org.hamcrest.Matchers.nullValue()); + + // Get: noAuth with includePath + sharedLink2 = restClient.withCoreAPI().usingSharedLinks().getSharedLink(sharedLink2); + restClient.onResponse().assertThat().body("entry.nodeId", org.hamcrest.Matchers.equalTo(file2.getNodeRefWithoutVersion())); + restClient.onResponse().assertThat().body("entry.name", org.hamcrest.Matchers.equalTo(file2.getName())); + restClient.onResponse().assertThat().body("entry.id", org.hamcrest.Matchers.equalTo(sharedLink2.getId())); + // Verify that path is null since includePath is not supported for this noAuth api + restClient.onResponse().assertThat().body("entry.path", org.hamcrest.Matchers.nullValue()); + + // Same Checks above using sharedLink methods: GET sharedLink: noAuth + Assert.assertEquals(sharedLink2.getNodeId(), file2.getNodeRefWithoutVersion()); + Assert.assertEquals(sharedLink2.getName(), file2.getName()); + Assert.assertNull(sharedLink2.getPath(), "Path is expected to be null for noauth api: Response shows: " + sharedLink2.toJson()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.SHAREDLINKS }, executionType = ExecutionType.SANITY, description = "Verify delete sharedLinks with and without Path") + @Test(groups = { TestGroup.REST_API, TestGroup.SHAREDLINKS, TestGroup.SANITY}) + public void testDeleteSharedLinks() throws Exception + { + sharedLink3 = restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().createSharedLink(file3); + restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().deleteSharedLink(sharedLink3); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + sharedLink4 = restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().createSharedLink(file4); + restClient.authenticateUser(testUser1).withCoreAPI().includePath().usingSharedLinks().deleteSharedLink(sharedLink4); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.SHAREDLINKS }, executionType = ExecutionType.SANITY, description = "Sanity tests for GET {sharedId}/content and POST {sharedId}/email endpoints") + @Test(groups = { TestGroup.REST_API, TestGroup.SHAREDLINKS, TestGroup.SANITY }) + public void testGetSharedLinkContentAndPostEmail() throws Exception + { + // Create shared-link + sharedLink6 = restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().createSharedLink(file6); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + // Make GET {sharedId}/content and check file content + restClient.withCoreAPI().usingSharedLinks().getSharedLinkContent(sharedLink6); + restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.assertHeaderValueContains("Content-Disposition", file6.getName()); + restClient.onResponse().getResponse().body().asString().contains("Sample text."); + + // Make POST {sharedId}/email to send email with created shared-link + String postBody = Json.createObjectBuilder().add("client", "share") + .add("recipientEmails", "john.doe@acme.com") + .build().toString(); + restClient.withCoreAPI().usingSharedLinks().sendSharedLinkEmail(sharedLink6, postBody); + restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.SHAREDLINKS }, executionType = ExecutionType.REGRESSION, description = "Verify get sharedLink/content and get/renditions") + @Test(groups = { TestGroup.REST_API, TestGroup.SHAREDLINKS, TestGroup.REGRESSION, TestGroup.REQUIRE_TRANSFORMATION }) + public void testCreateWithExpiryDateAndGetSharedLinkRendition() throws Exception + { + sharedLink5 = restClient.authenticateUser(testUser1).withCoreAPI().includePath().usingSharedLinks().createSharedLinkWithExpiryDate(file5, expiryDate); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + Assert.assertEquals(sharedLink5.getExpiresAt(), expiryDate); + Assert.assertNotNull(sharedLink5.getPath(), "Path not expected to be null: Response shows: " + sharedLink5.toJson()); + + restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().getSharedLinkRenditions(sharedLink5); + restClient.assertStatusCodeIs(HttpStatus.OK); + + restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().getSharedLinkRendition(sharedLink5, "doclib"); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.SHAREDLINKS }, executionType = ExecutionType.SANITY, description = "Sanity tests for GET /renditions, GET /renditions/{renditionId} and GET /renditions/{renditionId}/content endpoints") + @Test(groups = { TestGroup.REST_API, TestGroup.SHAREDLINKS, TestGroup.SANITY, TestGroup.REQUIRE_TRANSFORMATION }) + public void testGetSharedLinkRendition() throws Exception + { + /* + * Create shared-link and generate renditions for node "doclib"; + * rendition is automatically created when creating "pdf" rendition + */ + sharedLink7 = restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().createSharedLink(file7); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.withCoreAPI().usingNode(file7).createNodeRendition("pdf"); + restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); + + // GET /renditions: wait until all renditions are created and GET all entries + Utility.sleep(1000, 30000, () -> + { + nodeRenditionInfoCollection = restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().getSharedLinkRenditions(sharedLink7); + restClient.assertStatusCodeIs(HttpStatus.OK); + + nodeRenditionInfoCollection.assertThat().entriesListCountIs(2); + nodeRenditionInfoCollection.getEntryByIndex(0).assertThat().field("id").is("doclib").and() + .field("status").is("CREATED"); + nodeRenditionInfoCollection.getEntryByIndex(1).assertThat().field("id").is("pdf").and() + .field("status").is("CREATED"); + }); + + // GET /renditions/{renditionId}: get specific rendition information for the file with shared link + nodeRenditionInfo = restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().getSharedLinkRendition(sharedLink7, "pdf"); + restClient.assertStatusCodeIs(HttpStatus.OK); + nodeRenditionInfo.assertThat().field("id").is("pdf").and() + .field("status").is("CREATED"); + + // GET /renditions/{renditionId}/content: get the rendition content for file with shared link + restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().getSharedLinkRenditionContent(sharedLink7, "pdf"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.assertHeaderValueContains("Content-Type","application/pdf;charset=UTF-8"); + Assert.assertTrue(restClient.onResponse().getResponse().body().asInputStream().available() > 0); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.SHAREDLINKS }, executionType = ExecutionType.SANITY, description = "Sanity tests for Range reuest header on GET shared-links/{sharedId}/renditions/{renditionId}/content endpoints") + @Test(groups = { TestGroup.REST_API, TestGroup.SHAREDLINKS, TestGroup.SANITY, TestGroup.REQUIRE_TRANSFORMATION }) + public void testGetVerifyRangeReguestOnSharedLinks() throws Exception + { + sharedLink8 = restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().createSharedLink(file8); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.withCoreAPI().usingNode(file8).createNodeRendition("pdf"); + restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); + + // GET /renditions/{renditionId}/content: get the Range request header for file with shared links endpoints. + Utility.sleep(1000, 30000, () -> + { + restClient.configureRequestSpec().addHeader("content-range", "bytes=1-10"); + restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().getSharedLinkRenditionContent(sharedLink8, "pdf"); + restClient.assertStatusCodeIs(HttpStatus.PARTIAL_CONTENT); + restClient.assertHeaderValueContains("Content-Type","application/pdf;charset=UTF-8"); + restClient.assertHeaderValueContains("content-range", "bytes 1-10"); + }); + } +} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/rest/sites/GetSiteTests.java b/e2e-test/src/test/java/org/alfresco/rest/sites/GetSiteTests.java new file mode 100644 index 000000000..e205fe7a1 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/sites/GetSiteTests.java @@ -0,0 +1,362 @@ +package org.alfresco.rest.sites; + +import org.alfresco.dataprep.SiteService; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.core.RestResponse; +import org.alfresco.rest.model.*; +import org.alfresco.utility.constants.ContainerName; +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.HttpMethod; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import java.util.List; + +import static org.hamcrest.CoreMatchers.equalTo; + +/** + * @author iulia.cojocea + */ + +public class GetSiteTests extends RestTest +{ + private UserModel adminUserModel; + private ListUserWithRoles usersWithRoles; + private UserModel userModel, privateSiteConsumer; + private SiteModel publicSite, privateSite, moderatedSite; + private RestSiteModel restSiteModel; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws DataPreparationException + { + adminUserModel = dataUser.getAdminUser(); + restClient.authenticateUser(adminUserModel); + publicSite = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + usersWithRoles = dataUser.addUsersWithRolesToSite(publicSite, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + + userModel = dataUser.createRandomTestUser(); + privateSiteConsumer = dataUser.createRandomTestUser(); + + privateSite = dataSite.usingAdmin().createPrivateRandomSite(); + moderatedSite = dataSite.usingAdmin().createModeratedRandomSite(); + dataUser.addUserToSite(privateSiteConsumer, privateSite, UserRole.SiteConsumer); + } + + @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 information and gets status code OK (200)") + public void getSiteWithManagerRole() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingSite(publicSite) + .getSite() + .and().field("id").is(publicSite.getId()) + .and().field("title").is(publicSite.getTitle()); + + 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 information and gets status code OK (200)") + public void getSiteWithCollaboratorRole() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingSite(publicSite) + .getSite() + .and().field("id").is(publicSite.getId()) + .and().field("title").is(publicSite.getTitle()); + 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 information and gets status code OK (200)") + public void getSiteWithContributorRole() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) + .withCoreAPI().usingSite(publicSite) + .getSite() + .and().field("id").is(publicSite.getId()) + .and().field("title").is(publicSite.getTitle()); + 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 information and gets status code OK (200)") + public void getSiteWithConsumerRole() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + .withCoreAPI().usingSite(publicSite) + .getSite() + .and().field("id").is(publicSite.getId()) + .and().field("title").is(publicSite.getTitle()); + 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 role gets site information and gets status code OK (200)") + public void getSiteWithAdminRole() throws Exception + { + restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingSite(publicSite) + .getSite() + .and().field("id").is(publicSite.getId()) + .and().field("title").is(publicSite.getTitle()); + 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 call returns status code 401") +// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") + public void unauthenticatedUserIsNotAuthorizedToRetrieveSite() throws Exception + { + UserModel unauthenticatedManager = dataUser.createRandomTestUser(); + unauthenticatedManager.setPassword("user wrong password"); + dataUser.addUserToSite(unauthenticatedManager, publicSite, UserRole.SiteManager); + restClient.authenticateUser(unauthenticatedManager).withParams("maxItems=10000") + .withCoreAPI() + .getSites(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify invalid request returns status code 404 if siteId does not exist") + public void checkStatusCodeForNonExistentSiteId() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite("NonExistentSiteId").getSite(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "NonExistentSiteId")) + .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 all public and moderated sites if an empty siteId is provided") + public void checkStatusCodeForEmptySiteId() throws Exception + { + restClient.authenticateUser(userModel).withCoreAPI(); + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "sites/{siteId}", ""); + RestSiteModelsCollection sites = restClient.processModels(RestSiteModelsCollection.class, request); + restClient.assertStatusCodeIs(HttpStatus.OK); + sites.assertThat().entriesListIsNotEmpty(); + } + + @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 details and status code is 200") + public void getPublicSiteByNotASiteMember() throws Exception + { + restSiteModel = restClient.authenticateUser(userModel).withCoreAPI() + .usingSite(publicSite).getSite(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteModel.assertThat().field("visibility").is(publicSite.getVisibility()) + .and().field("id").is(publicSite.getId()) + .and().field("description").is(publicSite.getDescription()) + .and().field("title").is(publicSite.getTitle()) + .and().field("guid").isNotEmpty(); + } + + @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 details and status code is 200") + public void getModeratedSiteByNotASiteMember() throws Exception + { + restSiteModel = restClient.authenticateUser(userModel).withCoreAPI() + .usingSite(moderatedSite).getSite(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteModel.assertThat().field("visibility").is(moderatedSite.getVisibility()) + .and().field("id").is(moderatedSite.getId()) + .and().field("description").is(moderatedSite.getDescription()) + .and().field("title").is(moderatedSite.getTitle()) + .and().field("guid").isNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if member of a private site gets that site details and status code is 200") + public void getPrivateSiteBySiteMember() throws Exception + { + restSiteModel = restClient.authenticateUser(privateSiteConsumer).withCoreAPI() + .usingSite(privateSite).getSite(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteModel.assertThat().field("visibility").is(privateSite.getVisibility()) + .and().field("id").is(privateSite.getId()) + .and().field("description").is(privateSite.getDescription()) + .and().field("title").is(privateSite.getTitle()) + .and().field("guid").isNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if user that is not member of a private site does not get that site details and status code is 200") + public void getPrivateSiteByNotASiteMember() throws Exception + { + restSiteModel = restClient.authenticateUser(userModel).withCoreAPI() + .usingSite(privateSite).getSite(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, privateSite.getTitle())) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }, expectedExceptions = java.lang.AssertionError.class) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Check that properties parameter is applied (guid field is mandatory, thus assertion error is expected)") + public void checkThatPropertiesParameterIsApplied() throws Exception + { + restSiteModel = restClient.authenticateUser(adminUserModel).withParams("properties=id, visibility").withCoreAPI().usingSite(publicSite).getSite(); + restSiteModel.assertThat().field("id").is(publicSite.getId()).and().field("visibility").is(SiteService.Visibility.PUBLIC.toString()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION } ) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Check that properties parameter is applied") + public void checkThatPropertiesParameterIsAppliedPositiveTest() throws Exception + { + restSiteModel = restClient.authenticateUser(adminUserModel).withParams("properties=id,guid,title,visibility").withCoreAPI().usingSite(publicSite).getSite(); + restSiteModel.assertThat().field("id").is(publicSite.getId()).and().field("visibility").is(SiteService.Visibility.PUBLIC.toString()) + .and().field("description").isNull() + .and().field("role").isNull(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION } ) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Delete site then get site details") + public void deleteSiteThenGetSiteDetails() throws Exception + { + SiteModel newSite = dataSite.usingAdmin().createPublicRandomSite(); + dataSite.deleteSite(newSite); + restSiteModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(newSite).getSite(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newSite.getId())) + .containsErrorKey(RestErrorModel.ENTITY_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= "Delete site then get site details") + public void updateSiteVisibilityToPrivateThenGetSite() throws Exception + { + SiteModel newSite = dataSite.usingAdmin().createPublicRandomSite(); + restSiteModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(newSite).getSite(); + restClient.assertStatusCodeIs(HttpStatus.OK); + dataSite.updateSiteVisibility(newSite, SiteService.Visibility.PRIVATE); + restSiteModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(newSite).getSite(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restSiteModel.assertThat().field("id").is(newSite.getId()) + .and().field("visibility").is(SiteService.Visibility.PRIVATE.toString()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION } ) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Check that relations parameter is applied for containers") + public void checkThatRelationsParameterIsAppliedForContainers() throws Exception + { + List jsonObjects = restClient.authenticateUser(adminUserModel) + .withParams("relations=containers").withCoreAPI().usingSite(publicSite).getSiteWithRelations(); + + RestSiteModel siteModel = (RestSiteModel) jsonObjects.get(0); + RestSiteContainerModelsCollection containers = (RestSiteContainerModelsCollection) jsonObjects.get(1); + + siteModel.assertThat().field("visibility").is(publicSite.getVisibility()) + .and().field("id").is(publicSite.getId()) + .and().field("description").is(publicSite.getDescription()) + .and().field("title").is(publicSite.getTitle()) + .and().field("preset").is("site-dashboard") + .and().field("guid").isNotEmpty(); + + containers.assertThat().entriesListCountIs(1) + .and().entriesListContains("folderId", ContainerName.documentLibrary.toString()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION } ) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Check that relations parameter is applied for members") + public void checkThatRelationsParameterIsAppliedForMembers() throws Exception + { + SiteModel publicRandomSite = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + List jsonObjects = restClient.authenticateUser(adminUserModel) + .withParams("relations=members").withCoreAPI().usingSite(publicRandomSite).getSiteWithRelations(); + + RestSiteModel siteModel = (RestSiteModel) jsonObjects.get(0); + RestSiteMemberModelsCollection siteMembers = (RestSiteMemberModelsCollection) jsonObjects.get(1); + + siteModel.assertThat().field("visibility").is(publicRandomSite.getVisibility()) + .and().field("id").is(publicRandomSite.getId()) + .and().field("description").is(publicRandomSite.getDescription()) + .and().field("title").is(publicRandomSite.getTitle()) + .and().field("preset").is("site-dashboard") + .and().field("guid").isNotEmpty(); + + siteMembers.assertThat().entriesListCountIs(1) + .assertThat().entriesListContains("id", adminUserModel.getUsername()) + .assertThat().entriesListContains("role", UserRole.SiteManager.toString()); + siteMembers.getOneRandomEntry().onModel().assertThat().field("person.firstName").is("Administrator") + .and().field("person.id").is("admin"); + } + + @Test(groups="demo") + public void checkThatRelationsParameterIsAppliedForMembersCustom() + { + /*1 - select API endpoint*/ + restClient.withCoreAPI(); + + /*2 - define request */ + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "sites/{siteId}?{parameters}", publicSite.getId(), "relations=members"); + + /*3 - send request */ + RestResponse response = restClient.authenticateUser(adminUserModel).process(request); + + /*assertions */ + response.assertThat().body("entry.id", equalTo(publicSite.getId())); + response.assertThat().body("relations.members.list.entries.entry[0].role", equalTo("SiteManager")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION } ) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Check that relations parameter is applied for containers and members") + public void checkThatRelationsParameterIsAppliedForContainersAndMembers() throws Exception + { + SiteModel publicRandomSite = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + List jsonObjects = restClient.authenticateUser(adminUserModel) + .withParams("relations=containers,members").withCoreAPI().usingSite(publicRandomSite).getSiteWithRelations(); + + RestSiteModel siteModel = (RestSiteModel) jsonObjects.get(0); + RestSiteContainerModelsCollection containers = (RestSiteContainerModelsCollection) jsonObjects.get(1); + RestSiteMemberModelsCollection siteMembers = (RestSiteMemberModelsCollection) jsonObjects.get(2); + + siteModel.assertThat().field("visibility").is(publicRandomSite.getVisibility()) + .and().field("id").is(publicRandomSite.getId()) + .and().field("description").is(publicRandomSite.getDescription()) + .and().field("title").is(publicRandomSite.getTitle()) + .and().field("preset").is("site-dashboard") + .and().field("guid").isNotEmpty(); + + containers.assertThat().entriesListCountIs(1) + .and().entriesListContains("folderId", ContainerName.documentLibrary.toString()); + + siteMembers.assertThat().entriesListCountIs(1) + .assertThat().entriesListContains("id", adminUserModel.getUsername()) + .assertThat().entriesListContains("role", UserRole.SiteManager.toString()); + siteMembers.getOneRandomEntry().onModel().assertThat().field("person.firstName").is("Administrator") + .and().field("person.id").is("admin"); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/sites/GetSitesTests.java b/e2e-test/src/test/java/org/alfresco/rest/sites/GetSitesTests.java new file mode 100644 index 000000000..d178612bf --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/sites/GetSitesTests.java @@ -0,0 +1,484 @@ +package org.alfresco.rest.sites; + +import org.alfresco.dataprep.SiteService; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.*; +import org.alfresco.utility.constants.ContainerName; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.data.RandomData; +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.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import java.util.List; + +/** + * @author iulia.cojocea + */ +public class GetSitesTests extends RestTest +{ + private UserModel adminUser; + private UserModel lastPrivateSiteManager; + private ListUserWithRoles usersWithRoles; + private SiteModel siteModel; + private UserModel regularUser, privateSiteManager, privateSiteConsumer; + private SiteModel firstPublicSite, firstPrivateSite, firstModeratedSite, deletedSite; + private SiteModel lastPublicSite, lastPrivateSite, lastModeratedSite; + private RestSiteModelsCollection sites; + private String name; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + regularUser = dataUser.createRandomTestUser(); + lastPrivateSiteManager = dataUser.createRandomTestUser(); + privateSiteManager = dataUser.createRandomTestUser(); + privateSiteConsumer = dataUser.createRandomTestUser(); + + siteModel = new SiteModel(RandomData.getRandomName("0-PublicSite")); + firstPublicSite = dataSite.usingAdmin().createSite(siteModel); + siteModel = new SiteModel(RandomData.getRandomName("0-PrivateSite"), SiteService.Visibility.PRIVATE); + firstPrivateSite = dataSite.usingAdmin().createSite(siteModel); + siteModel = new SiteModel(RandomData.getRandomName("0-ModeratedSite"), SiteService.Visibility.MODERATED); + firstModeratedSite = dataSite.usingAdmin().createSite(siteModel); + dataUser.addUserToSite(privateSiteManager, firstPrivateSite, UserRole.SiteManager); + dataUser.addUserToSite(privateSiteConsumer, firstPrivateSite, UserRole.SiteConsumer); + deletedSite = dataSite.usingAdmin().createPublicRandomSite(); + + name = RandomData.getRandomName("ZZZZZZZZZ-PublicSite"); + lastPublicSite = dataSite.usingAdmin().createSite(new SiteModel(SiteService.Visibility.PUBLIC, "guid", name, name, name)); + lastPrivateSite = dataSite.usingAdmin().createSite(new SiteModel(RandomData.getRandomName("ZZZZZZZZZ-PrivateSite"), SiteService.Visibility.PRIVATE)); + lastModeratedSite = dataSite.usingAdmin().createSite(new SiteModel(RandomData.getRandomName("ZZZZZZZZZ-ModeratedSite"), SiteService.Visibility.MODERATED)); + + adminUser = dataUser.getAdminUser(); + siteModel = dataSite.usingAdmin().createPublicRandomSite(); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + dataUser.addUserToSite(lastPrivateSiteManager, lastPrivateSite, 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 sites information and gets status code OK (200)") + public void managerIsAbleToRetrieveSites() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withParams("maxItems=10000") + .withCoreAPI().getSites() + .assertThat().entriesListIsNotEmpty() + .assertThat().entriesListContains("id", siteModel.getId()) + .and().paginationExist(); + 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 sites information and gets status code OK (200)") + public void collaboratorIsAbleToRetrieveSites() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withParams("maxItems=10000") + .withCoreAPI().getSites().assertThat().entriesListIsNotEmpty() + .assertThat().entriesListContains("id", siteModel.getId()) + .and().paginationExist(); + + 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 sites information and gets status code OK (200)") + public void contributorIsAbleToRetrieveSites() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withParams("maxItems=10000") + .withCoreAPI().getSites() + .assertThat().entriesListIsNotEmpty() + .assertThat().entriesListContains("id", siteModel.getId()) + .and().paginationExist(); + 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 sites information and gets status code OK (200)") + public void consumerIsAbleToRetrieveSites() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withParams("maxItems=10000") + .withCoreAPI().getSites() + .assertThat().entriesListIsNotEmpty() + .assertThat().entriesListContains("id", siteModel.getId()) + .and().paginationExist(); + 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 sites information and gets status code OK (200)") + public void adminUserIsAbleToRetrieveSites() throws Exception + { + restClient.authenticateUser(adminUser).withParams("maxItems=10000") + .withCoreAPI().getSites() + .assertThat().entriesListIsNotEmpty() + .assertThat().entriesListContains("id", siteModel.getId()) + .and().paginationExist(); + 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 sites call returns status code 401") +// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") + public void unauthenticatedUserIsNotAuthorizedToRetrieveSites() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + UserModel userModel = dataUser.createRandomTestUser(); + userModel.setPassword("user wrong password"); + dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); + restClient.authenticateUser(userModel).withParams("maxItems=1") + .withCoreAPI().getSites(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if get sites request returns status code 400 when invalid maxItems parameter is used") + public void getSitesWithInvalidMaxItems() throws Exception + { + restClient.authenticateUser(regularUser).withParams("maxItems=0=09") + .withCoreAPI().getSites(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "0=09")); + + restClient.withParams("maxItems=A") + .withCoreAPI().getSites(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "A")); + + restClient.withParams("maxItems=0") + .withCoreAPI().getSites(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if get sites request returns status code 400 when invalid skipCount parameter is used") + public void getSitesWithInvalidSkipCount() throws Exception + { + restClient.authenticateUser(regularUser).withParams("skipCount=A") + .withCoreAPI().getSites(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "A")); + + restClient.authenticateUser(regularUser).withParams("skipCount=-1") + .withCoreAPI().getSites(); + 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 User gets sites ordered by title ascending and status code is 200") + public void getSitesOrderedByTitleASC() throws Exception + { + sites = restClient.authenticateUser(privateSiteManager).withParams("orderBy=title ASC") + .withCoreAPI().getSites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + sites.assertThat().entriesListIsNotEmpty(); + List sitesList = sites.getEntries(); + sitesList.get(0).onModel().assertThat().field("title").is(firstModeratedSite.getTitle()); + sitesList.get(1).onModel().assertThat().field("title").is(firstPrivateSite.getTitle()); + sitesList.get(2).onModel().assertThat().field("title").is(firstPublicSite.getTitle()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if a regular user gets all public and moderated sites and status code is 200") + public void regularUserGetsOnlyPublicAndModeratedSites() throws Exception + { + sites = restClient.authenticateUser(regularUser).withParams("maxItems=5000") + .withCoreAPI().getSites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + sites.assertThat().entriesListContains("title", firstPublicSite.getTitle()) + .and().entriesListContains("title", firstModeratedSite.getTitle()) + .and().entriesListDoesNotContain("title", firstPrivateSite.getTitle()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if a member of a private site gets the private site, all public sites and all moderated sites. Verify if status code is 200") + public void privateSiteMemberGetsSitesVisibleForHim() throws Exception + { + sites = restClient.authenticateUser(privateSiteConsumer).withParams("maxItems=5000") + .withCoreAPI().getSites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + sites.assertThat().entriesListContains("title", firstPublicSite.getTitle()) + .and().entriesListContains("title", firstModeratedSite.getTitle()) + .and().entriesListContains("title", firstPrivateSite.getTitle()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if a site is not retrieved anymore after deletion and status code is 200") + public void checkDeletedSiteIsNotRetrieved() throws Exception + { + sites = restClient.authenticateUser(regularUser).withParams("maxItems=5000").withCoreAPI().getSites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + sites.assertThat().entriesListContains("title", deletedSite.getTitle()); + + dataSite.usingAdmin().deleteSite(deletedSite); + + sites = restClient.withParams("maxItems=5000").withCoreAPI().getSites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + sites.assertThat().entriesListDoesNotContain("title", deletedSite.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 sites ordered by title descending and status code is 200") + public void getSitesOrderedByTitleDESC() throws Exception + { + int totalItems = restClient.authenticateUser(lastPrivateSiteManager).withCoreAPI().getSites().getPagination().getTotalItems(); + sites = restClient.authenticateUser(lastPrivateSiteManager).withParams(String.format("maxItems=%s&orderBy=title DESC", totalItems)) + .withCoreAPI().getSites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + sites.assertThat().entriesListIsNotEmpty(); + List sitesList = sites.getEntries(); + sitesList.get(0).onModel().assertThat().field("title").is(lastPublicSite.getTitle()); + sitesList.get(1).onModel().assertThat().field("title").is(lastPrivateSite.getTitle()); + sitesList.get(2).onModel().assertThat().field("title").is(lastModeratedSite.getTitle()); + sitesList.get(sitesList.size()-1).onModel().assertThat().field("title").is(firstModeratedSite.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 sites ordered by id ascending and status code is 200") + public void getSitesOrderedByIdASC() throws Exception + { + int totalItems = restClient.authenticateUser(lastPrivateSiteManager).withCoreAPI().getSites().getPagination().getTotalItems(); + sites = restClient.authenticateUser(lastPrivateSiteManager).withParams(String.format("maxItems=%s&orderBy=id ASC", totalItems)) + .withCoreAPI().getSites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + sites.assertThat().entriesListIsNotEmpty(); + List sitesList = sites.getEntries(); + sitesList.get(sitesList.size()-1).onModel().assertThat().field("id").is(lastPublicSite.getId()); + sitesList.get(sitesList.size()-2).onModel().assertThat().field("id").is(lastPrivateSite.getId()); + sitesList.get(sitesList.size()-3).onModel().assertThat().field("id").is(lastModeratedSite.getId()); + sitesList.get(0).onModel().assertThat().field("id").is(firstModeratedSite.getId()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION}) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify pagination") + public void checkPagination() throws Exception + { + sites = restClient.authenticateUser(regularUser).withCoreAPI().getSites(); + sites.getPagination().assertThat() + .field("totalItems").isNotEmpty().and() + .field("maxItems").is("100").and() + .field("hasMoreItems").is((sites.getPagination().getTotalItems() > sites.getPagination().getMaxItems()) ? "true" : "false").and() + .field("skipCount").is("0").and() + .field("count").is((sites.getPagination().isHasMoreItems()) ? sites.getPagination().getMaxItems() : sites.getPagination().getTotalItems()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION}) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify user can get only first two sites and status code is 200") + public void getFirstTwoSites() throws Exception + { + sites = restClient.authenticateUser(regularUser).withParams(String.format("maxItems=%s&orderBy=title ASC", 2)) + .withCoreAPI().getSites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + sites.getPagination().assertThat().field("maxItems").is("2").and().field("count").is("2"); + sites.assertThat().entriesListCountIs(2).and().entriesListDoesNotContain(firstPublicSite.getId()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION}) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify user can get sites using high skipCount parameter and status code is 200") + public void getSitesUsingHighSkipCount() throws Exception + { + RestSiteModelsCollection allSites = restClient.authenticateUser(regularUser).withCoreAPI().getSites(); + sites = restClient.withParams("skipCount=100").withCoreAPI().getSites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + sites.assertThat().paginationField("skipCount").is("100"); + if(allSites.getPagination().getTotalItems() > 100) + sites.assertThat().entriesListIsNotEmpty(); + else + sites.assertThat().entriesListIsEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION}) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify user can not get sites using zero maxItems parameter and status code is 400") + public void userCanNotGetSitesUsingZeroMaxItems() throws Exception + { + sites = restClient.authenticateUser(regularUser).withParams("maxItems=0").withCoreAPI().getSites(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsErrorKey(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) + .containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) + .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 that getSites request applies valid properties param and status code is 200") + public void getSitesRequestWithValidPropertiesParam() throws Exception + { + sites = restClient.authenticateUser(regularUser).withParams("properties=id").withCoreAPI().getSites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + sites.assertThat().entriesListDoesNotContain("description") + .assertThat().entriesListDoesNotContain("title") + .assertThat().entriesListDoesNotContain("visibility") + .assertThat().entriesListDoesNotContain("guid") + .assertThat().entriesListContains("id"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION}) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify pagination when skipCount and MaxItems are used") + public void checkPaginationWithSkipCountAndMaxItems() throws Exception + { + sites = restClient.authenticateUser(regularUser).withParams("skipCount=10&maxItems=110").withCoreAPI().getSites(); + sites.getPagination().assertThat() + .field("totalItems").isNotEmpty().and() + .field("maxItems").is("110").and() + .field("hasMoreItems").is((sites.getPagination().getTotalItems() - sites.getPagination().getSkipCount() > sites.getPagination().getMaxItems())?"true":"false").and() + .field("skipCount").is("10").and() + .field("count").is((sites.getPagination().isHasMoreItems()) ? sites.getPagination().getMaxItems() + : sites.getPagination().getTotalItems() - sites.getPagination().getSkipCount()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION}) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if User gets sites ordered by id ascending and status code is 200") + public void getSitesOrderedByTitleASCAndVisibilityASC() throws Exception + { + SiteModel secondPublicSite = dataSite.usingAdmin().createSite( + new SiteModel(SiteService.Visibility.PUBLIC, "guid", name+"A", name+"A", name)); + SiteModel thirdPublicSite = dataSite.usingAdmin().createSite( + new SiteModel(SiteService.Visibility.PUBLIC, "guid", name+"B", name+"B", name)); + + int totalItems = restClient.authenticateUser(regularUser).withCoreAPI().getSites().getPagination().getTotalItems(); + sites = restClient.authenticateUser(regularUser).withParams(String.format("maxItems=%s&orderBy=title ASC&orderBy=description ASC", totalItems)) + .withCoreAPI().getSites(); + restClient.assertStatusCodeIs(HttpStatus.OK); + sites.assertThat().entriesListIsNotEmpty(); + List sitesList = sites.getEntries(); + sitesList.get(sitesList.size()-1).onModel().assertThat().field("title").is(thirdPublicSite.getTitle()); + sitesList.get(sitesList.size()-2).onModel().assertThat().field("title").is(secondPublicSite.getTitle()); + + dataSite.usingAdmin().deleteSite(secondPublicSite); + dataSite.usingAdmin().deleteSite(thirdPublicSite); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION} ) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Check that relations parameter is applied for containers") + public void checkThatRelationsParameterIsAppliedForContainers() throws Exception + { + List> jsonObjects = restClient.authenticateUser(adminUser) + .withParams("relations=containers").withCoreAPI().usingSite(lastPublicSite).getSitesWithRelations(); + + List siteObjects = jsonObjects.get(0); + for (int i = 0; i < siteObjects.size(); i++) + { + RestSiteModel siteModel = (RestSiteModel) siteObjects.get(i); + siteModel.assertThat().field("visibility").isNotEmpty() + .and().field("id").isNotEmpty() + .and().field("title").isNotEmpty() + .and().field("preset").is("site-dashboard") + .and().field("guid").isNotEmpty(); + } + + List containerObjects = jsonObjects.get(1); + for (int i = 0; i < containerObjects.size(); i++) + { + RestSiteContainerModelsCollection containers = (RestSiteContainerModelsCollection) containerObjects.get(i); + containers.assertThat().entriesListIsNotEmpty().and().entriesListContains("folderId", ContainerName.documentLibrary.toString()); + } + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION} ) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Check that relations parameter is applied for members") + public void checkThatRelationsParameterIsAppliedForMembers() throws Exception + { + List> jsonObjects = restClient.authenticateUser(adminUser) + .withParams("relations=members").withCoreAPI().usingSite(lastPublicSite).getSitesWithRelations(); + + List siteObjects = jsonObjects.get(0); + for (int i = 0; i < siteObjects.size(); i++) + { + RestSiteModel siteModel = (RestSiteModel) siteObjects.get(i); + siteModel.assertThat().field("visibility").isNotEmpty() + .and().field("id").isNotEmpty() + .and().field("title").isNotEmpty() + .and().field("preset").is("site-dashboard") + .and().field("guid").isNotEmpty(); + } + + List memberObjects = jsonObjects.get(1); + for (int i = 0; i < memberObjects.size(); i++) + { + RestSiteMemberModelsCollection siteMembers = (RestSiteMemberModelsCollection) memberObjects.get(i); + siteMembers.assertThat().entriesListIsNotEmpty().assertThat().entriesListContains("id").assertThat().entriesListContains("role", UserRole.SiteManager.toString()); + siteMembers.getOneRandomEntry().onModel().assertThat().field("person.firstName").isNotEmpty().and().field("person.id").isNotEmpty(); + } + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION} ) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Check that relations parameter is applied for members and containers") + public void checkThatRelationsParameterIsAppliedForMembersAndContainers() throws Exception + { + List> jsonObjects = restClient.authenticateUser(adminUser) + .withParams("relations=containers,members").withCoreAPI().usingSite(lastPublicSite).getSitesWithRelations(); + + List siteObjects = jsonObjects.get(0); + for (int i = 0; i < siteObjects.size(); i++) + { + RestSiteModel siteModel = (RestSiteModel) siteObjects.get(i); + siteModel.assertThat().field("visibility").isNotEmpty() + .and().field("id").isNotEmpty() + .and().field("title").isNotEmpty() + .and().field("preset").is("site-dashboard") + .and().field("guid").isNotEmpty(); + } + + List containerObjects = jsonObjects.get(1); + for (int i = 0; i < containerObjects.size(); i++) + { + RestSiteContainerModelsCollection containers = (RestSiteContainerModelsCollection) containerObjects.get(i); + containers.assertThat().entriesListIsNotEmpty().and().entriesListContains("folderId", ContainerName.documentLibrary.toString()); + } + + List memberObjects = jsonObjects.get(2); + for (int i = 0; i < memberObjects.size(); i++) + { + RestSiteMemberModelsCollection siteMembers = (RestSiteMemberModelsCollection) memberObjects.get(i); + siteMembers.assertThat().entriesListIsNotEmpty().assertThat().entriesListContains("id").assertThat().entriesListContains("role", UserRole.SiteManager.toString()); + siteMembers.getOneRandomEntry().onModel().assertThat().field("person.firstName").isNotEmpty().and().field("person.id").isNotEmpty(); + } + } + + @AfterClass(alwaysRun=true) + public void cleanup() throws Exception + { + dataSite.usingAdmin().deleteSite(firstModeratedSite); + dataSite.usingAdmin().deleteSite(firstPrivateSite); + dataSite.usingAdmin().deleteSite(firstPublicSite); + + dataSite.usingAdmin().deleteSite(lastPublicSite); + dataSite.usingAdmin().deleteSite(lastPrivateSite); + dataSite.usingAdmin().deleteSite(lastModeratedSite); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/sites/SitesNetworkTests.java b/e2e-test/src/test/java/org/alfresco/rest/sites/SitesNetworkTests.java new file mode 100644 index 000000000..9716ecba0 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/sites/SitesNetworkTests.java @@ -0,0 +1,85 @@ +package org.alfresco.rest.sites; + +import org.alfresco.dataprep.SiteService; +import org.alfresco.rest.NetworkDataPrep; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestSiteMembershipRequestModel; +import org.alfresco.utility.model.SiteModel; +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.BeforeClass; +import org.testng.annotations.Test; + +public class SitesNetworkTests extends NetworkDataPrep +{ + protected SiteModel siteModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + init(); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION, TestGroup.NETWORKS }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify create site membership request returns status code 404 when personId is not member of the domain.") + public void addSiteMembershipRequestWhenPersonIdIsNotInTheDomain() throws Exception + { + restClient.authenticateUser(adminTenantUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(siteModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, adminTenantUser.getUsername().toLowerCase(), siteModel.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION, TestGroup.NETWORKS }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify create site membership request returns status code 200 with tenant.") + public void addSiteMembershipRequestWithTenant() throws Exception + { + SiteModel tenantPublicSite = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); + RestSiteMembershipRequestModel siteMembershipRequest = restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(tenantPublicSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + siteMembershipRequest.assertThat().field("id").is(tenantPublicSite.getId()) + .assertThat().field("site").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Add process item using by admin in other network.") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void getSiteMembershipRequestByAdminInOtherNetwork() throws Exception + { + SiteModel moderatedSite = dataSite.usingUser(secondAdminTenantUser).createModeratedRandomSite(); + + restClient.authenticateUser(adminTenantUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + restClient.authenticateUser(secondAdminTenantUser).withCoreAPI().usingAuthUser().getSiteMembershipRequest(moderatedSite); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, secondAdminTenantUser.getUsername().toLowerCase(), moderatedSite.getId())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Add process item using by the admin in same network.") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void getSiteMembershipRequestByAdminSameNetwork() throws Exception + { + SiteModel moderatedSite = dataSite.usingUser(adminTenantUser).createModeratedRandomSite(); + restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + + RestSiteMembershipRequestModel returnedModel = restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().getSiteMembershipRequest(moderatedSite); + + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedModel.assertThat().field("id").is(moderatedSite.getId()) + .and().field("message").is("Please accept me") + .and().field("site.title").is(moderatedSite.getTitle()) + .and().field("site.visibility").is(SiteService.Visibility.MODERATED.toString()) + .and().field("site.guid").isNotEmpty() + .and().field("site.description").is(moderatedSite.getDescription()) + .and().field("site.preset").is("site-dashboard"); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/sites/SitesTests.java b/e2e-test/src/test/java/org/alfresco/rest/sites/SitesTests.java new file mode 100644 index 000000000..9b40f7082 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/sites/SitesTests.java @@ -0,0 +1,36 @@ +package org.alfresco.rest.sites; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestSiteModel; +import org.alfresco.utility.model.SiteModel; +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/#!/sites + * + * @author Ana Bozianu + */ +public class SitesTests extends RestTest +{ + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Tests the creation of a site") + public void testCreateSite() throws Exception + { + SiteModel site = RestSiteModel.getRandomSiteModel(); + + RestSiteModel createdSite = restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingSite(site).createSite(); + + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + createdSite.assertThat().field("id").is(site.getId()) + .assertThat().field("title").is(site.getTitle()) + .assertThat().field("description").is(site.getDescription()) + .assertThat().field("visibility").is(site.getVisibility()); + } + +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/sites/containers/GetSiteContainerTests.java b/e2e-test/src/test/java/org/alfresco/rest/sites/containers/GetSiteContainerTests.java new file mode 100644 index 000000000..2ca445467 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/sites/containers/GetSiteContainerTests.java @@ -0,0 +1,304 @@ +package org.alfresco.rest.sites.containers; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestSiteContainerModel; +import org.alfresco.utility.constants.ContainerName; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.apache.commons.lang3.RandomStringUtils; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * @author iulia.cojocea + */ +public class GetSiteContainerTests extends RestTest +{ + private UserModel adminUserModel; + private SiteModel publicSiteModel, moderatedSiteModel, privateSiteModel, adminPrivateSiteModel; + private ListUserWithRoles usersWithRoles; + private RestSiteContainerModel siteContainerModel; + private UserModel testUser; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + testUser = dataUser.createRandomTestUser(); + + publicSiteModel = dataSite.usingAdmin().createPublicRandomSite(); + moderatedSiteModel = dataSite.usingUser(testUser).createModeratedRandomSite(); + privateSiteModel = dataSite.usingUser(testUser).createPrivateRandomSite(); + adminPrivateSiteModel = dataSite.usingAdmin().createPrivateRandomSite(); + + usersWithRoles = dataUser.addUsersWithRolesToSite(publicSiteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + + dataLink.usingAdmin().usingSite(publicSiteModel).createRandomLink(); + + dataLink.usingAdmin().usingSite(adminPrivateSiteModel).createRandomLink(); + + dataLink.usingUser(testUser).usingSite(privateSiteModel).createRandomLink(); + } + + @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 container and gets status code OK (200)") + public void getSiteContainerWithManagerRole() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + siteContainerModel = restClient.withCoreAPI().usingSite(publicSiteModel).getSiteContainers().getOneRandomEntry(); + restClient.withCoreAPI().usingSite(publicSiteModel).getSiteContainer(siteContainerModel.onModel()) + .assertThat().field("id").is(siteContainerModel.onModel().getId()) + .and().field("folderId").is(siteContainerModel.onModel().getFolderId()); + 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 container and gets status code OK (200)") + public void getSiteContainerWithCollaboratorRole() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + siteContainerModel = restClient.withCoreAPI().usingSite(publicSiteModel).getSiteContainers().getOneRandomEntry(); + restClient.withCoreAPI().usingSite(publicSiteModel).getSiteContainer(siteContainerModel.onModel()) + .and().field("id").is(siteContainerModel.onModel().getId()) + .and().field("folderId").is(siteContainerModel.onModel().getFolderId()); + 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 container and gets status code OK (200)") + public void getSiteContainerWithContributorRole() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + siteContainerModel = restClient.withCoreAPI().usingSite(publicSiteModel).getSiteContainers().getOneRandomEntry(); + restClient.withCoreAPI().usingSite(publicSiteModel).getSiteContainer(siteContainerModel.onModel()) + .assertThat().field("id").is(siteContainerModel.onModel().getId()) + .and().field("folderId").is(siteContainerModel.onModel().getFolderId()); + 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 container and gets status code OK (200)") + public void getSiteContainerWithConsumerRole() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + siteContainerModel = restClient.withCoreAPI().usingSite(publicSiteModel).getSiteContainers().getOneRandomEntry(); + restClient.withCoreAPI().usingSite(publicSiteModel).getSiteContainer(siteContainerModel.onModel()) + .assertThat().field("id").is(siteContainerModel.onModel().getId()) + .and().field("folderId").is(siteContainerModel.onModel().getFolderId()); + 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 container and gets status code OK (200)") + public void getSiteContainerWithAdminUser() throws Exception + { + restClient.authenticateUser(adminUserModel); + siteContainerModel = restClient.withCoreAPI().usingSite(publicSiteModel).getSiteContainers().getOneRandomEntry(); + restClient.withCoreAPI().usingSite(publicSiteModel).getSiteContainer(siteContainerModel.onModel()) + .assertThat().field("id").is(siteContainerModel.onModel().getId()) + .and().field("folderId").is(siteContainerModel.onModel().getFolderId()); + 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 container call returns status code 401") + public void unauthenticatedUserIsNotAuthorizedToRetrieveSiteContainer() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + siteContainerModel = restClient.withCoreAPI().usingSite(publicSiteModel).getSiteContainers().getOneRandomEntry(); + UserModel userModel = dataUser.createRandomTestUser(); + userModel.setPassword("user wrong password"); + dataUser.addUserToSite(userModel, publicSiteModel, UserRole.SiteManager); + restClient.authenticateUser(userModel) + .withCoreAPI().usingSite(publicSiteModel).getSiteContainer(siteContainerModel.onModel()); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if get container request returns status code 400 when site doesn't exist") + public void getContainerWithNonExistentSite() throws Exception + { + restClient.authenticateUser(testUser) + .withCoreAPI().usingSite("NonExistentSiteId").getSiteContainer(ContainerName.links.toString()); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, "NonExistentSiteId", ContainerName.links.toString())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if get container request returns status code 400 when container item doesn't exist") + public void getContainerWithNonExistentItem() throws Exception + { + restClient.authenticateUser(testUser) + .withCoreAPI().usingSite(publicSiteModel).getSiteContainer("NonExistentFolder"); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, publicSiteModel.getId(), "NonExistentFolder")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify regular user can get container for public site and request returns status 200") + public void getContainerForPublicSite() throws Exception + { + restClient.authenticateUser(testUser) + .withCoreAPI().usingSite(publicSiteModel).getSiteContainer(ContainerName.links.toString()) + .assertThat().field("folderId").is(ContainerName.links.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 manager is able to get container for his private site and request returns status 200") + public void getContainerForPrivateSite() throws Exception + { + restClient.authenticateUser(testUser) + .withCoreAPI().usingSite(privateSiteModel).getSiteContainer(ContainerName.links.toString()) + .assertThat().field("folderId").is(ContainerName.links.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 get container request returns status 200 for moderated site") + public void getContainerForModeratedSite() throws Exception + { + restClient.authenticateUser(testUser) + .withCoreAPI().usingSite(moderatedSiteModel).getSiteContainer(ContainerName.documentLibrary.toString()) + .assertThat().field("folderId").is(ContainerName.documentLibrary.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 if get container request with properties parameter returns status code 200 and parameter is applied") + public void getContainerUsingPropertiesParameter() throws Exception + { + restClient.authenticateUser(testUser) + .withCoreAPI().usingSite(publicSiteModel).usingParams("properties=id").getSiteContainer(ContainerName.links.toString()) + .assertThat().fieldsCount().is(1) + .and().field("id").isNotEmpty() + .and().field("folderId").isNull(); + 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 container request for a container that does not belong to site returns status code 404") + public void getContainerThatDoesNotBelongToSite() throws Exception + { + restClient.authenticateUser(testUser) + .withCoreAPI().usingSite(moderatedSiteModel).getSiteContainer(ContainerName.links.toString()); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, moderatedSiteModel.getId(), ContainerName.links.toString())) + .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 if get container request for empty siteId returns status code 404") + public void getContainerForEmptySiteId() throws Exception + { + restClient.authenticateUser(testUser) + .withCoreAPI().usingSite("").getSiteContainer(ContainerName.links.toString()); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, "", ContainerName.links.toString())) + .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 if get container request for empty container returns status code 200 and the list of containers") + public void getContainerForEmptyContainer() throws Exception + { + restClient.authenticateUser(testUser) + .withCoreAPI().usingSite(moderatedSiteModel).getSiteContainer(""); + 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 container with name containing special chars returns status code 404") + public void getContainerWithNameContainingSpecialChars() throws Exception + { + String containerSpecialName = RandomStringUtils.randomAlphabetic(2) + "~!%40%23%24%25%5E%26*()_%2B%5B%5D%7B%7D%7C%5C%3B%27%3A%22%2C.%2F%3C%3E"; + + restClient.authenticateUser(testUser) + .withCoreAPI().usingSite(publicSiteModel).getSiteContainer(containerSpecialName); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, publicSiteModel.getId(), containerSpecialName)) + .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 if admin can get container request for a private site created by another user and status code is 200") + public void adminCanGetContainerForPrivateSiteCreatedByUser() throws Exception + { + restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingSite(privateSiteModel).getSiteContainer(ContainerName.links.toString()) + .assertThat().field("folderId").is(ContainerName.links.toString()) + .and().field("id").isNotEmpty(); + 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 user cannot get container request for a private site created by admin and status code is 404") + public void userCannotGetContainerForPrivateSiteCreatedByAdmin() throws Exception + { + restClient.authenticateUser(testUser) + .withCoreAPI().usingSite(adminPrivateSiteModel).getSiteContainer(ContainerName.links.toString()); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, adminPrivateSiteModel.getId(), ContainerName.links.toString())) + .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 if get container request for a deleted container returns status code is 404") + public void getContainerThatWasDeleted() throws Exception + { + restClient.authenticateUser(testUser) + .withCoreAPI().usingSite(privateSiteModel).getSiteContainer(ContainerName.links.toString()) + .assertThat().field("folderId").is(ContainerName.links.toString()); + restClient.assertStatusCodeIs(HttpStatus.OK); + + //use dataprep for delete 'links' container + FolderModel folder= new FolderModel("links"); + folder.setCmisLocation(String.format("/Sites/%s/%s", privateSiteModel.getId(), ContainerName.links.toString())); + dataContent.deleteTree(folder); + + restClient.authenticateUser(testUser) + .withCoreAPI().usingSite(privateSiteModel).getSiteContainer(ContainerName.links.toString()); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, privateSiteModel.getId(), ContainerName.links.toString())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/sites/containers/GetSiteContainersTests.java b/e2e-test/src/test/java/org/alfresco/rest/sites/containers/GetSiteContainersTests.java new file mode 100644 index 000000000..2822239eb --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/sites/containers/GetSiteContainersTests.java @@ -0,0 +1,381 @@ +package org.alfresco.rest.sites.containers; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestSiteContainerModelsCollection; +import org.alfresco.utility.constants.ContainerName; +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 GetSiteContainersTests extends RestTest +{ + private UserModel adminUserModel; + private SiteModel publicSiteModel, publicSiteWithContainers; + private SiteModel moderatedSiteModel, privateSiteModel; + private ListUserWithRoles publicSiteUsers; + private ListUserWithRoles publicSiteWithContainersUsers; + private RestSiteContainerModelsCollection restSiteContainers; + private int totalItems; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + publicSiteModel = dataSite.usingAdmin().createPublicRandomSite(); + publicSiteWithContainers = dataSite.usingAdmin().createPublicRandomSite(); + moderatedSiteModel = dataSite.usingAdmin().createModeratedRandomSite(); + privateSiteModel = dataSite.usingAdmin().createPrivateRandomSite(); + + publicSiteUsers = dataUser.addUsersWithRolesToSite(publicSiteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + + publicSiteWithContainersUsers = dataUser + .addUsersWithRolesToSite(publicSiteWithContainers, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + + dataLink.usingAdmin().usingSite(publicSiteWithContainers).createRandomLink(); + + dataLink.usingAdmin().usingSite(moderatedSiteModel).createRandomLink(); + + dataLink.usingAdmin().usingSite(privateSiteModel).createRandomLink(); + + restSiteContainers = restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers(); + totalItems = restSiteContainers.getPagination().getTotalItems(); + } + + @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 containers and gets status code OK (200)") + public void getSiteContainersWithManagerRole() throws Exception + { + restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteManager)); + restClient.withCoreAPI().usingSite(publicSiteModel).getSiteContainers() + .assertThat().entriesListIsNotEmpty() + .assertThat().paginationExist() + .and().paginationField("count").isNot("0"); + 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 containers and gets status code OK (200)") + public void getSiteContainersWithCollaboratorRole() throws Exception + { + restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)); + restClient.withCoreAPI().usingSite(publicSiteModel).getSiteContainers() + .assertThat().entriesListIsNotEmpty() + .assertThat().paginationExist() + .and().paginationField("count").isNot("0"); + 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 containers and gets status code OK (200)") + public void getSiteContainersWithContributorRole() throws Exception + { + restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteContributor)); + restClient.withCoreAPI().usingSite(publicSiteModel).getSiteContainers() + .assertThat().entriesListIsNotEmpty() + .assertThat().paginationExist() + .and().paginationField("count").isNot("0"); + 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 containers and gets status code OK (200)") + public void getSiteContainersWithConsumerRole() throws Exception + { + restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteConsumer)); + restClient.withCoreAPI().usingSite(publicSiteModel).getSiteContainers() + .assertThat().entriesListIsNotEmpty() + .assertThat().paginationExist() + .and().paginationField("count").isNot("0"); + 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 containers information and gets status code OK (200)") + public void getSiteContainersWithAdminUser() throws Exception + { + restClient.authenticateUser(adminUserModel); + restClient.withCoreAPI().usingSite(publicSiteModel).getSiteContainers() + .assertThat().entriesListIsNotEmpty() + .assertThat().paginationExist() + .and().paginationField("count").isNot("0"); + 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 containers call returns status code 401 with Manager role") +// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") + public void unauthenticatedUserIsNotAuthorizedToRetrieveSiteContainers() throws Exception + { + UserModel userModel = dataUser.createRandomTestUser(); + userModel.setPassword("user wrong password"); + dataUser.addUserToSite(userModel, publicSiteModel, UserRole.SiteManager); + restClient.authenticateUser(userModel) + .withCoreAPI().usingSite(publicSiteModel).getSiteContainers(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if get site container request returns status code 200 with valid maxItems parameter") + public void getContainersWithValidMaxItems() throws Exception + { + restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteManager)) + .withParams("maxItems=5") + .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() + .assertThat().entriesListCountIs(2) + .and().entriesListContains("folderId" , ContainerName.documentLibrary.toString()) + .and().entriesListContains("folderId", ContainerName.links.toString()); + restClient.assertStatusCodeIs(HttpStatus.OK); + + restClient.withParams("maxItems=1") + .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() + .assertThat().entriesListCountIs(1); + + restClient.withParams("maxItems=3") + .withCoreAPI().usingSite(publicSiteModel).getSiteContainers() + .assertThat().entriesListCountIs(1) + .and().entriesListContains("folderId", ContainerName.documentLibrary.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 if get site container request returns status code 400 when invalid maxItems parameter is used") + public void getContainersWithMaxItemsZero () throws Exception + { + restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteManager)) + .withParams("maxItems=0") + .withCoreAPI().usingSite(publicSiteModel).getSiteContainers(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary("Only positive values supported for maxItems"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if get site container request returns status code 400 when invalid maxItems parameter is used") + public void getContainersWithMaxItemsCharacter () throws Exception + { + restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)) + .withParams("maxItems=test") + .withCoreAPI().usingSite(publicSiteModel).getSiteContainers(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "test")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if get site container request returns status code 200 when maxItems parameter starts with multiple zero") + public void getContainersWithMaxItemsMultipleZero () throws Exception + { + restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteCollaborator)) + .withParams("maxItems=000007") + .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() + .assertThat().entriesListCountIs(2); + 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 containers request returns status code 200 when valid skipCount parameter is used") + public void getSiteContainersWithValidSkipCount() throws Exception + { + restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteManager)).withParams("skipCount=1") + .withCoreAPI().usingSite(publicSiteModel).getSiteContainers() + .assertThat().entriesListCountIs(0); + restClient.assertStatusCodeIs(HttpStatus.OK); + + restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteCollaborator)).withParams("skipCount=1") + .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() + .assertThat().entriesListCountIs(1); + restClient.assertStatusCodeIs(HttpStatus.OK); + + restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteConsumer)).withParams("skipCount=2") + .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() + .assertThat().entriesListCountIs(0); + restClient.assertStatusCodeIs(HttpStatus.OK); + + restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteCollaborator)).withParams("skipCount=0") + .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() + .assertThat().entriesListCountIs(2); + 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 containers request returns status code 400 when invalid skipCount parameter is used") + public void getSiteContainersWithSkipCountCharacter() throws Exception + { + restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)).withParams("skipCount=abc") + .withCoreAPI().usingSite(publicSiteModel).getSiteContainers(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "abc")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if get site containers request returns status code 200 when skipCount parameter starts with multiple zero") + public void getSiteContainersWithSkipCountMultipleZero() throws Exception + { + restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)).withParams("skipCount=00002") + .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() + .assertThat().entriesListCountIs(0); + 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 containers request returns status code 400 when site doesn't exist") + public void getSiteContainersWithNonExistentSite() throws Exception + { + restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingSite("NonExistentSiteId").getSiteContainers(); + 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 containers request returns status 200 for private site") + public void getSiteContainersForPrivateSite() throws Exception + { + restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingSite(privateSiteModel).getSiteContainers() + .assertThat().entriesListCountIs(2); + 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 get site containers request returns status 200 for moderated site") + public void getSiteContainersForModeratedSite() throws Exception + { + restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingSite(moderatedSiteModel).getSiteContainers() + .assertThat().entriesListCountIs(2); + 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 get site containers request returns status 200 for several containers") + public void getSiteContainersForSeveralItems() throws Exception + { + restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() + .assertThat().entriesListCountIs(2) + .and().entriesListContains("folderId" ,ContainerName.documentLibrary.toString()) + .and().entriesListContains("folderId", ContainerName.links.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 get site containers request returns status 200 for one container") + public void getSiteContainersWithOneItem() throws Exception + { + restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingSite(publicSiteModel).getSiteContainers() + .assertThat().entriesListCountIs(1) + .and().entriesListContains("folderId" ,ContainerName.documentLibrary.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 if get site container request with properties parameter applied returns status code 200") + public void getSiteContainersUsingPropertiesParameter() throws Exception + { + restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingSite(publicSiteWithContainers).usingParams("properties=folderId").getSiteContainers() + .assertThat().entriesListCountIs(2) + .and().entriesListContains("folderId", ContainerName.documentLibrary.toString()) + .and().entriesListContains("folderId", ContainerName.links.toString()) + .and().entriesListDoesNotContain("id"); + 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 container request for a container that is not empty returns status code 200") + public void getSiteContainersThatIsNotEmpty() throws Exception + { + restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() + .assertThat().entriesListCountIs(2) + .and().entriesListContains("folderId", ContainerName.documentLibrary.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 if get site containers request returns status code 200 when first container is skipped") + public void getSiteContainersAndSkipFirst() throws Exception + { + restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteCollaborator)) + .withParams("skipCount=1").withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() + .assertThat().entriesListCountIs(1) + .and().entriesListDoesNotContain("folderId", restSiteContainers.getEntries().get(0).onModel().getFolderId()) + .and().entriesListContains("folderId", restSiteContainers.getEntries().get(1).onModel().getFolderId()); + 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 containers request and get last container returns status code 200") + public void getLastSiteContainer() throws Exception + { + restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteCollaborator)) + .withParams("skipCount=" + String.valueOf(totalItems-1)).withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() + .assertThat().entriesListCountIs(1) + .and().entriesListDoesNotContain("folderId", restSiteContainers.getEntries().get(0).onModel().getFolderId()) + .and().entriesListContains("folderId", restSiteContainers.getEntries().get(1).onModel().getFolderId()); + 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 containers request returns status code 200 when high skipCount parameter is used") + public void getSiteContainersWithHighSkipCount() throws Exception + { + restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteCollaborator)) + .withParams("skipCount=999999").withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() + .assertThat().entriesListIsEmpty() + .and().entriesListCountIs(0) + .and().paginationField("skipCount").is("999999"); + 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 container request for an empty siteId returns status code 404") + public void getSiteContainersForEmptySiteId() throws Exception + { + restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingSite("").getSiteContainers(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/sites/members/AddSiteMemberTests.java b/e2e-test/src/test/java/org/alfresco/rest/sites/members/AddSiteMemberTests.java new file mode 100644 index 000000000..51cab086f --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/sites/members/AddSiteMemberTests.java @@ -0,0 +1,589 @@ +package org.alfresco.rest.sites.members; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.JsonBodyGenerator; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestSiteMemberModel; +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.HttpMethod; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class AddSiteMemberTests extends RestTest +{ + private UserModel adminUserModel; + private SiteModel publicSiteModel, moderatedSiteModel, privateSiteModel; + private ListUserWithRoles publicSiteUsersWithRoles, moderatedSiteUsersWithRoles, privateSiteUsersWithRoles; + private String addMemberJson, addMembersJson; + private RestSiteMemberModel memberModel; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + publicSiteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + moderatedSiteModel = dataSite.usingUser(adminUserModel).createModeratedRandomSite(); + privateSiteModel = dataSite.usingUser(adminUserModel).createPrivateRandomSite(); + publicSiteUsersWithRoles = dataUser.addUsersWithRolesToSite(publicSiteModel, + UserRole.SiteManager, + UserRole.SiteCollaborator, + UserRole.SiteConsumer, + UserRole.SiteContributor); + moderatedSiteUsersWithRoles = dataUser.addUsersWithRolesToSite(moderatedSiteModel, + UserRole.SiteManager, + UserRole.SiteCollaborator, + UserRole.SiteConsumer, + UserRole.SiteContributor); + privateSiteUsersWithRoles = dataUser.addUsersWithRolesToSite(privateSiteModel, + UserRole.SiteManager, + UserRole.SiteCollaborator, + UserRole.SiteConsumer, + UserRole.SiteContributor); + addMemberJson = "{\"role\":\"%s\",\"id\":\"%s\"}"; + addMembersJson = "{\"role\":\"%s\",\"id\":\"%s\"}, {\"role\":\"%s\",\"id\":\"%s\"}"; + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, + description = "Verify that manager is able to add site member and gets status code CREATED (201)") + public void managerIsAbleToAddSiteMember() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteCollaborator); + restClient.authenticateUser(publicSiteUsersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + restClient.withCoreAPI().usingSite(publicSiteModel).addPerson(testUser) + .assertThat().field("id").is(testUser.getUsername()) + .and().field("role").is(testUser.getUserRole()); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that site collaborator is not able to add site member and gets status code FORBIDDEN (403)") + public void collaboratorIsNotAbleToAddSiteMember() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteConsumer); + restClient.authenticateUser(publicSiteUsersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingSite(publicSiteModel).addPerson(testUser); + + restClient.assertLastError().containsSummary("Permission was denied"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION}) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that site contributor is not able to add site member and gets status code FORBIDDEN (403)") + public void contributorIsNotAbleToAddSiteMember() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteConsumer); + restClient.authenticateUser(publicSiteUsersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) + .withCoreAPI().usingSite(publicSiteModel).addPerson(testUser); + restClient.assertLastError().containsSummary("Permission was denied"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that site consumer is not able to add site member and gets status code FORBIDDEN (403)") + public void consumerIsNotAbleToAddSiteMember() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteConsumer); + restClient.authenticateUser(publicSiteUsersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + .withCoreAPI().usingSite(publicSiteModel).addPerson(testUser); + restClient.assertLastError().containsSummary("Permission was denied"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, + description = "Verify that admin user is able to add site member and gets status code CREATED (201)") + public void adminIsAbleToAddSiteMember() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteConsumer); + restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingSite(publicSiteModel).addPerson(testUser) + .and().field("id").is(testUser.getUsername()) + .and().field("role").is(testUser.getUserRole()); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, + description = "Verify that unauthenticated user is not able to add site member") +// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") + public void unauthenticatedUserIsNotAuthorizedToAddSiteMmeber() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteConsumer); + + UserModel userModel = dataUser.createRandomTestUser(); + userModel.setPassword("user wrong password"); + dataUser.addUserToSite(userModel, publicSiteModel, UserRole.SiteManager); + + restClient.authenticateUser(userModel) + .withCoreAPI().usingSite(publicSiteModel).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that manager can add another user as manager to a public site and gets status code CREATED (201)") + public void addManagerToPublicSite() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteManager); + memberModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + memberModel.assertThat().field("id").is(testUser.getUsername()) + .and().field("role").is(testUser.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that manager can add another user as manager to a moderated site and gets status code CREATED (201)") + public void addManagerToModeratedSite() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteManager); + memberModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + memberModel.assertThat().field("id").is(testUser.getUsername()) + .and().field("role").is(testUser.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that manager can add another user as manager to a private site and gets status code CREATED (201)") + public void addManagerToPrivateSite() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteManager); + memberModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + memberModel.assertThat().field("id").is(testUser.getUsername()) + .and().field("role").is(testUser.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that consumer role is not able to add another user to a moderated site and gets status code 403") + public void addUserByConsumerToModeratedSite() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteConsumer); + restClient.authenticateUser(moderatedSiteUsersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingSite(moderatedSiteModel).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that consumer role is not able to add another user to a private site and gets status code 403") + public void addUserByConsumerToPrivateSite() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteConsumer); + restClient.authenticateUser(privateSiteUsersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingSite(privateSiteModel).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that collaborator role is not able to add another user to a moderated site and gets status code 403") + public void addUserByCollaboratorToModeratedSite() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteConsumer); + restClient.authenticateUser(moderatedSiteUsersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingSite(moderatedSiteModel).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that collaborator role is not able to add another user to a private site and gets status code 403") + public void addUserByCollaboratorToPrivateSite() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteConsumer); + restClient.authenticateUser(privateSiteUsersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingSite(privateSiteModel).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that contributor role is not able to add another user to a moderated site and gets status code 403") + public void addUserByContributorToModeratedSite() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteConsumer); + restClient.authenticateUser(moderatedSiteUsersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingSite(moderatedSiteModel).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that contributor role is not able to add another user to a private site and gets status code 403") + public void addUserByContributorToPrivateSite() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteConsumer); + restClient.authenticateUser(privateSiteUsersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingSite(privateSiteModel).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that a user without specified role can not be added to a site and gets status code 400") + public void canNotAddUserWithoutSpecifyingRoleToSite() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + restClient.authenticateUser(adminUserModel).withCoreAPI(); + String json = JsonBodyGenerator.keyValueJson("id", testUser.getUsername()); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, json, "sites/{siteId}/members?{parameters}", publicSiteModel.getId(), restClient.getParameters()); + restClient.processModel(RestSiteMemberModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(RestErrorModel.MUST_PROVIDE_ROLE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that a user with inexistent role can not be added to a site and gets status code 400") + public void canNotAddUserWithInexistentRoleToSite() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + restClient.authenticateUser(adminUserModel).withCoreAPI(); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, String.format("{\"role\":\"inexistentRole\",\"id\":\"%s\"}", testUser.getUsername()), "sites/{siteId}/members?{parameters}", publicSiteModel.getId(), restClient.getParameters()); + restClient.processModel(RestSiteMemberModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.UNKNOWN_ROLE, "inexistentRole")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that user can not add himself as a manager to a public site and gets status code 403") + public void userAddHimselfAsManagerToPublicSite() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteManager); + restClient.authenticateUser(testUser).withCoreAPI().usingSite(publicSiteModel).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that user can not add himself as a manager to a moderated site and gets status code 403") + public void userAddHimselfAsManagerToModeratedSite() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteManager); + restClient.authenticateUser(testUser).withCoreAPI().usingSite(moderatedSiteModel).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that user can not add himself as a manager to a private site and gets status code 404") + public void userAddHimselfAsManagerToPrivateSite() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteManager); + restClient.authenticateUser(testUser).withCoreAPI().usingSite(privateSiteModel).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, privateSiteModel.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that user can not be added to an inexistent site and gets status code 404") + public void userIsNotAbleToAddUserToAnInexistentSite() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteManager); + SiteModel inexistentSite = new SiteModel("inexistentSite"); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(inexistentSite).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, inexistentSite.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that user can not be added to a site if an empty site id is provided and gets status code 404") + public void userIsNotAbleToAddAnotherUserUsingEmptySiteId() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteManager); + SiteModel inexistentSite = new SiteModel(""); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(inexistentSite).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, inexistentSite.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that inexistent user can not be added to site and gets status code 404") + public void userIsNotAbleToAddInexistentUserToSite() throws Exception + { + UserModel testUser = new UserModel("inexistentUser", "password"); + testUser.setUserRole(UserRole.SiteManager); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, testUser.getUsername())) + .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 that empty username can not be added to site and gets status code 400") + public void userIsNotAbleToAddEmptyUserIdToSite() throws Exception + { + UserModel testUser = new UserModel("", "password"); + testUser.setUserRole(UserRole.SiteManager); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.NO_CONTENT, testUser.getUsername())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that user can not add another user that is already a memeber and gets status code 409") + public void userIsNotAbleToAddUserThatIsAlreadyAMember() throws Exception + { + UserModel collaborator = moderatedSiteUsersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(collaborator); + restClient.assertStatusCodeIs(HttpStatus.CONFLICT).assertLastError().containsSummary(String.format(RestErrorModel.ALREADY_Site_MEMBER, collaborator.getUsername(), moderatedSiteModel.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that several users with different roles can be added once in a row to a site and gets status code 201") + public void addSeveralUsersWithDifferentRolesToASite() throws Exception + { + UserModel firstUser = dataUser.createRandomTestUser("testUser"); + firstUser.setUserRole(UserRole.SiteContributor); + UserModel secondUser = dataUser.createRandomTestUser("testUser"); + secondUser.setUserRole(UserRole.SiteCollaborator); + restClient.authenticateUser(adminUserModel).withCoreAPI(); + String json = String.format(addMembersJson, firstUser.getUserRole(), firstUser.getUsername(), secondUser.getUserRole(), secondUser.getUsername()); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, json, "sites/{siteId}/members?{parameters}", publicSiteModel.getId(), restClient.getParameters()); + restClient.processModel(RestSiteMemberModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that several users with same roles can be added once in a row to a site and gets status code 201") + public void addSeveralUsersWithSameRolesToASite() throws Exception + { + UserModel firstUser = dataUser.createRandomTestUser("testUser"); + firstUser.setUserRole(UserRole.SiteCollaborator); + UserModel secondUser = dataUser.createRandomTestUser("testUser"); + secondUser.setUserRole(UserRole.SiteCollaborator); + restClient.authenticateUser(adminUserModel).withCoreAPI(); + String json = String.format(addMembersJson, firstUser.getUserRole(), firstUser.getUsername(), secondUser.getUserRole(), secondUser.getUsername()); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, json, "sites/{siteId}/members?{parameters}", publicSiteModel.getId(), restClient.getParameters()); + restClient.processModel(RestSiteMemberModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that several users that are already added to the site can not be added once in a row and gets status code 400") + public void addSeveralUsersThatAreAlreadyAddedToASite() throws Exception + { + UserModel collaborator = moderatedSiteUsersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); + UserModel consumer = moderatedSiteUsersWithRoles.getOneUserWithRole(UserRole.SiteConsumer); + restClient.authenticateUser(adminUserModel).withCoreAPI(); + String json = String.format(addMembersJson, collaborator.getUserRole(), collaborator.getUsername(), consumer.getUserRole(), consumer.getUsername()); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, json, "sites/{siteId}/members?{parameters}", moderatedSiteModel.getId(), restClient.getParameters()); + restClient.processModel(RestSiteMemberModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.CONFLICT).assertLastError().containsSummary(String.format(RestErrorModel.ALREADY_Site_MEMBER, collaborator.getUsername(), moderatedSiteModel.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Add new site member request by providing an empty body") + public void addSiteMemberUsingEmptyBody() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI(); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "", "sites/{siteId}/members?{parameters}", + publicSiteModel.getId(), restClient.getParameters()); + restClient.processModel(RestSiteMemberModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.NO_CONTENT, "No content to map due to end-of-input")) + .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "No content to map due to end-of-input")) + .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 = "Check lower and upper case letters for role field") + public void checkLowerUpperCaseLettersForRole() throws Exception + { + UserModel user = dataUser.createRandomTestUser(); + + String json = String.format(addMemberJson, "SITEMANAGER", user.getUsername()); + restClient.authenticateUser(adminUserModel).withCoreAPI(); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, json, "sites/{siteId}/members?{parameters}", publicSiteModel.getId(), restClient.getParameters()); + restClient.processModel(RestSiteMemberModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.UNKNOWN_ROLE, "SITEMANAGER")) + .containsErrorKey(String.format(RestErrorModel.UNKNOWN_ROLE, "SITEMANAGER")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + + json = String.format(addMemberJson, "sitemanager", user.getUsername()); + restClient.authenticateUser(adminUserModel).withCoreAPI(); + request = RestRequest.requestWithBody(HttpMethod.POST, json, "sites/{siteId}/members?{parameters}", publicSiteModel.getId(), restClient.getParameters()); + restClient.processModel(RestSiteMemberModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.UNKNOWN_ROLE, "sitemanager")) + .containsErrorKey(String.format(RestErrorModel.UNKNOWN_ROLE, "sitemanager")) + .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 = "Check empty value for user role") + public void checkEmptyValueForRole() throws Exception + { + UserModel user = dataUser.createRandomTestUser(); + + String json = String.format(addMemberJson, "", user.getUsername()); + restClient.authenticateUser(adminUserModel).withCoreAPI(); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, json, "sites/{siteId}/members?{parameters}", publicSiteModel.getId(), restClient.getParameters()); + restClient.processModel(RestSiteMemberModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "N/A")) + .containsSummary(String.format(RestErrorModel.NO_CONTENT, "N/A")) + .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 that contributor role can be added to public site") + public void addContributorToPublicSite() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteContributor); + memberModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + memberModel.assertThat().field("id").is(testUser.getUsername()) + .and().field("role").is(testUser.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that collaborator role can be added to moderated site") + public void addCollaboratorToModeratedSite() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteCollaborator); + memberModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + memberModel.assertThat().field("id").is(testUser.getUsername()) + .and().field("role").is(testUser.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that contributor role can be added to moderated site") + public void addContributorToModeratedSite() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteContributor); + memberModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + memberModel.assertThat().field("id").is(testUser.getUsername()) + .and().field("role").is(testUser.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that consumer role can be added to moderated site") + public void addConsumerToModeratedSite() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteConsumer); + memberModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + memberModel.assertThat().field("id").is(testUser.getUsername()) + .and().field("role").is(testUser.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that collaborator role can be added to private site") + public void addCollaboratorToPrivateSite() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteCollaborator); + memberModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + memberModel.assertThat().field("id").is(testUser.getUsername()) + .and().field("role").is(testUser.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that contributor role can be added to private site") + public void addContributorToPrivateSite() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteContributor); + memberModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + memberModel.assertThat().field("id").is(testUser.getUsername()) + .and().field("role").is(testUser.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that consumer role can be added to private site") + public void addConsumerToPrivateSite() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteConsumer); + memberModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + memberModel.assertThat().field("id").is(testUser.getUsername()) + .and().field("role").is(testUser.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin can be added to private site by site manager") + public void adminCanBeAddedToPrivateSiteBySiteManager() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser(); + SiteModel privateSite = dataSite.usingUser(testUser).createPrivateRandomSite(); + adminUserModel.setUserRole(UserRole.SiteContributor); + memberModel = restClient.authenticateUser(testUser).withCoreAPI().usingSite(privateSite).addPerson(adminUserModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + memberModel.assertThat().field("id").is(adminUserModel.getUsername()).and().field("role").is(adminUserModel.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin cannot be added to private site by site collaborator") + public void adminCannotBeAddedToPrivateSiteBySiteCollaborator() throws Exception + { + UserModel testUser = dataUser.createRandomTestUser(); + SiteModel privateSite = dataSite.usingUser(testUser).createPrivateRandomSite(); + UserModel siteCollaborator = dataUser.createRandomTestUser(); + dataUser.addUserToSite(siteCollaborator, privateSite, UserRole.SiteCollaborator); + adminUserModel.setUserRole(UserRole.SiteContributor); + memberModel = restClient.authenticateUser(siteCollaborator).withCoreAPI().usingSite(privateSite).addPerson(adminUserModel); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/sites/members/GetSiteMemberTests.java b/e2e-test/src/test/java/org/alfresco/rest/sites/members/GetSiteMemberTests.java new file mode 100644 index 000000000..b9c0e9f49 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/sites/members/GetSiteMemberTests.java @@ -0,0 +1,396 @@ +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).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @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); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/sites/members/GetSiteMembersTests.java b/e2e-test/src/test/java/org/alfresco/rest/sites/members/GetSiteMembersTests.java new file mode 100644 index 000000000..a6231ad49 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/sites/members/GetSiteMembersTests.java @@ -0,0 +1,355 @@ +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).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @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()); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/sites/members/RemoveSiteMemberTests.java b/e2e-test/src/test/java/org/alfresco/rest/sites/members/RemoveSiteMemberTests.java new file mode 100644 index 000000000..fca039386 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/sites/members/RemoveSiteMemberTests.java @@ -0,0 +1,467 @@ +package org.alfresco.rest.sites.members; + +import org.alfresco.rest.RestTest; +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.report.Bug; +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 RemoveSiteMemberTests extends RestTest +{ + private SiteModel publicSiteModel, moderatedSiteModel, privateSiteModel; + private UserModel adminUserModel, siteCreator; + private ListUserWithRoles usersWithRoles; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws DataPreparationException + { + adminUserModel = dataUser.getAdminUser(); + siteCreator = dataUser.createRandomTestUser(); + publicSiteModel = dataSite.usingUser(siteCreator).createPublicRandomSite(); + moderatedSiteModel = dataSite.usingUser(siteCreator).createModeratedRandomSite(); + privateSiteModel = dataSite.usingUser(siteCreator).createPrivateRandomSite(); + usersWithRoles = dataUser.addUsersWithRolesToSite(publicSiteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that site manager can delete site member and gets status code 204, 'No Content'") + public void siteManagerIsAbleToDeleteSiteMemberWithConsumerRole() throws Exception + { + UserModel testUserModel = dataUser.createRandomTestUser(); + dataUser.addUserToSite(testUserModel, publicSiteModel, UserRole.SiteConsumer); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + restClient.withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(testUserModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMembers() + .assertThat().entriesListDoesNotContain("id", testUserModel.getUsername()); + 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 that site collaborator cannot delete site member and gets status code 403, 'Forbidden'") + public void siteCollaboratorIsNotAbleToDeleteSiteMemberWithConsumerRole() throws Exception + { + UserModel testUserModel = dataUser.createRandomTestUser(); + dataUser.addUserToSite(testUserModel, publicSiteModel, UserRole.SiteConsumer); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + restClient.withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(testUserModel); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY); + + restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMembers() + .assertThat().entriesListContains("id", testUserModel.getUsername()); + 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 that site contributor cannot delete site member and gets status code 403, 'Forbidden'") + public void siteContributorIsNotAbleToDeleteSiteMemberWithConsumerRole() throws Exception + { + UserModel testUserModel = dataUser.createRandomTestUser(); + dataUser.addUserToSite(testUserModel, publicSiteModel, UserRole.SiteConsumer); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + restClient.withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(testUserModel); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY); + + restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMembers() + .assertThat().entriesListContains("id", testUserModel.getUsername()); + 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 that site consumer cannot delete site member and gets status code 403, 'Forbidden'") + public void siteConsumerIsNotAbleToDeleteSiteMemberWithConsumerRole() throws Exception + { + UserModel testUserModel = dataUser.createRandomTestUser(); + dataUser.addUserToSite(testUserModel, publicSiteModel, UserRole.SiteConsumer); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingSite(publicSiteModel) + .deleteSiteMember(testUserModel); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY); + + restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMembers() + .assertThat().entriesListContains("id", testUserModel.getUsername()); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that unauthenticated user is not able to delete site member") +// @Bug(id = "MNT-16904", description = "It fails only on environment with tenants") + public void unauthenticatedUserIsNotAuthorizedToDeleteSiteMember() throws Exception + { + UserModel testUserModel = dataUser.createRandomTestUser(); + dataUser.addUserToSite(testUserModel, publicSiteModel, UserRole.SiteConsumer); + + UserModel inexistentUser = new UserModel("inexistent user", "inexistent password"); + restClient.authenticateUser(inexistentUser).withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(testUserModel); + + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that manager can NOT delete site member for an inexistent user and gets status code 404, 'Not Found'") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + public void managerIsNotAbleToDeleteInexistentSiteMember() throws Exception + { + UserModel inexistentUser = new UserModel("inexistentUser", "password"); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + restClient.withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(inexistentUser); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, inexistentUser.getUsername())); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that manager can NOT delete site member for a non site member and gets status code 400, 'Bad Request'") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + public void managerIsNotAbleToDeleteNotSiteMember() throws Exception + { + UserModel nonMember = dataUser.createRandomTestUser(); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + restClient.withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(nonMember); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_ARGUMENT, "argument")); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that manager can NOT delete site member for an invalid site and gets status code 404, 'Not Found'") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + public void managerIsNotAbleToDeleteSiteMemberOfInvalidSite() throws Exception + { + SiteModel invalidSite = new SiteModel("invalidSite"); + UserModel testUserModel = dataUser.createRandomTestUser(); + dataUser.addUserToSite(testUserModel, publicSiteModel, UserRole.SiteConsumer); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + restClient.withCoreAPI().usingSite(invalidSite).deleteSiteMember(testUserModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, testUserModel.getUsername(), invalidSite.getId())); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that manager can delete a site member with manager role") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + public void siteManagerIsAbleToDeleteSiteMemberWithManagerRole() throws Exception + { + UserModel anothermanager = dataUser.createRandomTestUser(); + dataUser.addUserToSite(anothermanager, publicSiteModel, UserRole.SiteManager); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(anothermanager); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMembers() + .assertThat().entriesListDoesNotContain("id", anothermanager.getUsername()); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that manager can delete site member using \"-me-\" in place of personId") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + public void managerIsAbleToDeleteSiteMemberUsingMe() throws Exception + { + UserModel manager = dataUser.createRandomTestUser(); + dataUser.addUserToSite(manager, publicSiteModel, UserRole.SiteManager); + UserModel meUser = new UserModel("-me-", "password"); + + restClient.authenticateUser(manager); + restClient.withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(meUser); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMembers() + .assertThat().entriesListDoesNotContain("id", manager.getUsername()); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that site collaborator cannot delete a site member with Manager role and gets status code 422") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + public void siteCollaboratorIsNotAbleToDeleteSiteMemberWithManagerRole() throws Exception + { + UserModel managerForDelete = dataUser.createRandomTestUser(); + dataUser.addUserToSite(managerForDelete, publicSiteModel, UserRole.SiteManager); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + restClient.withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(managerForDelete); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY) + .assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that site contributor cannot delete site member with Manager role and gets status code 422") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + public void siteContributorIsNotAbleToDeleteSiteMemberWithManagerRole() throws Exception + { + UserModel managerForDelete = dataUser.createRandomTestUser(); + dataUser.addUserToSite(managerForDelete, publicSiteModel, UserRole.SiteManager); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + restClient.withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(managerForDelete); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY) + .assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that site consumer cannot delete site member with Manager role and gets status code 422") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + public void siteConsumerIsNotAbleToDeleteSiteMemberWithManagerRole() throws Exception + { + UserModel managerForDelete = dataUser.createRandomTestUser(); + dataUser.addUserToSite(managerForDelete, publicSiteModel, UserRole.SiteManager); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + restClient.withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(managerForDelete); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY) + .assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that site collaborator cannot delete a site member with Contributor role and gets status code 422") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + public void siteCollaboratorIsNotAbleToDeleteSiteMemberWithContributorRole() throws Exception + { + UserModel contributorForDelete = dataUser.createRandomTestUser(); + dataUser.addUserToSite(contributorForDelete, publicSiteModel, UserRole.SiteContributor); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + restClient.withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(contributorForDelete); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY) + .assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that site contributor cannot delete site member with Contributor role and gets status code 422") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + public void siteContributorIsNotAbleToDeleteSiteMemberWithContributorRole() throws Exception + { + UserModel contributorForDelete = dataUser.createRandomTestUser(); + dataUser.addUserToSite(contributorForDelete, publicSiteModel, UserRole.SiteContributor); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + restClient.withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(contributorForDelete); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY) + .assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that site consumer cannot delete site member with Contributor role and gets status code 422") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + public void siteConsumerIsNotAbleToDeleteSiteMemberWithContributorRole() throws Exception + { + UserModel contributorForDelete = dataUser.createRandomTestUser(); + dataUser.addUserToSite(contributorForDelete, publicSiteModel, UserRole.SiteContributor); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + restClient.withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(contributorForDelete); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY) + .assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that manager can delete a site member with Contributor role") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + public void siteManagerIsAbleToDeleteSiteMemberWithContributorRole() throws Exception + { + UserModel contributorForDelete = dataUser.createRandomTestUser(); + dataUser.addUserToSite(contributorForDelete, publicSiteModel, UserRole.SiteContributor); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(contributorForDelete); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMembers() + .assertThat().entriesListDoesNotContain("id", contributorForDelete.getUsername()); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that site collaborator cannot delete a site member with Collaborator role and gets status code 422") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + public void siteCollaboratorIsNotAbleToDeleteSiteMemberWithCollaboratorRole() throws Exception + { + UserModel collaboratorForDelete = dataUser.createRandomTestUser(); + dataUser.addUserToSite(collaboratorForDelete, publicSiteModel, UserRole.SiteCollaborator); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + restClient.withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(collaboratorForDelete); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY) + .assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that site contributor cannot delete site member with Collaborator role and gets status code 422") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + public void siteContributorIsNotAbleToDeleteSiteMemberWithCollaboratorRole() throws Exception + { + UserModel collaboratorForDelete = dataUser.createRandomTestUser(); + dataUser.addUserToSite(collaboratorForDelete, publicSiteModel, UserRole.SiteCollaborator); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + restClient.withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(collaboratorForDelete); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY) + .assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that site consumer cannot delete site member with Collaborator role and gets status code 422") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + public void siteConsumerIsNotAbleToDeleteSiteMemberWithCollaboratorRole() throws Exception + { + UserModel collaboratorForDelete = dataUser.createRandomTestUser(); + dataUser.addUserToSite(collaboratorForDelete, publicSiteModel, UserRole.SiteCollaborator); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + restClient.withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(collaboratorForDelete); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY) + .assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that manager can delete a site member with Collaborator role") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + public void siteManagerIsAbleToDeleteSiteMemberWithCollaboratorRole() throws Exception + { + UserModel collaboratorForDelete = dataUser.createRandomTestUser(); + dataUser.addUserToSite(collaboratorForDelete, publicSiteModel, UserRole.SiteCollaborator); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(collaboratorForDelete); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMembers() + .assertThat().entriesListDoesNotContain("id", collaboratorForDelete.getUsername()); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin can delete a site member with Contributor role and gets status code 204") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + public void adminIsAbleToDeleteSiteMemberWithContributorRole() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel) + .deleteSiteMember(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + dataUser.addUserToSite(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor), publicSiteModel, UserRole.SiteContributor); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin can delete site member with Manager role and gets status code 204") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + public void aminIsAbleToDeleteSiteMemberWithManagerRole() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel) + .deleteSiteMember(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + dataUser.addUserToSite(usersWithRoles.getOneUserWithRole(UserRole.SiteManager), publicSiteModel, UserRole.SiteManager); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin can delete site member with Consumer role and gets status code 204") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + public void adminIsAbleToDeleteSiteMemberWithConsumerRole() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel) + .deleteSiteMember(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + dataUser.addUserToSite(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer), publicSiteModel, UserRole.SiteConsumer); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin can delete a site member with Collaborator role and gets status code 204") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + public void adminIsAbleToDeleteSiteMemberWithCollaboratorRole() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel) + .deleteSiteMember(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + dataUser.addUserToSite(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), publicSiteModel, UserRole.SiteCollaborator); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin can delete a site member of moderated site and gets status code 204") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + public void adminIsAbleToDeleteModeratedSiteMember() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + newMember.setUserRole(UserRole.SiteManager); + dataUser.addUserToSite(newMember, moderatedSiteModel, UserRole.SiteManager); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).deleteSiteMember(newMember); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin can delete a site member of private site and gets status code 204") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + public void adminIsAbleToDeletePrivateSiteMember() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + newMember.setUserRole(UserRole.SiteManager); + dataUser.addUserToSite(newMember, privateSiteModel, UserRole.SiteManager); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).deleteSiteMember(newMember); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that regular user can not delete admin and gets status code 422") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + public void regularUserIsNotAbleToDeleteASiteMember() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingSite(publicSiteModel) + .deleteSiteMember(siteCreator); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() + .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getTitle())) + .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin can not delete a site member twice and gets status code 404 for the second attempt") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @Bug(id="ACE-5447") + public void adminIsNotAbleToRemoveSiteMemberTwice() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel) + .deleteSiteMember(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel) + .deleteSiteMember(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(RestErrorModel.ENTITY_NOT_FOUND); + dataUser.addUserToSite(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor), publicSiteModel, UserRole.SiteContributor); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify admin is not able to remove from site a user that created a member request that was not accepted yet") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @Bug(id="ACE-5447") + public void adminIsNotAbleToRemoveFromSiteANonExistingMember() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(publicSiteModel); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).deleteSiteMember(newMember); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(RestErrorModel.ENTITY_NOT_FOUND); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/sites/members/UpdateSiteMemberTests.java b/e2e-test/src/test/java/org/alfresco/rest/sites/members/UpdateSiteMemberTests.java new file mode 100644 index 000000000..3b98afebb --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/sites/members/UpdateSiteMemberTests.java @@ -0,0 +1,546 @@ +package org.alfresco.rest.sites.members; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.JsonBodyGenerator; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestSiteMemberModel; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser; +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.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class UpdateSiteMemberTests extends RestTest +{ + private UserModel adminUser, siteCreator, regularUser; + private SiteModel publicSite, moderatedSite, privateSite; + private ListUserWithRoles publicSiteUsers; + private UserModel userToBeUpdated; + private RestSiteMemberModel updatedMember; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + siteCreator = dataUser.createRandomTestUser(); + publicSite = dataSite.usingUser(siteCreator).createPublicRandomSite(); + moderatedSite = dataSite.usingUser(siteCreator).createModeratedRandomSite(); + privateSite = dataSite.usingUser(siteCreator).createPrivateRandomSite(); + publicSiteUsers = dataUser.addUsersWithRolesToSite(publicSite, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + + regularUser = dataUser.createRandomTestUser(); + regularUser.setUserRole(UserRole.SiteConsumer); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that collaborator is not able to update site member and gets status code FORBIDDEN (403)") + public void collaboratorIsNotAbleToUpdateSiteMember() throws Exception + { + userToBeUpdated = dataUser.createRandomTestUser(); + dataUser.addUserToSite(userToBeUpdated, publicSite, UserRole.SiteConsumer); + userToBeUpdated.setUserRole(UserRole.SiteCollaborator); + restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)); + restClient.withCoreAPI().usingSite(publicSite).updateSiteMember(userToBeUpdated); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY); + restClient.assertLastError() + .containsSummary(String.format("The current user does not have permissions to modify the membership details of the site %s.", publicSite.getTitle())); + } + + @Bug(id = "REPO-1832") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that collaborator is not able to update site member and gets status code FORBIDDEN (403)") + public void collaboratorIsNotAbleToUpdateSiteMemberWithTheSameRole() throws Exception + { + userToBeUpdated = dataUser.createRandomTestUser(); + dataUser.addUserToSite(userToBeUpdated, publicSite, UserRole.SiteConsumer); + userToBeUpdated.setUserRole(UserRole.SiteConsumer); + restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)); + restClient.withCoreAPI().usingSite(publicSite).updateSiteMember(userToBeUpdated); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY); + restClient.assertLastError() + .containsSummary(String.format("The current user does not have permissions to modify the membership details of the site %s.", publicSite.getTitle())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that contributor is not able to update site member and gets status code FORBIDDEN (403)") + public void contributorIsNotAbleToUpdateSiteMember() throws Exception + { + userToBeUpdated = dataUser.createRandomTestUser(); + dataUser.addUserToSite(userToBeUpdated, publicSite, UserRole.SiteConsumer); + userToBeUpdated.setUserRole(UserRole.SiteCollaborator); + restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteContributor)); + restClient.withCoreAPI().usingSite(publicSite).updateSiteMember(userToBeUpdated); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY); + restClient.assertLastError() + .containsSummary(String.format("The current user does not have permissions to modify the membership details of the site %s.", publicSite.getTitle())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that consumer is not able to update site member and gets status code FORBIDDEN (403)") + public void consumerIsNotAbleToUpdateSiteMember() throws Exception + { + userToBeUpdated = dataUser.createRandomTestUser(); + dataUser.addUserToSite(userToBeUpdated, publicSite, UserRole.SiteConsumer); + userToBeUpdated.setUserRole(UserRole.SiteCollaborator); + restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteConsumer)); + restClient.withCoreAPI().usingSite(publicSite).updateSiteMember(userToBeUpdated); + restClient.assertLastError() + .containsSummary(String.format("The current user does not have permissions to modify the membership details of the site %s.", publicSite.getTitle())); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin is able to update site member and gets status code OK (200)") + public void adminIsAbleToUpdateSiteMember() throws Exception + { + userToBeUpdated = dataUser.createRandomTestUser(); + dataUser.addUserToSite(userToBeUpdated, publicSite, UserRole.SiteConsumer); + userToBeUpdated.setUserRole(UserRole.SiteCollaborator); + restClient.authenticateUser(adminUser); + restClient.withCoreAPI().usingSite(publicSite).updateSiteMember(userToBeUpdated) + .assertThat().field("id").is(userToBeUpdated.getUsername()) + .and().field("role").is(userToBeUpdated.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 = "Verify that unauthenticated user is not able to update site member") +// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") + public void unauthenticatedUserIsNotAuthorizedToUpdateSiteMmeber() throws Exception + { + userToBeUpdated = dataUser.createRandomTestUser(); + dataUser.addUserToSite(userToBeUpdated, publicSite, UserRole.SiteConsumer); + userToBeUpdated.setUserRole(UserRole.SiteCollaborator); + UserModel inexistentUser = new UserModel("inexistent user", "inexistent password"); + restClient.authenticateUser(inexistentUser); + restClient.withCoreAPI().usingSite(publicSite).updateSiteMember(userToBeUpdated); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if update site member request returns status code 404 when nonexistent siteId is used") + public void updateSiteMemberOfNonexistentSite() throws Exception + { + SiteModel deletedSite = dataSite.usingUser(adminUser).createPublicRandomSite(); + dataUser.addUserToSite(regularUser, deletedSite, UserRole.SiteConsumer); + dataSite.deleteSite(deletedSite); + + restClient.authenticateUser(adminUser).withCoreAPI() + .usingSite(deletedSite).updateSiteMember(regularUser); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, deletedSite.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if update site member request returns status code 400 when personId is not member of the site") + public void updateNotASiteMember() throws Exception + { + restClient.authenticateUser(adminUser).withCoreAPI() + .usingSite(publicSite).updateSiteMember(regularUser); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary("User is not a member of the site"); + } + + // @Bug(id="REPO-1642", description = "reproduced on 5.2.1 only, it works on 5.2.0") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if update site member request returns status code 404 when personId does not exist") + public void updateNonexistentSiteMember() throws Exception + { + UserModel nonexistentUser = new UserModel("nonexistentUser", DataUser.PASSWORD); + nonexistentUser.setUserRole(UserRole.SiteContributor); + restClient.authenticateUser(adminUser).withCoreAPI() + .usingSite(publicSite).updateSiteMember(nonexistentUser); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, nonexistentUser.getUsername())); + } + + @Bug(id="REPO-1941") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if a manager is able to downgrade to contributor using -me- string in place of personId.") + public void updateSiteManagerToSiteContributorUsingMe() throws Exception + { + UserModel meManager = dataUser.createRandomTestUser(); + dataUser.addUserToSite(meManager, publicSite, UserRole.SiteManager); + UserModel meUser = new UserModel("-me-", "password"); + meUser.setUserRole(UserRole.SiteContributor); + updatedMember = restClient.authenticateUser(meManager).withCoreAPI() + .usingSite(publicSite).updateSiteMember(meUser); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedMember.assertThat().field("id").is(meManager.getUsername()) + .and().field("role").is(meUser.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if update site member request returns status code 404 when empty siteId is used") + public void updateSiteMemberUsingEmptySiteId() throws Exception + { + restClient.authenticateUser(adminUser).withCoreAPI() + .usingSite("").updateSiteMember(regularUser); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if update site member request returns status code 405 when empty personId is used") + public void updateSiteMemberUsingEmptyPersonId() throws Exception + { + UserModel emptyUser = new UserModel("", DataUser.PASSWORD); + emptyUser.setUserRole(UserRole.SiteCollaborator); + restClient.authenticateUser(adminUser).withCoreAPI() + .usingSite(publicSite).updateSiteMember(emptyUser); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) + .assertLastError().containsSummary(RestErrorModel.PUT_EMPTY_ARGUMENT); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if update site member request returns status code 400 when invalid role is used") + public void updateSiteMemberUsingInvalidRole() throws Exception + { + restClient.authenticateUser(siteCreator).withCoreAPI(); + UserModel siteConsumer = publicSiteUsers.getOneUserWithRole(UserRole.SiteConsumer); + String json = JsonBodyGenerator.keyValueJson("role","invalidRole"); + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, json, "sites/{siteId}/members/{personId}", publicSite.getId(), siteConsumer.getUsername()); + restClient.processModel(RestSiteMemberModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.UNKNOWN_ROLE, "invalidRole")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if manager is able to update another site manager to site collaborator") + public void managerUpdateSiteManagerToSiteCollaborator() throws Exception + { + UserModel siteManager = dataUser.createRandomTestUser(); + dataUser.addUserToSite(siteManager, publicSite, UserRole.SiteManager); + siteManager.setUserRole(UserRole.SiteCollaborator); + updatedMember = restClient.authenticateUser(siteCreator).withCoreAPI() + .usingSite(publicSite).updateSiteMember(siteManager); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedMember.assertThat().field("id").is(siteManager.getUsername()) + .and().field("role").is(siteManager.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if manager is able to update site contributor to site manager") + public void managerUpdateSiteContributorToSiteManager() throws Exception + { + UserModel siteContributor = publicSiteUsers.getOneUserWithRole(UserRole.SiteContributor); + siteContributor.setUserRole(UserRole.SiteManager); + updatedMember = restClient.authenticateUser(siteCreator).withCoreAPI() + .usingSite(publicSite).updateSiteMember(siteContributor); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedMember.assertThat().field("id").is(siteContributor.getUsername()) + .and().field("role").is(siteContributor.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if manager is able to update site collaborator to site manager") + public void managerUpdateSiteCollaboratorToSiteManager() throws Exception + { + UserModel siteCollaborator = publicSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator); + siteCollaborator.setUserRole(UserRole.SiteManager); + updatedMember = restClient.authenticateUser(siteCreator).withCoreAPI() + .usingSite(publicSite).updateSiteMember(siteCollaborator); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedMember.assertThat().field("id").is(siteCollaborator.getUsername()) + .and().field("role").is(siteCollaborator.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.SANITY, + description= "Verify if manager is able to update site consumer to site manager") + public void managerUpdateSiteConsumerToSiteManager() throws Exception + { + UserModel siteConsumer = publicSiteUsers.getOneUserWithRole(UserRole.SiteConsumer); + siteConsumer.setUserRole(UserRole.SiteManager); + updatedMember = restClient.authenticateUser(siteCreator).withCoreAPI() + .usingSite(publicSite).updateSiteMember(siteConsumer); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedMember.assertThat().field("id").is(siteConsumer.getUsername()) + .and().field("role").is(siteConsumer.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if manager is able to downgrade himself to site consumer") + public void publicSiteManagerDowngradesRole() throws Exception + { + UserModel siteManager = publicSiteUsers.getOneUserWithRole(UserRole.SiteManager); + siteManager.setUserRole(UserRole.SiteConsumer); + updatedMember = restClient.authenticateUser(siteManager).withCoreAPI() + .usingSite(publicSite).updateSiteMember(siteManager); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedMember.assertThat().field("id").is(siteManager.getUsername()) + .and().field("role").is(siteManager.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if manager is able to update another site manager to site contributor") + public void managerUpdateSiteManagerToSiteContributor() throws Exception + { + UserModel siteManager = dataUser.createRandomTestUser(); + dataUser.addUserToSite(siteManager, publicSite, UserRole.SiteManager); + + siteManager.setUserRole(UserRole.SiteContributor); + updatedMember = restClient.authenticateUser(siteCreator).withCoreAPI() + .usingSite(publicSite).updateSiteMember(siteManager); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedMember.assertThat().field("id").is(siteManager.getUsername()).and().field("role").is(siteManager.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if manager is able to update another site manager to site consumer") + public void managerUpdateSiteManagerToSiteConsumer() throws Exception + { + UserModel siteManager = dataUser.createRandomTestUser(); + dataUser.addUserToSite(siteManager, publicSite, UserRole.SiteManager); + + siteManager.setUserRole(UserRole.SiteConsumer); + updatedMember = restClient.authenticateUser(siteCreator).withCoreAPI() + .usingSite(publicSite).updateSiteMember(siteManager); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedMember.assertThat().field("id").is(siteManager.getUsername()).and().field("role").is(siteManager.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if manager is able to update site contributor to site collaborator") + public void managerUpdateSiteContributorToSiteCollaborator() throws Exception + { + UserModel siteContributor = dataUser.createRandomTestUser(); + dataUser.addUserToSite(siteContributor, publicSite, UserRole.SiteContributor); + + siteContributor.setUserRole(UserRole.SiteCollaborator); + updatedMember = restClient.authenticateUser(siteCreator).withCoreAPI() + .usingSite(publicSite).updateSiteMember(siteContributor); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedMember.assertThat().field("id").is(siteContributor.getUsername()).and().field("role").is(siteContributor.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if manager is able to update site contributor to site consumer") + public void managerUpdateSiteContributorToSiteConsumer() throws Exception + { + UserModel siteContributor = dataUser.createRandomTestUser(); + dataUser.addUserToSite(siteContributor, publicSite, UserRole.SiteContributor); + + siteContributor.setUserRole(UserRole.SiteConsumer); + updatedMember = restClient.authenticateUser(siteCreator).withCoreAPI() + .usingSite(publicSite).updateSiteMember(siteContributor); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedMember.assertThat().field("id").is(siteContributor.getUsername()).and().field("role").is(siteContributor.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if manager is able to update site collaborator to site contributor") + public void managerUpdateSiteCollaboratorToSiteContributor() throws Exception + { + UserModel siteCollaborator = dataUser.createRandomTestUser(); + dataUser.addUserToSite(siteCollaborator, publicSite, UserRole.SiteCollaborator); + + siteCollaborator.setUserRole(UserRole.SiteContributor); + updatedMember = restClient.authenticateUser(siteCreator).withCoreAPI() + .usingSite(publicSite).updateSiteMember(siteCollaborator); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedMember.assertThat().field("id").is(siteCollaborator.getUsername()).and().field("role").is(siteCollaborator.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if manager is able to update site collaborator to site consumer") + public void managerUpdateSiteCollaboratorToSiteConsumer() throws Exception + { + UserModel siteCollaborator = dataUser.createRandomTestUser(); + dataUser.addUserToSite(siteCollaborator, publicSite, UserRole.SiteCollaborator); + + siteCollaborator.setUserRole(UserRole.SiteConsumer); + updatedMember = restClient.authenticateUser(siteCreator).withCoreAPI() + .usingSite(publicSite).updateSiteMember(siteCollaborator); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedMember.assertThat().field("id").is(siteCollaborator.getUsername()).and().field("role").is(siteCollaborator.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if manager is able to update site consumer to site collaborator") + public void managerUpdateSiteConsumerToSiteCollaborator() throws Exception + { + UserModel siteConsumer = dataUser.createRandomTestUser(); + dataUser.addUserToSite(siteConsumer, publicSite, UserRole.SiteConsumer); + + siteConsumer.setUserRole(UserRole.SiteCollaborator); + updatedMember = restClient.authenticateUser(siteCreator).withCoreAPI() + .usingSite(publicSite).updateSiteMember(siteConsumer); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedMember.assertThat().field("id").is(siteConsumer.getUsername()).and().field("role").is(siteConsumer.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if manager is able to update site consumer to site contributor") + public void managerUpdateSiteConsumerToSiteContributor() throws Exception + { + UserModel siteConsumer = dataUser.createRandomTestUser(); + dataUser.addUserToSite(siteConsumer, publicSite, UserRole.SiteConsumer); + + siteConsumer.setUserRole(UserRole.SiteContributor); + updatedMember = restClient.authenticateUser(siteCreator).withCoreAPI() + .usingSite(publicSite).updateSiteMember(siteConsumer); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedMember.assertThat().field("id").is(siteConsumer.getUsername()).and().field("role").is(siteConsumer.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if manager is able to update another site manager to site manager") + public void managerUpdateSiteManagerToSiteManager() throws Exception + { + UserModel siteManager = dataUser.createRandomTestUser(); + dataUser.addUserToSite(siteManager, publicSite, UserRole.SiteManager); + + siteManager.setUserRole(UserRole.SiteManager); + updatedMember = restClient.authenticateUser(siteCreator).withCoreAPI() + .usingSite(publicSite).updateSiteMember(siteManager); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedMember.assertThat().field("id").is(siteManager.getUsername()).and().field("role").is(siteManager.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if manager is able to update site collaborator to site collaborator") + public void managerUpdateSiteCollaboratorToSiteCollaborator() throws Exception + { + UserModel siteCollaborator = dataUser.createRandomTestUser(); + dataUser.addUserToSite(siteCollaborator, publicSite, UserRole.SiteCollaborator); + + siteCollaborator.setUserRole(UserRole.SiteCollaborator); + updatedMember = restClient.authenticateUser(siteCreator).withCoreAPI() + .usingSite(publicSite).updateSiteMember(siteCollaborator); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedMember.assertThat().field("id").is(siteCollaborator.getUsername()).and().field("role").is(siteCollaborator.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if manager is able to update site contributor to site contributor") + public void managerUpdateSiteContributorToSiteContributor() throws Exception + { + UserModel siteContributor = dataUser.createRandomTestUser(); + dataUser.addUserToSite(siteContributor, publicSite, UserRole.SiteContributor); + + siteContributor.setUserRole(UserRole.SiteContributor); + updatedMember = restClient.authenticateUser(siteCreator).withCoreAPI() + .usingSite(publicSite).updateSiteMember(siteContributor); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedMember.assertThat().field("id").is(siteContributor.getUsername()).and().field("role").is(siteContributor.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if manager is able to update site consumer to site consumer") + public void managerUpdateSiteConsumerToSiteConsumer() throws Exception + { + UserModel siteConsumer = dataUser.createRandomTestUser(); + dataUser.addUserToSite(siteConsumer, publicSite, UserRole.SiteConsumer); + + siteConsumer.setUserRole(UserRole.SiteConsumer); + updatedMember = restClient.authenticateUser(siteCreator).withCoreAPI() + .usingSite(publicSite).updateSiteMember(siteConsumer); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedMember.assertThat().field("id").is(siteConsumer.getUsername()).and().field("role").is(siteConsumer.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if manager of a private site is able to downgrade his role") + public void privateSiteManagerDowngradesRole() throws Exception + { + UserModel siteManager = dataUser.createRandomTestUser(); + dataUser.addUserToSite(siteManager, privateSite, UserRole.SiteManager); + + siteManager.setUserRole(UserRole.SiteConsumer); + updatedMember = restClient.authenticateUser(siteManager).withCoreAPI() + .usingSite(privateSite).updateSiteMember(siteManager); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedMember.assertThat().field("id").is(siteManager.getUsername()).and().field("role").is(siteManager.getUserRole()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if manager of a moderated site is able to downgrade his role") + public void moderatedSiteManagerDowngradesRole() throws Exception + { + UserModel siteManager = dataUser.createRandomTestUser(); + dataUser.addUserToSite(siteManager, moderatedSite, UserRole.SiteManager); + + siteManager.setUserRole(UserRole.SiteConsumer); + updatedMember = restClient.authenticateUser(siteManager).withCoreAPI() + .usingSite(moderatedSite).updateSiteMember(siteManager); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedMember.assertThat().field("id").is(siteManager.getUsername()).and().field("role").is(siteManager.getUserRole()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, + description = "Verify the response of updating a site member with empty body at request") + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) + public void managerCanNotUpdateSiteMemberWithEmptyBody() throws Exception + { + restClient.authenticateUser(siteCreator).withCoreAPI(); + UserModel siteCollaborator = dataUser.createRandomTestUser(); + dataUser.addUserToSite(siteCollaborator, publicSite, UserRole.SiteCollaborator); + siteCollaborator.setUserRole(UserRole.SiteConsumer); + + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "", "sites/{siteId}/members/{personId}", publicSite.getId(), siteCollaborator.getUsername()); + restClient.processModel(RestSiteMemberModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.NO_CONTENT, "No content to map due to end-of-input")) + .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "No content to map due to end-of-input")) + .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 if manager is able to update a user that has created a site membership request, but it's not a member of the site yet") + public void managerCanNotUpdateUserWithSiteMembershipRequest() throws Exception + { + UserModel siteConsumer = dataUser.createRandomTestUser(); + siteConsumer.setUserRole(UserRole.SiteConsumer); + restClient.authenticateUser(siteConsumer).withCoreAPI().usingUser(siteConsumer).addSiteMembershipRequest(moderatedSite); + + updatedMember = restClient.authenticateUser(siteCreator).withCoreAPI() + .usingSite(moderatedSite).updateSiteMember(siteConsumer); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(RestErrorModel.NOT_A_MEMBER); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/sites/membershipRequests/AddSiteMembershipRequestTests.java b/e2e-test/src/test/java/org/alfresco/rest/sites/membershipRequests/AddSiteMembershipRequestTests.java new file mode 100644 index 000000000..a6f155cf6 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/sites/membershipRequests/AddSiteMembershipRequestTests.java @@ -0,0 +1,409 @@ +package org.alfresco.rest.sites.membershipRequests; + +import org.alfresco.dataprep.SiteService; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestSiteEntry; +import org.alfresco.rest.model.RestSiteMembershipRequestModel; +import org.alfresco.rest.model.RestSiteMembershipRequestModelsCollection; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser; +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.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class AddSiteMembershipRequestTests extends RestTest +{ + private SiteModel publicSite, anotherPublicSite, moderatedSite, privateSite; + private DataUser.ListUserWithRoles usersWithRoles; + private UserModel adminUser, siteManager, regularUser, newMember; + private RestSiteMembershipRequestModel siteMembershipRequest; + private RestSiteMembershipRequestModelsCollection siteMembershipRequests; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws DataPreparationException + { + adminUser = dataUser.getAdminUser(); + publicSite = dataSite.usingUser(adminUser).createPublicRandomSite(); + usersWithRoles = dataUser.addUsersWithRolesToSite(publicSite, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + + siteManager = dataUser.createRandomTestUser(); + anotherPublicSite = dataSite.usingUser(siteManager).createPublicRandomSite(); + + moderatedSite = dataSite.usingUser(adminUser).createModeratedRandomSite(); + privateSite = dataSite.usingUser(adminUser).createPrivateRandomSite(); + + newMember = dataUser.createRandomTestUser(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, + description = "Verify site manager is able to create new site membership request for himself and status code is 201") + public void managerCreatesNewSiteMembershipRequestForSelf() throws Exception + { + siteMembershipRequest = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingAuthUser().addSiteMembershipRequest(anotherPublicSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + siteMembershipRequest.assertThat().field("id").is(anotherPublicSite.getId()) + .assertThat().field("site").isNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify site contributor is able to create new site membership request for himself and status code is 201") + public void contributorCreatesNewSiteMembershipRequestForSelf() throws Exception + { + siteMembershipRequest = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingAuthUser().addSiteMembershipRequest(anotherPublicSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + siteMembershipRequest.assertThat().field("id").is(anotherPublicSite.getId()) + .assertThat().field("site").isNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify site collaborator is able to create new site membership request for himself and status code is 201") + public void collaboratorCreatesNewSiteMembershipRequestForSelf() throws Exception + { + siteMembershipRequest = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingAuthUser().addSiteMembershipRequest(anotherPublicSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + siteMembershipRequest.assertThat().field("id").is(anotherPublicSite.getId()) + .assertThat().field("site").isNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify site consumer is able to create new site membership request for himself and status code is 201") + public void consumerCreatesNewSiteMembershipRequestForSelf() throws Exception + { + siteMembershipRequest = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingAuthUser().addSiteMembershipRequest(anotherPublicSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + siteMembershipRequest.assertThat().field("id").is(anotherPublicSite.getId()) + .assertThat().field("site").isNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify admin is able to create new site membership request for himself and status code is 201") + public void adminCreatesNewSiteMembershipRequestForSelf() throws Exception + { + siteMembershipRequest = restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(anotherPublicSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + siteMembershipRequest.assertThat().field("id").is(anotherPublicSite.getId()) + .assertThat().field("site").isNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, + description = "Verify unauthenticated user is not able to create new site membership request") + public void unauthenticatedUserIsNotAbleToCreateSiteMembershipRequest() throws Exception + { + restClient.authenticateUser(new UserModel("random user", "random password")).withCoreAPI().usingAuthUser().addSiteMembershipRequest(publicSite); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify addSiteMembershipRequest Rest API status code is 400 for a user that has already been invited") + public void addSiteMembershipRequestStatusCodeIs400ReceivedForAUserThatIsAlreadyInvited() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + dataUser.addUserToSite(newMember, moderatedSite, UserRole.SiteContributor); + restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + restClient.assertLastError().containsSummary(String.format(RestErrorModel.ALREADY_Site_MEMBER, newMember.getUsername(), moderatedSite.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify addSiteMembershipRequest Rest API status code is 404 for a user that does not exist") + public void addSiteMembershipRequestStatusCodeIs404ReceivedForAUserThatDoesNotExist() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(newMember).withCoreAPI().usingUser(new UserModel("invalidUser", "password")).addSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + restClient.assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidUser")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify addSiteMembershipRequest Rest API status code is 404 for a site that does not exist") + public void addSiteMembershipRequestStatusCodeIs404ReceivedForASiteThatDoesNotExist() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest(new SiteModel("invalidSiteID")); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + restClient.assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, newMember.getUsername(), "invalidSiteID")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify addSiteMembershipRequest Rest API status code is 400 for empty request body") + public void addSiteMembershipRequestStatusCodeIs400ForEmptyRequestBody() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest(""); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.NO_CONTENT, "No content to map due to end-of-input")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify addSiteMembershipRequest Rest API status code is 201 for request with empty message") + public void addSiteMembershipRequestStatusCodeIs201ForRequestWithEmptyMessage() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + siteMembershipRequest = restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest("", moderatedSite, "New request"); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + siteMembershipRequest.assertThat().field("id").is(moderatedSite.getId()).assertThat().field("site").isNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify addSiteMembershipRequest Rest API status code is 201 for request with empty title") + public void addSiteMembershipRequestStatusCodeIs201ForRequestWithEmptyTitle() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + siteMembershipRequest = restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest("Please accept me", moderatedSite, ""); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + siteMembershipRequest.assertThat().field("id").is(moderatedSite.getId()).assertThat().field("site").isNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site manager is not able to create new site membership request for other user") + public void managerIsNotAbleToCreateSiteMembershipRequestForOtherUser() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingUser(newMember) + .addSiteMembershipRequest(publicSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())) + .statusCodeIs(HttpStatus.NOT_FOUND) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site collaborator is not able to create new site membership request for other user") + public void collaboratorIsNotAbleToCreateSiteMembershipRequestForOtherUser() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingUser(newMember) + .addSiteMembershipRequest(publicSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site contributor is not able to create new site membership request for other user") + public void contributorIsNotAbleToCreateSiteMembershipRequestForOtherUser() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingUser(newMember) + .addSiteMembershipRequest(publicSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site consumer is not able to create new site membership request for other user") + public void consumerIsNotAbleToCreateSiteMembershipRequestForOtherUser() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingUser(newMember) + .addSiteMembershipRequest(publicSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin user is not able to create new site membership request for other user") + public void adminIsNotAbleToCreateSiteMembershipRequestForOtherUser() throws Exception + { + restClient.authenticateUser(adminUser).withCoreAPI().usingUser(newMember).addSiteMembershipRequest(publicSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); + + restClient.withCoreAPI().usingUser(newMember).addSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); + + restClient.withCoreAPI().usingUser(newMember).addSiteMembershipRequest(privateSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); + } + + @Bug(id="ACE-2413") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify addSiteMembershipRequest Rest API status code is 400 for an invalid user id") + public void addSiteMembershipRequestReturns400ForEmptyUserId() throws Exception + { + restClient.authenticateUser(adminUser).withCoreAPI() + .usingUser(new UserModel("", "password")).addSiteMembershipRequest(publicSite); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify regular user is able to create new public site membership request for himself. Check that user joins immediately as consumer.") + public void userIsAbleToRequestMembershipOfPublicSite() throws Exception + { + regularUser = dataUser.createRandomTestUser(); + siteMembershipRequest = restClient.authenticateUser(regularUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(publicSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + siteMembershipRequest.assertThat().field("id").is(publicSite.getId()) + .assertThat().field("site").isNotEmpty(); + RestSiteEntry siteEntry = restClient.withCoreAPI().usingAuthUser().getSiteMembership(publicSite); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteEntry.assertThat().field("role").is(UserRole.SiteConsumer) + .and().field("id").is(publicSite.getId()); + siteMembershipRequests = restClient.withCoreAPI().usingAuthUser().getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembershipRequests.assertThat().entriesListIsEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify regular user is able to create new moderated site membership request for himself. Check that the request is added to the site membership request list.") + public void userIsAbleToRequestMembershipOfModeratedSite() throws Exception + { + regularUser = dataUser.createRandomTestUser(); + siteMembershipRequest = restClient.authenticateUser(regularUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + siteMembershipRequest.assertThat().field("id").is(moderatedSite.getId()) + .assertThat().field("message").is("Please accept me") + .assertThat().field("site").isNotEmpty(); + siteMembershipRequest.getSite() + .assertThat().field("visibility").is(moderatedSite.getVisibility()) + .assertThat().field("guid").is(moderatedSite.getGuid()) + .assertThat().field("description").is(moderatedSite.getDescription()) + .assertThat().field("id").is(moderatedSite.getId()) + .assertThat().field("title").is(moderatedSite.getTitle()); + + siteMembershipRequests = restClient.withCoreAPI().usingAuthUser().getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembershipRequests.assertThat().entriesListContains("id", moderatedSite.getId()) + .assertThat().entriesListCountIs(1); + + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify regular user is not able to request membership of a private site.") + public void userIsNotAbleToRequestMembershipOfPrivateSite() throws Exception + { + regularUser = dataUser.createRandomTestUser(); + restClient.authenticateUser(regularUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(privateSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, regularUser.getUsername(), privateSite.getId())); + siteMembershipRequests = restClient.withCoreAPI().usingAuthUser().getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembershipRequests.assertThat().entriesListIsEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify regular user is not able to create new site membership request for other user") + public void regularUserIsNotAbleToCreateSiteMembershipRequestForOtherUser() throws Exception + { + regularUser = dataUser.createRandomTestUser(); + restClient.authenticateUser(regularUser).withCoreAPI().usingUser(newMember) + .addSiteMembershipRequest(publicSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); + + restClient.withCoreAPI().usingUser(newMember).addSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); + + restClient.withCoreAPI().usingUser(newMember).addSiteMembershipRequest(privateSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify create public site membership request returns status code 400 when the request is made twice") + public void userRequestsTwiceMembershipOfPublicSite() throws Exception + { + regularUser = dataUser.createRandomTestUser(); + siteMembershipRequest = restClient.authenticateUser(regularUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(publicSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + siteMembershipRequest.assertThat().field("id").is(publicSite.getId()) + .assertThat().field("site").isNotEmpty(); + restClient.withCoreAPI().usingAuthUser().addSiteMembershipRequest(publicSite); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + restClient.assertLastError().containsSummary(String.format(RestErrorModel.ALREADY_Site_MEMBER, regularUser.getUsername(), publicSite.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify create moderated site membership request returns status code 400 when the request is made twice") + public void userRequestsTwiceMembershipOfModeratedSite() throws Exception + { + regularUser = dataUser.createRandomTestUser(); + siteMembershipRequest = restClient.authenticateUser(regularUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + siteMembershipRequest.assertThat().field("id").is(moderatedSite.getId()) + .assertThat().field("site").isNotEmpty(); + restClient.withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + restClient.assertLastError().containsSummary(String.format(RestErrorModel.ALREADY_INVITED, regularUser.getUsername(), moderatedSite.getId())); + + siteMembershipRequests = restClient.withCoreAPI().usingAuthUser().getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembershipRequests.assertThat().entriesListContains("id", moderatedSite.getId()) + .assertThat().entriesListCountIs(1); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify create private site membership request returns status code 404 when request is made with the user who created the site") + public void siteCreatorRequestsMembershipOfHisPrivateSite() throws Exception + { + restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(privateSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, adminUser.getUsername(), privateSite.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify create moderated site membership request returns status code 400 when request is made with the user who created the site") + public void siteCreatorRequestsMembershipOfHisModeratedSite() throws Exception + { + restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.ALREADY_Site_MEMBER, adminUser.getUsername(), moderatedSite.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify admin is able to create new moderated site membership request for himself. Check that the request is added to the site membership request list.") + public void adminIsAbleToRequestMembershipOfModeratedSite() throws Exception + { + regularUser = dataUser.createRandomTestUser(); + SiteModel anotherModeratedSite = dataSite.usingUser(regularUser).createModeratedRandomSite(); + siteMembershipRequest = restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(anotherModeratedSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + siteMembershipRequest.assertThat().field("id").is(anotherModeratedSite.getId()) + .assertThat().field("site").isNotEmpty(); + siteMembershipRequests = restClient.withCoreAPI().usingAuthUser().getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembershipRequests.assertThat().entriesListContains("id", anotherModeratedSite.getId()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify site membership request is automatically rejected when a site is switched from moderated to private") + public void siteMembershipRequestIsRejectedWhenSiteIsSwitchedFromModeratedToPrivate() throws Exception + { + regularUser = dataUser.createRandomTestUser(); + SiteModel moderatedThenPrivateSite = dataSite.usingUser(adminUser).createModeratedRandomSite(); + siteMembershipRequest = restClient.authenticateUser(regularUser).withCoreAPI().usingMe().addSiteMembershipRequest(moderatedThenPrivateSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + siteMembershipRequest.assertThat().field("id").is(moderatedThenPrivateSite.getId()) + .assertThat().field("site").isNotEmpty(); + + dataSite.usingUser(adminUser).updateSiteVisibility(moderatedThenPrivateSite, SiteService.Visibility.PRIVATE); + + siteMembershipRequests = restClient.withCoreAPI().usingAuthUser().getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembershipRequests.assertThat().entriesListIsEmpty(); + } +} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/rest/sites/membershipRequests/DeleteSiteMembershipRequestTests.java b/e2e-test/src/test/java/org/alfresco/rest/sites/membershipRequests/DeleteSiteMembershipRequestTests.java new file mode 100644 index 000000000..c1da58fb1 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/sites/membershipRequests/DeleteSiteMembershipRequestTests.java @@ -0,0 +1,317 @@ +package org.alfresco.rest.sites.membershipRequests; + +import org.alfresco.dataprep.SiteService.Visibility; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestSiteMembershipRequestModelsCollection; +import org.alfresco.rest.model.RestTaskModel; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.data.RandomData; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * @author iulia.cojocea + */ + +public class DeleteSiteMembershipRequestTests extends RestTest +{ + UserModel siteCreator, adminUserModel, secondSiteCreator, siteMember; + SiteModel moderatedSite, secondModeratedSite, publicSite; + private ListUserWithRoles usersWithRoles; + RestSiteMembershipRequestModelsCollection siteMembershipRequests; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + siteCreator = dataUser.createRandomTestUser(); + secondSiteCreator = dataUser.createRandomTestUser(); + String siteId = RandomData.getRandomName("site"); + moderatedSite = dataSite.usingUser(siteCreator).createSite(new SiteModel(Visibility.MODERATED, siteId, siteId, siteId, siteId)); + usersWithRoles = dataUser.addUsersWithRolesToSite(moderatedSite, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + + dataUser.addUserToSite(adminUserModel, moderatedSite, UserRole.SiteManager); + secondModeratedSite = dataSite.usingUser(secondSiteCreator).createModeratedRandomSite(); + publicSite = dataSite.usingUser(siteCreator).createPublicRandomSite(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify one user is able to delete his one site memebership request") + public void userCanDeleteHisOwnSiteMembershipRequest() throws Exception + { + restClient.authenticateUser(secondSiteCreator).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.withCoreAPI().usingUser(secondSiteCreator).deleteSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site manager is able to delete site membership request") + public void managerCanDeleteSiteMembershipRequest() throws Exception + { + siteMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(siteMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingUser(siteMember) + .deleteSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingUser(siteMember).getSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, siteMember.getUsername(), moderatedSite.getTitle())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin user is able to delete site memebership request") + public void adminUserCanDeleteSiteMembershipRequest() throws Exception + { + siteMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(siteMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(siteMember).deleteSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @Bug(id = "REPO-1946") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify collaborator user is not able to delete site memebership request") + public void collaboratorCannotDeleteSiteMembershipRequest() throws Exception + { + siteMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(siteMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingUser(siteMember) + .deleteSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @Bug(id = "REPO-1946") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify contributor user is not able to delete site memebership request") + public void contributorCannotDeleteSiteMembershipRequest() throws Exception + { + siteMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(siteMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingUser(siteMember) + .deleteSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @Bug(id = "REPO-1946") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify consumer user is not able to delete site memebership request") + public void consumerCannotDeleteSiteMembershipRequest() throws Exception + { + siteMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(siteMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingUser(siteMember) + .deleteSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @Bug(id = "REPO-1946") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify random user is not able to delete site memebership request") + public void randomUserCanNotDeleteSiteMembershipRequest() throws Exception + { + siteMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(siteMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + + restClient.authenticateUser(dataUser.createRandomTestUser()).withCoreAPI().usingUser(siteMember).deleteSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, 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") + public void unauthenticatedUserIsNotAuthorizedToDeleteSiteMmebershipRequest() throws Exception + { + restClient.authenticateUser(dataUser.createRandomTestUser()).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + UserModel inexistentUser = new UserModel("inexistent user", "inexistent password"); + restClient.authenticateUser(inexistentUser).withCoreAPI().usingAuthUser().deleteSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify user is able to remove his own site memebership request using '-me-' in place of personId and response is successful (204)") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void userCanDeleteHisOwnSiteMembershipRequestUsingMeAsPersonId() throws Exception + { + restClient.authenticateUser(secondSiteCreator).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + restClient.withCoreAPI().usingMe().deleteSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify user is not able to remove a site memebership request of an inexistent user and response is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void adminIsNotAbleToDeleteSiteMembershipRequestOfAnInexistentUser() throws Exception + { + UserModel inexistentUser = new UserModel("inexistenUser", "password"); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(inexistentUser).deleteSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, inexistentUser.getUsername())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify user is not able to remove a site memebership request to an inexistent site and response is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void adminIsNotAbleToDeleteSiteMembershipRequestToAnInexistentSite() throws Exception + { + SiteModel inexistentSite = new SiteModel("inexistentSite"); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).deleteSiteMembershipRequest(inexistentSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, adminUserModel.getUsername(), inexistentSite.getId())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify user is not able to remove a site memebership request to an empty site id and response is 405") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void adminIsNotAbleToDeleteSiteMembershipRequestWithEmptySiteId() throws Exception + { + SiteModel inexistentSite = new SiteModel(""); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).deleteSiteMembershipRequest(inexistentSite); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.DELETE_EMPTY_ARGUMENT); + } + + @Bug(id = "REPO-1946") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify contributor user is not able to remove a site memebership request of admin to a moderated site and response is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void contributorIsNotAbleToDeleteSiteMembershipRequestOfAdminToAModeratedSite() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingUser(adminUserModel).deleteSiteMembershipRequest(secondModeratedSite); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify manager is able to remove a site memebership request of admin to a moderated site and response is 204") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void managerUserIsAbleToDeleteSiteMembershipRequestOfAdminToAModeratedSite() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteMembershipRequest(secondModeratedSite); + restClient.authenticateUser(secondSiteCreator).withCoreAPI().usingUser(adminUserModel).deleteSiteMembershipRequest(secondModeratedSite); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify manager is not able to remove a site memebership request if it was already approved and response is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void managerUserIsNotAbleToDeleteASiteMembershipRequestIfItWasAlreadyApproved() throws Exception + { + siteMember.setUserRole(UserRole.SiteCollaborator); + restClient.authenticateUser(siteMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(secondModeratedSite); + RestTaskModel taskModel = restClient.authenticateUser(siteMember).withWorkflowAPI().getTasks().getTaskModelByDescription(secondModeratedSite); + workflow.approveSiteMembershipRequest(secondSiteCreator.getUsername(), secondSiteCreator.getPassword(), taskModel.getId(), true, "Approve"); + + restClient.authenticateUser(secondSiteCreator).withCoreAPI().usingUser(siteMember).deleteSiteMembershipRequest(secondModeratedSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, siteMember.getUsername(), secondModeratedSite.getId())); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify manager is not able to remove an inexitent site memebership request and response is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void managerUserIsNotAbleToDeleteAnInexistentSiteMembershipRequest() throws Exception + { + restClient.authenticateUser(secondSiteCreator).withCoreAPI().usingUser(adminUserModel).deleteSiteMembershipRequest(secondModeratedSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, adminUserModel.getUsername(), secondModeratedSite.getId())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify collaborator user is not able to remove a site memebership request of admin to a public site and response is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void collaboratorIsNotAbleToDeleteSiteMembershipRequestOfAdminToAPublicSite() throws Exception + { + UserModel userCollaborator = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); + restClient.authenticateUser(siteMember).withCoreAPI().usingSite(publicSite).addPerson(userCollaborator); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteMembershipRequest(publicSite); + + restClient.authenticateUser(userCollaborator).withCoreAPI().usingUser(adminUserModel).deleteSiteMembershipRequest(publicSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, adminUserModel.getUsername(), publicSite.getId())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Delete a rejected site membership request.") + public void deleteARejectedSiteMembershipRequest() throws Exception + { + UserModel userWithRejectedRequests = dataUser.createRandomTestUser(); + restClient.authenticateUser(userWithRejectedRequests).withCoreAPI().usingAuthUser().addSiteMembershipRequest(secondModeratedSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestTaskModel taskModel = restClient.authenticateUser(userWithRejectedRequests).withWorkflowAPI().getTasks() + .getTaskModelByDescription(secondModeratedSite); + workflow.approveSiteMembershipRequest(secondSiteCreator.getUsername(), secondSiteCreator.getPassword(), taskModel.getId(), false, "Rejected"); + + siteMembershipRequests = restClient.authenticateUser(userWithRejectedRequests).withCoreAPI().usingMe().getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembershipRequests.assertThat().entriesListDoesNotContain("id", secondModeratedSite.getId()); + + restClient.authenticateUser(secondSiteCreator).withCoreAPI().usingUser(userWithRejectedRequests).deleteSiteMembershipRequest(secondModeratedSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, userWithRejectedRequests.getUsername(), secondModeratedSite.getId())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Bug(id="ACE-2413") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify user is not able to remove a site memebership request- empty person id and response is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void adminIsNotAbleToDeleteSiteMembershipRequestEmptyPersonID() throws Exception + { + UserModel emptyPersonId = new UserModel("", "password"); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(emptyPersonId).deleteSiteMembershipRequest(moderatedSite); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .containsSummary(RestErrorModel.ENTITY_NOT_FOUND) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify manager removes/cancel twice same site memebership request and response is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void managerCancelsTwiceSiteMembershipRequestModeratedSite() throws Exception + { + siteMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(siteMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + + restClient.authenticateUser(siteCreator).withCoreAPI().usingUser(siteMember).deleteSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withCoreAPI().usingUser(siteMember).deleteSiteMembershipRequest(moderatedSite); + + restClient.withCoreAPI().usingUser(siteMember).getSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, siteMember.getUsername(), moderatedSite.getTitle())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestTests.java b/e2e-test/src/test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestTests.java new file mode 100644 index 000000000..fba1deab0 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestTests.java @@ -0,0 +1,332 @@ +package org.alfresco.rest.sites.membershipRequests; + +import org.alfresco.dataprep.SiteService; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestSiteMembershipRequestModel; +import org.alfresco.rest.model.RestTaskModel; +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.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class GetSiteMembershipRequestTests extends RestTest +{ + private SiteModel publicSite, moderatedSite; + private ListUserWithRoles usersWithRoles; + private UserModel adminUser, siteCreator, newMember; + private RestSiteMembershipRequestModel returnedModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + publicSite = dataSite.usingUser(adminUser).createPublicRandomSite(); + + siteCreator = dataUser.createRandomTestUser(); + moderatedSite = dataSite.usingUser(siteCreator).createModeratedRandomSite(); + + usersWithRoles = dataUser.addUsersWithRolesToSite(moderatedSite, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + + newMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site manager is able to retrieve site membership request") + public void siteManagerIsAbleToRetrieveSiteMembershipRequest() throws Exception + { + returnedModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingUser(newMember).getSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedModel.assertThat().field("id").is(moderatedSite.getId()) + .and().field("message").is("Please accept me") + .and().field("site.title").is(moderatedSite.getTitle()) + .and().field("site.visibility").is(SiteService.Visibility.MODERATED.toString()) + .and().field("site.guid").isNotEmpty() + .and().field("site.description").is(moderatedSite.getDescription()) + .and().field("site.preset").is("site-dashboard"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site collaborator is able to retrieve site membership request") + public void siteCollaboratorIsNotAbleToRetrieveSiteMembershipRequest() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingUser(newMember).getSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site contributor is able to retrieve site membership request") + public void siteContributorIsNotAbleToRetrieveSiteMembershipRequest() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingUser(newMember).getSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site consumer is able to retrieve site membership request") + public void siteConsumerIsNotAbleToRetrieveSiteMembershipRequest() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingUser(newMember).getSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin user is able to retrieve site membership request") + public void adminIsAbleToRetrieveSiteMembershipRequest() throws Exception + { + returnedModel = restClient.authenticateUser(adminUser).withCoreAPI().usingUser(newMember).getSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedModel.assertThat().field("id").is(moderatedSite.getId()) + .and().field("message").is("Please accept me") + .and().field("site.title").is(moderatedSite.getTitle()) + .and().field("site.visibility").is(SiteService.Visibility.MODERATED.toString()) + .and().field("site.guid").isNotEmpty() + .and().field("site.description").is(moderatedSite.getDescription()) + .and().field("site.preset").is("site-dashboard"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, + description = "Verify user fails to get all site membership requests of a specific person with Rest API when the authentication fails (401)") + public void unauthorizedUserFailsToGetSiteMembershipRequests() throws Exception + { + UserModel manager = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(siteCreator).addUserToSite(manager, moderatedSite, UserRole.SiteManager); + manager.setPassword("newpassword"); + restClient.authenticateUser(manager).withCoreAPI().usingUser(newMember).getSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError().containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify a user gets all its own site membership requests using '-me-' with Rest API and response is successful (200)") + public void usingMeGetSiteMembershipRequestsWithSuccess() throws Exception + { + restClient.authenticateUser(newMember).withCoreAPI().usingMe().getSiteMembershipRequest(moderatedSite).assertThat().field("id").is(moderatedSite.getId()); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site manager can't get site membership requests for inexistent user and response is not found (404)") + public void siteManagerCantGetSiteMembershipRequestsInexistentUser() throws Exception + { + restClient.authenticateUser(newMember).withCoreAPI().usingUser(UserModel.getRandomUserModel()).getSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user can get site membership requests on site with no requests and response is successful (200)") + public void userWithNoRequestsCantGetSiteMembershipRequests() throws Exception + { + UserModel noRequestUser = dataUser.createRandomTestUser(); + restClient.authenticateUser(noRequestUser).withCoreAPI().usingMe().getSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, noRequestUser.getUsername(), moderatedSite.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site manager can't get site membership requests on public site and response is not found (404)") + public void siteManagerCantGetPublicSiteMembershipRequests() throws Exception + { + UserModel publicUser = dataUser.createRandomTestUser(); + restClient.authenticateUser(publicUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(publicSite); + restClient.authenticateUser(adminUser).withCoreAPI() + .usingUser(publicUser).getSiteMembershipRequest(publicSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, publicUser.getUsername(), publicSite.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site manager can't get site membership requests on private site and response is not found (404)") + public void siteManagerCantGetPrivateSiteMembershipRequests() throws Exception + { + UserModel privateUser = dataUser.createRandomTestUser(); + SiteModel privateSite = dataSite.usingUser(siteCreator).createPrivateRandomSite(); + restClient.authenticateUser(privateUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(privateSite); + restClient.authenticateUser(siteCreator).withCoreAPI().usingUser(privateUser).getSiteMembershipRequest(privateSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, privateUser.getUsername(), privateSite.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site manager can't get site membership requests for inexistent site and response is not found (404)") + public void siteManagerCantGetSiteMembershipRequestsForInexistentSite() throws Exception + { + SiteModel inexistentSite = SiteModel.getRandomSiteModel(); + restClient.authenticateUser(siteCreator).withCoreAPI().usingMe().getSiteMembershipRequest(inexistentSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, siteCreator.getUsername(), inexistentSite.getId())); + } + + @Bug(id = "ACE-2413") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify if person ID field is empty user can't get site membership requests on moderated site and response is not found (400)") + public void emptyPersonIdCantGetModeratedSiteMembershipRequests() throws Exception + { + UserModel emptyUser = new UserModel("", "password"); + restClient.authenticateUser(siteCreator).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + restClient.authenticateUser(siteCreator).withCoreAPI().usingUser(emptyUser).getSiteMembershipRequest(moderatedSite); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .containsSummary(String.format("The entity with id: personId is null. was not found")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Approve site membership request then verify get site membership requests - response is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void approveRequestThenGetSiteMembershipRequest() throws Exception + { + UserModel userWithApprovedRequests = dataUser.createRandomTestUser(); + restClient.authenticateUser(userWithApprovedRequests).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestTaskModel taskModel = restClient.authenticateUser(userWithApprovedRequests).withWorkflowAPI().getTasks().getTaskModelByDescription(moderatedSite); + workflow.approveSiteMembershipRequest(siteCreator.getUsername(), siteCreator.getPassword(), taskModel.getId(), true, "Approve"); + + returnedModel = restClient.authenticateUser(userWithApprovedRequests).withCoreAPI().usingMe().getSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, userWithApprovedRequests.getUsername(), moderatedSite.getId())) + .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Reject site membership request then verify get site membership requests - response is 404") + public void rejectRequestThenGetSiteMembershipRequest() throws Exception + { + UserModel userWithRejectedRequests = dataUser.createRandomTestUser(); + restClient.authenticateUser(userWithRejectedRequests).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestTaskModel taskModel = restClient.authenticateUser(userWithRejectedRequests).withWorkflowAPI().getTasks().getTaskModelByDescription(moderatedSite); + workflow.approveSiteMembershipRequest(siteCreator.getUsername(), siteCreator.getPassword(), taskModel.getId(), false, "Rejected"); + + returnedModel = restClient.authenticateUser(userWithRejectedRequests).withCoreAPI().usingMe().getSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, userWithRejectedRequests.getUsername(), moderatedSite.getId())) + .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @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 site favorite response with Rest API") + public void checkResponseSchemaForGetSiteMembershipRequest() throws Exception + { + dataUser.usingUser(siteCreator).addUserToSite(newMember, moderatedSite, UserRole.SiteContributor); + returnedModel = restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().getSiteMembershipRequest(moderatedSite); + + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedModel.assertThat().field("id").is(moderatedSite.getId()) + .and().field("message").is("Please accept me") + .and().field("site.title").is(moderatedSite.getTitle()) + .and().field("site.visibility").is(SiteService.Visibility.MODERATED.toString()) + .and().field("site.guid").isNotEmpty() + .and().field("site.description").is(moderatedSite.getDescription()) + .and().field("site.preset").is("site-dashboard") + .and().field("site.role").is("SiteContributor"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify that getFavoriteSites request applies valid properties param") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void getSiteMembershipRequestWithValidPropertiesParam() throws Exception + { + RestSiteMembershipRequestModel returnedModel = restClient.authenticateUser(newMember).withParams("properties=message").withCoreAPI().usingAuthUser() + .getSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedModel.assertThat().fieldsCount().is(1).assertThat().field("message").isNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify that getFavoriteSites request returns status 200 when using valid parameters") + public void getSiteMembershipRequestUsingParameters() throws Exception + { + RestSiteMembershipRequestModel returnedModel = restClient.withParams("message=Please accept me") + .authenticateUser(newMember).withCoreAPI().usingMe() + .getSiteMembershipRequest(moderatedSite); + + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedModel.assertThat().field("id").is(moderatedSite.getId()).and().field("site.title").is(moderatedSite.getTitle()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify user doesn't have permission to get site membership request of admin without membership request with Rest API and status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void userIsNotAbleToGetSiteMembershipRequestOfAdminWithoutRequest() throws Exception + { + returnedModel = restClient.authenticateUser(newMember).withCoreAPI().usingUser(adminUser).getSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, adminUser.getUsername(), moderatedSite.getId())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER).stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify user doesn't have permission to get site membership request of admin with requests with Rest API and status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void userIsNotAbleToGetSiteMembershipRequestOfAdminWithRequest() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + + returnedModel = restClient.authenticateUser(newMember).withCoreAPI().usingUser(adminUser).getSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, adminUser.getUsername(), moderatedSite.getId())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify admin user doesn't have permission to get site membership request of another user with Rest API and status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void userIsNotAbleToGetSiteMembershipRequestOfAnotherUser() throws Exception + { + UserModel userCollaborator = dataUser.createRandomTestUser(); + UserModel userConsumer = dataUser.createRandomTestUser(); + restClient.authenticateUser(userConsumer).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + dataUser.usingUser(siteCreator).addUserToSite(userConsumer, moderatedSite, UserRole.SiteConsumer); + restClient.authenticateUser(userCollaborator).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + dataUser.usingUser(siteCreator).addUserToSite(userCollaborator, moderatedSite, UserRole.SiteCollaborator); + + returnedModel = restClient.authenticateUser(userCollaborator).withCoreAPI().usingUser(userConsumer).getSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, userConsumer.getUsername(), moderatedSite.getId())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + +} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestsTests.java b/e2e-test/src/test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestsTests.java new file mode 100644 index 000000000..470b118dd --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestsTests.java @@ -0,0 +1,421 @@ +package org.alfresco.rest.sites.membershipRequests; + +import static org.alfresco.utility.report.log.Step.STEP; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.*; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Tests for + * GET /people/{personId}/site-membership-requests + * GET /site-membership-requests + * POST /sites/{siteId}/site-membership-requests/{inviteeId}/approve + * POST /sites/{siteId}/site-membership-requests/{inviteeId}/reject + * + * @author Cristina Axinte + */ + +public class GetSiteMembershipRequestsTests extends RestTest +{ + UserModel siteManager, newMember, adminUser, regularUser, testUser, testUser1; + DataUser.ListUserWithRoles usersWithRoles; + SiteModel moderatedSite1, moderatedSite2; + RestSiteMembershipRequestModelsCollection siteMembershipRequests; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + siteManager = dataUser.createRandomTestUser(); + newMember = dataUser.createRandomTestUser(); + regularUser = dataUser.createRandomTestUser(); + + testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteConsumer); + testUser1 = dataUser.createRandomTestUser("testUser1"); + testUser1.setUserRole(UserRole.SiteConsumer); + + moderatedSite1 = dataSite.usingUser(siteManager).createModeratedRandomSite(); + moderatedSite2 = dataSite.usingUser(siteManager).createModeratedRandomSite(); + + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite1); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite1); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + usersWithRoles = dataUser.addUsersWithRolesToSite(moderatedSite1, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @Bug(id = "MNT-16557") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user gets all site membership requests of a specific person with Rest API and response is successful (200)") + public void managerUserGetsSiteMembershipRequestsWithSuccess() throws Exception + { + siteMembershipRequests = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI() + .usingUser(newMember).getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembershipRequests.assertThat().entriesListIsNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @Bug(id = "MNT-16557") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify collaborator user fails to get all site membership requests of another user with Rest API (403)") + public void collaboratorUserFailsToGetSiteMembershipRequestsOfAnotherUser() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI() + .usingUser(newMember).getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @Bug(id = "MNT-16557") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify contributor user fails to get all site membership requests of another user with Rest API (403)") + public void contributorUserFailsToGetSiteMembershipRequestsOfAnotherUser() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI() + .usingUser(newMember).getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @Bug(id = "MNT-16557") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify consumer user fails to get all site membership requests of another user with Rest API (403)") + public void consumerUserFailsToGetSiteMembershipRequestsOfAnotherUser() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingUser(newMember).getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @Bug(id = "MNT-16557") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin user gets all site membership requests of a specific person with Rest API and response is successful (200)") + public void adminGetsSiteMembershipRequestsOfanotherUserWithSuccess() throws Exception + { + siteMembershipRequests = restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI() + .usingUser(newMember).getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembershipRequests.assertThat().entriesListIsNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) +// @Bug(id = "MNT-16904", description = "It fails only on environment with tenants") + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user fails to get all site membership requests of a specific person with Rest API when the authentication fails (401)") + public void unauthorizedUserFailsToGetSiteMembershipRequests() throws Exception + { + restClient.authenticateUser(new UserModel("random user", "random password")).withCoreAPI() + .usingAuthUser().getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify a user gets all its own site membership requests with Rest API and response is successful (200)") + public void oneUserGetsItsOwnSiteMembershipRequestsWithSuccess() throws Exception + { + siteMembershipRequests = restClient.authenticateUser(newMember).withCoreAPI().usingUser(newMember).getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembershipRequests.assertThat().entriesListContains("id", moderatedSite1.getId()) + .assertThat().entriesListContains("message", "Please accept me") + .assertThat().entriesListCountIs(2); + RestSiteModel firstSite = siteMembershipRequests.getEntries().get(0).onModel().getSite(); + if (firstSite.getId().equals(moderatedSite1.getId())) + { + firstSite.assertThat().field("visibility").is(moderatedSite1.getVisibility()) + .assertThat().field("guid").is(moderatedSite1.getGuid()) + .assertThat().field("description").is(moderatedSite1.getDescription()) + .assertThat().field("id").is(moderatedSite1.getId()) + .assertThat().field("title").is(moderatedSite1.getTitle()); + } + else + { + firstSite.assertThat().field("visibility").is(moderatedSite2.getVisibility()) + .assertThat().field("guid").is(moderatedSite2.getGuid()) + .assertThat().field("description").is(moderatedSite2.getDescription()) + .assertThat().field("id").is(moderatedSite2.getId()) + .assertThat().field("title").is(moderatedSite2.getTitle()); + } + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, + description = "Verify that for invalid maxItems parameter status code returned is 400.") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void checkInvalidMaxItemsStatusCode() throws Exception + { + restClient.authenticateUser(adminUser).withParams("maxItems=AB") + .withCoreAPI().usingUser(newMember).getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "AB")); + + restClient.authenticateUser(adminUser).withParams("maxItems=0") + .withCoreAPI().usingUser(newMember).getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, + description = "Verify that for invalid skipCount parameter status code returned is 400.") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void checkInvalidSkipCountStatusCode() throws Exception + { + restClient.authenticateUser(adminUser).withParams("skipCount=AB") + .withCoreAPI().usingUser(newMember).getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "AB")); + + restClient.authenticateUser(adminUser).withParams("skipCount=-1") + .withCoreAPI().usingUser(newMember).getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, + description = "Verify that if personId does not exist status code returned is 404.") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void ifPersonIdDoesNotExist() throws Exception + { + UserModel nonexistentUser = dataUser.createRandomTestUser(); + nonexistentUser.setUsername("nonexistent"); + + restClient.authenticateUser(adminUser).withCoreAPI().usingUser(nonexistentUser).getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "nonexistent")) + .statusCodeIs(HttpStatus.NOT_FOUND) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, + description = "Specify -me- string in place of for request.") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void replacePersonIdWithMeRequest() throws Exception + { + UserModel meUser = dataUser.createRandomTestUser(); + restClient.authenticateUser(meUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite1); + siteMembershipRequests = restClient.authenticateUser(meUser).withCoreAPI().usingMe().getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembershipRequests.assertThat().entriesListContains("id", moderatedSite1.getId()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, + description = "Verify that if empty personId is used status code returned is 404.") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void useEmptyPersonId() throws Exception + { + UserModel emptyNameMember = dataUser.createRandomTestUser(); + emptyNameMember.setUsername(" "); + + restClient.authenticateUser(adminUser).withCoreAPI().usingUser(emptyNameMember).getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, emptyNameMember.getUsername())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, + description = "Get site membership requests to a public site.") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void getRequestsToPublicSite() throws Exception + { + SiteModel publicSite = dataSite.usingAdmin().createPublicRandomSite(); + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(publicSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + siteMembershipRequests = restClient.withCoreAPI().usingAuthUser().getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembershipRequests.assertThat().entriesListDoesNotContain("id", publicSite.getId()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, + description = "Approve request then get requests.") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void approveRequestThenGetRequests() throws Exception + { + UserModel siteManager = dataUser.createRandomTestUser(); + + SiteModel moderatedSite = dataSite.usingUser(siteManager).createModeratedRandomSite(); + restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestTaskModel taskModel = restClient.authenticateUser(newMember).withWorkflowAPI().getTasks().getTaskModelByDescription(moderatedSite); + workflow.approveSiteMembershipRequest(siteManager.getUsername(), siteManager.getPassword(), taskModel.getId(), true, "Approve"); + + siteMembershipRequests = restClient.authenticateUser(newMember).withCoreAPI().usingMe().getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembershipRequests.assertThat().entriesListDoesNotContain("id", moderatedSite.getId()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, + description = "Verify admin user gets all its own site membership requests with Rest API and response is successful (200)") + public void adminGetsItsOwnSiteMembershipRequestsWithSuccess() throws Exception + { + siteMembershipRequests = restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembershipRequests.assertThat().entriesListContains("id", moderatedSite1.getId()) + .assertThat().entriesListContains("id", moderatedSite2.getId()); + } + + @Bug(id = "MNT-16557") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, + description = "Verify regular user fails to get all site membership requests of another user with Rest API (403)") + public void regularUserFailsToGetSiteMembershipRequestsOfAnotherUser() throws Exception + { + restClient.authenticateUser(regularUser).withCoreAPI() + .usingUser(newMember).getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Bug(id = "MNT-16557") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, + description = "Verify regular user fails to get all site membership requests of admin with Rest API (403)") + public void regularUserFailsToGetSiteMembershipRequestsOfAdmin() throws Exception + { + restClient.authenticateUser(regularUser).withCoreAPI() + .usingUser(adminUser).getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, + description = "Verify regular user is able to get his site membership requests with, but skip the first one") + public void getSiteMembershipRequestsButSkipTheFirstOne() throws Exception + { + siteMembershipRequests = restClient.authenticateUser(newMember).withParams("orderBy=id ASC").withCoreAPI() + .usingMe().getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembershipRequests.assertThat().entriesListContains("id", moderatedSite1.getId()) + .assertThat().entriesListContains("id", moderatedSite2.getId()); + + RestSiteMembershipRequestModel firstSiteMembershipRequest = siteMembershipRequests.getEntries().get(0).onModel(); + RestSiteMembershipRequestModel secondSiteMembershipRequest = siteMembershipRequests.getEntries().get(1).onModel(); + + siteMembershipRequests = restClient.authenticateUser(newMember).withParams("orderBy=id ASC&skipCount=1").withCoreAPI() + .usingMe().getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembershipRequests.assertThat().entriesListDoesNotContain("id", firstSiteMembershipRequest.getId()) + .assertThat().entriesListContains("id", secondSiteMembershipRequest.getId()) + .assertThat().entriesListContains("id", secondSiteMembershipRequest.getSite().getId()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, + description = "Verify regular user is able to get his site membership requests with higher skipCount than number of requests") + public void getSiteMembershipRequestsWithHighSkipCount() throws Exception + { + siteMembershipRequests = restClient.authenticateUser(newMember).withParams("skipCount=3").withCoreAPI() + .usingMe().getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembershipRequests.assertThat().entriesListIsEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, + description = "Verify get site membership requests returns an empty list where there are no requests") + public void getSiteMembershipRequestsWhereThereAreNoRequests() throws Exception + { + siteMembershipRequests = restClient.authenticateUser(regularUser).withCoreAPI().usingMe().getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembershipRequests.assertThat().entriesListIsEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, + description = "Reject request then get site membership requests.") + public void rejectRequestThenGetSiteMembershipRequests() throws Exception + { + UserModel userWithRejectedRequests = dataUser.createRandomTestUser(); + + restClient.authenticateUser(userWithRejectedRequests).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite1); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestTaskModel taskModel = restClient.authenticateUser(userWithRejectedRequests).withWorkflowAPI().getTasks().getTaskModelByDescription(moderatedSite1); + workflow.approveSiteMembershipRequest(siteManager.getUsername(), siteManager.getPassword(), taskModel.getId(), false, "Rejected"); + + siteMembershipRequests = restClient.authenticateUser(userWithRejectedRequests).withCoreAPI().usingMe().getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembershipRequests.assertThat().entriesListDoesNotContain("id", moderatedSite1.getId()) + .assertThat().entriesListContains("id", moderatedSite2.getId()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, + executionType = ExecutionType.REGRESSION, + description = "Check get site membership requests when properties parameter is used") + public void getSiteMembershipRequestsWithProperties() throws Exception + { + siteMembershipRequests = restClient.authenticateUser(newMember).withParams("properties=id") + .withCoreAPI().usingAuthUser().getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembershipRequests.assertThat().entriesListContains("id", moderatedSite1.getId()) + .assertThat().entriesListContains("id", moderatedSite2.getId()); + RestSiteMembershipRequestModel siteMembershipRequest = siteMembershipRequests.getOneRandomEntry().onModel(); + siteMembershipRequest.assertThat().fieldsCount().is(1); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Sanity test for endpoints: GET /site-membership-requests, POST /sites/{siteId}/site-membership-requests/{inviteeId}/approve, POST /sites/{siteId}/site-membership-requests/{inviteeId}/reject") + public void approveRejectSiteMembership() throws Exception + { + STEP("1. Make membership requests for 2 users on moderatedSite."); + restClient.authenticateUser(testUser).withCoreAPI().usingMe().addSiteMembershipRequest(moderatedSite1); + restClient.authenticateUser(testUser1).withCoreAPI().usingMe().addSiteMembershipRequest(moderatedSite1); + + STEP("2. Get site memberships and filter using username and siteId "); + RestSitePersonMembershipRequestModelsCollection membership = restClient.authenticateUser(siteManager) + .withParams("where=(personId='" + testUser.getUsername() + "' AND siteId='" + moderatedSite1.getId() + "')").withCoreAPI() + .usingSite(moderatedSite1).getSiteMemberships(); + + restClient.assertStatusCodeIs(HttpStatus.OK); + membership.getEntryByIndex(0).getSite().assertThat().field("id").is(moderatedSite1.getId()); + membership.getEntryByIndex(0).getPersonModel().assertThat().field("id").is(testUser.getUsername()); + + STEP("3. Approve site membership for one of the users. Check that the user is now a member of the site"); + restClient.authenticateUser(siteManager).withCoreAPI().usingSite(moderatedSite1).approveSiteMembership(testUser); + restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.withCoreAPI().usingSite(moderatedSite1).getSiteMember(testUser).assertThat().field("id").is(testUser.getUsername()).and().field("role") + .is(testUser.getUserRole()); + + STEP("4. Reject site membership for the second user. Check that the user is not a member of the site"); + restClient.authenticateUser(siteManager).withCoreAPI().usingSite(moderatedSite1).rejectSiteMembership(testUser1); + restClient.assertStatusCodeIs(HttpStatus.OK); + RestSiteMemberModelsCollection memberList = restClient.withCoreAPI().usingSite(moderatedSite1).getSiteMembers(); + memberList.assertThat().entriesListDoesNotContain("id", testUser1.getUsername()); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/sites/membershipRequests/UpdateSiteMembershipRequestTests.java b/e2e-test/src/test/java/org/alfresco/rest/sites/membershipRequests/UpdateSiteMembershipRequestTests.java new file mode 100644 index 000000000..c40d3a2b5 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/sites/membershipRequests/UpdateSiteMembershipRequestTests.java @@ -0,0 +1,610 @@ +package org.alfresco.rest.sites.membershipRequests; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestSiteMembershipRequestModel; +import org.alfresco.rest.model.RestTaskModel; +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.HttpMethod; +import org.springframework.http.HttpStatus; +import org.testng.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class UpdateSiteMembershipRequestTests extends RestTest +{ + private SiteModel moderatedSite; + private ListUserWithRoles usersWithRoles; + private UserModel adminUser, managerUser; + private String updatedMessage, moderatedSiteId; + private RestSiteMembershipRequestModel requestUpdateModel, requestGetModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws DataPreparationException + { + adminUser = dataUser.getAdminUser(); + managerUser = dataUser.createRandomTestUser(); + moderatedSite = dataSite.usingUser(managerUser).createModeratedRandomSite(); + + usersWithRoles = dataUser.addUsersWithRolesToSite(moderatedSite, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + updatedMessage = "Please review my request"; + moderatedSiteId = moderatedSite.getId(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify user is able to update its own site membership request") + public void userIsAbleToUpdateItsOwnSiteMembershipRequest() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + requestUpdateModel = restClient.withCoreAPI().usingUser(newMember).updateSiteMembershipRequest(moderatedSite, updatedMessage); + restClient.assertStatusCodeIs(HttpStatus.OK); + + requestUpdateModel.assertThat().field("id").is(moderatedSite.getId()) + .assertThat().field("message").is(updatedMessage) + .assertThat().field("site").isNotEmpty() + .assertThat().field("modifiedAt").isNotEmpty() + .assertThat().field("createdAt").isNotEmpty(); + requestUpdateModel.getSite().assertThat().field("visibility").is(moderatedSite.getVisibility()) + .assertThat().field("guid").is(moderatedSite.getGuid()) + .assertThat().field("description").is(moderatedSite.getDescription()) + .assertThat().field("id").is(moderatedSite.getId()) + .assertThat().field("preset").is("site-dashboard") + .assertThat().field("title").is(moderatedSite.getTitle()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site manager is not able to update membership request of another user") +// @Bug(id = "MNT-16919", description = "Not a bug, The presence of the personId in the URL does not mean it should be possible to act on any other users behalf.") + public void siteManagerIsNotAbleToUpdateSiteMembershipRequestOfAnotherUser() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingUser(newMember) + .updateSiteMembershipRequest(moderatedSite, updatedMessage); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site collaborator is not able to update membership request of another user") + // @Bug(id = "MNT-16919", description = "Not a bug, The presence of the personId in the URL does not mean it should be possible to act on any other users behalf.") + public void siteCollaboratorIsNotAbleToUpdateSiteMembershipRequestOfAnotherUser() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingUser(newMember) + .updateSiteMembershipRequest(moderatedSite, updatedMessage); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site contributor is not able to update membership request of another user") + // @Bug(id = "MNT-16919", description = "Not a bug, The presence of the personId in the URL does not mean it should be possible to act on any other users behalf.") + public void siteContributorIsNotAbleToUpdateSiteMembershipRequestOfAnotherUser() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingUser(newMember) + .updateSiteMembershipRequest(moderatedSite, updatedMessage); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site consumer is not able to update membership request of another user") + // @Bug(id = "MNT-16919", description = "Not a bug, The presence of the personId in the URL does not mean it should be possible to act on any other users behalf.") + public void siteConsumerIsNotAbleToUpdateSiteMembershipRequestOfAnotherUser() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingUser(newMember) + .updateSiteMembershipRequest(moderatedSite, updatedMessage); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify one user is not able to update membership request of another user") + // @Bug(id = "MNT-16919", description = "Not a bug, The presence of the personId in the URL does not mean it should be possible to act on any other users behalf.") + public void regularUserIsNotAbleToUpdateSiteMembershipRequestOfAnotherUser() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + UserModel otherMember = dataUser.createRandomTestUser(); + + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + + restClient.authenticateUser(otherMember).withCoreAPI().usingUser(newMember).updateSiteMembershipRequest(moderatedSite, updatedMessage); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is not able to update membership request of another user") + // @Bug(id = "MNT-16919", description = "Not a bug, The presence of the personId in the URL does not mean it should be possible to act on any other users behalf.") + public void adminIsNotAbleToUpdateSiteMembershipRequestOfAnotherUser() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + + restClient.authenticateUser(adminUser).withCoreAPI().usingUser(newMember).updateSiteMembershipRequest(moderatedSite, updatedMessage); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify unauthorized user is not able to update user site membership request") + public void unauthorizedUserIsNotAbleToUpdateSiteMembershipRequest() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + newMember.setPassword("fakePass"); + restClient.withCoreAPI().usingUser(newMember).updateSiteMembershipRequest(moderatedSite, updatedMessage); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError().containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is able to update its own site membership request using -me-") + public void usingMeUpdateSiteMembershipRequest() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + requestUpdateModel = restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(moderatedSite, updatedMessage); + restClient.assertStatusCodeIs(HttpStatus.OK); + requestUpdateModel.assertMembershipRequestMessageIs(updatedMessage).and().field("id").is(moderatedSite.getId()).and().field("modifiedAt").isNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify inexistent user is not able to update its own site membership request") + public void inexistentUserCannotUpdateSiteMembershipRequest() throws Exception + { + UserModel inexistentUser = UserModel.getRandomUserModel(); + restClient.authenticateUser(managerUser).withCoreAPI().usingUser(inexistentUser).updateSiteMembershipRequest(moderatedSite, updatedMessage); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, inexistentUser.getUsername())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to update its own site membership request for inexistent site") + public void userCannotUpdateSiteMembershipRequestForInexistentSite() throws Exception + { + SiteModel randomSite = SiteModel.getRandomSiteModel(); + UserModel newMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(newMember).withCoreAPI().usingMe().updateSiteMembershipRequest(randomSite, updatedMessage); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, newMember.getUsername(), randomSite.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is able not to update its own site membership request for public site") + public void userCannotUpdateSiteMembershipRequestForPublicSite() throws Exception + { + SiteModel publicSite = dataSite.usingUser(managerUser).createPublicRandomSite(); + UserModel newMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(publicSite); + restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(publicSite, updatedMessage); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, newMember.getUsername(), publicSite.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to update its own site membership request for private site") + public void userCannotUpdateSiteMembershipRequestForPrivateSite() throws Exception + { + SiteModel privateSite = dataSite.usingUser(managerUser).createPrivateRandomSite(); + UserModel newMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(privateSite); + restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(privateSite, updatedMessage); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, newMember.getUsername(), privateSite.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is able to update its own site membership request with initial message") + public void userCanUpdateSiteMembershipRequestWithInitialMessage() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(updatedMessage, moderatedSite, "Accept me"); + requestUpdateModel = restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(moderatedSite, updatedMessage); + restClient.assertStatusCodeIs(HttpStatus.OK); + requestUpdateModel.assertMembershipRequestMessageIs(updatedMessage).and().field("id").is(moderatedSite.getId()).and().field("modifiedAt").isNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is able to update its own site membership request with different message") + public void userCanUpdateSiteMembershipRequestWithDifferentMessage() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest("", moderatedSite, "Accept me"); + requestUpdateModel = restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(moderatedSite, updatedMessage); + restClient.assertStatusCodeIs(HttpStatus.OK); + requestUpdateModel.assertMembershipRequestMessageIs(updatedMessage).and().field("id").is(moderatedSite.getId()).and().field("modifiedAt").isNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify modifiedAt field for update siteMembership request call") + public void verifyModifiedAtForUpdateSiteMembershipRequest() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); + String firstModifiedAt = restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(moderatedSite, "first message").getModifiedAt(); + String secondModifiedAt = restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(moderatedSite, "second message").getModifiedAt(); + Assert.assertNotEquals(firstModifiedAt, secondModifiedAt); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify user is not able to update membership request of admin") + public void userIsNotAbleToUpdateSiteMembershipRequestOfAdmin() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser() + .addSiteMembershipRequest(moderatedSite); + + restClient.authenticateUser(newMember).withCoreAPI().usingUser(adminUser) + .updateSiteMembershipRequest(moderatedSite, updatedMessage); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format("The entity with id: " + RestErrorModel.ENTITY_NOT_FOUND, adminUser.getUsername())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify site manager is able to update site membership request") + public void updateSiteMembershipRequestAfterUserIsAddedAsMember() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser() + .addSiteMembershipRequest(moderatedSite); + dataUser.usingUser(managerUser).addUserToSite(newMember, moderatedSite, UserRole.SiteManager); + requestUpdateModel = restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser() + .updateSiteMembershipRequest(moderatedSite, updatedMessage); + + restClient.assertStatusCodeIs(HttpStatus.OK); + requestUpdateModel.assertThat().field("id").is(moderatedSite.getId()) + .assertThat().field("message").is(updatedMessage) + .assertThat().field("modifiedAt").isNotEmpty() + .assertThat().field("createdAt").isNotEmpty(); + requestUpdateModel.getSite().assertThat().field("role").is(UserRole.SiteManager) + .assertThat().field("visibility").is(moderatedSite.getVisibility()) + .assertThat().field("guid").is(moderatedSite.getGuid()) + .assertThat().field("description").is(moderatedSite.getDescription()) + .assertThat().field("id").is(moderatedSite.getId()) + .assertThat().field("preset").is("site-dashboard") + .assertThat().field("title").is(moderatedSite.getTitle()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify admin is able to update site membership request") + public void adminIsAbleToUpdateHisSiteMembershipRequest() throws Exception + { + UserModel regularUser = dataUser.createRandomTestUser(); + SiteModel anotherModeratedSite = dataSite.usingUser(regularUser).createModeratedRandomSite(); + requestUpdateModel = restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser() + .addSiteMembershipRequest(anotherModeratedSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + requestUpdateModel = restClient.withCoreAPI().usingAuthUser() + .updateSiteMembershipRequest(anotherModeratedSite, updatedMessage); + + restClient.assertStatusCodeIs(HttpStatus.OK); + requestUpdateModel.assertThat().field("id").is(anotherModeratedSite.getId()) + .assertThat().field("message").is("Please review my request") + .assertThat().field("modifiedAt").isNotEmpty() + .assertThat().field("createdAt").isNotEmpty(); + requestUpdateModel.getSite().assertThat().field("visibility").is(anotherModeratedSite.getVisibility()) + .assertThat().field("guid").is(anotherModeratedSite.getGuid()) + .assertThat().field("description").is(anotherModeratedSite.getDescription()) + .assertThat().field("id").is(anotherModeratedSite.getId()) + .assertThat().field("preset").is("site-dashboard") + .assertThat().field("title").is(anotherModeratedSite.getTitle()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify user update site membership request with no message then adds a new message") + public void userUpdateSiteMembershipRequestWithNoMessageThenAddsNewMessage() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + requestUpdateModel = restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser() + .addSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + requestUpdateModel.assertThat().field("id").is(moderatedSite.getId()) + .assertThat().field("message").is("Please accept me"); + + requestUpdateModel = restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(moderatedSite, ""); + restClient.assertStatusCodeIs(HttpStatus.OK); + requestUpdateModel.assertThat().field("id").is(moderatedSite.getId()) + .and().field("modifiedAt").isNotEmpty() + .assertThat().field("message").isNull(); + + requestUpdateModel = restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(moderatedSite, updatedMessage); + requestUpdateModel.assertThat().field("id").is(moderatedSite.getId()) + .assertThat().field("message").is(updatedMessage) + .assertThat().field("modifiedAt").isNotEmpty() + .assertThat().field("createdAt").isNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify user updates site membership request and verifies 'ModifiedAt' field using GET") + public void userUpdateSiteMembershipRequestAndCheckModifiedAtWithGet() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + requestUpdateModel = restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser() + .addSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + requestUpdateModel.assertThat().field("id").is(moderatedSite.getId()) + .assertThat().field("message").is("Please accept me"); + + requestUpdateModel = restClient.withCoreAPI().usingAuthUser().updateSiteMembershipRequest(moderatedSite, updatedMessage); + requestGetModel = restClient.withCoreAPI().usingAuthUser().getSiteMembershipRequest(moderatedSite); + + restClient.assertStatusCodeIs(HttpStatus.OK); + requestGetModel.assertThat().field("id").is(requestUpdateModel.getId()) + .and().field("modifiedAt").is(requestUpdateModel.getModifiedAt()) + .assertThat().field("message").is(requestUpdateModel.getMessage()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Update membership request - empty body") + public void emptyBodyUpdateSiteMembershipRequest() throws Exception + { + restClient.authenticateUser(adminUser).withCoreAPI(); + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"\": \"\",\"\": \"\", \"\": \"\"}", + "people/{personId}/site-membership-requests/{siteId}", adminUser.getUsername(), moderatedSite.getId()); + restClient.processModel(RestSiteMembershipRequestModel.class, request); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.NO_CONTENT, "Unrecognized field " + "\"\"")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Update membership request - missing 'Title' field from Json") + public void missingTitleFieldBodyUpdateSiteMembershipRequest() throws Exception + { + SiteModel moderatedSite = dataSite.usingUser(managerUser).createModeratedRandomSite(); + UserModel newMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser() + .addSiteMembershipRequest(moderatedSite); + + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, + "{\"message\":\"Please review my request\",\"id\":\"" + moderatedSite.getId() + "\"}", + "people/{personId}/site-membership-requests/{siteId}", + newMember.getUsername(), moderatedSite.getId()); + requestUpdateModel = restClient.processModel(RestSiteMembershipRequestModel.class, request); + + restClient.assertStatusCodeIs(HttpStatus.OK); + requestUpdateModel.assertThat().field("id").is(moderatedSite.getId()) + .assertThat().field("message").is(updatedMessage) + .assertThat().field("site").isNotEmpty() + .assertThat().field("modifiedAt").isNotEmpty() + .assertThat().field("createdAt").isNotEmpty(); + requestUpdateModel.getSite().assertThat().field("visibility").is(moderatedSite.getVisibility()) + .assertThat().field("guid").is(moderatedSite.getGuid()) + .assertThat().field("description").is(moderatedSite.getDescription()) + .assertThat().field("id").is(moderatedSite.getId()) + .assertThat().field("preset").is("site-dashboard") + .assertThat().field("title").is(moderatedSite.getTitle()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Update site membership request - missing JSON body") + public void missingJsonFieldBodyUpdateSiteMembershipRequest() throws Exception + { + SiteModel moderatedSite = dataSite.usingUser(managerUser).createModeratedRandomSite(); + UserModel newMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser() + .addSiteMembershipRequest(moderatedSite); + + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "", + "people/{personId}/site-membership-requests/{siteId}", newMember.getUsername(), + moderatedSite.getId()); + requestUpdateModel = restClient.processModel(RestSiteMembershipRequestModel.class, request); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsSummary(String.format(RestErrorModel.NO_CONTENT, "No content to map due to end-of-input")) + .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "No content to map due to end-of-input")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Update site membership request - empty JSON body") + public void emptyJsonFieldBodyUpdateSiteMembershipRequest() throws Exception + { + SiteModel moderatedSite = dataSite.usingUser(managerUser).createModeratedRandomSite(); + UserModel newMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser() + .addSiteMembershipRequest(moderatedSite); + + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{}", + "people/{personId}/site-membership-requests/{siteId}", newMember.getUsername(), + moderatedSite.getId()); + requestUpdateModel = restClient.processModel(RestSiteMembershipRequestModel.class, request); + + restClient.assertStatusCodeIs(HttpStatus.OK); + requestUpdateModel.assertThat().field("id").is(moderatedSite.getId()) + .assertThat().field("message").isNull() + .assertThat().field("site").isNotEmpty() + .assertThat().field("modifiedAt").isNotEmpty() + .assertThat().field("createdAt").isNotEmpty(); + requestUpdateModel.getSite().assertThat().field("visibility").is(moderatedSite.getVisibility()) + .assertThat().field("guid").is(moderatedSite.getGuid()) + .assertThat().field("description").is(moderatedSite.getDescription()) + .assertThat().field("id").is(moderatedSite.getId()) + .assertThat().field("preset").is("site-dashboard") + .assertThat().field("title").is(moderatedSite.getTitle()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Update site membership request - invalid SiteId") + public void invalidSiteIdUpdateSiteMembershipRequest() throws Exception + { + moderatedSite.setId("invalidSiteId"); + restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser() + .updateSiteMembershipRequest(moderatedSite, updatedMessage); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, managerUser.getUsername(), moderatedSite.getId())); + + moderatedSite.setId(moderatedSiteId); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Update site membership request - empty SiteId") + public void emptySiteIdUpdateSiteMembershipRequest() throws Exception + { + moderatedSite.setId(""); + restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser() + .updateSiteMembershipRequest(moderatedSite, updatedMessage); + + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) + .assertLastError() + .containsSummary(RestErrorModel.PUT_EMPTY_ARGUMENT) + .containsErrorKey(RestErrorModel.PUT_EMPTY_ARGUMENT) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + + moderatedSite.setId(moderatedSiteId); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify inexistent user is not able to update site membership request") + public void emptyUserCannotUpdateSiteMembershipRequest() throws Exception + { + UserModel emptyUser = new UserModel("", "password"); + restClient.authenticateUser(emptyUser).withCoreAPI().usingAuthUser() + .updateSiteMembershipRequest(moderatedSite, updatedMessage); + + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Update site membership request - rejected Request") + public void rejectRequestThenUpdateSiteMembershipRequest() throws Exception + { + UserModel userWithRejectedRequests = dataUser.createRandomTestUser(); + restClient.authenticateUser(userWithRejectedRequests).withCoreAPI().usingAuthUser() + .addSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + RestTaskModel taskModel = restClient.authenticateUser(userWithRejectedRequests).withWorkflowAPI().getTasks() + .getTaskModelByDescription(moderatedSite); + workflow.approveSiteMembershipRequest(managerUser.getUsername(), managerUser.getPassword(), taskModel.getId(), false, "Rejected"); + + requestUpdateModel = restClient.authenticateUser(userWithRejectedRequests).withCoreAPI().usingMe() + .updateSiteMembershipRequest(moderatedSite, updatedMessage); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, userWithRejectedRequests.getUsername(), moderatedSite.getId())) + .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Update site membership request - approved Request") + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + public void approveRequestThenUpdateSiteMembershipRequest() throws Exception + { + UserModel userWithApprovedRequests = dataUser.createRandomTestUser(); + restClient.authenticateUser(userWithApprovedRequests).withCoreAPI().usingAuthUser() + .addSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + RestTaskModel taskModel = restClient.authenticateUser(userWithApprovedRequests).withWorkflowAPI().getTasks().getTaskModelByDescription(moderatedSite); + workflow.approveSiteMembershipRequest(managerUser.getUsername(), managerUser.getPassword(), taskModel.getId(), true, "Approve"); + + requestUpdateModel = restClient.authenticateUser(userWithApprovedRequests).withCoreAPI().usingMe() + .updateSiteMembershipRequest(moderatedSite, updatedMessage); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, userWithApprovedRequests.getUsername(), moderatedSite.getId())) + .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE}, executionType = ExecutionType.REGRESSION, + description = "Update site membership request using invalid network") + public void updateSiteMembershipRequestUsingInvalidNetwork() throws Exception + { + UserModel invalidUserNetwork = dataUser.createRandomTestUser(); + SiteModel site = dataSite.usingUser(invalidUserNetwork).createModeratedRandomSite(); + dataSite.usingUser(invalidUserNetwork).usingSite(site).addSiteToFavorites(); + invalidUserNetwork.setDomain("invalidNetwork"); + + requestUpdateModel = restClient.authenticateUser(invalidUserNetwork).withCoreAPI().usingMe() + .updateSiteMembershipRequest(site, updatedMessage); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE}, executionType = ExecutionType.REGRESSION, + description = "Verify user is not able to update a deleted site membership request") + public void userCantUpdateSiteMembershipRequestForDeletedRequest() throws Exception + { + SiteModel moderatedSite = dataSite.usingUser(managerUser).createModeratedRandomSite(); + UserModel newMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser() + .addSiteMembershipRequest(moderatedSite); + + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser() + .deleteSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + requestUpdateModel = restClient.withCoreAPI().usingAuthUser() + .updateSiteMembershipRequest(moderatedSite, updatedMessage); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, newMember.getUsername(), moderatedSite.getId())); + } +} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/rest/syncService/SyncServiceAPITests.java b/e2e-test/src/test/java/org/alfresco/rest/syncService/SyncServiceAPITests.java new file mode 100644 index 000000000..58dacb907 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/syncService/SyncServiceAPITests.java @@ -0,0 +1,204 @@ +package org.alfresco.rest.syncService; + +import java.util.LinkedList; +import java.util.List; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestSubscriberModel; +import org.alfresco.rest.model.RestSubscriberModelCollection; +import org.alfresco.rest.model.RestSyncNodeSubscriptionModel; +import org.alfresco.rest.model.RestSyncNodeSubscriptionModelCollection; +import org.alfresco.rest.model.RestSyncServiceHealthCheckModel; +import org.alfresco.rest.model.RestSyncSetChangesModel; +import org.alfresco.rest.model.RestSyncSetGetModel; +import org.alfresco.rest.model.RestSyncSetRequestModel; +import org.alfresco.rest.requests.syncServiceAPI.Healthcheck; +import org.alfresco.rest.requests.syncServiceAPI.Subscriptions.TYPE; +import org.alfresco.utility.LogFactory; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.slf4j.Logger; +import org.springframework.http.HttpStatus; +import org.testng.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Sanity tests for Testing Sync Service APIs + * + * @author mbhave + */ +@Test(groups = { TestGroup.SYNC_API, TestGroup.REQUIRES_AMP }) +public class SyncServiceAPITests extends RestTest +{ + private static Logger LOG = LogFactory.getLogger(); + + private UserModel adminUserModel; + private SiteModel siteModel; + private FolderModel targetFolder1; + private FolderModel targetFolder2; + + private RestSyncNodeSubscriptionModelCollection nodeSubscriptions; + + private String clientVersion; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + restClient.authenticateUser(adminUserModel); + + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + + targetFolder1 = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); + + targetFolder2 = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); + + siteModel.setGuid(restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(siteModel).getSite().getGuidWithoutVersion()); + + clientVersion = "1.1"; + } + + @Test(priority = 1) + public void testSyncServiceHealthCheck() throws Exception + { + // Perform HealthCheck + Healthcheck healthCheck = restClient.authenticateUser(adminUserModel).withPrivateAPI().doHealthCheck(); + + RestSyncServiceHealthCheckModel syncServiceHealthCheck = healthCheck.getHealthcheck(); + + Assert.assertTrue(syncServiceHealthCheck.getActiveMQConnection().getHealthy()); + Assert.assertTrue(syncServiceHealthCheck.getDatabaseConnection().getHealthy()); + Assert.assertTrue(syncServiceHealthCheck.getRepositoryConnection().getHealthy()); + Assert.assertTrue(syncServiceHealthCheck.getDeadlocks().getHealthy()); + Assert.assertTrue(syncServiceHealthCheck.getEventsHealthCheck().getHealthy()); + Assert.assertTrue(syncServiceHealthCheck.getSyncServiceIdCheck().getHealthy()); + Assert.assertTrue(syncServiceHealthCheck.getVersionCheck().getHealthy()); + } + + @Test(priority = 2) + public void testNewDeviceSubscription() throws Exception + { + // Register Device + RestSubscriberModel deviceSubscription = restClient.authenticateUser(adminUserModel).withPrivateAPI().withSubscribers() + .registerDevice("windows", clientVersion); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.onResponse().assertThat().body("entry.id", org.hamcrest.Matchers.notNullValue()); + restClient.onResponse().assertThat().body("entry.id", org.hamcrest.Matchers.equalTo(deviceSubscription.getId())); + + // Get Registered Devices + RestSubscriberModelCollection deviceSubscriptions = restClient.authenticateUser(adminUserModel).withParams("maxItems=500").withPrivateAPI() + .withSubscribers().getSubscribers(); + + restClient.onResponse().assertThat().body("list.entries.entry", org.hamcrest.Matchers.notNullValue()); + int noOfSubscriptions = deviceSubscriptions.getEntries().size(); + Assert.assertTrue(noOfSubscriptions > 0, "No Device subscriptions found when expected"); + Assert.assertTrue(deviceSubscriptions.getEntries().get(noOfSubscriptions - 1).onModel().getId().equals(deviceSubscription.getId()), "Not found: " + + deviceSubscription.getId()); + + } + + @Test(priority = 3) + public void testDeviceSubcriptionToNode() throws Exception + { + // Register Device + RestSubscriberModel deviceSubscription = restClient.authenticateUser(adminUserModel).withPrivateAPI().withSubscribers() + .registerDevice("windows", clientVersion); + + // Subscribe to a node + RestSyncNodeSubscriptionModel nodeSubscription = restClient.withPrivateAPI().withSubscriber(deviceSubscription) + .subscribeToNode(targetFolder1.getNodeRefWithoutVersion(), TYPE.BOTH); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.onResponse().assertThat().body("entry.deviceSubscriptionId", org.hamcrest.Matchers.notNullValue()); + restClient.onResponse().assertThat().body("entry.deviceSubscriptionId", org.hamcrest.Matchers.equalTo(deviceSubscription.getId())); + + restClient.onResponse().assertThat().body("entry.targetNodeId", org.hamcrest.Matchers.notNullValue()); + restClient.onResponse().assertThat().body("entry.targetNodeId", org.hamcrest.Matchers.equalTo(targetFolder1.getNodeRefWithoutVersion())); + + restClient.onResponse().assertThat().body("entry.id", org.hamcrest.Matchers.notNullValue()); + restClient.onResponse().assertThat().body("entry.id", org.hamcrest.Matchers.equalTo(nodeSubscription.getId())); + + // Get Sync Node Subscriptions + nodeSubscriptions = restClient.withPrivateAPI().withSubscriber(deviceSubscription).getSubscriptions(); + + nodeSubscriptions.assertThat().entriesListContains("id", nodeSubscription.getId()); + + restClient.onResponse().assertThat().body("list.entries.entry", org.hamcrest.Matchers.notNullValue()); + + int noOfSubscriptions = nodeSubscriptions.getEntries().size(); + Assert.assertTrue(noOfSubscriptions > 0, "No Sync subscriptions found when expected"); + LOG.info("Subscriptions: " + nodeSubscriptions); + Assert.assertEquals(nodeSubscriptions.getEntries().get(noOfSubscriptions - 1).onModel().getId(), nodeSubscription.getId()); + Assert.assertEquals(nodeSubscriptions.getEntries().get(noOfSubscriptions - 1).onModel().getDeviceSubscriptionId(), + nodeSubscription.getDeviceSubscriptionId()); + + // Get Sync Node Subscription by subscriptionId + RestSyncNodeSubscriptionModel subscription = restClient.withPrivateAPI().withSubscriber(deviceSubscription).getSubscription(nodeSubscription.getId()); + + subscription.assertThat().field("id").isNotNull().assertThat().field("id").is(nodeSubscription.getId()).assertThat().field("deviceSubscriptionId") + .isNotNull().assertThat().field("deviceSubscriptionId").is(nodeSubscription.getDeviceSubscriptionId()); + } + + @Test(priority = 4) + public void testDeviceSubcriptionToMultipleNodes() throws Exception + { + // Register Device + RestSubscriberModel deviceSubscription = restClient.authenticateUser(adminUserModel).withPrivateAPI().withSubscribers() + .registerDevice("windows", "1.2"); + + // Subscribe to a node + restClient.withPrivateAPI().withSubscriber(deviceSubscription) + .subscribeToNodes(siteModel.getGuid(), targetFolder1.getNodeRefWithoutVersion(), targetFolder2.getNodeRefWithoutVersion()); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + // Get Sync Node Subscriptions + RestSyncNodeSubscriptionModelCollection subscriptionList = restClient.withPrivateAPI().withSubscriber(deviceSubscription).getSubscriptions(); + + int countOfEntries = subscriptionList.getEntries().size(); + Assert.assertTrue(countOfEntries == 3, "Node subscriptions NOT found when expected"); + } + + @Test(priority = 5) + public void testSyncProcess() throws Exception + { + // Register Device + List clientChanges = new LinkedList<>(); + RestSubscriberModel deviceSubscription = restClient.authenticateUser(adminUserModel).withPrivateAPI().withSubscribers() + .registerDevice("windows", "1.2"); + + // Subscribe to a node + RestSyncNodeSubscriptionModel nodeSubscription = restClient.withPrivateAPI().withSubscriber(deviceSubscription) + .subscribeToNode(targetFolder1.getNodeRefWithoutVersion(), TYPE.BOTH); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + // Start Sync + RestSyncSetRequestModel syncRequest = restClient.authenticateUser(adminUserModel).withPrivateAPI().withSubscription(nodeSubscription) + .startSync(nodeSubscription, clientChanges, clientVersion); + + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + Assert.assertNotNull(syncRequest.getSyncId(), "Sync Id not expected to be null"); + String syncId = syncRequest.getSyncId(); + Assert.assertNotNull(syncRequest.getUrl(), "Sync URL not expected to be null"); + Assert.assertTrue(syncRequest.getUrl().endsWith(syncId), "Incorrect Sync URL, expected to end with syncId: " + syncId); + Assert.assertEquals(syncRequest.getStatus(), "ok", "Sync Status not ok. Actual: " + syncRequest.getStatus()); + Assert.assertNull(syncRequest.getMessage(), "Sync Message was expected to be null. Actual: " + syncRequest.getMessage()); + Assert.assertNull(syncRequest.getError(), "Sync Error expected to be null. Actual: " + syncRequest.getError()); + + // Get Sync Changes + RestSyncSetGetModel changeSet = restClient.withPrivateAPI().withSubscription(nodeSubscription).getSync(nodeSubscription, syncRequest); + + restClient.assertStatusCodeIs(HttpStatus.OK); + Assert.assertNotNull(changeSet.getSyncId(), "Sync Id not expected to be null"); + Assert.assertTrue(changeSet.getSyncId().equals(syncId), "Incorrect SyncId in the response"); + Assert.assertNotNull(changeSet.getMoreChanges(), "MoreChanges expected to be true or false. It's null"); + + // End Sync + restClient.withPrivateAPI().withSubscription(nodeSubscription).endSync(nodeSubscription, syncRequest); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/tags/GetTagTests.java b/e2e-test/src/test/java/org/alfresco/rest/tags/GetTagTests.java new file mode 100644 index 000000000..99bb12b8a --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/tags/GetTagTests.java @@ -0,0 +1,139 @@ +package org.alfresco.rest.tags; + +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestTagModel; +import org.alfresco.utility.constants.UserRole; +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; + +@Test(groups = {TestGroup.REQUIRE_SOLR}) +public class GetTagTests extends TagsDataPrep +{ + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + init(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify admin user gets tag using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void adminIsAbleToGetTag() throws Exception + { + RestTagModel returnedTag = restClient.authenticateUser(adminUserModel).withCoreAPI().getTag(documentTag); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedTag.assertThat().field("tag").is(documentTagValue.toLowerCase()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role gets tag using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) + public void userWithManagerRoleIsAbleToGetTag() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + + RestTagModel returnedTag = restClient.withCoreAPI().getTag(documentTag); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedTag.assertThat().field("tag").is(documentTagValue.toLowerCase()) + .assertThat().field("id").is(documentTag.getId()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify user with Collaborator role gets tag using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void userWithCollaboratorRoleIsAbleToGetTag() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + RestTagModel returnedTag = restClient.withCoreAPI().getTag(documentTag); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedTag.assertThat().field("tag").is(documentTagValue.toLowerCase()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify user with Contributor role gets tag using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void userWithContributorRoleIsAbleToGetTag() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + RestTagModel returnedTag = restClient.withCoreAPI().getTag(documentTag); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedTag.assertThat().field("tag").is(documentTagValue.toLowerCase()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify user with Consumer role gets tag using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void userWithConsumerRoleIsAbleToGetTag() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + RestTagModel returnedTag = restClient.withCoreAPI().getTag(documentTag); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedTag.assertThat().field("tag").is(documentTagValue.toLowerCase()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Manager user gets status code 401 if authentication call fails") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) +// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") + public void managerIsNotAbleToGetTagIfAuthenticationFails() throws Exception + { + UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); + String managerPassword = managerUser.getPassword(); + dataUser.addUserToSite(managerUser, siteModel, UserRole.SiteManager); + managerUser.setPassword("wrongPassword"); + restClient.authenticateUser(managerUser).withCoreAPI().getTag(documentTag); + managerUser.setPassword(managerPassword); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that if tag id is invalid status code returned is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void invalidTagIdTest() throws Exception + { + String tagId = documentTag.getId(); + documentTag.setId("random_tag_value"); + restClient.authenticateUser(adminUserModel).withCoreAPI().getTag(documentTag); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "random_tag_value")); + documentTag.setId(tagId); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, + executionType = ExecutionType.REGRESSION, description = "Check that properties filter is applied when getting tag using Manager user.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void checkPropertiesFilterIsApplied() throws Exception + { + RestTagModel returnedTag = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withParams("properties=id,tag").withCoreAPI().getTag(documentTag); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedTag.assertThat().field("id").is(documentTag.getId()) + .assertThat().field("tag").is(documentTag.getTag().toLowerCase()) + .assertThat().fieldsCount().is(2); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, + executionType = ExecutionType.REGRESSION, description = "Check that Manager user can get tag of a folder.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void getTagOfAFolder() throws Exception + { + RestTagModel returnedTag = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().getTag(folderTag); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedTag.assertThat().field("tag").is(folderTagValue.toLowerCase()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, + executionType = ExecutionType.REGRESSION, description = "Check default error model schema. Use invalid skipCount parameter.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void checkDefaultErrorModelSchema() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withParams("skipCount=abc").withCoreAPI().getTag(documentTag); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(String.format(RestErrorModel.INVALID_SKIPCOUNT, "abc")) + .containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "abc")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } +} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/rest/tags/GetTagsTests.java b/e2e-test/src/test/java/org/alfresco/rest/tags/GetTagsTests.java new file mode 100644 index 000000000..5c3b49ff9 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/tags/GetTagsTests.java @@ -0,0 +1,230 @@ +package org.alfresco.rest.tags; + +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestTagModel; +import org.alfresco.rest.model.RestTagModelsCollection; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.RandomData; +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.BeforeClass; +import org.testng.annotations.Test; + +@Test(groups = {TestGroup.REQUIRE_SOLR}) +public class GetTagsTests extends TagsDataPrep +{ + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + init(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role gets tags using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) + public void getTagsWithManagerRole() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat().entriesListIsNotEmpty() + .and().entriesListContains("tag", documentTagValue.toLowerCase()) + .and().entriesListContains("tag", documentTagValue2.toLowerCase()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify user with Collaborator role gets tags using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void getTagsWithCollaboratorRole() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat().entriesListIsNotEmpty() + .and().entriesListContains("tag", documentTagValue.toLowerCase()) + .and().entriesListContains("tag", documentTagValue2.toLowerCase()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify user with Contributor role gets tags using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void getTagsWithContributorRole() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat().entriesListIsNotEmpty() + .and().entriesListContains("tag", documentTagValue.toLowerCase()) + .and().entriesListContains("tag", documentTagValue2.toLowerCase()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify user with Consumer role gets tags using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void getTagsWithConsumerRole() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat().entriesListIsNotEmpty() + .and().entriesListContains("tag", documentTagValue.toLowerCase()) + .and().entriesListContains("tag", documentTagValue2.toLowerCase()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Failed authentication get tags call returns status code 401 with Manager role") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) +// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") + public void failedAuthenticationReturnsUnauthorizedStatus() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + userModel = dataUser.createRandomTestUser(); + userModel.setPassword("user wrong password"); + dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); + restClient.authenticateUser(userModel); + restClient.withCoreAPI().getTags(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that if maxItems is invalid status code returned is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION}) + public void maxItemsInvalidValueTest() throws Exception + { + restClient.authenticateUser(adminUserModel).withParams("maxItems=abc").withCoreAPI().getTags(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "abc")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that if skipCount is invalid status code returned is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION}) + public void skipCountInvalidValueTest() throws Exception + { + restClient.authenticateUser(adminUserModel).withParams("skipCount=abc").withCoreAPI().getTags(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "abc")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that file tag is retrieved") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION}) + public void fileTagIsRetrieved() throws Exception + { + restClient.authenticateUser(adminUserModel); + returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat().entriesListIsNotEmpty() + .and().entriesListContains("tag", documentTagValue.toLowerCase()) + .and().entriesListContains("tag", documentTagValue2.toLowerCase()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that folder tag is retrieved") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION}) + public void folderTagIsRetrieved() throws Exception + { + restClient.authenticateUser(adminUserModel); + returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat().entriesListIsNotEmpty() + .and().entriesListContains("tag", folderTagValue.toLowerCase()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify site Manager is able to get tags using properties parameter." + + "Check that properties filter is applied.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void siteManagerIsAbleToRetrieveTagsWithPropertiesParameter() throws Exception + { + returnedCollection = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withParams("maxItems=5000&properties=tag").withCoreAPI().getTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat().entriesListIsNotEmpty() + .and().entriesListContains("tag", documentTagValue.toLowerCase()) + .and().entriesListContains("tag", documentTagValue2.toLowerCase()) + .and().entriesListDoesNotContain("id"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "With admin get tags and use skipCount parameter. Check pagination") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void useSkipCountCheckPagination() throws Exception + { + returnedCollection = restClient.authenticateUser(adminUserModel).withCoreAPI().getTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + RestTagModel firstTag = returnedCollection.getEntries().get(0).onModel(); + RestTagModel secondTag = returnedCollection.getEntries().get(1).onModel(); + RestTagModelsCollection tagsWithSkipCount = restClient.withParams("skipCount=2").withCoreAPI().getTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + tagsWithSkipCount.assertThat().entriesListDoesNotContain("tag", firstTag.getTag()) + .assertThat().entriesListDoesNotContain("tag", secondTag.getTag()); + tagsWithSkipCount.assertThat().paginationField("skipCount").is("2"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "With admin get tags and use maxItems parameter. Check pagination") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void useMaxItemsParameterCheckPagination() throws Exception + { + returnedCollection = restClient.authenticateUser(adminUserModel).withCoreAPI().getTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + RestTagModel firstTag = returnedCollection.getEntries().get(0).onModel(); + RestTagModel secondTag = returnedCollection.getEntries().get(1).onModel(); + RestTagModelsCollection tagsWithMaxItems = restClient.withParams("maxItems=2").withCoreAPI().getTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + tagsWithMaxItems.assertThat().entriesListContains("tag", firstTag.getTag()) + .assertThat().entriesListContains("tag", secondTag.getTag()) + .assertThat().entriesListCountIs(2); + tagsWithMaxItems.assertThat().paginationField("maxItems").is("2"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "With manager get tags and use high skipCount parameter. Check pagination") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void useHighSkipCountCheckPagination() throws Exception + { + returnedCollection = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withParams("skipCount=20000").withCoreAPI().getTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat().entriesListIsEmpty() + .getPagination().assertThat().field("maxItems").is(100) + .and().field("hasMoreItems").is("false") + .and().field("count").is("0") + .and().field("skipCount").is(20000) + .and().field("totalItems").isNull(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "With Collaborator user get tags and use maxItems with value zero. Check default error model schema") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void useMaxItemsWithValueZeroCheckDefaultErrorModelSchema() throws Exception + { + returnedCollection = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withParams("maxItems=0").withCoreAPI().getTags(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) + .containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "With Manager user delete tag. Check it is not retrieved anymore.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void checkThatDeletedTagIsNotRetrievedAnymore() throws Exception + { + String removedTag = RandomData.getRandomName("tag3"); + + RestTagModel deletedTag = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(document).addTag(removedTag); + + restClient.withCoreAPI().usingResource(document).deleteTag(deletedTag); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); + returnedCollection.assertThat().entriesListIsNotEmpty() + .and().entriesListDoesNotContain("tag", removedTag.toLowerCase()); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/tags/TagsDataPrep.java b/e2e-test/src/test/java/org/alfresco/rest/tags/TagsDataPrep.java new file mode 100644 index 000000000..a499ab15b --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/tags/TagsDataPrep.java @@ -0,0 +1,70 @@ +package org.alfresco.rest.tags; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestTagModel; +import org.alfresco.rest.model.RestTagModelsCollection; +import org.alfresco.utility.Utility; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.data.RandomData; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.testng.annotations.Test; + +@Test(groups = {TestGroup.REQUIRE_SOLR}) +public class TagsDataPrep extends RestTest +{ + + protected static UserModel adminUserModel; + protected static UserModel userModel; + protected static ListUserWithRoles usersWithRoles; + protected static SiteModel siteModel; + protected static FileModel document; + protected static FolderModel folder; + protected static String documentTagValue, documentTagValue2, folderTagValue; + protected static RestTagModel documentTag, documentTag2, folderTag, returnedModel; + protected static RestTagModelsCollection returnedCollection; + private static boolean isInitialized = false; + + public void init() throws Exception + { + if(!isInitialized) + { + isInitialized = true; + initialization(); + } + } + + public void initialization() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + //Create public site + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + usersWithRoles = dataUser.usingAdmin().addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + document = dataContent.usingUser(adminUserModel).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + folder = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); + + documentTagValue = RandomData.getRandomName("tag"); + documentTagValue2 = RandomData.getRandomName("tag"); + folderTagValue = RandomData.getRandomName("tag"); + + restClient.authenticateUser(adminUserModel); + documentTag = restClient.withCoreAPI().usingResource(document).addTag(documentTagValue); + documentTag2 = restClient.withCoreAPI().usingResource(document).addTag(documentTagValue2); + folderTag = restClient.withCoreAPI().usingResource(folder).addTag(folderTagValue); + + // Allow indexing to complete. + Utility.sleep(1000, 60000, () -> + { + returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); + returnedCollection.assertThat().entriesListContains("tag", documentTagValue.toLowerCase()) + .and().entriesListContains("tag", documentTagValue2.toLowerCase()) + .and().entriesListContains("tag", folderTagValue.toLowerCase()); + }); + + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/tags/UpdateTagTests.java b/e2e-test/src/test/java/org/alfresco/rest/tags/UpdateTagTests.java new file mode 100644 index 000000000..21f506483 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/tags/UpdateTagTests.java @@ -0,0 +1,269 @@ +package org.alfresco.rest.tags; + +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestTagModel; +import org.alfresco.utility.Utility; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.RandomData; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.apache.commons.lang3.RandomStringUtils; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +/** + * Created by Claudia Agache on 10/4/2016. + */ +@Test(groups = {TestGroup.REQUIRE_SOLR}) +public class UpdateTagTests extends TagsDataPrep +{ + private RestTagModel oldTag; + private String randomTag = ""; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + init(); + } + + @BeforeMethod(alwaysRun=true) + public void addTagToDocument() throws Exception + { + restClient.authenticateUser(adminUserModel); + oldTag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("old")); + randomTag = RandomData.getRandomName("tag"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Admin user updates tags and status code is 200") + @Bug(id="REPO-1828") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) + public void adminIsAbleToUpdateTags() throws Exception + { + restClient.authenticateUser(adminUserModel); + returnedModel = restClient.withCoreAPI().usingTag(oldTag).update(randomTag); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedModel.assertThat().field("tag").is(randomTag); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify Manager user can't update tags with Rest API and status code is 403") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void managerIsNotAbleToUpdateTag() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + restClient.withCoreAPI().usingTag(oldTag).update(randomTag); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, + executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user can't update tags with Rest API and status code is 403") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void collaboratorIsNotAbleToUpdateTagCheckDefaultErrorModelSchema() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + restClient.withCoreAPI().usingTag(oldTag).update(randomTag); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, + executionType = ExecutionType.REGRESSION, description = "Verify Contributor user can't update tags with Rest API and status code is 403") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void contributorIsNotAbleToUpdateTag() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + restClient.withCoreAPI().usingTag(oldTag).update(randomTag); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, + executionType = ExecutionType.SANITY, description = "Verify Consumer user can't update tags with Rest API and status code is 403") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void consumerIsNotAbleToUpdateTag() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + restClient.withCoreAPI().usingTag(oldTag).update(randomTag); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, + executionType = ExecutionType.SANITY, description = "Verify user gets status code 401 if authentication call fails") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) +// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") + public void userIsNotAbleToUpdateTagIfAuthenticationFails() throws Exception + { + UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); + String managerPassword = siteManager.getPassword(); + siteManager.setPassword("wrongPassword"); + restClient.authenticateUser(siteManager); + restClient.withCoreAPI().usingTag(oldTag).update(randomTag); + siteManager.setPassword(managerPassword); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify admin is not able to update tag with invalid id") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void adminIsNotAbleToUpdateTagWithInvalidId() throws Exception + { + String invalidTagId = "invalid-id"; + RestTagModel tag = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); + tag.setId(invalidTagId); + restClient.withCoreAPI().usingTag(tag).update(RandomData.getRandomName("tag")); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, invalidTagId)); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify admin is not able to update tag with empty id") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void adminIsNotAbleToUpdateTagWithEmptyId() throws Exception + { + RestTagModel tag = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); + tag.setId(""); + restClient.withCoreAPI().usingTag(tag).update(RandomData.getRandomName("tag")); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) + .assertLastError().containsSummary(RestErrorModel.PUT_EMPTY_ARGUMENT); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify admin is not able to update tag with invalid body") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void adminIsNotAbleToUpdateTagWithEmptyBody() throws Exception + { + RestTagModel tag = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); + restClient.withCoreAPI().usingTag(tag).update(""); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(RestErrorModel.EMPTY_TAG); + } + + @Bug(id="ACE-5629") + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify admin is not able to update tag with invalid body containing '|' symbol") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void adminIsNotAbleToUpdateTagWithInvalidBodyScenario1() throws Exception + { + String invalidTagBody = "|.\"/<>*"; + RestTagModel tag = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); + Utility.waitToLoopTime(20); + restClient.withCoreAPI().usingTag(tag).update(invalidTagBody); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_TAG, invalidTagBody)); + } + + @Bug(id="ACE-5629") + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify admin is not able to update tag with invalid body without '|' symbol") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void adminIsNotAbleToUpdateTagWithInvalidBodyScenario2() throws Exception + { + String invalidTagBody = ".\"/<>*"; + RestTagModel tag = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); + Utility.waitToLoopTime(20); + restClient.withCoreAPI().usingTag(tag).update(invalidTagBody); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_TAG, invalidTagBody)); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify admin user can provide large string for new tag value.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + @Bug(id="REPO-1828") + public void adminIsAbleToUpdateTagsProvideLargeStringTag() throws Exception + { + String largeStringTag = RandomStringUtils.randomAlphanumeric(10000); + + restClient.authenticateUser(adminUserModel); + returnedModel = restClient.withCoreAPI().usingTag(oldTag).update(largeStringTag); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedModel.assertThat().field("tag").is(largeStringTag); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify admin user can provide short string for new tag value.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + @Bug(id="REPO-1828") + public void adminIsAbleToUpdateTagsProvideShortStringTag() throws Exception + { + String shortStringTag = RandomStringUtils.randomAlphanumeric(2); + + restClient.authenticateUser(adminUserModel); + returnedModel = restClient.withCoreAPI().usingTag(oldTag).update(shortStringTag); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedModel.assertThat().field("tag").is(shortStringTag); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify admin user can provide string with special chars for new tag value.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + @Bug(id="REPO-1828") + public void adminIsAbleToUpdateTagsProvideSpecialCharsStringTag() throws Exception + { + String specialCharsString = "!@#$%^&*()'\".,<>-_+=|\\"; + + restClient.authenticateUser(adminUserModel); + returnedModel = restClient.withCoreAPI().usingTag(oldTag).update(specialCharsString); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedModel.assertThat().field("tag").is(specialCharsString); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify Admin user can provide existing tag for new tag value.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + @Bug(id="REPO-1828") + public void adminIsAbleToUpdateTagsProvideExistingTag() throws Exception + { + String existingTag = "oldTag"; + RestTagModel oldExistingTag = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(document).addTag(existingTag); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(adminUserModel); + returnedModel = restClient.withCoreAPI().usingTag(oldExistingTag).update(existingTag); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedModel.assertThat().field("tag").is(existingTag); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify Admin user can delete a tag, add tag and update it.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + @Bug(id="REPO-1828") + public void adminDeleteTagAddTagUpdateTag() throws Exception + { + restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingResource(document).deleteTag(oldTag); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + String newTag = "addTag"; + RestTagModel newTagModel = restClient.withCoreAPI().usingResource(document).addTag(newTag); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedModel = restClient.withCoreAPI().usingTag(newTagModel).update(newTag); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedModel.assertThat().field("tag").is(newTag); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify Admin user can update a tag, delete tag and add it.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + @Bug(id="REPO-1828") + public void adminUpdateTagDeleteTagAddTag() throws Exception + { + String newTag = "addTag"; + + returnedModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingTag(oldTag).update(newTag); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedModel.assertThat().field("tag").is(newTag); + + restClient.withCoreAPI().usingResource(document).deleteTag(returnedModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingResource(document).addTag(newTag); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + } +} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/rest/tags/nodes/AddTagTests.java b/e2e-test/src/test/java/org/alfresco/rest/tags/nodes/AddTagTests.java new file mode 100644 index 000000000..c0606d3dc --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/tags/nodes/AddTagTests.java @@ -0,0 +1,337 @@ +package org.alfresco.rest.tags.nodes; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.model.RestCommentModel; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestTagModel; +import org.alfresco.rest.model.RestTagModelsCollection; +import org.alfresco.rest.tags.TagsDataPrep; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.RandomData; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.apache.commons.lang3.RandomStringUtils; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +/** + * Created by Claudia Agache on 10/3/2016. + */ +@Test(groups = {TestGroup.REQUIRE_SOLR}) +public class AddTagTests extends TagsDataPrep +{ + private String tagValue; + private RestTagModel returnedModel; + private RestCommentModel returnedModelComment; + private RestTagModelsCollection returnedModelTags; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + init(); + } + + @BeforeMethod(alwaysRun = true) + public void generateRandomTag() + { + tagValue = RandomData.getRandomName("tag"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify admin user adds tags with Rest API and status code is 201") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void adminIsAbleToAddTag() throws Exception + { + restClient.authenticateUser(adminUserModel); + returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedModel.assertThat().field("tag").is(tagValue) + .and().field("id").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, + description = "Verify Manager user adds tags with Rest API and status code is 201") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) + public void managerIsAbleToTagAFile() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedModel.assertThat().field("tag").is(tagValue) + .and().field("id").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify Collaborator user adds tags with Rest API and status code is 201") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void collaboratorIsAbleToTagAFile() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedModel.assertThat().field("tag").is(tagValue) + .and().field("id").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify Contributor user doesn't have permission to add tags with Rest API and status code is 403") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void contributorIsNotAbleToAddTagToAnotherContent() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + restClient.withCoreAPI().usingResource(document).addTag(tagValue); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify Contributor user adds tags to his content with Rest API and status code is 201") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void contributorIsAbleToAddTagToHisContent() throws Exception + { + userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); + restClient.authenticateUser(userModel); + FileModel contributorDoc = dataContent.usingSite(siteModel).usingUser(userModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + returnedModel = restClient.withCoreAPI().usingResource(contributorDoc).addTag(tagValue); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedModel.assertThat().field("id").isNotEmpty() + .and().field("tag").is(tagValue); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify Consumer user doesn't have permission to add tags with Rest API and status code is 403") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void consumerIsNotAbleToTagAFile() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + restClient.withCoreAPI().usingResource(document).addTag(tagValue); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, + description = "Verify user gets status code 401 if authentication call fails") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) +// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") + public void userIsNotAbleToAddTagIfAuthenticationFails() throws Exception + { + UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); + String managerPassword = siteManager.getPassword(); + siteManager.setPassword("wrongPassword"); + restClient.authenticateUser(siteManager); + restClient.withCoreAPI().usingResource(document).addTag("tagUnauthorized"); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + siteManager.setPassword(managerPassword); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that adding empty tag returns status code 400") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void emptyTagTest() throws Exception + { + restClient.authenticateUser(adminUserModel); + returnedModel = restClient.withCoreAPI().usingResource(document).addTag(""); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.NULL_ARGUMENT, "tag")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that adding tag with user that has no permissions returns status code 403") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void addTagWithUserThatDoesNotHavePermissions() throws Exception + { + restClient.authenticateUser(dataUser.createRandomTestUser()); + returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that adding tag to a node that does not exist returns status code 404") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void addTagToInexistentNode() throws Exception + { + String oldNodeRef = document.getNodeRef(); + String nodeRef = RandomStringUtils.randomAlphanumeric(10); + document.setNodeRef(nodeRef); + + restClient.authenticateUser(adminUserModel); + returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, nodeRef)); + document.setNodeRef(oldNodeRef); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, + description = "Verify that manager is able to tag a folder") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) + public void managerIsAbleToTagAFolder() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + returnedModel = restClient.withCoreAPI().usingResource(folderModel).addTag(tagValue); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedModel.assertThat().field("tag").is(tagValue).and().field("id").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that tagged file can be tagged again") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void addTagToATaggedFile() throws Exception + { + restClient.authenticateUser(adminUserModel); + + returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedModel.assertThat().field("tag").is(tagValue).and().field("id").isNotEmpty(); + + returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedModel.assertThat().field("tag").is(tagValue).and().field("id").isNotEmpty(); + + returnedModel = restClient.withCoreAPI().usingResource(document).addTag("random_tag_value"); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedModel.assertThat().field("tag").is("random_tag_value").and().field("id").isNotEmpty(); + + restClient.withCoreAPI().usingResource(document).getNodeTags().assertThat() + .entriesListContains("tag", tagValue.toLowerCase()) + .and().entriesListContains("tag", "random_tag_value"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that user cannot add invalid tag") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void addInvalidTag() throws Exception + { + restClient.authenticateUser(adminUserModel); + returnedModel = restClient.withCoreAPI().usingResource(document).addTag("-1~!|@#$%^&*()_="); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_TAG, "|")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that contributor is able to tag a folder created by self") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void contributorIsAbleToTagAFolderCreatedBySelf() throws Exception + { + FolderModel folderModel = dataContent.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingSite(siteModel).createFolder(); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + returnedModel = restClient.withCoreAPI().usingResource(folderModel).addTag(tagValue); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedModel.assertThat().field("tag").is(tagValue).and().field("id").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that collaborator is able to tag a folder") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void collaboratorIsAbleToTagAFolder() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + returnedModel = restClient.withCoreAPI().usingResource(folderModel).addTag(tagValue); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedModel.assertThat().field("tag").is(tagValue).and().field("id").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that consumer is not able to tag a folder. Check default error model schema.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void consumerIsNotAbleToTagAFolder() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + .withCoreAPI().usingResource(folderModel).addTag(tagValue); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that tagged folder can be tagged again") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void addTagToATaggedFolder() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + + returnedModel = restClient.withCoreAPI().usingResource(folderModel).addTag(tagValue); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedModel.assertThat().field("tag").is(tagValue).and().field("id").isNotEmpty(); + + returnedModel = restClient.withCoreAPI().usingResource(folderModel).addTag("random_tag_value"); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedModel.assertThat().field("tag").is("random_tag_value").and().field("id").isNotEmpty(); + + restClient.withCoreAPI().usingResource(folderModel).getNodeTags().assertThat() + .entriesListContains("tag", tagValue.toLowerCase()) + .and().entriesListContains("tag", "random_tag_value") + .and().entriesListCountIs(2); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Using collaborator provide more than one tag element") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void provideMoreThanOneTagElement() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); + String tagValue1 = RandomData.getRandomName("tag1"); + String tagValue2 = RandomData.getRandomName("tag2"); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + + returnedModelTags = restClient.withCoreAPI().usingResource(folderModel).addTags(tagValue, tagValue1, tagValue2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedModelTags.assertThat().entriesListContains("tag", tagValue) + .and().entriesListContains("tag", tagValue1) + .and().entriesListContains("tag", tagValue2) + .and().entriesListCountIs(3); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that manager cannot add tag with special characters.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void addTagWithSpecialCharacters() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); + String specialCharsTag = "!@#$%^&*()'\".,<>-_+=|\\"; + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(folderModel).addTag(specialCharsTag); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_TAG, "|")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that you cannot tag a comment and it returns status code 405") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void addTagToAComment() throws Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + String comment = "comment for a tag"; + + restClient.authenticateUser(adminUserModel); + returnedModelComment = restClient.withCoreAPI().usingResource(file).addComment(comment); + file.setNodeRef(returnedModelComment.getId()); + restClient.withCoreAPI().usingResource(file).addTag(tagValue); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.CANNOT_TAG); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that you cannot tag a tag and it returns status code 405") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void addTagToATag() throws Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(adminUserModel); + returnedModel = restClient.withCoreAPI().usingResource(file).addTag(tagValue); + file.setNodeRef(returnedModel.getId()); + restClient.withCoreAPI().usingResource(file).addTag(tagValue); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.CANNOT_TAG); + } +} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/rest/tags/nodes/AddTagsTests.java b/e2e-test/src/test/java/org/alfresco/rest/tags/nodes/AddTagsTests.java new file mode 100644 index 000000000..25063550e --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/tags/nodes/AddTagsTests.java @@ -0,0 +1,150 @@ +package org.alfresco.rest.tags.nodes; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestTagModel; +import org.alfresco.rest.model.RestTagModelsCollection; +import org.alfresco.rest.tags.TagsDataPrep; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.RandomData; +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.HttpStatus; +import org.testng.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +/** + * Created by Claudia Agache on 10/7/2016. + */ +@Test(groups = {TestGroup.REQUIRE_SOLR}) +public class AddTagsTests extends TagsDataPrep +{ + private FileModel contributorDoc; + private String tag1, tag2; + private RestTagModelsCollection returnedCollection; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + init(); + } + + @BeforeMethod(alwaysRun = true) + public void generateRandomTagsList() + { + tag1 = RandomData.getRandomName("tag"); + tag2 = RandomData.getRandomName("tag"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify admin user adds multiple tags with Rest API and status code is 201") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void adminIsAbleToAddTags() throws Exception + { + restClient.authenticateUser(adminUserModel); + returnedCollection = restClient.withCoreAPI().usingResource(document).addTags(tag1, tag2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedCollection.assertThat().entriesListContains("tag", tag1) + .and().entriesListContains("tag", tag2); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, + description = "Verify Manager user adds multiple tags with Rest API and status code is 201") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) + public void managerIsAbleToAddTags() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + returnedCollection = restClient.withCoreAPI().usingResource(document).addTags(tag1, tag2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedCollection.assertThat().entriesListContains("tag", tag1) + .and().entriesListContains("tag", tag2); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, + executionType = ExecutionType.SANITY, description = "Verify Collaborator user adds multiple tags with Rest API and status code is 201") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void collaboratorIsAbleToAddTags() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + returnedCollection = restClient.withCoreAPI().usingResource(document).addTags(tag1, tag2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedCollection.assertThat().entriesListContains("tag", tag1) + .and().entriesListContains("tag", tag2); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify Contributor user doesn't have permission to add multiple tags with Rest API and status code is 403") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void contributorIsNotAbleToAddTagsToAnotherContent() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + restClient.withCoreAPI().usingResource(document).addTags(tag1, tag2); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify Contributor user adds multiple tags to his content with Rest API and status code is 201") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void contributorIsAbleToAddTagsToHisContent() throws Exception + { + userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); + restClient.authenticateUser(userModel); + contributorDoc = dataContent.usingSite(siteModel).usingUser(userModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + returnedCollection = restClient.withCoreAPI().usingResource(contributorDoc).addTags(tag1, tag2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedCollection.assertThat().entriesListContains("tag", tag1) + .and().entriesListContains("tag", tag2); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify Consumer user doesn't have permission to add multiple tags with Rest API and status code is 403") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void consumerIsNotAbleToAddTags() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingResource(document).addTags(tag1, tag2); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.TAGS }, executionType = ExecutionType.SANITY, + description = "Verify user gets status code 401 if authentication call fails") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) +// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") + public void userIsNotAbleToAddTagsIfAuthenticationFails() throws Exception + { + UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); + String managerPassword = siteManager.getPassword(); + siteManager.setPassword("wrongPassword"); + restClient.authenticateUser(siteManager).withCoreAPI().usingResource(document).addTags(tag1, tag2); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + siteManager.setPassword(managerPassword); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify include count parameter") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void getTagsUsingCountParam() throws Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + String tagName = RandomData.getRandomName("tag"); + returnedModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addTag(RandomData.getRandomName("tag")); + RestTagModelsCollection tagsWithIncludeParamCount = restClient.withParams("include=count").withCoreAPI().getTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + for (RestTagModel tagModel : tagsWithIncludeParamCount.getEntries()) + { + if (tagModel != null && tagModel.getTag() != null) + { + if (tagModel.getTag().equals(tagName)) + { + Assert.assertEquals(tagModel.getCount().intValue(), 1); + } + } + } + + } +} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/rest/tags/nodes/DeleteTagTests.java b/e2e-test/src/test/java/org/alfresco/rest/tags/nodes/DeleteTagTests.java new file mode 100644 index 000000000..ec77b8fc7 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/tags/nodes/DeleteTagTests.java @@ -0,0 +1,287 @@ +package org.alfresco.rest.tags.nodes; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestTagModel; +import org.alfresco.rest.tags.TagsDataPrep; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.RandomData; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.apache.commons.lang3.RandomStringUtils; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Created by Claudia Agache on 10/4/2016. + */ +@Test(groups = {TestGroup.REQUIRE_SOLR}) +public class DeleteTagTests extends TagsDataPrep +{ + private RestTagModel tag; + private FileModel contributorDoc; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + init(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify Admin user deletes tags with Rest API and status code is 204") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void adminIsAbleToDeleteTags() throws Exception + { + restClient.authenticateUser(adminUserModel); + tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); + + restClient.withCoreAPI().usingResource(document).deleteTag(tag); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withCoreAPI().usingResource(document).getNodeTags() + .assertThat().entriesListDoesNotContain("tag", tag.getTag()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, + description = "Verify Manager user deletes tags created by admin user with Rest API and status code is 204") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) + public void managerIsAbleToDeleteTags() throws Exception + { + restClient.authenticateUser(adminUserModel); + tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + restClient.withCoreAPI().usingResource(document).deleteTag(tag); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify Collaborator user deletes tags created by admin user with Rest API and status code is 204") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void collaboratorIsAbleToDeleteTags() throws Exception + { + restClient.authenticateUser(adminUserModel); + tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + restClient.withCoreAPI().usingResource(document).deleteTag(tag); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify Contributor user can't delete tags created by admin user with Rest API and status code is 403") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void contributorIsNotAbleToDeleteTagsForAnotherUserContent() throws Exception + { + restClient.authenticateUser(adminUserModel); + tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + restClient.withCoreAPI().usingResource(document).deleteTag(tag); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify Contributor user deletes tags created by him with Rest API and status code is 204") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void contributorIsAbleToDeleteTagsForHisContent() throws Exception + { + userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); + restClient.authenticateUser(userModel); + contributorDoc = dataContent.usingSite(siteModel).usingUser(userModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);; + tag = restClient.withCoreAPI().usingResource(contributorDoc).addTag(RandomData.getRandomName("tag")); + + restClient.withCoreAPI().usingResource(document).deleteTag(tag); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify Consumer user can't delete tags created by admin user with Rest API and status code is 403") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void consumerIsNotAbleToDeleteTags() throws Exception + { + restClient.authenticateUser(adminUserModel); + tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + restClient.withCoreAPI().usingResource(document).deleteTag(tag); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, + description = "Verify user gets status code 401 if authentication call fails") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) +// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") + public void userIsNotAbleToDeleteTagIfAuthenticationFails() throws Exception + { + restClient.authenticateUser(adminUserModel); + tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); + + UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); + String managerPassword = siteManager.getPassword(); + siteManager.setPassword("wrongPassword"); + restClient.authenticateUser(siteManager); + restClient.withCoreAPI().usingResource(document).deleteTag(tag); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + siteManager.setPassword(managerPassword); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that if user has no permission to remove tag returned status code is 403. Check default error model schema") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void deleteTagWithUserWithoutPermissionCheckDefaultErrorModelSchema() throws Exception + { + restClient.authenticateUser(adminUserModel); + RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); + + restClient.authenticateUser(dataUser.createRandomTestUser()); + restClient.withCoreAPI().usingResource(document).deleteTag(tag); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that if node does not exist returned status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void deleteTagForANonexistentNode() throws Exception + { + restClient.authenticateUser(adminUserModel); + RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); + + FileModel document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + String nodeRef = RandomStringUtils.randomAlphanumeric(10); + document.setNodeRef(nodeRef); + restClient.withCoreAPI().usingResource(document).deleteTag(tag); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, nodeRef)); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that if tag does not exist returned status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void deleteTagThatDoesNotExist() throws Exception + { + restClient.authenticateUser(adminUserModel); + RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); + + tag.setId("abc"); + restClient.withCoreAPI().usingResource(document).deleteTag(tag); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "abc")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that if tag id is empty returned status code is 405") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void deleteTagWithEmptyId() throws Exception + { + restClient.authenticateUser(adminUserModel); + RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); + + tag.setId(""); + restClient.withCoreAPI().usingResource(document).deleteTag(tag); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.DELETE_EMPTY_ARGUMENT); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that folder tag can be deleted") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void deleteFolderTag() throws Exception + { + FolderModel folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder();; + restClient.authenticateUser(adminUserModel); + RestTagModel tag = restClient.withCoreAPI().usingResource(folderModel).addTag(RandomData.getRandomName("tag")); + restClient.withCoreAPI().usingResource(folderModel).deleteTag(tag); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withCoreAPI().usingResource(folderModel).getNodeTags() + .assertThat().entriesListDoesNotContain("tag", tag.getTag()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, + executionType = ExecutionType.REGRESSION, description = "Verify Manager user can't delete deleted tag.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + @Bug(id = "ACE-5455") + public void managerCannotDeleteDeletedTag() throws Exception + { + tag = restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(document).deleteTag(tag); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingResource(document).deleteTag(tag); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, + executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user can delete long tag.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void userCollaboratorCanDeleteLongTag() throws Exception + { + String longTag = RandomStringUtils.randomAlphanumeric(800); + + tag = restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingResource(document).addTag(longTag); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingResource(document).deleteTag(tag); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, + executionType = ExecutionType.REGRESSION, description = "Verify Manager user can delete short tag.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void managerCanDeleteShortTag() throws Exception + { + String shortTag = RandomStringUtils.randomAlphanumeric(10); + + tag = restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingResource(document).addTag(shortTag); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(document).deleteTag(tag); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, + executionType = ExecutionType.REGRESSION, description = "Verify Admin can delete tag then add it again.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void adminRemovesTagAndAddsItAgain() throws Exception + { + String tagValue = RandomStringUtils.randomAlphanumeric(10); + + tag = restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingResource(document).addTag(tagValue); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(document).deleteTag(tag); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + tag = restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingResource(document).addTag(tagValue); + RestTagModel returnedTag = restClient.withCoreAPI().getTag(tag); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedTag.assertThat().field("tag").is(tagValue.toLowerCase()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, + executionType = ExecutionType.REGRESSION, description = "Verify Manager user can delete tag added by another user.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void managerCanDeleteTagAddedByAnotherUser() throws Exception + { + tag = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingResource(document).addTag(RandomStringUtils.randomAlphanumeric(10)); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(document).deleteTag(tag); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } +} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/rest/tags/nodes/GetNodeTagsTests.java b/e2e-test/src/test/java/org/alfresco/rest/tags/nodes/GetNodeTagsTests.java new file mode 100644 index 000000000..f38e20d64 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/tags/nodes/GetNodeTagsTests.java @@ -0,0 +1,319 @@ +package org.alfresco.rest.tags.nodes; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.tags.TagsDataPrep; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.apache.commons.lang3.RandomStringUtils; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +@Test(groups = {TestGroup.REQUIRE_SOLR}) +public class GetNodeTagsTests extends TagsDataPrep +{ + private String tagValue; + private String tagValue2; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + init(); + tagValue = documentTagValue; + tagValue2 = documentTagValue2; + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, + executionType = ExecutionType.SANITY, description = "Verify site Manager is able to get node tags") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) + public void siteManagerIsAbleToRetrieveNodeTags() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + + returnedCollection = restClient.withCoreAPI().usingResource(document).getNodeTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat() + .entriesListContains("tag", tagValue.toLowerCase()) + .and().entriesListContains("tag", tagValue2.toLowerCase()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, + executionType = ExecutionType.REGRESSION, description = "Verify site Collaborator is able to get node tags") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void siteCollaboratorIsAbleToRetrieveNodeTags() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + + returnedCollection = restClient.withCoreAPI().usingResource(document).getNodeTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat() + .entriesListContains("tag", tagValue.toLowerCase()) + .and().entriesListContains("tag", tagValue2.toLowerCase()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, + executionType = ExecutionType.REGRESSION, description = "Verify site Contributor is able to get node tags") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void siteContributorIsAbleToRetrieveNodeTags() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + + returnedCollection = restClient.withCoreAPI().usingResource(document).getNodeTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat() + .entriesListContains("tag", tagValue.toLowerCase()) + .and().entriesListContains("tag", tagValue2.toLowerCase()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, + executionType = ExecutionType.REGRESSION, description = "Verify site Consumer is able to get node tags") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void siteConsumerIsAbleToRetrieveNodeTags() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + + returnedCollection = restClient.withCoreAPI().usingResource(document).getNodeTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat() + .entriesListContains("tag", tagValue.toLowerCase()) + .and().entriesListContains("tag", tagValue2.toLowerCase()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, + executionType = ExecutionType.REGRESSION, description = "Verify admin is able to get node tags") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void adminIsAbleToRetrieveNodeTags() throws Exception + { + restClient.authenticateUser(adminUserModel); + returnedCollection = restClient.withCoreAPI().usingResource(document).getNodeTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat() + .entriesListContains("tag", tagValue.toLowerCase()) + .and().entriesListContains("tag", tagValue2.toLowerCase()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, + executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to get node tags") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) +// @Bug(id = "MNT-16904", description = "fails only on environment with tenants") + public void unauthenticatedUserIsNotAbleToRetrieveNodeTags() throws Exception + { + restClient.authenticateUser(new UserModel("random user", "random password")); + restClient.withCoreAPI().usingResource(document).getNodeTags(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that using invalid value for skipCount parameter returns status code 400") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION}) + public void invalidSkipCountTest() throws Exception + { + restClient.withParams("skipCount=abc").withCoreAPI().usingResource(document).getNodeTags(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "abc")); + + restClient.withParams("skipCount=-1").withCoreAPI().usingResource(document).getNodeTags(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that using invalid value for maxItems parameter returns status code 400") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION}) + public void invalidMaxItemsTest() throws Exception + { + restClient.withParams("maxItems=abc").withCoreAPI().usingResource(document).getNodeTags(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "abc")); + + restClient.withParams("maxItems=-1").withCoreAPI().usingResource(document).getNodeTags(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that user without permissions returns status code 403") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION}) + public void userWithoutPermissionsTest() throws Exception + { + SiteModel moderatedSite = dataSite.usingUser(adminUserModel).createModeratedRandomSite(); + FileModel moderatedDocument = dataContent.usingSite(moderatedSite).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(dataUser.createRandomTestUser()).withCoreAPI().usingResource(moderatedDocument).getNodeTags(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that if node does not exist returns status code 403") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION}) + public void nonexistentNodeTest() throws Exception + { + FileModel badDocument = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + String nodeRef = RandomStringUtils.randomAlphanumeric(10); + badDocument.setNodeRef(nodeRef); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(badDocument).getNodeTags(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, nodeRef)); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that if node id is empty returns status code 403") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION}) + public void emptyNodeIdTest() throws Exception + { + FileModel badDocument = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + badDocument.setNodeRef(""); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(badDocument).getNodeTags(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify folder tags") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION}) + public void folderTagsTest() throws Exception + { + FolderModel folder = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); + + restClient.withCoreAPI().usingResource(folder).addTag(tagValue); + restClient.withCoreAPI().usingResource(folder).addTag(tagValue2); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(folder).getNodeTags() + .assertThat() + .entriesListContains("tag", tagValue.toLowerCase()) + .and().entriesListContains("tag", tagValue2.toLowerCase()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify site Manager is able to get node tags using properties parameter") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void siteManagerIsAbleToRetrieveNodeTagsWithPropertiesParameter() throws Exception + { + returnedCollection = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withParams("properties=tag").withCoreAPI().usingResource(document).getNodeTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat().entriesListContains("tag", tagValue.toLowerCase()) + .and().entriesListContains("tag", tagValue2.toLowerCase()) + .and().entriesListDoesNotContain("id"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that Collaborator user is not able to get node tags using site id instead of node id") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void collaboratorGetNodeTagsUseSiteIdInsteadOfNodeId() throws Exception + { + FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + + file.setNodeRef(siteModel.getId()); + returnedCollection = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(file).getNodeTags(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, file.getNodeRef())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "With admin get node tags and use skipCount parameter. Check pagination and maxItems") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void useSkipCountCheckPaginationAndMaxItems() throws Exception + { + returnedCollection = restClient.authenticateUser(adminUserModel) + .withParams("skipCount=1").withCoreAPI().usingResource(document).getNodeTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.getPagination().assertThat().field("maxItems").is(100) + .and().field("hasMoreItems").is("false") + .and().field("count").isGreaterThan(1); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "With admin get node tags and use maxItems parameter. Check pagination") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void useMaxItemsParameterCheckPagination() throws Exception + { + returnedCollection = restClient.authenticateUser(adminUserModel) + .withParams("maxItems=1").withCoreAPI().usingResource(document).getNodeTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.getPagination().assertThat().field("maxItems").is(1) + .and().field("hasMoreItems").is("true") + .and().field("count").is("1") + .and().field("skipCount").is("0"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Using manager user get only one tag.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void usingManagerGetOnlyOneTag() throws Exception + { + FileModel file = dataContent.usingAdmin().usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addTag(tagValue); + + returnedCollection = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(file).getNodeTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.getPagination().assertThat().field("maxItems").is(100) + .and().field("hasMoreItems").is("false") + .and().field("totalItems").is("1") + .and().field("count").is("1") + .and().field("skipCount").is("0"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Using admin get last 2 tags and skip first 2 tags") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void adminUserGetLast2TagsAndSkipFirst2Tags() throws Exception + { + String firstTag = "1st tag"; + String secondTag = "2nd tag"; + String thirdTag = "3rd tag"; + String fourthTag = "4th tag"; + FileModel file = dataContent.usingAdmin().usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addTag(firstTag); + restClient.withCoreAPI().usingResource(file).addTag(secondTag); + restClient.withCoreAPI().usingResource(file).addTag(thirdTag); + restClient.withCoreAPI().usingResource(file).addTag(fourthTag); + + returnedCollection = restClient.withParams("skipCount=2").withCoreAPI().usingResource(file).getNodeTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + returnedCollection.assertThat().entriesListContains("tag", thirdTag.toLowerCase()) + .and().entriesListContains("tag", fourthTag.toLowerCase()); + returnedCollection.getPagination().assertThat().field("maxItems").is(100) + .and().field("hasMoreItems").is("false") + .and().field("totalItems").is("4") + .and().field("count").is("2") + .and().field("skipCount").is("2"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "With admin get node tags and use maxItems=0.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void getTagsWithZeroMaxItems() throws Exception + { + returnedCollection = restClient.authenticateUser(adminUserModel) + .withParams("maxItems=0").withCoreAPI().usingResource(document).getNodeTags(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that using high skipCount parameter returns status code 200.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) + public void getTagsWithHighSkipCount() throws Exception + { + returnedCollection = restClient.authenticateUser(adminUserModel).withParams("skipCount=10000") + .withCoreAPI().usingResource(document).getNodeTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.getPagination().assertThat().field("maxItems").is(100) + .and().field("hasMoreItems").is("false") + .and().field("count").is("0") + .and().field("skipCount").is("10000"); + returnedCollection.assertThat().entriesListCountIs(0); + } +} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/rest/trashcan/GetDeletedNodesTests.java b/e2e-test/src/test/java/org/alfresco/rest/trashcan/GetDeletedNodesTests.java new file mode 100644 index 000000000..553b044d1 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/trashcan/GetDeletedNodesTests.java @@ -0,0 +1,245 @@ +/* + * Copyright (C) 2005-2017 Alfresco Software Limited. + * This file is part of Alfresco + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ + +package org.alfresco.rest.trashcan; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestNodeModel; +import org.alfresco.rest.model.RestNodeModelsCollection; +import org.alfresco.rest.model.RestRenditionInfoModel; +import org.alfresco.rest.model.RestRenditionInfoModelCollection; +import org.alfresco.utility.Utility; +import org.alfresco.utility.exception.DataPreparationException; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.Assert; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Tests for /api-explorer/#!/trashcan/listDeletedNodes + * /api-explorer/#!/trashcan/deleteDeletedNode + * /api-explorer/#!/trashcan/getDeletedNode + * /api-explorer/#!/trashcan/restoreDeletedNode + * + * @author jcule + * + */ +public class GetDeletedNodesTests extends RestTest +{ + private UserModel adminUserModel; + private SiteModel deleteNodesSiteModel; + private FolderModel deleteNodesFolder1, deleteNodesFolder2, deleteNodesFolder3, deleteNodesFolder4, deleteNodesFolder5, getDeleteNodesFolder6; + private FileModel file, file1, file2, file3, file4; + + private RestNodeModelsCollection deletedNodes, deletedNodesMaxItem; + private RestNodeModel node; + + private RestRenditionInfoModelCollection nodeRenditionInfoCollection; + private RestRenditionInfoModel nodeRenditionInfo; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws DataPreparationException + { + adminUserModel = dataUser.getAdminUser(); + restClient.authenticateUser(adminUserModel); + deleteNodesSiteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + } + + @AfterClass(alwaysRun = true) + public void cleanup() throws Exception + { + dataSite.usingAdmin().deleteSite(deleteNodesSiteModel); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.REGRESSION }) + public void testDeletedNodesBiggerThanMaxCount() throws Exception + { + // get the number of item in the trashcan + deletedNodes = restClient.withCoreAPI().usingTrashcan().findDeletedNodes(); + int count = deletedNodes.getPagination().getCount(); + int totalItems = deletedNodes.getPagination().getTotalItems(); + + // create folders + deleteNodesFolder1 = dataContent.usingUser(adminUserModel).usingSite(deleteNodesSiteModel).createFolder(); + deleteNodesFolder2 = dataContent.usingUser(adminUserModel).usingSite(deleteNodesSiteModel).createFolder(); + deleteNodesFolder3 = dataContent.usingUser(adminUserModel).usingSite(deleteNodesSiteModel).createFolder(); + + // delete folders + dataContent.usingUser(adminUserModel).usingResource(deleteNodesFolder1).deleteContent(); + dataContent.usingUser(adminUserModel).usingResource(deleteNodesFolder2).deleteContent(); + dataContent.usingUser(adminUserModel).usingResource(deleteNodesFolder3).deleteContent(); + + int maxItems = count + 1; + deletedNodesMaxItem = restClient.withCoreAPI().usingTrashcan().usingParams(String.format("maxItems=%s", maxItems)).findDeletedNodes(); + + String countMaxItem = Integer.toString(maxItems); + String totalItemsMaxItem = Integer.toString(totalItems + 3); + String hasMoreItemsMaxItem = Boolean.toString(deletedNodesMaxItem.getPagination().isHasMoreItems()); + String skipCount = Integer.toString(deletedNodesMaxItem.getPagination().getSkipCount()); + + restClient.assertStatusCodeIs(HttpStatus.OK); + deletedNodesMaxItem.getPagination().assertThat().field("totalItems").is(totalItemsMaxItem).and().field("count").is(countMaxItem); + deletedNodesMaxItem.getPagination().assertThat().field("hasMoreItems").is(hasMoreItemsMaxItem).and().field("skipCount").is(skipCount); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TRASHCAN }, executionType = ExecutionType.SANITY, description = "Sanity tests for GET /deleted-nodes and GET /deleted-nodes/{nodeId}") + @Test(groups = { TestGroup.REST_API, TestGroup.TRASHCAN, TestGroup.SANITY }) + public void testGetDeletedNodesFromTrashcan() throws Exception + { + // Create a folder and a file + deleteNodesFolder4 = dataContent.usingUser(adminUserModel).usingSite(deleteNodesSiteModel).createFolder(); + file = dataContent.usingUser(adminUserModel).usingSite(deleteNodesSiteModel).createContent(DocumentType.TEXT_PLAIN); + + // Delete file and folder + dataContent.usingUser(adminUserModel).usingResource(deleteNodesFolder4).deleteContent(); + dataContent.usingUser(adminUserModel).usingResource(file).deleteContent(); + + // GET /deleted-nodes: deleted file and folder are in the trashcan list + deletedNodes = restClient.withCoreAPI().usingTrashcan().findDeletedNodes(); + restClient.assertStatusCodeIs(HttpStatus.OK); + deletedNodes.getEntryByIndex(0).assertThat().field("name").is(file.getName()).and() + .field("id").is(file.getNodeRefWithoutVersion()); + deletedNodes.getEntryByIndex(1).assertThat().field("name").is(deleteNodesFolder4.getName()).and() + .field("id").is(deleteNodesFolder4.getNodeRefWithoutVersion()); + + // GET /deleted-nodes/{nodeId}: check a single deleted object + node = restClient.withCoreAPI().usingTrashcan().findDeletedNode(deleteNodesFolder4); + restClient.assertStatusCodeIs(HttpStatus.OK); + node.assertThat().field("name").is(deleteNodesFolder4.getName()).and() + .field("id").is(deleteNodesFolder4.getNodeRefWithoutVersion()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TRASHCAN }, executionType = ExecutionType.SANITY, description = "Sanity tests for DELETE /deleted-nodes/{nodeId} and POST /deleted-nodes/{nodeId}/restore") + @Test(groups = { TestGroup.REST_API, TestGroup.TRASHCAN, TestGroup.SANITY }) + public void testDeleteAndRestoreNodeFromTrashcan() throws Exception + { + // Create a folder and a file + deleteNodesFolder5 = dataContent.usingUser(adminUserModel).usingSite(deleteNodesSiteModel).createFolder(); + String docLibNodeRef = dataContent.usingUser(adminUserModel).usingSite(deleteNodesSiteModel).getNodeRef(); + file1 = dataContent.usingUser(adminUserModel).usingSite(deleteNodesSiteModel).createContent(DocumentType.TEXT_PLAIN); + + // Delete file and folder + dataContent.usingUser(adminUserModel).usingResource(deleteNodesFolder5).deleteContent(); + dataContent.usingUser(adminUserModel).usingResource(file1).deleteContent(); + + // DELETE /deleted-nodes/{nodeId}: delete an object from trashcan + restClient.withCoreAPI().usingTrashcan().deleteNodeFromTrashcan(file1); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingTrashcan().findDeletedNode(file1); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + + // POST /deleted-nodes/{nodeId}/restore: restore to repository a deleted object + node = restClient.withCoreAPI().usingTrashcan().restoreNodeFromTrashcan(deleteNodesFolder5); + restClient.assertStatusCodeIs(HttpStatus.OK); + node.assertThat().field("id").is(deleteNodesFolder5.getNodeRefWithoutVersion()).and() + .field("parentId").is(docLibNodeRef); + + // Checks that the node was removed from trashcan + restClient.withCoreAPI().usingTrashcan().findDeletedNode(deleteNodesFolder5); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TRASHCAN }, executionType = ExecutionType.SANITY, description = "Sanity tests for GET /deleted-nodes/{nodeId}/content") + @Test(groups = { TestGroup.REST_API, TestGroup.TRASHCAN, TestGroup.SANITY }) + public void testGetDeletedNodesContent() throws Exception + { + // Create file2 based on existing resource + FileModel newFile = FileModel.getFileModelBasedOnTestDataFile("sampleContent.txt"); + newFile.setName("sampleContent.txt"); + file2 = dataContent.usingUser(adminUserModel).usingSite(deleteNodesSiteModel).createContent(newFile); + + // Delete file2 to be moved in trashcan + dataContent.usingUser(adminUserModel).usingResource(file2).deleteContent(); + + // Make GET /deleted-nodes/{nodeId}/content and check file content + restClient.withCoreAPI().usingTrashcan().getDeletedNodeContent(file2); + restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.assertHeaderValueContains("Content-Disposition", file2.getName()); + restClient.onResponse().getResponse().body().asString().contains("Sample text."); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TRASHCAN, TestGroup.REQUIRE_SOLR }, executionType = ExecutionType.SANITY, + description = "Sanity tests for GET /deleted-nodes/{nodeId}/renditions, GET /deleted-nodes/{nodeId}/renditions/{renditionId}, GET /deleted-nodes/{nodeId}/renditions/{renditionId}/content") + @Test(groups = { TestGroup.REST_API, TestGroup.TRASHCAN, TestGroup.SANITY }) + public void testGetDeletedNodesRenditions() throws Exception + { + // Create file3 based on existing resource + file3 = dataContent.usingUser(adminUserModel).usingSite(deleteNodesSiteModel).createContent(DocumentType.TEXT_PLAIN); + + // Create rendition and delete file3 to be moved in trashcan + restClient.withCoreAPI().usingNode(file3).createNodeRendition("pdf"); + restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); + dataContent.usingUser(adminUserModel).usingResource(file3).deleteContent(); + + // GET /deleted-nodes/{nodeId}/renditions + Utility.sleep(1000, 30000, () -> + { + nodeRenditionInfoCollection = restClient.authenticateUser(adminUserModel).withCoreAPI().usingTrashcan().getDeletedNodeRenditions(file3); + restClient.assertStatusCodeIs(HttpStatus.OK); + + // Check if renditions are retrieved, created or not. Entries are ordered + nodeRenditionInfoCollection.assertThat().entriesListContains("id", "doclib"); + nodeRenditionInfoCollection.getEntryByIndex(5).assertThat().field("id").is("pdf").and() + .field("status").is("CREATED"); + }); + + // GET /deleted-nodes/{nodeId}/renditions/{id} + nodeRenditionInfo = restClient.authenticateUser(adminUserModel).withCoreAPI().usingTrashcan().getDeletedNodeRendition(file3, "pdf"); + restClient.assertStatusCodeIs(HttpStatus.OK); + nodeRenditionInfo.assertThat().field("id").is("pdf").and() + .field("status").is("CREATED"); + + // GET /deleted-nodes/{nodeId}/renditions/{id}/content + restClient.authenticateUser(adminUserModel).withCoreAPI().usingTrashcan().getDeletedNodeRenditionContent(file3, "pdf"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.assertHeaderValueContains("Content-Type","application/pdf;charset=UTF-8"); + Assert.assertTrue(restClient.onResponse().getResponse().body().asInputStream().available() > 0); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.TRASHCAN, TestGroup.REQUIRE_SOLR}, executionType = ExecutionType.SANITY, + description = "Sanity test to verify Range request header on GET /deleted-nodes/{nodeId}/renditions/{renditionId}/content endpoint") + @Test(groups = {TestGroup.REST_API, TestGroup.TRASHCAN, TestGroup.SANITY}) + public void testGetDeletedNodesRenditionsandVerifyRangeRequestheader() throws Exception + { + // Create file4 based on existing resource + file4 = dataContent.usingUser(adminUserModel).usingSite(deleteNodesSiteModel).createContent(DocumentType.TEXT_PLAIN); + + // Create rendition and delete file4 to be moved in trashcan + restClient.withCoreAPI().usingNode(file4).createNodeRendition("pdf"); + restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); + dataContent.usingUser(adminUserModel).usingResource(file4).deleteContent(); + + // GET /deleted-nodes/{nodeId}/renditions/{id}/content and verify range request header + Utility.sleep(1000, 30000, () -> + { + restClient.configureRequestSpec().addHeader("content-range", "bytes=1-10"); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingTrashcan().getDeletedNodeRenditionContent(file4, "pdf"); + restClient.assertStatusCodeIs(HttpStatus.PARTIAL_CONTENT); + restClient.assertHeaderValueContains("Content-Type", "application/pdf;charset=UTF-8"); + restClient.assertHeaderValueContains("content-range", "bytes 1-10"); + restClient.assertHeaderValueContains("content-length", String.valueOf(10)); + }); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/WorkflowNetworkDeploymentsTests.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/WorkflowNetworkDeploymentsTests.java new file mode 100644 index 000000000..8a255fd0b --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/WorkflowNetworkDeploymentsTests.java @@ -0,0 +1,124 @@ +package org.alfresco.rest.workflow; + +import java.util.List; + +import org.alfresco.rest.NetworkDataPrep; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestDeploymentModel; +import org.alfresco.rest.model.RestDeploymentModelsCollection; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class WorkflowNetworkDeploymentsTests extends NetworkDataPrep +{ + private RestDeploymentModel expectedDeployment, actualDeployment; + private RestDeploymentModelsCollection deployments; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + init(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, + executionType = ExecutionType.REGRESSION, + description = "Verify if network admin user gets a network deployment using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION, TestGroup.NETWORKS}) + public void adminGetsNetworkDeploymentWithSuccess() throws Exception + { + + expectedDeployment = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getDeployments().getOneRandomEntry().onModel(); + actualDeployment = restClient.withWorkflowAPI().usingDeployment(expectedDeployment).getDeployment(); + restClient.assertStatusCodeIs(HttpStatus.OK); + actualDeployment.assertThat().field("deployedAt").isNotEmpty() + .and().field("name").is(expectedDeployment.getName()) + .and().field("id").is(expectedDeployment.getId()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, + executionType = ExecutionType.REGRESSION, + description = "Verify non admin user is forbidden to get a network deployment using REST API (403)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void nonAdminUserIsForbiddenToGetNetworkDeployment() throws Exception + { + expectedDeployment = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getDeployments().getOneRandomEntry().onModel(); + + restClient.authenticateUser(tenantUser).withWorkflowAPI().usingDeployment(expectedDeployment).getDeployment(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Bug(id = "MNT-16996") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, + executionType = ExecutionType.REGRESSION, + description = "Verify get deployments returns an empty list after deleting all network deployments.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION, TestGroup.NETWORKS}) + public void getNetworkDeploymentsAfterDeletingAllNetworkDeployments() throws Exception + { + + List networkDeployments = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getDeployments().getEntries(); + for (RestDeploymentModel networkDeployment: networkDeployments) + { + restClient.withWorkflowAPI().usingDeployment(networkDeployment.onModel()).deleteDeployment(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + deployments = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getDeployments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + deployments.assertThat().entriesListIsEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, + executionType = ExecutionType.REGRESSION, + description = "Verify non admin user is not able to get network deployments using REST API and status code is Forbidden") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION, TestGroup.NETWORKS}) + public void nonAdminUserCanNotGetNetworkDeployments() throws Exception + { + restClient.authenticateUser(tenantUser).withWorkflowAPI().getDeployments(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, + executionType = ExecutionType.REGRESSION, + description = "Verify that network admin user is not able to get a deployment from other network using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION, TestGroup.NETWORKS}) + public void adminDoesNotGetDeploymentFromOtherNetwork() throws Exception + { + expectedDeployment = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getDeployments().getOneRandomEntry().onModel(); + actualDeployment = restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().usingDeployment(expectedDeployment).getDeployment(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, expectedDeployment.getId())) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, + executionType = ExecutionType.REGRESSION, + description = "Verify that network admin user is not able to get a deployment from other network using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION, TestGroup.NETWORKS}) + public void adminDoesNotGetDeploymentsFromOtherNetwork() throws Exception + { + RestDeploymentModel deployment = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getDeployments().getOneRandomEntry().onModel(); + deployments = restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().getDeployments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + deployments.assertThat().entriesListDoesNotContain("id", deployment.getId()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.SANITY, + description = "Verify Tenant Admin user gets network deployments using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.SANITY, TestGroup.NETWORKS}) + public void getNetworkDeploymentsWithAdmin() throws JsonToModelConversionException, Exception + { + deployments = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getDeployments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + deployments.assertThat().entriesListIsNotEmpty(); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/WorkflowNetworkProcessDefinitionsTests.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/WorkflowNetworkProcessDefinitionsTests.java new file mode 100644 index 000000000..038681aef --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/WorkflowNetworkProcessDefinitionsTests.java @@ -0,0 +1,221 @@ +package org.alfresco.rest.workflow; + +import org.alfresco.dataprep.CMISUtil.Priority; +import org.alfresco.rest.NetworkDataPrep; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestProcessDefinitionModel; +import org.alfresco.rest.model.RestProcessDefinitionModelsCollection; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class WorkflowNetworkProcessDefinitionsTests extends NetworkDataPrep +{ + private RestProcessDefinitionModel randomProcessDefinition, returnedProcessDefinition; + private RestProcessModel addedProcess; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + init(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, + executionType = ExecutionType.REGRESSION, + description = "Verify network admin is able to get a process definition using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void networkAdminGetProcessDefinition() throws Exception + { + randomProcessDefinition = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry().onModel(); + returnedProcessDefinition = restClient.withWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinition(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedProcessDefinition.assertThat().field("name").is(randomProcessDefinition.getName()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, + executionType = ExecutionType.REGRESSION, + description = "Verify network user is able to get a process definition using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void networkUserGetProcessDefinition() throws Exception + { + randomProcessDefinition = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() + .getAllProcessDefinitions().getOneRandomEntry().onModel(); + returnedProcessDefinition = restClient.authenticateUser(tenantUser).withWorkflowAPI() + .usingProcessDefinitions(randomProcessDefinition).getProcessDefinition(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedProcessDefinition.assertThat().field("name").is(randomProcessDefinition.getName()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, + description = "Verify get process definitions using any network user for network enabled deployments with REST API status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION, TestGroup.NETWORKS}) + public void networkUserGetsProcessDefinitions() throws Exception + { + restClient.authenticateUser(tenantUser) + .withWorkflowAPI() + .getAllProcessDefinitions() + .assertThat().entriesListIsNotEmpty(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, + executionType = ExecutionType.REGRESSION, + description = "Verify Network user is not able to get a process definition from another network") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.NETWORKS, TestGroup.REGRESSION }) + public void getProcessDefinitionFromAnotherNetwork() throws Exception + { + randomProcessDefinition = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() + .getAllProcessDefinitions().getOneRandomEntry().onModel(); + restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI() + .usingProcessDefinitions(randomProcessDefinition).getProcessDefinition(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, randomProcessDefinition.getId())) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, + executionType = ExecutionType.REGRESSION, + description = "Verify Tenant User doesn't get process definitions for another network deployment using REST API") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void networkUserIsNotAbleToGetProcessDefinitionsForAnotherNetwork() throws Exception + { + RestProcessDefinitionModel randomProcessDefinitionTenant1 = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() + .getAllProcessDefinitions().getOneRandomEntry().onModel(); + RestProcessDefinitionModelsCollection processDefinitionsTenant2 = restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI() + .getAllProcessDefinitions(); + restClient.assertStatusCodeIs(HttpStatus.OK); + processDefinitionsTenant2.assertThat().entriesListDoesNotContain("id", randomProcessDefinitionTenant1.getId()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, + executionType = ExecutionType.REGRESSION, + description = "Verify network admin is able to get a process definition image using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION, TestGroup.NETWORKS}) + @Bug(id = "MNT-17243") + public void networkAdminGetProcessDefinitionImage() throws Exception + { + randomProcessDefinition = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry().onModel(); + restClient.withWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionImage() + .assertResponseContainsImage(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESS_DEFINITION }, + executionType = ExecutionType.REGRESSION, + description = "Verify network user is able to get a process definition image using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION, TestGroup.NETWORKS}) + @Bug(id = "MNT-17243") + public void networkUserGetProcessDefinitionImage() throws Exception + { + randomProcessDefinition = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() + .getAllProcessDefinitions().getOneRandomEntry().onModel(); + restClient.authenticateUser(tenantUser).withWorkflowAPI() + .usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionImage() + .assertResponseContainsImage(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, + executionType = ExecutionType.SANITY, description = "Verify Tenant Admin user gets process definitions for network deployments using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY, TestGroup.NETWORKS}) + public void networkAdminGetsProcessDefinitions() throws Exception + { + restClient.authenticateUser(adminTenantUser); + restClient.withWorkflowAPI().getAllProcessDefinitions().assertThat().entriesListIsNotEmpty(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, + executionType = ExecutionType.REGRESSION, + description = "Verify Tenant User doesn't get process definition image for another network deployment using REST API") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void networkUserIsNotAbleToGetProcessDefinitionImageForAnotherNetwork() throws Exception + { + RestProcessDefinitionModel randomProcessDefinition = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() + .getAllProcessDefinitions().getOneRandomEntry().onModel(); + restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI() + .usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionImage(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, randomProcessDefinition.getId())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, + executionType = ExecutionType.REGRESSION, + description = "Verify Tenant User gets a model of the start form type definition for network deployments using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void networkUserGetsStartFormModel() throws Exception + { + randomProcessDefinition = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() + .getAllProcessDefinitions().getOneRandomEntry().onModel(); + restClient.authenticateUser(tenantUser).withWorkflowAPI() + .usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionStartFormModel() + .assertThat().entriesListIsNotEmpty(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, + executionType = ExecutionType.REGRESSION, + description = "Verify Tenant User doesn't get a model of the start form type definition for another network deployment using REST API") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void networkUserIsNotAbleToGetStartFormModelForAnotherNetwork() throws Exception + { + RestProcessDefinitionModel randomProcessDefinition = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() + .getAllProcessDefinitions().getOneRandomEntry().onModel(); + restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI() + .usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionStartFormModel(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, randomProcessDefinition.getId())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, + executionType = ExecutionType.SANITY, + description = "Verify Tenant Admin gets a model of the start form type definition for network deployments using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY, TestGroup.NETWORKS }) + public void networkAdminGetsStartFormModel() throws Exception + { + restClient.authenticateUser(adminTenantUser); + randomProcessDefinition = restClient.withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry().onModel(); + restClient.withWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionStartFormModel().assertThat().entriesListIsNotEmpty(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify network user can start new process with processDefinitionKey from same network using REST API and status code is 201") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS}) + public void networkUserCanStartNewProcessWithProcessDefinitionFromSameNetwork() throws JsonToModelConversionException, Exception + { + RestProcessDefinitionModel firstProcessDefTenant1 = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getAllProcessDefinitions().getEntries().get(0).onModel(); + + String processDefinitionKey = firstProcessDefTenant1.getKey(); + addedProcess = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess(processDefinitionKey, secondTenantUser, false, Priority.Normal); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + addedProcess.assertThat().field("processDefinitionId").is(firstProcessDefTenant1.getId()) + .and().field("startUserId").is(tenantUser.getEmailAddress().substring(0,2)+tenantUser.getEmailAddress().substring(2).toLowerCase()) + .and().field("processDefinitionKey").is(processDefinitionKey); + } + + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify network user cannot start new process with processDefinitionKey from another network using REST API and status code is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS}) + public void networkUserCannotStartNewProcessWithProcessDefinitionFromAnotherNetwork() throws JsonToModelConversionException, Exception + { + RestProcessDefinitionModel firstProcessDefTenant1 = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getAllProcessDefinitions().getEntries().get(0).onModel(); + + String processDefinitionKey = firstProcessDefTenant1.getId().substring(0,firstProcessDefTenant1.getId().indexOf(":")); + addedProcess = restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().addProcess(processDefinitionKey, differentNetworkTenantUser, false, Priority.Normal); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(String.format(RestErrorModel.NO_WORKFLOW_DEFINITION_FOUND, processDefinitionKey)) + .containsSummary(String.format(RestErrorModel.NO_WORKFLOW_DEFINITION_FOUND, processDefinitionKey)) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/WorkflowNetworkProcessesTests.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/WorkflowNetworkProcessesTests.java new file mode 100644 index 000000000..0e9b6696f --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/WorkflowNetworkProcessesTests.java @@ -0,0 +1,540 @@ +package org.alfresco.rest.workflow; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.dataprep.CMISUtil.Priority; +import org.alfresco.rest.NetworkDataPrep; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestItemModel; +import org.alfresco.rest.model.RestItemModelsCollection; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestProcessModelsCollection; +import org.alfresco.rest.model.RestProcessVariableCollection; +import org.alfresco.rest.model.RestProcessVariableModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class WorkflowNetworkProcessesTests extends NetworkDataPrep +{ + private RestProcessModel processModel; + private RestProcessModelsCollection processes; + private RestItemModel processItem; + private RestItemModelsCollection processItems; + private RestProcessVariableModel variableModel, processVariable; + private RestProcessVariableCollection variables; + protected SiteModel siteModel; + protected FileModel document, document2; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + init(); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + document2 = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW, + TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Verify network user is able to start new process using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY, TestGroup.NETWORKS }) + public void networkUserStartsNewProcess() throws JsonToModelConversionException, Exception + { + processModel = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + processModel.assertThat().field("id").is(processModel.getId()) + .and().field("startUserId").is(processModel.getStartUserId()); + + processes = restClient.withWorkflowAPI().getProcesses(); + restClient.assertStatusCodeIs(HttpStatus.OK); + processes.assertThat().entriesListContains("id", processModel.getId()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES}, executionType = ExecutionType.REGRESSION, + description = "Verify that non network user cannot get process from a network") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) + @Bug(id = "REPO-2092") + public void nonNetworkUserCannotAccessNetworkProcess() throws Exception + { + RestProcessModel networkProcess1 = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().addProcess("activitiReview", tenantUser, false, CMISUtil.Priority.High); + + restClient.authenticateUser(adminUserModel).withWorkflowAPI().usingProcess(networkProcess1).getProcess(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError().containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify that tenant user can get process from the same network") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void tenantUserCanGetProcessFromTheSameNetwork() throws Exception + { + RestProcessModel networkProcess1 = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().addProcess("activitiReview", tenantUser, false, CMISUtil.Priority.High); + + restClient.authenticateUser(tenantUser).withWorkflowAPI().usingProcess(networkProcess1).getProcess(); + restClient.assertStatusCodeIs(HttpStatus.OK); + networkProcess1.assertThat().field("id").is(networkProcess1.getId()) + .and().field("startUserId").is(networkProcess1.getStartUserId());; + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES}, executionType = ExecutionType.REGRESSION, + description = "Verify that tenant user cannot get process from another network") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) + @Bug(id = "REPO-2092") + public void tenantUserCannotGetProcessFromAnotherNetwork() throws Exception + { + RestProcessModel networkProcess1 = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().addProcess("activitiReview", tenantUser, false, CMISUtil.Priority.High); + + restClient.authenticateUser(differentNetworkTenantUser).withWorkflowAPI().usingProcess(networkProcess1).getProcess(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError().containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin user can get process started by a network user") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void adminUserCanGetProcessFromANetwork() throws Exception + { + RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiReview", adminTenantUser, false, CMISUtil.Priority.High); + + restClient.authenticateUser(dataUser.getAdminUser()).withWorkflowAPI().usingProcess(networkProcess1).getProcess(); + restClient.assertStatusCodeIs(HttpStatus.OK); + networkProcess1.assertThat().field("processDefinitionId").contains(String.format("@%s%s", tenantUser.getDomain().toLowerCase(), "@activitiReview:1")) + .and().field("startUserId").is(tenantUser.getEmailAddress().substring(0, 2)+tenantUser.getEmailAddress().substring(2).toLowerCase()) + .and().field("startActivityId").is("start") + .and().field("startedAt").isNotEmpty() + .and().field("id").is(networkProcess1.getId()) + .and().field("completed").is(false) + .and().field("processDefinitionKey").is("activitiReview"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Add multiple process items using by admin in other network.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void addMultipleProcessItemsByAdminInOtherNetwork() throws Exception + { + processModel = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUser, false, Priority.Normal); + restClient.authenticateUser(secondAdminTenantUser); + + processItems = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItems(document, document2); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError() + .containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Add multiple process items using by the admin in same network.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void addMultipleProcessItemsByAdminSameNetwork() throws Exception + { + processModel = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); + + siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); + document = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + document2 = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + processItems = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().usingProcess(processModel).addProcessItems(document, document2); + + restClient.assertStatusCodeIs(HttpStatus.CREATED); + processItems.getEntries().get(0).onModel().assertThat() + .field("createdAt").isNotEmpty().and() + .field("size").is("19").and() + .field("createdBy").is(adminTenantUser.getUsername().toLowerCase()).and() + .field("modifiedAt").isNotEmpty().and() + .field("name").is(document.getName()).and() + .field("modifiedBy").is(adminTenantUser.getUsername().toLowerCase()).and() + .field("id").isNotEmpty().and() + .field("mimeType").is(document.getFileType().mimeType); + processItems.getEntries().get(1).onModel().assertThat() + .field("createdAt").isNotEmpty().and() + .field("size").is("19").and() + .field("createdBy").is(adminTenantUser.getUsername().toLowerCase()).and() + .field("modifiedAt").isNotEmpty().and() + .field("name").is(document2.getName()).and() + .field("modifiedBy").is(adminTenantUser.getUsername().toLowerCase()).and() + .field("id").isNotEmpty().and() + .field("mimeType").is(document2.getFileType().mimeType); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Add process item using by admin in other network.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void addProcessItemByAdminInOtherNetwork() throws Exception + { + processModel = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUser, false, Priority.Normal); + restClient.authenticateUser(secondAdminTenantUser); + processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Add process item using by the admin in same network.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void addProcessItemByAdminSameNetwork() throws Exception + { + processModel = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); + + siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); + document = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + processItem = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().usingProcess(processModel).addProcessItem(document); + + restClient.assertStatusCodeIs(HttpStatus.CREATED); + processItem.assertThat().field("createdAt").isNotEmpty().and().field("size").is("19").and().field("createdBy").is(adminTenantUser.getUsername().toLowerCase()).and() + .field("modifiedAt").isNotEmpty().and().field("name").is(document.getName()).and().field("modifiedBy").is(adminTenantUser.getUsername().toLowerCase()).and() + .field("id").isNotEmpty().and().field("mimeType").is(document.getFileType().mimeType); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Delete process item using by admin in other network.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void deleteProcessItemByAdminInOtherNetwork() throws Exception + { + processModel = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, CMISUtil.Priority.Normal); + processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().usingProcess(processModel) + .deleteProcessItem(processItem); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError() + .containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .containsErrorKey(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT) + .stackTraceIs(RestErrorModel.STACKTRACE); + + //restore document + document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Delete process item using by the admin in same network.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void deleteProcessItemByAdminSameNetwork() throws Exception + { + processModel = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, CMISUtil.Priority.Normal); + + processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(adminTenantUser).withWorkflowAPI().usingProcess(processModel) + .deleteProcessItem(processItem); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() + .assertThat().entriesListDoesNotContain("name", processItem.getName()); + + //restore document + document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Get process items using admin from different network") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void getProcessItemsReturnsOnlyItemsInsideNetwork() throws Exception + { + processModel = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, CMISUtil.Priority.Normal); + + siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); + document = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestProcessModel processModel2 = restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondAdminTenantUser, false, CMISUtil.Priority.Normal); + + SiteModel siteModel2 = dataSite.usingUser(secondAdminTenantUser).createPublicRandomSite(); + document2 = dataContent.usingUser(secondAdminTenantUser).usingSite(siteModel2).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().usingProcess(processModel2).addProcessItem(document2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + processItems = restClient.withWorkflowAPI().usingProcess(processModel2).getProcessItems(); + restClient.assertStatusCodeIs(HttpStatus.OK); + processItems.assertThat().entriesListDoesNotContain("name", document.getName()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Get process items using admin from different network") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void getProcessItemsUsingAdminUserFromDifferentNetwork() throws Exception + { + processModel = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, CMISUtil.Priority.Normal); + + siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); + document = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().usingProcess(processModel).getProcessItems(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Add process variable using by admin in other network.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void addProcessVariableByAdminInOtherNetwork() throws Exception + { + processModel = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); + + restClient.authenticateUser(secondAdminTenantUser); + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError() + .containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Add process variable using admin user from same network") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY, TestGroup.NETWORKS }) + public void addProcessVariableByAdmin() throws Exception + { + restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + + processVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + processVariable.assertThat().field("name").is(variableModel.getName()) + .and().field("type").is(variableModel.getType()) + .and().field("value").is(variableModel.getValue()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin from different network is not able to delete network process variables") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void deleteProcessVariablesWithAdminFromDifferentNetwork() throws Exception + { + RestProcessModel processModel = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() + .addProcess("activitiAdhoc", tenantUser, false, Priority.Normal); + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser).withWorkflowAPI() + .getProcesses().getProcessModelByProcessDefId(processModel.getId()); + restClient.withWorkflowAPI().usingProcess(networkProcess1).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(adminUserModel).withWorkflowAPI().usingProcess(networkProcess1) + .deleteProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + restClient.assertLastError().containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .containsErrorKey(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT) + .stackTraceIs(RestErrorModel.STACKTRACE); + + restClient.authenticateUser(tenantUser).withWorkflowAPI().usingProcess(networkProcess1).getProcessVariables().assertThat() + .entriesListContains("name", variableModel.getName()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin from the same network is able to delete network process variables") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void deleteProcessVariablesWithAdminFromSameNetwork() throws Exception + { + RestProcessModel processModel = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() + .addProcess("activitiAdhoc", tenantUser, false, Priority.Normal); + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser).withWorkflowAPI() + .getProcesses().getProcessModelByProcessDefId(processModel.getId()); + restClient.withWorkflowAPI().usingProcess(networkProcess1).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(adminTenantUser).withWorkflowAPI().usingProcess(networkProcess1) + .deleteProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingProcess(networkProcess1).getProcessVariables() + .assertThat() + .entriesListDoesNotContain("name", variableModel.getName()); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin from different network is not able to retrieve network process variables") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void getProcessVariablesWithAdminFromDifferentNetwork() throws Exception + { + RestProcessModel networkProcess1 = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() + .addProcess("activitiReview", tenantUser, false, CMISUtil.Priority.High); + + variables = restClient.authenticateUser(adminUserModel).withWorkflowAPI().usingProcess(networkProcess1).getProcessVariables(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT); + } + + @TestRail(section = {TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin from the same network is able to retrieve network process variables") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void getProcessVariablesWithAdminFromSameNetwork() throws Exception + { + RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser).withWorkflowAPI() + .addProcess("activitiReview", tenantUser, false, CMISUtil.Priority.High); + + variables = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().usingProcess(networkProcess1).getProcessVariables(); + restClient.assertStatusCodeIs(HttpStatus.OK); + variables.assertThat().entriesListIsNotEmpty(); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify admin gets all processes from same network") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void getProcessFromSameNetworkUsingAdmin() throws Exception + { + RestProcessModel process = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); + + RestProcessModelsCollection tenantProcesses = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getProcesses(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + tenantProcesses.assertThat().entriesListContains("id", process.getId()); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Get process items using admin from same network") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY, TestGroup.NETWORKS }) + public void getProcessItemsUsingAdminUserFromSameNetwork() throws Exception + { + processModel = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); + + siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); + document = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); + + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + processItems = restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems(); + restClient.assertStatusCodeIs(HttpStatus.OK); + processItems.assertThat().entriesListContains("name", document.getName()); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Add multiple process variables using admin user from same network") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY, TestGroup.NETWORKS }) + public void addMultipleProcessVariablesByAdminSameNetwork() throws Exception + { + restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processVariable = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + + variables = restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariables(variableModel, processVariable); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + variables.assertThat().entriesListContains("name", variableModel.getName()) + .assertThat().entriesListContains("name", processVariable.getName()); + + variables.getEntries().get(0).onModel().assertThat() + .field("name").is(variableModel.getName()).and() + .field("value").is(variableModel.getValue()).and() + .field("type").is(variableModel.getType()); + variables.getEntries().get(1).onModel().assertThat() + .field("name").is(processVariable.getName()).and() + .field("value").is(processVariable.getValue()).and() + .field("type").is(processVariable.getType()); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Add process variables using admin user from same network") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY, TestGroup.NETWORKS }) + public void addProcessVariableByAdminSameNetwork() throws Exception + { + restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + + processVariable = restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + processVariable.assertThat().field("name").is(variableModel.getName()) + .and().field("type").is(variableModel.getType()) + .and().field("value").is(variableModel.getValue()); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify any user cannot get processes from same network") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void getProcessFromSameNetworkUsingAnyUser() throws Exception + { + restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); + + restClient.authenticateUser(tenantUser).withWorkflowAPI().getProcesses(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify getProcessTasks using admin from different network with REST API and status code is FORBIDDEN (403)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void getProcessTasksWithAdminFromDifferentNetwork() throws Exception + { + siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); + dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + RestProcessModel processModel = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, CMISUtil.Priority.Normal); + + restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI() + .usingProcess(processModel).getProcessTasks().assertThat().entriesListIsEmpty(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify getProcessTasks using admin from same network with REST API and status code is OK") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void getProcessTasksWithAdminFromSameNetwork() throws Exception + { + siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); + dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + + RestProcessModel processModel = restClient.authenticateUser(secondTenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, CMISUtil.Priority.Normal); + + restClient.authenticateUser(adminTenantUser).withWorkflowAPI() + .usingProcess(processModel).getProcessTasks().assertThat().entriesListIsNotEmpty(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW,TestGroup.PROCESSES}, executionType = ExecutionType.REGRESSION, + description = "Add multiple process variables using by Admin in other network.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void addMultipleProcessVariablesByAdminInOtherNetwork() throws Exception + { + + siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); + dataWorkflow.usingUser(tenantUser).usingSite(siteModel).usingResource(document) + .createNewTaskAndAssignTo(secondTenantUser); + + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processVariable = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); + restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().usingProcess(processModel) + .addProcessVariables(variableModel, processVariable); + + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError() + .containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .containsErrorKey(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES}, executionType = ExecutionType.REGRESSION, + description = "Add process variables using by Admin in other network.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void addProcessVariablesByAdminInOtherNetwork() throws Exception + { + siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); + dataWorkflow.usingUser(tenantUser).usingSite(siteModel).usingResource(document) + .createNewTaskAndAssignTo(secondTenantUser); + + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); + processVariable = restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().usingProcess(processModel) + .addProcessVariable(variableModel); + + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError() + .containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .containsErrorKey(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/WorkflowNetworkTasksTests.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/WorkflowNetworkTasksTests.java new file mode 100644 index 000000000..f1f4e53a4 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/WorkflowNetworkTasksTests.java @@ -0,0 +1,578 @@ +package org.alfresco.rest.workflow; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.dataprep.CMISUtil.Priority; +import org.alfresco.rest.NetworkDataPrep; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestFormModelsCollection; +import org.alfresco.rest.model.RestItemModel; +import org.alfresco.rest.model.RestItemModelsCollection; +import org.alfresco.rest.model.RestProcessDefinitionModel; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestTaskModel; +import org.alfresco.rest.model.RestTaskModelsCollection; +import org.alfresco.rest.model.RestVariableModel; +import org.alfresco.rest.model.RestVariableModelsCollection; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TaskModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class WorkflowNetworkTasksTests extends NetworkDataPrep +{ + private TaskModel taskModel; + private RestFormModelsCollection returnedCollection; + private RestTaskModel restTaskModel; + private RestTaskModelsCollection taskModels; + private RestVariableModel variableModel, variableModel1; + private RestVariableModelsCollection restVariableCollection; + private RestProcessModel restProcessModel; + private RestItemModelsCollection itemModels; + private RestItemModel restTaskItem; + protected SiteModel siteModel; + protected FileModel document, document2; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + init(); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + document2 = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, + executionType = ExecutionType.REGRESSION, description = "Verify network admin user gets all task form models inside his network with Rest API and response is successful (200)") + public void networkAdminGetsTaskFormModels() throws Exception + { + RestProcessModel networkProcess = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() + .addProcess("activitiReview", tenantUser, false, CMISUtil.Priority.High); + RestTaskModel networkTask = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() + .usingProcess(networkProcess).getProcessTasks().getOneRandomEntry().onModel(); + + restClient.authenticateUser(adminUserModel).withWorkflowAPI().usingTask(networkTask).getTaskFormModel(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + + returnedCollection = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().usingTask(networkTask).getTaskFormModel(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat().entriesListIsNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Add multiple task item using by admin in other network.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void addMultipleTaskItemByAdminInOtherNetwork() throws Exception + { + + SiteModel siteModel1 = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); + document = dataContent.usingUser(adminTenantUser).usingSite(siteModel1).createContent(DocumentType.XML); + document2 = dataContent.usingSite(siteModel1).createContent(DocumentType.XML); + + RestProcessModel addedProcess = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); + RestTaskModel addedTask = restClient.withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess); + restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().usingTask(addedTask).addTaskItems(document, document2); + + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .stackTraceIs(RestErrorModel.STACKTRACE);; + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Add task item using by admin in other network.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void addTaskItemByAdminInOtherNetwork() throws Exception + { + document = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(DocumentType.XML); + RestProcessModel addedProcess = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); + RestTaskModel addedTask = restClient.withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess); + restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().usingTask(addedTask).addTaskItem(document); + + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Bug(id = "REPO-1980") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify tenant admin can update only task from its network and response is 200") + public void adminTenantCanUpdateOnlyTaskInItsNetwork() throws Exception + { + FileModel fileModel1 = dataContent.usingUser(tenantUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + RestProcessDefinitionModel def1 = restClient.authenticateUser(tenantUser).withWorkflowAPI().getAllProcessDefinitions().getEntries().get(0).onModel(); + TaskModel taskModel1 = dataWorkflow.usingUser(tenantUser).usingSite(siteModel).usingResource(fileModel1) + .createTaskWithProcessDefAndAssignTo(def1.getId(), secondTenantUser); + + SiteModel siteModel2 = dataSite.usingUser(differentNetworkTenantUser).createPublicRandomSite(); + FileModel fileModel2 = dataContent.usingUser(differentNetworkTenantUser).usingSite(siteModel2).createContent(DocumentType.TEXT_PLAIN); + RestProcessDefinitionModel def2 = restClient.authenticateUser(differentNetworkTenantUser).withWorkflowAPI().getAllProcessDefinitions().getEntries().get(0).onModel(); + TaskModel taskModel2 = dataWorkflow.usingUser(differentNetworkTenantUser).usingSite(siteModel2).usingResource(fileModel2) + .createTaskWithProcessDefAndAssignTo(def2.getId(), secondAdminTenantUser); + + restTaskModel = restClient.authenticateUser(secondAdminTenantUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel2).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel2.getId()) + .and().field("state").is("completed"); + + restTaskModel = restClient.authenticateUser(secondAdminTenantUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel1).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin from the same network is able to add multiple task variables") + public void addMultipleTaskVariablesByTenantAdmin() throws Exception + { + RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser).withWorkflowAPI() + .addProcess("activitiReview", tenantUser, false, CMISUtil.Priority.High); + RestTaskModel task = restClient.authenticateUser(adminTenantUser) + .withWorkflowAPI().usingProcess(networkProcess1).getProcessTasks().getOneRandomEntry(); + restClient.authenticateUser(adminTenantUser); + + variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + variableModel1 = RestVariableModel.getRandomTaskVariableModel("global", "d:text"); + + restVariableCollection = restClient.withWorkflowAPI().usingTask(task.onModel()) + .addTaskVariables(variableModel, variableModel1); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restVariableCollection.getEntries().get(0).onModel().assertThat() + .field("scope").is(variableModel.getScope()) + .and().field("name").is(variableModel.getName()) + .and().field("value").is(variableModel.getValue()) + .and().field("type").is(variableModel.getType()); + + restVariableCollection.getEntries().get(1).onModel().assertThat() + .field("scope").is(variableModel1.getScope()) + .and().field("name").is(variableModel1.getName()) + .and().field("value").is(variableModel1.getValue()) + .and().field("type").is(variableModel1.getType()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin from the same network is able to add and remove task variables") + public void addAndRemoveTaskVariablesByTenantAdmin() throws Exception + { + RestProcessModel networkProcess1 = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() + .addProcess("activitiReview", adminTenantUser, false, CMISUtil.Priority.High); + RestTaskModel task = restClient.authenticateUser(adminTenantUser) + .withWorkflowAPI().usingProcess(networkProcess1).getProcessTasks().getOneRandomEntry(); + restClient.authenticateUser(adminTenantUser); + RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + variableModel = restClient.withWorkflowAPI() + .usingTask(task.onModel()) + .addTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + variableModel.assertThat() + .field("scope").is(variableModel.getScope()) + .and().field("name").is(variableModel.getName()) + .and().field("value").is(variableModel.getValue()) + .and().field("type").is(variableModel.getType()); + + restClient.withWorkflowAPI().usingTask(task.onModel()).deleteTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingTask(task.onModel()).getTaskVariables() + .assertThat().entriesListDoesNotContain("name", variableModel.getName()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin from the other network is not able to remove task variables") + public void addTaskVariablesByTenantAdminOtherNetwork() throws Exception + { + RestProcessModel networkProcess1 = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() + .addProcess("activitiReview", adminTenantUser, false, CMISUtil.Priority.High); + RestTaskModel task = restClient.authenticateUser(adminTenantUser) + .withWorkflowAPI().usingProcess(networkProcess1).getProcessTasks().getOneRandomEntry(); + restClient.authenticateUser(adminTenantUser); + RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + restClient.withWorkflowAPI() + .usingTask(task.onModel()) + .addTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().usingTask(task.onModel()).deleteTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin from another network is not able to add task variables") + public void addTaskVariablesByTenantFromAnotherNetwork() throws Exception + { + RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser).withWorkflowAPI() + .addProcess("activitiReview", tenantUser, false, CMISUtil.Priority.High); + RestTaskModel task = restClient.authenticateUser(adminTenantUser) + .withWorkflowAPI().usingProcess(networkProcess1).getProcessTasks().getOneRandomEntry(); + RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + variableModel = restClient.authenticateUser(secondTenantUser).withWorkflowAPI() + .usingTask(task.onModel()) + .addTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin from another network is not able to add multiple task variables") + public void addMultipleTaskVariablesByTenantFromAnotherNetwork() throws Exception + { + RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser).withWorkflowAPI() + .addProcess("activitiReview", tenantUser, false, CMISUtil.Priority.High); + RestTaskModel task = restClient.authenticateUser(adminTenantUser) + .withWorkflowAPI().usingProcess(networkProcess1).getProcessTasks().getOneRandomEntry(); + restClient.authenticateUser(adminTenantUser); + + variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + variableModel1 = RestVariableModel.getRandomTaskVariableModel("global", "d:text"); + restVariableCollection = restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI() + .usingTask(task.onModel()) + .addTaskVariables(variableModel,variableModel1); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin from another network is not able to update task variables") + public void updateTaskVariablesByTenantFromAnotherNetwork() throws Exception + { + RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser).withWorkflowAPI() + .addProcess("activitiReview", tenantUser, false, CMISUtil.Priority.High); + RestTaskModel task = restClient.authenticateUser(adminTenantUser) + .withWorkflowAPI().usingProcess(networkProcess1).getProcessTasks().getOneRandomEntry(); + restClient.authenticateUser(adminTenantUser); + RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + variableModel = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().usingTask(task.onModel()) + .addTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().usingTask(task.onModel()) + .updateTaskVariable(variableModel); + + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, + executionType = ExecutionType.REGRESSION, description = "Check that for admin network gets tasks only from its network.") + public void adminTenantGetsTasksOnlyFromItsNetwork() throws Exception + { + RestProcessModel processOnTenant1 = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Low); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestProcessModel processOnTenant2 = restClient.authenticateUser(differentNetworkTenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondAdminTenantUser, false, Priority.Normal); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestTaskModelsCollection tenantTasks1 = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + tenantTasks1.assertThat().entriesListIsNotEmpty() + .and().entriesListIsNotEmpty() + .and().entriesListContains("assignee", String.format("sTenant@%s", secondTenantUser.getDomain().toLowerCase())) + .and().entriesListContains("processId", processOnTenant1.getId()) + .and().entriesListDoesNotContain("assignee", String.format("admin@%s", secondAdminTenantUser.getDomain().toLowerCase())) + .and().entriesListDoesNotContain("processId", processOnTenant2.getId()); + + RestTaskModelsCollection tenantTasks2 = restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + tenantTasks2.assertThat().entriesListIsNotEmpty() + .and().entriesListIsNotEmpty() + .and().entriesListContains("assignee", String.format("admin@%s", secondAdminTenantUser.getDomain().toLowerCase())) + .and().entriesListContains("processId", processOnTenant2.getId()) + .and().entriesListDoesNotContain("assignee", String.format("sTenant@%s", secondTenantUser.getDomain().toLowerCase())) + .and().entriesListDoesNotContain("processId", processOnTenant1.getId()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check that for network enabled only that network tasks are returned.") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) + public void networkEnabledTasksReturned() throws Exception + { + restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); + + taskModels = restClient.authenticateUser(secondTenantUser).withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + taskModels.assertThat().entriesListIsNotEmpty().and().entriesListContains("assignee", + String.format("sTenant@%s", secondTenantUser.getDomain().toLowerCase())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify gets task items call with admin from different network") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void getTaskItemsByAdminFromAnotherNetwork() throws Exception + { + + siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); + document = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(DocumentType.XML); + restProcessModel = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); + restTaskModel = restClient.withWorkflowAPI().getTasks().getTaskModelByProcess(restProcessModel); + restClient.withWorkflowAPI().usingTask(restTaskModel).addTaskItem(document); + + restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().usingTask(restTaskModel).getTaskItems(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify gets task items call returns only task items inside network") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void getTaskItemsReturnsOnlyItemsFromThatNetwork() throws Exception + { + SiteModel siteModel1 = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); + FileModel fileModel1 = dataContent.usingUser(adminTenantUser).usingSite(siteModel1).createContent(DocumentType.XML); + + RestProcessModel addedProcess1 = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUser, false, Priority.Normal); + RestTaskModel addedTask1 = restClient.withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess1); + RestItemModel taskItem1 = restClient.withWorkflowAPI().usingTask(addedTask1).addTaskItem(fileModel1); + + SiteModel siteModel2 = dataSite.usingUser(secondAdminTenantUser).createPublicRandomSite(); + FileModel fileModel2 = dataContent.usingUser(secondAdminTenantUser).usingSite(siteModel2).createContent(DocumentType.XML); + + RestProcessModel addedProcess2 = restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().addProcess("activitiAdhoc", differentNetworkTenantUser, false, Priority.Normal); + RestTaskModel addedTask2 = restClient.withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess2); + RestItemModel taskItem2 = restClient.withWorkflowAPI().usingTask(addedTask2).addTaskItem(fileModel2); + + itemModels = restClient.withWorkflowAPI().usingTask(addedTask2).getTaskItems(); + restClient.assertStatusCodeIs(HttpStatus.OK); + itemModels.assertThat() + .entriesListIsNotEmpty().and() + .entriesListContains("id", taskItem2.getId()).and() + .entriesListContains("name", fileModel2.getName()).and() + .entriesListDoesNotContain("id", taskItem1.getId()).and() + .entriesListDoesNotContain("name", fileModel1.getName()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, + executionType = ExecutionType.REGRESSION, description = "Check that for admin network gets task only from its network.") + public void adminTenantGetsTaskOnlyFromItsNetwork() throws Exception + { + RestProcessModel processOnTenant1 = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Low); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestProcessModel processOnTenant2 = restClient.authenticateUser(differentNetworkTenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondAdminTenantUser, false, Priority.Normal); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestTaskModelsCollection tenantTasks2 = restClient.authenticateUser(differentNetworkTenantUser).withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + tenantTasks2.assertThat().entriesListIsNotEmpty() + .and().entriesListCountIs(1) + .and().entriesListContains("assignee", String.format("admin@%s", secondAdminTenantUser.getDomain().toLowerCase())) + .and().entriesListContains("processId", processOnTenant2.getId()) + .and().entriesListDoesNotContain("assignee", String.format("admin@%s", secondTenantUser.getDomain().toLowerCase())) + .and().entriesListDoesNotContain("processId", processOnTenant1.getId()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify that in a network only tasks inside network are returned.") + @Test(groups = {TestGroup.NETWORKS,TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void tasksInsideNetworkReturned() throws Exception + { + + RestProcessModel addedProcess = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, + Priority.Normal); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + taskModel = restClient.withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess); + restTaskModel = restClient.authenticateUser(secondTenantUser).withWorkflowAPI().usingTask(taskModel).getTask(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("assignee").is(String.format("sTenant@%s", secondTenantUser.getDomain().toLowerCase())).and() + .field("processId").is(addedProcess.getId()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Verify that user that started the process gets task items") + @Test(groups = { TestGroup.NETWORKS,TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY}) + public void getTaskItemsByAdminInSameNetwork() throws Exception + { + + siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); + document = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(DocumentType.XML); + RestProcessModel addedProcess = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); + RestTaskModel addedTask = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess); + restTaskItem = restClient.withWorkflowAPI().usingTask(addedTask).addTaskItem(document); + + itemModels = restClient.withWorkflowAPI().usingTask(addedTask).getTaskItems(); + restClient.assertStatusCodeIs(HttpStatus.OK); + itemModels.assertThat() + .entriesListIsNotEmpty().and() + .entriesListContains("id", restTaskItem.getId()).and() + .entriesListContains("name", document.getName()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin from the same network is able to retrieve network task variables") + public void getTaskVariablesByTenantAdmin() throws Exception + { + RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser).withWorkflowAPI() + .addProcess("activitiReview", tenantUser, false, CMISUtil.Priority.High); + RestTaskModel task = restClient.authenticateUser(adminTenantUser) + .withWorkflowAPI().usingProcess(networkProcess1).getProcessTasks().getOneRandomEntry(); + + restVariableCollection = restClient.withWorkflowAPI().usingTask(task.onModel()).getTaskVariables(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restVariableCollection.assertThat().entriesListIsNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin from another network is not able to retrieve network task variables") + public void getTaskVariablesByTenantFromAnotherNetwork() throws Exception + { + RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser).withWorkflowAPI() + .addProcess("activitiReview", tenantUser, false, CMISUtil.Priority.High); + RestTaskModel task = restClient.authenticateUser(adminTenantUser) + .withWorkflowAPI().usingProcess(networkProcess1).getProcessTasks().getOneRandomEntry(); + + restVariableCollection = restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().usingTask(task.onModel()).getTaskVariables(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } + + @Test(groups = { TestGroup.NETWORKS,TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Add task item using admin user from same network") + public void addMultipleTaskItemByAdminSameNetwork() throws Exception + { + + siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); + document = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(DocumentType.XML); + document2 = dataContent.usingUser(adminTenantUser).usingUser(adminTenantUser).usingSite(siteModel).createContent(DocumentType.XML); + RestProcessModel addedProcess = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); + RestTaskModel addedTask = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess); + + itemModels = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().usingTask(addedTask) + .addTaskItems(document2,document); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + itemModels.getEntries().get(0).onModel() + .assertThat().field("createdAt").is(itemModels.getEntries().get(0).onModel().getCreatedAt()) + .assertThat().field("size").is(itemModels.getEntries().get(0).onModel().getSize()) + .assertThat().field("createdBy").is(itemModels.getEntries().get(0).onModel().getCreatedBy()) + .assertThat().field("modifiedAt").is(itemModels.getEntries().get(0).onModel().getModifiedAt()) + .assertThat().field("name").is(itemModels.getEntries().get(0).onModel().getName()) + .assertThat().field("modifiedBy").is(itemModels.getEntries().get(0).onModel().getModifiedBy()) + .assertThat().field("id").is(itemModels.getEntries().get(0).onModel().getId()) + .assertThat().field("mimeType").is(itemModels.getEntries().get(0).onModel().getMimeType()); + + itemModels.getEntries().get(1).onModel() + .assertThat().field("createdAt").is(itemModels.getEntries().get(1).onModel().getCreatedAt()) + .assertThat().field("size").is(itemModels.getEntries().get(1).onModel().getSize()) + .assertThat().field("createdBy").is(itemModels.getEntries().get(1).onModel().getCreatedBy()) + .assertThat().field("modifiedAt").is(itemModels.getEntries().get(1).onModel().getModifiedAt()) + .assertThat().field("name").is(itemModels.getEntries().get(1).onModel().getName()) + .assertThat().field("modifiedBy").is(itemModels.getEntries().get(1).onModel().getModifiedBy()) + .assertThat().field("id").is(itemModels.getEntries().get(1).onModel().getId()); + } + + @Test(groups = { TestGroup.NETWORKS,TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Add task item using admin user from same network") + public void addTaskItemByAdminSameNetwork() throws Exception + { + siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); + document = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(DocumentType.XML); + RestProcessModel addedProcess = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); + RestTaskModel addedTask = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess); + + restTaskItem = restClient.withWorkflowAPI().usingTask(addedTask).addTaskItem(document); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restTaskItem.assertThat().field("createdAt").is(restTaskItem.getCreatedAt()) + .and().field("size").is(restTaskItem.getSize()) + .and().field("createdBy").is(restTaskItem.getCreatedBy()) + .and().field("modifiedAt").is(restTaskItem.getModifiedAt()) + .and().field("name").is(restTaskItem.getName()) + .and().field("modifiedBy").is(restTaskItem.getModifiedBy()) + .and().field("id").is(restTaskItem.getId()) + .and().field("mimeType").is(restTaskItem.getMimeType()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS}) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Update existing task variable by admin in the same network") + public void updateTaskVariableByAdminInSameNetwork() throws Exception + { + RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser).withWorkflowAPI() + .addProcess("activitiReview", tenantUser, false, CMISUtil.Priority.High); + RestTaskModel task = restClient.authenticateUser(adminTenantUser) + .withWorkflowAPI().usingProcess(networkProcess1).getProcessTasks().getOneRandomEntry(); + + variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + variableModel1 = restClient.withWorkflowAPI().usingTask(task.onModel()) + .updateTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + variableModel1.assertThat().field("scope").is(variableModel1.getScope()) + .and().field("name").is(variableModel1.getName()) + .and().field("type").is(variableModel1.getType()) + .and().field("value").is(variableModel1.getValue()); + + variableModel.setValue("updatedValue"); + variableModel1 = restClient.withWorkflowAPI().usingTask(task.onModel()).updateTaskVariable(variableModel).and().field("value").is("updatedValue"); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify tenant user that created the task can update task only in its network and response is 200, for other networks is 403") + public void ownerTenantCanUpdatedTaskOnlyInItsNetwork() throws Exception + { + + + SiteModel siteModel1 = dataSite.usingUser(tenantUser).createPublicRandomSite(); + FileModel fileModel1 = dataContent.usingUser(tenantUser).usingSite(siteModel1).createContent(DocumentType.TEXT_PLAIN); + RestProcessDefinitionModel def1 = restClient.authenticateUser(tenantUser).withWorkflowAPI().getAllProcessDefinitions().getEntries().get(0).onModel(); + TaskModel taskModel1 = dataWorkflow.usingUser(tenantUser).usingSite(siteModel1).usingResource(fileModel1) + .createTaskWithProcessDefAndAssignTo(def1.getId(), secondTenantUser); + + SiteModel siteModel2 = dataSite.usingUser(differentNetworkTenantUser).createPublicRandomSite(); + FileModel fileModel2 = dataContent.usingUser(differentNetworkTenantUser).usingSite(siteModel2).createContent(DocumentType.TEXT_PLAIN); + RestProcessDefinitionModel def2 = restClient.authenticateUser(differentNetworkTenantUser).withWorkflowAPI().getAllProcessDefinitions().getEntries().get(0).onModel(); + TaskModel taskModel2 = dataWorkflow.usingUser(differentNetworkTenantUser).usingSite(siteModel2).usingResource(fileModel2) + .createTaskWithProcessDefAndAssignTo(def2.getId(), secondAdminTenantUser); + + restTaskModel = restClient.authenticateUser(differentNetworkTenantUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel2).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel2.getId()) + .and().field("state").is("completed"); + + restTaskModel = restClient.authenticateUser(differentNetworkTenantUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel1).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentTests.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentTests.java new file mode 100644 index 000000000..0a929fd0e --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentTests.java @@ -0,0 +1,144 @@ +package org.alfresco.rest.workflow.deployments; + +import java.util.List; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestDeploymentModel; +import org.alfresco.rest.model.RestDeploymentModelsCollection; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestProcessDefinitionModel; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestTaskModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Tests for REST API call DELETE "/deployments/{deploymentId}" + * Class has priority 100 in order to be executed last in the list of tests classes + * + * @author Cristina Axinte + * + */ +public class DeleteDeploymentTests extends RestTest +{ + private UserModel adminUser, userModel; + private RestDeploymentModel deployment; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userModel = dataUser.createRandomTestUser(); + } + + @Bug(id = "REPO-1930") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, + executionType = ExecutionType.SANITY, description = "Verify admin user deletes a specific deployment using REST API and status code is successful (204)") + @Test(groups = { TestGroup.REST_API, TestGroup.DEPLOYMENTS, TestGroup.SANITY, TestGroup.WORKFLOW }, priority = 100) + public void adminDeletesDeploymentWithSuccess() throws Exception + { + dataContent.assertExtensionAmpExists("alfresco-workflow-extension"); + // The deployment with name "customWorkflowExtentionForRest.bpmn" is created by Workflow Extention Point + RestDeploymentModelsCollection allDeployments = restClient.authenticateUser(adminUser).withWorkflowAPI().getDeployments(); + allDeployments.assertThat().entriesListContains("name", "customWorkflowExtentionForRest.bpmn"); + deployment = allDeployments.getDeploymentByName("customWorkflowExtentionForRest.bpmn"); + + RestProcessDefinitionModel processDefinitionAssociated = + restClient.withWorkflowAPI().getAllProcessDefinitions().getProcessDefinitionById(deployment.getId()); + + RestProcessModel addedProcess = + restClient.withWorkflowAPI().addProcess(processDefinitionAssociated.getName(), adminUser, false, CMISUtil.Priority.Normal); + + List processTasks = + restClient.withWorkflowAPI().usingProcess(addedProcess).getProcessTasks().getEntries(); + + restClient.withWorkflowAPI().usingDeployment(deployment).deleteDeployment(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + //check get deployment returns http status Not Found after deleting the deployment + restClient.withWorkflowAPI().usingDeployment(deployment).getDeployment(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, deployment.getId())); + + //check that process definitions contained by deployment are deleted + restClient.withWorkflowAPI().usingProcessDefinitions(processDefinitionAssociated).getProcessDefinition(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, processDefinitionAssociated.getId())); + + //check that history information associated with the deployment is deleted + restClient.withWorkflowAPI().usingProcess(addedProcess).getProcess(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, addedProcess.getId())); + + for (RestTaskModel processTask: processTasks) + { + restClient.withWorkflowAPI().usingTask(processTask).getTask(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, processTask.getId())); + } + + //check getProcessDefinitionStartFormModel after deletion of process definition + restClient.withWorkflowAPI().usingProcessDefinitions(processDefinitionAssociated).getProcessDefinitionStartFormModel(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, processDefinitionAssociated.getId())); + + //check getProcessDefinitionImage after deletion of process definition + restClient.withWorkflowAPI().usingProcessDefinitions(processDefinitionAssociated).getProcessDefinitionImage(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, processDefinitionAssociated.getId())); + + //delete deployment twice + restClient.withWorkflowAPI().usingDeployment(deployment).deleteDeployment(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, deployment.getId())) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Bug(id = "REPO-1930") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, + executionType = ExecutionType.SANITY, description = "Verify admin user cannot delete an inexistent deployment using REST API and status code is successful (204)") + @Test(groups = { TestGroup.REST_API, TestGroup.DEPLOYMENTS, TestGroup.SANITY, TestGroup.WORKFLOW }, priority = 100) + public void adminCannotDeleteInexistentDeployment() throws Exception + { + deployment = restClient.authenticateUser(adminUser).withWorkflowAPI().getDeployments().getOneRandomEntry().onModel(); + deployment.setId(String.valueOf(1000)); + + restClient.withWorkflowAPI().usingDeployment(deployment).deleteDeployment(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "1000")); + } + + @Bug(id = "REPO-1930") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, + description = "Verify deleteDeployment is unsupported for empty deployment id with REST API and status code is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION, TestGroup.WORKFLOW }) + public void deleteDeploymentIsUnsupportedForEmptyId() throws Exception + { + deployment = restClient.authenticateUser(adminUser).withWorkflowAPI().getDeployments().getOneRandomEntry().onModel(); + deployment.setId(""); + restClient.withWorkflowAPI().usingDeployment(deployment).deleteDeployment(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); + } + + @Bug(id = "REPO-1930") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, + description = "Verify deleteDeployment is forbidden using non admin user or different user than creator with REST API and status code is 403") + @Test(groups = { TestGroup.REST_API, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION, TestGroup.WORKFLOW }) + public void deleteDeploymentUsingNonAdminUser() throws Exception + { + deployment = restClient.authenticateUser(adminUser).withWorkflowAPI().getDeployments().getOneRandomEntry().onModel(); + restClient.authenticateUser(userModel).withWorkflowAPI().usingDeployment(deployment).deleteDeployment(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/deployments/GetDeploymentCoreTests.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/deployments/GetDeploymentCoreTests.java new file mode 100644 index 000000000..df2aae3a0 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/deployments/GetDeploymentCoreTests.java @@ -0,0 +1,42 @@ +package org.alfresco.rest.workflow.deployments; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestDeploymentModel; +import org.alfresco.rest.model.RestErrorModel; +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; + +/** + * Created by Claudia Agache on 12/7/2016. + */ +public class GetDeploymentCoreTests extends RestTest +{ + private UserModel adminUser; + private RestDeploymentModel expectedDeployment; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, + executionType = ExecutionType.REGRESSION, + description = "Verify if get deployment request returns status code 404 when invalid deploymentId is used.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION }) + public void getNonNetworkDeploymentUsingInvalidDeploymentId() throws Exception + { + expectedDeployment = restClient.authenticateUser(adminUser).withWorkflowAPI().getDeployments().getOneRandomEntry().onModel(); + expectedDeployment.setId("invalidId"); + + restClient.withWorkflowAPI().usingDeployment(expectedDeployment).getDeployment(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidId")); + } + +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/deployments/GetDeploymentFullTests.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/deployments/GetDeploymentFullTests.java new file mode 100644 index 000000000..cea14ceca --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/deployments/GetDeploymentFullTests.java @@ -0,0 +1,57 @@ +package org.alfresco.rest.workflow.deployments; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.model.RestDeploymentModel; +import org.alfresco.rest.model.RestDeploymentModelsCollection; +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; + +/** + * Created by Claudia Agache on 1/31/2017. + */ +public class GetDeploymentFullTests extends RestTest +{ + private UserModel adminUser; + private RestDeploymentModel expectedDeployment, actualDeployment; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, + executionType = ExecutionType.REGRESSION, + description = "Verify if get deployment request returns all deployments if empty deploymentId is used.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION }) + public void getNonNetworkDeploymentUsingEmptyDeploymentId() throws Exception + { + restClient.authenticateUser(adminUser).withWorkflowAPI(); + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "deployments/{deploymentId}", ""); + RestDeploymentModelsCollection deployments = restClient.processModels(RestDeploymentModelsCollection.class, request); + restClient.assertStatusCodeIs(HttpStatus.OK); + deployments.assertThat().entriesListIsNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, + description = "Verify Admin user gets non-network deployments with properties parameter applied using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION}) + public void getNonNetworkDeploymentsWithValidProperties() throws Exception + { + expectedDeployment = restClient.authenticateUser(adminUser).withWorkflowAPI().getDeployments().getOneRandomEntry().onModel(); + actualDeployment = restClient.withParams("properties=id,name").withWorkflowAPI().usingDeployment(expectedDeployment).getDeployment(); + restClient.assertStatusCodeIs(HttpStatus.OK); + actualDeployment.assertThat() + .fieldsCount().is(2).and() + .field("id").is(expectedDeployment.getId()).and() + .field("deployedAt").isNull().and() + .field("name").is(expectedDeployment.getName()); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/deployments/GetDeploymentSanityTests.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/deployments/GetDeploymentSanityTests.java new file mode 100644 index 000000000..67bda8b8a --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/deployments/GetDeploymentSanityTests.java @@ -0,0 +1,57 @@ +package org.alfresco.rest.workflow.deployments; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestDeploymentModel; +import org.alfresco.rest.model.RestErrorModel; +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; + +/** + * Tests for REST API call GET "/deployments/{deploymentId}" + * + * @author Cristina Axinte + * + */ +public class GetDeploymentSanityTests extends RestTest +{ + private UserModel adminUser; + private UserModel anotherUser; + private RestDeploymentModel expectedDeployment, actualDeployment; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + anotherUser = dataUser.createRandomTestUser(); + + expectedDeployment = restClient.authenticateUser(adminUser).withWorkflowAPI().getDeployments().getOneRandomEntry().onModel(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, + executionType = ExecutionType.SANITY, description = "Verify admin user gets a non-network deployment using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.SANITY }) + public void adminGetsNonNetworkDeploymentWithSuccess() throws JsonToModelConversionException, Exception + { + actualDeployment = restClient.authenticateUser(adminUser).withWorkflowAPI().usingDeployment(expectedDeployment).getDeployment(); + restClient.assertStatusCodeIs(HttpStatus.OK); + actualDeployment.assertThat().field("deployedAt").isNotEmpty() + .and().field("name").is(expectedDeployment.getName()) + .and().field("id").is(expectedDeployment.getId()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, + executionType = ExecutionType.SANITY, description = "Verify non admin user is forbidden to get a non-network deployment using REST API (403)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.SANITY }) + public void nonAdminIsForbiddenToGetNonNetworkDeployment() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(anotherUser).withWorkflowAPI().usingDeployment(expectedDeployment).getDeployment(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsCoreTests.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsCoreTests.java new file mode 100644 index 000000000..f35f882a4 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsCoreTests.java @@ -0,0 +1,30 @@ +package org.alfresco.rest.workflow.deployments; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +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.Test; + +/** + * Created by Claudia Agache on 12/7/2016. + */ +public class GetDeploymentsCoreTests extends RestTest +{ + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, + executionType = ExecutionType.REGRESSION, + description = "Verify non admin user is not able to get non-network deployments using REST API and status code is Forbidden") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION}) + public void nonAdminUserCanNotGetNonNetworkDeployments() throws Exception + { + UserModel userModel = dataUser.createRandomTestUser(); + restClient.authenticateUser(userModel).withWorkflowAPI().getDeployments(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsFullTests.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsFullTests.java new file mode 100644 index 000000000..6ba152e46 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsFullTests.java @@ -0,0 +1,146 @@ +package org.alfresco.rest.workflow.deployments; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestDeploymentModel; +import org.alfresco.rest.model.RestDeploymentModelsCollection; +import org.alfresco.rest.model.RestErrorModel; +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; + +/** + * Created by Claudia Agache on 1/30/2017. + */ +public class GetDeploymentsFullTests extends RestTest +{ + private UserModel adminUserModel; + private RestDeploymentModelsCollection deployments; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + restClient.authenticateUser(adminUserModel); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, + description = "Verify Admin user gets non-network deployments with skipCount parameter applied using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION}) + public void getNonNetworkDeploymentsWithValidSkipCount() throws JsonToModelConversionException, Exception + { + deployments = restClient.withWorkflowAPI().getDeployments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + RestDeploymentModel firstDeployment = deployments.getEntries().get(0).onModel(); + RestDeploymentModel secondDeployment = deployments.getEntries().get(1).onModel(); + RestDeploymentModelsCollection deploymentsWithSkipCount = restClient.withParams("skipCount=2").withWorkflowAPI().getDeployments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + deploymentsWithSkipCount + .assertThat().entriesListDoesNotContain("name", firstDeployment.getName()) + .assertThat().entriesListDoesNotContain("name", secondDeployment.getName()) + .assertThat().entriesListCountIs(deployments.getEntries().size()-2); + deploymentsWithSkipCount.assertThat().paginationField("skipCount").is("2"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, + description = "Verify Admin user doesn't get non-network deployments when negative skipCount parameter is applied using REST API and status code is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION}) + public void getNonNetworkDeploymentsWithNegativeSkipCount() throws JsonToModelConversionException, Exception + { + restClient.withParams("skipCount=-1").withWorkflowAPI().getDeployments(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT) + .containsErrorKey(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE) + .statusCodeIs(HttpStatus.BAD_REQUEST); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, + description = "Verify Admin user doesn't get non-network deployments when non numeric skipCount parameter is applied using REST API and status code is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION}) + public void getNonNetworkDeploymentsWithNotNumericSkipCount() throws JsonToModelConversionException, Exception + { + restClient.withParams("skipCount=A").withWorkflowAPI().getDeployments(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "A")); + } + + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, + description = "Verify Admin user gets non-network deployments with maxItems parameter applied using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION}) + public void getNonNetworkDeploymentsWithValidMaxItems() throws JsonToModelConversionException, Exception + { + deployments = restClient.withWorkflowAPI().getDeployments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + RestDeploymentModel firstDeployment = deployments.getEntries().get(0).onModel(); + RestDeploymentModel secondDeployment = deployments.getEntries().get(1).onModel(); + RestDeploymentModelsCollection deploymentsWithMaxItems = restClient.withParams("maxItems=2").withWorkflowAPI().getDeployments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + deploymentsWithMaxItems + .assertThat().entriesListContains("name", firstDeployment.getName()) + .assertThat().entriesListContains("name", secondDeployment.getName()) + .assertThat().entriesListCountIs(2); + deploymentsWithMaxItems.assertThat().paginationField("maxItems").is("2"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, + description = "Verify Admin user doesn't get non-network deployments when negative maxItems parameter is applied using REST API and status code is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION}) + public void getNonNetworkDeploymentsWithNegativeMaxItems() throws JsonToModelConversionException, Exception + { + restClient.withParams("maxItems=-1").withWorkflowAPI().getDeployments(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) + .containsErrorKey(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE) + .statusCodeIs(HttpStatus.BAD_REQUEST); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, + description = "Verify Admin user doesn't get non-network deployments when non numeric maxItems parameter is applied using REST API and status code is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION}) + public void getNonNetworkDeploymentsWithNotNumericMaxItems() throws JsonToModelConversionException, Exception + { + restClient.withParams("maxItems=A").withWorkflowAPI().getDeployments(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "A")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, + description = "Verify Admin user gets non-network deployments with properties parameter applied using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION}) + public void getNonNetworkDeploymentsWithValidProperties() throws JsonToModelConversionException, Exception + { + deployments = restClient.withParams("properties=name").withWorkflowAPI().getDeployments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + deployments.assertThat().entriesListIsNotEmpty(); + deployments.getOneRandomEntry().onModel().assertThat() + .fieldsCount().is(1).and() + .field("id").isNull().and() + .field("deployedAt").isNull().and() + .field("name").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, + description = "Verify Admin user gets non-network deployments with non existing properties parameter applied using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION}) + public void getNonNetworkDeploymentsWithNonExistingProperties() throws JsonToModelConversionException, Exception + { + deployments = restClient.withParams("properties=TAS").withWorkflowAPI().getDeployments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + deployments.assertThat().entriesListIsNotEmpty(); + deployments.getOneRandomEntry().onModel().assertThat() + .fieldsCount().is(0).and() + .field("id").isNull().and() + .field("deployedAt").isNull().and() + .field("name").isNull(); + } + +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsSanityTests.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsSanityTests.java new file mode 100644 index 000000000..9d1a4025f --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsSanityTests.java @@ -0,0 +1,44 @@ +package org.alfresco.rest.workflow.deployments; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestDeploymentModelsCollection; +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; + +/** + * Created by Claudia Agache on 10/4/2016. + */ +public class GetDeploymentsSanityTests extends RestTest +{ + private UserModel adminUserModel; + private RestDeploymentModelsCollection deployments; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + restClient.authenticateUser(adminUserModel); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.SANITY, + description = "Verify Admin user gets non-network deployments using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.SANITY}) + public void getNonNetworkDeploymentsWithAdmin() throws JsonToModelConversionException, Exception + { + deployments = restClient.authenticateUser(adminUserModel).withWorkflowAPI().getDeployments(); + restClient.assertStatusCodeIs(HttpStatus.OK); + deployments.assertThat().entriesListIsNotEmpty(); + deployments.getOneRandomEntry().onModel().assertThat() + .fieldsCount().is(3).and() + .field("id").isNotEmpty().and() + .field("deployedAt").isNotEmpty().and() + .field("name").isNotEmpty(); + } + +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionCoreTests.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionCoreTests.java new file mode 100644 index 000000000..3edb7e020 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionCoreTests.java @@ -0,0 +1,45 @@ +package org.alfresco.rest.workflow.processDefinitions; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestProcessDefinitionModel; +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; + +/** + * Created by Claudia Agache on 12/5/2016. + */ +public class GetProcessDefinitionCoreTests extends RestTest +{ + private UserModel adminUser; + private RestProcessDefinitionModel randomProcessDefinition; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, + executionType = ExecutionType.REGRESSION, + description = "Verify if get process definition returns status code 404 when invalid processDefinitionId is used") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) + public void getProcessDefinitionUsingInvalidProcessDefinitionId() throws Exception + { + restClient.authenticateUser(adminUser); + randomProcessDefinition = restClient.withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry().onModel(); + randomProcessDefinition.setId("invalidID"); + restClient.withWorkflowAPI() + .usingProcessDefinitions(randomProcessDefinition).getProcessDefinition(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidID")) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionFullTests.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionFullTests.java new file mode 100644 index 000000000..17c2b6972 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionFullTests.java @@ -0,0 +1,67 @@ +package org.alfresco.rest.workflow.processDefinitions; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.model.RestProcessDefinitionModel; +import org.alfresco.rest.model.RestProcessDefinitionModelsCollection; +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; + +/** + * Created by Claudia Agache on 2/1/2017. + */ +public class GetProcessDefinitionFullTests extends RestTest +{ + private UserModel adminUser; + private RestProcessDefinitionModel randomProcessDefinition, returnedProcessDefinition; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, + executionType = ExecutionType.REGRESSION, + description = "Verify if get process definition returns all process definitions when empty processDefinitionId is used") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) + public void getProcessDefinitionUsingEmptyProcessDefinitionId() throws Exception + { + restClient.authenticateUser(adminUser).withWorkflowAPI(); + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "/process-definitions/{processDefinitionId}", ""); + RestProcessDefinitionModelsCollection processDefinitions = restClient.processModels(RestProcessDefinitionModelsCollection.class, request); + restClient.assertStatusCodeIs(HttpStatus.OK); + processDefinitions.assertThat().entriesListIsNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, + executionType = ExecutionType.REGRESSION, + description = "Verify Admin user gets a process definition with properties parameter applied using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) + public void getProcessDefinitionWithValidProperties() throws Exception + { + randomProcessDefinition = restClient.authenticateUser(adminUser).withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry().onModel(); + returnedProcessDefinition = restClient.withParams("properties=id,name,graphicNotationDefined,version") + .withWorkflowAPI() + .usingProcessDefinitions(randomProcessDefinition).getProcessDefinition(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedProcessDefinition.assertThat() + .fieldsCount().is(4).and() + .field("deploymentId").isNull().and() + .field("description").isNull().and() + .field("id").is(randomProcessDefinition.getId()).and() + .field("startFormResourceKey").isNull().and() + .field("category").isNull().and() + .field("title").isNull().and() + .field("version").is(randomProcessDefinition.getVersion()).and() + .field("graphicNotationDefined").is(randomProcessDefinition.getGraphicNotationDefined()).and() + .field("key").isNull().and() + .field("name").is(randomProcessDefinition.getName()); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageCoreTests.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageCoreTests.java new file mode 100644 index 000000000..2fe6f5f3c --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageCoreTests.java @@ -0,0 +1,46 @@ +package org.alfresco.rest.workflow.processDefinitions; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestProcessDefinitionModel; +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; + +/** + * Created by Claudia Agache on 12/6/2016. + */ +public class GetProcessDefinitionImageCoreTests extends RestTest +{ + private UserModel adminUser; + private RestProcessDefinitionModel randomProcessDefinition; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, + executionType = ExecutionType.REGRESSION, + description = "Verify if get process definition image returns status code 404 when invalid processDefinitionId is used") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) + public void getProcessDefinitionImageUsingInvalidProcessDefinitionId() throws Exception + { + restClient.authenticateUser(adminUser); + randomProcessDefinition = restClient.withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry().onModel(); + randomProcessDefinition.setId("invalidID"); + + restClient.withWorkflowAPI() + .usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionImage(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidID")) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageFullTests.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageFullTests.java new file mode 100644 index 000000000..9c37e7c46 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageFullTests.java @@ -0,0 +1,42 @@ +package org.alfresco.rest.workflow.processDefinitions; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestProcessDefinitionModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Created by Claudia Agache on 2/1/2017. + */ +public class GetProcessDefinitionImageFullTests extends RestTest +{ + private UserModel adminUser; + private RestProcessDefinitionModel randomProcessDefinition; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + } + + @Bug(id = "REPO-1911") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, + executionType = ExecutionType.REGRESSION, + description = "Verify if get process definition image returns status code 404 when empty processDefinitionId is used") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) + public void getProcessDefinitionImageUsingEmptyProcessDefinitionId() throws Exception + { + restClient.authenticateUser(adminUser); + randomProcessDefinition = restClient.withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry().onModel(); + randomProcessDefinition.setId(""); + restClient.withWorkflowAPI() + .usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionImage(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java new file mode 100644 index 000000000..06f76f017 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java @@ -0,0 +1,49 @@ +package org.alfresco.rest.workflow.processDefinitions; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestProcessDefinitionModel; +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; + +/** + * Created by Claudia Agache on 10/13/2016. + */ +public class GetProcessDefinitionImageSanityTests extends RestTest +{ + private UserModel testUser; + private RestProcessDefinitionModel randomProcessDefinition; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + testUser = dataUser.createRandomTestUser(); + restClient.authenticateUser(dataUser.getAdminUser()); + randomProcessDefinition = restClient.withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry().onModel(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.SANITY, + description = "Verify Any user gets a specific process definition image for non-network deployments using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY, TestGroup.REQUIRE_TRANSFORMATION }) + public void anyUserGetsProcessDefinitionImage() throws Exception + { + restClient.authenticateUser(testUser); + restClient.withWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionImage() + .assertResponseContainsImage(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.SANITY, + description = "Verify Admin user gets a specific process definition image for non-network deployments using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY, TestGroup.REQUIRE_TRANSFORMATION }) + public void adminGetsProcessDefinitionImage() throws Exception + { + restClient.withWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionImage() + .assertResponseContainsImage(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java new file mode 100644 index 000000000..36d8ef872 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java @@ -0,0 +1,62 @@ +package org.alfresco.rest.workflow.processDefinitions; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestProcessDefinitionModel; +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; + +/** + * Created by Claudia Agache on 10/13/2016. + */ +public class GetProcessDefinitionSanityTests extends RestTest +{ + private UserModel testUser; + private RestProcessDefinitionModel randomProcessDefinition, firstRandomProcessDefinition, returnedProcessDefinition; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + testUser = dataUser.createRandomTestUser(); + restClient.authenticateUser(dataUser.getAdminUser()); + randomProcessDefinition = restClient.withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry().onModel(); + firstRandomProcessDefinition = restClient.withWorkflowAPI().getAllProcessDefinitions().getProcessDefinitionByDeploymentId("1"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, + executionType = ExecutionType.SANITY, + description = "Verify Admin user gets a specific process definition for non-network deployments using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY }) + public void adminGetsProcessDefinition() throws Exception + { + returnedProcessDefinition = restClient.withWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinition(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedProcessDefinition.assertThat().field("name").is(randomProcessDefinition.getName()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, + executionType = ExecutionType.SANITY, + description = "Verify Any user gets a specific process definition for non-network deployments using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY }) + public void anyUserGetsProcessDefinition() throws Exception + { + restClient.authenticateUser(testUser); + returnedProcessDefinition = restClient.withWorkflowAPI().usingProcessDefinitions(firstRandomProcessDefinition).getProcessDefinition(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedProcessDefinition.assertThat() + .field("name").is(firstRandomProcessDefinition.getName()).and() + .field("deploymentId").is(firstRandomProcessDefinition.getDeploymentId()).and() + .field("description").is(firstRandomProcessDefinition.getDescription()).and() + .field("id").is(firstRandomProcessDefinition.getId()).and() + .field("startFormResourceKey").is(firstRandomProcessDefinition.getStartFormResourceKey()).and() + .field("category").is(firstRandomProcessDefinition.getCategory()).and() + .field("title").is(firstRandomProcessDefinition.getTitle()).and() + .field("version").is(firstRandomProcessDefinition.getVersion()).and() + .field("graphicNotationDefined").is(firstRandomProcessDefinition.getGraphicNotationDefined()).and() + .field("key").is(firstRandomProcessDefinition.getKey()); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java new file mode 100644 index 000000000..6290ad9f6 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java @@ -0,0 +1,80 @@ +package org.alfresco.rest.workflow.processDefinitions; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestProcessDefinitionModel; +import org.alfresco.rest.model.RestProcessDefinitionModelsCollection; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Created by Claudia Agache on 12/6/2016. + */ +public class GetProcessDefinitionStartFormModelCoreTests extends RestTest +{ + private UserModel adminUser; + private RestProcessDefinitionModel randomProcessDefinition; + private RestProcessDefinitionModelsCollection allProcessDefinitions; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + allProcessDefinitions = restClient.authenticateUser(adminUser).withWorkflowAPI().getAllProcessDefinitions(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, + executionType = ExecutionType.REGRESSION, + description = "Verify any user gets a model of the start form type definition for non-network deployments using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) + public void nonNetworkUserGetsStartFormModel() throws Exception + { + UserModel nonNetworkUser = dataUser.createRandomTestUser(); + randomProcessDefinition = allProcessDefinitions.getOneRandomEntry().onModel(); + restClient.authenticateUser(nonNetworkUser).withWorkflowAPI() + .usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionStartFormModel() + .assertThat().entriesListIsNotEmpty(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Bug(id = "ALF-20187") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, + executionType = ExecutionType.REGRESSION, + description = "Verify if get request returns status code 404 when invalid processDefinitionId is used") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) + public void getStartFormModelUsingInvalidProcessDefinitionId() throws Exception + { + randomProcessDefinition = allProcessDefinitions.getOneRandomEntry().onModel(); + randomProcessDefinition.setId("invalidID"); + + restClient.authenticateUser(adminUser).withWorkflowAPI() + .usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionStartFormModel(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format("no deployed process definition found with id '%s'", "invalidID")) + .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Bug(id = "ALF-20187") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, + executionType = ExecutionType.REGRESSION, + description = "Verify if get request returns status code 404 when empty processDefinitionId is used") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) + public void getStartFormModelUsingEmptyProcessDefinitionId() throws Exception + { + randomProcessDefinition = allProcessDefinitions.getOneRandomEntry().onModel(); + randomProcessDefinition.setId(""); + + restClient.authenticateUser(adminUser).withWorkflowAPI() + .usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionStartFormModel(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary("no deployed process definition found with id ''"); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelFullTests.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelFullTests.java new file mode 100644 index 000000000..fa77452a4 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelFullTests.java @@ -0,0 +1,71 @@ +package org.alfresco.rest.workflow.processDefinitions; + +import java.util.Arrays; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestFormModelsCollection; +import org.alfresco.rest.model.RestProcessDefinitionModel; +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; + +/** + * Created by Claudia Agache on 1/31/2017. + */ +public class GetProcessDefinitionStartFormModelFullTests extends RestTest +{ + private UserModel adminUser; + private RestProcessDefinitionModel activitiAdhoc; + private RestFormModelsCollection returnedResponse; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + activitiAdhoc = restClient.authenticateUser(adminUser).withWorkflowAPI().getAllProcessDefinitions().getProcessDefinitionByDeploymentId("1"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, + executionType = ExecutionType.REGRESSION, + description = "Verify admin gets a model of the start form type definition for specific process definition using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) + public void adminGetsStartFormModelForActivitiAdhocProcessDefinition() throws Exception + { + returnedResponse = restClient.authenticateUser(adminUser).withWorkflowAPI() + .usingProcessDefinitions(activitiAdhoc).getProcessDefinitionStartFormModel(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedResponse.assertThat().entriesListContains("qualifiedName", "{http://www.alfresco.org/model/bpm/1.0}workflowPriority"); + returnedResponse.getStartFormModelByQualifiedName("{http://www.alfresco.org/model/bpm/1.0}workflowPriority") + .assertThat().field("defaultValue").is("2") + .and().field("dataType").is("d:int") + .and().field("name").is("bpm_workflowPriority") + .and().field("title").is("Workflow Priority") + .and().field("required").is("false") + .and().field("allowedValues").is(Arrays.asList("1", "2", "3")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, + executionType = ExecutionType.REGRESSION, + description = "Verify admin gets a model of the start form type definition with properties parameter applied using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) + public void adminGetsStartFormModelWithPropertiesParameterApplied() throws Exception + { + returnedResponse = restClient.authenticateUser(adminUser).withParams("properties=qualifiedName,dataType,title").withWorkflowAPI() + .usingProcessDefinitions(activitiAdhoc).getProcessDefinitionStartFormModel(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedResponse.assertThat().entriesListContains("qualifiedName", "{http://www.alfresco.org/model/bpm/1.0}workflowPriority"); + returnedResponse.getStartFormModelByQualifiedName("{http://www.alfresco.org/model/bpm/1.0}workflowPriority") + .assertThat().fieldsCount().is(3) + .and().field("qualifiedName").is("{http://www.alfresco.org/model/bpm/1.0}workflowPriority") + .and().field("defaultValue").isNull() + .and().field("dataType").is("d:int") + .and().field("name").isNull() + .and().field("title").is("Workflow Priority") + .and().field("required").isNull() + .and().field("allowedValues").isNull(); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java new file mode 100644 index 000000000..7b3d98aef --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java @@ -0,0 +1,38 @@ +package org.alfresco.rest.workflow.processDefinitions; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestProcessDefinitionModel; +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; + +/** + * Created by Claudia Agache on 10/18/2016. + */ +public class GetProcessDefinitionStartFormModelSanityTests extends RestTest +{ + private UserModel adminUserModel; + private RestProcessDefinitionModel randomProcessDefinition; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + restClient.authenticateUser(adminUserModel); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, + executionType = ExecutionType.SANITY, + description = "Verify Admin gets a model of the start form type definition for non-network deployments using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY }) + public void nonNetworkAdminGetsStartFormModel() throws Exception + { + randomProcessDefinition = restClient.withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry().onModel(); + restClient.withWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionStartFormModel().assertThat().entriesListIsNotEmpty(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsCoreTests.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsCoreTests.java new file mode 100644 index 000000000..6d4e492ff --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsCoreTests.java @@ -0,0 +1,53 @@ +package org.alfresco.rest.workflow.processDefinitions; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class GetProcessDefinitionsCoreTests extends RestTest +{ + private UserModel userModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, + description = "Verify call to get process definitions with invalid orderBy parameter with REST API and status code is BAD_REQUEST (400)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) + public void userGetProcessDefinitionsWithInvalidOrderBy() throws Exception + { + restClient.authenticateUser(userModel) + .withParams("orderBy=test") + .withWorkflowAPI() + .getAllProcessDefinitions() + .assertThat().entriesListIsEmpty(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_ORDERBY, "test", "deploymentId, name, id, category, version, key")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, + description = "Verify call to get process definitions with invalid where parameter with REST API and status code is BAD_REQUEST (400)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) + public void userGetProcessDefinitionsWithInvalidWhere() throws Exception + { + restClient.authenticateUser(userModel) + .withParams("where=test") + .withWorkflowAPI() + .getAllProcessDefinitions() + .assertThat().entriesListIsEmpty(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_WHERE_QUERY, "test")) + .containsErrorKey(RestErrorModel.INVALID_QUERY_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsFullTests.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsFullTests.java new file mode 100644 index 000000000..6d4f929e7 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsFullTests.java @@ -0,0 +1,174 @@ +package org.alfresco.rest.workflow.processDefinitions; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestProcessDefinitionModel; +import org.alfresco.rest.model.RestProcessDefinitionModelsCollection; +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; + +/** + * Created by Claudia Agache on 2/1/2017. + */ +public class GetProcessDefinitionsFullTests extends RestTest +{ + private UserModel adminUserModel; + private RestProcessDefinitionModelsCollection processDefinitions; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, + description = "Verify admin gets process definitions with valid skipCount parameter applied using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) + public void getProcessDefinitionsWithValidSkipCount() throws Exception + { + processDefinitions = restClient.authenticateUser(adminUserModel) + .withWorkflowAPI().getAllProcessDefinitions(); + restClient.assertStatusCodeIs(HttpStatus.OK); + RestProcessDefinitionModel firstProcessDefinition = processDefinitions.getEntries().get(0).onModel(); + RestProcessDefinitionModel secondProcessDefinition = processDefinitions.getEntries().get(1).onModel(); + + RestProcessDefinitionModelsCollection procDefWithSkipCount = restClient.withParams("skipCount=2").withWorkflowAPI().getAllProcessDefinitions(); + restClient.assertStatusCodeIs(HttpStatus.OK); + procDefWithSkipCount + .assertThat().entriesListDoesNotContain("name", firstProcessDefinition.getName()) + .assertThat().entriesListDoesNotContain("name", secondProcessDefinition.getName()) + .assertThat().entriesListCountIs(processDefinitions.getEntries().size()-2); + procDefWithSkipCount.assertThat().paginationField("skipCount").is("2"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, + description = "Verify admin doesn't get process definitions with negative skipCount parameter applied using REST API") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) + public void getProcessDefinitionsWithNegativeSkipCount() throws Exception + { + restClient.authenticateUser(adminUserModel).withParams("skipCount=-1").withWorkflowAPI().getAllProcessDefinitions(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT) + .containsErrorKey(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE) + .statusCodeIs(HttpStatus.BAD_REQUEST); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, + description = "Verify admin doesn't get process definitions with non numeric skipCount parameter applied using REST API") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) + public void getProcessDefinitionsWithNonNumericSkipCount() throws Exception + { + restClient.authenticateUser(adminUserModel).withParams("skipCount=A").withWorkflowAPI().getAllProcessDefinitions(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "A")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, + description = "Verify admin gets process definitions with valid maxItems parameter applied using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) + public void getProcessDefinitionsWithValidMaxItems() throws Exception + { + processDefinitions = restClient.authenticateUser(adminUserModel) + .withWorkflowAPI().getAllProcessDefinitions(); + restClient.assertStatusCodeIs(HttpStatus.OK); + RestProcessDefinitionModel firstProcessDefinition = processDefinitions.getEntries().get(0).onModel(); + RestProcessDefinitionModel secondProcessDefinition = processDefinitions.getEntries().get(1).onModel(); + + RestProcessDefinitionModelsCollection procDefWithMaxItems = restClient.withParams("maxItems=2").withWorkflowAPI().getAllProcessDefinitions(); + restClient.assertStatusCodeIs(HttpStatus.OK); + procDefWithMaxItems + .assertThat().entriesListContains("name", firstProcessDefinition.getName()) + .assertThat().entriesListContains("name", secondProcessDefinition.getName()) + .assertThat().entriesListCountIs(2); + procDefWithMaxItems.assertThat().paginationField("maxItems").is("2"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, + description = "Verify admin doesn't get process definitions with negative maxItems parameter applied using REST API") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) + public void getProcessDefinitionsWithNegativeMaxItems() throws Exception + { + restClient.authenticateUser(adminUserModel).withParams("maxItems=-1").withWorkflowAPI().getAllProcessDefinitions(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) + .containsErrorKey(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE) + .statusCodeIs(HttpStatus.BAD_REQUEST); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, + description = "Verify admin doesn't get process definitions with non numeric maxItems parameter applied using REST API") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) + public void getProcessDefinitionsWithNonNumericMaxItems() throws Exception + { + restClient.authenticateUser(adminUserModel).withParams("maxItems=A").withWorkflowAPI().getAllProcessDefinitions(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "A")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, + description = "Verify Admin user gets process definitions with properties parameter applied using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) + public void getProcessDefinitionsWithValidProperties() throws Exception + { + processDefinitions =restClient.authenticateUser(adminUserModel).withParams("properties=name,graphicNotationDefined,version").withWorkflowAPI().getAllProcessDefinitions(); + restClient.assertStatusCodeIs(HttpStatus.OK); + processDefinitions.assertThat().entriesListIsNotEmpty(); + processDefinitions.getOneRandomEntry().onModel().assertThat() + .fieldsCount().is(3).and() + .field("deploymentId").isNull().and() + .field("description").isNull().and() + .field("id").isNull().and() + .field("startFormResourceKey").isNull().and() + .field("category").isNull().and() + .field("title").isNull().and() + .field("version").isNotEmpty().and() + .field("graphicNotationDefined").isNotEmpty().and() + .field("key").isNull().and() + .field("name").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, + description = "Verify admin gets process definitions ordered by name ascendant using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) + public void getProcessDefinitionsOrderedByNameAsc() throws Exception + { + processDefinitions = restClient.authenticateUser(adminUserModel) + .withParams("orderBy=name ASC").withWorkflowAPI().getAllProcessDefinitions(); + restClient.assertStatusCodeIs(HttpStatus.OK); + processDefinitions.assertThat().entriesListIsSortedAscBy("name"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, + description = "Verify admin doesn't get process definitions when many fields are used for orderBy parameter") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) + public void getProcessDefinitionsOrderedByManyFields() throws Exception + { + restClient.authenticateUser(adminUserModel) + .withParams("orderBy=name,id").withWorkflowAPI().getAllProcessDefinitions(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(RestErrorModel.ONLY_ONE_ORDERBY); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, + description = "Verify admin gets process definitions when where parameter is applied") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) + public void getProcessDefinitionsFilteredByKey() throws Exception + { + processDefinitions = restClient.authenticateUser(adminUserModel) + .withParams("where=(key matches('activitiParallel%'))").withWorkflowAPI().getAllProcessDefinitions(); + restClient.assertStatusCodeIs(HttpStatus.OK); + processDefinitions.assertThat().entriesListCountIs(2) + .assertThat().entriesListContains("key", "activitiParallelReview") + .assertThat().entriesListContains("key", "activitiParallelGroupReview"); + } + +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java new file mode 100644 index 000000000..f0a330d7c --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java @@ -0,0 +1,48 @@ +package org.alfresco.rest.workflow.processDefinitions; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestProcessDefinitionModelsCollection; +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; + +/** + * Created by Claudia Agache on 10/13/2016. + */ +public class GetProcessDefinitionsSanityTests extends RestTest +{ + private UserModel adminUserModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + restClient.authenticateUser(adminUserModel); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, + executionType = ExecutionType.SANITY, description = "Verify Admin user gets process definitions for non-network deployments using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY }) + public void nonNetworkAdminGetsProcessDefinitions() throws Exception + { + RestProcessDefinitionModelsCollection processDefinitions = restClient.authenticateUser(adminUserModel) + .withWorkflowAPI() + .getAllProcessDefinitions(); + restClient.assertStatusCodeIs(HttpStatus.OK); + processDefinitions.assertThat().entriesListIsNotEmpty(); + processDefinitions.getProcessDefinitionByDeploymentId("1").assertThat() + .field("name").is("Adhoc Activiti Process").and() + .field("description").is("Assign a new task to yourself or a colleague").and() + .field("id").is("activitiAdhoc:1:4").and() + .field("startFormResourceKey").is("wf:submitAdhocTask").and() + .field("category").is("http://alfresco.org").and() + .field("title").is("New Task").and() + .field("version").is("1").and() + .field("graphicNotationDefined").is("true").and() + .field("key").is("activitiAdhoc"); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/AddProcessCoreTests.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/AddProcessCoreTests.java new file mode 100644 index 000000000..8a2eac446 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/AddProcessCoreTests.java @@ -0,0 +1,130 @@ +package org.alfresco.rest.workflow.processes; + +import org.alfresco.dataprep.CMISUtil.Priority; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestProcessDefinitionModel; +import org.alfresco.rest.model.RestProcessDefinitionModelsCollection; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestProcessModelsCollection; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.testng.annotations.Test; + +/** + * + * @author Cristina Axinte + * + */ +public class AddProcessCoreTests extends RestTest +{ + private UserModel assignee, adminUser; + private RestProcessModel addedProcess; + private RestProcessModelsCollection processes; + private RestProcessDefinitionModel processDefinition; + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, + executionType = ExecutionType.REGRESSION, description = "Verify non network admin is able to start new process using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void nonNetworkAdminUserStartsNewProcess() throws JsonToModelConversionException, Exception + { + adminUser = dataUser.getAdminUser(); + assignee = dataUser.createRandomTestUser(); + + addedProcess = restClient.authenticateUser(adminUser).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + addedProcess.assertThat().field("id").is(addedProcess.getId()) + .and().field("startUserId").is(adminUser.getUsername()); + + processDefinition = restClient.authenticateUser(adminUser).withWorkflowAPI().getAllProcessDefinitions().getProcessDefinitionByKey("activitiAdhoc"); + processes = restClient.withWorkflowAPI().getProcesses(); + restClient.assertStatusCodeIs(HttpStatus.OK); + processes.assertThat().entriesListContains("id", addedProcess.getId()) + .assertThat().entriesListContains("processDefinitionId", processDefinition.getId()) + .assertThat().entriesListContains("startUserId", adminUser.getUsername()) + .assertThat().entriesListContains("startActivityId", "start") + .assertThat().entriesListContains("completed", "false") + .assertThat().entriesListContains("processDefinitionKey", "activitiAdhoc"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, + executionType = ExecutionType.REGRESSION, description = "Verify start new process with empty request body using REST API returns status code is Bad Request (400)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void startNewProcessWithEmptyProcessBody() throws JsonToModelConversionException, Exception + { + adminUser = dataUser.getAdminUser(); + assignee = dataUser.createRandomTestUser(); + + restClient.authenticateUser(adminUser).withWorkflowAPI(); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "", "processes"); + restClient.processModel(RestProcessModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + } + + @Bug(id = "REPO-1936") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, + executionType = ExecutionType.REGRESSION, description = "Verify start new process with invalid request body using REST API returns status code is Bad Request (400)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void startNewProcessWithInvalidProcessDefInProcessBody() throws JsonToModelConversionException, Exception + { + adminUser = dataUser.getAdminUser(); + assignee = dataUser.createRandomTestUser(); + + restClient.authenticateUser(adminUser).withWorkflowAPI(); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{\"processDefinitionKey\":\"activitiAdhoc\"}", "processes"); + restClient.processModel(RestProcessModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, + executionType = ExecutionType.REGRESSION, description = "Verify start new process with invalid request body using REST API returns status code is Bad Request (400)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void startNewProcessWithInvalidVariablesInProcessBody1() throws JsonToModelConversionException, Exception + { + adminUser = dataUser.getAdminUser(); + assignee = dataUser.createRandomTestUser(); + + restClient.authenticateUser(adminUser).withWorkflowAPI(); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{\"variables\":{\"bpm_sendEMailNotifications\":false}}", "processes"); + restClient.processModel(RestProcessModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary("Either processDefinitionId or processDefinitionKey is required"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, + executionType = ExecutionType.REGRESSION, description = "Verify start new process with invalid request body using REST API returns status code is Bad Request (400)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void startNewProcessWithInvalidVariablesInProcessBody2() throws JsonToModelConversionException, Exception + { + adminUser = dataUser.getAdminUser(); + assignee = dataUser.createRandomTestUser(); + + restClient.authenticateUser(adminUser).withWorkflowAPI(); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{\"variables\":{\"bpm_assignee\":\"admin\"}}", "processes"); + restClient.processModel(RestProcessModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary("Either processDefinitionId or processDefinitionKey is required"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, + executionType = ExecutionType.REGRESSION, description = "Verify start new process with invalid request body using REST API returns status code is Bad Request (400)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void startNewProcessWithInvalidVariablesInProcessBody3() throws JsonToModelConversionException, Exception + { + adminUser = dataUser.getAdminUser(); + assignee = dataUser.createRandomTestUser(); + + restClient.authenticateUser(adminUser).withWorkflowAPI(); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{\"variables\":{\"bpm_workflowPriority\":2}}", "processes"); + restClient.processModel(RestProcessModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary("Either processDefinitionId or processDefinitionKey is required"); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/AddProcessFullTests.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/AddProcessFullTests.java new file mode 100644 index 000000000..c1eb6b24a --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/AddProcessFullTests.java @@ -0,0 +1,150 @@ +package org.alfresco.rest.workflow.processes; + +import javax.json.JsonObject; + +import org.alfresco.dataprep.CMISUtil.Priority; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.JsonBodyGenerator; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * + * @author Cristina Axinte + * + */ +public class AddProcessFullTests extends RestTest +{ + private UserModel userWhoStartsProcess, assignee; + RestProcessModel addedProcess; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + assignee = dataUser.createRandomTestUser(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify user cannot start new process with invalid processDefinitionKey using REST API and status code is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void userStartsNewProcessWithInvalidProcessDefinitionKey() throws JsonToModelConversionException, Exception + { + userWhoStartsProcess = dataUser.createRandomTestUser(); + + addedProcess = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcess("activitiAdhocc", assignee, false, Priority.Normal); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(String.format(RestErrorModel.NO_WORKFLOW_DEFINITION_FOUND, "activitiAdhocc")) + .containsSummary(String.format(RestErrorModel.NO_WORKFLOW_DEFINITION_FOUND, "activitiAdhocc")) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } + + @Bug(id = "REPO-1970") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify user cannot start new process with invalid processDefinitionKey using REST API and status code is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void userStartsNewProcessWithEmptyVariablesBody() throws JsonToModelConversionException, Exception + { + userWhoStartsProcess = dataUser.createRandomTestUser(); + + JsonObject postJson = JsonBodyGenerator.defineJSON() + .add("processDefinitionKey", "activitiAdhoc") + .add("variables", + JsonBodyGenerator.defineJSON().build() + ).build(); + addedProcess = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcessWithBody(postJson); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(String.format(RestErrorModel.NO_WORKFLOW_DEFINITION_FOUND, "activitiAdhoc")); + } + + @Bug(id = "REPO-1970") + @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify user cannot start new process with invalid processDefinitionKey using REST API and status code is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void userStartsNewProcessWithNoAssigneeInVariablesBody() throws JsonToModelConversionException, Exception + { + userWhoStartsProcess = dataUser.createRandomTestUser(); + + JsonObject postJson = JsonBodyGenerator.defineJSON() + .add("processDefinitionKey", "activitiAdhoc") + .add("variables", + JsonBodyGenerator.defineJSON() + .add("bpm_sendEMailNotifications", false) + .add("bpm_workflowPriority", Priority.Low.getLevel()).build() + ).build(); + addedProcess = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcessWithBody(postJson); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(String.format(RestErrorModel.NO_WORKFLOW_DEFINITION_FOUND, "activitiAdhoc")); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify user cannot start new process with invalid assignee using REST API and status code is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void userStartsNewProcessWithInvalidAssignee() throws JsonToModelConversionException, Exception + { + userWhoStartsProcess = dataUser.createRandomTestUser(); + UserModel invalidAssignee = new UserModel("invalidAssignee", "password"); + + addedProcess = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcess("activitiAdhoc", invalidAssignee, false, Priority.Normal); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(String.format(RestErrorModel.INVALID_USER_ID, invalidAssignee.getUsername())) + .containsSummary(String.format(RestErrorModel.INVALID_USER_ID, invalidAssignee.getUsername())) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } + + @Bug(id = "REPO-1970") + @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify user cannot start new process with invalid sendEMailNotifications value using REST API and status code is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void userStartsNewProcessWithInvalidEmailNotification() throws JsonToModelConversionException, Exception + { + userWhoStartsProcess = dataUser.createRandomTestUser(); + JsonObject postJson = JsonBodyGenerator.defineJSON() + .add("processDefinitionKey", "activitiAdhoc") + .add("variables", + JsonBodyGenerator.defineJSON() + .add("bpm_assignee", assignee.getUsername()) + .add("bpm_sendEMailNotifications", "111") + .add("bpm_workflowPriority", Priority.Low.getLevel()).build() + ).build(); + + addedProcess = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcessWithBody(postJson); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(String.format(RestErrorModel.UNSUPPORTED_TYPE, "111")) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } + + @Bug(id = "REPO-1970") + @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify user cannot start new process with invalid priority using REST API and status code is 400") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void userStartsNewProcessWithInvalidPriority() throws JsonToModelConversionException, Exception + { + userWhoStartsProcess = dataUser.createRandomTestUser(); + JsonObject postJson = JsonBodyGenerator.defineJSON() + .add("processDefinitionKey", "activitiAdhoc") + .add("variables", + JsonBodyGenerator.defineJSON() + .add("bpm_assignee", assignee.getUsername()) + .add("bpm_sendEMailNotifications", false) + .add("bpm_workflowPriority", "test").build() + ).build(); + + addedProcess = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcessWithBody(postJson); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(String.format(RestErrorModel.UNSUPPORTED_TYPE, "test")) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/AddProcessSanityTests.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/AddProcessSanityTests.java new file mode 100644 index 000000000..e43e59203 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/AddProcessSanityTests.java @@ -0,0 +1,44 @@ +package org.alfresco.rest.workflow.processes; + +import org.alfresco.dataprep.CMISUtil.Priority; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestProcessModelsCollection; +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.Test; + +/** + * Created by Claudia Agache on 10/18/2016. + */ +public class AddProcessSanityTests extends RestTest +{ + private UserModel userWhoStartsProcess, assignee; + private RestProcessModel addedProcess; + private RestProcessModelsCollection processes; + + @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW, + TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Verify non network user is able to start new process using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) + public void nonNetworkUserStartsNewProcess() throws JsonToModelConversionException, Exception + { + userWhoStartsProcess = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + + addedProcess = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + addedProcess.assertThat().field("id").is(addedProcess.getId()) + .and().field("startUserId").is(addedProcess.getStartUserId()); + + processes = restClient.withWorkflowAPI().getProcesses(); + restClient.assertStatusCodeIs(HttpStatus.OK); + processes.assertThat().entriesListContains("id", addedProcess.getId()); + + } + +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/DeleteProcessCoreTests.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/DeleteProcessCoreTests.java new file mode 100644 index 000000000..26253d2b1 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/DeleteProcessCoreTests.java @@ -0,0 +1,69 @@ +package org.alfresco.rest.workflow.processes; + +import org.alfresco.dataprep.CMISUtil.Priority; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class DeleteProcessCoreTests extends RestTest +{ + private UserModel userWhoAddsProcess, assignee; + private RestProcessModel process; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + userWhoAddsProcess = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW, + TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify admin user is able to delete a process started by another user.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void deleteProcessByAdminUser() throws Exception + { + process = restClient.authenticateUser(userWhoAddsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.authenticateUser(dataUser.getAdminUser()) + .withWorkflowAPI().usingProcess(process).deleteProcess(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().getProcesses() + .assertThat().entriesListDoesNotContain("id", process.getId()); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW, + TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify User is not able to delete process with invalid id") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void deleteProcessWithInvalidId() throws Exception + { + process = restClient.authenticateUser(userWhoAddsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + process.setId("00001"); + restClient.withWorkflowAPI().usingProcess(process).deleteProcess(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "00001")); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW, + TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify User is not able to delete process with empty id") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void deleteProcessWithEmptyId() throws Exception + { + process = restClient.authenticateUser(userWhoAddsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + process.setId(""); + restClient.withWorkflowAPI().usingProcess(process).deleteProcess(); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) + .assertLastError().containsSummary(RestErrorModel.DELETE_EMPTY_ARGUMENT); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/DeleteProcessFullTests.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/DeleteProcessFullTests.java new file mode 100644 index 000000000..e1c295f72 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/DeleteProcessFullTests.java @@ -0,0 +1,52 @@ +package org.alfresco.rest.workflow.processes; + +import org.alfresco.dataprep.CMISUtil.Priority; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestProcessModel; +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 Cristina Axinte + * + */ +public class DeleteProcessFullTests extends RestTest +{ + private UserModel userWhoAddsProcess, assignee; + private RestProcessModel process; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + userWhoAddsProcess = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify user is NOT able to delete process started by him twice using REST API and status code is NOT FOUND (404)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void deleteProcessByUserWhoStartedProcessTwice() throws Exception + { + process = restClient.authenticateUser(userWhoAddsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.withWorkflowAPI().usingProcess(process).deleteProcess(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withWorkflowAPI().usingProcess(process).deleteProcess(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.ENTITY_WAS_NOT_FOUND, process.getId())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + + restClient.withWorkflowAPI().getProcesses().assertThat().entriesListDoesNotContain("id", process.getId()); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java new file mode 100644 index 000000000..9478b9d0e --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java @@ -0,0 +1,69 @@ +package org.alfresco.rest.workflow.processes; + +import org.alfresco.dataprep.CMISUtil.Priority; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestProcessModel; +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; + +/** + * Created by Claudia Agache on 10/12/2016. + */ +public class DeleteProcessSanityTests extends RestTest +{ + private UserModel userWhoAddsProcess, assignee, anotherUser; + private RestProcessModel process; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + userWhoAddsProcess = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + anotherUser = dataUser.createRandomTestUser(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Verify User is able to delete process started by him using REST API and status code is OK (204)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) + public void deleteProcessByUserWhoStartedProcess() throws Exception + { + process = restClient.authenticateUser(userWhoAddsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.withWorkflowAPI().usingProcess(process).deleteProcess(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withWorkflowAPI().getProcesses().assertThat().entriesListDoesNotContain("id", process.getId()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Verify User is able to delete process assigned to him using REST API and status code is OK (204)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) + public void deleteProcessByAssignedUser() throws Exception + { + process = restClient.authenticateUser(userWhoAddsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(process).deleteProcess(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withWorkflowAPI().getProcesses().assertThat().entriesListDoesNotContain("id", process.getId()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Verify User that is not involved in a process is not authorized to delete it using REST API and status code is 403") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) + public void deleteProcessByAnotherUser() throws Exception + { + process = restClient.authenticateUser(userWhoAddsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(anotherUser).withWorkflowAPI().usingProcess(process).deleteProcess(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("user is not allowed to access information about process"); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/GetProcessCoreTests.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/GetProcessCoreTests.java new file mode 100644 index 000000000..418e4b8a0 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/GetProcessCoreTests.java @@ -0,0 +1,44 @@ +package org.alfresco.rest.workflow.processes; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.apache.commons.lang3.RandomStringUtils; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class GetProcessCoreTests extends RestTest +{ + private UserModel userWhoStartsProcess, assignee; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + userWhoStartsProcess = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify that using invalid process ID returns status code 404") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION}) + public void invalidProcessIdTest() throws Exception + { + RestProcessModel newProcess = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.High); + String processId = RandomStringUtils.randomAlphanumeric(10); + newProcess.setId(processId); + restClient.authenticateUser(dataUser.getAdminUser()) + .withWorkflowAPI().usingProcess(newProcess).getProcess(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, processId)) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } +} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/GetProcessFullTests.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/GetProcessFullTests.java new file mode 100644 index 000000000..01c11e8a2 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/GetProcessFullTests.java @@ -0,0 +1,85 @@ +package org.alfresco.rest.workflow.processes; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestProcessDefinitionModel; +import org.alfresco.rest.model.RestProcessModel; +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 Cristina Axinte + * + */ +public class GetProcessFullTests extends RestTest +{ + private UserModel userWhoStartsProcess, assignee; + private RestProcessModel addedProcess, process; + private RestProcessDefinitionModel adhocProcessDefinition; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + userWhoStartsProcess = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + addedProcess = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.High); + adhocProcessDefinition = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getAllProcessDefinitions().getProcessDefinitionByKey("activitiAdhoc"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify user is able to get the process with properties parameter applied using REST API") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void getProcessWithPropertiesParameter() throws Exception + { + process = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingParams("properties=startUserId,id").usingProcess(addedProcess).getProcess(); + restClient.assertStatusCodeIs(HttpStatus.OK); + process.assertThat().fieldsCount().is(2) + .and().field("startUserId").is(addedProcess.getStartUserId()) + .and().field("id").is(addedProcess.getId()) + .and().field("processDefinitionKey").isNull(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify user is able to get a process that was deleted, but it has 'deleted through REST API call' deleteReason") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void getDeletedProcess() throws Exception + { + addedProcess = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.High); + + process = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingProcess(addedProcess).getProcess(); + restClient.assertStatusCodeIs(HttpStatus.OK); + process.assertThat() + .field("processDefinitionId").is(adhocProcessDefinition.getId()) + .and().field("startUserId").is(addedProcess.getStartUserId()) + .and().field("startActivityId").is("start") + .and().field("startedAt").isNotEmpty() + .and().field("id").is(addedProcess.getId()) + .and().field("completed").is(false) + .and().field("processDefinitionKey").is("activitiAdhoc"); + + restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingProcess(addedProcess).deleteProcess(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + process = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingProcess(addedProcess).getProcess(); + restClient.assertStatusCodeIs(HttpStatus.OK); + process.assertThat() + .field("processDefinitionId").is(adhocProcessDefinition.getId()) + .and().field("durationInMs").isNotNull() + .and().field("startUserId").is(addedProcess.getStartUserId()) + .and().field("startActivityId").is("start") + .and().field("endedAt").isNotEmpty() + .and().field("startedAt").isNotEmpty() + .and().field("id").is(addedProcess.getId()) + .and().field("completed").is(true) + .and().field("deleteReason").is("deleted through REST API call") + .and().field("processDefinitionKey").is("activitiAdhoc"); + + restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().assertThat().entriesListDoesNotContain("id", process.getId()); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/GetProcessSanityTests.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/GetProcessSanityTests.java new file mode 100644 index 000000000..b4288002a --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/GetProcessSanityTests.java @@ -0,0 +1,62 @@ +package org.alfresco.rest.workflow.processes; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestProcessModel; +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; + +/** + * Created by Claudia Agache on 10/19/2016. + */ +public class GetProcessSanityTests extends RestTest +{ + private UserModel userWhoStartsProcess, assignee; + private RestProcessModel addedProcess, process; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + userWhoStartsProcess = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + addedProcess = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.High); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Verify user is able to get the process started by him using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) + public void getProcessByOwner() throws Exception + { + process = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingProcess(addedProcess).getProcess(); + restClient.assertStatusCodeIs(HttpStatus.OK); + process.assertThat().field("id").is(addedProcess.getId()) + .and().field("startUserId").is(addedProcess.getStartUserId()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Verify user is able to get the process assigned to him using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) + public void getProcessByAssignee() throws Exception + { + process = restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(addedProcess).getProcess(); + restClient.assertStatusCodeIs(HttpStatus.OK); + process.assertThat().field("id").is(addedProcess.getId()) + .and().field("startUserId").is(addedProcess.getStartUserId()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Verify admin is able to get any process using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) + public void getProcessByAdmin() throws Exception + { + process = restClient.authenticateUser(dataUser.getAdminUser()).withWorkflowAPI().usingProcess(addedProcess).getProcess(); + restClient.assertStatusCodeIs(HttpStatus.OK); + process.assertThat().field("id").is(addedProcess.getId()) + .and().field("startUserId").is(addedProcess.getStartUserId()); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/GetProcessesCoreTests.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/GetProcessesCoreTests.java new file mode 100644 index 000000000..5a5c5fd5d --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/GetProcessesCoreTests.java @@ -0,0 +1,80 @@ +package org.alfresco.rest.workflow.processes; + +import java.util.List; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestProcessDefinitionModel; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestProcessModelsCollection; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.ProcessModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TaskModel; +import org.alfresco.utility.model.TestGroup; +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 Cristina Axinte + * + */ +public class GetProcessesCoreTests extends RestTest +{ + private FileModel document; + private SiteModel siteModel; + private UserModel adminUser, userWhoStartsTask, assignee ; + private TaskModel task1, task2; + private ProcessModel process3; + private RestProcessDefinitionModel adhocProcessDefinition; + private RestProcessDefinitionModel activitiReviewProcessDefinition; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userWhoStartsTask = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + task1 = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); + task2 = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(adminUser); + process3 = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createSingleReviewerTaskAndAssignTo(assignee); + adhocProcessDefinition = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getAllProcessDefinitions().getProcessDefinitionByKey("activitiAdhoc"); + activitiReviewProcessDefinition = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getAllProcessDefinitions().getProcessDefinitionByKey("activitiReview"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify user gets all processes started by him ordered descending by id") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void getProcessesOrderedByIdDESC() throws Exception + { + RestProcessModelsCollection processes = restClient.authenticateUser(userWhoStartsTask).withParams("orderBy=id DESC") + .withWorkflowAPI().getProcesses(); + restClient.assertStatusCodeIs(HttpStatus.OK); + processes.assertThat().entriesListIsNotEmpty(); + List processesList = processes.getEntries(); + processesList.get(0).onModel().assertThat().field("id").is(process3.getId()); + processesList.get(1).onModel().assertThat().field("id").is(task2.getProcessId()); + processesList.get(2).onModel().assertThat().field("id").is(task1.getProcessId()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify user gets processes that matches a where clause") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void getProcessesWithWhereClauseAsParameter() throws JsonToModelConversionException, Exception + { + RestProcessModelsCollection processes = restClient.authenticateUser(userWhoStartsTask).where("processDefinitionKey='activitiReview'") + .withWorkflowAPI().getProcesses(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + processes.assertThat().entriesListIsNotEmpty().and().entriesListContains("processDefinitionId", activitiReviewProcessDefinition.getId()) + .and().entriesListDoesNotContain("processDefinitionId", adhocProcessDefinition.getId()); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/GetProcessesFullTests.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/GetProcessesFullTests.java new file mode 100644 index 000000000..c4595920e --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/GetProcessesFullTests.java @@ -0,0 +1,160 @@ +package org.alfresco.rest.workflow.processes; + +import java.util.List; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestProcessModelsCollection; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.ProcessModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TaskModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * + * @author Cristina Axinte + * + */ +public class GetProcessesFullTests extends RestTest +{ + private FileModel document; + private SiteModel siteModel; + private UserModel adminUser, userWhoStartsTask, assignee; + private TaskModel task1, task2; + private ProcessModel process3; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userWhoStartsTask = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + task1 = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); + task2 = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(adminUser); + process3 = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createSingleReviewerTaskAndAssignTo(assignee); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify user gets processes when skipCount parameter is applied") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void getProcessesWithSkipCountParameter() throws Exception + { + RestProcessModelsCollection processes = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getProcesses(); + restClient.assertStatusCodeIs(HttpStatus.OK); + processes.assertThat().paginationField("count").is("3"); + RestProcessModel process1 = processes.getEntries().get(0).onModel(); + RestProcessModel process2 = processes.getEntries().get(1).onModel(); + RestProcessModel process3 = processes.getEntries().get(2).onModel(); + + processes = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingParams("skipCount=2").getProcesses(); + restClient.assertStatusCodeIs(HttpStatus.OK); + processes.assertThat().paginationField("count").is("1"); + processes.assertThat().paginationField("skipCount").is("2"); + processes.assertThat().entriesListDoesNotContain("id", process1.getId()); + processes.assertThat().entriesListDoesNotContain("id", process2.getId()); + processes.getEntries().get(0).onModel().assertThat().field("id").is(process3.getId()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify user gets processes when maxItems parameter is applied") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void getProcessesWithMaxItemsParameter() throws Exception + { + RestProcessModelsCollection processes = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getProcesses(); + restClient.assertStatusCodeIs(HttpStatus.OK); + processes.assertThat().paginationField("count").is("3"); + RestProcessModel process1 = processes.getEntries().get(0).onModel(); + RestProcessModel process2 = processes.getEntries().get(1).onModel(); + RestProcessModel process3 = processes.getEntries().get(2).onModel(); + + processes = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingParams("maxItems=2").getProcesses(); + restClient.assertStatusCodeIs(HttpStatus.OK); + processes.assertThat().paginationField("count").is("2"); + processes.assertThat().paginationField("maxItems").is("2"); + processes.assertThat().entriesListDoesNotContain("id", process3.getId()); + processes.getEntries().get(0).onModel().assertThat().field("id").is(process1.getId()); + processes.getEntries().get(1).onModel().assertThat().field("id").is(process2.getId()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify user gets processes when properties parameter is applied") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void getProcessesWithPropertiesParameter() throws Exception + { + RestProcessModelsCollection processes = restClient.authenticateUser(userWhoStartsTask).withParams("properties=id") + .withWorkflowAPI().getProcesses(); + restClient.assertStatusCodeIs(HttpStatus.OK); + List processesList = processes.getEntries(); + processesList.get(0).onModel().assertThat().fieldsCount().is(1) + .and().field("id").isNotEmpty() + .and().field("processDefinitionId").isNull() + .and().field("startUserId").isNull(); + processesList.get(1).onModel().assertThat().fieldsCount().is(1) + .and().field("id").isNotEmpty() + .and().field("processDefinitionId").isNull() + .and().field("startUserId").isNull(); + processesList.get(2).onModel().assertThat().fieldsCount().is(1) + .and().field("id").isNotEmpty() + .and().field("processDefinitionId").isNull() + .and().field("startUserId").isNull(); + processes.assertThat().entriesListIsNotEmpty() + .and().entriesListContains("id", process3.getId()) + .and().entriesListContains("id", task2.getProcessId()) + .and().entriesListContains("id", task1.getProcessId()); + } + + @Bug(id = "REPO-1958") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify user cannot get processes when using an invalid orderBy parameter") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void getProcessesWithInvalidOrderByParameter() throws Exception + { + restClient.authenticateUser(userWhoStartsTask).withParams("orderBy=test") + .withWorkflowAPI().getProcesses(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(String.format(RestErrorModel.INVALID_ORDERBY, "test", "processDefinitionId, startUserId, startActivityId,startedAt, id, completed, processDefinitionKey")) + .containsSummary(String.format(RestErrorModel.INVALID_ORDERBY, "test", "processDefinitionId, startUserId, startActivityId,startedAt, id, completed, processDefinitionKey")) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify user cannot get processes when using an invalid parameter in where clause") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void getProcessesWithInvalidWhereParameter() throws Exception + { + restClient.authenticateUser(userWhoStartsTask).where("startUserIdd='" + userWhoStartsTask.getUsername() + "'") + .withWorkflowAPI().getProcesses(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(RestErrorModel.INVALID_PROPERTY_ERRORKEY) + .containsSummary(String.format(RestErrorModel.PROPERTY_IS_NOT_SUPPORTED_EQUALS, "startUserIdd", userWhoStartsTask.getUsername())) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify user cannot get processes when using an invalid where clause expression") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void getProcessesWithInvalidWhereClauseExpression() throws Exception + { + restClient.authenticateUser(userWhoStartsTask).where("startUserId AND '" + userWhoStartsTask.getUsername() + "'") + .withWorkflowAPI().getProcesses(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(RestErrorModel.INVALID_QUERY_ERRORKEY) + .containsSummary(String.format(RestErrorModel.INVALID_WHERE_QUERY, "(startUserId AND '" + userWhoStartsTask.getUsername() + "')")) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java new file mode 100644 index 000000000..b64d0d141 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java @@ -0,0 +1,78 @@ +package org.alfresco.rest.workflow.processes; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestProcessModelsCollection; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TaskModel; +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; + +/** + * Created by Claudia Agache on 10/11/2016. + */ +public class GetProcessesSanityTests extends RestTest +{ + private FileModel document; + private SiteModel siteModel; + private UserModel userWhoStartsTask, assignee, anotherUser; + private TaskModel task; + private RestProcessModelsCollection allProcesses; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + userWhoStartsTask = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + anotherUser = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + task = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Verify User gets all processes started by him using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) + public void getProcessesByUserWhoStartedProcess() throws Exception + { + allProcesses = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getProcesses(); + restClient.assertStatusCodeIs(HttpStatus.OK); + allProcesses.assertThat().entriesListContains("id", task.getProcessId()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Verify User gets all processes assigned to him using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) + public void getProcessesByAssignedUser() throws Exception + { + allProcesses = restClient.authenticateUser(assignee).withWorkflowAPI().getProcesses(); + restClient.assertStatusCodeIs(HttpStatus.OK); + allProcesses.assertThat().entriesListContains("id", task.getProcessId()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Verify User that is not involved in a process can not get that process using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) + public void getProcessesByAnotherUser() throws Exception + { + allProcesses = restClient.authenticateUser(anotherUser).withWorkflowAPI().getProcesses(); + restClient.assertStatusCodeIs(HttpStatus.OK); + allProcesses.assertThat().entriesListDoesNotContain("id", task.getProcessId()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Verify Admin gets all processes, even if he isn't involved in a process, using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) + public void getProcessesByAdmin() throws Exception + { + allProcesses = restClient.authenticateUser(dataUser.getAdminUser()).withWorkflowAPI().getProcesses(); + restClient.assertStatusCodeIs(HttpStatus.OK); + allProcesses.assertThat().entriesListContains("id", task.getProcessId()); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemCoreTests.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemCoreTests.java new file mode 100644 index 000000000..9eaa02099 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemCoreTests.java @@ -0,0 +1,181 @@ +package org.alfresco.rest.workflow.processes.items; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestItemModel; +import org.alfresco.rest.model.RestItemModelsCollection; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestProcessModelsCollection; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class AddProcessItemCoreTests extends RestTest +{ + private FileModel document, document2; + private SiteModel siteModel; + private UserModel userWhoStartsProcess, assignee, adminUser, anotherUser; + private RestProcessModel processModel; + private RestItemModel processItem; + private RestItemModelsCollection processItems; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userWhoStartsProcess = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + document2 = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Add process item using by the user who started the process.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void addProcessItemByUserThatStartedTheProcess() throws Exception + { + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); + + restClient.assertStatusCodeIs(HttpStatus.CREATED); + processItem.assertThat().field("createdAt").isNotEmpty().and().field("size").is("19").and().field("createdBy").is(adminUser.getUsername()).and() + .field("modifiedAt").isNotEmpty().and().field("name").is(document.getName()).and().field("modifiedBy").is(userWhoStartsProcess.getUsername()) + .and().field("id").isNotEmpty().and().field("mimeType").is(document.getFileType().mimeType); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Add multiple process items using by the user who started the process.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void addMultipleProcessItemsByUserThatStartedTheProcess() throws Exception + { + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processItems = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItems(document, document2); + + restClient.assertStatusCodeIs(HttpStatus.CREATED); + processItems.getEntries().get(0).onModel().assertThat() + .field("createdAt").isNotEmpty().and() + .field("size").is("19").and() + .field("createdBy").is(adminUser.getUsername()).and() + .field("modifiedAt").isNotEmpty().and() + .field("name").is(document.getName()).and() + .field("modifiedBy").is(userWhoStartsProcess.getUsername()).and() + .field("id").isNotEmpty().and() + .field("mimeType").is(document.getFileType().mimeType); + processItems.getEntries().get(1).onModel().assertThat() + .field("createdAt").isNotEmpty().and() + .field("size").is("19").and() + .field("createdBy").is(adminUser.getUsername()).and() + .field("modifiedAt").isNotEmpty().and() + .field("name").is(document2.getName()).and() + .field("modifiedBy").is(userWhoStartsProcess.getUsername()).and() + .field("id").isNotEmpty().and() + .field("mimeType").is(document2.getFileType().mimeType); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Add process item by a random user.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void addProcessItemByAnyUser() throws Exception + { + anotherUser = dataUser.createRandomTestUser(); + + document2 = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + processModel = restClient.authenticateUser(adminUser).withParams("maxItems=1").withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processItem = restClient.authenticateUser(anotherUser).withWorkflowAPI().usingProcess(processModel).addProcessItem(document2); + + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsSummary(String.format(RestErrorModel.ACCESS_INFORMATION_NOT_ALLOWED, processModel.getId())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Add multiple process item by a random user.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void addMultipleProcessItemByAnyUser() throws Exception + { + anotherUser = dataUser.createRandomTestUser(); + + document2 = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + processModel = restClient.authenticateUser(adminUser).withParams("maxItems=1").withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processItems = restClient.authenticateUser(anotherUser).withWorkflowAPI().usingProcess(processModel) + .addProcessItems(document2, document); + + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsSummary(String.format(RestErrorModel.ACCESS_INFORMATION_NOT_ALLOWED, processModel.getId())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding process item is falling in case of invalid process id is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void failedAddingProcessItemIfInvalidProcessIdIsProvided() throws Exception + { + RestProcessModelsCollection processes = restClient.authenticateUser(adminUser).withParams("maxItems=1").withWorkflowAPI().getProcesses(); + processModel = processes.assertThat().entriesListIsNotEmpty().when().getOneRandomEntry().onModel(); + FileModel testDocument = dataContent.usingAdmin().usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + + processModel.setId("invalidProcessId"); + processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(testDocument); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidProcessId")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding multiple process items is falling in case of invalid process id is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void failedAddingMultipleProcessItemsIfInvalidProcessIdIsProvided() throws Exception + { + RestProcessModelsCollection processes = restClient.authenticateUser(adminUser).withParams("maxItems=1").withWorkflowAPI().getProcesses(); + processModel = processes.assertThat().entriesListIsNotEmpty().when().getOneRandomEntry().onModel(); + FileModel testDocument = dataContent.usingAdmin().usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + + processModel.setId("invalidProcessId"); + processItems = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItems(testDocument, document); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidProcessId")); + } + + @Bug(id = "REPO-1937") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding process item is falling in case of invalid body item is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void failedAddingProcessItemIfInvalidItemBodyIsProvided() throws Exception + { + document.setNodeRef("invalidNodeRef"); + processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidId")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding multiple process items is falling in case of empty body item value is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void failedAddingMultipleProcessItemIfEmptyItemBodyIsProvided() throws Exception + { + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + document.setNodeRef(""); + processItems = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItems(document, document2); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.REQUIRED_TO_ADD, "itemId")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding process item is falling in case of incomplete body (empty) is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void failedAddingProcessItemIfIncompleteBodyIsProvided() throws Exception + { + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{}", "processes/{processId}/items", processModel.getId()); + restClient.processModel(RestItemModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.REQUIRED_TO_ADD, "itemId")); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemFullTests.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemFullTests.java new file mode 100644 index 000000000..202fcf554 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemFullTests.java @@ -0,0 +1,131 @@ +package org.alfresco.rest.workflow.processes.items; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestItemModel; +import org.alfresco.rest.model.RestItemModelsCollection; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.ProcessModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class AddProcessItemFullTests extends RestTest +{ + private FileModel document, document2; + private SiteModel siteModel; + private UserModel userWhoStartsProcess, assignee, adminUser; + private ProcessModel processModel; + private RestItemModel processItem; + private RestItemModelsCollection processItems; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userWhoStartsProcess = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + document2 = dataContent.usingSite(siteModel).createContent(DocumentType.MSPOWERPOINT); + dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding multiple process items is falling in case of empty process id is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void failedAddingMultipleProcessItemsIfEmptyProcessIdIsProvided() throws Exception + { + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + FileModel testDocument = dataContent.usingAdmin().usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + + processModel.setId(""); + processItems = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItems(testDocument, document); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_WAS_NOT_FOUND, "")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding process items is falling in case of empty process id is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void failedAddingProcessItemsIfEmptyProcessIdIsProvided() throws Exception + { + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + FileModel testDocument = dataContent.usingAdmin().usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + + processModel.setId(""); + processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(testDocument); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_WAS_NOT_FOUND, "")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding process item is falling in case of empty body item value is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void failedAddingProcessItemIfEmptyItemBodyIsProvided() throws Exception + { + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + document.setNodeRef(""); + processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.REQUIRED_TO_ADD, "itemId")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding multiple process items is falling in case of empty body item value is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void failedAddingMultipleProcessItemsIfEmptyItemBodyIsProvided() throws Exception + { + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + document.setNodeRef(""); + + processItems = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItems(document, document2); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.REQUIRED_TO_ADD, "itemId")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Add a new process item, update the item and then delete.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void createDeleteCreateMultipleProcessItems() throws Exception + { + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + document2 = dataContent.usingAdmin().usingSite(siteModel).createContent(DocumentType.MSPOWERPOINT); + processItems = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItems(document, document2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.withWorkflowAPI().usingProcess(processModel).deleteProcessItem(processItems.getEntries().get(0).onModel()); + + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems() + .assertThat().entriesListDoesNotContain("name", processItems.getEntries().get(0).onModel().getName()); + + processItems = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItems(document); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Add a new process item, delete the item and create it again.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void createDeleteCreateProcessItem() throws Exception + { + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem( document2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.withWorkflowAPI().usingProcess(processModel).deleteProcessItem(processItem); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems() + .assertThat().entriesListDoesNotContain("name", processItem.getName()); + + processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems() + .assertThat().entriesListContains("name", processItem.getName()); + } + +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemSanityTests.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemSanityTests.java new file mode 100644 index 000000000..797936ceb --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemSanityTests.java @@ -0,0 +1,175 @@ +package org.alfresco.rest.workflow.processes.items; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestItemModel; +import org.alfresco.rest.model.RestItemModelsCollection; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FileType; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +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 AddProcessItemSanityTests extends RestTest +{ + private FileModel document, document2; + private SiteModel siteModel; + private UserModel userWhoStartsTask, assignee, adminUser; + private RestProcessModel processModel; + private RestItemModel processItem; + private RestItemModelsCollection processItems; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userWhoStartsTask = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Create non-existing process item") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY}) + public void addProcessItem() throws JsonToModelConversionException, Exception + { + document2 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file content"); + dataContent.usingSite(siteModel).createContent(document2); + + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + processItem.assertThat().field("createdAt").isNotEmpty() + .and().field("size").is(document2.getContent().length()) + .and().field("createdBy").is(adminUser.getUsername()) + .and().field("modifiedAt").isNotEmpty() + .and().field("name").is(document2.getName()) + .and().field("modifiedBy").is(adminUser.getUsername()) + .and().field("id").isNotEmpty() + .and().field("mimeType").is(document2.getFileType().mimeType); + + restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems() + .assertThat().entriesListContains("id", processItem.getId()); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Create non-existing process item") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY}) + public void addMultipleProcessItem() throws JsonToModelConversionException, Exception + { + document2 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file content"); + dataContent.usingSite(siteModel).createContent(document2); + document = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file content"); + dataContent.usingSite(siteModel).createContent(document); + + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processItems = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItems(document2, document); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + processItems.getEntries().get(0).onModel() + .assertThat().field("createdAt").isNotEmpty() + .and().field("size").is(document2.getContent().length()) + .and().field("createdBy").is(adminUser.getUsername()) + .and().field("modifiedAt").isNotEmpty() + .and().field("name").is(document2.getName()) + .and().field("modifiedBy").is(adminUser.getUsername()) + .and().field("id").isNotEmpty() + .and().field("mimeType").is(document2.getFileType().mimeType); + + processItems.getEntries().get(1).onModel() + .assertThat().field("createdAt").isNotEmpty() + .and().field("size").is(document.getContent().length()) + .and().field("createdBy").is(adminUser.getUsername()) + .and().field("modifiedAt").isNotEmpty() + .and().field("name").is(document.getName()) + .and().field("modifiedBy").is(adminUser.getUsername()) + .and().field("id").isNotEmpty() + .and().field("mimeType").is(document.getFileType().mimeType); + + restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems() + .assertThat().entriesListContains("id", processItems.getEntries().get(0).onModel().getId()) + .assertThat().entriesListContains("id", processItems.getEntries().get(1).onModel().getId()); + } + + @Bug(id= "REPO-1927") + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Add process item that already exists") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY}) + public void addProcessItemThatAlreadyExists() throws JsonToModelConversionException, Exception + { + document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + processItem.assertThat().field("createdAt").isNotEmpty() + .and().field("size").is("19") + .and().field("createdBy").is(adminUser.getUsername()) + .and().field("modifiedAt").isNotEmpty() + .and().field("name").is(document2.getName()) + .and().field("modifiedBy").is(adminUser.getUsername()) + .and().field("id").isNotEmpty() + .and().field("mimeType").is(document2.getFileType().mimeType); + + restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems() + .assertThat().entriesListContains("id", processItem.getId()) + .and().entriesListContains("name", document2.getName()); + restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document2); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + } + + @Bug(id= "REPO-1927") + @TestRail(section = {TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Add process item that already exists") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY}) + public void addMultipleProcessItemThatAlreadyExists() throws JsonToModelConversionException, Exception + { + document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + document = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processItems = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItems(document2, document); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + processItems.getEntries().get(0).onModel() + .assertThat().field("createdAt").isNotEmpty() + .and().field("size").is("19") + .and().field("createdBy").is(adminUser.getUsername()) + .and().field("modifiedAt").isNotEmpty() + .and().field("name").is(document2.getName()) + .and().field("modifiedBy").is(adminUser.getUsername()) + .and().field("id").isNotEmpty() + .and().field("mimeType").is(document2.getFileType().mimeType); + + processItems.getEntries().get(1).onModel() + .assertThat().field("createdAt").isNotEmpty() + .and().field("size").is("19") + .and().field("createdBy").is(adminUser.getUsername()) + .and().field("modifiedAt").isNotEmpty() + .and().field("name").is(document.getName()) + .and().field("modifiedBy").is(adminUser.getUsername()) + .and().field("id").isNotEmpty() + .and().field("mimeType").is(document.getFileType().mimeType); + + restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems() + .assertThat().entriesListContains("id", processItems.getEntries().get(0).onModel().getId()) + .and().entriesListContains("name", document2.getName()) + .assertThat().entriesListContains("id", processItems.getEntries().get(1).onModel().getId()) + .and().entriesListContains("name", document.getName()); + + restClient.withWorkflowAPI().usingProcess(processModel).addProcessItems(document2, document); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/items/DeleteProcessItemCoreTests.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/items/DeleteProcessItemCoreTests.java new file mode 100644 index 000000000..ca7a5a308 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/items/DeleteProcessItemCoreTests.java @@ -0,0 +1,85 @@ +package org.alfresco.rest.workflow.processes.items; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestItemModel; +import org.alfresco.rest.model.RestItemModelsCollection; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.ProcessModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class DeleteProcessItemCoreTests extends RestTest +{ + private FileModel document, secondDoc; + private SiteModel siteModel; + private UserModel userWhoStartsTask, assignee; + private RestProcessModel restProcessModel; + private ProcessModel processModel; + private RestItemModelsCollection items; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + userWhoStartsTask = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + processModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document) + .createSingleReviewerTaskAndAssignTo(assignee); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Delete process item with invalid id") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void deleteProcessItemWithInvalidItemId() throws Exception + { + restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() + .getProcesses().getProcessModelByProcessDefId(processModel.getId()); + secondDoc = dataContent.usingUser(userWhoStartsTask).usingSite(siteModel).createContent(DocumentType.MSWORD); + RestItemModel processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(secondDoc); + processItem.setId("invalid-id"); + restClient.withWorkflowAPI().usingProcess(processModel).deleteProcessItem(processItem); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.PROCESS_ENTITY_NOT_FOUND, "invalid-id")); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Delete process item with empty id") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void deleteProcessItemWithEmptyItemId() throws Exception + { + restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() + .getProcesses().getProcessModelByProcessDefId(processModel.getId()); + secondDoc = dataContent.usingUser(userWhoStartsTask).usingSite(siteModel).createContent(DocumentType.MSWORD); + RestItemModel processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(secondDoc); + processItem.setId(""); + restClient.withWorkflowAPI().usingProcess(processModel).deleteProcessItem(processItem); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) + .assertLastError().containsSummary(String.format(RestErrorModel.DELETE_EMPTY_ARGUMENT)); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Delete process item twice") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void deleteProcessItemTwice() throws Exception + { + restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() + .getProcesses().getProcessModelByProcessDefId(processModel.getId()); + items = restClient.withWorkflowAPI().usingProcess(restProcessModel).getProcessItems(); + RestItemModel processItem = items.getEntries().get(0); + restClient.withWorkflowAPI().usingProcess(processModel).deleteProcessItem(processItem.onModel()); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingProcess(processModel).deleteProcessItem(processItem.onModel()); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.PROCESS_ENTITY_NOT_FOUND, processItem.onModel().getId())); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/items/DeleteProcessItemFullTests.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/items/DeleteProcessItemFullTests.java new file mode 100644 index 000000000..3afd2e31c --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/items/DeleteProcessItemFullTests.java @@ -0,0 +1,215 @@ +package org.alfresco.rest.workflow.processes.items; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.dataprep.CMISUtil.Priority; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.EmptyRestModelCollectionException; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestItemModel; +import org.alfresco.rest.model.RestItemModelsCollection; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.ProcessModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class DeleteProcessItemFullTests extends RestTest +{ + private FileModel document, document2; + private SiteModel siteModel; + private UserModel userWhoStartsProcess, assignee, adminUser, anotherUser; + private ProcessModel processModel; + private RestItemModelsCollection items; + private RestItemModel processItem; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userWhoStartsProcess = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userWhoStartsProcess).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Try to delete existing process item using empty processId") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void deleteProcessItemUsingEmptyProcessId() throws Exception + { + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI() + .addProcess("activitiAdhoc", assignee, false, Priority.Normal); + document2 = dataContent.usingAdmin().usingSite(siteModel).createContent(DocumentType.MSPOWERPOINT); + processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + processModel.setId(""); + restClient.withWorkflowAPI().usingProcess(processModel).deleteProcessItem(processItem); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "The entity with id: ")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Add a new process item, update the item and then delete.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void createUpdateDeleteProcessItem() throws Exception + { + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI() + .addProcess("activitiAdhoc", assignee, false, Priority.Normal); + document2 = dataContent.usingAdmin().usingSite(siteModel).createContent(DocumentType.MSPOWERPOINT); + processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + processItem.setName("newItemName"); + processItem.assertThat().field("name").is("newItemName"); + + restClient.withWorkflowAPI().usingProcess(processModel).deleteProcessItem(processItem); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems() + .assertThat().entriesListDoesNotContain("name", processItem.getName()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Delete process item using any user.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void deleteProcessItemByAnyUser() throws Exception + { + anotherUser = dataUser.createRandomTestUser(); + + document2 = dataContent.usingAdmin().usingSite(siteModel).createContent(DocumentType.HTML); + processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(anotherUser).withWorkflowAPI().usingProcess(processModel) + .deleteProcessItem(processItem); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError() + .containsSummary(String.format(RestErrorModel.ACCESS_INFORMATION_NOT_ALLOWED, processModel.getId())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .containsErrorKey(String.format(RestErrorModel.ACCESS_INFORMATION_NOT_ALLOWED, processModel.getId())) + .stackTraceIs(RestErrorModel.STACKTRACE);; + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Delete process item with admin.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void deleteProcessItemWithAdmin() throws Exception + { + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI() + .addProcess("activitiAdhoc", assignee, false, Priority.Normal); + + document2 = dataContent.usingAdmin().usingSite(siteModel).createContent(DocumentType.HTML); + processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(adminUser).withWorkflowAPI().usingProcess(processModel) + .deleteProcessItem(processItem); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() + .assertThat().entriesListDoesNotContain("name", processItem.getName()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Delete process item by the user who is involved in the process.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void deleteProcessItemByUserInvolvedInTheProcess() throws Exception + { + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI() + .addProcess("activitiAdhoc", assignee, false, Priority.Normal); + + processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(processModel) + .deleteProcessItem(processItem); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() + .assertThat().entriesListDoesNotContain("name", processItem.getName()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Delete process item by the user who started the process.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void deleteProcessItemByUserThatStartedTheProcess() throws Exception + { + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI() + .addProcess("activitiAdhoc", assignee, false, Priority.Normal); + processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingProcess(processModel) + .deleteProcessItem(processItem); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() + .assertThat().entriesListDoesNotContain("name", processItem.getName()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Delete process item for a deleted process.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void deleteProcessItemsForDeletedProcess() throws Exception + { + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI() + .addProcess("activitiAdhoc", assignee, false, Priority.Normal); + processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.withWorkflowAPI().usingProcess(processModel).deleteProcess(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withWorkflowAPI().usingProcess(processModel).deleteProcessItem(processItem); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, processModel.getId())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Delete process item by inexistent user.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void deleteProcessItemByInexistentUser() throws Exception + { + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI() + .addProcess("activitiAdhoc", assignee, false, Priority.Normal); + processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(UserModel.getRandomUserModel()).withWorkflowAPI().usingProcess(processModel) + .deleteProcessItem(processItem); + + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Delete process item for process without items.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION}, + expectedExceptions = EmptyRestModelCollectionException.class) + public void deleteProcessItemsForProcessWithoutItems() throws Exception + { + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI() + .addProcess("activitiAdhoc", assignee, false, Priority.Normal); + + items = restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems(); + restClient.assertStatusCodeIs(HttpStatus.OK); + items.assertThat().entriesListIsEmpty(); + + restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingProcess(processModel) + .deleteProcessItem(items.getOneRandomEntry()); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/items/DeleteProcessItemSanityTests.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/items/DeleteProcessItemSanityTests.java new file mode 100644 index 000000000..df776f144 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/items/DeleteProcessItemSanityTests.java @@ -0,0 +1,67 @@ +package org.alfresco.rest.workflow.processes.items; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestItemModel; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.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 DeleteProcessItemSanityTests extends RestTest +{ + private FileModel document, document2; + private SiteModel siteModel; + private UserModel userWhoStartsTask, assignee, adminUser; + private RestProcessModel processModel; + private RestItemModel processItem; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userWhoStartsTask = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); + } + + @TestRail(section = {TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Delete existing process item") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) + public void deleteProcessItem() throws Exception + { + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + document2 = dataContent.usingAdmin().usingSite(siteModel).createContent(DocumentType.MSWORD); + processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.withWorkflowAPI().usingProcess(processModel).deleteProcessItem(processItem); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems() + .assertThat().entriesListDoesNotContain("id", processItem.getId()); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Try to delete existing process item using invalid processId") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) + public void deleteProcessItemUsingInvalidProcessId() throws Exception + { + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + document2 = dataContent.usingAdmin().usingSite(siteModel).createContent(DocumentType.MSPOWERPOINT); + processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + processModel.setId("incorrectProcessId"); + restClient.withWorkflowAPI().usingProcess(processModel).deleteProcessItem(processItem); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/items/GetProcessItemsCoreTests.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/items/GetProcessItemsCoreTests.java new file mode 100644 index 000000000..918af8111 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/items/GetProcessItemsCoreTests.java @@ -0,0 +1,70 @@ +package org.alfresco.rest.workflow.processes.items; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class GetProcessItemsCoreTests extends RestTest +{ + private FileModel document; + private SiteModel siteModel; + private UserModel adminUser, userWhoStartsTask, assignee; + private RestProcessModel processModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userWhoStartsTask = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin calling getProcessItems can see anything with REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void getProcessItemsAsAdminReturnsAnything() throws Exception + { + processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); + + restClient.authenticateUser(adminUser).withWorkflowAPI().usingProcess(processModel).getProcessItems().assertThat().entriesListIsNotEmpty(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify getProcessItems for invalid processId with REST API and status code is NOT_FOUND (404)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void getProcessItemsForInvalidProcessId() throws Exception + { + processModel = restClient.authenticateUser(assignee).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processModel.setId("invalidProcessId"); + restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems().assertThat().entriesListIsEmpty(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidProcessId")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify getProcessItems for empty processId with REST API and status code is NOT_FOUND (404)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void getProcessItemsForEmptyProcessId() throws Exception + { + processModel = restClient.authenticateUser(assignee).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processModel.setId(""); + restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems().assertThat().entriesListIsEmpty(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/items/GetProcessItemsFullTests.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/items/GetProcessItemsFullTests.java new file mode 100644 index 000000000..c81c5c3f4 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/items/GetProcessItemsFullTests.java @@ -0,0 +1,198 @@ +package org.alfresco.rest.workflow.processes.items; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestItemModelsCollection; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Created by Claudia Agache on 2/2/2017. + */ +public class GetProcessItemsFullTests extends RestTest +{ + private FileModel document1, document2, document3; + private SiteModel siteModel; + private UserModel userWhoStartsTask, assignee; + private RestProcessModel processModel; + private RestItemModelsCollection items; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + userWhoStartsTask = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); + document1 = dataContent.usingUser(userWhoStartsTask).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + document2 = dataContent.usingUser(userWhoStartsTask).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + document3 = dataContent.usingUser(userWhoStartsTask).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Get process items for process without items") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION}) + public void getProcessItemsForProcessWithoutItems() throws Exception + { + processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.Normal); + items = restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems(); + restClient.assertStatusCodeIs(HttpStatus.OK); + items.assertThat().entriesListIsEmpty(); + } + + @Bug(id = "REPO-1989") + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Get process items for process with valid skipCount parameter") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION}) + public void getProcessItemsWithValidSkipCount() throws Exception + { + processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.Normal); + restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document1); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document3); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + items = restClient.authenticateUser(assignee).withParams("skipCount=2").withWorkflowAPI().usingProcess(processModel).getProcessItems(); + restClient.assertStatusCodeIs(HttpStatus.OK); + items.assertThat().entriesListContains("name", document3.getName()) + .assertThat().entriesListDoesNotContain("name", document1.getName()) + .assertThat().entriesListDoesNotContain("name", document2.getName()) + .assertThat().entriesListCountIs(1) + .assertThat().paginationField("skipCount").is("2"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Get process items for process with negative skipCount") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION}) + public void getProcessItemsWithNegativeSkipCount() throws Exception + { + processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.Normal); + restClient.authenticateUser(assignee).withParams("skipCount=-2").withWorkflowAPI().usingProcess(processModel).getProcessItems(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT) + .containsErrorKey(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE) + .statusCodeIs(HttpStatus.BAD_REQUEST); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Get process items for process with non numeric skipCount") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION}) + public void getProcessItemsWithNonNumericSkipCount() throws Exception + { + processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.Normal); + restClient.authenticateUser(assignee).withParams("skipCount=A").withWorkflowAPI().usingProcess(processModel).getProcessItems(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "A")); + } + + @Bug(id = "MNT-17438") + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Get process items for process with valid maxItems parameter") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION}) + public void getProcessItemsWithValidMaxItems() throws Exception + { + processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.Normal); + restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document1); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document3); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + items = restClient.authenticateUser(assignee).withParams("maxItems=2").withWorkflowAPI().usingProcess(processModel).getProcessItems(); + restClient.assertStatusCodeIs(HttpStatus.OK); + items.assertThat().entriesListDoesNotContain("name", document3.getName()) + .assertThat().entriesListContains("name", document1.getName()) + .assertThat().entriesListContains("name", document2.getName()) + .assertThat().entriesListCountIs(2) + .assertThat().paginationField("maxItems").is("2"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Get process items for process with negative maxItems") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION}) + public void getProcessItemsWithNegativeMaxItems() throws Exception + { + processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.Normal); + restClient.authenticateUser(assignee).withParams("maxItems=-2").withWorkflowAPI().usingProcess(processModel).getProcessItems(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) + .containsErrorKey(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE) + .statusCodeIs(HttpStatus.BAD_REQUEST); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Get process items for process with non numeric maxItems") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION}) + public void getProcessItemsWithNonNumericMaxItems() throws Exception + { + processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.Normal); + restClient.authenticateUser(assignee).withParams("maxItems=A").withWorkflowAPI().usingProcess(processModel).getProcessItems(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "A")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify get all process items with properties parameter.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void getProcessItemsWithPropertiesParameter() throws Exception + { + processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.Normal); + restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document1); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + items = restClient.authenticateUser(assignee).withParams("properties=createdBy,name,mimeType,size").withWorkflowAPI().usingProcess(processModel).getProcessItems(); + restClient.assertStatusCodeIs(HttpStatus.OK); + items.assertThat().entriesListIsNotEmpty(); + items.getProcessItemByName(document1.getName()) + .assertThat().field("createdBy").is(userWhoStartsTask.getUsername()) + .assertThat().field("name").is(document1.getName()) + .assertThat().field("mimeType").is(document1.getFileType().mimeType) + .assertThat().field("size").isNotNull() + .assertThat().field("modifiedAt").isNull() + .assertThat().field("modifiedBy").isNull() + .assertThat().field("id").isNull() + .assertThat().field("createdAt ").isNull() + .assertThat().fieldsCount().is(4); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify get all process items after process is deleted.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void getProcessItemsAfterDeletingProcess() throws Exception + { + processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.Normal); + restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document1); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.withWorkflowAPI().usingProcess(processModel).deleteProcess(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + items = restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(processModel).getProcessItems(); + restClient.assertStatusCodeIs(HttpStatus.OK); + items.assertThat().entriesListIsNotEmpty(); + items.getProcessItemByName(document1.getName()) + .assertThat().field("createdBy").is(userWhoStartsTask.getUsername()) + .assertThat().field("name").is(document1.getName()) + .assertThat().field("mimeType").is(document1.getFileType().mimeType) + .assertThat().field("size").isNotNull() + .assertThat().field("modifiedAt").isNotNull() + .assertThat().field("modifiedBy").is(userWhoStartsTask.getUsername()) + .assertThat().field("id").is(document1.getNodeRefWithoutVersion()) + .assertThat().field("createdAt ").isNotNull(); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/items/GetProcessItemsSanityTests.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/items/GetProcessItemsSanityTests.java new file mode 100644 index 000000000..6c0ce3764 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/items/GetProcessItemsSanityTests.java @@ -0,0 +1,59 @@ +package org.alfresco.rest.workflow.processes.items; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestItemModelsCollection; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.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 GetProcessItemsSanityTests extends RestTest +{ + private FileModel document; + private SiteModel siteModel; + private UserModel userWhoStartsTask, assignee; + private RestProcessModel processModel; + private RestItemModelsCollection items; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + userWhoStartsTask = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); + document = dataContent.usingUser(userWhoStartsTask).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Verify that user that started the process gets all process items") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) + public void getProcessItemsUsingTheUserWhoStartedProcess() throws Exception + { + processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + items = restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems(); + restClient.assertStatusCodeIs(HttpStatus.OK); + items.assertThat().entriesListIsNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Verify that user that is involved in the process gets all process items") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) + public void getProcessItemsUsingUserInvolvedInProcess() throws Exception + { + processModel = restClient.authenticateUser(assignee).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + items = restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems(); + restClient.assertStatusCodeIs(HttpStatus.OK); + items.assertThat().entriesListIsNotEmpty(); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/tasks/GetProcessTasksCoreTests.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/tasks/GetProcessTasksCoreTests.java new file mode 100644 index 000000000..93bb26a4b --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/tasks/GetProcessTasksCoreTests.java @@ -0,0 +1,98 @@ +package org.alfresco.rest.workflow.processes.tasks; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestTaskModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.GroupModel; +import org.alfresco.utility.model.ProcessModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class GetProcessTasksCoreTests extends RestTest +{ + private FileModel document, document1, document2; + private SiteModel siteModel; + private UserModel userWhoStartsProcess, candidate, anotherAssignee, assignee; + private ProcessModel process; + private GroupModel group; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + userWhoStartsProcess = dataUser.createRandomTestUser(); + candidate = dataUser.createRandomTestUser(); + anotherAssignee = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userWhoStartsProcess).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + document1 = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + document2 = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + process = dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document) + .createSingleReviewerTaskAndAssignTo(assignee); + group = dataGroup.createRandomGroup(); + dataGroup.addListOfUsersToGroup(group, candidate); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "getProcessTasks with user that is candidate with REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void getProcessTasksWithUserThatIsCandidate() throws Exception + { + ProcessModel processModel = dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document1) + .createGroupReviewTaskAndAssignTo(group); + + restClient.authenticateUser(candidate).withWorkflowAPI() + .usingProcess(processModel).getProcessTasks().assertThat().entriesListIsNotEmpty() + .and().entriesListContains("assignee", candidate.getUsername()); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "getProcessTasks for invalid processId with REST API and status code is NOT_FOUND (404)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void getProcessTasksUsingInvalidProcessId() throws Exception + { + ProcessModel processModel = process; + processModel.setId("invalidProcessId"); + restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI() + .usingProcess(processModel).getProcessTasks().assertThat().entriesListIsEmpty(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "getProcessTasks for empty processId with REST API and status code is NOT_FOUND (404)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void getProcessTasksUsingEmptyProcessId() throws Exception + { + ProcessModel processModel = process; + processModel.setId(""); + restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI() + .usingProcess(processModel).getProcessTasks().assertThat().entriesListIsEmpty(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "User completes task then getProcessTasks with REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void completeTaskThenGetProcessTasks() throws Exception + { + ProcessModel processModel = dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document2) + .createMoreReviewersWorkflowAndAssignTo(anotherAssignee); + RestTaskModel restTaskModel = restClient.authenticateUser(anotherAssignee).withWorkflowAPI() + .usingProcess(processModel).getProcessTasks().assertThat().entriesListIsNotEmpty().getOneRandomEntry().onModel(); + restTaskModel = restClient.withParams("select=state").withWorkflowAPI().usingTask(restTaskModel).updateTask("completed"); + restTaskModel.assertThat().field("id").is(restTaskModel.getId()).and().field("state").is("completed"); + restClient.withWorkflowAPI().getTasks().assertThat().entriesListIsEmpty(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/tasks/GetProcessTasksFullTests.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/tasks/GetProcessTasksFullTests.java new file mode 100644 index 000000000..5c7a98d65 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/tasks/GetProcessTasksFullTests.java @@ -0,0 +1,207 @@ +package org.alfresco.rest.workflow.processes.tasks; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestTaskModelsCollection; +import org.alfresco.utility.model.*; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Created by Claudia Agache on 2/3/2017. + */ +public class GetProcessTasksFullTests extends RestTest +{ + private FileModel document; + private SiteModel publicSite; + private UserModel adminUser, userWhoStartsProcess, assignee1, assignee2, assignee3; + private ProcessModel processWithSingleTask, processWithMultipleTasks; + private RestTaskModelsCollection processTasks; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userWhoStartsProcess = dataUser.createRandomTestUser(); + assignee1 = dataUser.createRandomTestUser("A_1"); + assignee2 = dataUser.createRandomTestUser("B_2"); + assignee3 = dataUser.createRandomTestUser("C_3"); + publicSite = dataSite.usingUser(userWhoStartsProcess).createPublicRandomSite(); + document = dataContent.usingSite(publicSite).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + processWithSingleTask = dataWorkflow.usingUser(userWhoStartsProcess).usingSite(publicSite).usingResource(document) + .createSingleReviewerTaskAndAssignTo(assignee1); + processWithMultipleTasks = dataWorkflow.usingUser(userWhoStartsProcess).usingSite(publicSite).usingResource(document) + .createMoreReviewersWorkflowAndAssignTo(assignee1, assignee2, assignee3); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify admin user is able to getProcessTasks even if he wasn't involved in process. Check status code is OK") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void getProcessTasksWithAdmin() throws Exception + { + processTasks = restClient.authenticateUser(adminUser).withWorkflowAPI() + .usingProcess(processWithSingleTask).getProcessTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + processTasks.assertThat().entriesListCountIs(1) + .and().entriesListContains("assignee", assignee1.getUsername()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Get process tasks with valid skipCount parameter applied") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION}) + public void getProcessTasksWithValidSkipCount() throws Exception + { + processTasks = restClient.authenticateUser(userWhoStartsProcess) + .withParams("orderBy=assignee ASC&skipCount=2").withWorkflowAPI() + .usingProcess(processWithMultipleTasks).getProcessTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + processTasks.assertThat().entriesListContains("assignee", assignee3.getUsername()) + .assertThat().entriesListDoesNotContain("assignee", assignee1.getUsername()) + .assertThat().entriesListDoesNotContain("assignee", assignee2.getUsername()) + .assertThat().entriesListCountIs(1) + .assertThat().paginationField("skipCount").is("2"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Get process tasks with negative skipCount parameter applied") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION}) + public void getProcessTasksWithNegativeSkipCount() throws Exception + { + restClient.authenticateUser(userWhoStartsProcess) + .withParams("skipCount=-2").withWorkflowAPI() + .usingProcess(processWithMultipleTasks).getProcessTasks(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT) + .containsErrorKey(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE) + .statusCodeIs(HttpStatus.BAD_REQUEST); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Get process tasks with non numeric skipCount parameter applied") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION}) + public void getProcessTasksWithNonNumericSkipCount() throws Exception + { + restClient.authenticateUser(userWhoStartsProcess) + .withParams("skipCount=A").withWorkflowAPI() + .usingProcess(processWithMultipleTasks).getProcessTasks(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "A")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Get process tasks with valid maxItems parameter applied") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION}) + public void getProcessTasksWithValidMaxItems() throws Exception + { + processTasks = restClient.authenticateUser(userWhoStartsProcess) + .withParams("orderBy=assignee ASC&maxItems=2").withWorkflowAPI() + .usingProcess(processWithMultipleTasks).getProcessTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + processTasks.assertThat().entriesListDoesNotContain("assignee", assignee3.getUsername()) + .assertThat().entriesListContains("assignee", assignee1.getUsername()) + .assertThat().entriesListContains("assignee", assignee2.getUsername()) + .assertThat().entriesListCountIs(2) + .assertThat().paginationField("maxItems").is("2"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Get process tasks with negative maxItems parameter applied") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION}) + public void getProcessTasksWithNegativeMaxItems() throws Exception + { + restClient.authenticateUser(userWhoStartsProcess) + .withParams("maxItems=-2").withWorkflowAPI() + .usingProcess(processWithMultipleTasks).getProcessTasks(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) + .containsErrorKey(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE) + .statusCodeIs(HttpStatus.BAD_REQUEST); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Get process tasks with non numeric maxItems parameter applied") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION}) + public void getProcessTasksWithNonNumericMaxItems() throws Exception + { + restClient.authenticateUser(userWhoStartsProcess) + .withParams("maxItems=A").withWorkflowAPI() + .usingProcess(processWithMultipleTasks).getProcessTasks(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "A")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify getProcessTasks with properties parameter") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void getProcessTasksWithPropertiesParameter() throws Exception + { + processTasks = restClient.authenticateUser(adminUser) + .withParams("properties=name,assignee,state").withWorkflowAPI() + .usingProcess(processWithSingleTask).getProcessTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + processTasks.assertThat().entriesListCountIs(1); + processTasks.getOneRandomEntry().onModel().assertThat() + .field("dueAt").isNull().and() + .field("processDefinitionId").isNull().and() + .field("processId").isNull().and() + .field("description").isNull().and() + .field("startedAt").isNull().and() + .field("id").isNull().and() + .field("activityDefinitionId").isNull().and() + .field("priority").isNull().and() + .field("formResourceKey").isNull().and() + .field("name").is("Review Task").and() + .field("state").is("claimed").and() + .field("assignee").is(assignee1.getUsername()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify admin gets Process Tasks ordered by assignee ascendant using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void getProcessTasksOrderedByAssignee() throws Exception + { + processTasks = restClient.authenticateUser(adminUser) + .withParams("orderBy=assignee").withWorkflowAPI() + .usingProcess(processWithMultipleTasks).getProcessTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + processTasks.assertThat().entriesListIsSortedAscBy("assignee"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify admin doesn't get Process Tasks ordered by many fields") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void getProcessTasksOrderedByMultipleFields() throws Exception + { + restClient.authenticateUser(adminUser) + .withParams("orderBy=assignee,state").withWorkflowAPI() + .usingProcess(processWithMultipleTasks).getProcessTasks(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary("Only one order by parameter is supported"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify get all process tasks after process is deleted.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void getProcessTasksAfterDeletingProcess() throws Exception + { + ProcessModel processModel = dataWorkflow.usingUser(userWhoStartsProcess).usingSite(publicSite).usingResource(document) + .createSingleReviewerTaskAndAssignTo(assignee1); + + restClient.authenticateUser(adminUser).withWorkflowAPI().usingProcess(processModel).deleteProcess(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + processTasks = restClient.authenticateUser(adminUser).withWorkflowAPI() + .usingProcess(processModel).getProcessTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + processTasks.assertThat().entriesListIsEmpty(); + } + +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/tasks/GetProcessTasksSanityTests.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/tasks/GetProcessTasksSanityTests.java new file mode 100644 index 000000000..d0c5f0efd --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/tasks/GetProcessTasksSanityTests.java @@ -0,0 +1,86 @@ +package org.alfresco.rest.workflow.processes.tasks; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestTaskModelsCollection; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.ProcessModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Tests for GET "/processes/{processId}/tasks" REST API call + * + * @author Cristina Axinte + */ +public class GetProcessTasksSanityTests extends RestTest +{ + private FileModel document; + private SiteModel siteModel; + private UserModel userModel, assignee1, assignee2, assignee3; + private ProcessModel process; + private RestTaskModelsCollection processTasks; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + assignee1 = dataUser.createRandomTestUser(); + assignee2 = dataUser.createRandomTestUser(); + assignee3 = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + process = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(document) + .createMoreReviewersWorkflowAndAssignTo(assignee1, assignee2, assignee3); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Verify user who started the process gets all tasks of started process with Rest API and response is successfull (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) + public void userWhoStartedProcessCanGetProcessTasks() throws JsonToModelConversionException, Exception + { + processTasks = restClient.authenticateUser(userModel).withWorkflowAPI().usingProcess(process).getProcessTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + processTasks.assertThat() + .entriesListCountIs(3).and() + .entriesListContains("assignee", assignee1.getUsername()).and() + .entriesListContains("assignee", assignee2.getUsername()).and() + .entriesListContains("assignee", assignee3.getUsername()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Verify any assignee user of the process gets all tasks of the process with Rest API and response is successfull (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) + public void assigneeUserCanGetAllProcessTasks() throws JsonToModelConversionException, Exception + { + processTasks = restClient.authenticateUser(assignee1).withWorkflowAPI().usingProcess(process).getProcessTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + processTasks.assertThat() + .entriesListContains("assignee", assignee1.getUsername()).and() + .entriesListContains("assignee", assignee2.getUsername()).and() + .entriesListContains("assignee", assignee3.getUsername()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Verify any assignee user of the process gets all tasks of the process with Rest API and response is successfull (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) + public void involvedUserCanGetAllProcessTasks() throws JsonToModelConversionException, Exception + { + ProcessModel process = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(document) + .createMoreReviewersWorkflowAndAssignTo(assignee1, assignee2, assignee3); + dataWorkflow.usingUser(assignee1).approveTask(process); + + processTasks = restClient.authenticateUser(assignee2).withWorkflowAPI().usingProcess(process).getProcessTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + processTasks.assertThat() + .entriesListIsNotEmpty().assertThat() + .entriesListContains("assignee", userModel.getUsername()); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariableCoreTests.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariableCoreTests.java new file mode 100644 index 000000000..d1dc33782 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariableCoreTests.java @@ -0,0 +1,188 @@ +package org.alfresco.rest.workflow.processes.variables; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.dataprep.CMISUtil.Priority; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestProcessVariableModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class AddProcessVariableCoreTests extends RestTest +{ + private FileModel document; + private SiteModel siteModel; + private UserModel userWhoStartsProcess, assignee, adminUser, anotherUser; + private RestProcessModel processModel; + private RestProcessVariableModel variableModel, processVariable; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + anotherUser = dataUser.createRandomTestUser(); + userWhoStartsProcess = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userWhoStartsProcess).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Add process variable using by the user who started the process.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void addProcessVariableByUserThatStartedTheProcess() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); + + processVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + processVariable.assertThat().field("name").is(variableModel.getName()) + .and().field("type").is(variableModel.getType()) + .and().field("value").is(variableModel.getValue()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Add process variable using by a random user.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void addProcessVariableByAnyUser() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(anotherUser).withWorkflowAPI().addProcess("activitiAdhoc", anotherUser, false, Priority.Normal); + + processVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + processVariable.assertThat().field("name").is(variableModel.getName()) + .and().field("type").is(variableModel.getType()) + .and().field("value").is(variableModel.getValue()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding process variable is falling in case invalid type is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void failedAddingProcessVariableIfInvalidTypeIsProvided() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:textarea"); + + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsErrorKey(String.format(RestErrorModel.UNSUPPORTED_TYPE, "d:textarea")) + .containsSummary(String.format(RestErrorModel.UNSUPPORTED_TYPE, "d:textarea")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Bug(id = "REPO-1938") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding process variable is falling in case invalid type prefix is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void failedAddingProcessVariableIfInvalidTypePrefixIsProvided() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("ddt:text"); + + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .containsSummary(String.format(RestErrorModel.INVALID_NAMEPACE_PREFIX, "ddt")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding process variable is falling in case invalid value is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void failedAddingProcessVariableIfInvalidValueIsProvided() throws Exception + { + RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:int"); + variableModel.setValue("invalidValue"); + + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .containsSummary(String.format(RestErrorModel.FOR_INPUT_STRING, "invalidValue")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding process variable is falling in case missing required variable body (name) is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void failedAddingProcessVariableIfMissingRequiredVariableNameBodyIsProvided() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"value\": \"missingVariableName\",\"type\": \"d:text\"}", + "processes/{processId}/variables/{variableName}", processModel.getId(), variableModel.getName()); + restClient.processModel(RestProcessVariableModel.class, request); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsErrorKey(RestErrorModel.VARIABLE_NAME_REQUIRED) + .containsSummary(RestErrorModel.VARIABLE_NAME_REQUIRED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding process variable is falling in case invalid variableBody (adding extra parameter in body) is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void failedAddingProcessVariableIfInvalidBodyIsProvided() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"scope\": \"local\",\"value\": \"testing\",\"type\": \"d:text\"}", + "processes/{processId}/variables/{variableName}", processModel.getId(), variableModel.getName()); + restClient.processModel(RestProcessVariableModel.class, request); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "Unrecognized field \"scope\"")) + .containsSummary(String.format(RestErrorModel.NO_CONTENT, "Unrecognized field \"scope\"")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding process variable is falling in case empty name is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void failedAddingProcessVariableIfEmptyNameIsProvided() throws Exception + { + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); + RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + variableModel.setName(""); + + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); + + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) + .assertLastError() + .containsErrorKey(RestErrorModel.PUT_EMPTY_ARGUMENT) + .containsSummary(RestErrorModel.PUT_EMPTY_ARGUMENT) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariableFullTests.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariableFullTests.java new file mode 100644 index 000000000..098a0658d --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariableFullTests.java @@ -0,0 +1,182 @@ +package org.alfresco.rest.workflow.processes.variables; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestProcessVariableModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.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 AddProcessVariableFullTests extends RestTest +{ + private FileModel document; + private SiteModel siteModel; + private UserModel userWhoStartsProcess, assignee, adminUser; + private RestProcessModel processModel; + private RestProcessVariableModel variableModel, processVariable, updatedProcessVariable; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userWhoStartsProcess = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userWhoStartsProcess).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify addProcessVariable by any user for invalid processID with REST API and status code is NOT_FOUND (404)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void addProcessVariableWithInvalidProcessId() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processModel.setId("invalidProcessID"); + + processVariable = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingProcess(processModel) + .updateProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidProcessID")); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify addProcessVariable by any user for empty processID with REST API and status code is NOT_FOUND (404)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void addProcessVariableWithEmptyProcessId() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processModel.setId(""); + + processVariable = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingProcess(processModel) + .updateProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding process variable in case of having only 'name' field is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void addingProcessVariableWithOnlyNameProvided() throws Exception + { + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"name\": \"variableName\"}", + "processes/{processId}/variables/{variableName}", processModel.getId(), "variableName"); + processVariable = restClient.processModel(RestProcessVariableModel.class, request); + + restClient.assertStatusCodeIs(HttpStatus.OK); + processVariable.assertThat().field("name").is("variableName") + .and().field("type").is("d:any") + .and().field("value").isNull(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding process variable in case of missing type field is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void addingProcessVariableIfMissingValueIsProvided() throws Exception + { + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"name\": \"variableName\", \"type\": \"d:text\"}", + "processes/{processId}/variables/{variableName}", processModel.getId(), "variableName"); + processVariable = restClient.processModel(RestProcessVariableModel.class, request); + + restClient.assertStatusCodeIs(HttpStatus.OK); + processVariable.assertThat().field("name").is("variableName") + .and().field("type").is("d:text") + .and().field("value").isNull(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding process variable in case of missing type field is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void addingProcessVariableIfMissingTypeIsProvided() throws Exception + { + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"value\": \"variableValue\", \"name\": \"variableName\"}", + "processes/{processId}/variables/{variableName}", processModel.getId(), "variableValue"); + processVariable = restClient.processModel(RestProcessVariableModel.class, request); + + restClient.assertStatusCodeIs(HttpStatus.OK); + processVariable.assertThat().field("name").is("variableName") + .and().field("type").is("d:text") + .and().field("value").is("variableValue"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding process variable is case of empty type value is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void addingProcessVariableIfEmptyTypeIsProvided() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel(""); + + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); + + restClient.assertStatusCodeIs(HttpStatus.OK); + processVariable.assertThat().field("name").is(variableModel.getName()) + .and().field("type").is("d:text") + .and().field("value").is(variableModel.getValue()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding process variable in case of empty body field is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void addingProcessVariableWithEmptyBodyProvided() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel(""); + + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{ }", + "processes/{processId}/variables/{variableName}", processModel.getId(), variableModel.getName()); + processVariable = restClient.processModel(RestProcessVariableModel.class, request); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsErrorKey(RestErrorModel.VARIABLE_NAME_REQUIRED) + .containsSummary(RestErrorModel.VARIABLE_NAME_REQUIRED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Update twice in a row the same variable.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void updateTwiceInARowSameProcessVariable() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + + processVariable = restClient.withWorkflowAPI().usingProcess(processModel) + .updateProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + processVariable.assertThat().field("name").is(variableModel.getName()) + .and().field("type").is(variableModel.getType()) + .and().field("value").is(variableModel.getValue()); + + restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() + .assertThat().entriesListContains("name", variableModel.getName()); + + updatedProcessVariable = restClient.withWorkflowAPI().usingProcess(processModel) + .updateProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedProcessVariable.assertThat().field("name").is(variableModel.getName()) + .and().field("type").is(variableModel.getType()) + .and().field("value").is(variableModel.getValue()); + + restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() + .assertThat().entriesListContains("name", variableModel.getName()); + } + +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariableSanityTests.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariableSanityTests.java new file mode 100644 index 000000000..fed3c5c70 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariableSanityTests.java @@ -0,0 +1,95 @@ +package org.alfresco.rest.workflow.processes.variables; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestProcessVariableModel; +import org.alfresco.utility.data.RandomData; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.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 AddProcessVariableSanityTests extends RestTest +{ + private FileModel document; + private SiteModel siteModel; + private UserModel userWhoStartsTask, assignee, adminUser; + private RestProcessModel processModel; + private RestProcessVariableModel variableModel, processVariable; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userWhoStartsTask = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Create non-existing variable") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) + public void addProcessVariable() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + + processVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + processVariable.assertThat().field("name").is(variableModel.getName()) + .and().field("type").is(variableModel.getType()) + .and().field("value").is(variableModel.getValue()); + + restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() + .assertThat().entriesListContains("name", variableModel.getName()); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Update existing variable") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) + public void updateExistingProcessVariable() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + processVariable.assertThat().field("name").is(variableModel.getName()) + .and().field("type").is(variableModel.getType()) + .and().field("value").is(variableModel.getValue()); + + String newValue = RandomData.getRandomName("value"); + variableModel.setValue(newValue); + processVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + processVariable.assertThat().field("value").is(newValue); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Adding process variable is falling in case invalid variableBody is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) + public void failedAddingProcessVariableIfInvalidBodyIsProvided() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("incorrect type"); + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + + restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsErrorKey(String.format(RestErrorModel.UNSUPPORTED_TYPE, "incorrect type")) + .containsSummary(String.format(RestErrorModel.UNSUPPORTED_TYPE, "incorrect type")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesCoreTests.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesCoreTests.java new file mode 100644 index 000000000..e597ddd50 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesCoreTests.java @@ -0,0 +1,101 @@ +package org.alfresco.rest.workflow.processes.variables; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestProcessVariableModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class AddProcessVariablesCoreTests extends RestTest +{ + private FileModel document; + private SiteModel siteModel; + private UserModel userWhoStartsProcess, assignee; + private RestProcessModel processModel; + private RestProcessVariableModel variableModel, processVariable, variableModel1; + + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + userWhoStartsProcess = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userWhoStartsProcess).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify addProcessVariable by any user for invalid processID with REST API and status code is NOT_FOUND (404)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void addProcessVariableForInvalidProcessIdIsNotFound() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processModel.setId("invalidProcessID"); + + processVariable = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingProcess(processModel) + .addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidProcessID")); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify addProcessVariable by any user for empty processID with REST API and status code is NOT_FOUND (404)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void addProcessVariableForEmptyProcessIdIsEmpty() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processModel.setId(""); + + processVariable = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingProcess(processModel) + .addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding multiple process variables is falling in case invalid process id is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void addMultipleProcessVariablesInvalidProcessId() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:int"); + variableModel1 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processModel.setId("invalidProcessID"); + + restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(processModel) + .addProcessVariables(variableModel1, variableModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidProcessID")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding multiple process variables is falling in case empty process id is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void addMultipleProcessVariablesEmptyProcessId() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:int"); + variableModel1 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processModel.setId(""); + + restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(processModel) + .addProcessVariables(variableModel1, variableModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesFullTests.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesFullTests.java new file mode 100644 index 000000000..ba28bd516 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesFullTests.java @@ -0,0 +1,395 @@ +package org.alfresco.rest.workflow.processes.variables; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.dataprep.CMISUtil.Priority; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestProcessVariableCollection; +import org.alfresco.rest.model.RestProcessVariableModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.ProcessModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class AddProcessVariablesFullTests extends RestTest +{ + private FileModel document; + private SiteModel siteModel; + private UserModel userWhoStartsProcess, assignee, adminUser; + private ProcessModel processModel; + private RestProcessModel restProcessModel; + private RestProcessVariableModel variableModel, processVariable, variableModel1, variableModel2, variableModel3; + private RestProcessVariableCollection processVariableCollection; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userWhoStartsProcess = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userWhoStartsProcess).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + processModel = dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document).createSingleReviewerTaskAndAssignTo(assignee); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Add process variables using by the user involved in the process.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void addProcessVariableByUserInvolvedTheProcess() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + restProcessModel = restClient.authenticateUser(assignee).withWorkflowAPI().getProcesses() + .getProcessModelByProcessDefId(processModel.getId()); + + processVariable = restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(restProcessModel) + .addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + processVariable.assertThat().field("name").is(variableModel.getName()) + .and().field("type").is(variableModel.getType()) + .and().field("value").is(variableModel.getValue()); + + restClient.withWorkflowAPI().usingProcess(restProcessModel).getProcessVariables() + .assertThat().entriesListContains("name", variableModel.getName()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Add process variables using by the user involved in the process.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void addMultipleProcessVariableByUserInvolvedTheProcess() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + variableModel1 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + restProcessModel = restClient.authenticateUser(assignee).withWorkflowAPI().getProcesses() + .getProcessModelByProcessDefId(processModel.getId()); + + processVariableCollection = restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(restProcessModel) + .addProcessVariables(variableModel, variableModel1); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + processVariableCollection.getEntries().get(0).onModel() + .assertThat().field("name").is(variableModel.getName()) + .and().field("type").is(variableModel.getType()) + .and().field("value").is(variableModel.getValue()); + + processVariableCollection.getEntries().get(1).onModel() + .assertThat().field("name").is(variableModel1.getName()) + .and().field("type").is(variableModel1.getType()) + .and().field("value").is(variableModel1.getValue()); + + restClient.withWorkflowAPI().usingProcess(restProcessModel).getProcessVariables() + .assertThat().entriesListContains("name", variableModel.getName()) + .assertThat().entriesListContains("name", variableModel1.getName()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Add process variables using by inexistent user.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void addProcessVariableByInexistentUser() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + restProcessModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses() + .getProcessModelByProcessDefId(processModel.getId()); + + processVariable = restClient.authenticateUser(UserModel.getRandomUserModel()).withWorkflowAPI() + .usingProcess(restProcessModel) + .addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Add multiple process variables using by inexistent user.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void addMultipleProcessVariableByInexistentUser() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + variableModel1 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + restProcessModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses() + .getProcessModelByProcessDefId(processModel.getId()); + + processVariableCollection = restClient.authenticateUser(UserModel.getRandomUserModel()).withWorkflowAPI() + .usingProcess(restProcessModel) + .addProcessVariables(variableModel,variableModel1); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding process variables is falling in case invalid type is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void failedAddingProcessVariableIfInvalidTypeIsProvided() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:textarea"); + restProcessModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses() + .getProcessModelByProcessDefId(processModel.getId()); + + restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary( + String.format(RestErrorModel.UNSUPPORTED_TYPE, "d:textarea")) + .containsErrorKey(String.format(RestErrorModel.UNSUPPORTED_TYPE, "d:textarea")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Bug(id = "REPO-1938") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding process variables is falling in case invalid type prefix is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void failedAddingProcessVariableIfInvalidTypePrefixIsProvided() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("ddt:text"); + restProcessModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses() + .getProcessModelByProcessDefId(processModel.getId()); + + restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsSummary(String.format(RestErrorModel.INVALID_NAMEPACE_PREFIX, "ddt")) + .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding process variables is falling in case invalid value is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void failedAddingProcessVariableIfInvalidValueIsProvided() throws Exception + { + RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:int"); + variableModel.setValue("invalidValue"); + restProcessModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses() + .getProcessModelByProcessDefId(processModel.getId()); + + restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .containsSummary(String.format(RestErrorModel.FOR_INPUT_STRING, "invalidValue")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding process variables is falling in case invalid variableBody (adding extra parameter in body:scope) is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void failedAddingProcessVariableIfInvalidBodyIsProvided() throws Exception + { + restProcessModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses() + .getProcessModelByProcessDefId(processModel.getId()); + + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{\"name\": \"variableName\",\"scope\": \"local\",\"value\": \"testing\",\"type\": \"d:text\"}", + "processes/{processId}/variables", processModel.getId()); + restClient.processModel(RestProcessVariableModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsSummary(String.format(RestErrorModel.NO_CONTENT, "Unrecognized field \"scope\"")) + .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "Unrecognized field \"scope\"")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + //@Bug(id="REPO-1985") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding process variables is falling in case empty name is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void failedAddingProcessVariableIfEmptyNameIsProvided() throws Exception + { + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); + restProcessModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses() + .getProcessModelByProcessDefId(processModel.getId()); + RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + variableModel.setName(""); + + restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsSummary(RestErrorModel.VARIABLE_NAME_REQUIRED) + .containsErrorKey(RestErrorModel.VARIABLE_NAME_REQUIRED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + //@Bug(id="REPO-1985") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding process variables is falling in case invalid name is provided: ony white spaces") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void failedAddingProcessVariableUsingOnlyWhiteSpaceInName() throws Exception + { + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); + restProcessModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses() + .getProcessModelByProcessDefId(processModel.getId()); + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + variableModel.setName(" "); + + processVariable = restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + processVariable.assertThat().field("name").isNull() + .and().field("type").is(variableModel.getType()) + .and().field("value").is(variableModel.getValue()); + + restClient.withWorkflowAPI().usingProcess(restProcessModel).getProcessVariables() + .assertThat().entriesListContains("value", variableModel.getValue()); + } + + @Bug(id="REPO-1987") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding process variables is falling in case invalid name is provided: symbols") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void failedAddingProcessVariableWithSymbolsInName() throws Exception + { + restProcessModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses() + .getProcessModelByProcessDefId(processModel.getId()); + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + variableModel.setName("123_%^&: õÈ,Ì,Ò"); + + processVariable = restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + processVariable.assertThat().field("name").is(variableModel.getName()) + .and().field("type").is(variableModel.getType()) + .and().field("value").is(variableModel.getValue()); + + restClient.withWorkflowAPI().usingProcess(restProcessModel).getProcessVariables() + .assertThat().entriesListContains("name", variableModel.getName()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Add two process variables using by the user involved in the process.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void addingMultipleValidProcessVariables() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + variableModel2 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + variableModel3 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + restProcessModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses() + .getProcessModelByProcessDefId(processModel.getId()); + + processVariableCollection = restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(restProcessModel) + .addProcessVariables(variableModel, variableModel2, variableModel3); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + processVariableCollection.assertThat().entriesListContains("name", variableModel.getName()) + .assertThat().entriesListContains("name", variableModel2.getName()) + .assertThat().entriesListContains("name", variableModel3.getName()); + + processVariableCollection.getEntries().get(0).onModel().assertThat() + .field("name").is(variableModel.getName()).and() + .field("value").is(variableModel.getValue()).and() + .field("type").is(variableModel.getType()); + processVariableCollection.getEntries().get(1).onModel().assertThat() + .field("name").is(variableModel2.getName()).and() + .field("value").is(variableModel2.getValue()).and() + .field("type").is(variableModel2.getType()); + processVariableCollection.getEntries().get(2).onModel().assertThat() + .field("name").is(variableModel3.getName()).and() + .field("value").is(variableModel3.getValue()).and() + .field("type").is(variableModel3.getType()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Add two process variables using by the user involved in the process.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void failedAddingMultipleProcessVariablesInvalidType() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + variableModel.setType("d:string"); + variableModel2 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + restProcessModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses() + .getProcessModelByProcessDefId(processModel.getId()); + + processVariableCollection = restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(restProcessModel) + .addProcessVariables(variableModel, variableModel2); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.UNSUPPORTED_TYPE, "d:string")) + .containsErrorKey(String.format(RestErrorModel.UNSUPPORTED_TYPE, "d:string")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Bug(id = "REPO-1938") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Add two process variables using by the user involved in the process.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void failledAddingMultipleProcessVariablesInvalidTypePrefix() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + variableModel.setType("e:text"); + variableModel2 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + restProcessModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses() + .getProcessModelByProcessDefId(processModel.getId()); + + processVariableCollection = restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(restProcessModel) + .addProcessVariables(variableModel, variableModel2); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsSummary(String.format(RestErrorModel.INVALID_NAMEPACE_PREFIX, "e")) + .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding process variables is falling in case invalid value is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void failledAddingMultipleProcessVariablesInvalidValue() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:int"); + variableModel.setValue("invalidValue"); + variableModel1 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + variableModel2 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + restProcessModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses() + .getProcessModelByProcessDefId(processModel.getId()); + + processVariableCollection = restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(restProcessModel) + .addProcessVariables(variableModel, variableModel1, variableModel2); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .containsSummary(String.format(RestErrorModel.FOR_INPUT_STRING, "invalidValue")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding process variables is falling in case invalid value is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void failledAddingMultipleInvalidProcessVariables() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:int"); + variableModel.setValue("invalidValue"); + variableModel1 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + variableModel1.setType(""); + restProcessModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses() + .getProcessModelByProcessDefId(processModel.getId()); + + processVariableCollection = restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(restProcessModel) + .addProcessVariables(variableModel1, variableModel); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .containsSummary(String.format(RestErrorModel.FOR_INPUT_STRING, "invalidValue")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesSanityTests.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesSanityTests.java new file mode 100644 index 000000000..26ce6bd8d --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesSanityTests.java @@ -0,0 +1,158 @@ +package org.alfresco.rest.workflow.processes.variables; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestProcessVariableCollection; +import org.alfresco.rest.model.RestProcessVariableModel; +import org.alfresco.utility.data.RandomData; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class AddProcessVariablesSanityTests extends RestTest +{ + private FileModel document; + private SiteModel siteModel; + private UserModel userWhoStartsProcess, assignee, adminUser; + private RestProcessModel processModel; + private RestProcessVariableModel variableModel, variableModel1, variableModel2, processVariable; + private RestProcessVariableCollection processVariableCollection; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userWhoStartsProcess = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userWhoStartsProcess).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Create non-existing variable") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) + public void addProcessVariable() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + + processVariable = restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + processVariable.assertThat().field("name").is(variableModel.getName()) + .and().field("type").is(variableModel.getType()) + .and().field("value").is(variableModel.getValue()); + + restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() + .assertThat().entriesListContains("name", variableModel.getName()); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Create non-existing variable") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) + public void addMultipleProcessVariable() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + variableModel1 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + variableModel2 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + + processVariableCollection = restClient.withWorkflowAPI().usingProcess(processModel) + .addProcessVariables(variableModel, variableModel1, variableModel2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + processVariableCollection.getEntries().get(0).onModel() + .assertThat().field("name").is( variableModel.getName()) + .and().field("type").is( variableModel.getType()) + .and().field("value").is( variableModel.getValue()); + + processVariableCollection.getEntries().get(1).onModel() + .assertThat().field("name").is(variableModel1.getName()) + .and().field("type").is(variableModel1.getType()) + .and().field("value").is(variableModel1.getValue()); + + processVariableCollection.getEntries().get(2).onModel() + .assertThat().field("name").is(variableModel2.getName()) + .and().field("type").is(variableModel2.getType()) + .and().field("value").is(variableModel2.getValue()); + + restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() + .assertThat().entriesListContains("name", variableModel.getName()) + .assertThat().entriesListContains("name", variableModel1.getName()) + .assertThat().entriesListContains("name", variableModel2.getName()); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Update existing variables") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) + public void updateExistingProcessVariable() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + + processVariable = restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + processVariable.assertThat().field("name").is(variableModel.getName()) + .and().field("type").is(variableModel.getType()) + .and().field("value").is(variableModel.getValue()); + + String newValue = RandomData.getRandomName("value"); + variableModel.setValue(newValue); + processVariable = restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + processVariable.assertThat().field("value").is(newValue); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Update existing variables") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) + public void updateExistingMultipleProcessVariable() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + variableModel1 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + + processVariableCollection = restClient.withWorkflowAPI().usingProcess(processModel) + .addProcessVariables(variableModel, variableModel1); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + processVariableCollection.getEntries().get(0).onModel() + .assertThat().field("name").is(variableModel.getName()) + .and().field("type").is(variableModel.getType()) + .and().field("value").is(variableModel.getValue()); + + processVariableCollection.getEntries().get(1).onModel() + .assertThat().field("name").is(variableModel1.getName()) + .and().field("type").is(variableModel1.getType()) + .and().field("value").is(variableModel1.getValue()); + + String newValueVar = RandomData.getRandomName("valueVar"); + variableModel.setValue(newValueVar); + String newValueVar1 = RandomData.getRandomName("valueVar1"); + variableModel1.setValue(newValueVar1); + + processVariableCollection = restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariables(variableModel, variableModel1); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + processVariableCollection.getEntries().get(0).onModel().assertThat().field("value").is(newValueVar); + processVariableCollection.getEntries().get(1).onModel().assertThat().field("value").is(newValueVar1); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Adding process variables is falling in case invalid variableBody is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) + public void failedAddingProcessVariableIfInvalidBodyIsProvided() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("incorrect type"); + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + + restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary("Unsupported type of variable: 'incorrect type'."); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/DeleteProcessVariableCoreTests.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/DeleteProcessVariableCoreTests.java new file mode 100644 index 000000000..031f749b4 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/DeleteProcessVariableCoreTests.java @@ -0,0 +1,118 @@ +package org.alfresco.rest.workflow.processes.variables; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestProcessVariableModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.ProcessModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * + * @author bogdan.bocancea + * + */ +public class DeleteProcessVariableCoreTests extends RestTest +{ + private FileModel document; + private SiteModel siteModel; + private UserModel userWhoStartsTask, assignee, adminUser; + private RestProcessModel restProcessModel; + private ProcessModel processModel; + private RestProcessVariableModel variableModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userWhoStartsTask = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + processModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document) + .createSingleReviewerTaskAndAssignTo(assignee); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Delete invalid process variable") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void deleteInvalidProcessVariable() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("x:InvalidVar"); + restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() + .getProcesses().getProcessModelByProcessDefId(processModel.getId()); + restClient.withWorkflowAPI().usingProcess(restProcessModel).deleteProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, variableModel.getName())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Delete process variable twice") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void deleteProcessVariableTwice() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() + .getProcesses().getProcessModelByProcessDefId(processModel.getId()); + restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.withWorkflowAPI().usingProcess(restProcessModel).deleteProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingProcess(restProcessModel).deleteProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, variableModel.getName())); + } + + @TestRail(section = {TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Remove process variables with empty processId") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void deleteProcessVariableEmptyProcessId() throws JsonToModelConversionException, Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() + .getProcesses().getProcessModelByProcessDefId(processModel.getId()); + restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restProcessModel.setId(""); + restClient.withWorkflowAPI().usingProcess(restProcessModel).deleteProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Delete process variable with admin.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void deleteProcessVariableWithAdmin() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() + .getProcesses().getProcessModelByProcessDefId(processModel.getId()); + restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(adminUser).withWorkflowAPI().usingProcess(processModel) + .deleteProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() + .assertThat().entriesListDoesNotContain("name", variableModel.getName()); + } + +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/DeleteProcessVariableFullTests.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/DeleteProcessVariableFullTests.java new file mode 100644 index 000000000..9def8ff2b --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/DeleteProcessVariableFullTests.java @@ -0,0 +1,196 @@ +package org.alfresco.rest.workflow.processes.variables; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.dataprep.CMISUtil.Priority; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestProcessVariableModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.ProcessModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class DeleteProcessVariableFullTests extends RestTest +{ + private FileModel document; + private SiteModel siteModel; + private UserModel userWhoStartsTask, assignee; + private RestProcessModel restProcessModel; + private ProcessModel processModel; + private RestProcessVariableModel variableModel; + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + userWhoStartsTask = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + processModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createSingleReviewerTaskAndAssignTo(assignee); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Delete empty process variable") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void deleteEmptyProcessVariable() throws Exception + { + variableModel = new RestProcessVariableModel("", "", "bpm:workflowPackage"); + restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getProcesses() + .getProcessModelByProcessDefId(processModel.getId()); + + restClient.withWorkflowAPI().usingProcess(restProcessModel) + .deleteProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) + .assertLastError() + .containsSummary(RestErrorModel.DELETE_EMPTY_ARGUMENT) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .containsErrorKey(RestErrorModel.DELETE_EMPTY_ARGUMENT) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Delete process then delete process variables, status OK should be returned") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void deleteProcessVariablesForADeletedProcess() throws Exception + { + UserModel userWhoStartsTask = dataUser.createRandomTestUser(); + UserModel assignee = dataUser.createRandomTestUser(); + + RestProcessModel processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() + .addProcess("activitiAdhoc", assignee, false, Priority.Normal); + + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() + .getProcesses().getProcessModelByProcessDefId(processModel.getId()); + restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingProcess(processModel) + .deleteProcess(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withWorkflowAPI().usingProcess(processModel).deleteProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, processModel.getId())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Delete process variable using by the user who started the process.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void deleteProcessVariableByUserThatStartedTheProcess() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() + .addProcess("activitiAdhoc", assignee, false, Priority.Normal); + + restProcessModel = restClient.withWorkflowAPI().getProcesses() + .getProcessModelByProcessDefId(processModel.getId()); + restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.withWorkflowAPI().usingProcess(processModel) + .deleteProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() + .assertThat() + .entriesListDoesNotContain("name", variableModel.getName()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Delete process variable using by the user involved in the process.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void deleteProcessVariableByUserInvolvedInTheProcess() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() + .addProcess("activitiAdhoc", assignee, false, Priority.Normal); + + restProcessModel = restClient.withWorkflowAPI().getProcesses() + .getProcessModelByProcessDefId(processModel.getId()); + restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(processModel) + .deleteProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() + .assertThat() + .entriesListDoesNotContain("name", variableModel.getName()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Delete process variable with invalid type") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void deleteProcessVariableInvalidType() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() + .getProcesses().getProcessModelByProcessDefId(processModel.getId()); + restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + variableModel.setType("invalid-type"); + restClient.withWorkflowAPI().usingProcess(restProcessModel).deleteProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() + .assertThat() + .entriesListDoesNotContain("name", variableModel.getName()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Delete process variable by non assigned user") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void deleteProcessVarialbleByNonAssignedUser() throws Exception + { + UserModel nonAssigned = dataUser.createRandomTestUser(); + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() + .getProcesses().getProcessModelByProcessDefId(processModel.getId()); + restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(nonAssigned).withWorkflowAPI().usingProcess(restProcessModel) + .deleteProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError() + .containsSummary(String.format(RestErrorModel.ACCESS_INFORMATION_NOT_ALLOWED, processModel.getId())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .containsErrorKey(String.format(RestErrorModel.ACCESS_INFORMATION_NOT_ALLOWED, processModel.getId())) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Delete process variable by inexistent user") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void deleteProcessVarialbleByInexistentUser() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() + .addProcess("activitiAdhoc", userWhoStartsTask, false, Priority.Normal); + restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() + .getProcesses().getProcessModelByProcessDefId(processModel.getId()); + restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(UserModel.getRandomUserModel()).withWorkflowAPI() + .usingProcess(restProcessModel) + .deleteProcessVariable(variableModel); + + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .stackTraceIs(RestErrorModel.STACKTRACE); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/DeleteProcessVariableSanityTests.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/DeleteProcessVariableSanityTests.java new file mode 100644 index 000000000..cb43c40c8 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/DeleteProcessVariableSanityTests.java @@ -0,0 +1,69 @@ +package org.alfresco.rest.workflow.processes.variables; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.dataprep.CMISUtil.Priority; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestProcessVariableModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.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 DeleteProcessVariableSanityTests extends RestTest +{ + private FileModel document; + private SiteModel siteModel; + private UserModel userWhoStartsTask, assignee, adminUser; + private RestProcessModel processModel; + private RestProcessVariableModel variableModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userWhoStartsTask = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().addProcess("activitiAdhoc", adminUser, false, Priority.Normal); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Delete existing variable") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) + public void deleteProcessVariable() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.withWorkflowAPI().usingProcess(processModel).deleteProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() + .assertThat().entriesListDoesNotContain("name", variableModel.getName()); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Try to delete existing variable using invalid processId") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) + public void deleteProcessVariableUsingInvalidProcessId() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + processModel.setId("incorrectProcessId"); + restClient.withWorkflowAPI().usingProcess(processModel).deleteProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "incorrectProcessId")); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/GetProcessVariablesCoreTests.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/GetProcessVariablesCoreTests.java new file mode 100644 index 000000000..0b8c721b6 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/GetProcessVariablesCoreTests.java @@ -0,0 +1,88 @@ +package org.alfresco.rest.workflow.processes.variables; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.dataprep.CMISUtil.Priority; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestProcessModelsCollection; +import org.alfresco.rest.model.RestProcessVariableCollection; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.apache.commons.lang3.RandomStringUtils; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class GetProcessVariablesCoreTests extends RestTest +{ + private FileModel document; + private SiteModel siteModel; + private UserModel userWhoStartsTask, assignee, admin; + private RestProcessModel processModel; + private RestProcessVariableCollection variables; + + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + admin = dataUser.getAdminUser(); + userWhoStartsTask = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Get process variables using invalid process ID") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void getProcessVariablesUsingInvalidProcessId() throws Exception + { + restClient.authenticateUser(userWhoStartsTask).withParams("maxItems=2").withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); + RestProcessModelsCollection processes = restClient.authenticateUser(userWhoStartsTask).withParams("maxItems=2").withWorkflowAPI().getProcesses(); + processModel = processes.assertThat().entriesListIsNotEmpty().when().getOneRandomEntry().onModel(); + + String id = RandomStringUtils.randomAlphanumeric(10); + processModel.setId(id); + variables = restClient.withParams("maxItems=2").withWorkflowAPI().usingProcess(processModel).getProcessVariables(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, id)) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Get process variables using empty process ID") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void getProcessVariablesUsingEmptyProcessId() throws Exception + { + processModel = restClient.authenticateUser(userWhoStartsTask).withParams("maxItems=2").withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processModel.setId(""); + variables = restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Delete process then get process variables, status OK should be returned") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void getProcessVariablesForADeletedProcess() throws Exception + { + UserModel userWhoStartsTask = dataUser.createRandomTestUser(); + UserModel assignee = dataUser.createRandomTestUser(); + + RestProcessModel processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); + + restClient.authenticateUser(admin).withWorkflowAPI().usingProcess(processModel).deleteProcess(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + RestProcessVariableCollection variables = restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables(); + restClient.assertStatusCodeIs(HttpStatus.OK); + variables.assertThat().entriesListIsNotEmpty(); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/GetProcessVariablesFullTests.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/GetProcessVariablesFullTests.java new file mode 100644 index 000000000..e7c841cd3 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/GetProcessVariablesFullTests.java @@ -0,0 +1,161 @@ +package org.alfresco.rest.workflow.processes.variables; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestProcessVariableCollection; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Created by Claudia Agache on 2/2/2017. + */ +public class GetProcessVariablesFullTests extends RestTest +{ + private UserModel userWhoStartsProcess, assignee, admin; + private RestProcessModel processModel; + private RestProcessVariableCollection variables; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + admin = dataUser.getAdminUser(); + userWhoStartsProcess = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.Normal); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify get all process variables call using admin user. Admin can see the process even if he isn't involved in it.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void getProcessVariablesUsingAdmin() throws Exception + { + variables = restClient.authenticateUser(admin).withWorkflowAPI().usingProcess(processModel).getProcessVariables(); + restClient.assertStatusCodeIs(HttpStatus.OK); + variables.assertThat().entriesListIsNotEmpty(); + variables.getProcessVariableByName("initiator") + .assertThat().field("name").is("initiator") + .assertThat().field("type").is("d:noderef") + .assertThat().field("value").is(userWhoStartsProcess.getUsername()); + variables.getProcessVariableByName("bpm_assignee") + .assertThat().field("name").is("bpm_assignee") + .assertThat().field("type").is("cm:person") + .assertThat().field("value").is(assignee.getUsername()); + variables.getProcessVariableByName("bpm_sendEMailNotifications") + .assertThat().field("name").is("bpm_sendEMailNotifications") + .assertThat().field("type").is("d:boolean") + .assertThat().field("value").is(false); + variables.getProcessVariableByName("bpm_priority") + .assertThat().field("name").is("bpm_priority") + .assertThat().field("type").is("d:int") + .assertThat().field("value").is(CMISUtil.Priority.Normal.getLevel()); + } + + @Bug(id = "MNT-17438") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify get all process variables with valid skip count parameter applied.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void getProcessVariablesWithValidSkipCount() throws Exception + { + variables = restClient.authenticateUser(admin).withWorkflowAPI().usingProcess(processModel).getProcessVariables(); + restClient.assertStatusCodeIs(HttpStatus.OK); + variables.assertThat().entriesListIsNotEmpty(); + + RestProcessVariableCollection variablesSkipped = restClient.authenticateUser(admin).withParams("skipCount=2").withWorkflowAPI().usingProcess(processModel).getProcessVariables(); + restClient.assertStatusCodeIs(HttpStatus.OK); + variablesSkipped + .assertThat().entriesListDoesNotContain("name", variables.getEntries().get(0).onModel().getName()) + .assertThat().entriesListDoesNotContain("name", variables.getEntries().get(1).onModel().getName()) + .assertThat().entriesListCountIs(variables.getEntries().size()-2) + .assertThat().paginationField("skipCount").is("2"); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify get all process variables with negative skip count parameter applied.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void getProcessVariablesWithNegativeSkipCount() throws Exception + { + restClient.authenticateUser(admin).withParams("skipCount=-2").withWorkflowAPI().usingProcess(processModel).getProcessVariables(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT) + .containsErrorKey(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE) + .statusCodeIs(HttpStatus.BAD_REQUEST); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify get all process variables with not numeric skip count parameter applied.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void getProcessVariablesWithNonNumericSkipCount() throws Exception + { + restClient.authenticateUser(admin).withParams("skipCount=A").withWorkflowAPI().usingProcess(processModel).getProcessVariables(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "A")); + } + + @Bug(id = "MNT-17438") + @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify get all process variables with valid maxItems parameter applied.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void getProcessVariablesWithValidMaxItems() throws Exception + { + variables = restClient.authenticateUser(admin).withWorkflowAPI().usingProcess(processModel).getProcessVariables(); + restClient.assertStatusCodeIs(HttpStatus.OK); + variables.assertThat().entriesListIsNotEmpty(); + + RestProcessVariableCollection variablesSkipped = restClient.authenticateUser(admin).withParams("maxItems=2").withWorkflowAPI().usingProcess(processModel).getProcessVariables(); + restClient.assertStatusCodeIs(HttpStatus.OK); + variablesSkipped + .assertThat().entriesListContains("name", variables.getEntries().get(0).onModel().getName()) + .assertThat().entriesListContains("name", variables.getEntries().get(1).onModel().getName()) + .assertThat().entriesListCountIs(2) + .assertThat().paginationField("maxItems").is("2"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify get all process variables with negative maxItems parameter applied.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void getProcessVariablesWithNegativeMaxItems() throws Exception + { + restClient.authenticateUser(admin).withParams("maxItems=-2").withWorkflowAPI().usingProcess(processModel).getProcessVariables(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) + .containsErrorKey(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE) + .statusCodeIs(HttpStatus.BAD_REQUEST); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify get all process variables with not numeric maxItems parameter applied.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void getProcessVariablesWithNonNumericMaxItems() throws Exception + { + restClient.authenticateUser(admin).withParams("maxItems=A").withWorkflowAPI().usingProcess(processModel).getProcessVariables(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "A")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify get all process variables with properties parameter.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void getProcessVariablesWithPropertiesParameter() throws Exception + { + variables = restClient.authenticateUser(admin).withParams("properties=name").withWorkflowAPI().usingProcess(processModel).getProcessVariables(); + restClient.assertStatusCodeIs(HttpStatus.OK); + variables.assertThat().entriesListIsNotEmpty(); + variables.getProcessVariableByName("initiator") + .assertThat().field("name").is("initiator") + .assertThat().field("type").isNull() + .assertThat().field("value").isNull() + .assertThat().fieldsCount().is(1); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/GetProcessVariablesSanityTests.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/GetProcessVariablesSanityTests.java new file mode 100644 index 000000000..9cb56b95f --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/GetProcessVariablesSanityTests.java @@ -0,0 +1,60 @@ +package org.alfresco.rest.workflow.processes.variables; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestProcessVariableCollection; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.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 GetProcessVariablesSanityTests extends RestTest +{ + private FileModel document; + private SiteModel siteModel; + private UserModel userWhoStartsTask, assignee; + private RestProcessModel processModel; + private RestProcessVariableCollection variables; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + userWhoStartsTask = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Verify that user that started the process gets all process variables") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) + public void getProcessVariablesUsingTheUserWhoStartedProcess() throws JsonToModelConversionException, Exception + { + processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + variables = restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables(); + restClient.assertStatusCodeIs(HttpStatus.OK); + variables.assertThat().entriesListIsNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + description = "Verify get all process variables call using a user that is involved in the process") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) + public void getProcessVariablesUsingUserInvolvedInProcess() throws JsonToModelConversionException, Exception + { + processModel = restClient.authenticateUser(assignee).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + variables = restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables(); + restClient.assertStatusCodeIs(HttpStatus.OK); + variables.assertThat().entriesListIsNotEmpty(); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/UpdateProcessVariableTests.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/UpdateProcessVariableTests.java new file mode 100644 index 000000000..140966bce --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/UpdateProcessVariableTests.java @@ -0,0 +1,139 @@ +package org.alfresco.rest.workflow.processes.variables; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestProcessVariableModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + + +public class UpdateProcessVariableTests extends RestTest +{ + private FileModel document; + private SiteModel siteModel; + private UserModel userWhoStartsProcess, assignee; + private RestProcessModel processModel; + private RestProcessVariableModel variableModel, updatedVariable; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + userWhoStartsProcess = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userWhoStartsProcess).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Update existing variable using PUT call - invalid type") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void updateProcessVariableInvalidType() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + variableModel.setType("dd"); + + updatedVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsErrorKey(String.format(RestErrorModel.UNSUPPORTED_TYPE, "dd")) + .containsSummary(String.format(RestErrorModel.UNSUPPORTED_TYPE, "dd")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Update existing variable using PUT call - invalid type") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void updateProcessVariableTwoUsers() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:any"); + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + variableModel.setType("d:text"); + updatedVariable = restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(processModel) + .updateProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedVariable.assertThat().field("type").is("d:text"); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Update existing variable using PUT call - value") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) + public void updateProcessVariableValue() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + variableModel.setValue("newValue"); + + updatedVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedVariable.assertThat().field("value").is("newValue"); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Update existing variable using PUT call - name") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) + public void updateProcessVariableName() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + variableModel.setName("newVariableName"); + + updatedVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedVariable.assertThat().field("name").is("newVariableName"); + } + + @TestRail(section = {TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Update existing variable created by the user who started the process using put call with a user that is not involved in the process- value") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) + public void cantUpdateProcessVariableValueCreatedWithAnyUser() throws Exception + { + UserModel anotherUser = dataUser.createRandomTestUser(); + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + variableModel.setValue("newValue"); + + restClient.authenticateUser(anotherUser).withWorkflowAPI().usingProcess(processModel) + .updateProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(String.format(RestErrorModel.ACCESS_INFORMATION_NOT_ALLOWED, processModel.getId())); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Try to add process variable using an invalid processId") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) + public void updateProcessVariableUsingInvalidProcessId() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + processModel.setId("abc"); + + restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "abc")); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelTests.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelTests.java new file mode 100644 index 000000000..dec930fdb --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelTests.java @@ -0,0 +1,256 @@ +package org.alfresco.rest.workflow.tasks; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.*; +import org.alfresco.utility.model.*; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Created by Claudia Agache on 2/3/2017. + */ +public class GetTaskFormModelTests extends RestTest +{ + UserModel userModel, adminUser; + SiteModel siteModel; + FileModel fileModel; + TaskModel taskModel; + RestFormModelsCollection returnedCollection; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + fileModel = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, + executionType = ExecutionType.SANITY, description = "Verify admin user gets all task form models with Rest API and response is successful (200)") + public void adminGetsTaskFormModels() throws Exception + { + taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(userModel); + returnedCollection = restClient.authenticateUser(dataUser.getAdminUser()).withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat().entriesListIsNotEmpty(); + + String[] qualifiedNames = { + "{http://www.alfresco.org/model/bpm/1.0}percentComplete", + "{http://www.alfresco.org/model/bpm/1.0}context", + "{http://www.alfresco.org/model/bpm/1.0}completedItems", + "{http://www.alfresco.org/model/content/1.0}name", + "{http://www.alfresco.org/model/bpm/1.0}packageActionGroup", + "{http://www.alfresco.org/model/bpm/1.0}reassignable", + "{http://www.alfresco.org/model/content/1.0}owner", + "{http://www.alfresco.org/model/bpm/1.0}outcome", + "{http://www.alfresco.org/model/bpm/1.0}taskId", + "{http://www.alfresco.org/model/bpm/1.0}packageItemActionGroup", + "{http://www.alfresco.org/model/bpm/1.0}completionDate"}; + + for(String formQualifiedName : qualifiedNames) + { + returnedCollection.assertThat().entriesListContains("qualifiedName", formQualifiedName); + } + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, + executionType = ExecutionType.SANITY, description = "Verify user involved in task gets all the task form models with Rest API and response is successful (200)") + public void involvedUserGetsTaskFormModels() throws Exception + { + taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(userModel); + returnedCollection = restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat().entriesListIsNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, + executionType = ExecutionType.REGRESSION, + description = "Verify that non involved user in task cannot get form models with Rest API and response is FORBIDDEN (403)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void nonInvolvedUserCannotGetTaskFormModels() throws Exception + { + taskModel = dataWorkflow.usingUser(userModel) + .usingSite(siteModel) + .usingResource(fileModel).createNewTaskAndAssignTo(userModel); + UserModel nonInvolvedUser = dataUser.createRandomTestUser(); + restClient.authenticateUser(nonInvolvedUser); + restClient.withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, + executionType = ExecutionType.REGRESSION, + description = "Verify user involved in task cannot get task form models with invalid task id") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void getTaskFormModelsInvalidTaskId() throws Exception + { + taskModel = dataWorkflow.usingUser(userModel) + .usingSite(siteModel) + .usingResource(fileModel).createNewTaskAndAssignTo(userModel); + taskModel.setId("0000"); + restClient.authenticateUser(userModel); + restClient.withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "0000")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, + executionType = ExecutionType.REGRESSION, + description = "Verify user involved in task cannot get task form models with invalid task id") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void getTaskFormModelsEmptyTaskId() throws Exception + { + taskModel = dataWorkflow.usingUser(userModel) + .usingSite(siteModel) + .usingResource(fileModel).createNewTaskAndAssignTo(userModel); + taskModel.setId(""); + restClient.authenticateUser(userModel); + restClient.withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, + executionType = ExecutionType.REGRESSION, + description = "Verify user involved in task can get completed task form models") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void getTaskFormModelsForCompletedTask() throws Exception + { + UserModel assignedUser = dataUser.createRandomTestUser(); + taskModel = dataWorkflow.usingUser(userModel) + .usingSite(siteModel) + .usingResource(fileModel).createNewTaskAndAssignTo(assignedUser); + dataWorkflow.usingUser(assignedUser).taskDone(taskModel); + dataWorkflow.usingUser(userModel).taskDone(taskModel); + restClient.authenticateUser(userModel); + returnedCollection = restClient.withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat().entriesListIsNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, + executionType = ExecutionType.REGRESSION, description = "Verify admin user gets all task form models with properties parameter applied and response is successful (200)") + public void adminGetsTaskFormModelsWithPropertiesParameter() throws Exception + { + taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(userModel); + returnedCollection = restClient.authenticateUser(adminUser).withParams("properties=qualifiedName,required").withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat().entriesListIsNotEmpty(); + returnedCollection.getOneRandomEntry().onModel() + .assertThat() + .field("qualifiedName").isNotEmpty().and() + .field("required").isNotEmpty().and() + .field("dataType").isNull().and() + .field("name").isNull().and() + .field("title").isNull().and() + .field("defaultValue").isNull().and() + .field("allowedValues").isNull().and() + .fieldsCount().is(2); + } + + @Bug(id = "MNT-17438") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify admin gets task form model with valid skipCount parameter applied using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void getTaskFormModelWithValidSkipCount() throws Exception + { + taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(userModel); + returnedCollection = restClient.authenticateUser(adminUser) + .withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); + restClient.assertStatusCodeIs(HttpStatus.OK); + RestFormModel firstTaskFormModel = returnedCollection.getEntries().get(0).onModel(); + RestFormModel secondTaskFormModel = returnedCollection.getEntries().get(1).onModel(); + + RestFormModelsCollection formModelsWithSkipCount = restClient.withParams("skipCount=2").withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); + restClient.assertStatusCodeIs(HttpStatus.OK); + formModelsWithSkipCount + .assertThat().entriesListDoesNotContain("name", firstTaskFormModel.getName()) + .assertThat().entriesListDoesNotContain("name", secondTaskFormModel.getName()) + .assertThat().entriesListCountIs(returnedCollection.getEntries().size()-2); + formModelsWithSkipCount.assertThat().paginationField("skipCount").is("2"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify admin doesn't get task form model with negative skipCount parameter applied using REST API") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void getTaskFormModelWithNegativeSkipCount() throws Exception + { + taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(userModel); + restClient.authenticateUser(adminUser).withParams("skipCount=-1").withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT) + .containsErrorKey(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE) + .statusCodeIs(HttpStatus.BAD_REQUEST); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify admin doesn't get task form model with non numeric skipCount parameter applied using REST API") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void getTaskFormModelWithNonNumericSkipCount() throws Exception + { + taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(userModel); + restClient.authenticateUser(adminUser).withParams("skipCount=A").withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "A")); + } + + @Bug(id = "MNT-17438") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify admin gets task form model with valid maxItems parameter applied using REST API and status code is OK (200)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void getTaskFormModelWithValidMaxItems() throws Exception + { + taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(userModel); + returnedCollection = restClient.authenticateUser(adminUser) + .withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); + restClient.assertStatusCodeIs(HttpStatus.OK); + RestFormModel firstTaskFormModel = returnedCollection.getEntries().get(0).onModel(); + RestFormModel secondTaskFormModel = returnedCollection.getEntries().get(1).onModel(); + + RestFormModelsCollection formModelsWithMaxItems = restClient.withParams("maxItems=2").withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); + restClient.assertStatusCodeIs(HttpStatus.OK); + formModelsWithMaxItems + .assertThat().entriesListContains("name", firstTaskFormModel.getName()) + .assertThat().entriesListContains("name", secondTaskFormModel.getName()) + .assertThat().entriesListCountIs(2); + formModelsWithMaxItems.assertThat().paginationField("maxItems").is("2"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify admin doesn't get task form model with negative maxItems parameter applied using REST API") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void getTaskFormModelWithNegativeMaxItems() throws Exception + { + taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(userModel); + restClient.authenticateUser(adminUser).withParams("maxItems=-1").withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) + .containsErrorKey(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE) + .statusCodeIs(HttpStatus.BAD_REQUEST); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify admin doesn't get task form model with non numeric maxItems parameter applied using REST API") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void getTaskFormModelWithNonNumericMaxItems() throws Exception + { + taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(userModel); + restClient.authenticateUser(adminUser).withParams("maxItems=A").withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "A")); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/GetTaskTests.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/GetTaskTests.java new file mode 100644 index 000000000..1aec76b5d --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/GetTaskTests.java @@ -0,0 +1,212 @@ +package org.alfresco.rest.workflow.tasks; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestTaskModel; +import org.alfresco.rest.model.RestTaskModelsCollection; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.GroupModel; +import org.alfresco.utility.model.ProcessModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TaskModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.apache.commons.lang3.RandomStringUtils; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +/** + * + * @author Cristina Axinte + * + */ +public class GetTaskTests extends RestTest +{ + UserModel userModel, assigneeUser; + UserModel adminTenantUser, tenantUser, tenantUserAssignee, adminUser; + SiteModel siteModel; + FileModel fileModel; + TaskModel taskModel; + RestTaskModel restTaskModel, tenantTask; + RestTaskModelsCollection taskModels; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + assigneeUser = dataUser.createRandomTestUser(); + } + + @BeforeMethod(alwaysRun=true) + public void createTask() throws Exception + { + taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify admin user gets any existing task with Rest API and response is successfull (200)") + public void adminUserGetsAnyTaskWithSuccess() throws Exception + { + restTaskModel = restClient.authenticateUser(adminUser).withWorkflowAPI().usingTask(taskModel).getTask(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("description").is(taskModel.getMessage()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify assignee user gets its assigned task with Rest API and response is successfull (200)") + public void assigneeUserGetsItsTaskWithSuccess() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser).withWorkflowAPI().usingTask(taskModel).getTask(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("description").is(taskModel.getMessage()).and().field("assignee") + .is(assigneeUser.getUsername()); + + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify user that started the task gets the started task with Rest API and response is successfull (200)") + public void starterUserGetsItsTaskWithSuccess() throws Exception + { + restTaskModel = restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).getTask(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("description").is(taskModel.getMessage()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify any user with no relation to task id forbidden to get other task with Rest API (403)") + public void anyUserIsForbiddenToGetOtherTask() throws Exception + { + UserModel anyUser = dataUser.createRandomTestUser(); + + restTaskModel = restClient.authenticateUser(anyUser).withWorkflowAPI().usingTask(taskModel).getTask(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify candidate user gets its specific task and no other user claimed the task with Rest API and response is successfull (200)") + public void candidateUserGetsItsTasks() throws Exception + { + UserModel userModel1 = dataUser.createRandomTestUser(); + UserModel userModel2 = dataUser.createRandomTestUser(); + GroupModel group = dataGroup.createRandomGroup(); + dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); + TaskModel taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); + + restTaskModel = restClient.authenticateUser(userModel1).withWorkflowAPI().usingTask(taskModel).getTask(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("description").is(taskModel.getMessage()); + + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @Bug(id = "MNT-17051") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify involved user in a task without claim it gets the task with Rest API and response is successfull (200)") + public void involvedUserWithoutClaimTaskGetsTask() throws Exception + { + UserModel userModel1 = dataUser.createRandomTestUser(); + UserModel userModel2 = dataUser.createRandomTestUser(); + GroupModel group = dataGroup.createRandomGroup(); + dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); + TaskModel taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); + dataWorkflow.usingUser(userModel1).claimTask(taskModel); + + restTaskModel = restClient.authenticateUser(userModel2).withWorkflowAPI().usingTask(taskModel).getTask(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("description").is(taskModel.getMessage()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, + executionType = ExecutionType.REGRESSION, description = "Verify user who started a task gets the task with empty taskId with Rest API") + public void starterUserGetsTaskWithEmptyTaskId() throws Exception + { + UserModel userWhoStartsTask = dataUser.createRandomTestUser(); + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(userWhoStartsTask); + + restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI(); + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "tasks/{taskId}", ""); + RestTaskModelsCollection tasks = restClient.processModels(RestTaskModelsCollection.class, request); + + restClient.assertStatusCodeIs(HttpStatus.OK); + tasks.assertThat().entriesListIsNotEmpty() + .and().entriesListCountIs(1) + .and().entriesListContains("id", taskModel.getId()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, + executionType = ExecutionType.REGRESSION, description = "Verify user who started a task gets the task with properties parameter with Rest API") + public void starterUserGetsTaskWithPropertiesParameter() throws Exception + { + restTaskModel = restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).usingParams("properties=id,assignee,formResourceKey").getTask(); + + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().fieldsCount().is(3) + .and().field("id").is(taskModel.getId()) + .and().field("assignee").is(taskModel.getAssignee()) + .and().field("formResourceKey").is("wf:adhocTask") + .and().field("processDefinitionId").isNull() + .and().field("processId").isNull(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, + executionType = ExecutionType.REGRESSION, description = "Verify user who started a task gets the task after it is deleted with Rest API") + public void starterUserGetsDeletedTask() throws Exception + { + restTaskModel = restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).getTask(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()); + + ProcessModel process = new ProcessModel(); + process.setId(taskModel.getProcessId()); + dataWorkflow.usingUser(userModel).deleteProcess(process); + + restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).getTask(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, taskModel.getId())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify if using invalid taskId status code 404 is returned.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void invalidTaskId() throws Exception + { + taskModel.setId(RandomStringUtils.randomAlphanumeric(20)); + restTaskModel = restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).getTask(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, taskModel.getId())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify if using empty taskId status code 200 is returned.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void emptyTaskId() throws Exception + { + restClient.authenticateUser(userModel).withWorkflowAPI(); + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "tasks/{taskId}", ""); + taskModels = restClient.processModels(RestTaskModelsCollection.class, request); + restClient.assertStatusCodeIs(HttpStatus.OK); + taskModels.assertThat().entriesListIsNotEmpty(); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/GetTasksTests.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/GetTasksTests.java new file mode 100644 index 000000000..eb28d7c31 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/GetTasksTests.java @@ -0,0 +1,234 @@ +package org.alfresco.rest.workflow.tasks; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.dataprep.CMISUtil.Priority; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestTaskModel; +import org.alfresco.rest.model.RestTaskModelsCollection; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.GroupModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TaskModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class GetTasksTests extends RestTest +{ + UserModel userModel, userNotInvolved, assigneeUser, adminUser; + UserModel adminTenantUser, tenantUser, tenantUserAssignee; + SiteModel siteModel; + FileModel fileModel; + RestTaskModelsCollection taskModels, taskCollections, tenantTask; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userModel = dataUser.createRandomTestUser(); + userNotInvolved = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + + assigneeUser = dataUser.createRandomTestUser(); + dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify admin user gets all existing tasks with Rest API and response is successfull (200)") + public void adminUserGetsAllTasks() throws Exception + { + UserModel adminUser = dataUser.getAdminUser(); + + taskModels = restClient.authenticateUser(adminUser).withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + taskModels.assertThat().entriesListIsNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify asignee user gets its existing tasks with Rest API and response is successfull (200)") + public void assigneeUserGetsItsTasks() throws Exception + { + taskModels = restClient.authenticateUser(assigneeUser).withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + taskModels.assertThat().entriesListIsNotEmpty().and().entriesListCountIs(1).and().entriesListContains("assignee", assigneeUser.getUsername()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify candidate user that claims the task gets its existing tasks with Rest API and response is successfull (200)") + @Bug(id = "MNT-16967") + public void candidateUserGetsItsTasks() throws Exception + { + UserModel userModel1 = dataUser.createRandomTestUser(); + UserModel userModel2 = dataUser.createRandomTestUser(); + GroupModel group = dataGroup.createRandomGroup(); + + dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); + dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); + + taskModels = restClient.authenticateUser(userModel1).withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + taskModels.assertThat().entriesListIsNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify candidate user that claims the task gets its existing tasks with Rest API and response is successfull (200)") + public void candidateUserThatClaimsTaskGetsItsTasks() throws Exception + { + UserModel userModel1 = dataUser.createRandomTestUser(); + UserModel userModel2 = dataUser.createRandomTestUser(); + GroupModel group = dataGroup.createRandomGroup(); + dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); + TaskModel taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); + dataWorkflow.usingUser(userModel1).claimTask(taskModel); + + taskModels = restClient.authenticateUser(userModel1).withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + taskModels.assertThat().entriesListIsNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify candidate user without claim gets no tasks with Rest API and response is successfull (200)") + public void candidateUserWithoutClaimTaskGetsNoTasks() throws Exception + { + UserModel userModel1 = dataUser.createRandomTestUser(); + UserModel userModel2 = dataUser.createRandomTestUser(); + GroupModel group = dataGroup.createRandomGroup(); + + dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); + TaskModel taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); + dataWorkflow.usingUser(userModel1).claimTask(taskModel); + + taskModels = restClient.authenticateUser(userModel2).withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + taskModels.assertThat().entriesListIsEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check that skipCount parameter is applied.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void skipCountParameterApplied() throws Exception + { + taskCollections = restClient.authenticateUser(dataUser.getAdminUser()).withParams("orderBy=description ASC").withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + RestTaskModel firstTask = taskCollections.getEntries().get(0).onModel(); + RestTaskModel secondTask = taskCollections.getEntries().get(1).onModel(); + + taskModels = restClient.withParams("orderBy=description ASC&skipCount=2").withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + taskModels.assertThat().entriesListDoesNotContain("id", firstTask.getId()) + .assertThat().entriesListDoesNotContain("id", secondTask.getId()); + taskModels.assertThat().paginationField("skipCount").is("2"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check that maxItems parameter is applied.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void maxItemsParameterApplied() throws Exception + { + restClient.authenticateUser(userModel).withWorkflowAPI().addProcess("activitiAdhoc", assigneeUser, false, Priority.Low); + restClient.authenticateUser(userModel).withWorkflowAPI().addProcess("activitiAdhoc", adminUser, false, Priority.Low); + taskCollections = restClient.authenticateUser(userModel).withParams("orderBy=assignee ASC").withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + taskModels = restClient.withParams("orderBy=startedAt DESC&maxItems=2").withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + taskModels.assertThat().entriesListIsNotEmpty() + .assertThat().entriesListContains("assignee", assigneeUser.getUsername()) + .assertThat().entriesListDoesNotContain("assignee", userModel.getUsername()); + taskModels.assertThat().paginationField("maxItems").is("2"); + taskModels.assertThat().paginationField("count").is("2"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check that properties parameter is applied.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void propertiesParameterApplied() throws Exception + { + taskModels = restClient.authenticateUser(dataUser.getAdminUser()).withParams("properties=name,description").withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + taskModels.assertThat().entriesListIsNotEmpty() + .assertThat().entriesListContains("name") + .assertThat().entriesListContains("description") + .assertThat().entriesListDoesNotContain("processDefinitionId") + .assertThat().entriesListDoesNotContain("processId") + .assertThat().entriesListDoesNotContain("startedAt") + .assertThat().entriesListDoesNotContain("id") + .assertThat().entriesListDoesNotContain("state") + .assertThat().entriesListDoesNotContain("activityDefinitionId") + .assertThat().entriesListDoesNotContain("priority") + .assertThat().entriesListDoesNotContain("formResourceKey"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Use invalid where parameter. Check default error model schema.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void invalidWhereParameterCheckDefaultErrorModelSchema() throws Exception + { + restClient.authenticateUser(dataUser.getAdminUser()).where("assignee AND '" + assigneeUser.getUsername() + "'").withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(RestErrorModel.INVALID_QUERY_ERRORKEY) + .containsSummary(String.format(RestErrorModel.INVALID_WHERE_QUERY, "(assignee AND '" + assigneeUser.getUsername() + "')")) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify the request in case of any user which is not involved.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void requestWithUserNotInvolved() throws Exception + { + taskModels = restClient.authenticateUser(userNotInvolved).withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + taskModels.assertThat().entriesListIsEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check that orderBy parameter is applied.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void orderByParameterApplied() throws Exception + { + taskModels = restClient.authenticateUser(dataUser.getAdminUser()).withParams("orderBy=id").withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + taskModels.assertThat().entriesListIsNotEmpty(). + and().entriesListIsSortedAscBy("id"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check that orderBy parameter is applied and supports only one parameter.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void orderByParameterSupportsOnlyOneParameter() throws Exception + { + taskModels = restClient.authenticateUser(dataUser.getAdminUser()).withParams("orderBy=id,processDefinitionId").withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Only one order by parameter is supported"); + taskModels.assertThat().entriesListIsEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check that where parameter is applied.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void whereParameterApplied() throws Exception + { + UserModel anotherAssignee = dataUser.createRandomTestUser(); + dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(anotherAssignee); + taskModels = restClient.authenticateUser(dataUser.getAdminUser()).withParams("where=(assignee='" + anotherAssignee.getUsername() + "')").withWorkflowAPI() + .getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + taskModels.assertThat().entriesListIsNotEmpty().and().entriesListContains("assignee", anotherAssignee.getUsername()).and().entriesListCountIs(1); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check that invalid orderBy parameter applied returns 400 status code.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void invalidOrderByParameterApplied() throws Exception + { + restClient.authenticateUser(dataUser.getAdminUser()).withParams("orderBy=invalidParameter").withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("invalidParameter is not supported"); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/UpdateTaskTests.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/UpdateTaskTests.java new file mode 100644 index 000000000..6f069d2ff --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/UpdateTaskTests.java @@ -0,0 +1,1639 @@ +package org.alfresco.rest.workflow.tasks; + +import java.util.HashMap; + +import javax.json.JsonObject; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.JsonBodyGenerator; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestProcessDefinitionModel; +import org.alfresco.rest.model.RestTaskModel; +import org.alfresco.rest.model.RestVariableModelsCollection; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.GroupModel; +import org.alfresco.utility.model.ProcessModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TaskModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +public class UpdateTaskTests extends RestTest +{ + UserModel owner, anyUser; + SiteModel siteModel; + FileModel fileModel; + UserModel assigneeUser; + TaskModel taskModel; + RestTaskModel restTaskModel; + UserModel adminUser; + RestProcessDefinitionModel activitiReviewProcessDefinition; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + owner = dataUser.createRandomTestUser(); + anyUser = dataUser.createRandomTestUser(); + assigneeUser = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); + fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + activitiReviewProcessDefinition = restClient.authenticateUser(adminUser).withWorkflowAPI().getAllProcessDefinitions().getProcessDefinitionByKey("activitiReviewPooled"); + } + + @BeforeMethod(alwaysRun = true) + public void createTask() throws Exception + { + taskModel = dataWorkflow.usingUser(owner).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify admin user updates task with Rest API and response is successfull (200)") + public void adminUserUpdatesAnyTaskWithSuccess() throws Exception + { + restTaskModel = restClient.authenticateUser(adminUser).withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("description").is(taskModel.getMessage()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify assignee user updates its assigned task with Rest API and response is successfull (200)") + public void assigneeUserUpdatesItsTaskWithSuccess() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser).withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("description").is(taskModel.getMessage()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify user that started the task updates the started task with Rest API and response is successfull (200)") + public void starterUserUpdatesItsTaskWithSuccess() throws Exception + { + restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify any user with no relation to task is forbidden to update other task with Rest API (403)") + public void anyUserIsForbiddenToUpdateOtherTask() throws Exception + { + restTaskModel = restClient.authenticateUser(anyUser).withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify candidate user updates its specific task and no other user claimed the task with Rest API and response is successfull (200)") + public void candidateUserUpdatesItsTasks() throws Exception + { + UserModel userModel1 = dataUser.createRandomTestUser(); + UserModel userModel2 = dataUser.createRandomTestUser(); + GroupModel group = dataGroup.createRandomGroup(); + dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); + TaskModel taskModel = dataWorkflow.usingUser(owner).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); + + restTaskModel = restClient.authenticateUser(userModel1).withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat() + .field("dueAt").isNotEmpty() + .and().field("processDefinitionId").is(activitiReviewProcessDefinition.getId()) + .and().field("processId").is(taskModel.getProcessId()) + .and().field("name").is("Review Task") + .and().field("description").is(taskModel.getMessage()) + .and().field("startedAt").isNotEmpty() + .and().field("id").is(taskModel.getId()) + .and().field("state").is("unclaimed") + .and().field("activityDefinitionId").is("reviewTask") + .and().field("priority").is(taskModel.getPriority().getLevel()) + .and().field("formResourceKey").is("wf:activitiReviewTask"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task owner can update twice task with status resolve successfully (200)") + public void taskOwnerCanUpdateTaskWithResolveStateTwice() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("resolved"); + + restClient.authenticateUser(owner) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task asignee cannot update twice task with status resolve - Forbidden (403)") + public void taskAssigneeCanNotUpdateTaskWithResolveStateTwice() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("resolved"); + + restClient.authenticateUser(assigneeUser) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task cannot be update using a invalid json body property - Bad Request (400)") + public void taskCanNotBeUpdatedWithInvalidJsonBodyProperty() throws Exception + { + String invalidJsonProperty= "states"; + restClient.authenticateUser(assigneeUser) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel); + String postBody = JsonBodyGenerator.keyValueJson(invalidJsonProperty, "completed"); + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); + restClient.processModel(RestTaskModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.NO_CONTENT, "Unrecognized field \""+invalidJsonProperty+"\"")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task cannot be update using a invalid state - Bad Request (400)") + public void taskCanNotBeUpdatedWithInvalidState() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("continued"); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_VALUE, "task state", "continued")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task cannot be update using a invalid property - Bad Request (400)") + public void taskCanNotBeUpdatedWithInvalidSelectProperty() throws Exception + { + String invalidProperty= "states"; + restClient.authenticateUser(assigneeUser) + .withParams("select=" + invalidProperty).withWorkflowAPI().usingTask(taskModel); + String postBody = JsonBodyGenerator.keyValueJson("state", "completed"); + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); + restClient.processModel(RestTaskModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.PROPERTY_DOES_NOT_EXIST, invalidProperty)); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task can be update using multiple select values successfully (200)") + public void taskCanBeUpdatedWithMultipleSelectValues() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("state", "resolved") + .add("assignee", "admin").build(); + + restTaskModel = restClient.authenticateUser(assigneeUser) + .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("resolved"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Verify task assignee can complete task successfully (200)") + public void taskAssigneeCanCompleteTask() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("completed"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Verify task owner can complete task successfully (200))") + public void taskOwnerCanCompleteTask() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("completed"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify any user cannot complete task - Forbidden (403))") + public void anyUserCannotCompleteTask() throws Exception + { + UserModel anyUser = dataUser.createRandomTestUser(); + + restTaskModel = restClient.authenticateUser(anyUser) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @Bug(id = "REPO-2062") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task owner cannot complete task with invalid name - Bad Request(400))") + public void taskOwnerCannotCompleteTaskWithInvalidName() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("state", "completed") + .add("variables", JsonBodyGenerator.defineJSONArray() + .add(JsonBodyGenerator.defineJSON() + .add("name", "bpmx_priorityx") + .add("type", "d:int") + .add("value", 1) + .add("scope", "global").build()) + ).build(); + + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state,variables").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.UNSUPPORTED_TYPE,"bpm_priorityx")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task owner cannot complete task with invalid Type - Bad Request(400))") + public void taskOwnerCannotCompleteTaskWithInvalidType() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("state", "completed") + .add("variables", JsonBodyGenerator.defineJSONArray() + .add(JsonBodyGenerator.defineJSON() + .add("name", "bpmx_priority") + .add("type", "d_int") + .add("value", 1) + .add("scope", "global").build()) + ).build(); + + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state,variables").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.UNSUPPORTED_TYPE,"d_int")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @Bug(id = "REPO-2062") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task owner cannot complete task with invalid value - Bad Request(400))") + public void taskOwnerCannotCompleteTaskWithInvalidValue() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("state", "completed") + .add("variables", JsonBodyGenerator.defineJSONArray() + .add(JsonBodyGenerator.defineJSON() + .add("name", "bpmx_priority") + .add("type", "d:int") + .add("value", "text") + .add("scope", "global").build()) + ).build(); + + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state,variables").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.UNSUPPORTED_TYPE, "text")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task owner cannot complete task with invalid scope - Bad Request(400))") + public void taskOwnerCannotCompleteTaskWithInvalidScope() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("state", "completed") + .add("variables", JsonBodyGenerator.defineJSONArray() + .add(JsonBodyGenerator.defineJSON() + .add("name", "bpmx_priority") + .add("type", "d:int") + .add("value", 1) + .add("scope", "globalscope").build()) + ).build(); + + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state,variables").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.ILLEGAL_SCOPE, "globalscope")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task assignee can claim task successfully (200)") + public void taskAssigneeCanClaimTask() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("claimed"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task assignee can unclaim task successfully (200)") + public void taskAssigneeCanUnclaimTask() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("unclaimed"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task assignee can delegate task successfully (200)") + public void taskAssigneeCanDelegateTask() throws Exception + { + UserModel delagateToUser = dataUser.createRandomTestUser(); + + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("state", "delegated") + .add("assignee", delagateToUser.getUsername()).build(); + + restTaskModel = restClient.authenticateUser(assigneeUser) + .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("delegated") + .and().field("assignee").is(delagateToUser.getUsername()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task owner can delegate task to same assignee successfully (200)") + public void taskOwnerCanDelegateTaskToSameAssignee() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("state", "delegated") + .add("assignee", assigneeUser.getUsername()).build(); + + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("delegated") + .and().field("assignee").is(assigneeUser.getUsername()); + } + + + @Bug(id = "REPO-2063") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task assignee cannot delegate task to task owner - (400)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskAssigneeCannotDelegateTaskToTaskOwner() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("state", "delegated") + .add("assignee", owner.getUsername()).build(); + + restTaskModel = restClient.authenticateUser(assigneeUser) + .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @Bug(id = "REPO-2063") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task assignee cannot delegate task to invalid assignee - (400)") + public void taskAssigneeCannotDelegateTaskToInvalidAssignee() throws Exception + { + UserModel invalidAssignee = new UserModel("invalidAssignee", "password"); + + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("state", "delegated") + .add("assignee", invalidAssignee.getUsername()).build(); + + restTaskModel = restClient.authenticateUser(assigneeUser) + .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task assignee can update task with status resolve") + public void resolveTaskAsCurrentAssignee() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("resolved"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify update task using invalid taskId") + public void updateTaskUsingInvalidTaskId() throws Exception + { + taskModel.setId("invalidId"); + + restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidId")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify update task using another name") + public void updateTaskUsingAnotherName() throws Exception + { + restClient.authenticateUser(owner).withParams("select=name").withWorkflowAPI().usingTask(taskModel); + String postBody = "{\"name\":\"newNameTask\"}"; + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); + restTaskModel = restClient.processModel(RestTaskModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("name").is("newNameTask"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify update task using another description") + public void updateTaskUsingAnotherDescription() throws Exception + { + restClient.authenticateUser(owner).withParams("select=description").withWorkflowAPI().usingTask(taskModel); + String postBody = "{\"description\":\"newDescription\"}"; + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); + restTaskModel = restClient.processModel(RestTaskModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("description").is("newDescription"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify update task using another priority") + public void updateTaskUsingAnotherPriority() throws Exception + { + restClient.authenticateUser(owner).withParams("select=priority").withWorkflowAPI().usingTask(taskModel); + String postBody = "{\"priority\":3}"; + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); + restTaskModel = restClient.processModel(RestTaskModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("priority").is(CMISUtil.Priority.Low.getLevel()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify update task using another priority") + public void updateTaskUsingAnotherOwner() throws Exception + { + UserModel newOwner = dataUser.createRandomTestUser(); + + restClient.authenticateUser(owner).withParams("select=owner").withWorkflowAPI().usingTask(taskModel); + String postBody = "{\"owner\":\""+newOwner.getUsername()+"\"}"; + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); + restTaskModel = restClient.processModel(RestTaskModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("owner").is(newOwner.getUsername()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can not update task from completed to claimed and response is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskOwnerCanNotUpdateTaskFromCompletedToClaimed() throws Exception + { + restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("completed"); + restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() + .containsSummary(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can not update task from completed to unclaimed and response is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskOwnerCanNotUpdateTaskFromCompletedToUnclaimed() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("completed"); + restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() + .containsSummary(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can not update task from completed to completed and response is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskOwnerCanNotUpdateTaskWithCompleteStateTwice() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("completed"); + restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() + .containsSummary(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can update task from claimed to completed and response is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskOwnerCanUpdateTaskFromClaimedToCompleted() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("claimed"); + restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("completed"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify user can update task from claimed to claimed and response is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void userCanUpdateTaskWithClaimedStateTwice() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("claimed"); + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("claimed"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can update task from unclaimed to completed and response is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskOwnerCanUpdateTaskFromUnclaimedToCompleted() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); + restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("completed"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can not update task from unclaimed to unclaimed and response is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskOwnerCanNotUpdateTaskWithUnclaimedStateTwice() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); + restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); + } + + @Bug(id = "REPO-1924") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can not update task from delegated to completed and response is 422") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskOwnerCanNotUpdateTaskFromDelegatedToCompleted() throws Exception + { + restClient.authenticateUser(owner).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel); + HashMap body = new HashMap(); + body.put("state", "delegated"); + body.put("assignee", assigneeUser.getUsername()); + String postBody = JsonBodyGenerator.keyValueJson(body); + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), + restClient.getParameters()); + restTaskModel = restClient.processModel(RestTaskModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated").and().field("assignee") + .is(assigneeUser.getUsername()); + + restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(RestErrorModel.DELEGATED_TASK_CAN_NOT_BE_COMPLETED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can not update task from delegated to delegated and response is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskOwnerCanNotUpdateTaskWithDelegatedStateTwice() throws Exception + { + restClient.authenticateUser(owner).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel); + HashMap body = new HashMap(); + body.put("state", "delegated"); + body.put("assignee", assigneeUser.getUsername()); + String postBody = JsonBodyGenerator.keyValueJson(body); + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), + restClient.getParameters()); + restTaskModel = restClient.processModel(RestTaskModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated").and().field("assignee") + .is(assigneeUser.getUsername()); + + request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); + restTaskModel = restClient.processModel(RestTaskModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated").and().field("assignee") + .is(assigneeUser.getUsername()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can update task from resolved to completed and response is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskOwnerCanUpdateTaskFromResolvedToCompleted() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("resolved"); + + restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("completed"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify owner cannot update task from status completed to delegated and response is 404") + public void ownerCannotUpdateTaskFromCompletedToDelegated() throws Exception + { + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("completed"); + + restClient.authenticateUser(owner) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("delegated"); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() + .containsErrorKey(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) + .containsSummary(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify assignee cannot update task from status completed to delegated and response is 404") + public void assigneeCannotUpdateTaskFromCompletedToDelegated() throws Exception + { + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("completed"); + + restClient.authenticateUser(assigneeUser) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("delegated"); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() + .containsErrorKey(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) + .containsSummary(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify owner cannot update task from status completed to resolved and response is 404") + public void ownerCannotUpdateTaskFromCompletedToResolved() throws Exception + { + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("completed"); + + restClient.authenticateUser(owner) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() + .containsErrorKey(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) + .containsSummary(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify assignee cannot update task from status completed to resolved and response is 404") + public void assigneeCannotUpdateTaskFromCompletedToResolved() throws Exception + { + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("completed"); + + restClient.authenticateUser(assigneeUser) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() + .containsErrorKey(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) + .containsSummary(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify owner cannot update task from status completed to completed and response is 404") + public void ownerCannotUpdateTaskFromCompletedToCompleted() throws Exception + { + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("completed"); + + restClient.authenticateUser(owner) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() + .containsErrorKey(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) + .containsSummary(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify assignee cannot update task from status completed to completed and response is 404") + public void assigneeCannotUpdateTaskFromCompletedToCompleted() throws Exception + { + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("completed"); + + restClient.authenticateUser(assigneeUser) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() + .containsErrorKey(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) + .containsSummary(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify owner can update task from status claimed to unclaimed and response is 200") + public void ownerCanUpdateTaskFromClaimedToUnclaimed() throws Exception + { + restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).getTask(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("claimed"); + + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("unclaimed"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify assignee can update task from status claimed to unclaimed and response is 200") + public void assigneeCanUpdateTaskFromClaimedToUnclaimed() throws Exception + { + restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).getTask(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("claimed"); + + restTaskModel = restClient.authenticateUser(assigneeUser) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("unclaimed"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify owner can update task from status claimed to delegated and response is 200") + public void ownerCanUpdateTaskFromClaimedToDelegated() throws Exception + { + restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).getTask(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("claimed"); + + UserModel newAssignee = dataUser.createRandomTestUser(); + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("state", "delegated") + .add("assignee", newAssignee.getUsername()).build(); + + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("delegated") + .and().field("assignee").is(newAssignee.getUsername()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify assignee can update task from status claimed to delegated and response is 200") + public void assigneeCanUpdateTaskFromClaimedToDelegated() throws Exception + { + restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).getTask(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("claimed"); + + UserModel newAssignee = dataUser.createRandomTestUser(); + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("state", "delegated") + .add("assignee", newAssignee.getUsername()).build(); + + restTaskModel = restClient.authenticateUser(assigneeUser) + .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("delegated") + .and().field("assignee").is(newAssignee.getUsername()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify owner can update task from status claimed to resolved and response is 200") + public void ownerCanUpdateTaskFromClaimedToResolved() throws Exception + { + restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).getTask(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("claimed"); + + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("resolved"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify assignee can update task from status claimed to resolved and response is 200") + public void assigneeCanUpdateTaskFromClaimedToResolved() throws Exception + { + restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).getTask(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("claimed"); + + restTaskModel = restClient.authenticateUser(assigneeUser) + .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("resolved"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify owner cannot update task from status claimed to claimed and response is 409") + public void ownerCannotUpdateTaskFromClaimedToClaimed() throws Exception + { + restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).getTask(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("claimed"); + + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); + restClient.assertStatusCodeIs(HttpStatus.CONFLICT).assertLastError() + .containsErrorKey(RestErrorModel.TASK_ALREADY_CLAIMED) + .containsSummary(RestErrorModel.TASK_ALREADY_CLAIMED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify assignee can update task from status claimed to claimed and response is 200") + public void assigneeCanUpdateTaskFromClaimedToClaimed() throws Exception + { + restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).getTask(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("claimed"); + + restTaskModel = restClient.authenticateUser(assigneeUser) + .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("claimed"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task owner can complete task with valid variables and response is 200") + public void taskOwnerCanCompleteTaskWithValidVariables() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("state", "completed") + .add("variables", JsonBodyGenerator.defineJSONArray() + .add(JsonBodyGenerator.defineJSON() + .add("name", "bpm_priority") + .add("type", "d:int") + .add("value", 3) + .add("scope", "global").build()) + ).build(); + + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state,variables").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("priority").is(1) + .and().field("state").is("completed") + .and().field("assignee").is(taskModel.getAssignee()); + RestVariableModelsCollection variables = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(restTaskModel).getTaskVariables(); + restClient.assertStatusCodeIs(HttpStatus.OK); + variables.getVariableByName("bpm_priority").assertThat().field("scope").is("global") + .and().field("name").is("bpm_priority") + .and().field("type").is("d:int") + .and().field("value").is(3); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task owner cannot complete task with empty variables array and response is 200") + public void taskOwnerCannotUpdateTaskWithEmptyVariablesArray() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("state", "completed") + .add("variables", JsonBodyGenerator.defineJSONArray() + ).build(); + + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state,variables").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("priority").is(1) + .and().field("state").is("completed") + .and().field("assignee").is(taskModel.getAssignee()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task owner cannot complete task with empty variables json body and response is 200") + public void taskOwnerCannotUpdateTaskWithEmptyVariablesJsonBody() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("state", "completed") + .add("variables", JsonBodyGenerator.defineJSONArray() + .add(JsonBodyGenerator.defineJSON().build()) + ).build(); + + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state,variables").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(RestErrorModel.VARIABLE_NAME_REQUIRED) + .containsSummary(RestErrorModel.VARIABLE_NAME_REQUIRED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify any user with no relation to task is forbidden to delegate other task with Rest API (403)") + public void anyUserIsForbiddenToDelegateOtherTask() throws Exception + { + restTaskModel = restClient.authenticateUser(anyUser).withWorkflowAPI().usingTask(taskModel).updateTask("delegated"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify any user with no relation to task is forbidden to resolve other task with Rest API (403)") + public void anyUserIsForbiddenToResolveOtherTask() throws Exception + { + restTaskModel = restClient.authenticateUser(anyUser).withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify any user with no relation to task is forbidden to claim other task with Rest API (403)") + public void anyUserIsForbiddenToClaimOtherTask() throws Exception + { + restTaskModel = restClient.authenticateUser(anyUser).withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify any user with no relation to task is forbidden to unclaim other task with Rest API (403)") + public void anyUserIsForbiddenToUnclaimOtherTask() throws Exception + { + restTaskModel = restClient.authenticateUser(anyUser).withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify user cannot delegate task with emty assignee name and response is 400") + public void updateTaskWithEmptyAssigneeValue() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("state", "delegated") + .add("assignee", "") + .build(); + + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(RestErrorModel.DELEGATING_ASSIGNEE_PROVIDED) + .containsSummary(RestErrorModel.DELEGATING_ASSIGNEE_PROVIDED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify owner can resolve task when assignee is the owner and response is 200") + public void taskOwnerUpdateTaskResolveStateAndOwnerAssignee() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("state", "resolved") + .add("assignee", owner.getUsername()) + .build(); + + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("state").is("resolved") + .and().field("assignee").isNull(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify owner cannot update task after it was deleted and response is 404") + public void updateTaskAfterItWasDeleted() throws Exception + { + ProcessModel process = new ProcessModel(); + process.setId(taskModel.getProcessId()); + dataWorkflow.usingUser(owner).deleteProcess(process); + + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.ENTITY_WAS_NOT_FOUND, taskModel.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task owner cannot update task with empty input body and response is 400") + public void taskOwnerCannotUpdateTaskWithEmptyInputBody() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON().build(); + + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(String.format(RestErrorModel.TASK_INVALID_STATE, "null")) + .containsSummary(String.format(RestErrorModel.TASK_INVALID_STATE, "null")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify any user cannot update task using another name") + public void anyUserCannotUpdateTaskUsingAnotherName() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("name", "Review Task-updated") + .build(); + + restClient.authenticateUser(anyUser).withParams("select=name").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify any user cannot update task using another description") + public void anyUserCannotUpdateTaskUsingAnotherDescription() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("description", "description updated") + .build(); + + restClient.authenticateUser(anyUser).withParams("select=description").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify any user cannot update task using another dueAt") + public void anyUserCannotUpdateTaskUsingAnotherDueAt() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("dueAt", "2025-01-01T11:57:32.000+0000") + .build(); + + restClient.authenticateUser(anyUser).withParams("select=dueAt").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify any user cannot update task using another priority") + public void anyUserCannotUpdateTaskUsingAnotherPriority() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("priority", 3) + .build(); + + restClient.authenticateUser(anyUser).withParams("select=priority").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify any user cannot update task using another priority") + public void anyUserCannotUpdateTaskUsingAnotherOwner() throws Exception + { + UserModel newOwner = dataUser.createRandomTestUser(); + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("owner", newOwner.getUsername()) + .build(); + + + restClient.authenticateUser(anyUser).withParams("select=owner").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify any user cannot update task using invalid name") + public void anyUserCannotUpdateTaskUsingInvalidName() throws Exception + { + restClient.authenticateUser(owner).withParams("select=name").withWorkflowAPI().usingTask(taskModel); + String postBody = "{\"name\":\"invalid-\"a\"}"; + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); + restTaskModel = restClient.processModel(RestTaskModel.class, request); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "Unexpected character ('a'")) + .containsSummary(String.format(RestErrorModel.NO_CONTENT, "Unexpected character ('a'")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify any user cannot update task using invalid description") + public void anyUserCannotUpdateTaskUsingInvalidDescription() throws Exception + { + restClient.authenticateUser(owner).withParams("select=description").withWorkflowAPI().usingTask(taskModel); + String postBody = "{\"description\":\"invalid-\"a\"}"; + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); + restTaskModel = restClient.processModel(RestTaskModel.class, request); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "Unexpected character ('a'")) + .containsSummary(String.format(RestErrorModel.NO_CONTENT, "Unexpected character ('a'")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify any user cannot update task using invalid dueAt") + public void anyUserCannotUpdateTaskUsingInvalidDueAt() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("dueAt", "invalid-date") + .build(); + + restClient.authenticateUser(anyUser).withParams("select=dueAt").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify any user cannot update task using invalid priority") + public void anyUserCannotUpdateTaskUsingInvalidPriority() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("priority", "a") + .build(); + + restClient.authenticateUser(anyUser).withParams("select=priority").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify any user cannot update task using invalid priority") + public void anyUserCannotUpdateTaskUsingInvalidOwner() throws Exception + { + restClient.authenticateUser(owner).withParams("select=owner").withWorkflowAPI().usingTask(taskModel); + String postBody = "{\"owner\":\"invalid-\"a\"}"; + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); + restTaskModel = restClient.processModel(RestTaskModel.class, request); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "Unexpected character ('a'")) + .containsSummary(String.format(RestErrorModel.NO_CONTENT, "Unexpected character ('a'")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from unclaimed to claimed by task creator") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskCreatorCanUpdateTaskFromUnclaimedToClaimed() throws Exception + { + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); + restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("claimed"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task cannot be updated from unclaimed to claimed by a regular user not connected to the task") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void regularUserCannotUpdateTaskFromUnclaimedToClaimed() throws Exception + { + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from unclaimed to delegated by task creator") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskCreatorCanUpdateTaskFromUnclaimedToDelegated() throws Exception + { + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); + + JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", owner.getUsername()).build(); + + restTaskModel = restClient.authenticateUser(owner).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task cannot be updated from unclaimed to delegated by a regular user not connected to the task") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void regularUserCannotUpdateTaskFromUnclaimedToDelegated() throws Exception + { + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); + + JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); + + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from unclaimed to resolved by task creator") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskCreatorCanUpdateTaskFromUnclaimedToResolved() throws Exception + { + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); + restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("resolved"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from unclaimed to resolved by a regular user not connected to the task") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void regularCanNotUpdateTaskFromUnclaimedToResolved() throws Exception + { + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from unclaimed to unclaimed by task creator") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskCreatorCanUpdateTaskFromUnclaimedToUnclaimed() throws Exception + { + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); + restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from unclaimed to unclaimed by a regular user not connected to the task") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void regularUserCannotUpdateTaskFromUnclaimedToUnclaimed() throws Exception + { + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Bug(id = "REPO-1982") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from delegated to unclaimed by task creator") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskCreatorCanUpdateTaskFromDelegatedToUnclaimed() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); + + restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); + } + + @Bug(id = "REPO-1982") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from delegated to unclaimed by task assignee") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskAssigneeCanUpdateTaskFromDelegatedToUnclaimed() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); + + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task cannot be updated from delegated to claimed since it is already claimed by task creator") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskCreatorCannotUpdateTaskFromDelegatedToClaimed() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); + + restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); + restClient.assertStatusCodeIs(HttpStatus.CONFLICT).assertLastError() + .containsErrorKey(RestErrorModel.TASK_ALREADY_CLAIMED) + .containsSummary(RestErrorModel.TASK_ALREADY_CLAIMED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from delegated to claimed since it is already claimed by task assignee") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskAssigneeCanUpdateTaskFromDelegatedToClaimed() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); + + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); + } + + @Bug(id = "REPO-1924") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from delegated to completed by task creator") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskCreatorCanUpdateTaskFromDelegatedToCompleted() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); + + restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() + .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .containsSummary(RestErrorModel.DELEGATED_TASK_CAN_NOT_BE_COMPLETED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Bug(id = "REPO-1924") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from delegated to completed by task assignee") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskAssigneeCanUpdateTaskFromDelegatedToCompleted() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); + + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() + .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .containsSummary(RestErrorModel.DELEGATED_TASK_CAN_NOT_BE_COMPLETED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from delegated to resolved") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskCreatorCanUpdateTaskFromDelegatedToResolved() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); + + restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("resolved"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from delegated to resolved by task assignee") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskAssigneeCanUpdateTaskFromDelegatedToResolved() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); + + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("resolved"); + } + + @Bug(id = "REPO-1982") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from resolved to unclaimed by task creator") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskCreatorCanUpdateTaskFromResolvedToUnclaimed() throws Exception + { + restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + + restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("resolved"); + } + + @Bug(id = "REPO-1982") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task cannot be updated from resolved to unclaimed by task assignee") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskAssigneeCannotUpdateTaskFromResolvedToUnclaimed() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Bug(id = "REPO-1982") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task cannot be updated from resolved to claimed by task owner") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskOwnerCanUpdateTaskFromResolvedToClaimed() throws Exception + { + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + + restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("resolved"); + } + + @Bug(id = "REPO-1982") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task cannot be updated from resolved to claimed by task assignee") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskAssigneeCanUpdateTaskFromResolvedToClaimed() throws Exception + { + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Bug(id = "REPO-1982") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from resolved to delegated by task creator") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskCreatorCannotUpdateTaskFromResolvedToDelegated() throws Exception + { + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + + JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); + restTaskModel = restClient.authenticateUser(owner).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from resolved to delegated by task assignee") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskAssigneeCannotUpdateTaskFromResolvedToDelegated() throws Exception + { + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + + JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Bug(id = "REPO-1982") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from resolved to resolved by task creator") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskCreatorCannotUpdateTaskFromResolvedToResolved() throws Exception + { + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + + restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("resolved"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from resolved to resolved by task assignee") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskAssigneeCannotUpdateTaskFromResolvedToResolved() throws Exception + { + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Bug(id = "REPO-1982") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Update task by providing empty select value") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void updateTaskByProvidingEmptySelectValue() throws Exception + { + restTaskModel = restClient.authenticateUser(owner).withParams("select=").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(RestErrorModel.INVALID_SELECT_ERRORKEY) + .containsSummary(RestErrorModel.INVALID_SELECT) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Update task by providing empty state value") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void updateTaskByProvidingEmptyStateValue() throws Exception + { + restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask(" "); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(String.format(RestErrorModel.TASK_INVALID_STATE, " ")) + .containsSummary(String.format(RestErrorModel.TASK_INVALID_STATE, " ")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/candidates/GetTaskCandidatesRegressionTests.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/candidates/GetTaskCandidatesRegressionTests.java new file mode 100644 index 000000000..5e8d3d09f --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/candidates/GetTaskCandidatesRegressionTests.java @@ -0,0 +1,268 @@ +package org.alfresco.rest.workflow.tasks.candidates; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestCandidateModelsCollection; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.GroupModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TaskModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * + * @author bogdan.bocancea + * + */ +public class GetTaskCandidatesRegressionTests extends RestTest +{ + private UserModel userModel, userModel1, userModel2; + private SiteModel siteModel; + private FileModel fileModel; + private TaskModel taskModel; + private GroupModel group; + private RestCandidateModelsCollection candidateModels; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + userModel1 = dataUser.createRandomTestUser(); + userModel2 = dataUser.createRandomTestUser(); + group = dataGroup.createRandomGroup(); + dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); + } + + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify get task candidates with invalid task id") + public void getTaskCandidatesWithInvalidTaskId() throws Exception + { + taskModel = dataWorkflow.usingUser(userModel) + .usingSite(siteModel) + .usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); + taskModel.setId("invalid-id"); + restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).getTaskCandidates(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalid-id")) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } + + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify get task candidates with empty task id") + public void getTaskCandidatesWithEmptyTaskId() throws Exception + { + taskModel = dataWorkflow.usingUser(userModel) + .usingSite(siteModel) + .usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); + taskModel.setId(""); + restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).getTaskCandidates(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); + } + + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify get task candidates for completed task") + public void getTaskCandidatesForCompletedTask() throws Exception + { + taskModel = dataWorkflow.usingUser(userModel) + .usingSite(siteModel) + .usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); + + restClient.authenticateUser(userModel1).withWorkflowAPI().usingTask(taskModel).getTaskCandidates(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + dataWorkflow.usingUser(userModel1).taskDone(taskModel); + + restClient.authenticateUser(userModel1).withWorkflowAPI().usingTask(taskModel).getTaskCandidates(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, taskModel.getId())); + + restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).getTaskCandidates(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, taskModel.getId())); + } + + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify get task candidates by non candidate user") + public void getTaskCandidatesByNonCandidateUser() throws Exception + { + UserModel outsider = dataUser.createRandomTestUser(); + taskModel = dataWorkflow.usingUser(userModel) + .usingSite(siteModel) + .usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); + restClient.authenticateUser(outsider).withWorkflowAPI().usingTask(taskModel).getTaskCandidates(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Bug(id="MNT-17438") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Get task candidates with skip count parameter") + public void getTaskCandidatesWithSkipCount() throws Exception + { + taskModel = dataWorkflow.usingUser(userModel) + .usingSite(siteModel) + .usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); + candidateModels = restClient.authenticateUser(userModel).withWorkflowAPI() + .usingParams("skipCount=1").usingTask(taskModel).getTaskCandidates(); + restClient.assertStatusCodeIs(HttpStatus.OK); + candidateModels.assertThat() + .entriesListIsNotEmpty() + .and().paginationField("count").is("0"); + } + + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Get task candidates with max items parameter set to 0") + public void getTaskCandidatesWithZeroMaxItems() throws Exception + { + taskModel = dataWorkflow.usingUser(userModel) + .usingSite(siteModel) + .usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); + candidateModels = restClient.authenticateUser(userModel).withWorkflowAPI() + .usingParams("maxItems=0").usingTask(taskModel).getTaskCandidates(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsErrorKey(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) + .containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } + + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Get task candidates with max items parameter") + public void getTaskCandidatesWithMaxItems() throws Exception + { + taskModel = dataWorkflow.usingUser(userModel) + .usingSite(siteModel) + .usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); + candidateModels = restClient.authenticateUser(userModel).withWorkflowAPI() + .usingParams("maxItems=2").usingTask(taskModel).getTaskCandidates(); + restClient.assertStatusCodeIs(HttpStatus.OK); + candidateModels.assertThat() + .entriesListIsNotEmpty() + .and().paginationField("count").is("1"); + } + + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Get task candidates with properties") + public void getTaskCandidatesWithProperties() throws Exception + { + taskModel = dataWorkflow.usingUser(userModel) + .usingSite(siteModel) + .usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); + candidateModels = restClient.authenticateUser(userModel).withWorkflowAPI() + .usingParams("properties=candidateId").usingTask(taskModel).getTaskCandidates(); + restClient.assertStatusCodeIs(HttpStatus.OK); + candidateModels.getEntries().get(0).onModel().assertThat() + .field("candidateId").contains(group.getGroupIdentifier()).and() + .field("candidateType").isNull(); + } + + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Get task candidates with invalid properties") + public void getTaskCandidatesWithInvalidProperties() throws Exception + { + taskModel = dataWorkflow.usingUser(userModel) + .usingSite(siteModel) + .usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); + candidateModels = restClient.authenticateUser(userModel).withWorkflowAPI() + .usingParams("properties=unknown-prop").usingTask(taskModel).getTaskCandidates(); + restClient.assertStatusCodeIs(HttpStatus.OK); + candidateModels.getEntries().get(0).onModel().assertThat() + .fieldsCount().is(0).and(); + } + + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Get task candidates by deleted candidate") + public void getTaskCandidatesByDeletedCandidate() throws Exception + { + UserModel newUser = dataUser.createRandomTestUser(); + dataGroup.addListOfUsersToGroup(group, newUser); + taskModel = dataWorkflow.usingUser(userModel) + .usingSite(siteModel) + .usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); + restClient.authenticateUser(newUser).withWorkflowAPI() + .usingTask(taskModel).getTaskCandidates(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + dataUser.usingAdmin().deleteUser(newUser); + + restClient.authenticateUser(newUser).withWorkflowAPI() + .usingTask(taskModel).getTaskCandidates(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError().containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } + + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Get task candidates by deleted group") + public void getTaskCandidatesByDeletedGroup() throws Exception + { + GroupModel deletedGroup = dataGroup.createRandomGroup(); + UserModel newUser = dataUser.createRandomTestUser(); + dataGroup.addListOfUsersToGroup(deletedGroup, userModel2, newUser); + taskModel = dataWorkflow.usingUser(userModel) + .usingSite(siteModel) + .usingResource(fileModel).createPooledReviewTaskAndAssignTo(deletedGroup); + restClient.authenticateUser(newUser).withWorkflowAPI() + .usingTask(taskModel).getTaskCandidates(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + dataGroup.usingAdmin().deleteGroup(deletedGroup); + + restClient.authenticateUser(newUser).withWorkflowAPI() + .usingTask(taskModel).getTaskCandidates(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Get task candidates by user that was removed from group") + public void getTaskCandidatesByUserRemovedFromGroup() throws Exception + { + UserModel newUser = dataUser.createRandomTestUser(); + dataGroup.addListOfUsersToGroup(group, newUser); + taskModel = dataWorkflow.usingUser(userModel) + .usingSite(siteModel) + .usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); + restClient.authenticateUser(newUser).withWorkflowAPI() + .usingTask(taskModel).getTaskCandidates(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + dataGroup.usingAdmin().removeUserFromGroup(group, newUser); + + restClient.authenticateUser(newUser).withWorkflowAPI() + .usingTask(taskModel).getTaskCandidates(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .stackTraceIs(RestErrorModel.STACKTRACE); + } +} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/candidates/GetTaskCandidatesSanityTests.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/candidates/GetTaskCandidatesSanityTests.java new file mode 100644 index 000000000..b9fd88f1a --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/candidates/GetTaskCandidatesSanityTests.java @@ -0,0 +1,79 @@ +package org.alfresco.rest.workflow.tasks.candidates; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestCandidateModelsCollection; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.GroupModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TaskModel; +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 Cristina Axinte + * + */ + +public class GetTaskCandidatesSanityTests extends RestTest +{ + private UserModel userModel, user, userModel1, userModel2; + private SiteModel siteModel; + private FileModel fileModel; + private TaskModel taskModel; + private GroupModel group; + private RestCandidateModelsCollection candidateModels; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + user = dataUser.createRandomTestUser(); + userModel1 = dataUser.createRandomTestUser(); + userModel2 = dataUser.createRandomTestUser(); + group = dataGroup.createRandomGroup(); + dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); + taskModel = dataWorkflow.usingUser(user).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); + } + + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Verify that admin gets task candidates") + public void getTaskCandidatesByAdmin() throws Exception + { + candidateModels = restClient.authenticateUser(dataUser.getAdminUser()).withWorkflowAPI().usingTask(taskModel).getTaskCandidates(); + restClient.assertStatusCodeIs(HttpStatus.OK); + candidateModels.assertThat().entriesListContains("candidateType", "group") + .and().entriesListContains("candidateId", String.format("GROUP_%s", group.getGroupIdentifier())); + } + + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Verify that user that started the process gets task candidates") + public void getTaskCandidatesByUserWhoStartedProcess() throws Exception + { + candidateModels = restClient.authenticateUser(user).withWorkflowAPI().usingTask(taskModel).getTaskCandidates(); + restClient.assertStatusCodeIs(HttpStatus.OK); + candidateModels.assertThat().entriesListContains("candidateType", "group") + .and().entriesListContains("candidateId", String.format("GROUP_%s", group.getGroupIdentifier())); + } + + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Verify that user from the assighed group to the process gets task candidates") + public void getTaskCandidatesByCandidateUser() throws Exception + { + candidateModels = restClient.authenticateUser(userModel1).withWorkflowAPI().usingTask(taskModel).getTaskCandidates(); + restClient.assertStatusCodeIs(HttpStatus.OK); + candidateModels.assertThat().entriesListContains("candidateType", "group") + .and().entriesListContains("candidateId", String.format("GROUP_%s", group.getGroupIdentifier())); + } +} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemTestsBulk1.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemTestsBulk1.java new file mode 100644 index 000000000..e0bb0e483 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemTestsBulk1.java @@ -0,0 +1,158 @@ +package org.alfresco.rest.workflow.tasks.items; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestItemModel; +import org.alfresco.rest.model.RestItemModelsCollection; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TaskModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + + +public class AddTaskItemTestsBulk1 extends RestTest +{ + private UserModel userModel, userWhoStartsTask, assigneeUser; + private SiteModel siteModel; + private FileModel fileModel, document2, document3; + private TaskModel taskModel; + private RestItemModelsCollection taskItems; + private RestItemModel taskItem; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + userWhoStartsTask = dataUser.createRandomTestUser(); + assigneeUser = dataUser.createRandomTestUser(); + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + } + + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Create non-existing task item") + public void createTaskItem() throws Exception + { + UserModel adminUser = dataUser.getAdminUser(); + restClient.authenticateUser(adminUser); + document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + + taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + taskItem.assertThat().field("createdAt").is(taskItem.getCreatedAt()) + .assertThat().field("size").is(taskItem.getSize()) + .assertThat().field("createdBy").is(taskItem.getCreatedBy()) + .assertThat().field("modifiedAt").is(taskItem.getModifiedAt()) + .assertThat().field("name").is(taskItem.getName()) + .assertThat().field("modifiedBy").is(taskItem.getModifiedBy()) + .assertThat().field("id").is(taskItem.getId()) + .assertThat().field("mimeType").is(taskItem.getMimeType()); + } + + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Create multiple non-existing task item") + public void createMultipleTaskItem() throws Exception + { + UserModel adminUser = dataUser.getAdminUser(); + restClient.authenticateUser(adminUser); + document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + + taskItems = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItems(document2, fileModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + taskItems.getEntries().get(0).onModel() + .assertThat().field("createdAt").is(taskItems.getEntries().get(0).onModel().getCreatedAt()) + .assertThat().field("size").is(taskItems.getEntries().get(0).onModel().getSize()) + .assertThat().field("createdBy").is(taskItems.getEntries().get(0).onModel().getCreatedBy()) + .assertThat().field("modifiedAt").is(taskItems.getEntries().get(0).onModel().getModifiedAt()) + .assertThat().field("name").is(taskItems.getEntries().get(0).onModel().getName()) + .assertThat().field("modifiedBy").is(taskItems.getEntries().get(0).onModel().getModifiedBy()) + .assertThat().field("id").is(taskItems.getEntries().get(0).onModel().getId()) + .assertThat().field("mimeType").is(taskItems.getEntries().get(0).onModel().getMimeType()); + + taskItems.getEntries().get(1).onModel() + .assertThat().field("createdAt").is(taskItems.getEntries().get(1).onModel().getCreatedAt()) + .assertThat().field("size").is(taskItems.getEntries().get(1).onModel().getSize()) + .assertThat().field("createdBy").is(taskItems.getEntries().get(1).onModel().getCreatedBy()) + .assertThat().field("modifiedAt").is(taskItems.getEntries().get(1).onModel().getModifiedAt()) + .assertThat().field("name").is(taskItems.getEntries().get(1).onModel().getName()) + .assertThat().field("modifiedBy").is(taskItems.getEntries().get(1).onModel().getModifiedBy()) + .assertThat().field("id").is(taskItems.getEntries().get(1).onModel().getId()) + .assertThat().field("mimeType").is(taskItems.getEntries().get(1).onModel().getMimeType()); + } + + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @Bug(id = "MNT-16966") + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that in case task item exists the request fails") + public void createTaskItemThatAlreadyExists() throws Exception + { + UserModel adminUser = dataUser.getAdminUser(); + restClient.authenticateUser(adminUser); + document3 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + + taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document3); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + taskItem.assertThat().field("createdAt").is(taskItem.getCreatedAt()) + .assertThat().field("size").is(taskItem.getSize()) + .and().field("createdBy").is(taskItem.getCreatedBy()) + .and().field("modifiedAt").is(taskItem.getModifiedAt()) + .and().field("name").is(taskItem.getName()) + .and().field("modifiedBy").is(taskItem.getModifiedBy()) + .and().field("id").is(taskItem.getId()) + .and().field("mimeType").is(taskItem.getMimeType()); + + taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document3); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + } + + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @Bug(id = "MNT-16966") + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that in case task item exists the request fails") + public void createMultipleTaskItemThatAlreadyExists() throws Exception + { + UserModel adminUser = dataUser.getAdminUser(); + restClient.authenticateUser(adminUser); + document3 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + + taskItems = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItems(document3, document2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + taskItems.getEntries().get(0).onModel() + .assertThat().field("createdAt").is(taskItems.getEntries().get(0).onModel().getCreatedAt()) + .assertThat().field("size").is(taskItems.getEntries().get(0).onModel().getSize()) + .assertThat().field("createdBy").is(taskItems.getEntries().get(0).onModel().getCreatedBy()) + .assertThat().field("modifiedAt").is(taskItems.getEntries().get(0).onModel().getModifiedAt()) + .assertThat().field("name").is(taskItems.getEntries().get(0).onModel().getName()) + .assertThat().field("modifiedBy").is(taskItems.getEntries().get(0).onModel().getModifiedBy()) + .assertThat().field("id").is(taskItems.getEntries().get(0).onModel().getId()) + .assertThat().field("mimeType").is(taskItems.getEntries().get(0).onModel().getMimeType()); + + taskItems.getEntries().get(1).onModel() + .assertThat().field("createdAt").is(taskItems.getEntries().get(1).onModel().getCreatedAt()) + .assertThat().field("size").is(taskItems.getEntries().get(1).onModel().getSize()) + .assertThat().field("createdBy").is(taskItems.getEntries().get(1).onModel().getCreatedBy()) + .assertThat().field("modifiedAt").is(taskItems.getEntries().get(1).onModel().getModifiedAt()) + .assertThat().field("name").is(taskItems.getEntries().get(1).onModel().getName()) + .assertThat().field("modifiedBy").is(taskItems.getEntries().get(1).onModel().getModifiedBy()) + .assertThat().field("id").is(taskItems.getEntries().get(1).onModel().getId()) + .assertThat().field("mimeType").is(taskItems.getEntries().get(1).onModel().getMimeType()); + + taskItems = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItems(document3, document2); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + } +} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemTestsBulk2.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemTestsBulk2.java new file mode 100644 index 000000000..b54d54193 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemTestsBulk2.java @@ -0,0 +1,175 @@ +package org.alfresco.rest.workflow.tasks.items; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestVariableModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TaskModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class AddTaskItemTestsBulk2 extends RestTest +{ + private UserModel userModel, assigneeUser, anotherUser; + private SiteModel siteModel; + private FileModel fileModel, fileModel1; + private TaskModel taskModel; + private String taskId; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + fileModel1 = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + assigneeUser = dataUser.createRandomTestUser(); + taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + + taskId = taskModel.getId(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Add task item using random user.") + public void addTaskItemByRandomUser() throws Exception + { + anotherUser = dataUser.createRandomTestUser(); + restClient.authenticateUser(anotherUser).withWorkflowAPI().usingTask(taskModel).addTaskItem(fileModel); + + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError() + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Add multiple task item using random user.") + public void addMultipleTaskItemByRandomUser() throws Exception + { + anotherUser = dataUser.createRandomTestUser(); + restClient.authenticateUser(anotherUser).withWorkflowAPI().usingTask(taskModel) + .addTaskItems(fileModel,fileModel1); + + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE);; + } + + @Bug(id = "ACE-5683") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Adding task item, is falling in case invalid itemBody is provided") + public void failedAddingTaskItemIfInvalidItemBodyIsProvided() throws Exception + { + fileModel.setNodeRef("invalidNodeRef"); + restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).addTaskItem(fileModel); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidNodeRef")) + .containsErrorKey(RestErrorModel.NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Bug(id = "ACE-5683") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Adding multiple task item, is falling in case invalid itemBody is provided") + public void failedAddingMultipleTaskItemIfInvalidItemBodyIsProvided() throws Exception + { + fileModel.setNodeRef("invalidNodeRef"); + restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel) + .addTaskItems(fileModel, fileModel1); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidNodeRef")) + .containsErrorKey(RestErrorModel.NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE);; + } + + @Bug(id = "ACE-5675") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Adding task item is falling in case empty item body is provided") + public void failedAddingTaskItemIfEmptyItemBodyIsProvided() throws Exception + { + fileModel.setNodeRef(""); + restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).addTaskItem(fileModel); + + // TODO - expected error message to be added + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(""); + } + + @Bug(id = "ACE-5675") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Adding multiple task item is falling in case empty item body is provided") + public void failedAddingMultipleTaskItemIfEmptyItemBodyIsProvided() throws Exception + { + fileModel.setNodeRef(""); + restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).addTaskItems(fileModel, fileModel1); + + // TODO - expected error message to be added + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(""); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Adding task item is falling in case invalid task id is provided") + public void failedAddingTaskItemIfInvalidTaskIdIsProvided() throws Exception + { + taskModel.setId("invalidTaskId"); + restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).addTaskItem(fileModel); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidTaskId")) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE);; + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Adding task item is falling in case invalid task id is provided") + public void failedAddingMultipleTaskItemIfInvalidTaskIdIsProvided() throws Exception + { + taskModel.setId("invalidTaskId"); + restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).addTaskItems(fileModel,fileModel1); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidTaskId")) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Bug(id = "ACE-5675") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Adding task item is falling in case incomplete body type is provided") + public void failedAddingTaskVariableIfIncompleteBodyIsProvided() throws Exception + { + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{}", "tasks/{taskId}/items", taskId); + restClient.processModel(RestVariableModel.class, request); + + // TODO - expected error message to be added + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(""); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemTestsBulk3.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemTestsBulk3.java new file mode 100644 index 000000000..fd6a130c5 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemTestsBulk3.java @@ -0,0 +1,128 @@ +package org.alfresco.rest.workflow.tasks.items; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestItemModel; +import org.alfresco.rest.model.RestItemModelsCollection; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TaskModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class AddTaskItemTestsBulk3 extends RestTest +{ + private UserModel userModel,userWhoStartsTask, assigneeUser; + private SiteModel siteModel; + private FileModel fileModel, fileModel1, document1, document2,document3; + private TaskModel taskModel; + private RestItemModelsCollection taskItems; + private RestItemModel taskItem; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + userWhoStartsTask = dataUser.createRandomTestUser(); + assigneeUser = dataUser.createRandomTestUser(); + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Add task item using random user.") + public void addTaskItemByTheUserThatStartedTheProcess() throws Exception + { + taskItem = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingTask(taskModel).addTaskItem(fileModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + taskItem.assertThat().field("createdAt").is(taskItem.getCreatedAt()) + .and().field("size").is(taskItem.getSize()) + .and().field("createdBy").is(taskItem.getCreatedBy()) + .and().field("modifiedAt").is(taskItem.getModifiedAt()) + .and().field("name").is(taskItem.getName()) + .and().field("modifiedBy").is(taskItem.getModifiedBy()) + .and().field("id").is(taskItem.getId()) + .and().field("mimeType").is(taskItem.getMimeType()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Add multiple task item using random user.") + public void addMultipleTaskItemByTheUserThatStartedTheProcess() throws Exception + { + fileModel1 = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + taskItems = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingTask(taskModel) + .addTaskItems(fileModel, fileModel1); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + taskItems.getEntries().get(0).onModel() + .assertThat().field("createdAt").is(taskItems.getEntries().get(0).onModel().getCreatedAt()) + .and().field("size").is(taskItems.getEntries().get(0).onModel().getSize()) + .and().field("createdBy").is(taskItems.getEntries().get(0).onModel().getCreatedBy()) + .and().field("modifiedAt").is(taskItems.getEntries().get(0).onModel().getModifiedAt()) + .and().field("name").is(taskItems.getEntries().get(0).onModel().getName()) + .and().field("modifiedBy").is(taskItems.getEntries().get(0).onModel().getModifiedBy()) + .and().field("id").is(taskItems.getEntries().get(0).onModel().getId()) + .and().field("mimeType").is(taskItems.getEntries().get(0).onModel().getMimeType()); + + taskItems.getEntries().get(1).onModel() + .assertThat().field("createdAt").is(taskItems.getEntries().get(1).onModel().getCreatedAt()) + .assertThat().field("size").is(taskItems.getEntries().get(1).onModel().getSize()) + .assertThat().field("createdBy").is(taskItems.getEntries().get(1).onModel().getCreatedBy()) + .assertThat().field("modifiedAt").is(taskItems.getEntries().get(1).onModel().getModifiedAt()) + .assertThat().field("name").is(taskItems.getEntries().get(1).onModel().getName()) + .assertThat().field("modifiedBy").is(taskItems.getEntries().get(1).onModel().getModifiedBy()) + .assertThat().field("id").is(taskItems.getEntries().get(1).onModel().getId()) + .assertThat().field("mimeType").is(taskItems.getEntries().get(1).onModel().getMimeType()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Delete task item then create it again") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION}) + public void deleteTaskItemThenCreateItAgain() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel) + .createNewTaskAndAssignTo(assigneeUser); + restClient.authenticateUser(userWhoStartsTask); + document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Delete multiple task item then create it again") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION}) + public void deleteMultipleTaskItemsThenCreateThemAgain() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel) + .createNewTaskAndAssignTo(assigneeUser); + restClient.authenticateUser(userWhoStartsTask); + document1 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + document3 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + taskItems = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItems(document2, document1, document3); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItems.getEntries().get(0).onModel()); + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItems.getEntries().get(1).onModel()); + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItems.getEntries().get(2).onModel()); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withWorkflowAPI().usingTask(taskModel).addTaskItems(document2, document1, document3); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/items/GetTaskItemsRegressionTests.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/items/GetTaskItemsRegressionTests.java new file mode 100644 index 000000000..e8841828f --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/items/GetTaskItemsRegressionTests.java @@ -0,0 +1,260 @@ +package org.alfresco.rest.workflow.tasks.items; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.dataprep.CMISUtil.Priority; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestItemModel; +import org.alfresco.rest.model.RestItemModelsCollection; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestTaskModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TaskModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Created by Claudia Agache on 12/8/2016. + */ +public class GetTaskItemsRegressionTests extends RestTest +{ + private UserModel userWhoStartsTask, assignee; + private SiteModel siteModel; + private FileModel fileModel; + private TaskModel taskModel; + private RestItemModelsCollection itemModels; + private RestProcessModel addedProcess; + private RestTaskModel addedTask; + private RestItemModel taskItem; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + userWhoStartsTask = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); + fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify if get task items call return status code 404 when invalid taskId is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void getTaskItemsUsingInvalidTaskId() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); + taskModel.setId("invalidId"); + + restClient.authenticateUser(assignee).withWorkflowAPI() + .usingTask(taskModel).getTaskItems(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidId")); + + taskModel.setId(""); + + restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() + .usingTask(taskModel).getTaskItems(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, + executionType = ExecutionType.REGRESSION, + description = "Verify if get task items request returns status code 200 after the task is finished.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void getTaskItemsAfterFinishingTask() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); + dataWorkflow.usingUser(assignee).taskDone(taskModel); + restClient.authenticateUser(userWhoStartsTask); + itemModels = restClient.withWorkflowAPI().usingTask(taskModel).getTaskItems(); + restClient.assertStatusCodeIs(HttpStatus.OK); + itemModels.assertThat().entriesListIsNotEmpty().and().entriesListContains("name", fileModel.getName()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, + executionType = ExecutionType.REGRESSION, + description = "Verify if get task items request returns status code 200 after the process is deleted (Task state is now completed.)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void getTaskItemsAfterDeletingProcess() throws Exception + { + addedProcess = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); + addedTask = restClient.withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess); + restClient.withWorkflowAPI().usingTask(addedTask).addTaskItem(fileModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.withWorkflowAPI().usingProcess(addedProcess).deleteProcess(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + itemModels = restClient.withWorkflowAPI().usingTask(addedTask).getTaskItems(); + restClient.assertStatusCodeIs(HttpStatus.OK); + itemModels.assertThat().entriesListIsNotEmpty().and().entriesListContains("name", fileModel.getName()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Check default error model schema for get task items api call") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void getTaskItemsUsingCheckErrorModel() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); + taskModel.setId("invalidId"); + restClient.authenticateUser(assignee).withWorkflowAPI() + .usingTask(taskModel).getTaskItems(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidId")) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } + + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin user can get task items") + public void getTaskItemsByAdminUser() throws Exception + { + restClient.authenticateUser(userWhoStartsTask); + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); + taskItem = restClient.withWorkflowAPI().usingTask(taskModel).getTaskItems().getOneRandomEntry(); + + itemModels = restClient.authenticateUser(dataUser.getAdminUser()).withWorkflowAPI().usingTask(taskModel).getTaskItems(); + restClient.assertStatusCodeIs(HttpStatus.OK); + itemModels.assertThat() + .entriesListIsNotEmpty().and() + .entriesListContains("id", taskItem.onModel().getId()).and() + .entriesListContains("name", taskItem.onModel().getName()) + .getEntries().get(0).onModel() + .assertThat().field("createdAt").isNotNull() + .assertThat().field("size").isNotNull() + .assertThat().field("createdBy").contains(dataUser.getAdminUser().getUsername()) + .assertThat().field("modifiedAt").isNotNull() + .assertThat().field("name").contains(fileModel.getName()) + .assertThat().field("modifiedBy").contains(userWhoStartsTask.getUsername()) + .assertThat().field("id").contains(fileModel.getNodeRef().split(";")[0]) + .assertThat().field("mimeType").contains(fileModel.getFileType().mimeType); + } + + @Bug(id="MNT-17438") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that user who started the process can get task items with skip count parameter") + public void getTaskItemsWithSkipCount() throws Exception + { + restClient.authenticateUser(userWhoStartsTask); + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); + FileModel document1 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document1); + itemModels = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() + .usingParams("skipCount=1").usingTask(taskModel).getTaskItems(); + restClient.assertStatusCodeIs(HttpStatus.OK); + itemModels.assertThat() + .entriesListIsNotEmpty() + .and().paginationField("count").is("1"); + } + + @Bug(id="MNT-17438") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that user who started the process can get task items with max items parameter") + public void getTaskItemsWithMaxItems() throws Exception + { + restClient.authenticateUser(userWhoStartsTask); + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); + FileModel document1 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document1); + itemModels = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() + .usingParams("maxItems=1").usingTask(taskModel).getTaskItems(); + restClient.assertStatusCodeIs(HttpStatus.OK); + itemModels.assertThat() + .entriesListIsNotEmpty() + .and().paginationField("count").is("1"); + } + + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that user who started the process can get task items with valid properties") + public void getTaskItemsWithValidProperties() throws Exception + { + restClient.authenticateUser(userWhoStartsTask); + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); + taskItem = restClient.withWorkflowAPI().usingTask(taskModel).getTaskItems().getOneRandomEntry(); + itemModels = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() + .usingParams("properties=createdAt,createdBy,id,size").usingTask(taskModel).getTaskItems(); + restClient.assertStatusCodeIs(HttpStatus.OK); + itemModels.getOneRandomEntry().onModel().assertThat() + .fieldsCount().is(4).and() + .field("createdAt").isNotNull().and() + .field("size").isNotNull().and() + .field("createdBy").isNotNull().and() + .field("modifiedAt").isNull().and() + .field("name").isNull().and() + .field("modifiedBy").isNull().and() + .field("id").isNotNull().and() + .field("mimeType").isNull(); + } + + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that user who started the process can get task items with an invalid property") + public void getTaskItemsWithInvalidProperties() throws Exception + { + restClient.authenticateUser(userWhoStartsTask); + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); + taskItem = restClient.withWorkflowAPI().usingTask(taskModel).getTaskItems().getOneRandomEntry(); + itemModels = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() + .usingParams("properties=size,fake-prop").usingTask(taskModel).getTaskItems(); + restClient.assertStatusCodeIs(HttpStatus.OK); + itemModels.getOneRandomEntry().onModel().assertThat() + .fieldsCount().is(1).and() + .field("createdAt").isNull().and() + .field("size").isNotNull().and() + .field("createdBy").isNull().and() + .field("modifiedAt").isNull().and() + .field("name").isNull().and() + .field("modifiedBy").isNull().and() + .field("id").isNull().and() + .field("mimeType").isNull(); + } + + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that involved user in process that was deleted cannot get task items") + public void getTaskItemsByDeletedUserInvolvedInProcess() throws Exception + { + UserModel assigneeDeleted = dataUser.createRandomTestUser(); + restClient.authenticateUser(userWhoStartsTask); + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeDeleted); + + dataUser.usingAdmin().deleteUser(assigneeDeleted); + + itemModels = restClient.authenticateUser(assigneeDeleted).withWorkflowAPI().usingTask(taskModel).getTaskItems(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError().containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } + + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that involved user in process that was disabled cannot get task items") + public void getTaskItemsByDisabledUserInvolvedInProcess() throws Exception + { + UserModel assigneeDisabled = dataUser.createRandomTestUser(); + restClient.authenticateUser(userWhoStartsTask); + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeDisabled); + + dataUser.usingAdmin().disableUser(assigneeDisabled); + + itemModels = restClient.authenticateUser(assigneeDisabled).withWorkflowAPI().usingTask(taskModel).getTaskItems(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError().containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/items/GetTaskItemsSanityTests.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/items/GetTaskItemsSanityTests.java new file mode 100644 index 000000000..594ea0449 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/items/GetTaskItemsSanityTests.java @@ -0,0 +1,75 @@ +package org.alfresco.rest.workflow.tasks.items; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestItemModel; +import org.alfresco.rest.model.RestItemModelsCollection; +import org.alfresco.utility.Utility; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TaskModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + + +public class GetTaskItemsSanityTests extends RestTest +{ + private UserModel userModel, userWhoStartsTask, assignee; + private SiteModel siteModel; + private FileModel fileModel, document1; + private TaskModel taskModel; + private RestItemModel taskItem; + private RestItemModelsCollection itemModels; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + userWhoStartsTask = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); + } + + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Verify that user that started the process gets task items") + public void getTaskItemsByUserWhoStartedProcess() throws Exception + { + restClient.authenticateUser(userWhoStartsTask); + document1 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document1); + Utility.checkObjectIsInitialized(taskItem, "taskItem"); + + itemModels = restClient.withWorkflowAPI().usingTask(taskModel).getTaskItems(); + restClient.assertStatusCodeIs(HttpStatus.OK); + itemModels.assertThat() + .entriesListIsNotEmpty().and() + .entriesListContains("id", taskItem.getId()).and() + .entriesListContains("name", document1.getName()); + } + + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Verify that involved user in process gets task items") + public void getTaskItemsByUserInvolvedInProcess() throws Exception + { + restClient.authenticateUser(assignee); + document1 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document1); + + itemModels = restClient.withWorkflowAPI().usingTask(taskModel).getTaskItems(); + restClient.assertStatusCodeIs(HttpStatus.OK); + itemModels.assertThat() + .entriesListIsNotEmpty().and() + .entriesListContains("id", taskItem.getId()).and() + .entriesListContains("name", document1.getName()); + + } +} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/items/RemoveTaskItemTests.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/items/RemoveTaskItemTests.java new file mode 100644 index 000000000..7eeb25407 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/items/RemoveTaskItemTests.java @@ -0,0 +1,256 @@ +package org.alfresco.rest.workflow.tasks.items; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestItemModel; +import org.alfresco.utility.model.*; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * @author bogdan.bocancea + */ +public class RemoveTaskItemTests extends RestTest +{ + private UserModel adminUser, userWhoStartsTask, assigneeUser; + private SiteModel siteModel; + private FileModel fileModel, document2; + private TaskModel taskModel; + private RestItemModel taskItem; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userWhoStartsTask = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); + fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + assigneeUser = dataUser.createRandomTestUser(); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Delete existing task item") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + public void deleteTaskItem() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + restClient.authenticateUser(adminUser); + document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + + taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingTask(taskModel).getTaskItems() + .assertThat().entriesListDoesNotContain("id", taskItem.getId()).and() + .entriesListDoesNotContain("name", document2.getName()); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Try to Delete existing task item using invalid taskId") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void deleteTaskItemUsingInvalidTaskId() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + restClient.authenticateUser(adminUser); + document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + + taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); + taskModel.setId("invalidTaskId"); + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidTaskId")); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Try to Delete existing task item using invalid itemId") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void deleteTaskItemUsingInvalidItemId() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + restClient.authenticateUser(adminUser); + document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); + taskItem.setId("incorrectItemId"); + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.PROCESS_ENTITY_NOT_FOUND, "incorrectItemId")); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Delete existing task item with empty task id") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void deleteTaskItemEmptyTaskId() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + restClient.authenticateUser(userWhoStartsTask); + document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); + taskModel.setId(""); + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Delete existing task item with empty item id") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void deleteTaskItemEmptyItemId() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + restClient.authenticateUser(userWhoStartsTask); + document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); + taskItem.setId(""); + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) + .assertLastError().containsSummary(RestErrorModel.DELETE_EMPTY_ARGUMENT); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Delete existing task item for completed task") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void deleteTaskItemForCompletedTask() throws Exception + { + TaskModel completedTask = dataWorkflow.usingUser(userWhoStartsTask) + .usingSite(siteModel) + .usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + restClient.authenticateUser(userWhoStartsTask); + document2 = dataContent.usingUser(userWhoStartsTask).usingSite(siteModel).createContent(DocumentType.XML); + taskItem = restClient.withWorkflowAPI().usingTask(completedTask).addTaskItem(document2); + dataWorkflow.usingUser(assigneeUser).taskDone(completedTask); + dataWorkflow.usingUser(userWhoStartsTask).taskDone(completedTask); + restClient.withWorkflowAPI().usingTask(completedTask).deleteTaskItem(taskItem); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, completedTask.getId())); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Delete existing task item with candidate user") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + public void deleteTaskItemWithCandidateUser() throws Exception + { + GroupModel group = dataGroup.createRandomGroup(); + dataGroup.addListOfUsersToGroup(group, assigneeUser); + TaskModel groupTask = dataWorkflow.usingUser(userWhoStartsTask) + .usingSite(siteModel) + .usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); + + restClient.authenticateUser(userWhoStartsTask); + document2 = dataContent.usingUser(userWhoStartsTask).usingSite(siteModel).createContent(DocumentType.XML); + taskItem = restClient.withWorkflowAPI().usingTask(groupTask).addTaskItem(document2); + restClient.authenticateUser(assigneeUser) + .withWorkflowAPI().usingTask(groupTask).deleteTaskItem(taskItem); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Delete existing task item with unauthorized user") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void deleteTaskItemWithUnauthorizedUser() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + UserModel unauthorizedUser = dataUser.createRandomTestUser(); + document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + taskItem = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); + restClient.authenticateUser(unauthorizedUser).withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Delete existing task item with inexistent user") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) +// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") + public void deleteTaskItemWithInexistentUser() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + taskItem = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); + restClient.authenticateUser(UserModel.getRandomUserModel()).withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Delete existing task item for deleted task") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void deleteTaskItemFromDeletedProcess() throws Exception + { + ProcessModel deletedProcess = dataWorkflow.usingUser(userWhoStartsTask) + .usingSite(siteModel) + .usingResource(fileModel).createMoreReviewersWorkflowAndAssignTo(assigneeUser); + TaskModel task = restClient.authenticateUser(userWhoStartsTask) + .withWorkflowAPI().usingProcess(deletedProcess).getProcessTasks().getEntries().get(0).onModel(); + + document2 = dataContent.usingUser(userWhoStartsTask).usingSite(siteModel).createContent(DocumentType.XML); + taskItem = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingTask(task).addTaskItem(document2); + dataWorkflow.usingUser(userWhoStartsTask).deleteProcess(deletedProcess); + restClient.withWorkflowAPI().usingTask(task).deleteTaskItem(taskItem); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, task.getId())); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Delete task item twice") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void deleteTaskItemTwice() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + restClient.authenticateUser(userWhoStartsTask); + document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); + + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.PROCESS_ENTITY_NOT_FOUND, document2.getNodeRefWithoutVersion())) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Delete task item with locked document") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void deleteTaskItemWithLockedDocument() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + restClient.authenticateUser(userWhoStartsTask); + document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); + + dataContent.usingUser(userWhoStartsTask).usingResource(document2).checkOutDocument(); + + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); + restClient.assertStatusCodeIs(HttpStatus.CONFLICT) + .assertLastError().containsSummary(String.format(RestErrorModel.LOCKED_NODE_OPERATION, document2.getNodeRefWithoutVersion())) + .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Delete task item with deleted document") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void deleteTaskItemWithDeletedDocument() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + restClient.authenticateUser(userWhoStartsTask); + document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); + + dataContent.usingUser(userWhoStartsTask).usingResource(document2).deleteContent(); + + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.PROCESS_ENTITY_NOT_FOUND, document2.getNodeRefWithoutVersion())) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } +} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk1.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk1.java new file mode 100644 index 000000000..03dac2155 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk1.java @@ -0,0 +1,198 @@ +package org.alfresco.rest.workflow.tasks.variables; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestVariableModel; +import org.alfresco.rest.model.RestVariableModelsCollection; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TaskModel; +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 AddTaskVariablesTestsBulk1 extends RestTest +{ + private UserModel userModel, userWhoStartsTask; + private SiteModel siteModel; + private FileModel fileModel; + private UserModel assigneeUser; + private TaskModel taskModel; + private RestVariableModel restVariablemodel; + private RestVariableModelsCollection restVariableCollection; + private RestVariableModel variableModel, variableModel1; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + userWhoStartsTask = dataUser.createRandomTestUser(); + assigneeUser = dataUser.createRandomTestUser(); + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + } + + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Create non-existing task variable with admin") + public void createTaskVariableWithAdmin() throws Exception + { + UserModel adminUser = dataUser.getAdminUser(); + restClient.authenticateUser(adminUser); + RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + + restVariablemodel = restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restVariablemodel.assertThat() + .field("scope").is(variableModel.getScope()) + .and().field("name").is(variableModel.getName()) + .and().field("value").is(variableModel.getValue()) + .and().field("type").is(variableModel.getType()); + } + + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Create non-existing task variable with admin") + public void createMultipleTaskVariablesWithAdmin() throws Exception + { + UserModel adminUser = dataUser.getAdminUser(); + restClient.authenticateUser(adminUser); + variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + variableModel1 = RestVariableModel.getRandomTaskVariableModel("global", "d:text"); + + restVariableCollection = restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariables(variableModel,variableModel1); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restVariableCollection.getEntries().get(0).onModel().assertThat() + .field("scope").is(variableModel.getScope()) + .and().field("name").is(variableModel.getName()) + .and().field("value").is(variableModel.getValue()) + .and().field("type").is(variableModel.getType()); + + restVariableCollection.getEntries().get(1).onModel().assertThat() + .field("scope").is(variableModel1.getScope()) + .and().field("name").is(variableModel1.getName()) + .and().field("value").is(variableModel1.getValue()) + .and().field("type").is(variableModel1.getType()); + } + + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Create non-existing task variable with user involved in the process") + public void createTaskVariableWithInvolvedUser() throws Exception + { + restClient.authenticateUser(assigneeUser); + RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + + restVariablemodel = restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restVariablemodel.assertThat().field("scope").is(variableModel.getScope()) + .and().field("name").is(variableModel.getName()) + .and().field("value").is(variableModel.getValue()) + .and().field("type").is(variableModel.getType()); + + restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables().assertThat().entriesListContains("name", variableModel.getName()); + } + + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Create multiple non-existing task variable with involved user") + public void createMultipleTaskVariableWithInvolvedUser() throws Exception + { + restClient.authenticateUser(assigneeUser); + variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + variableModel1 = RestVariableModel.getRandomTaskVariableModel("global", "d:text"); + + restVariableCollection = restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariables(variableModel,variableModel1); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restVariableCollection.getEntries().get(0).onModel().assertThat() + .field("scope").is(variableModel.getScope()) + .and().field("name").is(variableModel.getName()) + .and().field("value").is(variableModel.getValue()) + .and().field("type").is(variableModel.getType()); + + restVariableCollection.getEntries().get(1).onModel().assertThat() + .field("scope").is(variableModel1.getScope()) + .and().field("name").is(variableModel1.getName()) + .and().field("value").is(variableModel1.getValue()) + .and().field("type").is(variableModel1.getType()); + } + + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Create non-existing task variable with task owner") + public void createTaskVariableWithTaskOwner() throws Exception + { + restClient.authenticateUser(userWhoStartsTask); + RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + + restVariablemodel = restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restVariablemodel.assertThat().field("scope").is(variableModel.getScope()) + .and().field("name").is(variableModel.getName()) + .and().field("value").is(variableModel.getValue()) + .and().field("type").is(variableModel.getType()); + } + + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Create multiple non-existing task variable with task owner") + public void createMultipleTaskVariableWithTaskOwner() throws Exception + { + restClient.authenticateUser(userWhoStartsTask); + variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + variableModel1 = RestVariableModel.getRandomTaskVariableModel("global", "d:text"); + + restVariableCollection = restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariables(variableModel,variableModel1); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restVariableCollection.getEntries().get(0).onModel().assertThat() + .field("scope").is(variableModel.getScope()) + .and().field("name").is(variableModel.getName()) + .and().field("value").is(variableModel.getValue()) + .and().field("type").is(variableModel.getType()); + + restVariableCollection.getEntries().get(1).onModel().assertThat() + .field("scope").is(variableModel1.getScope()) + .and().field("name").is(variableModel1.getName()) + .and().field("value").is(variableModel1.getValue()) + .and().field("type").is(variableModel1.getType()); + } + + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Create non-existing task variable with any user") + public void createTaskVariableWithRandomUser() throws Exception + { + userModel = dataUser.createRandomTestUser(); + restClient.authenticateUser(userModel); + RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + + restVariablemodel = restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); + } + + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Create multiple non-existing task variable with any user") + public void createMultipleTaskVariableWithRandomUser() throws Exception + { + restClient.authenticateUser(userModel); + variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + variableModel1 = RestVariableModel.getRandomTaskVariableModel("global", "d:text"); + + restVariableCollection = restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariables(variableModel,variableModel1); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); + } + +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk2.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk2.java new file mode 100644 index 000000000..fd2704692 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk2.java @@ -0,0 +1,241 @@ +package org.alfresco.rest.workflow.tasks.variables; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestVariableModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TaskModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + + +public class AddTaskVariablesTestsBulk2 extends RestTest +{ + private UserModel userWhoStartsTask, adminUser; + private SiteModel siteModel; + private FileModel fileModel; + private UserModel assigneeUser; + private TaskModel taskModel; + private RestVariableModel invalidVariableModel, variableModel, variableModel1; + + private String taskId; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userWhoStartsTask = dataUser.createRandomTestUser(); + assigneeUser = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); + fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + + taskId = taskModel.getId(); + restClient.authenticateUser(adminUser); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case invalid variableBody is provided") + public void failedAddingTaskVariableIfInvalidBodyIsProvided() throws Exception + { + invalidVariableModel = RestVariableModel.getRandomTaskVariableModel("instance", "d:char"); + restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(invalidVariableModel); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Illegal value for variable scope: 'instance'."); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Adding multiple task variable is falling in case invalid variableBody is provided") + public void failedAddingMultipleTaskVariableIfInvalidBodyIsProvided() throws Exception + { + variableModel = RestVariableModel.getRandomTaskVariableModel("instance", "d:char"); + variableModel1 = RestVariableModel.getRandomTaskVariableModel("global", "d:text"); + restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariables(variableModel, variableModel1); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Illegal value for variable scope: 'instance'."); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case empty body type is provided") + public void failedAddingTaskVariableIfEmptyBodyIsProvided() throws Exception + { + RestVariableModel invalidVariableModel = RestVariableModel.getRandomTaskVariableModel("", ""); + restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(invalidVariableModel); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary("Variable scope is required and can only be 'local' or 'global'."); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Adding multiple task variable is falling in case empty body type is provided") + public void failedAddingMultipleTaskVariableIfEmptyBodyIsProvided() throws Exception + { + RestVariableModel invalidVariableModel = RestVariableModel.getRandomTaskVariableModel("", ""); + variableModel1 = RestVariableModel.getRandomTaskVariableModel("global", "d:text"); + restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariables(invalidVariableModel, variableModel1); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary("Variable scope is required and can only be 'local' or 'global'."); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case incomplete body type is provided") + public void failedAddingTaskVariableIfIncompleteBodyIsProvided() throws Exception + { + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{\"name\": \"missingVariableScope\",\"value\": \"test\",\"type\": \"d:text\"}", + "tasks/{taskId}/variables", taskId); + restClient.processModel(RestVariableModel.class, request); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary("Variable scope is required and can only be 'local' or 'global'."); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case incomplete body - missing required: name type is provided") + public void failedAddingTaskVariableIfIncompleteRequiredBodyIsProvided() throws Exception + { + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{\"scope\": \"local\",\"value\": \"missingVariableName\",\"type\": \"d:text\"}", + "tasks/{taskId}/variables", taskId); + restClient.processModel(RestVariableModel.class, request); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Variable name is required."); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case invalid type is provided") + public void failedAddingTaskVariableIfInvalidTypeIsProvided() throws Exception + { + RestVariableModel invalidVariableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:char"); + taskModel.setId(taskId); + + restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(invalidVariableModel); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Unsupported type of variable: 'd:char'."); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Adding multiple task variable is falling in case invalid type is provided") + public void failedAddingMultipleTaskVariableIfInvalidTypeIsProvided() throws Exception + { + RestVariableModel invalidVariableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:char"); + taskModel.setId(taskId); + variableModel1 = RestVariableModel.getRandomTaskVariableModel("global", "d:text"); + + restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariables(invalidVariableModel, variableModel1); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Unsupported type of variable: 'd:char'."); + } + + @Bug(id = "ACE-5674") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case invalid type prefix is provided") + public void failedAddingTaskVariableIfInvalidTypePrefixIsProvided() throws Exception + { + RestVariableModel invalidVariableModel = RestVariableModel.getRandomTaskVariableModel("local", "ddm:text"); + taskModel.setId(taskId); + + restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(invalidVariableModel); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Namespace prefix ddm is not mapped to a namespace URI"); + } + + @Bug(id = "ACE-5674") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Adding multiple task variable is falling in case invalid type prefix is provided") + public void failedAddingMultipleTaskVariableIfInvalidTypePrefixIsProvided() throws Exception + { + RestVariableModel invalidVariableModel = RestVariableModel.getRandomTaskVariableModel("local", "ddm:text"); + taskModel.setId(taskId); + variableModel1 = RestVariableModel.getRandomTaskVariableModel("global", "d:text"); + variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + + restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariables(invalidVariableModel,variableModel1, variableModel); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Namespace prefix ddm is not mapped to a namespace URI"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case invalid scope is provided") + public void failedAddingTaskVariableIfInvalidScopeIsProvided() throws Exception + { + RestVariableModel invalidVariableModel = RestVariableModel.getRandomTaskVariableModel("instance", "d:text"); + taskModel.setId(taskId); + + restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(invalidVariableModel); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Illegal value for variable scope: 'instance'."); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Adding multiple task variable is falling in case invalid scope is provided") + public void failedAddingMultipleTaskVariableIfInvalidScopeIsProvided() throws Exception + { + RestVariableModel invalidVariableModel = RestVariableModel.getRandomTaskVariableModel("instance", "d:text"); + taskModel.setId(taskId); + variableModel1 = RestVariableModel.getRandomTaskVariableModel("global", "d:text"); + variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + + restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariables(invalidVariableModel, variableModel, variableModel1); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Illegal value for variable scope: 'instance'."); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case invalid task id is provided") + public void failedAddingTaskVariableIfInvalidTaskIdIsProvided() throws Exception + { + RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + taskModel.setId(taskModel.getId() + "TEST"); + restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, taskModel.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Adding multiple task variable is falling in case invalid task id is provided") + public void failedAddingMultipleTaskVariableIfInvalidTaskIdIsProvided() throws Exception + { + variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + taskModel.setId(taskModel.getId() + "TEST"); + variableModel1 = RestVariableModel.getRandomTaskVariableModel("global", "d:text"); + restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariables(variableModel, variableModel1); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, taskModel.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case invalid task id is provided") + public void failedAddingTaskVariableIfInvalidValueIsProvided() throws Exception + { + RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:int"); + variableModel.setValue("invalidValue"); + + restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("For input string: \"invalidValue\""); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Adding multiple task variable is falling in case invalid task id is provided") + public void failedAddingMultipleTaskVariableIfInvalidValueIsProvided() throws Exception + { + variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:int"); + variableModel.setValue("invalidValue"); + variableModel1 = RestVariableModel.getRandomTaskVariableModel("global", "d:text"); + + restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariables(variableModel, variableModel1); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("For input string: \"invalidValue\""); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk3.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk3.java new file mode 100644 index 000000000..e81e3f0b5 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk3.java @@ -0,0 +1,155 @@ +package org.alfresco.rest.workflow.tasks.variables; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestVariableModel; +import org.alfresco.rest.model.RestVariableModelsCollection; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TaskModel; +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 AddTaskVariablesTestsBulk3 extends RestTest +{ + private UserModel userWhoStartsTask, adminUser; + private SiteModel siteModel; + private FileModel fileModel; + private UserModel assigneeUser; + private TaskModel taskModel; + private RestVariableModel restVariablemodel, variableModel, variableModel1; + private RestVariableModelsCollection restVariableCollection; + private String taskId; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userWhoStartsTask = dataUser.createRandomTestUser(); + assigneeUser = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); + fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + + taskId = taskModel.getId(); + } + + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Create task variable with name containing symbols") + public void createTaskVariableWithSymbolsInName() throws Exception + { + UserModel adminUser = dataUser.getAdminUser(); + restClient.authenticateUser(adminUser); + RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + variableModel.setName("!@#$%^&*({}<>.,;'=_|"); + restVariablemodel = restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restVariablemodel.assertThat() + .field("scope").is(variableModel.getScope()) + .and().field("name").is(variableModel.getName()) + .and().field("value").is(variableModel.getValue()) + .and().field("type").is(variableModel.getType()); + } + + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Create multiple task variable with name containing symbols") + public void createMultipleTaskVariableWithSymbolsInName() throws Exception + { + UserModel adminUser = dataUser.getAdminUser(); + restClient.authenticateUser(adminUser); + variableModel1 = RestVariableModel.getRandomTaskVariableModel("global", "d:text"); + variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + variableModel.setName("!@#$%^&*({}<>.,;'=_|"); + + restVariableCollection = restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariables(variableModel,variableModel1); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restVariableCollection.getEntries().get(0).onModel().assertThat() + .field("scope").is(variableModel.getScope()) + .and().field("name").is(variableModel.getName()) + .and().field("value").is(variableModel.getValue()) + .and().field("type").is(variableModel.getType()); + + restVariableCollection.getEntries().get(1).onModel().assertThat() + .field("scope").is(variableModel1.getScope()) + .and().field("name").is(variableModel1.getName()) + .and().field("value").is(variableModel1.getValue()) + .and().field("type").is(variableModel1.getType()); + } + + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Create task variable with empty name") + public void createTaskVariableWithEmptyName() throws Exception + { + UserModel adminUser = dataUser.getAdminUser(); + restClient.authenticateUser(adminUser); + RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + variableModel.setName(""); + restVariablemodel = restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsErrorKey(RestErrorModel.VARIABLE_NAME_REQUIRED) + .containsSummary(RestErrorModel.VARIABLE_NAME_REQUIRED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Update task variable with invalid variable name") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void createTaskVariableWithInvalidVariableName() throws Exception + { + restClient.authenticateUser(adminUser).withWorkflowAPI(); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{\"scope\": \"local\",\"names\": \"varName\",\"value\": \"test\"," + + "\"type\": \"d:text\"}", "tasks/{taskId}/variables", taskId); + restClient.processModel(RestVariableModel.class, request); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsSummary(String.format(RestErrorModel.NO_CONTENT,"Unrecognized field " + "\"names\"")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Create task variable with invalid name") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void createTaskVariableWithInvalidName() throws Exception + { + restClient.authenticateUser(adminUser).withWorkflowAPI(); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{\"scope\": \"local\",\"name\": ',\"value\": \"test\"," + + "\"type\": \"d:text\"}", "tasks/{taskId}/variables", taskId); + restClient.processModel(RestVariableModel.class, request); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsSummary(String.format(RestErrorModel.NO_CONTENT,"Unexpected character " + "('''")); + } + + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Create task variable with empty name") + public void failedCreatingMultipleTaskVariableWithEmptyName() throws Exception + { + UserModel adminUser = dataUser.getAdminUser(); + restClient.authenticateUser(adminUser); + variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + variableModel1 = RestVariableModel.getRandomTaskVariableModel("global", "d:text"); + variableModel.setName(""); + + restVariableCollection = restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariables(variableModel, variableModel1); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsErrorKey(RestErrorModel.VARIABLE_NAME_REQUIRED) + .containsSummary(RestErrorModel.VARIABLE_NAME_REQUIRED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/variables/DeleteTaskVariableTests.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/variables/DeleteTaskVariableTests.java new file mode 100644 index 000000000..4a046ce6d --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/variables/DeleteTaskVariableTests.java @@ -0,0 +1,231 @@ +package org.alfresco.rest.workflow.tasks.variables; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestVariableModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TaskModel; +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 bogdan.bocancea + */ +public class DeleteTaskVariableTests extends RestTest +{ + private UserModel userModel, assigneeUser, adminUser; + private SiteModel siteModel; + private FileModel fileModel; + private TaskModel taskModel; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userModel = dataUser.createRandomTestUser(); + assigneeUser = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Delete existing task variable") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + public void deleteTaskVariable() throws Exception + { + restClient.authenticateUser(adminUser); + RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + + restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables() + .assertThat().entriesListDoesNotContain("name", variableModel.getName()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Try to delete existing task variable using invalid task id") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void tryToDeleteTaskVariableUsingInvalidTaskId() throws Exception + { + restClient.authenticateUser(adminUser); + RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + + restClient.withWorkflowAPI().usingTask(taskModel).updateTaskVariable(variableModel); + taskModel.setId("incorrectTaskId"); + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Delete task variable with any user") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + public void deleteTaskVariableByAnyUser() throws Exception + { + restClient.authenticateUser(userModel); + RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + + restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables() + .assertThat().entriesListDoesNotContain("name", variableModel.getName()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Delete task variable with invalid type") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void deleteTaskVariableInvalidType() throws Exception + { + restClient.authenticateUser(userModel); + RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); + variableModel.setType("invalid-type"); + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables() + . assertThat().entriesListDoesNotContain("name", variableModel.getName()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Delete task variable with invalid name") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void deleteTaskVariableInvalidName() throws Exception + { + restClient.authenticateUser(userModel); + RestVariableModel variableModel = new RestVariableModel("local", "<>.,;/|-+=%", "d:text", "invalid name"); + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Create, update, delete task variable with any user") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void createUpdateDeleteTaskVariableByAnyUser() throws Exception + { + restClient.authenticateUser(userModel); + RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + + restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); + variableModel.setName("new-variable"); + restClient.withWorkflowAPI().usingTask(taskModel).updateTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables() + .assertThat().entriesListDoesNotContain("name", variableModel.getName()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Delete task variable by non assigned user") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void deleteTaskVariableByNonAssignedUser() throws Exception + { + UserModel nonAssigned = dataUser.createRandomTestUser(); + RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + + restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); + restClient.authenticateUser(nonAssigned).withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Delete task variable by inexistent user") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) +// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") + public void deleteTaskVariableByInexistentUser() throws Exception + { + RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); + restClient.authenticateUser(UserModel.getRandomUserModel()) + .withWorkflowAPI() + .usingTask(taskModel) + .deleteTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Delete task variable twice") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void deleteTaskVariableTwice() throws Exception + { + restClient.authenticateUser(userModel); + RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + + restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables() + .assertThat().entriesListDoesNotContain("name", variableModel.getName()); + + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, variableModel.getName())) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Delete task variable with empty variable name") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void deleteTaskEmptyVariableName() throws Exception + { + restClient.authenticateUser(userModel); + RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + + restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); + variableModel.setName(""); + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) + .assertLastError().containsErrorKey(RestErrorModel.DELETE_EMPTY_ARGUMENT) + .containsSummary(RestErrorModel.DELETE_EMPTY_ARGUMENT) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Delete task variable with empty variable scope") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void deleteTaskEmptyVariableScope() throws Exception + { + restClient.authenticateUser(userModel); + RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + + restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); + variableModel.setScope(""); + variableModel.setType(""); + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables() + .assertThat().entriesListDoesNotContain("name", variableModel.getName()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Delete task variable with invalid variable name") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void deleteTaskInvalidVariableName() throws Exception + { + restClient.authenticateUser(userModel); + RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + + restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); + variableModel.setName("invalid-name"); + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalid-name")) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/variables/GetTaskVariablesTests.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/variables/GetTaskVariablesTests.java new file mode 100644 index 000000000..90a07ba9d --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/variables/GetTaskVariablesTests.java @@ -0,0 +1,252 @@ +package org.alfresco.rest.workflow.tasks.variables; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestTaskModel; +import org.alfresco.rest.model.RestVariableModelsCollection; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TaskModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class GetTaskVariablesTests extends RestTest +{ + private UserModel userWhoStartsTask, assignee; + private SiteModel siteModel; + private FileModel fileModel; + private TaskModel taskModel; + private RestVariableModelsCollection variableModels; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + userWhoStartsTask = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); + fileModel = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Verify that user that started the process gets task variables") + public void getTaskVariablesByUserWhoStartedProcess() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask) + .usingSite(siteModel).usingResource(fileModel) + .createNewTaskAndAssignTo(assignee); + restClient.authenticateUser(userWhoStartsTask); + variableModels = restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables(); + restClient.assertStatusCodeIs(HttpStatus.OK); + variableModels.assertThat().entriesListIsNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Verify that user that is involved in the process gets task variables") + public void getTaskVariablesByUserInvolvedInProcess() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask) + .usingSite(siteModel).usingResource(fileModel) + .createNewTaskAndAssignTo(assignee); + restClient.authenticateUser(assignee); + variableModels = restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables(); + restClient.assertStatusCodeIs(HttpStatus.OK); + variableModels.assertThat().entriesListIsNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Verify that user that is not involved in the process gets task variables") + public void getTaskVariablesUsingAnyUser() throws Exception + { + UserModel randomUser = dataUser.createRandomTestUser(); + taskModel = dataWorkflow.usingUser(userWhoStartsTask) + .usingSite(siteModel).usingResource(fileModel) + .createNewTaskAndAssignTo(assignee); + restClient.authenticateUser(randomUser); + restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Verify that admin is able to task variables") + public void getTaskVariablesUsingAdmin() throws Exception + { + UserModel adminUser = dataUser.getAdminUser(); + taskModel = dataWorkflow.usingUser(userWhoStartsTask) + .usingSite(siteModel).usingResource(fileModel) + .createNewTaskAndAssignTo(assignee); + restClient.authenticateUser(adminUser); + variableModels = restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables(); + restClient.assertStatusCodeIs(HttpStatus.OK); + variableModels.assertThat().entriesListIsNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify if get task variables request returns status code 404 when invalid taskId is used") + public void getTaskVariablesUsingInvalidTaskId() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask) + .usingSite(siteModel).usingResource(fileModel) + .createNewTaskAndAssignTo(assignee); + taskModel.setId("invalidId"); + + restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingTask(taskModel).getTaskVariables(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidId")) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify if get task variables request returns status code 404 when empty taskId is used") + public void getTaskVariablesUsingEmptyTaskId() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); + taskModel.setId(""); + + restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingTask(taskModel).getTaskVariables(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify if get task variables request returns status code 200 after the task is finished.") + public void getTaskVariablesAfterFinishingTask() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); + dataWorkflow.usingUser(assignee).taskDone(taskModel); + + variableModels = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingTask(taskModel).getTaskVariables(); + restClient.assertStatusCodeIs(HttpStatus.OK); + variableModels.assertThat().entriesListIsNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify if get task variables request returns status code 200 after the process is deleted (Task state is now completed.)") + public void getTaskVariablesAfterDeletingProcess() throws Exception + { + RestProcessModel addedProcess = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.Normal); + RestTaskModel addedTask = restClient.withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess); + restClient.withWorkflowAPI().usingProcess(addedProcess).deleteProcess(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + variableModels = restClient.withWorkflowAPI().usingTask(addedTask).getTaskVariables(); + restClient.assertStatusCodeIs(HttpStatus.OK); + variableModels.assertThat().entriesListIsNotEmpty(); + } + + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify user gets task variables that matches a where clause.") + public void getTaskVariablesWithWhereClauseAsParameter() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); + variableModels = restClient.authenticateUser(userWhoStartsTask).where("scope='local'") + .withWorkflowAPI().usingTask(taskModel).getTaskVariables(); + restClient.assertStatusCodeIs(HttpStatus.OK); + variableModels.assertThat().entriesListIsNotEmpty() + .and().entriesListDoesNotContain("scope", "global") + .and().paginationField("totalItems").is("8"); + + variableModels = restClient.authenticateUser(userWhoStartsTask) + .withWorkflowAPI().usingTask(taskModel).getTaskVariables(); + restClient.assertStatusCodeIs(HttpStatus.OK); + variableModels.assertThat().entriesListContains("scope", "global") + .and().paginationField("totalItems").is("30"); + } + + @Bug(id="MNT-17438") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify user gets task with 'maxItems' parameter") + public void getTaskVariablesWithMaxItems() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); + variableModels = restClient.authenticateUser(userWhoStartsTask) + .withWorkflowAPI().usingParams("maxItems=2").usingTask(taskModel).getTaskVariables(); + restClient.assertStatusCodeIs(HttpStatus.OK); + variableModels.assertThat().entriesListIsNotEmpty() + .and().paginationField("count").is("2"); + } + + @Bug(id="MNT-17438") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify user gets task with 'skipCount' parameter") + public void getTaskVariablesWithSkipCount() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); + variableModels = restClient.authenticateUser(userWhoStartsTask) + .withWorkflowAPI().usingParams("skipCount=10").usingTask(taskModel).getTaskVariables(); + restClient.assertStatusCodeIs(HttpStatus.OK); + variableModels.assertThat().entriesListIsNotEmpty() + .and().paginationField("count").is("20"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify user cannot get task variables with invalid where clause.") + public void getTaskVariablesWithInvalidWhereClauseAsParameter() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); + variableModels = restClient.authenticateUser(userWhoStartsTask).where("scope='fake-where'") + .withWorkflowAPI().usingTask(taskModel).getTaskVariables(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_WHERE_QUERY, "Invalid value for 'scope' used in query: fake-where.")) + .containsErrorKey(RestErrorModel.INVALID_QUERY_ERRORKEY) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify user gets tasks variables with 'properties' parameter") + public void getTaskVariablesWithValidProperties() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); + variableModels = restClient.authenticateUser(userWhoStartsTask).withParams("properties=scope,name") + .withWorkflowAPI().usingTask(taskModel).getTaskVariables(); + restClient.assertStatusCodeIs(HttpStatus.OK); + variableModels.assertThat().entriesListIsNotEmpty(); + variableModels.getOneRandomEntry().onModel().assertThat() + .fieldsCount().is(2).and() + .field("type").isNull().and() + .field("value").isNull().and() + .field("scope").isNotEmpty().and() + .field("name").isNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify user cannot get tasks variables with invalid 'properties' parameter") + public void getTaskVariablesWithInvalidProperties() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); + variableModels = restClient.authenticateUser(userWhoStartsTask).withParams("properties=fake") + .withWorkflowAPI().usingTask(taskModel).getTaskVariables(); + restClient.assertStatusCodeIs(HttpStatus.OK); + variableModels.getOneRandomEntry().onModel().assertThat() + .fieldsCount().is(0).and() + .field("type").isNull().and() + .field("value").isNull().and() + .field("scope").isNull().and() + .field("name").isNull(); + } +} diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk1.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk1.java new file mode 100644 index 000000000..c3718b38f --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk1.java @@ -0,0 +1,79 @@ +package org.alfresco.rest.workflow.tasks.variables; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestVariableModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TaskModel; +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 UpdateTaskVariableTestsBulk1 extends RestTest +{ + private UserModel userModel; + private UserModel adminUser; + private SiteModel siteModel; + private FileModel fileModel; + private UserModel assigneeUser; + private TaskModel taskModel; + + private RestVariableModel taskVariable; + private RestVariableModel variableModel; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + assigneeUser = dataUser.createRandomTestUser(); + taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Create non-existing task variable") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + public void createTaskVariable() throws Exception + { + restClient.authenticateUser(adminUser); + variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + + taskVariable = restClient.withWorkflowAPI().usingTask(taskModel).updateTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + taskVariable.assertThat().field("scope").is(taskVariable.getScope()) + .and().field("name").is(taskVariable.getName()) + .and().field("type").is(taskVariable.getType()) + .and().field("value").is(taskVariable.getValue()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Update existing task variable") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + public void updateExistingTaskVariable() throws Exception + { + restClient.authenticateUser(adminUser); + variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + + taskVariable = restClient.withWorkflowAPI().usingTask(taskModel).updateTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + taskVariable.assertThat().field("scope").is(taskVariable.getScope()) + .and().field("name").is(taskVariable.getName()) + .and().field("type").is(taskVariable.getType()) + .and().field("value").is(taskVariable.getValue()); + + variableModel.setValue("updatedValue"); + taskVariable = restClient.withWorkflowAPI().usingTask(taskModel).updateTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + taskVariable.assertThat().field("value").is("updatedValue"); + } +} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk2.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk2.java new file mode 100644 index 000000000..53fe2f6a2 --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk2.java @@ -0,0 +1,173 @@ +package org.alfresco.rest.workflow.tasks.variables; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestVariableModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TaskModel; +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 bogdan.bocancea + */ +public class UpdateTaskVariableTestsBulk2 extends RestTest +{ + private UserModel userModel; + private SiteModel siteModel; + private FileModel fileModel; + private UserModel assigneeUser; + private TaskModel taskModel; + private RestVariableModel taskVariable; + private RestVariableModel variableModel; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + assigneeUser = dataUser.createRandomTestUser(); + taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Update task variable by user who started the process") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + public void updateTaskVariableByUserWhoStartedProcess() throws Exception + { + variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + taskVariable = restClient.authenticateUser(userModel) + .withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + variableModel.setValue("new-value"); + variableModel.setName("new-name"); + taskVariable = restClient.authenticateUser(userModel). + withWorkflowAPI().usingTask(taskModel).updateTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + taskVariable.assertThat().field("value").is("new-value") + .and().field("name").is("new-name"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Update task variable with symbols in name") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void updateTaskVariableWithSymbolsInName() throws Exception + { + String symbolName = "<>.,;-'+=%|[]#*&-+"; + variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + taskVariable = restClient.authenticateUser(userModel) + .withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + variableModel.setName(symbolName); + taskVariable = restClient.authenticateUser(userModel). + withWorkflowAPI().usingTask(taskModel).updateTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + taskVariable.assertThat().field("name").is(symbolName); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Update task variable with invalid task id") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void updateTaskVariableWithInvalidTaskId() throws Exception + { + TaskModel invalidTask = new TaskModel(userModel.getUsername()); + invalidTask.setId("invalid-task-id"); + taskVariable = restClient.authenticateUser(userModel). + withWorkflowAPI().usingTask(invalidTask) + .updateTaskVariable(RestVariableModel.getRandomTaskVariableModel("local", "d:text")); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, invalidTask.getId())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Update task variable with invalid scope") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void updateTaskVariableWithInvalidScope() throws Exception + { + variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + taskVariable = restClient.authenticateUser(userModel) + .withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + variableModel.setScope("invalid-scope"); + taskVariable = restClient.authenticateUser(userModel). + withWorkflowAPI().usingTask(taskModel).updateTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.ILLEGAL_SCOPE, "invalid-scope")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Update task variable with invalid type") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void updateTaskVariableWithInvalidType() throws Exception + { + variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + taskVariable = restClient.authenticateUser(userModel) + .withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + variableModel.setType("d:invalidType"); + taskVariable = restClient.authenticateUser(userModel). + withWorkflowAPI().usingTask(taskModel).updateTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.UNSUPPORTED_TYPE, "d:invalidType")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Update task variable with symbols in value") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void updateTaskVariableWithSymbolsInValue() throws Exception + { + String symbolValue = "<>.,;-'+=%|[]#*&-+/\\#!@"; + variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + taskVariable = restClient.authenticateUser(userModel) + .withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + variableModel.setValue(symbolValue); + taskVariable = restClient.authenticateUser(userModel). + withWorkflowAPI().usingTask(taskModel).updateTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + taskVariable.assertThat().field("value").is(symbolValue); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Update task variable by non assigned user") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void updateTaskVariableByNonAssignedUser() throws Exception + { + UserModel nonAssigned = dataUser.createRandomTestUser(); + variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + taskVariable = restClient.authenticateUser(userModel) + .withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + variableModel.setName("new-name"); + taskVariable = restClient.authenticateUser(nonAssigned) + .withWorkflowAPI().usingTask(taskModel).updateTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Update task variable by inexistent user") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) +// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") + public void updateTaskVariableByNonexistentUser() throws Exception + { + variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + taskVariable = restClient.authenticateUser(userModel) + .withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + variableModel.setName("new-name"); + taskVariable = restClient.authenticateUser(UserModel.getRandomUserModel()) + .withWorkflowAPI().usingTask(taskModel).updateTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + +} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk3.java b/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk3.java new file mode 100644 index 000000000..156be6a2e --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk3.java @@ -0,0 +1,247 @@ +package org.alfresco.rest.workflow.tasks.variables; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestVariableModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TaskModel; +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 UpdateTaskVariableTestsBulk3 extends RestTest +{ + private SiteModel siteModel; + private FileModel fileModel; + private TaskModel taskModel; + private UserModel userModel; + private RestVariableModel taskVariable, updatedTaskVariable; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(userModel); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Update task variable with invalid name - PUT call") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void updateTaskVariableWithInvalidVariableName() throws Exception + { + taskVariable = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + restClient.authenticateUser(userModel) + .withWorkflowAPI().usingTask(taskModel).addTaskVariable(taskVariable); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"scope\": \"local\",\"names\": \"varName\",\"value\": \"test\"," + + "\"type\": \"d:text\"}", + "tasks/{taskId}/variables/{variableName}", taskModel.getId(), taskVariable.getName()); + restClient.processModel(RestVariableModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsSummary(String.format(RestErrorModel.NO_CONTENT,"Unrecognized field " + "\"names\"")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Update task variable with invalid name - PUT call") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void updateTaskVariableWithInvalidVariableValue() throws Exception + { + taskVariable = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + restClient.authenticateUser(userModel) + .withWorkflowAPI().usingTask(taskModel).addTaskVariable(taskVariable); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"scope\": \"local\",\"name\": \"varName\",\"values\": \"test\"," + + "\"type\": \"d:text\"}", + "tasks/{taskId}/variables/{variableName}", taskModel.getId(), taskVariable.getName()); + restClient.processModel(RestVariableModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsSummary(String.format(RestErrorModel.NO_CONTENT,"Unrecognized field " + "\"values\"")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Update task variable with invalid name - PUT call") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void updateTaskVariableWithEmptyVariableName() throws Exception + { + taskVariable = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + restClient.authenticateUser(userModel) + .withWorkflowAPI().usingTask(taskModel).addTaskVariable(taskVariable); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"scope\": \"local\",\"\": \"varName\",\"value\": \"test\"," + + "\"type\": \"d:text\"}", + "tasks/{taskId}/variables/{variableName}", taskModel.getId(), taskVariable.getName()); + restClient.processModel(RestVariableModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsSummary(String.format(RestErrorModel.NO_CONTENT,"Unrecognized field " + "\"\"")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Update task variable with empty name - PUT call") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void updateTaskVariableWithEmptyName() throws Exception + { + taskVariable = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).addTaskVariable(taskVariable); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + taskVariable.setName(""); + restClient.withWorkflowAPI().usingTask(taskModel).updateTaskVariable(taskVariable); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) + .assertLastError().containsErrorKey(RestErrorModel.PUT_EMPTY_ARGUMENT) + .containsSummary(RestErrorModel.PUT_EMPTY_ARGUMENT) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Update task variable with empty name - PUT call") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void updateTaskVariableWithInvalidName() throws Exception + { + taskVariable = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).addTaskVariable(taskVariable); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"scope\": \"local\",\"name\": ',\"value\": \"test\"," + + "\"type\": \"d:text\"}", + "tasks/{taskId}/variables/{variableName}", taskModel.getId(), taskVariable.getName()); + restClient.processModel(RestVariableModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsSummary(String.format(RestErrorModel.NO_CONTENT,"Unexpected character " + "('''")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Update task variable with empty name - PUT call") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void updateTaskVariableWithInvalidValue() throws Exception + { + taskVariable = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).addTaskVariable(taskVariable); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"scope\": \"local\",\"name\": \"varName\",\"value\"::," + + "\"type\": \"d:text\"}", + "tasks/{taskId}/variables/{variableName}", taskModel.getId(), taskVariable.getName()); + restClient.processModel(RestVariableModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsSummary(String.format(RestErrorModel.NO_CONTENT,"Unexpected character " + "(':'")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Update task variable with empty name - PUT call") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void updateTaskVariableWithMissingType() throws Exception + { + taskVariable = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + restClient.authenticateUser(userModel) + .withWorkflowAPI().usingTask(taskModel).addTaskVariable(taskVariable); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"scope\": \"local\",\"name\": \"varName\",\"value\": \"test\"}", + "tasks/{taskId}/variables/{variableName}", taskModel.getId(), taskVariable.getName()); + restClient.processModel(RestVariableModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.OK); + taskVariable.assertThat().field("scope").is(taskVariable.getScope()) + .and().field("name").is(taskVariable.getName()) + .and().field("type").is("d:text") + .and().field("value").is(taskVariable.getValue()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Update task variable with empty name - PUT call") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void updateTaskVariableWithMissingTypeAndValue() throws Exception + { + taskVariable = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + restClient.authenticateUser(userModel) + .withWorkflowAPI().usingTask(taskModel).addTaskVariable(taskVariable); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"scope\": \"local\",\"name\": \"varName\"}", + "tasks/{taskId}/variables/{variableName}", taskModel.getId(), taskVariable.getName()); + updatedTaskVariable = restClient.processModel(RestVariableModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedTaskVariable.assertThat().field("scope").is(updatedTaskVariable.getScope()) + .and().field("name").is(updatedTaskVariable.getName()) + .and().field("type").is("d:any"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Update task variable with invalid name - PUT call") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void updateTaskVariableWithEmptyBody() throws Exception + { + taskVariable = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + restClient.authenticateUser(userModel) + .withWorkflowAPI().usingTask(taskModel).addTaskVariable(taskVariable); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{}", + "tasks/{taskId}/variables/{variableName}", taskModel.getId(), taskVariable.getName()); + restClient.processModel(RestVariableModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsErrorKey(RestErrorModel.VARIABLE_NAME_REQUIRED) + .containsSummary(RestErrorModel.VARIABLE_NAME_REQUIRED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Update task variable with invalid name - PUT call") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void updateTaskVariableWithInvalidBody() throws Exception + { + taskVariable = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + restClient.authenticateUser(userModel) + .withWorkflowAPI().usingTask(taskModel).addTaskVariable(taskVariable); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"scope\": \"local\",\"name\": \"varName\",\"value\": \"test\"," + + "\"type\": \"d:text\", \"errorKey\": \"invalidBody\"}", + "tasks/{taskId}/variables/{variableName}", taskModel.getId(), taskVariable.getName()); + restClient.processModel(RestVariableModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsSummary(String.format(RestErrorModel.NO_CONTENT,"Unrecognized field " + "\"errorKey\"")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Update task variable with empty name - PUT call") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void updateTwiceInARowSameTaskVariable() throws Exception + { + taskVariable = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).addTaskVariable(taskVariable); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + taskVariable.setName("newName"); + taskVariable.setScope("global"); + updatedTaskVariable = restClient.withWorkflowAPI().usingTask(taskModel).updateTaskVariable(taskVariable); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedTaskVariable.assertThat().field("scope").is("global"); + updatedTaskVariable.assertThat().field("name").is("newName"); + + updatedTaskVariable = restClient.withWorkflowAPI().usingTask(taskModel).updateTaskVariable(taskVariable); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedTaskVariable.assertThat().field("scope").is("global"); + updatedTaskVariable.assertThat().field("name").is("newName"); + } +} diff --git a/e2e-test/src/test/resources/SearchSuite.xml b/e2e-test/src/test/resources/SearchSuite.xml new file mode 100644 index 000000000..425276be0 --- /dev/null +++ b/e2e-test/src/test/resources/SearchSuite.xml @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/e2e-test/src/test/resources/alfresco-restapi-context.xml b/e2e-test/src/test/resources/alfresco-restapi-context.xml new file mode 100644 index 000000000..8b2ce79cb --- /dev/null +++ b/e2e-test/src/test/resources/alfresco-restapi-context.xml @@ -0,0 +1,17 @@ + + + + + + + + + diff --git a/e2e-test/src/test/resources/default.properties b/e2e-test/src/test/resources/default.properties new file mode 100644 index 000000000..08d38d82f --- /dev/null +++ b/e2e-test/src/test/resources/default.properties @@ -0,0 +1,84 @@ +# dataprep related +alfresco.scheme=http +alfresco.server=localhost +alfresco.port=8081 + +# sync service related +sync.scheme=http +sync.server=localhost +sync.port=9090 + +# Solr Server Settings +solr.scheme=http +solr.server=localhost +solr.port=8083 + +#Solr Indexing Time +solrWaitTimeInSeconds=20 + +# credentials +admin.user=admin +admin.password=admin + +# in containers we cannot access directly JMX, so we will use http://jolokia.org agent +# disabling this we will use direct JMX calls to server +jmx.useJolokiaAgent=false + +# Server Health section +# in ServerHealth#isServerReachable() - could also be shown. +# enable this option to view if on server there are tenants or not +serverHealth.showTenants=false + +# TEST MANAGEMENT SECTION - Test Rail +# +# (currently supporting Test Rail v5.2.1.3472 integration) +# +# Example of configuration: +# ------------------------------------------------------ +# if testManagement.enabled=true we enabled TestRailExecutorListener (if used in your suite xml file) +# testManagement.updateTestExecutionResultsOnly=true (this will just update the results of a test: no step will be updated - good for performance) +# testManagement.endPoint=https://alfresco.testrail.com/ +# testManagement.username= +# testManagement.apiKey= +# testManagement.project= +# testManagement.includeOnlyTestCasesExecuted=true #if you want to include in your run ONLY the test cases that you run, then set this value to false +# testManagement.rateLimitInSeconds=1 #is the default rate limit after what minimum time, should we upload the next request. http://docs.gurock.com/testrail-api2/introduction #Rate Limit +# testManagement.suiteId=23 (the id of the Master suite) +# ------------------------------------------------------ +testManagement.enabled=false +testManagement.endPoint=https://alfresco.testrail.com/ +testManagement.username=tas.alfresco@gmail.com +testManagement.apiKey=EYpY7.fV0AoMGWbmyuVC-k5u.nzwHy6a.QWzJq8.S +testManagement.project=7 +testManagement.includeOnlyTestCasesExecuted=true +testManagement.rateLimitInSeconds=1 +testManagement.testRun=MyTestRunInTestRail +testManagement.suiteId=12 + +# The location of the reports path +reports.path=./target/reports + +# +# Database Section +# You should provide here the database URL, that can be a differed server as alfresco. +# https://docs.oracle.com/javase/tutorial/jdbc/basics/connecting.html +# +# Current supported db.url: +# +# MySQL: +# db.url = jdbc:mysql://${alfresco.server}:3306/alfresco +# +# PostgreSQL: +# db.url = jdbc:postgresql://:3306/alfresco +# +# Oracle: +# db.url = jdbc:oracle://:3306/alfresco +# +# MariaDB: +# db.url = jdbc:mariadb://:3306/alfresco +# +db.url = jdbc:mysql://${alfresco.server}:3306/alfresco +db.username = alfresco +db.password = alfresco + diff --git a/e2e-test/src/test/resources/log4j.properties b/e2e-test/src/test/resources/log4j.properties new file mode 100644 index 000000000..00e9b5a11 --- /dev/null +++ b/e2e-test/src/test/resources/log4j.properties @@ -0,0 +1,26 @@ +# Root logger option +log4j.rootLogger=INFO, file, stdout + +# Direct log messages to a log file +log4j.appender.file=org.apache.log4j.RollingFileAppender +log4j.appender.file.File=./target/reports/alfresco-tas.log +log4j.appender.file.MaxBackupIndex=10 +log4j.appender.file.layout=org.apache.log4j.PatternLayout +log4j.appender.file.layout.ConversionPattern=[%t] %d{HH:mm:ss} %-5p %c{1}:%L - %m%n + +# Direct log messages to stdout +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.Target=System.out +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=[%t] %d{HH:mm:ss} %-5p %c{1}:%L - %m%n + +# TestRail particular log file +# Direct log messages to a log file +log4j.appender.testrailLog=org.apache.log4j.RollingFileAppender +log4j.appender.testrailLog.File=./target/reports/alfresco-testrail.log +log4j.appender.testrailLog.MaxBackupIndex=10 +log4j.appender.testrailLog.layout=org.apache.log4j.PatternLayout +log4j.appender.testrailLog.layout.ConversionPattern=%d{HH:mm:ss} %-5p %c{1}:%L - %m%n + +log4j.category.testrail=INFO, testrailLog +log4j.additivity.testrail=false \ No newline at end of file diff --git a/e2e-test/src/test/resources/models/SEARCH-1063.xml b/e2e-test/src/test/resources/models/SEARCH-1063.xml new file mode 100755 index 000000000..816afd2bc --- /dev/null +++ b/e2e-test/src/test/resources/models/SEARCH-1063.xml @@ -0,0 +1,159 @@ + + + Administrator admin user + + + + + + + + + + + + + + + + + song + cm:content + + + Name + d:text + false + + true + BOTH + false + + + + Genre + d:text + false + + true + BOTH + false + + + + Producer + d:text + false + + true + BOTH + false + + + + + + + + + Artist + cm:content + + + Name + d:text + false + + true + BOTH + false + + + + Voice Type + d:text + false + + true + BOTH + false + + + + + + + + + + Bassist + cm:content + + + Name + d:text + false + + true + BOTH + false + + + + + + + + + Drummer + cm:content + + + Name + d:text + false + + true + BOTH + false + + + + + + + + + Sax + cm:content + + + Name + d:text + false + + true + BOTH + false + + + + + + + + + + \ No newline at end of file From 1a6f4de941ce0fcfb31a93c5ecaf28918f2809a2 Mon Sep 17 00:00:00 2001 From: agazzarini Date: Fri, 29 Mar 2019 10:26:30 +0100 Subject: [PATCH 1476/1491] [ SEARCH-1485 ] TAS-RESTAPI dependency updated from 6.0.0.1 to 6.0.0.3 --- e2e-test/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/pom.xml b/e2e-test/pom.xml index dd26657f6..3f5733bcb 100644 --- a/e2e-test/pom.xml +++ b/e2e-test/pom.xml @@ -11,7 +11,7 @@ Search Analytics E2E Tests Test Project to test Search Service and Analytics Features on a complete setup of Alfresco, Share - 6.0.0.1 + 6.0.0.3 6.0.0.0 2.0.1 2.6.0 From cd2acb53bf08f07b6aad3949fa8f938dbaa1e3a0 Mon Sep 17 00:00:00 2001 From: agazzarini Date: Fri, 29 Mar 2019 15:20:12 +0100 Subject: [PATCH 1477/1491] [ SEARCH-1485 ] moved RESTAPI tests under org.alfresco.service.search.rest namespace (package) --- e2e-test/resources/SearchSuite.xml | 36 ++++++++--------- .../search}/rest/FunctionalCasesTests.java | 2 +- .../search}/rest/NetworkDataPrep.java | 2 +- .../{ => service/search}/rest/RestTest.java | 2 +- .../search}/rest/actions/ActionsTests.java | 4 +- .../search}/rest/aos/AosApiTest.java | 4 +- .../search}/rest/audit/AuditTest.java | 4 +- .../search}/rest/audit/DeleteAuditTests.java | 2 +- .../search}/rest/audit/GetAuditTests.java | 2 +- .../search}/rest/audit/PutAuditTests.java | 2 +- .../search}/rest/auth/AuthTests.java | 4 +- .../search}/rest/cmis/CmisBrowserTest.java | 4 +- .../rest/comments/AddCommentTests.java | 4 +- .../rest/comments/AddCommentsTests.java | 4 +- .../rest/comments/DeleteCommentTests.java | 4 +- .../rest/comments/GetCommentsTests.java | 4 +- .../rest/comments/UpdateCommentTests.java | 4 +- .../search}/rest/demo/RestDemoTests.java | 4 +- .../rest/demo/SampleCommentsTests.java | 4 +- .../search}/rest/demo/SamplePeopleTests.java | 4 +- .../search}/rest/demo/SampleSitesTests.java | 4 +- .../rest/demo/workshop/RestApiDemoTests.java | 4 +- .../demo/workshop/RestApiWorkshopTests.java | 4 +- .../rest/discovery/DiscoveryTests.java | 4 +- .../rest/downloads/DownloadsTests.java | 4 +- .../rest/favorites/AddFavoriteSiteTests.java | 4 +- .../rest/favorites/AddFavoritesTests.java | 4 +- .../favorites/DeleteFavoriteSiteTests.java | 4 +- .../rest/favorites/DeleteFavoriteTests.java | 4 +- .../favorites/FavoritesIncludePathTests.java | 4 +- .../rest/favorites/FavoritesNetworkTests.java | 4 +- .../rest/favorites/GetFavoriteSiteTests.java | 4 +- .../rest/favorites/GetFavoriteSitesTests.java | 4 +- .../rest/favorites/GetFavoriteTests.java | 4 +- .../rest/favorites/GetFavoritesTests.java | 4 +- .../search}/rest/groups/GroupsTests.java | 4 +- .../RestGetNetworkForPersonTests.java | 4 +- .../rest/networks/RestGetNetworkTests.java | 4 +- .../RestGetNetworksForPersonTests.java | 4 +- .../nodes/NodesActionDefinitionTests.java | 4 +- .../nodes/NodesContentAndVersioningTests.java | 4 +- .../search}/rest/nodes/NodesLockTests.java | 4 +- .../rest/nodes/NodesParentChildrenTests.java | 4 +- .../rest/nodes/NodesTargetSourcesTests.java | 4 +- .../search}/rest/nodes/NodesTests.java | 4 +- .../search}/rest/nodes/NodesUnlockTests.java | 4 +- .../rest/people/AvatarPeopleSanityTest.java | 4 +- .../people/DeleteSiteMemberCoreTests.java | 4 +- .../people/DeleteSiteMemberFullTests.java | 4 +- .../people/DeleteSiteMemberSanityTests.java | 4 +- .../rest/people/GetPeopleCoreTests.java | 4 +- .../rest/people/GetPeopleFullTests.java | 4 +- .../rest/people/GetPeopleSanityTests.java | 4 +- .../people/GetSiteMembershipCoreTests.java | 4 +- .../people/GetSiteMembershipFullTests.java | 4 +- .../people/GetSiteMembershipSanityTests.java | 4 +- ...etSitesMembershipInformationCoreTests.java | 4 +- ...etSitesMembershipInformationFullTests.java | 4 +- ...SitesMembershipInformationSanityTests.java | 4 +- .../GetPeopleActivitiesCoreTests.java | 4 +- .../GetPeopleActivitiesFullTests.java | 4 +- .../GetPeopleActivitiesSanityTests.java | 4 +- .../GetPeoplePreferenceCoreTests.java | 4 +- .../GetPeoplePreferenceFullTests.java | 4 +- .../GetPeoplePreferenceSanityTests.java | 4 +- .../GetPeoplePreferencesCoreTests.java | 4 +- .../GetPeoplePreferencesFullTests.java | 4 +- .../GetPeoplePreferencesSanityTests.java | 4 +- .../search}/rest/queries/QueriesTest.java | 4 +- .../search}/rest/ratings/AddRatingTests.java | 4 +- .../rest/ratings/DeleteRatingTests.java | 4 +- .../search}/rest/ratings/GetRatingTests.java | 4 +- .../search}/rest/ratings/GetRatingsTests.java | 4 +- .../renditions/AvailableRenditionTests.java | 2 +- .../rest/renditions/CreateRenditionTests.java | 4 +- .../rest/renditions/GetRenditionTests.java | 4 +- .../renditions/RenditionIntegrationTests.java | 4 +- .../rest/search/AbstractSearchTest.java | 11 +++-- .../rest/search/FacetFieldsSearchTest.java | 9 ++++- .../rest/search/FacetIntervalSearchTest.java | 9 ++++- .../rest/search/FacetRangeSearchTest.java | 6 ++- .../rest/search/FacetedSearchTest.java | 12 +++++- .../search}/rest/search/FingerPrintTest.java | 4 +- .../rest/search/PivotFacetedSearchTest.java | 10 ++++- .../search}/rest/search/SearchAPATHTest.java | 9 ++++- .../rest/search/SearchHighLightTest.java | 8 +++- .../rest/search/SearchSpellCheckTest.java | 5 ++- .../search}/rest/search/SearchTest.java | 7 +++- .../search}/rest/search/ShardInfoTest.java | 6 ++- .../search}/rest/search/StatsSearchTest.java | 14 ++++++- .../rest/search/solr/SearchSolrAPITest.java | 4 +- .../rest/search/sql/SearchSQLAPITest.java | 4 +- .../rest/search/sql/SearchSQLPhraseTest.java | 4 +- .../rest/search/sql/SearchSQLViaJDBCTest.java | 4 +- .../sql/SearchSQLWithQuotedIdentifiers.java | 6 +-- .../sharedLinks/GetSharedLinksFullTests.java | 4 +- .../sharedLinks/SharedLinksSanityTests.java | 4 +- .../search}/rest/sites/GetSiteTests.java | 4 +- .../search}/rest/sites/GetSitesTests.java | 4 +- .../search}/rest/sites/SitesNetworkTests.java | 4 +- .../search}/rest/sites/SitesTests.java | 4 +- .../containers/GetSiteContainerTests.java | 4 +- .../containers/GetSiteContainersTests.java | 4 +- .../sites/members/AddSiteMemberTests.java | 4 +- .../sites/members/GetSiteMemberTests.java | 4 +- .../sites/members/GetSiteMembersTests.java | 4 +- .../sites/members/RemoveSiteMemberTests.java | 4 +- .../sites/members/UpdateSiteMemberTests.java | 4 +- .../AddSiteMembershipRequestTests.java | 4 +- .../DeleteSiteMembershipRequestTests.java | 4 +- .../GetSiteMembershipRequestTests.java | 4 +- .../GetSiteMembershipRequestsTests.java | 4 +- .../UpdateSiteMembershipRequestTests.java | 4 +- .../rest/syncService/SyncServiceAPITests.java | 4 +- .../search}/rest/tags/GetTagTests.java | 2 +- .../search}/rest/tags/GetTagsTests.java | 2 +- .../search}/rest/tags/TagsDataPrep.java | 4 +- .../search}/rest/tags/UpdateTagTests.java | 2 +- .../search}/rest/tags/nodes/AddTagTests.java | 4 +- .../search}/rest/tags/nodes/AddTagsTests.java | 4 +- .../rest/tags/nodes/DeleteTagTests.java | 4 +- .../rest/tags/nodes/GetNodeTagsTests.java | 4 +- .../rest/trashcan/GetDeletedNodesTests.java | 4 +- .../WorkflowNetworkDeploymentsTests.java | 4 +- ...orkflowNetworkProcessDefinitionsTests.java | 4 +- .../WorkflowNetworkProcessesTests.java | 4 +- .../workflow/WorkflowNetworkTasksTests.java | 4 +- .../deployments/DeleteDeploymentTests.java | 4 +- .../deployments/GetDeploymentCoreTests.java | 4 +- .../deployments/GetDeploymentFullTests.java | 4 +- .../deployments/GetDeploymentSanityTests.java | 4 +- .../deployments/GetDeploymentsCoreTests.java | 4 +- .../deployments/GetDeploymentsFullTests.java | 4 +- .../GetDeploymentsSanityTests.java | 4 +- .../GetProcessDefinitionCoreTests.java | 4 +- .../GetProcessDefinitionFullTests.java | 4 +- .../GetProcessDefinitionImageCoreTests.java | 4 +- .../GetProcessDefinitionImageFullTests.java | 4 +- .../GetProcessDefinitionImageSanityTests.java | 4 +- .../GetProcessDefinitionSanityTests.java | 4 +- ...cessDefinitionStartFormModelCoreTests.java | 4 +- ...cessDefinitionStartFormModelFullTests.java | 4 +- ...ssDefinitionStartFormModelSanityTests.java | 4 +- .../GetProcessDefinitionsCoreTests.java | 4 +- .../GetProcessDefinitionsFullTests.java | 4 +- .../GetProcessDefinitionsSanityTests.java | 4 +- .../processes/AddProcessCoreTests.java | 6 +-- .../processes/AddProcessFullTests.java | 4 +- .../processes/AddProcessSanityTests.java | 4 +- .../processes/DeleteProcessCoreTests.java | 4 +- .../processes/DeleteProcessFullTests.java | 4 +- .../processes/DeleteProcessSanityTests.java | 4 +- .../processes/GetProcessCoreTests.java | 4 +- .../processes/GetProcessFullTests.java | 4 +- .../processes/GetProcessSanityTests.java | 4 +- .../processes/GetProcessesCoreTests.java | 4 +- .../processes/GetProcessesFullTests.java | 4 +- .../processes/GetProcessesSanityTests.java | 4 +- .../items/AddProcessItemCoreTests.java | 4 +- .../items/AddProcessItemFullTests.java | 4 +- .../items/AddProcessItemSanityTests.java | 4 +- .../items/DeleteProcessItemCoreTests.java | 4 +- .../items/DeleteProcessItemFullTests.java | 4 +- .../items/DeleteProcessItemSanityTests.java | 4 +- .../items/GetProcessItemsCoreTests.java | 4 +- .../items/GetProcessItemsFullTests.java | 4 +- .../items/GetProcessItemsSanityTests.java | 4 +- .../tasks/GetProcessTasksCoreTests.java | 4 +- .../tasks/GetProcessTasksFullTests.java | 4 +- .../tasks/GetProcessTasksSanityTests.java | 4 +- .../AddProcessVariableCoreTests.java | 4 +- .../AddProcessVariableFullTests.java | 4 +- .../AddProcessVariableSanityTests.java | 4 +- .../AddProcessVariablesCoreTests.java | 4 +- .../AddProcessVariablesFullTests.java | 4 +- .../AddProcessVariablesSanityTests.java | 4 +- .../DeleteProcessVariableCoreTests.java | 4 +- .../DeleteProcessVariableFullTests.java | 4 +- .../DeleteProcessVariableSanityTests.java | 4 +- .../GetProcessVariablesCoreTests.java | 4 +- .../GetProcessVariablesFullTests.java | 4 +- .../GetProcessVariablesSanityTests.java | 4 +- .../variables/UpdateProcessVariableTests.java | 4 +- .../workflow/tasks/GetTaskFormModelTests.java | 4 +- .../rest/workflow/tasks/GetTaskTests.java | 4 +- .../rest/workflow/tasks/GetTasksTests.java | 4 +- .../rest/workflow/tasks/UpdateTaskTests.java | 4 +- .../GetTaskCandidatesRegressionTests.java | 4 +- .../GetTaskCandidatesSanityTests.java | 4 +- .../tasks/items/AddTaskItemTestsBulk1.java | 4 +- .../tasks/items/AddTaskItemTestsBulk2.java | 4 +- .../tasks/items/AddTaskItemTestsBulk3.java | 4 +- .../items/GetTaskItemsRegressionTests.java | 4 +- .../tasks/items/GetTaskItemsSanityTests.java | 4 +- .../tasks/items/RemoveTaskItemTests.java | 4 +- .../variables/AddTaskVariablesTestsBulk1.java | 4 +- .../variables/AddTaskVariablesTestsBulk2.java | 4 +- .../variables/AddTaskVariablesTestsBulk3.java | 4 +- .../variables/DeleteTaskVariableTests.java | 4 +- .../variables/GetTaskVariablesTests.java | 4 +- .../UpdateTaskVariableTestsBulk1.java | 4 +- .../UpdateTaskVariableTestsBulk2.java | 4 +- .../UpdateTaskVariableTestsBulk3.java | 4 +- e2e-test/src/test/resources/SearchSuite.xml | 40 +++++++++---------- 204 files changed, 499 insertions(+), 427 deletions(-) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/FunctionalCasesTests.java (98%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/NetworkDataPrep.java (97%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/RestTest.java (98%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/actions/ActionsTests.java (98%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/aos/AosApiTest.java (87%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/audit/AuditTest.java (98%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/audit/DeleteAuditTests.java (98%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/audit/GetAuditTests.java (99%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/audit/PutAuditTests.java (99%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/auth/AuthTests.java (97%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/cmis/CmisBrowserTest.java (90%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/comments/AddCommentTests.java (99%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/comments/AddCommentsTests.java (99%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/comments/DeleteCommentTests.java (97%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/comments/GetCommentsTests.java (98%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/comments/UpdateCommentTests.java (98%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/demo/RestDemoTests.java (97%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/demo/SampleCommentsTests.java (95%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/demo/SamplePeopleTests.java (90%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/demo/SampleSitesTests.java (96%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/demo/workshop/RestApiDemoTests.java (94%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/demo/workshop/RestApiWorkshopTests.java (89%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/discovery/DiscoveryTests.java (98%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/downloads/DownloadsTests.java (98%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/favorites/AddFavoriteSiteTests.java (99%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/favorites/AddFavoritesTests.java (99%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/favorites/DeleteFavoriteSiteTests.java (99%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/favorites/DeleteFavoriteTests.java (99%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/favorites/FavoritesIncludePathTests.java (98%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/favorites/FavoritesNetworkTests.java (99%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/favorites/GetFavoriteSiteTests.java (99%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/favorites/GetFavoriteSitesTests.java (99%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/favorites/GetFavoriteTests.java (99%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/favorites/GetFavoritesTests.java (99%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/groups/GroupsTests.java (98%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/networks/RestGetNetworkForPersonTests.java (98%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/networks/RestGetNetworkTests.java (98%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/networks/RestGetNetworksForPersonTests.java (98%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/nodes/NodesActionDefinitionTests.java (97%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/nodes/NodesContentAndVersioningTests.java (99%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/nodes/NodesLockTests.java (99%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/nodes/NodesParentChildrenTests.java (99%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/nodes/NodesTargetSourcesTests.java (98%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/nodes/NodesTests.java (95%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/nodes/NodesUnlockTests.java (98%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/people/AvatarPeopleSanityTest.java (96%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/people/DeleteSiteMemberCoreTests.java (98%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/people/DeleteSiteMemberFullTests.java (98%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/people/DeleteSiteMemberSanityTests.java (98%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/people/GetPeopleCoreTests.java (96%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/people/GetPeopleFullTests.java (97%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/people/GetPeopleSanityTests.java (98%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/people/GetSiteMembershipCoreTests.java (98%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/people/GetSiteMembershipFullTests.java (98%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/people/GetSiteMembershipSanityTests.java (98%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/people/GetSitesMembershipInformationCoreTests.java (98%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/people/GetSitesMembershipInformationFullTests.java (99%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/people/GetSitesMembershipInformationSanityTests.java (98%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/people/activities/GetPeopleActivitiesCoreTests.java (98%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/people/activities/GetPeopleActivitiesFullTests.java (99%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/people/activities/GetPeopleActivitiesSanityTests.java (98%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/people/preferences/GetPeoplePreferenceCoreTests.java (97%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/people/preferences/GetPeoplePreferenceFullTests.java (99%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/people/preferences/GetPeoplePreferenceSanityTests.java (98%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/people/preferences/GetPeoplePreferencesCoreTests.java (98%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/people/preferences/GetPeoplePreferencesFullTests.java (98%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/people/preferences/GetPeoplePreferencesSanityTests.java (98%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/queries/QueriesTest.java (98%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/ratings/AddRatingTests.java (99%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/ratings/DeleteRatingTests.java (99%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/ratings/GetRatingTests.java (99%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/ratings/GetRatingsTests.java (99%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/renditions/AvailableRenditionTests.java (96%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/renditions/CreateRenditionTests.java (97%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/renditions/GetRenditionTests.java (98%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/renditions/RenditionIntegrationTests.java (94%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/search/AbstractSearchTest.java (96%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/search/FacetFieldsSearchTest.java (96%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/search/FacetIntervalSearchTest.java (95%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/search/FacetRangeSearchTest.java (98%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/search/FacetedSearchTest.java (95%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/search/FingerPrintTest.java (97%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/search/PivotFacetedSearchTest.java (96%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/search/SearchAPATHTest.java (93%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/search/SearchHighLightTest.java (90%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/search/SearchSpellCheckTest.java (97%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/search/SearchTest.java (97%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/search/ShardInfoTest.java (93%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/search/StatsSearchTest.java (95%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/search/solr/SearchSolrAPITest.java (97%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/search/sql/SearchSQLAPITest.java (99%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/search/sql/SearchSQLPhraseTest.java (99%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/search/sql/SearchSQLViaJDBCTest.java (98%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/search/sql/SearchSQLWithQuotedIdentifiers.java (98%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/sharedLinks/GetSharedLinksFullTests.java (97%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/sharedLinks/SharedLinksSanityTests.java (99%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/sites/GetSiteTests.java (99%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/sites/GetSitesTests.java (99%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/sites/SitesNetworkTests.java (97%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/sites/SitesTests.java (93%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/sites/containers/GetSiteContainerTests.java (99%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/sites/containers/GetSiteContainersTests.java (99%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/sites/members/AddSiteMemberTests.java (99%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/sites/members/GetSiteMemberTests.java (99%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/sites/members/GetSiteMembersTests.java (99%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/sites/members/RemoveSiteMemberTests.java (99%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/sites/members/UpdateSiteMemberTests.java (99%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/sites/membershipRequests/AddSiteMembershipRequestTests.java (99%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/sites/membershipRequests/DeleteSiteMembershipRequestTests.java (99%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/sites/membershipRequests/GetSiteMembershipRequestTests.java (99%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/sites/membershipRequests/GetSiteMembershipRequestsTests.java (99%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/sites/membershipRequests/UpdateSiteMembershipRequestTests.java (99%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/syncService/SyncServiceAPITests.java (99%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/tags/GetTagTests.java (99%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/tags/GetTagsTests.java (99%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/tags/TagsDataPrep.java (96%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/tags/UpdateTagTests.java (99%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/tags/nodes/AddTagTests.java (99%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/tags/nodes/AddTagsTests.java (98%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/tags/nodes/DeleteTagTests.java (99%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/tags/nodes/GetNodeTagsTests.java (99%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/trashcan/GetDeletedNodesTests.java (99%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/WorkflowNetworkDeploymentsTests.java (98%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/WorkflowNetworkProcessDefinitionsTests.java (99%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/WorkflowNetworkProcessesTests.java (99%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/WorkflowNetworkTasksTests.java (99%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/deployments/DeleteDeploymentTests.java (98%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/deployments/GetDeploymentCoreTests.java (93%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/deployments/GetDeploymentFullTests.java (96%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/deployments/GetDeploymentSanityTests.java (96%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/deployments/GetDeploymentsCoreTests.java (91%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/deployments/GetDeploymentsFullTests.java (98%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/deployments/GetDeploymentsSanityTests.java (94%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/processDefinitions/GetProcessDefinitionCoreTests.java (94%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/processDefinitions/GetProcessDefinitionFullTests.java (96%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/processDefinitions/GetProcessDefinitionImageCoreTests.java (94%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/processDefinitions/GetProcessDefinitionImageFullTests.java (93%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java (95%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java (96%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java (97%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelFullTests.java (97%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java (93%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/processDefinitions/GetProcessDefinitionsCoreTests.java (95%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/processDefinitions/GetProcessDefinitionsFullTests.java (98%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java (94%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/processes/AddProcessCoreTests.java (97%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/processes/AddProcessFullTests.java (98%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/processes/AddProcessSanityTests.java (94%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/processes/DeleteProcessCoreTests.java (96%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/processes/DeleteProcessFullTests.java (95%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/processes/DeleteProcessSanityTests.java (97%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/processes/GetProcessCoreTests.java (94%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/processes/GetProcessFullTests.java (97%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/processes/GetProcessSanityTests.java (96%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/processes/GetProcessesCoreTests.java (97%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/processes/GetProcessesFullTests.java (98%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/processes/GetProcessesSanityTests.java (97%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/processes/items/AddProcessItemCoreTests.java (99%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/processes/items/AddProcessItemFullTests.java (98%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/processes/items/AddProcessItemSanityTests.java (98%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/processes/items/DeleteProcessItemCoreTests.java (97%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/processes/items/DeleteProcessItemFullTests.java (99%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/processes/items/DeleteProcessItemSanityTests.java (96%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/processes/items/GetProcessItemsCoreTests.java (97%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/processes/items/GetProcessItemsFullTests.java (99%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/processes/items/GetProcessItemsSanityTests.java (96%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/processes/tasks/GetProcessTasksCoreTests.java (98%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/processes/tasks/GetProcessTasksFullTests.java (99%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/processes/tasks/GetProcessTasksSanityTests.java (97%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/processes/variables/AddProcessVariableCoreTests.java (98%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/processes/variables/AddProcessVariableFullTests.java (98%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/processes/variables/AddProcessVariableSanityTests.java (97%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/processes/variables/AddProcessVariablesCoreTests.java (98%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/processes/variables/AddProcessVariablesFullTests.java (99%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/processes/variables/AddProcessVariablesSanityTests.java (98%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/processes/variables/DeleteProcessVariableCoreTests.java (98%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/processes/variables/DeleteProcessVariableFullTests.java (98%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/processes/variables/DeleteProcessVariableSanityTests.java (96%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/processes/variables/GetProcessVariablesCoreTests.java (97%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/processes/variables/GetProcessVariablesFullTests.java (98%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/processes/variables/GetProcessVariablesSanityTests.java (96%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/processes/variables/UpdateProcessVariableTests.java (98%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/tasks/GetTaskFormModelTests.java (99%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/tasks/GetTaskTests.java (99%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/tasks/GetTasksTests.java (99%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/tasks/UpdateTaskTests.java (99%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/tasks/candidates/GetTaskCandidatesRegressionTests.java (99%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/tasks/candidates/GetTaskCandidatesSanityTests.java (97%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/tasks/items/AddTaskItemTestsBulk1.java (98%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/tasks/items/AddTaskItemTestsBulk2.java (98%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/tasks/items/AddTaskItemTestsBulk3.java (98%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/tasks/items/GetTaskItemsRegressionTests.java (99%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/tasks/items/GetTaskItemsSanityTests.java (96%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/tasks/items/RemoveTaskItemTests.java (99%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk1.java (98%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk2.java (99%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk3.java (98%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/tasks/variables/DeleteTaskVariableTests.java (99%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/tasks/variables/GetTaskVariablesTests.java (99%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk1.java (96%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk2.java (98%) rename e2e-test/src/test/java/org/alfresco/{ => service/search}/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk3.java (99%) diff --git a/e2e-test/resources/SearchSuite.xml b/e2e-test/resources/SearchSuite.xml index 425276be0..88af99b0e 100644 --- a/e2e-test/resources/SearchSuite.xml +++ b/e2e-test/resources/SearchSuite.xml @@ -3,48 +3,48 @@ - - + + - - - - - + + + + + - - - - - - + + + + + + - + - + - - - + + + diff --git a/e2e-test/src/test/java/org/alfresco/rest/FunctionalCasesTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/FunctionalCasesTests.java similarity index 98% rename from e2e-test/src/test/java/org/alfresco/rest/FunctionalCasesTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/FunctionalCasesTests.java index ae2d5425b..2608e18db 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/FunctionalCasesTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/FunctionalCasesTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest; +package org.alfresco.service.search.rest; import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.CMISUtil.DocumentType; diff --git a/e2e-test/src/test/java/org/alfresco/rest/NetworkDataPrep.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/NetworkDataPrep.java similarity index 97% rename from e2e-test/src/test/java/org/alfresco/rest/NetworkDataPrep.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/NetworkDataPrep.java index dfee1c0d5..f3903b106 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/NetworkDataPrep.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/NetworkDataPrep.java @@ -1,4 +1,4 @@ -package org.alfresco.rest; +package org.alfresco.service.search.rest; import org.alfresco.rest.model.RestNetworkModel; import org.alfresco.utility.model.UserModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/RestTest.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/RestTest.java similarity index 98% rename from e2e-test/src/test/java/org/alfresco/rest/RestTest.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/RestTest.java index 1c6953576..5f042d387 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/RestTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/RestTest.java @@ -1,4 +1,4 @@ -package org.alfresco.rest; +package org.alfresco.service.search.rest; import java.lang.reflect.Method; diff --git a/e2e-test/src/test/java/org/alfresco/rest/actions/ActionsTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/actions/ActionsTests.java similarity index 98% rename from e2e-test/src/test/java/org/alfresco/rest/actions/ActionsTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/actions/ActionsTests.java index df822111d..b35a8251d 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/actions/ActionsTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/actions/ActionsTests.java @@ -1,11 +1,11 @@ -package org.alfresco.rest.actions; +package org.alfresco.service.search.rest.actions; import static org.testng.Assert.assertFalse; import com.google.common.collect.ImmutableMap; import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestActionDefinitionModel; import org.alfresco.rest.model.RestActionDefinitionModelsCollection; import org.alfresco.rest.model.RestNodeModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/aos/AosApiTest.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/aos/AosApiTest.java similarity index 87% rename from e2e-test/src/test/java/org/alfresco/rest/aos/AosApiTest.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/aos/AosApiTest.java index 6223db2f7..a8f596359 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/aos/AosApiTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/aos/AosApiTest.java @@ -1,6 +1,6 @@ -package org.alfresco.rest.aos; +package org.alfresco.service.search.rest.aos; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.core.RestRequest; import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; diff --git a/e2e-test/src/test/java/org/alfresco/rest/audit/AuditTest.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/audit/AuditTest.java similarity index 98% rename from e2e-test/src/test/java/org/alfresco/rest/audit/AuditTest.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/audit/AuditTest.java index 92ac3afc9..78b973100 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/audit/AuditTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/audit/AuditTest.java @@ -1,9 +1,9 @@ -package org.alfresco.rest.audit; +package org.alfresco.service.search.rest.audit; import static org.hamcrest.Matchers.is; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.core.RestResponse; import org.alfresco.rest.core.RestWrapper; diff --git a/e2e-test/src/test/java/org/alfresco/rest/audit/DeleteAuditTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/audit/DeleteAuditTests.java similarity index 98% rename from e2e-test/src/test/java/org/alfresco/rest/audit/DeleteAuditTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/audit/DeleteAuditTests.java index f6f0065b2..5adbbaa4c 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/audit/DeleteAuditTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/audit/DeleteAuditTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.audit; +package org.alfresco.service.search.rest.audit; import static org.testng.Assert.assertEquals; diff --git a/e2e-test/src/test/java/org/alfresco/rest/audit/GetAuditTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/audit/GetAuditTests.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/rest/audit/GetAuditTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/audit/GetAuditTests.java index 39c3afb2e..993166e4c 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/audit/GetAuditTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/audit/GetAuditTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.audit; +package org.alfresco.service.search.rest.audit; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; diff --git a/e2e-test/src/test/java/org/alfresco/rest/audit/PutAuditTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/audit/PutAuditTests.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/rest/audit/PutAuditTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/audit/PutAuditTests.java index 38ccd3c6d..1f8957cd1 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/audit/PutAuditTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/audit/PutAuditTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.audit; +package org.alfresco.service.search.rest.audit; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.testrail.ExecutionType; diff --git a/e2e-test/src/test/java/org/alfresco/rest/auth/AuthTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/auth/AuthTests.java similarity index 97% rename from e2e-test/src/test/java/org/alfresco/rest/auth/AuthTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/auth/AuthTests.java index 70826fe4c..4ddbc61d8 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/auth/AuthTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/auth/AuthTests.java @@ -1,6 +1,6 @@ -package org.alfresco.rest.auth; +package org.alfresco.service.search.rest.auth; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.core.RestWrapper; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestTicketBodyModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/cmis/CmisBrowserTest.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/cmis/CmisBrowserTest.java similarity index 90% rename from e2e-test/src/test/java/org/alfresco/rest/cmis/CmisBrowserTest.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/cmis/CmisBrowserTest.java index 1e9afbab7..56e99e3a2 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/cmis/CmisBrowserTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/cmis/CmisBrowserTest.java @@ -1,7 +1,7 @@ -package org.alfresco.rest.cmis; +package org.alfresco.service.search.rest.cmis; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.core.RestResponse; import org.alfresco.utility.model.FileModel; import org.testng.annotations.Test; diff --git a/e2e-test/src/test/java/org/alfresco/rest/comments/AddCommentTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/comments/AddCommentTests.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/rest/comments/AddCommentTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/comments/AddCommentTests.java index aeaa95869..f4eb84930 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/comments/AddCommentTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/comments/AddCommentTests.java @@ -1,8 +1,8 @@ -package org.alfresco.rest.comments; +package org.alfresco.service.search.rest.comments; import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestCommentModel; import org.alfresco.rest.model.RestCommentModelsCollection; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/comments/AddCommentsTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/comments/AddCommentsTests.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/rest/comments/AddCommentsTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/comments/AddCommentsTests.java index 7f28fd249..77984666c 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/comments/AddCommentsTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/comments/AddCommentsTests.java @@ -1,10 +1,10 @@ -package org.alfresco.rest.comments; +package org.alfresco.service.search.rest.comments; import java.util.List; import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.core.JsonBodyGenerator; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.exception.JsonToModelConversionException; diff --git a/e2e-test/src/test/java/org/alfresco/rest/comments/DeleteCommentTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/comments/DeleteCommentTests.java similarity index 97% rename from e2e-test/src/test/java/org/alfresco/rest/comments/DeleteCommentTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/comments/DeleteCommentTests.java index 614f257df..ee44818cc 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/comments/DeleteCommentTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/comments/DeleteCommentTests.java @@ -1,7 +1,7 @@ -package org.alfresco.rest.comments; +package org.alfresco.service.search.rest.comments; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestCommentModel; import org.alfresco.rest.model.RestCommentModelsCollection; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/comments/GetCommentsTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/comments/GetCommentsTests.java similarity index 98% rename from e2e-test/src/test/java/org/alfresco/rest/comments/GetCommentsTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/comments/GetCommentsTests.java index 6c8f07af2..23670eb81 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/comments/GetCommentsTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/comments/GetCommentsTests.java @@ -1,7 +1,7 @@ -package org.alfresco.rest.comments; +package org.alfresco.service.search.rest.comments; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestCommentModelsCollection; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.constants.UserRole; diff --git a/e2e-test/src/test/java/org/alfresco/rest/comments/UpdateCommentTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/comments/UpdateCommentTests.java similarity index 98% rename from e2e-test/src/test/java/org/alfresco/rest/comments/UpdateCommentTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/comments/UpdateCommentTests.java index aad251918..5ee3a596f 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/comments/UpdateCommentTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/comments/UpdateCommentTests.java @@ -1,8 +1,8 @@ -package org.alfresco.rest.comments; +package org.alfresco.service.search.rest.comments; import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestCommentModel; import org.alfresco.rest.model.RestCommentModelsCollection; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/demo/RestDemoTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/RestDemoTests.java similarity index 97% rename from e2e-test/src/test/java/org/alfresco/rest/demo/RestDemoTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/demo/RestDemoTests.java index 80ba29199..0792a9bc4 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/demo/RestDemoTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/RestDemoTests.java @@ -1,8 +1,8 @@ -package org.alfresco.rest.demo; +package org.alfresco.service.search.rest.demo; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.SiteService.Visibility; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.exception.DataPreparationException; diff --git a/e2e-test/src/test/java/org/alfresco/rest/demo/SampleCommentsTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/SampleCommentsTests.java similarity index 95% rename from e2e-test/src/test/java/org/alfresco/rest/demo/SampleCommentsTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/demo/SampleCommentsTests.java index 1151d4c2e..d7cd27d76 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/demo/SampleCommentsTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/SampleCommentsTests.java @@ -1,7 +1,7 @@ -package org.alfresco.rest.demo; +package org.alfresco.service.search.rest.demo; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestCommentModel; import org.alfresco.utility.model.FileModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/demo/SamplePeopleTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/SamplePeopleTests.java similarity index 90% rename from e2e-test/src/test/java/org/alfresco/rest/demo/SamplePeopleTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/demo/SamplePeopleTests.java index 6c0a2ff18..38ae35e47 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/demo/SamplePeopleTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/SamplePeopleTests.java @@ -1,6 +1,6 @@ -package org.alfresco.rest.demo; +package org.alfresco.service.search.rest.demo; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.UserModel; import org.apache.commons.lang3.RandomStringUtils; diff --git a/e2e-test/src/test/java/org/alfresco/rest/demo/SampleSitesTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/SampleSitesTests.java similarity index 96% rename from e2e-test/src/test/java/org/alfresco/rest/demo/SampleSitesTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/demo/SampleSitesTests.java index f5c59e8a8..1c66115ab 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/demo/SampleSitesTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/SampleSitesTests.java @@ -1,6 +1,6 @@ -package org.alfresco.rest.demo; +package org.alfresco.service.search.rest.demo; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.exception.DataPreparationException; diff --git a/e2e-test/src/test/java/org/alfresco/rest/demo/workshop/RestApiDemoTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/workshop/RestApiDemoTests.java similarity index 94% rename from e2e-test/src/test/java/org/alfresco/rest/demo/workshop/RestApiDemoTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/demo/workshop/RestApiDemoTests.java index 7492d8023..fa450616e 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/demo/workshop/RestApiDemoTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/workshop/RestApiDemoTests.java @@ -1,6 +1,6 @@ -package org.alfresco.rest.demo.workshop; +package org.alfresco.service.search.rest.demo.workshop; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/demo/workshop/RestApiWorkshopTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/workshop/RestApiWorkshopTests.java similarity index 89% rename from e2e-test/src/test/java/org/alfresco/rest/demo/workshop/RestApiWorkshopTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/demo/workshop/RestApiWorkshopTests.java index 88484bf66..49f7fce0d 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/demo/workshop/RestApiWorkshopTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/workshop/RestApiWorkshopTests.java @@ -1,6 +1,6 @@ -package org.alfresco.rest.demo.workshop; +package org.alfresco.service.search.rest.demo.workshop; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.testng.annotations.Test; /** diff --git a/e2e-test/src/test/java/org/alfresco/rest/discovery/DiscoveryTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/discovery/DiscoveryTests.java similarity index 98% rename from e2e-test/src/test/java/org/alfresco/rest/discovery/DiscoveryTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/discovery/DiscoveryTests.java index f4011a4c5..020555705 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/discovery/DiscoveryTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/discovery/DiscoveryTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.discovery; +package org.alfresco.service.search.rest.discovery; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; @@ -7,9 +7,9 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; -import org.alfresco.rest.RestTest; import org.alfresco.rest.core.RestResponse; import org.alfresco.rest.model.RestDiscoveryModel; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; diff --git a/e2e-test/src/test/java/org/alfresco/rest/downloads/DownloadsTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/downloads/DownloadsTests.java similarity index 98% rename from e2e-test/src/test/java/org/alfresco/rest/downloads/DownloadsTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/downloads/DownloadsTests.java index 054801807..b75b84a7a 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/downloads/DownloadsTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/downloads/DownloadsTests.java @@ -1,11 +1,11 @@ -package org.alfresco.rest.downloads; +package org.alfresco.service.search.rest.downloads; import javax.json.JsonObject; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; import org.alfresco.rest.core.JsonBodyGenerator; import org.alfresco.rest.model.RestDownloadsModel; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.utility.Utility; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FolderModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/favorites/AddFavoriteSiteTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/AddFavoriteSiteTests.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/rest/favorites/AddFavoriteSiteTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/AddFavoriteSiteTests.java index efc505218..df167a6e7 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/favorites/AddFavoriteSiteTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/AddFavoriteSiteTests.java @@ -1,7 +1,6 @@ -package org.alfresco.rest.favorites; +package org.alfresco.service.search.rest.favorites; import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestTest; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.model.RestCommentModel; import org.alfresco.rest.model.RestErrorModel; @@ -9,6 +8,7 @@ import org.alfresco.rest.model.RestFavoriteSiteModel; import org.alfresco.rest.model.RestPersonFavoritesModel; import org.alfresco.rest.model.RestPersonFavoritesModelsCollection; import org.alfresco.rest.model.RestTagModel; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FolderModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/favorites/AddFavoritesTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/AddFavoritesTests.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/rest/favorites/AddFavoritesTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/AddFavoritesTests.java index 0797eadee..52acf953f 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/favorites/AddFavoritesTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/AddFavoritesTests.java @@ -1,10 +1,10 @@ -package org.alfresco.rest.favorites; +package org.alfresco.service.search.rest.favorites; import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestTest; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.*; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.*; diff --git a/e2e-test/src/test/java/org/alfresco/rest/favorites/DeleteFavoriteSiteTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/DeleteFavoriteSiteTests.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/rest/favorites/DeleteFavoriteSiteTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/DeleteFavoriteSiteTests.java index b3fa0d190..057c48e65 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/favorites/DeleteFavoriteSiteTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/DeleteFavoriteSiteTests.java @@ -1,7 +1,7 @@ -package org.alfresco.rest.favorites; +package org.alfresco.service.search.rest.favorites; -import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.model.SiteModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/favorites/DeleteFavoriteTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/DeleteFavoriteTests.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/rest/favorites/DeleteFavoriteTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/DeleteFavoriteTests.java index 79570ff1d..32e6765b1 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/favorites/DeleteFavoriteTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/DeleteFavoriteTests.java @@ -1,8 +1,8 @@ -package org.alfresco.rest.favorites; +package org.alfresco.service.search.rest.favorites; import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.FileModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/favorites/FavoritesIncludePathTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/FavoritesIncludePathTests.java similarity index 98% rename from e2e-test/src/test/java/org/alfresco/rest/favorites/FavoritesIncludePathTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/FavoritesIncludePathTests.java index dcbba231f..c0f43ceef 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/favorites/FavoritesIncludePathTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/FavoritesIncludePathTests.java @@ -1,9 +1,9 @@ -package org.alfresco.rest.favorites; +package org.alfresco.service.search.rest.favorites; import static org.alfresco.utility.report.log.Step.STEP; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/favorites/FavoritesNetworkTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/FavoritesNetworkTests.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/rest/favorites/FavoritesNetworkTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/FavoritesNetworkTests.java index 6690a75ed..54becb068 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/favorites/FavoritesNetworkTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/FavoritesNetworkTests.java @@ -1,6 +1,6 @@ -package org.alfresco.rest.favorites; +package org.alfresco.service.search.rest.favorites; -import org.alfresco.rest.NetworkDataPrep; +import org.alfresco.service.search.rest.NetworkDataPrep; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; diff --git a/e2e-test/src/test/java/org/alfresco/rest/favorites/GetFavoriteSiteTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/GetFavoriteSiteTests.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/rest/favorites/GetFavoriteSiteTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/GetFavoriteSiteTests.java index 9cdc776aa..12f5fcbad 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/favorites/GetFavoriteSiteTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/GetFavoriteSiteTests.java @@ -1,12 +1,12 @@ -package org.alfresco.rest.favorites; +package org.alfresco.service.search.rest.favorites; import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.SiteService; -import org.alfresco.rest.RestTest; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestSiteModel; import org.alfresco.rest.model.RestSiteModelsCollection; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.model.FileModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/favorites/GetFavoriteSitesTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/GetFavoriteSitesTests.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/rest/favorites/GetFavoriteSitesTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/GetFavoriteSitesTests.java index db6dd2f90..141cdd27c 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/favorites/GetFavoriteSitesTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/GetFavoriteSitesTests.java @@ -1,9 +1,9 @@ -package org.alfresco.rest.favorites; +package org.alfresco.service.search.rest.favorites; -import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestSiteModel; import org.alfresco.rest.model.RestSiteModelsCollection; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.RandomData; diff --git a/e2e-test/src/test/java/org/alfresco/rest/favorites/GetFavoriteTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/GetFavoriteTests.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/rest/favorites/GetFavoriteTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/GetFavoriteTests.java index c5ededc33..0c0f32dbf 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/favorites/GetFavoriteTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/GetFavoriteTests.java @@ -1,10 +1,10 @@ -package org.alfresco.rest.favorites; +package org.alfresco.service.search.rest.favorites; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.SiteService; -import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestPersonFavoritesModel; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.DataUser.ListUserWithRoles; diff --git a/e2e-test/src/test/java/org/alfresco/rest/favorites/GetFavoritesTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/GetFavoritesTests.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/rest/favorites/GetFavoritesTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/GetFavoritesTests.java index f12845720..34f704e45 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/favorites/GetFavoritesTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/GetFavoritesTests.java @@ -1,11 +1,11 @@ -package org.alfresco.rest.favorites; +package org.alfresco.service.search.rest.favorites; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestPersonFavoritesModel; import org.alfresco.rest.model.RestPersonFavoritesModelsCollection; import org.alfresco.rest.model.RestSiteModel; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.model.FileModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/groups/GroupsTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/groups/GroupsTests.java similarity index 98% rename from e2e-test/src/test/java/org/alfresco/rest/groups/GroupsTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/groups/GroupsTests.java index 5eb3fa562..cbc87a06a 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/groups/GroupsTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/groups/GroupsTests.java @@ -1,11 +1,11 @@ -package org.alfresco.rest.groups; +package org.alfresco.service.search.rest.groups; import java.util.UUID; import javax.json.Json; import javax.json.JsonObject; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.utility.RetryOperation; import org.alfresco.utility.Utility; import org.alfresco.utility.model.TestGroup; diff --git a/e2e-test/src/test/java/org/alfresco/rest/networks/RestGetNetworkForPersonTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/networks/RestGetNetworkForPersonTests.java similarity index 98% rename from e2e-test/src/test/java/org/alfresco/rest/networks/RestGetNetworkForPersonTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/networks/RestGetNetworkForPersonTests.java index 384edd07f..1f0078dac 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/networks/RestGetNetworkForPersonTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/networks/RestGetNetworkForPersonTests.java @@ -1,8 +1,8 @@ -package org.alfresco.rest.networks; +package org.alfresco.service.search.rest.networks; import java.util.ArrayList; -import org.alfresco.rest.NetworkDataPrep; +import org.alfresco.service.search.rest.NetworkDataPrep; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestNetworkQuotaModel; import org.alfresco.utility.model.TestGroup; diff --git a/e2e-test/src/test/java/org/alfresco/rest/networks/RestGetNetworkTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/networks/RestGetNetworkTests.java similarity index 98% rename from e2e-test/src/test/java/org/alfresco/rest/networks/RestGetNetworkTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/networks/RestGetNetworkTests.java index e872aa0da..8bc917e1e 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/networks/RestGetNetworkTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/networks/RestGetNetworkTests.java @@ -1,6 +1,6 @@ -package org.alfresco.rest.networks; +package org.alfresco.service.search.rest.networks; -import org.alfresco.rest.NetworkDataPrep; +import org.alfresco.service.search.rest.NetworkDataPrep; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestNetworkModel; import org.alfresco.utility.model.TestGroup; diff --git a/e2e-test/src/test/java/org/alfresco/rest/networks/RestGetNetworksForPersonTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/networks/RestGetNetworksForPersonTests.java similarity index 98% rename from e2e-test/src/test/java/org/alfresco/rest/networks/RestGetNetworksForPersonTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/networks/RestGetNetworksForPersonTests.java index 9f5e04dde..db118a56d 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/networks/RestGetNetworksForPersonTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/networks/RestGetNetworksForPersonTests.java @@ -1,6 +1,6 @@ -package org.alfresco.rest.networks; +package org.alfresco.service.search.rest.networks; -import org.alfresco.rest.NetworkDataPrep; +import org.alfresco.service.search.rest.NetworkDataPrep; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestNetworkModelsCollection; import org.alfresco.utility.model.TestGroup; diff --git a/e2e-test/src/test/java/org/alfresco/rest/nodes/NodesActionDefinitionTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesActionDefinitionTests.java similarity index 97% rename from e2e-test/src/test/java/org/alfresco/rest/nodes/NodesActionDefinitionTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesActionDefinitionTests.java index 596ebf72c..a82c602a8 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/nodes/NodesActionDefinitionTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesActionDefinitionTests.java @@ -1,9 +1,9 @@ -package org.alfresco.rest.nodes; +package org.alfresco.service.search.rest.nodes; import static org.testng.Assert.assertFalse; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestActionDefinitionModelsCollection; import org.alfresco.rest.model.builder.NodesBuilder; diff --git a/e2e-test/src/test/java/org/alfresco/rest/nodes/NodesContentAndVersioningTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesContentAndVersioningTests.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/rest/nodes/NodesContentAndVersioningTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesContentAndVersioningTests.java index a3770353a..97dbfbc18 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/nodes/NodesContentAndVersioningTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesContentAndVersioningTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.nodes; +package org.alfresco.service.search.rest.nodes; import static org.alfresco.utility.report.log.Step.STEP; import static org.testng.Assert.assertEquals; @@ -14,7 +14,7 @@ import java.io.IOException; import java.io.RandomAccessFile; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.core.JsonBodyGenerator; import org.alfresco.rest.core.RestResponse; import org.alfresco.rest.model.RestNodeModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/nodes/NodesLockTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesLockTests.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/rest/nodes/NodesLockTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesLockTests.java index ce19991f6..dc05c3602 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/nodes/NodesLockTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesLockTests.java @@ -1,7 +1,7 @@ -package org.alfresco.rest.nodes; +package org.alfresco.service.search.rest.nodes; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestNodeModel; import org.alfresco.rest.model.body.RestNodeLockBodyModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/nodes/NodesParentChildrenTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesParentChildrenTests.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/rest/nodes/NodesParentChildrenTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesParentChildrenTests.java index 417eb99d1..d2f525553 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/nodes/NodesParentChildrenTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesParentChildrenTests.java @@ -1,8 +1,8 @@ -package org.alfresco.rest.nodes; +package org.alfresco.service.search.rest.nodes; import static org.alfresco.utility.report.log.Step.STEP; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestNodeBodyModel; import org.alfresco.rest.model.RestNodeChildAssocModelCollection; import org.alfresco.rest.model.RestNodeChildAssociationModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/nodes/NodesTargetSourcesTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesTargetSourcesTests.java similarity index 98% rename from e2e-test/src/test/java/org/alfresco/rest/nodes/NodesTargetSourcesTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesTargetSourcesTests.java index 83863ad59..d6fe35259 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/nodes/NodesTargetSourcesTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesTargetSourcesTests.java @@ -1,8 +1,8 @@ -package org.alfresco.rest.nodes; +package org.alfresco.service.search.rest.nodes; import static org.alfresco.utility.report.log.Step.STEP; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestNodeAssocTargetModel; import org.alfresco.rest.model.RestNodeAssociationModelCollection; import org.alfresco.rest.model.builder.NodesBuilder; diff --git a/e2e-test/src/test/java/org/alfresco/rest/nodes/NodesTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesTests.java similarity index 95% rename from e2e-test/src/test/java/org/alfresco/rest/nodes/NodesTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesTests.java index b122296c6..9a3866989 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/nodes/NodesTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesTests.java @@ -1,6 +1,6 @@ -package org.alfresco.rest.nodes; +package org.alfresco.service.search.rest.nodes; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestNodeBodyMoveCopyModel; import org.alfresco.rest.model.RestNodeModel; import org.alfresco.rest.model.builder.NodesBuilder; diff --git a/e2e-test/src/test/java/org/alfresco/rest/nodes/NodesUnlockTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesUnlockTests.java similarity index 98% rename from e2e-test/src/test/java/org/alfresco/rest/nodes/NodesUnlockTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesUnlockTests.java index ca10a5c59..488dd854d 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/nodes/NodesUnlockTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesUnlockTests.java @@ -1,9 +1,9 @@ -package org.alfresco.rest.nodes; +package org.alfresco.service.search.rest.nodes; import static org.alfresco.utility.report.log.Step.STEP; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestNodeModel; import org.alfresco.rest.model.body.RestNodeLockBodyModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/people/AvatarPeopleSanityTest.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/AvatarPeopleSanityTest.java similarity index 96% rename from e2e-test/src/test/java/org/alfresco/rest/people/AvatarPeopleSanityTest.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/people/AvatarPeopleSanityTest.java index 73aae3bdf..46e4cd71c 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/people/AvatarPeopleSanityTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/AvatarPeopleSanityTest.java @@ -1,11 +1,11 @@ -package org.alfresco.rest.people; +package org.alfresco.service.search.rest.people; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertTrue; import java.io.File; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.utility.Utility; import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.TestGroup; diff --git a/e2e-test/src/test/java/org/alfresco/rest/people/DeleteSiteMemberCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/DeleteSiteMemberCoreTests.java similarity index 98% rename from e2e-test/src/test/java/org/alfresco/rest/people/DeleteSiteMemberCoreTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/people/DeleteSiteMemberCoreTests.java index 71c5eb18a..32a8b8e53 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/people/DeleteSiteMemberCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/DeleteSiteMemberCoreTests.java @@ -1,6 +1,6 @@ -package org.alfresco.rest.people; +package org.alfresco.service.search.rest.people; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.model.SiteModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/people/DeleteSiteMemberFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/DeleteSiteMemberFullTests.java similarity index 98% rename from e2e-test/src/test/java/org/alfresco/rest/people/DeleteSiteMemberFullTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/people/DeleteSiteMemberFullTests.java index 85315e3a4..fe7336390 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/people/DeleteSiteMemberFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/DeleteSiteMemberFullTests.java @@ -1,6 +1,6 @@ -package org.alfresco.rest.people; +package org.alfresco.service.search.rest.people; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; diff --git a/e2e-test/src/test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/DeleteSiteMemberSanityTests.java similarity index 98% rename from e2e-test/src/test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/people/DeleteSiteMemberSanityTests.java index 589c4b6ef..d76871c62 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/DeleteSiteMemberSanityTests.java @@ -1,6 +1,6 @@ -package org.alfresco.rest.people; +package org.alfresco.service.search.rest.people; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.constants.UserRole; diff --git a/e2e-test/src/test/java/org/alfresco/rest/people/GetPeopleCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetPeopleCoreTests.java similarity index 96% rename from e2e-test/src/test/java/org/alfresco/rest/people/GetPeopleCoreTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetPeopleCoreTests.java index a209dc427..2ff985718 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/people/GetPeopleCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetPeopleCoreTests.java @@ -1,6 +1,6 @@ -package org.alfresco.rest.people; +package org.alfresco.service.search.rest.people; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.model.SiteModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/people/GetPeopleFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetPeopleFullTests.java similarity index 97% rename from e2e-test/src/test/java/org/alfresco/rest/people/GetPeopleFullTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetPeopleFullTests.java index a447bd1d5..454500cc3 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/people/GetPeopleFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetPeopleFullTests.java @@ -1,6 +1,6 @@ -package org.alfresco.rest.people; +package org.alfresco.service.search.rest.people; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.model.RestPersonModel; import org.alfresco.rest.model.RestPersonModelsCollection; diff --git a/e2e-test/src/test/java/org/alfresco/rest/people/GetPeopleSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetPeopleSanityTests.java similarity index 98% rename from e2e-test/src/test/java/org/alfresco/rest/people/GetPeopleSanityTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetPeopleSanityTests.java index 2678895a5..e4937bba5 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/people/GetPeopleSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetPeopleSanityTests.java @@ -1,6 +1,6 @@ -package org.alfresco.rest.people; +package org.alfresco.service.search.rest.people; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestPersonModel; import org.alfresco.utility.constants.UserRole; diff --git a/e2e-test/src/test/java/org/alfresco/rest/people/GetSiteMembershipCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSiteMembershipCoreTests.java similarity index 98% rename from e2e-test/src/test/java/org/alfresco/rest/people/GetSiteMembershipCoreTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSiteMembershipCoreTests.java index a1ed9384e..22d5c0292 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/people/GetSiteMembershipCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSiteMembershipCoreTests.java @@ -1,6 +1,6 @@ -package org.alfresco.rest.people; +package org.alfresco.service.search.rest.people; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestSiteEntry; import org.alfresco.utility.constants.UserRole; diff --git a/e2e-test/src/test/java/org/alfresco/rest/people/GetSiteMembershipFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSiteMembershipFullTests.java similarity index 98% rename from e2e-test/src/test/java/org/alfresco/rest/people/GetSiteMembershipFullTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSiteMembershipFullTests.java index 7ad0ae6f9..30b8a4771 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/people/GetSiteMembershipFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSiteMembershipFullTests.java @@ -1,6 +1,6 @@ -package org.alfresco.rest.people; +package org.alfresco.service.search.rest.people; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestSiteEntry; import org.alfresco.utility.constants.UserRole; diff --git a/e2e-test/src/test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSiteMembershipSanityTests.java similarity index 98% rename from e2e-test/src/test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSiteMembershipSanityTests.java index 5e348663b..e1639d7e3 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSiteMembershipSanityTests.java @@ -1,6 +1,6 @@ -package org.alfresco.rest.people; +package org.alfresco.service.search.rest.people; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.constants.UserRole; diff --git a/e2e-test/src/test/java/org/alfresco/rest/people/GetSitesMembershipInformationCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSitesMembershipInformationCoreTests.java similarity index 98% rename from e2e-test/src/test/java/org/alfresco/rest/people/GetSitesMembershipInformationCoreTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSitesMembershipInformationCoreTests.java index 16a91b969..21c503948 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/people/GetSitesMembershipInformationCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSitesMembershipInformationCoreTests.java @@ -1,6 +1,6 @@ -package org.alfresco.rest.people; +package org.alfresco.service.search.rest.people; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.exception.DataPreparationException; diff --git a/e2e-test/src/test/java/org/alfresco/rest/people/GetSitesMembershipInformationFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSitesMembershipInformationFullTests.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/rest/people/GetSitesMembershipInformationFullTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSitesMembershipInformationFullTests.java index 856f8bf28..26278e8f7 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/people/GetSitesMembershipInformationFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSitesMembershipInformationFullTests.java @@ -1,6 +1,6 @@ -package org.alfresco.rest.people; +package org.alfresco.service.search.rest.people; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestSiteMembershipModelsCollection; import org.alfresco.rest.model.RestTaskModel; import org.alfresco.utility.constants.UserRole; diff --git a/e2e-test/src/test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSitesMembershipInformationSanityTests.java similarity index 98% rename from e2e-test/src/test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSitesMembershipInformationSanityTests.java index 7280ec849..53b9c935f 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSitesMembershipInformationSanityTests.java @@ -1,6 +1,6 @@ -package org.alfresco.rest.people; +package org.alfresco.service.search.rest.people; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.constants.UserRole; diff --git a/e2e-test/src/test/java/org/alfresco/rest/people/activities/GetPeopleActivitiesCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/activities/GetPeopleActivitiesCoreTests.java similarity index 98% rename from e2e-test/src/test/java/org/alfresco/rest/people/activities/GetPeopleActivitiesCoreTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/people/activities/GetPeopleActivitiesCoreTests.java index bdc7d7dd6..af25befea 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/people/activities/GetPeopleActivitiesCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/activities/GetPeopleActivitiesCoreTests.java @@ -1,7 +1,7 @@ -package org.alfresco.rest.people.activities; +package org.alfresco.service.search.rest.people.activities; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestActivityModelsCollection; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.constants.UserRole; diff --git a/e2e-test/src/test/java/org/alfresco/rest/people/activities/GetPeopleActivitiesFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/activities/GetPeopleActivitiesFullTests.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/rest/people/activities/GetPeopleActivitiesFullTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/people/activities/GetPeopleActivitiesFullTests.java index 1abd5a4e7..6e31e1b6a 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/people/activities/GetPeopleActivitiesFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/activities/GetPeopleActivitiesFullTests.java @@ -1,7 +1,7 @@ -package org.alfresco.rest.people.activities; +package org.alfresco.service.search.rest.people.activities; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestActivityModel; import org.alfresco.rest.model.RestActivityModelsCollection; import org.alfresco.rest.model.RestActivitySummaryModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/people/activities/GetPeopleActivitiesSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/activities/GetPeopleActivitiesSanityTests.java similarity index 98% rename from e2e-test/src/test/java/org/alfresco/rest/people/activities/GetPeopleActivitiesSanityTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/people/activities/GetPeopleActivitiesSanityTests.java index 468f13bfa..f31460a15 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/people/activities/GetPeopleActivitiesSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/activities/GetPeopleActivitiesSanityTests.java @@ -1,7 +1,7 @@ -package org.alfresco.rest.people.activities; +package org.alfresco.service.search.rest.people.activities; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestActivityModelsCollection; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.constants.UserRole; diff --git a/e2e-test/src/test/java/org/alfresco/rest/people/preferences/GetPeoplePreferenceCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferenceCoreTests.java similarity index 97% rename from e2e-test/src/test/java/org/alfresco/rest/people/preferences/GetPeoplePreferenceCoreTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferenceCoreTests.java index 4e02b7025..7dd7ad1cf 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/people/preferences/GetPeoplePreferenceCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferenceCoreTests.java @@ -1,6 +1,6 @@ -package org.alfresco.rest.people.preferences; +package org.alfresco.service.search.rest.people.preferences; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.constants.PreferenceName; import org.alfresco.utility.model.SiteModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/people/preferences/GetPeoplePreferenceFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferenceFullTests.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/rest/people/preferences/GetPeoplePreferenceFullTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferenceFullTests.java index 5c874d427..ee07f650a 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/people/preferences/GetPeoplePreferenceFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferenceFullTests.java @@ -1,8 +1,8 @@ -package org.alfresco.rest.people.preferences; +package org.alfresco.service.search.rest.people.preferences; import java.nio.file.Paths; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestPreferenceModel; import org.alfresco.utility.Utility; diff --git a/e2e-test/src/test/java/org/alfresco/rest/people/preferences/GetPeoplePreferenceSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferenceSanityTests.java similarity index 98% rename from e2e-test/src/test/java/org/alfresco/rest/people/preferences/GetPeoplePreferenceSanityTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferenceSanityTests.java index be9802d5f..bc668d8cd 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/people/preferences/GetPeoplePreferenceSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferenceSanityTests.java @@ -1,6 +1,6 @@ -package org.alfresco.rest.people.preferences; +package org.alfresco.service.search.rest.people.preferences; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestPreferenceModel; import org.alfresco.utility.constants.PreferenceName; diff --git a/e2e-test/src/test/java/org/alfresco/rest/people/preferences/GetPeoplePreferencesCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferencesCoreTests.java similarity index 98% rename from e2e-test/src/test/java/org/alfresco/rest/people/preferences/GetPeoplePreferencesCoreTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferencesCoreTests.java index f4b42e8c7..ea1942fe5 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/people/preferences/GetPeoplePreferencesCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferencesCoreTests.java @@ -1,6 +1,6 @@ -package org.alfresco.rest.people.preferences; +package org.alfresco.service.search.rest.people.preferences; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestPreferenceModelsCollection; import org.alfresco.utility.constants.PreferenceName; diff --git a/e2e-test/src/test/java/org/alfresco/rest/people/preferences/GetPeoplePreferencesFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferencesFullTests.java similarity index 98% rename from e2e-test/src/test/java/org/alfresco/rest/people/preferences/GetPeoplePreferencesFullTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferencesFullTests.java index 28de256d3..f48d41a7b 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/people/preferences/GetPeoplePreferencesFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferencesFullTests.java @@ -1,6 +1,6 @@ -package org.alfresco.rest.people.preferences; +package org.alfresco.service.search.rest.people.preferences; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestPreferenceModelsCollection; import org.alfresco.utility.constants.PreferenceName; diff --git a/e2e-test/src/test/java/org/alfresco/rest/people/preferences/GetPeoplePreferencesSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferencesSanityTests.java similarity index 98% rename from e2e-test/src/test/java/org/alfresco/rest/people/preferences/GetPeoplePreferencesSanityTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferencesSanityTests.java index 7570f80a4..4b7e657a4 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/people/preferences/GetPeoplePreferencesSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferencesSanityTests.java @@ -1,6 +1,6 @@ -package org.alfresco.rest.people.preferences; +package org.alfresco.service.search.rest.people.preferences; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestPreferenceModelsCollection; import org.alfresco.utility.constants.PreferenceName; diff --git a/e2e-test/src/test/java/org/alfresco/rest/queries/QueriesTest.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/queries/QueriesTest.java similarity index 98% rename from e2e-test/src/test/java/org/alfresco/rest/queries/QueriesTest.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/queries/QueriesTest.java index ddfce7ae8..5d83550eb 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/queries/QueriesTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/queries/QueriesTest.java @@ -1,9 +1,9 @@ -package org.alfresco.rest.queries; +package org.alfresco.service.search.rest.queries; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestNodeModelsCollection; import org.alfresco.rest.model.RestPersonModelsCollection; import org.alfresco.rest.model.RestSiteModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/ratings/AddRatingTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/ratings/AddRatingTests.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/rest/ratings/AddRatingTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/ratings/AddRatingTests.java index 72e3595a4..39b5c823d 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/ratings/AddRatingTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/ratings/AddRatingTests.java @@ -1,7 +1,7 @@ -package org.alfresco.rest.ratings; +package org.alfresco.service.search.rest.ratings; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestCommentModel; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestRatingModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/ratings/DeleteRatingTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/ratings/DeleteRatingTests.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/rest/ratings/DeleteRatingTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/ratings/DeleteRatingTests.java index 1edea1c5d..829febf57 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/ratings/DeleteRatingTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/ratings/DeleteRatingTests.java @@ -1,7 +1,7 @@ -package org.alfresco.rest.ratings; +package org.alfresco.service.search.rest.ratings; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestRatingModel; import org.alfresco.rest.model.RestRatingModelsCollection; diff --git a/e2e-test/src/test/java/org/alfresco/rest/ratings/GetRatingTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/ratings/GetRatingTests.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/rest/ratings/GetRatingTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/ratings/GetRatingTests.java index 9cb42f8f7..ef9f99f3b 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/ratings/GetRatingTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/ratings/GetRatingTests.java @@ -1,7 +1,7 @@ -package org.alfresco.rest.ratings; +package org.alfresco.service.search.rest.ratings; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestRatingModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/ratings/GetRatingsTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/ratings/GetRatingsTests.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/rest/ratings/GetRatingsTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/ratings/GetRatingsTests.java index ca4469a85..19cd55116 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/ratings/GetRatingsTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/ratings/GetRatingsTests.java @@ -1,8 +1,8 @@ -package org.alfresco.rest.ratings; +package org.alfresco.service.search.rest.ratings; import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestRatingModelsCollection; import org.alfresco.utility.constants.UserRole; diff --git a/e2e-test/src/test/java/org/alfresco/rest/renditions/AvailableRenditionTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/renditions/AvailableRenditionTests.java similarity index 96% rename from e2e-test/src/test/java/org/alfresco/rest/renditions/AvailableRenditionTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/renditions/AvailableRenditionTests.java index 70f1d79d5..60ddd5c18 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/renditions/AvailableRenditionTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/renditions/AvailableRenditionTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.renditions; +package org.alfresco.service.search.rest.renditions; import org.alfresco.rest.model.RestNodeModel; import org.alfresco.rest.model.RestRenditionInfoModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/renditions/CreateRenditionTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/renditions/CreateRenditionTests.java similarity index 97% rename from e2e-test/src/test/java/org/alfresco/rest/renditions/CreateRenditionTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/renditions/CreateRenditionTests.java index 4c8964aee..e1b58a126 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/renditions/CreateRenditionTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/renditions/CreateRenditionTests.java @@ -1,9 +1,9 @@ -package org.alfresco.rest.renditions; +package org.alfresco.service.search.rest.renditions; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestNodeModel; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.utility.Utility; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FolderModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/renditions/GetRenditionTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/renditions/GetRenditionTests.java similarity index 98% rename from e2e-test/src/test/java/org/alfresco/rest/renditions/GetRenditionTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/renditions/GetRenditionTests.java index bbeda974c..5ccb346b7 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/renditions/GetRenditionTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/renditions/GetRenditionTests.java @@ -1,12 +1,12 @@ -package org.alfresco.rest.renditions; +package org.alfresco.service.search.rest.renditions; import static org.alfresco.utility.report.log.Step.STEP; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; import org.alfresco.rest.core.RestResponse; import org.alfresco.rest.model.RestNodeModel; import org.alfresco.rest.model.RestRenditionInfoModel; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.utility.Utility; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FolderModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/renditions/RenditionIntegrationTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/renditions/RenditionIntegrationTests.java similarity index 94% rename from e2e-test/src/test/java/org/alfresco/rest/renditions/RenditionIntegrationTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/renditions/RenditionIntegrationTests.java index 2423613ca..6002aaa48 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/renditions/RenditionIntegrationTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/renditions/RenditionIntegrationTests.java @@ -1,8 +1,8 @@ -package org.alfresco.rest.renditions; +package org.alfresco.service.search.rest.renditions; -import org.alfresco.rest.RestTest; import org.alfresco.rest.core.RestResponse; import org.alfresco.rest.model.RestNodeModel; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.utility.Utility; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FolderModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/search/AbstractSearchTest.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/AbstractSearchTest.java similarity index 96% rename from e2e-test/src/test/java/org/alfresco/rest/search/AbstractSearchTest.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/search/AbstractSearchTest.java index 8ec3643ae..37cfdc236 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/search/AbstractSearchTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/AbstractSearchTest.java @@ -16,11 +16,16 @@ * You should have received a copy of the GNU Lesser General Public License * along with Alfresco. If not, see . */ -package org.alfresco.rest.search; +package org.alfresco.service.search.rest.search; import org.alfresco.dataprep.SiteService.Visibility; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.core.RestResponse; +import org.alfresco.rest.search.RestRequestHighlightModel; +import org.alfresco.rest.search.RestRequestQueryModel; +import org.alfresco.rest.search.SearchRequest; +import org.alfresco.rest.search.SearchResponse; +import org.alfresco.rest.search.SearchSqlRequest; import org.alfresco.utility.Utility; import org.alfresco.utility.data.RandomData; import org.alfresco.utility.model.FileModel; @@ -122,7 +127,7 @@ public class AbstractSearchTest extends RestTest * @throws Exception if error * */ - protected SearchResponse query(RestRequestQueryModel queryReq,RestRequestHighlightModel highlight) throws Exception + protected SearchResponse query(RestRequestQueryModel queryReq, RestRequestHighlightModel highlight) throws Exception { SearchRequest query = new SearchRequest(queryReq); query.setHighlight(highlight); diff --git a/e2e-test/src/test/java/org/alfresco/rest/search/FacetFieldsSearchTest.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/FacetFieldsSearchTest.java similarity index 96% rename from e2e-test/src/test/java/org/alfresco/rest/search/FacetFieldsSearchTest.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/search/FacetFieldsSearchTest.java index 190d66112..c6c60d8bd 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/search/FacetFieldsSearchTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/FacetFieldsSearchTest.java @@ -16,7 +16,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with Alfresco. If not, see . */ -package org.alfresco.rest.search; +package org.alfresco.service.search.rest.search; import java.util.ArrayList; import java.util.List; @@ -25,6 +25,13 @@ import javax.json.Json; import javax.json.JsonObject; import org.alfresco.dataprep.SiteService.Visibility; +import org.alfresco.rest.search.FacetFieldBucket; +import org.alfresco.rest.search.RestRequestFacetFieldModel; +import org.alfresco.rest.search.RestRequestFacetFieldsModel; +import org.alfresco.rest.search.RestRequestQueryModel; +import org.alfresco.rest.search.RestResultBucketsModel; +import org.alfresco.rest.search.SearchRequest; +import org.alfresco.rest.search.SearchResponse; import org.alfresco.utility.data.RandomData; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FileType; diff --git a/e2e-test/src/test/java/org/alfresco/rest/search/FacetIntervalSearchTest.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/FacetIntervalSearchTest.java similarity index 95% rename from e2e-test/src/test/java/org/alfresco/rest/search/FacetIntervalSearchTest.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/search/FacetIntervalSearchTest.java index ef9f579dd..a624d44f2 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/search/FacetIntervalSearchTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/FacetIntervalSearchTest.java @@ -16,9 +16,16 @@ * You should have received a copy of the GNU Lesser General Public License * along with Alfresco. If not, see . */ -package org.alfresco.rest.search; +package org.alfresco.service.search.rest.search; import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.search.FacetInterval; +import org.alfresco.rest.search.RestGenericBucketModel; +import org.alfresco.rest.search.RestGenericFacetResponseModel; +import org.alfresco.rest.search.RestRequestFacetIntervalsModel; +import org.alfresco.rest.search.RestRequestFacetSetModel; +import org.alfresco.rest.search.SearchRequest; +import org.alfresco.rest.search.SearchResponse; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; diff --git a/e2e-test/src/test/java/org/alfresco/rest/search/FacetRangeSearchTest.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/FacetRangeSearchTest.java similarity index 98% rename from e2e-test/src/test/java/org/alfresco/rest/search/FacetRangeSearchTest.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/search/FacetRangeSearchTest.java index b3c518445..fb798662f 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/search/FacetRangeSearchTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/FacetRangeSearchTest.java @@ -16,7 +16,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with Alfresco. If not, see . */ -package org.alfresco.rest.search; +package org.alfresco.service.search.rest.search; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; @@ -27,6 +27,10 @@ import java.util.Map; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestRequestRangesModel; +import org.alfresco.rest.search.RestGenericBucketModel; +import org.alfresco.rest.search.RestGenericFacetResponseModel; +import org.alfresco.rest.search.SearchRequest; +import org.alfresco.rest.search.SearchResponse; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; diff --git a/e2e-test/src/test/java/org/alfresco/rest/search/FacetedSearchTest.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/FacetedSearchTest.java similarity index 95% rename from e2e-test/src/test/java/org/alfresco/rest/search/FacetedSearchTest.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/search/FacetedSearchTest.java index 4c1d54339..747042898 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/search/FacetedSearchTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/FacetedSearchTest.java @@ -16,11 +16,21 @@ * You should have received a copy of the GNU Lesser General Public License * along with Alfresco. If not, see . */ -package org.alfresco.rest.search; +package org.alfresco.service.search.rest.search; import java.util.ArrayList; import java.util.List; +import org.alfresco.rest.search.FacetFieldBucket; +import org.alfresco.rest.search.FacetQuery; +import org.alfresco.rest.search.RestGenericBucketModel; +import org.alfresco.rest.search.RestGenericFacetResponseModel; +import org.alfresco.rest.search.RestRequestFacetFieldModel; +import org.alfresco.rest.search.RestRequestFacetFieldsModel; +import org.alfresco.rest.search.RestRequestQueryModel; +import org.alfresco.rest.search.RestResultBucketsModel; +import org.alfresco.rest.search.SearchRequest; +import org.alfresco.rest.search.SearchResponse; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; diff --git a/e2e-test/src/test/java/org/alfresco/rest/search/FingerPrintTest.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/FingerPrintTest.java similarity index 97% rename from e2e-test/src/test/java/org/alfresco/rest/search/FingerPrintTest.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/search/FingerPrintTest.java index 26874a90a..9044c1175 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/search/FingerPrintTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/FingerPrintTest.java @@ -16,8 +16,10 @@ * You should have received a copy of the GNU Lesser General Public License * along with Alfresco. If not, see . */ -package org.alfresco.rest.search; +package org.alfresco.service.search.rest.search; +import org.alfresco.rest.search.SearchNodeModel; +import org.alfresco.rest.search.SearchResponse; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FileType; import org.alfresco.utility.model.FolderModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/search/PivotFacetedSearchTest.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/PivotFacetedSearchTest.java similarity index 96% rename from e2e-test/src/test/java/org/alfresco/rest/search/PivotFacetedSearchTest.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/search/PivotFacetedSearchTest.java index fae882339..54e99bb86 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/search/PivotFacetedSearchTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/PivotFacetedSearchTest.java @@ -16,7 +16,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with Alfresco. If not, see . */ -package org.alfresco.rest.search; +package org.alfresco.service.search.rest.search; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; @@ -26,6 +26,14 @@ import java.util.List; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestRequestRangesModel; +import org.alfresco.rest.search.Pagination; +import org.alfresco.rest.search.RestGenericBucketModel; +import org.alfresco.rest.search.RestGenericFacetResponseModel; +import org.alfresco.rest.search.RestRequestFacetFieldModel; +import org.alfresco.rest.search.RestRequestFacetFieldsModel; +import org.alfresco.rest.search.RestRequestPivotModel; +import org.alfresco.rest.search.SearchRequest; +import org.alfresco.rest.search.SearchResponse; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; diff --git a/e2e-test/src/test/java/org/alfresco/rest/search/SearchAPATHTest.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/SearchAPATHTest.java similarity index 93% rename from e2e-test/src/test/java/org/alfresco/rest/search/SearchAPATHTest.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/search/SearchAPATHTest.java index a045144f9..ad08e72f4 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/search/SearchAPATHTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/SearchAPATHTest.java @@ -16,12 +16,19 @@ * You should have received a copy of the GNU Lesser General Public License * along with Alfresco. If not, see . */ -package org.alfresco.rest.search; +package org.alfresco.service.search.rest.search; import java.util.Collections; import java.util.List; +import org.alfresco.rest.search.FacetFieldBucket; +import org.alfresco.rest.search.RestRequestFacetFieldModel; +import org.alfresco.rest.search.RestRequestFacetFieldsModel; +import org.alfresco.rest.search.RestRequestQueryModel; +import org.alfresco.rest.search.RestResultBucketsModel; +import org.alfresco.rest.search.SearchRequest; +import org.alfresco.rest.search.SearchResponse; import org.alfresco.utility.model.TestGroup; import org.testng.Assert; import org.testng.annotations.Test; diff --git a/e2e-test/src/test/java/org/alfresco/rest/search/SearchHighLightTest.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/SearchHighLightTest.java similarity index 90% rename from e2e-test/src/test/java/org/alfresco/rest/search/SearchHighLightTest.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/search/SearchHighLightTest.java index 06528e684..1c03c9b47 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/search/SearchHighLightTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/SearchHighLightTest.java @@ -16,14 +16,18 @@ * You should have received a copy of the GNU Lesser General Public License * along with Alfresco. If not, see . */ -package org.alfresco.rest.search; +package org.alfresco.service.search.rest.search; import java.util.ArrayList; import java.util.List; +import org.alfresco.rest.search.ResponseHighLightModel; +import org.alfresco.rest.search.RestRequestFieldsModel; +import org.alfresco.rest.search.RestRequestHighlightModel; +import org.alfresco.rest.search.RestRequestQueryModel; +import org.alfresco.rest.search.SearchResponse; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.report.Bug; -import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; /** diff --git a/e2e-test/src/test/java/org/alfresco/rest/search/SearchSpellCheckTest.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/SearchSpellCheckTest.java similarity index 97% rename from e2e-test/src/test/java/org/alfresco/rest/search/SearchSpellCheckTest.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/search/SearchSpellCheckTest.java index 9be9d7fd7..96273d299 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/search/SearchSpellCheckTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/SearchSpellCheckTest.java @@ -16,9 +16,12 @@ * You should have received a copy of the GNU Lesser General Public License * along with Alfresco. If not, see . */ -package org.alfresco.rest.search; +package org.alfresco.service.search.rest.search; import org.alfresco.rest.model.RestRequestSpellcheckModel; +import org.alfresco.rest.search.RestRequestQueryModel; +import org.alfresco.rest.search.SearchRequest; +import org.alfresco.rest.search.SearchResponse; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FileType; import org.alfresco.utility.model.TestGroup; diff --git a/e2e-test/src/test/java/org/alfresco/rest/search/SearchTest.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/SearchTest.java similarity index 97% rename from e2e-test/src/test/java/org/alfresco/rest/search/SearchTest.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/search/SearchTest.java index 8db269fd4..edb496667 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/search/SearchTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/SearchTest.java @@ -16,7 +16,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with Alfresco. If not, see . */ -package org.alfresco.rest.search; +package org.alfresco.service.search.rest.search; import static java.util.Arrays.asList; import static java.util.Collections.reverse; @@ -33,6 +33,11 @@ import java.util.List; import java.util.stream.Collectors; import org.alfresco.rest.model.body.RestNodeLockBodyModel; +import org.alfresco.rest.search.RestRequestFilterQueryModel; +import org.alfresco.rest.search.RestRequestQueryModel; +import org.alfresco.rest.search.SearchNodeModel; +import org.alfresco.rest.search.SearchRequest; +import org.alfresco.rest.search.SearchResponse; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FileType; import org.alfresco.utility.model.TestGroup; diff --git a/e2e-test/src/test/java/org/alfresco/rest/search/ShardInfoTest.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/ShardInfoTest.java similarity index 93% rename from e2e-test/src/test/java/org/alfresco/rest/search/ShardInfoTest.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/search/ShardInfoTest.java index 410779581..6305f242b 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/search/ShardInfoTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/ShardInfoTest.java @@ -16,7 +16,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with Alfresco. If not, see . */ -package org.alfresco.rest.search; +package org.alfresco.service.search.rest.search; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; @@ -28,6 +28,10 @@ import java.util.List; import com.fasterxml.jackson.core.JsonProcessingException; import org.alfresco.rest.exception.EmptyRestModelCollectionException; +import org.alfresco.rest.search.RestInstanceModel; +import org.alfresco.rest.search.RestShardInfoModel; +import org.alfresco.rest.search.RestShardInfoModelCollection; +import org.alfresco.rest.search.RestShardModel; import org.alfresco.utility.model.TestGroup; import org.springframework.http.HttpStatus; import org.testng.annotations.Test; diff --git a/e2e-test/src/test/java/org/alfresco/rest/search/StatsSearchTest.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/StatsSearchTest.java similarity index 95% rename from e2e-test/src/test/java/org/alfresco/rest/search/StatsSearchTest.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/search/StatsSearchTest.java index 594bb47b6..9e00a5d19 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/search/StatsSearchTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/StatsSearchTest.java @@ -16,7 +16,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with Alfresco. If not, see . */ -package org.alfresco.rest.search; +package org.alfresco.service.search.rest.search; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; @@ -30,6 +30,18 @@ import java.util.Set; import java.util.stream.Collectors; import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.search.Pagination; +import org.alfresco.rest.search.RestGenericBucketModel; +import org.alfresco.rest.search.RestGenericFacetResponseModel; +import org.alfresco.rest.search.RestGenericMetricModel; +import org.alfresco.rest.search.RestRequestFacetFieldModel; +import org.alfresco.rest.search.RestRequestFacetFieldsModel; +import org.alfresco.rest.search.RestRequestFilterQueryModel; +import org.alfresco.rest.search.RestRequestPivotModel; +import org.alfresco.rest.search.RestRequestQueryModel; +import org.alfresco.rest.search.RestRequestStatsModel; +import org.alfresco.rest.search.SearchRequest; +import org.alfresco.rest.search.SearchResponse; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; diff --git a/e2e-test/src/test/java/org/alfresco/rest/search/solr/SearchSolrAPITest.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/solr/SearchSolrAPITest.java similarity index 97% rename from e2e-test/src/test/java/org/alfresco/rest/search/solr/SearchSolrAPITest.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/search/solr/SearchSolrAPITest.java index 0f1ed9f06..6e664b0d1 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/search/solr/SearchSolrAPITest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/solr/SearchSolrAPITest.java @@ -12,7 +12,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with Alfresco. If not, see . */ -package org.alfresco.rest.search.solr; +package org.alfresco.service.search.rest.search.solr; import java.net.URLEncoder; @@ -20,7 +20,7 @@ import javax.json.JsonArrayBuilder; import org.alfresco.rest.core.JsonBodyGenerator; import org.alfresco.rest.model.RestTextResponse; -import org.alfresco.rest.search.AbstractSearchTest; +import org.alfresco.service.search.rest.search.AbstractSearchTest; import org.alfresco.utility.model.TestGroup; import org.hamcrest.Matchers; import org.springframework.http.HttpStatus; diff --git a/e2e-test/src/test/java/org/alfresco/rest/search/sql/SearchSQLAPITest.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/sql/SearchSQLAPITest.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/rest/search/sql/SearchSQLAPITest.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/search/sql/SearchSQLAPITest.java index 3335e85c5..eca9eb29d 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/search/sql/SearchSQLAPITest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/sql/SearchSQLAPITest.java @@ -12,7 +12,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with Alfresco. If not, see . */ -package org.alfresco.rest.search.sql; +package org.alfresco.service.search.rest.search.sql; import static java.util.Arrays.asList; @@ -26,7 +26,7 @@ import static org.hamcrest.Matchers.isIn; import static org.hamcrest.Matchers.not; import org.alfresco.rest.core.RestResponse; -import org.alfresco.rest.search.AbstractSearchTest; +import org.alfresco.service.search.rest.search.AbstractSearchTest; import org.alfresco.rest.search.SearchSqlRequest; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.model.TestGroup; diff --git a/e2e-test/src/test/java/org/alfresco/rest/search/sql/SearchSQLPhraseTest.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/sql/SearchSQLPhraseTest.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/rest/search/sql/SearchSQLPhraseTest.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/search/sql/SearchSQLPhraseTest.java index 86551eb09..c0392a372 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/search/sql/SearchSQLPhraseTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/sql/SearchSQLPhraseTest.java @@ -12,7 +12,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with Alfresco. If not, see . */ -package org.alfresco.rest.search.sql; +package org.alfresco.service.search.rest.search.sql; import java.sql.ResultSet; import java.util.ArrayList; @@ -22,7 +22,7 @@ import java.util.List; import java.util.Map; import org.alfresco.rest.core.RestResponse; -import org.alfresco.rest.search.AbstractSearchTest; +import org.alfresco.service.search.rest.search.AbstractSearchTest; import org.alfresco.rest.search.SearchSqlJDBCRequest; import org.alfresco.rest.search.SearchSqlRequest; import org.alfresco.utility.model.FileModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/search/sql/SearchSQLViaJDBCTest.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/sql/SearchSQLViaJDBCTest.java similarity index 98% rename from e2e-test/src/test/java/org/alfresco/rest/search/sql/SearchSQLViaJDBCTest.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/search/sql/SearchSQLViaJDBCTest.java index eed0bb445..21f34c7ce 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/search/sql/SearchSQLViaJDBCTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/sql/SearchSQLViaJDBCTest.java @@ -16,7 +16,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with Alfresco. If not, see . */ -package org.alfresco.rest.search.sql; +package org.alfresco.service.search.rest.search.sql; import java.sql.ResultSet; import java.sql.SQLException; @@ -25,7 +25,7 @@ import java.util.List; import org.alfresco.dataprep.SiteService.Visibility; import org.alfresco.rest.requests.search.SearchSQLJDBC; -import org.alfresco.rest.search.AbstractSearchTest; +import org.alfresco.service.search.rest.search.AbstractSearchTest; import org.alfresco.rest.search.SearchSqlJDBCRequest; import org.alfresco.utility.data.RandomData; import org.alfresco.utility.model.SiteModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/search/sql/SearchSQLWithQuotedIdentifiers.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/sql/SearchSQLWithQuotedIdentifiers.java similarity index 98% rename from e2e-test/src/test/java/org/alfresco/rest/search/sql/SearchSQLWithQuotedIdentifiers.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/search/sql/SearchSQLWithQuotedIdentifiers.java index 30f773d53..4b7b36f1f 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/search/sql/SearchSQLWithQuotedIdentifiers.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/sql/SearchSQLWithQuotedIdentifiers.java @@ -16,12 +16,12 @@ * You should have received a copy of the GNU Lesser General Public License * along with Alfresco. If not, see . */ -package org.alfresco.rest.search.sql; +package org.alfresco.service.search.rest.search.sql; import java.util.UUID; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.search.AbstractSearchTest; +import org.alfresco.service.search.rest.RestTest; +import org.alfresco.service.search.rest.search.AbstractSearchTest; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.CustomObjectTypeProperties; import org.alfresco.utility.model.ContentModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/sharedLinks/GetSharedLinksFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sharedLinks/GetSharedLinksFullTests.java similarity index 97% rename from e2e-test/src/test/java/org/alfresco/rest/sharedLinks/GetSharedLinksFullTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/sharedLinks/GetSharedLinksFullTests.java index c2e3627a6..296cd58f7 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/sharedLinks/GetSharedLinksFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/sharedLinks/GetSharedLinksFullTests.java @@ -1,12 +1,12 @@ -package org.alfresco.rest.sharedLinks; +package org.alfresco.service.search.rest.sharedLinks; import javax.json.Json; import javax.json.JsonObject; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestNodeModel; import org.alfresco.rest.model.RestSharedLinksModelCollection; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/sharedLinks/SharedLinksSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sharedLinks/SharedLinksSanityTests.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/rest/sharedLinks/SharedLinksSanityTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/sharedLinks/SharedLinksSanityTests.java index c9dbc91fe..fdff67357 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/sharedLinks/SharedLinksSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/sharedLinks/SharedLinksSanityTests.java @@ -1,13 +1,13 @@ -package org.alfresco.rest.sharedLinks; +package org.alfresco.service.search.rest.sharedLinks; import javax.json.Json; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestRenditionInfoModel; import org.alfresco.rest.model.RestRenditionInfoModelCollection; import org.alfresco.rest.model.RestSharedLinksModel; import org.alfresco.rest.model.RestSharedLinksModelCollection; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.utility.Utility; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FolderModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/sites/GetSiteTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/GetSiteTests.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/rest/sites/GetSiteTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/sites/GetSiteTests.java index e205fe7a1..7a2f5107b 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/sites/GetSiteTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/GetSiteTests.java @@ -1,7 +1,7 @@ -package org.alfresco.rest.sites; +package org.alfresco.service.search.rest.sites; import org.alfresco.dataprep.SiteService; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.core.RestResponse; import org.alfresco.rest.model.*; diff --git a/e2e-test/src/test/java/org/alfresco/rest/sites/GetSitesTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/GetSitesTests.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/rest/sites/GetSitesTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/sites/GetSitesTests.java index d178612bf..2d986ab57 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/sites/GetSitesTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/GetSitesTests.java @@ -1,7 +1,7 @@ -package org.alfresco.rest.sites; +package org.alfresco.service.search.rest.sites; import org.alfresco.dataprep.SiteService; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.*; import org.alfresco.utility.constants.ContainerName; import org.alfresco.utility.constants.UserRole; diff --git a/e2e-test/src/test/java/org/alfresco/rest/sites/SitesNetworkTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/SitesNetworkTests.java similarity index 97% rename from e2e-test/src/test/java/org/alfresco/rest/sites/SitesNetworkTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/sites/SitesNetworkTests.java index 9716ecba0..ea3a9a2e3 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/sites/SitesNetworkTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/SitesNetworkTests.java @@ -1,7 +1,7 @@ -package org.alfresco.rest.sites; +package org.alfresco.service.search.rest.sites; import org.alfresco.dataprep.SiteService; -import org.alfresco.rest.NetworkDataPrep; +import org.alfresco.service.search.rest.NetworkDataPrep; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestSiteMembershipRequestModel; import org.alfresco.utility.model.SiteModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/sites/SitesTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/SitesTests.java similarity index 93% rename from e2e-test/src/test/java/org/alfresco/rest/sites/SitesTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/sites/SitesTests.java index 9b40f7082..6f2923d0b 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/sites/SitesTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/SitesTests.java @@ -1,6 +1,6 @@ -package org.alfresco.rest.sites; +package org.alfresco.service.search.rest.sites; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestSiteModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; diff --git a/e2e-test/src/test/java/org/alfresco/rest/sites/containers/GetSiteContainerTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/containers/GetSiteContainerTests.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/rest/sites/containers/GetSiteContainerTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/sites/containers/GetSiteContainerTests.java index 2ca445467..94c2782b8 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/sites/containers/GetSiteContainerTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/containers/GetSiteContainerTests.java @@ -1,6 +1,6 @@ -package org.alfresco.rest.sites.containers; +package org.alfresco.service.search.rest.sites.containers; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestSiteContainerModel; import org.alfresco.utility.constants.ContainerName; diff --git a/e2e-test/src/test/java/org/alfresco/rest/sites/containers/GetSiteContainersTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/containers/GetSiteContainersTests.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/rest/sites/containers/GetSiteContainersTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/sites/containers/GetSiteContainersTests.java index 2822239eb..b6bd7cc8a 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/sites/containers/GetSiteContainersTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/containers/GetSiteContainersTests.java @@ -1,6 +1,6 @@ -package org.alfresco.rest.sites.containers; +package org.alfresco.service.search.rest.sites.containers; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestSiteContainerModelsCollection; import org.alfresco.utility.constants.ContainerName; diff --git a/e2e-test/src/test/java/org/alfresco/rest/sites/members/AddSiteMemberTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/AddSiteMemberTests.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/rest/sites/members/AddSiteMemberTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/AddSiteMemberTests.java index 51cab086f..7ce21de18 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/sites/members/AddSiteMemberTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/AddSiteMemberTests.java @@ -1,6 +1,6 @@ -package org.alfresco.rest.sites.members; +package org.alfresco.service.search.rest.sites.members; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.core.JsonBodyGenerator; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/sites/members/GetSiteMemberTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/GetSiteMemberTests.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/rest/sites/members/GetSiteMemberTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/GetSiteMemberTests.java index b9c0e9f49..9911bf47a 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/sites/members/GetSiteMemberTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/GetSiteMemberTests.java @@ -1,6 +1,6 @@ -package org.alfresco.rest.sites.members; +package org.alfresco.service.search.rest.sites.members; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.constants.UserRole; diff --git a/e2e-test/src/test/java/org/alfresco/rest/sites/members/GetSiteMembersTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/GetSiteMembersTests.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/rest/sites/members/GetSiteMembersTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/GetSiteMembersTests.java index a6231ad49..fdcf3def4 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/sites/members/GetSiteMembersTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/GetSiteMembersTests.java @@ -1,6 +1,6 @@ -package org.alfresco.rest.sites.members; +package org.alfresco.service.search.rest.sites.members; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestSiteMemberModel; import org.alfresco.rest.model.RestSiteMemberModelsCollection; diff --git a/e2e-test/src/test/java/org/alfresco/rest/sites/members/RemoveSiteMemberTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/RemoveSiteMemberTests.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/rest/sites/members/RemoveSiteMemberTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/RemoveSiteMemberTests.java index fca039386..485305e59 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/sites/members/RemoveSiteMemberTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/RemoveSiteMemberTests.java @@ -1,6 +1,6 @@ -package org.alfresco.rest.sites.members; +package org.alfresco.service.search.rest.sites.members; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; diff --git a/e2e-test/src/test/java/org/alfresco/rest/sites/members/UpdateSiteMemberTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/UpdateSiteMemberTests.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/rest/sites/members/UpdateSiteMemberTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/UpdateSiteMemberTests.java index 3b98afebb..338bbc192 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/sites/members/UpdateSiteMemberTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/UpdateSiteMemberTests.java @@ -1,6 +1,6 @@ -package org.alfresco.rest.sites.members; +package org.alfresco.service.search.rest.sites.members; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.core.JsonBodyGenerator; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/sites/membershipRequests/AddSiteMembershipRequestTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/AddSiteMembershipRequestTests.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/rest/sites/membershipRequests/AddSiteMembershipRequestTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/AddSiteMembershipRequestTests.java index a6f155cf6..de28098b4 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/sites/membershipRequests/AddSiteMembershipRequestTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/AddSiteMembershipRequestTests.java @@ -1,7 +1,7 @@ -package org.alfresco.rest.sites.membershipRequests; +package org.alfresco.service.search.rest.sites.membershipRequests; import org.alfresco.dataprep.SiteService; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestSiteEntry; import org.alfresco.rest.model.RestSiteMembershipRequestModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/sites/membershipRequests/DeleteSiteMembershipRequestTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/DeleteSiteMembershipRequestTests.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/rest/sites/membershipRequests/DeleteSiteMembershipRequestTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/DeleteSiteMembershipRequestTests.java index c1da58fb1..dd495422d 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/sites/membershipRequests/DeleteSiteMembershipRequestTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/DeleteSiteMembershipRequestTests.java @@ -1,7 +1,7 @@ -package org.alfresco.rest.sites.membershipRequests; +package org.alfresco.service.search.rest.sites.membershipRequests; import org.alfresco.dataprep.SiteService.Visibility; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestSiteMembershipRequestModelsCollection; import org.alfresco.rest.model.RestTaskModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/GetSiteMembershipRequestTests.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/GetSiteMembershipRequestTests.java index fba1deab0..ed63a790b 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/GetSiteMembershipRequestTests.java @@ -1,7 +1,7 @@ -package org.alfresco.rest.sites.membershipRequests; +package org.alfresco.service.search.rest.sites.membershipRequests; import org.alfresco.dataprep.SiteService; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestSiteMembershipRequestModel; import org.alfresco.rest.model.RestTaskModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestsTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/GetSiteMembershipRequestsTests.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestsTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/GetSiteMembershipRequestsTests.java index 470b118dd..dbb5ef43f 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestsTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/GetSiteMembershipRequestsTests.java @@ -1,8 +1,8 @@ -package org.alfresco.rest.sites.membershipRequests; +package org.alfresco.service.search.rest.sites.membershipRequests; import static org.alfresco.utility.report.log.Step.STEP; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.*; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; diff --git a/e2e-test/src/test/java/org/alfresco/rest/sites/membershipRequests/UpdateSiteMembershipRequestTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/UpdateSiteMembershipRequestTests.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/rest/sites/membershipRequests/UpdateSiteMembershipRequestTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/UpdateSiteMembershipRequestTests.java index c40d3a2b5..8cb9af558 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/sites/membershipRequests/UpdateSiteMembershipRequestTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/UpdateSiteMembershipRequestTests.java @@ -1,6 +1,6 @@ -package org.alfresco.rest.sites.membershipRequests; +package org.alfresco.service.search.rest.sites.membershipRequests; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestSiteMembershipRequestModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/syncService/SyncServiceAPITests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/syncService/SyncServiceAPITests.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/rest/syncService/SyncServiceAPITests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/syncService/SyncServiceAPITests.java index 58dacb907..1f834f875 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/syncService/SyncServiceAPITests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/syncService/SyncServiceAPITests.java @@ -1,9 +1,8 @@ -package org.alfresco.rest.syncService; +package org.alfresco.service.search.rest.syncService; import java.util.LinkedList; import java.util.List; -import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestSubscriberModel; import org.alfresco.rest.model.RestSubscriberModelCollection; import org.alfresco.rest.model.RestSyncNodeSubscriptionModel; @@ -14,6 +13,7 @@ import org.alfresco.rest.model.RestSyncSetGetModel; import org.alfresco.rest.model.RestSyncSetRequestModel; import org.alfresco.rest.requests.syncServiceAPI.Healthcheck; import org.alfresco.rest.requests.syncServiceAPI.Subscriptions.TYPE; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.utility.LogFactory; import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/tags/GetTagTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/tags/GetTagTests.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/rest/tags/GetTagTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/tags/GetTagTests.java index 99bb12b8a..c155d472e 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/tags/GetTagTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/tags/GetTagTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.tags; +package org.alfresco.service.search.rest.tags; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestTagModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/tags/GetTagsTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/tags/GetTagsTests.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/rest/tags/GetTagsTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/tags/GetTagsTests.java index 5c3b49ff9..d3e77911a 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/tags/GetTagsTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/tags/GetTagsTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.tags; +package org.alfresco.service.search.rest.tags; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestTagModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/tags/TagsDataPrep.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/tags/TagsDataPrep.java similarity index 96% rename from e2e-test/src/test/java/org/alfresco/rest/tags/TagsDataPrep.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/tags/TagsDataPrep.java index a499ab15b..974257df6 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/tags/TagsDataPrep.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/tags/TagsDataPrep.java @@ -1,7 +1,7 @@ -package org.alfresco.rest.tags; +package org.alfresco.service.search.rest.tags; import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestTagModel; import org.alfresco.rest.model.RestTagModelsCollection; import org.alfresco.utility.Utility; diff --git a/e2e-test/src/test/java/org/alfresco/rest/tags/UpdateTagTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/tags/UpdateTagTests.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/rest/tags/UpdateTagTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/tags/UpdateTagTests.java index 21f506483..efa6b115e 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/tags/UpdateTagTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/tags/UpdateTagTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.tags; +package org.alfresco.service.search.rest.tags; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestTagModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/tags/nodes/AddTagTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/tags/nodes/AddTagTests.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/rest/tags/nodes/AddTagTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/tags/nodes/AddTagTests.java index c0606d3dc..9ecb92f39 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/tags/nodes/AddTagTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/tags/nodes/AddTagTests.java @@ -1,11 +1,11 @@ -package org.alfresco.rest.tags.nodes; +package org.alfresco.service.search.rest.tags.nodes; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.model.RestCommentModel; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestTagModel; import org.alfresco.rest.model.RestTagModelsCollection; -import org.alfresco.rest.tags.TagsDataPrep; +import org.alfresco.service.search.rest.tags.TagsDataPrep; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.RandomData; import org.alfresco.utility.model.FileModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/tags/nodes/AddTagsTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/tags/nodes/AddTagsTests.java similarity index 98% rename from e2e-test/src/test/java/org/alfresco/rest/tags/nodes/AddTagsTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/tags/nodes/AddTagsTests.java index 25063550e..8e2e8a452 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/tags/nodes/AddTagsTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/tags/nodes/AddTagsTests.java @@ -1,10 +1,10 @@ -package org.alfresco.rest.tags.nodes; +package org.alfresco.service.search.rest.tags.nodes; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestTagModel; import org.alfresco.rest.model.RestTagModelsCollection; -import org.alfresco.rest.tags.TagsDataPrep; +import org.alfresco.service.search.rest.tags.TagsDataPrep; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.RandomData; import org.alfresco.utility.model.FileModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/tags/nodes/DeleteTagTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/tags/nodes/DeleteTagTests.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/rest/tags/nodes/DeleteTagTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/tags/nodes/DeleteTagTests.java index ec77b8fc7..75540fcbc 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/tags/nodes/DeleteTagTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/tags/nodes/DeleteTagTests.java @@ -1,9 +1,9 @@ -package org.alfresco.rest.tags.nodes; +package org.alfresco.service.search.rest.tags.nodes; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestTagModel; -import org.alfresco.rest.tags.TagsDataPrep; +import org.alfresco.service.search.rest.tags.TagsDataPrep; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.RandomData; import org.alfresco.utility.model.FileModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/tags/nodes/GetNodeTagsTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/tags/nodes/GetNodeTagsTests.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/rest/tags/nodes/GetNodeTagsTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/tags/nodes/GetNodeTagsTests.java index f38e20d64..b144ab16f 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/tags/nodes/GetNodeTagsTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/tags/nodes/GetNodeTagsTests.java @@ -1,8 +1,8 @@ -package org.alfresco.rest.tags.nodes; +package org.alfresco.service.search.rest.tags.nodes; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.tags.TagsDataPrep; +import org.alfresco.service.search.rest.tags.TagsDataPrep; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FolderModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/trashcan/GetDeletedNodesTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/trashcan/GetDeletedNodesTests.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/rest/trashcan/GetDeletedNodesTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/trashcan/GetDeletedNodesTests.java index 553b044d1..02ea3f126 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/trashcan/GetDeletedNodesTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/trashcan/GetDeletedNodesTests.java @@ -13,10 +13,10 @@ * along with Alfresco. If not, see . */ -package org.alfresco.rest.trashcan; +package org.alfresco.service.search.rest.trashcan; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestNodeModel; import org.alfresco.rest.model.RestNodeModelsCollection; import org.alfresco.rest.model.RestRenditionInfoModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/WorkflowNetworkDeploymentsTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/WorkflowNetworkDeploymentsTests.java similarity index 98% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/WorkflowNetworkDeploymentsTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/WorkflowNetworkDeploymentsTests.java index 8a255fd0b..b28409dc0 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/WorkflowNetworkDeploymentsTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/WorkflowNetworkDeploymentsTests.java @@ -1,8 +1,8 @@ -package org.alfresco.rest.workflow; +package org.alfresco.service.search.rest.workflow; import java.util.List; -import org.alfresco.rest.NetworkDataPrep; +import org.alfresco.service.search.rest.NetworkDataPrep; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestDeploymentModel; import org.alfresco.rest.model.RestDeploymentModelsCollection; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/WorkflowNetworkProcessDefinitionsTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/WorkflowNetworkProcessDefinitionsTests.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/WorkflowNetworkProcessDefinitionsTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/WorkflowNetworkProcessDefinitionsTests.java index 038681aef..f20cb20dc 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/WorkflowNetworkProcessDefinitionsTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/WorkflowNetworkProcessDefinitionsTests.java @@ -1,7 +1,7 @@ -package org.alfresco.rest.workflow; +package org.alfresco.service.search.rest.workflow; import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.rest.NetworkDataPrep; +import org.alfresco.service.search.rest.NetworkDataPrep; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessDefinitionModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/WorkflowNetworkProcessesTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/WorkflowNetworkProcessesTests.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/WorkflowNetworkProcessesTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/WorkflowNetworkProcessesTests.java index 0e9b6696f..42233fc84 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/WorkflowNetworkProcessesTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/WorkflowNetworkProcessesTests.java @@ -1,9 +1,9 @@ -package org.alfresco.rest.workflow; +package org.alfresco.service.search.rest.workflow; import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.rest.NetworkDataPrep; +import org.alfresco.service.search.rest.NetworkDataPrep; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestItemModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/WorkflowNetworkTasksTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/WorkflowNetworkTasksTests.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/WorkflowNetworkTasksTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/WorkflowNetworkTasksTests.java index f1f4e53a4..19be57be2 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/WorkflowNetworkTasksTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/WorkflowNetworkTasksTests.java @@ -1,9 +1,9 @@ -package org.alfresco.rest.workflow; +package org.alfresco.service.search.rest.workflow; import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.rest.NetworkDataPrep; +import org.alfresco.service.search.rest.NetworkDataPrep; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestFormModelsCollection; import org.alfresco.rest.model.RestItemModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/DeleteDeploymentTests.java similarity index 98% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/DeleteDeploymentTests.java index 0a929fd0e..330a8bdd2 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/DeleteDeploymentTests.java @@ -1,15 +1,15 @@ -package org.alfresco.rest.workflow.deployments; +package org.alfresco.service.search.rest.workflow.deployments; import java.util.List; import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestDeploymentModel; import org.alfresco.rest.model.RestDeploymentModelsCollection; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessDefinitionModel; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.rest.model.RestTaskModel; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/deployments/GetDeploymentCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentCoreTests.java similarity index 93% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/deployments/GetDeploymentCoreTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentCoreTests.java index df2aae3a0..42842959a 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/deployments/GetDeploymentCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentCoreTests.java @@ -1,8 +1,8 @@ -package org.alfresco.rest.workflow.deployments; +package org.alfresco.service.search.rest.workflow.deployments; -import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestDeploymentModel; import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/deployments/GetDeploymentFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentFullTests.java similarity index 96% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/deployments/GetDeploymentFullTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentFullTests.java index cea14ceca..9dcae1999 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/deployments/GetDeploymentFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentFullTests.java @@ -1,9 +1,9 @@ -package org.alfresco.rest.workflow.deployments; +package org.alfresco.service.search.rest.workflow.deployments; -import org.alfresco.rest.RestTest; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.model.RestDeploymentModel; import org.alfresco.rest.model.RestDeploymentModelsCollection; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/deployments/GetDeploymentSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentSanityTests.java similarity index 96% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/deployments/GetDeploymentSanityTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentSanityTests.java index 67bda8b8a..014f692fb 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/deployments/GetDeploymentSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentSanityTests.java @@ -1,9 +1,9 @@ -package org.alfresco.rest.workflow.deployments; +package org.alfresco.service.search.rest.workflow.deployments; -import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestDeploymentModel; import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentsCoreTests.java similarity index 91% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsCoreTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentsCoreTests.java index f35f882a4..161d277d0 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentsCoreTests.java @@ -1,7 +1,7 @@ -package org.alfresco.rest.workflow.deployments; +package org.alfresco.service.search.rest.workflow.deployments; -import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentsFullTests.java similarity index 98% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsFullTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentsFullTests.java index 6ba152e46..ccd805c12 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentsFullTests.java @@ -1,10 +1,10 @@ -package org.alfresco.rest.workflow.deployments; +package org.alfresco.service.search.rest.workflow.deployments; -import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestDeploymentModel; import org.alfresco.rest.model.RestDeploymentModelsCollection; import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentsSanityTests.java similarity index 94% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsSanityTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentsSanityTests.java index 9d1a4025f..4c0396f6c 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentsSanityTests.java @@ -1,8 +1,8 @@ -package org.alfresco.rest.workflow.deployments; +package org.alfresco.service.search.rest.workflow.deployments; -import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestDeploymentModelsCollection; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionCoreTests.java similarity index 94% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionCoreTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionCoreTests.java index 3edb7e020..39a0fa465 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionCoreTests.java @@ -1,8 +1,8 @@ -package org.alfresco.rest.workflow.processDefinitions; +package org.alfresco.service.search.rest.workflow.processDefinitions; -import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessDefinitionModel; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionFullTests.java similarity index 96% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionFullTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionFullTests.java index 17c2b6972..6f04b16b4 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionFullTests.java @@ -1,9 +1,9 @@ -package org.alfresco.rest.workflow.processDefinitions; +package org.alfresco.service.search.rest.workflow.processDefinitions; -import org.alfresco.rest.RestTest; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.model.RestProcessDefinitionModel; import org.alfresco.rest.model.RestProcessDefinitionModelsCollection; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionImageCoreTests.java similarity index 94% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageCoreTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionImageCoreTests.java index 2fe6f5f3c..ef3dd0fd7 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionImageCoreTests.java @@ -1,8 +1,8 @@ -package org.alfresco.rest.workflow.processDefinitions; +package org.alfresco.service.search.rest.workflow.processDefinitions; -import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessDefinitionModel; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionImageFullTests.java similarity index 93% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageFullTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionImageFullTests.java index 9c37e7c46..4a39909cd 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionImageFullTests.java @@ -1,7 +1,7 @@ -package org.alfresco.rest.workflow.processDefinitions; +package org.alfresco.service.search.rest.workflow.processDefinitions; -import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestProcessDefinitionModel; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java similarity index 95% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java index 06f76f017..7d39eb362 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java @@ -1,7 +1,7 @@ -package org.alfresco.rest.workflow.processDefinitions; +package org.alfresco.service.search.rest.workflow.processDefinitions; -import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestProcessDefinitionModel; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java similarity index 96% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java index 36d8ef872..4eb0baa28 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java @@ -1,7 +1,7 @@ -package org.alfresco.rest.workflow.processDefinitions; +package org.alfresco.service.search.rest.workflow.processDefinitions; -import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestProcessDefinitionModel; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java similarity index 97% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java index 6290ad9f6..2e8fe6c1f 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java @@ -1,9 +1,9 @@ -package org.alfresco.rest.workflow.processDefinitions; +package org.alfresco.service.search.rest.workflow.processDefinitions; -import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessDefinitionModel; import org.alfresco.rest.model.RestProcessDefinitionModelsCollection; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelFullTests.java similarity index 97% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelFullTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelFullTests.java index fa77452a4..5062ea772 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelFullTests.java @@ -1,10 +1,10 @@ -package org.alfresco.rest.workflow.processDefinitions; +package org.alfresco.service.search.rest.workflow.processDefinitions; import java.util.Arrays; -import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestFormModelsCollection; import org.alfresco.rest.model.RestProcessDefinitionModel; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java similarity index 93% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java index 7b3d98aef..820fbee80 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java @@ -1,7 +1,7 @@ -package org.alfresco.rest.workflow.processDefinitions; +package org.alfresco.service.search.rest.workflow.processDefinitions; -import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestProcessDefinitionModel; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionsCoreTests.java similarity index 95% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsCoreTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionsCoreTests.java index 6d4e492ff..c30e3177d 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionsCoreTests.java @@ -1,7 +1,7 @@ -package org.alfresco.rest.workflow.processDefinitions; +package org.alfresco.service.search.rest.workflow.processDefinitions; -import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionsFullTests.java similarity index 98% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsFullTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionsFullTests.java index 6d4f929e7..2b2687dd4 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionsFullTests.java @@ -1,9 +1,9 @@ -package org.alfresco.rest.workflow.processDefinitions; +package org.alfresco.service.search.rest.workflow.processDefinitions; -import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessDefinitionModel; import org.alfresco.rest.model.RestProcessDefinitionModelsCollection; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java similarity index 94% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java index f0a330d7c..bfa595150 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java @@ -1,7 +1,7 @@ -package org.alfresco.rest.workflow.processDefinitions; +package org.alfresco.service.search.rest.workflow.processDefinitions; -import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestProcessDefinitionModelsCollection; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.testrail.ExecutionType; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/AddProcessCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/AddProcessCoreTests.java similarity index 97% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/processes/AddProcessCoreTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/AddProcessCoreTests.java index 8a2eac446..4ae2f8b59 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/AddProcessCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/AddProcessCoreTests.java @@ -1,12 +1,10 @@ -package org.alfresco.rest.workflow.processes; +package org.alfresco.service.search.rest.workflow.processes; import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessDefinitionModel; -import org.alfresco.rest.model.RestProcessDefinitionModelsCollection; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.rest.model.RestProcessModelsCollection; import org.alfresco.utility.model.TestGroup; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/AddProcessFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/AddProcessFullTests.java similarity index 98% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/processes/AddProcessFullTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/AddProcessFullTests.java index c1eb6b24a..61b609c63 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/AddProcessFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/AddProcessFullTests.java @@ -1,9 +1,9 @@ -package org.alfresco.rest.workflow.processes; +package org.alfresco.service.search.rest.workflow.processes; import javax.json.JsonObject; import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.core.JsonBodyGenerator; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/AddProcessSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/AddProcessSanityTests.java similarity index 94% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/processes/AddProcessSanityTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/AddProcessSanityTests.java index e43e59203..4be323242 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/AddProcessSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/AddProcessSanityTests.java @@ -1,7 +1,7 @@ -package org.alfresco.rest.workflow.processes; +package org.alfresco.service.search.rest.workflow.processes; import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.rest.model.RestProcessModelsCollection; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/DeleteProcessCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/DeleteProcessCoreTests.java similarity index 96% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/processes/DeleteProcessCoreTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/DeleteProcessCoreTests.java index 26253d2b1..8d0525e1e 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/DeleteProcessCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/DeleteProcessCoreTests.java @@ -1,7 +1,7 @@ -package org.alfresco.rest.workflow.processes; +package org.alfresco.service.search.rest.workflow.processes; import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.utility.model.TestGroup; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/DeleteProcessFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/DeleteProcessFullTests.java similarity index 95% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/processes/DeleteProcessFullTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/DeleteProcessFullTests.java index e1c295f72..dad9826f2 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/DeleteProcessFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/DeleteProcessFullTests.java @@ -1,7 +1,7 @@ -package org.alfresco.rest.workflow.processes; +package org.alfresco.service.search.rest.workflow.processes; import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.utility.model.TestGroup; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/DeleteProcessSanityTests.java similarity index 97% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/DeleteProcessSanityTests.java index 9478b9d0e..6cea148d8 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/DeleteProcessSanityTests.java @@ -1,7 +1,7 @@ -package org.alfresco.rest.workflow.processes; +package org.alfresco.service.search.rest.workflow.processes; import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/GetProcessCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessCoreTests.java similarity index 94% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/processes/GetProcessCoreTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessCoreTests.java index 418e4b8a0..bc97bb842 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/GetProcessCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessCoreTests.java @@ -1,7 +1,7 @@ -package org.alfresco.rest.workflow.processes; +package org.alfresco.service.search.rest.workflow.processes; import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.utility.model.TestGroup; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/GetProcessFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessFullTests.java similarity index 97% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/processes/GetProcessFullTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessFullTests.java index 01c11e8a2..e7214bba5 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/GetProcessFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessFullTests.java @@ -1,7 +1,7 @@ -package org.alfresco.rest.workflow.processes; +package org.alfresco.service.search.rest.workflow.processes; import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestProcessDefinitionModel; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.utility.model.TestGroup; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/GetProcessSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessSanityTests.java similarity index 96% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/processes/GetProcessSanityTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessSanityTests.java index b4288002a..33649ebf5 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/GetProcessSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessSanityTests.java @@ -1,7 +1,7 @@ -package org.alfresco.rest.workflow.processes; +package org.alfresco.service.search.rest.workflow.processes; import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/GetProcessesCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessesCoreTests.java similarity index 97% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/processes/GetProcessesCoreTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessesCoreTests.java index 5a5c5fd5d..d2532d36a 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/GetProcessesCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessesCoreTests.java @@ -1,9 +1,9 @@ -package org.alfresco.rest.workflow.processes; +package org.alfresco.service.search.rest.workflow.processes; import java.util.List; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestProcessDefinitionModel; import org.alfresco.rest.model.RestProcessModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/GetProcessesFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessesFullTests.java similarity index 98% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/processes/GetProcessesFullTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessesFullTests.java index c4595920e..0c5b63b5e 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/GetProcessesFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessesFullTests.java @@ -1,9 +1,9 @@ -package org.alfresco.rest.workflow.processes; +package org.alfresco.service.search.rest.workflow.processes; import java.util.List; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.rest.model.RestProcessModelsCollection; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessesSanityTests.java similarity index 97% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessesSanityTests.java index b64d0d141..58d5b8032 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessesSanityTests.java @@ -1,7 +1,7 @@ -package org.alfresco.rest.workflow.processes; +package org.alfresco.service.search.rest.workflow.processes; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestProcessModelsCollection; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/AddProcessItemCoreTests.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemCoreTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/AddProcessItemCoreTests.java index 9eaa02099..86e6d4489 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/AddProcessItemCoreTests.java @@ -1,7 +1,7 @@ -package org.alfresco.rest.workflow.processes.items; +package org.alfresco.service.search.rest.workflow.processes.items; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestItemModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/AddProcessItemFullTests.java similarity index 98% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemFullTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/AddProcessItemFullTests.java index 202fcf554..49a8f28a2 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/AddProcessItemFullTests.java @@ -1,7 +1,7 @@ -package org.alfresco.rest.workflow.processes.items; +package org.alfresco.service.search.rest.workflow.processes.items; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestItemModel; import org.alfresco.rest.model.RestItemModelsCollection; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/AddProcessItemSanityTests.java similarity index 98% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemSanityTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/AddProcessItemSanityTests.java index 797936ceb..e31365974 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/AddProcessItemSanityTests.java @@ -1,7 +1,7 @@ -package org.alfresco.rest.workflow.processes.items; +package org.alfresco.service.search.rest.workflow.processes.items; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestItemModel; import org.alfresco.rest.model.RestItemModelsCollection; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/items/DeleteProcessItemCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/DeleteProcessItemCoreTests.java similarity index 97% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/processes/items/DeleteProcessItemCoreTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/DeleteProcessItemCoreTests.java index ca7a5a308..ae9d60211 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/items/DeleteProcessItemCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/DeleteProcessItemCoreTests.java @@ -1,7 +1,7 @@ -package org.alfresco.rest.workflow.processes.items; +package org.alfresco.service.search.rest.workflow.processes.items; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestItemModel; import org.alfresco.rest.model.RestItemModelsCollection; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/items/DeleteProcessItemFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/DeleteProcessItemFullTests.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/processes/items/DeleteProcessItemFullTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/DeleteProcessItemFullTests.java index 3afd2e31c..2be92a1aa 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/items/DeleteProcessItemFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/DeleteProcessItemFullTests.java @@ -1,8 +1,8 @@ -package org.alfresco.rest.workflow.processes.items; +package org.alfresco.service.search.rest.workflow.processes.items; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.exception.EmptyRestModelCollectionException; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestItemModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/items/DeleteProcessItemSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/DeleteProcessItemSanityTests.java similarity index 96% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/processes/items/DeleteProcessItemSanityTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/DeleteProcessItemSanityTests.java index df776f144..341dc6fa1 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/items/DeleteProcessItemSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/DeleteProcessItemSanityTests.java @@ -1,7 +1,7 @@ -package org.alfresco.rest.workflow.processes.items; +package org.alfresco.service.search.rest.workflow.processes.items; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestItemModel; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.utility.model.FileModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/items/GetProcessItemsCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/GetProcessItemsCoreTests.java similarity index 97% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/processes/items/GetProcessItemsCoreTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/GetProcessItemsCoreTests.java index 918af8111..c121a9d47 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/items/GetProcessItemsCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/GetProcessItemsCoreTests.java @@ -1,7 +1,7 @@ -package org.alfresco.rest.workflow.processes.items; +package org.alfresco.service.search.rest.workflow.processes.items; import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.utility.model.FileModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/items/GetProcessItemsFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/GetProcessItemsFullTests.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/processes/items/GetProcessItemsFullTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/GetProcessItemsFullTests.java index c81c5c3f4..b22e118db 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/items/GetProcessItemsFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/GetProcessItemsFullTests.java @@ -1,7 +1,7 @@ -package org.alfresco.rest.workflow.processes.items; +package org.alfresco.service.search.rest.workflow.processes.items; import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestItemModelsCollection; import org.alfresco.rest.model.RestProcessModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/items/GetProcessItemsSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/GetProcessItemsSanityTests.java similarity index 96% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/processes/items/GetProcessItemsSanityTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/GetProcessItemsSanityTests.java index 6c0ce3764..5b293fd0d 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/items/GetProcessItemsSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/GetProcessItemsSanityTests.java @@ -1,7 +1,7 @@ -package org.alfresco.rest.workflow.processes.items; +package org.alfresco.service.search.rest.workflow.processes.items; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestItemModelsCollection; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.utility.model.FileModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/tasks/GetProcessTasksCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/tasks/GetProcessTasksCoreTests.java similarity index 98% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/processes/tasks/GetProcessTasksCoreTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/tasks/GetProcessTasksCoreTests.java index 93bb26a4b..fc6b6d3bc 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/tasks/GetProcessTasksCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/tasks/GetProcessTasksCoreTests.java @@ -1,7 +1,7 @@ -package org.alfresco.rest.workflow.processes.tasks; +package org.alfresco.service.search.rest.workflow.processes.tasks; import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestTaskModel; import org.alfresco.utility.model.FileModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/tasks/GetProcessTasksFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/tasks/GetProcessTasksFullTests.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/processes/tasks/GetProcessTasksFullTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/tasks/GetProcessTasksFullTests.java index 5c7a98d65..bdd935e42 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/tasks/GetProcessTasksFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/tasks/GetProcessTasksFullTests.java @@ -1,7 +1,7 @@ -package org.alfresco.rest.workflow.processes.tasks; +package org.alfresco.service.search.rest.workflow.processes.tasks; import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestTaskModelsCollection; import org.alfresco.utility.model.*; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/tasks/GetProcessTasksSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/tasks/GetProcessTasksSanityTests.java similarity index 97% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/processes/tasks/GetProcessTasksSanityTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/tasks/GetProcessTasksSanityTests.java index d0c5f0efd..f94b72e14 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/tasks/GetProcessTasksSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/tasks/GetProcessTasksSanityTests.java @@ -1,7 +1,7 @@ -package org.alfresco.rest.workflow.processes.tasks; +package org.alfresco.service.search.rest.workflow.processes.tasks; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestTaskModelsCollection; import org.alfresco.utility.model.FileModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariableCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariableCoreTests.java similarity index 98% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariableCoreTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariableCoreTests.java index d1dc33782..6bed60292 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariableCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariableCoreTests.java @@ -1,12 +1,12 @@ -package org.alfresco.rest.workflow.processes.variables; +package org.alfresco.service.search.rest.workflow.processes.variables; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.rest.RestTest; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.rest.model.RestProcessVariableModel; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariableFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariableFullTests.java similarity index 98% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariableFullTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariableFullTests.java index 098a0658d..63abe5c76 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariableFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariableFullTests.java @@ -1,7 +1,7 @@ -package org.alfresco.rest.workflow.processes.variables; +package org.alfresco.service.search.rest.workflow.processes.variables; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariableSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariableSanityTests.java similarity index 97% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariableSanityTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariableSanityTests.java index fed3c5c70..bcdc5c7fc 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariableSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariableSanityTests.java @@ -1,7 +1,7 @@ -package org.alfresco.rest.workflow.processes.variables; +package org.alfresco.service.search.rest.workflow.processes.variables; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.rest.model.RestProcessVariableModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariablesCoreTests.java similarity index 98% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesCoreTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariablesCoreTests.java index e597ddd50..ca5ca5358 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariablesCoreTests.java @@ -1,7 +1,7 @@ -package org.alfresco.rest.workflow.processes.variables; +package org.alfresco.service.search.rest.workflow.processes.variables; import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.rest.model.RestProcessVariableModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariablesFullTests.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesFullTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariablesFullTests.java index ba28bd516..88256f3b1 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariablesFullTests.java @@ -1,8 +1,8 @@ -package org.alfresco.rest.workflow.processes.variables; +package org.alfresco.service.search.rest.workflow.processes.variables; import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariablesSanityTests.java similarity index 98% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesSanityTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariablesSanityTests.java index 26ce6bd8d..8bdc65cbe 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariablesSanityTests.java @@ -1,10 +1,10 @@ -package org.alfresco.rest.workflow.processes.variables; +package org.alfresco.service.search.rest.workflow.processes.variables; import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.rest.model.RestProcessVariableCollection; import org.alfresco.rest.model.RestProcessVariableModel; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.utility.data.RandomData; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/DeleteProcessVariableCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/DeleteProcessVariableCoreTests.java similarity index 98% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/DeleteProcessVariableCoreTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/DeleteProcessVariableCoreTests.java index 031f749b4..1e5681d81 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/DeleteProcessVariableCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/DeleteProcessVariableCoreTests.java @@ -1,7 +1,7 @@ -package org.alfresco.rest.workflow.processes.variables; +package org.alfresco.service.search.rest.workflow.processes.variables; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/DeleteProcessVariableFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/DeleteProcessVariableFullTests.java similarity index 98% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/DeleteProcessVariableFullTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/DeleteProcessVariableFullTests.java index 9def8ff2b..a17edb3a4 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/DeleteProcessVariableFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/DeleteProcessVariableFullTests.java @@ -1,11 +1,11 @@ -package org.alfresco.rest.workflow.processes.variables; +package org.alfresco.service.search.rest.workflow.processes.variables; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.rest.model.RestProcessVariableModel; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.ProcessModel; import org.alfresco.utility.model.SiteModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/DeleteProcessVariableSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/DeleteProcessVariableSanityTests.java similarity index 96% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/DeleteProcessVariableSanityTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/DeleteProcessVariableSanityTests.java index cb43c40c8..d46a55890 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/DeleteProcessVariableSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/DeleteProcessVariableSanityTests.java @@ -1,8 +1,8 @@ -package org.alfresco.rest.workflow.processes.variables; +package org.alfresco.service.search.rest.workflow.processes.variables; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.rest.model.RestProcessVariableModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/GetProcessVariablesCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/GetProcessVariablesCoreTests.java similarity index 97% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/GetProcessVariablesCoreTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/GetProcessVariablesCoreTests.java index 0b8c721b6..77abbdbf0 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/GetProcessVariablesCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/GetProcessVariablesCoreTests.java @@ -1,8 +1,8 @@ -package org.alfresco.rest.workflow.processes.variables; +package org.alfresco.service.search.rest.workflow.processes.variables; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.rest.model.RestProcessModelsCollection; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/GetProcessVariablesFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/GetProcessVariablesFullTests.java similarity index 98% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/GetProcessVariablesFullTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/GetProcessVariablesFullTests.java index e7c841cd3..c87d9d1f6 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/GetProcessVariablesFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/GetProcessVariablesFullTests.java @@ -1,10 +1,10 @@ -package org.alfresco.rest.workflow.processes.variables; +package org.alfresco.service.search.rest.workflow.processes.variables; import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.rest.model.RestProcessVariableCollection; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/GetProcessVariablesSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/GetProcessVariablesSanityTests.java similarity index 96% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/GetProcessVariablesSanityTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/GetProcessVariablesSanityTests.java index 9cb56b95f..77d769435 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/GetProcessVariablesSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/GetProcessVariablesSanityTests.java @@ -1,7 +1,7 @@ -package org.alfresco.rest.workflow.processes.variables; +package org.alfresco.service.search.rest.workflow.processes.variables; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.rest.model.RestProcessVariableCollection; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/UpdateProcessVariableTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/UpdateProcessVariableTests.java similarity index 98% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/UpdateProcessVariableTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/UpdateProcessVariableTests.java index 140966bce..9dcec0c4b 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/processes/variables/UpdateProcessVariableTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/UpdateProcessVariableTests.java @@ -1,10 +1,10 @@ -package org.alfresco.rest.workflow.processes.variables; +package org.alfresco.service.search.rest.workflow.processes.variables; import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.rest.model.RestProcessVariableModel; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/GetTaskFormModelTests.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/GetTaskFormModelTests.java index dec930fdb..559fc29b9 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/GetTaskFormModelTests.java @@ -1,7 +1,7 @@ -package org.alfresco.rest.workflow.tasks; +package org.alfresco.service.search.rest.workflow.tasks; import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.*; import org.alfresco.utility.model.*; import org.alfresco.utility.report.Bug; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/GetTaskTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/GetTaskTests.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/GetTaskTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/GetTaskTests.java index 1aec76b5d..a09d69c39 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/GetTaskTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/GetTaskTests.java @@ -1,7 +1,7 @@ -package org.alfresco.rest.workflow.tasks; +package org.alfresco.service.search.rest.workflow.tasks; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestTaskModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/GetTasksTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/GetTasksTests.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/GetTasksTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/GetTasksTests.java index eb28d7c31..7f84dcbdf 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/GetTasksTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/GetTasksTests.java @@ -1,8 +1,8 @@ -package org.alfresco.rest.workflow.tasks; +package org.alfresco.service.search.rest.workflow.tasks; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestTaskModel; import org.alfresco.rest.model.RestTaskModelsCollection; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/UpdateTaskTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/UpdateTaskTests.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/UpdateTaskTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/UpdateTaskTests.java index 6f069d2ff..304f57b03 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/UpdateTaskTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/UpdateTaskTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks; +package org.alfresco.service.search.rest.workflow.tasks; import java.util.HashMap; @@ -6,7 +6,7 @@ import javax.json.JsonObject; import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.core.JsonBodyGenerator; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/candidates/GetTaskCandidatesRegressionTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/candidates/GetTaskCandidatesRegressionTests.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/candidates/GetTaskCandidatesRegressionTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/candidates/GetTaskCandidatesRegressionTests.java index 5e8d3d09f..c3c9cc5fc 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/candidates/GetTaskCandidatesRegressionTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/candidates/GetTaskCandidatesRegressionTests.java @@ -1,7 +1,7 @@ -package org.alfresco.rest.workflow.tasks.candidates; +package org.alfresco.service.search.rest.workflow.tasks.candidates; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestCandidateModelsCollection; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.model.FileModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/candidates/GetTaskCandidatesSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/candidates/GetTaskCandidatesSanityTests.java similarity index 97% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/candidates/GetTaskCandidatesSanityTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/candidates/GetTaskCandidatesSanityTests.java index b9fd88f1a..cbd17f10f 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/candidates/GetTaskCandidatesSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/candidates/GetTaskCandidatesSanityTests.java @@ -1,7 +1,7 @@ -package org.alfresco.rest.workflow.tasks.candidates; +package org.alfresco.service.search.rest.workflow.tasks.candidates; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestCandidateModelsCollection; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.GroupModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemTestsBulk1.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/AddTaskItemTestsBulk1.java similarity index 98% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemTestsBulk1.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/AddTaskItemTestsBulk1.java index e0bb0e483..84856161f 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemTestsBulk1.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/AddTaskItemTestsBulk1.java @@ -1,7 +1,7 @@ -package org.alfresco.rest.workflow.tasks.items; +package org.alfresco.service.search.rest.workflow.tasks.items; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestItemModel; import org.alfresco.rest.model.RestItemModelsCollection; import org.alfresco.utility.model.FileModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemTestsBulk2.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/AddTaskItemTestsBulk2.java similarity index 98% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemTestsBulk2.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/AddTaskItemTestsBulk2.java index b54d54193..54ccf0cdc 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemTestsBulk2.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/AddTaskItemTestsBulk2.java @@ -1,7 +1,7 @@ -package org.alfresco.rest.workflow.tasks.items; +package org.alfresco.service.search.rest.workflow.tasks.items; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestVariableModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemTestsBulk3.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/AddTaskItemTestsBulk3.java similarity index 98% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemTestsBulk3.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/AddTaskItemTestsBulk3.java index fd6a130c5..10bb83f4c 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemTestsBulk3.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/AddTaskItemTestsBulk3.java @@ -1,7 +1,7 @@ -package org.alfresco.rest.workflow.tasks.items; +package org.alfresco.service.search.rest.workflow.tasks.items; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestItemModel; import org.alfresco.rest.model.RestItemModelsCollection; import org.alfresco.utility.model.FileModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/items/GetTaskItemsRegressionTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/GetTaskItemsRegressionTests.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/items/GetTaskItemsRegressionTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/GetTaskItemsRegressionTests.java index e8841828f..d1e3bd9ab 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/items/GetTaskItemsRegressionTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/GetTaskItemsRegressionTests.java @@ -1,8 +1,8 @@ -package org.alfresco.rest.workflow.tasks.items; +package org.alfresco.service.search.rest.workflow.tasks.items; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestItemModel; import org.alfresco.rest.model.RestItemModelsCollection; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/items/GetTaskItemsSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/GetTaskItemsSanityTests.java similarity index 96% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/items/GetTaskItemsSanityTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/GetTaskItemsSanityTests.java index 594ea0449..42421e2dd 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/items/GetTaskItemsSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/GetTaskItemsSanityTests.java @@ -1,7 +1,7 @@ -package org.alfresco.rest.workflow.tasks.items; +package org.alfresco.service.search.rest.workflow.tasks.items; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestItemModel; import org.alfresco.rest.model.RestItemModelsCollection; import org.alfresco.utility.Utility; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/items/RemoveTaskItemTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/RemoveTaskItemTests.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/items/RemoveTaskItemTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/RemoveTaskItemTests.java index 7eeb25407..6aa66a19f 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/items/RemoveTaskItemTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/RemoveTaskItemTests.java @@ -1,7 +1,7 @@ -package org.alfresco.rest.workflow.tasks.items; +package org.alfresco.service.search.rest.workflow.tasks.items; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestItemModel; import org.alfresco.utility.model.*; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk1.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk1.java similarity index 98% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk1.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk1.java index 03dac2155..370df5668 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk1.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk1.java @@ -1,7 +1,7 @@ -package org.alfresco.rest.workflow.tasks.variables; +package org.alfresco.service.search.rest.workflow.tasks.variables; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestVariableModel; import org.alfresco.rest.model.RestVariableModelsCollection; import org.alfresco.utility.model.FileModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk2.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk2.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk2.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk2.java index fd2704692..bee35a55b 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk2.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk2.java @@ -1,7 +1,7 @@ -package org.alfresco.rest.workflow.tasks.variables; +package org.alfresco.service.search.rest.workflow.tasks.variables; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestVariableModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk3.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk3.java similarity index 98% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk3.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk3.java index e81e3f0b5..c819511b9 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk3.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk3.java @@ -1,7 +1,7 @@ -package org.alfresco.rest.workflow.tasks.variables; +package org.alfresco.service.search.rest.workflow.tasks.variables; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestVariableModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/variables/DeleteTaskVariableTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/DeleteTaskVariableTests.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/variables/DeleteTaskVariableTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/DeleteTaskVariableTests.java index 4a046ce6d..8a41452c1 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/variables/DeleteTaskVariableTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/DeleteTaskVariableTests.java @@ -1,7 +1,7 @@ -package org.alfresco.rest.workflow.tasks.variables; +package org.alfresco.service.search.rest.workflow.tasks.variables; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestVariableModel; import org.alfresco.utility.model.FileModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/variables/GetTaskVariablesTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/GetTaskVariablesTests.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/variables/GetTaskVariablesTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/GetTaskVariablesTests.java index 90a07ba9d..e0113fc4e 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/variables/GetTaskVariablesTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/GetTaskVariablesTests.java @@ -1,7 +1,7 @@ -package org.alfresco.rest.workflow.tasks.variables; +package org.alfresco.service.search.rest.workflow.tasks.variables; import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.rest.model.RestTaskModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk1.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk1.java similarity index 96% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk1.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk1.java index c3718b38f..4e2bed673 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk1.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk1.java @@ -1,7 +1,7 @@ -package org.alfresco.rest.workflow.tasks.variables; +package org.alfresco.service.search.rest.workflow.tasks.variables; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestVariableModel; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk2.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk2.java similarity index 98% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk2.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk2.java index 53fe2f6a2..13b2ea472 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk2.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk2.java @@ -1,7 +1,7 @@ -package org.alfresco.rest.workflow.tasks.variables; +package org.alfresco.service.search.rest.workflow.tasks.variables; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestVariableModel; import org.alfresco.utility.model.FileModel; diff --git a/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk3.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk3.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk3.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk3.java index 156be6a2e..30823d3a2 100644 --- a/e2e-test/src/test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk3.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk3.java @@ -1,7 +1,7 @@ -package org.alfresco.rest.workflow.tasks.variables; +package org.alfresco.service.search.rest.workflow.tasks.variables; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestVariableModel; diff --git a/e2e-test/src/test/resources/SearchSuite.xml b/e2e-test/src/test/resources/SearchSuite.xml index e96fb4598..a455134d5 100644 --- a/e2e-test/src/test/resources/SearchSuite.xml +++ b/e2e-test/src/test/resources/SearchSuite.xml @@ -3,55 +3,51 @@ - - + + - - - - - + + + + + - - - - - - + + + + + + - + - + - - - + + + - - - - From ef0d54492ba5d9cffc8a429cc1f19328bde0fadc Mon Sep 17 00:00:00 2001 From: agazzarini Date: Fri, 29 Mar 2019 15:57:17 +0100 Subject: [PATCH 1478/1491] [ SEARCH-1485 ] removed classes without history --- .../search/rest/FunctionalCasesTests.java | 701 ------- .../service/search/rest/NetworkDataPrep.java | 45 - .../service/search/rest/RestTest.java | 85 - .../search/rest/actions/ActionsTests.java | 151 -- .../service/search/rest/aos/AosApiTest.java | 24 - .../service/search/rest/audit/AuditTest.java | 112 -- .../search/rest/audit/DeleteAuditTests.java | 66 - .../search/rest/audit/GetAuditTests.java | 357 ---- .../search/rest/audit/PutAuditTests.java | 111 -- .../service/search/rest/auth/AuthTests.java | 87 - .../search/rest/cmis/CmisBrowserTest.java | 25 - .../search/rest/comments/AddCommentTests.java | 260 --- .../rest/comments/AddCommentsTests.java | 377 ---- .../rest/comments/DeleteCommentTests.java | 295 --- .../rest/comments/GetCommentsTests.java | 422 ----- .../rest/comments/UpdateCommentTests.java | 461 ----- .../search/rest/demo/RestDemoTests.java | 104 -- .../search/rest/demo/SampleCommentsTests.java | 56 - .../search/rest/demo/SamplePeopleTests.java | 32 - .../search/rest/demo/SampleSitesTests.java | 79 - .../rest/demo/workshop/RestApiDemoTests.java | 52 - .../demo/workshop/RestApiWorkshopTests.java | 38 - .../search/rest/discovery/DiscoveryTests.java | 108 -- .../search/rest/downloads/DownloadsTests.java | 106 -- .../rest/favorites/AddFavoriteSiteTests.java | 487 ----- .../rest/favorites/AddFavoritesTests.java | 446 ----- .../favorites/DeleteFavoriteSiteTests.java | 364 ---- .../rest/favorites/DeleteFavoriteTests.java | 412 ----- .../favorites/FavoritesIncludePathTests.java | 143 -- .../rest/favorites/FavoritesNetworkTests.java | 292 --- .../rest/favorites/GetFavoriteSiteTests.java | 292 --- .../rest/favorites/GetFavoriteSitesTests.java | 325 ---- .../rest/favorites/GetFavoriteTests.java | 480 ----- .../rest/favorites/GetFavoritesTests.java | 555 ------ .../search/rest/groups/GroupsTests.java | 158 -- .../RestGetNetworkForPersonTests.java | 151 -- .../rest/networks/RestGetNetworkTests.java | 145 -- .../RestGetNetworksForPersonTests.java | 166 -- .../nodes/NodesActionDefinitionTests.java | 87 - .../nodes/NodesContentAndVersioningTests.java | 308 ---- .../search/rest/nodes/NodesLockTests.java | 761 -------- .../rest/nodes/NodesParentChildrenTests.java | 205 --- .../rest/nodes/NodesTargetSourcesTests.java | 120 -- .../service/search/rest/nodes/NodesTests.java | 56 - .../search/rest/nodes/NodesUnlockTests.java | 112 -- .../rest/people/AvatarPeopleSanityTest.java | 66 - .../people/DeleteSiteMemberCoreTests.java | 229 --- .../people/DeleteSiteMemberFullTests.java | 207 --- .../people/DeleteSiteMemberSanityTests.java | 111 -- .../rest/people/GetPeopleCoreTests.java | 57 - .../rest/people/GetPeopleFullTests.java | 88 - .../rest/people/GetPeopleSanityTests.java | 110 -- .../people/GetSiteMembershipCoreTests.java | 114 -- .../people/GetSiteMembershipFullTests.java | 138 -- .../people/GetSiteMembershipSanityTests.java | 90 - ...etSitesMembershipInformationCoreTests.java | 136 -- ...etSitesMembershipInformationFullTests.java | 205 --- ...SitesMembershipInformationSanityTests.java | 89 - .../GetPeopleActivitiesCoreTests.java | 126 -- .../GetPeopleActivitiesFullTests.java | 184 -- .../GetPeopleActivitiesSanityTests.java | 111 -- .../GetPeoplePreferenceCoreTests.java | 78 - .../GetPeoplePreferenceFullTests.java | 194 -- .../GetPeoplePreferenceSanityTests.java | 120 -- .../GetPeoplePreferencesCoreTests.java | 123 -- .../GetPeoplePreferencesFullTests.java | 114 -- .../GetPeoplePreferencesSanityTests.java | 121 -- .../search/rest/queries/QueriesTest.java | 178 -- .../search/rest/ratings/AddRatingTests.java | 818 -------- .../rest/ratings/DeleteRatingTests.java | 525 ------ .../search/rest/ratings/GetRatingTests.java | 438 ----- .../search/rest/ratings/GetRatingsTests.java | 313 ---- .../rest/renditions/CreateRenditionTests.java | 101 - .../rest/renditions/GetRenditionTests.java | 157 -- .../renditions/RenditionIntegrationTests.java | 81 - .../rest/search/AbstractSearchTest.java | 272 --- .../rest/search/FacetFieldsSearchTest.java | 257 --- .../rest/search/FacetIntervalSearchTest.java | 196 -- .../rest/search/FacetRangeSearchTest.java | 346 ---- .../rest/search/PivotFacetedSearchTest.java | 281 --- .../rest/search/SearchHighLightTest.java | 80 - .../rest/search/SearchSpellCheckTest.java | 177 -- .../search/rest/search/StatsSearchTest.java | 332 ---- .../sql/SearchSQLWithQuotedIdentifiers.java | 218 --- .../sharedLinks/GetSharedLinksFullTests.java | 75 - .../sharedLinks/SharedLinksSanityTests.java | 276 --- .../search/rest/sites/GetSiteTests.java | 362 ---- .../search/rest/sites/GetSitesTests.java | 484 ----- .../search/rest/sites/SitesNetworkTests.java | 85 - .../service/search/rest/sites/SitesTests.java | 36 - .../containers/GetSiteContainerTests.java | 304 --- .../containers/GetSiteContainersTests.java | 381 ---- .../sites/members/AddSiteMemberTests.java | 589 ------ .../sites/members/GetSiteMemberTests.java | 396 ---- .../sites/members/GetSiteMembersTests.java | 355 ---- .../sites/members/RemoveSiteMemberTests.java | 467 ----- .../sites/members/UpdateSiteMemberTests.java | 546 ------ .../AddSiteMembershipRequestTests.java | 409 ---- .../DeleteSiteMembershipRequestTests.java | 317 ---- .../GetSiteMembershipRequestTests.java | 332 ---- .../GetSiteMembershipRequestsTests.java | 421 ----- .../UpdateSiteMembershipRequestTests.java | 610 ------ .../rest/syncService/SyncServiceAPITests.java | 204 -- .../search/rest/tags/TagsDataPrep.java | 70 - .../rest/trashcan/GetDeletedNodesTests.java | 245 --- .../WorkflowNetworkDeploymentsTests.java | 124 -- ...orkflowNetworkProcessDefinitionsTests.java | 221 --- .../WorkflowNetworkProcessesTests.java | 540 ------ .../workflow/WorkflowNetworkTasksTests.java | 578 ------ .../deployments/DeleteDeploymentTests.java | 144 -- .../deployments/GetDeploymentCoreTests.java | 42 - .../deployments/GetDeploymentFullTests.java | 57 - .../deployments/GetDeploymentSanityTests.java | 57 - .../deployments/GetDeploymentsCoreTests.java | 30 - .../deployments/GetDeploymentsFullTests.java | 146 -- .../GetDeploymentsSanityTests.java | 44 - .../GetProcessDefinitionCoreTests.java | 45 - .../GetProcessDefinitionFullTests.java | 67 - .../GetProcessDefinitionImageCoreTests.java | 46 - .../GetProcessDefinitionImageFullTests.java | 42 - .../GetProcessDefinitionImageSanityTests.java | 49 - .../GetProcessDefinitionSanityTests.java | 62 - ...cessDefinitionStartFormModelCoreTests.java | 80 - ...cessDefinitionStartFormModelFullTests.java | 71 - ...ssDefinitionStartFormModelSanityTests.java | 38 - .../GetProcessDefinitionsCoreTests.java | 53 - .../GetProcessDefinitionsFullTests.java | 174 -- .../GetProcessDefinitionsSanityTests.java | 48 - .../processes/AddProcessCoreTests.java | 128 -- .../processes/AddProcessFullTests.java | 150 -- .../processes/AddProcessSanityTests.java | 44 - .../processes/DeleteProcessCoreTests.java | 69 - .../processes/DeleteProcessFullTests.java | 52 - .../processes/DeleteProcessSanityTests.java | 69 - .../processes/GetProcessCoreTests.java | 44 - .../processes/GetProcessFullTests.java | 85 - .../processes/GetProcessSanityTests.java | 62 - .../processes/GetProcessesCoreTests.java | 80 - .../processes/GetProcessesFullTests.java | 160 -- .../processes/GetProcessesSanityTests.java | 78 - .../items/AddProcessItemCoreTests.java | 181 -- .../items/AddProcessItemFullTests.java | 131 -- .../items/AddProcessItemSanityTests.java | 175 -- .../items/DeleteProcessItemCoreTests.java | 85 - .../items/DeleteProcessItemFullTests.java | 215 --- .../items/DeleteProcessItemSanityTests.java | 67 - .../items/GetProcessItemsCoreTests.java | 70 - .../items/GetProcessItemsFullTests.java | 198 -- .../items/GetProcessItemsSanityTests.java | 59 - .../tasks/GetProcessTasksCoreTests.java | 98 - .../tasks/GetProcessTasksFullTests.java | 207 --- .../tasks/GetProcessTasksSanityTests.java | 86 - .../AddProcessVariableCoreTests.java | 188 -- .../AddProcessVariableFullTests.java | 182 -- .../AddProcessVariableSanityTests.java | 95 - .../AddProcessVariablesCoreTests.java | 101 - .../AddProcessVariablesFullTests.java | 395 ---- .../AddProcessVariablesSanityTests.java | 158 -- .../DeleteProcessVariableCoreTests.java | 118 -- .../DeleteProcessVariableFullTests.java | 196 -- .../DeleteProcessVariableSanityTests.java | 69 - .../GetProcessVariablesCoreTests.java | 88 - .../GetProcessVariablesFullTests.java | 161 -- .../GetProcessVariablesSanityTests.java | 60 - .../variables/UpdateProcessVariableTests.java | 139 -- .../workflow/tasks/GetTaskFormModelTests.java | 256 --- .../rest/workflow/tasks/GetTaskTests.java | 212 --- .../rest/workflow/tasks/GetTasksTests.java | 234 --- .../rest/workflow/tasks/UpdateTaskTests.java | 1639 ----------------- .../GetTaskCandidatesRegressionTests.java | 268 --- .../GetTaskCandidatesSanityTests.java | 79 - .../tasks/items/AddTaskItemTestsBulk1.java | 158 -- .../tasks/items/AddTaskItemTestsBulk2.java | 175 -- .../tasks/items/AddTaskItemTestsBulk3.java | 128 -- .../items/GetTaskItemsRegressionTests.java | 260 --- .../tasks/items/GetTaskItemsSanityTests.java | 75 - .../tasks/items/RemoveTaskItemTests.java | 256 --- .../variables/AddTaskVariablesTestsBulk1.java | 198 -- .../variables/AddTaskVariablesTestsBulk2.java | 241 --- .../variables/AddTaskVariablesTestsBulk3.java | 155 -- .../variables/DeleteTaskVariableTests.java | 231 --- .../variables/GetTaskVariablesTests.java | 252 --- .../UpdateTaskVariableTestsBulk1.java | 79 - .../UpdateTaskVariableTestsBulk2.java | 173 -- .../UpdateTaskVariableTestsBulk3.java | 247 --- 185 files changed, 37381 deletions(-) delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/FunctionalCasesTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/NetworkDataPrep.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/RestTest.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/actions/ActionsTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/aos/AosApiTest.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/audit/AuditTest.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/audit/DeleteAuditTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/audit/GetAuditTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/audit/PutAuditTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/auth/AuthTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/cmis/CmisBrowserTest.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/comments/AddCommentTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/comments/AddCommentsTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/comments/DeleteCommentTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/comments/GetCommentsTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/comments/UpdateCommentTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/demo/RestDemoTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/demo/SampleCommentsTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/demo/SamplePeopleTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/demo/SampleSitesTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/demo/workshop/RestApiDemoTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/demo/workshop/RestApiWorkshopTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/discovery/DiscoveryTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/downloads/DownloadsTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/AddFavoriteSiteTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/AddFavoritesTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/DeleteFavoriteSiteTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/DeleteFavoriteTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/FavoritesIncludePathTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/FavoritesNetworkTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/GetFavoriteSiteTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/GetFavoriteSitesTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/GetFavoriteTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/GetFavoritesTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/groups/GroupsTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/networks/RestGetNetworkForPersonTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/networks/RestGetNetworkTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/networks/RestGetNetworksForPersonTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesActionDefinitionTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesContentAndVersioningTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesLockTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesParentChildrenTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesTargetSourcesTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesUnlockTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/people/AvatarPeopleSanityTest.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/people/DeleteSiteMemberCoreTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/people/DeleteSiteMemberFullTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/people/DeleteSiteMemberSanityTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetPeopleCoreTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetPeopleFullTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetPeopleSanityTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSiteMembershipCoreTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSiteMembershipFullTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSiteMembershipSanityTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSitesMembershipInformationCoreTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSitesMembershipInformationFullTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSitesMembershipInformationSanityTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/people/activities/GetPeopleActivitiesCoreTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/people/activities/GetPeopleActivitiesFullTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/people/activities/GetPeopleActivitiesSanityTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferenceCoreTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferenceFullTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferenceSanityTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferencesCoreTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferencesFullTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferencesSanityTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/queries/QueriesTest.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/ratings/AddRatingTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/ratings/DeleteRatingTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/ratings/GetRatingTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/ratings/GetRatingsTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/renditions/CreateRenditionTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/renditions/GetRenditionTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/renditions/RenditionIntegrationTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/search/AbstractSearchTest.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/search/FacetFieldsSearchTest.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/search/FacetIntervalSearchTest.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/search/FacetRangeSearchTest.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/search/PivotFacetedSearchTest.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/search/SearchHighLightTest.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/search/SearchSpellCheckTest.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/search/StatsSearchTest.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/search/sql/SearchSQLWithQuotedIdentifiers.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/sharedLinks/GetSharedLinksFullTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/sharedLinks/SharedLinksSanityTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/sites/GetSiteTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/sites/GetSitesTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/sites/SitesNetworkTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/sites/SitesTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/sites/containers/GetSiteContainerTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/sites/containers/GetSiteContainersTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/AddSiteMemberTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/GetSiteMemberTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/GetSiteMembersTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/RemoveSiteMemberTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/UpdateSiteMemberTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/AddSiteMembershipRequestTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/DeleteSiteMembershipRequestTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/GetSiteMembershipRequestTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/GetSiteMembershipRequestsTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/UpdateSiteMembershipRequestTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/syncService/SyncServiceAPITests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/tags/TagsDataPrep.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/trashcan/GetDeletedNodesTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/WorkflowNetworkDeploymentsTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/WorkflowNetworkProcessDefinitionsTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/WorkflowNetworkProcessesTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/WorkflowNetworkTasksTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/DeleteDeploymentTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentCoreTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentFullTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentSanityTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentsCoreTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentsFullTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentsSanityTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionCoreTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionFullTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionImageCoreTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionImageFullTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelFullTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionsCoreTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionsFullTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/AddProcessCoreTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/AddProcessFullTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/AddProcessSanityTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/DeleteProcessCoreTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/DeleteProcessFullTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/DeleteProcessSanityTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessCoreTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessFullTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessSanityTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessesCoreTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessesFullTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessesSanityTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/AddProcessItemCoreTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/AddProcessItemFullTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/AddProcessItemSanityTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/DeleteProcessItemCoreTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/DeleteProcessItemFullTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/DeleteProcessItemSanityTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/GetProcessItemsCoreTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/GetProcessItemsFullTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/GetProcessItemsSanityTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/tasks/GetProcessTasksCoreTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/tasks/GetProcessTasksFullTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/tasks/GetProcessTasksSanityTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariableCoreTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariableFullTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariableSanityTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariablesCoreTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariablesFullTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariablesSanityTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/DeleteProcessVariableCoreTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/DeleteProcessVariableFullTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/DeleteProcessVariableSanityTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/GetProcessVariablesCoreTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/GetProcessVariablesFullTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/GetProcessVariablesSanityTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/UpdateProcessVariableTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/GetTaskFormModelTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/GetTaskTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/GetTasksTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/UpdateTaskTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/candidates/GetTaskCandidatesRegressionTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/candidates/GetTaskCandidatesSanityTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/AddTaskItemTestsBulk1.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/AddTaskItemTestsBulk2.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/AddTaskItemTestsBulk3.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/GetTaskItemsRegressionTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/GetTaskItemsSanityTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/RemoveTaskItemTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk1.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk2.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk3.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/DeleteTaskVariableTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/GetTaskVariablesTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk1.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk2.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk3.java diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/FunctionalCasesTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/FunctionalCasesTests.java deleted file mode 100644 index 2608e18db..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/FunctionalCasesTests.java +++ /dev/null @@ -1,701 +0,0 @@ -package org.alfresco.service.search.rest; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.dataprep.SiteService.Visibility; -import org.alfresco.rest.model.RestActivityModelsCollection; -import org.alfresco.rest.model.RestCommentModel; -import org.alfresco.rest.model.RestCommentModelsCollection; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestFavoriteSiteModel; -import org.alfresco.rest.model.RestPersonFavoritesModelsCollection; -import org.alfresco.rest.model.RestRatingModel; -import org.alfresco.rest.model.RestSiteMemberModel; -import org.alfresco.rest.model.RestSiteMembershipRequestModelsCollection; -import org.alfresco.rest.model.RestTagModel; -import org.alfresco.rest.model.RestTaskModel; -import org.alfresco.utility.constants.ActivityType; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class FunctionalCasesTests extends RestTest -{ - private UserModel adminUser, manager; - private SiteModel publicSite, moderatedSite, privateSite; - private RestSiteMemberModel updatedMember; - private RestSiteMembershipRequestModelsCollection returnedCollection; - private RestFavoriteSiteModel restFavoriteSiteModel; - private RestActivityModelsCollection activities; - private FileModel file; - private RestActivityModelsCollection restActivityModelsCollection; - - private FileModel fileInSite; - private RestCommentModel commentModel; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - manager = dataUser.createRandomTestUser(); - publicSite = dataSite.usingUser(adminUser).createPublicRandomSite(); - dataUser.addUserToSite(manager, publicSite, UserRole.SiteManager); - moderatedSite = dataSite.usingUser(adminUser).createModeratedRandomSite(); - privateSite = dataSite.usingUser(adminUser).createPrivateRandomSite(); - } - - /** - * Scenario: - * 1. Add a site member as Manager - * 2. Update it's role to Collaborator - * 3. Update it's role to Contributor - * 4. Update it's role to Consumer - */ - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that manager is able to update manager with different roles and gets status code CREATED (201)") - public void managerIsAbleToUpdateManagerWithDifferentRoles() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteManager); - restClient.authenticateUser(adminUser).withCoreAPI().usingSite(publicSite).addPerson(testUser) - .assertThat().field("id").is(testUser.getUsername()) - .and().field("role").is(testUser.getUserRole()); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - testUser.setUserRole(UserRole.SiteCollaborator); - updatedMember = restClient.withCoreAPI() - .usingSite(publicSite).updateSiteMember(testUser); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedMember.assertThat().field("id").is(testUser.getUsername()).and().field("role").is(testUser.getUserRole()); - - testUser.setUserRole(UserRole.SiteContributor); - updatedMember = restClient.withCoreAPI() - .usingSite(publicSite).updateSiteMember(testUser); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedMember.assertThat().field("id").is(testUser.getUsername()).and().field("role").is(testUser.getUserRole()); - - testUser.setUserRole(UserRole.SiteConsumer); - updatedMember = restClient.withCoreAPI() - .usingSite(publicSite).updateSiteMember(testUser); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedMember.assertThat().field("id").is(testUser.getUsername()).and().field("role").is(testUser.getUserRole()); - } - - /** - * Scenario: - * 1. Add a site member as Consumer - * 2. Update it's role to Contributor - * 3. Update it's role to Collaborator - * 4. Update it's role to Manager - */ - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that manager is able to update consumer with different roles and gets status code CREATED (201)") - public void managerIsAbleToUpdateConsumerWithDifferentRoles() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteConsumer); - restClient.authenticateUser(adminUser).withCoreAPI().usingSite(publicSite).addPerson(testUser) - .assertThat().field("id").is(testUser.getUsername()) - .and().field("role").is(testUser.getUserRole()); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - testUser.setUserRole(UserRole.SiteContributor); - updatedMember = restClient.withCoreAPI() - .usingSite(publicSite).updateSiteMember(testUser); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedMember.assertThat().field("id").is(testUser.getUsername()).and().field("role").is(testUser.getUserRole()); - - testUser.setUserRole(UserRole.SiteCollaborator); - updatedMember = restClient.withCoreAPI() - .usingSite(publicSite).updateSiteMember(testUser); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedMember.assertThat().field("id").is(testUser.getUsername()).and().field("role").is(testUser.getUserRole()); - - testUser.setUserRole(UserRole.SiteManager); - updatedMember = restClient.withCoreAPI() - .usingSite(publicSite).updateSiteMember(testUser); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedMember.assertThat().field("id").is(testUser.getUsername()).and().field("role").is(testUser.getUserRole()); - } - - /** - * Scenario: - * 1. Create site membership request - * 2. Approve site membership request - * 3. Add site to Favorites - * 4. Delete site from Favorites - */ - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, description = "Approve request, add site to favorites, then delete it from favorites") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void approveRequestAddAndDeleteSiteFromFavorites() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - - restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestTaskModel taskModel = restClient.authenticateUser(newMember).withWorkflowAPI().getTasks().getTaskModelByDescription(moderatedSite); - workflow.approveSiteMembershipRequest(adminUser.getUsername(), adminUser.getPassword(), taskModel.getId(), true, "Approve"); - returnedCollection = restClient.authenticateUser(newMember).withCoreAPI().usingMe().getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat().entriesListDoesNotContain("id", moderatedSite.getId()); - - restFavoriteSiteModel = restClient.authenticateUser(newMember).withCoreAPI().usingUser(newMember).addFavoriteSite(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restFavoriteSiteModel.assertThat().field("id").is(moderatedSite.getId()); - - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().removeFavoriteSite(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - /** - * Scenario: - * 1. Create site membership request - * 2. Reject site membership request - * 3. Add moderated site to Favorites - * 4. Create site membership request again - * 5. Approve site membership request - * 6. Delete member from site - */ - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, description = "Reject request, add moderated site to favorites, create request again and approve it") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void rejectRequestAddModeratedSiteToFavorites() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - - restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestTaskModel taskModel = restClient.authenticateUser(newMember).withWorkflowAPI().getTasks().getTaskModelByDescription(moderatedSite); - workflow.approveSiteMembershipRequest(adminUser.getUsername(), adminUser.getPassword(), taskModel.getId(), false, "Rejected"); - returnedCollection = restClient.authenticateUser(newMember).withCoreAPI().usingMe().getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat().entriesListDoesNotContain("id", moderatedSite.getId()); - - restFavoriteSiteModel = restClient.authenticateUser(newMember).withCoreAPI().usingUser(newMember).addFavoriteSite(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restFavoriteSiteModel.assertThat().field("id").is(moderatedSite.getId()); - - restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - taskModel = restClient.authenticateUser(newMember).withWorkflowAPI().getTasks().getTaskModelByDescription(moderatedSite); - workflow.approveSiteMembershipRequest(adminUser.getUsername(), adminUser.getPassword(), taskModel.getId(), true, "Accept"); - - restClient.authenticateUser(adminUser).withCoreAPI().usingUser(newMember).deleteSiteMember(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingSite(moderatedSite).getSiteMembers().assertThat().entriesListDoesNotContain("id", newMember.getUsername()); - } - - /** - * Scenario: - * 1. Add file - * 2. Check file is included in person activities list - */ - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Add a file and check that activity is included in person activities") - public void addFileThenGetPersonActivities() throws Exception - { - file = dataContent.usingUser(manager).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); - activities = restClient.authenticateUser(manager).withCoreAPI().usingAuthUser().getPersonActivitiesUntilEntriesCountIs(2); - activities.assertThat().entriesListIsNotEmpty() - .and().entriesListContains("siteId", publicSite.getId()) - .and().entriesListContains("activityType", "org.alfresco.documentlibrary.file-added") - .and().entriesListContains("activitySummary.objectId", file.getNodeRefWithoutVersion()); - } - - /** - * Scenario: - * 1. Add a comment to a file - * 2. Check that comment is included in person activities list - */ - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Add a comment to a file and check that activity is included in person activities") - public void addCommentThenGetPersonActivities() throws Exception - { - file = dataContent.usingUser(manager).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(manager).withCoreAPI().usingResource(file).addComment("new comment"); - activities = restClient.authenticateUser(manager).withCoreAPI().usingAuthUser().getPersonActivitiesUntilEntriesCountIs(3); - activities.assertThat().entriesListIsNotEmpty() - .and().entriesListContains("siteId", publicSite.getId()) - .and().entriesListContains("activityType", "org.alfresco.comments.comment-created") - .and().entriesListContains("activitySummary.objectId", file.getNodeRefWithoutVersion()); - } - - /** - * Scenario: - * 1. Add file then delete it - * 2. Check action is included in person activities list - */ - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Add a file, delete it and check that activity is included in person activities") - public void addFileDeleteItThenGetPersonActivities() throws Exception - { - file = dataContent.usingUser(manager).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); - dataContent.usingUser(manager).usingResource(file).deleteContent(); - activities = restClient.authenticateUser(manager).withCoreAPI().usingAuthUser().getPersonActivitiesUntilEntriesCountIs(2); - activities.assertThat().entriesListIsNotEmpty() - .and().entriesListContains("siteId", publicSite.getId()) - .and().entriesListContains("activityType", "org.alfresco.documentlibrary.file-deleted") - .and().entriesListContains("activitySummary.objectId", file.getNodeRefWithoutVersion()); - } - - /** - * 1. Post one comment - * 2. Get comment details - * 3. Update comment - * 4. Get again comment details - * 5. Delete comment - */ - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, - executionType = ExecutionType.REGRESSION, - description = "Add comment to a file, then get comment details. Update it and check that get comment returns updated details. Delete comment then check that file has no comments.") - public void addUpdateDeleteCommentThenGetCommentDetails() throws Exception - { - file = dataContent.usingUser(manager).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); - RestCommentModel newComment = restClient.authenticateUser(manager).withCoreAPI().usingResource(file).addComment("new comment"); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestCommentModelsCollection fileComments = restClient.withCoreAPI().usingResource(file).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - fileComments.assertThat().entriesListContains("content", newComment.getContent()); - - RestCommentModel updatedComment = restClient.withCoreAPI().usingResource(file).updateComment(newComment, "updated comment"); - restClient.assertStatusCodeIs(HttpStatus.OK); - - fileComments = restClient.withCoreAPI().usingResource(file).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - fileComments.assertThat().entriesListContains("content", updatedComment.getContent()).assertThat().entriesListDoesNotContain("content", newComment.getContent()); - - restClient.withCoreAPI().usingResource(file).deleteComment(updatedComment); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - fileComments = restClient.withCoreAPI().usingResource(file).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - fileComments.assertThat().entriesListIsEmpty(); - } - - /** - * 1. Post one comment - * 2. Delete comment - * 3. Post the same comment again - */ - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, - executionType = ExecutionType.REGRESSION, - description = "Add a comment to a file, delete it, then added the same comment again.") - public void checkThatADeletedCommentCanBePostedAgain() throws Exception - { - file = dataContent.usingUser(manager).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); - RestCommentModel newComment = restClient.authenticateUser(manager).withCoreAPI().usingResource(file).addComment("new comment"); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestCommentModelsCollection fileComments = restClient.withCoreAPI().usingResource(file).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - fileComments.assertThat().entriesListContains("content", newComment.getContent()); - - restClient.withCoreAPI().usingResource(file).deleteComment(newComment); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - fileComments = restClient.withCoreAPI().usingResource(file).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - fileComments.assertThat().entriesListIsEmpty(); - - restClient.authenticateUser(manager).withCoreAPI().usingResource(file).addComment("new comment"); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - fileComments = restClient.withCoreAPI().usingResource(file).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - fileComments.assertThat().entriesListContains("content", newComment.getContent()); - } - - /** - * Scenario: - * 1. join an user to a site - * 2. Check action is included in person activities list - * - * @throws Exception - */ - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Create an user, join the user to a site and check that activity is included in person activities") - public void joinUserToSiteThenGetPersonActivities() throws Exception - { - UserModel userJoinSite = dataUser.createRandomTestUser(); - - restClient.authenticateUser(userJoinSite).withCoreAPI().usingMe().addSiteMembershipRequest(publicSite); - activities = restClient.withCoreAPI().usingAuthUser().getPersonActivitiesUntilEntriesCountIs(2); - activities.assertThat().entriesListIsNotEmpty().and() - .entriesListContains("siteId", publicSite.getId()).and() - .entriesListContains("activityType", "org.alfresco.site.user-joined").and() - .entriesListContains("activitySummary.memberPersonId", userJoinSite.getUsername()); - } - - /** - * Scenario: - * 1. Add user to private site - * 2. Remove user from private site - * 3. User creates membership request to the same private site - */ - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, description = "Verify membership request by user after it was removed from site gets status code 404") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void userCanNotCreateMembershipRequestIfItWasRemovedFromPrivateSite() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - newMember.setUserRole(UserRole.SiteCollaborator); - - restClient.authenticateUser(adminUser).withCoreAPI().usingSite(privateSite).addPerson(newMember) - .assertThat().field("id").is(newMember.getUsername()); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(adminUser).withCoreAPI().usingUser(newMember).deleteSiteMember(privateSite); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest(privateSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, newMember.getUsername(), privateSite.getTitle())); - } - - /** - * Scenario: - * 1. User creates membership request to moderated site - * 2. Accept membership request - * 3. Remove user from moderated site - * 4. Add user on moderated site - */ - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, description = "Verify user can be added back after if was removed from site") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void userCanBeAddedAfterItWasRemovedFromSite() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - newMember.setUserRole(UserRole.SiteCollaborator); - - restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestTaskModel taskModel = restClient.authenticateUser(newMember).withWorkflowAPI().getTasks().getTaskModelByDescription(moderatedSite); - workflow.approveSiteMembershipRequest(adminUser.getUsername(), adminUser.getPassword(), taskModel.getId(), true, "Accept"); - - restClient.authenticateUser(adminUser).withCoreAPI().usingUser(newMember).deleteSiteMember(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingSite(moderatedSite).getSiteMembers().assertThat().entriesListDoesNotContain("id", newMember.getUsername()); - - restClient.authenticateUser(adminUser).withCoreAPI().usingSite(moderatedSite).addPerson(newMember) - .assertThat().field("id").is(newMember.getUsername()); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.withCoreAPI().usingSite(moderatedSite).getSiteMembers().assertThat().entriesListContains("id", newMember.getUsername()); - } - - /** - * Scenario: - * 1. Create document in site - * 2. Add comment - * 3. Delete document - * 4. Get comments and check if the above comment was deleted - */ - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, - executionType = ExecutionType.REGRESSION, description = "Check that a comment of a document was also removed after deleting the document") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void checkTheCommentOfADocumentThatWasDeletedDoesNotExist() throws Exception - { - file = dataContent.usingSite(publicSite).usingUser(adminUser).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - String newContent = "This is a new comment added by " + adminUser.getUsername(); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(file).addComment(newContent) - .assertThat().field("content").isNotEmpty() - .and().field("content").is(newContent); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - dataContent.usingUser(adminUser).usingResource(file).deleteContent(); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(file).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary((String.format(RestErrorModel.ENTITY_WAS_NOT_FOUND, file.getNodeRefWithoutVersion()))); - } - - /** - * Scenario: - * 1. Add user to private site - * 2. Add comment to a document of private site - * 3. Remove user from site - * 4. Get comments and check if the above comment was deleted - */ - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, - executionType = ExecutionType.REGRESSION, description = "Check that a comment of a document from a private site is not deleted after user is removed") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void checkThatCommentIsNotDeletedWhenPrivateSiteMemberIsRemoved() throws Exception - { - UserModel newUser = dataUser.createRandomTestUser(); - newUser.setUserRole(UserRole.SiteManager); - restClient.authenticateUser(adminUser).withCoreAPI().usingSite(privateSite).addPerson(newUser); - - file = dataContent.usingSite(privateSite).usingUser(adminUser).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - String newContent = "This is a new comment added by " + newUser.getUsername(); - - restClient.authenticateUser(newUser).withCoreAPI().usingResource(file).addComment(newContent) - .assertThat().field("content").isNotEmpty() - .and().field("content").is(newContent); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(adminUser).withCoreAPI().usingSite(privateSite).deleteSiteMember(newUser); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingSite(privateSite).getSiteMembers().assertThat().entriesListDoesNotContain("id", newUser.getUsername()); - - RestCommentModelsCollection comments = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(file).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", newContent) - .and().entriesListContains("createdBy.id", newUser.getUsername()); - } - - /** - * Scenario: - * 1. Add one file to favorites then add a comment to this file - */ - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, - executionType = ExecutionType.REGRESSION, - description = "Add one file to favorites then add a comment to this file") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void commentAFavoriteFile() throws Exception - { - file = dataContent.usingSite(publicSite).usingUser(adminUser).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - restClient.authenticateUser(manager).withCoreAPI().usingMe().addFileToFavorites(file); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.withCoreAPI().usingAuthUser().getFavorites() - .assertThat().entriesListContains("targetGuid", file.getNodeRefWithoutVersion()); - - RestCommentModel comment = restClient.withCoreAPI().usingResource(file).addComment("new comment"); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - comment.assertThat().field("content").is("new comment"); - } - - /** - * Scenario: - * 1. Remove one file from favorites then add a comment to this file - */ - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, - executionType = ExecutionType.REGRESSION, - description = "Remove one file from favorites then add a comment to this file") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void commentFileRemovedFromFavorites() throws Exception - { - file = dataContent.usingSite(publicSite).usingUser(adminUser).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - restClient.authenticateUser(manager).withCoreAPI().usingMe().addFileToFavorites(file); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.withCoreAPI().usingMe().deleteFileFromFavorites(file); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingAuthUser().getFavorites() - .assertThat().entriesListDoesNotContain("targetGuid", file.getNodeRefWithoutVersion()); - - RestCommentModel comment = restClient.withCoreAPI().usingResource(file).addComment("new comment"); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - comment.assertThat().field("content").is("new comment"); - } - - /** - * Scenario: - * 1. Add public site to favorites - * 2. Change site visibility to moderated - * 3. Check favorites - * 4. Change site visibility to private - * 5. Check favorites - */ - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, - executionType = ExecutionType.REGRESSION, - description = "Check favorite sites after a favorite site visibility is changed") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void changeFavoriteSiteVisibilityThenCheckFavorites() throws Exception - { - SiteModel favoriteSite = dataSite.usingUser(manager).createPublicRandomSite(); - UserModel regularUser = dataUser.createRandomTestUser(); - - restClient.authenticateUser(regularUser).withCoreAPI().usingAuthUser().addSiteToFavorites(favoriteSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestPersonFavoritesModelsCollection userFavoriteSites = restClient.withCoreAPI().usingAuthUser().where().targetSiteExist().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - userFavoriteSites.assertThat().entriesListContains("targetGuid", favoriteSite.getGuid()) - .assertThat().entriesListContains("target.site.visibility", favoriteSite.getVisibility().name()) - .assertThat().entriesListContains("target.site.id", favoriteSite.getId()); - - dataSite.usingUser(manager).updateSiteVisibility(favoriteSite, Visibility.MODERATED); - - userFavoriteSites = restClient.authenticateUser(regularUser).withCoreAPI().usingAuthUser().where().targetSiteExist().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - userFavoriteSites.assertThat().entriesListContains("targetGuid", favoriteSite.getGuid()) - .assertThat().entriesListContains("target.site.visibility", "MODERATED") - .assertThat().entriesListContains("target.site.id", favoriteSite.getId()); - - dataSite.usingUser(manager).updateSiteVisibility(favoriteSite, Visibility.PRIVATE); - - userFavoriteSites = restClient.authenticateUser(regularUser).withCoreAPI().usingAuthUser().where().targetSiteExist().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - userFavoriteSites.assertThat().entriesListIsEmpty(); - - dataSite.usingUser(manager).updateSiteVisibility(favoriteSite, Visibility.PUBLIC); - - userFavoriteSites = restClient.authenticateUser(regularUser).withCoreAPI().usingAuthUser().where().targetSiteExist().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - userFavoriteSites.assertThat().entriesListContains("targetGuid", favoriteSite.getGuid()) - .assertThat().entriesListContains("target.site.visibility", favoriteSite.getVisibility().name()) - .assertThat().entriesListContains("target.site.id", favoriteSite.getId()); - } - - /** - * Scenario: - * 1. Regular user adds moderated site membership request - * 2. Site manager approves the request - * 3. Site manager updates the new member role to Manager - * 4. New member adds comment to a file on site - * 5. New member likes and rate one file - * 6. New member adds tags to a file - * 7. New member adds site to favorite - * 8. New member adds, then deletes a site member - */ - @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, - executionType = ExecutionType.REGRESSION, - description = "Check that a user who joins a moderated site as manager is able to comment, rate, tag an existing file from the site, add site to favorites, add and remove site members.") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - public void checkNewManagerActions() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - file = dataContent.usingSite(moderatedSite).usingUser(adminUser).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestTaskModel taskModel = restClient.withWorkflowAPI().getTasks().getTaskModelByDescription(moderatedSite); - workflow.approveSiteMembershipRequest(adminUser.getUsername(), adminUser.getPassword(), taskModel.getId(), true, "Approve"); - returnedCollection = restClient.withCoreAPI().usingMe().getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat().entriesListDoesNotContain("id", moderatedSite.getId()); - - newMember.setUserRole(UserRole.SiteManager); - restClient.authenticateUser(adminUser).withCoreAPI().usingSite(moderatedSite).updateSiteMember(newMember) - .assertThat().field("id").is(newMember.getUsername()) - .and().field("role").is(newMember.getUserRole()); - restClient.assertStatusCodeIs(HttpStatus.OK); - - RestCommentModel comment = restClient.authenticateUser(newMember).withCoreAPI().usingResource(file).addComment("new comment"); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - comment.assertThat().field("content").is("new comment"); - - RestRatingModel returnedRatingModel = restClient.withCoreAPI().usingResource(file).likeDocument(); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedRatingModel.assertThat().field("myRating").is("true") - .and().field("id").is("likes") - .and().field("aggregate").isNotEmpty(); - - returnedRatingModel = restClient.withCoreAPI().usingResource(file).rateStarsToDocument(5); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedRatingModel.assertThat().field("myRating").is("5") - .and().field("id").is("fiveStar") - .and().field("aggregate").isNotEmpty(); - - RestTagModel tag = restClient.withCoreAPI().usingResource(file).addTag("filetag"); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - tag.assertThat().field("tag").is("filetag") - .and().field("id").isNotEmpty(); - - restFavoriteSiteModel = restClient.withCoreAPI().usingAuthUser().addFavoriteSite(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restFavoriteSiteModel.assertThat().field("id").is(moderatedSite.getId()); - - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteManager); - restClient.withCoreAPI().usingSite(moderatedSite).addPerson(testUser) - .assertThat().field("id").is(testUser.getUsername()) - .and().field("role").is(testUser.getUserRole()); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.withCoreAPI().usingSite(moderatedSite).deleteSiteMember(testUser); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingSite(moderatedSite).getSiteMembers() - .assertThat().entriesListDoesNotContain("id", testUser.getUsername()); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - /** - * Scenario: - * 1. Add user to site - * 2. Create folder - * 3. Create document - * 4. Add comment to the document - * 5. Like document - * 6. Update Comment - * 7. Update user role - * 8. Delete like rating - * 9. Delete site member - * 10. Delete comment - * 11. Get Activities - * - * @throws Exception - */ - @Bug(id="REPO-1830") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its activities with Rest API and response is successful") - public void userGetsItsPeopleActivities() throws Exception - { - UserModel newUser = dataUser.createRandomTestUser(); - SiteModel userSiteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); - - dataUser.addUserToSite(newUser, userSiteModel, UserRole.SiteCollaborator); - dataContent.usingUser(newUser).usingSite(userSiteModel).createFolder(); - - fileInSite = dataContent.usingUser(newUser).usingSite(userSiteModel).createContent(DocumentType.TEXT_PLAIN); - String newContent = "This is a new comment added by " + newUser.getUsername(); - commentModel = restClient.authenticateUser(newUser).withCoreAPI().usingResource(fileInSite).addComment(newContent); - restClient.authenticateUser(newUser).withCoreAPI().usingResource(fileInSite).likeDocument(); - - restClient.withCoreAPI().usingResource(fileInSite).updateComment(commentModel, "new Content"); - newUser.setUserRole(UserRole.SiteManager); - restClient.authenticateUser(adminUser).withCoreAPI().usingSite(userSiteModel).updateSiteMember(newUser); - - restClient.authenticateUser(newUser).withCoreAPI().usingResource(fileInSite).deleteLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingResource(fileInSite).deleteComment(commentModel); - restClient.authenticateUser(adminUser).withCoreAPI().usingSite(userSiteModel).deleteSiteMember(newUser); - - restActivityModelsCollection = restClient.authenticateUser(newUser).withCoreAPI().usingMe().getPersonActivitiesUntilEntriesCountIs(10); - restClient.assertStatusCodeIs(HttpStatus.OK); - restActivityModelsCollection.assertThat().paginationField("count").is("10"); - - restActivityModelsCollection = restClient.authenticateUser(newUser).withCoreAPI().usingMe().getPersonActivities(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restActivityModelsCollection.assertThat().paginationField("count").is("10"); - - restActivityModelsCollection.assertThat().entriesListContains("activityType", ActivityType.USER_JOINED.toString()).assertThat() - .entriesListContains("activityType", ActivityType.FILE_ADDED.toString()).assertThat() - .entriesListContains("activityType", ActivityType.FOLDER_ADDED.toString()).assertThat() - .entriesListContains("activityType", ActivityType.COMMENT_CREATED.toString()).assertThat() - .entriesListContains("activityType", ActivityType.FILE_LIKED.toString()).assertThat() - .entriesListContains("activityType", ActivityType.COMMENT_UPDATED.toString()).assertThat() - .entriesListContains("activityType", ActivityType.USER_ROLE_CHANGED.toString()).assertThat() - .entriesListContains("activityType", ActivityType.COMMENT_DELETED.toString()).assertThat() - .entriesListContains("activityType", ActivityType.USER_LEFT.toString()); - } - -} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/NetworkDataPrep.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/NetworkDataPrep.java deleted file mode 100644 index f3903b106..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/NetworkDataPrep.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.alfresco.service.search.rest; - -import org.alfresco.rest.model.RestNetworkModel; -import org.alfresco.utility.model.UserModel; - -public abstract class NetworkDataPrep extends RestTest -{ - protected static UserModel adminUserModel; - protected static UserModel adminTenantUser, secondAdminTenantUser; - protected static UserModel tenantUser, secondTenantUser, differentNetworkTenantUser; - protected static UserModel tenantUserWithBad; - protected static UserModel userModel; - protected static RestNetworkModel restNetworkModel; - protected static String tenantDomain; - private static boolean isInitialized = false; - - public void init() throws Exception - { - if(!isInitialized) - { - isInitialized = true; - initialization(); - } - } - - public void initialization() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - //create first tenant Admin User. - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUserModel); - restClient.usingTenant().createTenant(adminTenantUser); - - tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - secondTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("sTenant"); - //create second tenant Admin User. - secondAdminTenantUser = UserModel.getAdminTenantUser(); - restClient.usingTenant().createTenant(secondAdminTenantUser); - - tenantDomain = tenantUser.getDomain(); - differentNetworkTenantUser = dataUser.usingUser(secondAdminTenantUser).createUserWithTenant("dTenant"); - - userModel = dataUser.createRandomTestUser(); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/RestTest.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/RestTest.java deleted file mode 100644 index 5f042d387..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/RestTest.java +++ /dev/null @@ -1,85 +0,0 @@ -package org.alfresco.service.search.rest; - -import java.lang.reflect.Method; - -import org.alfresco.dataprep.WorkflowService; -import org.alfresco.rest.core.RestProperties; -import org.alfresco.rest.core.RestWrapper; -import org.alfresco.utility.LogFactory; -import org.alfresco.utility.TasProperties; -import org.alfresco.utility.data.DataContent; -import org.alfresco.utility.data.DataGroup; -import org.alfresco.utility.data.DataLink; -import org.alfresco.utility.data.DataSite; -import org.alfresco.utility.data.DataUser; -import org.alfresco.utility.data.DataWorkflow; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.network.ServerHealth; -import org.slf4j.Logger; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.BeforeSuite; - -@ContextConfiguration("classpath:alfresco-restapi-context.xml") -public abstract class RestTest extends AbstractTestNGSpringContextTests -{ - private static Logger LOG = LogFactory.getLogger(); - - @Autowired - protected RestProperties restProperties; - - @Autowired - protected TasProperties properties; - - @Autowired - protected ServerHealth serverHealth; - - @Autowired - protected RestWrapper restClient; - - @Autowired - protected DataUser dataUser; - - @Autowired - protected DataSite dataSite; - - @Autowired - protected DataContent dataContent; - - @Autowired - protected DataGroup dataGroup; - - @Autowired - protected DataWorkflow dataWorkflow; - - @Autowired - protected DataLink dataLink; - - @Autowired - protected WorkflowService workflow; - - protected SiteModel testSite; - - @BeforeSuite(alwaysRun = true) - public void checkServerHealth() throws Exception - { - super.springTestContextPrepareTestInstance(); - serverHealth.assertServerIsOnline(); - testSite = dataSite.createPublicRandomSite(); - } - - @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/e2e-test/src/test/java/org/alfresco/service/search/rest/actions/ActionsTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/actions/ActionsTests.java deleted file mode 100644 index b35a8251d..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/actions/ActionsTests.java +++ /dev/null @@ -1,151 +0,0 @@ -package org.alfresco.service.search.rest.actions; - -import static org.testng.Assert.assertFalse; - -import com.google.common.collect.ImmutableMap; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestActionDefinitionModel; -import org.alfresco.rest.model.RestActionDefinitionModelsCollection; -import org.alfresco.rest.model.RestNodeModel; -import org.alfresco.utility.Utility; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.json.JSONObject; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class ActionsTests extends RestTest -{ - private UserModel adminUser; - private FileModel document; - private SiteModel publicSite; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - publicSite = dataSite.createPublicRandomSite(); - document = dataContent.usingSite(publicSite).usingUser(adminUser).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.ACTIONS }, executionType = ExecutionType.SANITY, - description = "Verify actions") - @Test(groups = { TestGroup.REST_API, TestGroup.ACTIONS, TestGroup.SANITY}) - public void testActionDefinitions() throws Exception - { - restClient.authenticateUser(dataContent.getAdminUser()); - - RestActionDefinitionModelsCollection restActionDefinitions = restClient. - withCoreAPI(). - usingActions(). - listActionDefinitions(); - - restClient.assertStatusCodeIs(HttpStatus.OK); - assertFalse(restActionDefinitions.isEmpty()); - restActionDefinitions.assertThat(). - entriesListContains("name", "copy"). - and().entriesListContains("name", "move"). - and().entriesListContains("name", "check-out"). - and().entriesListContains("name", "check-in"); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.ACTIONS }, executionType = ExecutionType.REGRESSION, - description = "Verify actions error conditions") - @Test(groups = { TestGroup.REST_API, TestGroup.ACTIONS, TestGroup.REGRESSION}) - public void testActionDefinitionsNegative() throws Exception{ - // Badly formed request -> 400 - { - restClient.authenticateUser(dataContent.getAdminUser()). - // invalid skipCount - withParams("skipCount=-1"). - withCoreAPI(). - usingActions(). - listActionDefinitions(); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - - } - - // Unauthorized -> 401 - { - - UserModel userUnauthorized = new UserModel("invalid-user", "invalid-pasword"); - restClient.authenticateUser(userUnauthorized).withCoreAPI().usingActions().listActionDefinitions(); - - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); - } - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.ACTIONS }, executionType = ExecutionType.SANITY, - description = "Sanity test for POST /action-executions") - @Test(groups = { TestGroup.REST_API, TestGroup.ACTIONS, TestGroup.SANITY}) - public void executeAction() throws Exception - { - JSONObject response = restClient.authenticateUser(adminUser).withCoreAPI().usingActions().executeAction - ("add-features", document, ImmutableMap.of("aspect-name", "cm:versionable")); - restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); - - assertFalse(response.getString("id").isEmpty()); - - /* - * Get all node properties and check that action was executed and - * cm:versionable aspect was added - */ - Utility.sleep(500, 20000, () -> { - RestNodeModel fileModel = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(document).getNode(); - - restClient.assertStatusCodeIs(HttpStatus.OK); - fileModel.assertThat().field("aspectNames").contains("cm:versionable"); - }); - } - - @TestRail (section = { TestGroup.REST_API, TestGroup.ACTIONS }, executionType = ExecutionType.SANITY, - description = "Sanity test for POST /action-executions") - @Test (groups = { TestGroup.REST_API, TestGroup.ACTIONS, TestGroup.SANITY }) - public void executeActionWithoutParam() throws Exception - { - JSONObject response = restClient.authenticateUser(adminUser).withCoreAPI().usingActions().executeAction - ("check-out", document); - restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); - - assertFalse(response.getString("id").isEmpty()); - - /* - * Get all node properties and check that action was executed and - * cm:checkedOut aspect was added - */ - Utility.sleep(500, 20000, () -> { - RestNodeModel fileModel = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(document) - .getNode(); - - restClient.assertStatusCodeIs(HttpStatus.OK); - fileModel.assertThat().field("aspectNames").contains("cm:checkedOut"); - }); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.ACTIONS }, executionType = ExecutionType.SANITY, - description = "Sanity test for ACTIONS endpoint GET action-definitions/{actionDefinitionId}") - @Test(groups = { TestGroup.REST_API, TestGroup.ACTIONS, TestGroup.SANITY}) - public void testGetActionDefinitionById() throws Exception - { - restClient.authenticateUser(dataContent.getAdminUser()); - - RestActionDefinitionModel restActionDefinition = restClient. - withCoreAPI(). - usingActions(). - getActionDefinitionById("add-features"); - - restClient.assertStatusCodeIs(HttpStatus.OK); - assertFalse(restActionDefinition.getId().isEmpty()); - restActionDefinition.getId().equals("add-features"); - restActionDefinition.getDescription().equals("This will add an aspect to the matched item."); - restActionDefinition.getTitle().equals("Add aspect"); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/aos/AosApiTest.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/aos/AosApiTest.java deleted file mode 100644 index a8f596359..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/aos/AosApiTest.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.alfresco.service.search.rest.aos; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.core.RestRequest; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.testng.annotations.Test; - -public class AosApiTest extends RestTest -{ - /* - * @author: Catalin Gornea - * - * simple test for demo purposes on how to use Aos with Rest - */ - @Test(enabled=false) - public void assertResponsIsSuccesufulWhenGetRootDirectory() throws Exception - { - restClient.authenticateUser(dataUser.getAdminUser()).withAosAPI(); - RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, ""); - restClient.process(request); - restClient.assertStatusCodeIs(HttpStatus.OK); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/audit/AuditTest.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/audit/AuditTest.java deleted file mode 100644 index 78b973100..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/audit/AuditTest.java +++ /dev/null @@ -1,112 +0,0 @@ -package org.alfresco.service.search.rest.audit; - -import static org.hamcrest.Matchers.is; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.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.RestAuditAppModel; -import org.alfresco.rest.model.RestAuditAppModelsCollection; -import org.alfresco.rest.model.RestAuditEntryModel; -import org.alfresco.rest.model.RestAuditEntryModelsCollection; -import org.alfresco.rest.model.RestNodeModel; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.network.JmxBuilder; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.testng.Assert; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import com.jayway.restassured.RestAssured; - -@Test(groups = {TestGroup.REQUIRE_JMX}) -public abstract class AuditTest extends RestTest -{ - - @Autowired - protected RestWrapper restAPI; - - @Autowired - protected JmxBuilder jmxBuilder; - - protected UserModel userModel, userModel1, adminUser; - protected RestAuditAppModelsCollection restAuditCollection; - protected RestAuditAppModel restAuditAppModel; - protected RestAuditEntryModel restAuditEntryModel; - protected RestAuditEntryModelsCollection restAuditEntryCollection; - protected RestAuditAppModel syncRestAuditAppModel; - protected RestAuditAppModel taggingRestAuditAppModel; - protected RestNodeModel node; - protected FileModel file; - protected SiteModel privateTestSite; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - //Audit API is designed for users with admin rights (except /nodes/{nodeId}/audit-entries) - //Create users and add userModel as SiteCollaborator on private site - userModel = dataUser.createRandomTestUser(); - userModel1 = dataUser.createRandomTestUser(); - adminUser = dataUser.getAdminUser(); - privateTestSite = dataSite.createPrivateRandomSite(); - - dataUser.addUserToSite(userModel, privateTestSite, UserRole.SiteCollaborator); - userModel.setUserRole(UserRole.SiteCollaborator); - - //Enable alfresco-access audit application. - jmxBuilder.getJmxClient().writeProperty("Alfresco:Type=Configuration,Category=Audit,id1=default", "audit.alfresco-access.enabled", Boolean.TRUE.toString()); - String alfrescoAccessEnabled = jmxBuilder.getJmxClient().readProperty("Alfresco:Type=Configuration,Category=Audit,id1=default", "audit.alfresco-access.enabled").toString(); - Assert.assertEquals(alfrescoAccessEnabled, Boolean.TRUE.toString(), String.format("Property audit.alfresco-access.enabled is [%s]", alfrescoAccessEnabled)); - - //GET /alfresco/service/api/audit/control to verify if Audit is enabled on the system. - RestAssured.basePath = ""; - restAPI.configureRequestSpec().setBasePath(RestAssured.basePath); - RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "alfresco/service/api/audit/control"); - RestResponse response = restAPI.authenticateUser(adminUser).process(request); - response.assertThat().body("enabled", is(true)); - - //GET /audit-applications and verify that there are audit applications in the system. - restAuditCollection = restClient.authenticateUser(adminUser).withCoreAPI().usingAudit().getAuditApplications(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restAuditCollection.assertThat().entriesListIsNotEmpty(); - - //Find alfresco-access audit application in the list of audit applications. - int i = 0; - do - { - restAuditAppModel = restAuditCollection.getEntries().get(i++).onModel(); - } while (!restAuditAppModel.getName().equals("alfresco-access")); - - //Create new file - file = dataContent.usingUser(adminUser).usingSite(privateTestSite).createContent(DocumentType.TEXT_PLAIN); - node = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file).usingParams("include=isLocked").getNode(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - protected RestAuditAppModel getSyncRestAuditAppModel(UserModel userModel) throws Exception - { - restAuditCollection = restClient.authenticateUser(userModel).withCoreAPI().usingAudit().getAuditApplications(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restAuditCollection.assertThat().entriesListIsNotEmpty(); - RestAuditAppModel syncRestAuditAppModel = restAuditCollection.getEntries().get(0).onModel(); - return syncRestAuditAppModel; - } - - protected RestAuditAppModel getTaggingRestAuditAppModel(UserModel userModel) throws Exception - { - restAuditCollection = restClient.authenticateUser(userModel).withCoreAPI().usingAudit().getAuditApplications(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restAuditCollection.assertThat().entriesListIsNotEmpty(); - RestAuditAppModel taggingRestAuditAppModel = restAuditCollection.getEntries().get(1).onModel(); - return taggingRestAuditAppModel; - } - -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/audit/DeleteAuditTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/audit/DeleteAuditTests.java deleted file mode 100644 index 5adbbaa4c..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/audit/DeleteAuditTests.java +++ /dev/null @@ -1,66 +0,0 @@ -package org.alfresco.service.search.rest.audit; - -import static org.testng.Assert.assertEquals; - -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; - -@Test(groups = {TestGroup.REQUIRE_JMX}) -public class DeleteAuditTests extends AuditTest -{ - - @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if deleting an audit entry for an application is only for admin user, and status code is 204") - public void deleteAuditEntry() throws Exception - { - restAuditEntryCollection = restClient.authenticateUser(adminUser).withParams("maxItems=10").withCoreAPI().usingAudit() - .listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); - restClient.assertStatusCodeIs(HttpStatus.OK); - String entryId = restAuditEntryCollection.getEntries().get(restAuditEntryCollection.getPagination().getCount() - 1) - .onModel().getId(); - - restClient.authenticateUser(userModel).withCoreAPI().usingAudit() - .deleteAuditEntryForAnAuditApplication(restAuditAppModel.getId(), entryId); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - - restClient.authenticateUser(adminUser).withCoreAPI().usingAudit() - .deleteAuditEntryForAnAuditApplication(restAuditAppModel.getId(), entryId); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restAuditEntryModel = restClient.authenticateUser(adminUser).withCoreAPI().usingAudit() - .getAuditEntryForAnAuditApplication(restAuditAppModel.getId(), entryId); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if deleting a set of audit entries for an application is only for admin user, and status code is 204") - public void deleteAuditEntriesForAnAuditApplication() throws Exception - { - restAuditEntryCollection = restClient.authenticateUser(adminUser).withParams("maxItems=4").withCoreAPI().usingAudit() - .listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); - restClient.assertStatusCodeIs(HttpStatus.OK); - - String firstId = restAuditEntryCollection.getEntries().get(0).onModel().getId(); - String secondId = restAuditEntryCollection.getEntries().get(restAuditEntryCollection.getPagination().getCount() - 1) - .onModel().getId(); - - restClient.authenticateUser(userModel).withParams("where=(id BETWEEN (" + firstId + "," + secondId + "))").withCoreAPI() - .usingAudit().deleteAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - - restClient.authenticateUser(adminUser).withParams("where=(id BETWEEN (" + firstId + "," + secondId + "))").withCoreAPI() - .usingAudit().deleteAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restAuditEntryCollection = restClient.authenticateUser(adminUser).withParams("where=(id BETWEEN ("+firstId+","+secondId+"))").withCoreAPI().usingAudit() - .listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); - restClient.assertStatusCodeIs(HttpStatus.OK); - assertEquals(restAuditEntryCollection.getPagination().getCount(), 0); - } - -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/audit/GetAuditTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/audit/GetAuditTests.java deleted file mode 100644 index 993166e4c..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/audit/GetAuditTests.java +++ /dev/null @@ -1,357 +0,0 @@ -package org.alfresco.service.search.rest.audit; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; - -import java.util.ArrayList; - -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; - -@Test(groups = {TestGroup.REQUIRE_JMX}) -public class GetAuditTests extends AuditTest -{ - - @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if the admin user gets audit application info") - public void getAuditApplicationInfoWithAdminUser() throws Exception - { - restAuditAppModel.assertThat().field("isEnabled").is(true); - restAuditAppModel.assertThat().field("name").is("alfresco-access"); - restAuditAppModel.assertThat().field("id").is("alfresco-access"); - - syncRestAuditAppModel = getSyncRestAuditAppModel(adminUser); - syncRestAuditAppModel.assertThat().field("isEnabled").is(true); - syncRestAuditAppModel.assertThat().field("name").is("Alfresco Sync Service"); - syncRestAuditAppModel.assertThat().field("id").is("sync"); - - taggingRestAuditAppModel = getTaggingRestAuditAppModel(adminUser); - taggingRestAuditAppModel.assertThat().field("isEnabled").is(true); - taggingRestAuditAppModel.assertThat().field("name").is("Alfresco Tagging Service"); - taggingRestAuditAppModel.assertThat().field("id").is("tagging"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if a normal user gets a list of audit applications and status code is 403") - public void getAuditApplicationsWithNormalUser() throws Exception - { - restAuditCollection = restClient.authenticateUser(userModel).withCoreAPI().usingAudit().getAuditApplications(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - restAuditCollection.assertThat().entriesListIsEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.AUDIT }, executionType = ExecutionType.REGRESSION, description = "Verify if the admin user gets a list of audit applications using skipCount and status code is 200") - public void getAuditApplicationsWithAdminUserUsingValidSkipCount() throws Exception - { - restAuditCollection = restClient.authenticateUser(adminUser).withParams("skipCount=1").withCoreAPI() - .usingAudit().getAuditApplications(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restAuditCollection.getPagination().assertThat().field("totalItems").isNotNull().and().field("totalItems") - .isGreaterThan(0).and().field("skipCount").is("1"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.AUDIT }, executionType = ExecutionType.REGRESSION, description = "Verify if the admin user gets a list of audit applications using invalid skipCount and status code is 400") - public void getAuditApplicationsWithAdminUserUsingInvalidSkipCount() throws Exception - { - restClient.authenticateUser(adminUser).withParams("skipCount=-1").withCoreAPI().usingAudit() - .getAuditApplications(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.AUDIT }, executionType = ExecutionType.REGRESSION, description = "Verify if the admin user gets a list of audit applications using maxItems and status code is 200") - public void getAuditApplicationsWithAdminUserUsingValidMaxItems() throws Exception - { - restAuditCollection = restClient.authenticateUser(adminUser).withParams("maxItems=1").withCoreAPI() - .usingAudit().getAuditApplications(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restAuditCollection.getPagination().assertThat().field("totalItems").isNotNull().and().field("totalItems") - .isGreaterThan(0).and().field("maxItems").is("1"); - assertEquals(restAuditCollection.getEntries().size(), 1); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.AUDIT }, executionType = ExecutionType.REGRESSION, description = "Verify if the admin user gets a list of audit applications using invalid maxItems and status code is 400") - public void getAuditApplicationsWithAdminUserUsingInvalidMaxItems() throws Exception - { - restClient.authenticateUser(adminUser).withParams("maxItems=-1").withCoreAPI().usingAudit() - .getAuditApplications(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - - restClient.authenticateUser(adminUser).withParams("maxItems=0").withCoreAPI().usingAudit() - .getAuditApplications(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - - } - - @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if the admin user gets a list of audit applications using skipCount and maxItems and status code is 200") - public void getAuditApplicationsWithAdminUserUsingValidSkipCountAndMaxItems() throws Exception - { - restAuditCollection = restClient.authenticateUser(adminUser).withParams("skipCount=1&maxItems=1") - .withCoreAPI().usingAudit().getAuditApplications(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restAuditCollection.getPagination().assertThat().field("totalItems").isNotNull().and().field("totalItems") - .isGreaterThan(0).and().field("maxItems").is("1").and().field("skipCount").is("1"); - assertEquals(restAuditCollection.getEntries().size(), 1); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.AUDIT }, executionType = ExecutionType.REGRESSION, description = "Verify if the admin user gets a list of audit applications using invalid skipCount and/or invalid maxItems and status code is 400") - public void getAuditApplicationsWithAdminUserUsingInvalidSkipCountAndMaxItems() throws Exception - { - restClient.authenticateUser(adminUser).withParams("skipCount=-1&maxItems=1").withCoreAPI().usingAudit() - .getAuditApplications(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - - restClient.authenticateUser(adminUser).withParams("skipCount=-1&maxItems=-1").withCoreAPI().usingAudit() - .getAuditApplications(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - - restClient.authenticateUser(adminUser).withParams("skipCount=-1&maxItems=0").withCoreAPI().usingAudit() - .getAuditApplications(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - - restClient.authenticateUser(adminUser).withParams("skipCount=1&maxItems=-1").withCoreAPI().usingAudit() - .getAuditApplications(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if a normal user gets a list of audit entries for audit application auditApplicationId and status code is 403") - public void getAuditEntriesWithNormalUser() throws Exception - { - restClient.authenticateUser(userModel).withCoreAPI().usingAudit() - .listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if the admin user gets a list of audit entries using invalid skipCount and/or invalid maxItems and status code is 400") - public void getAuditEntriesWithAdminUserUsingInvalidSkipCountAndMaxItems() throws Exception - { - restClient.authenticateUser(adminUser).withParams("skipCount=-1&maxItems=1").withCoreAPI().usingAudit() - .listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - - restClient.authenticateUser(adminUser).withParams("skipCount=-1&maxItems=-1").withCoreAPI().usingAudit() - .listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - - restClient.authenticateUser(adminUser).withParams("skipCount=-1&maxItems=0").withCoreAPI().usingAudit() - .listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - - restClient.authenticateUser(adminUser).withParams("skipCount=1&maxItems=-1").withCoreAPI().usingAudit() - .listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if the admin user gets a list of audit entries using valid skipCount and maxItems and status code is 200") - public void getAuditEntriesWithAdminUserUsingValidSkipCountAndMaxItems() throws Exception - { - restAuditEntryCollection = restClient.authenticateUser(adminUser).withParams("skipCount=1&maxItems=1") - .withCoreAPI().usingAudit().listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); - restClient.assertStatusCodeIs(HttpStatus.OK); - restAuditEntryCollection.getPagination().assertThat().field("totalItems").isNotNull().and().field("totalItems") - .isGreaterThan(0).and().field("maxItems").is("1").and().field("skipCount").is("1"); - assertEquals(restAuditEntryCollection.getEntries().size(), 1); - - // Testing Pagination - restAuditEntryCollection = restClient.authenticateUser(adminUser).withParams("maxItems=10").withCoreAPI().usingAudit() - .listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); - restClient.assertStatusCodeIs(HttpStatus.OK); - ArrayList ids = new ArrayList<>(); - int numberOfElements = restAuditEntryCollection.getPagination().getCount(); - for (int i = 0; i < numberOfElements; i++) - { - ids.add(restAuditEntryCollection.getEntries().get(i).onModel().getId()); - } - - int skipCount = 0; - do - { - restAuditEntryCollection = restClient.authenticateUser(adminUser).withParams("maxItems=1&skipCount=" + skipCount) - .withCoreAPI().usingAudit().listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); - restClient.assertStatusCodeIs(HttpStatus.OK); - assertEquals(restAuditEntryCollection.getEntries().size(), 1); - assertEquals(restAuditEntryCollection.getPagination().getCount(), 1); - assertEquals(restAuditEntryCollection.getPagination().getSkipCount(), skipCount); - assertEquals(restAuditEntryCollection.getEntries().get(0).onModel().getId(), ids.get(skipCount)); - skipCount++; - } while (skipCount < numberOfElements); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.AUDIT }, executionType = ExecutionType.REGRESSION, description = "Verify if the admin user gets a list of audit entries using orderBy and status code is 200") - public void getAuditEntriesWithAdminUserUsingOrderBy() throws Exception - { - restAuditEntryCollection = restClient.authenticateUser(adminUser).withParams("orderBy=createdAt ASC&maxItems=10") - .withCoreAPI().usingAudit().listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); - restClient.assertStatusCodeIs(HttpStatus.OK); - - String ascId = restAuditEntryCollection.getEntries().get(1).onModel().getId(); - - restAuditEntryCollection = restClient.authenticateUser(adminUser).withParams("orderBy=createdAt DESC&maxItems=10") - .withCoreAPI().usingAudit().listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); - restClient.assertStatusCodeIs(HttpStatus.OK); - - assertTrue(Integer.parseInt(restAuditEntryCollection.getEntries().get(1).onModel().getId()) > Integer.parseInt(ascId)); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.AUDIT }, executionType = ExecutionType.REGRESSION, description = "Verify if the admin user gets a list of audit entries using the where parameter to and status code is 200") - public void getAuditEntriesWithAdminUserUsingWhere() throws Exception - { - int expectedNumberOfItems; - String id1,id2; - restAuditEntryCollection = restClient.authenticateUser(adminUser).withParams("maxItems=2").withCoreAPI().usingAudit().listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); - restClient.assertStatusCodeIs(HttpStatus.OK); - - if (restAuditEntryCollection.getPagination().getCount() == 2) - { - id1 = restAuditEntryCollection.getEntries().get(0).onModel().getId(); - id2 = restAuditEntryCollection.getEntries().get(1).onModel().getId(); - expectedNumberOfItems = 2; - } - else - { - id1 = id2 = restAuditEntryCollection.getEntries().get(0).onModel().getId(); - expectedNumberOfItems = 1; - } - - restAuditEntryCollection = restClient.authenticateUser(adminUser).withParams("where=(id BETWEEN ("+id1+","+id2+"))") - .withCoreAPI().usingAudit().listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); - restClient.assertStatusCodeIs(HttpStatus.OK); - - restAuditEntryCollection.assertThat().entriesListCountIs(expectedNumberOfItems); - assertEquals(id1, restAuditEntryCollection.getEntries().get(0).onModel().getId()); - if (!id1.equals(id2)) - { - assertEquals(id2, restAuditEntryCollection.getEntries().get(1).onModel().getId()); - } - } - - @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if retrieving an audit entry for an audit application is only for admin user, with and without the include=values paramater and status code is 200") - public void getAuditEntry() throws Exception - { - restAuditEntryCollection = restClient.authenticateUser(adminUser).withParams("maxItems=10").withCoreAPI().usingAudit() - .listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); - restClient.assertStatusCodeIs(HttpStatus.OK); - String entryId = restAuditEntryCollection.getEntries().get(restAuditEntryCollection.getPagination().getCount() - 1) - .onModel().getId(); - String entryApplicationId = restAuditEntryCollection.getEntries() - .get(restAuditEntryCollection.getPagination().getCount() - 1).onModel().getAuditApplicationId(); - - restAuditEntryModel = restClient.authenticateUser(userModel).withCoreAPI().usingAudit() - .getAuditEntryForAnAuditApplication(restAuditAppModel.getId(), entryId); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - - restAuditEntryModel = restClient.authenticateUser(adminUser).withCoreAPI().usingAudit() - .getAuditEntryForAnAuditApplication(restAuditAppModel.getId(), entryId); - restClient.assertStatusCodeIs(HttpStatus.OK); - assertEquals(entryId, restAuditEntryModel.getId()); - assertEquals(entryApplicationId, restAuditEntryModel.getAuditApplicationId()); - // Values are displayed by default for single audit application entry - assertNotNull(restAuditEntryModel.getValues()); - - restAuditEntryModel = restClient.authenticateUser(adminUser).withParams("include=values").withCoreAPI().usingAudit() - .getAuditEntryForAnAuditApplication(restAuditAppModel.getId(), entryId); - restClient.assertStatusCodeIs(HttpStatus.OK); - assertEquals(entryId, restAuditEntryModel.getId()); - assertEquals(entryApplicationId, restAuditEntryModel.getAuditApplicationId()); - assertNotNull(restAuditEntryModel.getValues()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if the admin user gets a list of audit entries for node id nodeId using 'where' and 'maxItems' param and status code is 200") - public void getAuditEntriesForNodeUsingMaxItemsAndWhereParam() throws Exception - { - String createdAt1, createdAt2; - int expectedNumberOfItems; - - // Get the node id - String nodeId = node.getId(); - - // Add comments for a node (to create audit entries) - restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file).addComment("This is the first comment"); - restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file).addComment("This is the second comment"); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - // Get maxium two audit entries for the node using 'maxItems' param on /nodes/{nodeId}/audit-entries - restAuditEntryCollection = restClient.authenticateUser(adminUser).withParams("maxItems=2").withCoreAPI().usingAudit().listAuditEntriesForNode(nodeId); - restClient.assertStatusCodeIs(HttpStatus.OK); - restAuditEntryCollection.assertThat().entriesListIsNotEmpty(); - - if (restAuditEntryCollection.getPagination().getCount() == 2) - { - createdAt1 = restAuditEntryCollection.getEntries().get(0).onModel().getCreatedAt(); - createdAt2 = restAuditEntryCollection.getEntries().get(1).onModel().getCreatedAt(); - expectedNumberOfItems = 2; - } - else - { - createdAt1 = createdAt2 = restAuditEntryCollection.getEntries().get(0).onModel().getCreatedAt(); - expectedNumberOfItems = 1; - } - - // Get audit entries between ids for the node using 'where' clause on /nodes/{nodeId}/audit-entries - restAuditEntryCollection = restClient.authenticateUser(adminUser).withParams("where=(createdAt BETWEEN ('" + createdAt1 + "','" + createdAt2 + "'))") - .withCoreAPI().usingAudit().listAuditEntriesForNode(nodeId); - restClient.assertStatusCodeIs(HttpStatus.OK); - - restAuditEntryCollection.assertThat().entriesListCountIs(expectedNumberOfItems); - assertEquals(createdAt1, restAuditEntryCollection.getEntries().get(0).onModel().getCreatedAt()); - if (!createdAt1.equals(createdAt2)) - { - assertEquals(createdAt2, restAuditEntryCollection.getEntries().get(1).onModel().getCreatedAt()); - } - } - - @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if user with permissions can get a list of audit entries for node and status code is 200") - public void getAuditEntriesForNodeUsingUserWithPermissions() throws Exception - { - // Get the node id - String nodeId = node.getId(); - - // Add comments for a node using user with permissions (to create audit entries and check if user can view/edit the node) - restClient.authenticateUser(userModel).withCoreAPI().usingNode(file).addComment("This is a comment"); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - // Get audit entries for the node using a user with permissions and /nodes/{nodeId}/audit-entries - restAuditEntryCollection = restClient.authenticateUser(userModel).withCoreAPI().usingAudit().listAuditEntriesForNode(nodeId); - restClient.assertStatusCodeIs(HttpStatus.OK); - restAuditEntryCollection.assertThat().entriesListIsNotEmpty(); - - // Check that a user that doesn't have access to node, doesn't have access to audit entries for node - restClient.authenticateUser(userModel1).withCoreAPI().usingNode(file).getNode(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - restClient.authenticateUser(userModel1).withCoreAPI().usingAudit().listAuditEntriesForNode(nodeId); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/audit/PutAuditTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/audit/PutAuditTests.java deleted file mode 100644 index 1f8957cd1..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/audit/PutAuditTests.java +++ /dev/null @@ -1,111 +0,0 @@ -package org.alfresco.service.search.rest.audit; - -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; - -@Test(groups = {TestGroup.REQUIRE_JMX}) -public class PutAuditTests extends AuditTest -{ - - @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.AUDIT }, executionType = ExecutionType.REGRESSION, description = "Verify that the admin user can enable/disable sync application auditing") - public void enableDisableSyncApplicationAuditingAsAdminUser() throws Exception - { - // disable sync audit app - syncRestAuditAppModel = getSyncRestAuditAppModel(adminUser); - restClient.authenticateUser(adminUser).withCoreAPI().usingAudit().updateAuditApp(syncRestAuditAppModel, "isEnabled", - "false"); - - // check isEnabled=false - syncRestAuditAppModel = getSyncRestAuditAppModel(adminUser); - syncRestAuditAppModel.assertThat().field("isEnabled").is(false); - syncRestAuditAppModel.assertThat().field("name").is("Alfresco Sync Service"); - syncRestAuditAppModel.assertThat().field("id").is("sync"); - - // enable sync audit app - restClient.authenticateUser(adminUser).withCoreAPI().usingAudit().updateAuditApp(syncRestAuditAppModel, "isEnabled", - "true"); - - // check isEnabled=true - syncRestAuditAppModel = getSyncRestAuditAppModel(adminUser); - syncRestAuditAppModel.assertThat().field("isEnabled").is(true); - syncRestAuditAppModel.assertThat().field("name").is("Alfresco Sync Service"); - syncRestAuditAppModel.assertThat().field("id").is("sync"); - - } - - @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify that the admin user can enable/disable tagging application auditing") - public void enableDisableTaggingApplicationAuditingAsAdminUser() throws Exception - { - // disable tagging audit app - taggingRestAuditAppModel = getTaggingRestAuditAppModel(adminUser); - restClient.authenticateUser(adminUser).withCoreAPI().usingAudit().updateAuditApp(taggingRestAuditAppModel, "isEnabled", - "false"); - - // check isEnabled=false - taggingRestAuditAppModel = getTaggingRestAuditAppModel(adminUser); - taggingRestAuditAppModel.assertThat().field("isEnabled").is(false); - taggingRestAuditAppModel.assertThat().field("name").is("Alfresco Tagging Service"); - taggingRestAuditAppModel.assertThat().field("id").is("tagging"); - - // enable tagging audit app - restClient.authenticateUser(adminUser).withCoreAPI().usingAudit().updateAuditApp(taggingRestAuditAppModel, "isEnabled", - "true"); - - // check isEnabled=true - taggingRestAuditAppModel = getTaggingRestAuditAppModel(adminUser); - taggingRestAuditAppModel.assertThat().field("isEnabled").is(true); - taggingRestAuditAppModel.assertThat().field("name").is("Alfresco Tagging Service"); - taggingRestAuditAppModel.assertThat().field("id").is("tagging"); - - } - - @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.AUDIT }, executionType = ExecutionType.REGRESSION, description = "Verify that the normal user can't enable/disable sync application auditing") - public void enableDisableSyncApplicationAuditingAsNormalUser() throws Exception - { - // disable sync audit app - syncRestAuditAppModel = getSyncRestAuditAppModel(adminUser); - restClient.authenticateUser(userModel).withCoreAPI().usingAudit().updateAuditApp(syncRestAuditAppModel, "isEnabled", - "false"); - - // permission denied - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - - // enable sync audit app - restClient.authenticateUser(userModel).withCoreAPI().usingAudit().updateAuditApp(syncRestAuditAppModel, "isEnabled", - "true"); - - // permission denied - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify that the normal user can't enable/disable tagging application auditing") - public void enableDisableTaggingApplicationAuditingAsNormalUser() throws Exception - { - // disable tagging audit app - taggingRestAuditAppModel = getTaggingRestAuditAppModel(adminUser); - restClient.authenticateUser(userModel).withCoreAPI().usingAudit().updateAuditApp(taggingRestAuditAppModel, "isEnabled", - "false"); - - // permission denied - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - - // disable tagging audit app - restClient.authenticateUser(userModel).withCoreAPI().usingAudit().updateAuditApp(taggingRestAuditAppModel, "isEnabled", - "true"); - - // permission denied - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - } - -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/auth/AuthTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/auth/AuthTests.java deleted file mode 100644 index 4ddbc61d8..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/auth/AuthTests.java +++ /dev/null @@ -1,87 +0,0 @@ -package org.alfresco.service.search.rest.auth; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.core.RestWrapper; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestTicketBodyModel; -import org.alfresco.rest.model.RestTicketModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.apache.commons.codec.binary.Base64; -import org.springframework.http.HttpStatus; -import org.testng.Assert; -import org.testng.annotations.Test; - -public class AuthTests extends RestTest -{ - - private RestWrapper addRestRequestAuthorization(RestTicketModel ticketModel) - { - restClient.configureRequestSpec().addHeader("Authorization", "Basic " + encodeB64(ticketModel.getId())); - return restClient; - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.AUTH }, executionType = ExecutionType.SANITY, description = "Verify HttpMethod.POST tickets") - @Test(groups = { TestGroup.REST_API, TestGroup.SANITY, TestGroup.AUTH }) - public void adminShouldGetTicketBody() throws JsonToModelConversionException, Exception - { - RestTicketBodyModel ticketBody = new RestTicketBodyModel(); - ticketBody.setUserId("admin"); - ticketBody.setPassword("admin"); - - RestTicketModel ticketReturned = restClient.authenticateUser(dataContent.getAdminUser()).withAuthAPI().createTicket(ticketBody); - - restClient.assertStatusCodeIs(HttpStatus.CREATED); - ticketReturned.assertThat().field("id").contains("TICKET_"); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.AUTH }, executionType = ExecutionType.SANITY, description = "Verify HttpMethod.GET tickets/-me-") - @Test(groups = { TestGroup.REST_API, TestGroup.SANITY, TestGroup.AUTH }) - public void randomUserGetTicket() throws Exception - { - UserModel userModel = dataUser.createRandomTestUser(); - RestTicketBodyModel ticketBody = new RestTicketBodyModel(); - ticketBody.setUserId(userModel.getUsername()); - ticketBody.setPassword(userModel.getPassword()); - - RestTicketModel ticketCreated = restClient.authenticateUser(userModel).withAuthAPI().createTicket(ticketBody); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - addRestRequestAuthorization(ticketCreated); - RestTicketModel ticketReturned = restClient.withAuthAPI().getTicket(); - Assert.assertEquals(ticketCreated.getId(), ticketReturned.getId()); - - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.AUTH }, executionType = ExecutionType.SANITY, description = "Verify HttpMethod.REMOVE tickets/-me-") - @Test(groups = { TestGroup.REST_API, TestGroup.SANITY, TestGroup.AUTH }) - public void randomUserRemoveTicket() throws Exception - { - UserModel userModel = dataUser.createRandomTestUser(); - RestTicketBodyModel ticketBody = new RestTicketBodyModel(); - ticketBody.setUserId(userModel.getUsername()); - ticketBody.setPassword(userModel.getPassword()); - - RestTicketModel ticketCreated = restClient.authenticateUser(userModel).withAuthAPI().createTicket(ticketBody); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - addRestRequestAuthorization(ticketCreated); - restClient.withAuthAPI().removeTicket(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withAuthAPI().getTicket(); - restClient.assertLastError().containsErrorKey("Ticket base authentication required."); - - } - - private String encodeB64(String str) - { - return Base64.encodeBase64String(str.getBytes()); - } - -} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/cmis/CmisBrowserTest.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/cmis/CmisBrowserTest.java deleted file mode 100644 index 56e99e3a2..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/cmis/CmisBrowserTest.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.alfresco.service.search.rest.cmis; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.core.RestResponse; -import org.alfresco.utility.model.FileModel; -import org.testng.annotations.Test; - -public class CmisBrowserTest extends RestTest -{ - /* - * @author: Paul Brodner - * simple test for demo purposes on how to use CMIS browser binding with Rest - */ - @Test(enabled=false) - public void assertContentDispositionHeaderOnCmisFile() throws Exception - { - FileModel document = dataContent.usingUser(dataUser.getAdminUser()) - .usingSite(testSite).createContent(DocumentType.HTML); - - RestResponse response = restClient.authenticateUser(dataUser.getAdminUser()).withCMISApi().getRootObjectByID(document); - response.assertThat().header("Content-Disposition", String.format("attachment; filename=%s", document.getName())); - } - -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/comments/AddCommentTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/comments/AddCommentTests.java deleted file mode 100644 index f4eb84930..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/comments/AddCommentTests.java +++ /dev/null @@ -1,260 +0,0 @@ -package org.alfresco.service.search.rest.comments; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestCommentModel; -import org.alfresco.rest.model.RestCommentModelsCollection; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestTagModel; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FileType; -import org.alfresco.utility.model.LinkModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.apache.commons.lang3.RandomStringUtils; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class AddCommentTests extends RestTest -{ - private UserModel adminUserModel; - private FileModel document; - private SiteModel siteModel; - private ListUserWithRoles usersWithRoles; - private String comment; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - restClient.authenticateUser(adminUserModel); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify admin user adds comments with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) - public void adminIsAbleToAddComment() throws Exception - { - restClient.authenticateUser(adminUserModel); - String newContent = "This is a new comment added by " + adminUserModel.getUsername(); - restClient.withCoreAPI().usingResource(document).addComment(newContent) - .assertThat().field("content").isNotEmpty() - .and().field("content").is(newContent); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.onResponse().assertThat().body("entry.edited", org.hamcrest.Matchers.is(false)); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, - description = "Verify that comment can be retrieved after it is added") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) - public void addCommentThenRetrieveComment() throws Exception - { - comment = RandomData.getRandomName("comment1"); - restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingResource(document).addComment(comment); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestCommentModelsCollection comments = restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingResource(document).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - comments.assertThat().entriesListContains("content", comment); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user gets status code 401 on post comments call") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) -// @Bug(id = "MNT-16904", description = "It fails only on environment with tenants") - public void unauthenticatedUserIsNotAbleToAddComment() throws Exception - { - restClient.authenticateUser(new UserModel("random user", "random password")); - restClient.withCoreAPI().usingResource(document).addComment("This is a new comment"); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Manager user adds comments with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void managerIsAbleToAddComment() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - String contentSiteManger = "This is a new comment added by user with role: " + UserRole.SiteManager; - RestCommentModel createdComment = restClient.withCoreAPI().usingResource(document).addComment(contentSiteManger); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - createdComment.assertThat().field("content").isNotEmpty() - .and().field("content").is(contentSiteManger); - - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Contributor user adds comments with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - @Bug(id="ACE-4614") - public void contributorIsAbleToAddComment() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - String contentSiteContributor = "This is a new comment added by user with role" + UserRole.SiteContributor; - RestCommentModel createdComment = restClient.withCoreAPI().usingResource(document).addComment(contentSiteContributor); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - createdComment.assertThat().field("content").isNotEmpty() - .and().field("content").is(contentSiteContributor); - - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user adds comments with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void collaboratorIsAbleToAddComment() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - String contentSiteCollaborator = "This is a new comment added by user with role: " + UserRole.SiteCollaborator; - restClient.withCoreAPI().usingResource(document).addComment(contentSiteCollaborator) - .assertThat().field("content").isNotEmpty() - .and().field("content").is(contentSiteCollaborator); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Consumer user can't add comments with Rest API and status code is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void consumerIsNotAbleToAddComment() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - String contentSiteConsumer = "This is a new comment added by user with role: " + UserRole.SiteConsumer; - restClient.withCoreAPI().usingResource(document).addComment(contentSiteConsumer); - restClient - .assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, - description = "Verify that invalid request returns status code 404 for nodeId that does not exist") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void addCommentUsingInvalidNodeId() throws Exception - { - comment = RandomData.getRandomName("comment1"); - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - file.setNodeRef(RandomStringUtils.randomAlphanumeric(20)); - - restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingResource(file).addComment(comment); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, file.getNodeRef())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, - description = "Verify that request using nodeId that is neither document or folder returns 405") - @Bug(id = "MNT-16904") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void addCommentUsingResourceThatIsNotFileOrFolder() throws Exception - { - comment = RandomData.getRandomName("comment1"); - LinkModel link = dataLink.usingAdmin().usingSite(siteModel).createRandomLink(); - FileModel fileWithNodeRefFromLink = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); - fileWithNodeRefFromLink = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - fileWithNodeRefFromLink.setNodeRef(link.getNodeRef()); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(fileWithNodeRefFromLink).addComment(comment); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, - description = "Verify that adding comment using empty content returns 400 status code") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void addCommentUsingEmptyContent() throws Exception - { - restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingResource(document).addComment(""); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.NULL_ARGUMENT, "comment")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, - description = "Verify adding comment with the same content as one existing comment") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void addCommentTwice() throws Exception - { - comment = RandomData.getRandomName("comment1"); - restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingResource(document).addComment(comment); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingResource(document).addComment(comment); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.withCoreAPI().usingResource(document).getNodeComments() - .assertThat().entriesListContains("content", comment); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, - description = "Verify comment cannot be added if user is not member of private site") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void addCommentWithNonMemberOfPrivateSite() throws Exception - { - comment = RandomData.getRandomName("comment1"); - UserModel member = dataUser.createRandomTestUser(); - SiteModel privateSite = dataSite.usingUser(adminUserModel).createPrivateRandomSite(); - FileModel file = dataContent.usingSite(privateSite).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(member) - .withCoreAPI().usingResource(file).addComment(comment); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, - description = "Verify comment cannot be added if empty network ID is provided") -// @Bug(id = "MNT-16904", description = "It fails only on environment with tenants") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void addCommentUsingEmptyNetworkId() throws Exception - { - comment = RandomData.getRandomName("comment1"); - UserModel member = dataUser.createRandomTestUser(); - member.setDomain(""); - - restClient.authenticateUser(member) - .withCoreAPI().usingResource(document).addComment(comment); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, - description = "Verify that comment cannot be added to another comment") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void addCommentToAComment() throws Exception - { - comment = RandomData.getRandomName("comment1"); - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - RestCommentModel commentEntry = restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingResource(file).addComment(comment); - file.setNodeRef(commentEntry.getId()); - - restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingResource(file).addComment(comment); - - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.CANNOT_COMMENT); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, - description = "Verify that comment cannot be added to a tag") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void addCommentToATag() throws Exception - { - comment = RandomData.getRandomName("comment1"); - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag("randomTag"); - - file.setNodeRef(tag.getId()); - - restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingResource(file).addComment(comment); - - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.CANNOT_COMMENT); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/comments/AddCommentsTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/comments/AddCommentsTests.java deleted file mode 100644 index 77984666c..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/comments/AddCommentsTests.java +++ /dev/null @@ -1,377 +0,0 @@ -package org.alfresco.service.search.rest.comments; - -import java.util.List; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.core.JsonBodyGenerator; -import org.alfresco.rest.core.RestRequest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestCommentModel; -import org.alfresco.rest.model.RestCommentModelsCollection; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestTagModel; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser; -import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FileType; -import org.alfresco.utility.model.LinkModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.apache.commons.lang3.RandomStringUtils; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -/** - * Created by Claudia Agache on 10/10/2016. - */ -public class AddCommentsTests extends RestTest -{ - private UserModel adminUserModel, networkUserModel; - private FileModel document; - private SiteModel siteModel; - private DataUser.ListUserWithRoles usersWithRoles; - private RestCommentModelsCollection comments; - private String comment1, comment2; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - networkUserModel = dataUser.createRandomTestUser(); - restClient.authenticateUser(adminUserModel); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - - document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); - } - - @BeforeMethod(alwaysRun = true) - public void generateRandomComments() - { - comment1 = RandomData.getRandomName("comment1"); - comment2 = RandomData.getRandomName("comment2"); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify admin user adds multiple comments with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) - public void adminIsAbleToAddComments() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingResource(document).addComments(comment1, comment2) - .assertThat().entriesListIsNotEmpty() - .and().entriesListContains("content", comment1) - .and().entriesListContains("content", comment2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user gets status code 401 on post multiple comments call") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) - public void unauthenticatedUserIsNotAbleToAddComments() throws JsonToModelConversionException, Exception - { - restClient.noAuthentication() - .withCoreAPI().usingResource(document).addComments(comment1, comment2); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Manager user adds multiple comments with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void managerIsAbleToAddComments() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(document).addComments(comment1, comment2) - .assertThat().entriesListIsNotEmpty() - .and().entriesListContains("content", comment1) - .and().entriesListContains("content", comment2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Contributor user adds multiple comments with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void contributorIsAbleToAddComments() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) - .withCoreAPI().usingResource(document).addComments(comment1, comment2) - .assertThat().entriesListIsNotEmpty() - .and().entriesListContains("content", comment1) - .and().entriesListContains("content", comment2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user adds multiple comments with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void collaboratorIsAbleToAddComments() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingResource(document).addComments(comment1, comment2) - .assertThat().paginationExist().and().entriesListIsNotEmpty() - .and().entriesListContains("content", comment1) - .and().entriesListContains("content", comment2); - - restClient.assertStatusCodeIs(HttpStatus.CREATED); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Consumer user adds multiple comments with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void consumerIsAbleToAddComments() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .withCoreAPI().usingResource(document).addComments(comment1, comment2); - - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify User can not add comments to a not joined private site. Status code returned is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void userCanNotAddCommentsToANotJoinedPrivateSite() throws Exception - { - SiteModel sitePrivateNotJoined = dataSite.createPrivateRandomSite(); - FileModel file = dataContent.usingSite(sitePrivateNotJoined).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(file).addComments(comment1, comment2); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify User can't add comments to a node with ID that does not exist and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void userCanNotAddCommentsOnNonexistentFile() throws Exception - { - FileModel nonexistentFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); - - nonexistentFile.setNodeRef("ABC"); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(nonexistentFile).addComments(comment1,comment2); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, nonexistentFile.getNodeRef())); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify User can't add comments to a node that exists but is not a document or a folder and status code is 405") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - @Bug(id = "MNT-16904") - public void userCanNotAddCommentsOnLink() throws Exception - { - LinkModel link = dataLink.usingAdmin().usingSite(siteModel).createRandomLink(); - FileModel fileWithNodeRefFromLink = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); - fileWithNodeRefFromLink.setNodeRef(link.getNodeRef()); - - restClient.authenticateUser(adminUserModel).withCoreAPI() - .usingResource(fileWithNodeRefFromLink).addComments(comment1,comment2); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(RestErrorModel.UNABLE_TO_LOCATE); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify User can add comments with the same content as one existing comment") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void userCanAddCommentWithTheSameContentAsExistingOne() throws Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - String sameComment = comment1; - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(file).addComments(comment1, sameComment) - .assertThat().paginationExist().and().entriesListIsNotEmpty() - .and().entriesListContains("content", comment1) - .and().entriesListContains("content", sameComment); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - comments = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI() - .usingResource(file).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListIsNotEmpty(); - List commentsList = comments.getEntries(); - commentsList.get(0).onModel().assertThat().field("content").is(comment1); - commentsList.get(1).onModel().assertThat().field("content").is(sameComment); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify add comments from node with invalid network id returns status code 401") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void addCommentsWithInvalidNetworkId() throws Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - - networkUserModel.setDomain("invalidNetwork"); - restClient.authenticateUser(networkUserModel).withCoreAPI().usingResource(file).addComments(comment1,comment2); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify add comments from node with empty network id returns status code 401") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void addCommentsWithEmptyNetworkId() throws Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - - networkUserModel.setDomain(""); - restClient.authenticateUser(networkUserModel).withCoreAPI().usingResource(file).addComments(comment1,comment2); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, - description = "Verify that comments cannot be added to another comment") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void addCommentsToAComment() throws JsonToModelConversionException, Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - RestCommentModel commentEntry = restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingResource(file).addComment(comment1); - file.setNodeRef(commentEntry.getId()); - - restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingResource(file).addComments(comment1, comment2); - - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.CANNOT_COMMENT); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, - description = "Verify that comments cannot be added to a tag") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void addCommentsToATag() throws JsonToModelConversionException, Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - RestTagModel tag = restClient.withCoreAPI().usingResource(file).addTag("randomTag"); - - file.setNodeRef(tag.getId()); - - restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingResource(file).addComments(comment1, comment2); - - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.CANNOT_COMMENT); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Using Manager user verify that you can provide a large string for one comment") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void addLongCommentsWithManagerAndCheckThatCommentIsReturned() throws Exception - { - document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - String longString = RandomStringUtils.randomAlphanumeric(10000); - String longString1 = RandomStringUtils.randomAlphanumeric(90000); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(document).addComments(longString, longString1); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", longString); - comments.assertThat().entriesListContains("content", longString1); - comments.assertThat().paginationField("totalItems").is("2"); - comments.assertThat().paginationField("count").is("2"); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Using Manager user verify that you can provide a short string for one comment") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void addShortCommentsWithManagerAndCheckThatCommentIsReturned() throws Exception - { - document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - String shortString = RandomStringUtils.randomAlphanumeric(2); - String shortString1 = RandomStringUtils.randomAlphanumeric(1); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(document).addComments(shortString, shortString1); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", shortString); - comments.assertThat().entriesListContains("content", shortString1); - comments.assertThat().paginationField("totalItems").is("2"); - comments.assertThat().paginationField("count").is("2"); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Using Collaborator user verify that you can provide a string with special characters for one comment") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void addCommentsWithSpecialCharsWithCollaboratorCheckCommentIsReturned() throws Exception - { - document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - String specialCharsString = "!@#$%^&*()'\".,<>-_+=|\\"; - String shortString = RandomStringUtils.randomAlphanumeric(2); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingResource(document).addComments(specialCharsString, shortString); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", specialCharsString); - comments.assertThat().entriesListContains("content", shortString); - comments.assertThat().paginationField("totalItems").is("2"); - comments.assertThat().paginationField("count").is("2"); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Using Manager user verify that you can not provide an empty string for one comment") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void addEmptyStringCommentsWithManagerCheckCommentIsReturned() throws Exception - { - document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - String emptyString = ""; - String spaceString = " "; - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(document).addComments(emptyString, spaceString); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(RestErrorModel.NON_NULL_COMMENT); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Using Collaborator user verify that you can provide several comments in one request") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void addSeveralCommentsWithCollaboratorCheckCommentsAreReturned() throws Exception - { - document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - String charString = RandomStringUtils.randomAlphanumeric(10); - String charString1 = RandomStringUtils.randomAlphanumeric(10); - String charString2 = RandomStringUtils.randomAlphanumeric(10); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingResource(document).addComments(comment1, comment2, charString, charString1, charString2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", comment1); - comments.assertThat().paginationField("totalItems").is("5"); - comments.assertThat().paginationField("count").is("5"); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Provide invalid request body parameter and check default error model schema") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void invalidRequestBodyParameterCheckErrorModelSchema() throws Exception - { - document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(adminUserModel).withCoreAPI(); - String postBody = JsonBodyGenerator.keyValueJson("content2", comment1); - RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, postBody, "nodes/{nodeId}/comments", document.getNodeRef()); - restClient.processModel(RestCommentModel.class, request); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - restClient.assertLastError().containsErrorKey(String.format(RestErrorModel.UNRECOGNIZED_FIELD, "content2")); - restClient.assertLastError().containsSummary(String.format(RestErrorModel.UNRECOGNIZED_FIELD, "content2")); - restClient.assertLastError().descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - restClient.assertLastError().stackTraceIs(RestErrorModel.STACKTRACE); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/comments/DeleteCommentTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/comments/DeleteCommentTests.java deleted file mode 100644 index ee44818cc..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/comments/DeleteCommentTests.java +++ /dev/null @@ -1,295 +0,0 @@ -package org.alfresco.service.search.rest.comments; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestCommentModel; -import org.alfresco.rest.model.RestCommentModelsCollection; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class DeleteCommentTests extends RestTest -{ - private UserModel adminUserModel, networkUserModel; - - private FileModel document; - private SiteModel siteModel; - private RestCommentModelsCollection comments; - private RestCommentModel commentModel; - private ListUserWithRoles usersWithRoles; - private String commentText = "This is a new comment"; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - networkUserModel = dataUser.createRandomTestUser(); - restClient.authenticateUser(adminUserModel); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Admin user deletes comments with Rest API and status code is 204") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) - public void adminIsAbleToDeleteComments() throws Exception - { - restClient.authenticateUser(adminUserModel); - commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment"); - restClient.withCoreAPI().usingResource(document).deleteComment(commentModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify User gets status code 401 if authentication call fails") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) -// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void userIsNotAbleToDeleteCommentIfAuthenticationFails() throws Exception - { - restClient.authenticateUser(adminUserModel); - commentModel = restClient.withCoreAPI().usingResource(document).addComment("New comment addded by admin"); - UserModel nonexistentModel = new UserModel("nonexistentUser", "nonexistentPassword"); - restClient.authenticateUser(nonexistentModel); - restClient.withCoreAPI().usingResource(document).deleteComment(commentModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Manager user deletes own comments and status code is 204") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void managerIsAbleToDeleteComments() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - commentModel = restClient.withCoreAPI().usingResource(document).addComment("New comment added by Manager"); - restClient.withCoreAPI().usingResource(document).deleteComment(commentModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user deletes own comments and status code is 204") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void collaboratorIsAbleToDeleteComments() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - commentModel = restClient.withCoreAPI().usingResource(document).addComment("New comment added by Collaborator"); - restClient.withCoreAPI().usingResource(document).deleteComment(commentModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Contributor user deletes own comments and status code is 204") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void contributorIsAbleToDeleteComments() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - commentModel = restClient.withCoreAPI().usingResource(document).addComment("New comment added by Contributor"); - restClient.withCoreAPI().usingResource(document).deleteComment(commentModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Consumer user can't delete comments created by admin user and status code is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void consumerIsNotAbleToDeleteComments() throws Exception - { - restClient.authenticateUser(adminUserModel); - commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment"); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.withCoreAPI().usingResource(document).deleteComment(commentModel); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Admin user can't delete comments with inexistent ID and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void userIsNotAbleToDeleteInexistentComment() throws Exception - { - restClient.authenticateUser(adminUserModel); - commentModel = new RestCommentModel(); - commentModel.setId("inexistent"); - restClient.withCoreAPI().usingResource(document).deleteComment(commentModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Admin user can't delete comments with inexistend NodeId and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void userIsNotAbleToDeleteCommentWithInexistentNodeId() throws Exception - { - restClient.authenticateUser(adminUserModel); - commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment"); - FileModel inexistentDocument = new FileModel(); - inexistentDocument.setNodeRef("inexistent"); - restClient.withCoreAPI().usingResource(inexistentDocument).deleteComment(commentModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Admin user can't delete deleted comments and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void userIsNotAbleToDeleteDeletedComment() throws Exception - { - restClient.authenticateUser(adminUserModel); - commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment"); - restClient.withCoreAPI().usingResource(document).deleteComment(commentModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingResource(document).deleteComment(commentModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS }, - executionType = ExecutionType.REGRESSION, description = "Verify Manager user deletes comment created by admin" - + " and status code is 204. Check with getComments for validation") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void managerIsAbleToDeleteCommentCreatedByOthers() throws Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - - commentModel = restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingResource(file).addComment(commentText); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(file).deleteComment(commentModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListDoesNotContain("content", commentText); - comments.getPagination().assertThat().field("totalItems").is("0").and().field("count").is("0"); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS }, - executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user can delete comment created by self" - + " and status code is 204. Check with getComments for validation") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void collaboratorIsAbleToDeleteCommentCreatedBySelf() throws Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - - commentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingResource(file).addComment(commentText); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.withCoreAPI().usingResource(file).deleteComment(commentModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListDoesNotContain("content", commentText); - comments.getPagination().assertThat().field("totalItems").is("0").and().field("count").is("0"); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS }, - executionType = ExecutionType.REGRESSION, description = "Verify Contributor user deletes comment created by self" - + " and status code is 204. Check with getComments for validation") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - @Bug(id = "ACE-4614") - public void contributorIsAbleToDeleteCommentCreatedBySelf() throws Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - - commentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) - .withCoreAPI().usingResource(file).addComment(commentText); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.withCoreAPI().usingResource(file).deleteComment(commentModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListDoesNotContain("content", commentText); - comments.getPagination().assertThat().field("totalItems").is("0").and().field("count").is("0"); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS }, - executionType = ExecutionType.REGRESSION, description = "Verify Consumer user cannot delete comment created by admin" - + " and status code is 403. Check with getComments for validation and check default error model schema.") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void consumerIsNotAbleToDeleteCommentCreatedByOthersDefaultErrorModelSchema() throws Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - - commentModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(commentText); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .withCoreAPI().usingResource(file).deleteComment(commentModel); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .statusCodeIs(HttpStatus.FORBIDDEN) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE) - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY); - - comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", commentText); - comments.getPagination().assertThat().field("totalItems").is("1").and().field("count").is("1"); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS }, - executionType = ExecutionType.REGRESSION, description = "Verify Manager can delete comment with version number") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void usingManagerDeleteCommentWithVersionNumber() throws Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - dataContent.usingAdmin().usingResource(file).updateContent("updated content to increase version number"); - - commentModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(commentText); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(file).deleteComment(commentModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS }, - executionType = ExecutionType.REGRESSION, description = "Verify Manager user cannot delete comment with invalid node " - + "and status code is 404. Check with getComments for validation") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void usingManagerDeleteCommentWithInvalidNode() throws Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - - commentModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(commentText); - file.setNodeRef("invalid"); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(file).deleteComment(commentModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(file.getNodeRef() + " was not found"); - - comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(file.getNodeRef() + " was not found"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS}, executionType = ExecutionType.REGRESSION, - description = "Verify deleteComment from node with invalid network id returns status code 401") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void deleteCommentWithInvalidNetworkId() throws Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - - commentModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(commentText); - networkUserModel.setDomain("invalidNetwork"); - restClient.authenticateUser(networkUserModel).withCoreAPI().usingResource(file).deleteComment(commentModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS }, - executionType = ExecutionType.REGRESSION, description = "Verify deleteComment from node with empty network id returns status code 401") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void deleteCommentWithEmptyNetworkId() throws Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - - commentModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(commentText); - networkUserModel.setDomain(""); - restClient.authenticateUser(networkUserModel).withCoreAPI().usingResource(file).deleteComment(commentModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/comments/GetCommentsTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/comments/GetCommentsTests.java deleted file mode 100644 index 23670eb81..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/comments/GetCommentsTests.java +++ /dev/null @@ -1,422 +0,0 @@ -package org.alfresco.service.search.rest.comments; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestCommentModelsCollection; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FileType; -import org.alfresco.utility.model.LinkModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class GetCommentsTests extends RestTest -{ - private FileModel file, document, document1; - private SiteModel siteModel, privateSiteModel; - private UserModel adminUserModel, userModel, networkUserModel; - private ListUserWithRoles usersWithRoles; - private String comment = "This is a new comment"; - private String comment2 = "This is a 2nd comment"; - private String comment3 = "This is a 3rd comment"; - private RestCommentModelsCollection comments; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - networkUserModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - privateSiteModel = dataSite.usingUser(adminUserModel).createPrivateRandomSite(); - document = dataContent.usingSite(privateSiteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - document1 = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(adminUserModel).withCoreAPI() - .usingResource(document1).addComment(comment); - restClient.withCoreAPI().usingResource(document).addComment(comment); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.withCoreAPI().usingResource(document).addComment(comment2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.withCoreAPI().usingResource(document).addComment(comment3); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.SANITY, - description= "Verify Admin user gets comments with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) - public void adminIsAbleToRetrieveComments() throws Exception - { - comments = restClient.authenticateUser(adminUserModel).withCoreAPI() - .usingResource(document1).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", comment); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.SANITY, - description= "Verify Manager user gets status code 401 if authentication call fails") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) -// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void managerIsNotAbleToRetrieveCommentIfAuthenticationFails() throws Exception - { - UserModel nonexistentModel = new UserModel("nonexistentUser", "nonexistentPassword"); - restClient.authenticateUser(nonexistentModel).withCoreAPI() - .usingResource(document1).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify Manager user gets comments created by admin user with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void managerIsAbleToRetrieveComments() throws Exception - { - comments = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI() - .usingResource(document1).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", comment); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify Contributor user gets comments created by admin user with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void contributorIsAbleToRetrieveComments() throws Exception - { - comments = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI() - .usingResource(document1).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", comment); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify Collaborator user gets comments created by admin user with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void collaboratorIsAbleToRetrieveComments() throws Exception - { - comments = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI() - .usingResource(document1).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", comment); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify Consumer user gets comments created by admin user with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void consumerIsAbleToRetrieveComments() throws Exception - { - comments = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI() - .usingResource(document1).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", comment); - } - - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify Manager user gets comments created by another user and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void managerIsAbleToRetrieveCommentsCreatedByAnotherUser() throws Exception - { - userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); - String contentManager = "This is a new comment added by " + userModel.getUsername(); - restClient.authenticateUser(userModel).withCoreAPI() - .usingResource(document1).addComment(contentManager); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - comments = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI() - .usingResource(document1).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", contentManager) - .and().entriesListContains("content", comment); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify admin user gets comments created by another user and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void adminIsAbleToRetrieveCommentsCreatedByAnotherUser() throws Exception - { - userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); - String contentCollaborator = "This is a new comment added by " + userModel.getUsername(); - restClient.authenticateUser(userModel).withCoreAPI() - .usingResource(document1).addComment(contentCollaborator); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - comments = restClient.authenticateUser(adminUserModel).withCoreAPI() - .usingResource(document1).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", contentCollaborator) - .and().entriesListContains("content", comment); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify request returns status 403 if the user does not have permission read comments on the node") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void uninvitedUserCanNotGetCommentsFromPrivateSite() throws Exception - { - restClient.authenticateUser(userModel).withCoreAPI() - .usingResource(document).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify user gets comments without the first 2 and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void skipFirst2Comments() throws Exception - { - comments = restClient.authenticateUser(adminUserModel).withParams("skipCount=2") - .withCoreAPI().usingResource(document).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", comment) - .and().paginationField("count").is("1"); - comments.assertThat().paginationField("skipCount").is("2"); - comments.assertThat().paginationField("totalItems").is("3"); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify invalid request returns status code 400 for invalid maxItems or skipCount") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void checkStatusCodeForInvalidMaxItems() throws Exception - { - restClient.authenticateUser(adminUserModel).withParams("maxItems=0") - .withCoreAPI().usingResource(document).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary("Only positive values supported for maxItems"); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify User can't get comments for node with ID that does not exist and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void userCanNotGetCommentsOnNonExistentFile() throws Exception - { - FileModel nonexistentFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); - nonexistentFile.setNodeRef("ABC"); - restClient.authenticateUser(adminUserModel).withCoreAPI() - .usingResource(nonexistentFile).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, nonexistentFile.getNodeRef())); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify User can't get comments for node that exists but is not a document or a folder and status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void userCanNotGetCommentsOnLink() throws Exception - { - LinkModel link = dataLink.usingAdmin().usingSite(siteModel).createRandomLink(); - FileModel fileWithNodeRefFromLink = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); - fileWithNodeRefFromLink.setNodeRef(link.getNodeRef().replace("workspace://SpacesStore/", "workspace%3A%2F%2FSpacesStore%2F")); - restClient.authenticateUser(adminUserModel).withCoreAPI() - .usingResource(fileWithNodeRefFromLink).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, fileWithNodeRefFromLink.getNodeRef())) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify get comments from node with invalid network id returns status code 401") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void getCommentsWithInvalidNetwork() throws Exception - { - networkUserModel.setDomain("invalidNetwork"); - restClient.authenticateUser(networkUserModel).withCoreAPI().usingResource(document).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify get comments from node with empty network id returns status code 401") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void getCommentsWithEmptyNetwork() throws Exception - { - networkUserModel.setDomain(""); - restClient.authenticateUser(networkUserModel).withCoreAPI().usingResource(document).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify that if manager adds one comment, it will be returned in getComments response") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void addCommentWithManagerAndCheckThatCommentIsReturned() throws Exception - { - file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(file).addComment(comment); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", comment) - .getPagination().assertThat().field("totalItems").is("1") - .assertThat().field("count").is("1"); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify that if collaborator adds one comment, it will be returned in getComments response") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void addCommentWithCollaboratorAndCheckThatCommentIsReturned() throws Exception - { - file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingResource(file).addComment(comment); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", comment) - .getPagination().assertThat().field("totalItems").is("1") - .assertThat().field("count").is("1"); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify that if contributor adds one comment, it will be returned in getComments response") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - @Bug(id = "ACE-4614") - public void addCommentWithContributorAndCheckThatCommentIsReturned() throws Exception - { - file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) - .withCoreAPI().usingResource(file).addComment(comment); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", comment) - .getPagination().assertThat().field("totalItems").is("1") - .assertThat().field("count").is("1"); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify that consumer cannot add a comment and no comments will be returned in getComments response") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void addCommentWithConsumerAndCheckThatCommentIsNotReturned() throws Exception - { - file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .withCoreAPI().usingResource(file).addComment(comment); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - - comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().paginationField("totalItems").is("0"); - comments.assertThat().paginationField("count").is("0"); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Add one comment with Manager and check that returned person is the right one") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void addCommentWithManagerCheckReturnedPersonIsTheRightOne() throws Exception - { - file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - UserModel user1 = dataUser.createRandomTestUser(); - dataUser.addUserToSite(user1, siteModel, UserRole.SiteManager); - - restClient.authenticateUser(user1).withCoreAPI().usingResource(file).addComment(comment); - comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); - comments.getOneRandomEntry().onModel().getCreatedBy().assertThat().field("firstName").is(user1.getUsername() + " FirstName") - .assertThat().field("lastName").is("LN-" + user1.getUsername()); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Add one comment with Collaborator and check that returned company details are correct") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void addCommentWithCollaboratorCheckReturnedCompanyDetails() throws Exception - { - file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(file).addComment(comment); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); - comments.getOneRandomEntry().onModel().getCreatedBy().getCompany() - .assertThat().field("organization").isNull() - .assertThat().field("address1").isNull() - .assertThat().field("address2").isNull() - .assertThat().field("address3").isNull() - .assertThat().field("postcode").isNull() - .assertThat().field("telephone").isNull() - .assertThat().field("fax").isNull() - .assertThat().field("email").isNull(); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Add 2 comments with Manager and Collaborator users and verify valid request using skipCount. Check that param is applied") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void addTwoCommentsWithManagerCollaboratorVerifySkipCountParamIsApplied() throws Exception - { - file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(file).addComment(comment); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(file).addComment(comment2); - - comments = restClient.authenticateUser(adminUserModel).withParams("skipCount=1") - .withCoreAPI().usingResource(file).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", comment) - .and().paginationField("count").is("1"); - comments.assertThat().paginationField("skipCount").is("1"); - comments.assertThat().paginationField("totalItems").is("2"); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Add 2 comments with Admin and Collaborator users and verify valid request using maxItems. Check that param is applied") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void addTwoCommentsWithAdminCollaboratorVerifyMaxItemsParamIsApplied() throws Exception - { - file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(comment); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(file).addComment(comment2); - - comments = restClient.authenticateUser(adminUserModel).withParams("maxItems=1") - .withCoreAPI().usingResource(file).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", comment2) - .and().paginationField("count").is("1"); - comments.assertThat().paginationField("totalItems").is("2"); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Add 2 comments with Manager and Admin users and verify valid request using properties. Check that param is applied") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void addTwoCommentsWithAdminManagerVerifyPropertiesParamIsApplied() throws Exception - { - file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(comment); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(file).addComment(comment2); - - comments = restClient.authenticateUser(adminUserModel).withParams("properties=createdBy,modifiedBy") - .withCoreAPI().usingResource(file).getNodeComments(); - comments.assertThat().entriesListIsNotEmpty() - .and().paginationField("count").is("2"); - comments.assertThat().paginationField("totalItems").is("2"); - - comments.getEntries().get(0).onModel().getCreatedBy() - .assertThat().field("firstName").is(usersWithRoles.getOneUserWithRole(UserRole.SiteManager).getUsername() + " FirstName") - .assertThat().field("lastName").is("LN-" + usersWithRoles.getOneUserWithRole(UserRole.SiteManager).getUsername()); - - comments.getEntries().get(1).onModel().getCreatedBy() - .assertThat().field("firstName").is("Administrator") - .assertThat().field("id").is("admin"); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Check default error model schema") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void addTwoCommentsWithManagerCheckDefaultErrorModelSchema() throws Exception - { - file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(file).addComments(comment, comment2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).usingParams("maxItems=0").getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); - restClient.assertLastError().containsErrorKey(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); - restClient.assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); - restClient.assertLastError().descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - restClient.assertLastError().stackTraceIs(RestErrorModel.STACKTRACE); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/comments/UpdateCommentTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/comments/UpdateCommentTests.java deleted file mode 100644 index 5ee3a596f..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/comments/UpdateCommentTests.java +++ /dev/null @@ -1,461 +0,0 @@ -package org.alfresco.service.search.rest.comments; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestCommentModel; -import org.alfresco.rest.model.RestCommentModelsCollection; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FileType; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.LinkModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.apache.commons.lang3.RandomStringUtils; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class UpdateCommentTests extends RestTest -{ - private UserModel adminUserModel, networkUserModel; - private FileModel document; - private SiteModel siteModel; - private RestCommentModel commentModel, returnedCommentModel; - private RestCommentModelsCollection comments;; - private ListUserWithRoles usersWithRoles; - private String firstComment = "This is a new comment"; - private String updatedComment = "This is the updated comment"; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - restClient.authenticateUser(adminUserModel); - networkUserModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - - document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Admin user updates comments and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) - public void adminIsAbleToUpdateHisComment() throws Exception - { - restClient.authenticateUser(adminUserModel); - commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by admin"); - String updatedContent = "This is the updated comment with admin user"; - restClient.withCoreAPI().usingResource(document).updateComment(commentModel, updatedContent) - .assertThat().field("content").isNotEmpty() - .and().field("content").is(updatedContent); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user gets status code 401 on update comment call") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) -// @Bug(id = "MNT-16904", description = "fails only on environment with tenants") - public void unauthenticatedUserIsNotAbleToUpdateComment() throws Exception - { - restClient.authenticateUser(adminUserModel); - commentModel = restClient.withCoreAPI().usingResource(document).addComment("To be updated by unauthenticated user."); - UserModel incorrectUserModel = new UserModel("userName", "password"); - restClient.authenticateUser(incorrectUserModel) - .withCoreAPI().usingResource(document).updateComment(commentModel, "try to update"); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify entry content in response") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) - public void checkEntryContentInResponse() throws Exception - { - restClient.authenticateUser(adminUserModel); - commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by admin"); - commentModel = restClient.withCoreAPI().usingResource(document).updateComment(commentModel, "This is the updated comment with admin user"); - restClient.assertStatusCodeIs(HttpStatus.OK); - commentModel.assertThat().field("content").is("This is the updated comment with admin user"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Manager user updates comments created by admin user and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void managerIsAbleToUpdateHisComment() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by manager"); - restClient.withCoreAPI().usingResource(document).updateComment(commentModel, "This is the updated comment with Manager user") - .and().field("content").is("This is the updated comment with Manager user") - .and().field("canEdit").is(true) - .and().field("canDelete").is(true); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Contributor user can update his own comment and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void contributorIsAbleToUpdateHisComment() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by contributor"); - String updatedContent = "This is the updated comment with Contributor user"; - restClient.withCoreAPI().usingResource(document).updateComment(commentModel, updatedContent); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Consumer user can not update comments created by admin user and status code is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void consumerIsNotAbleToUpdateComment() throws Exception - { - restClient.authenticateUser(adminUserModel); - commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by admin"); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.withCoreAPI().usingResource(document).updateComment(commentModel, "This is the updated comment with Consumer user"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user can update his own comment and status code is 200") -// @Bug(id="REPO-1011") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void collaboratorIsAbleToUpdateHisComment() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by collaborator"); - restClient.withCoreAPI().usingResource(document).updateComment(commentModel, "This is the updated comment with Collaborator user"); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user can not update comments of another user and status code is 200") -// @Bug(id="MNT-2502",description="seems it's one old issue: also logged as MNT-2502, MNT-2346") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void collaboratorIsNotAbleToUpdateCommentOfAnotherUser() throws Exception - { - restClient.authenticateUser(adminUserModel); - commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by admin"); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingResource(document).updateComment(commentModel, "This is the updated comment with Collaborator user"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify update comment with inexistent nodeId returns status code 404") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void canNotUpdateCommentIfNodeIdIsNotSet() throws Exception - { - restClient.authenticateUser(adminUserModel); - - FolderModel content = FolderModel.getRandomFolderModel(); - content.setNodeRef("node ref that does not exist"); - commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment"); - restClient.withCoreAPI().usingResource(content).updateComment(commentModel, "This is the updated comment."); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary("node ref that does not exist was not found"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify if commentId is not set the status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void canNotUpdateCommentIfCommentIdIsNotSet() throws Exception - { - restClient.authenticateUser(adminUserModel); - - RestCommentModel comment = new RestCommentModel(); - String id = "comment id that does not exist"; - comment.setId(id); - restClient.withCoreAPI().usingResource(document).updateComment(comment, "This is the updated comment."); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, id)); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify can not update comment if NodeId is neither document or folder and returns status code 405") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void canNotUpdateCommentIfNodeIdIsNeitherDocumentOrFolder() throws Exception - { - FileModel content = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); - content = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(adminUserModel); - commentModel = restClient.withCoreAPI().usingResource(content).addComment("This is a new comment"); - - LinkModel link = dataLink.usingAdmin().usingSite(siteModel).createRandomLink(); - content.setNodeRef(link.getNodeRef().replace("workspace://SpacesStore/", "workspace%3A%2F%2FSpacesStore%2F")); - - restClient.withCoreAPI().usingResource(content).updateComment(commentModel, "This is the updated comment."); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, content.getNodeRef())) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Admin user is not able to update with empty comment body and status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void adminIsNotAbleToUpdateWithEmptyCommentBody() throws Exception - { - restClient.authenticateUser(adminUserModel); - commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by admin"); - restClient.withCoreAPI().usingResource(document).updateComment(commentModel, ""); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary("An invalid argument was received"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify updated comment by Manager is listed when calling getComments and status code is 200") -// @Bug(id="REPO-1011") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void updatedCommentByManagerIsListed() throws Exception - { - commentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingResource(document).addComment("This is a new comment added by collaborator"); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI() - .usingResource(document).updateComment(commentModel, "This is the updated comment with Manager user"); - comments = restClient.withCoreAPI().usingResource(document).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", "This is the updated comment with Manager user"); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify Manager user can update a comment with a large string") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void managerIsAbleToUpdateACommentWithALargeString() throws Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - String longString = RandomStringUtils.randomAlphanumeric(10000); - - commentModel = restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingResource(file).addComment(firstComment); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedCommentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(file).updateComment(commentModel, longString); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCommentModel.assertThat().field("content").is(longString); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify Manager user can update a comment with a short string") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void managerIsAbleToUpdateACommentWithAShortString() throws Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - String shortString = RandomStringUtils.randomAlphanumeric(2); - - commentModel = restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingResource(file).addComment(firstComment); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedCommentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(file).updateComment(commentModel, shortString); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCommentModel.assertThat().field("content").is(shortString); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify Collaborator user can update a comment with special characters") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void collaboratorIsAbleToUpdateACommentThatContainsSpecialChars() throws Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - String specialChars = "!@#$%^&*()'\".,<>-_+=|\\"; - - commentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingResource(file).addComment(firstComment); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedCommentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingResource(file).updateComment(commentModel, specialChars); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCommentModel.assertThat().field("content").is(specialChars); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Check that you cannot update comment with Consumer then call getComments and check new comment is not listed") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void cannotUpdateCommentWithConsumerCallGetComments() throws Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - - commentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingResource(file).addComment(firstComment); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingResource(file).updateComment(commentModel, updatedComment); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - - comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", firstComment) - .and().entriesListDoesNotContain("content", updatedComment) - .and().paginationField("totalItems").is("1"); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Update comment with Contributor then call getComments and check new comment is listed") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - @Bug(id = "ACE-4614") - public void updateCommentWithContributorCallGetComments() throws Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - - commentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) - .withCoreAPI().usingResource(file).addComment(firstComment); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingResource(file).updateComment(commentModel, updatedComment); - restClient.assertStatusCodeIs(HttpStatus.OK); - - comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", updatedComment) - .and().entriesListDoesNotContain("content", firstComment) - .and().paginationField("totalItems").is("1"); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Update comment with Collaborator then call getComments and check new comment is listed") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void updateCommentWithCollaboratorCallGetComments() throws Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - - commentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingResource(file).addComment(firstComment); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(file).updateComment(commentModel, updatedComment); - restClient.assertStatusCodeIs(HttpStatus.OK); - - comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", updatedComment) - .and().entriesListDoesNotContain("content", firstComment) - .and().paginationField("totalItems").is("1"); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Update comment with Manager then check modified by information in response") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void updateCommentWithManagerCheckModifiedBy() throws Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - UserModel manager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); - - commentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingResource(file).addComment(firstComment); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedCommentModel = restClient.authenticateUser(manager).withCoreAPI().usingResource(file).updateComment(commentModel, updatedComment); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCommentModel.assertThat().field("modifiedBy.id").is(manager.getUsername()) - .and().field("content").is(updatedComment); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Delete comment with Admin then try to update it") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void deleteCommentThenTryToUpdateIt() throws Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - - commentModel = restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingResource(file).addComment(firstComment); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.withCoreAPI().usingResource(file).deleteComment(commentModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingResource(file).updateComment(commentModel, updatedComment); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify Manager user can update a comment with multi byte content") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void managerIsAbleToUpdateACommentWithMultiByteContent() throws Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - String multiByte = "\ufeff\u6768\u6728\u91d1"; - - commentModel = restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingResource(file).addComment(firstComment); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedCommentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(file).updateComment(commentModel, multiByte); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCommentModel.assertThat().field("content").is(multiByte); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify Admin user can update a comment with properties parameter") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void adminIsAbleToUpdateACommentWithPropertiesParameter() throws Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - - commentModel = restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingResource(file).addComment(firstComment); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - UserModel manager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); - - returnedCommentModel = restClient.authenticateUser(manager) - .withParams("properties=createdBy,modifiedBy,canEdit,canDelete").withCoreAPI().usingResource(file).updateComment(commentModel, updatedComment); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCommentModel.assertThat().field("createdBy.id").is(adminUserModel.getUsername()) - .assertThat().field("modifiedBy.id").is(manager.getUsername()) - .assertThat().fieldsCount().is(4); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, - description = "Update comment with invalid node") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void updateCommentUsingInvalidNodeId() throws Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - - commentModel = restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingResource(file).addComment(firstComment); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - file.setNodeRef(RandomStringUtils.randomAlphanumeric(20)); - restClient.withCoreAPI().usingResource(file).updateComment(commentModel, updatedComment); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, file.getNodeRef())); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify update comment from node with invalid network id returns status code 401") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void updateCommentWithInvalidNetworkId() throws Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - - commentModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(firstComment); - networkUserModel.setDomain("invalidNetwork"); - restClient.authenticateUser(networkUserModel).withCoreAPI().usingResource(file).updateComment(commentModel, updatedComment); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify User can not update comment to a not joined private site. Status code returned is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void userCanNotUpdateCommentToANotJoinedPrivateSiteDefaultErrorModelSchema() throws Exception - { - UserModel newUser = dataUser.createRandomTestUser(); - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - - commentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(file).addComment(firstComment); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(newUser).withCoreAPI().usingResource(file).updateComment(commentModel, updatedComment); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE) - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/RestDemoTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/RestDemoTests.java deleted file mode 100644 index 0792a9bc4..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/RestDemoTests.java +++ /dev/null @@ -1,104 +0,0 @@ -package org.alfresco.service.search.rest.demo; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.dataprep.SiteService.Visibility; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.exception.DataPreparationException; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.UserModel; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class RestDemoTests extends RestTest -{ - private UserModel userModel; - private SiteModel siteModel; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws DataPreparationException - { - userModel = dataUser.getAdminUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - restClient.authenticateUser(userModel); - } - - /** - * Data preparation – create site with custom details
        - * Perform GET sites call using admin user
        - * Check that created site is included in response
        - * Perform GET site call, validate that site title, description and visibility are correct
        - * - * @throws JsonToModelConversionException - * @throws Exception - */ - @Test(groups = { "demo" }) - public void adminRetrievesCorrectSiteDetails() throws JsonToModelConversionException, Exception - { - restClient.withCoreAPI().getSites().assertThat() - .entriesListContains("id", siteModel.getId()); - - restClient.withCoreAPI().usingSite(siteModel).getSite() - .assertThat().field("id").isNotNull() - .assertThat().field("description").is(siteModel.getDescription()) - .assertThat().field("title").is(siteModel.getTitle()) - .assertThat().field("visibility").is(Visibility.PUBLIC); - } - - /** - * Data preparation – create site and document on server
        - * POST one comment to file using admin user
        - * Perform GET comments, check the new one is listed
        - * Update existing comment using PUT call, check that comment content is updated
        - * @throws Exception - */ - @Test(groups = { "demo" }) - public void adminCanPostAndUpdateComments() throws Exception - { - FileModel fileModel = dataContent.usingUser(userModel) - .usingResource(FolderModel.getSharedFolderModel()) - .createContent(DocumentType.TEXT_PLAIN); - // add new comment - restClient.withCoreAPI().usingResource(fileModel).addComment("This is a new comment"); - restClient.withCoreAPI().usingResource(fileModel).getNodeComments() - .assertThat().entriesListIsNotEmpty().and() - .entriesListContains("content", "This is a new comment"); - } - - /** - * Data preparation – create site and a new user
        - * As admin, add user as Consumer to site as a new site member using POST call
        - * Update site member role to Manager using PUT call
        - * Delete site member using DELETE call
        - * - * @throws DataPreparationException - * @throws JsonToModelConversionException - */ - @Test(groups = { "demo" }) - public void adminCanAddAndUpdateSiteMemberDetails() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteConsumer); - - // add user as Consumer to site - restClient.withCoreAPI().usingSite(siteModel).addPerson(testUser); - restClient.withCoreAPI().usingSite(siteModel).getSiteMembers().assertThat().entriesListContains("id", testUser.getUsername()) - .when().getSiteMember(testUser.getUsername()) - .assertSiteMemberHasRole(UserRole.SiteConsumer); - - // update site member to Manager - testUser.setUserRole(UserRole.SiteCollaborator); - restClient.withCoreAPI().usingSite(siteModel).updateSiteMember(testUser); - restClient.withCoreAPI().usingSite(siteModel).getSiteMembers().and() - .entriesListContains("id", testUser.getUsername()) - .when().getSiteMember(testUser.getUsername()) - .assertSiteMemberHasRole(UserRole.SiteCollaborator); - - restClient.withCoreAPI().usingSite(siteModel).deleteSiteMember(testUser); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } -} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/SampleCommentsTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/SampleCommentsTests.java deleted file mode 100644 index d7cd27d76..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/SampleCommentsTests.java +++ /dev/null @@ -1,56 +0,0 @@ -package org.alfresco.service.search.rest.demo; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestCommentModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.UserModel; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - - -public class SampleCommentsTests extends RestTest -{ - private UserModel userModel; - private FolderModel folderModel; - private SiteModel siteModel; - private FileModel document; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - userModel = dataUser.getAdminUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - restClient.authenticateUser(userModel); - document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - } - - @Test(groups = { "demo" }) - public void admiShouldAddComment() throws JsonToModelConversionException, Exception - { - restClient.withCoreAPI().usingResource(document).addComment("This is a new comment"); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - } - - @Test(groups = { "demo" }) - public void admiShouldRetrieveComments() throws Exception - { - restClient.withCoreAPI().usingResource(document).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { "demo" }) - public void adminShouldUpdateComment() throws JsonToModelConversionException, Exception - { - RestCommentModel commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment"); - - restClient.withCoreAPI().usingResource(document).updateComment(commentModel, "This is the updated comment with Collaborator user") - .assertThat().field("content").is("This is the updated comment with Collaborator user"); - } - -} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/SamplePeopleTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/SamplePeopleTests.java deleted file mode 100644 index 38ae35e47..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/SamplePeopleTests.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.alfresco.service.search.rest.demo; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.utility.exception.DataPreparationException; -import org.alfresco.utility.model.UserModel; -import org.apache.commons.lang3.RandomStringUtils; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - - -public class SamplePeopleTests extends RestTest -{ - private UserModel userModel; - private UserModel adminUser; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws DataPreparationException - { - userModel = dataUser.createUser(RandomStringUtils.randomAlphanumeric(20)); - adminUser = dataUser.getAdminUser(); - restClient.authenticateUser(adminUser); - } - - @Test(groups = { "demo" }) - public void adminShouldRetrievePerson() throws Exception - { - restClient.withCoreAPI().usingUser(userModel).getPerson().assertThat().field("id").isNotEmpty(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - -} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/SampleSitesTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/SampleSitesTests.java deleted file mode 100644 index 1c66115ab..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/SampleSitesTests.java +++ /dev/null @@ -1,79 +0,0 @@ -package org.alfresco.service.search.rest.demo; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.exception.DataPreparationException; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.UserModel; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - - -public class SampleSitesTests extends RestTest -{ - private UserModel userModel; - private SiteModel siteModel; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws DataPreparationException - { - userModel = dataUser.getAdminUser(); - restClient.authenticateUser(userModel); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - } - - @Test(groups = { "demo" }) - public void adminShouldGetSiteDetails() throws JsonToModelConversionException, Exception - { - restClient.withCoreAPI().usingSite(siteModel).getSite() - .assertThat().field("id").isNotNull(); - } - - @Test(groups = { "demo" }) - public void adminShouldGetSites() throws JsonToModelConversionException, Exception - { - restClient.withCoreAPI().usingSite(siteModel).getSite(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { "demo" }) - public void adminShouldAccessSites() throws JsonToModelConversionException, Exception - { - restClient.withCoreAPI().getSites().assertThat().entriesListIsNotEmpty(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { "demo" }) - public void adminShouldAccessResponsePagination() throws JsonToModelConversionException, Exception - { - restClient.withCoreAPI().getSites().assertThat().paginationExist(); - } - - @Test(groups = { "demo" }) - public void adminShouldAddNewSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteConsumer); - restClient.withCoreAPI().usingSite(siteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - } - - @Test(groups = { "demo" }) - public void adminShouldGetSiteFromSitesList() throws JsonToModelConversionException, Exception - { - restClient.withCoreAPI().getSites().assertThat().entriesListContains("id", siteModel.getId()); - } - - @Test(groups = { "demo" }) - public void adminShouldAccessSiteDetails() throws JsonToModelConversionException, Exception - { - restClient.withCoreAPI().usingSite(siteModel).getSite() - .assertThat().field("id").isNotNull() - .and().field("description").is(siteModel.getDescription()) - .and().field("title").is(siteModel.getTitle()) - .and().field("visibility").is(siteModel.getVisibility()); - } - -} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/workshop/RestApiDemoTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/workshop/RestApiDemoTests.java deleted file mode 100644 index fa450616e..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/workshop/RestApiDemoTests.java +++ /dev/null @@ -1,52 +0,0 @@ -package org.alfresco.service.search.rest.demo.workshop; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.UserModel; -import org.testng.annotations.Test; - -public class RestApiDemoTests extends RestTest -{ - /* - * Test steps: - * 1. create a user - * 2. create a site - * 3. create a second user - * 4. add the second user to site with a user role - * 5. call rest api call " GET sites/{siteId}/members" with first user authenticated - * Expected: the response contains the user added as a member to the site - */ - @Test(groups = { "demo" }) - public void verifyGetSiteMembersRestApiCall() throws Exception - { - UserModel user = dataUser.createRandomTestUser(); - SiteModel site = dataSite.usingUser(user).createPublicRandomSite(); - UserModel member = dataUser.createRandomTestUser(); - dataUser.usingUser(user).addUserToSite(member, site, UserRole.SiteCollaborator); - - //add here code for step 5 - - } - - /* - * Test steps: - * 1. create a user - * 2. create a site - * 3. create a second user - * 4. add the second user to site with a user role - * 5. call rest api call " GET sites/{siteId}/members/{personId}" with first user authenticated - * Expected: the response contains the user added as a member to the site - */ - - @Test(groups = { "demo" }) - public void verifyGetASiteMemberApiCall() throws Exception - { - UserModel user = dataUser.createRandomTestUser(); - SiteModel site = dataSite.usingUser(user).createPublicRandomSite(); - UserModel member = dataUser.createRandomTestUser(); - dataUser.usingUser(user).addUserToSite(member, site, UserRole.SiteCollaborator); - - //add here code for step 5 - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/workshop/RestApiWorkshopTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/workshop/RestApiWorkshopTests.java deleted file mode 100644 index 49f7fce0d..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/workshop/RestApiWorkshopTests.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.alfresco.service.search.rest.demo.workshop; - -import org.alfresco.service.search.rest.RestTest; -import org.testng.annotations.Test; - -/** - * - * Demo workshop for RestAPI test - * - */ -public class RestApiWorkshopTests extends RestTest -{ - @Test(groups = { "demo" }) - public void verifyGetSitesRestApiCall() throws Exception - { - // creating a random user in repository - - // create a new random site using your UserModel from above - - // using "siteApi", call get "/sites" Rest API and verify created site is present - - // verify status is OK - - } - - @Test(groups = { "demo" }) - public void verifyGetASiteRestApiCall() throws Exception - { - // creating a random user in repository - - // create a new random site using your UserModel from above - - // using "siteApi", call get "/sites/{siteId}" Rest API - // using "siteApi", verify created site is present - - // verify status is OK - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/discovery/DiscoveryTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/discovery/DiscoveryTests.java deleted file mode 100644 index 020555705..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/discovery/DiscoveryTests.java +++ /dev/null @@ -1,108 +0,0 @@ -package org.alfresco.service.search.rest.discovery; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -import org.alfresco.rest.core.RestResponse; -import org.alfresco.rest.model.RestDiscoveryModel; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class DiscoveryTests extends RestTest -{ - private UserModel adminModel, userModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminModel = dataUser.getAdminUser(); - userModel = dataUser.createRandomTestUser(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.DISCOVERY, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.DISCOVERY }, executionType = ExecutionType.SANITY, - description = "Sanity tests for GET /discovery endpoint") - public void getRepositoryInformation() throws Exception - { - // Get repository info from admin console - RestResponse adminConsoleRepoInfo = restClient.authenticateUser(adminModel).withAdminConsole().getAdminConsoleRepoInfo(); - String id = adminConsoleRepoInfo.getResponse().getBody().path("data.id"); - String edition = adminConsoleRepoInfo.getResponse().getBody().path("data.edition"); - String schema = adminConsoleRepoInfo.getResponse().getBody().path("data.schema"); - String version = adminConsoleRepoInfo.getResponse().getBody().path("data.version"); - - // Get repository info using Discovery API - RestDiscoveryModel response = restClient.authenticateUser(userModel).withDiscoveryAPI().getRepositoryInfo(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - // Compare information - response.getRepository().getVersion().assertThat().field("major").is(version.charAt(0)); - response.getRepository().getVersion().assertThat().field("minor").is(version.charAt(2)); - response.getRepository().getVersion().assertThat().field("patch").is(version.charAt(4)); - response.getRepository().getVersion().assertThat().field("schema").is(schema); - response.getRepository().getId().equals(id); - response.getRepository().getEdition().equals(edition); - response.getRepository().getStatus().assertThat().field("isReadOnly").is(false); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.DISCOVERY, TestGroup.ALL_AMPS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.DISCOVERY }, executionType = ExecutionType.SANITY, - description = "Sanity tests for GET /discovery endpoint") - public void getRepositoryInstalledModules() throws Exception - { - // Get repository info using Discovery API - restClient.authenticateUser(userModel).withDiscoveryAPI().getRepositoryInfo(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - // Check that all modules are present - List modules = restClient.onResponse().getResponse().jsonPath().getList("entry.repository.modules.id", String.class); - List expectedModules = Arrays.asList("alfresco-aos-module", "org.alfresco.integrations.google.docs", - "org_alfresco_integrations_S3Connector", "org_alfresco_module_xamconnector", - "org.alfresco.module.KofaxAddon", "alfresco-content-connector-for-salesforce-repo", - "alfresco-share-services", - // uncomment when REPO-4233 is fixed - // "alfresco-saml-repo", - "org_alfresco_device_sync_repo", - // uncomment when MM-785 is fixed: - // "org_alfresco_mm_repo", - "org.alfresco.module.TransformationServer", "alfresco-glacier-connector-repo"); - - expectedModules.forEach(module -> - assertTrue(modules.contains(module), String.format("Expected module %s is not installed", module))); - - // Check that all installed modules are in INSTALLED state - List modulesStates = restClient.onResponse().getResponse().jsonPath().getList("entry.repository.modules.installState", String.class); - //change back to assertEquals after REPO-4233 and MM-785 is fixed - assertTrue(Collections.frequency(modulesStates, "INSTALLED") >= expectedModules.size(), "Number of amps installed should match expected"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.DISCOVERY, TestGroup.SANITY, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.DISCOVERY }, executionType = ExecutionType.SANITY, - description = "Sanity tests for GET /discovery endpoint") - public void getDefaultRepositoryInstalledModules() throws Exception - { - // Get repository info using Discovery API - restClient.authenticateUser(userModel).withDiscoveryAPI().getRepositoryInfo(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - // Check that all modules are present - List modules = restClient.onResponse().getResponse().jsonPath().getList("entry.repository.modules.id", String.class); - assertTrue(modules.contains("alfresco-aos-module")); - assertTrue(modules.contains("org.alfresco.integrations.google.docs")); - assertTrue(modules.contains("alfresco-share-services")); - - // Check that all installed modules are in INSTALLED state - List modulesStates = restClient.onResponse().getResponse().jsonPath().getList("entry.repository.modules.installState", String.class); - assertEquals(Collections.frequency(modulesStates, "INSTALLED"), 3); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/downloads/DownloadsTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/downloads/DownloadsTests.java deleted file mode 100644 index b75b84a7a..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/downloads/DownloadsTests.java +++ /dev/null @@ -1,106 +0,0 @@ -package org.alfresco.service.search.rest.downloads; - -import javax.json.JsonObject; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.core.JsonBodyGenerator; -import org.alfresco.rest.model.RestDownloadsModel; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.utility.Utility; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.Assert; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class DownloadsTests extends RestTest -{ - private UserModel adminModel; - private FileModel document, document1; - private FolderModel folder; - private SiteModel siteModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminModel = dataUser.getAdminUser(); - siteModel = dataSite.usingUser(adminModel).createPrivateRandomSite(); - folder = dataContent.usingUser(adminModel).usingSite(siteModel).createFolder(); - document = dataContent.usingSite(siteModel).usingUser(adminModel).createContent(DocumentType.TEXT_PLAIN); - - // Create document1 based on existing resource - FileModel newFile = FileModel.getFileModelBasedOnTestDataFile("larger.pdf"); - newFile.setName("larger.pdf"); - document1 = dataContent.usingUser(adminModel).usingResource(folder).createContent(newFile); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.DOWNLOADS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.DOWNLOADS }, executionType = ExecutionType.SANITY, - description = "Sanity tests for GET /downloads/{downloadId} and POST /downloads") - public void createDownloadNodeAndGetInfo() throws Exception - { - // POST /downloads - JsonObject postBody = JsonBodyGenerator.defineJSON() - .add("nodeIds", JsonBodyGenerator.defineJSONArray().add(document.getNodeRefWithoutVersion())) - .build(); - RestDownloadsModel downloadModel = restClient.authenticateUser(adminModel).withCoreAPI().usingDownloads().createDownload(postBody.toString()); - restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); - downloadModel.assertThat().fieldsCount().is(6).and() - .field("id").isNotEmpty(); - - // GET /downloads/{downloadId} - Utility.sleep(500, 10000, () -> { - RestDownloadsModel downloadModel1 = restClient.authenticateUser(adminModel).withCoreAPI().usingDownloads(downloadModel).getDownload(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - downloadModel1.assertThat().fieldsCount().is(6).and() - .field("id").is(downloadModel.getId()).and() - .field("filesAdded").isGreaterThan(0).and() - .field("bytesAdded").isGreaterThan(0).and() - .field("totalBytes").isGreaterThan(0).and() - .field("totalFiles").isGreaterThan(0).and() - .field("status").is("DONE"); - }); - - // Check that download node has content - restClient.authenticateUser(adminModel).withCoreAPI().usingNode().getNodeContent(downloadModel.getId()); - - restClient.assertStatusCodeIs(HttpStatus.OK); - restClient.assertHeaderValueContains("Content-Type","application/octet-stream;charset=UTF-8"); - restClient.assertHeaderValueContains("Content-disposition",".zip"); - Assert.assertTrue(restClient.onResponse().getResponse().body().asInputStream().available() > 0); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.DOWNLOADS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.DOWNLOADS }, executionType = ExecutionType.SANITY, - description = "Sanity tests for DELETE /downloads/{downloadId}") - public void cancelDownloadNode() throws Exception - { - // POST /downloads - String postBody = JsonBodyGenerator.defineJSON() - .add("nodeIds", JsonBodyGenerator.defineJSONArray().add(document1.getNodeRefWithoutVersion())) - .build().toString(); - RestDownloadsModel downloadModel = restClient.authenticateUser(adminModel).withCoreAPI().usingDownloads().createDownload(postBody); - - /* - * DELETE /downloads/{downloadId} - * Download canceling is async and it works only if download status is not "DONE" - * To have this case, a large pdf file was used that takes a longer time to download - */ - restClient.authenticateUser(adminModel).withCoreAPI().usingDownloads(downloadModel).cancelDownload(); - restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); - - // GET /downloads/{downloadId} to check that the download is canceled - Utility.sleep(500, 10000, () -> { - RestDownloadsModel downloadModel1 = restClient.authenticateUser(adminModel).withCoreAPI().usingDownloads(downloadModel).getDownload(); - restClient.assertStatusCodeIs(HttpStatus.OK); - downloadModel1.assertThat().field("status").is("CANCELLED"); - }); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/AddFavoriteSiteTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/AddFavoriteSiteTests.java deleted file mode 100644 index df167a6e7..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/AddFavoriteSiteTests.java +++ /dev/null @@ -1,487 +0,0 @@ -package org.alfresco.service.search.rest.favorites; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.core.RestRequest; -import org.alfresco.rest.model.RestCommentModel; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestFavoriteSiteModel; -import org.alfresco.rest.model.RestPersonFavoritesModel; -import org.alfresco.rest.model.RestPersonFavoritesModelsCollection; -import org.alfresco.rest.model.RestTagModel; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.LinkModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class AddFavoriteSiteTests extends RestTest -{ - private UserModel userModel, adminUser; - private SiteModel publicSite, privateSite, moderatedSite; - private FileModel document; - private FolderModel folder; - private RestFavoriteSiteModel restFavoriteSiteModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userModel = dataUser.createRandomTestUser(); - - publicSite = dataSite.usingUser(userModel).createPublicRandomSite(); - privateSite = dataSite.usingUser(userModel).createPrivateRandomSite(); - moderatedSite = dataSite.usingUser(userModel).createModeratedRandomSite(); - - document = dataContent.usingSite(publicSite).usingUser(adminUser).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - folder = dataContent.usingSite(publicSite).usingUser(adminUser).createFolder(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user add a favorite site with Rest API and response is successful (201)") - public void managerUserAddFavoriteSiteWithSuccess() throws Exception - { - UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(managerUser, publicSite, UserRole.SiteManager); - - restFavoriteSiteModel = restClient.authenticateUser(managerUser).withCoreAPI().usingUser(managerUser).addFavoriteSite(publicSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restFavoriteSiteModel.assertThat().field("id").is(publicSite.getId()); - - restClient.withCoreAPI().usingUser(managerUser).addFavoriteSite(publicSite); - restClient.assertStatusCodeIs(HttpStatus.CONFLICT); - restClient.assertLastError().containsSummary(String.format("%s is already a favourite site", publicSite.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify a manager user is NOT Authorized to add a favorite site with Rest API when authentication fails (401)") -// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void managerUserNotAuthorizedFailsToAddFavoriteSite() throws Exception - { - UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(managerUser, publicSite, UserRole.SiteManager); - managerUser.setPassword("newpassword"); - - restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().addFavoriteSite(publicSite); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify collaborator user add a favorite site with Rest API and response is successful (201)") - public void collaboratorUserAddFavoriteSiteWithSuccess() throws Exception - { - UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(collaboratorUser, publicSite, UserRole.SiteCollaborator); - - restFavoriteSiteModel = restClient.authenticateUser(collaboratorUser).withCoreAPI().usingAuthUser().addFavoriteSite(publicSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restFavoriteSiteModel.assertThat().field("id").is(publicSite.getId()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify contributor user add a favorite site with Rest API and response is successful (201)") - public void contributorUserAddFavoriteSiteWithSuccess() throws Exception - { - UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(contributorUser, publicSite, UserRole.SiteContributor); - - restFavoriteSiteModel = restClient.authenticateUser(contributorUser).withCoreAPI().usingAuthUser().addFavoriteSite(publicSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restFavoriteSiteModel.assertThat().field("id").is(publicSite.getId()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify consumer user add a favorite site with Rest API and response is successful (201)") - public void consumerUserAddFavoriteSiteWithSuccess() throws Exception - { - UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(consumerUser, publicSite, UserRole.SiteConsumer); - - restFavoriteSiteModel = restClient.authenticateUser(consumerUser).withCoreAPI().usingAuthUser().addFavoriteSite(publicSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restFavoriteSiteModel.assertThat().field("id").is(publicSite.getId()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin user add a favorite site with Rest API and response is successful (201)") - public void adminUserAddFavoriteSiteWithSuccess() throws Exception - { - restFavoriteSiteModel = restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().addFavoriteSite(publicSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restFavoriteSiteModel.assertThat().field("id").is(publicSite.getId()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify manager user is not able to add a favorite site when the site is already favorite - status code (409)") - public void managerUserAddFavoriteSiteAlreadyAFavoriteSite() throws Exception - { - publicSite = dataSite.usingUser(userModel).createPublicRandomSite(); - UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(managerUser, publicSite, UserRole.SiteManager); - - restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().addFavoriteSite(publicSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.withCoreAPI().usingUser(managerUser).addFavoriteSite(publicSite); - restClient.assertStatusCodeIs(HttpStatus.CONFLICT); - restClient.assertLastError() - .containsSummary(String.format("%s is already a favourite site", publicSite.getId())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE) - .containsErrorKey(String.format("Site %s is already a favourite site", publicSite.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify user doesn't have permission to delete favorites of admin user with Rest API and status code is 403") - public void userIsNotAbleToAddFavoriteSiteOfAnotherUser() throws Exception - { - publicSite = dataSite.usingUser(userModel).createPublicRandomSite(); - UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(contributorUser, publicSite, UserRole.SiteContributor); - UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(consumerUser, publicSite, UserRole.SiteConsumer); - - restClient.authenticateUser(consumerUser).withCoreAPI() - .usingUser(contributorUser).addFavoriteSite(publicSite); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError() - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify manager user is able to add as favorite a private site.") - public void managerAddsPrivateSiteAsFavorite() throws Exception - { - UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(managerUser, privateSite, UserRole.SiteManager); - - restClient.authenticateUser(managerUser).withCoreAPI().usingUser(managerUser).addFavoriteSite(privateSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestPersonFavoritesModelsCollection favorites = restClient.withCoreAPI().usingAuthUser().getFavorites(); - favorites.assertThat().entriesListContains("targetGuid", privateSite.getGuidWithoutVersion()) - .and().paginationField("totalItems").is("1"); - favorites.getOneRandomEntry().onModel().getTarget().getSite() - .assertThat() - .field("description").is(privateSite.getDescription()) - .and().field("id").is(privateSite.getId()) - .and().field("visibility").is(privateSite.getVisibility().toString()) - .and().field("title").is(privateSite.getTitle()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify manager user is able to add as favorite a moderated site.") - public void managerAddsModeratedSiteAsFavorite() throws Exception - { - UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(managerUser, moderatedSite, UserRole.SiteManager); - - restClient.authenticateUser(managerUser).withCoreAPI().usingUser(managerUser).addFavoriteSite(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestPersonFavoritesModelsCollection favorites = restClient.withCoreAPI().usingAuthUser().getFavorites(); - favorites.assertThat().entriesListContains("targetGuid", moderatedSite.getGuidWithoutVersion()) - .and().paginationField("totalItems").is("1"); - favorites.getOneRandomEntry().onModel().getTarget().getSite() - .assertThat() - .field("description").is(moderatedSite.getDescription()) - .and().field("id").is(moderatedSite.getId()) - .and().field("visibility").is(moderatedSite.getVisibility().toString()) - .and().field("title").is(moderatedSite.getTitle()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify user removes a site from favorites using '-me-' in place of personId with Rest API and response is successful (201)") - public void addFavoriteSiteWithSuccessUsingMeAsPersonId() throws Exception - { - restClient.authenticateUser(adminUser).withCoreAPI().usingMe().addFavoriteSite(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify manager user removes a site from its favorites and adds it again and response is successful (204)") - public void managerUserRemovesFavoriteSiteAndAddItAgain() throws Exception - { - UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(managerUser, publicSite, UserRole.SiteManager); - dataSite.usingUser(managerUser).usingSite(publicSite).addSiteToFavorites(); - - restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().removeFavoriteSite(publicSite); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingUser(managerUser).addSiteToFavorites(publicSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - } - - @Bug(id="ACE-2413") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify empty user is not able to add a site from favorites and response is (400)") - public void emptyUserIsNotAbleToRemoveFavoriteSite() throws Exception - { - UserModel emptyUser = new UserModel("", "password"); - restClient.authenticateUser(adminUser).withCoreAPI().usingUser(emptyUser).addFavoriteSite(publicSite); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "emptyUser")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify inexistent user is not able to add a site from favorites and response is (404)") - public void inexistentUserIsNotAbleToRemoveFavoriteSite() throws Exception - { - UserModel inexistentUser = new UserModel("inexistentUser", "password"); - restClient.authenticateUser(adminUser).withCoreAPI().usingUser(inexistentUser).addFavoriteSite(publicSite); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "inexistentUser")) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Bug(id="REPO-1827") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify user is not able to add a favorite site when the 'id' is empty - status code (400)") - public void userAddFavoriteSiteWithEmptySiteId() throws Exception - { - publicSite.setId(""); - restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().addFavoriteSite(publicSite); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - restClient.assertLastError() - .containsSummary("siteId is null") - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify admin user doesn't have permission to add a favorite site of another user with Rest API and status code is 403") - public void adminIsNotAbleToAddFavoriteSiteOfAnotherUser() throws Exception - { - UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(collaboratorUser, publicSite, UserRole.SiteCollaborator); - restClient.authenticateUser(collaboratorUser) - .withCoreAPI().usingUser(adminUser).addFavoriteSite(publicSite); - - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError() - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Bug(id="MNT-17338") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify admin user doesn't have permission to add a favorite site of another user with Rest API and status code is 403") - public void userIsNotAbleToAddFavoriteSiteOfAdmin() throws Exception - { - UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(consumerUser, publicSite, UserRole.SiteConsumer); - restClient.authenticateUser(adminUser) - .withCoreAPI().usingUser(consumerUser).addFavoriteSite(publicSite); - - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError() - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify add favorite site using empty body - status code is 400") - public void addFavoriteSiteWithEmptyBody() throws Exception - { - restClient.authenticateUser(adminUser).withCoreAPI(); - RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{\"ids\": \"local\"}" , - "people/{personId}/favorite-sites", adminUser.getUsername()); - restClient.processModel(RestPersonFavoritesModel.class, request); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsSummary(String.format(RestErrorModel.NO_CONTENT, "Unrecognized field " + "\"ids\"")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify add favorite site using empty body - status code is 400") - public void addFavoriteSiteWithEmptyRequiredFieldsBody() throws Exception - { - restClient.authenticateUser(adminUser).withCoreAPI(); - RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{\"\": \"\"}", - "people/{personId}/favorite-sites", adminUser.getUsername()); - restClient.processModel(RestPersonFavoritesModel.class, request); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsSummary(String.format(RestErrorModel.NO_CONTENT, "Unrecognized field " + "\"\"")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify non member user is not able to add a private favorite site - status code is 404") - public void userAddFavoriteSiteUserNotMemberOfPrivateSite() throws Exception - { - UserModel user = dataUser.usingAdmin().createRandomTestUser(); - restClient.authenticateUser(user).withCoreAPI() - .usingAuthUser().addFavoriteSite(privateSite); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, privateSite.getId())) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify non member user is able to add a moderated favorite site") - public void userAddFavoriteSiteUserNotMemberOfModeratedSite() throws Exception - { - UserModel user = dataUser.usingAdmin().createRandomTestUser(); - restClient.authenticateUser(user).withCoreAPI().usingAuthUser() - .addFavoriteSite(moderatedSite); - - RestPersonFavoritesModelsCollection favorites = restClient.withCoreAPI().usingAuthUser().getFavorites(); - favorites.assertThat().entriesListContains("targetGuid", moderatedSite.getGuidWithoutVersion()) - .and().paginationField("totalItems").is("1"); - favorites.getOneRandomEntry().onModel().getTarget().getSite() - .assertThat() - .field("description").is(moderatedSite.getDescription()) - .and().field("id").is(moderatedSite.getId()) - .and().field("visibility").is(moderatedSite.getVisibility().toString()) - .and().field("title").is(moderatedSite.getTitle()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify non member user is able to add a public favorite site") - public void userAddFavoriteSiteUserNotMemberOfPublicSite() throws Exception - { - UserModel user = dataUser.usingAdmin().createRandomTestUser(); - restFavoriteSiteModel = restClient.authenticateUser(user).withCoreAPI().usingAuthUser().addFavoriteSite(publicSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restFavoriteSiteModel.assertThat().field("id").is(publicSite.getId()); - - RestPersonFavoritesModelsCollection favorites = restClient.withCoreAPI().usingAuthUser().getFavorites(); - favorites.assertThat().entriesListContains("targetGuid", publicSite.getGuidWithoutVersion()) - .and().paginationField("totalItems").is("1"); - favorites.getOneRandomEntry().onModel().getTarget().getSite() - .assertThat() - .field("description").is(publicSite.getDescription()) - .and().field("id").is(publicSite.getId()) - .and().field("visibility").is(publicSite.getVisibility().toString()) - .and().field("title").is(publicSite.getTitle()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Check that if id does not exist, status code is 404") - public void addFavoriteSiteUsingInvalidId() throws Exception - { - SiteModel site = dataSite.usingUser(adminUser).createPublicRandomSite(); - String id = publicSite.getId(); - site.setId("invalidID"); - - restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().addFavoriteSite(site); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidID")); - - publicSite.setId(id); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Check that if user provides site in id but id is of a file status code is 404") - public void addSiteToFavoritesUsingFileId() throws Exception - { - String id = publicSite.getId(); - publicSite.setId(document.getNodeRefWithoutVersion()); - - restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().addFavoriteSite(publicSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, document.getNodeRefWithoutVersion())); - - publicSite.setId(id); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Check that if user provides site in id but id is of a folder status code is 404") - public void addSiteToFavoritesUsingFolderId() throws Exception - { - String id = publicSite.getId(); - publicSite.setId(folder.getNodeRefWithoutVersion()); - - restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().addFavoriteSite(publicSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, folder.getNodeRefWithoutVersion())); - - publicSite.setId(id); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Check that if user provides site in id but id is of a comment status code is 404") - public void addSiteToFavoriteUsingCommentId() throws Exception - { - publicSite = dataSite.usingUser(userModel).createPublicRandomSite(); - String id = publicSite.getId(); - FileModel file = dataContent.usingSite(publicSite).usingUser(adminUser).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - RestCommentModel comment = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(file).addComment("This is a comment"); - file.setNodeRef(comment.getId()); - publicSite.setId(comment.getId()); - - restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().addFavoriteSite(publicSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - publicSite.setId(id); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Check that if user provides site in id but id is of a tag status code is 404") - public void addSiteFavoriteUsingTagId() throws Exception - { - FileModel file = dataContent.usingSite(publicSite).usingUser(adminUser).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - RestTagModel returnedModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(file).addTag("random_tag"); - file.setNodeRef(returnedModel.getId()); - publicSite.setId(returnedModel.getId()); - - restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().addFavoriteSite(publicSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, returnedModel.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION}) - @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Check that if id does not describe a site, file, or folder status code is 400") - public void addFavoriteUsingInvalidGuid() throws Exception - { - LinkModel link = dataLink.usingAdmin().usingSite(publicSite).createRandomLink(); - SiteModel site = dataSite.usingUser(adminUser).createPublicRandomSite(); - site.setId(link.getNodeRef()); - - restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().addFavoriteSite(site); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, site.getId().split("/")[3])); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/AddFavoritesTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/AddFavoritesTests.java deleted file mode 100644 index 52acf953f..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/AddFavoritesTests.java +++ /dev/null @@ -1,446 +0,0 @@ -package org.alfresco.service.search.rest.favorites; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.core.RestRequest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.*; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.model.*; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class AddFavoritesTests extends RestTest -{ - private UserModel adminUserModel; - private SiteModel siteModel; - private ListUserWithRoles usersWithRoles; - private RestPersonFavoritesModel restPersonFavoritesModel; - private FileModel document; - private FolderModel folder; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - - document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - folder = dataContent.usingSite(siteModel).usingUser(adminUserModel).createFolder(); - } - - // @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Verify Manager user gets status code 401 if authentication call fails") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - public void managerIsNotAbleToAddToFavoritesIfAuthenticationFails() throws Exception - { - UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); - siteManager.setPassword("wrongPassword"); - restClient.authenticateUser(siteManager).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify Collaborator user add site to favorites with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void collaboratorIsAbleToAddToFavorites() throws Exception - { - restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restPersonFavoritesModel.and().field("targetGuid").is(siteModel.getGuid()); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify Contributor user add site to favorites with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void contributorIsAbleToAddToFavorites() throws JsonToModelConversionException, Exception - { - restPersonFavoritesModel= restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) - .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restPersonFavoritesModel.and().field("targetGuid").is(siteModel.getGuid()); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify Consumer user add site to favorites with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void consumerIsAbleToAddToFavorites() throws Exception - { - restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restPersonFavoritesModel.and().field("targetGuid").is(siteModel.getGuid()); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify Admin user add site to favorites with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void adminIsAbleToAddToFavorites() throws Exception - { - restPersonFavoritesModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restPersonFavoritesModel.assertThat().field("targetGuid").is(siteModel.getGuid()); - } - - @Bug(id = "MNT-17157") - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Check that if a favorite already exists with the specified id status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void addFavoriteTwice() throws Exception - { - SiteModel site = dataSite.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).createPublicRandomSite(); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteToFavorites(site); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(site); - restClient.assertStatusCodeIs(HttpStatus.CONFLICT); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Add to favorites a file for a Manager, check it was added") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - public void managerIsAbleToAddFileToFavorites() throws Exception - { - restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingAuthUser().addFileToFavorites(document); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restPersonFavoritesModel.assertThat().field("targetGuid").is(document.getNodeRefWithoutVersion()); - - RestFileModel restFileModel = restPersonFavoritesModel.getTarget().getFile(); - restFileModel.assertThat().field("mimeType").is("text/plain").and() - .field("isFile").is("true").and() - .field("isFolder").is("false").and() - .field("createdBy").is(adminUserModel.getUsername()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Add to favorites a folder for a Manager, check it was added") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - public void managerIsAbleToAddFolderToFavorites() throws Exception - { - restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingAuthUser().addFolderToFavorites(folder); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restPersonFavoritesModel.assertThat().field("targetGuid").is(folder.getNodeRefWithoutVersion()); - - RestFolderModel restFolderModel = restPersonFavoritesModel.getTarget().getFolder(); - restFolderModel.assertThat().field("isFile").is("false").and() - .field("isFolder").is("true").and() - .field("createdBy").is(adminUserModel.getUsername()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Add to favorites a site for a Manager, check it was added") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - public void managerIsAbleToAddSiteToFavorites() throws Exception - { - restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restPersonFavoritesModel.assertThat().field("targetGuid").is(siteModel.getGuid()); - - RestSiteModel restSiteModel = restPersonFavoritesModel.getTarget().getSite(); - restSiteModel.assertThat().field("visibility").is(siteModel.getVisibility()).and() - .field("guid").is(siteModel.getGuid()).and() - .field("description").is(siteModel.getDescription()).and() - .field("id").is(siteModel.getId()).and() - .field("title").is(siteModel.getTitle()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify add favorite specifying -me- string in place of for request") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void userIsAbleToAddFavoriteWhenUsingMeAsUsername() throws Exception - { - UserModel user = dataUser.createRandomTestUser(); - restPersonFavoritesModel = restClient.authenticateUser(user) - .withCoreAPI().usingMe().addSiteToFavorites(siteModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restPersonFavoritesModel.assertThat().field("targetGuid").is(siteModel.getGuid()); - - restClient.authenticateUser(user).withCoreAPI().usingAuthUser().getFavoriteSites().assertThat().entriesListContains("guid", siteModel.getGuid()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Add to favorites a file for a Collaborator, check it was added") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void collaboratorIsAbleToAddFileToFavorites() throws Exception - { - restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingAuthUser().addFileToFavorites(document); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restPersonFavoritesModel.assertThat().field("targetGuid").is(document.getNodeRefWithoutVersion()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Add to favorites a file for a Contributor, check it was added") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void contributorIsAbleToAddFileToFavorites() throws Exception - { - restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) - .withCoreAPI().usingAuthUser().addFileToFavorites(document); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restPersonFavoritesModel.assertThat().field("targetGuid").is(document.getNodeRefWithoutVersion()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Add to favorites a file for a Consumer, check it was added") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void consumerIsAbleToAddFileToFavorites() throws Exception - { - restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .withCoreAPI().usingAuthUser().addFileToFavorites(document); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restPersonFavoritesModel.assertThat().field("targetGuid").is(document.getNodeRefWithoutVersion()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Add to favorites a folder for a Collaborator, check it was added") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void collaboratorIsAbleToAddFolderToFavorites() throws Exception - { - restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).addFolderToFavorites(folder); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restPersonFavoritesModel.assertThat().field("targetGuid").is(folder.getNodeRefWithoutVersion()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Add to favorites a folder for a Contributor, check it was added") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void contributorIsAbleToAddFolderToFavorites() throws Exception - { - restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) - .withCoreAPI().usingAuthUser().addFolderToFavorites(folder); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restPersonFavoritesModel.assertThat().field("targetGuid").is(folder.getNodeRefWithoutVersion()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Add to favorites a folder for a Consumer, check it was added") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void consumerIsAbleToAddFolderToFavorites() throws Exception - { - restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .withCoreAPI().usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).addFolderToFavorites(folder); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restPersonFavoritesModel.assertThat().field("targetGuid").is(folder.getNodeRefWithoutVersion()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Add to favorites a site for a Collaborator, check it was added") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void collaboratorIsAbleToAddSiteToFavorites() throws Exception - { - restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restPersonFavoritesModel.assertThat().field("targetGuid").is(siteModel.getGuid()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Add to favorites a site for a Contributor, check it was added") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void contributorIsAbleToAddSiteToFavorites() throws Exception - { - restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) - .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restPersonFavoritesModel.assertThat().field("targetGuid").is(siteModel.getGuid()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Add to favorites a site for a Consumer, check it was added") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void consumerIsAbleToAddSiteToFavorites() throws Exception - { - restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restPersonFavoritesModel.assertThat().field("targetGuid").is(siteModel.getGuid()); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Check that if target guid does not describe a site, file, or folder status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void addFavoriteUsingInvalidGuid() throws Exception - { - LinkModel link = dataLink.usingAdmin().usingSite(siteModel).createRandomLink(); - SiteModel site = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - site.setGuid(link.getNodeRef()); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteToFavorites(site); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, site.getGuid().split("/")[3])); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Check that if personId does not exist, status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void addFavoriteUsingInexistentUser() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(new UserModel("random_user", "random_password")).addSiteToFavorites(siteModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "random_user")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Check that if target guid does not exist, status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void addFavoriteUsingInexistentGuid() throws Exception - { - SiteModel site = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - site.setGuid("random_guid"); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteToFavorites(site); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "random_guid")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Check that if user provides file in target but guid is of a folder status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void addFileToFavoritesUsingFolderGuid() throws Exception - { - String nodeRef = document.getNodeRef(); - document.setNodeRef(folder.getNodeRef()); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFileToFavorites(document); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, - adminUserModel.getUsername(), folder.getNodeRefWithoutVersion())); - - document.setNodeRef(nodeRef); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify add favorite, perform getFavorites call, check value is updated") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void verifyGetFavoritesAfterFavoritingSite() throws Exception - { - UserModel user = dataUser.createRandomTestUser(); - restPersonFavoritesModel = restClient.authenticateUser(user) - .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(user).withCoreAPI().usingAuthUser().getFavoriteSites() - .assertThat().entriesListContains("guid", siteModel.getGuid()); - } - - // @Bug(id = "MNT-17158", description="Not a bug, If we need to stop comments from being favorited then an improvement/enhancement request should be raised against the platform.") - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify add file favorite with comment id returns status code 201") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void addFileFavoriteUsingCommentId() throws Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - RestCommentModel comment = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment("This is a comment"); - file.setNodeRef(comment.getId()); - - restPersonFavoritesModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFileToFavorites(file); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restPersonFavoritesModel.assertThat().field("targetGuid").is(file.getNodeRef()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify add file favorite with tag id returns status code 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void addFileFavoriteUsingTagId() throws Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - RestTagModel returnedModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addTag("random_tag"); - file.setNodeRef(returnedModel.getId()); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFileToFavorites(file); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, - adminUserModel.getUsername(), returnedModel.getId())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Check that if user provides site in target but id is of a file status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void addSiteToFavoritesUsingFileId() throws Exception - { - String guid = siteModel.getGuid(); - siteModel.setGuid(document.getNodeRefWithoutVersion()); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, document.getNodeRefWithoutVersion())); - - siteModel.setGuid(guid); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Check that if user provides folder in target but guid is of a file status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void addFolderToFavoritesUsingFileGuid() throws Exception - { - String nodeRef = folder.getNodeRef(); - folder.setNodeRef(document.getNodeRef()); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFolderToFavorites(folder); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, document.getNodeRef())); - - folder.setNodeRef(nodeRef); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Check that if user provides file in target but guid is of a site status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void addSiteToFavoritesUsingFolderId() throws Exception - { - SiteModel newSiteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - newSiteModel.setGuid(folder.getNodeRef()); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteToFavorites(newSiteModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, folder.getNodeRef())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Check that if user provides folder in target but guid is of a site status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void addFolderToFavoritesUsingSiteId() throws Exception - { - FolderModel newFolder = dataContent.usingSite(siteModel).usingUser(adminUserModel).createFolder(); - newFolder.setNodeRef(siteModel.getGuid()); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFolderToFavorites(newFolder); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, - adminUserModel.getUsername(), siteModel.getGuid())); - } - - @Bug(id = "REPO-1061") - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Check that if user does not have permission to favorite a site status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void verifyFavoriteASiteIfTheUserDoesNotHavePermission() throws Exception - { - SiteModel privateSite = dataSite.usingUser(adminUserModel).createPrivateRandomSite(); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingAuthUser().addSiteToFavorites(privateSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, privateSite.getGuid())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .containsErrorKey(RestErrorModel.NOT_FOUND_ERRORKEY) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify the response of favorite a sie with empty body at request") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void verifyFavoriteASiteWithEmptyBody() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI(); - RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "", "people/{personId}/favorites", adminUserModel.getUsername()); - restClient.processModel(RestPersonFavoritesModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.NO_CONTENT, "No content to map due to end-of-input")); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/DeleteFavoriteSiteTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/DeleteFavoriteSiteTests.java deleted file mode 100644 index 057c48e65..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/DeleteFavoriteSiteTests.java +++ /dev/null @@ -1,364 +0,0 @@ -package org.alfresco.service.search.rest.favorites; - -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser; -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 Cristina Axinte - */ - -public class DeleteFavoriteSiteTests extends RestTest -{ - private UserModel userModel, adminUserModel; - private SiteModel siteModel1, siteModel2; - private DataUser.ListUserWithRoles usersWithRoles; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - siteModel1 = dataSite.usingUser(userModel).createPublicRandomSite(); - siteModel2 = dataSite.usingUser(userModel).createPublicRandomSite(); - adminUserModel = dataUser.getAdminUser(); - - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel1, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, - description = "Verify manager user removes a site from its favorite sites list with Rest API and response is successful (204)") - public void managerUserRemovesFavoriteSiteWithSuccess() throws Exception - { - UserModel managerUser = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); - dataSite.usingUser(managerUser).usingSite(siteModel1).addSiteToFavorites(); - dataSite.usingUser(managerUser).usingSite(siteModel2).addSiteToFavorites(); - - restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingAuthUser().getFavorites() - .assertThat() - .entriesListDoesNotContain("targetGuid", siteModel1.getGuid()) - .and().entriesListDoesNotContain("id", siteModel1.getId()) - .and().entriesListDoesNotContain("description", siteModel1.getDescription()) - .and().entriesListDoesNotContain("visibility", siteModel1.getVisibility().toString()) - .and().entriesListDoesNotContain("title", siteModel1.getTitle()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, - description = "Verify manager user is NOT Authorized to remove a site from its favorite sites list with Rest API when authentication fails (401)") - public void managerUserNotAuthorizedFailsToRemoveFavoriteSite() throws Exception - { - UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel1, UserRole.SiteManager); - dataSite.usingUser(managerUser).usingSite(siteModel1).addSiteToFavorites(); - dataSite.usingUser(managerUser).usingSite(siteModel2).addSiteToFavorites(); - managerUser.setPassword("newpassword"); - - restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE) - .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify collaborator user removes a site from its favorite sites list with Rest API and response is successful (204)") - public void collaboratorUserRemovesFavoriteSiteWithSuccess() throws Exception - { - UserModel collaboratorUser = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); - dataSite.usingUser(collaboratorUser).usingSite(siteModel1).addSiteToFavorites(); - dataSite.usingUser(collaboratorUser).usingSite(siteModel2).addSiteToFavorites(); - - restClient.authenticateUser(collaboratorUser).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingAuthUser().getFavorites() - .assertThat() - .entriesListDoesNotContain("targetGuid", siteModel1.getGuid()) - .and().entriesListDoesNotContain("id", siteModel1.getId()) - .and().entriesListDoesNotContain("description", siteModel1.getDescription()) - .and().entriesListDoesNotContain("visibility", siteModel1.getVisibility().toString()) - .and().entriesListDoesNotContain("title", siteModel1.getTitle()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify contributor user removes a site from its favorite sites list with Rest API and response is successful (204)") - public void contributorUserRemovesFavoriteSiteWithSuccess() throws Exception - { - UserModel contributorUser = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); - dataSite.usingUser(contributorUser).usingSite(siteModel1).addSiteToFavorites(); - dataSite.usingUser(contributorUser).usingSite(siteModel2).addSiteToFavorites(); - - restClient.authenticateUser(contributorUser).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingAuthUser().getFavorites() - .assertThat() - .entriesListDoesNotContain("targetGuid", siteModel1.getGuid()) - .and().entriesListDoesNotContain("id", siteModel1.getId()) - .and().entriesListDoesNotContain("description", siteModel1.getDescription()) - .and().entriesListDoesNotContain("visibility", siteModel1.getVisibility().toString()) - .and().entriesListDoesNotContain("title", siteModel1.getTitle()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify consumer user removes a site from its favorite sites list with Rest API and response is successful (204)") - public void consumerUserRemovesFavoriteSiteWithSuccess() throws Exception - { - UserModel consumerUser = usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer); - dataSite.usingUser(consumerUser).usingSite(siteModel1).addSiteToFavorites(); - dataSite.usingUser(consumerUser).usingSite(siteModel2).addSiteToFavorites(); - - restClient.authenticateUser(consumerUser).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingAuthUser().getFavorites() - .assertThat() - .entriesListDoesNotContain("targetGuid", siteModel1.getGuid()) - .and().entriesListDoesNotContain("id", siteModel1.getId()) - .and().entriesListDoesNotContain("description", siteModel1.getDescription()) - .and().entriesListDoesNotContain("visibility", siteModel1.getVisibility().toString()) - .and().entriesListDoesNotContain("title", siteModel1.getTitle()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify admin user removes a site from any user's favorite sites list with Rest API and response is successful (204)") - public void adminUserRemovesAnyFavoriteSiteWithSuccess() throws Exception - { - UserModel anyUser = dataUser.usingAdmin().createRandomTestUser(); - dataSite.usingUser(anyUser).usingSite(siteModel1).addSiteToFavorites(); - dataSite.usingUser(anyUser).usingSite(siteModel2).addSiteToFavorites(); - - restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingUser(anyUser).removeFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE , TestGroup.REGRESSION}) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify a user removes a site from another user's favorite sites list with Rest API and response is permission denied (403)") - public void userCannotRemoveAnotherUserFavoriteSite() throws Exception - { - UserModel userAuth = dataUser.usingAdmin().createRandomTestUser(); - UserModel anotherUser = dataUser.usingAdmin().createRandomTestUser(); - dataSite.usingUser(anotherUser).usingSite(siteModel1).addSiteToFavorites(); - dataSite.usingUser(anotherUser).usingSite(siteModel2).addSiteToFavorites(); - - restClient.authenticateUser(userAuth).withCoreAPI().usingUser(anotherUser).removeFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError() - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE) - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify uninvited user can delete favorite public site and response is 204") - public void uninvitedUserCanDeleteFavoritePublicSite() throws Exception - { - SiteModel publicSiteModel = dataSite.usingAdmin().createPublicRandomSite(); - restClient.authenticateUser(userModel).withCoreAPI().usingUser(userModel).addFavoriteSite(publicSiteModel); - - restClient.withCoreAPI().usingAuthUser() - .removeFavoriteSite(publicSiteModel); - - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingAuthUser().getFavoriteSites() - .assertThat().entriesListDoesNotContain("id", publicSiteModel.getId()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify uninvited user can delete favorite moderated site and response is 204") - public void uninvitedUserCanDeleteFavoriteModeratedSite() throws Exception - { - SiteModel moderatedSiteModel = dataSite.usingAdmin().createModeratedRandomSite(); - restClient.authenticateUser(userModel).withCoreAPI().usingUser(userModel).addFavoriteSite(moderatedSiteModel); - - restClient.withCoreAPI().usingAuthUser() - .removeFavoriteSite(moderatedSiteModel); - - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingAuthUser().getFavoriteSites() - .assertThat().entriesListDoesNotContain("id", moderatedSiteModel.getId()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify user can delete favorite private site and response is 204") - public void userCanDeleteFavoritePrivateSite() throws Exception - { - SiteModel privateSiteModel = dataSite.usingUser(userModel).createPrivateRandomSite(); - restClient.authenticateUser(userModel).withCoreAPI().usingUser(userModel).addFavoriteSite(privateSiteModel); - - restClient.withCoreAPI().usingAuthUser() - .removeFavoriteSite(privateSiteModel); - - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingAuthUser().getFavoriteSites() - .assertThat().entriesListDoesNotContain("id", privateSiteModel.getId()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify manager user removes a site from its favorites and adds it again and response is successful (204)") - public void managerUserRemovesFavoriteSiteAndAddItAgain() throws Exception - { - UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel1, UserRole.SiteManager); - dataSite.usingUser(managerUser).usingSite(siteModel1).addSiteToFavorites(); - - restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser() - .removeFavoriteSite(siteModel1); - - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingUser(managerUser).addFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify user removes a site from favorites using '-me-' in place of personId with Rest API and response is successful (204)") - public void removeFavoriteSiteWithSuccessUsingMeAsPersonId() throws Exception - { - restClient.authenticateUser(adminUserModel); - dataSite.usingUser(adminUserModel).usingSite(siteModel1).addSiteToFavorites(); - - restClient.withCoreAPI().usingMe().removeFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) -// @Bug(id = "REPO-1642", description = "reproduced on 5.2.1 only, it works on 5.2.0") - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify inexistent user is not able to remove a site from favorites and response is 404") - public void inexistentUserIsNotAbleToRemoveFavoriteSite() throws Exception - { - UserModel inexistentUser = new UserModel("inexistenUser", "password"); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(inexistentUser) - .removeFavoriteSite(siteModel1); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "inexistenUser")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify user is not able to remove from favorites a site with inexistent id and response is 404") - public void userIsNotAbleToRemoveFavoriteSiteWithInexistentId() throws Exception - { - SiteModel inexistentSite = new SiteModel("inexistentSite"); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel) - .removeFavoriteSite(inexistentSite); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, - adminUserModel.getUsername(), inexistentSite.getTitle())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE) - .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "User is not able to remove a favorite site of admin user") - public void userIsNotAbleToDeleteFavoritesOfAdmin() throws Exception - { - UserModel contributor = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); - dataSite.usingUser(adminUserModel).usingSite(siteModel1).addSiteToFavorites(); - - restClient.authenticateUser(contributor) - .withCoreAPI().usingUser(adminUserModel).removeFavoriteSite(siteModel1); - - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError() - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Users removed twice from favorites same site.") - public void managerUserRemovesDeletedFavoriteSite() throws Exception - { - UserModel managerUser = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); - dataSite.usingUser(managerUser).usingSite(siteModel1).addSiteToFavorites(); - - restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel1); - restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.NOT_FAVOURITE_SITE, siteModel1.getTitle())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Users removes from favorite a site that is already deleted.") - public void consumerUserRemovesDeletedFavoriteSite() throws Exception - { - SiteModel siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel, UserRole.SiteConsumer); - dataSite.usingUser(consumerUser).usingSite(siteModel).addSiteToFavorites(); - - dataSite.usingAdmin().deleteSite(siteModel); - restClient.authenticateUser(consumerUser).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, - consumerUser.getUsername(), siteModel.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Delete favorite site that is NOT favorite.") - public void adminUserRemovesDeletedFavoriteSiteThatIsNotFavorite() throws Exception - { - SiteModel siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.NOT_FAVOURITE_SITE, siteModel.getTitle())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify user doesn't have permission to delete favorites of another user with Rest API and status code is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void siteMemberIsNotAbleToDeleteFavoritesOfAnotherSiteMember() throws Exception - { - UserModel siteCollaborator = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); - dataSite.usingUser(siteCollaborator).usingSite(siteModel1).addSiteToFavorites(); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .withCoreAPI() - .usingUser(siteCollaborator) - .removeFavoriteSite(siteModel1); - - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError() - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/DeleteFavoriteTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/DeleteFavoriteTests.java deleted file mode 100644 index 32e6765b1..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/DeleteFavoriteTests.java +++ /dev/null @@ -1,412 +0,0 @@ -package org.alfresco.service.search.rest.favorites; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class DeleteFavoriteTests extends RestTest -{ - private UserModel adminUserModel; - private SiteModel siteModel; - private ListUserWithRoles usersWithRoles; - private FileModel fileModel; - private FolderModel folderModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - siteModel.setGuid(restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(siteModel).getSite().getGuid()); - - fileModel = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - folderModel = dataContent.usingSite(siteModel).usingUser(adminUserModel).createFolder(); - - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Verify Manager user deletes site from favorites with Rest API and status code is 204") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - public void managerIsAbleToDeleteFavorites() throws Exception - { - UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); - restClient.authenticateUser(siteManager).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - - restClient.withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel).assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingAuthUser().getFavorites() - .assertThat() - .entriesListDoesNotContain("targetGuid", siteModel.getGuid()) - .and().entriesListDoesNotContain("id", siteModel.getId()) - .and().entriesListDoesNotContain("description", siteModel.getDescription()) - .and().entriesListDoesNotContain("visibility", siteModel.getVisibility().toString()) - .and().entriesListDoesNotContain("title", siteModel.getTitle()); - } - - // @Bug(id = "MNT-16904", description = "It fails only on environment with tenants") - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Verify user gets status code 401 if authentication call fails") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - public void userIsNotAbleToDeleteFavoritesIfAuthenticationFails() throws Exception - { - UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); - siteManager.setPassword("wrongPassword"); - restClient.authenticateUser(siteManager).withCoreAPI().usingAuthUser() - .deleteSiteFromFavorites(siteModel).assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify Collaborator user deletes site from favorites with Rest API and status code is 204") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void collaboratorIsAbleToDeleteFavorites() throws Exception - { - UserModel siteCollaborator = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); - restClient.authenticateUser(siteCollaborator).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - - restClient.withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel).assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingAuthUser().getFavorites() - .assertThat() - .entriesListDoesNotContain("targetGuid", siteModel.getGuid()) - .and().entriesListDoesNotContain("id", siteModel.getId()) - .and().entriesListDoesNotContain("description", siteModel.getDescription()) - .and().entriesListDoesNotContain("visibility", siteModel.getVisibility().toString()) - .and().entriesListDoesNotContain("title", siteModel.getTitle()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify Contributor user deletes site from favorites with Rest API and status code is 204") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void contributorIsAbleToDeleteFavorites() throws Exception - { - UserModel siteContributor = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); - restClient.authenticateUser(siteContributor).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - - restClient.withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel).assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingAuthUser().getFavorites() - .assertThat() - .entriesListDoesNotContain("targetGuid", siteModel.getGuid()) - .and().entriesListDoesNotContain("id", siteModel.getId()) - .and().entriesListDoesNotContain("description", siteModel.getDescription()) - .and().entriesListDoesNotContain("visibility", siteModel.getVisibility().toString()) - .and().entriesListDoesNotContain("title", siteModel.getTitle()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify Consumer user delets site from favorites with Rest API and status code is 204") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void consumerIsAbleToDeleteFavorites() throws Exception - { - UserModel siteConsumer = usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer); - restClient.authenticateUser(siteConsumer).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - - restClient.withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel).assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingAuthUser().getFavorites() - .assertThat() - .entriesListDoesNotContain("targetGuid", siteModel.getGuid()) - .and().entriesListDoesNotContain("id", siteModel.getId()) - .and().entriesListDoesNotContain("description", siteModel.getDescription()) - .and().entriesListDoesNotContain("visibility", siteModel.getVisibility().toString()) - .and().entriesListDoesNotContain("title", siteModel.getTitle()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify Admin user deletes site from favorites with Rest API and status code is 204") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void adminIsAbleToDeleteFavorites() throws Exception - { - restClient.withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); - - restClient.withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel).assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingAuthUser().getFavorites().assertThat().entriesListDoesNotContain("targetGuid", siteModel.getGuid()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify admin deletes files from favorites with Rest API and status code is (204)") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void adminIsAbleToDeleteFavoriteFile() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFileToFavorites(fileModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.withCoreAPI().usingAuthUser().deleteFileFromFavorites(fileModel).assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingAuthUser().getFavorites() - .assertThat() - .entriesListDoesNotContain("targetGuid", fileModel.getNodeRefWithoutVersion()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify admin deletes folder from favorites with Rest API and status code is (204)") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void adminIsAbleToDeleteFavoriteFolder() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFolderToFavorites(folderModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.withCoreAPI().usingAuthUser().deleteFolderFromFavorites(folderModel) - .assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingAuthUser().getFavorites() - .assertThat() - .entriesListDoesNotContain("targetGuid", fileModel.getNodeRefWithoutVersion()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify user removes a site from favorites using '-me-' in place of personId with Rest API and response is successful (204)") - public void deleteFavoriteSiteWithSuccessUsingMeAsPersonId() throws Exception - { - siteModel.setGuid(restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(siteModel).getSite().getGuid()); - restClient.withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); - - restClient.withCoreAPI().usingMe().deleteSiteFromFavorites(siteModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @Bug(id="ACE-5588") - @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify user doesn't have permission to delete favorites of admin user with Rest API and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void userIsNotAbleToDeleteFavoritesOfAdminUser() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel) - .assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Bug(id="ACE-5588") - @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify admin user doesn't have permission to delete favorites of another user with Rest API and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void adminIsNotAbleToDeleteFavoritesOfASiteMember() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - - restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel) - .assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError() - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Bug(id="ACE-5588") - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify user doesn't have permission to delete favorites of another user with Rest API and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void consumerIsNotAbleToDeleteFavoritesOfAnotherUser() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI() - .usingAuthUser().addSiteToFavorites(siteModel); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI() - .usingAuthUser().deleteSiteFromFavorites(siteModel) - .assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Bug(id="ACE-5588") - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify consumer user doesn't have permission to delete favorites of another user with Rest API and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void collaboratorIsNotAbleToDeleteFavoriteOfAnotherUser() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI() - .usingAuthUser().addSiteToFavorites(siteModel); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI() - .usingAuthUser().deleteSiteFromFavorites(siteModel) - .assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError() - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Bug(id="ACE-5588") - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify contributor user doesn't have permission to delete favorites of another user with Rest API and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void contributorIsNotAbleToDeleteFavoriteOfAnotherUser() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI() - .usingAuthUser().addSiteToFavorites(siteModel); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI() - .usingAuthUser().deleteSiteFromFavorites(siteModel) - .assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError() - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Bug(id="ACE-5588") - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify contributor user doesn't have permission to delete favorites of another user with Rest API and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void adminIsNotAbleToDeleteFavoriteOfAnotherUser() throws Exception - { - UserModel user = dataUser.createRandomTestUser(); - restClient.authenticateUser(user).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - - restClient.authenticateUser(adminUserModel).withCoreAPI() - .usingAuthUser().deleteSiteFromFavorites(siteModel) - .assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError() - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that status code is 404 if PersonID is incorrect - favorite file.") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION}) - public void deleteFavoriteIfPersonIdNotExists() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); - restClient.withCoreAPI().usingAuthUser().addFileToFavorites(fileModel); - - restClient.withCoreAPI().usingUser(new UserModel("inexistent", "inexistent")) - .deleteFileFromFavorites(fileModel).assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "inexistent")); - } - - @Bug(id="ACE-2413") - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that status code is 404 if PersonID is empty - favorite file.") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION}) - public void deleteFavoriteIfPersonIdIsEmpty() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); - restClient.withCoreAPI().usingAuthUser().addFileToFavorites(fileModel); - - restClient.withCoreAPI().usingUser(new UserModel ("", "")) - .deleteFileFromFavorites(fileModel).assertStatusCodeIs(HttpStatus.BAD_REQUEST); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that status code is 404 if FavoriteID is incorrect - favorite file.") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION}) - public void deleteFavoriteFileIfFavoriteIdIsIncorrect() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFileToFavorites(fileModel); - - fileModel.setNodeRef("wrongFavoriteId"); - restClient.withCoreAPI().usingAuthUser() - .deleteFileFromFavorites(fileModel).assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "wrongFavoriteId")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that status code is 404 if FavoriteID is incorrect - favorite file.") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION}) - public void deleteFavoriteFileIfFavoriteIdNotExists() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFileToFavorites(fileModel); - FileModel inexistentDocument = new FileModel(); - inexistentDocument.setNodeRef("inexistent"); - - restClient.withCoreAPI().usingAuthUser() - .deleteFileFromFavorites(inexistentDocument).assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "inexistent")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that status code is 404 if FavoriteID is incorrect - favorite site.") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION}) - public void deleteFavoriteSiteIfFavoriteIdNotExists() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); - siteModel.setGuid("wrongFavoriteId"); - - restClient.withCoreAPI().usingAuthUser() - .deleteSiteFromFavorites(siteModel).assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "wrongFavoriteId")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that status code is 404 if FavoriteID is incorrect - favorite folder.") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION}) - public void deleteFavoriteFolderIfFavoriteIdNotExists() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); - restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(folderModel); - - folderModel.setNodeRef("wrongFavoriteId"); - restClient.withCoreAPI().usingAuthUser() - .deleteFolderFromFavorites(folderModel).assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "wrongFavoriteId")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify admin is not able to deletes files from favorites that were already deleted with Rest API and status code is (404)") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void adminIsNotAbleToDeleteADeletedFavoriteFile() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFileToFavorites(fileModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.withCoreAPI().usingAuthUser().deleteFileFromFavorites(fileModel).assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingAuthUser().getFavorites() - .assertThat() - .entriesListDoesNotContain("targetGuid", fileModel.getNodeRefWithoutVersion()); - - restClient.withCoreAPI().usingAuthUser().deleteFileFromFavorites(fileModel) - .assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, - adminUserModel.getUsername(), fileModel.getNodeRef())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify user can't delete favorites using an invalid network ID.") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void userIsNotAbleToDeleteFavoriteSiteWithInvalidNetworkID() throws Exception - { - UserModel networkUserModel = dataUser.createRandomTestUser(); - restClient.authenticateUser(networkUserModel).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - networkUserModel.setDomain("invalidNetwork"); - - restClient.withCoreAPI() - .usingAuthUser().deleteSiteFromFavorites(siteModel) - .assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) - .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify contributor user doesn't have permission to delete favorites of another user with Rest API and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void adminDeletesFavoriteForNotFavouriteFile() throws Exception - { - fileModel = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser() - .deleteFileFromFavorites(fileModel) - .assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, - adminUserModel.getUsername(), fileModel.getNodeRef())) - .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/FavoritesIncludePathTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/FavoritesIncludePathTests.java deleted file mode 100644 index c0f43ceef..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/FavoritesIncludePathTests.java +++ /dev/null @@ -1,143 +0,0 @@ -package org.alfresco.service.search.rest.favorites; - -import static org.alfresco.utility.report.log.Step.STEP; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Class includes Sanity tests for the favorites api. Detailed tests would be covered in the alfresco-remote-api test project - * - * @author meenal bhave - */ -public class FavoritesIncludePathTests extends RestTest -{ - private UserModel adminUser; - private UserModel testUser1; - - private SiteModel siteModel1; - - private FolderModel folder1; - - private FileModel file1; - - private FolderModel subFolder1; - private FileModel fileInSubFolder; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - restClient.authenticateUser(adminUser); - - // Create Standard User - testUser1 = dataUser.usingUser(adminUser).createRandomTestUser(); - - // Create Site - siteModel1 = dataSite.usingUser(testUser1).createPublicRandomSite(); - - folder1 = dataContent.usingUser(adminUser).usingSite(siteModel1).createFolder(); - subFolder1 = dataContent.usingUser(adminUser).usingResource(folder1).createFolder(); - file1 = dataContent.usingUser(adminUser).usingResource(folder1).createContent(DocumentType.TEXT_PLAIN); - fileInSubFolder = dataContent.usingUser(adminUser).usingResource(subFolder1).createContent(DocumentType.TEXT_PLAIN); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify that get favorite site request does not include Path") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION}) - public void testGetFavoriteIncludePathForSite() throws Exception - { - restClient.authenticateUser(testUser1).withCoreAPI().usingAuthUser().includePath().getFavorite(siteModel1.getGuid()); - restClient.assertStatusCodeIs(HttpStatus.OK); - restClient.onResponse().assertThat().body("entry.target.site.id", org.hamcrest.Matchers.equalTo(siteModel1.getId()));//(org.hamcrest.Matchers.nullValue())); - restClient.onResponse().assertThat().body("entry.target.site.path", org.hamcrest.Matchers.is(org.hamcrest.Matchers.nullValue())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify that get favorite file or folder request includes path when requested") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION}) - public void testGetFavouriteIncludePathForFileFolder() throws Exception - { - STEP("1. Favourite Folder and File"); - restClient.authenticateUser(testUser1).withCoreAPI().usingAuthUser().addFolderToFavorites(folder1); - restClient.authenticateUser(testUser1).withCoreAPI().usingAuthUser().addFileToFavorites(file1); - - STEP("2. Check Path for Folder: Displayed when requested"); - restClient.authenticateUser(testUser1).withCoreAPI().usingAuthUser().includePath().getFavorite(folder1.getNodeRefWithoutVersion()); - restClient.assertStatusCodeIs(HttpStatus.OK); - restClient.onResponse().assertThat().body("entry.target.folder.id", org.hamcrest.Matchers.equalTo(folder1.getNodeRefWithoutVersion())); - restClient.onResponse().assertThat().body("entry.target.folder.path", org.hamcrest.Matchers.notNullValue()); - - STEP("3. Check Path for file: Displayed when requested"); - restClient.authenticateUser(testUser1).withCoreAPI().usingAuthUser().includePath().getFavorite(file1.getNodeRefWithoutVersion()); - restClient.assertStatusCodeIs(HttpStatus.OK); - restClient.onResponse().assertThat().body("entry.target.file.id", org.hamcrest.Matchers.equalTo(file1.getNodeRefWithoutVersion())); - restClient.onResponse().assertThat().body("entry.target.file.path", org.hamcrest.Matchers.notNullValue()); - - STEP("4. Check Path for Folder: Not Displayed when not requested"); - restClient.authenticateUser(testUser1).withCoreAPI().usingAuthUser().getFavorite(folder1.getNodeRefWithoutVersion()); - restClient.assertStatusCodeIs(HttpStatus.OK); - restClient.onResponse().assertThat().body("entry.target.folder.id", org.hamcrest.Matchers.equalTo(folder1.getNodeRefWithoutVersion())); - restClient.onResponse().assertThat().body("entry.target.folder.path", org.hamcrest.Matchers.nullValue()); - - STEP("5. Check Path for file: Not Displayed when not requested"); - restClient.authenticateUser(testUser1).withCoreAPI().usingAuthUser().getFavorite(file1.getNodeRefWithoutVersion()); - restClient.assertStatusCodeIs(HttpStatus.OK); - restClient.onResponse().assertThat().body("entry.target.file.id", org.hamcrest.Matchers.equalTo(file1.getNodeRefWithoutVersion())); - restClient.onResponse().assertThat().body("entry.target.file.path", org.hamcrest.Matchers.nullValue()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify path in get favorites") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION}) - public void testGetFavouritesIncludePath() throws Exception - { - STEP("1. Favourite Folder and File"); - restClient.authenticateUser(testUser1).withCoreAPI().usingAuthUser().addFolderToFavorites(folder1); - restClient.authenticateUser(testUser1).withCoreAPI().usingAuthUser().addFileToFavorites(file1); - - STEP("2. Check Path: Displayed when appropriate"); - restClient.authenticateUser(testUser1).withCoreAPI().usingAuthUser().includePath().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - // Folder - restClient.onResponse().assertThat().body("list.entries.entry.target.folder.id", org.hamcrest.Matchers.contains(folder1.getNodeRefWithoutVersion())); - restClient.onResponse().assertThat().body("list.entries.entry.target.folder.path", org.hamcrest.Matchers.notNullValue()); - // File - restClient.onResponse().assertThat().body("list.entries.entry.target.file.id", org.hamcrest.Matchers.contains(file1.getNodeRefWithoutVersion())); - restClient.onResponse().assertThat().body("list.entries.entry.target.file.path", org.hamcrest.Matchers.notNullValue()); - // Site - restClient.onResponse().assertThat().body("list.entries.entry.target.site.id", org.hamcrest.Matchers.contains(siteModel1.getId())); - restClient.onResponse().assertThat().body("list.entries.entry.target.site.path", org.hamcrest.Matchers.contains(org.hamcrest.Matchers.nullValue())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify path in post favorites") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION}) - public void testPostFavouritesIncludePath() throws Exception - { - STEP("1. Favourite Site"); - restClient.authenticateUser(testUser1).withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel1); - restClient.authenticateUser(testUser1).withCoreAPI().usingAuthUser().usingParams("include=path").addFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.onResponse().assertThat().body("entry.id", org.hamcrest.Matchers.equalTo(siteModel1.getId())); - restClient.onResponse().assertThat().body("entry.path", org.hamcrest.Matchers.nullValue()); - - STEP("2. Favourite Folder"); - restClient.authenticateUser(testUser1).withCoreAPI().usingAuthUser().usingParams("include=path").addFolderToFavorites(subFolder1); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.onResponse().assertThat().body("entry.target.folder.id", org.hamcrest.Matchers.equalTo(subFolder1.getNodeRefWithoutVersion())); - restClient.onResponse().assertThat().body("entry.target.folder.path", org.hamcrest.Matchers.notNullValue()); - - STEP("3. Favourite File"); - restClient.authenticateUser(testUser1).withCoreAPI().usingAuthUser().includePath().addFileToFavorites(fileInSubFolder); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.onResponse().assertThat().body("entry.target.file.id", org.hamcrest.Matchers.equalTo(fileInSubFolder.getNodeRefWithoutVersion())); - restClient.onResponse().assertThat().body("entry.target.file.path", org.hamcrest.Matchers.notNullValue()); - } -} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/FavoritesNetworkTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/FavoritesNetworkTests.java deleted file mode 100644 index 54becb068..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/FavoritesNetworkTests.java +++ /dev/null @@ -1,292 +0,0 @@ -package org.alfresco.service.search.rest.favorites; - -import org.alfresco.service.search.rest.NetworkDataPrep; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class FavoritesNetworkTests extends NetworkDataPrep -{ - private SiteModel publicSite, siteModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - init(); - siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.NETWORKS, TestGroup.REGRESSION}) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE}, executionType = ExecutionType.REGRESSION, - description = "Verify tenant user is able to add to favorites his site and status code is (201)") - public void tenantAddFavoriteSiteValidNetwork() throws Exception - { - publicSite = dataSite.usingUser(tenantUser).createPublicRandomSite(); - - restClient.authenticateUser(tenantUser).withCoreAPI(); - - restClient.withCoreAPI() - .usingAuthUser().addSiteToFavorites(publicSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.withCoreAPI().usingAuthUser().getFavorites() - .assertThat() - .entriesListContains("targetGuid", publicSite.getGuidWithoutVersion()); - } - - @Bug(id="MNT-16904") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.NETWORKS, TestGroup.REGRESSION}) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Verify tenant user is not able to add favorites using an invalid network ID - status code (401)") - public void tenantIsNotAbleToAddFavoriteSiteWithInvalidNetworkID() throws Exception - { - publicSite = dataSite.usingUser(tenantUser).createPublicRandomSite(); - - restClient.authenticateUser(tenantUser).withCoreAPI(); - String domain = tenantUser.getDomain(); - try - { - tenantUser.setDomain("invalidNetwork"); - - restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(publicSite); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - finally - { - tenantUser.setDomain(domain); - } - } - - @Bug(id="MNT-16904") - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE}, executionType = ExecutionType.REGRESSION, - description = "Verify tenant user is not able to remove favorites using an invalid network ID") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.NETWORKS, TestGroup.REGRESSION }) - public void tenantIsNotAbleToRemoveFavoriteSiteWithInvalidNetworkID() throws Exception - { - SiteModel siteModel = dataSite.usingUser(tenantUser).createPublicRandomSite(); - - restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - String domain = tenantUser.getDomain(); - try - { - tenantUser.setDomain("invalidNetwork"); - - restClient.withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - finally - { - tenantUser.setDomain(domain); - } - } - - @Bug(id="MNT-16904") - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify tenant user is not able to delete favorites using an invalid network ID") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES,TestGroup.NETWORKS, TestGroup.REGRESSION }) - public void tenantIsNotAbleToDeleteFavoriteSiteWithInvalidNetworkID() throws Exception - { - restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - String domain = tenantUser.getDomain(); - try - { - tenantUser.setDomain("invalidNetwork"); - - restClient.withCoreAPI() - .usingAuthUser().deleteSiteFromFavorites(siteModel) - .assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - finally - { - tenantUser.setDomain(domain); - } - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.NETWORKS, TestGroup.REGRESSION}) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE}, executionType = ExecutionType.REGRESSION, - description = "Verify tenant user is able to add to favorites a site created by admin tenant - same network and status code is (201)") - public void tenantUserIsAbleToAddFavoriteSiteAddedByAdminSameNetwork() throws Exception - { - publicSite = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); - - restClient.authenticateUser(tenantUser).withCoreAPI(); - tenantUser.setDomain(adminTenantUser.getDomain()); - - restClient.withCoreAPI().usingAuthUser().addFavoriteSite(publicSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.withCoreAPI().usingAuthUser().getFavorites() - .assertThat() - .entriesListContains("targetGuid", publicSite.getGuidWithoutVersion()); - } - - @Bug(id = "MNT-16904") - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify the get favorites request when network id is invalid for tenant user") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION, TestGroup.NETWORKS}) - public void getFavoriteSitesWhenNetworkIdIsInvalid() throws Exception - { - SiteModel firstSiteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - - restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); - - String domain = tenantUser.getDomain(); - try - { - tenantUser.setDomain("invalidNetwork"); - restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - finally - { - tenantUser.setDomain(domain); - } - } - - @Bug(id = "MNT-16904") - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify the post favorites request when network id is invalid for tenant user") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION, TestGroup.NETWORKS}) - public void addFavoriteSitesWhenNetworkIdIsInvalid() throws Exception - { - String domain = tenantUser.getDomain(); - try - { - tenantUser.setDomain("invalidNetwork"); - restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - finally{ - tenantUser.setDomain(domain); - } - } - - @Bug(id = "MNT-16904") - @TestRail(section = { TestGroup.REST_API, - TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify the get favorite request for invalid network id") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void getFavoriteSiteWithInvalidNetworkId() throws Exception - { - restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - - String domain = tenantUser.getDomain(); - try - { - tenantUser.setDomain("invalidNetwork"); - restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().getFavorite(siteModel.getGuid()); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - finally - { - tenantUser.setDomain(domain); - } - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify the get favorite request with tenant user") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void getFavoriteSiteWithTenantUser() throws Exception - { - restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - - restClient.withCoreAPI().usingAuthUser().getFavorite(siteModel.getGuid()); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE}, executionType = ExecutionType.REGRESSION, - description = "Verify tenant user deletes favorites site and status code is (204)") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.NETWORKS, TestGroup.REGRESSION }) - public void tenantRemoveFavoriteSiteValidNetwork() throws Exception - { - SiteModel siteModel = dataSite.usingUser(tenantUser).createPublicRandomSite(); - restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - - restClient.withCoreAPI() - .usingAuthUser().removeFavoriteSite(siteModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingAuthUser().getFavorites() - .assertThat() - .entriesListDoesNotContain("targetGuid", siteModel.getGuidWithoutVersion()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES}, executionType = ExecutionType.REGRESSION, - description = "Verify tenant user deletes favorites site and status code is (204)") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES,TestGroup.NETWORKS, TestGroup.REGRESSION }) - public void tenantDeleteFavoriteSiteValidNetwork() throws Exception - { - - restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - - restClient.withCoreAPI() - .usingAuthUser().deleteSiteFromFavorites(siteModel) - .assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingAuthUser().getFavorites() - .assertThat() - .entriesListDoesNotContain("targetGuid", siteModel.getGuidWithoutVersion()); - siteModel = dataSite.usingUser(tenantUser).createPublicRandomSite(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE}, executionType = ExecutionType.REGRESSION, - description = "Verify tenant user remove favorites site created by admin tenant - same network and status code is (204)") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.NETWORKS, TestGroup.REGRESSION }) - public void tenantUserIsAbleToRemoveFavoriteSiteAddedByAdminSameNetwork() throws Exception - { - SiteModel siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); - - restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - tenantUser.setDomain(adminTenantUser.getDomain()); - - restClient.withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingAuthUser().getFavorites() - .assertThat() - .entriesListDoesNotContain("targetGuid", siteModel.getGuidWithoutVersion()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES}, executionType = ExecutionType.REGRESSION, - description = "Verify tenant user deletes favorites site created by admin tenant - same network and status code is (204)") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES,TestGroup.NETWORKS, TestGroup.REGRESSION }) - public void tenantUserIsAbleToDeleteFavoriteSiteAddedByAdminSameNetwork() throws Exception - { - - restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - tenantUser.setDomain(adminTenantUser.getDomain()); - - restClient.withCoreAPI() - .usingAuthUser().deleteSiteFromFavorites(siteModel) - .assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingAuthUser().getFavorites() - .assertThat() - .entriesListDoesNotContain("targetGuid", siteModel.getGuidWithoutVersion()); - siteModel = dataSite.usingUser(tenantUser).createPublicRandomSite(); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/GetFavoriteSiteTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/GetFavoriteSiteTests.java deleted file mode 100644 index 12f5fcbad..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/GetFavoriteSiteTests.java +++ /dev/null @@ -1,292 +0,0 @@ -package org.alfresco.service.search.rest.favorites; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.dataprep.SiteService; -import org.alfresco.rest.core.RestRequest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestSiteModel; -import org.alfresco.rest.model.RestSiteModelsCollection; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Tests for Get Favorite Sites (/people/{personId}/preferences) RestAPI call - * - * @author Cristina Axinte - */ - -public class GetFavoriteSiteTests extends RestTest -{ - private UserModel userModel; - private SiteModel siteModel1; - private SiteModel siteModel2; - private RestSiteModel restSiteModel; - private DataUser.ListUserWithRoles usersWithRoles; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - siteModel1 = dataSite.usingUser(userModel).createPublicRandomSite(); - siteModel2 = dataSite.usingUser(userModel).createPublicRandomSite(); - - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel1, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - - dataSite.usingUser(userModel).usingSite(siteModel1).addSiteToFavorites(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user gets its specific favorite site with Rest API and response is successful (200)") - public void managerUserGetsFavoriteSiteWithSuccess() throws Exception - { - UserModel managerUser = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); - - dataSite.usingUser(managerUser).usingSite(siteModel1).addSiteToFavorites(); - dataSite.usingUser(managerUser).usingSite(siteModel2).addSiteToFavorites(); - - restSiteModel = restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().getFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModel.assertThat().field("id").is(siteModel1.getId()).and().field("title").isNotNull(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify collaborator user gets its specific favorite site with Rest API and response is successful (200)") - public void collaboratorUserGetsFavoriteSiteWithSuccess() throws Exception - { - UserModel collaboratorUser = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); - - dataSite.usingUser(collaboratorUser).usingSite(siteModel1).addSiteToFavorites(); - dataSite.usingUser(collaboratorUser).usingSite(siteModel2).addSiteToFavorites(); - - restSiteModel = restClient.authenticateUser(collaboratorUser).withCoreAPI().usingAuthUser().getFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModel.assertThat().field("id").is(siteModel1.getId()).and().field("title").isNotNull(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify contributor user gets its specific favorite site with Rest API and response is successful (200)") - public void contributorUserGetsFavoriteSiteWithSuccess() throws Exception - { - UserModel contributorUser = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); - - dataSite.usingUser(contributorUser).usingSite(siteModel1).addSiteToFavorites(); - dataSite.usingUser(contributorUser).usingSite(siteModel2).addSiteToFavorites(); - - restSiteModel = restClient.authenticateUser(contributorUser).withCoreAPI().usingAuthUser().getFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModel.assertThat().field("id").is(siteModel1.getId()).and().field("title").isNotNull(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify consumer user gets its specific favorite site with Rest API and response is successful (200)") - public void consumerUserGetsFavoriteSiteWithSuccess() throws Exception - { - UserModel consumerUser = usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer); - - dataSite.usingUser(consumerUser).usingSite(siteModel1).addSiteToFavorites(); - dataSite.usingUser(consumerUser).usingSite(siteModel2).addSiteToFavorites(); - - restSiteModel = restClient.authenticateUser(consumerUser).withCoreAPI().usingAuthUser().getFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModel.assertThat().field("id").is(siteModel1.getId()).and().field("title").isNotNull(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin user gets specific favorite site of any user with Rest API and response is successful (200)") - public void adminUserGetsAnyFavoriteSiteWithSuccess() throws Exception - { - UserModel adminUser = dataUser.getAdminUser(); - UserModel anyUser = dataUser.usingAdmin().createRandomTestUser(); - dataSite.usingUser(anyUser).usingSite(siteModel1).addSiteToFavorites(); - dataSite.usingUser(anyUser).usingSite(siteModel2).addSiteToFavorites(); - - restSiteModel = restClient.authenticateUser(adminUser).withCoreAPI().usingUser(anyUser).getFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModel.assertThat().field("id").is(siteModel1.getId()).and().field("title").isNotNull(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify manager user fails to get specific favorite site of another user with Rest API and response is successful (403)") - public void managerUserFailsToGetFavoriteSiteOfAnotherUser() throws Exception - { - UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel1, UserRole.SiteManager); - dataSite.usingUser(managerUser).usingSite(siteModel1).addSiteToFavorites(); - dataSite.usingUser(managerUser).usingSite(siteModel2).addSiteToFavorites(); - - restClient.authenticateUser(managerUser).withCoreAPI().usingUser(userModel).getFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized gets its specific favorite site with Rest API when authentication fails (401)") -// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void managerUserNotAuthorizedFailsToGetFavoriteSite() throws Exception - { - UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel1, UserRole.SiteManager); - dataSite.usingUser(managerUser).usingSite(siteModel1).addSiteToFavorites(); - dataSite.usingUser(managerUser).usingSite(siteModel2).addSiteToFavorites(); - managerUser.setPassword("newpassword"); - - restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().getFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify invalid request returns status 404 when personId does not exist") - public void getFavoriteSiteWithNonExistentPersonId() throws Exception - { - UserModel someUser = new UserModel("someUser", DataUser.PASSWORD); - - restClient.authenticateUser(userModel).withCoreAPI().usingUser(someUser).getFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "someUser")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify invalid request returns status 404 when siteId does not exist") - public void getFavoriteSiteWithNonExistentSiteId() throws Exception - { - SiteModel nonExistentSite = new SiteModel("nonExistentSite"); - - restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().getFavoriteSite(nonExistentSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, userModel.getUsername(), nonExistentSite.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify User fails to get specific favorite site of admin with Rest API and response is 403") - public void userFailsToGetFavoriteSiteOfAdmin() throws Exception - { - restClient.authenticateUser(userModel).withCoreAPI().usingUser(dataUser.getAdminUser()).getFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify request with empty site id") - public void getFavoriteSiteWithEmptySiteId() throws Exception - { - restClient.authenticateUser(userModel).withCoreAPI(); - RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "people/{personId}/favorite-sites/{siteId}?{parameters}", - userModel.getUsername(), "", restClient.getParameters()); - RestSiteModelsCollection sites = restClient.processModels(RestSiteModelsCollection.class, request); - restClient.assertStatusCodeIs(HttpStatus.OK); - sites.assertThat().entriesListIsNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify invalid request returns status 401 when user is empty") - public void getFavoriteSiteWithEmptyPersonId() throws Exception - { - UserModel emptyUser = new UserModel("", "password"); - restClient.authenticateUser(emptyUser).withCoreAPI().usingAuthUser().getFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify invalid request returns status 404 when another user get favorite site of an user") - public void getFavoriteSiteWithAnotherUser() throws Exception - { - UserModel user = dataUser.createRandomTestUser(); - restClient.authenticateUser(user).withCoreAPI().usingAuthUser().getFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, user.getUsername(), siteModel1.getId())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE) - .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify request returns status 200 when using -me-") - public void getFavoriteSiteUsingMe() throws Exception - { - restSiteModel = restClient.authenticateUser(userModel).withCoreAPI().usingMe().getFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModel.assertThat().field("id").is(siteModel1.getId()) - .and().field("title").is(siteModel1.getTitle()) - .and().field("role").is(UserRole.SiteManager.toString()) - .and().field("visibility").is(SiteService.Visibility.PUBLIC.toString()) - .and().field("guid").isNotEmpty() - .and().field("description").is(siteModel1.getDescription()) - .and().field("preset").is("site-dashboard"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify invalid request returns status 404 when providing folder name instead of site id") - public void getFavoriteSiteUsingFolder() throws Exception - { - FolderModel folder = dataContent.usingUser(userModel).usingSite(siteModel1).createFolder(); - SiteModel siteFolder = new SiteModel(folder.getName()); - restSiteModel = restClient.authenticateUser(userModel).withCoreAPI().usingMe().getFavoriteSite(siteFolder); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, userModel.getUsername(), folder.getName())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify invalid request returns status 404 when providing file name instead of site id") - public void getFavoriteSiteUsingFile() throws Exception - { - FileModel file = dataContent.usingSite(siteModel1).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - SiteModel siteFolder = new SiteModel(file.getName()); - restSiteModel = restClient.authenticateUser(userModel).withCoreAPI().usingMe().getFavoriteSite(siteFolder); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, userModel.getUsername(), file.getName())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify request returns status 200 when using valid parameters") - public void getFavoriteSiteUsingParameters() throws Exception - { - restSiteModel = restClient.withParams("maxItems=100").authenticateUser(userModel).withCoreAPI().usingMe().getFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModel.assertThat().field("id").is(siteModel1.getId()) - .and().field("title").is(siteModel1.getTitle()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify request returns status 400 when using maxItems=0") - public void getFavoriteSiteUsingInvalidMaxItems() throws Exception - { - restSiteModel = restClient.withParams("maxItems=0").authenticateUser(userModel).withCoreAPI().usingMe().getFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify request returns status 401 when using invalid network") - public void getFavoriteSiteUsingInvalidNetwork() throws Exception - { - UserModel invalidUserNetwork = dataUser.createRandomTestUser(); - SiteModel site = dataSite.usingUser(invalidUserNetwork).createPublicRandomSite(); - dataSite.usingUser(invalidUserNetwork).usingSite(site).addSiteToFavorites(); - invalidUserNetwork.setDomain("invalidNetwork"); - restSiteModel = restClient.authenticateUser(invalidUserNetwork).withCoreAPI().usingMe().getFavoriteSite(site); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/GetFavoriteSitesTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/GetFavoriteSitesTests.java deleted file mode 100644 index 141cdd27c..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/GetFavoriteSitesTests.java +++ /dev/null @@ -1,325 +0,0 @@ -package org.alfresco.service.search.rest.favorites; - -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestSiteModel; -import org.alfresco.rest.model.RestSiteModelsCollection; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser; -import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class GetFavoriteSitesTests extends RestTest -{ - private UserModel userModel, testUser1; - private SiteModel siteModel, testSite1, testSite2, testSite3; - private RestSiteModelsCollection restSiteModelsCollection; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - testUser1 = dataUser.createRandomTestUser(); - - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - testSite1 = new SiteModel("A-" + RandomData.getRandomAlphanumeric()); - testSite2 = new SiteModel("B-" + RandomData.getRandomAlphanumeric()); - testSite3 = new SiteModel("C-" + RandomData.getRandomAlphanumeric()); - - dataSite.usingUser(userModel).usingSite(siteModel).addSiteToFavorites(); - - dataSite.usingUser(testUser1).createSite(testSite1); - dataSite.usingUser(testUser1).createSite(testSite2); - dataSite.usingUser(testUser1).createSite(testSite3); - - dataSite.usingUser(testUser1).usingSite(testSite3).addSiteToFavorites(); - dataSite.usingUser(testUser1).usingSite(testSite2).addSiteToFavorites(); - dataSite.usingUser(testUser1).usingSite(testSite1).addSiteToFavorites(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify manager user fails to get an user favorite sites with Rest API (403)") - public void managerUserFailsToGetAnUserFavoriteSites() throws Exception - { - UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); - UserModel anotherUser = dataUser.usingAdmin().createRandomTestUser(); - dataSite.usingUser(anotherUser).usingSite(siteModel).addSiteToFavorites(); - - restClient.authenticateUser(managerUser).withCoreAPI().usingUser(anotherUser).getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify collaborator user fails to get an user favorite sites with Rest API (403)") - public void collaboratorUserFailsToGetAnUserFavoriteSites() throws Exception - { - UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(collaboratorUser, siteModel, UserRole.SiteCollaborator); - UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(contributorUser, siteModel, UserRole.SiteContributor); - dataSite.usingUser(contributorUser).usingSite(siteModel).addSiteToFavorites(); - - restClient.authenticateUser(collaboratorUser).withCoreAPI().usingUser(contributorUser).getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify contributor user fails to get an user favorite sites with Rest API (403)") - public void contributorUserFailsToGetAnUserFavoriteSites() throws Exception - { - UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); - UserModel contributorUser2 = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(contributorUser, siteModel, UserRole.SiteContributor); - dataUser.usingUser(userModel).addUserToSite(contributorUser2, siteModel, UserRole.SiteContributor); - dataSite.usingUser(contributorUser2).usingSite(siteModel).addSiteToFavorites(); - - restClient.authenticateUser(contributorUser).withCoreAPI().usingUser(contributorUser2).getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify consumer user fails to get an user favorite sites with Rest API (403)") - public void consumerUserFailsToGetAnUserFavoriteSites() throws Exception - { - UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); - UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel, UserRole.SiteConsumer); - dataUser.usingUser(collaboratorUser).addUserToSite(collaboratorUser, siteModel, UserRole.SiteCollaborator); - dataSite.usingUser(collaboratorUser).usingSite(siteModel).addSiteToFavorites(); - - restClient.authenticateUser(consumerUser).withCoreAPI().usingUser(collaboratorUser).getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify any user gets its own user favorite sites with Rest API and response is successful (200)") - public void anyUserGetsHisFavoriteSites() throws Exception - { - UserModel anyUser = dataUser.usingAdmin().createRandomTestUser(); - dataSite.usingUser(anyUser).usingSite(siteModel).addSiteToFavorites(); - - restSiteModelsCollection = restClient.authenticateUser(anyUser).withCoreAPI().usingAuthUser().getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModelsCollection.assertThat().entriesListIsNotEmpty().and().entriesListContains("id", siteModel.getId()).and().paginationExist(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify any user is NOT Authorized to get its favorite sites with Rest API when authentication fails (401)") -// @Bug(id = "MNT-16904", description = "It fails only on environment with tenants") - public void unauthenticatedUserIsNotAuthorizedToGetFavoriteSites() throws Exception - { - UserModel anyUser = dataUser.usingAdmin().createRandomTestUser(); - dataSite.usingUser(anyUser).usingSite(siteModel).addSiteToFavorites(); - anyUser.setPassword("newpassword"); - - restClient.authenticateUser(anyUser).withCoreAPI().usingAuthUser().getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify that getFavoriteSites request status code is 404 for a personId that does not exist") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void getFavoriteSitesReturns404ForAPersonIdThatDoesNotExist() throws Exception - { - UserModel invalidUser = new UserModel(RandomData.getRandomName("User"), DataUser.PASSWORD); - - restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingUser(invalidUser).getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, invalidUser.getUsername())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify that getFavoriteSites request status code is 403 if the user doesn't have access to the person favorite sites") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void userCannotGetFavoriteSitesForAnotherUser() throws Exception - { - restClient.authenticateUser(userModel).withCoreAPI().usingUser(testUser1).getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin has access to regular user site favorites") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void adminCanGetFavoriteSitesForARegularUser() throws Exception - { - restSiteModelsCollection = restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingUser(userModel).getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModelsCollection.assertThat().entriesListIsNotEmpty() - .assertThat().entriesListContains("id", siteModel.getId()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify that regular user can not see admin user site favorites") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void regularUserCannotGetFavoriteSitesForAdminUser() throws Exception - { - restClient.authenticateUser(testUser1).withCoreAPI().usingUser(dataUser.getAdminUser()).getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify that favorite site can be removed") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void verifyThatFavoriteSiteCanBeRemoved() throws Exception - { - UserModel randomTestUser = dataUser.createRandomTestUser(); - dataSite.usingUser(randomTestUser).usingSite(siteModel).addSiteToFavorites(); - - restSiteModelsCollection = restClient.authenticateUser(randomTestUser).withCoreAPI().usingAuthUser().getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModelsCollection.assertThat().entriesListIsNotEmpty() - .assertThat().entriesListContains("id", siteModel.getId()); - - dataSite.usingUser(randomTestUser).usingSite(siteModel).removeSiteFromFavorites(); - restSiteModelsCollection = restClient.withCoreAPI().usingAuthUser().getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModelsCollection.assertThat().entriesListIsEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify that if maxItems param is invalid status code returned is BAD_REQUEST (400)") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void getFavoriteSitesMaxItemsInvalidValueTest() throws Exception - { - restClient.authenticateUser(userModel).withParams("maxItems=-1").withCoreAPI().usingAuthUser().getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); - - restClient.authenticateUser(userModel).withParams("maxItems=abc").withCoreAPI().usingAuthUser().getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "abc")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify that if skipCount param is invalid status code returned is BAD_REQUEST (400)") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void getFavoriteSitesSkipCountInvalidValueTest() throws Exception - { - restClient.authenticateUser(userModel).withParams("skipCount=-1").withCoreAPI().usingAuthUser().getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT); - - restClient.authenticateUser(userModel).withParams("skipCount=abc").withCoreAPI().usingAuthUser().getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "abc")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify that getFavoriteSites request response status using -me- string in place of personId is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void userGetsFavoriteSiteWithSuccessUsingMEForRequest() throws Exception - { - restSiteModelsCollection = restClient.authenticateUser(testUser1).withCoreAPI().usingMe().getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModelsCollection.assertThat().entriesListIsNotEmpty() - .and().entriesListContains("id", testSite1.getId()) - .and().paginationExist(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify that getFavoriteSites request response status for a user that has no favorite sites is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void getFavoriteSiteRequestForUserWithNoFavoriteSitesIsSuccessful() throws Exception - { - UserModel randomTestUser = dataUser.createRandomTestUser(); - - restSiteModelsCollection = restClient.authenticateUser(randomTestUser).withCoreAPI().usingMe().getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModelsCollection.assertThat().entriesListIsEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify that getFavoriteSites request response status for a user with several favorite sites is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void getFavoriteSiteRequestForUserWithSeveralFavoriteSitesIsSuccessful() throws Exception - { - restSiteModelsCollection = restClient.authenticateUser(testUser1).withCoreAPI().usingAuthUser().getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModelsCollection.assertThat().entriesListIsNotEmpty() - .and().entriesListContains("id", testSite1.getId()) - .and().entriesListContains("id", testSite2.getId()) - .and().entriesListContains("id", testSite3.getId()) - .and().paginationExist(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify that getFavoriteSites request can only be called with a positive maxItems param") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void userCanNotGetFavoriteSitesWith0MaxItems() throws Exception - { - restClient.authenticateUser(testUser1).withParams("maxItems=0").withCoreAPI().usingAuthUser().getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsErrorKey(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) - .containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify that getFavoriteSites request response status code for a high skipCount param is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void userCanGetFavoriteSitesWithHighSkipCount() throws Exception - { - restSiteModelsCollection = restClient.authenticateUser(testUser1).withParams("skipCount=999999999").withCoreAPI().usingAuthUser().getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModelsCollection.assertThat().entriesListIsEmpty() - .assertThat().paginationField("skipCount").is("999999999"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify that user can retrieve the last 2 favorite sites") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void userCanRetrieveLast2FavoriteSites() throws Exception - { - restSiteModelsCollection = restClient.authenticateUser(testUser1).withParams("skipCount=1&maxCount=2"). - withCoreAPI().usingAuthUser().getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModelsCollection.assertThat().entriesListIsNotEmpty() - .assertThat().entriesListCountIs(2) - .assertThat().entriesListContains("id", testSite2.getId()) - .assertThat().entriesListContains("id", testSite3.getId()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify that getFavoriteSites request applies valid properties param") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void getFavoriteSitesRequestWithValidPropertiesParam() throws Exception - { - RestSiteModel restSiteModel = restClient.authenticateUser(testUser1).withParams("properties=title") - .withCoreAPI().usingAuthUser().getFavoriteSites().getOneRandomEntry().onModel(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModel.assertThat().fieldsCount().is(1) - .assertThat().field("title").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify that getFavoriteSites request applies invalid properties param") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void getFavoriteSitesRequestWithInvalidPropertiesParam() throws Exception - { - restClient.authenticateUser(testUser1).withParams("properties=tas").withCoreAPI().usingAuthUser() - .getFavoriteSites().getOneRandomEntry().onModel().assertThat().fieldsCount().is(0); - restClient.assertStatusCodeIs(HttpStatus.OK); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/GetFavoriteTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/GetFavoriteTests.java deleted file mode 100644 index 0c0f32dbf..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/GetFavoriteTests.java +++ /dev/null @@ -1,480 +0,0 @@ -package org.alfresco.service.search.rest.favorites; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.dataprep.SiteService; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestPersonFavoritesModel; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser; -import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class GetFavoriteTests extends RestTest -{ - private UserModel adminUserModel; - private SiteModel siteModel; - private FolderModel folderModel; - private FileModel fileModel; - private ListUserWithRoles usersWithRoles; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - - folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); - fileModel = dataContent.usingUser(adminUserModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Verify Manager user gets favorite site with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - public void managerIsAbleToRetrieveFavoriteSite() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - - RestPersonFavoritesModel favSite = restClient.withCoreAPI().usingAuthUser().getFavorite(siteModel.getGuid()); - restClient.assertStatusCodeIs(HttpStatus.OK); - favSite.assertThat().field("targetGuid").is(siteModel.getGuid()); - - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Verify Manager user gets favorite folder with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - public void managerIsAbleToRetrieveFavoriteFolder() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(folderModel); - - RestPersonFavoritesModel favoriteFolder = restClient.withCoreAPI().usingAuthUser().getFavorite(folderModel.getNodeRef()); - restClient.assertStatusCodeIs(HttpStatus.OK); - favoriteFolder.assertThat().field("targetGuid").is(folderModel.getNodeRef()); - - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Verify Manager user gets favorite file with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - public void managerIsAbleToRetrieveFavoriteFile() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingAuthUser().addFileToFavorites(fileModel); - - RestPersonFavoritesModel favoriteFile = restClient.withCoreAPI().usingAuthUser().getFavorite(fileModel.getNodeRefWithoutVersion()); - restClient.assertStatusCodeIs(HttpStatus.OK); - favoriteFile.assertThat().field("targetGuid").is(fileModel.getNodeRefWithoutVersion()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Verify user gets status code 401 if authentication call fails") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) -// @Bug(id = "MNT-16904", description = "fails only on environment with tenants") - public void userIsNotAbleToRetrieveFavoriteSiteIfAuthenticationFails() throws Exception - { - UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); - siteManager.setPassword("wrongPassword"); - restClient.authenticateUser(siteManager).withCoreAPI() - .usingUser(siteManager).getFavorite(siteModel.getGuid()); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify Admin user gets favorite site with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void adminIsAbleToRetrieveFavoritesSite() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); - - RestPersonFavoritesModel favoriteSite = restClient.withCoreAPI().usingUser(adminUserModel).getFavorite(siteModel.getGuid()); - restClient.assertStatusCodeIs(HttpStatus.OK); - favoriteSite.assertThat().field("targetGuid").is(siteModel.getGuid()); - favoriteSite.getTarget().getSite() - .assertThat().field("guid").is(siteModel.getGuid()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify Admin user gets favorite folder with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void adminIsAbleToRetrieveFavoritesFolder() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).addFolderToFavorites(folderModel); - - RestPersonFavoritesModel favoriteFolder = restClient.withCoreAPI().usingUser(adminUserModel).getFavorite(folderModel.getNodeRef()); - restClient.assertStatusCodeIs(HttpStatus.OK); - favoriteFolder.assertThat().field("targetGuid").is(folderModel.getNodeRef()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify Admin user gets favorite file with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void adminIsAbleToRetrieveFavoritesFile() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).addFileToFavorites(fileModel); - - RestPersonFavoritesModel favoriteFile = restClient.withCoreAPI().usingUser(adminUserModel).getFavorite(fileModel.getNodeRefWithoutVersion()); - restClient.assertStatusCodeIs(HttpStatus.OK); - favoriteFile.assertThat().field("targetGuid").is(fileModel.getNodeRefWithoutVersion()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify Collaborator user gets favorite site with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void collaboratorIsAbleToRetrieveFavoriteSite() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - - RestPersonFavoritesModel favSite = restClient.withCoreAPI().usingAuthUser().getFavorite(siteModel.getGuid()); - restClient.assertStatusCodeIs(HttpStatus.OK); - favSite.assertThat().field("targetGuid").is(siteModel.getGuid()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify collaborator user gets favorite folder with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void collaboratorIsAbleToRetrieveFavoriteFolder() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(folderModel); - - RestPersonFavoritesModel favoriteFolder = restClient.withCoreAPI().usingAuthUser().getFavorite(folderModel.getNodeRef()); - restClient.assertStatusCodeIs(HttpStatus.OK); - favoriteFolder.assertThat().field("targetGuid").is(folderModel.getNodeRef()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify collaborator user gets favorite file with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void collaboratorIsAbleToRetrieveFavoriteFile() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.withCoreAPI().usingAuthUser().addFileToFavorites(fileModel); - - RestPersonFavoritesModel favoriteFile = restClient.withCoreAPI().usingAuthUser().getFavorite(fileModel.getNodeRefWithoutVersion()); - restClient.assertStatusCodeIs(HttpStatus.OK); - favoriteFile.assertThat().field("targetGuid").is(fileModel.getNodeRefWithoutVersion()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify Contributor user gets favorite site with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void contributorIsAbleToRetrieveFavoriteSite() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - - RestPersonFavoritesModel favSite = restClient.withCoreAPI().usingAuthUser().getFavorite(siteModel.getGuid()); - restClient.assertStatusCodeIs(HttpStatus.OK); - favSite.assertThat().field("targetGuid").is(siteModel.getGuid()); ; - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify contributor user gets favorite folder with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void contributorIsAbleToRetrieveFavoriteFolder() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(folderModel); - - RestPersonFavoritesModel favoriteFolder = restClient.withCoreAPI().usingAuthUser().getFavorite(folderModel.getNodeRef()); - restClient.assertStatusCodeIs(HttpStatus.OK); - favoriteFolder.assertThat().field("targetGuid").is(folderModel.getNodeRef()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify contributor user gets favorite file with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void contributorIsAbleToRetrieveFavoriteFile() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - restClient.withCoreAPI().usingAuthUser().addFileToFavorites(fileModel); - - RestPersonFavoritesModel favoriteFile = restClient.withCoreAPI().usingAuthUser().getFavorite(fileModel.getNodeRefWithoutVersion()); - restClient.assertStatusCodeIs(HttpStatus.OK); - favoriteFile.assertThat().field("targetGuid").is(fileModel.getNodeRefWithoutVersion()); - } - - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify Consumer user gets favorite site with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void consumerIsAbleToRetrieveFavorites() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - - RestPersonFavoritesModel favSite = restClient.withCoreAPI().usingAuthUser().getFavorite(siteModel.getGuid()); - restClient.assertStatusCodeIs(HttpStatus.OK); - favSite.assertThat().field("targetGuid").is(siteModel.getGuid()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify consumer user gets favorite folder with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void consumerIsAbleToRetrieveFavoriteFolder() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(folderModel); - - RestPersonFavoritesModel favoriteFolder = restClient.withCoreAPI().usingAuthUser().getFavorite(folderModel.getNodeRef()); - restClient.assertStatusCodeIs(HttpStatus.OK); - favoriteFolder.assertThat().field("targetGuid").is(folderModel.getNodeRef()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify consumer user gets favorite file with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void consumerIsAbleToRetrieveFavoriteFile() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.withCoreAPI().usingAuthUser().addFileToFavorites(fileModel); - - RestPersonFavoritesModel favoriteFile = restClient.withCoreAPI().usingAuthUser().getFavorite(fileModel.getNodeRefWithoutVersion()); - restClient.assertStatusCodeIs(HttpStatus.OK); - favoriteFile.assertThat().field("targetGuid").is(fileModel.getNodeRefWithoutVersion()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify user doesn't get favorite site of another user with Rest API and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void userIsNotAbleToRetrieveFavoriteSiteOfAnotherSiteMember() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.withCoreAPI().usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .getFavorite(siteModel.getGuid()); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator).getUsername())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify user doesn't get favorite site of admin user with Rest API and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void userIsNotAbleToRetrieveFavoritesOfAdminUser() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .withCoreAPI().usingUser(adminUserModel).getFavorite(siteModel.getGuid()); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, adminUserModel.getUsername())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify admin user doesn't get favorite site of another user with Rest API and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void adminIsNotAbleToRetrieveFavoritesOfAnotherUser() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI() - .usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).getFavorite(siteModel.getGuid()); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator).getUsername())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, - executionType = ExecutionType.REGRESSION, description = "Verify get favorite user doesn't have any favorite site, file or folder") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void getFavoriteSiteForUserWithoutAnyFavorites() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingAuthUser().getFavorite(siteModel.getGuid()); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, usersWithRoles.getOneUserWithRole(UserRole.SiteManager).getUsername(), siteModel.getGuid())) - .statusCodeIs(HttpStatus.NOT_FOUND) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE) - .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify get favorite site for -me-") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void getFavoriteSiteUsingMe() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - - RestPersonFavoritesModel favoriteSite = restClient.withCoreAPI().usingMe().getFavorite(siteModel.getGuid()); - restClient.assertStatusCodeIs(HttpStatus.OK); - favoriteSite.assertThat().field("targetGuid").is(siteModel.getGuid()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify get favorite site for -me-") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void getFavoriteFileUsingMe() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingAuthUser().addFileToFavorites(fileModel); - - RestPersonFavoritesModel favoriteFile = restClient.withCoreAPI().usingMe().getFavorite(fileModel.getNodeRefWithoutVersion()); - restClient.assertStatusCodeIs(HttpStatus.OK); - favoriteFile.assertThat().field("targetGuid").is(fileModel.getNodeRefWithoutVersion()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, - executionType = ExecutionType.REGRESSION, description = "Verify get favorite site when person id does't exist") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void getFavoriteSiteWhenPersonIdNotExist() throws Exception { - - restClient.withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); - UserModel someUser = new UserModel("invalidUser", DataUser.PASSWORD); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(someUser).getFavorite(siteModel.getGuid()); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, someUser.getUsername())) - .statusCodeIs(HttpStatus.NOT_FOUND) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY); - } - - @Bug(id = "ACE-2413") - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, - executionType = ExecutionType.REGRESSION, description = "Verify get favorite site when person id is empty") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void getFavoriteSiteWithEmptyUserId() throws Exception { - - restClient.withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); - UserModel someUser = new UserModel("", DataUser.PASSWORD); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(someUser).getFavorite(siteModel.getGuid()); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, someUser.getUsername())) - .statusCodeIs(HttpStatus.BAD_REQUEST); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, - executionType = ExecutionType.REGRESSION, description = "Verify get favorite site when favorite id does't exist") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void getFavoriteSiteWhenFavoriteIdNotExist() throws Exception { - - restClient.withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).getFavorite("invalidId"); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidId")) - .statusCodeIs(HttpStatus.NOT_FOUND) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify Admin user gets favorite site with properties filter") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void verifyRequestForGetFavoriteSiteWithProperties() throws Exception - { - UserModel collaborator = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); - restClient.authenticateUser(collaborator); - restClient.withCoreAPI().usingUser(collaborator).addSiteToFavorites(siteModel); - - RestPersonFavoritesModel favoriteSite = restClient.authenticateUser(collaborator).withParams("properties=targetGuid") - .withCoreAPI().usingAuthUser().getFavorite(siteModel.getGuid()); - restClient.assertStatusCodeIs(HttpStatus.OK); - favoriteSite.assertThat().field("targetGuid").is(siteModel.getGuid()); - favoriteSite.assertThat().fieldsCount().is(1); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify Admin user gets favorite site with inccorect properties filter") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void verifyRequestForGetFavoriteSiteWithInvalidProperties() throws Exception - { - UserModel collaborator = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); - restClient.authenticateUser(collaborator); - restClient.withCoreAPI().usingUser(collaborator).addFileToFavorites(fileModel); - - RestPersonFavoritesModel favoriteFile = restClient.authenticateUser(collaborator).withParams("properties=tas") - .withCoreAPI().usingAuthUser().getFavorite(fileModel.getNodeRefWithoutVersion()); - restClient.assertStatusCodeIs(HttpStatus.OK); - favoriteFile.assertThat().fieldsCount().is(0); - } - - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify all values from get favorite rest api for a file") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void verifyRequestFieldsForGetFavoriteFile() throws Exception - { - UserModel contributor = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); - restClient.authenticateUser(contributor); - restClient.withCoreAPI().usingUser(contributor).addFileToFavorites(fileModel); - - RestPersonFavoritesModel favoriteFile = restClient.authenticateUser(contributor) - .withCoreAPI().usingAuthUser().getFavorite(fileModel.getNodeRefWithoutVersion()); - restClient.assertStatusCodeIs(HttpStatus.OK); - - favoriteFile.assertThat().field("targetGuid").is(fileModel.getNodeRefWithoutVersion()) - .and().field("target.file.isFile").is("true") - .and().field("target.file.mimeType").is("text/plain") - .and().field("target.file.isFolder").is("false") - .and().field("target.file.createdBy").is(adminUserModel.getUsername()) - .and().field("target.file.versionLabel").is("1.0") - .and().field("target.file.name").is(fileModel.getName()) - .and().field("target.file.parentId").is(folderModel.getNodeRef()) - .and().field("target.file.guid").is(fileModel.getNodeRefWithoutVersion()) - .and().field("target.file.modifiedBy").is(adminUserModel.getUsername()) - .and().field("target.file.id").is(fileModel.getNodeRefWithoutVersion()); - } - - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify all values from get favorite rest api for a site") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void verifyRequestFieldsForGetFavoriteSite() throws Exception - { - UserModel contributor = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); - restClient.authenticateUser(contributor); - restClient.withCoreAPI().usingUser(contributor).addFavoriteSite(siteModel); - - RestPersonFavoritesModel favoriteSite = restClient.authenticateUser(contributor) - .withCoreAPI().usingAuthUser().getFavorite(siteModel.getGuid()); - restClient.assertStatusCodeIs(HttpStatus.OK); - - favoriteSite.assertThat().field("targetGuid").is(siteModel.getGuid()) - .and().field("target.site.role").is(UserRole.SiteContributor.toString()) - .and().field("target.site.visibility").is(SiteService.Visibility.PUBLIC.toString()) - .and().field("target.site.guid").is(siteModel.getGuid()) - .and().field("target.site.description").is(siteModel.getDescription()) - .and().field("target.site.id").is(siteModel.getId()) - .and().field("target.site.preset").is("site-dashboard") - .and().field("target.site.title").is(siteModel.getTitle()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify all values from get favorite rest api for a folder") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void verifyRequestFieldsForGetFavoriteFolder() throws Exception - { - UserModel contributor = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); - restClient.authenticateUser(contributor); - restClient.withCoreAPI().usingUser(contributor).addFolderToFavorites(folderModel); - - RestPersonFavoritesModel favoriteFolder = restClient.authenticateUser(contributor) - .withCoreAPI().usingAuthUser().getFavorite(folderModel.getNodeRef()); - restClient.assertStatusCodeIs(HttpStatus.OK); - - favoriteFolder.assertThat().field("targetGuid").is(folderModel.getNodeRef()) - .and().field("target.folder.isFile").is("false") - .and().field("target.folder.isFolder").is("true") - .and().field("target.folder.createdBy").is(adminUserModel.getUsername()) - .and().field("target.folder.name").is(folderModel.getName()) - .and().field("target.folder.guid").is(folderModel.getNodeRef()) - .and().field("target.folder.modifiedBy").is(adminUserModel.getUsername()) - .and().field("target.folder.id").is(folderModel.getNodeRef()); - } -} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/GetFavoritesTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/GetFavoritesTests.java deleted file mode 100644 index 34f704e45..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/GetFavoritesTests.java +++ /dev/null @@ -1,555 +0,0 @@ -package org.alfresco.service.search.rest.favorites; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestPersonFavoritesModel; -import org.alfresco.rest.model.RestPersonFavoritesModelsCollection; -import org.alfresco.rest.model.RestSiteModel; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class GetFavoritesTests extends RestTest -{ - private UserModel adminUserModel, userModel; - private SiteModel firstSiteModel; - private SiteModel secondSiteModel; - private SiteModel thirdSiteModel; - private FileModel firstFileModel; - private FileModel secondFileModel; - private FolderModel firstFolderModel; - private FolderModel secondFolderModel; - private ListUserWithRoles firstSiteUsers, secondSiteUsers; - private RestPersonFavoritesModelsCollection userFavorites; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - userModel = dataUser.createRandomTestUser(); - - firstSiteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - secondSiteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - thirdSiteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - firstFolderModel = dataContent.usingUser(adminUserModel).usingSite(firstSiteModel).createFolder(); - secondFolderModel = dataContent.usingUser(adminUserModel).usingSite(firstSiteModel).createFolder(); - firstFileModel = dataContent.usingUser(adminUserModel).usingResource(firstFolderModel).createContent(DocumentType.TEXT_PLAIN); - secondFileModel = dataContent.usingUser(adminUserModel).usingResource(firstFolderModel).createContent(DocumentType.TEXT_PLAIN); - - firstSiteUsers = dataUser.addUsersWithRolesToSite(firstSiteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - secondSiteUsers = dataUser.addUsersWithRolesToSite(secondSiteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - - restClient.authenticateUser(userModel); - restClient.withCoreAPI().usingUser(userModel).addSiteToFavorites(firstSiteModel); - restClient.withCoreAPI().usingUser(userModel).addSiteToFavorites(secondSiteModel); - restClient.withCoreAPI().usingUser(userModel).addSiteToFavorites(thirdSiteModel); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Verify Manager user gets favorites with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - public void managerIsAbleToRetrieveFavorites() throws Exception - { - restClient.authenticateUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); - restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(secondSiteModel); - - userFavorites = restClient.withCoreAPI().usingAuthUser().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - userFavorites.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) - .assertThat().entriesListContains("targetGuid", secondSiteModel.getGuid()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Verify user gets status code 401 if authentication call fails") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) -// @Bug(id = "MNT-16904", description = "It fails only on environment with tenants") - public void userIsNotAbleToRetrieveFavoritesIfAuthenticationFails() throws Exception - { - UserModel siteManager = firstSiteUsers.getOneUserWithRole(UserRole.SiteManager); - siteManager.setPassword("wrongPassword"); - restClient.authenticateUser(siteManager).withCoreAPI().usingAuthUser().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify Admin user gets favorites sites with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void adminIsAbleToRetrieveFavoritesSites() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(firstSiteModel); - restClient.withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(secondSiteModel); - - userFavorites = restClient.withCoreAPI() - .usingAuthUser().where().targetSiteExist().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - userFavorites.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) - .and().entriesListContains("targetGuid", secondSiteModel.getGuid()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify Admin user gets favorites folders with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void adminIsAbleToRetrieveFavoritesFolders() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).addFolderToFavorites(firstFolderModel); - restClient.withCoreAPI().usingUser(adminUserModel).addFolderToFavorites(secondFolderModel); - - userFavorites = restClient.withCoreAPI() - .usingAuthUser().where().targetFolderExist().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - userFavorites.assertThat().entriesListContains("targetGuid", firstFolderModel.getNodeRef()) - .and().entriesListContains("targetGuid", secondFolderModel.getNodeRef()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify Admin user gets favorites files with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void adminIsAbleToRetrieveFavoritesFiles() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).addFileToFavorites(firstFileModel); - restClient.withCoreAPI().usingUser(adminUserModel).addFileToFavorites(secondFileModel); - - userFavorites = restClient.withCoreAPI() - .usingAuthUser().where().targetFileExist().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - userFavorites.assertThat().entriesListContains("targetGuid", firstFileModel.getNodeRefWithoutVersion()) - .and().entriesListContains("targetGuid", secondFileModel.getNodeRefWithoutVersion()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify Collaborator user gets favorites with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void collaboratorIsAbleToRetrieveFavorites() throws Exception - { - restClient.authenticateUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); - restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(secondSiteModel); - - userFavorites = restClient.withCoreAPI().usingAuthUser().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - userFavorites.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) - .and().entriesListContains("targetGuid", secondSiteModel.getGuid()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify Contributor user gets favorites with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void contributorIsAbleToRetrieveFavorites() throws Exception - { - restClient.authenticateUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteContributor)) - .withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); - restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(secondSiteModel); - - userFavorites = restClient.withCoreAPI().usingAuthUser().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - userFavorites.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()).and() - .entriesListContains("targetGuid", secondSiteModel.getGuid()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify Consumer user gets favorites with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void consumerIsAbleToRetrieveFavorites() throws Exception - { - restClient.authenticateUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteConsumer)) - .withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); - restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(secondSiteModel); - - userFavorites = restClient.withCoreAPI().usingAuthUser().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - userFavorites.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) - .assertThat().entriesListContains("targetGuid", secondSiteModel.getGuid()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify user doesn't have permission to get favorites of another user with Rest API and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void userIsNotAbleToRetrieveFavoritesOfAnotherUser() throws Exception - { - restClient.authenticateUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteConsumer)) - .withCoreAPI().usingUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)).getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, firstSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator).getUsername())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify user doesn't have permission to get favorites of admin user with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void userIsNotAbleToRetrieveFavoritesOfAdminUser() throws Exception - { - restClient.authenticateUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI() - .usingUser(adminUserModel).getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, adminUserModel.getUsername())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify admin user doesn't have permission to get favorites of another user with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void adminIsNotAbleToRetrieveFavoritesOfAnotherUser() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)) - .getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, firstSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator).getUsername())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify User gets only favorites sites with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void userIsAbleToRetrieveOnlyFavoritesSites() throws Exception - { - restClient.authenticateUser(secondSiteUsers.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); - restClient.withCoreAPI().usingAuthUser().addFileToFavorites(firstFileModel); - restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(firstFolderModel); - - userFavorites = restClient.withCoreAPI().usingAuthUser().where().targetSiteExist().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - userFavorites.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) - .and().entriesListDoesNotContain("targetGuid", secondSiteModel.getGuid()) - .and().entriesListDoesNotContain("targetGuid", firstFileModel.getNodeRefWithoutVersion()) - .and().entriesListDoesNotContain("targetGuid", firstFolderModel.getNodeRef()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify User gets only favorites files with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void userIsAbleToRetrieveOnlyFavoritesFiles() throws Exception - { - restClient.authenticateUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); - restClient.withCoreAPI().usingAuthUser().addFileToFavorites(firstFileModel); - restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(firstFolderModel); - - userFavorites = restClient.withCoreAPI().usingAuthUser().where().targetFileExist().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - userFavorites.assertThat().entriesListContains("targetGuid", firstFileModel.getNodeRefWithoutVersion()) - .and().entriesListDoesNotContain("targetGuid", secondFileModel.getNodeRefWithoutVersion()) - .and().entriesListDoesNotContain("targetGuid", firstSiteModel.getGuid()) - .and().entriesListDoesNotContain("targetGuid", firstFolderModel.getNodeRef()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify User gets only favorites folders with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void userIsAbleToRetrieveOnlyFavoritesFolders() throws Exception - { - restClient.authenticateUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); - restClient.withCoreAPI().usingAuthUser().addFileToFavorites(firstFileModel); - restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(firstFolderModel); - - userFavorites = restClient.withCoreAPI().usingAuthUser().where().targetFolderExist().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - userFavorites.assertThat().entriesListContains("targetGuid", firstFolderModel.getNodeRef()) - .and().entriesListDoesNotContain("targetGuid", secondFolderModel.getNodeRef()) - .and().entriesListDoesNotContain("targetGuid", firstSiteModel.getGuid()) - .and().entriesListDoesNotContain("targetGuid", firstFileModel.getNodeRefWithoutVersion()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify User gets only favorites files or folders with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void userIsAbleToRetrieveFavoritesFilesOrFolders() throws Exception - { - restClient.authenticateUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); - restClient.withCoreAPI().usingAuthUser().addFileToFavorites(firstFileModel); - restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(firstFolderModel); - - userFavorites = restClient.withCoreAPI().usingAuthUser() - .where().targetFolderExist().or().targetFileExist() - .getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - userFavorites.assertThat().entriesListContains("targetGuid", firstFolderModel.getNodeRef()) - .and().entriesListContains("targetGuid", firstFileModel.getNodeRefWithoutVersion()) - .and().entriesListDoesNotContain("targetGuid", secondFolderModel.getNodeRef()) - .and().entriesListDoesNotContain("targetGuid", secondFileModel.getNodeRefWithoutVersion()) - .and().entriesListDoesNotContain("targetGuid", firstSiteModel.getGuid()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify User gets only favorites files or sites with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void userIsAbleToRetrieveFavoritesFilesOrSites() throws Exception - { - restClient.authenticateUser(secondSiteUsers.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); - restClient.withCoreAPI().usingAuthUser().addFileToFavorites(firstFileModel); - restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(firstFolderModel); - - userFavorites = restClient.withCoreAPI().usingAuthUser() - .where().targetSiteExist().or().targetFileExist() - .getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - userFavorites.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) - .and().entriesListContains("targetGuid", firstFileModel.getNodeRefWithoutVersion()) - .and().entriesListDoesNotContain("targetGuid", secondSiteModel.getGuid()) - .and().entriesListDoesNotContain("targetGuid", secondFileModel.getNodeRefWithoutVersion()) - .and().entriesListDoesNotContain("targetGuid", firstFolderModel.getNodeRef()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify User gets only favorites folders or sites with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void userIsAbleToRetrieveFavoritesFoldersOrSites() throws Exception - { - restClient.authenticateUser(secondSiteUsers.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); - restClient.withCoreAPI().usingAuthUser().addFileToFavorites(firstFileModel); - restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(firstFolderModel); - - userFavorites = restClient.withCoreAPI().usingAuthUser() - .where().targetSiteExist().or().targetFolderExist() - .getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - userFavorites.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) - .and().entriesListContains("targetGuid", firstFolderModel.getNodeRef()) - .and().entriesListDoesNotContain("targetGuid", secondSiteModel.getGuid()) - .and().entriesListDoesNotContain("targetGuid", secondFolderModel.getNodeRef()) - .and().entriesListDoesNotContain("targetGuid", firstFileModel.getNodeRefWithoutVersion()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify User gets all favorites with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void userIsAbleToRetrieveAllFavorites() throws Exception - { - restClient.authenticateUser(secondSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); - restClient.withCoreAPI().usingAuthUser().addFileToFavorites(firstFileModel); - restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(firstFolderModel); - - userFavorites = restClient.withCoreAPI().usingAuthUser() - .where().targetSiteExist().or().targetFolderExist().or().targetFileExist() - .getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - userFavorites.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) - .and().entriesListContains("targetGuid", firstFolderModel.getNodeRef()) - .and().entriesListContains("targetGuid", firstFileModel.getNodeRefWithoutVersion()) - .and().entriesListDoesNotContain("targetGuid", secondSiteModel.getGuid()) - .and().entriesListDoesNotContain("targetGuid", secondFolderModel.getNodeRef()) - .and().entriesListDoesNotContain("targetGuid", secondFileModel.getNodeRefWithoutVersion()); - - userFavorites = restClient.withCoreAPI().usingAuthUser().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - userFavorites.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) - .and().entriesListContains("targetGuid", firstFolderModel.getNodeRef()) - .and().entriesListContains("targetGuid", firstFileModel.getNodeRefWithoutVersion()) - .and().entriesListDoesNotContain("targetGuid", secondSiteModel.getGuid()) - .and().entriesListDoesNotContain("targetGuid", secondFolderModel.getNodeRef()) - .and().entriesListDoesNotContain("targetGuid", secondFileModel.getNodeRefWithoutVersion()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify request for a user with no favorites returns status 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void userHasNoFavorites() throws Exception - { - restClient.authenticateUser(secondSiteUsers.getOneUserWithRole(UserRole.SiteContributor)); - - userFavorites = restClient.withCoreAPI().usingAuthUser().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - userFavorites.assertThat().entriesListIsEmpty().and().paginationField("totalItems").is("0"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify request using invalid where parameter returns status 400") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void getFavoritesUsingInvalidWhereParameter() throws Exception - { - restClient.authenticateUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); - restClient.withCoreAPI().usingAuthUser().addFileToFavorites(firstFileModel); - restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(firstFolderModel); - - userFavorites = restClient.withCoreAPI().usingAuthUser() - .where().or().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_ARGUMENT, "WHERE query")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify User gets correct favorites after deleting a favorite") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void checkFavoriteFolderIsRemoved() throws Exception - { - restClient.authenticateUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); - restClient.withCoreAPI().usingAuthUser().addFileToFavorites(firstFileModel); - restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(firstFolderModel); - - restClient.withCoreAPI().usingAuthUser().deleteFolderFromFavorites(firstFolderModel); - - userFavorites = restClient.withCoreAPI().usingAuthUser().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - userFavorites.assertThat().entriesListDoesNotContain("targetGuid", firstFolderModel.getNodeRef()) - .and().paginationField("totalItems").is("2"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify get favorites specifying -me- string in place of for request") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void userIsAbleToGetFavoritesWhenUsingMeAsUsername() throws Exception - { - userFavorites = restClient.authenticateUser(userModel).withCoreAPI().usingMe().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - userFavorites.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()).and().entriesListContains("targetGuid", secondSiteModel.getGuid()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify get favorites using empty for where parameter for request") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void userIsAbleToGetFavoritesWhenUsingEmptyWhereParameter() throws Exception - { - userFavorites = restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().where().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_ARGUMENT, "WHERE query")); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that for invalid maxItems parameter status code returned is 400.") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void checkInvalidMaxItemsStatusCode() throws Exception - { - restClient.authenticateUser(adminUserModel).withParams("maxItems=AB").withCoreAPI().usingUser(adminUserModel).getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Invalid paging parameter"); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that for invalid skipCount parameter status code returned is 400.") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void checkInvalidSkipCountStatusCode() throws Exception - { - restClient.authenticateUser(adminUserModel).withParams("skipCount=AB").withCoreAPI().usingUser(adminUserModel).getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Invalid paging parameter"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify get favorites when using invalid network id for non-tenant user") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void getFavoritesWhenNetworkIdIsInvalid() throws Exception - { - UserModel networkUserModel = dataUser.createRandomTestUser(); - networkUserModel.setDomain("invalidNetwork"); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(networkUserModel).where().targetSiteExist().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, networkUserModel.getUsername())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify get favorites using AND instead of OR in where parameter for request") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void userIsNotAbleToGetFavoritesWhenUsingANDInWhereParameter() throws Exception - { - userFavorites = restClient.withCoreAPI().usingAuthUser().where().targetFolderExist().invalidWhereParameter("AND").targetFileExist().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_ARGUMENT, "WHERE query")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify get favorites using wrong name instead of EXISTS in where parameter for request") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void userIsNotAbleToGetFavoritesWhenUsingWrongWhereParameter() throws Exception - { - userFavorites = restClient.withCoreAPI().usingAuthUser().where().invalidWhereParameter("EXIST((target/site))").targetFileExist().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_ARGUMENT, "WHERE query")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify get favorites except the first one for request") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void userIsAbleToGetFavoritesExceptTheFirstOne() throws Exception - { - userFavorites = restClient.authenticateUser(userModel).withParams("skipCount=1").withCoreAPI().usingUser(userModel).getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - userFavorites.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) - .and().entriesListContains("targetGuid", secondSiteModel.getGuid()) - .and().entriesListDoesNotContain("targetGuid", thirdSiteModel.getGuid()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify get first two favorites sites") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void userIsAbleToGetFirstTwoFavorites() throws Exception - { - userFavorites = restClient.authenticateUser(userModel).withParams("maxItems=2").withCoreAPI().usingUser(userModel).getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - userFavorites.assertThat().entriesListContains("targetGuid", thirdSiteModel.getGuid()) - .and().entriesListContains("targetGuid", secondSiteModel.getGuid()) - .and().entriesListDoesNotContain("targetGuid", firstSiteModel.getGuid()) - .getPagination().assertThat().field("maxItems").is("2") - .and().field("hasMoreItems").is("true") - .and().field("count").is("2"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify get favorites sites when using empty values for skipCount and maxItems") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void userIsAbleToGetFavoritesWhenSkipCountAndMaxItemsAreEmpty() throws Exception - { - restClient.authenticateUser(userModel).withParams("skipCount= ").withCoreAPI().usingUser(userModel).getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, " ")); - - restClient.authenticateUser(userModel).withParams("maxItems= ").withCoreAPI().usingUser(userModel).getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, " ")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify the get favorites request for a high value for skipCount parameter") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void userIsAbleToGetFavoritesWithHighSkipCount() throws Exception - { - userFavorites = restClient.authenticateUser(userModel).withParams("skipCount=999999999").withCoreAPI().usingUser(userModel).getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - userFavorites.assertThat().entriesListIsEmpty().assertThat().paginationField("skipCount").is("999999999"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify the get favorites request with properties parameter applied") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void userIsAbleToGetFavoritesWithPropertiesParamApplied() throws Exception - { - userFavorites = restClient.authenticateUser(userModel).withParams("properties=targetGuid").withCoreAPI().usingUser(userModel).getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - RestPersonFavoritesModel restPersonFavoritesModel = userFavorites.getEntries().get(0).onModel(); - restPersonFavoritesModel.assertThat().field("targetGuid").is(thirdSiteModel.getGuid()).and().field("createdAt").isNull(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify entry details for get favorites response with Rest API") - public void checkResponseSchemaForGetFavorites() throws Exception - { - userFavorites = restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - RestPersonFavoritesModel restPersonFavoritesModel = userFavorites.getEntries().get(0).onModel(); - restPersonFavoritesModel.assertThat().field("targetGuid").is(thirdSiteModel.getGuid()); - - RestSiteModel restSiteModel = restPersonFavoritesModel.getTarget().getSite(); - restSiteModel.assertThat().field("visibility").is(thirdSiteModel.getVisibility()).and() - .field("guid").is(thirdSiteModel.getGuid()).and() - .field("description").is(thirdSiteModel.getDescription()).and() - .field("id").is(thirdSiteModel.getId()).and() - .field("title").is(thirdSiteModel.getTitle()); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/groups/GroupsTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/groups/GroupsTests.java deleted file mode 100644 index cbc87a06a..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/groups/GroupsTests.java +++ /dev/null @@ -1,158 +0,0 @@ -package org.alfresco.service.search.rest.groups; - -import java.util.UUID; - -import javax.json.Json; -import javax.json.JsonObject; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.utility.RetryOperation; -import org.alfresco.utility.Utility; -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; - -@Test(groups = {TestGroup.REQUIRE_SOLR}) -public class GroupsTests extends RestTest -{ - private UserModel adminUser, userModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userModel = dataUser.createRandomTestUser(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.GROUPS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.SANITY, - description = "Verify creation, listing, updating and deletion of groups.") - public void createListUpdateAndDeleteGroup() throws Exception - { - String groupName = "ZtestGroup" + UUID.randomUUID().toString(); - JsonObject groupBody = Json.createObjectBuilder().add("id", groupName).add("displayName", groupName).build(); - String groupBodyCreate = groupBody.toString(); - - //GroupCreation: - //-ve - restClient.authenticateUser(userModel).withCoreAPI().usingGroups().createGroup(groupBodyCreate); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - //+ve - restClient.authenticateUser(adminUser).withCoreAPI().usingParams("include=zones").usingGroups().createGroup(groupBodyCreate) - .assertThat().field("zones").contains("APP.DEFAULT") - .and().field("isRoot").is(true) - .and().field("displayName").is(groupName); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - //ListGroups: - restClient.withCoreAPI().usingParams("orderBy=displayName DESC&maxItems=10").usingGroups().listGroups() - .assertThat().entriesListContains("id", "GROUP_"+groupName) - .and().entriesListDoesNotContain("zones") - .and().paginationField("maxItems").is("10"); - restClient.assertStatusCodeIs(HttpStatus.OK); - - groupBody = Json.createObjectBuilder().add("displayName", "Z"+groupName).build(); - String groupBodyUpdate = groupBody.toString(); - //UpdateGroup: - restClient.withCoreAPI().usingGroups().updateGroupDetails("GROUP_"+groupName, groupBodyUpdate) - .assertThat().field("displayName").is("Z"+groupName) - .and().field("id").is("GROUP_"+groupName) - .and().field("zones").isNull(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - //GetGroupDetails: - restClient.withCoreAPI().usingParams("include=zones").usingGroups().getGroupDetail("GROUP_"+groupName) - .assertThat().field("id").is("GROUP_"+groupName) - .and().field("zones").contains("APP.DEFAULT") - .and().field("isRoot").is(true); - restClient.assertStatusCodeIs(HttpStatus.OK); - - //DeleteGroup: - //-ve - restClient.authenticateUser(userModel).withCoreAPI().usingGroups().deleteGroup("GROUP_"+groupName); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - //+ve - restClient.authenticateUser(adminUser).withCoreAPI().usingGroups().deleteGroup("GROUP_"+groupName); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.GROUPS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.SANITY, - description = "Verify creation, listing(only for person) and deletion of group memberships. ") - public void createListDeleteGroupMembership() throws Exception - { - String groupName = "ZtestGroup" + UUID.randomUUID().toString(); - JsonObject groupBody = Json.createObjectBuilder().add("id", groupName).add("displayName", groupName).build(); - String groupBodyCreate = groupBody.toString(); - - //GroupCreation: - restClient.authenticateUser(adminUser).withCoreAPI().usingParams("include=zones").usingGroups().createGroup(groupBodyCreate); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - JsonObject groupMembershipBody = Json.createObjectBuilder().add("id", userModel.getUsername()).add("memberType", "PERSON").build(); - String groupMembershipBodyCreate = groupMembershipBody.toString(); - //MembershipCreation: - //-ve - restClient.authenticateUser(userModel).withCoreAPI().usingGroups().createGroupMembership("GROUP_"+groupName, groupMembershipBodyCreate); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - //+ve - restClient.authenticateUser(adminUser).withCoreAPI().usingGroups().createGroupMembership("GROUP_"+groupName, groupMembershipBodyCreate); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - //ListPersonMembership - restClient.authenticateUser(userModel).withCoreAPI().usingUser(userModel).listGroupMemberships() - .assertThat().entriesListContains("id", "GROUP_"+groupName); - restClient.assertStatusCodeIs(HttpStatus.OK); - - //DeleteGroupMembership - //-ve - restClient.withCoreAPI().usingGroups().deleteGroupMembership("GROUP_"+groupName, userModel.getUsername()); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - //+ve - restClient.authenticateUser(adminUser).withCoreAPI().usingGroups().deleteGroupMembership("GROUP_"+groupName, userModel.getUsername()); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - //ListAgainPersonMembership - restClient.withCoreAPI().usingUser(userModel).listGroupMemberships() - .assertThat().entriesListDoesNotContain("id", "GROUP_"+groupName); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.GROUPS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.SANITY, - description = "Verify listing of group memberships.") - public void listGroupMembership() throws Exception - { - String groupName = "testGroup" + UUID.randomUUID().toString(); - JsonObject groupBody = Json.createObjectBuilder().add("id", groupName).add("displayName", groupName).build(); - String groupBodyCreate = groupBody.toString(); - - //GroupCreation: - restClient.authenticateUser(adminUser).withCoreAPI().usingParams("include=zones").usingGroups().createGroup(groupBodyCreate); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - JsonObject groupMembershipBody = Json.createObjectBuilder().add("id", userModel.getUsername()).add("memberType", "PERSON").build(); - String groupMembershipBodyCreate = groupMembershipBody.toString(); - - //MembershipCreation - restClient.withCoreAPI().usingGroups().createGroupMembership("GROUP_"+groupName, groupMembershipBodyCreate) - .assertThat().field("displayName").is(userModel.getUsername()) - .and().field("id").is(userModel.getUsername()) - .and().field("memberType").is("PERSON"); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - //ListGroupMembership - RetryOperation op = new RetryOperation(){ - public void execute() throws Exception{ - restClient.withCoreAPI().usingGroups().listGroupMemberships("GROUP_"+groupName) - .assertThat().entriesListContains("id", userModel.getUsername()); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - }; - Utility.sleep(1000, 35000, op);// Allow indexing to complete. - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/networks/RestGetNetworkForPersonTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/networks/RestGetNetworkForPersonTests.java deleted file mode 100644 index 1f0078dac..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/networks/RestGetNetworkForPersonTests.java +++ /dev/null @@ -1,151 +0,0 @@ -package org.alfresco.service.search.rest.networks; - -import java.util.ArrayList; - -import org.alfresco.service.search.rest.NetworkDataPrep; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestNetworkQuotaModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Tests for /people/{personId}/networks - */ -public class RestGetNetworkForPersonTests extends NetworkDataPrep -{ - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - init(); - } - - @Bug(id = "MNT-16904") - @TestRail(section = { TestGroup.REST_API, - TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, description = "Verify non existing user gets another existing network with Rest API and checks the forbidden status") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) - public void nonExistingTenantUserIsNotAuthorizedToRequest() throws Exception - { - UserModel tenantUser = new UserModel("nonexisting", "password"); - tenantUser.setDomain(adminTenantUser.getDomain()); - restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().getNetwork(adminTenantUser); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify tenant admin user gets specific network with Rest API and response is not empty") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) - public void adminTenantChecksIfNetworkIsPresent() throws Exception - { - restClient.authenticateUser(adminTenantUser).withCoreAPI().usingUser(adminTenantUser).getNetwork(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify tenant user gets specific network with Rest API and response is not empty") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) - public void tenantUserChecksIfNetworkIsPresent() throws Exception - { - restClient.authenticateUser(tenantUser).withCoreAPI().usingUser(tenantUser).getNetwork(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Bug(id = "needs to be checked") - @TestRail(section = { TestGroup.REST_API, - TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, description = "Verify tenant user check network of admin user with Rest API") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) - public void tenantUserIsNotAuthorizedToCheckNetworkOfAdminUser() throws Exception - { - restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().getNetwork(adminTenantUser); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Bug(id = "needs to be checked") - @TestRail(section = { TestGroup.REST_API, - TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, description = "Verify getNetwork request status code is 200 if a user tries to get network information of another user") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) - public void verifyGetNetworkByAUserForAnotherUser() throws Exception - { - UserModel randomTestUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("randomTestUser"); - restNetworkModel = restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().getNetwork(randomTestUser); - restClient.assertStatusCodeIs(HttpStatus.OK); - restNetworkModel.assertThat().field("id").is(tenantUser.getDomain()); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, description = "Verify that getNetwork status code is 404 for a personId that does not exist") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) - public void verifyThatGetNetworkStatusIs404ForAPersonIdThatDoesNotExist() throws Exception - { - UserModel invalidUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("validUsername"); - invalidUser.setUsername("invalidUsername"); - - restClient.authenticateUser(adminTenantUser).withCoreAPI().usingUser(invalidUser).getNetwork(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, invalidUser.getUsername())).descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, description = "Verify that getNetwork status code is 404 for a networkId that does not exist") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) - public void verifyThatGetNetworkStatusIs404ForANetworkIdThatDoesNotExist() throws Exception - { - UserModel invalidUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("invalidNetworkId"); - invalidUser.setDomain("invalidNetworkId"); - - restClient.authenticateUser(adminTenantUser).withCoreAPI().usingUser(invalidUser).getNetwork(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, invalidUser.getUsername())).descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, description = "Verify getNetwork request that is made using -me- instead of personId") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) - public void verifyGetNetworkRequestUsingMeInsteadOfPersonId() throws Exception - { - restNetworkModel = restClient.authenticateUser(adminTenantUser).withCoreAPI().usingMe().getNetwork(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restNetworkModel.assertThat().field("quotas").is(new ArrayList()).assertThat().field("isEnabled").is("true").assertThat() - .field("homeNetwork").is("true").assertThat().field("id").is(adminTenantUser.getDomain().toLowerCase()); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, description = "Verify that properties parameter is applied to getNetwork request") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) - public void verifyPropertiesParameterIsAppliedToGetNetworkRequest() throws Exception - { - restNetworkModel = restClient.authenticateUser(adminTenantUser).withParams("properties=id,isEnabled,homeNetwork,paidNetwork").withCoreAPI().usingMe() - .getNetwork(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restNetworkModel.assertThat().field("id").is(adminTenantUser.getDomain().toLowerCase()).assertThat().field("isEnabled").is("true").assertThat() - .field("homeNetwork").is("true").assertThat().field("paidNetwork").is("false").assertThat().field("quotas").isNull(); - restNetworkModel.assertThat().fieldsCount().is(4); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, description = "Verify getNetwork request status code is 404 for a network to which user does not belong") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) - public void verifyGetNetworkRequestStatusCodeIs404ForANetworkToWhichTheUserDoesNotBelong() throws Exception - { - restClient.authenticateUser(adminTenantUser).withCoreAPI().usingAuthUser().getNetwork(secondAdminTenantUser); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, description = "Verify admin tenant user is not authorized to check network of another user with Rest API and checks the forbidden status") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) - public void adminTenantUserIsNotAuthorizedToCheckNetworkOfAnotherUser() throws Exception - { - UserModel secondTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("anotherTenant"); - restClient.authenticateUser(secondAdminTenantUser).withCoreAPI().usingAuthUser().getNetwork(secondTenantUser); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/networks/RestGetNetworkTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/networks/RestGetNetworkTests.java deleted file mode 100644 index 8bc917e1e..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/networks/RestGetNetworkTests.java +++ /dev/null @@ -1,145 +0,0 @@ -package org.alfresco.service.search.rest.networks; - -import org.alfresco.service.search.rest.NetworkDataPrep; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestNetworkModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.json.JSONException; -import org.json.JSONObject; -import org.springframework.http.HttpStatus; -import org.testng.Assert; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Created by Cristina Axinte on 9/26/2016. - */ -public class RestGetNetworkTests extends NetworkDataPrep -{ - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - init(); - } - - @Bug(id = "MNT-16904") - @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, - description = "Verify non existing user gets another exisiting network with Rest API and checks the forbidden status") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY}) - public void nonExistingTenantUserIsNotAuthorizedToRequest() throws Exception - { - UserModel tenantUser = new UserModel("nonexisting", "password"); - tenantUser.setDomain(adminTenantUser.getDomain()); - restClient.authenticateUser(tenantUser); - restClient.withCoreAPI().usingNetworks().getNetwork(adminTenantUser); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, - description = "Verify tenant admin user gets specific network with Rest API and response is not empty") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) - public void adminTenantChecksIfNetworkIsPresent() throws Exception - { - restClient.authenticateUser(adminTenantUser); - restClient.withCoreAPI().usingNetworks().getNetwork().assertNetworkHasName(adminTenantUser).assertNetworkIsEnabled(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Verify tenant admin user gets another existing network with Rest API and checks the forbidden status") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) - public void adminTenantChecksIfAnotherExistingNetworkIsForbidden() throws Exception - { - restClient.authenticateUser(adminTenantUser); - restClient.withCoreAPI().usingNetworks().getNetwork(secondAdminTenantUser); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, - description = "Verify any tenant user gets its network with Rest API and response is not empty") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) - public void userTenantChecksIfNetworkIsPresent() throws Exception - { - restClient.authenticateUser(tenantUser); - restClient.withCoreAPI().usingNetworks().getNetwork(adminTenantUser).assertNetworkHasName(adminTenantUser).assertNetworkIsEnabled(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Verify any tenant user gets non existing network with Rest API and checks the not found status") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) - public void userTenantChecksIfNonExistingNetworkIsNotFound() throws Exception - { - restClient.authenticateUser(tenantUser); - restClient.withCoreAPI().usingNetworks().getNetwork(UserModel.getRandomTenantUser()); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Verify any tenant user gets another existing network with Rest API and checks the forbidden status") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) - public void userTenantChecksIfAnotherExistingNetworkIsForbidden() throws Exception - { - restClient.authenticateUser(tenantUser); - restClient.withCoreAPI().usingNetworks().getNetwork(secondAdminTenantUser); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - } - - @Bug(id = "ACE-5738") - @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Verify tenant admin user gets an invalid network with Rest API and checks the not found status") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) - public void adminTenantGetsInvalidNetwork() throws Exception - { - restClient.authenticateUser(secondAdminTenantUser); - secondAdminTenantUser.setDomain("tenant.@%"); - - restClient.withCoreAPI().usingNetworks().getNetwork(secondAdminTenantUser); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.UNEXPECTED_TENANT, adminTenantUser.getDomain(), "@")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Bug(id = "ACE-5745") - @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Verify admin user gets an existing network successfully with Rest API") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) - public void adminUserGetsExistingNetwork() throws Exception - { - RestNetworkModel restNetworkModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingNetworks().getNetwork(adminTenantUser); - restClient.assertStatusCodeIs(HttpStatus.OK); - restNetworkModel.assertThat().fieldsCount().is("1"); - restNetworkModel.assertThat().field("id").is(adminTenantUser.getDomain()) - .and().field("homeNetwork").isNull() - .and().field("isEnabled").is("true"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Verify tenant admin user gets network using properties parameter successfully with Rest API") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) - public void adminTenantGetsNetworkUsingPropertiesParameter() throws Exception - { - JSONObject entryResponse= restClient.authenticateUser(tenantUser).withCoreAPI().usingNetworks().usingParams("properties=id").getNetworkWithParams(adminTenantUser); - restClient.assertStatusCodeIs(HttpStatus.OK); - Assert.assertTrue(entryResponse.get("id").equals(adminTenantUser.getDomain().toLowerCase())); - assertJsonResponseDoesnotContainField(entryResponse, "homeNetwork"); - assertJsonResponseDoesnotContainField(entryResponse, "isEnabled"); - } - - private void assertJsonResponseDoesnotContainField(JSONObject entryResponse, String field) - { - try{ - entryResponse.get(field); - } - catch(JSONException ex) - { - Assert.assertTrue(ex.getMessage().equals(String.format("JSONObject[\"%s\"] not found.", field))); - } - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/networks/RestGetNetworksForPersonTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/networks/RestGetNetworksForPersonTests.java deleted file mode 100644 index db118a56d..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/networks/RestGetNetworksForPersonTests.java +++ /dev/null @@ -1,166 +0,0 @@ -package org.alfresco.service.search.rest.networks; - -import org.alfresco.service.search.rest.NetworkDataPrep; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestNetworkModelsCollection; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class RestGetNetworksForPersonTests extends NetworkDataPrep -{ - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - init(); - } - - @Bug(id = "MNT-16904") - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, - description = "Verify non existing user gets another exisiting network with Rest API and checks the unauthorized status") - @Test(groups = { TestGroup.REST_API, TestGroup.SANITY, TestGroup.NETWORKS }) - public void nonExistingTenantUserIsNotAuthorizedToRequest() throws Exception - { - UserModel tenantUser = new UserModel("nonexisting", "password"); - tenantUser.setDomain(adminTenantUser.getDomain()); - restClient.authenticateUser(tenantUser); - restClient.withCoreAPI().usingAuthUser().getNetworks(adminTenantUser); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, - description = "Verify tenant admin user gets specific network with Rest API and response is not empty") - @Test(groups = {TestGroup.REST_API, TestGroup.SANITY, TestGroup.NETWORKS }) - public void adminTenantChecksIfNetworkIsPresent() throws Exception - { - RestNetworkModelsCollection networks = restClient.authenticateUser(adminTenantUser).withCoreAPI().usingAuthUser().getNetworks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - networks.getOneRandomEntry().onModel().assertNetworkIsEnabled() - .and().field("id").is(adminTenantUser.getDomain().toLowerCase()) - .and().field("quotas").is("[]") - .and().field("homeNetwork").is("false"); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, - description = "Verify tenant user gets specific network with Rest API and response is not empty") - @Test(groups = {TestGroup.REST_API, TestGroup.SANITY, TestGroup.NETWORKS }) - public void tenantUserChecksIfNetworkIsPresent() throws Exception - { - restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().getNetworks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Verify tenant user is not authorized to check network of admin user with Rest API and checks the forbidden status") - @Test(groups = {TestGroup.REST_API, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void tenantUserIsNotAuthorizedToCheckNetworkOfAdminUser() throws Exception - { - restClient.authenticateUser(tenantUser); - restClient.withCoreAPI().usingAuthUser().getNetworks(adminTenantUser); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Verify admin tenant user is not authorized to check network of another user with Rest API and checks the forbidden status") - @Test(groups = {TestGroup.REST_API, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void adminTenantUserIsNotAuthorizedToCheckNetworkOfAnotherUser() throws Exception - { - restClient.authenticateUser(secondAdminTenantUser); - restClient.withCoreAPI().usingAuthUser().getNetworks(secondTenantUser); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Get tenant user networks using invalid value for skipCount") - @Test(groups = {TestGroup.REST_API, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void invalidValueForSkipCountTest() throws Exception - { - restClient.authenticateUser(adminTenantUser).withParams("skipCount=abc").withCoreAPI().usingAuthUser().getNetworks(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "abc")); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Get tenant user networks using invalid value for maxItems") - @Test(groups = {TestGroup.REST_API, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void invalidValueForMaxItemsTest() throws Exception - { - restClient.authenticateUser(adminTenantUser).withParams("maxItems=abc").withCoreAPI().usingAuthUser().getNetworks(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "abc")); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Get tenant user networks using personId that does not exist") - @Test(groups = {TestGroup.REST_API, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void inexistentTenantTest() throws Exception - { - restClient.authenticateUser(adminTenantUser).withCoreAPI().usingUser(new UserModel("invalidTenantUser", "password")).getNetworks(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidTenantUser")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Get tenant user networks using -me- instead of personId") - @Test(groups = {TestGroup.REST_API, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void specifyMeInsteadOfPersonIdTest() throws Exception - { - RestNetworkModelsCollection networks = restClient.authenticateUser(adminTenantUser).withCoreAPI().usingMe().getNetworks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - networks.getOneRandomEntry().onModel().assertNetworkIsEnabled().and().field("id").is(adminTenantUser.getDomain().toLowerCase()); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Check default error schema for get networks for member") - @Test(groups = { TestGroup.REST_API, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void getNetworksAndCheckPropertiesParameter() throws Exception - { - RestNetworkModelsCollection networks = restClient.authenticateUser(adminTenantUser).withParams("properties=isEnabled,id").withCoreAPI().usingAuthUser().getNetworks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - networks.getOneRandomEntry().onModel().assertThat().field("homeNetwork").is("false") - .and().field("quotas").isNull() - .and().field("isEnabled").is("true") - .and().field("id").is(adminTenantUser.getDomain().toLowerCase()); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Check that skipCount parameter is applied") - @Test(groups = { TestGroup.REST_API, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void checkThatSkipCountParameterIsApplied() throws Exception - { - RestNetworkModelsCollection networks = restClient.authenticateUser(adminTenantUser).withParams("skipCount=1").withCoreAPI().usingAuthUser().getNetworks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - networks.assertThat().entriesListIsEmpty(); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Check that high skipCount parameter is applied") - @Test(groups = { TestGroup.REST_API, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void checkThatHighSkipCountParameterIsApplied() throws Exception - { - RestNetworkModelsCollection networks = restClient.authenticateUser(adminTenantUser).withParams("skipCount=100").withCoreAPI().usingAuthUser().getNetworks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - networks.assertThat().entriesListIsEmpty(); - networks.assertThat().paginationField("skipCount").is("100"); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Check that maxItems parameter is applied") - @Test(groups = { TestGroup.REST_API, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void checkThatMaxItemsParameterIsApplied() throws Exception - { - RestNetworkModelsCollection networks = restClient.authenticateUser(adminTenantUser).withParams("maxItems=1").withCoreAPI().usingAuthUser().getNetworks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - networks.getOneRandomEntry().onModel().assertThat().field("homeNetwork").is("false") - .and().field("quotas").is("[]") - .and().field("isEnabled").is("true") - .and().field("id").is(adminTenantUser.getDomain().toLowerCase()); - networks.assertThat().paginationField("maxItems").is("1"); - } -} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesActionDefinitionTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesActionDefinitionTests.java deleted file mode 100644 index a82c602a8..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesActionDefinitionTests.java +++ /dev/null @@ -1,87 +0,0 @@ -package org.alfresco.service.search.rest.nodes; - - -import static org.testng.Assert.assertFalse; - -import org.alfresco.service.search.rest.RestTest; - -import org.alfresco.rest.model.RestActionDefinitionModelsCollection; -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.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.Test; - -public class NodesActionDefinitionTests extends RestTest -{ - - - @TestRail(section = { TestGroup.REST_API,TestGroup.NODES }, executionType = ExecutionType.SANITY, - description = "Verify actions") - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY}) - public void testActionDefinition() throws Exception - { - restClient.authenticateUser(dataContent.getAdminUser()); - - /* - * Create the following file structure for preconditions : - * - sourceFolder - * - file - */ - NodesBuilder nodesBuilder = restClient.withCoreAPI().usingNode(ContentModel.my()).defineNodes(); - NodeDetail sourceFolder = nodesBuilder.folder("sourceFolder"); - NodeDetail file = sourceFolder.file("file"); - ContentModel fileActionDefinitions = new ContentModel(); - fileActionDefinitions.setNodeRef(file.getId()); - - RestActionDefinitionModelsCollection restActionDefinitions = restClient.withCoreAPI().usingNode(fileActionDefinitions).getActionDefinitions(); - restClient.assertStatusCodeIs(HttpStatus.OK); - assertFalse(restActionDefinitions.isEmpty()); - restActionDefinitions.assertThat().entriesListContains("name", "copy"); - restActionDefinitions.assertThat().entriesListContains("name", "move"); - restActionDefinitions.assertThat().entriesListContains("name", "check-out"); - restActionDefinitions.assertThat().entriesListContains("name", "check-in"); - - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NODES }, executionType = ExecutionType.REGRESSION, - description = "Verify actions negative request") - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION}) - public void testActionDefinitionNegative() throws Exception{ - - NodesBuilder nodesBuilder = restClient.withCoreAPI().usingNode(ContentModel.my()).defineNodes(); - NodeDetail sourceFolder = nodesBuilder.folder("sourceFolder"); - ContentModel validNode = new ContentModel(); - validNode.setNodeRef(sourceFolder.getId()); - - // Non-existent node ID - { - ContentModel fakeNode = new ContentModel(); - fakeNode.setNodeRef("750a2867-ecfa-478c-8343-fa0e39d27be3"); - restClient.authenticateUser(dataContent.getAdminUser()).withCoreAPI().usingNode(fakeNode).getActionDefinitions(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } - - // Badly formed request -> 400 - { - restClient.authenticateUser(dataContent.getAdminUser()).withParams("skipCount=-1").withCoreAPI().usingNode(validNode) - .getActionDefinitions(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - - } - - // Unauthorized -> 401 - { - - UserModel userUnauthorized = new UserModel("invalid-user", "invalid-pasword"); - restClient.authenticateUser(userUnauthorized).withCoreAPI().usingNode(validNode).getActionDefinitions(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); - - } - } - -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesContentAndVersioningTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesContentAndVersioningTests.java deleted file mode 100644 index 97dbfbc18..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesContentAndVersioningTests.java +++ /dev/null @@ -1,308 +0,0 @@ -package org.alfresco.service.search.rest.nodes; - -import static org.alfresco.utility.report.log.Step.STEP; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNotSame; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertSame; -import static org.testng.Assert.assertTrue; - -import java.io.File; -import java.io.IOException; -import java.io.RandomAccessFile; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.core.JsonBodyGenerator; -import org.alfresco.rest.core.RestResponse; -import org.alfresco.rest.model.RestNodeModel; -import org.alfresco.rest.model.RestVersionModel; -import org.alfresco.rest.model.RestVersionModelsCollection; -import org.alfresco.rest.model.body.RestNodeLockBodyModel; -import org.alfresco.util.TempFileProvider; -import org.alfresco.utility.Utility; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FileType; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.json.JSONObject; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * - * @author mpopa - * - */ -public class NodesContentAndVersioningTests extends RestTest -{ - private UserModel user1, user2; - private SiteModel site1, site2; - private FileModel file1, file2; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - user1 = dataUser.createRandomTestUser(); - user2 = dataUser.createRandomTestUser(); - site1 = dataSite.usingUser(user1).createPublicRandomSite(); - site2 = dataSite.usingUser(user2).createPublicRandomSite(); - file1 = dataContent.usingUser(user1).usingSite(site1).createContent(DocumentType.TEXT_PLAIN); - file2 = dataContent.usingUser(user2).usingSite(site2).createContent(DocumentType.TEXT_PLAIN); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.SANITY, description = "Verify file name in Content-Disposition header") - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY }) - public void checkFileNameWithRegularCharsInHeader() throws Exception - { - restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("attachment=false").getNodeContent(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restClient.assertHeaderValueContains("Content-Disposition", String.format("filename=\"%s\"", file1.getName())); - } - - - - - @Bug(id = "MNT-17545", description = "HTTP Header Injection in ContentStreamer", status = Bug.Status.FIXED) - @TestRail(section = { TestGroup.REST_API, - TestGroup.NODES }, executionType = ExecutionType.REGRESSION, description = "Verify file name with special chars is escaped in Content-Disposition header") - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) - public void checkFileNameWithSpecialCharsInHeader() throws Exception - { - char c1 = 127; - char c2 = 31; - char c3 = 256; - FileModel file = dataContent.usingUser(user2).usingSite(site2).createContent(new FileModel("\ntest" + c1 + c2 + c3, FileType.TEXT_PLAIN)); - restClient.authenticateUser(user2).withCoreAPI().usingNode(file).usingParams("attachment=false").getNodeContent(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restClient.assertHeaderValueContains("Content-Disposition", "filename=\" test .txt\""); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.NODES }, executionType = ExecutionType.SANITY, description = "Verify that alfresco returns the correct encoding for files created via REST.") - public void verifyFileEncodingUsingRestAPI() throws Exception - { - STEP("1. Create a folder, two text file templates and define the expected encoding."); - FileModel utf8File = new FileModel("utf8File", FileType.TEXT_PLAIN); - FileModel iso8859File = new FileModel("iso8859File", FileType.TEXT_PLAIN); - FolderModel folder = dataContent.usingUser(user1).usingSite(site1).createFolder(FolderModel.getRandomFolderModel()); - String utf8Type = "text/plain;charset=UTF-8"; - String iso8859Type = "text/plain;charset=ISO-8859-1"; - - STEP("2. Using multipart data upload (POST nodes/{nodeId}/children) the UTF-8 encoded file."); - restClient.authenticateUser(user1).configureRequestSpec().addMultiPart("filedata", Utility.getResourceTestDataFile("UTF-8File.txt")); - RestNodeModel fileNode = restClient.withCoreAPI().usingNode(folder).createNode(); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - utf8File.setNodeRef(fileNode.getId()); - - STEP("3. Using multipart data upload (POST nodes/{nodeId}/children) the ISO-8859-1 file."); - restClient.configureRequestSpec().addMultiPart("filedata", Utility.getResourceTestDataFile("iso8859File.txt")); - fileNode = restClient.withCoreAPI().usingNode(folder).createNode(); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - iso8859File.setNodeRef(fileNode.getId()); - - STEP("4. Retrieve the nodes and verify that the content type is the expected one (GET nodes/{nodeId})."); - restClient.withCoreAPI().usingNode(utf8File).getNodeContent().assertThat().contentType(utf8Type); - restClient.withCoreAPI().usingNode(iso8859File).getNodeContent().assertThat().contentType(iso8859Type); - } - - - // This test takes around 30 minutes to complete so it will be ignored by default - @Test(enabled=false, groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, - executionType = ExecutionType.REGRESSION, description = "Verify that the node content is streamed directly to the client and not buffered in memory.") - public void verifyUploadDownloadLargeFileUsingRestAPI() throws Exception - { - Integer largeFileSizeBytes = Integer.MAX_VALUE; - String largeFileName = "largeFile.tmp"; - String tempFolderPath = TempFileProvider.getTempDir().getAbsolutePath(); - - STEP("1. Create a folder and a large file"); - FolderModel folder = dataContent.usingUser(user1).usingSite(site1).createFolder(FolderModel.getRandomFolderModel()); - createRandomFileInDirectory(tempFolderPath, largeFileName, largeFileSizeBytes); - - STEP("2. Using multipart data upload for the large file (POST nodes/{nodeId}/children)."); - File largeFile = new File(tempFolderPath, largeFileName); - FileModel largeFileModel = new FileModel(largeFileName, FileType.UNDEFINED); - restClient.authenticateUser(user1).configureRequestSpec().addMultiPart("filedata", largeFile); - RestNodeModel fileNode = restClient.withCoreAPI().usingNode(folder).createNode(); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - largeFileModel.setNodeRef(fileNode.getId()); - - STEP("3. Retrieve the content of the node without running out of memory (GET nodes/{nodeId}/content)."); - RestResponse nodeContent = restClient.withCoreAPI().usingNode(largeFileModel).getNodeContent(); - restClient.assertStatusCodeIs(HttpStatus.OK); - assertEquals(Integer.valueOf(nodeContent.getResponse().getHeader("Content-Length")), largeFileSizeBytes); - - largeFile.delete(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.SANITY, description = "Verify updating a node content.") - public void testUpdateNodeContent() throws Exception - { - STEP("1. Retrieve the node in order to get data to compare after update GET /nodes/{nodeId}?include=path."); - RestNodeModel initialNode = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=path").getNode(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - STEP("2. Update the node content (different from the initial one) PUT /nodes/{nodeId}/content?majorVersion=true&name=newfile.txt."); - File updatedConentFile = Utility.getResourceTestDataFile("sampleContent.txt"); - RestNodeModel updatedBodyNode = restClient.withCoreAPI().usingNode(file1).usingParams("majorVersion=true&name=newfile.txt").updateNodeContent(updatedConentFile); - restClient.assertStatusCodeIs(HttpStatus.OK); - - STEP("3. Compare contentSize, modifiedAt, name and version, they should be different."); - assertNotSame(initialNode.getContent().getSizeInBytes(), updatedBodyNode.getContent().getSizeInBytes()); - assertNotSame(initialNode.getModifiedAt(), updatedBodyNode.getModifiedAt()); - assertNotSame(initialNode.getName(), updatedBodyNode.getName()); - - String initialNodeVersion = new JSONObject(initialNode.toJson()).getJSONObject("properties").getString("cm:versionLabel"); - String updatedBodyNodeVersion = new JSONObject(updatedBodyNode.toJson()).getJSONObject("properties").getString("cm:versionLabel"); - assertTrue(updatedBodyNodeVersion.charAt(0) > initialNodeVersion.charAt(0)); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.SANITY, description = "Test copy a node.") - public void testCopyNode() throws Exception - { - STEP("1. Create a lock and lock the node POST /nodes/{nodeId}/lock?include=path,isLocked."); - RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); - lockBodyModel.setLifetime("EPHEMERAL"); - lockBodyModel.setTimeToExpire(20); - lockBodyModel.setType("FULL"); - RestNodeModel initialNode = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=path,isLocked").lockNode(lockBodyModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - - STEP("2. With another user(that has access to the file), copy the node to another path POST /nodes/{nodeId}/copy?include=path,isLocked."); - String postBody = JsonBodyGenerator.keyValueJson("targetParentId", site2.getGuid()); - RestNodeModel copiedNode = restClient.authenticateUser(user2).withCoreAPI().usingNode(file1).usingParams("include=path,isLocked").copyNode(postBody); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - STEP("3. ParentId, createdAt, path and lock are different, but the nodes have the same contentSize."); - assertNotSame(copiedNode.getParentId(), initialNode.getParentId()); - assertNotSame(copiedNode.getCreatedAt(), initialNode.getCreatedAt()); - assertNotSame(copiedNode.getPath(), initialNode.getPath()); - assertTrue(initialNode.getIsLocked()); - assertSame(copiedNode.getContent().getSizeInBytes(), initialNode.getContent().getSizeInBytes()); - assertFalse(copiedNode.getIsLocked()); - - STEP("4. Unlock the node (this node may be used in the next tests)."); - initialNode = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").unlockNode(); - restClient.assertStatusCodeIs(HttpStatus.OK); - assertFalse(initialNode.getIsLocked()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.NODES }, executionType = ExecutionType.SANITY, description = "Test retrieving node versions, a specific version and version content.") - public void testGetVersionContent() throws Exception - { - file2 = dataContent.usingUser(user2).usingSite(site2).createContent(DocumentType.TEXT_PLAIN); - File sampleFile = Utility.getResourceTestDataFile("sampleContent.txt"); - - STEP("1. Update the node content in order to increase version(one minor and one major) PUT /nodes/{nodeId}/content."); - // minor version update - restClient.authenticateUser(user2).withCoreAPI().usingNode(file2).updateNodeContent(sampleFile); - restClient.assertStatusCodeIs(HttpStatus.OK); - // major version update - restClient.authenticateUser(user2).withCoreAPI().usingParams("majorVersion=true").usingNode(file2).updateNodeContent(sampleFile); - restClient.assertStatusCodeIs(HttpStatus.OK); - - STEP("2. List node version history GET /nodes/{nodeId}/versions. And verify that first (in the list) version is 2.0 and last is 1.0."); - RestVersionModelsCollection versionListing = restClient.withCoreAPI().usingNode(file2).listVersionHistory(); - restClient.assertStatusCodeIs(HttpStatus.OK); - // additional check that the properties are not displayed by default. - assertEquals(versionListing.getEntries().get(versionListing.getPagination().getCount() - 1).onModel().getId(), "1.0"); - assertEquals(versionListing.getEntries().get(0).onModel().getId(), "2.0"); - assertNull(versionListing.getEntries().get(0).onModel().getProperties()); - - STEP("3. List node version using skipCount(1),maxItems(1) and include(properties) GET /nodes/{nodeId}/versions?include=properties&skipCount=1&maxItems=1"); - versionListing = restClient.withCoreAPI().usingParams("include=properties&skipCount=1&maxItems=1").usingNode(file2).listVersionHistory(); - restClient.assertStatusCodeIs(HttpStatus.OK); - // we expect only version 1.1 to be retrieved with the value for properties. - RestVersionModel version = versionListing.getEntries().get(0).onModel(); - assertNotNull(version.getProperties()); - assertEquals(version.getId(), "1.1"); - assertEquals(versionListing.getPagination().getMaxItems(), 1); - assertEquals(versionListing.getPagination().getSkipCount(), 1); - assertEquals(versionListing.getPagination().getCount(), 1); - - STEP("4. Get version information for version 1.1 GET /nodes/{nodeId}/versions/{versionId} ."); - RestVersionModel version11 = restClient.withCoreAPI().usingNode(file2).getVersionInformation("1.1"); - restClient.assertStatusCodeIs(HttpStatus.OK); - // aspectNames and properties are displayed by default. We compare - // id,contentSize and name with the values from v1.1, taken from listing all - // versions. - assertNotNull(version11.getAspectNames()); - assertNotNull(version11.getProperties()); - assertEquals(version.getId(), version11.getId()); - assertEquals(version.getContent().getSizeInBytes(), version11.getContent().getSizeInBytes()); - assertEquals(version.getName(), version11.getName()); - - STEP("5. Retrieve version 2.0 content GET /nodes/{nodeId}/versions/{versionId}/content"); - // verify the content is the same as the uploaded file and check in headers for - // Content-Disposition to validate the download as attachment and fileName. - // wait for content to be picked up on AWS QS stacks - Utility.sleep(1000, 60000, () -> { - RestResponse versionContent = restClient.withCoreAPI().usingNode(file2).getVersionContent("2.0"); - restClient.assertStatusCodeIs(HttpStatus.OK); - - assertEquals("Sample text.\n", versionContent.getResponse().body().asString()); - restClient.assertHeaderValueContains("Content-Disposition", "attachment"); - restClient.assertHeaderValueContains("Content-Disposition", String.format("filename=\"%s\"", file2.getName())); - }); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.SANITY, description = "Test revert and delete a node version.") - public void testRevertDeleteVersion() throws Exception - { - STEP("1. Revert to version 1.0 POST /nodes/{nodeId}/versions/{versionId}/revert"); - RestVersionModel version = restClient.authenticateUser(user2).withCoreAPI().usingNode(file2).revertVersion("1.0", new String("{}")); - restClient.assertStatusCodeIs(HttpStatus.OK); - String nodeVersionType = new JSONObject(version.toJson()).getJSONObject("properties").getString("cm:versionType"); - assertEquals(nodeVersionType, "MINOR"); - String nodeVersion = version.getId(); - - STEP("2. Revert to last minor version /nodes/{nodeId}/versions/{versionId}/revert"); - version = restClient.withCoreAPI().usingNode(file2).revertVersion(nodeVersion, new String("{\"majorVersion\": true}")); - restClient.assertStatusCodeIs(HttpStatus.OK); - nodeVersionType = new JSONObject(version.toJson()).getJSONObject("properties").getString("cm:versionType"); - assertEquals(nodeVersionType, "MAJOR"); - assertTrue(nodeVersion.charAt(0) + 1 == version.getId().charAt(0)); - - STEP("3. Delete last MINOR version DELETE /nodes/{nodeId}/versions/{versionId}"); - restClient.withCoreAPI().usingNode(file2).deleteNodeVersion(nodeVersion); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingNode(file2).getVersionInformation(nodeVersion); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.SANITY, description = "Verify file name in Content Range header") - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY }) - public void checkFileNameContentRangeHeader() throws Exception - { - restClient.configureRequestSpec().addHeader("content-range", "bytes=1-10"); - restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).getNodeContent(); - restClient.assertStatusCodeIs(HttpStatus.PARTIAL_CONTENT); - restClient.assertHeaderValueContains("content-range", "bytes 1-10"); - restClient.assertHeaderValueContains("content-length", String.valueOf(10)); - } - - - private void createRandomFileInDirectory(String path, String fileName, int size) throws IOException { - String fullPath = new File(path, fileName).getPath(); - - RandomAccessFile file = new RandomAccessFile(fullPath,"rw"); - file.setLength(size); - file.close(); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesLockTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesLockTests.java deleted file mode 100644 index dc05c3602..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesLockTests.java +++ /dev/null @@ -1,761 +0,0 @@ -package org.alfresco.service.search.rest.nodes; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestNodeModel; -import org.alfresco.rest.model.body.RestNodeLockBodyModel; -import org.alfresco.rest.search.RestRequestFilterQueryModel; -import org.alfresco.rest.search.RestRequestQueryModel; -import org.alfresco.rest.search.SearchRequest; -import org.alfresco.rest.search.SearchResponse; -import org.alfresco.utility.Utility; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.report.Bug.Status; -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; - -import static org.alfresco.utility.report.log.Step.STEP; - -public class NodesLockTests extends RestTest -{ - private UserModel user1, user2, adminUser; - private SiteModel publicSite; - private FileModel file1; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - publicSite = dataSite.usingUser(adminUser).createPublicRandomSite(); - user1 = dataUser.createRandomTestUser(); - user2 = dataUser.createRandomTestUser(); - dataUser.addUserToSite(user1, publicSite, UserRole.SiteCollaborator); - user1.setUserRole(UserRole.SiteCollaborator); - dataUser.addUserToSite(user2, publicSite, UserRole.SiteCollaborator); - user2.setUserRole(UserRole.SiteCollaborator); - - } - - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, - description = "Verify Collaborator can not lock PERSISTENT after EPHEMERAL lock made by different user") - public void lockEphemeralAndRelockPersistentDifferentUser() throws Exception - { - STEP("1. Administrator adds a file in the site."); - file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); - - STEP("2. Verify with admin that the file is not locked."); - RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model1.assertThat().field("isLocked").is(false); - - STEP("3. Lock the file using mode EPHEMERAL for 20 seconds with user1 (POST nodes/{nodeId}/lock)."); - RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); - lockBodyModel.setLifetime("EPHEMERAL"); - lockBodyModel.setTimeToExpire(20); - lockBodyModel.setType("FULL"); - restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").lockNode(lockBodyModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - - STEP("4. Verify with user1 that the file is locked."); - RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model2.assertThat().field("isLocked").is(true) - .assertThat().field("properties").contains("lockLifetime=EPHEMERAL") - .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); - - STEP("5. Cannot lock the file using mode PERSISTENT with user2 while the file is still locked"); - RestNodeLockBodyModel lockBodyModel2 = new RestNodeLockBodyModel(); - lockBodyModel2.setLifetime("PERSISTENT"); - lockBodyModel2.setTimeToExpire(20); - lockBodyModel2.setType("ALLOW_OWNER_CHANGES"); - restClient.authenticateUser(user2).withCoreAPI().usingNode(file1).usingParams("include=isLocked").lockNode(lockBodyModel2); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() - .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .containsSummary(String.format(RestErrorModel.LOCKED_NODE_SUMMARY, file1.getNodeRefWithoutVersion())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, - description = "Verify Collaborator can not lock EPHEMERAL after EPHEMERAL lock made by different user") - public void lockEphemeralAndRelockEphemeralDifferentUser() throws Exception - { - STEP("1. Adds a file in the site by administrator."); - file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); - - STEP("2. Verify with admin that the file is not locked."); - RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model1.assertThat().field("isLocked").is(false); - - STEP("3. Lock the file using mode EPHEMERAL with user1 (POST nodes/{nodeId}/lock)."); - RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); - lockBodyModel.setLifetime("EPHEMERAL"); - lockBodyModel.setTimeToExpire(20); - lockBodyModel.setType("FULL"); - restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - - STEP("4. Verify with user1 that the file is locked."); - RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model2.assertThat().field("isLocked").is(true) - .assertThat().field("properties").contains("lockLifetime=EPHEMERAL") - .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); - - STEP("5. Cannot lock the file using mode EPHEMERAL with user2 while the file is still locked"); - RestNodeLockBodyModel lockBodyModel2 = new RestNodeLockBodyModel(); - lockBodyModel2.setLifetime("EPHEMERAL"); - lockBodyModel2.setTimeToExpire(20); - lockBodyModel2.setType("FULL"); - restClient.authenticateUser(user2).withCoreAPI().usingNode(file1).usingParams("include=isLocked").lockNode(lockBodyModel2); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() - .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .containsSummary(String.format(RestErrorModel.LOCKED_NODE_SUMMARY, file1.getNodeRefWithoutVersion())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, - description = "Verify Collaborator can lock EPHEMERAL after EPHEMERAL lock made by same user") - public void lockEphemeralAndRelockEphemeralSameUser() throws Exception - { - STEP("1. Adds a file in the site by administrator."); - file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); - - STEP("2. Verify with admin that the file is not locked."); - RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model1.assertThat().field("isLocked").is(false); - - STEP("3. Lock the file using mode EPHEMERAL with user1 (POST nodes/{nodeId}/lock)."); - RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); - lockBodyModel.setLifetime("EPHEMERAL"); - lockBodyModel.setTimeToExpire(20); - lockBodyModel.setType("FULL"); - restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - - STEP("4. Verify with user1 that the file is locked."); - RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model2.assertThat().field("isLocked").is(true) - .assertThat().field("properties").contains("lockLifetime=EPHEMERAL") - .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); - - STEP("5. Lock the file using mode EPHEMERAL with user1 while the file is still locked"); - RestNodeLockBodyModel lockBodyModel2 = new RestNodeLockBodyModel(); - lockBodyModel2.setLifetime("EPHEMERAL"); - lockBodyModel2.setTimeToExpire(20); - lockBodyModel2.setType("FULL"); - RestNodeModel file1Model3 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").lockNode(lockBodyModel2); - restClient.assertStatusCodeIs(HttpStatus.OK); - file1Model3.assertThat().field("isLocked").is(true) - .assertThat().field("properties").contains("lockLifetime=EPHEMERAL") - .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); - } - - @Bug(id = "MNT-17612", status = Status.FIXED, description = "AccessDeniedException in AOS Edit Offline Upload New Version") - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, - description = "Verify Collaborator can lock PERSISTENT after EPHEMERAL lock made by same user") - public void lockEphemeralAndRelockPersistentSameUser() throws Exception - { - STEP("1. Adds a file in the site by administrator."); - file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); - - STEP("2. Verify with admin that the file is not locked."); - RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model1.assertThat().field("isLocked").is(false); - - STEP("3. Lock the file using mode EPHEMERAL with user1 (POST nodes/{nodeId}/lock)."); - RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); - lockBodyModel.setLifetime("EPHEMERAL"); - lockBodyModel.setTimeToExpire(2); - lockBodyModel.setType("FULL"); - restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - - STEP("4. Verify with user1 that the file is locked."); - RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model2.assertThat().field("isLocked").is(true) - .assertThat().field("properties").contains("lockLifetime=EPHEMERAL") - .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); - - STEP("5. Lock the file using mode PERSISTENT with user1 while the file is still locked"); - RestNodeLockBodyModel lockBodyModel2 = new RestNodeLockBodyModel(); - lockBodyModel2.setLifetime("PERSISTENT"); - lockBodyModel2.setTimeToExpire(20); - lockBodyModel2.setType("ALLOW_OWNER_CHANGES"); - RestNodeModel file1Model3 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").lockNode(lockBodyModel2); - restClient.assertStatusCodeIs(HttpStatus.OK); - file1Model3.assertThat().field("isLocked").is(true) - .assertThat().field("properties").contains("lockLifetime=EPHEMERAL") - .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); - - STEP("6. Verify that the file is locked PERSISTENT only after EPHEMERAL lock has expired"); - try{Thread.sleep(2500);}finally{} - RestNodeModel file1Model4 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model4.assertThat().field("isLocked").is(true) - .assertThat().field("properties").contains("lockLifetime=PERSISTENT") - .assertThat().field("properties").contains("lockType=WRITE_LOCK"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, - description = "Verify Collaborator can not lock EPHEMERAL after PERSISTENT lock made by different user") - public void lockPersistentAndRelockEphemeralDifferentUser() throws Exception - { - STEP("1. Adds a file in the site by administrator."); - file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); - - STEP("2. Verify with admin that the file is not locked."); - RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model1.assertThat().field("isLocked").is(false); - - STEP("3. Lock the file using mode PERSISTENT with user1 (POST nodes/{nodeId}/lock)."); - RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); - lockBodyModel.setLifetime("PERSISTENT"); - lockBodyModel.setTimeToExpire(20); - lockBodyModel.setType("ALLOW_OWNER_CHANGES"); - restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - - STEP("4. Verify with user1 that the file is locked."); - RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model2.assertThat().field("isLocked").is(true) - .assertThat().field("properties").contains("lockLifetime=PERSISTENT") - .assertThat().field("properties").contains("lockType=WRITE_LOCK"); - - STEP("5. Cannot lock the file using mode EPHEMERAL with user2 while the file is still locked"); - RestNodeLockBodyModel lockBodyModel2 = new RestNodeLockBodyModel(); - lockBodyModel2.setLifetime("EPHEMERAL"); - lockBodyModel2.setTimeToExpire(20); - lockBodyModel2.setType("FULL"); - restClient.authenticateUser(user2).withCoreAPI().usingNode(file1).usingParams("include=isLocked").lockNode(lockBodyModel2); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() - .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .containsSummary(String.format(RestErrorModel.LOCKED_NODE_SUMMARY, file1.getNodeRefWithoutVersion())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, - description = "Verify Collaborator can not lock PERSISTENT after PERSISTENT lock made by different user") - public void lockPersistentAndRelockPersistentDifferentUser() throws Exception - { - STEP("1. Adds a file in the site by administrator."); - file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); - - STEP("2. Verify with admin that the file is not locked."); - RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model1.assertThat().field("isLocked").is(false); - - STEP("3. Lock the file using mode PERSISTENT with user1 (POST nodes/{nodeId}/lock)."); - RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); - lockBodyModel.setLifetime("PERSISTENT"); - lockBodyModel.setTimeToExpire(20); - lockBodyModel.setType("ALLOW_OWNER_CHANGES"); - restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - - STEP("4. Verify with user1 that the file is locked."); - RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model2.assertThat().field("isLocked").is(true) - .assertThat().field("properties").contains("lockLifetime=PERSISTENT") - .assertThat().field("properties").contains("lockType=WRITE_LOCK"); - - STEP("5. Cannot lock the file using mode PERSISTENT with user2 while the file is still locked"); - RestNodeLockBodyModel lockBodyModel2 = new RestNodeLockBodyModel(); - lockBodyModel2.setLifetime("PERSISTENT"); - lockBodyModel2.setTimeToExpire(20); - lockBodyModel2.setType("ALLOW_OWNER_CHANGES"); - restClient.authenticateUser(user2).withCoreAPI().usingNode(file1).usingParams("include=isLocked").lockNode(lockBodyModel2); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() - .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .containsSummary(String.format(RestErrorModel.LOCKED_NODE_SUMMARY, file1.getNodeRefWithoutVersion())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, - description = "Verify Collaborator can lock EPHEMERAL after PERSISTENT lock made by different user is expired") - public void lockPersistentAndRelockEphemeralAfterExpiredLockDifferentUser() throws Exception - { - STEP("1. Adds a file in the site by administrator."); - file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); - - STEP("2. Verify with admin that the file is not locked."); - RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model1.assertThat().field("isLocked").is(false); - - STEP("3. Lock the file using mode PERSISTENT with user1 (POST nodes/{nodeId}/lock)."); - RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); - lockBodyModel.setLifetime("PERSISTENT"); - lockBodyModel.setTimeToExpire(1); - lockBodyModel.setType("ALLOW_OWNER_CHANGES"); - restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - - STEP("4. Verify with admin that the file is locked."); - RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model2.assertThat().field("isLocked").is(true) - .assertThat().field("properties").contains("lockLifetime=PERSISTENT") - .assertThat().field("properties").contains("lockType=WRITE_LOCK"); - - STEP("5. Lock the file using mode EPHEMERAL with user2 while the first lock has expired"); - RestNodeLockBodyModel lockBodyModel2 = new RestNodeLockBodyModel(); - lockBodyModel2.setLifetime("EPHEMERAL"); - lockBodyModel2.setTimeToExpire(20); - lockBodyModel2.setType("FULL"); - try{Thread.sleep(1500);}finally{} - RestNodeModel file1Model3 = restClient.authenticateUser(user2).withCoreAPI().usingNode(file1).usingParams("include=isLocked").lockNode(lockBodyModel2); - restClient.assertStatusCodeIs(HttpStatus.OK); - file1Model3.assertThat().field("isLocked").is(true) - .assertThat().field("properties").contains("lockLifetime=EPHEMERAL") - .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); - } - - @Bug(id = "MNT-17612", status = Status.FIXED, description = "AccessDeniedException in AOS Edit Offline Upload New Version") - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, - description = "Verify Collaborator can lock PERSISTENT after EPHEMERAL lock made by another user is expired") - public void lockEphemeralAndRelockPersistentAfterExpiredLockDifferentUser() throws Exception - { - STEP("1. Adds a file in the site by administrator."); - file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); - - STEP("2. Verify with admin that the file is not locked."); - RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model1.assertThat().field("isLocked").is(false); - - STEP("3. Lock the file using mode EPHEMERAL with user1 (POST nodes/{nodeId}/lock)."); - RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); - lockBodyModel.setLifetime("EPHEMERAL"); - lockBodyModel.setTimeToExpire(1); - lockBodyModel.setType("FULL"); - restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - - STEP("4. Verify with user1 that the file is locked."); - RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model2.assertThat().field("isLocked").is(true) - .assertThat().field("properties").contains("lockLifetime=EPHEMERAL") - .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); - - STEP("5. Lock the file using mode PERSISTENT with user2 after the first lock has expired"); - RestNodeLockBodyModel lockBodyModel2 = new RestNodeLockBodyModel(); - lockBodyModel2.setLifetime("PERSISTENT"); - lockBodyModel2.setTimeToExpire(20); - lockBodyModel2.setType("ALLOW_OWNER_CHANGES"); - try{Thread.sleep(1500);}finally{} - RestNodeModel file1Model3 = restClient.authenticateUser(user2).withCoreAPI().usingNode(file1).usingParams("include=isLocked").lockNode(lockBodyModel2); - restClient.assertStatusCodeIs(HttpStatus.OK); - file1Model3.assertThat().field("isLocked").is(true) - .assertThat().field("properties").contains("lockLifetime=PERSISTENT") - .assertThat().field("properties").contains("lockType=WRITE_LOCK"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, - description = "Verify Collaborator can lock EPHEMERAL after EPHEMERAL lock made by another user is expired") - public void lockEphemeralAndRelockEphemeralAfterExpiredLockDifferentUser() throws Exception - { - STEP("1. Adds a file in the site by administrator."); - file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); - - STEP("2. Verify with admin that the file is not locked."); - RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model1.assertThat().field("isLocked").is(false); - - STEP("3. Lock the file using mode EPHEMERAL with user1 (POST nodes/{nodeId}/lock)."); - RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); - lockBodyModel.setLifetime("EPHEMERAL"); - lockBodyModel.setTimeToExpire(1); - lockBodyModel.setType("FULL"); - restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - - STEP("4. Verify with user1 that the file is locked."); - RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model2.assertThat().field("isLocked").is(true) - .assertThat().field("properties").contains("lockLifetime=EPHEMERAL") - .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); - - STEP("5. Lock the file using mode EPHEMERAL with user2 while the first lock has expired"); - RestNodeLockBodyModel lockBodyModel2 = new RestNodeLockBodyModel(); - lockBodyModel2.setLifetime("EPHEMERAL"); - lockBodyModel2.setTimeToExpire(20); - lockBodyModel2.setType("FULL"); - try{Thread.sleep(1500);}finally{} - RestNodeModel file1Model3 = restClient.authenticateUser(user2).withCoreAPI().usingNode(file1).usingParams("include=isLocked").lockNode(lockBodyModel2); - restClient.assertStatusCodeIs(HttpStatus.OK); - file1Model3.assertThat().field("isLocked").is(true) - .assertThat().field("properties").contains("lockLifetime=EPHEMERAL") - .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, - description = "Verify Collaborator can lock PERSISTENT after PERSISTENT lock made by different user is expired") - public void lockPersistentAndRelockPersistentAfterExpiredLockDifferentUser() throws Exception - { - STEP("1. Adds a file in the site by administrator."); - file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); - - STEP("2. Verify with admin that the file is not locked."); - RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model1.assertThat().field("isLocked").is(false); - - STEP("3. Lock the file using mode PERSISTENT with user1 (POST nodes/{nodeId}/lock)."); - RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); - lockBodyModel.setLifetime("PERSISTENT"); - lockBodyModel.setTimeToExpire(1); - lockBodyModel.setType("ALLOW_OWNER_CHANGES"); - restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - - STEP("4. Verify with admin that the file is locked."); - RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model2.assertThat().field("isLocked").is(true) - .assertThat().field("properties").contains("lockLifetime=PERSISTENT") - .assertThat().field("properties").contains("lockType=WRITE_LOCK"); - - STEP("5. Lock the file using mode PERSISTENT with user2 after the first lock has expired"); - RestNodeLockBodyModel lockBodyModel2 = new RestNodeLockBodyModel(); - lockBodyModel2.setLifetime("PERSISTENT"); - lockBodyModel2.setTimeToExpire(20); - lockBodyModel2.setType("ALLOW_OWNER_CHANGES"); - try{Thread.sleep(1500);}finally{} - RestNodeModel file1Model3 = restClient.authenticateUser(user2).withCoreAPI().usingNode(file1).usingParams("include=isLocked").lockNode(lockBodyModel2); - restClient.assertStatusCodeIs(HttpStatus.OK); - file1Model3.assertThat().field("isLocked").is(true) - .assertThat().field("properties").contains("lockLifetime=PERSISTENT") - .assertThat().field("properties").contains("lockType=WRITE_LOCK"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, - description = "Verify Collaborator can lock EPHEMERAL after EPHEMERAL lock made by same user is expired") - public void lockEphemeralAndRelockEphemeralAfterExpiredLockSameUser() throws Exception - { - STEP("1. Adds a file in the site by administrator."); - file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); - - STEP("2. Verify with admin that the file is not locked."); - RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model1.assertThat().field("isLocked").is(false); - - STEP("3. Lock the file using mode EPHEMERAL with user1 (POST nodes/{nodeId}/lock)."); - RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); - lockBodyModel.setLifetime("EPHEMERAL"); - lockBodyModel.setTimeToExpire(1); - lockBodyModel.setType("FULL"); - restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - - STEP("4. Verify with user1 that the file is locked."); - RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model2.assertThat().field("isLocked").is(true) - .assertThat().field("properties").contains("lockLifetime=EPHEMERAL") - .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); - - STEP("5. Lock the file using mode EPHEMERAL with user1 after the first lock has expired"); - RestNodeLockBodyModel lockBodyModel2 = new RestNodeLockBodyModel(); - lockBodyModel2.setLifetime("EPHEMERAL"); - lockBodyModel2.setTimeToExpire(20); - lockBodyModel2.setType("FULL"); - try{Thread.sleep(1500);}finally{} - RestNodeModel file1Model3 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").lockNode(lockBodyModel2); - restClient.assertStatusCodeIs(HttpStatus.OK); - file1Model3.assertThat().field("isLocked").is(true) - .assertThat().field("properties").contains("lockLifetime=EPHEMERAL") - .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, - description = "Verify Collaborator can lock PERSISTENT after PERSISTENT lock made by same user is expired") - public void lockPersistentAndRelockPersistentAfterExpiredLockSameUser() throws Exception - { - STEP("1. Adds a file in the site by administrator."); - file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); - - STEP("2. Verify with admin that the file is not locked."); - RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model1.assertThat().field("isLocked").is(false); - - STEP("3. Lock the file using mode PERSISTENT with user1 (POST nodes/{nodeId}/lock)."); - RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); - lockBodyModel.setLifetime("PERSISTENT"); - lockBodyModel.setTimeToExpire(1); - lockBodyModel.setType("ALLOW_OWNER_CHANGES"); - restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - - STEP("4. Verify with user1 that the file is locked."); - RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model2.assertThat().field("isLocked").is(true); - file1Model2.assertThat().field("properties").contains("lockLifetime=PERSISTENT"); - - STEP("5. Lock the file using mode PERSISTENT with user1 while the first lock has expired"); - RestNodeLockBodyModel lockBodyModel2 = new RestNodeLockBodyModel(); - lockBodyModel2.setLifetime("PERSISTENT"); - lockBodyModel2.setTimeToExpire(20); - lockBodyModel2.setType("ALLOW_OWNER_CHANGES"); - try{Thread.sleep(1500);}finally{} - RestNodeModel file1Model3 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").lockNode(lockBodyModel2); - restClient.assertStatusCodeIs(HttpStatus.OK); - file1Model3.assertThat().field("isLocked").is(true) - .assertThat().field("properties").contains("lockLifetime=PERSISTENT") - .assertThat().field("properties").contains("lockType=WRITE_LOCK"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, - description = "Verify Collaborator can lock EPHEMERAL after PERSISTENT lock made by same user is expired") - public void lockPersistentAndRelockEphemeralAfterExpiredLockSameUser() throws Exception - { - STEP("1. Adds a file in the site by administrator."); - file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); - - STEP("2. Verify with admin that the file is not locked."); - RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model1.assertThat().field("isLocked").is(false); - - STEP("3. Lock the file using mode PERSISTENT with user1 (POST nodes/{nodeId}/lock)."); - RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); - lockBodyModel.setLifetime("PERSISTENT"); - lockBodyModel.setTimeToExpire(1); - lockBodyModel.setType("ALLOW_OWNER_CHANGES"); - restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - - STEP("4. Verify with admin that the file is locked."); - RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model2.assertThat().field("isLocked").is(true) - .assertThat().field("properties").contains("lockLifetime=PERSISTENT") - .assertThat().field("properties").contains("lockType=WRITE_LOCK"); - - STEP("5. Lock the file using mode EPHEMERAL with user1 while the first lock has expired"); - RestNodeLockBodyModel lockBodyModel2 = new RestNodeLockBodyModel(); - lockBodyModel2.setLifetime("EPHEMERAL"); - lockBodyModel2.setTimeToExpire(20); - lockBodyModel2.setType("FULL"); - try{Thread.sleep(1500);}finally{} - RestNodeModel file1Model3 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").lockNode(lockBodyModel2); - restClient.assertStatusCodeIs(HttpStatus.OK); - file1Model3.assertThat().field("isLocked").is(true) - .assertThat().field("properties").contains("lockLifetime=EPHEMERAL") - .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); - } - - @Bug(id = "MNT-17612", status = Status.FIXED, description = "AccessDeniedException in AOS Edit Offline Upload New Version") - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, - description = "Verify Collaborator can lock PERSISTENT after EPHEMERAL lock made by same user is expired") - public void lockEphemeralAndRelockPersistentAfterExpiredLockSameUser() throws Exception - { - STEP("1. Adds a file in the site by administrator."); - file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); - - STEP("2. Verify with admin that the file is not locked."); - RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1) - .usingParams("include=isLocked").getNode(); - file1Model1.assertThat().field("isLocked").is(false); - - STEP("3. Lock the file using mode EPHEMERAL with user1 (POST nodes/{nodeId}/lock)."); - RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); - lockBodyModel.setLifetime("EPHEMERAL"); - lockBodyModel.setTimeToExpire(1); - lockBodyModel.setType("FULL"); - restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - - STEP("4. Verify with useer1 that the file is locked."); - RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model2.assertThat().field("isLocked").is(true) - .assertThat().field("properties").contains("lockLifetime=EPHEMERAL") - .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); - - STEP("5. Lock the file using mode PERSISTENT with user1 while the first lock has expired"); - RestNodeLockBodyModel lockBodyModel2 = new RestNodeLockBodyModel(); - lockBodyModel2.setLifetime("PERSISTENT"); - lockBodyModel2.setTimeToExpire(20); - lockBodyModel2.setType("ALLOW_OWNER_CHANGES"); - try{Thread.sleep(1500);}finally{} - RestNodeModel file1Model3 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").lockNode(lockBodyModel2); - restClient.assertStatusCodeIs(HttpStatus.OK); - file1Model3.assertThat().field("isLocked").is(true) - .assertThat().field("properties").contains("lockLifetime=PERSISTENT") - .assertThat().field("properties").contains("lockType=WRITE_LOCK"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, - description = "Verify Collaborator can lock PERSISTENT after PERSISTENT lock made by same user") - public void lockPersistentAndRelockPersistentSameUser() throws Exception - { - STEP("1. Adds a file in the site by administrator."); - file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); - - STEP("2. Verify with admin that the file is not locked."); - RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model1.assertThat().field("isLocked").is(false); - - STEP("3. Lock the file using mode PERSISTENT with user1 (POST nodes/{nodeId}/lock)."); - RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); - lockBodyModel.setLifetime("PERSISTENT"); - lockBodyModel.setTimeToExpire(20); - lockBodyModel.setType("ALLOW_OWNER_CHANGES"); - restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - - STEP("4. Verify with user1 that the file is locked."); - RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model2.assertThat().field("isLocked").is(true) - .assertThat().field("properties").contains("lockLifetime=PERSISTENT") - .assertThat().field("properties").contains("lockType=WRITE_LOCK"); - - STEP("5. Lock the file using mode PERSISTENT with user1 while the file is still locked"); - RestNodeLockBodyModel lockBodyModel2 = new RestNodeLockBodyModel(); - lockBodyModel2.setLifetime("PERSISTENT"); - lockBodyModel2.setTimeToExpire(20); - lockBodyModel2.setType("ALLOW_OWNER_CHANGES"); - RestNodeModel file1Model3 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").lockNode(lockBodyModel2); - restClient.assertStatusCodeIs(HttpStatus.OK); - file1Model3.assertThat().field("isLocked").is(true); - file1Model3.assertThat().field("properties").contains("lockLifetime=PERSISTENT") - .assertThat().field("properties").contains("lockType=WRITE_LOCK"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, - description = "Verify Collaborator can lock EPHERMERAL after PERSISTENT lock made by same user") - public void lockPersistentAndRelockEphemeralSameUser() throws Exception - { - STEP("1. Adds a file in the site by administrator."); - file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); - - STEP("2. Verify with admin that the file is not locked."); - RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model1.assertThat().field("isLocked").is(false); - - STEP("3. Lock the file using mode PERSISTENT with user1 (POST nodes/{nodeId}/lock)."); - RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); - lockBodyModel.setLifetime("PERSISTENT"); - lockBodyModel.setTimeToExpire(1); - lockBodyModel.setType("ALLOW_OWNER_CHANGES"); - restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - - STEP("4. Verify with user1 that the file is locked."); - RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model2.assertThat().field("isLocked").is(true) - .assertThat().field("properties").contains("lockLifetime=PERSISTENT") - .assertThat().field("properties").contains("lockType=WRITE_LOCK"); - - STEP("5. Lock the file using mode EPHERMERAL with user1 while the file is still locked"); - RestNodeLockBodyModel lockBodyModel2 = new RestNodeLockBodyModel(); - lockBodyModel2.setLifetime("EPHEMERAL"); - lockBodyModel2.setTimeToExpire(20); - lockBodyModel2.setType("FULL"); - RestNodeModel file1Model3 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").lockNode(lockBodyModel2); - restClient.assertStatusCodeIs(HttpStatus.OK); - file1Model3.assertThat().field("isLocked").is(true); - file1Model3.assertThat().field("properties").contains("lockLifetime=EPHEMERAL") - .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION, TestGroup.REQUIRE_SOLR }) - @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, - description = "Verify that child nodes can be locked differently and unlocked") - public void testLockUnlockParentChild() throws Exception - { - STEP("1. Create user, site, parent node and children nodes."); - SiteModel siteLock = dataSite.usingUser(adminUser).createPublicRandomSite(); - FolderModel parentNode = dataContent.usingUser(adminUser).usingSite(siteLock).createFolder(); - FileModel childNode1 = dataContent.usingUser(adminUser).usingSite(siteLock).usingResource(parentNode).createContent(DocumentType.TEXT_PLAIN); - FileModel childNode2 = dataContent.usingUser(adminUser).usingSite(siteLock).usingResource(parentNode).createContent(DocumentType.TEXT_PLAIN); - - STEP("2. Verify with admin that the file is not locked."); - RestNodeModel restNodeResponse = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(parentNode).usingParams("include=isLocked").getNode(); - restNodeResponse.assertThat().field("isLocked").is(false); - - restNodeResponse = restClient.withCoreAPI().usingNode(childNode1).usingParams("include=isLocked").getNode(); - restNodeResponse.assertThat().field("isLocked").is(false); - - restNodeResponse = restClient.withCoreAPI().usingNode(childNode2).usingParams("include=isLocked").getNode(); - restNodeResponse.assertThat().field("isLocked").is(false); - - STEP("3. Lock childNode1 using mode PERSISTENT with adminUser (POST nodes/{nodeId}/lock)."); - RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); - lockBodyModel.setLifetime("PERSISTENT"); - lockBodyModel.setTimeToExpire(0); - lockBodyModel.setType("ALLOW_OWNER_CHANGES"); - restNodeResponse = restClient.withCoreAPI().usingNode(childNode1).usingParams("include=isLocked").lockNode(lockBodyModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - restNodeResponse.assertThat().field("aspectNames").contains("cm:lockable") - .assertThat().field("isLocked").is(true) - .assertThat().field("properties").contains("lockLifetime=PERSISTENT") - .assertThat().field("properties").contains("lockType=WRITE_LOCK"); - - STEP("4. Lock childNode2 using mode PERSISTENT with adminUser (POST nodes/{nodeId}/lock)."); - lockBodyModel = new RestNodeLockBodyModel(); - lockBodyModel.setLifetime("PERSISTENT"); - lockBodyModel.setTimeToExpire(0); - lockBodyModel.setType("FULL"); - restNodeResponse = restClient.withCoreAPI().usingNode(childNode2).usingParams("include=isLocked").lockNode(lockBodyModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - restNodeResponse.assertThat().field("aspectNames").contains("cm:lockable") - .assertThat().field("isLocked").is(true) - .assertThat().field("properties").contains("lockLifetime=PERSISTENT") - .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); - - STEP("5. Verify that childNode1 and childNode 2 are locked."); - SearchRequest query = new SearchRequest(); - RestRequestQueryModel queryReq = new RestRequestQueryModel(); - RestRequestFilterQueryModel queryFilters = new RestRequestFilterQueryModel(); - queryFilters.setQuery("cm:lockOwner:\'admin\'"); - queryReq.setQuery("ASPECT:\'cm:lockable\'"); - query.setQuery(queryReq); - query.setFilterQueries(queryFilters); - query.setIncludeRequest(false); - - // Allow indexing to complete. - Utility.sleep(1000, 60000, () -> - { - SearchResponse response = query(query); - restClient.assertStatusCodeIs(HttpStatus.OK); - response.assertThat().entriesListContains("id",childNode1.getNodeRefWithoutVersion()); - response.assertThat().entriesListContains("id",childNode2.getNodeRefWithoutVersion()); - }); - - STEP("6. Unlock the nodes."); - restNodeResponse = restClient.withCoreAPI().usingNode(childNode1).usingParams("include=isLocked").unlockNode(); - restNodeResponse.assertThat().field("isLocked").is(false); - - restNodeResponse = restClient.withCoreAPI().usingNode(childNode2).usingParams("include=isLocked").unlockNode(); - restNodeResponse.assertThat().field("isLocked").is(false); - - STEP("7. Verify that childNode1 and childNode2 are not found in the query results."); - // Allow indexing to complete. - Utility.sleep(1000, 60000, () -> - { - SearchResponse response = query(query); - restClient.assertStatusCodeIs(HttpStatus.OK); - response.assertThat().entriesListDoesNotContain("id",childNode1.getNodeRefWithoutVersion()); - response.assertThat().entriesListDoesNotContain("id",childNode2.getNodeRefWithoutVersion()); - }); - } - - protected SearchResponse query(SearchRequest query) throws Exception - { - return restClient.authenticateUser(dataUser.getAdminUser()).withSearchAPI().search(query); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesParentChildrenTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesParentChildrenTests.java deleted file mode 100644 index d2f525553..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesParentChildrenTests.java +++ /dev/null @@ -1,205 +0,0 @@ -package org.alfresco.service.search.rest.nodes; - -import static org.alfresco.utility.report.log.Step.STEP; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestNodeBodyModel; -import org.alfresco.rest.model.RestNodeChildAssocModelCollection; -import org.alfresco.rest.model.RestNodeChildAssociationModel; -import org.alfresco.rest.model.RestNodeModel; -import org.alfresco.rest.model.RestNodeModelsCollection; -import org.alfresco.rest.model.RestNodeAssociationModelCollection; -import org.alfresco.rest.model.builder.NodesBuilder; -import org.alfresco.utility.Utility; -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/children - * api-explorer/#!/nodes/secondary-children - * api-explorer/#!/nodes/parents - */ -public class NodesParentChildrenTests extends RestTest -{ - @TestRail(section = { TestGroup.REST_API,TestGroup.NODES }, executionType = ExecutionType.SANITY, - description = "Verify new folder node is created as children on -my- posting as JSON content type") - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY}) - public void createNewFolderNodeViaJason() throws Exception - { - restClient.authenticateUser(dataContent.getAdminUser()); - - RestNodeBodyModel node = new RestNodeBodyModel(); - node.setName("My Folder"); - node.setNodeType("cm:folder"); - - RestNodeModel newNode = restClient.withParams("autoRename=true").withCoreAPI().usingNode(ContentModel.my()).createNode(node); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - newNode.assertThat().field("aspectNames").contains("cm:auditable") - .assertThat().field("isFolder").is(true) - .assertThat().field("isFile").is(false) - .assertThat().field("name").contains(node.getName()); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NODES }, executionType = ExecutionType.REGRESSION, - description = "Verify new folder node is created as children on -my- posting as MultiPart content type") - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION}) - public void createNewFolderNodeWithMultiPartForms() throws Exception - { - //configuring multipart form - restClient.authenticateUser(dataContent.getAdminUser()) - .configureRequestSpec() - .addMultiPart("filedata", Utility.getResourceTestDataFile("restapi-resource")) - .addFormParam("renditions", "doclib") - .addFormParam("autoRename", true); - - RestNodeModel newNode = restClient.withCoreAPI().usingNode(ContentModel.my()).createNode(); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - newNode.assertThat().field("aspectNames").contains("cm:auditable") - .assertThat().field("isFolder").is(false) - .assertThat().field("isFile").is(true) - .assertThat().field("name").contains("restapi-resource"); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NODES }, executionType = ExecutionType.SANITY, - description = "Verify list children when listing with relativePath and pagination") - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY}) - public void checkRelativePathAndPaginationOnCreateChildrenNode() throws Exception - { - /* - * Given we have a folder hierarchy folder1/folder2/folder3 and folder3 containing 3 files file1, file2, and file3 - */ - NodesBuilder nodesBuilder = restClient.authenticateUser(dataUser.getAdminUser()) - .withCoreAPI().usingNode(ContentModel.my()) - .defineNodes(); - nodesBuilder - .folder("F1") - .folder("F2") - .folder("F3") - .file("f1") - .file("f2") - .file("f3"); - - RestNodeModelsCollection returnedFiles = restClient.withParams("maxItems=2", - "skipCount=1", - String.format("relativePath=%s/%s", nodesBuilder.getNode("F2").getName(), nodesBuilder.getNode("F3").getName())) - .withCoreAPI().usingNode(nodesBuilder.getNode("F1").toContentModel()).listChildren(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - /* - * Then I receive file2 and file3 - */ - returnedFiles.assertThat().entriesListCountIs(2); - returnedFiles.getEntries().get(0).onModel().assertThat().field("id").is(nodesBuilder.getNode("f2").getId()); - returnedFiles.getEntries().get(1).onModel().assertThat().field("id").is(nodesBuilder.getNode("f3").getId()); - } - - /** - * Sanity check for the following api endpoints - * POST /nodes/{nodeId}/secondary-children - * GET /nodes/{nodeId}/secondary-children - * DELETE /nodes/{nodeId}/secondary-children/{childId} - */ - @TestRail(section = { TestGroup.REST_API, - TestGroup.NODES }, executionType = ExecutionType.SANITY, description = "Check /secondary-children (create, list, delete) api calls") - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY }) - public void checkSecondaryChildrenApi() throws Exception - { - STEP("1. Create a folder hierarchy folder1/folder2, with folder2 containing 3 files: f1, f2, and f3"); - NodesBuilder nodesBuilder = restClient.authenticateUser(dataUser.getAdminUser()) - .withCoreAPI().usingNode(ContentModel.my()) - .defineNodes(); - nodesBuilder - .folder("F1") - .folder("F2") - .file("f1") - .file("f2") - .file("f3"); - - STEP("2. Create secondary child associations model objects"); - RestNodeChildAssociationModel childAssoc1 = new RestNodeChildAssociationModel(nodesBuilder.getNode("f1").getId(), "cm:contains"); - RestNodeChildAssociationModel childAssoc2 = new RestNodeChildAssociationModel(nodesBuilder.getNode("f2").getId(), "cm:contains"); - RestNodeChildAssociationModel childAssoc3 = new RestNodeChildAssociationModel(nodesBuilder.getNode("f3").getId(), "cm:preferenceImage"); - String secondaryChildrenBody = "[" + childAssoc1.toJson() + "," + childAssoc2.toJson() + "," + childAssoc3.toJson() + "]"; - - STEP("3. Create secondary child associations using POST /nodes/{nodeId}/secondary-children"); - RestNodeChildAssocModelCollection secondaryChildAssoc = restClient.withCoreAPI().usingNode(nodesBuilder.getNode("F1").toContentModel()) - .createSecondaryChildren(secondaryChildrenBody); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - secondaryChildAssoc.getEntryByIndex(0).assertThat().field("childId").is(childAssoc1.getChildId()); - secondaryChildAssoc.getEntryByIndex(1).assertThat().field("childId").is(childAssoc2.getChildId()); - secondaryChildAssoc.getEntryByIndex(2).assertThat().field("childId").is(childAssoc3.getChildId()); - - STEP("4. Check using GET /nodes/{nodeId}/secondary-children that the secondary 'cm:contains' child associations were created"); - RestNodeAssociationModelCollection secondaryChildren = restClient.withParams("where=(assocType='cm:contains')").withCoreAPI() - .usingNode(nodesBuilder.getNode("F1").toContentModel()).getSecondaryChildren(); - restClient.assertStatusCodeIs(HttpStatus.OK); - secondaryChildren.assertThat().entriesListCountIs(2); - - STEP("5. Check using DELETE /nodes/{nodeId}/secondary-children/{childId} that a secondary child can be deleted"); - restClient.withCoreAPI().usingNode(nodesBuilder.getNode("F1").toContentModel()).deleteSecondaryChild(secondaryChildren.getEntryByIndex(0)); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - STEP("6. Check using GET /nodes/{nodeId}/secondary-children that a secondary child association was deleted"); - secondaryChildren = restClient.withCoreAPI().usingNode(nodesBuilder.getNode("F1").toContentModel()) - .getSecondaryChildren(); - restClient.assertStatusCodeIs(HttpStatus.OK); - secondaryChildren.assertThat().entriesListCountIs(2); - secondaryChildren.getEntryByIndex(0).assertThat() - .field("id").is(secondaryChildAssoc.getEntryByIndex(1).getChildId()).and() - .field("parentId").is(nodesBuilder.getNode("F2").getId()) - .getAssociation().assertThat() - .field("isPrimary").is(false).and() - .field("assocType").is("cm:contains"); - secondaryChildren.getEntryByIndex(1).assertThat() - .field("id").is(secondaryChildAssoc.getEntryByIndex(2).getChildId()) - .getAssociation().assertThat() - .field("assocType").is("cm:preferenceImage"); - } - - /** - * Sanity check for the following api endpoint - * GET /nodes/{nodeId}/parents - */ - @TestRail(section = { TestGroup.REST_API, - TestGroup.NODES }, executionType = ExecutionType.SANITY, description = "Check that GET /parents retrieves primary and secondary parents for a node") - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY }) - public void checkGetNodeParents() throws Exception - { - STEP("1. Create a folder hierarchy folder1/folder2, with folder2 containing file f1"); - NodesBuilder nodesBuilder = restClient.authenticateUser(dataUser.getAdminUser()) - .withCoreAPI().usingNode(ContentModel.my()) - .defineNodes(); - nodesBuilder - .folder("F1") - .folder("F2") - .file("f1"); - - STEP("2. Create secondary child associations using POST /nodes/{nodeId}/secondary-children"); - RestNodeChildAssociationModel childAssoc = new RestNodeChildAssociationModel(nodesBuilder.getNode("f1").getId(), "cm:contains"); - restClient.withCoreAPI().usingNode(nodesBuilder.getNode("F1").toContentModel()).createSecondaryChildren(childAssoc.toJson()); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - STEP("3. Get all parents for file 'f1' - both primary and secondary"); - RestNodeAssociationModelCollection parents = restClient.withCoreAPI().usingNode(nodesBuilder.getNode("f1").toContentModel()).getParents(); - restClient.assertStatusCodeIs(HttpStatus.OK); - parents.assertThat().entriesListCountIs(2); - - STEP("4. Check using GET /nodes/{nodeId}/parents that the parent (not primary) for f1 is found"); - parents = restClient.withParams("where=(isPrimary=false)").withCoreAPI().usingNode(nodesBuilder.getNode("f1").toContentModel()).getParents(); - restClient.assertStatusCodeIs(HttpStatus.OK); - parents.assertThat().entriesListCountIs(1); - parents.getEntryByIndex(0).assertThat() - .field("isFolder").is("true").and() - .field("isFile").is(false).and() - .field("name").is(nodesBuilder.getNode("F1").getName()) - .getAssociation().assertThat() - .field("isPrimary").is(false).and() - .field("assocType").is("cm:contains"); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesTargetSourcesTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesTargetSourcesTests.java deleted file mode 100644 index d6fe35259..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesTargetSourcesTests.java +++ /dev/null @@ -1,120 +0,0 @@ -package org.alfresco.service.search.rest.nodes; - -import static org.alfresco.utility.report.log.Step.STEP; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestNodeAssocTargetModel; -import org.alfresco.rest.model.RestNodeAssociationModelCollection; -import org.alfresco.rest.model.builder.NodesBuilder; -import org.alfresco.utility.model.ContentModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class NodesTargetSourcesTests extends RestTest -{ - - private UserModel adminUserModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - } - - /** - * Sanity check for the following api endpoints - * POST /nodes/{nodeId}/targets - * GET /nodes/{nodeId}/targets - * DELETE /nodes/{nodeId}/targets/{targetId} - */ - - @TestRail(section = { TestGroup.REST_API, - TestGroup.NODES }, executionType = ExecutionType.SANITY, description = "Check /targets (create, list, delete) api calls") - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY }) - public void checkTargetsNodeApi() throws Exception - { - STEP("1.Create folder1 which contains 3 files: f1, f2, and f3"); - NodesBuilder nodesBuilder = restClient.authenticateUser(adminUserModel).withCoreAPI().usingNode(ContentModel.my()).defineNodes(); - nodesBuilder.folder("F1").file("f1").file("f2").file("f3"); - - STEP("2. Create target associations model objects"); - RestNodeAssocTargetModel assocDocTarget1 = new RestNodeAssocTargetModel(nodesBuilder.getNode("f2").toContentModel().getNodeRef(), "cm:references"); - RestNodeAssocTargetModel assocDocTarget2 = new RestNodeAssocTargetModel(nodesBuilder.getNode("f3").toContentModel().getNodeRef(), "cm:references"); - - STEP("3. Create target associations using POST /nodes/{nodeId}/targets"); - restClient.withCoreAPI().usingResource(nodesBuilder.getNode("f1").toContentModel()).createTargetForNode(assocDocTarget1); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.withCoreAPI().usingResource(nodesBuilder.getNode("f1").toContentModel()).createTargetForNode(assocDocTarget2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - STEP("4. Check using GET /nodes/{nodeId}/targets targets associations were created"); - RestNodeAssociationModelCollection targetsRes = restClient.withParams("where=(assocType='cm:references')").withCoreAPI().usingResource(nodesBuilder.getNode("f1").toContentModel()).getNodeTargets(); - restClient.assertStatusCodeIs(HttpStatus.OK); - targetsRes.assertThat().entriesListCountIs(2); - targetsRes.getEntryByIndex(0).assertThat().field("association.assocType").is("cm:references").and().field("name") - .is(nodesBuilder.getNode("f2").getName()); - targetsRes.getEntryByIndex(1).assertThat().field("association.assocType").is("cm:references").and().field("name") - .is(nodesBuilder.getNode("f3").getName()); - - STEP("5. Check using DELETE /nodes/{nodeId}/targets/{targetId} that a target can be deleted"); - restClient.authenticateUser(adminUserModel); - restClient.withCoreAPI().usingResource(nodesBuilder.getNode("f1").toContentModel()).deleteTarget(assocDocTarget1); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - STEP("6. Check using GET /nodes/{nodeId}/targets that target association was deleted"); - targetsRes = restClient.withParams("where=(assocType='cm:references')").withCoreAPI() - .usingResource(nodesBuilder.getNode("f1").toContentModel()).getNodeTargets(); - restClient.assertStatusCodeIs(HttpStatus.OK); - targetsRes.assertThat().entriesListCountIs(1); - targetsRes.getEntryByIndex(0).assertThat().field("association.assocType").is("cm:references"); - } - - /** - * Sanity check for the following api endpoint - * GET /nodes/{nodeId}/sources - */ - @TestRail(section = { TestGroup.REST_API, - TestGroup.NODES }, executionType = ExecutionType.SANITY, description = "Check that source objects are retrieved using GET /nodes/{nodeId}/sources") - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY }) - public void checkGetNodeSources() throws Exception - { - STEP("1.Create a folder hierarchy folder1 containing 4 files: f1, f2, and f3"); - NodesBuilder nodesBuilder = restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingNode(ContentModel.my()).defineNodes(); - nodesBuilder.folder("F1").file("f1").file("f2").file("f3"); - - STEP("2. Create target associations model objects"); - RestNodeAssocTargetModel assocDocTarget1 = new RestNodeAssocTargetModel(nodesBuilder.getNode("f3").toContentModel().getNodeRef(), "cm:references"); - RestNodeAssocTargetModel assocDocTarget2 = new RestNodeAssocTargetModel(nodesBuilder.getNode("f3").toContentModel().getNodeRef(), "cm:preferenceImage"); - - STEP("3. Create target associations using POST /nodes/{nodeId}/targets"); - restClient.authenticateUser(adminUserModel); - restClient.withCoreAPI().usingResource(nodesBuilder.getNode("f1").toContentModel()).createTargetForNode(assocDocTarget1); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.withCoreAPI().usingResource(nodesBuilder.getNode("f2").toContentModel()).createTargetForNode(assocDocTarget2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - STEP("4. Check using GET /nodes/{nodeId}/sources that all source associations are displayed"); - RestNodeAssociationModelCollection sources = restClient.withCoreAPI().usingResource(nodesBuilder.getNode("f3").toContentModel()).getNodeSources(); - restClient.assertStatusCodeIs(HttpStatus.OK); - sources.assertThat().entriesListCountIs(2); - - STEP("5. Check using GET /nodes/{nodeId}/sources with params that sources and fields can be filtered in the response"); - sources = restClient.withParams("where=(assocType='cm:references')", "fields=isFile,name,association,id,nodeType,parentId").withCoreAPI().usingResource(nodesBuilder.getNode("f3").toContentModel()).getNodeSources(); - restClient.assertStatusCodeIs(HttpStatus.OK); - sources.assertThat().entriesListCountIs(1); - - sources.getEntryByIndex(0).assertThat() - .field("isFile").is(true).and() - .field("name").is(nodesBuilder.getNode("f1").getName()).and() - .field("id").is(nodesBuilder.getNode("f1").getId()).and() - .field("id").is(nodesBuilder.getNode("f1").getId()).and() - .field("nodeType").is("cm:content") - .getAssociation().assertThat() - .field("assocType").is("cm:references"); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesTests.java deleted file mode 100644 index 9a3866989..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesTests.java +++ /dev/null @@ -1,56 +0,0 @@ -package org.alfresco.service.search.rest.nodes; - -import org.alfresco.service.search.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()); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesUnlockTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesUnlockTests.java deleted file mode 100644 index 488dd854d..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesUnlockTests.java +++ /dev/null @@ -1,112 +0,0 @@ -package org.alfresco.service.search.rest.nodes; - -import static org.alfresco.utility.report.log.Step.STEP; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestNodeModel; -import org.alfresco.rest.model.body.RestNodeLockBodyModel; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class NodesUnlockTests extends RestTest -{ - private UserModel user1, user2, adminUser; - private SiteModel publicSite; - private FileModel file1; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - publicSite = dataSite.usingUser(adminUser).createPublicRandomSite(); - user1 = dataUser.createRandomTestUser(); - user2 = dataUser.createRandomTestUser(); - dataUser.addUserToSite(user1, publicSite, UserRole.SiteCollaborator); - user1.setUserRole(UserRole.SiteCollaborator); - dataUser.addUserToSite(user2, publicSite, UserRole.SiteCollaborator); - user2.setUserRole(UserRole.SiteCollaborator); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY }) - @TestRail(section={TestGroup.REST_API, TestGroup.NODES}, executionType= ExecutionType.SANITY, - description= "Verify Collaborator canot unlock EPHEMERAL lock made by different user, but can unlock EPHEMERAL lock made by same user") - public void lockEphemeralAndUnlock() throws Exception - { - STEP("1. Add user(s) as collaborators to the site created by administrator and add a file in this site."); - file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); - - STEP("2. Verify with user1 that the file is not locked."); - RestNodeModel file1Model1 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model1.assertThat().field("isLocked").is(false); - - STEP("3. Lock the file using mode EPHEMERAL with user1 (POST nodes/{nodeId}/lock)."); - RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); - lockBodyModel.setLifetime("EPHEMERAL"); - lockBodyModel.setTimeToExpire(20); - restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - - STEP("4. Verify with user1 that the file is locked."); - RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model2.assertThat().field("isLocked").is(true); - - STEP("5. Cannot unlock the file with user2 while the file is still locked"); - restClient.authenticateUser(user2).withCoreAPI().usingNode(file1).usingParams("include=isLocked").unlockNode(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError() - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - - STEP("6. Unlock the file with user1 while the file is still locked"); - RestNodeModel file1Model3 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").unlockNode(); - file1Model3.assertThat().field("isLocked").is(false); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY }) - @TestRail(section={TestGroup.REST_API, TestGroup.NODES}, executionType= ExecutionType.SANITY, - description= "Verify Collaborator canot unlock PERSISTENT lock made by different user, but can unlock PERSISTENT lock made by same user") - public void lockPersistentAndUnlock() throws Exception{ - - STEP("1. Add user(s) as collaborators to the site created by administrator and add a file in this site."); - file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); - - STEP("2. Verify with admin that the file is not locked."); - RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model1.assertThat().field("isLocked").is(false); - - STEP("3. Lock the file using mode PERSISTENT with user1 (POST nodes/{nodeId}/lock)."); - RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); - lockBodyModel.setLifetime("PERSISTENT"); - lockBodyModel.setTimeToExpire(20); - restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - - STEP("4. Verify with user1 that the file is locked."); - RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model2.assertThat().field("isLocked").is(true); - - STEP("5. Cannot unlock the file with user2 while the file is still locked"); - restClient.authenticateUser(user2).withCoreAPI().usingNode(file1).usingParams("include=isLocked").unlockNode(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError() - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - - STEP("6. Unlock the file with user1 while the file is still locked"); - RestNodeModel file1Model3 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").unlockNode(); - file1Model3.assertThat().field("isLocked").is(false); - } - -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/AvatarPeopleSanityTest.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/AvatarPeopleSanityTest.java deleted file mode 100644 index 46e4cd71c..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/AvatarPeopleSanityTest.java +++ /dev/null @@ -1,66 +0,0 @@ -package org.alfresco.service.search.rest.people; - -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; - -import java.io.File; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.utility.Utility; -import org.alfresco.utility.exception.DataPreparationException; -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; - -import com.jayway.restassured.response.ValidatableResponse; - -public class AvatarPeopleSanityTest extends RestTest -{ - - private UserModel userModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws DataPreparationException - { - userModel = dataUser.createRandomTestUser(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY, TestGroup.REQUIRE_TRANSFORMATION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Update Avatar for People") - public void updateGetAvatarForPeople() throws Exception - { - File avatarFile = Utility.getResourceTestDataFile("avatar.jpg"); - restClient.authenticateUser(userModel); - ValidatableResponse response = restClient.withCoreAPI().usingAuthUser() - .uploadAvatarContent(restProperties.envProperty().getFullServerUrl(), avatarFile).statusCode(200); - // Renditions are async - Utility.sleep(500, 60000, () -> - { - restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().downloadAvatarContent(); - restClient.assertStatusCodeIs(HttpStatus.OK); - }); - assertNotNull(response.extract().body().asByteArray()); - assertTrue(response.extract().body().asByteArray().length > 0, "Avatar Image not uploaded"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY, TestGroup.REQUIRE_TRANSFORMATION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Remove Avatar for People") - public void removeGetAvatarForPeople() throws Exception - { - File avatarFile = Utility.getResourceTestDataFile("avatar.jpg"); - restClient.authenticateUser(userModel); - restClient.withCoreAPI().usingAuthUser().uploadAvatarContent(restProperties.envProperty().getFullServerUrl(), avatarFile).statusCode(200); - - restClient.authenticateUser(userModel); - restClient.withCoreAPI().usingAuthUser().resetAvatarImageRequest(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().downloadAvatarContent(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } - -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/DeleteSiteMemberCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/DeleteSiteMemberCoreTests.java deleted file mode 100644 index 32a8b8e53..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/DeleteSiteMemberCoreTests.java +++ /dev/null @@ -1,229 +0,0 @@ -package org.alfresco.service.search.rest.people; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -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.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class DeleteSiteMemberCoreTests extends RestTest -{ - private UserModel userModel; - private UserModel managerModel; - private SiteModel publicSiteModel; - private SiteModel moderatedSiteModel; - private SiteModel privateSiteModel; - private UserModel adminUserModel; - private UserModel secondUserModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - secondUserModel = dataUser.createRandomTestUser(); - secondUserModel.setUserRole(UserRole.SiteCollaborator); - userModel = dataUser.createRandomTestUser(); - userModel.setUserRole(UserRole.SiteCollaborator); - managerModel = dataUser.createRandomTestUser(); - managerModel.setUserRole(UserRole.SiteManager); - adminUserModel = dataUser.getAdminUser(); - publicSiteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - moderatedSiteModel = dataSite.usingUser(adminUserModel).createModeratedRandomSite(); - privateSiteModel = dataSite.usingUser(adminUserModel).createPrivateRandomSite(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user removes a site member using '-me-' in place of personId and response is successful (204)") - public void removeSiteMemberWithSuccessUsingMeAsPersonId() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(userModel); - - restClient.authenticateUser(userModel).withCoreAPI().usingMe().deleteSiteMember(publicSiteModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user can't remove a site membership of an inexistent uer and response is 404") - public void userIsNotAbleToRemoveInexistentSiteMember() throws Exception - { - UserModel inexistentUser = new UserModel("inexistenUser", "password"); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(inexistentUser).deleteSiteMember(publicSiteModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, inexistentUser.getUsername())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove a member of an inexistent site and response is 404") - public void userIsNotAbleToRemoveMembershipOfInexistentSite() throws Exception - { - SiteModel inexistentSite = new SiteModel("inexistentSite"); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(userModel).deleteSiteMember(inexistentSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, userModel.getUsername(), inexistentSite.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove a member of an empty site id and response is 404") - public void userIsNotAbleToRemoveMembershipOfEmptySiteId() throws Exception - { - SiteModel inexistentSite = new SiteModel(""); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(userModel).deleteSiteMember(inexistentSite); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.DELETE_EMPTY_ARGUMENT); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove a regular member a moderated site and response is 422") - public void regularUserIsNotAbleToRemoveRegularUserSiteMembershipFromModeratedSite() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(secondUserModel); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(userModel); - restClient.authenticateUser(secondUserModel).withCoreAPI().usingUser(userModel).deleteSiteMember(moderatedSiteModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() - .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, moderatedSiteModel.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove a regular member of a private site and response is 422") - public void regularUserIsNotAbleToRemoveRegularUserSiteMembershipFromPrivateSite() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(userModel); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(secondUserModel); - restClient.authenticateUser(secondUserModel).withCoreAPI().usingUser(userModel).deleteSiteMember(privateSiteModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() - .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, privateSiteModel.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove a regular member of a moderated site and response is 204") - public void adminIsAbleToRemoveRegularUserSiteMembershipFromModeratedSite() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(userModel); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(userModel).deleteSiteMember(moderatedSiteModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove a regular member of a private site and response is 204") - public void adminIsAbleToRemoveRegularUserSiteMembershipFromPrivateSite() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(userModel); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(userModel).deleteSiteMember(privateSiteModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove admin membership from public site and response is 422") - public void regularUserIsNotAbleToRemoveAdminSiteMembershipFromPublicSite() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(managerModel); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(userModel); - restClient.authenticateUser(userModel).withCoreAPI().usingUser(adminUserModel).deleteSiteMember(publicSiteModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() - .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove admin membership from moderated site and response is 422") - public void regularUserIsNotAbleToRemoveAdminSiteMembershipFromModeratedSite() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(managerModel); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(userModel); - restClient.authenticateUser(userModel).withCoreAPI().usingUser(adminUserModel).deleteSiteMember(moderatedSiteModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() - .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, moderatedSiteModel.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove admin membership from private site and response is 422") - public void regularUserIsNotAbleToRemoveAdminSiteMembershipFromPrivateSite() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(managerModel); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(userModel); - restClient.authenticateUser(userModel).withCoreAPI().usingUser(adminUserModel).deleteSiteMember(privateSiteModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() - .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, privateSiteModel.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove the membership of a manager from a public site and response is 204") - public void adminIsAbleToRemoveManagerSiteMembershipOfPublicSite() throws Exception - { - UserModel secondManager = dataUser.createRandomTestUser(); - secondManager.setUserRole(UserRole.SiteManager); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(secondManager); - restClient.withCoreAPI().usingSite(publicSiteModel).addPerson(managerModel); - restClient.withCoreAPI().usingUser(managerModel).deleteSiteMember(publicSiteModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove the membership of a manager from a moderated site and response is 204") - public void adminIsAbleToRemoveManagerSiteMembershipOfModeratedSite() throws Exception - { - UserModel secondManager = dataUser.createRandomTestUser(); - secondManager.setUserRole(UserRole.SiteManager); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(secondManager); - restClient.withCoreAPI().usingSite(moderatedSiteModel).addPerson(managerModel); - restClient.withCoreAPI().usingUser(managerModel).deleteSiteMember(moderatedSiteModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove the membership of a manager from a private site and response is 204") - public void adminIsAbleToRemoveManagerSiteMembershipOfPrivateSite() throws Exception - { - UserModel secondManager = dataUser.createRandomTestUser(); - secondManager.setUserRole(UserRole.SiteManager); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(secondManager); - restClient.withCoreAPI().usingSite(privateSiteModel).addPerson(managerModel); - restClient.withCoreAPI().usingUser(managerModel).deleteSiteMember(privateSiteModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify collaborator is not able to remove the membership of a manager from a public site and response is 204") - public void userIsNotAbleToRemoveManagerSiteMembershipOfPublicSite() throws Exception - { - UserModel secondManager = dataUser.createRandomTestUser(); - secondManager.setUserRole(UserRole.SiteManager); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(secondManager); - restClient.withCoreAPI().usingSite(publicSiteModel).addPerson(userModel); - restClient.withCoreAPI().usingSite(publicSiteModel).addPerson(managerModel); - restClient.authenticateUser(userModel).withCoreAPI().usingUser(managerModel).deleteSiteMember(publicSiteModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() - .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify collaborator is not able to remove the membership of a manager from a moderated site and response is 204") - public void userIsNotAbleToRemoveManagerSiteMembershipOfModeratedSite() throws Exception - { - UserModel secondManager = dataUser.createRandomTestUser(); - secondManager.setUserRole(UserRole.SiteManager); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(secondManager); - restClient.withCoreAPI().usingSite(publicSiteModel).addPerson(userModel); - restClient.withCoreAPI().usingSite(moderatedSiteModel).addPerson(managerModel); - restClient.authenticateUser(userModel).withCoreAPI().usingUser(managerModel).deleteSiteMember(moderatedSiteModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() - .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, moderatedSiteModel.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify collaborator is not able to remove the membership of a manager from a private site and response is 204") - public void userIsNotAbleToRemoveManagerSiteMembershipOfPrivateSite() throws Exception - { - UserModel secondManager = dataUser.createRandomTestUser(); - secondManager.setUserRole(UserRole.SiteManager); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(secondManager); - restClient.withCoreAPI().usingSite(privateSiteModel).addPerson(userModel); - restClient.withCoreAPI().usingSite(privateSiteModel).addPerson(managerModel); - restClient.authenticateUser(userModel).withCoreAPI().usingUser(managerModel).deleteSiteMember(privateSiteModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() - .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, privateSiteModel.getId())); - } -} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/DeleteSiteMemberFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/DeleteSiteMemberFullTests.java deleted file mode 100644 index fe7336390..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/DeleteSiteMemberFullTests.java +++ /dev/null @@ -1,207 +0,0 @@ -package org.alfresco.service.search.rest.people; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -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.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class DeleteSiteMemberFullTests extends RestTest -{ - private SiteModel publicSiteModel; - private SiteModel moderatedSiteModel; - private SiteModel privateSiteModel; - private UserModel adminUserModel; - private ListUserWithRoles usersWithRolesPublicSite; - private ListUserWithRoles usersWithRolesModeratedSite; - private ListUserWithRoles usersWithRolesPrivateSite; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - adminUserModel.setUserRole(UserRole.SiteManager); - publicSiteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - moderatedSiteModel = dataSite.usingUser(adminUserModel).createModeratedRandomSite(); - privateSiteModel = dataSite.usingUser(adminUserModel).createPrivateRandomSite(); - - usersWithRolesPublicSite = dataUser.addUsersWithRolesToSite(publicSiteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - usersWithRolesModeratedSite = dataUser.addUsersWithRolesToSite(moderatedSiteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - usersWithRolesPrivateSite = dataUser.addUsersWithRolesToSite(privateSiteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove collaborator member of a public site") - public void adminIsAbleToRemoveCollaboratorSiteMembershipFromPublicSite() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteCollaborator)).deleteSiteMember(publicSiteModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteCollaborator)); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove contributor member of a public site") - public void adminIsAbleToRemoveContributorSiteMembershipFromPublicSite() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteContributor)).deleteSiteMember(publicSiteModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteContributor)); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove contributor member of a public site and response is 422") - public void userIsNotAbleToRemoveContributorSiteMembershipFromPublicSite() throws Exception - { - restClient.authenticateUser(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingUser(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteContributor)).deleteSiteMember(publicSiteModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() - .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove consumer member of a public site and response is 422") - public void userIsNotAbleToRemoveConsumerSiteMembershipFromPublicSite() throws Exception - { - restClient.authenticateUser(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingUser(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteConsumer)).deleteSiteMember(publicSiteModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() - .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove collaborator member of a moderated site") - public void adminIsAbleToRemoveCollaboratorSiteMembershipFromModeratedSite() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(usersWithRolesModeratedSite.getOneUserWithRole(UserRole.SiteCollaborator)).deleteSiteMember(moderatedSiteModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(usersWithRolesModeratedSite.getOneUserWithRole(UserRole.SiteCollaborator)); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove contributor member of a moderated site") - public void adminIsAbleToRemoveContributorSiteMembershipFromModeratedSite() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(usersWithRolesModeratedSite.getOneUserWithRole(UserRole.SiteContributor)).deleteSiteMember(moderatedSiteModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(usersWithRolesModeratedSite.getOneUserWithRole(UserRole.SiteContributor)); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove contributor member of a moderated site and response is 422") - public void userIsNotAbleToRemoveContributorSiteMembershipFromModeratedSite() throws Exception - { - restClient.authenticateUser(usersWithRolesModeratedSite.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingUser(usersWithRolesModeratedSite.getOneUserWithRole(UserRole.SiteContributor)).deleteSiteMember(moderatedSiteModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() - .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, moderatedSiteModel.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove consumer member of a moderated site and response is 422") - public void userIsNotAbleToRemoveConsumerSiteMembershipFromModeratedSite() throws Exception - { - restClient.authenticateUser(usersWithRolesModeratedSite.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingUser(usersWithRolesModeratedSite.getOneUserWithRole(UserRole.SiteConsumer)).deleteSiteMember(moderatedSiteModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() - .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, moderatedSiteModel.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove collaborator member of a private site") - public void adminIsAbleToRemoveCollaboratorSiteMembershipFromPrivateSite() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(usersWithRolesPrivateSite.getOneUserWithRole(UserRole.SiteCollaborator)).deleteSiteMember(privateSiteModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(usersWithRolesPrivateSite.getOneUserWithRole(UserRole.SiteCollaborator)); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove contributor member of a private site") - public void adminIsAbleToRemoveContributorSiteMembershipFromPrivateSite() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(usersWithRolesPrivateSite.getOneUserWithRole(UserRole.SiteContributor)).deleteSiteMember(privateSiteModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(usersWithRolesPrivateSite.getOneUserWithRole(UserRole.SiteContributor)); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove contributor member of a private site and response is 422") - public void userIsNotAbleToRemoveContributorSiteMembershipFromPrivateSite() throws Exception - { - restClient.authenticateUser(usersWithRolesPrivateSite.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingUser(usersWithRolesPrivateSite.getOneUserWithRole(UserRole.SiteContributor)).deleteSiteMember(privateSiteModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() - .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, privateSiteModel.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove consumer member of a private site and response is 422") - public void userIsNotAbleToRemoveConsumerSiteMembershipFromPrivateSite() throws Exception - { - restClient.authenticateUser(usersWithRolesPrivateSite.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingUser(usersWithRolesPrivateSite.getOneUserWithRole(UserRole.SiteConsumer)).deleteSiteMember(privateSiteModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() - .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, privateSiteModel.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is not able to remove same user twice and response is 400") - @Bug(id="ACE-5447") - public void adminIsNotAbleToRemoveSameUserTwice() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteCollaborator)).deleteSiteMember(publicSiteModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteCollaborator)).deleteSiteMember(publicSiteModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(RestErrorModel.ENTITY_NOT_FOUND); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMembers().assertThat().entriesListContains("id", usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteCollaborator).getUsername()) - .when().getSiteMember(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteCollaborator).getUsername()) - .assertSiteMemberHasRole(UserRole.SiteCollaborator); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify single manager is not able to delete himself and response is 400") - public void lastManagerIsNotAbleToDeleteHimself() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteManager)).deleteSiteMember(publicSiteModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingUser(adminUserModel).deleteSiteMember(publicSiteModel); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.DELETE_LAST_MANAGER, publicSiteModel.getTitle())) - .containsErrorKey(String.format(RestErrorModel.DELETE_LAST_MANAGER, publicSiteModel.getTitle())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER).stackTraceIs(RestErrorModel.STACKTRACE); - - restClient.withCoreAPI().usingSite(publicSiteModel).addPerson(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMembers() - .assertThat().entriesListContains("id", usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteManager).getUsername()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site creator can be deleted") - public void siteCreatorCanBeDeleted() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).deleteSiteMember(publicSiteModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.authenticateUser(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingSite(publicSiteModel).addPerson(adminUserModel); - restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMembers().assertThat().entriesListContains("id", adminUserModel.getUsername()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is not able to remove from site a user that created a member request that was not accepted yet") - @Bug(id="ACE-5447") - public void adminIsNotAbleToRemoveFromSiteANonExistingMember() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSiteModel); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(newMember).deleteSiteMember(moderatedSiteModel); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(RestErrorModel.ENTITY_NOT_FOUND); - } - -} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/DeleteSiteMemberSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/DeleteSiteMemberSanityTests.java deleted file mode 100644 index d76871c62..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/DeleteSiteMemberSanityTests.java +++ /dev/null @@ -1,111 +0,0 @@ -package org.alfresco.service.search.rest.people; - -import org.alfresco.service.search.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; - -public class DeleteSiteMemberSanityTests extends RestTest -{ - private SiteModel siteModel; - private UserModel adminUser; - private ListUserWithRoles usersWithRoles; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws DataPreparationException - { - adminUser = dataUser.getAdminUser(); - siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); - - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site manager is able to delete another member of the site") - public void siteManagerCanDeleteSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception - { - UserModel newUser = dataUser.createRandomTestUser("testUser"); - newUser.setUserRole(UserRole.SiteCollaborator); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingSite(siteModel).addPerson(newUser); - - restClient.withCoreAPI().usingUser(newUser).deleteSiteMember(siteModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify admin user is able to delete another member of the site") - public void adminIsAbleToDeleteSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception - { - UserModel newUser = dataUser.createRandomTestUser("testUser"); - newUser.setUserRole(UserRole.SiteCollaborator); - restClient.authenticateUser(adminUser).withCoreAPI().usingSite(siteModel).addPerson(newUser); - - restClient.withCoreAPI().usingUser(newUser).deleteSiteMember(siteModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site collaborator does not have permission to delete another member of the site") - public void siteCollaboratorIsNotAbleToDeleteSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception - { - UserModel newUser = dataUser.createRandomTestUser("testUser"); - newUser.setUserRole(UserRole.SiteCollaborator); - restClient.authenticateUser(adminUser).withCoreAPI().usingSite(siteModel).addPerson(newUser); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - - restClient.withCoreAPI().usingUser(newUser).deleteSiteMember(siteModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() - .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site contributor does not have permission to delete another member of the site") - public void siteContributorIsNotAbleToDeleteSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception - { - UserModel newUser = dataUser.createRandomTestUser("testUser"); - newUser.setUserRole(UserRole.SiteCollaborator); - restClient.authenticateUser(adminUser).withCoreAPI().usingSite(siteModel).addPerson(newUser); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - - restClient.withCoreAPI().usingUser(newUser).deleteSiteMember(siteModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() - .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site consumer does not have permission to delete another member of the site") - public void siteConsumerIsNotAbleToDeleteSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception - { - UserModel newUser = dataUser.createRandomTestUser("testUser"); - newUser.setUserRole(UserRole.SiteCollaborator); - restClient.authenticateUser(adminUser).withCoreAPI().usingSite(siteModel).addPerson(newUser); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - - restClient.withCoreAPI().usingUser(newUser).deleteSiteMember(siteModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() - .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify unauthenticated user is not able to delete another member of the site") - public void unauthenticatedUserIsNotAbleToDeleteSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception - { - restClient.authenticateUser(new UserModel("random user", "random password")); - - restClient.withCoreAPI().usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).deleteSiteMember(siteModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError().containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED);; - } -} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetPeopleCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetPeopleCoreTests.java deleted file mode 100644 index 2ff985718..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetPeopleCoreTests.java +++ /dev/null @@ -1,57 +0,0 @@ -package org.alfresco.service.search.rest.people; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -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.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * - * @author Cristina Axinte - * - */ -public class GetPeopleCoreTests extends RestTest -{ - UserModel userModel; - SiteModel siteModel; - UserModel searchedUser; - UserModel adminUser, managerUser; - UserModel inexistentUser; - - @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); - inexistentUser = new UserModel("inexistentUser", "password"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify inexistent user cannot get a person with Rest API and response is 401") - public void inexistentUserIsUnauthorizedToGetPerson() throws Exception - { - restClient.authenticateUser(inexistentUser).withCoreAPI().usingUser(searchedUser).getPerson(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); - restClient.assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot get a person that doesn't exists with Rest API and response is 404") - public void userCannotGetInexistentPerson() throws Exception - { - restClient.authenticateUser(managerUser).withCoreAPI().usingUser(inexistentUser).getPerson(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - restClient.assertLastError().containsSummary(String.format(inexistentUser.getUsername(), RestErrorModel.ENTITY_NOT_FOUND)); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetPeopleFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetPeopleFullTests.java deleted file mode 100644 index 454500cc3..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetPeopleFullTests.java +++ /dev/null @@ -1,88 +0,0 @@ -package org.alfresco.service.search.rest.people; - -import org.alfresco.service.search.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"); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetPeopleSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetPeopleSanityTests.java deleted file mode 100644 index e4937bba5..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetPeopleSanityTests.java +++ /dev/null @@ -1,110 +0,0 @@ -package org.alfresco.service.search.rest.people; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestPersonModel; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class GetPeopleSanityTests extends RestTest -{ - UserModel userModel; - SiteModel siteModel; - UserModel searchedUser; - UserModel adminUser; - private RestPersonModel personModel; - private String domain = "@tas-automation.org"; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - searchedUser = dataUser.createRandomTestUser(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user gets a person with Rest API and response is successful") - public void managerUserChecksIfPersonIsPresent() throws Exception - { - UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); - - personModel = restClient.authenticateUser(managerUser).withCoreAPI().usingUser(searchedUser).getPerson(); - restClient.assertStatusCodeIs(HttpStatus.OK); - personModel.assertThat().field("id").is(searchedUser.getUsername()).assertThat().field("firstName").is(searchedUser.getUsername() + " FirstName").and() - .field("email").is(searchedUser.getUsername() + domain).and().field("emailNotificationsEnabled").is("true"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify collaborator user gets a person with Rest API and response is successful") - public void collaboratorUserChecksIfPersonIsPresent() throws Exception - { - UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(collaboratorUser, siteModel, UserRole.SiteCollaborator); - - personModel = restClient.authenticateUser(collaboratorUser).withCoreAPI().usingUser(searchedUser).getPerson(); - restClient.assertStatusCodeIs(HttpStatus.OK); - personModel.assertThat().field("id").is(searchedUser.getUsername()).assertThat().field("firstName").is(searchedUser.getUsername() + " FirstName").and() - .field("email").is(searchedUser.getUsername() + domain).and().field("emailNotificationsEnabled").is("true"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.COMMENTS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify contributor user gets a person with Rest API and response is successful") - public void contributorUserChecksIfPersonIsPresent() throws Exception - { - UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(contributorUser, siteModel, UserRole.SiteContributor); - - personModel = restClient.authenticateUser(contributorUser).withCoreAPI().usingUser(searchedUser).getPerson(); - restClient.assertStatusCodeIs(HttpStatus.OK); - personModel.assertThat().field("id").is(searchedUser.getUsername()).assertThat().field("firstName").is(searchedUser.getUsername() + " FirstName").and() - .field("email").is(searchedUser.getUsername() + domain).and().field("emailNotificationsEnabled").is("true"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify consumer user gets a person with Rest API and response is successful") - public void consumerUserChecksIfPersonIsPresent() throws Exception - { - UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel, UserRole.SiteConsumer); - - personModel = restClient.authenticateUser(consumerUser).withCoreAPI().usingUser(searchedUser).getPerson(); - restClient.assertStatusCodeIs(HttpStatus.OK); - personModel.assertThat().field("id").is(searchedUser.getUsername()).assertThat().field("firstName").is(searchedUser.getUsername() + " FirstName").and() - .field("email").is(searchedUser.getUsername() + domain).and().field("emailNotificationsEnabled").is("true"); - ; - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify admin user gets a person with Rest API and response is successful") - public void adminUserChecksIfPersonIsPresent() throws Exception - { - personModel = restClient.authenticateUser(adminUser).withCoreAPI().usingUser(searchedUser).getPerson(); - restClient.assertStatusCodeIs(HttpStatus.OK); - personModel.assertThat().field("id").is(searchedUser.getUsername()).assertThat().field("firstName").is(searchedUser.getUsername() + " FirstName").and() - .field("email").is(searchedUser.getUsername() + domain).and().field("emailNotificationsEnabled").is("true"); - ; - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user gets a non existing person with Rest API and person is not found") - public void managerUserChecksIfNonExistingPersonIsPresent() throws Exception - { - UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); - UserModel searchedNonUser = new UserModel("nonexistinguser", DataUser.PASSWORD); - - restClient.authenticateUser(managerUser).withCoreAPI().usingUser(searchedNonUser).getPerson(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); - } -} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSiteMembershipCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSiteMembershipCoreTests.java deleted file mode 100644 index 22d5c0292..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSiteMembershipCoreTests.java +++ /dev/null @@ -1,114 +0,0 @@ -package org.alfresco.service.search.rest.people; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestSiteEntry; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser; -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; - -/** - * Created by Claudia Agache on 11/28/2016. - */ - -public class GetSiteMembershipCoreTests extends RestTest -{ - UserModel regularUser, publicSiteManager, privateSiteManager, moderatedSiteManager, adminUser; - SiteModel publicSite, privateSite, moderatedSite; - private DataUser.ListUserWithRoles publicSiteUsers; - private RestSiteEntry restSiteEntry; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - regularUser = dataUser.createRandomTestUser(); - privateSiteManager = dataUser.createRandomTestUser(); - moderatedSiteManager = dataUser.createRandomTestUser(); - publicSite = dataSite.usingAdmin().createPublicRandomSite(); - privateSite = dataSite.usingAdmin().createPrivateRandomSite(); - moderatedSite = dataSite.usingAdmin().createModeratedRandomSite(); - - publicSiteUsers = dataUser.addUsersWithRolesToSite(publicSite, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - publicSiteManager = publicSiteUsers.getOneUserWithRole(UserRole.SiteManager); - dataUser.usingAdmin().addUserToSite(privateSiteManager, privateSite, UserRole.SiteManager); - dataUser.usingAdmin().addUserToSite(moderatedSiteManager, moderatedSite, UserRole.SiteManager); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) -// @Bug(id = "REPO-1642", description = "reproduced on 5.2.1 only, it works on 5.2.0") - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify get site membership for a site returns status 404 when personId does not exist.") - public void getSiteMembershipUsingNonExistentPersonId() throws Exception - { - UserModel someUser = new UserModel("someUser", DataUser.PASSWORD); - - restClient.authenticateUser(regularUser).withCoreAPI().usingUser(someUser).getSiteMembership(publicSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "someUser")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify get site membership for a site returns status 404 when siteId does not exist.") - public void getSiteMembershipUsingNonExistentSiteId() throws Exception - { - SiteModel someSite = new SiteModel("someSite"); - - restClient.authenticateUser(regularUser).withCoreAPI().usingAuthUser().getSiteMembership(someSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, regularUser.getUsername(), "someSite")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify get site membership for a site returns status 404 when personId is not a site member.") - public void getSiteMembershipForPersonThatIsNotSiteMember() throws Exception - { - restClient.authenticateUser(publicSiteManager).withCoreAPI().usingUser(regularUser).getSiteMembership(publicSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, regularUser.getUsername(), publicSite.getTitle())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify regular user is not able to retrieve site membership information of a private site member.") - public void regularUserIsNotAbleToRetrieveSiteMembershipForPrivateSiteManager() throws Exception - { - restClient.authenticateUser(regularUser).withCoreAPI().usingUser(privateSiteManager).getSiteMembership(privateSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, privateSiteManager.getUsername(), privateSite.getTitle())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify regular user is able to retrieve site membership information of a moderated site member.") - public void regularUserGetsSiteMembershipForModeratedSiteMember() throws Exception - { - restSiteEntry = restClient.authenticateUser(regularUser).withCoreAPI().usingUser(moderatedSiteManager).getSiteMembership(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteEntry.assertThat().field("role").is(UserRole.SiteManager).and().field("id").is(moderatedSite.getId()).and().field("site").isNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify if Admin user is able to retrieve site membership information of him.") - public void adminGetsSiteMembershipForHim() throws Exception - { - restSiteEntry = restClient.authenticateUser(adminUser).withCoreAPI().usingUser(adminUser).getSiteMembership(privateSite); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteEntry.assertThat().field("role").is(UserRole.SiteManager).and().field("id").is(privateSite.getId()).and().field("site").isNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify if Admin user is able to retrieve site membership information of him.") - public void getSiteMembershipAfterRemovingASiteMember() throws Exception - { - UserModel publicSiteConsumer = publicSiteUsers.getOneUserWithRole(UserRole.SiteConsumer); - restClient.authenticateUser(publicSiteManager).withCoreAPI().usingSite(publicSite).deleteSiteMember(publicSiteConsumer); - restClient.authenticateUser(publicSiteManager).withCoreAPI().usingUser(publicSiteConsumer).getSiteMembership(publicSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, publicSiteConsumer.getUsername(), publicSite.getTitle())); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSiteMembershipFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSiteMembershipFullTests.java deleted file mode 100644 index 30b8a4771..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSiteMembershipFullTests.java +++ /dev/null @@ -1,138 +0,0 @@ -package org.alfresco.service.search.rest.people; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestSiteEntry; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class GetSiteMembershipFullTests extends RestTest -{ - UserModel regularUser, adminUser; - SiteModel publicSite, moderatedSite; - private DataUser.ListUserWithRoles publicSiteUsers; - private RestSiteEntry restSiteEntry; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - regularUser = dataUser.createRandomTestUser(); - publicSite = dataSite.usingAdmin().createPublicRandomSite(); - moderatedSite = dataSite.usingAdmin().createModeratedRandomSite(); - - publicSiteUsers = dataUser.addUsersWithRolesToSite(publicSite, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify that properties parameter is applied.") - public void checkThatPropertiesParameterIsApplied() throws Exception - { - restSiteEntry = restClient.authenticateUser(regularUser).withCoreAPI().usingParams("properties=site,role,id") - .usingUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteManager)).getSiteMembership(publicSite); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteEntry.assertThat().field("role").is(UserRole.SiteManager) - .and().field("id").is(publicSite.getId()) - .and().field("site").isNotEmpty() - .and().field("guid").isNull(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify that regular user " - + "is able to retrieve site membership information of admin.") - public void regularUserGetsSiteMembershipForAdmin() throws Exception - { - restSiteEntry = restClient.authenticateUser(regularUser).withCoreAPI().usingUser(adminUser).getSiteMembership(publicSite); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteEntry.assertThat().field("role").is(UserRole.SiteManager) - .and().field("id").is(publicSite.getId()) - .and().field("site.id").is(publicSite.getId()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify that regular user " - + "is able to retrieve site membership details for a Collaborator role.") - public void getSiteMembershipDetailsForACollaboratorRole() throws Exception - { - restSiteEntry = restClient.authenticateUser(regularUser).withCoreAPI() - .usingUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)).getSiteMembership(publicSite); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteEntry.assertThat().field("role").is(UserRole.SiteCollaborator) - .and().field("guid").is(publicSite.getGuid()) - .and().field("id").is(publicSite.getId()) - .and().field("site.visibility").is(publicSite.getVisibility().toString()) - .and().field("site.guid").is(publicSite.getGuid()) - .and().field("site.description").is(publicSite.getDescription()) - .and().field("site.id").is(publicSite.getId()) - .and().field("site.preset").is("site-dashboard") - .and().field("site.title").is(publicSite.getTitle()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify that regular user " - + "is able to retrieve site membership details for a Contributor role.") - public void getSiteMembershipDetailsForAContributorRole() throws Exception - { - restSiteEntry = restClient.authenticateUser(regularUser).withCoreAPI() - .usingUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteContributor)).getSiteMembership(publicSite); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteEntry.assertThat().field("role").is(UserRole.SiteContributor) - .and().field("id").is(publicSite.getId()) - .and().field("site").isNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify that regular user " - + "is able to retrieve site membership details for a Consumer role.") - public void getSiteMembershipDetailsForAConsumerRole() throws Exception - { - restSiteEntry = restClient.authenticateUser(regularUser).withCoreAPI() - .usingUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteConsumer)).getSiteMembership(publicSite); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteEntry.assertThat().field("role").is(UserRole.SiteConsumer) - .and().field("id").is(publicSite.getId()) - .and().field("site").isNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "As regular user make a request to join a moderated site." - + " The request is pending. Check membership details.") - public void pendingRequestToASiteCheckMembershipDetails() throws Exception - { - restClient.authenticateUser(regularUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restSiteEntry = restClient.authenticateUser(adminUser).withCoreAPI() - .usingUser(regularUser).getSiteMembership(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, regularUser.getUsername(), moderatedSite.getTitle())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "As Collaborator user leave site and perform get call." - + "Check default error model schema.") - public void leaveSiteAndPerformGetCallCheckDefaultErrorModelSchema() throws Exception - { - UserModel leaveSiteUser = dataUser.createRandomTestUser(); - dataUser.addUserToSite(leaveSiteUser, publicSite, UserRole.SiteCollaborator); - restClient.authenticateUser(leaveSiteUser).withCoreAPI().usingAuthUser().deleteSiteMember(publicSite); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restSiteEntry = restClient.authenticateUser(adminUser).withCoreAPI() - .usingUser(leaveSiteUser).getSiteMembership(publicSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, leaveSiteUser.getUsername(), publicSite.getTitle())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSiteMembershipSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSiteMembershipSanityTests.java deleted file mode 100644 index e1639d7e3..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSiteMembershipSanityTests.java +++ /dev/null @@ -1,90 +0,0 @@ -package org.alfresco.service.search.rest.people; - -import org.alfresco.service.search.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; - -public class GetSiteMembershipSanityTests extends RestTest -{ - private SiteModel siteModel; - private UserModel adminUser; - private ListUserWithRoles usersWithRoles; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws DataPreparationException - { - adminUser = dataUser.getAdminUser(); - siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); - - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site manager is able to retrieve site membership information of another user") - public void siteManagerCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingUser(adminUser).getSiteMembership(siteModel) - .assertThat().field("role").is(UserRole.SiteManager).and().field("id").is(siteModel.getId()).and().field("site").isNotEmpty(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site collaborator is able to retrieve site membership information of another user") - public void siteCollaboratorCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingUser(adminUser) - .getSiteMembership(siteModel).onSite().assertThat().field("role").is(UserRole.SiteCollaborator).and().field("id").is(siteModel.getId()); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site contributor is able to retrieve site membership information of another user") - public void siteContributorCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingUser(adminUser) - .getSiteMembership(siteModel).assertThat().field("role").is(UserRole.SiteManager).and().field("id").is(siteModel.getId()).and().field("site") - .isNotEmpty(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site consumer is able to retrieve site membership information of another user") - public void siteConsumerCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingUser(adminUser).getSiteMembership(siteModel) - .assertThat().field("role").is(UserRole.SiteManager).and().field("id").is(siteModel.getId()).and().field("site").isNotEmpty(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify admin user is able to retrieve site membership information of another user") - public void adminCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUser).withCoreAPI().usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).getSiteMembership(siteModel) - .assertThat().field("role").is(UserRole.SiteManager).and().field("id").is(siteModel.getId()).and().field("site").isNotEmpty(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to retrieve site membership information of another user") -// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void unauthenticatedUserCannotRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(new UserModel("random user", "random password")).withCoreAPI() - .usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).getSiteMembership(siteModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } -} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSitesMembershipInformationCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSitesMembershipInformationCoreTests.java deleted file mode 100644 index 21c503948..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSitesMembershipInformationCoreTests.java +++ /dev/null @@ -1,136 +0,0 @@ -package org.alfresco.service.search.rest.people; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.utility.constants.UserRole; -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; - -public class GetSitesMembershipInformationCoreTests extends RestTest -{ - private SiteModel publicSiteModel; - private SiteModel moderatedSiteModel; - private SiteModel privateSiteModel; - private UserModel userModel; - UserModel leaveSiteUserModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws DataPreparationException - { - userModel = dataUser.createRandomTestUser(); - leaveSiteUserModel = dataUser.createRandomTestUser(); - publicSiteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - moderatedSiteModel = dataSite.usingUser(userModel).createModeratedRandomSite(); - privateSiteModel = dataSite.usingUser(userModel).createPrivateRandomSite(); - dataUser.addUserToSite(leaveSiteUserModel, publicSiteModel, UserRole.SiteCollaborator); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site manager is not able to retrieve site membership information for a personId that does not exist") - public void siteManagerCantRetrieveSiteMembershipInformationForAPersonIdThatDoesNotExist() throws Exception - { - restClient.authenticateUser(userModel).withCoreAPI().usingUser(new UserModel("invalidPersonId", "password")).getSitesMembershipInformation() - .assertThat().entriesListIsEmpty(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - restClient.assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidPersonId")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify if get site membership information request returns status code 400 when invalid maxItems parameter is used") - public void getSiteMembershipInformationRequestReturns400ForInvalidMaxItemsParameter() throws Exception - { - restClient.authenticateUser(userModel).withParams("maxItems=0").withCoreAPI().usingAuthUser().getSitesMembershipInformation().assertThat() - .entriesListIsEmpty(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - restClient.assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); - - restClient.withParams("maxItems=-1").withCoreAPI().usingAuthUser().getSitesMembershipInformation().assertThat().entriesListIsEmpty(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - restClient.assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); - - restClient.withParams("maxItems=test").withCoreAPI().usingAuthUser().getSitesMembershipInformation().assertThat().entriesListIsEmpty(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - restClient.assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "test")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify if get site membership information request returns status code 200 for valid maxItems parameter") - public void getSiteMembershipInformationRequestReturns200ForValidMaxItemsParameter() throws Exception - { - restClient.authenticateUser(userModel).withParams("maxItems=5").withCoreAPI().usingAuthUser().getSitesMembershipInformation().assertThat() - .entriesListIsNotEmpty().getPagination().assertThat().field("maxItems").is("5"); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify if get site membership information request returns status code 400 when invalid skipCount parameter is used") - public void getSiteMembershipInformationRequestReturns400ForInvalidSkipCountParameter() throws Exception - { - restClient.authenticateUser(userModel).withParams("skipCount=-1").withCoreAPI().usingAuthUser().getSitesMembershipInformation().assertThat() - .entriesListIsEmpty(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - restClient.assertLastError().containsSummary(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT); - - restClient.withParams("skipCount=test").withCoreAPI().usingAuthUser().getSitesMembershipInformation().assertThat().entriesListIsEmpty(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - restClient.assertLastError().containsErrorKey(String.format(RestErrorModel.INVALID_SKIPCOUNT, "test")) - .containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "test")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify if get site membership information request returns status code 200 for valid skipCount parameter") - public void getSiteMembershipInformationRequestReturns200ForValidSkipCountParameter() throws Exception - { - restClient.authenticateUser(userModel).withParams("skipCount=1").withCoreAPI().usingAuthUser().getSitesMembershipInformation().assertThat() - .entriesListIsNotEmpty().getPagination().assertThat().field("skipCount").is("1"); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site manager is able to retrieve public sites") - public void siteManagerCheckThatPublicSitesAreRetrieved() throws Exception - { - restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().getSitesMembershipInformation().assertThat() - .entriesListContains("id", publicSiteModel.getId()); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site manager is able to retrieve moderated sites") - public void siteManagerCheckThatModeratedSitesAreRetrieved() throws Exception - { - restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().getSitesMembershipInformation().assertThat() - .entriesListContains("id", moderatedSiteModel.getId()); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site manager is able to retrieve private sites") - public void siteManagerCheckThatPrivateSitesAreRetrieved() throws Exception - { - restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().getSitesMembershipInformation().assertThat() - .entriesListContains("id", privateSiteModel.getId()); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site member is able to leave site") - public void siteMemberIsAbleToLeaveSite() throws Exception - { - restClient.authenticateUser(leaveSiteUserModel).withCoreAPI().usingAuthUser().deleteSiteMember(publicSiteModel); - restClient.authenticateUser(leaveSiteUserModel).withCoreAPI().usingAuthUser().getSitesMembershipInformation().assertThat().entriesListIsEmpty(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSitesMembershipInformationFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSitesMembershipInformationFullTests.java deleted file mode 100644 index 26278e8f7..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSitesMembershipInformationFullTests.java +++ /dev/null @@ -1,205 +0,0 @@ -package org.alfresco.service.search.rest.people; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestSiteMembershipModelsCollection; -import org.alfresco.rest.model.RestTaskModel; -import org.alfresco.utility.constants.UserRole; -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 Cristina Axinte - * - */ -public class GetSitesMembershipInformationFullTests extends RestTest -{ - private SiteModel publicSiteModel; - private SiteModel moderatedSiteModel; - private SiteModel privateSiteModel; - private SiteModel anotherUserSite; - private UserModel userModel, adminUser, anotherUserModel; - private RestSiteMembershipModelsCollection sitesMembershipInformation; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws DataPreparationException - { - adminUser = dataUser.getAdminUser(); - anotherUserSite = dataSite.usingUser(adminUser).createPublicRandomSite(); - userModel = dataUser.createRandomTestUser(); - anotherUserModel = dataUser.createRandomTestUser(); - publicSiteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); - dataUser.addUserToSite(userModel, publicSiteModel, UserRole.SiteCollaborator); - moderatedSiteModel = dataSite.usingUser(adminUser).createModeratedRandomSite(); - dataUser.addUserToSite(userModel, moderatedSiteModel, UserRole.SiteConsumer); - privateSiteModel = dataSite.usingUser(userModel).createPrivateRandomSite(); - dataUser.addUserToSite(anotherUserModel, anotherUserSite, UserRole.SiteCollaborator); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify if get site membership information request returns status code 200 for valid properties parameter") - public void getSiteMembershipInformationUsingPropertiesParameter() throws Exception - { - sitesMembershipInformation = restClient.authenticateUser(userModel).withParams("properties=id").withCoreAPI().usingAuthUser().getSitesMembershipInformation(); - restClient.assertStatusCodeIs(HttpStatus.OK); - sitesMembershipInformation.assertThat().entriesListIsNotEmpty().getPagination().assertThat().field("count").is("3"); - sitesMembershipInformation.assertThat().entriesListContains("id", publicSiteModel.getId()) - .and().entriesListContains("id", moderatedSiteModel.getId()) - .and().entriesListContains("id", privateSiteModel.getId()) - .and().entriesListDoesNotContain("site") - .and().entriesListDoesNotContain("role") - .and().entriesListDoesNotContain("guid"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify if get site membership information request returns status code 200 for order ASC by parameter") - public void getSiteMembershipInformationUsingOrderAscByParameter() throws Exception - { - sitesMembershipInformation = restClient.authenticateUser(userModel).withParams("orderBy=id ASC").withCoreAPI().usingAuthUser().getSitesMembershipInformation(); - restClient.assertStatusCodeIs(HttpStatus.OK); - sitesMembershipInformation.assertThat().entriesListIsNotEmpty().getPagination().assertThat().field("count").is("3"); - sitesMembershipInformation.assertThat().entriesListIsSortedAscBy("id"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify if get site membership information request returns status code 200 for order DESC by parameter") - public void getSiteMembershipInformationUsingOrderDescByParameter() throws Exception - { - sitesMembershipInformation = restClient.authenticateUser(userModel).withParams("orderBy=id Desc").withCoreAPI().usingAuthUser().getSitesMembershipInformation(); - restClient.assertStatusCodeIs(HttpStatus.OK); - sitesMembershipInformation.assertThat().entriesListIsNotEmpty().getPagination().assertThat().field("count").is("3"); - sitesMembershipInformation.assertThat().entriesListIsSortedDescBy("id"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify if get site membership information request returns status code 200 for order by role parameter") - public void getSiteMembershipInformationUsingOrderByRoleParameter() throws Exception - { - sitesMembershipInformation = restClient.authenticateUser(userModel).withParams("orderBy=role").withCoreAPI().usingAuthUser().getSitesMembershipInformation(); - restClient.assertStatusCodeIs(HttpStatus.OK); - sitesMembershipInformation.assertThat().entriesListIsNotEmpty().getPagination().assertThat().field("count").is("3"); - sitesMembershipInformation.assertThat().entriesListIsSortedAscBy("role"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify if user gets site membership information of another user successfully") - public void userCanGetSiteMembershipInformationOfAnotherUser() throws Exception - { - sitesMembershipInformation = restClient.authenticateUser(userModel).withCoreAPI().usingUser(anotherUserModel).getSitesMembershipInformation(); - restClient.assertStatusCodeIs(HttpStatus.OK); - sitesMembershipInformation.assertThat().entriesListIsNotEmpty().getPagination().assertThat().field("count").is("1"); - sitesMembershipInformation.getEntries().get(0).onModel() - .assertThat().field("site.visibility").is(anotherUserSite.getVisibility().toString()) - .and().field("site.guid").is(anotherUserSite.getGuid()) - .and().field("site.description").is(anotherUserSite.getDescription()) - .and().field("site.id").is(anotherUserSite.getId()) - .and().field("site.preset").is("site-dashboard") - .and().field("site.title").is(anotherUserSite.getTitle()) - .and().field("id").is(anotherUserSite.getId()) - .and().field("guid").is(anotherUserSite.getGuid()) - .and().field("role").is(UserRole.SiteCollaborator.toString()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify if get site membership information request returns status code 200 for relations parameter") - public void getSiteMembershipInformationUsingRelationsParameter() throws Exception - { - sitesMembershipInformation = restClient.authenticateUser(userModel).withParams("relations=site-membership-requests").withCoreAPI().usingAuthUser().getSitesMembershipInformation(); - restClient.assertStatusCodeIs(HttpStatus.OK); - sitesMembershipInformation.assertThat().entriesListIsNotEmpty().getPagination().assertThat().field("count").is("3"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify get site membership information request when a site membership request is rejected") - public void getSiteMembershipInformationWhenASiteRequestIsRejected() throws Exception - { - UserModel userWithRequests = dataUser.createRandomTestUser(); - - restClient.authenticateUser(userWithRequests).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSiteModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - sitesMembershipInformation = restClient.authenticateUser(adminUser).withCoreAPI().usingUser(userWithRequests).getSitesMembershipInformation(); - restClient.assertStatusCodeIs(HttpStatus.OK); - sitesMembershipInformation.assertThat().entriesListIsEmpty() - .and().paginationField("count").is("0"); - - RestTaskModel taskModel = restClient.authenticateUser(userWithRequests).withWorkflowAPI().getTasks().getTaskModelByDescription(moderatedSiteModel); - workflow.approveSiteMembershipRequest(adminUser.getUsername(), adminUser.getPassword(), taskModel.getId(), false, "Rejected"); - - sitesMembershipInformation = restClient.authenticateUser(adminUser).withCoreAPI().usingUser(userWithRequests).getSitesMembershipInformation(); - restClient.assertStatusCodeIs(HttpStatus.OK); - sitesMembershipInformation.assertThat().entriesListIsEmpty() - .and().paginationField("count").is("0"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify get site membership information request when a site membership request is approved") - public void getSiteMembershipInformationWhenASiteRequestIsAppropved() throws Exception - { - UserModel userWithRequests = dataUser.createRandomTestUser(); - - restClient.authenticateUser(userWithRequests).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSiteModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - sitesMembershipInformation = restClient.authenticateUser(adminUser).withCoreAPI().usingUser(userWithRequests).getSitesMembershipInformation(); - restClient.assertStatusCodeIs(HttpStatus.OK); - sitesMembershipInformation.assertThat().entriesListIsEmpty() - .and().paginationField("count").is("0"); - - RestTaskModel taskModel = restClient.authenticateUser(userWithRequests).withWorkflowAPI().getTasks().getTaskModelByDescription(moderatedSiteModel); - workflow.approveSiteMembershipRequest(adminUser.getUsername(), adminUser.getPassword(), taskModel.getId(), true, "Approve"); - - sitesMembershipInformation = restClient.authenticateUser(adminUser).withCoreAPI().usingUser(userWithRequests).getSitesMembershipInformation(); - restClient.assertStatusCodeIs(HttpStatus.OK); - sitesMembershipInformation.assertThat().entriesListIsNotEmpty() - .and().entriesListContains("role", UserRole.SiteConsumer.toString()) - .and().entriesListContains("guid", moderatedSiteModel.getGuid()) - .and().entriesListContains("id", moderatedSiteModel.getId()) - .and().paginationField("count").is("1"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify if get site membership information request returns status code 200 for valid maxItems parameter") - public void getSiteMembershipInformationUsingMaxItemsParameter() throws Exception - { - sitesMembershipInformation = restClient.authenticateUser(userModel).withParams("maxItems=2").withCoreAPI().usingAuthUser().getSitesMembershipInformation(); - restClient.assertStatusCodeIs(HttpStatus.OK); - sitesMembershipInformation.assertThat().entriesListCountIs(2) - .getPagination().assertThat().field("count").is("2") - .and().field("hasMoreItems").is("true") - .and().field("totalItems").is("3") - .and().field("skipCount").is("0") - .and().field("maxItems").is("2"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify if get site membership information request returns status code 200 for valid skipCount parameter") - public void getSiteMembershipInformationUsingSkipCountParameter() throws Exception - { - sitesMembershipInformation = restClient.authenticateUser(userModel).withParams("skipCount=2").withCoreAPI().usingAuthUser().getSitesMembershipInformation(); - restClient.assertStatusCodeIs(HttpStatus.OK); - sitesMembershipInformation.assertThat().entriesListCountIs(1) - .getPagination().assertThat().field("count").is("1") - .and().field("hasMoreItems").is("false") - .and().field("totalItems").is("3") - .and().field("skipCount").is("2") - .and().field("maxItems").is("100"); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSitesMembershipInformationSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSitesMembershipInformationSanityTests.java deleted file mode 100644 index 53b9c935f..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSitesMembershipInformationSanityTests.java +++ /dev/null @@ -1,89 +0,0 @@ -package org.alfresco.service.search.rest.people; - -import org.alfresco.service.search.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; - -public class GetSitesMembershipInformationSanityTests extends RestTest -{ - private SiteModel siteModel; - private UserModel adminUser; - private ListUserWithRoles usersWithRoles; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws DataPreparationException - { - adminUser = dataUser.getAdminUser(); - siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site manager is able to retrieve sites membership information of another user") - public void siteManagerIsAbleToRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingUser(adminUser).getSitesMembershipInformation() - .assertThat().entriesListIsNotEmpty().and().paginationExist().and().paginationField("count").isNot("0"); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site collaborator is able to retrieve sites membership information of another user") - public void siteCollaboratorIsAbleToRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingUser(adminUser) - .getSitesMembershipInformation().assertThat().entriesListIsNotEmpty().and().paginationExist().and().paginationField("count").isNot("0"); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site contributor is able to retrieve sites membership information of another user") - public void siteContributorIsAbleToRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingUser(adminUser) - .getSitesMembershipInformation().assertThat().entriesListIsNotEmpty().and().paginationExist().and().paginationField("count").isNot("0"); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site consumer is able to retrieve sites membership information of another user") - public void siteConsumerIsAbleToRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingUser(adminUser) - .getSitesMembershipInformation().assertThat().entriesListIsNotEmpty().and().paginationExist().and().paginationField("count").isNot("0"); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify admin is able to retrieve sites membership information of another user") - public void siteAdminIsAbleToRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUser).withCoreAPI().usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).getSitesMembershipInformation() - .assertThat().entriesListIsNotEmpty().and().paginationExist().and().paginationField("count").isNot("0"); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify that unauthenticated user is not able to retrieve sites membership information") -// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void unauthenticatedUserCannotRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception - { - UserModel inexistentUser = new UserModel("inexistent user", "wrong password"); - restClient.authenticateUser(inexistentUser).withCoreAPI().usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .getSitesMembershipInformation(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } -} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/activities/GetPeopleActivitiesCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/activities/GetPeopleActivitiesCoreTests.java deleted file mode 100644 index af25befea..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/activities/GetPeopleActivitiesCoreTests.java +++ /dev/null @@ -1,126 +0,0 @@ -package org.alfresco.service.search.rest.people.activities; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestActivityModelsCollection; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * - * @author Cristina Axinte - * - */ -public class GetPeopleActivitiesCoreTests extends RestTest -{ - UserModel userModel, adminUser, managerUser; - SiteModel siteModel1, siteModel2; - FileModel fileInSite1, fileInSite2; - FolderModel folderInSite2; - private RestActivityModelsCollection restActivityModelsCollection; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userModel = dataUser.createRandomTestUser(); - siteModel1 = dataSite.usingUser(userModel).createPublicRandomSite(); - fileInSite1 = dataContent.usingUser(userModel).usingSite(siteModel1).createContent(DocumentType.TEXT_PLAIN); - - siteModel2 = dataSite.usingUser(userModel).createPublicRandomSite(); - folderInSite2 = dataContent.usingUser(userModel).usingSite(siteModel2).createFolder(); - fileInSite2 = dataContent.usingAdmin().usingSite(siteModel2).createContent(DocumentType.TEXT_PLAIN); - - managerUser = dataUser.createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel2, UserRole.SiteManager); - - // only once the activity list is checked with retry in order not to wait the entire list in each test - restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingMe().getPersonActivitiesUntilEntriesCountIs(4); - restClient.assertStatusCodeIs(HttpStatus.OK); - restActivityModelsCollection.assertThat().paginationField("count").is("4"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot get activities for inexistent user with Rest API and response is 404") - public void userCannotGetPeopleActivitiesForInexistentPersonId() throws Exception - { - UserModel inexistentUserName = new UserModel("inexistent", "password"); - - restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingUser(inexistentUserName).getPersonActivities(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, inexistentUserName.getUsername())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its activities for inexistent siteId with Rest API and response is 404") - public void userGetItsPeopleActivitiesForInexistentSite() throws Exception - { - restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingUser(userModel).usingParams(String.format("siteId=inexistent")).getPersonActivities(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "inexistent")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities with invald skipCount parameter with Rest API and response is 400") - public void userGetPeopleActivitiesUsingInvalidSkipCountParameter() throws Exception - { - restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingMe().usingParams("skipCount=-1").getPersonActivities(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsErrorKey(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT) - .containsSummary(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities with invalid maxItems parameter with Rest API and response is 400") - public void userGetPeopleActivitiesUsingInvalidMaxItemsParameter() throws Exception - { - restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingMe().usingParams("maxItems=0").getPersonActivities(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsErrorKey(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) - .containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities using invalid value for parameter 'who'with Rest API and response is 400") - public void userGetsPeopleActivitiesUsingInvalidValueForWhoParameter() throws Exception - { - restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingUser(userModel).usingParams("who=mee").getPersonActivities(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsErrorKey(RestErrorModel.INVALID_PARAMETER_WHO) - .containsSummary(RestErrorModel.INVALID_PARAMETER_WHO) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities successfully using parameter 'who' with 'others' value with Rest API") - public void userGetsPeopleActivitiesUsingOthersForWhoParameter() throws Exception - { - restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingUser(userModel).usingParams("who=others").getPersonActivities(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restActivityModelsCollection.assertThat().paginationField("count").is("2"); - restActivityModelsCollection.assertThat().entriesListDoesNotContain("postPersonId", userModel.getUsername().toLowerCase()) - .and().entriesListContains("postPersonId", adminUser.getUsername().toLowerCase()) - .and().entriesListContains("postPersonId", managerUser.getUsername().toLowerCase()); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/activities/GetPeopleActivitiesFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/activities/GetPeopleActivitiesFullTests.java deleted file mode 100644 index 6e31e1b6a..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/activities/GetPeopleActivitiesFullTests.java +++ /dev/null @@ -1,184 +0,0 @@ -package org.alfresco.service.search.rest.people.activities; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestActivityModel; -import org.alfresco.rest.model.RestActivityModelsCollection; -import org.alfresco.rest.model.RestActivitySummaryModel; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -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 Cristina Axinte - * - */ -public class GetPeopleActivitiesFullTests extends RestTest -{ - UserModel userModel, adminUser, managerUser; - SiteModel siteModel1, siteModel2; - FileModel fileInSite1, fileInSite2; - FolderModel folderInSite2; - private RestActivityModelsCollection restActivityModelsCollection; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userModel = dataUser.createRandomTestUser(); - siteModel1 = dataSite.usingUser(userModel).createPublicRandomSite(); - fileInSite1 = dataContent.usingUser(userModel).usingSite(siteModel1).createContent(DocumentType.TEXT_PLAIN); - - siteModel2 = dataSite.usingUser(userModel).createPublicRandomSite(); - folderInSite2 = dataContent.usingUser(userModel).usingSite(siteModel2).createFolder(); - fileInSite2 = dataContent.usingAdmin().usingSite(siteModel2).createContent(DocumentType.TEXT_PLAIN); - - managerUser = dataUser.createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel2, UserRole.SiteManager); - - // only once the activity list is checked with retry in order not to wait the entire list in each test - restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingMe().getPersonActivitiesUntilEntriesCountIs(4); - restClient.assertStatusCodeIs(HttpStatus.OK); - restActivityModelsCollection.assertThat().paginationField("count").is("4"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify activity summary from user gets activities response with Rest API") - public void userGetPeopleActivitiesWithActivitySummaryCheck() throws Exception - { - restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingMe().usingParams(String.format("siteId=%s", siteModel1.getId())).getPersonActivities(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restActivityModelsCollection.assertThat().paginationField("count").is("1"); - RestActivitySummaryModel summary = restActivityModelsCollection.getEntries().get(0).onModel().getActivitySummary(); - summary.assertThat().field("firstName").is(userModel.getUsername() + " FirstName") - .and().field("lastName").is("LN-" + userModel.getUsername()) - .and().field("title").is(fileInSite1.getName()) - .and().field("objectId").is(fileInSite1.getNodeRefWithoutVersion()); - } - - @Bug(id = "REPO-1911") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE,TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot get activities for empty user with Rest API and response is 400") - public void userCannotGetPeopleActivitiesForEmptyPersonId() throws Exception - { - UserModel emptyUserName = new UserModel("", "password"); - - restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingUser(emptyUserName).getPersonActivities(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .containsSummary(RestErrorModel.LOCAL_NAME_CONSISTANCE) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE,TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its activities for siteId specified in siteId parameter using me with Rest API and response is successful") - public void userGetItsPeopleActivitiesForASpecificSite() throws Exception - { - restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingUser(userModel).usingParams(String.format("siteId=%s", siteModel1.getId())).getPersonActivities(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restActivityModelsCollection.assertThat().paginationField("count").is("1"); - restActivityModelsCollection.assertThat().entriesListContains("siteId", siteModel1.getId()) - .and().entriesListDoesNotContain("siteId", siteModel2.getId()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities for user with no activities with Rest API and response is successful") - public void userGetPeopleActivitiesForUserWithNoActivities() throws Exception - { - UserModel userNoActivities = dataUser.createRandomTestUser(); - dataSite.usingUser(userNoActivities).createPublicRandomSite(); - - restActivityModelsCollection = restClient.authenticateUser(adminUser).withCoreAPI().usingUser(userNoActivities).getPersonActivities(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restActivityModelsCollection.assertThat().paginationField("count").is("0"); - restActivityModelsCollection.assertThat().entriesListIsEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot get activities for siteId that user doesn't have access to with Rest API and response is not found") - public void userGetPeopleActivitiesForASiteWithNoAccess() throws Exception - { - SiteModel siteNoAccess = dataSite.usingUser(managerUser).createPrivateRandomSite(); - - restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingUser(userModel).usingParams(String.format("siteId=%s", siteNoAccess.getId())).getPersonActivities(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - restClient.assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, siteNoAccess.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot get activities for another user with Rest API and response is permission denied") - public void userGetPeopleActivitiesForAnotherUser() throws Exception - { - restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingUser(managerUser).getPersonActivities(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - restClient.assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities with properties parameter applied with Rest API and response is successful") - public void userGetPeopleActivitiesUsingPropertiesParameter() throws Exception - { - restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingMe().usingParams("properties=postPersonId").getPersonActivities(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restActivityModelsCollection.assertThat().paginationField("count").is("4"); - restActivityModelsCollection.assertThat().entriesListContains("postPersonId", userModel.getUsername().toLowerCase()) - .and().entriesListContains("postPersonId", adminUser.getUsername().toLowerCase()) - .and().entriesListContains("postPersonId", managerUser.getUsername().toLowerCase()) - .and().entriesListDoesNotContain("postedAt") - .and().entriesListDoesNotContain("feedPersonId") - .and().entriesListDoesNotContain("siteId") - .and().entriesListDoesNotContain("activitySummary") - .and().entriesListDoesNotContain("id") - .and().entriesListDoesNotContain("activityType"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities with skipCount parameter applied with Rest API and response is successful") - public void userGetPeopleActivitiesUsingSkipCountParameter() throws Exception - { - restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingMe().getPersonActivities(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restActivityModelsCollection.assertThat().paginationField("count").is("4"); - RestActivityModel expectedRestActivity3 = restActivityModelsCollection.getEntries().get(2).onModel(); - RestActivityModel expectedRestActivity4 = restActivityModelsCollection.getEntries().get(3).onModel(); - - restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingMe().usingParams("skipCount=2").getPersonActivities(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restActivityModelsCollection.assertThat().paginationField("count").is("2"); - restActivityModelsCollection.getEntries().get(0).onModel().assertThat().field("postPersonId").is(expectedRestActivity3.getPostPersonId()) - .and().field("activityType").is(expectedRestActivity3.getActivityType()); - restActivityModelsCollection.getEntries().get(1).onModel().assertThat().field("postPersonId").is(expectedRestActivity4.getPostPersonId()) - .and().field("activityType").is(expectedRestActivity4.getActivityType()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities with maxItems parameter applied with Rest API and response is successful") - public void userGetPeopleActivitiesUsingMaxItemsParameter() throws Exception - { - restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingMe().getPersonActivities(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restActivityModelsCollection.assertThat().paginationField("count").is("4"); - RestActivityModel expectedRestActivity1 = restActivityModelsCollection.getEntries().get(0).onModel(); - RestActivityModel expectedRestActivity2 = restActivityModelsCollection.getEntries().get(1).onModel(); - - restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingMe().usingParams("maxItems=2").getPersonActivities(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restActivityModelsCollection.assertThat().paginationField("count").is("2"); - restActivityModelsCollection.getEntries().get(0).onModel().assertThat().field("postPersonId").is(expectedRestActivity1.getPostPersonId()) - .and().field("activityType").is(expectedRestActivity1.getActivityType()); - restActivityModelsCollection.getEntries().get(1).onModel().assertThat().field("postPersonId").is(expectedRestActivity2.getPostPersonId()) - .and().field("activityType").is(expectedRestActivity2.getActivityType()); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/activities/GetPeopleActivitiesSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/activities/GetPeopleActivitiesSanityTests.java deleted file mode 100644 index f31460a15..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/activities/GetPeopleActivitiesSanityTests.java +++ /dev/null @@ -1,111 +0,0 @@ -package org.alfresco.service.search.rest.people.activities; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestActivityModelsCollection; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser; -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 Cristina Axinte - * Tests for getActivities (/people/{personId}/activities) RestAPI call - */ - -public class GetPeopleActivitiesSanityTests extends RestTest -{ - UserModel userModel, unauthenticatedUser; - SiteModel siteModel; - private DataUser.ListUserWithRoles usersWithRoles; - private RestActivityModelsCollection restActivityModelsCollection; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - unauthenticatedUser = dataUser.usingAdmin().createRandomTestUser(); - unauthenticatedUser.setPassword("newpassword"); - - // only once the activity list is checked with retry in order not to wait the entire list in each test - restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().getPersonActivitiesUntilEntriesCountIs(5); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.SANITY, description = "Verify manager user gets its activities with Rest API and response is successful") - public void managerUserShouldGetPeopleActivitiesList() throws Exception - { - UserModel managerUser = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); - dataContent.usingUser(managerUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - - restActivityModelsCollection = restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().getPersonActivities(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restActivityModelsCollection.assertThat().entriesListIsNotEmpty().and().entriesListContains("siteId", siteModel.getId()).and().paginationExist(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.SANITY, description = "Verify collaborator user gets its activities with Rest API and response is successful") - public void collaboratorUserShouldGetPeopleActivitiesList() throws Exception - { - UserModel collaboratorUser = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); - dataContent.usingUser(collaboratorUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - - restActivityModelsCollection = restClient.authenticateUser(collaboratorUser).withCoreAPI().usingAuthUser().getPersonActivities(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restActivityModelsCollection.assertThat().entriesListIsNotEmpty().and().entriesListContains("siteId", siteModel.getId()).and().paginationExist(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.ACTIVITIES }, executionType = ExecutionType.SANITY, description = "Verify contributor user gets its activities with Rest API and response is successful") - public void contributorUserShouldGetPeopleActivitiesList() throws Exception - { - UserModel contributorUser = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); - dataContent.usingUser(contributorUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - - restActivityModelsCollection = restClient.authenticateUser(contributorUser).withCoreAPI().usingAuthUser().getPersonActivities(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restActivityModelsCollection.assertThat().entriesListIsNotEmpty().and().entriesListContains("siteId", siteModel.getId()).and().paginationExist(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.ACTIVITIES }, executionType = ExecutionType.SANITY, description = "Verify consumer user gets its activities with Rest API and response is successful") - public void consumerUserShouldGetPeopleActivitiesList() throws Exception - { - UserModel consumerUser = usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer); - - restActivityModelsCollection = restClient.authenticateUser(consumerUser).withCoreAPI().usingAuthUser().getPersonActivities(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restActivityModelsCollection.assertThat().entriesListIsNotEmpty().and().entriesListContains("siteId", siteModel.getId()).and().paginationExist(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.ACTIVITIES }, executionType = ExecutionType.SANITY, description = "Verify admin user gets another user activities with Rest API and response is successful") - public void adminUserShouldGetPeopleActivitiesList() throws Exception - { - restActivityModelsCollection = restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingUser(userModel).getPersonActivities(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restActivityModelsCollection.assertThat().entriesListIsNotEmpty().and().entriesListContains("siteId", siteModel.getId()).and().paginationExist(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.ACTIVITIES }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is NOT Authorized to gets another user activities with Rest API") - public void unauthenticatedUserShouldNotGetPeopleActivitiesList() throws Exception - { - restClient.authenticateUser(unauthenticatedUser).withCoreAPI().usingUser(userModel).getPersonActivities(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError().containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferenceCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferenceCoreTests.java deleted file mode 100644 index 7dd7ad1cf..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferenceCoreTests.java +++ /dev/null @@ -1,78 +0,0 @@ -package org.alfresco.service.search.rest.people.preferences; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.utility.constants.PreferenceName; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class GetPeoplePreferenceCoreTests extends RestTest -{ - UserModel userModel; - SiteModel siteModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - dataSite.usingUser(userModel).usingSite(siteModel).addSiteToFavorites(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user is Forbidden to get a specific preference for another user with Rest API and response is 403") - public void userDoesNotHaveAccessToFavoriteSitesOfAnotherUser() throws Exception - { - UserModel secondUser = dataUser.createRandomTestUser(); - restClient.authenticateUser(secondUser).withCoreAPI().usingUser(userModel) - .getPersonPreferenceInformation(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - restClient.assertLastError().containsSummary("Permission was denied"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify manager fails to get a specific preference for an invalid user with Rest API and response is 404") - public void statusNotFoundIsReturnedForAPersonIDThatDoesNotExist() throws Exception - { - restClient.authenticateUser(userModel).withCoreAPI().usingUser(new UserModel("invalidPersonID", "password")) - .getPersonPreferenceInformation(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidPersonID")) - .statusCodeIs(HttpStatus.NOT_FOUND) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify manager fails to get a specific preference for an invalid preference with Rest API and response is 404") - public void statusNotFoundIsReturnedForAPreferenceNameThatDoesNotExist() throws Exception - { - restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().getPersonPreferenceInformation("invalidPreferenceName"); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - restClient.assertLastError().containsSummary( - String.format("The relationship resource was not found for the" + " entity with id: %s and a relationship id of invalidPreferenceName", - userModel.getUsername())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify manager fails to get a specific preference for removed preference with Rest API and response is 404") - public void statusNotFoundIsReturnedForAPreferenceNameThatHasBeenRemoved() throws Exception - { - SiteModel preferenceSite = dataSite.usingUser(userModel).createPublicRandomSite(); - dataSite.usingUser(userModel).usingSite(preferenceSite).addSiteToFavorites(); - dataSite.usingUser(userModel).usingSite(preferenceSite).removeSiteFromFavorites(); - restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser() - .getPersonPreferenceInformation(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), preferenceSite.getId())); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - restClient.assertLastError().containsSummary( - String.format("The relationship resource was not found for the" + " entity with id: %s and a relationship id of %s", userModel.getUsername(), - String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), preferenceSite.getId()))); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferenceFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferenceFullTests.java deleted file mode 100644 index ee07f650a..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferenceFullTests.java +++ /dev/null @@ -1,194 +0,0 @@ -package org.alfresco.service.search.rest.people.preferences; - -import java.nio.file.Paths; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestPreferenceModel; -import org.alfresco.utility.Utility; -import org.alfresco.utility.constants.PreferenceName; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FileType; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class GetPeoplePreferenceFullTests extends RestTest -{ - private UserModel userModel; - private SiteModel siteModel; - private RestPreferenceModel restPreferenceModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - dataSite.usingUser(userModel).usingSite(siteModel).addSiteToFavorites(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, - description = "Check that properties parameter is applied") - public void propertiesParameterIsAppliedWhenRetrievingPreference() throws Exception - { - restPreferenceModel = restClient.authenticateUser(userModel).withParams("properties=id").withCoreAPI().usingUser(userModel) - .getPersonPreferenceInformation(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())); - restClient.assertStatusCodeIs(HttpStatus.OK); - restPreferenceModel.assertThat().field("id").is(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())) - .and().field("value").isNull(); - - restPreferenceModel = restClient.authenticateUser(userModel).withParams("properties=id,value").withCoreAPI().usingUser(userModel) - .getPersonPreferenceInformation(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())); - restClient.assertStatusCodeIs(HttpStatus.OK); - restPreferenceModel.assertThat().field("id").is(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())) - .and().field("value").is("true"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, - description = "Validate ID element in get site preference response") - public void validateIdElementInGetSitePreferenceResponse() throws Exception - { - restPreferenceModel = restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser() - .getPersonPreferenceInformation(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())); - restPreferenceModel.assertThat().field("id").is(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())) - .and().field("value").is("true"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, - description = "Validate ID element in get folder preference response") - public void validateIdElementInGetFolderPreferenceResponse() throws Exception - { - FolderModel folderFavorite = new FolderModel("favoriteFolder"); - folderFavorite = dataContent.usingSite(siteModel).createFolder(folderFavorite); - dataContent.getContentActions().setFolderAsFavorite(userModel.getUsername(), userModel.getPassword(), siteModel.getId(), folderFavorite.getName()); - - restPreferenceModel = restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser() - .getPersonPreferenceInformation(PreferenceName.FOLDERS_FAVORITES_PREFIX.toString()); - restPreferenceModel.assertThat().field("id").is(PreferenceName.FOLDERS_FAVORITES_PREFIX) - .and().field("value").is(Utility.removeLastSlash(Utility.buildPath("workspace://SpacesStore", folderFavorite.getNodeRef()))); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, - description = "Validate ID element in get file preference response") - public void validateIdElementInGetFilePreferenceResponse() throws Exception - { - FileModel fileFavorite = new FileModel("favoriteFile", FileType.TEXT_PLAIN); - fileFavorite = dataContent.usingSite(siteModel).createContent(fileFavorite); - dataContent.getContentActions().setFileAsFavorite(userModel.getUsername(), userModel.getPassword(), siteModel.getId(), String.format("%s.%s", fileFavorite.getName(), fileFavorite.getFileType().extention)); - - restPreferenceModel = restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser() - .getPersonPreferenceInformation(PreferenceName.DOCUMENTS_FAVORITES_PREFIX.toString()); - restPreferenceModel.assertThat().field("id").is(PreferenceName.DOCUMENTS_FAVORITES_PREFIX) - .and().field("value").is(Utility.removeLastSlash(Utility.buildPath("workspace://SpacesStore", fileFavorite.getNodeRefWithoutVersion()))); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, - description = "Get preference of an user that has no preferences") - public void getPreferenceForUserWithoutPreferences() throws Exception - { - UserModel newUser = dataUser.createRandomTestUser(); - - restPreferenceModel = restClient.authenticateUser(newUser).withCoreAPI().usingAuthUser() - .getPersonPreferenceInformation(PreferenceName.DOCUMENTS_FAVORITES_PREFIX.toString()); - restClient.assertLastError().containsSummary( - String.format("The relationship resource was not found for the" + " entity with id: %s and a relationship id of %s", newUser.getUsername(), - PreferenceName.DOCUMENTS_FAVORITES_PREFIX.toString())); - - restPreferenceModel = restClient.authenticateUser(newUser).withCoreAPI().usingAuthUser() - .getPersonPreferenceInformation(PreferenceName.FOLDERS_FAVORITES_PREFIX.toString()); - restClient.assertLastError().containsSummary( - String.format("The relationship resource was not found for the" + " entity with id: %s and a relationship id of %s", newUser.getUsername(), - PreferenceName.FOLDERS_FAVORITES_PREFIX.toString())); - - restPreferenceModel = restClient.authenticateUser(newUser).withCoreAPI().usingAuthUser() - .getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX.toString()); - restClient.assertLastError().containsSummary( - String.format("The relationship resource was not found for the" + " entity with id: %s and a relationship id of %s", newUser.getUsername(), - PreferenceName.SITES_FAVORITES_PREFIX.toString())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, - description = "Change one preference for an user then perform get call") - @Bug(id = "REPO-1922") - public void changePreferenceThenPerformGetPreferenceCall() throws Exception - { - UserModel newUser = dataUser.createRandomTestUser(); - SiteModel site = dataSite.usingUser(newUser).createPublicRandomSite(); - - dataSite.usingUser(newUser).usingSite(site).addSiteToFavorites(); - - FileModel fileFavorite = new FileModel("favoriteFile", FileType.TEXT_PLAIN); - fileFavorite = dataContent.usingSite(site).createContent(fileFavorite); - dataContent.getContentActions().setFileAsFavorite(newUser.getUsername(), newUser.getPassword(), site.getId(), String.format("%s.%s", fileFavorite.getName(), fileFavorite.getFileType().extention)); - - FolderModel folderFavorite = new FolderModel("favoriteFolder"); - folderFavorite = dataContent.usingSite(site).createFolder(folderFavorite); - dataContent.getContentActions().setFolderAsFavorite(newUser.getUsername(), newUser.getPassword(), site.getId(), folderFavorite.getName()); - - dataSite.usingUser(newUser).usingSite(site).removeSiteFromFavorites(); - dataContent.getContentActions().removeFavorite(newUser.getUsername(), newUser.getPassword(), site.getId(), folderFavorite.getName()); - dataContent.getContentActions().removeFavorite(newUser.getUsername(), newUser.getPassword(), site.getId(), Paths.get(fileFavorite.getCmisLocation()).getFileName().toString()); - - restPreferenceModel = restClient.authenticateUser(newUser).withCoreAPI().usingAuthUser() - .getPersonPreferenceInformation(PreferenceName.FOLDERS_FAVORITES_PREFIX.toString()); - restClient.assertLastError().containsSummary( - String.format("The relationship resource was not found for the" + " entity with id: %s and a relationship id of %s", newUser.getUsername(), - PreferenceName.FOLDERS_FAVORITES_PREFIX.toString())); - - restPreferenceModel = restClient.authenticateUser(newUser).withCoreAPI().usingAuthUser() - .getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX.toString()); - restClient.assertLastError().containsSummary( - String.format("The relationship resource was not found for the" + " entity with id: %s and a relationship id of %s", newUser.getUsername(), - PreferenceName.SITES_FAVORITES_PREFIX.toString())); - - restPreferenceModel = restClient.authenticateUser(newUser).withCoreAPI().usingAuthUser() - .getPersonPreferenceInformation(PreferenceName.DOCUMENTS_FAVORITES_PREFIX.toString()); - restClient.assertLastError().containsSummary( - String.format("The relationship resource was not found for the" + " entity with id: %s and a relationship id of %s", newUser.getUsername(), - PreferenceName.DOCUMENTS_FAVORITES_PREFIX.toString())); - - restPreferenceModel = restClient.authenticateUser(newUser).withCoreAPI().usingAuthUser() - .getPersonPreferenceInformation(PreferenceName.FOLDERS_FAVORITES_PREFIX.toString()); - restClient.assertLastError().containsSummary( - String.format("The relationship resource was not found for the" + " entity with id: %s and a relationship id of %s", newUser.getUsername(), - PreferenceName.FOLDERS_FAVORITES_PREFIX.toString())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, - description = "Verify admin is able to get preference of another user") - public void adminIsAbleToGetOtherUserPreference() throws Exception - { - restPreferenceModel = restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingUser(userModel) - .getPersonPreferenceInformation(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())); - restClient.assertStatusCodeIs(HttpStatus.OK); - restPreferenceModel.assertThat().field("id").is(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())).and().field("value").is("true"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, - description = "Verify regular user is not able to get preference of admin user") - public void regularUserIsNotAbleToGetAdminPreference() throws Exception - { - SiteModel newSite = dataSite.usingUser(dataUser.getAdminUser()).createPublicRandomSite(); - dataSite.usingUser(dataUser.getAdminUser()).usingSite(newSite).addSiteToFavorites(); - - restClient.authenticateUser(userModel).withCoreAPI().usingUser(dataUser.getAdminUser()) - .getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + newSite.getId()); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - restClient.assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } -} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferenceSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferenceSanityTests.java deleted file mode 100644 index bc668d8cd..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferenceSanityTests.java +++ /dev/null @@ -1,120 +0,0 @@ -package org.alfresco.service.search.rest.people.preferences; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestPreferenceModel; -import org.alfresco.utility.constants.PreferenceName; -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.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Tests for Get a Peference (/people/{personId}/preferences/{preferenceName}) RestAPI call - * - * @author Cristina Axinte - */ - -public class GetPeoplePreferenceSanityTests extends RestTest -{ - UserModel userModel; - SiteModel siteModel; - private RestPreferenceModel restPreferenceModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify manager user gets a specific preference with Rest API and response is successful (200)") - public void managerUserGetsAPreferenceWithSuccess() throws Exception - { - UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); - dataSite.usingUser(managerUser).usingSite(siteModel).addSiteToFavorites(); - - restPreferenceModel = restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser() - .getPersonPreferenceInformation(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())); - restClient.assertStatusCodeIs(HttpStatus.OK); - restPreferenceModel.assertThat().field("id").is(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())).and().field("value").is("true"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify collaborator user gets a specific preference with Rest API and response is successful (200)") - public void collaboratorUserGetsAPreferenceWithSuccess() throws Exception - { - UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(collaboratorUser, siteModel, UserRole.SiteCollaborator); - dataSite.usingUser(collaboratorUser).usingSite(siteModel).addSiteToFavorites(); - - restPreferenceModel = restClient.authenticateUser(collaboratorUser).withCoreAPI().usingAuthUser() - .getPersonPreferenceInformation(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())); - restClient.assertStatusCodeIs(HttpStatus.OK); - restPreferenceModel.assertThat().field("id").is(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())).and().field("value").is("true"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify contributor user gets a specific preference with Rest API and response is successful (200)") - public void contributorUserGetsAPreferenceWithSuccess() throws Exception - { - UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(contributorUser, siteModel, UserRole.SiteContributor); - dataSite.usingUser(contributorUser).usingSite(siteModel).addSiteToFavorites(); - - restPreferenceModel = restClient.authenticateUser(contributorUser).withCoreAPI().usingAuthUser() - .getPersonPreferenceInformation(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())); - restClient.assertStatusCodeIs(HttpStatus.OK); - restPreferenceModel.assertThat().field("id").is(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())).and().field("value").is("true"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify consumer user gets a specific preference with Rest API and response is successful (200)") - public void consumerUserGetsAPreferenceWithSuccess() throws Exception - { - UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel, UserRole.SiteConsumer); - dataSite.usingUser(consumerUser).usingSite(siteModel).addSiteToFavorites(); - - restPreferenceModel = restClient.authenticateUser(consumerUser).withCoreAPI().usingAuthUser() - .getPersonPreferenceInformation(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(),siteModel.getId())); - restClient.assertStatusCodeIs(HttpStatus.OK); - restPreferenceModel.assertThat().field("id").is(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(),siteModel.getId())).and().field("value").is("true"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify admin user gets a specific preference with Rest API and response is successful (200)") - public void adminUserGetsAPreferenceWithSuccess() throws Exception - { - UserModel adminUser = dataUser.getAdminUser(); - dataSite.usingUser(adminUser).usingSite(siteModel).addSiteToFavorites(); - - restPreferenceModel = restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser() - .getPersonPreferenceInformation(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())); - restClient.assertStatusCodeIs(HttpStatus.OK); - restPreferenceModel.assertThat().field("id").is(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())).and().field("value").is("true"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized to get a specific preference with Rest API when authentication fails (401)") -// @Bug(id = "MNT-16904", description = "fails only on environment with tenants") - public void managerUserNotAuthorizedFailsToGetsAPreference() throws Exception - { - UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); - dataSite.usingUser(managerUser).usingSite(siteModel).addSiteToFavorites(); - managerUser.setPassword("newpassword"); - - restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser() - .getPersonPreferenceInformation(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferencesCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferencesCoreTests.java deleted file mode 100644 index ea1942fe5..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferencesCoreTests.java +++ /dev/null @@ -1,123 +0,0 @@ -package org.alfresco.service.search.rest.people.preferences; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestPreferenceModelsCollection; -import org.alfresco.utility.constants.PreferenceName; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * - * @author Cristina Axinte - * - */ -public class GetPeoplePreferencesCoreTests extends RestTest -{ - UserModel userModel, user1, user2, adminUser; - SiteModel siteModel; - FolderModel folderModel; - private RestPreferenceModelsCollection restPreferenceModelsCollection; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - - user1 = dataUser.createRandomTestUser(); - dataSite.usingUser(user1).usingSite(siteModel).addSiteToFavorites(); - dataContent.usingUser(user1).usingSite(siteModel).addFolderToFavorites(folderModel); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its preferences with invalid maxItems parameter with Rest API and response is 400") - public void userGetsPeoplePreferencesUsingInvalidMaxItemsParameter() throws Exception - { - restPreferenceModelsCollection = restClient.authenticateUser(user1).withCoreAPI().usingMe().usingParams("maxItems=0").getPersonPreferences(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsErrorKey(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) - .containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its preferences with skipCount parameter applied with Rest API and response is successful") - public void userGetsPeoplePreferencesUsingInvalidSkipCountParameter() throws Exception - { - restPreferenceModelsCollection = restClient.authenticateUser(user1).withCoreAPI().usingMe().usingParams("skipCount=-1").getPersonPreferences(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsErrorKey(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT) - .containsSummary(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user which doesn't have access to another user preferences fails to get its preferences with Rest API and response is permission denied") - public void userWithNoAccessToOtherUserPreferencesIsForbiddenToGetItsPreferences() throws Exception - { - UserModel noAccessUser = dataUser.createRandomTestUser(); - dataSite.usingUser(noAccessUser).usingSite(siteModel).addSiteToFavorites(); - - restPreferenceModelsCollection = restClient.authenticateUser(user1).withCoreAPI().usingUser(noAccessUser).getPersonPreferences(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - restClient.assertLastError().containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user fails to get preferences for inexistent personId with Rest API and response is 404") - public void userCannotGetPeoplePreferencesForInexistentPersonId() throws Exception - { - UserModel inexistentUserName = new UserModel("inexistent", "password"); - - restPreferenceModelsCollection = restClient.authenticateUser(user1).withCoreAPI().usingUser(inexistentUserName).getPersonPreferences(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - restClient.assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, inexistentUserName.getUsername())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user get preferences for a user with no preferences with Rest API and response is empty") - public void userGetsPeoplePreferencesForUserWithNoPreferences() throws Exception - { - UserModel userNoActivities = dataUser.createRandomTestUser(); - - restPreferenceModelsCollection = restClient.authenticateUser(adminUser).withCoreAPI().usingUser(userNoActivities).getPersonPreferences(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restPreferenceModelsCollection.assertThat().paginationField("count").is("0"); - restPreferenceModelsCollection.assertThat().entriesListIsEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user fails to get preferences for a removed preference with Rest API and response is 404") - public void userFailsToGetPeoplePreferencesIfPreferenceWasRemoved() throws Exception - { - SiteModel preferenceSite = dataSite.usingUser(user1).createPublicRandomSite(); - dataSite.usingUser(user1).usingSite(preferenceSite).addSiteToFavorites(); - restPreferenceModelsCollection = restClient.authenticateUser(user1).withCoreAPI().usingAuthUser().getPersonPreferences(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restPreferenceModelsCollection.assertThat().paginationField("count").is("6"); - - dataSite.usingUser(user1).usingSite(preferenceSite).removeSiteFromFavorites(); - restPreferenceModelsCollection = restClient.authenticateUser(user1).withCoreAPI().usingAuthUser().getPersonPreferences(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restPreferenceModelsCollection.assertThat().paginationField("count").is("5"); - restPreferenceModelsCollection.assertThat().entriesListDoesNotContain("id", String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), preferenceSite.getId())); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferencesFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferencesFullTests.java deleted file mode 100644 index f48d41a7b..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferencesFullTests.java +++ /dev/null @@ -1,114 +0,0 @@ -package org.alfresco.service.search.rest.people.preferences; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestPreferenceModelsCollection; -import org.alfresco.utility.constants.PreferenceName; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * - * @author Cristina Axinte - * - */ -public class GetPeoplePreferencesFullTests extends RestTest -{ - UserModel userModel, user1, user2, adminUser; - SiteModel siteModel; - FolderModel folderModel; - private RestPreferenceModelsCollection restPreferenceModelsCollection; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - - user1 = dataUser.createRandomTestUser(); - dataSite.usingUser(user1).usingSite(siteModel).addSiteToFavorites(); - dataContent.usingUser(user1).usingSite(siteModel).addFolderToFavorites(folderModel); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its preferences with skipCount parameter applied with Rest API and response is successful") - public void userGetsItsPeoplePreferencesUsingSkipCountParameter() throws Exception - { - restPreferenceModelsCollection = restClient.authenticateUser(user1).withCoreAPI().usingMe().usingParams("skipCount=2").getPersonPreferences(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restPreferenceModelsCollection.assertThat().paginationField("count").is("2"); - restPreferenceModelsCollection.assertThat().paginationField("skipCount").is("2"); - restPreferenceModelsCollection.assertThat().entriesListIsNotEmpty() - .and().entriesListDoesNotContain("id", String.format(PreferenceName.EXT_FOLDERS_FAVORITES_PREFIX.toString(), "workspace://SpacesStore/" + folderModel.getNodeRef())) - .and().entriesListDoesNotContain("id", String.format(PreferenceName.EXT_SITES_FAVORITES_PREFIX.toString(), siteModel.getId())) - .and().entriesListContains("id", PreferenceName.FOLDERS_FAVORITES_PREFIX.toString()) - .and().entriesListContains("value", "workspace://SpacesStore/" + folderModel.getNodeRef()) - .and().entriesListContains("id", String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())) - .and().entriesListContains("value", "true"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its preferences with maxItems parameter applied with Rest API and response is successful") - public void userGetsItsPeoplePreferencesUsingMaxItemsParameter() throws Exception - { - restPreferenceModelsCollection = restClient.authenticateUser(user1).withCoreAPI().usingMe().usingParams("maxItems=1").getPersonPreferences(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restPreferenceModelsCollection.assertThat().paginationField("count").is("1"); - restPreferenceModelsCollection.assertThat().paginationField("maxItems").is("1"); - restPreferenceModelsCollection.assertThat().entriesListIsNotEmpty() - .and().entriesListContains("id", String.format(PreferenceName.EXT_FOLDERS_FAVORITES_PREFIX.toString(), "workspace://SpacesStore/" + folderModel.getNodeRef())) - .and().entriesListDoesNotContain("id", String.format(PreferenceName.EXT_SITES_FAVORITES_PREFIX.toString(), siteModel.getId())) - .and().entriesListDoesNotContain("id", PreferenceName.FOLDERS_FAVORITES_PREFIX.toString()) - .and().entriesListDoesNotContain("value", "workspace://SpacesStore/" + folderModel.getNodeRef()) - .and().entriesListDoesNotContain("id", String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())) - .and().entriesListDoesNotContain("value", "true"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets admin preferences with Rest API and response is permission denied") - public void userIsForbiddenToGetAdminPreferences() throws Exception - { - restPreferenceModelsCollection = restClient.authenticateUser(user1).withCoreAPI().usingUser(adminUser).getPersonPreferences(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - restClient.assertLastError().containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its preferences with skipCount parameter higher then no of entries with Rest API and response is empty") - public void userGetsItsPeoplePreferencesUsingHighSkipCount() throws Exception - { - restPreferenceModelsCollection = restClient.authenticateUser(user1).withCoreAPI().usingMe().usingParams("skipCount=100").getPersonPreferences(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restPreferenceModelsCollection.assertThat().paginationField("count").is("0"); - restPreferenceModelsCollection.assertThat().paginationField("skipCount").is("100"); - restPreferenceModelsCollection.assertThat().entriesListIsEmpty(); - } - - @Bug(id = "REPO-1911") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot get preferences for empty user with Rest API and response is 400") - public void userGetsItsPeoplePreferencesForEmptyPersonId() throws Exception - { - UserModel emptyUserName = new UserModel("", "password"); - - restPreferenceModelsCollection = restClient.authenticateUser(user1).withCoreAPI().usingUser(emptyUserName).getPersonPreferences(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .containsSummary(RestErrorModel.LOCAL_NAME_CONSISTANCE) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferencesSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferencesSanityTests.java deleted file mode 100644 index 4b7e657a4..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferencesSanityTests.java +++ /dev/null @@ -1,121 +0,0 @@ -package org.alfresco.service.search.rest.people.preferences; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestPreferenceModelsCollection; -import org.alfresco.utility.constants.PreferenceName; -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.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Tests for Get Peferences (/people/{personId}/preferences) RestAPI call - * - * @author Cristina Axinte - */ - -public class GetPeoplePreferencesSanityTests extends RestTest -{ - UserModel userModel; - SiteModel siteModel; - private RestPreferenceModelsCollection restPreferenceModelsCollection; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify manager user gets its preferences with Rest API and response is successful (200)") - public void managerUserGetsPeoplePreferencesWithSuccess() throws Exception - { - UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); - dataSite.usingUser(managerUser).usingSite(siteModel).addSiteToFavorites(); - - restPreferenceModelsCollection = restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().getPersonPreferences(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restPreferenceModelsCollection.assertThat().entriesListIsNotEmpty().assertThat().paginationExist().and() - .entriesListContains("id", String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify collaborator user gets its preferences with Rest API and response is successful (200)") - public void collaboratorUserGetsPeoplePreferencesWithSuccess() throws Exception - { - UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(collaboratorUser, siteModel, UserRole.SiteCollaborator); - dataSite.usingUser(collaboratorUser).usingSite(siteModel).addSiteToFavorites(); - - restPreferenceModelsCollection = restClient.authenticateUser(collaboratorUser).withCoreAPI().usingAuthUser().getPersonPreferences(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restPreferenceModelsCollection.assertThat().entriesListIsNotEmpty().assertThat().paginationExist().and() - .entriesListContains("id", String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify contributor user gets its preferences with Rest API and response is successful (200)") - public void contributorUserGetsPeoplePreferencesWithSuccess() throws Exception - { - UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(contributorUser, siteModel, UserRole.SiteContributor); - dataSite.usingUser(contributorUser).usingSite(siteModel).addSiteToFavorites(); - - restPreferenceModelsCollection = restClient.authenticateUser(contributorUser).withCoreAPI().usingAuthUser().getPersonPreferences(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restPreferenceModelsCollection.assertThat().entriesListIsNotEmpty().assertThat().paginationExist().and() - .entriesListContains("id", String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify consumer user gets its preferences with Rest API and response is successful (200)") - public void consumerUserGetsPeoplePreferencesWithSuccess() throws Exception - { - UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel, UserRole.SiteConsumer); - dataSite.usingUser(consumerUser).usingSite(siteModel).addSiteToFavorites(); - - restPreferenceModelsCollection = restClient.authenticateUser(consumerUser).withCoreAPI().usingAuthUser().getPersonPreferences(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restPreferenceModelsCollection.assertThat().entriesListIsNotEmpty().assertThat().paginationExist().and() - .entriesListContains("id", String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify admin user gets another user preferences with Rest API and response is successful (200)") - public void adminUserGetsPeoplePreferencesWithSuccess() throws Exception - { - UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); - dataSite.usingUser(managerUser).usingSite(siteModel).addSiteToFavorites(); - UserModel adminUser = dataUser.getAdminUser(); - - restPreferenceModelsCollection = restClient.authenticateUser(adminUser).withCoreAPI().usingUser(managerUser).getPersonPreferences(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restPreferenceModelsCollection.assertThat().entriesListIsNotEmpty().assertThat().paginationExist().and() - .entriesListContains("id", String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized to gets its preferences with Rest API when authentication fails(401)") -// @Bug(id = "MNT-16904", description = "It fails only on environment with tenants") - public void managerUserGetsPeoplePreferencesIsNotAuthorized() throws Exception - { - UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); - dataSite.usingUser(managerUser).usingSite(siteModel).addSiteToFavorites(); - managerUser.setPassword("newpassword"); - - restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().getPersonPreferences(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/queries/QueriesTest.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/queries/QueriesTest.java deleted file mode 100644 index 5d83550eb..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/queries/QueriesTest.java +++ /dev/null @@ -1,178 +0,0 @@ -package org.alfresco.service.search.rest.queries; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestNodeModelsCollection; -import org.alfresco.rest.model.RestPersonModelsCollection; -import org.alfresco.rest.model.RestSiteModel; -import org.alfresco.rest.model.RestSiteModelsCollection; -import org.alfresco.utility.RetryOperation; -import org.alfresco.utility.Utility; -import org.alfresco.utility.model.ContentModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FileType; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.Test; - - -/** - * Handle requests on Queries - * - */ -public class QueriesTest extends RestTest -{ - @TestRail(section = { TestGroup.REST_API, - TestGroup.QUERIES }, executionType = ExecutionType.SANITY, description = "Check basic functionality of GET queries/sites") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) - public void getQueriesSites() throws Exception - { - restClient.authenticateUser(dataContent.getAdminUser()).withCoreAPI().usingQueries().findSites(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - restClient.assertLastError().containsErrorKey("Query 'term' not specified") - // and assert on summary too if you want - .containsSummary("Query 'term' not specified"); - - restClient.withCoreAPI().usingQueries().usingParams("term=b").findSites(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - restClient.assertLastError().containsErrorKey("Query 'term' is too short"); - - SiteModel site = RestSiteModel.getRandomSiteModel(); - RestSiteModel createdSite = restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingSite(site).createSite(); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RetryOperation op = new RetryOperation() - { - public void execute() throws Exception - { - RestSiteModelsCollection restSiteModels = restClient.withCoreAPI().usingQueries().usingParams("term=" + createdSite.getTitle()) - .findSites(); - - assertEquals(restSiteModels.getEntries().size(), 1); - - } - }; - - Utility.sleep(100, 100000, op);// Allow indexing to complete. - - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.QUERIES }, executionType = ExecutionType.SANITY, description = "Check basic functionality of GET queries/people") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) - public void getQueriesPeople() throws Exception - { - restClient.authenticateUser(dataContent.getAdminUser()).withCoreAPI().usingQueries().findPeople(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - restClient.assertLastError().containsErrorKey("Query 'term' not specified") - // and assert on summary too if you want - .containsSummary("Query 'term' not specified"); - - restClient.withCoreAPI().usingQueries().usingParams("term=b").findPeople(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - restClient.assertLastError().containsErrorKey("Query 'term' is too short"); - - UserModel userModel = dataUser.createRandomTestUser(); - RetryOperation op = new RetryOperation() - { - public void execute() throws Exception - { - RestPersonModelsCollection restPersonModels = restClient.withCoreAPI().usingQueries().usingParams("term=" + userModel.getUsername()) - .findPeople(); - - assertEquals(restPersonModels.getEntries().size(), 1); - - } - }; - - Utility.sleep(100, 100000, op);// Allow indexing to complete. - - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.QUERIES }, - executionType = ExecutionType.REGRESSION, description = "Check basic functionality of GET queries/nodes") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void getOnQueriesNodesRoute() throws Exception - { - restClient.authenticateUser(dataContent.getAdminUser()) - .withCoreAPI() - .usingQueries().findNodes(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - - restClient.assertLastError() - .containsErrorKey("Query 'term' not specified") - //and assert on summary too if you want - .containsSummary("Query 'term' not specified"); - - restClient.withCoreAPI() - .usingQueries() - .usingParams("term=ab") - .findNodes(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - - restClient.assertLastError() - .containsErrorKey("Query 'term' is too short"); - - /* - * now making the correct call with a valid term value - */ - restClient.withCoreAPI().usingQueries().usingParams("term=name").findNodes(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.QUERIES }, executionType = ExecutionType.REGRESSION, description = "Verify GET queries on queries/nodes return success status code") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) - public void testSearchTermWhiteSpace() throws Exception - { - - UserModel userModel = dataUser.createRandomTestUser(); - SiteModel siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - /* - * Create the following file structure for preconditions : - * |- folder - * |--find123.txt - * |-- find123 find.txt - */ - restClient.authenticateUser(userModel).withCoreAPI().usingNode(ContentModel.my()).defineNodes(); - FolderModel folder = new FolderModel("folder" + Math.random()); - - // I use "find123" and "find123 find", the search using second term must - // return less result - // The space must not break the query - String childTerm = "find" + Math.random(); - String childTermWS = childTerm + " " + "find"; - - dataContent.usingUser(userModel).usingSite(siteModel).createFolder(folder); - FileModel file1 = new FileModel(childTerm + ".txt", FileType.TEXT_PLAIN, childTerm); - FileModel file2 = new FileModel(childTermWS + ".txt", FileType.TEXT_PLAIN, childTermWS); - ContentModel cm = new ContentModel(); - cm.setCmisLocation(folder.getCmisLocation()); - cm.setName(folder.getName()); - dataContent.usingUser(userModel).usingSite(siteModel).usingResource(cm).createContent(file1); - dataContent.usingUser(userModel).usingSite(siteModel).usingResource(cm).createContent(file2); - - RetryOperation op = new RetryOperation(){ - public void execute() throws Exception{ - RestNodeModelsCollection nodesChildTerm = restClient.withCoreAPI().usingQueries().usingParams("term=" + childTerm).findNodes(); - // check if the search returns all nodes which contain that query term - assertEquals(2, nodesChildTerm.getEntries().size()); - RestNodeModelsCollection nodesChildTermWS = restClient.withCoreAPI().usingQueries().usingParams("term=" + childTermWS).findNodes(); - // check if search works for words with space and the space don't break - // the query - assertEquals(1, nodesChildTermWS.getEntries().size()); - assertTrue(nodesChildTerm.getEntries().size() >= nodesChildTermWS.getEntries().size()); - } - - }; - Utility.sleep(10, 3500, op);// Allow indexing to complete. - - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/ratings/AddRatingTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/ratings/AddRatingTests.java deleted file mode 100644 index 39b5c823d..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/ratings/AddRatingTests.java +++ /dev/null @@ -1,818 +0,0 @@ -package org.alfresco.service.search.rest.ratings; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestCommentModel; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestRatingModel; -import org.alfresco.rest.model.RestTagModel; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.exception.DataPreparationException; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.LinkModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.apache.commons.lang3.RandomStringUtils; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - - -public class AddRatingTests extends RestTest -{ - private UserModel userModel; - private SiteModel siteModel; - private UserModel adminUser; - private ListUserWithRoles usersWithRoles; - private RestRatingModel returnedRatingModel; // placeholder for returned model - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws DataPreparationException - { - userModel = dataUser.createRandomTestUser(); - adminUser = dataUser.getAdminUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.SANITY, description = "Verify user with Manager role is able to post like rating to a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) - public void managerIsAbleToLikeDocument() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(document) - .likeDocument(); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Verify user with Collaborator role is able to post like rating to a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void collaboratorIsAbleToLikeDocument() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(document) - .likeDocument(); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Verify user with Contributor role is able to post like rating to a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void contributorIsAbleToLikeDocument() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingResource(document) - .likeDocument(); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Verify user with Consumer role is able to post like rating to a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void consumerIsAbleToLikeDocument() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingResource(document) - .likeDocument(); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Verify admin user is able to post like rating to a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void adminIsAbleToLikeDocument() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - returnedRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to post like rating to a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) -// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void unauthenticatedUserIsNotAbleToLikeDocument() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(new UserModel("random user", "random password")).withCoreAPI().usingResource(document).likeDocument(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.SANITY, description = "Verify user with Manager role is able to post stars rating to a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) - public void managerIsAbleToAddStarsToDocument() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(document) - .rateStarsToDocument(5); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Verify user with Collaborator role is able to post stars rating to a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void collaboratorIsAbleToAddStarsToDocument() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(document) - .rateStarsToDocument(5); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); - - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Verify user with Contributor role is able to post stars rating to a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void contributorIsAbleToAddStarsToDocument() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingResource(document) - .rateStarsToDocument(5); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Verify user with Consumer role is able to post stars rating to a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void consumerIsAbleToAddStarsToDocument() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingResource(document) - .rateStarsToDocument(5); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.REGRESSION }, - executionType = ExecutionType.SANITY, description = "Verify admin user is able to post stars rating to a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void adminIsAbleToAddStarsToDocument() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - returnedRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).rateStarsToDocument(3); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedRatingModel.assertThat().field("myRating").is("3").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to post stars rating to a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) -// @Bug(id="MNT-16904", description = "fails only on environment with tenants") - public void unauthenticatedUserIsNotAbleToRateStarsToDocument() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(new UserModel("random user", "random password")).withCoreAPI().usingResource(document).rateStarsToDocument(5); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Verify that if unknown rating scheme is provided status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void unknownRatingSchemeReturnsBadRequest() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"invalidRate\"}"); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsSummary(String.format(RestErrorModel.INVALID_RATING, "invalidRate")) - .containsErrorKey(String.format(RestErrorModel.INVALID_RATING, "invalidRate")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Verify that if nodeId does not exist status code 404 is returned") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void invalidNodeIdReturnsNotFound() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - document.setNodeRef(RandomStringUtils.randomAlphanumeric(10)); - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, document.getNodeRef())) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Verify that if nodeId provided cannot be rated 405 status code is returned") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void likeResourceThatCannotBeRated() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - LinkModel link = dataLink.usingAdmin().usingSite(siteModel).createRandomLink(); - document.setNodeRef(link.getNodeRef().replace("workspace://SpacesStore/", "workspace%3A%2F%2FSpacesStore%2F")); - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, document.getNodeRef())) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.SANITY, description = "Verify that manager is able to like a folder") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) - public void managerIsAbleToLikeAFolder() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(folderModel) - .likeDocument(); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.SANITY, description = "Verify that manager is able to like a site") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) - public void managerIsAbleToLikeASite() throws Exception - { - FolderModel folderModel = new FolderModel(); - folderModel.setNodeRef(siteModel.getGuid()); - - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(folderModel) - .likeDocument(); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty(); - - restClient.withCoreAPI().usingResource(folderModel).getRatings() - .assertNodeIsLiked(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.SANITY, description = "Verify that manager is able to rate a folder") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) - public void managerIsAbleToRateAFolder() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(folderModel) - .rateStarsToDocument(5); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.SANITY }, - executionType = ExecutionType.REGRESSION, description = "Verify that manager is able to rate a site") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) - public void managerIsAbleToRateASite() throws Exception - { - FolderModel folderModel = new FolderModel(); - folderModel.setNodeRef(siteModel.getGuid()); - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(folderModel) - .rateStarsToDocument(5); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); - - restClient.withCoreAPI().usingResource(folderModel).getRatings() - .assertNodeHasFiveStarRating(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Verify that adding like again has no effect on a file") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void fileCanBeLikedTwice() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Verify that adding rate again has no effect on a file") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void fileCanBeRatedTwice() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).rateStarsToDocument(5); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).rateStarsToDocument(5); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Verify that rate is not added if empty rating object is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void addRateUsingEmptyRatingObject() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating(""); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.NO_CONTENT, "No content to map due to end-of-input")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Verify that if empty rate id is provided status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void addRateUsingEmptyValueForId() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"\"}"); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - // The message is shortened for comparison as there is a Java object id in the message (random) - .containsSummary(String.format(RestErrorModel.NO_CONTENT, "N/A")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Verify that if empty rating is provided status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void addRateUsingEmptyValueForMyRating() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"likes\", \"myRating\":\"\"}"); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.NULL_LIKE_RATING)); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"fiveStar\", \"myRating\":\"\"}"); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.NULL_FIVESTAR_RATING)); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Verify that user is not able to rate a comment") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void addRatingToAComment() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - RestCommentModel comment = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addComment("This is a comment"); - document.setNodeRef(comment.getId()); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) - .assertLastError() - .containsSummary(String.format(RestErrorModel.CANNOT_RATE)) - .containsErrorKey(RestErrorModel.CANNOT_RATE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).rateStarsToDocument(5); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(String.format(RestErrorModel.CANNOT_RATE)); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Verify that user is not able to rate a tag") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void addRatingToATag() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - RestTagModel tag = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addTag("randomTag"); - document.setNodeRef(tag.getId()); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(String.format(RestErrorModel.CANNOT_RATE)); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).rateStarsToDocument(5); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(String.format(RestErrorModel.CANNOT_RATE)); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that Contributor is able to like a folder") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void contributorIsAbleToLikeAFolder() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI() - .usingResource(folderModel) - .likeDocument(); - - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedRatingModel.assertThat().field("myRating").is("true") - .and().field("id").is("likes") - .and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that Collaborator is able to like a folder") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void collaboratorIsAbleToLikeAFolder() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI() - .usingResource(folderModel) - .likeDocument(); - - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedRatingModel.assertThat().field("myRating").is("true") - .and().field("id").is("likes") - .and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that Consumer is able to like a folder") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void consumerIsAbleToLikeAFolder() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI() - .usingResource(folderModel) - .likeDocument(); - - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedRatingModel.assertThat().field("myRating").is("true") - .and().field("id").is("likes") - .and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that Contributor is able to rate a folder") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void contributorIsAbleToRateAFolder() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI() - .usingResource(folderModel) - .rateStarsToDocument(5); - - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedRatingModel.assertThat().field("myRating").is("5") - .and().field("id").is("fiveStar") - .and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that Collaborator is able to rate a folder") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void collaboratorIsAbleToRateAFolder() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI() - .usingResource(folderModel) - .rateStarsToDocument(5); - - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedRatingModel.assertThat().field("myRating").is("5") - .and().field("id").is("fiveStar") - .and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that Consumer is able to rate a folder") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void consumerIsAbleToRateAFolder() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI() - .usingResource(folderModel) - .rateStarsToDocument(5); - - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedRatingModel.assertThat().field("myRating").is("5") - .and().field("id").is("fiveStar") - .and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that adding like again has no effect on a folder") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void folderCanBeLikedTwice() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folderModel).likeDocument(); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folderModel).likeDocument(); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("true") - .and().field("id").is("likes") - .and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that adding rate again has no effect on a folder") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void folderCanBeRatedTwice() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folderModel).rateStarsToDocument(5); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folderModel).rateStarsToDocument(5); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("5") - .and().field("id").is("fiveStar") - .and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that if invalid rate id is provided status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void addRateUsingInvalidValueForId() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"like\"}"); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsSummary(String.format(RestErrorModel.INVALID_RATING, "like")) - .containsErrorKey(String.format(RestErrorModel.INVALID_RATING, "like")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that rate id is case sensitive is provided status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void addRateUsingInvalidValueForIdCaseSensitive() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"Likes\"}"); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsSummary(String.format(RestErrorModel.INVALID_RATING, "Likes")) - .containsErrorKey(String.format(RestErrorModel.INVALID_RATING, "Likes")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"FiveStar\"}"); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsSummary(String.format(RestErrorModel.INVALID_RATING, "FiveStar")) - .containsErrorKey(String.format(RestErrorModel.INVALID_RATING, "FiveStar")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that if invalid rating is provided status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void addRateUsingInvalidValueForMyRating() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"likes\", \"myRating\":\"skiped\"}"); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsSummary(String.format(RestErrorModel.NULL_LIKE_RATING)); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"fiveStar\", \"myRating\":\"string\"}"); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsSummary(String.format(RestErrorModel.NULL_FIVESTAR_RATING)); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Like file created by a different user") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void addLikeToAnotherUserFile() throws Exception - { - UserModel user = dataUser.usingAdmin().createRandomTestUser(); - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - returnedRatingModel = restClient.authenticateUser(user).withCoreAPI().usingResource(document).likeDocument(); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedRatingModel.assertThat().field("myRating").is("true") - .and().field("id").is("likes") - .and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Rate a file created by a different user") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void addRatingToAnotherUserFile() throws Exception - { - UserModel user = dataUser.usingAdmin().createRandomTestUser(); - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - returnedRatingModel = restClient.authenticateUser(user).withCoreAPI().usingResource(document).rateStarsToDocument(5); - returnedRatingModel.assertThat().field("myRating").is("5") - .and().field("id").is("fiveStar") - .and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Add Rate Using Boolean Value For 'myRating'") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void addRateUsingBooleanValueForMyRating() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"fiveStar\", \"myRating\":\"true\"}"); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsSummary(RestErrorModel.NULL_FIVESTAR_RATING) - .containsErrorKey(RestErrorModel.NULL_FIVESTAR_RATING) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Add Like Using Integer Value For 'myRating'") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void addLikeUsingIntegerValueForMyRating() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"likes\", \"myRating\":\"2\"}"); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsSummary(RestErrorModel.NULL_LIKE_RATING) - .containsErrorKey(RestErrorModel.NULL_LIKE_RATING) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that user is not able to like his own comment") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void userCannotLikeHisOwnComment() throws Exception - { - UserModel user = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); - FolderModel folderModel = dataContent.usingUser(user).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(user).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - RestCommentModel comment = restClient.authenticateUser(user).withCoreAPI().usingResource(document).addComment("This is a comment"); - document.setNodeRef(comment.getId()); - - returnedRatingModel = restClient.authenticateUser(user).withCoreAPI().usingResource(document).likeDocument(); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) - .assertLastError() - .containsSummary(String.format(RestErrorModel.CANNOT_RATE)) - .containsErrorKey(RestErrorModel.CANNOT_RATE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER).stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that user is not able to rate his own comment") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void userCannotRateHisOwnComment() throws Exception - { - UserModel user = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); - FolderModel folderModel = dataContent.usingUser(user).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(user).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - RestCommentModel comment = restClient.authenticateUser(user).withCoreAPI().usingResource(document).addComment("This is a comment"); - document.setNodeRef(comment.getId()); - - returnedRatingModel = restClient.authenticateUser(user).withCoreAPI().usingResource(document).rateStarsToDocument(5); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) - .assertLastError() - .containsSummary(String.format(RestErrorModel.CANNOT_RATE)) - .containsErrorKey(RestErrorModel.CANNOT_RATE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that Collaborator is NOT able to add a negative rating to a file") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void collaboratorIsNotAbleToAddANegativeRatingToAFile() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI() - .usingResource(document) - .rateStarsToDocument(-5); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsSummary(RestErrorModel.RATING_OUT_OF_BOUNDS) - .containsErrorKey(RestErrorModel.RATING_OUT_OF_BOUNDS) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that Collaborator is NOT able to add a high rating to a file") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void collaboratorIsNotAbleToAddAHighRatingToAFile() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI() - .usingResource(document) - .rateStarsToDocument(10); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsSummary(RestErrorModel.RATING_OUT_OF_BOUNDS) - .containsErrorKey(RestErrorModel.RATING_OUT_OF_BOUNDS) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - // @Bug(id = "MNT-17375", description = "Won't Fix, the error message is not ideal and a little cryptic but it does provide the reason i.e. ratingSchemeId is null.") - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Do not provide field - 'id'") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void notProvideIdLikeFile() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"myRating\":\"true\"}"); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsSummary(String.format(RestErrorModel.INVALID_RATING, "null")) - .containsErrorKey(String.format(RestErrorModel.INVALID_RATING, "null")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Do not provide field - 'myRating'") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void notProvideMyRatingRateFile() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"likes\"}"); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsSummary(RestErrorModel.NULL_LIKE_RATING) - .containsErrorKey(RestErrorModel.NULL_LIKE_RATING) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } -} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/ratings/DeleteRatingTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/ratings/DeleteRatingTests.java deleted file mode 100644 index 829febf57..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/ratings/DeleteRatingTests.java +++ /dev/null @@ -1,525 +0,0 @@ -package org.alfresco.service.search.rest.ratings; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestRatingModel; -import org.alfresco.rest.model.RestRatingModelsCollection; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.exception.DataPreparationException; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class DeleteRatingTests extends RestTest -{ - private SiteModel siteModel; - private UserModel adminUser; - private ListUserWithRoles usersWithRoles; - private RestRatingModelsCollection returnedRatingModelCollection; - private RestRatingModel returnedRatingModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws DataPreparationException - { - adminUser = dataUser.getAdminUser(); - siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); - - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.SANITY, description = "Verify user with Manager role is able to remove its own rating of a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) - public void managerIsAbleToDeleteItsOwnRatings() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingResource(document).likeDocument(); - restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - - restClient.withCoreAPI().usingResource(document).deleteLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - returnedRatingModelCollection = restClient.withCoreAPI().usingResource(document).getRatings(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedRatingModelCollection.assertNodeIsNotLiked().assertNodeHasNoFiveStarRating().and().entriesListIsNotEmpty().and().paginationExist(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Verify user with Collaborator role is able to remove its own rating of a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void collaboratorIsAbleToDeleteItsOwnRatings() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - - restClient.withCoreAPI().usingResource(document).likeDocument(); - restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - - restClient.withCoreAPI().usingResource(document).deleteLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - returnedRatingModelCollection = restClient.withCoreAPI().usingResource(document).getRatings(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedRatingModelCollection.assertNodeIsNotLiked().assertNodeHasNoFiveStarRating().and().entriesListIsNotEmpty().and().paginationExist(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Verify user with Contributor role is able to remove its own rating of a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void contributorIsAbleToDeleteItsOwnRatings() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - - restClient.withCoreAPI().usingResource(document).likeDocument(); - restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - - restClient.withCoreAPI().usingResource(document).deleteLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - returnedRatingModelCollection = restClient.withCoreAPI().usingResource(document).getRatings(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedRatingModelCollection.assertNodeIsNotLiked().assertNodeHasNoFiveStarRating().and().entriesListIsNotEmpty().and().paginationExist(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Verify user with Consumer role is able to remove its own rating of a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void consumerIsAbleToDeleteItsOwnRatings() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - - restClient.withCoreAPI().usingResource(document).likeDocument(); - restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - - restClient.withCoreAPI().usingResource(document).deleteLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - returnedRatingModelCollection = restClient.withCoreAPI().usingResource(document).getRatings(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedRatingModelCollection.assertNodeIsNotLiked().assertNodeHasNoFiveStarRating().and().entriesListIsNotEmpty().and().paginationExist(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Verify admin user is able to remove its own rating of a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void adminIsAbleToDeleteItsOwnRatings() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - document = dataContent.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).usingResource(folderModel) - .createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(adminUser); - - restClient.withCoreAPI().usingResource(document).likeDocument(); - restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - - restClient.withCoreAPI().usingResource(document).deleteLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - returnedRatingModelCollection = restClient.withCoreAPI().usingResource(document).getRatings(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedRatingModelCollection.assertNodeIsNotLiked().assertNodeHasNoFiveStarRating().and().entriesListIsNotEmpty().and().paginationExist(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to remove its own rating of a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) -// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void unauthenticatedUserIsNotAbleToDeleteRatings() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - document = dataContent.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).usingResource(folderModel) - .createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(adminUser); - - restClient.withCoreAPI().usingResource(document).likeDocument(); - restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - - restClient.authenticateUser(new UserModel("random user", "random password")); - - restClient.withCoreAPI().usingResource(document).deleteLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - - restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Verify one user is not able to remove rating added by another user") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - @Bug(id = "ACE-5459") - public void oneUserIsNotAbleToDeleteRatingsOfAnotherUser() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - UserModel userA = dataUser.createRandomTestUser(); - UserModel userB = dataUser.createRandomTestUser(); - - restClient.authenticateUser(userA); - - restClient.withCoreAPI().usingResource(document).likeDocument(); - restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - - restClient.authenticateUser(userB); - - restClient.withCoreAPI().usingResource(document).deleteLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - - restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - restClient.withCoreAPI().usingResource(document).getRatings() - .assertNodeIsLiked() - .assertNodeHasFiveStarRating(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Verify that if ratingId provided is unknown status code returned is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void deleteInvalidRating() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).deleteInvalidRating("random_rating"); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsSummary(String.format(RestErrorModel.INVALID_RATING, "random_rating")) - .containsErrorKey(String.format(RestErrorModel.INVALID_RATING, "random_rating")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Verify that if nodeId does not exist status code returned is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void deleteRatingUsingInvalidDocument() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - document.setNodeRef("random_value"); - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).deleteLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "random_value")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Delete rating stars for a document that was not rated") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - @Bug(id = "MNT-17181") - public void deleteStarsForANotRatedDocument() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).deleteFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Delete like rating for a document that was not liked") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - @Bug(id = "MNT-17181") - public void deleteLikeForANotLikedDocument() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).deleteLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Delete like for a file then add it again") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void likeDocumentAfterLikeRatingIsDeleted() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); - restClient.withCoreAPI().usingResource(document).deleteLikeRating(); - returnedRatingModel = restClient.withCoreAPI().usingResource(document).likeDocument(); - - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Delete stars for a file then add them again") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void addStarsToDocumentAfterRatingIsDeleted() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(document).rateStarsToDocument(5); - restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - returnedRatingModel = restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Verify site manager is not able to remove rating added by another user") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - @Bug(id = "ACE-5459") - public void deleteDocumentRatingUsingManager() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(document).rateStarsToDocument(5); - restClient.withCoreAPI().usingResource(document).likeDocument(); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(document).deleteFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - restClient.withCoreAPI().usingResource(document).deleteLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - - restClient.withCoreAPI().usingResource(document).getRatings() - .assertNodeIsLiked() - .assertNodeHasFiveStarRating(); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Verify site contributor is not able to remove rating added by another user") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - @Bug(id = "ACE-5459") - public void contributorIsNotAbleToDeleteRatingsOfAnotherUser() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(document).rateStarsToDocument(5); - restClient.withCoreAPI().usingResource(document).likeDocument(); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingResource(document).deleteFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - restClient.withCoreAPI().usingResource(document).deleteLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - - restClient.withCoreAPI().usingResource(document).getRatings() - .assertNodeIsLiked() - .assertNodeHasFiveStarRating(); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Verify site collaborator is not able to remove rating added by another user") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - @Bug(id = "ACE-5459") - public void collaboratorIsNotAbleToDeleteRatingsOfAnotherUser() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(document).rateStarsToDocument(5); - restClient.withCoreAPI().usingResource(document).likeDocument(); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(document).deleteFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - restClient.withCoreAPI().usingResource(document).deleteLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - - restClient.withCoreAPI().usingResource(document).getRatings() - .assertNodeIsLiked() - .assertNodeHasFiveStarRating(); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Verify site consumer is not able to remove rating added by another user") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - @Bug(id = "ACE-5459") - public void consumerIsNotAbleToDeleteRatingsOfAnotherUser() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(document).rateStarsToDocument(5); - restClient.withCoreAPI().usingResource(document).likeDocument(); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingResource(document).deleteFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - restClient.withCoreAPI().usingResource(document).deleteLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - - restClient.withCoreAPI().usingResource(document).getRatings() - .assertNodeIsLiked() - .assertNodeHasFiveStarRating(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Delete rating stars twice") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - @Bug(id = "MNT-17181") - public void deleteStarsTwice() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(document).rateStarsToDocument(5); - - restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - returnedRatingModelCollection = restClient.withCoreAPI().usingResource(document).getRatings(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedRatingModelCollection.assertNodeHasNoFiveStarRating(); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).deleteFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Delete like rating twice") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - @Bug(id = "MNT-17181") - public void deleteLikeTwice() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingResource(document).likeDocument(); - - restClient.withCoreAPI().usingResource(document).deleteLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - returnedRatingModelCollection = restClient.withCoreAPI().usingResource(document).getRatings(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedRatingModelCollection.assertNodeIsNotLiked(); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).deleteLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Delete like for a folder then add it again") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void likeFolderAfterLikeRatingIsDeleted() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folderModel).likeDocument(); - restClient.withCoreAPI().usingResource(folderModel).deleteLikeRating(); - returnedRatingModel = restClient.withCoreAPI().usingResource(folderModel).likeDocument(); - - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Delete stars for a folder then add them again") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void addStarsToFolderAfterRatingIsDeleted() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(folderModel).rateStarsToDocument(5); - restClient.withCoreAPI().usingResource(folderModel).deleteFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - returnedRatingModel = restClient.withCoreAPI().usingResource(folderModel).rateStarsToDocument(5); - - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Delete like for a site then add it again") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void likeSiteAfterLikeRatingIsDeleted() throws Exception - { - FolderModel folderModel = new FolderModel(); - folderModel.setNodeRef(siteModel.getGuid()); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folderModel).likeDocument(); - restClient.withCoreAPI().usingResource(folderModel).deleteLikeRating(); - returnedRatingModel = restClient.withCoreAPI().usingResource(folderModel).likeDocument(); - - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Delete stars for a site then add them again") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void addStarsToSiteAfterRatingIsDeleted() throws Exception - { - FolderModel folderModel = new FolderModel(); - folderModel.setNodeRef(siteModel.getGuid()); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(folderModel).rateStarsToDocument(5); - restClient.withCoreAPI().usingResource(folderModel).deleteFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - returnedRatingModel = restClient.withCoreAPI().usingResource(folderModel).rateStarsToDocument(5); - - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Verify user with Manager role is able to remove one star rating of a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void removeOneStarRating() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingResource(document).rateStarsToDocument(1); - - restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - returnedRatingModelCollection = restClient.withCoreAPI().usingResource(document).getRatings(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedRatingModelCollection.assertNodeIsNotLiked().assertNodeHasNoFiveStarRating().and().entriesListIsNotEmpty().and().paginationExist(); - } -} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/ratings/GetRatingTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/ratings/GetRatingTests.java deleted file mode 100644 index ef9f99f3b..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/ratings/GetRatingTests.java +++ /dev/null @@ -1,438 +0,0 @@ -package org.alfresco.service.search.rest.ratings; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.core.RestRequest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestRatingModel; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.exception.DataPreparationException; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.apache.commons.lang3.RandomStringUtils; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -public class GetRatingTests extends RestTest -{ - private SiteModel siteModel; - private UserModel adminUser, userModel, managerUser; - private FileModel document; - private ListUserWithRoles usersWithRoles; - private RestRatingModel restRatingModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws DataPreparationException - { - adminUser = dataUser.getAdminUser(); - userModel = dataUser.createRandomTestUser(); - managerUser = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); - - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - - dataUser.addUserToSite(managerUser, siteModel, UserRole.SiteManager); - } - - @BeforeMethod(alwaysRun = true) - public void setUp() throws Exception - { - document = dataContent.usingSite(siteModel).usingAdmin().createContent(DocumentType.TEXT_PLAIN); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.SANITY, description = "Verify user with Manager role is able to retrieve rating of a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) - public void managerIsAbleToRetrieveRating() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - - restClient.withCoreAPI().usingResource(document).likeDocument(); - restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - - restRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); - - restRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").is("5"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Verify user with Collaborator role is able to retrieve rating of a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void collaboratorIsAbleToRetrieveRating() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - - restClient.withCoreAPI().usingResource(document).likeDocument(); - restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - - restRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); - - restRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").is("5"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Verify user with Contributor role is able to retrieve rating of a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void contributorIsAbleToRetrieveRating() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - - restClient.withCoreAPI().usingResource(document).likeDocument(); - restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - - restRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); - - restRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").is("5"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Verify user with Consumer role is able to retrieve rating of a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void consumerIsAbleToRetrieveRating() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - - restClient.withCoreAPI().usingResource(document).likeDocument(); - restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - - restRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); - - restRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").is("5"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Verify admin user is able to retrieve rating of a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void adminIsAbleToRetrieveRating() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingResource(folderModel) - .createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(adminUser); - restClient.withCoreAPI().usingResource(document).likeDocument(); - restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - - restRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); - - restRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").is("5"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to retrieve rating of a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) -// @Bug(id = "MNT-16904", description = "It fails only on environment with tenants") - public void unauthenticatedUserIsNotAbleToRetrieveRating() throws Exception - { - restClient.authenticateUser(adminUser); - restClient.withCoreAPI().usingResource(document).likeDocument(); - restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - - restClient.authenticateUser(new UserModel("random user", "random password")); - - restClient.withCoreAPI().usingResource(document).getLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - - restClient.withCoreAPI().usingResource(document).getFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Check that using invalid ratingId for get rating call returns status code 400.") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void checkInvalidRatingIdStatusCode() throws Exception - { - restClient.authenticateUser(adminUser).withCoreAPI(); - RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "nodes/{nodeId}/ratings/{ratingId}", document.getNodeRef(), "invalid ratingId"); - restClient.processModel(RestRatingModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.INVALID_RATING, "invalid ratingId")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Check that using invalid node ID for get rating call returns status code 404.") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void getRatingUsingInvalidNodeId() throws Exception - { - document.setNodeRef(RandomStringUtils.randomAlphanumeric(20)); - restRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).getFiveStarRating(); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, document.getNodeRef())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Get rating of a file that has only likes.") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void getRatingOfFileThatHasOnlyLikes() throws Exception - { - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); - - restRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); - restRatingModel.getAggregate().assertThat().field("numberOfRatings").is("1"); - - restRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restRatingModel.getAggregate().assertThat().field("numberOfRatings").is("0"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Get rating of a file that has only stars.") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void getRatingOfFileThatHasOnlyStars() throws Exception - { - restClient.authenticateUser(userModel).withCoreAPI().usingResource(document).rateStarsToDocument(5); - - restRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); - restRatingModel.getAggregate().assertThat().field("numberOfRatings").is("1"); - - restRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restRatingModel.getAggregate().assertThat().field("numberOfRatings").is("0"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Get rating of a file that has likes and stars.") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void getRatingOfFileThatHasLikesAndStars() throws Exception - { - restClient.authenticateUser(userModel).withCoreAPI().usingResource(document).likeDocument(); - restClient.authenticateUser(userModel).withCoreAPI().usingResource(document).rateStarsToDocument(5); - - restRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); - restRatingModel.getAggregate().assertThat().field("numberOfRatings").is("1"); - - restRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); - restRatingModel.getAggregate().assertThat().field("numberOfRatings").is("1"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Get rating of a folder that has only likes.") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void getRatingOfFolderThatHasOnlyLikes() throws Exception - { - FolderModel firstFolderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(firstFolderModel).likeDocument(); - - restRatingModel = restClient.withCoreAPI().usingResource(firstFolderModel).getLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); - restRatingModel.getAggregate().assertThat().field("numberOfRatings").is("1"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Get rating of a file that has no ratings.") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void getRatingOfFileThatHasNoRatings() throws Exception - { - restRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).getLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restRatingModel.getAggregate().assertThat().field("numberOfRatings").is("0"); - - restRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restRatingModel.getAggregate().assertThat().field("numberOfRatings").is("0"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Check default error schema") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void checkDefaultErrorSchema() throws Exception - { - FileModel document = dataContent.usingSite(siteModel).usingAdmin().createContent(DocumentType.TEXT_PLAIN); - String randomNodeRef = RandomStringUtils.randomAlphanumeric(10); - document.setNodeRef(randomNodeRef); - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).getLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, randomNodeRef)) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Get rating of a folder that has only stars") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void getRatingOfFolderThatHasOnlyStars() throws Exception - { - FolderModel folder = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - restClient.authenticateUser(managerUser).withCoreAPI().usingResource(folder).rateStarsToDocument(3); - restRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folder).getFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restRatingModel.assertThat().field("id").is("fiveStar") - .getAggregate().assertThat().field("numberOfRatings").is("1") - .assertThat().field("average").is("3.0"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Get rating of a folder that has both likes and stars") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void getRatingOfFolderThatHasLikedAndStars() throws Exception - { - FolderModel folder = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - restClient.authenticateUser(managerUser).withCoreAPI().usingResource(folder).rateStarsToDocument(3); - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folder).likeDocument(); - - restRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folder).getFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restRatingModel.assertThat().field("id").is("fiveStar") - .getAggregate().assertThat().field("numberOfRatings").is("1") - .assertThat().field("average").is("3.0"); - - restRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folder).getLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restRatingModel.assertThat().field("id").is("likes") - .assertThat().field("myRating").is("true"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Get rating of a folder that has no ratings") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void getRatingOfFolderThatHasNoRatings() throws Exception - { - FolderModel folder = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - - restRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folder).getFiveStarRating(); - restRatingModel.getAggregate().assertThat().field("numberOfRatings").is("0"); - - restRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folder).getLikeRating(); - restRatingModel.getAggregate().assertThat().field("numberOfRatings").is("0"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Get rating of a folder after rating was deleted") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void getDeletedRatingOfAFolder() throws Exception - { - FolderModel folder = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - restClient.authenticateUser(managerUser).withCoreAPI().usingResource(folder).rateStarsToDocument(3); - restClient.authenticateUser(managerUser).withCoreAPI().usingResource(folder).deleteFiveStarRating(); - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folder).likeDocument(); - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folder).deleteLikeRating(); - - restRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folder).getFiveStarRating(); - restRatingModel.assertThat().field("id").is("fiveStar").getAggregate().assertThat().field("numberOfRatings").is("0") - .assertThat().field("average").isNull(); - - restRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folder).getLikeRating(); - restRatingModel.assertThat().field("id").is("likes").assertThat().field("myRating").isNull() - .getAggregate().assertThat().field("numberOfRatings").is("0"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Get rating of a file after rating was deleted") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void getDeletedRatingOfAFile() throws Exception - { - FileModel file = dataContent.usingUser(adminUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(managerUser).withCoreAPI().usingResource(file).rateStarsToDocument(3); - restClient.authenticateUser(managerUser).withCoreAPI().usingResource(file).deleteFiveStarRating(); - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(file).likeDocument(); - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(file).deleteLikeRating(); - - restRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(file).getFiveStarRating(); - restRatingModel.assertThat().field("id").is("fiveStar").getAggregate().assertThat().field("numberOfRatings").is("0") - .assertThat().field("average").isNull(); - - restRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(file).getLikeRating(); - restRatingModel.assertThat().field("id").is("likes").assertThat().field("myRating").isNull() - .getAggregate().assertThat().field("numberOfRatings").is("0"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Get rating of another user as admin") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void getRatingOfAnotherUserAsAdmin() throws Exception - { - FileModel file = dataContent.usingUser(adminUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(managerUser).withCoreAPI().usingResource(file).rateStarsToDocument(3); - restClient.authenticateUser(managerUser).withCoreAPI().usingResource(file).likeDocument(); - - restRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(file).getFiveStarRating(); - restRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").isNull() - .getAggregate().assertThat().field("numberOfRatings").is("1").assertThat().field("average").is("3.0"); - - restRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(file).getLikeRating(); - restRatingModel.assertThat().field("id").is("likes").assertThat().field("myRating").isNull() - .getAggregate().assertThat().field("numberOfRatings").is("1"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Get rating of admin with another user") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void getRatingOfAdminWithAnotherUser() throws Exception - { - FileModel file = dataContent.usingUser(managerUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(file).rateStarsToDocument(3); - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(file).likeDocument(); - - restRatingModel = restClient.authenticateUser(managerUser).withCoreAPI().usingResource(file).getFiveStarRating(); - restRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").isNull() - .getAggregate().assertThat().field("numberOfRatings").is("1").assertThat().field("average").is("3.0"); - - restRatingModel = restClient.authenticateUser(managerUser).withCoreAPI().usingResource(file).getLikeRating(); - restRatingModel.assertThat().field("id").is("likes").assertThat().field("myRating").isNull() - .getAggregate().assertThat().field("numberOfRatings").is("1"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Get five star rating") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void getFiveStarRating() throws Exception - { - FileModel file = dataContent.usingUser(managerUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(file).rateStarsToDocument(5); - - restRatingModel = restClient.authenticateUser(managerUser).withCoreAPI().usingResource(file).getFiveStarRating(); - restRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").isNull() - .getAggregate().assertThat().field("numberOfRatings").is("1").assertThat().field("average").is("5.0"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Get one star rating") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void getOneStarRating() throws Exception - { - FileModel file = dataContent.usingUser(managerUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(file).rateStarsToDocument(1); - - restRatingModel = restClient.authenticateUser(managerUser).withCoreAPI().usingResource(file).getFiveStarRating(); - restRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").isNull() - .getAggregate().assertThat().field("numberOfRatings").is("1").assertThat().field("average").is("1.0"); - } -} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/ratings/GetRatingsTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/ratings/GetRatingsTests.java deleted file mode 100644 index 19cd55116..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/ratings/GetRatingsTests.java +++ /dev/null @@ -1,313 +0,0 @@ -package org.alfresco.service.search.rest.ratings; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestRatingModelsCollection; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.exception.DataPreparationException; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.apache.commons.lang3.RandomStringUtils; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class GetRatingsTests extends RestTest -{ - private SiteModel siteModel; - private UserModel adminUser, userModel; - private ListUserWithRoles usersWithRoles; - private RestRatingModelsCollection restRatingModelsCollection; - private FileModel document; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws DataPreparationException - { - adminUser = dataUser.getAdminUser(); - userModel = dataUser.createRandomTestUser(); - - siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); - - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.SANITY, description = "Manager is able to retrieve document ratings") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) - public void managerIsAbleToRetrieveDocumentRatings() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - - restClient.withCoreAPI().usingResource(document).likeDocument(); - restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - - restRatingModelsCollection = restClient.withCoreAPI().usingResource(document).getRatings(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restRatingModelsCollection.assertNodeHasFiveStarRating().assertNodeIsLiked(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Collaborator is able to retrieve document ratings") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void collaboratorIsAbleToRetrieveDocumentRatings() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - - restClient.withCoreAPI().usingResource(document).likeDocument(); - restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - - restRatingModelsCollection = restClient.withCoreAPI().usingResource(document).getRatings(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restRatingModelsCollection.assertNodeHasFiveStarRating().assertNodeIsLiked(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Contributor is able to retrieve document ratings") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void contributorIsAbleToRetrieveDocumentRatings() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - - restClient.withCoreAPI().usingResource(document).likeDocument(); - restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - - restRatingModelsCollection = restClient.withCoreAPI().usingResource(document).getRatings(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restRatingModelsCollection.assertNodeHasFiveStarRating().assertNodeIsLiked(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Consumer is able to retrieve document ratings") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void consumerIsAbleToRetrieveDocumentRatings() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - - restClient.withCoreAPI().usingResource(document).likeDocument(); - restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - - restRatingModelsCollection = restClient.withCoreAPI().usingResource(document).getRatings(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restRatingModelsCollection.assertNodeHasFiveStarRating().assertNodeIsLiked(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Admin user is able to retrieve document ratings") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void adminIsAbleToRetrieveDocumentRatings() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - document = dataContent.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingResource(folderModel) - .createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(adminUser); - restClient.withCoreAPI().usingResource(document).likeDocument(); - restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - - restRatingModelsCollection = restClient.withCoreAPI().usingResource(document).getRatings(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restRatingModelsCollection.assertNodeHasFiveStarRating().assertNodeIsLiked(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to retrieve document ratings") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) -// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void unauthenticatedUserIsNotAbleToRetrieveRatings() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(adminUser); - restClient.withCoreAPI().usingResource(document).likeDocument(); - restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - - restClient.authenticateUser(new UserModel("random user", "random password")); - - restClient.withCoreAPI().usingResource(document).getRatings(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Check that rating for invalid maxItems status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void checkInvalidMaxItemsStatusCode() throws Exception - { - document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); - restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).rateStarsToDocument(5); - restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).likeDocument(); - - restClient.authenticateUser(adminUser).withParams("maxItems=0").withCoreAPI().usingResource(document).getRatings(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Only positive values supported for maxItems"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Check that rating for invalid skipCount status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void checkInvalidSkipCountStatusCode() throws Exception - { - document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); - restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).rateStarsToDocument(5); - restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).likeDocument(); - - restClient.authenticateUser(adminUser).withParams("skipCount=AB").withCoreAPI().usingResource(document).getRatings(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Invalid paging parameter skipCount:AB"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "If nodeId does not exist status code is 404 when a document is liked") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void addLikeUsingInvalidNodeId() throws Exception - { - document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); - restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).rateStarsToDocument(5); - restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).likeDocument(); - document.setNodeRef(RandomStringUtils.randomAlphanumeric(20)); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).getRatings(); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, document.getNodeRef())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Check that rating value is TRUE for a like rating") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void checkRatingValueIsTrueForLikedDoc() throws Exception - { - document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); - restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).rateStarsToDocument(5); - restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).likeDocument(); - - restRatingModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingResource(document).getRatings(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - restRatingModelsCollection.assertThat().entriesListContains("myRating", "true") - .assertThat().entriesListContains("id", "likes"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Check that rating value is an INTEGER value for stars rating") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void checkRatingValueIsIntegerForStarsRating() throws Exception - { - document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); - restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).rateStarsToDocument(5); - restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).likeDocument(); - - restRatingModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingResource(document).getRatings(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - restRatingModelsCollection.assertThat().entriesListContains("myRating", "5") - .assertThat().entriesListContains("id", "fiveStar"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Check default error schema in case of failure") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void checkDefaultErrorSchema() throws Exception - { - FileModel document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); - document.setNodeRef("abc"); - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).getRatings(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "abc")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Check maxItems and skipCount parameters") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void checkMaxItemsAndSkipCountParameters() throws Exception - { - document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); - restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).rateStarsToDocument(5); - restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).likeDocument(); - - restRatingModelsCollection = restClient.authenticateUser(adminUser).withParams("maxItems=1", "skipCount=1").withCoreAPI().usingResource(document).getRatings(); - restRatingModelsCollection.assertThat().entriesListCountIs(1); - restRatingModelsCollection.getPagination().assertThat().field("maxItems").is("1") - .and().field("skipCount").is("1"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Check totalItems and hasMoreitems parameters") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void checkTotalItemsAndHasMoreItemsParameters() throws Exception - { - document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); - restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).rateStarsToDocument(5); - restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).likeDocument(); - - restRatingModelsCollection = restClient.authenticateUser(adminUser).withParams("maxItems=1").withCoreAPI().usingResource(document).getRatings(); - restRatingModelsCollection.assertThat().entriesListCountIs(1); - restRatingModelsCollection.getPagination().assertThat().field("hasMoreItems").is("true") - .and().field("count").is("1").and().field("maxItems").is("1"); - } - - @Bug(id = "REPO-1831") - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Get ratings for a document to which authenticated user does not have access") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void userIsNotAbleToGetRatingsOfDocumentToWhichItHasNoAccess() throws Exception - { - SiteModel privateSite = dataSite.usingAdmin().createPrivateRandomSite(); - FileModel file = dataContent.usingSite(privateSite).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); - restRatingModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingResource(file).getRatings(); - restRatingModelsCollection.assertThat().entriesListIsEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Check high value for skipCount parameter") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void getRatingsUsingHighValueForSkipCount() throws Exception - { - document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); - restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).rateStarsToDocument(5); - restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).likeDocument(); - - restRatingModelsCollection = restClient.authenticateUser(adminUser).withParams("skipCount=100").withCoreAPI().usingResource(document).getRatings(); - restRatingModelsCollection.getPagination().assertThat().field("skipCount").is("100"); - restRatingModelsCollection.assertThat().entriesListIsEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Get ratings using site id instead of node id") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void getRatingsUsingSiteId() throws Exception - { - FileModel document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); - document.setNodeRef(siteModel.getId()); - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).getRatings(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, siteModel.getId())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } -} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/renditions/CreateRenditionTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/renditions/CreateRenditionTests.java deleted file mode 100644 index e1b58a126..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/renditions/CreateRenditionTests.java +++ /dev/null @@ -1,101 +0,0 @@ -package org.alfresco.service.search.rest.renditions; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestNodeModel; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.utility.Utility; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.report.Bug.Status; -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.BeforeMethod; -import org.testng.annotations.Test; - -/** - * Handles tests related to POST api-explorer/#!/renditions - * @author Cristina Axinte - * - */ -@Test(groups = {TestGroup.REQUIRE_TRANSFORMATION}) -public class CreateRenditionTests extends RestTest -{ - private UserModel adminUser, user; - private SiteModel site; - private FileModel document; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - user = dataUser.createRandomTestUser(); - site = dataSite.usingUser(user).createPublicRandomSite(); - } - - @BeforeMethod(alwaysRun = true) - public void createDocument() throws Exception - { - document = dataContent.usingUser(user).usingSite(site).createContent(DocumentType.TEXT_PLAIN); - } - - @Bug(id = "REPO-2042", description = "Should fail only on MAC OS System and Linux", status = Status.FIXED ) - @TestRail(section = { TestGroup.REST_API, TestGroup.RENDITIONS }, executionType = ExecutionType.SANITY, - description = "Verify admin user creates rendition with Rest API and status code is 202") - @Test(groups = { TestGroup.REST_API, TestGroup.RENDITIONS, TestGroup.SANITY }) - public void adminCanCreateRenditionToExistingNode() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUser).withCoreAPI().usingNode(document).createNodeRendition("pdf"); - restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); - - restClient.withCoreAPI().usingNode(document).getNodeRenditionUntilIsCreated("pdf") - .assertThat().field("status").is("CREATED"); - } - - @Bug(id = "REPO-2042", description = "Should fail only on MAC OS System and Linux", status = Status.FIXED ) - @TestRail(section = { TestGroup.REST_API, TestGroup.RENDITIONS }, executionType = ExecutionType.REGRESSION, - description = "Verify user that created the document can also creates 'pdf' rendition for it with Rest API and status code is 202") - @Test(groups = { TestGroup.REST_API, TestGroup.RENDITIONS, TestGroup.REGRESSION }) - public void userThatCreatedFileCanCreatePdfRenditionForIt() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(user).withCoreAPI().usingNode(document).createNodeRendition("pdf"); - restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); - - restClient.withCoreAPI().usingNode(document).getNodeRenditionUntilIsCreated("pdf") - .assertThat().field("status").is("CREATED"); - } - - @Bug(id = "REPO-2042", description = "Should fail only on MAC OS System and Linux", status = Status.FIXED ) - @TestRail(section = { TestGroup.REST_API, TestGroup.RENDITIONS }, executionType = ExecutionType.REGRESSION, - description = "Verify user that created the document can also creates 'doclib' rendition for it with Rest API and status code is 202") - @Test(groups = { TestGroup.REST_API, TestGroup.RENDITIONS, TestGroup.REGRESSION }) - public void userThatCreatedFileCanCreateDoclibRenditionForIt() throws JsonToModelConversionException, Exception - { - FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder(); - restClient.authenticateUser(user) - .configureRequestSpec() - .addMultiPart("filedata", Utility.getResourceTestDataFile("my-file.tif")); - - RestNodeModel fileNode = restClient.authenticateUser(user).withCoreAPI().usingResource(folder).createNode(); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - document = new FileModel("my-file.tif"); - document.setCmisLocation(folder.getCmisLocation() + "/my-file.tif"); - document.setNodeRef(fileNode.getId()); - - restClient.authenticateUser(user).withCoreAPI().usingNode(document).createNodeRendition("doclib"); - restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); - - // Renditions are async - Utility.sleep(500, 60000, () -> - { - restClient.withCoreAPI().usingNode(document).getNodeRenditionUntilIsCreated("doclib") - .assertThat().field("status").is("CREATED"); - }); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/renditions/GetRenditionTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/renditions/GetRenditionTests.java deleted file mode 100644 index 5ccb346b7..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/renditions/GetRenditionTests.java +++ /dev/null @@ -1,157 +0,0 @@ -package org.alfresco.service.search.rest.renditions; - -import static org.alfresco.utility.report.log.Step.STEP; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.core.RestResponse; -import org.alfresco.rest.model.RestNodeModel; -import org.alfresco.rest.model.RestRenditionInfoModel; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.utility.Utility; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.report.Bug.Status; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.Assert; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Handles tests related to GET api-explorer/#!/renditions - * @author Cristina Axinte - * - */ -@Test(groups = {TestGroup.REQUIRE_TRANSFORMATION}) -public class GetRenditionTests extends RestTest -{ - private UserModel user; - private SiteModel site; - private FileModel file1; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - user = dataUser.createRandomTestUser(); - site = dataSite.usingUser(user).createPublicRandomSite(); - file1 = dataContent.usingUser(user).usingSite(site).createContent(DocumentType.TEXT_PLAIN); - } - - @Bug(id = "REPO-2449", status = Status.FIXED) - @Test(groups = { TestGroup.REST_API, TestGroup.RENDITIONS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.RENDITIONS }, executionType = ExecutionType.SANITY, - description = "Verify that ZIP document preview is rendered") - public void verifyPreviewOfZipFile() throws Exception - { - STEP("1. Create a folder in existing site"); - FolderModel folder = FolderModel.getRandomFolderModel(); - folder = dataContent.usingUser(user).usingSite(site).createFolder(folder); - - STEP("2. Upload a local ZIP file using RESTAPI"); - restClient.authenticateUser(user).configureRequestSpec().addMultiPart("filedata", Utility.getResourceTestDataFile("content-zip-test.zip")); - - RestNodeModel fileNode = restClient.authenticateUser(user).withCoreAPI().usingNode(folder).createNode(); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - FileModel file = new FileModel("content-zip-test.zip"); - file.setCmisLocation(folder.getCmisLocation() + "/content-zip-test.zip"); - file.setNodeRef(fileNode.getId()); - - STEP("3. Create preview of ZIP file using RESTAPI"); - restClient.withCoreAPI().usingNode(file).createNodeRendition("pdf"); - restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); - - STEP("4. Verify preview of ZIP file is created using RESTAPI"); - RestRenditionInfoModel renditionInfo = restClient.withCoreAPI().usingNode(file).getNodeRenditionUntilIsCreated("pdf"); - restClient.assertStatusCodeIs(HttpStatus.OK); - renditionInfo.assertThat().field("status").is("CREATED"); - } - - @Bug(id = "REPO-2485", status = Status.FIXED) - @Test(groups = { TestGroup.REST_API, TestGroup.RENDITIONS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.RENDITIONS }, executionType = ExecutionType.SANITY, - description = "Verify that ZIP document thumbnail is rendered") - public void verifyThumbnailOfZipFile() throws Exception - { - STEP("1. Create a folder in existing site"); - FolderModel folder = FolderModel.getRandomFolderModel(); - folder = dataContent.usingUser(user).usingSite(site).createFolder(folder); - - STEP("2. Upload a local ZIP file using RESTAPI"); - restClient.authenticateUser(user).configureRequestSpec().addMultiPart("filedata", Utility.getResourceTestDataFile("content-zip-test.zip")); - - RestNodeModel fileNode = restClient.authenticateUser(user).withCoreAPI().usingNode(folder).createNode(); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - FileModel file = new FileModel("content-zip-test.zip"); - file.setCmisLocation(folder.getCmisLocation() + "/content-zip-test.zip"); - file.setNodeRef(fileNode.getId()); - - STEP("3. Create thumbnail of ZIP file using RESTAPI"); - restClient.withCoreAPI().usingNode(file).createNodeRendition("doclib"); - restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); - - STEP("4. Verify thumbnail of ZIP file is created and has content using RESTAPI"); - RestRenditionInfoModel renditionInfo = restClient.withCoreAPI().usingNode(file).getNodeRenditionUntilIsCreated("doclib"); - restClient.assertStatusCodeIs(HttpStatus.OK); - renditionInfo.assertThat().field("status").is("CREATED"); - renditionInfo.assertThat().field("content.sizeInBytes").isGreaterThan(120); - } - - /** - * Sanity test for the following endpoint: - * GET /nodes/{nodeId}/renditions/{renditionId}/content - * @throws Exception - */ - @Test(groups = { TestGroup.REST_API, TestGroup.RENDITIONS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.RENDITIONS }, executionType = ExecutionType.SANITY, - description = "Verify that the rendition content can be downloaded using GET /nodes/{nodeId}/renditions/{renditionId}/content") - public void getRenditionContent() throws Exception - { - STEP("1. Create a folder in existing site"); - FolderModel folder = FolderModel.getRandomFolderModel(); - folder = dataContent.usingUser(user).usingSite(site).createFolder(folder); - - STEP("2. Upload a local txt file using RESTAPI"); - restClient.authenticateUser(user).configureRequestSpec().addMultiPart("filedata", Utility.getResourceTestDataFile("iso8859File.txt")); - - RestNodeModel fileNode = restClient.authenticateUser(user).withCoreAPI().usingNode(folder).createNode(); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - FileModel file = new FileModel("iso8859File.txt"); - file.setCmisLocation(folder.getCmisLocation() + "/iso8859File.txt"); - file.setNodeRef(fileNode.getId()); - - STEP("3. Create thumbnail of txt file using RESTAPI"); - restClient.withCoreAPI().usingNode(file).createNodeRendition("doclib"); - restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); - - STEP("4. Verify thumbnail of txt file is created and has content using RESTAPI"); - RestResponse restResponse = restClient.withCoreAPI().usingNode(file).getNodeRenditionContentUntilIsCreated("doclib"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restClient.assertHeaderValueContains("Content-Type","image/png;charset=UTF-8"); - Assert.assertTrue(restResponse.getResponse().body().asInputStream().available() > 0); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.RENDITIONS, TestGroup.SANITY}) - @TestRail(section = {TestGroup.REST_API, TestGroup.RENDITIONS}, executionType = ExecutionType.SANITY, - description = "Verify the Range request header using GET /nodes/{nodeId}/renditions/{renditionId}/content") - public void getVerifyRangeRequestHeader() throws Exception - { - STEP("1. Create thumbnail on file"); - restClient.authenticateUser(user).withCoreAPI().usingNode(file1).createNodeRendition("pdf"); - restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); - - STEP("2. Make GET rendition content using content-range header"); - Utility.sleep(1000, 30000, () -> { - restClient.configureRequestSpec().addHeader("content-range", "bytes=1-10"); - restClient.authenticateUser(user).withCoreAPI().usingNode(file1).getNodeRenditionContent("pdf"); - restClient.assertStatusCodeIs(HttpStatus.PARTIAL_CONTENT); - restClient.assertHeaderValueContains("content-range", "bytes 1-10"); - restClient.assertHeaderValueContains("content-length", String.valueOf(10)); - }); - } -} - diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/renditions/RenditionIntegrationTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/renditions/RenditionIntegrationTests.java deleted file mode 100644 index 6002aaa48..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/renditions/RenditionIntegrationTests.java +++ /dev/null @@ -1,81 +0,0 @@ -package org.alfresco.service.search.rest.renditions; - -import org.alfresco.rest.core.RestResponse; -import org.alfresco.rest.model.RestNodeModel; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.utility.Utility; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; - -import org.alfresco.utility.model.UserModel; - -import org.springframework.http.HttpStatus; -import org.testng.Assert; -import org.testng.annotations.BeforeClass; - -public abstract class RenditionIntegrationTests extends RestTest -{ - - protected UserModel user; - protected SiteModel site; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - user = dataUser.createRandomTestUser(); - site = dataSite.usingUser(user).createPublicRandomSite(); - } - - /** - * Check that a rendition can be created for the specified node id - * @param fileName - * @param nodeId - * @param renditionId - * @param expectedMimeType - * @throws Exception - */ - protected void checkRendition(String fileName, String nodeId, String renditionId, String expectedMimeType) throws Exception - { - FileModel file = new FileModel(); - file.setNodeRef(nodeId); - - // 1. Create a rendition of the file using RESTAPI - restClient.withCoreAPI().usingNode(file).createNodeRendition(renditionId); - Assert.assertEquals(restClient.getStatusCode(), HttpStatus.ACCEPTED.toString(), - "Failed to submit a request for rendition. [" + fileName+ ", " + renditionId+"] [source file, rendition ID]. "); - - // 2. Verify that a rendition of the file is created and has content using RESTAPI - RestResponse restResponse = restClient.withCoreAPI().usingNode(file).getNodeRenditionContentUntilIsCreated(renditionId); - Assert.assertEquals(restClient.getStatusCode(), HttpStatus.OK.toString(), - "Failed to produce rendition. [" + fileName+ ", " + renditionId+"] [source file, rendition ID] "); - - // 3. Check the returned content type - Assert.assertEquals(restClient.getResponseHeaders().getValue("Content-Type"), expectedMimeType+";charset=UTF-8", - "Rendition was created but it has the wrong Content-Type. [" + fileName+ ", " + renditionId + "] [source file, rendition ID]"); - - - Assert.assertTrue((restResponse.getResponse().body().asInputStream().available() > 0), - "Rendition was created but its content is empty. [" + fileName+ ", " + renditionId+"] [source file, rendition ID] "); - } - - /** - * Upload a file and return its node id - * @param sourceFile - * @return - * @throws Exception - */ - protected RestNodeModel uploadFile(String sourceFile) throws Exception - { - FolderModel folder = FolderModel.getRandomFolderModel(); - folder = dataContent.usingUser(user).usingSite(site).createFolder(folder); - restClient.authenticateUser(user).configureRequestSpec() - .addMultiPart("filedata", Utility.getResourceTestDataFile(sourceFile)); - RestNodeModel fileNode = restClient.authenticateUser(user).withCoreAPI().usingNode(folder).createNode(); - - Assert.assertEquals(restClient.getStatusCode(), HttpStatus.CREATED.toString(), - "Failed to created a node for rendition tests using file " + sourceFile); - - return fileNode; - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/AbstractSearchTest.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/AbstractSearchTest.java deleted file mode 100644 index 37cfdc236..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/AbstractSearchTest.java +++ /dev/null @@ -1,272 +0,0 @@ -/* - * Copyright (C) 2018 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.service.search.rest.search; - -import org.alfresco.dataprep.SiteService.Visibility; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.core.RestResponse; -import org.alfresco.rest.search.RestRequestHighlightModel; -import org.alfresco.rest.search.RestRequestQueryModel; -import org.alfresco.rest.search.SearchRequest; -import org.alfresco.rest.search.SearchResponse; -import org.alfresco.rest.search.SearchSqlRequest; -import org.alfresco.utility.Utility; -import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FileType; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.UserModel; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; - -import javax.naming.AuthenticationException; - -/** - * Abstract Search test class that contains useful methods - * such as: - *
          - *
        • Preparing the data to index. - *
        • Preparing search requests. - * - * @author Michael Suzuki - * @author Meenal Bhave - * - */ -public class AbstractSearchTest extends RestTest -{ - - protected static final String SEARCH_DATA_SAMPLE_FOLDER = "FolderSearch"; - protected UserModel userModel, adminUserModel; - protected SiteModel siteModel; - protected UserModel searchedUser; - protected FileModel file, file2, file3, file4; - - protected static String unique_searchString; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - userModel = dataUser.createRandomTestUser("UserSearch"); - - siteModel = new SiteModel(RandomData.getRandomName("SiteSearch")); - siteModel.setVisibility(Visibility.PRIVATE); - - siteModel = dataSite.usingUser(userModel).createSite(siteModel); - - unique_searchString = siteModel.getTitle().replace("SiteSearch", "Unique"); - - /* - * Create the following file structure for preconditions : - * |- folder - * |-- pangram.txt - * |-- cars.txt - * |-- alfresco.txt - * |-- - */ - - FolderModel folder = new FolderModel(SEARCH_DATA_SAMPLE_FOLDER); - dataContent.usingUser(userModel).usingSite(siteModel).createFolder(folder); - - //Create files - String title = "Title: " + unique_searchString; - String description = "Description: File is created for search tests by Author: " + unique_searchString + " . "; - - file = new FileModel("pangram.txt", "pangram" + title, description, FileType.TEXT_PLAIN, description + " The quick brown fox jumps over the lazy dog"); - - file2 = new FileModel("cars.txt", "cars" + title, description, FileType.TEXT_PLAIN, "The landrover discovery is not a sports car "); - - file3 = new FileModel("alfresco.txt", "alfresco", "alfresco", FileType.TEXT_PLAIN, "Alfresco text file for search "); - - file4 = new FileModel(unique_searchString + ".txt", "uniquee" + title, description, FileType.TEXT_PLAIN, "Unique text file for search "); - - dataContent.usingUser(userModel).usingSite(siteModel).usingResource(folder).createContent(file); - dataContent.usingUser(userModel).usingSite(siteModel).usingResource(folder).createContent(file2); - dataContent.usingUser(userModel).usingSite(siteModel).usingResource(folder).createContent(file3); - dataContent.usingUser(userModel).usingSite(siteModel).usingResource(folder).createContent(file4); - - waitForMetadataIndexing(file4.getName(), true); - } - - /** - * Helper method which create an http post request to Search API end point. - * @param term String search term - * @return {@link SearchResponse} response. - * @throws Exception if error - * - */ - protected SearchResponse query(String term) throws Exception - { - RestRequestQueryModel queryReq = new RestRequestQueryModel(); - queryReq.setLanguage("afts"); - queryReq.setQuery(term); - SearchRequest query = new SearchRequest(queryReq); - return restClient.authenticateUser(userModel).withSearchAPI().search(query); - } - /** - * Helper method which create an http post request to Search API end point. - * @param term String search term - * @return {@link SearchResponse} response. - * @throws Exception if error - * - */ - protected SearchResponse query(RestRequestQueryModel queryReq, RestRequestHighlightModel highlight) throws Exception - { - SearchRequest query = new SearchRequest(queryReq); - query.setHighlight(highlight); - return restClient.authenticateUser(userModel).withSearchAPI().search(query); - } - /** - * - * Helper method which create an http post request to Search API end point. - * Executes the given search request without throwing checked exceptions (a {@link RuntimeException} will be thrown in case). - * @param query the search request. - * @return {@link SearchResponse} response. - * - */ - protected SearchResponse query(SearchRequest query) throws Exception - { - try - { - return restClient.authenticateUser(userModel).withSearchAPI().search(query); - } - catch (final Exception exception) - { - throw new RuntimeException(exception); - } - } - - /** - * Executes an SQL Query using "solr" as output format. - * - * @param sql the SQL statement. - */ - protected RestResponse executeSqlAsSolr(String sql) throws Exception - { - SearchSqlRequest sqlRequest = new SearchSqlRequest(); - sqlRequest.setSql(sql); - sqlRequest.setFormat("solr"); - return searchSql(sqlRequest); - } - - protected SearchRequest createQuery(String term) - { - SearchRequest query = new SearchRequest(); - RestRequestQueryModel queryReq = new RestRequestQueryModel(); - queryReq.setQuery(term); - query.setQuery(queryReq); - return query; - } - - protected SearchRequest carsQuery() - { - return createQuery("cars"); - } - - protected RestResponse searchSql(SearchSqlRequest searchSqlRequest) throws Exception - { - return restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(searchSqlRequest); - } - - /** - * Wait for Solr to finish indexing: Indexing has caught up = true if search returns appropriate results - * - * @param userQuery: search query, this can include the fieldname, unique search string will guarantee accurate results - * @param expectedInResults, true if entry is expected in the results set - * @return true (indexing is finished) if search returns appropriate results - * @throws Exception - */ - public boolean waitForIndexing(String userQuery, boolean expectedInResults) throws Exception - { - // Use the search query as is: fieldname(s) may or may not be specified within the userQuery - return waitForIndexing(null, userQuery, expectedInResults); - } - - /** - * waitForIndexing method that matches / waits for filename, metadata to be indexed. - * @param userQuery - * @param expectedInResults - * @return - * @throws Exception - */ - public boolean waitForMetadataIndexing(String userQuery, boolean expectedInResults) throws Exception - { - return waitForIndexing("name", userQuery, expectedInResults); - } - - /** - * waitForIndexing method that matches / waits for content to be indexed, this can take longer than metadata indexing. - * Since Metadata is indexed first, use this method where tests, queries need content to be indexed too. - * @param userQuery - * @param expectedInResults - * @return - * @throws Exception - */ - public boolean waitForContentIndexing(String userQuery, boolean expectedInResults) throws Exception - { - return waitForIndexing("cm:content", userQuery, expectedInResults); - } - - /** - * Wait for Solr to finish indexing: Indexing has caught up = true if search returns appropriate results - * - * @param fieldName: specific field to search for, e.g. name. When specified, the query will become: name:'userQuery' - * @param userQuery: search string, unique search string will guarantee accurate results - * @param expectedInResults, true if entry is expected in the results set - * @return true (indexing is finished) if search returns appropriate results - * @throws Exception - */ - private boolean waitForIndexing(String fieldName, String userQuery, boolean expectedInResults) throws Exception - { - boolean resultAsExpected = false; - String expectedStatusCode = HttpStatus.OK.toString(); - String query = (fieldName == null)? userQuery: String.format("%s:'%s'", fieldName, userQuery); - - // Repeat search until the query results are as expected or Search Retry count is hit - for (int searchCount = 1; searchCount <= 3; searchCount++) - { - SearchRequest searchRequest = createQuery(query); - SearchResponse response = query(searchRequest); - - if (restClient.getStatusCode().matches(expectedStatusCode)) - { - boolean found = !response.getEntries().isEmpty(); - - // Loop again if result is not as expected: To cater for solr lag: eventual consistency - resultAsExpected = (expectedInResults == found); - if (resultAsExpected) - { - break; - } - else - { - // Wait for the solr indexing. - Utility.waitToLoopTime(properties.getSolrWaitTimeInSeconds(), "Wait For Indexing"); - } - } - else - { - throw new AuthenticationException("API returned status code:" + restClient.getStatusCode() + " Expected: " + expectedStatusCode); - } - } - - return resultAsExpected; - } -} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/FacetFieldsSearchTest.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/FacetFieldsSearchTest.java deleted file mode 100644 index c6c60d8bd..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/FacetFieldsSearchTest.java +++ /dev/null @@ -1,257 +0,0 @@ -/* - * Copyright (C) 2019 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.service.search.rest.search; - -import java.util.ArrayList; -import java.util.List; - -import javax.json.Json; -import javax.json.JsonObject; - -import org.alfresco.dataprep.SiteService.Visibility; -import org.alfresco.rest.search.FacetFieldBucket; -import org.alfresco.rest.search.RestRequestFacetFieldModel; -import org.alfresco.rest.search.RestRequestFacetFieldsModel; -import org.alfresco.rest.search.RestRequestQueryModel; -import org.alfresco.rest.search.RestResultBucketsModel; -import org.alfresco.rest.search.SearchRequest; -import org.alfresco.rest.search.SearchResponse; -import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FileType; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.testng.Assert; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Faceted search test with FacetFields - * @author Meenal Bhave - * - */ -public class FacetFieldsSearchTest extends AbstractSearchTest -{ - private UserModel userWithNoAccess, userCanAccessTextFile; - private SiteModel testSite; - private FolderModel testFolder; - private FileModel textFile, htmlFile; - private String fname; - - @BeforeClass(alwaysRun = true) - public void setupEnvironment() throws Exception - { - serverHealth.assertServerIsOnline(); - - fname = unique_searchString + "facet"; - - testSite = new SiteModel(RandomData.getRandomName("SiteSearch")); - testSite.setVisibility(Visibility.PRIVATE); - - testSite = dataSite.usingUser(userModel).createSite(testSite); - - // Create another user who would not have access to the Private Site created by userModel - userWithNoAccess = dataUser.createRandomTestUser("UserSearch2"); - userCanAccessTextFile = dataUser.createRandomTestUser("UserSearch3"); - - // Create a folder and a file as test User - testFolder = new FolderModel(fname); - dataContent.usingUser(userModel).usingSite(testSite).createFolder(testFolder); - - textFile = new FileModel(fname + "-1.txt", fname, fname, FileType.TEXT_PLAIN, fname + " file for search "); - dataContent.usingUser(userModel).usingSite(testSite).createContent(textFile); - - htmlFile = new FileModel(fname + "-2.html", FileType.HTML, fname + " file 2 for search "); - dataContent.usingUser(userModel).usingSite(testSite).createContent(htmlFile); - - // Set Node Permissions to allow access for user for text File - JsonObject userPermission = Json.createObjectBuilder() - .add("permissions", Json.createObjectBuilder().add("isInheritanceEnabled", false) - .add("locallySet",Json.createObjectBuilder().add("authorityId", userCanAccessTextFile.getUsername()) - .add("name", "SiteConsumer").add("accessStatus", "ALLOWED"))) - .build(); - String putBody = userPermission.toString(); - - restClient.authenticateUser(userModel).withCoreAPI().usingNode(textFile).updateNode(putBody); - - // Wait for the file to be indexed - waitForIndexing(htmlFile.getName(), true); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_121 }) - public void testSearchFacetFieldsBucketExcludedWhenMinCount2() throws Exception - { - // Create Query with FacetFields: Site and Content MimeType - SearchRequest query = new SearchRequest(); - RestRequestQueryModel queryReq = new RestRequestQueryModel(); - queryReq.setQuery("name:" + fname); - query.setQuery(queryReq); - - RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); - List facets = new ArrayList(); - - facets.add(new RestRequestFacetFieldModel("SITE", "SEARCH.FACET_FIELDS.SITE", 0)); // MinCount = 0 - facets.add(new RestRequestFacetFieldModel("cm:content.mimetype", "Mimetype", 2)); // MinCount = 2 - - facetFields.setFacets(facets); - query.setFacetFields(facetFields); - - // Search query using user who created site - SearchResponse response = query(query); - - // Expect MimeType bucket with size 1 is excluded as minCount = 2 won't be reached - Assert.assertEquals(response.getContext().getFacetsFields().size(), 1); - - // Expect SITE bucket is included and MinCount defaults to 1 - RestResultBucketsModel facetFieldList = response.getContext().getFacetsFields().get(0); - Assert.assertEquals(facetFieldList.getLabel(), "SEARCH.FACET_FIELDS.SITE"); - Assert.assertEquals(facetFieldList.getBuckets().size(), 1); - - FacetFieldBucket bucket1 = facetFieldList.getBuckets().get(0); - bucket1.assertThat().field("label").is(testSite.getId()); - bucket1.assertThat().field("filterQuery").contains(testSite.getId()); - bucket1.assertThat().field("count").is(3); // One folder and 2 files created above - - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_121 }) - public void testSearchWithFacetFieldsMinCountChecks() throws Exception - { - SearchRequest query = new SearchRequest(); - RestRequestQueryModel queryReq = new RestRequestQueryModel(); - queryReq.setQuery("name:" + fname); - query.setQuery(queryReq); - - RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); - List facets = new ArrayList(); - - // MinCount not set - facets.add(new RestRequestFacetFieldModel("SITE", "SEARCH.FACET_FIELD1.SITE", null)); // MinCount Not set - facets.add(new RestRequestFacetFieldModel("cm:content.mimetype", "SEARCH.FACET_FIELD2.Mimetype", 1)); // MinCount = 1 - - facetFields.setFacets(facets); - query.setFacetFields(facetFields); - - // Search query using user who created site - SearchResponse response = query(query); - - // Expect 2 Facet buckets to be retrieved: MinCount when not set defaults to 1 - List facetFieldBucketsList = response.getContext().getFacetsFields(); - Assert.assertEquals(facetFieldBucketsList.size(), 2, "FacetField"); - - RestResultBucketsModel facetFieldList = facetFieldBucketsList.get(0); - Assert.assertEquals(facetFieldList.getLabel(), "SEARCH.FACET_FIELD1.SITE"); - - FacetFieldBucket bucket1 = facetFieldList.getBuckets().get(0); - bucket1.assertThat().field("label").is(testSite.getId()); - bucket1.assertThat().field("filterQuery").contains(testSite.getId()); - bucket1.assertThat().field("count").is(3); - - // MimeType bucket will be shown with 2 buckets - facetFieldList = facetFieldBucketsList.get(1); - Assert.assertEquals(facetFieldList.getLabel(), "SEARCH.FACET_FIELD2.Mimetype"); - Assert.assertEquals(facetFieldList.getBuckets().size(), 2); - - bucket1 = facetFieldList.getBuckets().get(0); - bucket1.assertThat().field("label").is("text/html"); - bucket1.assertThat().field("filterQuery").contains("text/html"); - bucket1.assertThat().field("count").is(1); - bucket1.assertThat().field("display").is("HTML"); - - bucket1 = facetFieldList.getBuckets().get(1); - bucket1.assertThat().field("label").is("text/plain"); - bucket1.assertThat().field("filterQuery").contains("text/plain"); - bucket1.assertThat().field("count").is(1); - bucket1.assertThat().field("display").is("Plain Text"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_121 }) - public void testSearchWithFacetFieldsNoFacetsWhenNoAccess() throws Exception - { - SearchRequest query = new SearchRequest(); - RestRequestQueryModel queryReq = new RestRequestQueryModel(); - queryReq.setQuery("name:" + fname); - query.setQuery(queryReq); - - RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); - List facets = new ArrayList(); - - facets.add(new RestRequestFacetFieldModel("SITE", "SEARCH.FACET_FIELD1.SITE", null)); // MinCount Not set - facets.add(new RestRequestFacetFieldModel("cm:content.mimetype", "SEARCH.FACET_FIELD2.Mimetype", 1)); // MinCount = 1 - - facetFields.setFacets(facets); - query.setFacetFields(facetFields); - - // Search query using other user - SearchResponse response = restClient.authenticateUser(userWithNoAccess).withSearchAPI().search(query); - - // User has No access to matching content hence no buckets expected - Assert.assertNull(response.getContext().getFacetsFields()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_121 }) - public void testSearchWithFacetFieldsOnlyFacetsWhereAccess() throws Exception - { - SearchRequest query = new SearchRequest(); - RestRequestQueryModel queryReq = new RestRequestQueryModel(); - queryReq.setQuery("name:" + fname); - query.setQuery(queryReq); - - RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); - List facets = new ArrayList(); - - facets.add(new RestRequestFacetFieldModel("SITE", "SEARCH.FACET_FIELD1.SITE", null)); // MinCount Not set - facets.add(new RestRequestFacetFieldModel("cm:content.mimetype", "SEARCH.FACET_FIELD2.Mimetype", 1)); // MinCount = 1 - - facetFields.setFacets(facets); - query.setFacetFields(facetFields); - - // Search query using user that can access 1 text file - SearchResponse response = restClient.authenticateUser(userCanAccessTextFile).withSearchAPI().search(query); - - List facetFieldBucketsList = response.getContext().getFacetsFields(); - Assert.assertEquals(facetFieldBucketsList.size(), 2); - - // Check FacetField 1 - RestResultBucketsModel facetFieldList = facetFieldBucketsList.get(0); - - // User has granular permissions to content within this private site, so expect the Site bucket - Assert.assertEquals(facetFieldList.getLabel(), "SEARCH.FACET_FIELD1.SITE"); - - FacetFieldBucket bucket1 = facetFieldList.getBuckets().get(0); - bucket1.assertThat().field("label").is(testSite.getId()); - bucket1.assertThat().field("filterQuery").contains(testSite.getId()); - bucket1.assertThat().field("count").is(1); - - // Expect MimeType bucket shows only 1 bucket where user has access to content - facetFieldList = facetFieldBucketsList.get(1); - Assert.assertEquals(facetFieldList.getLabel(), "SEARCH.FACET_FIELD2.Mimetype"); - Assert.assertEquals(facetFieldList.getBuckets().size(), 1); - - // User has access to text file alone, so expect bucket for text/plain and not for html content. - bucket1 = facetFieldList.getBuckets().get(0); - bucket1.assertThat().field("label").is("text/plain"); - bucket1.assertThat().field("label").isNot("text/html"); - bucket1.assertThat().field("filterQuery").contains("text/plain"); - bucket1.assertThat().field("count").is(1); - bucket1.assertThat().field("display").is("Plain Text"); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/FacetIntervalSearchTest.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/FacetIntervalSearchTest.java deleted file mode 100644 index a624d44f2..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/FacetIntervalSearchTest.java +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Copyright (C) 2017 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.service.search.rest.search; - -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.search.FacetInterval; -import org.alfresco.rest.search.RestGenericBucketModel; -import org.alfresco.rest.search.RestGenericFacetResponseModel; -import org.alfresco.rest.search.RestRequestFacetIntervalsModel; -import org.alfresco.rest.search.RestRequestFacetSetModel; -import org.alfresco.rest.search.SearchRequest; -import org.alfresco.rest.search.SearchResponse; -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.Assert; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import java.util.Arrays; - -/** - * Faceted Intervals Search Test - * @author Gethin James - * - */ -public class FacetIntervalSearchTest extends AbstractSearchTest -{ - @BeforeClass(alwaysRun = true) - public void setupEnvironment() throws Exception - { - waitForContentIndexing(file4.getContent(), true); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, - description = "Check facet intervals mandatory fields") - public void checkingFacetsMandatoryErrorMessages()throws Exception - { - SearchRequest query = carsQuery(); - - RestRequestFacetIntervalsModel facetIntervalsModel = new RestRequestFacetIntervalsModel(); - FacetInterval facetInterval = new FacetInterval(null, null, null); - facetIntervalsModel.setIntervals(Arrays.asList(facetInterval)); - query.setFacetIntervals(facetIntervalsModel); - - query(query); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.MANDATORY_PARAM, "facetIntervals intervals field")); - facetInterval.setField("created"); - query(query); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.MANDATORY_COLLECTION, "facetIntervals intervals sets")); - - RestRequestFacetSetModel restFacetSetModel = new RestRequestFacetSetModel(); - restFacetSetModel.setLabel("theRest"); - facetInterval.setSets(Arrays.asList(restFacetSetModel)); - query(query); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.MANDATORY_PARAM, "facetIntervals intervals created sets start")); - - restFacetSetModel.setStart("A"); - query(query); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.MANDATORY_PARAM, "facetIntervals intervals created sets end")); - - restFacetSetModel.setEnd("B"); - RestRequestFacetSetModel duplicate = new RestRequestFacetSetModel(); - facetInterval.setSets(Arrays.asList(restFacetSetModel,duplicate)); - duplicate.setLabel("theRest"); - duplicate.setStart("A"); - duplicate.setEnd("C"); - - query(query); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary("duplicate set interval label [theRest=2]"); - - facetInterval.setSets(Arrays.asList(restFacetSetModel)); - facetInterval.setLabel("thesame"); - FacetInterval duplicateLabel = new FacetInterval("creator", "thesame", Arrays.asList(duplicate)); - facetIntervalsModel.setIntervals(Arrays.asList(facetInterval, duplicateLabel)); - query.setFacetIntervals(facetIntervalsModel); - - query(query); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary("duplicate interval label [thesame=2]"); - - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, - description = "Check basic facet intervals search api") - public void searchWithBasicInterval()throws Exception - { - SearchRequest query = carsQuery(); - - RestRequestFacetIntervalsModel facetIntervalsModel = new RestRequestFacetIntervalsModel(); - RestRequestFacetSetModel restRequestFacetSetModel = new RestRequestFacetSetModel(); - restRequestFacetSetModel.setStart("a"); - restRequestFacetSetModel.setEnd("user"); - restRequestFacetSetModel.setLabel("aUser"); - - RestRequestFacetSetModel restFacetSetModel = new RestRequestFacetSetModel(); - restFacetSetModel.setStart("user"); - restFacetSetModel.setEnd("z"); - restFacetSetModel.setStartInclusive(false); - restFacetSetModel.setLabel("theRest"); - - FacetInterval facetInterval = new FacetInterval("creator", null, Arrays.asList(restRequestFacetSetModel, restFacetSetModel)); - facetIntervalsModel.setIntervals(Arrays.asList(facetInterval)); - query.setFacetIntervals(facetIntervalsModel); - - SearchResponse response = query(query); - response.assertThat().entriesListIsNotEmpty(); - response.getContext().assertThat().field("facets").isNotEmpty(); - RestGenericFacetResponseModel facetResponseModel = response.getContext().getFacets().get(0); - - RestGenericBucketModel bucket = facetResponseModel.getBuckets().get(0); - Assert.assertEquals(facetResponseModel.getBuckets().size(), 2); - bucket.assertThat().field("label").is("aUser"); - bucket.assertThat().field("filterQuery").is("creator:[\"a\" TO \"user\"]"); - bucket.getMetrics().get(0).assertThat().field("type").is("count"); - bucket.getMetrics().get(0).assertThat().field("value").contains("{count="); - - bucket = facetResponseModel.getBuckets().get(1); - - bucket.assertThat().field("label").is("theRest"); - bucket.assertThat().field("filterQuery").is("creator:<\"user\" TO \"z\"]"); - bucket.getMetrics().get(0).assertThat().field("type").is("count"); - bucket.getMetrics().get(0).assertThat().field("value").is("{count=0}"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, - description = "Check date facet intervals search api") - public void searchWithDates() throws Exception - { - SearchRequest query = carsQuery(); - - RestRequestFacetIntervalsModel facetIntervalsModel = new RestRequestFacetIntervalsModel(); - RestRequestFacetSetModel restRequestFacetSetModel = new RestRequestFacetSetModel(); - restRequestFacetSetModel.setStart("*"); - restRequestFacetSetModel.setEnd("2016"); - restRequestFacetSetModel.setEndInclusive(false); - restRequestFacetSetModel.setLabel("Before2016"); - - RestRequestFacetSetModel restFacetSetModel = new RestRequestFacetSetModel(); - restFacetSetModel.setStart("2016"); - restFacetSetModel.setEnd("now"); - restFacetSetModel.setLabel("From2016"); - - FacetInterval facetInterval = new FacetInterval("cm:modified", "modified", Arrays.asList(restRequestFacetSetModel, restFacetSetModel)); - facetIntervalsModel.setIntervals(Arrays.asList(facetInterval)); - query.setFacetIntervals(facetIntervalsModel); - - SearchResponse response = query(query); - response.assertThat().entriesListIsNotEmpty(); - response.getContext().assertThat().field("facets").isNotEmpty(); - RestGenericFacetResponseModel facetResponseModel = response.getContext().getFacets().get(0); - - facetResponseModel.assertThat().field("label").is("modified"); - RestGenericBucketModel bucket = facetResponseModel.getBuckets().get(0); - Assert.assertEquals(facetResponseModel.getBuckets().size(), 2); - - bucket.assertThat().field("label").is("From2016"); - bucket.assertThat().field("filterQuery").is("cm:modified:[\"2016\" TO \"now\"]"); - bucket.getMetrics().get(0).assertThat().field("type").is("count"); - bucket.getMetrics().get(0).assertThat().field("value").contains("{count="); - - - bucket = facetResponseModel.getBuckets().get(1); - - bucket.assertThat().field("label").is("Before2016"); - bucket.assertThat().field("filterQuery").is("cm:modified:[\"*\" TO \"2016\">"); - bucket.getMetrics().get(0).assertThat().field("type").is("count"); - bucket.getMetrics().get(0).assertThat().field("value").is("{count=0}"); - } - -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/FacetRangeSearchTest.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/FacetRangeSearchTest.java deleted file mode 100644 index fb798662f..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/FacetRangeSearchTest.java +++ /dev/null @@ -1,346 +0,0 @@ -/* - * Copyright (C) 2017 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.service.search.rest.search; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.core.Is.is; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestRequestRangesModel; -import org.alfresco.rest.search.RestGenericBucketModel; -import org.alfresco.rest.search.RestGenericFacetResponseModel; -import org.alfresco.rest.search.SearchRequest; -import org.alfresco.rest.search.SearchResponse; -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.Assert; -import org.testng.annotations.Test; - -/** - * Faceted Range Search Query for numeric range - * { - * "query": { - * "query": "name:A*" - * }, - * "range": { - * "field": "content.size", - * "start": "0", - * "end": "400", - * "gap": "100" - * } - * } - * Date range query: - * { - * "query": { - * "query": "name:A*" - * }, - * "range": { - * "field": "created", - * "start": "2015-09-29T10:45:15.729Z", - * "end": "2016-09-29T10:45:15.729Z", - * "gap": "+100DAY" - * } - * } - * @author Michael Suzuki - * - */ -public class FacetRangeSearchTest extends AbstractSearchTest -{ - - @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, - description = "Check facet intervals mandatory fields") - public void checkingFacetsMandatoryErrorMessages()throws Exception - { - SearchRequest query = carsQuery(); - List ranges = new ArrayList(); - RestRequestRangesModel facetRangeModel = new RestRequestRangesModel(); - ranges.add(facetRangeModel); - query.setRanges(ranges); - query(query); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.MANDATORY_PARAM, "field")); - ranges.clear(); - facetRangeModel.setField("content.size"); - ranges.add(facetRangeModel); - query.setRanges(ranges); - - query(query); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.MANDATORY_PARAM, "start")); - facetRangeModel.setStart("0"); - ranges.clear(); - ranges.add(facetRangeModel); - query.setRanges(ranges); - - query(query); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.MANDATORY_PARAM, "end")); - facetRangeModel.setEnd("400"); - query.setRanges(ranges); - ranges.clear(); - ranges.add(facetRangeModel); - - query(query); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.MANDATORY_PARAM, "gap")); - - facetRangeModel.setGap("100"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, - description = "Check basic facet range search api") - public void searchWithRange()throws Exception - { - SearchRequest query = createQuery("A*"); - - RestRequestRangesModel facetRangeModel = new RestRequestRangesModel(); - facetRangeModel.setField("content.size"); - facetRangeModel.setStart("0"); - facetRangeModel.setEnd("500"); - facetRangeModel.setGap("200"); - List ranges = new ArrayList(); - ranges.add(facetRangeModel); - query.setRanges(ranges); - SearchResponse response = query(query); - response.assertThat().entriesListIsNotEmpty(); - response.getContext().assertThat().field("facets").isNotEmpty(); - RestGenericFacetResponseModel facetResponseModel = response.getContext().getFacets().get(0); - - RestGenericBucketModel bucket = facetResponseModel.getBuckets().get(0); - bucket.assertThat().field("label").is("[0 - 200)"); - bucket.assertThat().field("filterQuery").is("content.size:[\"0\" TO \"200\">"); - Map metric = (Map) bucket.getMetrics().get(0).getValue(); - Assert.assertTrue(Integer.valueOf(metric.get("count")) >= 4); - Map info = (Map) bucket.getBucketInfo(); - Assert.assertEquals(info.get("start"),"0"); - Assert.assertEquals(info.get("end"),"200"); - Assert.assertNull(info.get("count")); - Assert.assertEquals(info.get("startInclusive"),"true"); - Assert.assertEquals(info.get("endInclusive"),"false"); - - bucket = facetResponseModel.getBuckets().get(1); - bucket.assertThat().field("label").is("[200 - 400)"); - bucket.assertThat().field("filterQuery").is("content.size:[\"200\" TO \"400\">"); - metric = (Map) bucket.getMetrics().get(0).getValue(); - Integer count = Integer.valueOf(metric.get("count")); - Assert.assertTrue(count >= 4); - info = (Map) bucket.getBucketInfo(); - Assert.assertEquals(info.get("start"),"200"); - Assert.assertEquals(info.get("end"),"400"); - Assert.assertEquals(info.get("startInclusive"),"true"); - Assert.assertEquals(info.get("endInclusive"),"false"); - - bucket = facetResponseModel.getBuckets().get(2); - bucket.assertThat().field("label").is("[400 - 600]"); - bucket.assertThat().field("filterQuery").is("content.size:[\"400\" TO \"600\"]"); - metric = (Map) bucket.getMetrics().get(0).getValue(); - Assert.assertTrue(Integer.valueOf(metric.get("count")) >= 7); - info = (Map) bucket.getBucketInfo(); - Assert.assertEquals(info.get("start"),"400"); - Assert.assertEquals(info.get("end"),"600"); - Assert.assertEquals(info.get("startInclusive"),"true"); - Assert.assertEquals(info.get("endInclusive"),"true"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, - description = "Check date facet intervals search api") - public void searchWithRangeHardend()throws Exception - { - SearchRequest query = createQuery("A*"); - - RestRequestRangesModel facetRangeModel = new RestRequestRangesModel(); - facetRangeModel.setField("content.size"); - facetRangeModel.setStart("0"); - facetRangeModel.setEnd("500"); - facetRangeModel.setGap("200"); - facetRangeModel.setHardend(true); - List ranges = new ArrayList(); - ranges.add(facetRangeModel); - query.setRanges(ranges); - SearchResponse response = query(query); - response.assertThat().entriesListIsNotEmpty(); - response.getContext().assertThat().field("facets").isNotEmpty(); - RestGenericFacetResponseModel facetResponseModel = response.getContext().getFacets().get(0); - - RestGenericBucketModel bucket = facetResponseModel.getBuckets().get(0); - bucket.assertThat().field("label").is("[0 - 200)"); - bucket.assertThat().field("filterQuery").is("content.size:[\"0\" TO \"200\">"); - Map metric = (Map) bucket.getMetrics().get(0).getValue(); - Assert.assertTrue(Integer.valueOf(metric.get("count")) >= 4); - Map info = (Map) bucket.getBucketInfo(); - Assert.assertEquals(info.get("start"),"0"); - Assert.assertEquals(info.get("end"),"200"); - Assert.assertEquals(info.get("startInclusive"),"true"); - Assert.assertEquals(info.get("endInclusive"),"false"); - Assert.assertNull(info.get("count")); - - bucket = facetResponseModel.getBuckets().get(1); - bucket.assertThat().field("label").is("[200 - 400)"); - bucket.assertThat().field("filterQuery").is("content.size:[\"200\" TO \"400\">"); - info = (Map) bucket.getBucketInfo(); - Assert.assertEquals(info.get("start"),"200"); - Assert.assertEquals(info.get("end"),"400"); - metric = (Map) bucket.getMetrics().get(0).getValue(); - Assert.assertTrue(Integer.valueOf(metric.get("count")) >= 4); - Assert.assertNull(info.get("count")); - Assert.assertEquals(info.get("startInclusive"),"true"); - Assert.assertEquals(info.get("endInclusive"),"false"); - - bucket = facetResponseModel.getBuckets().get(2); - bucket.assertThat().field("label").is("[400 - 500]"); - bucket.assertThat().field("filterQuery").is("content.size:[\"400\" TO \"500\"]"); - metric = (Map) bucket.getMetrics().get(0).getValue(); - Assert.assertTrue(Integer.valueOf(metric.get("count")) >= 3); - info = (Map) bucket.getBucketInfo(); - Assert.assertEquals(info.get("start"),"400"); - Assert.assertEquals(info.get("end"),"500"); - Assert.assertNull(info.get("count")); - Assert.assertEquals(info.get("startInclusive"),"true"); - Assert.assertEquals(info.get("endInclusive"),"true"); - } - @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_121 }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_121 }, executionType = ExecutionType.REGRESSION, - description = "Check date facet intervals search api") - public void searchDateRange()throws Exception - { - SearchRequest query = createQuery("name:A*"); - - RestRequestRangesModel facetRangeModel = new RestRequestRangesModel(); - facetRangeModel.setField("created"); - facetRangeModel.setStart("2015-09-29T10:45:15.729Z"); - facetRangeModel.setEnd("2016-09-29T10:45:15.729Z"); - facetRangeModel.setGap("+280DAY"); - List ranges = new ArrayList(); - ranges.add(facetRangeModel); - query.setRanges(ranges); - SearchResponse response = query(query); - response.assertThat().entriesListIsNotEmpty(); - response.getContext().assertThat().field("facets").isNotEmpty(); - RestGenericFacetResponseModel facetResponseModel = response.getContext().getFacets().get(0); - - List buckets = facetResponseModel.getBuckets(); - assertThat(buckets.size(),is(1)); - - RestGenericBucketModel bucket = buckets.get(0); - bucket.assertThat().field("label").is("[2015-09-29T10:45:15.729Z - 2017-04-11T10:45:15.729Z]"); - bucket.assertThat().field("filterQuery").is("created:[\"2015-09-29T10:45:15.729Z\" TO \"2017-04-11T10:45:15.729Z\"]"); - bucket.getMetrics().get(0).assertThat().field("value").is("{count=1}"); - Map info = (Map) bucket.getBucketInfo(); - Assert.assertEquals(info.get("start"),"2015-09-29T10:45:15.729Z"); - Assert.assertEquals(info.get("end"),"2017-04-11T10:45:15.729Z"); - Assert.assertNull(info.get("count"),"1"); - Assert.assertEquals(info.get("startInclusive"),"true"); - Assert.assertEquals(info.get("endInclusive"),"true"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, - description = "Check date facet intervals search api") - public void searchDateAndSizeRanges()throws Exception - { - SearchRequest query = createQuery("name:A*"); - List ranges = new ArrayList(); - RestRequestRangesModel facetRangeModel = new RestRequestRangesModel(); - facetRangeModel.setField("created"); - facetRangeModel.setStart("2015-09-29T10:45:15.729Z"); - facetRangeModel.setEnd("2016-09-29T10:45:15.729Z"); - facetRangeModel.setGap("+280DAY"); - ranges.add(facetRangeModel); - RestRequestRangesModel facetCountRangeModel = new RestRequestRangesModel(); - facetCountRangeModel.setField("content.size"); - facetCountRangeModel.setStart("0"); - facetCountRangeModel.setEnd("500"); - facetCountRangeModel.setGap("200"); - ranges.add(facetCountRangeModel); - query.setRanges(ranges); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, - description = "Check basic facet range search api") - public void searchWithRangeAndIncludeUpperBound()throws Exception - { - SearchRequest query = createQuery("A*"); - - RestRequestRangesModel facetRangeModel = new RestRequestRangesModel(); - facetRangeModel.setField("content.size"); - facetRangeModel.setStart("0"); - facetRangeModel.setEnd("500"); - facetRangeModel.setGap("200"); - List include = new ArrayList(); - include.add("upper"); - facetRangeModel.setInclude(include); - List ranges = new ArrayList(); - ranges.add(facetRangeModel); - query.setRanges(ranges); - SearchResponse response = query(query); - response.assertThat().entriesListIsNotEmpty(); - response.getContext().assertThat().field("facets").isNotEmpty(); - RestGenericFacetResponseModel facetResponseModel = response.getContext().getFacets().get(0); - - RestGenericBucketModel bucket = facetResponseModel.getBuckets().get(0); - bucket.assertThat().field("label").is("(0 - 200]"); - bucket.assertThat().field("filterQuery").is("content.size:<\"0\" TO \"200\"]"); - Map metric = (Map) bucket.getMetrics().get(0).getValue(); - Assert.assertTrue(Integer.valueOf(metric.get("count")) >= 4); - Map info = (Map) bucket.getBucketInfo(); - Assert.assertEquals(info.get("start"),"0"); - Assert.assertEquals(info.get("end"),"200"); - Assert.assertNull(info.get("count")); - Assert.assertEquals(info.get("startInclusive"),"false"); - Assert.assertEquals(info.get("endInclusive"),"true"); - - bucket = facetResponseModel.getBuckets().get(1); - bucket.assertThat().field("label").is("(200 - 400]"); - bucket.assertThat().field("filterQuery").is("content.size:<\"200\" TO \"400\"]"); - metric = (Map) bucket.getMetrics().get(0).getValue(); - Integer count = Integer.valueOf(metric.get("count")); - Assert.assertTrue(count >= 4); - info = (Map) bucket.getBucketInfo(); - Assert.assertEquals(info.get("start"),"200"); - Assert.assertEquals(info.get("end"),"400"); - Assert.assertEquals(info.get("startInclusive"),"false"); - Assert.assertEquals(info.get("endInclusive"),"true"); - - bucket = facetResponseModel.getBuckets().get(2); - bucket.assertThat().field("label").is("(400 - 600]"); - bucket.assertThat().field("filterQuery").is("content.size:<\"400\" TO \"600\"]"); - metric = (Map) bucket.getMetrics().get(0).getValue(); - Assert.assertTrue(Integer.valueOf(metric.get("count")) >= 7); - info = (Map) bucket.getBucketInfo(); - Assert.assertEquals(info.get("start"),"400"); - Assert.assertEquals(info.get("end"),"600"); - Assert.assertEquals(info.get("startInclusive"),"false"); - Assert.assertEquals(info.get("endInclusive"),"true"); - } - -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/PivotFacetedSearchTest.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/PivotFacetedSearchTest.java deleted file mode 100644 index 54e99bb86..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/PivotFacetedSearchTest.java +++ /dev/null @@ -1,281 +0,0 @@ -/* - * Copyright (C) 2017 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.service.search.rest.search; - -import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestRequestRangesModel; -import org.alfresco.rest.search.Pagination; -import org.alfresco.rest.search.RestGenericBucketModel; -import org.alfresco.rest.search.RestGenericFacetResponseModel; -import org.alfresco.rest.search.RestRequestFacetFieldModel; -import org.alfresco.rest.search.RestRequestFacetFieldsModel; -import org.alfresco.rest.search.RestRequestPivotModel; -import org.alfresco.rest.search.SearchRequest; -import org.alfresco.rest.search.SearchResponse; -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.Assert; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Faceted search test. - * @author Gethin James - * - */ -public class PivotFacetedSearchTest extends AbstractSearchTest -{ - @BeforeClass(alwaysRun = true) - public void setupEnvironment() throws Exception - { - waitForContentIndexing(file4.getContent(), true); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, - executionType = ExecutionType.REGRESSION, - description = "Checks errors with pivot using Search api") - public void searchWithPivotingErrors() throws Exception - { - SearchRequest query = carsQuery(); - - RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); - List list = new ArrayList<>(); - list.add(new RestRequestFacetFieldModel("'creator'")); - facetFields.setFacets(list); - query.setFacetFields(facetFields); - query.setIncludeRequest(false); - List pivotModelList = new ArrayList<>(); - RestRequestPivotModel pivots = new RestRequestPivotModel(); - pivotModelList.add(pivots); - query.setPivots(pivotModelList); - - query(query); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.MANDATORY_PARAM, "pivot key")); - - pivots.setKey("none_like_this"); - - query(query); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary("invalid argument was received") - .containsSummary("Pivot parameter none_like_this does not reference"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, - executionType = ExecutionType.REGRESSION, - description = "Checks with pivot using Search api") - public void searchWithPivoting() throws Exception - { - SearchRequest query = carsQuery(); - - RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); - List list = new ArrayList<>(); - list.add(new RestRequestFacetFieldModel("creator")); - facetFields.setFacets(list); - query.setFacetFields(facetFields); - query.setIncludeRequest(false); - - SearchResponse response = query(query); - response.getContext().assertThat().field("facetsFields").isNotNull(); - - List pivotModelList = new ArrayList<>(); - RestRequestPivotModel pivots = new RestRequestPivotModel(); - pivots.setKey("creator"); - pivotModelList.add(pivots); - query.setPivots(pivotModelList); - response = query(query); - - //Pivot key has matched facet field so there is no longer a facet fields response - assertPivotResponse(response, "creator", null); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, - executionType = ExecutionType.REGRESSION, - description = "Checks nested pivot using Search api") - public void searchWithNestedPivoting() throws Exception - { - SearchRequest query = carsQuery(); - - RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); - List list = new ArrayList<>(); - RestRequestFacetFieldModel restRequestFacetFieldModel = new RestRequestFacetFieldModel("SITE"); - restRequestFacetFieldModel.setLabel("site"); - list.add(restRequestFacetFieldModel); - list.add(new RestRequestFacetFieldModel("creator")); - list.add(new RestRequestFacetFieldModel("modifier")); - facetFields.setFacets(list); - query.setFacetFields(facetFields); - query.setIncludeRequest(false); - - List pivotModelList = new ArrayList<>(); - RestRequestPivotModel sitepivots = new RestRequestPivotModel(); - sitepivots.setKey("site"); - RestRequestPivotModel creatorpivot = new RestRequestPivotModel(); - creatorpivot.setKey("creator"); - RestRequestPivotModel modifierpivot = new RestRequestPivotModel(); - modifierpivot.setKey("modifier"); - sitepivots.setPivots(Arrays.asList(creatorpivot, modifierpivot)); - pivotModelList.add(sitepivots); - query.setPivots(pivotModelList); - - SearchResponse response = query(query); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary("invalid argument was received") - .containsSummary("Currently only 1 nested pivot is supported, you have 2"); - - pivotModelList = new ArrayList<>(); - sitepivots = new RestRequestPivotModel(); - sitepivots.setKey("site"); - sitepivots.setPivots(Arrays.asList(modifierpivot)); - pivotModelList.add(sitepivots); - pivotModelList.add(creatorpivot); - query.setPivots(pivotModelList); - - response = query(query); - assertPivotResponse(response, "SITE", "site"); - - RestGenericFacetResponseModel siteResponse = response.getContext().getFacets().get(0); - RestGenericBucketModel bucket = siteResponse.getBuckets().get(0); - RestGenericFacetResponseModel modifiedResponse = bucket.getFacets().get(0); - modifiedResponse.assertThat().field("type").is("pivot"); - modifiedResponse.assertThat().field("label").is("modifier"); - - RestGenericFacetResponseModel creatorResponse = response.getContext().getFacets().get(1); - creatorResponse.assertThat().field("type").is("pivot"); - creatorResponse.assertThat().field("label").is("creator"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, - executionType = ExecutionType.REGRESSION, - description = "Checks range pivots using Search api") - public void searchWithRangePivoting() throws Exception - { - SearchRequest query = carsQuery(); - - String endDate = LocalDateTime.now() - .format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss'Z'")); //the car document is created at runtime, so to include it in range facets end date must be now - - Pagination pagination = new Pagination(); - pagination.setMaxItems(2); - query.setPaging(pagination); - RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); - List list = new ArrayList<>(); - list.add(new RestRequestFacetFieldModel("creator")); - facetFields.setFacets(list); - query.setFacetFields(facetFields); - query.setIncludeRequest(false); - - RestRequestRangesModel facetRangeModel = new RestRequestRangesModel(); - facetRangeModel.setField("created"); - facetRangeModel.setStart("2015-09-29T10:45:15.729Z"); - facetRangeModel.setEnd(endDate); - facetRangeModel.setGap("+280DAY"); - facetRangeModel.setLabel("aRange"); - List ranges = new ArrayList(); - ranges.add(facetRangeModel); - query.setRanges(ranges); - - List pivotModelList = new ArrayList<>(); - RestRequestPivotModel creatorpivot = new RestRequestPivotModel(); - creatorpivot.setKey("creator"); - RestRequestPivotModel rangepivot = new RestRequestPivotModel(); - rangepivot.setKey("aRange"); - creatorpivot.setPivots(Arrays.asList(rangepivot)); - pivotModelList.add(creatorpivot); - query.setPivots(pivotModelList); - - SearchResponse response = query(query); - RestGenericFacetResponseModel facetResponseModel = response.getContext().getFacets().get(1); - facetResponseModel.assertThat().field("type").is("pivot"); - facetResponseModel.assertThat().field("label").is("creator"); - RestGenericBucketModel bucket = facetResponseModel.getBuckets().get(0); - RestGenericFacetResponseModel rangeResponse = bucket.getFacets().get(0); - rangeResponse.assertThat().field("type").is("range"); - } - - private void assertPivotResponse(SearchResponse response, String field, String alabel) throws Exception - { - String label = alabel!=null?alabel:field; - response.getContext().assertThat().field("facetsFields").isNull(); - response.getContext().assertThat().field("facets").isNotEmpty(); - RestGenericFacetResponseModel facetResponseModel = response.getContext().getFacets().get(0); - facetResponseModel.assertThat().field("type").is("pivot"); - facetResponseModel.assertThat().field("label").is(label); - RestGenericBucketModel bucket = facetResponseModel.getBuckets().get(0); - bucket.assertThat().field("label").isNotEmpty(); - bucket.assertThat().field("filterQuery").is(field+":\""+bucket.getLabel()+"\""); - Assert.assertEquals("count", bucket.getMetrics().get(0).getType()); - Assert.assertTrue(bucket.getMetrics().get(0).getValue().toString().contains("{count=")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, - executionType = ExecutionType.REGRESSION, - description = "Checks with pivot using Search api and a label as a key") - public void searchWithPivotingUsingLabel() throws Exception - { - SearchRequest query = carsQuery(); - RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); - List list = new ArrayList<>(); - RestRequestFacetFieldModel creatorFacetFieldModel = new RestRequestFacetFieldModel("creator"); - creatorFacetFieldModel.setLabel("create"); - list.add(creatorFacetFieldModel); - RestRequestFacetFieldModel restRequestFacetFieldModel = new RestRequestFacetFieldModel("modifier"); - restRequestFacetFieldModel.setLabel("aLabel"); - list.add(restRequestFacetFieldModel); - facetFields.setFacets(list); - query.setFacetFields(facetFields); - query.setIncludeRequest(false); - RestRequestPivotModel pivots = new RestRequestPivotModel(); - pivots.setKey("create"); - RestRequestPivotModel pivotmod = new RestRequestPivotModel(); - pivotmod.setKey("aLabel"); - - List pivotModelList = new ArrayList<>(); - pivotModelList.add(pivots); - pivotModelList.add(pivotmod); - query.setPivots(pivotModelList); - SearchResponse response = query(query); - assertPivotResponse(response, "creator", "create"); - - //Now check the nesting - RestGenericFacetResponseModel labelResponseModel = response.getContext().getFacets().get(1); - labelResponseModel.assertThat().field("type").is("pivot"); - labelResponseModel.assertThat().field("label").isNotEmpty(); - labelResponseModel.assertThat().field("label").is("aLabel"); - RestGenericBucketModel bucket = labelResponseModel.getBuckets().get(0); - bucket.assertThat().field("filterQuery").is("modifier:\""+bucket.getLabel()+"\""); - Assert.assertEquals("count", bucket.getMetrics().get(0).getType()); - Assert.assertTrue(bucket.getMetrics().get(0).getValue().toString().contains("{count=")); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/SearchHighLightTest.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/SearchHighLightTest.java deleted file mode 100644 index 1c03c9b47..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/SearchHighLightTest.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (C) 2017 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.service.search.rest.search; - -import java.util.ArrayList; -import java.util.List; - -import org.alfresco.rest.search.ResponseHighLightModel; -import org.alfresco.rest.search.RestRequestFieldsModel; -import org.alfresco.rest.search.RestRequestHighlightModel; -import org.alfresco.rest.search.RestRequestQueryModel; -import org.alfresco.rest.search.SearchResponse; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.report.Bug; -import org.testng.annotations.Test; - -/** - * Search high lighting test. - * @author Michael Suzuki - * - */ -public class SearchHighLightTest extends AbstractSearchTest -{ - @Test(groups={TestGroup.SEARCH,TestGroup.REST_API}) - @Bug(id = "TAS-3220") - public void searchWithHighLight() throws Exception - { - waitForContentIndexing(file2.getContent(), true); - - RestRequestQueryModel queryReq = new RestRequestQueryModel(); - queryReq.setQuery("cm:content:cars"); - queryReq.setUserQuery("cars"); - - RestRequestHighlightModel highlight = new RestRequestHighlightModel(); - highlight.setPrefix("¿"); - highlight.setPostfix("?"); - highlight.setMergeContiguous(true); - List fields = new ArrayList(); - fields.add(new RestRequestFieldsModel("cm:content")); - highlight.setFields(fields); - SearchResponse nodes = query(queryReq, highlight); - nodes.assertThat().entriesListIsNotEmpty(); - ResponseHighLightModel hl = nodes.getEntryByIndex(0).getSearch().getHighlight().get(0); - hl.assertThat().field("snippets").contains( "The landrover discovery is not a sports ¿car?"); - } - - @Test(groups={TestGroup.SEARCH,TestGroup.REST_API}) - public void searchNonIndexedData() throws Exception - { - RestRequestQueryModel queryReq = new RestRequestQueryModel(); - queryReq.setQuery("cm:title"); - queryReq.setUserQuery("zoro"); - - RestRequestHighlightModel highlight = new RestRequestHighlightModel(); - highlight.setPrefix("¿"); - highlight.setPostfix("?"); - highlight.setMergeContiguous(true); - List fields = new ArrayList(); - fields.add(new RestRequestFieldsModel("cm:title")); - highlight.setFields(fields); - SearchResponse nodes = query(queryReq, highlight); - nodes.assertThat().entriesListDoesNotContain("highlight"); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/SearchSpellCheckTest.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/SearchSpellCheckTest.java deleted file mode 100644 index 96273d299..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/SearchSpellCheckTest.java +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Copyright (C) 2018 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.service.search.rest.search; - -import org.alfresco.rest.model.RestRequestSpellcheckModel; -import org.alfresco.rest.search.RestRequestQueryModel; -import org.alfresco.rest.search.SearchRequest; -import org.alfresco.rest.search.SearchResponse; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FileType; -import org.alfresco.utility.model.TestGroup; -import org.testng.Assert; -import org.testng.annotations.Test; - -/** - * Search end point Public API test with spell checking enabled. - * @author Michael Suzuki - * @author Meenal Bhave - */ -public class SearchSpellCheckTest extends AbstractSearchTest -{ - - /** - * Perform the below query - * { - * "spellcheck" : { }, - * "query" : { - * "userQuery" : "alfrezco", - * "query" : "cm:title:alfrezco" - * } - * to yeild the following result. - * { - * "list": { - * "pagination": { - * "count": 22, - * "hasMoreItems": false, - * "totalItems": 22, - * "skipCount": 0, - * "maxItems": 100 - * }, - * "context": { - * "spellCheck": { - * "type": "searchInsteadFor", - * "suggestions": [ - * "alfresco" - * ] - * } - * }, - * "entries": [...] - * } - * - * @throws Exception - */ - @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ACS_60n}, priority=1) - public void testSearchMissSpelled() throws Exception - { - waitForContentIndexing(file4.getContent(), true); - - // Name - SearchRequest searchReq = new SearchRequest(); - RestRequestQueryModel queryReq = new RestRequestQueryModel(); - queryReq.setQuery("cm:name:alfrezco"); - queryReq.setUserQuery("alfrezco"); - searchReq.setQuery(queryReq); - searchReq.setSpellcheck(new RestRequestSpellcheckModel()); - assertResponse(query(searchReq)); - - // Title - queryReq.setQuery("cm:title:alfrezco"); - queryReq.setUserQuery("alfrezco"); - searchReq.setQuery(queryReq); - searchReq.setSpellcheck(new RestRequestSpellcheckModel()); - assertResponse(query(searchReq)); - - // Description - queryReq.setQuery("cm:description:alfrezco"); - queryReq.setUserQuery("alfrezco"); - searchReq.setQuery(queryReq); - searchReq.setSpellcheck(new RestRequestSpellcheckModel()); - assertResponse(query(searchReq)); - - // Content - queryReq.setQuery("cm:content:alfrezco"); - queryReq.setUserQuery("alfrezco"); - searchReq.setQuery(queryReq); - searchReq.setSpellcheck(new RestRequestSpellcheckModel()); - assertResponse(query(searchReq)); - } - - private void assertResponse(SearchResponse nodes) throws Exception - { - nodes.assertThat().entriesListIsNotEmpty(); - nodes.getContext().assertThat().field("spellCheck").isNotEmpty(); - nodes.getContext().getSpellCheck().assertThat().field("suggestions").contains("alfresco"); - nodes.getContext().getSpellCheck().assertThat().field("type").is("searchInsteadFor"); - } - - /** - * Perform alternative way by setting the value in spellcheck object. - * - * { - * "query": { - * "query": "cm:title:alfrezco", - * "language": "afts" - * }, - * "spellcheck": {"query": "alfrezco"} - * } - * @throws Exception - */ - @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ACS_60n}, priority=2) - public void testSearchMissSpelledVersion2() throws Exception - { - SearchRequest searchReq = new SearchRequest(); - RestRequestQueryModel queryReq = new RestRequestQueryModel(); - queryReq.setQuery("cm:title:alfrezco"); - searchReq.setQuery(queryReq); - - RestRequestSpellcheckModel spellCheck = new RestRequestSpellcheckModel(); - spellCheck.setQuery("alfrezco"); - searchReq.setSpellcheck(spellCheck); - assertResponse(query(searchReq)); - } - - @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ACS_60n}, priority=3) - public void testSearchWithSpellcheckerAndCorrectSpelling() throws Exception - { - SearchRequest searchReq = new SearchRequest(); - RestRequestQueryModel queryReq = new RestRequestQueryModel(); - queryReq.setQuery("cm:title:alfresco"); - queryReq.setUserQuery("alfresco"); - searchReq.setQuery(queryReq); - searchReq.setSpellcheck(new RestRequestSpellcheckModel()); - SearchResponse res = query(searchReq); - Assert.assertNull(res.getContext().getSpellCheck()); - res.assertThat().entriesListIsNotEmpty(); - } - - @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ACS_60n}, priority=4) - public void testSpellCheckType() throws Exception - { - // Create a file with mis-spelt name, expect spellcheck type = didYouMean - FileModel file = new FileModel(unique_searchString + "-1.txt", "uniquee" + "uniquee", "uniquee", FileType.TEXT_PLAIN, "Unique text file for search "); - dataContent.usingUser(userModel).usingSite(siteModel).createContent(file); - - waitForIndexing(file.getName(), true); - - // Search - SearchRequest searchReq = new SearchRequest(); - RestRequestQueryModel queryReq = new RestRequestQueryModel(); - queryReq.setQuery("cm:title:uniquee"); - queryReq.setUserQuery("uniquee"); - searchReq.setQuery(queryReq); - searchReq.setSpellcheck(new RestRequestSpellcheckModel()); - SearchResponse nodes = query(searchReq); - - nodes.assertThat().entriesListIsNotEmpty(); - nodes.getContext().assertThat().field("spellCheck").isNotEmpty(); - nodes.getContext().getSpellCheck().assertThat().field("suggestions").contains("unique"); - nodes.getContext().getSpellCheck().assertThat().field("type").is("didYouMean"); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/StatsSearchTest.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/StatsSearchTest.java deleted file mode 100644 index 9e00a5d19..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/StatsSearchTest.java +++ /dev/null @@ -1,332 +0,0 @@ -/* - * Copyright (C) 2017 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.service.search.rest.search; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertTrue; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; - -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.search.Pagination; -import org.alfresco.rest.search.RestGenericBucketModel; -import org.alfresco.rest.search.RestGenericFacetResponseModel; -import org.alfresco.rest.search.RestGenericMetricModel; -import org.alfresco.rest.search.RestRequestFacetFieldModel; -import org.alfresco.rest.search.RestRequestFacetFieldsModel; -import org.alfresco.rest.search.RestRequestFilterQueryModel; -import org.alfresco.rest.search.RestRequestPivotModel; -import org.alfresco.rest.search.RestRequestQueryModel; -import org.alfresco.rest.search.RestRequestStatsModel; -import org.alfresco.rest.search.SearchRequest; -import org.alfresco.rest.search.SearchResponse; -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.BeforeClass; -import org.testng.annotations.Test; - -/** - * Stats search test. - * @author Gethin James - * - */ -public class StatsSearchTest extends AbstractSearchTest -{ - @BeforeClass(alwaysRun = true) - public void setupEnvironment() throws Exception - { - waitForContentIndexing(file2.getContent(), true); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, - executionType = ExecutionType.REGRESSION, - description = "Checks errors with stats using Search api") - public void searchWithBasicStats() throws Exception - { - SearchRequest query = carsQuery(); - Pagination pagination = new Pagination(); - pagination.setMaxItems(2); - List statsModels = new ArrayList<>(); - RestRequestStatsModel statsModel1 = new RestRequestStatsModel(); - statsModels.add(statsModel1); - query.setStats(statsModels); - query.setPaging(pagination); - - SearchResponse response = query(query); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.MANDATORY_PARAM, "stats field")); - - statsModel1.setField("DBID"); - response = query(query); - //8 metrics by default for a numeric field - Set metricTypes = assertStatsFacetedResponse(response, "DBID", 8); - assertTrue(metricTypes.containsAll(Arrays.asList("missing", "countValues", "sum","min","max", "sumOfSquares", "mean", "stddev"))); - - statsModel1.setField("creator"); - response = query(query); - //4 metrics by default for a string field - metricTypes = assertStatsFacetedResponse(response, "creator", 4); - assertTrue(metricTypes.containsAll(Arrays.asList("missing", "countValues", "min","max"))); - - statsModel1.setField("modified"); - response = query(query); - //8 metrics by default for a date field - metricTypes = assertStatsFacetedResponse(response, "modified", 8); - assertTrue(metricTypes.containsAll(Arrays.asList("missing", "countValues", "sum","min","max", "sumOfSquares", "mean", "stddev"))); - - statsModel1.setField("modifier"); - statsModel1.setMin(false); - statsModel1.setMax(false); - statsModel1.setMissing(false); - response = query(query); - metricTypes = assertStatsFacetedResponse(response, "modifier", 1); - assertFalse(metricTypes.containsAll(Arrays.asList("missing", "min","max"))); - - statsModel1.setField("DBID"); - statsModel1.setMin(true); - statsModel1.setMax(true); - statsModel1.setCountValues(false); - statsModel1.setMissing(false); - statsModel1.setSum(false); - statsModel1.setSumOfSquares(false); - statsModel1.setMean(false); - statsModel1.setStddev(false); - response = query(query); - metricTypes = assertStatsFacetedResponse(response, "DBID", 2); - assertTrue(metricTypes.containsAll(Arrays.asList("min","max"))); - assertFalse(metricTypes.containsAll(Arrays.asList("missing", "countValues", "sum","sumOfSquares", "mean", "stddev"))); - - statsModel1.setField("modifier"); - statsModel1.setMin(false); - statsModel1.setMax(false); - statsModel1.setCountDistinct(true); - statsModel1.setDistinctValues(true); - statsModel1.setCardinality(true); - response = query(query); - metricTypes = assertStatsFacetedResponse(response, "modifier", 3); - assertTrue(metricTypes.containsAll(Arrays.asList("countDistinct", "distinctValues", "cardinality"))); - - statsModel1.setField("DBID"); - statsModel1.setPercentiles(Arrays.asList(1,75,99,99.9)); - statsModel1.setCountDistinct(false); - statsModel1.setDistinctValues(false); - statsModel1.setCardinality(false); - response = query(query); - assertStatsFacetedResponse(response, "DBID", 1); - RestGenericMetricModel percMetric = response.getContext().getFacets().get(0).getBuckets().get(0).getMetrics().get(0); - assertEquals(percMetric.getType(),"percentiles"); - Map percVal = (Map) percMetric.getValue(); - Map percentiles = (Map) percVal.get("percentiles"); - assertEquals(percentiles.size(),4); - assertTrue(percentiles.keySet().containsAll(Arrays.asList("1.0","75.0","99.0","99.9"))); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, - executionType = ExecutionType.REGRESSION, - description = "Checks errors with stats labels using Search api") - public void searchWithStatsLabel() throws Exception - { - SearchRequest query = carsQuery(); - Pagination pagination = new Pagination(); - pagination.setMaxItems(2); - List statsModels = new ArrayList<>(); - RestRequestStatsModel statsModel1 = new RestRequestStatsModel(); - statsModel1.setField("modified"); - statsModel1.setLabel("DateChanged"); - statsModels.add(statsModel1); - query.setStats(statsModels); - query.setPaging(pagination); - SearchResponse response = query(query); - assertStatsFacetedResponse(response, "DateChanged", 8); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, - executionType = ExecutionType.REGRESSION, - description = "Checks errors with stats fitlers using Search api") - public void searchWithStatsFilters() throws Exception - { - SearchRequest query = new SearchRequest(); - RestRequestQueryModel queryReq = new RestRequestQueryModel(); - queryReq.setQuery("content.mimetype:text/plain"); - query.setQuery(queryReq); - List statsModels = new ArrayList<>(); - RestRequestStatsModel statsModel1 = new RestRequestStatsModel(); - statsModel1.setField("creator"); - statsModel1.setMin(false); - statsModel1.setMax(false); - statsModel1.setMissing(false); - statsModels.add(statsModel1); - query.setFilterQueries(new RestRequestFilterQueryModel("cars", Arrays.asList("justCars"))); - query.setStats(statsModels); - SearchResponse response = query(query); - assertStatsFacetedResponse(response, "creator", 1); - RestGenericMetricModel countMetric = response.getContext().getFacets().get(0).getBuckets().get(0).getMetrics().get(0); - Integer count = response.getPagination().getTotalItems(); - Map metricCount = (Map) countMetric.getValue(); - assertEquals(count, metricCount.get("countValues")); - - statsModel1.setExcludeFilters(Arrays.asList("justCars")); - response = query(query); - assertStatsFacetedResponse(response, "creator", 1); - countMetric = response.getContext().getFacets().get(0).getBuckets().get(0).getMetrics().get(0); - count = response.getEntries().size(); - metricCount = (Map) countMetric.getValue(); - assertTrue((Integer)metricCount.get("countValues") > count, "With the exclude filter there will be more documents than returned"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, - executionType = ExecutionType.REGRESSION, - description = "Checks errors with stats with Pivot using Search api") - public void searchWithStatsAndMutlilevelPivot() throws Exception - { - SearchRequest query = carsQuery(); - - Pagination pagination = new Pagination(); - pagination.setMaxItems(1); - query.setPaging(pagination); - RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); - List list = new ArrayList<>(); - RestRequestFacetFieldModel b0 = new RestRequestFacetFieldModel("SITE"); - b0.setLabel("b0"); - list.add(b0); - list.add(new RestRequestFacetFieldModel("created")); - RestRequestFacetFieldModel b2 = new RestRequestFacetFieldModel("modifier"); - b2.setLabel("b2"); - list.add(b2); - facetFields.setFacets(list); - query.setFacetFields(facetFields); - query.setIncludeRequest(false); - - List pivotModelList = new ArrayList<>(); - RestRequestPivotModel pivots = new RestRequestPivotModel(); - pivots.setKey("b0"); - RestRequestPivotModel pivotn = new RestRequestPivotModel(); - pivotn.setKey("created"); - RestRequestPivotModel pivot2 = new RestRequestPivotModel(); - pivot2.setKey("aNumber"); - - pivotn.setPivots(Arrays.asList(pivot2)); - pivots.setPivots(Arrays.asList(pivotn)); - pivotModelList.add(pivots); - query.setPivots(pivotModelList); - - List statsModels = new ArrayList<>(); - RestRequestStatsModel statsModel1 = new RestRequestStatsModel(); - statsModels.add(statsModel1); - query.setStats(statsModels); - statsModel1.setField("DBID"); - statsModel1.setLabel("aNumber"); - - SearchResponse response = query(query); - response.getContext().assertThat().field("facetsFields").isNotNull(); - response.getContext().assertThat().field("facets").isNotEmpty(); - assertEquals(response.getContext().getFacetsFields().size(), 1, "There should be 1 facet field for modifier"); - assertEquals(response.getContext().getFacets().size(), 2, "There should be 1 pivot facet with stats on the end and a high level stats facet"); - - RestGenericFacetResponseModel facetResponseModel = response.getContext().getFacets().get(0); - facetResponseModel.assertThat().field("type").is("pivot"); - facetResponseModel.assertThat().field("label").is("b0"); - - //pivot created - RestGenericFacetResponseModel created = facetResponseModel.getBuckets().get(0).getFacets().get(0); - created.assertThat().field("type").is("pivot"); - created.assertThat().field("label").is("created"); - //Another nested stats - assertEquals(created.getBuckets().get(0).getMetrics().size(), 9, "Metrics are on the end of a pivot bucket"); - - } - - - @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, - executionType = ExecutionType.REGRESSION, - description = "Checks errors with stats with Pivot using Search api") - public void searchWithStatsAndPivot() throws Exception - { - SearchRequest query = carsQuery(); - - Pagination pagination = new Pagination(); - pagination.setMaxItems(2); - query.setPaging(pagination); - RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); - List list = new ArrayList<>(); - list.add(new RestRequestFacetFieldModel("creator")); - facetFields.setFacets(list); - query.setFacetFields(facetFields); - query.setIncludeRequest(false); - - SearchResponse response = query(query); - response.getContext().assertThat().field("facetsFields").isNotNull(); - - List pivotModelList = new ArrayList<>(); - RestRequestPivotModel pivots = new RestRequestPivotModel(); - pivots.setKey("creator"); - RestRequestPivotModel pivotn = new RestRequestPivotModel(); - pivotn.setKey("numericId"); - - pivots.setPivots(Arrays.asList(pivotn)); - pivotModelList.add(pivots); - query.setPivots(pivotModelList); - - List statsModels = new ArrayList<>(); - RestRequestStatsModel statsModel1 = new RestRequestStatsModel(); - statsModels.add(statsModel1); - query.setStats(statsModels); - statsModel1.setField("DBID"); - statsModel1.setLabel("numericId"); - - response = query(query); - - response.getContext().assertThat().field("facets").isNotEmpty(); - assertEquals(response.getContext().getFacets().size(), 2, "There should be 1 pivot facet with stats on the end and a high level stats facet"); - RestGenericFacetResponseModel facetResponseModel = response.getContext().getFacets().get(0); - facetResponseModel.assertThat().field("type").is("pivot"); - facetResponseModel.assertThat().field("label").is("creator"); - assertEquals(facetResponseModel.getBuckets().get(0).getMetrics().size(), 9, "Metrics are on the end of a pivot bucket"); - RestGenericFacetResponseModel statsFacet = response.getContext().getFacets().get(1); - statsFacet.assertThat().field("type").is("stats"); - statsFacet.assertThat().field("label").is("numericId"); - - } - - private Set assertStatsFacetedResponse(SearchResponse response, String label, int metricsCount) throws Exception - { - response.getContext().assertThat().field("facets").isNotEmpty(); - RestGenericFacetResponseModel facetResponseModel = response.getContext().getFacets().get(0); - facetResponseModel.assertThat().field("type").is("stats"); - facetResponseModel.assertThat().field("label").is(label); - RestGenericBucketModel bucket = facetResponseModel.getBuckets().get(0); - List metrics = bucket.getMetrics(); - assertEquals(metrics.size(),metricsCount); - return metrics.stream().map(m -> m.getType()).collect(Collectors.toSet()); - } - -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/sql/SearchSQLWithQuotedIdentifiers.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/sql/SearchSQLWithQuotedIdentifiers.java deleted file mode 100644 index 4b7b36f1f..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/sql/SearchSQLWithQuotedIdentifiers.java +++ /dev/null @@ -1,218 +0,0 @@ -/* - * Copyright (C) 2018 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.service.search.rest.search.sql; - -import java.util.UUID; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.service.search.rest.search.AbstractSearchTest; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.CustomObjectTypeProperties; -import org.alfresco.utility.model.ContentModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FileType; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.report.Bug; -import org.hamcrest.Matchers; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Tests for /sql end point Search API when a custom model contains identifiers that need to be quoted in queries. - * While it seems there is not an ANSI standard for naming database objects, on the other side the most popular - * databases don't like columns starting with a number. - * In those cases, the column identifier need to be quoted. How to quote a given object identifier (a column name, in - * this case) depends on the specific database lexicon: Oracle uses double quotes ("), MySQL uses back quotes(`). - * - * At time of writing, the lexicon used by the /sql endpoint is MySql so queries that use column names starting with - * a number need to be quoted with back quotes. - * - */ -public class SearchSQLWithQuotedIdentifiers extends AbstractSearchTest -{ - - private String songName; - private String genre; - private String coProducer; - - private String artistName; - private String voiceType; - - private String bassistName; - private String drummerName; - private String saxophonistName; - - private FileModel file5; - - /** - * Setup fixture for this test case. - * Overrides the superlayer method because the data preparation requires a bit different preconditions. - * The method uses a transient test site created in the {@link RestTest#checkServerHealth()} and on top of that: - * - *
            - *
          • It adds a user which is added to the site as contributor
          • - *
          • - * It deploys a custom model which declares a set of prefixes composed by a combination of digits, hyphens - * and underscores. Those prefixes are associated with four entities (song, artist, bassist, drummer and - * sax) with their corresponding attributes. - *
          • - *
          • - * It creates a folder with 5 files associated with the types declared in the model. - * That allows those files to have a value for the properties/attributes included in the model definition. - *
          • - *
          - * - * @see RestTest#checkServerHealth() - * @throws Exception hopefully never, otherwise the test fails. - */ - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - songName = "The Dry Cleaner from Des Moines "; - genre = "Jazz, vocal jazz "; - coProducer = "Roberta Joan Mitchell "; - - artistName = "Joni Mitchell " + UUID.randomUUID(); - voiceType = "Blue Mezzo (1965-1984) / Cloudy Contralto (1985-present) "; - - bassistName = "Jaco Pastorius"; - drummerName = "Peter Erskine"; - saxophonistName = "Wayne Shorter"; - - userModel = dataUser.createRandomTestUser(); - - dataContent.usingAdmin().deployContentModel("models/SEARCH-1063.xml"); - - dataUser.addUserToSite(userModel, testSite, UserRole.SiteContributor); - - FolderModel testFolder = dataContent.usingSite(testSite).usingUser(userModel).createFolder(); - - file = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); - file2 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); - file3 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); - file4 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); - file5 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); - - dataContent.usingUser(userModel) - .usingResource(testFolder) - .createCustomContent( - file, - "D:1:song", - new CustomObjectTypeProperties() - .addProperty("1:name", songName) - .addProperty("1:genre", genre) - .addProperty("1:co-producer", coProducer)); - - dataContent.usingUser(userModel) - .usingResource(testFolder) - .createCustomContent( - file2, - "D:123:artist", - new CustomObjectTypeProperties() - .addProperty("123:name", artistName) - .addProperty("123:voice_type", voiceType)); - - dataContent.usingUser(userModel) - .usingResource(testFolder) - .createCustomContent( - file3, - "D:1_2_3:bassist", - new CustomObjectTypeProperties() - .addProperty("1_2_3:name", bassistName)); - - dataContent.usingUser(userModel) - .usingResource(testFolder) - .createCustomContent( - file4, - "D:1-2-3:drummer", - new CustomObjectTypeProperties() - .addProperty("1-2-3:name", drummerName)); - - ContentModel content = - dataContent.usingUser(userModel) - .usingResource(testFolder) - .createCustomContent( - file5, - "D:1-2_3:saxophonist", - new CustomObjectTypeProperties() - .addProperty("1-2_3:name", saxophonistName)); - - waitForIndexing(content.getName(), true); - } - - @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_1}) - @Bug(id = "SEARCH-1063") - public void prefixIsComposedByOneNumber() throws Exception - { - executeSqlAsSolr("select cm_name, `1_name`, `1_genre`, `1_co-producer` from alfresco where TYPE='1:song' and SITE='" + testSite.getId() + "'"); - - restClient.assertStatusCodeIs(HttpStatus.OK); - restClient.onResponse().assertThat().body("result-set.docs[0].cm_name", Matchers.equalTo(file.getName())); - restClient.onResponse().assertThat().body("result-set.docs[0].1_name", Matchers.equalTo(songName)); - restClient.onResponse().assertThat().body("result-set.docs[0].1_genre", Matchers.equalTo(genre)); - restClient.onResponse().assertThat().body("result-set.docs[0].1_co-producer", Matchers.equalTo(coProducer)); - } - - @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_1}) - @Bug(id = "SEARCH-1063") - public void prefixIsComposedByMultipleNumbers() throws Exception - { - executeSqlAsSolr("select cm_name, `123_name`, `123_voice_type` from alfresco where TYPE='123:artist' and SITE='" + testSite.getId() + "'"); - - restClient.assertStatusCodeIs(HttpStatus.OK); - restClient.onResponse().assertThat().body("result-set.docs[0].cm_name", Matchers.equalTo(file2.getName())); - restClient.onResponse().assertThat().body("result-set.docs[0].123_name", Matchers.equalTo(artistName)); - restClient.onResponse().assertThat().body("result-set.docs[0].123_voice_type", Matchers.equalTo(voiceType)); - } - - @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_1}) - @Bug(id = "SEARCH-1063") - public void prefixIncludesUnderscore() throws Exception - { - executeSqlAsSolr("select cm_name, `1_2_3_name` from alfresco where TYPE='1_2_3:bassist' and SITE='" + testSite.getId() + "'"); - - restClient.assertStatusCodeIs(HttpStatus.OK); - restClient.onResponse().assertThat().body("result-set.docs[0].cm_name", Matchers.equalTo(file3.getName())); - restClient.onResponse().assertThat().body("result-set.docs[0].1_2_3_name", Matchers.equalTo(bassistName)); - } - - @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_1}) - @Bug(id = "SEARCH-1063") - public void prefixIncludesHyphen() throws Exception - { - executeSqlAsSolr("select cm_name, `1-2-3_name` from alfresco where TYPE='1-2-3:drummer' and SITE='" + testSite.getId() + "'"); - - restClient.assertStatusCodeIs(HttpStatus.OK); - restClient.onResponse().assertThat().body("result-set.docs[0].cm_name", Matchers.equalTo(file4.getName())); - restClient.onResponse().assertThat().body("result-set.docs[0].1-2-3_name", Matchers.equalTo(drummerName)); - } - - @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_1}) - @Bug(id = "SEARCH-1063") - public void prefixIncludesHyphenAndUnderscore() throws Exception - { - executeSqlAsSolr("select cm_name, `1-2_3_name` from alfresco where TYPE='1-2_3:saxophonist' and SITE='" + testSite.getId() + "'"); - - restClient.assertStatusCodeIs(HttpStatus.OK); - restClient.onResponse().assertThat().body("result-set.docs[0].cm_name", Matchers.equalTo(file5.getName())); - restClient.onResponse().assertThat().body("result-set.docs[0].1-2_3_name", Matchers.equalTo(saxophonistName)); - } -} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/sharedLinks/GetSharedLinksFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sharedLinks/GetSharedLinksFullTests.java deleted file mode 100644 index 296cd58f7..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/sharedLinks/GetSharedLinksFullTests.java +++ /dev/null @@ -1,75 +0,0 @@ -package org.alfresco.service.search.rest.sharedLinks; - -import javax.json.Json; -import javax.json.JsonObject; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.model.RestNodeModel; -import org.alfresco.rest.model.RestSharedLinksModelCollection; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.utility.exception.DataPreparationException; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class GetSharedLinksFullTests extends RestTest -{ - private SiteModel privateSite; - private UserModel adminUser, userModel; - protected FileModel file; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws DataPreparationException - { - adminUser = dataUser.getAdminUser(); - userModel = dataUser.createRandomTestUser(); - privateSite = dataSite.usingUser(adminUser).createPrivateRandomSite(); - } - - @Bug(id="REPO-2365") - @TestRail(section = { TestGroup.REST_API, - TestGroup.SHAREDLINKS }, executionType = ExecutionType.REGRESSION, description = "Verify that a user with permission can get allowableOperations on sharedLinks") - @Test(groups = { TestGroup.REST_API, TestGroup.SHAREDLINKS, TestGroup.REGRESSION }) - public void getSharedLinksWithAllowableOperations() throws Exception - { - file = dataContent.usingUser(adminUser).usingSite(privateSite).createContent(DocumentType.TEXT_PLAIN); - - /* - * { "permissions": { "isInheritanceEnabled": true, "locallySet": { "authorityId": "userModel.getUsername()", - * "name": "SiteConsumer", "accessStatus":"ALLOWED" } } } - */ - JsonObject userPermission = Json.createObjectBuilder().add("permissions", - Json.createObjectBuilder().add("isInheritanceEnabled", true).add("locallySet", Json.createObjectBuilder() - .add("authorityId", userModel.getUsername()).add("name", "SiteConsumer").add("accessStatus", "ALLOWED"))) - .build(); - String putBody = userPermission.toString(); - restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file).updateNode(putBody); - restClient.assertStatusCodeIs(HttpStatus.OK); - restClient.authenticateUser(adminUser).withCoreAPI().usingSharedLinks().createSharedLink(file); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - // verify that the permision exists - RestNodeModel permissionsRequest = restClient.authenticateUser(userModel).withCoreAPI().usingNode(file) - .usingParams("include=permissions").getNode(); - permissionsRequest.assertThat().field("permissions.locallySet.authorityId").is("[" + userModel.getUsername() + "]"); - - // because the sharedLink take time to be created, we may need to wait for solr to index it. - int numberOfTries = 0; - RestSharedLinksModelCollection operationsRequest; - do - { - Thread.sleep(1000); - numberOfTries++; - operationsRequest = restClient.authenticateUser(userModel).withCoreAPI().usingSharedLinks().usingParams("include=allowableOperations").getSharedLinks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } while (operationsRequest.getPagination().getCount() == 0 && numberOfTries < 15); - operationsRequest.getPagination().assertThat().field("count").is(1); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/sharedLinks/SharedLinksSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sharedLinks/SharedLinksSanityTests.java deleted file mode 100644 index fdff67357..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/sharedLinks/SharedLinksSanityTests.java +++ /dev/null @@ -1,276 +0,0 @@ -package org.alfresco.service.search.rest.sharedLinks; - -import javax.json.Json; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.model.RestRenditionInfoModel; -import org.alfresco.rest.model.RestRenditionInfoModelCollection; -import org.alfresco.rest.model.RestSharedLinksModel; -import org.alfresco.rest.model.RestSharedLinksModelCollection; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.utility.Utility; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.Assert; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Class includes Sanity tests for the shared-links api. Detailed tests would be covered in the alfresco-remote-api test project - * - * @author meenal bhave - */ -public class SharedLinksSanityTests extends RestTest -{ - private UserModel adminUser; - private UserModel testUser1; - - private SiteModel siteModel1; - - private FolderModel folder1; - - private FileModel file1; - private FileModel file2; - private FileModel file3; - private FileModel file4; - private FileModel file5; - private FileModel file6; - private FileModel file7; - private FileModel file8; - - private RestSharedLinksModel sharedLink1; - private RestSharedLinksModel sharedLink2; - private RestSharedLinksModel sharedLink3; - private RestSharedLinksModel sharedLink4; - private RestSharedLinksModel sharedLink5; - private RestSharedLinksModel sharedLink6; - private RestSharedLinksModel sharedLink7; - private RestSharedLinksModel sharedLink8; - private RestRenditionInfoModel nodeRenditionInfo; - - private RestSharedLinksModelCollection sharedLinksCollection; - private RestRenditionInfoModelCollection nodeRenditionInfoCollection; - - private String expiryDate = "2027-03-23T23:00:00.000+0000"; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - - adminUser = dataUser.getAdminUser(); - restClient.authenticateUser(adminUser); - - // Create Standard User - testUser1 = dataUser.usingUser(adminUser).createRandomTestUser(); - - // Create Site - siteModel1 = dataSite.usingUser(testUser1).createPublicRandomSite(); - - folder1 = dataContent.usingUser(adminUser).usingSite(siteModel1).createFolder(); - - file1 = dataContent.usingUser(adminUser).usingResource(folder1).createContent(DocumentType.TEXT_PLAIN); - file2 = dataContent.usingUser(adminUser).usingResource(folder1).createContent(DocumentType.TEXT_PLAIN); - file3 = dataContent.usingUser(adminUser).usingResource(folder1).createContent(DocumentType.TEXT_PLAIN); - file4 = dataContent.usingUser(adminUser).usingResource(folder1).createContent(DocumentType.TEXT_PLAIN); - file5 = dataContent.usingUser(adminUser).usingResource(folder1).createContent(DocumentType.TEXT_PLAIN); - file7 = dataContent.usingUser(adminUser).usingResource(folder1).createContent(DocumentType.TEXT_PLAIN); - file8 = dataContent.usingUser(adminUser).usingResource(folder1).createContent(DocumentType.TEXT_PLAIN); - // Create file6 based on existing resource - FileModel newFile = FileModel.getFileModelBasedOnTestDataFile("sampleContent.txt"); - newFile.setName("sampleContent.txt"); - file6 = dataContent.usingUser(adminUser).usingResource(folder1).createContent(newFile); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.SHAREDLINKS }, executionType = ExecutionType.SANITY, description = "Verify create sharedLinks without Path") - @Test(groups = { TestGroup.REST_API, TestGroup.SHAREDLINKS, TestGroup.SANITY }) - public void testCreateAndGetSharedLinks() throws Exception - { - // Post without includePath - sharedLink1 = restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().createSharedLink(file1); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.onResponse().assertThat().body("entry.nodeId", org.hamcrest.Matchers.equalTo(file1.getNodeRefWithoutVersion())); - restClient.onResponse().assertThat().body("entry.name", org.hamcrest.Matchers.equalTo(file1.getName())); - restClient.onResponse().assertThat().body("entry.id", org.hamcrest.Matchers.equalTo(sharedLink1.getId())); - restClient.onResponse().assertThat().body("entry.path", org.hamcrest.Matchers.nullValue()); - - // Same Checks above using sharedLink methods: GET sharedLink: without includePath - Assert.assertEquals(sharedLink1.getNodeId(), file1.getNodeRefWithoutVersion()); - Assert.assertEquals(sharedLink1.getName(), file1.getName()); - Assert.assertNull(sharedLink1.getPath(), "Path is expected to be null for noauth api: Response shows: " + sharedLink1.toJson()); - - // Get without includePath - restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().getSharedLink(sharedLink1); - restClient.onResponse().assertThat().body("entry.nodeId", org.hamcrest.Matchers.equalTo(file1.getNodeRefWithoutVersion())); - restClient.onResponse().assertThat().body("entry.name", org.hamcrest.Matchers.equalTo(file1.getName())); - restClient.onResponse().assertThat().body("entry.id", org.hamcrest.Matchers.equalTo(sharedLink1.getId())); - restClient.onResponse().assertThat().body("entry.path", org.hamcrest.Matchers.nullValue()); - - /* - * Get all shared-links while allowing indexing to complete and check - * that the created shared-link is displayed - */ - Utility.sleep(1000, 30000, () -> - { - sharedLinksCollection = restClient.withCoreAPI().usingSharedLinks().getSharedLinks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - sharedLinksCollection.assertThat().entriesListContains("id", sharedLink1.getId()).and() - .entriesListContains("nodeId", sharedLink1.getNodeId()); - }); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.SHAREDLINKS }, executionType = ExecutionType.REGRESSION, description = "Verify create sharedLinks with Path") - @Test(groups = { TestGroup.REST_API, TestGroup.SHAREDLINKS, TestGroup.REGRESSION }) - public void testCreateAndGetSharedLinksWithInclude() throws Exception - { - // Post with includePath - sharedLink2 = restClient.authenticateUser(testUser1).withCoreAPI().includePath().usingSharedLinks().createSharedLink(file2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.onResponse().assertThat().body("entry.nodeId", org.hamcrest.Matchers.equalTo(file2.getNodeRefWithoutVersion())); - restClient.onResponse().assertThat().body("entry.name", org.hamcrest.Matchers.equalTo(file2.getName())); - restClient.onResponse().assertThat().body("entry.id", org.hamcrest.Matchers.equalTo(sharedLink2.getId())); - restClient.onResponse().assertThat().body("entry.path", org.hamcrest.Matchers.notNullValue()); - - // Same Checks above using sharedLink methods: POST sharedLink: includePath - Assert.assertEquals(sharedLink2.getNodeId(), file2.getNodeRefWithoutVersion()); - Assert.assertEquals(sharedLink2.getName(), file2.getName()); - Assert.assertNotNull(sharedLink2.getPath(), "Path not expected to be null for noauth api: Response shows: " + sharedLink1.toJson()); - - // Get with includePath - restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().getSharedLink(sharedLink2); - restClient.onResponse().assertThat().body("entry.nodeId", org.hamcrest.Matchers.equalTo(file2.getNodeRefWithoutVersion())); - restClient.onResponse().assertThat().body("entry.name", org.hamcrest.Matchers.equalTo(file2.getName())); - restClient.onResponse().assertThat().body("entry.id", org.hamcrest.Matchers.equalTo(sharedLink2.getId())); - // Verify that path is null since includePath is not supported for this noAuth api - restClient.onResponse().assertThat().body("entry.path", org.hamcrest.Matchers.nullValue()); - - // Get: noAuth with includePath - sharedLink2 = restClient.withCoreAPI().usingSharedLinks().getSharedLink(sharedLink2); - restClient.onResponse().assertThat().body("entry.nodeId", org.hamcrest.Matchers.equalTo(file2.getNodeRefWithoutVersion())); - restClient.onResponse().assertThat().body("entry.name", org.hamcrest.Matchers.equalTo(file2.getName())); - restClient.onResponse().assertThat().body("entry.id", org.hamcrest.Matchers.equalTo(sharedLink2.getId())); - // Verify that path is null since includePath is not supported for this noAuth api - restClient.onResponse().assertThat().body("entry.path", org.hamcrest.Matchers.nullValue()); - - // Same Checks above using sharedLink methods: GET sharedLink: noAuth - Assert.assertEquals(sharedLink2.getNodeId(), file2.getNodeRefWithoutVersion()); - Assert.assertEquals(sharedLink2.getName(), file2.getName()); - Assert.assertNull(sharedLink2.getPath(), "Path is expected to be null for noauth api: Response shows: " + sharedLink2.toJson()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.SHAREDLINKS }, executionType = ExecutionType.SANITY, description = "Verify delete sharedLinks with and without Path") - @Test(groups = { TestGroup.REST_API, TestGroup.SHAREDLINKS, TestGroup.SANITY}) - public void testDeleteSharedLinks() throws Exception - { - sharedLink3 = restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().createSharedLink(file3); - restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().deleteSharedLink(sharedLink3); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - sharedLink4 = restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().createSharedLink(file4); - restClient.authenticateUser(testUser1).withCoreAPI().includePath().usingSharedLinks().deleteSharedLink(sharedLink4); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.SHAREDLINKS }, executionType = ExecutionType.SANITY, description = "Sanity tests for GET {sharedId}/content and POST {sharedId}/email endpoints") - @Test(groups = { TestGroup.REST_API, TestGroup.SHAREDLINKS, TestGroup.SANITY }) - public void testGetSharedLinkContentAndPostEmail() throws Exception - { - // Create shared-link - sharedLink6 = restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().createSharedLink(file6); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - // Make GET {sharedId}/content and check file content - restClient.withCoreAPI().usingSharedLinks().getSharedLinkContent(sharedLink6); - restClient.assertStatusCodeIs(HttpStatus.OK); - restClient.assertHeaderValueContains("Content-Disposition", file6.getName()); - restClient.onResponse().getResponse().body().asString().contains("Sample text."); - - // Make POST {sharedId}/email to send email with created shared-link - String postBody = Json.createObjectBuilder().add("client", "share") - .add("recipientEmails", "john.doe@acme.com") - .build().toString(); - restClient.withCoreAPI().usingSharedLinks().sendSharedLinkEmail(sharedLink6, postBody); - restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.SHAREDLINKS }, executionType = ExecutionType.REGRESSION, description = "Verify get sharedLink/content and get/renditions") - @Test(groups = { TestGroup.REST_API, TestGroup.SHAREDLINKS, TestGroup.REGRESSION, TestGroup.REQUIRE_TRANSFORMATION }) - public void testCreateWithExpiryDateAndGetSharedLinkRendition() throws Exception - { - sharedLink5 = restClient.authenticateUser(testUser1).withCoreAPI().includePath().usingSharedLinks().createSharedLinkWithExpiryDate(file5, expiryDate); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - Assert.assertEquals(sharedLink5.getExpiresAt(), expiryDate); - Assert.assertNotNull(sharedLink5.getPath(), "Path not expected to be null: Response shows: " + sharedLink5.toJson()); - - restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().getSharedLinkRenditions(sharedLink5); - restClient.assertStatusCodeIs(HttpStatus.OK); - - restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().getSharedLinkRendition(sharedLink5, "doclib"); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.SHAREDLINKS }, executionType = ExecutionType.SANITY, description = "Sanity tests for GET /renditions, GET /renditions/{renditionId} and GET /renditions/{renditionId}/content endpoints") - @Test(groups = { TestGroup.REST_API, TestGroup.SHAREDLINKS, TestGroup.SANITY, TestGroup.REQUIRE_TRANSFORMATION }) - public void testGetSharedLinkRendition() throws Exception - { - /* - * Create shared-link and generate renditions for node "doclib"; - * rendition is automatically created when creating "pdf" rendition - */ - sharedLink7 = restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().createSharedLink(file7); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.withCoreAPI().usingNode(file7).createNodeRendition("pdf"); - restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); - - // GET /renditions: wait until all renditions are created and GET all entries - Utility.sleep(1000, 30000, () -> - { - nodeRenditionInfoCollection = restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().getSharedLinkRenditions(sharedLink7); - restClient.assertStatusCodeIs(HttpStatus.OK); - - nodeRenditionInfoCollection.assertThat().entriesListCountIs(2); - nodeRenditionInfoCollection.getEntryByIndex(0).assertThat().field("id").is("doclib").and() - .field("status").is("CREATED"); - nodeRenditionInfoCollection.getEntryByIndex(1).assertThat().field("id").is("pdf").and() - .field("status").is("CREATED"); - }); - - // GET /renditions/{renditionId}: get specific rendition information for the file with shared link - nodeRenditionInfo = restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().getSharedLinkRendition(sharedLink7, "pdf"); - restClient.assertStatusCodeIs(HttpStatus.OK); - nodeRenditionInfo.assertThat().field("id").is("pdf").and() - .field("status").is("CREATED"); - - // GET /renditions/{renditionId}/content: get the rendition content for file with shared link - restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().getSharedLinkRenditionContent(sharedLink7, "pdf"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restClient.assertHeaderValueContains("Content-Type","application/pdf;charset=UTF-8"); - Assert.assertTrue(restClient.onResponse().getResponse().body().asInputStream().available() > 0); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.SHAREDLINKS }, executionType = ExecutionType.SANITY, description = "Sanity tests for Range reuest header on GET shared-links/{sharedId}/renditions/{renditionId}/content endpoints") - @Test(groups = { TestGroup.REST_API, TestGroup.SHAREDLINKS, TestGroup.SANITY, TestGroup.REQUIRE_TRANSFORMATION }) - public void testGetVerifyRangeReguestOnSharedLinks() throws Exception - { - sharedLink8 = restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().createSharedLink(file8); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.withCoreAPI().usingNode(file8).createNodeRendition("pdf"); - restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); - - // GET /renditions/{renditionId}/content: get the Range request header for file with shared links endpoints. - Utility.sleep(1000, 30000, () -> - { - restClient.configureRequestSpec().addHeader("content-range", "bytes=1-10"); - restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().getSharedLinkRenditionContent(sharedLink8, "pdf"); - restClient.assertStatusCodeIs(HttpStatus.PARTIAL_CONTENT); - restClient.assertHeaderValueContains("Content-Type","application/pdf;charset=UTF-8"); - restClient.assertHeaderValueContains("content-range", "bytes 1-10"); - }); - } -} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/GetSiteTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/GetSiteTests.java deleted file mode 100644 index 7a2f5107b..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/GetSiteTests.java +++ /dev/null @@ -1,362 +0,0 @@ -package org.alfresco.service.search.rest.sites; - -import org.alfresco.dataprep.SiteService; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.core.RestRequest; -import org.alfresco.rest.core.RestResponse; -import org.alfresco.rest.model.*; -import org.alfresco.utility.constants.ContainerName; -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.HttpMethod; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import java.util.List; - -import static org.hamcrest.CoreMatchers.equalTo; - -/** - * @author iulia.cojocea - */ - -public class GetSiteTests extends RestTest -{ - private UserModel adminUserModel; - private ListUserWithRoles usersWithRoles; - private UserModel userModel, privateSiteConsumer; - private SiteModel publicSite, privateSite, moderatedSite; - private RestSiteModel restSiteModel; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws DataPreparationException - { - adminUserModel = dataUser.getAdminUser(); - restClient.authenticateUser(adminUserModel); - publicSite = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - usersWithRoles = dataUser.addUsersWithRolesToSite(publicSite, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); - - userModel = dataUser.createRandomTestUser(); - privateSiteConsumer = dataUser.createRandomTestUser(); - - privateSite = dataSite.usingAdmin().createPrivateRandomSite(); - moderatedSite = dataSite.usingAdmin().createModeratedRandomSite(); - dataUser.addUserToSite(privateSiteConsumer, privateSite, UserRole.SiteConsumer); - } - - @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 information and gets status code OK (200)") - public void getSiteWithManagerRole() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingSite(publicSite) - .getSite() - .and().field("id").is(publicSite.getId()) - .and().field("title").is(publicSite.getTitle()); - - 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 information and gets status code OK (200)") - public void getSiteWithCollaboratorRole() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingSite(publicSite) - .getSite() - .and().field("id").is(publicSite.getId()) - .and().field("title").is(publicSite.getTitle()); - 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 information and gets status code OK (200)") - public void getSiteWithContributorRole() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) - .withCoreAPI().usingSite(publicSite) - .getSite() - .and().field("id").is(publicSite.getId()) - .and().field("title").is(publicSite.getTitle()); - 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 information and gets status code OK (200)") - public void getSiteWithConsumerRole() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .withCoreAPI().usingSite(publicSite) - .getSite() - .and().field("id").is(publicSite.getId()) - .and().field("title").is(publicSite.getTitle()); - 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 role gets site information and gets status code OK (200)") - public void getSiteWithAdminRole() throws Exception - { - restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingSite(publicSite) - .getSite() - .and().field("id").is(publicSite.getId()) - .and().field("title").is(publicSite.getTitle()); - 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 call returns status code 401") -// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void unauthenticatedUserIsNotAuthorizedToRetrieveSite() throws Exception - { - UserModel unauthenticatedManager = dataUser.createRandomTestUser(); - unauthenticatedManager.setPassword("user wrong password"); - dataUser.addUserToSite(unauthenticatedManager, publicSite, UserRole.SiteManager); - restClient.authenticateUser(unauthenticatedManager).withParams("maxItems=10000") - .withCoreAPI() - .getSites(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify invalid request returns status code 404 if siteId does not exist") - public void checkStatusCodeForNonExistentSiteId() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite("NonExistentSiteId").getSite(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "NonExistentSiteId")) - .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 all public and moderated sites if an empty siteId is provided") - public void checkStatusCodeForEmptySiteId() throws Exception - { - restClient.authenticateUser(userModel).withCoreAPI(); - RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "sites/{siteId}", ""); - RestSiteModelsCollection sites = restClient.processModels(RestSiteModelsCollection.class, request); - restClient.assertStatusCodeIs(HttpStatus.OK); - sites.assertThat().entriesListIsNotEmpty(); - } - - @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 details and status code is 200") - public void getPublicSiteByNotASiteMember() throws Exception - { - restSiteModel = restClient.authenticateUser(userModel).withCoreAPI() - .usingSite(publicSite).getSite(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModel.assertThat().field("visibility").is(publicSite.getVisibility()) - .and().field("id").is(publicSite.getId()) - .and().field("description").is(publicSite.getDescription()) - .and().field("title").is(publicSite.getTitle()) - .and().field("guid").isNotEmpty(); - } - - @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 details and status code is 200") - public void getModeratedSiteByNotASiteMember() throws Exception - { - restSiteModel = restClient.authenticateUser(userModel).withCoreAPI() - .usingSite(moderatedSite).getSite(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModel.assertThat().field("visibility").is(moderatedSite.getVisibility()) - .and().field("id").is(moderatedSite.getId()) - .and().field("description").is(moderatedSite.getDescription()) - .and().field("title").is(moderatedSite.getTitle()) - .and().field("guid").isNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if member of a private site gets that site details and status code is 200") - public void getPrivateSiteBySiteMember() throws Exception - { - restSiteModel = restClient.authenticateUser(privateSiteConsumer).withCoreAPI() - .usingSite(privateSite).getSite(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModel.assertThat().field("visibility").is(privateSite.getVisibility()) - .and().field("id").is(privateSite.getId()) - .and().field("description").is(privateSite.getDescription()) - .and().field("title").is(privateSite.getTitle()) - .and().field("guid").isNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if user that is not member of a private site does not get that site details and status code is 200") - public void getPrivateSiteByNotASiteMember() throws Exception - { - restSiteModel = restClient.authenticateUser(userModel).withCoreAPI() - .usingSite(privateSite).getSite(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, privateSite.getTitle())) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }, expectedExceptions = java.lang.AssertionError.class) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Check that properties parameter is applied (guid field is mandatory, thus assertion error is expected)") - public void checkThatPropertiesParameterIsApplied() throws Exception - { - restSiteModel = restClient.authenticateUser(adminUserModel).withParams("properties=id, visibility").withCoreAPI().usingSite(publicSite).getSite(); - restSiteModel.assertThat().field("id").is(publicSite.getId()).and().field("visibility").is(SiteService.Visibility.PUBLIC.toString()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION } ) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Check that properties parameter is applied") - public void checkThatPropertiesParameterIsAppliedPositiveTest() throws Exception - { - restSiteModel = restClient.authenticateUser(adminUserModel).withParams("properties=id,guid,title,visibility").withCoreAPI().usingSite(publicSite).getSite(); - restSiteModel.assertThat().field("id").is(publicSite.getId()).and().field("visibility").is(SiteService.Visibility.PUBLIC.toString()) - .and().field("description").isNull() - .and().field("role").isNull(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION } ) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Delete site then get site details") - public void deleteSiteThenGetSiteDetails() throws Exception - { - SiteModel newSite = dataSite.usingAdmin().createPublicRandomSite(); - dataSite.deleteSite(newSite); - restSiteModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(newSite).getSite(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newSite.getId())) - .containsErrorKey(RestErrorModel.ENTITY_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= "Delete site then get site details") - public void updateSiteVisibilityToPrivateThenGetSite() throws Exception - { - SiteModel newSite = dataSite.usingAdmin().createPublicRandomSite(); - restSiteModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(newSite).getSite(); - restClient.assertStatusCodeIs(HttpStatus.OK); - dataSite.updateSiteVisibility(newSite, SiteService.Visibility.PRIVATE); - restSiteModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(newSite).getSite(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModel.assertThat().field("id").is(newSite.getId()) - .and().field("visibility").is(SiteService.Visibility.PRIVATE.toString()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION } ) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Check that relations parameter is applied for containers") - public void checkThatRelationsParameterIsAppliedForContainers() throws Exception - { - List jsonObjects = restClient.authenticateUser(adminUserModel) - .withParams("relations=containers").withCoreAPI().usingSite(publicSite).getSiteWithRelations(); - - RestSiteModel siteModel = (RestSiteModel) jsonObjects.get(0); - RestSiteContainerModelsCollection containers = (RestSiteContainerModelsCollection) jsonObjects.get(1); - - siteModel.assertThat().field("visibility").is(publicSite.getVisibility()) - .and().field("id").is(publicSite.getId()) - .and().field("description").is(publicSite.getDescription()) - .and().field("title").is(publicSite.getTitle()) - .and().field("preset").is("site-dashboard") - .and().field("guid").isNotEmpty(); - - containers.assertThat().entriesListCountIs(1) - .and().entriesListContains("folderId", ContainerName.documentLibrary.toString()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION } ) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Check that relations parameter is applied for members") - public void checkThatRelationsParameterIsAppliedForMembers() throws Exception - { - SiteModel publicRandomSite = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - List jsonObjects = restClient.authenticateUser(adminUserModel) - .withParams("relations=members").withCoreAPI().usingSite(publicRandomSite).getSiteWithRelations(); - - RestSiteModel siteModel = (RestSiteModel) jsonObjects.get(0); - RestSiteMemberModelsCollection siteMembers = (RestSiteMemberModelsCollection) jsonObjects.get(1); - - siteModel.assertThat().field("visibility").is(publicRandomSite.getVisibility()) - .and().field("id").is(publicRandomSite.getId()) - .and().field("description").is(publicRandomSite.getDescription()) - .and().field("title").is(publicRandomSite.getTitle()) - .and().field("preset").is("site-dashboard") - .and().field("guid").isNotEmpty(); - - siteMembers.assertThat().entriesListCountIs(1) - .assertThat().entriesListContains("id", adminUserModel.getUsername()) - .assertThat().entriesListContains("role", UserRole.SiteManager.toString()); - siteMembers.getOneRandomEntry().onModel().assertThat().field("person.firstName").is("Administrator") - .and().field("person.id").is("admin"); - } - - @Test(groups="demo") - public void checkThatRelationsParameterIsAppliedForMembersCustom() - { - /*1 - select API endpoint*/ - restClient.withCoreAPI(); - - /*2 - define request */ - RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "sites/{siteId}?{parameters}", publicSite.getId(), "relations=members"); - - /*3 - send request */ - RestResponse response = restClient.authenticateUser(adminUserModel).process(request); - - /*assertions */ - response.assertThat().body("entry.id", equalTo(publicSite.getId())); - response.assertThat().body("relations.members.list.entries.entry[0].role", equalTo("SiteManager")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION } ) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Check that relations parameter is applied for containers and members") - public void checkThatRelationsParameterIsAppliedForContainersAndMembers() throws Exception - { - SiteModel publicRandomSite = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - List jsonObjects = restClient.authenticateUser(adminUserModel) - .withParams("relations=containers,members").withCoreAPI().usingSite(publicRandomSite).getSiteWithRelations(); - - RestSiteModel siteModel = (RestSiteModel) jsonObjects.get(0); - RestSiteContainerModelsCollection containers = (RestSiteContainerModelsCollection) jsonObjects.get(1); - RestSiteMemberModelsCollection siteMembers = (RestSiteMemberModelsCollection) jsonObjects.get(2); - - siteModel.assertThat().field("visibility").is(publicRandomSite.getVisibility()) - .and().field("id").is(publicRandomSite.getId()) - .and().field("description").is(publicRandomSite.getDescription()) - .and().field("title").is(publicRandomSite.getTitle()) - .and().field("preset").is("site-dashboard") - .and().field("guid").isNotEmpty(); - - containers.assertThat().entriesListCountIs(1) - .and().entriesListContains("folderId", ContainerName.documentLibrary.toString()); - - siteMembers.assertThat().entriesListCountIs(1) - .assertThat().entriesListContains("id", adminUserModel.getUsername()) - .assertThat().entriesListContains("role", UserRole.SiteManager.toString()); - siteMembers.getOneRandomEntry().onModel().assertThat().field("person.firstName").is("Administrator") - .and().field("person.id").is("admin"); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/GetSitesTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/GetSitesTests.java deleted file mode 100644 index 2d986ab57..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/GetSitesTests.java +++ /dev/null @@ -1,484 +0,0 @@ -package org.alfresco.service.search.rest.sites; - -import org.alfresco.dataprep.SiteService; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.*; -import org.alfresco.utility.constants.ContainerName; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.data.RandomData; -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.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import java.util.List; - -/** - * @author iulia.cojocea - */ -public class GetSitesTests extends RestTest -{ - private UserModel adminUser; - private UserModel lastPrivateSiteManager; - private ListUserWithRoles usersWithRoles; - private SiteModel siteModel; - private UserModel regularUser, privateSiteManager, privateSiteConsumer; - private SiteModel firstPublicSite, firstPrivateSite, firstModeratedSite, deletedSite; - private SiteModel lastPublicSite, lastPrivateSite, lastModeratedSite; - private RestSiteModelsCollection sites; - private String name; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - regularUser = dataUser.createRandomTestUser(); - lastPrivateSiteManager = dataUser.createRandomTestUser(); - privateSiteManager = dataUser.createRandomTestUser(); - privateSiteConsumer = dataUser.createRandomTestUser(); - - siteModel = new SiteModel(RandomData.getRandomName("0-PublicSite")); - firstPublicSite = dataSite.usingAdmin().createSite(siteModel); - siteModel = new SiteModel(RandomData.getRandomName("0-PrivateSite"), SiteService.Visibility.PRIVATE); - firstPrivateSite = dataSite.usingAdmin().createSite(siteModel); - siteModel = new SiteModel(RandomData.getRandomName("0-ModeratedSite"), SiteService.Visibility.MODERATED); - firstModeratedSite = dataSite.usingAdmin().createSite(siteModel); - dataUser.addUserToSite(privateSiteManager, firstPrivateSite, UserRole.SiteManager); - dataUser.addUserToSite(privateSiteConsumer, firstPrivateSite, UserRole.SiteConsumer); - deletedSite = dataSite.usingAdmin().createPublicRandomSite(); - - name = RandomData.getRandomName("ZZZZZZZZZ-PublicSite"); - lastPublicSite = dataSite.usingAdmin().createSite(new SiteModel(SiteService.Visibility.PUBLIC, "guid", name, name, name)); - lastPrivateSite = dataSite.usingAdmin().createSite(new SiteModel(RandomData.getRandomName("ZZZZZZZZZ-PrivateSite"), SiteService.Visibility.PRIVATE)); - lastModeratedSite = dataSite.usingAdmin().createSite(new SiteModel(RandomData.getRandomName("ZZZZZZZZZ-ModeratedSite"), SiteService.Visibility.MODERATED)); - - adminUser = dataUser.getAdminUser(); - siteModel = dataSite.usingAdmin().createPublicRandomSite(); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); - dataUser.addUserToSite(lastPrivateSiteManager, lastPrivateSite, 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 sites information and gets status code OK (200)") - public void managerIsAbleToRetrieveSites() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withParams("maxItems=10000") - .withCoreAPI().getSites() - .assertThat().entriesListIsNotEmpty() - .assertThat().entriesListContains("id", siteModel.getId()) - .and().paginationExist(); - 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 sites information and gets status code OK (200)") - public void collaboratorIsAbleToRetrieveSites() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withParams("maxItems=10000") - .withCoreAPI().getSites().assertThat().entriesListIsNotEmpty() - .assertThat().entriesListContains("id", siteModel.getId()) - .and().paginationExist(); - - 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 sites information and gets status code OK (200)") - public void contributorIsAbleToRetrieveSites() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withParams("maxItems=10000") - .withCoreAPI().getSites() - .assertThat().entriesListIsNotEmpty() - .assertThat().entriesListContains("id", siteModel.getId()) - .and().paginationExist(); - 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 sites information and gets status code OK (200)") - public void consumerIsAbleToRetrieveSites() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withParams("maxItems=10000") - .withCoreAPI().getSites() - .assertThat().entriesListIsNotEmpty() - .assertThat().entriesListContains("id", siteModel.getId()) - .and().paginationExist(); - 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 sites information and gets status code OK (200)") - public void adminUserIsAbleToRetrieveSites() throws Exception - { - restClient.authenticateUser(adminUser).withParams("maxItems=10000") - .withCoreAPI().getSites() - .assertThat().entriesListIsNotEmpty() - .assertThat().entriesListContains("id", siteModel.getId()) - .and().paginationExist(); - 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 sites call returns status code 401") -// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void unauthenticatedUserIsNotAuthorizedToRetrieveSites() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - UserModel userModel = dataUser.createRandomTestUser(); - userModel.setPassword("user wrong password"); - dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); - restClient.authenticateUser(userModel).withParams("maxItems=1") - .withCoreAPI().getSites(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if get sites request returns status code 400 when invalid maxItems parameter is used") - public void getSitesWithInvalidMaxItems() throws Exception - { - restClient.authenticateUser(regularUser).withParams("maxItems=0=09") - .withCoreAPI().getSites(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "0=09")); - - restClient.withParams("maxItems=A") - .withCoreAPI().getSites(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "A")); - - restClient.withParams("maxItems=0") - .withCoreAPI().getSites(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if get sites request returns status code 400 when invalid skipCount parameter is used") - public void getSitesWithInvalidSkipCount() throws Exception - { - restClient.authenticateUser(regularUser).withParams("skipCount=A") - .withCoreAPI().getSites(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "A")); - - restClient.authenticateUser(regularUser).withParams("skipCount=-1") - .withCoreAPI().getSites(); - 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 User gets sites ordered by title ascending and status code is 200") - public void getSitesOrderedByTitleASC() throws Exception - { - sites = restClient.authenticateUser(privateSiteManager).withParams("orderBy=title ASC") - .withCoreAPI().getSites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - sites.assertThat().entriesListIsNotEmpty(); - List sitesList = sites.getEntries(); - sitesList.get(0).onModel().assertThat().field("title").is(firstModeratedSite.getTitle()); - sitesList.get(1).onModel().assertThat().field("title").is(firstPrivateSite.getTitle()); - sitesList.get(2).onModel().assertThat().field("title").is(firstPublicSite.getTitle()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if a regular user gets all public and moderated sites and status code is 200") - public void regularUserGetsOnlyPublicAndModeratedSites() throws Exception - { - sites = restClient.authenticateUser(regularUser).withParams("maxItems=5000") - .withCoreAPI().getSites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - sites.assertThat().entriesListContains("title", firstPublicSite.getTitle()) - .and().entriesListContains("title", firstModeratedSite.getTitle()) - .and().entriesListDoesNotContain("title", firstPrivateSite.getTitle()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if a member of a private site gets the private site, all public sites and all moderated sites. Verify if status code is 200") - public void privateSiteMemberGetsSitesVisibleForHim() throws Exception - { - sites = restClient.authenticateUser(privateSiteConsumer).withParams("maxItems=5000") - .withCoreAPI().getSites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - sites.assertThat().entriesListContains("title", firstPublicSite.getTitle()) - .and().entriesListContains("title", firstModeratedSite.getTitle()) - .and().entriesListContains("title", firstPrivateSite.getTitle()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if a site is not retrieved anymore after deletion and status code is 200") - public void checkDeletedSiteIsNotRetrieved() throws Exception - { - sites = restClient.authenticateUser(regularUser).withParams("maxItems=5000").withCoreAPI().getSites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - sites.assertThat().entriesListContains("title", deletedSite.getTitle()); - - dataSite.usingAdmin().deleteSite(deletedSite); - - sites = restClient.withParams("maxItems=5000").withCoreAPI().getSites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - sites.assertThat().entriesListDoesNotContain("title", deletedSite.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 sites ordered by title descending and status code is 200") - public void getSitesOrderedByTitleDESC() throws Exception - { - int totalItems = restClient.authenticateUser(lastPrivateSiteManager).withCoreAPI().getSites().getPagination().getTotalItems(); - sites = restClient.authenticateUser(lastPrivateSiteManager).withParams(String.format("maxItems=%s&orderBy=title DESC", totalItems)) - .withCoreAPI().getSites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - sites.assertThat().entriesListIsNotEmpty(); - List sitesList = sites.getEntries(); - sitesList.get(0).onModel().assertThat().field("title").is(lastPublicSite.getTitle()); - sitesList.get(1).onModel().assertThat().field("title").is(lastPrivateSite.getTitle()); - sitesList.get(2).onModel().assertThat().field("title").is(lastModeratedSite.getTitle()); - sitesList.get(sitesList.size()-1).onModel().assertThat().field("title").is(firstModeratedSite.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 sites ordered by id ascending and status code is 200") - public void getSitesOrderedByIdASC() throws Exception - { - int totalItems = restClient.authenticateUser(lastPrivateSiteManager).withCoreAPI().getSites().getPagination().getTotalItems(); - sites = restClient.authenticateUser(lastPrivateSiteManager).withParams(String.format("maxItems=%s&orderBy=id ASC", totalItems)) - .withCoreAPI().getSites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - sites.assertThat().entriesListIsNotEmpty(); - List sitesList = sites.getEntries(); - sitesList.get(sitesList.size()-1).onModel().assertThat().field("id").is(lastPublicSite.getId()); - sitesList.get(sitesList.size()-2).onModel().assertThat().field("id").is(lastPrivateSite.getId()); - sitesList.get(sitesList.size()-3).onModel().assertThat().field("id").is(lastModeratedSite.getId()); - sitesList.get(0).onModel().assertThat().field("id").is(firstModeratedSite.getId()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION}) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify pagination") - public void checkPagination() throws Exception - { - sites = restClient.authenticateUser(regularUser).withCoreAPI().getSites(); - sites.getPagination().assertThat() - .field("totalItems").isNotEmpty().and() - .field("maxItems").is("100").and() - .field("hasMoreItems").is((sites.getPagination().getTotalItems() > sites.getPagination().getMaxItems()) ? "true" : "false").and() - .field("skipCount").is("0").and() - .field("count").is((sites.getPagination().isHasMoreItems()) ? sites.getPagination().getMaxItems() : sites.getPagination().getTotalItems()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION}) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify user can get only first two sites and status code is 200") - public void getFirstTwoSites() throws Exception - { - sites = restClient.authenticateUser(regularUser).withParams(String.format("maxItems=%s&orderBy=title ASC", 2)) - .withCoreAPI().getSites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - sites.getPagination().assertThat().field("maxItems").is("2").and().field("count").is("2"); - sites.assertThat().entriesListCountIs(2).and().entriesListDoesNotContain(firstPublicSite.getId()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION}) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify user can get sites using high skipCount parameter and status code is 200") - public void getSitesUsingHighSkipCount() throws Exception - { - RestSiteModelsCollection allSites = restClient.authenticateUser(regularUser).withCoreAPI().getSites(); - sites = restClient.withParams("skipCount=100").withCoreAPI().getSites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - sites.assertThat().paginationField("skipCount").is("100"); - if(allSites.getPagination().getTotalItems() > 100) - sites.assertThat().entriesListIsNotEmpty(); - else - sites.assertThat().entriesListIsEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION}) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify user can not get sites using zero maxItems parameter and status code is 400") - public void userCanNotGetSitesUsingZeroMaxItems() throws Exception - { - sites = restClient.authenticateUser(regularUser).withParams("maxItems=0").withCoreAPI().getSites(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsErrorKey(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) - .containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) - .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 that getSites request applies valid properties param and status code is 200") - public void getSitesRequestWithValidPropertiesParam() throws Exception - { - sites = restClient.authenticateUser(regularUser).withParams("properties=id").withCoreAPI().getSites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - sites.assertThat().entriesListDoesNotContain("description") - .assertThat().entriesListDoesNotContain("title") - .assertThat().entriesListDoesNotContain("visibility") - .assertThat().entriesListDoesNotContain("guid") - .assertThat().entriesListContains("id"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION}) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify pagination when skipCount and MaxItems are used") - public void checkPaginationWithSkipCountAndMaxItems() throws Exception - { - sites = restClient.authenticateUser(regularUser).withParams("skipCount=10&maxItems=110").withCoreAPI().getSites(); - sites.getPagination().assertThat() - .field("totalItems").isNotEmpty().and() - .field("maxItems").is("110").and() - .field("hasMoreItems").is((sites.getPagination().getTotalItems() - sites.getPagination().getSkipCount() > sites.getPagination().getMaxItems())?"true":"false").and() - .field("skipCount").is("10").and() - .field("count").is((sites.getPagination().isHasMoreItems()) ? sites.getPagination().getMaxItems() - : sites.getPagination().getTotalItems() - sites.getPagination().getSkipCount()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION}) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if User gets sites ordered by id ascending and status code is 200") - public void getSitesOrderedByTitleASCAndVisibilityASC() throws Exception - { - SiteModel secondPublicSite = dataSite.usingAdmin().createSite( - new SiteModel(SiteService.Visibility.PUBLIC, "guid", name+"A", name+"A", name)); - SiteModel thirdPublicSite = dataSite.usingAdmin().createSite( - new SiteModel(SiteService.Visibility.PUBLIC, "guid", name+"B", name+"B", name)); - - int totalItems = restClient.authenticateUser(regularUser).withCoreAPI().getSites().getPagination().getTotalItems(); - sites = restClient.authenticateUser(regularUser).withParams(String.format("maxItems=%s&orderBy=title ASC&orderBy=description ASC", totalItems)) - .withCoreAPI().getSites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - sites.assertThat().entriesListIsNotEmpty(); - List sitesList = sites.getEntries(); - sitesList.get(sitesList.size()-1).onModel().assertThat().field("title").is(thirdPublicSite.getTitle()); - sitesList.get(sitesList.size()-2).onModel().assertThat().field("title").is(secondPublicSite.getTitle()); - - dataSite.usingAdmin().deleteSite(secondPublicSite); - dataSite.usingAdmin().deleteSite(thirdPublicSite); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION} ) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Check that relations parameter is applied for containers") - public void checkThatRelationsParameterIsAppliedForContainers() throws Exception - { - List> jsonObjects = restClient.authenticateUser(adminUser) - .withParams("relations=containers").withCoreAPI().usingSite(lastPublicSite).getSitesWithRelations(); - - List siteObjects = jsonObjects.get(0); - for (int i = 0; i < siteObjects.size(); i++) - { - RestSiteModel siteModel = (RestSiteModel) siteObjects.get(i); - siteModel.assertThat().field("visibility").isNotEmpty() - .and().field("id").isNotEmpty() - .and().field("title").isNotEmpty() - .and().field("preset").is("site-dashboard") - .and().field("guid").isNotEmpty(); - } - - List containerObjects = jsonObjects.get(1); - for (int i = 0; i < containerObjects.size(); i++) - { - RestSiteContainerModelsCollection containers = (RestSiteContainerModelsCollection) containerObjects.get(i); - containers.assertThat().entriesListIsNotEmpty().and().entriesListContains("folderId", ContainerName.documentLibrary.toString()); - } - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION} ) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Check that relations parameter is applied for members") - public void checkThatRelationsParameterIsAppliedForMembers() throws Exception - { - List> jsonObjects = restClient.authenticateUser(adminUser) - .withParams("relations=members").withCoreAPI().usingSite(lastPublicSite).getSitesWithRelations(); - - List siteObjects = jsonObjects.get(0); - for (int i = 0; i < siteObjects.size(); i++) - { - RestSiteModel siteModel = (RestSiteModel) siteObjects.get(i); - siteModel.assertThat().field("visibility").isNotEmpty() - .and().field("id").isNotEmpty() - .and().field("title").isNotEmpty() - .and().field("preset").is("site-dashboard") - .and().field("guid").isNotEmpty(); - } - - List memberObjects = jsonObjects.get(1); - for (int i = 0; i < memberObjects.size(); i++) - { - RestSiteMemberModelsCollection siteMembers = (RestSiteMemberModelsCollection) memberObjects.get(i); - siteMembers.assertThat().entriesListIsNotEmpty().assertThat().entriesListContains("id").assertThat().entriesListContains("role", UserRole.SiteManager.toString()); - siteMembers.getOneRandomEntry().onModel().assertThat().field("person.firstName").isNotEmpty().and().field("person.id").isNotEmpty(); - } - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION} ) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Check that relations parameter is applied for members and containers") - public void checkThatRelationsParameterIsAppliedForMembersAndContainers() throws Exception - { - List> jsonObjects = restClient.authenticateUser(adminUser) - .withParams("relations=containers,members").withCoreAPI().usingSite(lastPublicSite).getSitesWithRelations(); - - List siteObjects = jsonObjects.get(0); - for (int i = 0; i < siteObjects.size(); i++) - { - RestSiteModel siteModel = (RestSiteModel) siteObjects.get(i); - siteModel.assertThat().field("visibility").isNotEmpty() - .and().field("id").isNotEmpty() - .and().field("title").isNotEmpty() - .and().field("preset").is("site-dashboard") - .and().field("guid").isNotEmpty(); - } - - List containerObjects = jsonObjects.get(1); - for (int i = 0; i < containerObjects.size(); i++) - { - RestSiteContainerModelsCollection containers = (RestSiteContainerModelsCollection) containerObjects.get(i); - containers.assertThat().entriesListIsNotEmpty().and().entriesListContains("folderId", ContainerName.documentLibrary.toString()); - } - - List memberObjects = jsonObjects.get(2); - for (int i = 0; i < memberObjects.size(); i++) - { - RestSiteMemberModelsCollection siteMembers = (RestSiteMemberModelsCollection) memberObjects.get(i); - siteMembers.assertThat().entriesListIsNotEmpty().assertThat().entriesListContains("id").assertThat().entriesListContains("role", UserRole.SiteManager.toString()); - siteMembers.getOneRandomEntry().onModel().assertThat().field("person.firstName").isNotEmpty().and().field("person.id").isNotEmpty(); - } - } - - @AfterClass(alwaysRun=true) - public void cleanup() throws Exception - { - dataSite.usingAdmin().deleteSite(firstModeratedSite); - dataSite.usingAdmin().deleteSite(firstPrivateSite); - dataSite.usingAdmin().deleteSite(firstPublicSite); - - dataSite.usingAdmin().deleteSite(lastPublicSite); - dataSite.usingAdmin().deleteSite(lastPrivateSite); - dataSite.usingAdmin().deleteSite(lastModeratedSite); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/SitesNetworkTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/SitesNetworkTests.java deleted file mode 100644 index ea3a9a2e3..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/SitesNetworkTests.java +++ /dev/null @@ -1,85 +0,0 @@ -package org.alfresco.service.search.rest.sites; - -import org.alfresco.dataprep.SiteService; -import org.alfresco.service.search.rest.NetworkDataPrep; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestSiteMembershipRequestModel; -import org.alfresco.utility.model.SiteModel; -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.BeforeClass; -import org.testng.annotations.Test; - -public class SitesNetworkTests extends NetworkDataPrep -{ - protected SiteModel siteModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - init(); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION, TestGroup.NETWORKS }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify create site membership request returns status code 404 when personId is not member of the domain.") - public void addSiteMembershipRequestWhenPersonIdIsNotInTheDomain() throws Exception - { - restClient.authenticateUser(adminTenantUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(siteModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, adminTenantUser.getUsername().toLowerCase(), siteModel.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION, TestGroup.NETWORKS }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify create site membership request returns status code 200 with tenant.") - public void addSiteMembershipRequestWithTenant() throws Exception - { - SiteModel tenantPublicSite = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); - RestSiteMembershipRequestModel siteMembershipRequest = restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(tenantPublicSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - siteMembershipRequest.assertThat().field("id").is(tenantPublicSite.getId()) - .assertThat().field("site").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Add process item using by admin in other network.") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void getSiteMembershipRequestByAdminInOtherNetwork() throws Exception - { - SiteModel moderatedSite = dataSite.usingUser(secondAdminTenantUser).createModeratedRandomSite(); - - restClient.authenticateUser(adminTenantUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - restClient.authenticateUser(secondAdminTenantUser).withCoreAPI().usingAuthUser().getSiteMembershipRequest(moderatedSite); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, secondAdminTenantUser.getUsername().toLowerCase(), moderatedSite.getId())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Add process item using by the admin in same network.") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void getSiteMembershipRequestByAdminSameNetwork() throws Exception - { - SiteModel moderatedSite = dataSite.usingUser(adminTenantUser).createModeratedRandomSite(); - restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - - RestSiteMembershipRequestModel returnedModel = restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().getSiteMembershipRequest(moderatedSite); - - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedModel.assertThat().field("id").is(moderatedSite.getId()) - .and().field("message").is("Please accept me") - .and().field("site.title").is(moderatedSite.getTitle()) - .and().field("site.visibility").is(SiteService.Visibility.MODERATED.toString()) - .and().field("site.guid").isNotEmpty() - .and().field("site.description").is(moderatedSite.getDescription()) - .and().field("site.preset").is("site-dashboard"); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/SitesTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/SitesTests.java deleted file mode 100644 index 6f2923d0b..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/SitesTests.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.alfresco.service.search.rest.sites; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestSiteModel; -import org.alfresco.utility.model.SiteModel; -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/#!/sites - * - * @author Ana Bozianu - */ -public class SitesTests extends RestTest -{ - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Tests the creation of a site") - public void testCreateSite() throws Exception - { - SiteModel site = RestSiteModel.getRandomSiteModel(); - - RestSiteModel createdSite = restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingSite(site).createSite(); - - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - createdSite.assertThat().field("id").is(site.getId()) - .assertThat().field("title").is(site.getTitle()) - .assertThat().field("description").is(site.getDescription()) - .assertThat().field("visibility").is(site.getVisibility()); - } - -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/containers/GetSiteContainerTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/containers/GetSiteContainerTests.java deleted file mode 100644 index 94c2782b8..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/containers/GetSiteContainerTests.java +++ /dev/null @@ -1,304 +0,0 @@ -package org.alfresco.service.search.rest.sites.containers; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestSiteContainerModel; -import org.alfresco.utility.constants.ContainerName; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.apache.commons.lang3.RandomStringUtils; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * @author iulia.cojocea - */ -public class GetSiteContainerTests extends RestTest -{ - private UserModel adminUserModel; - private SiteModel publicSiteModel, moderatedSiteModel, privateSiteModel, adminPrivateSiteModel; - private ListUserWithRoles usersWithRoles; - private RestSiteContainerModel siteContainerModel; - private UserModel testUser; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - testUser = dataUser.createRandomTestUser(); - - publicSiteModel = dataSite.usingAdmin().createPublicRandomSite(); - moderatedSiteModel = dataSite.usingUser(testUser).createModeratedRandomSite(); - privateSiteModel = dataSite.usingUser(testUser).createPrivateRandomSite(); - adminPrivateSiteModel = dataSite.usingAdmin().createPrivateRandomSite(); - - usersWithRoles = dataUser.addUsersWithRolesToSite(publicSiteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - - dataLink.usingAdmin().usingSite(publicSiteModel).createRandomLink(); - - dataLink.usingAdmin().usingSite(adminPrivateSiteModel).createRandomLink(); - - dataLink.usingUser(testUser).usingSite(privateSiteModel).createRandomLink(); - } - - @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 container and gets status code OK (200)") - public void getSiteContainerWithManagerRole() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - siteContainerModel = restClient.withCoreAPI().usingSite(publicSiteModel).getSiteContainers().getOneRandomEntry(); - restClient.withCoreAPI().usingSite(publicSiteModel).getSiteContainer(siteContainerModel.onModel()) - .assertThat().field("id").is(siteContainerModel.onModel().getId()) - .and().field("folderId").is(siteContainerModel.onModel().getFolderId()); - 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 container and gets status code OK (200)") - public void getSiteContainerWithCollaboratorRole() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - siteContainerModel = restClient.withCoreAPI().usingSite(publicSiteModel).getSiteContainers().getOneRandomEntry(); - restClient.withCoreAPI().usingSite(publicSiteModel).getSiteContainer(siteContainerModel.onModel()) - .and().field("id").is(siteContainerModel.onModel().getId()) - .and().field("folderId").is(siteContainerModel.onModel().getFolderId()); - 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 container and gets status code OK (200)") - public void getSiteContainerWithContributorRole() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - siteContainerModel = restClient.withCoreAPI().usingSite(publicSiteModel).getSiteContainers().getOneRandomEntry(); - restClient.withCoreAPI().usingSite(publicSiteModel).getSiteContainer(siteContainerModel.onModel()) - .assertThat().field("id").is(siteContainerModel.onModel().getId()) - .and().field("folderId").is(siteContainerModel.onModel().getFolderId()); - 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 container and gets status code OK (200)") - public void getSiteContainerWithConsumerRole() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - siteContainerModel = restClient.withCoreAPI().usingSite(publicSiteModel).getSiteContainers().getOneRandomEntry(); - restClient.withCoreAPI().usingSite(publicSiteModel).getSiteContainer(siteContainerModel.onModel()) - .assertThat().field("id").is(siteContainerModel.onModel().getId()) - .and().field("folderId").is(siteContainerModel.onModel().getFolderId()); - 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 container and gets status code OK (200)") - public void getSiteContainerWithAdminUser() throws Exception - { - restClient.authenticateUser(adminUserModel); - siteContainerModel = restClient.withCoreAPI().usingSite(publicSiteModel).getSiteContainers().getOneRandomEntry(); - restClient.withCoreAPI().usingSite(publicSiteModel).getSiteContainer(siteContainerModel.onModel()) - .assertThat().field("id").is(siteContainerModel.onModel().getId()) - .and().field("folderId").is(siteContainerModel.onModel().getFolderId()); - 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 container call returns status code 401") - public void unauthenticatedUserIsNotAuthorizedToRetrieveSiteContainer() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - siteContainerModel = restClient.withCoreAPI().usingSite(publicSiteModel).getSiteContainers().getOneRandomEntry(); - UserModel userModel = dataUser.createRandomTestUser(); - userModel.setPassword("user wrong password"); - dataUser.addUserToSite(userModel, publicSiteModel, UserRole.SiteManager); - restClient.authenticateUser(userModel) - .withCoreAPI().usingSite(publicSiteModel).getSiteContainer(siteContainerModel.onModel()); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if get container request returns status code 400 when site doesn't exist") - public void getContainerWithNonExistentSite() throws Exception - { - restClient.authenticateUser(testUser) - .withCoreAPI().usingSite("NonExistentSiteId").getSiteContainer(ContainerName.links.toString()); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, "NonExistentSiteId", ContainerName.links.toString())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if get container request returns status code 400 when container item doesn't exist") - public void getContainerWithNonExistentItem() throws Exception - { - restClient.authenticateUser(testUser) - .withCoreAPI().usingSite(publicSiteModel).getSiteContainer("NonExistentFolder"); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, publicSiteModel.getId(), "NonExistentFolder")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify regular user can get container for public site and request returns status 200") - public void getContainerForPublicSite() throws Exception - { - restClient.authenticateUser(testUser) - .withCoreAPI().usingSite(publicSiteModel).getSiteContainer(ContainerName.links.toString()) - .assertThat().field("folderId").is(ContainerName.links.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 manager is able to get container for his private site and request returns status 200") - public void getContainerForPrivateSite() throws Exception - { - restClient.authenticateUser(testUser) - .withCoreAPI().usingSite(privateSiteModel).getSiteContainer(ContainerName.links.toString()) - .assertThat().field("folderId").is(ContainerName.links.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 get container request returns status 200 for moderated site") - public void getContainerForModeratedSite() throws Exception - { - restClient.authenticateUser(testUser) - .withCoreAPI().usingSite(moderatedSiteModel).getSiteContainer(ContainerName.documentLibrary.toString()) - .assertThat().field("folderId").is(ContainerName.documentLibrary.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 if get container request with properties parameter returns status code 200 and parameter is applied") - public void getContainerUsingPropertiesParameter() throws Exception - { - restClient.authenticateUser(testUser) - .withCoreAPI().usingSite(publicSiteModel).usingParams("properties=id").getSiteContainer(ContainerName.links.toString()) - .assertThat().fieldsCount().is(1) - .and().field("id").isNotEmpty() - .and().field("folderId").isNull(); - 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 container request for a container that does not belong to site returns status code 404") - public void getContainerThatDoesNotBelongToSite() throws Exception - { - restClient.authenticateUser(testUser) - .withCoreAPI().usingSite(moderatedSiteModel).getSiteContainer(ContainerName.links.toString()); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, moderatedSiteModel.getId(), ContainerName.links.toString())) - .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 if get container request for empty siteId returns status code 404") - public void getContainerForEmptySiteId() throws Exception - { - restClient.authenticateUser(testUser) - .withCoreAPI().usingSite("").getSiteContainer(ContainerName.links.toString()); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, "", ContainerName.links.toString())) - .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 if get container request for empty container returns status code 200 and the list of containers") - public void getContainerForEmptyContainer() throws Exception - { - restClient.authenticateUser(testUser) - .withCoreAPI().usingSite(moderatedSiteModel).getSiteContainer(""); - 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 container with name containing special chars returns status code 404") - public void getContainerWithNameContainingSpecialChars() throws Exception - { - String containerSpecialName = RandomStringUtils.randomAlphabetic(2) + "~!%40%23%24%25%5E%26*()_%2B%5B%5D%7B%7D%7C%5C%3B%27%3A%22%2C.%2F%3C%3E"; - - restClient.authenticateUser(testUser) - .withCoreAPI().usingSite(publicSiteModel).getSiteContainer(containerSpecialName); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, publicSiteModel.getId(), containerSpecialName)) - .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 if admin can get container request for a private site created by another user and status code is 200") - public void adminCanGetContainerForPrivateSiteCreatedByUser() throws Exception - { - restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingSite(privateSiteModel).getSiteContainer(ContainerName.links.toString()) - .assertThat().field("folderId").is(ContainerName.links.toString()) - .and().field("id").isNotEmpty(); - 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 user cannot get container request for a private site created by admin and status code is 404") - public void userCannotGetContainerForPrivateSiteCreatedByAdmin() throws Exception - { - restClient.authenticateUser(testUser) - .withCoreAPI().usingSite(adminPrivateSiteModel).getSiteContainer(ContainerName.links.toString()); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, adminPrivateSiteModel.getId(), ContainerName.links.toString())) - .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 if get container request for a deleted container returns status code is 404") - public void getContainerThatWasDeleted() throws Exception - { - restClient.authenticateUser(testUser) - .withCoreAPI().usingSite(privateSiteModel).getSiteContainer(ContainerName.links.toString()) - .assertThat().field("folderId").is(ContainerName.links.toString()); - restClient.assertStatusCodeIs(HttpStatus.OK); - - //use dataprep for delete 'links' container - FolderModel folder= new FolderModel("links"); - folder.setCmisLocation(String.format("/Sites/%s/%s", privateSiteModel.getId(), ContainerName.links.toString())); - dataContent.deleteTree(folder); - - restClient.authenticateUser(testUser) - .withCoreAPI().usingSite(privateSiteModel).getSiteContainer(ContainerName.links.toString()); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, privateSiteModel.getId(), ContainerName.links.toString())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/containers/GetSiteContainersTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/containers/GetSiteContainersTests.java deleted file mode 100644 index b6bd7cc8a..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/containers/GetSiteContainersTests.java +++ /dev/null @@ -1,381 +0,0 @@ -package org.alfresco.service.search.rest.sites.containers; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestSiteContainerModelsCollection; -import org.alfresco.utility.constants.ContainerName; -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 GetSiteContainersTests extends RestTest -{ - private UserModel adminUserModel; - private SiteModel publicSiteModel, publicSiteWithContainers; - private SiteModel moderatedSiteModel, privateSiteModel; - private ListUserWithRoles publicSiteUsers; - private ListUserWithRoles publicSiteWithContainersUsers; - private RestSiteContainerModelsCollection restSiteContainers; - private int totalItems; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - publicSiteModel = dataSite.usingAdmin().createPublicRandomSite(); - publicSiteWithContainers = dataSite.usingAdmin().createPublicRandomSite(); - moderatedSiteModel = dataSite.usingAdmin().createModeratedRandomSite(); - privateSiteModel = dataSite.usingAdmin().createPrivateRandomSite(); - - publicSiteUsers = dataUser.addUsersWithRolesToSite(publicSiteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); - - publicSiteWithContainersUsers = dataUser - .addUsersWithRolesToSite(publicSiteWithContainers, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - - dataLink.usingAdmin().usingSite(publicSiteWithContainers).createRandomLink(); - - dataLink.usingAdmin().usingSite(moderatedSiteModel).createRandomLink(); - - dataLink.usingAdmin().usingSite(privateSiteModel).createRandomLink(); - - restSiteContainers = restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers(); - totalItems = restSiteContainers.getPagination().getTotalItems(); - } - - @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 containers and gets status code OK (200)") - public void getSiteContainersWithManagerRole() throws Exception - { - restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingSite(publicSiteModel).getSiteContainers() - .assertThat().entriesListIsNotEmpty() - .assertThat().paginationExist() - .and().paginationField("count").isNot("0"); - 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 containers and gets status code OK (200)") - public void getSiteContainersWithCollaboratorRole() throws Exception - { - restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.withCoreAPI().usingSite(publicSiteModel).getSiteContainers() - .assertThat().entriesListIsNotEmpty() - .assertThat().paginationExist() - .and().paginationField("count").isNot("0"); - 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 containers and gets status code OK (200)") - public void getSiteContainersWithContributorRole() throws Exception - { - restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteContributor)); - restClient.withCoreAPI().usingSite(publicSiteModel).getSiteContainers() - .assertThat().entriesListIsNotEmpty() - .assertThat().paginationExist() - .and().paginationField("count").isNot("0"); - 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 containers and gets status code OK (200)") - public void getSiteContainersWithConsumerRole() throws Exception - { - restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.withCoreAPI().usingSite(publicSiteModel).getSiteContainers() - .assertThat().entriesListIsNotEmpty() - .assertThat().paginationExist() - .and().paginationField("count").isNot("0"); - 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 containers information and gets status code OK (200)") - public void getSiteContainersWithAdminUser() throws Exception - { - restClient.authenticateUser(adminUserModel); - restClient.withCoreAPI().usingSite(publicSiteModel).getSiteContainers() - .assertThat().entriesListIsNotEmpty() - .assertThat().paginationExist() - .and().paginationField("count").isNot("0"); - 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 containers call returns status code 401 with Manager role") -// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void unauthenticatedUserIsNotAuthorizedToRetrieveSiteContainers() throws Exception - { - UserModel userModel = dataUser.createRandomTestUser(); - userModel.setPassword("user wrong password"); - dataUser.addUserToSite(userModel, publicSiteModel, UserRole.SiteManager); - restClient.authenticateUser(userModel) - .withCoreAPI().usingSite(publicSiteModel).getSiteContainers(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if get site container request returns status code 200 with valid maxItems parameter") - public void getContainersWithValidMaxItems() throws Exception - { - restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteManager)) - .withParams("maxItems=5") - .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() - .assertThat().entriesListCountIs(2) - .and().entriesListContains("folderId" , ContainerName.documentLibrary.toString()) - .and().entriesListContains("folderId", ContainerName.links.toString()); - restClient.assertStatusCodeIs(HttpStatus.OK); - - restClient.withParams("maxItems=1") - .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() - .assertThat().entriesListCountIs(1); - - restClient.withParams("maxItems=3") - .withCoreAPI().usingSite(publicSiteModel).getSiteContainers() - .assertThat().entriesListCountIs(1) - .and().entriesListContains("folderId", ContainerName.documentLibrary.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 if get site container request returns status code 400 when invalid maxItems parameter is used") - public void getContainersWithMaxItemsZero () throws Exception - { - restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteManager)) - .withParams("maxItems=0") - .withCoreAPI().usingSite(publicSiteModel).getSiteContainers(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary("Only positive values supported for maxItems"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if get site container request returns status code 400 when invalid maxItems parameter is used") - public void getContainersWithMaxItemsCharacter () throws Exception - { - restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)) - .withParams("maxItems=test") - .withCoreAPI().usingSite(publicSiteModel).getSiteContainers(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "test")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if get site container request returns status code 200 when maxItems parameter starts with multiple zero") - public void getContainersWithMaxItemsMultipleZero () throws Exception - { - restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteCollaborator)) - .withParams("maxItems=000007") - .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() - .assertThat().entriesListCountIs(2); - 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 containers request returns status code 200 when valid skipCount parameter is used") - public void getSiteContainersWithValidSkipCount() throws Exception - { - restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteManager)).withParams("skipCount=1") - .withCoreAPI().usingSite(publicSiteModel).getSiteContainers() - .assertThat().entriesListCountIs(0); - restClient.assertStatusCodeIs(HttpStatus.OK); - - restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteCollaborator)).withParams("skipCount=1") - .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() - .assertThat().entriesListCountIs(1); - restClient.assertStatusCodeIs(HttpStatus.OK); - - restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteConsumer)).withParams("skipCount=2") - .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() - .assertThat().entriesListCountIs(0); - restClient.assertStatusCodeIs(HttpStatus.OK); - - restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteCollaborator)).withParams("skipCount=0") - .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() - .assertThat().entriesListCountIs(2); - 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 containers request returns status code 400 when invalid skipCount parameter is used") - public void getSiteContainersWithSkipCountCharacter() throws Exception - { - restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)).withParams("skipCount=abc") - .withCoreAPI().usingSite(publicSiteModel).getSiteContainers(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "abc")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if get site containers request returns status code 200 when skipCount parameter starts with multiple zero") - public void getSiteContainersWithSkipCountMultipleZero() throws Exception - { - restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)).withParams("skipCount=00002") - .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() - .assertThat().entriesListCountIs(0); - 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 containers request returns status code 400 when site doesn't exist") - public void getSiteContainersWithNonExistentSite() throws Exception - { - restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingSite("NonExistentSiteId").getSiteContainers(); - 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 containers request returns status 200 for private site") - public void getSiteContainersForPrivateSite() throws Exception - { - restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingSite(privateSiteModel).getSiteContainers() - .assertThat().entriesListCountIs(2); - 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 get site containers request returns status 200 for moderated site") - public void getSiteContainersForModeratedSite() throws Exception - { - restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingSite(moderatedSiteModel).getSiteContainers() - .assertThat().entriesListCountIs(2); - 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 get site containers request returns status 200 for several containers") - public void getSiteContainersForSeveralItems() throws Exception - { - restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() - .assertThat().entriesListCountIs(2) - .and().entriesListContains("folderId" ,ContainerName.documentLibrary.toString()) - .and().entriesListContains("folderId", ContainerName.links.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 get site containers request returns status 200 for one container") - public void getSiteContainersWithOneItem() throws Exception - { - restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingSite(publicSiteModel).getSiteContainers() - .assertThat().entriesListCountIs(1) - .and().entriesListContains("folderId" ,ContainerName.documentLibrary.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 if get site container request with properties parameter applied returns status code 200") - public void getSiteContainersUsingPropertiesParameter() throws Exception - { - restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingSite(publicSiteWithContainers).usingParams("properties=folderId").getSiteContainers() - .assertThat().entriesListCountIs(2) - .and().entriesListContains("folderId", ContainerName.documentLibrary.toString()) - .and().entriesListContains("folderId", ContainerName.links.toString()) - .and().entriesListDoesNotContain("id"); - 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 container request for a container that is not empty returns status code 200") - public void getSiteContainersThatIsNotEmpty() throws Exception - { - restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() - .assertThat().entriesListCountIs(2) - .and().entriesListContains("folderId", ContainerName.documentLibrary.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 if get site containers request returns status code 200 when first container is skipped") - public void getSiteContainersAndSkipFirst() throws Exception - { - restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteCollaborator)) - .withParams("skipCount=1").withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() - .assertThat().entriesListCountIs(1) - .and().entriesListDoesNotContain("folderId", restSiteContainers.getEntries().get(0).onModel().getFolderId()) - .and().entriesListContains("folderId", restSiteContainers.getEntries().get(1).onModel().getFolderId()); - 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 containers request and get last container returns status code 200") - public void getLastSiteContainer() throws Exception - { - restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteCollaborator)) - .withParams("skipCount=" + String.valueOf(totalItems-1)).withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() - .assertThat().entriesListCountIs(1) - .and().entriesListDoesNotContain("folderId", restSiteContainers.getEntries().get(0).onModel().getFolderId()) - .and().entriesListContains("folderId", restSiteContainers.getEntries().get(1).onModel().getFolderId()); - 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 containers request returns status code 200 when high skipCount parameter is used") - public void getSiteContainersWithHighSkipCount() throws Exception - { - restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteCollaborator)) - .withParams("skipCount=999999").withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() - .assertThat().entriesListIsEmpty() - .and().entriesListCountIs(0) - .and().paginationField("skipCount").is("999999"); - 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 container request for an empty siteId returns status code 404") - public void getSiteContainersForEmptySiteId() throws Exception - { - restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingSite("").getSiteContainers(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/AddSiteMemberTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/AddSiteMemberTests.java deleted file mode 100644 index 7ce21de18..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/AddSiteMemberTests.java +++ /dev/null @@ -1,589 +0,0 @@ -package org.alfresco.service.search.rest.sites.members; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.core.JsonBodyGenerator; -import org.alfresco.rest.core.RestRequest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestSiteMemberModel; -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.HttpMethod; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class AddSiteMemberTests extends RestTest -{ - private UserModel adminUserModel; - private SiteModel publicSiteModel, moderatedSiteModel, privateSiteModel; - private ListUserWithRoles publicSiteUsersWithRoles, moderatedSiteUsersWithRoles, privateSiteUsersWithRoles; - private String addMemberJson, addMembersJson; - private RestSiteMemberModel memberModel; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - publicSiteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - moderatedSiteModel = dataSite.usingUser(adminUserModel).createModeratedRandomSite(); - privateSiteModel = dataSite.usingUser(adminUserModel).createPrivateRandomSite(); - publicSiteUsersWithRoles = dataUser.addUsersWithRolesToSite(publicSiteModel, - UserRole.SiteManager, - UserRole.SiteCollaborator, - UserRole.SiteConsumer, - UserRole.SiteContributor); - moderatedSiteUsersWithRoles = dataUser.addUsersWithRolesToSite(moderatedSiteModel, - UserRole.SiteManager, - UserRole.SiteCollaborator, - UserRole.SiteConsumer, - UserRole.SiteContributor); - privateSiteUsersWithRoles = dataUser.addUsersWithRolesToSite(privateSiteModel, - UserRole.SiteManager, - UserRole.SiteCollaborator, - UserRole.SiteConsumer, - UserRole.SiteContributor); - addMemberJson = "{\"role\":\"%s\",\"id\":\"%s\"}"; - addMembersJson = "{\"role\":\"%s\",\"id\":\"%s\"}, {\"role\":\"%s\",\"id\":\"%s\"}"; - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, - description = "Verify that manager is able to add site member and gets status code CREATED (201)") - public void managerIsAbleToAddSiteMember() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteCollaborator); - restClient.authenticateUser(publicSiteUsersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingSite(publicSiteModel).addPerson(testUser) - .assertThat().field("id").is(testUser.getUsername()) - .and().field("role").is(testUser.getUserRole()); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that site collaborator is not able to add site member and gets status code FORBIDDEN (403)") - public void collaboratorIsNotAbleToAddSiteMember() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteConsumer); - restClient.authenticateUser(publicSiteUsersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingSite(publicSiteModel).addPerson(testUser); - - restClient.assertLastError().containsSummary("Permission was denied"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION}) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that site contributor is not able to add site member and gets status code FORBIDDEN (403)") - public void contributorIsNotAbleToAddSiteMember() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteConsumer); - restClient.authenticateUser(publicSiteUsersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) - .withCoreAPI().usingSite(publicSiteModel).addPerson(testUser); - restClient.assertLastError().containsSummary("Permission was denied"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that site consumer is not able to add site member and gets status code FORBIDDEN (403)") - public void consumerIsNotAbleToAddSiteMember() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteConsumer); - restClient.authenticateUser(publicSiteUsersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .withCoreAPI().usingSite(publicSiteModel).addPerson(testUser); - restClient.assertLastError().containsSummary("Permission was denied"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, - description = "Verify that admin user is able to add site member and gets status code CREATED (201)") - public void adminIsAbleToAddSiteMember() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteConsumer); - restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingSite(publicSiteModel).addPerson(testUser) - .and().field("id").is(testUser.getUsername()) - .and().field("role").is(testUser.getUserRole()); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, - description = "Verify that unauthenticated user is not able to add site member") -// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void unauthenticatedUserIsNotAuthorizedToAddSiteMmeber() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteConsumer); - - UserModel userModel = dataUser.createRandomTestUser(); - userModel.setPassword("user wrong password"); - dataUser.addUserToSite(userModel, publicSiteModel, UserRole.SiteManager); - - restClient.authenticateUser(userModel) - .withCoreAPI().usingSite(publicSiteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that manager can add another user as manager to a public site and gets status code CREATED (201)") - public void addManagerToPublicSite() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteManager); - memberModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - memberModel.assertThat().field("id").is(testUser.getUsername()) - .and().field("role").is(testUser.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that manager can add another user as manager to a moderated site and gets status code CREATED (201)") - public void addManagerToModeratedSite() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteManager); - memberModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - memberModel.assertThat().field("id").is(testUser.getUsername()) - .and().field("role").is(testUser.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that manager can add another user as manager to a private site and gets status code CREATED (201)") - public void addManagerToPrivateSite() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteManager); - memberModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - memberModel.assertThat().field("id").is(testUser.getUsername()) - .and().field("role").is(testUser.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that consumer role is not able to add another user to a moderated site and gets status code 403") - public void addUserByConsumerToModeratedSite() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteConsumer); - restClient.authenticateUser(moderatedSiteUsersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingSite(moderatedSiteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that consumer role is not able to add another user to a private site and gets status code 403") - public void addUserByConsumerToPrivateSite() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteConsumer); - restClient.authenticateUser(privateSiteUsersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingSite(privateSiteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that collaborator role is not able to add another user to a moderated site and gets status code 403") - public void addUserByCollaboratorToModeratedSite() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteConsumer); - restClient.authenticateUser(moderatedSiteUsersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingSite(moderatedSiteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that collaborator role is not able to add another user to a private site and gets status code 403") - public void addUserByCollaboratorToPrivateSite() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteConsumer); - restClient.authenticateUser(privateSiteUsersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingSite(privateSiteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that contributor role is not able to add another user to a moderated site and gets status code 403") - public void addUserByContributorToModeratedSite() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteConsumer); - restClient.authenticateUser(moderatedSiteUsersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingSite(moderatedSiteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that contributor role is not able to add another user to a private site and gets status code 403") - public void addUserByContributorToPrivateSite() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteConsumer); - restClient.authenticateUser(privateSiteUsersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingSite(privateSiteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that a user without specified role can not be added to a site and gets status code 400") - public void canNotAddUserWithoutSpecifyingRoleToSite() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - restClient.authenticateUser(adminUserModel).withCoreAPI(); - String json = JsonBodyGenerator.keyValueJson("id", testUser.getUsername()); - RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, json, "sites/{siteId}/members?{parameters}", publicSiteModel.getId(), restClient.getParameters()); - restClient.processModel(RestSiteMemberModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(RestErrorModel.MUST_PROVIDE_ROLE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that a user with inexistent role can not be added to a site and gets status code 400") - public void canNotAddUserWithInexistentRoleToSite() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - restClient.authenticateUser(adminUserModel).withCoreAPI(); - RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, String.format("{\"role\":\"inexistentRole\",\"id\":\"%s\"}", testUser.getUsername()), "sites/{siteId}/members?{parameters}", publicSiteModel.getId(), restClient.getParameters()); - restClient.processModel(RestSiteMemberModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.UNKNOWN_ROLE, "inexistentRole")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that user can not add himself as a manager to a public site and gets status code 403") - public void userAddHimselfAsManagerToPublicSite() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteManager); - restClient.authenticateUser(testUser).withCoreAPI().usingSite(publicSiteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that user can not add himself as a manager to a moderated site and gets status code 403") - public void userAddHimselfAsManagerToModeratedSite() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteManager); - restClient.authenticateUser(testUser).withCoreAPI().usingSite(moderatedSiteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that user can not add himself as a manager to a private site and gets status code 404") - public void userAddHimselfAsManagerToPrivateSite() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteManager); - restClient.authenticateUser(testUser).withCoreAPI().usingSite(privateSiteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, privateSiteModel.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that user can not be added to an inexistent site and gets status code 404") - public void userIsNotAbleToAddUserToAnInexistentSite() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteManager); - SiteModel inexistentSite = new SiteModel("inexistentSite"); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(inexistentSite).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, inexistentSite.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that user can not be added to a site if an empty site id is provided and gets status code 404") - public void userIsNotAbleToAddAnotherUserUsingEmptySiteId() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteManager); - SiteModel inexistentSite = new SiteModel(""); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(inexistentSite).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, inexistentSite.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that inexistent user can not be added to site and gets status code 404") - public void userIsNotAbleToAddInexistentUserToSite() throws Exception - { - UserModel testUser = new UserModel("inexistentUser", "password"); - testUser.setUserRole(UserRole.SiteManager); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, testUser.getUsername())) - .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 that empty username can not be added to site and gets status code 400") - public void userIsNotAbleToAddEmptyUserIdToSite() throws Exception - { - UserModel testUser = new UserModel("", "password"); - testUser.setUserRole(UserRole.SiteManager); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.NO_CONTENT, testUser.getUsername())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that user can not add another user that is already a memeber and gets status code 409") - public void userIsNotAbleToAddUserThatIsAlreadyAMember() throws Exception - { - UserModel collaborator = moderatedSiteUsersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(collaborator); - restClient.assertStatusCodeIs(HttpStatus.CONFLICT).assertLastError().containsSummary(String.format(RestErrorModel.ALREADY_Site_MEMBER, collaborator.getUsername(), moderatedSiteModel.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that several users with different roles can be added once in a row to a site and gets status code 201") - public void addSeveralUsersWithDifferentRolesToASite() throws Exception - { - UserModel firstUser = dataUser.createRandomTestUser("testUser"); - firstUser.setUserRole(UserRole.SiteContributor); - UserModel secondUser = dataUser.createRandomTestUser("testUser"); - secondUser.setUserRole(UserRole.SiteCollaborator); - restClient.authenticateUser(adminUserModel).withCoreAPI(); - String json = String.format(addMembersJson, firstUser.getUserRole(), firstUser.getUsername(), secondUser.getUserRole(), secondUser.getUsername()); - RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, json, "sites/{siteId}/members?{parameters}", publicSiteModel.getId(), restClient.getParameters()); - restClient.processModel(RestSiteMemberModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that several users with same roles can be added once in a row to a site and gets status code 201") - public void addSeveralUsersWithSameRolesToASite() throws Exception - { - UserModel firstUser = dataUser.createRandomTestUser("testUser"); - firstUser.setUserRole(UserRole.SiteCollaborator); - UserModel secondUser = dataUser.createRandomTestUser("testUser"); - secondUser.setUserRole(UserRole.SiteCollaborator); - restClient.authenticateUser(adminUserModel).withCoreAPI(); - String json = String.format(addMembersJson, firstUser.getUserRole(), firstUser.getUsername(), secondUser.getUserRole(), secondUser.getUsername()); - RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, json, "sites/{siteId}/members?{parameters}", publicSiteModel.getId(), restClient.getParameters()); - restClient.processModel(RestSiteMemberModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that several users that are already added to the site can not be added once in a row and gets status code 400") - public void addSeveralUsersThatAreAlreadyAddedToASite() throws Exception - { - UserModel collaborator = moderatedSiteUsersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); - UserModel consumer = moderatedSiteUsersWithRoles.getOneUserWithRole(UserRole.SiteConsumer); - restClient.authenticateUser(adminUserModel).withCoreAPI(); - String json = String.format(addMembersJson, collaborator.getUserRole(), collaborator.getUsername(), consumer.getUserRole(), consumer.getUsername()); - RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, json, "sites/{siteId}/members?{parameters}", moderatedSiteModel.getId(), restClient.getParameters()); - restClient.processModel(RestSiteMemberModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.CONFLICT).assertLastError().containsSummary(String.format(RestErrorModel.ALREADY_Site_MEMBER, collaborator.getUsername(), moderatedSiteModel.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Add new site member request by providing an empty body") - public void addSiteMemberUsingEmptyBody() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI(); - RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "", "sites/{siteId}/members?{parameters}", - publicSiteModel.getId(), restClient.getParameters()); - restClient.processModel(RestSiteMemberModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.NO_CONTENT, "No content to map due to end-of-input")) - .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "No content to map due to end-of-input")) - .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 = "Check lower and upper case letters for role field") - public void checkLowerUpperCaseLettersForRole() throws Exception - { - UserModel user = dataUser.createRandomTestUser(); - - String json = String.format(addMemberJson, "SITEMANAGER", user.getUsername()); - restClient.authenticateUser(adminUserModel).withCoreAPI(); - RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, json, "sites/{siteId}/members?{parameters}", publicSiteModel.getId(), restClient.getParameters()); - restClient.processModel(RestSiteMemberModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.UNKNOWN_ROLE, "SITEMANAGER")) - .containsErrorKey(String.format(RestErrorModel.UNKNOWN_ROLE, "SITEMANAGER")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - - json = String.format(addMemberJson, "sitemanager", user.getUsername()); - restClient.authenticateUser(adminUserModel).withCoreAPI(); - request = RestRequest.requestWithBody(HttpMethod.POST, json, "sites/{siteId}/members?{parameters}", publicSiteModel.getId(), restClient.getParameters()); - restClient.processModel(RestSiteMemberModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.UNKNOWN_ROLE, "sitemanager")) - .containsErrorKey(String.format(RestErrorModel.UNKNOWN_ROLE, "sitemanager")) - .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 = "Check empty value for user role") - public void checkEmptyValueForRole() throws Exception - { - UserModel user = dataUser.createRandomTestUser(); - - String json = String.format(addMemberJson, "", user.getUsername()); - restClient.authenticateUser(adminUserModel).withCoreAPI(); - RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, json, "sites/{siteId}/members?{parameters}", publicSiteModel.getId(), restClient.getParameters()); - restClient.processModel(RestSiteMemberModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "N/A")) - .containsSummary(String.format(RestErrorModel.NO_CONTENT, "N/A")) - .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 that contributor role can be added to public site") - public void addContributorToPublicSite() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteContributor); - memberModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - memberModel.assertThat().field("id").is(testUser.getUsername()) - .and().field("role").is(testUser.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that collaborator role can be added to moderated site") - public void addCollaboratorToModeratedSite() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteCollaborator); - memberModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - memberModel.assertThat().field("id").is(testUser.getUsername()) - .and().field("role").is(testUser.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that contributor role can be added to moderated site") - public void addContributorToModeratedSite() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteContributor); - memberModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - memberModel.assertThat().field("id").is(testUser.getUsername()) - .and().field("role").is(testUser.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that consumer role can be added to moderated site") - public void addConsumerToModeratedSite() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteConsumer); - memberModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - memberModel.assertThat().field("id").is(testUser.getUsername()) - .and().field("role").is(testUser.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that collaborator role can be added to private site") - public void addCollaboratorToPrivateSite() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteCollaborator); - memberModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - memberModel.assertThat().field("id").is(testUser.getUsername()) - .and().field("role").is(testUser.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that contributor role can be added to private site") - public void addContributorToPrivateSite() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteContributor); - memberModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - memberModel.assertThat().field("id").is(testUser.getUsername()) - .and().field("role").is(testUser.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that consumer role can be added to private site") - public void addConsumerToPrivateSite() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteConsumer); - memberModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - memberModel.assertThat().field("id").is(testUser.getUsername()) - .and().field("role").is(testUser.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin can be added to private site by site manager") - public void adminCanBeAddedToPrivateSiteBySiteManager() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser(); - SiteModel privateSite = dataSite.usingUser(testUser).createPrivateRandomSite(); - adminUserModel.setUserRole(UserRole.SiteContributor); - memberModel = restClient.authenticateUser(testUser).withCoreAPI().usingSite(privateSite).addPerson(adminUserModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - memberModel.assertThat().field("id").is(adminUserModel.getUsername()).and().field("role").is(adminUserModel.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin cannot be added to private site by site collaborator") - public void adminCannotBeAddedToPrivateSiteBySiteCollaborator() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser(); - SiteModel privateSite = dataSite.usingUser(testUser).createPrivateRandomSite(); - UserModel siteCollaborator = dataUser.createRandomTestUser(); - dataUser.addUserToSite(siteCollaborator, privateSite, UserRole.SiteCollaborator); - adminUserModel.setUserRole(UserRole.SiteContributor); - memberModel = restClient.authenticateUser(siteCollaborator).withCoreAPI().usingSite(privateSite).addPerson(adminUserModel); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/GetSiteMemberTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/GetSiteMemberTests.java deleted file mode 100644 index 9911bf47a..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/GetSiteMemberTests.java +++ /dev/null @@ -1,396 +0,0 @@ -package org.alfresco.service.search.rest.sites.members; - -import org.alfresco.service.search.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).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @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); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/GetSiteMembersTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/GetSiteMembersTests.java deleted file mode 100644 index fdcf3def4..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/GetSiteMembersTests.java +++ /dev/null @@ -1,355 +0,0 @@ -package org.alfresco.service.search.rest.sites.members; - -import org.alfresco.service.search.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).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @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()); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/RemoveSiteMemberTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/RemoveSiteMemberTests.java deleted file mode 100644 index 485305e59..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/RemoveSiteMemberTests.java +++ /dev/null @@ -1,467 +0,0 @@ -package org.alfresco.service.search.rest.sites.members; - -import org.alfresco.service.search.rest.RestTest; -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.report.Bug; -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 RemoveSiteMemberTests extends RestTest -{ - private SiteModel publicSiteModel, moderatedSiteModel, privateSiteModel; - private UserModel adminUserModel, siteCreator; - private ListUserWithRoles usersWithRoles; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws DataPreparationException - { - adminUserModel = dataUser.getAdminUser(); - siteCreator = dataUser.createRandomTestUser(); - publicSiteModel = dataSite.usingUser(siteCreator).createPublicRandomSite(); - moderatedSiteModel = dataSite.usingUser(siteCreator).createModeratedRandomSite(); - privateSiteModel = dataSite.usingUser(siteCreator).createPrivateRandomSite(); - usersWithRoles = dataUser.addUsersWithRolesToSite(publicSiteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that site manager can delete site member and gets status code 204, 'No Content'") - public void siteManagerIsAbleToDeleteSiteMemberWithConsumerRole() throws Exception - { - UserModel testUserModel = dataUser.createRandomTestUser(); - dataUser.addUserToSite(testUserModel, publicSiteModel, UserRole.SiteConsumer); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(testUserModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMembers() - .assertThat().entriesListDoesNotContain("id", testUserModel.getUsername()); - 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 that site collaborator cannot delete site member and gets status code 403, 'Forbidden'") - public void siteCollaboratorIsNotAbleToDeleteSiteMemberWithConsumerRole() throws Exception - { - UserModel testUserModel = dataUser.createRandomTestUser(); - dataUser.addUserToSite(testUserModel, publicSiteModel, UserRole.SiteConsumer); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(testUserModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY); - - restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMembers() - .assertThat().entriesListContains("id", testUserModel.getUsername()); - 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 that site contributor cannot delete site member and gets status code 403, 'Forbidden'") - public void siteContributorIsNotAbleToDeleteSiteMemberWithConsumerRole() throws Exception - { - UserModel testUserModel = dataUser.createRandomTestUser(); - dataUser.addUserToSite(testUserModel, publicSiteModel, UserRole.SiteConsumer); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - restClient.withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(testUserModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY); - - restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMembers() - .assertThat().entriesListContains("id", testUserModel.getUsername()); - 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 that site consumer cannot delete site member and gets status code 403, 'Forbidden'") - public void siteConsumerIsNotAbleToDeleteSiteMemberWithConsumerRole() throws Exception - { - UserModel testUserModel = dataUser.createRandomTestUser(); - dataUser.addUserToSite(testUserModel, publicSiteModel, UserRole.SiteConsumer); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingSite(publicSiteModel) - .deleteSiteMember(testUserModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY); - - restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMembers() - .assertThat().entriesListContains("id", testUserModel.getUsername()); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that unauthenticated user is not able to delete site member") -// @Bug(id = "MNT-16904", description = "It fails only on environment with tenants") - public void unauthenticatedUserIsNotAuthorizedToDeleteSiteMember() throws Exception - { - UserModel testUserModel = dataUser.createRandomTestUser(); - dataUser.addUserToSite(testUserModel, publicSiteModel, UserRole.SiteConsumer); - - UserModel inexistentUser = new UserModel("inexistent user", "inexistent password"); - restClient.authenticateUser(inexistentUser).withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(testUserModel); - - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that manager can NOT delete site member for an inexistent user and gets status code 404, 'Not Found'") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - public void managerIsNotAbleToDeleteInexistentSiteMember() throws Exception - { - UserModel inexistentUser = new UserModel("inexistentUser", "password"); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(inexistentUser); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, inexistentUser.getUsername())); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that manager can NOT delete site member for a non site member and gets status code 400, 'Bad Request'") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - public void managerIsNotAbleToDeleteNotSiteMember() throws Exception - { - UserModel nonMember = dataUser.createRandomTestUser(); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(nonMember); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_ARGUMENT, "argument")); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that manager can NOT delete site member for an invalid site and gets status code 404, 'Not Found'") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - public void managerIsNotAbleToDeleteSiteMemberOfInvalidSite() throws Exception - { - SiteModel invalidSite = new SiteModel("invalidSite"); - UserModel testUserModel = dataUser.createRandomTestUser(); - dataUser.addUserToSite(testUserModel, publicSiteModel, UserRole.SiteConsumer); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingSite(invalidSite).deleteSiteMember(testUserModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, testUserModel.getUsername(), invalidSite.getId())); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that manager can delete a site member with manager role") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - public void siteManagerIsAbleToDeleteSiteMemberWithManagerRole() throws Exception - { - UserModel anothermanager = dataUser.createRandomTestUser(); - dataUser.addUserToSite(anothermanager, publicSiteModel, UserRole.SiteManager); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(anothermanager); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMembers() - .assertThat().entriesListDoesNotContain("id", anothermanager.getUsername()); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that manager can delete site member using \"-me-\" in place of personId") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - public void managerIsAbleToDeleteSiteMemberUsingMe() throws Exception - { - UserModel manager = dataUser.createRandomTestUser(); - dataUser.addUserToSite(manager, publicSiteModel, UserRole.SiteManager); - UserModel meUser = new UserModel("-me-", "password"); - - restClient.authenticateUser(manager); - restClient.withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(meUser); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMembers() - .assertThat().entriesListDoesNotContain("id", manager.getUsername()); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that site collaborator cannot delete a site member with Manager role and gets status code 422") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - public void siteCollaboratorIsNotAbleToDeleteSiteMemberWithManagerRole() throws Exception - { - UserModel managerForDelete = dataUser.createRandomTestUser(); - dataUser.addUserToSite(managerForDelete, publicSiteModel, UserRole.SiteManager); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(managerForDelete); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY) - .assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that site contributor cannot delete site member with Manager role and gets status code 422") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - public void siteContributorIsNotAbleToDeleteSiteMemberWithManagerRole() throws Exception - { - UserModel managerForDelete = dataUser.createRandomTestUser(); - dataUser.addUserToSite(managerForDelete, publicSiteModel, UserRole.SiteManager); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - restClient.withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(managerForDelete); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY) - .assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that site consumer cannot delete site member with Manager role and gets status code 422") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - public void siteConsumerIsNotAbleToDeleteSiteMemberWithManagerRole() throws Exception - { - UserModel managerForDelete = dataUser.createRandomTestUser(); - dataUser.addUserToSite(managerForDelete, publicSiteModel, UserRole.SiteManager); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(managerForDelete); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY) - .assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that site collaborator cannot delete a site member with Contributor role and gets status code 422") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - public void siteCollaboratorIsNotAbleToDeleteSiteMemberWithContributorRole() throws Exception - { - UserModel contributorForDelete = dataUser.createRandomTestUser(); - dataUser.addUserToSite(contributorForDelete, publicSiteModel, UserRole.SiteContributor); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(contributorForDelete); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY) - .assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that site contributor cannot delete site member with Contributor role and gets status code 422") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - public void siteContributorIsNotAbleToDeleteSiteMemberWithContributorRole() throws Exception - { - UserModel contributorForDelete = dataUser.createRandomTestUser(); - dataUser.addUserToSite(contributorForDelete, publicSiteModel, UserRole.SiteContributor); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - restClient.withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(contributorForDelete); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY) - .assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that site consumer cannot delete site member with Contributor role and gets status code 422") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - public void siteConsumerIsNotAbleToDeleteSiteMemberWithContributorRole() throws Exception - { - UserModel contributorForDelete = dataUser.createRandomTestUser(); - dataUser.addUserToSite(contributorForDelete, publicSiteModel, UserRole.SiteContributor); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(contributorForDelete); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY) - .assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that manager can delete a site member with Contributor role") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - public void siteManagerIsAbleToDeleteSiteMemberWithContributorRole() throws Exception - { - UserModel contributorForDelete = dataUser.createRandomTestUser(); - dataUser.addUserToSite(contributorForDelete, publicSiteModel, UserRole.SiteContributor); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(contributorForDelete); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMembers() - .assertThat().entriesListDoesNotContain("id", contributorForDelete.getUsername()); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that site collaborator cannot delete a site member with Collaborator role and gets status code 422") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - public void siteCollaboratorIsNotAbleToDeleteSiteMemberWithCollaboratorRole() throws Exception - { - UserModel collaboratorForDelete = dataUser.createRandomTestUser(); - dataUser.addUserToSite(collaboratorForDelete, publicSiteModel, UserRole.SiteCollaborator); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(collaboratorForDelete); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY) - .assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that site contributor cannot delete site member with Collaborator role and gets status code 422") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - public void siteContributorIsNotAbleToDeleteSiteMemberWithCollaboratorRole() throws Exception - { - UserModel collaboratorForDelete = dataUser.createRandomTestUser(); - dataUser.addUserToSite(collaboratorForDelete, publicSiteModel, UserRole.SiteCollaborator); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - restClient.withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(collaboratorForDelete); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY) - .assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that site consumer cannot delete site member with Collaborator role and gets status code 422") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - public void siteConsumerIsNotAbleToDeleteSiteMemberWithCollaboratorRole() throws Exception - { - UserModel collaboratorForDelete = dataUser.createRandomTestUser(); - dataUser.addUserToSite(collaboratorForDelete, publicSiteModel, UserRole.SiteCollaborator); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(collaboratorForDelete); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY) - .assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that manager can delete a site member with Collaborator role") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - public void siteManagerIsAbleToDeleteSiteMemberWithCollaboratorRole() throws Exception - { - UserModel collaboratorForDelete = dataUser.createRandomTestUser(); - dataUser.addUserToSite(collaboratorForDelete, publicSiteModel, UserRole.SiteCollaborator); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(collaboratorForDelete); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMembers() - .assertThat().entriesListDoesNotContain("id", collaboratorForDelete.getUsername()); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin can delete a site member with Contributor role and gets status code 204") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - public void adminIsAbleToDeleteSiteMemberWithContributorRole() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel) - .deleteSiteMember(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - dataUser.addUserToSite(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor), publicSiteModel, UserRole.SiteContributor); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin can delete site member with Manager role and gets status code 204") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - public void aminIsAbleToDeleteSiteMemberWithManagerRole() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel) - .deleteSiteMember(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - dataUser.addUserToSite(usersWithRoles.getOneUserWithRole(UserRole.SiteManager), publicSiteModel, UserRole.SiteManager); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin can delete site member with Consumer role and gets status code 204") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - public void adminIsAbleToDeleteSiteMemberWithConsumerRole() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel) - .deleteSiteMember(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - dataUser.addUserToSite(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer), publicSiteModel, UserRole.SiteConsumer); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin can delete a site member with Collaborator role and gets status code 204") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - public void adminIsAbleToDeleteSiteMemberWithCollaboratorRole() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel) - .deleteSiteMember(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - dataUser.addUserToSite(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), publicSiteModel, UserRole.SiteCollaborator); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin can delete a site member of moderated site and gets status code 204") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - public void adminIsAbleToDeleteModeratedSiteMember() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - newMember.setUserRole(UserRole.SiteManager); - dataUser.addUserToSite(newMember, moderatedSiteModel, UserRole.SiteManager); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).deleteSiteMember(newMember); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin can delete a site member of private site and gets status code 204") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - public void adminIsAbleToDeletePrivateSiteMember() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - newMember.setUserRole(UserRole.SiteManager); - dataUser.addUserToSite(newMember, privateSiteModel, UserRole.SiteManager); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).deleteSiteMember(newMember); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that regular user can not delete admin and gets status code 422") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - public void regularUserIsNotAbleToDeleteASiteMember() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingSite(publicSiteModel) - .deleteSiteMember(siteCreator); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() - .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getTitle())) - .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin can not delete a site member twice and gets status code 404 for the second attempt") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @Bug(id="ACE-5447") - public void adminIsNotAbleToRemoveSiteMemberTwice() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel) - .deleteSiteMember(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel) - .deleteSiteMember(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(RestErrorModel.ENTITY_NOT_FOUND); - dataUser.addUserToSite(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor), publicSiteModel, UserRole.SiteContributor); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify admin is not able to remove from site a user that created a member request that was not accepted yet") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @Bug(id="ACE-5447") - public void adminIsNotAbleToRemoveFromSiteANonExistingMember() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(publicSiteModel); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).deleteSiteMember(newMember); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(RestErrorModel.ENTITY_NOT_FOUND); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/UpdateSiteMemberTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/UpdateSiteMemberTests.java deleted file mode 100644 index 338bbc192..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/UpdateSiteMemberTests.java +++ /dev/null @@ -1,546 +0,0 @@ -package org.alfresco.service.search.rest.sites.members; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.core.JsonBodyGenerator; -import org.alfresco.rest.core.RestRequest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestSiteMemberModel; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser; -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.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class UpdateSiteMemberTests extends RestTest -{ - private UserModel adminUser, siteCreator, regularUser; - private SiteModel publicSite, moderatedSite, privateSite; - private ListUserWithRoles publicSiteUsers; - private UserModel userToBeUpdated; - private RestSiteMemberModel updatedMember; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - siteCreator = dataUser.createRandomTestUser(); - publicSite = dataSite.usingUser(siteCreator).createPublicRandomSite(); - moderatedSite = dataSite.usingUser(siteCreator).createModeratedRandomSite(); - privateSite = dataSite.usingUser(siteCreator).createPrivateRandomSite(); - publicSiteUsers = dataUser.addUsersWithRolesToSite(publicSite, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - - regularUser = dataUser.createRandomTestUser(); - regularUser.setUserRole(UserRole.SiteConsumer); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that collaborator is not able to update site member and gets status code FORBIDDEN (403)") - public void collaboratorIsNotAbleToUpdateSiteMember() throws Exception - { - userToBeUpdated = dataUser.createRandomTestUser(); - dataUser.addUserToSite(userToBeUpdated, publicSite, UserRole.SiteConsumer); - userToBeUpdated.setUserRole(UserRole.SiteCollaborator); - restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.withCoreAPI().usingSite(publicSite).updateSiteMember(userToBeUpdated); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY); - restClient.assertLastError() - .containsSummary(String.format("The current user does not have permissions to modify the membership details of the site %s.", publicSite.getTitle())); - } - - @Bug(id = "REPO-1832") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that collaborator is not able to update site member and gets status code FORBIDDEN (403)") - public void collaboratorIsNotAbleToUpdateSiteMemberWithTheSameRole() throws Exception - { - userToBeUpdated = dataUser.createRandomTestUser(); - dataUser.addUserToSite(userToBeUpdated, publicSite, UserRole.SiteConsumer); - userToBeUpdated.setUserRole(UserRole.SiteConsumer); - restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.withCoreAPI().usingSite(publicSite).updateSiteMember(userToBeUpdated); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY); - restClient.assertLastError() - .containsSummary(String.format("The current user does not have permissions to modify the membership details of the site %s.", publicSite.getTitle())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that contributor is not able to update site member and gets status code FORBIDDEN (403)") - public void contributorIsNotAbleToUpdateSiteMember() throws Exception - { - userToBeUpdated = dataUser.createRandomTestUser(); - dataUser.addUserToSite(userToBeUpdated, publicSite, UserRole.SiteConsumer); - userToBeUpdated.setUserRole(UserRole.SiteCollaborator); - restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteContributor)); - restClient.withCoreAPI().usingSite(publicSite).updateSiteMember(userToBeUpdated); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY); - restClient.assertLastError() - .containsSummary(String.format("The current user does not have permissions to modify the membership details of the site %s.", publicSite.getTitle())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that consumer is not able to update site member and gets status code FORBIDDEN (403)") - public void consumerIsNotAbleToUpdateSiteMember() throws Exception - { - userToBeUpdated = dataUser.createRandomTestUser(); - dataUser.addUserToSite(userToBeUpdated, publicSite, UserRole.SiteConsumer); - userToBeUpdated.setUserRole(UserRole.SiteCollaborator); - restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.withCoreAPI().usingSite(publicSite).updateSiteMember(userToBeUpdated); - restClient.assertLastError() - .containsSummary(String.format("The current user does not have permissions to modify the membership details of the site %s.", publicSite.getTitle())); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin is able to update site member and gets status code OK (200)") - public void adminIsAbleToUpdateSiteMember() throws Exception - { - userToBeUpdated = dataUser.createRandomTestUser(); - dataUser.addUserToSite(userToBeUpdated, publicSite, UserRole.SiteConsumer); - userToBeUpdated.setUserRole(UserRole.SiteCollaborator); - restClient.authenticateUser(adminUser); - restClient.withCoreAPI().usingSite(publicSite).updateSiteMember(userToBeUpdated) - .assertThat().field("id").is(userToBeUpdated.getUsername()) - .and().field("role").is(userToBeUpdated.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 = "Verify that unauthenticated user is not able to update site member") -// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void unauthenticatedUserIsNotAuthorizedToUpdateSiteMmeber() throws Exception - { - userToBeUpdated = dataUser.createRandomTestUser(); - dataUser.addUserToSite(userToBeUpdated, publicSite, UserRole.SiteConsumer); - userToBeUpdated.setUserRole(UserRole.SiteCollaborator); - UserModel inexistentUser = new UserModel("inexistent user", "inexistent password"); - restClient.authenticateUser(inexistentUser); - restClient.withCoreAPI().usingSite(publicSite).updateSiteMember(userToBeUpdated); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if update site member request returns status code 404 when nonexistent siteId is used") - public void updateSiteMemberOfNonexistentSite() throws Exception - { - SiteModel deletedSite = dataSite.usingUser(adminUser).createPublicRandomSite(); - dataUser.addUserToSite(regularUser, deletedSite, UserRole.SiteConsumer); - dataSite.deleteSite(deletedSite); - - restClient.authenticateUser(adminUser).withCoreAPI() - .usingSite(deletedSite).updateSiteMember(regularUser); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, deletedSite.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if update site member request returns status code 400 when personId is not member of the site") - public void updateNotASiteMember() throws Exception - { - restClient.authenticateUser(adminUser).withCoreAPI() - .usingSite(publicSite).updateSiteMember(regularUser); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary("User is not a member of the site"); - } - - // @Bug(id="REPO-1642", description = "reproduced on 5.2.1 only, it works on 5.2.0") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if update site member request returns status code 404 when personId does not exist") - public void updateNonexistentSiteMember() throws Exception - { - UserModel nonexistentUser = new UserModel("nonexistentUser", DataUser.PASSWORD); - nonexistentUser.setUserRole(UserRole.SiteContributor); - restClient.authenticateUser(adminUser).withCoreAPI() - .usingSite(publicSite).updateSiteMember(nonexistentUser); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, nonexistentUser.getUsername())); - } - - @Bug(id="REPO-1941") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if a manager is able to downgrade to contributor using -me- string in place of personId.") - public void updateSiteManagerToSiteContributorUsingMe() throws Exception - { - UserModel meManager = dataUser.createRandomTestUser(); - dataUser.addUserToSite(meManager, publicSite, UserRole.SiteManager); - UserModel meUser = new UserModel("-me-", "password"); - meUser.setUserRole(UserRole.SiteContributor); - updatedMember = restClient.authenticateUser(meManager).withCoreAPI() - .usingSite(publicSite).updateSiteMember(meUser); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedMember.assertThat().field("id").is(meManager.getUsername()) - .and().field("role").is(meUser.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if update site member request returns status code 404 when empty siteId is used") - public void updateSiteMemberUsingEmptySiteId() throws Exception - { - restClient.authenticateUser(adminUser).withCoreAPI() - .usingSite("").updateSiteMember(regularUser); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if update site member request returns status code 405 when empty personId is used") - public void updateSiteMemberUsingEmptyPersonId() throws Exception - { - UserModel emptyUser = new UserModel("", DataUser.PASSWORD); - emptyUser.setUserRole(UserRole.SiteCollaborator); - restClient.authenticateUser(adminUser).withCoreAPI() - .usingSite(publicSite).updateSiteMember(emptyUser); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) - .assertLastError().containsSummary(RestErrorModel.PUT_EMPTY_ARGUMENT); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if update site member request returns status code 400 when invalid role is used") - public void updateSiteMemberUsingInvalidRole() throws Exception - { - restClient.authenticateUser(siteCreator).withCoreAPI(); - UserModel siteConsumer = publicSiteUsers.getOneUserWithRole(UserRole.SiteConsumer); - String json = JsonBodyGenerator.keyValueJson("role","invalidRole"); - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, json, "sites/{siteId}/members/{personId}", publicSite.getId(), siteConsumer.getUsername()); - restClient.processModel(RestSiteMemberModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.UNKNOWN_ROLE, "invalidRole")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if manager is able to update another site manager to site collaborator") - public void managerUpdateSiteManagerToSiteCollaborator() throws Exception - { - UserModel siteManager = dataUser.createRandomTestUser(); - dataUser.addUserToSite(siteManager, publicSite, UserRole.SiteManager); - siteManager.setUserRole(UserRole.SiteCollaborator); - updatedMember = restClient.authenticateUser(siteCreator).withCoreAPI() - .usingSite(publicSite).updateSiteMember(siteManager); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedMember.assertThat().field("id").is(siteManager.getUsername()) - .and().field("role").is(siteManager.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if manager is able to update site contributor to site manager") - public void managerUpdateSiteContributorToSiteManager() throws Exception - { - UserModel siteContributor = publicSiteUsers.getOneUserWithRole(UserRole.SiteContributor); - siteContributor.setUserRole(UserRole.SiteManager); - updatedMember = restClient.authenticateUser(siteCreator).withCoreAPI() - .usingSite(publicSite).updateSiteMember(siteContributor); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedMember.assertThat().field("id").is(siteContributor.getUsername()) - .and().field("role").is(siteContributor.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if manager is able to update site collaborator to site manager") - public void managerUpdateSiteCollaboratorToSiteManager() throws Exception - { - UserModel siteCollaborator = publicSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator); - siteCollaborator.setUserRole(UserRole.SiteManager); - updatedMember = restClient.authenticateUser(siteCreator).withCoreAPI() - .usingSite(publicSite).updateSiteMember(siteCollaborator); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedMember.assertThat().field("id").is(siteCollaborator.getUsername()) - .and().field("role").is(siteCollaborator.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.SANITY, - description= "Verify if manager is able to update site consumer to site manager") - public void managerUpdateSiteConsumerToSiteManager() throws Exception - { - UserModel siteConsumer = publicSiteUsers.getOneUserWithRole(UserRole.SiteConsumer); - siteConsumer.setUserRole(UserRole.SiteManager); - updatedMember = restClient.authenticateUser(siteCreator).withCoreAPI() - .usingSite(publicSite).updateSiteMember(siteConsumer); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedMember.assertThat().field("id").is(siteConsumer.getUsername()) - .and().field("role").is(siteConsumer.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if manager is able to downgrade himself to site consumer") - public void publicSiteManagerDowngradesRole() throws Exception - { - UserModel siteManager = publicSiteUsers.getOneUserWithRole(UserRole.SiteManager); - siteManager.setUserRole(UserRole.SiteConsumer); - updatedMember = restClient.authenticateUser(siteManager).withCoreAPI() - .usingSite(publicSite).updateSiteMember(siteManager); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedMember.assertThat().field("id").is(siteManager.getUsername()) - .and().field("role").is(siteManager.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if manager is able to update another site manager to site contributor") - public void managerUpdateSiteManagerToSiteContributor() throws Exception - { - UserModel siteManager = dataUser.createRandomTestUser(); - dataUser.addUserToSite(siteManager, publicSite, UserRole.SiteManager); - - siteManager.setUserRole(UserRole.SiteContributor); - updatedMember = restClient.authenticateUser(siteCreator).withCoreAPI() - .usingSite(publicSite).updateSiteMember(siteManager); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedMember.assertThat().field("id").is(siteManager.getUsername()).and().field("role").is(siteManager.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if manager is able to update another site manager to site consumer") - public void managerUpdateSiteManagerToSiteConsumer() throws Exception - { - UserModel siteManager = dataUser.createRandomTestUser(); - dataUser.addUserToSite(siteManager, publicSite, UserRole.SiteManager); - - siteManager.setUserRole(UserRole.SiteConsumer); - updatedMember = restClient.authenticateUser(siteCreator).withCoreAPI() - .usingSite(publicSite).updateSiteMember(siteManager); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedMember.assertThat().field("id").is(siteManager.getUsername()).and().field("role").is(siteManager.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if manager is able to update site contributor to site collaborator") - public void managerUpdateSiteContributorToSiteCollaborator() throws Exception - { - UserModel siteContributor = dataUser.createRandomTestUser(); - dataUser.addUserToSite(siteContributor, publicSite, UserRole.SiteContributor); - - siteContributor.setUserRole(UserRole.SiteCollaborator); - updatedMember = restClient.authenticateUser(siteCreator).withCoreAPI() - .usingSite(publicSite).updateSiteMember(siteContributor); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedMember.assertThat().field("id").is(siteContributor.getUsername()).and().field("role").is(siteContributor.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if manager is able to update site contributor to site consumer") - public void managerUpdateSiteContributorToSiteConsumer() throws Exception - { - UserModel siteContributor = dataUser.createRandomTestUser(); - dataUser.addUserToSite(siteContributor, publicSite, UserRole.SiteContributor); - - siteContributor.setUserRole(UserRole.SiteConsumer); - updatedMember = restClient.authenticateUser(siteCreator).withCoreAPI() - .usingSite(publicSite).updateSiteMember(siteContributor); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedMember.assertThat().field("id").is(siteContributor.getUsername()).and().field("role").is(siteContributor.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if manager is able to update site collaborator to site contributor") - public void managerUpdateSiteCollaboratorToSiteContributor() throws Exception - { - UserModel siteCollaborator = dataUser.createRandomTestUser(); - dataUser.addUserToSite(siteCollaborator, publicSite, UserRole.SiteCollaborator); - - siteCollaborator.setUserRole(UserRole.SiteContributor); - updatedMember = restClient.authenticateUser(siteCreator).withCoreAPI() - .usingSite(publicSite).updateSiteMember(siteCollaborator); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedMember.assertThat().field("id").is(siteCollaborator.getUsername()).and().field("role").is(siteCollaborator.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if manager is able to update site collaborator to site consumer") - public void managerUpdateSiteCollaboratorToSiteConsumer() throws Exception - { - UserModel siteCollaborator = dataUser.createRandomTestUser(); - dataUser.addUserToSite(siteCollaborator, publicSite, UserRole.SiteCollaborator); - - siteCollaborator.setUserRole(UserRole.SiteConsumer); - updatedMember = restClient.authenticateUser(siteCreator).withCoreAPI() - .usingSite(publicSite).updateSiteMember(siteCollaborator); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedMember.assertThat().field("id").is(siteCollaborator.getUsername()).and().field("role").is(siteCollaborator.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if manager is able to update site consumer to site collaborator") - public void managerUpdateSiteConsumerToSiteCollaborator() throws Exception - { - UserModel siteConsumer = dataUser.createRandomTestUser(); - dataUser.addUserToSite(siteConsumer, publicSite, UserRole.SiteConsumer); - - siteConsumer.setUserRole(UserRole.SiteCollaborator); - updatedMember = restClient.authenticateUser(siteCreator).withCoreAPI() - .usingSite(publicSite).updateSiteMember(siteConsumer); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedMember.assertThat().field("id").is(siteConsumer.getUsername()).and().field("role").is(siteConsumer.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if manager is able to update site consumer to site contributor") - public void managerUpdateSiteConsumerToSiteContributor() throws Exception - { - UserModel siteConsumer = dataUser.createRandomTestUser(); - dataUser.addUserToSite(siteConsumer, publicSite, UserRole.SiteConsumer); - - siteConsumer.setUserRole(UserRole.SiteContributor); - updatedMember = restClient.authenticateUser(siteCreator).withCoreAPI() - .usingSite(publicSite).updateSiteMember(siteConsumer); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedMember.assertThat().field("id").is(siteConsumer.getUsername()).and().field("role").is(siteConsumer.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if manager is able to update another site manager to site manager") - public void managerUpdateSiteManagerToSiteManager() throws Exception - { - UserModel siteManager = dataUser.createRandomTestUser(); - dataUser.addUserToSite(siteManager, publicSite, UserRole.SiteManager); - - siteManager.setUserRole(UserRole.SiteManager); - updatedMember = restClient.authenticateUser(siteCreator).withCoreAPI() - .usingSite(publicSite).updateSiteMember(siteManager); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedMember.assertThat().field("id").is(siteManager.getUsername()).and().field("role").is(siteManager.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if manager is able to update site collaborator to site collaborator") - public void managerUpdateSiteCollaboratorToSiteCollaborator() throws Exception - { - UserModel siteCollaborator = dataUser.createRandomTestUser(); - dataUser.addUserToSite(siteCollaborator, publicSite, UserRole.SiteCollaborator); - - siteCollaborator.setUserRole(UserRole.SiteCollaborator); - updatedMember = restClient.authenticateUser(siteCreator).withCoreAPI() - .usingSite(publicSite).updateSiteMember(siteCollaborator); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedMember.assertThat().field("id").is(siteCollaborator.getUsername()).and().field("role").is(siteCollaborator.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if manager is able to update site contributor to site contributor") - public void managerUpdateSiteContributorToSiteContributor() throws Exception - { - UserModel siteContributor = dataUser.createRandomTestUser(); - dataUser.addUserToSite(siteContributor, publicSite, UserRole.SiteContributor); - - siteContributor.setUserRole(UserRole.SiteContributor); - updatedMember = restClient.authenticateUser(siteCreator).withCoreAPI() - .usingSite(publicSite).updateSiteMember(siteContributor); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedMember.assertThat().field("id").is(siteContributor.getUsername()).and().field("role").is(siteContributor.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if manager is able to update site consumer to site consumer") - public void managerUpdateSiteConsumerToSiteConsumer() throws Exception - { - UserModel siteConsumer = dataUser.createRandomTestUser(); - dataUser.addUserToSite(siteConsumer, publicSite, UserRole.SiteConsumer); - - siteConsumer.setUserRole(UserRole.SiteConsumer); - updatedMember = restClient.authenticateUser(siteCreator).withCoreAPI() - .usingSite(publicSite).updateSiteMember(siteConsumer); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedMember.assertThat().field("id").is(siteConsumer.getUsername()).and().field("role").is(siteConsumer.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if manager of a private site is able to downgrade his role") - public void privateSiteManagerDowngradesRole() throws Exception - { - UserModel siteManager = dataUser.createRandomTestUser(); - dataUser.addUserToSite(siteManager, privateSite, UserRole.SiteManager); - - siteManager.setUserRole(UserRole.SiteConsumer); - updatedMember = restClient.authenticateUser(siteManager).withCoreAPI() - .usingSite(privateSite).updateSiteMember(siteManager); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedMember.assertThat().field("id").is(siteManager.getUsername()).and().field("role").is(siteManager.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if manager of a moderated site is able to downgrade his role") - public void moderatedSiteManagerDowngradesRole() throws Exception - { - UserModel siteManager = dataUser.createRandomTestUser(); - dataUser.addUserToSite(siteManager, moderatedSite, UserRole.SiteManager); - - siteManager.setUserRole(UserRole.SiteConsumer); - updatedMember = restClient.authenticateUser(siteManager).withCoreAPI() - .usingSite(moderatedSite).updateSiteMember(siteManager); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedMember.assertThat().field("id").is(siteManager.getUsername()).and().field("role").is(siteManager.getUserRole()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify the response of updating a site member with empty body at request") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void managerCanNotUpdateSiteMemberWithEmptyBody() throws Exception - { - restClient.authenticateUser(siteCreator).withCoreAPI(); - UserModel siteCollaborator = dataUser.createRandomTestUser(); - dataUser.addUserToSite(siteCollaborator, publicSite, UserRole.SiteCollaborator); - siteCollaborator.setUserRole(UserRole.SiteConsumer); - - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "", "sites/{siteId}/members/{personId}", publicSite.getId(), siteCollaborator.getUsername()); - restClient.processModel(RestSiteMemberModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.NO_CONTENT, "No content to map due to end-of-input")) - .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "No content to map due to end-of-input")) - .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 if manager is able to update a user that has created a site membership request, but it's not a member of the site yet") - public void managerCanNotUpdateUserWithSiteMembershipRequest() throws Exception - { - UserModel siteConsumer = dataUser.createRandomTestUser(); - siteConsumer.setUserRole(UserRole.SiteConsumer); - restClient.authenticateUser(siteConsumer).withCoreAPI().usingUser(siteConsumer).addSiteMembershipRequest(moderatedSite); - - updatedMember = restClient.authenticateUser(siteCreator).withCoreAPI() - .usingSite(moderatedSite).updateSiteMember(siteConsumer); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(RestErrorModel.NOT_A_MEMBER); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/AddSiteMembershipRequestTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/AddSiteMembershipRequestTests.java deleted file mode 100644 index de28098b4..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/AddSiteMembershipRequestTests.java +++ /dev/null @@ -1,409 +0,0 @@ -package org.alfresco.service.search.rest.sites.membershipRequests; - -import org.alfresco.dataprep.SiteService; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestSiteEntry; -import org.alfresco.rest.model.RestSiteMembershipRequestModel; -import org.alfresco.rest.model.RestSiteMembershipRequestModelsCollection; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser; -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.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class AddSiteMembershipRequestTests extends RestTest -{ - private SiteModel publicSite, anotherPublicSite, moderatedSite, privateSite; - private DataUser.ListUserWithRoles usersWithRoles; - private UserModel adminUser, siteManager, regularUser, newMember; - private RestSiteMembershipRequestModel siteMembershipRequest; - private RestSiteMembershipRequestModelsCollection siteMembershipRequests; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws DataPreparationException - { - adminUser = dataUser.getAdminUser(); - publicSite = dataSite.usingUser(adminUser).createPublicRandomSite(); - usersWithRoles = dataUser.addUsersWithRolesToSite(publicSite, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - - siteManager = dataUser.createRandomTestUser(); - anotherPublicSite = dataSite.usingUser(siteManager).createPublicRandomSite(); - - moderatedSite = dataSite.usingUser(adminUser).createModeratedRandomSite(); - privateSite = dataSite.usingUser(adminUser).createPrivateRandomSite(); - - newMember = dataUser.createRandomTestUser(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, - description = "Verify site manager is able to create new site membership request for himself and status code is 201") - public void managerCreatesNewSiteMembershipRequestForSelf() throws Exception - { - siteMembershipRequest = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingAuthUser().addSiteMembershipRequest(anotherPublicSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - siteMembershipRequest.assertThat().field("id").is(anotherPublicSite.getId()) - .assertThat().field("site").isNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify site contributor is able to create new site membership request for himself and status code is 201") - public void contributorCreatesNewSiteMembershipRequestForSelf() throws Exception - { - siteMembershipRequest = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingAuthUser().addSiteMembershipRequest(anotherPublicSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - siteMembershipRequest.assertThat().field("id").is(anotherPublicSite.getId()) - .assertThat().field("site").isNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify site collaborator is able to create new site membership request for himself and status code is 201") - public void collaboratorCreatesNewSiteMembershipRequestForSelf() throws Exception - { - siteMembershipRequest = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingAuthUser().addSiteMembershipRequest(anotherPublicSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - siteMembershipRequest.assertThat().field("id").is(anotherPublicSite.getId()) - .assertThat().field("site").isNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify site consumer is able to create new site membership request for himself and status code is 201") - public void consumerCreatesNewSiteMembershipRequestForSelf() throws Exception - { - siteMembershipRequest = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingAuthUser().addSiteMembershipRequest(anotherPublicSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - siteMembershipRequest.assertThat().field("id").is(anotherPublicSite.getId()) - .assertThat().field("site").isNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify admin is able to create new site membership request for himself and status code is 201") - public void adminCreatesNewSiteMembershipRequestForSelf() throws Exception - { - siteMembershipRequest = restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(anotherPublicSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - siteMembershipRequest.assertThat().field("id").is(anotherPublicSite.getId()) - .assertThat().field("site").isNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, - description = "Verify unauthenticated user is not able to create new site membership request") - public void unauthenticatedUserIsNotAbleToCreateSiteMembershipRequest() throws Exception - { - restClient.authenticateUser(new UserModel("random user", "random password")).withCoreAPI().usingAuthUser().addSiteMembershipRequest(publicSite); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify addSiteMembershipRequest Rest API status code is 400 for a user that has already been invited") - public void addSiteMembershipRequestStatusCodeIs400ReceivedForAUserThatIsAlreadyInvited() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - dataUser.addUserToSite(newMember, moderatedSite, UserRole.SiteContributor); - restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - restClient.assertLastError().containsSummary(String.format(RestErrorModel.ALREADY_Site_MEMBER, newMember.getUsername(), moderatedSite.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify addSiteMembershipRequest Rest API status code is 404 for a user that does not exist") - public void addSiteMembershipRequestStatusCodeIs404ReceivedForAUserThatDoesNotExist() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingUser(new UserModel("invalidUser", "password")).addSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - restClient.assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidUser")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify addSiteMembershipRequest Rest API status code is 404 for a site that does not exist") - public void addSiteMembershipRequestStatusCodeIs404ReceivedForASiteThatDoesNotExist() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest(new SiteModel("invalidSiteID")); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - restClient.assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, newMember.getUsername(), "invalidSiteID")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify addSiteMembershipRequest Rest API status code is 400 for empty request body") - public void addSiteMembershipRequestStatusCodeIs400ForEmptyRequestBody() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest(""); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.NO_CONTENT, "No content to map due to end-of-input")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify addSiteMembershipRequest Rest API status code is 201 for request with empty message") - public void addSiteMembershipRequestStatusCodeIs201ForRequestWithEmptyMessage() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - siteMembershipRequest = restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest("", moderatedSite, "New request"); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - siteMembershipRequest.assertThat().field("id").is(moderatedSite.getId()).assertThat().field("site").isNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify addSiteMembershipRequest Rest API status code is 201 for request with empty title") - public void addSiteMembershipRequestStatusCodeIs201ForRequestWithEmptyTitle() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - siteMembershipRequest = restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest("Please accept me", moderatedSite, ""); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - siteMembershipRequest.assertThat().field("id").is(moderatedSite.getId()).assertThat().field("site").isNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site manager is not able to create new site membership request for other user") - public void managerIsNotAbleToCreateSiteMembershipRequestForOtherUser() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingUser(newMember) - .addSiteMembershipRequest(publicSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())) - .statusCodeIs(HttpStatus.NOT_FOUND) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site collaborator is not able to create new site membership request for other user") - public void collaboratorIsNotAbleToCreateSiteMembershipRequestForOtherUser() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingUser(newMember) - .addSiteMembershipRequest(publicSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site contributor is not able to create new site membership request for other user") - public void contributorIsNotAbleToCreateSiteMembershipRequestForOtherUser() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingUser(newMember) - .addSiteMembershipRequest(publicSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site consumer is not able to create new site membership request for other user") - public void consumerIsNotAbleToCreateSiteMembershipRequestForOtherUser() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingUser(newMember) - .addSiteMembershipRequest(publicSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin user is not able to create new site membership request for other user") - public void adminIsNotAbleToCreateSiteMembershipRequestForOtherUser() throws Exception - { - restClient.authenticateUser(adminUser).withCoreAPI().usingUser(newMember).addSiteMembershipRequest(publicSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); - - restClient.withCoreAPI().usingUser(newMember).addSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); - - restClient.withCoreAPI().usingUser(newMember).addSiteMembershipRequest(privateSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); - } - - @Bug(id="ACE-2413") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify addSiteMembershipRequest Rest API status code is 400 for an invalid user id") - public void addSiteMembershipRequestReturns400ForEmptyUserId() throws Exception - { - restClient.authenticateUser(adminUser).withCoreAPI() - .usingUser(new UserModel("", "password")).addSiteMembershipRequest(publicSite); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify regular user is able to create new public site membership request for himself. Check that user joins immediately as consumer.") - public void userIsAbleToRequestMembershipOfPublicSite() throws Exception - { - regularUser = dataUser.createRandomTestUser(); - siteMembershipRequest = restClient.authenticateUser(regularUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(publicSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - siteMembershipRequest.assertThat().field("id").is(publicSite.getId()) - .assertThat().field("site").isNotEmpty(); - RestSiteEntry siteEntry = restClient.withCoreAPI().usingAuthUser().getSiteMembership(publicSite); - restClient.assertStatusCodeIs(HttpStatus.OK); - siteEntry.assertThat().field("role").is(UserRole.SiteConsumer) - .and().field("id").is(publicSite.getId()); - siteMembershipRequests = restClient.withCoreAPI().usingAuthUser().getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.OK); - siteMembershipRequests.assertThat().entriesListIsEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify regular user is able to create new moderated site membership request for himself. Check that the request is added to the site membership request list.") - public void userIsAbleToRequestMembershipOfModeratedSite() throws Exception - { - regularUser = dataUser.createRandomTestUser(); - siteMembershipRequest = restClient.authenticateUser(regularUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - siteMembershipRequest.assertThat().field("id").is(moderatedSite.getId()) - .assertThat().field("message").is("Please accept me") - .assertThat().field("site").isNotEmpty(); - siteMembershipRequest.getSite() - .assertThat().field("visibility").is(moderatedSite.getVisibility()) - .assertThat().field("guid").is(moderatedSite.getGuid()) - .assertThat().field("description").is(moderatedSite.getDescription()) - .assertThat().field("id").is(moderatedSite.getId()) - .assertThat().field("title").is(moderatedSite.getTitle()); - - siteMembershipRequests = restClient.withCoreAPI().usingAuthUser().getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.OK); - siteMembershipRequests.assertThat().entriesListContains("id", moderatedSite.getId()) - .assertThat().entriesListCountIs(1); - - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify regular user is not able to request membership of a private site.") - public void userIsNotAbleToRequestMembershipOfPrivateSite() throws Exception - { - regularUser = dataUser.createRandomTestUser(); - restClient.authenticateUser(regularUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(privateSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, regularUser.getUsername(), privateSite.getId())); - siteMembershipRequests = restClient.withCoreAPI().usingAuthUser().getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.OK); - siteMembershipRequests.assertThat().entriesListIsEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify regular user is not able to create new site membership request for other user") - public void regularUserIsNotAbleToCreateSiteMembershipRequestForOtherUser() throws Exception - { - regularUser = dataUser.createRandomTestUser(); - restClient.authenticateUser(regularUser).withCoreAPI().usingUser(newMember) - .addSiteMembershipRequest(publicSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); - - restClient.withCoreAPI().usingUser(newMember).addSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); - - restClient.withCoreAPI().usingUser(newMember).addSiteMembershipRequest(privateSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify create public site membership request returns status code 400 when the request is made twice") - public void userRequestsTwiceMembershipOfPublicSite() throws Exception - { - regularUser = dataUser.createRandomTestUser(); - siteMembershipRequest = restClient.authenticateUser(regularUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(publicSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - siteMembershipRequest.assertThat().field("id").is(publicSite.getId()) - .assertThat().field("site").isNotEmpty(); - restClient.withCoreAPI().usingAuthUser().addSiteMembershipRequest(publicSite); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - restClient.assertLastError().containsSummary(String.format(RestErrorModel.ALREADY_Site_MEMBER, regularUser.getUsername(), publicSite.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify create moderated site membership request returns status code 400 when the request is made twice") - public void userRequestsTwiceMembershipOfModeratedSite() throws Exception - { - regularUser = dataUser.createRandomTestUser(); - siteMembershipRequest = restClient.authenticateUser(regularUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - siteMembershipRequest.assertThat().field("id").is(moderatedSite.getId()) - .assertThat().field("site").isNotEmpty(); - restClient.withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - restClient.assertLastError().containsSummary(String.format(RestErrorModel.ALREADY_INVITED, regularUser.getUsername(), moderatedSite.getId())); - - siteMembershipRequests = restClient.withCoreAPI().usingAuthUser().getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.OK); - siteMembershipRequests.assertThat().entriesListContains("id", moderatedSite.getId()) - .assertThat().entriesListCountIs(1); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify create private site membership request returns status code 404 when request is made with the user who created the site") - public void siteCreatorRequestsMembershipOfHisPrivateSite() throws Exception - { - restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(privateSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, adminUser.getUsername(), privateSite.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify create moderated site membership request returns status code 400 when request is made with the user who created the site") - public void siteCreatorRequestsMembershipOfHisModeratedSite() throws Exception - { - restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.ALREADY_Site_MEMBER, adminUser.getUsername(), moderatedSite.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify admin is able to create new moderated site membership request for himself. Check that the request is added to the site membership request list.") - public void adminIsAbleToRequestMembershipOfModeratedSite() throws Exception - { - regularUser = dataUser.createRandomTestUser(); - SiteModel anotherModeratedSite = dataSite.usingUser(regularUser).createModeratedRandomSite(); - siteMembershipRequest = restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(anotherModeratedSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - siteMembershipRequest.assertThat().field("id").is(anotherModeratedSite.getId()) - .assertThat().field("site").isNotEmpty(); - siteMembershipRequests = restClient.withCoreAPI().usingAuthUser().getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.OK); - siteMembershipRequests.assertThat().entriesListContains("id", anotherModeratedSite.getId()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify site membership request is automatically rejected when a site is switched from moderated to private") - public void siteMembershipRequestIsRejectedWhenSiteIsSwitchedFromModeratedToPrivate() throws Exception - { - regularUser = dataUser.createRandomTestUser(); - SiteModel moderatedThenPrivateSite = dataSite.usingUser(adminUser).createModeratedRandomSite(); - siteMembershipRequest = restClient.authenticateUser(regularUser).withCoreAPI().usingMe().addSiteMembershipRequest(moderatedThenPrivateSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - siteMembershipRequest.assertThat().field("id").is(moderatedThenPrivateSite.getId()) - .assertThat().field("site").isNotEmpty(); - - dataSite.usingUser(adminUser).updateSiteVisibility(moderatedThenPrivateSite, SiteService.Visibility.PRIVATE); - - siteMembershipRequests = restClient.withCoreAPI().usingAuthUser().getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.OK); - siteMembershipRequests.assertThat().entriesListIsEmpty(); - } -} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/DeleteSiteMembershipRequestTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/DeleteSiteMembershipRequestTests.java deleted file mode 100644 index dd495422d..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/DeleteSiteMembershipRequestTests.java +++ /dev/null @@ -1,317 +0,0 @@ -package org.alfresco.service.search.rest.sites.membershipRequests; - -import org.alfresco.dataprep.SiteService.Visibility; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestSiteMembershipRequestModelsCollection; -import org.alfresco.rest.model.RestTaskModel; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * @author iulia.cojocea - */ - -public class DeleteSiteMembershipRequestTests extends RestTest -{ - UserModel siteCreator, adminUserModel, secondSiteCreator, siteMember; - SiteModel moderatedSite, secondModeratedSite, publicSite; - private ListUserWithRoles usersWithRoles; - RestSiteMembershipRequestModelsCollection siteMembershipRequests; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - siteCreator = dataUser.createRandomTestUser(); - secondSiteCreator = dataUser.createRandomTestUser(); - String siteId = RandomData.getRandomName("site"); - moderatedSite = dataSite.usingUser(siteCreator).createSite(new SiteModel(Visibility.MODERATED, siteId, siteId, siteId, siteId)); - usersWithRoles = dataUser.addUsersWithRolesToSite(moderatedSite, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - - dataUser.addUserToSite(adminUserModel, moderatedSite, UserRole.SiteManager); - secondModeratedSite = dataSite.usingUser(secondSiteCreator).createModeratedRandomSite(); - publicSite = dataSite.usingUser(siteCreator).createPublicRandomSite(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify one user is able to delete his one site memebership request") - public void userCanDeleteHisOwnSiteMembershipRequest() throws Exception - { - restClient.authenticateUser(secondSiteCreator).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.withCoreAPI().usingUser(secondSiteCreator).deleteSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site manager is able to delete site membership request") - public void managerCanDeleteSiteMembershipRequest() throws Exception - { - siteMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(siteMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingUser(siteMember) - .deleteSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingUser(siteMember).getSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, siteMember.getUsername(), moderatedSite.getTitle())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin user is able to delete site memebership request") - public void adminUserCanDeleteSiteMembershipRequest() throws Exception - { - siteMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(siteMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(siteMember).deleteSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @Bug(id = "REPO-1946") - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify collaborator user is not able to delete site memebership request") - public void collaboratorCannotDeleteSiteMembershipRequest() throws Exception - { - siteMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(siteMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingUser(siteMember) - .deleteSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @Bug(id = "REPO-1946") - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify contributor user is not able to delete site memebership request") - public void contributorCannotDeleteSiteMembershipRequest() throws Exception - { - siteMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(siteMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingUser(siteMember) - .deleteSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @Bug(id = "REPO-1946") - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify consumer user is not able to delete site memebership request") - public void consumerCannotDeleteSiteMembershipRequest() throws Exception - { - siteMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(siteMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingUser(siteMember) - .deleteSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @Bug(id = "REPO-1946") - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify random user is not able to delete site memebership request") - public void randomUserCanNotDeleteSiteMembershipRequest() throws Exception - { - siteMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(siteMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - - restClient.authenticateUser(dataUser.createRandomTestUser()).withCoreAPI().usingUser(siteMember).deleteSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, 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") - public void unauthenticatedUserIsNotAuthorizedToDeleteSiteMmebershipRequest() throws Exception - { - restClient.authenticateUser(dataUser.createRandomTestUser()).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - UserModel inexistentUser = new UserModel("inexistent user", "inexistent password"); - restClient.authenticateUser(inexistentUser).withCoreAPI().usingAuthUser().deleteSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify user is able to remove his own site memebership request using '-me-' in place of personId and response is successful (204)") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void userCanDeleteHisOwnSiteMembershipRequestUsingMeAsPersonId() throws Exception - { - restClient.authenticateUser(secondSiteCreator).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - restClient.withCoreAPI().usingMe().deleteSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify user is not able to remove a site memebership request of an inexistent user and response is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void adminIsNotAbleToDeleteSiteMembershipRequestOfAnInexistentUser() throws Exception - { - UserModel inexistentUser = new UserModel("inexistenUser", "password"); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(inexistentUser).deleteSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, inexistentUser.getUsername())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify user is not able to remove a site memebership request to an inexistent site and response is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void adminIsNotAbleToDeleteSiteMembershipRequestToAnInexistentSite() throws Exception - { - SiteModel inexistentSite = new SiteModel("inexistentSite"); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).deleteSiteMembershipRequest(inexistentSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, adminUserModel.getUsername(), inexistentSite.getId())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify user is not able to remove a site memebership request to an empty site id and response is 405") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void adminIsNotAbleToDeleteSiteMembershipRequestWithEmptySiteId() throws Exception - { - SiteModel inexistentSite = new SiteModel(""); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).deleteSiteMembershipRequest(inexistentSite); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.DELETE_EMPTY_ARGUMENT); - } - - @Bug(id = "REPO-1946") - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify contributor user is not able to remove a site memebership request of admin to a moderated site and response is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void contributorIsNotAbleToDeleteSiteMembershipRequestOfAdminToAModeratedSite() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingUser(adminUserModel).deleteSiteMembershipRequest(secondModeratedSite); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify manager is able to remove a site memebership request of admin to a moderated site and response is 204") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void managerUserIsAbleToDeleteSiteMembershipRequestOfAdminToAModeratedSite() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteMembershipRequest(secondModeratedSite); - restClient.authenticateUser(secondSiteCreator).withCoreAPI().usingUser(adminUserModel).deleteSiteMembershipRequest(secondModeratedSite); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify manager is not able to remove a site memebership request if it was already approved and response is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void managerUserIsNotAbleToDeleteASiteMembershipRequestIfItWasAlreadyApproved() throws Exception - { - siteMember.setUserRole(UserRole.SiteCollaborator); - restClient.authenticateUser(siteMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(secondModeratedSite); - RestTaskModel taskModel = restClient.authenticateUser(siteMember).withWorkflowAPI().getTasks().getTaskModelByDescription(secondModeratedSite); - workflow.approveSiteMembershipRequest(secondSiteCreator.getUsername(), secondSiteCreator.getPassword(), taskModel.getId(), true, "Approve"); - - restClient.authenticateUser(secondSiteCreator).withCoreAPI().usingUser(siteMember).deleteSiteMembershipRequest(secondModeratedSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, siteMember.getUsername(), secondModeratedSite.getId())); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify manager is not able to remove an inexitent site memebership request and response is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void managerUserIsNotAbleToDeleteAnInexistentSiteMembershipRequest() throws Exception - { - restClient.authenticateUser(secondSiteCreator).withCoreAPI().usingUser(adminUserModel).deleteSiteMembershipRequest(secondModeratedSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, adminUserModel.getUsername(), secondModeratedSite.getId())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify collaborator user is not able to remove a site memebership request of admin to a public site and response is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void collaboratorIsNotAbleToDeleteSiteMembershipRequestOfAdminToAPublicSite() throws Exception - { - UserModel userCollaborator = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); - restClient.authenticateUser(siteMember).withCoreAPI().usingSite(publicSite).addPerson(userCollaborator); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteMembershipRequest(publicSite); - - restClient.authenticateUser(userCollaborator).withCoreAPI().usingUser(adminUserModel).deleteSiteMembershipRequest(publicSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, adminUserModel.getUsername(), publicSite.getId())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Delete a rejected site membership request.") - public void deleteARejectedSiteMembershipRequest() throws Exception - { - UserModel userWithRejectedRequests = dataUser.createRandomTestUser(); - restClient.authenticateUser(userWithRejectedRequests).withCoreAPI().usingAuthUser().addSiteMembershipRequest(secondModeratedSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestTaskModel taskModel = restClient.authenticateUser(userWithRejectedRequests).withWorkflowAPI().getTasks() - .getTaskModelByDescription(secondModeratedSite); - workflow.approveSiteMembershipRequest(secondSiteCreator.getUsername(), secondSiteCreator.getPassword(), taskModel.getId(), false, "Rejected"); - - siteMembershipRequests = restClient.authenticateUser(userWithRejectedRequests).withCoreAPI().usingMe().getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.OK); - siteMembershipRequests.assertThat().entriesListDoesNotContain("id", secondModeratedSite.getId()); - - restClient.authenticateUser(secondSiteCreator).withCoreAPI().usingUser(userWithRejectedRequests).deleteSiteMembershipRequest(secondModeratedSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, userWithRejectedRequests.getUsername(), secondModeratedSite.getId())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Bug(id="ACE-2413") - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify user is not able to remove a site memebership request- empty person id and response is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void adminIsNotAbleToDeleteSiteMembershipRequestEmptyPersonID() throws Exception - { - UserModel emptyPersonId = new UserModel("", "password"); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(emptyPersonId).deleteSiteMembershipRequest(moderatedSite); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .containsSummary(RestErrorModel.ENTITY_NOT_FOUND) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify manager removes/cancel twice same site memebership request and response is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void managerCancelsTwiceSiteMembershipRequestModeratedSite() throws Exception - { - siteMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(siteMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - - restClient.authenticateUser(siteCreator).withCoreAPI().usingUser(siteMember).deleteSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingUser(siteMember).deleteSiteMembershipRequest(moderatedSite); - - restClient.withCoreAPI().usingUser(siteMember).getSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, siteMember.getUsername(), moderatedSite.getTitle())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/GetSiteMembershipRequestTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/GetSiteMembershipRequestTests.java deleted file mode 100644 index ed63a790b..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/GetSiteMembershipRequestTests.java +++ /dev/null @@ -1,332 +0,0 @@ -package org.alfresco.service.search.rest.sites.membershipRequests; - -import org.alfresco.dataprep.SiteService; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestSiteMembershipRequestModel; -import org.alfresco.rest.model.RestTaskModel; -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.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class GetSiteMembershipRequestTests extends RestTest -{ - private SiteModel publicSite, moderatedSite; - private ListUserWithRoles usersWithRoles; - private UserModel adminUser, siteCreator, newMember; - private RestSiteMembershipRequestModel returnedModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - publicSite = dataSite.usingUser(adminUser).createPublicRandomSite(); - - siteCreator = dataUser.createRandomTestUser(); - moderatedSite = dataSite.usingUser(siteCreator).createModeratedRandomSite(); - - usersWithRoles = dataUser.addUsersWithRolesToSite(moderatedSite, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - - newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site manager is able to retrieve site membership request") - public void siteManagerIsAbleToRetrieveSiteMembershipRequest() throws Exception - { - returnedModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingUser(newMember).getSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedModel.assertThat().field("id").is(moderatedSite.getId()) - .and().field("message").is("Please accept me") - .and().field("site.title").is(moderatedSite.getTitle()) - .and().field("site.visibility").is(SiteService.Visibility.MODERATED.toString()) - .and().field("site.guid").isNotEmpty() - .and().field("site.description").is(moderatedSite.getDescription()) - .and().field("site.preset").is("site-dashboard"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site collaborator is able to retrieve site membership request") - public void siteCollaboratorIsNotAbleToRetrieveSiteMembershipRequest() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingUser(newMember).getSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site contributor is able to retrieve site membership request") - public void siteContributorIsNotAbleToRetrieveSiteMembershipRequest() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingUser(newMember).getSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site consumer is able to retrieve site membership request") - public void siteConsumerIsNotAbleToRetrieveSiteMembershipRequest() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingUser(newMember).getSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin user is able to retrieve site membership request") - public void adminIsAbleToRetrieveSiteMembershipRequest() throws Exception - { - returnedModel = restClient.authenticateUser(adminUser).withCoreAPI().usingUser(newMember).getSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedModel.assertThat().field("id").is(moderatedSite.getId()) - .and().field("message").is("Please accept me") - .and().field("site.title").is(moderatedSite.getTitle()) - .and().field("site.visibility").is(SiteService.Visibility.MODERATED.toString()) - .and().field("site.guid").isNotEmpty() - .and().field("site.description").is(moderatedSite.getDescription()) - .and().field("site.preset").is("site-dashboard"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, - description = "Verify user fails to get all site membership requests of a specific person with Rest API when the authentication fails (401)") - public void unauthorizedUserFailsToGetSiteMembershipRequests() throws Exception - { - UserModel manager = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(siteCreator).addUserToSite(manager, moderatedSite, UserRole.SiteManager); - manager.setPassword("newpassword"); - restClient.authenticateUser(manager).withCoreAPI().usingUser(newMember).getSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError().containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify a user gets all its own site membership requests using '-me-' with Rest API and response is successful (200)") - public void usingMeGetSiteMembershipRequestsWithSuccess() throws Exception - { - restClient.authenticateUser(newMember).withCoreAPI().usingMe().getSiteMembershipRequest(moderatedSite).assertThat().field("id").is(moderatedSite.getId()); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site manager can't get site membership requests for inexistent user and response is not found (404)") - public void siteManagerCantGetSiteMembershipRequestsInexistentUser() throws Exception - { - restClient.authenticateUser(newMember).withCoreAPI().usingUser(UserModel.getRandomUserModel()).getSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user can get site membership requests on site with no requests and response is successful (200)") - public void userWithNoRequestsCantGetSiteMembershipRequests() throws Exception - { - UserModel noRequestUser = dataUser.createRandomTestUser(); - restClient.authenticateUser(noRequestUser).withCoreAPI().usingMe().getSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, noRequestUser.getUsername(), moderatedSite.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site manager can't get site membership requests on public site and response is not found (404)") - public void siteManagerCantGetPublicSiteMembershipRequests() throws Exception - { - UserModel publicUser = dataUser.createRandomTestUser(); - restClient.authenticateUser(publicUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(publicSite); - restClient.authenticateUser(adminUser).withCoreAPI() - .usingUser(publicUser).getSiteMembershipRequest(publicSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, publicUser.getUsername(), publicSite.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site manager can't get site membership requests on private site and response is not found (404)") - public void siteManagerCantGetPrivateSiteMembershipRequests() throws Exception - { - UserModel privateUser = dataUser.createRandomTestUser(); - SiteModel privateSite = dataSite.usingUser(siteCreator).createPrivateRandomSite(); - restClient.authenticateUser(privateUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(privateSite); - restClient.authenticateUser(siteCreator).withCoreAPI().usingUser(privateUser).getSiteMembershipRequest(privateSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, privateUser.getUsername(), privateSite.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site manager can't get site membership requests for inexistent site and response is not found (404)") - public void siteManagerCantGetSiteMembershipRequestsForInexistentSite() throws Exception - { - SiteModel inexistentSite = SiteModel.getRandomSiteModel(); - restClient.authenticateUser(siteCreator).withCoreAPI().usingMe().getSiteMembershipRequest(inexistentSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, siteCreator.getUsername(), inexistentSite.getId())); - } - - @Bug(id = "ACE-2413") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify if person ID field is empty user can't get site membership requests on moderated site and response is not found (400)") - public void emptyPersonIdCantGetModeratedSiteMembershipRequests() throws Exception - { - UserModel emptyUser = new UserModel("", "password"); - restClient.authenticateUser(siteCreator).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - restClient.authenticateUser(siteCreator).withCoreAPI().usingUser(emptyUser).getSiteMembershipRequest(moderatedSite); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .containsSummary(String.format("The entity with id: personId is null. was not found")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Approve site membership request then verify get site membership requests - response is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void approveRequestThenGetSiteMembershipRequest() throws Exception - { - UserModel userWithApprovedRequests = dataUser.createRandomTestUser(); - restClient.authenticateUser(userWithApprovedRequests).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestTaskModel taskModel = restClient.authenticateUser(userWithApprovedRequests).withWorkflowAPI().getTasks().getTaskModelByDescription(moderatedSite); - workflow.approveSiteMembershipRequest(siteCreator.getUsername(), siteCreator.getPassword(), taskModel.getId(), true, "Approve"); - - returnedModel = restClient.authenticateUser(userWithApprovedRequests).withCoreAPI().usingMe().getSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, userWithApprovedRequests.getUsername(), moderatedSite.getId())) - .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Reject site membership request then verify get site membership requests - response is 404") - public void rejectRequestThenGetSiteMembershipRequest() throws Exception - { - UserModel userWithRejectedRequests = dataUser.createRandomTestUser(); - restClient.authenticateUser(userWithRejectedRequests).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestTaskModel taskModel = restClient.authenticateUser(userWithRejectedRequests).withWorkflowAPI().getTasks().getTaskModelByDescription(moderatedSite); - workflow.approveSiteMembershipRequest(siteCreator.getUsername(), siteCreator.getPassword(), taskModel.getId(), false, "Rejected"); - - returnedModel = restClient.authenticateUser(userWithRejectedRequests).withCoreAPI().usingMe().getSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, userWithRejectedRequests.getUsername(), moderatedSite.getId())) - .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @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 site favorite response with Rest API") - public void checkResponseSchemaForGetSiteMembershipRequest() throws Exception - { - dataUser.usingUser(siteCreator).addUserToSite(newMember, moderatedSite, UserRole.SiteContributor); - returnedModel = restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().getSiteMembershipRequest(moderatedSite); - - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedModel.assertThat().field("id").is(moderatedSite.getId()) - .and().field("message").is("Please accept me") - .and().field("site.title").is(moderatedSite.getTitle()) - .and().field("site.visibility").is(SiteService.Visibility.MODERATED.toString()) - .and().field("site.guid").isNotEmpty() - .and().field("site.description").is(moderatedSite.getDescription()) - .and().field("site.preset").is("site-dashboard") - .and().field("site.role").is("SiteContributor"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify that getFavoriteSites request applies valid properties param") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void getSiteMembershipRequestWithValidPropertiesParam() throws Exception - { - RestSiteMembershipRequestModel returnedModel = restClient.authenticateUser(newMember).withParams("properties=message").withCoreAPI().usingAuthUser() - .getSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedModel.assertThat().fieldsCount().is(1).assertThat().field("message").isNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify that getFavoriteSites request returns status 200 when using valid parameters") - public void getSiteMembershipRequestUsingParameters() throws Exception - { - RestSiteMembershipRequestModel returnedModel = restClient.withParams("message=Please accept me") - .authenticateUser(newMember).withCoreAPI().usingMe() - .getSiteMembershipRequest(moderatedSite); - - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedModel.assertThat().field("id").is(moderatedSite.getId()).and().field("site.title").is(moderatedSite.getTitle()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify user doesn't have permission to get site membership request of admin without membership request with Rest API and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void userIsNotAbleToGetSiteMembershipRequestOfAdminWithoutRequest() throws Exception - { - returnedModel = restClient.authenticateUser(newMember).withCoreAPI().usingUser(adminUser).getSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, adminUser.getUsername(), moderatedSite.getId())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER).stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify user doesn't have permission to get site membership request of admin with requests with Rest API and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void userIsNotAbleToGetSiteMembershipRequestOfAdminWithRequest() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - - returnedModel = restClient.authenticateUser(newMember).withCoreAPI().usingUser(adminUser).getSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, adminUser.getUsername(), moderatedSite.getId())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify admin user doesn't have permission to get site membership request of another user with Rest API and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void userIsNotAbleToGetSiteMembershipRequestOfAnotherUser() throws Exception - { - UserModel userCollaborator = dataUser.createRandomTestUser(); - UserModel userConsumer = dataUser.createRandomTestUser(); - restClient.authenticateUser(userConsumer).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - dataUser.usingUser(siteCreator).addUserToSite(userConsumer, moderatedSite, UserRole.SiteConsumer); - restClient.authenticateUser(userCollaborator).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - dataUser.usingUser(siteCreator).addUserToSite(userCollaborator, moderatedSite, UserRole.SiteCollaborator); - - returnedModel = restClient.authenticateUser(userCollaborator).withCoreAPI().usingUser(userConsumer).getSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, userConsumer.getUsername(), moderatedSite.getId())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - -} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/GetSiteMembershipRequestsTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/GetSiteMembershipRequestsTests.java deleted file mode 100644 index dbb5ef43f..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/GetSiteMembershipRequestsTests.java +++ /dev/null @@ -1,421 +0,0 @@ -package org.alfresco.service.search.rest.sites.membershipRequests; - -import static org.alfresco.utility.report.log.Step.STEP; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.*; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Tests for - * GET /people/{personId}/site-membership-requests - * GET /site-membership-requests - * POST /sites/{siteId}/site-membership-requests/{inviteeId}/approve - * POST /sites/{siteId}/site-membership-requests/{inviteeId}/reject - * - * @author Cristina Axinte - */ - -public class GetSiteMembershipRequestsTests extends RestTest -{ - UserModel siteManager, newMember, adminUser, regularUser, testUser, testUser1; - DataUser.ListUserWithRoles usersWithRoles; - SiteModel moderatedSite1, moderatedSite2; - RestSiteMembershipRequestModelsCollection siteMembershipRequests; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - siteManager = dataUser.createRandomTestUser(); - newMember = dataUser.createRandomTestUser(); - regularUser = dataUser.createRandomTestUser(); - - testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteConsumer); - testUser1 = dataUser.createRandomTestUser("testUser1"); - testUser1.setUserRole(UserRole.SiteConsumer); - - moderatedSite1 = dataSite.usingUser(siteManager).createModeratedRandomSite(); - moderatedSite2 = dataSite.usingUser(siteManager).createModeratedRandomSite(); - - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite1); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite1); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - usersWithRoles = dataUser.addUsersWithRolesToSite(moderatedSite1, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @Bug(id = "MNT-16557") - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user gets all site membership requests of a specific person with Rest API and response is successful (200)") - public void managerUserGetsSiteMembershipRequestsWithSuccess() throws Exception - { - siteMembershipRequests = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI() - .usingUser(newMember).getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.OK); - siteMembershipRequests.assertThat().entriesListIsNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @Bug(id = "MNT-16557") - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify collaborator user fails to get all site membership requests of another user with Rest API (403)") - public void collaboratorUserFailsToGetSiteMembershipRequestsOfAnotherUser() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI() - .usingUser(newMember).getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @Bug(id = "MNT-16557") - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify contributor user fails to get all site membership requests of another user with Rest API (403)") - public void contributorUserFailsToGetSiteMembershipRequestsOfAnotherUser() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI() - .usingUser(newMember).getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @Bug(id = "MNT-16557") - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify consumer user fails to get all site membership requests of another user with Rest API (403)") - public void consumerUserFailsToGetSiteMembershipRequestsOfAnotherUser() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingUser(newMember).getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @Bug(id = "MNT-16557") - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin user gets all site membership requests of a specific person with Rest API and response is successful (200)") - public void adminGetsSiteMembershipRequestsOfanotherUserWithSuccess() throws Exception - { - siteMembershipRequests = restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI() - .usingUser(newMember).getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.OK); - siteMembershipRequests.assertThat().entriesListIsNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) -// @Bug(id = "MNT-16904", description = "It fails only on environment with tenants") - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user fails to get all site membership requests of a specific person with Rest API when the authentication fails (401)") - public void unauthorizedUserFailsToGetSiteMembershipRequests() throws Exception - { - restClient.authenticateUser(new UserModel("random user", "random password")).withCoreAPI() - .usingAuthUser().getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify a user gets all its own site membership requests with Rest API and response is successful (200)") - public void oneUserGetsItsOwnSiteMembershipRequestsWithSuccess() throws Exception - { - siteMembershipRequests = restClient.authenticateUser(newMember).withCoreAPI().usingUser(newMember).getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.OK); - siteMembershipRequests.assertThat().entriesListContains("id", moderatedSite1.getId()) - .assertThat().entriesListContains("message", "Please accept me") - .assertThat().entriesListCountIs(2); - RestSiteModel firstSite = siteMembershipRequests.getEntries().get(0).onModel().getSite(); - if (firstSite.getId().equals(moderatedSite1.getId())) - { - firstSite.assertThat().field("visibility").is(moderatedSite1.getVisibility()) - .assertThat().field("guid").is(moderatedSite1.getGuid()) - .assertThat().field("description").is(moderatedSite1.getDescription()) - .assertThat().field("id").is(moderatedSite1.getId()) - .assertThat().field("title").is(moderatedSite1.getTitle()); - } - else - { - firstSite.assertThat().field("visibility").is(moderatedSite2.getVisibility()) - .assertThat().field("guid").is(moderatedSite2.getGuid()) - .assertThat().field("description").is(moderatedSite2.getDescription()) - .assertThat().field("id").is(moderatedSite2.getId()) - .assertThat().field("title").is(moderatedSite2.getTitle()); - } - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, - description = "Verify that for invalid maxItems parameter status code returned is 400.") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void checkInvalidMaxItemsStatusCode() throws Exception - { - restClient.authenticateUser(adminUser).withParams("maxItems=AB") - .withCoreAPI().usingUser(newMember).getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "AB")); - - restClient.authenticateUser(adminUser).withParams("maxItems=0") - .withCoreAPI().usingUser(newMember).getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, - description = "Verify that for invalid skipCount parameter status code returned is 400.") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void checkInvalidSkipCountStatusCode() throws Exception - { - restClient.authenticateUser(adminUser).withParams("skipCount=AB") - .withCoreAPI().usingUser(newMember).getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "AB")); - - restClient.authenticateUser(adminUser).withParams("skipCount=-1") - .withCoreAPI().usingUser(newMember).getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, - description = "Verify that if personId does not exist status code returned is 404.") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void ifPersonIdDoesNotExist() throws Exception - { - UserModel nonexistentUser = dataUser.createRandomTestUser(); - nonexistentUser.setUsername("nonexistent"); - - restClient.authenticateUser(adminUser).withCoreAPI().usingUser(nonexistentUser).getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "nonexistent")) - .statusCodeIs(HttpStatus.NOT_FOUND) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, - description = "Specify -me- string in place of for request.") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void replacePersonIdWithMeRequest() throws Exception - { - UserModel meUser = dataUser.createRandomTestUser(); - restClient.authenticateUser(meUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite1); - siteMembershipRequests = restClient.authenticateUser(meUser).withCoreAPI().usingMe().getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.OK); - siteMembershipRequests.assertThat().entriesListContains("id", moderatedSite1.getId()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, - description = "Verify that if empty personId is used status code returned is 404.") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void useEmptyPersonId() throws Exception - { - UserModel emptyNameMember = dataUser.createRandomTestUser(); - emptyNameMember.setUsername(" "); - - restClient.authenticateUser(adminUser).withCoreAPI().usingUser(emptyNameMember).getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, emptyNameMember.getUsername())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, - description = "Get site membership requests to a public site.") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void getRequestsToPublicSite() throws Exception - { - SiteModel publicSite = dataSite.usingAdmin().createPublicRandomSite(); - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(publicSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - siteMembershipRequests = restClient.withCoreAPI().usingAuthUser().getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.OK); - siteMembershipRequests.assertThat().entriesListDoesNotContain("id", publicSite.getId()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, - description = "Approve request then get requests.") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void approveRequestThenGetRequests() throws Exception - { - UserModel siteManager = dataUser.createRandomTestUser(); - - SiteModel moderatedSite = dataSite.usingUser(siteManager).createModeratedRandomSite(); - restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestTaskModel taskModel = restClient.authenticateUser(newMember).withWorkflowAPI().getTasks().getTaskModelByDescription(moderatedSite); - workflow.approveSiteMembershipRequest(siteManager.getUsername(), siteManager.getPassword(), taskModel.getId(), true, "Approve"); - - siteMembershipRequests = restClient.authenticateUser(newMember).withCoreAPI().usingMe().getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.OK); - siteMembershipRequests.assertThat().entriesListDoesNotContain("id", moderatedSite.getId()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, - description = "Verify admin user gets all its own site membership requests with Rest API and response is successful (200)") - public void adminGetsItsOwnSiteMembershipRequestsWithSuccess() throws Exception - { - siteMembershipRequests = restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.OK); - siteMembershipRequests.assertThat().entriesListContains("id", moderatedSite1.getId()) - .assertThat().entriesListContains("id", moderatedSite2.getId()); - } - - @Bug(id = "MNT-16557") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, - description = "Verify regular user fails to get all site membership requests of another user with Rest API (403)") - public void regularUserFailsToGetSiteMembershipRequestsOfAnotherUser() throws Exception - { - restClient.authenticateUser(regularUser).withCoreAPI() - .usingUser(newMember).getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Bug(id = "MNT-16557") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, - description = "Verify regular user fails to get all site membership requests of admin with Rest API (403)") - public void regularUserFailsToGetSiteMembershipRequestsOfAdmin() throws Exception - { - restClient.authenticateUser(regularUser).withCoreAPI() - .usingUser(adminUser).getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, - description = "Verify regular user is able to get his site membership requests with, but skip the first one") - public void getSiteMembershipRequestsButSkipTheFirstOne() throws Exception - { - siteMembershipRequests = restClient.authenticateUser(newMember).withParams("orderBy=id ASC").withCoreAPI() - .usingMe().getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.OK); - siteMembershipRequests.assertThat().entriesListContains("id", moderatedSite1.getId()) - .assertThat().entriesListContains("id", moderatedSite2.getId()); - - RestSiteMembershipRequestModel firstSiteMembershipRequest = siteMembershipRequests.getEntries().get(0).onModel(); - RestSiteMembershipRequestModel secondSiteMembershipRequest = siteMembershipRequests.getEntries().get(1).onModel(); - - siteMembershipRequests = restClient.authenticateUser(newMember).withParams("orderBy=id ASC&skipCount=1").withCoreAPI() - .usingMe().getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.OK); - siteMembershipRequests.assertThat().entriesListDoesNotContain("id", firstSiteMembershipRequest.getId()) - .assertThat().entriesListContains("id", secondSiteMembershipRequest.getId()) - .assertThat().entriesListContains("id", secondSiteMembershipRequest.getSite().getId()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, - description = "Verify regular user is able to get his site membership requests with higher skipCount than number of requests") - public void getSiteMembershipRequestsWithHighSkipCount() throws Exception - { - siteMembershipRequests = restClient.authenticateUser(newMember).withParams("skipCount=3").withCoreAPI() - .usingMe().getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.OK); - siteMembershipRequests.assertThat().entriesListIsEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, - description = "Verify get site membership requests returns an empty list where there are no requests") - public void getSiteMembershipRequestsWhereThereAreNoRequests() throws Exception - { - siteMembershipRequests = restClient.authenticateUser(regularUser).withCoreAPI().usingMe().getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.OK); - siteMembershipRequests.assertThat().entriesListIsEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, - description = "Reject request then get site membership requests.") - public void rejectRequestThenGetSiteMembershipRequests() throws Exception - { - UserModel userWithRejectedRequests = dataUser.createRandomTestUser(); - - restClient.authenticateUser(userWithRejectedRequests).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite1); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestTaskModel taskModel = restClient.authenticateUser(userWithRejectedRequests).withWorkflowAPI().getTasks().getTaskModelByDescription(moderatedSite1); - workflow.approveSiteMembershipRequest(siteManager.getUsername(), siteManager.getPassword(), taskModel.getId(), false, "Rejected"); - - siteMembershipRequests = restClient.authenticateUser(userWithRejectedRequests).withCoreAPI().usingMe().getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.OK); - siteMembershipRequests.assertThat().entriesListDoesNotContain("id", moderatedSite1.getId()) - .assertThat().entriesListContains("id", moderatedSite2.getId()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, - description = "Check get site membership requests when properties parameter is used") - public void getSiteMembershipRequestsWithProperties() throws Exception - { - siteMembershipRequests = restClient.authenticateUser(newMember).withParams("properties=id") - .withCoreAPI().usingAuthUser().getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.OK); - siteMembershipRequests.assertThat().entriesListContains("id", moderatedSite1.getId()) - .assertThat().entriesListContains("id", moderatedSite2.getId()); - RestSiteMembershipRequestModel siteMembershipRequest = siteMembershipRequests.getOneRandomEntry().onModel(); - siteMembershipRequest.assertThat().fieldsCount().is(1); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Sanity test for endpoints: GET /site-membership-requests, POST /sites/{siteId}/site-membership-requests/{inviteeId}/approve, POST /sites/{siteId}/site-membership-requests/{inviteeId}/reject") - public void approveRejectSiteMembership() throws Exception - { - STEP("1. Make membership requests for 2 users on moderatedSite."); - restClient.authenticateUser(testUser).withCoreAPI().usingMe().addSiteMembershipRequest(moderatedSite1); - restClient.authenticateUser(testUser1).withCoreAPI().usingMe().addSiteMembershipRequest(moderatedSite1); - - STEP("2. Get site memberships and filter using username and siteId "); - RestSitePersonMembershipRequestModelsCollection membership = restClient.authenticateUser(siteManager) - .withParams("where=(personId='" + testUser.getUsername() + "' AND siteId='" + moderatedSite1.getId() + "')").withCoreAPI() - .usingSite(moderatedSite1).getSiteMemberships(); - - restClient.assertStatusCodeIs(HttpStatus.OK); - membership.getEntryByIndex(0).getSite().assertThat().field("id").is(moderatedSite1.getId()); - membership.getEntryByIndex(0).getPersonModel().assertThat().field("id").is(testUser.getUsername()); - - STEP("3. Approve site membership for one of the users. Check that the user is now a member of the site"); - restClient.authenticateUser(siteManager).withCoreAPI().usingSite(moderatedSite1).approveSiteMembership(testUser); - restClient.assertStatusCodeIs(HttpStatus.OK); - restClient.withCoreAPI().usingSite(moderatedSite1).getSiteMember(testUser).assertThat().field("id").is(testUser.getUsername()).and().field("role") - .is(testUser.getUserRole()); - - STEP("4. Reject site membership for the second user. Check that the user is not a member of the site"); - restClient.authenticateUser(siteManager).withCoreAPI().usingSite(moderatedSite1).rejectSiteMembership(testUser1); - restClient.assertStatusCodeIs(HttpStatus.OK); - RestSiteMemberModelsCollection memberList = restClient.withCoreAPI().usingSite(moderatedSite1).getSiteMembers(); - memberList.assertThat().entriesListDoesNotContain("id", testUser1.getUsername()); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/UpdateSiteMembershipRequestTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/UpdateSiteMembershipRequestTests.java deleted file mode 100644 index 8cb9af558..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/UpdateSiteMembershipRequestTests.java +++ /dev/null @@ -1,610 +0,0 @@ -package org.alfresco.service.search.rest.sites.membershipRequests; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.core.RestRequest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestSiteMembershipRequestModel; -import org.alfresco.rest.model.RestTaskModel; -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.HttpMethod; -import org.springframework.http.HttpStatus; -import org.testng.Assert; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class UpdateSiteMembershipRequestTests extends RestTest -{ - private SiteModel moderatedSite; - private ListUserWithRoles usersWithRoles; - private UserModel adminUser, managerUser; - private String updatedMessage, moderatedSiteId; - private RestSiteMembershipRequestModel requestUpdateModel, requestGetModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws DataPreparationException - { - adminUser = dataUser.getAdminUser(); - managerUser = dataUser.createRandomTestUser(); - moderatedSite = dataSite.usingUser(managerUser).createModeratedRandomSite(); - - usersWithRoles = dataUser.addUsersWithRolesToSite(moderatedSite, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - updatedMessage = "Please review my request"; - moderatedSiteId = moderatedSite.getId(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify user is able to update its own site membership request") - public void userIsAbleToUpdateItsOwnSiteMembershipRequest() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - requestUpdateModel = restClient.withCoreAPI().usingUser(newMember).updateSiteMembershipRequest(moderatedSite, updatedMessage); - restClient.assertStatusCodeIs(HttpStatus.OK); - - requestUpdateModel.assertThat().field("id").is(moderatedSite.getId()) - .assertThat().field("message").is(updatedMessage) - .assertThat().field("site").isNotEmpty() - .assertThat().field("modifiedAt").isNotEmpty() - .assertThat().field("createdAt").isNotEmpty(); - requestUpdateModel.getSite().assertThat().field("visibility").is(moderatedSite.getVisibility()) - .assertThat().field("guid").is(moderatedSite.getGuid()) - .assertThat().field("description").is(moderatedSite.getDescription()) - .assertThat().field("id").is(moderatedSite.getId()) - .assertThat().field("preset").is("site-dashboard") - .assertThat().field("title").is(moderatedSite.getTitle()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site manager is not able to update membership request of another user") -// @Bug(id = "MNT-16919", description = "Not a bug, The presence of the personId in the URL does not mean it should be possible to act on any other users behalf.") - public void siteManagerIsNotAbleToUpdateSiteMembershipRequestOfAnotherUser() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingUser(newMember) - .updateSiteMembershipRequest(moderatedSite, updatedMessage); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site collaborator is not able to update membership request of another user") - // @Bug(id = "MNT-16919", description = "Not a bug, The presence of the personId in the URL does not mean it should be possible to act on any other users behalf.") - public void siteCollaboratorIsNotAbleToUpdateSiteMembershipRequestOfAnotherUser() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingUser(newMember) - .updateSiteMembershipRequest(moderatedSite, updatedMessage); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site contributor is not able to update membership request of another user") - // @Bug(id = "MNT-16919", description = "Not a bug, The presence of the personId in the URL does not mean it should be possible to act on any other users behalf.") - public void siteContributorIsNotAbleToUpdateSiteMembershipRequestOfAnotherUser() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingUser(newMember) - .updateSiteMembershipRequest(moderatedSite, updatedMessage); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site consumer is not able to update membership request of another user") - // @Bug(id = "MNT-16919", description = "Not a bug, The presence of the personId in the URL does not mean it should be possible to act on any other users behalf.") - public void siteConsumerIsNotAbleToUpdateSiteMembershipRequestOfAnotherUser() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingUser(newMember) - .updateSiteMembershipRequest(moderatedSite, updatedMessage); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify one user is not able to update membership request of another user") - // @Bug(id = "MNT-16919", description = "Not a bug, The presence of the personId in the URL does not mean it should be possible to act on any other users behalf.") - public void regularUserIsNotAbleToUpdateSiteMembershipRequestOfAnotherUser() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - UserModel otherMember = dataUser.createRandomTestUser(); - - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - - restClient.authenticateUser(otherMember).withCoreAPI().usingUser(newMember).updateSiteMembershipRequest(moderatedSite, updatedMessage); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is not able to update membership request of another user") - // @Bug(id = "MNT-16919", description = "Not a bug, The presence of the personId in the URL does not mean it should be possible to act on any other users behalf.") - public void adminIsNotAbleToUpdateSiteMembershipRequestOfAnotherUser() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - - restClient.authenticateUser(adminUser).withCoreAPI().usingUser(newMember).updateSiteMembershipRequest(moderatedSite, updatedMessage); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify unauthorized user is not able to update user site membership request") - public void unauthorizedUserIsNotAbleToUpdateSiteMembershipRequest() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - newMember.setPassword("fakePass"); - restClient.withCoreAPI().usingUser(newMember).updateSiteMembershipRequest(moderatedSite, updatedMessage); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError().containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is able to update its own site membership request using -me-") - public void usingMeUpdateSiteMembershipRequest() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - requestUpdateModel = restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(moderatedSite, updatedMessage); - restClient.assertStatusCodeIs(HttpStatus.OK); - requestUpdateModel.assertMembershipRequestMessageIs(updatedMessage).and().field("id").is(moderatedSite.getId()).and().field("modifiedAt").isNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify inexistent user is not able to update its own site membership request") - public void inexistentUserCannotUpdateSiteMembershipRequest() throws Exception - { - UserModel inexistentUser = UserModel.getRandomUserModel(); - restClient.authenticateUser(managerUser).withCoreAPI().usingUser(inexistentUser).updateSiteMembershipRequest(moderatedSite, updatedMessage); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, inexistentUser.getUsername())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to update its own site membership request for inexistent site") - public void userCannotUpdateSiteMembershipRequestForInexistentSite() throws Exception - { - SiteModel randomSite = SiteModel.getRandomSiteModel(); - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingMe().updateSiteMembershipRequest(randomSite, updatedMessage); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, newMember.getUsername(), randomSite.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is able not to update its own site membership request for public site") - public void userCannotUpdateSiteMembershipRequestForPublicSite() throws Exception - { - SiteModel publicSite = dataSite.usingUser(managerUser).createPublicRandomSite(); - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(publicSite); - restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(publicSite, updatedMessage); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, newMember.getUsername(), publicSite.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to update its own site membership request for private site") - public void userCannotUpdateSiteMembershipRequestForPrivateSite() throws Exception - { - SiteModel privateSite = dataSite.usingUser(managerUser).createPrivateRandomSite(); - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(privateSite); - restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(privateSite, updatedMessage); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, newMember.getUsername(), privateSite.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is able to update its own site membership request with initial message") - public void userCanUpdateSiteMembershipRequestWithInitialMessage() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(updatedMessage, moderatedSite, "Accept me"); - requestUpdateModel = restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(moderatedSite, updatedMessage); - restClient.assertStatusCodeIs(HttpStatus.OK); - requestUpdateModel.assertMembershipRequestMessageIs(updatedMessage).and().field("id").is(moderatedSite.getId()).and().field("modifiedAt").isNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is able to update its own site membership request with different message") - public void userCanUpdateSiteMembershipRequestWithDifferentMessage() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest("", moderatedSite, "Accept me"); - requestUpdateModel = restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(moderatedSite, updatedMessage); - restClient.assertStatusCodeIs(HttpStatus.OK); - requestUpdateModel.assertMembershipRequestMessageIs(updatedMessage).and().field("id").is(moderatedSite.getId()).and().field("modifiedAt").isNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify modifiedAt field for update siteMembership request call") - public void verifyModifiedAtForUpdateSiteMembershipRequest() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - String firstModifiedAt = restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(moderatedSite, "first message").getModifiedAt(); - String secondModifiedAt = restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(moderatedSite, "second message").getModifiedAt(); - Assert.assertNotEquals(firstModifiedAt, secondModifiedAt); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify user is not able to update membership request of admin") - public void userIsNotAbleToUpdateSiteMembershipRequestOfAdmin() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser() - .addSiteMembershipRequest(moderatedSite); - - restClient.authenticateUser(newMember).withCoreAPI().usingUser(adminUser) - .updateSiteMembershipRequest(moderatedSite, updatedMessage); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format("The entity with id: " + RestErrorModel.ENTITY_NOT_FOUND, adminUser.getUsername())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify site manager is able to update site membership request") - public void updateSiteMembershipRequestAfterUserIsAddedAsMember() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser() - .addSiteMembershipRequest(moderatedSite); - dataUser.usingUser(managerUser).addUserToSite(newMember, moderatedSite, UserRole.SiteManager); - requestUpdateModel = restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser() - .updateSiteMembershipRequest(moderatedSite, updatedMessage); - - restClient.assertStatusCodeIs(HttpStatus.OK); - requestUpdateModel.assertThat().field("id").is(moderatedSite.getId()) - .assertThat().field("message").is(updatedMessage) - .assertThat().field("modifiedAt").isNotEmpty() - .assertThat().field("createdAt").isNotEmpty(); - requestUpdateModel.getSite().assertThat().field("role").is(UserRole.SiteManager) - .assertThat().field("visibility").is(moderatedSite.getVisibility()) - .assertThat().field("guid").is(moderatedSite.getGuid()) - .assertThat().field("description").is(moderatedSite.getDescription()) - .assertThat().field("id").is(moderatedSite.getId()) - .assertThat().field("preset").is("site-dashboard") - .assertThat().field("title").is(moderatedSite.getTitle()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify admin is able to update site membership request") - public void adminIsAbleToUpdateHisSiteMembershipRequest() throws Exception - { - UserModel regularUser = dataUser.createRandomTestUser(); - SiteModel anotherModeratedSite = dataSite.usingUser(regularUser).createModeratedRandomSite(); - requestUpdateModel = restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser() - .addSiteMembershipRequest(anotherModeratedSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - requestUpdateModel = restClient.withCoreAPI().usingAuthUser() - .updateSiteMembershipRequest(anotherModeratedSite, updatedMessage); - - restClient.assertStatusCodeIs(HttpStatus.OK); - requestUpdateModel.assertThat().field("id").is(anotherModeratedSite.getId()) - .assertThat().field("message").is("Please review my request") - .assertThat().field("modifiedAt").isNotEmpty() - .assertThat().field("createdAt").isNotEmpty(); - requestUpdateModel.getSite().assertThat().field("visibility").is(anotherModeratedSite.getVisibility()) - .assertThat().field("guid").is(anotherModeratedSite.getGuid()) - .assertThat().field("description").is(anotherModeratedSite.getDescription()) - .assertThat().field("id").is(anotherModeratedSite.getId()) - .assertThat().field("preset").is("site-dashboard") - .assertThat().field("title").is(anotherModeratedSite.getTitle()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify user update site membership request with no message then adds a new message") - public void userUpdateSiteMembershipRequestWithNoMessageThenAddsNewMessage() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - requestUpdateModel = restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser() - .addSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - requestUpdateModel.assertThat().field("id").is(moderatedSite.getId()) - .assertThat().field("message").is("Please accept me"); - - requestUpdateModel = restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(moderatedSite, ""); - restClient.assertStatusCodeIs(HttpStatus.OK); - requestUpdateModel.assertThat().field("id").is(moderatedSite.getId()) - .and().field("modifiedAt").isNotEmpty() - .assertThat().field("message").isNull(); - - requestUpdateModel = restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(moderatedSite, updatedMessage); - requestUpdateModel.assertThat().field("id").is(moderatedSite.getId()) - .assertThat().field("message").is(updatedMessage) - .assertThat().field("modifiedAt").isNotEmpty() - .assertThat().field("createdAt").isNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify user updates site membership request and verifies 'ModifiedAt' field using GET") - public void userUpdateSiteMembershipRequestAndCheckModifiedAtWithGet() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - requestUpdateModel = restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser() - .addSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - requestUpdateModel.assertThat().field("id").is(moderatedSite.getId()) - .assertThat().field("message").is("Please accept me"); - - requestUpdateModel = restClient.withCoreAPI().usingAuthUser().updateSiteMembershipRequest(moderatedSite, updatedMessage); - requestGetModel = restClient.withCoreAPI().usingAuthUser().getSiteMembershipRequest(moderatedSite); - - restClient.assertStatusCodeIs(HttpStatus.OK); - requestGetModel.assertThat().field("id").is(requestUpdateModel.getId()) - .and().field("modifiedAt").is(requestUpdateModel.getModifiedAt()) - .assertThat().field("message").is(requestUpdateModel.getMessage()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Update membership request - empty body") - public void emptyBodyUpdateSiteMembershipRequest() throws Exception - { - restClient.authenticateUser(adminUser).withCoreAPI(); - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"\": \"\",\"\": \"\", \"\": \"\"}", - "people/{personId}/site-membership-requests/{siteId}", adminUser.getUsername(), moderatedSite.getId()); - restClient.processModel(RestSiteMembershipRequestModel.class, request); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.NO_CONTENT, "Unrecognized field " + "\"\"")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Update membership request - missing 'Title' field from Json") - public void missingTitleFieldBodyUpdateSiteMembershipRequest() throws Exception - { - SiteModel moderatedSite = dataSite.usingUser(managerUser).createModeratedRandomSite(); - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser() - .addSiteMembershipRequest(moderatedSite); - - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, - "{\"message\":\"Please review my request\",\"id\":\"" + moderatedSite.getId() + "\"}", - "people/{personId}/site-membership-requests/{siteId}", - newMember.getUsername(), moderatedSite.getId()); - requestUpdateModel = restClient.processModel(RestSiteMembershipRequestModel.class, request); - - restClient.assertStatusCodeIs(HttpStatus.OK); - requestUpdateModel.assertThat().field("id").is(moderatedSite.getId()) - .assertThat().field("message").is(updatedMessage) - .assertThat().field("site").isNotEmpty() - .assertThat().field("modifiedAt").isNotEmpty() - .assertThat().field("createdAt").isNotEmpty(); - requestUpdateModel.getSite().assertThat().field("visibility").is(moderatedSite.getVisibility()) - .assertThat().field("guid").is(moderatedSite.getGuid()) - .assertThat().field("description").is(moderatedSite.getDescription()) - .assertThat().field("id").is(moderatedSite.getId()) - .assertThat().field("preset").is("site-dashboard") - .assertThat().field("title").is(moderatedSite.getTitle()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Update site membership request - missing JSON body") - public void missingJsonFieldBodyUpdateSiteMembershipRequest() throws Exception - { - SiteModel moderatedSite = dataSite.usingUser(managerUser).createModeratedRandomSite(); - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser() - .addSiteMembershipRequest(moderatedSite); - - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "", - "people/{personId}/site-membership-requests/{siteId}", newMember.getUsername(), - moderatedSite.getId()); - requestUpdateModel = restClient.processModel(RestSiteMembershipRequestModel.class, request); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsSummary(String.format(RestErrorModel.NO_CONTENT, "No content to map due to end-of-input")) - .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "No content to map due to end-of-input")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Update site membership request - empty JSON body") - public void emptyJsonFieldBodyUpdateSiteMembershipRequest() throws Exception - { - SiteModel moderatedSite = dataSite.usingUser(managerUser).createModeratedRandomSite(); - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser() - .addSiteMembershipRequest(moderatedSite); - - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{}", - "people/{personId}/site-membership-requests/{siteId}", newMember.getUsername(), - moderatedSite.getId()); - requestUpdateModel = restClient.processModel(RestSiteMembershipRequestModel.class, request); - - restClient.assertStatusCodeIs(HttpStatus.OK); - requestUpdateModel.assertThat().field("id").is(moderatedSite.getId()) - .assertThat().field("message").isNull() - .assertThat().field("site").isNotEmpty() - .assertThat().field("modifiedAt").isNotEmpty() - .assertThat().field("createdAt").isNotEmpty(); - requestUpdateModel.getSite().assertThat().field("visibility").is(moderatedSite.getVisibility()) - .assertThat().field("guid").is(moderatedSite.getGuid()) - .assertThat().field("description").is(moderatedSite.getDescription()) - .assertThat().field("id").is(moderatedSite.getId()) - .assertThat().field("preset").is("site-dashboard") - .assertThat().field("title").is(moderatedSite.getTitle()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Update site membership request - invalid SiteId") - public void invalidSiteIdUpdateSiteMembershipRequest() throws Exception - { - moderatedSite.setId("invalidSiteId"); - restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser() - .updateSiteMembershipRequest(moderatedSite, updatedMessage); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, managerUser.getUsername(), moderatedSite.getId())); - - moderatedSite.setId(moderatedSiteId); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Update site membership request - empty SiteId") - public void emptySiteIdUpdateSiteMembershipRequest() throws Exception - { - moderatedSite.setId(""); - restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser() - .updateSiteMembershipRequest(moderatedSite, updatedMessage); - - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) - .assertLastError() - .containsSummary(RestErrorModel.PUT_EMPTY_ARGUMENT) - .containsErrorKey(RestErrorModel.PUT_EMPTY_ARGUMENT) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - - moderatedSite.setId(moderatedSiteId); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify inexistent user is not able to update site membership request") - public void emptyUserCannotUpdateSiteMembershipRequest() throws Exception - { - UserModel emptyUser = new UserModel("", "password"); - restClient.authenticateUser(emptyUser).withCoreAPI().usingAuthUser() - .updateSiteMembershipRequest(moderatedSite, updatedMessage); - - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Update site membership request - rejected Request") - public void rejectRequestThenUpdateSiteMembershipRequest() throws Exception - { - UserModel userWithRejectedRequests = dataUser.createRandomTestUser(); - restClient.authenticateUser(userWithRejectedRequests).withCoreAPI().usingAuthUser() - .addSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - RestTaskModel taskModel = restClient.authenticateUser(userWithRejectedRequests).withWorkflowAPI().getTasks() - .getTaskModelByDescription(moderatedSite); - workflow.approveSiteMembershipRequest(managerUser.getUsername(), managerUser.getPassword(), taskModel.getId(), false, "Rejected"); - - requestUpdateModel = restClient.authenticateUser(userWithRejectedRequests).withCoreAPI().usingMe() - .updateSiteMembershipRequest(moderatedSite, updatedMessage); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, userWithRejectedRequests.getUsername(), moderatedSite.getId())) - .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Update site membership request - approved Request") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void approveRequestThenUpdateSiteMembershipRequest() throws Exception - { - UserModel userWithApprovedRequests = dataUser.createRandomTestUser(); - restClient.authenticateUser(userWithApprovedRequests).withCoreAPI().usingAuthUser() - .addSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - RestTaskModel taskModel = restClient.authenticateUser(userWithApprovedRequests).withWorkflowAPI().getTasks().getTaskModelByDescription(moderatedSite); - workflow.approveSiteMembershipRequest(managerUser.getUsername(), managerUser.getPassword(), taskModel.getId(), true, "Approve"); - - requestUpdateModel = restClient.authenticateUser(userWithApprovedRequests).withCoreAPI().usingMe() - .updateSiteMembershipRequest(moderatedSite, updatedMessage); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, userWithApprovedRequests.getUsername(), moderatedSite.getId())) - .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE}, executionType = ExecutionType.REGRESSION, - description = "Update site membership request using invalid network") - public void updateSiteMembershipRequestUsingInvalidNetwork() throws Exception - { - UserModel invalidUserNetwork = dataUser.createRandomTestUser(); - SiteModel site = dataSite.usingUser(invalidUserNetwork).createModeratedRandomSite(); - dataSite.usingUser(invalidUserNetwork).usingSite(site).addSiteToFavorites(); - invalidUserNetwork.setDomain("invalidNetwork"); - - requestUpdateModel = restClient.authenticateUser(invalidUserNetwork).withCoreAPI().usingMe() - .updateSiteMembershipRequest(site, updatedMessage); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE}, executionType = ExecutionType.REGRESSION, - description = "Verify user is not able to update a deleted site membership request") - public void userCantUpdateSiteMembershipRequestForDeletedRequest() throws Exception - { - SiteModel moderatedSite = dataSite.usingUser(managerUser).createModeratedRandomSite(); - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser() - .addSiteMembershipRequest(moderatedSite); - - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser() - .deleteSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - requestUpdateModel = restClient.withCoreAPI().usingAuthUser() - .updateSiteMembershipRequest(moderatedSite, updatedMessage); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, newMember.getUsername(), moderatedSite.getId())); - } -} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/syncService/SyncServiceAPITests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/syncService/SyncServiceAPITests.java deleted file mode 100644 index 1f834f875..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/syncService/SyncServiceAPITests.java +++ /dev/null @@ -1,204 +0,0 @@ -package org.alfresco.service.search.rest.syncService; - -import java.util.LinkedList; -import java.util.List; - -import org.alfresco.rest.model.RestSubscriberModel; -import org.alfresco.rest.model.RestSubscriberModelCollection; -import org.alfresco.rest.model.RestSyncNodeSubscriptionModel; -import org.alfresco.rest.model.RestSyncNodeSubscriptionModelCollection; -import org.alfresco.rest.model.RestSyncServiceHealthCheckModel; -import org.alfresco.rest.model.RestSyncSetChangesModel; -import org.alfresco.rest.model.RestSyncSetGetModel; -import org.alfresco.rest.model.RestSyncSetRequestModel; -import org.alfresco.rest.requests.syncServiceAPI.Healthcheck; -import org.alfresco.rest.requests.syncServiceAPI.Subscriptions.TYPE; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.utility.LogFactory; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.slf4j.Logger; -import org.springframework.http.HttpStatus; -import org.testng.Assert; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Sanity tests for Testing Sync Service APIs - * - * @author mbhave - */ -@Test(groups = { TestGroup.SYNC_API, TestGroup.REQUIRES_AMP }) -public class SyncServiceAPITests extends RestTest -{ - private static Logger LOG = LogFactory.getLogger(); - - private UserModel adminUserModel; - private SiteModel siteModel; - private FolderModel targetFolder1; - private FolderModel targetFolder2; - - private RestSyncNodeSubscriptionModelCollection nodeSubscriptions; - - private String clientVersion; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - restClient.authenticateUser(adminUserModel); - - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - - targetFolder1 = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); - - targetFolder2 = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); - - siteModel.setGuid(restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(siteModel).getSite().getGuidWithoutVersion()); - - clientVersion = "1.1"; - } - - @Test(priority = 1) - public void testSyncServiceHealthCheck() throws Exception - { - // Perform HealthCheck - Healthcheck healthCheck = restClient.authenticateUser(adminUserModel).withPrivateAPI().doHealthCheck(); - - RestSyncServiceHealthCheckModel syncServiceHealthCheck = healthCheck.getHealthcheck(); - - Assert.assertTrue(syncServiceHealthCheck.getActiveMQConnection().getHealthy()); - Assert.assertTrue(syncServiceHealthCheck.getDatabaseConnection().getHealthy()); - Assert.assertTrue(syncServiceHealthCheck.getRepositoryConnection().getHealthy()); - Assert.assertTrue(syncServiceHealthCheck.getDeadlocks().getHealthy()); - Assert.assertTrue(syncServiceHealthCheck.getEventsHealthCheck().getHealthy()); - Assert.assertTrue(syncServiceHealthCheck.getSyncServiceIdCheck().getHealthy()); - Assert.assertTrue(syncServiceHealthCheck.getVersionCheck().getHealthy()); - } - - @Test(priority = 2) - public void testNewDeviceSubscription() throws Exception - { - // Register Device - RestSubscriberModel deviceSubscription = restClient.authenticateUser(adminUserModel).withPrivateAPI().withSubscribers() - .registerDevice("windows", clientVersion); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.onResponse().assertThat().body("entry.id", org.hamcrest.Matchers.notNullValue()); - restClient.onResponse().assertThat().body("entry.id", org.hamcrest.Matchers.equalTo(deviceSubscription.getId())); - - // Get Registered Devices - RestSubscriberModelCollection deviceSubscriptions = restClient.authenticateUser(adminUserModel).withParams("maxItems=500").withPrivateAPI() - .withSubscribers().getSubscribers(); - - restClient.onResponse().assertThat().body("list.entries.entry", org.hamcrest.Matchers.notNullValue()); - int noOfSubscriptions = deviceSubscriptions.getEntries().size(); - Assert.assertTrue(noOfSubscriptions > 0, "No Device subscriptions found when expected"); - Assert.assertTrue(deviceSubscriptions.getEntries().get(noOfSubscriptions - 1).onModel().getId().equals(deviceSubscription.getId()), "Not found: " - + deviceSubscription.getId()); - - } - - @Test(priority = 3) - public void testDeviceSubcriptionToNode() throws Exception - { - // Register Device - RestSubscriberModel deviceSubscription = restClient.authenticateUser(adminUserModel).withPrivateAPI().withSubscribers() - .registerDevice("windows", clientVersion); - - // Subscribe to a node - RestSyncNodeSubscriptionModel nodeSubscription = restClient.withPrivateAPI().withSubscriber(deviceSubscription) - .subscribeToNode(targetFolder1.getNodeRefWithoutVersion(), TYPE.BOTH); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.onResponse().assertThat().body("entry.deviceSubscriptionId", org.hamcrest.Matchers.notNullValue()); - restClient.onResponse().assertThat().body("entry.deviceSubscriptionId", org.hamcrest.Matchers.equalTo(deviceSubscription.getId())); - - restClient.onResponse().assertThat().body("entry.targetNodeId", org.hamcrest.Matchers.notNullValue()); - restClient.onResponse().assertThat().body("entry.targetNodeId", org.hamcrest.Matchers.equalTo(targetFolder1.getNodeRefWithoutVersion())); - - restClient.onResponse().assertThat().body("entry.id", org.hamcrest.Matchers.notNullValue()); - restClient.onResponse().assertThat().body("entry.id", org.hamcrest.Matchers.equalTo(nodeSubscription.getId())); - - // Get Sync Node Subscriptions - nodeSubscriptions = restClient.withPrivateAPI().withSubscriber(deviceSubscription).getSubscriptions(); - - nodeSubscriptions.assertThat().entriesListContains("id", nodeSubscription.getId()); - - restClient.onResponse().assertThat().body("list.entries.entry", org.hamcrest.Matchers.notNullValue()); - - int noOfSubscriptions = nodeSubscriptions.getEntries().size(); - Assert.assertTrue(noOfSubscriptions > 0, "No Sync subscriptions found when expected"); - LOG.info("Subscriptions: " + nodeSubscriptions); - Assert.assertEquals(nodeSubscriptions.getEntries().get(noOfSubscriptions - 1).onModel().getId(), nodeSubscription.getId()); - Assert.assertEquals(nodeSubscriptions.getEntries().get(noOfSubscriptions - 1).onModel().getDeviceSubscriptionId(), - nodeSubscription.getDeviceSubscriptionId()); - - // Get Sync Node Subscription by subscriptionId - RestSyncNodeSubscriptionModel subscription = restClient.withPrivateAPI().withSubscriber(deviceSubscription).getSubscription(nodeSubscription.getId()); - - subscription.assertThat().field("id").isNotNull().assertThat().field("id").is(nodeSubscription.getId()).assertThat().field("deviceSubscriptionId") - .isNotNull().assertThat().field("deviceSubscriptionId").is(nodeSubscription.getDeviceSubscriptionId()); - } - - @Test(priority = 4) - public void testDeviceSubcriptionToMultipleNodes() throws Exception - { - // Register Device - RestSubscriberModel deviceSubscription = restClient.authenticateUser(adminUserModel).withPrivateAPI().withSubscribers() - .registerDevice("windows", "1.2"); - - // Subscribe to a node - restClient.withPrivateAPI().withSubscriber(deviceSubscription) - .subscribeToNodes(siteModel.getGuid(), targetFolder1.getNodeRefWithoutVersion(), targetFolder2.getNodeRefWithoutVersion()); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - // Get Sync Node Subscriptions - RestSyncNodeSubscriptionModelCollection subscriptionList = restClient.withPrivateAPI().withSubscriber(deviceSubscription).getSubscriptions(); - - int countOfEntries = subscriptionList.getEntries().size(); - Assert.assertTrue(countOfEntries == 3, "Node subscriptions NOT found when expected"); - } - - @Test(priority = 5) - public void testSyncProcess() throws Exception - { - // Register Device - List clientChanges = new LinkedList<>(); - RestSubscriberModel deviceSubscription = restClient.authenticateUser(adminUserModel).withPrivateAPI().withSubscribers() - .registerDevice("windows", "1.2"); - - // Subscribe to a node - RestSyncNodeSubscriptionModel nodeSubscription = restClient.withPrivateAPI().withSubscriber(deviceSubscription) - .subscribeToNode(targetFolder1.getNodeRefWithoutVersion(), TYPE.BOTH); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - // Start Sync - RestSyncSetRequestModel syncRequest = restClient.authenticateUser(adminUserModel).withPrivateAPI().withSubscription(nodeSubscription) - .startSync(nodeSubscription, clientChanges, clientVersion); - - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - Assert.assertNotNull(syncRequest.getSyncId(), "Sync Id not expected to be null"); - String syncId = syncRequest.getSyncId(); - Assert.assertNotNull(syncRequest.getUrl(), "Sync URL not expected to be null"); - Assert.assertTrue(syncRequest.getUrl().endsWith(syncId), "Incorrect Sync URL, expected to end with syncId: " + syncId); - Assert.assertEquals(syncRequest.getStatus(), "ok", "Sync Status not ok. Actual: " + syncRequest.getStatus()); - Assert.assertNull(syncRequest.getMessage(), "Sync Message was expected to be null. Actual: " + syncRequest.getMessage()); - Assert.assertNull(syncRequest.getError(), "Sync Error expected to be null. Actual: " + syncRequest.getError()); - - // Get Sync Changes - RestSyncSetGetModel changeSet = restClient.withPrivateAPI().withSubscription(nodeSubscription).getSync(nodeSubscription, syncRequest); - - restClient.assertStatusCodeIs(HttpStatus.OK); - Assert.assertNotNull(changeSet.getSyncId(), "Sync Id not expected to be null"); - Assert.assertTrue(changeSet.getSyncId().equals(syncId), "Incorrect SyncId in the response"); - Assert.assertNotNull(changeSet.getMoreChanges(), "MoreChanges expected to be true or false. It's null"); - - // End Sync - restClient.withPrivateAPI().withSubscription(nodeSubscription).endSync(nodeSubscription, syncRequest); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/tags/TagsDataPrep.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/tags/TagsDataPrep.java deleted file mode 100644 index 974257df6..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/tags/TagsDataPrep.java +++ /dev/null @@ -1,70 +0,0 @@ -package org.alfresco.service.search.rest.tags; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestTagModel; -import org.alfresco.rest.model.RestTagModelsCollection; -import org.alfresco.utility.Utility; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.testng.annotations.Test; - -@Test(groups = {TestGroup.REQUIRE_SOLR}) -public class TagsDataPrep extends RestTest -{ - - protected static UserModel adminUserModel; - protected static UserModel userModel; - protected static ListUserWithRoles usersWithRoles; - protected static SiteModel siteModel; - protected static FileModel document; - protected static FolderModel folder; - protected static String documentTagValue, documentTagValue2, folderTagValue; - protected static RestTagModel documentTag, documentTag2, folderTag, returnedModel; - protected static RestTagModelsCollection returnedCollection; - private static boolean isInitialized = false; - - public void init() throws Exception - { - if(!isInitialized) - { - isInitialized = true; - initialization(); - } - } - - public void initialization() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - //Create public site - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - usersWithRoles = dataUser.usingAdmin().addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); - document = dataContent.usingUser(adminUserModel).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - folder = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); - - documentTagValue = RandomData.getRandomName("tag"); - documentTagValue2 = RandomData.getRandomName("tag"); - folderTagValue = RandomData.getRandomName("tag"); - - restClient.authenticateUser(adminUserModel); - documentTag = restClient.withCoreAPI().usingResource(document).addTag(documentTagValue); - documentTag2 = restClient.withCoreAPI().usingResource(document).addTag(documentTagValue2); - folderTag = restClient.withCoreAPI().usingResource(folder).addTag(folderTagValue); - - // Allow indexing to complete. - Utility.sleep(1000, 60000, () -> - { - returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); - returnedCollection.assertThat().entriesListContains("tag", documentTagValue.toLowerCase()) - .and().entriesListContains("tag", documentTagValue2.toLowerCase()) - .and().entriesListContains("tag", folderTagValue.toLowerCase()); - }); - - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/trashcan/GetDeletedNodesTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/trashcan/GetDeletedNodesTests.java deleted file mode 100644 index 02ea3f126..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/trashcan/GetDeletedNodesTests.java +++ /dev/null @@ -1,245 +0,0 @@ -/* - * Copyright (C) 2005-2017 Alfresco Software Limited. - * This file is part of Alfresco - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ - -package org.alfresco.service.search.rest.trashcan; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestNodeModel; -import org.alfresco.rest.model.RestNodeModelsCollection; -import org.alfresco.rest.model.RestRenditionInfoModel; -import org.alfresco.rest.model.RestRenditionInfoModelCollection; -import org.alfresco.utility.Utility; -import org.alfresco.utility.exception.DataPreparationException; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Tests for /api-explorer/#!/trashcan/listDeletedNodes - * /api-explorer/#!/trashcan/deleteDeletedNode - * /api-explorer/#!/trashcan/getDeletedNode - * /api-explorer/#!/trashcan/restoreDeletedNode - * - * @author jcule - * - */ -public class GetDeletedNodesTests extends RestTest -{ - private UserModel adminUserModel; - private SiteModel deleteNodesSiteModel; - private FolderModel deleteNodesFolder1, deleteNodesFolder2, deleteNodesFolder3, deleteNodesFolder4, deleteNodesFolder5, getDeleteNodesFolder6; - private FileModel file, file1, file2, file3, file4; - - private RestNodeModelsCollection deletedNodes, deletedNodesMaxItem; - private RestNodeModel node; - - private RestRenditionInfoModelCollection nodeRenditionInfoCollection; - private RestRenditionInfoModel nodeRenditionInfo; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws DataPreparationException - { - adminUserModel = dataUser.getAdminUser(); - restClient.authenticateUser(adminUserModel); - deleteNodesSiteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - } - - @AfterClass(alwaysRun = true) - public void cleanup() throws Exception - { - dataSite.usingAdmin().deleteSite(deleteNodesSiteModel); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.REGRESSION }) - public void testDeletedNodesBiggerThanMaxCount() throws Exception - { - // get the number of item in the trashcan - deletedNodes = restClient.withCoreAPI().usingTrashcan().findDeletedNodes(); - int count = deletedNodes.getPagination().getCount(); - int totalItems = deletedNodes.getPagination().getTotalItems(); - - // create folders - deleteNodesFolder1 = dataContent.usingUser(adminUserModel).usingSite(deleteNodesSiteModel).createFolder(); - deleteNodesFolder2 = dataContent.usingUser(adminUserModel).usingSite(deleteNodesSiteModel).createFolder(); - deleteNodesFolder3 = dataContent.usingUser(adminUserModel).usingSite(deleteNodesSiteModel).createFolder(); - - // delete folders - dataContent.usingUser(adminUserModel).usingResource(deleteNodesFolder1).deleteContent(); - dataContent.usingUser(adminUserModel).usingResource(deleteNodesFolder2).deleteContent(); - dataContent.usingUser(adminUserModel).usingResource(deleteNodesFolder3).deleteContent(); - - int maxItems = count + 1; - deletedNodesMaxItem = restClient.withCoreAPI().usingTrashcan().usingParams(String.format("maxItems=%s", maxItems)).findDeletedNodes(); - - String countMaxItem = Integer.toString(maxItems); - String totalItemsMaxItem = Integer.toString(totalItems + 3); - String hasMoreItemsMaxItem = Boolean.toString(deletedNodesMaxItem.getPagination().isHasMoreItems()); - String skipCount = Integer.toString(deletedNodesMaxItem.getPagination().getSkipCount()); - - restClient.assertStatusCodeIs(HttpStatus.OK); - deletedNodesMaxItem.getPagination().assertThat().field("totalItems").is(totalItemsMaxItem).and().field("count").is(countMaxItem); - deletedNodesMaxItem.getPagination().assertThat().field("hasMoreItems").is(hasMoreItemsMaxItem).and().field("skipCount").is(skipCount); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TRASHCAN }, executionType = ExecutionType.SANITY, description = "Sanity tests for GET /deleted-nodes and GET /deleted-nodes/{nodeId}") - @Test(groups = { TestGroup.REST_API, TestGroup.TRASHCAN, TestGroup.SANITY }) - public void testGetDeletedNodesFromTrashcan() throws Exception - { - // Create a folder and a file - deleteNodesFolder4 = dataContent.usingUser(adminUserModel).usingSite(deleteNodesSiteModel).createFolder(); - file = dataContent.usingUser(adminUserModel).usingSite(deleteNodesSiteModel).createContent(DocumentType.TEXT_PLAIN); - - // Delete file and folder - dataContent.usingUser(adminUserModel).usingResource(deleteNodesFolder4).deleteContent(); - dataContent.usingUser(adminUserModel).usingResource(file).deleteContent(); - - // GET /deleted-nodes: deleted file and folder are in the trashcan list - deletedNodes = restClient.withCoreAPI().usingTrashcan().findDeletedNodes(); - restClient.assertStatusCodeIs(HttpStatus.OK); - deletedNodes.getEntryByIndex(0).assertThat().field("name").is(file.getName()).and() - .field("id").is(file.getNodeRefWithoutVersion()); - deletedNodes.getEntryByIndex(1).assertThat().field("name").is(deleteNodesFolder4.getName()).and() - .field("id").is(deleteNodesFolder4.getNodeRefWithoutVersion()); - - // GET /deleted-nodes/{nodeId}: check a single deleted object - node = restClient.withCoreAPI().usingTrashcan().findDeletedNode(deleteNodesFolder4); - restClient.assertStatusCodeIs(HttpStatus.OK); - node.assertThat().field("name").is(deleteNodesFolder4.getName()).and() - .field("id").is(deleteNodesFolder4.getNodeRefWithoutVersion()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TRASHCAN }, executionType = ExecutionType.SANITY, description = "Sanity tests for DELETE /deleted-nodes/{nodeId} and POST /deleted-nodes/{nodeId}/restore") - @Test(groups = { TestGroup.REST_API, TestGroup.TRASHCAN, TestGroup.SANITY }) - public void testDeleteAndRestoreNodeFromTrashcan() throws Exception - { - // Create a folder and a file - deleteNodesFolder5 = dataContent.usingUser(adminUserModel).usingSite(deleteNodesSiteModel).createFolder(); - String docLibNodeRef = dataContent.usingUser(adminUserModel).usingSite(deleteNodesSiteModel).getNodeRef(); - file1 = dataContent.usingUser(adminUserModel).usingSite(deleteNodesSiteModel).createContent(DocumentType.TEXT_PLAIN); - - // Delete file and folder - dataContent.usingUser(adminUserModel).usingResource(deleteNodesFolder5).deleteContent(); - dataContent.usingUser(adminUserModel).usingResource(file1).deleteContent(); - - // DELETE /deleted-nodes/{nodeId}: delete an object from trashcan - restClient.withCoreAPI().usingTrashcan().deleteNodeFromTrashcan(file1); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingTrashcan().findDeletedNode(file1); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - - // POST /deleted-nodes/{nodeId}/restore: restore to repository a deleted object - node = restClient.withCoreAPI().usingTrashcan().restoreNodeFromTrashcan(deleteNodesFolder5); - restClient.assertStatusCodeIs(HttpStatus.OK); - node.assertThat().field("id").is(deleteNodesFolder5.getNodeRefWithoutVersion()).and() - .field("parentId").is(docLibNodeRef); - - // Checks that the node was removed from trashcan - restClient.withCoreAPI().usingTrashcan().findDeletedNode(deleteNodesFolder5); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TRASHCAN }, executionType = ExecutionType.SANITY, description = "Sanity tests for GET /deleted-nodes/{nodeId}/content") - @Test(groups = { TestGroup.REST_API, TestGroup.TRASHCAN, TestGroup.SANITY }) - public void testGetDeletedNodesContent() throws Exception - { - // Create file2 based on existing resource - FileModel newFile = FileModel.getFileModelBasedOnTestDataFile("sampleContent.txt"); - newFile.setName("sampleContent.txt"); - file2 = dataContent.usingUser(adminUserModel).usingSite(deleteNodesSiteModel).createContent(newFile); - - // Delete file2 to be moved in trashcan - dataContent.usingUser(adminUserModel).usingResource(file2).deleteContent(); - - // Make GET /deleted-nodes/{nodeId}/content and check file content - restClient.withCoreAPI().usingTrashcan().getDeletedNodeContent(file2); - restClient.assertStatusCodeIs(HttpStatus.OK); - restClient.assertHeaderValueContains("Content-Disposition", file2.getName()); - restClient.onResponse().getResponse().body().asString().contains("Sample text."); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TRASHCAN, TestGroup.REQUIRE_SOLR }, executionType = ExecutionType.SANITY, - description = "Sanity tests for GET /deleted-nodes/{nodeId}/renditions, GET /deleted-nodes/{nodeId}/renditions/{renditionId}, GET /deleted-nodes/{nodeId}/renditions/{renditionId}/content") - @Test(groups = { TestGroup.REST_API, TestGroup.TRASHCAN, TestGroup.SANITY }) - public void testGetDeletedNodesRenditions() throws Exception - { - // Create file3 based on existing resource - file3 = dataContent.usingUser(adminUserModel).usingSite(deleteNodesSiteModel).createContent(DocumentType.TEXT_PLAIN); - - // Create rendition and delete file3 to be moved in trashcan - restClient.withCoreAPI().usingNode(file3).createNodeRendition("pdf"); - restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); - dataContent.usingUser(adminUserModel).usingResource(file3).deleteContent(); - - // GET /deleted-nodes/{nodeId}/renditions - Utility.sleep(1000, 30000, () -> - { - nodeRenditionInfoCollection = restClient.authenticateUser(adminUserModel).withCoreAPI().usingTrashcan().getDeletedNodeRenditions(file3); - restClient.assertStatusCodeIs(HttpStatus.OK); - - // Check if renditions are retrieved, created or not. Entries are ordered - nodeRenditionInfoCollection.assertThat().entriesListContains("id", "doclib"); - nodeRenditionInfoCollection.getEntryByIndex(5).assertThat().field("id").is("pdf").and() - .field("status").is("CREATED"); - }); - - // GET /deleted-nodes/{nodeId}/renditions/{id} - nodeRenditionInfo = restClient.authenticateUser(adminUserModel).withCoreAPI().usingTrashcan().getDeletedNodeRendition(file3, "pdf"); - restClient.assertStatusCodeIs(HttpStatus.OK); - nodeRenditionInfo.assertThat().field("id").is("pdf").and() - .field("status").is("CREATED"); - - // GET /deleted-nodes/{nodeId}/renditions/{id}/content - restClient.authenticateUser(adminUserModel).withCoreAPI().usingTrashcan().getDeletedNodeRenditionContent(file3, "pdf"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restClient.assertHeaderValueContains("Content-Type","application/pdf;charset=UTF-8"); - Assert.assertTrue(restClient.onResponse().getResponse().body().asInputStream().available() > 0); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.TRASHCAN, TestGroup.REQUIRE_SOLR}, executionType = ExecutionType.SANITY, - description = "Sanity test to verify Range request header on GET /deleted-nodes/{nodeId}/renditions/{renditionId}/content endpoint") - @Test(groups = {TestGroup.REST_API, TestGroup.TRASHCAN, TestGroup.SANITY}) - public void testGetDeletedNodesRenditionsandVerifyRangeRequestheader() throws Exception - { - // Create file4 based on existing resource - file4 = dataContent.usingUser(adminUserModel).usingSite(deleteNodesSiteModel).createContent(DocumentType.TEXT_PLAIN); - - // Create rendition and delete file4 to be moved in trashcan - restClient.withCoreAPI().usingNode(file4).createNodeRendition("pdf"); - restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); - dataContent.usingUser(adminUserModel).usingResource(file4).deleteContent(); - - // GET /deleted-nodes/{nodeId}/renditions/{id}/content and verify range request header - Utility.sleep(1000, 30000, () -> - { - restClient.configureRequestSpec().addHeader("content-range", "bytes=1-10"); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingTrashcan().getDeletedNodeRenditionContent(file4, "pdf"); - restClient.assertStatusCodeIs(HttpStatus.PARTIAL_CONTENT); - restClient.assertHeaderValueContains("Content-Type", "application/pdf;charset=UTF-8"); - restClient.assertHeaderValueContains("content-range", "bytes 1-10"); - restClient.assertHeaderValueContains("content-length", String.valueOf(10)); - }); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/WorkflowNetworkDeploymentsTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/WorkflowNetworkDeploymentsTests.java deleted file mode 100644 index b28409dc0..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/WorkflowNetworkDeploymentsTests.java +++ /dev/null @@ -1,124 +0,0 @@ -package org.alfresco.service.search.rest.workflow; - -import java.util.List; - -import org.alfresco.service.search.rest.NetworkDataPrep; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestDeploymentModel; -import org.alfresco.rest.model.RestDeploymentModelsCollection; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class WorkflowNetworkDeploymentsTests extends NetworkDataPrep -{ - private RestDeploymentModel expectedDeployment, actualDeployment; - private RestDeploymentModelsCollection deployments; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - init(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, - executionType = ExecutionType.REGRESSION, - description = "Verify if network admin user gets a network deployment using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION, TestGroup.NETWORKS}) - public void adminGetsNetworkDeploymentWithSuccess() throws Exception - { - - expectedDeployment = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getDeployments().getOneRandomEntry().onModel(); - actualDeployment = restClient.withWorkflowAPI().usingDeployment(expectedDeployment).getDeployment(); - restClient.assertStatusCodeIs(HttpStatus.OK); - actualDeployment.assertThat().field("deployedAt").isNotEmpty() - .and().field("name").is(expectedDeployment.getName()) - .and().field("id").is(expectedDeployment.getId()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, - executionType = ExecutionType.REGRESSION, - description = "Verify non admin user is forbidden to get a network deployment using REST API (403)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void nonAdminUserIsForbiddenToGetNetworkDeployment() throws Exception - { - expectedDeployment = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getDeployments().getOneRandomEntry().onModel(); - - restClient.authenticateUser(tenantUser).withWorkflowAPI().usingDeployment(expectedDeployment).getDeployment(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Bug(id = "MNT-16996") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, - executionType = ExecutionType.REGRESSION, - description = "Verify get deployments returns an empty list after deleting all network deployments.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION, TestGroup.NETWORKS}) - public void getNetworkDeploymentsAfterDeletingAllNetworkDeployments() throws Exception - { - - List networkDeployments = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getDeployments().getEntries(); - for (RestDeploymentModel networkDeployment: networkDeployments) - { - restClient.withWorkflowAPI().usingDeployment(networkDeployment.onModel()).deleteDeployment(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - deployments = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getDeployments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - deployments.assertThat().entriesListIsEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, - executionType = ExecutionType.REGRESSION, - description = "Verify non admin user is not able to get network deployments using REST API and status code is Forbidden") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION, TestGroup.NETWORKS}) - public void nonAdminUserCanNotGetNetworkDeployments() throws Exception - { - restClient.authenticateUser(tenantUser).withWorkflowAPI().getDeployments(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, - executionType = ExecutionType.REGRESSION, - description = "Verify that network admin user is not able to get a deployment from other network using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION, TestGroup.NETWORKS}) - public void adminDoesNotGetDeploymentFromOtherNetwork() throws Exception - { - expectedDeployment = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getDeployments().getOneRandomEntry().onModel(); - actualDeployment = restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().usingDeployment(expectedDeployment).getDeployment(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, expectedDeployment.getId())) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, - executionType = ExecutionType.REGRESSION, - description = "Verify that network admin user is not able to get a deployment from other network using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION, TestGroup.NETWORKS}) - public void adminDoesNotGetDeploymentsFromOtherNetwork() throws Exception - { - RestDeploymentModel deployment = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getDeployments().getOneRandomEntry().onModel(); - deployments = restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().getDeployments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - deployments.assertThat().entriesListDoesNotContain("id", deployment.getId()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.SANITY, - description = "Verify Tenant Admin user gets network deployments using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.SANITY, TestGroup.NETWORKS}) - public void getNetworkDeploymentsWithAdmin() throws JsonToModelConversionException, Exception - { - deployments = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getDeployments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - deployments.assertThat().entriesListIsNotEmpty(); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/WorkflowNetworkProcessDefinitionsTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/WorkflowNetworkProcessDefinitionsTests.java deleted file mode 100644 index f20cb20dc..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/WorkflowNetworkProcessDefinitionsTests.java +++ /dev/null @@ -1,221 +0,0 @@ -package org.alfresco.service.search.rest.workflow; - -import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.service.search.rest.NetworkDataPrep; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestProcessDefinitionModel; -import org.alfresco.rest.model.RestProcessDefinitionModelsCollection; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class WorkflowNetworkProcessDefinitionsTests extends NetworkDataPrep -{ - private RestProcessDefinitionModel randomProcessDefinition, returnedProcessDefinition; - private RestProcessModel addedProcess; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - init(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, - executionType = ExecutionType.REGRESSION, - description = "Verify network admin is able to get a process definition using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void networkAdminGetProcessDefinition() throws Exception - { - randomProcessDefinition = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry().onModel(); - returnedProcessDefinition = restClient.withWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinition(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedProcessDefinition.assertThat().field("name").is(randomProcessDefinition.getName()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, - executionType = ExecutionType.REGRESSION, - description = "Verify network user is able to get a process definition using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void networkUserGetProcessDefinition() throws Exception - { - randomProcessDefinition = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() - .getAllProcessDefinitions().getOneRandomEntry().onModel(); - returnedProcessDefinition = restClient.authenticateUser(tenantUser).withWorkflowAPI() - .usingProcessDefinitions(randomProcessDefinition).getProcessDefinition(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedProcessDefinition.assertThat().field("name").is(randomProcessDefinition.getName()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, - description = "Verify get process definitions using any network user for network enabled deployments with REST API status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION, TestGroup.NETWORKS}) - public void networkUserGetsProcessDefinitions() throws Exception - { - restClient.authenticateUser(tenantUser) - .withWorkflowAPI() - .getAllProcessDefinitions() - .assertThat().entriesListIsNotEmpty(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, - executionType = ExecutionType.REGRESSION, - description = "Verify Network user is not able to get a process definition from another network") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.NETWORKS, TestGroup.REGRESSION }) - public void getProcessDefinitionFromAnotherNetwork() throws Exception - { - randomProcessDefinition = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() - .getAllProcessDefinitions().getOneRandomEntry().onModel(); - restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI() - .usingProcessDefinitions(randomProcessDefinition).getProcessDefinition(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, randomProcessDefinition.getId())) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, - executionType = ExecutionType.REGRESSION, - description = "Verify Tenant User doesn't get process definitions for another network deployment using REST API") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void networkUserIsNotAbleToGetProcessDefinitionsForAnotherNetwork() throws Exception - { - RestProcessDefinitionModel randomProcessDefinitionTenant1 = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() - .getAllProcessDefinitions().getOneRandomEntry().onModel(); - RestProcessDefinitionModelsCollection processDefinitionsTenant2 = restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI() - .getAllProcessDefinitions(); - restClient.assertStatusCodeIs(HttpStatus.OK); - processDefinitionsTenant2.assertThat().entriesListDoesNotContain("id", randomProcessDefinitionTenant1.getId()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, - executionType = ExecutionType.REGRESSION, - description = "Verify network admin is able to get a process definition image using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION, TestGroup.NETWORKS}) - @Bug(id = "MNT-17243") - public void networkAdminGetProcessDefinitionImage() throws Exception - { - randomProcessDefinition = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry().onModel(); - restClient.withWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionImage() - .assertResponseContainsImage(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESS_DEFINITION }, - executionType = ExecutionType.REGRESSION, - description = "Verify network user is able to get a process definition image using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION, TestGroup.NETWORKS}) - @Bug(id = "MNT-17243") - public void networkUserGetProcessDefinitionImage() throws Exception - { - randomProcessDefinition = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() - .getAllProcessDefinitions().getOneRandomEntry().onModel(); - restClient.authenticateUser(tenantUser).withWorkflowAPI() - .usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionImage() - .assertResponseContainsImage(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, - executionType = ExecutionType.SANITY, description = "Verify Tenant Admin user gets process definitions for network deployments using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY, TestGroup.NETWORKS}) - public void networkAdminGetsProcessDefinitions() throws Exception - { - restClient.authenticateUser(adminTenantUser); - restClient.withWorkflowAPI().getAllProcessDefinitions().assertThat().entriesListIsNotEmpty(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, - executionType = ExecutionType.REGRESSION, - description = "Verify Tenant User doesn't get process definition image for another network deployment using REST API") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void networkUserIsNotAbleToGetProcessDefinitionImageForAnotherNetwork() throws Exception - { - RestProcessDefinitionModel randomProcessDefinition = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() - .getAllProcessDefinitions().getOneRandomEntry().onModel(); - restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI() - .usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionImage(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, randomProcessDefinition.getId())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, - executionType = ExecutionType.REGRESSION, - description = "Verify Tenant User gets a model of the start form type definition for network deployments using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void networkUserGetsStartFormModel() throws Exception - { - randomProcessDefinition = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() - .getAllProcessDefinitions().getOneRandomEntry().onModel(); - restClient.authenticateUser(tenantUser).withWorkflowAPI() - .usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionStartFormModel() - .assertThat().entriesListIsNotEmpty(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, - executionType = ExecutionType.REGRESSION, - description = "Verify Tenant User doesn't get a model of the start form type definition for another network deployment using REST API") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void networkUserIsNotAbleToGetStartFormModelForAnotherNetwork() throws Exception - { - RestProcessDefinitionModel randomProcessDefinition = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() - .getAllProcessDefinitions().getOneRandomEntry().onModel(); - restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI() - .usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionStartFormModel(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, randomProcessDefinition.getId())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, - executionType = ExecutionType.SANITY, - description = "Verify Tenant Admin gets a model of the start form type definition for network deployments using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY, TestGroup.NETWORKS }) - public void networkAdminGetsStartFormModel() throws Exception - { - restClient.authenticateUser(adminTenantUser); - randomProcessDefinition = restClient.withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry().onModel(); - restClient.withWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionStartFormModel().assertThat().entriesListIsNotEmpty(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify network user can start new process with processDefinitionKey from same network using REST API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS}) - public void networkUserCanStartNewProcessWithProcessDefinitionFromSameNetwork() throws JsonToModelConversionException, Exception - { - RestProcessDefinitionModel firstProcessDefTenant1 = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getAllProcessDefinitions().getEntries().get(0).onModel(); - - String processDefinitionKey = firstProcessDefTenant1.getKey(); - addedProcess = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess(processDefinitionKey, secondTenantUser, false, Priority.Normal); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - addedProcess.assertThat().field("processDefinitionId").is(firstProcessDefTenant1.getId()) - .and().field("startUserId").is(tenantUser.getEmailAddress().substring(0,2)+tenantUser.getEmailAddress().substring(2).toLowerCase()) - .and().field("processDefinitionKey").is(processDefinitionKey); - } - - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify network user cannot start new process with processDefinitionKey from another network using REST API and status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS}) - public void networkUserCannotStartNewProcessWithProcessDefinitionFromAnotherNetwork() throws JsonToModelConversionException, Exception - { - RestProcessDefinitionModel firstProcessDefTenant1 = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getAllProcessDefinitions().getEntries().get(0).onModel(); - - String processDefinitionKey = firstProcessDefTenant1.getId().substring(0,firstProcessDefTenant1.getId().indexOf(":")); - addedProcess = restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().addProcess(processDefinitionKey, differentNetworkTenantUser, false, Priority.Normal); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(String.format(RestErrorModel.NO_WORKFLOW_DEFINITION_FOUND, processDefinitionKey)) - .containsSummary(String.format(RestErrorModel.NO_WORKFLOW_DEFINITION_FOUND, processDefinitionKey)) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/WorkflowNetworkProcessesTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/WorkflowNetworkProcessesTests.java deleted file mode 100644 index 42233fc84..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/WorkflowNetworkProcessesTests.java +++ /dev/null @@ -1,540 +0,0 @@ -package org.alfresco.service.search.rest.workflow; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.service.search.rest.NetworkDataPrep; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestItemModel; -import org.alfresco.rest.model.RestItemModelsCollection; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.model.RestProcessModelsCollection; -import org.alfresco.rest.model.RestProcessVariableCollection; -import org.alfresco.rest.model.RestProcessVariableModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class WorkflowNetworkProcessesTests extends NetworkDataPrep -{ - private RestProcessModel processModel; - private RestProcessModelsCollection processes; - private RestItemModel processItem; - private RestItemModelsCollection processItems; - private RestProcessVariableModel variableModel, processVariable; - private RestProcessVariableCollection variables; - protected SiteModel siteModel; - protected FileModel document, document2; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - init(); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - document2 = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW, - TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Verify network user is able to start new process using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY, TestGroup.NETWORKS }) - public void networkUserStartsNewProcess() throws JsonToModelConversionException, Exception - { - processModel = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - processModel.assertThat().field("id").is(processModel.getId()) - .and().field("startUserId").is(processModel.getStartUserId()); - - processes = restClient.withWorkflowAPI().getProcesses(); - restClient.assertStatusCodeIs(HttpStatus.OK); - processes.assertThat().entriesListContains("id", processModel.getId()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES}, executionType = ExecutionType.REGRESSION, - description = "Verify that non network user cannot get process from a network") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - @Bug(id = "REPO-2092") - public void nonNetworkUserCannotAccessNetworkProcess() throws Exception - { - RestProcessModel networkProcess1 = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().addProcess("activitiReview", tenantUser, false, CMISUtil.Priority.High); - - restClient.authenticateUser(adminUserModel).withWorkflowAPI().usingProcess(networkProcess1).getProcess(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError().containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify that tenant user can get process from the same network") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void tenantUserCanGetProcessFromTheSameNetwork() throws Exception - { - RestProcessModel networkProcess1 = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().addProcess("activitiReview", tenantUser, false, CMISUtil.Priority.High); - - restClient.authenticateUser(tenantUser).withWorkflowAPI().usingProcess(networkProcess1).getProcess(); - restClient.assertStatusCodeIs(HttpStatus.OK); - networkProcess1.assertThat().field("id").is(networkProcess1.getId()) - .and().field("startUserId").is(networkProcess1.getStartUserId());; - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES}, executionType = ExecutionType.REGRESSION, - description = "Verify that tenant user cannot get process from another network") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - @Bug(id = "REPO-2092") - public void tenantUserCannotGetProcessFromAnotherNetwork() throws Exception - { - RestProcessModel networkProcess1 = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().addProcess("activitiReview", tenantUser, false, CMISUtil.Priority.High); - - restClient.authenticateUser(differentNetworkTenantUser).withWorkflowAPI().usingProcess(networkProcess1).getProcess(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError().containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin user can get process started by a network user") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void adminUserCanGetProcessFromANetwork() throws Exception - { - RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiReview", adminTenantUser, false, CMISUtil.Priority.High); - - restClient.authenticateUser(dataUser.getAdminUser()).withWorkflowAPI().usingProcess(networkProcess1).getProcess(); - restClient.assertStatusCodeIs(HttpStatus.OK); - networkProcess1.assertThat().field("processDefinitionId").contains(String.format("@%s%s", tenantUser.getDomain().toLowerCase(), "@activitiReview:1")) - .and().field("startUserId").is(tenantUser.getEmailAddress().substring(0, 2)+tenantUser.getEmailAddress().substring(2).toLowerCase()) - .and().field("startActivityId").is("start") - .and().field("startedAt").isNotEmpty() - .and().field("id").is(networkProcess1.getId()) - .and().field("completed").is(false) - .and().field("processDefinitionKey").is("activitiReview"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Add multiple process items using by admin in other network.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void addMultipleProcessItemsByAdminInOtherNetwork() throws Exception - { - processModel = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUser, false, Priority.Normal); - restClient.authenticateUser(secondAdminTenantUser); - - processItems = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItems(document, document2); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError() - .containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Add multiple process items using by the admin in same network.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void addMultipleProcessItemsByAdminSameNetwork() throws Exception - { - processModel = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); - - siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); - document = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - document2 = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - processItems = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().usingProcess(processModel).addProcessItems(document, document2); - - restClient.assertStatusCodeIs(HttpStatus.CREATED); - processItems.getEntries().get(0).onModel().assertThat() - .field("createdAt").isNotEmpty().and() - .field("size").is("19").and() - .field("createdBy").is(adminTenantUser.getUsername().toLowerCase()).and() - .field("modifiedAt").isNotEmpty().and() - .field("name").is(document.getName()).and() - .field("modifiedBy").is(adminTenantUser.getUsername().toLowerCase()).and() - .field("id").isNotEmpty().and() - .field("mimeType").is(document.getFileType().mimeType); - processItems.getEntries().get(1).onModel().assertThat() - .field("createdAt").isNotEmpty().and() - .field("size").is("19").and() - .field("createdBy").is(adminTenantUser.getUsername().toLowerCase()).and() - .field("modifiedAt").isNotEmpty().and() - .field("name").is(document2.getName()).and() - .field("modifiedBy").is(adminTenantUser.getUsername().toLowerCase()).and() - .field("id").isNotEmpty().and() - .field("mimeType").is(document2.getFileType().mimeType); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Add process item using by admin in other network.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void addProcessItemByAdminInOtherNetwork() throws Exception - { - processModel = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUser, false, Priority.Normal); - restClient.authenticateUser(secondAdminTenantUser); - processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Add process item using by the admin in same network.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void addProcessItemByAdminSameNetwork() throws Exception - { - processModel = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); - - siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); - document = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - processItem = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().usingProcess(processModel).addProcessItem(document); - - restClient.assertStatusCodeIs(HttpStatus.CREATED); - processItem.assertThat().field("createdAt").isNotEmpty().and().field("size").is("19").and().field("createdBy").is(adminTenantUser.getUsername().toLowerCase()).and() - .field("modifiedAt").isNotEmpty().and().field("name").is(document.getName()).and().field("modifiedBy").is(adminTenantUser.getUsername().toLowerCase()).and() - .field("id").isNotEmpty().and().field("mimeType").is(document.getFileType().mimeType); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Delete process item using by admin in other network.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void deleteProcessItemByAdminInOtherNetwork() throws Exception - { - processModel = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, CMISUtil.Priority.Normal); - processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().usingProcess(processModel) - .deleteProcessItem(processItem); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError() - .containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .containsErrorKey(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT) - .stackTraceIs(RestErrorModel.STACKTRACE); - - //restore document - document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Delete process item using by the admin in same network.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void deleteProcessItemByAdminSameNetwork() throws Exception - { - processModel = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, CMISUtil.Priority.Normal); - - processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(adminTenantUser).withWorkflowAPI().usingProcess(processModel) - .deleteProcessItem(processItem); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() - .assertThat().entriesListDoesNotContain("name", processItem.getName()); - - //restore document - document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Get process items using admin from different network") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void getProcessItemsReturnsOnlyItemsInsideNetwork() throws Exception - { - processModel = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, CMISUtil.Priority.Normal); - - siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); - document = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestProcessModel processModel2 = restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondAdminTenantUser, false, CMISUtil.Priority.Normal); - - SiteModel siteModel2 = dataSite.usingUser(secondAdminTenantUser).createPublicRandomSite(); - document2 = dataContent.usingUser(secondAdminTenantUser).usingSite(siteModel2).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().usingProcess(processModel2).addProcessItem(document2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - processItems = restClient.withWorkflowAPI().usingProcess(processModel2).getProcessItems(); - restClient.assertStatusCodeIs(HttpStatus.OK); - processItems.assertThat().entriesListDoesNotContain("name", document.getName()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Get process items using admin from different network") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void getProcessItemsUsingAdminUserFromDifferentNetwork() throws Exception - { - processModel = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, CMISUtil.Priority.Normal); - - siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); - document = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().usingProcess(processModel).getProcessItems(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Add process variable using by admin in other network.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void addProcessVariableByAdminInOtherNetwork() throws Exception - { - processModel = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); - - restClient.authenticateUser(secondAdminTenantUser); - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError() - .containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Add process variable using admin user from same network") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY, TestGroup.NETWORKS }) - public void addProcessVariableByAdmin() throws Exception - { - restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - - processVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - processVariable.assertThat().field("name").is(variableModel.getName()) - .and().field("type").is(variableModel.getType()) - .and().field("value").is(variableModel.getValue()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin from different network is not able to delete network process variables") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void deleteProcessVariablesWithAdminFromDifferentNetwork() throws Exception - { - RestProcessModel processModel = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() - .addProcess("activitiAdhoc", tenantUser, false, Priority.Normal); - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser).withWorkflowAPI() - .getProcesses().getProcessModelByProcessDefId(processModel.getId()); - restClient.withWorkflowAPI().usingProcess(networkProcess1).addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(adminUserModel).withWorkflowAPI().usingProcess(networkProcess1) - .deleteProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - restClient.assertLastError().containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .containsErrorKey(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT) - .stackTraceIs(RestErrorModel.STACKTRACE); - - restClient.authenticateUser(tenantUser).withWorkflowAPI().usingProcess(networkProcess1).getProcessVariables().assertThat() - .entriesListContains("name", variableModel.getName()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin from the same network is able to delete network process variables") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void deleteProcessVariablesWithAdminFromSameNetwork() throws Exception - { - RestProcessModel processModel = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() - .addProcess("activitiAdhoc", tenantUser, false, Priority.Normal); - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser).withWorkflowAPI() - .getProcesses().getProcessModelByProcessDefId(processModel.getId()); - restClient.withWorkflowAPI().usingProcess(networkProcess1).addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(adminTenantUser).withWorkflowAPI().usingProcess(networkProcess1) - .deleteProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withWorkflowAPI().usingProcess(networkProcess1).getProcessVariables() - .assertThat() - .entriesListDoesNotContain("name", variableModel.getName()); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin from different network is not able to retrieve network process variables") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void getProcessVariablesWithAdminFromDifferentNetwork() throws Exception - { - RestProcessModel networkProcess1 = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() - .addProcess("activitiReview", tenantUser, false, CMISUtil.Priority.High); - - variables = restClient.authenticateUser(adminUserModel).withWorkflowAPI().usingProcess(networkProcess1).getProcessVariables(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT); - } - - @TestRail(section = {TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin from the same network is able to retrieve network process variables") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void getProcessVariablesWithAdminFromSameNetwork() throws Exception - { - RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser).withWorkflowAPI() - .addProcess("activitiReview", tenantUser, false, CMISUtil.Priority.High); - - variables = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().usingProcess(networkProcess1).getProcessVariables(); - restClient.assertStatusCodeIs(HttpStatus.OK); - variables.assertThat().entriesListIsNotEmpty(); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify admin gets all processes from same network") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void getProcessFromSameNetworkUsingAdmin() throws Exception - { - RestProcessModel process = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); - - RestProcessModelsCollection tenantProcesses = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getProcesses(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - tenantProcesses.assertThat().entriesListContains("id", process.getId()); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Get process items using admin from same network") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY, TestGroup.NETWORKS }) - public void getProcessItemsUsingAdminUserFromSameNetwork() throws Exception - { - processModel = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); - - siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); - document = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); - - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - processItems = restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems(); - restClient.assertStatusCodeIs(HttpStatus.OK); - processItems.assertThat().entriesListContains("name", document.getName()); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Add multiple process variables using admin user from same network") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY, TestGroup.NETWORKS }) - public void addMultipleProcessVariablesByAdminSameNetwork() throws Exception - { - restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processVariable = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - - variables = restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariables(variableModel, processVariable); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - variables.assertThat().entriesListContains("name", variableModel.getName()) - .assertThat().entriesListContains("name", processVariable.getName()); - - variables.getEntries().get(0).onModel().assertThat() - .field("name").is(variableModel.getName()).and() - .field("value").is(variableModel.getValue()).and() - .field("type").is(variableModel.getType()); - variables.getEntries().get(1).onModel().assertThat() - .field("name").is(processVariable.getName()).and() - .field("value").is(processVariable.getValue()).and() - .field("type").is(processVariable.getType()); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Add process variables using admin user from same network") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY, TestGroup.NETWORKS }) - public void addProcessVariableByAdminSameNetwork() throws Exception - { - restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - - processVariable = restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - processVariable.assertThat().field("name").is(variableModel.getName()) - .and().field("type").is(variableModel.getType()) - .and().field("value").is(variableModel.getValue()); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify any user cannot get processes from same network") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void getProcessFromSameNetworkUsingAnyUser() throws Exception - { - restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); - - restClient.authenticateUser(tenantUser).withWorkflowAPI().getProcesses(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify getProcessTasks using admin from different network with REST API and status code is FORBIDDEN (403)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void getProcessTasksWithAdminFromDifferentNetwork() throws Exception - { - siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); - dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - RestProcessModel processModel = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, CMISUtil.Priority.Normal); - - restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI() - .usingProcess(processModel).getProcessTasks().assertThat().entriesListIsEmpty(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify getProcessTasks using admin from same network with REST API and status code is OK") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void getProcessTasksWithAdminFromSameNetwork() throws Exception - { - siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); - dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - - RestProcessModel processModel = restClient.authenticateUser(secondTenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, CMISUtil.Priority.Normal); - - restClient.authenticateUser(adminTenantUser).withWorkflowAPI() - .usingProcess(processModel).getProcessTasks().assertThat().entriesListIsNotEmpty(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW,TestGroup.PROCESSES}, executionType = ExecutionType.REGRESSION, - description = "Add multiple process variables using by Admin in other network.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void addMultipleProcessVariablesByAdminInOtherNetwork() throws Exception - { - - siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); - dataWorkflow.usingUser(tenantUser).usingSite(siteModel).usingResource(document) - .createNewTaskAndAssignTo(secondTenantUser); - - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processVariable = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); - restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().usingProcess(processModel) - .addProcessVariables(variableModel, processVariable); - - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError() - .containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .containsErrorKey(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES}, executionType = ExecutionType.REGRESSION, - description = "Add process variables using by Admin in other network.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void addProcessVariablesByAdminInOtherNetwork() throws Exception - { - siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); - dataWorkflow.usingUser(tenantUser).usingSite(siteModel).usingResource(document) - .createNewTaskAndAssignTo(secondTenantUser); - - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); - processVariable = restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().usingProcess(processModel) - .addProcessVariable(variableModel); - - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError() - .containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .containsErrorKey(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/WorkflowNetworkTasksTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/WorkflowNetworkTasksTests.java deleted file mode 100644 index 19be57be2..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/WorkflowNetworkTasksTests.java +++ /dev/null @@ -1,578 +0,0 @@ -package org.alfresco.service.search.rest.workflow; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.service.search.rest.NetworkDataPrep; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestFormModelsCollection; -import org.alfresco.rest.model.RestItemModel; -import org.alfresco.rest.model.RestItemModelsCollection; -import org.alfresco.rest.model.RestProcessDefinitionModel; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.model.RestTaskModel; -import org.alfresco.rest.model.RestTaskModelsCollection; -import org.alfresco.rest.model.RestVariableModel; -import org.alfresco.rest.model.RestVariableModelsCollection; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TaskModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class WorkflowNetworkTasksTests extends NetworkDataPrep -{ - private TaskModel taskModel; - private RestFormModelsCollection returnedCollection; - private RestTaskModel restTaskModel; - private RestTaskModelsCollection taskModels; - private RestVariableModel variableModel, variableModel1; - private RestVariableModelsCollection restVariableCollection; - private RestProcessModel restProcessModel; - private RestItemModelsCollection itemModels; - private RestItemModel restTaskItem; - protected SiteModel siteModel; - protected FileModel document, document2; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - init(); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - document2 = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, - executionType = ExecutionType.REGRESSION, description = "Verify network admin user gets all task form models inside his network with Rest API and response is successful (200)") - public void networkAdminGetsTaskFormModels() throws Exception - { - RestProcessModel networkProcess = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() - .addProcess("activitiReview", tenantUser, false, CMISUtil.Priority.High); - RestTaskModel networkTask = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() - .usingProcess(networkProcess).getProcessTasks().getOneRandomEntry().onModel(); - - restClient.authenticateUser(adminUserModel).withWorkflowAPI().usingTask(networkTask).getTaskFormModel(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - - returnedCollection = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().usingTask(networkTask).getTaskFormModel(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat().entriesListIsNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Add multiple task item using by admin in other network.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void addMultipleTaskItemByAdminInOtherNetwork() throws Exception - { - - SiteModel siteModel1 = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); - document = dataContent.usingUser(adminTenantUser).usingSite(siteModel1).createContent(DocumentType.XML); - document2 = dataContent.usingSite(siteModel1).createContent(DocumentType.XML); - - RestProcessModel addedProcess = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); - RestTaskModel addedTask = restClient.withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess); - restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().usingTask(addedTask).addTaskItems(document, document2); - - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .stackTraceIs(RestErrorModel.STACKTRACE);; - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Add task item using by admin in other network.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void addTaskItemByAdminInOtherNetwork() throws Exception - { - document = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(DocumentType.XML); - RestProcessModel addedProcess = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); - RestTaskModel addedTask = restClient.withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess); - restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().usingTask(addedTask).addTaskItem(document); - - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Bug(id = "REPO-1980") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify tenant admin can update only task from its network and response is 200") - public void adminTenantCanUpdateOnlyTaskInItsNetwork() throws Exception - { - FileModel fileModel1 = dataContent.usingUser(tenantUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - RestProcessDefinitionModel def1 = restClient.authenticateUser(tenantUser).withWorkflowAPI().getAllProcessDefinitions().getEntries().get(0).onModel(); - TaskModel taskModel1 = dataWorkflow.usingUser(tenantUser).usingSite(siteModel).usingResource(fileModel1) - .createTaskWithProcessDefAndAssignTo(def1.getId(), secondTenantUser); - - SiteModel siteModel2 = dataSite.usingUser(differentNetworkTenantUser).createPublicRandomSite(); - FileModel fileModel2 = dataContent.usingUser(differentNetworkTenantUser).usingSite(siteModel2).createContent(DocumentType.TEXT_PLAIN); - RestProcessDefinitionModel def2 = restClient.authenticateUser(differentNetworkTenantUser).withWorkflowAPI().getAllProcessDefinitions().getEntries().get(0).onModel(); - TaskModel taskModel2 = dataWorkflow.usingUser(differentNetworkTenantUser).usingSite(siteModel2).usingResource(fileModel2) - .createTaskWithProcessDefAndAssignTo(def2.getId(), secondAdminTenantUser); - - restTaskModel = restClient.authenticateUser(secondAdminTenantUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel2).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel2.getId()) - .and().field("state").is("completed"); - - restTaskModel = restClient.authenticateUser(secondAdminTenantUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel1).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin from the same network is able to add multiple task variables") - public void addMultipleTaskVariablesByTenantAdmin() throws Exception - { - RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser).withWorkflowAPI() - .addProcess("activitiReview", tenantUser, false, CMISUtil.Priority.High); - RestTaskModel task = restClient.authenticateUser(adminTenantUser) - .withWorkflowAPI().usingProcess(networkProcess1).getProcessTasks().getOneRandomEntry(); - restClient.authenticateUser(adminTenantUser); - - variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - variableModel1 = RestVariableModel.getRandomTaskVariableModel("global", "d:text"); - - restVariableCollection = restClient.withWorkflowAPI().usingTask(task.onModel()) - .addTaskVariables(variableModel, variableModel1); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restVariableCollection.getEntries().get(0).onModel().assertThat() - .field("scope").is(variableModel.getScope()) - .and().field("name").is(variableModel.getName()) - .and().field("value").is(variableModel.getValue()) - .and().field("type").is(variableModel.getType()); - - restVariableCollection.getEntries().get(1).onModel().assertThat() - .field("scope").is(variableModel1.getScope()) - .and().field("name").is(variableModel1.getName()) - .and().field("value").is(variableModel1.getValue()) - .and().field("type").is(variableModel1.getType()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin from the same network is able to add and remove task variables") - public void addAndRemoveTaskVariablesByTenantAdmin() throws Exception - { - RestProcessModel networkProcess1 = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() - .addProcess("activitiReview", adminTenantUser, false, CMISUtil.Priority.High); - RestTaskModel task = restClient.authenticateUser(adminTenantUser) - .withWorkflowAPI().usingProcess(networkProcess1).getProcessTasks().getOneRandomEntry(); - restClient.authenticateUser(adminTenantUser); - RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - variableModel = restClient.withWorkflowAPI() - .usingTask(task.onModel()) - .addTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - variableModel.assertThat() - .field("scope").is(variableModel.getScope()) - .and().field("name").is(variableModel.getName()) - .and().field("value").is(variableModel.getValue()) - .and().field("type").is(variableModel.getType()); - - restClient.withWorkflowAPI().usingTask(task.onModel()).deleteTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withWorkflowAPI().usingTask(task.onModel()).getTaskVariables() - .assertThat().entriesListDoesNotContain("name", variableModel.getName()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin from the other network is not able to remove task variables") - public void addTaskVariablesByTenantAdminOtherNetwork() throws Exception - { - RestProcessModel networkProcess1 = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() - .addProcess("activitiReview", adminTenantUser, false, CMISUtil.Priority.High); - RestTaskModel task = restClient.authenticateUser(adminTenantUser) - .withWorkflowAPI().usingProcess(networkProcess1).getProcessTasks().getOneRandomEntry(); - restClient.authenticateUser(adminTenantUser); - RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - restClient.withWorkflowAPI() - .usingTask(task.onModel()) - .addTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().usingTask(task.onModel()).deleteTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin from another network is not able to add task variables") - public void addTaskVariablesByTenantFromAnotherNetwork() throws Exception - { - RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser).withWorkflowAPI() - .addProcess("activitiReview", tenantUser, false, CMISUtil.Priority.High); - RestTaskModel task = restClient.authenticateUser(adminTenantUser) - .withWorkflowAPI().usingProcess(networkProcess1).getProcessTasks().getOneRandomEntry(); - RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - variableModel = restClient.authenticateUser(secondTenantUser).withWorkflowAPI() - .usingTask(task.onModel()) - .addTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin from another network is not able to add multiple task variables") - public void addMultipleTaskVariablesByTenantFromAnotherNetwork() throws Exception - { - RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser).withWorkflowAPI() - .addProcess("activitiReview", tenantUser, false, CMISUtil.Priority.High); - RestTaskModel task = restClient.authenticateUser(adminTenantUser) - .withWorkflowAPI().usingProcess(networkProcess1).getProcessTasks().getOneRandomEntry(); - restClient.authenticateUser(adminTenantUser); - - variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - variableModel1 = RestVariableModel.getRandomTaskVariableModel("global", "d:text"); - restVariableCollection = restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI() - .usingTask(task.onModel()) - .addTaskVariables(variableModel,variableModel1); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin from another network is not able to update task variables") - public void updateTaskVariablesByTenantFromAnotherNetwork() throws Exception - { - RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser).withWorkflowAPI() - .addProcess("activitiReview", tenantUser, false, CMISUtil.Priority.High); - RestTaskModel task = restClient.authenticateUser(adminTenantUser) - .withWorkflowAPI().usingProcess(networkProcess1).getProcessTasks().getOneRandomEntry(); - restClient.authenticateUser(adminTenantUser); - RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - variableModel = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().usingTask(task.onModel()) - .addTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().usingTask(task.onModel()) - .updateTaskVariable(variableModel); - - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, - executionType = ExecutionType.REGRESSION, description = "Check that for admin network gets tasks only from its network.") - public void adminTenantGetsTasksOnlyFromItsNetwork() throws Exception - { - RestProcessModel processOnTenant1 = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Low); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestProcessModel processOnTenant2 = restClient.authenticateUser(differentNetworkTenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondAdminTenantUser, false, Priority.Normal); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestTaskModelsCollection tenantTasks1 = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - tenantTasks1.assertThat().entriesListIsNotEmpty() - .and().entriesListIsNotEmpty() - .and().entriesListContains("assignee", String.format("sTenant@%s", secondTenantUser.getDomain().toLowerCase())) - .and().entriesListContains("processId", processOnTenant1.getId()) - .and().entriesListDoesNotContain("assignee", String.format("admin@%s", secondAdminTenantUser.getDomain().toLowerCase())) - .and().entriesListDoesNotContain("processId", processOnTenant2.getId()); - - RestTaskModelsCollection tenantTasks2 = restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - tenantTasks2.assertThat().entriesListIsNotEmpty() - .and().entriesListIsNotEmpty() - .and().entriesListContains("assignee", String.format("admin@%s", secondAdminTenantUser.getDomain().toLowerCase())) - .and().entriesListContains("processId", processOnTenant2.getId()) - .and().entriesListDoesNotContain("assignee", String.format("sTenant@%s", secondTenantUser.getDomain().toLowerCase())) - .and().entriesListDoesNotContain("processId", processOnTenant1.getId()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check that for network enabled only that network tasks are returned.") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) - public void networkEnabledTasksReturned() throws Exception - { - restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); - - taskModels = restClient.authenticateUser(secondTenantUser).withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - taskModels.assertThat().entriesListIsNotEmpty().and().entriesListContains("assignee", - String.format("sTenant@%s", secondTenantUser.getDomain().toLowerCase())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify gets task items call with admin from different network") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void getTaskItemsByAdminFromAnotherNetwork() throws Exception - { - - siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); - document = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(DocumentType.XML); - restProcessModel = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); - restTaskModel = restClient.withWorkflowAPI().getTasks().getTaskModelByProcess(restProcessModel); - restClient.withWorkflowAPI().usingTask(restTaskModel).addTaskItem(document); - - restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().usingTask(restTaskModel).getTaskItems(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify gets task items call returns only task items inside network") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void getTaskItemsReturnsOnlyItemsFromThatNetwork() throws Exception - { - SiteModel siteModel1 = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); - FileModel fileModel1 = dataContent.usingUser(adminTenantUser).usingSite(siteModel1).createContent(DocumentType.XML); - - RestProcessModel addedProcess1 = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUser, false, Priority.Normal); - RestTaskModel addedTask1 = restClient.withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess1); - RestItemModel taskItem1 = restClient.withWorkflowAPI().usingTask(addedTask1).addTaskItem(fileModel1); - - SiteModel siteModel2 = dataSite.usingUser(secondAdminTenantUser).createPublicRandomSite(); - FileModel fileModel2 = dataContent.usingUser(secondAdminTenantUser).usingSite(siteModel2).createContent(DocumentType.XML); - - RestProcessModel addedProcess2 = restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().addProcess("activitiAdhoc", differentNetworkTenantUser, false, Priority.Normal); - RestTaskModel addedTask2 = restClient.withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess2); - RestItemModel taskItem2 = restClient.withWorkflowAPI().usingTask(addedTask2).addTaskItem(fileModel2); - - itemModels = restClient.withWorkflowAPI().usingTask(addedTask2).getTaskItems(); - restClient.assertStatusCodeIs(HttpStatus.OK); - itemModels.assertThat() - .entriesListIsNotEmpty().and() - .entriesListContains("id", taskItem2.getId()).and() - .entriesListContains("name", fileModel2.getName()).and() - .entriesListDoesNotContain("id", taskItem1.getId()).and() - .entriesListDoesNotContain("name", fileModel1.getName()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, - executionType = ExecutionType.REGRESSION, description = "Check that for admin network gets task only from its network.") - public void adminTenantGetsTaskOnlyFromItsNetwork() throws Exception - { - RestProcessModel processOnTenant1 = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Low); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestProcessModel processOnTenant2 = restClient.authenticateUser(differentNetworkTenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondAdminTenantUser, false, Priority.Normal); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestTaskModelsCollection tenantTasks2 = restClient.authenticateUser(differentNetworkTenantUser).withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - tenantTasks2.assertThat().entriesListIsNotEmpty() - .and().entriesListCountIs(1) - .and().entriesListContains("assignee", String.format("admin@%s", secondAdminTenantUser.getDomain().toLowerCase())) - .and().entriesListContains("processId", processOnTenant2.getId()) - .and().entriesListDoesNotContain("assignee", String.format("admin@%s", secondTenantUser.getDomain().toLowerCase())) - .and().entriesListDoesNotContain("processId", processOnTenant1.getId()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify that in a network only tasks inside network are returned.") - @Test(groups = {TestGroup.NETWORKS,TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void tasksInsideNetworkReturned() throws Exception - { - - RestProcessModel addedProcess = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, - Priority.Normal); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - taskModel = restClient.withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess); - restTaskModel = restClient.authenticateUser(secondTenantUser).withWorkflowAPI().usingTask(taskModel).getTask(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("assignee").is(String.format("sTenant@%s", secondTenantUser.getDomain().toLowerCase())).and() - .field("processId").is(addedProcess.getId()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, - description = "Verify that user that started the process gets task items") - @Test(groups = { TestGroup.NETWORKS,TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY}) - public void getTaskItemsByAdminInSameNetwork() throws Exception - { - - siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); - document = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(DocumentType.XML); - RestProcessModel addedProcess = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); - RestTaskModel addedTask = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess); - restTaskItem = restClient.withWorkflowAPI().usingTask(addedTask).addTaskItem(document); - - itemModels = restClient.withWorkflowAPI().usingTask(addedTask).getTaskItems(); - restClient.assertStatusCodeIs(HttpStatus.OK); - itemModels.assertThat() - .entriesListIsNotEmpty().and() - .entriesListContains("id", restTaskItem.getId()).and() - .entriesListContains("name", document.getName()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin from the same network is able to retrieve network task variables") - public void getTaskVariablesByTenantAdmin() throws Exception - { - RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser).withWorkflowAPI() - .addProcess("activitiReview", tenantUser, false, CMISUtil.Priority.High); - RestTaskModel task = restClient.authenticateUser(adminTenantUser) - .withWorkflowAPI().usingProcess(networkProcess1).getProcessTasks().getOneRandomEntry(); - - restVariableCollection = restClient.withWorkflowAPI().usingTask(task.onModel()).getTaskVariables(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restVariableCollection.assertThat().entriesListIsNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin from another network is not able to retrieve network task variables") - public void getTaskVariablesByTenantFromAnotherNetwork() throws Exception - { - RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser).withWorkflowAPI() - .addProcess("activitiReview", tenantUser, false, CMISUtil.Priority.High); - RestTaskModel task = restClient.authenticateUser(adminTenantUser) - .withWorkflowAPI().usingProcess(networkProcess1).getProcessTasks().getOneRandomEntry(); - - restVariableCollection = restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().usingTask(task.onModel()).getTaskVariables(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } - - @Test(groups = { TestGroup.NETWORKS,TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Add task item using admin user from same network") - public void addMultipleTaskItemByAdminSameNetwork() throws Exception - { - - siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); - document = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(DocumentType.XML); - document2 = dataContent.usingUser(adminTenantUser).usingUser(adminTenantUser).usingSite(siteModel).createContent(DocumentType.XML); - RestProcessModel addedProcess = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); - RestTaskModel addedTask = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess); - - itemModels = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().usingTask(addedTask) - .addTaskItems(document2,document); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - itemModels.getEntries().get(0).onModel() - .assertThat().field("createdAt").is(itemModels.getEntries().get(0).onModel().getCreatedAt()) - .assertThat().field("size").is(itemModels.getEntries().get(0).onModel().getSize()) - .assertThat().field("createdBy").is(itemModels.getEntries().get(0).onModel().getCreatedBy()) - .assertThat().field("modifiedAt").is(itemModels.getEntries().get(0).onModel().getModifiedAt()) - .assertThat().field("name").is(itemModels.getEntries().get(0).onModel().getName()) - .assertThat().field("modifiedBy").is(itemModels.getEntries().get(0).onModel().getModifiedBy()) - .assertThat().field("id").is(itemModels.getEntries().get(0).onModel().getId()) - .assertThat().field("mimeType").is(itemModels.getEntries().get(0).onModel().getMimeType()); - - itemModels.getEntries().get(1).onModel() - .assertThat().field("createdAt").is(itemModels.getEntries().get(1).onModel().getCreatedAt()) - .assertThat().field("size").is(itemModels.getEntries().get(1).onModel().getSize()) - .assertThat().field("createdBy").is(itemModels.getEntries().get(1).onModel().getCreatedBy()) - .assertThat().field("modifiedAt").is(itemModels.getEntries().get(1).onModel().getModifiedAt()) - .assertThat().field("name").is(itemModels.getEntries().get(1).onModel().getName()) - .assertThat().field("modifiedBy").is(itemModels.getEntries().get(1).onModel().getModifiedBy()) - .assertThat().field("id").is(itemModels.getEntries().get(1).onModel().getId()); - } - - @Test(groups = { TestGroup.NETWORKS,TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Add task item using admin user from same network") - public void addTaskItemByAdminSameNetwork() throws Exception - { - siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); - document = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(DocumentType.XML); - RestProcessModel addedProcess = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); - RestTaskModel addedTask = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess); - - restTaskItem = restClient.withWorkflowAPI().usingTask(addedTask).addTaskItem(document); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restTaskItem.assertThat().field("createdAt").is(restTaskItem.getCreatedAt()) - .and().field("size").is(restTaskItem.getSize()) - .and().field("createdBy").is(restTaskItem.getCreatedBy()) - .and().field("modifiedAt").is(restTaskItem.getModifiedAt()) - .and().field("name").is(restTaskItem.getName()) - .and().field("modifiedBy").is(restTaskItem.getModifiedBy()) - .and().field("id").is(restTaskItem.getId()) - .and().field("mimeType").is(restTaskItem.getMimeType()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS}) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Update existing task variable by admin in the same network") - public void updateTaskVariableByAdminInSameNetwork() throws Exception - { - RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser).withWorkflowAPI() - .addProcess("activitiReview", tenantUser, false, CMISUtil.Priority.High); - RestTaskModel task = restClient.authenticateUser(adminTenantUser) - .withWorkflowAPI().usingProcess(networkProcess1).getProcessTasks().getOneRandomEntry(); - - variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - variableModel1 = restClient.withWorkflowAPI().usingTask(task.onModel()) - .updateTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - variableModel1.assertThat().field("scope").is(variableModel1.getScope()) - .and().field("name").is(variableModel1.getName()) - .and().field("type").is(variableModel1.getType()) - .and().field("value").is(variableModel1.getValue()); - - variableModel.setValue("updatedValue"); - variableModel1 = restClient.withWorkflowAPI().usingTask(task.onModel()).updateTaskVariable(variableModel).and().field("value").is("updatedValue"); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify tenant user that created the task can update task only in its network and response is 200, for other networks is 403") - public void ownerTenantCanUpdatedTaskOnlyInItsNetwork() throws Exception - { - - - SiteModel siteModel1 = dataSite.usingUser(tenantUser).createPublicRandomSite(); - FileModel fileModel1 = dataContent.usingUser(tenantUser).usingSite(siteModel1).createContent(DocumentType.TEXT_PLAIN); - RestProcessDefinitionModel def1 = restClient.authenticateUser(tenantUser).withWorkflowAPI().getAllProcessDefinitions().getEntries().get(0).onModel(); - TaskModel taskModel1 = dataWorkflow.usingUser(tenantUser).usingSite(siteModel1).usingResource(fileModel1) - .createTaskWithProcessDefAndAssignTo(def1.getId(), secondTenantUser); - - SiteModel siteModel2 = dataSite.usingUser(differentNetworkTenantUser).createPublicRandomSite(); - FileModel fileModel2 = dataContent.usingUser(differentNetworkTenantUser).usingSite(siteModel2).createContent(DocumentType.TEXT_PLAIN); - RestProcessDefinitionModel def2 = restClient.authenticateUser(differentNetworkTenantUser).withWorkflowAPI().getAllProcessDefinitions().getEntries().get(0).onModel(); - TaskModel taskModel2 = dataWorkflow.usingUser(differentNetworkTenantUser).usingSite(siteModel2).usingResource(fileModel2) - .createTaskWithProcessDefAndAssignTo(def2.getId(), secondAdminTenantUser); - - restTaskModel = restClient.authenticateUser(differentNetworkTenantUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel2).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel2.getId()) - .and().field("state").is("completed"); - - restTaskModel = restClient.authenticateUser(differentNetworkTenantUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel1).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/DeleteDeploymentTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/DeleteDeploymentTests.java deleted file mode 100644 index 330a8bdd2..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/DeleteDeploymentTests.java +++ /dev/null @@ -1,144 +0,0 @@ -package org.alfresco.service.search.rest.workflow.deployments; - -import java.util.List; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.model.RestDeploymentModel; -import org.alfresco.rest.model.RestDeploymentModelsCollection; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestProcessDefinitionModel; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.model.RestTaskModel; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Tests for REST API call DELETE "/deployments/{deploymentId}" - * Class has priority 100 in order to be executed last in the list of tests classes - * - * @author Cristina Axinte - * - */ -public class DeleteDeploymentTests extends RestTest -{ - private UserModel adminUser, userModel; - private RestDeploymentModel deployment; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userModel = dataUser.createRandomTestUser(); - } - - @Bug(id = "REPO-1930") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, - executionType = ExecutionType.SANITY, description = "Verify admin user deletes a specific deployment using REST API and status code is successful (204)") - @Test(groups = { TestGroup.REST_API, TestGroup.DEPLOYMENTS, TestGroup.SANITY, TestGroup.WORKFLOW }, priority = 100) - public void adminDeletesDeploymentWithSuccess() throws Exception - { - dataContent.assertExtensionAmpExists("alfresco-workflow-extension"); - // The deployment with name "customWorkflowExtentionForRest.bpmn" is created by Workflow Extention Point - RestDeploymentModelsCollection allDeployments = restClient.authenticateUser(adminUser).withWorkflowAPI().getDeployments(); - allDeployments.assertThat().entriesListContains("name", "customWorkflowExtentionForRest.bpmn"); - deployment = allDeployments.getDeploymentByName("customWorkflowExtentionForRest.bpmn"); - - RestProcessDefinitionModel processDefinitionAssociated = - restClient.withWorkflowAPI().getAllProcessDefinitions().getProcessDefinitionById(deployment.getId()); - - RestProcessModel addedProcess = - restClient.withWorkflowAPI().addProcess(processDefinitionAssociated.getName(), adminUser, false, CMISUtil.Priority.Normal); - - List processTasks = - restClient.withWorkflowAPI().usingProcess(addedProcess).getProcessTasks().getEntries(); - - restClient.withWorkflowAPI().usingDeployment(deployment).deleteDeployment(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - //check get deployment returns http status Not Found after deleting the deployment - restClient.withWorkflowAPI().usingDeployment(deployment).getDeployment(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, deployment.getId())); - - //check that process definitions contained by deployment are deleted - restClient.withWorkflowAPI().usingProcessDefinitions(processDefinitionAssociated).getProcessDefinition(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, processDefinitionAssociated.getId())); - - //check that history information associated with the deployment is deleted - restClient.withWorkflowAPI().usingProcess(addedProcess).getProcess(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, addedProcess.getId())); - - for (RestTaskModel processTask: processTasks) - { - restClient.withWorkflowAPI().usingTask(processTask).getTask(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, processTask.getId())); - } - - //check getProcessDefinitionStartFormModel after deletion of process definition - restClient.withWorkflowAPI().usingProcessDefinitions(processDefinitionAssociated).getProcessDefinitionStartFormModel(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, processDefinitionAssociated.getId())); - - //check getProcessDefinitionImage after deletion of process definition - restClient.withWorkflowAPI().usingProcessDefinitions(processDefinitionAssociated).getProcessDefinitionImage(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, processDefinitionAssociated.getId())); - - //delete deployment twice - restClient.withWorkflowAPI().usingDeployment(deployment).deleteDeployment(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, deployment.getId())) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Bug(id = "REPO-1930") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, - executionType = ExecutionType.SANITY, description = "Verify admin user cannot delete an inexistent deployment using REST API and status code is successful (204)") - @Test(groups = { TestGroup.REST_API, TestGroup.DEPLOYMENTS, TestGroup.SANITY, TestGroup.WORKFLOW }, priority = 100) - public void adminCannotDeleteInexistentDeployment() throws Exception - { - deployment = restClient.authenticateUser(adminUser).withWorkflowAPI().getDeployments().getOneRandomEntry().onModel(); - deployment.setId(String.valueOf(1000)); - - restClient.withWorkflowAPI().usingDeployment(deployment).deleteDeployment(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "1000")); - } - - @Bug(id = "REPO-1930") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, - description = "Verify deleteDeployment is unsupported for empty deployment id with REST API and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION, TestGroup.WORKFLOW }) - public void deleteDeploymentIsUnsupportedForEmptyId() throws Exception - { - deployment = restClient.authenticateUser(adminUser).withWorkflowAPI().getDeployments().getOneRandomEntry().onModel(); - deployment.setId(""); - restClient.withWorkflowAPI().usingDeployment(deployment).deleteDeployment(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); - } - - @Bug(id = "REPO-1930") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, - description = "Verify deleteDeployment is forbidden using non admin user or different user than creator with REST API and status code is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION, TestGroup.WORKFLOW }) - public void deleteDeploymentUsingNonAdminUser() throws Exception - { - deployment = restClient.authenticateUser(adminUser).withWorkflowAPI().getDeployments().getOneRandomEntry().onModel(); - restClient.authenticateUser(userModel).withWorkflowAPI().usingDeployment(deployment).deleteDeployment(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentCoreTests.java deleted file mode 100644 index 42842959a..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentCoreTests.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.alfresco.service.search.rest.workflow.deployments; - -import org.alfresco.rest.model.RestDeploymentModel; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.service.search.rest.RestTest; -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; - -/** - * Created by Claudia Agache on 12/7/2016. - */ -public class GetDeploymentCoreTests extends RestTest -{ - private UserModel adminUser; - private RestDeploymentModel expectedDeployment; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, - executionType = ExecutionType.REGRESSION, - description = "Verify if get deployment request returns status code 404 when invalid deploymentId is used.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION }) - public void getNonNetworkDeploymentUsingInvalidDeploymentId() throws Exception - { - expectedDeployment = restClient.authenticateUser(adminUser).withWorkflowAPI().getDeployments().getOneRandomEntry().onModel(); - expectedDeployment.setId("invalidId"); - - restClient.withWorkflowAPI().usingDeployment(expectedDeployment).getDeployment(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidId")); - } - -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentFullTests.java deleted file mode 100644 index 9dcae1999..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentFullTests.java +++ /dev/null @@ -1,57 +0,0 @@ -package org.alfresco.service.search.rest.workflow.deployments; - -import org.alfresco.rest.core.RestRequest; -import org.alfresco.rest.model.RestDeploymentModel; -import org.alfresco.rest.model.RestDeploymentModelsCollection; -import org.alfresco.service.search.rest.RestTest; -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; - -/** - * Created by Claudia Agache on 1/31/2017. - */ -public class GetDeploymentFullTests extends RestTest -{ - private UserModel adminUser; - private RestDeploymentModel expectedDeployment, actualDeployment; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, - executionType = ExecutionType.REGRESSION, - description = "Verify if get deployment request returns all deployments if empty deploymentId is used.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION }) - public void getNonNetworkDeploymentUsingEmptyDeploymentId() throws Exception - { - restClient.authenticateUser(adminUser).withWorkflowAPI(); - RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "deployments/{deploymentId}", ""); - RestDeploymentModelsCollection deployments = restClient.processModels(RestDeploymentModelsCollection.class, request); - restClient.assertStatusCodeIs(HttpStatus.OK); - deployments.assertThat().entriesListIsNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, - description = "Verify Admin user gets non-network deployments with properties parameter applied using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION}) - public void getNonNetworkDeploymentsWithValidProperties() throws Exception - { - expectedDeployment = restClient.authenticateUser(adminUser).withWorkflowAPI().getDeployments().getOneRandomEntry().onModel(); - actualDeployment = restClient.withParams("properties=id,name").withWorkflowAPI().usingDeployment(expectedDeployment).getDeployment(); - restClient.assertStatusCodeIs(HttpStatus.OK); - actualDeployment.assertThat() - .fieldsCount().is(2).and() - .field("id").is(expectedDeployment.getId()).and() - .field("deployedAt").isNull().and() - .field("name").is(expectedDeployment.getName()); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentSanityTests.java deleted file mode 100644 index 014f692fb..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentSanityTests.java +++ /dev/null @@ -1,57 +0,0 @@ -package org.alfresco.service.search.rest.workflow.deployments; - -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestDeploymentModel; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.service.search.rest.RestTest; -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; - -/** - * Tests for REST API call GET "/deployments/{deploymentId}" - * - * @author Cristina Axinte - * - */ -public class GetDeploymentSanityTests extends RestTest -{ - private UserModel adminUser; - private UserModel anotherUser; - private RestDeploymentModel expectedDeployment, actualDeployment; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - anotherUser = dataUser.createRandomTestUser(); - - expectedDeployment = restClient.authenticateUser(adminUser).withWorkflowAPI().getDeployments().getOneRandomEntry().onModel(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, - executionType = ExecutionType.SANITY, description = "Verify admin user gets a non-network deployment using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.SANITY }) - public void adminGetsNonNetworkDeploymentWithSuccess() throws JsonToModelConversionException, Exception - { - actualDeployment = restClient.authenticateUser(adminUser).withWorkflowAPI().usingDeployment(expectedDeployment).getDeployment(); - restClient.assertStatusCodeIs(HttpStatus.OK); - actualDeployment.assertThat().field("deployedAt").isNotEmpty() - .and().field("name").is(expectedDeployment.getName()) - .and().field("id").is(expectedDeployment.getId()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, - executionType = ExecutionType.SANITY, description = "Verify non admin user is forbidden to get a non-network deployment using REST API (403)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.SANITY }) - public void nonAdminIsForbiddenToGetNonNetworkDeployment() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(anotherUser).withWorkflowAPI().usingDeployment(expectedDeployment).getDeployment(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentsCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentsCoreTests.java deleted file mode 100644 index 161d277d0..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentsCoreTests.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.alfresco.service.search.rest.workflow.deployments; - -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.service.search.rest.RestTest; -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.Test; - -/** - * Created by Claudia Agache on 12/7/2016. - */ -public class GetDeploymentsCoreTests extends RestTest -{ - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, - executionType = ExecutionType.REGRESSION, - description = "Verify non admin user is not able to get non-network deployments using REST API and status code is Forbidden") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION}) - public void nonAdminUserCanNotGetNonNetworkDeployments() throws Exception - { - UserModel userModel = dataUser.createRandomTestUser(); - restClient.authenticateUser(userModel).withWorkflowAPI().getDeployments(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentsFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentsFullTests.java deleted file mode 100644 index ccd805c12..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentsFullTests.java +++ /dev/null @@ -1,146 +0,0 @@ -package org.alfresco.service.search.rest.workflow.deployments; - -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestDeploymentModel; -import org.alfresco.rest.model.RestDeploymentModelsCollection; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.service.search.rest.RestTest; -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; - -/** - * Created by Claudia Agache on 1/30/2017. - */ -public class GetDeploymentsFullTests extends RestTest -{ - private UserModel adminUserModel; - private RestDeploymentModelsCollection deployments; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - restClient.authenticateUser(adminUserModel); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, - description = "Verify Admin user gets non-network deployments with skipCount parameter applied using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION}) - public void getNonNetworkDeploymentsWithValidSkipCount() throws JsonToModelConversionException, Exception - { - deployments = restClient.withWorkflowAPI().getDeployments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - RestDeploymentModel firstDeployment = deployments.getEntries().get(0).onModel(); - RestDeploymentModel secondDeployment = deployments.getEntries().get(1).onModel(); - RestDeploymentModelsCollection deploymentsWithSkipCount = restClient.withParams("skipCount=2").withWorkflowAPI().getDeployments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - deploymentsWithSkipCount - .assertThat().entriesListDoesNotContain("name", firstDeployment.getName()) - .assertThat().entriesListDoesNotContain("name", secondDeployment.getName()) - .assertThat().entriesListCountIs(deployments.getEntries().size()-2); - deploymentsWithSkipCount.assertThat().paginationField("skipCount").is("2"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, - description = "Verify Admin user doesn't get non-network deployments when negative skipCount parameter is applied using REST API and status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION}) - public void getNonNetworkDeploymentsWithNegativeSkipCount() throws JsonToModelConversionException, Exception - { - restClient.withParams("skipCount=-1").withWorkflowAPI().getDeployments(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT) - .containsErrorKey(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE) - .statusCodeIs(HttpStatus.BAD_REQUEST); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, - description = "Verify Admin user doesn't get non-network deployments when non numeric skipCount parameter is applied using REST API and status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION}) - public void getNonNetworkDeploymentsWithNotNumericSkipCount() throws JsonToModelConversionException, Exception - { - restClient.withParams("skipCount=A").withWorkflowAPI().getDeployments(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "A")); - } - - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, - description = "Verify Admin user gets non-network deployments with maxItems parameter applied using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION}) - public void getNonNetworkDeploymentsWithValidMaxItems() throws JsonToModelConversionException, Exception - { - deployments = restClient.withWorkflowAPI().getDeployments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - RestDeploymentModel firstDeployment = deployments.getEntries().get(0).onModel(); - RestDeploymentModel secondDeployment = deployments.getEntries().get(1).onModel(); - RestDeploymentModelsCollection deploymentsWithMaxItems = restClient.withParams("maxItems=2").withWorkflowAPI().getDeployments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - deploymentsWithMaxItems - .assertThat().entriesListContains("name", firstDeployment.getName()) - .assertThat().entriesListContains("name", secondDeployment.getName()) - .assertThat().entriesListCountIs(2); - deploymentsWithMaxItems.assertThat().paginationField("maxItems").is("2"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, - description = "Verify Admin user doesn't get non-network deployments when negative maxItems parameter is applied using REST API and status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION}) - public void getNonNetworkDeploymentsWithNegativeMaxItems() throws JsonToModelConversionException, Exception - { - restClient.withParams("maxItems=-1").withWorkflowAPI().getDeployments(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) - .containsErrorKey(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE) - .statusCodeIs(HttpStatus.BAD_REQUEST); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, - description = "Verify Admin user doesn't get non-network deployments when non numeric maxItems parameter is applied using REST API and status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION}) - public void getNonNetworkDeploymentsWithNotNumericMaxItems() throws JsonToModelConversionException, Exception - { - restClient.withParams("maxItems=A").withWorkflowAPI().getDeployments(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "A")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, - description = "Verify Admin user gets non-network deployments with properties parameter applied using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION}) - public void getNonNetworkDeploymentsWithValidProperties() throws JsonToModelConversionException, Exception - { - deployments = restClient.withParams("properties=name").withWorkflowAPI().getDeployments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - deployments.assertThat().entriesListIsNotEmpty(); - deployments.getOneRandomEntry().onModel().assertThat() - .fieldsCount().is(1).and() - .field("id").isNull().and() - .field("deployedAt").isNull().and() - .field("name").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, - description = "Verify Admin user gets non-network deployments with non existing properties parameter applied using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION}) - public void getNonNetworkDeploymentsWithNonExistingProperties() throws JsonToModelConversionException, Exception - { - deployments = restClient.withParams("properties=TAS").withWorkflowAPI().getDeployments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - deployments.assertThat().entriesListIsNotEmpty(); - deployments.getOneRandomEntry().onModel().assertThat() - .fieldsCount().is(0).and() - .field("id").isNull().and() - .field("deployedAt").isNull().and() - .field("name").isNull(); - } - -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentsSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentsSanityTests.java deleted file mode 100644 index 4c0396f6c..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentsSanityTests.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.alfresco.service.search.rest.workflow.deployments; - -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestDeploymentModelsCollection; -import org.alfresco.service.search.rest.RestTest; -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; - -/** - * Created by Claudia Agache on 10/4/2016. - */ -public class GetDeploymentsSanityTests extends RestTest -{ - private UserModel adminUserModel; - private RestDeploymentModelsCollection deployments; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - restClient.authenticateUser(adminUserModel); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.SANITY, - description = "Verify Admin user gets non-network deployments using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.SANITY}) - public void getNonNetworkDeploymentsWithAdmin() throws JsonToModelConversionException, Exception - { - deployments = restClient.authenticateUser(adminUserModel).withWorkflowAPI().getDeployments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - deployments.assertThat().entriesListIsNotEmpty(); - deployments.getOneRandomEntry().onModel().assertThat() - .fieldsCount().is(3).and() - .field("id").isNotEmpty().and() - .field("deployedAt").isNotEmpty().and() - .field("name").isNotEmpty(); - } - -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionCoreTests.java deleted file mode 100644 index 39a0fa465..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionCoreTests.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processDefinitions; - -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestProcessDefinitionModel; -import org.alfresco.service.search.rest.RestTest; -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; - -/** - * Created by Claudia Agache on 12/5/2016. - */ -public class GetProcessDefinitionCoreTests extends RestTest -{ - private UserModel adminUser; - private RestProcessDefinitionModel randomProcessDefinition; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, - executionType = ExecutionType.REGRESSION, - description = "Verify if get process definition returns status code 404 when invalid processDefinitionId is used") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) - public void getProcessDefinitionUsingInvalidProcessDefinitionId() throws Exception - { - restClient.authenticateUser(adminUser); - randomProcessDefinition = restClient.withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry().onModel(); - randomProcessDefinition.setId("invalidID"); - restClient.withWorkflowAPI() - .usingProcessDefinitions(randomProcessDefinition).getProcessDefinition(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidID")) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionFullTests.java deleted file mode 100644 index 6f04b16b4..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionFullTests.java +++ /dev/null @@ -1,67 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processDefinitions; - -import org.alfresco.rest.core.RestRequest; -import org.alfresco.rest.model.RestProcessDefinitionModel; -import org.alfresco.rest.model.RestProcessDefinitionModelsCollection; -import org.alfresco.service.search.rest.RestTest; -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; - -/** - * Created by Claudia Agache on 2/1/2017. - */ -public class GetProcessDefinitionFullTests extends RestTest -{ - private UserModel adminUser; - private RestProcessDefinitionModel randomProcessDefinition, returnedProcessDefinition; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, - executionType = ExecutionType.REGRESSION, - description = "Verify if get process definition returns all process definitions when empty processDefinitionId is used") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) - public void getProcessDefinitionUsingEmptyProcessDefinitionId() throws Exception - { - restClient.authenticateUser(adminUser).withWorkflowAPI(); - RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "/process-definitions/{processDefinitionId}", ""); - RestProcessDefinitionModelsCollection processDefinitions = restClient.processModels(RestProcessDefinitionModelsCollection.class, request); - restClient.assertStatusCodeIs(HttpStatus.OK); - processDefinitions.assertThat().entriesListIsNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, - executionType = ExecutionType.REGRESSION, - description = "Verify Admin user gets a process definition with properties parameter applied using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) - public void getProcessDefinitionWithValidProperties() throws Exception - { - randomProcessDefinition = restClient.authenticateUser(adminUser).withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry().onModel(); - returnedProcessDefinition = restClient.withParams("properties=id,name,graphicNotationDefined,version") - .withWorkflowAPI() - .usingProcessDefinitions(randomProcessDefinition).getProcessDefinition(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedProcessDefinition.assertThat() - .fieldsCount().is(4).and() - .field("deploymentId").isNull().and() - .field("description").isNull().and() - .field("id").is(randomProcessDefinition.getId()).and() - .field("startFormResourceKey").isNull().and() - .field("category").isNull().and() - .field("title").isNull().and() - .field("version").is(randomProcessDefinition.getVersion()).and() - .field("graphicNotationDefined").is(randomProcessDefinition.getGraphicNotationDefined()).and() - .field("key").isNull().and() - .field("name").is(randomProcessDefinition.getName()); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionImageCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionImageCoreTests.java deleted file mode 100644 index ef3dd0fd7..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionImageCoreTests.java +++ /dev/null @@ -1,46 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processDefinitions; - -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestProcessDefinitionModel; -import org.alfresco.service.search.rest.RestTest; -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; - -/** - * Created by Claudia Agache on 12/6/2016. - */ -public class GetProcessDefinitionImageCoreTests extends RestTest -{ - private UserModel adminUser; - private RestProcessDefinitionModel randomProcessDefinition; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, - executionType = ExecutionType.REGRESSION, - description = "Verify if get process definition image returns status code 404 when invalid processDefinitionId is used") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) - public void getProcessDefinitionImageUsingInvalidProcessDefinitionId() throws Exception - { - restClient.authenticateUser(adminUser); - randomProcessDefinition = restClient.withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry().onModel(); - randomProcessDefinition.setId("invalidID"); - - restClient.withWorkflowAPI() - .usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionImage(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidID")) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionImageFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionImageFullTests.java deleted file mode 100644 index 4a39909cd..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionImageFullTests.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processDefinitions; - -import org.alfresco.rest.model.RestProcessDefinitionModel; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Created by Claudia Agache on 2/1/2017. - */ -public class GetProcessDefinitionImageFullTests extends RestTest -{ - private UserModel adminUser; - private RestProcessDefinitionModel randomProcessDefinition; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - } - - @Bug(id = "REPO-1911") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, - executionType = ExecutionType.REGRESSION, - description = "Verify if get process definition image returns status code 404 when empty processDefinitionId is used") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) - public void getProcessDefinitionImageUsingEmptyProcessDefinitionId() throws Exception - { - restClient.authenticateUser(adminUser); - randomProcessDefinition = restClient.withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry().onModel(); - randomProcessDefinition.setId(""); - restClient.withWorkflowAPI() - .usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionImage(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java deleted file mode 100644 index 7d39eb362..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processDefinitions; - -import org.alfresco.rest.model.RestProcessDefinitionModel; -import org.alfresco.service.search.rest.RestTest; -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; - -/** - * Created by Claudia Agache on 10/13/2016. - */ -public class GetProcessDefinitionImageSanityTests extends RestTest -{ - private UserModel testUser; - private RestProcessDefinitionModel randomProcessDefinition; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - testUser = dataUser.createRandomTestUser(); - restClient.authenticateUser(dataUser.getAdminUser()); - randomProcessDefinition = restClient.withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry().onModel(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.SANITY, - description = "Verify Any user gets a specific process definition image for non-network deployments using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY, TestGroup.REQUIRE_TRANSFORMATION }) - public void anyUserGetsProcessDefinitionImage() throws Exception - { - restClient.authenticateUser(testUser); - restClient.withWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionImage() - .assertResponseContainsImage(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.SANITY, - description = "Verify Admin user gets a specific process definition image for non-network deployments using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY, TestGroup.REQUIRE_TRANSFORMATION }) - public void adminGetsProcessDefinitionImage() throws Exception - { - restClient.withWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionImage() - .assertResponseContainsImage(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java deleted file mode 100644 index 4eb0baa28..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java +++ /dev/null @@ -1,62 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processDefinitions; - -import org.alfresco.rest.model.RestProcessDefinitionModel; -import org.alfresco.service.search.rest.RestTest; -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; - -/** - * Created by Claudia Agache on 10/13/2016. - */ -public class GetProcessDefinitionSanityTests extends RestTest -{ - private UserModel testUser; - private RestProcessDefinitionModel randomProcessDefinition, firstRandomProcessDefinition, returnedProcessDefinition; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - testUser = dataUser.createRandomTestUser(); - restClient.authenticateUser(dataUser.getAdminUser()); - randomProcessDefinition = restClient.withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry().onModel(); - firstRandomProcessDefinition = restClient.withWorkflowAPI().getAllProcessDefinitions().getProcessDefinitionByDeploymentId("1"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, - executionType = ExecutionType.SANITY, - description = "Verify Admin user gets a specific process definition for non-network deployments using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY }) - public void adminGetsProcessDefinition() throws Exception - { - returnedProcessDefinition = restClient.withWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinition(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedProcessDefinition.assertThat().field("name").is(randomProcessDefinition.getName()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, - executionType = ExecutionType.SANITY, - description = "Verify Any user gets a specific process definition for non-network deployments using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY }) - public void anyUserGetsProcessDefinition() throws Exception - { - restClient.authenticateUser(testUser); - returnedProcessDefinition = restClient.withWorkflowAPI().usingProcessDefinitions(firstRandomProcessDefinition).getProcessDefinition(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedProcessDefinition.assertThat() - .field("name").is(firstRandomProcessDefinition.getName()).and() - .field("deploymentId").is(firstRandomProcessDefinition.getDeploymentId()).and() - .field("description").is(firstRandomProcessDefinition.getDescription()).and() - .field("id").is(firstRandomProcessDefinition.getId()).and() - .field("startFormResourceKey").is(firstRandomProcessDefinition.getStartFormResourceKey()).and() - .field("category").is(firstRandomProcessDefinition.getCategory()).and() - .field("title").is(firstRandomProcessDefinition.getTitle()).and() - .field("version").is(firstRandomProcessDefinition.getVersion()).and() - .field("graphicNotationDefined").is(firstRandomProcessDefinition.getGraphicNotationDefined()).and() - .field("key").is(firstRandomProcessDefinition.getKey()); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java deleted file mode 100644 index 2e8fe6c1f..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java +++ /dev/null @@ -1,80 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processDefinitions; - -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestProcessDefinitionModel; -import org.alfresco.rest.model.RestProcessDefinitionModelsCollection; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Created by Claudia Agache on 12/6/2016. - */ -public class GetProcessDefinitionStartFormModelCoreTests extends RestTest -{ - private UserModel adminUser; - private RestProcessDefinitionModel randomProcessDefinition; - private RestProcessDefinitionModelsCollection allProcessDefinitions; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - allProcessDefinitions = restClient.authenticateUser(adminUser).withWorkflowAPI().getAllProcessDefinitions(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, - executionType = ExecutionType.REGRESSION, - description = "Verify any user gets a model of the start form type definition for non-network deployments using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) - public void nonNetworkUserGetsStartFormModel() throws Exception - { - UserModel nonNetworkUser = dataUser.createRandomTestUser(); - randomProcessDefinition = allProcessDefinitions.getOneRandomEntry().onModel(); - restClient.authenticateUser(nonNetworkUser).withWorkflowAPI() - .usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionStartFormModel() - .assertThat().entriesListIsNotEmpty(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Bug(id = "ALF-20187") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, - executionType = ExecutionType.REGRESSION, - description = "Verify if get request returns status code 404 when invalid processDefinitionId is used") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) - public void getStartFormModelUsingInvalidProcessDefinitionId() throws Exception - { - randomProcessDefinition = allProcessDefinitions.getOneRandomEntry().onModel(); - randomProcessDefinition.setId("invalidID"); - - restClient.authenticateUser(adminUser).withWorkflowAPI() - .usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionStartFormModel(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format("no deployed process definition found with id '%s'", "invalidID")) - .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Bug(id = "ALF-20187") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, - executionType = ExecutionType.REGRESSION, - description = "Verify if get request returns status code 404 when empty processDefinitionId is used") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) - public void getStartFormModelUsingEmptyProcessDefinitionId() throws Exception - { - randomProcessDefinition = allProcessDefinitions.getOneRandomEntry().onModel(); - randomProcessDefinition.setId(""); - - restClient.authenticateUser(adminUser).withWorkflowAPI() - .usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionStartFormModel(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary("no deployed process definition found with id ''"); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelFullTests.java deleted file mode 100644 index 5062ea772..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelFullTests.java +++ /dev/null @@ -1,71 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processDefinitions; - -import java.util.Arrays; - -import org.alfresco.rest.model.RestFormModelsCollection; -import org.alfresco.rest.model.RestProcessDefinitionModel; -import org.alfresco.service.search.rest.RestTest; -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; - -/** - * Created by Claudia Agache on 1/31/2017. - */ -public class GetProcessDefinitionStartFormModelFullTests extends RestTest -{ - private UserModel adminUser; - private RestProcessDefinitionModel activitiAdhoc; - private RestFormModelsCollection returnedResponse; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - activitiAdhoc = restClient.authenticateUser(adminUser).withWorkflowAPI().getAllProcessDefinitions().getProcessDefinitionByDeploymentId("1"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, - executionType = ExecutionType.REGRESSION, - description = "Verify admin gets a model of the start form type definition for specific process definition using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) - public void adminGetsStartFormModelForActivitiAdhocProcessDefinition() throws Exception - { - returnedResponse = restClient.authenticateUser(adminUser).withWorkflowAPI() - .usingProcessDefinitions(activitiAdhoc).getProcessDefinitionStartFormModel(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedResponse.assertThat().entriesListContains("qualifiedName", "{http://www.alfresco.org/model/bpm/1.0}workflowPriority"); - returnedResponse.getStartFormModelByQualifiedName("{http://www.alfresco.org/model/bpm/1.0}workflowPriority") - .assertThat().field("defaultValue").is("2") - .and().field("dataType").is("d:int") - .and().field("name").is("bpm_workflowPriority") - .and().field("title").is("Workflow Priority") - .and().field("required").is("false") - .and().field("allowedValues").is(Arrays.asList("1", "2", "3")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, - executionType = ExecutionType.REGRESSION, - description = "Verify admin gets a model of the start form type definition with properties parameter applied using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) - public void adminGetsStartFormModelWithPropertiesParameterApplied() throws Exception - { - returnedResponse = restClient.authenticateUser(adminUser).withParams("properties=qualifiedName,dataType,title").withWorkflowAPI() - .usingProcessDefinitions(activitiAdhoc).getProcessDefinitionStartFormModel(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedResponse.assertThat().entriesListContains("qualifiedName", "{http://www.alfresco.org/model/bpm/1.0}workflowPriority"); - returnedResponse.getStartFormModelByQualifiedName("{http://www.alfresco.org/model/bpm/1.0}workflowPriority") - .assertThat().fieldsCount().is(3) - .and().field("qualifiedName").is("{http://www.alfresco.org/model/bpm/1.0}workflowPriority") - .and().field("defaultValue").isNull() - .and().field("dataType").is("d:int") - .and().field("name").isNull() - .and().field("title").is("Workflow Priority") - .and().field("required").isNull() - .and().field("allowedValues").isNull(); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java deleted file mode 100644 index 820fbee80..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processDefinitions; - -import org.alfresco.rest.model.RestProcessDefinitionModel; -import org.alfresco.service.search.rest.RestTest; -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; - -/** - * Created by Claudia Agache on 10/18/2016. - */ -public class GetProcessDefinitionStartFormModelSanityTests extends RestTest -{ - private UserModel adminUserModel; - private RestProcessDefinitionModel randomProcessDefinition; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - restClient.authenticateUser(adminUserModel); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, - executionType = ExecutionType.SANITY, - description = "Verify Admin gets a model of the start form type definition for non-network deployments using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY }) - public void nonNetworkAdminGetsStartFormModel() throws Exception - { - randomProcessDefinition = restClient.withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry().onModel(); - restClient.withWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionStartFormModel().assertThat().entriesListIsNotEmpty(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionsCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionsCoreTests.java deleted file mode 100644 index c30e3177d..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionsCoreTests.java +++ /dev/null @@ -1,53 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processDefinitions; - -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class GetProcessDefinitionsCoreTests extends RestTest -{ - private UserModel userModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, - description = "Verify call to get process definitions with invalid orderBy parameter with REST API and status code is BAD_REQUEST (400)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) - public void userGetProcessDefinitionsWithInvalidOrderBy() throws Exception - { - restClient.authenticateUser(userModel) - .withParams("orderBy=test") - .withWorkflowAPI() - .getAllProcessDefinitions() - .assertThat().entriesListIsEmpty(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_ORDERBY, "test", "deploymentId, name, id, category, version, key")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, - description = "Verify call to get process definitions with invalid where parameter with REST API and status code is BAD_REQUEST (400)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) - public void userGetProcessDefinitionsWithInvalidWhere() throws Exception - { - restClient.authenticateUser(userModel) - .withParams("where=test") - .withWorkflowAPI() - .getAllProcessDefinitions() - .assertThat().entriesListIsEmpty(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_WHERE_QUERY, "test")) - .containsErrorKey(RestErrorModel.INVALID_QUERY_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionsFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionsFullTests.java deleted file mode 100644 index 2b2687dd4..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionsFullTests.java +++ /dev/null @@ -1,174 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processDefinitions; - -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestProcessDefinitionModel; -import org.alfresco.rest.model.RestProcessDefinitionModelsCollection; -import org.alfresco.service.search.rest.RestTest; -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; - -/** - * Created by Claudia Agache on 2/1/2017. - */ -public class GetProcessDefinitionsFullTests extends RestTest -{ - private UserModel adminUserModel; - private RestProcessDefinitionModelsCollection processDefinitions; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, - description = "Verify admin gets process definitions with valid skipCount parameter applied using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) - public void getProcessDefinitionsWithValidSkipCount() throws Exception - { - processDefinitions = restClient.authenticateUser(adminUserModel) - .withWorkflowAPI().getAllProcessDefinitions(); - restClient.assertStatusCodeIs(HttpStatus.OK); - RestProcessDefinitionModel firstProcessDefinition = processDefinitions.getEntries().get(0).onModel(); - RestProcessDefinitionModel secondProcessDefinition = processDefinitions.getEntries().get(1).onModel(); - - RestProcessDefinitionModelsCollection procDefWithSkipCount = restClient.withParams("skipCount=2").withWorkflowAPI().getAllProcessDefinitions(); - restClient.assertStatusCodeIs(HttpStatus.OK); - procDefWithSkipCount - .assertThat().entriesListDoesNotContain("name", firstProcessDefinition.getName()) - .assertThat().entriesListDoesNotContain("name", secondProcessDefinition.getName()) - .assertThat().entriesListCountIs(processDefinitions.getEntries().size()-2); - procDefWithSkipCount.assertThat().paginationField("skipCount").is("2"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, - description = "Verify admin doesn't get process definitions with negative skipCount parameter applied using REST API") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) - public void getProcessDefinitionsWithNegativeSkipCount() throws Exception - { - restClient.authenticateUser(adminUserModel).withParams("skipCount=-1").withWorkflowAPI().getAllProcessDefinitions(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT) - .containsErrorKey(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE) - .statusCodeIs(HttpStatus.BAD_REQUEST); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, - description = "Verify admin doesn't get process definitions with non numeric skipCount parameter applied using REST API") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) - public void getProcessDefinitionsWithNonNumericSkipCount() throws Exception - { - restClient.authenticateUser(adminUserModel).withParams("skipCount=A").withWorkflowAPI().getAllProcessDefinitions(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "A")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, - description = "Verify admin gets process definitions with valid maxItems parameter applied using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) - public void getProcessDefinitionsWithValidMaxItems() throws Exception - { - processDefinitions = restClient.authenticateUser(adminUserModel) - .withWorkflowAPI().getAllProcessDefinitions(); - restClient.assertStatusCodeIs(HttpStatus.OK); - RestProcessDefinitionModel firstProcessDefinition = processDefinitions.getEntries().get(0).onModel(); - RestProcessDefinitionModel secondProcessDefinition = processDefinitions.getEntries().get(1).onModel(); - - RestProcessDefinitionModelsCollection procDefWithMaxItems = restClient.withParams("maxItems=2").withWorkflowAPI().getAllProcessDefinitions(); - restClient.assertStatusCodeIs(HttpStatus.OK); - procDefWithMaxItems - .assertThat().entriesListContains("name", firstProcessDefinition.getName()) - .assertThat().entriesListContains("name", secondProcessDefinition.getName()) - .assertThat().entriesListCountIs(2); - procDefWithMaxItems.assertThat().paginationField("maxItems").is("2"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, - description = "Verify admin doesn't get process definitions with negative maxItems parameter applied using REST API") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) - public void getProcessDefinitionsWithNegativeMaxItems() throws Exception - { - restClient.authenticateUser(adminUserModel).withParams("maxItems=-1").withWorkflowAPI().getAllProcessDefinitions(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) - .containsErrorKey(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE) - .statusCodeIs(HttpStatus.BAD_REQUEST); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, - description = "Verify admin doesn't get process definitions with non numeric maxItems parameter applied using REST API") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) - public void getProcessDefinitionsWithNonNumericMaxItems() throws Exception - { - restClient.authenticateUser(adminUserModel).withParams("maxItems=A").withWorkflowAPI().getAllProcessDefinitions(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "A")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, - description = "Verify Admin user gets process definitions with properties parameter applied using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) - public void getProcessDefinitionsWithValidProperties() throws Exception - { - processDefinitions =restClient.authenticateUser(adminUserModel).withParams("properties=name,graphicNotationDefined,version").withWorkflowAPI().getAllProcessDefinitions(); - restClient.assertStatusCodeIs(HttpStatus.OK); - processDefinitions.assertThat().entriesListIsNotEmpty(); - processDefinitions.getOneRandomEntry().onModel().assertThat() - .fieldsCount().is(3).and() - .field("deploymentId").isNull().and() - .field("description").isNull().and() - .field("id").isNull().and() - .field("startFormResourceKey").isNull().and() - .field("category").isNull().and() - .field("title").isNull().and() - .field("version").isNotEmpty().and() - .field("graphicNotationDefined").isNotEmpty().and() - .field("key").isNull().and() - .field("name").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, - description = "Verify admin gets process definitions ordered by name ascendant using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) - public void getProcessDefinitionsOrderedByNameAsc() throws Exception - { - processDefinitions = restClient.authenticateUser(adminUserModel) - .withParams("orderBy=name ASC").withWorkflowAPI().getAllProcessDefinitions(); - restClient.assertStatusCodeIs(HttpStatus.OK); - processDefinitions.assertThat().entriesListIsSortedAscBy("name"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, - description = "Verify admin doesn't get process definitions when many fields are used for orderBy parameter") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) - public void getProcessDefinitionsOrderedByManyFields() throws Exception - { - restClient.authenticateUser(adminUserModel) - .withParams("orderBy=name,id").withWorkflowAPI().getAllProcessDefinitions(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(RestErrorModel.ONLY_ONE_ORDERBY); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, - description = "Verify admin gets process definitions when where parameter is applied") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) - public void getProcessDefinitionsFilteredByKey() throws Exception - { - processDefinitions = restClient.authenticateUser(adminUserModel) - .withParams("where=(key matches('activitiParallel%'))").withWorkflowAPI().getAllProcessDefinitions(); - restClient.assertStatusCodeIs(HttpStatus.OK); - processDefinitions.assertThat().entriesListCountIs(2) - .assertThat().entriesListContains("key", "activitiParallelReview") - .assertThat().entriesListContains("key", "activitiParallelGroupReview"); - } - -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java deleted file mode 100644 index bfa595150..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java +++ /dev/null @@ -1,48 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processDefinitions; - -import org.alfresco.rest.model.RestProcessDefinitionModelsCollection; -import org.alfresco.service.search.rest.RestTest; -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; - -/** - * Created by Claudia Agache on 10/13/2016. - */ -public class GetProcessDefinitionsSanityTests extends RestTest -{ - private UserModel adminUserModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - restClient.authenticateUser(adminUserModel); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, - executionType = ExecutionType.SANITY, description = "Verify Admin user gets process definitions for non-network deployments using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY }) - public void nonNetworkAdminGetsProcessDefinitions() throws Exception - { - RestProcessDefinitionModelsCollection processDefinitions = restClient.authenticateUser(adminUserModel) - .withWorkflowAPI() - .getAllProcessDefinitions(); - restClient.assertStatusCodeIs(HttpStatus.OK); - processDefinitions.assertThat().entriesListIsNotEmpty(); - processDefinitions.getProcessDefinitionByDeploymentId("1").assertThat() - .field("name").is("Adhoc Activiti Process").and() - .field("description").is("Assign a new task to yourself or a colleague").and() - .field("id").is("activitiAdhoc:1:4").and() - .field("startFormResourceKey").is("wf:submitAdhocTask").and() - .field("category").is("http://alfresco.org").and() - .field("title").is("New Task").and() - .field("version").is("1").and() - .field("graphicNotationDefined").is("true").and() - .field("key").is("activitiAdhoc"); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/AddProcessCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/AddProcessCoreTests.java deleted file mode 100644 index 4ae2f8b59..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/AddProcessCoreTests.java +++ /dev/null @@ -1,128 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes; - -import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.core.RestRequest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestProcessDefinitionModel; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.model.RestProcessModelsCollection; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.testng.annotations.Test; - -/** - * - * @author Cristina Axinte - * - */ -public class AddProcessCoreTests extends RestTest -{ - private UserModel assignee, adminUser; - private RestProcessModel addedProcess; - private RestProcessModelsCollection processes; - private RestProcessDefinitionModel processDefinition; - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, - executionType = ExecutionType.REGRESSION, description = "Verify non network admin is able to start new process using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void nonNetworkAdminUserStartsNewProcess() throws JsonToModelConversionException, Exception - { - adminUser = dataUser.getAdminUser(); - assignee = dataUser.createRandomTestUser(); - - addedProcess = restClient.authenticateUser(adminUser).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - addedProcess.assertThat().field("id").is(addedProcess.getId()) - .and().field("startUserId").is(adminUser.getUsername()); - - processDefinition = restClient.authenticateUser(adminUser).withWorkflowAPI().getAllProcessDefinitions().getProcessDefinitionByKey("activitiAdhoc"); - processes = restClient.withWorkflowAPI().getProcesses(); - restClient.assertStatusCodeIs(HttpStatus.OK); - processes.assertThat().entriesListContains("id", addedProcess.getId()) - .assertThat().entriesListContains("processDefinitionId", processDefinition.getId()) - .assertThat().entriesListContains("startUserId", adminUser.getUsername()) - .assertThat().entriesListContains("startActivityId", "start") - .assertThat().entriesListContains("completed", "false") - .assertThat().entriesListContains("processDefinitionKey", "activitiAdhoc"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, - executionType = ExecutionType.REGRESSION, description = "Verify start new process with empty request body using REST API returns status code is Bad Request (400)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void startNewProcessWithEmptyProcessBody() throws JsonToModelConversionException, Exception - { - adminUser = dataUser.getAdminUser(); - assignee = dataUser.createRandomTestUser(); - - restClient.authenticateUser(adminUser).withWorkflowAPI(); - RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "", "processes"); - restClient.processModel(RestProcessModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - } - - @Bug(id = "REPO-1936") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, - executionType = ExecutionType.REGRESSION, description = "Verify start new process with invalid request body using REST API returns status code is Bad Request (400)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void startNewProcessWithInvalidProcessDefInProcessBody() throws JsonToModelConversionException, Exception - { - adminUser = dataUser.getAdminUser(); - assignee = dataUser.createRandomTestUser(); - - restClient.authenticateUser(adminUser).withWorkflowAPI(); - RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{\"processDefinitionKey\":\"activitiAdhoc\"}", "processes"); - restClient.processModel(RestProcessModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, - executionType = ExecutionType.REGRESSION, description = "Verify start new process with invalid request body using REST API returns status code is Bad Request (400)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void startNewProcessWithInvalidVariablesInProcessBody1() throws JsonToModelConversionException, Exception - { - adminUser = dataUser.getAdminUser(); - assignee = dataUser.createRandomTestUser(); - - restClient.authenticateUser(adminUser).withWorkflowAPI(); - RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{\"variables\":{\"bpm_sendEMailNotifications\":false}}", "processes"); - restClient.processModel(RestProcessModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary("Either processDefinitionId or processDefinitionKey is required"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, - executionType = ExecutionType.REGRESSION, description = "Verify start new process with invalid request body using REST API returns status code is Bad Request (400)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void startNewProcessWithInvalidVariablesInProcessBody2() throws JsonToModelConversionException, Exception - { - adminUser = dataUser.getAdminUser(); - assignee = dataUser.createRandomTestUser(); - - restClient.authenticateUser(adminUser).withWorkflowAPI(); - RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{\"variables\":{\"bpm_assignee\":\"admin\"}}", "processes"); - restClient.processModel(RestProcessModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary("Either processDefinitionId or processDefinitionKey is required"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, - executionType = ExecutionType.REGRESSION, description = "Verify start new process with invalid request body using REST API returns status code is Bad Request (400)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void startNewProcessWithInvalidVariablesInProcessBody3() throws JsonToModelConversionException, Exception - { - adminUser = dataUser.getAdminUser(); - assignee = dataUser.createRandomTestUser(); - - restClient.authenticateUser(adminUser).withWorkflowAPI(); - RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{\"variables\":{\"bpm_workflowPriority\":2}}", "processes"); - restClient.processModel(RestProcessModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary("Either processDefinitionId or processDefinitionKey is required"); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/AddProcessFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/AddProcessFullTests.java deleted file mode 100644 index 61b609c63..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/AddProcessFullTests.java +++ /dev/null @@ -1,150 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes; - -import javax.json.JsonObject; - -import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.core.JsonBodyGenerator; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * - * @author Cristina Axinte - * - */ -public class AddProcessFullTests extends RestTest -{ - private UserModel userWhoStartsProcess, assignee; - RestProcessModel addedProcess; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - assignee = dataUser.createRandomTestUser(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify user cannot start new process with invalid processDefinitionKey using REST API and status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void userStartsNewProcessWithInvalidProcessDefinitionKey() throws JsonToModelConversionException, Exception - { - userWhoStartsProcess = dataUser.createRandomTestUser(); - - addedProcess = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcess("activitiAdhocc", assignee, false, Priority.Normal); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(String.format(RestErrorModel.NO_WORKFLOW_DEFINITION_FOUND, "activitiAdhocc")) - .containsSummary(String.format(RestErrorModel.NO_WORKFLOW_DEFINITION_FOUND, "activitiAdhocc")) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } - - @Bug(id = "REPO-1970") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify user cannot start new process with invalid processDefinitionKey using REST API and status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void userStartsNewProcessWithEmptyVariablesBody() throws JsonToModelConversionException, Exception - { - userWhoStartsProcess = dataUser.createRandomTestUser(); - - JsonObject postJson = JsonBodyGenerator.defineJSON() - .add("processDefinitionKey", "activitiAdhoc") - .add("variables", - JsonBodyGenerator.defineJSON().build() - ).build(); - addedProcess = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcessWithBody(postJson); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(String.format(RestErrorModel.NO_WORKFLOW_DEFINITION_FOUND, "activitiAdhoc")); - } - - @Bug(id = "REPO-1970") - @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify user cannot start new process with invalid processDefinitionKey using REST API and status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void userStartsNewProcessWithNoAssigneeInVariablesBody() throws JsonToModelConversionException, Exception - { - userWhoStartsProcess = dataUser.createRandomTestUser(); - - JsonObject postJson = JsonBodyGenerator.defineJSON() - .add("processDefinitionKey", "activitiAdhoc") - .add("variables", - JsonBodyGenerator.defineJSON() - .add("bpm_sendEMailNotifications", false) - .add("bpm_workflowPriority", Priority.Low.getLevel()).build() - ).build(); - addedProcess = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcessWithBody(postJson); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(String.format(RestErrorModel.NO_WORKFLOW_DEFINITION_FOUND, "activitiAdhoc")); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify user cannot start new process with invalid assignee using REST API and status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void userStartsNewProcessWithInvalidAssignee() throws JsonToModelConversionException, Exception - { - userWhoStartsProcess = dataUser.createRandomTestUser(); - UserModel invalidAssignee = new UserModel("invalidAssignee", "password"); - - addedProcess = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcess("activitiAdhoc", invalidAssignee, false, Priority.Normal); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(String.format(RestErrorModel.INVALID_USER_ID, invalidAssignee.getUsername())) - .containsSummary(String.format(RestErrorModel.INVALID_USER_ID, invalidAssignee.getUsername())) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } - - @Bug(id = "REPO-1970") - @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify user cannot start new process with invalid sendEMailNotifications value using REST API and status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void userStartsNewProcessWithInvalidEmailNotification() throws JsonToModelConversionException, Exception - { - userWhoStartsProcess = dataUser.createRandomTestUser(); - JsonObject postJson = JsonBodyGenerator.defineJSON() - .add("processDefinitionKey", "activitiAdhoc") - .add("variables", - JsonBodyGenerator.defineJSON() - .add("bpm_assignee", assignee.getUsername()) - .add("bpm_sendEMailNotifications", "111") - .add("bpm_workflowPriority", Priority.Low.getLevel()).build() - ).build(); - - addedProcess = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcessWithBody(postJson); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(String.format(RestErrorModel.UNSUPPORTED_TYPE, "111")) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } - - @Bug(id = "REPO-1970") - @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify user cannot start new process with invalid priority using REST API and status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void userStartsNewProcessWithInvalidPriority() throws JsonToModelConversionException, Exception - { - userWhoStartsProcess = dataUser.createRandomTestUser(); - JsonObject postJson = JsonBodyGenerator.defineJSON() - .add("processDefinitionKey", "activitiAdhoc") - .add("variables", - JsonBodyGenerator.defineJSON() - .add("bpm_assignee", assignee.getUsername()) - .add("bpm_sendEMailNotifications", false) - .add("bpm_workflowPriority", "test").build() - ).build(); - - addedProcess = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcessWithBody(postJson); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(String.format(RestErrorModel.UNSUPPORTED_TYPE, "test")) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/AddProcessSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/AddProcessSanityTests.java deleted file mode 100644 index 4be323242..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/AddProcessSanityTests.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes; - -import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.model.RestProcessModelsCollection; -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.Test; - -/** - * Created by Claudia Agache on 10/18/2016. - */ -public class AddProcessSanityTests extends RestTest -{ - private UserModel userWhoStartsProcess, assignee; - private RestProcessModel addedProcess; - private RestProcessModelsCollection processes; - - @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW, - TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Verify non network user is able to start new process using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) - public void nonNetworkUserStartsNewProcess() throws JsonToModelConversionException, Exception - { - userWhoStartsProcess = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - - addedProcess = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - addedProcess.assertThat().field("id").is(addedProcess.getId()) - .and().field("startUserId").is(addedProcess.getStartUserId()); - - processes = restClient.withWorkflowAPI().getProcesses(); - restClient.assertStatusCodeIs(HttpStatus.OK); - processes.assertThat().entriesListContains("id", addedProcess.getId()); - - } - -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/DeleteProcessCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/DeleteProcessCoreTests.java deleted file mode 100644 index 8d0525e1e..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/DeleteProcessCoreTests.java +++ /dev/null @@ -1,69 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes; - -import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class DeleteProcessCoreTests extends RestTest -{ - private UserModel userWhoAddsProcess, assignee; - private RestProcessModel process; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - userWhoAddsProcess = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW, - TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify admin user is able to delete a process started by another user.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void deleteProcessByAdminUser() throws Exception - { - process = restClient.authenticateUser(userWhoAddsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.authenticateUser(dataUser.getAdminUser()) - .withWorkflowAPI().usingProcess(process).deleteProcess(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withWorkflowAPI().getProcesses() - .assertThat().entriesListDoesNotContain("id", process.getId()); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW, - TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify User is not able to delete process with invalid id") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void deleteProcessWithInvalidId() throws Exception - { - process = restClient.authenticateUser(userWhoAddsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - process.setId("00001"); - restClient.withWorkflowAPI().usingProcess(process).deleteProcess(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "00001")); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW, - TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify User is not able to delete process with empty id") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void deleteProcessWithEmptyId() throws Exception - { - process = restClient.authenticateUser(userWhoAddsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - process.setId(""); - restClient.withWorkflowAPI().usingProcess(process).deleteProcess(); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) - .assertLastError().containsSummary(RestErrorModel.DELETE_EMPTY_ARGUMENT); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/DeleteProcessFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/DeleteProcessFullTests.java deleted file mode 100644 index dad9826f2..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/DeleteProcessFullTests.java +++ /dev/null @@ -1,52 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes; - -import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestProcessModel; -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 Cristina Axinte - * - */ -public class DeleteProcessFullTests extends RestTest -{ - private UserModel userWhoAddsProcess, assignee; - private RestProcessModel process; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - userWhoAddsProcess = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify user is NOT able to delete process started by him twice using REST API and status code is NOT FOUND (404)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void deleteProcessByUserWhoStartedProcessTwice() throws Exception - { - process = restClient.authenticateUser(userWhoAddsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.withWorkflowAPI().usingProcess(process).deleteProcess(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withWorkflowAPI().usingProcess(process).deleteProcess(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.ENTITY_WAS_NOT_FOUND, process.getId())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - - restClient.withWorkflowAPI().getProcesses().assertThat().entriesListDoesNotContain("id", process.getId()); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/DeleteProcessSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/DeleteProcessSanityTests.java deleted file mode 100644 index 6cea148d8..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/DeleteProcessSanityTests.java +++ /dev/null @@ -1,69 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes; - -import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestProcessModel; -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; - -/** - * Created by Claudia Agache on 10/12/2016. - */ -public class DeleteProcessSanityTests extends RestTest -{ - private UserModel userWhoAddsProcess, assignee, anotherUser; - private RestProcessModel process; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - userWhoAddsProcess = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - anotherUser = dataUser.createRandomTestUser(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Verify User is able to delete process started by him using REST API and status code is OK (204)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) - public void deleteProcessByUserWhoStartedProcess() throws Exception - { - process = restClient.authenticateUser(userWhoAddsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.withWorkflowAPI().usingProcess(process).deleteProcess(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withWorkflowAPI().getProcesses().assertThat().entriesListDoesNotContain("id", process.getId()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Verify User is able to delete process assigned to him using REST API and status code is OK (204)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) - public void deleteProcessByAssignedUser() throws Exception - { - process = restClient.authenticateUser(userWhoAddsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(process).deleteProcess(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withWorkflowAPI().getProcesses().assertThat().entriesListDoesNotContain("id", process.getId()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Verify User that is not involved in a process is not authorized to delete it using REST API and status code is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) - public void deleteProcessByAnotherUser() throws Exception - { - process = restClient.authenticateUser(userWhoAddsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(anotherUser).withWorkflowAPI().usingProcess(process).deleteProcess(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("user is not allowed to access information about process"); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessCoreTests.java deleted file mode 100644 index bc97bb842..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessCoreTests.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.apache.commons.lang3.RandomStringUtils; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class GetProcessCoreTests extends RestTest -{ - private UserModel userWhoStartsProcess, assignee; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - userWhoStartsProcess = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify that using invalid process ID returns status code 404") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION}) - public void invalidProcessIdTest() throws Exception - { - RestProcessModel newProcess = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.High); - String processId = RandomStringUtils.randomAlphanumeric(10); - newProcess.setId(processId); - restClient.authenticateUser(dataUser.getAdminUser()) - .withWorkflowAPI().usingProcess(newProcess).getProcess(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, processId)) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } -} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessFullTests.java deleted file mode 100644 index e7214bba5..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessFullTests.java +++ /dev/null @@ -1,85 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestProcessDefinitionModel; -import org.alfresco.rest.model.RestProcessModel; -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 Cristina Axinte - * - */ -public class GetProcessFullTests extends RestTest -{ - private UserModel userWhoStartsProcess, assignee; - private RestProcessModel addedProcess, process; - private RestProcessDefinitionModel adhocProcessDefinition; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - userWhoStartsProcess = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - addedProcess = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.High); - adhocProcessDefinition = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getAllProcessDefinitions().getProcessDefinitionByKey("activitiAdhoc"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify user is able to get the process with properties parameter applied using REST API") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void getProcessWithPropertiesParameter() throws Exception - { - process = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingParams("properties=startUserId,id").usingProcess(addedProcess).getProcess(); - restClient.assertStatusCodeIs(HttpStatus.OK); - process.assertThat().fieldsCount().is(2) - .and().field("startUserId").is(addedProcess.getStartUserId()) - .and().field("id").is(addedProcess.getId()) - .and().field("processDefinitionKey").isNull(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify user is able to get a process that was deleted, but it has 'deleted through REST API call' deleteReason") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void getDeletedProcess() throws Exception - { - addedProcess = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.High); - - process = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingProcess(addedProcess).getProcess(); - restClient.assertStatusCodeIs(HttpStatus.OK); - process.assertThat() - .field("processDefinitionId").is(adhocProcessDefinition.getId()) - .and().field("startUserId").is(addedProcess.getStartUserId()) - .and().field("startActivityId").is("start") - .and().field("startedAt").isNotEmpty() - .and().field("id").is(addedProcess.getId()) - .and().field("completed").is(false) - .and().field("processDefinitionKey").is("activitiAdhoc"); - - restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingProcess(addedProcess).deleteProcess(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - process = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingProcess(addedProcess).getProcess(); - restClient.assertStatusCodeIs(HttpStatus.OK); - process.assertThat() - .field("processDefinitionId").is(adhocProcessDefinition.getId()) - .and().field("durationInMs").isNotNull() - .and().field("startUserId").is(addedProcess.getStartUserId()) - .and().field("startActivityId").is("start") - .and().field("endedAt").isNotEmpty() - .and().field("startedAt").isNotEmpty() - .and().field("id").is(addedProcess.getId()) - .and().field("completed").is(true) - .and().field("deleteReason").is("deleted through REST API call") - .and().field("processDefinitionKey").is("activitiAdhoc"); - - restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().assertThat().entriesListDoesNotContain("id", process.getId()); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessSanityTests.java deleted file mode 100644 index 33649ebf5..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessSanityTests.java +++ /dev/null @@ -1,62 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestProcessModel; -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; - -/** - * Created by Claudia Agache on 10/19/2016. - */ -public class GetProcessSanityTests extends RestTest -{ - private UserModel userWhoStartsProcess, assignee; - private RestProcessModel addedProcess, process; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - userWhoStartsProcess = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - addedProcess = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.High); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Verify user is able to get the process started by him using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) - public void getProcessByOwner() throws Exception - { - process = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingProcess(addedProcess).getProcess(); - restClient.assertStatusCodeIs(HttpStatus.OK); - process.assertThat().field("id").is(addedProcess.getId()) - .and().field("startUserId").is(addedProcess.getStartUserId()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Verify user is able to get the process assigned to him using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) - public void getProcessByAssignee() throws Exception - { - process = restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(addedProcess).getProcess(); - restClient.assertStatusCodeIs(HttpStatus.OK); - process.assertThat().field("id").is(addedProcess.getId()) - .and().field("startUserId").is(addedProcess.getStartUserId()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Verify admin is able to get any process using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) - public void getProcessByAdmin() throws Exception - { - process = restClient.authenticateUser(dataUser.getAdminUser()).withWorkflowAPI().usingProcess(addedProcess).getProcess(); - restClient.assertStatusCodeIs(HttpStatus.OK); - process.assertThat().field("id").is(addedProcess.getId()) - .and().field("startUserId").is(addedProcess.getStartUserId()); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessesCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessesCoreTests.java deleted file mode 100644 index d2532d36a..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessesCoreTests.java +++ /dev/null @@ -1,80 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes; - -import java.util.List; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestProcessDefinitionModel; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.model.RestProcessModelsCollection; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.ProcessModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TaskModel; -import org.alfresco.utility.model.TestGroup; -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 Cristina Axinte - * - */ -public class GetProcessesCoreTests extends RestTest -{ - private FileModel document; - private SiteModel siteModel; - private UserModel adminUser, userWhoStartsTask, assignee ; - private TaskModel task1, task2; - private ProcessModel process3; - private RestProcessDefinitionModel adhocProcessDefinition; - private RestProcessDefinitionModel activitiReviewProcessDefinition; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userWhoStartsTask = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - task1 = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); - task2 = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(adminUser); - process3 = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createSingleReviewerTaskAndAssignTo(assignee); - adhocProcessDefinition = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getAllProcessDefinitions().getProcessDefinitionByKey("activitiAdhoc"); - activitiReviewProcessDefinition = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getAllProcessDefinitions().getProcessDefinitionByKey("activitiReview"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify user gets all processes started by him ordered descending by id") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void getProcessesOrderedByIdDESC() throws Exception - { - RestProcessModelsCollection processes = restClient.authenticateUser(userWhoStartsTask).withParams("orderBy=id DESC") - .withWorkflowAPI().getProcesses(); - restClient.assertStatusCodeIs(HttpStatus.OK); - processes.assertThat().entriesListIsNotEmpty(); - List processesList = processes.getEntries(); - processesList.get(0).onModel().assertThat().field("id").is(process3.getId()); - processesList.get(1).onModel().assertThat().field("id").is(task2.getProcessId()); - processesList.get(2).onModel().assertThat().field("id").is(task1.getProcessId()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify user gets processes that matches a where clause") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void getProcessesWithWhereClauseAsParameter() throws JsonToModelConversionException, Exception - { - RestProcessModelsCollection processes = restClient.authenticateUser(userWhoStartsTask).where("processDefinitionKey='activitiReview'") - .withWorkflowAPI().getProcesses(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - processes.assertThat().entriesListIsNotEmpty().and().entriesListContains("processDefinitionId", activitiReviewProcessDefinition.getId()) - .and().entriesListDoesNotContain("processDefinitionId", adhocProcessDefinition.getId()); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessesFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessesFullTests.java deleted file mode 100644 index 0c5b63b5e..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessesFullTests.java +++ /dev/null @@ -1,160 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes; - -import java.util.List; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.model.RestProcessModelsCollection; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.ProcessModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TaskModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * - * @author Cristina Axinte - * - */ -public class GetProcessesFullTests extends RestTest -{ - private FileModel document; - private SiteModel siteModel; - private UserModel adminUser, userWhoStartsTask, assignee; - private TaskModel task1, task2; - private ProcessModel process3; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userWhoStartsTask = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - task1 = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); - task2 = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(adminUser); - process3 = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createSingleReviewerTaskAndAssignTo(assignee); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify user gets processes when skipCount parameter is applied") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void getProcessesWithSkipCountParameter() throws Exception - { - RestProcessModelsCollection processes = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getProcesses(); - restClient.assertStatusCodeIs(HttpStatus.OK); - processes.assertThat().paginationField("count").is("3"); - RestProcessModel process1 = processes.getEntries().get(0).onModel(); - RestProcessModel process2 = processes.getEntries().get(1).onModel(); - RestProcessModel process3 = processes.getEntries().get(2).onModel(); - - processes = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingParams("skipCount=2").getProcesses(); - restClient.assertStatusCodeIs(HttpStatus.OK); - processes.assertThat().paginationField("count").is("1"); - processes.assertThat().paginationField("skipCount").is("2"); - processes.assertThat().entriesListDoesNotContain("id", process1.getId()); - processes.assertThat().entriesListDoesNotContain("id", process2.getId()); - processes.getEntries().get(0).onModel().assertThat().field("id").is(process3.getId()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify user gets processes when maxItems parameter is applied") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void getProcessesWithMaxItemsParameter() throws Exception - { - RestProcessModelsCollection processes = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getProcesses(); - restClient.assertStatusCodeIs(HttpStatus.OK); - processes.assertThat().paginationField("count").is("3"); - RestProcessModel process1 = processes.getEntries().get(0).onModel(); - RestProcessModel process2 = processes.getEntries().get(1).onModel(); - RestProcessModel process3 = processes.getEntries().get(2).onModel(); - - processes = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingParams("maxItems=2").getProcesses(); - restClient.assertStatusCodeIs(HttpStatus.OK); - processes.assertThat().paginationField("count").is("2"); - processes.assertThat().paginationField("maxItems").is("2"); - processes.assertThat().entriesListDoesNotContain("id", process3.getId()); - processes.getEntries().get(0).onModel().assertThat().field("id").is(process1.getId()); - processes.getEntries().get(1).onModel().assertThat().field("id").is(process2.getId()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify user gets processes when properties parameter is applied") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void getProcessesWithPropertiesParameter() throws Exception - { - RestProcessModelsCollection processes = restClient.authenticateUser(userWhoStartsTask).withParams("properties=id") - .withWorkflowAPI().getProcesses(); - restClient.assertStatusCodeIs(HttpStatus.OK); - List processesList = processes.getEntries(); - processesList.get(0).onModel().assertThat().fieldsCount().is(1) - .and().field("id").isNotEmpty() - .and().field("processDefinitionId").isNull() - .and().field("startUserId").isNull(); - processesList.get(1).onModel().assertThat().fieldsCount().is(1) - .and().field("id").isNotEmpty() - .and().field("processDefinitionId").isNull() - .and().field("startUserId").isNull(); - processesList.get(2).onModel().assertThat().fieldsCount().is(1) - .and().field("id").isNotEmpty() - .and().field("processDefinitionId").isNull() - .and().field("startUserId").isNull(); - processes.assertThat().entriesListIsNotEmpty() - .and().entriesListContains("id", process3.getId()) - .and().entriesListContains("id", task2.getProcessId()) - .and().entriesListContains("id", task1.getProcessId()); - } - - @Bug(id = "REPO-1958") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify user cannot get processes when using an invalid orderBy parameter") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void getProcessesWithInvalidOrderByParameter() throws Exception - { - restClient.authenticateUser(userWhoStartsTask).withParams("orderBy=test") - .withWorkflowAPI().getProcesses(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(String.format(RestErrorModel.INVALID_ORDERBY, "test", "processDefinitionId, startUserId, startActivityId,startedAt, id, completed, processDefinitionKey")) - .containsSummary(String.format(RestErrorModel.INVALID_ORDERBY, "test", "processDefinitionId, startUserId, startActivityId,startedAt, id, completed, processDefinitionKey")) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify user cannot get processes when using an invalid parameter in where clause") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void getProcessesWithInvalidWhereParameter() throws Exception - { - restClient.authenticateUser(userWhoStartsTask).where("startUserIdd='" + userWhoStartsTask.getUsername() + "'") - .withWorkflowAPI().getProcesses(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(RestErrorModel.INVALID_PROPERTY_ERRORKEY) - .containsSummary(String.format(RestErrorModel.PROPERTY_IS_NOT_SUPPORTED_EQUALS, "startUserIdd", userWhoStartsTask.getUsername())) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify user cannot get processes when using an invalid where clause expression") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void getProcessesWithInvalidWhereClauseExpression() throws Exception - { - restClient.authenticateUser(userWhoStartsTask).where("startUserId AND '" + userWhoStartsTask.getUsername() + "'") - .withWorkflowAPI().getProcesses(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(RestErrorModel.INVALID_QUERY_ERRORKEY) - .containsSummary(String.format(RestErrorModel.INVALID_WHERE_QUERY, "(startUserId AND '" + userWhoStartsTask.getUsername() + "')")) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessesSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessesSanityTests.java deleted file mode 100644 index 58d5b8032..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessesSanityTests.java +++ /dev/null @@ -1,78 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestProcessModelsCollection; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TaskModel; -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; - -/** - * Created by Claudia Agache on 10/11/2016. - */ -public class GetProcessesSanityTests extends RestTest -{ - private FileModel document; - private SiteModel siteModel; - private UserModel userWhoStartsTask, assignee, anotherUser; - private TaskModel task; - private RestProcessModelsCollection allProcesses; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - userWhoStartsTask = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - anotherUser = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - task = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Verify User gets all processes started by him using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) - public void getProcessesByUserWhoStartedProcess() throws Exception - { - allProcesses = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getProcesses(); - restClient.assertStatusCodeIs(HttpStatus.OK); - allProcesses.assertThat().entriesListContains("id", task.getProcessId()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Verify User gets all processes assigned to him using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) - public void getProcessesByAssignedUser() throws Exception - { - allProcesses = restClient.authenticateUser(assignee).withWorkflowAPI().getProcesses(); - restClient.assertStatusCodeIs(HttpStatus.OK); - allProcesses.assertThat().entriesListContains("id", task.getProcessId()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Verify User that is not involved in a process can not get that process using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) - public void getProcessesByAnotherUser() throws Exception - { - allProcesses = restClient.authenticateUser(anotherUser).withWorkflowAPI().getProcesses(); - restClient.assertStatusCodeIs(HttpStatus.OK); - allProcesses.assertThat().entriesListDoesNotContain("id", task.getProcessId()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Verify Admin gets all processes, even if he isn't involved in a process, using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) - public void getProcessesByAdmin() throws Exception - { - allProcesses = restClient.authenticateUser(dataUser.getAdminUser()).withWorkflowAPI().getProcesses(); - restClient.assertStatusCodeIs(HttpStatus.OK); - allProcesses.assertThat().entriesListContains("id", task.getProcessId()); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/AddProcessItemCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/AddProcessItemCoreTests.java deleted file mode 100644 index 86e6d4489..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/AddProcessItemCoreTests.java +++ /dev/null @@ -1,181 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes.items; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.core.RestRequest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestItemModel; -import org.alfresco.rest.model.RestItemModelsCollection; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.model.RestProcessModelsCollection; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class AddProcessItemCoreTests extends RestTest -{ - private FileModel document, document2; - private SiteModel siteModel; - private UserModel userWhoStartsProcess, assignee, adminUser, anotherUser; - private RestProcessModel processModel; - private RestItemModel processItem; - private RestItemModelsCollection processItems; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userWhoStartsProcess = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - document2 = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Add process item using by the user who started the process.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void addProcessItemByUserThatStartedTheProcess() throws Exception - { - processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); - - restClient.assertStatusCodeIs(HttpStatus.CREATED); - processItem.assertThat().field("createdAt").isNotEmpty().and().field("size").is("19").and().field("createdBy").is(adminUser.getUsername()).and() - .field("modifiedAt").isNotEmpty().and().field("name").is(document.getName()).and().field("modifiedBy").is(userWhoStartsProcess.getUsername()) - .and().field("id").isNotEmpty().and().field("mimeType").is(document.getFileType().mimeType); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Add multiple process items using by the user who started the process.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void addMultipleProcessItemsByUserThatStartedTheProcess() throws Exception - { - processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - processItems = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItems(document, document2); - - restClient.assertStatusCodeIs(HttpStatus.CREATED); - processItems.getEntries().get(0).onModel().assertThat() - .field("createdAt").isNotEmpty().and() - .field("size").is("19").and() - .field("createdBy").is(adminUser.getUsername()).and() - .field("modifiedAt").isNotEmpty().and() - .field("name").is(document.getName()).and() - .field("modifiedBy").is(userWhoStartsProcess.getUsername()).and() - .field("id").isNotEmpty().and() - .field("mimeType").is(document.getFileType().mimeType); - processItems.getEntries().get(1).onModel().assertThat() - .field("createdAt").isNotEmpty().and() - .field("size").is("19").and() - .field("createdBy").is(adminUser.getUsername()).and() - .field("modifiedAt").isNotEmpty().and() - .field("name").is(document2.getName()).and() - .field("modifiedBy").is(userWhoStartsProcess.getUsername()).and() - .field("id").isNotEmpty().and() - .field("mimeType").is(document2.getFileType().mimeType); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Add process item by a random user.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void addProcessItemByAnyUser() throws Exception - { - anotherUser = dataUser.createRandomTestUser(); - - document2 = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - processModel = restClient.authenticateUser(adminUser).withParams("maxItems=1").withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - processItem = restClient.authenticateUser(anotherUser).withWorkflowAPI().usingProcess(processModel).addProcessItem(document2); - - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsSummary(String.format(RestErrorModel.ACCESS_INFORMATION_NOT_ALLOWED, processModel.getId())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Add multiple process item by a random user.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void addMultipleProcessItemByAnyUser() throws Exception - { - anotherUser = dataUser.createRandomTestUser(); - - document2 = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - processModel = restClient.authenticateUser(adminUser).withParams("maxItems=1").withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - processItems = restClient.authenticateUser(anotherUser).withWorkflowAPI().usingProcess(processModel) - .addProcessItems(document2, document); - - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsSummary(String.format(RestErrorModel.ACCESS_INFORMATION_NOT_ALLOWED, processModel.getId())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding process item is falling in case of invalid process id is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void failedAddingProcessItemIfInvalidProcessIdIsProvided() throws Exception - { - RestProcessModelsCollection processes = restClient.authenticateUser(adminUser).withParams("maxItems=1").withWorkflowAPI().getProcesses(); - processModel = processes.assertThat().entriesListIsNotEmpty().when().getOneRandomEntry().onModel(); - FileModel testDocument = dataContent.usingAdmin().usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - - processModel.setId("invalidProcessId"); - processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(testDocument); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidProcessId")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding multiple process items is falling in case of invalid process id is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void failedAddingMultipleProcessItemsIfInvalidProcessIdIsProvided() throws Exception - { - RestProcessModelsCollection processes = restClient.authenticateUser(adminUser).withParams("maxItems=1").withWorkflowAPI().getProcesses(); - processModel = processes.assertThat().entriesListIsNotEmpty().when().getOneRandomEntry().onModel(); - FileModel testDocument = dataContent.usingAdmin().usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - - processModel.setId("invalidProcessId"); - processItems = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItems(testDocument, document); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidProcessId")); - } - - @Bug(id = "REPO-1937") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding process item is falling in case of invalid body item is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void failedAddingProcessItemIfInvalidItemBodyIsProvided() throws Exception - { - document.setNodeRef("invalidNodeRef"); - processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidId")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding multiple process items is falling in case of empty body item value is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void failedAddingMultipleProcessItemIfEmptyItemBodyIsProvided() throws Exception - { - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - document.setNodeRef(""); - processItems = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItems(document, document2); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.REQUIRED_TO_ADD, "itemId")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding process item is falling in case of incomplete body (empty) is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void failedAddingProcessItemIfIncompleteBodyIsProvided() throws Exception - { - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{}", "processes/{processId}/items", processModel.getId()); - restClient.processModel(RestItemModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.REQUIRED_TO_ADD, "itemId")); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/AddProcessItemFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/AddProcessItemFullTests.java deleted file mode 100644 index 49a8f28a2..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/AddProcessItemFullTests.java +++ /dev/null @@ -1,131 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes.items; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestItemModel; -import org.alfresco.rest.model.RestItemModelsCollection; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.ProcessModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class AddProcessItemFullTests extends RestTest -{ - private FileModel document, document2; - private SiteModel siteModel; - private UserModel userWhoStartsProcess, assignee, adminUser; - private ProcessModel processModel; - private RestItemModel processItem; - private RestItemModelsCollection processItems; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userWhoStartsProcess = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - document2 = dataContent.usingSite(siteModel).createContent(DocumentType.MSPOWERPOINT); - dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding multiple process items is falling in case of empty process id is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void failedAddingMultipleProcessItemsIfEmptyProcessIdIsProvided() throws Exception - { - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - FileModel testDocument = dataContent.usingAdmin().usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - - processModel.setId(""); - processItems = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItems(testDocument, document); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_WAS_NOT_FOUND, "")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding process items is falling in case of empty process id is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void failedAddingProcessItemsIfEmptyProcessIdIsProvided() throws Exception - { - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - FileModel testDocument = dataContent.usingAdmin().usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - - processModel.setId(""); - processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(testDocument); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_WAS_NOT_FOUND, "")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding process item is falling in case of empty body item value is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void failedAddingProcessItemIfEmptyItemBodyIsProvided() throws Exception - { - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - document.setNodeRef(""); - processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.REQUIRED_TO_ADD, "itemId")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding multiple process items is falling in case of empty body item value is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void failedAddingMultipleProcessItemsIfEmptyItemBodyIsProvided() throws Exception - { - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - document.setNodeRef(""); - - processItems = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItems(document, document2); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.REQUIRED_TO_ADD, "itemId")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Add a new process item, update the item and then delete.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void createDeleteCreateMultipleProcessItems() throws Exception - { - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - document2 = dataContent.usingAdmin().usingSite(siteModel).createContent(DocumentType.MSPOWERPOINT); - processItems = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItems(document, document2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.withWorkflowAPI().usingProcess(processModel).deleteProcessItem(processItems.getEntries().get(0).onModel()); - - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems() - .assertThat().entriesListDoesNotContain("name", processItems.getEntries().get(0).onModel().getName()); - - processItems = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItems(document); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Add a new process item, delete the item and create it again.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void createDeleteCreateProcessItem() throws Exception - { - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem( document2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.withWorkflowAPI().usingProcess(processModel).deleteProcessItem(processItem); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems() - .assertThat().entriesListDoesNotContain("name", processItem.getName()); - - processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems() - .assertThat().entriesListContains("name", processItem.getName()); - } - -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/AddProcessItemSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/AddProcessItemSanityTests.java deleted file mode 100644 index e31365974..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/AddProcessItemSanityTests.java +++ /dev/null @@ -1,175 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes.items; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestItemModel; -import org.alfresco.rest.model.RestItemModelsCollection; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FileType; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -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 AddProcessItemSanityTests extends RestTest -{ - private FileModel document, document2; - private SiteModel siteModel; - private UserModel userWhoStartsTask, assignee, adminUser; - private RestProcessModel processModel; - private RestItemModel processItem; - private RestItemModelsCollection processItems; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userWhoStartsTask = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Create non-existing process item") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY}) - public void addProcessItem() throws JsonToModelConversionException, Exception - { - document2 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file content"); - dataContent.usingSite(siteModel).createContent(document2); - - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - processItem.assertThat().field("createdAt").isNotEmpty() - .and().field("size").is(document2.getContent().length()) - .and().field("createdBy").is(adminUser.getUsername()) - .and().field("modifiedAt").isNotEmpty() - .and().field("name").is(document2.getName()) - .and().field("modifiedBy").is(adminUser.getUsername()) - .and().field("id").isNotEmpty() - .and().field("mimeType").is(document2.getFileType().mimeType); - - restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems() - .assertThat().entriesListContains("id", processItem.getId()); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Create non-existing process item") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY}) - public void addMultipleProcessItem() throws JsonToModelConversionException, Exception - { - document2 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file content"); - dataContent.usingSite(siteModel).createContent(document2); - document = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file content"); - dataContent.usingSite(siteModel).createContent(document); - - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - processItems = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItems(document2, document); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - processItems.getEntries().get(0).onModel() - .assertThat().field("createdAt").isNotEmpty() - .and().field("size").is(document2.getContent().length()) - .and().field("createdBy").is(adminUser.getUsername()) - .and().field("modifiedAt").isNotEmpty() - .and().field("name").is(document2.getName()) - .and().field("modifiedBy").is(adminUser.getUsername()) - .and().field("id").isNotEmpty() - .and().field("mimeType").is(document2.getFileType().mimeType); - - processItems.getEntries().get(1).onModel() - .assertThat().field("createdAt").isNotEmpty() - .and().field("size").is(document.getContent().length()) - .and().field("createdBy").is(adminUser.getUsername()) - .and().field("modifiedAt").isNotEmpty() - .and().field("name").is(document.getName()) - .and().field("modifiedBy").is(adminUser.getUsername()) - .and().field("id").isNotEmpty() - .and().field("mimeType").is(document.getFileType().mimeType); - - restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems() - .assertThat().entriesListContains("id", processItems.getEntries().get(0).onModel().getId()) - .assertThat().entriesListContains("id", processItems.getEntries().get(1).onModel().getId()); - } - - @Bug(id= "REPO-1927") - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Add process item that already exists") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY}) - public void addProcessItemThatAlreadyExists() throws JsonToModelConversionException, Exception - { - document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - processItem.assertThat().field("createdAt").isNotEmpty() - .and().field("size").is("19") - .and().field("createdBy").is(adminUser.getUsername()) - .and().field("modifiedAt").isNotEmpty() - .and().field("name").is(document2.getName()) - .and().field("modifiedBy").is(adminUser.getUsername()) - .and().field("id").isNotEmpty() - .and().field("mimeType").is(document2.getFileType().mimeType); - - restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems() - .assertThat().entriesListContains("id", processItem.getId()) - .and().entriesListContains("name", document2.getName()); - restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document2); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - } - - @Bug(id= "REPO-1927") - @TestRail(section = {TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Add process item that already exists") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY}) - public void addMultipleProcessItemThatAlreadyExists() throws JsonToModelConversionException, Exception - { - document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - document = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - processItems = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItems(document2, document); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - processItems.getEntries().get(0).onModel() - .assertThat().field("createdAt").isNotEmpty() - .and().field("size").is("19") - .and().field("createdBy").is(adminUser.getUsername()) - .and().field("modifiedAt").isNotEmpty() - .and().field("name").is(document2.getName()) - .and().field("modifiedBy").is(adminUser.getUsername()) - .and().field("id").isNotEmpty() - .and().field("mimeType").is(document2.getFileType().mimeType); - - processItems.getEntries().get(1).onModel() - .assertThat().field("createdAt").isNotEmpty() - .and().field("size").is("19") - .and().field("createdBy").is(adminUser.getUsername()) - .and().field("modifiedAt").isNotEmpty() - .and().field("name").is(document.getName()) - .and().field("modifiedBy").is(adminUser.getUsername()) - .and().field("id").isNotEmpty() - .and().field("mimeType").is(document.getFileType().mimeType); - - restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems() - .assertThat().entriesListContains("id", processItems.getEntries().get(0).onModel().getId()) - .and().entriesListContains("name", document2.getName()) - .assertThat().entriesListContains("id", processItems.getEntries().get(1).onModel().getId()) - .and().entriesListContains("name", document.getName()); - - restClient.withWorkflowAPI().usingProcess(processModel).addProcessItems(document2, document); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/DeleteProcessItemCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/DeleteProcessItemCoreTests.java deleted file mode 100644 index ae9d60211..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/DeleteProcessItemCoreTests.java +++ /dev/null @@ -1,85 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes.items; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestItemModel; -import org.alfresco.rest.model.RestItemModelsCollection; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.ProcessModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class DeleteProcessItemCoreTests extends RestTest -{ - private FileModel document, secondDoc; - private SiteModel siteModel; - private UserModel userWhoStartsTask, assignee; - private RestProcessModel restProcessModel; - private ProcessModel processModel; - private RestItemModelsCollection items; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - userWhoStartsTask = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - processModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document) - .createSingleReviewerTaskAndAssignTo(assignee); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Delete process item with invalid id") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void deleteProcessItemWithInvalidItemId() throws Exception - { - restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() - .getProcesses().getProcessModelByProcessDefId(processModel.getId()); - secondDoc = dataContent.usingUser(userWhoStartsTask).usingSite(siteModel).createContent(DocumentType.MSWORD); - RestItemModel processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(secondDoc); - processItem.setId("invalid-id"); - restClient.withWorkflowAPI().usingProcess(processModel).deleteProcessItem(processItem); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.PROCESS_ENTITY_NOT_FOUND, "invalid-id")); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Delete process item with empty id") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void deleteProcessItemWithEmptyItemId() throws Exception - { - restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() - .getProcesses().getProcessModelByProcessDefId(processModel.getId()); - secondDoc = dataContent.usingUser(userWhoStartsTask).usingSite(siteModel).createContent(DocumentType.MSWORD); - RestItemModel processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(secondDoc); - processItem.setId(""); - restClient.withWorkflowAPI().usingProcess(processModel).deleteProcessItem(processItem); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) - .assertLastError().containsSummary(String.format(RestErrorModel.DELETE_EMPTY_ARGUMENT)); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Delete process item twice") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void deleteProcessItemTwice() throws Exception - { - restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() - .getProcesses().getProcessModelByProcessDefId(processModel.getId()); - items = restClient.withWorkflowAPI().usingProcess(restProcessModel).getProcessItems(); - RestItemModel processItem = items.getEntries().get(0); - restClient.withWorkflowAPI().usingProcess(processModel).deleteProcessItem(processItem.onModel()); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withWorkflowAPI().usingProcess(processModel).deleteProcessItem(processItem.onModel()); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.PROCESS_ENTITY_NOT_FOUND, processItem.onModel().getId())); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/DeleteProcessItemFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/DeleteProcessItemFullTests.java deleted file mode 100644 index 2be92a1aa..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/DeleteProcessItemFullTests.java +++ /dev/null @@ -1,215 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes.items; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.exception.EmptyRestModelCollectionException; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestItemModel; -import org.alfresco.rest.model.RestItemModelsCollection; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.ProcessModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class DeleteProcessItemFullTests extends RestTest -{ - private FileModel document, document2; - private SiteModel siteModel; - private UserModel userWhoStartsProcess, assignee, adminUser, anotherUser; - private ProcessModel processModel; - private RestItemModelsCollection items; - private RestItemModel processItem; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userWhoStartsProcess = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userWhoStartsProcess).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Try to delete existing process item using empty processId") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void deleteProcessItemUsingEmptyProcessId() throws Exception - { - processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI() - .addProcess("activitiAdhoc", assignee, false, Priority.Normal); - document2 = dataContent.usingAdmin().usingSite(siteModel).createContent(DocumentType.MSPOWERPOINT); - processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - processModel.setId(""); - restClient.withWorkflowAPI().usingProcess(processModel).deleteProcessItem(processItem); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "The entity with id: ")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Add a new process item, update the item and then delete.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void createUpdateDeleteProcessItem() throws Exception - { - processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI() - .addProcess("activitiAdhoc", assignee, false, Priority.Normal); - document2 = dataContent.usingAdmin().usingSite(siteModel).createContent(DocumentType.MSPOWERPOINT); - processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - processItem.setName("newItemName"); - processItem.assertThat().field("name").is("newItemName"); - - restClient.withWorkflowAPI().usingProcess(processModel).deleteProcessItem(processItem); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems() - .assertThat().entriesListDoesNotContain("name", processItem.getName()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Delete process item using any user.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void deleteProcessItemByAnyUser() throws Exception - { - anotherUser = dataUser.createRandomTestUser(); - - document2 = dataContent.usingAdmin().usingSite(siteModel).createContent(DocumentType.HTML); - processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(anotherUser).withWorkflowAPI().usingProcess(processModel) - .deleteProcessItem(processItem); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError() - .containsSummary(String.format(RestErrorModel.ACCESS_INFORMATION_NOT_ALLOWED, processModel.getId())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .containsErrorKey(String.format(RestErrorModel.ACCESS_INFORMATION_NOT_ALLOWED, processModel.getId())) - .stackTraceIs(RestErrorModel.STACKTRACE);; - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Delete process item with admin.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void deleteProcessItemWithAdmin() throws Exception - { - processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI() - .addProcess("activitiAdhoc", assignee, false, Priority.Normal); - - document2 = dataContent.usingAdmin().usingSite(siteModel).createContent(DocumentType.HTML); - processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(adminUser).withWorkflowAPI().usingProcess(processModel) - .deleteProcessItem(processItem); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() - .assertThat().entriesListDoesNotContain("name", processItem.getName()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Delete process item by the user who is involved in the process.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void deleteProcessItemByUserInvolvedInTheProcess() throws Exception - { - processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI() - .addProcess("activitiAdhoc", assignee, false, Priority.Normal); - - processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(processModel) - .deleteProcessItem(processItem); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() - .assertThat().entriesListDoesNotContain("name", processItem.getName()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Delete process item by the user who started the process.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void deleteProcessItemByUserThatStartedTheProcess() throws Exception - { - processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI() - .addProcess("activitiAdhoc", assignee, false, Priority.Normal); - processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingProcess(processModel) - .deleteProcessItem(processItem); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() - .assertThat().entriesListDoesNotContain("name", processItem.getName()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Delete process item for a deleted process.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void deleteProcessItemsForDeletedProcess() throws Exception - { - processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI() - .addProcess("activitiAdhoc", assignee, false, Priority.Normal); - processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.withWorkflowAPI().usingProcess(processModel).deleteProcess(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withWorkflowAPI().usingProcess(processModel).deleteProcessItem(processItem); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, processModel.getId())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Delete process item by inexistent user.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void deleteProcessItemByInexistentUser() throws Exception - { - processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI() - .addProcess("activitiAdhoc", assignee, false, Priority.Normal); - processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(UserModel.getRandomUserModel()).withWorkflowAPI().usingProcess(processModel) - .deleteProcessItem(processItem); - - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Delete process item for process without items.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION}, - expectedExceptions = EmptyRestModelCollectionException.class) - public void deleteProcessItemsForProcessWithoutItems() throws Exception - { - processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI() - .addProcess("activitiAdhoc", assignee, false, Priority.Normal); - - items = restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems(); - restClient.assertStatusCodeIs(HttpStatus.OK); - items.assertThat().entriesListIsEmpty(); - - restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingProcess(processModel) - .deleteProcessItem(items.getOneRandomEntry()); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/DeleteProcessItemSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/DeleteProcessItemSanityTests.java deleted file mode 100644 index 341dc6fa1..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/DeleteProcessItemSanityTests.java +++ /dev/null @@ -1,67 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes.items; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestItemModel; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.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 DeleteProcessItemSanityTests extends RestTest -{ - private FileModel document, document2; - private SiteModel siteModel; - private UserModel userWhoStartsTask, assignee, adminUser; - private RestProcessModel processModel; - private RestItemModel processItem; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userWhoStartsTask = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); - } - - @TestRail(section = {TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Delete existing process item") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) - public void deleteProcessItem() throws Exception - { - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - document2 = dataContent.usingAdmin().usingSite(siteModel).createContent(DocumentType.MSWORD); - processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.withWorkflowAPI().usingProcess(processModel).deleteProcessItem(processItem); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems() - .assertThat().entriesListDoesNotContain("id", processItem.getId()); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Try to delete existing process item using invalid processId") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) - public void deleteProcessItemUsingInvalidProcessId() throws Exception - { - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - document2 = dataContent.usingAdmin().usingSite(siteModel).createContent(DocumentType.MSPOWERPOINT); - processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - processModel.setId("incorrectProcessId"); - restClient.withWorkflowAPI().usingProcess(processModel).deleteProcessItem(processItem); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/GetProcessItemsCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/GetProcessItemsCoreTests.java deleted file mode 100644 index c121a9d47..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/GetProcessItemsCoreTests.java +++ /dev/null @@ -1,70 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes.items; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class GetProcessItemsCoreTests extends RestTest -{ - private FileModel document; - private SiteModel siteModel; - private UserModel adminUser, userWhoStartsTask, assignee; - private RestProcessModel processModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userWhoStartsTask = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin calling getProcessItems can see anything with REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void getProcessItemsAsAdminReturnsAnything() throws Exception - { - processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); - - restClient.authenticateUser(adminUser).withWorkflowAPI().usingProcess(processModel).getProcessItems().assertThat().entriesListIsNotEmpty(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify getProcessItems for invalid processId with REST API and status code is NOT_FOUND (404)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void getProcessItemsForInvalidProcessId() throws Exception - { - processModel = restClient.authenticateUser(assignee).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - processModel.setId("invalidProcessId"); - restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems().assertThat().entriesListIsEmpty(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidProcessId")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify getProcessItems for empty processId with REST API and status code is NOT_FOUND (404)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void getProcessItemsForEmptyProcessId() throws Exception - { - processModel = restClient.authenticateUser(assignee).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - processModel.setId(""); - restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems().assertThat().entriesListIsEmpty(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/GetProcessItemsFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/GetProcessItemsFullTests.java deleted file mode 100644 index b22e118db..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/GetProcessItemsFullTests.java +++ /dev/null @@ -1,198 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes.items; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestItemModelsCollection; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Created by Claudia Agache on 2/2/2017. - */ -public class GetProcessItemsFullTests extends RestTest -{ - private FileModel document1, document2, document3; - private SiteModel siteModel; - private UserModel userWhoStartsTask, assignee; - private RestProcessModel processModel; - private RestItemModelsCollection items; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - userWhoStartsTask = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); - document1 = dataContent.usingUser(userWhoStartsTask).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - document2 = dataContent.usingUser(userWhoStartsTask).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - document3 = dataContent.usingUser(userWhoStartsTask).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Get process items for process without items") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION}) - public void getProcessItemsForProcessWithoutItems() throws Exception - { - processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.Normal); - items = restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems(); - restClient.assertStatusCodeIs(HttpStatus.OK); - items.assertThat().entriesListIsEmpty(); - } - - @Bug(id = "REPO-1989") - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Get process items for process with valid skipCount parameter") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION}) - public void getProcessItemsWithValidSkipCount() throws Exception - { - processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.Normal); - restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document1); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document3); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - items = restClient.authenticateUser(assignee).withParams("skipCount=2").withWorkflowAPI().usingProcess(processModel).getProcessItems(); - restClient.assertStatusCodeIs(HttpStatus.OK); - items.assertThat().entriesListContains("name", document3.getName()) - .assertThat().entriesListDoesNotContain("name", document1.getName()) - .assertThat().entriesListDoesNotContain("name", document2.getName()) - .assertThat().entriesListCountIs(1) - .assertThat().paginationField("skipCount").is("2"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Get process items for process with negative skipCount") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION}) - public void getProcessItemsWithNegativeSkipCount() throws Exception - { - processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.Normal); - restClient.authenticateUser(assignee).withParams("skipCount=-2").withWorkflowAPI().usingProcess(processModel).getProcessItems(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT) - .containsErrorKey(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE) - .statusCodeIs(HttpStatus.BAD_REQUEST); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Get process items for process with non numeric skipCount") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION}) - public void getProcessItemsWithNonNumericSkipCount() throws Exception - { - processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.Normal); - restClient.authenticateUser(assignee).withParams("skipCount=A").withWorkflowAPI().usingProcess(processModel).getProcessItems(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "A")); - } - - @Bug(id = "MNT-17438") - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Get process items for process with valid maxItems parameter") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION}) - public void getProcessItemsWithValidMaxItems() throws Exception - { - processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.Normal); - restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document1); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document3); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - items = restClient.authenticateUser(assignee).withParams("maxItems=2").withWorkflowAPI().usingProcess(processModel).getProcessItems(); - restClient.assertStatusCodeIs(HttpStatus.OK); - items.assertThat().entriesListDoesNotContain("name", document3.getName()) - .assertThat().entriesListContains("name", document1.getName()) - .assertThat().entriesListContains("name", document2.getName()) - .assertThat().entriesListCountIs(2) - .assertThat().paginationField("maxItems").is("2"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Get process items for process with negative maxItems") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION}) - public void getProcessItemsWithNegativeMaxItems() throws Exception - { - processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.Normal); - restClient.authenticateUser(assignee).withParams("maxItems=-2").withWorkflowAPI().usingProcess(processModel).getProcessItems(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) - .containsErrorKey(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE) - .statusCodeIs(HttpStatus.BAD_REQUEST); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Get process items for process with non numeric maxItems") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION}) - public void getProcessItemsWithNonNumericMaxItems() throws Exception - { - processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.Normal); - restClient.authenticateUser(assignee).withParams("maxItems=A").withWorkflowAPI().usingProcess(processModel).getProcessItems(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "A")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify get all process items with properties parameter.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void getProcessItemsWithPropertiesParameter() throws Exception - { - processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.Normal); - restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document1); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - items = restClient.authenticateUser(assignee).withParams("properties=createdBy,name,mimeType,size").withWorkflowAPI().usingProcess(processModel).getProcessItems(); - restClient.assertStatusCodeIs(HttpStatus.OK); - items.assertThat().entriesListIsNotEmpty(); - items.getProcessItemByName(document1.getName()) - .assertThat().field("createdBy").is(userWhoStartsTask.getUsername()) - .assertThat().field("name").is(document1.getName()) - .assertThat().field("mimeType").is(document1.getFileType().mimeType) - .assertThat().field("size").isNotNull() - .assertThat().field("modifiedAt").isNull() - .assertThat().field("modifiedBy").isNull() - .assertThat().field("id").isNull() - .assertThat().field("createdAt ").isNull() - .assertThat().fieldsCount().is(4); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify get all process items after process is deleted.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void getProcessItemsAfterDeletingProcess() throws Exception - { - processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.Normal); - restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document1); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.withWorkflowAPI().usingProcess(processModel).deleteProcess(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - items = restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(processModel).getProcessItems(); - restClient.assertStatusCodeIs(HttpStatus.OK); - items.assertThat().entriesListIsNotEmpty(); - items.getProcessItemByName(document1.getName()) - .assertThat().field("createdBy").is(userWhoStartsTask.getUsername()) - .assertThat().field("name").is(document1.getName()) - .assertThat().field("mimeType").is(document1.getFileType().mimeType) - .assertThat().field("size").isNotNull() - .assertThat().field("modifiedAt").isNotNull() - .assertThat().field("modifiedBy").is(userWhoStartsTask.getUsername()) - .assertThat().field("id").is(document1.getNodeRefWithoutVersion()) - .assertThat().field("createdAt ").isNotNull(); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/GetProcessItemsSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/GetProcessItemsSanityTests.java deleted file mode 100644 index 5b293fd0d..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/GetProcessItemsSanityTests.java +++ /dev/null @@ -1,59 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes.items; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestItemModelsCollection; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.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 GetProcessItemsSanityTests extends RestTest -{ - private FileModel document; - private SiteModel siteModel; - private UserModel userWhoStartsTask, assignee; - private RestProcessModel processModel; - private RestItemModelsCollection items; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - userWhoStartsTask = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); - document = dataContent.usingUser(userWhoStartsTask).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Verify that user that started the process gets all process items") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) - public void getProcessItemsUsingTheUserWhoStartedProcess() throws Exception - { - processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - items = restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems(); - restClient.assertStatusCodeIs(HttpStatus.OK); - items.assertThat().entriesListIsNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Verify that user that is involved in the process gets all process items") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) - public void getProcessItemsUsingUserInvolvedInProcess() throws Exception - { - processModel = restClient.authenticateUser(assignee).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - items = restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems(); - restClient.assertStatusCodeIs(HttpStatus.OK); - items.assertThat().entriesListIsNotEmpty(); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/tasks/GetProcessTasksCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/tasks/GetProcessTasksCoreTests.java deleted file mode 100644 index fc6b6d3bc..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/tasks/GetProcessTasksCoreTests.java +++ /dev/null @@ -1,98 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes.tasks; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestTaskModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.GroupModel; -import org.alfresco.utility.model.ProcessModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class GetProcessTasksCoreTests extends RestTest -{ - private FileModel document, document1, document2; - private SiteModel siteModel; - private UserModel userWhoStartsProcess, candidate, anotherAssignee, assignee; - private ProcessModel process; - private GroupModel group; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - userWhoStartsProcess = dataUser.createRandomTestUser(); - candidate = dataUser.createRandomTestUser(); - anotherAssignee = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userWhoStartsProcess).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - document1 = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - document2 = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - process = dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document) - .createSingleReviewerTaskAndAssignTo(assignee); - group = dataGroup.createRandomGroup(); - dataGroup.addListOfUsersToGroup(group, candidate); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "getProcessTasks with user that is candidate with REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void getProcessTasksWithUserThatIsCandidate() throws Exception - { - ProcessModel processModel = dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document1) - .createGroupReviewTaskAndAssignTo(group); - - restClient.authenticateUser(candidate).withWorkflowAPI() - .usingProcess(processModel).getProcessTasks().assertThat().entriesListIsNotEmpty() - .and().entriesListContains("assignee", candidate.getUsername()); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "getProcessTasks for invalid processId with REST API and status code is NOT_FOUND (404)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void getProcessTasksUsingInvalidProcessId() throws Exception - { - ProcessModel processModel = process; - processModel.setId("invalidProcessId"); - restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI() - .usingProcess(processModel).getProcessTasks().assertThat().entriesListIsEmpty(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "getProcessTasks for empty processId with REST API and status code is NOT_FOUND (404)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void getProcessTasksUsingEmptyProcessId() throws Exception - { - ProcessModel processModel = process; - processModel.setId(""); - restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI() - .usingProcess(processModel).getProcessTasks().assertThat().entriesListIsEmpty(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "User completes task then getProcessTasks with REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void completeTaskThenGetProcessTasks() throws Exception - { - ProcessModel processModel = dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document2) - .createMoreReviewersWorkflowAndAssignTo(anotherAssignee); - RestTaskModel restTaskModel = restClient.authenticateUser(anotherAssignee).withWorkflowAPI() - .usingProcess(processModel).getProcessTasks().assertThat().entriesListIsNotEmpty().getOneRandomEntry().onModel(); - restTaskModel = restClient.withParams("select=state").withWorkflowAPI().usingTask(restTaskModel).updateTask("completed"); - restTaskModel.assertThat().field("id").is(restTaskModel.getId()).and().field("state").is("completed"); - restClient.withWorkflowAPI().getTasks().assertThat().entriesListIsEmpty(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/tasks/GetProcessTasksFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/tasks/GetProcessTasksFullTests.java deleted file mode 100644 index bdd935e42..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/tasks/GetProcessTasksFullTests.java +++ /dev/null @@ -1,207 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes.tasks; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestTaskModelsCollection; -import org.alfresco.utility.model.*; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Created by Claudia Agache on 2/3/2017. - */ -public class GetProcessTasksFullTests extends RestTest -{ - private FileModel document; - private SiteModel publicSite; - private UserModel adminUser, userWhoStartsProcess, assignee1, assignee2, assignee3; - private ProcessModel processWithSingleTask, processWithMultipleTasks; - private RestTaskModelsCollection processTasks; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userWhoStartsProcess = dataUser.createRandomTestUser(); - assignee1 = dataUser.createRandomTestUser("A_1"); - assignee2 = dataUser.createRandomTestUser("B_2"); - assignee3 = dataUser.createRandomTestUser("C_3"); - publicSite = dataSite.usingUser(userWhoStartsProcess).createPublicRandomSite(); - document = dataContent.usingSite(publicSite).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - processWithSingleTask = dataWorkflow.usingUser(userWhoStartsProcess).usingSite(publicSite).usingResource(document) - .createSingleReviewerTaskAndAssignTo(assignee1); - processWithMultipleTasks = dataWorkflow.usingUser(userWhoStartsProcess).usingSite(publicSite).usingResource(document) - .createMoreReviewersWorkflowAndAssignTo(assignee1, assignee2, assignee3); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify admin user is able to getProcessTasks even if he wasn't involved in process. Check status code is OK") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void getProcessTasksWithAdmin() throws Exception - { - processTasks = restClient.authenticateUser(adminUser).withWorkflowAPI() - .usingProcess(processWithSingleTask).getProcessTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - processTasks.assertThat().entriesListCountIs(1) - .and().entriesListContains("assignee", assignee1.getUsername()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Get process tasks with valid skipCount parameter applied") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION}) - public void getProcessTasksWithValidSkipCount() throws Exception - { - processTasks = restClient.authenticateUser(userWhoStartsProcess) - .withParams("orderBy=assignee ASC&skipCount=2").withWorkflowAPI() - .usingProcess(processWithMultipleTasks).getProcessTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - processTasks.assertThat().entriesListContains("assignee", assignee3.getUsername()) - .assertThat().entriesListDoesNotContain("assignee", assignee1.getUsername()) - .assertThat().entriesListDoesNotContain("assignee", assignee2.getUsername()) - .assertThat().entriesListCountIs(1) - .assertThat().paginationField("skipCount").is("2"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Get process tasks with negative skipCount parameter applied") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION}) - public void getProcessTasksWithNegativeSkipCount() throws Exception - { - restClient.authenticateUser(userWhoStartsProcess) - .withParams("skipCount=-2").withWorkflowAPI() - .usingProcess(processWithMultipleTasks).getProcessTasks(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT) - .containsErrorKey(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE) - .statusCodeIs(HttpStatus.BAD_REQUEST); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Get process tasks with non numeric skipCount parameter applied") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION}) - public void getProcessTasksWithNonNumericSkipCount() throws Exception - { - restClient.authenticateUser(userWhoStartsProcess) - .withParams("skipCount=A").withWorkflowAPI() - .usingProcess(processWithMultipleTasks).getProcessTasks(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "A")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Get process tasks with valid maxItems parameter applied") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION}) - public void getProcessTasksWithValidMaxItems() throws Exception - { - processTasks = restClient.authenticateUser(userWhoStartsProcess) - .withParams("orderBy=assignee ASC&maxItems=2").withWorkflowAPI() - .usingProcess(processWithMultipleTasks).getProcessTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - processTasks.assertThat().entriesListDoesNotContain("assignee", assignee3.getUsername()) - .assertThat().entriesListContains("assignee", assignee1.getUsername()) - .assertThat().entriesListContains("assignee", assignee2.getUsername()) - .assertThat().entriesListCountIs(2) - .assertThat().paginationField("maxItems").is("2"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Get process tasks with negative maxItems parameter applied") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION}) - public void getProcessTasksWithNegativeMaxItems() throws Exception - { - restClient.authenticateUser(userWhoStartsProcess) - .withParams("maxItems=-2").withWorkflowAPI() - .usingProcess(processWithMultipleTasks).getProcessTasks(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) - .containsErrorKey(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE) - .statusCodeIs(HttpStatus.BAD_REQUEST); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Get process tasks with non numeric maxItems parameter applied") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION}) - public void getProcessTasksWithNonNumericMaxItems() throws Exception - { - restClient.authenticateUser(userWhoStartsProcess) - .withParams("maxItems=A").withWorkflowAPI() - .usingProcess(processWithMultipleTasks).getProcessTasks(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "A")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify getProcessTasks with properties parameter") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void getProcessTasksWithPropertiesParameter() throws Exception - { - processTasks = restClient.authenticateUser(adminUser) - .withParams("properties=name,assignee,state").withWorkflowAPI() - .usingProcess(processWithSingleTask).getProcessTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - processTasks.assertThat().entriesListCountIs(1); - processTasks.getOneRandomEntry().onModel().assertThat() - .field("dueAt").isNull().and() - .field("processDefinitionId").isNull().and() - .field("processId").isNull().and() - .field("description").isNull().and() - .field("startedAt").isNull().and() - .field("id").isNull().and() - .field("activityDefinitionId").isNull().and() - .field("priority").isNull().and() - .field("formResourceKey").isNull().and() - .field("name").is("Review Task").and() - .field("state").is("claimed").and() - .field("assignee").is(assignee1.getUsername()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify admin gets Process Tasks ordered by assignee ascendant using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void getProcessTasksOrderedByAssignee() throws Exception - { - processTasks = restClient.authenticateUser(adminUser) - .withParams("orderBy=assignee").withWorkflowAPI() - .usingProcess(processWithMultipleTasks).getProcessTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - processTasks.assertThat().entriesListIsSortedAscBy("assignee"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify admin doesn't get Process Tasks ordered by many fields") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void getProcessTasksOrderedByMultipleFields() throws Exception - { - restClient.authenticateUser(adminUser) - .withParams("orderBy=assignee,state").withWorkflowAPI() - .usingProcess(processWithMultipleTasks).getProcessTasks(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary("Only one order by parameter is supported"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify get all process tasks after process is deleted.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void getProcessTasksAfterDeletingProcess() throws Exception - { - ProcessModel processModel = dataWorkflow.usingUser(userWhoStartsProcess).usingSite(publicSite).usingResource(document) - .createSingleReviewerTaskAndAssignTo(assignee1); - - restClient.authenticateUser(adminUser).withWorkflowAPI().usingProcess(processModel).deleteProcess(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - processTasks = restClient.authenticateUser(adminUser).withWorkflowAPI() - .usingProcess(processModel).getProcessTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - processTasks.assertThat().entriesListIsEmpty(); - } - -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/tasks/GetProcessTasksSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/tasks/GetProcessTasksSanityTests.java deleted file mode 100644 index f94b72e14..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/tasks/GetProcessTasksSanityTests.java +++ /dev/null @@ -1,86 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes.tasks; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestTaskModelsCollection; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.ProcessModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Tests for GET "/processes/{processId}/tasks" REST API call - * - * @author Cristina Axinte - */ -public class GetProcessTasksSanityTests extends RestTest -{ - private FileModel document; - private SiteModel siteModel; - private UserModel userModel, assignee1, assignee2, assignee3; - private ProcessModel process; - private RestTaskModelsCollection processTasks; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - assignee1 = dataUser.createRandomTestUser(); - assignee2 = dataUser.createRandomTestUser(); - assignee3 = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - process = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(document) - .createMoreReviewersWorkflowAndAssignTo(assignee1, assignee2, assignee3); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Verify user who started the process gets all tasks of started process with Rest API and response is successfull (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) - public void userWhoStartedProcessCanGetProcessTasks() throws JsonToModelConversionException, Exception - { - processTasks = restClient.authenticateUser(userModel).withWorkflowAPI().usingProcess(process).getProcessTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - processTasks.assertThat() - .entriesListCountIs(3).and() - .entriesListContains("assignee", assignee1.getUsername()).and() - .entriesListContains("assignee", assignee2.getUsername()).and() - .entriesListContains("assignee", assignee3.getUsername()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Verify any assignee user of the process gets all tasks of the process with Rest API and response is successfull (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) - public void assigneeUserCanGetAllProcessTasks() throws JsonToModelConversionException, Exception - { - processTasks = restClient.authenticateUser(assignee1).withWorkflowAPI().usingProcess(process).getProcessTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - processTasks.assertThat() - .entriesListContains("assignee", assignee1.getUsername()).and() - .entriesListContains("assignee", assignee2.getUsername()).and() - .entriesListContains("assignee", assignee3.getUsername()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Verify any assignee user of the process gets all tasks of the process with Rest API and response is successfull (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) - public void involvedUserCanGetAllProcessTasks() throws JsonToModelConversionException, Exception - { - ProcessModel process = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(document) - .createMoreReviewersWorkflowAndAssignTo(assignee1, assignee2, assignee3); - dataWorkflow.usingUser(assignee1).approveTask(process); - - processTasks = restClient.authenticateUser(assignee2).withWorkflowAPI().usingProcess(process).getProcessTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - processTasks.assertThat() - .entriesListIsNotEmpty().assertThat() - .entriesListContains("assignee", userModel.getUsername()); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariableCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariableCoreTests.java deleted file mode 100644 index 6bed60292..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariableCoreTests.java +++ /dev/null @@ -1,188 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes.variables; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.rest.core.RestRequest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.model.RestProcessVariableModel; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class AddProcessVariableCoreTests extends RestTest -{ - private FileModel document; - private SiteModel siteModel; - private UserModel userWhoStartsProcess, assignee, adminUser, anotherUser; - private RestProcessModel processModel; - private RestProcessVariableModel variableModel, processVariable; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - anotherUser = dataUser.createRandomTestUser(); - userWhoStartsProcess = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userWhoStartsProcess).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Add process variable using by the user who started the process.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void addProcessVariableByUserThatStartedTheProcess() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); - - processVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - processVariable.assertThat().field("name").is(variableModel.getName()) - .and().field("type").is(variableModel.getType()) - .and().field("value").is(variableModel.getValue()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Add process variable using by a random user.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void addProcessVariableByAnyUser() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(anotherUser).withWorkflowAPI().addProcess("activitiAdhoc", anotherUser, false, Priority.Normal); - - processVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - processVariable.assertThat().field("name").is(variableModel.getName()) - .and().field("type").is(variableModel.getType()) - .and().field("value").is(variableModel.getValue()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding process variable is falling in case invalid type is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void failedAddingProcessVariableIfInvalidTypeIsProvided() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:textarea"); - - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsErrorKey(String.format(RestErrorModel.UNSUPPORTED_TYPE, "d:textarea")) - .containsSummary(String.format(RestErrorModel.UNSUPPORTED_TYPE, "d:textarea")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Bug(id = "REPO-1938") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding process variable is falling in case invalid type prefix is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void failedAddingProcessVariableIfInvalidTypePrefixIsProvided() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("ddt:text"); - - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .containsSummary(String.format(RestErrorModel.INVALID_NAMEPACE_PREFIX, "ddt")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding process variable is falling in case invalid value is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void failedAddingProcessVariableIfInvalidValueIsProvided() throws Exception - { - RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:int"); - variableModel.setValue("invalidValue"); - - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .containsSummary(String.format(RestErrorModel.FOR_INPUT_STRING, "invalidValue")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding process variable is falling in case missing required variable body (name) is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void failedAddingProcessVariableIfMissingRequiredVariableNameBodyIsProvided() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"value\": \"missingVariableName\",\"type\": \"d:text\"}", - "processes/{processId}/variables/{variableName}", processModel.getId(), variableModel.getName()); - restClient.processModel(RestProcessVariableModel.class, request); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsErrorKey(RestErrorModel.VARIABLE_NAME_REQUIRED) - .containsSummary(RestErrorModel.VARIABLE_NAME_REQUIRED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding process variable is falling in case invalid variableBody (adding extra parameter in body) is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void failedAddingProcessVariableIfInvalidBodyIsProvided() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"scope\": \"local\",\"value\": \"testing\",\"type\": \"d:text\"}", - "processes/{processId}/variables/{variableName}", processModel.getId(), variableModel.getName()); - restClient.processModel(RestProcessVariableModel.class, request); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "Unrecognized field \"scope\"")) - .containsSummary(String.format(RestErrorModel.NO_CONTENT, "Unrecognized field \"scope\"")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding process variable is falling in case empty name is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void failedAddingProcessVariableIfEmptyNameIsProvided() throws Exception - { - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); - RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - variableModel.setName(""); - - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); - - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) - .assertLastError() - .containsErrorKey(RestErrorModel.PUT_EMPTY_ARGUMENT) - .containsSummary(RestErrorModel.PUT_EMPTY_ARGUMENT) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariableFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariableFullTests.java deleted file mode 100644 index 63abe5c76..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariableFullTests.java +++ /dev/null @@ -1,182 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes.variables; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.core.RestRequest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.model.RestProcessVariableModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.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 AddProcessVariableFullTests extends RestTest -{ - private FileModel document; - private SiteModel siteModel; - private UserModel userWhoStartsProcess, assignee, adminUser; - private RestProcessModel processModel; - private RestProcessVariableModel variableModel, processVariable, updatedProcessVariable; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userWhoStartsProcess = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userWhoStartsProcess).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify addProcessVariable by any user for invalid processID with REST API and status code is NOT_FOUND (404)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void addProcessVariableWithInvalidProcessId() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - processModel.setId("invalidProcessID"); - - processVariable = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingProcess(processModel) - .updateProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidProcessID")); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify addProcessVariable by any user for empty processID with REST API and status code is NOT_FOUND (404)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void addProcessVariableWithEmptyProcessId() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - processModel.setId(""); - - processVariable = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingProcess(processModel) - .updateProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding process variable in case of having only 'name' field is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void addingProcessVariableWithOnlyNameProvided() throws Exception - { - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"name\": \"variableName\"}", - "processes/{processId}/variables/{variableName}", processModel.getId(), "variableName"); - processVariable = restClient.processModel(RestProcessVariableModel.class, request); - - restClient.assertStatusCodeIs(HttpStatus.OK); - processVariable.assertThat().field("name").is("variableName") - .and().field("type").is("d:any") - .and().field("value").isNull(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding process variable in case of missing type field is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void addingProcessVariableIfMissingValueIsProvided() throws Exception - { - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"name\": \"variableName\", \"type\": \"d:text\"}", - "processes/{processId}/variables/{variableName}", processModel.getId(), "variableName"); - processVariable = restClient.processModel(RestProcessVariableModel.class, request); - - restClient.assertStatusCodeIs(HttpStatus.OK); - processVariable.assertThat().field("name").is("variableName") - .and().field("type").is("d:text") - .and().field("value").isNull(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding process variable in case of missing type field is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void addingProcessVariableIfMissingTypeIsProvided() throws Exception - { - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"value\": \"variableValue\", \"name\": \"variableName\"}", - "processes/{processId}/variables/{variableName}", processModel.getId(), "variableValue"); - processVariable = restClient.processModel(RestProcessVariableModel.class, request); - - restClient.assertStatusCodeIs(HttpStatus.OK); - processVariable.assertThat().field("name").is("variableName") - .and().field("type").is("d:text") - .and().field("value").is("variableValue"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding process variable is case of empty type value is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void addingProcessVariableIfEmptyTypeIsProvided() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel(""); - - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - processVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); - - restClient.assertStatusCodeIs(HttpStatus.OK); - processVariable.assertThat().field("name").is(variableModel.getName()) - .and().field("type").is("d:text") - .and().field("value").is(variableModel.getValue()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding process variable in case of empty body field is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void addingProcessVariableWithEmptyBodyProvided() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel(""); - - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{ }", - "processes/{processId}/variables/{variableName}", processModel.getId(), variableModel.getName()); - processVariable = restClient.processModel(RestProcessVariableModel.class, request); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsErrorKey(RestErrorModel.VARIABLE_NAME_REQUIRED) - .containsSummary(RestErrorModel.VARIABLE_NAME_REQUIRED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Update twice in a row the same variable.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void updateTwiceInARowSameProcessVariable() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - - processVariable = restClient.withWorkflowAPI().usingProcess(processModel) - .updateProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - processVariable.assertThat().field("name").is(variableModel.getName()) - .and().field("type").is(variableModel.getType()) - .and().field("value").is(variableModel.getValue()); - - restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() - .assertThat().entriesListContains("name", variableModel.getName()); - - updatedProcessVariable = restClient.withWorkflowAPI().usingProcess(processModel) - .updateProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedProcessVariable.assertThat().field("name").is(variableModel.getName()) - .and().field("type").is(variableModel.getType()) - .and().field("value").is(variableModel.getValue()); - - restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() - .assertThat().entriesListContains("name", variableModel.getName()); - } - -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariableSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariableSanityTests.java deleted file mode 100644 index bcdc5c7fc..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariableSanityTests.java +++ /dev/null @@ -1,95 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes.variables; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.model.RestProcessVariableModel; -import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.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 AddProcessVariableSanityTests extends RestTest -{ - private FileModel document; - private SiteModel siteModel; - private UserModel userWhoStartsTask, assignee, adminUser; - private RestProcessModel processModel; - private RestProcessVariableModel variableModel, processVariable; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userWhoStartsTask = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Create non-existing variable") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) - public void addProcessVariable() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - - processVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - processVariable.assertThat().field("name").is(variableModel.getName()) - .and().field("type").is(variableModel.getType()) - .and().field("value").is(variableModel.getValue()); - - restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() - .assertThat().entriesListContains("name", variableModel.getName()); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Update existing variable") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) - public void updateExistingProcessVariable() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - processVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - processVariable.assertThat().field("name").is(variableModel.getName()) - .and().field("type").is(variableModel.getType()) - .and().field("value").is(variableModel.getValue()); - - String newValue = RandomData.getRandomName("value"); - variableModel.setValue(newValue); - processVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - processVariable.assertThat().field("value").is(newValue); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Adding process variable is falling in case invalid variableBody is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) - public void failedAddingProcessVariableIfInvalidBodyIsProvided() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("incorrect type"); - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - - restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsErrorKey(String.format(RestErrorModel.UNSUPPORTED_TYPE, "incorrect type")) - .containsSummary(String.format(RestErrorModel.UNSUPPORTED_TYPE, "incorrect type")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariablesCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariablesCoreTests.java deleted file mode 100644 index ca5ca5358..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariablesCoreTests.java +++ /dev/null @@ -1,101 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes.variables; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.model.RestProcessVariableModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class AddProcessVariablesCoreTests extends RestTest -{ - private FileModel document; - private SiteModel siteModel; - private UserModel userWhoStartsProcess, assignee; - private RestProcessModel processModel; - private RestProcessVariableModel variableModel, processVariable, variableModel1; - - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - userWhoStartsProcess = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userWhoStartsProcess).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify addProcessVariable by any user for invalid processID with REST API and status code is NOT_FOUND (404)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void addProcessVariableForInvalidProcessIdIsNotFound() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - processModel.setId("invalidProcessID"); - - processVariable = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingProcess(processModel) - .addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidProcessID")); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify addProcessVariable by any user for empty processID with REST API and status code is NOT_FOUND (404)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void addProcessVariableForEmptyProcessIdIsEmpty() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - processModel.setId(""); - - processVariable = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingProcess(processModel) - .addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding multiple process variables is falling in case invalid process id is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void addMultipleProcessVariablesInvalidProcessId() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:int"); - variableModel1 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - - processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - processModel.setId("invalidProcessID"); - - restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(processModel) - .addProcessVariables(variableModel1, variableModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidProcessID")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding multiple process variables is falling in case empty process id is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void addMultipleProcessVariablesEmptyProcessId() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:int"); - variableModel1 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - processModel.setId(""); - - restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(processModel) - .addProcessVariables(variableModel1, variableModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariablesFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariablesFullTests.java deleted file mode 100644 index 88256f3b1..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariablesFullTests.java +++ /dev/null @@ -1,395 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes.variables; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.core.RestRequest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.model.RestProcessVariableCollection; -import org.alfresco.rest.model.RestProcessVariableModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.ProcessModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class AddProcessVariablesFullTests extends RestTest -{ - private FileModel document; - private SiteModel siteModel; - private UserModel userWhoStartsProcess, assignee, adminUser; - private ProcessModel processModel; - private RestProcessModel restProcessModel; - private RestProcessVariableModel variableModel, processVariable, variableModel1, variableModel2, variableModel3; - private RestProcessVariableCollection processVariableCollection; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userWhoStartsProcess = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userWhoStartsProcess).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - processModel = dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document).createSingleReviewerTaskAndAssignTo(assignee); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Add process variables using by the user involved in the process.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void addProcessVariableByUserInvolvedTheProcess() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - restProcessModel = restClient.authenticateUser(assignee).withWorkflowAPI().getProcesses() - .getProcessModelByProcessDefId(processModel.getId()); - - processVariable = restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(restProcessModel) - .addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - processVariable.assertThat().field("name").is(variableModel.getName()) - .and().field("type").is(variableModel.getType()) - .and().field("value").is(variableModel.getValue()); - - restClient.withWorkflowAPI().usingProcess(restProcessModel).getProcessVariables() - .assertThat().entriesListContains("name", variableModel.getName()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Add process variables using by the user involved in the process.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void addMultipleProcessVariableByUserInvolvedTheProcess() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - variableModel1 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - restProcessModel = restClient.authenticateUser(assignee).withWorkflowAPI().getProcesses() - .getProcessModelByProcessDefId(processModel.getId()); - - processVariableCollection = restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(restProcessModel) - .addProcessVariables(variableModel, variableModel1); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - processVariableCollection.getEntries().get(0).onModel() - .assertThat().field("name").is(variableModel.getName()) - .and().field("type").is(variableModel.getType()) - .and().field("value").is(variableModel.getValue()); - - processVariableCollection.getEntries().get(1).onModel() - .assertThat().field("name").is(variableModel1.getName()) - .and().field("type").is(variableModel1.getType()) - .and().field("value").is(variableModel1.getValue()); - - restClient.withWorkflowAPI().usingProcess(restProcessModel).getProcessVariables() - .assertThat().entriesListContains("name", variableModel.getName()) - .assertThat().entriesListContains("name", variableModel1.getName()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Add process variables using by inexistent user.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void addProcessVariableByInexistentUser() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - restProcessModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses() - .getProcessModelByProcessDefId(processModel.getId()); - - processVariable = restClient.authenticateUser(UserModel.getRandomUserModel()).withWorkflowAPI() - .usingProcess(restProcessModel) - .addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Add multiple process variables using by inexistent user.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void addMultipleProcessVariableByInexistentUser() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - variableModel1 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - restProcessModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses() - .getProcessModelByProcessDefId(processModel.getId()); - - processVariableCollection = restClient.authenticateUser(UserModel.getRandomUserModel()).withWorkflowAPI() - .usingProcess(restProcessModel) - .addProcessVariables(variableModel,variableModel1); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding process variables is falling in case invalid type is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void failedAddingProcessVariableIfInvalidTypeIsProvided() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:textarea"); - restProcessModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses() - .getProcessModelByProcessDefId(processModel.getId()); - - restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary( - String.format(RestErrorModel.UNSUPPORTED_TYPE, "d:textarea")) - .containsErrorKey(String.format(RestErrorModel.UNSUPPORTED_TYPE, "d:textarea")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Bug(id = "REPO-1938") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding process variables is falling in case invalid type prefix is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void failedAddingProcessVariableIfInvalidTypePrefixIsProvided() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("ddt:text"); - restProcessModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses() - .getProcessModelByProcessDefId(processModel.getId()); - - restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsSummary(String.format(RestErrorModel.INVALID_NAMEPACE_PREFIX, "ddt")) - .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding process variables is falling in case invalid value is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void failedAddingProcessVariableIfInvalidValueIsProvided() throws Exception - { - RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:int"); - variableModel.setValue("invalidValue"); - restProcessModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses() - .getProcessModelByProcessDefId(processModel.getId()); - - restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .containsSummary(String.format(RestErrorModel.FOR_INPUT_STRING, "invalidValue")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding process variables is falling in case invalid variableBody (adding extra parameter in body:scope) is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void failedAddingProcessVariableIfInvalidBodyIsProvided() throws Exception - { - restProcessModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses() - .getProcessModelByProcessDefId(processModel.getId()); - - RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{\"name\": \"variableName\",\"scope\": \"local\",\"value\": \"testing\",\"type\": \"d:text\"}", - "processes/{processId}/variables", processModel.getId()); - restClient.processModel(RestProcessVariableModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsSummary(String.format(RestErrorModel.NO_CONTENT, "Unrecognized field \"scope\"")) - .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "Unrecognized field \"scope\"")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - //@Bug(id="REPO-1985") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding process variables is falling in case empty name is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void failedAddingProcessVariableIfEmptyNameIsProvided() throws Exception - { - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); - restProcessModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses() - .getProcessModelByProcessDefId(processModel.getId()); - RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - variableModel.setName(""); - - restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsSummary(RestErrorModel.VARIABLE_NAME_REQUIRED) - .containsErrorKey(RestErrorModel.VARIABLE_NAME_REQUIRED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - //@Bug(id="REPO-1985") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding process variables is falling in case invalid name is provided: ony white spaces") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void failedAddingProcessVariableUsingOnlyWhiteSpaceInName() throws Exception - { - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); - restProcessModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses() - .getProcessModelByProcessDefId(processModel.getId()); - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - variableModel.setName(" "); - - processVariable = restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - processVariable.assertThat().field("name").isNull() - .and().field("type").is(variableModel.getType()) - .and().field("value").is(variableModel.getValue()); - - restClient.withWorkflowAPI().usingProcess(restProcessModel).getProcessVariables() - .assertThat().entriesListContains("value", variableModel.getValue()); - } - - @Bug(id="REPO-1987") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding process variables is falling in case invalid name is provided: symbols") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void failedAddingProcessVariableWithSymbolsInName() throws Exception - { - restProcessModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses() - .getProcessModelByProcessDefId(processModel.getId()); - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - variableModel.setName("123_%^&: õÈ,Ì,Ò"); - - processVariable = restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - processVariable.assertThat().field("name").is(variableModel.getName()) - .and().field("type").is(variableModel.getType()) - .and().field("value").is(variableModel.getValue()); - - restClient.withWorkflowAPI().usingProcess(restProcessModel).getProcessVariables() - .assertThat().entriesListContains("name", variableModel.getName()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Add two process variables using by the user involved in the process.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void addingMultipleValidProcessVariables() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - variableModel2 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - variableModel3 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - restProcessModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses() - .getProcessModelByProcessDefId(processModel.getId()); - - processVariableCollection = restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(restProcessModel) - .addProcessVariables(variableModel, variableModel2, variableModel3); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - processVariableCollection.assertThat().entriesListContains("name", variableModel.getName()) - .assertThat().entriesListContains("name", variableModel2.getName()) - .assertThat().entriesListContains("name", variableModel3.getName()); - - processVariableCollection.getEntries().get(0).onModel().assertThat() - .field("name").is(variableModel.getName()).and() - .field("value").is(variableModel.getValue()).and() - .field("type").is(variableModel.getType()); - processVariableCollection.getEntries().get(1).onModel().assertThat() - .field("name").is(variableModel2.getName()).and() - .field("value").is(variableModel2.getValue()).and() - .field("type").is(variableModel2.getType()); - processVariableCollection.getEntries().get(2).onModel().assertThat() - .field("name").is(variableModel3.getName()).and() - .field("value").is(variableModel3.getValue()).and() - .field("type").is(variableModel3.getType()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Add two process variables using by the user involved in the process.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void failedAddingMultipleProcessVariablesInvalidType() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - variableModel.setType("d:string"); - variableModel2 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - restProcessModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses() - .getProcessModelByProcessDefId(processModel.getId()); - - processVariableCollection = restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(restProcessModel) - .addProcessVariables(variableModel, variableModel2); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.UNSUPPORTED_TYPE, "d:string")) - .containsErrorKey(String.format(RestErrorModel.UNSUPPORTED_TYPE, "d:string")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Bug(id = "REPO-1938") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Add two process variables using by the user involved in the process.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void failledAddingMultipleProcessVariablesInvalidTypePrefix() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - variableModel.setType("e:text"); - variableModel2 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - restProcessModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses() - .getProcessModelByProcessDefId(processModel.getId()); - - processVariableCollection = restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(restProcessModel) - .addProcessVariables(variableModel, variableModel2); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsSummary(String.format(RestErrorModel.INVALID_NAMEPACE_PREFIX, "e")) - .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding process variables is falling in case invalid value is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void failledAddingMultipleProcessVariablesInvalidValue() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:int"); - variableModel.setValue("invalidValue"); - variableModel1 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - variableModel2 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - restProcessModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses() - .getProcessModelByProcessDefId(processModel.getId()); - - processVariableCollection = restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(restProcessModel) - .addProcessVariables(variableModel, variableModel1, variableModel2); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .containsSummary(String.format(RestErrorModel.FOR_INPUT_STRING, "invalidValue")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding process variables is falling in case invalid value is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void failledAddingMultipleInvalidProcessVariables() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:int"); - variableModel.setValue("invalidValue"); - variableModel1 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - variableModel1.setType(""); - restProcessModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses() - .getProcessModelByProcessDefId(processModel.getId()); - - processVariableCollection = restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(restProcessModel) - .addProcessVariables(variableModel1, variableModel); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .containsSummary(String.format(RestErrorModel.FOR_INPUT_STRING, "invalidValue")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariablesSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariablesSanityTests.java deleted file mode 100644 index 8bdc65cbe..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariablesSanityTests.java +++ /dev/null @@ -1,158 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes.variables; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.model.RestProcessVariableCollection; -import org.alfresco.rest.model.RestProcessVariableModel; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class AddProcessVariablesSanityTests extends RestTest -{ - private FileModel document; - private SiteModel siteModel; - private UserModel userWhoStartsProcess, assignee, adminUser; - private RestProcessModel processModel; - private RestProcessVariableModel variableModel, variableModel1, variableModel2, processVariable; - private RestProcessVariableCollection processVariableCollection; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userWhoStartsProcess = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userWhoStartsProcess).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Create non-existing variable") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) - public void addProcessVariable() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - - processVariable = restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - processVariable.assertThat().field("name").is(variableModel.getName()) - .and().field("type").is(variableModel.getType()) - .and().field("value").is(variableModel.getValue()); - - restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() - .assertThat().entriesListContains("name", variableModel.getName()); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Create non-existing variable") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) - public void addMultipleProcessVariable() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - variableModel1 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - variableModel2 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - - processVariableCollection = restClient.withWorkflowAPI().usingProcess(processModel) - .addProcessVariables(variableModel, variableModel1, variableModel2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - processVariableCollection.getEntries().get(0).onModel() - .assertThat().field("name").is( variableModel.getName()) - .and().field("type").is( variableModel.getType()) - .and().field("value").is( variableModel.getValue()); - - processVariableCollection.getEntries().get(1).onModel() - .assertThat().field("name").is(variableModel1.getName()) - .and().field("type").is(variableModel1.getType()) - .and().field("value").is(variableModel1.getValue()); - - processVariableCollection.getEntries().get(2).onModel() - .assertThat().field("name").is(variableModel2.getName()) - .and().field("type").is(variableModel2.getType()) - .and().field("value").is(variableModel2.getValue()); - - restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() - .assertThat().entriesListContains("name", variableModel.getName()) - .assertThat().entriesListContains("name", variableModel1.getName()) - .assertThat().entriesListContains("name", variableModel2.getName()); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Update existing variables") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) - public void updateExistingProcessVariable() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - - processVariable = restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - processVariable.assertThat().field("name").is(variableModel.getName()) - .and().field("type").is(variableModel.getType()) - .and().field("value").is(variableModel.getValue()); - - String newValue = RandomData.getRandomName("value"); - variableModel.setValue(newValue); - processVariable = restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - processVariable.assertThat().field("value").is(newValue); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Update existing variables") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) - public void updateExistingMultipleProcessVariable() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - variableModel1 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - - processVariableCollection = restClient.withWorkflowAPI().usingProcess(processModel) - .addProcessVariables(variableModel, variableModel1); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - processVariableCollection.getEntries().get(0).onModel() - .assertThat().field("name").is(variableModel.getName()) - .and().field("type").is(variableModel.getType()) - .and().field("value").is(variableModel.getValue()); - - processVariableCollection.getEntries().get(1).onModel() - .assertThat().field("name").is(variableModel1.getName()) - .and().field("type").is(variableModel1.getType()) - .and().field("value").is(variableModel1.getValue()); - - String newValueVar = RandomData.getRandomName("valueVar"); - variableModel.setValue(newValueVar); - String newValueVar1 = RandomData.getRandomName("valueVar1"); - variableModel1.setValue(newValueVar1); - - processVariableCollection = restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariables(variableModel, variableModel1); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - processVariableCollection.getEntries().get(0).onModel().assertThat().field("value").is(newValueVar); - processVariableCollection.getEntries().get(1).onModel().assertThat().field("value").is(newValueVar1); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Adding process variables is falling in case invalid variableBody is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) - public void failedAddingProcessVariableIfInvalidBodyIsProvided() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("incorrect type"); - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - - restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary("Unsupported type of variable: 'incorrect type'."); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/DeleteProcessVariableCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/DeleteProcessVariableCoreTests.java deleted file mode 100644 index 1e5681d81..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/DeleteProcessVariableCoreTests.java +++ /dev/null @@ -1,118 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes.variables; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.model.RestProcessVariableModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.ProcessModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * - * @author bogdan.bocancea - * - */ -public class DeleteProcessVariableCoreTests extends RestTest -{ - private FileModel document; - private SiteModel siteModel; - private UserModel userWhoStartsTask, assignee, adminUser; - private RestProcessModel restProcessModel; - private ProcessModel processModel; - private RestProcessVariableModel variableModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userWhoStartsTask = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - processModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document) - .createSingleReviewerTaskAndAssignTo(assignee); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Delete invalid process variable") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void deleteInvalidProcessVariable() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("x:InvalidVar"); - restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() - .getProcesses().getProcessModelByProcessDefId(processModel.getId()); - restClient.withWorkflowAPI().usingProcess(restProcessModel).deleteProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, variableModel.getName())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Delete process variable twice") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void deleteProcessVariableTwice() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() - .getProcesses().getProcessModelByProcessDefId(processModel.getId()); - restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.withWorkflowAPI().usingProcess(restProcessModel).deleteProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withWorkflowAPI().usingProcess(restProcessModel).deleteProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, variableModel.getName())); - } - - @TestRail(section = {TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Remove process variables with empty processId") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void deleteProcessVariableEmptyProcessId() throws JsonToModelConversionException, Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() - .getProcesses().getProcessModelByProcessDefId(processModel.getId()); - restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restProcessModel.setId(""); - restClient.withWorkflowAPI().usingProcess(restProcessModel).deleteProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Delete process variable with admin.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void deleteProcessVariableWithAdmin() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() - .getProcesses().getProcessModelByProcessDefId(processModel.getId()); - restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(adminUser).withWorkflowAPI().usingProcess(processModel) - .deleteProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() - .assertThat().entriesListDoesNotContain("name", variableModel.getName()); - } - -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/DeleteProcessVariableFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/DeleteProcessVariableFullTests.java deleted file mode 100644 index a17edb3a4..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/DeleteProcessVariableFullTests.java +++ /dev/null @@ -1,196 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes.variables; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.model.RestProcessVariableModel; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.ProcessModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class DeleteProcessVariableFullTests extends RestTest -{ - private FileModel document; - private SiteModel siteModel; - private UserModel userWhoStartsTask, assignee; - private RestProcessModel restProcessModel; - private ProcessModel processModel; - private RestProcessVariableModel variableModel; - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - userWhoStartsTask = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - processModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createSingleReviewerTaskAndAssignTo(assignee); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Delete empty process variable") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void deleteEmptyProcessVariable() throws Exception - { - variableModel = new RestProcessVariableModel("", "", "bpm:workflowPackage"); - restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getProcesses() - .getProcessModelByProcessDefId(processModel.getId()); - - restClient.withWorkflowAPI().usingProcess(restProcessModel) - .deleteProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) - .assertLastError() - .containsSummary(RestErrorModel.DELETE_EMPTY_ARGUMENT) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .containsErrorKey(RestErrorModel.DELETE_EMPTY_ARGUMENT) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Delete process then delete process variables, status OK should be returned") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void deleteProcessVariablesForADeletedProcess() throws Exception - { - UserModel userWhoStartsTask = dataUser.createRandomTestUser(); - UserModel assignee = dataUser.createRandomTestUser(); - - RestProcessModel processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() - .addProcess("activitiAdhoc", assignee, false, Priority.Normal); - - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() - .getProcesses().getProcessModelByProcessDefId(processModel.getId()); - restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingProcess(processModel) - .deleteProcess(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withWorkflowAPI().usingProcess(processModel).deleteProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, processModel.getId())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Delete process variable using by the user who started the process.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void deleteProcessVariableByUserThatStartedTheProcess() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() - .addProcess("activitiAdhoc", assignee, false, Priority.Normal); - - restProcessModel = restClient.withWorkflowAPI().getProcesses() - .getProcessModelByProcessDefId(processModel.getId()); - restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.withWorkflowAPI().usingProcess(processModel) - .deleteProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() - .assertThat() - .entriesListDoesNotContain("name", variableModel.getName()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Delete process variable using by the user involved in the process.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void deleteProcessVariableByUserInvolvedInTheProcess() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() - .addProcess("activitiAdhoc", assignee, false, Priority.Normal); - - restProcessModel = restClient.withWorkflowAPI().getProcesses() - .getProcessModelByProcessDefId(processModel.getId()); - restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(processModel) - .deleteProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() - .assertThat() - .entriesListDoesNotContain("name", variableModel.getName()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Delete process variable with invalid type") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void deleteProcessVariableInvalidType() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() - .getProcesses().getProcessModelByProcessDefId(processModel.getId()); - restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - variableModel.setType("invalid-type"); - restClient.withWorkflowAPI().usingProcess(restProcessModel).deleteProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() - .assertThat() - .entriesListDoesNotContain("name", variableModel.getName()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Delete process variable by non assigned user") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void deleteProcessVarialbleByNonAssignedUser() throws Exception - { - UserModel nonAssigned = dataUser.createRandomTestUser(); - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() - .getProcesses().getProcessModelByProcessDefId(processModel.getId()); - restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(nonAssigned).withWorkflowAPI().usingProcess(restProcessModel) - .deleteProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError() - .containsSummary(String.format(RestErrorModel.ACCESS_INFORMATION_NOT_ALLOWED, processModel.getId())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .containsErrorKey(String.format(RestErrorModel.ACCESS_INFORMATION_NOT_ALLOWED, processModel.getId())) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Delete process variable by inexistent user") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void deleteProcessVarialbleByInexistentUser() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() - .addProcess("activitiAdhoc", userWhoStartsTask, false, Priority.Normal); - restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() - .getProcesses().getProcessModelByProcessDefId(processModel.getId()); - restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(UserModel.getRandomUserModel()).withWorkflowAPI() - .usingProcess(restProcessModel) - .deleteProcessVariable(variableModel); - - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .stackTraceIs(RestErrorModel.STACKTRACE); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/DeleteProcessVariableSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/DeleteProcessVariableSanityTests.java deleted file mode 100644 index d46a55890..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/DeleteProcessVariableSanityTests.java +++ /dev/null @@ -1,69 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes.variables; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.model.RestProcessVariableModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.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 DeleteProcessVariableSanityTests extends RestTest -{ - private FileModel document; - private SiteModel siteModel; - private UserModel userWhoStartsTask, assignee, adminUser; - private RestProcessModel processModel; - private RestProcessVariableModel variableModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userWhoStartsTask = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().addProcess("activitiAdhoc", adminUser, false, Priority.Normal); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Delete existing variable") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) - public void deleteProcessVariable() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.withWorkflowAPI().usingProcess(processModel).deleteProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() - .assertThat().entriesListDoesNotContain("name", variableModel.getName()); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Try to delete existing variable using invalid processId") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) - public void deleteProcessVariableUsingInvalidProcessId() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - processModel.setId("incorrectProcessId"); - restClient.withWorkflowAPI().usingProcess(processModel).deleteProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "incorrectProcessId")); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/GetProcessVariablesCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/GetProcessVariablesCoreTests.java deleted file mode 100644 index 77abbdbf0..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/GetProcessVariablesCoreTests.java +++ /dev/null @@ -1,88 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes.variables; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.model.RestProcessModelsCollection; -import org.alfresco.rest.model.RestProcessVariableCollection; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.apache.commons.lang3.RandomStringUtils; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class GetProcessVariablesCoreTests extends RestTest -{ - private FileModel document; - private SiteModel siteModel; - private UserModel userWhoStartsTask, assignee, admin; - private RestProcessModel processModel; - private RestProcessVariableCollection variables; - - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - admin = dataUser.getAdminUser(); - userWhoStartsTask = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Get process variables using invalid process ID") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void getProcessVariablesUsingInvalidProcessId() throws Exception - { - restClient.authenticateUser(userWhoStartsTask).withParams("maxItems=2").withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); - RestProcessModelsCollection processes = restClient.authenticateUser(userWhoStartsTask).withParams("maxItems=2").withWorkflowAPI().getProcesses(); - processModel = processes.assertThat().entriesListIsNotEmpty().when().getOneRandomEntry().onModel(); - - String id = RandomStringUtils.randomAlphanumeric(10); - processModel.setId(id); - variables = restClient.withParams("maxItems=2").withWorkflowAPI().usingProcess(processModel).getProcessVariables(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, id)) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Get process variables using empty process ID") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void getProcessVariablesUsingEmptyProcessId() throws Exception - { - processModel = restClient.authenticateUser(userWhoStartsTask).withParams("maxItems=2").withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - processModel.setId(""); - variables = restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Delete process then get process variables, status OK should be returned") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void getProcessVariablesForADeletedProcess() throws Exception - { - UserModel userWhoStartsTask = dataUser.createRandomTestUser(); - UserModel assignee = dataUser.createRandomTestUser(); - - RestProcessModel processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); - - restClient.authenticateUser(admin).withWorkflowAPI().usingProcess(processModel).deleteProcess(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - RestProcessVariableCollection variables = restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables(); - restClient.assertStatusCodeIs(HttpStatus.OK); - variables.assertThat().entriesListIsNotEmpty(); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/GetProcessVariablesFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/GetProcessVariablesFullTests.java deleted file mode 100644 index c87d9d1f6..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/GetProcessVariablesFullTests.java +++ /dev/null @@ -1,161 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes.variables; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.model.RestProcessVariableCollection; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Created by Claudia Agache on 2/2/2017. - */ -public class GetProcessVariablesFullTests extends RestTest -{ - private UserModel userWhoStartsProcess, assignee, admin; - private RestProcessModel processModel; - private RestProcessVariableCollection variables; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - admin = dataUser.getAdminUser(); - userWhoStartsProcess = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.Normal); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify get all process variables call using admin user. Admin can see the process even if he isn't involved in it.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void getProcessVariablesUsingAdmin() throws Exception - { - variables = restClient.authenticateUser(admin).withWorkflowAPI().usingProcess(processModel).getProcessVariables(); - restClient.assertStatusCodeIs(HttpStatus.OK); - variables.assertThat().entriesListIsNotEmpty(); - variables.getProcessVariableByName("initiator") - .assertThat().field("name").is("initiator") - .assertThat().field("type").is("d:noderef") - .assertThat().field("value").is(userWhoStartsProcess.getUsername()); - variables.getProcessVariableByName("bpm_assignee") - .assertThat().field("name").is("bpm_assignee") - .assertThat().field("type").is("cm:person") - .assertThat().field("value").is(assignee.getUsername()); - variables.getProcessVariableByName("bpm_sendEMailNotifications") - .assertThat().field("name").is("bpm_sendEMailNotifications") - .assertThat().field("type").is("d:boolean") - .assertThat().field("value").is(false); - variables.getProcessVariableByName("bpm_priority") - .assertThat().field("name").is("bpm_priority") - .assertThat().field("type").is("d:int") - .assertThat().field("value").is(CMISUtil.Priority.Normal.getLevel()); - } - - @Bug(id = "MNT-17438") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify get all process variables with valid skip count parameter applied.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void getProcessVariablesWithValidSkipCount() throws Exception - { - variables = restClient.authenticateUser(admin).withWorkflowAPI().usingProcess(processModel).getProcessVariables(); - restClient.assertStatusCodeIs(HttpStatus.OK); - variables.assertThat().entriesListIsNotEmpty(); - - RestProcessVariableCollection variablesSkipped = restClient.authenticateUser(admin).withParams("skipCount=2").withWorkflowAPI().usingProcess(processModel).getProcessVariables(); - restClient.assertStatusCodeIs(HttpStatus.OK); - variablesSkipped - .assertThat().entriesListDoesNotContain("name", variables.getEntries().get(0).onModel().getName()) - .assertThat().entriesListDoesNotContain("name", variables.getEntries().get(1).onModel().getName()) - .assertThat().entriesListCountIs(variables.getEntries().size()-2) - .assertThat().paginationField("skipCount").is("2"); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify get all process variables with negative skip count parameter applied.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void getProcessVariablesWithNegativeSkipCount() throws Exception - { - restClient.authenticateUser(admin).withParams("skipCount=-2").withWorkflowAPI().usingProcess(processModel).getProcessVariables(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT) - .containsErrorKey(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE) - .statusCodeIs(HttpStatus.BAD_REQUEST); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify get all process variables with not numeric skip count parameter applied.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void getProcessVariablesWithNonNumericSkipCount() throws Exception - { - restClient.authenticateUser(admin).withParams("skipCount=A").withWorkflowAPI().usingProcess(processModel).getProcessVariables(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "A")); - } - - @Bug(id = "MNT-17438") - @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify get all process variables with valid maxItems parameter applied.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void getProcessVariablesWithValidMaxItems() throws Exception - { - variables = restClient.authenticateUser(admin).withWorkflowAPI().usingProcess(processModel).getProcessVariables(); - restClient.assertStatusCodeIs(HttpStatus.OK); - variables.assertThat().entriesListIsNotEmpty(); - - RestProcessVariableCollection variablesSkipped = restClient.authenticateUser(admin).withParams("maxItems=2").withWorkflowAPI().usingProcess(processModel).getProcessVariables(); - restClient.assertStatusCodeIs(HttpStatus.OK); - variablesSkipped - .assertThat().entriesListContains("name", variables.getEntries().get(0).onModel().getName()) - .assertThat().entriesListContains("name", variables.getEntries().get(1).onModel().getName()) - .assertThat().entriesListCountIs(2) - .assertThat().paginationField("maxItems").is("2"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify get all process variables with negative maxItems parameter applied.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void getProcessVariablesWithNegativeMaxItems() throws Exception - { - restClient.authenticateUser(admin).withParams("maxItems=-2").withWorkflowAPI().usingProcess(processModel).getProcessVariables(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) - .containsErrorKey(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE) - .statusCodeIs(HttpStatus.BAD_REQUEST); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify get all process variables with not numeric maxItems parameter applied.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void getProcessVariablesWithNonNumericMaxItems() throws Exception - { - restClient.authenticateUser(admin).withParams("maxItems=A").withWorkflowAPI().usingProcess(processModel).getProcessVariables(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "A")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify get all process variables with properties parameter.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void getProcessVariablesWithPropertiesParameter() throws Exception - { - variables = restClient.authenticateUser(admin).withParams("properties=name").withWorkflowAPI().usingProcess(processModel).getProcessVariables(); - restClient.assertStatusCodeIs(HttpStatus.OK); - variables.assertThat().entriesListIsNotEmpty(); - variables.getProcessVariableByName("initiator") - .assertThat().field("name").is("initiator") - .assertThat().field("type").isNull() - .assertThat().field("value").isNull() - .assertThat().fieldsCount().is(1); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/GetProcessVariablesSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/GetProcessVariablesSanityTests.java deleted file mode 100644 index 77d769435..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/GetProcessVariablesSanityTests.java +++ /dev/null @@ -1,60 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes.variables; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.model.RestProcessVariableCollection; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.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 GetProcessVariablesSanityTests extends RestTest -{ - private FileModel document; - private SiteModel siteModel; - private UserModel userWhoStartsTask, assignee; - private RestProcessModel processModel; - private RestProcessVariableCollection variables; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - userWhoStartsTask = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Verify that user that started the process gets all process variables") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) - public void getProcessVariablesUsingTheUserWhoStartedProcess() throws JsonToModelConversionException, Exception - { - processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - variables = restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables(); - restClient.assertStatusCodeIs(HttpStatus.OK); - variables.assertThat().entriesListIsNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Verify get all process variables call using a user that is involved in the process") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) - public void getProcessVariablesUsingUserInvolvedInProcess() throws JsonToModelConversionException, Exception - { - processModel = restClient.authenticateUser(assignee).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - variables = restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables(); - restClient.assertStatusCodeIs(HttpStatus.OK); - variables.assertThat().entriesListIsNotEmpty(); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/UpdateProcessVariableTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/UpdateProcessVariableTests.java deleted file mode 100644 index 9dcec0c4b..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/UpdateProcessVariableTests.java +++ /dev/null @@ -1,139 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes.variables; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.model.RestProcessVariableModel; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - - -public class UpdateProcessVariableTests extends RestTest -{ - private FileModel document; - private SiteModel siteModel; - private UserModel userWhoStartsProcess, assignee; - private RestProcessModel processModel; - private RestProcessVariableModel variableModel, updatedVariable; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - userWhoStartsProcess = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userWhoStartsProcess).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Update existing variable using PUT call - invalid type") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void updateProcessVariableInvalidType() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - variableModel.setType("dd"); - - updatedVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsErrorKey(String.format(RestErrorModel.UNSUPPORTED_TYPE, "dd")) - .containsSummary(String.format(RestErrorModel.UNSUPPORTED_TYPE, "dd")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Update existing variable using PUT call - invalid type") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void updateProcessVariableTwoUsers() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:any"); - processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - variableModel.setType("d:text"); - updatedVariable = restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(processModel) - .updateProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedVariable.assertThat().field("type").is("d:text"); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Update existing variable using PUT call - value") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) - public void updateProcessVariableValue() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - variableModel.setValue("newValue"); - - updatedVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedVariable.assertThat().field("value").is("newValue"); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Update existing variable using PUT call - name") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void updateProcessVariableName() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - variableModel.setName("newVariableName"); - - updatedVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedVariable.assertThat().field("name").is("newVariableName"); - } - - @TestRail(section = {TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Update existing variable created by the user who started the process using put call with a user that is not involved in the process- value") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) - public void cantUpdateProcessVariableValueCreatedWithAnyUser() throws Exception - { - UserModel anotherUser = dataUser.createRandomTestUser(); - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - variableModel.setValue("newValue"); - - restClient.authenticateUser(anotherUser).withWorkflowAPI().usingProcess(processModel) - .updateProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(String.format(RestErrorModel.ACCESS_INFORMATION_NOT_ALLOWED, processModel.getId())); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Try to add process variable using an invalid processId") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) - public void updateProcessVariableUsingInvalidProcessId() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - processModel.setId("abc"); - - restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "abc")); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/GetTaskFormModelTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/GetTaskFormModelTests.java deleted file mode 100644 index 559fc29b9..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/GetTaskFormModelTests.java +++ /dev/null @@ -1,256 +0,0 @@ -package org.alfresco.service.search.rest.workflow.tasks; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.*; -import org.alfresco.utility.model.*; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Created by Claudia Agache on 2/3/2017. - */ -public class GetTaskFormModelTests extends RestTest -{ - UserModel userModel, adminUser; - SiteModel siteModel; - FileModel fileModel; - TaskModel taskModel; - RestFormModelsCollection returnedCollection; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, - executionType = ExecutionType.SANITY, description = "Verify admin user gets all task form models with Rest API and response is successful (200)") - public void adminGetsTaskFormModels() throws Exception - { - taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(userModel); - returnedCollection = restClient.authenticateUser(dataUser.getAdminUser()).withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat().entriesListIsNotEmpty(); - - String[] qualifiedNames = { - "{http://www.alfresco.org/model/bpm/1.0}percentComplete", - "{http://www.alfresco.org/model/bpm/1.0}context", - "{http://www.alfresco.org/model/bpm/1.0}completedItems", - "{http://www.alfresco.org/model/content/1.0}name", - "{http://www.alfresco.org/model/bpm/1.0}packageActionGroup", - "{http://www.alfresco.org/model/bpm/1.0}reassignable", - "{http://www.alfresco.org/model/content/1.0}owner", - "{http://www.alfresco.org/model/bpm/1.0}outcome", - "{http://www.alfresco.org/model/bpm/1.0}taskId", - "{http://www.alfresco.org/model/bpm/1.0}packageItemActionGroup", - "{http://www.alfresco.org/model/bpm/1.0}completionDate"}; - - for(String formQualifiedName : qualifiedNames) - { - returnedCollection.assertThat().entriesListContains("qualifiedName", formQualifiedName); - } - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, - executionType = ExecutionType.SANITY, description = "Verify user involved in task gets all the task form models with Rest API and response is successful (200)") - public void involvedUserGetsTaskFormModels() throws Exception - { - taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(userModel); - returnedCollection = restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat().entriesListIsNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, - executionType = ExecutionType.REGRESSION, - description = "Verify that non involved user in task cannot get form models with Rest API and response is FORBIDDEN (403)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void nonInvolvedUserCannotGetTaskFormModels() throws Exception - { - taskModel = dataWorkflow.usingUser(userModel) - .usingSite(siteModel) - .usingResource(fileModel).createNewTaskAndAssignTo(userModel); - UserModel nonInvolvedUser = dataUser.createRandomTestUser(); - restClient.authenticateUser(nonInvolvedUser); - restClient.withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, - executionType = ExecutionType.REGRESSION, - description = "Verify user involved in task cannot get task form models with invalid task id") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void getTaskFormModelsInvalidTaskId() throws Exception - { - taskModel = dataWorkflow.usingUser(userModel) - .usingSite(siteModel) - .usingResource(fileModel).createNewTaskAndAssignTo(userModel); - taskModel.setId("0000"); - restClient.authenticateUser(userModel); - restClient.withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "0000")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, - executionType = ExecutionType.REGRESSION, - description = "Verify user involved in task cannot get task form models with invalid task id") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void getTaskFormModelsEmptyTaskId() throws Exception - { - taskModel = dataWorkflow.usingUser(userModel) - .usingSite(siteModel) - .usingResource(fileModel).createNewTaskAndAssignTo(userModel); - taskModel.setId(""); - restClient.authenticateUser(userModel); - restClient.withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, - executionType = ExecutionType.REGRESSION, - description = "Verify user involved in task can get completed task form models") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void getTaskFormModelsForCompletedTask() throws Exception - { - UserModel assignedUser = dataUser.createRandomTestUser(); - taskModel = dataWorkflow.usingUser(userModel) - .usingSite(siteModel) - .usingResource(fileModel).createNewTaskAndAssignTo(assignedUser); - dataWorkflow.usingUser(assignedUser).taskDone(taskModel); - dataWorkflow.usingUser(userModel).taskDone(taskModel); - restClient.authenticateUser(userModel); - returnedCollection = restClient.withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat().entriesListIsNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, - executionType = ExecutionType.REGRESSION, description = "Verify admin user gets all task form models with properties parameter applied and response is successful (200)") - public void adminGetsTaskFormModelsWithPropertiesParameter() throws Exception - { - taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(userModel); - returnedCollection = restClient.authenticateUser(adminUser).withParams("properties=qualifiedName,required").withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat().entriesListIsNotEmpty(); - returnedCollection.getOneRandomEntry().onModel() - .assertThat() - .field("qualifiedName").isNotEmpty().and() - .field("required").isNotEmpty().and() - .field("dataType").isNull().and() - .field("name").isNull().and() - .field("title").isNull().and() - .field("defaultValue").isNull().and() - .field("allowedValues").isNull().and() - .fieldsCount().is(2); - } - - @Bug(id = "MNT-17438") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify admin gets task form model with valid skipCount parameter applied using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void getTaskFormModelWithValidSkipCount() throws Exception - { - taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(userModel); - returnedCollection = restClient.authenticateUser(adminUser) - .withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); - restClient.assertStatusCodeIs(HttpStatus.OK); - RestFormModel firstTaskFormModel = returnedCollection.getEntries().get(0).onModel(); - RestFormModel secondTaskFormModel = returnedCollection.getEntries().get(1).onModel(); - - RestFormModelsCollection formModelsWithSkipCount = restClient.withParams("skipCount=2").withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); - restClient.assertStatusCodeIs(HttpStatus.OK); - formModelsWithSkipCount - .assertThat().entriesListDoesNotContain("name", firstTaskFormModel.getName()) - .assertThat().entriesListDoesNotContain("name", secondTaskFormModel.getName()) - .assertThat().entriesListCountIs(returnedCollection.getEntries().size()-2); - formModelsWithSkipCount.assertThat().paginationField("skipCount").is("2"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify admin doesn't get task form model with negative skipCount parameter applied using REST API") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void getTaskFormModelWithNegativeSkipCount() throws Exception - { - taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(userModel); - restClient.authenticateUser(adminUser).withParams("skipCount=-1").withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT) - .containsErrorKey(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE) - .statusCodeIs(HttpStatus.BAD_REQUEST); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify admin doesn't get task form model with non numeric skipCount parameter applied using REST API") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void getTaskFormModelWithNonNumericSkipCount() throws Exception - { - taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(userModel); - restClient.authenticateUser(adminUser).withParams("skipCount=A").withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "A")); - } - - @Bug(id = "MNT-17438") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify admin gets task form model with valid maxItems parameter applied using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void getTaskFormModelWithValidMaxItems() throws Exception - { - taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(userModel); - returnedCollection = restClient.authenticateUser(adminUser) - .withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); - restClient.assertStatusCodeIs(HttpStatus.OK); - RestFormModel firstTaskFormModel = returnedCollection.getEntries().get(0).onModel(); - RestFormModel secondTaskFormModel = returnedCollection.getEntries().get(1).onModel(); - - RestFormModelsCollection formModelsWithMaxItems = restClient.withParams("maxItems=2").withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); - restClient.assertStatusCodeIs(HttpStatus.OK); - formModelsWithMaxItems - .assertThat().entriesListContains("name", firstTaskFormModel.getName()) - .assertThat().entriesListContains("name", secondTaskFormModel.getName()) - .assertThat().entriesListCountIs(2); - formModelsWithMaxItems.assertThat().paginationField("maxItems").is("2"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify admin doesn't get task form model with negative maxItems parameter applied using REST API") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void getTaskFormModelWithNegativeMaxItems() throws Exception - { - taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(userModel); - restClient.authenticateUser(adminUser).withParams("maxItems=-1").withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) - .containsErrorKey(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE) - .statusCodeIs(HttpStatus.BAD_REQUEST); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify admin doesn't get task form model with non numeric maxItems parameter applied using REST API") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void getTaskFormModelWithNonNumericMaxItems() throws Exception - { - taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(userModel); - restClient.authenticateUser(adminUser).withParams("maxItems=A").withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "A")); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/GetTaskTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/GetTaskTests.java deleted file mode 100644 index a09d69c39..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/GetTaskTests.java +++ /dev/null @@ -1,212 +0,0 @@ -package org.alfresco.service.search.rest.workflow.tasks; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.core.RestRequest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestTaskModel; -import org.alfresco.rest.model.RestTaskModelsCollection; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.GroupModel; -import org.alfresco.utility.model.ProcessModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TaskModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.apache.commons.lang3.RandomStringUtils; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -/** - * - * @author Cristina Axinte - * - */ -public class GetTaskTests extends RestTest -{ - UserModel userModel, assigneeUser; - UserModel adminTenantUser, tenantUser, tenantUserAssignee, adminUser; - SiteModel siteModel; - FileModel fileModel; - TaskModel taskModel; - RestTaskModel restTaskModel, tenantTask; - RestTaskModelsCollection taskModels; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - assigneeUser = dataUser.createRandomTestUser(); - } - - @BeforeMethod(alwaysRun=true) - public void createTask() throws Exception - { - taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify admin user gets any existing task with Rest API and response is successfull (200)") - public void adminUserGetsAnyTaskWithSuccess() throws Exception - { - restTaskModel = restClient.authenticateUser(adminUser).withWorkflowAPI().usingTask(taskModel).getTask(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("description").is(taskModel.getMessage()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify assignee user gets its assigned task with Rest API and response is successfull (200)") - public void assigneeUserGetsItsTaskWithSuccess() throws Exception - { - restTaskModel = restClient.authenticateUser(assigneeUser).withWorkflowAPI().usingTask(taskModel).getTask(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("description").is(taskModel.getMessage()).and().field("assignee") - .is(assigneeUser.getUsername()); - - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify user that started the task gets the started task with Rest API and response is successfull (200)") - public void starterUserGetsItsTaskWithSuccess() throws Exception - { - restTaskModel = restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).getTask(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("description").is(taskModel.getMessage()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify any user with no relation to task id forbidden to get other task with Rest API (403)") - public void anyUserIsForbiddenToGetOtherTask() throws Exception - { - UserModel anyUser = dataUser.createRandomTestUser(); - - restTaskModel = restClient.authenticateUser(anyUser).withWorkflowAPI().usingTask(taskModel).getTask(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify candidate user gets its specific task and no other user claimed the task with Rest API and response is successfull (200)") - public void candidateUserGetsItsTasks() throws Exception - { - UserModel userModel1 = dataUser.createRandomTestUser(); - UserModel userModel2 = dataUser.createRandomTestUser(); - GroupModel group = dataGroup.createRandomGroup(); - dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); - TaskModel taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); - - restTaskModel = restClient.authenticateUser(userModel1).withWorkflowAPI().usingTask(taskModel).getTask(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("description").is(taskModel.getMessage()); - - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @Bug(id = "MNT-17051") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify involved user in a task without claim it gets the task with Rest API and response is successfull (200)") - public void involvedUserWithoutClaimTaskGetsTask() throws Exception - { - UserModel userModel1 = dataUser.createRandomTestUser(); - UserModel userModel2 = dataUser.createRandomTestUser(); - GroupModel group = dataGroup.createRandomGroup(); - dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); - TaskModel taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); - dataWorkflow.usingUser(userModel1).claimTask(taskModel); - - restTaskModel = restClient.authenticateUser(userModel2).withWorkflowAPI().usingTask(taskModel).getTask(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("description").is(taskModel.getMessage()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, - executionType = ExecutionType.REGRESSION, description = "Verify user who started a task gets the task with empty taskId with Rest API") - public void starterUserGetsTaskWithEmptyTaskId() throws Exception - { - UserModel userWhoStartsTask = dataUser.createRandomTestUser(); - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(userWhoStartsTask); - - restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI(); - RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "tasks/{taskId}", ""); - RestTaskModelsCollection tasks = restClient.processModels(RestTaskModelsCollection.class, request); - - restClient.assertStatusCodeIs(HttpStatus.OK); - tasks.assertThat().entriesListIsNotEmpty() - .and().entriesListCountIs(1) - .and().entriesListContains("id", taskModel.getId()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, - executionType = ExecutionType.REGRESSION, description = "Verify user who started a task gets the task with properties parameter with Rest API") - public void starterUserGetsTaskWithPropertiesParameter() throws Exception - { - restTaskModel = restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).usingParams("properties=id,assignee,formResourceKey").getTask(); - - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().fieldsCount().is(3) - .and().field("id").is(taskModel.getId()) - .and().field("assignee").is(taskModel.getAssignee()) - .and().field("formResourceKey").is("wf:adhocTask") - .and().field("processDefinitionId").isNull() - .and().field("processId").isNull(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, - executionType = ExecutionType.REGRESSION, description = "Verify user who started a task gets the task after it is deleted with Rest API") - public void starterUserGetsDeletedTask() throws Exception - { - restTaskModel = restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).getTask(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()); - - ProcessModel process = new ProcessModel(); - process.setId(taskModel.getProcessId()); - dataWorkflow.usingUser(userModel).deleteProcess(process); - - restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).getTask(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, taskModel.getId())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify if using invalid taskId status code 404 is returned.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void invalidTaskId() throws Exception - { - taskModel.setId(RandomStringUtils.randomAlphanumeric(20)); - restTaskModel = restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).getTask(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, taskModel.getId())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify if using empty taskId status code 200 is returned.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void emptyTaskId() throws Exception - { - restClient.authenticateUser(userModel).withWorkflowAPI(); - RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "tasks/{taskId}", ""); - taskModels = restClient.processModels(RestTaskModelsCollection.class, request); - restClient.assertStatusCodeIs(HttpStatus.OK); - taskModels.assertThat().entriesListIsNotEmpty(); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/GetTasksTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/GetTasksTests.java deleted file mode 100644 index 7f84dcbdf..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/GetTasksTests.java +++ /dev/null @@ -1,234 +0,0 @@ -package org.alfresco.service.search.rest.workflow.tasks; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestTaskModel; -import org.alfresco.rest.model.RestTaskModelsCollection; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.GroupModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TaskModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class GetTasksTests extends RestTest -{ - UserModel userModel, userNotInvolved, assigneeUser, adminUser; - UserModel adminTenantUser, tenantUser, tenantUserAssignee; - SiteModel siteModel; - FileModel fileModel; - RestTaskModelsCollection taskModels, taskCollections, tenantTask; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userModel = dataUser.createRandomTestUser(); - userNotInvolved = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - - assigneeUser = dataUser.createRandomTestUser(); - dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify admin user gets all existing tasks with Rest API and response is successfull (200)") - public void adminUserGetsAllTasks() throws Exception - { - UserModel adminUser = dataUser.getAdminUser(); - - taskModels = restClient.authenticateUser(adminUser).withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - taskModels.assertThat().entriesListIsNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify asignee user gets its existing tasks with Rest API and response is successfull (200)") - public void assigneeUserGetsItsTasks() throws Exception - { - taskModels = restClient.authenticateUser(assigneeUser).withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - taskModels.assertThat().entriesListIsNotEmpty().and().entriesListCountIs(1).and().entriesListContains("assignee", assigneeUser.getUsername()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify candidate user that claims the task gets its existing tasks with Rest API and response is successfull (200)") - @Bug(id = "MNT-16967") - public void candidateUserGetsItsTasks() throws Exception - { - UserModel userModel1 = dataUser.createRandomTestUser(); - UserModel userModel2 = dataUser.createRandomTestUser(); - GroupModel group = dataGroup.createRandomGroup(); - - dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); - dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); - - taskModels = restClient.authenticateUser(userModel1).withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - taskModels.assertThat().entriesListIsNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify candidate user that claims the task gets its existing tasks with Rest API and response is successfull (200)") - public void candidateUserThatClaimsTaskGetsItsTasks() throws Exception - { - UserModel userModel1 = dataUser.createRandomTestUser(); - UserModel userModel2 = dataUser.createRandomTestUser(); - GroupModel group = dataGroup.createRandomGroup(); - dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); - TaskModel taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); - dataWorkflow.usingUser(userModel1).claimTask(taskModel); - - taskModels = restClient.authenticateUser(userModel1).withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - taskModels.assertThat().entriesListIsNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify candidate user without claim gets no tasks with Rest API and response is successfull (200)") - public void candidateUserWithoutClaimTaskGetsNoTasks() throws Exception - { - UserModel userModel1 = dataUser.createRandomTestUser(); - UserModel userModel2 = dataUser.createRandomTestUser(); - GroupModel group = dataGroup.createRandomGroup(); - - dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); - TaskModel taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); - dataWorkflow.usingUser(userModel1).claimTask(taskModel); - - taskModels = restClient.authenticateUser(userModel2).withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - taskModels.assertThat().entriesListIsEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check that skipCount parameter is applied.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void skipCountParameterApplied() throws Exception - { - taskCollections = restClient.authenticateUser(dataUser.getAdminUser()).withParams("orderBy=description ASC").withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - RestTaskModel firstTask = taskCollections.getEntries().get(0).onModel(); - RestTaskModel secondTask = taskCollections.getEntries().get(1).onModel(); - - taskModels = restClient.withParams("orderBy=description ASC&skipCount=2").withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - taskModels.assertThat().entriesListDoesNotContain("id", firstTask.getId()) - .assertThat().entriesListDoesNotContain("id", secondTask.getId()); - taskModels.assertThat().paginationField("skipCount").is("2"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check that maxItems parameter is applied.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void maxItemsParameterApplied() throws Exception - { - restClient.authenticateUser(userModel).withWorkflowAPI().addProcess("activitiAdhoc", assigneeUser, false, Priority.Low); - restClient.authenticateUser(userModel).withWorkflowAPI().addProcess("activitiAdhoc", adminUser, false, Priority.Low); - taskCollections = restClient.authenticateUser(userModel).withParams("orderBy=assignee ASC").withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - taskModels = restClient.withParams("orderBy=startedAt DESC&maxItems=2").withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - taskModels.assertThat().entriesListIsNotEmpty() - .assertThat().entriesListContains("assignee", assigneeUser.getUsername()) - .assertThat().entriesListDoesNotContain("assignee", userModel.getUsername()); - taskModels.assertThat().paginationField("maxItems").is("2"); - taskModels.assertThat().paginationField("count").is("2"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check that properties parameter is applied.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void propertiesParameterApplied() throws Exception - { - taskModels = restClient.authenticateUser(dataUser.getAdminUser()).withParams("properties=name,description").withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - taskModels.assertThat().entriesListIsNotEmpty() - .assertThat().entriesListContains("name") - .assertThat().entriesListContains("description") - .assertThat().entriesListDoesNotContain("processDefinitionId") - .assertThat().entriesListDoesNotContain("processId") - .assertThat().entriesListDoesNotContain("startedAt") - .assertThat().entriesListDoesNotContain("id") - .assertThat().entriesListDoesNotContain("state") - .assertThat().entriesListDoesNotContain("activityDefinitionId") - .assertThat().entriesListDoesNotContain("priority") - .assertThat().entriesListDoesNotContain("formResourceKey"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Use invalid where parameter. Check default error model schema.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void invalidWhereParameterCheckDefaultErrorModelSchema() throws Exception - { - restClient.authenticateUser(dataUser.getAdminUser()).where("assignee AND '" + assigneeUser.getUsername() + "'").withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(RestErrorModel.INVALID_QUERY_ERRORKEY) - .containsSummary(String.format(RestErrorModel.INVALID_WHERE_QUERY, "(assignee AND '" + assigneeUser.getUsername() + "')")) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify the request in case of any user which is not involved.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void requestWithUserNotInvolved() throws Exception - { - taskModels = restClient.authenticateUser(userNotInvolved).withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - taskModels.assertThat().entriesListIsEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check that orderBy parameter is applied.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void orderByParameterApplied() throws Exception - { - taskModels = restClient.authenticateUser(dataUser.getAdminUser()).withParams("orderBy=id").withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - taskModels.assertThat().entriesListIsNotEmpty(). - and().entriesListIsSortedAscBy("id"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check that orderBy parameter is applied and supports only one parameter.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void orderByParameterSupportsOnlyOneParameter() throws Exception - { - taskModels = restClient.authenticateUser(dataUser.getAdminUser()).withParams("orderBy=id,processDefinitionId").withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Only one order by parameter is supported"); - taskModels.assertThat().entriesListIsEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check that where parameter is applied.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void whereParameterApplied() throws Exception - { - UserModel anotherAssignee = dataUser.createRandomTestUser(); - dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(anotherAssignee); - taskModels = restClient.authenticateUser(dataUser.getAdminUser()).withParams("where=(assignee='" + anotherAssignee.getUsername() + "')").withWorkflowAPI() - .getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - taskModels.assertThat().entriesListIsNotEmpty().and().entriesListContains("assignee", anotherAssignee.getUsername()).and().entriesListCountIs(1); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check that invalid orderBy parameter applied returns 400 status code.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void invalidOrderByParameterApplied() throws Exception - { - restClient.authenticateUser(dataUser.getAdminUser()).withParams("orderBy=invalidParameter").withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("invalidParameter is not supported"); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/UpdateTaskTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/UpdateTaskTests.java deleted file mode 100644 index 304f57b03..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/UpdateTaskTests.java +++ /dev/null @@ -1,1639 +0,0 @@ -package org.alfresco.service.search.rest.workflow.tasks; - -import java.util.HashMap; - -import javax.json.JsonObject; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.core.JsonBodyGenerator; -import org.alfresco.rest.core.RestRequest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestProcessDefinitionModel; -import org.alfresco.rest.model.RestTaskModel; -import org.alfresco.rest.model.RestVariableModelsCollection; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.GroupModel; -import org.alfresco.utility.model.ProcessModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TaskModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -public class UpdateTaskTests extends RestTest -{ - UserModel owner, anyUser; - SiteModel siteModel; - FileModel fileModel; - UserModel assigneeUser; - TaskModel taskModel; - RestTaskModel restTaskModel; - UserModel adminUser; - RestProcessDefinitionModel activitiReviewProcessDefinition; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - owner = dataUser.createRandomTestUser(); - anyUser = dataUser.createRandomTestUser(); - assigneeUser = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - activitiReviewProcessDefinition = restClient.authenticateUser(adminUser).withWorkflowAPI().getAllProcessDefinitions().getProcessDefinitionByKey("activitiReviewPooled"); - } - - @BeforeMethod(alwaysRun = true) - public void createTask() throws Exception - { - taskModel = dataWorkflow.usingUser(owner).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify admin user updates task with Rest API and response is successfull (200)") - public void adminUserUpdatesAnyTaskWithSuccess() throws Exception - { - restTaskModel = restClient.authenticateUser(adminUser).withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("description").is(taskModel.getMessage()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify assignee user updates its assigned task with Rest API and response is successfull (200)") - public void assigneeUserUpdatesItsTaskWithSuccess() throws Exception - { - restTaskModel = restClient.authenticateUser(assigneeUser).withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("description").is(taskModel.getMessage()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify user that started the task updates the started task with Rest API and response is successfull (200)") - public void starterUserUpdatesItsTaskWithSuccess() throws Exception - { - restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify any user with no relation to task is forbidden to update other task with Rest API (403)") - public void anyUserIsForbiddenToUpdateOtherTask() throws Exception - { - restTaskModel = restClient.authenticateUser(anyUser).withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify candidate user updates its specific task and no other user claimed the task with Rest API and response is successfull (200)") - public void candidateUserUpdatesItsTasks() throws Exception - { - UserModel userModel1 = dataUser.createRandomTestUser(); - UserModel userModel2 = dataUser.createRandomTestUser(); - GroupModel group = dataGroup.createRandomGroup(); - dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); - TaskModel taskModel = dataWorkflow.usingUser(owner).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); - - restTaskModel = restClient.authenticateUser(userModel1).withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat() - .field("dueAt").isNotEmpty() - .and().field("processDefinitionId").is(activitiReviewProcessDefinition.getId()) - .and().field("processId").is(taskModel.getProcessId()) - .and().field("name").is("Review Task") - .and().field("description").is(taskModel.getMessage()) - .and().field("startedAt").isNotEmpty() - .and().field("id").is(taskModel.getId()) - .and().field("state").is("unclaimed") - .and().field("activityDefinitionId").is("reviewTask") - .and().field("priority").is(taskModel.getPriority().getLevel()) - .and().field("formResourceKey").is("wf:activitiReviewTask"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task owner can update twice task with status resolve successfully (200)") - public void taskOwnerCanUpdateTaskWithResolveStateTwice() throws Exception - { - restTaskModel = restClient.authenticateUser(assigneeUser) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("resolved"); - - restClient.authenticateUser(owner) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task asignee cannot update twice task with status resolve - Forbidden (403)") - public void taskAssigneeCanNotUpdateTaskWithResolveStateTwice() throws Exception - { - restTaskModel = restClient.authenticateUser(assigneeUser) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("resolved"); - - restClient.authenticateUser(assigneeUser) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task cannot be update using a invalid json body property - Bad Request (400)") - public void taskCanNotBeUpdatedWithInvalidJsonBodyProperty() throws Exception - { - String invalidJsonProperty= "states"; - restClient.authenticateUser(assigneeUser) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel); - String postBody = JsonBodyGenerator.keyValueJson(invalidJsonProperty, "completed"); - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); - restClient.processModel(RestTaskModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.NO_CONTENT, "Unrecognized field \""+invalidJsonProperty+"\"")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task cannot be update using a invalid state - Bad Request (400)") - public void taskCanNotBeUpdatedWithInvalidState() throws Exception - { - restTaskModel = restClient.authenticateUser(assigneeUser) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("continued"); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_VALUE, "task state", "continued")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task cannot be update using a invalid property - Bad Request (400)") - public void taskCanNotBeUpdatedWithInvalidSelectProperty() throws Exception - { - String invalidProperty= "states"; - restClient.authenticateUser(assigneeUser) - .withParams("select=" + invalidProperty).withWorkflowAPI().usingTask(taskModel); - String postBody = JsonBodyGenerator.keyValueJson("state", "completed"); - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); - restClient.processModel(RestTaskModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.PROPERTY_DOES_NOT_EXIST, invalidProperty)); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task can be update using multiple select values successfully (200)") - public void taskCanBeUpdatedWithMultipleSelectValues() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("state", "resolved") - .add("assignee", "admin").build(); - - restTaskModel = restClient.authenticateUser(assigneeUser) - .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("resolved"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, - description = "Verify task assignee can complete task successfully (200)") - public void taskAssigneeCanCompleteTask() throws Exception - { - restTaskModel = restClient.authenticateUser(assigneeUser) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("completed"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, - description = "Verify task owner can complete task successfully (200))") - public void taskOwnerCanCompleteTask() throws Exception - { - restTaskModel = restClient.authenticateUser(assigneeUser) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("completed"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify any user cannot complete task - Forbidden (403))") - public void anyUserCannotCompleteTask() throws Exception - { - UserModel anyUser = dataUser.createRandomTestUser(); - - restTaskModel = restClient.authenticateUser(anyUser) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @Bug(id = "REPO-2062") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task owner cannot complete task with invalid name - Bad Request(400))") - public void taskOwnerCannotCompleteTaskWithInvalidName() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("state", "completed") - .add("variables", JsonBodyGenerator.defineJSONArray() - .add(JsonBodyGenerator.defineJSON() - .add("name", "bpmx_priorityx") - .add("type", "d:int") - .add("value", 1) - .add("scope", "global").build()) - ).build(); - - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state,variables").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.UNSUPPORTED_TYPE,"bpm_priorityx")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task owner cannot complete task with invalid Type - Bad Request(400))") - public void taskOwnerCannotCompleteTaskWithInvalidType() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("state", "completed") - .add("variables", JsonBodyGenerator.defineJSONArray() - .add(JsonBodyGenerator.defineJSON() - .add("name", "bpmx_priority") - .add("type", "d_int") - .add("value", 1) - .add("scope", "global").build()) - ).build(); - - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state,variables").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.UNSUPPORTED_TYPE,"d_int")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @Bug(id = "REPO-2062") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task owner cannot complete task with invalid value - Bad Request(400))") - public void taskOwnerCannotCompleteTaskWithInvalidValue() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("state", "completed") - .add("variables", JsonBodyGenerator.defineJSONArray() - .add(JsonBodyGenerator.defineJSON() - .add("name", "bpmx_priority") - .add("type", "d:int") - .add("value", "text") - .add("scope", "global").build()) - ).build(); - - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state,variables").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.UNSUPPORTED_TYPE, "text")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task owner cannot complete task with invalid scope - Bad Request(400))") - public void taskOwnerCannotCompleteTaskWithInvalidScope() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("state", "completed") - .add("variables", JsonBodyGenerator.defineJSONArray() - .add(JsonBodyGenerator.defineJSON() - .add("name", "bpmx_priority") - .add("type", "d:int") - .add("value", 1) - .add("scope", "globalscope").build()) - ).build(); - - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state,variables").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.ILLEGAL_SCOPE, "globalscope")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task assignee can claim task successfully (200)") - public void taskAssigneeCanClaimTask() throws Exception - { - restTaskModel = restClient.authenticateUser(assigneeUser) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("claimed"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task assignee can unclaim task successfully (200)") - public void taskAssigneeCanUnclaimTask() throws Exception - { - restTaskModel = restClient.authenticateUser(assigneeUser) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("unclaimed"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task assignee can delegate task successfully (200)") - public void taskAssigneeCanDelegateTask() throws Exception - { - UserModel delagateToUser = dataUser.createRandomTestUser(); - - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("state", "delegated") - .add("assignee", delagateToUser.getUsername()).build(); - - restTaskModel = restClient.authenticateUser(assigneeUser) - .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("delegated") - .and().field("assignee").is(delagateToUser.getUsername()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task owner can delegate task to same assignee successfully (200)") - public void taskOwnerCanDelegateTaskToSameAssignee() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("state", "delegated") - .add("assignee", assigneeUser.getUsername()).build(); - - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("delegated") - .and().field("assignee").is(assigneeUser.getUsername()); - } - - - @Bug(id = "REPO-2063") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task assignee cannot delegate task to task owner - (400)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void taskAssigneeCannotDelegateTaskToTaskOwner() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("state", "delegated") - .add("assignee", owner.getUsername()).build(); - - restTaskModel = restClient.authenticateUser(assigneeUser) - .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @Bug(id = "REPO-2063") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task assignee cannot delegate task to invalid assignee - (400)") - public void taskAssigneeCannotDelegateTaskToInvalidAssignee() throws Exception - { - UserModel invalidAssignee = new UserModel("invalidAssignee", "password"); - - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("state", "delegated") - .add("assignee", invalidAssignee.getUsername()).build(); - - restTaskModel = restClient.authenticateUser(assigneeUser) - .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task assignee can update task with status resolve") - public void resolveTaskAsCurrentAssignee() throws Exception - { - restTaskModel = restClient.authenticateUser(assigneeUser) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("resolved"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify update task using invalid taskId") - public void updateTaskUsingInvalidTaskId() throws Exception - { - taskModel.setId("invalidId"); - - restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidId")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify update task using another name") - public void updateTaskUsingAnotherName() throws Exception - { - restClient.authenticateUser(owner).withParams("select=name").withWorkflowAPI().usingTask(taskModel); - String postBody = "{\"name\":\"newNameTask\"}"; - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); - restTaskModel = restClient.processModel(RestTaskModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("name").is("newNameTask"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify update task using another description") - public void updateTaskUsingAnotherDescription() throws Exception - { - restClient.authenticateUser(owner).withParams("select=description").withWorkflowAPI().usingTask(taskModel); - String postBody = "{\"description\":\"newDescription\"}"; - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); - restTaskModel = restClient.processModel(RestTaskModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("description").is("newDescription"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify update task using another priority") - public void updateTaskUsingAnotherPriority() throws Exception - { - restClient.authenticateUser(owner).withParams("select=priority").withWorkflowAPI().usingTask(taskModel); - String postBody = "{\"priority\":3}"; - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); - restTaskModel = restClient.processModel(RestTaskModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("priority").is(CMISUtil.Priority.Low.getLevel()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify update task using another priority") - public void updateTaskUsingAnotherOwner() throws Exception - { - UserModel newOwner = dataUser.createRandomTestUser(); - - restClient.authenticateUser(owner).withParams("select=owner").withWorkflowAPI().usingTask(taskModel); - String postBody = "{\"owner\":\""+newOwner.getUsername()+"\"}"; - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); - restTaskModel = restClient.processModel(RestTaskModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("owner").is(newOwner.getUsername()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can not update task from completed to claimed and response is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void taskOwnerCanNotUpdateTaskFromCompletedToClaimed() throws Exception - { - restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("completed"); - restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() - .containsSummary(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can not update task from completed to unclaimed and response is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void taskOwnerCanNotUpdateTaskFromCompletedToUnclaimed() throws Exception - { - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("completed"); - restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() - .containsSummary(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can not update task from completed to completed and response is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void taskOwnerCanNotUpdateTaskWithCompleteStateTwice() throws Exception - { - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("completed"); - restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() - .containsSummary(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can update task from claimed to completed and response is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void taskOwnerCanUpdateTaskFromClaimedToCompleted() throws Exception - { - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("claimed"); - restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("completed"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify user can update task from claimed to claimed and response is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void userCanUpdateTaskWithClaimedStateTwice() throws Exception - { - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("claimed"); - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("claimed"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can update task from unclaimed to completed and response is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void taskOwnerCanUpdateTaskFromUnclaimedToCompleted() throws Exception - { - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); - restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("completed"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can not update task from unclaimed to unclaimed and response is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void taskOwnerCanNotUpdateTaskWithUnclaimedStateTwice() throws Exception - { - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); - restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); - } - - @Bug(id = "REPO-1924") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can not update task from delegated to completed and response is 422") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void taskOwnerCanNotUpdateTaskFromDelegatedToCompleted() throws Exception - { - restClient.authenticateUser(owner).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel); - HashMap body = new HashMap(); - body.put("state", "delegated"); - body.put("assignee", assigneeUser.getUsername()); - String postBody = JsonBodyGenerator.keyValueJson(body); - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), - restClient.getParameters()); - restTaskModel = restClient.processModel(RestTaskModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated").and().field("assignee") - .is(assigneeUser.getUsername()); - - restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(RestErrorModel.DELEGATED_TASK_CAN_NOT_BE_COMPLETED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can not update task from delegated to delegated and response is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void taskOwnerCanNotUpdateTaskWithDelegatedStateTwice() throws Exception - { - restClient.authenticateUser(owner).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel); - HashMap body = new HashMap(); - body.put("state", "delegated"); - body.put("assignee", assigneeUser.getUsername()); - String postBody = JsonBodyGenerator.keyValueJson(body); - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), - restClient.getParameters()); - restTaskModel = restClient.processModel(RestTaskModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated").and().field("assignee") - .is(assigneeUser.getUsername()); - - request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); - restTaskModel = restClient.processModel(RestTaskModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated").and().field("assignee") - .is(assigneeUser.getUsername()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can update task from resolved to completed and response is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void taskOwnerCanUpdateTaskFromResolvedToCompleted() throws Exception - { - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("resolved"); - - restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("completed"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify owner cannot update task from status completed to delegated and response is 404") - public void ownerCannotUpdateTaskFromCompletedToDelegated() throws Exception - { - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("completed"); - - restClient.authenticateUser(owner) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("delegated"); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() - .containsErrorKey(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) - .containsSummary(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify assignee cannot update task from status completed to delegated and response is 404") - public void assigneeCannotUpdateTaskFromCompletedToDelegated() throws Exception - { - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("completed"); - - restClient.authenticateUser(assigneeUser) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("delegated"); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() - .containsErrorKey(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) - .containsSummary(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify owner cannot update task from status completed to resolved and response is 404") - public void ownerCannotUpdateTaskFromCompletedToResolved() throws Exception - { - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("completed"); - - restClient.authenticateUser(owner) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() - .containsErrorKey(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) - .containsSummary(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify assignee cannot update task from status completed to resolved and response is 404") - public void assigneeCannotUpdateTaskFromCompletedToResolved() throws Exception - { - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("completed"); - - restClient.authenticateUser(assigneeUser) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() - .containsErrorKey(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) - .containsSummary(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify owner cannot update task from status completed to completed and response is 404") - public void ownerCannotUpdateTaskFromCompletedToCompleted() throws Exception - { - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("completed"); - - restClient.authenticateUser(owner) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() - .containsErrorKey(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) - .containsSummary(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify assignee cannot update task from status completed to completed and response is 404") - public void assigneeCannotUpdateTaskFromCompletedToCompleted() throws Exception - { - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("completed"); - - restClient.authenticateUser(assigneeUser) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() - .containsErrorKey(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) - .containsSummary(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify owner can update task from status claimed to unclaimed and response is 200") - public void ownerCanUpdateTaskFromClaimedToUnclaimed() throws Exception - { - restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).getTask(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("claimed"); - - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("unclaimed"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify assignee can update task from status claimed to unclaimed and response is 200") - public void assigneeCanUpdateTaskFromClaimedToUnclaimed() throws Exception - { - restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).getTask(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("claimed"); - - restTaskModel = restClient.authenticateUser(assigneeUser) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("unclaimed"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify owner can update task from status claimed to delegated and response is 200") - public void ownerCanUpdateTaskFromClaimedToDelegated() throws Exception - { - restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).getTask(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("claimed"); - - UserModel newAssignee = dataUser.createRandomTestUser(); - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("state", "delegated") - .add("assignee", newAssignee.getUsername()).build(); - - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("delegated") - .and().field("assignee").is(newAssignee.getUsername()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify assignee can update task from status claimed to delegated and response is 200") - public void assigneeCanUpdateTaskFromClaimedToDelegated() throws Exception - { - restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).getTask(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("claimed"); - - UserModel newAssignee = dataUser.createRandomTestUser(); - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("state", "delegated") - .add("assignee", newAssignee.getUsername()).build(); - - restTaskModel = restClient.authenticateUser(assigneeUser) - .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("delegated") - .and().field("assignee").is(newAssignee.getUsername()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify owner can update task from status claimed to resolved and response is 200") - public void ownerCanUpdateTaskFromClaimedToResolved() throws Exception - { - restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).getTask(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("claimed"); - - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("resolved"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify assignee can update task from status claimed to resolved and response is 200") - public void assigneeCanUpdateTaskFromClaimedToResolved() throws Exception - { - restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).getTask(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("claimed"); - - restTaskModel = restClient.authenticateUser(assigneeUser) - .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("resolved"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify owner cannot update task from status claimed to claimed and response is 409") - public void ownerCannotUpdateTaskFromClaimedToClaimed() throws Exception - { - restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).getTask(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("claimed"); - - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); - restClient.assertStatusCodeIs(HttpStatus.CONFLICT).assertLastError() - .containsErrorKey(RestErrorModel.TASK_ALREADY_CLAIMED) - .containsSummary(RestErrorModel.TASK_ALREADY_CLAIMED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify assignee can update task from status claimed to claimed and response is 200") - public void assigneeCanUpdateTaskFromClaimedToClaimed() throws Exception - { - restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).getTask(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("claimed"); - - restTaskModel = restClient.authenticateUser(assigneeUser) - .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("claimed"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task owner can complete task with valid variables and response is 200") - public void taskOwnerCanCompleteTaskWithValidVariables() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("state", "completed") - .add("variables", JsonBodyGenerator.defineJSONArray() - .add(JsonBodyGenerator.defineJSON() - .add("name", "bpm_priority") - .add("type", "d:int") - .add("value", 3) - .add("scope", "global").build()) - ).build(); - - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state,variables").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("priority").is(1) - .and().field("state").is("completed") - .and().field("assignee").is(taskModel.getAssignee()); - RestVariableModelsCollection variables = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(restTaskModel).getTaskVariables(); - restClient.assertStatusCodeIs(HttpStatus.OK); - variables.getVariableByName("bpm_priority").assertThat().field("scope").is("global") - .and().field("name").is("bpm_priority") - .and().field("type").is("d:int") - .and().field("value").is(3); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task owner cannot complete task with empty variables array and response is 200") - public void taskOwnerCannotUpdateTaskWithEmptyVariablesArray() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("state", "completed") - .add("variables", JsonBodyGenerator.defineJSONArray() - ).build(); - - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state,variables").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("priority").is(1) - .and().field("state").is("completed") - .and().field("assignee").is(taskModel.getAssignee()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task owner cannot complete task with empty variables json body and response is 200") - public void taskOwnerCannotUpdateTaskWithEmptyVariablesJsonBody() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("state", "completed") - .add("variables", JsonBodyGenerator.defineJSONArray() - .add(JsonBodyGenerator.defineJSON().build()) - ).build(); - - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state,variables").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(RestErrorModel.VARIABLE_NAME_REQUIRED) - .containsSummary(RestErrorModel.VARIABLE_NAME_REQUIRED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify any user with no relation to task is forbidden to delegate other task with Rest API (403)") - public void anyUserIsForbiddenToDelegateOtherTask() throws Exception - { - restTaskModel = restClient.authenticateUser(anyUser).withWorkflowAPI().usingTask(taskModel).updateTask("delegated"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify any user with no relation to task is forbidden to resolve other task with Rest API (403)") - public void anyUserIsForbiddenToResolveOtherTask() throws Exception - { - restTaskModel = restClient.authenticateUser(anyUser).withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify any user with no relation to task is forbidden to claim other task with Rest API (403)") - public void anyUserIsForbiddenToClaimOtherTask() throws Exception - { - restTaskModel = restClient.authenticateUser(anyUser).withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify any user with no relation to task is forbidden to unclaim other task with Rest API (403)") - public void anyUserIsForbiddenToUnclaimOtherTask() throws Exception - { - restTaskModel = restClient.authenticateUser(anyUser).withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify user cannot delegate task with emty assignee name and response is 400") - public void updateTaskWithEmptyAssigneeValue() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("state", "delegated") - .add("assignee", "") - .build(); - - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(RestErrorModel.DELEGATING_ASSIGNEE_PROVIDED) - .containsSummary(RestErrorModel.DELEGATING_ASSIGNEE_PROVIDED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify owner can resolve task when assignee is the owner and response is 200") - public void taskOwnerUpdateTaskResolveStateAndOwnerAssignee() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("state", "resolved") - .add("assignee", owner.getUsername()) - .build(); - - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("state").is("resolved") - .and().field("assignee").isNull(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify owner cannot update task after it was deleted and response is 404") - public void updateTaskAfterItWasDeleted() throws Exception - { - ProcessModel process = new ProcessModel(); - process.setId(taskModel.getProcessId()); - dataWorkflow.usingUser(owner).deleteProcess(process); - - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.ENTITY_WAS_NOT_FOUND, taskModel.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task owner cannot update task with empty input body and response is 400") - public void taskOwnerCannotUpdateTaskWithEmptyInputBody() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON().build(); - - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(String.format(RestErrorModel.TASK_INVALID_STATE, "null")) - .containsSummary(String.format(RestErrorModel.TASK_INVALID_STATE, "null")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify any user cannot update task using another name") - public void anyUserCannotUpdateTaskUsingAnotherName() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("name", "Review Task-updated") - .build(); - - restClient.authenticateUser(anyUser).withParams("select=name").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify any user cannot update task using another description") - public void anyUserCannotUpdateTaskUsingAnotherDescription() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("description", "description updated") - .build(); - - restClient.authenticateUser(anyUser).withParams("select=description").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify any user cannot update task using another dueAt") - public void anyUserCannotUpdateTaskUsingAnotherDueAt() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("dueAt", "2025-01-01T11:57:32.000+0000") - .build(); - - restClient.authenticateUser(anyUser).withParams("select=dueAt").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify any user cannot update task using another priority") - public void anyUserCannotUpdateTaskUsingAnotherPriority() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("priority", 3) - .build(); - - restClient.authenticateUser(anyUser).withParams("select=priority").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify any user cannot update task using another priority") - public void anyUserCannotUpdateTaskUsingAnotherOwner() throws Exception - { - UserModel newOwner = dataUser.createRandomTestUser(); - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("owner", newOwner.getUsername()) - .build(); - - - restClient.authenticateUser(anyUser).withParams("select=owner").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify any user cannot update task using invalid name") - public void anyUserCannotUpdateTaskUsingInvalidName() throws Exception - { - restClient.authenticateUser(owner).withParams("select=name").withWorkflowAPI().usingTask(taskModel); - String postBody = "{\"name\":\"invalid-\"a\"}"; - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); - restTaskModel = restClient.processModel(RestTaskModel.class, request); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "Unexpected character ('a'")) - .containsSummary(String.format(RestErrorModel.NO_CONTENT, "Unexpected character ('a'")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify any user cannot update task using invalid description") - public void anyUserCannotUpdateTaskUsingInvalidDescription() throws Exception - { - restClient.authenticateUser(owner).withParams("select=description").withWorkflowAPI().usingTask(taskModel); - String postBody = "{\"description\":\"invalid-\"a\"}"; - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); - restTaskModel = restClient.processModel(RestTaskModel.class, request); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "Unexpected character ('a'")) - .containsSummary(String.format(RestErrorModel.NO_CONTENT, "Unexpected character ('a'")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify any user cannot update task using invalid dueAt") - public void anyUserCannotUpdateTaskUsingInvalidDueAt() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("dueAt", "invalid-date") - .build(); - - restClient.authenticateUser(anyUser).withParams("select=dueAt").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify any user cannot update task using invalid priority") - public void anyUserCannotUpdateTaskUsingInvalidPriority() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("priority", "a") - .build(); - - restClient.authenticateUser(anyUser).withParams("select=priority").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify any user cannot update task using invalid priority") - public void anyUserCannotUpdateTaskUsingInvalidOwner() throws Exception - { - restClient.authenticateUser(owner).withParams("select=owner").withWorkflowAPI().usingTask(taskModel); - String postBody = "{\"owner\":\"invalid-\"a\"}"; - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); - restTaskModel = restClient.processModel(RestTaskModel.class, request); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "Unexpected character ('a'")) - .containsSummary(String.format(RestErrorModel.NO_CONTENT, "Unexpected character ('a'")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from unclaimed to claimed by task creator") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void taskCreatorCanUpdateTaskFromUnclaimedToClaimed() throws Exception - { - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); - restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("claimed"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task cannot be updated from unclaimed to claimed by a regular user not connected to the task") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void regularUserCannotUpdateTaskFromUnclaimedToClaimed() throws Exception - { - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from unclaimed to delegated by task creator") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void taskCreatorCanUpdateTaskFromUnclaimedToDelegated() throws Exception - { - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); - - JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", owner.getUsername()).build(); - - restTaskModel = restClient.authenticateUser(owner).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task cannot be updated from unclaimed to delegated by a regular user not connected to the task") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void regularUserCannotUpdateTaskFromUnclaimedToDelegated() throws Exception - { - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); - - JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); - - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from unclaimed to resolved by task creator") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void taskCreatorCanUpdateTaskFromUnclaimedToResolved() throws Exception - { - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); - restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("resolved"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from unclaimed to resolved by a regular user not connected to the task") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void regularCanNotUpdateTaskFromUnclaimedToResolved() throws Exception - { - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from unclaimed to unclaimed by task creator") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void taskCreatorCanUpdateTaskFromUnclaimedToUnclaimed() throws Exception - { - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); - restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from unclaimed to unclaimed by a regular user not connected to the task") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void regularUserCannotUpdateTaskFromUnclaimedToUnclaimed() throws Exception - { - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Bug(id = "REPO-1982") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from delegated to unclaimed by task creator") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void taskCreatorCanUpdateTaskFromDelegatedToUnclaimed() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); - - restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); - } - - @Bug(id = "REPO-1982") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from delegated to unclaimed by task assignee") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void taskAssigneeCanUpdateTaskFromDelegatedToUnclaimed() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); - - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task cannot be updated from delegated to claimed since it is already claimed by task creator") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void taskCreatorCannotUpdateTaskFromDelegatedToClaimed() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); - - restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); - restClient.assertStatusCodeIs(HttpStatus.CONFLICT).assertLastError() - .containsErrorKey(RestErrorModel.TASK_ALREADY_CLAIMED) - .containsSummary(RestErrorModel.TASK_ALREADY_CLAIMED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from delegated to claimed since it is already claimed by task assignee") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void taskAssigneeCanUpdateTaskFromDelegatedToClaimed() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); - - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); - } - - @Bug(id = "REPO-1924") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from delegated to completed by task creator") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void taskCreatorCanUpdateTaskFromDelegatedToCompleted() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); - - restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() - .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .containsSummary(RestErrorModel.DELEGATED_TASK_CAN_NOT_BE_COMPLETED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Bug(id = "REPO-1924") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from delegated to completed by task assignee") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void taskAssigneeCanUpdateTaskFromDelegatedToCompleted() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); - - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() - .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .containsSummary(RestErrorModel.DELEGATED_TASK_CAN_NOT_BE_COMPLETED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from delegated to resolved") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void taskCreatorCanUpdateTaskFromDelegatedToResolved() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); - - restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("resolved"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from delegated to resolved by task assignee") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void taskAssigneeCanUpdateTaskFromDelegatedToResolved() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); - - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("resolved"); - } - - @Bug(id = "REPO-1982") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from resolved to unclaimed by task creator") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void taskCreatorCanUpdateTaskFromResolvedToUnclaimed() throws Exception - { - restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - - restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("resolved"); - } - - @Bug(id = "REPO-1982") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task cannot be updated from resolved to unclaimed by task assignee") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void taskAssigneeCannotUpdateTaskFromResolvedToUnclaimed() throws Exception - { - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Bug(id = "REPO-1982") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task cannot be updated from resolved to claimed by task owner") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void taskOwnerCanUpdateTaskFromResolvedToClaimed() throws Exception - { - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - - restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("resolved"); - } - - @Bug(id = "REPO-1982") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task cannot be updated from resolved to claimed by task assignee") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void taskAssigneeCanUpdateTaskFromResolvedToClaimed() throws Exception - { - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Bug(id = "REPO-1982") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from resolved to delegated by task creator") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void taskCreatorCannotUpdateTaskFromResolvedToDelegated() throws Exception - { - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - - JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); - restTaskModel = restClient.authenticateUser(owner).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from resolved to delegated by task assignee") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void taskAssigneeCannotUpdateTaskFromResolvedToDelegated() throws Exception - { - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - - JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Bug(id = "REPO-1982") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from resolved to resolved by task creator") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void taskCreatorCannotUpdateTaskFromResolvedToResolved() throws Exception - { - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - - restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("resolved"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from resolved to resolved by task assignee") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void taskAssigneeCannotUpdateTaskFromResolvedToResolved() throws Exception - { - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Bug(id = "REPO-1982") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Update task by providing empty select value") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void updateTaskByProvidingEmptySelectValue() throws Exception - { - restTaskModel = restClient.authenticateUser(owner).withParams("select=").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(RestErrorModel.INVALID_SELECT_ERRORKEY) - .containsSummary(RestErrorModel.INVALID_SELECT) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Update task by providing empty state value") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void updateTaskByProvidingEmptyStateValue() throws Exception - { - restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask(" "); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(String.format(RestErrorModel.TASK_INVALID_STATE, " ")) - .containsSummary(String.format(RestErrorModel.TASK_INVALID_STATE, " ")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/candidates/GetTaskCandidatesRegressionTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/candidates/GetTaskCandidatesRegressionTests.java deleted file mode 100644 index c3c9cc5fc..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/candidates/GetTaskCandidatesRegressionTests.java +++ /dev/null @@ -1,268 +0,0 @@ -package org.alfresco.service.search.rest.workflow.tasks.candidates; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestCandidateModelsCollection; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.GroupModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TaskModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * - * @author bogdan.bocancea - * - */ -public class GetTaskCandidatesRegressionTests extends RestTest -{ - private UserModel userModel, userModel1, userModel2; - private SiteModel siteModel; - private FileModel fileModel; - private TaskModel taskModel; - private GroupModel group; - private RestCandidateModelsCollection candidateModels; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - userModel1 = dataUser.createRandomTestUser(); - userModel2 = dataUser.createRandomTestUser(); - group = dataGroup.createRandomGroup(); - dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify get task candidates with invalid task id") - public void getTaskCandidatesWithInvalidTaskId() throws Exception - { - taskModel = dataWorkflow.usingUser(userModel) - .usingSite(siteModel) - .usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); - taskModel.setId("invalid-id"); - restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).getTaskCandidates(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalid-id")) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify get task candidates with empty task id") - public void getTaskCandidatesWithEmptyTaskId() throws Exception - { - taskModel = dataWorkflow.usingUser(userModel) - .usingSite(siteModel) - .usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); - taskModel.setId(""); - restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).getTaskCandidates(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify get task candidates for completed task") - public void getTaskCandidatesForCompletedTask() throws Exception - { - taskModel = dataWorkflow.usingUser(userModel) - .usingSite(siteModel) - .usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); - - restClient.authenticateUser(userModel1).withWorkflowAPI().usingTask(taskModel).getTaskCandidates(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - dataWorkflow.usingUser(userModel1).taskDone(taskModel); - - restClient.authenticateUser(userModel1).withWorkflowAPI().usingTask(taskModel).getTaskCandidates(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, taskModel.getId())); - - restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).getTaskCandidates(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, taskModel.getId())); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify get task candidates by non candidate user") - public void getTaskCandidatesByNonCandidateUser() throws Exception - { - UserModel outsider = dataUser.createRandomTestUser(); - taskModel = dataWorkflow.usingUser(userModel) - .usingSite(siteModel) - .usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); - restClient.authenticateUser(outsider).withWorkflowAPI().usingTask(taskModel).getTaskCandidates(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Bug(id="MNT-17438") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Get task candidates with skip count parameter") - public void getTaskCandidatesWithSkipCount() throws Exception - { - taskModel = dataWorkflow.usingUser(userModel) - .usingSite(siteModel) - .usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); - candidateModels = restClient.authenticateUser(userModel).withWorkflowAPI() - .usingParams("skipCount=1").usingTask(taskModel).getTaskCandidates(); - restClient.assertStatusCodeIs(HttpStatus.OK); - candidateModels.assertThat() - .entriesListIsNotEmpty() - .and().paginationField("count").is("0"); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Get task candidates with max items parameter set to 0") - public void getTaskCandidatesWithZeroMaxItems() throws Exception - { - taskModel = dataWorkflow.usingUser(userModel) - .usingSite(siteModel) - .usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); - candidateModels = restClient.authenticateUser(userModel).withWorkflowAPI() - .usingParams("maxItems=0").usingTask(taskModel).getTaskCandidates(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsErrorKey(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) - .containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Get task candidates with max items parameter") - public void getTaskCandidatesWithMaxItems() throws Exception - { - taskModel = dataWorkflow.usingUser(userModel) - .usingSite(siteModel) - .usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); - candidateModels = restClient.authenticateUser(userModel).withWorkflowAPI() - .usingParams("maxItems=2").usingTask(taskModel).getTaskCandidates(); - restClient.assertStatusCodeIs(HttpStatus.OK); - candidateModels.assertThat() - .entriesListIsNotEmpty() - .and().paginationField("count").is("1"); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Get task candidates with properties") - public void getTaskCandidatesWithProperties() throws Exception - { - taskModel = dataWorkflow.usingUser(userModel) - .usingSite(siteModel) - .usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); - candidateModels = restClient.authenticateUser(userModel).withWorkflowAPI() - .usingParams("properties=candidateId").usingTask(taskModel).getTaskCandidates(); - restClient.assertStatusCodeIs(HttpStatus.OK); - candidateModels.getEntries().get(0).onModel().assertThat() - .field("candidateId").contains(group.getGroupIdentifier()).and() - .field("candidateType").isNull(); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Get task candidates with invalid properties") - public void getTaskCandidatesWithInvalidProperties() throws Exception - { - taskModel = dataWorkflow.usingUser(userModel) - .usingSite(siteModel) - .usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); - candidateModels = restClient.authenticateUser(userModel).withWorkflowAPI() - .usingParams("properties=unknown-prop").usingTask(taskModel).getTaskCandidates(); - restClient.assertStatusCodeIs(HttpStatus.OK); - candidateModels.getEntries().get(0).onModel().assertThat() - .fieldsCount().is(0).and(); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Get task candidates by deleted candidate") - public void getTaskCandidatesByDeletedCandidate() throws Exception - { - UserModel newUser = dataUser.createRandomTestUser(); - dataGroup.addListOfUsersToGroup(group, newUser); - taskModel = dataWorkflow.usingUser(userModel) - .usingSite(siteModel) - .usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); - restClient.authenticateUser(newUser).withWorkflowAPI() - .usingTask(taskModel).getTaskCandidates(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - dataUser.usingAdmin().deleteUser(newUser); - - restClient.authenticateUser(newUser).withWorkflowAPI() - .usingTask(taskModel).getTaskCandidates(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError().containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Get task candidates by deleted group") - public void getTaskCandidatesByDeletedGroup() throws Exception - { - GroupModel deletedGroup = dataGroup.createRandomGroup(); - UserModel newUser = dataUser.createRandomTestUser(); - dataGroup.addListOfUsersToGroup(deletedGroup, userModel2, newUser); - taskModel = dataWorkflow.usingUser(userModel) - .usingSite(siteModel) - .usingResource(fileModel).createPooledReviewTaskAndAssignTo(deletedGroup); - restClient.authenticateUser(newUser).withWorkflowAPI() - .usingTask(taskModel).getTaskCandidates(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - dataGroup.usingAdmin().deleteGroup(deletedGroup); - - restClient.authenticateUser(newUser).withWorkflowAPI() - .usingTask(taskModel).getTaskCandidates(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Get task candidates by user that was removed from group") - public void getTaskCandidatesByUserRemovedFromGroup() throws Exception - { - UserModel newUser = dataUser.createRandomTestUser(); - dataGroup.addListOfUsersToGroup(group, newUser); - taskModel = dataWorkflow.usingUser(userModel) - .usingSite(siteModel) - .usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); - restClient.authenticateUser(newUser).withWorkflowAPI() - .usingTask(taskModel).getTaskCandidates(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - dataGroup.usingAdmin().removeUserFromGroup(group, newUser); - - restClient.authenticateUser(newUser).withWorkflowAPI() - .usingTask(taskModel).getTaskCandidates(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .stackTraceIs(RestErrorModel.STACKTRACE); - } -} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/candidates/GetTaskCandidatesSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/candidates/GetTaskCandidatesSanityTests.java deleted file mode 100644 index cbd17f10f..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/candidates/GetTaskCandidatesSanityTests.java +++ /dev/null @@ -1,79 +0,0 @@ -package org.alfresco.service.search.rest.workflow.tasks.candidates; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestCandidateModelsCollection; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.GroupModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TaskModel; -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 Cristina Axinte - * - */ - -public class GetTaskCandidatesSanityTests extends RestTest -{ - private UserModel userModel, user, userModel1, userModel2; - private SiteModel siteModel; - private FileModel fileModel; - private TaskModel taskModel; - private GroupModel group; - private RestCandidateModelsCollection candidateModels; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - user = dataUser.createRandomTestUser(); - userModel1 = dataUser.createRandomTestUser(); - userModel2 = dataUser.createRandomTestUser(); - group = dataGroup.createRandomGroup(); - dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); - taskModel = dataWorkflow.usingUser(user).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, - description = "Verify that admin gets task candidates") - public void getTaskCandidatesByAdmin() throws Exception - { - candidateModels = restClient.authenticateUser(dataUser.getAdminUser()).withWorkflowAPI().usingTask(taskModel).getTaskCandidates(); - restClient.assertStatusCodeIs(HttpStatus.OK); - candidateModels.assertThat().entriesListContains("candidateType", "group") - .and().entriesListContains("candidateId", String.format("GROUP_%s", group.getGroupIdentifier())); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, - description = "Verify that user that started the process gets task candidates") - public void getTaskCandidatesByUserWhoStartedProcess() throws Exception - { - candidateModels = restClient.authenticateUser(user).withWorkflowAPI().usingTask(taskModel).getTaskCandidates(); - restClient.assertStatusCodeIs(HttpStatus.OK); - candidateModels.assertThat().entriesListContains("candidateType", "group") - .and().entriesListContains("candidateId", String.format("GROUP_%s", group.getGroupIdentifier())); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, - description = "Verify that user from the assighed group to the process gets task candidates") - public void getTaskCandidatesByCandidateUser() throws Exception - { - candidateModels = restClient.authenticateUser(userModel1).withWorkflowAPI().usingTask(taskModel).getTaskCandidates(); - restClient.assertStatusCodeIs(HttpStatus.OK); - candidateModels.assertThat().entriesListContains("candidateType", "group") - .and().entriesListContains("candidateId", String.format("GROUP_%s", group.getGroupIdentifier())); - } -} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/AddTaskItemTestsBulk1.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/AddTaskItemTestsBulk1.java deleted file mode 100644 index 84856161f..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/AddTaskItemTestsBulk1.java +++ /dev/null @@ -1,158 +0,0 @@ -package org.alfresco.service.search.rest.workflow.tasks.items; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestItemModel; -import org.alfresco.rest.model.RestItemModelsCollection; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TaskModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - - -public class AddTaskItemTestsBulk1 extends RestTest -{ - private UserModel userModel, userWhoStartsTask, assigneeUser; - private SiteModel siteModel; - private FileModel fileModel, document2, document3; - private TaskModel taskModel; - private RestItemModelsCollection taskItems; - private RestItemModel taskItem; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - userWhoStartsTask = dataUser.createRandomTestUser(); - assigneeUser = dataUser.createRandomTestUser(); - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, - description = "Create non-existing task item") - public void createTaskItem() throws Exception - { - UserModel adminUser = dataUser.getAdminUser(); - restClient.authenticateUser(adminUser); - document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - - taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - taskItem.assertThat().field("createdAt").is(taskItem.getCreatedAt()) - .assertThat().field("size").is(taskItem.getSize()) - .assertThat().field("createdBy").is(taskItem.getCreatedBy()) - .assertThat().field("modifiedAt").is(taskItem.getModifiedAt()) - .assertThat().field("name").is(taskItem.getName()) - .assertThat().field("modifiedBy").is(taskItem.getModifiedBy()) - .assertThat().field("id").is(taskItem.getId()) - .assertThat().field("mimeType").is(taskItem.getMimeType()); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, - description = "Create multiple non-existing task item") - public void createMultipleTaskItem() throws Exception - { - UserModel adminUser = dataUser.getAdminUser(); - restClient.authenticateUser(adminUser); - document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - - taskItems = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItems(document2, fileModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - taskItems.getEntries().get(0).onModel() - .assertThat().field("createdAt").is(taskItems.getEntries().get(0).onModel().getCreatedAt()) - .assertThat().field("size").is(taskItems.getEntries().get(0).onModel().getSize()) - .assertThat().field("createdBy").is(taskItems.getEntries().get(0).onModel().getCreatedBy()) - .assertThat().field("modifiedAt").is(taskItems.getEntries().get(0).onModel().getModifiedAt()) - .assertThat().field("name").is(taskItems.getEntries().get(0).onModel().getName()) - .assertThat().field("modifiedBy").is(taskItems.getEntries().get(0).onModel().getModifiedBy()) - .assertThat().field("id").is(taskItems.getEntries().get(0).onModel().getId()) - .assertThat().field("mimeType").is(taskItems.getEntries().get(0).onModel().getMimeType()); - - taskItems.getEntries().get(1).onModel() - .assertThat().field("createdAt").is(taskItems.getEntries().get(1).onModel().getCreatedAt()) - .assertThat().field("size").is(taskItems.getEntries().get(1).onModel().getSize()) - .assertThat().field("createdBy").is(taskItems.getEntries().get(1).onModel().getCreatedBy()) - .assertThat().field("modifiedAt").is(taskItems.getEntries().get(1).onModel().getModifiedAt()) - .assertThat().field("name").is(taskItems.getEntries().get(1).onModel().getName()) - .assertThat().field("modifiedBy").is(taskItems.getEntries().get(1).onModel().getModifiedBy()) - .assertThat().field("id").is(taskItems.getEntries().get(1).onModel().getId()) - .assertThat().field("mimeType").is(taskItems.getEntries().get(1).onModel().getMimeType()); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @Bug(id = "MNT-16966") - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that in case task item exists the request fails") - public void createTaskItemThatAlreadyExists() throws Exception - { - UserModel adminUser = dataUser.getAdminUser(); - restClient.authenticateUser(adminUser); - document3 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - - taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document3); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - taskItem.assertThat().field("createdAt").is(taskItem.getCreatedAt()) - .assertThat().field("size").is(taskItem.getSize()) - .and().field("createdBy").is(taskItem.getCreatedBy()) - .and().field("modifiedAt").is(taskItem.getModifiedAt()) - .and().field("name").is(taskItem.getName()) - .and().field("modifiedBy").is(taskItem.getModifiedBy()) - .and().field("id").is(taskItem.getId()) - .and().field("mimeType").is(taskItem.getMimeType()); - - taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document3); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @Bug(id = "MNT-16966") - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that in case task item exists the request fails") - public void createMultipleTaskItemThatAlreadyExists() throws Exception - { - UserModel adminUser = dataUser.getAdminUser(); - restClient.authenticateUser(adminUser); - document3 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - - taskItems = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItems(document3, document2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - taskItems.getEntries().get(0).onModel() - .assertThat().field("createdAt").is(taskItems.getEntries().get(0).onModel().getCreatedAt()) - .assertThat().field("size").is(taskItems.getEntries().get(0).onModel().getSize()) - .assertThat().field("createdBy").is(taskItems.getEntries().get(0).onModel().getCreatedBy()) - .assertThat().field("modifiedAt").is(taskItems.getEntries().get(0).onModel().getModifiedAt()) - .assertThat().field("name").is(taskItems.getEntries().get(0).onModel().getName()) - .assertThat().field("modifiedBy").is(taskItems.getEntries().get(0).onModel().getModifiedBy()) - .assertThat().field("id").is(taskItems.getEntries().get(0).onModel().getId()) - .assertThat().field("mimeType").is(taskItems.getEntries().get(0).onModel().getMimeType()); - - taskItems.getEntries().get(1).onModel() - .assertThat().field("createdAt").is(taskItems.getEntries().get(1).onModel().getCreatedAt()) - .assertThat().field("size").is(taskItems.getEntries().get(1).onModel().getSize()) - .assertThat().field("createdBy").is(taskItems.getEntries().get(1).onModel().getCreatedBy()) - .assertThat().field("modifiedAt").is(taskItems.getEntries().get(1).onModel().getModifiedAt()) - .assertThat().field("name").is(taskItems.getEntries().get(1).onModel().getName()) - .assertThat().field("modifiedBy").is(taskItems.getEntries().get(1).onModel().getModifiedBy()) - .assertThat().field("id").is(taskItems.getEntries().get(1).onModel().getId()) - .assertThat().field("mimeType").is(taskItems.getEntries().get(1).onModel().getMimeType()); - - taskItems = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItems(document3, document2); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - } -} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/AddTaskItemTestsBulk2.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/AddTaskItemTestsBulk2.java deleted file mode 100644 index 54ccf0cdc..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/AddTaskItemTestsBulk2.java +++ /dev/null @@ -1,175 +0,0 @@ -package org.alfresco.service.search.rest.workflow.tasks.items; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.core.RestRequest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestVariableModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TaskModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class AddTaskItemTestsBulk2 extends RestTest -{ - private UserModel userModel, assigneeUser, anotherUser; - private SiteModel siteModel; - private FileModel fileModel, fileModel1; - private TaskModel taskModel; - private String taskId; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - fileModel1 = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - assigneeUser = dataUser.createRandomTestUser(); - taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - - taskId = taskModel.getId(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Add task item using random user.") - public void addTaskItemByRandomUser() throws Exception - { - anotherUser = dataUser.createRandomTestUser(); - restClient.authenticateUser(anotherUser).withWorkflowAPI().usingTask(taskModel).addTaskItem(fileModel); - - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError() - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Add multiple task item using random user.") - public void addMultipleTaskItemByRandomUser() throws Exception - { - anotherUser = dataUser.createRandomTestUser(); - restClient.authenticateUser(anotherUser).withWorkflowAPI().usingTask(taskModel) - .addTaskItems(fileModel,fileModel1); - - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE);; - } - - @Bug(id = "ACE-5683") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Adding task item, is falling in case invalid itemBody is provided") - public void failedAddingTaskItemIfInvalidItemBodyIsProvided() throws Exception - { - fileModel.setNodeRef("invalidNodeRef"); - restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).addTaskItem(fileModel); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidNodeRef")) - .containsErrorKey(RestErrorModel.NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Bug(id = "ACE-5683") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Adding multiple task item, is falling in case invalid itemBody is provided") - public void failedAddingMultipleTaskItemIfInvalidItemBodyIsProvided() throws Exception - { - fileModel.setNodeRef("invalidNodeRef"); - restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel) - .addTaskItems(fileModel, fileModel1); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidNodeRef")) - .containsErrorKey(RestErrorModel.NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE);; - } - - @Bug(id = "ACE-5675") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Adding task item is falling in case empty item body is provided") - public void failedAddingTaskItemIfEmptyItemBodyIsProvided() throws Exception - { - fileModel.setNodeRef(""); - restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).addTaskItem(fileModel); - - // TODO - expected error message to be added - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(""); - } - - @Bug(id = "ACE-5675") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Adding multiple task item is falling in case empty item body is provided") - public void failedAddingMultipleTaskItemIfEmptyItemBodyIsProvided() throws Exception - { - fileModel.setNodeRef(""); - restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).addTaskItems(fileModel, fileModel1); - - // TODO - expected error message to be added - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(""); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Adding task item is falling in case invalid task id is provided") - public void failedAddingTaskItemIfInvalidTaskIdIsProvided() throws Exception - { - taskModel.setId("invalidTaskId"); - restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).addTaskItem(fileModel); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidTaskId")) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE);; - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Adding task item is falling in case invalid task id is provided") - public void failedAddingMultipleTaskItemIfInvalidTaskIdIsProvided() throws Exception - { - taskModel.setId("invalidTaskId"); - restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).addTaskItems(fileModel,fileModel1); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidTaskId")) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Bug(id = "ACE-5675") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Adding task item is falling in case incomplete body type is provided") - public void failedAddingTaskVariableIfIncompleteBodyIsProvided() throws Exception - { - RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{}", "tasks/{taskId}/items", taskId); - restClient.processModel(RestVariableModel.class, request); - - // TODO - expected error message to be added - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(""); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/AddTaskItemTestsBulk3.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/AddTaskItemTestsBulk3.java deleted file mode 100644 index 10bb83f4c..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/AddTaskItemTestsBulk3.java +++ /dev/null @@ -1,128 +0,0 @@ -package org.alfresco.service.search.rest.workflow.tasks.items; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestItemModel; -import org.alfresco.rest.model.RestItemModelsCollection; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TaskModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class AddTaskItemTestsBulk3 extends RestTest -{ - private UserModel userModel,userWhoStartsTask, assigneeUser; - private SiteModel siteModel; - private FileModel fileModel, fileModel1, document1, document2,document3; - private TaskModel taskModel; - private RestItemModelsCollection taskItems; - private RestItemModel taskItem; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - userWhoStartsTask = dataUser.createRandomTestUser(); - assigneeUser = dataUser.createRandomTestUser(); - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Add task item using random user.") - public void addTaskItemByTheUserThatStartedTheProcess() throws Exception - { - taskItem = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingTask(taskModel).addTaskItem(fileModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - taskItem.assertThat().field("createdAt").is(taskItem.getCreatedAt()) - .and().field("size").is(taskItem.getSize()) - .and().field("createdBy").is(taskItem.getCreatedBy()) - .and().field("modifiedAt").is(taskItem.getModifiedAt()) - .and().field("name").is(taskItem.getName()) - .and().field("modifiedBy").is(taskItem.getModifiedBy()) - .and().field("id").is(taskItem.getId()) - .and().field("mimeType").is(taskItem.getMimeType()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Add multiple task item using random user.") - public void addMultipleTaskItemByTheUserThatStartedTheProcess() throws Exception - { - fileModel1 = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - taskItems = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingTask(taskModel) - .addTaskItems(fileModel, fileModel1); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - taskItems.getEntries().get(0).onModel() - .assertThat().field("createdAt").is(taskItems.getEntries().get(0).onModel().getCreatedAt()) - .and().field("size").is(taskItems.getEntries().get(0).onModel().getSize()) - .and().field("createdBy").is(taskItems.getEntries().get(0).onModel().getCreatedBy()) - .and().field("modifiedAt").is(taskItems.getEntries().get(0).onModel().getModifiedAt()) - .and().field("name").is(taskItems.getEntries().get(0).onModel().getName()) - .and().field("modifiedBy").is(taskItems.getEntries().get(0).onModel().getModifiedBy()) - .and().field("id").is(taskItems.getEntries().get(0).onModel().getId()) - .and().field("mimeType").is(taskItems.getEntries().get(0).onModel().getMimeType()); - - taskItems.getEntries().get(1).onModel() - .assertThat().field("createdAt").is(taskItems.getEntries().get(1).onModel().getCreatedAt()) - .assertThat().field("size").is(taskItems.getEntries().get(1).onModel().getSize()) - .assertThat().field("createdBy").is(taskItems.getEntries().get(1).onModel().getCreatedBy()) - .assertThat().field("modifiedAt").is(taskItems.getEntries().get(1).onModel().getModifiedAt()) - .assertThat().field("name").is(taskItems.getEntries().get(1).onModel().getName()) - .assertThat().field("modifiedBy").is(taskItems.getEntries().get(1).onModel().getModifiedBy()) - .assertThat().field("id").is(taskItems.getEntries().get(1).onModel().getId()) - .assertThat().field("mimeType").is(taskItems.getEntries().get(1).onModel().getMimeType()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Delete task item then create it again") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION}) - public void deleteTaskItemThenCreateItAgain() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel) - .createNewTaskAndAssignTo(assigneeUser); - restClient.authenticateUser(userWhoStartsTask); - document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Delete multiple task item then create it again") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION}) - public void deleteMultipleTaskItemsThenCreateThemAgain() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel) - .createNewTaskAndAssignTo(assigneeUser); - restClient.authenticateUser(userWhoStartsTask); - document1 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - document3 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - taskItems = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItems(document2, document1, document3); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItems.getEntries().get(0).onModel()); - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItems.getEntries().get(1).onModel()); - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItems.getEntries().get(2).onModel()); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withWorkflowAPI().usingTask(taskModel).addTaskItems(document2, document1, document3); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/GetTaskItemsRegressionTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/GetTaskItemsRegressionTests.java deleted file mode 100644 index d1e3bd9ab..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/GetTaskItemsRegressionTests.java +++ /dev/null @@ -1,260 +0,0 @@ -package org.alfresco.service.search.rest.workflow.tasks.items; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestItemModel; -import org.alfresco.rest.model.RestItemModelsCollection; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.model.RestTaskModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TaskModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Created by Claudia Agache on 12/8/2016. - */ -public class GetTaskItemsRegressionTests extends RestTest -{ - private UserModel userWhoStartsTask, assignee; - private SiteModel siteModel; - private FileModel fileModel; - private TaskModel taskModel; - private RestItemModelsCollection itemModels; - private RestProcessModel addedProcess; - private RestTaskModel addedTask; - private RestItemModel taskItem; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - userWhoStartsTask = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify if get task items call return status code 404 when invalid taskId is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void getTaskItemsUsingInvalidTaskId() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); - taskModel.setId("invalidId"); - - restClient.authenticateUser(assignee).withWorkflowAPI() - .usingTask(taskModel).getTaskItems(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidId")); - - taskModel.setId(""); - - restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() - .usingTask(taskModel).getTaskItems(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, - executionType = ExecutionType.REGRESSION, - description = "Verify if get task items request returns status code 200 after the task is finished.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void getTaskItemsAfterFinishingTask() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); - dataWorkflow.usingUser(assignee).taskDone(taskModel); - restClient.authenticateUser(userWhoStartsTask); - itemModels = restClient.withWorkflowAPI().usingTask(taskModel).getTaskItems(); - restClient.assertStatusCodeIs(HttpStatus.OK); - itemModels.assertThat().entriesListIsNotEmpty().and().entriesListContains("name", fileModel.getName()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, - executionType = ExecutionType.REGRESSION, - description = "Verify if get task items request returns status code 200 after the process is deleted (Task state is now completed.)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void getTaskItemsAfterDeletingProcess() throws Exception - { - addedProcess = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); - addedTask = restClient.withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess); - restClient.withWorkflowAPI().usingTask(addedTask).addTaskItem(fileModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.withWorkflowAPI().usingProcess(addedProcess).deleteProcess(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - itemModels = restClient.withWorkflowAPI().usingTask(addedTask).getTaskItems(); - restClient.assertStatusCodeIs(HttpStatus.OK); - itemModels.assertThat().entriesListIsNotEmpty().and().entriesListContains("name", fileModel.getName()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Check default error model schema for get task items api call") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void getTaskItemsUsingCheckErrorModel() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); - taskModel.setId("invalidId"); - restClient.authenticateUser(assignee).withWorkflowAPI() - .usingTask(taskModel).getTaskItems(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidId")) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin user can get task items") - public void getTaskItemsByAdminUser() throws Exception - { - restClient.authenticateUser(userWhoStartsTask); - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); - taskItem = restClient.withWorkflowAPI().usingTask(taskModel).getTaskItems().getOneRandomEntry(); - - itemModels = restClient.authenticateUser(dataUser.getAdminUser()).withWorkflowAPI().usingTask(taskModel).getTaskItems(); - restClient.assertStatusCodeIs(HttpStatus.OK); - itemModels.assertThat() - .entriesListIsNotEmpty().and() - .entriesListContains("id", taskItem.onModel().getId()).and() - .entriesListContains("name", taskItem.onModel().getName()) - .getEntries().get(0).onModel() - .assertThat().field("createdAt").isNotNull() - .assertThat().field("size").isNotNull() - .assertThat().field("createdBy").contains(dataUser.getAdminUser().getUsername()) - .assertThat().field("modifiedAt").isNotNull() - .assertThat().field("name").contains(fileModel.getName()) - .assertThat().field("modifiedBy").contains(userWhoStartsTask.getUsername()) - .assertThat().field("id").contains(fileModel.getNodeRef().split(";")[0]) - .assertThat().field("mimeType").contains(fileModel.getFileType().mimeType); - } - - @Bug(id="MNT-17438") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that user who started the process can get task items with skip count parameter") - public void getTaskItemsWithSkipCount() throws Exception - { - restClient.authenticateUser(userWhoStartsTask); - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); - FileModel document1 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document1); - itemModels = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() - .usingParams("skipCount=1").usingTask(taskModel).getTaskItems(); - restClient.assertStatusCodeIs(HttpStatus.OK); - itemModels.assertThat() - .entriesListIsNotEmpty() - .and().paginationField("count").is("1"); - } - - @Bug(id="MNT-17438") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that user who started the process can get task items with max items parameter") - public void getTaskItemsWithMaxItems() throws Exception - { - restClient.authenticateUser(userWhoStartsTask); - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); - FileModel document1 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document1); - itemModels = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() - .usingParams("maxItems=1").usingTask(taskModel).getTaskItems(); - restClient.assertStatusCodeIs(HttpStatus.OK); - itemModels.assertThat() - .entriesListIsNotEmpty() - .and().paginationField("count").is("1"); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that user who started the process can get task items with valid properties") - public void getTaskItemsWithValidProperties() throws Exception - { - restClient.authenticateUser(userWhoStartsTask); - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); - taskItem = restClient.withWorkflowAPI().usingTask(taskModel).getTaskItems().getOneRandomEntry(); - itemModels = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() - .usingParams("properties=createdAt,createdBy,id,size").usingTask(taskModel).getTaskItems(); - restClient.assertStatusCodeIs(HttpStatus.OK); - itemModels.getOneRandomEntry().onModel().assertThat() - .fieldsCount().is(4).and() - .field("createdAt").isNotNull().and() - .field("size").isNotNull().and() - .field("createdBy").isNotNull().and() - .field("modifiedAt").isNull().and() - .field("name").isNull().and() - .field("modifiedBy").isNull().and() - .field("id").isNotNull().and() - .field("mimeType").isNull(); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that user who started the process can get task items with an invalid property") - public void getTaskItemsWithInvalidProperties() throws Exception - { - restClient.authenticateUser(userWhoStartsTask); - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); - taskItem = restClient.withWorkflowAPI().usingTask(taskModel).getTaskItems().getOneRandomEntry(); - itemModels = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() - .usingParams("properties=size,fake-prop").usingTask(taskModel).getTaskItems(); - restClient.assertStatusCodeIs(HttpStatus.OK); - itemModels.getOneRandomEntry().onModel().assertThat() - .fieldsCount().is(1).and() - .field("createdAt").isNull().and() - .field("size").isNotNull().and() - .field("createdBy").isNull().and() - .field("modifiedAt").isNull().and() - .field("name").isNull().and() - .field("modifiedBy").isNull().and() - .field("id").isNull().and() - .field("mimeType").isNull(); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that involved user in process that was deleted cannot get task items") - public void getTaskItemsByDeletedUserInvolvedInProcess() throws Exception - { - UserModel assigneeDeleted = dataUser.createRandomTestUser(); - restClient.authenticateUser(userWhoStartsTask); - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeDeleted); - - dataUser.usingAdmin().deleteUser(assigneeDeleted); - - itemModels = restClient.authenticateUser(assigneeDeleted).withWorkflowAPI().usingTask(taskModel).getTaskItems(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError().containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that involved user in process that was disabled cannot get task items") - public void getTaskItemsByDisabledUserInvolvedInProcess() throws Exception - { - UserModel assigneeDisabled = dataUser.createRandomTestUser(); - restClient.authenticateUser(userWhoStartsTask); - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeDisabled); - - dataUser.usingAdmin().disableUser(assigneeDisabled); - - itemModels = restClient.authenticateUser(assigneeDisabled).withWorkflowAPI().usingTask(taskModel).getTaskItems(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError().containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/GetTaskItemsSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/GetTaskItemsSanityTests.java deleted file mode 100644 index 42421e2dd..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/GetTaskItemsSanityTests.java +++ /dev/null @@ -1,75 +0,0 @@ -package org.alfresco.service.search.rest.workflow.tasks.items; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestItemModel; -import org.alfresco.rest.model.RestItemModelsCollection; -import org.alfresco.utility.Utility; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TaskModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - - -public class GetTaskItemsSanityTests extends RestTest -{ - private UserModel userModel, userWhoStartsTask, assignee; - private SiteModel siteModel; - private FileModel fileModel, document1; - private TaskModel taskModel; - private RestItemModel taskItem; - private RestItemModelsCollection itemModels; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - userWhoStartsTask = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, - description = "Verify that user that started the process gets task items") - public void getTaskItemsByUserWhoStartedProcess() throws Exception - { - restClient.authenticateUser(userWhoStartsTask); - document1 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document1); - Utility.checkObjectIsInitialized(taskItem, "taskItem"); - - itemModels = restClient.withWorkflowAPI().usingTask(taskModel).getTaskItems(); - restClient.assertStatusCodeIs(HttpStatus.OK); - itemModels.assertThat() - .entriesListIsNotEmpty().and() - .entriesListContains("id", taskItem.getId()).and() - .entriesListContains("name", document1.getName()); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, - description = "Verify that involved user in process gets task items") - public void getTaskItemsByUserInvolvedInProcess() throws Exception - { - restClient.authenticateUser(assignee); - document1 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document1); - - itemModels = restClient.withWorkflowAPI().usingTask(taskModel).getTaskItems(); - restClient.assertStatusCodeIs(HttpStatus.OK); - itemModels.assertThat() - .entriesListIsNotEmpty().and() - .entriesListContains("id", taskItem.getId()).and() - .entriesListContains("name", document1.getName()); - - } -} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/RemoveTaskItemTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/RemoveTaskItemTests.java deleted file mode 100644 index 6aa66a19f..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/RemoveTaskItemTests.java +++ /dev/null @@ -1,256 +0,0 @@ -package org.alfresco.service.search.rest.workflow.tasks.items; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestItemModel; -import org.alfresco.utility.model.*; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * @author bogdan.bocancea - */ -public class RemoveTaskItemTests extends RestTest -{ - private UserModel adminUser, userWhoStartsTask, assigneeUser; - private SiteModel siteModel; - private FileModel fileModel, document2; - private TaskModel taskModel; - private RestItemModel taskItem; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userWhoStartsTask = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - assigneeUser = dataUser.createRandomTestUser(); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, - description = "Delete existing task item") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - public void deleteTaskItem() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - restClient.authenticateUser(adminUser); - document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - - taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withWorkflowAPI().usingTask(taskModel).getTaskItems() - .assertThat().entriesListDoesNotContain("id", taskItem.getId()).and() - .entriesListDoesNotContain("name", document2.getName()); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Try to Delete existing task item using invalid taskId") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void deleteTaskItemUsingInvalidTaskId() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - restClient.authenticateUser(adminUser); - document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - - taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); - taskModel.setId("invalidTaskId"); - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidTaskId")); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Try to Delete existing task item using invalid itemId") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void deleteTaskItemUsingInvalidItemId() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - restClient.authenticateUser(adminUser); - document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); - taskItem.setId("incorrectItemId"); - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.PROCESS_ENTITY_NOT_FOUND, "incorrectItemId")); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Delete existing task item with empty task id") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void deleteTaskItemEmptyTaskId() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - restClient.authenticateUser(userWhoStartsTask); - document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); - taskModel.setId(""); - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Delete existing task item with empty item id") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void deleteTaskItemEmptyItemId() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - restClient.authenticateUser(userWhoStartsTask); - document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); - taskItem.setId(""); - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) - .assertLastError().containsSummary(RestErrorModel.DELETE_EMPTY_ARGUMENT); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Delete existing task item for completed task") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void deleteTaskItemForCompletedTask() throws Exception - { - TaskModel completedTask = dataWorkflow.usingUser(userWhoStartsTask) - .usingSite(siteModel) - .usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - restClient.authenticateUser(userWhoStartsTask); - document2 = dataContent.usingUser(userWhoStartsTask).usingSite(siteModel).createContent(DocumentType.XML); - taskItem = restClient.withWorkflowAPI().usingTask(completedTask).addTaskItem(document2); - dataWorkflow.usingUser(assigneeUser).taskDone(completedTask); - dataWorkflow.usingUser(userWhoStartsTask).taskDone(completedTask); - restClient.withWorkflowAPI().usingTask(completedTask).deleteTaskItem(taskItem); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, completedTask.getId())); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, - description = "Delete existing task item with candidate user") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - public void deleteTaskItemWithCandidateUser() throws Exception - { - GroupModel group = dataGroup.createRandomGroup(); - dataGroup.addListOfUsersToGroup(group, assigneeUser); - TaskModel groupTask = dataWorkflow.usingUser(userWhoStartsTask) - .usingSite(siteModel) - .usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); - - restClient.authenticateUser(userWhoStartsTask); - document2 = dataContent.usingUser(userWhoStartsTask).usingSite(siteModel).createContent(DocumentType.XML); - taskItem = restClient.withWorkflowAPI().usingTask(groupTask).addTaskItem(document2); - restClient.authenticateUser(assigneeUser) - .withWorkflowAPI().usingTask(groupTask).deleteTaskItem(taskItem); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Delete existing task item with unauthorized user") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void deleteTaskItemWithUnauthorizedUser() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - UserModel unauthorizedUser = dataUser.createRandomTestUser(); - document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - taskItem = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); - restClient.authenticateUser(unauthorizedUser).withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, - description = "Delete existing task item with inexistent user") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) -// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void deleteTaskItemWithInexistentUser() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - taskItem = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); - restClient.authenticateUser(UserModel.getRandomUserModel()).withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Delete existing task item for deleted task") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void deleteTaskItemFromDeletedProcess() throws Exception - { - ProcessModel deletedProcess = dataWorkflow.usingUser(userWhoStartsTask) - .usingSite(siteModel) - .usingResource(fileModel).createMoreReviewersWorkflowAndAssignTo(assigneeUser); - TaskModel task = restClient.authenticateUser(userWhoStartsTask) - .withWorkflowAPI().usingProcess(deletedProcess).getProcessTasks().getEntries().get(0).onModel(); - - document2 = dataContent.usingUser(userWhoStartsTask).usingSite(siteModel).createContent(DocumentType.XML); - taskItem = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingTask(task).addTaskItem(document2); - dataWorkflow.usingUser(userWhoStartsTask).deleteProcess(deletedProcess); - restClient.withWorkflowAPI().usingTask(task).deleteTaskItem(taskItem); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, task.getId())); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Delete task item twice") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void deleteTaskItemTwice() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - restClient.authenticateUser(userWhoStartsTask); - document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); - - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.PROCESS_ENTITY_NOT_FOUND, document2.getNodeRefWithoutVersion())) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Delete task item with locked document") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void deleteTaskItemWithLockedDocument() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - restClient.authenticateUser(userWhoStartsTask); - document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); - - dataContent.usingUser(userWhoStartsTask).usingResource(document2).checkOutDocument(); - - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); - restClient.assertStatusCodeIs(HttpStatus.CONFLICT) - .assertLastError().containsSummary(String.format(RestErrorModel.LOCKED_NODE_OPERATION, document2.getNodeRefWithoutVersion())) - .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Delete task item with deleted document") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void deleteTaskItemWithDeletedDocument() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - restClient.authenticateUser(userWhoStartsTask); - document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); - - dataContent.usingUser(userWhoStartsTask).usingResource(document2).deleteContent(); - - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.PROCESS_ENTITY_NOT_FOUND, document2.getNodeRefWithoutVersion())) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } -} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk1.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk1.java deleted file mode 100644 index 370df5668..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk1.java +++ /dev/null @@ -1,198 +0,0 @@ -package org.alfresco.service.search.rest.workflow.tasks.variables; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestVariableModel; -import org.alfresco.rest.model.RestVariableModelsCollection; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TaskModel; -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 AddTaskVariablesTestsBulk1 extends RestTest -{ - private UserModel userModel, userWhoStartsTask; - private SiteModel siteModel; - private FileModel fileModel; - private UserModel assigneeUser; - private TaskModel taskModel; - private RestVariableModel restVariablemodel; - private RestVariableModelsCollection restVariableCollection; - private RestVariableModel variableModel, variableModel1; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - userWhoStartsTask = dataUser.createRandomTestUser(); - assigneeUser = dataUser.createRandomTestUser(); - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, - description = "Create non-existing task variable with admin") - public void createTaskVariableWithAdmin() throws Exception - { - UserModel adminUser = dataUser.getAdminUser(); - restClient.authenticateUser(adminUser); - RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - - restVariablemodel = restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restVariablemodel.assertThat() - .field("scope").is(variableModel.getScope()) - .and().field("name").is(variableModel.getName()) - .and().field("value").is(variableModel.getValue()) - .and().field("type").is(variableModel.getType()); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Create non-existing task variable with admin") - public void createMultipleTaskVariablesWithAdmin() throws Exception - { - UserModel adminUser = dataUser.getAdminUser(); - restClient.authenticateUser(adminUser); - variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - variableModel1 = RestVariableModel.getRandomTaskVariableModel("global", "d:text"); - - restVariableCollection = restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariables(variableModel,variableModel1); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restVariableCollection.getEntries().get(0).onModel().assertThat() - .field("scope").is(variableModel.getScope()) - .and().field("name").is(variableModel.getName()) - .and().field("value").is(variableModel.getValue()) - .and().field("type").is(variableModel.getType()); - - restVariableCollection.getEntries().get(1).onModel().assertThat() - .field("scope").is(variableModel1.getScope()) - .and().field("name").is(variableModel1.getName()) - .and().field("value").is(variableModel1.getValue()) - .and().field("type").is(variableModel1.getType()); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, - description = "Create non-existing task variable with user involved in the process") - public void createTaskVariableWithInvolvedUser() throws Exception - { - restClient.authenticateUser(assigneeUser); - RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - - restVariablemodel = restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restVariablemodel.assertThat().field("scope").is(variableModel.getScope()) - .and().field("name").is(variableModel.getName()) - .and().field("value").is(variableModel.getValue()) - .and().field("type").is(variableModel.getType()); - - restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables().assertThat().entriesListContains("name", variableModel.getName()); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Create multiple non-existing task variable with involved user") - public void createMultipleTaskVariableWithInvolvedUser() throws Exception - { - restClient.authenticateUser(assigneeUser); - variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - variableModel1 = RestVariableModel.getRandomTaskVariableModel("global", "d:text"); - - restVariableCollection = restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariables(variableModel,variableModel1); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restVariableCollection.getEntries().get(0).onModel().assertThat() - .field("scope").is(variableModel.getScope()) - .and().field("name").is(variableModel.getName()) - .and().field("value").is(variableModel.getValue()) - .and().field("type").is(variableModel.getType()); - - restVariableCollection.getEntries().get(1).onModel().assertThat() - .field("scope").is(variableModel1.getScope()) - .and().field("name").is(variableModel1.getName()) - .and().field("value").is(variableModel1.getValue()) - .and().field("type").is(variableModel1.getType()); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, - description = "Create non-existing task variable with task owner") - public void createTaskVariableWithTaskOwner() throws Exception - { - restClient.authenticateUser(userWhoStartsTask); - RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - - restVariablemodel = restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restVariablemodel.assertThat().field("scope").is(variableModel.getScope()) - .and().field("name").is(variableModel.getName()) - .and().field("value").is(variableModel.getValue()) - .and().field("type").is(variableModel.getType()); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Create multiple non-existing task variable with task owner") - public void createMultipleTaskVariableWithTaskOwner() throws Exception - { - restClient.authenticateUser(userWhoStartsTask); - variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - variableModel1 = RestVariableModel.getRandomTaskVariableModel("global", "d:text"); - - restVariableCollection = restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariables(variableModel,variableModel1); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restVariableCollection.getEntries().get(0).onModel().assertThat() - .field("scope").is(variableModel.getScope()) - .and().field("name").is(variableModel.getName()) - .and().field("value").is(variableModel.getValue()) - .and().field("type").is(variableModel.getType()); - - restVariableCollection.getEntries().get(1).onModel().assertThat() - .field("scope").is(variableModel1.getScope()) - .and().field("name").is(variableModel1.getName()) - .and().field("value").is(variableModel1.getValue()) - .and().field("type").is(variableModel1.getType()); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Create non-existing task variable with any user") - public void createTaskVariableWithRandomUser() throws Exception - { - userModel = dataUser.createRandomTestUser(); - restClient.authenticateUser(userModel); - RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - - restVariablemodel = restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Create multiple non-existing task variable with any user") - public void createMultipleTaskVariableWithRandomUser() throws Exception - { - restClient.authenticateUser(userModel); - variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - variableModel1 = RestVariableModel.getRandomTaskVariableModel("global", "d:text"); - - restVariableCollection = restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariables(variableModel,variableModel1); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); - } - -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk2.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk2.java deleted file mode 100644 index bee35a55b..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk2.java +++ /dev/null @@ -1,241 +0,0 @@ -package org.alfresco.service.search.rest.workflow.tasks.variables; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.core.RestRequest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestVariableModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TaskModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - - -public class AddTaskVariablesTestsBulk2 extends RestTest -{ - private UserModel userWhoStartsTask, adminUser; - private SiteModel siteModel; - private FileModel fileModel; - private UserModel assigneeUser; - private TaskModel taskModel; - private RestVariableModel invalidVariableModel, variableModel, variableModel1; - - private String taskId; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userWhoStartsTask = dataUser.createRandomTestUser(); - assigneeUser = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - - taskId = taskModel.getId(); - restClient.authenticateUser(adminUser); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case invalid variableBody is provided") - public void failedAddingTaskVariableIfInvalidBodyIsProvided() throws Exception - { - invalidVariableModel = RestVariableModel.getRandomTaskVariableModel("instance", "d:char"); - restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(invalidVariableModel); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Illegal value for variable scope: 'instance'."); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Adding multiple task variable is falling in case invalid variableBody is provided") - public void failedAddingMultipleTaskVariableIfInvalidBodyIsProvided() throws Exception - { - variableModel = RestVariableModel.getRandomTaskVariableModel("instance", "d:char"); - variableModel1 = RestVariableModel.getRandomTaskVariableModel("global", "d:text"); - restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariables(variableModel, variableModel1); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Illegal value for variable scope: 'instance'."); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case empty body type is provided") - public void failedAddingTaskVariableIfEmptyBodyIsProvided() throws Exception - { - RestVariableModel invalidVariableModel = RestVariableModel.getRandomTaskVariableModel("", ""); - restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(invalidVariableModel); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary("Variable scope is required and can only be 'local' or 'global'."); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Adding multiple task variable is falling in case empty body type is provided") - public void failedAddingMultipleTaskVariableIfEmptyBodyIsProvided() throws Exception - { - RestVariableModel invalidVariableModel = RestVariableModel.getRandomTaskVariableModel("", ""); - variableModel1 = RestVariableModel.getRandomTaskVariableModel("global", "d:text"); - restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariables(invalidVariableModel, variableModel1); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary("Variable scope is required and can only be 'local' or 'global'."); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case incomplete body type is provided") - public void failedAddingTaskVariableIfIncompleteBodyIsProvided() throws Exception - { - RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{\"name\": \"missingVariableScope\",\"value\": \"test\",\"type\": \"d:text\"}", - "tasks/{taskId}/variables", taskId); - restClient.processModel(RestVariableModel.class, request); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary("Variable scope is required and can only be 'local' or 'global'."); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case incomplete body - missing required: name type is provided") - public void failedAddingTaskVariableIfIncompleteRequiredBodyIsProvided() throws Exception - { - RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{\"scope\": \"local\",\"value\": \"missingVariableName\",\"type\": \"d:text\"}", - "tasks/{taskId}/variables", taskId); - restClient.processModel(RestVariableModel.class, request); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Variable name is required."); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case invalid type is provided") - public void failedAddingTaskVariableIfInvalidTypeIsProvided() throws Exception - { - RestVariableModel invalidVariableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:char"); - taskModel.setId(taskId); - - restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(invalidVariableModel); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Unsupported type of variable: 'd:char'."); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Adding multiple task variable is falling in case invalid type is provided") - public void failedAddingMultipleTaskVariableIfInvalidTypeIsProvided() throws Exception - { - RestVariableModel invalidVariableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:char"); - taskModel.setId(taskId); - variableModel1 = RestVariableModel.getRandomTaskVariableModel("global", "d:text"); - - restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariables(invalidVariableModel, variableModel1); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Unsupported type of variable: 'd:char'."); - } - - @Bug(id = "ACE-5674") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case invalid type prefix is provided") - public void failedAddingTaskVariableIfInvalidTypePrefixIsProvided() throws Exception - { - RestVariableModel invalidVariableModel = RestVariableModel.getRandomTaskVariableModel("local", "ddm:text"); - taskModel.setId(taskId); - - restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(invalidVariableModel); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Namespace prefix ddm is not mapped to a namespace URI"); - } - - @Bug(id = "ACE-5674") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Adding multiple task variable is falling in case invalid type prefix is provided") - public void failedAddingMultipleTaskVariableIfInvalidTypePrefixIsProvided() throws Exception - { - RestVariableModel invalidVariableModel = RestVariableModel.getRandomTaskVariableModel("local", "ddm:text"); - taskModel.setId(taskId); - variableModel1 = RestVariableModel.getRandomTaskVariableModel("global", "d:text"); - variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - - restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariables(invalidVariableModel,variableModel1, variableModel); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Namespace prefix ddm is not mapped to a namespace URI"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case invalid scope is provided") - public void failedAddingTaskVariableIfInvalidScopeIsProvided() throws Exception - { - RestVariableModel invalidVariableModel = RestVariableModel.getRandomTaskVariableModel("instance", "d:text"); - taskModel.setId(taskId); - - restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(invalidVariableModel); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Illegal value for variable scope: 'instance'."); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Adding multiple task variable is falling in case invalid scope is provided") - public void failedAddingMultipleTaskVariableIfInvalidScopeIsProvided() throws Exception - { - RestVariableModel invalidVariableModel = RestVariableModel.getRandomTaskVariableModel("instance", "d:text"); - taskModel.setId(taskId); - variableModel1 = RestVariableModel.getRandomTaskVariableModel("global", "d:text"); - variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - - restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariables(invalidVariableModel, variableModel, variableModel1); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Illegal value for variable scope: 'instance'."); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case invalid task id is provided") - public void failedAddingTaskVariableIfInvalidTaskIdIsProvided() throws Exception - { - RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - taskModel.setId(taskModel.getId() + "TEST"); - restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, taskModel.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Adding multiple task variable is falling in case invalid task id is provided") - public void failedAddingMultipleTaskVariableIfInvalidTaskIdIsProvided() throws Exception - { - variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - taskModel.setId(taskModel.getId() + "TEST"); - variableModel1 = RestVariableModel.getRandomTaskVariableModel("global", "d:text"); - restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariables(variableModel, variableModel1); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, taskModel.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case invalid task id is provided") - public void failedAddingTaskVariableIfInvalidValueIsProvided() throws Exception - { - RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:int"); - variableModel.setValue("invalidValue"); - - restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("For input string: \"invalidValue\""); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Adding multiple task variable is falling in case invalid task id is provided") - public void failedAddingMultipleTaskVariableIfInvalidValueIsProvided() throws Exception - { - variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:int"); - variableModel.setValue("invalidValue"); - variableModel1 = RestVariableModel.getRandomTaskVariableModel("global", "d:text"); - - restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariables(variableModel, variableModel1); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("For input string: \"invalidValue\""); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk3.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk3.java deleted file mode 100644 index c819511b9..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk3.java +++ /dev/null @@ -1,155 +0,0 @@ -package org.alfresco.service.search.rest.workflow.tasks.variables; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.core.RestRequest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestVariableModel; -import org.alfresco.rest.model.RestVariableModelsCollection; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TaskModel; -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 AddTaskVariablesTestsBulk3 extends RestTest -{ - private UserModel userWhoStartsTask, adminUser; - private SiteModel siteModel; - private FileModel fileModel; - private UserModel assigneeUser; - private TaskModel taskModel; - private RestVariableModel restVariablemodel, variableModel, variableModel1; - private RestVariableModelsCollection restVariableCollection; - private String taskId; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userWhoStartsTask = dataUser.createRandomTestUser(); - assigneeUser = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - - taskId = taskModel.getId(); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Create task variable with name containing symbols") - public void createTaskVariableWithSymbolsInName() throws Exception - { - UserModel adminUser = dataUser.getAdminUser(); - restClient.authenticateUser(adminUser); - RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - variableModel.setName("!@#$%^&*({}<>.,;'=_|"); - restVariablemodel = restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restVariablemodel.assertThat() - .field("scope").is(variableModel.getScope()) - .and().field("name").is(variableModel.getName()) - .and().field("value").is(variableModel.getValue()) - .and().field("type").is(variableModel.getType()); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Create multiple task variable with name containing symbols") - public void createMultipleTaskVariableWithSymbolsInName() throws Exception - { - UserModel adminUser = dataUser.getAdminUser(); - restClient.authenticateUser(adminUser); - variableModel1 = RestVariableModel.getRandomTaskVariableModel("global", "d:text"); - variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - variableModel.setName("!@#$%^&*({}<>.,;'=_|"); - - restVariableCollection = restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariables(variableModel,variableModel1); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restVariableCollection.getEntries().get(0).onModel().assertThat() - .field("scope").is(variableModel.getScope()) - .and().field("name").is(variableModel.getName()) - .and().field("value").is(variableModel.getValue()) - .and().field("type").is(variableModel.getType()); - - restVariableCollection.getEntries().get(1).onModel().assertThat() - .field("scope").is(variableModel1.getScope()) - .and().field("name").is(variableModel1.getName()) - .and().field("value").is(variableModel1.getValue()) - .and().field("type").is(variableModel1.getType()); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Create task variable with empty name") - public void createTaskVariableWithEmptyName() throws Exception - { - UserModel adminUser = dataUser.getAdminUser(); - restClient.authenticateUser(adminUser); - RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - variableModel.setName(""); - restVariablemodel = restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsErrorKey(RestErrorModel.VARIABLE_NAME_REQUIRED) - .containsSummary(RestErrorModel.VARIABLE_NAME_REQUIRED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Update task variable with invalid variable name") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void createTaskVariableWithInvalidVariableName() throws Exception - { - restClient.authenticateUser(adminUser).withWorkflowAPI(); - RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{\"scope\": \"local\",\"names\": \"varName\",\"value\": \"test\"," - + "\"type\": \"d:text\"}", "tasks/{taskId}/variables", taskId); - restClient.processModel(RestVariableModel.class, request); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsSummary(String.format(RestErrorModel.NO_CONTENT,"Unrecognized field " + "\"names\"")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Create task variable with invalid name") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void createTaskVariableWithInvalidName() throws Exception - { - restClient.authenticateUser(adminUser).withWorkflowAPI(); - RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{\"scope\": \"local\",\"name\": ',\"value\": \"test\"," - + "\"type\": \"d:text\"}", "tasks/{taskId}/variables", taskId); - restClient.processModel(RestVariableModel.class, request); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsSummary(String.format(RestErrorModel.NO_CONTENT,"Unexpected character " + "('''")); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Create task variable with empty name") - public void failedCreatingMultipleTaskVariableWithEmptyName() throws Exception - { - UserModel adminUser = dataUser.getAdminUser(); - restClient.authenticateUser(adminUser); - variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - variableModel1 = RestVariableModel.getRandomTaskVariableModel("global", "d:text"); - variableModel.setName(""); - - restVariableCollection = restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariables(variableModel, variableModel1); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsErrorKey(RestErrorModel.VARIABLE_NAME_REQUIRED) - .containsSummary(RestErrorModel.VARIABLE_NAME_REQUIRED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/DeleteTaskVariableTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/DeleteTaskVariableTests.java deleted file mode 100644 index 8a41452c1..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/DeleteTaskVariableTests.java +++ /dev/null @@ -1,231 +0,0 @@ -package org.alfresco.service.search.rest.workflow.tasks.variables; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestVariableModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TaskModel; -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 bogdan.bocancea - */ -public class DeleteTaskVariableTests extends RestTest -{ - private UserModel userModel, assigneeUser, adminUser; - private SiteModel siteModel; - private FileModel fileModel; - private TaskModel taskModel; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userModel = dataUser.createRandomTestUser(); - assigneeUser = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, - description = "Delete existing task variable") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - public void deleteTaskVariable() throws Exception - { - restClient.authenticateUser(adminUser); - RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - - restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables() - .assertThat().entriesListDoesNotContain("name", variableModel.getName()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Try to delete existing task variable using invalid task id") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void tryToDeleteTaskVariableUsingInvalidTaskId() throws Exception - { - restClient.authenticateUser(adminUser); - RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - - restClient.withWorkflowAPI().usingTask(taskModel).updateTaskVariable(variableModel); - taskModel.setId("incorrectTaskId"); - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, - description = "Delete task variable with any user") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - public void deleteTaskVariableByAnyUser() throws Exception - { - restClient.authenticateUser(userModel); - RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - - restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables() - .assertThat().entriesListDoesNotContain("name", variableModel.getName()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Delete task variable with invalid type") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void deleteTaskVariableInvalidType() throws Exception - { - restClient.authenticateUser(userModel); - RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); - variableModel.setType("invalid-type"); - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables() - . assertThat().entriesListDoesNotContain("name", variableModel.getName()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Delete task variable with invalid name") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void deleteTaskVariableInvalidName() throws Exception - { - restClient.authenticateUser(userModel); - RestVariableModel variableModel = new RestVariableModel("local", "<>.,;/|-+=%", "d:text", "invalid name"); - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Create, update, delete task variable with any user") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void createUpdateDeleteTaskVariableByAnyUser() throws Exception - { - restClient.authenticateUser(userModel); - RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - - restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); - variableModel.setName("new-variable"); - restClient.withWorkflowAPI().usingTask(taskModel).updateTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables() - .assertThat().entriesListDoesNotContain("name", variableModel.getName()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Delete task variable by non assigned user") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void deleteTaskVariableByNonAssignedUser() throws Exception - { - UserModel nonAssigned = dataUser.createRandomTestUser(); - RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - - restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); - restClient.authenticateUser(nonAssigned).withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Delete task variable by inexistent user") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) -// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void deleteTaskVariableByInexistentUser() throws Exception - { - RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); - restClient.authenticateUser(UserModel.getRandomUserModel()) - .withWorkflowAPI() - .usingTask(taskModel) - .deleteTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Delete task variable twice") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void deleteTaskVariableTwice() throws Exception - { - restClient.authenticateUser(userModel); - RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - - restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables() - .assertThat().entriesListDoesNotContain("name", variableModel.getName()); - - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, variableModel.getName())) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Delete task variable with empty variable name") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void deleteTaskEmptyVariableName() throws Exception - { - restClient.authenticateUser(userModel); - RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - - restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); - variableModel.setName(""); - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) - .assertLastError().containsErrorKey(RestErrorModel.DELETE_EMPTY_ARGUMENT) - .containsSummary(RestErrorModel.DELETE_EMPTY_ARGUMENT) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Delete task variable with empty variable scope") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void deleteTaskEmptyVariableScope() throws Exception - { - restClient.authenticateUser(userModel); - RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - - restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); - variableModel.setScope(""); - variableModel.setType(""); - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables() - .assertThat().entriesListDoesNotContain("name", variableModel.getName()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Delete task variable with invalid variable name") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void deleteTaskInvalidVariableName() throws Exception - { - restClient.authenticateUser(userModel); - RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - - restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); - variableModel.setName("invalid-name"); - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalid-name")) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/GetTaskVariablesTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/GetTaskVariablesTests.java deleted file mode 100644 index e0113fc4e..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/GetTaskVariablesTests.java +++ /dev/null @@ -1,252 +0,0 @@ -package org.alfresco.service.search.rest.workflow.tasks.variables; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.model.RestTaskModel; -import org.alfresco.rest.model.RestVariableModelsCollection; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TaskModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class GetTaskVariablesTests extends RestTest -{ - private UserModel userWhoStartsTask, assignee; - private SiteModel siteModel; - private FileModel fileModel; - private TaskModel taskModel; - private RestVariableModelsCollection variableModels; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - userWhoStartsTask = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, - description = "Verify that user that started the process gets task variables") - public void getTaskVariablesByUserWhoStartedProcess() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask) - .usingSite(siteModel).usingResource(fileModel) - .createNewTaskAndAssignTo(assignee); - restClient.authenticateUser(userWhoStartsTask); - variableModels = restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables(); - restClient.assertStatusCodeIs(HttpStatus.OK); - variableModels.assertThat().entriesListIsNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, - description = "Verify that user that is involved in the process gets task variables") - public void getTaskVariablesByUserInvolvedInProcess() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask) - .usingSite(siteModel).usingResource(fileModel) - .createNewTaskAndAssignTo(assignee); - restClient.authenticateUser(assignee); - variableModels = restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables(); - restClient.assertStatusCodeIs(HttpStatus.OK); - variableModels.assertThat().entriesListIsNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, - description = "Verify that user that is not involved in the process gets task variables") - public void getTaskVariablesUsingAnyUser() throws Exception - { - UserModel randomUser = dataUser.createRandomTestUser(); - taskModel = dataWorkflow.usingUser(userWhoStartsTask) - .usingSite(siteModel).usingResource(fileModel) - .createNewTaskAndAssignTo(assignee); - restClient.authenticateUser(randomUser); - restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, - description = "Verify that admin is able to task variables") - public void getTaskVariablesUsingAdmin() throws Exception - { - UserModel adminUser = dataUser.getAdminUser(); - taskModel = dataWorkflow.usingUser(userWhoStartsTask) - .usingSite(siteModel).usingResource(fileModel) - .createNewTaskAndAssignTo(assignee); - restClient.authenticateUser(adminUser); - variableModels = restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables(); - restClient.assertStatusCodeIs(HttpStatus.OK); - variableModels.assertThat().entriesListIsNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify if get task variables request returns status code 404 when invalid taskId is used") - public void getTaskVariablesUsingInvalidTaskId() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask) - .usingSite(siteModel).usingResource(fileModel) - .createNewTaskAndAssignTo(assignee); - taskModel.setId("invalidId"); - - restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingTask(taskModel).getTaskVariables(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidId")) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify if get task variables request returns status code 404 when empty taskId is used") - public void getTaskVariablesUsingEmptyTaskId() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); - taskModel.setId(""); - - restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingTask(taskModel).getTaskVariables(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify if get task variables request returns status code 200 after the task is finished.") - public void getTaskVariablesAfterFinishingTask() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); - dataWorkflow.usingUser(assignee).taskDone(taskModel); - - variableModels = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingTask(taskModel).getTaskVariables(); - restClient.assertStatusCodeIs(HttpStatus.OK); - variableModels.assertThat().entriesListIsNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify if get task variables request returns status code 200 after the process is deleted (Task state is now completed.)") - public void getTaskVariablesAfterDeletingProcess() throws Exception - { - RestProcessModel addedProcess = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.Normal); - RestTaskModel addedTask = restClient.withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess); - restClient.withWorkflowAPI().usingProcess(addedProcess).deleteProcess(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - variableModels = restClient.withWorkflowAPI().usingTask(addedTask).getTaskVariables(); - restClient.assertStatusCodeIs(HttpStatus.OK); - variableModels.assertThat().entriesListIsNotEmpty(); - } - - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify user gets task variables that matches a where clause.") - public void getTaskVariablesWithWhereClauseAsParameter() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); - variableModels = restClient.authenticateUser(userWhoStartsTask).where("scope='local'") - .withWorkflowAPI().usingTask(taskModel).getTaskVariables(); - restClient.assertStatusCodeIs(HttpStatus.OK); - variableModels.assertThat().entriesListIsNotEmpty() - .and().entriesListDoesNotContain("scope", "global") - .and().paginationField("totalItems").is("8"); - - variableModels = restClient.authenticateUser(userWhoStartsTask) - .withWorkflowAPI().usingTask(taskModel).getTaskVariables(); - restClient.assertStatusCodeIs(HttpStatus.OK); - variableModels.assertThat().entriesListContains("scope", "global") - .and().paginationField("totalItems").is("30"); - } - - @Bug(id="MNT-17438") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify user gets task with 'maxItems' parameter") - public void getTaskVariablesWithMaxItems() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); - variableModels = restClient.authenticateUser(userWhoStartsTask) - .withWorkflowAPI().usingParams("maxItems=2").usingTask(taskModel).getTaskVariables(); - restClient.assertStatusCodeIs(HttpStatus.OK); - variableModels.assertThat().entriesListIsNotEmpty() - .and().paginationField("count").is("2"); - } - - @Bug(id="MNT-17438") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify user gets task with 'skipCount' parameter") - public void getTaskVariablesWithSkipCount() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); - variableModels = restClient.authenticateUser(userWhoStartsTask) - .withWorkflowAPI().usingParams("skipCount=10").usingTask(taskModel).getTaskVariables(); - restClient.assertStatusCodeIs(HttpStatus.OK); - variableModels.assertThat().entriesListIsNotEmpty() - .and().paginationField("count").is("20"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify user cannot get task variables with invalid where clause.") - public void getTaskVariablesWithInvalidWhereClauseAsParameter() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); - variableModels = restClient.authenticateUser(userWhoStartsTask).where("scope='fake-where'") - .withWorkflowAPI().usingTask(taskModel).getTaskVariables(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_WHERE_QUERY, "Invalid value for 'scope' used in query: fake-where.")) - .containsErrorKey(RestErrorModel.INVALID_QUERY_ERRORKEY) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify user gets tasks variables with 'properties' parameter") - public void getTaskVariablesWithValidProperties() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); - variableModels = restClient.authenticateUser(userWhoStartsTask).withParams("properties=scope,name") - .withWorkflowAPI().usingTask(taskModel).getTaskVariables(); - restClient.assertStatusCodeIs(HttpStatus.OK); - variableModels.assertThat().entriesListIsNotEmpty(); - variableModels.getOneRandomEntry().onModel().assertThat() - .fieldsCount().is(2).and() - .field("type").isNull().and() - .field("value").isNull().and() - .field("scope").isNotEmpty().and() - .field("name").isNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify user cannot get tasks variables with invalid 'properties' parameter") - public void getTaskVariablesWithInvalidProperties() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); - variableModels = restClient.authenticateUser(userWhoStartsTask).withParams("properties=fake") - .withWorkflowAPI().usingTask(taskModel).getTaskVariables(); - restClient.assertStatusCodeIs(HttpStatus.OK); - variableModels.getOneRandomEntry().onModel().assertThat() - .fieldsCount().is(0).and() - .field("type").isNull().and() - .field("value").isNull().and() - .field("scope").isNull().and() - .field("name").isNull(); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk1.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk1.java deleted file mode 100644 index 4e2bed673..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk1.java +++ /dev/null @@ -1,79 +0,0 @@ -package org.alfresco.service.search.rest.workflow.tasks.variables; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestVariableModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TaskModel; -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 UpdateTaskVariableTestsBulk1 extends RestTest -{ - private UserModel userModel; - private UserModel adminUser; - private SiteModel siteModel; - private FileModel fileModel; - private UserModel assigneeUser; - private TaskModel taskModel; - - private RestVariableModel taskVariable; - private RestVariableModel variableModel; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - assigneeUser = dataUser.createRandomTestUser(); - taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, - description = "Create non-existing task variable") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - public void createTaskVariable() throws Exception - { - restClient.authenticateUser(adminUser); - variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - - taskVariable = restClient.withWorkflowAPI().usingTask(taskModel).updateTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - taskVariable.assertThat().field("scope").is(taskVariable.getScope()) - .and().field("name").is(taskVariable.getName()) - .and().field("type").is(taskVariable.getType()) - .and().field("value").is(taskVariable.getValue()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, - description = "Update existing task variable") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - public void updateExistingTaskVariable() throws Exception - { - restClient.authenticateUser(adminUser); - variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - - taskVariable = restClient.withWorkflowAPI().usingTask(taskModel).updateTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - taskVariable.assertThat().field("scope").is(taskVariable.getScope()) - .and().field("name").is(taskVariable.getName()) - .and().field("type").is(taskVariable.getType()) - .and().field("value").is(taskVariable.getValue()); - - variableModel.setValue("updatedValue"); - taskVariable = restClient.withWorkflowAPI().usingTask(taskModel).updateTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - taskVariable.assertThat().field("value").is("updatedValue"); - } -} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk2.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk2.java deleted file mode 100644 index 13b2ea472..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk2.java +++ /dev/null @@ -1,173 +0,0 @@ -package org.alfresco.service.search.rest.workflow.tasks.variables; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestVariableModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TaskModel; -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 bogdan.bocancea - */ -public class UpdateTaskVariableTestsBulk2 extends RestTest -{ - private UserModel userModel; - private SiteModel siteModel; - private FileModel fileModel; - private UserModel assigneeUser; - private TaskModel taskModel; - private RestVariableModel taskVariable; - private RestVariableModel variableModel; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - assigneeUser = dataUser.createRandomTestUser(); - taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, - description = "Update task variable by user who started the process") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - public void updateTaskVariableByUserWhoStartedProcess() throws Exception - { - variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - taskVariable = restClient.authenticateUser(userModel) - .withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - variableModel.setValue("new-value"); - variableModel.setName("new-name"); - taskVariable = restClient.authenticateUser(userModel). - withWorkflowAPI().usingTask(taskModel).updateTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - taskVariable.assertThat().field("value").is("new-value") - .and().field("name").is("new-name"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Update task variable with symbols in name") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void updateTaskVariableWithSymbolsInName() throws Exception - { - String symbolName = "<>.,;-'+=%|[]#*&-+"; - variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - taskVariable = restClient.authenticateUser(userModel) - .withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - variableModel.setName(symbolName); - taskVariable = restClient.authenticateUser(userModel). - withWorkflowAPI().usingTask(taskModel).updateTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - taskVariable.assertThat().field("name").is(symbolName); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Update task variable with invalid task id") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void updateTaskVariableWithInvalidTaskId() throws Exception - { - TaskModel invalidTask = new TaskModel(userModel.getUsername()); - invalidTask.setId("invalid-task-id"); - taskVariable = restClient.authenticateUser(userModel). - withWorkflowAPI().usingTask(invalidTask) - .updateTaskVariable(RestVariableModel.getRandomTaskVariableModel("local", "d:text")); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, invalidTask.getId())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Update task variable with invalid scope") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void updateTaskVariableWithInvalidScope() throws Exception - { - variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - taskVariable = restClient.authenticateUser(userModel) - .withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - variableModel.setScope("invalid-scope"); - taskVariable = restClient.authenticateUser(userModel). - withWorkflowAPI().usingTask(taskModel).updateTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.ILLEGAL_SCOPE, "invalid-scope")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Update task variable with invalid type") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void updateTaskVariableWithInvalidType() throws Exception - { - variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - taskVariable = restClient.authenticateUser(userModel) - .withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - variableModel.setType("d:invalidType"); - taskVariable = restClient.authenticateUser(userModel). - withWorkflowAPI().usingTask(taskModel).updateTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.UNSUPPORTED_TYPE, "d:invalidType")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Update task variable with symbols in value") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void updateTaskVariableWithSymbolsInValue() throws Exception - { - String symbolValue = "<>.,;-'+=%|[]#*&-+/\\#!@"; - variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - taskVariable = restClient.authenticateUser(userModel) - .withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - variableModel.setValue(symbolValue); - taskVariable = restClient.authenticateUser(userModel). - withWorkflowAPI().usingTask(taskModel).updateTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - taskVariable.assertThat().field("value").is(symbolValue); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Update task variable by non assigned user") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void updateTaskVariableByNonAssignedUser() throws Exception - { - UserModel nonAssigned = dataUser.createRandomTestUser(); - variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - taskVariable = restClient.authenticateUser(userModel) - .withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - variableModel.setName("new-name"); - taskVariable = restClient.authenticateUser(nonAssigned) - .withWorkflowAPI().usingTask(taskModel).updateTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Update task variable by inexistent user") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) -// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void updateTaskVariableByNonexistentUser() throws Exception - { - variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - taskVariable = restClient.authenticateUser(userModel) - .withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - variableModel.setName("new-name"); - taskVariable = restClient.authenticateUser(UserModel.getRandomUserModel()) - .withWorkflowAPI().usingTask(taskModel).updateTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - -} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk3.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk3.java deleted file mode 100644 index 30823d3a2..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk3.java +++ /dev/null @@ -1,247 +0,0 @@ -package org.alfresco.service.search.rest.workflow.tasks.variables; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.core.RestRequest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestVariableModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TaskModel; -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 UpdateTaskVariableTestsBulk3 extends RestTest -{ - private SiteModel siteModel; - private FileModel fileModel; - private TaskModel taskModel; - private UserModel userModel; - private RestVariableModel taskVariable, updatedTaskVariable; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(userModel); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Update task variable with invalid name - PUT call") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void updateTaskVariableWithInvalidVariableName() throws Exception - { - taskVariable = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - restClient.authenticateUser(userModel) - .withWorkflowAPI().usingTask(taskModel).addTaskVariable(taskVariable); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"scope\": \"local\",\"names\": \"varName\",\"value\": \"test\"," - + "\"type\": \"d:text\"}", - "tasks/{taskId}/variables/{variableName}", taskModel.getId(), taskVariable.getName()); - restClient.processModel(RestVariableModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsSummary(String.format(RestErrorModel.NO_CONTENT,"Unrecognized field " + "\"names\"")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Update task variable with invalid name - PUT call") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void updateTaskVariableWithInvalidVariableValue() throws Exception - { - taskVariable = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - restClient.authenticateUser(userModel) - .withWorkflowAPI().usingTask(taskModel).addTaskVariable(taskVariable); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"scope\": \"local\",\"name\": \"varName\",\"values\": \"test\"," - + "\"type\": \"d:text\"}", - "tasks/{taskId}/variables/{variableName}", taskModel.getId(), taskVariable.getName()); - restClient.processModel(RestVariableModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsSummary(String.format(RestErrorModel.NO_CONTENT,"Unrecognized field " + "\"values\"")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Update task variable with invalid name - PUT call") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void updateTaskVariableWithEmptyVariableName() throws Exception - { - taskVariable = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - restClient.authenticateUser(userModel) - .withWorkflowAPI().usingTask(taskModel).addTaskVariable(taskVariable); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"scope\": \"local\",\"\": \"varName\",\"value\": \"test\"," - + "\"type\": \"d:text\"}", - "tasks/{taskId}/variables/{variableName}", taskModel.getId(), taskVariable.getName()); - restClient.processModel(RestVariableModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsSummary(String.format(RestErrorModel.NO_CONTENT,"Unrecognized field " + "\"\"")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Update task variable with empty name - PUT call") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void updateTaskVariableWithEmptyName() throws Exception - { - taskVariable = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).addTaskVariable(taskVariable); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - taskVariable.setName(""); - restClient.withWorkflowAPI().usingTask(taskModel).updateTaskVariable(taskVariable); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) - .assertLastError().containsErrorKey(RestErrorModel.PUT_EMPTY_ARGUMENT) - .containsSummary(RestErrorModel.PUT_EMPTY_ARGUMENT) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Update task variable with empty name - PUT call") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void updateTaskVariableWithInvalidName() throws Exception - { - taskVariable = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).addTaskVariable(taskVariable); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"scope\": \"local\",\"name\": ',\"value\": \"test\"," - + "\"type\": \"d:text\"}", - "tasks/{taskId}/variables/{variableName}", taskModel.getId(), taskVariable.getName()); - restClient.processModel(RestVariableModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsSummary(String.format(RestErrorModel.NO_CONTENT,"Unexpected character " + "('''")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Update task variable with empty name - PUT call") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void updateTaskVariableWithInvalidValue() throws Exception - { - taskVariable = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).addTaskVariable(taskVariable); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"scope\": \"local\",\"name\": \"varName\",\"value\"::," - + "\"type\": \"d:text\"}", - "tasks/{taskId}/variables/{variableName}", taskModel.getId(), taskVariable.getName()); - restClient.processModel(RestVariableModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsSummary(String.format(RestErrorModel.NO_CONTENT,"Unexpected character " + "(':'")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Update task variable with empty name - PUT call") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void updateTaskVariableWithMissingType() throws Exception - { - taskVariable = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - restClient.authenticateUser(userModel) - .withWorkflowAPI().usingTask(taskModel).addTaskVariable(taskVariable); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"scope\": \"local\",\"name\": \"varName\",\"value\": \"test\"}", - "tasks/{taskId}/variables/{variableName}", taskModel.getId(), taskVariable.getName()); - restClient.processModel(RestVariableModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.OK); - taskVariable.assertThat().field("scope").is(taskVariable.getScope()) - .and().field("name").is(taskVariable.getName()) - .and().field("type").is("d:text") - .and().field("value").is(taskVariable.getValue()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Update task variable with empty name - PUT call") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void updateTaskVariableWithMissingTypeAndValue() throws Exception - { - taskVariable = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - restClient.authenticateUser(userModel) - .withWorkflowAPI().usingTask(taskModel).addTaskVariable(taskVariable); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"scope\": \"local\",\"name\": \"varName\"}", - "tasks/{taskId}/variables/{variableName}", taskModel.getId(), taskVariable.getName()); - updatedTaskVariable = restClient.processModel(RestVariableModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedTaskVariable.assertThat().field("scope").is(updatedTaskVariable.getScope()) - .and().field("name").is(updatedTaskVariable.getName()) - .and().field("type").is("d:any"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Update task variable with invalid name - PUT call") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void updateTaskVariableWithEmptyBody() throws Exception - { - taskVariable = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - restClient.authenticateUser(userModel) - .withWorkflowAPI().usingTask(taskModel).addTaskVariable(taskVariable); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{}", - "tasks/{taskId}/variables/{variableName}", taskModel.getId(), taskVariable.getName()); - restClient.processModel(RestVariableModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsErrorKey(RestErrorModel.VARIABLE_NAME_REQUIRED) - .containsSummary(RestErrorModel.VARIABLE_NAME_REQUIRED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Update task variable with invalid name - PUT call") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void updateTaskVariableWithInvalidBody() throws Exception - { - taskVariable = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - restClient.authenticateUser(userModel) - .withWorkflowAPI().usingTask(taskModel).addTaskVariable(taskVariable); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"scope\": \"local\",\"name\": \"varName\",\"value\": \"test\"," - + "\"type\": \"d:text\", \"errorKey\": \"invalidBody\"}", - "tasks/{taskId}/variables/{variableName}", taskModel.getId(), taskVariable.getName()); - restClient.processModel(RestVariableModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsSummary(String.format(RestErrorModel.NO_CONTENT,"Unrecognized field " + "\"errorKey\"")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Update task variable with empty name - PUT call") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void updateTwiceInARowSameTaskVariable() throws Exception - { - taskVariable = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).addTaskVariable(taskVariable); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - taskVariable.setName("newName"); - taskVariable.setScope("global"); - updatedTaskVariable = restClient.withWorkflowAPI().usingTask(taskModel).updateTaskVariable(taskVariable); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedTaskVariable.assertThat().field("scope").is("global"); - updatedTaskVariable.assertThat().field("name").is("newName"); - - updatedTaskVariable = restClient.withWorkflowAPI().usingTask(taskModel).updateTaskVariable(taskVariable); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedTaskVariable.assertThat().field("scope").is("global"); - updatedTaskVariable.assertThat().field("name").is("newName"); - } -} From f37f0ee09d3bbe738b34e4e2f59686d18b49a577 Mon Sep 17 00:00:00 2001 From: agazzarini Date: Fri, 29 Mar 2019 16:07:34 +0100 Subject: [PATCH 1479/1491] [ SEARCH-1485 ] moved RESTAPI tests under org.alfresco.service.search.rest namespace (package) --- .../renditions/AvailableRenditionTests.java | 134 --- .../rest/search/FacetedSearchTest.java | 322 -------- .../alfresco/rest/search/FingerPrintTest.java | 166 ---- .../alfresco/rest/search/SearchAPATHTest.java | 185 ----- .../org/alfresco/rest/search/SearchTest.java | 309 ------- .../alfresco/rest/search/ShardInfoTest.java | 85 -- .../rest/search/solr/SearchSolrAPITest.java | 120 --- .../rest/search/sql/SearchSQLAPITest.java | 781 ------------------ .../rest/search/sql/SearchSQLPhraseTest.java | 256 ------ .../rest/search/sql/SearchSQLViaJDBCTest.java | 213 ----- .../org/alfresco/rest/tags/GetTagTests.java | 139 ---- .../org/alfresco/rest/tags/GetTagsTests.java | 230 ------ .../alfresco/rest/tags/UpdateTagTests.java | 269 ------ .../alfresco/rest/tags/nodes/AddTagTests.java | 337 -------- .../rest/tags/nodes/AddTagsTests.java | 150 ---- .../rest/tags/nodes/DeleteTagTests.java | 287 ------- .../rest/tags/nodes/GetNodeTagsTests.java | 319 ------- .../search}/rest/FunctionalCasesTests.java | 3 +- .../service/search}/rest/NetworkDataPrep.java | 3 +- .../service/search}/rest/RestTest.java | 2 +- .../search}/rest/actions/ActionsTests.java | 2 +- .../service/search}/rest/aos/AosApiTest.java | 2 +- .../service/search}/rest/audit/AuditTest.java | 2 +- .../search}/rest/audit/DeleteAuditTests.java | 3 +- .../search}/rest/audit/GetAuditTests.java | 3 +- .../search}/rest/audit/PutAuditTests.java | 3 +- .../service/search}/rest/auth/AuthTests.java | 2 +- .../search}/rest/cmis/CmisBrowserTest.java | 2 +- .../rest/comments/AddCommentTests.java | 2 +- .../rest/comments/AddCommentsTests.java | 2 +- .../rest/comments/DeleteCommentTests.java | 2 +- .../rest/comments/GetCommentsTests.java | 2 +- .../rest/comments/UpdateCommentTests.java | 2 +- .../search}/rest/demo/RestDemoTests.java | 2 +- .../rest/demo/SampleCommentsTests.java | 2 +- .../search}/rest/demo/SamplePeopleTests.java | 2 +- .../search}/rest/demo/SampleSitesTests.java | 2 +- .../rest/demo/workshop/RestApiDemoTests.java | 2 +- .../demo/workshop/RestApiWorkshopTests.java | 2 +- .../rest/discovery/DiscoveryTests.java | 2 +- .../rest/downloads/DownloadsTests.java | 2 +- .../rest/favorites/AddFavoriteSiteTests.java | 2 +- .../rest/favorites/AddFavoritesTests.java | 2 +- .../favorites/DeleteFavoriteSiteTests.java | 2 +- .../rest/favorites/DeleteFavoriteTests.java | 2 +- .../favorites/FavoritesIncludePathTests.java | 2 +- .../rest/favorites/FavoritesNetworkTests.java | 2 +- .../rest/favorites/GetFavoriteSiteTests.java | 2 +- .../rest/favorites/GetFavoriteSitesTests.java | 2 +- .../rest/favorites/GetFavoriteTests.java | 2 +- .../rest/favorites/GetFavoritesTests.java | 2 +- .../search}/rest/groups/GroupsTests.java | 2 +- .../RestGetNetworkForPersonTests.java | 2 +- .../rest/networks/RestGetNetworkTests.java | 2 +- .../RestGetNetworksForPersonTests.java | 2 +- .../nodes/NodesActionDefinitionTests.java | 2 +- .../nodes/NodesContentAndVersioningTests.java | 2 +- .../search}/rest/nodes/NodesLockTests.java | 2 +- .../rest/nodes/NodesParentChildrenTests.java | 2 +- .../rest/nodes/NodesTargetSourcesTests.java | 2 +- .../search}/rest/nodes/NodesTests.java | 2 +- .../search}/rest/nodes/NodesUnlockTests.java | 2 +- .../rest/people/AvatarPeopleSanityTest.java | 2 +- .../people/DeleteSiteMemberCoreTests.java | 2 +- .../people/DeleteSiteMemberFullTests.java | 2 +- .../people/DeleteSiteMemberSanityTests.java | 2 +- .../rest/people/GetPeopleCoreTests.java | 2 +- .../rest/people/GetPeopleFullTests.java | 2 +- .../rest/people/GetPeopleSanityTests.java | 2 +- .../people/GetSiteMembershipCoreTests.java | 2 +- .../people/GetSiteMembershipFullTests.java | 2 +- .../people/GetSiteMembershipSanityTests.java | 2 +- ...etSitesMembershipInformationCoreTests.java | 2 +- ...etSitesMembershipInformationFullTests.java | 2 +- ...SitesMembershipInformationSanityTests.java | 2 +- .../GetPeopleActivitiesCoreTests.java | 2 +- .../GetPeopleActivitiesFullTests.java | 2 +- .../GetPeopleActivitiesSanityTests.java | 2 +- .../GetPeoplePreferenceCoreTests.java | 2 +- .../GetPeoplePreferenceFullTests.java | 2 +- .../GetPeoplePreferenceSanityTests.java | 2 +- .../GetPeoplePreferencesCoreTests.java | 2 +- .../GetPeoplePreferencesFullTests.java | 2 +- .../GetPeoplePreferencesSanityTests.java | 2 +- .../search}/rest/queries/QueriesTest.java | 2 +- .../search}/rest/ratings/AddRatingTests.java | 2 +- .../rest/ratings/DeleteRatingTests.java | 2 +- .../search}/rest/ratings/GetRatingTests.java | 2 +- .../search}/rest/ratings/GetRatingsTests.java | 2 +- .../rest/renditions/CreateRenditionTests.java | 2 +- .../rest/renditions/GetRenditionTests.java | 2 +- .../renditions/RenditionIntegrationTests.java | 2 +- .../rest/search/AbstractSearchTest.java | 9 +- .../rest/search/FacetFieldsSearchTest.java | 10 +- .../rest/search/FacetIntervalSearchTest.java | 10 +- .../rest/search/FacetRangeSearchTest.java | 7 +- .../rest/search/PivotFacetedSearchTest.java | 11 +- .../rest/search/SearchHighLightTest.java | 8 +- .../rest/search/SearchSpellCheckTest.java | 6 +- .../search}/rest/search/StatsSearchTest.java | 14 +- .../sql/SearchSQLWithQuotedIdentifiers.java | 4 +- .../sharedLinks/GetSharedLinksFullTests.java | 2 +- .../sharedLinks/SharedLinksSanityTests.java | 2 +- .../search}/rest/sites/GetSiteTests.java | 2 +- .../search}/rest/sites/GetSitesTests.java | 2 +- .../search}/rest/sites/SitesNetworkTests.java | 2 +- .../search}/rest/sites/SitesTests.java | 2 +- .../containers/GetSiteContainerTests.java | 2 +- .../containers/GetSiteContainersTests.java | 2 +- .../sites/members/AddSiteMemberTests.java | 2 +- .../sites/members/GetSiteMemberTests.java | 2 +- .../sites/members/GetSiteMembersTests.java | 2 +- .../sites/members/RemoveSiteMemberTests.java | 2 +- .../sites/members/UpdateSiteMemberTests.java | 2 +- .../AddSiteMembershipRequestTests.java | 2 +- .../DeleteSiteMembershipRequestTests.java | 2 +- .../GetSiteMembershipRequestTests.java | 2 +- .../GetSiteMembershipRequestsTests.java | 2 +- .../UpdateSiteMembershipRequestTests.java | 2 +- .../rest/syncService/SyncServiceAPITests.java | 2 +- .../search}/rest/tags/TagsDataPrep.java | 2 +- .../rest/trashcan/GetDeletedNodesTests.java | 2 +- .../WorkflowNetworkDeploymentsTests.java | 2 +- ...orkflowNetworkProcessDefinitionsTests.java | 2 +- .../WorkflowNetworkProcessesTests.java | 2 +- .../workflow/WorkflowNetworkTasksTests.java | 2 +- .../deployments/DeleteDeploymentTests.java | 2 +- .../deployments/GetDeploymentCoreTests.java | 2 +- .../deployments/GetDeploymentFullTests.java | 2 +- .../deployments/GetDeploymentSanityTests.java | 2 +- .../deployments/GetDeploymentsCoreTests.java | 2 +- .../deployments/GetDeploymentsFullTests.java | 2 +- .../GetDeploymentsSanityTests.java | 2 +- .../GetProcessDefinitionCoreTests.java | 2 +- .../GetProcessDefinitionFullTests.java | 2 +- .../GetProcessDefinitionImageCoreTests.java | 2 +- .../GetProcessDefinitionImageFullTests.java | 2 +- .../GetProcessDefinitionImageSanityTests.java | 2 +- .../GetProcessDefinitionSanityTests.java | 2 +- ...cessDefinitionStartFormModelCoreTests.java | 2 +- ...cessDefinitionStartFormModelFullTests.java | 2 +- ...ssDefinitionStartFormModelSanityTests.java | 2 +- .../GetProcessDefinitionsCoreTests.java | 2 +- .../GetProcessDefinitionsFullTests.java | 2 +- .../GetProcessDefinitionsSanityTests.java | 2 +- .../processes/AddProcessCoreTests.java | 2 +- .../processes/AddProcessFullTests.java | 2 +- .../processes/AddProcessSanityTests.java | 2 +- .../processes/DeleteProcessCoreTests.java | 2 +- .../processes/DeleteProcessFullTests.java | 2 +- .../processes/DeleteProcessSanityTests.java | 2 +- .../processes/GetProcessCoreTests.java | 2 +- .../processes/GetProcessFullTests.java | 2 +- .../processes/GetProcessSanityTests.java | 2 +- .../processes/GetProcessesCoreTests.java | 2 +- .../processes/GetProcessesFullTests.java | 2 +- .../processes/GetProcessesSanityTests.java | 2 +- .../items/AddProcessItemCoreTests.java | 2 +- .../items/AddProcessItemFullTests.java | 2 +- .../items/AddProcessItemSanityTests.java | 2 +- .../items/DeleteProcessItemCoreTests.java | 2 +- .../items/DeleteProcessItemFullTests.java | 2 +- .../items/DeleteProcessItemSanityTests.java | 2 +- .../items/GetProcessItemsCoreTests.java | 2 +- .../items/GetProcessItemsFullTests.java | 2 +- .../items/GetProcessItemsSanityTests.java | 2 +- .../tasks/GetProcessTasksCoreTests.java | 2 +- .../tasks/GetProcessTasksFullTests.java | 2 +- .../tasks/GetProcessTasksSanityTests.java | 2 +- .../AddProcessVariableCoreTests.java | 2 +- .../AddProcessVariableFullTests.java | 2 +- .../AddProcessVariableSanityTests.java | 2 +- .../AddProcessVariablesCoreTests.java | 2 +- .../AddProcessVariablesFullTests.java | 2 +- .../AddProcessVariablesSanityTests.java | 2 +- .../DeleteProcessVariableCoreTests.java | 2 +- .../DeleteProcessVariableFullTests.java | 2 +- .../DeleteProcessVariableSanityTests.java | 2 +- .../GetProcessVariablesCoreTests.java | 2 +- .../GetProcessVariablesFullTests.java | 2 +- .../GetProcessVariablesSanityTests.java | 2 +- .../variables/UpdateProcessVariableTests.java | 2 +- .../workflow/tasks/GetTaskFormModelTests.java | 2 +- .../rest/workflow/tasks/GetTaskTests.java | 2 +- .../rest/workflow/tasks/GetTasksTests.java | 2 +- .../rest/workflow/tasks/UpdateTaskTests.java | 2 +- .../GetTaskCandidatesRegressionTests.java | 2 +- .../GetTaskCandidatesSanityTests.java | 2 +- .../tasks/items/AddTaskItemTestsBulk1.java | 2 +- .../tasks/items/AddTaskItemTestsBulk2.java | 2 +- .../tasks/items/AddTaskItemTestsBulk3.java | 2 +- .../items/GetTaskItemsRegressionTests.java | 2 +- .../tasks/items/GetTaskItemsSanityTests.java | 2 +- .../tasks/items/RemoveTaskItemTests.java | 2 +- .../variables/AddTaskVariablesTestsBulk1.java | 2 +- .../variables/AddTaskVariablesTestsBulk2.java | 2 +- .../variables/AddTaskVariablesTestsBulk3.java | 2 +- .../variables/DeleteTaskVariableTests.java | 2 +- .../variables/GetTaskVariablesTests.java | 2 +- .../UpdateTaskVariableTestsBulk1.java | 2 +- .../UpdateTaskVariableTestsBulk2.java | 2 +- .../UpdateTaskVariableTestsBulk3.java | 2 +- 202 files changed, 249 insertions(+), 4489 deletions(-) delete mode 100644 e2e-test/java/org/alfresco/rest/renditions/AvailableRenditionTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java delete mode 100644 e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java delete mode 100644 e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java delete mode 100644 e2e-test/java/org/alfresco/rest/search/SearchTest.java delete mode 100644 e2e-test/java/org/alfresco/rest/search/ShardInfoTest.java delete mode 100644 e2e-test/java/org/alfresco/rest/search/solr/SearchSolrAPITest.java delete mode 100644 e2e-test/java/org/alfresco/rest/search/sql/SearchSQLAPITest.java delete mode 100644 e2e-test/java/org/alfresco/rest/search/sql/SearchSQLPhraseTest.java delete mode 100644 e2e-test/java/org/alfresco/rest/search/sql/SearchSQLViaJDBCTest.java delete mode 100644 e2e-test/java/org/alfresco/rest/tags/GetTagTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/tags/GetTagsTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/tags/UpdateTagTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/tags/nodes/AddTagTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/tags/nodes/AddTagsTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/tags/nodes/DeleteTagTests.java delete mode 100644 e2e-test/java/org/alfresco/rest/tags/nodes/GetNodeTagsTests.java rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/FunctionalCasesTests.java (98%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/NetworkDataPrep.java (95%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/RestTest.java (98%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/actions/ActionsTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/aos/AosApiTest.java (93%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/audit/AuditTest.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/audit/DeleteAuditTests.java (97%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/audit/GetAuditTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/audit/PutAuditTests.java (98%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/auth/AuthTests.java (98%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/cmis/CmisBrowserTest.java (95%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/comments/AddCommentTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/comments/AddCommentsTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/comments/DeleteCommentTests.java (98%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/comments/GetCommentsTests.java (98%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/comments/UpdateCommentTests.java (98%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/demo/RestDemoTests.java (98%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/demo/SampleCommentsTests.java (97%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/demo/SamplePeopleTests.java (95%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/demo/SampleSitesTests.java (98%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/demo/workshop/RestApiDemoTests.java (97%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/demo/workshop/RestApiWorkshopTests.java (94%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/discovery/DiscoveryTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/downloads/DownloadsTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/favorites/AddFavoriteSiteTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/favorites/AddFavoritesTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/favorites/DeleteFavoriteSiteTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/favorites/DeleteFavoriteTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/favorites/FavoritesIncludePathTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/favorites/FavoritesNetworkTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/favorites/GetFavoriteSiteTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/favorites/GetFavoriteSitesTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/favorites/GetFavoriteTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/favorites/GetFavoritesTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/groups/GroupsTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/networks/RestGetNetworkForPersonTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/networks/RestGetNetworkTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/networks/RestGetNetworksForPersonTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/nodes/NodesActionDefinitionTests.java (98%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/nodes/NodesContentAndVersioningTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/nodes/NodesLockTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/nodes/NodesParentChildrenTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/nodes/NodesTargetSourcesTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/nodes/NodesTests.java (97%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/nodes/NodesUnlockTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/people/AvatarPeopleSanityTest.java (98%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/people/DeleteSiteMemberCoreTests.java (98%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/people/DeleteSiteMemberFullTests.java (98%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/people/DeleteSiteMemberSanityTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/people/GetPeopleCoreTests.java (98%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/people/GetPeopleFullTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/people/GetPeopleSanityTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/people/GetSiteMembershipCoreTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/people/GetSiteMembershipFullTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/people/GetSiteMembershipSanityTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/people/GetSitesMembershipInformationCoreTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/people/GetSitesMembershipInformationFullTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/people/GetSitesMembershipInformationSanityTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/people/activities/GetPeopleActivitiesCoreTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/people/activities/GetPeopleActivitiesFullTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/people/activities/GetPeopleActivitiesSanityTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/people/preferences/GetPeoplePreferenceCoreTests.java (98%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/people/preferences/GetPeoplePreferenceFullTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/people/preferences/GetPeoplePreferenceSanityTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/people/preferences/GetPeoplePreferencesCoreTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/people/preferences/GetPeoplePreferencesFullTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/people/preferences/GetPeoplePreferencesSanityTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/queries/QueriesTest.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/ratings/AddRatingTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/ratings/DeleteRatingTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/ratings/GetRatingTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/ratings/GetRatingsTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/renditions/CreateRenditionTests.java (98%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/renditions/GetRenditionTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/renditions/RenditionIntegrationTests.java (96%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/search/AbstractSearchTest.java (96%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/search/FacetFieldsSearchTest.java (96%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/search/FacetIntervalSearchTest.java (94%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/search/FacetRangeSearchTest.java (98%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/search/PivotFacetedSearchTest.java (96%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/search/SearchHighLightTest.java (88%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/search/SearchSpellCheckTest.java (96%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/search/StatsSearchTest.java (95%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/search/sql/SearchSQLWithQuotedIdentifiers.java (98%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/sharedLinks/GetSharedLinksFullTests.java (98%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/sharedLinks/SharedLinksSanityTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/sites/GetSiteTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/sites/GetSitesTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/sites/SitesNetworkTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/sites/SitesTests.java (96%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/sites/containers/GetSiteContainerTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/sites/containers/GetSiteContainersTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/sites/members/AddSiteMemberTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/sites/members/GetSiteMemberTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/sites/members/GetSiteMembersTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/sites/members/RemoveSiteMemberTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/sites/members/UpdateSiteMemberTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/sites/membershipRequests/AddSiteMembershipRequestTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/sites/membershipRequests/DeleteSiteMembershipRequestTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/sites/membershipRequests/GetSiteMembershipRequestTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/sites/membershipRequests/GetSiteMembershipRequestsTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/sites/membershipRequests/UpdateSiteMembershipRequestTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/syncService/SyncServiceAPITests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/tags/TagsDataPrep.java (98%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/trashcan/GetDeletedNodesTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/WorkflowNetworkDeploymentsTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/WorkflowNetworkProcessDefinitionsTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/WorkflowNetworkProcessesTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/WorkflowNetworkTasksTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/deployments/DeleteDeploymentTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/deployments/GetDeploymentCoreTests.java (96%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/deployments/GetDeploymentFullTests.java (97%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/deployments/GetDeploymentSanityTests.java (97%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/deployments/GetDeploymentsCoreTests.java (95%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/deployments/GetDeploymentsFullTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/deployments/GetDeploymentsSanityTests.java (96%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/processDefinitions/GetProcessDefinitionCoreTests.java (96%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/processDefinitions/GetProcessDefinitionFullTests.java (98%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/processDefinitions/GetProcessDefinitionImageCoreTests.java (96%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/processDefinitions/GetProcessDefinitionImageFullTests.java (96%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java (97%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java (98%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java (98%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelFullTests.java (98%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java (96%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/processDefinitions/GetProcessDefinitionsCoreTests.java (97%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/processDefinitions/GetProcessDefinitionsFullTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java (96%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/processes/AddProcessCoreTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/processes/AddProcessFullTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/processes/AddProcessSanityTests.java (96%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/processes/DeleteProcessCoreTests.java (98%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/processes/DeleteProcessFullTests.java (97%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/processes/DeleteProcessSanityTests.java (98%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/processes/GetProcessCoreTests.java (97%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/processes/GetProcessFullTests.java (98%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/processes/GetProcessSanityTests.java (98%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/processes/GetProcessesCoreTests.java (98%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/processes/GetProcessesFullTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/processes/GetProcessesSanityTests.java (98%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/processes/items/AddProcessItemCoreTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/processes/items/AddProcessItemFullTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/processes/items/AddProcessItemSanityTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/processes/items/DeleteProcessItemCoreTests.java (98%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/processes/items/DeleteProcessItemFullTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/processes/items/DeleteProcessItemSanityTests.java (98%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/processes/items/GetProcessItemsCoreTests.java (98%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/processes/items/GetProcessItemsFullTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/processes/items/GetProcessItemsSanityTests.java (97%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/processes/tasks/GetProcessTasksCoreTests.java (98%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/processes/tasks/GetProcessTasksFullTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/processes/tasks/GetProcessTasksSanityTests.java (98%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/processes/variables/AddProcessVariableCoreTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/processes/variables/AddProcessVariableFullTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/processes/variables/AddProcessVariableSanityTests.java (98%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/processes/variables/AddProcessVariablesCoreTests.java (98%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/processes/variables/AddProcessVariablesFullTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/processes/variables/AddProcessVariablesSanityTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/processes/variables/DeleteProcessVariableCoreTests.java (98%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/processes/variables/DeleteProcessVariableFullTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/processes/variables/DeleteProcessVariableSanityTests.java (98%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/processes/variables/GetProcessVariablesCoreTests.java (98%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/processes/variables/GetProcessVariablesFullTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/processes/variables/GetProcessVariablesSanityTests.java (97%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/processes/variables/UpdateProcessVariableTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/tasks/GetTaskFormModelTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/tasks/GetTaskTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/tasks/GetTasksTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/tasks/UpdateTaskTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/tasks/candidates/GetTaskCandidatesRegressionTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/tasks/candidates/GetTaskCandidatesSanityTests.java (98%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/tasks/items/AddTaskItemTestsBulk1.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/tasks/items/AddTaskItemTestsBulk2.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/tasks/items/AddTaskItemTestsBulk3.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/tasks/items/GetTaskItemsRegressionTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/tasks/items/GetTaskItemsSanityTests.java (98%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/tasks/items/RemoveTaskItemTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk1.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk2.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk3.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/tasks/variables/DeleteTaskVariableTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/tasks/variables/GetTaskVariablesTests.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk1.java (98%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk2.java (99%) rename e2e-test/{java/org/alfresco => src/test/java/org/alfresco/service/search}/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk3.java (99%) diff --git a/e2e-test/java/org/alfresco/rest/renditions/AvailableRenditionTests.java b/e2e-test/java/org/alfresco/rest/renditions/AvailableRenditionTests.java deleted file mode 100644 index 70f1d79d5..000000000 --- a/e2e-test/java/org/alfresco/rest/renditions/AvailableRenditionTests.java +++ /dev/null @@ -1,134 +0,0 @@ -package org.alfresco.rest.renditions; - -import org.alfresco.rest.model.RestNodeModel; -import org.alfresco.rest.model.RestRenditionInfoModel; -import org.alfresco.rest.model.RestRenditionInfoModelCollection; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.Assert; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; - -import java.util.Arrays; -import java.util.Collections; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; - -/** - * - * Sanity check for renditions through REST API.
          - * Tests upload files and then request renditions for those files.
          - * Renditions are requested based on supported renditions according to GET '/nodes/{nodeId}/renditions'.
          - */ -@Test(groups = {TestGroup.REQUIRE_TRANSFORMATION, TestGroup.RENDITIONS_REGRESSION}) -public class AvailableRenditionTests extends RenditionIntegrationTests -{ - /** List of parameters used as an input to supportedRenditionTest - fileName, nodeId, renditionId, expectedMimeType **/ - private List renditionsToTest; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - super.dataPreparation(); - - // Upload files and get available renditions for each file - List toTest = Arrays.asList("doc", "xls", "ppt", "docx", "xlsx", "pptx", "msg", "pdf", "png", "gif", "jpg"); - List renditionsForFiles = new LinkedList<>(); - for (String extensions : toTest) - { - String sourceFile = "quick/quick." + extensions; - renditionsForFiles.addAll(uploadFileAndGetAvailableRenditions(sourceFile)); - } - - renditionsToTest = Collections.unmodifiableList(renditionsForFiles); - } - - /** - * Upload a source file and get all supported renditions for it. - */ - private List uploadFileAndGetAvailableRenditions(String sourceFile) throws Exception - { - - // Create folder & upload file - RestNodeModel fileNode = uploadFile(sourceFile); - FileModel file = new FileModel(); - file.setNodeRef(fileNode.getId()); - - List renditionsForFile = new LinkedList<>(); - - // Get supported renditions - RestRenditionInfoModelCollection renditionsInfo = restClient.withCoreAPI().usingNode(file).getNodeRenditionsInfo(); - for (RestRenditionInfoModel m : renditionsInfo.getEntries()) - { - RestRenditionInfoModel renditionInfo = m.onModel(); - String renditionId = renditionInfo.getId(); - String targetMimeType = renditionInfo.getContent().getMimeType(); - - renditionsForFile.add(new Object[]{sourceFile, fileNode.getId(), renditionId, targetMimeType}); - - } - - return renditionsForFile; - } - - /** - * Check that a particular rendition can be created for the file and that it has the expected Mime type - */ - @Test(dataProvider = "RenditionTestDataProvider", groups = {TestGroup.REST_API, TestGroup.RENDITIONS, TestGroup.SANITY}) - @TestRail(section = { TestGroup.REST_API, TestGroup.RENDITIONS }, executionType = ExecutionType.SANITY, - description = "Verify renditions created for a selection of test files via POST nodes/{nodeId}/renditions") - public void supportedRenditionTest(String fileName, String nodeId, String renditionId, String expectedMimeType) throws Exception - { - checkRendition(fileName, nodeId, renditionId, expectedMimeType); - } - - @DataProvider(name = "RenditionTestDataProvider") - protected Iterator renditionTestDataProvider() throws Exception - { - return renditionsToTest.iterator(); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.RENDITIONS, TestGroup.SANITY}) - @TestRail(section = { TestGroup.REST_API, TestGroup.RENDITIONS }, executionType = ExecutionType.SANITY, - description = "Verify that there are some available renditions.") - public void renditionsAvailableTest() - { - Assert.assertFalse(renditionsToTest.isEmpty(), "No available renditions were reported for any of the test files."); - } - - @Test(dataProvider = "UnsupportedRenditionTestDataProvider",groups = {TestGroup.REST_API, TestGroup.RENDITIONS, TestGroup.SANITY}) - @TestRail(section = { TestGroup.REST_API, TestGroup.RENDITIONS }, executionType = ExecutionType.SANITY, - description = "Verify that requests for unsupported renditions return 400 ") - public void unsupportedRenditionTest(String sourceFile, String renditionId) throws Exception - { - RestNodeModel fileNode = uploadFile(sourceFile); - - // 2. Request rendition of the file using RESTAPI - FileModel file = new FileModel(sourceFile); - file.setNodeRef(fileNode.getId()); - restClient.withCoreAPI().usingNode(file).createNodeRendition(renditionId); - - Assert.assertEquals(restClient.getStatusCode(), HttpStatus.BAD_REQUEST.toString(), - "Expected to see the rendition rejected. [" + sourceFile + ", " + renditionId + "] [source file, rendition ID] "); - } - - @DataProvider(name = "UnsupportedRenditionTestDataProvider") - protected Iterator unsupportedRenditionTestDataProvider() throws Exception - { - String renditionId = "pdf"; - - List toTest = new LinkedList<>(); - toTest.add(new Object[]{"quick/quick.png", renditionId}); - toTest.add(new Object[]{"quick/quick.gif", renditionId}); - toTest.add(new Object[]{"quick/quick.jpg", renditionId}); - toTest.add(new Object[]{"quick/quick.pdf", renditionId}); - - return toTest.iterator(); - } -} - diff --git a/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java b/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java deleted file mode 100644 index 4c1d54339..000000000 --- a/e2e-test/java/org/alfresco/rest/search/FacetedSearchTest.java +++ /dev/null @@ -1,322 +0,0 @@ -/* - * Copyright (C) 2018 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.rest.search; - -import java.util.ArrayList; -import java.util.List; - -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.testng.Assert; -import org.testng.TestException; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Faceted search test. - * @author Michael Suzuki - * - */ -public class FacetedSearchTest extends AbstractSearchTest -{ - - /** - * Perform the below facet query. - * { - * "query": { - * "query": "cars", - * "language": "afts" - * }, - * "facetQueries": [ - * {"query": "content.size:[o TO 102400]", "label": "small"}, - * {"query": "content.size:[102400 TO 1048576]", "label": "medium"}, - * {"query": "content.size:[1048576 TO 16777216]", "label": "large"} - * ], - * "facetFields": {"facets": [{"field": "'content.size'"}]} - * } - * - * Expected response - * {"list": { - * "entries": [... All the results], - * "pagination": { - * "maxItems": 100, - * "hasMoreItems": false, - * "totalItems": 61, - * "count": 61, - * "skipCount": 0 - * }, - * "facetsFields": [ - * { - * "type": "query", - * "label": "foo", - * "buckets": [ - * { - * "label": "small", - * "filterQuery": "content.size:[0 TO 102400]", - * "display": 1 - * }, - * { - * "label": "large", - * "filterQuery": "content.size:[1048576 TO 16777216]", - * "metrics": [ - * { - * "type": "count", - * "value": { - * "count": 0 - * } - * } - * ] - * }, - * }} - * @throws Exception - */ - - @BeforeClass(alwaysRun = true) - public void setupEnvironment() throws Exception - { - waitForContentIndexing(file4.getContent(), true); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) - @TestRail(section = { TestGroup.REST_API, TestGroup.SEARCH, - TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, description = "Checks facet queries for the Search api") - public void searchWithQueryFaceting() throws Exception - { - SearchRequest query = new SearchRequest(); - RestRequestQueryModel queryReq = new RestRequestQueryModel(); - queryReq.setQuery("cars"); - query.setQuery(queryReq); - - List facets = new ArrayList(); - facets.add(new FacetQuery("content.size:[0 TO 102400]", "small")); - facets.add(new FacetQuery("content.size:[102400 TO 1048576]", "medium")); - facets.add(new FacetQuery("content.size:[1048576 TO 16777216]", "large")); - query.setFacetQueries(facets); - RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); - List list = new ArrayList<>(); - list.add(new RestRequestFacetFieldModel("'content.size'")); - facetFields.setFacets(list); - query.setFacetFields(facetFields); - query.setIncludeRequest(true); - - SearchResponse response = query(query); - - response.assertThat().entriesListIsNotEmpty(); - response.getContext().assertThat().field("facetQueries").isNotEmpty(); - - FacetFieldBucket facet = response.getContext().getFacetQueries().get(0); - facet.assertThat().field("label").contains("small").and().field("count").isGreaterThan(0); - facet.assertThat().field("label").contains("small").and().field("filterQuery").is("content.size:[0 TO 102400]"); - response.getContext().getFacetQueries().get(1).assertThat().field("label").contains("large") - .and().field("count").isLessThan(1) - .and().field("filterQuery").is("content.size:[1048576 TO 16777216]"); - response.getContext().getFacetQueries().get(2).assertThat().field("label").contains("medium") - .and().field("count").isLessThan(1) - .and().field("filterQuery").is("content.size:[102400 TO 1048576]"); - //We don't expect to see the FacetFields if group is being used. - Assert.assertNull(response.getContext().getFacetsFields()); - Assert.assertNull(response.getContext().getFacets()); - } - @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH , TestGroup.ASS_1}) - @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH ,TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, - description = "Checks facet queries for the Search api") - /** - * * Perform a group by faceting, below test groups the facet by group name foo. - * { - * "query": { - * "query": "cars", - * "language": "afts" - * }, - * "facetQueries": [ - * {"query": "content.size:[o TO 102400]", "label": "small","group":"foo"}, - * {"query": "content.size:[102400 TO 1048576]", "label": "medium","group":"foo"}, - * {"query": "content.size:[1048576 TO 16777216]", "label": "large","group":"foo"} - * ], - * "facetFields": {"facets": [{"field": "'content.size'"}]} - * } - * - * Expected response - * {"list": { - * "entries": [... All the results], - * "pagination": { - * "maxItems": 100, - * "hasMoreItems": false, - * "totalItems": 61, - * "count": 61, - * "skipCount": 0 - * }, - * "context": { - * "consistency": {"lastTxId": 512}, - * //Added below as part of SEARCH-374 - * "facets": [ - * { "label": "foo", - * "buckets": [ - * { "label": "small", "count": 61, "filterQuery": "content.size:[o TO 102400]"}, - * { "label": "large", "count": 0, "filterQuery": "content.size:[1048576 TO 16777216]"}, - * { "label": "medium", "count": 61, "filterQuery": "content.size:[102400 TO 1048576]"} - * ] - * } - * } - * }} - * - * - * @throws Exception - */ - public void searchQueryFacetingWithGroup() throws Exception - { - SearchRequest query = new SearchRequest(); - RestRequestQueryModel queryReq = new RestRequestQueryModel(); - queryReq.setQuery("cars"); - query.setQuery(queryReq); - - List facets = new ArrayList(); - facets.add(new FacetQuery("content.size:[0 TO 102400]", "small", "foo")); - facets.add(new FacetQuery("content.size:[102400 TO 1048576]", "medium", "foo")); - facets.add(new FacetQuery("content.size:[1048576 TO 16777216]", "large", "foo")); - query.setFacetQueries(facets); - - RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); - List list = new ArrayList<>(); - list.add(new RestRequestFacetFieldModel("'content.size'")); - facetFields.setFacets(list); - query.setFacetFields(facetFields); - - SearchResponse response = query(query); - - // We don't expect to see the FacetQueries if group is being used. - Assert.assertTrue(response.getContext().getFacetQueries() == null); - // Validate the facet field structure is correct. - Assert.assertFalse(response.getContext().getFacets().isEmpty()); - Assert.assertEquals(response.getContext().getFacets().get(0).getLabel(), "foo"); - - RestGenericBucketModel bucket = response.getContext().getFacets().get(0).getBuckets().get(0); - bucket.assertThat().field("label").isNotEmpty(); - Assert.assertEquals(bucket.getMetrics().get(0).getType(), "count"); - Assert.assertNotEquals(bucket.getMetrics().get(0).getValue(), ""); - bucket.assertThat().field("filterQuery").isNotEmpty(); - response.getContext().getFacets().get(0).getBuckets().forEach(action -> { - switch (action.getLabel()) - { - case "small": - Assert.assertEquals(action.getFilterQuery(), "content.size:[0 TO 102400]"); - break; - case "medium": - Assert.assertEquals(action.getFilterQuery(), "content.size:[102400 TO 1048576]"); - break; - case "large": - Assert.assertEquals(action.getFilterQuery(), "content.size:[1048576 TO 16777216]"); - break; - - default: - throw new TestException("Unexpected value returned"); - } - }); - - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH , TestGroup.ASS_1}) - @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH ,TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, - description = "Checks facet queries for the Search api") - /** - * { - * "query": { - * "query": "*" - * }, - * "facetFields": { - * "facets": [{"field": "cm:mimetype"},{"field": "modifier"}] - * } - * } - */ - public void searchWithFactedFields() throws Exception - { - SearchRequest query = new SearchRequest(); - RestRequestQueryModel queryReq = new RestRequestQueryModel(); - queryReq.setQuery(unique_searchString); - query.setQuery(queryReq); - - RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); - List facets = new ArrayList(); - facets.add(new RestRequestFacetFieldModel("cm:mimetype")); - facets.add(new RestRequestFacetFieldModel("modifier")); - facetFields.setFacets(facets); - query.setFacetFields(facetFields); - - SearchResponse response = query(query); - - Assert.assertFalse(response.getContext().getFacetsFields().isEmpty()); - Assert.assertNull(response.getContext().getFacetQueries()); - Assert.assertNull(response.getContext().getFacets()); - - RestResultBucketsModel model = response.getContext().getFacetsFields().get(0); - Assert.assertEquals(model.getLabel(), "modifier"); - - model.assertThat().field("label").is("modifier"); - FacetFieldBucket bucket1 = model.getBuckets().get(0); - bucket1.assertThat().field("label").is(userModel.getUsername()); - bucket1.assertThat().field("display").is(userModel.getUsername() + " FirstName LN-" + userModel.getUsername()); - bucket1.assertThat().field("filterQuery").is("modifier:\"" + userModel.getUsername() + "\""); - bucket1.assertThat().field("count").is(1); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH , TestGroup.ASS_1}) - @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH ,TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, - description = "Checks facet queries for the Search api") - /** - * Test that items returned are in the format of generic facets. - * { - * "query": { - * "query": "*" - * }, - * "facetFields": { - * "facets": [{"field": "cm:mimetype"},{"field": "modifier"}] - * }, - * "facetFormat":"V2" - * } - */ - public void searchWithFactedFieldsFacetFormatV2() throws Exception - { - SearchRequest query = new SearchRequest(); - RestRequestQueryModel queryReq = new RestRequestQueryModel(); - queryReq.setQuery(unique_searchString); - query.setQuery(queryReq); - query.setFacetFormat("V2"); - RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); - List facets = new ArrayList(); - facets.add(new RestRequestFacetFieldModel("cm:mimetype")); - facets.add(new RestRequestFacetFieldModel("modifier")); - facetFields.setFacets(facets); - query.setFacetFields(facetFields); - - SearchResponse response = query(query); - - Assert.assertNull(response.getContext().getFacetsFields()); - Assert.assertNull(response.getContext().getFacetQueries()); - Assert.assertFalse(response.getContext().getFacets().isEmpty()); - RestGenericFacetResponseModel model = response.getContext().getFacets().get(0); - Assert.assertEquals(model.getLabel(), "modifier"); - - model.assertThat().field("label").is("modifier"); - RestGenericBucketModel bucket1 = model.getBuckets().get(0); - bucket1.assertThat().field("label").is(userModel.getUsername()); - bucket1.assertThat().field("display").is(userModel.getUsername() + " FirstName LN-" + userModel.getUsername()); - bucket1.assertThat().field("filterQuery").is("modifier:\"" + userModel.getUsername() + "\""); - bucket1.assertThat().field("metrics").is("[{entry=null, type=count, value={count=1}}]"); - } -} diff --git a/e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java b/e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java deleted file mode 100644 index 26874a90a..000000000 --- a/e2e-test/java/org/alfresco/rest/search/FingerPrintTest.java +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Copyright (C) 2018 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.rest.search; - -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FileType; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.TestGroup; -import org.testng.Assert; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Search end point Public API test with finger print. - * @author Michael Suzuki - * - */ -public class FingerPrintTest extends AbstractSearchTest -{ - private FileModel file1, file2, file3, file4; - - @BeforeClass(alwaysRun = true) - public void indexSimilarFile() throws Exception - { - - /* - * Create the following file structure in the same Site : In addition to the preconditions created in dataPreparation - * |- folder - * |-- pangram-banana.txt - * |-- pangram-taco.txt - * |-- pangram-cat.txt - * |-- dog.txt - */ - - FolderModel folder = new FolderModel("The quick brown fox jumps over"); - dataContent.usingUser(userModel).usingSite(siteModel).createFolder(folder); - - file1 = new FileModel("pangram-banana.txt", FileType.TEXT_PLAIN, "The quick brown fox jumps over the lazy banana"); - file2 = new FileModel("pangram-taco.txt", FileType.TEXT_PLAIN, "The quick brown fox jumps over the lazy dog that ate the taco"); - file3 = new FileModel("pangram-cat.txt", FileType.TEXT_PLAIN, "The quick brown fox jumps over the lazy cat"); - file4 = new FileModel("dog.txt", FileType.TEXT_PLAIN, "The quick brown fox ate the lazy dog"); - - dataContent.usingUser(userModel).usingSite(siteModel).usingResource(folder).createContent(file1); - dataContent.usingUser(userModel).usingSite(siteModel).usingResource(folder).createContent(file2); - dataContent.usingUser(userModel).usingSite(siteModel).usingResource(folder).createContent(file3); - dataContent.usingUser(userModel).usingSite(siteModel).usingResource(folder).createContent(file4); - - waitForContentIndexing(file4.getContent(), true); - // Additional wait implemented to remove inconsistent failures. Ref: Search-1438 for details - waitForIndexing("FINGERPRINT:" + file2.getNodeRefWithoutVersion(), true); - waitForIndexing("FINGERPRINT:" + file3.getNodeRefWithoutVersion(), true); - } - - /** - * Search similar document based on document finger print. - * The data prep should have loaded 2 files which one is similar - * to the files loaded as part of this test. - * Note that for fingerprint to work it need a 5 word sequence. - * - * @throws Exception - */ - @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) - public void search() throws Exception - { - String uuid = file1.getNodeRefWithoutVersion(); - Assert.assertNotNull(uuid); - String fingerprint = String.format("FINGERPRINT:%s", uuid); - SearchResponse response = query(fingerprint); - int count = response.getEntries().size(); - Assert.assertTrue(count > 1); - for (SearchNodeModel m : response.getEntries()) - { - String match = m.getModel().getName(); - switch (match) - { - case "pangram.txt": - break; - case "pangram-banana.txt": - break; - case "pangram-taco.txt": - break; - case "pangram-cat.txt": - break; - default: - throw new AssertionError("Not a match to an expected file: " + m.getModel().getName()); - } - m.getModel().assertThat().field("name").isNot("dog.txt"); - m.getModel().assertThat().field("name").isNot("cars.txt"); - } - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) - public void searchSimilar() throws Exception - { - String uuid = file2.getNodeRefWithoutVersion(); - Assert.assertNotNull(uuid); - - // In the response entity there is a score of each doc, change below threshold to bring more like or less. - String fingerprint = String.format("FINGERPRINT:%s_68", uuid); - SearchResponse response = query(fingerprint); - - int count = response.getEntries().size(); - Assert.assertTrue(count > 1); - - for (SearchNodeModel m : response.getEntries()) - { - switch (m.getModel().getName()) - { - case "pangram.txt": - break; - case "pangram-taco.txt": - break; - default: - throw new AssertionError("Not a match to an expected file: " + m.getModel().getName()); - } - m.getModel().assertThat().field("name").isNot("pangram-banana.txt"); - m.getModel().assertThat().field("name").isNot("pangram-cat.txt"); - m.getModel().assertThat().field("name").isNot("dog.txt"); - m.getModel().assertThat().field("name").isNot("cars.txt"); - } - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) - public void searchSimilar67Percent() throws Exception - { - String uuid = file2.getNodeRefWithoutVersion(); - Assert.assertNotNull(uuid); - String fingerprint = String.format("FINGERPRINT:%s_68", uuid); - SearchResponse response = query(fingerprint); - int count = response.getEntries().size(); - Assert.assertTrue(count > 1); - for (SearchNodeModel m : response.getEntries()) - { - switch (m.getModel().getName()) - { - case "pangram.txt": - break; - case "pangram-taco.txt": - break; - case "pangram-cat.txt": - break; - default: - throw new AssertionError("Not a match to an expected file: " + m.getModel().getName()); - } - m.getModel().assertThat().field("name").isNot("pangram-banana.txt"); - m.getModel().assertThat().field("name").isNot("dog.txt"); - m.getModel().assertThat().field("name").isNot("cars.txt"); - } - } -} diff --git a/e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java b/e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java deleted file mode 100644 index a045144f9..000000000 --- a/e2e-test/java/org/alfresco/rest/search/SearchAPATHTest.java +++ /dev/null @@ -1,185 +0,0 @@ -/* - * Copyright (C) 2018 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.rest.search; - - -import java.util.Collections; -import java.util.List; - -import org.alfresco.utility.model.TestGroup; -import org.testng.Assert; -import org.testng.annotations.Test; - -/** - * Tests the search functionality using an ancestor path. - * Using the category as an example, it is a node that is located - * in root/rootCategory/classifiable. We now provide the ability to search by path - * so that we can return all the child elements of our target path. - * A search on root/rootCategory/classifiable should return Regions, Languages - * as they are the child elements of the given path. - * - * @author Michael Suzuki - * - */ -public class SearchAPATHTest extends AbstractSearchTest -{ - - @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_1}) - /** - * { - * "query": { - * "query": "name:*" - * }, - * "facetFields": { - * "facets": [ - * {"field": "APATH", "prefix": "0" } - * ] - * } - * } - * Expected result - * entries[], - * "pagination": { - * "maxItems": 100, - * "hasMoreItems": true, - * "totalItems": 914, - * "count": 100, - * "skipCount": 0 - * }, - * "context": { - * "facetsFields": [{ - * "buckets": [ - * { - * "count": 913, - * "label": "0/5c09534f-3ca2-4272-bc25-064a7c1762b4" - * }, - * { - * "count": 2, - * "label": "0/" - * } - * ], - * "label": "APATH" - * }], - * "consistency": {"lastTxId": 89} - * } - *}} - * - */ - public void searchLevel0() throws Exception - { - SearchRequest searchQuery = searchRequestWithAPATHFacet("name:*", "0"); - SearchResponse response = query(searchQuery); - - List buckets = getBuckets(response); - Assert.assertEquals(2, buckets.size()); - - buckets.forEach(bucket -> bucket.assertThat().field("label").contains("0/")); - } - - @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_1}) - public void searchLevel0andIncludeSubLevel1() throws Exception - { - SearchRequest searchQuery = searchRequestWithAPATHFacet("name:*", "1/"); - SearchResponse response = query(searchQuery); - - List buckets = getBuckets(response); - Assert.assertEquals(4, buckets.size()); - - getFirstBucket(response).assertThat().field("label").contains("1/"); - } - - @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_1}) - public void searchLevel2() throws Exception - { - String queryString = "name:cars"; - - SearchRequest l1Request = searchRequestWithAPATHFacet(queryString, "1/"); - SearchResponse l1Response = query(l1Request); - - String l2Prefix = getFirstBucket(l1Response).getLabel().replaceFirst("^1/", "2/"); - - SearchRequest l2Request = searchRequestWithAPATHFacet(queryString, l2Prefix); - SearchResponse l2Response = query(l2Request); - - FacetFieldBucket bucket = getFirstBucket(l2Response); - bucket.assertThat().field("label").contains(l2Prefix); - - String l3Prefix = bucket.getLabel().replaceFirst("^2/", "3/"); - - SearchRequest l3Request = searchRequestWithAPATHFacet(queryString, l3Prefix); - SearchResponse l3response = query(l3Request); - - List buckets = getBuckets(l3response); - Assert.assertEquals(1, buckets.size()); - - getFirstBucket(l3response).assertThat().field("label").contains(l3Prefix); - } - - /** - * Creates a new {@link SearchRequest} for this test case. - * - * @param queryString the query string. - * @param facetPrefix the facet prefix. - * @return a new {@link SearchRequest} for this test case. - */ - private SearchRequest searchRequestWithAPATHFacet(String queryString, String facetPrefix) - { - SearchRequest searchRequest = new SearchRequest(); - - RestRequestQueryModel query = new RestRequestQueryModel(); - query.setQuery(queryString); - searchRequest.setQuery(query); - - RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel(); - facetFields.setFacets(Collections.singletonList(new RestRequestFacetFieldModel("APATH", facetPrefix))); - searchRequest.setFacetFields(facetFields); - - return searchRequest; - } - - /** - * Extracts the first bucket from the given response. - * - * @param response the results of a query execution. - * @return the first bucket included in the search response. - */ - private FacetFieldBucket getFirstBucket(SearchResponse response) - { - return getBuckets(response).iterator().next(); - } - - /** - * Extracts the buckets from the given response. - * The method also makes sure the buckets list is not empty in the input response. - * - * @param response the results of a query execution. - * @return the getBuckets included in the search response. - */ - private List getBuckets(SearchResponse response) - { - List facetFields = response.getContext().getFacetsFields(); - Assert.assertNotNull(facetFields); - Assert.assertFalse(facetFields.isEmpty()); - - List buckets = facetFields.iterator().next().getBuckets(); - Assert.assertNotNull(buckets); - Assert.assertFalse(buckets.isEmpty()); - - return buckets; - } -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/search/SearchTest.java b/e2e-test/java/org/alfresco/rest/search/SearchTest.java deleted file mode 100644 index 8db269fd4..000000000 --- a/e2e-test/java/org/alfresco/rest/search/SearchTest.java +++ /dev/null @@ -1,309 +0,0 @@ -/* - * Copyright (C) 2018 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.rest.search; - -import static java.util.Arrays.asList; -import static java.util.Collections.reverse; - -import static org.codehaus.groovy.runtime.InvokerHelper.asList; -import static org.hamcrest.Matchers.containsString; -import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.notNullValue; -import static org.hamcrest.Matchers.nullValue; -import static org.testng.AssertJUnit.assertEquals; - -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Collectors; - -import org.alfresco.rest.model.body.RestNodeLockBodyModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FileType; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.hamcrest.Matchers; -import org.springframework.http.HttpStatus; -import org.testng.Assert; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Search end point Public API test. - * @author Michael Suzuki - * - */ -public class SearchTest extends AbstractSearchTest -{ - @BeforeClass(alwaysRun = true) - public void setupEnvironment() throws Exception - { - waitForContentIndexing(file4.getContent(), true); - } - - @Test(groups={TestGroup.SEARCH, TestGroup.REST_API}) - public void searchOnIndexedData() throws Exception - { - SearchResponse nodes = query(unique_searchString); - restClient.assertStatusCodeIs(HttpStatus.OK); - nodes.assertThat().entriesListIsNotEmpty(); - - SearchNodeModel entity = nodes.getEntryByIndex(0); - entity.assertThat().field("search").contains("score"); - entity.getSearch().assertThat().field("score").isNotEmpty(); - Assert.assertEquals("pangram.txt",entity.getName()); - } - - @Test(groups={TestGroup.SEARCH,TestGroup.REST_API}) - public void searchNonIndexedData() throws Exception - { - SearchResponse nodes = query("yeti"); - restClient.assertStatusCodeIs(HttpStatus.OK); - nodes.assertThat().entriesListIsEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, - description = "Checks its possible to include the original request in the response") - public void searchWithRequest() throws Exception - { - SearchRequest query = new SearchRequest(); - RestRequestQueryModel queryReq = new RestRequestQueryModel(); - queryReq.setQuery("fox"); - query.setQuery(queryReq); - query.setIncludeRequest(true); - - SearchResponse response = query(query); - restClient.assertStatusCodeIs(HttpStatus.OK); - - response.getContext().assertThat().field("request").isNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, - description = "Tests a search request containing a sort clause.") - public void searchWithOneSortClause() throws Exception - { - // Tests the ascending order first - List expectedOrder = asList("alfresco.txt", "cars.txt", "pangram.txt"); - - SearchRequest searchRequest = createQuery("cm_name:alfresco\\.txt cm_name:cars\\.txt cm_name:pangram\\.txt"); - searchRequest.addSortClause("FIELD", "name", true); - - RestRequestFilterQueryModel filters = new RestRequestFilterQueryModel(); - filters.setQuery("SITE:'" + siteModel.getId() + "'"); - searchRequest.setFilterQueries(filters); - - SearchResponse responseWithAscendingOrder = query(searchRequest); - - restClient.assertStatusCodeIs(HttpStatus.OK); - - assertEquals( - expectedOrder, - responseWithAscendingOrder.getEntries().stream() - .map(SearchNodeModel::getModel) - .map(SearchNodeModel::getName) - .collect(Collectors.toList())); - - // Reverts the expected order... - reverse(expectedOrder); - - // ...and test the descending order - searchRequest.getSort().clear(); - searchRequest.addSortClause("FIELD", "name", false); - - SearchResponse responseWithDescendingOrder = query(searchRequest); - assertEquals( - expectedOrder, - responseWithDescendingOrder.getEntries().stream() - .map(SearchNodeModel::getModel) - .map(SearchNodeModel::getName) - .collect(Collectors.toList())); - } - - /** - * Tests the query execution with two sort clauses. - * The first clause has always the same value for all matches so the test makes sure the request is correctly - * processed and the returned order is determined by the second clause. - */ - @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, - description = "Tests a search request containing a sort clause.") - public void searchWithTwoSortClauses() throws Exception - { - // Tests the ascending order first - List expectedOrder = asList("alfresco.txt", "cars.txt", "pangram.txt"); - - SearchRequest searchRequest = createQuery("cm_name:alfresco\\.txt cm_name:cars\\.txt cm_name:pangram\\.txt"); - searchRequest.addSortClause("FIELD", "name", true); - searchRequest.addSortClause("FIELD", "createdByUser.id", true); - - RestRequestFilterQueryModel filters = new RestRequestFilterQueryModel(); - filters.setQuery("SITE:'" + siteModel.getId() + "'"); - searchRequest.setFilterQueries(filters); - - SearchResponse responseWithAscendingOrder = query(searchRequest); - - restClient.assertStatusCodeIs(HttpStatus.OK); - - assertEquals( - expectedOrder, - responseWithAscendingOrder.getEntries().stream() - .map(SearchNodeModel::getModel) - .map(SearchNodeModel::getName) - .collect(Collectors.toList())); - - // Reverts the expected order... - reverse(expectedOrder); - - // ...and test the descending order - searchRequest.getSort().clear(); - searchRequest.addSortClause("FIELD", "name", false); - searchRequest.addSortClause("FIELD", "createdByUser.id", true); - - SearchResponse responseWithDescendingOrder = query(searchRequest); - assertEquals( - expectedOrder, - responseWithDescendingOrder.getEntries().stream() - .map(SearchNodeModel::getModel) - .map(SearchNodeModel::getName) - .collect(Collectors.toList())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ACS_61n }) @TestRail(section = { - TestGroup.REST_API, TestGroup.SEARCH, - TestGroup.ACS_61n }, executionType = ExecutionType.REGRESSION, description = "Checks the \"include\" request parameter support the 'permissions' option") public void searchQuery_includePermissions_shouldReturnNodeWithPermissionsInformation() - throws Exception - { - String query = "fox"; - String include = "permissions"; - - SearchRequest retrievalQueryIncludingPermissionsInformation = createQuery(query); - retrievalQueryIncludingPermissionsInformation.setInclude(asList(include)); - - query(retrievalQueryIncludingPermissionsInformation); - - restClient.assertStatusCodeIs(HttpStatus.OK); - restClient.onResponse().assertThat().body("list.entries[0].entry.permissions", notNullValue()); - - SearchRequest retrievalQueryNotIncludingLockInformation = createQuery(query); - - query(retrievalQueryNotIncludingLockInformation); - - restClient.assertStatusCodeIs(HttpStatus.OK); - restClient.onResponse().assertThat().body("list.entries[0].entry.permissions", nullValue()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ACS_61n }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ACS_61n }, executionType = ExecutionType.REGRESSION, - description = "Checks the \"include\" request parameter support the 'isLocked' option") - public void searchQuery_includeIsLocked_shouldReturnNodeWithLockInformation() throws Exception { - String query = "fox"; - String include = "isLocked"; - - SearchRequest retrievalQueryIncludingLockInformation = createQuery(query); - retrievalQueryIncludingLockInformation.setInclude(asList(include)); - - query(retrievalQueryIncludingLockInformation); - - restClient.assertStatusCodeIs(HttpStatus.OK); - restClient.onResponse().assertThat().body("list.entries[0].entry.isLocked", equalTo(false)); - - RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); - lockBodyModel.setLifetime("EPHEMERAL"); - lockBodyModel.setTimeToExpire(20); - lockBodyModel.setType("FULL"); - restClient.authenticateUser(userModel).withCoreAPI().usingNode(file).usingParams("include=isLocked").lockNode(lockBodyModel); - - query(retrievalQueryIncludingLockInformation); - - restClient.assertStatusCodeIs(HttpStatus.OK); - restClient.onResponse().assertThat().body("list.entries[0].entry.isLocked", equalTo(true)); - - SearchRequest retrievalQueryNotIncludingLockInformation = createQuery(query); - - query(retrievalQueryNotIncludingLockInformation); - - restClient.assertStatusCodeIs(HttpStatus.OK); - restClient.onResponse().assertThat().body("list.entries[0].entry.isLocked", nullValue()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ACS_61n }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ACS_61n }, executionType = ExecutionType.REGRESSION, - description = "Checks the \"include\" request parameter does not support the 'notValid' option") - public void searchQuery_includeInvalid_shouldReturnBadResponse() throws Exception - { - String query = "fox"; - String notValidInclude = "notValid"; - SearchRequest permissionsRetrieval = createQuery(query); - permissionsRetrieval.setInclude(asList(notValidInclude)); - - query(permissionsRetrieval); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - restClient.onResponse() - .assertThat() - .body("error.briefSummary", containsString("An invalid argument was received "+notValidInclude)); - } - - // Test that when fields parameter is set, only restricted fields appear in the response - @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) - public void searchWithFields() throws Exception - { - SearchRequest query = new SearchRequest(); - RestRequestQueryModel queryReq = new RestRequestQueryModel(); - queryReq.setQuery("alfresco"); - query.setQuery(queryReq); - - // Restrict to fields: parentId - List fields = new ArrayList(); - fields.add("parentId"); - query.setFields(fields); - - query(query); - restClient.assertStatusCodeIs(HttpStatus.OK); - - // Only Field parentId is included in the response - restClient.onResponse().assertThat().body("list.entries.entry[0].parentId", Matchers.notNullValue()); - // Usual Fields such as 'name, id' aren't included in the response - restClient.onResponse().assertThat().body("list.entries.entry[0].name", Matchers.nullValue()); - restClient.onResponse().assertThat().body("list.entries.entry[0].id", Matchers.nullValue()); - } - - @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API }) - public void searchSpecialCharacters() throws Exception - { - // Create a file with Special Characters - String specialCharfileName = "è¥äæ§ç§-åæ.pdf"; - FileModel file = new FileModel(specialCharfileName, "è¥äæ§ç§-忬¯¸" + "è¥äæ§ç§-忬¯¸", "è¥äæ§ç§-忬¯¸", FileType.TEXT_PLAIN, - "Text file with Special Characters: " + specialCharfileName); - dataContent.usingUser(userModel).usingSite(siteModel).createContent(file); - - waitForIndexing(file.getName(), true); - - // Search - SearchRequest searchReq = createQuery("name:'" + specialCharfileName + "'"); - SearchResponse nodes = query(searchReq); - - restClient.assertStatusCodeIs(HttpStatus.OK); - nodes.assertThat().entriesListIsNotEmpty(); - - restClient.onResponse().assertThat().body("list.entries.entry[0].name", Matchers.equalToIgnoringCase(specialCharfileName)); - } -} diff --git a/e2e-test/java/org/alfresco/rest/search/ShardInfoTest.java b/e2e-test/java/org/alfresco/rest/search/ShardInfoTest.java deleted file mode 100644 index 410779581..000000000 --- a/e2e-test/java/org/alfresco/rest/search/ShardInfoTest.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (C) 2005-2018 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.rest.search; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; - -import java.util.Arrays; -import java.util.List; - -import com.fasterxml.jackson.core.JsonProcessingException; - -import org.alfresco.rest.exception.EmptyRestModelCollectionException; -import org.alfresco.utility.model.TestGroup; -import org.springframework.http.HttpStatus; -import org.testng.annotations.Test; - -/** - * Shard info end point REST API test. - * - * @author Tuna Aksoy - */ -public class ShardInfoTest extends AbstractSearchTest -{ - @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ACS_60n}) - public void getShardInfoWithAdminAuthority() throws JsonProcessingException, EmptyRestModelCollectionException - { - RestShardInfoModelCollection info = restClient.authenticateUser(dataUser.getAdminUser()).withShardInfoAPI().getInfo(); - restClient.assertStatusCodeIs(HttpStatus.OK); - info.assertThat().entriesListIsNotEmpty(); - assertEquals(info.getPagination().getTotalItems().intValue(), 2); - - List stores = Arrays.asList("workspace://SpacesStore", "archive://SpacesStore"); - List baseUrls = Arrays.asList("/solr/alfresco", "/solr/archive"); - - List entries = info.getEntries(); - for (RestShardInfoModel shardInfoModel : entries) - { - RestShardInfoModel model = shardInfoModel.getModel(); - assertEquals(model.getTemplate(), "rerank"); - assertEquals(model.getMode(), "MASTER"); - assertEquals(model.getShardMethod(), "DB_ID"); - assertTrue(model.getHasContent()); - stores.contains(model.getStores()); - List shards = model.getShards(); - assertNotNull(shards); - RestShardModel shard = shards.iterator().next(); - assertNotNull(shard); - List instances = shard.getInstances(); - assertNotNull(instances); - RestInstanceModel instance = instances.iterator().next(); - assertNotNull(instance); - baseUrls.contains(instance.getBaseUrl()); - // TODO: Ideally Solr Host and Port should be Parameterised - assertEquals(instance.getHost(), "search"); - assertEquals(instance.getPort().intValue(), 8983); - assertEquals(instance.getState(), "ACTIVE"); - assertEquals(instance.getMode(), "MASTER"); - } - } - - @Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ACS_60n}) - public void getShardInfoWithoutAdminAuthority() throws Exception - { - restClient.authenticateUser(dataUser.createRandomTestUser()).withShardInfoAPI().getInfo(); - restClient.assertStatusCodeIs(HttpStatus.INTERNAL_SERVER_ERROR); - } -} diff --git a/e2e-test/java/org/alfresco/rest/search/solr/SearchSolrAPITest.java b/e2e-test/java/org/alfresco/rest/search/solr/SearchSolrAPITest.java deleted file mode 100644 index 0f1ed9f06..000000000 --- a/e2e-test/java/org/alfresco/rest/search/solr/SearchSolrAPITest.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright (C) 2018 Alfresco Software Limited. - * This file is part of Alfresco - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.rest.search.solr; - -import java.net.URLEncoder; - -import javax.json.JsonArrayBuilder; - -import org.alfresco.rest.core.JsonBodyGenerator; -import org.alfresco.rest.model.RestTextResponse; -import org.alfresco.rest.search.AbstractSearchTest; -import org.alfresco.utility.model.TestGroup; -import org.hamcrest.Matchers; -import org.springframework.http.HttpStatus; -import org.testng.Assert; -import org.testng.annotations.Test; - -/** - * Tests for solr/alfresco Solr API. - * - * @author Meenal Bhave - */ -public class SearchSolrAPITest extends AbstractSearchTest -{ - @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_112 }, priority = 01) - public void testGetSolrConfig() throws Exception - { - RestTextResponse response = restClient.authenticateUser(adminUserModel).withSolrAPI().getConfig(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - restClient.onResponse().assertThat().content(Matchers.containsString("config")); - Assert.assertNotNull(response.getJsonValueByPath("config.requestHandler")); - Assert.assertNotNull(response.getJsonObjectByPath("config.requestHandler")); - - // TODO: Following asserts fail with error: - /* - * java.lang.IllegalStateException: Expected response body to be verified as JSON, HTML or XML but content-type 'text/plain' is not supported out of the box. - * Try registering a custom parser using: RestAssured.registerParser("text/plain", ); - */ - - // response.assertThat().body("config.requestHandler", Matchers.notNullValue()); - // restClient.onResponse().assertThat().body("config.requestHandler",Matchers.notNullValue()); - } - - @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_112 }, priority = 02) - public void testEditSolrConfig() throws Exception - { - String expectedError = "solrconfig editing is not enabled due to disable.configEdit"; - - JsonArrayBuilder argsArray = JsonBodyGenerator.defineJSONArray(); - argsArray.add("ANYARGS"); - - String postBody = JsonBodyGenerator.defineJSON() - .add("add-listener", JsonBodyGenerator.defineJSON() - .add("event", "postCommit") - .add("name", "newlistener") - .add("class", "solr.RunExecutableListener") - .add("exe", "ANYCOMMAND") - .add("dir", "/usr/bin/") - .add("args", argsArray)).build().toString(); - - // RestTextResponse response = - restClient.authenticateUser(adminUserModel).withSolrAPI().postConfig(postBody); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - - restClient.onResponse().assertThat().content(Matchers.containsString(expectedError)); - - // TODO: Following asserts fail with error: - /* - * java.lang.IllegalStateException: Expected response body to be verified as JSON, HTML or XML but content-type 'text/plain' is not supported out of the box. - * Try registering a custom parser using: RestAssured.registerParser("text/plain", ); - */ - - // response.assertThat().body("error.msg", Matchers.contains(expectedError)); - } - - @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_112 }, priority = 03) - public void testGetSolrConfigOverlay() throws Exception - { - restClient.authenticateUser(adminUserModel).withSolrAPI().getConfigOverlay(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - restClient.onResponse().assertThat().content(Matchers.containsString("overlay")); - } - - @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_112 }, priority = 04) - public void testGetSolrConfigParams() throws Exception - { - restClient.authenticateUser(adminUserModel).withSolrAPI().getConfigParams(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - restClient.onResponse().assertThat().content(Matchers.containsString("response")); - } - - @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ASS_112 }, priority = 05) - public void testGetSolrSelect() throws Exception - { - String queryParams = "{!xmlparser v=''}"; - - String encodedQueryParams = URLEncoder.encode(queryParams, "UTF-8"); - - restClient.authenticateUser(dataContent.getAdminUser()).withParams(encodedQueryParams).withSolrAPI().getSelectQuery(); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - String errorMsg = "No QueryObjectBuilder defined for node a in {q={!xmlparser"; - Assert.assertTrue(restClient.onResponse().getResponse().body().xmlPath().getString("response").contains(errorMsg)); - } -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLAPITest.java b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLAPITest.java deleted file mode 100644 index 3335e85c5..000000000 --- a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLAPITest.java +++ /dev/null @@ -1,781 +0,0 @@ -/* - * Copyright (C) 2018 Alfresco Software Limited. - * This file is part of Alfresco - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.rest.search.sql; - -import static java.util.Arrays.asList; - -import static org.hamcrest.Matchers.containsInAnyOrder; -import static org.hamcrest.Matchers.empty; -import static org.hamcrest.Matchers.equalToIgnoringCase; -import static org.hamcrest.Matchers.everyItem; -import static org.hamcrest.Matchers.greaterThan; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.isIn; -import static org.hamcrest.Matchers.not; - -import org.alfresco.rest.core.RestResponse; -import org.alfresco.rest.search.AbstractSearchTest; -import org.alfresco.rest.search.SearchSqlRequest; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.hamcrest.Matchers; -import org.springframework.http.HttpStatus; -import org.testng.Assert; -import org.testng.annotations.Test; - -/** - * Tests for /sql end point Search API. - * - * @author Meenal Bhave - */ -public class SearchSQLAPITest extends AbstractSearchTest -{ - /** - * Path selector to get the values of all cm_name entries for returned search results. - *

          - * For example it will retrieve the "alfresco.txt" from: - *

          -     * {"list": {
          -     *    "entries": [
          -     *       {"entry": [{
          -     *          "label": "cm_name",
          -     *          "value": "alfresco.txt"
          -     *       }]},
          -     *       ...
          -     * 
          - */ - private static final String CM_NAME_VALUES = "list.entries.collect {it.entry.findAll {it.label == 'cm_name'}}.flatten().value"; - String sql = "select SITE, CM_OWNER from alfresco group by SITE,CM_OWNER"; - String[] locales = { "en-US" }; - String solrFormat = "solr"; - - /** - * API post: - * { - * "stmt": "select SITE from alfresco", - * "locales" : ["en_US"], - * "format" : "solr", - * "timezone":"", - * "includeMetadata":false - * } - * Example Response: In Solr Format - * { - * "result-set": - * { - * "docs": - * [ - * { - * "SITE": - * [ - * "swsdp" - * ] - * }, - * { - * "SITE": - * [ - * "swsdp" - * ] - * } - * ] - * } - */ - @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 01) - public void testWithSolr() throws Exception - { - SearchSqlRequest sqlRequest = new SearchSqlRequest(); - sqlRequest.setSql(sql); - sqlRequest.setFormat(solrFormat); - sqlRequest.setLocales(locales); - - restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest); - restClient.assertStatusCodeIs(HttpStatus.OK); - - restClient.onResponse().assertThat().body("result-set", Matchers.notNullValue()); - restClient.onResponse().assertThat().body("result-set.docs", Matchers.notNullValue()); - } - - /** - * API post example: - * { - * "stmt": "select SITE from alfresco", - * "locales" : ["en_US"], - * "format" : "json", - * "timezone":"", - * "includeMetadata":false - * } - * Example Response: In json Format - * { - * "list": - * { - * "pagination": - * { - "count": 103, - "hasMoreItems": false, - "totalItems": 103, - "skipCount": 0, - "maxItems": 1000 - }, - * "entries": - * [ - * "entry": [ - { - "label": "SITE", - "value": "[\"swsdp\"]" - } - ], - "entry": [ - { - "label": "SITE", - "value": "[\"swsdp\"]" - } - ] - * ] - * } - */ - @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 02) - public void testWithJson() throws Exception - { - SearchSqlRequest sqlRequest = new SearchSqlRequest(); - sqlRequest.setSql(sql); - sqlRequest.setLocales(locales); - // Format not set - - restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest); - restClient.assertStatusCodeIs(HttpStatus.OK); - - restClient.onResponse().assertThat().body("result-set", Matchers.nullValue()); - restClient.onResponse().assertThat().body("list.entries", Matchers.notNullValue()); - - sqlRequest = new SearchSqlRequest(); - sqlRequest.setSql(sql); - sqlRequest.setLocales(locales); - sqlRequest.setFormat("json"); // Format json - - restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest); - restClient.assertStatusCodeIs(HttpStatus.OK); - - restClient.onResponse().assertThat().body("result-set", Matchers.nullValue()); - restClient.onResponse().assertThat().body("list.entries", Matchers.notNullValue()); - - sqlRequest = new SearchSqlRequest(); - sqlRequest.setSql(sql); - sqlRequest.setLocales(locales); - sqlRequest.setFormat("abcd"); // Format any other than solr - - restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest); - restClient.assertStatusCodeIs(HttpStatus.OK); - - restClient.onResponse().assertThat().body("result-set", Matchers.nullValue()); - restClient.onResponse().assertThat().body("list.entries", Matchers.notNullValue()); - } - - /** - * API post: - * { - * "stmt": "select SITE from alfresco", - * "locales" : ["en_US"], - * "format" : "solr", - * "timezone":"", - * "includeMetadata":true - * } - * Example Response: In Solr Format: Includes metadata: aliases, fields, isMetadata=true - * { - * "result-set": { - * "docs": [ - * { - * "aliases": { - * "SITE": "SITE" - * }, - * "isMetadata": true, - * "fields": [ - * "SITE" - * ] - * }, - * { - * "SITE": [ - * "swsdp" - * ] - * }, - * { - * "SITE": [ - * "swsdp" - * ] - * }, - * { - * "RESPONSE_TIME": 79, - * "EOF": true - * } - * ] - * } - * } - */ - @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 03) - public void testWithSolrIncludeMetadata() throws Exception - { - SearchSqlRequest sqlRequest = new SearchSqlRequest(); - sqlRequest.setSql(sql); - sqlRequest.setFormat(solrFormat); - sqlRequest.setLocales(locales); - sqlRequest.setIncludeMetadata(true); - - searchSql(sqlRequest); - - restClient.assertStatusCodeIs(HttpStatus.OK); - - restClient.onResponse().assertThat().body("result-set", Matchers.notNullValue()); - restClient.onResponse().assertThat().body("result-set.docs", Matchers.notNullValue()); - restClient.onResponse().assertThat().body("result-set.docs[0].aliases.SITE", equalToIgnoringCase("SITE")); - restClient.onResponse().assertThat().body("result-set.docs[0].isMetadata", is(true)); - restClient.onResponse().assertThat().body("result-set.docs[0].fields[0]", equalToIgnoringCase("SITE")); - } - - /** - * API post example: - * { - * "stmt": "select SITE from alfresco limit 2", - * "locales" : ["en_US"], - * "format" : "json", - * "timezone":"", - * "includeMetadata":false - * } - * Example Response: In json Format - * { - * "list": - * { - * "pagination": - * { - "count": 3, - "hasMoreItems": false, - "totalItems": 3, - "skipCount": 0, - "maxItems": 1000 - }, - * "entries": - * [ - * "entry": [ - { - "label": "aliases", - "value": "{\"SITE\":\"SITE\"}" - }, - { - "label": "isMetadata", - "value": "true" - }, - { - "label": "fields", - "value": "[\"SITE\"]" - } - ] - }, - * "entry": [ - { - "label": "SITE", - "value": "[\"swsdp\"]" - } - ], - "entry": [ - { - "label": "SITE", - "value": "[\"swsdp\"]" - } - ] - * ] - * } - */ - @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 04) - public void testWithJsonIncludeMetadata() throws Exception - { - SearchSqlRequest sqlRequest = new SearchSqlRequest(); - sqlRequest.setSql(sql); - sqlRequest.setFormat(""); - sqlRequest.setLocales(locales); - sqlRequest.setIncludeMetadata(true); - - searchSql(sqlRequest); - - restClient.assertStatusCodeIs(HttpStatus.OK); - - restClient.onResponse().assertThat().body("result-set", Matchers.nullValue()); - restClient.onResponse().assertThat().body("list.entries", Matchers.notNullValue()); - restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", equalToIgnoringCase("aliases")); - restClient.onResponse().assertThat().body("list.entries.entry[0][0].value", equalToIgnoringCase("{\"SITE\":\"SITE\",\"cm_owner\":\"CM_OWNER\"}")); - restClient.onResponse().assertThat().body("list.entries.entry[0][1].label", equalToIgnoringCase("isMetadata")); - restClient.onResponse().assertThat().body("list.entries.entry[0][1].value", is("true")); - restClient.onResponse().assertThat().body("list.entries.entry[0][2].label", equalToIgnoringCase("fields")); - restClient.onResponse().assertThat().body("list.entries.entry[0][2].value", equalToIgnoringCase("[\"SITE\",\"cm_owner\"]")); - } - - @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 05) - public void testIncludeMetadataFalse() throws Exception - { - SearchSqlRequest sqlRequest = new SearchSqlRequest(); - sqlRequest.setSql(sql); - sqlRequest.setFormat("solr"); // Format solr - sqlRequest.setIncludeMetadata(false); - - restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest); - restClient.assertStatusCodeIs(HttpStatus.OK); - - restClient.onResponse().assertThat().body("result-set", Matchers.notNullValue()); - restClient.onResponse().assertThat().body("result-set.docs", Matchers.notNullValue()); - restClient.onResponse().assertThat().body("result-set.docs[0].aliases", Matchers.nullValue()); - restClient.onResponse().assertThat().body("result-set.docs[0].isMetadata", Matchers.nullValue()); - restClient.onResponse().assertThat().body("result-set.docs[0].fields", Matchers.nullValue()); - - sqlRequest = new SearchSqlRequest(); - sqlRequest.setSql(sql); - sqlRequest.setIncludeMetadata(false); - sqlRequest.setFormat("json"); // Format json - - restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest); - restClient.assertStatusCodeIs(HttpStatus.OK); - - restClient.onResponse().assertThat().body("result-set", Matchers.nullValue()); - restClient.onResponse().assertThat().body("list.entries", Matchers.notNullValue()); - restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", Matchers.notNullValue()); - restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", not("aliases")); - - sqlRequest = new SearchSqlRequest(); - sqlRequest.setSql(sql); - sqlRequest.setIncludeMetadata(false); // Format not set - - restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest); - restClient.assertStatusCodeIs(HttpStatus.OK); - - restClient.onResponse().assertThat().body("result-set", Matchers.nullValue()); - restClient.onResponse().assertThat().body("list.entries", Matchers.notNullValue()); - restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", Matchers.notNullValue()); - restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", not("aliases")); - - sqlRequest = new SearchSqlRequest(); - sqlRequest.setSql(sql); - sqlRequest.setFormat(solrFormat); // IncludeMetadata = false when not specified - - restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest); - restClient.assertStatusCodeIs(HttpStatus.OK); - - restClient.onResponse().assertThat().body("result-set", Matchers.notNullValue()); - restClient.onResponse().assertThat().body("result-set.docs", Matchers.notNullValue()); - restClient.onResponse().assertThat().body("result-set.docs[0].aliases", Matchers.nullValue()); - restClient.onResponse().assertThat().body("result-set.docs[0].isMetadata", Matchers.nullValue()); - restClient.onResponse().assertThat().body("result-set.docs[0].fields", Matchers.nullValue()); - } - - @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 06) - public void testLocales() throws Exception - { - String[] noLocales = {}; // Not specified - - SearchSqlRequest sqlRequest = new SearchSqlRequest(); - sqlRequest.setSql(sql); - sqlRequest.setLocales(noLocales); - - searchSql(sqlRequest); - - restClient.assertStatusCodeIs(HttpStatus.OK); - - String[] singleLocale = { "en-Uk" }; - - sqlRequest = new SearchSqlRequest(); - sqlRequest.setSql(sql); - sqlRequest.setLocales(singleLocale); - - searchSql(sqlRequest); - - restClient.assertStatusCodeIs(HttpStatus.OK); - - String[] multipleLocales = { "en-US", "ja" }; - - sqlRequest = new SearchSqlRequest(); - sqlRequest.setSql(sql); - sqlRequest.setLocales(multipleLocales); - - searchSql(sqlRequest); - - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 07) - public void testTimezone() throws Exception - { - String timezone = ""; // Not specified - - SearchSqlRequest sqlRequest = new SearchSqlRequest(); - sqlRequest.setSql(sql); - sqlRequest.setTimezone(timezone); - - searchSql(sqlRequest); - - restClient.assertStatusCodeIs(HttpStatus.OK); - - timezone = "UTC"; // UTC - - sqlRequest = new SearchSqlRequest(); - sqlRequest.setSql(sql); - sqlRequest.setTimezone(timezone); - - searchSql(sqlRequest); - - restClient.assertStatusCodeIs(HttpStatus.OK); - - timezone = "false"; // Invalid timezone is ignored - - sqlRequest = new SearchSqlRequest(); - sqlRequest.setSql(sql); - sqlRequest.setTimezone(timezone); - - searchSql(sqlRequest); - - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 8) - public void testAggregateSQL() throws Exception - { - String agSql = "select count(*) FROM alfresco where TYPE='cm:content'"; - - SearchSqlRequest sqlRequest = new SearchSqlRequest(); - sqlRequest.setSql(agSql); - - RestResponse response = searchSql(sqlRequest); - - restClient.assertStatusCodeIs(HttpStatus.OK); - response.assertThat().body("list.entries", Matchers.notNullValue()); - response.assertThat().body("list.entries.entry[0][0].value", not("0")); - } - - @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 9) - public void testLimit() throws Exception - { - Integer defaultLimit = 1000; - - Integer limit = null; // Limit defaults to the default setting when null - - SearchSqlRequest sqlRequest = new SearchSqlRequest(); - sqlRequest.setSql(sql); - sqlRequest.setLimit(limit); - - RestResponse response = searchSql(sqlRequest); - - restClient.assertStatusCodeIs(HttpStatus.OK); - response.assertThat().body("list.pagination.maxItems", Matchers.equalTo(defaultLimit)); - - limit = 0; // Limit defaults to the default setting when 0 - sqlRequest = new SearchSqlRequest(); - sqlRequest.setSql(sql); - sqlRequest.setLimit(limit); - - response = searchSql(sqlRequest); - - restClient.assertStatusCodeIs(HttpStatus.OK); - response.assertThat().body("list.pagination.maxItems", Matchers.equalTo(defaultLimit)); - - limit = 100; // Limit is applied correctly, with maxItems = limit - sqlRequest = new SearchSqlRequest(); - sqlRequest.setSql(sql); - sqlRequest.setLimit(limit); - - response = searchSql(sqlRequest); - - restClient.assertStatusCodeIs(HttpStatus.OK); - response.assertThat().body("list.pagination.maxItems", Matchers.equalTo(limit)); - } - - @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 10) - public void testAuthenticationError() throws Exception - { - UserModel dummyUser = dataUser.createRandomTestUser("UserSearchDummy"); - dummyUser.setPassword("incorrect-password"); - - SearchSqlRequest sqlRequest = new SearchSqlRequest(); - sqlRequest.setSql(sql); - sqlRequest.setLocales(locales); - - restClient.authenticateUser(dummyUser).withSearchSqlAPI().searchSql(sqlRequest); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); - } - - @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 11) - public void testPermissions() throws Exception - { - UserModel userNoPerm = dataUser.createRandomTestUser("UserSearchNoPerm"); - UserModel userPerm = dataUser.createRandomTestUser("UserSearchPerm"); - - dataUser.addUserToSite(userPerm, siteModel, UserRole.SiteContributor); - - String siteSQL = "select SITE, CM_OWNER from alfresco where SITE='" + siteModel.getId() + "'"; - SearchSqlRequest sqlRequest = new SearchSqlRequest(); - sqlRequest.setSql(siteSQL); - - // 0 results expected for query as User does not have access to the private site - restClient.authenticateUser(userNoPerm).withSearchSqlAPI().searchSql(sqlRequest); - restClient.assertStatusCodeIs(HttpStatus.OK); - - restClient.onResponse().assertThat().body("list.pagination.count", is(0)); - restClient.onResponse().assertThat().body("list.pagination.totalItems", is(0)); - restClient.onResponse().assertThat().body("list.pagination.hasMoreItems", is(false)); - restClient.onResponse().assertThat().body("list.entries", empty()); - - // Results expected for query as User does has access to the private site - restClient.authenticateUser(userPerm).withSearchSqlAPI().searchSql(sqlRequest); - restClient.assertStatusCodeIs(HttpStatus.OK); - - restClient.onResponse().assertThat().body("list.pagination.count", greaterThan(0)); - restClient.onResponse().assertThat().body("list.pagination.totalItems", greaterThan(0)); - restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", equalToIgnoringCase("SITE")); - restClient.onResponse().assertThat().body("list.entries.entry[0][0].value", equalToIgnoringCase("[\"" + siteModel.getId() + "\"]")); - } - - @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 12) - public void testErrors() throws Exception - { - String incorrectSQL = ""; // Missing SQL - - SearchSqlRequest sqlRequest = new SearchSqlRequest(); - sqlRequest.setSql(incorrectSQL); - - restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - restClient.onResponse().assertThat().body("error.briefSummary", Matchers.notNullValue()); - restClient.onResponse().assertThat().body("error.briefSummary", Matchers.containsString("Required stmt parameter is missing")); - - incorrectSQL = "select SITE from unknownTable"; // Wrong table name - - sqlRequest = new SearchSqlRequest(); - sqlRequest.setSql(incorrectSQL); - - restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - restClient.onResponse().assertThat().body("error.briefSummary", Matchers.notNullValue()); - // restClient.onResponse().assertThat().body("error.briefSummary", Matchers.containsString("Table 'unknownTable' not found")); - - incorrectSQL = "select Column1 from alfresco"; // Wrong ColumnName - - sqlRequest = new SearchSqlRequest(); - sqlRequest.setSql(incorrectSQL); - - restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - restClient.onResponse().assertThat().body("error.briefSummary", Matchers.notNullValue()); - restClient.onResponse().assertThat().body("error.briefSummary", Matchers.containsString("Column 'Column1' not found")); - - incorrectSQL = "select SITE alfresco"; // BAD SQL Grammar: from missing - - sqlRequest = new SearchSqlRequest(); - sqlRequest.setSql(incorrectSQL); - - restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - restClient.onResponse().assertThat().body("error.briefSummary", Matchers.notNullValue()); - restClient.onResponse().assertThat().body("error.briefSummary", Matchers.containsString("Unable to execute the query")); - - incorrectSQL = "select SITE, CM_OWNER from alfresco group by SITE"; // BAD SQL Grammar: CM_OWNER is not being grouped - - sqlRequest = new SearchSqlRequest(); - sqlRequest.setSql(incorrectSQL); - - restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - restClient.onResponse().assertThat().body("error.briefSummary", Matchers.notNullValue()); - restClient.onResponse().assertThat().body("error.briefSummary", Matchers.containsString("Expression 'CM_OWNER' is not being grouped")); - - incorrectSQL = "delete SITE from alfresco"; // BAD SQL Grammar - - sqlRequest = new SearchSqlRequest(); - sqlRequest.setSql(incorrectSQL); - - restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - restClient.onResponse().assertThat().body("error.briefSummary", Matchers.notNullValue()); - restClient.onResponse().assertThat().body("error.briefSummary", Matchers.containsString("Was expecting one of")); - } - - @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.NOT_INSIGHT_ENGINE }, priority = 13) - public void testErrorForSQLAPIWithASS() throws Exception - { - String acsVersion = serverHealth.getAlfrescoVersion(); - HttpStatus expectedStatus = HttpStatus.OK; - - SearchSqlRequest sqlRequest = new SearchSqlRequest(); - sqlRequest.setSql(sql); - sqlRequest.setLocales(locales); - - // Set expected result based on ACS Version and ASS Version - if (!acsVersion.startsWith("6")) - { - expectedStatus = HttpStatus.NOT_FOUND; - } - else - { - expectedStatus = HttpStatus.BAD_REQUEST; - } - - restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest); - restClient.assertStatusCodeIs(expectedStatus); - } - - @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 14) - public void testSelectStar() throws Exception - { - // Select * with Limit, json format - SearchSqlRequest sqlRequest = new SearchSqlRequest(); - sqlRequest.setSql("select * from alfresco"); - sqlRequest.setLimit(1); - - RestResponse response = searchSql(sqlRequest); - - restClient.assertStatusCodeIs(HttpStatus.OK); - response.assertThat().body("list.pagination.maxItems", Matchers.equalTo(1)); - restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", equalToIgnoringCase("PATH")); - - // Select * with Limit, solr format: Also covered in JDBC - sqlRequest = new SearchSqlRequest(); - sqlRequest.setSql("select * from alfresco"); - sqlRequest.setFormat("solr"); - sqlRequest.setIncludeMetadata(true); - sqlRequest.setLimit(1); - - response = searchSql(sqlRequest); - - restClient.assertStatusCodeIs(HttpStatus.OK); - restClient.onResponse().assertThat().body("result-set.docs[0].aliases.cm_name", Matchers.notNullValue()); - restClient.onResponse().assertThat().body("result-set.docs[0].aliases.cm_created", Matchers.notNullValue()); - restClient.onResponse().assertThat().body("result-set.docs[0].aliases.cm_creator", Matchers.notNullValue()); - restClient.onResponse().assertThat().body("result-set.docs[0].aliases.cm_modified", Matchers.notNullValue()); - restClient.onResponse().assertThat().body("result-set.docs[0].aliases.cm_modifier", Matchers.notNullValue()); - restClient.onResponse().assertThat().body("result-set.docs[0].aliases.cm_owner", Matchers.notNullValue()); - restClient.onResponse().assertThat().body("result-set.docs[0].aliases.OWNER", Matchers.notNullValue()); - restClient.onResponse().assertThat().body("result-set.docs[0].aliases.TYPE", Matchers.notNullValue()); - restClient.onResponse().assertThat().body("result-set.docs[0].aliases.LID", Matchers.notNullValue()); - restClient.onResponse().assertThat().body("result-set.docs[0].aliases.DBID", Matchers.notNullValue()); - restClient.onResponse().assertThat().body("result-set.docs[0].aliases.cm_title", Matchers.notNullValue()); - restClient.onResponse().assertThat().body("result-set.docs[0].aliases.cm_description", Matchers.notNullValue()); - - // This type of assertion is required because of a '.' in the field name - Assert.assertTrue(response.getResponse().body().jsonPath().get("result-set.docs[0].aliases").toString().contains("cm_content.size=cm_content.size")); - Assert.assertTrue(response.getResponse().body().jsonPath().get("result-set.docs[0].aliases").toString().contains("cm_content.mimetype=cm_content.mimetype")); - Assert.assertTrue(response.getResponse().body().jsonPath().get("result-set.docs[0].aliases").toString().contains("cm_content.encoding=cm_content.encoding")); - Assert.assertTrue(response.getResponse().body().jsonPath().get("result-set.docs[0].aliases").toString().contains("cm_content.locale=cm_content.locale")); - - restClient.onResponse().assertThat().body("result-set.docs[0].aliases.cm_lockOwner", Matchers.notNullValue()); - restClient.onResponse().assertThat().body("result-set.docs[0].aliases.SITE", Matchers.notNullValue()); - restClient.onResponse().assertThat().body("result-set.docs[0].aliases.PARENT", Matchers.notNullValue()); - restClient.onResponse().assertThat().body("result-set.docs[0].aliases.PATH", Matchers.notNullValue()); - restClient.onResponse().assertThat().body("result-set.docs[0].aliases.PRIMARYPARENT", Matchers.notNullValue()); - restClient.onResponse().assertThat().body("result-set.docs[0].aliases.ASPECT", Matchers.notNullValue()); - restClient.onResponse().assertThat().body("result-set.docs[0].aliases.QNAME", Matchers.notNullValue()); - - // Test that cm_content and any other random field does not appear in the response - restClient.onResponse().assertThat().body("result-set.docs[0].aliases.cm_content", Matchers.nullValue()); - restClient.onResponse().assertThat().body("result-set.docs[0].aliases.RandomNonExistentField", Matchers.nullValue()); - } - - @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 15) - public void testDistinct() throws Exception - { - // Select distinct site: json format - SearchSqlRequest sqlRequest = new SearchSqlRequest(); - sqlRequest.setSql("select distinct Site from alfresco"); - sqlRequest.setLimit(10); - - RestResponse response = searchSql(sqlRequest); - - restClient.assertStatusCodeIs(HttpStatus.OK); - response.assertThat().body("list.pagination.maxItems", Matchers.equalTo(10)); - restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", equalToIgnoringCase("site")); - - // Select distinct cm_name: solr format - sqlRequest = new SearchSqlRequest(); - sqlRequest.setSql("select distinct cm_name from alfresco limit 5"); - sqlRequest.setFormat("solr"); - - searchSql(sqlRequest); - - restClient.assertStatusCodeIs(HttpStatus.OK); - restClient.onResponse().assertThat().body("result-set.docs[0].cm_name", Matchers.notNullValue()); - } - - /** Check that a filter query can affect which results are included. */ - @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_11 }, priority = 16) - public void testFilterQuery() throws Exception - { - SearchSqlRequest sqlRequest = new SearchSqlRequest(); - String siteSQL = "select SITE, CM_OWNER from alfresco where SITE='" + siteModel.getId() + "'"; - sqlRequest.setSql(siteSQL); - // Add a filter query to only include results from inside the site (i.e. all results). - String[] filterQuery = { "SITE:'" + siteModel.getId() + "'" }; - sqlRequest.setFilterQuery(filterQuery); - - searchSql(sqlRequest); - - restClient.assertStatusCodeIs(HttpStatus.OK); - restClient.onResponse().assertThat().body("list.pagination.count", greaterThan(0)); - restClient.onResponse().assertThat().body("list.pagination.totalItems", greaterThan(0)); - restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", equalToIgnoringCase("SITE")); - restClient.onResponse().assertThat().body("list.entries.entry[0][0].value", equalToIgnoringCase("[\"" + siteModel.getId() + "\"]")); - - // Now try instead removing everything from the site (i.e. all results). - String[] inverseFilterQuery = { "-SITE:'" + siteModel.getId() + "'" }; - sqlRequest.setFilterQuery(inverseFilterQuery); - - searchSql(sqlRequest); - - restClient.assertStatusCodeIs(HttpStatus.OK); - restClient.onResponse().assertThat().body("list.pagination.count", is(0)); - restClient.onResponse().assertThat().body("list.pagination.totalItems", is(0)); - restClient.onResponse().assertThat().body("list.pagination.hasMoreItems", is(false)); - restClient.onResponse().assertThat().body("list.entries", empty()); - } - - /** Check that the combination of multiple filter queries produce the intersection of results. */ - @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_11 }, priority = 17) - public void testCombiningFilterQueries() throws Exception - { - String siteSQL = "select cm_name from alfresco where SITE='" + siteModel.getId() + "'"; - SearchSqlRequest sqlRequest = new SearchSqlRequest(); - sqlRequest.setSql(siteSQL); - // Add a filter query to only include results from inside the site (i.e. all results). - String[] filterQueries = { "-cm_name:'cars'", "-cm_name:'pangram'" }; - sqlRequest.setFilterQuery(filterQueries); - - searchSql(sqlRequest); - - restClient.assertStatusCodeIs(HttpStatus.OK); - restClient.onResponse().assertThat().body("list.pagination.count", greaterThan(0)); - restClient.onResponse().assertThat().body("list.pagination.totalItems", greaterThan(0)); - // Check that pangram.txt and cars.txt were both filtered out. - restClient.onResponse().assertThat() - .body(CM_NAME_VALUES, everyItem(not(isIn(asList("pangram.txt", "cars.txt"))))); - } - - /** Check that an empty list of filter queries doesn't remove anything from the results. */ - @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_11 }, priority = 18) - public void testEmptyFilterQuery() throws Exception - { - String siteSQL = "select cm_name from alfresco where SITE='" + siteModel.getId() + "'"; - SearchSqlRequest sqlRequest = new SearchSqlRequest(); - sqlRequest.setSql(siteSQL); - // Add an empty list of filter queries. - sqlRequest.setFilterQuery(new String[]{}); - - searchSql(sqlRequest); - - restClient.assertStatusCodeIs(HttpStatus.OK); - // Check that the cm_names of all nodes in the site are returned. - restClient.onResponse().assertThat() - .body(CM_NAME_VALUES, containsInAnyOrder("documentLibrary", SEARCH_DATA_SAMPLE_FOLDER, "pangram.txt", "cars.txt", "alfresco.txt", unique_searchString + ".txt")); - } -} diff --git a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLPhraseTest.java b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLPhraseTest.java deleted file mode 100644 index 86551eb09..000000000 --- a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLPhraseTest.java +++ /dev/null @@ -1,256 +0,0 @@ -/* - * Copyright (C) 2018 Alfresco Software Limited. - * This file is part of Alfresco - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.rest.search.sql; - -import java.sql.ResultSet; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import org.alfresco.rest.core.RestResponse; -import org.alfresco.rest.search.AbstractSearchTest; -import org.alfresco.rest.search.SearchSqlJDBCRequest; -import org.alfresco.rest.search.SearchSqlRequest; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FileType; -import org.alfresco.utility.model.TestGroup; -import org.springframework.http.HttpStatus; -import org.testng.Assert; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; -import org.hamcrest.Matchers; - -/** - * Tests for /sql end point Search API: Phrase Searching. - * - * @author Meenal Bhave - */ -public class SearchSQLPhraseTest extends AbstractSearchTest -{ - FileModel fileBanana, fileYellowBanana, fileBigYellowBanana, fileBigBananaBoat, fileYellowBananaBigBoat, fileBigYellowBoat; - - List expectedContent = new ArrayList(); - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - super.dataPreparation(); - - // Create files with different phrases - fileBanana = new FileModel(unique_searchString + "-1.txt", "banana", "phrase searching", FileType.TEXT_PLAIN, "banana"); - dataContent.usingUser(userModel).usingSite(siteModel).createContent(fileBanana); - - fileYellowBanana = new FileModel(unique_searchString + "-2.txt", "yellow banana", "phrase searching", FileType.TEXT_PLAIN, "yellow banana"); - dataContent.usingUser(userModel).usingSite(siteModel).createContent(fileYellowBanana); - - fileBigYellowBanana = new FileModel(unique_searchString + "-3.txt", "big yellow banana", "phrase searching", FileType.TEXT_PLAIN, "big yellow banana"); - dataContent.usingUser(userModel).usingSite(siteModel).createContent(fileBigYellowBanana); - - fileBigBananaBoat = new FileModel(unique_searchString + "-4.txt", "big boat", "phrase searching", FileType.TEXT_PLAIN, "big boat"); - dataContent.usingUser(userModel).usingSite(siteModel).createContent(fileBigBananaBoat); - - fileYellowBananaBigBoat = new FileModel(unique_searchString + "-5.txt", "yellow banana big boat", "phrase searching", FileType.TEXT_PLAIN, "yellow banana big boat"); - dataContent.usingUser(userModel).usingSite(siteModel).createContent(fileYellowBananaBigBoat); - - fileBigYellowBoat = new FileModel(unique_searchString + "-6.txt", "big yellow boat", "phrase searching", FileType.TEXT_PLAIN, "big yellow boat"); - dataContent.usingUser(userModel).usingSite(siteModel).createContent(fileBigYellowBoat); - - waitForIndexing(fileBigYellowBoat.getName(), true); - } - - @SuppressWarnings("unchecked") - @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 1) - public void testPhraseQueries() throws Exception - { - // yellow banana: 5 results expected - SearchSqlRequest sqlRequest = new SearchSqlRequest(); - sqlRequest.setSql("select cm_content from alfresco where cm_content = '(yellow banana)'"); - sqlRequest.setLimit(10); - - RestResponse response = searchSql(sqlRequest); - - restClient.assertStatusCodeIs(HttpStatus.OK); - - // Set Expected Result - expectedContent = new ArrayList(); - expectedContent.add(Arrays.asList(fileBanana.getContent())); - expectedContent.add(Arrays.asList(fileYellowBanana.getContent())); - expectedContent.add(Arrays.asList(fileBigYellowBanana.getContent())); - expectedContent.add(Arrays.asList(fileYellowBananaBigBoat.getContent())); - expectedContent.add(Arrays.asList(fileBigYellowBoat.getContent())); - - // Check Result count matches - response.assertThat().body("list.pagination.count", Matchers.equalTo(expectedContent.size())); - - // Check Results match - Collection> actualContent = response.getResponse().body().jsonPath().get("list.entries.entry.value"); - Assert.assertTrue(actualContent.containsAll(expectedContent), String.format("Phrase Search Results expected: %s Actual: %s", expectedContent.toString(), actualContent.toString())); - Assert.assertTrue(expectedContent.containsAll(actualContent), String.format("Phrase Search Results expected: %s Actual: %s", expectedContent.toString(), actualContent.toString())); - - // yellow banana big boat: 6 results expected - sqlRequest = new SearchSqlRequest(); - sqlRequest.setSql("select cm_content from alfresco where cm_content = '(yellow banana big boat)'"); - sqlRequest.setLimit(10); - - response = searchSql(sqlRequest); - - restClient.assertStatusCodeIs(HttpStatus.OK); - - // Set Expected Result - expectedContent = new ArrayList(); - expectedContent.add(Arrays.asList(fileBanana.getContent())); - expectedContent.add(Arrays.asList(fileYellowBanana.getContent())); - expectedContent.add(Arrays.asList(fileBigYellowBanana.getContent())); - expectedContent.add(Arrays.asList(fileYellowBananaBigBoat.getContent())); - expectedContent.add(Arrays.asList(fileBigYellowBoat.getContent())); - expectedContent.add(Arrays.asList(fileBigBananaBoat.getContent())); - - // Check Result count matches - response.assertThat().body("list.pagination.count", Matchers.equalTo(expectedContent.size())); - - // Check Results match - actualContent = response.getResponse().body().jsonPath().get("list.entries.entry.value"); - Assert.assertTrue(actualContent.containsAll(expectedContent), String.format("Phrase Search Results expected: %s Actual: %s", expectedContent.toString(), actualContent.toString())); - Assert.assertTrue(expectedContent.containsAll(actualContent), String.format("Phrase Search Results expected: %s Actual: %s", expectedContent.toString(), actualContent.toString())); - - // yellow banana big boat: 4 results expected - sqlRequest = new SearchSqlRequest(); - sqlRequest.setSql("select cm_content from alfresco where cm_content = '(big boat)'"); - sqlRequest.setLimit(10); - - response = searchSql(sqlRequest); - - restClient.assertStatusCodeIs(HttpStatus.OK); - - // Set Expected Result - expectedContent = new ArrayList(); - expectedContent.add(Arrays.asList(fileBigYellowBanana.getContent())); - expectedContent.add(Arrays.asList(fileYellowBananaBigBoat.getContent())); - expectedContent.add(Arrays.asList(fileBigYellowBoat.getContent())); - expectedContent.add(Arrays.asList(fileBigBananaBoat.getContent())); - - // Check Result count matches - response.assertThat().body("list.pagination.count", Matchers.equalTo(expectedContent.size())); - - // Check Results match - actualContent = response.getResponse().body().jsonPath().get("list.entries.entry.value"); - Assert.assertTrue(actualContent.containsAll(expectedContent), String.format("Phrase Search Results expected: %s Actual: %s", expectedContent.toString(), actualContent.toString())); - Assert.assertTrue(expectedContent.containsAll(actualContent), String.format("Phrase Search Results expected: %s Actual: %s", expectedContent.toString(), actualContent.toString())); - } - - @SuppressWarnings("unchecked") - @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 2) - public void testPhraseQueriesViaJDBC() throws Exception - { - // yellow banana: 5 results expected - SearchSqlJDBCRequest sqlRequest = new SearchSqlJDBCRequest(); - String sql = "select cm_content from alfresco where cm_content = '(yellow banana)'"; - sqlRequest.setSql(sql); - sqlRequest.setAuthUser(userModel); - - ResultSet rs = restClient.withSearchSqlViaJDBC().executeQueryViaJDBC(sqlRequest); - Assert.assertNotNull(rs); - Assert.assertNull(sqlRequest.getErrorDetails()); - - // Set Expected Result - expectedContent = new ArrayList(); - expectedContent.add(Arrays.asList(fileBanana.getContent())); - expectedContent.add(Arrays.asList(fileYellowBanana.getContent())); - expectedContent.add(Arrays.asList(fileBigYellowBanana.getContent())); - expectedContent.add(Arrays.asList(fileYellowBananaBigBoat.getContent())); - expectedContent.add(Arrays.asList(fileBigYellowBoat.getContent())); - - Integer i = 0; - List actualContent = new ArrayList(); - - while (rs.next()) - { - // Field values are retrieved - Assert.assertNotNull(rs.getString("cm_content")); - actualContent.add(Arrays.asList(rs.getString("cm_content"))); - i++; - } - - Assert.assertTrue(i == expectedContent.size()); - Assert.assertTrue(actualContent.containsAll(expectedContent), String.format("Phrase Search Results expected: %s Actual: %s", expectedContent.toString(), actualContent.toString())); - Assert.assertTrue(expectedContent.containsAll(actualContent), String.format("Phrase Search Results expected: %s Actual: %s", expectedContent.toString(), actualContent.toString())); - - // yellow banana big boat: 6 results expected - sql = "select cm_content from alfresco where cm_content = '(yellow banana big boat)'"; - sqlRequest.setSql(sql); - sqlRequest.setAuthUser(userModel); - - rs = restClient.withSearchSqlViaJDBC().executeQueryViaJDBC(sqlRequest); - Assert.assertNotNull(rs); - Assert.assertNull(sqlRequest.getErrorDetails()); - - // Set Expected Result - expectedContent = new ArrayList(); - expectedContent.add(Arrays.asList(fileBanana.getContent())); - expectedContent.add(Arrays.asList(fileYellowBanana.getContent())); - expectedContent.add(Arrays.asList(fileBigYellowBanana.getContent())); - expectedContent.add(Arrays.asList(fileYellowBananaBigBoat.getContent())); - expectedContent.add(Arrays.asList(fileBigYellowBoat.getContent())); - expectedContent.add(Arrays.asList(fileBigBananaBoat.getContent())); - - i = 0; - actualContent = new ArrayList(); - - while (rs.next()) - { - // Field values are retrieved - Assert.assertNotNull(rs.getString("cm_content")); - actualContent.add(Arrays.asList(rs.getString("cm_content"))); - i++; - } - - Assert.assertTrue(i == expectedContent.size()); - Assert.assertTrue(actualContent.containsAll(expectedContent), String.format("Phrase Search Results expected: %s Actual: %s", expectedContent.toString(), actualContent.toString())); - Assert.assertTrue(expectedContent.containsAll(actualContent), String.format("Phrase Search Results expected: %s Actual: %s", expectedContent.toString(), actualContent.toString())); - - // big boat: 4 results expected - sql = "select cm_content from alfresco where cm_content = '(big boat)'"; - sqlRequest.setSql(sql); - sqlRequest.setAuthUser(userModel); - - rs = restClient.withSearchSqlViaJDBC().executeQueryViaJDBC(sqlRequest); - Assert.assertNotNull(rs); - Assert.assertNull(sqlRequest.getErrorDetails()); - - // Set Expected Result - expectedContent = new ArrayList(); - expectedContent.add(Arrays.asList(fileBigYellowBanana.getContent())); - expectedContent.add(Arrays.asList(fileYellowBananaBigBoat.getContent())); - expectedContent.add(Arrays.asList(fileBigYellowBoat.getContent())); - expectedContent.add(Arrays.asList(fileBigBananaBoat.getContent())); - - i = 0; - actualContent = new ArrayList(); - - while (rs.next()) - { - // Field values are retrieved - Assert.assertNotNull(rs.getString("cm_content")); - actualContent.add(Arrays.asList(rs.getString("cm_content"))); - i++; - } - - Assert.assertTrue(i == expectedContent.size()); - Assert.assertTrue(actualContent.containsAll(expectedContent), String.format("Phrase Search Results expected: %s Actual: %s", expectedContent.toString(), actualContent.toString())); - Assert.assertTrue(expectedContent.containsAll(actualContent), String.format("Phrase Search Results expected: %s Actual: %s", expectedContent.toString(), actualContent.toString())); - } -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLViaJDBCTest.java b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLViaJDBCTest.java deleted file mode 100644 index eed0bb445..000000000 --- a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLViaJDBCTest.java +++ /dev/null @@ -1,213 +0,0 @@ -/* - * Copyright (C) 2018 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.rest.search.sql; - -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; - -import org.alfresco.dataprep.SiteService.Visibility; -import org.alfresco.rest.requests.search.SearchSQLJDBC; -import org.alfresco.rest.search.AbstractSearchTest; -import org.alfresco.rest.search.SearchSqlJDBCRequest; -import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.Test; -import org.testng.Assert; - -/** - * Search SQL end point test via JDBC. - * @author MSuzuki - * @author Meenal Bhave - * - */ -public class SearchSQLViaJDBCTest extends AbstractSearchTest -{ - List sites = new ArrayList(); - SearchSQLJDBC searchSql; - SearchSqlJDBCRequest sqlRequest = new SearchSqlJDBCRequest(); - - @AfterMethod(alwaysRun=true) - public void cleanUp() throws SQLException - { - restClient.withSearchSqlViaJDBC().clearSearchQuery(sqlRequest); - sqlRequest = new SearchSqlJDBCRequest(); - sites = new ArrayList(); - } - - @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority=01) - public void testQueryPublicSite() throws SQLException - { - - SiteModel publicSite = new SiteModel(RandomData.getRandomName("SiteSearch")); - publicSite.setVisibility(Visibility.PUBLIC); - - publicSite = dataSite.usingUser(adminUserModel).createSite(publicSite); - - String sql = "select SITE,CM_OWNER from alfresco where SITE ='" + publicSite.getTitle() + "' group by SITE,CM_OWNER"; - sqlRequest.setSql(sql); - sqlRequest.setAuthUser(userModel); - - ResultSet rs = restClient.withSearchSqlViaJDBC().executeQueryViaJDBC(sqlRequest); - - while (rs.next()) - { - // User can see the Public Site created by other user - Assert.assertNotNull(rs.getString("SITE")); - Assert.assertTrue(publicSite.getTitle().equalsIgnoreCase(rs.getString("SITE"))); - - Assert.assertNotNull(rs.getString("CM_OWNER")); - Assert.assertTrue(rs.getString("CM_OWNER").contains(adminUserModel.getUsername())); - } - } - - @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority=02) - public void testQueryMyCreatedPrivateSite() throws SQLException - { - String sql = "select distinct SITE from alfresco where SITE ='" + siteModel.getTitle() + "'"; - sqlRequest.setSql(sql); - sqlRequest.setAuthUser(userModel); - - ResultSet rs = restClient.withSearchSqlViaJDBC().executeQueryViaJDBC(sqlRequest); - - while (rs.next()) - { - // User can see Own Private Site - Assert.assertNotNull(rs.getString("SITE")); - Assert.assertTrue(siteModel.getTitle().equalsIgnoreCase(rs.getString("SITE"))); - } - } - - @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority=03) - public void testQueryPrivateSiteWithSuperUser() throws SQLException - { - String sql = "select distinct SITE from alfresco where SITE ='" + siteModel.getTitle() + "'"; - sqlRequest.setSql(sql); - sqlRequest.setAuthUser(adminUserModel); - - ResultSet rs = restClient.withSearchSqlViaJDBC().executeQueryViaJDBC(sqlRequest); - - while (rs.next()) - { - // Super user can see Private Site created by other user - Assert.assertNotNull(rs.getString("SITE")); - Assert.assertTrue(siteModel.getTitle().equalsIgnoreCase(rs.getString("SITE"))); - } - } - - @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority=04) - public void testQueryPrivateSiteWithSimpleUser() throws SQLException - { - UserModel managerUser = dataUser.createRandomTestUser("UserSearchMgr"); - - String sql = "select SITE from alfresco where SITE = '" + siteModel.getTitle() + "'"; - sqlRequest.setSql(sql); - sqlRequest.setAuthUser(managerUser); - - // Non admin user can NOT see Private Site created by other user - ResultSet rs = restClient.withSearchSqlViaJDBC().executeQueryViaJDBC(sqlRequest); - Assert.assertFalse(rs.next()); - } - - - - @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority=05) - public void testQueryErrorReturned() throws SQLException - { - String expectedError = "Column 'SITE1' not found"; - - String sql = "select SITE1 from alfresco"; - sqlRequest.setSql(sql); - sqlRequest.setAuthUser(userModel); - - // Appropriate error is retrieved when SQL is incorrect - ResultSet rs = restClient.withSearchSqlViaJDBC().executeQueryViaJDBC(sqlRequest); - - String error = sqlRequest.getErrorDetails(); - Assert.assertNotNull(error); - Assert.assertTrue(error.contains(expectedError), "Error shown: " + error + " Error expected: " + expectedError); - - // Record set is null - Assert.assertNull(rs); - } - - @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 06) - public void testQuerySelectStar() throws SQLException - { - // Select * query with limit clause - String sql = "select * from alfresco limit 5"; - sqlRequest.setSql(sql); - sqlRequest.setAuthUser(userModel); - - // Select * with limit clause works: No error is retrieved - ResultSet rs = restClient.withSearchSqlViaJDBC().executeQueryViaJDBC(sqlRequest); - Assert.assertNotNull(rs); - Assert.assertNull(sqlRequest.getErrorDetails()); - - while (rs.next()) - { - // Field values are retrieved - Assert.assertNotNull(rs.getString("PATH")); - Assert.assertNotNull(rs.getString("DBID")); - Assert.assertNotNull(rs.getString("cm_name")); - } - - // Select * query Without limit clause: No error is retrieved - sql = "select * from alfresco"; - sqlRequest.setSql(sql); - sqlRequest.setAuthUser(userModel); - - // No error is retrieved when SQL is incorrect - rs = restClient.withSearchSqlViaJDBC().executeQueryViaJDBC(sqlRequest); - Assert.assertNotNull(rs); - Assert.assertNull(sqlRequest.getErrorDetails()); - - while (rs.next()) - { - // Field values are retrieved - Assert.assertNotNull(rs.getString("PATH")); - Assert.assertNotNull(rs.getString("DBID")); - Assert.assertNotNull(rs.getString("cm_name")); - } - } - - @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 07) - public void testQuerySelectDistinct() throws SQLException - { - // Select distinct query with limit clause - String sql = "select distinct cm_name from alfresco limit 5"; - sqlRequest.setSql(sql); - sqlRequest.setAuthUser(adminUserModel); - - // Select distinct with limit clause works: No error is retrieved - ResultSet rs = restClient.withSearchSqlViaJDBC().executeQueryViaJDBC(sqlRequest); - Assert.assertNotNull(rs); - Assert.assertNull(sqlRequest.getErrorDetails()); - - while (rs.next()) - { - // Field values are retrieved - Assert.assertNotNull(rs.getString("cm_name")); - } - } -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/tags/GetTagTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagTests.java deleted file mode 100644 index 99bb12b8a..000000000 --- a/e2e-test/java/org/alfresco/rest/tags/GetTagTests.java +++ /dev/null @@ -1,139 +0,0 @@ -package org.alfresco.rest.tags; - -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestTagModel; -import org.alfresco.utility.constants.UserRole; -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; - -@Test(groups = {TestGroup.REQUIRE_SOLR}) -public class GetTagTests extends TagsDataPrep -{ - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - init(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify admin user gets tag using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void adminIsAbleToGetTag() throws Exception - { - RestTagModel returnedTag = restClient.authenticateUser(adminUserModel).withCoreAPI().getTag(documentTag); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedTag.assertThat().field("tag").is(documentTagValue.toLowerCase()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role gets tag using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) - public void userWithManagerRoleIsAbleToGetTag() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - - RestTagModel returnedTag = restClient.withCoreAPI().getTag(documentTag); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedTag.assertThat().field("tag").is(documentTagValue.toLowerCase()) - .assertThat().field("id").is(documentTag.getId()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify user with Collaborator role gets tag using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void userWithCollaboratorRoleIsAbleToGetTag() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - RestTagModel returnedTag = restClient.withCoreAPI().getTag(documentTag); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedTag.assertThat().field("tag").is(documentTagValue.toLowerCase()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify user with Contributor role gets tag using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void userWithContributorRoleIsAbleToGetTag() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - RestTagModel returnedTag = restClient.withCoreAPI().getTag(documentTag); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedTag.assertThat().field("tag").is(documentTagValue.toLowerCase()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify user with Consumer role gets tag using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void userWithConsumerRoleIsAbleToGetTag() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - RestTagModel returnedTag = restClient.withCoreAPI().getTag(documentTag); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedTag.assertThat().field("tag").is(documentTagValue.toLowerCase()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Manager user gets status code 401 if authentication call fails") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) -// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void managerIsNotAbleToGetTagIfAuthenticationFails() throws Exception - { - UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); - String managerPassword = managerUser.getPassword(); - dataUser.addUserToSite(managerUser, siteModel, UserRole.SiteManager); - managerUser.setPassword("wrongPassword"); - restClient.authenticateUser(managerUser).withCoreAPI().getTag(documentTag); - managerUser.setPassword(managerPassword); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that if tag id is invalid status code returned is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void invalidTagIdTest() throws Exception - { - String tagId = documentTag.getId(); - documentTag.setId("random_tag_value"); - restClient.authenticateUser(adminUserModel).withCoreAPI().getTag(documentTag); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "random_tag_value")); - documentTag.setId(tagId); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, - executionType = ExecutionType.REGRESSION, description = "Check that properties filter is applied when getting tag using Manager user.") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void checkPropertiesFilterIsApplied() throws Exception - { - RestTagModel returnedTag = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withParams("properties=id,tag").withCoreAPI().getTag(documentTag); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedTag.assertThat().field("id").is(documentTag.getId()) - .assertThat().field("tag").is(documentTag.getTag().toLowerCase()) - .assertThat().fieldsCount().is(2); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, - executionType = ExecutionType.REGRESSION, description = "Check that Manager user can get tag of a folder.") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void getTagOfAFolder() throws Exception - { - RestTagModel returnedTag = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().getTag(folderTag); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedTag.assertThat().field("tag").is(folderTagValue.toLowerCase()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, - executionType = ExecutionType.REGRESSION, description = "Check default error model schema. Use invalid skipCount parameter.") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void checkDefaultErrorModelSchema() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withParams("skipCount=abc").withCoreAPI().getTag(documentTag); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(String.format(RestErrorModel.INVALID_SKIPCOUNT, "abc")) - .containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "abc")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/tags/GetTagsTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagsTests.java deleted file mode 100644 index 5c3b49ff9..000000000 --- a/e2e-test/java/org/alfresco/rest/tags/GetTagsTests.java +++ /dev/null @@ -1,230 +0,0 @@ -package org.alfresco.rest.tags; - -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestTagModel; -import org.alfresco.rest.model.RestTagModelsCollection; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.RandomData; -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.BeforeClass; -import org.testng.annotations.Test; - -@Test(groups = {TestGroup.REQUIRE_SOLR}) -public class GetTagsTests extends TagsDataPrep -{ - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - init(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role gets tags using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) - public void getTagsWithManagerRole() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat().entriesListIsNotEmpty() - .and().entriesListContains("tag", documentTagValue.toLowerCase()) - .and().entriesListContains("tag", documentTagValue2.toLowerCase()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify user with Collaborator role gets tags using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void getTagsWithCollaboratorRole() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat().entriesListIsNotEmpty() - .and().entriesListContains("tag", documentTagValue.toLowerCase()) - .and().entriesListContains("tag", documentTagValue2.toLowerCase()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify user with Contributor role gets tags using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void getTagsWithContributorRole() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat().entriesListIsNotEmpty() - .and().entriesListContains("tag", documentTagValue.toLowerCase()) - .and().entriesListContains("tag", documentTagValue2.toLowerCase()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify user with Consumer role gets tags using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void getTagsWithConsumerRole() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat().entriesListIsNotEmpty() - .and().entriesListContains("tag", documentTagValue.toLowerCase()) - .and().entriesListContains("tag", documentTagValue2.toLowerCase()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Failed authentication get tags call returns status code 401 with Manager role") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) -// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void failedAuthenticationReturnsUnauthorizedStatus() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - userModel = dataUser.createRandomTestUser(); - userModel.setPassword("user wrong password"); - dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); - restClient.authenticateUser(userModel); - restClient.withCoreAPI().getTags(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that if maxItems is invalid status code returned is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION}) - public void maxItemsInvalidValueTest() throws Exception - { - restClient.authenticateUser(adminUserModel).withParams("maxItems=abc").withCoreAPI().getTags(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "abc")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that if skipCount is invalid status code returned is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION}) - public void skipCountInvalidValueTest() throws Exception - { - restClient.authenticateUser(adminUserModel).withParams("skipCount=abc").withCoreAPI().getTags(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "abc")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that file tag is retrieved") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION}) - public void fileTagIsRetrieved() throws Exception - { - restClient.authenticateUser(adminUserModel); - returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat().entriesListIsNotEmpty() - .and().entriesListContains("tag", documentTagValue.toLowerCase()) - .and().entriesListContains("tag", documentTagValue2.toLowerCase()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that folder tag is retrieved") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION}) - public void folderTagIsRetrieved() throws Exception - { - restClient.authenticateUser(adminUserModel); - returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat().entriesListIsNotEmpty() - .and().entriesListContains("tag", folderTagValue.toLowerCase()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify site Manager is able to get tags using properties parameter." - + "Check that properties filter is applied.") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void siteManagerIsAbleToRetrieveTagsWithPropertiesParameter() throws Exception - { - returnedCollection = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withParams("maxItems=5000&properties=tag").withCoreAPI().getTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat().entriesListIsNotEmpty() - .and().entriesListContains("tag", documentTagValue.toLowerCase()) - .and().entriesListContains("tag", documentTagValue2.toLowerCase()) - .and().entriesListDoesNotContain("id"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "With admin get tags and use skipCount parameter. Check pagination") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void useSkipCountCheckPagination() throws Exception - { - returnedCollection = restClient.authenticateUser(adminUserModel).withCoreAPI().getTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - RestTagModel firstTag = returnedCollection.getEntries().get(0).onModel(); - RestTagModel secondTag = returnedCollection.getEntries().get(1).onModel(); - RestTagModelsCollection tagsWithSkipCount = restClient.withParams("skipCount=2").withCoreAPI().getTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - tagsWithSkipCount.assertThat().entriesListDoesNotContain("tag", firstTag.getTag()) - .assertThat().entriesListDoesNotContain("tag", secondTag.getTag()); - tagsWithSkipCount.assertThat().paginationField("skipCount").is("2"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "With admin get tags and use maxItems parameter. Check pagination") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void useMaxItemsParameterCheckPagination() throws Exception - { - returnedCollection = restClient.authenticateUser(adminUserModel).withCoreAPI().getTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - RestTagModel firstTag = returnedCollection.getEntries().get(0).onModel(); - RestTagModel secondTag = returnedCollection.getEntries().get(1).onModel(); - RestTagModelsCollection tagsWithMaxItems = restClient.withParams("maxItems=2").withCoreAPI().getTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - tagsWithMaxItems.assertThat().entriesListContains("tag", firstTag.getTag()) - .assertThat().entriesListContains("tag", secondTag.getTag()) - .assertThat().entriesListCountIs(2); - tagsWithMaxItems.assertThat().paginationField("maxItems").is("2"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "With manager get tags and use high skipCount parameter. Check pagination") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void useHighSkipCountCheckPagination() throws Exception - { - returnedCollection = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withParams("skipCount=20000").withCoreAPI().getTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat().entriesListIsEmpty() - .getPagination().assertThat().field("maxItems").is(100) - .and().field("hasMoreItems").is("false") - .and().field("count").is("0") - .and().field("skipCount").is(20000) - .and().field("totalItems").isNull(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "With Collaborator user get tags and use maxItems with value zero. Check default error model schema") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void useMaxItemsWithValueZeroCheckDefaultErrorModelSchema() throws Exception - { - returnedCollection = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withParams("maxItems=0").withCoreAPI().getTags(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) - .containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "With Manager user delete tag. Check it is not retrieved anymore.") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void checkThatDeletedTagIsNotRetrievedAnymore() throws Exception - { - String removedTag = RandomData.getRandomName("tag3"); - - RestTagModel deletedTag = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(document).addTag(removedTag); - - restClient.withCoreAPI().usingResource(document).deleteTag(deletedTag); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); - returnedCollection.assertThat().entriesListIsNotEmpty() - .and().entriesListDoesNotContain("tag", removedTag.toLowerCase()); - } -} diff --git a/e2e-test/java/org/alfresco/rest/tags/UpdateTagTests.java b/e2e-test/java/org/alfresco/rest/tags/UpdateTagTests.java deleted file mode 100644 index 21f506483..000000000 --- a/e2e-test/java/org/alfresco/rest/tags/UpdateTagTests.java +++ /dev/null @@ -1,269 +0,0 @@ -package org.alfresco.rest.tags; - -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestTagModel; -import org.alfresco.utility.Utility; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.apache.commons.lang3.RandomStringUtils; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -/** - * Created by Claudia Agache on 10/4/2016. - */ -@Test(groups = {TestGroup.REQUIRE_SOLR}) -public class UpdateTagTests extends TagsDataPrep -{ - private RestTagModel oldTag; - private String randomTag = ""; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - init(); - } - - @BeforeMethod(alwaysRun=true) - public void addTagToDocument() throws Exception - { - restClient.authenticateUser(adminUserModel); - oldTag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("old")); - randomTag = RandomData.getRandomName("tag"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Admin user updates tags and status code is 200") - @Bug(id="REPO-1828") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) - public void adminIsAbleToUpdateTags() throws Exception - { - restClient.authenticateUser(adminUserModel); - returnedModel = restClient.withCoreAPI().usingTag(oldTag).update(randomTag); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedModel.assertThat().field("tag").is(randomTag); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify Manager user can't update tags with Rest API and status code is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void managerIsNotAbleToUpdateTag() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingTag(oldTag).update(randomTag); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, - executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user can't update tags with Rest API and status code is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void collaboratorIsNotAbleToUpdateTagCheckDefaultErrorModelSchema() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.withCoreAPI().usingTag(oldTag).update(randomTag); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, - executionType = ExecutionType.REGRESSION, description = "Verify Contributor user can't update tags with Rest API and status code is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void contributorIsNotAbleToUpdateTag() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - restClient.withCoreAPI().usingTag(oldTag).update(randomTag); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, - executionType = ExecutionType.SANITY, description = "Verify Consumer user can't update tags with Rest API and status code is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void consumerIsNotAbleToUpdateTag() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.withCoreAPI().usingTag(oldTag).update(randomTag); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, - executionType = ExecutionType.SANITY, description = "Verify user gets status code 401 if authentication call fails") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) -// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void userIsNotAbleToUpdateTagIfAuthenticationFails() throws Exception - { - UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); - String managerPassword = siteManager.getPassword(); - siteManager.setPassword("wrongPassword"); - restClient.authenticateUser(siteManager); - restClient.withCoreAPI().usingTag(oldTag).update(randomTag); - siteManager.setPassword(managerPassword); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify admin is not able to update tag with invalid id") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void adminIsNotAbleToUpdateTagWithInvalidId() throws Exception - { - String invalidTagId = "invalid-id"; - RestTagModel tag = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); - tag.setId(invalidTagId); - restClient.withCoreAPI().usingTag(tag).update(RandomData.getRandomName("tag")); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, invalidTagId)); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify admin is not able to update tag with empty id") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void adminIsNotAbleToUpdateTagWithEmptyId() throws Exception - { - RestTagModel tag = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); - tag.setId(""); - restClient.withCoreAPI().usingTag(tag).update(RandomData.getRandomName("tag")); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) - .assertLastError().containsSummary(RestErrorModel.PUT_EMPTY_ARGUMENT); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify admin is not able to update tag with invalid body") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void adminIsNotAbleToUpdateTagWithEmptyBody() throws Exception - { - RestTagModel tag = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); - restClient.withCoreAPI().usingTag(tag).update(""); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(RestErrorModel.EMPTY_TAG); - } - - @Bug(id="ACE-5629") - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify admin is not able to update tag with invalid body containing '|' symbol") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void adminIsNotAbleToUpdateTagWithInvalidBodyScenario1() throws Exception - { - String invalidTagBody = "|.\"/<>*"; - RestTagModel tag = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); - Utility.waitToLoopTime(20); - restClient.withCoreAPI().usingTag(tag).update(invalidTagBody); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_TAG, invalidTagBody)); - } - - @Bug(id="ACE-5629") - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify admin is not able to update tag with invalid body without '|' symbol") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void adminIsNotAbleToUpdateTagWithInvalidBodyScenario2() throws Exception - { - String invalidTagBody = ".\"/<>*"; - RestTagModel tag = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); - Utility.waitToLoopTime(20); - restClient.withCoreAPI().usingTag(tag).update(invalidTagBody); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_TAG, invalidTagBody)); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify admin user can provide large string for new tag value.") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - @Bug(id="REPO-1828") - public void adminIsAbleToUpdateTagsProvideLargeStringTag() throws Exception - { - String largeStringTag = RandomStringUtils.randomAlphanumeric(10000); - - restClient.authenticateUser(adminUserModel); - returnedModel = restClient.withCoreAPI().usingTag(oldTag).update(largeStringTag); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedModel.assertThat().field("tag").is(largeStringTag); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify admin user can provide short string for new tag value.") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - @Bug(id="REPO-1828") - public void adminIsAbleToUpdateTagsProvideShortStringTag() throws Exception - { - String shortStringTag = RandomStringUtils.randomAlphanumeric(2); - - restClient.authenticateUser(adminUserModel); - returnedModel = restClient.withCoreAPI().usingTag(oldTag).update(shortStringTag); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedModel.assertThat().field("tag").is(shortStringTag); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify admin user can provide string with special chars for new tag value.") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - @Bug(id="REPO-1828") - public void adminIsAbleToUpdateTagsProvideSpecialCharsStringTag() throws Exception - { - String specialCharsString = "!@#$%^&*()'\".,<>-_+=|\\"; - - restClient.authenticateUser(adminUserModel); - returnedModel = restClient.withCoreAPI().usingTag(oldTag).update(specialCharsString); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedModel.assertThat().field("tag").is(specialCharsString); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify Admin user can provide existing tag for new tag value.") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - @Bug(id="REPO-1828") - public void adminIsAbleToUpdateTagsProvideExistingTag() throws Exception - { - String existingTag = "oldTag"; - RestTagModel oldExistingTag = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(document).addTag(existingTag); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(adminUserModel); - returnedModel = restClient.withCoreAPI().usingTag(oldExistingTag).update(existingTag); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedModel.assertThat().field("tag").is(existingTag); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify Admin user can delete a tag, add tag and update it.") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - @Bug(id="REPO-1828") - public void adminDeleteTagAddTagUpdateTag() throws Exception - { - restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingResource(document).deleteTag(oldTag); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - String newTag = "addTag"; - RestTagModel newTagModel = restClient.withCoreAPI().usingResource(document).addTag(newTag); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedModel = restClient.withCoreAPI().usingTag(newTagModel).update(newTag); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedModel.assertThat().field("tag").is(newTag); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify Admin user can update a tag, delete tag and add it.") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - @Bug(id="REPO-1828") - public void adminUpdateTagDeleteTagAddTag() throws Exception - { - String newTag = "addTag"; - - returnedModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingTag(oldTag).update(newTag); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedModel.assertThat().field("tag").is(newTag); - - restClient.withCoreAPI().usingResource(document).deleteTag(returnedModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingResource(document).addTag(newTag); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - } -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagTests.java b/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagTests.java deleted file mode 100644 index c0606d3dc..000000000 --- a/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagTests.java +++ /dev/null @@ -1,337 +0,0 @@ -package org.alfresco.rest.tags.nodes; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.model.RestCommentModel; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestTagModel; -import org.alfresco.rest.model.RestTagModelsCollection; -import org.alfresco.rest.tags.TagsDataPrep; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.apache.commons.lang3.RandomStringUtils; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -/** - * Created by Claudia Agache on 10/3/2016. - */ -@Test(groups = {TestGroup.REQUIRE_SOLR}) -public class AddTagTests extends TagsDataPrep -{ - private String tagValue; - private RestTagModel returnedModel; - private RestCommentModel returnedModelComment; - private RestTagModelsCollection returnedModelTags; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - init(); - } - - @BeforeMethod(alwaysRun = true) - public void generateRandomTag() - { - tagValue = RandomData.getRandomName("tag"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify admin user adds tags with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void adminIsAbleToAddTag() throws Exception - { - restClient.authenticateUser(adminUserModel); - returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedModel.assertThat().field("tag").is(tagValue) - .and().field("id").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, - description = "Verify Manager user adds tags with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) - public void managerIsAbleToTagAFile() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedModel.assertThat().field("tag").is(tagValue) - .and().field("id").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify Collaborator user adds tags with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void collaboratorIsAbleToTagAFile() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedModel.assertThat().field("tag").is(tagValue) - .and().field("id").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify Contributor user doesn't have permission to add tags with Rest API and status code is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void contributorIsNotAbleToAddTagToAnotherContent() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - restClient.withCoreAPI().usingResource(document).addTag(tagValue); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify Contributor user adds tags to his content with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void contributorIsAbleToAddTagToHisContent() throws Exception - { - userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); - restClient.authenticateUser(userModel); - FileModel contributorDoc = dataContent.usingSite(siteModel).usingUser(userModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - returnedModel = restClient.withCoreAPI().usingResource(contributorDoc).addTag(tagValue); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedModel.assertThat().field("id").isNotEmpty() - .and().field("tag").is(tagValue); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify Consumer user doesn't have permission to add tags with Rest API and status code is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void consumerIsNotAbleToTagAFile() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.withCoreAPI().usingResource(document).addTag(tagValue); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, - description = "Verify user gets status code 401 if authentication call fails") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) -// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void userIsNotAbleToAddTagIfAuthenticationFails() throws Exception - { - UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); - String managerPassword = siteManager.getPassword(); - siteManager.setPassword("wrongPassword"); - restClient.authenticateUser(siteManager); - restClient.withCoreAPI().usingResource(document).addTag("tagUnauthorized"); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - siteManager.setPassword(managerPassword); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that adding empty tag returns status code 400") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void emptyTagTest() throws Exception - { - restClient.authenticateUser(adminUserModel); - returnedModel = restClient.withCoreAPI().usingResource(document).addTag(""); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.NULL_ARGUMENT, "tag")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that adding tag with user that has no permissions returns status code 403") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void addTagWithUserThatDoesNotHavePermissions() throws Exception - { - restClient.authenticateUser(dataUser.createRandomTestUser()); - returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that adding tag to a node that does not exist returns status code 404") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void addTagToInexistentNode() throws Exception - { - String oldNodeRef = document.getNodeRef(); - String nodeRef = RandomStringUtils.randomAlphanumeric(10); - document.setNodeRef(nodeRef); - - restClient.authenticateUser(adminUserModel); - returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, nodeRef)); - document.setNodeRef(oldNodeRef); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, - description = "Verify that manager is able to tag a folder") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) - public void managerIsAbleToTagAFolder() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - returnedModel = restClient.withCoreAPI().usingResource(folderModel).addTag(tagValue); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedModel.assertThat().field("tag").is(tagValue).and().field("id").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that tagged file can be tagged again") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void addTagToATaggedFile() throws Exception - { - restClient.authenticateUser(adminUserModel); - - returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedModel.assertThat().field("tag").is(tagValue).and().field("id").isNotEmpty(); - - returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedModel.assertThat().field("tag").is(tagValue).and().field("id").isNotEmpty(); - - returnedModel = restClient.withCoreAPI().usingResource(document).addTag("random_tag_value"); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedModel.assertThat().field("tag").is("random_tag_value").and().field("id").isNotEmpty(); - - restClient.withCoreAPI().usingResource(document).getNodeTags().assertThat() - .entriesListContains("tag", tagValue.toLowerCase()) - .and().entriesListContains("tag", "random_tag_value"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that user cannot add invalid tag") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void addInvalidTag() throws Exception - { - restClient.authenticateUser(adminUserModel); - returnedModel = restClient.withCoreAPI().usingResource(document).addTag("-1~!|@#$%^&*()_="); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_TAG, "|")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that contributor is able to tag a folder created by self") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void contributorIsAbleToTagAFolderCreatedBySelf() throws Exception - { - FolderModel folderModel = dataContent.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingSite(siteModel).createFolder(); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - returnedModel = restClient.withCoreAPI().usingResource(folderModel).addTag(tagValue); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedModel.assertThat().field("tag").is(tagValue).and().field("id").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that collaborator is able to tag a folder") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void collaboratorIsAbleToTagAFolder() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - returnedModel = restClient.withCoreAPI().usingResource(folderModel).addTag(tagValue); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedModel.assertThat().field("tag").is(tagValue).and().field("id").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that consumer is not able to tag a folder. Check default error model schema.") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void consumerIsNotAbleToTagAFolder() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .withCoreAPI().usingResource(folderModel).addTag(tagValue); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that tagged folder can be tagged again") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void addTagToATaggedFolder() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - - returnedModel = restClient.withCoreAPI().usingResource(folderModel).addTag(tagValue); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedModel.assertThat().field("tag").is(tagValue).and().field("id").isNotEmpty(); - - returnedModel = restClient.withCoreAPI().usingResource(folderModel).addTag("random_tag_value"); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedModel.assertThat().field("tag").is("random_tag_value").and().field("id").isNotEmpty(); - - restClient.withCoreAPI().usingResource(folderModel).getNodeTags().assertThat() - .entriesListContains("tag", tagValue.toLowerCase()) - .and().entriesListContains("tag", "random_tag_value") - .and().entriesListCountIs(2); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Using collaborator provide more than one tag element") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void provideMoreThanOneTagElement() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); - String tagValue1 = RandomData.getRandomName("tag1"); - String tagValue2 = RandomData.getRandomName("tag2"); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - - returnedModelTags = restClient.withCoreAPI().usingResource(folderModel).addTags(tagValue, tagValue1, tagValue2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedModelTags.assertThat().entriesListContains("tag", tagValue) - .and().entriesListContains("tag", tagValue1) - .and().entriesListContains("tag", tagValue2) - .and().entriesListCountIs(3); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that manager cannot add tag with special characters.") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void addTagWithSpecialCharacters() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); - String specialCharsTag = "!@#$%^&*()'\".,<>-_+=|\\"; - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(folderModel).addTag(specialCharsTag); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_TAG, "|")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that you cannot tag a comment and it returns status code 405") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void addTagToAComment() throws Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - String comment = "comment for a tag"; - - restClient.authenticateUser(adminUserModel); - returnedModelComment = restClient.withCoreAPI().usingResource(file).addComment(comment); - file.setNodeRef(returnedModelComment.getId()); - restClient.withCoreAPI().usingResource(file).addTag(tagValue); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.CANNOT_TAG); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that you cannot tag a tag and it returns status code 405") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void addTagToATag() throws Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(adminUserModel); - returnedModel = restClient.withCoreAPI().usingResource(file).addTag(tagValue); - file.setNodeRef(returnedModel.getId()); - restClient.withCoreAPI().usingResource(file).addTag(tagValue); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.CANNOT_TAG); - } -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagsTests.java b/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagsTests.java deleted file mode 100644 index 25063550e..000000000 --- a/e2e-test/java/org/alfresco/rest/tags/nodes/AddTagsTests.java +++ /dev/null @@ -1,150 +0,0 @@ -package org.alfresco.rest.tags.nodes; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestTagModel; -import org.alfresco.rest.model.RestTagModelsCollection; -import org.alfresco.rest.tags.TagsDataPrep; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.RandomData; -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.HttpStatus; -import org.testng.Assert; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -/** - * Created by Claudia Agache on 10/7/2016. - */ -@Test(groups = {TestGroup.REQUIRE_SOLR}) -public class AddTagsTests extends TagsDataPrep -{ - private FileModel contributorDoc; - private String tag1, tag2; - private RestTagModelsCollection returnedCollection; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - init(); - } - - @BeforeMethod(alwaysRun = true) - public void generateRandomTagsList() - { - tag1 = RandomData.getRandomName("tag"); - tag2 = RandomData.getRandomName("tag"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify admin user adds multiple tags with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void adminIsAbleToAddTags() throws Exception - { - restClient.authenticateUser(adminUserModel); - returnedCollection = restClient.withCoreAPI().usingResource(document).addTags(tag1, tag2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedCollection.assertThat().entriesListContains("tag", tag1) - .and().entriesListContains("tag", tag2); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, - description = "Verify Manager user adds multiple tags with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) - public void managerIsAbleToAddTags() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - returnedCollection = restClient.withCoreAPI().usingResource(document).addTags(tag1, tag2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedCollection.assertThat().entriesListContains("tag", tag1) - .and().entriesListContains("tag", tag2); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, - executionType = ExecutionType.SANITY, description = "Verify Collaborator user adds multiple tags with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void collaboratorIsAbleToAddTags() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - returnedCollection = restClient.withCoreAPI().usingResource(document).addTags(tag1, tag2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedCollection.assertThat().entriesListContains("tag", tag1) - .and().entriesListContains("tag", tag2); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify Contributor user doesn't have permission to add multiple tags with Rest API and status code is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void contributorIsNotAbleToAddTagsToAnotherContent() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - restClient.withCoreAPI().usingResource(document).addTags(tag1, tag2); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify Contributor user adds multiple tags to his content with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void contributorIsAbleToAddTagsToHisContent() throws Exception - { - userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); - restClient.authenticateUser(userModel); - contributorDoc = dataContent.usingSite(siteModel).usingUser(userModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - returnedCollection = restClient.withCoreAPI().usingResource(contributorDoc).addTags(tag1, tag2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedCollection.assertThat().entriesListContains("tag", tag1) - .and().entriesListContains("tag", tag2); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify Consumer user doesn't have permission to add multiple tags with Rest API and status code is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void consumerIsNotAbleToAddTags() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingResource(document).addTags(tag1, tag2); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.TAGS }, executionType = ExecutionType.SANITY, - description = "Verify user gets status code 401 if authentication call fails") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) -// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void userIsNotAbleToAddTagsIfAuthenticationFails() throws Exception - { - UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); - String managerPassword = siteManager.getPassword(); - siteManager.setPassword("wrongPassword"); - restClient.authenticateUser(siteManager).withCoreAPI().usingResource(document).addTags(tag1, tag2); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - siteManager.setPassword(managerPassword); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify include count parameter") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void getTagsUsingCountParam() throws Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - String tagName = RandomData.getRandomName("tag"); - returnedModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addTag(RandomData.getRandomName("tag")); - RestTagModelsCollection tagsWithIncludeParamCount = restClient.withParams("include=count").withCoreAPI().getTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); - for (RestTagModel tagModel : tagsWithIncludeParamCount.getEntries()) - { - if (tagModel != null && tagModel.getTag() != null) - { - if (tagModel.getTag().equals(tagName)) - { - Assert.assertEquals(tagModel.getCount().intValue(), 1); - } - } - } - - } -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/tags/nodes/DeleteTagTests.java b/e2e-test/java/org/alfresco/rest/tags/nodes/DeleteTagTests.java deleted file mode 100644 index ec77b8fc7..000000000 --- a/e2e-test/java/org/alfresco/rest/tags/nodes/DeleteTagTests.java +++ /dev/null @@ -1,287 +0,0 @@ -package org.alfresco.rest.tags.nodes; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestTagModel; -import org.alfresco.rest.tags.TagsDataPrep; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.apache.commons.lang3.RandomStringUtils; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Created by Claudia Agache on 10/4/2016. - */ -@Test(groups = {TestGroup.REQUIRE_SOLR}) -public class DeleteTagTests extends TagsDataPrep -{ - private RestTagModel tag; - private FileModel contributorDoc; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - init(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify Admin user deletes tags with Rest API and status code is 204") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void adminIsAbleToDeleteTags() throws Exception - { - restClient.authenticateUser(adminUserModel); - tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); - - restClient.withCoreAPI().usingResource(document).deleteTag(tag); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingResource(document).getNodeTags() - .assertThat().entriesListDoesNotContain("tag", tag.getTag()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, - description = "Verify Manager user deletes tags created by admin user with Rest API and status code is 204") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) - public void managerIsAbleToDeleteTags() throws Exception - { - restClient.authenticateUser(adminUserModel); - tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingResource(document).deleteTag(tag); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify Collaborator user deletes tags created by admin user with Rest API and status code is 204") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void collaboratorIsAbleToDeleteTags() throws Exception - { - restClient.authenticateUser(adminUserModel); - tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.withCoreAPI().usingResource(document).deleteTag(tag); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify Contributor user can't delete tags created by admin user with Rest API and status code is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void contributorIsNotAbleToDeleteTagsForAnotherUserContent() throws Exception - { - restClient.authenticateUser(adminUserModel); - tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - restClient.withCoreAPI().usingResource(document).deleteTag(tag); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify Contributor user deletes tags created by him with Rest API and status code is 204") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void contributorIsAbleToDeleteTagsForHisContent() throws Exception - { - userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); - restClient.authenticateUser(userModel); - contributorDoc = dataContent.usingSite(siteModel).usingUser(userModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);; - tag = restClient.withCoreAPI().usingResource(contributorDoc).addTag(RandomData.getRandomName("tag")); - - restClient.withCoreAPI().usingResource(document).deleteTag(tag); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify Consumer user can't delete tags created by admin user with Rest API and status code is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void consumerIsNotAbleToDeleteTags() throws Exception - { - restClient.authenticateUser(adminUserModel); - tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.withCoreAPI().usingResource(document).deleteTag(tag); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, - description = "Verify user gets status code 401 if authentication call fails") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) -// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void userIsNotAbleToDeleteTagIfAuthenticationFails() throws Exception - { - restClient.authenticateUser(adminUserModel); - tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); - - UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); - String managerPassword = siteManager.getPassword(); - siteManager.setPassword("wrongPassword"); - restClient.authenticateUser(siteManager); - restClient.withCoreAPI().usingResource(document).deleteTag(tag); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - siteManager.setPassword(managerPassword); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that if user has no permission to remove tag returned status code is 403. Check default error model schema") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void deleteTagWithUserWithoutPermissionCheckDefaultErrorModelSchema() throws Exception - { - restClient.authenticateUser(adminUserModel); - RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); - - restClient.authenticateUser(dataUser.createRandomTestUser()); - restClient.withCoreAPI().usingResource(document).deleteTag(tag); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that if node does not exist returned status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void deleteTagForANonexistentNode() throws Exception - { - restClient.authenticateUser(adminUserModel); - RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); - - FileModel document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - String nodeRef = RandomStringUtils.randomAlphanumeric(10); - document.setNodeRef(nodeRef); - restClient.withCoreAPI().usingResource(document).deleteTag(tag); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, nodeRef)); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that if tag does not exist returned status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void deleteTagThatDoesNotExist() throws Exception - { - restClient.authenticateUser(adminUserModel); - RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); - - tag.setId("abc"); - restClient.withCoreAPI().usingResource(document).deleteTag(tag); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "abc")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that if tag id is empty returned status code is 405") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void deleteTagWithEmptyId() throws Exception - { - restClient.authenticateUser(adminUserModel); - RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); - - tag.setId(""); - restClient.withCoreAPI().usingResource(document).deleteTag(tag); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.DELETE_EMPTY_ARGUMENT); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that folder tag can be deleted") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void deleteFolderTag() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder();; - restClient.authenticateUser(adminUserModel); - RestTagModel tag = restClient.withCoreAPI().usingResource(folderModel).addTag(RandomData.getRandomName("tag")); - restClient.withCoreAPI().usingResource(folderModel).deleteTag(tag); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingResource(folderModel).getNodeTags() - .assertThat().entriesListDoesNotContain("tag", tag.getTag()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, - executionType = ExecutionType.REGRESSION, description = "Verify Manager user can't delete deleted tag.") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - @Bug(id = "ACE-5455") - public void managerCannotDeleteDeletedTag() throws Exception - { - tag = restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(document).deleteTag(tag); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingResource(document).deleteTag(tag); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, - executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user can delete long tag.") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void userCollaboratorCanDeleteLongTag() throws Exception - { - String longTag = RandomStringUtils.randomAlphanumeric(800); - - tag = restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingResource(document).addTag(longTag); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingResource(document).deleteTag(tag); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, - executionType = ExecutionType.REGRESSION, description = "Verify Manager user can delete short tag.") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void managerCanDeleteShortTag() throws Exception - { - String shortTag = RandomStringUtils.randomAlphanumeric(10); - - tag = restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingResource(document).addTag(shortTag); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(document).deleteTag(tag); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, - executionType = ExecutionType.REGRESSION, description = "Verify Admin can delete tag then add it again.") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void adminRemovesTagAndAddsItAgain() throws Exception - { - String tagValue = RandomStringUtils.randomAlphanumeric(10); - - tag = restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingResource(document).addTag(tagValue); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(document).deleteTag(tag); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - tag = restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingResource(document).addTag(tagValue); - RestTagModel returnedTag = restClient.withCoreAPI().getTag(tag); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedTag.assertThat().field("tag").is(tagValue.toLowerCase()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, - executionType = ExecutionType.REGRESSION, description = "Verify Manager user can delete tag added by another user.") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void managerCanDeleteTagAddedByAnotherUser() throws Exception - { - tag = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingResource(document).addTag(RandomStringUtils.randomAlphanumeric(10)); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(document).deleteTag(tag); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/tags/nodes/GetNodeTagsTests.java b/e2e-test/java/org/alfresco/rest/tags/nodes/GetNodeTagsTests.java deleted file mode 100644 index f38e20d64..000000000 --- a/e2e-test/java/org/alfresco/rest/tags/nodes/GetNodeTagsTests.java +++ /dev/null @@ -1,319 +0,0 @@ -package org.alfresco.rest.tags.nodes; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.tags.TagsDataPrep; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.apache.commons.lang3.RandomStringUtils; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -@Test(groups = {TestGroup.REQUIRE_SOLR}) -public class GetNodeTagsTests extends TagsDataPrep -{ - private String tagValue; - private String tagValue2; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - init(); - tagValue = documentTagValue; - tagValue2 = documentTagValue2; - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, - executionType = ExecutionType.SANITY, description = "Verify site Manager is able to get node tags") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) - public void siteManagerIsAbleToRetrieveNodeTags() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - - returnedCollection = restClient.withCoreAPI().usingResource(document).getNodeTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat() - .entriesListContains("tag", tagValue.toLowerCase()) - .and().entriesListContains("tag", tagValue2.toLowerCase()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, - executionType = ExecutionType.REGRESSION, description = "Verify site Collaborator is able to get node tags") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void siteCollaboratorIsAbleToRetrieveNodeTags() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - - returnedCollection = restClient.withCoreAPI().usingResource(document).getNodeTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat() - .entriesListContains("tag", tagValue.toLowerCase()) - .and().entriesListContains("tag", tagValue2.toLowerCase()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, - executionType = ExecutionType.REGRESSION, description = "Verify site Contributor is able to get node tags") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void siteContributorIsAbleToRetrieveNodeTags() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - - returnedCollection = restClient.withCoreAPI().usingResource(document).getNodeTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat() - .entriesListContains("tag", tagValue.toLowerCase()) - .and().entriesListContains("tag", tagValue2.toLowerCase()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, - executionType = ExecutionType.REGRESSION, description = "Verify site Consumer is able to get node tags") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void siteConsumerIsAbleToRetrieveNodeTags() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - - returnedCollection = restClient.withCoreAPI().usingResource(document).getNodeTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat() - .entriesListContains("tag", tagValue.toLowerCase()) - .and().entriesListContains("tag", tagValue2.toLowerCase()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, - executionType = ExecutionType.REGRESSION, description = "Verify admin is able to get node tags") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void adminIsAbleToRetrieveNodeTags() throws Exception - { - restClient.authenticateUser(adminUserModel); - returnedCollection = restClient.withCoreAPI().usingResource(document).getNodeTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat() - .entriesListContains("tag", tagValue.toLowerCase()) - .and().entriesListContains("tag", tagValue2.toLowerCase()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, - executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to get node tags") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) -// @Bug(id = "MNT-16904", description = "fails only on environment with tenants") - public void unauthenticatedUserIsNotAbleToRetrieveNodeTags() throws Exception - { - restClient.authenticateUser(new UserModel("random user", "random password")); - restClient.withCoreAPI().usingResource(document).getNodeTags(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that using invalid value for skipCount parameter returns status code 400") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION}) - public void invalidSkipCountTest() throws Exception - { - restClient.withParams("skipCount=abc").withCoreAPI().usingResource(document).getNodeTags(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "abc")); - - restClient.withParams("skipCount=-1").withCoreAPI().usingResource(document).getNodeTags(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that using invalid value for maxItems parameter returns status code 400") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION}) - public void invalidMaxItemsTest() throws Exception - { - restClient.withParams("maxItems=abc").withCoreAPI().usingResource(document).getNodeTags(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "abc")); - - restClient.withParams("maxItems=-1").withCoreAPI().usingResource(document).getNodeTags(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that user without permissions returns status code 403") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION}) - public void userWithoutPermissionsTest() throws Exception - { - SiteModel moderatedSite = dataSite.usingUser(adminUserModel).createModeratedRandomSite(); - FileModel moderatedDocument = dataContent.usingSite(moderatedSite).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(dataUser.createRandomTestUser()).withCoreAPI().usingResource(moderatedDocument).getNodeTags(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that if node does not exist returns status code 403") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION}) - public void nonexistentNodeTest() throws Exception - { - FileModel badDocument = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - String nodeRef = RandomStringUtils.randomAlphanumeric(10); - badDocument.setNodeRef(nodeRef); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(badDocument).getNodeTags(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, nodeRef)); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that if node id is empty returns status code 403") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION}) - public void emptyNodeIdTest() throws Exception - { - FileModel badDocument = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - badDocument.setNodeRef(""); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(badDocument).getNodeTags(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify folder tags") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION}) - public void folderTagsTest() throws Exception - { - FolderModel folder = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); - - restClient.withCoreAPI().usingResource(folder).addTag(tagValue); - restClient.withCoreAPI().usingResource(folder).addTag(tagValue2); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(folder).getNodeTags() - .assertThat() - .entriesListContains("tag", tagValue.toLowerCase()) - .and().entriesListContains("tag", tagValue2.toLowerCase()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify site Manager is able to get node tags using properties parameter") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void siteManagerIsAbleToRetrieveNodeTagsWithPropertiesParameter() throws Exception - { - returnedCollection = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withParams("properties=tag").withCoreAPI().usingResource(document).getNodeTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat().entriesListContains("tag", tagValue.toLowerCase()) - .and().entriesListContains("tag", tagValue2.toLowerCase()) - .and().entriesListDoesNotContain("id"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that Collaborator user is not able to get node tags using site id instead of node id") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void collaboratorGetNodeTagsUseSiteIdInsteadOfNodeId() throws Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - - file.setNodeRef(siteModel.getId()); - returnedCollection = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(file).getNodeTags(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, file.getNodeRef())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "With admin get node tags and use skipCount parameter. Check pagination and maxItems") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void useSkipCountCheckPaginationAndMaxItems() throws Exception - { - returnedCollection = restClient.authenticateUser(adminUserModel) - .withParams("skipCount=1").withCoreAPI().usingResource(document).getNodeTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.getPagination().assertThat().field("maxItems").is(100) - .and().field("hasMoreItems").is("false") - .and().field("count").isGreaterThan(1); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "With admin get node tags and use maxItems parameter. Check pagination") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void useMaxItemsParameterCheckPagination() throws Exception - { - returnedCollection = restClient.authenticateUser(adminUserModel) - .withParams("maxItems=1").withCoreAPI().usingResource(document).getNodeTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.getPagination().assertThat().field("maxItems").is(1) - .and().field("hasMoreItems").is("true") - .and().field("count").is("1") - .and().field("skipCount").is("0"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Using manager user get only one tag.") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void usingManagerGetOnlyOneTag() throws Exception - { - FileModel file = dataContent.usingAdmin().usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addTag(tagValue); - - returnedCollection = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(file).getNodeTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.getPagination().assertThat().field("maxItems").is(100) - .and().field("hasMoreItems").is("false") - .and().field("totalItems").is("1") - .and().field("count").is("1") - .and().field("skipCount").is("0"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Using admin get last 2 tags and skip first 2 tags") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void adminUserGetLast2TagsAndSkipFirst2Tags() throws Exception - { - String firstTag = "1st tag"; - String secondTag = "2nd tag"; - String thirdTag = "3rd tag"; - String fourthTag = "4th tag"; - FileModel file = dataContent.usingAdmin().usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addTag(firstTag); - restClient.withCoreAPI().usingResource(file).addTag(secondTag); - restClient.withCoreAPI().usingResource(file).addTag(thirdTag); - restClient.withCoreAPI().usingResource(file).addTag(fourthTag); - - returnedCollection = restClient.withParams("skipCount=2").withCoreAPI().usingResource(file).getNodeTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - returnedCollection.assertThat().entriesListContains("tag", thirdTag.toLowerCase()) - .and().entriesListContains("tag", fourthTag.toLowerCase()); - returnedCollection.getPagination().assertThat().field("maxItems").is(100) - .and().field("hasMoreItems").is("false") - .and().field("totalItems").is("4") - .and().field("count").is("2") - .and().field("skipCount").is("2"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "With admin get node tags and use maxItems=0.") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void getTagsWithZeroMaxItems() throws Exception - { - returnedCollection = restClient.authenticateUser(adminUserModel) - .withParams("maxItems=0").withCoreAPI().usingResource(document).getNodeTags(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that using high skipCount parameter returns status code 200.") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void getTagsWithHighSkipCount() throws Exception - { - returnedCollection = restClient.authenticateUser(adminUserModel).withParams("skipCount=10000") - .withCoreAPI().usingResource(document).getNodeTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.getPagination().assertThat().field("maxItems").is(100) - .and().field("hasMoreItems").is("false") - .and().field("count").is("0") - .and().field("skipCount").is("10000"); - returnedCollection.assertThat().entriesListCountIs(0); - } -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/FunctionalCasesTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/FunctionalCasesTests.java index ae2d5425b..a23b246e6 100644 --- a/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/FunctionalCasesTests.java @@ -1,8 +1,9 @@ -package org.alfresco.rest; +package org.alfresco.service.search.rest; import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.SiteService.Visibility; +import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestActivityModelsCollection; import org.alfresco.rest.model.RestCommentModel; import org.alfresco.rest.model.RestCommentModelsCollection; diff --git a/e2e-test/java/org/alfresco/rest/NetworkDataPrep.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/NetworkDataPrep.java similarity index 95% rename from e2e-test/java/org/alfresco/rest/NetworkDataPrep.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/NetworkDataPrep.java index dfee1c0d5..8d6d5b422 100644 --- a/e2e-test/java/org/alfresco/rest/NetworkDataPrep.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/NetworkDataPrep.java @@ -1,5 +1,6 @@ -package org.alfresco.rest; +package org.alfresco.service.search.rest; +import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestNetworkModel; import org.alfresco.utility.model.UserModel; diff --git a/e2e-test/java/org/alfresco/rest/RestTest.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/RestTest.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/RestTest.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/RestTest.java index 1c6953576..5f042d387 100644 --- a/e2e-test/java/org/alfresco/rest/RestTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/RestTest.java @@ -1,4 +1,4 @@ -package org.alfresco.rest; +package org.alfresco.service.search.rest; import java.lang.reflect.Method; diff --git a/e2e-test/java/org/alfresco/rest/actions/ActionsTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/actions/ActionsTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/actions/ActionsTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/actions/ActionsTests.java index df822111d..3340ee1ff 100644 --- a/e2e-test/java/org/alfresco/rest/actions/ActionsTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/actions/ActionsTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.actions; +package org.alfresco.service.search.rest.actions; import static org.testng.Assert.assertFalse; diff --git a/e2e-test/java/org/alfresco/rest/aos/AosApiTest.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/aos/AosApiTest.java similarity index 93% rename from e2e-test/java/org/alfresco/rest/aos/AosApiTest.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/aos/AosApiTest.java index 6223db2f7..efe1da439 100644 --- a/e2e-test/java/org/alfresco/rest/aos/AosApiTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/aos/AosApiTest.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.aos; +package org.alfresco.service.search.rest.aos; import org.alfresco.rest.RestTest; import org.alfresco.rest.core.RestRequest; diff --git a/e2e-test/java/org/alfresco/rest/audit/AuditTest.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/audit/AuditTest.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/audit/AuditTest.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/audit/AuditTest.java index 92ac3afc9..22fe23df1 100644 --- a/e2e-test/java/org/alfresco/rest/audit/AuditTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/audit/AuditTest.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.audit; +package org.alfresco.service.search.rest.audit; import static org.hamcrest.Matchers.is; diff --git a/e2e-test/java/org/alfresco/rest/audit/DeleteAuditTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/audit/DeleteAuditTests.java similarity index 97% rename from e2e-test/java/org/alfresco/rest/audit/DeleteAuditTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/audit/DeleteAuditTests.java index f6f0065b2..603bcccf6 100644 --- a/e2e-test/java/org/alfresco/rest/audit/DeleteAuditTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/audit/DeleteAuditTests.java @@ -1,7 +1,8 @@ -package org.alfresco.rest.audit; +package org.alfresco.service.search.rest.audit; import static org.testng.Assert.assertEquals; +import org.alfresco.rest.audit.AuditTest; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; diff --git a/e2e-test/java/org/alfresco/rest/audit/GetAuditTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/audit/GetAuditTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/audit/GetAuditTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/audit/GetAuditTests.java index 39c3afb2e..e565d8d68 100644 --- a/e2e-test/java/org/alfresco/rest/audit/GetAuditTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/audit/GetAuditTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.audit; +package org.alfresco.service.search.rest.audit; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; @@ -6,6 +6,7 @@ import static org.testng.Assert.assertTrue; import java.util.ArrayList; +import org.alfresco.rest.audit.AuditTest; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; diff --git a/e2e-test/java/org/alfresco/rest/audit/PutAuditTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/audit/PutAuditTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/audit/PutAuditTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/audit/PutAuditTests.java index 38ccd3c6d..aa038ac7d 100644 --- a/e2e-test/java/org/alfresco/rest/audit/PutAuditTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/audit/PutAuditTests.java @@ -1,5 +1,6 @@ -package org.alfresco.rest.audit; +package org.alfresco.service.search.rest.audit; +import org.alfresco.rest.audit.AuditTest; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; diff --git a/e2e-test/java/org/alfresco/rest/auth/AuthTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/auth/AuthTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/auth/AuthTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/auth/AuthTests.java index 70826fe4c..d7ed5aa73 100644 --- a/e2e-test/java/org/alfresco/rest/auth/AuthTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/auth/AuthTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.auth; +package org.alfresco.service.search.rest.auth; import org.alfresco.rest.RestTest; import org.alfresco.rest.core.RestWrapper; diff --git a/e2e-test/java/org/alfresco/rest/cmis/CmisBrowserTest.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/cmis/CmisBrowserTest.java similarity index 95% rename from e2e-test/java/org/alfresco/rest/cmis/CmisBrowserTest.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/cmis/CmisBrowserTest.java index 1e9afbab7..302aa0a69 100644 --- a/e2e-test/java/org/alfresco/rest/cmis/CmisBrowserTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/cmis/CmisBrowserTest.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.cmis; +package org.alfresco.service.search.rest.cmis; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/comments/AddCommentTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/comments/AddCommentTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/comments/AddCommentTests.java index aeaa95869..2b4d51b24 100644 --- a/e2e-test/java/org/alfresco/rest/comments/AddCommentTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/comments/AddCommentTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.comments; +package org.alfresco.service.search.rest.comments; import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.CMISUtil.DocumentType; diff --git a/e2e-test/java/org/alfresco/rest/comments/AddCommentsTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/comments/AddCommentsTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/comments/AddCommentsTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/comments/AddCommentsTests.java index 7f28fd249..482dba09f 100644 --- a/e2e-test/java/org/alfresco/rest/comments/AddCommentsTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/comments/AddCommentsTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.comments; +package org.alfresco.service.search.rest.comments; import java.util.List; diff --git a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/comments/DeleteCommentTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/comments/DeleteCommentTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/comments/DeleteCommentTests.java index 614f257df..40260a1a8 100644 --- a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/comments/DeleteCommentTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.comments; +package org.alfresco.service.search.rest.comments; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/comments/GetCommentsTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/comments/GetCommentsTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/comments/GetCommentsTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/comments/GetCommentsTests.java index 6c8f07af2..d213863e5 100644 --- a/e2e-test/java/org/alfresco/rest/comments/GetCommentsTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/comments/GetCommentsTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.comments; +package org.alfresco.service.search.rest.comments; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/comments/UpdateCommentTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/comments/UpdateCommentTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/comments/UpdateCommentTests.java index aad251918..cdf4cfbf5 100644 --- a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/comments/UpdateCommentTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.comments; +package org.alfresco.service.search.rest.comments; import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.CMISUtil.DocumentType; diff --git a/e2e-test/java/org/alfresco/rest/demo/RestDemoTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/RestDemoTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/demo/RestDemoTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/demo/RestDemoTests.java index 80ba29199..0a7a6e9d6 100644 --- a/e2e-test/java/org/alfresco/rest/demo/RestDemoTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/RestDemoTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.demo; +package org.alfresco.service.search.rest.demo; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.SiteService.Visibility; diff --git a/e2e-test/java/org/alfresco/rest/demo/SampleCommentsTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/SampleCommentsTests.java similarity index 97% rename from e2e-test/java/org/alfresco/rest/demo/SampleCommentsTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/demo/SampleCommentsTests.java index 1151d4c2e..fdb43d8d0 100644 --- a/e2e-test/java/org/alfresco/rest/demo/SampleCommentsTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/SampleCommentsTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.demo; +package org.alfresco.service.search.rest.demo; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/demo/SamplePeopleTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/SamplePeopleTests.java similarity index 95% rename from e2e-test/java/org/alfresco/rest/demo/SamplePeopleTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/demo/SamplePeopleTests.java index 6c0a2ff18..4c803b4b8 100644 --- a/e2e-test/java/org/alfresco/rest/demo/SamplePeopleTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/SamplePeopleTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.demo; +package org.alfresco.service.search.rest.demo; import org.alfresco.rest.RestTest; import org.alfresco.utility.exception.DataPreparationException; diff --git a/e2e-test/java/org/alfresco/rest/demo/SampleSitesTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/SampleSitesTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/demo/SampleSitesTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/demo/SampleSitesTests.java index f5c59e8a8..38fd2d1a8 100644 --- a/e2e-test/java/org/alfresco/rest/demo/SampleSitesTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/SampleSitesTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.demo; +package org.alfresco.service.search.rest.demo; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; diff --git a/e2e-test/java/org/alfresco/rest/demo/workshop/RestApiDemoTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/workshop/RestApiDemoTests.java similarity index 97% rename from e2e-test/java/org/alfresco/rest/demo/workshop/RestApiDemoTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/demo/workshop/RestApiDemoTests.java index 7492d8023..d1953cea0 100644 --- a/e2e-test/java/org/alfresco/rest/demo/workshop/RestApiDemoTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/workshop/RestApiDemoTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.demo.workshop; +package org.alfresco.service.search.rest.demo.workshop; import org.alfresco.rest.RestTest; import org.alfresco.utility.constants.UserRole; diff --git a/e2e-test/java/org/alfresco/rest/demo/workshop/RestApiWorkshopTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/workshop/RestApiWorkshopTests.java similarity index 94% rename from e2e-test/java/org/alfresco/rest/demo/workshop/RestApiWorkshopTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/demo/workshop/RestApiWorkshopTests.java index 88484bf66..efbc0e431 100644 --- a/e2e-test/java/org/alfresco/rest/demo/workshop/RestApiWorkshopTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/workshop/RestApiWorkshopTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.demo.workshop; +package org.alfresco.service.search.rest.demo.workshop; import org.alfresco.rest.RestTest; import org.testng.annotations.Test; diff --git a/e2e-test/java/org/alfresco/rest/discovery/DiscoveryTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/discovery/DiscoveryTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/discovery/DiscoveryTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/discovery/DiscoveryTests.java index f4011a4c5..8e2ab0145 100644 --- a/e2e-test/java/org/alfresco/rest/discovery/DiscoveryTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/discovery/DiscoveryTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.discovery; +package org.alfresco.service.search.rest.discovery; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; diff --git a/e2e-test/java/org/alfresco/rest/downloads/DownloadsTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/downloads/DownloadsTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/downloads/DownloadsTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/downloads/DownloadsTests.java index 054801807..76c74bcc3 100644 --- a/e2e-test/java/org/alfresco/rest/downloads/DownloadsTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/downloads/DownloadsTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.downloads; +package org.alfresco.service.search.rest.downloads; import javax.json.JsonObject; diff --git a/e2e-test/java/org/alfresco/rest/favorites/AddFavoriteSiteTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/AddFavoriteSiteTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/favorites/AddFavoriteSiteTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/AddFavoriteSiteTests.java index efc505218..74f05a42e 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/AddFavoriteSiteTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/AddFavoriteSiteTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.favorites; +package org.alfresco.service.search.rest.favorites; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/AddFavoritesTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/favorites/AddFavoritesTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/AddFavoritesTests.java index 0797eadee..d6c969625 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/AddFavoritesTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/AddFavoritesTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.favorites; +package org.alfresco.service.search.rest.favorites; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteSiteTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/DeleteFavoriteSiteTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteSiteTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/DeleteFavoriteSiteTests.java index b3fa0d190..e7240beb6 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteSiteTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/DeleteFavoriteSiteTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.favorites; +package org.alfresco.service.search.rest.favorites; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/DeleteFavoriteTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/DeleteFavoriteTests.java index 79570ff1d..997c9f386 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/DeleteFavoriteTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/DeleteFavoriteTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.favorites; +package org.alfresco.service.search.rest.favorites; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/favorites/FavoritesIncludePathTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/FavoritesIncludePathTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/favorites/FavoritesIncludePathTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/FavoritesIncludePathTests.java index dcbba231f..d1f521bca 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/FavoritesIncludePathTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/FavoritesIncludePathTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.favorites; +package org.alfresco.service.search.rest.favorites; import static org.alfresco.utility.report.log.Step.STEP; diff --git a/e2e-test/java/org/alfresco/rest/favorites/FavoritesNetworkTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/FavoritesNetworkTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/favorites/FavoritesNetworkTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/FavoritesNetworkTests.java index 6690a75ed..ebdebfad7 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/FavoritesNetworkTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/FavoritesNetworkTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.favorites; +package org.alfresco.service.search.rest.favorites; import org.alfresco.rest.NetworkDataPrep; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSiteTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/GetFavoriteSiteTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSiteTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/GetFavoriteSiteTests.java index 9cdc776aa..a20eda655 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSiteTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/GetFavoriteSiteTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.favorites; +package org.alfresco.service.search.rest.favorites; import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.SiteService; diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSitesTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/GetFavoriteSitesTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSitesTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/GetFavoriteSitesTests.java index db6dd2f90..dbe564837 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteSitesTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/GetFavoriteSitesTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.favorites; +package org.alfresco.service.search.rest.favorites; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/GetFavoriteTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/favorites/GetFavoriteTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/GetFavoriteTests.java index c5ededc33..0dcc4c178 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoriteTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/GetFavoriteTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.favorites; +package org.alfresco.service.search.rest.favorites; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.SiteService; diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/GetFavoritesTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/favorites/GetFavoritesTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/GetFavoritesTests.java index f12845720..7fc493824 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/GetFavoritesTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.favorites; +package org.alfresco.service.search.rest.favorites; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/groups/GroupsTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/groups/GroupsTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/groups/GroupsTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/groups/GroupsTests.java index 5eb3fa562..589bf3e1e 100644 --- a/e2e-test/java/org/alfresco/rest/groups/GroupsTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/groups/GroupsTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.groups; +package org.alfresco.service.search.rest.groups; import java.util.UUID; diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/networks/RestGetNetworkForPersonTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/networks/RestGetNetworkForPersonTests.java index 384edd07f..278c0bc10 100644 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/networks/RestGetNetworkForPersonTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.networks; +package org.alfresco.service.search.rest.networks; import java.util.ArrayList; diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/networks/RestGetNetworkTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/networks/RestGetNetworkTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/networks/RestGetNetworkTests.java index e872aa0da..2f60f4c19 100644 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/networks/RestGetNetworkTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.networks; +package org.alfresco.service.search.rest.networks; import org.alfresco.rest.NetworkDataPrep; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/networks/RestGetNetworksForPersonTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/networks/RestGetNetworksForPersonTests.java index 9f5e04dde..fd6848127 100644 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/networks/RestGetNetworksForPersonTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.networks; +package org.alfresco.service.search.rest.networks; import org.alfresco.rest.NetworkDataPrep; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/nodes/NodesActionDefinitionTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesActionDefinitionTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/nodes/NodesActionDefinitionTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesActionDefinitionTests.java index 596ebf72c..07860a156 100644 --- a/e2e-test/java/org/alfresco/rest/nodes/NodesActionDefinitionTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesActionDefinitionTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.nodes; +package org.alfresco.service.search.rest.nodes; import static org.testng.Assert.assertFalse; diff --git a/e2e-test/java/org/alfresco/rest/nodes/NodesContentAndVersioningTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesContentAndVersioningTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/nodes/NodesContentAndVersioningTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesContentAndVersioningTests.java index a3770353a..ba1c15567 100644 --- a/e2e-test/java/org/alfresco/rest/nodes/NodesContentAndVersioningTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesContentAndVersioningTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.nodes; +package org.alfresco.service.search.rest.nodes; import static org.alfresco.utility.report.log.Step.STEP; import static org.testng.Assert.assertEquals; diff --git a/e2e-test/java/org/alfresco/rest/nodes/NodesLockTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesLockTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/nodes/NodesLockTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesLockTests.java index ce19991f6..b85b7dcb3 100644 --- a/e2e-test/java/org/alfresco/rest/nodes/NodesLockTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesLockTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.nodes; +package org.alfresco.service.search.rest.nodes; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/nodes/NodesParentChildrenTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesParentChildrenTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/nodes/NodesParentChildrenTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesParentChildrenTests.java index 417eb99d1..8cb5d82da 100644 --- a/e2e-test/java/org/alfresco/rest/nodes/NodesParentChildrenTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesParentChildrenTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.nodes; +package org.alfresco.service.search.rest.nodes; import static org.alfresco.utility.report.log.Step.STEP; diff --git a/e2e-test/java/org/alfresco/rest/nodes/NodesTargetSourcesTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesTargetSourcesTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/nodes/NodesTargetSourcesTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesTargetSourcesTests.java index 83863ad59..489a9007b 100644 --- a/e2e-test/java/org/alfresco/rest/nodes/NodesTargetSourcesTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesTargetSourcesTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.nodes; +package org.alfresco.service.search.rest.nodes; import static org.alfresco.utility.report.log.Step.STEP; diff --git a/e2e-test/java/org/alfresco/rest/nodes/NodesTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesTests.java similarity index 97% rename from e2e-test/java/org/alfresco/rest/nodes/NodesTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesTests.java index b122296c6..d8453e80c 100644 --- a/e2e-test/java/org/alfresco/rest/nodes/NodesTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.nodes; +package org.alfresco.service.search.rest.nodes; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestNodeBodyMoveCopyModel; diff --git a/e2e-test/java/org/alfresco/rest/nodes/NodesUnlockTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesUnlockTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/nodes/NodesUnlockTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesUnlockTests.java index ca10a5c59..788685149 100644 --- a/e2e-test/java/org/alfresco/rest/nodes/NodesUnlockTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesUnlockTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.nodes; +package org.alfresco.service.search.rest.nodes; import static org.alfresco.utility.report.log.Step.STEP; diff --git a/e2e-test/java/org/alfresco/rest/people/AvatarPeopleSanityTest.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/AvatarPeopleSanityTest.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/people/AvatarPeopleSanityTest.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/people/AvatarPeopleSanityTest.java index 73aae3bdf..90b64b771 100644 --- a/e2e-test/java/org/alfresco/rest/people/AvatarPeopleSanityTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/AvatarPeopleSanityTest.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.people; +package org.alfresco.service.search.rest.people; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertTrue; diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/DeleteSiteMemberCoreTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberCoreTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/people/DeleteSiteMemberCoreTests.java index 71c5eb18a..1c06c6403 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/DeleteSiteMemberCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.people; +package org.alfresco.service.search.rest.people; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/DeleteSiteMemberFullTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberFullTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/people/DeleteSiteMemberFullTests.java index 85315e3a4..d10e7aee6 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/DeleteSiteMemberFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.people; +package org.alfresco.service.search.rest.people; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/DeleteSiteMemberSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/people/DeleteSiteMemberSanityTests.java index 589c4b6ef..033ec7751 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/DeleteSiteMemberSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.people; +package org.alfresco.service.search.rest.people; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetPeopleCoreTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/people/GetPeopleCoreTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetPeopleCoreTests.java index a209dc427..2fabbf450 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetPeopleCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.people; +package org.alfresco.service.search.rest.people; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetPeopleFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/people/GetPeopleFullTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetPeopleFullTests.java index a447bd1d5..83795ff2b 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetPeopleFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.people; +package org.alfresco.service.search.rest.people; import org.alfresco.rest.RestTest; import org.alfresco.rest.core.RestRequest; diff --git a/e2e-test/java/org/alfresco/rest/people/GetPeopleSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetPeopleSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/people/GetPeopleSanityTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetPeopleSanityTests.java index 2678895a5..9ceb6f3e6 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetPeopleSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetPeopleSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.people; +package org.alfresco.service.search.rest.people; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSiteMembershipCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/people/GetSiteMembershipCoreTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSiteMembershipCoreTests.java index a1ed9384e..a5b68ea32 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSiteMembershipCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.people; +package org.alfresco.service.search.rest.people; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSiteMembershipFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/people/GetSiteMembershipFullTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSiteMembershipFullTests.java index 7ad0ae6f9..54e6aa8a8 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSiteMembershipFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.people; +package org.alfresco.service.search.rest.people; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSiteMembershipSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSiteMembershipSanityTests.java index 5e348663b..f12ce12ff 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSiteMembershipSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSiteMembershipSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.people; +package org.alfresco.service.search.rest.people; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; diff --git a/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSitesMembershipInformationCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationCoreTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSitesMembershipInformationCoreTests.java index 16a91b969..602c89a4f 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSitesMembershipInformationCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.people; +package org.alfresco.service.search.rest.people; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSitesMembershipInformationFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationFullTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSitesMembershipInformationFullTests.java index 856f8bf28..7ace01c68 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSitesMembershipInformationFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.people; +package org.alfresco.service.search.rest.people; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestSiteMembershipModelsCollection; diff --git a/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSitesMembershipInformationSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSitesMembershipInformationSanityTests.java index 7280ec849..067f7abee 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetSitesMembershipInformationSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSitesMembershipInformationSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.people; +package org.alfresco.service.search.rest.people; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; diff --git a/e2e-test/java/org/alfresco/rest/people/activities/GetPeopleActivitiesCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/activities/GetPeopleActivitiesCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/people/activities/GetPeopleActivitiesCoreTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/people/activities/GetPeopleActivitiesCoreTests.java index bdc7d7dd6..4eb1711fd 100644 --- a/e2e-test/java/org/alfresco/rest/people/activities/GetPeopleActivitiesCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/activities/GetPeopleActivitiesCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.people.activities; +package org.alfresco.service.search.rest.people.activities; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/people/activities/GetPeopleActivitiesFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/activities/GetPeopleActivitiesFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/people/activities/GetPeopleActivitiesFullTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/people/activities/GetPeopleActivitiesFullTests.java index 1abd5a4e7..d1c8d8219 100644 --- a/e2e-test/java/org/alfresco/rest/people/activities/GetPeopleActivitiesFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/activities/GetPeopleActivitiesFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.people.activities; +package org.alfresco.service.search.rest.people.activities; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/people/activities/GetPeopleActivitiesSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/activities/GetPeopleActivitiesSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/people/activities/GetPeopleActivitiesSanityTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/people/activities/GetPeopleActivitiesSanityTests.java index 468f13bfa..193621c37 100644 --- a/e2e-test/java/org/alfresco/rest/people/activities/GetPeopleActivitiesSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/activities/GetPeopleActivitiesSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.people.activities; +package org.alfresco.service.search.rest.people.activities; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferenceCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferenceCoreTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferenceCoreTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferenceCoreTests.java index 4e02b7025..d6093c3ac 100644 --- a/e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferenceCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferenceCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.people.preferences; +package org.alfresco.service.search.rest.people.preferences; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferenceFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferenceFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferenceFullTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferenceFullTests.java index 5c874d427..806d475dd 100644 --- a/e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferenceFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferenceFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.people.preferences; +package org.alfresco.service.search.rest.people.preferences; import java.nio.file.Paths; diff --git a/e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferenceSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferenceSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferenceSanityTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferenceSanityTests.java index be9802d5f..07484fd53 100644 --- a/e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferenceSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferenceSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.people.preferences; +package org.alfresco.service.search.rest.people.preferences; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferencesCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferencesCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferencesCoreTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferencesCoreTests.java index f4b42e8c7..f3c511b71 100644 --- a/e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferencesCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferencesCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.people.preferences; +package org.alfresco.service.search.rest.people.preferences; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferencesFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferencesFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferencesFullTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferencesFullTests.java index 28de256d3..99d2f0220 100644 --- a/e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferencesFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferencesFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.people.preferences; +package org.alfresco.service.search.rest.people.preferences; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferencesSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferencesSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferencesSanityTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferencesSanityTests.java index 7570f80a4..e48a9527e 100644 --- a/e2e-test/java/org/alfresco/rest/people/preferences/GetPeoplePreferencesSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferencesSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.people.preferences; +package org.alfresco.service.search.rest.people.preferences; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/queries/QueriesTest.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/queries/QueriesTest.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/queries/QueriesTest.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/queries/QueriesTest.java index ddfce7ae8..c85222e79 100644 --- a/e2e-test/java/org/alfresco/rest/queries/QueriesTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/queries/QueriesTest.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.queries; +package org.alfresco.service.search.rest.queries; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; diff --git a/e2e-test/java/org/alfresco/rest/ratings/AddRatingTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/ratings/AddRatingTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/ratings/AddRatingTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/ratings/AddRatingTests.java index 72e3595a4..407b71359 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/AddRatingTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/ratings/AddRatingTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.ratings; +package org.alfresco.service.search.rest.ratings; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/ratings/DeleteRatingTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/ratings/DeleteRatingTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/ratings/DeleteRatingTests.java index 1edea1c5d..849a1ec70 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/DeleteRatingTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/ratings/DeleteRatingTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.ratings; +package org.alfresco.service.search.rest.ratings; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/ratings/GetRatingTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/ratings/GetRatingTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/ratings/GetRatingTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/ratings/GetRatingTests.java index 9cb42f8f7..54700fa59 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/GetRatingTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/ratings/GetRatingTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.ratings; +package org.alfresco.service.search.rest.ratings; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/ratings/GetRatingsTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/ratings/GetRatingsTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/ratings/GetRatingsTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/ratings/GetRatingsTests.java index ca4469a85..60f17ec8a 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/GetRatingsTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/ratings/GetRatingsTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.ratings; +package org.alfresco.service.search.rest.ratings; import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.CMISUtil.DocumentType; diff --git a/e2e-test/java/org/alfresco/rest/renditions/CreateRenditionTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/renditions/CreateRenditionTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/renditions/CreateRenditionTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/renditions/CreateRenditionTests.java index 4c8964aee..0e7af8ef3 100644 --- a/e2e-test/java/org/alfresco/rest/renditions/CreateRenditionTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/renditions/CreateRenditionTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.renditions; +package org.alfresco.service.search.rest.renditions; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/renditions/GetRenditionTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/renditions/GetRenditionTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/renditions/GetRenditionTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/renditions/GetRenditionTests.java index bbeda974c..a6fce94f9 100644 --- a/e2e-test/java/org/alfresco/rest/renditions/GetRenditionTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/renditions/GetRenditionTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.renditions; +package org.alfresco.service.search.rest.renditions; import static org.alfresco.utility.report.log.Step.STEP; diff --git a/e2e-test/java/org/alfresco/rest/renditions/RenditionIntegrationTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/renditions/RenditionIntegrationTests.java similarity index 96% rename from e2e-test/java/org/alfresco/rest/renditions/RenditionIntegrationTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/renditions/RenditionIntegrationTests.java index 2423613ca..d9769fcd7 100644 --- a/e2e-test/java/org/alfresco/rest/renditions/RenditionIntegrationTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/renditions/RenditionIntegrationTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.renditions; +package org.alfresco.service.search.rest.renditions; import org.alfresco.rest.RestTest; import org.alfresco.rest.core.RestResponse; diff --git a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/AbstractSearchTest.java similarity index 96% rename from e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/search/AbstractSearchTest.java index 8ec3643ae..1ea8d1ab8 100644 --- a/e2e-test/java/org/alfresco/rest/search/AbstractSearchTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/AbstractSearchTest.java @@ -16,11 +16,16 @@ * You should have received a copy of the GNU Lesser General Public License * along with Alfresco. If not, see . */ -package org.alfresco.rest.search; +package org.alfresco.service.search.rest.search; import org.alfresco.dataprep.SiteService.Visibility; import org.alfresco.rest.RestTest; import org.alfresco.rest.core.RestResponse; +import org.alfresco.rest.search.RestRequestHighlightModel; +import org.alfresco.rest.search.RestRequestQueryModel; +import org.alfresco.rest.search.SearchRequest; +import org.alfresco.rest.search.SearchResponse; +import org.alfresco.rest.search.SearchSqlRequest; import org.alfresco.utility.Utility; import org.alfresco.utility.data.RandomData; import org.alfresco.utility.model.FileModel; @@ -122,7 +127,7 @@ public class AbstractSearchTest extends RestTest * @throws Exception if error * */ - protected SearchResponse query(RestRequestQueryModel queryReq,RestRequestHighlightModel highlight) throws Exception + protected SearchResponse query(RestRequestQueryModel queryReq, RestRequestHighlightModel highlight) throws Exception { SearchRequest query = new SearchRequest(queryReq); query.setHighlight(highlight); diff --git a/e2e-test/java/org/alfresco/rest/search/FacetFieldsSearchTest.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/FacetFieldsSearchTest.java similarity index 96% rename from e2e-test/java/org/alfresco/rest/search/FacetFieldsSearchTest.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/search/FacetFieldsSearchTest.java index 190d66112..356173e83 100644 --- a/e2e-test/java/org/alfresco/rest/search/FacetFieldsSearchTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/FacetFieldsSearchTest.java @@ -16,7 +16,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with Alfresco. If not, see . */ -package org.alfresco.rest.search; +package org.alfresco.service.search.rest.search; import java.util.ArrayList; import java.util.List; @@ -25,6 +25,14 @@ import javax.json.Json; import javax.json.JsonObject; import org.alfresco.dataprep.SiteService.Visibility; +import org.alfresco.rest.search.AbstractSearchTest; +import org.alfresco.rest.search.FacetFieldBucket; +import org.alfresco.rest.search.RestRequestFacetFieldModel; +import org.alfresco.rest.search.RestRequestFacetFieldsModel; +import org.alfresco.rest.search.RestRequestQueryModel; +import org.alfresco.rest.search.RestResultBucketsModel; +import org.alfresco.rest.search.SearchRequest; +import org.alfresco.rest.search.SearchResponse; import org.alfresco.utility.data.RandomData; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FileType; diff --git a/e2e-test/java/org/alfresco/rest/search/FacetIntervalSearchTest.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/FacetIntervalSearchTest.java similarity index 94% rename from e2e-test/java/org/alfresco/rest/search/FacetIntervalSearchTest.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/search/FacetIntervalSearchTest.java index ef9f579dd..c01c6024c 100644 --- a/e2e-test/java/org/alfresco/rest/search/FacetIntervalSearchTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/FacetIntervalSearchTest.java @@ -16,9 +16,17 @@ * You should have received a copy of the GNU Lesser General Public License * along with Alfresco. If not, see . */ -package org.alfresco.rest.search; +package org.alfresco.service.search.rest.search; import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.search.AbstractSearchTest; +import org.alfresco.rest.search.FacetInterval; +import org.alfresco.rest.search.RestGenericBucketModel; +import org.alfresco.rest.search.RestGenericFacetResponseModel; +import org.alfresco.rest.search.RestRequestFacetIntervalsModel; +import org.alfresco.rest.search.RestRequestFacetSetModel; +import org.alfresco.rest.search.SearchRequest; +import org.alfresco.rest.search.SearchResponse; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; diff --git a/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/FacetRangeSearchTest.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/search/FacetRangeSearchTest.java index b3c518445..d1bf514f7 100644 --- a/e2e-test/java/org/alfresco/rest/search/FacetRangeSearchTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/FacetRangeSearchTest.java @@ -16,7 +16,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with Alfresco. If not, see . */ -package org.alfresco.rest.search; +package org.alfresco.service.search.rest.search; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; @@ -27,6 +27,11 @@ import java.util.Map; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestRequestRangesModel; +import org.alfresco.rest.search.AbstractSearchTest; +import org.alfresco.rest.search.RestGenericBucketModel; +import org.alfresco.rest.search.RestGenericFacetResponseModel; +import org.alfresco.rest.search.SearchRequest; +import org.alfresco.rest.search.SearchResponse; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; diff --git a/e2e-test/java/org/alfresco/rest/search/PivotFacetedSearchTest.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/PivotFacetedSearchTest.java similarity index 96% rename from e2e-test/java/org/alfresco/rest/search/PivotFacetedSearchTest.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/search/PivotFacetedSearchTest.java index fae882339..eec830bbd 100644 --- a/e2e-test/java/org/alfresco/rest/search/PivotFacetedSearchTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/PivotFacetedSearchTest.java @@ -16,7 +16,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with Alfresco. If not, see . */ -package org.alfresco.rest.search; +package org.alfresco.service.search.rest.search; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; @@ -26,6 +26,15 @@ import java.util.List; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestRequestRangesModel; +import org.alfresco.rest.search.AbstractSearchTest; +import org.alfresco.rest.search.Pagination; +import org.alfresco.rest.search.RestGenericBucketModel; +import org.alfresco.rest.search.RestGenericFacetResponseModel; +import org.alfresco.rest.search.RestRequestFacetFieldModel; +import org.alfresco.rest.search.RestRequestFacetFieldsModel; +import org.alfresco.rest.search.RestRequestPivotModel; +import org.alfresco.rest.search.SearchRequest; +import org.alfresco.rest.search.SearchResponse; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; diff --git a/e2e-test/java/org/alfresco/rest/search/SearchHighLightTest.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/SearchHighLightTest.java similarity index 88% rename from e2e-test/java/org/alfresco/rest/search/SearchHighLightTest.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/search/SearchHighLightTest.java index 06528e684..96e93a062 100644 --- a/e2e-test/java/org/alfresco/rest/search/SearchHighLightTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/SearchHighLightTest.java @@ -16,11 +16,17 @@ * You should have received a copy of the GNU Lesser General Public License * along with Alfresco. If not, see . */ -package org.alfresco.rest.search; +package org.alfresco.service.search.rest.search; import java.util.ArrayList; import java.util.List; +import org.alfresco.rest.search.AbstractSearchTest; +import org.alfresco.rest.search.ResponseHighLightModel; +import org.alfresco.rest.search.RestRequestFieldsModel; +import org.alfresco.rest.search.RestRequestHighlightModel; +import org.alfresco.rest.search.RestRequestQueryModel; +import org.alfresco.rest.search.SearchResponse; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.report.Bug; import org.testng.annotations.BeforeClass; diff --git a/e2e-test/java/org/alfresco/rest/search/SearchSpellCheckTest.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/SearchSpellCheckTest.java similarity index 96% rename from e2e-test/java/org/alfresco/rest/search/SearchSpellCheckTest.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/search/SearchSpellCheckTest.java index 9be9d7fd7..19e822682 100644 --- a/e2e-test/java/org/alfresco/rest/search/SearchSpellCheckTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/SearchSpellCheckTest.java @@ -16,9 +16,13 @@ * You should have received a copy of the GNU Lesser General Public License * along with Alfresco. If not, see . */ -package org.alfresco.rest.search; +package org.alfresco.service.search.rest.search; import org.alfresco.rest.model.RestRequestSpellcheckModel; +import org.alfresco.rest.search.AbstractSearchTest; +import org.alfresco.rest.search.RestRequestQueryModel; +import org.alfresco.rest.search.SearchRequest; +import org.alfresco.rest.search.SearchResponse; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FileType; import org.alfresco.utility.model.TestGroup; diff --git a/e2e-test/java/org/alfresco/rest/search/StatsSearchTest.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/StatsSearchTest.java similarity index 95% rename from e2e-test/java/org/alfresco/rest/search/StatsSearchTest.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/search/StatsSearchTest.java index 594bb47b6..9e00a5d19 100644 --- a/e2e-test/java/org/alfresco/rest/search/StatsSearchTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/StatsSearchTest.java @@ -16,7 +16,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with Alfresco. If not, see . */ -package org.alfresco.rest.search; +package org.alfresco.service.search.rest.search; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; @@ -30,6 +30,18 @@ import java.util.Set; import java.util.stream.Collectors; import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.search.Pagination; +import org.alfresco.rest.search.RestGenericBucketModel; +import org.alfresco.rest.search.RestGenericFacetResponseModel; +import org.alfresco.rest.search.RestGenericMetricModel; +import org.alfresco.rest.search.RestRequestFacetFieldModel; +import org.alfresco.rest.search.RestRequestFacetFieldsModel; +import org.alfresco.rest.search.RestRequestFilterQueryModel; +import org.alfresco.rest.search.RestRequestPivotModel; +import org.alfresco.rest.search.RestRequestQueryModel; +import org.alfresco.rest.search.RestRequestStatsModel; +import org.alfresco.rest.search.SearchRequest; +import org.alfresco.rest.search.SearchResponse; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; diff --git a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLWithQuotedIdentifiers.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/sql/SearchSQLWithQuotedIdentifiers.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/search/sql/SearchSQLWithQuotedIdentifiers.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/search/sql/SearchSQLWithQuotedIdentifiers.java index 30f773d53..aed8d807f 100644 --- a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLWithQuotedIdentifiers.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/sql/SearchSQLWithQuotedIdentifiers.java @@ -16,12 +16,12 @@ * You should have received a copy of the GNU Lesser General Public License * along with Alfresco. If not, see . */ -package org.alfresco.rest.search.sql; +package org.alfresco.service.search.rest.search.sql; import java.util.UUID; import org.alfresco.rest.RestTest; -import org.alfresco.rest.search.AbstractSearchTest; +import org.alfresco.service.search.rest.search.AbstractSearchTest; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.CustomObjectTypeProperties; import org.alfresco.utility.model.ContentModel; diff --git a/e2e-test/java/org/alfresco/rest/sharedLinks/GetSharedLinksFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sharedLinks/GetSharedLinksFullTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/sharedLinks/GetSharedLinksFullTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/sharedLinks/GetSharedLinksFullTests.java index c2e3627a6..b51ce650d 100644 --- a/e2e-test/java/org/alfresco/rest/sharedLinks/GetSharedLinksFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/sharedLinks/GetSharedLinksFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sharedLinks; +package org.alfresco.service.search.rest.sharedLinks; import javax.json.Json; import javax.json.JsonObject; diff --git a/e2e-test/java/org/alfresco/rest/sharedLinks/SharedLinksSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sharedLinks/SharedLinksSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sharedLinks/SharedLinksSanityTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/sharedLinks/SharedLinksSanityTests.java index c9dbc91fe..746910792 100644 --- a/e2e-test/java/org/alfresco/rest/sharedLinks/SharedLinksSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/sharedLinks/SharedLinksSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sharedLinks; +package org.alfresco.service.search.rest.sharedLinks; import javax.json.Json; diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/GetSiteTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/GetSiteTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/sites/GetSiteTests.java index e205fe7a1..bd74a6c89 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/GetSiteTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites; +package org.alfresco.service.search.rest.sites; import org.alfresco.dataprep.SiteService; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSitesTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/GetSitesTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/GetSitesTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/sites/GetSitesTests.java index d178612bf..8234e69fe 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSitesTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/GetSitesTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites; +package org.alfresco.service.search.rest.sites; import org.alfresco.dataprep.SiteService; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/sites/SitesNetworkTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/SitesNetworkTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/SitesNetworkTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/sites/SitesNetworkTests.java index 9716ecba0..3811d3cf4 100644 --- a/e2e-test/java/org/alfresco/rest/sites/SitesNetworkTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/SitesNetworkTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites; +package org.alfresco.service.search.rest.sites; import org.alfresco.dataprep.SiteService; import org.alfresco.rest.NetworkDataPrep; diff --git a/e2e-test/java/org/alfresco/rest/sites/SitesTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/SitesTests.java similarity index 96% rename from e2e-test/java/org/alfresco/rest/sites/SitesTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/sites/SitesTests.java index 9b40f7082..03ed1aab2 100644 --- a/e2e-test/java/org/alfresco/rest/sites/SitesTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/SitesTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites; +package org.alfresco.service.search.rest.sites; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestSiteModel; diff --git a/e2e-test/java/org/alfresco/rest/sites/containers/GetSiteContainerTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/containers/GetSiteContainerTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/containers/GetSiteContainerTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/sites/containers/GetSiteContainerTests.java index 2ca445467..60fc66501 100644 --- a/e2e-test/java/org/alfresco/rest/sites/containers/GetSiteContainerTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/containers/GetSiteContainerTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites.containers; +package org.alfresco.service.search.rest.sites.containers; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/sites/containers/GetSiteContainersTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/containers/GetSiteContainersTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/containers/GetSiteContainersTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/sites/containers/GetSiteContainersTests.java index 2822239eb..a55f96b05 100644 --- a/e2e-test/java/org/alfresco/rest/sites/containers/GetSiteContainersTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/containers/GetSiteContainersTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites.containers; +package org.alfresco.service.search.rest.sites.containers; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/sites/members/AddSiteMemberTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/AddSiteMemberTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/members/AddSiteMemberTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/AddSiteMemberTests.java index 51cab086f..bb943b4bb 100644 --- a/e2e-test/java/org/alfresco/rest/sites/members/AddSiteMemberTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/AddSiteMemberTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites.members; +package org.alfresco.service.search.rest.sites.members; import org.alfresco.rest.RestTest; import org.alfresco.rest.core.JsonBodyGenerator; diff --git a/e2e-test/java/org/alfresco/rest/sites/members/GetSiteMemberTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/GetSiteMemberTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/members/GetSiteMemberTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/GetSiteMemberTests.java index b9c0e9f49..f33dcda18 100644 --- a/e2e-test/java/org/alfresco/rest/sites/members/GetSiteMemberTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/GetSiteMemberTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites.members; +package org.alfresco.service.search.rest.sites.members; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; diff --git a/e2e-test/java/org/alfresco/rest/sites/members/GetSiteMembersTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/GetSiteMembersTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/members/GetSiteMembersTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/GetSiteMembersTests.java index a6231ad49..12831b14e 100644 --- a/e2e-test/java/org/alfresco/rest/sites/members/GetSiteMembersTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/GetSiteMembersTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites.members; +package org.alfresco.service.search.rest.sites.members; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/sites/members/RemoveSiteMemberTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/RemoveSiteMemberTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/members/RemoveSiteMemberTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/RemoveSiteMemberTests.java index fca039386..c858bf5c6 100644 --- a/e2e-test/java/org/alfresco/rest/sites/members/RemoveSiteMemberTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/RemoveSiteMemberTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites.members; +package org.alfresco.service.search.rest.sites.members; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/sites/members/UpdateSiteMemberTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/UpdateSiteMemberTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/members/UpdateSiteMemberTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/UpdateSiteMemberTests.java index 3b98afebb..f95f7b96d 100644 --- a/e2e-test/java/org/alfresco/rest/sites/members/UpdateSiteMemberTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/UpdateSiteMemberTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites.members; +package org.alfresco.service.search.rest.sites.members; import org.alfresco.rest.RestTest; import org.alfresco.rest.core.JsonBodyGenerator; diff --git a/e2e-test/java/org/alfresco/rest/sites/membershipRequests/AddSiteMembershipRequestTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/AddSiteMembershipRequestTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/membershipRequests/AddSiteMembershipRequestTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/AddSiteMembershipRequestTests.java index a6f155cf6..1fc6f8f34 100644 --- a/e2e-test/java/org/alfresco/rest/sites/membershipRequests/AddSiteMembershipRequestTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/AddSiteMembershipRequestTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites.membershipRequests; +package org.alfresco.service.search.rest.sites.membershipRequests; import org.alfresco.dataprep.SiteService; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/sites/membershipRequests/DeleteSiteMembershipRequestTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/DeleteSiteMembershipRequestTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/membershipRequests/DeleteSiteMembershipRequestTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/DeleteSiteMembershipRequestTests.java index c1da58fb1..9ef32abb2 100644 --- a/e2e-test/java/org/alfresco/rest/sites/membershipRequests/DeleteSiteMembershipRequestTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/DeleteSiteMembershipRequestTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites.membershipRequests; +package org.alfresco.service.search.rest.sites.membershipRequests; import org.alfresco.dataprep.SiteService.Visibility; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/GetSiteMembershipRequestTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/GetSiteMembershipRequestTests.java index fba1deab0..e82752e0e 100644 --- a/e2e-test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/GetSiteMembershipRequestTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites.membershipRequests; +package org.alfresco.service.search.rest.sites.membershipRequests; import org.alfresco.dataprep.SiteService; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestsTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/GetSiteMembershipRequestsTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestsTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/GetSiteMembershipRequestsTests.java index 470b118dd..3671546dd 100644 --- a/e2e-test/java/org/alfresco/rest/sites/membershipRequests/GetSiteMembershipRequestsTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/GetSiteMembershipRequestsTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites.membershipRequests; +package org.alfresco.service.search.rest.sites.membershipRequests; import static org.alfresco.utility.report.log.Step.STEP; diff --git a/e2e-test/java/org/alfresco/rest/sites/membershipRequests/UpdateSiteMembershipRequestTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/UpdateSiteMembershipRequestTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/sites/membershipRequests/UpdateSiteMembershipRequestTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/UpdateSiteMembershipRequestTests.java index c40d3a2b5..8b0f31d97 100644 --- a/e2e-test/java/org/alfresco/rest/sites/membershipRequests/UpdateSiteMembershipRequestTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/UpdateSiteMembershipRequestTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.sites.membershipRequests; +package org.alfresco.service.search.rest.sites.membershipRequests; import org.alfresco.rest.RestTest; import org.alfresco.rest.core.RestRequest; diff --git a/e2e-test/java/org/alfresco/rest/syncService/SyncServiceAPITests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/syncService/SyncServiceAPITests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/syncService/SyncServiceAPITests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/syncService/SyncServiceAPITests.java index 58dacb907..896377507 100644 --- a/e2e-test/java/org/alfresco/rest/syncService/SyncServiceAPITests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/syncService/SyncServiceAPITests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.syncService; +package org.alfresco.service.search.rest.syncService; import java.util.LinkedList; import java.util.List; diff --git a/e2e-test/java/org/alfresco/rest/tags/TagsDataPrep.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/tags/TagsDataPrep.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/tags/TagsDataPrep.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/tags/TagsDataPrep.java index a499ab15b..4c87b3f52 100644 --- a/e2e-test/java/org/alfresco/rest/tags/TagsDataPrep.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/tags/TagsDataPrep.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.tags; +package org.alfresco.service.search.rest.tags; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/trashcan/GetDeletedNodesTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/trashcan/GetDeletedNodesTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/trashcan/GetDeletedNodesTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/trashcan/GetDeletedNodesTests.java index 553b044d1..c3719afe8 100644 --- a/e2e-test/java/org/alfresco/rest/trashcan/GetDeletedNodesTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/trashcan/GetDeletedNodesTests.java @@ -13,7 +13,7 @@ * along with Alfresco. If not, see . */ -package org.alfresco.rest.trashcan; +package org.alfresco.service.search.rest.trashcan; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/WorkflowNetworkDeploymentsTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/WorkflowNetworkDeploymentsTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/WorkflowNetworkDeploymentsTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/WorkflowNetworkDeploymentsTests.java index 8a255fd0b..695d16df4 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/WorkflowNetworkDeploymentsTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/WorkflowNetworkDeploymentsTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow; +package org.alfresco.service.search.rest.workflow; import java.util.List; diff --git a/e2e-test/java/org/alfresco/rest/workflow/WorkflowNetworkProcessDefinitionsTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/WorkflowNetworkProcessDefinitionsTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/WorkflowNetworkProcessDefinitionsTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/WorkflowNetworkProcessDefinitionsTests.java index 038681aef..7de03cbfd 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/WorkflowNetworkProcessDefinitionsTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/WorkflowNetworkProcessDefinitionsTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow; +package org.alfresco.service.search.rest.workflow; import org.alfresco.dataprep.CMISUtil.Priority; import org.alfresco.rest.NetworkDataPrep; diff --git a/e2e-test/java/org/alfresco/rest/workflow/WorkflowNetworkProcessesTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/WorkflowNetworkProcessesTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/WorkflowNetworkProcessesTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/WorkflowNetworkProcessesTests.java index 0e9b6696f..2b6155747 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/WorkflowNetworkProcessesTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/WorkflowNetworkProcessesTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow; +package org.alfresco.service.search.rest.workflow; import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.CMISUtil.DocumentType; diff --git a/e2e-test/java/org/alfresco/rest/workflow/WorkflowNetworkTasksTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/WorkflowNetworkTasksTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/WorkflowNetworkTasksTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/WorkflowNetworkTasksTests.java index f1f4e53a4..4f6774ac1 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/WorkflowNetworkTasksTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/WorkflowNetworkTasksTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow; +package org.alfresco.service.search.rest.workflow; import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.CMISUtil.DocumentType; diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/DeleteDeploymentTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/DeleteDeploymentTests.java index 0a929fd0e..68b0f2e6a 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/DeleteDeploymentTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/DeleteDeploymentTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.deployments; +package org.alfresco.service.search.rest.workflow.deployments; import java.util.List; diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentCoreTests.java similarity index 96% rename from e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentCoreTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentCoreTests.java index df2aae3a0..b7c53d8cc 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.deployments; +package org.alfresco.service.search.rest.workflow.deployments; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestDeploymentModel; diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentFullTests.java similarity index 97% rename from e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentFullTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentFullTests.java index cea14ceca..102758b0f 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.deployments; +package org.alfresco.service.search.rest.workflow.deployments; import org.alfresco.rest.RestTest; import org.alfresco.rest.core.RestRequest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentSanityTests.java similarity index 97% rename from e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentSanityTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentSanityTests.java index 67bda8b8a..02a7b29a5 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.deployments; +package org.alfresco.service.search.rest.workflow.deployments; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentsCoreTests.java similarity index 95% rename from e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsCoreTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentsCoreTests.java index f35f882a4..93dc839b8 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentsCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.deployments; +package org.alfresco.service.search.rest.workflow.deployments; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentsFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsFullTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentsFullTests.java index 6ba152e46..e8d556be1 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentsFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.deployments; +package org.alfresco.service.search.rest.workflow.deployments; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; diff --git a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentsSanityTests.java similarity index 96% rename from e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsSanityTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentsSanityTests.java index 9d1a4025f..9226f8803 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/deployments/GetDeploymentsSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentsSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.deployments; +package org.alfresco.service.search.rest.workflow.deployments; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionCoreTests.java similarity index 96% rename from e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionCoreTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionCoreTests.java index 3edb7e020..648522b66 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processDefinitions; +package org.alfresco.service.search.rest.workflow.processDefinitions; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionFullTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionFullTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionFullTests.java index 17c2b6972..77166ef3e 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processDefinitions; +package org.alfresco.service.search.rest.workflow.processDefinitions; import org.alfresco.rest.RestTest; import org.alfresco.rest.core.RestRequest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionImageCoreTests.java similarity index 96% rename from e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageCoreTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionImageCoreTests.java index 2fe6f5f3c..94e8e72d3 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionImageCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processDefinitions; +package org.alfresco.service.search.rest.workflow.processDefinitions; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionImageFullTests.java similarity index 96% rename from e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageFullTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionImageFullTests.java index 9c37e7c46..e7e2887d1 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionImageFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processDefinitions; +package org.alfresco.service.search.rest.workflow.processDefinitions; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestProcessDefinitionModel; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java similarity index 97% rename from e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java index 06f76f017..18955b818 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processDefinitions; +package org.alfresco.service.search.rest.workflow.processDefinitions; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestProcessDefinitionModel; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java index 36d8ef872..aed83fb72 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processDefinitions; +package org.alfresco.service.search.rest.workflow.processDefinitions; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestProcessDefinitionModel; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java index 6290ad9f6..b3b3a1a33 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processDefinitions; +package org.alfresco.service.search.rest.workflow.processDefinitions; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelFullTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelFullTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelFullTests.java index fa77452a4..fb9cd6703 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processDefinitions; +package org.alfresco.service.search.rest.workflow.processDefinitions; import java.util.Arrays; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java similarity index 96% rename from e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java index 7b3d98aef..f966e5031 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processDefinitions; +package org.alfresco.service.search.rest.workflow.processDefinitions; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestProcessDefinitionModel; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionsCoreTests.java similarity index 97% rename from e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsCoreTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionsCoreTests.java index 6d4e492ff..6b6bea2cb 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionsCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processDefinitions; +package org.alfresco.service.search.rest.workflow.processDefinitions; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionsFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsFullTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionsFullTests.java index 6d4f929e7..46dd92024 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionsFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processDefinitions; +package org.alfresco.service.search.rest.workflow.processDefinitions; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java similarity index 96% rename from e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java index f0a330d7c..55f96807e 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processDefinitions; +package org.alfresco.service.search.rest.workflow.processDefinitions; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestProcessDefinitionModelsCollection; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/AddProcessCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessCoreTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/AddProcessCoreTests.java index 8a2eac446..e68b088f2 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/AddProcessCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes; +package org.alfresco.service.search.rest.workflow.processes; import org.alfresco.dataprep.CMISUtil.Priority; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/AddProcessFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessFullTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/AddProcessFullTests.java index c1eb6b24a..e7cd091e1 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/AddProcessFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes; +package org.alfresco.service.search.rest.workflow.processes; import javax.json.JsonObject; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/AddProcessSanityTests.java similarity index 96% rename from e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessSanityTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/AddProcessSanityTests.java index e43e59203..aeba6d7e4 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/AddProcessSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes; +package org.alfresco.service.search.rest.workflow.processes; import org.alfresco.dataprep.CMISUtil.Priority; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/DeleteProcessCoreTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessCoreTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/DeleteProcessCoreTests.java index 26253d2b1..afae4d6db 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/DeleteProcessCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes; +package org.alfresco.service.search.rest.workflow.processes; import org.alfresco.dataprep.CMISUtil.Priority; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/DeleteProcessFullTests.java similarity index 97% rename from e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessFullTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/DeleteProcessFullTests.java index e1c295f72..de176a36a 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/DeleteProcessFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes; +package org.alfresco.service.search.rest.workflow.processes; import org.alfresco.dataprep.CMISUtil.Priority; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/DeleteProcessSanityTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/DeleteProcessSanityTests.java index 9478b9d0e..efc3280ec 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/DeleteProcessSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes; +package org.alfresco.service.search.rest.workflow.processes; import org.alfresco.dataprep.CMISUtil.Priority; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessCoreTests.java similarity index 97% rename from e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessCoreTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessCoreTests.java index 418e4b8a0..ba17f929d 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes; +package org.alfresco.service.search.rest.workflow.processes; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessFullTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessFullTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessFullTests.java index 01c11e8a2..1f4dba963 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes; +package org.alfresco.service.search.rest.workflow.processes; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessSanityTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessSanityTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessSanityTests.java index b4288002a..08ca30dde 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes; +package org.alfresco.service.search.rest.workflow.processes; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessesCoreTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesCoreTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessesCoreTests.java index 5a5c5fd5d..c3565f1a3 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessesCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes; +package org.alfresco.service.search.rest.workflow.processes; import java.util.List; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessesFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesFullTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessesFullTests.java index c4595920e..2c9d01685 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessesFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes; +package org.alfresco.service.search.rest.workflow.processes; import java.util.List; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessesSanityTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessesSanityTests.java index b64d0d141..1d2e32b34 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessesSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes; +package org.alfresco.service.search.rest.workflow.processes; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/AddProcessItemCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemCoreTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/AddProcessItemCoreTests.java index 9eaa02099..a49fad9e4 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/AddProcessItemCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes.items; +package org.alfresco.service.search.rest.workflow.processes.items; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/AddProcessItemFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemFullTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/AddProcessItemFullTests.java index 202fcf554..420662910 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/AddProcessItemFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes.items; +package org.alfresco.service.search.rest.workflow.processes.items; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/AddProcessItemSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemSanityTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/AddProcessItemSanityTests.java index 797936ceb..9773d72df 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/AddProcessItemSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes.items; +package org.alfresco.service.search.rest.workflow.processes.items; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/items/DeleteProcessItemCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/DeleteProcessItemCoreTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/workflow/processes/items/DeleteProcessItemCoreTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/DeleteProcessItemCoreTests.java index ca7a5a308..037a5a162 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/items/DeleteProcessItemCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/DeleteProcessItemCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes.items; +package org.alfresco.service.search.rest.workflow.processes.items; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/items/DeleteProcessItemFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/DeleteProcessItemFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/processes/items/DeleteProcessItemFullTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/DeleteProcessItemFullTests.java index 3afd2e31c..c8847ecaa 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/items/DeleteProcessItemFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/DeleteProcessItemFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes.items; +package org.alfresco.service.search.rest.workflow.processes.items; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.CMISUtil.Priority; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/items/DeleteProcessItemSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/DeleteProcessItemSanityTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/workflow/processes/items/DeleteProcessItemSanityTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/DeleteProcessItemSanityTests.java index df776f144..7f2661afc 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/items/DeleteProcessItemSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/DeleteProcessItemSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes.items; +package org.alfresco.service.search.rest.workflow.processes.items; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/items/GetProcessItemsCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/GetProcessItemsCoreTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/workflow/processes/items/GetProcessItemsCoreTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/GetProcessItemsCoreTests.java index 918af8111..73a5a03b4 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/items/GetProcessItemsCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/GetProcessItemsCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes.items; +package org.alfresco.service.search.rest.workflow.processes.items; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/items/GetProcessItemsFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/GetProcessItemsFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/processes/items/GetProcessItemsFullTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/GetProcessItemsFullTests.java index c81c5c3f4..4f37f5cc1 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/items/GetProcessItemsFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/GetProcessItemsFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes.items; +package org.alfresco.service.search.rest.workflow.processes.items; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/items/GetProcessItemsSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/GetProcessItemsSanityTests.java similarity index 97% rename from e2e-test/java/org/alfresco/rest/workflow/processes/items/GetProcessItemsSanityTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/GetProcessItemsSanityTests.java index 6c0ce3764..5276618ef 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/items/GetProcessItemsSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/GetProcessItemsSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes.items; +package org.alfresco.service.search.rest.workflow.processes.items; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/tasks/GetProcessTasksCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/tasks/GetProcessTasksCoreTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/workflow/processes/tasks/GetProcessTasksCoreTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/tasks/GetProcessTasksCoreTests.java index 93bb26a4b..3308fb9c5 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/tasks/GetProcessTasksCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/tasks/GetProcessTasksCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes.tasks; +package org.alfresco.service.search.rest.workflow.processes.tasks; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/tasks/GetProcessTasksFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/tasks/GetProcessTasksFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/processes/tasks/GetProcessTasksFullTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/tasks/GetProcessTasksFullTests.java index 5c7a98d65..23874c34e 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/tasks/GetProcessTasksFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/tasks/GetProcessTasksFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes.tasks; +package org.alfresco.service.search.rest.workflow.processes.tasks; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/tasks/GetProcessTasksSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/tasks/GetProcessTasksSanityTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/workflow/processes/tasks/GetProcessTasksSanityTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/tasks/GetProcessTasksSanityTests.java index d0c5f0efd..d5ac28a3e 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/tasks/GetProcessTasksSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/tasks/GetProcessTasksSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes.tasks; +package org.alfresco.service.search.rest.workflow.processes.tasks; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariableCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariableCoreTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariableCoreTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariableCoreTests.java index d1dc33782..63333851e 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariableCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariableCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes.variables; +package org.alfresco.service.search.rest.workflow.processes.variables; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.CMISUtil.Priority; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariableFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariableFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariableFullTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariableFullTests.java index 098a0658d..c69a0cbb2 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariableFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariableFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes.variables; +package org.alfresco.service.search.rest.workflow.processes.variables; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariableSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariableSanityTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariableSanityTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariableSanityTests.java index fed3c5c70..7bdf3774d 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariableSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariableSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes.variables; +package org.alfresco.service.search.rest.workflow.processes.variables; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariablesCoreTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesCoreTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariablesCoreTests.java index e597ddd50..817ebcf0c 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariablesCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes.variables; +package org.alfresco.service.search.rest.workflow.processes.variables; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariablesFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesFullTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariablesFullTests.java index ba28bd516..c8da63a34 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariablesFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes.variables; +package org.alfresco.service.search.rest.workflow.processes.variables; import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.CMISUtil.Priority; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariablesSanityTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesSanityTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariablesSanityTests.java index 26ce6bd8d..4787ccf92 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariablesSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes.variables; +package org.alfresco.service.search.rest.workflow.processes.variables; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/DeleteProcessVariableCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/DeleteProcessVariableCoreTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/workflow/processes/variables/DeleteProcessVariableCoreTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/DeleteProcessVariableCoreTests.java index 031f749b4..3f743b6e5 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/DeleteProcessVariableCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/DeleteProcessVariableCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes.variables; +package org.alfresco.service.search.rest.workflow.processes.variables; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/DeleteProcessVariableFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/DeleteProcessVariableFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/processes/variables/DeleteProcessVariableFullTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/DeleteProcessVariableFullTests.java index 9def8ff2b..1897a082a 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/DeleteProcessVariableFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/DeleteProcessVariableFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes.variables; +package org.alfresco.service.search.rest.workflow.processes.variables; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.CMISUtil.Priority; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/DeleteProcessVariableSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/DeleteProcessVariableSanityTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/workflow/processes/variables/DeleteProcessVariableSanityTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/DeleteProcessVariableSanityTests.java index cb43c40c8..ea2fdf1bd 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/DeleteProcessVariableSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/DeleteProcessVariableSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes.variables; +package org.alfresco.service.search.rest.workflow.processes.variables; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.CMISUtil.Priority; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/GetProcessVariablesCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/GetProcessVariablesCoreTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/workflow/processes/variables/GetProcessVariablesCoreTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/GetProcessVariablesCoreTests.java index 0b8c721b6..97cd43478 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/GetProcessVariablesCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/GetProcessVariablesCoreTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes.variables; +package org.alfresco.service.search.rest.workflow.processes.variables; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.CMISUtil.Priority; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/GetProcessVariablesFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/GetProcessVariablesFullTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/processes/variables/GetProcessVariablesFullTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/GetProcessVariablesFullTests.java index e7c841cd3..4ee163932 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/GetProcessVariablesFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/GetProcessVariablesFullTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes.variables; +package org.alfresco.service.search.rest.workflow.processes.variables; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/GetProcessVariablesSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/GetProcessVariablesSanityTests.java similarity index 97% rename from e2e-test/java/org/alfresco/rest/workflow/processes/variables/GetProcessVariablesSanityTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/GetProcessVariablesSanityTests.java index 9cb56b95f..e820d852a 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/GetProcessVariablesSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/GetProcessVariablesSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes.variables; +package org.alfresco.service.search.rest.workflow.processes.variables; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/UpdateProcessVariableTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/UpdateProcessVariableTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/processes/variables/UpdateProcessVariableTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/UpdateProcessVariableTests.java index 140966bce..9bf2d5de7 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/variables/UpdateProcessVariableTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/UpdateProcessVariableTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.processes.variables; +package org.alfresco.service.search.rest.workflow.processes.variables; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/GetTaskFormModelTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/GetTaskFormModelTests.java index dec930fdb..9a3a2c070 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/GetTaskFormModelTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks; +package org.alfresco.service.search.rest.workflow.tasks; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/GetTaskTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/GetTaskTests.java index 1aec76b5d..9bfb02727 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/GetTaskTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks; +package org.alfresco.service.search.rest.workflow.tasks; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/GetTasksTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/GetTasksTests.java index eb28d7c31..10d45413c 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/GetTasksTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks; +package org.alfresco.service.search.rest.workflow.tasks; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.CMISUtil.Priority; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/UpdateTaskTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/UpdateTaskTests.java index 6f069d2ff..1e17d6f5a 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/UpdateTaskTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks; +package org.alfresco.service.search.rest.workflow.tasks; import java.util.HashMap; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/candidates/GetTaskCandidatesRegressionTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/candidates/GetTaskCandidatesRegressionTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/candidates/GetTaskCandidatesRegressionTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/candidates/GetTaskCandidatesRegressionTests.java index 5e8d3d09f..da241d245 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/candidates/GetTaskCandidatesRegressionTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/candidates/GetTaskCandidatesRegressionTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks.candidates; +package org.alfresco.service.search.rest.workflow.tasks.candidates; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/candidates/GetTaskCandidatesSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/candidates/GetTaskCandidatesSanityTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/candidates/GetTaskCandidatesSanityTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/candidates/GetTaskCandidatesSanityTests.java index b9fd88f1a..497314093 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/candidates/GetTaskCandidatesSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/candidates/GetTaskCandidatesSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks.candidates; +package org.alfresco.service.search.rest.workflow.tasks.candidates; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemTestsBulk1.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/AddTaskItemTestsBulk1.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemTestsBulk1.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/AddTaskItemTestsBulk1.java index e0bb0e483..6d3908293 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemTestsBulk1.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/AddTaskItemTestsBulk1.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks.items; +package org.alfresco.service.search.rest.workflow.tasks.items; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemTestsBulk2.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/AddTaskItemTestsBulk2.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemTestsBulk2.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/AddTaskItemTestsBulk2.java index b54d54193..d46f258eb 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemTestsBulk2.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/AddTaskItemTestsBulk2.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks.items; +package org.alfresco.service.search.rest.workflow.tasks.items; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemTestsBulk3.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/AddTaskItemTestsBulk3.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemTestsBulk3.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/AddTaskItemTestsBulk3.java index fd6a130c5..d0efc888a 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemTestsBulk3.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/AddTaskItemTestsBulk3.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks.items; +package org.alfresco.service.search.rest.workflow.tasks.items; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/items/GetTaskItemsRegressionTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/GetTaskItemsRegressionTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/items/GetTaskItemsRegressionTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/GetTaskItemsRegressionTests.java index e8841828f..858e87f95 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/items/GetTaskItemsRegressionTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/GetTaskItemsRegressionTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks.items; +package org.alfresco.service.search.rest.workflow.tasks.items; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.CMISUtil.Priority; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/items/GetTaskItemsSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/GetTaskItemsSanityTests.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/items/GetTaskItemsSanityTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/GetTaskItemsSanityTests.java index 594ea0449..d75a9b6b5 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/items/GetTaskItemsSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/GetTaskItemsSanityTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks.items; +package org.alfresco.service.search.rest.workflow.tasks.items; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/items/RemoveTaskItemTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/RemoveTaskItemTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/items/RemoveTaskItemTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/RemoveTaskItemTests.java index 7eeb25407..0158b1d5a 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/items/RemoveTaskItemTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/RemoveTaskItemTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks.items; +package org.alfresco.service.search.rest.workflow.tasks.items; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk1.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk1.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk1.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk1.java index 03dac2155..44274ee30 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk1.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk1.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks.variables; +package org.alfresco.service.search.rest.workflow.tasks.variables; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk2.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk2.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk2.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk2.java index fd2704692..a3688fe2f 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk2.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk2.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks.variables; +package org.alfresco.service.search.rest.workflow.tasks.variables; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk3.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk3.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk3.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk3.java index e81e3f0b5..5ea48bf1f 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk3.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk3.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks.variables; +package org.alfresco.service.search.rest.workflow.tasks.variables; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/DeleteTaskVariableTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/DeleteTaskVariableTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/variables/DeleteTaskVariableTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/DeleteTaskVariableTests.java index 4a046ce6d..0f1e0a7fb 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/DeleteTaskVariableTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/DeleteTaskVariableTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks.variables; +package org.alfresco.service.search.rest.workflow.tasks.variables; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/GetTaskVariablesTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/GetTaskVariablesTests.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/variables/GetTaskVariablesTests.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/GetTaskVariablesTests.java index 90a07ba9d..d20ba6bd9 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/GetTaskVariablesTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/GetTaskVariablesTests.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks.variables; +package org.alfresco.service.search.rest.workflow.tasks.variables; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk1.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk1.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk1.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk1.java index c3718b38f..82b3a7fdc 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk1.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk1.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks.variables; +package org.alfresco.service.search.rest.workflow.tasks.variables; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk2.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk2.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk2.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk2.java index 53fe2f6a2..e9705cc38 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk2.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk2.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks.variables; +package org.alfresco.service.search.rest.workflow.tasks.variables; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk3.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk3.java similarity index 99% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk3.java rename to e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk3.java index 156be6a2e..b55b7961b 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk3.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk3.java @@ -1,4 +1,4 @@ -package org.alfresco.rest.workflow.tasks.variables; +package org.alfresco.service.search.rest.workflow.tasks.variables; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; From 39aea400e774638824a718f837ae51cfcce1654b Mon Sep 17 00:00:00 2001 From: agazzarini Date: Fri, 29 Mar 2019 17:15:01 +0100 Subject: [PATCH 1480/1491] [ SEARCH-1485 ] removed imports from test-restapi:tests classifier --- .../service/search/rest/FunctionalCasesTests.java | 1 - .../alfresco/service/search/rest/NetworkDataPrep.java | 1 - .../service/search/rest/actions/ActionsTests.java | 2 +- .../alfresco/service/search/rest/aos/AosApiTest.java | 2 +- .../alfresco/service/search/rest/audit/AuditTest.java | 2 +- .../alfresco/service/search/rest/auth/AuthTests.java | 2 +- .../service/search/rest/cmis/CmisBrowserTest.java | 2 +- .../service/search/rest/comments/AddCommentTests.java | 2 +- .../service/search/rest/comments/AddCommentsTests.java | 2 +- .../search/rest/comments/DeleteCommentTests.java | 2 +- .../service/search/rest/comments/GetCommentsTests.java | 2 +- .../search/rest/comments/UpdateCommentTests.java | 2 +- .../service/search/rest/demo/RestDemoTests.java | 2 +- .../service/search/rest/demo/SampleCommentsTests.java | 2 +- .../service/search/rest/demo/SamplePeopleTests.java | 2 +- .../service/search/rest/demo/SampleSitesTests.java | 2 +- .../search/rest/demo/workshop/RestApiDemoTests.java | 2 +- .../rest/demo/workshop/RestApiWorkshopTests.java | 2 +- .../service/search/rest/discovery/DiscoveryTests.java | 2 +- .../service/search/rest/downloads/DownloadsTests.java | 2 +- .../search/rest/favorites/AddFavoriteSiteTests.java | 2 +- .../search/rest/favorites/AddFavoritesTests.java | 2 +- .../search/rest/favorites/DeleteFavoriteSiteTests.java | 2 +- .../search/rest/favorites/DeleteFavoriteTests.java | 2 +- .../rest/favorites/FavoritesIncludePathTests.java | 2 +- .../search/rest/favorites/FavoritesNetworkTests.java | 2 +- .../search/rest/favorites/GetFavoriteSiteTests.java | 2 +- .../search/rest/favorites/GetFavoriteSitesTests.java | 2 +- .../search/rest/favorites/GetFavoriteTests.java | 2 +- .../search/rest/favorites/GetFavoritesTests.java | 2 +- .../service/search/rest/groups/GroupsTests.java | 2 +- .../rest/networks/RestGetNetworkForPersonTests.java | 2 +- .../search/rest/networks/RestGetNetworkTests.java | 2 +- .../rest/networks/RestGetNetworksForPersonTests.java | 2 +- .../search/rest/nodes/NodesActionDefinitionTests.java | 2 +- .../rest/nodes/NodesContentAndVersioningTests.java | 2 +- .../service/search/rest/nodes/NodesLockTests.java | 2 +- .../search/rest/nodes/NodesParentChildrenTests.java | 2 +- .../search/rest/nodes/NodesTargetSourcesTests.java | 2 +- .../alfresco/service/search/rest/nodes/NodesTests.java | 2 +- .../service/search/rest/nodes/NodesUnlockTests.java | 2 +- .../search/rest/people/AvatarPeopleSanityTest.java | 2 +- .../search/rest/people/DeleteSiteMemberCoreTests.java | 2 +- .../search/rest/people/DeleteSiteMemberFullTests.java | 2 +- .../rest/people/DeleteSiteMemberSanityTests.java | 2 +- .../service/search/rest/people/GetPeopleCoreTests.java | 2 +- .../service/search/rest/people/GetPeopleFullTests.java | 2 +- .../search/rest/people/GetPeopleSanityTests.java | 2 +- .../search/rest/people/GetSiteMembershipCoreTests.java | 2 +- .../search/rest/people/GetSiteMembershipFullTests.java | 2 +- .../rest/people/GetSiteMembershipSanityTests.java | 2 +- .../people/GetSitesMembershipInformationCoreTests.java | 2 +- .../people/GetSitesMembershipInformationFullTests.java | 2 +- .../GetSitesMembershipInformationSanityTests.java | 2 +- .../activities/GetPeopleActivitiesCoreTests.java | 2 +- .../activities/GetPeopleActivitiesFullTests.java | 2 +- .../activities/GetPeopleActivitiesSanityTests.java | 2 +- .../preferences/GetPeoplePreferenceCoreTests.java | 2 +- .../preferences/GetPeoplePreferenceFullTests.java | 2 +- .../preferences/GetPeoplePreferenceSanityTests.java | 2 +- .../preferences/GetPeoplePreferencesCoreTests.java | 2 +- .../preferences/GetPeoplePreferencesFullTests.java | 2 +- .../preferences/GetPeoplePreferencesSanityTests.java | 2 +- .../service/search/rest/queries/QueriesTest.java | 2 +- .../service/search/rest/ratings/AddRatingTests.java | 2 +- .../service/search/rest/ratings/DeleteRatingTests.java | 2 +- .../service/search/rest/ratings/GetRatingTests.java | 2 +- .../service/search/rest/ratings/GetRatingsTests.java | 2 +- .../search/rest/renditions/CreateRenditionTests.java | 2 +- .../search/rest/renditions/GetRenditionTests.java | 2 +- .../rest/renditions/RenditionIntegrationTests.java | 2 +- .../service/search/rest/search/AbstractSearchTest.java | 4 ++-- .../search/rest/search/FacetFieldsSearchTest.java | 1 - .../search/rest/search/FacetIntervalSearchTest.java | 2 -- .../search/rest/search/FacetRangeSearchTest.java | 3 ++- .../search/rest/search/PivotFacetedSearchTest.java | 2 +- .../search/rest/search/SearchHighLightTest.java | 2 -- .../search/rest/search/SearchSpellCheckTest.java | 2 +- .../service/search/rest/search/SearchTest.java | 10 +++++----- .../search/sql/SearchSQLWithQuotedIdentifiers.java | 2 +- .../rest/sharedLinks/GetSharedLinksFullTests.java | 2 +- .../rest/sharedLinks/SharedLinksSanityTests.java | 2 +- .../service/search/rest/sites/GetSiteTests.java | 2 +- .../service/search/rest/sites/GetSitesTests.java | 2 +- .../service/search/rest/sites/SitesNetworkTests.java | 2 +- .../alfresco/service/search/rest/sites/SitesTests.java | 2 +- .../rest/sites/containers/GetSiteContainerTests.java | 2 +- .../rest/sites/containers/GetSiteContainersTests.java | 2 +- .../search/rest/sites/members/AddSiteMemberTests.java | 2 +- .../search/rest/sites/members/GetSiteMemberTests.java | 2 +- .../search/rest/sites/members/GetSiteMembersTests.java | 2 +- .../rest/sites/members/RemoveSiteMemberTests.java | 2 +- .../rest/sites/members/UpdateSiteMemberTests.java | 2 +- .../AddSiteMembershipRequestTests.java | 2 +- .../DeleteSiteMembershipRequestTests.java | 2 +- .../GetSiteMembershipRequestTests.java | 2 +- .../GetSiteMembershipRequestsTests.java | 2 +- .../UpdateSiteMembershipRequestTests.java | 2 +- .../search/rest/syncService/SyncServiceAPITests.java | 2 +- .../service/search/rest/tags/TagsDataPrep.java | 2 +- .../search/rest/trashcan/GetDeletedNodesTests.java | 2 +- .../rest/workflow/WorkflowNetworkDeploymentsTests.java | 2 +- .../WorkflowNetworkProcessDefinitionsTests.java | 2 +- .../rest/workflow/WorkflowNetworkProcessesTests.java | 2 +- .../rest/workflow/WorkflowNetworkTasksTests.java | 2 +- .../workflow/deployments/DeleteDeploymentTests.java | 2 +- .../workflow/deployments/GetDeploymentCoreTests.java | 2 +- .../workflow/deployments/GetDeploymentFullTests.java | 2 +- .../workflow/deployments/GetDeploymentSanityTests.java | 2 +- .../workflow/deployments/GetDeploymentsCoreTests.java | 2 +- .../workflow/deployments/GetDeploymentsFullTests.java | 2 +- .../deployments/GetDeploymentsSanityTests.java | 2 +- .../GetProcessDefinitionCoreTests.java | 2 +- .../GetProcessDefinitionFullTests.java | 2 +- .../GetProcessDefinitionImageCoreTests.java | 2 +- .../GetProcessDefinitionImageFullTests.java | 2 +- .../GetProcessDefinitionImageSanityTests.java | 2 +- .../GetProcessDefinitionSanityTests.java | 2 +- .../GetProcessDefinitionStartFormModelCoreTests.java | 2 +- .../GetProcessDefinitionStartFormModelFullTests.java | 2 +- .../GetProcessDefinitionStartFormModelSanityTests.java | 2 +- .../GetProcessDefinitionsCoreTests.java | 2 +- .../GetProcessDefinitionsFullTests.java | 2 +- .../GetProcessDefinitionsSanityTests.java | 2 +- .../rest/workflow/processes/AddProcessCoreTests.java | 2 +- .../rest/workflow/processes/AddProcessFullTests.java | 2 +- .../rest/workflow/processes/AddProcessSanityTests.java | 2 +- .../workflow/processes/DeleteProcessCoreTests.java | 2 +- .../workflow/processes/DeleteProcessFullTests.java | 2 +- .../workflow/processes/DeleteProcessSanityTests.java | 2 +- .../rest/workflow/processes/GetProcessCoreTests.java | 2 +- .../rest/workflow/processes/GetProcessFullTests.java | 2 +- .../rest/workflow/processes/GetProcessSanityTests.java | 2 +- .../rest/workflow/processes/GetProcessesCoreTests.java | 2 +- .../rest/workflow/processes/GetProcessesFullTests.java | 2 +- .../workflow/processes/GetProcessesSanityTests.java | 2 +- .../processes/items/AddProcessItemCoreTests.java | 2 +- .../processes/items/AddProcessItemFullTests.java | 2 +- .../processes/items/AddProcessItemSanityTests.java | 2 +- .../processes/items/DeleteProcessItemCoreTests.java | 2 +- .../processes/items/DeleteProcessItemFullTests.java | 2 +- .../processes/items/DeleteProcessItemSanityTests.java | 2 +- .../processes/items/GetProcessItemsCoreTests.java | 2 +- .../processes/items/GetProcessItemsFullTests.java | 2 +- .../processes/items/GetProcessItemsSanityTests.java | 2 +- .../processes/tasks/GetProcessTasksCoreTests.java | 2 +- .../processes/tasks/GetProcessTasksFullTests.java | 2 +- .../processes/tasks/GetProcessTasksSanityTests.java | 2 +- .../variables/AddProcessVariableCoreTests.java | 2 +- .../variables/AddProcessVariableFullTests.java | 2 +- .../variables/AddProcessVariableSanityTests.java | 2 +- .../variables/AddProcessVariablesCoreTests.java | 2 +- .../variables/AddProcessVariablesFullTests.java | 2 +- .../variables/AddProcessVariablesSanityTests.java | 2 +- .../variables/DeleteProcessVariableCoreTests.java | 2 +- .../variables/DeleteProcessVariableFullTests.java | 2 +- .../variables/DeleteProcessVariableSanityTests.java | 2 +- .../variables/GetProcessVariablesCoreTests.java | 2 +- .../variables/GetProcessVariablesFullTests.java | 2 +- .../variables/GetProcessVariablesSanityTests.java | 2 +- .../variables/UpdateProcessVariableTests.java | 2 +- .../rest/workflow/tasks/GetTaskFormModelTests.java | 2 +- .../search/rest/workflow/tasks/GetTaskTests.java | 2 +- .../search/rest/workflow/tasks/GetTasksTests.java | 2 +- .../search/rest/workflow/tasks/UpdateTaskTests.java | 2 +- .../candidates/GetTaskCandidatesRegressionTests.java | 2 +- .../tasks/candidates/GetTaskCandidatesSanityTests.java | 2 +- .../workflow/tasks/items/AddTaskItemTestsBulk1.java | 2 +- .../workflow/tasks/items/AddTaskItemTestsBulk2.java | 2 +- .../workflow/tasks/items/AddTaskItemTestsBulk3.java | 2 +- .../tasks/items/GetTaskItemsRegressionTests.java | 2 +- .../workflow/tasks/items/GetTaskItemsSanityTests.java | 2 +- .../rest/workflow/tasks/items/RemoveTaskItemTests.java | 2 +- .../tasks/variables/AddTaskVariablesTestsBulk1.java | 2 +- .../tasks/variables/AddTaskVariablesTestsBulk2.java | 2 +- .../tasks/variables/AddTaskVariablesTestsBulk3.java | 2 +- .../tasks/variables/DeleteTaskVariableTests.java | 2 +- .../tasks/variables/GetTaskVariablesTests.java | 2 +- .../tasks/variables/UpdateTaskVariableTestsBulk1.java | 2 +- .../tasks/variables/UpdateTaskVariableTestsBulk2.java | 2 +- .../tasks/variables/UpdateTaskVariableTestsBulk3.java | 2 +- 181 files changed, 182 insertions(+), 188 deletions(-) diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/FunctionalCasesTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/FunctionalCasesTests.java index a23b246e6..2608e18db 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/FunctionalCasesTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/FunctionalCasesTests.java @@ -3,7 +3,6 @@ package org.alfresco.service.search.rest; import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.SiteService.Visibility; -import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestActivityModelsCollection; import org.alfresco.rest.model.RestCommentModel; import org.alfresco.rest.model.RestCommentModelsCollection; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/NetworkDataPrep.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/NetworkDataPrep.java index 8d6d5b422..f3903b106 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/NetworkDataPrep.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/NetworkDataPrep.java @@ -1,6 +1,5 @@ package org.alfresco.service.search.rest; -import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestNetworkModel; import org.alfresco.utility.model.UserModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/actions/ActionsTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/actions/ActionsTests.java index 3340ee1ff..b35a8251d 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/actions/ActionsTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/actions/ActionsTests.java @@ -5,7 +5,7 @@ import static org.testng.Assert.assertFalse; import com.google.common.collect.ImmutableMap; import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestActionDefinitionModel; import org.alfresco.rest.model.RestActionDefinitionModelsCollection; import org.alfresco.rest.model.RestNodeModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/aos/AosApiTest.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/aos/AosApiTest.java index efe1da439..a8f596359 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/aos/AosApiTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/aos/AosApiTest.java @@ -1,6 +1,6 @@ package org.alfresco.service.search.rest.aos; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.core.RestRequest; import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/audit/AuditTest.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/audit/AuditTest.java index 22fe23df1..78b973100 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/audit/AuditTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/audit/AuditTest.java @@ -3,7 +3,7 @@ package org.alfresco.service.search.rest.audit; import static org.hamcrest.Matchers.is; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.core.RestResponse; import org.alfresco.rest.core.RestWrapper; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/auth/AuthTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/auth/AuthTests.java index d7ed5aa73..4ddbc61d8 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/auth/AuthTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/auth/AuthTests.java @@ -1,6 +1,6 @@ package org.alfresco.service.search.rest.auth; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.core.RestWrapper; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestTicketBodyModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/cmis/CmisBrowserTest.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/cmis/CmisBrowserTest.java index 302aa0a69..56e99e3a2 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/cmis/CmisBrowserTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/cmis/CmisBrowserTest.java @@ -1,7 +1,7 @@ package org.alfresco.service.search.rest.cmis; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.core.RestResponse; import org.alfresco.utility.model.FileModel; import org.testng.annotations.Test; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/comments/AddCommentTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/comments/AddCommentTests.java index 2b4d51b24..f4eb84930 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/comments/AddCommentTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/comments/AddCommentTests.java @@ -2,7 +2,7 @@ package org.alfresco.service.search.rest.comments; import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestCommentModel; import org.alfresco.rest.model.RestCommentModelsCollection; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/comments/AddCommentsTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/comments/AddCommentsTests.java index 482dba09f..77984666c 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/comments/AddCommentsTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/comments/AddCommentsTests.java @@ -4,7 +4,7 @@ import java.util.List; import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.core.JsonBodyGenerator; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.exception.JsonToModelConversionException; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/comments/DeleteCommentTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/comments/DeleteCommentTests.java index 40260a1a8..ee44818cc 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/comments/DeleteCommentTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/comments/DeleteCommentTests.java @@ -1,7 +1,7 @@ package org.alfresco.service.search.rest.comments; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestCommentModel; import org.alfresco.rest.model.RestCommentModelsCollection; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/comments/GetCommentsTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/comments/GetCommentsTests.java index d213863e5..23670eb81 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/comments/GetCommentsTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/comments/GetCommentsTests.java @@ -1,7 +1,7 @@ package org.alfresco.service.search.rest.comments; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestCommentModelsCollection; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.constants.UserRole; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/comments/UpdateCommentTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/comments/UpdateCommentTests.java index cdf4cfbf5..5ee3a596f 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/comments/UpdateCommentTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/comments/UpdateCommentTests.java @@ -2,7 +2,7 @@ package org.alfresco.service.search.rest.comments; import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestCommentModel; import org.alfresco.rest.model.RestCommentModelsCollection; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/RestDemoTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/RestDemoTests.java index 0a7a6e9d6..0792a9bc4 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/RestDemoTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/RestDemoTests.java @@ -2,7 +2,7 @@ package org.alfresco.service.search.rest.demo; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.SiteService.Visibility; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.exception.DataPreparationException; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/SampleCommentsTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/SampleCommentsTests.java index fdb43d8d0..d7cd27d76 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/SampleCommentsTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/SampleCommentsTests.java @@ -1,7 +1,7 @@ package org.alfresco.service.search.rest.demo; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestCommentModel; import org.alfresco.utility.model.FileModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/SamplePeopleTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/SamplePeopleTests.java index 4c803b4b8..38ae35e47 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/SamplePeopleTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/SamplePeopleTests.java @@ -1,6 +1,6 @@ package org.alfresco.service.search.rest.demo; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.UserModel; import org.apache.commons.lang3.RandomStringUtils; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/SampleSitesTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/SampleSitesTests.java index 38fd2d1a8..1c66115ab 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/SampleSitesTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/SampleSitesTests.java @@ -1,6 +1,6 @@ package org.alfresco.service.search.rest.demo; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.exception.DataPreparationException; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/workshop/RestApiDemoTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/workshop/RestApiDemoTests.java index d1953cea0..fa450616e 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/workshop/RestApiDemoTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/workshop/RestApiDemoTests.java @@ -1,6 +1,6 @@ package org.alfresco.service.search.rest.demo.workshop; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/workshop/RestApiWorkshopTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/workshop/RestApiWorkshopTests.java index efbc0e431..49f7fce0d 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/workshop/RestApiWorkshopTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/workshop/RestApiWorkshopTests.java @@ -1,6 +1,6 @@ package org.alfresco.service.search.rest.demo.workshop; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.testng.annotations.Test; /** diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/discovery/DiscoveryTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/discovery/DiscoveryTests.java index 8e2ab0145..50763752c 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/discovery/DiscoveryTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/discovery/DiscoveryTests.java @@ -7,7 +7,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.core.RestResponse; import org.alfresco.rest.model.RestDiscoveryModel; import org.alfresco.utility.model.TestGroup; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/downloads/DownloadsTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/downloads/DownloadsTests.java index 76c74bcc3..f903b1376 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/downloads/DownloadsTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/downloads/DownloadsTests.java @@ -3,7 +3,7 @@ package org.alfresco.service.search.rest.downloads; import javax.json.JsonObject; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.core.JsonBodyGenerator; import org.alfresco.rest.model.RestDownloadsModel; import org.alfresco.utility.Utility; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/AddFavoriteSiteTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/AddFavoriteSiteTests.java index 74f05a42e..087d19a4f 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/AddFavoriteSiteTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/AddFavoriteSiteTests.java @@ -1,7 +1,7 @@ package org.alfresco.service.search.rest.favorites; import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.model.RestCommentModel; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/AddFavoritesTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/AddFavoritesTests.java index d6c969625..3adeb9a4c 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/AddFavoritesTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/AddFavoritesTests.java @@ -1,7 +1,7 @@ package org.alfresco.service.search.rest.favorites; import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.*; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/DeleteFavoriteSiteTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/DeleteFavoriteSiteTests.java index e7240beb6..17574ca2f 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/DeleteFavoriteSiteTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/DeleteFavoriteSiteTests.java @@ -1,6 +1,6 @@ package org.alfresco.service.search.rest.favorites; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/DeleteFavoriteTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/DeleteFavoriteTests.java index 997c9f386..3706ede36 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/DeleteFavoriteTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/DeleteFavoriteTests.java @@ -1,7 +1,7 @@ package org.alfresco.service.search.rest.favorites; import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/FavoritesIncludePathTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/FavoritesIncludePathTests.java index d1f521bca..c0f43ceef 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/FavoritesIncludePathTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/FavoritesIncludePathTests.java @@ -3,7 +3,7 @@ package org.alfresco.service.search.rest.favorites; import static org.alfresco.utility.report.log.Step.STEP; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/FavoritesNetworkTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/FavoritesNetworkTests.java index ebdebfad7..54becb068 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/FavoritesNetworkTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/FavoritesNetworkTests.java @@ -1,6 +1,6 @@ package org.alfresco.service.search.rest.favorites; -import org.alfresco.rest.NetworkDataPrep; +import org.alfresco.service.search.rest.NetworkDataPrep; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/GetFavoriteSiteTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/GetFavoriteSiteTests.java index a20eda655..e2654df64 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/GetFavoriteSiteTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/GetFavoriteSiteTests.java @@ -2,7 +2,7 @@ package org.alfresco.service.search.rest.favorites; import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.SiteService; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestSiteModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/GetFavoriteSitesTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/GetFavoriteSitesTests.java index dbe564837..ed162d744 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/GetFavoriteSitesTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/GetFavoriteSitesTests.java @@ -1,6 +1,6 @@ package org.alfresco.service.search.rest.favorites; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestSiteModel; import org.alfresco.rest.model.RestSiteModelsCollection; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/GetFavoriteTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/GetFavoriteTests.java index 0dcc4c178..70cee947a 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/GetFavoriteTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/GetFavoriteTests.java @@ -2,7 +2,7 @@ package org.alfresco.service.search.rest.favorites; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.SiteService; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestPersonFavoritesModel; import org.alfresco.utility.constants.UserRole; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/GetFavoritesTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/GetFavoritesTests.java index 7fc493824..e73bd92dd 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/GetFavoritesTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/GetFavoritesTests.java @@ -1,7 +1,7 @@ package org.alfresco.service.search.rest.favorites; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestPersonFavoritesModel; import org.alfresco.rest.model.RestPersonFavoritesModelsCollection; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/groups/GroupsTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/groups/GroupsTests.java index 589bf3e1e..cbc87a06a 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/groups/GroupsTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/groups/GroupsTests.java @@ -5,7 +5,7 @@ import java.util.UUID; import javax.json.Json; import javax.json.JsonObject; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.utility.RetryOperation; import org.alfresco.utility.Utility; import org.alfresco.utility.model.TestGroup; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/networks/RestGetNetworkForPersonTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/networks/RestGetNetworkForPersonTests.java index 278c0bc10..1f0078dac 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/networks/RestGetNetworkForPersonTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/networks/RestGetNetworkForPersonTests.java @@ -2,7 +2,7 @@ package org.alfresco.service.search.rest.networks; import java.util.ArrayList; -import org.alfresco.rest.NetworkDataPrep; +import org.alfresco.service.search.rest.NetworkDataPrep; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestNetworkQuotaModel; import org.alfresco.utility.model.TestGroup; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/networks/RestGetNetworkTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/networks/RestGetNetworkTests.java index 2f60f4c19..8bc917e1e 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/networks/RestGetNetworkTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/networks/RestGetNetworkTests.java @@ -1,6 +1,6 @@ package org.alfresco.service.search.rest.networks; -import org.alfresco.rest.NetworkDataPrep; +import org.alfresco.service.search.rest.NetworkDataPrep; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestNetworkModel; import org.alfresco.utility.model.TestGroup; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/networks/RestGetNetworksForPersonTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/networks/RestGetNetworksForPersonTests.java index fd6848127..db118a56d 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/networks/RestGetNetworksForPersonTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/networks/RestGetNetworksForPersonTests.java @@ -1,6 +1,6 @@ package org.alfresco.service.search.rest.networks; -import org.alfresco.rest.NetworkDataPrep; +import org.alfresco.service.search.rest.NetworkDataPrep; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestNetworkModelsCollection; import org.alfresco.utility.model.TestGroup; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesActionDefinitionTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesActionDefinitionTests.java index 07860a156..a82c602a8 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesActionDefinitionTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesActionDefinitionTests.java @@ -3,7 +3,7 @@ package org.alfresco.service.search.rest.nodes; import static org.testng.Assert.assertFalse; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestActionDefinitionModelsCollection; import org.alfresco.rest.model.builder.NodesBuilder; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesContentAndVersioningTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesContentAndVersioningTests.java index ba1c15567..97dbfbc18 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesContentAndVersioningTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesContentAndVersioningTests.java @@ -14,7 +14,7 @@ import java.io.IOException; import java.io.RandomAccessFile; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.core.JsonBodyGenerator; import org.alfresco.rest.core.RestResponse; import org.alfresco.rest.model.RestNodeModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesLockTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesLockTests.java index b85b7dcb3..dc05c3602 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesLockTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesLockTests.java @@ -1,7 +1,7 @@ package org.alfresco.service.search.rest.nodes; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestNodeModel; import org.alfresco.rest.model.body.RestNodeLockBodyModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesParentChildrenTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesParentChildrenTests.java index 8cb5d82da..d2f525553 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesParentChildrenTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesParentChildrenTests.java @@ -2,7 +2,7 @@ package org.alfresco.service.search.rest.nodes; import static org.alfresco.utility.report.log.Step.STEP; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestNodeBodyModel; import org.alfresco.rest.model.RestNodeChildAssocModelCollection; import org.alfresco.rest.model.RestNodeChildAssociationModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesTargetSourcesTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesTargetSourcesTests.java index 489a9007b..d6fe35259 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesTargetSourcesTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesTargetSourcesTests.java @@ -2,7 +2,7 @@ package org.alfresco.service.search.rest.nodes; import static org.alfresco.utility.report.log.Step.STEP; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestNodeAssocTargetModel; import org.alfresco.rest.model.RestNodeAssociationModelCollection; import org.alfresco.rest.model.builder.NodesBuilder; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesTests.java index d8453e80c..9a3866989 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesTests.java @@ -1,6 +1,6 @@ package org.alfresco.service.search.rest.nodes; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestNodeBodyMoveCopyModel; import org.alfresco.rest.model.RestNodeModel; import org.alfresco.rest.model.builder.NodesBuilder; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesUnlockTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesUnlockTests.java index 788685149..488dd854d 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesUnlockTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesUnlockTests.java @@ -3,7 +3,7 @@ package org.alfresco.service.search.rest.nodes; import static org.alfresco.utility.report.log.Step.STEP; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestNodeModel; import org.alfresco.rest.model.body.RestNodeLockBodyModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/AvatarPeopleSanityTest.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/AvatarPeopleSanityTest.java index 90b64b771..46e4cd71c 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/AvatarPeopleSanityTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/AvatarPeopleSanityTest.java @@ -5,7 +5,7 @@ import static org.testng.Assert.assertTrue; import java.io.File; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.utility.Utility; import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.TestGroup; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/DeleteSiteMemberCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/DeleteSiteMemberCoreTests.java index 1c06c6403..32a8b8e53 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/DeleteSiteMemberCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/DeleteSiteMemberCoreTests.java @@ -1,6 +1,6 @@ package org.alfresco.service.search.rest.people; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.model.SiteModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/DeleteSiteMemberFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/DeleteSiteMemberFullTests.java index d10e7aee6..fe7336390 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/DeleteSiteMemberFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/DeleteSiteMemberFullTests.java @@ -1,6 +1,6 @@ package org.alfresco.service.search.rest.people; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/DeleteSiteMemberSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/DeleteSiteMemberSanityTests.java index 033ec7751..d76871c62 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/DeleteSiteMemberSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/DeleteSiteMemberSanityTests.java @@ -1,6 +1,6 @@ package org.alfresco.service.search.rest.people; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.constants.UserRole; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetPeopleCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetPeopleCoreTests.java index 2fabbf450..2ff985718 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetPeopleCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetPeopleCoreTests.java @@ -1,6 +1,6 @@ package org.alfresco.service.search.rest.people; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.model.SiteModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetPeopleFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetPeopleFullTests.java index 83795ff2b..454500cc3 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetPeopleFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetPeopleFullTests.java @@ -1,6 +1,6 @@ package org.alfresco.service.search.rest.people; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.model.RestPersonModel; import org.alfresco.rest.model.RestPersonModelsCollection; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetPeopleSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetPeopleSanityTests.java index 9ceb6f3e6..e4937bba5 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetPeopleSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetPeopleSanityTests.java @@ -1,6 +1,6 @@ package org.alfresco.service.search.rest.people; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestPersonModel; import org.alfresco.utility.constants.UserRole; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSiteMembershipCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSiteMembershipCoreTests.java index a5b68ea32..22d5c0292 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSiteMembershipCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSiteMembershipCoreTests.java @@ -1,6 +1,6 @@ package org.alfresco.service.search.rest.people; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestSiteEntry; import org.alfresco.utility.constants.UserRole; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSiteMembershipFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSiteMembershipFullTests.java index 54e6aa8a8..30b8a4771 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSiteMembershipFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSiteMembershipFullTests.java @@ -1,6 +1,6 @@ package org.alfresco.service.search.rest.people; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestSiteEntry; import org.alfresco.utility.constants.UserRole; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSiteMembershipSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSiteMembershipSanityTests.java index f12ce12ff..e1639d7e3 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSiteMembershipSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSiteMembershipSanityTests.java @@ -1,6 +1,6 @@ package org.alfresco.service.search.rest.people; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.constants.UserRole; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSitesMembershipInformationCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSitesMembershipInformationCoreTests.java index 602c89a4f..21c503948 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSitesMembershipInformationCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSitesMembershipInformationCoreTests.java @@ -1,6 +1,6 @@ package org.alfresco.service.search.rest.people; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.exception.DataPreparationException; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSitesMembershipInformationFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSitesMembershipInformationFullTests.java index 7ace01c68..26278e8f7 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSitesMembershipInformationFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSitesMembershipInformationFullTests.java @@ -1,6 +1,6 @@ package org.alfresco.service.search.rest.people; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestSiteMembershipModelsCollection; import org.alfresco.rest.model.RestTaskModel; import org.alfresco.utility.constants.UserRole; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSitesMembershipInformationSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSitesMembershipInformationSanityTests.java index 067f7abee..53b9c935f 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSitesMembershipInformationSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSitesMembershipInformationSanityTests.java @@ -1,6 +1,6 @@ package org.alfresco.service.search.rest.people; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.constants.UserRole; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/activities/GetPeopleActivitiesCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/activities/GetPeopleActivitiesCoreTests.java index 4eb1711fd..af25befea 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/activities/GetPeopleActivitiesCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/activities/GetPeopleActivitiesCoreTests.java @@ -1,7 +1,7 @@ package org.alfresco.service.search.rest.people.activities; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestActivityModelsCollection; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.constants.UserRole; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/activities/GetPeopleActivitiesFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/activities/GetPeopleActivitiesFullTests.java index d1c8d8219..6e31e1b6a 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/activities/GetPeopleActivitiesFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/activities/GetPeopleActivitiesFullTests.java @@ -1,7 +1,7 @@ package org.alfresco.service.search.rest.people.activities; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestActivityModel; import org.alfresco.rest.model.RestActivityModelsCollection; import org.alfresco.rest.model.RestActivitySummaryModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/activities/GetPeopleActivitiesSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/activities/GetPeopleActivitiesSanityTests.java index 193621c37..f31460a15 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/activities/GetPeopleActivitiesSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/activities/GetPeopleActivitiesSanityTests.java @@ -1,7 +1,7 @@ package org.alfresco.service.search.rest.people.activities; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestActivityModelsCollection; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.constants.UserRole; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferenceCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferenceCoreTests.java index d6093c3ac..7dd7ad1cf 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferenceCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferenceCoreTests.java @@ -1,6 +1,6 @@ package org.alfresco.service.search.rest.people.preferences; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.constants.PreferenceName; import org.alfresco.utility.model.SiteModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferenceFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferenceFullTests.java index 806d475dd..ee07f650a 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferenceFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferenceFullTests.java @@ -2,7 +2,7 @@ package org.alfresco.service.search.rest.people.preferences; import java.nio.file.Paths; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestPreferenceModel; import org.alfresco.utility.Utility; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferenceSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferenceSanityTests.java index 07484fd53..bc668d8cd 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferenceSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferenceSanityTests.java @@ -1,6 +1,6 @@ package org.alfresco.service.search.rest.people.preferences; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestPreferenceModel; import org.alfresco.utility.constants.PreferenceName; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferencesCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferencesCoreTests.java index f3c511b71..ea1942fe5 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferencesCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferencesCoreTests.java @@ -1,6 +1,6 @@ package org.alfresco.service.search.rest.people.preferences; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestPreferenceModelsCollection; import org.alfresco.utility.constants.PreferenceName; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferencesFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferencesFullTests.java index 99d2f0220..f48d41a7b 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferencesFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferencesFullTests.java @@ -1,6 +1,6 @@ package org.alfresco.service.search.rest.people.preferences; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestPreferenceModelsCollection; import org.alfresco.utility.constants.PreferenceName; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferencesSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferencesSanityTests.java index e48a9527e..4b7e657a4 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferencesSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferencesSanityTests.java @@ -1,6 +1,6 @@ package org.alfresco.service.search.rest.people.preferences; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestPreferenceModelsCollection; import org.alfresco.utility.constants.PreferenceName; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/queries/QueriesTest.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/queries/QueriesTest.java index c85222e79..5d83550eb 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/queries/QueriesTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/queries/QueriesTest.java @@ -3,7 +3,7 @@ package org.alfresco.service.search.rest.queries; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestNodeModelsCollection; import org.alfresco.rest.model.RestPersonModelsCollection; import org.alfresco.rest.model.RestSiteModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/ratings/AddRatingTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/ratings/AddRatingTests.java index 407b71359..18d3d4c23 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/ratings/AddRatingTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/ratings/AddRatingTests.java @@ -1,11 +1,11 @@ package org.alfresco.service.search.rest.ratings; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestCommentModel; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestRatingModel; import org.alfresco.rest.model.RestTagModel; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.exception.DataPreparationException; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/ratings/DeleteRatingTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/ratings/DeleteRatingTests.java index 849a1ec70..829febf57 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/ratings/DeleteRatingTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/ratings/DeleteRatingTests.java @@ -1,7 +1,7 @@ package org.alfresco.service.search.rest.ratings; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestRatingModel; import org.alfresco.rest.model.RestRatingModelsCollection; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/ratings/GetRatingTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/ratings/GetRatingTests.java index 54700fa59..71acd3a6c 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/ratings/GetRatingTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/ratings/GetRatingTests.java @@ -1,10 +1,10 @@ package org.alfresco.service.search.rest.ratings; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestRatingModel; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.exception.DataPreparationException; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/ratings/GetRatingsTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/ratings/GetRatingsTests.java index 60f17ec8a..19cd55116 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/ratings/GetRatingsTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/ratings/GetRatingsTests.java @@ -2,7 +2,7 @@ package org.alfresco.service.search.rest.ratings; import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestRatingModelsCollection; import org.alfresco.utility.constants.UserRole; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/renditions/CreateRenditionTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/renditions/CreateRenditionTests.java index 0e7af8ef3..d7a85b429 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/renditions/CreateRenditionTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/renditions/CreateRenditionTests.java @@ -1,7 +1,7 @@ package org.alfresco.service.search.rest.renditions; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestNodeModel; import org.alfresco.utility.Utility; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/renditions/GetRenditionTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/renditions/GetRenditionTests.java index a6fce94f9..c917265ae 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/renditions/GetRenditionTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/renditions/GetRenditionTests.java @@ -3,7 +3,7 @@ package org.alfresco.service.search.rest.renditions; import static org.alfresco.utility.report.log.Step.STEP; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.core.RestResponse; import org.alfresco.rest.model.RestNodeModel; import org.alfresco.rest.model.RestRenditionInfoModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/renditions/RenditionIntegrationTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/renditions/RenditionIntegrationTests.java index d9769fcd7..ece6818aa 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/renditions/RenditionIntegrationTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/renditions/RenditionIntegrationTests.java @@ -1,6 +1,6 @@ package org.alfresco.service.search.rest.renditions; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.core.RestResponse; import org.alfresco.rest.model.RestNodeModel; import org.alfresco.utility.Utility; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/AbstractSearchTest.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/AbstractSearchTest.java index 1ea8d1ab8..ed3baba94 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/AbstractSearchTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/AbstractSearchTest.java @@ -19,7 +19,7 @@ package org.alfresco.service.search.rest.search; import org.alfresco.dataprep.SiteService.Visibility; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.core.RestResponse; import org.alfresco.rest.search.RestRequestHighlightModel; import org.alfresco.rest.search.RestRequestQueryModel; @@ -122,7 +122,7 @@ public class AbstractSearchTest extends RestTest } /** * Helper method which create an http post request to Search API end point. - * @param term String search term + * * @return {@link SearchResponse} response. * @throws Exception if error * diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/FacetFieldsSearchTest.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/FacetFieldsSearchTest.java index 356173e83..c6c60d8bd 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/FacetFieldsSearchTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/FacetFieldsSearchTest.java @@ -25,7 +25,6 @@ import javax.json.Json; import javax.json.JsonObject; import org.alfresco.dataprep.SiteService.Visibility; -import org.alfresco.rest.search.AbstractSearchTest; import org.alfresco.rest.search.FacetFieldBucket; import org.alfresco.rest.search.RestRequestFacetFieldModel; import org.alfresco.rest.search.RestRequestFacetFieldsModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/FacetIntervalSearchTest.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/FacetIntervalSearchTest.java index c01c6024c..b29671fd9 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/FacetIntervalSearchTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/FacetIntervalSearchTest.java @@ -19,7 +19,6 @@ package org.alfresco.service.search.rest.search; import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.search.AbstractSearchTest; import org.alfresco.rest.search.FacetInterval; import org.alfresco.rest.search.RestGenericBucketModel; import org.alfresco.rest.search.RestGenericFacetResponseModel; @@ -40,7 +39,6 @@ import java.util.Arrays; /** * Faceted Intervals Search Test * @author Gethin James - * */ public class FacetIntervalSearchTest extends AbstractSearchTest { diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/FacetRangeSearchTest.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/FacetRangeSearchTest.java index d1bf514f7..60d4a151c 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/FacetRangeSearchTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/FacetRangeSearchTest.java @@ -27,7 +27,7 @@ import java.util.Map; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestRequestRangesModel; -import org.alfresco.rest.search.AbstractSearchTest; +import org.alfresco.service.search.rest.search.AbstractSearchTest; import org.alfresco.rest.search.RestGenericBucketModel; import org.alfresco.rest.search.RestGenericFacetResponseModel; import org.alfresco.rest.search.SearchRequest; @@ -67,6 +67,7 @@ import org.testng.annotations.Test; * @author Michael Suzuki * */ +@SuppressWarnings("unchecked") public class FacetRangeSearchTest extends AbstractSearchTest { diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/PivotFacetedSearchTest.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/PivotFacetedSearchTest.java index eec830bbd..35d7f1c9c 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/PivotFacetedSearchTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/PivotFacetedSearchTest.java @@ -26,7 +26,7 @@ import java.util.List; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestRequestRangesModel; -import org.alfresco.rest.search.AbstractSearchTest; +import org.alfresco.service.search.rest.search.AbstractSearchTest; import org.alfresco.rest.search.Pagination; import org.alfresco.rest.search.RestGenericBucketModel; import org.alfresco.rest.search.RestGenericFacetResponseModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/SearchHighLightTest.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/SearchHighLightTest.java index 96e93a062..1c03c9b47 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/SearchHighLightTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/SearchHighLightTest.java @@ -21,7 +21,6 @@ package org.alfresco.service.search.rest.search; import java.util.ArrayList; import java.util.List; -import org.alfresco.rest.search.AbstractSearchTest; import org.alfresco.rest.search.ResponseHighLightModel; import org.alfresco.rest.search.RestRequestFieldsModel; import org.alfresco.rest.search.RestRequestHighlightModel; @@ -29,7 +28,6 @@ import org.alfresco.rest.search.RestRequestQueryModel; import org.alfresco.rest.search.SearchResponse; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.report.Bug; -import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; /** diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/SearchSpellCheckTest.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/SearchSpellCheckTest.java index 19e822682..aa75bc4a0 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/SearchSpellCheckTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/SearchSpellCheckTest.java @@ -19,7 +19,7 @@ package org.alfresco.service.search.rest.search; import org.alfresco.rest.model.RestRequestSpellcheckModel; -import org.alfresco.rest.search.AbstractSearchTest; +import org.alfresco.service.search.rest.search.AbstractSearchTest; import org.alfresco.rest.search.RestRequestQueryModel; import org.alfresco.rest.search.SearchRequest; import org.alfresco.rest.search.SearchResponse; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/SearchTest.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/SearchTest.java index edb496667..081a8fadc 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/SearchTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/SearchTest.java @@ -19,9 +19,9 @@ package org.alfresco.service.search.rest.search; import static java.util.Arrays.asList; +import static java.util.Collections.singletonList; import static java.util.Collections.reverse; -import static org.codehaus.groovy.runtime.InvokerHelper.asList; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.notNullValue; @@ -200,7 +200,7 @@ public class SearchTest extends AbstractSearchTest String include = "permissions"; SearchRequest retrievalQueryIncludingPermissionsInformation = createQuery(query); - retrievalQueryIncludingPermissionsInformation.setInclude(asList(include)); + retrievalQueryIncludingPermissionsInformation.setInclude(singletonList(include)); query(retrievalQueryIncludingPermissionsInformation); @@ -223,7 +223,7 @@ public class SearchTest extends AbstractSearchTest String include = "isLocked"; SearchRequest retrievalQueryIncludingLockInformation = createQuery(query); - retrievalQueryIncludingLockInformation.setInclude(asList(include)); + retrievalQueryIncludingLockInformation.setInclude(singletonList(include)); query(retrievalQueryIncludingLockInformation); @@ -257,7 +257,7 @@ public class SearchTest extends AbstractSearchTest String query = "fox"; String notValidInclude = "notValid"; SearchRequest permissionsRetrieval = createQuery(query); - permissionsRetrieval.setInclude(asList(notValidInclude)); + permissionsRetrieval.setInclude(singletonList(notValidInclude)); query(permissionsRetrieval); @@ -277,7 +277,7 @@ public class SearchTest extends AbstractSearchTest query.setQuery(queryReq); // Restrict to fields: parentId - List fields = new ArrayList(); + List fields = new ArrayList<>(); fields.add("parentId"); query.setFields(fields); diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/sql/SearchSQLWithQuotedIdentifiers.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/sql/SearchSQLWithQuotedIdentifiers.java index aed8d807f..4b7b36f1f 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/sql/SearchSQLWithQuotedIdentifiers.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/sql/SearchSQLWithQuotedIdentifiers.java @@ -20,7 +20,7 @@ package org.alfresco.service.search.rest.search.sql; import java.util.UUID; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.service.search.rest.search.AbstractSearchTest; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.CustomObjectTypeProperties; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/sharedLinks/GetSharedLinksFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sharedLinks/GetSharedLinksFullTests.java index b51ce650d..414f4537e 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/sharedLinks/GetSharedLinksFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/sharedLinks/GetSharedLinksFullTests.java @@ -4,7 +4,7 @@ import javax.json.Json; import javax.json.JsonObject; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestNodeModel; import org.alfresco.rest.model.RestSharedLinksModelCollection; import org.alfresco.utility.exception.DataPreparationException; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/sharedLinks/SharedLinksSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sharedLinks/SharedLinksSanityTests.java index 746910792..c7917d8dd 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/sharedLinks/SharedLinksSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/sharedLinks/SharedLinksSanityTests.java @@ -3,7 +3,7 @@ package org.alfresco.service.search.rest.sharedLinks; import javax.json.Json; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestRenditionInfoModel; import org.alfresco.rest.model.RestRenditionInfoModelCollection; import org.alfresco.rest.model.RestSharedLinksModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/GetSiteTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/GetSiteTests.java index bd74a6c89..7a2f5107b 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/GetSiteTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/GetSiteTests.java @@ -1,7 +1,7 @@ package org.alfresco.service.search.rest.sites; import org.alfresco.dataprep.SiteService; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.core.RestResponse; import org.alfresco.rest.model.*; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/GetSitesTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/GetSitesTests.java index 8234e69fe..2d986ab57 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/GetSitesTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/GetSitesTests.java @@ -1,7 +1,7 @@ package org.alfresco.service.search.rest.sites; import org.alfresco.dataprep.SiteService; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.*; import org.alfresco.utility.constants.ContainerName; import org.alfresco.utility.constants.UserRole; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/SitesNetworkTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/SitesNetworkTests.java index 3811d3cf4..ea3a9a2e3 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/SitesNetworkTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/SitesNetworkTests.java @@ -1,7 +1,7 @@ package org.alfresco.service.search.rest.sites; import org.alfresco.dataprep.SiteService; -import org.alfresco.rest.NetworkDataPrep; +import org.alfresco.service.search.rest.NetworkDataPrep; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestSiteMembershipRequestModel; import org.alfresco.utility.model.SiteModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/SitesTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/SitesTests.java index 03ed1aab2..6f2923d0b 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/SitesTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/SitesTests.java @@ -1,6 +1,6 @@ package org.alfresco.service.search.rest.sites; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestSiteModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/containers/GetSiteContainerTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/containers/GetSiteContainerTests.java index 60fc66501..94c2782b8 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/containers/GetSiteContainerTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/containers/GetSiteContainerTests.java @@ -1,6 +1,6 @@ package org.alfresco.service.search.rest.sites.containers; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestSiteContainerModel; import org.alfresco.utility.constants.ContainerName; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/containers/GetSiteContainersTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/containers/GetSiteContainersTests.java index a55f96b05..b6bd7cc8a 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/containers/GetSiteContainersTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/containers/GetSiteContainersTests.java @@ -1,6 +1,6 @@ package org.alfresco.service.search.rest.sites.containers; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestSiteContainerModelsCollection; import org.alfresco.utility.constants.ContainerName; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/AddSiteMemberTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/AddSiteMemberTests.java index bb943b4bb..7ce21de18 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/AddSiteMemberTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/AddSiteMemberTests.java @@ -1,6 +1,6 @@ package org.alfresco.service.search.rest.sites.members; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.core.JsonBodyGenerator; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/GetSiteMemberTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/GetSiteMemberTests.java index f33dcda18..9911bf47a 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/GetSiteMemberTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/GetSiteMemberTests.java @@ -1,6 +1,6 @@ package org.alfresco.service.search.rest.sites.members; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.constants.UserRole; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/GetSiteMembersTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/GetSiteMembersTests.java index 12831b14e..fdcf3def4 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/GetSiteMembersTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/GetSiteMembersTests.java @@ -1,6 +1,6 @@ package org.alfresco.service.search.rest.sites.members; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestSiteMemberModel; import org.alfresco.rest.model.RestSiteMemberModelsCollection; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/RemoveSiteMemberTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/RemoveSiteMemberTests.java index c858bf5c6..485305e59 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/RemoveSiteMemberTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/RemoveSiteMemberTests.java @@ -1,6 +1,6 @@ package org.alfresco.service.search.rest.sites.members; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/UpdateSiteMemberTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/UpdateSiteMemberTests.java index f95f7b96d..338bbc192 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/UpdateSiteMemberTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/UpdateSiteMemberTests.java @@ -1,6 +1,6 @@ package org.alfresco.service.search.rest.sites.members; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.core.JsonBodyGenerator; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/AddSiteMembershipRequestTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/AddSiteMembershipRequestTests.java index 1fc6f8f34..de28098b4 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/AddSiteMembershipRequestTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/AddSiteMembershipRequestTests.java @@ -1,7 +1,7 @@ package org.alfresco.service.search.rest.sites.membershipRequests; import org.alfresco.dataprep.SiteService; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestSiteEntry; import org.alfresco.rest.model.RestSiteMembershipRequestModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/DeleteSiteMembershipRequestTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/DeleteSiteMembershipRequestTests.java index 9ef32abb2..dd495422d 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/DeleteSiteMembershipRequestTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/DeleteSiteMembershipRequestTests.java @@ -1,7 +1,7 @@ package org.alfresco.service.search.rest.sites.membershipRequests; import org.alfresco.dataprep.SiteService.Visibility; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestSiteMembershipRequestModelsCollection; import org.alfresco.rest.model.RestTaskModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/GetSiteMembershipRequestTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/GetSiteMembershipRequestTests.java index e82752e0e..ed63a790b 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/GetSiteMembershipRequestTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/GetSiteMembershipRequestTests.java @@ -1,7 +1,7 @@ package org.alfresco.service.search.rest.sites.membershipRequests; import org.alfresco.dataprep.SiteService; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestSiteMembershipRequestModel; import org.alfresco.rest.model.RestTaskModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/GetSiteMembershipRequestsTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/GetSiteMembershipRequestsTests.java index 3671546dd..dbb5ef43f 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/GetSiteMembershipRequestsTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/GetSiteMembershipRequestsTests.java @@ -2,7 +2,7 @@ package org.alfresco.service.search.rest.sites.membershipRequests; import static org.alfresco.utility.report.log.Step.STEP; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.*; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/UpdateSiteMembershipRequestTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/UpdateSiteMembershipRequestTests.java index 8b0f31d97..8cb9af558 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/UpdateSiteMembershipRequestTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/UpdateSiteMembershipRequestTests.java @@ -1,6 +1,6 @@ package org.alfresco.service.search.rest.sites.membershipRequests; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestSiteMembershipRequestModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/syncService/SyncServiceAPITests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/syncService/SyncServiceAPITests.java index 896377507..4c79218af 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/syncService/SyncServiceAPITests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/syncService/SyncServiceAPITests.java @@ -3,7 +3,7 @@ package org.alfresco.service.search.rest.syncService; import java.util.LinkedList; import java.util.List; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestSubscriberModel; import org.alfresco.rest.model.RestSubscriberModelCollection; import org.alfresco.rest.model.RestSyncNodeSubscriptionModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/tags/TagsDataPrep.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/tags/TagsDataPrep.java index 4c87b3f52..974257df6 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/tags/TagsDataPrep.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/tags/TagsDataPrep.java @@ -1,7 +1,7 @@ package org.alfresco.service.search.rest.tags; import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestTagModel; import org.alfresco.rest.model.RestTagModelsCollection; import org.alfresco.utility.Utility; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/trashcan/GetDeletedNodesTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/trashcan/GetDeletedNodesTests.java index c3719afe8..02ea3f126 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/trashcan/GetDeletedNodesTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/trashcan/GetDeletedNodesTests.java @@ -16,7 +16,7 @@ package org.alfresco.service.search.rest.trashcan; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestNodeModel; import org.alfresco.rest.model.RestNodeModelsCollection; import org.alfresco.rest.model.RestRenditionInfoModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/WorkflowNetworkDeploymentsTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/WorkflowNetworkDeploymentsTests.java index 695d16df4..b28409dc0 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/WorkflowNetworkDeploymentsTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/WorkflowNetworkDeploymentsTests.java @@ -2,7 +2,7 @@ package org.alfresco.service.search.rest.workflow; import java.util.List; -import org.alfresco.rest.NetworkDataPrep; +import org.alfresco.service.search.rest.NetworkDataPrep; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestDeploymentModel; import org.alfresco.rest.model.RestDeploymentModelsCollection; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/WorkflowNetworkProcessDefinitionsTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/WorkflowNetworkProcessDefinitionsTests.java index 7de03cbfd..f20cb20dc 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/WorkflowNetworkProcessDefinitionsTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/WorkflowNetworkProcessDefinitionsTests.java @@ -1,7 +1,7 @@ package org.alfresco.service.search.rest.workflow; import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.rest.NetworkDataPrep; +import org.alfresco.service.search.rest.NetworkDataPrep; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessDefinitionModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/WorkflowNetworkProcessesTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/WorkflowNetworkProcessesTests.java index 2b6155747..866da43e5 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/WorkflowNetworkProcessesTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/WorkflowNetworkProcessesTests.java @@ -3,7 +3,6 @@ package org.alfresco.service.search.rest.workflow; import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.rest.NetworkDataPrep; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestItemModel; @@ -21,6 +20,7 @@ import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import org.alfresco.service.search.rest.NetworkDataPrep; public class WorkflowNetworkProcessesTests extends NetworkDataPrep { diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/WorkflowNetworkTasksTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/WorkflowNetworkTasksTests.java index 4f6774ac1..19be57be2 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/WorkflowNetworkTasksTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/WorkflowNetworkTasksTests.java @@ -3,7 +3,7 @@ package org.alfresco.service.search.rest.workflow; import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.rest.NetworkDataPrep; +import org.alfresco.service.search.rest.NetworkDataPrep; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestFormModelsCollection; import org.alfresco.rest.model.RestItemModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/DeleteDeploymentTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/DeleteDeploymentTests.java index 68b0f2e6a..244231747 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/DeleteDeploymentTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/DeleteDeploymentTests.java @@ -3,7 +3,7 @@ package org.alfresco.service.search.rest.workflow.deployments; import java.util.List; import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestDeploymentModel; import org.alfresco.rest.model.RestDeploymentModelsCollection; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentCoreTests.java index b7c53d8cc..29dcdcc91 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentCoreTests.java @@ -1,6 +1,6 @@ package org.alfresco.service.search.rest.workflow.deployments; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestDeploymentModel; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.model.TestGroup; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentFullTests.java index 102758b0f..bf55fb084 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentFullTests.java @@ -1,6 +1,6 @@ package org.alfresco.service.search.rest.workflow.deployments; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.model.RestDeploymentModel; import org.alfresco.rest.model.RestDeploymentModelsCollection; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentSanityTests.java index 02a7b29a5..74c4aa754 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentSanityTests.java @@ -1,6 +1,6 @@ package org.alfresco.service.search.rest.workflow.deployments; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestDeploymentModel; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentsCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentsCoreTests.java index 93dc839b8..406621f77 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentsCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentsCoreTests.java @@ -1,6 +1,6 @@ package org.alfresco.service.search.rest.workflow.deployments; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentsFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentsFullTests.java index e8d556be1..586711559 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentsFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentsFullTests.java @@ -1,6 +1,6 @@ package org.alfresco.service.search.rest.workflow.deployments; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestDeploymentModel; import org.alfresco.rest.model.RestDeploymentModelsCollection; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentsSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentsSanityTests.java index 9226f8803..2253c1df5 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentsSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentsSanityTests.java @@ -1,6 +1,6 @@ package org.alfresco.service.search.rest.workflow.deployments; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestDeploymentModelsCollection; import org.alfresco.utility.model.TestGroup; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionCoreTests.java index 648522b66..f1a1205f6 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionCoreTests.java @@ -1,6 +1,6 @@ package org.alfresco.service.search.rest.workflow.processDefinitions; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessDefinitionModel; import org.alfresco.utility.model.TestGroup; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionFullTests.java index 77166ef3e..601aeb14d 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionFullTests.java @@ -1,6 +1,6 @@ package org.alfresco.service.search.rest.workflow.processDefinitions; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.model.RestProcessDefinitionModel; import org.alfresco.rest.model.RestProcessDefinitionModelsCollection; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionImageCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionImageCoreTests.java index 94e8e72d3..9b5a2f64b 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionImageCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionImageCoreTests.java @@ -1,6 +1,6 @@ package org.alfresco.service.search.rest.workflow.processDefinitions; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessDefinitionModel; import org.alfresco.utility.model.TestGroup; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionImageFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionImageFullTests.java index e7e2887d1..194e0ebcc 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionImageFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionImageFullTests.java @@ -1,6 +1,6 @@ package org.alfresco.service.search.rest.workflow.processDefinitions; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestProcessDefinitionModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java index 18955b818..1e3c81cb7 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java @@ -1,6 +1,6 @@ package org.alfresco.service.search.rest.workflow.processDefinitions; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestProcessDefinitionModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java index aed83fb72..0ac6e6496 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java @@ -1,6 +1,6 @@ package org.alfresco.service.search.rest.workflow.processDefinitions; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestProcessDefinitionModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java index b3b3a1a33..4458d5b31 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java @@ -1,6 +1,6 @@ package org.alfresco.service.search.rest.workflow.processDefinitions; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessDefinitionModel; import org.alfresco.rest.model.RestProcessDefinitionModelsCollection; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelFullTests.java index fb9cd6703..dfd483433 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelFullTests.java @@ -2,7 +2,7 @@ package org.alfresco.service.search.rest.workflow.processDefinitions; import java.util.Arrays; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestFormModelsCollection; import org.alfresco.rest.model.RestProcessDefinitionModel; import org.alfresco.utility.model.TestGroup; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java index f966e5031..3309c3540 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java @@ -1,6 +1,6 @@ package org.alfresco.service.search.rest.workflow.processDefinitions; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestProcessDefinitionModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionsCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionsCoreTests.java index 6b6bea2cb..04849dd5e 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionsCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionsCoreTests.java @@ -1,6 +1,6 @@ package org.alfresco.service.search.rest.workflow.processDefinitions; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionsFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionsFullTests.java index 46dd92024..44b7d93bf 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionsFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionsFullTests.java @@ -1,6 +1,6 @@ package org.alfresco.service.search.rest.workflow.processDefinitions; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessDefinitionModel; import org.alfresco.rest.model.RestProcessDefinitionModelsCollection; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java index 55f96807e..69833ca4c 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java @@ -1,6 +1,6 @@ package org.alfresco.service.search.rest.workflow.processDefinitions; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestProcessDefinitionModelsCollection; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/AddProcessCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/AddProcessCoreTests.java index e68b088f2..8704b6147 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/AddProcessCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/AddProcessCoreTests.java @@ -1,7 +1,7 @@ package org.alfresco.service.search.rest.workflow.processes; import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/AddProcessFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/AddProcessFullTests.java index e7cd091e1..61b609c63 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/AddProcessFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/AddProcessFullTests.java @@ -3,7 +3,7 @@ package org.alfresco.service.search.rest.workflow.processes; import javax.json.JsonObject; import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.core.JsonBodyGenerator; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/AddProcessSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/AddProcessSanityTests.java index aeba6d7e4..4be323242 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/AddProcessSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/AddProcessSanityTests.java @@ -1,7 +1,7 @@ package org.alfresco.service.search.rest.workflow.processes; import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.rest.model.RestProcessModelsCollection; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/DeleteProcessCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/DeleteProcessCoreTests.java index afae4d6db..8d0525e1e 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/DeleteProcessCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/DeleteProcessCoreTests.java @@ -1,7 +1,7 @@ package org.alfresco.service.search.rest.workflow.processes; import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.utility.model.TestGroup; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/DeleteProcessFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/DeleteProcessFullTests.java index de176a36a..dad9826f2 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/DeleteProcessFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/DeleteProcessFullTests.java @@ -1,7 +1,7 @@ package org.alfresco.service.search.rest.workflow.processes; import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.utility.model.TestGroup; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/DeleteProcessSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/DeleteProcessSanityTests.java index efc3280ec..6cea148d8 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/DeleteProcessSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/DeleteProcessSanityTests.java @@ -1,7 +1,7 @@ package org.alfresco.service.search.rest.workflow.processes; import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessCoreTests.java index ba17f929d..bc97bb842 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessCoreTests.java @@ -1,7 +1,7 @@ package org.alfresco.service.search.rest.workflow.processes; import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.utility.model.TestGroup; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessFullTests.java index 1f4dba963..e7214bba5 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessFullTests.java @@ -1,7 +1,7 @@ package org.alfresco.service.search.rest.workflow.processes; import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestProcessDefinitionModel; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.utility.model.TestGroup; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessSanityTests.java index 08ca30dde..33649ebf5 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessSanityTests.java @@ -1,7 +1,7 @@ package org.alfresco.service.search.rest.workflow.processes; import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessesCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessesCoreTests.java index c3565f1a3..d2532d36a 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessesCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessesCoreTests.java @@ -3,7 +3,7 @@ package org.alfresco.service.search.rest.workflow.processes; import java.util.List; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestProcessDefinitionModel; import org.alfresco.rest.model.RestProcessModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessesFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessesFullTests.java index 2c9d01685..0c5b63b5e 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessesFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessesFullTests.java @@ -3,7 +3,7 @@ package org.alfresco.service.search.rest.workflow.processes; import java.util.List; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.rest.model.RestProcessModelsCollection; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessesSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessesSanityTests.java index 1d2e32b34..58d5b8032 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessesSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessesSanityTests.java @@ -1,7 +1,7 @@ package org.alfresco.service.search.rest.workflow.processes; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestProcessModelsCollection; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/AddProcessItemCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/AddProcessItemCoreTests.java index a49fad9e4..86e6d4489 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/AddProcessItemCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/AddProcessItemCoreTests.java @@ -1,7 +1,7 @@ package org.alfresco.service.search.rest.workflow.processes.items; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestItemModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/AddProcessItemFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/AddProcessItemFullTests.java index 420662910..49a8f28a2 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/AddProcessItemFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/AddProcessItemFullTests.java @@ -1,7 +1,7 @@ package org.alfresco.service.search.rest.workflow.processes.items; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestItemModel; import org.alfresco.rest.model.RestItemModelsCollection; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/AddProcessItemSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/AddProcessItemSanityTests.java index 9773d72df..e31365974 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/AddProcessItemSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/AddProcessItemSanityTests.java @@ -1,7 +1,7 @@ package org.alfresco.service.search.rest.workflow.processes.items; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestItemModel; import org.alfresco.rest.model.RestItemModelsCollection; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/DeleteProcessItemCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/DeleteProcessItemCoreTests.java index 037a5a162..ae9d60211 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/DeleteProcessItemCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/DeleteProcessItemCoreTests.java @@ -1,7 +1,7 @@ package org.alfresco.service.search.rest.workflow.processes.items; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestItemModel; import org.alfresco.rest.model.RestItemModelsCollection; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/DeleteProcessItemFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/DeleteProcessItemFullTests.java index c8847ecaa..2be92a1aa 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/DeleteProcessItemFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/DeleteProcessItemFullTests.java @@ -2,7 +2,7 @@ package org.alfresco.service.search.rest.workflow.processes.items; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.exception.EmptyRestModelCollectionException; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestItemModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/DeleteProcessItemSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/DeleteProcessItemSanityTests.java index 7f2661afc..341dc6fa1 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/DeleteProcessItemSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/DeleteProcessItemSanityTests.java @@ -1,7 +1,7 @@ package org.alfresco.service.search.rest.workflow.processes.items; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestItemModel; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.utility.model.FileModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/GetProcessItemsCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/GetProcessItemsCoreTests.java index 73a5a03b4..c121a9d47 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/GetProcessItemsCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/GetProcessItemsCoreTests.java @@ -1,7 +1,7 @@ package org.alfresco.service.search.rest.workflow.processes.items; import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.utility.model.FileModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/GetProcessItemsFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/GetProcessItemsFullTests.java index 4f37f5cc1..b22e118db 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/GetProcessItemsFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/GetProcessItemsFullTests.java @@ -1,7 +1,7 @@ package org.alfresco.service.search.rest.workflow.processes.items; import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestItemModelsCollection; import org.alfresco.rest.model.RestProcessModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/GetProcessItemsSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/GetProcessItemsSanityTests.java index 5276618ef..5b293fd0d 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/GetProcessItemsSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/GetProcessItemsSanityTests.java @@ -1,7 +1,7 @@ package org.alfresco.service.search.rest.workflow.processes.items; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestItemModelsCollection; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.utility.model.FileModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/tasks/GetProcessTasksCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/tasks/GetProcessTasksCoreTests.java index 3308fb9c5..fc6b6d3bc 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/tasks/GetProcessTasksCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/tasks/GetProcessTasksCoreTests.java @@ -1,7 +1,7 @@ package org.alfresco.service.search.rest.workflow.processes.tasks; import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestTaskModel; import org.alfresco.utility.model.FileModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/tasks/GetProcessTasksFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/tasks/GetProcessTasksFullTests.java index 23874c34e..bdd935e42 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/tasks/GetProcessTasksFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/tasks/GetProcessTasksFullTests.java @@ -1,7 +1,7 @@ package org.alfresco.service.search.rest.workflow.processes.tasks; import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestTaskModelsCollection; import org.alfresco.utility.model.*; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/tasks/GetProcessTasksSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/tasks/GetProcessTasksSanityTests.java index d5ac28a3e..f94b72e14 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/tasks/GetProcessTasksSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/tasks/GetProcessTasksSanityTests.java @@ -1,7 +1,7 @@ package org.alfresco.service.search.rest.workflow.processes.tasks; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestTaskModelsCollection; import org.alfresco.utility.model.FileModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariableCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariableCoreTests.java index 63333851e..cf2ddf39e 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariableCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariableCoreTests.java @@ -2,7 +2,7 @@ package org.alfresco.service.search.rest.workflow.processes.variables; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariableFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariableFullTests.java index c69a0cbb2..63abe5c76 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariableFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariableFullTests.java @@ -1,7 +1,7 @@ package org.alfresco.service.search.rest.workflow.processes.variables; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariableSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariableSanityTests.java index 7bdf3774d..bcdc5c7fc 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariableSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariableSanityTests.java @@ -1,7 +1,7 @@ package org.alfresco.service.search.rest.workflow.processes.variables; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.rest.model.RestProcessVariableModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariablesCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariablesCoreTests.java index 817ebcf0c..ca5ca5358 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariablesCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariablesCoreTests.java @@ -1,7 +1,7 @@ package org.alfresco.service.search.rest.workflow.processes.variables; import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.rest.model.RestProcessVariableModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariablesFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariablesFullTests.java index c8da63a34..88256f3b1 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariablesFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariablesFullTests.java @@ -2,7 +2,7 @@ package org.alfresco.service.search.rest.workflow.processes.variables; import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariablesSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariablesSanityTests.java index 4787ccf92..d11230ff6 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariablesSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariablesSanityTests.java @@ -1,7 +1,7 @@ package org.alfresco.service.search.rest.workflow.processes.variables; import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.rest.model.RestProcessVariableCollection; import org.alfresco.rest.model.RestProcessVariableModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/DeleteProcessVariableCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/DeleteProcessVariableCoreTests.java index 3f743b6e5..1e5681d81 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/DeleteProcessVariableCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/DeleteProcessVariableCoreTests.java @@ -1,7 +1,7 @@ package org.alfresco.service.search.rest.workflow.processes.variables; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/DeleteProcessVariableFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/DeleteProcessVariableFullTests.java index 1897a082a..a48260f8f 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/DeleteProcessVariableFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/DeleteProcessVariableFullTests.java @@ -2,7 +2,7 @@ package org.alfresco.service.search.rest.workflow.processes.variables; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.rest.model.RestProcessVariableModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/DeleteProcessVariableSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/DeleteProcessVariableSanityTests.java index ea2fdf1bd..d46a55890 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/DeleteProcessVariableSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/DeleteProcessVariableSanityTests.java @@ -2,7 +2,7 @@ package org.alfresco.service.search.rest.workflow.processes.variables; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.rest.model.RestProcessVariableModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/GetProcessVariablesCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/GetProcessVariablesCoreTests.java index 97cd43478..77abbdbf0 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/GetProcessVariablesCoreTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/GetProcessVariablesCoreTests.java @@ -2,7 +2,7 @@ package org.alfresco.service.search.rest.workflow.processes.variables; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.rest.model.RestProcessModelsCollection; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/GetProcessVariablesFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/GetProcessVariablesFullTests.java index 4ee163932..abbc93811 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/GetProcessVariablesFullTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/GetProcessVariablesFullTests.java @@ -1,7 +1,7 @@ package org.alfresco.service.search.rest.workflow.processes.variables; import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.rest.model.RestProcessVariableCollection; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/GetProcessVariablesSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/GetProcessVariablesSanityTests.java index e820d852a..77d769435 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/GetProcessVariablesSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/GetProcessVariablesSanityTests.java @@ -1,7 +1,7 @@ package org.alfresco.service.search.rest.workflow.processes.variables; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.rest.model.RestProcessVariableCollection; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/UpdateProcessVariableTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/UpdateProcessVariableTests.java index 9bf2d5de7..a504bd082 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/UpdateProcessVariableTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/UpdateProcessVariableTests.java @@ -1,7 +1,7 @@ package org.alfresco.service.search.rest.workflow.processes.variables; import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.rest.model.RestProcessVariableModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/GetTaskFormModelTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/GetTaskFormModelTests.java index 9a3a2c070..559fc29b9 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/GetTaskFormModelTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/GetTaskFormModelTests.java @@ -1,7 +1,7 @@ package org.alfresco.service.search.rest.workflow.tasks; import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.*; import org.alfresco.utility.model.*; import org.alfresco.utility.report.Bug; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/GetTaskTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/GetTaskTests.java index 9bfb02727..a09d69c39 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/GetTaskTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/GetTaskTests.java @@ -1,7 +1,7 @@ package org.alfresco.service.search.rest.workflow.tasks; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestTaskModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/GetTasksTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/GetTasksTests.java index 10d45413c..7f84dcbdf 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/GetTasksTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/GetTasksTests.java @@ -2,7 +2,7 @@ package org.alfresco.service.search.rest.workflow.tasks; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestTaskModel; import org.alfresco.rest.model.RestTaskModelsCollection; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/UpdateTaskTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/UpdateTaskTests.java index 1e17d6f5a..304f57b03 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/UpdateTaskTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/UpdateTaskTests.java @@ -6,7 +6,7 @@ import javax.json.JsonObject; import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.core.JsonBodyGenerator; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.model.RestErrorModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/candidates/GetTaskCandidatesRegressionTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/candidates/GetTaskCandidatesRegressionTests.java index da241d245..c3c9cc5fc 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/candidates/GetTaskCandidatesRegressionTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/candidates/GetTaskCandidatesRegressionTests.java @@ -1,7 +1,7 @@ package org.alfresco.service.search.rest.workflow.tasks.candidates; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestCandidateModelsCollection; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.model.FileModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/candidates/GetTaskCandidatesSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/candidates/GetTaskCandidatesSanityTests.java index 497314093..cbd17f10f 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/candidates/GetTaskCandidatesSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/candidates/GetTaskCandidatesSanityTests.java @@ -1,7 +1,7 @@ package org.alfresco.service.search.rest.workflow.tasks.candidates; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestCandidateModelsCollection; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.GroupModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/AddTaskItemTestsBulk1.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/AddTaskItemTestsBulk1.java index 6d3908293..84856161f 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/AddTaskItemTestsBulk1.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/AddTaskItemTestsBulk1.java @@ -1,7 +1,7 @@ package org.alfresco.service.search.rest.workflow.tasks.items; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestItemModel; import org.alfresco.rest.model.RestItemModelsCollection; import org.alfresco.utility.model.FileModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/AddTaskItemTestsBulk2.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/AddTaskItemTestsBulk2.java index d46f258eb..54ccf0cdc 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/AddTaskItemTestsBulk2.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/AddTaskItemTestsBulk2.java @@ -1,7 +1,7 @@ package org.alfresco.service.search.rest.workflow.tasks.items; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestVariableModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/AddTaskItemTestsBulk3.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/AddTaskItemTestsBulk3.java index d0efc888a..10bb83f4c 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/AddTaskItemTestsBulk3.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/AddTaskItemTestsBulk3.java @@ -1,7 +1,7 @@ package org.alfresco.service.search.rest.workflow.tasks.items; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestItemModel; import org.alfresco.rest.model.RestItemModelsCollection; import org.alfresco.utility.model.FileModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/GetTaskItemsRegressionTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/GetTaskItemsRegressionTests.java index 858e87f95..d1e3bd9ab 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/GetTaskItemsRegressionTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/GetTaskItemsRegressionTests.java @@ -2,7 +2,7 @@ package org.alfresco.service.search.rest.workflow.tasks.items; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestItemModel; import org.alfresco.rest.model.RestItemModelsCollection; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/GetTaskItemsSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/GetTaskItemsSanityTests.java index d75a9b6b5..42421e2dd 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/GetTaskItemsSanityTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/GetTaskItemsSanityTests.java @@ -1,7 +1,7 @@ package org.alfresco.service.search.rest.workflow.tasks.items; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestItemModel; import org.alfresco.rest.model.RestItemModelsCollection; import org.alfresco.utility.Utility; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/RemoveTaskItemTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/RemoveTaskItemTests.java index 0158b1d5a..6aa66a19f 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/RemoveTaskItemTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/RemoveTaskItemTests.java @@ -1,7 +1,7 @@ package org.alfresco.service.search.rest.workflow.tasks.items; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestItemModel; import org.alfresco.utility.model.*; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk1.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk1.java index 44274ee30..370df5668 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk1.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk1.java @@ -1,7 +1,7 @@ package org.alfresco.service.search.rest.workflow.tasks.variables; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestVariableModel; import org.alfresco.rest.model.RestVariableModelsCollection; import org.alfresco.utility.model.FileModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk2.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk2.java index a3688fe2f..bee35a55b 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk2.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk2.java @@ -1,7 +1,7 @@ package org.alfresco.service.search.rest.workflow.tasks.variables; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestVariableModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk3.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk3.java index 5ea48bf1f..c819511b9 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk3.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk3.java @@ -1,7 +1,7 @@ package org.alfresco.service.search.rest.workflow.tasks.variables; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestVariableModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/DeleteTaskVariableTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/DeleteTaskVariableTests.java index 0f1e0a7fb..8a41452c1 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/DeleteTaskVariableTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/DeleteTaskVariableTests.java @@ -1,7 +1,7 @@ package org.alfresco.service.search.rest.workflow.tasks.variables; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestVariableModel; import org.alfresco.utility.model.FileModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/GetTaskVariablesTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/GetTaskVariablesTests.java index d20ba6bd9..e0113fc4e 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/GetTaskVariablesTests.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/GetTaskVariablesTests.java @@ -1,7 +1,7 @@ package org.alfresco.service.search.rest.workflow.tasks.variables; import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.rest.model.RestTaskModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk1.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk1.java index 82b3a7fdc..4e2bed673 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk1.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk1.java @@ -1,7 +1,7 @@ package org.alfresco.service.search.rest.workflow.tasks.variables; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestVariableModel; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk2.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk2.java index e9705cc38..13b2ea472 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk2.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk2.java @@ -1,7 +1,7 @@ package org.alfresco.service.search.rest.workflow.tasks.variables; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestVariableModel; import org.alfresco.utility.model.FileModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk3.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk3.java index b55b7961b..30823d3a2 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk3.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk3.java @@ -1,7 +1,7 @@ package org.alfresco.service.search.rest.workflow.tasks.variables; import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; +import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.core.RestRequest; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestVariableModel; From b40586b72f50a38908e0db07c48eb7193e9b4348 Mon Sep 17 00:00:00 2001 From: agazzarini Date: Mon, 1 Apr 2019 10:16:43 +0200 Subject: [PATCH 1481/1491] [ SEARCH-1485 ] Merge FacetRangeSearchTest fix (change applied by Tom in TAS-RESTAPI repo) --- .../rest/search/AbstractSearchTest.java | 2 +- .../rest/search/FacetRangeSearchTest.java | 252 +++++++++--------- 2 files changed, 125 insertions(+), 129 deletions(-) diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/AbstractSearchTest.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/AbstractSearchTest.java index ed3baba94..9b85e5c8d 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/AbstractSearchTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/AbstractSearchTest.java @@ -141,7 +141,7 @@ public class AbstractSearchTest extends RestTest * @return {@link SearchResponse} response. * */ - protected SearchResponse query(SearchRequest query) throws Exception + protected SearchResponse query(SearchRequest query) { try { diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/FacetRangeSearchTest.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/FacetRangeSearchTest.java index 60d4a151c..30d534cc5 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/FacetRangeSearchTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/FacetRangeSearchTest.java @@ -20,6 +20,7 @@ package org.alfresco.service.search.rest.search; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; +import static org.testng.Assert.assertEquals; import java.util.ArrayList; import java.util.List; @@ -27,7 +28,6 @@ import java.util.Map; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestRequestRangesModel; -import org.alfresco.service.search.rest.search.AbstractSearchTest; import org.alfresco.rest.search.RestGenericBucketModel; import org.alfresco.rest.search.RestGenericFacetResponseModel; import org.alfresco.rest.search.SearchRequest; @@ -67,68 +67,66 @@ import org.testng.annotations.Test; * @author Michael Suzuki * */ -@SuppressWarnings("unchecked") public class FacetRangeSearchTest extends AbstractSearchTest { - @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, - description = "Check facet intervals mandatory fields") - public void checkingFacetsMandatoryErrorMessages()throws Exception + description = "Check facet intervals mandatory fields") + public void checkingFacetsMandatoryErrorMessages() { SearchRequest query = carsQuery(); - List ranges = new ArrayList(); + List ranges = new ArrayList<>(); RestRequestRangesModel facetRangeModel = new RestRequestRangesModel(); ranges.add(facetRangeModel); query.setRanges(ranges); query(query); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.MANDATORY_PARAM, "field")); + .containsSummary(String.format(RestErrorModel.MANDATORY_PARAM, "field")); ranges.clear(); facetRangeModel.setField("content.size"); ranges.add(facetRangeModel); query.setRanges(ranges); query(query); - + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.MANDATORY_PARAM, "start")); + .containsSummary(String.format(RestErrorModel.MANDATORY_PARAM, "start")); facetRangeModel.setStart("0"); ranges.clear(); ranges.add(facetRangeModel); query.setRanges(ranges); - + query(query); - + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.MANDATORY_PARAM, "end")); + .containsSummary(String.format(RestErrorModel.MANDATORY_PARAM, "end")); facetRangeModel.setEnd("400"); query.setRanges(ranges); ranges.clear(); ranges.add(facetRangeModel); - + query(query); - + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.MANDATORY_PARAM, "gap")); - + .containsSummary(String.format(RestErrorModel.MANDATORY_PARAM, "gap")); + facetRangeModel.setGap("100"); } @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, - description = "Check basic facet range search api") - public void searchWithRange()throws Exception + description = "Check basic facet range search api") + public void searchWithRange() { - SearchRequest query = createQuery("A*"); + SearchRequest query = createQuery("* AND SITE:'" + siteModel.getId() + "'"); RestRequestRangesModel facetRangeModel = new RestRequestRangesModel(); facetRangeModel.setField("content.size"); facetRangeModel.setStart("0"); - facetRangeModel.setEnd("500"); - facetRangeModel.setGap("200"); - List ranges = new ArrayList(); + facetRangeModel.setEnd("200"); + facetRangeModel.setGap("20"); + List ranges = new ArrayList<>(); ranges.add(facetRangeModel); query.setRanges(ranges); SearchResponse response = query(query); @@ -137,55 +135,53 @@ public class FacetRangeSearchTest extends AbstractSearchTest RestGenericFacetResponseModel facetResponseModel = response.getContext().getFacets().get(0); RestGenericBucketModel bucket = facetResponseModel.getBuckets().get(0); - bucket.assertThat().field("label").is("[0 - 200)"); - bucket.assertThat().field("filterQuery").is("content.size:[\"0\" TO \"200\">"); + bucket.assertThat().field("label").is("[20 - 40)"); + bucket.assertThat().field("filterQuery").is("content.size:[\"20\" TO \"40\">"); Map metric = (Map) bucket.getMetrics().get(0).getValue(); - Assert.assertTrue(Integer.valueOf(metric.get("count")) >= 4); + assertEquals(Integer.valueOf(metric.get("count")).intValue(), 2, "Unexpected count for first bucket."); Map info = (Map) bucket.getBucketInfo(); - Assert.assertEquals(info.get("start"),"0"); - Assert.assertEquals(info.get("end"),"200"); + assertEquals(info.get("start"),"20"); + assertEquals(info.get("end"),"40"); Assert.assertNull(info.get("count")); - Assert.assertEquals(info.get("startInclusive"),"true"); - Assert.assertEquals(info.get("endInclusive"),"false"); - + assertEquals(info.get("startInclusive"),"true"); + assertEquals(info.get("endInclusive"),"false"); + bucket = facetResponseModel.getBuckets().get(1); - bucket.assertThat().field("label").is("[200 - 400)"); - bucket.assertThat().field("filterQuery").is("content.size:[\"200\" TO \"400\">"); + bucket.assertThat().field("label").is("[40 - 120)"); + bucket.assertThat().field("filterQuery").is("content.size:[\"40\" TO \"120\">"); metric = (Map) bucket.getMetrics().get(0).getValue(); - Integer count = Integer.valueOf(metric.get("count")); - Assert.assertTrue(count >= 4); + assertEquals(Integer.valueOf(metric.get("count")).intValue(), 1, "Unexpected count for second bucket."); info = (Map) bucket.getBucketInfo(); - Assert.assertEquals(info.get("start"),"200"); - Assert.assertEquals(info.get("end"),"400"); - Assert.assertEquals(info.get("startInclusive"),"true"); - Assert.assertEquals(info.get("endInclusive"),"false"); - + assertEquals(info.get("start"),"40"); + assertEquals(info.get("end"),"120"); + assertEquals(info.get("startInclusive"),"true"); + assertEquals(info.get("endInclusive"),"false"); + bucket = facetResponseModel.getBuckets().get(2); - bucket.assertThat().field("label").is("[400 - 600]"); - bucket.assertThat().field("filterQuery").is("content.size:[\"400\" TO \"600\"]"); - metric = (Map) bucket.getMetrics().get(0).getValue(); - Assert.assertTrue(Integer.valueOf(metric.get("count")) >= 7); + bucket.assertThat().field("label").is("[120 - 200]"); + bucket.assertThat().field("filterQuery").is("content.size:[\"120\" TO \"200\"]"); + assertEquals(Integer.valueOf(metric.get("count")).intValue(), 1, "Unexpected count for third bucket."); info = (Map) bucket.getBucketInfo(); - Assert.assertEquals(info.get("start"),"400"); - Assert.assertEquals(info.get("end"),"600"); - Assert.assertEquals(info.get("startInclusive"),"true"); - Assert.assertEquals(info.get("endInclusive"),"true"); + assertEquals(info.get("start"),"120"); + assertEquals(info.get("end"),"200"); + assertEquals(info.get("startInclusive"),"true"); + assertEquals(info.get("endInclusive"),"true"); } @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, - description = "Check date facet intervals search api") - public void searchWithRangeHardend()throws Exception + description = "Check date facet intervals search api") + public void searchWithRangeHardend() { - SearchRequest query = createQuery("A*"); + SearchRequest query = createQuery("* AND SITE:'" + siteModel.getId() + "'"); RestRequestRangesModel facetRangeModel = new RestRequestRangesModel(); facetRangeModel.setField("content.size"); facetRangeModel.setStart("0"); - facetRangeModel.setEnd("500"); - facetRangeModel.setGap("200"); + facetRangeModel.setEnd("200"); + facetRangeModel.setGap("20"); facetRangeModel.setHardend(true); - List ranges = new ArrayList(); + List ranges = new ArrayList<>(); ranges.add(facetRangeModel); query.setRanges(ranges); SearchResponse response = query(query); @@ -194,45 +190,47 @@ public class FacetRangeSearchTest extends AbstractSearchTest RestGenericFacetResponseModel facetResponseModel = response.getContext().getFacets().get(0); RestGenericBucketModel bucket = facetResponseModel.getBuckets().get(0); - bucket.assertThat().field("label").is("[0 - 200)"); - bucket.assertThat().field("filterQuery").is("content.size:[\"0\" TO \"200\">"); + bucket.assertThat().field("label").is("[20 - 40)"); + bucket.assertThat().field("filterQuery").is("content.size:[\"20\" TO \"40\">"); Map metric = (Map) bucket.getMetrics().get(0).getValue(); - Assert.assertTrue(Integer.valueOf(metric.get("count")) >= 4); + assertEquals(Integer.valueOf(metric.get("count")).intValue(), 2, "Unexpected count for first bucket."); Map info = (Map) bucket.getBucketInfo(); - Assert.assertEquals(info.get("start"),"0"); - Assert.assertEquals(info.get("end"),"200"); - Assert.assertEquals(info.get("startInclusive"),"true"); - Assert.assertEquals(info.get("endInclusive"),"false"); + assertEquals(info.get("start"),"20"); + assertEquals(info.get("end"),"40"); + assertEquals(info.get("startInclusive"),"true"); + assertEquals(info.get("endInclusive"),"false"); Assert.assertNull(info.get("count")); - + bucket = facetResponseModel.getBuckets().get(1); - bucket.assertThat().field("label").is("[200 - 400)"); - bucket.assertThat().field("filterQuery").is("content.size:[\"200\" TO \"400\">"); + bucket.assertThat().field("label").is("[40 - 120)"); + bucket.assertThat().field("filterQuery").is("content.size:[\"40\" TO \"120\">"); info = (Map) bucket.getBucketInfo(); - Assert.assertEquals(info.get("start"),"200"); - Assert.assertEquals(info.get("end"),"400"); + assertEquals(info.get("start"),"40"); + assertEquals(info.get("end"),"120"); metric = (Map) bucket.getMetrics().get(0).getValue(); - Assert.assertTrue(Integer.valueOf(metric.get("count")) >= 4); + assertEquals(Integer.valueOf(metric.get("count")).intValue(), 1, "Unexpected count for second bucket."); Assert.assertNull(info.get("count")); - Assert.assertEquals(info.get("startInclusive"),"true"); - Assert.assertEquals(info.get("endInclusive"),"false"); - + assertEquals(info.get("startInclusive"),"true"); + assertEquals(info.get("endInclusive"),"false"); + bucket = facetResponseModel.getBuckets().get(2); - bucket.assertThat().field("label").is("[400 - 500]"); - bucket.assertThat().field("filterQuery").is("content.size:[\"400\" TO \"500\"]"); + bucket.assertThat().field("label").is("[120 - 200]"); + bucket.assertThat().field("filterQuery").is("content.size:[\"120\" TO \"200\"]"); metric = (Map) bucket.getMetrics().get(0).getValue(); - Assert.assertTrue(Integer.valueOf(metric.get("count")) >= 3); + assertEquals(Integer.valueOf(metric.get("count")).intValue(), 1, "Unexpected count for third bucket."); info = (Map) bucket.getBucketInfo(); - Assert.assertEquals(info.get("start"),"400"); - Assert.assertEquals(info.get("end"),"500"); + assertEquals(info.get("start"),"120"); + assertEquals(info.get("end"),"200"); Assert.assertNull(info.get("count")); - Assert.assertEquals(info.get("startInclusive"),"true"); - Assert.assertEquals(info.get("endInclusive"),"true"); + assertEquals(info.get("startInclusive"),"true"); + assertEquals(info.get("endInclusive"),"true"); } + + /** This test relies on a document created in 2015 existing, probably part of the sample site. */ @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_121 }) @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_121 }, executionType = ExecutionType.REGRESSION, - description = "Check date facet intervals search api") - public void searchDateRange()throws Exception + description = "Check date facet intervals search api") + public void searchDateRange() { SearchRequest query = createQuery("name:A*"); @@ -241,7 +239,7 @@ public class FacetRangeSearchTest extends AbstractSearchTest facetRangeModel.setStart("2015-09-29T10:45:15.729Z"); facetRangeModel.setEnd("2016-09-29T10:45:15.729Z"); facetRangeModel.setGap("+280DAY"); - List ranges = new ArrayList(); + List ranges = new ArrayList<>(); ranges.add(facetRangeModel); query.setRanges(ranges); SearchResponse response = query(query); @@ -251,26 +249,26 @@ public class FacetRangeSearchTest extends AbstractSearchTest List buckets = facetResponseModel.getBuckets(); assertThat(buckets.size(),is(1)); - + RestGenericBucketModel bucket = buckets.get(0); bucket.assertThat().field("label").is("[2015-09-29T10:45:15.729Z - 2017-04-11T10:45:15.729Z]"); bucket.assertThat().field("filterQuery").is("created:[\"2015-09-29T10:45:15.729Z\" TO \"2017-04-11T10:45:15.729Z\"]"); bucket.getMetrics().get(0).assertThat().field("value").is("{count=1}"); Map info = (Map) bucket.getBucketInfo(); - Assert.assertEquals(info.get("start"),"2015-09-29T10:45:15.729Z"); - Assert.assertEquals(info.get("end"),"2017-04-11T10:45:15.729Z"); + assertEquals(info.get("start"),"2015-09-29T10:45:15.729Z"); + assertEquals(info.get("end"),"2017-04-11T10:45:15.729Z"); Assert.assertNull(info.get("count"),"1"); - Assert.assertEquals(info.get("startInclusive"),"true"); - Assert.assertEquals(info.get("endInclusive"),"true"); + assertEquals(info.get("startInclusive"),"true"); + assertEquals(info.get("endInclusive"),"true"); } - + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, - description = "Check date facet intervals search api") - public void searchDateAndSizeRanges()throws Exception + description = "Check date facet intervals search api") + public void searchDateAndSizeRanges() { - SearchRequest query = createQuery("name:A*"); - List ranges = new ArrayList(); + SearchRequest query = createQuery("* AND SITE:'" + siteModel.getId() + "'"); + List ranges = new ArrayList<>(); RestRequestRangesModel facetRangeModel = new RestRequestRangesModel(); facetRangeModel.setField("created"); facetRangeModel.setStart("2015-09-29T10:45:15.729Z"); @@ -285,23 +283,23 @@ public class FacetRangeSearchTest extends AbstractSearchTest ranges.add(facetCountRangeModel); query.setRanges(ranges); } - + @Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }) @TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, - description = "Check basic facet range search api") - public void searchWithRangeAndIncludeUpperBound()throws Exception + description = "Check basic facet range search api") + public void searchWithRangeAndIncludeUpperBound() { - SearchRequest query = createQuery("A*"); + SearchRequest query = createQuery("* AND SITE:'" + siteModel.getId() + "'"); RestRequestRangesModel facetRangeModel = new RestRequestRangesModel(); facetRangeModel.setField("content.size"); facetRangeModel.setStart("0"); - facetRangeModel.setEnd("500"); - facetRangeModel.setGap("200"); - List include = new ArrayList(); + facetRangeModel.setEnd("200"); + facetRangeModel.setGap("20"); + List include = new ArrayList<>(); include.add("upper"); facetRangeModel.setInclude(include); - List ranges = new ArrayList(); + List ranges = new ArrayList<>(); ranges.add(facetRangeModel); query.setRanges(ranges); SearchResponse response = query(query); @@ -310,39 +308,37 @@ public class FacetRangeSearchTest extends AbstractSearchTest RestGenericFacetResponseModel facetResponseModel = response.getContext().getFacets().get(0); RestGenericBucketModel bucket = facetResponseModel.getBuckets().get(0); - bucket.assertThat().field("label").is("(0 - 200]"); - bucket.assertThat().field("filterQuery").is("content.size:<\"0\" TO \"200\"]"); + bucket.assertThat().field("label").is("(20 - 40]"); + bucket.assertThat().field("filterQuery").is("content.size:<\"20\" TO \"40\"]"); Map metric = (Map) bucket.getMetrics().get(0).getValue(); - Assert.assertTrue(Integer.valueOf(metric.get("count")) >= 4); + assertEquals(Integer.valueOf(metric.get("count")).intValue(), 2, "Unexpected count for first bucket."); Map info = (Map) bucket.getBucketInfo(); - Assert.assertEquals(info.get("start"),"0"); - Assert.assertEquals(info.get("end"),"200"); + assertEquals(info.get("start"),"20"); + assertEquals(info.get("end"),"40"); Assert.assertNull(info.get("count")); - Assert.assertEquals(info.get("startInclusive"),"false"); - Assert.assertEquals(info.get("endInclusive"),"true"); - - bucket = facetResponseModel.getBuckets().get(1); - bucket.assertThat().field("label").is("(200 - 400]"); - bucket.assertThat().field("filterQuery").is("content.size:<\"200\" TO \"400\"]"); - metric = (Map) bucket.getMetrics().get(0).getValue(); - Integer count = Integer.valueOf(metric.get("count")); - Assert.assertTrue(count >= 4); - info = (Map) bucket.getBucketInfo(); - Assert.assertEquals(info.get("start"),"200"); - Assert.assertEquals(info.get("end"),"400"); - Assert.assertEquals(info.get("startInclusive"),"false"); - Assert.assertEquals(info.get("endInclusive"),"true"); - - bucket = facetResponseModel.getBuckets().get(2); - bucket.assertThat().field("label").is("(400 - 600]"); - bucket.assertThat().field("filterQuery").is("content.size:<\"400\" TO \"600\"]"); - metric = (Map) bucket.getMetrics().get(0).getValue(); - Assert.assertTrue(Integer.valueOf(metric.get("count")) >= 7); - info = (Map) bucket.getBucketInfo(); - Assert.assertEquals(info.get("start"),"400"); - Assert.assertEquals(info.get("end"),"600"); - Assert.assertEquals(info.get("startInclusive"),"false"); - Assert.assertEquals(info.get("endInclusive"),"true"); - } + assertEquals(info.get("startInclusive"),"false"); + assertEquals(info.get("endInclusive"),"true"); + bucket = facetResponseModel.getBuckets().get(1); + bucket.assertThat().field("label").is("(40 - 120]"); + bucket.assertThat().field("filterQuery").is("content.size:<\"40\" TO \"120\"]"); + metric = (Map) bucket.getMetrics().get(0).getValue(); + assertEquals(Integer.valueOf(metric.get("count")).intValue(), 1, "Unexpected count for second bucket."); + info = (Map) bucket.getBucketInfo(); + assertEquals(info.get("start"),"40"); + assertEquals(info.get("end"),"120"); + assertEquals(info.get("startInclusive"),"false"); + assertEquals(info.get("endInclusive"),"true"); + + bucket = facetResponseModel.getBuckets().get(2); + bucket.assertThat().field("label").is("(120 - 200]"); + bucket.assertThat().field("filterQuery").is("content.size:<\"120\" TO \"200\"]"); + metric = (Map) bucket.getMetrics().get(0).getValue(); + assertEquals(Integer.valueOf(metric.get("count")).intValue(), 1, "Unexpected count for third bucket."); + info = (Map) bucket.getBucketInfo(); + assertEquals(info.get("start"),"120"); + assertEquals(info.get("end"),"200"); + assertEquals(info.get("startInclusive"),"false"); + assertEquals(info.get("endInclusive"),"true"); + } } From 8be9c701dd1b4223720657b15d73698102af0c1d Mon Sep 17 00:00:00 2001 From: agazzarini Date: Mon, 1 Apr 2019 11:58:48 +0200 Subject: [PATCH 1482/1491] [ SEARCH-1485 ] Integrated a minor fix for SEARCH-1445 (as per suggestion by Elia) --- .../org/alfresco/service/search/rest/search/SearchTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/SearchTest.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/SearchTest.java index 081a8fadc..ebe7cd33b 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/SearchTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/rest/search/SearchTest.java @@ -64,15 +64,15 @@ public class SearchTest extends AbstractSearchTest @Test(groups={TestGroup.SEARCH, TestGroup.REST_API}) public void searchOnIndexedData() throws Exception - { - SearchResponse nodes = query(unique_searchString); + { + SearchResponse nodes = query("cm:content:" + unique_searchString); restClient.assertStatusCodeIs(HttpStatus.OK); nodes.assertThat().entriesListIsNotEmpty(); SearchNodeModel entity = nodes.getEntryByIndex(0); entity.assertThat().field("search").contains("score"); entity.getSearch().assertThat().field("score").isNotEmpty(); - Assert.assertEquals("pangram.txt",entity.getName()); + Assert.assertEquals(entity.getName(),"pangram.txt"); } @Test(groups={TestGroup.SEARCH,TestGroup.REST_API}) From 0bd9e955cdba4f3118b50804b65349d217e456d2 Mon Sep 17 00:00:00 2001 From: agazzarini Date: Mon, 1 Apr 2019 19:26:22 +0200 Subject: [PATCH 1483/1491] [ SEARCH-1485 ] search resources package renaming + remove non-search tests --- .../insightEngine}/sql/SearchSQLAPITest.java | 4 +- .../sql/SearchSQLPhraseTest.java | 4 +- .../sql/SearchSQLViaJDBCTest.java | 4 +- .../sql/SearchSQLWithQuotedIdentifiers.java | 6 +- .../searchservices}/AbstractSearchTest.java | 4 +- .../FacetFieldsSearchTest.java | 2 +- .../FacetIntervalSearchTest.java | 2 +- .../searchservices}/FacetRangeSearchTest.java | 2 +- .../searchservices}/FacetedSearchTest.java | 2 +- .../searchservices}/FingerPrintTest.java | 2 +- .../PivotFacetedSearchTest.java | 3 +- .../searchservices}/SearchAPATHTest.java | 2 +- .../searchservices}/SearchHighLightTest.java | 2 +- .../searchservices}/SearchSpellCheckTest.java | 3 +- .../searchservices}/SearchTest.java | 2 +- .../searchservices}/ShardInfoTest.java | 2 +- .../searchservices}/StatsSearchTest.java | 2 +- .../solr/SearchSolrAPITest.java | 4 +- .../search/rest/FunctionalCasesTests.java | 701 ------- .../service/search/rest/NetworkDataPrep.java | 45 - .../service/search/rest/RestTest.java | 85 - .../search/rest/actions/ActionsTests.java | 151 -- .../service/search/rest/aos/AosApiTest.java | 24 - .../service/search/rest/audit/AuditTest.java | 112 -- .../search/rest/audit/DeleteAuditTests.java | 67 - .../search/rest/audit/GetAuditTests.java | 358 ---- .../search/rest/audit/PutAuditTests.java | 112 -- .../service/search/rest/auth/AuthTests.java | 87 - .../search/rest/cmis/CmisBrowserTest.java | 25 - .../search/rest/comments/AddCommentTests.java | 260 --- .../rest/comments/AddCommentsTests.java | 377 ---- .../rest/comments/DeleteCommentTests.java | 295 --- .../rest/comments/GetCommentsTests.java | 422 ----- .../rest/comments/UpdateCommentTests.java | 461 ----- .../search/rest/demo/RestDemoTests.java | 104 -- .../search/rest/demo/SampleCommentsTests.java | 56 - .../search/rest/demo/SamplePeopleTests.java | 32 - .../search/rest/demo/SampleSitesTests.java | 79 - .../rest/demo/workshop/RestApiDemoTests.java | 52 - .../demo/workshop/RestApiWorkshopTests.java | 38 - .../search/rest/discovery/DiscoveryTests.java | 108 -- .../search/rest/downloads/DownloadsTests.java | 106 -- .../rest/favorites/AddFavoriteSiteTests.java | 487 ----- .../rest/favorites/AddFavoritesTests.java | 446 ----- .../favorites/DeleteFavoriteSiteTests.java | 364 ---- .../rest/favorites/DeleteFavoriteTests.java | 412 ----- .../favorites/FavoritesIncludePathTests.java | 143 -- .../rest/favorites/FavoritesNetworkTests.java | 292 --- .../rest/favorites/GetFavoriteSiteTests.java | 292 --- .../rest/favorites/GetFavoriteSitesTests.java | 325 ---- .../rest/favorites/GetFavoriteTests.java | 480 ----- .../rest/favorites/GetFavoritesTests.java | 555 ------ .../search/rest/groups/GroupsTests.java | 158 -- .../RestGetNetworkForPersonTests.java | 151 -- .../rest/networks/RestGetNetworkTests.java | 145 -- .../RestGetNetworksForPersonTests.java | 166 -- .../nodes/NodesActionDefinitionTests.java | 87 - .../nodes/NodesContentAndVersioningTests.java | 308 ---- .../search/rest/nodes/NodesLockTests.java | 761 -------- .../rest/nodes/NodesParentChildrenTests.java | 205 --- .../rest/nodes/NodesTargetSourcesTests.java | 120 -- .../service/search/rest/nodes/NodesTests.java | 56 - .../search/rest/nodes/NodesUnlockTests.java | 112 -- .../rest/people/AvatarPeopleSanityTest.java | 66 - .../people/DeleteSiteMemberCoreTests.java | 229 --- .../people/DeleteSiteMemberFullTests.java | 207 --- .../people/DeleteSiteMemberSanityTests.java | 111 -- .../rest/people/GetPeopleCoreTests.java | 57 - .../rest/people/GetPeopleFullTests.java | 88 - .../rest/people/GetPeopleSanityTests.java | 110 -- .../people/GetSiteMembershipCoreTests.java | 114 -- .../people/GetSiteMembershipFullTests.java | 138 -- .../people/GetSiteMembershipSanityTests.java | 90 - ...etSitesMembershipInformationCoreTests.java | 136 -- ...etSitesMembershipInformationFullTests.java | 205 --- ...SitesMembershipInformationSanityTests.java | 89 - .../GetPeopleActivitiesCoreTests.java | 126 -- .../GetPeopleActivitiesFullTests.java | 184 -- .../GetPeopleActivitiesSanityTests.java | 111 -- .../GetPeoplePreferenceCoreTests.java | 78 - .../GetPeoplePreferenceFullTests.java | 194 -- .../GetPeoplePreferenceSanityTests.java | 120 -- .../GetPeoplePreferencesCoreTests.java | 123 -- .../GetPeoplePreferencesFullTests.java | 114 -- .../GetPeoplePreferencesSanityTests.java | 121 -- .../search/rest/queries/QueriesTest.java | 178 -- .../search/rest/ratings/AddRatingTests.java | 818 -------- .../rest/ratings/DeleteRatingTests.java | 525 ------ .../search/rest/ratings/GetRatingTests.java | 438 ----- .../search/rest/ratings/GetRatingsTests.java | 313 ---- .../renditions/AvailableRenditionTests.java | 134 -- .../rest/renditions/CreateRenditionTests.java | 101 - .../rest/renditions/GetRenditionTests.java | 157 -- .../renditions/RenditionIntegrationTests.java | 81 - .../sharedLinks/GetSharedLinksFullTests.java | 75 - .../sharedLinks/SharedLinksSanityTests.java | 276 --- .../search/rest/sites/GetSiteTests.java | 362 ---- .../search/rest/sites/GetSitesTests.java | 484 ----- .../search/rest/sites/SitesNetworkTests.java | 85 - .../service/search/rest/sites/SitesTests.java | 36 - .../containers/GetSiteContainerTests.java | 304 --- .../containers/GetSiteContainersTests.java | 381 ---- .../sites/members/AddSiteMemberTests.java | 589 ------ .../sites/members/GetSiteMemberTests.java | 396 ---- .../sites/members/GetSiteMembersTests.java | 355 ---- .../sites/members/RemoveSiteMemberTests.java | 467 ----- .../sites/members/UpdateSiteMemberTests.java | 546 ------ .../AddSiteMembershipRequestTests.java | 409 ---- .../DeleteSiteMembershipRequestTests.java | 317 ---- .../GetSiteMembershipRequestTests.java | 332 ---- .../GetSiteMembershipRequestsTests.java | 421 ----- .../UpdateSiteMembershipRequestTests.java | 610 ------ .../rest/syncService/SyncServiceAPITests.java | 204 -- .../service/search/rest/tags/GetTagTests.java | 139 -- .../search/rest/tags/GetTagsTests.java | 230 --- .../search/rest/tags/TagsDataPrep.java | 70 - .../search/rest/tags/UpdateTagTests.java | 269 --- .../search/rest/tags/nodes/AddTagTests.java | 337 ---- .../search/rest/tags/nodes/AddTagsTests.java | 150 -- .../rest/tags/nodes/DeleteTagTests.java | 287 --- .../rest/tags/nodes/GetNodeTagsTests.java | 319 ---- .../rest/trashcan/GetDeletedNodesTests.java | 245 --- .../WorkflowNetworkDeploymentsTests.java | 124 -- ...orkflowNetworkProcessDefinitionsTests.java | 221 --- .../WorkflowNetworkProcessesTests.java | 540 ------ .../workflow/WorkflowNetworkTasksTests.java | 578 ------ .../deployments/DeleteDeploymentTests.java | 144 -- .../deployments/GetDeploymentCoreTests.java | 42 - .../deployments/GetDeploymentFullTests.java | 57 - .../deployments/GetDeploymentSanityTests.java | 57 - .../deployments/GetDeploymentsCoreTests.java | 30 - .../deployments/GetDeploymentsFullTests.java | 146 -- .../GetDeploymentsSanityTests.java | 44 - .../GetProcessDefinitionCoreTests.java | 45 - .../GetProcessDefinitionFullTests.java | 67 - .../GetProcessDefinitionImageCoreTests.java | 46 - .../GetProcessDefinitionImageFullTests.java | 42 - .../GetProcessDefinitionImageSanityTests.java | 49 - .../GetProcessDefinitionSanityTests.java | 62 - ...cessDefinitionStartFormModelCoreTests.java | 80 - ...cessDefinitionStartFormModelFullTests.java | 71 - ...ssDefinitionStartFormModelSanityTests.java | 38 - .../GetProcessDefinitionsCoreTests.java | 53 - .../GetProcessDefinitionsFullTests.java | 174 -- .../GetProcessDefinitionsSanityTests.java | 48 - .../processes/AddProcessCoreTests.java | 130 -- .../processes/AddProcessFullTests.java | 150 -- .../processes/AddProcessSanityTests.java | 44 - .../processes/DeleteProcessCoreTests.java | 69 - .../processes/DeleteProcessFullTests.java | 52 - .../processes/DeleteProcessSanityTests.java | 69 - .../processes/GetProcessCoreTests.java | 44 - .../processes/GetProcessFullTests.java | 85 - .../processes/GetProcessSanityTests.java | 62 - .../processes/GetProcessesCoreTests.java | 80 - .../processes/GetProcessesFullTests.java | 160 -- .../processes/GetProcessesSanityTests.java | 78 - .../items/AddProcessItemCoreTests.java | 181 -- .../items/AddProcessItemFullTests.java | 131 -- .../items/AddProcessItemSanityTests.java | 175 -- .../items/DeleteProcessItemCoreTests.java | 85 - .../items/DeleteProcessItemFullTests.java | 215 --- .../items/DeleteProcessItemSanityTests.java | 67 - .../items/GetProcessItemsCoreTests.java | 70 - .../items/GetProcessItemsFullTests.java | 198 -- .../items/GetProcessItemsSanityTests.java | 59 - .../tasks/GetProcessTasksCoreTests.java | 98 - .../tasks/GetProcessTasksFullTests.java | 207 --- .../tasks/GetProcessTasksSanityTests.java | 86 - .../AddProcessVariableCoreTests.java | 188 -- .../AddProcessVariableFullTests.java | 182 -- .../AddProcessVariableSanityTests.java | 95 - .../AddProcessVariablesCoreTests.java | 101 - .../AddProcessVariablesFullTests.java | 395 ---- .../AddProcessVariablesSanityTests.java | 158 -- .../DeleteProcessVariableCoreTests.java | 118 -- .../DeleteProcessVariableFullTests.java | 196 -- .../DeleteProcessVariableSanityTests.java | 69 - .../GetProcessVariablesCoreTests.java | 88 - .../GetProcessVariablesFullTests.java | 161 -- .../GetProcessVariablesSanityTests.java | 60 - .../variables/UpdateProcessVariableTests.java | 139 -- .../workflow/tasks/GetTaskFormModelTests.java | 256 --- .../rest/workflow/tasks/GetTaskTests.java | 212 --- .../rest/workflow/tasks/GetTasksTests.java | 234 --- .../rest/workflow/tasks/UpdateTaskTests.java | 1639 ----------------- .../GetTaskCandidatesRegressionTests.java | 268 --- .../GetTaskCandidatesSanityTests.java | 79 - .../tasks/items/AddTaskItemTestsBulk1.java | 158 -- .../tasks/items/AddTaskItemTestsBulk2.java | 175 -- .../tasks/items/AddTaskItemTestsBulk3.java | 128 -- .../items/GetTaskItemsRegressionTests.java | 260 --- .../tasks/items/GetTaskItemsSanityTests.java | 75 - .../tasks/items/RemoveTaskItemTests.java | 256 --- .../variables/AddTaskVariablesTestsBulk1.java | 198 -- .../variables/AddTaskVariablesTestsBulk2.java | 241 --- .../variables/AddTaskVariablesTestsBulk3.java | 155 -- .../variables/DeleteTaskVariableTests.java | 231 --- .../variables/GetTaskVariablesTests.java | 252 --- .../UpdateTaskVariableTestsBulk1.java | 79 - .../UpdateTaskVariableTestsBulk2.java | 173 -- .../UpdateTaskVariableTestsBulk3.java | 247 --- 202 files changed, 25 insertions(+), 37119 deletions(-) rename e2e-test/src/test/java/org/alfresco/service/search/{rest/search => e2e/insightEngine}/sql/SearchSQLAPITest.java (99%) rename e2e-test/src/test/java/org/alfresco/service/search/{rest/search => e2e/insightEngine}/sql/SearchSQLPhraseTest.java (99%) rename e2e-test/src/test/java/org/alfresco/service/search/{rest/search => e2e/insightEngine}/sql/SearchSQLViaJDBCTest.java (98%) rename e2e-test/src/test/java/org/alfresco/service/search/{rest/search => e2e/insightEngine}/sql/SearchSQLWithQuotedIdentifiers.java (98%) rename e2e-test/src/test/java/org/alfresco/service/search/{rest/search => e2e/searchservices}/AbstractSearchTest.java (99%) rename e2e-test/src/test/java/org/alfresco/service/search/{rest/search => e2e/searchservices}/FacetFieldsSearchTest.java (99%) rename e2e-test/src/test/java/org/alfresco/service/search/{rest/search => e2e/searchservices}/FacetIntervalSearchTest.java (99%) rename e2e-test/src/test/java/org/alfresco/service/search/{rest/search => e2e/searchservices}/FacetRangeSearchTest.java (99%) rename e2e-test/src/test/java/org/alfresco/service/search/{rest/search => e2e/searchservices}/FacetedSearchTest.java (99%) rename e2e-test/src/test/java/org/alfresco/service/search/{rest/search => e2e/searchservices}/FingerPrintTest.java (99%) rename e2e-test/src/test/java/org/alfresco/service/search/{rest/search => e2e/searchservices}/PivotFacetedSearchTest.java (99%) rename e2e-test/src/test/java/org/alfresco/service/search/{rest/search => e2e/searchservices}/SearchAPATHTest.java (99%) rename e2e-test/src/test/java/org/alfresco/service/search/{rest/search => e2e/searchservices}/SearchHighLightTest.java (98%) rename e2e-test/src/test/java/org/alfresco/service/search/{rest/search => e2e/searchservices}/SearchSpellCheckTest.java (98%) rename e2e-test/src/test/java/org/alfresco/service/search/{rest/search => e2e/searchservices}/SearchTest.java (99%) rename e2e-test/src/test/java/org/alfresco/service/search/{rest/search => e2e/searchservices}/ShardInfoTest.java (98%) rename e2e-test/src/test/java/org/alfresco/service/search/{rest/search => e2e/searchservices}/StatsSearchTest.java (99%) rename e2e-test/src/test/java/org/alfresco/service/search/{rest/search => e2e/searchservices}/solr/SearchSolrAPITest.java (97%) delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/FunctionalCasesTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/NetworkDataPrep.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/RestTest.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/actions/ActionsTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/aos/AosApiTest.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/audit/AuditTest.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/audit/DeleteAuditTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/audit/GetAuditTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/audit/PutAuditTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/auth/AuthTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/cmis/CmisBrowserTest.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/comments/AddCommentTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/comments/AddCommentsTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/comments/DeleteCommentTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/comments/GetCommentsTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/comments/UpdateCommentTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/demo/RestDemoTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/demo/SampleCommentsTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/demo/SamplePeopleTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/demo/SampleSitesTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/demo/workshop/RestApiDemoTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/demo/workshop/RestApiWorkshopTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/discovery/DiscoveryTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/downloads/DownloadsTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/AddFavoriteSiteTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/AddFavoritesTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/DeleteFavoriteSiteTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/DeleteFavoriteTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/FavoritesIncludePathTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/FavoritesNetworkTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/GetFavoriteSiteTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/GetFavoriteSitesTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/GetFavoriteTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/GetFavoritesTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/groups/GroupsTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/networks/RestGetNetworkForPersonTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/networks/RestGetNetworkTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/networks/RestGetNetworksForPersonTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesActionDefinitionTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesContentAndVersioningTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesLockTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesParentChildrenTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesTargetSourcesTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesUnlockTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/people/AvatarPeopleSanityTest.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/people/DeleteSiteMemberCoreTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/people/DeleteSiteMemberFullTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/people/DeleteSiteMemberSanityTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetPeopleCoreTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetPeopleFullTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetPeopleSanityTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSiteMembershipCoreTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSiteMembershipFullTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSiteMembershipSanityTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSitesMembershipInformationCoreTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSitesMembershipInformationFullTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSitesMembershipInformationSanityTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/people/activities/GetPeopleActivitiesCoreTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/people/activities/GetPeopleActivitiesFullTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/people/activities/GetPeopleActivitiesSanityTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferenceCoreTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferenceFullTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferenceSanityTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferencesCoreTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferencesFullTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferencesSanityTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/queries/QueriesTest.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/ratings/AddRatingTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/ratings/DeleteRatingTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/ratings/GetRatingTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/ratings/GetRatingsTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/renditions/AvailableRenditionTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/renditions/CreateRenditionTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/renditions/GetRenditionTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/renditions/RenditionIntegrationTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/sharedLinks/GetSharedLinksFullTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/sharedLinks/SharedLinksSanityTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/sites/GetSiteTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/sites/GetSitesTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/sites/SitesNetworkTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/sites/SitesTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/sites/containers/GetSiteContainerTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/sites/containers/GetSiteContainersTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/AddSiteMemberTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/GetSiteMemberTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/GetSiteMembersTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/RemoveSiteMemberTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/UpdateSiteMemberTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/AddSiteMembershipRequestTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/DeleteSiteMembershipRequestTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/GetSiteMembershipRequestTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/GetSiteMembershipRequestsTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/UpdateSiteMembershipRequestTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/syncService/SyncServiceAPITests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/tags/GetTagTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/tags/GetTagsTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/tags/TagsDataPrep.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/tags/UpdateTagTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/tags/nodes/AddTagTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/tags/nodes/AddTagsTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/tags/nodes/DeleteTagTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/tags/nodes/GetNodeTagsTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/trashcan/GetDeletedNodesTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/WorkflowNetworkDeploymentsTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/WorkflowNetworkProcessDefinitionsTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/WorkflowNetworkProcessesTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/WorkflowNetworkTasksTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/DeleteDeploymentTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentCoreTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentFullTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentSanityTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentsCoreTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentsFullTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentsSanityTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionCoreTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionFullTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionImageCoreTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionImageFullTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelFullTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionsCoreTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionsFullTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/AddProcessCoreTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/AddProcessFullTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/AddProcessSanityTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/DeleteProcessCoreTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/DeleteProcessFullTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/DeleteProcessSanityTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessCoreTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessFullTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessSanityTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessesCoreTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessesFullTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessesSanityTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/AddProcessItemCoreTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/AddProcessItemFullTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/AddProcessItemSanityTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/DeleteProcessItemCoreTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/DeleteProcessItemFullTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/DeleteProcessItemSanityTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/GetProcessItemsCoreTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/GetProcessItemsFullTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/GetProcessItemsSanityTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/tasks/GetProcessTasksCoreTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/tasks/GetProcessTasksFullTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/tasks/GetProcessTasksSanityTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariableCoreTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariableFullTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariableSanityTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariablesCoreTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariablesFullTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariablesSanityTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/DeleteProcessVariableCoreTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/DeleteProcessVariableFullTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/DeleteProcessVariableSanityTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/GetProcessVariablesCoreTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/GetProcessVariablesFullTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/GetProcessVariablesSanityTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/UpdateProcessVariableTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/GetTaskFormModelTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/GetTaskTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/GetTasksTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/UpdateTaskTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/candidates/GetTaskCandidatesRegressionTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/candidates/GetTaskCandidatesSanityTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/AddTaskItemTestsBulk1.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/AddTaskItemTestsBulk2.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/AddTaskItemTestsBulk3.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/GetTaskItemsRegressionTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/GetTaskItemsSanityTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/RemoveTaskItemTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk1.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk2.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk3.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/DeleteTaskVariableTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/GetTaskVariablesTests.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk1.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk2.java delete mode 100644 e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk3.java diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/sql/SearchSQLAPITest.java b/e2e-test/src/test/java/org/alfresco/service/search/e2e/insightEngine/sql/SearchSQLAPITest.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/service/search/rest/search/sql/SearchSQLAPITest.java rename to e2e-test/src/test/java/org/alfresco/service/search/e2e/insightEngine/sql/SearchSQLAPITest.java index eca9eb29d..d2f5c0be7 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/sql/SearchSQLAPITest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/e2e/insightEngine/sql/SearchSQLAPITest.java @@ -12,7 +12,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with Alfresco. If not, see . */ -package org.alfresco.service.search.rest.search.sql; +package org.alfresco.service.search.e2e.insightEngine.sql; import static java.util.Arrays.asList; @@ -26,7 +26,7 @@ import static org.hamcrest.Matchers.isIn; import static org.hamcrest.Matchers.not; import org.alfresco.rest.core.RestResponse; -import org.alfresco.service.search.rest.search.AbstractSearchTest; +import org.alfresco.service.search.e2e.searchservices.AbstractSearchTest; import org.alfresco.rest.search.SearchSqlRequest; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.model.TestGroup; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/sql/SearchSQLPhraseTest.java b/e2e-test/src/test/java/org/alfresco/service/search/e2e/insightEngine/sql/SearchSQLPhraseTest.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/service/search/rest/search/sql/SearchSQLPhraseTest.java rename to e2e-test/src/test/java/org/alfresco/service/search/e2e/insightEngine/sql/SearchSQLPhraseTest.java index c0392a372..d379e0116 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/sql/SearchSQLPhraseTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/e2e/insightEngine/sql/SearchSQLPhraseTest.java @@ -12,7 +12,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with Alfresco. If not, see . */ -package org.alfresco.service.search.rest.search.sql; +package org.alfresco.service.search.e2e.insightEngine.sql; import java.sql.ResultSet; import java.util.ArrayList; @@ -22,7 +22,7 @@ import java.util.List; import java.util.Map; import org.alfresco.rest.core.RestResponse; -import org.alfresco.service.search.rest.search.AbstractSearchTest; +import org.alfresco.service.search.e2e.searchservices.AbstractSearchTest; import org.alfresco.rest.search.SearchSqlJDBCRequest; import org.alfresco.rest.search.SearchSqlRequest; import org.alfresco.utility.model.FileModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/sql/SearchSQLViaJDBCTest.java b/e2e-test/src/test/java/org/alfresco/service/search/e2e/insightEngine/sql/SearchSQLViaJDBCTest.java similarity index 98% rename from e2e-test/src/test/java/org/alfresco/service/search/rest/search/sql/SearchSQLViaJDBCTest.java rename to e2e-test/src/test/java/org/alfresco/service/search/e2e/insightEngine/sql/SearchSQLViaJDBCTest.java index 21f34c7ce..47219e4ad 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/sql/SearchSQLViaJDBCTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/e2e/insightEngine/sql/SearchSQLViaJDBCTest.java @@ -16,7 +16,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with Alfresco. If not, see . */ -package org.alfresco.service.search.rest.search.sql; +package org.alfresco.service.search.e2e.insightEngine.sql; import java.sql.ResultSet; import java.sql.SQLException; @@ -25,7 +25,7 @@ import java.util.List; import org.alfresco.dataprep.SiteService.Visibility; import org.alfresco.rest.requests.search.SearchSQLJDBC; -import org.alfresco.service.search.rest.search.AbstractSearchTest; +import org.alfresco.service.search.e2e.searchservices.AbstractSearchTest; import org.alfresco.rest.search.SearchSqlJDBCRequest; import org.alfresco.utility.data.RandomData; import org.alfresco.utility.model.SiteModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/sql/SearchSQLWithQuotedIdentifiers.java b/e2e-test/src/test/java/org/alfresco/service/search/e2e/insightEngine/sql/SearchSQLWithQuotedIdentifiers.java similarity index 98% rename from e2e-test/src/test/java/org/alfresco/service/search/rest/search/sql/SearchSQLWithQuotedIdentifiers.java rename to e2e-test/src/test/java/org/alfresco/service/search/e2e/insightEngine/sql/SearchSQLWithQuotedIdentifiers.java index 4b7b36f1f..c51613711 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/sql/SearchSQLWithQuotedIdentifiers.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/e2e/insightEngine/sql/SearchSQLWithQuotedIdentifiers.java @@ -16,12 +16,11 @@ * You should have received a copy of the GNU Lesser General Public License * along with Alfresco. If not, see . */ -package org.alfresco.service.search.rest.search.sql; +package org.alfresco.service.search.e2e.insightEngine.sql; import java.util.UUID; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.service.search.rest.search.AbstractSearchTest; +import org.alfresco.service.search.e2e.searchservices.AbstractSearchTest; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.CustomObjectTypeProperties; import org.alfresco.utility.model.ContentModel; @@ -34,6 +33,7 @@ import org.hamcrest.Matchers; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import org.alfresco.rest.RestTest; /** * Tests for /sql end point Search API when a custom model contains identifiers that need to be quoted in queries. diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/AbstractSearchTest.java b/e2e-test/src/test/java/org/alfresco/service/search/e2e/searchservices/AbstractSearchTest.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/service/search/rest/search/AbstractSearchTest.java rename to e2e-test/src/test/java/org/alfresco/service/search/e2e/searchservices/AbstractSearchTest.java index 9b85e5c8d..5e2597d49 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/AbstractSearchTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/e2e/searchservices/AbstractSearchTest.java @@ -16,10 +16,9 @@ * You should have received a copy of the GNU Lesser General Public License * along with Alfresco. If not, see . */ -package org.alfresco.service.search.rest.search; +package org.alfresco.service.search.e2e.searchservices; import org.alfresco.dataprep.SiteService.Visibility; -import org.alfresco.service.search.rest.RestTest; import org.alfresco.rest.core.RestResponse; import org.alfresco.rest.search.RestRequestHighlightModel; import org.alfresco.rest.search.RestRequestQueryModel; @@ -35,6 +34,7 @@ import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; +import org.alfresco.rest.RestTest; import javax.naming.AuthenticationException; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/FacetFieldsSearchTest.java b/e2e-test/src/test/java/org/alfresco/service/search/e2e/searchservices/FacetFieldsSearchTest.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/service/search/rest/search/FacetFieldsSearchTest.java rename to e2e-test/src/test/java/org/alfresco/service/search/e2e/searchservices/FacetFieldsSearchTest.java index c6c60d8bd..85d613a8c 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/FacetFieldsSearchTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/e2e/searchservices/FacetFieldsSearchTest.java @@ -16,7 +16,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with Alfresco. If not, see . */ -package org.alfresco.service.search.rest.search; +package org.alfresco.service.search.e2e.searchservices; import java.util.ArrayList; import java.util.List; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/FacetIntervalSearchTest.java b/e2e-test/src/test/java/org/alfresco/service/search/e2e/searchservices/FacetIntervalSearchTest.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/service/search/rest/search/FacetIntervalSearchTest.java rename to e2e-test/src/test/java/org/alfresco/service/search/e2e/searchservices/FacetIntervalSearchTest.java index b29671fd9..3c473467c 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/FacetIntervalSearchTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/e2e/searchservices/FacetIntervalSearchTest.java @@ -16,7 +16,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with Alfresco. If not, see . */ -package org.alfresco.service.search.rest.search; +package org.alfresco.service.search.e2e.searchservices; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.search.FacetInterval; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/FacetRangeSearchTest.java b/e2e-test/src/test/java/org/alfresco/service/search/e2e/searchservices/FacetRangeSearchTest.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/service/search/rest/search/FacetRangeSearchTest.java rename to e2e-test/src/test/java/org/alfresco/service/search/e2e/searchservices/FacetRangeSearchTest.java index 30d534cc5..14a65b0cb 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/FacetRangeSearchTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/e2e/searchservices/FacetRangeSearchTest.java @@ -16,7 +16,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with Alfresco. If not, see . */ -package org.alfresco.service.search.rest.search; +package org.alfresco.service.search.e2e.searchservices; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/FacetedSearchTest.java b/e2e-test/src/test/java/org/alfresco/service/search/e2e/searchservices/FacetedSearchTest.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/service/search/rest/search/FacetedSearchTest.java rename to e2e-test/src/test/java/org/alfresco/service/search/e2e/searchservices/FacetedSearchTest.java index 747042898..3d51cfccd 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/FacetedSearchTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/e2e/searchservices/FacetedSearchTest.java @@ -16,7 +16,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with Alfresco. If not, see . */ -package org.alfresco.service.search.rest.search; +package org.alfresco.service.search.e2e.searchservices; import java.util.ArrayList; import java.util.List; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/FingerPrintTest.java b/e2e-test/src/test/java/org/alfresco/service/search/e2e/searchservices/FingerPrintTest.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/service/search/rest/search/FingerPrintTest.java rename to e2e-test/src/test/java/org/alfresco/service/search/e2e/searchservices/FingerPrintTest.java index 9044c1175..6cad2b28f 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/FingerPrintTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/e2e/searchservices/FingerPrintTest.java @@ -16,7 +16,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with Alfresco. If not, see . */ -package org.alfresco.service.search.rest.search; +package org.alfresco.service.search.e2e.searchservices; import org.alfresco.rest.search.SearchNodeModel; import org.alfresco.rest.search.SearchResponse; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/PivotFacetedSearchTest.java b/e2e-test/src/test/java/org/alfresco/service/search/e2e/searchservices/PivotFacetedSearchTest.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/service/search/rest/search/PivotFacetedSearchTest.java rename to e2e-test/src/test/java/org/alfresco/service/search/e2e/searchservices/PivotFacetedSearchTest.java index 35d7f1c9c..4a438b20b 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/PivotFacetedSearchTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/e2e/searchservices/PivotFacetedSearchTest.java @@ -16,7 +16,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with Alfresco. If not, see . */ -package org.alfresco.service.search.rest.search; +package org.alfresco.service.search.e2e.searchservices; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; @@ -26,7 +26,6 @@ import java.util.List; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestRequestRangesModel; -import org.alfresco.service.search.rest.search.AbstractSearchTest; import org.alfresco.rest.search.Pagination; import org.alfresco.rest.search.RestGenericBucketModel; import org.alfresco.rest.search.RestGenericFacetResponseModel; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/SearchAPATHTest.java b/e2e-test/src/test/java/org/alfresco/service/search/e2e/searchservices/SearchAPATHTest.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/service/search/rest/search/SearchAPATHTest.java rename to e2e-test/src/test/java/org/alfresco/service/search/e2e/searchservices/SearchAPATHTest.java index ad08e72f4..dbf6556cf 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/SearchAPATHTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/e2e/searchservices/SearchAPATHTest.java @@ -16,7 +16,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with Alfresco. If not, see . */ -package org.alfresco.service.search.rest.search; +package org.alfresco.service.search.e2e.searchservices; import java.util.Collections; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/SearchHighLightTest.java b/e2e-test/src/test/java/org/alfresco/service/search/e2e/searchservices/SearchHighLightTest.java similarity index 98% rename from e2e-test/src/test/java/org/alfresco/service/search/rest/search/SearchHighLightTest.java rename to e2e-test/src/test/java/org/alfresco/service/search/e2e/searchservices/SearchHighLightTest.java index 1c03c9b47..83907d43e 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/SearchHighLightTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/e2e/searchservices/SearchHighLightTest.java @@ -16,7 +16,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with Alfresco. If not, see . */ -package org.alfresco.service.search.rest.search; +package org.alfresco.service.search.e2e.searchservices; import java.util.ArrayList; import java.util.List; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/SearchSpellCheckTest.java b/e2e-test/src/test/java/org/alfresco/service/search/e2e/searchservices/SearchSpellCheckTest.java similarity index 98% rename from e2e-test/src/test/java/org/alfresco/service/search/rest/search/SearchSpellCheckTest.java rename to e2e-test/src/test/java/org/alfresco/service/search/e2e/searchservices/SearchSpellCheckTest.java index aa75bc4a0..0e54d5690 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/SearchSpellCheckTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/e2e/searchservices/SearchSpellCheckTest.java @@ -16,10 +16,9 @@ * You should have received a copy of the GNU Lesser General Public License * along with Alfresco. If not, see . */ -package org.alfresco.service.search.rest.search; +package org.alfresco.service.search.e2e.searchservices; import org.alfresco.rest.model.RestRequestSpellcheckModel; -import org.alfresco.service.search.rest.search.AbstractSearchTest; import org.alfresco.rest.search.RestRequestQueryModel; import org.alfresco.rest.search.SearchRequest; import org.alfresco.rest.search.SearchResponse; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/SearchTest.java b/e2e-test/src/test/java/org/alfresco/service/search/e2e/searchservices/SearchTest.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/service/search/rest/search/SearchTest.java rename to e2e-test/src/test/java/org/alfresco/service/search/e2e/searchservices/SearchTest.java index ebe7cd33b..e2f081b9f 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/SearchTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/e2e/searchservices/SearchTest.java @@ -16,7 +16,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with Alfresco. If not, see . */ -package org.alfresco.service.search.rest.search; +package org.alfresco.service.search.e2e.searchservices; import static java.util.Arrays.asList; import static java.util.Collections.singletonList; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/ShardInfoTest.java b/e2e-test/src/test/java/org/alfresco/service/search/e2e/searchservices/ShardInfoTest.java similarity index 98% rename from e2e-test/src/test/java/org/alfresco/service/search/rest/search/ShardInfoTest.java rename to e2e-test/src/test/java/org/alfresco/service/search/e2e/searchservices/ShardInfoTest.java index 6305f242b..31eff2577 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/ShardInfoTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/e2e/searchservices/ShardInfoTest.java @@ -16,7 +16,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with Alfresco. If not, see . */ -package org.alfresco.service.search.rest.search; +package org.alfresco.service.search.e2e.searchservices; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/StatsSearchTest.java b/e2e-test/src/test/java/org/alfresco/service/search/e2e/searchservices/StatsSearchTest.java similarity index 99% rename from e2e-test/src/test/java/org/alfresco/service/search/rest/search/StatsSearchTest.java rename to e2e-test/src/test/java/org/alfresco/service/search/e2e/searchservices/StatsSearchTest.java index 9e00a5d19..39fa79a9b 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/StatsSearchTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/e2e/searchservices/StatsSearchTest.java @@ -16,7 +16,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with Alfresco. If not, see . */ -package org.alfresco.service.search.rest.search; +package org.alfresco.service.search.e2e.searchservices; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/solr/SearchSolrAPITest.java b/e2e-test/src/test/java/org/alfresco/service/search/e2e/searchservices/solr/SearchSolrAPITest.java similarity index 97% rename from e2e-test/src/test/java/org/alfresco/service/search/rest/search/solr/SearchSolrAPITest.java rename to e2e-test/src/test/java/org/alfresco/service/search/e2e/searchservices/solr/SearchSolrAPITest.java index 6e664b0d1..281e24fc4 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/search/solr/SearchSolrAPITest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/e2e/searchservices/solr/SearchSolrAPITest.java @@ -12,7 +12,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with Alfresco. If not, see . */ -package org.alfresco.service.search.rest.search.solr; +package org.alfresco.service.search.e2e.searchservices.solr; import java.net.URLEncoder; @@ -20,7 +20,7 @@ import javax.json.JsonArrayBuilder; import org.alfresco.rest.core.JsonBodyGenerator; import org.alfresco.rest.model.RestTextResponse; -import org.alfresco.service.search.rest.search.AbstractSearchTest; +import org.alfresco.service.search.e2e.searchservices.AbstractSearchTest; import org.alfresco.utility.model.TestGroup; import org.hamcrest.Matchers; import org.springframework.http.HttpStatus; diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/FunctionalCasesTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/FunctionalCasesTests.java deleted file mode 100644 index 2608e18db..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/FunctionalCasesTests.java +++ /dev/null @@ -1,701 +0,0 @@ -package org.alfresco.service.search.rest; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.dataprep.SiteService.Visibility; -import org.alfresco.rest.model.RestActivityModelsCollection; -import org.alfresco.rest.model.RestCommentModel; -import org.alfresco.rest.model.RestCommentModelsCollection; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestFavoriteSiteModel; -import org.alfresco.rest.model.RestPersonFavoritesModelsCollection; -import org.alfresco.rest.model.RestRatingModel; -import org.alfresco.rest.model.RestSiteMemberModel; -import org.alfresco.rest.model.RestSiteMembershipRequestModelsCollection; -import org.alfresco.rest.model.RestTagModel; -import org.alfresco.rest.model.RestTaskModel; -import org.alfresco.utility.constants.ActivityType; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class FunctionalCasesTests extends RestTest -{ - private UserModel adminUser, manager; - private SiteModel publicSite, moderatedSite, privateSite; - private RestSiteMemberModel updatedMember; - private RestSiteMembershipRequestModelsCollection returnedCollection; - private RestFavoriteSiteModel restFavoriteSiteModel; - private RestActivityModelsCollection activities; - private FileModel file; - private RestActivityModelsCollection restActivityModelsCollection; - - private FileModel fileInSite; - private RestCommentModel commentModel; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - manager = dataUser.createRandomTestUser(); - publicSite = dataSite.usingUser(adminUser).createPublicRandomSite(); - dataUser.addUserToSite(manager, publicSite, UserRole.SiteManager); - moderatedSite = dataSite.usingUser(adminUser).createModeratedRandomSite(); - privateSite = dataSite.usingUser(adminUser).createPrivateRandomSite(); - } - - /** - * Scenario: - * 1. Add a site member as Manager - * 2. Update it's role to Collaborator - * 3. Update it's role to Contributor - * 4. Update it's role to Consumer - */ - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that manager is able to update manager with different roles and gets status code CREATED (201)") - public void managerIsAbleToUpdateManagerWithDifferentRoles() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteManager); - restClient.authenticateUser(adminUser).withCoreAPI().usingSite(publicSite).addPerson(testUser) - .assertThat().field("id").is(testUser.getUsername()) - .and().field("role").is(testUser.getUserRole()); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - testUser.setUserRole(UserRole.SiteCollaborator); - updatedMember = restClient.withCoreAPI() - .usingSite(publicSite).updateSiteMember(testUser); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedMember.assertThat().field("id").is(testUser.getUsername()).and().field("role").is(testUser.getUserRole()); - - testUser.setUserRole(UserRole.SiteContributor); - updatedMember = restClient.withCoreAPI() - .usingSite(publicSite).updateSiteMember(testUser); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedMember.assertThat().field("id").is(testUser.getUsername()).and().field("role").is(testUser.getUserRole()); - - testUser.setUserRole(UserRole.SiteConsumer); - updatedMember = restClient.withCoreAPI() - .usingSite(publicSite).updateSiteMember(testUser); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedMember.assertThat().field("id").is(testUser.getUsername()).and().field("role").is(testUser.getUserRole()); - } - - /** - * Scenario: - * 1. Add a site member as Consumer - * 2. Update it's role to Contributor - * 3. Update it's role to Collaborator - * 4. Update it's role to Manager - */ - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that manager is able to update consumer with different roles and gets status code CREATED (201)") - public void managerIsAbleToUpdateConsumerWithDifferentRoles() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteConsumer); - restClient.authenticateUser(adminUser).withCoreAPI().usingSite(publicSite).addPerson(testUser) - .assertThat().field("id").is(testUser.getUsername()) - .and().field("role").is(testUser.getUserRole()); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - testUser.setUserRole(UserRole.SiteContributor); - updatedMember = restClient.withCoreAPI() - .usingSite(publicSite).updateSiteMember(testUser); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedMember.assertThat().field("id").is(testUser.getUsername()).and().field("role").is(testUser.getUserRole()); - - testUser.setUserRole(UserRole.SiteCollaborator); - updatedMember = restClient.withCoreAPI() - .usingSite(publicSite).updateSiteMember(testUser); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedMember.assertThat().field("id").is(testUser.getUsername()).and().field("role").is(testUser.getUserRole()); - - testUser.setUserRole(UserRole.SiteManager); - updatedMember = restClient.withCoreAPI() - .usingSite(publicSite).updateSiteMember(testUser); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedMember.assertThat().field("id").is(testUser.getUsername()).and().field("role").is(testUser.getUserRole()); - } - - /** - * Scenario: - * 1. Create site membership request - * 2. Approve site membership request - * 3. Add site to Favorites - * 4. Delete site from Favorites - */ - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, description = "Approve request, add site to favorites, then delete it from favorites") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void approveRequestAddAndDeleteSiteFromFavorites() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - - restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestTaskModel taskModel = restClient.authenticateUser(newMember).withWorkflowAPI().getTasks().getTaskModelByDescription(moderatedSite); - workflow.approveSiteMembershipRequest(adminUser.getUsername(), adminUser.getPassword(), taskModel.getId(), true, "Approve"); - returnedCollection = restClient.authenticateUser(newMember).withCoreAPI().usingMe().getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat().entriesListDoesNotContain("id", moderatedSite.getId()); - - restFavoriteSiteModel = restClient.authenticateUser(newMember).withCoreAPI().usingUser(newMember).addFavoriteSite(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restFavoriteSiteModel.assertThat().field("id").is(moderatedSite.getId()); - - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().removeFavoriteSite(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - /** - * Scenario: - * 1. Create site membership request - * 2. Reject site membership request - * 3. Add moderated site to Favorites - * 4. Create site membership request again - * 5. Approve site membership request - * 6. Delete member from site - */ - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, description = "Reject request, add moderated site to favorites, create request again and approve it") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void rejectRequestAddModeratedSiteToFavorites() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - - restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestTaskModel taskModel = restClient.authenticateUser(newMember).withWorkflowAPI().getTasks().getTaskModelByDescription(moderatedSite); - workflow.approveSiteMembershipRequest(adminUser.getUsername(), adminUser.getPassword(), taskModel.getId(), false, "Rejected"); - returnedCollection = restClient.authenticateUser(newMember).withCoreAPI().usingMe().getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat().entriesListDoesNotContain("id", moderatedSite.getId()); - - restFavoriteSiteModel = restClient.authenticateUser(newMember).withCoreAPI().usingUser(newMember).addFavoriteSite(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restFavoriteSiteModel.assertThat().field("id").is(moderatedSite.getId()); - - restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - taskModel = restClient.authenticateUser(newMember).withWorkflowAPI().getTasks().getTaskModelByDescription(moderatedSite); - workflow.approveSiteMembershipRequest(adminUser.getUsername(), adminUser.getPassword(), taskModel.getId(), true, "Accept"); - - restClient.authenticateUser(adminUser).withCoreAPI().usingUser(newMember).deleteSiteMember(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingSite(moderatedSite).getSiteMembers().assertThat().entriesListDoesNotContain("id", newMember.getUsername()); - } - - /** - * Scenario: - * 1. Add file - * 2. Check file is included in person activities list - */ - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Add a file and check that activity is included in person activities") - public void addFileThenGetPersonActivities() throws Exception - { - file = dataContent.usingUser(manager).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); - activities = restClient.authenticateUser(manager).withCoreAPI().usingAuthUser().getPersonActivitiesUntilEntriesCountIs(2); - activities.assertThat().entriesListIsNotEmpty() - .and().entriesListContains("siteId", publicSite.getId()) - .and().entriesListContains("activityType", "org.alfresco.documentlibrary.file-added") - .and().entriesListContains("activitySummary.objectId", file.getNodeRefWithoutVersion()); - } - - /** - * Scenario: - * 1. Add a comment to a file - * 2. Check that comment is included in person activities list - */ - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Add a comment to a file and check that activity is included in person activities") - public void addCommentThenGetPersonActivities() throws Exception - { - file = dataContent.usingUser(manager).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(manager).withCoreAPI().usingResource(file).addComment("new comment"); - activities = restClient.authenticateUser(manager).withCoreAPI().usingAuthUser().getPersonActivitiesUntilEntriesCountIs(3); - activities.assertThat().entriesListIsNotEmpty() - .and().entriesListContains("siteId", publicSite.getId()) - .and().entriesListContains("activityType", "org.alfresco.comments.comment-created") - .and().entriesListContains("activitySummary.objectId", file.getNodeRefWithoutVersion()); - } - - /** - * Scenario: - * 1. Add file then delete it - * 2. Check action is included in person activities list - */ - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Add a file, delete it and check that activity is included in person activities") - public void addFileDeleteItThenGetPersonActivities() throws Exception - { - file = dataContent.usingUser(manager).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); - dataContent.usingUser(manager).usingResource(file).deleteContent(); - activities = restClient.authenticateUser(manager).withCoreAPI().usingAuthUser().getPersonActivitiesUntilEntriesCountIs(2); - activities.assertThat().entriesListIsNotEmpty() - .and().entriesListContains("siteId", publicSite.getId()) - .and().entriesListContains("activityType", "org.alfresco.documentlibrary.file-deleted") - .and().entriesListContains("activitySummary.objectId", file.getNodeRefWithoutVersion()); - } - - /** - * 1. Post one comment - * 2. Get comment details - * 3. Update comment - * 4. Get again comment details - * 5. Delete comment - */ - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, - executionType = ExecutionType.REGRESSION, - description = "Add comment to a file, then get comment details. Update it and check that get comment returns updated details. Delete comment then check that file has no comments.") - public void addUpdateDeleteCommentThenGetCommentDetails() throws Exception - { - file = dataContent.usingUser(manager).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); - RestCommentModel newComment = restClient.authenticateUser(manager).withCoreAPI().usingResource(file).addComment("new comment"); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestCommentModelsCollection fileComments = restClient.withCoreAPI().usingResource(file).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - fileComments.assertThat().entriesListContains("content", newComment.getContent()); - - RestCommentModel updatedComment = restClient.withCoreAPI().usingResource(file).updateComment(newComment, "updated comment"); - restClient.assertStatusCodeIs(HttpStatus.OK); - - fileComments = restClient.withCoreAPI().usingResource(file).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - fileComments.assertThat().entriesListContains("content", updatedComment.getContent()).assertThat().entriesListDoesNotContain("content", newComment.getContent()); - - restClient.withCoreAPI().usingResource(file).deleteComment(updatedComment); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - fileComments = restClient.withCoreAPI().usingResource(file).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - fileComments.assertThat().entriesListIsEmpty(); - } - - /** - * 1. Post one comment - * 2. Delete comment - * 3. Post the same comment again - */ - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, - executionType = ExecutionType.REGRESSION, - description = "Add a comment to a file, delete it, then added the same comment again.") - public void checkThatADeletedCommentCanBePostedAgain() throws Exception - { - file = dataContent.usingUser(manager).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); - RestCommentModel newComment = restClient.authenticateUser(manager).withCoreAPI().usingResource(file).addComment("new comment"); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestCommentModelsCollection fileComments = restClient.withCoreAPI().usingResource(file).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - fileComments.assertThat().entriesListContains("content", newComment.getContent()); - - restClient.withCoreAPI().usingResource(file).deleteComment(newComment); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - fileComments = restClient.withCoreAPI().usingResource(file).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - fileComments.assertThat().entriesListIsEmpty(); - - restClient.authenticateUser(manager).withCoreAPI().usingResource(file).addComment("new comment"); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - fileComments = restClient.withCoreAPI().usingResource(file).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - fileComments.assertThat().entriesListContains("content", newComment.getContent()); - } - - /** - * Scenario: - * 1. join an user to a site - * 2. Check action is included in person activities list - * - * @throws Exception - */ - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Create an user, join the user to a site and check that activity is included in person activities") - public void joinUserToSiteThenGetPersonActivities() throws Exception - { - UserModel userJoinSite = dataUser.createRandomTestUser(); - - restClient.authenticateUser(userJoinSite).withCoreAPI().usingMe().addSiteMembershipRequest(publicSite); - activities = restClient.withCoreAPI().usingAuthUser().getPersonActivitiesUntilEntriesCountIs(2); - activities.assertThat().entriesListIsNotEmpty().and() - .entriesListContains("siteId", publicSite.getId()).and() - .entriesListContains("activityType", "org.alfresco.site.user-joined").and() - .entriesListContains("activitySummary.memberPersonId", userJoinSite.getUsername()); - } - - /** - * Scenario: - * 1. Add user to private site - * 2. Remove user from private site - * 3. User creates membership request to the same private site - */ - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, description = "Verify membership request by user after it was removed from site gets status code 404") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void userCanNotCreateMembershipRequestIfItWasRemovedFromPrivateSite() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - newMember.setUserRole(UserRole.SiteCollaborator); - - restClient.authenticateUser(adminUser).withCoreAPI().usingSite(privateSite).addPerson(newMember) - .assertThat().field("id").is(newMember.getUsername()); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(adminUser).withCoreAPI().usingUser(newMember).deleteSiteMember(privateSite); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest(privateSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, newMember.getUsername(), privateSite.getTitle())); - } - - /** - * Scenario: - * 1. User creates membership request to moderated site - * 2. Accept membership request - * 3. Remove user from moderated site - * 4. Add user on moderated site - */ - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, description = "Verify user can be added back after if was removed from site") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void userCanBeAddedAfterItWasRemovedFromSite() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - newMember.setUserRole(UserRole.SiteCollaborator); - - restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestTaskModel taskModel = restClient.authenticateUser(newMember).withWorkflowAPI().getTasks().getTaskModelByDescription(moderatedSite); - workflow.approveSiteMembershipRequest(adminUser.getUsername(), adminUser.getPassword(), taskModel.getId(), true, "Accept"); - - restClient.authenticateUser(adminUser).withCoreAPI().usingUser(newMember).deleteSiteMember(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingSite(moderatedSite).getSiteMembers().assertThat().entriesListDoesNotContain("id", newMember.getUsername()); - - restClient.authenticateUser(adminUser).withCoreAPI().usingSite(moderatedSite).addPerson(newMember) - .assertThat().field("id").is(newMember.getUsername()); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.withCoreAPI().usingSite(moderatedSite).getSiteMembers().assertThat().entriesListContains("id", newMember.getUsername()); - } - - /** - * Scenario: - * 1. Create document in site - * 2. Add comment - * 3. Delete document - * 4. Get comments and check if the above comment was deleted - */ - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, - executionType = ExecutionType.REGRESSION, description = "Check that a comment of a document was also removed after deleting the document") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void checkTheCommentOfADocumentThatWasDeletedDoesNotExist() throws Exception - { - file = dataContent.usingSite(publicSite).usingUser(adminUser).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - String newContent = "This is a new comment added by " + adminUser.getUsername(); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(file).addComment(newContent) - .assertThat().field("content").isNotEmpty() - .and().field("content").is(newContent); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - dataContent.usingUser(adminUser).usingResource(file).deleteContent(); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(file).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary((String.format(RestErrorModel.ENTITY_WAS_NOT_FOUND, file.getNodeRefWithoutVersion()))); - } - - /** - * Scenario: - * 1. Add user to private site - * 2. Add comment to a document of private site - * 3. Remove user from site - * 4. Get comments and check if the above comment was deleted - */ - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, - executionType = ExecutionType.REGRESSION, description = "Check that a comment of a document from a private site is not deleted after user is removed") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void checkThatCommentIsNotDeletedWhenPrivateSiteMemberIsRemoved() throws Exception - { - UserModel newUser = dataUser.createRandomTestUser(); - newUser.setUserRole(UserRole.SiteManager); - restClient.authenticateUser(adminUser).withCoreAPI().usingSite(privateSite).addPerson(newUser); - - file = dataContent.usingSite(privateSite).usingUser(adminUser).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - String newContent = "This is a new comment added by " + newUser.getUsername(); - - restClient.authenticateUser(newUser).withCoreAPI().usingResource(file).addComment(newContent) - .assertThat().field("content").isNotEmpty() - .and().field("content").is(newContent); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(adminUser).withCoreAPI().usingSite(privateSite).deleteSiteMember(newUser); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingSite(privateSite).getSiteMembers().assertThat().entriesListDoesNotContain("id", newUser.getUsername()); - - RestCommentModelsCollection comments = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(file).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", newContent) - .and().entriesListContains("createdBy.id", newUser.getUsername()); - } - - /** - * Scenario: - * 1. Add one file to favorites then add a comment to this file - */ - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, - executionType = ExecutionType.REGRESSION, - description = "Add one file to favorites then add a comment to this file") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void commentAFavoriteFile() throws Exception - { - file = dataContent.usingSite(publicSite).usingUser(adminUser).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - restClient.authenticateUser(manager).withCoreAPI().usingMe().addFileToFavorites(file); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.withCoreAPI().usingAuthUser().getFavorites() - .assertThat().entriesListContains("targetGuid", file.getNodeRefWithoutVersion()); - - RestCommentModel comment = restClient.withCoreAPI().usingResource(file).addComment("new comment"); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - comment.assertThat().field("content").is("new comment"); - } - - /** - * Scenario: - * 1. Remove one file from favorites then add a comment to this file - */ - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, - executionType = ExecutionType.REGRESSION, - description = "Remove one file from favorites then add a comment to this file") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void commentFileRemovedFromFavorites() throws Exception - { - file = dataContent.usingSite(publicSite).usingUser(adminUser).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - restClient.authenticateUser(manager).withCoreAPI().usingMe().addFileToFavorites(file); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.withCoreAPI().usingMe().deleteFileFromFavorites(file); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingAuthUser().getFavorites() - .assertThat().entriesListDoesNotContain("targetGuid", file.getNodeRefWithoutVersion()); - - RestCommentModel comment = restClient.withCoreAPI().usingResource(file).addComment("new comment"); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - comment.assertThat().field("content").is("new comment"); - } - - /** - * Scenario: - * 1. Add public site to favorites - * 2. Change site visibility to moderated - * 3. Check favorites - * 4. Change site visibility to private - * 5. Check favorites - */ - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, - executionType = ExecutionType.REGRESSION, - description = "Check favorite sites after a favorite site visibility is changed") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void changeFavoriteSiteVisibilityThenCheckFavorites() throws Exception - { - SiteModel favoriteSite = dataSite.usingUser(manager).createPublicRandomSite(); - UserModel regularUser = dataUser.createRandomTestUser(); - - restClient.authenticateUser(regularUser).withCoreAPI().usingAuthUser().addSiteToFavorites(favoriteSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestPersonFavoritesModelsCollection userFavoriteSites = restClient.withCoreAPI().usingAuthUser().where().targetSiteExist().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - userFavoriteSites.assertThat().entriesListContains("targetGuid", favoriteSite.getGuid()) - .assertThat().entriesListContains("target.site.visibility", favoriteSite.getVisibility().name()) - .assertThat().entriesListContains("target.site.id", favoriteSite.getId()); - - dataSite.usingUser(manager).updateSiteVisibility(favoriteSite, Visibility.MODERATED); - - userFavoriteSites = restClient.authenticateUser(regularUser).withCoreAPI().usingAuthUser().where().targetSiteExist().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - userFavoriteSites.assertThat().entriesListContains("targetGuid", favoriteSite.getGuid()) - .assertThat().entriesListContains("target.site.visibility", "MODERATED") - .assertThat().entriesListContains("target.site.id", favoriteSite.getId()); - - dataSite.usingUser(manager).updateSiteVisibility(favoriteSite, Visibility.PRIVATE); - - userFavoriteSites = restClient.authenticateUser(regularUser).withCoreAPI().usingAuthUser().where().targetSiteExist().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - userFavoriteSites.assertThat().entriesListIsEmpty(); - - dataSite.usingUser(manager).updateSiteVisibility(favoriteSite, Visibility.PUBLIC); - - userFavoriteSites = restClient.authenticateUser(regularUser).withCoreAPI().usingAuthUser().where().targetSiteExist().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - userFavoriteSites.assertThat().entriesListContains("targetGuid", favoriteSite.getGuid()) - .assertThat().entriesListContains("target.site.visibility", favoriteSite.getVisibility().name()) - .assertThat().entriesListContains("target.site.id", favoriteSite.getId()); - } - - /** - * Scenario: - * 1. Regular user adds moderated site membership request - * 2. Site manager approves the request - * 3. Site manager updates the new member role to Manager - * 4. New member adds comment to a file on site - * 5. New member likes and rate one file - * 6. New member adds tags to a file - * 7. New member adds site to favorite - * 8. New member adds, then deletes a site member - */ - @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, - executionType = ExecutionType.REGRESSION, - description = "Check that a user who joins a moderated site as manager is able to comment, rate, tag an existing file from the site, add site to favorites, add and remove site members.") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - public void checkNewManagerActions() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - file = dataContent.usingSite(moderatedSite).usingUser(adminUser).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestTaskModel taskModel = restClient.withWorkflowAPI().getTasks().getTaskModelByDescription(moderatedSite); - workflow.approveSiteMembershipRequest(adminUser.getUsername(), adminUser.getPassword(), taskModel.getId(), true, "Approve"); - returnedCollection = restClient.withCoreAPI().usingMe().getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat().entriesListDoesNotContain("id", moderatedSite.getId()); - - newMember.setUserRole(UserRole.SiteManager); - restClient.authenticateUser(adminUser).withCoreAPI().usingSite(moderatedSite).updateSiteMember(newMember) - .assertThat().field("id").is(newMember.getUsername()) - .and().field("role").is(newMember.getUserRole()); - restClient.assertStatusCodeIs(HttpStatus.OK); - - RestCommentModel comment = restClient.authenticateUser(newMember).withCoreAPI().usingResource(file).addComment("new comment"); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - comment.assertThat().field("content").is("new comment"); - - RestRatingModel returnedRatingModel = restClient.withCoreAPI().usingResource(file).likeDocument(); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedRatingModel.assertThat().field("myRating").is("true") - .and().field("id").is("likes") - .and().field("aggregate").isNotEmpty(); - - returnedRatingModel = restClient.withCoreAPI().usingResource(file).rateStarsToDocument(5); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedRatingModel.assertThat().field("myRating").is("5") - .and().field("id").is("fiveStar") - .and().field("aggregate").isNotEmpty(); - - RestTagModel tag = restClient.withCoreAPI().usingResource(file).addTag("filetag"); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - tag.assertThat().field("tag").is("filetag") - .and().field("id").isNotEmpty(); - - restFavoriteSiteModel = restClient.withCoreAPI().usingAuthUser().addFavoriteSite(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restFavoriteSiteModel.assertThat().field("id").is(moderatedSite.getId()); - - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteManager); - restClient.withCoreAPI().usingSite(moderatedSite).addPerson(testUser) - .assertThat().field("id").is(testUser.getUsername()) - .and().field("role").is(testUser.getUserRole()); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.withCoreAPI().usingSite(moderatedSite).deleteSiteMember(testUser); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingSite(moderatedSite).getSiteMembers() - .assertThat().entriesListDoesNotContain("id", testUser.getUsername()); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - /** - * Scenario: - * 1. Add user to site - * 2. Create folder - * 3. Create document - * 4. Add comment to the document - * 5. Like document - * 6. Update Comment - * 7. Update user role - * 8. Delete like rating - * 9. Delete site member - * 10. Delete comment - * 11. Get Activities - * - * @throws Exception - */ - @Bug(id="REPO-1830") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its activities with Rest API and response is successful") - public void userGetsItsPeopleActivities() throws Exception - { - UserModel newUser = dataUser.createRandomTestUser(); - SiteModel userSiteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); - - dataUser.addUserToSite(newUser, userSiteModel, UserRole.SiteCollaborator); - dataContent.usingUser(newUser).usingSite(userSiteModel).createFolder(); - - fileInSite = dataContent.usingUser(newUser).usingSite(userSiteModel).createContent(DocumentType.TEXT_PLAIN); - String newContent = "This is a new comment added by " + newUser.getUsername(); - commentModel = restClient.authenticateUser(newUser).withCoreAPI().usingResource(fileInSite).addComment(newContent); - restClient.authenticateUser(newUser).withCoreAPI().usingResource(fileInSite).likeDocument(); - - restClient.withCoreAPI().usingResource(fileInSite).updateComment(commentModel, "new Content"); - newUser.setUserRole(UserRole.SiteManager); - restClient.authenticateUser(adminUser).withCoreAPI().usingSite(userSiteModel).updateSiteMember(newUser); - - restClient.authenticateUser(newUser).withCoreAPI().usingResource(fileInSite).deleteLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingResource(fileInSite).deleteComment(commentModel); - restClient.authenticateUser(adminUser).withCoreAPI().usingSite(userSiteModel).deleteSiteMember(newUser); - - restActivityModelsCollection = restClient.authenticateUser(newUser).withCoreAPI().usingMe().getPersonActivitiesUntilEntriesCountIs(10); - restClient.assertStatusCodeIs(HttpStatus.OK); - restActivityModelsCollection.assertThat().paginationField("count").is("10"); - - restActivityModelsCollection = restClient.authenticateUser(newUser).withCoreAPI().usingMe().getPersonActivities(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restActivityModelsCollection.assertThat().paginationField("count").is("10"); - - restActivityModelsCollection.assertThat().entriesListContains("activityType", ActivityType.USER_JOINED.toString()).assertThat() - .entriesListContains("activityType", ActivityType.FILE_ADDED.toString()).assertThat() - .entriesListContains("activityType", ActivityType.FOLDER_ADDED.toString()).assertThat() - .entriesListContains("activityType", ActivityType.COMMENT_CREATED.toString()).assertThat() - .entriesListContains("activityType", ActivityType.FILE_LIKED.toString()).assertThat() - .entriesListContains("activityType", ActivityType.COMMENT_UPDATED.toString()).assertThat() - .entriesListContains("activityType", ActivityType.USER_ROLE_CHANGED.toString()).assertThat() - .entriesListContains("activityType", ActivityType.COMMENT_DELETED.toString()).assertThat() - .entriesListContains("activityType", ActivityType.USER_LEFT.toString()); - } - -} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/NetworkDataPrep.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/NetworkDataPrep.java deleted file mode 100644 index f3903b106..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/NetworkDataPrep.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.alfresco.service.search.rest; - -import org.alfresco.rest.model.RestNetworkModel; -import org.alfresco.utility.model.UserModel; - -public abstract class NetworkDataPrep extends RestTest -{ - protected static UserModel adminUserModel; - protected static UserModel adminTenantUser, secondAdminTenantUser; - protected static UserModel tenantUser, secondTenantUser, differentNetworkTenantUser; - protected static UserModel tenantUserWithBad; - protected static UserModel userModel; - protected static RestNetworkModel restNetworkModel; - protected static String tenantDomain; - private static boolean isInitialized = false; - - public void init() throws Exception - { - if(!isInitialized) - { - isInitialized = true; - initialization(); - } - } - - public void initialization() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - //create first tenant Admin User. - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUserModel); - restClient.usingTenant().createTenant(adminTenantUser); - - tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - secondTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("sTenant"); - //create second tenant Admin User. - secondAdminTenantUser = UserModel.getAdminTenantUser(); - restClient.usingTenant().createTenant(secondAdminTenantUser); - - tenantDomain = tenantUser.getDomain(); - differentNetworkTenantUser = dataUser.usingUser(secondAdminTenantUser).createUserWithTenant("dTenant"); - - userModel = dataUser.createRandomTestUser(); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/RestTest.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/RestTest.java deleted file mode 100644 index 5f042d387..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/RestTest.java +++ /dev/null @@ -1,85 +0,0 @@ -package org.alfresco.service.search.rest; - -import java.lang.reflect.Method; - -import org.alfresco.dataprep.WorkflowService; -import org.alfresco.rest.core.RestProperties; -import org.alfresco.rest.core.RestWrapper; -import org.alfresco.utility.LogFactory; -import org.alfresco.utility.TasProperties; -import org.alfresco.utility.data.DataContent; -import org.alfresco.utility.data.DataGroup; -import org.alfresco.utility.data.DataLink; -import org.alfresco.utility.data.DataSite; -import org.alfresco.utility.data.DataUser; -import org.alfresco.utility.data.DataWorkflow; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.network.ServerHealth; -import org.slf4j.Logger; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.BeforeSuite; - -@ContextConfiguration("classpath:alfresco-restapi-context.xml") -public abstract class RestTest extends AbstractTestNGSpringContextTests -{ - private static Logger LOG = LogFactory.getLogger(); - - @Autowired - protected RestProperties restProperties; - - @Autowired - protected TasProperties properties; - - @Autowired - protected ServerHealth serverHealth; - - @Autowired - protected RestWrapper restClient; - - @Autowired - protected DataUser dataUser; - - @Autowired - protected DataSite dataSite; - - @Autowired - protected DataContent dataContent; - - @Autowired - protected DataGroup dataGroup; - - @Autowired - protected DataWorkflow dataWorkflow; - - @Autowired - protected DataLink dataLink; - - @Autowired - protected WorkflowService workflow; - - protected SiteModel testSite; - - @BeforeSuite(alwaysRun = true) - public void checkServerHealth() throws Exception - { - super.springTestContextPrepareTestInstance(); - serverHealth.assertServerIsOnline(); - testSite = dataSite.createPublicRandomSite(); - } - - @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/e2e-test/src/test/java/org/alfresco/service/search/rest/actions/ActionsTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/actions/ActionsTests.java deleted file mode 100644 index b35a8251d..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/actions/ActionsTests.java +++ /dev/null @@ -1,151 +0,0 @@ -package org.alfresco.service.search.rest.actions; - -import static org.testng.Assert.assertFalse; - -import com.google.common.collect.ImmutableMap; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestActionDefinitionModel; -import org.alfresco.rest.model.RestActionDefinitionModelsCollection; -import org.alfresco.rest.model.RestNodeModel; -import org.alfresco.utility.Utility; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.json.JSONObject; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class ActionsTests extends RestTest -{ - private UserModel adminUser; - private FileModel document; - private SiteModel publicSite; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - publicSite = dataSite.createPublicRandomSite(); - document = dataContent.usingSite(publicSite).usingUser(adminUser).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.ACTIONS }, executionType = ExecutionType.SANITY, - description = "Verify actions") - @Test(groups = { TestGroup.REST_API, TestGroup.ACTIONS, TestGroup.SANITY}) - public void testActionDefinitions() throws Exception - { - restClient.authenticateUser(dataContent.getAdminUser()); - - RestActionDefinitionModelsCollection restActionDefinitions = restClient. - withCoreAPI(). - usingActions(). - listActionDefinitions(); - - restClient.assertStatusCodeIs(HttpStatus.OK); - assertFalse(restActionDefinitions.isEmpty()); - restActionDefinitions.assertThat(). - entriesListContains("name", "copy"). - and().entriesListContains("name", "move"). - and().entriesListContains("name", "check-out"). - and().entriesListContains("name", "check-in"); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.ACTIONS }, executionType = ExecutionType.REGRESSION, - description = "Verify actions error conditions") - @Test(groups = { TestGroup.REST_API, TestGroup.ACTIONS, TestGroup.REGRESSION}) - public void testActionDefinitionsNegative() throws Exception{ - // Badly formed request -> 400 - { - restClient.authenticateUser(dataContent.getAdminUser()). - // invalid skipCount - withParams("skipCount=-1"). - withCoreAPI(). - usingActions(). - listActionDefinitions(); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - - } - - // Unauthorized -> 401 - { - - UserModel userUnauthorized = new UserModel("invalid-user", "invalid-pasword"); - restClient.authenticateUser(userUnauthorized).withCoreAPI().usingActions().listActionDefinitions(); - - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); - } - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.ACTIONS }, executionType = ExecutionType.SANITY, - description = "Sanity test for POST /action-executions") - @Test(groups = { TestGroup.REST_API, TestGroup.ACTIONS, TestGroup.SANITY}) - public void executeAction() throws Exception - { - JSONObject response = restClient.authenticateUser(adminUser).withCoreAPI().usingActions().executeAction - ("add-features", document, ImmutableMap.of("aspect-name", "cm:versionable")); - restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); - - assertFalse(response.getString("id").isEmpty()); - - /* - * Get all node properties and check that action was executed and - * cm:versionable aspect was added - */ - Utility.sleep(500, 20000, () -> { - RestNodeModel fileModel = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(document).getNode(); - - restClient.assertStatusCodeIs(HttpStatus.OK); - fileModel.assertThat().field("aspectNames").contains("cm:versionable"); - }); - } - - @TestRail (section = { TestGroup.REST_API, TestGroup.ACTIONS }, executionType = ExecutionType.SANITY, - description = "Sanity test for POST /action-executions") - @Test (groups = { TestGroup.REST_API, TestGroup.ACTIONS, TestGroup.SANITY }) - public void executeActionWithoutParam() throws Exception - { - JSONObject response = restClient.authenticateUser(adminUser).withCoreAPI().usingActions().executeAction - ("check-out", document); - restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); - - assertFalse(response.getString("id").isEmpty()); - - /* - * Get all node properties and check that action was executed and - * cm:checkedOut aspect was added - */ - Utility.sleep(500, 20000, () -> { - RestNodeModel fileModel = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(document) - .getNode(); - - restClient.assertStatusCodeIs(HttpStatus.OK); - fileModel.assertThat().field("aspectNames").contains("cm:checkedOut"); - }); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.ACTIONS }, executionType = ExecutionType.SANITY, - description = "Sanity test for ACTIONS endpoint GET action-definitions/{actionDefinitionId}") - @Test(groups = { TestGroup.REST_API, TestGroup.ACTIONS, TestGroup.SANITY}) - public void testGetActionDefinitionById() throws Exception - { - restClient.authenticateUser(dataContent.getAdminUser()); - - RestActionDefinitionModel restActionDefinition = restClient. - withCoreAPI(). - usingActions(). - getActionDefinitionById("add-features"); - - restClient.assertStatusCodeIs(HttpStatus.OK); - assertFalse(restActionDefinition.getId().isEmpty()); - restActionDefinition.getId().equals("add-features"); - restActionDefinition.getDescription().equals("This will add an aspect to the matched item."); - restActionDefinition.getTitle().equals("Add aspect"); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/aos/AosApiTest.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/aos/AosApiTest.java deleted file mode 100644 index a8f596359..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/aos/AosApiTest.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.alfresco.service.search.rest.aos; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.core.RestRequest; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.testng.annotations.Test; - -public class AosApiTest extends RestTest -{ - /* - * @author: Catalin Gornea - * - * simple test for demo purposes on how to use Aos with Rest - */ - @Test(enabled=false) - public void assertResponsIsSuccesufulWhenGetRootDirectory() throws Exception - { - restClient.authenticateUser(dataUser.getAdminUser()).withAosAPI(); - RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, ""); - restClient.process(request); - restClient.assertStatusCodeIs(HttpStatus.OK); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/audit/AuditTest.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/audit/AuditTest.java deleted file mode 100644 index 78b973100..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/audit/AuditTest.java +++ /dev/null @@ -1,112 +0,0 @@ -package org.alfresco.service.search.rest.audit; - -import static org.hamcrest.Matchers.is; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.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.RestAuditAppModel; -import org.alfresco.rest.model.RestAuditAppModelsCollection; -import org.alfresco.rest.model.RestAuditEntryModel; -import org.alfresco.rest.model.RestAuditEntryModelsCollection; -import org.alfresco.rest.model.RestNodeModel; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.network.JmxBuilder; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.testng.Assert; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import com.jayway.restassured.RestAssured; - -@Test(groups = {TestGroup.REQUIRE_JMX}) -public abstract class AuditTest extends RestTest -{ - - @Autowired - protected RestWrapper restAPI; - - @Autowired - protected JmxBuilder jmxBuilder; - - protected UserModel userModel, userModel1, adminUser; - protected RestAuditAppModelsCollection restAuditCollection; - protected RestAuditAppModel restAuditAppModel; - protected RestAuditEntryModel restAuditEntryModel; - protected RestAuditEntryModelsCollection restAuditEntryCollection; - protected RestAuditAppModel syncRestAuditAppModel; - protected RestAuditAppModel taggingRestAuditAppModel; - protected RestNodeModel node; - protected FileModel file; - protected SiteModel privateTestSite; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - //Audit API is designed for users with admin rights (except /nodes/{nodeId}/audit-entries) - //Create users and add userModel as SiteCollaborator on private site - userModel = dataUser.createRandomTestUser(); - userModel1 = dataUser.createRandomTestUser(); - adminUser = dataUser.getAdminUser(); - privateTestSite = dataSite.createPrivateRandomSite(); - - dataUser.addUserToSite(userModel, privateTestSite, UserRole.SiteCollaborator); - userModel.setUserRole(UserRole.SiteCollaborator); - - //Enable alfresco-access audit application. - jmxBuilder.getJmxClient().writeProperty("Alfresco:Type=Configuration,Category=Audit,id1=default", "audit.alfresco-access.enabled", Boolean.TRUE.toString()); - String alfrescoAccessEnabled = jmxBuilder.getJmxClient().readProperty("Alfresco:Type=Configuration,Category=Audit,id1=default", "audit.alfresco-access.enabled").toString(); - Assert.assertEquals(alfrescoAccessEnabled, Boolean.TRUE.toString(), String.format("Property audit.alfresco-access.enabled is [%s]", alfrescoAccessEnabled)); - - //GET /alfresco/service/api/audit/control to verify if Audit is enabled on the system. - RestAssured.basePath = ""; - restAPI.configureRequestSpec().setBasePath(RestAssured.basePath); - RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "alfresco/service/api/audit/control"); - RestResponse response = restAPI.authenticateUser(adminUser).process(request); - response.assertThat().body("enabled", is(true)); - - //GET /audit-applications and verify that there are audit applications in the system. - restAuditCollection = restClient.authenticateUser(adminUser).withCoreAPI().usingAudit().getAuditApplications(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restAuditCollection.assertThat().entriesListIsNotEmpty(); - - //Find alfresco-access audit application in the list of audit applications. - int i = 0; - do - { - restAuditAppModel = restAuditCollection.getEntries().get(i++).onModel(); - } while (!restAuditAppModel.getName().equals("alfresco-access")); - - //Create new file - file = dataContent.usingUser(adminUser).usingSite(privateTestSite).createContent(DocumentType.TEXT_PLAIN); - node = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file).usingParams("include=isLocked").getNode(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - protected RestAuditAppModel getSyncRestAuditAppModel(UserModel userModel) throws Exception - { - restAuditCollection = restClient.authenticateUser(userModel).withCoreAPI().usingAudit().getAuditApplications(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restAuditCollection.assertThat().entriesListIsNotEmpty(); - RestAuditAppModel syncRestAuditAppModel = restAuditCollection.getEntries().get(0).onModel(); - return syncRestAuditAppModel; - } - - protected RestAuditAppModel getTaggingRestAuditAppModel(UserModel userModel) throws Exception - { - restAuditCollection = restClient.authenticateUser(userModel).withCoreAPI().usingAudit().getAuditApplications(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restAuditCollection.assertThat().entriesListIsNotEmpty(); - RestAuditAppModel taggingRestAuditAppModel = restAuditCollection.getEntries().get(1).onModel(); - return taggingRestAuditAppModel; - } - -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/audit/DeleteAuditTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/audit/DeleteAuditTests.java deleted file mode 100644 index 603bcccf6..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/audit/DeleteAuditTests.java +++ /dev/null @@ -1,67 +0,0 @@ -package org.alfresco.service.search.rest.audit; - -import static org.testng.Assert.assertEquals; - -import org.alfresco.rest.audit.AuditTest; -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; - -@Test(groups = {TestGroup.REQUIRE_JMX}) -public class DeleteAuditTests extends AuditTest -{ - - @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if deleting an audit entry for an application is only for admin user, and status code is 204") - public void deleteAuditEntry() throws Exception - { - restAuditEntryCollection = restClient.authenticateUser(adminUser).withParams("maxItems=10").withCoreAPI().usingAudit() - .listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); - restClient.assertStatusCodeIs(HttpStatus.OK); - String entryId = restAuditEntryCollection.getEntries().get(restAuditEntryCollection.getPagination().getCount() - 1) - .onModel().getId(); - - restClient.authenticateUser(userModel).withCoreAPI().usingAudit() - .deleteAuditEntryForAnAuditApplication(restAuditAppModel.getId(), entryId); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - - restClient.authenticateUser(adminUser).withCoreAPI().usingAudit() - .deleteAuditEntryForAnAuditApplication(restAuditAppModel.getId(), entryId); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restAuditEntryModel = restClient.authenticateUser(adminUser).withCoreAPI().usingAudit() - .getAuditEntryForAnAuditApplication(restAuditAppModel.getId(), entryId); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if deleting a set of audit entries for an application is only for admin user, and status code is 204") - public void deleteAuditEntriesForAnAuditApplication() throws Exception - { - restAuditEntryCollection = restClient.authenticateUser(adminUser).withParams("maxItems=4").withCoreAPI().usingAudit() - .listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); - restClient.assertStatusCodeIs(HttpStatus.OK); - - String firstId = restAuditEntryCollection.getEntries().get(0).onModel().getId(); - String secondId = restAuditEntryCollection.getEntries().get(restAuditEntryCollection.getPagination().getCount() - 1) - .onModel().getId(); - - restClient.authenticateUser(userModel).withParams("where=(id BETWEEN (" + firstId + "," + secondId + "))").withCoreAPI() - .usingAudit().deleteAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - - restClient.authenticateUser(adminUser).withParams("where=(id BETWEEN (" + firstId + "," + secondId + "))").withCoreAPI() - .usingAudit().deleteAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restAuditEntryCollection = restClient.authenticateUser(adminUser).withParams("where=(id BETWEEN ("+firstId+","+secondId+"))").withCoreAPI().usingAudit() - .listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); - restClient.assertStatusCodeIs(HttpStatus.OK); - assertEquals(restAuditEntryCollection.getPagination().getCount(), 0); - } - -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/audit/GetAuditTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/audit/GetAuditTests.java deleted file mode 100644 index e565d8d68..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/audit/GetAuditTests.java +++ /dev/null @@ -1,358 +0,0 @@ -package org.alfresco.service.search.rest.audit; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; - -import java.util.ArrayList; - -import org.alfresco.rest.audit.AuditTest; -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; - -@Test(groups = {TestGroup.REQUIRE_JMX}) -public class GetAuditTests extends AuditTest -{ - - @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if the admin user gets audit application info") - public void getAuditApplicationInfoWithAdminUser() throws Exception - { - restAuditAppModel.assertThat().field("isEnabled").is(true); - restAuditAppModel.assertThat().field("name").is("alfresco-access"); - restAuditAppModel.assertThat().field("id").is("alfresco-access"); - - syncRestAuditAppModel = getSyncRestAuditAppModel(adminUser); - syncRestAuditAppModel.assertThat().field("isEnabled").is(true); - syncRestAuditAppModel.assertThat().field("name").is("Alfresco Sync Service"); - syncRestAuditAppModel.assertThat().field("id").is("sync"); - - taggingRestAuditAppModel = getTaggingRestAuditAppModel(adminUser); - taggingRestAuditAppModel.assertThat().field("isEnabled").is(true); - taggingRestAuditAppModel.assertThat().field("name").is("Alfresco Tagging Service"); - taggingRestAuditAppModel.assertThat().field("id").is("tagging"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if a normal user gets a list of audit applications and status code is 403") - public void getAuditApplicationsWithNormalUser() throws Exception - { - restAuditCollection = restClient.authenticateUser(userModel).withCoreAPI().usingAudit().getAuditApplications(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - restAuditCollection.assertThat().entriesListIsEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.AUDIT }, executionType = ExecutionType.REGRESSION, description = "Verify if the admin user gets a list of audit applications using skipCount and status code is 200") - public void getAuditApplicationsWithAdminUserUsingValidSkipCount() throws Exception - { - restAuditCollection = restClient.authenticateUser(adminUser).withParams("skipCount=1").withCoreAPI() - .usingAudit().getAuditApplications(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restAuditCollection.getPagination().assertThat().field("totalItems").isNotNull().and().field("totalItems") - .isGreaterThan(0).and().field("skipCount").is("1"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.AUDIT }, executionType = ExecutionType.REGRESSION, description = "Verify if the admin user gets a list of audit applications using invalid skipCount and status code is 400") - public void getAuditApplicationsWithAdminUserUsingInvalidSkipCount() throws Exception - { - restClient.authenticateUser(adminUser).withParams("skipCount=-1").withCoreAPI().usingAudit() - .getAuditApplications(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.AUDIT }, executionType = ExecutionType.REGRESSION, description = "Verify if the admin user gets a list of audit applications using maxItems and status code is 200") - public void getAuditApplicationsWithAdminUserUsingValidMaxItems() throws Exception - { - restAuditCollection = restClient.authenticateUser(adminUser).withParams("maxItems=1").withCoreAPI() - .usingAudit().getAuditApplications(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restAuditCollection.getPagination().assertThat().field("totalItems").isNotNull().and().field("totalItems") - .isGreaterThan(0).and().field("maxItems").is("1"); - assertEquals(restAuditCollection.getEntries().size(), 1); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.AUDIT }, executionType = ExecutionType.REGRESSION, description = "Verify if the admin user gets a list of audit applications using invalid maxItems and status code is 400") - public void getAuditApplicationsWithAdminUserUsingInvalidMaxItems() throws Exception - { - restClient.authenticateUser(adminUser).withParams("maxItems=-1").withCoreAPI().usingAudit() - .getAuditApplications(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - - restClient.authenticateUser(adminUser).withParams("maxItems=0").withCoreAPI().usingAudit() - .getAuditApplications(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - - } - - @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if the admin user gets a list of audit applications using skipCount and maxItems and status code is 200") - public void getAuditApplicationsWithAdminUserUsingValidSkipCountAndMaxItems() throws Exception - { - restAuditCollection = restClient.authenticateUser(adminUser).withParams("skipCount=1&maxItems=1") - .withCoreAPI().usingAudit().getAuditApplications(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restAuditCollection.getPagination().assertThat().field("totalItems").isNotNull().and().field("totalItems") - .isGreaterThan(0).and().field("maxItems").is("1").and().field("skipCount").is("1"); - assertEquals(restAuditCollection.getEntries().size(), 1); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.AUDIT }, executionType = ExecutionType.REGRESSION, description = "Verify if the admin user gets a list of audit applications using invalid skipCount and/or invalid maxItems and status code is 400") - public void getAuditApplicationsWithAdminUserUsingInvalidSkipCountAndMaxItems() throws Exception - { - restClient.authenticateUser(adminUser).withParams("skipCount=-1&maxItems=1").withCoreAPI().usingAudit() - .getAuditApplications(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - - restClient.authenticateUser(adminUser).withParams("skipCount=-1&maxItems=-1").withCoreAPI().usingAudit() - .getAuditApplications(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - - restClient.authenticateUser(adminUser).withParams("skipCount=-1&maxItems=0").withCoreAPI().usingAudit() - .getAuditApplications(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - - restClient.authenticateUser(adminUser).withParams("skipCount=1&maxItems=-1").withCoreAPI().usingAudit() - .getAuditApplications(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if a normal user gets a list of audit entries for audit application auditApplicationId and status code is 403") - public void getAuditEntriesWithNormalUser() throws Exception - { - restClient.authenticateUser(userModel).withCoreAPI().usingAudit() - .listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if the admin user gets a list of audit entries using invalid skipCount and/or invalid maxItems and status code is 400") - public void getAuditEntriesWithAdminUserUsingInvalidSkipCountAndMaxItems() throws Exception - { - restClient.authenticateUser(adminUser).withParams("skipCount=-1&maxItems=1").withCoreAPI().usingAudit() - .listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - - restClient.authenticateUser(adminUser).withParams("skipCount=-1&maxItems=-1").withCoreAPI().usingAudit() - .listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - - restClient.authenticateUser(adminUser).withParams("skipCount=-1&maxItems=0").withCoreAPI().usingAudit() - .listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - - restClient.authenticateUser(adminUser).withParams("skipCount=1&maxItems=-1").withCoreAPI().usingAudit() - .listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if the admin user gets a list of audit entries using valid skipCount and maxItems and status code is 200") - public void getAuditEntriesWithAdminUserUsingValidSkipCountAndMaxItems() throws Exception - { - restAuditEntryCollection = restClient.authenticateUser(adminUser).withParams("skipCount=1&maxItems=1") - .withCoreAPI().usingAudit().listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); - restClient.assertStatusCodeIs(HttpStatus.OK); - restAuditEntryCollection.getPagination().assertThat().field("totalItems").isNotNull().and().field("totalItems") - .isGreaterThan(0).and().field("maxItems").is("1").and().field("skipCount").is("1"); - assertEquals(restAuditEntryCollection.getEntries().size(), 1); - - // Testing Pagination - restAuditEntryCollection = restClient.authenticateUser(adminUser).withParams("maxItems=10").withCoreAPI().usingAudit() - .listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); - restClient.assertStatusCodeIs(HttpStatus.OK); - ArrayList ids = new ArrayList<>(); - int numberOfElements = restAuditEntryCollection.getPagination().getCount(); - for (int i = 0; i < numberOfElements; i++) - { - ids.add(restAuditEntryCollection.getEntries().get(i).onModel().getId()); - } - - int skipCount = 0; - do - { - restAuditEntryCollection = restClient.authenticateUser(adminUser).withParams("maxItems=1&skipCount=" + skipCount) - .withCoreAPI().usingAudit().listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); - restClient.assertStatusCodeIs(HttpStatus.OK); - assertEquals(restAuditEntryCollection.getEntries().size(), 1); - assertEquals(restAuditEntryCollection.getPagination().getCount(), 1); - assertEquals(restAuditEntryCollection.getPagination().getSkipCount(), skipCount); - assertEquals(restAuditEntryCollection.getEntries().get(0).onModel().getId(), ids.get(skipCount)); - skipCount++; - } while (skipCount < numberOfElements); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.AUDIT }, executionType = ExecutionType.REGRESSION, description = "Verify if the admin user gets a list of audit entries using orderBy and status code is 200") - public void getAuditEntriesWithAdminUserUsingOrderBy() throws Exception - { - restAuditEntryCollection = restClient.authenticateUser(adminUser).withParams("orderBy=createdAt ASC&maxItems=10") - .withCoreAPI().usingAudit().listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); - restClient.assertStatusCodeIs(HttpStatus.OK); - - String ascId = restAuditEntryCollection.getEntries().get(1).onModel().getId(); - - restAuditEntryCollection = restClient.authenticateUser(adminUser).withParams("orderBy=createdAt DESC&maxItems=10") - .withCoreAPI().usingAudit().listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); - restClient.assertStatusCodeIs(HttpStatus.OK); - - assertTrue(Integer.parseInt(restAuditEntryCollection.getEntries().get(1).onModel().getId()) > Integer.parseInt(ascId)); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.AUDIT }, executionType = ExecutionType.REGRESSION, description = "Verify if the admin user gets a list of audit entries using the where parameter to and status code is 200") - public void getAuditEntriesWithAdminUserUsingWhere() throws Exception - { - int expectedNumberOfItems; - String id1,id2; - restAuditEntryCollection = restClient.authenticateUser(adminUser).withParams("maxItems=2").withCoreAPI().usingAudit().listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); - restClient.assertStatusCodeIs(HttpStatus.OK); - - if (restAuditEntryCollection.getPagination().getCount() == 2) - { - id1 = restAuditEntryCollection.getEntries().get(0).onModel().getId(); - id2 = restAuditEntryCollection.getEntries().get(1).onModel().getId(); - expectedNumberOfItems = 2; - } - else - { - id1 = id2 = restAuditEntryCollection.getEntries().get(0).onModel().getId(); - expectedNumberOfItems = 1; - } - - restAuditEntryCollection = restClient.authenticateUser(adminUser).withParams("where=(id BETWEEN ("+id1+","+id2+"))") - .withCoreAPI().usingAudit().listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); - restClient.assertStatusCodeIs(HttpStatus.OK); - - restAuditEntryCollection.assertThat().entriesListCountIs(expectedNumberOfItems); - assertEquals(id1, restAuditEntryCollection.getEntries().get(0).onModel().getId()); - if (!id1.equals(id2)) - { - assertEquals(id2, restAuditEntryCollection.getEntries().get(1).onModel().getId()); - } - } - - @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if retrieving an audit entry for an audit application is only for admin user, with and without the include=values paramater and status code is 200") - public void getAuditEntry() throws Exception - { - restAuditEntryCollection = restClient.authenticateUser(adminUser).withParams("maxItems=10").withCoreAPI().usingAudit() - .listAuditEntriesForAnAuditApplication(restAuditAppModel.getId()); - restClient.assertStatusCodeIs(HttpStatus.OK); - String entryId = restAuditEntryCollection.getEntries().get(restAuditEntryCollection.getPagination().getCount() - 1) - .onModel().getId(); - String entryApplicationId = restAuditEntryCollection.getEntries() - .get(restAuditEntryCollection.getPagination().getCount() - 1).onModel().getAuditApplicationId(); - - restAuditEntryModel = restClient.authenticateUser(userModel).withCoreAPI().usingAudit() - .getAuditEntryForAnAuditApplication(restAuditAppModel.getId(), entryId); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - - restAuditEntryModel = restClient.authenticateUser(adminUser).withCoreAPI().usingAudit() - .getAuditEntryForAnAuditApplication(restAuditAppModel.getId(), entryId); - restClient.assertStatusCodeIs(HttpStatus.OK); - assertEquals(entryId, restAuditEntryModel.getId()); - assertEquals(entryApplicationId, restAuditEntryModel.getAuditApplicationId()); - // Values are displayed by default for single audit application entry - assertNotNull(restAuditEntryModel.getValues()); - - restAuditEntryModel = restClient.authenticateUser(adminUser).withParams("include=values").withCoreAPI().usingAudit() - .getAuditEntryForAnAuditApplication(restAuditAppModel.getId(), entryId); - restClient.assertStatusCodeIs(HttpStatus.OK); - assertEquals(entryId, restAuditEntryModel.getId()); - assertEquals(entryApplicationId, restAuditEntryModel.getAuditApplicationId()); - assertNotNull(restAuditEntryModel.getValues()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if the admin user gets a list of audit entries for node id nodeId using 'where' and 'maxItems' param and status code is 200") - public void getAuditEntriesForNodeUsingMaxItemsAndWhereParam() throws Exception - { - String createdAt1, createdAt2; - int expectedNumberOfItems; - - // Get the node id - String nodeId = node.getId(); - - // Add comments for a node (to create audit entries) - restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file).addComment("This is the first comment"); - restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file).addComment("This is the second comment"); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - // Get maxium two audit entries for the node using 'maxItems' param on /nodes/{nodeId}/audit-entries - restAuditEntryCollection = restClient.authenticateUser(adminUser).withParams("maxItems=2").withCoreAPI().usingAudit().listAuditEntriesForNode(nodeId); - restClient.assertStatusCodeIs(HttpStatus.OK); - restAuditEntryCollection.assertThat().entriesListIsNotEmpty(); - - if (restAuditEntryCollection.getPagination().getCount() == 2) - { - createdAt1 = restAuditEntryCollection.getEntries().get(0).onModel().getCreatedAt(); - createdAt2 = restAuditEntryCollection.getEntries().get(1).onModel().getCreatedAt(); - expectedNumberOfItems = 2; - } - else - { - createdAt1 = createdAt2 = restAuditEntryCollection.getEntries().get(0).onModel().getCreatedAt(); - expectedNumberOfItems = 1; - } - - // Get audit entries between ids for the node using 'where' clause on /nodes/{nodeId}/audit-entries - restAuditEntryCollection = restClient.authenticateUser(adminUser).withParams("where=(createdAt BETWEEN ('" + createdAt1 + "','" + createdAt2 + "'))") - .withCoreAPI().usingAudit().listAuditEntriesForNode(nodeId); - restClient.assertStatusCodeIs(HttpStatus.OK); - - restAuditEntryCollection.assertThat().entriesListCountIs(expectedNumberOfItems); - assertEquals(createdAt1, restAuditEntryCollection.getEntries().get(0).onModel().getCreatedAt()); - if (!createdAt1.equals(createdAt2)) - { - assertEquals(createdAt2, restAuditEntryCollection.getEntries().get(1).onModel().getCreatedAt()); - } - } - - @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if user with permissions can get a list of audit entries for node and status code is 200") - public void getAuditEntriesForNodeUsingUserWithPermissions() throws Exception - { - // Get the node id - String nodeId = node.getId(); - - // Add comments for a node using user with permissions (to create audit entries and check if user can view/edit the node) - restClient.authenticateUser(userModel).withCoreAPI().usingNode(file).addComment("This is a comment"); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - // Get audit entries for the node using a user with permissions and /nodes/{nodeId}/audit-entries - restAuditEntryCollection = restClient.authenticateUser(userModel).withCoreAPI().usingAudit().listAuditEntriesForNode(nodeId); - restClient.assertStatusCodeIs(HttpStatus.OK); - restAuditEntryCollection.assertThat().entriesListIsNotEmpty(); - - // Check that a user that doesn't have access to node, doesn't have access to audit entries for node - restClient.authenticateUser(userModel1).withCoreAPI().usingNode(file).getNode(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - restClient.authenticateUser(userModel1).withCoreAPI().usingAudit().listAuditEntriesForNode(nodeId); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/audit/PutAuditTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/audit/PutAuditTests.java deleted file mode 100644 index aa038ac7d..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/audit/PutAuditTests.java +++ /dev/null @@ -1,112 +0,0 @@ -package org.alfresco.service.search.rest.audit; - -import org.alfresco.rest.audit.AuditTest; -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; - -@Test(groups = {TestGroup.REQUIRE_JMX}) -public class PutAuditTests extends AuditTest -{ - - @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.AUDIT }, executionType = ExecutionType.REGRESSION, description = "Verify that the admin user can enable/disable sync application auditing") - public void enableDisableSyncApplicationAuditingAsAdminUser() throws Exception - { - // disable sync audit app - syncRestAuditAppModel = getSyncRestAuditAppModel(adminUser); - restClient.authenticateUser(adminUser).withCoreAPI().usingAudit().updateAuditApp(syncRestAuditAppModel, "isEnabled", - "false"); - - // check isEnabled=false - syncRestAuditAppModel = getSyncRestAuditAppModel(adminUser); - syncRestAuditAppModel.assertThat().field("isEnabled").is(false); - syncRestAuditAppModel.assertThat().field("name").is("Alfresco Sync Service"); - syncRestAuditAppModel.assertThat().field("id").is("sync"); - - // enable sync audit app - restClient.authenticateUser(adminUser).withCoreAPI().usingAudit().updateAuditApp(syncRestAuditAppModel, "isEnabled", - "true"); - - // check isEnabled=true - syncRestAuditAppModel = getSyncRestAuditAppModel(adminUser); - syncRestAuditAppModel.assertThat().field("isEnabled").is(true); - syncRestAuditAppModel.assertThat().field("name").is("Alfresco Sync Service"); - syncRestAuditAppModel.assertThat().field("id").is("sync"); - - } - - @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify that the admin user can enable/disable tagging application auditing") - public void enableDisableTaggingApplicationAuditingAsAdminUser() throws Exception - { - // disable tagging audit app - taggingRestAuditAppModel = getTaggingRestAuditAppModel(adminUser); - restClient.authenticateUser(adminUser).withCoreAPI().usingAudit().updateAuditApp(taggingRestAuditAppModel, "isEnabled", - "false"); - - // check isEnabled=false - taggingRestAuditAppModel = getTaggingRestAuditAppModel(adminUser); - taggingRestAuditAppModel.assertThat().field("isEnabled").is(false); - taggingRestAuditAppModel.assertThat().field("name").is("Alfresco Tagging Service"); - taggingRestAuditAppModel.assertThat().field("id").is("tagging"); - - // enable tagging audit app - restClient.authenticateUser(adminUser).withCoreAPI().usingAudit().updateAuditApp(taggingRestAuditAppModel, "isEnabled", - "true"); - - // check isEnabled=true - taggingRestAuditAppModel = getTaggingRestAuditAppModel(adminUser); - taggingRestAuditAppModel.assertThat().field("isEnabled").is(true); - taggingRestAuditAppModel.assertThat().field("name").is("Alfresco Tagging Service"); - taggingRestAuditAppModel.assertThat().field("id").is("tagging"); - - } - - @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.AUDIT }, executionType = ExecutionType.REGRESSION, description = "Verify that the normal user can't enable/disable sync application auditing") - public void enableDisableSyncApplicationAuditingAsNormalUser() throws Exception - { - // disable sync audit app - syncRestAuditAppModel = getSyncRestAuditAppModel(adminUser); - restClient.authenticateUser(userModel).withCoreAPI().usingAudit().updateAuditApp(syncRestAuditAppModel, "isEnabled", - "false"); - - // permission denied - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - - // enable sync audit app - restClient.authenticateUser(userModel).withCoreAPI().usingAudit().updateAuditApp(syncRestAuditAppModel, "isEnabled", - "true"); - - // permission denied - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify that the normal user can't enable/disable tagging application auditing") - public void enableDisableTaggingApplicationAuditingAsNormalUser() throws Exception - { - // disable tagging audit app - taggingRestAuditAppModel = getTaggingRestAuditAppModel(adminUser); - restClient.authenticateUser(userModel).withCoreAPI().usingAudit().updateAuditApp(taggingRestAuditAppModel, "isEnabled", - "false"); - - // permission denied - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - - // disable tagging audit app - restClient.authenticateUser(userModel).withCoreAPI().usingAudit().updateAuditApp(taggingRestAuditAppModel, "isEnabled", - "true"); - - // permission denied - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - } - -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/auth/AuthTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/auth/AuthTests.java deleted file mode 100644 index 4ddbc61d8..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/auth/AuthTests.java +++ /dev/null @@ -1,87 +0,0 @@ -package org.alfresco.service.search.rest.auth; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.core.RestWrapper; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestTicketBodyModel; -import org.alfresco.rest.model.RestTicketModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.apache.commons.codec.binary.Base64; -import org.springframework.http.HttpStatus; -import org.testng.Assert; -import org.testng.annotations.Test; - -public class AuthTests extends RestTest -{ - - private RestWrapper addRestRequestAuthorization(RestTicketModel ticketModel) - { - restClient.configureRequestSpec().addHeader("Authorization", "Basic " + encodeB64(ticketModel.getId())); - return restClient; - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.AUTH }, executionType = ExecutionType.SANITY, description = "Verify HttpMethod.POST tickets") - @Test(groups = { TestGroup.REST_API, TestGroup.SANITY, TestGroup.AUTH }) - public void adminShouldGetTicketBody() throws JsonToModelConversionException, Exception - { - RestTicketBodyModel ticketBody = new RestTicketBodyModel(); - ticketBody.setUserId("admin"); - ticketBody.setPassword("admin"); - - RestTicketModel ticketReturned = restClient.authenticateUser(dataContent.getAdminUser()).withAuthAPI().createTicket(ticketBody); - - restClient.assertStatusCodeIs(HttpStatus.CREATED); - ticketReturned.assertThat().field("id").contains("TICKET_"); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.AUTH }, executionType = ExecutionType.SANITY, description = "Verify HttpMethod.GET tickets/-me-") - @Test(groups = { TestGroup.REST_API, TestGroup.SANITY, TestGroup.AUTH }) - public void randomUserGetTicket() throws Exception - { - UserModel userModel = dataUser.createRandomTestUser(); - RestTicketBodyModel ticketBody = new RestTicketBodyModel(); - ticketBody.setUserId(userModel.getUsername()); - ticketBody.setPassword(userModel.getPassword()); - - RestTicketModel ticketCreated = restClient.authenticateUser(userModel).withAuthAPI().createTicket(ticketBody); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - addRestRequestAuthorization(ticketCreated); - RestTicketModel ticketReturned = restClient.withAuthAPI().getTicket(); - Assert.assertEquals(ticketCreated.getId(), ticketReturned.getId()); - - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.AUTH }, executionType = ExecutionType.SANITY, description = "Verify HttpMethod.REMOVE tickets/-me-") - @Test(groups = { TestGroup.REST_API, TestGroup.SANITY, TestGroup.AUTH }) - public void randomUserRemoveTicket() throws Exception - { - UserModel userModel = dataUser.createRandomTestUser(); - RestTicketBodyModel ticketBody = new RestTicketBodyModel(); - ticketBody.setUserId(userModel.getUsername()); - ticketBody.setPassword(userModel.getPassword()); - - RestTicketModel ticketCreated = restClient.authenticateUser(userModel).withAuthAPI().createTicket(ticketBody); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - addRestRequestAuthorization(ticketCreated); - restClient.withAuthAPI().removeTicket(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withAuthAPI().getTicket(); - restClient.assertLastError().containsErrorKey("Ticket base authentication required."); - - } - - private String encodeB64(String str) - { - return Base64.encodeBase64String(str.getBytes()); - } - -} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/cmis/CmisBrowserTest.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/cmis/CmisBrowserTest.java deleted file mode 100644 index 56e99e3a2..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/cmis/CmisBrowserTest.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.alfresco.service.search.rest.cmis; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.core.RestResponse; -import org.alfresco.utility.model.FileModel; -import org.testng.annotations.Test; - -public class CmisBrowserTest extends RestTest -{ - /* - * @author: Paul Brodner - * simple test for demo purposes on how to use CMIS browser binding with Rest - */ - @Test(enabled=false) - public void assertContentDispositionHeaderOnCmisFile() throws Exception - { - FileModel document = dataContent.usingUser(dataUser.getAdminUser()) - .usingSite(testSite).createContent(DocumentType.HTML); - - RestResponse response = restClient.authenticateUser(dataUser.getAdminUser()).withCMISApi().getRootObjectByID(document); - response.assertThat().header("Content-Disposition", String.format("attachment; filename=%s", document.getName())); - } - -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/comments/AddCommentTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/comments/AddCommentTests.java deleted file mode 100644 index f4eb84930..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/comments/AddCommentTests.java +++ /dev/null @@ -1,260 +0,0 @@ -package org.alfresco.service.search.rest.comments; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestCommentModel; -import org.alfresco.rest.model.RestCommentModelsCollection; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestTagModel; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FileType; -import org.alfresco.utility.model.LinkModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.apache.commons.lang3.RandomStringUtils; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class AddCommentTests extends RestTest -{ - private UserModel adminUserModel; - private FileModel document; - private SiteModel siteModel; - private ListUserWithRoles usersWithRoles; - private String comment; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - restClient.authenticateUser(adminUserModel); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify admin user adds comments with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) - public void adminIsAbleToAddComment() throws Exception - { - restClient.authenticateUser(adminUserModel); - String newContent = "This is a new comment added by " + adminUserModel.getUsername(); - restClient.withCoreAPI().usingResource(document).addComment(newContent) - .assertThat().field("content").isNotEmpty() - .and().field("content").is(newContent); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.onResponse().assertThat().body("entry.edited", org.hamcrest.Matchers.is(false)); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, - description = "Verify that comment can be retrieved after it is added") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) - public void addCommentThenRetrieveComment() throws Exception - { - comment = RandomData.getRandomName("comment1"); - restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingResource(document).addComment(comment); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestCommentModelsCollection comments = restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingResource(document).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - comments.assertThat().entriesListContains("content", comment); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user gets status code 401 on post comments call") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) -// @Bug(id = "MNT-16904", description = "It fails only on environment with tenants") - public void unauthenticatedUserIsNotAbleToAddComment() throws Exception - { - restClient.authenticateUser(new UserModel("random user", "random password")); - restClient.withCoreAPI().usingResource(document).addComment("This is a new comment"); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Manager user adds comments with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void managerIsAbleToAddComment() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - String contentSiteManger = "This is a new comment added by user with role: " + UserRole.SiteManager; - RestCommentModel createdComment = restClient.withCoreAPI().usingResource(document).addComment(contentSiteManger); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - createdComment.assertThat().field("content").isNotEmpty() - .and().field("content").is(contentSiteManger); - - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Contributor user adds comments with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - @Bug(id="ACE-4614") - public void contributorIsAbleToAddComment() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - String contentSiteContributor = "This is a new comment added by user with role" + UserRole.SiteContributor; - RestCommentModel createdComment = restClient.withCoreAPI().usingResource(document).addComment(contentSiteContributor); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - createdComment.assertThat().field("content").isNotEmpty() - .and().field("content").is(contentSiteContributor); - - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user adds comments with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void collaboratorIsAbleToAddComment() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - String contentSiteCollaborator = "This is a new comment added by user with role: " + UserRole.SiteCollaborator; - restClient.withCoreAPI().usingResource(document).addComment(contentSiteCollaborator) - .assertThat().field("content").isNotEmpty() - .and().field("content").is(contentSiteCollaborator); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Consumer user can't add comments with Rest API and status code is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void consumerIsNotAbleToAddComment() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - String contentSiteConsumer = "This is a new comment added by user with role: " + UserRole.SiteConsumer; - restClient.withCoreAPI().usingResource(document).addComment(contentSiteConsumer); - restClient - .assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, - description = "Verify that invalid request returns status code 404 for nodeId that does not exist") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void addCommentUsingInvalidNodeId() throws Exception - { - comment = RandomData.getRandomName("comment1"); - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - file.setNodeRef(RandomStringUtils.randomAlphanumeric(20)); - - restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingResource(file).addComment(comment); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, file.getNodeRef())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, - description = "Verify that request using nodeId that is neither document or folder returns 405") - @Bug(id = "MNT-16904") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void addCommentUsingResourceThatIsNotFileOrFolder() throws Exception - { - comment = RandomData.getRandomName("comment1"); - LinkModel link = dataLink.usingAdmin().usingSite(siteModel).createRandomLink(); - FileModel fileWithNodeRefFromLink = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); - fileWithNodeRefFromLink = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - fileWithNodeRefFromLink.setNodeRef(link.getNodeRef()); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(fileWithNodeRefFromLink).addComment(comment); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, - description = "Verify that adding comment using empty content returns 400 status code") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void addCommentUsingEmptyContent() throws Exception - { - restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingResource(document).addComment(""); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.NULL_ARGUMENT, "comment")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, - description = "Verify adding comment with the same content as one existing comment") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void addCommentTwice() throws Exception - { - comment = RandomData.getRandomName("comment1"); - restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingResource(document).addComment(comment); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingResource(document).addComment(comment); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.withCoreAPI().usingResource(document).getNodeComments() - .assertThat().entriesListContains("content", comment); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, - description = "Verify comment cannot be added if user is not member of private site") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void addCommentWithNonMemberOfPrivateSite() throws Exception - { - comment = RandomData.getRandomName("comment1"); - UserModel member = dataUser.createRandomTestUser(); - SiteModel privateSite = dataSite.usingUser(adminUserModel).createPrivateRandomSite(); - FileModel file = dataContent.usingSite(privateSite).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(member) - .withCoreAPI().usingResource(file).addComment(comment); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, - description = "Verify comment cannot be added if empty network ID is provided") -// @Bug(id = "MNT-16904", description = "It fails only on environment with tenants") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void addCommentUsingEmptyNetworkId() throws Exception - { - comment = RandomData.getRandomName("comment1"); - UserModel member = dataUser.createRandomTestUser(); - member.setDomain(""); - - restClient.authenticateUser(member) - .withCoreAPI().usingResource(document).addComment(comment); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, - description = "Verify that comment cannot be added to another comment") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void addCommentToAComment() throws Exception - { - comment = RandomData.getRandomName("comment1"); - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - RestCommentModel commentEntry = restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingResource(file).addComment(comment); - file.setNodeRef(commentEntry.getId()); - - restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingResource(file).addComment(comment); - - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.CANNOT_COMMENT); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, - description = "Verify that comment cannot be added to a tag") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void addCommentToATag() throws Exception - { - comment = RandomData.getRandomName("comment1"); - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag("randomTag"); - - file.setNodeRef(tag.getId()); - - restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingResource(file).addComment(comment); - - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.CANNOT_COMMENT); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/comments/AddCommentsTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/comments/AddCommentsTests.java deleted file mode 100644 index 77984666c..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/comments/AddCommentsTests.java +++ /dev/null @@ -1,377 +0,0 @@ -package org.alfresco.service.search.rest.comments; - -import java.util.List; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.core.JsonBodyGenerator; -import org.alfresco.rest.core.RestRequest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestCommentModel; -import org.alfresco.rest.model.RestCommentModelsCollection; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestTagModel; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser; -import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FileType; -import org.alfresco.utility.model.LinkModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.apache.commons.lang3.RandomStringUtils; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -/** - * Created by Claudia Agache on 10/10/2016. - */ -public class AddCommentsTests extends RestTest -{ - private UserModel adminUserModel, networkUserModel; - private FileModel document; - private SiteModel siteModel; - private DataUser.ListUserWithRoles usersWithRoles; - private RestCommentModelsCollection comments; - private String comment1, comment2; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - networkUserModel = dataUser.createRandomTestUser(); - restClient.authenticateUser(adminUserModel); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - - document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); - } - - @BeforeMethod(alwaysRun = true) - public void generateRandomComments() - { - comment1 = RandomData.getRandomName("comment1"); - comment2 = RandomData.getRandomName("comment2"); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify admin user adds multiple comments with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) - public void adminIsAbleToAddComments() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingResource(document).addComments(comment1, comment2) - .assertThat().entriesListIsNotEmpty() - .and().entriesListContains("content", comment1) - .and().entriesListContains("content", comment2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user gets status code 401 on post multiple comments call") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) - public void unauthenticatedUserIsNotAbleToAddComments() throws JsonToModelConversionException, Exception - { - restClient.noAuthentication() - .withCoreAPI().usingResource(document).addComments(comment1, comment2); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Manager user adds multiple comments with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void managerIsAbleToAddComments() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(document).addComments(comment1, comment2) - .assertThat().entriesListIsNotEmpty() - .and().entriesListContains("content", comment1) - .and().entriesListContains("content", comment2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Contributor user adds multiple comments with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void contributorIsAbleToAddComments() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) - .withCoreAPI().usingResource(document).addComments(comment1, comment2) - .assertThat().entriesListIsNotEmpty() - .and().entriesListContains("content", comment1) - .and().entriesListContains("content", comment2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user adds multiple comments with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void collaboratorIsAbleToAddComments() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingResource(document).addComments(comment1, comment2) - .assertThat().paginationExist().and().entriesListIsNotEmpty() - .and().entriesListContains("content", comment1) - .and().entriesListContains("content", comment2); - - restClient.assertStatusCodeIs(HttpStatus.CREATED); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Consumer user adds multiple comments with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void consumerIsAbleToAddComments() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .withCoreAPI().usingResource(document).addComments(comment1, comment2); - - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify User can not add comments to a not joined private site. Status code returned is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void userCanNotAddCommentsToANotJoinedPrivateSite() throws Exception - { - SiteModel sitePrivateNotJoined = dataSite.createPrivateRandomSite(); - FileModel file = dataContent.usingSite(sitePrivateNotJoined).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(file).addComments(comment1, comment2); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify User can't add comments to a node with ID that does not exist and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void userCanNotAddCommentsOnNonexistentFile() throws Exception - { - FileModel nonexistentFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); - - nonexistentFile.setNodeRef("ABC"); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(nonexistentFile).addComments(comment1,comment2); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, nonexistentFile.getNodeRef())); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify User can't add comments to a node that exists but is not a document or a folder and status code is 405") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - @Bug(id = "MNT-16904") - public void userCanNotAddCommentsOnLink() throws Exception - { - LinkModel link = dataLink.usingAdmin().usingSite(siteModel).createRandomLink(); - FileModel fileWithNodeRefFromLink = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); - fileWithNodeRefFromLink.setNodeRef(link.getNodeRef()); - - restClient.authenticateUser(adminUserModel).withCoreAPI() - .usingResource(fileWithNodeRefFromLink).addComments(comment1,comment2); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(RestErrorModel.UNABLE_TO_LOCATE); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify User can add comments with the same content as one existing comment") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void userCanAddCommentWithTheSameContentAsExistingOne() throws Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - String sameComment = comment1; - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(file).addComments(comment1, sameComment) - .assertThat().paginationExist().and().entriesListIsNotEmpty() - .and().entriesListContains("content", comment1) - .and().entriesListContains("content", sameComment); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - comments = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI() - .usingResource(file).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListIsNotEmpty(); - List commentsList = comments.getEntries(); - commentsList.get(0).onModel().assertThat().field("content").is(comment1); - commentsList.get(1).onModel().assertThat().field("content").is(sameComment); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify add comments from node with invalid network id returns status code 401") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void addCommentsWithInvalidNetworkId() throws Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - - networkUserModel.setDomain("invalidNetwork"); - restClient.authenticateUser(networkUserModel).withCoreAPI().usingResource(file).addComments(comment1,comment2); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify add comments from node with empty network id returns status code 401") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void addCommentsWithEmptyNetworkId() throws Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - - networkUserModel.setDomain(""); - restClient.authenticateUser(networkUserModel).withCoreAPI().usingResource(file).addComments(comment1,comment2); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, - description = "Verify that comments cannot be added to another comment") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void addCommentsToAComment() throws JsonToModelConversionException, Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - RestCommentModel commentEntry = restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingResource(file).addComment(comment1); - file.setNodeRef(commentEntry.getId()); - - restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingResource(file).addComments(comment1, comment2); - - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.CANNOT_COMMENT); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, - description = "Verify that comments cannot be added to a tag") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void addCommentsToATag() throws JsonToModelConversionException, Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - RestTagModel tag = restClient.withCoreAPI().usingResource(file).addTag("randomTag"); - - file.setNodeRef(tag.getId()); - - restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingResource(file).addComments(comment1, comment2); - - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.CANNOT_COMMENT); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Using Manager user verify that you can provide a large string for one comment") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void addLongCommentsWithManagerAndCheckThatCommentIsReturned() throws Exception - { - document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - String longString = RandomStringUtils.randomAlphanumeric(10000); - String longString1 = RandomStringUtils.randomAlphanumeric(90000); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(document).addComments(longString, longString1); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", longString); - comments.assertThat().entriesListContains("content", longString1); - comments.assertThat().paginationField("totalItems").is("2"); - comments.assertThat().paginationField("count").is("2"); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Using Manager user verify that you can provide a short string for one comment") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void addShortCommentsWithManagerAndCheckThatCommentIsReturned() throws Exception - { - document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - String shortString = RandomStringUtils.randomAlphanumeric(2); - String shortString1 = RandomStringUtils.randomAlphanumeric(1); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(document).addComments(shortString, shortString1); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", shortString); - comments.assertThat().entriesListContains("content", shortString1); - comments.assertThat().paginationField("totalItems").is("2"); - comments.assertThat().paginationField("count").is("2"); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Using Collaborator user verify that you can provide a string with special characters for one comment") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void addCommentsWithSpecialCharsWithCollaboratorCheckCommentIsReturned() throws Exception - { - document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - String specialCharsString = "!@#$%^&*()'\".,<>-_+=|\\"; - String shortString = RandomStringUtils.randomAlphanumeric(2); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingResource(document).addComments(specialCharsString, shortString); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", specialCharsString); - comments.assertThat().entriesListContains("content", shortString); - comments.assertThat().paginationField("totalItems").is("2"); - comments.assertThat().paginationField("count").is("2"); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Using Manager user verify that you can not provide an empty string for one comment") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void addEmptyStringCommentsWithManagerCheckCommentIsReturned() throws Exception - { - document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - String emptyString = ""; - String spaceString = " "; - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(document).addComments(emptyString, spaceString); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(RestErrorModel.NON_NULL_COMMENT); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Using Collaborator user verify that you can provide several comments in one request") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void addSeveralCommentsWithCollaboratorCheckCommentsAreReturned() throws Exception - { - document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - String charString = RandomStringUtils.randomAlphanumeric(10); - String charString1 = RandomStringUtils.randomAlphanumeric(10); - String charString2 = RandomStringUtils.randomAlphanumeric(10); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingResource(document).addComments(comment1, comment2, charString, charString1, charString2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", comment1); - comments.assertThat().paginationField("totalItems").is("5"); - comments.assertThat().paginationField("count").is("5"); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Provide invalid request body parameter and check default error model schema") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void invalidRequestBodyParameterCheckErrorModelSchema() throws Exception - { - document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(adminUserModel).withCoreAPI(); - String postBody = JsonBodyGenerator.keyValueJson("content2", comment1); - RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, postBody, "nodes/{nodeId}/comments", document.getNodeRef()); - restClient.processModel(RestCommentModel.class, request); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - restClient.assertLastError().containsErrorKey(String.format(RestErrorModel.UNRECOGNIZED_FIELD, "content2")); - restClient.assertLastError().containsSummary(String.format(RestErrorModel.UNRECOGNIZED_FIELD, "content2")); - restClient.assertLastError().descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - restClient.assertLastError().stackTraceIs(RestErrorModel.STACKTRACE); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/comments/DeleteCommentTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/comments/DeleteCommentTests.java deleted file mode 100644 index ee44818cc..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/comments/DeleteCommentTests.java +++ /dev/null @@ -1,295 +0,0 @@ -package org.alfresco.service.search.rest.comments; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestCommentModel; -import org.alfresco.rest.model.RestCommentModelsCollection; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class DeleteCommentTests extends RestTest -{ - private UserModel adminUserModel, networkUserModel; - - private FileModel document; - private SiteModel siteModel; - private RestCommentModelsCollection comments; - private RestCommentModel commentModel; - private ListUserWithRoles usersWithRoles; - private String commentText = "This is a new comment"; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - networkUserModel = dataUser.createRandomTestUser(); - restClient.authenticateUser(adminUserModel); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Admin user deletes comments with Rest API and status code is 204") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) - public void adminIsAbleToDeleteComments() throws Exception - { - restClient.authenticateUser(adminUserModel); - commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment"); - restClient.withCoreAPI().usingResource(document).deleteComment(commentModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify User gets status code 401 if authentication call fails") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) -// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void userIsNotAbleToDeleteCommentIfAuthenticationFails() throws Exception - { - restClient.authenticateUser(adminUserModel); - commentModel = restClient.withCoreAPI().usingResource(document).addComment("New comment addded by admin"); - UserModel nonexistentModel = new UserModel("nonexistentUser", "nonexistentPassword"); - restClient.authenticateUser(nonexistentModel); - restClient.withCoreAPI().usingResource(document).deleteComment(commentModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Manager user deletes own comments and status code is 204") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void managerIsAbleToDeleteComments() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - commentModel = restClient.withCoreAPI().usingResource(document).addComment("New comment added by Manager"); - restClient.withCoreAPI().usingResource(document).deleteComment(commentModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user deletes own comments and status code is 204") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void collaboratorIsAbleToDeleteComments() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - commentModel = restClient.withCoreAPI().usingResource(document).addComment("New comment added by Collaborator"); - restClient.withCoreAPI().usingResource(document).deleteComment(commentModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Contributor user deletes own comments and status code is 204") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void contributorIsAbleToDeleteComments() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - commentModel = restClient.withCoreAPI().usingResource(document).addComment("New comment added by Contributor"); - restClient.withCoreAPI().usingResource(document).deleteComment(commentModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Consumer user can't delete comments created by admin user and status code is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void consumerIsNotAbleToDeleteComments() throws Exception - { - restClient.authenticateUser(adminUserModel); - commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment"); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.withCoreAPI().usingResource(document).deleteComment(commentModel); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Admin user can't delete comments with inexistent ID and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void userIsNotAbleToDeleteInexistentComment() throws Exception - { - restClient.authenticateUser(adminUserModel); - commentModel = new RestCommentModel(); - commentModel.setId("inexistent"); - restClient.withCoreAPI().usingResource(document).deleteComment(commentModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Admin user can't delete comments with inexistend NodeId and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void userIsNotAbleToDeleteCommentWithInexistentNodeId() throws Exception - { - restClient.authenticateUser(adminUserModel); - commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment"); - FileModel inexistentDocument = new FileModel(); - inexistentDocument.setNodeRef("inexistent"); - restClient.withCoreAPI().usingResource(inexistentDocument).deleteComment(commentModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Admin user can't delete deleted comments and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void userIsNotAbleToDeleteDeletedComment() throws Exception - { - restClient.authenticateUser(adminUserModel); - commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment"); - restClient.withCoreAPI().usingResource(document).deleteComment(commentModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingResource(document).deleteComment(commentModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS }, - executionType = ExecutionType.REGRESSION, description = "Verify Manager user deletes comment created by admin" - + " and status code is 204. Check with getComments for validation") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void managerIsAbleToDeleteCommentCreatedByOthers() throws Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - - commentModel = restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingResource(file).addComment(commentText); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(file).deleteComment(commentModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListDoesNotContain("content", commentText); - comments.getPagination().assertThat().field("totalItems").is("0").and().field("count").is("0"); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS }, - executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user can delete comment created by self" - + " and status code is 204. Check with getComments for validation") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void collaboratorIsAbleToDeleteCommentCreatedBySelf() throws Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - - commentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingResource(file).addComment(commentText); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.withCoreAPI().usingResource(file).deleteComment(commentModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListDoesNotContain("content", commentText); - comments.getPagination().assertThat().field("totalItems").is("0").and().field("count").is("0"); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS }, - executionType = ExecutionType.REGRESSION, description = "Verify Contributor user deletes comment created by self" - + " and status code is 204. Check with getComments for validation") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - @Bug(id = "ACE-4614") - public void contributorIsAbleToDeleteCommentCreatedBySelf() throws Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - - commentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) - .withCoreAPI().usingResource(file).addComment(commentText); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.withCoreAPI().usingResource(file).deleteComment(commentModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListDoesNotContain("content", commentText); - comments.getPagination().assertThat().field("totalItems").is("0").and().field("count").is("0"); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS }, - executionType = ExecutionType.REGRESSION, description = "Verify Consumer user cannot delete comment created by admin" - + " and status code is 403. Check with getComments for validation and check default error model schema.") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void consumerIsNotAbleToDeleteCommentCreatedByOthersDefaultErrorModelSchema() throws Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - - commentModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(commentText); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .withCoreAPI().usingResource(file).deleteComment(commentModel); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .statusCodeIs(HttpStatus.FORBIDDEN) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE) - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY); - - comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", commentText); - comments.getPagination().assertThat().field("totalItems").is("1").and().field("count").is("1"); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS }, - executionType = ExecutionType.REGRESSION, description = "Verify Manager can delete comment with version number") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void usingManagerDeleteCommentWithVersionNumber() throws Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - dataContent.usingAdmin().usingResource(file).updateContent("updated content to increase version number"); - - commentModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(commentText); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(file).deleteComment(commentModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS }, - executionType = ExecutionType.REGRESSION, description = "Verify Manager user cannot delete comment with invalid node " - + "and status code is 404. Check with getComments for validation") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void usingManagerDeleteCommentWithInvalidNode() throws Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - - commentModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(commentText); - file.setNodeRef("invalid"); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(file).deleteComment(commentModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(file.getNodeRef() + " was not found"); - - comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(file.getNodeRef() + " was not found"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS}, executionType = ExecutionType.REGRESSION, - description = "Verify deleteComment from node with invalid network id returns status code 401") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void deleteCommentWithInvalidNetworkId() throws Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - - commentModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(commentText); - networkUserModel.setDomain("invalidNetwork"); - restClient.authenticateUser(networkUserModel).withCoreAPI().usingResource(file).deleteComment(commentModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS }, - executionType = ExecutionType.REGRESSION, description = "Verify deleteComment from node with empty network id returns status code 401") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void deleteCommentWithEmptyNetworkId() throws Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - - commentModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(commentText); - networkUserModel.setDomain(""); - restClient.authenticateUser(networkUserModel).withCoreAPI().usingResource(file).deleteComment(commentModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/comments/GetCommentsTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/comments/GetCommentsTests.java deleted file mode 100644 index 23670eb81..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/comments/GetCommentsTests.java +++ /dev/null @@ -1,422 +0,0 @@ -package org.alfresco.service.search.rest.comments; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestCommentModelsCollection; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FileType; -import org.alfresco.utility.model.LinkModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class GetCommentsTests extends RestTest -{ - private FileModel file, document, document1; - private SiteModel siteModel, privateSiteModel; - private UserModel adminUserModel, userModel, networkUserModel; - private ListUserWithRoles usersWithRoles; - private String comment = "This is a new comment"; - private String comment2 = "This is a 2nd comment"; - private String comment3 = "This is a 3rd comment"; - private RestCommentModelsCollection comments; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - networkUserModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - privateSiteModel = dataSite.usingUser(adminUserModel).createPrivateRandomSite(); - document = dataContent.usingSite(privateSiteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - document1 = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(adminUserModel).withCoreAPI() - .usingResource(document1).addComment(comment); - restClient.withCoreAPI().usingResource(document).addComment(comment); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.withCoreAPI().usingResource(document).addComment(comment2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.withCoreAPI().usingResource(document).addComment(comment3); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.SANITY, - description= "Verify Admin user gets comments with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) - public void adminIsAbleToRetrieveComments() throws Exception - { - comments = restClient.authenticateUser(adminUserModel).withCoreAPI() - .usingResource(document1).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", comment); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.SANITY, - description= "Verify Manager user gets status code 401 if authentication call fails") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) -// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void managerIsNotAbleToRetrieveCommentIfAuthenticationFails() throws Exception - { - UserModel nonexistentModel = new UserModel("nonexistentUser", "nonexistentPassword"); - restClient.authenticateUser(nonexistentModel).withCoreAPI() - .usingResource(document1).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify Manager user gets comments created by admin user with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void managerIsAbleToRetrieveComments() throws Exception - { - comments = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI() - .usingResource(document1).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", comment); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify Contributor user gets comments created by admin user with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void contributorIsAbleToRetrieveComments() throws Exception - { - comments = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI() - .usingResource(document1).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", comment); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify Collaborator user gets comments created by admin user with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void collaboratorIsAbleToRetrieveComments() throws Exception - { - comments = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI() - .usingResource(document1).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", comment); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify Consumer user gets comments created by admin user with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void consumerIsAbleToRetrieveComments() throws Exception - { - comments = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI() - .usingResource(document1).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", comment); - } - - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify Manager user gets comments created by another user and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void managerIsAbleToRetrieveCommentsCreatedByAnotherUser() throws Exception - { - userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); - String contentManager = "This is a new comment added by " + userModel.getUsername(); - restClient.authenticateUser(userModel).withCoreAPI() - .usingResource(document1).addComment(contentManager); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - comments = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI() - .usingResource(document1).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", contentManager) - .and().entriesListContains("content", comment); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify admin user gets comments created by another user and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void adminIsAbleToRetrieveCommentsCreatedByAnotherUser() throws Exception - { - userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); - String contentCollaborator = "This is a new comment added by " + userModel.getUsername(); - restClient.authenticateUser(userModel).withCoreAPI() - .usingResource(document1).addComment(contentCollaborator); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - comments = restClient.authenticateUser(adminUserModel).withCoreAPI() - .usingResource(document1).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", contentCollaborator) - .and().entriesListContains("content", comment); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify request returns status 403 if the user does not have permission read comments on the node") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void uninvitedUserCanNotGetCommentsFromPrivateSite() throws Exception - { - restClient.authenticateUser(userModel).withCoreAPI() - .usingResource(document).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify user gets comments without the first 2 and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void skipFirst2Comments() throws Exception - { - comments = restClient.authenticateUser(adminUserModel).withParams("skipCount=2") - .withCoreAPI().usingResource(document).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", comment) - .and().paginationField("count").is("1"); - comments.assertThat().paginationField("skipCount").is("2"); - comments.assertThat().paginationField("totalItems").is("3"); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify invalid request returns status code 400 for invalid maxItems or skipCount") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void checkStatusCodeForInvalidMaxItems() throws Exception - { - restClient.authenticateUser(adminUserModel).withParams("maxItems=0") - .withCoreAPI().usingResource(document).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary("Only positive values supported for maxItems"); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify User can't get comments for node with ID that does not exist and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void userCanNotGetCommentsOnNonExistentFile() throws Exception - { - FileModel nonexistentFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); - nonexistentFile.setNodeRef("ABC"); - restClient.authenticateUser(adminUserModel).withCoreAPI() - .usingResource(nonexistentFile).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, nonexistentFile.getNodeRef())); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify User can't get comments for node that exists but is not a document or a folder and status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void userCanNotGetCommentsOnLink() throws Exception - { - LinkModel link = dataLink.usingAdmin().usingSite(siteModel).createRandomLink(); - FileModel fileWithNodeRefFromLink = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); - fileWithNodeRefFromLink.setNodeRef(link.getNodeRef().replace("workspace://SpacesStore/", "workspace%3A%2F%2FSpacesStore%2F")); - restClient.authenticateUser(adminUserModel).withCoreAPI() - .usingResource(fileWithNodeRefFromLink).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, fileWithNodeRefFromLink.getNodeRef())) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify get comments from node with invalid network id returns status code 401") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void getCommentsWithInvalidNetwork() throws Exception - { - networkUserModel.setDomain("invalidNetwork"); - restClient.authenticateUser(networkUserModel).withCoreAPI().usingResource(document).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify get comments from node with empty network id returns status code 401") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void getCommentsWithEmptyNetwork() throws Exception - { - networkUserModel.setDomain(""); - restClient.authenticateUser(networkUserModel).withCoreAPI().usingResource(document).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify that if manager adds one comment, it will be returned in getComments response") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void addCommentWithManagerAndCheckThatCommentIsReturned() throws Exception - { - file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(file).addComment(comment); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", comment) - .getPagination().assertThat().field("totalItems").is("1") - .assertThat().field("count").is("1"); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify that if collaborator adds one comment, it will be returned in getComments response") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void addCommentWithCollaboratorAndCheckThatCommentIsReturned() throws Exception - { - file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingResource(file).addComment(comment); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", comment) - .getPagination().assertThat().field("totalItems").is("1") - .assertThat().field("count").is("1"); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify that if contributor adds one comment, it will be returned in getComments response") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - @Bug(id = "ACE-4614") - public void addCommentWithContributorAndCheckThatCommentIsReturned() throws Exception - { - file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) - .withCoreAPI().usingResource(file).addComment(comment); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", comment) - .getPagination().assertThat().field("totalItems").is("1") - .assertThat().field("count").is("1"); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify that consumer cannot add a comment and no comments will be returned in getComments response") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void addCommentWithConsumerAndCheckThatCommentIsNotReturned() throws Exception - { - file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .withCoreAPI().usingResource(file).addComment(comment); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - - comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().paginationField("totalItems").is("0"); - comments.assertThat().paginationField("count").is("0"); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Add one comment with Manager and check that returned person is the right one") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void addCommentWithManagerCheckReturnedPersonIsTheRightOne() throws Exception - { - file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - UserModel user1 = dataUser.createRandomTestUser(); - dataUser.addUserToSite(user1, siteModel, UserRole.SiteManager); - - restClient.authenticateUser(user1).withCoreAPI().usingResource(file).addComment(comment); - comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); - comments.getOneRandomEntry().onModel().getCreatedBy().assertThat().field("firstName").is(user1.getUsername() + " FirstName") - .assertThat().field("lastName").is("LN-" + user1.getUsername()); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Add one comment with Collaborator and check that returned company details are correct") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void addCommentWithCollaboratorCheckReturnedCompanyDetails() throws Exception - { - file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(file).addComment(comment); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); - comments.getOneRandomEntry().onModel().getCreatedBy().getCompany() - .assertThat().field("organization").isNull() - .assertThat().field("address1").isNull() - .assertThat().field("address2").isNull() - .assertThat().field("address3").isNull() - .assertThat().field("postcode").isNull() - .assertThat().field("telephone").isNull() - .assertThat().field("fax").isNull() - .assertThat().field("email").isNull(); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Add 2 comments with Manager and Collaborator users and verify valid request using skipCount. Check that param is applied") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void addTwoCommentsWithManagerCollaboratorVerifySkipCountParamIsApplied() throws Exception - { - file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(file).addComment(comment); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(file).addComment(comment2); - - comments = restClient.authenticateUser(adminUserModel).withParams("skipCount=1") - .withCoreAPI().usingResource(file).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", comment) - .and().paginationField("count").is("1"); - comments.assertThat().paginationField("skipCount").is("1"); - comments.assertThat().paginationField("totalItems").is("2"); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Add 2 comments with Admin and Collaborator users and verify valid request using maxItems. Check that param is applied") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void addTwoCommentsWithAdminCollaboratorVerifyMaxItemsParamIsApplied() throws Exception - { - file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(comment); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(file).addComment(comment2); - - comments = restClient.authenticateUser(adminUserModel).withParams("maxItems=1") - .withCoreAPI().usingResource(file).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", comment2) - .and().paginationField("count").is("1"); - comments.assertThat().paginationField("totalItems").is("2"); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Add 2 comments with Manager and Admin users and verify valid request using properties. Check that param is applied") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void addTwoCommentsWithAdminManagerVerifyPropertiesParamIsApplied() throws Exception - { - file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(comment); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(file).addComment(comment2); - - comments = restClient.authenticateUser(adminUserModel).withParams("properties=createdBy,modifiedBy") - .withCoreAPI().usingResource(file).getNodeComments(); - comments.assertThat().entriesListIsNotEmpty() - .and().paginationField("count").is("2"); - comments.assertThat().paginationField("totalItems").is("2"); - - comments.getEntries().get(0).onModel().getCreatedBy() - .assertThat().field("firstName").is(usersWithRoles.getOneUserWithRole(UserRole.SiteManager).getUsername() + " FirstName") - .assertThat().field("lastName").is("LN-" + usersWithRoles.getOneUserWithRole(UserRole.SiteManager).getUsername()); - - comments.getEntries().get(1).onModel().getCreatedBy() - .assertThat().field("firstName").is("Administrator") - .assertThat().field("id").is("admin"); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Check default error model schema") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void addTwoCommentsWithManagerCheckDefaultErrorModelSchema() throws Exception - { - file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(file).addComments(comment, comment2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).usingParams("maxItems=0").getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); - restClient.assertLastError().containsErrorKey(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); - restClient.assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); - restClient.assertLastError().descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - restClient.assertLastError().stackTraceIs(RestErrorModel.STACKTRACE); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/comments/UpdateCommentTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/comments/UpdateCommentTests.java deleted file mode 100644 index 5ee3a596f..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/comments/UpdateCommentTests.java +++ /dev/null @@ -1,461 +0,0 @@ -package org.alfresco.service.search.rest.comments; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestCommentModel; -import org.alfresco.rest.model.RestCommentModelsCollection; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FileType; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.LinkModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.apache.commons.lang3.RandomStringUtils; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class UpdateCommentTests extends RestTest -{ - private UserModel adminUserModel, networkUserModel; - private FileModel document; - private SiteModel siteModel; - private RestCommentModel commentModel, returnedCommentModel; - private RestCommentModelsCollection comments;; - private ListUserWithRoles usersWithRoles; - private String firstComment = "This is a new comment"; - private String updatedComment = "This is the updated comment"; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - restClient.authenticateUser(adminUserModel); - networkUserModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - - document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Admin user updates comments and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) - public void adminIsAbleToUpdateHisComment() throws Exception - { - restClient.authenticateUser(adminUserModel); - commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by admin"); - String updatedContent = "This is the updated comment with admin user"; - restClient.withCoreAPI().usingResource(document).updateComment(commentModel, updatedContent) - .assertThat().field("content").isNotEmpty() - .and().field("content").is(updatedContent); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user gets status code 401 on update comment call") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) -// @Bug(id = "MNT-16904", description = "fails only on environment with tenants") - public void unauthenticatedUserIsNotAbleToUpdateComment() throws Exception - { - restClient.authenticateUser(adminUserModel); - commentModel = restClient.withCoreAPI().usingResource(document).addComment("To be updated by unauthenticated user."); - UserModel incorrectUserModel = new UserModel("userName", "password"); - restClient.authenticateUser(incorrectUserModel) - .withCoreAPI().usingResource(document).updateComment(commentModel, "try to update"); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify entry content in response") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY }) - public void checkEntryContentInResponse() throws Exception - { - restClient.authenticateUser(adminUserModel); - commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by admin"); - commentModel = restClient.withCoreAPI().usingResource(document).updateComment(commentModel, "This is the updated comment with admin user"); - restClient.assertStatusCodeIs(HttpStatus.OK); - commentModel.assertThat().field("content").is("This is the updated comment with admin user"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Manager user updates comments created by admin user and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void managerIsAbleToUpdateHisComment() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by manager"); - restClient.withCoreAPI().usingResource(document).updateComment(commentModel, "This is the updated comment with Manager user") - .and().field("content").is("This is the updated comment with Manager user") - .and().field("canEdit").is(true) - .and().field("canDelete").is(true); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Contributor user can update his own comment and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void contributorIsAbleToUpdateHisComment() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by contributor"); - String updatedContent = "This is the updated comment with Contributor user"; - restClient.withCoreAPI().usingResource(document).updateComment(commentModel, updatedContent); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Consumer user can not update comments created by admin user and status code is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void consumerIsNotAbleToUpdateComment() throws Exception - { - restClient.authenticateUser(adminUserModel); - commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by admin"); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.withCoreAPI().usingResource(document).updateComment(commentModel, "This is the updated comment with Consumer user"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user can update his own comment and status code is 200") -// @Bug(id="REPO-1011") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void collaboratorIsAbleToUpdateHisComment() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by collaborator"); - restClient.withCoreAPI().usingResource(document).updateComment(commentModel, "This is the updated comment with Collaborator user"); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user can not update comments of another user and status code is 200") -// @Bug(id="MNT-2502",description="seems it's one old issue: also logged as MNT-2502, MNT-2346") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void collaboratorIsNotAbleToUpdateCommentOfAnotherUser() throws Exception - { - restClient.authenticateUser(adminUserModel); - commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by admin"); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingResource(document).updateComment(commentModel, "This is the updated comment with Collaborator user"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify update comment with inexistent nodeId returns status code 404") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void canNotUpdateCommentIfNodeIdIsNotSet() throws Exception - { - restClient.authenticateUser(adminUserModel); - - FolderModel content = FolderModel.getRandomFolderModel(); - content.setNodeRef("node ref that does not exist"); - commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment"); - restClient.withCoreAPI().usingResource(content).updateComment(commentModel, "This is the updated comment."); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary("node ref that does not exist was not found"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify if commentId is not set the status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void canNotUpdateCommentIfCommentIdIsNotSet() throws Exception - { - restClient.authenticateUser(adminUserModel); - - RestCommentModel comment = new RestCommentModel(); - String id = "comment id that does not exist"; - comment.setId(id); - restClient.withCoreAPI().usingResource(document).updateComment(comment, "This is the updated comment."); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, id)); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify can not update comment if NodeId is neither document or folder and returns status code 405") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void canNotUpdateCommentIfNodeIdIsNeitherDocumentOrFolder() throws Exception - { - FileModel content = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); - content = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(adminUserModel); - commentModel = restClient.withCoreAPI().usingResource(content).addComment("This is a new comment"); - - LinkModel link = dataLink.usingAdmin().usingSite(siteModel).createRandomLink(); - content.setNodeRef(link.getNodeRef().replace("workspace://SpacesStore/", "workspace%3A%2F%2FSpacesStore%2F")); - - restClient.withCoreAPI().usingResource(content).updateComment(commentModel, "This is the updated comment."); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, content.getNodeRef())) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Admin user is not able to update with empty comment body and status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void adminIsNotAbleToUpdateWithEmptyCommentBody() throws Exception - { - restClient.authenticateUser(adminUserModel); - commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by admin"); - restClient.withCoreAPI().usingResource(document).updateComment(commentModel, ""); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary("An invalid argument was received"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify updated comment by Manager is listed when calling getComments and status code is 200") -// @Bug(id="REPO-1011") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void updatedCommentByManagerIsListed() throws Exception - { - commentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingResource(document).addComment("This is a new comment added by collaborator"); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI() - .usingResource(document).updateComment(commentModel, "This is the updated comment with Manager user"); - comments = restClient.withCoreAPI().usingResource(document).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", "This is the updated comment with Manager user"); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify Manager user can update a comment with a large string") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void managerIsAbleToUpdateACommentWithALargeString() throws Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - String longString = RandomStringUtils.randomAlphanumeric(10000); - - commentModel = restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingResource(file).addComment(firstComment); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedCommentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(file).updateComment(commentModel, longString); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCommentModel.assertThat().field("content").is(longString); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify Manager user can update a comment with a short string") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void managerIsAbleToUpdateACommentWithAShortString() throws Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - String shortString = RandomStringUtils.randomAlphanumeric(2); - - commentModel = restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingResource(file).addComment(firstComment); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedCommentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(file).updateComment(commentModel, shortString); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCommentModel.assertThat().field("content").is(shortString); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify Collaborator user can update a comment with special characters") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void collaboratorIsAbleToUpdateACommentThatContainsSpecialChars() throws Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - String specialChars = "!@#$%^&*()'\".,<>-_+=|\\"; - - commentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingResource(file).addComment(firstComment); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedCommentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingResource(file).updateComment(commentModel, specialChars); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCommentModel.assertThat().field("content").is(specialChars); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Check that you cannot update comment with Consumer then call getComments and check new comment is not listed") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void cannotUpdateCommentWithConsumerCallGetComments() throws Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - - commentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingResource(file).addComment(firstComment); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingResource(file).updateComment(commentModel, updatedComment); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - - comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", firstComment) - .and().entriesListDoesNotContain("content", updatedComment) - .and().paginationField("totalItems").is("1"); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Update comment with Contributor then call getComments and check new comment is listed") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - @Bug(id = "ACE-4614") - public void updateCommentWithContributorCallGetComments() throws Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - - commentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) - .withCoreAPI().usingResource(file).addComment(firstComment); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingResource(file).updateComment(commentModel, updatedComment); - restClient.assertStatusCodeIs(HttpStatus.OK); - - comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", updatedComment) - .and().entriesListDoesNotContain("content", firstComment) - .and().paginationField("totalItems").is("1"); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Update comment with Collaborator then call getComments and check new comment is listed") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void updateCommentWithCollaboratorCallGetComments() throws Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - - commentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingResource(file).addComment(firstComment); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(file).updateComment(commentModel, updatedComment); - restClient.assertStatusCodeIs(HttpStatus.OK); - - comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - comments.assertThat().entriesListContains("content", updatedComment) - .and().entriesListDoesNotContain("content", firstComment) - .and().paginationField("totalItems").is("1"); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Update comment with Manager then check modified by information in response") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void updateCommentWithManagerCheckModifiedBy() throws Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - UserModel manager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); - - commentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingResource(file).addComment(firstComment); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedCommentModel = restClient.authenticateUser(manager).withCoreAPI().usingResource(file).updateComment(commentModel, updatedComment); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCommentModel.assertThat().field("modifiedBy.id").is(manager.getUsername()) - .and().field("content").is(updatedComment); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Delete comment with Admin then try to update it") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void deleteCommentThenTryToUpdateIt() throws Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - - commentModel = restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingResource(file).addComment(firstComment); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.withCoreAPI().usingResource(file).deleteComment(commentModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingResource(file).updateComment(commentModel, updatedComment); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify Manager user can update a comment with multi byte content") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void managerIsAbleToUpdateACommentWithMultiByteContent() throws Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - String multiByte = "\ufeff\u6768\u6728\u91d1"; - - commentModel = restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingResource(file).addComment(firstComment); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedCommentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(file).updateComment(commentModel, multiByte); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCommentModel.assertThat().field("content").is(multiByte); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify Admin user can update a comment with properties parameter") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void adminIsAbleToUpdateACommentWithPropertiesParameter() throws Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - - commentModel = restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingResource(file).addComment(firstComment); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - UserModel manager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); - - returnedCommentModel = restClient.authenticateUser(manager) - .withParams("properties=createdBy,modifiedBy,canEdit,canDelete").withCoreAPI().usingResource(file).updateComment(commentModel, updatedComment); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCommentModel.assertThat().field("createdBy.id").is(adminUserModel.getUsername()) - .assertThat().field("modifiedBy.id").is(manager.getUsername()) - .assertThat().fieldsCount().is(4); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, - description = "Update comment with invalid node") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void updateCommentUsingInvalidNodeId() throws Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - - commentModel = restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingResource(file).addComment(firstComment); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - file.setNodeRef(RandomStringUtils.randomAlphanumeric(20)); - restClient.withCoreAPI().usingResource(file).updateComment(commentModel, updatedComment); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, file.getNodeRef())); - } - - @TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, - description= "Verify update comment from node with invalid network id returns status code 401") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void updateCommentWithInvalidNetworkId() throws Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); - - commentModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(firstComment); - networkUserModel.setDomain("invalidNetwork"); - restClient.authenticateUser(networkUserModel).withCoreAPI().usingResource(file).updateComment(commentModel, updatedComment); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify User can not update comment to a not joined private site. Status code returned is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) - public void userCanNotUpdateCommentToANotJoinedPrivateSiteDefaultErrorModelSchema() throws Exception - { - UserModel newUser = dataUser.createRandomTestUser(); - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - - commentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(file).addComment(firstComment); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(newUser).withCoreAPI().usingResource(file).updateComment(commentModel, updatedComment); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE) - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/RestDemoTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/RestDemoTests.java deleted file mode 100644 index 0792a9bc4..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/RestDemoTests.java +++ /dev/null @@ -1,104 +0,0 @@ -package org.alfresco.service.search.rest.demo; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.dataprep.SiteService.Visibility; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.exception.DataPreparationException; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.UserModel; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class RestDemoTests extends RestTest -{ - private UserModel userModel; - private SiteModel siteModel; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws DataPreparationException - { - userModel = dataUser.getAdminUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - restClient.authenticateUser(userModel); - } - - /** - * Data preparation – create site with custom details
          - * Perform GET sites call using admin user
          - * Check that created site is included in response
          - * Perform GET site call, validate that site title, description and visibility are correct
          - * - * @throws JsonToModelConversionException - * @throws Exception - */ - @Test(groups = { "demo" }) - public void adminRetrievesCorrectSiteDetails() throws JsonToModelConversionException, Exception - { - restClient.withCoreAPI().getSites().assertThat() - .entriesListContains("id", siteModel.getId()); - - restClient.withCoreAPI().usingSite(siteModel).getSite() - .assertThat().field("id").isNotNull() - .assertThat().field("description").is(siteModel.getDescription()) - .assertThat().field("title").is(siteModel.getTitle()) - .assertThat().field("visibility").is(Visibility.PUBLIC); - } - - /** - * Data preparation – create site and document on server
          - * POST one comment to file using admin user
          - * Perform GET comments, check the new one is listed
          - * Update existing comment using PUT call, check that comment content is updated
          - * @throws Exception - */ - @Test(groups = { "demo" }) - public void adminCanPostAndUpdateComments() throws Exception - { - FileModel fileModel = dataContent.usingUser(userModel) - .usingResource(FolderModel.getSharedFolderModel()) - .createContent(DocumentType.TEXT_PLAIN); - // add new comment - restClient.withCoreAPI().usingResource(fileModel).addComment("This is a new comment"); - restClient.withCoreAPI().usingResource(fileModel).getNodeComments() - .assertThat().entriesListIsNotEmpty().and() - .entriesListContains("content", "This is a new comment"); - } - - /** - * Data preparation – create site and a new user
          - * As admin, add user as Consumer to site as a new site member using POST call
          - * Update site member role to Manager using PUT call
          - * Delete site member using DELETE call
          - * - * @throws DataPreparationException - * @throws JsonToModelConversionException - */ - @Test(groups = { "demo" }) - public void adminCanAddAndUpdateSiteMemberDetails() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteConsumer); - - // add user as Consumer to site - restClient.withCoreAPI().usingSite(siteModel).addPerson(testUser); - restClient.withCoreAPI().usingSite(siteModel).getSiteMembers().assertThat().entriesListContains("id", testUser.getUsername()) - .when().getSiteMember(testUser.getUsername()) - .assertSiteMemberHasRole(UserRole.SiteConsumer); - - // update site member to Manager - testUser.setUserRole(UserRole.SiteCollaborator); - restClient.withCoreAPI().usingSite(siteModel).updateSiteMember(testUser); - restClient.withCoreAPI().usingSite(siteModel).getSiteMembers().and() - .entriesListContains("id", testUser.getUsername()) - .when().getSiteMember(testUser.getUsername()) - .assertSiteMemberHasRole(UserRole.SiteCollaborator); - - restClient.withCoreAPI().usingSite(siteModel).deleteSiteMember(testUser); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } -} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/SampleCommentsTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/SampleCommentsTests.java deleted file mode 100644 index d7cd27d76..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/SampleCommentsTests.java +++ /dev/null @@ -1,56 +0,0 @@ -package org.alfresco.service.search.rest.demo; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestCommentModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.UserModel; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - - -public class SampleCommentsTests extends RestTest -{ - private UserModel userModel; - private FolderModel folderModel; - private SiteModel siteModel; - private FileModel document; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - userModel = dataUser.getAdminUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - restClient.authenticateUser(userModel); - document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - } - - @Test(groups = { "demo" }) - public void admiShouldAddComment() throws JsonToModelConversionException, Exception - { - restClient.withCoreAPI().usingResource(document).addComment("This is a new comment"); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - } - - @Test(groups = { "demo" }) - public void admiShouldRetrieveComments() throws Exception - { - restClient.withCoreAPI().usingResource(document).getNodeComments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { "demo" }) - public void adminShouldUpdateComment() throws JsonToModelConversionException, Exception - { - RestCommentModel commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment"); - - restClient.withCoreAPI().usingResource(document).updateComment(commentModel, "This is the updated comment with Collaborator user") - .assertThat().field("content").is("This is the updated comment with Collaborator user"); - } - -} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/SamplePeopleTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/SamplePeopleTests.java deleted file mode 100644 index 38ae35e47..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/SamplePeopleTests.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.alfresco.service.search.rest.demo; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.utility.exception.DataPreparationException; -import org.alfresco.utility.model.UserModel; -import org.apache.commons.lang3.RandomStringUtils; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - - -public class SamplePeopleTests extends RestTest -{ - private UserModel userModel; - private UserModel adminUser; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws DataPreparationException - { - userModel = dataUser.createUser(RandomStringUtils.randomAlphanumeric(20)); - adminUser = dataUser.getAdminUser(); - restClient.authenticateUser(adminUser); - } - - @Test(groups = { "demo" }) - public void adminShouldRetrievePerson() throws Exception - { - restClient.withCoreAPI().usingUser(userModel).getPerson().assertThat().field("id").isNotEmpty(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - -} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/SampleSitesTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/SampleSitesTests.java deleted file mode 100644 index 1c66115ab..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/SampleSitesTests.java +++ /dev/null @@ -1,79 +0,0 @@ -package org.alfresco.service.search.rest.demo; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.exception.DataPreparationException; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.UserModel; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - - -public class SampleSitesTests extends RestTest -{ - private UserModel userModel; - private SiteModel siteModel; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws DataPreparationException - { - userModel = dataUser.getAdminUser(); - restClient.authenticateUser(userModel); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - } - - @Test(groups = { "demo" }) - public void adminShouldGetSiteDetails() throws JsonToModelConversionException, Exception - { - restClient.withCoreAPI().usingSite(siteModel).getSite() - .assertThat().field("id").isNotNull(); - } - - @Test(groups = { "demo" }) - public void adminShouldGetSites() throws JsonToModelConversionException, Exception - { - restClient.withCoreAPI().usingSite(siteModel).getSite(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { "demo" }) - public void adminShouldAccessSites() throws JsonToModelConversionException, Exception - { - restClient.withCoreAPI().getSites().assertThat().entriesListIsNotEmpty(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { "demo" }) - public void adminShouldAccessResponsePagination() throws JsonToModelConversionException, Exception - { - restClient.withCoreAPI().getSites().assertThat().paginationExist(); - } - - @Test(groups = { "demo" }) - public void adminShouldAddNewSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteConsumer); - restClient.withCoreAPI().usingSite(siteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - } - - @Test(groups = { "demo" }) - public void adminShouldGetSiteFromSitesList() throws JsonToModelConversionException, Exception - { - restClient.withCoreAPI().getSites().assertThat().entriesListContains("id", siteModel.getId()); - } - - @Test(groups = { "demo" }) - public void adminShouldAccessSiteDetails() throws JsonToModelConversionException, Exception - { - restClient.withCoreAPI().usingSite(siteModel).getSite() - .assertThat().field("id").isNotNull() - .and().field("description").is(siteModel.getDescription()) - .and().field("title").is(siteModel.getTitle()) - .and().field("visibility").is(siteModel.getVisibility()); - } - -} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/workshop/RestApiDemoTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/workshop/RestApiDemoTests.java deleted file mode 100644 index fa450616e..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/workshop/RestApiDemoTests.java +++ /dev/null @@ -1,52 +0,0 @@ -package org.alfresco.service.search.rest.demo.workshop; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.UserModel; -import org.testng.annotations.Test; - -public class RestApiDemoTests extends RestTest -{ - /* - * Test steps: - * 1. create a user - * 2. create a site - * 3. create a second user - * 4. add the second user to site with a user role - * 5. call rest api call " GET sites/{siteId}/members" with first user authenticated - * Expected: the response contains the user added as a member to the site - */ - @Test(groups = { "demo" }) - public void verifyGetSiteMembersRestApiCall() throws Exception - { - UserModel user = dataUser.createRandomTestUser(); - SiteModel site = dataSite.usingUser(user).createPublicRandomSite(); - UserModel member = dataUser.createRandomTestUser(); - dataUser.usingUser(user).addUserToSite(member, site, UserRole.SiteCollaborator); - - //add here code for step 5 - - } - - /* - * Test steps: - * 1. create a user - * 2. create a site - * 3. create a second user - * 4. add the second user to site with a user role - * 5. call rest api call " GET sites/{siteId}/members/{personId}" with first user authenticated - * Expected: the response contains the user added as a member to the site - */ - - @Test(groups = { "demo" }) - public void verifyGetASiteMemberApiCall() throws Exception - { - UserModel user = dataUser.createRandomTestUser(); - SiteModel site = dataSite.usingUser(user).createPublicRandomSite(); - UserModel member = dataUser.createRandomTestUser(); - dataUser.usingUser(user).addUserToSite(member, site, UserRole.SiteCollaborator); - - //add here code for step 5 - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/workshop/RestApiWorkshopTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/workshop/RestApiWorkshopTests.java deleted file mode 100644 index 49f7fce0d..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/demo/workshop/RestApiWorkshopTests.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.alfresco.service.search.rest.demo.workshop; - -import org.alfresco.service.search.rest.RestTest; -import org.testng.annotations.Test; - -/** - * - * Demo workshop for RestAPI test - * - */ -public class RestApiWorkshopTests extends RestTest -{ - @Test(groups = { "demo" }) - public void verifyGetSitesRestApiCall() throws Exception - { - // creating a random user in repository - - // create a new random site using your UserModel from above - - // using "siteApi", call get "/sites" Rest API and verify created site is present - - // verify status is OK - - } - - @Test(groups = { "demo" }) - public void verifyGetASiteRestApiCall() throws Exception - { - // creating a random user in repository - - // create a new random site using your UserModel from above - - // using "siteApi", call get "/sites/{siteId}" Rest API - // using "siteApi", verify created site is present - - // verify status is OK - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/discovery/DiscoveryTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/discovery/DiscoveryTests.java deleted file mode 100644 index 50763752c..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/discovery/DiscoveryTests.java +++ /dev/null @@ -1,108 +0,0 @@ -package org.alfresco.service.search.rest.discovery; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.core.RestResponse; -import org.alfresco.rest.model.RestDiscoveryModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class DiscoveryTests extends RestTest -{ - private UserModel adminModel, userModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminModel = dataUser.getAdminUser(); - userModel = dataUser.createRandomTestUser(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.DISCOVERY, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.DISCOVERY }, executionType = ExecutionType.SANITY, - description = "Sanity tests for GET /discovery endpoint") - public void getRepositoryInformation() throws Exception - { - // Get repository info from admin console - RestResponse adminConsoleRepoInfo = restClient.authenticateUser(adminModel).withAdminConsole().getAdminConsoleRepoInfo(); - String id = adminConsoleRepoInfo.getResponse().getBody().path("data.id"); - String edition = adminConsoleRepoInfo.getResponse().getBody().path("data.edition"); - String schema = adminConsoleRepoInfo.getResponse().getBody().path("data.schema"); - String version = adminConsoleRepoInfo.getResponse().getBody().path("data.version"); - - // Get repository info using Discovery API - RestDiscoveryModel response = restClient.authenticateUser(userModel).withDiscoveryAPI().getRepositoryInfo(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - // Compare information - response.getRepository().getVersion().assertThat().field("major").is(version.charAt(0)); - response.getRepository().getVersion().assertThat().field("minor").is(version.charAt(2)); - response.getRepository().getVersion().assertThat().field("patch").is(version.charAt(4)); - response.getRepository().getVersion().assertThat().field("schema").is(schema); - response.getRepository().getId().equals(id); - response.getRepository().getEdition().equals(edition); - response.getRepository().getStatus().assertThat().field("isReadOnly").is(false); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.DISCOVERY, TestGroup.ALL_AMPS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.DISCOVERY }, executionType = ExecutionType.SANITY, - description = "Sanity tests for GET /discovery endpoint") - public void getRepositoryInstalledModules() throws Exception - { - // Get repository info using Discovery API - restClient.authenticateUser(userModel).withDiscoveryAPI().getRepositoryInfo(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - // Check that all modules are present - List modules = restClient.onResponse().getResponse().jsonPath().getList("entry.repository.modules.id", String.class); - List expectedModules = Arrays.asList("alfresco-aos-module", "org.alfresco.integrations.google.docs", - "org_alfresco_integrations_S3Connector", "org_alfresco_module_xamconnector", - "org.alfresco.module.KofaxAddon", "alfresco-content-connector-for-salesforce-repo", - "alfresco-share-services", - // uncomment when REPO-4233 is fixed - // "alfresco-saml-repo", - "org_alfresco_device_sync_repo", - // uncomment when MM-785 is fixed: - // "org_alfresco_mm_repo", - "org.alfresco.module.TransformationServer", "alfresco-glacier-connector-repo"); - - expectedModules.forEach(module -> - assertTrue(modules.contains(module), String.format("Expected module %s is not installed", module))); - - // Check that all installed modules are in INSTALLED state - List modulesStates = restClient.onResponse().getResponse().jsonPath().getList("entry.repository.modules.installState", String.class); - //change back to assertEquals after REPO-4233 and MM-785 is fixed - assertTrue(Collections.frequency(modulesStates, "INSTALLED") >= expectedModules.size(), "Number of amps installed should match expected"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.DISCOVERY, TestGroup.SANITY, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.DISCOVERY }, executionType = ExecutionType.SANITY, - description = "Sanity tests for GET /discovery endpoint") - public void getDefaultRepositoryInstalledModules() throws Exception - { - // Get repository info using Discovery API - restClient.authenticateUser(userModel).withDiscoveryAPI().getRepositoryInfo(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - // Check that all modules are present - List modules = restClient.onResponse().getResponse().jsonPath().getList("entry.repository.modules.id", String.class); - assertTrue(modules.contains("alfresco-aos-module")); - assertTrue(modules.contains("org.alfresco.integrations.google.docs")); - assertTrue(modules.contains("alfresco-share-services")); - - // Check that all installed modules are in INSTALLED state - List modulesStates = restClient.onResponse().getResponse().jsonPath().getList("entry.repository.modules.installState", String.class); - assertEquals(Collections.frequency(modulesStates, "INSTALLED"), 3); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/downloads/DownloadsTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/downloads/DownloadsTests.java deleted file mode 100644 index f903b1376..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/downloads/DownloadsTests.java +++ /dev/null @@ -1,106 +0,0 @@ -package org.alfresco.service.search.rest.downloads; - -import javax.json.JsonObject; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.core.JsonBodyGenerator; -import org.alfresco.rest.model.RestDownloadsModel; -import org.alfresco.utility.Utility; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.Assert; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class DownloadsTests extends RestTest -{ - private UserModel adminModel; - private FileModel document, document1; - private FolderModel folder; - private SiteModel siteModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminModel = dataUser.getAdminUser(); - siteModel = dataSite.usingUser(adminModel).createPrivateRandomSite(); - folder = dataContent.usingUser(adminModel).usingSite(siteModel).createFolder(); - document = dataContent.usingSite(siteModel).usingUser(adminModel).createContent(DocumentType.TEXT_PLAIN); - - // Create document1 based on existing resource - FileModel newFile = FileModel.getFileModelBasedOnTestDataFile("larger.pdf"); - newFile.setName("larger.pdf"); - document1 = dataContent.usingUser(adminModel).usingResource(folder).createContent(newFile); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.DOWNLOADS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.DOWNLOADS }, executionType = ExecutionType.SANITY, - description = "Sanity tests for GET /downloads/{downloadId} and POST /downloads") - public void createDownloadNodeAndGetInfo() throws Exception - { - // POST /downloads - JsonObject postBody = JsonBodyGenerator.defineJSON() - .add("nodeIds", JsonBodyGenerator.defineJSONArray().add(document.getNodeRefWithoutVersion())) - .build(); - RestDownloadsModel downloadModel = restClient.authenticateUser(adminModel).withCoreAPI().usingDownloads().createDownload(postBody.toString()); - restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); - downloadModel.assertThat().fieldsCount().is(6).and() - .field("id").isNotEmpty(); - - // GET /downloads/{downloadId} - Utility.sleep(500, 10000, () -> { - RestDownloadsModel downloadModel1 = restClient.authenticateUser(adminModel).withCoreAPI().usingDownloads(downloadModel).getDownload(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - downloadModel1.assertThat().fieldsCount().is(6).and() - .field("id").is(downloadModel.getId()).and() - .field("filesAdded").isGreaterThan(0).and() - .field("bytesAdded").isGreaterThan(0).and() - .field("totalBytes").isGreaterThan(0).and() - .field("totalFiles").isGreaterThan(0).and() - .field("status").is("DONE"); - }); - - // Check that download node has content - restClient.authenticateUser(adminModel).withCoreAPI().usingNode().getNodeContent(downloadModel.getId()); - - restClient.assertStatusCodeIs(HttpStatus.OK); - restClient.assertHeaderValueContains("Content-Type","application/octet-stream;charset=UTF-8"); - restClient.assertHeaderValueContains("Content-disposition",".zip"); - Assert.assertTrue(restClient.onResponse().getResponse().body().asInputStream().available() > 0); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.DOWNLOADS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.DOWNLOADS }, executionType = ExecutionType.SANITY, - description = "Sanity tests for DELETE /downloads/{downloadId}") - public void cancelDownloadNode() throws Exception - { - // POST /downloads - String postBody = JsonBodyGenerator.defineJSON() - .add("nodeIds", JsonBodyGenerator.defineJSONArray().add(document1.getNodeRefWithoutVersion())) - .build().toString(); - RestDownloadsModel downloadModel = restClient.authenticateUser(adminModel).withCoreAPI().usingDownloads().createDownload(postBody); - - /* - * DELETE /downloads/{downloadId} - * Download canceling is async and it works only if download status is not "DONE" - * To have this case, a large pdf file was used that takes a longer time to download - */ - restClient.authenticateUser(adminModel).withCoreAPI().usingDownloads(downloadModel).cancelDownload(); - restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); - - // GET /downloads/{downloadId} to check that the download is canceled - Utility.sleep(500, 10000, () -> { - RestDownloadsModel downloadModel1 = restClient.authenticateUser(adminModel).withCoreAPI().usingDownloads(downloadModel).getDownload(); - restClient.assertStatusCodeIs(HttpStatus.OK); - downloadModel1.assertThat().field("status").is("CANCELLED"); - }); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/AddFavoriteSiteTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/AddFavoriteSiteTests.java deleted file mode 100644 index 087d19a4f..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/AddFavoriteSiteTests.java +++ /dev/null @@ -1,487 +0,0 @@ -package org.alfresco.service.search.rest.favorites; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.core.RestRequest; -import org.alfresco.rest.model.RestCommentModel; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestFavoriteSiteModel; -import org.alfresco.rest.model.RestPersonFavoritesModel; -import org.alfresco.rest.model.RestPersonFavoritesModelsCollection; -import org.alfresco.rest.model.RestTagModel; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.LinkModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class AddFavoriteSiteTests extends RestTest -{ - private UserModel userModel, adminUser; - private SiteModel publicSite, privateSite, moderatedSite; - private FileModel document; - private FolderModel folder; - private RestFavoriteSiteModel restFavoriteSiteModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userModel = dataUser.createRandomTestUser(); - - publicSite = dataSite.usingUser(userModel).createPublicRandomSite(); - privateSite = dataSite.usingUser(userModel).createPrivateRandomSite(); - moderatedSite = dataSite.usingUser(userModel).createModeratedRandomSite(); - - document = dataContent.usingSite(publicSite).usingUser(adminUser).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - folder = dataContent.usingSite(publicSite).usingUser(adminUser).createFolder(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user add a favorite site with Rest API and response is successful (201)") - public void managerUserAddFavoriteSiteWithSuccess() throws Exception - { - UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(managerUser, publicSite, UserRole.SiteManager); - - restFavoriteSiteModel = restClient.authenticateUser(managerUser).withCoreAPI().usingUser(managerUser).addFavoriteSite(publicSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restFavoriteSiteModel.assertThat().field("id").is(publicSite.getId()); - - restClient.withCoreAPI().usingUser(managerUser).addFavoriteSite(publicSite); - restClient.assertStatusCodeIs(HttpStatus.CONFLICT); - restClient.assertLastError().containsSummary(String.format("%s is already a favourite site", publicSite.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify a manager user is NOT Authorized to add a favorite site with Rest API when authentication fails (401)") -// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void managerUserNotAuthorizedFailsToAddFavoriteSite() throws Exception - { - UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(managerUser, publicSite, UserRole.SiteManager); - managerUser.setPassword("newpassword"); - - restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().addFavoriteSite(publicSite); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify collaborator user add a favorite site with Rest API and response is successful (201)") - public void collaboratorUserAddFavoriteSiteWithSuccess() throws Exception - { - UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(collaboratorUser, publicSite, UserRole.SiteCollaborator); - - restFavoriteSiteModel = restClient.authenticateUser(collaboratorUser).withCoreAPI().usingAuthUser().addFavoriteSite(publicSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restFavoriteSiteModel.assertThat().field("id").is(publicSite.getId()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify contributor user add a favorite site with Rest API and response is successful (201)") - public void contributorUserAddFavoriteSiteWithSuccess() throws Exception - { - UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(contributorUser, publicSite, UserRole.SiteContributor); - - restFavoriteSiteModel = restClient.authenticateUser(contributorUser).withCoreAPI().usingAuthUser().addFavoriteSite(publicSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restFavoriteSiteModel.assertThat().field("id").is(publicSite.getId()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify consumer user add a favorite site with Rest API and response is successful (201)") - public void consumerUserAddFavoriteSiteWithSuccess() throws Exception - { - UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(consumerUser, publicSite, UserRole.SiteConsumer); - - restFavoriteSiteModel = restClient.authenticateUser(consumerUser).withCoreAPI().usingAuthUser().addFavoriteSite(publicSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restFavoriteSiteModel.assertThat().field("id").is(publicSite.getId()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin user add a favorite site with Rest API and response is successful (201)") - public void adminUserAddFavoriteSiteWithSuccess() throws Exception - { - restFavoriteSiteModel = restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().addFavoriteSite(publicSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restFavoriteSiteModel.assertThat().field("id").is(publicSite.getId()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify manager user is not able to add a favorite site when the site is already favorite - status code (409)") - public void managerUserAddFavoriteSiteAlreadyAFavoriteSite() throws Exception - { - publicSite = dataSite.usingUser(userModel).createPublicRandomSite(); - UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(managerUser, publicSite, UserRole.SiteManager); - - restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().addFavoriteSite(publicSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.withCoreAPI().usingUser(managerUser).addFavoriteSite(publicSite); - restClient.assertStatusCodeIs(HttpStatus.CONFLICT); - restClient.assertLastError() - .containsSummary(String.format("%s is already a favourite site", publicSite.getId())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE) - .containsErrorKey(String.format("Site %s is already a favourite site", publicSite.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify user doesn't have permission to delete favorites of admin user with Rest API and status code is 403") - public void userIsNotAbleToAddFavoriteSiteOfAnotherUser() throws Exception - { - publicSite = dataSite.usingUser(userModel).createPublicRandomSite(); - UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(contributorUser, publicSite, UserRole.SiteContributor); - UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(consumerUser, publicSite, UserRole.SiteConsumer); - - restClient.authenticateUser(consumerUser).withCoreAPI() - .usingUser(contributorUser).addFavoriteSite(publicSite); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError() - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify manager user is able to add as favorite a private site.") - public void managerAddsPrivateSiteAsFavorite() throws Exception - { - UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(managerUser, privateSite, UserRole.SiteManager); - - restClient.authenticateUser(managerUser).withCoreAPI().usingUser(managerUser).addFavoriteSite(privateSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestPersonFavoritesModelsCollection favorites = restClient.withCoreAPI().usingAuthUser().getFavorites(); - favorites.assertThat().entriesListContains("targetGuid", privateSite.getGuidWithoutVersion()) - .and().paginationField("totalItems").is("1"); - favorites.getOneRandomEntry().onModel().getTarget().getSite() - .assertThat() - .field("description").is(privateSite.getDescription()) - .and().field("id").is(privateSite.getId()) - .and().field("visibility").is(privateSite.getVisibility().toString()) - .and().field("title").is(privateSite.getTitle()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify manager user is able to add as favorite a moderated site.") - public void managerAddsModeratedSiteAsFavorite() throws Exception - { - UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(managerUser, moderatedSite, UserRole.SiteManager); - - restClient.authenticateUser(managerUser).withCoreAPI().usingUser(managerUser).addFavoriteSite(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestPersonFavoritesModelsCollection favorites = restClient.withCoreAPI().usingAuthUser().getFavorites(); - favorites.assertThat().entriesListContains("targetGuid", moderatedSite.getGuidWithoutVersion()) - .and().paginationField("totalItems").is("1"); - favorites.getOneRandomEntry().onModel().getTarget().getSite() - .assertThat() - .field("description").is(moderatedSite.getDescription()) - .and().field("id").is(moderatedSite.getId()) - .and().field("visibility").is(moderatedSite.getVisibility().toString()) - .and().field("title").is(moderatedSite.getTitle()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify user removes a site from favorites using '-me-' in place of personId with Rest API and response is successful (201)") - public void addFavoriteSiteWithSuccessUsingMeAsPersonId() throws Exception - { - restClient.authenticateUser(adminUser).withCoreAPI().usingMe().addFavoriteSite(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify manager user removes a site from its favorites and adds it again and response is successful (204)") - public void managerUserRemovesFavoriteSiteAndAddItAgain() throws Exception - { - UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(managerUser, publicSite, UserRole.SiteManager); - dataSite.usingUser(managerUser).usingSite(publicSite).addSiteToFavorites(); - - restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().removeFavoriteSite(publicSite); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingUser(managerUser).addSiteToFavorites(publicSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - } - - @Bug(id="ACE-2413") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify empty user is not able to add a site from favorites and response is (400)") - public void emptyUserIsNotAbleToRemoveFavoriteSite() throws Exception - { - UserModel emptyUser = new UserModel("", "password"); - restClient.authenticateUser(adminUser).withCoreAPI().usingUser(emptyUser).addFavoriteSite(publicSite); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "emptyUser")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify inexistent user is not able to add a site from favorites and response is (404)") - public void inexistentUserIsNotAbleToRemoveFavoriteSite() throws Exception - { - UserModel inexistentUser = new UserModel("inexistentUser", "password"); - restClient.authenticateUser(adminUser).withCoreAPI().usingUser(inexistentUser).addFavoriteSite(publicSite); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "inexistentUser")) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Bug(id="REPO-1827") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify user is not able to add a favorite site when the 'id' is empty - status code (400)") - public void userAddFavoriteSiteWithEmptySiteId() throws Exception - { - publicSite.setId(""); - restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().addFavoriteSite(publicSite); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - restClient.assertLastError() - .containsSummary("siteId is null") - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify admin user doesn't have permission to add a favorite site of another user with Rest API and status code is 403") - public void adminIsNotAbleToAddFavoriteSiteOfAnotherUser() throws Exception - { - UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(collaboratorUser, publicSite, UserRole.SiteCollaborator); - restClient.authenticateUser(collaboratorUser) - .withCoreAPI().usingUser(adminUser).addFavoriteSite(publicSite); - - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError() - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Bug(id="MNT-17338") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify admin user doesn't have permission to add a favorite site of another user with Rest API and status code is 403") - public void userIsNotAbleToAddFavoriteSiteOfAdmin() throws Exception - { - UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(consumerUser, publicSite, UserRole.SiteConsumer); - restClient.authenticateUser(adminUser) - .withCoreAPI().usingUser(consumerUser).addFavoriteSite(publicSite); - - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError() - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify add favorite site using empty body - status code is 400") - public void addFavoriteSiteWithEmptyBody() throws Exception - { - restClient.authenticateUser(adminUser).withCoreAPI(); - RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{\"ids\": \"local\"}" , - "people/{personId}/favorite-sites", adminUser.getUsername()); - restClient.processModel(RestPersonFavoritesModel.class, request); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsSummary(String.format(RestErrorModel.NO_CONTENT, "Unrecognized field " + "\"ids\"")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify add favorite site using empty body - status code is 400") - public void addFavoriteSiteWithEmptyRequiredFieldsBody() throws Exception - { - restClient.authenticateUser(adminUser).withCoreAPI(); - RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{\"\": \"\"}", - "people/{personId}/favorite-sites", adminUser.getUsername()); - restClient.processModel(RestPersonFavoritesModel.class, request); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsSummary(String.format(RestErrorModel.NO_CONTENT, "Unrecognized field " + "\"\"")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify non member user is not able to add a private favorite site - status code is 404") - public void userAddFavoriteSiteUserNotMemberOfPrivateSite() throws Exception - { - UserModel user = dataUser.usingAdmin().createRandomTestUser(); - restClient.authenticateUser(user).withCoreAPI() - .usingAuthUser().addFavoriteSite(privateSite); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, privateSite.getId())) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify non member user is able to add a moderated favorite site") - public void userAddFavoriteSiteUserNotMemberOfModeratedSite() throws Exception - { - UserModel user = dataUser.usingAdmin().createRandomTestUser(); - restClient.authenticateUser(user).withCoreAPI().usingAuthUser() - .addFavoriteSite(moderatedSite); - - RestPersonFavoritesModelsCollection favorites = restClient.withCoreAPI().usingAuthUser().getFavorites(); - favorites.assertThat().entriesListContains("targetGuid", moderatedSite.getGuidWithoutVersion()) - .and().paginationField("totalItems").is("1"); - favorites.getOneRandomEntry().onModel().getTarget().getSite() - .assertThat() - .field("description").is(moderatedSite.getDescription()) - .and().field("id").is(moderatedSite.getId()) - .and().field("visibility").is(moderatedSite.getVisibility().toString()) - .and().field("title").is(moderatedSite.getTitle()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify non member user is able to add a public favorite site") - public void userAddFavoriteSiteUserNotMemberOfPublicSite() throws Exception - { - UserModel user = dataUser.usingAdmin().createRandomTestUser(); - restFavoriteSiteModel = restClient.authenticateUser(user).withCoreAPI().usingAuthUser().addFavoriteSite(publicSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restFavoriteSiteModel.assertThat().field("id").is(publicSite.getId()); - - RestPersonFavoritesModelsCollection favorites = restClient.withCoreAPI().usingAuthUser().getFavorites(); - favorites.assertThat().entriesListContains("targetGuid", publicSite.getGuidWithoutVersion()) - .and().paginationField("totalItems").is("1"); - favorites.getOneRandomEntry().onModel().getTarget().getSite() - .assertThat() - .field("description").is(publicSite.getDescription()) - .and().field("id").is(publicSite.getId()) - .and().field("visibility").is(publicSite.getVisibility().toString()) - .and().field("title").is(publicSite.getTitle()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Check that if id does not exist, status code is 404") - public void addFavoriteSiteUsingInvalidId() throws Exception - { - SiteModel site = dataSite.usingUser(adminUser).createPublicRandomSite(); - String id = publicSite.getId(); - site.setId("invalidID"); - - restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().addFavoriteSite(site); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidID")); - - publicSite.setId(id); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Check that if user provides site in id but id is of a file status code is 404") - public void addSiteToFavoritesUsingFileId() throws Exception - { - String id = publicSite.getId(); - publicSite.setId(document.getNodeRefWithoutVersion()); - - restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().addFavoriteSite(publicSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, document.getNodeRefWithoutVersion())); - - publicSite.setId(id); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Check that if user provides site in id but id is of a folder status code is 404") - public void addSiteToFavoritesUsingFolderId() throws Exception - { - String id = publicSite.getId(); - publicSite.setId(folder.getNodeRefWithoutVersion()); - - restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().addFavoriteSite(publicSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, folder.getNodeRefWithoutVersion())); - - publicSite.setId(id); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Check that if user provides site in id but id is of a comment status code is 404") - public void addSiteToFavoriteUsingCommentId() throws Exception - { - publicSite = dataSite.usingUser(userModel).createPublicRandomSite(); - String id = publicSite.getId(); - FileModel file = dataContent.usingSite(publicSite).usingUser(adminUser).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - RestCommentModel comment = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(file).addComment("This is a comment"); - file.setNodeRef(comment.getId()); - publicSite.setId(comment.getId()); - - restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().addFavoriteSite(publicSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - publicSite.setId(id); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION}) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Check that if user provides site in id but id is of a tag status code is 404") - public void addSiteFavoriteUsingTagId() throws Exception - { - FileModel file = dataContent.usingSite(publicSite).usingUser(adminUser).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - RestTagModel returnedModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(file).addTag("random_tag"); - file.setNodeRef(returnedModel.getId()); - publicSite.setId(returnedModel.getId()); - - restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().addFavoriteSite(publicSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, returnedModel.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION}) - @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Check that if id does not describe a site, file, or folder status code is 400") - public void addFavoriteUsingInvalidGuid() throws Exception - { - LinkModel link = dataLink.usingAdmin().usingSite(publicSite).createRandomLink(); - SiteModel site = dataSite.usingUser(adminUser).createPublicRandomSite(); - site.setId(link.getNodeRef()); - - restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().addFavoriteSite(site); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, site.getId().split("/")[3])); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/AddFavoritesTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/AddFavoritesTests.java deleted file mode 100644 index 3adeb9a4c..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/AddFavoritesTests.java +++ /dev/null @@ -1,446 +0,0 @@ -package org.alfresco.service.search.rest.favorites; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.core.RestRequest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.*; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.model.*; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class AddFavoritesTests extends RestTest -{ - private UserModel adminUserModel; - private SiteModel siteModel; - private ListUserWithRoles usersWithRoles; - private RestPersonFavoritesModel restPersonFavoritesModel; - private FileModel document; - private FolderModel folder; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - - document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - folder = dataContent.usingSite(siteModel).usingUser(adminUserModel).createFolder(); - } - - // @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Verify Manager user gets status code 401 if authentication call fails") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - public void managerIsNotAbleToAddToFavoritesIfAuthenticationFails() throws Exception - { - UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); - siteManager.setPassword("wrongPassword"); - restClient.authenticateUser(siteManager).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify Collaborator user add site to favorites with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void collaboratorIsAbleToAddToFavorites() throws Exception - { - restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restPersonFavoritesModel.and().field("targetGuid").is(siteModel.getGuid()); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify Contributor user add site to favorites with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void contributorIsAbleToAddToFavorites() throws JsonToModelConversionException, Exception - { - restPersonFavoritesModel= restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) - .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restPersonFavoritesModel.and().field("targetGuid").is(siteModel.getGuid()); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify Consumer user add site to favorites with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void consumerIsAbleToAddToFavorites() throws Exception - { - restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restPersonFavoritesModel.and().field("targetGuid").is(siteModel.getGuid()); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify Admin user add site to favorites with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void adminIsAbleToAddToFavorites() throws Exception - { - restPersonFavoritesModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restPersonFavoritesModel.assertThat().field("targetGuid").is(siteModel.getGuid()); - } - - @Bug(id = "MNT-17157") - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Check that if a favorite already exists with the specified id status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void addFavoriteTwice() throws Exception - { - SiteModel site = dataSite.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).createPublicRandomSite(); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteToFavorites(site); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(site); - restClient.assertStatusCodeIs(HttpStatus.CONFLICT); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Add to favorites a file for a Manager, check it was added") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - public void managerIsAbleToAddFileToFavorites() throws Exception - { - restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingAuthUser().addFileToFavorites(document); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restPersonFavoritesModel.assertThat().field("targetGuid").is(document.getNodeRefWithoutVersion()); - - RestFileModel restFileModel = restPersonFavoritesModel.getTarget().getFile(); - restFileModel.assertThat().field("mimeType").is("text/plain").and() - .field("isFile").is("true").and() - .field("isFolder").is("false").and() - .field("createdBy").is(adminUserModel.getUsername()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Add to favorites a folder for a Manager, check it was added") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - public void managerIsAbleToAddFolderToFavorites() throws Exception - { - restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingAuthUser().addFolderToFavorites(folder); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restPersonFavoritesModel.assertThat().field("targetGuid").is(folder.getNodeRefWithoutVersion()); - - RestFolderModel restFolderModel = restPersonFavoritesModel.getTarget().getFolder(); - restFolderModel.assertThat().field("isFile").is("false").and() - .field("isFolder").is("true").and() - .field("createdBy").is(adminUserModel.getUsername()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Add to favorites a site for a Manager, check it was added") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - public void managerIsAbleToAddSiteToFavorites() throws Exception - { - restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restPersonFavoritesModel.assertThat().field("targetGuid").is(siteModel.getGuid()); - - RestSiteModel restSiteModel = restPersonFavoritesModel.getTarget().getSite(); - restSiteModel.assertThat().field("visibility").is(siteModel.getVisibility()).and() - .field("guid").is(siteModel.getGuid()).and() - .field("description").is(siteModel.getDescription()).and() - .field("id").is(siteModel.getId()).and() - .field("title").is(siteModel.getTitle()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify add favorite specifying -me- string in place of for request") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void userIsAbleToAddFavoriteWhenUsingMeAsUsername() throws Exception - { - UserModel user = dataUser.createRandomTestUser(); - restPersonFavoritesModel = restClient.authenticateUser(user) - .withCoreAPI().usingMe().addSiteToFavorites(siteModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restPersonFavoritesModel.assertThat().field("targetGuid").is(siteModel.getGuid()); - - restClient.authenticateUser(user).withCoreAPI().usingAuthUser().getFavoriteSites().assertThat().entriesListContains("guid", siteModel.getGuid()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Add to favorites a file for a Collaborator, check it was added") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void collaboratorIsAbleToAddFileToFavorites() throws Exception - { - restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingAuthUser().addFileToFavorites(document); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restPersonFavoritesModel.assertThat().field("targetGuid").is(document.getNodeRefWithoutVersion()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Add to favorites a file for a Contributor, check it was added") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void contributorIsAbleToAddFileToFavorites() throws Exception - { - restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) - .withCoreAPI().usingAuthUser().addFileToFavorites(document); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restPersonFavoritesModel.assertThat().field("targetGuid").is(document.getNodeRefWithoutVersion()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Add to favorites a file for a Consumer, check it was added") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void consumerIsAbleToAddFileToFavorites() throws Exception - { - restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .withCoreAPI().usingAuthUser().addFileToFavorites(document); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restPersonFavoritesModel.assertThat().field("targetGuid").is(document.getNodeRefWithoutVersion()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Add to favorites a folder for a Collaborator, check it was added") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void collaboratorIsAbleToAddFolderToFavorites() throws Exception - { - restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).addFolderToFavorites(folder); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restPersonFavoritesModel.assertThat().field("targetGuid").is(folder.getNodeRefWithoutVersion()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Add to favorites a folder for a Contributor, check it was added") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void contributorIsAbleToAddFolderToFavorites() throws Exception - { - restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) - .withCoreAPI().usingAuthUser().addFolderToFavorites(folder); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restPersonFavoritesModel.assertThat().field("targetGuid").is(folder.getNodeRefWithoutVersion()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Add to favorites a folder for a Consumer, check it was added") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void consumerIsAbleToAddFolderToFavorites() throws Exception - { - restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .withCoreAPI().usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).addFolderToFavorites(folder); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restPersonFavoritesModel.assertThat().field("targetGuid").is(folder.getNodeRefWithoutVersion()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Add to favorites a site for a Collaborator, check it was added") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void collaboratorIsAbleToAddSiteToFavorites() throws Exception - { - restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restPersonFavoritesModel.assertThat().field("targetGuid").is(siteModel.getGuid()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Add to favorites a site for a Contributor, check it was added") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void contributorIsAbleToAddSiteToFavorites() throws Exception - { - restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) - .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restPersonFavoritesModel.assertThat().field("targetGuid").is(siteModel.getGuid()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Add to favorites a site for a Consumer, check it was added") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void consumerIsAbleToAddSiteToFavorites() throws Exception - { - restPersonFavoritesModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restPersonFavoritesModel.assertThat().field("targetGuid").is(siteModel.getGuid()); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Check that if target guid does not describe a site, file, or folder status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void addFavoriteUsingInvalidGuid() throws Exception - { - LinkModel link = dataLink.usingAdmin().usingSite(siteModel).createRandomLink(); - SiteModel site = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - site.setGuid(link.getNodeRef()); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteToFavorites(site); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, site.getGuid().split("/")[3])); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Check that if personId does not exist, status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void addFavoriteUsingInexistentUser() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(new UserModel("random_user", "random_password")).addSiteToFavorites(siteModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "random_user")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Check that if target guid does not exist, status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void addFavoriteUsingInexistentGuid() throws Exception - { - SiteModel site = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - site.setGuid("random_guid"); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteToFavorites(site); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "random_guid")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Check that if user provides file in target but guid is of a folder status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void addFileToFavoritesUsingFolderGuid() throws Exception - { - String nodeRef = document.getNodeRef(); - document.setNodeRef(folder.getNodeRef()); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFileToFavorites(document); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, - adminUserModel.getUsername(), folder.getNodeRefWithoutVersion())); - - document.setNodeRef(nodeRef); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify add favorite, perform getFavorites call, check value is updated") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void verifyGetFavoritesAfterFavoritingSite() throws Exception - { - UserModel user = dataUser.createRandomTestUser(); - restPersonFavoritesModel = restClient.authenticateUser(user) - .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(user).withCoreAPI().usingAuthUser().getFavoriteSites() - .assertThat().entriesListContains("guid", siteModel.getGuid()); - } - - // @Bug(id = "MNT-17158", description="Not a bug, If we need to stop comments from being favorited then an improvement/enhancement request should be raised against the platform.") - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify add file favorite with comment id returns status code 201") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void addFileFavoriteUsingCommentId() throws Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - RestCommentModel comment = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment("This is a comment"); - file.setNodeRef(comment.getId()); - - restPersonFavoritesModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFileToFavorites(file); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restPersonFavoritesModel.assertThat().field("targetGuid").is(file.getNodeRef()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify add file favorite with tag id returns status code 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void addFileFavoriteUsingTagId() throws Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - RestTagModel returnedModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addTag("random_tag"); - file.setNodeRef(returnedModel.getId()); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFileToFavorites(file); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, - adminUserModel.getUsername(), returnedModel.getId())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Check that if user provides site in target but id is of a file status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void addSiteToFavoritesUsingFileId() throws Exception - { - String guid = siteModel.getGuid(); - siteModel.setGuid(document.getNodeRefWithoutVersion()); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, document.getNodeRefWithoutVersion())); - - siteModel.setGuid(guid); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Check that if user provides folder in target but guid is of a file status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void addFolderToFavoritesUsingFileGuid() throws Exception - { - String nodeRef = folder.getNodeRef(); - folder.setNodeRef(document.getNodeRef()); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFolderToFavorites(folder); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, document.getNodeRef())); - - folder.setNodeRef(nodeRef); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Check that if user provides file in target but guid is of a site status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void addSiteToFavoritesUsingFolderId() throws Exception - { - SiteModel newSiteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - newSiteModel.setGuid(folder.getNodeRef()); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteToFavorites(newSiteModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, folder.getNodeRef())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Check that if user provides folder in target but guid is of a site status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void addFolderToFavoritesUsingSiteId() throws Exception - { - FolderModel newFolder = dataContent.usingSite(siteModel).usingUser(adminUserModel).createFolder(); - newFolder.setNodeRef(siteModel.getGuid()); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFolderToFavorites(newFolder); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, - adminUserModel.getUsername(), siteModel.getGuid())); - } - - @Bug(id = "REPO-1061") - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Check that if user does not have permission to favorite a site status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void verifyFavoriteASiteIfTheUserDoesNotHavePermission() throws Exception - { - SiteModel privateSite = dataSite.usingUser(adminUserModel).createPrivateRandomSite(); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingAuthUser().addSiteToFavorites(privateSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, privateSite.getGuid())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .containsErrorKey(RestErrorModel.NOT_FOUND_ERRORKEY) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify the response of favorite a sie with empty body at request") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void verifyFavoriteASiteWithEmptyBody() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI(); - RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "", "people/{personId}/favorites", adminUserModel.getUsername()); - restClient.processModel(RestPersonFavoritesModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.NO_CONTENT, "No content to map due to end-of-input")); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/DeleteFavoriteSiteTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/DeleteFavoriteSiteTests.java deleted file mode 100644 index 17574ca2f..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/DeleteFavoriteSiteTests.java +++ /dev/null @@ -1,364 +0,0 @@ -package org.alfresco.service.search.rest.favorites; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser; -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 Cristina Axinte - */ - -public class DeleteFavoriteSiteTests extends RestTest -{ - private UserModel userModel, adminUserModel; - private SiteModel siteModel1, siteModel2; - private DataUser.ListUserWithRoles usersWithRoles; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - siteModel1 = dataSite.usingUser(userModel).createPublicRandomSite(); - siteModel2 = dataSite.usingUser(userModel).createPublicRandomSite(); - adminUserModel = dataUser.getAdminUser(); - - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel1, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, - description = "Verify manager user removes a site from its favorite sites list with Rest API and response is successful (204)") - public void managerUserRemovesFavoriteSiteWithSuccess() throws Exception - { - UserModel managerUser = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); - dataSite.usingUser(managerUser).usingSite(siteModel1).addSiteToFavorites(); - dataSite.usingUser(managerUser).usingSite(siteModel2).addSiteToFavorites(); - - restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingAuthUser().getFavorites() - .assertThat() - .entriesListDoesNotContain("targetGuid", siteModel1.getGuid()) - .and().entriesListDoesNotContain("id", siteModel1.getId()) - .and().entriesListDoesNotContain("description", siteModel1.getDescription()) - .and().entriesListDoesNotContain("visibility", siteModel1.getVisibility().toString()) - .and().entriesListDoesNotContain("title", siteModel1.getTitle()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, - description = "Verify manager user is NOT Authorized to remove a site from its favorite sites list with Rest API when authentication fails (401)") - public void managerUserNotAuthorizedFailsToRemoveFavoriteSite() throws Exception - { - UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel1, UserRole.SiteManager); - dataSite.usingUser(managerUser).usingSite(siteModel1).addSiteToFavorites(); - dataSite.usingUser(managerUser).usingSite(siteModel2).addSiteToFavorites(); - managerUser.setPassword("newpassword"); - - restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE) - .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify collaborator user removes a site from its favorite sites list with Rest API and response is successful (204)") - public void collaboratorUserRemovesFavoriteSiteWithSuccess() throws Exception - { - UserModel collaboratorUser = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); - dataSite.usingUser(collaboratorUser).usingSite(siteModel1).addSiteToFavorites(); - dataSite.usingUser(collaboratorUser).usingSite(siteModel2).addSiteToFavorites(); - - restClient.authenticateUser(collaboratorUser).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingAuthUser().getFavorites() - .assertThat() - .entriesListDoesNotContain("targetGuid", siteModel1.getGuid()) - .and().entriesListDoesNotContain("id", siteModel1.getId()) - .and().entriesListDoesNotContain("description", siteModel1.getDescription()) - .and().entriesListDoesNotContain("visibility", siteModel1.getVisibility().toString()) - .and().entriesListDoesNotContain("title", siteModel1.getTitle()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify contributor user removes a site from its favorite sites list with Rest API and response is successful (204)") - public void contributorUserRemovesFavoriteSiteWithSuccess() throws Exception - { - UserModel contributorUser = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); - dataSite.usingUser(contributorUser).usingSite(siteModel1).addSiteToFavorites(); - dataSite.usingUser(contributorUser).usingSite(siteModel2).addSiteToFavorites(); - - restClient.authenticateUser(contributorUser).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingAuthUser().getFavorites() - .assertThat() - .entriesListDoesNotContain("targetGuid", siteModel1.getGuid()) - .and().entriesListDoesNotContain("id", siteModel1.getId()) - .and().entriesListDoesNotContain("description", siteModel1.getDescription()) - .and().entriesListDoesNotContain("visibility", siteModel1.getVisibility().toString()) - .and().entriesListDoesNotContain("title", siteModel1.getTitle()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify consumer user removes a site from its favorite sites list with Rest API and response is successful (204)") - public void consumerUserRemovesFavoriteSiteWithSuccess() throws Exception - { - UserModel consumerUser = usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer); - dataSite.usingUser(consumerUser).usingSite(siteModel1).addSiteToFavorites(); - dataSite.usingUser(consumerUser).usingSite(siteModel2).addSiteToFavorites(); - - restClient.authenticateUser(consumerUser).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingAuthUser().getFavorites() - .assertThat() - .entriesListDoesNotContain("targetGuid", siteModel1.getGuid()) - .and().entriesListDoesNotContain("id", siteModel1.getId()) - .and().entriesListDoesNotContain("description", siteModel1.getDescription()) - .and().entriesListDoesNotContain("visibility", siteModel1.getVisibility().toString()) - .and().entriesListDoesNotContain("title", siteModel1.getTitle()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify admin user removes a site from any user's favorite sites list with Rest API and response is successful (204)") - public void adminUserRemovesAnyFavoriteSiteWithSuccess() throws Exception - { - UserModel anyUser = dataUser.usingAdmin().createRandomTestUser(); - dataSite.usingUser(anyUser).usingSite(siteModel1).addSiteToFavorites(); - dataSite.usingUser(anyUser).usingSite(siteModel2).addSiteToFavorites(); - - restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingUser(anyUser).removeFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE , TestGroup.REGRESSION}) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify a user removes a site from another user's favorite sites list with Rest API and response is permission denied (403)") - public void userCannotRemoveAnotherUserFavoriteSite() throws Exception - { - UserModel userAuth = dataUser.usingAdmin().createRandomTestUser(); - UserModel anotherUser = dataUser.usingAdmin().createRandomTestUser(); - dataSite.usingUser(anotherUser).usingSite(siteModel1).addSiteToFavorites(); - dataSite.usingUser(anotherUser).usingSite(siteModel2).addSiteToFavorites(); - - restClient.authenticateUser(userAuth).withCoreAPI().usingUser(anotherUser).removeFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError() - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE) - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify uninvited user can delete favorite public site and response is 204") - public void uninvitedUserCanDeleteFavoritePublicSite() throws Exception - { - SiteModel publicSiteModel = dataSite.usingAdmin().createPublicRandomSite(); - restClient.authenticateUser(userModel).withCoreAPI().usingUser(userModel).addFavoriteSite(publicSiteModel); - - restClient.withCoreAPI().usingAuthUser() - .removeFavoriteSite(publicSiteModel); - - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingAuthUser().getFavoriteSites() - .assertThat().entriesListDoesNotContain("id", publicSiteModel.getId()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify uninvited user can delete favorite moderated site and response is 204") - public void uninvitedUserCanDeleteFavoriteModeratedSite() throws Exception - { - SiteModel moderatedSiteModel = dataSite.usingAdmin().createModeratedRandomSite(); - restClient.authenticateUser(userModel).withCoreAPI().usingUser(userModel).addFavoriteSite(moderatedSiteModel); - - restClient.withCoreAPI().usingAuthUser() - .removeFavoriteSite(moderatedSiteModel); - - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingAuthUser().getFavoriteSites() - .assertThat().entriesListDoesNotContain("id", moderatedSiteModel.getId()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify user can delete favorite private site and response is 204") - public void userCanDeleteFavoritePrivateSite() throws Exception - { - SiteModel privateSiteModel = dataSite.usingUser(userModel).createPrivateRandomSite(); - restClient.authenticateUser(userModel).withCoreAPI().usingUser(userModel).addFavoriteSite(privateSiteModel); - - restClient.withCoreAPI().usingAuthUser() - .removeFavoriteSite(privateSiteModel); - - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingAuthUser().getFavoriteSites() - .assertThat().entriesListDoesNotContain("id", privateSiteModel.getId()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify manager user removes a site from its favorites and adds it again and response is successful (204)") - public void managerUserRemovesFavoriteSiteAndAddItAgain() throws Exception - { - UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel1, UserRole.SiteManager); - dataSite.usingUser(managerUser).usingSite(siteModel1).addSiteToFavorites(); - - restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser() - .removeFavoriteSite(siteModel1); - - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingUser(managerUser).addFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify user removes a site from favorites using '-me-' in place of personId with Rest API and response is successful (204)") - public void removeFavoriteSiteWithSuccessUsingMeAsPersonId() throws Exception - { - restClient.authenticateUser(adminUserModel); - dataSite.usingUser(adminUserModel).usingSite(siteModel1).addSiteToFavorites(); - - restClient.withCoreAPI().usingMe().removeFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) -// @Bug(id = "REPO-1642", description = "reproduced on 5.2.1 only, it works on 5.2.0") - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify inexistent user is not able to remove a site from favorites and response is 404") - public void inexistentUserIsNotAbleToRemoveFavoriteSite() throws Exception - { - UserModel inexistentUser = new UserModel("inexistenUser", "password"); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(inexistentUser) - .removeFavoriteSite(siteModel1); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "inexistenUser")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify user is not able to remove from favorites a site with inexistent id and response is 404") - public void userIsNotAbleToRemoveFavoriteSiteWithInexistentId() throws Exception - { - SiteModel inexistentSite = new SiteModel("inexistentSite"); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel) - .removeFavoriteSite(inexistentSite); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, - adminUserModel.getUsername(), inexistentSite.getTitle())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE) - .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "User is not able to remove a favorite site of admin user") - public void userIsNotAbleToDeleteFavoritesOfAdmin() throws Exception - { - UserModel contributor = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); - dataSite.usingUser(adminUserModel).usingSite(siteModel1).addSiteToFavorites(); - - restClient.authenticateUser(contributor) - .withCoreAPI().usingUser(adminUserModel).removeFavoriteSite(siteModel1); - - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError() - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Users removed twice from favorites same site.") - public void managerUserRemovesDeletedFavoriteSite() throws Exception - { - UserModel managerUser = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); - dataSite.usingUser(managerUser).usingSite(siteModel1).addSiteToFavorites(); - - restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel1); - restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.NOT_FAVOURITE_SITE, siteModel1.getTitle())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Users removes from favorite a site that is already deleted.") - public void consumerUserRemovesDeletedFavoriteSite() throws Exception - { - SiteModel siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel, UserRole.SiteConsumer); - dataSite.usingUser(consumerUser).usingSite(siteModel).addSiteToFavorites(); - - dataSite.usingAdmin().deleteSite(siteModel); - restClient.authenticateUser(consumerUser).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, - consumerUser.getUsername(), siteModel.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Delete favorite site that is NOT favorite.") - public void adminUserRemovesDeletedFavoriteSiteThatIsNotFavorite() throws Exception - { - SiteModel siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.NOT_FAVOURITE_SITE, siteModel.getTitle())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify user doesn't have permission to delete favorites of another user with Rest API and status code is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void siteMemberIsNotAbleToDeleteFavoritesOfAnotherSiteMember() throws Exception - { - UserModel siteCollaborator = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); - dataSite.usingUser(siteCollaborator).usingSite(siteModel1).addSiteToFavorites(); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .withCoreAPI() - .usingUser(siteCollaborator) - .removeFavoriteSite(siteModel1); - - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError() - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/DeleteFavoriteTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/DeleteFavoriteTests.java deleted file mode 100644 index 3706ede36..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/DeleteFavoriteTests.java +++ /dev/null @@ -1,412 +0,0 @@ -package org.alfresco.service.search.rest.favorites; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class DeleteFavoriteTests extends RestTest -{ - private UserModel adminUserModel; - private SiteModel siteModel; - private ListUserWithRoles usersWithRoles; - private FileModel fileModel; - private FolderModel folderModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - siteModel.setGuid(restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(siteModel).getSite().getGuid()); - - fileModel = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - folderModel = dataContent.usingSite(siteModel).usingUser(adminUserModel).createFolder(); - - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Verify Manager user deletes site from favorites with Rest API and status code is 204") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - public void managerIsAbleToDeleteFavorites() throws Exception - { - UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); - restClient.authenticateUser(siteManager).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - - restClient.withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel).assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingAuthUser().getFavorites() - .assertThat() - .entriesListDoesNotContain("targetGuid", siteModel.getGuid()) - .and().entriesListDoesNotContain("id", siteModel.getId()) - .and().entriesListDoesNotContain("description", siteModel.getDescription()) - .and().entriesListDoesNotContain("visibility", siteModel.getVisibility().toString()) - .and().entriesListDoesNotContain("title", siteModel.getTitle()); - } - - // @Bug(id = "MNT-16904", description = "It fails only on environment with tenants") - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Verify user gets status code 401 if authentication call fails") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - public void userIsNotAbleToDeleteFavoritesIfAuthenticationFails() throws Exception - { - UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); - siteManager.setPassword("wrongPassword"); - restClient.authenticateUser(siteManager).withCoreAPI().usingAuthUser() - .deleteSiteFromFavorites(siteModel).assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify Collaborator user deletes site from favorites with Rest API and status code is 204") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void collaboratorIsAbleToDeleteFavorites() throws Exception - { - UserModel siteCollaborator = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); - restClient.authenticateUser(siteCollaborator).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - - restClient.withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel).assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingAuthUser().getFavorites() - .assertThat() - .entriesListDoesNotContain("targetGuid", siteModel.getGuid()) - .and().entriesListDoesNotContain("id", siteModel.getId()) - .and().entriesListDoesNotContain("description", siteModel.getDescription()) - .and().entriesListDoesNotContain("visibility", siteModel.getVisibility().toString()) - .and().entriesListDoesNotContain("title", siteModel.getTitle()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify Contributor user deletes site from favorites with Rest API and status code is 204") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void contributorIsAbleToDeleteFavorites() throws Exception - { - UserModel siteContributor = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); - restClient.authenticateUser(siteContributor).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - - restClient.withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel).assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingAuthUser().getFavorites() - .assertThat() - .entriesListDoesNotContain("targetGuid", siteModel.getGuid()) - .and().entriesListDoesNotContain("id", siteModel.getId()) - .and().entriesListDoesNotContain("description", siteModel.getDescription()) - .and().entriesListDoesNotContain("visibility", siteModel.getVisibility().toString()) - .and().entriesListDoesNotContain("title", siteModel.getTitle()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify Consumer user delets site from favorites with Rest API and status code is 204") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void consumerIsAbleToDeleteFavorites() throws Exception - { - UserModel siteConsumer = usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer); - restClient.authenticateUser(siteConsumer).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - - restClient.withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel).assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingAuthUser().getFavorites() - .assertThat() - .entriesListDoesNotContain("targetGuid", siteModel.getGuid()) - .and().entriesListDoesNotContain("id", siteModel.getId()) - .and().entriesListDoesNotContain("description", siteModel.getDescription()) - .and().entriesListDoesNotContain("visibility", siteModel.getVisibility().toString()) - .and().entriesListDoesNotContain("title", siteModel.getTitle()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify Admin user deletes site from favorites with Rest API and status code is 204") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void adminIsAbleToDeleteFavorites() throws Exception - { - restClient.withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); - - restClient.withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel).assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingAuthUser().getFavorites().assertThat().entriesListDoesNotContain("targetGuid", siteModel.getGuid()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify admin deletes files from favorites with Rest API and status code is (204)") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void adminIsAbleToDeleteFavoriteFile() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFileToFavorites(fileModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.withCoreAPI().usingAuthUser().deleteFileFromFavorites(fileModel).assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingAuthUser().getFavorites() - .assertThat() - .entriesListDoesNotContain("targetGuid", fileModel.getNodeRefWithoutVersion()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify admin deletes folder from favorites with Rest API and status code is (204)") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void adminIsAbleToDeleteFavoriteFolder() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFolderToFavorites(folderModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.withCoreAPI().usingAuthUser().deleteFolderFromFavorites(folderModel) - .assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingAuthUser().getFavorites() - .assertThat() - .entriesListDoesNotContain("targetGuid", fileModel.getNodeRefWithoutVersion()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify user removes a site from favorites using '-me-' in place of personId with Rest API and response is successful (204)") - public void deleteFavoriteSiteWithSuccessUsingMeAsPersonId() throws Exception - { - siteModel.setGuid(restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(siteModel).getSite().getGuid()); - restClient.withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); - - restClient.withCoreAPI().usingMe().deleteSiteFromFavorites(siteModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @Bug(id="ACE-5588") - @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify user doesn't have permission to delete favorites of admin user with Rest API and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void userIsNotAbleToDeleteFavoritesOfAdminUser() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel) - .assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Bug(id="ACE-5588") - @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify admin user doesn't have permission to delete favorites of another user with Rest API and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void adminIsNotAbleToDeleteFavoritesOfASiteMember() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - - restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel) - .assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError() - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Bug(id="ACE-5588") - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify user doesn't have permission to delete favorites of another user with Rest API and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void consumerIsNotAbleToDeleteFavoritesOfAnotherUser() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI() - .usingAuthUser().addSiteToFavorites(siteModel); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI() - .usingAuthUser().deleteSiteFromFavorites(siteModel) - .assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Bug(id="ACE-5588") - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify consumer user doesn't have permission to delete favorites of another user with Rest API and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void collaboratorIsNotAbleToDeleteFavoriteOfAnotherUser() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI() - .usingAuthUser().addSiteToFavorites(siteModel); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI() - .usingAuthUser().deleteSiteFromFavorites(siteModel) - .assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError() - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Bug(id="ACE-5588") - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify contributor user doesn't have permission to delete favorites of another user with Rest API and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void contributorIsNotAbleToDeleteFavoriteOfAnotherUser() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI() - .usingAuthUser().addSiteToFavorites(siteModel); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI() - .usingAuthUser().deleteSiteFromFavorites(siteModel) - .assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError() - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Bug(id="ACE-5588") - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify contributor user doesn't have permission to delete favorites of another user with Rest API and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void adminIsNotAbleToDeleteFavoriteOfAnotherUser() throws Exception - { - UserModel user = dataUser.createRandomTestUser(); - restClient.authenticateUser(user).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - - restClient.authenticateUser(adminUserModel).withCoreAPI() - .usingAuthUser().deleteSiteFromFavorites(siteModel) - .assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError() - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that status code is 404 if PersonID is incorrect - favorite file.") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION}) - public void deleteFavoriteIfPersonIdNotExists() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); - restClient.withCoreAPI().usingAuthUser().addFileToFavorites(fileModel); - - restClient.withCoreAPI().usingUser(new UserModel("inexistent", "inexistent")) - .deleteFileFromFavorites(fileModel).assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "inexistent")); - } - - @Bug(id="ACE-2413") - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that status code is 404 if PersonID is empty - favorite file.") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION}) - public void deleteFavoriteIfPersonIdIsEmpty() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); - restClient.withCoreAPI().usingAuthUser().addFileToFavorites(fileModel); - - restClient.withCoreAPI().usingUser(new UserModel ("", "")) - .deleteFileFromFavorites(fileModel).assertStatusCodeIs(HttpStatus.BAD_REQUEST); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that status code is 404 if FavoriteID is incorrect - favorite file.") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION}) - public void deleteFavoriteFileIfFavoriteIdIsIncorrect() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFileToFavorites(fileModel); - - fileModel.setNodeRef("wrongFavoriteId"); - restClient.withCoreAPI().usingAuthUser() - .deleteFileFromFavorites(fileModel).assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "wrongFavoriteId")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that status code is 404 if FavoriteID is incorrect - favorite file.") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION}) - public void deleteFavoriteFileIfFavoriteIdNotExists() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFileToFavorites(fileModel); - FileModel inexistentDocument = new FileModel(); - inexistentDocument.setNodeRef("inexistent"); - - restClient.withCoreAPI().usingAuthUser() - .deleteFileFromFavorites(inexistentDocument).assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "inexistent")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that status code is 404 if FavoriteID is incorrect - favorite site.") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION}) - public void deleteFavoriteSiteIfFavoriteIdNotExists() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); - siteModel.setGuid("wrongFavoriteId"); - - restClient.withCoreAPI().usingAuthUser() - .deleteSiteFromFavorites(siteModel).assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "wrongFavoriteId")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that status code is 404 if FavoriteID is incorrect - favorite folder.") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION}) - public void deleteFavoriteFolderIfFavoriteIdNotExists() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); - restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(folderModel); - - folderModel.setNodeRef("wrongFavoriteId"); - restClient.withCoreAPI().usingAuthUser() - .deleteFolderFromFavorites(folderModel).assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "wrongFavoriteId")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify admin is not able to deletes files from favorites that were already deleted with Rest API and status code is (404)") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void adminIsNotAbleToDeleteADeletedFavoriteFile() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addFileToFavorites(fileModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.withCoreAPI().usingAuthUser().deleteFileFromFavorites(fileModel).assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingAuthUser().getFavorites() - .assertThat() - .entriesListDoesNotContain("targetGuid", fileModel.getNodeRefWithoutVersion()); - - restClient.withCoreAPI().usingAuthUser().deleteFileFromFavorites(fileModel) - .assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, - adminUserModel.getUsername(), fileModel.getNodeRef())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify user can't delete favorites using an invalid network ID.") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void userIsNotAbleToDeleteFavoriteSiteWithInvalidNetworkID() throws Exception - { - UserModel networkUserModel = dataUser.createRandomTestUser(); - restClient.authenticateUser(networkUserModel).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - networkUserModel.setDomain("invalidNetwork"); - - restClient.withCoreAPI() - .usingAuthUser().deleteSiteFromFavorites(siteModel) - .assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) - .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify contributor user doesn't have permission to delete favorites of another user with Rest API and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void adminDeletesFavoriteForNotFavouriteFile() throws Exception - { - fileModel = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser() - .deleteFileFromFavorites(fileModel) - .assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, - adminUserModel.getUsername(), fileModel.getNodeRef())) - .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/FavoritesIncludePathTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/FavoritesIncludePathTests.java deleted file mode 100644 index c0f43ceef..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/FavoritesIncludePathTests.java +++ /dev/null @@ -1,143 +0,0 @@ -package org.alfresco.service.search.rest.favorites; - -import static org.alfresco.utility.report.log.Step.STEP; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Class includes Sanity tests for the favorites api. Detailed tests would be covered in the alfresco-remote-api test project - * - * @author meenal bhave - */ -public class FavoritesIncludePathTests extends RestTest -{ - private UserModel adminUser; - private UserModel testUser1; - - private SiteModel siteModel1; - - private FolderModel folder1; - - private FileModel file1; - - private FolderModel subFolder1; - private FileModel fileInSubFolder; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - restClient.authenticateUser(adminUser); - - // Create Standard User - testUser1 = dataUser.usingUser(adminUser).createRandomTestUser(); - - // Create Site - siteModel1 = dataSite.usingUser(testUser1).createPublicRandomSite(); - - folder1 = dataContent.usingUser(adminUser).usingSite(siteModel1).createFolder(); - subFolder1 = dataContent.usingUser(adminUser).usingResource(folder1).createFolder(); - file1 = dataContent.usingUser(adminUser).usingResource(folder1).createContent(DocumentType.TEXT_PLAIN); - fileInSubFolder = dataContent.usingUser(adminUser).usingResource(subFolder1).createContent(DocumentType.TEXT_PLAIN); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify that get favorite site request does not include Path") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION}) - public void testGetFavoriteIncludePathForSite() throws Exception - { - restClient.authenticateUser(testUser1).withCoreAPI().usingAuthUser().includePath().getFavorite(siteModel1.getGuid()); - restClient.assertStatusCodeIs(HttpStatus.OK); - restClient.onResponse().assertThat().body("entry.target.site.id", org.hamcrest.Matchers.equalTo(siteModel1.getId()));//(org.hamcrest.Matchers.nullValue())); - restClient.onResponse().assertThat().body("entry.target.site.path", org.hamcrest.Matchers.is(org.hamcrest.Matchers.nullValue())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify that get favorite file or folder request includes path when requested") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION}) - public void testGetFavouriteIncludePathForFileFolder() throws Exception - { - STEP("1. Favourite Folder and File"); - restClient.authenticateUser(testUser1).withCoreAPI().usingAuthUser().addFolderToFavorites(folder1); - restClient.authenticateUser(testUser1).withCoreAPI().usingAuthUser().addFileToFavorites(file1); - - STEP("2. Check Path for Folder: Displayed when requested"); - restClient.authenticateUser(testUser1).withCoreAPI().usingAuthUser().includePath().getFavorite(folder1.getNodeRefWithoutVersion()); - restClient.assertStatusCodeIs(HttpStatus.OK); - restClient.onResponse().assertThat().body("entry.target.folder.id", org.hamcrest.Matchers.equalTo(folder1.getNodeRefWithoutVersion())); - restClient.onResponse().assertThat().body("entry.target.folder.path", org.hamcrest.Matchers.notNullValue()); - - STEP("3. Check Path for file: Displayed when requested"); - restClient.authenticateUser(testUser1).withCoreAPI().usingAuthUser().includePath().getFavorite(file1.getNodeRefWithoutVersion()); - restClient.assertStatusCodeIs(HttpStatus.OK); - restClient.onResponse().assertThat().body("entry.target.file.id", org.hamcrest.Matchers.equalTo(file1.getNodeRefWithoutVersion())); - restClient.onResponse().assertThat().body("entry.target.file.path", org.hamcrest.Matchers.notNullValue()); - - STEP("4. Check Path for Folder: Not Displayed when not requested"); - restClient.authenticateUser(testUser1).withCoreAPI().usingAuthUser().getFavorite(folder1.getNodeRefWithoutVersion()); - restClient.assertStatusCodeIs(HttpStatus.OK); - restClient.onResponse().assertThat().body("entry.target.folder.id", org.hamcrest.Matchers.equalTo(folder1.getNodeRefWithoutVersion())); - restClient.onResponse().assertThat().body("entry.target.folder.path", org.hamcrest.Matchers.nullValue()); - - STEP("5. Check Path for file: Not Displayed when not requested"); - restClient.authenticateUser(testUser1).withCoreAPI().usingAuthUser().getFavorite(file1.getNodeRefWithoutVersion()); - restClient.assertStatusCodeIs(HttpStatus.OK); - restClient.onResponse().assertThat().body("entry.target.file.id", org.hamcrest.Matchers.equalTo(file1.getNodeRefWithoutVersion())); - restClient.onResponse().assertThat().body("entry.target.file.path", org.hamcrest.Matchers.nullValue()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify path in get favorites") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION}) - public void testGetFavouritesIncludePath() throws Exception - { - STEP("1. Favourite Folder and File"); - restClient.authenticateUser(testUser1).withCoreAPI().usingAuthUser().addFolderToFavorites(folder1); - restClient.authenticateUser(testUser1).withCoreAPI().usingAuthUser().addFileToFavorites(file1); - - STEP("2. Check Path: Displayed when appropriate"); - restClient.authenticateUser(testUser1).withCoreAPI().usingAuthUser().includePath().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - // Folder - restClient.onResponse().assertThat().body("list.entries.entry.target.folder.id", org.hamcrest.Matchers.contains(folder1.getNodeRefWithoutVersion())); - restClient.onResponse().assertThat().body("list.entries.entry.target.folder.path", org.hamcrest.Matchers.notNullValue()); - // File - restClient.onResponse().assertThat().body("list.entries.entry.target.file.id", org.hamcrest.Matchers.contains(file1.getNodeRefWithoutVersion())); - restClient.onResponse().assertThat().body("list.entries.entry.target.file.path", org.hamcrest.Matchers.notNullValue()); - // Site - restClient.onResponse().assertThat().body("list.entries.entry.target.site.id", org.hamcrest.Matchers.contains(siteModel1.getId())); - restClient.onResponse().assertThat().body("list.entries.entry.target.site.path", org.hamcrest.Matchers.contains(org.hamcrest.Matchers.nullValue())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify path in post favorites") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION}) - public void testPostFavouritesIncludePath() throws Exception - { - STEP("1. Favourite Site"); - restClient.authenticateUser(testUser1).withCoreAPI().usingAuthUser().deleteSiteFromFavorites(siteModel1); - restClient.authenticateUser(testUser1).withCoreAPI().usingAuthUser().usingParams("include=path").addFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.onResponse().assertThat().body("entry.id", org.hamcrest.Matchers.equalTo(siteModel1.getId())); - restClient.onResponse().assertThat().body("entry.path", org.hamcrest.Matchers.nullValue()); - - STEP("2. Favourite Folder"); - restClient.authenticateUser(testUser1).withCoreAPI().usingAuthUser().usingParams("include=path").addFolderToFavorites(subFolder1); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.onResponse().assertThat().body("entry.target.folder.id", org.hamcrest.Matchers.equalTo(subFolder1.getNodeRefWithoutVersion())); - restClient.onResponse().assertThat().body("entry.target.folder.path", org.hamcrest.Matchers.notNullValue()); - - STEP("3. Favourite File"); - restClient.authenticateUser(testUser1).withCoreAPI().usingAuthUser().includePath().addFileToFavorites(fileInSubFolder); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.onResponse().assertThat().body("entry.target.file.id", org.hamcrest.Matchers.equalTo(fileInSubFolder.getNodeRefWithoutVersion())); - restClient.onResponse().assertThat().body("entry.target.file.path", org.hamcrest.Matchers.notNullValue()); - } -} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/FavoritesNetworkTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/FavoritesNetworkTests.java deleted file mode 100644 index 54becb068..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/FavoritesNetworkTests.java +++ /dev/null @@ -1,292 +0,0 @@ -package org.alfresco.service.search.rest.favorites; - -import org.alfresco.service.search.rest.NetworkDataPrep; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class FavoritesNetworkTests extends NetworkDataPrep -{ - private SiteModel publicSite, siteModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - init(); - siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.NETWORKS, TestGroup.REGRESSION}) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE}, executionType = ExecutionType.REGRESSION, - description = "Verify tenant user is able to add to favorites his site and status code is (201)") - public void tenantAddFavoriteSiteValidNetwork() throws Exception - { - publicSite = dataSite.usingUser(tenantUser).createPublicRandomSite(); - - restClient.authenticateUser(tenantUser).withCoreAPI(); - - restClient.withCoreAPI() - .usingAuthUser().addSiteToFavorites(publicSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.withCoreAPI().usingAuthUser().getFavorites() - .assertThat() - .entriesListContains("targetGuid", publicSite.getGuidWithoutVersion()); - } - - @Bug(id="MNT-16904") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.NETWORKS, TestGroup.REGRESSION}) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Verify tenant user is not able to add favorites using an invalid network ID - status code (401)") - public void tenantIsNotAbleToAddFavoriteSiteWithInvalidNetworkID() throws Exception - { - publicSite = dataSite.usingUser(tenantUser).createPublicRandomSite(); - - restClient.authenticateUser(tenantUser).withCoreAPI(); - String domain = tenantUser.getDomain(); - try - { - tenantUser.setDomain("invalidNetwork"); - - restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(publicSite); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - finally - { - tenantUser.setDomain(domain); - } - } - - @Bug(id="MNT-16904") - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE}, executionType = ExecutionType.REGRESSION, - description = "Verify tenant user is not able to remove favorites using an invalid network ID") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.NETWORKS, TestGroup.REGRESSION }) - public void tenantIsNotAbleToRemoveFavoriteSiteWithInvalidNetworkID() throws Exception - { - SiteModel siteModel = dataSite.usingUser(tenantUser).createPublicRandomSite(); - - restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - String domain = tenantUser.getDomain(); - try - { - tenantUser.setDomain("invalidNetwork"); - - restClient.withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - finally - { - tenantUser.setDomain(domain); - } - } - - @Bug(id="MNT-16904") - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify tenant user is not able to delete favorites using an invalid network ID") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES,TestGroup.NETWORKS, TestGroup.REGRESSION }) - public void tenantIsNotAbleToDeleteFavoriteSiteWithInvalidNetworkID() throws Exception - { - restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - String domain = tenantUser.getDomain(); - try - { - tenantUser.setDomain("invalidNetwork"); - - restClient.withCoreAPI() - .usingAuthUser().deleteSiteFromFavorites(siteModel) - .assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - finally - { - tenantUser.setDomain(domain); - } - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.NETWORKS, TestGroup.REGRESSION}) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE}, executionType = ExecutionType.REGRESSION, - description = "Verify tenant user is able to add to favorites a site created by admin tenant - same network and status code is (201)") - public void tenantUserIsAbleToAddFavoriteSiteAddedByAdminSameNetwork() throws Exception - { - publicSite = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); - - restClient.authenticateUser(tenantUser).withCoreAPI(); - tenantUser.setDomain(adminTenantUser.getDomain()); - - restClient.withCoreAPI().usingAuthUser().addFavoriteSite(publicSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.withCoreAPI().usingAuthUser().getFavorites() - .assertThat() - .entriesListContains("targetGuid", publicSite.getGuidWithoutVersion()); - } - - @Bug(id = "MNT-16904") - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify the get favorites request when network id is invalid for tenant user") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION, TestGroup.NETWORKS}) - public void getFavoriteSitesWhenNetworkIdIsInvalid() throws Exception - { - SiteModel firstSiteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - - restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); - - String domain = tenantUser.getDomain(); - try - { - tenantUser.setDomain("invalidNetwork"); - restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - finally - { - tenantUser.setDomain(domain); - } - } - - @Bug(id = "MNT-16904") - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify the post favorites request when network id is invalid for tenant user") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION, TestGroup.NETWORKS}) - public void addFavoriteSitesWhenNetworkIdIsInvalid() throws Exception - { - String domain = tenantUser.getDomain(); - try - { - tenantUser.setDomain("invalidNetwork"); - restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - finally{ - tenantUser.setDomain(domain); - } - } - - @Bug(id = "MNT-16904") - @TestRail(section = { TestGroup.REST_API, - TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify the get favorite request for invalid network id") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void getFavoriteSiteWithInvalidNetworkId() throws Exception - { - restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - - String domain = tenantUser.getDomain(); - try - { - tenantUser.setDomain("invalidNetwork"); - restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().getFavorite(siteModel.getGuid()); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - finally - { - tenantUser.setDomain(domain); - } - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify the get favorite request with tenant user") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void getFavoriteSiteWithTenantUser() throws Exception - { - restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - - restClient.withCoreAPI().usingAuthUser().getFavorite(siteModel.getGuid()); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE}, executionType = ExecutionType.REGRESSION, - description = "Verify tenant user deletes favorites site and status code is (204)") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.NETWORKS, TestGroup.REGRESSION }) - public void tenantRemoveFavoriteSiteValidNetwork() throws Exception - { - SiteModel siteModel = dataSite.usingUser(tenantUser).createPublicRandomSite(); - restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - - restClient.withCoreAPI() - .usingAuthUser().removeFavoriteSite(siteModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingAuthUser().getFavorites() - .assertThat() - .entriesListDoesNotContain("targetGuid", siteModel.getGuidWithoutVersion()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES}, executionType = ExecutionType.REGRESSION, - description = "Verify tenant user deletes favorites site and status code is (204)") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES,TestGroup.NETWORKS, TestGroup.REGRESSION }) - public void tenantDeleteFavoriteSiteValidNetwork() throws Exception - { - - restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - - restClient.withCoreAPI() - .usingAuthUser().deleteSiteFromFavorites(siteModel) - .assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingAuthUser().getFavorites() - .assertThat() - .entriesListDoesNotContain("targetGuid", siteModel.getGuidWithoutVersion()); - siteModel = dataSite.usingUser(tenantUser).createPublicRandomSite(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE}, executionType = ExecutionType.REGRESSION, - description = "Verify tenant user remove favorites site created by admin tenant - same network and status code is (204)") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.NETWORKS, TestGroup.REGRESSION }) - public void tenantUserIsAbleToRemoveFavoriteSiteAddedByAdminSameNetwork() throws Exception - { - SiteModel siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); - - restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - tenantUser.setDomain(adminTenantUser.getDomain()); - - restClient.withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingAuthUser().getFavorites() - .assertThat() - .entriesListDoesNotContain("targetGuid", siteModel.getGuidWithoutVersion()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES}, executionType = ExecutionType.REGRESSION, - description = "Verify tenant user deletes favorites site created by admin tenant - same network and status code is (204)") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES,TestGroup.NETWORKS, TestGroup.REGRESSION }) - public void tenantUserIsAbleToDeleteFavoriteSiteAddedByAdminSameNetwork() throws Exception - { - - restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - tenantUser.setDomain(adminTenantUser.getDomain()); - - restClient.withCoreAPI() - .usingAuthUser().deleteSiteFromFavorites(siteModel) - .assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingAuthUser().getFavorites() - .assertThat() - .entriesListDoesNotContain("targetGuid", siteModel.getGuidWithoutVersion()); - siteModel = dataSite.usingUser(tenantUser).createPublicRandomSite(); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/GetFavoriteSiteTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/GetFavoriteSiteTests.java deleted file mode 100644 index e2654df64..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/GetFavoriteSiteTests.java +++ /dev/null @@ -1,292 +0,0 @@ -package org.alfresco.service.search.rest.favorites; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.dataprep.SiteService; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.core.RestRequest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestSiteModel; -import org.alfresco.rest.model.RestSiteModelsCollection; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Tests for Get Favorite Sites (/people/{personId}/preferences) RestAPI call - * - * @author Cristina Axinte - */ - -public class GetFavoriteSiteTests extends RestTest -{ - private UserModel userModel; - private SiteModel siteModel1; - private SiteModel siteModel2; - private RestSiteModel restSiteModel; - private DataUser.ListUserWithRoles usersWithRoles; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - siteModel1 = dataSite.usingUser(userModel).createPublicRandomSite(); - siteModel2 = dataSite.usingUser(userModel).createPublicRandomSite(); - - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel1, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - - dataSite.usingUser(userModel).usingSite(siteModel1).addSiteToFavorites(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user gets its specific favorite site with Rest API and response is successful (200)") - public void managerUserGetsFavoriteSiteWithSuccess() throws Exception - { - UserModel managerUser = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); - - dataSite.usingUser(managerUser).usingSite(siteModel1).addSiteToFavorites(); - dataSite.usingUser(managerUser).usingSite(siteModel2).addSiteToFavorites(); - - restSiteModel = restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().getFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModel.assertThat().field("id").is(siteModel1.getId()).and().field("title").isNotNull(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify collaborator user gets its specific favorite site with Rest API and response is successful (200)") - public void collaboratorUserGetsFavoriteSiteWithSuccess() throws Exception - { - UserModel collaboratorUser = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); - - dataSite.usingUser(collaboratorUser).usingSite(siteModel1).addSiteToFavorites(); - dataSite.usingUser(collaboratorUser).usingSite(siteModel2).addSiteToFavorites(); - - restSiteModel = restClient.authenticateUser(collaboratorUser).withCoreAPI().usingAuthUser().getFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModel.assertThat().field("id").is(siteModel1.getId()).and().field("title").isNotNull(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify contributor user gets its specific favorite site with Rest API and response is successful (200)") - public void contributorUserGetsFavoriteSiteWithSuccess() throws Exception - { - UserModel contributorUser = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); - - dataSite.usingUser(contributorUser).usingSite(siteModel1).addSiteToFavorites(); - dataSite.usingUser(contributorUser).usingSite(siteModel2).addSiteToFavorites(); - - restSiteModel = restClient.authenticateUser(contributorUser).withCoreAPI().usingAuthUser().getFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModel.assertThat().field("id").is(siteModel1.getId()).and().field("title").isNotNull(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify consumer user gets its specific favorite site with Rest API and response is successful (200)") - public void consumerUserGetsFavoriteSiteWithSuccess() throws Exception - { - UserModel consumerUser = usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer); - - dataSite.usingUser(consumerUser).usingSite(siteModel1).addSiteToFavorites(); - dataSite.usingUser(consumerUser).usingSite(siteModel2).addSiteToFavorites(); - - restSiteModel = restClient.authenticateUser(consumerUser).withCoreAPI().usingAuthUser().getFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModel.assertThat().field("id").is(siteModel1.getId()).and().field("title").isNotNull(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin user gets specific favorite site of any user with Rest API and response is successful (200)") - public void adminUserGetsAnyFavoriteSiteWithSuccess() throws Exception - { - UserModel adminUser = dataUser.getAdminUser(); - UserModel anyUser = dataUser.usingAdmin().createRandomTestUser(); - dataSite.usingUser(anyUser).usingSite(siteModel1).addSiteToFavorites(); - dataSite.usingUser(anyUser).usingSite(siteModel2).addSiteToFavorites(); - - restSiteModel = restClient.authenticateUser(adminUser).withCoreAPI().usingUser(anyUser).getFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModel.assertThat().field("id").is(siteModel1.getId()).and().field("title").isNotNull(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify manager user fails to get specific favorite site of another user with Rest API and response is successful (403)") - public void managerUserFailsToGetFavoriteSiteOfAnotherUser() throws Exception - { - UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel1, UserRole.SiteManager); - dataSite.usingUser(managerUser).usingSite(siteModel1).addSiteToFavorites(); - dataSite.usingUser(managerUser).usingSite(siteModel2).addSiteToFavorites(); - - restClient.authenticateUser(managerUser).withCoreAPI().usingUser(userModel).getFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized gets its specific favorite site with Rest API when authentication fails (401)") -// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void managerUserNotAuthorizedFailsToGetFavoriteSite() throws Exception - { - UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel1, UserRole.SiteManager); - dataSite.usingUser(managerUser).usingSite(siteModel1).addSiteToFavorites(); - dataSite.usingUser(managerUser).usingSite(siteModel2).addSiteToFavorites(); - managerUser.setPassword("newpassword"); - - restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().getFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify invalid request returns status 404 when personId does not exist") - public void getFavoriteSiteWithNonExistentPersonId() throws Exception - { - UserModel someUser = new UserModel("someUser", DataUser.PASSWORD); - - restClient.authenticateUser(userModel).withCoreAPI().usingUser(someUser).getFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "someUser")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify invalid request returns status 404 when siteId does not exist") - public void getFavoriteSiteWithNonExistentSiteId() throws Exception - { - SiteModel nonExistentSite = new SiteModel("nonExistentSite"); - - restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().getFavoriteSite(nonExistentSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, userModel.getUsername(), nonExistentSite.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify User fails to get specific favorite site of admin with Rest API and response is 403") - public void userFailsToGetFavoriteSiteOfAdmin() throws Exception - { - restClient.authenticateUser(userModel).withCoreAPI().usingUser(dataUser.getAdminUser()).getFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify request with empty site id") - public void getFavoriteSiteWithEmptySiteId() throws Exception - { - restClient.authenticateUser(userModel).withCoreAPI(); - RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "people/{personId}/favorite-sites/{siteId}?{parameters}", - userModel.getUsername(), "", restClient.getParameters()); - RestSiteModelsCollection sites = restClient.processModels(RestSiteModelsCollection.class, request); - restClient.assertStatusCodeIs(HttpStatus.OK); - sites.assertThat().entriesListIsNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify invalid request returns status 401 when user is empty") - public void getFavoriteSiteWithEmptyPersonId() throws Exception - { - UserModel emptyUser = new UserModel("", "password"); - restClient.authenticateUser(emptyUser).withCoreAPI().usingAuthUser().getFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify invalid request returns status 404 when another user get favorite site of an user") - public void getFavoriteSiteWithAnotherUser() throws Exception - { - UserModel user = dataUser.createRandomTestUser(); - restClient.authenticateUser(user).withCoreAPI().usingAuthUser().getFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, user.getUsername(), siteModel1.getId())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE) - .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify request returns status 200 when using -me-") - public void getFavoriteSiteUsingMe() throws Exception - { - restSiteModel = restClient.authenticateUser(userModel).withCoreAPI().usingMe().getFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModel.assertThat().field("id").is(siteModel1.getId()) - .and().field("title").is(siteModel1.getTitle()) - .and().field("role").is(UserRole.SiteManager.toString()) - .and().field("visibility").is(SiteService.Visibility.PUBLIC.toString()) - .and().field("guid").isNotEmpty() - .and().field("description").is(siteModel1.getDescription()) - .and().field("preset").is("site-dashboard"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify invalid request returns status 404 when providing folder name instead of site id") - public void getFavoriteSiteUsingFolder() throws Exception - { - FolderModel folder = dataContent.usingUser(userModel).usingSite(siteModel1).createFolder(); - SiteModel siteFolder = new SiteModel(folder.getName()); - restSiteModel = restClient.authenticateUser(userModel).withCoreAPI().usingMe().getFavoriteSite(siteFolder); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, userModel.getUsername(), folder.getName())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify invalid request returns status 404 when providing file name instead of site id") - public void getFavoriteSiteUsingFile() throws Exception - { - FileModel file = dataContent.usingSite(siteModel1).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - SiteModel siteFolder = new SiteModel(file.getName()); - restSiteModel = restClient.authenticateUser(userModel).withCoreAPI().usingMe().getFavoriteSite(siteFolder); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, userModel.getUsername(), file.getName())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify request returns status 200 when using valid parameters") - public void getFavoriteSiteUsingParameters() throws Exception - { - restSiteModel = restClient.withParams("maxItems=100").authenticateUser(userModel).withCoreAPI().usingMe().getFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModel.assertThat().field("id").is(siteModel1.getId()) - .and().field("title").is(siteModel1.getTitle()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify request returns status 400 when using maxItems=0") - public void getFavoriteSiteUsingInvalidMaxItems() throws Exception - { - restSiteModel = restClient.withParams("maxItems=0").authenticateUser(userModel).withCoreAPI().usingMe().getFavoriteSite(siteModel1); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify request returns status 401 when using invalid network") - public void getFavoriteSiteUsingInvalidNetwork() throws Exception - { - UserModel invalidUserNetwork = dataUser.createRandomTestUser(); - SiteModel site = dataSite.usingUser(invalidUserNetwork).createPublicRandomSite(); - dataSite.usingUser(invalidUserNetwork).usingSite(site).addSiteToFavorites(); - invalidUserNetwork.setDomain("invalidNetwork"); - restSiteModel = restClient.authenticateUser(invalidUserNetwork).withCoreAPI().usingMe().getFavoriteSite(site); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/GetFavoriteSitesTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/GetFavoriteSitesTests.java deleted file mode 100644 index ed162d744..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/GetFavoriteSitesTests.java +++ /dev/null @@ -1,325 +0,0 @@ -package org.alfresco.service.search.rest.favorites; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestSiteModel; -import org.alfresco.rest.model.RestSiteModelsCollection; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser; -import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class GetFavoriteSitesTests extends RestTest -{ - private UserModel userModel, testUser1; - private SiteModel siteModel, testSite1, testSite2, testSite3; - private RestSiteModelsCollection restSiteModelsCollection; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - testUser1 = dataUser.createRandomTestUser(); - - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - testSite1 = new SiteModel("A-" + RandomData.getRandomAlphanumeric()); - testSite2 = new SiteModel("B-" + RandomData.getRandomAlphanumeric()); - testSite3 = new SiteModel("C-" + RandomData.getRandomAlphanumeric()); - - dataSite.usingUser(userModel).usingSite(siteModel).addSiteToFavorites(); - - dataSite.usingUser(testUser1).createSite(testSite1); - dataSite.usingUser(testUser1).createSite(testSite2); - dataSite.usingUser(testUser1).createSite(testSite3); - - dataSite.usingUser(testUser1).usingSite(testSite3).addSiteToFavorites(); - dataSite.usingUser(testUser1).usingSite(testSite2).addSiteToFavorites(); - dataSite.usingUser(testUser1).usingSite(testSite1).addSiteToFavorites(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify manager user fails to get an user favorite sites with Rest API (403)") - public void managerUserFailsToGetAnUserFavoriteSites() throws Exception - { - UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); - UserModel anotherUser = dataUser.usingAdmin().createRandomTestUser(); - dataSite.usingUser(anotherUser).usingSite(siteModel).addSiteToFavorites(); - - restClient.authenticateUser(managerUser).withCoreAPI().usingUser(anotherUser).getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify collaborator user fails to get an user favorite sites with Rest API (403)") - public void collaboratorUserFailsToGetAnUserFavoriteSites() throws Exception - { - UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(collaboratorUser, siteModel, UserRole.SiteCollaborator); - UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(contributorUser, siteModel, UserRole.SiteContributor); - dataSite.usingUser(contributorUser).usingSite(siteModel).addSiteToFavorites(); - - restClient.authenticateUser(collaboratorUser).withCoreAPI().usingUser(contributorUser).getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify contributor user fails to get an user favorite sites with Rest API (403)") - public void contributorUserFailsToGetAnUserFavoriteSites() throws Exception - { - UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); - UserModel contributorUser2 = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(contributorUser, siteModel, UserRole.SiteContributor); - dataUser.usingUser(userModel).addUserToSite(contributorUser2, siteModel, UserRole.SiteContributor); - dataSite.usingUser(contributorUser2).usingSite(siteModel).addSiteToFavorites(); - - restClient.authenticateUser(contributorUser).withCoreAPI().usingUser(contributorUser2).getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify consumer user fails to get an user favorite sites with Rest API (403)") - public void consumerUserFailsToGetAnUserFavoriteSites() throws Exception - { - UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); - UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel, UserRole.SiteConsumer); - dataUser.usingUser(collaboratorUser).addUserToSite(collaboratorUser, siteModel, UserRole.SiteCollaborator); - dataSite.usingUser(collaboratorUser).usingSite(siteModel).addSiteToFavorites(); - - restClient.authenticateUser(consumerUser).withCoreAPI().usingUser(collaboratorUser).getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify any user gets its own user favorite sites with Rest API and response is successful (200)") - public void anyUserGetsHisFavoriteSites() throws Exception - { - UserModel anyUser = dataUser.usingAdmin().createRandomTestUser(); - dataSite.usingUser(anyUser).usingSite(siteModel).addSiteToFavorites(); - - restSiteModelsCollection = restClient.authenticateUser(anyUser).withCoreAPI().usingAuthUser().getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModelsCollection.assertThat().entriesListIsNotEmpty().and().entriesListContains("id", siteModel.getId()).and().paginationExist(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify any user is NOT Authorized to get its favorite sites with Rest API when authentication fails (401)") -// @Bug(id = "MNT-16904", description = "It fails only on environment with tenants") - public void unauthenticatedUserIsNotAuthorizedToGetFavoriteSites() throws Exception - { - UserModel anyUser = dataUser.usingAdmin().createRandomTestUser(); - dataSite.usingUser(anyUser).usingSite(siteModel).addSiteToFavorites(); - anyUser.setPassword("newpassword"); - - restClient.authenticateUser(anyUser).withCoreAPI().usingAuthUser().getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify that getFavoriteSites request status code is 404 for a personId that does not exist") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void getFavoriteSitesReturns404ForAPersonIdThatDoesNotExist() throws Exception - { - UserModel invalidUser = new UserModel(RandomData.getRandomName("User"), DataUser.PASSWORD); - - restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingUser(invalidUser).getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, invalidUser.getUsername())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify that getFavoriteSites request status code is 403 if the user doesn't have access to the person favorite sites") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void userCannotGetFavoriteSitesForAnotherUser() throws Exception - { - restClient.authenticateUser(userModel).withCoreAPI().usingUser(testUser1).getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin has access to regular user site favorites") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void adminCanGetFavoriteSitesForARegularUser() throws Exception - { - restSiteModelsCollection = restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingUser(userModel).getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModelsCollection.assertThat().entriesListIsNotEmpty() - .assertThat().entriesListContains("id", siteModel.getId()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify that regular user can not see admin user site favorites") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void regularUserCannotGetFavoriteSitesForAdminUser() throws Exception - { - restClient.authenticateUser(testUser1).withCoreAPI().usingUser(dataUser.getAdminUser()).getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify that favorite site can be removed") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void verifyThatFavoriteSiteCanBeRemoved() throws Exception - { - UserModel randomTestUser = dataUser.createRandomTestUser(); - dataSite.usingUser(randomTestUser).usingSite(siteModel).addSiteToFavorites(); - - restSiteModelsCollection = restClient.authenticateUser(randomTestUser).withCoreAPI().usingAuthUser().getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModelsCollection.assertThat().entriesListIsNotEmpty() - .assertThat().entriesListContains("id", siteModel.getId()); - - dataSite.usingUser(randomTestUser).usingSite(siteModel).removeSiteFromFavorites(); - restSiteModelsCollection = restClient.withCoreAPI().usingAuthUser().getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModelsCollection.assertThat().entriesListIsEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify that if maxItems param is invalid status code returned is BAD_REQUEST (400)") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void getFavoriteSitesMaxItemsInvalidValueTest() throws Exception - { - restClient.authenticateUser(userModel).withParams("maxItems=-1").withCoreAPI().usingAuthUser().getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); - - restClient.authenticateUser(userModel).withParams("maxItems=abc").withCoreAPI().usingAuthUser().getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "abc")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify that if skipCount param is invalid status code returned is BAD_REQUEST (400)") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void getFavoriteSitesSkipCountInvalidValueTest() throws Exception - { - restClient.authenticateUser(userModel).withParams("skipCount=-1").withCoreAPI().usingAuthUser().getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT); - - restClient.authenticateUser(userModel).withParams("skipCount=abc").withCoreAPI().usingAuthUser().getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "abc")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify that getFavoriteSites request response status using -me- string in place of personId is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void userGetsFavoriteSiteWithSuccessUsingMEForRequest() throws Exception - { - restSiteModelsCollection = restClient.authenticateUser(testUser1).withCoreAPI().usingMe().getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModelsCollection.assertThat().entriesListIsNotEmpty() - .and().entriesListContains("id", testSite1.getId()) - .and().paginationExist(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify that getFavoriteSites request response status for a user that has no favorite sites is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void getFavoriteSiteRequestForUserWithNoFavoriteSitesIsSuccessful() throws Exception - { - UserModel randomTestUser = dataUser.createRandomTestUser(); - - restSiteModelsCollection = restClient.authenticateUser(randomTestUser).withCoreAPI().usingMe().getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModelsCollection.assertThat().entriesListIsEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify that getFavoriteSites request response status for a user with several favorite sites is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void getFavoriteSiteRequestForUserWithSeveralFavoriteSitesIsSuccessful() throws Exception - { - restSiteModelsCollection = restClient.authenticateUser(testUser1).withCoreAPI().usingAuthUser().getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModelsCollection.assertThat().entriesListIsNotEmpty() - .and().entriesListContains("id", testSite1.getId()) - .and().entriesListContains("id", testSite2.getId()) - .and().entriesListContains("id", testSite3.getId()) - .and().paginationExist(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify that getFavoriteSites request can only be called with a positive maxItems param") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void userCanNotGetFavoriteSitesWith0MaxItems() throws Exception - { - restClient.authenticateUser(testUser1).withParams("maxItems=0").withCoreAPI().usingAuthUser().getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsErrorKey(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) - .containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify that getFavoriteSites request response status code for a high skipCount param is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void userCanGetFavoriteSitesWithHighSkipCount() throws Exception - { - restSiteModelsCollection = restClient.authenticateUser(testUser1).withParams("skipCount=999999999").withCoreAPI().usingAuthUser().getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModelsCollection.assertThat().entriesListIsEmpty() - .assertThat().paginationField("skipCount").is("999999999"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify that user can retrieve the last 2 favorite sites") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void userCanRetrieveLast2FavoriteSites() throws Exception - { - restSiteModelsCollection = restClient.authenticateUser(testUser1).withParams("skipCount=1&maxCount=2"). - withCoreAPI().usingAuthUser().getFavoriteSites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModelsCollection.assertThat().entriesListIsNotEmpty() - .assertThat().entriesListCountIs(2) - .assertThat().entriesListContains("id", testSite2.getId()) - .assertThat().entriesListContains("id", testSite3.getId()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify that getFavoriteSites request applies valid properties param") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void getFavoriteSitesRequestWithValidPropertiesParam() throws Exception - { - RestSiteModel restSiteModel = restClient.authenticateUser(testUser1).withParams("properties=title") - .withCoreAPI().usingAuthUser().getFavoriteSites().getOneRandomEntry().onModel(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModel.assertThat().fieldsCount().is(1) - .assertThat().field("title").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify that getFavoriteSites request applies invalid properties param") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void getFavoriteSitesRequestWithInvalidPropertiesParam() throws Exception - { - restClient.authenticateUser(testUser1).withParams("properties=tas").withCoreAPI().usingAuthUser() - .getFavoriteSites().getOneRandomEntry().onModel().assertThat().fieldsCount().is(0); - restClient.assertStatusCodeIs(HttpStatus.OK); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/GetFavoriteTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/GetFavoriteTests.java deleted file mode 100644 index 70cee947a..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/GetFavoriteTests.java +++ /dev/null @@ -1,480 +0,0 @@ -package org.alfresco.service.search.rest.favorites; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.dataprep.SiteService; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestPersonFavoritesModel; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser; -import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class GetFavoriteTests extends RestTest -{ - private UserModel adminUserModel; - private SiteModel siteModel; - private FolderModel folderModel; - private FileModel fileModel; - private ListUserWithRoles usersWithRoles; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - - folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); - fileModel = dataContent.usingUser(adminUserModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Verify Manager user gets favorite site with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - public void managerIsAbleToRetrieveFavoriteSite() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - - RestPersonFavoritesModel favSite = restClient.withCoreAPI().usingAuthUser().getFavorite(siteModel.getGuid()); - restClient.assertStatusCodeIs(HttpStatus.OK); - favSite.assertThat().field("targetGuid").is(siteModel.getGuid()); - - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Verify Manager user gets favorite folder with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - public void managerIsAbleToRetrieveFavoriteFolder() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(folderModel); - - RestPersonFavoritesModel favoriteFolder = restClient.withCoreAPI().usingAuthUser().getFavorite(folderModel.getNodeRef()); - restClient.assertStatusCodeIs(HttpStatus.OK); - favoriteFolder.assertThat().field("targetGuid").is(folderModel.getNodeRef()); - - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Verify Manager user gets favorite file with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - public void managerIsAbleToRetrieveFavoriteFile() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingAuthUser().addFileToFavorites(fileModel); - - RestPersonFavoritesModel favoriteFile = restClient.withCoreAPI().usingAuthUser().getFavorite(fileModel.getNodeRefWithoutVersion()); - restClient.assertStatusCodeIs(HttpStatus.OK); - favoriteFile.assertThat().field("targetGuid").is(fileModel.getNodeRefWithoutVersion()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Verify user gets status code 401 if authentication call fails") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) -// @Bug(id = "MNT-16904", description = "fails only on environment with tenants") - public void userIsNotAbleToRetrieveFavoriteSiteIfAuthenticationFails() throws Exception - { - UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); - siteManager.setPassword("wrongPassword"); - restClient.authenticateUser(siteManager).withCoreAPI() - .usingUser(siteManager).getFavorite(siteModel.getGuid()); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify Admin user gets favorite site with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void adminIsAbleToRetrieveFavoritesSite() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); - - RestPersonFavoritesModel favoriteSite = restClient.withCoreAPI().usingUser(adminUserModel).getFavorite(siteModel.getGuid()); - restClient.assertStatusCodeIs(HttpStatus.OK); - favoriteSite.assertThat().field("targetGuid").is(siteModel.getGuid()); - favoriteSite.getTarget().getSite() - .assertThat().field("guid").is(siteModel.getGuid()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify Admin user gets favorite folder with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void adminIsAbleToRetrieveFavoritesFolder() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).addFolderToFavorites(folderModel); - - RestPersonFavoritesModel favoriteFolder = restClient.withCoreAPI().usingUser(adminUserModel).getFavorite(folderModel.getNodeRef()); - restClient.assertStatusCodeIs(HttpStatus.OK); - favoriteFolder.assertThat().field("targetGuid").is(folderModel.getNodeRef()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify Admin user gets favorite file with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void adminIsAbleToRetrieveFavoritesFile() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).addFileToFavorites(fileModel); - - RestPersonFavoritesModel favoriteFile = restClient.withCoreAPI().usingUser(adminUserModel).getFavorite(fileModel.getNodeRefWithoutVersion()); - restClient.assertStatusCodeIs(HttpStatus.OK); - favoriteFile.assertThat().field("targetGuid").is(fileModel.getNodeRefWithoutVersion()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify Collaborator user gets favorite site with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void collaboratorIsAbleToRetrieveFavoriteSite() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - - RestPersonFavoritesModel favSite = restClient.withCoreAPI().usingAuthUser().getFavorite(siteModel.getGuid()); - restClient.assertStatusCodeIs(HttpStatus.OK); - favSite.assertThat().field("targetGuid").is(siteModel.getGuid()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify collaborator user gets favorite folder with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void collaboratorIsAbleToRetrieveFavoriteFolder() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(folderModel); - - RestPersonFavoritesModel favoriteFolder = restClient.withCoreAPI().usingAuthUser().getFavorite(folderModel.getNodeRef()); - restClient.assertStatusCodeIs(HttpStatus.OK); - favoriteFolder.assertThat().field("targetGuid").is(folderModel.getNodeRef()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify collaborator user gets favorite file with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void collaboratorIsAbleToRetrieveFavoriteFile() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.withCoreAPI().usingAuthUser().addFileToFavorites(fileModel); - - RestPersonFavoritesModel favoriteFile = restClient.withCoreAPI().usingAuthUser().getFavorite(fileModel.getNodeRefWithoutVersion()); - restClient.assertStatusCodeIs(HttpStatus.OK); - favoriteFile.assertThat().field("targetGuid").is(fileModel.getNodeRefWithoutVersion()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify Contributor user gets favorite site with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void contributorIsAbleToRetrieveFavoriteSite() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - - RestPersonFavoritesModel favSite = restClient.withCoreAPI().usingAuthUser().getFavorite(siteModel.getGuid()); - restClient.assertStatusCodeIs(HttpStatus.OK); - favSite.assertThat().field("targetGuid").is(siteModel.getGuid()); ; - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify contributor user gets favorite folder with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void contributorIsAbleToRetrieveFavoriteFolder() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(folderModel); - - RestPersonFavoritesModel favoriteFolder = restClient.withCoreAPI().usingAuthUser().getFavorite(folderModel.getNodeRef()); - restClient.assertStatusCodeIs(HttpStatus.OK); - favoriteFolder.assertThat().field("targetGuid").is(folderModel.getNodeRef()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify contributor user gets favorite file with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void contributorIsAbleToRetrieveFavoriteFile() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - restClient.withCoreAPI().usingAuthUser().addFileToFavorites(fileModel); - - RestPersonFavoritesModel favoriteFile = restClient.withCoreAPI().usingAuthUser().getFavorite(fileModel.getNodeRefWithoutVersion()); - restClient.assertStatusCodeIs(HttpStatus.OK); - favoriteFile.assertThat().field("targetGuid").is(fileModel.getNodeRefWithoutVersion()); - } - - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify Consumer user gets favorite site with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void consumerIsAbleToRetrieveFavorites() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - - RestPersonFavoritesModel favSite = restClient.withCoreAPI().usingAuthUser().getFavorite(siteModel.getGuid()); - restClient.assertStatusCodeIs(HttpStatus.OK); - favSite.assertThat().field("targetGuid").is(siteModel.getGuid()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify consumer user gets favorite folder with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void consumerIsAbleToRetrieveFavoriteFolder() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(folderModel); - - RestPersonFavoritesModel favoriteFolder = restClient.withCoreAPI().usingAuthUser().getFavorite(folderModel.getNodeRef()); - restClient.assertStatusCodeIs(HttpStatus.OK); - favoriteFolder.assertThat().field("targetGuid").is(folderModel.getNodeRef()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify consumer user gets favorite file with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void consumerIsAbleToRetrieveFavoriteFile() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.withCoreAPI().usingAuthUser().addFileToFavorites(fileModel); - - RestPersonFavoritesModel favoriteFile = restClient.withCoreAPI().usingAuthUser().getFavorite(fileModel.getNodeRefWithoutVersion()); - restClient.assertStatusCodeIs(HttpStatus.OK); - favoriteFile.assertThat().field("targetGuid").is(fileModel.getNodeRefWithoutVersion()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify user doesn't get favorite site of another user with Rest API and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void userIsNotAbleToRetrieveFavoriteSiteOfAnotherSiteMember() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.withCoreAPI().usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .getFavorite(siteModel.getGuid()); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator).getUsername())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify user doesn't get favorite site of admin user with Rest API and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void userIsNotAbleToRetrieveFavoritesOfAdminUser() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .withCoreAPI().usingUser(adminUserModel).getFavorite(siteModel.getGuid()); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, adminUserModel.getUsername())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify admin user doesn't get favorite site of another user with Rest API and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void adminIsNotAbleToRetrieveFavoritesOfAnotherUser() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI() - .usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).getFavorite(siteModel.getGuid()); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator).getUsername())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, - executionType = ExecutionType.REGRESSION, description = "Verify get favorite user doesn't have any favorite site, file or folder") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void getFavoriteSiteForUserWithoutAnyFavorites() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingAuthUser().getFavorite(siteModel.getGuid()); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, usersWithRoles.getOneUserWithRole(UserRole.SiteManager).getUsername(), siteModel.getGuid())) - .statusCodeIs(HttpStatus.NOT_FOUND) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE) - .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify get favorite site for -me-") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void getFavoriteSiteUsingMe() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel); - - RestPersonFavoritesModel favoriteSite = restClient.withCoreAPI().usingMe().getFavorite(siteModel.getGuid()); - restClient.assertStatusCodeIs(HttpStatus.OK); - favoriteSite.assertThat().field("targetGuid").is(siteModel.getGuid()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify get favorite site for -me-") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void getFavoriteFileUsingMe() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingAuthUser().addFileToFavorites(fileModel); - - RestPersonFavoritesModel favoriteFile = restClient.withCoreAPI().usingMe().getFavorite(fileModel.getNodeRefWithoutVersion()); - restClient.assertStatusCodeIs(HttpStatus.OK); - favoriteFile.assertThat().field("targetGuid").is(fileModel.getNodeRefWithoutVersion()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, - executionType = ExecutionType.REGRESSION, description = "Verify get favorite site when person id does't exist") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void getFavoriteSiteWhenPersonIdNotExist() throws Exception { - - restClient.withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); - UserModel someUser = new UserModel("invalidUser", DataUser.PASSWORD); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(someUser).getFavorite(siteModel.getGuid()); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, someUser.getUsername())) - .statusCodeIs(HttpStatus.NOT_FOUND) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY); - } - - @Bug(id = "ACE-2413") - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, - executionType = ExecutionType.REGRESSION, description = "Verify get favorite site when person id is empty") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void getFavoriteSiteWithEmptyUserId() throws Exception { - - restClient.withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); - UserModel someUser = new UserModel("", DataUser.PASSWORD); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(someUser).getFavorite(siteModel.getGuid()); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, someUser.getUsername())) - .statusCodeIs(HttpStatus.BAD_REQUEST); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, - executionType = ExecutionType.REGRESSION, description = "Verify get favorite site when favorite id does't exist") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void getFavoriteSiteWhenFavoriteIdNotExist() throws Exception { - - restClient.withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).getFavorite("invalidId"); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidId")) - .statusCodeIs(HttpStatus.NOT_FOUND) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify Admin user gets favorite site with properties filter") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void verifyRequestForGetFavoriteSiteWithProperties() throws Exception - { - UserModel collaborator = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); - restClient.authenticateUser(collaborator); - restClient.withCoreAPI().usingUser(collaborator).addSiteToFavorites(siteModel); - - RestPersonFavoritesModel favoriteSite = restClient.authenticateUser(collaborator).withParams("properties=targetGuid") - .withCoreAPI().usingAuthUser().getFavorite(siteModel.getGuid()); - restClient.assertStatusCodeIs(HttpStatus.OK); - favoriteSite.assertThat().field("targetGuid").is(siteModel.getGuid()); - favoriteSite.assertThat().fieldsCount().is(1); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify Admin user gets favorite site with inccorect properties filter") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void verifyRequestForGetFavoriteSiteWithInvalidProperties() throws Exception - { - UserModel collaborator = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); - restClient.authenticateUser(collaborator); - restClient.withCoreAPI().usingUser(collaborator).addFileToFavorites(fileModel); - - RestPersonFavoritesModel favoriteFile = restClient.authenticateUser(collaborator).withParams("properties=tas") - .withCoreAPI().usingAuthUser().getFavorite(fileModel.getNodeRefWithoutVersion()); - restClient.assertStatusCodeIs(HttpStatus.OK); - favoriteFile.assertThat().fieldsCount().is(0); - } - - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify all values from get favorite rest api for a file") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void verifyRequestFieldsForGetFavoriteFile() throws Exception - { - UserModel contributor = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); - restClient.authenticateUser(contributor); - restClient.withCoreAPI().usingUser(contributor).addFileToFavorites(fileModel); - - RestPersonFavoritesModel favoriteFile = restClient.authenticateUser(contributor) - .withCoreAPI().usingAuthUser().getFavorite(fileModel.getNodeRefWithoutVersion()); - restClient.assertStatusCodeIs(HttpStatus.OK); - - favoriteFile.assertThat().field("targetGuid").is(fileModel.getNodeRefWithoutVersion()) - .and().field("target.file.isFile").is("true") - .and().field("target.file.mimeType").is("text/plain") - .and().field("target.file.isFolder").is("false") - .and().field("target.file.createdBy").is(adminUserModel.getUsername()) - .and().field("target.file.versionLabel").is("1.0") - .and().field("target.file.name").is(fileModel.getName()) - .and().field("target.file.parentId").is(folderModel.getNodeRef()) - .and().field("target.file.guid").is(fileModel.getNodeRefWithoutVersion()) - .and().field("target.file.modifiedBy").is(adminUserModel.getUsername()) - .and().field("target.file.id").is(fileModel.getNodeRefWithoutVersion()); - } - - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify all values from get favorite rest api for a site") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void verifyRequestFieldsForGetFavoriteSite() throws Exception - { - UserModel contributor = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); - restClient.authenticateUser(contributor); - restClient.withCoreAPI().usingUser(contributor).addFavoriteSite(siteModel); - - RestPersonFavoritesModel favoriteSite = restClient.authenticateUser(contributor) - .withCoreAPI().usingAuthUser().getFavorite(siteModel.getGuid()); - restClient.assertStatusCodeIs(HttpStatus.OK); - - favoriteSite.assertThat().field("targetGuid").is(siteModel.getGuid()) - .and().field("target.site.role").is(UserRole.SiteContributor.toString()) - .and().field("target.site.visibility").is(SiteService.Visibility.PUBLIC.toString()) - .and().field("target.site.guid").is(siteModel.getGuid()) - .and().field("target.site.description").is(siteModel.getDescription()) - .and().field("target.site.id").is(siteModel.getId()) - .and().field("target.site.preset").is("site-dashboard") - .and().field("target.site.title").is(siteModel.getTitle()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify all values from get favorite rest api for a folder") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void verifyRequestFieldsForGetFavoriteFolder() throws Exception - { - UserModel contributor = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); - restClient.authenticateUser(contributor); - restClient.withCoreAPI().usingUser(contributor).addFolderToFavorites(folderModel); - - RestPersonFavoritesModel favoriteFolder = restClient.authenticateUser(contributor) - .withCoreAPI().usingAuthUser().getFavorite(folderModel.getNodeRef()); - restClient.assertStatusCodeIs(HttpStatus.OK); - - favoriteFolder.assertThat().field("targetGuid").is(folderModel.getNodeRef()) - .and().field("target.folder.isFile").is("false") - .and().field("target.folder.isFolder").is("true") - .and().field("target.folder.createdBy").is(adminUserModel.getUsername()) - .and().field("target.folder.name").is(folderModel.getName()) - .and().field("target.folder.guid").is(folderModel.getNodeRef()) - .and().field("target.folder.modifiedBy").is(adminUserModel.getUsername()) - .and().field("target.folder.id").is(folderModel.getNodeRef()); - } -} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/GetFavoritesTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/GetFavoritesTests.java deleted file mode 100644 index e73bd92dd..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/favorites/GetFavoritesTests.java +++ /dev/null @@ -1,555 +0,0 @@ -package org.alfresco.service.search.rest.favorites; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestPersonFavoritesModel; -import org.alfresco.rest.model.RestPersonFavoritesModelsCollection; -import org.alfresco.rest.model.RestSiteModel; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class GetFavoritesTests extends RestTest -{ - private UserModel adminUserModel, userModel; - private SiteModel firstSiteModel; - private SiteModel secondSiteModel; - private SiteModel thirdSiteModel; - private FileModel firstFileModel; - private FileModel secondFileModel; - private FolderModel firstFolderModel; - private FolderModel secondFolderModel; - private ListUserWithRoles firstSiteUsers, secondSiteUsers; - private RestPersonFavoritesModelsCollection userFavorites; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - userModel = dataUser.createRandomTestUser(); - - firstSiteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - secondSiteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - thirdSiteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - firstFolderModel = dataContent.usingUser(adminUserModel).usingSite(firstSiteModel).createFolder(); - secondFolderModel = dataContent.usingUser(adminUserModel).usingSite(firstSiteModel).createFolder(); - firstFileModel = dataContent.usingUser(adminUserModel).usingResource(firstFolderModel).createContent(DocumentType.TEXT_PLAIN); - secondFileModel = dataContent.usingUser(adminUserModel).usingResource(firstFolderModel).createContent(DocumentType.TEXT_PLAIN); - - firstSiteUsers = dataUser.addUsersWithRolesToSite(firstSiteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - secondSiteUsers = dataUser.addUsersWithRolesToSite(secondSiteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - - restClient.authenticateUser(userModel); - restClient.withCoreAPI().usingUser(userModel).addSiteToFavorites(firstSiteModel); - restClient.withCoreAPI().usingUser(userModel).addSiteToFavorites(secondSiteModel); - restClient.withCoreAPI().usingUser(userModel).addSiteToFavorites(thirdSiteModel); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Verify Manager user gets favorites with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) - public void managerIsAbleToRetrieveFavorites() throws Exception - { - restClient.authenticateUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); - restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(secondSiteModel); - - userFavorites = restClient.withCoreAPI().usingAuthUser().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - userFavorites.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) - .assertThat().entriesListContains("targetGuid", secondSiteModel.getGuid()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY, - description = "Verify user gets status code 401 if authentication call fails") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY }) -// @Bug(id = "MNT-16904", description = "It fails only on environment with tenants") - public void userIsNotAbleToRetrieveFavoritesIfAuthenticationFails() throws Exception - { - UserModel siteManager = firstSiteUsers.getOneUserWithRole(UserRole.SiteManager); - siteManager.setPassword("wrongPassword"); - restClient.authenticateUser(siteManager).withCoreAPI().usingAuthUser().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify Admin user gets favorites sites with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void adminIsAbleToRetrieveFavoritesSites() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(firstSiteModel); - restClient.withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(secondSiteModel); - - userFavorites = restClient.withCoreAPI() - .usingAuthUser().where().targetSiteExist().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - userFavorites.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) - .and().entriesListContains("targetGuid", secondSiteModel.getGuid()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify Admin user gets favorites folders with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void adminIsAbleToRetrieveFavoritesFolders() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).addFolderToFavorites(firstFolderModel); - restClient.withCoreAPI().usingUser(adminUserModel).addFolderToFavorites(secondFolderModel); - - userFavorites = restClient.withCoreAPI() - .usingAuthUser().where().targetFolderExist().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - userFavorites.assertThat().entriesListContains("targetGuid", firstFolderModel.getNodeRef()) - .and().entriesListContains("targetGuid", secondFolderModel.getNodeRef()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify Admin user gets favorites files with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void adminIsAbleToRetrieveFavoritesFiles() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).addFileToFavorites(firstFileModel); - restClient.withCoreAPI().usingUser(adminUserModel).addFileToFavorites(secondFileModel); - - userFavorites = restClient.withCoreAPI() - .usingAuthUser().where().targetFileExist().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - userFavorites.assertThat().entriesListContains("targetGuid", firstFileModel.getNodeRefWithoutVersion()) - .and().entriesListContains("targetGuid", secondFileModel.getNodeRefWithoutVersion()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify Collaborator user gets favorites with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void collaboratorIsAbleToRetrieveFavorites() throws Exception - { - restClient.authenticateUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); - restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(secondSiteModel); - - userFavorites = restClient.withCoreAPI().usingAuthUser().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - userFavorites.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) - .and().entriesListContains("targetGuid", secondSiteModel.getGuid()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify Contributor user gets favorites with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void contributorIsAbleToRetrieveFavorites() throws Exception - { - restClient.authenticateUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteContributor)) - .withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); - restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(secondSiteModel); - - userFavorites = restClient.withCoreAPI().usingAuthUser().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - userFavorites.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()).and() - .entriesListContains("targetGuid", secondSiteModel.getGuid()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify Consumer user gets favorites with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void consumerIsAbleToRetrieveFavorites() throws Exception - { - restClient.authenticateUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteConsumer)) - .withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); - restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(secondSiteModel); - - userFavorites = restClient.withCoreAPI().usingAuthUser().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - userFavorites.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) - .assertThat().entriesListContains("targetGuid", secondSiteModel.getGuid()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify user doesn't have permission to get favorites of another user with Rest API and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void userIsNotAbleToRetrieveFavoritesOfAnotherUser() throws Exception - { - restClient.authenticateUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteConsumer)) - .withCoreAPI().usingUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)).getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, firstSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator).getUsername())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify user doesn't have permission to get favorites of admin user with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void userIsNotAbleToRetrieveFavoritesOfAdminUser() throws Exception - { - restClient.authenticateUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI() - .usingUser(adminUserModel).getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, adminUserModel.getUsername())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify admin user doesn't have permission to get favorites of another user with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void adminIsNotAbleToRetrieveFavoritesOfAnotherUser() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)) - .getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, firstSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator).getUsername())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify User gets only favorites sites with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void userIsAbleToRetrieveOnlyFavoritesSites() throws Exception - { - restClient.authenticateUser(secondSiteUsers.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); - restClient.withCoreAPI().usingAuthUser().addFileToFavorites(firstFileModel); - restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(firstFolderModel); - - userFavorites = restClient.withCoreAPI().usingAuthUser().where().targetSiteExist().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - userFavorites.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) - .and().entriesListDoesNotContain("targetGuid", secondSiteModel.getGuid()) - .and().entriesListDoesNotContain("targetGuid", firstFileModel.getNodeRefWithoutVersion()) - .and().entriesListDoesNotContain("targetGuid", firstFolderModel.getNodeRef()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify User gets only favorites files with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void userIsAbleToRetrieveOnlyFavoritesFiles() throws Exception - { - restClient.authenticateUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); - restClient.withCoreAPI().usingAuthUser().addFileToFavorites(firstFileModel); - restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(firstFolderModel); - - userFavorites = restClient.withCoreAPI().usingAuthUser().where().targetFileExist().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - userFavorites.assertThat().entriesListContains("targetGuid", firstFileModel.getNodeRefWithoutVersion()) - .and().entriesListDoesNotContain("targetGuid", secondFileModel.getNodeRefWithoutVersion()) - .and().entriesListDoesNotContain("targetGuid", firstSiteModel.getGuid()) - .and().entriesListDoesNotContain("targetGuid", firstFolderModel.getNodeRef()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify User gets only favorites folders with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void userIsAbleToRetrieveOnlyFavoritesFolders() throws Exception - { - restClient.authenticateUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); - restClient.withCoreAPI().usingAuthUser().addFileToFavorites(firstFileModel); - restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(firstFolderModel); - - userFavorites = restClient.withCoreAPI().usingAuthUser().where().targetFolderExist().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - userFavorites.assertThat().entriesListContains("targetGuid", firstFolderModel.getNodeRef()) - .and().entriesListDoesNotContain("targetGuid", secondFolderModel.getNodeRef()) - .and().entriesListDoesNotContain("targetGuid", firstSiteModel.getGuid()) - .and().entriesListDoesNotContain("targetGuid", firstFileModel.getNodeRefWithoutVersion()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify User gets only favorites files or folders with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void userIsAbleToRetrieveFavoritesFilesOrFolders() throws Exception - { - restClient.authenticateUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); - restClient.withCoreAPI().usingAuthUser().addFileToFavorites(firstFileModel); - restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(firstFolderModel); - - userFavorites = restClient.withCoreAPI().usingAuthUser() - .where().targetFolderExist().or().targetFileExist() - .getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - userFavorites.assertThat().entriesListContains("targetGuid", firstFolderModel.getNodeRef()) - .and().entriesListContains("targetGuid", firstFileModel.getNodeRefWithoutVersion()) - .and().entriesListDoesNotContain("targetGuid", secondFolderModel.getNodeRef()) - .and().entriesListDoesNotContain("targetGuid", secondFileModel.getNodeRefWithoutVersion()) - .and().entriesListDoesNotContain("targetGuid", firstSiteModel.getGuid()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify User gets only favorites files or sites with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void userIsAbleToRetrieveFavoritesFilesOrSites() throws Exception - { - restClient.authenticateUser(secondSiteUsers.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); - restClient.withCoreAPI().usingAuthUser().addFileToFavorites(firstFileModel); - restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(firstFolderModel); - - userFavorites = restClient.withCoreAPI().usingAuthUser() - .where().targetSiteExist().or().targetFileExist() - .getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - userFavorites.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) - .and().entriesListContains("targetGuid", firstFileModel.getNodeRefWithoutVersion()) - .and().entriesListDoesNotContain("targetGuid", secondSiteModel.getGuid()) - .and().entriesListDoesNotContain("targetGuid", secondFileModel.getNodeRefWithoutVersion()) - .and().entriesListDoesNotContain("targetGuid", firstFolderModel.getNodeRef()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify User gets only favorites folders or sites with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void userIsAbleToRetrieveFavoritesFoldersOrSites() throws Exception - { - restClient.authenticateUser(secondSiteUsers.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); - restClient.withCoreAPI().usingAuthUser().addFileToFavorites(firstFileModel); - restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(firstFolderModel); - - userFavorites = restClient.withCoreAPI().usingAuthUser() - .where().targetSiteExist().or().targetFolderExist() - .getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - userFavorites.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) - .and().entriesListContains("targetGuid", firstFolderModel.getNodeRef()) - .and().entriesListDoesNotContain("targetGuid", secondSiteModel.getGuid()) - .and().entriesListDoesNotContain("targetGuid", secondFolderModel.getNodeRef()) - .and().entriesListDoesNotContain("targetGuid", firstFileModel.getNodeRefWithoutVersion()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify User gets all favorites with Rest API and status code is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void userIsAbleToRetrieveAllFavorites() throws Exception - { - restClient.authenticateUser(secondSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); - restClient.withCoreAPI().usingAuthUser().addFileToFavorites(firstFileModel); - restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(firstFolderModel); - - userFavorites = restClient.withCoreAPI().usingAuthUser() - .where().targetSiteExist().or().targetFolderExist().or().targetFileExist() - .getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - userFavorites.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) - .and().entriesListContains("targetGuid", firstFolderModel.getNodeRef()) - .and().entriesListContains("targetGuid", firstFileModel.getNodeRefWithoutVersion()) - .and().entriesListDoesNotContain("targetGuid", secondSiteModel.getGuid()) - .and().entriesListDoesNotContain("targetGuid", secondFolderModel.getNodeRef()) - .and().entriesListDoesNotContain("targetGuid", secondFileModel.getNodeRefWithoutVersion()); - - userFavorites = restClient.withCoreAPI().usingAuthUser().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - userFavorites.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) - .and().entriesListContains("targetGuid", firstFolderModel.getNodeRef()) - .and().entriesListContains("targetGuid", firstFileModel.getNodeRefWithoutVersion()) - .and().entriesListDoesNotContain("targetGuid", secondSiteModel.getGuid()) - .and().entriesListDoesNotContain("targetGuid", secondFolderModel.getNodeRef()) - .and().entriesListDoesNotContain("targetGuid", secondFileModel.getNodeRefWithoutVersion()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify request for a user with no favorites returns status 200") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void userHasNoFavorites() throws Exception - { - restClient.authenticateUser(secondSiteUsers.getOneUserWithRole(UserRole.SiteContributor)); - - userFavorites = restClient.withCoreAPI().usingAuthUser().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - userFavorites.assertThat().entriesListIsEmpty().and().paginationField("totalItems").is("0"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify request using invalid where parameter returns status 400") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void getFavoritesUsingInvalidWhereParameter() throws Exception - { - restClient.authenticateUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); - restClient.withCoreAPI().usingAuthUser().addFileToFavorites(firstFileModel); - restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(firstFolderModel); - - userFavorites = restClient.withCoreAPI().usingAuthUser() - .where().or().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_ARGUMENT, "WHERE query")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify User gets correct favorites after deleting a favorite") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void checkFavoriteFolderIsRemoved() throws Exception - { - restClient.authenticateUser(firstSiteUsers.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(firstSiteModel); - restClient.withCoreAPI().usingAuthUser().addFileToFavorites(firstFileModel); - restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(firstFolderModel); - - restClient.withCoreAPI().usingAuthUser().deleteFolderFromFavorites(firstFolderModel); - - userFavorites = restClient.withCoreAPI().usingAuthUser().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - userFavorites.assertThat().entriesListDoesNotContain("targetGuid", firstFolderModel.getNodeRef()) - .and().paginationField("totalItems").is("2"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify get favorites specifying -me- string in place of for request") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void userIsAbleToGetFavoritesWhenUsingMeAsUsername() throws Exception - { - userFavorites = restClient.authenticateUser(userModel).withCoreAPI().usingMe().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - userFavorites.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()).and().entriesListContains("targetGuid", secondSiteModel.getGuid()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify get favorites using empty for where parameter for request") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void userIsAbleToGetFavoritesWhenUsingEmptyWhereParameter() throws Exception - { - userFavorites = restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().where().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_ARGUMENT, "WHERE query")); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that for invalid maxItems parameter status code returned is 400.") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void checkInvalidMaxItemsStatusCode() throws Exception - { - restClient.authenticateUser(adminUserModel).withParams("maxItems=AB").withCoreAPI().usingUser(adminUserModel).getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Invalid paging parameter"); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that for invalid skipCount parameter status code returned is 400.") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void checkInvalidSkipCountStatusCode() throws Exception - { - restClient.authenticateUser(adminUserModel).withParams("skipCount=AB").withCoreAPI().usingUser(adminUserModel).getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Invalid paging parameter"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify get favorites when using invalid network id for non-tenant user") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void getFavoritesWhenNetworkIdIsInvalid() throws Exception - { - UserModel networkUserModel = dataUser.createRandomTestUser(); - networkUserModel.setDomain("invalidNetwork"); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(networkUserModel).where().targetSiteExist().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, networkUserModel.getUsername())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify get favorites using AND instead of OR in where parameter for request") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void userIsNotAbleToGetFavoritesWhenUsingANDInWhereParameter() throws Exception - { - userFavorites = restClient.withCoreAPI().usingAuthUser().where().targetFolderExist().invalidWhereParameter("AND").targetFileExist().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_ARGUMENT, "WHERE query")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify get favorites using wrong name instead of EXISTS in where parameter for request") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void userIsNotAbleToGetFavoritesWhenUsingWrongWhereParameter() throws Exception - { - userFavorites = restClient.withCoreAPI().usingAuthUser().where().invalidWhereParameter("EXIST((target/site))").targetFileExist().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_ARGUMENT, "WHERE query")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify get favorites except the first one for request") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void userIsAbleToGetFavoritesExceptTheFirstOne() throws Exception - { - userFavorites = restClient.authenticateUser(userModel).withParams("skipCount=1").withCoreAPI().usingUser(userModel).getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - userFavorites.assertThat().entriesListContains("targetGuid", firstSiteModel.getGuid()) - .and().entriesListContains("targetGuid", secondSiteModel.getGuid()) - .and().entriesListDoesNotContain("targetGuid", thirdSiteModel.getGuid()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify get first two favorites sites") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void userIsAbleToGetFirstTwoFavorites() throws Exception - { - userFavorites = restClient.authenticateUser(userModel).withParams("maxItems=2").withCoreAPI().usingUser(userModel).getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - userFavorites.assertThat().entriesListContains("targetGuid", thirdSiteModel.getGuid()) - .and().entriesListContains("targetGuid", secondSiteModel.getGuid()) - .and().entriesListDoesNotContain("targetGuid", firstSiteModel.getGuid()) - .getPagination().assertThat().field("maxItems").is("2") - .and().field("hasMoreItems").is("true") - .and().field("count").is("2"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify get favorites sites when using empty values for skipCount and maxItems") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void userIsAbleToGetFavoritesWhenSkipCountAndMaxItemsAreEmpty() throws Exception - { - restClient.authenticateUser(userModel).withParams("skipCount= ").withCoreAPI().usingUser(userModel).getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, " ")); - - restClient.authenticateUser(userModel).withParams("maxItems= ").withCoreAPI().usingUser(userModel).getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, " ")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify the get favorites request for a high value for skipCount parameter") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void userIsAbleToGetFavoritesWithHighSkipCount() throws Exception - { - userFavorites = restClient.authenticateUser(userModel).withParams("skipCount=999999999").withCoreAPI().usingUser(userModel).getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - userFavorites.assertThat().entriesListIsEmpty().assertThat().paginationField("skipCount").is("999999999"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify the get favorites request with properties parameter applied") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void userIsAbleToGetFavoritesWithPropertiesParamApplied() throws Exception - { - userFavorites = restClient.authenticateUser(userModel).withParams("properties=targetGuid").withCoreAPI().usingUser(userModel).getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - RestPersonFavoritesModel restPersonFavoritesModel = userFavorites.getEntries().get(0).onModel(); - restPersonFavoritesModel.assertThat().field("targetGuid").is(thirdSiteModel.getGuid()).and().field("createdAt").isNull(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify entry details for get favorites response with Rest API") - public void checkResponseSchemaForGetFavorites() throws Exception - { - userFavorites = restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().getFavorites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - RestPersonFavoritesModel restPersonFavoritesModel = userFavorites.getEntries().get(0).onModel(); - restPersonFavoritesModel.assertThat().field("targetGuid").is(thirdSiteModel.getGuid()); - - RestSiteModel restSiteModel = restPersonFavoritesModel.getTarget().getSite(); - restSiteModel.assertThat().field("visibility").is(thirdSiteModel.getVisibility()).and() - .field("guid").is(thirdSiteModel.getGuid()).and() - .field("description").is(thirdSiteModel.getDescription()).and() - .field("id").is(thirdSiteModel.getId()).and() - .field("title").is(thirdSiteModel.getTitle()); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/groups/GroupsTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/groups/GroupsTests.java deleted file mode 100644 index cbc87a06a..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/groups/GroupsTests.java +++ /dev/null @@ -1,158 +0,0 @@ -package org.alfresco.service.search.rest.groups; - -import java.util.UUID; - -import javax.json.Json; -import javax.json.JsonObject; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.utility.RetryOperation; -import org.alfresco.utility.Utility; -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; - -@Test(groups = {TestGroup.REQUIRE_SOLR}) -public class GroupsTests extends RestTest -{ - private UserModel adminUser, userModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userModel = dataUser.createRandomTestUser(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.GROUPS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.SANITY, - description = "Verify creation, listing, updating and deletion of groups.") - public void createListUpdateAndDeleteGroup() throws Exception - { - String groupName = "ZtestGroup" + UUID.randomUUID().toString(); - JsonObject groupBody = Json.createObjectBuilder().add("id", groupName).add("displayName", groupName).build(); - String groupBodyCreate = groupBody.toString(); - - //GroupCreation: - //-ve - restClient.authenticateUser(userModel).withCoreAPI().usingGroups().createGroup(groupBodyCreate); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - //+ve - restClient.authenticateUser(adminUser).withCoreAPI().usingParams("include=zones").usingGroups().createGroup(groupBodyCreate) - .assertThat().field("zones").contains("APP.DEFAULT") - .and().field("isRoot").is(true) - .and().field("displayName").is(groupName); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - //ListGroups: - restClient.withCoreAPI().usingParams("orderBy=displayName DESC&maxItems=10").usingGroups().listGroups() - .assertThat().entriesListContains("id", "GROUP_"+groupName) - .and().entriesListDoesNotContain("zones") - .and().paginationField("maxItems").is("10"); - restClient.assertStatusCodeIs(HttpStatus.OK); - - groupBody = Json.createObjectBuilder().add("displayName", "Z"+groupName).build(); - String groupBodyUpdate = groupBody.toString(); - //UpdateGroup: - restClient.withCoreAPI().usingGroups().updateGroupDetails("GROUP_"+groupName, groupBodyUpdate) - .assertThat().field("displayName").is("Z"+groupName) - .and().field("id").is("GROUP_"+groupName) - .and().field("zones").isNull(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - //GetGroupDetails: - restClient.withCoreAPI().usingParams("include=zones").usingGroups().getGroupDetail("GROUP_"+groupName) - .assertThat().field("id").is("GROUP_"+groupName) - .and().field("zones").contains("APP.DEFAULT") - .and().field("isRoot").is(true); - restClient.assertStatusCodeIs(HttpStatus.OK); - - //DeleteGroup: - //-ve - restClient.authenticateUser(userModel).withCoreAPI().usingGroups().deleteGroup("GROUP_"+groupName); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - //+ve - restClient.authenticateUser(adminUser).withCoreAPI().usingGroups().deleteGroup("GROUP_"+groupName); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.GROUPS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.SANITY, - description = "Verify creation, listing(only for person) and deletion of group memberships. ") - public void createListDeleteGroupMembership() throws Exception - { - String groupName = "ZtestGroup" + UUID.randomUUID().toString(); - JsonObject groupBody = Json.createObjectBuilder().add("id", groupName).add("displayName", groupName).build(); - String groupBodyCreate = groupBody.toString(); - - //GroupCreation: - restClient.authenticateUser(adminUser).withCoreAPI().usingParams("include=zones").usingGroups().createGroup(groupBodyCreate); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - JsonObject groupMembershipBody = Json.createObjectBuilder().add("id", userModel.getUsername()).add("memberType", "PERSON").build(); - String groupMembershipBodyCreate = groupMembershipBody.toString(); - //MembershipCreation: - //-ve - restClient.authenticateUser(userModel).withCoreAPI().usingGroups().createGroupMembership("GROUP_"+groupName, groupMembershipBodyCreate); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - //+ve - restClient.authenticateUser(adminUser).withCoreAPI().usingGroups().createGroupMembership("GROUP_"+groupName, groupMembershipBodyCreate); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - //ListPersonMembership - restClient.authenticateUser(userModel).withCoreAPI().usingUser(userModel).listGroupMemberships() - .assertThat().entriesListContains("id", "GROUP_"+groupName); - restClient.assertStatusCodeIs(HttpStatus.OK); - - //DeleteGroupMembership - //-ve - restClient.withCoreAPI().usingGroups().deleteGroupMembership("GROUP_"+groupName, userModel.getUsername()); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - //+ve - restClient.authenticateUser(adminUser).withCoreAPI().usingGroups().deleteGroupMembership("GROUP_"+groupName, userModel.getUsername()); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - //ListAgainPersonMembership - restClient.withCoreAPI().usingUser(userModel).listGroupMemberships() - .assertThat().entriesListDoesNotContain("id", "GROUP_"+groupName); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.GROUPS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.SANITY, - description = "Verify listing of group memberships.") - public void listGroupMembership() throws Exception - { - String groupName = "testGroup" + UUID.randomUUID().toString(); - JsonObject groupBody = Json.createObjectBuilder().add("id", groupName).add("displayName", groupName).build(); - String groupBodyCreate = groupBody.toString(); - - //GroupCreation: - restClient.authenticateUser(adminUser).withCoreAPI().usingParams("include=zones").usingGroups().createGroup(groupBodyCreate); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - JsonObject groupMembershipBody = Json.createObjectBuilder().add("id", userModel.getUsername()).add("memberType", "PERSON").build(); - String groupMembershipBodyCreate = groupMembershipBody.toString(); - - //MembershipCreation - restClient.withCoreAPI().usingGroups().createGroupMembership("GROUP_"+groupName, groupMembershipBodyCreate) - .assertThat().field("displayName").is(userModel.getUsername()) - .and().field("id").is(userModel.getUsername()) - .and().field("memberType").is("PERSON"); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - //ListGroupMembership - RetryOperation op = new RetryOperation(){ - public void execute() throws Exception{ - restClient.withCoreAPI().usingGroups().listGroupMemberships("GROUP_"+groupName) - .assertThat().entriesListContains("id", userModel.getUsername()); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - }; - Utility.sleep(1000, 35000, op);// Allow indexing to complete. - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/networks/RestGetNetworkForPersonTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/networks/RestGetNetworkForPersonTests.java deleted file mode 100644 index 1f0078dac..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/networks/RestGetNetworkForPersonTests.java +++ /dev/null @@ -1,151 +0,0 @@ -package org.alfresco.service.search.rest.networks; - -import java.util.ArrayList; - -import org.alfresco.service.search.rest.NetworkDataPrep; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestNetworkQuotaModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Tests for /people/{personId}/networks - */ -public class RestGetNetworkForPersonTests extends NetworkDataPrep -{ - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - init(); - } - - @Bug(id = "MNT-16904") - @TestRail(section = { TestGroup.REST_API, - TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, description = "Verify non existing user gets another existing network with Rest API and checks the forbidden status") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) - public void nonExistingTenantUserIsNotAuthorizedToRequest() throws Exception - { - UserModel tenantUser = new UserModel("nonexisting", "password"); - tenantUser.setDomain(adminTenantUser.getDomain()); - restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().getNetwork(adminTenantUser); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify tenant admin user gets specific network with Rest API and response is not empty") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) - public void adminTenantChecksIfNetworkIsPresent() throws Exception - { - restClient.authenticateUser(adminTenantUser).withCoreAPI().usingUser(adminTenantUser).getNetwork(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify tenant user gets specific network with Rest API and response is not empty") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) - public void tenantUserChecksIfNetworkIsPresent() throws Exception - { - restClient.authenticateUser(tenantUser).withCoreAPI().usingUser(tenantUser).getNetwork(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Bug(id = "needs to be checked") - @TestRail(section = { TestGroup.REST_API, - TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, description = "Verify tenant user check network of admin user with Rest API") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) - public void tenantUserIsNotAuthorizedToCheckNetworkOfAdminUser() throws Exception - { - restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().getNetwork(adminTenantUser); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Bug(id = "needs to be checked") - @TestRail(section = { TestGroup.REST_API, - TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, description = "Verify getNetwork request status code is 200 if a user tries to get network information of another user") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) - public void verifyGetNetworkByAUserForAnotherUser() throws Exception - { - UserModel randomTestUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("randomTestUser"); - restNetworkModel = restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().getNetwork(randomTestUser); - restClient.assertStatusCodeIs(HttpStatus.OK); - restNetworkModel.assertThat().field("id").is(tenantUser.getDomain()); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, description = "Verify that getNetwork status code is 404 for a personId that does not exist") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) - public void verifyThatGetNetworkStatusIs404ForAPersonIdThatDoesNotExist() throws Exception - { - UserModel invalidUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("validUsername"); - invalidUser.setUsername("invalidUsername"); - - restClient.authenticateUser(adminTenantUser).withCoreAPI().usingUser(invalidUser).getNetwork(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, invalidUser.getUsername())).descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, description = "Verify that getNetwork status code is 404 for a networkId that does not exist") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) - public void verifyThatGetNetworkStatusIs404ForANetworkIdThatDoesNotExist() throws Exception - { - UserModel invalidUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("invalidNetworkId"); - invalidUser.setDomain("invalidNetworkId"); - - restClient.authenticateUser(adminTenantUser).withCoreAPI().usingUser(invalidUser).getNetwork(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, invalidUser.getUsername())).descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, description = "Verify getNetwork request that is made using -me- instead of personId") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) - public void verifyGetNetworkRequestUsingMeInsteadOfPersonId() throws Exception - { - restNetworkModel = restClient.authenticateUser(adminTenantUser).withCoreAPI().usingMe().getNetwork(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restNetworkModel.assertThat().field("quotas").is(new ArrayList()).assertThat().field("isEnabled").is("true").assertThat() - .field("homeNetwork").is("true").assertThat().field("id").is(adminTenantUser.getDomain().toLowerCase()); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, description = "Verify that properties parameter is applied to getNetwork request") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) - public void verifyPropertiesParameterIsAppliedToGetNetworkRequest() throws Exception - { - restNetworkModel = restClient.authenticateUser(adminTenantUser).withParams("properties=id,isEnabled,homeNetwork,paidNetwork").withCoreAPI().usingMe() - .getNetwork(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restNetworkModel.assertThat().field("id").is(adminTenantUser.getDomain().toLowerCase()).assertThat().field("isEnabled").is("true").assertThat() - .field("homeNetwork").is("true").assertThat().field("paidNetwork").is("false").assertThat().field("quotas").isNull(); - restNetworkModel.assertThat().fieldsCount().is(4); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, description = "Verify getNetwork request status code is 404 for a network to which user does not belong") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) - public void verifyGetNetworkRequestStatusCodeIs404ForANetworkToWhichTheUserDoesNotBelong() throws Exception - { - restClient.authenticateUser(adminTenantUser).withCoreAPI().usingAuthUser().getNetwork(secondAdminTenantUser); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, description = "Verify admin tenant user is not authorized to check network of another user with Rest API and checks the forbidden status") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) - public void adminTenantUserIsNotAuthorizedToCheckNetworkOfAnotherUser() throws Exception - { - UserModel secondTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("anotherTenant"); - restClient.authenticateUser(secondAdminTenantUser).withCoreAPI().usingAuthUser().getNetwork(secondTenantUser); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/networks/RestGetNetworkTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/networks/RestGetNetworkTests.java deleted file mode 100644 index 8bc917e1e..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/networks/RestGetNetworkTests.java +++ /dev/null @@ -1,145 +0,0 @@ -package org.alfresco.service.search.rest.networks; - -import org.alfresco.service.search.rest.NetworkDataPrep; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestNetworkModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.json.JSONException; -import org.json.JSONObject; -import org.springframework.http.HttpStatus; -import org.testng.Assert; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Created by Cristina Axinte on 9/26/2016. - */ -public class RestGetNetworkTests extends NetworkDataPrep -{ - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - init(); - } - - @Bug(id = "MNT-16904") - @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, - description = "Verify non existing user gets another exisiting network with Rest API and checks the forbidden status") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY}) - public void nonExistingTenantUserIsNotAuthorizedToRequest() throws Exception - { - UserModel tenantUser = new UserModel("nonexisting", "password"); - tenantUser.setDomain(adminTenantUser.getDomain()); - restClient.authenticateUser(tenantUser); - restClient.withCoreAPI().usingNetworks().getNetwork(adminTenantUser); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, - description = "Verify tenant admin user gets specific network with Rest API and response is not empty") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) - public void adminTenantChecksIfNetworkIsPresent() throws Exception - { - restClient.authenticateUser(adminTenantUser); - restClient.withCoreAPI().usingNetworks().getNetwork().assertNetworkHasName(adminTenantUser).assertNetworkIsEnabled(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Verify tenant admin user gets another existing network with Rest API and checks the forbidden status") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) - public void adminTenantChecksIfAnotherExistingNetworkIsForbidden() throws Exception - { - restClient.authenticateUser(adminTenantUser); - restClient.withCoreAPI().usingNetworks().getNetwork(secondAdminTenantUser); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, - description = "Verify any tenant user gets its network with Rest API and response is not empty") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) - public void userTenantChecksIfNetworkIsPresent() throws Exception - { - restClient.authenticateUser(tenantUser); - restClient.withCoreAPI().usingNetworks().getNetwork(adminTenantUser).assertNetworkHasName(adminTenantUser).assertNetworkIsEnabled(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Verify any tenant user gets non existing network with Rest API and checks the not found status") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) - public void userTenantChecksIfNonExistingNetworkIsNotFound() throws Exception - { - restClient.authenticateUser(tenantUser); - restClient.withCoreAPI().usingNetworks().getNetwork(UserModel.getRandomTenantUser()); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Verify any tenant user gets another existing network with Rest API and checks the forbidden status") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) - public void userTenantChecksIfAnotherExistingNetworkIsForbidden() throws Exception - { - restClient.authenticateUser(tenantUser); - restClient.withCoreAPI().usingNetworks().getNetwork(secondAdminTenantUser); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - } - - @Bug(id = "ACE-5738") - @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Verify tenant admin user gets an invalid network with Rest API and checks the not found status") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) - public void adminTenantGetsInvalidNetwork() throws Exception - { - restClient.authenticateUser(secondAdminTenantUser); - secondAdminTenantUser.setDomain("tenant.@%"); - - restClient.withCoreAPI().usingNetworks().getNetwork(secondAdminTenantUser); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.UNEXPECTED_TENANT, adminTenantUser.getDomain(), "@")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Bug(id = "ACE-5745") - @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Verify admin user gets an existing network successfully with Rest API") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) - public void adminUserGetsExistingNetwork() throws Exception - { - RestNetworkModel restNetworkModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingNetworks().getNetwork(adminTenantUser); - restClient.assertStatusCodeIs(HttpStatus.OK); - restNetworkModel.assertThat().fieldsCount().is("1"); - restNetworkModel.assertThat().field("id").is(adminTenantUser.getDomain()) - .and().field("homeNetwork").isNull() - .and().field("isEnabled").is("true"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Verify tenant admin user gets network using properties parameter successfully with Rest API") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) - public void adminTenantGetsNetworkUsingPropertiesParameter() throws Exception - { - JSONObject entryResponse= restClient.authenticateUser(tenantUser).withCoreAPI().usingNetworks().usingParams("properties=id").getNetworkWithParams(adminTenantUser); - restClient.assertStatusCodeIs(HttpStatus.OK); - Assert.assertTrue(entryResponse.get("id").equals(adminTenantUser.getDomain().toLowerCase())); - assertJsonResponseDoesnotContainField(entryResponse, "homeNetwork"); - assertJsonResponseDoesnotContainField(entryResponse, "isEnabled"); - } - - private void assertJsonResponseDoesnotContainField(JSONObject entryResponse, String field) - { - try{ - entryResponse.get(field); - } - catch(JSONException ex) - { - Assert.assertTrue(ex.getMessage().equals(String.format("JSONObject[\"%s\"] not found.", field))); - } - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/networks/RestGetNetworksForPersonTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/networks/RestGetNetworksForPersonTests.java deleted file mode 100644 index db118a56d..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/networks/RestGetNetworksForPersonTests.java +++ /dev/null @@ -1,166 +0,0 @@ -package org.alfresco.service.search.rest.networks; - -import org.alfresco.service.search.rest.NetworkDataPrep; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestNetworkModelsCollection; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class RestGetNetworksForPersonTests extends NetworkDataPrep -{ - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - init(); - } - - @Bug(id = "MNT-16904") - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, - description = "Verify non existing user gets another exisiting network with Rest API and checks the unauthorized status") - @Test(groups = { TestGroup.REST_API, TestGroup.SANITY, TestGroup.NETWORKS }) - public void nonExistingTenantUserIsNotAuthorizedToRequest() throws Exception - { - UserModel tenantUser = new UserModel("nonexisting", "password"); - tenantUser.setDomain(adminTenantUser.getDomain()); - restClient.authenticateUser(tenantUser); - restClient.withCoreAPI().usingAuthUser().getNetworks(adminTenantUser); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, - description = "Verify tenant admin user gets specific network with Rest API and response is not empty") - @Test(groups = {TestGroup.REST_API, TestGroup.SANITY, TestGroup.NETWORKS }) - public void adminTenantChecksIfNetworkIsPresent() throws Exception - { - RestNetworkModelsCollection networks = restClient.authenticateUser(adminTenantUser).withCoreAPI().usingAuthUser().getNetworks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - networks.getOneRandomEntry().onModel().assertNetworkIsEnabled() - .and().field("id").is(adminTenantUser.getDomain().toLowerCase()) - .and().field("quotas").is("[]") - .and().field("homeNetwork").is("false"); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, - description = "Verify tenant user gets specific network with Rest API and response is not empty") - @Test(groups = {TestGroup.REST_API, TestGroup.SANITY, TestGroup.NETWORKS }) - public void tenantUserChecksIfNetworkIsPresent() throws Exception - { - restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().getNetworks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Verify tenant user is not authorized to check network of admin user with Rest API and checks the forbidden status") - @Test(groups = {TestGroup.REST_API, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void tenantUserIsNotAuthorizedToCheckNetworkOfAdminUser() throws Exception - { - restClient.authenticateUser(tenantUser); - restClient.withCoreAPI().usingAuthUser().getNetworks(adminTenantUser); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Verify admin tenant user is not authorized to check network of another user with Rest API and checks the forbidden status") - @Test(groups = {TestGroup.REST_API, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void adminTenantUserIsNotAuthorizedToCheckNetworkOfAnotherUser() throws Exception - { - restClient.authenticateUser(secondAdminTenantUser); - restClient.withCoreAPI().usingAuthUser().getNetworks(secondTenantUser); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Get tenant user networks using invalid value for skipCount") - @Test(groups = {TestGroup.REST_API, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void invalidValueForSkipCountTest() throws Exception - { - restClient.authenticateUser(adminTenantUser).withParams("skipCount=abc").withCoreAPI().usingAuthUser().getNetworks(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "abc")); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Get tenant user networks using invalid value for maxItems") - @Test(groups = {TestGroup.REST_API, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void invalidValueForMaxItemsTest() throws Exception - { - restClient.authenticateUser(adminTenantUser).withParams("maxItems=abc").withCoreAPI().usingAuthUser().getNetworks(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "abc")); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Get tenant user networks using personId that does not exist") - @Test(groups = {TestGroup.REST_API, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void inexistentTenantTest() throws Exception - { - restClient.authenticateUser(adminTenantUser).withCoreAPI().usingUser(new UserModel("invalidTenantUser", "password")).getNetworks(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidTenantUser")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Get tenant user networks using -me- instead of personId") - @Test(groups = {TestGroup.REST_API, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void specifyMeInsteadOfPersonIdTest() throws Exception - { - RestNetworkModelsCollection networks = restClient.authenticateUser(adminTenantUser).withCoreAPI().usingMe().getNetworks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - networks.getOneRandomEntry().onModel().assertNetworkIsEnabled().and().field("id").is(adminTenantUser.getDomain().toLowerCase()); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Check default error schema for get networks for member") - @Test(groups = { TestGroup.REST_API, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void getNetworksAndCheckPropertiesParameter() throws Exception - { - RestNetworkModelsCollection networks = restClient.authenticateUser(adminTenantUser).withParams("properties=isEnabled,id").withCoreAPI().usingAuthUser().getNetworks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - networks.getOneRandomEntry().onModel().assertThat().field("homeNetwork").is("false") - .and().field("quotas").isNull() - .and().field("isEnabled").is("true") - .and().field("id").is(adminTenantUser.getDomain().toLowerCase()); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Check that skipCount parameter is applied") - @Test(groups = { TestGroup.REST_API, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void checkThatSkipCountParameterIsApplied() throws Exception - { - RestNetworkModelsCollection networks = restClient.authenticateUser(adminTenantUser).withParams("skipCount=1").withCoreAPI().usingAuthUser().getNetworks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - networks.assertThat().entriesListIsEmpty(); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Check that high skipCount parameter is applied") - @Test(groups = { TestGroup.REST_API, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void checkThatHighSkipCountParameterIsApplied() throws Exception - { - RestNetworkModelsCollection networks = restClient.authenticateUser(adminTenantUser).withParams("skipCount=100").withCoreAPI().usingAuthUser().getNetworks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - networks.assertThat().entriesListIsEmpty(); - networks.assertThat().paginationField("skipCount").is("100"); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Check that maxItems parameter is applied") - @Test(groups = { TestGroup.REST_API, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void checkThatMaxItemsParameterIsApplied() throws Exception - { - RestNetworkModelsCollection networks = restClient.authenticateUser(adminTenantUser).withParams("maxItems=1").withCoreAPI().usingAuthUser().getNetworks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - networks.getOneRandomEntry().onModel().assertThat().field("homeNetwork").is("false") - .and().field("quotas").is("[]") - .and().field("isEnabled").is("true") - .and().field("id").is(adminTenantUser.getDomain().toLowerCase()); - networks.assertThat().paginationField("maxItems").is("1"); - } -} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesActionDefinitionTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesActionDefinitionTests.java deleted file mode 100644 index a82c602a8..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesActionDefinitionTests.java +++ /dev/null @@ -1,87 +0,0 @@ -package org.alfresco.service.search.rest.nodes; - - -import static org.testng.Assert.assertFalse; - -import org.alfresco.service.search.rest.RestTest; - -import org.alfresco.rest.model.RestActionDefinitionModelsCollection; -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.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.Test; - -public class NodesActionDefinitionTests extends RestTest -{ - - - @TestRail(section = { TestGroup.REST_API,TestGroup.NODES }, executionType = ExecutionType.SANITY, - description = "Verify actions") - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY}) - public void testActionDefinition() throws Exception - { - restClient.authenticateUser(dataContent.getAdminUser()); - - /* - * Create the following file structure for preconditions : - * - sourceFolder - * - file - */ - NodesBuilder nodesBuilder = restClient.withCoreAPI().usingNode(ContentModel.my()).defineNodes(); - NodeDetail sourceFolder = nodesBuilder.folder("sourceFolder"); - NodeDetail file = sourceFolder.file("file"); - ContentModel fileActionDefinitions = new ContentModel(); - fileActionDefinitions.setNodeRef(file.getId()); - - RestActionDefinitionModelsCollection restActionDefinitions = restClient.withCoreAPI().usingNode(fileActionDefinitions).getActionDefinitions(); - restClient.assertStatusCodeIs(HttpStatus.OK); - assertFalse(restActionDefinitions.isEmpty()); - restActionDefinitions.assertThat().entriesListContains("name", "copy"); - restActionDefinitions.assertThat().entriesListContains("name", "move"); - restActionDefinitions.assertThat().entriesListContains("name", "check-out"); - restActionDefinitions.assertThat().entriesListContains("name", "check-in"); - - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NODES }, executionType = ExecutionType.REGRESSION, - description = "Verify actions negative request") - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION}) - public void testActionDefinitionNegative() throws Exception{ - - NodesBuilder nodesBuilder = restClient.withCoreAPI().usingNode(ContentModel.my()).defineNodes(); - NodeDetail sourceFolder = nodesBuilder.folder("sourceFolder"); - ContentModel validNode = new ContentModel(); - validNode.setNodeRef(sourceFolder.getId()); - - // Non-existent node ID - { - ContentModel fakeNode = new ContentModel(); - fakeNode.setNodeRef("750a2867-ecfa-478c-8343-fa0e39d27be3"); - restClient.authenticateUser(dataContent.getAdminUser()).withCoreAPI().usingNode(fakeNode).getActionDefinitions(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } - - // Badly formed request -> 400 - { - restClient.authenticateUser(dataContent.getAdminUser()).withParams("skipCount=-1").withCoreAPI().usingNode(validNode) - .getActionDefinitions(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - - } - - // Unauthorized -> 401 - { - - UserModel userUnauthorized = new UserModel("invalid-user", "invalid-pasword"); - restClient.authenticateUser(userUnauthorized).withCoreAPI().usingNode(validNode).getActionDefinitions(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); - - } - } - -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesContentAndVersioningTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesContentAndVersioningTests.java deleted file mode 100644 index 97dbfbc18..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesContentAndVersioningTests.java +++ /dev/null @@ -1,308 +0,0 @@ -package org.alfresco.service.search.rest.nodes; - -import static org.alfresco.utility.report.log.Step.STEP; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNotSame; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertSame; -import static org.testng.Assert.assertTrue; - -import java.io.File; -import java.io.IOException; -import java.io.RandomAccessFile; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.core.JsonBodyGenerator; -import org.alfresco.rest.core.RestResponse; -import org.alfresco.rest.model.RestNodeModel; -import org.alfresco.rest.model.RestVersionModel; -import org.alfresco.rest.model.RestVersionModelsCollection; -import org.alfresco.rest.model.body.RestNodeLockBodyModel; -import org.alfresco.util.TempFileProvider; -import org.alfresco.utility.Utility; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FileType; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.json.JSONObject; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * - * @author mpopa - * - */ -public class NodesContentAndVersioningTests extends RestTest -{ - private UserModel user1, user2; - private SiteModel site1, site2; - private FileModel file1, file2; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - user1 = dataUser.createRandomTestUser(); - user2 = dataUser.createRandomTestUser(); - site1 = dataSite.usingUser(user1).createPublicRandomSite(); - site2 = dataSite.usingUser(user2).createPublicRandomSite(); - file1 = dataContent.usingUser(user1).usingSite(site1).createContent(DocumentType.TEXT_PLAIN); - file2 = dataContent.usingUser(user2).usingSite(site2).createContent(DocumentType.TEXT_PLAIN); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.SANITY, description = "Verify file name in Content-Disposition header") - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY }) - public void checkFileNameWithRegularCharsInHeader() throws Exception - { - restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("attachment=false").getNodeContent(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restClient.assertHeaderValueContains("Content-Disposition", String.format("filename=\"%s\"", file1.getName())); - } - - - - - @Bug(id = "MNT-17545", description = "HTTP Header Injection in ContentStreamer", status = Bug.Status.FIXED) - @TestRail(section = { TestGroup.REST_API, - TestGroup.NODES }, executionType = ExecutionType.REGRESSION, description = "Verify file name with special chars is escaped in Content-Disposition header") - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) - public void checkFileNameWithSpecialCharsInHeader() throws Exception - { - char c1 = 127; - char c2 = 31; - char c3 = 256; - FileModel file = dataContent.usingUser(user2).usingSite(site2).createContent(new FileModel("\ntest" + c1 + c2 + c3, FileType.TEXT_PLAIN)); - restClient.authenticateUser(user2).withCoreAPI().usingNode(file).usingParams("attachment=false").getNodeContent(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restClient.assertHeaderValueContains("Content-Disposition", "filename=\" test .txt\""); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.NODES }, executionType = ExecutionType.SANITY, description = "Verify that alfresco returns the correct encoding for files created via REST.") - public void verifyFileEncodingUsingRestAPI() throws Exception - { - STEP("1. Create a folder, two text file templates and define the expected encoding."); - FileModel utf8File = new FileModel("utf8File", FileType.TEXT_PLAIN); - FileModel iso8859File = new FileModel("iso8859File", FileType.TEXT_PLAIN); - FolderModel folder = dataContent.usingUser(user1).usingSite(site1).createFolder(FolderModel.getRandomFolderModel()); - String utf8Type = "text/plain;charset=UTF-8"; - String iso8859Type = "text/plain;charset=ISO-8859-1"; - - STEP("2. Using multipart data upload (POST nodes/{nodeId}/children) the UTF-8 encoded file."); - restClient.authenticateUser(user1).configureRequestSpec().addMultiPart("filedata", Utility.getResourceTestDataFile("UTF-8File.txt")); - RestNodeModel fileNode = restClient.withCoreAPI().usingNode(folder).createNode(); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - utf8File.setNodeRef(fileNode.getId()); - - STEP("3. Using multipart data upload (POST nodes/{nodeId}/children) the ISO-8859-1 file."); - restClient.configureRequestSpec().addMultiPart("filedata", Utility.getResourceTestDataFile("iso8859File.txt")); - fileNode = restClient.withCoreAPI().usingNode(folder).createNode(); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - iso8859File.setNodeRef(fileNode.getId()); - - STEP("4. Retrieve the nodes and verify that the content type is the expected one (GET nodes/{nodeId})."); - restClient.withCoreAPI().usingNode(utf8File).getNodeContent().assertThat().contentType(utf8Type); - restClient.withCoreAPI().usingNode(iso8859File).getNodeContent().assertThat().contentType(iso8859Type); - } - - - // This test takes around 30 minutes to complete so it will be ignored by default - @Test(enabled=false, groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, - executionType = ExecutionType.REGRESSION, description = "Verify that the node content is streamed directly to the client and not buffered in memory.") - public void verifyUploadDownloadLargeFileUsingRestAPI() throws Exception - { - Integer largeFileSizeBytes = Integer.MAX_VALUE; - String largeFileName = "largeFile.tmp"; - String tempFolderPath = TempFileProvider.getTempDir().getAbsolutePath(); - - STEP("1. Create a folder and a large file"); - FolderModel folder = dataContent.usingUser(user1).usingSite(site1).createFolder(FolderModel.getRandomFolderModel()); - createRandomFileInDirectory(tempFolderPath, largeFileName, largeFileSizeBytes); - - STEP("2. Using multipart data upload for the large file (POST nodes/{nodeId}/children)."); - File largeFile = new File(tempFolderPath, largeFileName); - FileModel largeFileModel = new FileModel(largeFileName, FileType.UNDEFINED); - restClient.authenticateUser(user1).configureRequestSpec().addMultiPart("filedata", largeFile); - RestNodeModel fileNode = restClient.withCoreAPI().usingNode(folder).createNode(); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - largeFileModel.setNodeRef(fileNode.getId()); - - STEP("3. Retrieve the content of the node without running out of memory (GET nodes/{nodeId}/content)."); - RestResponse nodeContent = restClient.withCoreAPI().usingNode(largeFileModel).getNodeContent(); - restClient.assertStatusCodeIs(HttpStatus.OK); - assertEquals(Integer.valueOf(nodeContent.getResponse().getHeader("Content-Length")), largeFileSizeBytes); - - largeFile.delete(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.SANITY, description = "Verify updating a node content.") - public void testUpdateNodeContent() throws Exception - { - STEP("1. Retrieve the node in order to get data to compare after update GET /nodes/{nodeId}?include=path."); - RestNodeModel initialNode = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=path").getNode(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - STEP("2. Update the node content (different from the initial one) PUT /nodes/{nodeId}/content?majorVersion=true&name=newfile.txt."); - File updatedConentFile = Utility.getResourceTestDataFile("sampleContent.txt"); - RestNodeModel updatedBodyNode = restClient.withCoreAPI().usingNode(file1).usingParams("majorVersion=true&name=newfile.txt").updateNodeContent(updatedConentFile); - restClient.assertStatusCodeIs(HttpStatus.OK); - - STEP("3. Compare contentSize, modifiedAt, name and version, they should be different."); - assertNotSame(initialNode.getContent().getSizeInBytes(), updatedBodyNode.getContent().getSizeInBytes()); - assertNotSame(initialNode.getModifiedAt(), updatedBodyNode.getModifiedAt()); - assertNotSame(initialNode.getName(), updatedBodyNode.getName()); - - String initialNodeVersion = new JSONObject(initialNode.toJson()).getJSONObject("properties").getString("cm:versionLabel"); - String updatedBodyNodeVersion = new JSONObject(updatedBodyNode.toJson()).getJSONObject("properties").getString("cm:versionLabel"); - assertTrue(updatedBodyNodeVersion.charAt(0) > initialNodeVersion.charAt(0)); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.SANITY, description = "Test copy a node.") - public void testCopyNode() throws Exception - { - STEP("1. Create a lock and lock the node POST /nodes/{nodeId}/lock?include=path,isLocked."); - RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); - lockBodyModel.setLifetime("EPHEMERAL"); - lockBodyModel.setTimeToExpire(20); - lockBodyModel.setType("FULL"); - RestNodeModel initialNode = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=path,isLocked").lockNode(lockBodyModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - - STEP("2. With another user(that has access to the file), copy the node to another path POST /nodes/{nodeId}/copy?include=path,isLocked."); - String postBody = JsonBodyGenerator.keyValueJson("targetParentId", site2.getGuid()); - RestNodeModel copiedNode = restClient.authenticateUser(user2).withCoreAPI().usingNode(file1).usingParams("include=path,isLocked").copyNode(postBody); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - STEP("3. ParentId, createdAt, path and lock are different, but the nodes have the same contentSize."); - assertNotSame(copiedNode.getParentId(), initialNode.getParentId()); - assertNotSame(copiedNode.getCreatedAt(), initialNode.getCreatedAt()); - assertNotSame(copiedNode.getPath(), initialNode.getPath()); - assertTrue(initialNode.getIsLocked()); - assertSame(copiedNode.getContent().getSizeInBytes(), initialNode.getContent().getSizeInBytes()); - assertFalse(copiedNode.getIsLocked()); - - STEP("4. Unlock the node (this node may be used in the next tests)."); - initialNode = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").unlockNode(); - restClient.assertStatusCodeIs(HttpStatus.OK); - assertFalse(initialNode.getIsLocked()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.NODES }, executionType = ExecutionType.SANITY, description = "Test retrieving node versions, a specific version and version content.") - public void testGetVersionContent() throws Exception - { - file2 = dataContent.usingUser(user2).usingSite(site2).createContent(DocumentType.TEXT_PLAIN); - File sampleFile = Utility.getResourceTestDataFile("sampleContent.txt"); - - STEP("1. Update the node content in order to increase version(one minor and one major) PUT /nodes/{nodeId}/content."); - // minor version update - restClient.authenticateUser(user2).withCoreAPI().usingNode(file2).updateNodeContent(sampleFile); - restClient.assertStatusCodeIs(HttpStatus.OK); - // major version update - restClient.authenticateUser(user2).withCoreAPI().usingParams("majorVersion=true").usingNode(file2).updateNodeContent(sampleFile); - restClient.assertStatusCodeIs(HttpStatus.OK); - - STEP("2. List node version history GET /nodes/{nodeId}/versions. And verify that first (in the list) version is 2.0 and last is 1.0."); - RestVersionModelsCollection versionListing = restClient.withCoreAPI().usingNode(file2).listVersionHistory(); - restClient.assertStatusCodeIs(HttpStatus.OK); - // additional check that the properties are not displayed by default. - assertEquals(versionListing.getEntries().get(versionListing.getPagination().getCount() - 1).onModel().getId(), "1.0"); - assertEquals(versionListing.getEntries().get(0).onModel().getId(), "2.0"); - assertNull(versionListing.getEntries().get(0).onModel().getProperties()); - - STEP("3. List node version using skipCount(1),maxItems(1) and include(properties) GET /nodes/{nodeId}/versions?include=properties&skipCount=1&maxItems=1"); - versionListing = restClient.withCoreAPI().usingParams("include=properties&skipCount=1&maxItems=1").usingNode(file2).listVersionHistory(); - restClient.assertStatusCodeIs(HttpStatus.OK); - // we expect only version 1.1 to be retrieved with the value for properties. - RestVersionModel version = versionListing.getEntries().get(0).onModel(); - assertNotNull(version.getProperties()); - assertEquals(version.getId(), "1.1"); - assertEquals(versionListing.getPagination().getMaxItems(), 1); - assertEquals(versionListing.getPagination().getSkipCount(), 1); - assertEquals(versionListing.getPagination().getCount(), 1); - - STEP("4. Get version information for version 1.1 GET /nodes/{nodeId}/versions/{versionId} ."); - RestVersionModel version11 = restClient.withCoreAPI().usingNode(file2).getVersionInformation("1.1"); - restClient.assertStatusCodeIs(HttpStatus.OK); - // aspectNames and properties are displayed by default. We compare - // id,contentSize and name with the values from v1.1, taken from listing all - // versions. - assertNotNull(version11.getAspectNames()); - assertNotNull(version11.getProperties()); - assertEquals(version.getId(), version11.getId()); - assertEquals(version.getContent().getSizeInBytes(), version11.getContent().getSizeInBytes()); - assertEquals(version.getName(), version11.getName()); - - STEP("5. Retrieve version 2.0 content GET /nodes/{nodeId}/versions/{versionId}/content"); - // verify the content is the same as the uploaded file and check in headers for - // Content-Disposition to validate the download as attachment and fileName. - // wait for content to be picked up on AWS QS stacks - Utility.sleep(1000, 60000, () -> { - RestResponse versionContent = restClient.withCoreAPI().usingNode(file2).getVersionContent("2.0"); - restClient.assertStatusCodeIs(HttpStatus.OK); - - assertEquals("Sample text.\n", versionContent.getResponse().body().asString()); - restClient.assertHeaderValueContains("Content-Disposition", "attachment"); - restClient.assertHeaderValueContains("Content-Disposition", String.format("filename=\"%s\"", file2.getName())); - }); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.SANITY, description = "Test revert and delete a node version.") - public void testRevertDeleteVersion() throws Exception - { - STEP("1. Revert to version 1.0 POST /nodes/{nodeId}/versions/{versionId}/revert"); - RestVersionModel version = restClient.authenticateUser(user2).withCoreAPI().usingNode(file2).revertVersion("1.0", new String("{}")); - restClient.assertStatusCodeIs(HttpStatus.OK); - String nodeVersionType = new JSONObject(version.toJson()).getJSONObject("properties").getString("cm:versionType"); - assertEquals(nodeVersionType, "MINOR"); - String nodeVersion = version.getId(); - - STEP("2. Revert to last minor version /nodes/{nodeId}/versions/{versionId}/revert"); - version = restClient.withCoreAPI().usingNode(file2).revertVersion(nodeVersion, new String("{\"majorVersion\": true}")); - restClient.assertStatusCodeIs(HttpStatus.OK); - nodeVersionType = new JSONObject(version.toJson()).getJSONObject("properties").getString("cm:versionType"); - assertEquals(nodeVersionType, "MAJOR"); - assertTrue(nodeVersion.charAt(0) + 1 == version.getId().charAt(0)); - - STEP("3. Delete last MINOR version DELETE /nodes/{nodeId}/versions/{versionId}"); - restClient.withCoreAPI().usingNode(file2).deleteNodeVersion(nodeVersion); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingNode(file2).getVersionInformation(nodeVersion); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.SANITY, description = "Verify file name in Content Range header") - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY }) - public void checkFileNameContentRangeHeader() throws Exception - { - restClient.configureRequestSpec().addHeader("content-range", "bytes=1-10"); - restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).getNodeContent(); - restClient.assertStatusCodeIs(HttpStatus.PARTIAL_CONTENT); - restClient.assertHeaderValueContains("content-range", "bytes 1-10"); - restClient.assertHeaderValueContains("content-length", String.valueOf(10)); - } - - - private void createRandomFileInDirectory(String path, String fileName, int size) throws IOException { - String fullPath = new File(path, fileName).getPath(); - - RandomAccessFile file = new RandomAccessFile(fullPath,"rw"); - file.setLength(size); - file.close(); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesLockTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesLockTests.java deleted file mode 100644 index dc05c3602..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesLockTests.java +++ /dev/null @@ -1,761 +0,0 @@ -package org.alfresco.service.search.rest.nodes; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestNodeModel; -import org.alfresco.rest.model.body.RestNodeLockBodyModel; -import org.alfresco.rest.search.RestRequestFilterQueryModel; -import org.alfresco.rest.search.RestRequestQueryModel; -import org.alfresco.rest.search.SearchRequest; -import org.alfresco.rest.search.SearchResponse; -import org.alfresco.utility.Utility; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.report.Bug.Status; -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; - -import static org.alfresco.utility.report.log.Step.STEP; - -public class NodesLockTests extends RestTest -{ - private UserModel user1, user2, adminUser; - private SiteModel publicSite; - private FileModel file1; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - publicSite = dataSite.usingUser(adminUser).createPublicRandomSite(); - user1 = dataUser.createRandomTestUser(); - user2 = dataUser.createRandomTestUser(); - dataUser.addUserToSite(user1, publicSite, UserRole.SiteCollaborator); - user1.setUserRole(UserRole.SiteCollaborator); - dataUser.addUserToSite(user2, publicSite, UserRole.SiteCollaborator); - user2.setUserRole(UserRole.SiteCollaborator); - - } - - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, - description = "Verify Collaborator can not lock PERSISTENT after EPHEMERAL lock made by different user") - public void lockEphemeralAndRelockPersistentDifferentUser() throws Exception - { - STEP("1. Administrator adds a file in the site."); - file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); - - STEP("2. Verify with admin that the file is not locked."); - RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model1.assertThat().field("isLocked").is(false); - - STEP("3. Lock the file using mode EPHEMERAL for 20 seconds with user1 (POST nodes/{nodeId}/lock)."); - RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); - lockBodyModel.setLifetime("EPHEMERAL"); - lockBodyModel.setTimeToExpire(20); - lockBodyModel.setType("FULL"); - restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").lockNode(lockBodyModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - - STEP("4. Verify with user1 that the file is locked."); - RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model2.assertThat().field("isLocked").is(true) - .assertThat().field("properties").contains("lockLifetime=EPHEMERAL") - .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); - - STEP("5. Cannot lock the file using mode PERSISTENT with user2 while the file is still locked"); - RestNodeLockBodyModel lockBodyModel2 = new RestNodeLockBodyModel(); - lockBodyModel2.setLifetime("PERSISTENT"); - lockBodyModel2.setTimeToExpire(20); - lockBodyModel2.setType("ALLOW_OWNER_CHANGES"); - restClient.authenticateUser(user2).withCoreAPI().usingNode(file1).usingParams("include=isLocked").lockNode(lockBodyModel2); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() - .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .containsSummary(String.format(RestErrorModel.LOCKED_NODE_SUMMARY, file1.getNodeRefWithoutVersion())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, - description = "Verify Collaborator can not lock EPHEMERAL after EPHEMERAL lock made by different user") - public void lockEphemeralAndRelockEphemeralDifferentUser() throws Exception - { - STEP("1. Adds a file in the site by administrator."); - file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); - - STEP("2. Verify with admin that the file is not locked."); - RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model1.assertThat().field("isLocked").is(false); - - STEP("3. Lock the file using mode EPHEMERAL with user1 (POST nodes/{nodeId}/lock)."); - RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); - lockBodyModel.setLifetime("EPHEMERAL"); - lockBodyModel.setTimeToExpire(20); - lockBodyModel.setType("FULL"); - restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - - STEP("4. Verify with user1 that the file is locked."); - RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model2.assertThat().field("isLocked").is(true) - .assertThat().field("properties").contains("lockLifetime=EPHEMERAL") - .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); - - STEP("5. Cannot lock the file using mode EPHEMERAL with user2 while the file is still locked"); - RestNodeLockBodyModel lockBodyModel2 = new RestNodeLockBodyModel(); - lockBodyModel2.setLifetime("EPHEMERAL"); - lockBodyModel2.setTimeToExpire(20); - lockBodyModel2.setType("FULL"); - restClient.authenticateUser(user2).withCoreAPI().usingNode(file1).usingParams("include=isLocked").lockNode(lockBodyModel2); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() - .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .containsSummary(String.format(RestErrorModel.LOCKED_NODE_SUMMARY, file1.getNodeRefWithoutVersion())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, - description = "Verify Collaborator can lock EPHEMERAL after EPHEMERAL lock made by same user") - public void lockEphemeralAndRelockEphemeralSameUser() throws Exception - { - STEP("1. Adds a file in the site by administrator."); - file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); - - STEP("2. Verify with admin that the file is not locked."); - RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model1.assertThat().field("isLocked").is(false); - - STEP("3. Lock the file using mode EPHEMERAL with user1 (POST nodes/{nodeId}/lock)."); - RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); - lockBodyModel.setLifetime("EPHEMERAL"); - lockBodyModel.setTimeToExpire(20); - lockBodyModel.setType("FULL"); - restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - - STEP("4. Verify with user1 that the file is locked."); - RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model2.assertThat().field("isLocked").is(true) - .assertThat().field("properties").contains("lockLifetime=EPHEMERAL") - .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); - - STEP("5. Lock the file using mode EPHEMERAL with user1 while the file is still locked"); - RestNodeLockBodyModel lockBodyModel2 = new RestNodeLockBodyModel(); - lockBodyModel2.setLifetime("EPHEMERAL"); - lockBodyModel2.setTimeToExpire(20); - lockBodyModel2.setType("FULL"); - RestNodeModel file1Model3 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").lockNode(lockBodyModel2); - restClient.assertStatusCodeIs(HttpStatus.OK); - file1Model3.assertThat().field("isLocked").is(true) - .assertThat().field("properties").contains("lockLifetime=EPHEMERAL") - .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); - } - - @Bug(id = "MNT-17612", status = Status.FIXED, description = "AccessDeniedException in AOS Edit Offline Upload New Version") - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, - description = "Verify Collaborator can lock PERSISTENT after EPHEMERAL lock made by same user") - public void lockEphemeralAndRelockPersistentSameUser() throws Exception - { - STEP("1. Adds a file in the site by administrator."); - file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); - - STEP("2. Verify with admin that the file is not locked."); - RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model1.assertThat().field("isLocked").is(false); - - STEP("3. Lock the file using mode EPHEMERAL with user1 (POST nodes/{nodeId}/lock)."); - RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); - lockBodyModel.setLifetime("EPHEMERAL"); - lockBodyModel.setTimeToExpire(2); - lockBodyModel.setType("FULL"); - restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - - STEP("4. Verify with user1 that the file is locked."); - RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model2.assertThat().field("isLocked").is(true) - .assertThat().field("properties").contains("lockLifetime=EPHEMERAL") - .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); - - STEP("5. Lock the file using mode PERSISTENT with user1 while the file is still locked"); - RestNodeLockBodyModel lockBodyModel2 = new RestNodeLockBodyModel(); - lockBodyModel2.setLifetime("PERSISTENT"); - lockBodyModel2.setTimeToExpire(20); - lockBodyModel2.setType("ALLOW_OWNER_CHANGES"); - RestNodeModel file1Model3 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").lockNode(lockBodyModel2); - restClient.assertStatusCodeIs(HttpStatus.OK); - file1Model3.assertThat().field("isLocked").is(true) - .assertThat().field("properties").contains("lockLifetime=EPHEMERAL") - .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); - - STEP("6. Verify that the file is locked PERSISTENT only after EPHEMERAL lock has expired"); - try{Thread.sleep(2500);}finally{} - RestNodeModel file1Model4 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model4.assertThat().field("isLocked").is(true) - .assertThat().field("properties").contains("lockLifetime=PERSISTENT") - .assertThat().field("properties").contains("lockType=WRITE_LOCK"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, - description = "Verify Collaborator can not lock EPHEMERAL after PERSISTENT lock made by different user") - public void lockPersistentAndRelockEphemeralDifferentUser() throws Exception - { - STEP("1. Adds a file in the site by administrator."); - file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); - - STEP("2. Verify with admin that the file is not locked."); - RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model1.assertThat().field("isLocked").is(false); - - STEP("3. Lock the file using mode PERSISTENT with user1 (POST nodes/{nodeId}/lock)."); - RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); - lockBodyModel.setLifetime("PERSISTENT"); - lockBodyModel.setTimeToExpire(20); - lockBodyModel.setType("ALLOW_OWNER_CHANGES"); - restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - - STEP("4. Verify with user1 that the file is locked."); - RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model2.assertThat().field("isLocked").is(true) - .assertThat().field("properties").contains("lockLifetime=PERSISTENT") - .assertThat().field("properties").contains("lockType=WRITE_LOCK"); - - STEP("5. Cannot lock the file using mode EPHEMERAL with user2 while the file is still locked"); - RestNodeLockBodyModel lockBodyModel2 = new RestNodeLockBodyModel(); - lockBodyModel2.setLifetime("EPHEMERAL"); - lockBodyModel2.setTimeToExpire(20); - lockBodyModel2.setType("FULL"); - restClient.authenticateUser(user2).withCoreAPI().usingNode(file1).usingParams("include=isLocked").lockNode(lockBodyModel2); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() - .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .containsSummary(String.format(RestErrorModel.LOCKED_NODE_SUMMARY, file1.getNodeRefWithoutVersion())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, - description = "Verify Collaborator can not lock PERSISTENT after PERSISTENT lock made by different user") - public void lockPersistentAndRelockPersistentDifferentUser() throws Exception - { - STEP("1. Adds a file in the site by administrator."); - file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); - - STEP("2. Verify with admin that the file is not locked."); - RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model1.assertThat().field("isLocked").is(false); - - STEP("3. Lock the file using mode PERSISTENT with user1 (POST nodes/{nodeId}/lock)."); - RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); - lockBodyModel.setLifetime("PERSISTENT"); - lockBodyModel.setTimeToExpire(20); - lockBodyModel.setType("ALLOW_OWNER_CHANGES"); - restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - - STEP("4. Verify with user1 that the file is locked."); - RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model2.assertThat().field("isLocked").is(true) - .assertThat().field("properties").contains("lockLifetime=PERSISTENT") - .assertThat().field("properties").contains("lockType=WRITE_LOCK"); - - STEP("5. Cannot lock the file using mode PERSISTENT with user2 while the file is still locked"); - RestNodeLockBodyModel lockBodyModel2 = new RestNodeLockBodyModel(); - lockBodyModel2.setLifetime("PERSISTENT"); - lockBodyModel2.setTimeToExpire(20); - lockBodyModel2.setType("ALLOW_OWNER_CHANGES"); - restClient.authenticateUser(user2).withCoreAPI().usingNode(file1).usingParams("include=isLocked").lockNode(lockBodyModel2); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() - .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .containsSummary(String.format(RestErrorModel.LOCKED_NODE_SUMMARY, file1.getNodeRefWithoutVersion())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, - description = "Verify Collaborator can lock EPHEMERAL after PERSISTENT lock made by different user is expired") - public void lockPersistentAndRelockEphemeralAfterExpiredLockDifferentUser() throws Exception - { - STEP("1. Adds a file in the site by administrator."); - file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); - - STEP("2. Verify with admin that the file is not locked."); - RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model1.assertThat().field("isLocked").is(false); - - STEP("3. Lock the file using mode PERSISTENT with user1 (POST nodes/{nodeId}/lock)."); - RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); - lockBodyModel.setLifetime("PERSISTENT"); - lockBodyModel.setTimeToExpire(1); - lockBodyModel.setType("ALLOW_OWNER_CHANGES"); - restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - - STEP("4. Verify with admin that the file is locked."); - RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model2.assertThat().field("isLocked").is(true) - .assertThat().field("properties").contains("lockLifetime=PERSISTENT") - .assertThat().field("properties").contains("lockType=WRITE_LOCK"); - - STEP("5. Lock the file using mode EPHEMERAL with user2 while the first lock has expired"); - RestNodeLockBodyModel lockBodyModel2 = new RestNodeLockBodyModel(); - lockBodyModel2.setLifetime("EPHEMERAL"); - lockBodyModel2.setTimeToExpire(20); - lockBodyModel2.setType("FULL"); - try{Thread.sleep(1500);}finally{} - RestNodeModel file1Model3 = restClient.authenticateUser(user2).withCoreAPI().usingNode(file1).usingParams("include=isLocked").lockNode(lockBodyModel2); - restClient.assertStatusCodeIs(HttpStatus.OK); - file1Model3.assertThat().field("isLocked").is(true) - .assertThat().field("properties").contains("lockLifetime=EPHEMERAL") - .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); - } - - @Bug(id = "MNT-17612", status = Status.FIXED, description = "AccessDeniedException in AOS Edit Offline Upload New Version") - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, - description = "Verify Collaborator can lock PERSISTENT after EPHEMERAL lock made by another user is expired") - public void lockEphemeralAndRelockPersistentAfterExpiredLockDifferentUser() throws Exception - { - STEP("1. Adds a file in the site by administrator."); - file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); - - STEP("2. Verify with admin that the file is not locked."); - RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model1.assertThat().field("isLocked").is(false); - - STEP("3. Lock the file using mode EPHEMERAL with user1 (POST nodes/{nodeId}/lock)."); - RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); - lockBodyModel.setLifetime("EPHEMERAL"); - lockBodyModel.setTimeToExpire(1); - lockBodyModel.setType("FULL"); - restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - - STEP("4. Verify with user1 that the file is locked."); - RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model2.assertThat().field("isLocked").is(true) - .assertThat().field("properties").contains("lockLifetime=EPHEMERAL") - .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); - - STEP("5. Lock the file using mode PERSISTENT with user2 after the first lock has expired"); - RestNodeLockBodyModel lockBodyModel2 = new RestNodeLockBodyModel(); - lockBodyModel2.setLifetime("PERSISTENT"); - lockBodyModel2.setTimeToExpire(20); - lockBodyModel2.setType("ALLOW_OWNER_CHANGES"); - try{Thread.sleep(1500);}finally{} - RestNodeModel file1Model3 = restClient.authenticateUser(user2).withCoreAPI().usingNode(file1).usingParams("include=isLocked").lockNode(lockBodyModel2); - restClient.assertStatusCodeIs(HttpStatus.OK); - file1Model3.assertThat().field("isLocked").is(true) - .assertThat().field("properties").contains("lockLifetime=PERSISTENT") - .assertThat().field("properties").contains("lockType=WRITE_LOCK"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, - description = "Verify Collaborator can lock EPHEMERAL after EPHEMERAL lock made by another user is expired") - public void lockEphemeralAndRelockEphemeralAfterExpiredLockDifferentUser() throws Exception - { - STEP("1. Adds a file in the site by administrator."); - file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); - - STEP("2. Verify with admin that the file is not locked."); - RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model1.assertThat().field("isLocked").is(false); - - STEP("3. Lock the file using mode EPHEMERAL with user1 (POST nodes/{nodeId}/lock)."); - RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); - lockBodyModel.setLifetime("EPHEMERAL"); - lockBodyModel.setTimeToExpire(1); - lockBodyModel.setType("FULL"); - restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - - STEP("4. Verify with user1 that the file is locked."); - RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model2.assertThat().field("isLocked").is(true) - .assertThat().field("properties").contains("lockLifetime=EPHEMERAL") - .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); - - STEP("5. Lock the file using mode EPHEMERAL with user2 while the first lock has expired"); - RestNodeLockBodyModel lockBodyModel2 = new RestNodeLockBodyModel(); - lockBodyModel2.setLifetime("EPHEMERAL"); - lockBodyModel2.setTimeToExpire(20); - lockBodyModel2.setType("FULL"); - try{Thread.sleep(1500);}finally{} - RestNodeModel file1Model3 = restClient.authenticateUser(user2).withCoreAPI().usingNode(file1).usingParams("include=isLocked").lockNode(lockBodyModel2); - restClient.assertStatusCodeIs(HttpStatus.OK); - file1Model3.assertThat().field("isLocked").is(true) - .assertThat().field("properties").contains("lockLifetime=EPHEMERAL") - .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, - description = "Verify Collaborator can lock PERSISTENT after PERSISTENT lock made by different user is expired") - public void lockPersistentAndRelockPersistentAfterExpiredLockDifferentUser() throws Exception - { - STEP("1. Adds a file in the site by administrator."); - file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); - - STEP("2. Verify with admin that the file is not locked."); - RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model1.assertThat().field("isLocked").is(false); - - STEP("3. Lock the file using mode PERSISTENT with user1 (POST nodes/{nodeId}/lock)."); - RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); - lockBodyModel.setLifetime("PERSISTENT"); - lockBodyModel.setTimeToExpire(1); - lockBodyModel.setType("ALLOW_OWNER_CHANGES"); - restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - - STEP("4. Verify with admin that the file is locked."); - RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model2.assertThat().field("isLocked").is(true) - .assertThat().field("properties").contains("lockLifetime=PERSISTENT") - .assertThat().field("properties").contains("lockType=WRITE_LOCK"); - - STEP("5. Lock the file using mode PERSISTENT with user2 after the first lock has expired"); - RestNodeLockBodyModel lockBodyModel2 = new RestNodeLockBodyModel(); - lockBodyModel2.setLifetime("PERSISTENT"); - lockBodyModel2.setTimeToExpire(20); - lockBodyModel2.setType("ALLOW_OWNER_CHANGES"); - try{Thread.sleep(1500);}finally{} - RestNodeModel file1Model3 = restClient.authenticateUser(user2).withCoreAPI().usingNode(file1).usingParams("include=isLocked").lockNode(lockBodyModel2); - restClient.assertStatusCodeIs(HttpStatus.OK); - file1Model3.assertThat().field("isLocked").is(true) - .assertThat().field("properties").contains("lockLifetime=PERSISTENT") - .assertThat().field("properties").contains("lockType=WRITE_LOCK"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, - description = "Verify Collaborator can lock EPHEMERAL after EPHEMERAL lock made by same user is expired") - public void lockEphemeralAndRelockEphemeralAfterExpiredLockSameUser() throws Exception - { - STEP("1. Adds a file in the site by administrator."); - file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); - - STEP("2. Verify with admin that the file is not locked."); - RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model1.assertThat().field("isLocked").is(false); - - STEP("3. Lock the file using mode EPHEMERAL with user1 (POST nodes/{nodeId}/lock)."); - RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); - lockBodyModel.setLifetime("EPHEMERAL"); - lockBodyModel.setTimeToExpire(1); - lockBodyModel.setType("FULL"); - restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - - STEP("4. Verify with user1 that the file is locked."); - RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model2.assertThat().field("isLocked").is(true) - .assertThat().field("properties").contains("lockLifetime=EPHEMERAL") - .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); - - STEP("5. Lock the file using mode EPHEMERAL with user1 after the first lock has expired"); - RestNodeLockBodyModel lockBodyModel2 = new RestNodeLockBodyModel(); - lockBodyModel2.setLifetime("EPHEMERAL"); - lockBodyModel2.setTimeToExpire(20); - lockBodyModel2.setType("FULL"); - try{Thread.sleep(1500);}finally{} - RestNodeModel file1Model3 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").lockNode(lockBodyModel2); - restClient.assertStatusCodeIs(HttpStatus.OK); - file1Model3.assertThat().field("isLocked").is(true) - .assertThat().field("properties").contains("lockLifetime=EPHEMERAL") - .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, - description = "Verify Collaborator can lock PERSISTENT after PERSISTENT lock made by same user is expired") - public void lockPersistentAndRelockPersistentAfterExpiredLockSameUser() throws Exception - { - STEP("1. Adds a file in the site by administrator."); - file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); - - STEP("2. Verify with admin that the file is not locked."); - RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model1.assertThat().field("isLocked").is(false); - - STEP("3. Lock the file using mode PERSISTENT with user1 (POST nodes/{nodeId}/lock)."); - RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); - lockBodyModel.setLifetime("PERSISTENT"); - lockBodyModel.setTimeToExpire(1); - lockBodyModel.setType("ALLOW_OWNER_CHANGES"); - restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - - STEP("4. Verify with user1 that the file is locked."); - RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model2.assertThat().field("isLocked").is(true); - file1Model2.assertThat().field("properties").contains("lockLifetime=PERSISTENT"); - - STEP("5. Lock the file using mode PERSISTENT with user1 while the first lock has expired"); - RestNodeLockBodyModel lockBodyModel2 = new RestNodeLockBodyModel(); - lockBodyModel2.setLifetime("PERSISTENT"); - lockBodyModel2.setTimeToExpire(20); - lockBodyModel2.setType("ALLOW_OWNER_CHANGES"); - try{Thread.sleep(1500);}finally{} - RestNodeModel file1Model3 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").lockNode(lockBodyModel2); - restClient.assertStatusCodeIs(HttpStatus.OK); - file1Model3.assertThat().field("isLocked").is(true) - .assertThat().field("properties").contains("lockLifetime=PERSISTENT") - .assertThat().field("properties").contains("lockType=WRITE_LOCK"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, - description = "Verify Collaborator can lock EPHEMERAL after PERSISTENT lock made by same user is expired") - public void lockPersistentAndRelockEphemeralAfterExpiredLockSameUser() throws Exception - { - STEP("1. Adds a file in the site by administrator."); - file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); - - STEP("2. Verify with admin that the file is not locked."); - RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model1.assertThat().field("isLocked").is(false); - - STEP("3. Lock the file using mode PERSISTENT with user1 (POST nodes/{nodeId}/lock)."); - RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); - lockBodyModel.setLifetime("PERSISTENT"); - lockBodyModel.setTimeToExpire(1); - lockBodyModel.setType("ALLOW_OWNER_CHANGES"); - restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - - STEP("4. Verify with admin that the file is locked."); - RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model2.assertThat().field("isLocked").is(true) - .assertThat().field("properties").contains("lockLifetime=PERSISTENT") - .assertThat().field("properties").contains("lockType=WRITE_LOCK"); - - STEP("5. Lock the file using mode EPHEMERAL with user1 while the first lock has expired"); - RestNodeLockBodyModel lockBodyModel2 = new RestNodeLockBodyModel(); - lockBodyModel2.setLifetime("EPHEMERAL"); - lockBodyModel2.setTimeToExpire(20); - lockBodyModel2.setType("FULL"); - try{Thread.sleep(1500);}finally{} - RestNodeModel file1Model3 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").lockNode(lockBodyModel2); - restClient.assertStatusCodeIs(HttpStatus.OK); - file1Model3.assertThat().field("isLocked").is(true) - .assertThat().field("properties").contains("lockLifetime=EPHEMERAL") - .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); - } - - @Bug(id = "MNT-17612", status = Status.FIXED, description = "AccessDeniedException in AOS Edit Offline Upload New Version") - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, - description = "Verify Collaborator can lock PERSISTENT after EPHEMERAL lock made by same user is expired") - public void lockEphemeralAndRelockPersistentAfterExpiredLockSameUser() throws Exception - { - STEP("1. Adds a file in the site by administrator."); - file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); - - STEP("2. Verify with admin that the file is not locked."); - RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1) - .usingParams("include=isLocked").getNode(); - file1Model1.assertThat().field("isLocked").is(false); - - STEP("3. Lock the file using mode EPHEMERAL with user1 (POST nodes/{nodeId}/lock)."); - RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); - lockBodyModel.setLifetime("EPHEMERAL"); - lockBodyModel.setTimeToExpire(1); - lockBodyModel.setType("FULL"); - restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - - STEP("4. Verify with useer1 that the file is locked."); - RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model2.assertThat().field("isLocked").is(true) - .assertThat().field("properties").contains("lockLifetime=EPHEMERAL") - .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); - - STEP("5. Lock the file using mode PERSISTENT with user1 while the first lock has expired"); - RestNodeLockBodyModel lockBodyModel2 = new RestNodeLockBodyModel(); - lockBodyModel2.setLifetime("PERSISTENT"); - lockBodyModel2.setTimeToExpire(20); - lockBodyModel2.setType("ALLOW_OWNER_CHANGES"); - try{Thread.sleep(1500);}finally{} - RestNodeModel file1Model3 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").lockNode(lockBodyModel2); - restClient.assertStatusCodeIs(HttpStatus.OK); - file1Model3.assertThat().field("isLocked").is(true) - .assertThat().field("properties").contains("lockLifetime=PERSISTENT") - .assertThat().field("properties").contains("lockType=WRITE_LOCK"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, - description = "Verify Collaborator can lock PERSISTENT after PERSISTENT lock made by same user") - public void lockPersistentAndRelockPersistentSameUser() throws Exception - { - STEP("1. Adds a file in the site by administrator."); - file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); - - STEP("2. Verify with admin that the file is not locked."); - RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model1.assertThat().field("isLocked").is(false); - - STEP("3. Lock the file using mode PERSISTENT with user1 (POST nodes/{nodeId}/lock)."); - RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); - lockBodyModel.setLifetime("PERSISTENT"); - lockBodyModel.setTimeToExpire(20); - lockBodyModel.setType("ALLOW_OWNER_CHANGES"); - restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - - STEP("4. Verify with user1 that the file is locked."); - RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model2.assertThat().field("isLocked").is(true) - .assertThat().field("properties").contains("lockLifetime=PERSISTENT") - .assertThat().field("properties").contains("lockType=WRITE_LOCK"); - - STEP("5. Lock the file using mode PERSISTENT with user1 while the file is still locked"); - RestNodeLockBodyModel lockBodyModel2 = new RestNodeLockBodyModel(); - lockBodyModel2.setLifetime("PERSISTENT"); - lockBodyModel2.setTimeToExpire(20); - lockBodyModel2.setType("ALLOW_OWNER_CHANGES"); - RestNodeModel file1Model3 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").lockNode(lockBodyModel2); - restClient.assertStatusCodeIs(HttpStatus.OK); - file1Model3.assertThat().field("isLocked").is(true); - file1Model3.assertThat().field("properties").contains("lockLifetime=PERSISTENT") - .assertThat().field("properties").contains("lockType=WRITE_LOCK"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, - description = "Verify Collaborator can lock EPHERMERAL after PERSISTENT lock made by same user") - public void lockPersistentAndRelockEphemeralSameUser() throws Exception - { - STEP("1. Adds a file in the site by administrator."); - file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); - - STEP("2. Verify with admin that the file is not locked."); - RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model1.assertThat().field("isLocked").is(false); - - STEP("3. Lock the file using mode PERSISTENT with user1 (POST nodes/{nodeId}/lock)."); - RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); - lockBodyModel.setLifetime("PERSISTENT"); - lockBodyModel.setTimeToExpire(1); - lockBodyModel.setType("ALLOW_OWNER_CHANGES"); - restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - - STEP("4. Verify with user1 that the file is locked."); - RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model2.assertThat().field("isLocked").is(true) - .assertThat().field("properties").contains("lockLifetime=PERSISTENT") - .assertThat().field("properties").contains("lockType=WRITE_LOCK"); - - STEP("5. Lock the file using mode EPHERMERAL with user1 while the file is still locked"); - RestNodeLockBodyModel lockBodyModel2 = new RestNodeLockBodyModel(); - lockBodyModel2.setLifetime("EPHEMERAL"); - lockBodyModel2.setTimeToExpire(20); - lockBodyModel2.setType("FULL"); - RestNodeModel file1Model3 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").lockNode(lockBodyModel2); - restClient.assertStatusCodeIs(HttpStatus.OK); - file1Model3.assertThat().field("isLocked").is(true); - file1Model3.assertThat().field("properties").contains("lockLifetime=EPHEMERAL") - .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION, TestGroup.REQUIRE_SOLR }) - @TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.REGRESSION, - description = "Verify that child nodes can be locked differently and unlocked") - public void testLockUnlockParentChild() throws Exception - { - STEP("1. Create user, site, parent node and children nodes."); - SiteModel siteLock = dataSite.usingUser(adminUser).createPublicRandomSite(); - FolderModel parentNode = dataContent.usingUser(adminUser).usingSite(siteLock).createFolder(); - FileModel childNode1 = dataContent.usingUser(adminUser).usingSite(siteLock).usingResource(parentNode).createContent(DocumentType.TEXT_PLAIN); - FileModel childNode2 = dataContent.usingUser(adminUser).usingSite(siteLock).usingResource(parentNode).createContent(DocumentType.TEXT_PLAIN); - - STEP("2. Verify with admin that the file is not locked."); - RestNodeModel restNodeResponse = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(parentNode).usingParams("include=isLocked").getNode(); - restNodeResponse.assertThat().field("isLocked").is(false); - - restNodeResponse = restClient.withCoreAPI().usingNode(childNode1).usingParams("include=isLocked").getNode(); - restNodeResponse.assertThat().field("isLocked").is(false); - - restNodeResponse = restClient.withCoreAPI().usingNode(childNode2).usingParams("include=isLocked").getNode(); - restNodeResponse.assertThat().field("isLocked").is(false); - - STEP("3. Lock childNode1 using mode PERSISTENT with adminUser (POST nodes/{nodeId}/lock)."); - RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); - lockBodyModel.setLifetime("PERSISTENT"); - lockBodyModel.setTimeToExpire(0); - lockBodyModel.setType("ALLOW_OWNER_CHANGES"); - restNodeResponse = restClient.withCoreAPI().usingNode(childNode1).usingParams("include=isLocked").lockNode(lockBodyModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - restNodeResponse.assertThat().field("aspectNames").contains("cm:lockable") - .assertThat().field("isLocked").is(true) - .assertThat().field("properties").contains("lockLifetime=PERSISTENT") - .assertThat().field("properties").contains("lockType=WRITE_LOCK"); - - STEP("4. Lock childNode2 using mode PERSISTENT with adminUser (POST nodes/{nodeId}/lock)."); - lockBodyModel = new RestNodeLockBodyModel(); - lockBodyModel.setLifetime("PERSISTENT"); - lockBodyModel.setTimeToExpire(0); - lockBodyModel.setType("FULL"); - restNodeResponse = restClient.withCoreAPI().usingNode(childNode2).usingParams("include=isLocked").lockNode(lockBodyModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - restNodeResponse.assertThat().field("aspectNames").contains("cm:lockable") - .assertThat().field("isLocked").is(true) - .assertThat().field("properties").contains("lockLifetime=PERSISTENT") - .assertThat().field("properties").contains("lockType=READ_ONLY_LOCK"); - - STEP("5. Verify that childNode1 and childNode 2 are locked."); - SearchRequest query = new SearchRequest(); - RestRequestQueryModel queryReq = new RestRequestQueryModel(); - RestRequestFilterQueryModel queryFilters = new RestRequestFilterQueryModel(); - queryFilters.setQuery("cm:lockOwner:\'admin\'"); - queryReq.setQuery("ASPECT:\'cm:lockable\'"); - query.setQuery(queryReq); - query.setFilterQueries(queryFilters); - query.setIncludeRequest(false); - - // Allow indexing to complete. - Utility.sleep(1000, 60000, () -> - { - SearchResponse response = query(query); - restClient.assertStatusCodeIs(HttpStatus.OK); - response.assertThat().entriesListContains("id",childNode1.getNodeRefWithoutVersion()); - response.assertThat().entriesListContains("id",childNode2.getNodeRefWithoutVersion()); - }); - - STEP("6. Unlock the nodes."); - restNodeResponse = restClient.withCoreAPI().usingNode(childNode1).usingParams("include=isLocked").unlockNode(); - restNodeResponse.assertThat().field("isLocked").is(false); - - restNodeResponse = restClient.withCoreAPI().usingNode(childNode2).usingParams("include=isLocked").unlockNode(); - restNodeResponse.assertThat().field("isLocked").is(false); - - STEP("7. Verify that childNode1 and childNode2 are not found in the query results."); - // Allow indexing to complete. - Utility.sleep(1000, 60000, () -> - { - SearchResponse response = query(query); - restClient.assertStatusCodeIs(HttpStatus.OK); - response.assertThat().entriesListDoesNotContain("id",childNode1.getNodeRefWithoutVersion()); - response.assertThat().entriesListDoesNotContain("id",childNode2.getNodeRefWithoutVersion()); - }); - } - - protected SearchResponse query(SearchRequest query) throws Exception - { - return restClient.authenticateUser(dataUser.getAdminUser()).withSearchAPI().search(query); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesParentChildrenTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesParentChildrenTests.java deleted file mode 100644 index d2f525553..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesParentChildrenTests.java +++ /dev/null @@ -1,205 +0,0 @@ -package org.alfresco.service.search.rest.nodes; - -import static org.alfresco.utility.report.log.Step.STEP; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestNodeBodyModel; -import org.alfresco.rest.model.RestNodeChildAssocModelCollection; -import org.alfresco.rest.model.RestNodeChildAssociationModel; -import org.alfresco.rest.model.RestNodeModel; -import org.alfresco.rest.model.RestNodeModelsCollection; -import org.alfresco.rest.model.RestNodeAssociationModelCollection; -import org.alfresco.rest.model.builder.NodesBuilder; -import org.alfresco.utility.Utility; -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/children - * api-explorer/#!/nodes/secondary-children - * api-explorer/#!/nodes/parents - */ -public class NodesParentChildrenTests extends RestTest -{ - @TestRail(section = { TestGroup.REST_API,TestGroup.NODES }, executionType = ExecutionType.SANITY, - description = "Verify new folder node is created as children on -my- posting as JSON content type") - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY}) - public void createNewFolderNodeViaJason() throws Exception - { - restClient.authenticateUser(dataContent.getAdminUser()); - - RestNodeBodyModel node = new RestNodeBodyModel(); - node.setName("My Folder"); - node.setNodeType("cm:folder"); - - RestNodeModel newNode = restClient.withParams("autoRename=true").withCoreAPI().usingNode(ContentModel.my()).createNode(node); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - newNode.assertThat().field("aspectNames").contains("cm:auditable") - .assertThat().field("isFolder").is(true) - .assertThat().field("isFile").is(false) - .assertThat().field("name").contains(node.getName()); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NODES }, executionType = ExecutionType.REGRESSION, - description = "Verify new folder node is created as children on -my- posting as MultiPart content type") - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.REGRESSION}) - public void createNewFolderNodeWithMultiPartForms() throws Exception - { - //configuring multipart form - restClient.authenticateUser(dataContent.getAdminUser()) - .configureRequestSpec() - .addMultiPart("filedata", Utility.getResourceTestDataFile("restapi-resource")) - .addFormParam("renditions", "doclib") - .addFormParam("autoRename", true); - - RestNodeModel newNode = restClient.withCoreAPI().usingNode(ContentModel.my()).createNode(); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - newNode.assertThat().field("aspectNames").contains("cm:auditable") - .assertThat().field("isFolder").is(false) - .assertThat().field("isFile").is(true) - .assertThat().field("name").contains("restapi-resource"); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NODES }, executionType = ExecutionType.SANITY, - description = "Verify list children when listing with relativePath and pagination") - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY}) - public void checkRelativePathAndPaginationOnCreateChildrenNode() throws Exception - { - /* - * Given we have a folder hierarchy folder1/folder2/folder3 and folder3 containing 3 files file1, file2, and file3 - */ - NodesBuilder nodesBuilder = restClient.authenticateUser(dataUser.getAdminUser()) - .withCoreAPI().usingNode(ContentModel.my()) - .defineNodes(); - nodesBuilder - .folder("F1") - .folder("F2") - .folder("F3") - .file("f1") - .file("f2") - .file("f3"); - - RestNodeModelsCollection returnedFiles = restClient.withParams("maxItems=2", - "skipCount=1", - String.format("relativePath=%s/%s", nodesBuilder.getNode("F2").getName(), nodesBuilder.getNode("F3").getName())) - .withCoreAPI().usingNode(nodesBuilder.getNode("F1").toContentModel()).listChildren(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - /* - * Then I receive file2 and file3 - */ - returnedFiles.assertThat().entriesListCountIs(2); - returnedFiles.getEntries().get(0).onModel().assertThat().field("id").is(nodesBuilder.getNode("f2").getId()); - returnedFiles.getEntries().get(1).onModel().assertThat().field("id").is(nodesBuilder.getNode("f3").getId()); - } - - /** - * Sanity check for the following api endpoints - * POST /nodes/{nodeId}/secondary-children - * GET /nodes/{nodeId}/secondary-children - * DELETE /nodes/{nodeId}/secondary-children/{childId} - */ - @TestRail(section = { TestGroup.REST_API, - TestGroup.NODES }, executionType = ExecutionType.SANITY, description = "Check /secondary-children (create, list, delete) api calls") - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY }) - public void checkSecondaryChildrenApi() throws Exception - { - STEP("1. Create a folder hierarchy folder1/folder2, with folder2 containing 3 files: f1, f2, and f3"); - NodesBuilder nodesBuilder = restClient.authenticateUser(dataUser.getAdminUser()) - .withCoreAPI().usingNode(ContentModel.my()) - .defineNodes(); - nodesBuilder - .folder("F1") - .folder("F2") - .file("f1") - .file("f2") - .file("f3"); - - STEP("2. Create secondary child associations model objects"); - RestNodeChildAssociationModel childAssoc1 = new RestNodeChildAssociationModel(nodesBuilder.getNode("f1").getId(), "cm:contains"); - RestNodeChildAssociationModel childAssoc2 = new RestNodeChildAssociationModel(nodesBuilder.getNode("f2").getId(), "cm:contains"); - RestNodeChildAssociationModel childAssoc3 = new RestNodeChildAssociationModel(nodesBuilder.getNode("f3").getId(), "cm:preferenceImage"); - String secondaryChildrenBody = "[" + childAssoc1.toJson() + "," + childAssoc2.toJson() + "," + childAssoc3.toJson() + "]"; - - STEP("3. Create secondary child associations using POST /nodes/{nodeId}/secondary-children"); - RestNodeChildAssocModelCollection secondaryChildAssoc = restClient.withCoreAPI().usingNode(nodesBuilder.getNode("F1").toContentModel()) - .createSecondaryChildren(secondaryChildrenBody); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - secondaryChildAssoc.getEntryByIndex(0).assertThat().field("childId").is(childAssoc1.getChildId()); - secondaryChildAssoc.getEntryByIndex(1).assertThat().field("childId").is(childAssoc2.getChildId()); - secondaryChildAssoc.getEntryByIndex(2).assertThat().field("childId").is(childAssoc3.getChildId()); - - STEP("4. Check using GET /nodes/{nodeId}/secondary-children that the secondary 'cm:contains' child associations were created"); - RestNodeAssociationModelCollection secondaryChildren = restClient.withParams("where=(assocType='cm:contains')").withCoreAPI() - .usingNode(nodesBuilder.getNode("F1").toContentModel()).getSecondaryChildren(); - restClient.assertStatusCodeIs(HttpStatus.OK); - secondaryChildren.assertThat().entriesListCountIs(2); - - STEP("5. Check using DELETE /nodes/{nodeId}/secondary-children/{childId} that a secondary child can be deleted"); - restClient.withCoreAPI().usingNode(nodesBuilder.getNode("F1").toContentModel()).deleteSecondaryChild(secondaryChildren.getEntryByIndex(0)); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - STEP("6. Check using GET /nodes/{nodeId}/secondary-children that a secondary child association was deleted"); - secondaryChildren = restClient.withCoreAPI().usingNode(nodesBuilder.getNode("F1").toContentModel()) - .getSecondaryChildren(); - restClient.assertStatusCodeIs(HttpStatus.OK); - secondaryChildren.assertThat().entriesListCountIs(2); - secondaryChildren.getEntryByIndex(0).assertThat() - .field("id").is(secondaryChildAssoc.getEntryByIndex(1).getChildId()).and() - .field("parentId").is(nodesBuilder.getNode("F2").getId()) - .getAssociation().assertThat() - .field("isPrimary").is(false).and() - .field("assocType").is("cm:contains"); - secondaryChildren.getEntryByIndex(1).assertThat() - .field("id").is(secondaryChildAssoc.getEntryByIndex(2).getChildId()) - .getAssociation().assertThat() - .field("assocType").is("cm:preferenceImage"); - } - - /** - * Sanity check for the following api endpoint - * GET /nodes/{nodeId}/parents - */ - @TestRail(section = { TestGroup.REST_API, - TestGroup.NODES }, executionType = ExecutionType.SANITY, description = "Check that GET /parents retrieves primary and secondary parents for a node") - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY }) - public void checkGetNodeParents() throws Exception - { - STEP("1. Create a folder hierarchy folder1/folder2, with folder2 containing file f1"); - NodesBuilder nodesBuilder = restClient.authenticateUser(dataUser.getAdminUser()) - .withCoreAPI().usingNode(ContentModel.my()) - .defineNodes(); - nodesBuilder - .folder("F1") - .folder("F2") - .file("f1"); - - STEP("2. Create secondary child associations using POST /nodes/{nodeId}/secondary-children"); - RestNodeChildAssociationModel childAssoc = new RestNodeChildAssociationModel(nodesBuilder.getNode("f1").getId(), "cm:contains"); - restClient.withCoreAPI().usingNode(nodesBuilder.getNode("F1").toContentModel()).createSecondaryChildren(childAssoc.toJson()); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - STEP("3. Get all parents for file 'f1' - both primary and secondary"); - RestNodeAssociationModelCollection parents = restClient.withCoreAPI().usingNode(nodesBuilder.getNode("f1").toContentModel()).getParents(); - restClient.assertStatusCodeIs(HttpStatus.OK); - parents.assertThat().entriesListCountIs(2); - - STEP("4. Check using GET /nodes/{nodeId}/parents that the parent (not primary) for f1 is found"); - parents = restClient.withParams("where=(isPrimary=false)").withCoreAPI().usingNode(nodesBuilder.getNode("f1").toContentModel()).getParents(); - restClient.assertStatusCodeIs(HttpStatus.OK); - parents.assertThat().entriesListCountIs(1); - parents.getEntryByIndex(0).assertThat() - .field("isFolder").is("true").and() - .field("isFile").is(false).and() - .field("name").is(nodesBuilder.getNode("F1").getName()) - .getAssociation().assertThat() - .field("isPrimary").is(false).and() - .field("assocType").is("cm:contains"); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesTargetSourcesTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesTargetSourcesTests.java deleted file mode 100644 index d6fe35259..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesTargetSourcesTests.java +++ /dev/null @@ -1,120 +0,0 @@ -package org.alfresco.service.search.rest.nodes; - -import static org.alfresco.utility.report.log.Step.STEP; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestNodeAssocTargetModel; -import org.alfresco.rest.model.RestNodeAssociationModelCollection; -import org.alfresco.rest.model.builder.NodesBuilder; -import org.alfresco.utility.model.ContentModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class NodesTargetSourcesTests extends RestTest -{ - - private UserModel adminUserModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - } - - /** - * Sanity check for the following api endpoints - * POST /nodes/{nodeId}/targets - * GET /nodes/{nodeId}/targets - * DELETE /nodes/{nodeId}/targets/{targetId} - */ - - @TestRail(section = { TestGroup.REST_API, - TestGroup.NODES }, executionType = ExecutionType.SANITY, description = "Check /targets (create, list, delete) api calls") - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY }) - public void checkTargetsNodeApi() throws Exception - { - STEP("1.Create folder1 which contains 3 files: f1, f2, and f3"); - NodesBuilder nodesBuilder = restClient.authenticateUser(adminUserModel).withCoreAPI().usingNode(ContentModel.my()).defineNodes(); - nodesBuilder.folder("F1").file("f1").file("f2").file("f3"); - - STEP("2. Create target associations model objects"); - RestNodeAssocTargetModel assocDocTarget1 = new RestNodeAssocTargetModel(nodesBuilder.getNode("f2").toContentModel().getNodeRef(), "cm:references"); - RestNodeAssocTargetModel assocDocTarget2 = new RestNodeAssocTargetModel(nodesBuilder.getNode("f3").toContentModel().getNodeRef(), "cm:references"); - - STEP("3. Create target associations using POST /nodes/{nodeId}/targets"); - restClient.withCoreAPI().usingResource(nodesBuilder.getNode("f1").toContentModel()).createTargetForNode(assocDocTarget1); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.withCoreAPI().usingResource(nodesBuilder.getNode("f1").toContentModel()).createTargetForNode(assocDocTarget2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - STEP("4. Check using GET /nodes/{nodeId}/targets targets associations were created"); - RestNodeAssociationModelCollection targetsRes = restClient.withParams("where=(assocType='cm:references')").withCoreAPI().usingResource(nodesBuilder.getNode("f1").toContentModel()).getNodeTargets(); - restClient.assertStatusCodeIs(HttpStatus.OK); - targetsRes.assertThat().entriesListCountIs(2); - targetsRes.getEntryByIndex(0).assertThat().field("association.assocType").is("cm:references").and().field("name") - .is(nodesBuilder.getNode("f2").getName()); - targetsRes.getEntryByIndex(1).assertThat().field("association.assocType").is("cm:references").and().field("name") - .is(nodesBuilder.getNode("f3").getName()); - - STEP("5. Check using DELETE /nodes/{nodeId}/targets/{targetId} that a target can be deleted"); - restClient.authenticateUser(adminUserModel); - restClient.withCoreAPI().usingResource(nodesBuilder.getNode("f1").toContentModel()).deleteTarget(assocDocTarget1); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - STEP("6. Check using GET /nodes/{nodeId}/targets that target association was deleted"); - targetsRes = restClient.withParams("where=(assocType='cm:references')").withCoreAPI() - .usingResource(nodesBuilder.getNode("f1").toContentModel()).getNodeTargets(); - restClient.assertStatusCodeIs(HttpStatus.OK); - targetsRes.assertThat().entriesListCountIs(1); - targetsRes.getEntryByIndex(0).assertThat().field("association.assocType").is("cm:references"); - } - - /** - * Sanity check for the following api endpoint - * GET /nodes/{nodeId}/sources - */ - @TestRail(section = { TestGroup.REST_API, - TestGroup.NODES }, executionType = ExecutionType.SANITY, description = "Check that source objects are retrieved using GET /nodes/{nodeId}/sources") - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY }) - public void checkGetNodeSources() throws Exception - { - STEP("1.Create a folder hierarchy folder1 containing 4 files: f1, f2, and f3"); - NodesBuilder nodesBuilder = restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingNode(ContentModel.my()).defineNodes(); - nodesBuilder.folder("F1").file("f1").file("f2").file("f3"); - - STEP("2. Create target associations model objects"); - RestNodeAssocTargetModel assocDocTarget1 = new RestNodeAssocTargetModel(nodesBuilder.getNode("f3").toContentModel().getNodeRef(), "cm:references"); - RestNodeAssocTargetModel assocDocTarget2 = new RestNodeAssocTargetModel(nodesBuilder.getNode("f3").toContentModel().getNodeRef(), "cm:preferenceImage"); - - STEP("3. Create target associations using POST /nodes/{nodeId}/targets"); - restClient.authenticateUser(adminUserModel); - restClient.withCoreAPI().usingResource(nodesBuilder.getNode("f1").toContentModel()).createTargetForNode(assocDocTarget1); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.withCoreAPI().usingResource(nodesBuilder.getNode("f2").toContentModel()).createTargetForNode(assocDocTarget2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - STEP("4. Check using GET /nodes/{nodeId}/sources that all source associations are displayed"); - RestNodeAssociationModelCollection sources = restClient.withCoreAPI().usingResource(nodesBuilder.getNode("f3").toContentModel()).getNodeSources(); - restClient.assertStatusCodeIs(HttpStatus.OK); - sources.assertThat().entriesListCountIs(2); - - STEP("5. Check using GET /nodes/{nodeId}/sources with params that sources and fields can be filtered in the response"); - sources = restClient.withParams("where=(assocType='cm:references')", "fields=isFile,name,association,id,nodeType,parentId").withCoreAPI().usingResource(nodesBuilder.getNode("f3").toContentModel()).getNodeSources(); - restClient.assertStatusCodeIs(HttpStatus.OK); - sources.assertThat().entriesListCountIs(1); - - sources.getEntryByIndex(0).assertThat() - .field("isFile").is(true).and() - .field("name").is(nodesBuilder.getNode("f1").getName()).and() - .field("id").is(nodesBuilder.getNode("f1").getId()).and() - .field("id").is(nodesBuilder.getNode("f1").getId()).and() - .field("nodeType").is("cm:content") - .getAssociation().assertThat() - .field("assocType").is("cm:references"); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesTests.java deleted file mode 100644 index 9a3866989..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesTests.java +++ /dev/null @@ -1,56 +0,0 @@ -package org.alfresco.service.search.rest.nodes; - -import org.alfresco.service.search.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()); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesUnlockTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesUnlockTests.java deleted file mode 100644 index 488dd854d..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/nodes/NodesUnlockTests.java +++ /dev/null @@ -1,112 +0,0 @@ -package org.alfresco.service.search.rest.nodes; - -import static org.alfresco.utility.report.log.Step.STEP; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestNodeModel; -import org.alfresco.rest.model.body.RestNodeLockBodyModel; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class NodesUnlockTests extends RestTest -{ - private UserModel user1, user2, adminUser; - private SiteModel publicSite; - private FileModel file1; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - publicSite = dataSite.usingUser(adminUser).createPublicRandomSite(); - user1 = dataUser.createRandomTestUser(); - user2 = dataUser.createRandomTestUser(); - dataUser.addUserToSite(user1, publicSite, UserRole.SiteCollaborator); - user1.setUserRole(UserRole.SiteCollaborator); - dataUser.addUserToSite(user2, publicSite, UserRole.SiteCollaborator); - user2.setUserRole(UserRole.SiteCollaborator); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY }) - @TestRail(section={TestGroup.REST_API, TestGroup.NODES}, executionType= ExecutionType.SANITY, - description= "Verify Collaborator canot unlock EPHEMERAL lock made by different user, but can unlock EPHEMERAL lock made by same user") - public void lockEphemeralAndUnlock() throws Exception - { - STEP("1. Add user(s) as collaborators to the site created by administrator and add a file in this site."); - file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); - - STEP("2. Verify with user1 that the file is not locked."); - RestNodeModel file1Model1 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model1.assertThat().field("isLocked").is(false); - - STEP("3. Lock the file using mode EPHEMERAL with user1 (POST nodes/{nodeId}/lock)."); - RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); - lockBodyModel.setLifetime("EPHEMERAL"); - lockBodyModel.setTimeToExpire(20); - restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - - STEP("4. Verify with user1 that the file is locked."); - RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model2.assertThat().field("isLocked").is(true); - - STEP("5. Cannot unlock the file with user2 while the file is still locked"); - restClient.authenticateUser(user2).withCoreAPI().usingNode(file1).usingParams("include=isLocked").unlockNode(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError() - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - - STEP("6. Unlock the file with user1 while the file is still locked"); - RestNodeModel file1Model3 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").unlockNode(); - file1Model3.assertThat().field("isLocked").is(false); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY }) - @TestRail(section={TestGroup.REST_API, TestGroup.NODES}, executionType= ExecutionType.SANITY, - description= "Verify Collaborator canot unlock PERSISTENT lock made by different user, but can unlock PERSISTENT lock made by same user") - public void lockPersistentAndUnlock() throws Exception{ - - STEP("1. Add user(s) as collaborators to the site created by administrator and add a file in this site."); - file1 = dataContent.usingUser(adminUser).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN); - - STEP("2. Verify with admin that the file is not locked."); - RestNodeModel file1Model1 = restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model1.assertThat().field("isLocked").is(false); - - STEP("3. Lock the file using mode PERSISTENT with user1 (POST nodes/{nodeId}/lock)."); - RestNodeLockBodyModel lockBodyModel = new RestNodeLockBodyModel(); - lockBodyModel.setLifetime("PERSISTENT"); - lockBodyModel.setTimeToExpire(20); - restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include?isLocked").lockNode(lockBodyModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - - STEP("4. Verify with user1 that the file is locked."); - RestNodeModel file1Model2 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").getNode(); - file1Model2.assertThat().field("isLocked").is(true); - - STEP("5. Cannot unlock the file with user2 while the file is still locked"); - restClient.authenticateUser(user2).withCoreAPI().usingNode(file1).usingParams("include=isLocked").unlockNode(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError() - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - - STEP("6. Unlock the file with user1 while the file is still locked"); - RestNodeModel file1Model3 = restClient.authenticateUser(user1).withCoreAPI().usingNode(file1).usingParams("include=isLocked").unlockNode(); - file1Model3.assertThat().field("isLocked").is(false); - } - -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/AvatarPeopleSanityTest.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/AvatarPeopleSanityTest.java deleted file mode 100644 index 46e4cd71c..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/AvatarPeopleSanityTest.java +++ /dev/null @@ -1,66 +0,0 @@ -package org.alfresco.service.search.rest.people; - -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; - -import java.io.File; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.utility.Utility; -import org.alfresco.utility.exception.DataPreparationException; -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; - -import com.jayway.restassured.response.ValidatableResponse; - -public class AvatarPeopleSanityTest extends RestTest -{ - - private UserModel userModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws DataPreparationException - { - userModel = dataUser.createRandomTestUser(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY, TestGroup.REQUIRE_TRANSFORMATION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Update Avatar for People") - public void updateGetAvatarForPeople() throws Exception - { - File avatarFile = Utility.getResourceTestDataFile("avatar.jpg"); - restClient.authenticateUser(userModel); - ValidatableResponse response = restClient.withCoreAPI().usingAuthUser() - .uploadAvatarContent(restProperties.envProperty().getFullServerUrl(), avatarFile).statusCode(200); - // Renditions are async - Utility.sleep(500, 60000, () -> - { - restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().downloadAvatarContent(); - restClient.assertStatusCodeIs(HttpStatus.OK); - }); - assertNotNull(response.extract().body().asByteArray()); - assertTrue(response.extract().body().asByteArray().length > 0, "Avatar Image not uploaded"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY, TestGroup.REQUIRE_TRANSFORMATION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Remove Avatar for People") - public void removeGetAvatarForPeople() throws Exception - { - File avatarFile = Utility.getResourceTestDataFile("avatar.jpg"); - restClient.authenticateUser(userModel); - restClient.withCoreAPI().usingAuthUser().uploadAvatarContent(restProperties.envProperty().getFullServerUrl(), avatarFile).statusCode(200); - - restClient.authenticateUser(userModel); - restClient.withCoreAPI().usingAuthUser().resetAvatarImageRequest(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().downloadAvatarContent(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } - -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/DeleteSiteMemberCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/DeleteSiteMemberCoreTests.java deleted file mode 100644 index 32a8b8e53..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/DeleteSiteMemberCoreTests.java +++ /dev/null @@ -1,229 +0,0 @@ -package org.alfresco.service.search.rest.people; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -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.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class DeleteSiteMemberCoreTests extends RestTest -{ - private UserModel userModel; - private UserModel managerModel; - private SiteModel publicSiteModel; - private SiteModel moderatedSiteModel; - private SiteModel privateSiteModel; - private UserModel adminUserModel; - private UserModel secondUserModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - secondUserModel = dataUser.createRandomTestUser(); - secondUserModel.setUserRole(UserRole.SiteCollaborator); - userModel = dataUser.createRandomTestUser(); - userModel.setUserRole(UserRole.SiteCollaborator); - managerModel = dataUser.createRandomTestUser(); - managerModel.setUserRole(UserRole.SiteManager); - adminUserModel = dataUser.getAdminUser(); - publicSiteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - moderatedSiteModel = dataSite.usingUser(adminUserModel).createModeratedRandomSite(); - privateSiteModel = dataSite.usingUser(adminUserModel).createPrivateRandomSite(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user removes a site member using '-me-' in place of personId and response is successful (204)") - public void removeSiteMemberWithSuccessUsingMeAsPersonId() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(userModel); - - restClient.authenticateUser(userModel).withCoreAPI().usingMe().deleteSiteMember(publicSiteModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user can't remove a site membership of an inexistent uer and response is 404") - public void userIsNotAbleToRemoveInexistentSiteMember() throws Exception - { - UserModel inexistentUser = new UserModel("inexistenUser", "password"); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(inexistentUser).deleteSiteMember(publicSiteModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, inexistentUser.getUsername())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove a member of an inexistent site and response is 404") - public void userIsNotAbleToRemoveMembershipOfInexistentSite() throws Exception - { - SiteModel inexistentSite = new SiteModel("inexistentSite"); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(userModel).deleteSiteMember(inexistentSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, userModel.getUsername(), inexistentSite.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove a member of an empty site id and response is 404") - public void userIsNotAbleToRemoveMembershipOfEmptySiteId() throws Exception - { - SiteModel inexistentSite = new SiteModel(""); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(userModel).deleteSiteMember(inexistentSite); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.DELETE_EMPTY_ARGUMENT); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove a regular member a moderated site and response is 422") - public void regularUserIsNotAbleToRemoveRegularUserSiteMembershipFromModeratedSite() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(secondUserModel); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(userModel); - restClient.authenticateUser(secondUserModel).withCoreAPI().usingUser(userModel).deleteSiteMember(moderatedSiteModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() - .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, moderatedSiteModel.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove a regular member of a private site and response is 422") - public void regularUserIsNotAbleToRemoveRegularUserSiteMembershipFromPrivateSite() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(userModel); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(secondUserModel); - restClient.authenticateUser(secondUserModel).withCoreAPI().usingUser(userModel).deleteSiteMember(privateSiteModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() - .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, privateSiteModel.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove a regular member of a moderated site and response is 204") - public void adminIsAbleToRemoveRegularUserSiteMembershipFromModeratedSite() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(userModel); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(userModel).deleteSiteMember(moderatedSiteModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove a regular member of a private site and response is 204") - public void adminIsAbleToRemoveRegularUserSiteMembershipFromPrivateSite() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(userModel); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(userModel).deleteSiteMember(privateSiteModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove admin membership from public site and response is 422") - public void regularUserIsNotAbleToRemoveAdminSiteMembershipFromPublicSite() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(managerModel); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(userModel); - restClient.authenticateUser(userModel).withCoreAPI().usingUser(adminUserModel).deleteSiteMember(publicSiteModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() - .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove admin membership from moderated site and response is 422") - public void regularUserIsNotAbleToRemoveAdminSiteMembershipFromModeratedSite() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(managerModel); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(userModel); - restClient.authenticateUser(userModel).withCoreAPI().usingUser(adminUserModel).deleteSiteMember(moderatedSiteModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() - .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, moderatedSiteModel.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove admin membership from private site and response is 422") - public void regularUserIsNotAbleToRemoveAdminSiteMembershipFromPrivateSite() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(managerModel); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(userModel); - restClient.authenticateUser(userModel).withCoreAPI().usingUser(adminUserModel).deleteSiteMember(privateSiteModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() - .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, privateSiteModel.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove the membership of a manager from a public site and response is 204") - public void adminIsAbleToRemoveManagerSiteMembershipOfPublicSite() throws Exception - { - UserModel secondManager = dataUser.createRandomTestUser(); - secondManager.setUserRole(UserRole.SiteManager); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(secondManager); - restClient.withCoreAPI().usingSite(publicSiteModel).addPerson(managerModel); - restClient.withCoreAPI().usingUser(managerModel).deleteSiteMember(publicSiteModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove the membership of a manager from a moderated site and response is 204") - public void adminIsAbleToRemoveManagerSiteMembershipOfModeratedSite() throws Exception - { - UserModel secondManager = dataUser.createRandomTestUser(); - secondManager.setUserRole(UserRole.SiteManager); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(secondManager); - restClient.withCoreAPI().usingSite(moderatedSiteModel).addPerson(managerModel); - restClient.withCoreAPI().usingUser(managerModel).deleteSiteMember(moderatedSiteModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove the membership of a manager from a private site and response is 204") - public void adminIsAbleToRemoveManagerSiteMembershipOfPrivateSite() throws Exception - { - UserModel secondManager = dataUser.createRandomTestUser(); - secondManager.setUserRole(UserRole.SiteManager); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(secondManager); - restClient.withCoreAPI().usingSite(privateSiteModel).addPerson(managerModel); - restClient.withCoreAPI().usingUser(managerModel).deleteSiteMember(privateSiteModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify collaborator is not able to remove the membership of a manager from a public site and response is 204") - public void userIsNotAbleToRemoveManagerSiteMembershipOfPublicSite() throws Exception - { - UserModel secondManager = dataUser.createRandomTestUser(); - secondManager.setUserRole(UserRole.SiteManager); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(secondManager); - restClient.withCoreAPI().usingSite(publicSiteModel).addPerson(userModel); - restClient.withCoreAPI().usingSite(publicSiteModel).addPerson(managerModel); - restClient.authenticateUser(userModel).withCoreAPI().usingUser(managerModel).deleteSiteMember(publicSiteModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() - .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify collaborator is not able to remove the membership of a manager from a moderated site and response is 204") - public void userIsNotAbleToRemoveManagerSiteMembershipOfModeratedSite() throws Exception - { - UserModel secondManager = dataUser.createRandomTestUser(); - secondManager.setUserRole(UserRole.SiteManager); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(secondManager); - restClient.withCoreAPI().usingSite(publicSiteModel).addPerson(userModel); - restClient.withCoreAPI().usingSite(moderatedSiteModel).addPerson(managerModel); - restClient.authenticateUser(userModel).withCoreAPI().usingUser(managerModel).deleteSiteMember(moderatedSiteModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() - .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, moderatedSiteModel.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify collaborator is not able to remove the membership of a manager from a private site and response is 204") - public void userIsNotAbleToRemoveManagerSiteMembershipOfPrivateSite() throws Exception - { - UserModel secondManager = dataUser.createRandomTestUser(); - secondManager.setUserRole(UserRole.SiteManager); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(secondManager); - restClient.withCoreAPI().usingSite(privateSiteModel).addPerson(userModel); - restClient.withCoreAPI().usingSite(privateSiteModel).addPerson(managerModel); - restClient.authenticateUser(userModel).withCoreAPI().usingUser(managerModel).deleteSiteMember(privateSiteModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() - .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, privateSiteModel.getId())); - } -} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/DeleteSiteMemberFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/DeleteSiteMemberFullTests.java deleted file mode 100644 index fe7336390..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/DeleteSiteMemberFullTests.java +++ /dev/null @@ -1,207 +0,0 @@ -package org.alfresco.service.search.rest.people; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -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.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class DeleteSiteMemberFullTests extends RestTest -{ - private SiteModel publicSiteModel; - private SiteModel moderatedSiteModel; - private SiteModel privateSiteModel; - private UserModel adminUserModel; - private ListUserWithRoles usersWithRolesPublicSite; - private ListUserWithRoles usersWithRolesModeratedSite; - private ListUserWithRoles usersWithRolesPrivateSite; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - adminUserModel.setUserRole(UserRole.SiteManager); - publicSiteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - moderatedSiteModel = dataSite.usingUser(adminUserModel).createModeratedRandomSite(); - privateSiteModel = dataSite.usingUser(adminUserModel).createPrivateRandomSite(); - - usersWithRolesPublicSite = dataUser.addUsersWithRolesToSite(publicSiteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - usersWithRolesModeratedSite = dataUser.addUsersWithRolesToSite(moderatedSiteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - usersWithRolesPrivateSite = dataUser.addUsersWithRolesToSite(privateSiteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove collaborator member of a public site") - public void adminIsAbleToRemoveCollaboratorSiteMembershipFromPublicSite() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteCollaborator)).deleteSiteMember(publicSiteModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteCollaborator)); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove contributor member of a public site") - public void adminIsAbleToRemoveContributorSiteMembershipFromPublicSite() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteContributor)).deleteSiteMember(publicSiteModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteContributor)); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove contributor member of a public site and response is 422") - public void userIsNotAbleToRemoveContributorSiteMembershipFromPublicSite() throws Exception - { - restClient.authenticateUser(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingUser(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteContributor)).deleteSiteMember(publicSiteModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() - .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove consumer member of a public site and response is 422") - public void userIsNotAbleToRemoveConsumerSiteMembershipFromPublicSite() throws Exception - { - restClient.authenticateUser(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingUser(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteConsumer)).deleteSiteMember(publicSiteModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() - .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove collaborator member of a moderated site") - public void adminIsAbleToRemoveCollaboratorSiteMembershipFromModeratedSite() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(usersWithRolesModeratedSite.getOneUserWithRole(UserRole.SiteCollaborator)).deleteSiteMember(moderatedSiteModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(usersWithRolesModeratedSite.getOneUserWithRole(UserRole.SiteCollaborator)); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove contributor member of a moderated site") - public void adminIsAbleToRemoveContributorSiteMembershipFromModeratedSite() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(usersWithRolesModeratedSite.getOneUserWithRole(UserRole.SiteContributor)).deleteSiteMember(moderatedSiteModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(usersWithRolesModeratedSite.getOneUserWithRole(UserRole.SiteContributor)); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove contributor member of a moderated site and response is 422") - public void userIsNotAbleToRemoveContributorSiteMembershipFromModeratedSite() throws Exception - { - restClient.authenticateUser(usersWithRolesModeratedSite.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingUser(usersWithRolesModeratedSite.getOneUserWithRole(UserRole.SiteContributor)).deleteSiteMember(moderatedSiteModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() - .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, moderatedSiteModel.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove consumer member of a moderated site and response is 422") - public void userIsNotAbleToRemoveConsumerSiteMembershipFromModeratedSite() throws Exception - { - restClient.authenticateUser(usersWithRolesModeratedSite.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingUser(usersWithRolesModeratedSite.getOneUserWithRole(UserRole.SiteConsumer)).deleteSiteMember(moderatedSiteModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() - .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, moderatedSiteModel.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove collaborator member of a private site") - public void adminIsAbleToRemoveCollaboratorSiteMembershipFromPrivateSite() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(usersWithRolesPrivateSite.getOneUserWithRole(UserRole.SiteCollaborator)).deleteSiteMember(privateSiteModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(usersWithRolesPrivateSite.getOneUserWithRole(UserRole.SiteCollaborator)); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is able to remove contributor member of a private site") - public void adminIsAbleToRemoveContributorSiteMembershipFromPrivateSite() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(usersWithRolesPrivateSite.getOneUserWithRole(UserRole.SiteContributor)).deleteSiteMember(privateSiteModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(usersWithRolesPrivateSite.getOneUserWithRole(UserRole.SiteContributor)); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove contributor member of a private site and response is 422") - public void userIsNotAbleToRemoveContributorSiteMembershipFromPrivateSite() throws Exception - { - restClient.authenticateUser(usersWithRolesPrivateSite.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingUser(usersWithRolesPrivateSite.getOneUserWithRole(UserRole.SiteContributor)).deleteSiteMember(privateSiteModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() - .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, privateSiteModel.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove consumer member of a private site and response is 422") - public void userIsNotAbleToRemoveConsumerSiteMembershipFromPrivateSite() throws Exception - { - restClient.authenticateUser(usersWithRolesPrivateSite.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingUser(usersWithRolesPrivateSite.getOneUserWithRole(UserRole.SiteConsumer)).deleteSiteMember(privateSiteModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() - .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, privateSiteModel.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is not able to remove same user twice and response is 400") - @Bug(id="ACE-5447") - public void adminIsNotAbleToRemoveSameUserTwice() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteCollaborator)).deleteSiteMember(publicSiteModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteCollaborator)).deleteSiteMember(publicSiteModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(RestErrorModel.ENTITY_NOT_FOUND); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMembers().assertThat().entriesListContains("id", usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteCollaborator).getUsername()) - .when().getSiteMember(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteCollaborator).getUsername()) - .assertSiteMemberHasRole(UserRole.SiteCollaborator); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify single manager is not able to delete himself and response is 400") - public void lastManagerIsNotAbleToDeleteHimself() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteManager)).deleteSiteMember(publicSiteModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingUser(adminUserModel).deleteSiteMember(publicSiteModel); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.DELETE_LAST_MANAGER, publicSiteModel.getTitle())) - .containsErrorKey(String.format(RestErrorModel.DELETE_LAST_MANAGER, publicSiteModel.getTitle())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER).stackTraceIs(RestErrorModel.STACKTRACE); - - restClient.withCoreAPI().usingSite(publicSiteModel).addPerson(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMembers() - .assertThat().entriesListContains("id", usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteManager).getUsername()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site creator can be deleted") - public void siteCreatorCanBeDeleted() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).deleteSiteMember(publicSiteModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.authenticateUser(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingSite(publicSiteModel).addPerson(adminUserModel); - restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMembers().assertThat().entriesListContains("id", adminUserModel.getUsername()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is not able to remove from site a user that created a member request that was not accepted yet") - @Bug(id="ACE-5447") - public void adminIsNotAbleToRemoveFromSiteANonExistingMember() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSiteModel); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(newMember).deleteSiteMember(moderatedSiteModel); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(RestErrorModel.ENTITY_NOT_FOUND); - } - -} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/DeleteSiteMemberSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/DeleteSiteMemberSanityTests.java deleted file mode 100644 index d76871c62..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/DeleteSiteMemberSanityTests.java +++ /dev/null @@ -1,111 +0,0 @@ -package org.alfresco.service.search.rest.people; - -import org.alfresco.service.search.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; - -public class DeleteSiteMemberSanityTests extends RestTest -{ - private SiteModel siteModel; - private UserModel adminUser; - private ListUserWithRoles usersWithRoles; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws DataPreparationException - { - adminUser = dataUser.getAdminUser(); - siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); - - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site manager is able to delete another member of the site") - public void siteManagerCanDeleteSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception - { - UserModel newUser = dataUser.createRandomTestUser("testUser"); - newUser.setUserRole(UserRole.SiteCollaborator); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingSite(siteModel).addPerson(newUser); - - restClient.withCoreAPI().usingUser(newUser).deleteSiteMember(siteModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify admin user is able to delete another member of the site") - public void adminIsAbleToDeleteSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception - { - UserModel newUser = dataUser.createRandomTestUser("testUser"); - newUser.setUserRole(UserRole.SiteCollaborator); - restClient.authenticateUser(adminUser).withCoreAPI().usingSite(siteModel).addPerson(newUser); - - restClient.withCoreAPI().usingUser(newUser).deleteSiteMember(siteModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site collaborator does not have permission to delete another member of the site") - public void siteCollaboratorIsNotAbleToDeleteSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception - { - UserModel newUser = dataUser.createRandomTestUser("testUser"); - newUser.setUserRole(UserRole.SiteCollaborator); - restClient.authenticateUser(adminUser).withCoreAPI().usingSite(siteModel).addPerson(newUser); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - - restClient.withCoreAPI().usingUser(newUser).deleteSiteMember(siteModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() - .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site contributor does not have permission to delete another member of the site") - public void siteContributorIsNotAbleToDeleteSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception - { - UserModel newUser = dataUser.createRandomTestUser("testUser"); - newUser.setUserRole(UserRole.SiteCollaborator); - restClient.authenticateUser(adminUser).withCoreAPI().usingSite(siteModel).addPerson(newUser); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - - restClient.withCoreAPI().usingUser(newUser).deleteSiteMember(siteModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() - .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site consumer does not have permission to delete another member of the site") - public void siteConsumerIsNotAbleToDeleteSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception - { - UserModel newUser = dataUser.createRandomTestUser("testUser"); - newUser.setUserRole(UserRole.SiteCollaborator); - restClient.authenticateUser(adminUser).withCoreAPI().usingSite(siteModel).addPerson(newUser); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - - restClient.withCoreAPI().usingUser(newUser).deleteSiteMember(siteModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() - .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify unauthenticated user is not able to delete another member of the site") - public void unauthenticatedUserIsNotAbleToDeleteSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception - { - restClient.authenticateUser(new UserModel("random user", "random password")); - - restClient.withCoreAPI().usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).deleteSiteMember(siteModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError().containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED);; - } -} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetPeopleCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetPeopleCoreTests.java deleted file mode 100644 index 2ff985718..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetPeopleCoreTests.java +++ /dev/null @@ -1,57 +0,0 @@ -package org.alfresco.service.search.rest.people; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -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.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * - * @author Cristina Axinte - * - */ -public class GetPeopleCoreTests extends RestTest -{ - UserModel userModel; - SiteModel siteModel; - UserModel searchedUser; - UserModel adminUser, managerUser; - UserModel inexistentUser; - - @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); - inexistentUser = new UserModel("inexistentUser", "password"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify inexistent user cannot get a person with Rest API and response is 401") - public void inexistentUserIsUnauthorizedToGetPerson() throws Exception - { - restClient.authenticateUser(inexistentUser).withCoreAPI().usingUser(searchedUser).getPerson(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); - restClient.assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot get a person that doesn't exists with Rest API and response is 404") - public void userCannotGetInexistentPerson() throws Exception - { - restClient.authenticateUser(managerUser).withCoreAPI().usingUser(inexistentUser).getPerson(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - restClient.assertLastError().containsSummary(String.format(inexistentUser.getUsername(), RestErrorModel.ENTITY_NOT_FOUND)); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetPeopleFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetPeopleFullTests.java deleted file mode 100644 index 454500cc3..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetPeopleFullTests.java +++ /dev/null @@ -1,88 +0,0 @@ -package org.alfresco.service.search.rest.people; - -import org.alfresco.service.search.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"); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetPeopleSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetPeopleSanityTests.java deleted file mode 100644 index e4937bba5..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetPeopleSanityTests.java +++ /dev/null @@ -1,110 +0,0 @@ -package org.alfresco.service.search.rest.people; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestPersonModel; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class GetPeopleSanityTests extends RestTest -{ - UserModel userModel; - SiteModel siteModel; - UserModel searchedUser; - UserModel adminUser; - private RestPersonModel personModel; - private String domain = "@tas-automation.org"; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - searchedUser = dataUser.createRandomTestUser(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user gets a person with Rest API and response is successful") - public void managerUserChecksIfPersonIsPresent() throws Exception - { - UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); - - personModel = restClient.authenticateUser(managerUser).withCoreAPI().usingUser(searchedUser).getPerson(); - restClient.assertStatusCodeIs(HttpStatus.OK); - personModel.assertThat().field("id").is(searchedUser.getUsername()).assertThat().field("firstName").is(searchedUser.getUsername() + " FirstName").and() - .field("email").is(searchedUser.getUsername() + domain).and().field("emailNotificationsEnabled").is("true"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify collaborator user gets a person with Rest API and response is successful") - public void collaboratorUserChecksIfPersonIsPresent() throws Exception - { - UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(collaboratorUser, siteModel, UserRole.SiteCollaborator); - - personModel = restClient.authenticateUser(collaboratorUser).withCoreAPI().usingUser(searchedUser).getPerson(); - restClient.assertStatusCodeIs(HttpStatus.OK); - personModel.assertThat().field("id").is(searchedUser.getUsername()).assertThat().field("firstName").is(searchedUser.getUsername() + " FirstName").and() - .field("email").is(searchedUser.getUsername() + domain).and().field("emailNotificationsEnabled").is("true"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.COMMENTS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify contributor user gets a person with Rest API and response is successful") - public void contributorUserChecksIfPersonIsPresent() throws Exception - { - UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(contributorUser, siteModel, UserRole.SiteContributor); - - personModel = restClient.authenticateUser(contributorUser).withCoreAPI().usingUser(searchedUser).getPerson(); - restClient.assertStatusCodeIs(HttpStatus.OK); - personModel.assertThat().field("id").is(searchedUser.getUsername()).assertThat().field("firstName").is(searchedUser.getUsername() + " FirstName").and() - .field("email").is(searchedUser.getUsername() + domain).and().field("emailNotificationsEnabled").is("true"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify consumer user gets a person with Rest API and response is successful") - public void consumerUserChecksIfPersonIsPresent() throws Exception - { - UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel, UserRole.SiteConsumer); - - personModel = restClient.authenticateUser(consumerUser).withCoreAPI().usingUser(searchedUser).getPerson(); - restClient.assertStatusCodeIs(HttpStatus.OK); - personModel.assertThat().field("id").is(searchedUser.getUsername()).assertThat().field("firstName").is(searchedUser.getUsername() + " FirstName").and() - .field("email").is(searchedUser.getUsername() + domain).and().field("emailNotificationsEnabled").is("true"); - ; - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify admin user gets a person with Rest API and response is successful") - public void adminUserChecksIfPersonIsPresent() throws Exception - { - personModel = restClient.authenticateUser(adminUser).withCoreAPI().usingUser(searchedUser).getPerson(); - restClient.assertStatusCodeIs(HttpStatus.OK); - personModel.assertThat().field("id").is(searchedUser.getUsername()).assertThat().field("firstName").is(searchedUser.getUsername() + " FirstName").and() - .field("email").is(searchedUser.getUsername() + domain).and().field("emailNotificationsEnabled").is("true"); - ; - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user gets a non existing person with Rest API and person is not found") - public void managerUserChecksIfNonExistingPersonIsPresent() throws Exception - { - UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); - UserModel searchedNonUser = new UserModel("nonexistinguser", DataUser.PASSWORD); - - restClient.authenticateUser(managerUser).withCoreAPI().usingUser(searchedNonUser).getPerson(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); - } -} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSiteMembershipCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSiteMembershipCoreTests.java deleted file mode 100644 index 22d5c0292..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSiteMembershipCoreTests.java +++ /dev/null @@ -1,114 +0,0 @@ -package org.alfresco.service.search.rest.people; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestSiteEntry; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser; -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; - -/** - * Created by Claudia Agache on 11/28/2016. - */ - -public class GetSiteMembershipCoreTests extends RestTest -{ - UserModel regularUser, publicSiteManager, privateSiteManager, moderatedSiteManager, adminUser; - SiteModel publicSite, privateSite, moderatedSite; - private DataUser.ListUserWithRoles publicSiteUsers; - private RestSiteEntry restSiteEntry; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - regularUser = dataUser.createRandomTestUser(); - privateSiteManager = dataUser.createRandomTestUser(); - moderatedSiteManager = dataUser.createRandomTestUser(); - publicSite = dataSite.usingAdmin().createPublicRandomSite(); - privateSite = dataSite.usingAdmin().createPrivateRandomSite(); - moderatedSite = dataSite.usingAdmin().createModeratedRandomSite(); - - publicSiteUsers = dataUser.addUsersWithRolesToSite(publicSite, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - publicSiteManager = publicSiteUsers.getOneUserWithRole(UserRole.SiteManager); - dataUser.usingAdmin().addUserToSite(privateSiteManager, privateSite, UserRole.SiteManager); - dataUser.usingAdmin().addUserToSite(moderatedSiteManager, moderatedSite, UserRole.SiteManager); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) -// @Bug(id = "REPO-1642", description = "reproduced on 5.2.1 only, it works on 5.2.0") - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify get site membership for a site returns status 404 when personId does not exist.") - public void getSiteMembershipUsingNonExistentPersonId() throws Exception - { - UserModel someUser = new UserModel("someUser", DataUser.PASSWORD); - - restClient.authenticateUser(regularUser).withCoreAPI().usingUser(someUser).getSiteMembership(publicSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "someUser")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify get site membership for a site returns status 404 when siteId does not exist.") - public void getSiteMembershipUsingNonExistentSiteId() throws Exception - { - SiteModel someSite = new SiteModel("someSite"); - - restClient.authenticateUser(regularUser).withCoreAPI().usingAuthUser().getSiteMembership(someSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, regularUser.getUsername(), "someSite")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify get site membership for a site returns status 404 when personId is not a site member.") - public void getSiteMembershipForPersonThatIsNotSiteMember() throws Exception - { - restClient.authenticateUser(publicSiteManager).withCoreAPI().usingUser(regularUser).getSiteMembership(publicSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, regularUser.getUsername(), publicSite.getTitle())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify regular user is not able to retrieve site membership information of a private site member.") - public void regularUserIsNotAbleToRetrieveSiteMembershipForPrivateSiteManager() throws Exception - { - restClient.authenticateUser(regularUser).withCoreAPI().usingUser(privateSiteManager).getSiteMembership(privateSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, privateSiteManager.getUsername(), privateSite.getTitle())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify regular user is able to retrieve site membership information of a moderated site member.") - public void regularUserGetsSiteMembershipForModeratedSiteMember() throws Exception - { - restSiteEntry = restClient.authenticateUser(regularUser).withCoreAPI().usingUser(moderatedSiteManager).getSiteMembership(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteEntry.assertThat().field("role").is(UserRole.SiteManager).and().field("id").is(moderatedSite.getId()).and().field("site").isNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify if Admin user is able to retrieve site membership information of him.") - public void adminGetsSiteMembershipForHim() throws Exception - { - restSiteEntry = restClient.authenticateUser(adminUser).withCoreAPI().usingUser(adminUser).getSiteMembership(privateSite); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteEntry.assertThat().field("role").is(UserRole.SiteManager).and().field("id").is(privateSite.getId()).and().field("site").isNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify if Admin user is able to retrieve site membership information of him.") - public void getSiteMembershipAfterRemovingASiteMember() throws Exception - { - UserModel publicSiteConsumer = publicSiteUsers.getOneUserWithRole(UserRole.SiteConsumer); - restClient.authenticateUser(publicSiteManager).withCoreAPI().usingSite(publicSite).deleteSiteMember(publicSiteConsumer); - restClient.authenticateUser(publicSiteManager).withCoreAPI().usingUser(publicSiteConsumer).getSiteMembership(publicSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, publicSiteConsumer.getUsername(), publicSite.getTitle())); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSiteMembershipFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSiteMembershipFullTests.java deleted file mode 100644 index 30b8a4771..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSiteMembershipFullTests.java +++ /dev/null @@ -1,138 +0,0 @@ -package org.alfresco.service.search.rest.people; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestSiteEntry; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class GetSiteMembershipFullTests extends RestTest -{ - UserModel regularUser, adminUser; - SiteModel publicSite, moderatedSite; - private DataUser.ListUserWithRoles publicSiteUsers; - private RestSiteEntry restSiteEntry; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - regularUser = dataUser.createRandomTestUser(); - publicSite = dataSite.usingAdmin().createPublicRandomSite(); - moderatedSite = dataSite.usingAdmin().createModeratedRandomSite(); - - publicSiteUsers = dataUser.addUsersWithRolesToSite(publicSite, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify that properties parameter is applied.") - public void checkThatPropertiesParameterIsApplied() throws Exception - { - restSiteEntry = restClient.authenticateUser(regularUser).withCoreAPI().usingParams("properties=site,role,id") - .usingUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteManager)).getSiteMembership(publicSite); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteEntry.assertThat().field("role").is(UserRole.SiteManager) - .and().field("id").is(publicSite.getId()) - .and().field("site").isNotEmpty() - .and().field("guid").isNull(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify that regular user " - + "is able to retrieve site membership information of admin.") - public void regularUserGetsSiteMembershipForAdmin() throws Exception - { - restSiteEntry = restClient.authenticateUser(regularUser).withCoreAPI().usingUser(adminUser).getSiteMembership(publicSite); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteEntry.assertThat().field("role").is(UserRole.SiteManager) - .and().field("id").is(publicSite.getId()) - .and().field("site.id").is(publicSite.getId()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify that regular user " - + "is able to retrieve site membership details for a Collaborator role.") - public void getSiteMembershipDetailsForACollaboratorRole() throws Exception - { - restSiteEntry = restClient.authenticateUser(regularUser).withCoreAPI() - .usingUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)).getSiteMembership(publicSite); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteEntry.assertThat().field("role").is(UserRole.SiteCollaborator) - .and().field("guid").is(publicSite.getGuid()) - .and().field("id").is(publicSite.getId()) - .and().field("site.visibility").is(publicSite.getVisibility().toString()) - .and().field("site.guid").is(publicSite.getGuid()) - .and().field("site.description").is(publicSite.getDescription()) - .and().field("site.id").is(publicSite.getId()) - .and().field("site.preset").is("site-dashboard") - .and().field("site.title").is(publicSite.getTitle()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify that regular user " - + "is able to retrieve site membership details for a Contributor role.") - public void getSiteMembershipDetailsForAContributorRole() throws Exception - { - restSiteEntry = restClient.authenticateUser(regularUser).withCoreAPI() - .usingUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteContributor)).getSiteMembership(publicSite); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteEntry.assertThat().field("role").is(UserRole.SiteContributor) - .and().field("id").is(publicSite.getId()) - .and().field("site").isNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify that regular user " - + "is able to retrieve site membership details for a Consumer role.") - public void getSiteMembershipDetailsForAConsumerRole() throws Exception - { - restSiteEntry = restClient.authenticateUser(regularUser).withCoreAPI() - .usingUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteConsumer)).getSiteMembership(publicSite); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteEntry.assertThat().field("role").is(UserRole.SiteConsumer) - .and().field("id").is(publicSite.getId()) - .and().field("site").isNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "As regular user make a request to join a moderated site." - + " The request is pending. Check membership details.") - public void pendingRequestToASiteCheckMembershipDetails() throws Exception - { - restClient.authenticateUser(regularUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restSiteEntry = restClient.authenticateUser(adminUser).withCoreAPI() - .usingUser(regularUser).getSiteMembership(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, regularUser.getUsername(), moderatedSite.getTitle())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "As Collaborator user leave site and perform get call." - + "Check default error model schema.") - public void leaveSiteAndPerformGetCallCheckDefaultErrorModelSchema() throws Exception - { - UserModel leaveSiteUser = dataUser.createRandomTestUser(); - dataUser.addUserToSite(leaveSiteUser, publicSite, UserRole.SiteCollaborator); - restClient.authenticateUser(leaveSiteUser).withCoreAPI().usingAuthUser().deleteSiteMember(publicSite); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restSiteEntry = restClient.authenticateUser(adminUser).withCoreAPI() - .usingUser(leaveSiteUser).getSiteMembership(publicSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, leaveSiteUser.getUsername(), publicSite.getTitle())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSiteMembershipSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSiteMembershipSanityTests.java deleted file mode 100644 index e1639d7e3..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSiteMembershipSanityTests.java +++ /dev/null @@ -1,90 +0,0 @@ -package org.alfresco.service.search.rest.people; - -import org.alfresco.service.search.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; - -public class GetSiteMembershipSanityTests extends RestTest -{ - private SiteModel siteModel; - private UserModel adminUser; - private ListUserWithRoles usersWithRoles; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws DataPreparationException - { - adminUser = dataUser.getAdminUser(); - siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); - - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site manager is able to retrieve site membership information of another user") - public void siteManagerCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingUser(adminUser).getSiteMembership(siteModel) - .assertThat().field("role").is(UserRole.SiteManager).and().field("id").is(siteModel.getId()).and().field("site").isNotEmpty(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site collaborator is able to retrieve site membership information of another user") - public void siteCollaboratorCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingUser(adminUser) - .getSiteMembership(siteModel).onSite().assertThat().field("role").is(UserRole.SiteCollaborator).and().field("id").is(siteModel.getId()); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site contributor is able to retrieve site membership information of another user") - public void siteContributorCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingUser(adminUser) - .getSiteMembership(siteModel).assertThat().field("role").is(UserRole.SiteManager).and().field("id").is(siteModel.getId()).and().field("site") - .isNotEmpty(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site consumer is able to retrieve site membership information of another user") - public void siteConsumerCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingUser(adminUser).getSiteMembership(siteModel) - .assertThat().field("role").is(UserRole.SiteManager).and().field("id").is(siteModel.getId()).and().field("site").isNotEmpty(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify admin user is able to retrieve site membership information of another user") - public void adminCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUser).withCoreAPI().usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).getSiteMembership(siteModel) - .assertThat().field("role").is(UserRole.SiteManager).and().field("id").is(siteModel.getId()).and().field("site").isNotEmpty(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to retrieve site membership information of another user") -// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void unauthenticatedUserCannotRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(new UserModel("random user", "random password")).withCoreAPI() - .usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).getSiteMembership(siteModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } -} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSitesMembershipInformationCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSitesMembershipInformationCoreTests.java deleted file mode 100644 index 21c503948..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSitesMembershipInformationCoreTests.java +++ /dev/null @@ -1,136 +0,0 @@ -package org.alfresco.service.search.rest.people; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.utility.constants.UserRole; -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; - -public class GetSitesMembershipInformationCoreTests extends RestTest -{ - private SiteModel publicSiteModel; - private SiteModel moderatedSiteModel; - private SiteModel privateSiteModel; - private UserModel userModel; - UserModel leaveSiteUserModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws DataPreparationException - { - userModel = dataUser.createRandomTestUser(); - leaveSiteUserModel = dataUser.createRandomTestUser(); - publicSiteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - moderatedSiteModel = dataSite.usingUser(userModel).createModeratedRandomSite(); - privateSiteModel = dataSite.usingUser(userModel).createPrivateRandomSite(); - dataUser.addUserToSite(leaveSiteUserModel, publicSiteModel, UserRole.SiteCollaborator); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site manager is not able to retrieve site membership information for a personId that does not exist") - public void siteManagerCantRetrieveSiteMembershipInformationForAPersonIdThatDoesNotExist() throws Exception - { - restClient.authenticateUser(userModel).withCoreAPI().usingUser(new UserModel("invalidPersonId", "password")).getSitesMembershipInformation() - .assertThat().entriesListIsEmpty(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - restClient.assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidPersonId")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify if get site membership information request returns status code 400 when invalid maxItems parameter is used") - public void getSiteMembershipInformationRequestReturns400ForInvalidMaxItemsParameter() throws Exception - { - restClient.authenticateUser(userModel).withParams("maxItems=0").withCoreAPI().usingAuthUser().getSitesMembershipInformation().assertThat() - .entriesListIsEmpty(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - restClient.assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); - - restClient.withParams("maxItems=-1").withCoreAPI().usingAuthUser().getSitesMembershipInformation().assertThat().entriesListIsEmpty(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - restClient.assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); - - restClient.withParams("maxItems=test").withCoreAPI().usingAuthUser().getSitesMembershipInformation().assertThat().entriesListIsEmpty(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - restClient.assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "test")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify if get site membership information request returns status code 200 for valid maxItems parameter") - public void getSiteMembershipInformationRequestReturns200ForValidMaxItemsParameter() throws Exception - { - restClient.authenticateUser(userModel).withParams("maxItems=5").withCoreAPI().usingAuthUser().getSitesMembershipInformation().assertThat() - .entriesListIsNotEmpty().getPagination().assertThat().field("maxItems").is("5"); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify if get site membership information request returns status code 400 when invalid skipCount parameter is used") - public void getSiteMembershipInformationRequestReturns400ForInvalidSkipCountParameter() throws Exception - { - restClient.authenticateUser(userModel).withParams("skipCount=-1").withCoreAPI().usingAuthUser().getSitesMembershipInformation().assertThat() - .entriesListIsEmpty(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - restClient.assertLastError().containsSummary(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT); - - restClient.withParams("skipCount=test").withCoreAPI().usingAuthUser().getSitesMembershipInformation().assertThat().entriesListIsEmpty(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - restClient.assertLastError().containsErrorKey(String.format(RestErrorModel.INVALID_SKIPCOUNT, "test")) - .containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "test")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify if get site membership information request returns status code 200 for valid skipCount parameter") - public void getSiteMembershipInformationRequestReturns200ForValidSkipCountParameter() throws Exception - { - restClient.authenticateUser(userModel).withParams("skipCount=1").withCoreAPI().usingAuthUser().getSitesMembershipInformation().assertThat() - .entriesListIsNotEmpty().getPagination().assertThat().field("skipCount").is("1"); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site manager is able to retrieve public sites") - public void siteManagerCheckThatPublicSitesAreRetrieved() throws Exception - { - restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().getSitesMembershipInformation().assertThat() - .entriesListContains("id", publicSiteModel.getId()); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site manager is able to retrieve moderated sites") - public void siteManagerCheckThatModeratedSitesAreRetrieved() throws Exception - { - restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().getSitesMembershipInformation().assertThat() - .entriesListContains("id", moderatedSiteModel.getId()); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site manager is able to retrieve private sites") - public void siteManagerCheckThatPrivateSitesAreRetrieved() throws Exception - { - restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().getSitesMembershipInformation().assertThat() - .entriesListContains("id", privateSiteModel.getId()); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site member is able to leave site") - public void siteMemberIsAbleToLeaveSite() throws Exception - { - restClient.authenticateUser(leaveSiteUserModel).withCoreAPI().usingAuthUser().deleteSiteMember(publicSiteModel); - restClient.authenticateUser(leaveSiteUserModel).withCoreAPI().usingAuthUser().getSitesMembershipInformation().assertThat().entriesListIsEmpty(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSitesMembershipInformationFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSitesMembershipInformationFullTests.java deleted file mode 100644 index 26278e8f7..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSitesMembershipInformationFullTests.java +++ /dev/null @@ -1,205 +0,0 @@ -package org.alfresco.service.search.rest.people; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestSiteMembershipModelsCollection; -import org.alfresco.rest.model.RestTaskModel; -import org.alfresco.utility.constants.UserRole; -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 Cristina Axinte - * - */ -public class GetSitesMembershipInformationFullTests extends RestTest -{ - private SiteModel publicSiteModel; - private SiteModel moderatedSiteModel; - private SiteModel privateSiteModel; - private SiteModel anotherUserSite; - private UserModel userModel, adminUser, anotherUserModel; - private RestSiteMembershipModelsCollection sitesMembershipInformation; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws DataPreparationException - { - adminUser = dataUser.getAdminUser(); - anotherUserSite = dataSite.usingUser(adminUser).createPublicRandomSite(); - userModel = dataUser.createRandomTestUser(); - anotherUserModel = dataUser.createRandomTestUser(); - publicSiteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); - dataUser.addUserToSite(userModel, publicSiteModel, UserRole.SiteCollaborator); - moderatedSiteModel = dataSite.usingUser(adminUser).createModeratedRandomSite(); - dataUser.addUserToSite(userModel, moderatedSiteModel, UserRole.SiteConsumer); - privateSiteModel = dataSite.usingUser(userModel).createPrivateRandomSite(); - dataUser.addUserToSite(anotherUserModel, anotherUserSite, UserRole.SiteCollaborator); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify if get site membership information request returns status code 200 for valid properties parameter") - public void getSiteMembershipInformationUsingPropertiesParameter() throws Exception - { - sitesMembershipInformation = restClient.authenticateUser(userModel).withParams("properties=id").withCoreAPI().usingAuthUser().getSitesMembershipInformation(); - restClient.assertStatusCodeIs(HttpStatus.OK); - sitesMembershipInformation.assertThat().entriesListIsNotEmpty().getPagination().assertThat().field("count").is("3"); - sitesMembershipInformation.assertThat().entriesListContains("id", publicSiteModel.getId()) - .and().entriesListContains("id", moderatedSiteModel.getId()) - .and().entriesListContains("id", privateSiteModel.getId()) - .and().entriesListDoesNotContain("site") - .and().entriesListDoesNotContain("role") - .and().entriesListDoesNotContain("guid"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify if get site membership information request returns status code 200 for order ASC by parameter") - public void getSiteMembershipInformationUsingOrderAscByParameter() throws Exception - { - sitesMembershipInformation = restClient.authenticateUser(userModel).withParams("orderBy=id ASC").withCoreAPI().usingAuthUser().getSitesMembershipInformation(); - restClient.assertStatusCodeIs(HttpStatus.OK); - sitesMembershipInformation.assertThat().entriesListIsNotEmpty().getPagination().assertThat().field("count").is("3"); - sitesMembershipInformation.assertThat().entriesListIsSortedAscBy("id"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify if get site membership information request returns status code 200 for order DESC by parameter") - public void getSiteMembershipInformationUsingOrderDescByParameter() throws Exception - { - sitesMembershipInformation = restClient.authenticateUser(userModel).withParams("orderBy=id Desc").withCoreAPI().usingAuthUser().getSitesMembershipInformation(); - restClient.assertStatusCodeIs(HttpStatus.OK); - sitesMembershipInformation.assertThat().entriesListIsNotEmpty().getPagination().assertThat().field("count").is("3"); - sitesMembershipInformation.assertThat().entriesListIsSortedDescBy("id"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify if get site membership information request returns status code 200 for order by role parameter") - public void getSiteMembershipInformationUsingOrderByRoleParameter() throws Exception - { - sitesMembershipInformation = restClient.authenticateUser(userModel).withParams("orderBy=role").withCoreAPI().usingAuthUser().getSitesMembershipInformation(); - restClient.assertStatusCodeIs(HttpStatus.OK); - sitesMembershipInformation.assertThat().entriesListIsNotEmpty().getPagination().assertThat().field("count").is("3"); - sitesMembershipInformation.assertThat().entriesListIsSortedAscBy("role"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify if user gets site membership information of another user successfully") - public void userCanGetSiteMembershipInformationOfAnotherUser() throws Exception - { - sitesMembershipInformation = restClient.authenticateUser(userModel).withCoreAPI().usingUser(anotherUserModel).getSitesMembershipInformation(); - restClient.assertStatusCodeIs(HttpStatus.OK); - sitesMembershipInformation.assertThat().entriesListIsNotEmpty().getPagination().assertThat().field("count").is("1"); - sitesMembershipInformation.getEntries().get(0).onModel() - .assertThat().field("site.visibility").is(anotherUserSite.getVisibility().toString()) - .and().field("site.guid").is(anotherUserSite.getGuid()) - .and().field("site.description").is(anotherUserSite.getDescription()) - .and().field("site.id").is(anotherUserSite.getId()) - .and().field("site.preset").is("site-dashboard") - .and().field("site.title").is(anotherUserSite.getTitle()) - .and().field("id").is(anotherUserSite.getId()) - .and().field("guid").is(anotherUserSite.getGuid()) - .and().field("role").is(UserRole.SiteCollaborator.toString()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify if get site membership information request returns status code 200 for relations parameter") - public void getSiteMembershipInformationUsingRelationsParameter() throws Exception - { - sitesMembershipInformation = restClient.authenticateUser(userModel).withParams("relations=site-membership-requests").withCoreAPI().usingAuthUser().getSitesMembershipInformation(); - restClient.assertStatusCodeIs(HttpStatus.OK); - sitesMembershipInformation.assertThat().entriesListIsNotEmpty().getPagination().assertThat().field("count").is("3"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify get site membership information request when a site membership request is rejected") - public void getSiteMembershipInformationWhenASiteRequestIsRejected() throws Exception - { - UserModel userWithRequests = dataUser.createRandomTestUser(); - - restClient.authenticateUser(userWithRequests).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSiteModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - sitesMembershipInformation = restClient.authenticateUser(adminUser).withCoreAPI().usingUser(userWithRequests).getSitesMembershipInformation(); - restClient.assertStatusCodeIs(HttpStatus.OK); - sitesMembershipInformation.assertThat().entriesListIsEmpty() - .and().paginationField("count").is("0"); - - RestTaskModel taskModel = restClient.authenticateUser(userWithRequests).withWorkflowAPI().getTasks().getTaskModelByDescription(moderatedSiteModel); - workflow.approveSiteMembershipRequest(adminUser.getUsername(), adminUser.getPassword(), taskModel.getId(), false, "Rejected"); - - sitesMembershipInformation = restClient.authenticateUser(adminUser).withCoreAPI().usingUser(userWithRequests).getSitesMembershipInformation(); - restClient.assertStatusCodeIs(HttpStatus.OK); - sitesMembershipInformation.assertThat().entriesListIsEmpty() - .and().paginationField("count").is("0"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify get site membership information request when a site membership request is approved") - public void getSiteMembershipInformationWhenASiteRequestIsAppropved() throws Exception - { - UserModel userWithRequests = dataUser.createRandomTestUser(); - - restClient.authenticateUser(userWithRequests).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSiteModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - sitesMembershipInformation = restClient.authenticateUser(adminUser).withCoreAPI().usingUser(userWithRequests).getSitesMembershipInformation(); - restClient.assertStatusCodeIs(HttpStatus.OK); - sitesMembershipInformation.assertThat().entriesListIsEmpty() - .and().paginationField("count").is("0"); - - RestTaskModel taskModel = restClient.authenticateUser(userWithRequests).withWorkflowAPI().getTasks().getTaskModelByDescription(moderatedSiteModel); - workflow.approveSiteMembershipRequest(adminUser.getUsername(), adminUser.getPassword(), taskModel.getId(), true, "Approve"); - - sitesMembershipInformation = restClient.authenticateUser(adminUser).withCoreAPI().usingUser(userWithRequests).getSitesMembershipInformation(); - restClient.assertStatusCodeIs(HttpStatus.OK); - sitesMembershipInformation.assertThat().entriesListIsNotEmpty() - .and().entriesListContains("role", UserRole.SiteConsumer.toString()) - .and().entriesListContains("guid", moderatedSiteModel.getGuid()) - .and().entriesListContains("id", moderatedSiteModel.getId()) - .and().paginationField("count").is("1"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify if get site membership information request returns status code 200 for valid maxItems parameter") - public void getSiteMembershipInformationUsingMaxItemsParameter() throws Exception - { - sitesMembershipInformation = restClient.authenticateUser(userModel).withParams("maxItems=2").withCoreAPI().usingAuthUser().getSitesMembershipInformation(); - restClient.assertStatusCodeIs(HttpStatus.OK); - sitesMembershipInformation.assertThat().entriesListCountIs(2) - .getPagination().assertThat().field("count").is("2") - .and().field("hasMoreItems").is("true") - .and().field("totalItems").is("3") - .and().field("skipCount").is("0") - .and().field("maxItems").is("2"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify if get site membership information request returns status code 200 for valid skipCount parameter") - public void getSiteMembershipInformationUsingSkipCountParameter() throws Exception - { - sitesMembershipInformation = restClient.authenticateUser(userModel).withParams("skipCount=2").withCoreAPI().usingAuthUser().getSitesMembershipInformation(); - restClient.assertStatusCodeIs(HttpStatus.OK); - sitesMembershipInformation.assertThat().entriesListCountIs(1) - .getPagination().assertThat().field("count").is("1") - .and().field("hasMoreItems").is("false") - .and().field("totalItems").is("3") - .and().field("skipCount").is("2") - .and().field("maxItems").is("100"); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSitesMembershipInformationSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSitesMembershipInformationSanityTests.java deleted file mode 100644 index 53b9c935f..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/GetSitesMembershipInformationSanityTests.java +++ /dev/null @@ -1,89 +0,0 @@ -package org.alfresco.service.search.rest.people; - -import org.alfresco.service.search.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; - -public class GetSitesMembershipInformationSanityTests extends RestTest -{ - private SiteModel siteModel; - private UserModel adminUser; - private ListUserWithRoles usersWithRoles; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws DataPreparationException - { - adminUser = dataUser.getAdminUser(); - siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site manager is able to retrieve sites membership information of another user") - public void siteManagerIsAbleToRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingUser(adminUser).getSitesMembershipInformation() - .assertThat().entriesListIsNotEmpty().and().paginationExist().and().paginationField("count").isNot("0"); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site collaborator is able to retrieve sites membership information of another user") - public void siteCollaboratorIsAbleToRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingUser(adminUser) - .getSitesMembershipInformation().assertThat().entriesListIsNotEmpty().and().paginationExist().and().paginationField("count").isNot("0"); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site contributor is able to retrieve sites membership information of another user") - public void siteContributorIsAbleToRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingUser(adminUser) - .getSitesMembershipInformation().assertThat().entriesListIsNotEmpty().and().paginationExist().and().paginationField("count").isNot("0"); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site consumer is able to retrieve sites membership information of another user") - public void siteConsumerIsAbleToRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingUser(adminUser) - .getSitesMembershipInformation().assertThat().entriesListIsNotEmpty().and().paginationExist().and().paginationField("count").isNot("0"); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify admin is able to retrieve sites membership information of another user") - public void siteAdminIsAbleToRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUser).withCoreAPI().usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).getSitesMembershipInformation() - .assertThat().entriesListIsNotEmpty().and().paginationExist().and().paginationField("count").isNot("0"); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify that unauthenticated user is not able to retrieve sites membership information") -// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void unauthenticatedUserCannotRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception - { - UserModel inexistentUser = new UserModel("inexistent user", "wrong password"); - restClient.authenticateUser(inexistentUser).withCoreAPI().usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .getSitesMembershipInformation(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } -} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/activities/GetPeopleActivitiesCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/activities/GetPeopleActivitiesCoreTests.java deleted file mode 100644 index af25befea..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/activities/GetPeopleActivitiesCoreTests.java +++ /dev/null @@ -1,126 +0,0 @@ -package org.alfresco.service.search.rest.people.activities; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestActivityModelsCollection; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * - * @author Cristina Axinte - * - */ -public class GetPeopleActivitiesCoreTests extends RestTest -{ - UserModel userModel, adminUser, managerUser; - SiteModel siteModel1, siteModel2; - FileModel fileInSite1, fileInSite2; - FolderModel folderInSite2; - private RestActivityModelsCollection restActivityModelsCollection; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userModel = dataUser.createRandomTestUser(); - siteModel1 = dataSite.usingUser(userModel).createPublicRandomSite(); - fileInSite1 = dataContent.usingUser(userModel).usingSite(siteModel1).createContent(DocumentType.TEXT_PLAIN); - - siteModel2 = dataSite.usingUser(userModel).createPublicRandomSite(); - folderInSite2 = dataContent.usingUser(userModel).usingSite(siteModel2).createFolder(); - fileInSite2 = dataContent.usingAdmin().usingSite(siteModel2).createContent(DocumentType.TEXT_PLAIN); - - managerUser = dataUser.createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel2, UserRole.SiteManager); - - // only once the activity list is checked with retry in order not to wait the entire list in each test - restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingMe().getPersonActivitiesUntilEntriesCountIs(4); - restClient.assertStatusCodeIs(HttpStatus.OK); - restActivityModelsCollection.assertThat().paginationField("count").is("4"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot get activities for inexistent user with Rest API and response is 404") - public void userCannotGetPeopleActivitiesForInexistentPersonId() throws Exception - { - UserModel inexistentUserName = new UserModel("inexistent", "password"); - - restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingUser(inexistentUserName).getPersonActivities(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, inexistentUserName.getUsername())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its activities for inexistent siteId with Rest API and response is 404") - public void userGetItsPeopleActivitiesForInexistentSite() throws Exception - { - restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingUser(userModel).usingParams(String.format("siteId=inexistent")).getPersonActivities(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "inexistent")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities with invald skipCount parameter with Rest API and response is 400") - public void userGetPeopleActivitiesUsingInvalidSkipCountParameter() throws Exception - { - restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingMe().usingParams("skipCount=-1").getPersonActivities(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsErrorKey(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT) - .containsSummary(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities with invalid maxItems parameter with Rest API and response is 400") - public void userGetPeopleActivitiesUsingInvalidMaxItemsParameter() throws Exception - { - restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingMe().usingParams("maxItems=0").getPersonActivities(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsErrorKey(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) - .containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities using invalid value for parameter 'who'with Rest API and response is 400") - public void userGetsPeopleActivitiesUsingInvalidValueForWhoParameter() throws Exception - { - restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingUser(userModel).usingParams("who=mee").getPersonActivities(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsErrorKey(RestErrorModel.INVALID_PARAMETER_WHO) - .containsSummary(RestErrorModel.INVALID_PARAMETER_WHO) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities successfully using parameter 'who' with 'others' value with Rest API") - public void userGetsPeopleActivitiesUsingOthersForWhoParameter() throws Exception - { - restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingUser(userModel).usingParams("who=others").getPersonActivities(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restActivityModelsCollection.assertThat().paginationField("count").is("2"); - restActivityModelsCollection.assertThat().entriesListDoesNotContain("postPersonId", userModel.getUsername().toLowerCase()) - .and().entriesListContains("postPersonId", adminUser.getUsername().toLowerCase()) - .and().entriesListContains("postPersonId", managerUser.getUsername().toLowerCase()); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/activities/GetPeopleActivitiesFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/activities/GetPeopleActivitiesFullTests.java deleted file mode 100644 index 6e31e1b6a..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/activities/GetPeopleActivitiesFullTests.java +++ /dev/null @@ -1,184 +0,0 @@ -package org.alfresco.service.search.rest.people.activities; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestActivityModel; -import org.alfresco.rest.model.RestActivityModelsCollection; -import org.alfresco.rest.model.RestActivitySummaryModel; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -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 Cristina Axinte - * - */ -public class GetPeopleActivitiesFullTests extends RestTest -{ - UserModel userModel, adminUser, managerUser; - SiteModel siteModel1, siteModel2; - FileModel fileInSite1, fileInSite2; - FolderModel folderInSite2; - private RestActivityModelsCollection restActivityModelsCollection; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userModel = dataUser.createRandomTestUser(); - siteModel1 = dataSite.usingUser(userModel).createPublicRandomSite(); - fileInSite1 = dataContent.usingUser(userModel).usingSite(siteModel1).createContent(DocumentType.TEXT_PLAIN); - - siteModel2 = dataSite.usingUser(userModel).createPublicRandomSite(); - folderInSite2 = dataContent.usingUser(userModel).usingSite(siteModel2).createFolder(); - fileInSite2 = dataContent.usingAdmin().usingSite(siteModel2).createContent(DocumentType.TEXT_PLAIN); - - managerUser = dataUser.createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel2, UserRole.SiteManager); - - // only once the activity list is checked with retry in order not to wait the entire list in each test - restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingMe().getPersonActivitiesUntilEntriesCountIs(4); - restClient.assertStatusCodeIs(HttpStatus.OK); - restActivityModelsCollection.assertThat().paginationField("count").is("4"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify activity summary from user gets activities response with Rest API") - public void userGetPeopleActivitiesWithActivitySummaryCheck() throws Exception - { - restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingMe().usingParams(String.format("siteId=%s", siteModel1.getId())).getPersonActivities(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restActivityModelsCollection.assertThat().paginationField("count").is("1"); - RestActivitySummaryModel summary = restActivityModelsCollection.getEntries().get(0).onModel().getActivitySummary(); - summary.assertThat().field("firstName").is(userModel.getUsername() + " FirstName") - .and().field("lastName").is("LN-" + userModel.getUsername()) - .and().field("title").is(fileInSite1.getName()) - .and().field("objectId").is(fileInSite1.getNodeRefWithoutVersion()); - } - - @Bug(id = "REPO-1911") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE,TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot get activities for empty user with Rest API and response is 400") - public void userCannotGetPeopleActivitiesForEmptyPersonId() throws Exception - { - UserModel emptyUserName = new UserModel("", "password"); - - restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingUser(emptyUserName).getPersonActivities(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .containsSummary(RestErrorModel.LOCAL_NAME_CONSISTANCE) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE,TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its activities for siteId specified in siteId parameter using me with Rest API and response is successful") - public void userGetItsPeopleActivitiesForASpecificSite() throws Exception - { - restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingUser(userModel).usingParams(String.format("siteId=%s", siteModel1.getId())).getPersonActivities(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restActivityModelsCollection.assertThat().paginationField("count").is("1"); - restActivityModelsCollection.assertThat().entriesListContains("siteId", siteModel1.getId()) - .and().entriesListDoesNotContain("siteId", siteModel2.getId()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities for user with no activities with Rest API and response is successful") - public void userGetPeopleActivitiesForUserWithNoActivities() throws Exception - { - UserModel userNoActivities = dataUser.createRandomTestUser(); - dataSite.usingUser(userNoActivities).createPublicRandomSite(); - - restActivityModelsCollection = restClient.authenticateUser(adminUser).withCoreAPI().usingUser(userNoActivities).getPersonActivities(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restActivityModelsCollection.assertThat().paginationField("count").is("0"); - restActivityModelsCollection.assertThat().entriesListIsEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot get activities for siteId that user doesn't have access to with Rest API and response is not found") - public void userGetPeopleActivitiesForASiteWithNoAccess() throws Exception - { - SiteModel siteNoAccess = dataSite.usingUser(managerUser).createPrivateRandomSite(); - - restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingUser(userModel).usingParams(String.format("siteId=%s", siteNoAccess.getId())).getPersonActivities(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - restClient.assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, siteNoAccess.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot get activities for another user with Rest API and response is permission denied") - public void userGetPeopleActivitiesForAnotherUser() throws Exception - { - restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingUser(managerUser).getPersonActivities(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - restClient.assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities with properties parameter applied with Rest API and response is successful") - public void userGetPeopleActivitiesUsingPropertiesParameter() throws Exception - { - restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingMe().usingParams("properties=postPersonId").getPersonActivities(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restActivityModelsCollection.assertThat().paginationField("count").is("4"); - restActivityModelsCollection.assertThat().entriesListContains("postPersonId", userModel.getUsername().toLowerCase()) - .and().entriesListContains("postPersonId", adminUser.getUsername().toLowerCase()) - .and().entriesListContains("postPersonId", managerUser.getUsername().toLowerCase()) - .and().entriesListDoesNotContain("postedAt") - .and().entriesListDoesNotContain("feedPersonId") - .and().entriesListDoesNotContain("siteId") - .and().entriesListDoesNotContain("activitySummary") - .and().entriesListDoesNotContain("id") - .and().entriesListDoesNotContain("activityType"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities with skipCount parameter applied with Rest API and response is successful") - public void userGetPeopleActivitiesUsingSkipCountParameter() throws Exception - { - restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingMe().getPersonActivities(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restActivityModelsCollection.assertThat().paginationField("count").is("4"); - RestActivityModel expectedRestActivity3 = restActivityModelsCollection.getEntries().get(2).onModel(); - RestActivityModel expectedRestActivity4 = restActivityModelsCollection.getEntries().get(3).onModel(); - - restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingMe().usingParams("skipCount=2").getPersonActivities(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restActivityModelsCollection.assertThat().paginationField("count").is("2"); - restActivityModelsCollection.getEntries().get(0).onModel().assertThat().field("postPersonId").is(expectedRestActivity3.getPostPersonId()) - .and().field("activityType").is(expectedRestActivity3.getActivityType()); - restActivityModelsCollection.getEntries().get(1).onModel().assertThat().field("postPersonId").is(expectedRestActivity4.getPostPersonId()) - .and().field("activityType").is(expectedRestActivity4.getActivityType()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets activities with maxItems parameter applied with Rest API and response is successful") - public void userGetPeopleActivitiesUsingMaxItemsParameter() throws Exception - { - restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingMe().getPersonActivities(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restActivityModelsCollection.assertThat().paginationField("count").is("4"); - RestActivityModel expectedRestActivity1 = restActivityModelsCollection.getEntries().get(0).onModel(); - RestActivityModel expectedRestActivity2 = restActivityModelsCollection.getEntries().get(1).onModel(); - - restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingMe().usingParams("maxItems=2").getPersonActivities(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restActivityModelsCollection.assertThat().paginationField("count").is("2"); - restActivityModelsCollection.getEntries().get(0).onModel().assertThat().field("postPersonId").is(expectedRestActivity1.getPostPersonId()) - .and().field("activityType").is(expectedRestActivity1.getActivityType()); - restActivityModelsCollection.getEntries().get(1).onModel().assertThat().field("postPersonId").is(expectedRestActivity2.getPostPersonId()) - .and().field("activityType").is(expectedRestActivity2.getActivityType()); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/activities/GetPeopleActivitiesSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/activities/GetPeopleActivitiesSanityTests.java deleted file mode 100644 index f31460a15..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/activities/GetPeopleActivitiesSanityTests.java +++ /dev/null @@ -1,111 +0,0 @@ -package org.alfresco.service.search.rest.people.activities; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestActivityModelsCollection; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser; -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 Cristina Axinte - * Tests for getActivities (/people/{personId}/activities) RestAPI call - */ - -public class GetPeopleActivitiesSanityTests extends RestTest -{ - UserModel userModel, unauthenticatedUser; - SiteModel siteModel; - private DataUser.ListUserWithRoles usersWithRoles; - private RestActivityModelsCollection restActivityModelsCollection; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - unauthenticatedUser = dataUser.usingAdmin().createRandomTestUser(); - unauthenticatedUser.setPassword("newpassword"); - - // only once the activity list is checked with retry in order not to wait the entire list in each test - restActivityModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().getPersonActivitiesUntilEntriesCountIs(5); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.SANITY, description = "Verify manager user gets its activities with Rest API and response is successful") - public void managerUserShouldGetPeopleActivitiesList() throws Exception - { - UserModel managerUser = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); - dataContent.usingUser(managerUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - - restActivityModelsCollection = restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().getPersonActivities(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restActivityModelsCollection.assertThat().entriesListIsNotEmpty().and().entriesListContains("siteId", siteModel.getId()).and().paginationExist(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.SANITY, description = "Verify collaborator user gets its activities with Rest API and response is successful") - public void collaboratorUserShouldGetPeopleActivitiesList() throws Exception - { - UserModel collaboratorUser = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); - dataContent.usingUser(collaboratorUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - - restActivityModelsCollection = restClient.authenticateUser(collaboratorUser).withCoreAPI().usingAuthUser().getPersonActivities(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restActivityModelsCollection.assertThat().entriesListIsNotEmpty().and().entriesListContains("siteId", siteModel.getId()).and().paginationExist(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.ACTIVITIES }, executionType = ExecutionType.SANITY, description = "Verify contributor user gets its activities with Rest API and response is successful") - public void contributorUserShouldGetPeopleActivitiesList() throws Exception - { - UserModel contributorUser = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); - dataContent.usingUser(contributorUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - - restActivityModelsCollection = restClient.authenticateUser(contributorUser).withCoreAPI().usingAuthUser().getPersonActivities(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restActivityModelsCollection.assertThat().entriesListIsNotEmpty().and().entriesListContains("siteId", siteModel.getId()).and().paginationExist(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.ACTIVITIES }, executionType = ExecutionType.SANITY, description = "Verify consumer user gets its activities with Rest API and response is successful") - public void consumerUserShouldGetPeopleActivitiesList() throws Exception - { - UserModel consumerUser = usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer); - - restActivityModelsCollection = restClient.authenticateUser(consumerUser).withCoreAPI().usingAuthUser().getPersonActivities(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restActivityModelsCollection.assertThat().entriesListIsNotEmpty().and().entriesListContains("siteId", siteModel.getId()).and().paginationExist(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.ACTIVITIES }, executionType = ExecutionType.SANITY, description = "Verify admin user gets another user activities with Rest API and response is successful") - public void adminUserShouldGetPeopleActivitiesList() throws Exception - { - restActivityModelsCollection = restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingUser(userModel).getPersonActivities(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restActivityModelsCollection.assertThat().entriesListIsNotEmpty().and().entriesListContains("siteId", siteModel.getId()).and().paginationExist(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.ACTIVITIES }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is NOT Authorized to gets another user activities with Rest API") - public void unauthenticatedUserShouldNotGetPeopleActivitiesList() throws Exception - { - restClient.authenticateUser(unauthenticatedUser).withCoreAPI().usingUser(userModel).getPersonActivities(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError().containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferenceCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferenceCoreTests.java deleted file mode 100644 index 7dd7ad1cf..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferenceCoreTests.java +++ /dev/null @@ -1,78 +0,0 @@ -package org.alfresco.service.search.rest.people.preferences; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.utility.constants.PreferenceName; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class GetPeoplePreferenceCoreTests extends RestTest -{ - UserModel userModel; - SiteModel siteModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - dataSite.usingUser(userModel).usingSite(siteModel).addSiteToFavorites(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user is Forbidden to get a specific preference for another user with Rest API and response is 403") - public void userDoesNotHaveAccessToFavoriteSitesOfAnotherUser() throws Exception - { - UserModel secondUser = dataUser.createRandomTestUser(); - restClient.authenticateUser(secondUser).withCoreAPI().usingUser(userModel) - .getPersonPreferenceInformation(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - restClient.assertLastError().containsSummary("Permission was denied"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify manager fails to get a specific preference for an invalid user with Rest API and response is 404") - public void statusNotFoundIsReturnedForAPersonIDThatDoesNotExist() throws Exception - { - restClient.authenticateUser(userModel).withCoreAPI().usingUser(new UserModel("invalidPersonID", "password")) - .getPersonPreferenceInformation(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidPersonID")) - .statusCodeIs(HttpStatus.NOT_FOUND) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify manager fails to get a specific preference for an invalid preference with Rest API and response is 404") - public void statusNotFoundIsReturnedForAPreferenceNameThatDoesNotExist() throws Exception - { - restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().getPersonPreferenceInformation("invalidPreferenceName"); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - restClient.assertLastError().containsSummary( - String.format("The relationship resource was not found for the" + " entity with id: %s and a relationship id of invalidPreferenceName", - userModel.getUsername())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify manager fails to get a specific preference for removed preference with Rest API and response is 404") - public void statusNotFoundIsReturnedForAPreferenceNameThatHasBeenRemoved() throws Exception - { - SiteModel preferenceSite = dataSite.usingUser(userModel).createPublicRandomSite(); - dataSite.usingUser(userModel).usingSite(preferenceSite).addSiteToFavorites(); - dataSite.usingUser(userModel).usingSite(preferenceSite).removeSiteFromFavorites(); - restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser() - .getPersonPreferenceInformation(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), preferenceSite.getId())); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - restClient.assertLastError().containsSummary( - String.format("The relationship resource was not found for the" + " entity with id: %s and a relationship id of %s", userModel.getUsername(), - String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), preferenceSite.getId()))); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferenceFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferenceFullTests.java deleted file mode 100644 index ee07f650a..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferenceFullTests.java +++ /dev/null @@ -1,194 +0,0 @@ -package org.alfresco.service.search.rest.people.preferences; - -import java.nio.file.Paths; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestPreferenceModel; -import org.alfresco.utility.Utility; -import org.alfresco.utility.constants.PreferenceName; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FileType; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class GetPeoplePreferenceFullTests extends RestTest -{ - private UserModel userModel; - private SiteModel siteModel; - private RestPreferenceModel restPreferenceModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - dataSite.usingUser(userModel).usingSite(siteModel).addSiteToFavorites(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, - description = "Check that properties parameter is applied") - public void propertiesParameterIsAppliedWhenRetrievingPreference() throws Exception - { - restPreferenceModel = restClient.authenticateUser(userModel).withParams("properties=id").withCoreAPI().usingUser(userModel) - .getPersonPreferenceInformation(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())); - restClient.assertStatusCodeIs(HttpStatus.OK); - restPreferenceModel.assertThat().field("id").is(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())) - .and().field("value").isNull(); - - restPreferenceModel = restClient.authenticateUser(userModel).withParams("properties=id,value").withCoreAPI().usingUser(userModel) - .getPersonPreferenceInformation(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())); - restClient.assertStatusCodeIs(HttpStatus.OK); - restPreferenceModel.assertThat().field("id").is(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())) - .and().field("value").is("true"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, - description = "Validate ID element in get site preference response") - public void validateIdElementInGetSitePreferenceResponse() throws Exception - { - restPreferenceModel = restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser() - .getPersonPreferenceInformation(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())); - restPreferenceModel.assertThat().field("id").is(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())) - .and().field("value").is("true"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, - description = "Validate ID element in get folder preference response") - public void validateIdElementInGetFolderPreferenceResponse() throws Exception - { - FolderModel folderFavorite = new FolderModel("favoriteFolder"); - folderFavorite = dataContent.usingSite(siteModel).createFolder(folderFavorite); - dataContent.getContentActions().setFolderAsFavorite(userModel.getUsername(), userModel.getPassword(), siteModel.getId(), folderFavorite.getName()); - - restPreferenceModel = restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser() - .getPersonPreferenceInformation(PreferenceName.FOLDERS_FAVORITES_PREFIX.toString()); - restPreferenceModel.assertThat().field("id").is(PreferenceName.FOLDERS_FAVORITES_PREFIX) - .and().field("value").is(Utility.removeLastSlash(Utility.buildPath("workspace://SpacesStore", folderFavorite.getNodeRef()))); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, - description = "Validate ID element in get file preference response") - public void validateIdElementInGetFilePreferenceResponse() throws Exception - { - FileModel fileFavorite = new FileModel("favoriteFile", FileType.TEXT_PLAIN); - fileFavorite = dataContent.usingSite(siteModel).createContent(fileFavorite); - dataContent.getContentActions().setFileAsFavorite(userModel.getUsername(), userModel.getPassword(), siteModel.getId(), String.format("%s.%s", fileFavorite.getName(), fileFavorite.getFileType().extention)); - - restPreferenceModel = restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser() - .getPersonPreferenceInformation(PreferenceName.DOCUMENTS_FAVORITES_PREFIX.toString()); - restPreferenceModel.assertThat().field("id").is(PreferenceName.DOCUMENTS_FAVORITES_PREFIX) - .and().field("value").is(Utility.removeLastSlash(Utility.buildPath("workspace://SpacesStore", fileFavorite.getNodeRefWithoutVersion()))); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, - description = "Get preference of an user that has no preferences") - public void getPreferenceForUserWithoutPreferences() throws Exception - { - UserModel newUser = dataUser.createRandomTestUser(); - - restPreferenceModel = restClient.authenticateUser(newUser).withCoreAPI().usingAuthUser() - .getPersonPreferenceInformation(PreferenceName.DOCUMENTS_FAVORITES_PREFIX.toString()); - restClient.assertLastError().containsSummary( - String.format("The relationship resource was not found for the" + " entity with id: %s and a relationship id of %s", newUser.getUsername(), - PreferenceName.DOCUMENTS_FAVORITES_PREFIX.toString())); - - restPreferenceModel = restClient.authenticateUser(newUser).withCoreAPI().usingAuthUser() - .getPersonPreferenceInformation(PreferenceName.FOLDERS_FAVORITES_PREFIX.toString()); - restClient.assertLastError().containsSummary( - String.format("The relationship resource was not found for the" + " entity with id: %s and a relationship id of %s", newUser.getUsername(), - PreferenceName.FOLDERS_FAVORITES_PREFIX.toString())); - - restPreferenceModel = restClient.authenticateUser(newUser).withCoreAPI().usingAuthUser() - .getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX.toString()); - restClient.assertLastError().containsSummary( - String.format("The relationship resource was not found for the" + " entity with id: %s and a relationship id of %s", newUser.getUsername(), - PreferenceName.SITES_FAVORITES_PREFIX.toString())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, - description = "Change one preference for an user then perform get call") - @Bug(id = "REPO-1922") - public void changePreferenceThenPerformGetPreferenceCall() throws Exception - { - UserModel newUser = dataUser.createRandomTestUser(); - SiteModel site = dataSite.usingUser(newUser).createPublicRandomSite(); - - dataSite.usingUser(newUser).usingSite(site).addSiteToFavorites(); - - FileModel fileFavorite = new FileModel("favoriteFile", FileType.TEXT_PLAIN); - fileFavorite = dataContent.usingSite(site).createContent(fileFavorite); - dataContent.getContentActions().setFileAsFavorite(newUser.getUsername(), newUser.getPassword(), site.getId(), String.format("%s.%s", fileFavorite.getName(), fileFavorite.getFileType().extention)); - - FolderModel folderFavorite = new FolderModel("favoriteFolder"); - folderFavorite = dataContent.usingSite(site).createFolder(folderFavorite); - dataContent.getContentActions().setFolderAsFavorite(newUser.getUsername(), newUser.getPassword(), site.getId(), folderFavorite.getName()); - - dataSite.usingUser(newUser).usingSite(site).removeSiteFromFavorites(); - dataContent.getContentActions().removeFavorite(newUser.getUsername(), newUser.getPassword(), site.getId(), folderFavorite.getName()); - dataContent.getContentActions().removeFavorite(newUser.getUsername(), newUser.getPassword(), site.getId(), Paths.get(fileFavorite.getCmisLocation()).getFileName().toString()); - - restPreferenceModel = restClient.authenticateUser(newUser).withCoreAPI().usingAuthUser() - .getPersonPreferenceInformation(PreferenceName.FOLDERS_FAVORITES_PREFIX.toString()); - restClient.assertLastError().containsSummary( - String.format("The relationship resource was not found for the" + " entity with id: %s and a relationship id of %s", newUser.getUsername(), - PreferenceName.FOLDERS_FAVORITES_PREFIX.toString())); - - restPreferenceModel = restClient.authenticateUser(newUser).withCoreAPI().usingAuthUser() - .getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX.toString()); - restClient.assertLastError().containsSummary( - String.format("The relationship resource was not found for the" + " entity with id: %s and a relationship id of %s", newUser.getUsername(), - PreferenceName.SITES_FAVORITES_PREFIX.toString())); - - restPreferenceModel = restClient.authenticateUser(newUser).withCoreAPI().usingAuthUser() - .getPersonPreferenceInformation(PreferenceName.DOCUMENTS_FAVORITES_PREFIX.toString()); - restClient.assertLastError().containsSummary( - String.format("The relationship resource was not found for the" + " entity with id: %s and a relationship id of %s", newUser.getUsername(), - PreferenceName.DOCUMENTS_FAVORITES_PREFIX.toString())); - - restPreferenceModel = restClient.authenticateUser(newUser).withCoreAPI().usingAuthUser() - .getPersonPreferenceInformation(PreferenceName.FOLDERS_FAVORITES_PREFIX.toString()); - restClient.assertLastError().containsSummary( - String.format("The relationship resource was not found for the" + " entity with id: %s and a relationship id of %s", newUser.getUsername(), - PreferenceName.FOLDERS_FAVORITES_PREFIX.toString())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, - description = "Verify admin is able to get preference of another user") - public void adminIsAbleToGetOtherUserPreference() throws Exception - { - restPreferenceModel = restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingUser(userModel) - .getPersonPreferenceInformation(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())); - restClient.assertStatusCodeIs(HttpStatus.OK); - restPreferenceModel.assertThat().field("id").is(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())).and().field("value").is("true"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, - description = "Verify regular user is not able to get preference of admin user") - public void regularUserIsNotAbleToGetAdminPreference() throws Exception - { - SiteModel newSite = dataSite.usingUser(dataUser.getAdminUser()).createPublicRandomSite(); - dataSite.usingUser(dataUser.getAdminUser()).usingSite(newSite).addSiteToFavorites(); - - restClient.authenticateUser(userModel).withCoreAPI().usingUser(dataUser.getAdminUser()) - .getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + newSite.getId()); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - restClient.assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } -} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferenceSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferenceSanityTests.java deleted file mode 100644 index bc668d8cd..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferenceSanityTests.java +++ /dev/null @@ -1,120 +0,0 @@ -package org.alfresco.service.search.rest.people.preferences; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestPreferenceModel; -import org.alfresco.utility.constants.PreferenceName; -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.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Tests for Get a Peference (/people/{personId}/preferences/{preferenceName}) RestAPI call - * - * @author Cristina Axinte - */ - -public class GetPeoplePreferenceSanityTests extends RestTest -{ - UserModel userModel; - SiteModel siteModel; - private RestPreferenceModel restPreferenceModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify manager user gets a specific preference with Rest API and response is successful (200)") - public void managerUserGetsAPreferenceWithSuccess() throws Exception - { - UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); - dataSite.usingUser(managerUser).usingSite(siteModel).addSiteToFavorites(); - - restPreferenceModel = restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser() - .getPersonPreferenceInformation(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())); - restClient.assertStatusCodeIs(HttpStatus.OK); - restPreferenceModel.assertThat().field("id").is(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())).and().field("value").is("true"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify collaborator user gets a specific preference with Rest API and response is successful (200)") - public void collaboratorUserGetsAPreferenceWithSuccess() throws Exception - { - UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(collaboratorUser, siteModel, UserRole.SiteCollaborator); - dataSite.usingUser(collaboratorUser).usingSite(siteModel).addSiteToFavorites(); - - restPreferenceModel = restClient.authenticateUser(collaboratorUser).withCoreAPI().usingAuthUser() - .getPersonPreferenceInformation(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())); - restClient.assertStatusCodeIs(HttpStatus.OK); - restPreferenceModel.assertThat().field("id").is(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())).and().field("value").is("true"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify contributor user gets a specific preference with Rest API and response is successful (200)") - public void contributorUserGetsAPreferenceWithSuccess() throws Exception - { - UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(contributorUser, siteModel, UserRole.SiteContributor); - dataSite.usingUser(contributorUser).usingSite(siteModel).addSiteToFavorites(); - - restPreferenceModel = restClient.authenticateUser(contributorUser).withCoreAPI().usingAuthUser() - .getPersonPreferenceInformation(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())); - restClient.assertStatusCodeIs(HttpStatus.OK); - restPreferenceModel.assertThat().field("id").is(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())).and().field("value").is("true"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify consumer user gets a specific preference with Rest API and response is successful (200)") - public void consumerUserGetsAPreferenceWithSuccess() throws Exception - { - UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel, UserRole.SiteConsumer); - dataSite.usingUser(consumerUser).usingSite(siteModel).addSiteToFavorites(); - - restPreferenceModel = restClient.authenticateUser(consumerUser).withCoreAPI().usingAuthUser() - .getPersonPreferenceInformation(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(),siteModel.getId())); - restClient.assertStatusCodeIs(HttpStatus.OK); - restPreferenceModel.assertThat().field("id").is(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(),siteModel.getId())).and().field("value").is("true"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify admin user gets a specific preference with Rest API and response is successful (200)") - public void adminUserGetsAPreferenceWithSuccess() throws Exception - { - UserModel adminUser = dataUser.getAdminUser(); - dataSite.usingUser(adminUser).usingSite(siteModel).addSiteToFavorites(); - - restPreferenceModel = restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser() - .getPersonPreferenceInformation(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())); - restClient.assertStatusCodeIs(HttpStatus.OK); - restPreferenceModel.assertThat().field("id").is(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())).and().field("value").is("true"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized to get a specific preference with Rest API when authentication fails (401)") -// @Bug(id = "MNT-16904", description = "fails only on environment with tenants") - public void managerUserNotAuthorizedFailsToGetsAPreference() throws Exception - { - UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); - dataSite.usingUser(managerUser).usingSite(siteModel).addSiteToFavorites(); - managerUser.setPassword("newpassword"); - - restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser() - .getPersonPreferenceInformation(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferencesCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferencesCoreTests.java deleted file mode 100644 index ea1942fe5..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferencesCoreTests.java +++ /dev/null @@ -1,123 +0,0 @@ -package org.alfresco.service.search.rest.people.preferences; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestPreferenceModelsCollection; -import org.alfresco.utility.constants.PreferenceName; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * - * @author Cristina Axinte - * - */ -public class GetPeoplePreferencesCoreTests extends RestTest -{ - UserModel userModel, user1, user2, adminUser; - SiteModel siteModel; - FolderModel folderModel; - private RestPreferenceModelsCollection restPreferenceModelsCollection; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - - user1 = dataUser.createRandomTestUser(); - dataSite.usingUser(user1).usingSite(siteModel).addSiteToFavorites(); - dataContent.usingUser(user1).usingSite(siteModel).addFolderToFavorites(folderModel); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its preferences with invalid maxItems parameter with Rest API and response is 400") - public void userGetsPeoplePreferencesUsingInvalidMaxItemsParameter() throws Exception - { - restPreferenceModelsCollection = restClient.authenticateUser(user1).withCoreAPI().usingMe().usingParams("maxItems=0").getPersonPreferences(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsErrorKey(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) - .containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its preferences with skipCount parameter applied with Rest API and response is successful") - public void userGetsPeoplePreferencesUsingInvalidSkipCountParameter() throws Exception - { - restPreferenceModelsCollection = restClient.authenticateUser(user1).withCoreAPI().usingMe().usingParams("skipCount=-1").getPersonPreferences(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsErrorKey(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT) - .containsSummary(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user which doesn't have access to another user preferences fails to get its preferences with Rest API and response is permission denied") - public void userWithNoAccessToOtherUserPreferencesIsForbiddenToGetItsPreferences() throws Exception - { - UserModel noAccessUser = dataUser.createRandomTestUser(); - dataSite.usingUser(noAccessUser).usingSite(siteModel).addSiteToFavorites(); - - restPreferenceModelsCollection = restClient.authenticateUser(user1).withCoreAPI().usingUser(noAccessUser).getPersonPreferences(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - restClient.assertLastError().containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user fails to get preferences for inexistent personId with Rest API and response is 404") - public void userCannotGetPeoplePreferencesForInexistentPersonId() throws Exception - { - UserModel inexistentUserName = new UserModel("inexistent", "password"); - - restPreferenceModelsCollection = restClient.authenticateUser(user1).withCoreAPI().usingUser(inexistentUserName).getPersonPreferences(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - restClient.assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, inexistentUserName.getUsername())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user get preferences for a user with no preferences with Rest API and response is empty") - public void userGetsPeoplePreferencesForUserWithNoPreferences() throws Exception - { - UserModel userNoActivities = dataUser.createRandomTestUser(); - - restPreferenceModelsCollection = restClient.authenticateUser(adminUser).withCoreAPI().usingUser(userNoActivities).getPersonPreferences(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restPreferenceModelsCollection.assertThat().paginationField("count").is("0"); - restPreferenceModelsCollection.assertThat().entriesListIsEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user fails to get preferences for a removed preference with Rest API and response is 404") - public void userFailsToGetPeoplePreferencesIfPreferenceWasRemoved() throws Exception - { - SiteModel preferenceSite = dataSite.usingUser(user1).createPublicRandomSite(); - dataSite.usingUser(user1).usingSite(preferenceSite).addSiteToFavorites(); - restPreferenceModelsCollection = restClient.authenticateUser(user1).withCoreAPI().usingAuthUser().getPersonPreferences(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restPreferenceModelsCollection.assertThat().paginationField("count").is("6"); - - dataSite.usingUser(user1).usingSite(preferenceSite).removeSiteFromFavorites(); - restPreferenceModelsCollection = restClient.authenticateUser(user1).withCoreAPI().usingAuthUser().getPersonPreferences(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restPreferenceModelsCollection.assertThat().paginationField("count").is("5"); - restPreferenceModelsCollection.assertThat().entriesListDoesNotContain("id", String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), preferenceSite.getId())); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferencesFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferencesFullTests.java deleted file mode 100644 index f48d41a7b..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferencesFullTests.java +++ /dev/null @@ -1,114 +0,0 @@ -package org.alfresco.service.search.rest.people.preferences; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestPreferenceModelsCollection; -import org.alfresco.utility.constants.PreferenceName; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * - * @author Cristina Axinte - * - */ -public class GetPeoplePreferencesFullTests extends RestTest -{ - UserModel userModel, user1, user2, adminUser; - SiteModel siteModel; - FolderModel folderModel; - private RestPreferenceModelsCollection restPreferenceModelsCollection; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - - user1 = dataUser.createRandomTestUser(); - dataSite.usingUser(user1).usingSite(siteModel).addSiteToFavorites(); - dataContent.usingUser(user1).usingSite(siteModel).addFolderToFavorites(folderModel); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its preferences with skipCount parameter applied with Rest API and response is successful") - public void userGetsItsPeoplePreferencesUsingSkipCountParameter() throws Exception - { - restPreferenceModelsCollection = restClient.authenticateUser(user1).withCoreAPI().usingMe().usingParams("skipCount=2").getPersonPreferences(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restPreferenceModelsCollection.assertThat().paginationField("count").is("2"); - restPreferenceModelsCollection.assertThat().paginationField("skipCount").is("2"); - restPreferenceModelsCollection.assertThat().entriesListIsNotEmpty() - .and().entriesListDoesNotContain("id", String.format(PreferenceName.EXT_FOLDERS_FAVORITES_PREFIX.toString(), "workspace://SpacesStore/" + folderModel.getNodeRef())) - .and().entriesListDoesNotContain("id", String.format(PreferenceName.EXT_SITES_FAVORITES_PREFIX.toString(), siteModel.getId())) - .and().entriesListContains("id", PreferenceName.FOLDERS_FAVORITES_PREFIX.toString()) - .and().entriesListContains("value", "workspace://SpacesStore/" + folderModel.getNodeRef()) - .and().entriesListContains("id", String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())) - .and().entriesListContains("value", "true"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its preferences with maxItems parameter applied with Rest API and response is successful") - public void userGetsItsPeoplePreferencesUsingMaxItemsParameter() throws Exception - { - restPreferenceModelsCollection = restClient.authenticateUser(user1).withCoreAPI().usingMe().usingParams("maxItems=1").getPersonPreferences(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restPreferenceModelsCollection.assertThat().paginationField("count").is("1"); - restPreferenceModelsCollection.assertThat().paginationField("maxItems").is("1"); - restPreferenceModelsCollection.assertThat().entriesListIsNotEmpty() - .and().entriesListContains("id", String.format(PreferenceName.EXT_FOLDERS_FAVORITES_PREFIX.toString(), "workspace://SpacesStore/" + folderModel.getNodeRef())) - .and().entriesListDoesNotContain("id", String.format(PreferenceName.EXT_SITES_FAVORITES_PREFIX.toString(), siteModel.getId())) - .and().entriesListDoesNotContain("id", PreferenceName.FOLDERS_FAVORITES_PREFIX.toString()) - .and().entriesListDoesNotContain("value", "workspace://SpacesStore/" + folderModel.getNodeRef()) - .and().entriesListDoesNotContain("id", String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())) - .and().entriesListDoesNotContain("value", "true"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets admin preferences with Rest API and response is permission denied") - public void userIsForbiddenToGetAdminPreferences() throws Exception - { - restPreferenceModelsCollection = restClient.authenticateUser(user1).withCoreAPI().usingUser(adminUser).getPersonPreferences(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - restClient.assertLastError().containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its preferences with skipCount parameter higher then no of entries with Rest API and response is empty") - public void userGetsItsPeoplePreferencesUsingHighSkipCount() throws Exception - { - restPreferenceModelsCollection = restClient.authenticateUser(user1).withCoreAPI().usingMe().usingParams("skipCount=100").getPersonPreferences(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restPreferenceModelsCollection.assertThat().paginationField("count").is("0"); - restPreferenceModelsCollection.assertThat().paginationField("skipCount").is("100"); - restPreferenceModelsCollection.assertThat().entriesListIsEmpty(); - } - - @Bug(id = "REPO-1911") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot get preferences for empty user with Rest API and response is 400") - public void userGetsItsPeoplePreferencesForEmptyPersonId() throws Exception - { - UserModel emptyUserName = new UserModel("", "password"); - - restPreferenceModelsCollection = restClient.authenticateUser(user1).withCoreAPI().usingUser(emptyUserName).getPersonPreferences(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .containsSummary(RestErrorModel.LOCAL_NAME_CONSISTANCE) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferencesSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferencesSanityTests.java deleted file mode 100644 index 4b7e657a4..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/people/preferences/GetPeoplePreferencesSanityTests.java +++ /dev/null @@ -1,121 +0,0 @@ -package org.alfresco.service.search.rest.people.preferences; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestPreferenceModelsCollection; -import org.alfresco.utility.constants.PreferenceName; -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.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Tests for Get Peferences (/people/{personId}/preferences) RestAPI call - * - * @author Cristina Axinte - */ - -public class GetPeoplePreferencesSanityTests extends RestTest -{ - UserModel userModel; - SiteModel siteModel; - private RestPreferenceModelsCollection restPreferenceModelsCollection; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify manager user gets its preferences with Rest API and response is successful (200)") - public void managerUserGetsPeoplePreferencesWithSuccess() throws Exception - { - UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); - dataSite.usingUser(managerUser).usingSite(siteModel).addSiteToFavorites(); - - restPreferenceModelsCollection = restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().getPersonPreferences(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restPreferenceModelsCollection.assertThat().entriesListIsNotEmpty().assertThat().paginationExist().and() - .entriesListContains("id", String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify collaborator user gets its preferences with Rest API and response is successful (200)") - public void collaboratorUserGetsPeoplePreferencesWithSuccess() throws Exception - { - UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(collaboratorUser, siteModel, UserRole.SiteCollaborator); - dataSite.usingUser(collaboratorUser).usingSite(siteModel).addSiteToFavorites(); - - restPreferenceModelsCollection = restClient.authenticateUser(collaboratorUser).withCoreAPI().usingAuthUser().getPersonPreferences(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restPreferenceModelsCollection.assertThat().entriesListIsNotEmpty().assertThat().paginationExist().and() - .entriesListContains("id", String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify contributor user gets its preferences with Rest API and response is successful (200)") - public void contributorUserGetsPeoplePreferencesWithSuccess() throws Exception - { - UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(contributorUser, siteModel, UserRole.SiteContributor); - dataSite.usingUser(contributorUser).usingSite(siteModel).addSiteToFavorites(); - - restPreferenceModelsCollection = restClient.authenticateUser(contributorUser).withCoreAPI().usingAuthUser().getPersonPreferences(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restPreferenceModelsCollection.assertThat().entriesListIsNotEmpty().assertThat().paginationExist().and() - .entriesListContains("id", String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify consumer user gets its preferences with Rest API and response is successful (200)") - public void consumerUserGetsPeoplePreferencesWithSuccess() throws Exception - { - UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(consumerUser, siteModel, UserRole.SiteConsumer); - dataSite.usingUser(consumerUser).usingSite(siteModel).addSiteToFavorites(); - - restPreferenceModelsCollection = restClient.authenticateUser(consumerUser).withCoreAPI().usingAuthUser().getPersonPreferences(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restPreferenceModelsCollection.assertThat().entriesListIsNotEmpty().assertThat().paginationExist().and() - .entriesListContains("id", String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify admin user gets another user preferences with Rest API and response is successful (200)") - public void adminUserGetsPeoplePreferencesWithSuccess() throws Exception - { - UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); - dataSite.usingUser(managerUser).usingSite(siteModel).addSiteToFavorites(); - UserModel adminUser = dataUser.getAdminUser(); - - restPreferenceModelsCollection = restClient.authenticateUser(adminUser).withCoreAPI().usingUser(managerUser).getPersonPreferences(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restPreferenceModelsCollection.assertThat().entriesListIsNotEmpty().assertThat().paginationExist().and() - .entriesListContains("id", String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized to gets its preferences with Rest API when authentication fails(401)") -// @Bug(id = "MNT-16904", description = "It fails only on environment with tenants") - public void managerUserGetsPeoplePreferencesIsNotAuthorized() throws Exception - { - UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); - dataSite.usingUser(managerUser).usingSite(siteModel).addSiteToFavorites(); - managerUser.setPassword("newpassword"); - - restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().getPersonPreferences(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/queries/QueriesTest.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/queries/QueriesTest.java deleted file mode 100644 index 5d83550eb..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/queries/QueriesTest.java +++ /dev/null @@ -1,178 +0,0 @@ -package org.alfresco.service.search.rest.queries; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestNodeModelsCollection; -import org.alfresco.rest.model.RestPersonModelsCollection; -import org.alfresco.rest.model.RestSiteModel; -import org.alfresco.rest.model.RestSiteModelsCollection; -import org.alfresco.utility.RetryOperation; -import org.alfresco.utility.Utility; -import org.alfresco.utility.model.ContentModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FileType; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.Test; - - -/** - * Handle requests on Queries - * - */ -public class QueriesTest extends RestTest -{ - @TestRail(section = { TestGroup.REST_API, - TestGroup.QUERIES }, executionType = ExecutionType.SANITY, description = "Check basic functionality of GET queries/sites") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) - public void getQueriesSites() throws Exception - { - restClient.authenticateUser(dataContent.getAdminUser()).withCoreAPI().usingQueries().findSites(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - restClient.assertLastError().containsErrorKey("Query 'term' not specified") - // and assert on summary too if you want - .containsSummary("Query 'term' not specified"); - - restClient.withCoreAPI().usingQueries().usingParams("term=b").findSites(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - restClient.assertLastError().containsErrorKey("Query 'term' is too short"); - - SiteModel site = RestSiteModel.getRandomSiteModel(); - RestSiteModel createdSite = restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingSite(site).createSite(); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RetryOperation op = new RetryOperation() - { - public void execute() throws Exception - { - RestSiteModelsCollection restSiteModels = restClient.withCoreAPI().usingQueries().usingParams("term=" + createdSite.getTitle()) - .findSites(); - - assertEquals(restSiteModels.getEntries().size(), 1); - - } - }; - - Utility.sleep(100, 100000, op);// Allow indexing to complete. - - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.QUERIES }, executionType = ExecutionType.SANITY, description = "Check basic functionality of GET queries/people") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) - public void getQueriesPeople() throws Exception - { - restClient.authenticateUser(dataContent.getAdminUser()).withCoreAPI().usingQueries().findPeople(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - restClient.assertLastError().containsErrorKey("Query 'term' not specified") - // and assert on summary too if you want - .containsSummary("Query 'term' not specified"); - - restClient.withCoreAPI().usingQueries().usingParams("term=b").findPeople(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - restClient.assertLastError().containsErrorKey("Query 'term' is too short"); - - UserModel userModel = dataUser.createRandomTestUser(); - RetryOperation op = new RetryOperation() - { - public void execute() throws Exception - { - RestPersonModelsCollection restPersonModels = restClient.withCoreAPI().usingQueries().usingParams("term=" + userModel.getUsername()) - .findPeople(); - - assertEquals(restPersonModels.getEntries().size(), 1); - - } - }; - - Utility.sleep(100, 100000, op);// Allow indexing to complete. - - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.QUERIES }, - executionType = ExecutionType.REGRESSION, description = "Check basic functionality of GET queries/nodes") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void getOnQueriesNodesRoute() throws Exception - { - restClient.authenticateUser(dataContent.getAdminUser()) - .withCoreAPI() - .usingQueries().findNodes(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - - restClient.assertLastError() - .containsErrorKey("Query 'term' not specified") - //and assert on summary too if you want - .containsSummary("Query 'term' not specified"); - - restClient.withCoreAPI() - .usingQueries() - .usingParams("term=ab") - .findNodes(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - - restClient.assertLastError() - .containsErrorKey("Query 'term' is too short"); - - /* - * now making the correct call with a valid term value - */ - restClient.withCoreAPI().usingQueries().usingParams("term=name").findNodes(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.QUERIES }, executionType = ExecutionType.REGRESSION, description = "Verify GET queries on queries/nodes return success status code") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) - public void testSearchTermWhiteSpace() throws Exception - { - - UserModel userModel = dataUser.createRandomTestUser(); - SiteModel siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - /* - * Create the following file structure for preconditions : - * |- folder - * |--find123.txt - * |-- find123 find.txt - */ - restClient.authenticateUser(userModel).withCoreAPI().usingNode(ContentModel.my()).defineNodes(); - FolderModel folder = new FolderModel("folder" + Math.random()); - - // I use "find123" and "find123 find", the search using second term must - // return less result - // The space must not break the query - String childTerm = "find" + Math.random(); - String childTermWS = childTerm + " " + "find"; - - dataContent.usingUser(userModel).usingSite(siteModel).createFolder(folder); - FileModel file1 = new FileModel(childTerm + ".txt", FileType.TEXT_PLAIN, childTerm); - FileModel file2 = new FileModel(childTermWS + ".txt", FileType.TEXT_PLAIN, childTermWS); - ContentModel cm = new ContentModel(); - cm.setCmisLocation(folder.getCmisLocation()); - cm.setName(folder.getName()); - dataContent.usingUser(userModel).usingSite(siteModel).usingResource(cm).createContent(file1); - dataContent.usingUser(userModel).usingSite(siteModel).usingResource(cm).createContent(file2); - - RetryOperation op = new RetryOperation(){ - public void execute() throws Exception{ - RestNodeModelsCollection nodesChildTerm = restClient.withCoreAPI().usingQueries().usingParams("term=" + childTerm).findNodes(); - // check if the search returns all nodes which contain that query term - assertEquals(2, nodesChildTerm.getEntries().size()); - RestNodeModelsCollection nodesChildTermWS = restClient.withCoreAPI().usingQueries().usingParams("term=" + childTermWS).findNodes(); - // check if search works for words with space and the space don't break - // the query - assertEquals(1, nodesChildTermWS.getEntries().size()); - assertTrue(nodesChildTerm.getEntries().size() >= nodesChildTermWS.getEntries().size()); - } - - }; - Utility.sleep(10, 3500, op);// Allow indexing to complete. - - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/ratings/AddRatingTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/ratings/AddRatingTests.java deleted file mode 100644 index 18d3d4c23..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/ratings/AddRatingTests.java +++ /dev/null @@ -1,818 +0,0 @@ -package org.alfresco.service.search.rest.ratings; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.model.RestCommentModel; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestRatingModel; -import org.alfresco.rest.model.RestTagModel; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.exception.DataPreparationException; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.LinkModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.apache.commons.lang3.RandomStringUtils; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - - -public class AddRatingTests extends RestTest -{ - private UserModel userModel; - private SiteModel siteModel; - private UserModel adminUser; - private ListUserWithRoles usersWithRoles; - private RestRatingModel returnedRatingModel; // placeholder for returned model - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws DataPreparationException - { - userModel = dataUser.createRandomTestUser(); - adminUser = dataUser.getAdminUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.SANITY, description = "Verify user with Manager role is able to post like rating to a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) - public void managerIsAbleToLikeDocument() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(document) - .likeDocument(); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Verify user with Collaborator role is able to post like rating to a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void collaboratorIsAbleToLikeDocument() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(document) - .likeDocument(); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Verify user with Contributor role is able to post like rating to a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void contributorIsAbleToLikeDocument() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingResource(document) - .likeDocument(); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Verify user with Consumer role is able to post like rating to a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void consumerIsAbleToLikeDocument() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingResource(document) - .likeDocument(); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Verify admin user is able to post like rating to a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void adminIsAbleToLikeDocument() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - returnedRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to post like rating to a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) -// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void unauthenticatedUserIsNotAbleToLikeDocument() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(new UserModel("random user", "random password")).withCoreAPI().usingResource(document).likeDocument(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.SANITY, description = "Verify user with Manager role is able to post stars rating to a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) - public void managerIsAbleToAddStarsToDocument() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(document) - .rateStarsToDocument(5); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Verify user with Collaborator role is able to post stars rating to a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void collaboratorIsAbleToAddStarsToDocument() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(document) - .rateStarsToDocument(5); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); - - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Verify user with Contributor role is able to post stars rating to a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void contributorIsAbleToAddStarsToDocument() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingResource(document) - .rateStarsToDocument(5); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Verify user with Consumer role is able to post stars rating to a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void consumerIsAbleToAddStarsToDocument() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingResource(document) - .rateStarsToDocument(5); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.REGRESSION }, - executionType = ExecutionType.SANITY, description = "Verify admin user is able to post stars rating to a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void adminIsAbleToAddStarsToDocument() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - returnedRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).rateStarsToDocument(3); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedRatingModel.assertThat().field("myRating").is("3").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to post stars rating to a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) -// @Bug(id="MNT-16904", description = "fails only on environment with tenants") - public void unauthenticatedUserIsNotAbleToRateStarsToDocument() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(new UserModel("random user", "random password")).withCoreAPI().usingResource(document).rateStarsToDocument(5); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Verify that if unknown rating scheme is provided status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void unknownRatingSchemeReturnsBadRequest() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"invalidRate\"}"); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsSummary(String.format(RestErrorModel.INVALID_RATING, "invalidRate")) - .containsErrorKey(String.format(RestErrorModel.INVALID_RATING, "invalidRate")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Verify that if nodeId does not exist status code 404 is returned") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void invalidNodeIdReturnsNotFound() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - document.setNodeRef(RandomStringUtils.randomAlphanumeric(10)); - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, document.getNodeRef())) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Verify that if nodeId provided cannot be rated 405 status code is returned") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void likeResourceThatCannotBeRated() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - LinkModel link = dataLink.usingAdmin().usingSite(siteModel).createRandomLink(); - document.setNodeRef(link.getNodeRef().replace("workspace://SpacesStore/", "workspace%3A%2F%2FSpacesStore%2F")); - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, document.getNodeRef())) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.SANITY, description = "Verify that manager is able to like a folder") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) - public void managerIsAbleToLikeAFolder() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(folderModel) - .likeDocument(); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.SANITY, description = "Verify that manager is able to like a site") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) - public void managerIsAbleToLikeASite() throws Exception - { - FolderModel folderModel = new FolderModel(); - folderModel.setNodeRef(siteModel.getGuid()); - - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(folderModel) - .likeDocument(); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty(); - - restClient.withCoreAPI().usingResource(folderModel).getRatings() - .assertNodeIsLiked(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.SANITY, description = "Verify that manager is able to rate a folder") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) - public void managerIsAbleToRateAFolder() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(folderModel) - .rateStarsToDocument(5); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.SANITY }, - executionType = ExecutionType.REGRESSION, description = "Verify that manager is able to rate a site") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) - public void managerIsAbleToRateASite() throws Exception - { - FolderModel folderModel = new FolderModel(); - folderModel.setNodeRef(siteModel.getGuid()); - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(folderModel) - .rateStarsToDocument(5); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); - - restClient.withCoreAPI().usingResource(folderModel).getRatings() - .assertNodeHasFiveStarRating(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Verify that adding like again has no effect on a file") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void fileCanBeLikedTwice() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Verify that adding rate again has no effect on a file") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void fileCanBeRatedTwice() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).rateStarsToDocument(5); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).rateStarsToDocument(5); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Verify that rate is not added if empty rating object is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void addRateUsingEmptyRatingObject() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating(""); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.NO_CONTENT, "No content to map due to end-of-input")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Verify that if empty rate id is provided status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void addRateUsingEmptyValueForId() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"\"}"); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - // The message is shortened for comparison as there is a Java object id in the message (random) - .containsSummary(String.format(RestErrorModel.NO_CONTENT, "N/A")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Verify that if empty rating is provided status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void addRateUsingEmptyValueForMyRating() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"likes\", \"myRating\":\"\"}"); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.NULL_LIKE_RATING)); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"fiveStar\", \"myRating\":\"\"}"); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.NULL_FIVESTAR_RATING)); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Verify that user is not able to rate a comment") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void addRatingToAComment() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - RestCommentModel comment = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addComment("This is a comment"); - document.setNodeRef(comment.getId()); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) - .assertLastError() - .containsSummary(String.format(RestErrorModel.CANNOT_RATE)) - .containsErrorKey(RestErrorModel.CANNOT_RATE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).rateStarsToDocument(5); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(String.format(RestErrorModel.CANNOT_RATE)); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Verify that user is not able to rate a tag") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void addRatingToATag() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - RestTagModel tag = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addTag("randomTag"); - document.setNodeRef(tag.getId()); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(String.format(RestErrorModel.CANNOT_RATE)); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).rateStarsToDocument(5); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(String.format(RestErrorModel.CANNOT_RATE)); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that Contributor is able to like a folder") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void contributorIsAbleToLikeAFolder() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI() - .usingResource(folderModel) - .likeDocument(); - - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedRatingModel.assertThat().field("myRating").is("true") - .and().field("id").is("likes") - .and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that Collaborator is able to like a folder") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void collaboratorIsAbleToLikeAFolder() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI() - .usingResource(folderModel) - .likeDocument(); - - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedRatingModel.assertThat().field("myRating").is("true") - .and().field("id").is("likes") - .and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that Consumer is able to like a folder") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void consumerIsAbleToLikeAFolder() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI() - .usingResource(folderModel) - .likeDocument(); - - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedRatingModel.assertThat().field("myRating").is("true") - .and().field("id").is("likes") - .and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that Contributor is able to rate a folder") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void contributorIsAbleToRateAFolder() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI() - .usingResource(folderModel) - .rateStarsToDocument(5); - - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedRatingModel.assertThat().field("myRating").is("5") - .and().field("id").is("fiveStar") - .and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that Collaborator is able to rate a folder") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void collaboratorIsAbleToRateAFolder() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI() - .usingResource(folderModel) - .rateStarsToDocument(5); - - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedRatingModel.assertThat().field("myRating").is("5") - .and().field("id").is("fiveStar") - .and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that Consumer is able to rate a folder") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void consumerIsAbleToRateAFolder() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI() - .usingResource(folderModel) - .rateStarsToDocument(5); - - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedRatingModel.assertThat().field("myRating").is("5") - .and().field("id").is("fiveStar") - .and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that adding like again has no effect on a folder") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void folderCanBeLikedTwice() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folderModel).likeDocument(); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folderModel).likeDocument(); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("true") - .and().field("id").is("likes") - .and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that adding rate again has no effect on a folder") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void folderCanBeRatedTwice() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folderModel).rateStarsToDocument(5); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folderModel).rateStarsToDocument(5); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("5") - .and().field("id").is("fiveStar") - .and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that if invalid rate id is provided status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void addRateUsingInvalidValueForId() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"like\"}"); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsSummary(String.format(RestErrorModel.INVALID_RATING, "like")) - .containsErrorKey(String.format(RestErrorModel.INVALID_RATING, "like")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that rate id is case sensitive is provided status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void addRateUsingInvalidValueForIdCaseSensitive() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"Likes\"}"); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsSummary(String.format(RestErrorModel.INVALID_RATING, "Likes")) - .containsErrorKey(String.format(RestErrorModel.INVALID_RATING, "Likes")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"FiveStar\"}"); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsSummary(String.format(RestErrorModel.INVALID_RATING, "FiveStar")) - .containsErrorKey(String.format(RestErrorModel.INVALID_RATING, "FiveStar")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that if invalid rating is provided status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void addRateUsingInvalidValueForMyRating() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"likes\", \"myRating\":\"skiped\"}"); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsSummary(String.format(RestErrorModel.NULL_LIKE_RATING)); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"fiveStar\", \"myRating\":\"string\"}"); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsSummary(String.format(RestErrorModel.NULL_FIVESTAR_RATING)); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Like file created by a different user") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void addLikeToAnotherUserFile() throws Exception - { - UserModel user = dataUser.usingAdmin().createRandomTestUser(); - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - returnedRatingModel = restClient.authenticateUser(user).withCoreAPI().usingResource(document).likeDocument(); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedRatingModel.assertThat().field("myRating").is("true") - .and().field("id").is("likes") - .and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Rate a file created by a different user") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void addRatingToAnotherUserFile() throws Exception - { - UserModel user = dataUser.usingAdmin().createRandomTestUser(); - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - returnedRatingModel = restClient.authenticateUser(user).withCoreAPI().usingResource(document).rateStarsToDocument(5); - returnedRatingModel.assertThat().field("myRating").is("5") - .and().field("id").is("fiveStar") - .and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Add Rate Using Boolean Value For 'myRating'") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void addRateUsingBooleanValueForMyRating() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"fiveStar\", \"myRating\":\"true\"}"); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsSummary(RestErrorModel.NULL_FIVESTAR_RATING) - .containsErrorKey(RestErrorModel.NULL_FIVESTAR_RATING) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Add Like Using Integer Value For 'myRating'") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void addLikeUsingIntegerValueForMyRating() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"likes\", \"myRating\":\"2\"}"); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsSummary(RestErrorModel.NULL_LIKE_RATING) - .containsErrorKey(RestErrorModel.NULL_LIKE_RATING) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that user is not able to like his own comment") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void userCannotLikeHisOwnComment() throws Exception - { - UserModel user = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); - FolderModel folderModel = dataContent.usingUser(user).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(user).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - RestCommentModel comment = restClient.authenticateUser(user).withCoreAPI().usingResource(document).addComment("This is a comment"); - document.setNodeRef(comment.getId()); - - returnedRatingModel = restClient.authenticateUser(user).withCoreAPI().usingResource(document).likeDocument(); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) - .assertLastError() - .containsSummary(String.format(RestErrorModel.CANNOT_RATE)) - .containsErrorKey(RestErrorModel.CANNOT_RATE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER).stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that user is not able to rate his own comment") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void userCannotRateHisOwnComment() throws Exception - { - UserModel user = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); - FolderModel folderModel = dataContent.usingUser(user).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(user).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - RestCommentModel comment = restClient.authenticateUser(user).withCoreAPI().usingResource(document).addComment("This is a comment"); - document.setNodeRef(comment.getId()); - - returnedRatingModel = restClient.authenticateUser(user).withCoreAPI().usingResource(document).rateStarsToDocument(5); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) - .assertLastError() - .containsSummary(String.format(RestErrorModel.CANNOT_RATE)) - .containsErrorKey(RestErrorModel.CANNOT_RATE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that Collaborator is NOT able to add a negative rating to a file") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void collaboratorIsNotAbleToAddANegativeRatingToAFile() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI() - .usingResource(document) - .rateStarsToDocument(-5); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsSummary(RestErrorModel.RATING_OUT_OF_BOUNDS) - .containsErrorKey(RestErrorModel.RATING_OUT_OF_BOUNDS) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that Collaborator is NOT able to add a high rating to a file") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void collaboratorIsNotAbleToAddAHighRatingToAFile() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI() - .usingResource(document) - .rateStarsToDocument(10); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsSummary(RestErrorModel.RATING_OUT_OF_BOUNDS) - .containsErrorKey(RestErrorModel.RATING_OUT_OF_BOUNDS) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - // @Bug(id = "MNT-17375", description = "Won't Fix, the error message is not ideal and a little cryptic but it does provide the reason i.e. ratingSchemeId is null.") - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Do not provide field - 'id'") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void notProvideIdLikeFile() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"myRating\":\"true\"}"); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsSummary(String.format(RestErrorModel.INVALID_RATING, "null")) - .containsErrorKey(String.format(RestErrorModel.INVALID_RATING, "null")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Do not provide field - 'myRating'") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void notProvideMyRatingRateFile() throws Exception - { - FolderModel folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"likes\"}"); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsSummary(RestErrorModel.NULL_LIKE_RATING) - .containsErrorKey(RestErrorModel.NULL_LIKE_RATING) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } -} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/ratings/DeleteRatingTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/ratings/DeleteRatingTests.java deleted file mode 100644 index 829febf57..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/ratings/DeleteRatingTests.java +++ /dev/null @@ -1,525 +0,0 @@ -package org.alfresco.service.search.rest.ratings; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestRatingModel; -import org.alfresco.rest.model.RestRatingModelsCollection; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.exception.DataPreparationException; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class DeleteRatingTests extends RestTest -{ - private SiteModel siteModel; - private UserModel adminUser; - private ListUserWithRoles usersWithRoles; - private RestRatingModelsCollection returnedRatingModelCollection; - private RestRatingModel returnedRatingModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws DataPreparationException - { - adminUser = dataUser.getAdminUser(); - siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); - - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.SANITY, description = "Verify user with Manager role is able to remove its own rating of a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) - public void managerIsAbleToDeleteItsOwnRatings() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingResource(document).likeDocument(); - restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - - restClient.withCoreAPI().usingResource(document).deleteLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - returnedRatingModelCollection = restClient.withCoreAPI().usingResource(document).getRatings(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedRatingModelCollection.assertNodeIsNotLiked().assertNodeHasNoFiveStarRating().and().entriesListIsNotEmpty().and().paginationExist(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Verify user with Collaborator role is able to remove its own rating of a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void collaboratorIsAbleToDeleteItsOwnRatings() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - - restClient.withCoreAPI().usingResource(document).likeDocument(); - restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - - restClient.withCoreAPI().usingResource(document).deleteLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - returnedRatingModelCollection = restClient.withCoreAPI().usingResource(document).getRatings(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedRatingModelCollection.assertNodeIsNotLiked().assertNodeHasNoFiveStarRating().and().entriesListIsNotEmpty().and().paginationExist(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Verify user with Contributor role is able to remove its own rating of a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void contributorIsAbleToDeleteItsOwnRatings() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - - restClient.withCoreAPI().usingResource(document).likeDocument(); - restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - - restClient.withCoreAPI().usingResource(document).deleteLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - returnedRatingModelCollection = restClient.withCoreAPI().usingResource(document).getRatings(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedRatingModelCollection.assertNodeIsNotLiked().assertNodeHasNoFiveStarRating().and().entriesListIsNotEmpty().and().paginationExist(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Verify user with Consumer role is able to remove its own rating of a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void consumerIsAbleToDeleteItsOwnRatings() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - - restClient.withCoreAPI().usingResource(document).likeDocument(); - restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - - restClient.withCoreAPI().usingResource(document).deleteLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - returnedRatingModelCollection = restClient.withCoreAPI().usingResource(document).getRatings(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedRatingModelCollection.assertNodeIsNotLiked().assertNodeHasNoFiveStarRating().and().entriesListIsNotEmpty().and().paginationExist(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Verify admin user is able to remove its own rating of a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void adminIsAbleToDeleteItsOwnRatings() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - document = dataContent.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).usingResource(folderModel) - .createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(adminUser); - - restClient.withCoreAPI().usingResource(document).likeDocument(); - restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - - restClient.withCoreAPI().usingResource(document).deleteLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - returnedRatingModelCollection = restClient.withCoreAPI().usingResource(document).getRatings(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedRatingModelCollection.assertNodeIsNotLiked().assertNodeHasNoFiveStarRating().and().entriesListIsNotEmpty().and().paginationExist(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to remove its own rating of a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) -// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void unauthenticatedUserIsNotAbleToDeleteRatings() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - document = dataContent.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).usingResource(folderModel) - .createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(adminUser); - - restClient.withCoreAPI().usingResource(document).likeDocument(); - restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - - restClient.authenticateUser(new UserModel("random user", "random password")); - - restClient.withCoreAPI().usingResource(document).deleteLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - - restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Verify one user is not able to remove rating added by another user") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - @Bug(id = "ACE-5459") - public void oneUserIsNotAbleToDeleteRatingsOfAnotherUser() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - UserModel userA = dataUser.createRandomTestUser(); - UserModel userB = dataUser.createRandomTestUser(); - - restClient.authenticateUser(userA); - - restClient.withCoreAPI().usingResource(document).likeDocument(); - restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - - restClient.authenticateUser(userB); - - restClient.withCoreAPI().usingResource(document).deleteLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - - restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - restClient.withCoreAPI().usingResource(document).getRatings() - .assertNodeIsLiked() - .assertNodeHasFiveStarRating(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Verify that if ratingId provided is unknown status code returned is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void deleteInvalidRating() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).deleteInvalidRating("random_rating"); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsSummary(String.format(RestErrorModel.INVALID_RATING, "random_rating")) - .containsErrorKey(String.format(RestErrorModel.INVALID_RATING, "random_rating")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Verify that if nodeId does not exist status code returned is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void deleteRatingUsingInvalidDocument() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - document.setNodeRef("random_value"); - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).deleteLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "random_value")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Delete rating stars for a document that was not rated") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - @Bug(id = "MNT-17181") - public void deleteStarsForANotRatedDocument() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).deleteFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Delete like rating for a document that was not liked") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - @Bug(id = "MNT-17181") - public void deleteLikeForANotLikedDocument() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).deleteLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Delete like for a file then add it again") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void likeDocumentAfterLikeRatingIsDeleted() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); - restClient.withCoreAPI().usingResource(document).deleteLikeRating(); - returnedRatingModel = restClient.withCoreAPI().usingResource(document).likeDocument(); - - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Delete stars for a file then add them again") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void addStarsToDocumentAfterRatingIsDeleted() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(document).rateStarsToDocument(5); - restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - returnedRatingModel = restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Verify site manager is not able to remove rating added by another user") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - @Bug(id = "ACE-5459") - public void deleteDocumentRatingUsingManager() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(document).rateStarsToDocument(5); - restClient.withCoreAPI().usingResource(document).likeDocument(); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(document).deleteFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - restClient.withCoreAPI().usingResource(document).deleteLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - - restClient.withCoreAPI().usingResource(document).getRatings() - .assertNodeIsLiked() - .assertNodeHasFiveStarRating(); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Verify site contributor is not able to remove rating added by another user") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - @Bug(id = "ACE-5459") - public void contributorIsNotAbleToDeleteRatingsOfAnotherUser() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(document).rateStarsToDocument(5); - restClient.withCoreAPI().usingResource(document).likeDocument(); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingResource(document).deleteFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - restClient.withCoreAPI().usingResource(document).deleteLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - - restClient.withCoreAPI().usingResource(document).getRatings() - .assertNodeIsLiked() - .assertNodeHasFiveStarRating(); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Verify site collaborator is not able to remove rating added by another user") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - @Bug(id = "ACE-5459") - public void collaboratorIsNotAbleToDeleteRatingsOfAnotherUser() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(document).rateStarsToDocument(5); - restClient.withCoreAPI().usingResource(document).likeDocument(); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(document).deleteFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - restClient.withCoreAPI().usingResource(document).deleteLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - - restClient.withCoreAPI().usingResource(document).getRatings() - .assertNodeIsLiked() - .assertNodeHasFiveStarRating(); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Verify site consumer is not able to remove rating added by another user") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - @Bug(id = "ACE-5459") - public void consumerIsNotAbleToDeleteRatingsOfAnotherUser() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(document).rateStarsToDocument(5); - restClient.withCoreAPI().usingResource(document).likeDocument(); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingResource(document).deleteFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - restClient.withCoreAPI().usingResource(document).deleteLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - - restClient.withCoreAPI().usingResource(document).getRatings() - .assertNodeIsLiked() - .assertNodeHasFiveStarRating(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Delete rating stars twice") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - @Bug(id = "MNT-17181") - public void deleteStarsTwice() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(document).rateStarsToDocument(5); - - restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - returnedRatingModelCollection = restClient.withCoreAPI().usingResource(document).getRatings(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedRatingModelCollection.assertNodeHasNoFiveStarRating(); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).deleteFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Delete like rating twice") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - @Bug(id = "MNT-17181") - public void deleteLikeTwice() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingResource(document).likeDocument(); - - restClient.withCoreAPI().usingResource(document).deleteLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - returnedRatingModelCollection = restClient.withCoreAPI().usingResource(document).getRatings(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedRatingModelCollection.assertNodeIsNotLiked(); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).deleteLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Delete like for a folder then add it again") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void likeFolderAfterLikeRatingIsDeleted() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folderModel).likeDocument(); - restClient.withCoreAPI().usingResource(folderModel).deleteLikeRating(); - returnedRatingModel = restClient.withCoreAPI().usingResource(folderModel).likeDocument(); - - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Delete stars for a folder then add them again") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void addStarsToFolderAfterRatingIsDeleted() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(folderModel).rateStarsToDocument(5); - restClient.withCoreAPI().usingResource(folderModel).deleteFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - returnedRatingModel = restClient.withCoreAPI().usingResource(folderModel).rateStarsToDocument(5); - - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Delete like for a site then add it again") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void likeSiteAfterLikeRatingIsDeleted() throws Exception - { - FolderModel folderModel = new FolderModel(); - folderModel.setNodeRef(siteModel.getGuid()); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folderModel).likeDocument(); - restClient.withCoreAPI().usingResource(folderModel).deleteLikeRating(); - returnedRatingModel = restClient.withCoreAPI().usingResource(folderModel).likeDocument(); - - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Delete stars for a site then add them again") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void addStarsToSiteAfterRatingIsDeleted() throws Exception - { - FolderModel folderModel = new FolderModel(); - folderModel.setNodeRef(siteModel.getGuid()); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(folderModel).rateStarsToDocument(5); - restClient.withCoreAPI().usingResource(folderModel).deleteFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - returnedRatingModel = restClient.withCoreAPI().usingResource(folderModel).rateStarsToDocument(5); - - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Verify user with Manager role is able to remove one star rating of a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void removeOneStarRating() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingResource(document).rateStarsToDocument(1); - - restClient.withCoreAPI().usingResource(document).deleteFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - returnedRatingModelCollection = restClient.withCoreAPI().usingResource(document).getRatings(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedRatingModelCollection.assertNodeIsNotLiked().assertNodeHasNoFiveStarRating().and().entriesListIsNotEmpty().and().paginationExist(); - } -} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/ratings/GetRatingTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/ratings/GetRatingTests.java deleted file mode 100644 index 71acd3a6c..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/ratings/GetRatingTests.java +++ /dev/null @@ -1,438 +0,0 @@ -package org.alfresco.service.search.rest.ratings; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.core.RestRequest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestRatingModel; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.exception.DataPreparationException; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.apache.commons.lang3.RandomStringUtils; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -public class GetRatingTests extends RestTest -{ - private SiteModel siteModel; - private UserModel adminUser, userModel, managerUser; - private FileModel document; - private ListUserWithRoles usersWithRoles; - private RestRatingModel restRatingModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws DataPreparationException - { - adminUser = dataUser.getAdminUser(); - userModel = dataUser.createRandomTestUser(); - managerUser = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); - - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - - dataUser.addUserToSite(managerUser, siteModel, UserRole.SiteManager); - } - - @BeforeMethod(alwaysRun = true) - public void setUp() throws Exception - { - document = dataContent.usingSite(siteModel).usingAdmin().createContent(DocumentType.TEXT_PLAIN); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.SANITY, description = "Verify user with Manager role is able to retrieve rating of a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) - public void managerIsAbleToRetrieveRating() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - - restClient.withCoreAPI().usingResource(document).likeDocument(); - restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - - restRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); - - restRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").is("5"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Verify user with Collaborator role is able to retrieve rating of a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void collaboratorIsAbleToRetrieveRating() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - - restClient.withCoreAPI().usingResource(document).likeDocument(); - restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - - restRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); - - restRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").is("5"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Verify user with Contributor role is able to retrieve rating of a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void contributorIsAbleToRetrieveRating() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - - restClient.withCoreAPI().usingResource(document).likeDocument(); - restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - - restRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); - - restRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").is("5"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Verify user with Consumer role is able to retrieve rating of a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void consumerIsAbleToRetrieveRating() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - - restClient.withCoreAPI().usingResource(document).likeDocument(); - restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - - restRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); - - restRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").is("5"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Verify admin user is able to retrieve rating of a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void adminIsAbleToRetrieveRating() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - FileModel document = dataContent.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingResource(folderModel) - .createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(adminUser); - restClient.withCoreAPI().usingResource(document).likeDocument(); - restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - - restRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); - - restRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").is("5"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to retrieve rating of a document") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) -// @Bug(id = "MNT-16904", description = "It fails only on environment with tenants") - public void unauthenticatedUserIsNotAbleToRetrieveRating() throws Exception - { - restClient.authenticateUser(adminUser); - restClient.withCoreAPI().usingResource(document).likeDocument(); - restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - - restClient.authenticateUser(new UserModel("random user", "random password")); - - restClient.withCoreAPI().usingResource(document).getLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - - restClient.withCoreAPI().usingResource(document).getFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Check that using invalid ratingId for get rating call returns status code 400.") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void checkInvalidRatingIdStatusCode() throws Exception - { - restClient.authenticateUser(adminUser).withCoreAPI(); - RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "nodes/{nodeId}/ratings/{ratingId}", document.getNodeRef(), "invalid ratingId"); - restClient.processModel(RestRatingModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.INVALID_RATING, "invalid ratingId")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Check that using invalid node ID for get rating call returns status code 404.") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void getRatingUsingInvalidNodeId() throws Exception - { - document.setNodeRef(RandomStringUtils.randomAlphanumeric(20)); - restRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).getFiveStarRating(); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, document.getNodeRef())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Get rating of a file that has only likes.") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void getRatingOfFileThatHasOnlyLikes() throws Exception - { - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); - - restRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); - restRatingModel.getAggregate().assertThat().field("numberOfRatings").is("1"); - - restRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restRatingModel.getAggregate().assertThat().field("numberOfRatings").is("0"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Get rating of a file that has only stars.") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void getRatingOfFileThatHasOnlyStars() throws Exception - { - restClient.authenticateUser(userModel).withCoreAPI().usingResource(document).rateStarsToDocument(5); - - restRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); - restRatingModel.getAggregate().assertThat().field("numberOfRatings").is("1"); - - restRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restRatingModel.getAggregate().assertThat().field("numberOfRatings").is("0"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Get rating of a file that has likes and stars.") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void getRatingOfFileThatHasLikesAndStars() throws Exception - { - restClient.authenticateUser(userModel).withCoreAPI().usingResource(document).likeDocument(); - restClient.authenticateUser(userModel).withCoreAPI().usingResource(document).rateStarsToDocument(5); - - restRatingModel = restClient.withCoreAPI().usingResource(document).getLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); - restRatingModel.getAggregate().assertThat().field("numberOfRatings").is("1"); - - restRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); - restRatingModel.getAggregate().assertThat().field("numberOfRatings").is("1"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Get rating of a folder that has only likes.") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void getRatingOfFolderThatHasOnlyLikes() throws Exception - { - FolderModel firstFolderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(firstFolderModel).likeDocument(); - - restRatingModel = restClient.withCoreAPI().usingResource(firstFolderModel).getLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restRatingModel.assertThat().field("id").is("likes").and().field("myRating").is("true"); - restRatingModel.getAggregate().assertThat().field("numberOfRatings").is("1"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Get rating of a file that has no ratings.") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void getRatingOfFileThatHasNoRatings() throws Exception - { - restRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).getLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restRatingModel.getAggregate().assertThat().field("numberOfRatings").is("0"); - - restRatingModel = restClient.withCoreAPI().usingResource(document).getFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restRatingModel.getAggregate().assertThat().field("numberOfRatings").is("0"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Check default error schema") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void checkDefaultErrorSchema() throws Exception - { - FileModel document = dataContent.usingSite(siteModel).usingAdmin().createContent(DocumentType.TEXT_PLAIN); - String randomNodeRef = RandomStringUtils.randomAlphanumeric(10); - document.setNodeRef(randomNodeRef); - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).getLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, randomNodeRef)) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Get rating of a folder that has only stars") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void getRatingOfFolderThatHasOnlyStars() throws Exception - { - FolderModel folder = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - restClient.authenticateUser(managerUser).withCoreAPI().usingResource(folder).rateStarsToDocument(3); - restRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folder).getFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restRatingModel.assertThat().field("id").is("fiveStar") - .getAggregate().assertThat().field("numberOfRatings").is("1") - .assertThat().field("average").is("3.0"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Get rating of a folder that has both likes and stars") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void getRatingOfFolderThatHasLikedAndStars() throws Exception - { - FolderModel folder = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - restClient.authenticateUser(managerUser).withCoreAPI().usingResource(folder).rateStarsToDocument(3); - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folder).likeDocument(); - - restRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folder).getFiveStarRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restRatingModel.assertThat().field("id").is("fiveStar") - .getAggregate().assertThat().field("numberOfRatings").is("1") - .assertThat().field("average").is("3.0"); - - restRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folder).getLikeRating(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restRatingModel.assertThat().field("id").is("likes") - .assertThat().field("myRating").is("true"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Get rating of a folder that has no ratings") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void getRatingOfFolderThatHasNoRatings() throws Exception - { - FolderModel folder = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - - restRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folder).getFiveStarRating(); - restRatingModel.getAggregate().assertThat().field("numberOfRatings").is("0"); - - restRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folder).getLikeRating(); - restRatingModel.getAggregate().assertThat().field("numberOfRatings").is("0"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Get rating of a folder after rating was deleted") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void getDeletedRatingOfAFolder() throws Exception - { - FolderModel folder = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - restClient.authenticateUser(managerUser).withCoreAPI().usingResource(folder).rateStarsToDocument(3); - restClient.authenticateUser(managerUser).withCoreAPI().usingResource(folder).deleteFiveStarRating(); - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folder).likeDocument(); - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folder).deleteLikeRating(); - - restRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folder).getFiveStarRating(); - restRatingModel.assertThat().field("id").is("fiveStar").getAggregate().assertThat().field("numberOfRatings").is("0") - .assertThat().field("average").isNull(); - - restRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(folder).getLikeRating(); - restRatingModel.assertThat().field("id").is("likes").assertThat().field("myRating").isNull() - .getAggregate().assertThat().field("numberOfRatings").is("0"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Get rating of a file after rating was deleted") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void getDeletedRatingOfAFile() throws Exception - { - FileModel file = dataContent.usingUser(adminUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(managerUser).withCoreAPI().usingResource(file).rateStarsToDocument(3); - restClient.authenticateUser(managerUser).withCoreAPI().usingResource(file).deleteFiveStarRating(); - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(file).likeDocument(); - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(file).deleteLikeRating(); - - restRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(file).getFiveStarRating(); - restRatingModel.assertThat().field("id").is("fiveStar").getAggregate().assertThat().field("numberOfRatings").is("0") - .assertThat().field("average").isNull(); - - restRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(file).getLikeRating(); - restRatingModel.assertThat().field("id").is("likes").assertThat().field("myRating").isNull() - .getAggregate().assertThat().field("numberOfRatings").is("0"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Get rating of another user as admin") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void getRatingOfAnotherUserAsAdmin() throws Exception - { - FileModel file = dataContent.usingUser(adminUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(managerUser).withCoreAPI().usingResource(file).rateStarsToDocument(3); - restClient.authenticateUser(managerUser).withCoreAPI().usingResource(file).likeDocument(); - - restRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(file).getFiveStarRating(); - restRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").isNull() - .getAggregate().assertThat().field("numberOfRatings").is("1").assertThat().field("average").is("3.0"); - - restRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(file).getLikeRating(); - restRatingModel.assertThat().field("id").is("likes").assertThat().field("myRating").isNull() - .getAggregate().assertThat().field("numberOfRatings").is("1"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Get rating of admin with another user") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void getRatingOfAdminWithAnotherUser() throws Exception - { - FileModel file = dataContent.usingUser(managerUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(file).rateStarsToDocument(3); - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(file).likeDocument(); - - restRatingModel = restClient.authenticateUser(managerUser).withCoreAPI().usingResource(file).getFiveStarRating(); - restRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").isNull() - .getAggregate().assertThat().field("numberOfRatings").is("1").assertThat().field("average").is("3.0"); - - restRatingModel = restClient.authenticateUser(managerUser).withCoreAPI().usingResource(file).getLikeRating(); - restRatingModel.assertThat().field("id").is("likes").assertThat().field("myRating").isNull() - .getAggregate().assertThat().field("numberOfRatings").is("1"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Get five star rating") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void getFiveStarRating() throws Exception - { - FileModel file = dataContent.usingUser(managerUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(file).rateStarsToDocument(5); - - restRatingModel = restClient.authenticateUser(managerUser).withCoreAPI().usingResource(file).getFiveStarRating(); - restRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").isNull() - .getAggregate().assertThat().field("numberOfRatings").is("1").assertThat().field("average").is("5.0"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, description = "Get one star rating") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void getOneStarRating() throws Exception - { - FileModel file = dataContent.usingUser(managerUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(file).rateStarsToDocument(1); - - restRatingModel = restClient.authenticateUser(managerUser).withCoreAPI().usingResource(file).getFiveStarRating(); - restRatingModel.assertThat().field("id").is("fiveStar").and().field("myRating").isNull() - .getAggregate().assertThat().field("numberOfRatings").is("1").assertThat().field("average").is("1.0"); - } -} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/ratings/GetRatingsTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/ratings/GetRatingsTests.java deleted file mode 100644 index 19cd55116..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/ratings/GetRatingsTests.java +++ /dev/null @@ -1,313 +0,0 @@ -package org.alfresco.service.search.rest.ratings; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestRatingModelsCollection; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.exception.DataPreparationException; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.apache.commons.lang3.RandomStringUtils; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class GetRatingsTests extends RestTest -{ - private SiteModel siteModel; - private UserModel adminUser, userModel; - private ListUserWithRoles usersWithRoles; - private RestRatingModelsCollection restRatingModelsCollection; - private FileModel document; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws DataPreparationException - { - adminUser = dataUser.getAdminUser(); - userModel = dataUser.createRandomTestUser(); - - siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); - - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.SANITY, description = "Manager is able to retrieve document ratings") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) - public void managerIsAbleToRetrieveDocumentRatings() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - - restClient.withCoreAPI().usingResource(document).likeDocument(); - restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - - restRatingModelsCollection = restClient.withCoreAPI().usingResource(document).getRatings(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restRatingModelsCollection.assertNodeHasFiveStarRating().assertNodeIsLiked(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Collaborator is able to retrieve document ratings") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void collaboratorIsAbleToRetrieveDocumentRatings() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - - restClient.withCoreAPI().usingResource(document).likeDocument(); - restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - - restRatingModelsCollection = restClient.withCoreAPI().usingResource(document).getRatings(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restRatingModelsCollection.assertNodeHasFiveStarRating().assertNodeIsLiked(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Contributor is able to retrieve document ratings") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void contributorIsAbleToRetrieveDocumentRatings() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - - restClient.withCoreAPI().usingResource(document).likeDocument(); - restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - - restRatingModelsCollection = restClient.withCoreAPI().usingResource(document).getRatings(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restRatingModelsCollection.assertNodeHasFiveStarRating().assertNodeIsLiked(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Consumer is able to retrieve document ratings") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void consumerIsAbleToRetrieveDocumentRatings() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - - restClient.withCoreAPI().usingResource(document).likeDocument(); - restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - - restRatingModelsCollection = restClient.withCoreAPI().usingResource(document).getRatings(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restRatingModelsCollection.assertNodeHasFiveStarRating().assertNodeIsLiked(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.REGRESSION, description = "Admin user is able to retrieve document ratings") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void adminIsAbleToRetrieveDocumentRatings() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - document = dataContent.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingResource(folderModel) - .createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(adminUser); - restClient.withCoreAPI().usingResource(document).likeDocument(); - restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - - restRatingModelsCollection = restClient.withCoreAPI().usingResource(document).getRatings(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restRatingModelsCollection.assertNodeHasFiveStarRating().assertNodeIsLiked(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, - executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to retrieve document ratings") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.SANITY }) -// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void unauthenticatedUserIsNotAbleToRetrieveRatings() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUser).usingSite(siteModel).createFolder(); - document = dataContent.usingUser(adminUser).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(adminUser); - restClient.withCoreAPI().usingResource(document).likeDocument(); - restClient.withCoreAPI().usingResource(document).rateStarsToDocument(5); - - restClient.authenticateUser(new UserModel("random user", "random password")); - - restClient.withCoreAPI().usingResource(document).getRatings(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Check that rating for invalid maxItems status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void checkInvalidMaxItemsStatusCode() throws Exception - { - document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); - restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).rateStarsToDocument(5); - restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).likeDocument(); - - restClient.authenticateUser(adminUser).withParams("maxItems=0").withCoreAPI().usingResource(document).getRatings(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Only positive values supported for maxItems"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Check that rating for invalid skipCount status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void checkInvalidSkipCountStatusCode() throws Exception - { - document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); - restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).rateStarsToDocument(5); - restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).likeDocument(); - - restClient.authenticateUser(adminUser).withParams("skipCount=AB").withCoreAPI().usingResource(document).getRatings(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Invalid paging parameter skipCount:AB"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "If nodeId does not exist status code is 404 when a document is liked") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void addLikeUsingInvalidNodeId() throws Exception - { - document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); - restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).rateStarsToDocument(5); - restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).likeDocument(); - document.setNodeRef(RandomStringUtils.randomAlphanumeric(20)); - - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).getRatings(); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, document.getNodeRef())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Check that rating value is TRUE for a like rating") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void checkRatingValueIsTrueForLikedDoc() throws Exception - { - document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); - restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).rateStarsToDocument(5); - restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).likeDocument(); - - restRatingModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingResource(document).getRatings(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - restRatingModelsCollection.assertThat().entriesListContains("myRating", "true") - .assertThat().entriesListContains("id", "likes"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Check that rating value is an INTEGER value for stars rating") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void checkRatingValueIsIntegerForStarsRating() throws Exception - { - document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); - restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).rateStarsToDocument(5); - restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).likeDocument(); - - restRatingModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingResource(document).getRatings(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - restRatingModelsCollection.assertThat().entriesListContains("myRating", "5") - .assertThat().entriesListContains("id", "fiveStar"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Check default error schema in case of failure") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void checkDefaultErrorSchema() throws Exception - { - FileModel document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); - document.setNodeRef("abc"); - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).getRatings(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "abc")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Check maxItems and skipCount parameters") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void checkMaxItemsAndSkipCountParameters() throws Exception - { - document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); - restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).rateStarsToDocument(5); - restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).likeDocument(); - - restRatingModelsCollection = restClient.authenticateUser(adminUser).withParams("maxItems=1", "skipCount=1").withCoreAPI().usingResource(document).getRatings(); - restRatingModelsCollection.assertThat().entriesListCountIs(1); - restRatingModelsCollection.getPagination().assertThat().field("maxItems").is("1") - .and().field("skipCount").is("1"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Check totalItems and hasMoreitems parameters") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void checkTotalItemsAndHasMoreItemsParameters() throws Exception - { - document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); - restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).rateStarsToDocument(5); - restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).likeDocument(); - - restRatingModelsCollection = restClient.authenticateUser(adminUser).withParams("maxItems=1").withCoreAPI().usingResource(document).getRatings(); - restRatingModelsCollection.assertThat().entriesListCountIs(1); - restRatingModelsCollection.getPagination().assertThat().field("hasMoreItems").is("true") - .and().field("count").is("1").and().field("maxItems").is("1"); - } - - @Bug(id = "REPO-1831") - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Get ratings for a document to which authenticated user does not have access") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void userIsNotAbleToGetRatingsOfDocumentToWhichItHasNoAccess() throws Exception - { - SiteModel privateSite = dataSite.usingAdmin().createPrivateRandomSite(); - FileModel file = dataContent.usingSite(privateSite).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); - restRatingModelsCollection = restClient.authenticateUser(userModel).withCoreAPI().usingResource(file).getRatings(); - restRatingModelsCollection.assertThat().entriesListIsEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Check high value for skipCount parameter") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void getRatingsUsingHighValueForSkipCount() throws Exception - { - document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); - restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).rateStarsToDocument(5); - restClient.authenticateUser(userModel).withCoreAPI().usingNode(document).likeDocument(); - - restRatingModelsCollection = restClient.authenticateUser(adminUser).withParams("skipCount=100").withCoreAPI().usingResource(document).getRatings(); - restRatingModelsCollection.getPagination().assertThat().field("skipCount").is("100"); - restRatingModelsCollection.assertThat().entriesListIsEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, - description = "Get ratings using site id instead of node id") - @Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.REGRESSION }) - public void getRatingsUsingSiteId() throws Exception - { - FileModel document = dataContent.usingSite(siteModel).usingAdmin().createContent(CMISUtil.DocumentType.TEXT_PLAIN); - document.setNodeRef(siteModel.getId()); - restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).getRatings(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, siteModel.getId())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } -} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/renditions/AvailableRenditionTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/renditions/AvailableRenditionTests.java deleted file mode 100644 index 60ddd5c18..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/renditions/AvailableRenditionTests.java +++ /dev/null @@ -1,134 +0,0 @@ -package org.alfresco.service.search.rest.renditions; - -import org.alfresco.rest.model.RestNodeModel; -import org.alfresco.rest.model.RestRenditionInfoModel; -import org.alfresco.rest.model.RestRenditionInfoModelCollection; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.Assert; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; - -import java.util.Arrays; -import java.util.Collections; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; - -/** - * - * Sanity check for renditions through REST API.
          - * Tests upload files and then request renditions for those files.
          - * Renditions are requested based on supported renditions according to GET '/nodes/{nodeId}/renditions'.
          - */ -@Test(groups = {TestGroup.REQUIRE_TRANSFORMATION, TestGroup.RENDITIONS_REGRESSION}) -public class AvailableRenditionTests extends RenditionIntegrationTests -{ - /** List of parameters used as an input to supportedRenditionTest - fileName, nodeId, renditionId, expectedMimeType **/ - private List renditionsToTest; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - super.dataPreparation(); - - // Upload files and get available renditions for each file - List toTest = Arrays.asList("doc", "xls", "ppt", "docx", "xlsx", "pptx", "msg", "pdf", "png", "gif", "jpg"); - List renditionsForFiles = new LinkedList<>(); - for (String extensions : toTest) - { - String sourceFile = "quick/quick." + extensions; - renditionsForFiles.addAll(uploadFileAndGetAvailableRenditions(sourceFile)); - } - - renditionsToTest = Collections.unmodifiableList(renditionsForFiles); - } - - /** - * Upload a source file and get all supported renditions for it. - */ - private List uploadFileAndGetAvailableRenditions(String sourceFile) throws Exception - { - - // Create folder & upload file - RestNodeModel fileNode = uploadFile(sourceFile); - FileModel file = new FileModel(); - file.setNodeRef(fileNode.getId()); - - List renditionsForFile = new LinkedList<>(); - - // Get supported renditions - RestRenditionInfoModelCollection renditionsInfo = restClient.withCoreAPI().usingNode(file).getNodeRenditionsInfo(); - for (RestRenditionInfoModel m : renditionsInfo.getEntries()) - { - RestRenditionInfoModel renditionInfo = m.onModel(); - String renditionId = renditionInfo.getId(); - String targetMimeType = renditionInfo.getContent().getMimeType(); - - renditionsForFile.add(new Object[]{sourceFile, fileNode.getId(), renditionId, targetMimeType}); - - } - - return renditionsForFile; - } - - /** - * Check that a particular rendition can be created for the file and that it has the expected Mime type - */ - @Test(dataProvider = "RenditionTestDataProvider", groups = {TestGroup.REST_API, TestGroup.RENDITIONS, TestGroup.SANITY}) - @TestRail(section = { TestGroup.REST_API, TestGroup.RENDITIONS }, executionType = ExecutionType.SANITY, - description = "Verify renditions created for a selection of test files via POST nodes/{nodeId}/renditions") - public void supportedRenditionTest(String fileName, String nodeId, String renditionId, String expectedMimeType) throws Exception - { - checkRendition(fileName, nodeId, renditionId, expectedMimeType); - } - - @DataProvider(name = "RenditionTestDataProvider") - protected Iterator renditionTestDataProvider() throws Exception - { - return renditionsToTest.iterator(); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.RENDITIONS, TestGroup.SANITY}) - @TestRail(section = { TestGroup.REST_API, TestGroup.RENDITIONS }, executionType = ExecutionType.SANITY, - description = "Verify that there are some available renditions.") - public void renditionsAvailableTest() - { - Assert.assertFalse(renditionsToTest.isEmpty(), "No available renditions were reported for any of the test files."); - } - - @Test(dataProvider = "UnsupportedRenditionTestDataProvider",groups = {TestGroup.REST_API, TestGroup.RENDITIONS, TestGroup.SANITY}) - @TestRail(section = { TestGroup.REST_API, TestGroup.RENDITIONS }, executionType = ExecutionType.SANITY, - description = "Verify that requests for unsupported renditions return 400 ") - public void unsupportedRenditionTest(String sourceFile, String renditionId) throws Exception - { - RestNodeModel fileNode = uploadFile(sourceFile); - - // 2. Request rendition of the file using RESTAPI - FileModel file = new FileModel(sourceFile); - file.setNodeRef(fileNode.getId()); - restClient.withCoreAPI().usingNode(file).createNodeRendition(renditionId); - - Assert.assertEquals(restClient.getStatusCode(), HttpStatus.BAD_REQUEST.toString(), - "Expected to see the rendition rejected. [" + sourceFile + ", " + renditionId + "] [source file, rendition ID] "); - } - - @DataProvider(name = "UnsupportedRenditionTestDataProvider") - protected Iterator unsupportedRenditionTestDataProvider() throws Exception - { - String renditionId = "pdf"; - - List toTest = new LinkedList<>(); - toTest.add(new Object[]{"quick/quick.png", renditionId}); - toTest.add(new Object[]{"quick/quick.gif", renditionId}); - toTest.add(new Object[]{"quick/quick.jpg", renditionId}); - toTest.add(new Object[]{"quick/quick.pdf", renditionId}); - - return toTest.iterator(); - } -} - diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/renditions/CreateRenditionTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/renditions/CreateRenditionTests.java deleted file mode 100644 index d7a85b429..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/renditions/CreateRenditionTests.java +++ /dev/null @@ -1,101 +0,0 @@ -package org.alfresco.service.search.rest.renditions; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestNodeModel; -import org.alfresco.utility.Utility; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.report.Bug.Status; -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.BeforeMethod; -import org.testng.annotations.Test; - -/** - * Handles tests related to POST api-explorer/#!/renditions - * @author Cristina Axinte - * - */ -@Test(groups = {TestGroup.REQUIRE_TRANSFORMATION}) -public class CreateRenditionTests extends RestTest -{ - private UserModel adminUser, user; - private SiteModel site; - private FileModel document; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - user = dataUser.createRandomTestUser(); - site = dataSite.usingUser(user).createPublicRandomSite(); - } - - @BeforeMethod(alwaysRun = true) - public void createDocument() throws Exception - { - document = dataContent.usingUser(user).usingSite(site).createContent(DocumentType.TEXT_PLAIN); - } - - @Bug(id = "REPO-2042", description = "Should fail only on MAC OS System and Linux", status = Status.FIXED ) - @TestRail(section = { TestGroup.REST_API, TestGroup.RENDITIONS }, executionType = ExecutionType.SANITY, - description = "Verify admin user creates rendition with Rest API and status code is 202") - @Test(groups = { TestGroup.REST_API, TestGroup.RENDITIONS, TestGroup.SANITY }) - public void adminCanCreateRenditionToExistingNode() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(adminUser).withCoreAPI().usingNode(document).createNodeRendition("pdf"); - restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); - - restClient.withCoreAPI().usingNode(document).getNodeRenditionUntilIsCreated("pdf") - .assertThat().field("status").is("CREATED"); - } - - @Bug(id = "REPO-2042", description = "Should fail only on MAC OS System and Linux", status = Status.FIXED ) - @TestRail(section = { TestGroup.REST_API, TestGroup.RENDITIONS }, executionType = ExecutionType.REGRESSION, - description = "Verify user that created the document can also creates 'pdf' rendition for it with Rest API and status code is 202") - @Test(groups = { TestGroup.REST_API, TestGroup.RENDITIONS, TestGroup.REGRESSION }) - public void userThatCreatedFileCanCreatePdfRenditionForIt() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(user).withCoreAPI().usingNode(document).createNodeRendition("pdf"); - restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); - - restClient.withCoreAPI().usingNode(document).getNodeRenditionUntilIsCreated("pdf") - .assertThat().field("status").is("CREATED"); - } - - @Bug(id = "REPO-2042", description = "Should fail only on MAC OS System and Linux", status = Status.FIXED ) - @TestRail(section = { TestGroup.REST_API, TestGroup.RENDITIONS }, executionType = ExecutionType.REGRESSION, - description = "Verify user that created the document can also creates 'doclib' rendition for it with Rest API and status code is 202") - @Test(groups = { TestGroup.REST_API, TestGroup.RENDITIONS, TestGroup.REGRESSION }) - public void userThatCreatedFileCanCreateDoclibRenditionForIt() throws JsonToModelConversionException, Exception - { - FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder(); - restClient.authenticateUser(user) - .configureRequestSpec() - .addMultiPart("filedata", Utility.getResourceTestDataFile("my-file.tif")); - - RestNodeModel fileNode = restClient.authenticateUser(user).withCoreAPI().usingResource(folder).createNode(); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - document = new FileModel("my-file.tif"); - document.setCmisLocation(folder.getCmisLocation() + "/my-file.tif"); - document.setNodeRef(fileNode.getId()); - - restClient.authenticateUser(user).withCoreAPI().usingNode(document).createNodeRendition("doclib"); - restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); - - // Renditions are async - Utility.sleep(500, 60000, () -> - { - restClient.withCoreAPI().usingNode(document).getNodeRenditionUntilIsCreated("doclib") - .assertThat().field("status").is("CREATED"); - }); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/renditions/GetRenditionTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/renditions/GetRenditionTests.java deleted file mode 100644 index c917265ae..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/renditions/GetRenditionTests.java +++ /dev/null @@ -1,157 +0,0 @@ -package org.alfresco.service.search.rest.renditions; - -import static org.alfresco.utility.report.log.Step.STEP; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.core.RestResponse; -import org.alfresco.rest.model.RestNodeModel; -import org.alfresco.rest.model.RestRenditionInfoModel; -import org.alfresco.utility.Utility; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.report.Bug.Status; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.Assert; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Handles tests related to GET api-explorer/#!/renditions - * @author Cristina Axinte - * - */ -@Test(groups = {TestGroup.REQUIRE_TRANSFORMATION}) -public class GetRenditionTests extends RestTest -{ - private UserModel user; - private SiteModel site; - private FileModel file1; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - user = dataUser.createRandomTestUser(); - site = dataSite.usingUser(user).createPublicRandomSite(); - file1 = dataContent.usingUser(user).usingSite(site).createContent(DocumentType.TEXT_PLAIN); - } - - @Bug(id = "REPO-2449", status = Status.FIXED) - @Test(groups = { TestGroup.REST_API, TestGroup.RENDITIONS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.RENDITIONS }, executionType = ExecutionType.SANITY, - description = "Verify that ZIP document preview is rendered") - public void verifyPreviewOfZipFile() throws Exception - { - STEP("1. Create a folder in existing site"); - FolderModel folder = FolderModel.getRandomFolderModel(); - folder = dataContent.usingUser(user).usingSite(site).createFolder(folder); - - STEP("2. Upload a local ZIP file using RESTAPI"); - restClient.authenticateUser(user).configureRequestSpec().addMultiPart("filedata", Utility.getResourceTestDataFile("content-zip-test.zip")); - - RestNodeModel fileNode = restClient.authenticateUser(user).withCoreAPI().usingNode(folder).createNode(); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - FileModel file = new FileModel("content-zip-test.zip"); - file.setCmisLocation(folder.getCmisLocation() + "/content-zip-test.zip"); - file.setNodeRef(fileNode.getId()); - - STEP("3. Create preview of ZIP file using RESTAPI"); - restClient.withCoreAPI().usingNode(file).createNodeRendition("pdf"); - restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); - - STEP("4. Verify preview of ZIP file is created using RESTAPI"); - RestRenditionInfoModel renditionInfo = restClient.withCoreAPI().usingNode(file).getNodeRenditionUntilIsCreated("pdf"); - restClient.assertStatusCodeIs(HttpStatus.OK); - renditionInfo.assertThat().field("status").is("CREATED"); - } - - @Bug(id = "REPO-2485", status = Status.FIXED) - @Test(groups = { TestGroup.REST_API, TestGroup.RENDITIONS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.RENDITIONS }, executionType = ExecutionType.SANITY, - description = "Verify that ZIP document thumbnail is rendered") - public void verifyThumbnailOfZipFile() throws Exception - { - STEP("1. Create a folder in existing site"); - FolderModel folder = FolderModel.getRandomFolderModel(); - folder = dataContent.usingUser(user).usingSite(site).createFolder(folder); - - STEP("2. Upload a local ZIP file using RESTAPI"); - restClient.authenticateUser(user).configureRequestSpec().addMultiPart("filedata", Utility.getResourceTestDataFile("content-zip-test.zip")); - - RestNodeModel fileNode = restClient.authenticateUser(user).withCoreAPI().usingNode(folder).createNode(); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - FileModel file = new FileModel("content-zip-test.zip"); - file.setCmisLocation(folder.getCmisLocation() + "/content-zip-test.zip"); - file.setNodeRef(fileNode.getId()); - - STEP("3. Create thumbnail of ZIP file using RESTAPI"); - restClient.withCoreAPI().usingNode(file).createNodeRendition("doclib"); - restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); - - STEP("4. Verify thumbnail of ZIP file is created and has content using RESTAPI"); - RestRenditionInfoModel renditionInfo = restClient.withCoreAPI().usingNode(file).getNodeRenditionUntilIsCreated("doclib"); - restClient.assertStatusCodeIs(HttpStatus.OK); - renditionInfo.assertThat().field("status").is("CREATED"); - renditionInfo.assertThat().field("content.sizeInBytes").isGreaterThan(120); - } - - /** - * Sanity test for the following endpoint: - * GET /nodes/{nodeId}/renditions/{renditionId}/content - * @throws Exception - */ - @Test(groups = { TestGroup.REST_API, TestGroup.RENDITIONS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.RENDITIONS }, executionType = ExecutionType.SANITY, - description = "Verify that the rendition content can be downloaded using GET /nodes/{nodeId}/renditions/{renditionId}/content") - public void getRenditionContent() throws Exception - { - STEP("1. Create a folder in existing site"); - FolderModel folder = FolderModel.getRandomFolderModel(); - folder = dataContent.usingUser(user).usingSite(site).createFolder(folder); - - STEP("2. Upload a local txt file using RESTAPI"); - restClient.authenticateUser(user).configureRequestSpec().addMultiPart("filedata", Utility.getResourceTestDataFile("iso8859File.txt")); - - RestNodeModel fileNode = restClient.authenticateUser(user).withCoreAPI().usingNode(folder).createNode(); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - FileModel file = new FileModel("iso8859File.txt"); - file.setCmisLocation(folder.getCmisLocation() + "/iso8859File.txt"); - file.setNodeRef(fileNode.getId()); - - STEP("3. Create thumbnail of txt file using RESTAPI"); - restClient.withCoreAPI().usingNode(file).createNodeRendition("doclib"); - restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); - - STEP("4. Verify thumbnail of txt file is created and has content using RESTAPI"); - RestResponse restResponse = restClient.withCoreAPI().usingNode(file).getNodeRenditionContentUntilIsCreated("doclib"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restClient.assertHeaderValueContains("Content-Type","image/png;charset=UTF-8"); - Assert.assertTrue(restResponse.getResponse().body().asInputStream().available() > 0); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.RENDITIONS, TestGroup.SANITY}) - @TestRail(section = {TestGroup.REST_API, TestGroup.RENDITIONS}, executionType = ExecutionType.SANITY, - description = "Verify the Range request header using GET /nodes/{nodeId}/renditions/{renditionId}/content") - public void getVerifyRangeRequestHeader() throws Exception - { - STEP("1. Create thumbnail on file"); - restClient.authenticateUser(user).withCoreAPI().usingNode(file1).createNodeRendition("pdf"); - restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); - - STEP("2. Make GET rendition content using content-range header"); - Utility.sleep(1000, 30000, () -> { - restClient.configureRequestSpec().addHeader("content-range", "bytes=1-10"); - restClient.authenticateUser(user).withCoreAPI().usingNode(file1).getNodeRenditionContent("pdf"); - restClient.assertStatusCodeIs(HttpStatus.PARTIAL_CONTENT); - restClient.assertHeaderValueContains("content-range", "bytes 1-10"); - restClient.assertHeaderValueContains("content-length", String.valueOf(10)); - }); - } -} - diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/renditions/RenditionIntegrationTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/renditions/RenditionIntegrationTests.java deleted file mode 100644 index ece6818aa..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/renditions/RenditionIntegrationTests.java +++ /dev/null @@ -1,81 +0,0 @@ -package org.alfresco.service.search.rest.renditions; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.core.RestResponse; -import org.alfresco.rest.model.RestNodeModel; -import org.alfresco.utility.Utility; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; - -import org.alfresco.utility.model.UserModel; - -import org.springframework.http.HttpStatus; -import org.testng.Assert; -import org.testng.annotations.BeforeClass; - -public abstract class RenditionIntegrationTests extends RestTest -{ - - protected UserModel user; - protected SiteModel site; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - user = dataUser.createRandomTestUser(); - site = dataSite.usingUser(user).createPublicRandomSite(); - } - - /** - * Check that a rendition can be created for the specified node id - * @param fileName - * @param nodeId - * @param renditionId - * @param expectedMimeType - * @throws Exception - */ - protected void checkRendition(String fileName, String nodeId, String renditionId, String expectedMimeType) throws Exception - { - FileModel file = new FileModel(); - file.setNodeRef(nodeId); - - // 1. Create a rendition of the file using RESTAPI - restClient.withCoreAPI().usingNode(file).createNodeRendition(renditionId); - Assert.assertEquals(restClient.getStatusCode(), HttpStatus.ACCEPTED.toString(), - "Failed to submit a request for rendition. [" + fileName+ ", " + renditionId+"] [source file, rendition ID]. "); - - // 2. Verify that a rendition of the file is created and has content using RESTAPI - RestResponse restResponse = restClient.withCoreAPI().usingNode(file).getNodeRenditionContentUntilIsCreated(renditionId); - Assert.assertEquals(restClient.getStatusCode(), HttpStatus.OK.toString(), - "Failed to produce rendition. [" + fileName+ ", " + renditionId+"] [source file, rendition ID] "); - - // 3. Check the returned content type - Assert.assertEquals(restClient.getResponseHeaders().getValue("Content-Type"), expectedMimeType+";charset=UTF-8", - "Rendition was created but it has the wrong Content-Type. [" + fileName+ ", " + renditionId + "] [source file, rendition ID]"); - - - Assert.assertTrue((restResponse.getResponse().body().asInputStream().available() > 0), - "Rendition was created but its content is empty. [" + fileName+ ", " + renditionId+"] [source file, rendition ID] "); - } - - /** - * Upload a file and return its node id - * @param sourceFile - * @return - * @throws Exception - */ - protected RestNodeModel uploadFile(String sourceFile) throws Exception - { - FolderModel folder = FolderModel.getRandomFolderModel(); - folder = dataContent.usingUser(user).usingSite(site).createFolder(folder); - restClient.authenticateUser(user).configureRequestSpec() - .addMultiPart("filedata", Utility.getResourceTestDataFile(sourceFile)); - RestNodeModel fileNode = restClient.authenticateUser(user).withCoreAPI().usingNode(folder).createNode(); - - Assert.assertEquals(restClient.getStatusCode(), HttpStatus.CREATED.toString(), - "Failed to created a node for rendition tests using file " + sourceFile); - - return fileNode; - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/sharedLinks/GetSharedLinksFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sharedLinks/GetSharedLinksFullTests.java deleted file mode 100644 index 414f4537e..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/sharedLinks/GetSharedLinksFullTests.java +++ /dev/null @@ -1,75 +0,0 @@ -package org.alfresco.service.search.rest.sharedLinks; - -import javax.json.Json; -import javax.json.JsonObject; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestNodeModel; -import org.alfresco.rest.model.RestSharedLinksModelCollection; -import org.alfresco.utility.exception.DataPreparationException; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class GetSharedLinksFullTests extends RestTest -{ - private SiteModel privateSite; - private UserModel adminUser, userModel; - protected FileModel file; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws DataPreparationException - { - adminUser = dataUser.getAdminUser(); - userModel = dataUser.createRandomTestUser(); - privateSite = dataSite.usingUser(adminUser).createPrivateRandomSite(); - } - - @Bug(id="REPO-2365") - @TestRail(section = { TestGroup.REST_API, - TestGroup.SHAREDLINKS }, executionType = ExecutionType.REGRESSION, description = "Verify that a user with permission can get allowableOperations on sharedLinks") - @Test(groups = { TestGroup.REST_API, TestGroup.SHAREDLINKS, TestGroup.REGRESSION }) - public void getSharedLinksWithAllowableOperations() throws Exception - { - file = dataContent.usingUser(adminUser).usingSite(privateSite).createContent(DocumentType.TEXT_PLAIN); - - /* - * { "permissions": { "isInheritanceEnabled": true, "locallySet": { "authorityId": "userModel.getUsername()", - * "name": "SiteConsumer", "accessStatus":"ALLOWED" } } } - */ - JsonObject userPermission = Json.createObjectBuilder().add("permissions", - Json.createObjectBuilder().add("isInheritanceEnabled", true).add("locallySet", Json.createObjectBuilder() - .add("authorityId", userModel.getUsername()).add("name", "SiteConsumer").add("accessStatus", "ALLOWED"))) - .build(); - String putBody = userPermission.toString(); - restClient.authenticateUser(adminUser).withCoreAPI().usingNode(file).updateNode(putBody); - restClient.assertStatusCodeIs(HttpStatus.OK); - restClient.authenticateUser(adminUser).withCoreAPI().usingSharedLinks().createSharedLink(file); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - // verify that the permision exists - RestNodeModel permissionsRequest = restClient.authenticateUser(userModel).withCoreAPI().usingNode(file) - .usingParams("include=permissions").getNode(); - permissionsRequest.assertThat().field("permissions.locallySet.authorityId").is("[" + userModel.getUsername() + "]"); - - // because the sharedLink take time to be created, we may need to wait for solr to index it. - int numberOfTries = 0; - RestSharedLinksModelCollection operationsRequest; - do - { - Thread.sleep(1000); - numberOfTries++; - operationsRequest = restClient.authenticateUser(userModel).withCoreAPI().usingSharedLinks().usingParams("include=allowableOperations").getSharedLinks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } while (operationsRequest.getPagination().getCount() == 0 && numberOfTries < 15); - operationsRequest.getPagination().assertThat().field("count").is(1); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/sharedLinks/SharedLinksSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sharedLinks/SharedLinksSanityTests.java deleted file mode 100644 index c7917d8dd..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/sharedLinks/SharedLinksSanityTests.java +++ /dev/null @@ -1,276 +0,0 @@ -package org.alfresco.service.search.rest.sharedLinks; - -import javax.json.Json; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestRenditionInfoModel; -import org.alfresco.rest.model.RestRenditionInfoModelCollection; -import org.alfresco.rest.model.RestSharedLinksModel; -import org.alfresco.rest.model.RestSharedLinksModelCollection; -import org.alfresco.utility.Utility; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.Assert; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Class includes Sanity tests for the shared-links api. Detailed tests would be covered in the alfresco-remote-api test project - * - * @author meenal bhave - */ -public class SharedLinksSanityTests extends RestTest -{ - private UserModel adminUser; - private UserModel testUser1; - - private SiteModel siteModel1; - - private FolderModel folder1; - - private FileModel file1; - private FileModel file2; - private FileModel file3; - private FileModel file4; - private FileModel file5; - private FileModel file6; - private FileModel file7; - private FileModel file8; - - private RestSharedLinksModel sharedLink1; - private RestSharedLinksModel sharedLink2; - private RestSharedLinksModel sharedLink3; - private RestSharedLinksModel sharedLink4; - private RestSharedLinksModel sharedLink5; - private RestSharedLinksModel sharedLink6; - private RestSharedLinksModel sharedLink7; - private RestSharedLinksModel sharedLink8; - private RestRenditionInfoModel nodeRenditionInfo; - - private RestSharedLinksModelCollection sharedLinksCollection; - private RestRenditionInfoModelCollection nodeRenditionInfoCollection; - - private String expiryDate = "2027-03-23T23:00:00.000+0000"; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - - adminUser = dataUser.getAdminUser(); - restClient.authenticateUser(adminUser); - - // Create Standard User - testUser1 = dataUser.usingUser(adminUser).createRandomTestUser(); - - // Create Site - siteModel1 = dataSite.usingUser(testUser1).createPublicRandomSite(); - - folder1 = dataContent.usingUser(adminUser).usingSite(siteModel1).createFolder(); - - file1 = dataContent.usingUser(adminUser).usingResource(folder1).createContent(DocumentType.TEXT_PLAIN); - file2 = dataContent.usingUser(adminUser).usingResource(folder1).createContent(DocumentType.TEXT_PLAIN); - file3 = dataContent.usingUser(adminUser).usingResource(folder1).createContent(DocumentType.TEXT_PLAIN); - file4 = dataContent.usingUser(adminUser).usingResource(folder1).createContent(DocumentType.TEXT_PLAIN); - file5 = dataContent.usingUser(adminUser).usingResource(folder1).createContent(DocumentType.TEXT_PLAIN); - file7 = dataContent.usingUser(adminUser).usingResource(folder1).createContent(DocumentType.TEXT_PLAIN); - file8 = dataContent.usingUser(adminUser).usingResource(folder1).createContent(DocumentType.TEXT_PLAIN); - // Create file6 based on existing resource - FileModel newFile = FileModel.getFileModelBasedOnTestDataFile("sampleContent.txt"); - newFile.setName("sampleContent.txt"); - file6 = dataContent.usingUser(adminUser).usingResource(folder1).createContent(newFile); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.SHAREDLINKS }, executionType = ExecutionType.SANITY, description = "Verify create sharedLinks without Path") - @Test(groups = { TestGroup.REST_API, TestGroup.SHAREDLINKS, TestGroup.SANITY }) - public void testCreateAndGetSharedLinks() throws Exception - { - // Post without includePath - sharedLink1 = restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().createSharedLink(file1); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.onResponse().assertThat().body("entry.nodeId", org.hamcrest.Matchers.equalTo(file1.getNodeRefWithoutVersion())); - restClient.onResponse().assertThat().body("entry.name", org.hamcrest.Matchers.equalTo(file1.getName())); - restClient.onResponse().assertThat().body("entry.id", org.hamcrest.Matchers.equalTo(sharedLink1.getId())); - restClient.onResponse().assertThat().body("entry.path", org.hamcrest.Matchers.nullValue()); - - // Same Checks above using sharedLink methods: GET sharedLink: without includePath - Assert.assertEquals(sharedLink1.getNodeId(), file1.getNodeRefWithoutVersion()); - Assert.assertEquals(sharedLink1.getName(), file1.getName()); - Assert.assertNull(sharedLink1.getPath(), "Path is expected to be null for noauth api: Response shows: " + sharedLink1.toJson()); - - // Get without includePath - restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().getSharedLink(sharedLink1); - restClient.onResponse().assertThat().body("entry.nodeId", org.hamcrest.Matchers.equalTo(file1.getNodeRefWithoutVersion())); - restClient.onResponse().assertThat().body("entry.name", org.hamcrest.Matchers.equalTo(file1.getName())); - restClient.onResponse().assertThat().body("entry.id", org.hamcrest.Matchers.equalTo(sharedLink1.getId())); - restClient.onResponse().assertThat().body("entry.path", org.hamcrest.Matchers.nullValue()); - - /* - * Get all shared-links while allowing indexing to complete and check - * that the created shared-link is displayed - */ - Utility.sleep(1000, 30000, () -> - { - sharedLinksCollection = restClient.withCoreAPI().usingSharedLinks().getSharedLinks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - sharedLinksCollection.assertThat().entriesListContains("id", sharedLink1.getId()).and() - .entriesListContains("nodeId", sharedLink1.getNodeId()); - }); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.SHAREDLINKS }, executionType = ExecutionType.REGRESSION, description = "Verify create sharedLinks with Path") - @Test(groups = { TestGroup.REST_API, TestGroup.SHAREDLINKS, TestGroup.REGRESSION }) - public void testCreateAndGetSharedLinksWithInclude() throws Exception - { - // Post with includePath - sharedLink2 = restClient.authenticateUser(testUser1).withCoreAPI().includePath().usingSharedLinks().createSharedLink(file2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.onResponse().assertThat().body("entry.nodeId", org.hamcrest.Matchers.equalTo(file2.getNodeRefWithoutVersion())); - restClient.onResponse().assertThat().body("entry.name", org.hamcrest.Matchers.equalTo(file2.getName())); - restClient.onResponse().assertThat().body("entry.id", org.hamcrest.Matchers.equalTo(sharedLink2.getId())); - restClient.onResponse().assertThat().body("entry.path", org.hamcrest.Matchers.notNullValue()); - - // Same Checks above using sharedLink methods: POST sharedLink: includePath - Assert.assertEquals(sharedLink2.getNodeId(), file2.getNodeRefWithoutVersion()); - Assert.assertEquals(sharedLink2.getName(), file2.getName()); - Assert.assertNotNull(sharedLink2.getPath(), "Path not expected to be null for noauth api: Response shows: " + sharedLink1.toJson()); - - // Get with includePath - restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().getSharedLink(sharedLink2); - restClient.onResponse().assertThat().body("entry.nodeId", org.hamcrest.Matchers.equalTo(file2.getNodeRefWithoutVersion())); - restClient.onResponse().assertThat().body("entry.name", org.hamcrest.Matchers.equalTo(file2.getName())); - restClient.onResponse().assertThat().body("entry.id", org.hamcrest.Matchers.equalTo(sharedLink2.getId())); - // Verify that path is null since includePath is not supported for this noAuth api - restClient.onResponse().assertThat().body("entry.path", org.hamcrest.Matchers.nullValue()); - - // Get: noAuth with includePath - sharedLink2 = restClient.withCoreAPI().usingSharedLinks().getSharedLink(sharedLink2); - restClient.onResponse().assertThat().body("entry.nodeId", org.hamcrest.Matchers.equalTo(file2.getNodeRefWithoutVersion())); - restClient.onResponse().assertThat().body("entry.name", org.hamcrest.Matchers.equalTo(file2.getName())); - restClient.onResponse().assertThat().body("entry.id", org.hamcrest.Matchers.equalTo(sharedLink2.getId())); - // Verify that path is null since includePath is not supported for this noAuth api - restClient.onResponse().assertThat().body("entry.path", org.hamcrest.Matchers.nullValue()); - - // Same Checks above using sharedLink methods: GET sharedLink: noAuth - Assert.assertEquals(sharedLink2.getNodeId(), file2.getNodeRefWithoutVersion()); - Assert.assertEquals(sharedLink2.getName(), file2.getName()); - Assert.assertNull(sharedLink2.getPath(), "Path is expected to be null for noauth api: Response shows: " + sharedLink2.toJson()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.SHAREDLINKS }, executionType = ExecutionType.SANITY, description = "Verify delete sharedLinks with and without Path") - @Test(groups = { TestGroup.REST_API, TestGroup.SHAREDLINKS, TestGroup.SANITY}) - public void testDeleteSharedLinks() throws Exception - { - sharedLink3 = restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().createSharedLink(file3); - restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().deleteSharedLink(sharedLink3); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - sharedLink4 = restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().createSharedLink(file4); - restClient.authenticateUser(testUser1).withCoreAPI().includePath().usingSharedLinks().deleteSharedLink(sharedLink4); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.SHAREDLINKS }, executionType = ExecutionType.SANITY, description = "Sanity tests for GET {sharedId}/content and POST {sharedId}/email endpoints") - @Test(groups = { TestGroup.REST_API, TestGroup.SHAREDLINKS, TestGroup.SANITY }) - public void testGetSharedLinkContentAndPostEmail() throws Exception - { - // Create shared-link - sharedLink6 = restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().createSharedLink(file6); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - // Make GET {sharedId}/content and check file content - restClient.withCoreAPI().usingSharedLinks().getSharedLinkContent(sharedLink6); - restClient.assertStatusCodeIs(HttpStatus.OK); - restClient.assertHeaderValueContains("Content-Disposition", file6.getName()); - restClient.onResponse().getResponse().body().asString().contains("Sample text."); - - // Make POST {sharedId}/email to send email with created shared-link - String postBody = Json.createObjectBuilder().add("client", "share") - .add("recipientEmails", "john.doe@acme.com") - .build().toString(); - restClient.withCoreAPI().usingSharedLinks().sendSharedLinkEmail(sharedLink6, postBody); - restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.SHAREDLINKS }, executionType = ExecutionType.REGRESSION, description = "Verify get sharedLink/content and get/renditions") - @Test(groups = { TestGroup.REST_API, TestGroup.SHAREDLINKS, TestGroup.REGRESSION, TestGroup.REQUIRE_TRANSFORMATION }) - public void testCreateWithExpiryDateAndGetSharedLinkRendition() throws Exception - { - sharedLink5 = restClient.authenticateUser(testUser1).withCoreAPI().includePath().usingSharedLinks().createSharedLinkWithExpiryDate(file5, expiryDate); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - Assert.assertEquals(sharedLink5.getExpiresAt(), expiryDate); - Assert.assertNotNull(sharedLink5.getPath(), "Path not expected to be null: Response shows: " + sharedLink5.toJson()); - - restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().getSharedLinkRenditions(sharedLink5); - restClient.assertStatusCodeIs(HttpStatus.OK); - - restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().getSharedLinkRendition(sharedLink5, "doclib"); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.SHAREDLINKS }, executionType = ExecutionType.SANITY, description = "Sanity tests for GET /renditions, GET /renditions/{renditionId} and GET /renditions/{renditionId}/content endpoints") - @Test(groups = { TestGroup.REST_API, TestGroup.SHAREDLINKS, TestGroup.SANITY, TestGroup.REQUIRE_TRANSFORMATION }) - public void testGetSharedLinkRendition() throws Exception - { - /* - * Create shared-link and generate renditions for node "doclib"; - * rendition is automatically created when creating "pdf" rendition - */ - sharedLink7 = restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().createSharedLink(file7); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.withCoreAPI().usingNode(file7).createNodeRendition("pdf"); - restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); - - // GET /renditions: wait until all renditions are created and GET all entries - Utility.sleep(1000, 30000, () -> - { - nodeRenditionInfoCollection = restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().getSharedLinkRenditions(sharedLink7); - restClient.assertStatusCodeIs(HttpStatus.OK); - - nodeRenditionInfoCollection.assertThat().entriesListCountIs(2); - nodeRenditionInfoCollection.getEntryByIndex(0).assertThat().field("id").is("doclib").and() - .field("status").is("CREATED"); - nodeRenditionInfoCollection.getEntryByIndex(1).assertThat().field("id").is("pdf").and() - .field("status").is("CREATED"); - }); - - // GET /renditions/{renditionId}: get specific rendition information for the file with shared link - nodeRenditionInfo = restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().getSharedLinkRendition(sharedLink7, "pdf"); - restClient.assertStatusCodeIs(HttpStatus.OK); - nodeRenditionInfo.assertThat().field("id").is("pdf").and() - .field("status").is("CREATED"); - - // GET /renditions/{renditionId}/content: get the rendition content for file with shared link - restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().getSharedLinkRenditionContent(sharedLink7, "pdf"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restClient.assertHeaderValueContains("Content-Type","application/pdf;charset=UTF-8"); - Assert.assertTrue(restClient.onResponse().getResponse().body().asInputStream().available() > 0); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.SHAREDLINKS }, executionType = ExecutionType.SANITY, description = "Sanity tests for Range reuest header on GET shared-links/{sharedId}/renditions/{renditionId}/content endpoints") - @Test(groups = { TestGroup.REST_API, TestGroup.SHAREDLINKS, TestGroup.SANITY, TestGroup.REQUIRE_TRANSFORMATION }) - public void testGetVerifyRangeReguestOnSharedLinks() throws Exception - { - sharedLink8 = restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().createSharedLink(file8); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.withCoreAPI().usingNode(file8).createNodeRendition("pdf"); - restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); - - // GET /renditions/{renditionId}/content: get the Range request header for file with shared links endpoints. - Utility.sleep(1000, 30000, () -> - { - restClient.configureRequestSpec().addHeader("content-range", "bytes=1-10"); - restClient.authenticateUser(testUser1).withCoreAPI().usingSharedLinks().getSharedLinkRenditionContent(sharedLink8, "pdf"); - restClient.assertStatusCodeIs(HttpStatus.PARTIAL_CONTENT); - restClient.assertHeaderValueContains("Content-Type","application/pdf;charset=UTF-8"); - restClient.assertHeaderValueContains("content-range", "bytes 1-10"); - }); - } -} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/GetSiteTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/GetSiteTests.java deleted file mode 100644 index 7a2f5107b..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/GetSiteTests.java +++ /dev/null @@ -1,362 +0,0 @@ -package org.alfresco.service.search.rest.sites; - -import org.alfresco.dataprep.SiteService; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.core.RestRequest; -import org.alfresco.rest.core.RestResponse; -import org.alfresco.rest.model.*; -import org.alfresco.utility.constants.ContainerName; -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.HttpMethod; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import java.util.List; - -import static org.hamcrest.CoreMatchers.equalTo; - -/** - * @author iulia.cojocea - */ - -public class GetSiteTests extends RestTest -{ - private UserModel adminUserModel; - private ListUserWithRoles usersWithRoles; - private UserModel userModel, privateSiteConsumer; - private SiteModel publicSite, privateSite, moderatedSite; - private RestSiteModel restSiteModel; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws DataPreparationException - { - adminUserModel = dataUser.getAdminUser(); - restClient.authenticateUser(adminUserModel); - publicSite = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - usersWithRoles = dataUser.addUsersWithRolesToSite(publicSite, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); - - userModel = dataUser.createRandomTestUser(); - privateSiteConsumer = dataUser.createRandomTestUser(); - - privateSite = dataSite.usingAdmin().createPrivateRandomSite(); - moderatedSite = dataSite.usingAdmin().createModeratedRandomSite(); - dataUser.addUserToSite(privateSiteConsumer, privateSite, UserRole.SiteConsumer); - } - - @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 information and gets status code OK (200)") - public void getSiteWithManagerRole() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingSite(publicSite) - .getSite() - .and().field("id").is(publicSite.getId()) - .and().field("title").is(publicSite.getTitle()); - - 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 information and gets status code OK (200)") - public void getSiteWithCollaboratorRole() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingSite(publicSite) - .getSite() - .and().field("id").is(publicSite.getId()) - .and().field("title").is(publicSite.getTitle()); - 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 information and gets status code OK (200)") - public void getSiteWithContributorRole() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) - .withCoreAPI().usingSite(publicSite) - .getSite() - .and().field("id").is(publicSite.getId()) - .and().field("title").is(publicSite.getTitle()); - 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 information and gets status code OK (200)") - public void getSiteWithConsumerRole() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .withCoreAPI().usingSite(publicSite) - .getSite() - .and().field("id").is(publicSite.getId()) - .and().field("title").is(publicSite.getTitle()); - 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 role gets site information and gets status code OK (200)") - public void getSiteWithAdminRole() throws Exception - { - restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingSite(publicSite) - .getSite() - .and().field("id").is(publicSite.getId()) - .and().field("title").is(publicSite.getTitle()); - 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 call returns status code 401") -// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void unauthenticatedUserIsNotAuthorizedToRetrieveSite() throws Exception - { - UserModel unauthenticatedManager = dataUser.createRandomTestUser(); - unauthenticatedManager.setPassword("user wrong password"); - dataUser.addUserToSite(unauthenticatedManager, publicSite, UserRole.SiteManager); - restClient.authenticateUser(unauthenticatedManager).withParams("maxItems=10000") - .withCoreAPI() - .getSites(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify invalid request returns status code 404 if siteId does not exist") - public void checkStatusCodeForNonExistentSiteId() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite("NonExistentSiteId").getSite(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "NonExistentSiteId")) - .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 all public and moderated sites if an empty siteId is provided") - public void checkStatusCodeForEmptySiteId() throws Exception - { - restClient.authenticateUser(userModel).withCoreAPI(); - RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "sites/{siteId}", ""); - RestSiteModelsCollection sites = restClient.processModels(RestSiteModelsCollection.class, request); - restClient.assertStatusCodeIs(HttpStatus.OK); - sites.assertThat().entriesListIsNotEmpty(); - } - - @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 details and status code is 200") - public void getPublicSiteByNotASiteMember() throws Exception - { - restSiteModel = restClient.authenticateUser(userModel).withCoreAPI() - .usingSite(publicSite).getSite(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModel.assertThat().field("visibility").is(publicSite.getVisibility()) - .and().field("id").is(publicSite.getId()) - .and().field("description").is(publicSite.getDescription()) - .and().field("title").is(publicSite.getTitle()) - .and().field("guid").isNotEmpty(); - } - - @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 details and status code is 200") - public void getModeratedSiteByNotASiteMember() throws Exception - { - restSiteModel = restClient.authenticateUser(userModel).withCoreAPI() - .usingSite(moderatedSite).getSite(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModel.assertThat().field("visibility").is(moderatedSite.getVisibility()) - .and().field("id").is(moderatedSite.getId()) - .and().field("description").is(moderatedSite.getDescription()) - .and().field("title").is(moderatedSite.getTitle()) - .and().field("guid").isNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if member of a private site gets that site details and status code is 200") - public void getPrivateSiteBySiteMember() throws Exception - { - restSiteModel = restClient.authenticateUser(privateSiteConsumer).withCoreAPI() - .usingSite(privateSite).getSite(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModel.assertThat().field("visibility").is(privateSite.getVisibility()) - .and().field("id").is(privateSite.getId()) - .and().field("description").is(privateSite.getDescription()) - .and().field("title").is(privateSite.getTitle()) - .and().field("guid").isNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if user that is not member of a private site does not get that site details and status code is 200") - public void getPrivateSiteByNotASiteMember() throws Exception - { - restSiteModel = restClient.authenticateUser(userModel).withCoreAPI() - .usingSite(privateSite).getSite(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, privateSite.getTitle())) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }, expectedExceptions = java.lang.AssertionError.class) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Check that properties parameter is applied (guid field is mandatory, thus assertion error is expected)") - public void checkThatPropertiesParameterIsApplied() throws Exception - { - restSiteModel = restClient.authenticateUser(adminUserModel).withParams("properties=id, visibility").withCoreAPI().usingSite(publicSite).getSite(); - restSiteModel.assertThat().field("id").is(publicSite.getId()).and().field("visibility").is(SiteService.Visibility.PUBLIC.toString()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION } ) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Check that properties parameter is applied") - public void checkThatPropertiesParameterIsAppliedPositiveTest() throws Exception - { - restSiteModel = restClient.authenticateUser(adminUserModel).withParams("properties=id,guid,title,visibility").withCoreAPI().usingSite(publicSite).getSite(); - restSiteModel.assertThat().field("id").is(publicSite.getId()).and().field("visibility").is(SiteService.Visibility.PUBLIC.toString()) - .and().field("description").isNull() - .and().field("role").isNull(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION } ) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Delete site then get site details") - public void deleteSiteThenGetSiteDetails() throws Exception - { - SiteModel newSite = dataSite.usingAdmin().createPublicRandomSite(); - dataSite.deleteSite(newSite); - restSiteModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(newSite).getSite(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newSite.getId())) - .containsErrorKey(RestErrorModel.ENTITY_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= "Delete site then get site details") - public void updateSiteVisibilityToPrivateThenGetSite() throws Exception - { - SiteModel newSite = dataSite.usingAdmin().createPublicRandomSite(); - restSiteModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(newSite).getSite(); - restClient.assertStatusCodeIs(HttpStatus.OK); - dataSite.updateSiteVisibility(newSite, SiteService.Visibility.PRIVATE); - restSiteModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(newSite).getSite(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restSiteModel.assertThat().field("id").is(newSite.getId()) - .and().field("visibility").is(SiteService.Visibility.PRIVATE.toString()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION } ) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Check that relations parameter is applied for containers") - public void checkThatRelationsParameterIsAppliedForContainers() throws Exception - { - List jsonObjects = restClient.authenticateUser(adminUserModel) - .withParams("relations=containers").withCoreAPI().usingSite(publicSite).getSiteWithRelations(); - - RestSiteModel siteModel = (RestSiteModel) jsonObjects.get(0); - RestSiteContainerModelsCollection containers = (RestSiteContainerModelsCollection) jsonObjects.get(1); - - siteModel.assertThat().field("visibility").is(publicSite.getVisibility()) - .and().field("id").is(publicSite.getId()) - .and().field("description").is(publicSite.getDescription()) - .and().field("title").is(publicSite.getTitle()) - .and().field("preset").is("site-dashboard") - .and().field("guid").isNotEmpty(); - - containers.assertThat().entriesListCountIs(1) - .and().entriesListContains("folderId", ContainerName.documentLibrary.toString()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION } ) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Check that relations parameter is applied for members") - public void checkThatRelationsParameterIsAppliedForMembers() throws Exception - { - SiteModel publicRandomSite = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - List jsonObjects = restClient.authenticateUser(adminUserModel) - .withParams("relations=members").withCoreAPI().usingSite(publicRandomSite).getSiteWithRelations(); - - RestSiteModel siteModel = (RestSiteModel) jsonObjects.get(0); - RestSiteMemberModelsCollection siteMembers = (RestSiteMemberModelsCollection) jsonObjects.get(1); - - siteModel.assertThat().field("visibility").is(publicRandomSite.getVisibility()) - .and().field("id").is(publicRandomSite.getId()) - .and().field("description").is(publicRandomSite.getDescription()) - .and().field("title").is(publicRandomSite.getTitle()) - .and().field("preset").is("site-dashboard") - .and().field("guid").isNotEmpty(); - - siteMembers.assertThat().entriesListCountIs(1) - .assertThat().entriesListContains("id", adminUserModel.getUsername()) - .assertThat().entriesListContains("role", UserRole.SiteManager.toString()); - siteMembers.getOneRandomEntry().onModel().assertThat().field("person.firstName").is("Administrator") - .and().field("person.id").is("admin"); - } - - @Test(groups="demo") - public void checkThatRelationsParameterIsAppliedForMembersCustom() - { - /*1 - select API endpoint*/ - restClient.withCoreAPI(); - - /*2 - define request */ - RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "sites/{siteId}?{parameters}", publicSite.getId(), "relations=members"); - - /*3 - send request */ - RestResponse response = restClient.authenticateUser(adminUserModel).process(request); - - /*assertions */ - response.assertThat().body("entry.id", equalTo(publicSite.getId())); - response.assertThat().body("relations.members.list.entries.entry[0].role", equalTo("SiteManager")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION } ) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Check that relations parameter is applied for containers and members") - public void checkThatRelationsParameterIsAppliedForContainersAndMembers() throws Exception - { - SiteModel publicRandomSite = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - List jsonObjects = restClient.authenticateUser(adminUserModel) - .withParams("relations=containers,members").withCoreAPI().usingSite(publicRandomSite).getSiteWithRelations(); - - RestSiteModel siteModel = (RestSiteModel) jsonObjects.get(0); - RestSiteContainerModelsCollection containers = (RestSiteContainerModelsCollection) jsonObjects.get(1); - RestSiteMemberModelsCollection siteMembers = (RestSiteMemberModelsCollection) jsonObjects.get(2); - - siteModel.assertThat().field("visibility").is(publicRandomSite.getVisibility()) - .and().field("id").is(publicRandomSite.getId()) - .and().field("description").is(publicRandomSite.getDescription()) - .and().field("title").is(publicRandomSite.getTitle()) - .and().field("preset").is("site-dashboard") - .and().field("guid").isNotEmpty(); - - containers.assertThat().entriesListCountIs(1) - .and().entriesListContains("folderId", ContainerName.documentLibrary.toString()); - - siteMembers.assertThat().entriesListCountIs(1) - .assertThat().entriesListContains("id", adminUserModel.getUsername()) - .assertThat().entriesListContains("role", UserRole.SiteManager.toString()); - siteMembers.getOneRandomEntry().onModel().assertThat().field("person.firstName").is("Administrator") - .and().field("person.id").is("admin"); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/GetSitesTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/GetSitesTests.java deleted file mode 100644 index 2d986ab57..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/GetSitesTests.java +++ /dev/null @@ -1,484 +0,0 @@ -package org.alfresco.service.search.rest.sites; - -import org.alfresco.dataprep.SiteService; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.*; -import org.alfresco.utility.constants.ContainerName; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.data.RandomData; -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.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import java.util.List; - -/** - * @author iulia.cojocea - */ -public class GetSitesTests extends RestTest -{ - private UserModel adminUser; - private UserModel lastPrivateSiteManager; - private ListUserWithRoles usersWithRoles; - private SiteModel siteModel; - private UserModel regularUser, privateSiteManager, privateSiteConsumer; - private SiteModel firstPublicSite, firstPrivateSite, firstModeratedSite, deletedSite; - private SiteModel lastPublicSite, lastPrivateSite, lastModeratedSite; - private RestSiteModelsCollection sites; - private String name; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - regularUser = dataUser.createRandomTestUser(); - lastPrivateSiteManager = dataUser.createRandomTestUser(); - privateSiteManager = dataUser.createRandomTestUser(); - privateSiteConsumer = dataUser.createRandomTestUser(); - - siteModel = new SiteModel(RandomData.getRandomName("0-PublicSite")); - firstPublicSite = dataSite.usingAdmin().createSite(siteModel); - siteModel = new SiteModel(RandomData.getRandomName("0-PrivateSite"), SiteService.Visibility.PRIVATE); - firstPrivateSite = dataSite.usingAdmin().createSite(siteModel); - siteModel = new SiteModel(RandomData.getRandomName("0-ModeratedSite"), SiteService.Visibility.MODERATED); - firstModeratedSite = dataSite.usingAdmin().createSite(siteModel); - dataUser.addUserToSite(privateSiteManager, firstPrivateSite, UserRole.SiteManager); - dataUser.addUserToSite(privateSiteConsumer, firstPrivateSite, UserRole.SiteConsumer); - deletedSite = dataSite.usingAdmin().createPublicRandomSite(); - - name = RandomData.getRandomName("ZZZZZZZZZ-PublicSite"); - lastPublicSite = dataSite.usingAdmin().createSite(new SiteModel(SiteService.Visibility.PUBLIC, "guid", name, name, name)); - lastPrivateSite = dataSite.usingAdmin().createSite(new SiteModel(RandomData.getRandomName("ZZZZZZZZZ-PrivateSite"), SiteService.Visibility.PRIVATE)); - lastModeratedSite = dataSite.usingAdmin().createSite(new SiteModel(RandomData.getRandomName("ZZZZZZZZZ-ModeratedSite"), SiteService.Visibility.MODERATED)); - - adminUser = dataUser.getAdminUser(); - siteModel = dataSite.usingAdmin().createPublicRandomSite(); - usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); - dataUser.addUserToSite(lastPrivateSiteManager, lastPrivateSite, 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 sites information and gets status code OK (200)") - public void managerIsAbleToRetrieveSites() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withParams("maxItems=10000") - .withCoreAPI().getSites() - .assertThat().entriesListIsNotEmpty() - .assertThat().entriesListContains("id", siteModel.getId()) - .and().paginationExist(); - 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 sites information and gets status code OK (200)") - public void collaboratorIsAbleToRetrieveSites() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withParams("maxItems=10000") - .withCoreAPI().getSites().assertThat().entriesListIsNotEmpty() - .assertThat().entriesListContains("id", siteModel.getId()) - .and().paginationExist(); - - 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 sites information and gets status code OK (200)") - public void contributorIsAbleToRetrieveSites() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withParams("maxItems=10000") - .withCoreAPI().getSites() - .assertThat().entriesListIsNotEmpty() - .assertThat().entriesListContains("id", siteModel.getId()) - .and().paginationExist(); - 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 sites information and gets status code OK (200)") - public void consumerIsAbleToRetrieveSites() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withParams("maxItems=10000") - .withCoreAPI().getSites() - .assertThat().entriesListIsNotEmpty() - .assertThat().entriesListContains("id", siteModel.getId()) - .and().paginationExist(); - 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 sites information and gets status code OK (200)") - public void adminUserIsAbleToRetrieveSites() throws Exception - { - restClient.authenticateUser(adminUser).withParams("maxItems=10000") - .withCoreAPI().getSites() - .assertThat().entriesListIsNotEmpty() - .assertThat().entriesListContains("id", siteModel.getId()) - .and().paginationExist(); - 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 sites call returns status code 401") -// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void unauthenticatedUserIsNotAuthorizedToRetrieveSites() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - UserModel userModel = dataUser.createRandomTestUser(); - userModel.setPassword("user wrong password"); - dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); - restClient.authenticateUser(userModel).withParams("maxItems=1") - .withCoreAPI().getSites(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if get sites request returns status code 400 when invalid maxItems parameter is used") - public void getSitesWithInvalidMaxItems() throws Exception - { - restClient.authenticateUser(regularUser).withParams("maxItems=0=09") - .withCoreAPI().getSites(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "0=09")); - - restClient.withParams("maxItems=A") - .withCoreAPI().getSites(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "A")); - - restClient.withParams("maxItems=0") - .withCoreAPI().getSites(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if get sites request returns status code 400 when invalid skipCount parameter is used") - public void getSitesWithInvalidSkipCount() throws Exception - { - restClient.authenticateUser(regularUser).withParams("skipCount=A") - .withCoreAPI().getSites(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "A")); - - restClient.authenticateUser(regularUser).withParams("skipCount=-1") - .withCoreAPI().getSites(); - 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 User gets sites ordered by title ascending and status code is 200") - public void getSitesOrderedByTitleASC() throws Exception - { - sites = restClient.authenticateUser(privateSiteManager).withParams("orderBy=title ASC") - .withCoreAPI().getSites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - sites.assertThat().entriesListIsNotEmpty(); - List sitesList = sites.getEntries(); - sitesList.get(0).onModel().assertThat().field("title").is(firstModeratedSite.getTitle()); - sitesList.get(1).onModel().assertThat().field("title").is(firstPrivateSite.getTitle()); - sitesList.get(2).onModel().assertThat().field("title").is(firstPublicSite.getTitle()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if a regular user gets all public and moderated sites and status code is 200") - public void regularUserGetsOnlyPublicAndModeratedSites() throws Exception - { - sites = restClient.authenticateUser(regularUser).withParams("maxItems=5000") - .withCoreAPI().getSites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - sites.assertThat().entriesListContains("title", firstPublicSite.getTitle()) - .and().entriesListContains("title", firstModeratedSite.getTitle()) - .and().entriesListDoesNotContain("title", firstPrivateSite.getTitle()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if a member of a private site gets the private site, all public sites and all moderated sites. Verify if status code is 200") - public void privateSiteMemberGetsSitesVisibleForHim() throws Exception - { - sites = restClient.authenticateUser(privateSiteConsumer).withParams("maxItems=5000") - .withCoreAPI().getSites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - sites.assertThat().entriesListContains("title", firstPublicSite.getTitle()) - .and().entriesListContains("title", firstModeratedSite.getTitle()) - .and().entriesListContains("title", firstPrivateSite.getTitle()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if a site is not retrieved anymore after deletion and status code is 200") - public void checkDeletedSiteIsNotRetrieved() throws Exception - { - sites = restClient.authenticateUser(regularUser).withParams("maxItems=5000").withCoreAPI().getSites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - sites.assertThat().entriesListContains("title", deletedSite.getTitle()); - - dataSite.usingAdmin().deleteSite(deletedSite); - - sites = restClient.withParams("maxItems=5000").withCoreAPI().getSites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - sites.assertThat().entriesListDoesNotContain("title", deletedSite.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 sites ordered by title descending and status code is 200") - public void getSitesOrderedByTitleDESC() throws Exception - { - int totalItems = restClient.authenticateUser(lastPrivateSiteManager).withCoreAPI().getSites().getPagination().getTotalItems(); - sites = restClient.authenticateUser(lastPrivateSiteManager).withParams(String.format("maxItems=%s&orderBy=title DESC", totalItems)) - .withCoreAPI().getSites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - sites.assertThat().entriesListIsNotEmpty(); - List sitesList = sites.getEntries(); - sitesList.get(0).onModel().assertThat().field("title").is(lastPublicSite.getTitle()); - sitesList.get(1).onModel().assertThat().field("title").is(lastPrivateSite.getTitle()); - sitesList.get(2).onModel().assertThat().field("title").is(lastModeratedSite.getTitle()); - sitesList.get(sitesList.size()-1).onModel().assertThat().field("title").is(firstModeratedSite.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 sites ordered by id ascending and status code is 200") - public void getSitesOrderedByIdASC() throws Exception - { - int totalItems = restClient.authenticateUser(lastPrivateSiteManager).withCoreAPI().getSites().getPagination().getTotalItems(); - sites = restClient.authenticateUser(lastPrivateSiteManager).withParams(String.format("maxItems=%s&orderBy=id ASC", totalItems)) - .withCoreAPI().getSites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - sites.assertThat().entriesListIsNotEmpty(); - List sitesList = sites.getEntries(); - sitesList.get(sitesList.size()-1).onModel().assertThat().field("id").is(lastPublicSite.getId()); - sitesList.get(sitesList.size()-2).onModel().assertThat().field("id").is(lastPrivateSite.getId()); - sitesList.get(sitesList.size()-3).onModel().assertThat().field("id").is(lastModeratedSite.getId()); - sitesList.get(0).onModel().assertThat().field("id").is(firstModeratedSite.getId()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION}) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify pagination") - public void checkPagination() throws Exception - { - sites = restClient.authenticateUser(regularUser).withCoreAPI().getSites(); - sites.getPagination().assertThat() - .field("totalItems").isNotEmpty().and() - .field("maxItems").is("100").and() - .field("hasMoreItems").is((sites.getPagination().getTotalItems() > sites.getPagination().getMaxItems()) ? "true" : "false").and() - .field("skipCount").is("0").and() - .field("count").is((sites.getPagination().isHasMoreItems()) ? sites.getPagination().getMaxItems() : sites.getPagination().getTotalItems()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION}) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify user can get only first two sites and status code is 200") - public void getFirstTwoSites() throws Exception - { - sites = restClient.authenticateUser(regularUser).withParams(String.format("maxItems=%s&orderBy=title ASC", 2)) - .withCoreAPI().getSites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - sites.getPagination().assertThat().field("maxItems").is("2").and().field("count").is("2"); - sites.assertThat().entriesListCountIs(2).and().entriesListDoesNotContain(firstPublicSite.getId()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION}) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify user can get sites using high skipCount parameter and status code is 200") - public void getSitesUsingHighSkipCount() throws Exception - { - RestSiteModelsCollection allSites = restClient.authenticateUser(regularUser).withCoreAPI().getSites(); - sites = restClient.withParams("skipCount=100").withCoreAPI().getSites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - sites.assertThat().paginationField("skipCount").is("100"); - if(allSites.getPagination().getTotalItems() > 100) - sites.assertThat().entriesListIsNotEmpty(); - else - sites.assertThat().entriesListIsEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION}) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify user can not get sites using zero maxItems parameter and status code is 400") - public void userCanNotGetSitesUsingZeroMaxItems() throws Exception - { - sites = restClient.authenticateUser(regularUser).withParams("maxItems=0").withCoreAPI().getSites(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsErrorKey(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) - .containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) - .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 that getSites request applies valid properties param and status code is 200") - public void getSitesRequestWithValidPropertiesParam() throws Exception - { - sites = restClient.authenticateUser(regularUser).withParams("properties=id").withCoreAPI().getSites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - sites.assertThat().entriesListDoesNotContain("description") - .assertThat().entriesListDoesNotContain("title") - .assertThat().entriesListDoesNotContain("visibility") - .assertThat().entriesListDoesNotContain("guid") - .assertThat().entriesListContains("id"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION}) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify pagination when skipCount and MaxItems are used") - public void checkPaginationWithSkipCountAndMaxItems() throws Exception - { - sites = restClient.authenticateUser(regularUser).withParams("skipCount=10&maxItems=110").withCoreAPI().getSites(); - sites.getPagination().assertThat() - .field("totalItems").isNotEmpty().and() - .field("maxItems").is("110").and() - .field("hasMoreItems").is((sites.getPagination().getTotalItems() - sites.getPagination().getSkipCount() > sites.getPagination().getMaxItems())?"true":"false").and() - .field("skipCount").is("10").and() - .field("count").is((sites.getPagination().isHasMoreItems()) ? sites.getPagination().getMaxItems() - : sites.getPagination().getTotalItems() - sites.getPagination().getSkipCount()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION}) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if User gets sites ordered by id ascending and status code is 200") - public void getSitesOrderedByTitleASCAndVisibilityASC() throws Exception - { - SiteModel secondPublicSite = dataSite.usingAdmin().createSite( - new SiteModel(SiteService.Visibility.PUBLIC, "guid", name+"A", name+"A", name)); - SiteModel thirdPublicSite = dataSite.usingAdmin().createSite( - new SiteModel(SiteService.Visibility.PUBLIC, "guid", name+"B", name+"B", name)); - - int totalItems = restClient.authenticateUser(regularUser).withCoreAPI().getSites().getPagination().getTotalItems(); - sites = restClient.authenticateUser(regularUser).withParams(String.format("maxItems=%s&orderBy=title ASC&orderBy=description ASC", totalItems)) - .withCoreAPI().getSites(); - restClient.assertStatusCodeIs(HttpStatus.OK); - sites.assertThat().entriesListIsNotEmpty(); - List sitesList = sites.getEntries(); - sitesList.get(sitesList.size()-1).onModel().assertThat().field("title").is(thirdPublicSite.getTitle()); - sitesList.get(sitesList.size()-2).onModel().assertThat().field("title").is(secondPublicSite.getTitle()); - - dataSite.usingAdmin().deleteSite(secondPublicSite); - dataSite.usingAdmin().deleteSite(thirdPublicSite); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION} ) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Check that relations parameter is applied for containers") - public void checkThatRelationsParameterIsAppliedForContainers() throws Exception - { - List> jsonObjects = restClient.authenticateUser(adminUser) - .withParams("relations=containers").withCoreAPI().usingSite(lastPublicSite).getSitesWithRelations(); - - List siteObjects = jsonObjects.get(0); - for (int i = 0; i < siteObjects.size(); i++) - { - RestSiteModel siteModel = (RestSiteModel) siteObjects.get(i); - siteModel.assertThat().field("visibility").isNotEmpty() - .and().field("id").isNotEmpty() - .and().field("title").isNotEmpty() - .and().field("preset").is("site-dashboard") - .and().field("guid").isNotEmpty(); - } - - List containerObjects = jsonObjects.get(1); - for (int i = 0; i < containerObjects.size(); i++) - { - RestSiteContainerModelsCollection containers = (RestSiteContainerModelsCollection) containerObjects.get(i); - containers.assertThat().entriesListIsNotEmpty().and().entriesListContains("folderId", ContainerName.documentLibrary.toString()); - } - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION} ) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Check that relations parameter is applied for members") - public void checkThatRelationsParameterIsAppliedForMembers() throws Exception - { - List> jsonObjects = restClient.authenticateUser(adminUser) - .withParams("relations=members").withCoreAPI().usingSite(lastPublicSite).getSitesWithRelations(); - - List siteObjects = jsonObjects.get(0); - for (int i = 0; i < siteObjects.size(); i++) - { - RestSiteModel siteModel = (RestSiteModel) siteObjects.get(i); - siteModel.assertThat().field("visibility").isNotEmpty() - .and().field("id").isNotEmpty() - .and().field("title").isNotEmpty() - .and().field("preset").is("site-dashboard") - .and().field("guid").isNotEmpty(); - } - - List memberObjects = jsonObjects.get(1); - for (int i = 0; i < memberObjects.size(); i++) - { - RestSiteMemberModelsCollection siteMembers = (RestSiteMemberModelsCollection) memberObjects.get(i); - siteMembers.assertThat().entriesListIsNotEmpty().assertThat().entriesListContains("id").assertThat().entriesListContains("role", UserRole.SiteManager.toString()); - siteMembers.getOneRandomEntry().onModel().assertThat().field("person.firstName").isNotEmpty().and().field("person.id").isNotEmpty(); - } - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION} ) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Check that relations parameter is applied for members and containers") - public void checkThatRelationsParameterIsAppliedForMembersAndContainers() throws Exception - { - List> jsonObjects = restClient.authenticateUser(adminUser) - .withParams("relations=containers,members").withCoreAPI().usingSite(lastPublicSite).getSitesWithRelations(); - - List siteObjects = jsonObjects.get(0); - for (int i = 0; i < siteObjects.size(); i++) - { - RestSiteModel siteModel = (RestSiteModel) siteObjects.get(i); - siteModel.assertThat().field("visibility").isNotEmpty() - .and().field("id").isNotEmpty() - .and().field("title").isNotEmpty() - .and().field("preset").is("site-dashboard") - .and().field("guid").isNotEmpty(); - } - - List containerObjects = jsonObjects.get(1); - for (int i = 0; i < containerObjects.size(); i++) - { - RestSiteContainerModelsCollection containers = (RestSiteContainerModelsCollection) containerObjects.get(i); - containers.assertThat().entriesListIsNotEmpty().and().entriesListContains("folderId", ContainerName.documentLibrary.toString()); - } - - List memberObjects = jsonObjects.get(2); - for (int i = 0; i < memberObjects.size(); i++) - { - RestSiteMemberModelsCollection siteMembers = (RestSiteMemberModelsCollection) memberObjects.get(i); - siteMembers.assertThat().entriesListIsNotEmpty().assertThat().entriesListContains("id").assertThat().entriesListContains("role", UserRole.SiteManager.toString()); - siteMembers.getOneRandomEntry().onModel().assertThat().field("person.firstName").isNotEmpty().and().field("person.id").isNotEmpty(); - } - } - - @AfterClass(alwaysRun=true) - public void cleanup() throws Exception - { - dataSite.usingAdmin().deleteSite(firstModeratedSite); - dataSite.usingAdmin().deleteSite(firstPrivateSite); - dataSite.usingAdmin().deleteSite(firstPublicSite); - - dataSite.usingAdmin().deleteSite(lastPublicSite); - dataSite.usingAdmin().deleteSite(lastPrivateSite); - dataSite.usingAdmin().deleteSite(lastModeratedSite); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/SitesNetworkTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/SitesNetworkTests.java deleted file mode 100644 index ea3a9a2e3..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/SitesNetworkTests.java +++ /dev/null @@ -1,85 +0,0 @@ -package org.alfresco.service.search.rest.sites; - -import org.alfresco.dataprep.SiteService; -import org.alfresco.service.search.rest.NetworkDataPrep; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestSiteMembershipRequestModel; -import org.alfresco.utility.model.SiteModel; -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.BeforeClass; -import org.testng.annotations.Test; - -public class SitesNetworkTests extends NetworkDataPrep -{ - protected SiteModel siteModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - init(); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION, TestGroup.NETWORKS }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify create site membership request returns status code 404 when personId is not member of the domain.") - public void addSiteMembershipRequestWhenPersonIdIsNotInTheDomain() throws Exception - { - restClient.authenticateUser(adminTenantUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(siteModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, adminTenantUser.getUsername().toLowerCase(), siteModel.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION, TestGroup.NETWORKS }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify create site membership request returns status code 200 with tenant.") - public void addSiteMembershipRequestWithTenant() throws Exception - { - SiteModel tenantPublicSite = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); - RestSiteMembershipRequestModel siteMembershipRequest = restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(tenantPublicSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - siteMembershipRequest.assertThat().field("id").is(tenantPublicSite.getId()) - .assertThat().field("site").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Add process item using by admin in other network.") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void getSiteMembershipRequestByAdminInOtherNetwork() throws Exception - { - SiteModel moderatedSite = dataSite.usingUser(secondAdminTenantUser).createModeratedRandomSite(); - - restClient.authenticateUser(adminTenantUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - restClient.authenticateUser(secondAdminTenantUser).withCoreAPI().usingAuthUser().getSiteMembershipRequest(moderatedSite); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, secondAdminTenantUser.getUsername().toLowerCase(), moderatedSite.getId())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Add process item using by the admin in same network.") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void getSiteMembershipRequestByAdminSameNetwork() throws Exception - { - SiteModel moderatedSite = dataSite.usingUser(adminTenantUser).createModeratedRandomSite(); - restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - - RestSiteMembershipRequestModel returnedModel = restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().getSiteMembershipRequest(moderatedSite); - - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedModel.assertThat().field("id").is(moderatedSite.getId()) - .and().field("message").is("Please accept me") - .and().field("site.title").is(moderatedSite.getTitle()) - .and().field("site.visibility").is(SiteService.Visibility.MODERATED.toString()) - .and().field("site.guid").isNotEmpty() - .and().field("site.description").is(moderatedSite.getDescription()) - .and().field("site.preset").is("site-dashboard"); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/SitesTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/SitesTests.java deleted file mode 100644 index 6f2923d0b..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/SitesTests.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.alfresco.service.search.rest.sites; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestSiteModel; -import org.alfresco.utility.model.SiteModel; -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/#!/sites - * - * @author Ana Bozianu - */ -public class SitesTests extends RestTest -{ - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Tests the creation of a site") - public void testCreateSite() throws Exception - { - SiteModel site = RestSiteModel.getRandomSiteModel(); - - RestSiteModel createdSite = restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingSite(site).createSite(); - - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - createdSite.assertThat().field("id").is(site.getId()) - .assertThat().field("title").is(site.getTitle()) - .assertThat().field("description").is(site.getDescription()) - .assertThat().field("visibility").is(site.getVisibility()); - } - -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/containers/GetSiteContainerTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/containers/GetSiteContainerTests.java deleted file mode 100644 index 94c2782b8..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/containers/GetSiteContainerTests.java +++ /dev/null @@ -1,304 +0,0 @@ -package org.alfresco.service.search.rest.sites.containers; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestSiteContainerModel; -import org.alfresco.utility.constants.ContainerName; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.apache.commons.lang3.RandomStringUtils; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * @author iulia.cojocea - */ -public class GetSiteContainerTests extends RestTest -{ - private UserModel adminUserModel; - private SiteModel publicSiteModel, moderatedSiteModel, privateSiteModel, adminPrivateSiteModel; - private ListUserWithRoles usersWithRoles; - private RestSiteContainerModel siteContainerModel; - private UserModel testUser; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - testUser = dataUser.createRandomTestUser(); - - publicSiteModel = dataSite.usingAdmin().createPublicRandomSite(); - moderatedSiteModel = dataSite.usingUser(testUser).createModeratedRandomSite(); - privateSiteModel = dataSite.usingUser(testUser).createPrivateRandomSite(); - adminPrivateSiteModel = dataSite.usingAdmin().createPrivateRandomSite(); - - usersWithRoles = dataUser.addUsersWithRolesToSite(publicSiteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - - dataLink.usingAdmin().usingSite(publicSiteModel).createRandomLink(); - - dataLink.usingAdmin().usingSite(adminPrivateSiteModel).createRandomLink(); - - dataLink.usingUser(testUser).usingSite(privateSiteModel).createRandomLink(); - } - - @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 container and gets status code OK (200)") - public void getSiteContainerWithManagerRole() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - siteContainerModel = restClient.withCoreAPI().usingSite(publicSiteModel).getSiteContainers().getOneRandomEntry(); - restClient.withCoreAPI().usingSite(publicSiteModel).getSiteContainer(siteContainerModel.onModel()) - .assertThat().field("id").is(siteContainerModel.onModel().getId()) - .and().field("folderId").is(siteContainerModel.onModel().getFolderId()); - 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 container and gets status code OK (200)") - public void getSiteContainerWithCollaboratorRole() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - siteContainerModel = restClient.withCoreAPI().usingSite(publicSiteModel).getSiteContainers().getOneRandomEntry(); - restClient.withCoreAPI().usingSite(publicSiteModel).getSiteContainer(siteContainerModel.onModel()) - .and().field("id").is(siteContainerModel.onModel().getId()) - .and().field("folderId").is(siteContainerModel.onModel().getFolderId()); - 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 container and gets status code OK (200)") - public void getSiteContainerWithContributorRole() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - siteContainerModel = restClient.withCoreAPI().usingSite(publicSiteModel).getSiteContainers().getOneRandomEntry(); - restClient.withCoreAPI().usingSite(publicSiteModel).getSiteContainer(siteContainerModel.onModel()) - .assertThat().field("id").is(siteContainerModel.onModel().getId()) - .and().field("folderId").is(siteContainerModel.onModel().getFolderId()); - 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 container and gets status code OK (200)") - public void getSiteContainerWithConsumerRole() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - siteContainerModel = restClient.withCoreAPI().usingSite(publicSiteModel).getSiteContainers().getOneRandomEntry(); - restClient.withCoreAPI().usingSite(publicSiteModel).getSiteContainer(siteContainerModel.onModel()) - .assertThat().field("id").is(siteContainerModel.onModel().getId()) - .and().field("folderId").is(siteContainerModel.onModel().getFolderId()); - 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 container and gets status code OK (200)") - public void getSiteContainerWithAdminUser() throws Exception - { - restClient.authenticateUser(adminUserModel); - siteContainerModel = restClient.withCoreAPI().usingSite(publicSiteModel).getSiteContainers().getOneRandomEntry(); - restClient.withCoreAPI().usingSite(publicSiteModel).getSiteContainer(siteContainerModel.onModel()) - .assertThat().field("id").is(siteContainerModel.onModel().getId()) - .and().field("folderId").is(siteContainerModel.onModel().getFolderId()); - 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 container call returns status code 401") - public void unauthenticatedUserIsNotAuthorizedToRetrieveSiteContainer() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - siteContainerModel = restClient.withCoreAPI().usingSite(publicSiteModel).getSiteContainers().getOneRandomEntry(); - UserModel userModel = dataUser.createRandomTestUser(); - userModel.setPassword("user wrong password"); - dataUser.addUserToSite(userModel, publicSiteModel, UserRole.SiteManager); - restClient.authenticateUser(userModel) - .withCoreAPI().usingSite(publicSiteModel).getSiteContainer(siteContainerModel.onModel()); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if get container request returns status code 400 when site doesn't exist") - public void getContainerWithNonExistentSite() throws Exception - { - restClient.authenticateUser(testUser) - .withCoreAPI().usingSite("NonExistentSiteId").getSiteContainer(ContainerName.links.toString()); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, "NonExistentSiteId", ContainerName.links.toString())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if get container request returns status code 400 when container item doesn't exist") - public void getContainerWithNonExistentItem() throws Exception - { - restClient.authenticateUser(testUser) - .withCoreAPI().usingSite(publicSiteModel).getSiteContainer("NonExistentFolder"); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, publicSiteModel.getId(), "NonExistentFolder")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify regular user can get container for public site and request returns status 200") - public void getContainerForPublicSite() throws Exception - { - restClient.authenticateUser(testUser) - .withCoreAPI().usingSite(publicSiteModel).getSiteContainer(ContainerName.links.toString()) - .assertThat().field("folderId").is(ContainerName.links.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 manager is able to get container for his private site and request returns status 200") - public void getContainerForPrivateSite() throws Exception - { - restClient.authenticateUser(testUser) - .withCoreAPI().usingSite(privateSiteModel).getSiteContainer(ContainerName.links.toString()) - .assertThat().field("folderId").is(ContainerName.links.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 get container request returns status 200 for moderated site") - public void getContainerForModeratedSite() throws Exception - { - restClient.authenticateUser(testUser) - .withCoreAPI().usingSite(moderatedSiteModel).getSiteContainer(ContainerName.documentLibrary.toString()) - .assertThat().field("folderId").is(ContainerName.documentLibrary.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 if get container request with properties parameter returns status code 200 and parameter is applied") - public void getContainerUsingPropertiesParameter() throws Exception - { - restClient.authenticateUser(testUser) - .withCoreAPI().usingSite(publicSiteModel).usingParams("properties=id").getSiteContainer(ContainerName.links.toString()) - .assertThat().fieldsCount().is(1) - .and().field("id").isNotEmpty() - .and().field("folderId").isNull(); - 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 container request for a container that does not belong to site returns status code 404") - public void getContainerThatDoesNotBelongToSite() throws Exception - { - restClient.authenticateUser(testUser) - .withCoreAPI().usingSite(moderatedSiteModel).getSiteContainer(ContainerName.links.toString()); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, moderatedSiteModel.getId(), ContainerName.links.toString())) - .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 if get container request for empty siteId returns status code 404") - public void getContainerForEmptySiteId() throws Exception - { - restClient.authenticateUser(testUser) - .withCoreAPI().usingSite("").getSiteContainer(ContainerName.links.toString()); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, "", ContainerName.links.toString())) - .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 if get container request for empty container returns status code 200 and the list of containers") - public void getContainerForEmptyContainer() throws Exception - { - restClient.authenticateUser(testUser) - .withCoreAPI().usingSite(moderatedSiteModel).getSiteContainer(""); - 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 container with name containing special chars returns status code 404") - public void getContainerWithNameContainingSpecialChars() throws Exception - { - String containerSpecialName = RandomStringUtils.randomAlphabetic(2) + "~!%40%23%24%25%5E%26*()_%2B%5B%5D%7B%7D%7C%5C%3B%27%3A%22%2C.%2F%3C%3E"; - - restClient.authenticateUser(testUser) - .withCoreAPI().usingSite(publicSiteModel).getSiteContainer(containerSpecialName); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, publicSiteModel.getId(), containerSpecialName)) - .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 if admin can get container request for a private site created by another user and status code is 200") - public void adminCanGetContainerForPrivateSiteCreatedByUser() throws Exception - { - restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingSite(privateSiteModel).getSiteContainer(ContainerName.links.toString()) - .assertThat().field("folderId").is(ContainerName.links.toString()) - .and().field("id").isNotEmpty(); - 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 user cannot get container request for a private site created by admin and status code is 404") - public void userCannotGetContainerForPrivateSiteCreatedByAdmin() throws Exception - { - restClient.authenticateUser(testUser) - .withCoreAPI().usingSite(adminPrivateSiteModel).getSiteContainer(ContainerName.links.toString()); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, adminPrivateSiteModel.getId(), ContainerName.links.toString())) - .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 if get container request for a deleted container returns status code is 404") - public void getContainerThatWasDeleted() throws Exception - { - restClient.authenticateUser(testUser) - .withCoreAPI().usingSite(privateSiteModel).getSiteContainer(ContainerName.links.toString()) - .assertThat().field("folderId").is(ContainerName.links.toString()); - restClient.assertStatusCodeIs(HttpStatus.OK); - - //use dataprep for delete 'links' container - FolderModel folder= new FolderModel("links"); - folder.setCmisLocation(String.format("/Sites/%s/%s", privateSiteModel.getId(), ContainerName.links.toString())); - dataContent.deleteTree(folder); - - restClient.authenticateUser(testUser) - .withCoreAPI().usingSite(privateSiteModel).getSiteContainer(ContainerName.links.toString()); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, privateSiteModel.getId(), ContainerName.links.toString())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/containers/GetSiteContainersTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/containers/GetSiteContainersTests.java deleted file mode 100644 index b6bd7cc8a..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/containers/GetSiteContainersTests.java +++ /dev/null @@ -1,381 +0,0 @@ -package org.alfresco.service.search.rest.sites.containers; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestSiteContainerModelsCollection; -import org.alfresco.utility.constants.ContainerName; -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 GetSiteContainersTests extends RestTest -{ - private UserModel adminUserModel; - private SiteModel publicSiteModel, publicSiteWithContainers; - private SiteModel moderatedSiteModel, privateSiteModel; - private ListUserWithRoles publicSiteUsers; - private ListUserWithRoles publicSiteWithContainersUsers; - private RestSiteContainerModelsCollection restSiteContainers; - private int totalItems; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - publicSiteModel = dataSite.usingAdmin().createPublicRandomSite(); - publicSiteWithContainers = dataSite.usingAdmin().createPublicRandomSite(); - moderatedSiteModel = dataSite.usingAdmin().createModeratedRandomSite(); - privateSiteModel = dataSite.usingAdmin().createPrivateRandomSite(); - - publicSiteUsers = dataUser.addUsersWithRolesToSite(publicSiteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); - - publicSiteWithContainersUsers = dataUser - .addUsersWithRolesToSite(publicSiteWithContainers, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - - dataLink.usingAdmin().usingSite(publicSiteWithContainers).createRandomLink(); - - dataLink.usingAdmin().usingSite(moderatedSiteModel).createRandomLink(); - - dataLink.usingAdmin().usingSite(privateSiteModel).createRandomLink(); - - restSiteContainers = restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers(); - totalItems = restSiteContainers.getPagination().getTotalItems(); - } - - @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 containers and gets status code OK (200)") - public void getSiteContainersWithManagerRole() throws Exception - { - restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingSite(publicSiteModel).getSiteContainers() - .assertThat().entriesListIsNotEmpty() - .assertThat().paginationExist() - .and().paginationField("count").isNot("0"); - 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 containers and gets status code OK (200)") - public void getSiteContainersWithCollaboratorRole() throws Exception - { - restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.withCoreAPI().usingSite(publicSiteModel).getSiteContainers() - .assertThat().entriesListIsNotEmpty() - .assertThat().paginationExist() - .and().paginationField("count").isNot("0"); - 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 containers and gets status code OK (200)") - public void getSiteContainersWithContributorRole() throws Exception - { - restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteContributor)); - restClient.withCoreAPI().usingSite(publicSiteModel).getSiteContainers() - .assertThat().entriesListIsNotEmpty() - .assertThat().paginationExist() - .and().paginationField("count").isNot("0"); - 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 containers and gets status code OK (200)") - public void getSiteContainersWithConsumerRole() throws Exception - { - restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.withCoreAPI().usingSite(publicSiteModel).getSiteContainers() - .assertThat().entriesListIsNotEmpty() - .assertThat().paginationExist() - .and().paginationField("count").isNot("0"); - 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 containers information and gets status code OK (200)") - public void getSiteContainersWithAdminUser() throws Exception - { - restClient.authenticateUser(adminUserModel); - restClient.withCoreAPI().usingSite(publicSiteModel).getSiteContainers() - .assertThat().entriesListIsNotEmpty() - .assertThat().paginationExist() - .and().paginationField("count").isNot("0"); - 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 containers call returns status code 401 with Manager role") -// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void unauthenticatedUserIsNotAuthorizedToRetrieveSiteContainers() throws Exception - { - UserModel userModel = dataUser.createRandomTestUser(); - userModel.setPassword("user wrong password"); - dataUser.addUserToSite(userModel, publicSiteModel, UserRole.SiteManager); - restClient.authenticateUser(userModel) - .withCoreAPI().usingSite(publicSiteModel).getSiteContainers(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if get site container request returns status code 200 with valid maxItems parameter") - public void getContainersWithValidMaxItems() throws Exception - { - restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteManager)) - .withParams("maxItems=5") - .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() - .assertThat().entriesListCountIs(2) - .and().entriesListContains("folderId" , ContainerName.documentLibrary.toString()) - .and().entriesListContains("folderId", ContainerName.links.toString()); - restClient.assertStatusCodeIs(HttpStatus.OK); - - restClient.withParams("maxItems=1") - .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() - .assertThat().entriesListCountIs(1); - - restClient.withParams("maxItems=3") - .withCoreAPI().usingSite(publicSiteModel).getSiteContainers() - .assertThat().entriesListCountIs(1) - .and().entriesListContains("folderId", ContainerName.documentLibrary.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 if get site container request returns status code 400 when invalid maxItems parameter is used") - public void getContainersWithMaxItemsZero () throws Exception - { - restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteManager)) - .withParams("maxItems=0") - .withCoreAPI().usingSite(publicSiteModel).getSiteContainers(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary("Only positive values supported for maxItems"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if get site container request returns status code 400 when invalid maxItems parameter is used") - public void getContainersWithMaxItemsCharacter () throws Exception - { - restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)) - .withParams("maxItems=test") - .withCoreAPI().usingSite(publicSiteModel).getSiteContainers(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "test")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if get site container request returns status code 200 when maxItems parameter starts with multiple zero") - public void getContainersWithMaxItemsMultipleZero () throws Exception - { - restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteCollaborator)) - .withParams("maxItems=000007") - .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() - .assertThat().entriesListCountIs(2); - 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 containers request returns status code 200 when valid skipCount parameter is used") - public void getSiteContainersWithValidSkipCount() throws Exception - { - restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteManager)).withParams("skipCount=1") - .withCoreAPI().usingSite(publicSiteModel).getSiteContainers() - .assertThat().entriesListCountIs(0); - restClient.assertStatusCodeIs(HttpStatus.OK); - - restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteCollaborator)).withParams("skipCount=1") - .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() - .assertThat().entriesListCountIs(1); - restClient.assertStatusCodeIs(HttpStatus.OK); - - restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteConsumer)).withParams("skipCount=2") - .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() - .assertThat().entriesListCountIs(0); - restClient.assertStatusCodeIs(HttpStatus.OK); - - restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteCollaborator)).withParams("skipCount=0") - .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() - .assertThat().entriesListCountIs(2); - 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 containers request returns status code 400 when invalid skipCount parameter is used") - public void getSiteContainersWithSkipCountCharacter() throws Exception - { - restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)).withParams("skipCount=abc") - .withCoreAPI().usingSite(publicSiteModel).getSiteContainers(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "abc")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if get site containers request returns status code 200 when skipCount parameter starts with multiple zero") - public void getSiteContainersWithSkipCountMultipleZero() throws Exception - { - restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)).withParams("skipCount=00002") - .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() - .assertThat().entriesListCountIs(0); - 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 containers request returns status code 400 when site doesn't exist") - public void getSiteContainersWithNonExistentSite() throws Exception - { - restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingSite("NonExistentSiteId").getSiteContainers(); - 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 containers request returns status 200 for private site") - public void getSiteContainersForPrivateSite() throws Exception - { - restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingSite(privateSiteModel).getSiteContainers() - .assertThat().entriesListCountIs(2); - 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 get site containers request returns status 200 for moderated site") - public void getSiteContainersForModeratedSite() throws Exception - { - restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingSite(moderatedSiteModel).getSiteContainers() - .assertThat().entriesListCountIs(2); - 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 get site containers request returns status 200 for several containers") - public void getSiteContainersForSeveralItems() throws Exception - { - restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() - .assertThat().entriesListCountIs(2) - .and().entriesListContains("folderId" ,ContainerName.documentLibrary.toString()) - .and().entriesListContains("folderId", ContainerName.links.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 get site containers request returns status 200 for one container") - public void getSiteContainersWithOneItem() throws Exception - { - restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingSite(publicSiteModel).getSiteContainers() - .assertThat().entriesListCountIs(1) - .and().entriesListContains("folderId" ,ContainerName.documentLibrary.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 if get site container request with properties parameter applied returns status code 200") - public void getSiteContainersUsingPropertiesParameter() throws Exception - { - restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingSite(publicSiteWithContainers).usingParams("properties=folderId").getSiteContainers() - .assertThat().entriesListCountIs(2) - .and().entriesListContains("folderId", ContainerName.documentLibrary.toString()) - .and().entriesListContains("folderId", ContainerName.links.toString()) - .and().entriesListDoesNotContain("id"); - 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 container request for a container that is not empty returns status code 200") - public void getSiteContainersThatIsNotEmpty() throws Exception - { - restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() - .assertThat().entriesListCountIs(2) - .and().entriesListContains("folderId", ContainerName.documentLibrary.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 if get site containers request returns status code 200 when first container is skipped") - public void getSiteContainersAndSkipFirst() throws Exception - { - restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteCollaborator)) - .withParams("skipCount=1").withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() - .assertThat().entriesListCountIs(1) - .and().entriesListDoesNotContain("folderId", restSiteContainers.getEntries().get(0).onModel().getFolderId()) - .and().entriesListContains("folderId", restSiteContainers.getEntries().get(1).onModel().getFolderId()); - 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 containers request and get last container returns status code 200") - public void getLastSiteContainer() throws Exception - { - restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteCollaborator)) - .withParams("skipCount=" + String.valueOf(totalItems-1)).withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() - .assertThat().entriesListCountIs(1) - .and().entriesListDoesNotContain("folderId", restSiteContainers.getEntries().get(0).onModel().getFolderId()) - .and().entriesListContains("folderId", restSiteContainers.getEntries().get(1).onModel().getFolderId()); - 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 containers request returns status code 200 when high skipCount parameter is used") - public void getSiteContainersWithHighSkipCount() throws Exception - { - restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteCollaborator)) - .withParams("skipCount=999999").withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() - .assertThat().entriesListIsEmpty() - .and().entriesListCountIs(0) - .and().paginationField("skipCount").is("999999"); - 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 container request for an empty siteId returns status code 404") - public void getSiteContainersForEmptySiteId() throws Exception - { - restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingSite("").getSiteContainers(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/AddSiteMemberTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/AddSiteMemberTests.java deleted file mode 100644 index 7ce21de18..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/AddSiteMemberTests.java +++ /dev/null @@ -1,589 +0,0 @@ -package org.alfresco.service.search.rest.sites.members; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.core.JsonBodyGenerator; -import org.alfresco.rest.core.RestRequest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestSiteMemberModel; -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.HttpMethod; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class AddSiteMemberTests extends RestTest -{ - private UserModel adminUserModel; - private SiteModel publicSiteModel, moderatedSiteModel, privateSiteModel; - private ListUserWithRoles publicSiteUsersWithRoles, moderatedSiteUsersWithRoles, privateSiteUsersWithRoles; - private String addMemberJson, addMembersJson; - private RestSiteMemberModel memberModel; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - publicSiteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - moderatedSiteModel = dataSite.usingUser(adminUserModel).createModeratedRandomSite(); - privateSiteModel = dataSite.usingUser(adminUserModel).createPrivateRandomSite(); - publicSiteUsersWithRoles = dataUser.addUsersWithRolesToSite(publicSiteModel, - UserRole.SiteManager, - UserRole.SiteCollaborator, - UserRole.SiteConsumer, - UserRole.SiteContributor); - moderatedSiteUsersWithRoles = dataUser.addUsersWithRolesToSite(moderatedSiteModel, - UserRole.SiteManager, - UserRole.SiteCollaborator, - UserRole.SiteConsumer, - UserRole.SiteContributor); - privateSiteUsersWithRoles = dataUser.addUsersWithRolesToSite(privateSiteModel, - UserRole.SiteManager, - UserRole.SiteCollaborator, - UserRole.SiteConsumer, - UserRole.SiteContributor); - addMemberJson = "{\"role\":\"%s\",\"id\":\"%s\"}"; - addMembersJson = "{\"role\":\"%s\",\"id\":\"%s\"}, {\"role\":\"%s\",\"id\":\"%s\"}"; - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, - description = "Verify that manager is able to add site member and gets status code CREATED (201)") - public void managerIsAbleToAddSiteMember() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteCollaborator); - restClient.authenticateUser(publicSiteUsersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingSite(publicSiteModel).addPerson(testUser) - .assertThat().field("id").is(testUser.getUsername()) - .and().field("role").is(testUser.getUserRole()); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that site collaborator is not able to add site member and gets status code FORBIDDEN (403)") - public void collaboratorIsNotAbleToAddSiteMember() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteConsumer); - restClient.authenticateUser(publicSiteUsersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingSite(publicSiteModel).addPerson(testUser); - - restClient.assertLastError().containsSummary("Permission was denied"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION}) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that site contributor is not able to add site member and gets status code FORBIDDEN (403)") - public void contributorIsNotAbleToAddSiteMember() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteConsumer); - restClient.authenticateUser(publicSiteUsersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) - .withCoreAPI().usingSite(publicSiteModel).addPerson(testUser); - restClient.assertLastError().containsSummary("Permission was denied"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that site consumer is not able to add site member and gets status code FORBIDDEN (403)") - public void consumerIsNotAbleToAddSiteMember() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteConsumer); - restClient.authenticateUser(publicSiteUsersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .withCoreAPI().usingSite(publicSiteModel).addPerson(testUser); - restClient.assertLastError().containsSummary("Permission was denied"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, - description = "Verify that admin user is able to add site member and gets status code CREATED (201)") - public void adminIsAbleToAddSiteMember() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteConsumer); - restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingSite(publicSiteModel).addPerson(testUser) - .and().field("id").is(testUser.getUsername()) - .and().field("role").is(testUser.getUserRole()); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, - description = "Verify that unauthenticated user is not able to add site member") -// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void unauthenticatedUserIsNotAuthorizedToAddSiteMmeber() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteConsumer); - - UserModel userModel = dataUser.createRandomTestUser(); - userModel.setPassword("user wrong password"); - dataUser.addUserToSite(userModel, publicSiteModel, UserRole.SiteManager); - - restClient.authenticateUser(userModel) - .withCoreAPI().usingSite(publicSiteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that manager can add another user as manager to a public site and gets status code CREATED (201)") - public void addManagerToPublicSite() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteManager); - memberModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - memberModel.assertThat().field("id").is(testUser.getUsername()) - .and().field("role").is(testUser.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that manager can add another user as manager to a moderated site and gets status code CREATED (201)") - public void addManagerToModeratedSite() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteManager); - memberModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - memberModel.assertThat().field("id").is(testUser.getUsername()) - .and().field("role").is(testUser.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that manager can add another user as manager to a private site and gets status code CREATED (201)") - public void addManagerToPrivateSite() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteManager); - memberModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - memberModel.assertThat().field("id").is(testUser.getUsername()) - .and().field("role").is(testUser.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that consumer role is not able to add another user to a moderated site and gets status code 403") - public void addUserByConsumerToModeratedSite() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteConsumer); - restClient.authenticateUser(moderatedSiteUsersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingSite(moderatedSiteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that consumer role is not able to add another user to a private site and gets status code 403") - public void addUserByConsumerToPrivateSite() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteConsumer); - restClient.authenticateUser(privateSiteUsersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingSite(privateSiteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that collaborator role is not able to add another user to a moderated site and gets status code 403") - public void addUserByCollaboratorToModeratedSite() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteConsumer); - restClient.authenticateUser(moderatedSiteUsersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingSite(moderatedSiteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that collaborator role is not able to add another user to a private site and gets status code 403") - public void addUserByCollaboratorToPrivateSite() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteConsumer); - restClient.authenticateUser(privateSiteUsersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingSite(privateSiteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that contributor role is not able to add another user to a moderated site and gets status code 403") - public void addUserByContributorToModeratedSite() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteConsumer); - restClient.authenticateUser(moderatedSiteUsersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingSite(moderatedSiteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that contributor role is not able to add another user to a private site and gets status code 403") - public void addUserByContributorToPrivateSite() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteConsumer); - restClient.authenticateUser(privateSiteUsersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingSite(privateSiteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that a user without specified role can not be added to a site and gets status code 400") - public void canNotAddUserWithoutSpecifyingRoleToSite() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - restClient.authenticateUser(adminUserModel).withCoreAPI(); - String json = JsonBodyGenerator.keyValueJson("id", testUser.getUsername()); - RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, json, "sites/{siteId}/members?{parameters}", publicSiteModel.getId(), restClient.getParameters()); - restClient.processModel(RestSiteMemberModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(RestErrorModel.MUST_PROVIDE_ROLE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that a user with inexistent role can not be added to a site and gets status code 400") - public void canNotAddUserWithInexistentRoleToSite() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - restClient.authenticateUser(adminUserModel).withCoreAPI(); - RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, String.format("{\"role\":\"inexistentRole\",\"id\":\"%s\"}", testUser.getUsername()), "sites/{siteId}/members?{parameters}", publicSiteModel.getId(), restClient.getParameters()); - restClient.processModel(RestSiteMemberModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.UNKNOWN_ROLE, "inexistentRole")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that user can not add himself as a manager to a public site and gets status code 403") - public void userAddHimselfAsManagerToPublicSite() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteManager); - restClient.authenticateUser(testUser).withCoreAPI().usingSite(publicSiteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that user can not add himself as a manager to a moderated site and gets status code 403") - public void userAddHimselfAsManagerToModeratedSite() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteManager); - restClient.authenticateUser(testUser).withCoreAPI().usingSite(moderatedSiteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that user can not add himself as a manager to a private site and gets status code 404") - public void userAddHimselfAsManagerToPrivateSite() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteManager); - restClient.authenticateUser(testUser).withCoreAPI().usingSite(privateSiteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, privateSiteModel.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that user can not be added to an inexistent site and gets status code 404") - public void userIsNotAbleToAddUserToAnInexistentSite() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteManager); - SiteModel inexistentSite = new SiteModel("inexistentSite"); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(inexistentSite).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, inexistentSite.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that user can not be added to a site if an empty site id is provided and gets status code 404") - public void userIsNotAbleToAddAnotherUserUsingEmptySiteId() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteManager); - SiteModel inexistentSite = new SiteModel(""); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(inexistentSite).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, inexistentSite.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that inexistent user can not be added to site and gets status code 404") - public void userIsNotAbleToAddInexistentUserToSite() throws Exception - { - UserModel testUser = new UserModel("inexistentUser", "password"); - testUser.setUserRole(UserRole.SiteManager); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, testUser.getUsername())) - .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 that empty username can not be added to site and gets status code 400") - public void userIsNotAbleToAddEmptyUserIdToSite() throws Exception - { - UserModel testUser = new UserModel("", "password"); - testUser.setUserRole(UserRole.SiteManager); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.NO_CONTENT, testUser.getUsername())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that user can not add another user that is already a memeber and gets status code 409") - public void userIsNotAbleToAddUserThatIsAlreadyAMember() throws Exception - { - UserModel collaborator = moderatedSiteUsersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(collaborator); - restClient.assertStatusCodeIs(HttpStatus.CONFLICT).assertLastError().containsSummary(String.format(RestErrorModel.ALREADY_Site_MEMBER, collaborator.getUsername(), moderatedSiteModel.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that several users with different roles can be added once in a row to a site and gets status code 201") - public void addSeveralUsersWithDifferentRolesToASite() throws Exception - { - UserModel firstUser = dataUser.createRandomTestUser("testUser"); - firstUser.setUserRole(UserRole.SiteContributor); - UserModel secondUser = dataUser.createRandomTestUser("testUser"); - secondUser.setUserRole(UserRole.SiteCollaborator); - restClient.authenticateUser(adminUserModel).withCoreAPI(); - String json = String.format(addMembersJson, firstUser.getUserRole(), firstUser.getUsername(), secondUser.getUserRole(), secondUser.getUsername()); - RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, json, "sites/{siteId}/members?{parameters}", publicSiteModel.getId(), restClient.getParameters()); - restClient.processModel(RestSiteMemberModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that several users with same roles can be added once in a row to a site and gets status code 201") - public void addSeveralUsersWithSameRolesToASite() throws Exception - { - UserModel firstUser = dataUser.createRandomTestUser("testUser"); - firstUser.setUserRole(UserRole.SiteCollaborator); - UserModel secondUser = dataUser.createRandomTestUser("testUser"); - secondUser.setUserRole(UserRole.SiteCollaborator); - restClient.authenticateUser(adminUserModel).withCoreAPI(); - String json = String.format(addMembersJson, firstUser.getUserRole(), firstUser.getUsername(), secondUser.getUserRole(), secondUser.getUsername()); - RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, json, "sites/{siteId}/members?{parameters}", publicSiteModel.getId(), restClient.getParameters()); - restClient.processModel(RestSiteMemberModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that several users that are already added to the site can not be added once in a row and gets status code 400") - public void addSeveralUsersThatAreAlreadyAddedToASite() throws Exception - { - UserModel collaborator = moderatedSiteUsersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); - UserModel consumer = moderatedSiteUsersWithRoles.getOneUserWithRole(UserRole.SiteConsumer); - restClient.authenticateUser(adminUserModel).withCoreAPI(); - String json = String.format(addMembersJson, collaborator.getUserRole(), collaborator.getUsername(), consumer.getUserRole(), consumer.getUsername()); - RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, json, "sites/{siteId}/members?{parameters}", moderatedSiteModel.getId(), restClient.getParameters()); - restClient.processModel(RestSiteMemberModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.CONFLICT).assertLastError().containsSummary(String.format(RestErrorModel.ALREADY_Site_MEMBER, collaborator.getUsername(), moderatedSiteModel.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Add new site member request by providing an empty body") - public void addSiteMemberUsingEmptyBody() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI(); - RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "", "sites/{siteId}/members?{parameters}", - publicSiteModel.getId(), restClient.getParameters()); - restClient.processModel(RestSiteMemberModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.NO_CONTENT, "No content to map due to end-of-input")) - .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "No content to map due to end-of-input")) - .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 = "Check lower and upper case letters for role field") - public void checkLowerUpperCaseLettersForRole() throws Exception - { - UserModel user = dataUser.createRandomTestUser(); - - String json = String.format(addMemberJson, "SITEMANAGER", user.getUsername()); - restClient.authenticateUser(adminUserModel).withCoreAPI(); - RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, json, "sites/{siteId}/members?{parameters}", publicSiteModel.getId(), restClient.getParameters()); - restClient.processModel(RestSiteMemberModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.UNKNOWN_ROLE, "SITEMANAGER")) - .containsErrorKey(String.format(RestErrorModel.UNKNOWN_ROLE, "SITEMANAGER")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - - json = String.format(addMemberJson, "sitemanager", user.getUsername()); - restClient.authenticateUser(adminUserModel).withCoreAPI(); - request = RestRequest.requestWithBody(HttpMethod.POST, json, "sites/{siteId}/members?{parameters}", publicSiteModel.getId(), restClient.getParameters()); - restClient.processModel(RestSiteMemberModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.UNKNOWN_ROLE, "sitemanager")) - .containsErrorKey(String.format(RestErrorModel.UNKNOWN_ROLE, "sitemanager")) - .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 = "Check empty value for user role") - public void checkEmptyValueForRole() throws Exception - { - UserModel user = dataUser.createRandomTestUser(); - - String json = String.format(addMemberJson, "", user.getUsername()); - restClient.authenticateUser(adminUserModel).withCoreAPI(); - RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, json, "sites/{siteId}/members?{parameters}", publicSiteModel.getId(), restClient.getParameters()); - restClient.processModel(RestSiteMemberModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "N/A")) - .containsSummary(String.format(RestErrorModel.NO_CONTENT, "N/A")) - .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 that contributor role can be added to public site") - public void addContributorToPublicSite() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteContributor); - memberModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - memberModel.assertThat().field("id").is(testUser.getUsername()) - .and().field("role").is(testUser.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that collaborator role can be added to moderated site") - public void addCollaboratorToModeratedSite() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteCollaborator); - memberModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - memberModel.assertThat().field("id").is(testUser.getUsername()) - .and().field("role").is(testUser.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that contributor role can be added to moderated site") - public void addContributorToModeratedSite() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteContributor); - memberModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - memberModel.assertThat().field("id").is(testUser.getUsername()) - .and().field("role").is(testUser.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that consumer role can be added to moderated site") - public void addConsumerToModeratedSite() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteConsumer); - memberModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - memberModel.assertThat().field("id").is(testUser.getUsername()) - .and().field("role").is(testUser.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that collaborator role can be added to private site") - public void addCollaboratorToPrivateSite() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteCollaborator); - memberModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - memberModel.assertThat().field("id").is(testUser.getUsername()) - .and().field("role").is(testUser.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that contributor role can be added to private site") - public void addContributorToPrivateSite() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteContributor); - memberModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - memberModel.assertThat().field("id").is(testUser.getUsername()) - .and().field("role").is(testUser.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that consumer role can be added to private site") - public void addConsumerToPrivateSite() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteConsumer); - memberModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - memberModel.assertThat().field("id").is(testUser.getUsername()) - .and().field("role").is(testUser.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin can be added to private site by site manager") - public void adminCanBeAddedToPrivateSiteBySiteManager() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser(); - SiteModel privateSite = dataSite.usingUser(testUser).createPrivateRandomSite(); - adminUserModel.setUserRole(UserRole.SiteContributor); - memberModel = restClient.authenticateUser(testUser).withCoreAPI().usingSite(privateSite).addPerson(adminUserModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - memberModel.assertThat().field("id").is(adminUserModel.getUsername()).and().field("role").is(adminUserModel.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin cannot be added to private site by site collaborator") - public void adminCannotBeAddedToPrivateSiteBySiteCollaborator() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser(); - SiteModel privateSite = dataSite.usingUser(testUser).createPrivateRandomSite(); - UserModel siteCollaborator = dataUser.createRandomTestUser(); - dataUser.addUserToSite(siteCollaborator, privateSite, UserRole.SiteCollaborator); - adminUserModel.setUserRole(UserRole.SiteContributor); - memberModel = restClient.authenticateUser(siteCollaborator).withCoreAPI().usingSite(privateSite).addPerson(adminUserModel); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/GetSiteMemberTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/GetSiteMemberTests.java deleted file mode 100644 index 9911bf47a..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/GetSiteMemberTests.java +++ /dev/null @@ -1,396 +0,0 @@ -package org.alfresco.service.search.rest.sites.members; - -import org.alfresco.service.search.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).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @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); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/GetSiteMembersTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/GetSiteMembersTests.java deleted file mode 100644 index fdcf3def4..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/GetSiteMembersTests.java +++ /dev/null @@ -1,355 +0,0 @@ -package org.alfresco.service.search.rest.sites.members; - -import org.alfresco.service.search.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).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @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()); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/RemoveSiteMemberTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/RemoveSiteMemberTests.java deleted file mode 100644 index 485305e59..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/RemoveSiteMemberTests.java +++ /dev/null @@ -1,467 +0,0 @@ -package org.alfresco.service.search.rest.sites.members; - -import org.alfresco.service.search.rest.RestTest; -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.report.Bug; -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 RemoveSiteMemberTests extends RestTest -{ - private SiteModel publicSiteModel, moderatedSiteModel, privateSiteModel; - private UserModel adminUserModel, siteCreator; - private ListUserWithRoles usersWithRoles; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws DataPreparationException - { - adminUserModel = dataUser.getAdminUser(); - siteCreator = dataUser.createRandomTestUser(); - publicSiteModel = dataSite.usingUser(siteCreator).createPublicRandomSite(); - moderatedSiteModel = dataSite.usingUser(siteCreator).createModeratedRandomSite(); - privateSiteModel = dataSite.usingUser(siteCreator).createPrivateRandomSite(); - usersWithRoles = dataUser.addUsersWithRolesToSite(publicSiteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that site manager can delete site member and gets status code 204, 'No Content'") - public void siteManagerIsAbleToDeleteSiteMemberWithConsumerRole() throws Exception - { - UserModel testUserModel = dataUser.createRandomTestUser(); - dataUser.addUserToSite(testUserModel, publicSiteModel, UserRole.SiteConsumer); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(testUserModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMembers() - .assertThat().entriesListDoesNotContain("id", testUserModel.getUsername()); - 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 that site collaborator cannot delete site member and gets status code 403, 'Forbidden'") - public void siteCollaboratorIsNotAbleToDeleteSiteMemberWithConsumerRole() throws Exception - { - UserModel testUserModel = dataUser.createRandomTestUser(); - dataUser.addUserToSite(testUserModel, publicSiteModel, UserRole.SiteConsumer); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(testUserModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY); - - restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMembers() - .assertThat().entriesListContains("id", testUserModel.getUsername()); - 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 that site contributor cannot delete site member and gets status code 403, 'Forbidden'") - public void siteContributorIsNotAbleToDeleteSiteMemberWithConsumerRole() throws Exception - { - UserModel testUserModel = dataUser.createRandomTestUser(); - dataUser.addUserToSite(testUserModel, publicSiteModel, UserRole.SiteConsumer); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - restClient.withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(testUserModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY); - - restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMembers() - .assertThat().entriesListContains("id", testUserModel.getUsername()); - 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 that site consumer cannot delete site member and gets status code 403, 'Forbidden'") - public void siteConsumerIsNotAbleToDeleteSiteMemberWithConsumerRole() throws Exception - { - UserModel testUserModel = dataUser.createRandomTestUser(); - dataUser.addUserToSite(testUserModel, publicSiteModel, UserRole.SiteConsumer); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingSite(publicSiteModel) - .deleteSiteMember(testUserModel); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY); - - restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMembers() - .assertThat().entriesListContains("id", testUserModel.getUsername()); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that unauthenticated user is not able to delete site member") -// @Bug(id = "MNT-16904", description = "It fails only on environment with tenants") - public void unauthenticatedUserIsNotAuthorizedToDeleteSiteMember() throws Exception - { - UserModel testUserModel = dataUser.createRandomTestUser(); - dataUser.addUserToSite(testUserModel, publicSiteModel, UserRole.SiteConsumer); - - UserModel inexistentUser = new UserModel("inexistent user", "inexistent password"); - restClient.authenticateUser(inexistentUser).withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(testUserModel); - - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that manager can NOT delete site member for an inexistent user and gets status code 404, 'Not Found'") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - public void managerIsNotAbleToDeleteInexistentSiteMember() throws Exception - { - UserModel inexistentUser = new UserModel("inexistentUser", "password"); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(inexistentUser); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, inexistentUser.getUsername())); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that manager can NOT delete site member for a non site member and gets status code 400, 'Bad Request'") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - public void managerIsNotAbleToDeleteNotSiteMember() throws Exception - { - UserModel nonMember = dataUser.createRandomTestUser(); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(nonMember); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_ARGUMENT, "argument")); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that manager can NOT delete site member for an invalid site and gets status code 404, 'Not Found'") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - public void managerIsNotAbleToDeleteSiteMemberOfInvalidSite() throws Exception - { - SiteModel invalidSite = new SiteModel("invalidSite"); - UserModel testUserModel = dataUser.createRandomTestUser(); - dataUser.addUserToSite(testUserModel, publicSiteModel, UserRole.SiteConsumer); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingSite(invalidSite).deleteSiteMember(testUserModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, testUserModel.getUsername(), invalidSite.getId())); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that manager can delete a site member with manager role") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - public void siteManagerIsAbleToDeleteSiteMemberWithManagerRole() throws Exception - { - UserModel anothermanager = dataUser.createRandomTestUser(); - dataUser.addUserToSite(anothermanager, publicSiteModel, UserRole.SiteManager); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(anothermanager); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMembers() - .assertThat().entriesListDoesNotContain("id", anothermanager.getUsername()); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that manager can delete site member using \"-me-\" in place of personId") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - public void managerIsAbleToDeleteSiteMemberUsingMe() throws Exception - { - UserModel manager = dataUser.createRandomTestUser(); - dataUser.addUserToSite(manager, publicSiteModel, UserRole.SiteManager); - UserModel meUser = new UserModel("-me-", "password"); - - restClient.authenticateUser(manager); - restClient.withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(meUser); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMembers() - .assertThat().entriesListDoesNotContain("id", manager.getUsername()); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that site collaborator cannot delete a site member with Manager role and gets status code 422") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - public void siteCollaboratorIsNotAbleToDeleteSiteMemberWithManagerRole() throws Exception - { - UserModel managerForDelete = dataUser.createRandomTestUser(); - dataUser.addUserToSite(managerForDelete, publicSiteModel, UserRole.SiteManager); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(managerForDelete); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY) - .assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that site contributor cannot delete site member with Manager role and gets status code 422") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - public void siteContributorIsNotAbleToDeleteSiteMemberWithManagerRole() throws Exception - { - UserModel managerForDelete = dataUser.createRandomTestUser(); - dataUser.addUserToSite(managerForDelete, publicSiteModel, UserRole.SiteManager); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - restClient.withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(managerForDelete); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY) - .assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that site consumer cannot delete site member with Manager role and gets status code 422") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - public void siteConsumerIsNotAbleToDeleteSiteMemberWithManagerRole() throws Exception - { - UserModel managerForDelete = dataUser.createRandomTestUser(); - dataUser.addUserToSite(managerForDelete, publicSiteModel, UserRole.SiteManager); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(managerForDelete); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY) - .assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that site collaborator cannot delete a site member with Contributor role and gets status code 422") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - public void siteCollaboratorIsNotAbleToDeleteSiteMemberWithContributorRole() throws Exception - { - UserModel contributorForDelete = dataUser.createRandomTestUser(); - dataUser.addUserToSite(contributorForDelete, publicSiteModel, UserRole.SiteContributor); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(contributorForDelete); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY) - .assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that site contributor cannot delete site member with Contributor role and gets status code 422") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - public void siteContributorIsNotAbleToDeleteSiteMemberWithContributorRole() throws Exception - { - UserModel contributorForDelete = dataUser.createRandomTestUser(); - dataUser.addUserToSite(contributorForDelete, publicSiteModel, UserRole.SiteContributor); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - restClient.withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(contributorForDelete); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY) - .assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that site consumer cannot delete site member with Contributor role and gets status code 422") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - public void siteConsumerIsNotAbleToDeleteSiteMemberWithContributorRole() throws Exception - { - UserModel contributorForDelete = dataUser.createRandomTestUser(); - dataUser.addUserToSite(contributorForDelete, publicSiteModel, UserRole.SiteContributor); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(contributorForDelete); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY) - .assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that manager can delete a site member with Contributor role") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - public void siteManagerIsAbleToDeleteSiteMemberWithContributorRole() throws Exception - { - UserModel contributorForDelete = dataUser.createRandomTestUser(); - dataUser.addUserToSite(contributorForDelete, publicSiteModel, UserRole.SiteContributor); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(contributorForDelete); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMembers() - .assertThat().entriesListDoesNotContain("id", contributorForDelete.getUsername()); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that site collaborator cannot delete a site member with Collaborator role and gets status code 422") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - public void siteCollaboratorIsNotAbleToDeleteSiteMemberWithCollaboratorRole() throws Exception - { - UserModel collaboratorForDelete = dataUser.createRandomTestUser(); - dataUser.addUserToSite(collaboratorForDelete, publicSiteModel, UserRole.SiteCollaborator); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(collaboratorForDelete); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY) - .assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that site contributor cannot delete site member with Collaborator role and gets status code 422") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - public void siteContributorIsNotAbleToDeleteSiteMemberWithCollaboratorRole() throws Exception - { - UserModel collaboratorForDelete = dataUser.createRandomTestUser(); - dataUser.addUserToSite(collaboratorForDelete, publicSiteModel, UserRole.SiteCollaborator); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - restClient.withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(collaboratorForDelete); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY) - .assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that site consumer cannot delete site member with Collaborator role and gets status code 422") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - public void siteConsumerIsNotAbleToDeleteSiteMemberWithCollaboratorRole() throws Exception - { - UserModel collaboratorForDelete = dataUser.createRandomTestUser(); - dataUser.addUserToSite(collaboratorForDelete, publicSiteModel, UserRole.SiteCollaborator); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(collaboratorForDelete); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY) - .assertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId())); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that manager can delete a site member with Collaborator role") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - public void siteManagerIsAbleToDeleteSiteMemberWithCollaboratorRole() throws Exception - { - UserModel collaboratorForDelete = dataUser.createRandomTestUser(); - dataUser.addUserToSite(collaboratorForDelete, publicSiteModel, UserRole.SiteCollaborator); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingSite(publicSiteModel).deleteSiteMember(collaboratorForDelete); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMembers() - .assertThat().entriesListDoesNotContain("id", collaboratorForDelete.getUsername()); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin can delete a site member with Contributor role and gets status code 204") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - public void adminIsAbleToDeleteSiteMemberWithContributorRole() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel) - .deleteSiteMember(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - dataUser.addUserToSite(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor), publicSiteModel, UserRole.SiteContributor); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin can delete site member with Manager role and gets status code 204") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - public void aminIsAbleToDeleteSiteMemberWithManagerRole() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel) - .deleteSiteMember(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - dataUser.addUserToSite(usersWithRoles.getOneUserWithRole(UserRole.SiteManager), publicSiteModel, UserRole.SiteManager); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin can delete site member with Consumer role and gets status code 204") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - public void adminIsAbleToDeleteSiteMemberWithConsumerRole() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel) - .deleteSiteMember(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - dataUser.addUserToSite(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer), publicSiteModel, UserRole.SiteConsumer); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin can delete a site member with Collaborator role and gets status code 204") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - public void adminIsAbleToDeleteSiteMemberWithCollaboratorRole() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel) - .deleteSiteMember(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - dataUser.addUserToSite(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), publicSiteModel, UserRole.SiteCollaborator); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin can delete a site member of moderated site and gets status code 204") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - public void adminIsAbleToDeleteModeratedSiteMember() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - newMember.setUserRole(UserRole.SiteManager); - dataUser.addUserToSite(newMember, moderatedSiteModel, UserRole.SiteManager); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).deleteSiteMember(newMember); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin can delete a site member of private site and gets status code 204") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - public void adminIsAbleToDeletePrivateSiteMember() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - newMember.setUserRole(UserRole.SiteManager); - dataUser.addUserToSite(newMember, privateSiteModel, UserRole.SiteManager); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).deleteSiteMember(newMember); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that regular user can not delete admin and gets status code 422") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - public void regularUserIsNotAbleToDeleteASiteMember() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingSite(publicSiteModel) - .deleteSiteMember(siteCreator); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() - .containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getTitle())) - .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin can not delete a site member twice and gets status code 404 for the second attempt") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @Bug(id="ACE-5447") - public void adminIsNotAbleToRemoveSiteMemberTwice() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel) - .deleteSiteMember(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel) - .deleteSiteMember(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(RestErrorModel.ENTITY_NOT_FOUND); - dataUser.addUserToSite(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor), publicSiteModel, UserRole.SiteContributor); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify admin is not able to remove from site a user that created a member request that was not accepted yet") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @Bug(id="ACE-5447") - public void adminIsNotAbleToRemoveFromSiteANonExistingMember() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(publicSiteModel); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).deleteSiteMember(newMember); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(RestErrorModel.ENTITY_NOT_FOUND); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/UpdateSiteMemberTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/UpdateSiteMemberTests.java deleted file mode 100644 index 338bbc192..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/members/UpdateSiteMemberTests.java +++ /dev/null @@ -1,546 +0,0 @@ -package org.alfresco.service.search.rest.sites.members; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.core.JsonBodyGenerator; -import org.alfresco.rest.core.RestRequest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestSiteMemberModel; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser; -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.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class UpdateSiteMemberTests extends RestTest -{ - private UserModel adminUser, siteCreator, regularUser; - private SiteModel publicSite, moderatedSite, privateSite; - private ListUserWithRoles publicSiteUsers; - private UserModel userToBeUpdated; - private RestSiteMemberModel updatedMember; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - siteCreator = dataUser.createRandomTestUser(); - publicSite = dataSite.usingUser(siteCreator).createPublicRandomSite(); - moderatedSite = dataSite.usingUser(siteCreator).createModeratedRandomSite(); - privateSite = dataSite.usingUser(siteCreator).createPrivateRandomSite(); - publicSiteUsers = dataUser.addUsersWithRolesToSite(publicSite, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - - regularUser = dataUser.createRandomTestUser(); - regularUser.setUserRole(UserRole.SiteConsumer); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that collaborator is not able to update site member and gets status code FORBIDDEN (403)") - public void collaboratorIsNotAbleToUpdateSiteMember() throws Exception - { - userToBeUpdated = dataUser.createRandomTestUser(); - dataUser.addUserToSite(userToBeUpdated, publicSite, UserRole.SiteConsumer); - userToBeUpdated.setUserRole(UserRole.SiteCollaborator); - restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.withCoreAPI().usingSite(publicSite).updateSiteMember(userToBeUpdated); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY); - restClient.assertLastError() - .containsSummary(String.format("The current user does not have permissions to modify the membership details of the site %s.", publicSite.getTitle())); - } - - @Bug(id = "REPO-1832") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that collaborator is not able to update site member and gets status code FORBIDDEN (403)") - public void collaboratorIsNotAbleToUpdateSiteMemberWithTheSameRole() throws Exception - { - userToBeUpdated = dataUser.createRandomTestUser(); - dataUser.addUserToSite(userToBeUpdated, publicSite, UserRole.SiteConsumer); - userToBeUpdated.setUserRole(UserRole.SiteConsumer); - restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.withCoreAPI().usingSite(publicSite).updateSiteMember(userToBeUpdated); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY); - restClient.assertLastError() - .containsSummary(String.format("The current user does not have permissions to modify the membership details of the site %s.", publicSite.getTitle())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that contributor is not able to update site member and gets status code FORBIDDEN (403)") - public void contributorIsNotAbleToUpdateSiteMember() throws Exception - { - userToBeUpdated = dataUser.createRandomTestUser(); - dataUser.addUserToSite(userToBeUpdated, publicSite, UserRole.SiteConsumer); - userToBeUpdated.setUserRole(UserRole.SiteCollaborator); - restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteContributor)); - restClient.withCoreAPI().usingSite(publicSite).updateSiteMember(userToBeUpdated); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY); - restClient.assertLastError() - .containsSummary(String.format("The current user does not have permissions to modify the membership details of the site %s.", publicSite.getTitle())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that consumer is not able to update site member and gets status code FORBIDDEN (403)") - public void consumerIsNotAbleToUpdateSiteMember() throws Exception - { - userToBeUpdated = dataUser.createRandomTestUser(); - dataUser.addUserToSite(userToBeUpdated, publicSite, UserRole.SiteConsumer); - userToBeUpdated.setUserRole(UserRole.SiteCollaborator); - restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.withCoreAPI().usingSite(publicSite).updateSiteMember(userToBeUpdated); - restClient.assertLastError() - .containsSummary(String.format("The current user does not have permissions to modify the membership details of the site %s.", publicSite.getTitle())); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin is able to update site member and gets status code OK (200)") - public void adminIsAbleToUpdateSiteMember() throws Exception - { - userToBeUpdated = dataUser.createRandomTestUser(); - dataUser.addUserToSite(userToBeUpdated, publicSite, UserRole.SiteConsumer); - userToBeUpdated.setUserRole(UserRole.SiteCollaborator); - restClient.authenticateUser(adminUser); - restClient.withCoreAPI().usingSite(publicSite).updateSiteMember(userToBeUpdated) - .assertThat().field("id").is(userToBeUpdated.getUsername()) - .and().field("role").is(userToBeUpdated.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 = "Verify that unauthenticated user is not able to update site member") -// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void unauthenticatedUserIsNotAuthorizedToUpdateSiteMmeber() throws Exception - { - userToBeUpdated = dataUser.createRandomTestUser(); - dataUser.addUserToSite(userToBeUpdated, publicSite, UserRole.SiteConsumer); - userToBeUpdated.setUserRole(UserRole.SiteCollaborator); - UserModel inexistentUser = new UserModel("inexistent user", "inexistent password"); - restClient.authenticateUser(inexistentUser); - restClient.withCoreAPI().usingSite(publicSite).updateSiteMember(userToBeUpdated); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if update site member request returns status code 404 when nonexistent siteId is used") - public void updateSiteMemberOfNonexistentSite() throws Exception - { - SiteModel deletedSite = dataSite.usingUser(adminUser).createPublicRandomSite(); - dataUser.addUserToSite(regularUser, deletedSite, UserRole.SiteConsumer); - dataSite.deleteSite(deletedSite); - - restClient.authenticateUser(adminUser).withCoreAPI() - .usingSite(deletedSite).updateSiteMember(regularUser); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, deletedSite.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if update site member request returns status code 400 when personId is not member of the site") - public void updateNotASiteMember() throws Exception - { - restClient.authenticateUser(adminUser).withCoreAPI() - .usingSite(publicSite).updateSiteMember(regularUser); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary("User is not a member of the site"); - } - - // @Bug(id="REPO-1642", description = "reproduced on 5.2.1 only, it works on 5.2.0") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if update site member request returns status code 404 when personId does not exist") - public void updateNonexistentSiteMember() throws Exception - { - UserModel nonexistentUser = new UserModel("nonexistentUser", DataUser.PASSWORD); - nonexistentUser.setUserRole(UserRole.SiteContributor); - restClient.authenticateUser(adminUser).withCoreAPI() - .usingSite(publicSite).updateSiteMember(nonexistentUser); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, nonexistentUser.getUsername())); - } - - @Bug(id="REPO-1941") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if a manager is able to downgrade to contributor using -me- string in place of personId.") - public void updateSiteManagerToSiteContributorUsingMe() throws Exception - { - UserModel meManager = dataUser.createRandomTestUser(); - dataUser.addUserToSite(meManager, publicSite, UserRole.SiteManager); - UserModel meUser = new UserModel("-me-", "password"); - meUser.setUserRole(UserRole.SiteContributor); - updatedMember = restClient.authenticateUser(meManager).withCoreAPI() - .usingSite(publicSite).updateSiteMember(meUser); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedMember.assertThat().field("id").is(meManager.getUsername()) - .and().field("role").is(meUser.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if update site member request returns status code 404 when empty siteId is used") - public void updateSiteMemberUsingEmptySiteId() throws Exception - { - restClient.authenticateUser(adminUser).withCoreAPI() - .usingSite("").updateSiteMember(regularUser); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if update site member request returns status code 405 when empty personId is used") - public void updateSiteMemberUsingEmptyPersonId() throws Exception - { - UserModel emptyUser = new UserModel("", DataUser.PASSWORD); - emptyUser.setUserRole(UserRole.SiteCollaborator); - restClient.authenticateUser(adminUser).withCoreAPI() - .usingSite(publicSite).updateSiteMember(emptyUser); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) - .assertLastError().containsSummary(RestErrorModel.PUT_EMPTY_ARGUMENT); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if update site member request returns status code 400 when invalid role is used") - public void updateSiteMemberUsingInvalidRole() throws Exception - { - restClient.authenticateUser(siteCreator).withCoreAPI(); - UserModel siteConsumer = publicSiteUsers.getOneUserWithRole(UserRole.SiteConsumer); - String json = JsonBodyGenerator.keyValueJson("role","invalidRole"); - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, json, "sites/{siteId}/members/{personId}", publicSite.getId(), siteConsumer.getUsername()); - restClient.processModel(RestSiteMemberModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.UNKNOWN_ROLE, "invalidRole")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if manager is able to update another site manager to site collaborator") - public void managerUpdateSiteManagerToSiteCollaborator() throws Exception - { - UserModel siteManager = dataUser.createRandomTestUser(); - dataUser.addUserToSite(siteManager, publicSite, UserRole.SiteManager); - siteManager.setUserRole(UserRole.SiteCollaborator); - updatedMember = restClient.authenticateUser(siteCreator).withCoreAPI() - .usingSite(publicSite).updateSiteMember(siteManager); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedMember.assertThat().field("id").is(siteManager.getUsername()) - .and().field("role").is(siteManager.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if manager is able to update site contributor to site manager") - public void managerUpdateSiteContributorToSiteManager() throws Exception - { - UserModel siteContributor = publicSiteUsers.getOneUserWithRole(UserRole.SiteContributor); - siteContributor.setUserRole(UserRole.SiteManager); - updatedMember = restClient.authenticateUser(siteCreator).withCoreAPI() - .usingSite(publicSite).updateSiteMember(siteContributor); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedMember.assertThat().field("id").is(siteContributor.getUsername()) - .and().field("role").is(siteContributor.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if manager is able to update site collaborator to site manager") - public void managerUpdateSiteCollaboratorToSiteManager() throws Exception - { - UserModel siteCollaborator = publicSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator); - siteCollaborator.setUserRole(UserRole.SiteManager); - updatedMember = restClient.authenticateUser(siteCreator).withCoreAPI() - .usingSite(publicSite).updateSiteMember(siteCollaborator); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedMember.assertThat().field("id").is(siteCollaborator.getUsername()) - .and().field("role").is(siteCollaborator.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.SANITY, - description= "Verify if manager is able to update site consumer to site manager") - public void managerUpdateSiteConsumerToSiteManager() throws Exception - { - UserModel siteConsumer = publicSiteUsers.getOneUserWithRole(UserRole.SiteConsumer); - siteConsumer.setUserRole(UserRole.SiteManager); - updatedMember = restClient.authenticateUser(siteCreator).withCoreAPI() - .usingSite(publicSite).updateSiteMember(siteConsumer); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedMember.assertThat().field("id").is(siteConsumer.getUsername()) - .and().field("role").is(siteConsumer.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if manager is able to downgrade himself to site consumer") - public void publicSiteManagerDowngradesRole() throws Exception - { - UserModel siteManager = publicSiteUsers.getOneUserWithRole(UserRole.SiteManager); - siteManager.setUserRole(UserRole.SiteConsumer); - updatedMember = restClient.authenticateUser(siteManager).withCoreAPI() - .usingSite(publicSite).updateSiteMember(siteManager); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedMember.assertThat().field("id").is(siteManager.getUsername()) - .and().field("role").is(siteManager.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if manager is able to update another site manager to site contributor") - public void managerUpdateSiteManagerToSiteContributor() throws Exception - { - UserModel siteManager = dataUser.createRandomTestUser(); - dataUser.addUserToSite(siteManager, publicSite, UserRole.SiteManager); - - siteManager.setUserRole(UserRole.SiteContributor); - updatedMember = restClient.authenticateUser(siteCreator).withCoreAPI() - .usingSite(publicSite).updateSiteMember(siteManager); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedMember.assertThat().field("id").is(siteManager.getUsername()).and().field("role").is(siteManager.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if manager is able to update another site manager to site consumer") - public void managerUpdateSiteManagerToSiteConsumer() throws Exception - { - UserModel siteManager = dataUser.createRandomTestUser(); - dataUser.addUserToSite(siteManager, publicSite, UserRole.SiteManager); - - siteManager.setUserRole(UserRole.SiteConsumer); - updatedMember = restClient.authenticateUser(siteCreator).withCoreAPI() - .usingSite(publicSite).updateSiteMember(siteManager); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedMember.assertThat().field("id").is(siteManager.getUsername()).and().field("role").is(siteManager.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if manager is able to update site contributor to site collaborator") - public void managerUpdateSiteContributorToSiteCollaborator() throws Exception - { - UserModel siteContributor = dataUser.createRandomTestUser(); - dataUser.addUserToSite(siteContributor, publicSite, UserRole.SiteContributor); - - siteContributor.setUserRole(UserRole.SiteCollaborator); - updatedMember = restClient.authenticateUser(siteCreator).withCoreAPI() - .usingSite(publicSite).updateSiteMember(siteContributor); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedMember.assertThat().field("id").is(siteContributor.getUsername()).and().field("role").is(siteContributor.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if manager is able to update site contributor to site consumer") - public void managerUpdateSiteContributorToSiteConsumer() throws Exception - { - UserModel siteContributor = dataUser.createRandomTestUser(); - dataUser.addUserToSite(siteContributor, publicSite, UserRole.SiteContributor); - - siteContributor.setUserRole(UserRole.SiteConsumer); - updatedMember = restClient.authenticateUser(siteCreator).withCoreAPI() - .usingSite(publicSite).updateSiteMember(siteContributor); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedMember.assertThat().field("id").is(siteContributor.getUsername()).and().field("role").is(siteContributor.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if manager is able to update site collaborator to site contributor") - public void managerUpdateSiteCollaboratorToSiteContributor() throws Exception - { - UserModel siteCollaborator = dataUser.createRandomTestUser(); - dataUser.addUserToSite(siteCollaborator, publicSite, UserRole.SiteCollaborator); - - siteCollaborator.setUserRole(UserRole.SiteContributor); - updatedMember = restClient.authenticateUser(siteCreator).withCoreAPI() - .usingSite(publicSite).updateSiteMember(siteCollaborator); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedMember.assertThat().field("id").is(siteCollaborator.getUsername()).and().field("role").is(siteCollaborator.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if manager is able to update site collaborator to site consumer") - public void managerUpdateSiteCollaboratorToSiteConsumer() throws Exception - { - UserModel siteCollaborator = dataUser.createRandomTestUser(); - dataUser.addUserToSite(siteCollaborator, publicSite, UserRole.SiteCollaborator); - - siteCollaborator.setUserRole(UserRole.SiteConsumer); - updatedMember = restClient.authenticateUser(siteCreator).withCoreAPI() - .usingSite(publicSite).updateSiteMember(siteCollaborator); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedMember.assertThat().field("id").is(siteCollaborator.getUsername()).and().field("role").is(siteCollaborator.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if manager is able to update site consumer to site collaborator") - public void managerUpdateSiteConsumerToSiteCollaborator() throws Exception - { - UserModel siteConsumer = dataUser.createRandomTestUser(); - dataUser.addUserToSite(siteConsumer, publicSite, UserRole.SiteConsumer); - - siteConsumer.setUserRole(UserRole.SiteCollaborator); - updatedMember = restClient.authenticateUser(siteCreator).withCoreAPI() - .usingSite(publicSite).updateSiteMember(siteConsumer); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedMember.assertThat().field("id").is(siteConsumer.getUsername()).and().field("role").is(siteConsumer.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if manager is able to update site consumer to site contributor") - public void managerUpdateSiteConsumerToSiteContributor() throws Exception - { - UserModel siteConsumer = dataUser.createRandomTestUser(); - dataUser.addUserToSite(siteConsumer, publicSite, UserRole.SiteConsumer); - - siteConsumer.setUserRole(UserRole.SiteContributor); - updatedMember = restClient.authenticateUser(siteCreator).withCoreAPI() - .usingSite(publicSite).updateSiteMember(siteConsumer); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedMember.assertThat().field("id").is(siteConsumer.getUsername()).and().field("role").is(siteConsumer.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if manager is able to update another site manager to site manager") - public void managerUpdateSiteManagerToSiteManager() throws Exception - { - UserModel siteManager = dataUser.createRandomTestUser(); - dataUser.addUserToSite(siteManager, publicSite, UserRole.SiteManager); - - siteManager.setUserRole(UserRole.SiteManager); - updatedMember = restClient.authenticateUser(siteCreator).withCoreAPI() - .usingSite(publicSite).updateSiteMember(siteManager); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedMember.assertThat().field("id").is(siteManager.getUsername()).and().field("role").is(siteManager.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if manager is able to update site collaborator to site collaborator") - public void managerUpdateSiteCollaboratorToSiteCollaborator() throws Exception - { - UserModel siteCollaborator = dataUser.createRandomTestUser(); - dataUser.addUserToSite(siteCollaborator, publicSite, UserRole.SiteCollaborator); - - siteCollaborator.setUserRole(UserRole.SiteCollaborator); - updatedMember = restClient.authenticateUser(siteCreator).withCoreAPI() - .usingSite(publicSite).updateSiteMember(siteCollaborator); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedMember.assertThat().field("id").is(siteCollaborator.getUsername()).and().field("role").is(siteCollaborator.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if manager is able to update site contributor to site contributor") - public void managerUpdateSiteContributorToSiteContributor() throws Exception - { - UserModel siteContributor = dataUser.createRandomTestUser(); - dataUser.addUserToSite(siteContributor, publicSite, UserRole.SiteContributor); - - siteContributor.setUserRole(UserRole.SiteContributor); - updatedMember = restClient.authenticateUser(siteCreator).withCoreAPI() - .usingSite(publicSite).updateSiteMember(siteContributor); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedMember.assertThat().field("id").is(siteContributor.getUsername()).and().field("role").is(siteContributor.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if manager is able to update site consumer to site consumer") - public void managerUpdateSiteConsumerToSiteConsumer() throws Exception - { - UserModel siteConsumer = dataUser.createRandomTestUser(); - dataUser.addUserToSite(siteConsumer, publicSite, UserRole.SiteConsumer); - - siteConsumer.setUserRole(UserRole.SiteConsumer); - updatedMember = restClient.authenticateUser(siteCreator).withCoreAPI() - .usingSite(publicSite).updateSiteMember(siteConsumer); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedMember.assertThat().field("id").is(siteConsumer.getUsername()).and().field("role").is(siteConsumer.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if manager of a private site is able to downgrade his role") - public void privateSiteManagerDowngradesRole() throws Exception - { - UserModel siteManager = dataUser.createRandomTestUser(); - dataUser.addUserToSite(siteManager, privateSite, UserRole.SiteManager); - - siteManager.setUserRole(UserRole.SiteConsumer); - updatedMember = restClient.authenticateUser(siteManager).withCoreAPI() - .usingSite(privateSite).updateSiteMember(siteManager); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedMember.assertThat().field("id").is(siteManager.getUsername()).and().field("role").is(siteManager.getUserRole()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if manager of a moderated site is able to downgrade his role") - public void moderatedSiteManagerDowngradesRole() throws Exception - { - UserModel siteManager = dataUser.createRandomTestUser(); - dataUser.addUserToSite(siteManager, moderatedSite, UserRole.SiteManager); - - siteManager.setUserRole(UserRole.SiteConsumer); - updatedMember = restClient.authenticateUser(siteManager).withCoreAPI() - .usingSite(moderatedSite).updateSiteMember(siteManager); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedMember.assertThat().field("id").is(siteManager.getUsername()).and().field("role").is(siteManager.getUserRole()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, - description = "Verify the response of updating a site member with empty body at request") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) - public void managerCanNotUpdateSiteMemberWithEmptyBody() throws Exception - { - restClient.authenticateUser(siteCreator).withCoreAPI(); - UserModel siteCollaborator = dataUser.createRandomTestUser(); - dataUser.addUserToSite(siteCollaborator, publicSite, UserRole.SiteCollaborator); - siteCollaborator.setUserRole(UserRole.SiteConsumer); - - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "", "sites/{siteId}/members/{personId}", publicSite.getId(), siteCollaborator.getUsername()); - restClient.processModel(RestSiteMemberModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.NO_CONTENT, "No content to map due to end-of-input")) - .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "No content to map due to end-of-input")) - .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 if manager is able to update a user that has created a site membership request, but it's not a member of the site yet") - public void managerCanNotUpdateUserWithSiteMembershipRequest() throws Exception - { - UserModel siteConsumer = dataUser.createRandomTestUser(); - siteConsumer.setUserRole(UserRole.SiteConsumer); - restClient.authenticateUser(siteConsumer).withCoreAPI().usingUser(siteConsumer).addSiteMembershipRequest(moderatedSite); - - updatedMember = restClient.authenticateUser(siteCreator).withCoreAPI() - .usingSite(moderatedSite).updateSiteMember(siteConsumer); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(RestErrorModel.NOT_A_MEMBER); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/AddSiteMembershipRequestTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/AddSiteMembershipRequestTests.java deleted file mode 100644 index de28098b4..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/AddSiteMembershipRequestTests.java +++ /dev/null @@ -1,409 +0,0 @@ -package org.alfresco.service.search.rest.sites.membershipRequests; - -import org.alfresco.dataprep.SiteService; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestSiteEntry; -import org.alfresco.rest.model.RestSiteMembershipRequestModel; -import org.alfresco.rest.model.RestSiteMembershipRequestModelsCollection; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser; -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.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class AddSiteMembershipRequestTests extends RestTest -{ - private SiteModel publicSite, anotherPublicSite, moderatedSite, privateSite; - private DataUser.ListUserWithRoles usersWithRoles; - private UserModel adminUser, siteManager, regularUser, newMember; - private RestSiteMembershipRequestModel siteMembershipRequest; - private RestSiteMembershipRequestModelsCollection siteMembershipRequests; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws DataPreparationException - { - adminUser = dataUser.getAdminUser(); - publicSite = dataSite.usingUser(adminUser).createPublicRandomSite(); - usersWithRoles = dataUser.addUsersWithRolesToSite(publicSite, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - - siteManager = dataUser.createRandomTestUser(); - anotherPublicSite = dataSite.usingUser(siteManager).createPublicRandomSite(); - - moderatedSite = dataSite.usingUser(adminUser).createModeratedRandomSite(); - privateSite = dataSite.usingUser(adminUser).createPrivateRandomSite(); - - newMember = dataUser.createRandomTestUser(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, - description = "Verify site manager is able to create new site membership request for himself and status code is 201") - public void managerCreatesNewSiteMembershipRequestForSelf() throws Exception - { - siteMembershipRequest = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingAuthUser().addSiteMembershipRequest(anotherPublicSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - siteMembershipRequest.assertThat().field("id").is(anotherPublicSite.getId()) - .assertThat().field("site").isNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify site contributor is able to create new site membership request for himself and status code is 201") - public void contributorCreatesNewSiteMembershipRequestForSelf() throws Exception - { - siteMembershipRequest = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingAuthUser().addSiteMembershipRequest(anotherPublicSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - siteMembershipRequest.assertThat().field("id").is(anotherPublicSite.getId()) - .assertThat().field("site").isNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify site collaborator is able to create new site membership request for himself and status code is 201") - public void collaboratorCreatesNewSiteMembershipRequestForSelf() throws Exception - { - siteMembershipRequest = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingAuthUser().addSiteMembershipRequest(anotherPublicSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - siteMembershipRequest.assertThat().field("id").is(anotherPublicSite.getId()) - .assertThat().field("site").isNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify site consumer is able to create new site membership request for himself and status code is 201") - public void consumerCreatesNewSiteMembershipRequestForSelf() throws Exception - { - siteMembershipRequest = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingAuthUser().addSiteMembershipRequest(anotherPublicSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - siteMembershipRequest.assertThat().field("id").is(anotherPublicSite.getId()) - .assertThat().field("site").isNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify admin is able to create new site membership request for himself and status code is 201") - public void adminCreatesNewSiteMembershipRequestForSelf() throws Exception - { - siteMembershipRequest = restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(anotherPublicSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - siteMembershipRequest.assertThat().field("id").is(anotherPublicSite.getId()) - .assertThat().field("site").isNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, - description = "Verify unauthenticated user is not able to create new site membership request") - public void unauthenticatedUserIsNotAbleToCreateSiteMembershipRequest() throws Exception - { - restClient.authenticateUser(new UserModel("random user", "random password")).withCoreAPI().usingAuthUser().addSiteMembershipRequest(publicSite); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify addSiteMembershipRequest Rest API status code is 400 for a user that has already been invited") - public void addSiteMembershipRequestStatusCodeIs400ReceivedForAUserThatIsAlreadyInvited() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - dataUser.addUserToSite(newMember, moderatedSite, UserRole.SiteContributor); - restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - restClient.assertLastError().containsSummary(String.format(RestErrorModel.ALREADY_Site_MEMBER, newMember.getUsername(), moderatedSite.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify addSiteMembershipRequest Rest API status code is 404 for a user that does not exist") - public void addSiteMembershipRequestStatusCodeIs404ReceivedForAUserThatDoesNotExist() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingUser(new UserModel("invalidUser", "password")).addSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - restClient.assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidUser")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify addSiteMembershipRequest Rest API status code is 404 for a site that does not exist") - public void addSiteMembershipRequestStatusCodeIs404ReceivedForASiteThatDoesNotExist() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest(new SiteModel("invalidSiteID")); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - restClient.assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, newMember.getUsername(), "invalidSiteID")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify addSiteMembershipRequest Rest API status code is 400 for empty request body") - public void addSiteMembershipRequestStatusCodeIs400ForEmptyRequestBody() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest(""); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.NO_CONTENT, "No content to map due to end-of-input")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify addSiteMembershipRequest Rest API status code is 201 for request with empty message") - public void addSiteMembershipRequestStatusCodeIs201ForRequestWithEmptyMessage() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - siteMembershipRequest = restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest("", moderatedSite, "New request"); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - siteMembershipRequest.assertThat().field("id").is(moderatedSite.getId()).assertThat().field("site").isNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify addSiteMembershipRequest Rest API status code is 201 for request with empty title") - public void addSiteMembershipRequestStatusCodeIs201ForRequestWithEmptyTitle() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - siteMembershipRequest = restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest("Please accept me", moderatedSite, ""); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - siteMembershipRequest.assertThat().field("id").is(moderatedSite.getId()).assertThat().field("site").isNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site manager is not able to create new site membership request for other user") - public void managerIsNotAbleToCreateSiteMembershipRequestForOtherUser() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingUser(newMember) - .addSiteMembershipRequest(publicSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())) - .statusCodeIs(HttpStatus.NOT_FOUND) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site collaborator is not able to create new site membership request for other user") - public void collaboratorIsNotAbleToCreateSiteMembershipRequestForOtherUser() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingUser(newMember) - .addSiteMembershipRequest(publicSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site contributor is not able to create new site membership request for other user") - public void contributorIsNotAbleToCreateSiteMembershipRequestForOtherUser() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingUser(newMember) - .addSiteMembershipRequest(publicSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site consumer is not able to create new site membership request for other user") - public void consumerIsNotAbleToCreateSiteMembershipRequestForOtherUser() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingUser(newMember) - .addSiteMembershipRequest(publicSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin user is not able to create new site membership request for other user") - public void adminIsNotAbleToCreateSiteMembershipRequestForOtherUser() throws Exception - { - restClient.authenticateUser(adminUser).withCoreAPI().usingUser(newMember).addSiteMembershipRequest(publicSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); - - restClient.withCoreAPI().usingUser(newMember).addSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); - - restClient.withCoreAPI().usingUser(newMember).addSiteMembershipRequest(privateSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); - } - - @Bug(id="ACE-2413") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify addSiteMembershipRequest Rest API status code is 400 for an invalid user id") - public void addSiteMembershipRequestReturns400ForEmptyUserId() throws Exception - { - restClient.authenticateUser(adminUser).withCoreAPI() - .usingUser(new UserModel("", "password")).addSiteMembershipRequest(publicSite); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify regular user is able to create new public site membership request for himself. Check that user joins immediately as consumer.") - public void userIsAbleToRequestMembershipOfPublicSite() throws Exception - { - regularUser = dataUser.createRandomTestUser(); - siteMembershipRequest = restClient.authenticateUser(regularUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(publicSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - siteMembershipRequest.assertThat().field("id").is(publicSite.getId()) - .assertThat().field("site").isNotEmpty(); - RestSiteEntry siteEntry = restClient.withCoreAPI().usingAuthUser().getSiteMembership(publicSite); - restClient.assertStatusCodeIs(HttpStatus.OK); - siteEntry.assertThat().field("role").is(UserRole.SiteConsumer) - .and().field("id").is(publicSite.getId()); - siteMembershipRequests = restClient.withCoreAPI().usingAuthUser().getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.OK); - siteMembershipRequests.assertThat().entriesListIsEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify regular user is able to create new moderated site membership request for himself. Check that the request is added to the site membership request list.") - public void userIsAbleToRequestMembershipOfModeratedSite() throws Exception - { - regularUser = dataUser.createRandomTestUser(); - siteMembershipRequest = restClient.authenticateUser(regularUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - siteMembershipRequest.assertThat().field("id").is(moderatedSite.getId()) - .assertThat().field("message").is("Please accept me") - .assertThat().field("site").isNotEmpty(); - siteMembershipRequest.getSite() - .assertThat().field("visibility").is(moderatedSite.getVisibility()) - .assertThat().field("guid").is(moderatedSite.getGuid()) - .assertThat().field("description").is(moderatedSite.getDescription()) - .assertThat().field("id").is(moderatedSite.getId()) - .assertThat().field("title").is(moderatedSite.getTitle()); - - siteMembershipRequests = restClient.withCoreAPI().usingAuthUser().getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.OK); - siteMembershipRequests.assertThat().entriesListContains("id", moderatedSite.getId()) - .assertThat().entriesListCountIs(1); - - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify regular user is not able to request membership of a private site.") - public void userIsNotAbleToRequestMembershipOfPrivateSite() throws Exception - { - regularUser = dataUser.createRandomTestUser(); - restClient.authenticateUser(regularUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(privateSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, regularUser.getUsername(), privateSite.getId())); - siteMembershipRequests = restClient.withCoreAPI().usingAuthUser().getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.OK); - siteMembershipRequests.assertThat().entriesListIsEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify regular user is not able to create new site membership request for other user") - public void regularUserIsNotAbleToCreateSiteMembershipRequestForOtherUser() throws Exception - { - regularUser = dataUser.createRandomTestUser(); - restClient.authenticateUser(regularUser).withCoreAPI().usingUser(newMember) - .addSiteMembershipRequest(publicSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); - - restClient.withCoreAPI().usingUser(newMember).addSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); - - restClient.withCoreAPI().usingUser(newMember).addSiteMembershipRequest(privateSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify create public site membership request returns status code 400 when the request is made twice") - public void userRequestsTwiceMembershipOfPublicSite() throws Exception - { - regularUser = dataUser.createRandomTestUser(); - siteMembershipRequest = restClient.authenticateUser(regularUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(publicSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - siteMembershipRequest.assertThat().field("id").is(publicSite.getId()) - .assertThat().field("site").isNotEmpty(); - restClient.withCoreAPI().usingAuthUser().addSiteMembershipRequest(publicSite); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - restClient.assertLastError().containsSummary(String.format(RestErrorModel.ALREADY_Site_MEMBER, regularUser.getUsername(), publicSite.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify create moderated site membership request returns status code 400 when the request is made twice") - public void userRequestsTwiceMembershipOfModeratedSite() throws Exception - { - regularUser = dataUser.createRandomTestUser(); - siteMembershipRequest = restClient.authenticateUser(regularUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - siteMembershipRequest.assertThat().field("id").is(moderatedSite.getId()) - .assertThat().field("site").isNotEmpty(); - restClient.withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - restClient.assertLastError().containsSummary(String.format(RestErrorModel.ALREADY_INVITED, regularUser.getUsername(), moderatedSite.getId())); - - siteMembershipRequests = restClient.withCoreAPI().usingAuthUser().getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.OK); - siteMembershipRequests.assertThat().entriesListContains("id", moderatedSite.getId()) - .assertThat().entriesListCountIs(1); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify create private site membership request returns status code 404 when request is made with the user who created the site") - public void siteCreatorRequestsMembershipOfHisPrivateSite() throws Exception - { - restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(privateSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, adminUser.getUsername(), privateSite.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify create moderated site membership request returns status code 400 when request is made with the user who created the site") - public void siteCreatorRequestsMembershipOfHisModeratedSite() throws Exception - { - restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.ALREADY_Site_MEMBER, adminUser.getUsername(), moderatedSite.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify admin is able to create new moderated site membership request for himself. Check that the request is added to the site membership request list.") - public void adminIsAbleToRequestMembershipOfModeratedSite() throws Exception - { - regularUser = dataUser.createRandomTestUser(); - SiteModel anotherModeratedSite = dataSite.usingUser(regularUser).createModeratedRandomSite(); - siteMembershipRequest = restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(anotherModeratedSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - siteMembershipRequest.assertThat().field("id").is(anotherModeratedSite.getId()) - .assertThat().field("site").isNotEmpty(); - siteMembershipRequests = restClient.withCoreAPI().usingAuthUser().getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.OK); - siteMembershipRequests.assertThat().entriesListContains("id", anotherModeratedSite.getId()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify site membership request is automatically rejected when a site is switched from moderated to private") - public void siteMembershipRequestIsRejectedWhenSiteIsSwitchedFromModeratedToPrivate() throws Exception - { - regularUser = dataUser.createRandomTestUser(); - SiteModel moderatedThenPrivateSite = dataSite.usingUser(adminUser).createModeratedRandomSite(); - siteMembershipRequest = restClient.authenticateUser(regularUser).withCoreAPI().usingMe().addSiteMembershipRequest(moderatedThenPrivateSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - siteMembershipRequest.assertThat().field("id").is(moderatedThenPrivateSite.getId()) - .assertThat().field("site").isNotEmpty(); - - dataSite.usingUser(adminUser).updateSiteVisibility(moderatedThenPrivateSite, SiteService.Visibility.PRIVATE); - - siteMembershipRequests = restClient.withCoreAPI().usingAuthUser().getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.OK); - siteMembershipRequests.assertThat().entriesListIsEmpty(); - } -} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/DeleteSiteMembershipRequestTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/DeleteSiteMembershipRequestTests.java deleted file mode 100644 index dd495422d..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/DeleteSiteMembershipRequestTests.java +++ /dev/null @@ -1,317 +0,0 @@ -package org.alfresco.service.search.rest.sites.membershipRequests; - -import org.alfresco.dataprep.SiteService.Visibility; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestSiteMembershipRequestModelsCollection; -import org.alfresco.rest.model.RestTaskModel; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * @author iulia.cojocea - */ - -public class DeleteSiteMembershipRequestTests extends RestTest -{ - UserModel siteCreator, adminUserModel, secondSiteCreator, siteMember; - SiteModel moderatedSite, secondModeratedSite, publicSite; - private ListUserWithRoles usersWithRoles; - RestSiteMembershipRequestModelsCollection siteMembershipRequests; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - siteCreator = dataUser.createRandomTestUser(); - secondSiteCreator = dataUser.createRandomTestUser(); - String siteId = RandomData.getRandomName("site"); - moderatedSite = dataSite.usingUser(siteCreator).createSite(new SiteModel(Visibility.MODERATED, siteId, siteId, siteId, siteId)); - usersWithRoles = dataUser.addUsersWithRolesToSite(moderatedSite, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - - dataUser.addUserToSite(adminUserModel, moderatedSite, UserRole.SiteManager); - secondModeratedSite = dataSite.usingUser(secondSiteCreator).createModeratedRandomSite(); - publicSite = dataSite.usingUser(siteCreator).createPublicRandomSite(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify one user is able to delete his one site memebership request") - public void userCanDeleteHisOwnSiteMembershipRequest() throws Exception - { - restClient.authenticateUser(secondSiteCreator).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.withCoreAPI().usingUser(secondSiteCreator).deleteSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site manager is able to delete site membership request") - public void managerCanDeleteSiteMembershipRequest() throws Exception - { - siteMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(siteMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingUser(siteMember) - .deleteSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingUser(siteMember).getSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, siteMember.getUsername(), moderatedSite.getTitle())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin user is able to delete site memebership request") - public void adminUserCanDeleteSiteMembershipRequest() throws Exception - { - siteMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(siteMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(siteMember).deleteSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @Bug(id = "REPO-1946") - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify collaborator user is not able to delete site memebership request") - public void collaboratorCannotDeleteSiteMembershipRequest() throws Exception - { - siteMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(siteMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingUser(siteMember) - .deleteSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @Bug(id = "REPO-1946") - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify contributor user is not able to delete site memebership request") - public void contributorCannotDeleteSiteMembershipRequest() throws Exception - { - siteMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(siteMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingUser(siteMember) - .deleteSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @Bug(id = "REPO-1946") - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify consumer user is not able to delete site memebership request") - public void consumerCannotDeleteSiteMembershipRequest() throws Exception - { - siteMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(siteMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingUser(siteMember) - .deleteSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @Bug(id = "REPO-1946") - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify random user is not able to delete site memebership request") - public void randomUserCanNotDeleteSiteMembershipRequest() throws Exception - { - siteMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(siteMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - - restClient.authenticateUser(dataUser.createRandomTestUser()).withCoreAPI().usingUser(siteMember).deleteSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, 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") - public void unauthenticatedUserIsNotAuthorizedToDeleteSiteMmebershipRequest() throws Exception - { - restClient.authenticateUser(dataUser.createRandomTestUser()).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - UserModel inexistentUser = new UserModel("inexistent user", "inexistent password"); - restClient.authenticateUser(inexistentUser).withCoreAPI().usingAuthUser().deleteSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify user is able to remove his own site memebership request using '-me-' in place of personId and response is successful (204)") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void userCanDeleteHisOwnSiteMembershipRequestUsingMeAsPersonId() throws Exception - { - restClient.authenticateUser(secondSiteCreator).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - restClient.withCoreAPI().usingMe().deleteSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify user is not able to remove a site memebership request of an inexistent user and response is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void adminIsNotAbleToDeleteSiteMembershipRequestOfAnInexistentUser() throws Exception - { - UserModel inexistentUser = new UserModel("inexistenUser", "password"); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(inexistentUser).deleteSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, inexistentUser.getUsername())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify user is not able to remove a site memebership request to an inexistent site and response is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void adminIsNotAbleToDeleteSiteMembershipRequestToAnInexistentSite() throws Exception - { - SiteModel inexistentSite = new SiteModel("inexistentSite"); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).deleteSiteMembershipRequest(inexistentSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, adminUserModel.getUsername(), inexistentSite.getId())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify user is not able to remove a site memebership request to an empty site id and response is 405") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void adminIsNotAbleToDeleteSiteMembershipRequestWithEmptySiteId() throws Exception - { - SiteModel inexistentSite = new SiteModel(""); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).deleteSiteMembershipRequest(inexistentSite); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.DELETE_EMPTY_ARGUMENT); - } - - @Bug(id = "REPO-1946") - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify contributor user is not able to remove a site memebership request of admin to a moderated site and response is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void contributorIsNotAbleToDeleteSiteMembershipRequestOfAdminToAModeratedSite() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingUser(adminUserModel).deleteSiteMembershipRequest(secondModeratedSite); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify manager is able to remove a site memebership request of admin to a moderated site and response is 204") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void managerUserIsAbleToDeleteSiteMembershipRequestOfAdminToAModeratedSite() throws Exception - { - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteMembershipRequest(secondModeratedSite); - restClient.authenticateUser(secondSiteCreator).withCoreAPI().usingUser(adminUserModel).deleteSiteMembershipRequest(secondModeratedSite); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify manager is not able to remove a site memebership request if it was already approved and response is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void managerUserIsNotAbleToDeleteASiteMembershipRequestIfItWasAlreadyApproved() throws Exception - { - siteMember.setUserRole(UserRole.SiteCollaborator); - restClient.authenticateUser(siteMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(secondModeratedSite); - RestTaskModel taskModel = restClient.authenticateUser(siteMember).withWorkflowAPI().getTasks().getTaskModelByDescription(secondModeratedSite); - workflow.approveSiteMembershipRequest(secondSiteCreator.getUsername(), secondSiteCreator.getPassword(), taskModel.getId(), true, "Approve"); - - restClient.authenticateUser(secondSiteCreator).withCoreAPI().usingUser(siteMember).deleteSiteMembershipRequest(secondModeratedSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, siteMember.getUsername(), secondModeratedSite.getId())); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify manager is not able to remove an inexitent site memebership request and response is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void managerUserIsNotAbleToDeleteAnInexistentSiteMembershipRequest() throws Exception - { - restClient.authenticateUser(secondSiteCreator).withCoreAPI().usingUser(adminUserModel).deleteSiteMembershipRequest(secondModeratedSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, adminUserModel.getUsername(), secondModeratedSite.getId())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify collaborator user is not able to remove a site memebership request of admin to a public site and response is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void collaboratorIsNotAbleToDeleteSiteMembershipRequestOfAdminToAPublicSite() throws Exception - { - UserModel userCollaborator = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); - restClient.authenticateUser(siteMember).withCoreAPI().usingSite(publicSite).addPerson(userCollaborator); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingAuthUser().addSiteMembershipRequest(publicSite); - - restClient.authenticateUser(userCollaborator).withCoreAPI().usingUser(adminUserModel).deleteSiteMembershipRequest(publicSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, adminUserModel.getUsername(), publicSite.getId())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Delete a rejected site membership request.") - public void deleteARejectedSiteMembershipRequest() throws Exception - { - UserModel userWithRejectedRequests = dataUser.createRandomTestUser(); - restClient.authenticateUser(userWithRejectedRequests).withCoreAPI().usingAuthUser().addSiteMembershipRequest(secondModeratedSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestTaskModel taskModel = restClient.authenticateUser(userWithRejectedRequests).withWorkflowAPI().getTasks() - .getTaskModelByDescription(secondModeratedSite); - workflow.approveSiteMembershipRequest(secondSiteCreator.getUsername(), secondSiteCreator.getPassword(), taskModel.getId(), false, "Rejected"); - - siteMembershipRequests = restClient.authenticateUser(userWithRejectedRequests).withCoreAPI().usingMe().getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.OK); - siteMembershipRequests.assertThat().entriesListDoesNotContain("id", secondModeratedSite.getId()); - - restClient.authenticateUser(secondSiteCreator).withCoreAPI().usingUser(userWithRejectedRequests).deleteSiteMembershipRequest(secondModeratedSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, userWithRejectedRequests.getUsername(), secondModeratedSite.getId())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Bug(id="ACE-2413") - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify user is not able to remove a site memebership request- empty person id and response is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void adminIsNotAbleToDeleteSiteMembershipRequestEmptyPersonID() throws Exception - { - UserModel emptyPersonId = new UserModel("", "password"); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(emptyPersonId).deleteSiteMembershipRequest(moderatedSite); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .containsSummary(RestErrorModel.ENTITY_NOT_FOUND) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify manager removes/cancel twice same site memebership request and response is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void managerCancelsTwiceSiteMembershipRequestModeratedSite() throws Exception - { - siteMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(siteMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - - restClient.authenticateUser(siteCreator).withCoreAPI().usingUser(siteMember).deleteSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingUser(siteMember).deleteSiteMembershipRequest(moderatedSite); - - restClient.withCoreAPI().usingUser(siteMember).getSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, siteMember.getUsername(), moderatedSite.getTitle())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/GetSiteMembershipRequestTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/GetSiteMembershipRequestTests.java deleted file mode 100644 index ed63a790b..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/GetSiteMembershipRequestTests.java +++ /dev/null @@ -1,332 +0,0 @@ -package org.alfresco.service.search.rest.sites.membershipRequests; - -import org.alfresco.dataprep.SiteService; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestSiteMembershipRequestModel; -import org.alfresco.rest.model.RestTaskModel; -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.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class GetSiteMembershipRequestTests extends RestTest -{ - private SiteModel publicSite, moderatedSite; - private ListUserWithRoles usersWithRoles; - private UserModel adminUser, siteCreator, newMember; - private RestSiteMembershipRequestModel returnedModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - publicSite = dataSite.usingUser(adminUser).createPublicRandomSite(); - - siteCreator = dataUser.createRandomTestUser(); - moderatedSite = dataSite.usingUser(siteCreator).createModeratedRandomSite(); - - usersWithRoles = dataUser.addUsersWithRolesToSite(moderatedSite, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - - newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site manager is able to retrieve site membership request") - public void siteManagerIsAbleToRetrieveSiteMembershipRequest() throws Exception - { - returnedModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingUser(newMember).getSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedModel.assertThat().field("id").is(moderatedSite.getId()) - .and().field("message").is("Please accept me") - .and().field("site.title").is(moderatedSite.getTitle()) - .and().field("site.visibility").is(SiteService.Visibility.MODERATED.toString()) - .and().field("site.guid").isNotEmpty() - .and().field("site.description").is(moderatedSite.getDescription()) - .and().field("site.preset").is("site-dashboard"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site collaborator is able to retrieve site membership request") - public void siteCollaboratorIsNotAbleToRetrieveSiteMembershipRequest() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingUser(newMember).getSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site contributor is able to retrieve site membership request") - public void siteContributorIsNotAbleToRetrieveSiteMembershipRequest() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingUser(newMember).getSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site consumer is able to retrieve site membership request") - public void siteConsumerIsNotAbleToRetrieveSiteMembershipRequest() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingUser(newMember).getSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin user is able to retrieve site membership request") - public void adminIsAbleToRetrieveSiteMembershipRequest() throws Exception - { - returnedModel = restClient.authenticateUser(adminUser).withCoreAPI().usingUser(newMember).getSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedModel.assertThat().field("id").is(moderatedSite.getId()) - .and().field("message").is("Please accept me") - .and().field("site.title").is(moderatedSite.getTitle()) - .and().field("site.visibility").is(SiteService.Visibility.MODERATED.toString()) - .and().field("site.guid").isNotEmpty() - .and().field("site.description").is(moderatedSite.getDescription()) - .and().field("site.preset").is("site-dashboard"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, - description = "Verify user fails to get all site membership requests of a specific person with Rest API when the authentication fails (401)") - public void unauthorizedUserFailsToGetSiteMembershipRequests() throws Exception - { - UserModel manager = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(siteCreator).addUserToSite(manager, moderatedSite, UserRole.SiteManager); - manager.setPassword("newpassword"); - restClient.authenticateUser(manager).withCoreAPI().usingUser(newMember).getSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError().containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify a user gets all its own site membership requests using '-me-' with Rest API and response is successful (200)") - public void usingMeGetSiteMembershipRequestsWithSuccess() throws Exception - { - restClient.authenticateUser(newMember).withCoreAPI().usingMe().getSiteMembershipRequest(moderatedSite).assertThat().field("id").is(moderatedSite.getId()); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site manager can't get site membership requests for inexistent user and response is not found (404)") - public void siteManagerCantGetSiteMembershipRequestsInexistentUser() throws Exception - { - restClient.authenticateUser(newMember).withCoreAPI().usingUser(UserModel.getRandomUserModel()).getSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user can get site membership requests on site with no requests and response is successful (200)") - public void userWithNoRequestsCantGetSiteMembershipRequests() throws Exception - { - UserModel noRequestUser = dataUser.createRandomTestUser(); - restClient.authenticateUser(noRequestUser).withCoreAPI().usingMe().getSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, noRequestUser.getUsername(), moderatedSite.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site manager can't get site membership requests on public site and response is not found (404)") - public void siteManagerCantGetPublicSiteMembershipRequests() throws Exception - { - UserModel publicUser = dataUser.createRandomTestUser(); - restClient.authenticateUser(publicUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(publicSite); - restClient.authenticateUser(adminUser).withCoreAPI() - .usingUser(publicUser).getSiteMembershipRequest(publicSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, publicUser.getUsername(), publicSite.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site manager can't get site membership requests on private site and response is not found (404)") - public void siteManagerCantGetPrivateSiteMembershipRequests() throws Exception - { - UserModel privateUser = dataUser.createRandomTestUser(); - SiteModel privateSite = dataSite.usingUser(siteCreator).createPrivateRandomSite(); - restClient.authenticateUser(privateUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(privateSite); - restClient.authenticateUser(siteCreator).withCoreAPI().usingUser(privateUser).getSiteMembershipRequest(privateSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, privateUser.getUsername(), privateSite.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site manager can't get site membership requests for inexistent site and response is not found (404)") - public void siteManagerCantGetSiteMembershipRequestsForInexistentSite() throws Exception - { - SiteModel inexistentSite = SiteModel.getRandomSiteModel(); - restClient.authenticateUser(siteCreator).withCoreAPI().usingMe().getSiteMembershipRequest(inexistentSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, siteCreator.getUsername(), inexistentSite.getId())); - } - - @Bug(id = "ACE-2413") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify if person ID field is empty user can't get site membership requests on moderated site and response is not found (400)") - public void emptyPersonIdCantGetModeratedSiteMembershipRequests() throws Exception - { - UserModel emptyUser = new UserModel("", "password"); - restClient.authenticateUser(siteCreator).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - restClient.authenticateUser(siteCreator).withCoreAPI().usingUser(emptyUser).getSiteMembershipRequest(moderatedSite); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .containsSummary(String.format("The entity with id: personId is null. was not found")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Approve site membership request then verify get site membership requests - response is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void approveRequestThenGetSiteMembershipRequest() throws Exception - { - UserModel userWithApprovedRequests = dataUser.createRandomTestUser(); - restClient.authenticateUser(userWithApprovedRequests).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestTaskModel taskModel = restClient.authenticateUser(userWithApprovedRequests).withWorkflowAPI().getTasks().getTaskModelByDescription(moderatedSite); - workflow.approveSiteMembershipRequest(siteCreator.getUsername(), siteCreator.getPassword(), taskModel.getId(), true, "Approve"); - - returnedModel = restClient.authenticateUser(userWithApprovedRequests).withCoreAPI().usingMe().getSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, userWithApprovedRequests.getUsername(), moderatedSite.getId())) - .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Reject site membership request then verify get site membership requests - response is 404") - public void rejectRequestThenGetSiteMembershipRequest() throws Exception - { - UserModel userWithRejectedRequests = dataUser.createRandomTestUser(); - restClient.authenticateUser(userWithRejectedRequests).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestTaskModel taskModel = restClient.authenticateUser(userWithRejectedRequests).withWorkflowAPI().getTasks().getTaskModelByDescription(moderatedSite); - workflow.approveSiteMembershipRequest(siteCreator.getUsername(), siteCreator.getPassword(), taskModel.getId(), false, "Rejected"); - - returnedModel = restClient.authenticateUser(userWithRejectedRequests).withCoreAPI().usingMe().getSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, userWithRejectedRequests.getUsername(), moderatedSite.getId())) - .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @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 site favorite response with Rest API") - public void checkResponseSchemaForGetSiteMembershipRequest() throws Exception - { - dataUser.usingUser(siteCreator).addUserToSite(newMember, moderatedSite, UserRole.SiteContributor); - returnedModel = restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().getSiteMembershipRequest(moderatedSite); - - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedModel.assertThat().field("id").is(moderatedSite.getId()) - .and().field("message").is("Please accept me") - .and().field("site.title").is(moderatedSite.getTitle()) - .and().field("site.visibility").is(SiteService.Visibility.MODERATED.toString()) - .and().field("site.guid").isNotEmpty() - .and().field("site.description").is(moderatedSite.getDescription()) - .and().field("site.preset").is("site-dashboard") - .and().field("site.role").is("SiteContributor"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify that getFavoriteSites request applies valid properties param") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void getSiteMembershipRequestWithValidPropertiesParam() throws Exception - { - RestSiteMembershipRequestModel returnedModel = restClient.authenticateUser(newMember).withParams("properties=message").withCoreAPI().usingAuthUser() - .getSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedModel.assertThat().fieldsCount().is(1).assertThat().field("message").isNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify that getFavoriteSites request returns status 200 when using valid parameters") - public void getSiteMembershipRequestUsingParameters() throws Exception - { - RestSiteMembershipRequestModel returnedModel = restClient.withParams("message=Please accept me") - .authenticateUser(newMember).withCoreAPI().usingMe() - .getSiteMembershipRequest(moderatedSite); - - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedModel.assertThat().field("id").is(moderatedSite.getId()).and().field("site.title").is(moderatedSite.getTitle()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify user doesn't have permission to get site membership request of admin without membership request with Rest API and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void userIsNotAbleToGetSiteMembershipRequestOfAdminWithoutRequest() throws Exception - { - returnedModel = restClient.authenticateUser(newMember).withCoreAPI().usingUser(adminUser).getSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, adminUser.getUsername(), moderatedSite.getId())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER).stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify user doesn't have permission to get site membership request of admin with requests with Rest API and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void userIsNotAbleToGetSiteMembershipRequestOfAdminWithRequest() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - - returnedModel = restClient.authenticateUser(newMember).withCoreAPI().usingUser(adminUser).getSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, adminUser.getUsername(), moderatedSite.getId())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify admin user doesn't have permission to get site membership request of another user with Rest API and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void userIsNotAbleToGetSiteMembershipRequestOfAnotherUser() throws Exception - { - UserModel userCollaborator = dataUser.createRandomTestUser(); - UserModel userConsumer = dataUser.createRandomTestUser(); - restClient.authenticateUser(userConsumer).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - dataUser.usingUser(siteCreator).addUserToSite(userConsumer, moderatedSite, UserRole.SiteConsumer); - restClient.authenticateUser(userCollaborator).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - dataUser.usingUser(siteCreator).addUserToSite(userCollaborator, moderatedSite, UserRole.SiteCollaborator); - - returnedModel = restClient.authenticateUser(userCollaborator).withCoreAPI().usingUser(userConsumer).getSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, userConsumer.getUsername(), moderatedSite.getId())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - -} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/GetSiteMembershipRequestsTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/GetSiteMembershipRequestsTests.java deleted file mode 100644 index dbb5ef43f..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/GetSiteMembershipRequestsTests.java +++ /dev/null @@ -1,421 +0,0 @@ -package org.alfresco.service.search.rest.sites.membershipRequests; - -import static org.alfresco.utility.report.log.Step.STEP; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.*; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Tests for - * GET /people/{personId}/site-membership-requests - * GET /site-membership-requests - * POST /sites/{siteId}/site-membership-requests/{inviteeId}/approve - * POST /sites/{siteId}/site-membership-requests/{inviteeId}/reject - * - * @author Cristina Axinte - */ - -public class GetSiteMembershipRequestsTests extends RestTest -{ - UserModel siteManager, newMember, adminUser, regularUser, testUser, testUser1; - DataUser.ListUserWithRoles usersWithRoles; - SiteModel moderatedSite1, moderatedSite2; - RestSiteMembershipRequestModelsCollection siteMembershipRequests; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - siteManager = dataUser.createRandomTestUser(); - newMember = dataUser.createRandomTestUser(); - regularUser = dataUser.createRandomTestUser(); - - testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteConsumer); - testUser1 = dataUser.createRandomTestUser("testUser1"); - testUser1.setUserRole(UserRole.SiteConsumer); - - moderatedSite1 = dataSite.usingUser(siteManager).createModeratedRandomSite(); - moderatedSite2 = dataSite.usingUser(siteManager).createModeratedRandomSite(); - - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite1); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite1); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - usersWithRoles = dataUser.addUsersWithRolesToSite(moderatedSite1, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @Bug(id = "MNT-16557") - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user gets all site membership requests of a specific person with Rest API and response is successful (200)") - public void managerUserGetsSiteMembershipRequestsWithSuccess() throws Exception - { - siteMembershipRequests = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI() - .usingUser(newMember).getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.OK); - siteMembershipRequests.assertThat().entriesListIsNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @Bug(id = "MNT-16557") - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify collaborator user fails to get all site membership requests of another user with Rest API (403)") - public void collaboratorUserFailsToGetSiteMembershipRequestsOfAnotherUser() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI() - .usingUser(newMember).getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @Bug(id = "MNT-16557") - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify contributor user fails to get all site membership requests of another user with Rest API (403)") - public void contributorUserFailsToGetSiteMembershipRequestsOfAnotherUser() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI() - .usingUser(newMember).getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @Bug(id = "MNT-16557") - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify consumer user fails to get all site membership requests of another user with Rest API (403)") - public void consumerUserFailsToGetSiteMembershipRequestsOfAnotherUser() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingUser(newMember).getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @Bug(id = "MNT-16557") - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin user gets all site membership requests of a specific person with Rest API and response is successful (200)") - public void adminGetsSiteMembershipRequestsOfanotherUserWithSuccess() throws Exception - { - siteMembershipRequests = restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI() - .usingUser(newMember).getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.OK); - siteMembershipRequests.assertThat().entriesListIsNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) -// @Bug(id = "MNT-16904", description = "It fails only on environment with tenants") - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user fails to get all site membership requests of a specific person with Rest API when the authentication fails (401)") - public void unauthorizedUserFailsToGetSiteMembershipRequests() throws Exception - { - restClient.authenticateUser(new UserModel("random user", "random password")).withCoreAPI() - .usingAuthUser().getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify a user gets all its own site membership requests with Rest API and response is successful (200)") - public void oneUserGetsItsOwnSiteMembershipRequestsWithSuccess() throws Exception - { - siteMembershipRequests = restClient.authenticateUser(newMember).withCoreAPI().usingUser(newMember).getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.OK); - siteMembershipRequests.assertThat().entriesListContains("id", moderatedSite1.getId()) - .assertThat().entriesListContains("message", "Please accept me") - .assertThat().entriesListCountIs(2); - RestSiteModel firstSite = siteMembershipRequests.getEntries().get(0).onModel().getSite(); - if (firstSite.getId().equals(moderatedSite1.getId())) - { - firstSite.assertThat().field("visibility").is(moderatedSite1.getVisibility()) - .assertThat().field("guid").is(moderatedSite1.getGuid()) - .assertThat().field("description").is(moderatedSite1.getDescription()) - .assertThat().field("id").is(moderatedSite1.getId()) - .assertThat().field("title").is(moderatedSite1.getTitle()); - } - else - { - firstSite.assertThat().field("visibility").is(moderatedSite2.getVisibility()) - .assertThat().field("guid").is(moderatedSite2.getGuid()) - .assertThat().field("description").is(moderatedSite2.getDescription()) - .assertThat().field("id").is(moderatedSite2.getId()) - .assertThat().field("title").is(moderatedSite2.getTitle()); - } - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, - description = "Verify that for invalid maxItems parameter status code returned is 400.") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void checkInvalidMaxItemsStatusCode() throws Exception - { - restClient.authenticateUser(adminUser).withParams("maxItems=AB") - .withCoreAPI().usingUser(newMember).getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "AB")); - - restClient.authenticateUser(adminUser).withParams("maxItems=0") - .withCoreAPI().usingUser(newMember).getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, - description = "Verify that for invalid skipCount parameter status code returned is 400.") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void checkInvalidSkipCountStatusCode() throws Exception - { - restClient.authenticateUser(adminUser).withParams("skipCount=AB") - .withCoreAPI().usingUser(newMember).getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "AB")); - - restClient.authenticateUser(adminUser).withParams("skipCount=-1") - .withCoreAPI().usingUser(newMember).getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, - description = "Verify that if personId does not exist status code returned is 404.") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void ifPersonIdDoesNotExist() throws Exception - { - UserModel nonexistentUser = dataUser.createRandomTestUser(); - nonexistentUser.setUsername("nonexistent"); - - restClient.authenticateUser(adminUser).withCoreAPI().usingUser(nonexistentUser).getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "nonexistent")) - .statusCodeIs(HttpStatus.NOT_FOUND) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, - description = "Specify -me- string in place of for request.") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void replacePersonIdWithMeRequest() throws Exception - { - UserModel meUser = dataUser.createRandomTestUser(); - restClient.authenticateUser(meUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite1); - siteMembershipRequests = restClient.authenticateUser(meUser).withCoreAPI().usingMe().getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.OK); - siteMembershipRequests.assertThat().entriesListContains("id", moderatedSite1.getId()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, - description = "Verify that if empty personId is used status code returned is 404.") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void useEmptyPersonId() throws Exception - { - UserModel emptyNameMember = dataUser.createRandomTestUser(); - emptyNameMember.setUsername(" "); - - restClient.authenticateUser(adminUser).withCoreAPI().usingUser(emptyNameMember).getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, emptyNameMember.getUsername())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, - description = "Get site membership requests to a public site.") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void getRequestsToPublicSite() throws Exception - { - SiteModel publicSite = dataSite.usingAdmin().createPublicRandomSite(); - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(publicSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - siteMembershipRequests = restClient.withCoreAPI().usingAuthUser().getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.OK); - siteMembershipRequests.assertThat().entriesListDoesNotContain("id", publicSite.getId()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, - description = "Approve request then get requests.") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void approveRequestThenGetRequests() throws Exception - { - UserModel siteManager = dataUser.createRandomTestUser(); - - SiteModel moderatedSite = dataSite.usingUser(siteManager).createModeratedRandomSite(); - restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestTaskModel taskModel = restClient.authenticateUser(newMember).withWorkflowAPI().getTasks().getTaskModelByDescription(moderatedSite); - workflow.approveSiteMembershipRequest(siteManager.getUsername(), siteManager.getPassword(), taskModel.getId(), true, "Approve"); - - siteMembershipRequests = restClient.authenticateUser(newMember).withCoreAPI().usingMe().getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.OK); - siteMembershipRequests.assertThat().entriesListDoesNotContain("id", moderatedSite.getId()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, - description = "Verify admin user gets all its own site membership requests with Rest API and response is successful (200)") - public void adminGetsItsOwnSiteMembershipRequestsWithSuccess() throws Exception - { - siteMembershipRequests = restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.OK); - siteMembershipRequests.assertThat().entriesListContains("id", moderatedSite1.getId()) - .assertThat().entriesListContains("id", moderatedSite2.getId()); - } - - @Bug(id = "MNT-16557") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, - description = "Verify regular user fails to get all site membership requests of another user with Rest API (403)") - public void regularUserFailsToGetSiteMembershipRequestsOfAnotherUser() throws Exception - { - restClient.authenticateUser(regularUser).withCoreAPI() - .usingUser(newMember).getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Bug(id = "MNT-16557") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, - description = "Verify regular user fails to get all site membership requests of admin with Rest API (403)") - public void regularUserFailsToGetSiteMembershipRequestsOfAdmin() throws Exception - { - restClient.authenticateUser(regularUser).withCoreAPI() - .usingUser(adminUser).getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, - description = "Verify regular user is able to get his site membership requests with, but skip the first one") - public void getSiteMembershipRequestsButSkipTheFirstOne() throws Exception - { - siteMembershipRequests = restClient.authenticateUser(newMember).withParams("orderBy=id ASC").withCoreAPI() - .usingMe().getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.OK); - siteMembershipRequests.assertThat().entriesListContains("id", moderatedSite1.getId()) - .assertThat().entriesListContains("id", moderatedSite2.getId()); - - RestSiteMembershipRequestModel firstSiteMembershipRequest = siteMembershipRequests.getEntries().get(0).onModel(); - RestSiteMembershipRequestModel secondSiteMembershipRequest = siteMembershipRequests.getEntries().get(1).onModel(); - - siteMembershipRequests = restClient.authenticateUser(newMember).withParams("orderBy=id ASC&skipCount=1").withCoreAPI() - .usingMe().getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.OK); - siteMembershipRequests.assertThat().entriesListDoesNotContain("id", firstSiteMembershipRequest.getId()) - .assertThat().entriesListContains("id", secondSiteMembershipRequest.getId()) - .assertThat().entriesListContains("id", secondSiteMembershipRequest.getSite().getId()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, - description = "Verify regular user is able to get his site membership requests with higher skipCount than number of requests") - public void getSiteMembershipRequestsWithHighSkipCount() throws Exception - { - siteMembershipRequests = restClient.authenticateUser(newMember).withParams("skipCount=3").withCoreAPI() - .usingMe().getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.OK); - siteMembershipRequests.assertThat().entriesListIsEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, - description = "Verify get site membership requests returns an empty list where there are no requests") - public void getSiteMembershipRequestsWhereThereAreNoRequests() throws Exception - { - siteMembershipRequests = restClient.authenticateUser(regularUser).withCoreAPI().usingMe().getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.OK); - siteMembershipRequests.assertThat().entriesListIsEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, - description = "Reject request then get site membership requests.") - public void rejectRequestThenGetSiteMembershipRequests() throws Exception - { - UserModel userWithRejectedRequests = dataUser.createRandomTestUser(); - - restClient.authenticateUser(userWithRejectedRequests).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite1); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestTaskModel taskModel = restClient.authenticateUser(userWithRejectedRequests).withWorkflowAPI().getTasks().getTaskModelByDescription(moderatedSite1); - workflow.approveSiteMembershipRequest(siteManager.getUsername(), siteManager.getPassword(), taskModel.getId(), false, "Rejected"); - - siteMembershipRequests = restClient.authenticateUser(userWithRejectedRequests).withCoreAPI().usingMe().getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.OK); - siteMembershipRequests.assertThat().entriesListDoesNotContain("id", moderatedSite1.getId()) - .assertThat().entriesListContains("id", moderatedSite2.getId()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, - executionType = ExecutionType.REGRESSION, - description = "Check get site membership requests when properties parameter is used") - public void getSiteMembershipRequestsWithProperties() throws Exception - { - siteMembershipRequests = restClient.authenticateUser(newMember).withParams("properties=id") - .withCoreAPI().usingAuthUser().getSiteMembershipRequests(); - restClient.assertStatusCodeIs(HttpStatus.OK); - siteMembershipRequests.assertThat().entriesListContains("id", moderatedSite1.getId()) - .assertThat().entriesListContains("id", moderatedSite2.getId()); - RestSiteMembershipRequestModel siteMembershipRequest = siteMembershipRequests.getOneRandomEntry().onModel(); - siteMembershipRequest.assertThat().fieldsCount().is(1); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, - TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Sanity test for endpoints: GET /site-membership-requests, POST /sites/{siteId}/site-membership-requests/{inviteeId}/approve, POST /sites/{siteId}/site-membership-requests/{inviteeId}/reject") - public void approveRejectSiteMembership() throws Exception - { - STEP("1. Make membership requests for 2 users on moderatedSite."); - restClient.authenticateUser(testUser).withCoreAPI().usingMe().addSiteMembershipRequest(moderatedSite1); - restClient.authenticateUser(testUser1).withCoreAPI().usingMe().addSiteMembershipRequest(moderatedSite1); - - STEP("2. Get site memberships and filter using username and siteId "); - RestSitePersonMembershipRequestModelsCollection membership = restClient.authenticateUser(siteManager) - .withParams("where=(personId='" + testUser.getUsername() + "' AND siteId='" + moderatedSite1.getId() + "')").withCoreAPI() - .usingSite(moderatedSite1).getSiteMemberships(); - - restClient.assertStatusCodeIs(HttpStatus.OK); - membership.getEntryByIndex(0).getSite().assertThat().field("id").is(moderatedSite1.getId()); - membership.getEntryByIndex(0).getPersonModel().assertThat().field("id").is(testUser.getUsername()); - - STEP("3. Approve site membership for one of the users. Check that the user is now a member of the site"); - restClient.authenticateUser(siteManager).withCoreAPI().usingSite(moderatedSite1).approveSiteMembership(testUser); - restClient.assertStatusCodeIs(HttpStatus.OK); - restClient.withCoreAPI().usingSite(moderatedSite1).getSiteMember(testUser).assertThat().field("id").is(testUser.getUsername()).and().field("role") - .is(testUser.getUserRole()); - - STEP("4. Reject site membership for the second user. Check that the user is not a member of the site"); - restClient.authenticateUser(siteManager).withCoreAPI().usingSite(moderatedSite1).rejectSiteMembership(testUser1); - restClient.assertStatusCodeIs(HttpStatus.OK); - RestSiteMemberModelsCollection memberList = restClient.withCoreAPI().usingSite(moderatedSite1).getSiteMembers(); - memberList.assertThat().entriesListDoesNotContain("id", testUser1.getUsername()); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/UpdateSiteMembershipRequestTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/UpdateSiteMembershipRequestTests.java deleted file mode 100644 index 8cb9af558..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/sites/membershipRequests/UpdateSiteMembershipRequestTests.java +++ /dev/null @@ -1,610 +0,0 @@ -package org.alfresco.service.search.rest.sites.membershipRequests; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.core.RestRequest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestSiteMembershipRequestModel; -import org.alfresco.rest.model.RestTaskModel; -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.HttpMethod; -import org.springframework.http.HttpStatus; -import org.testng.Assert; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class UpdateSiteMembershipRequestTests extends RestTest -{ - private SiteModel moderatedSite; - private ListUserWithRoles usersWithRoles; - private UserModel adminUser, managerUser; - private String updatedMessage, moderatedSiteId; - private RestSiteMembershipRequestModel requestUpdateModel, requestGetModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws DataPreparationException - { - adminUser = dataUser.getAdminUser(); - managerUser = dataUser.createRandomTestUser(); - moderatedSite = dataSite.usingUser(managerUser).createModeratedRandomSite(); - - usersWithRoles = dataUser.addUsersWithRolesToSite(moderatedSite, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - updatedMessage = "Please review my request"; - moderatedSiteId = moderatedSite.getId(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify user is able to update its own site membership request") - public void userIsAbleToUpdateItsOwnSiteMembershipRequest() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - requestUpdateModel = restClient.withCoreAPI().usingUser(newMember).updateSiteMembershipRequest(moderatedSite, updatedMessage); - restClient.assertStatusCodeIs(HttpStatus.OK); - - requestUpdateModel.assertThat().field("id").is(moderatedSite.getId()) - .assertThat().field("message").is(updatedMessage) - .assertThat().field("site").isNotEmpty() - .assertThat().field("modifiedAt").isNotEmpty() - .assertThat().field("createdAt").isNotEmpty(); - requestUpdateModel.getSite().assertThat().field("visibility").is(moderatedSite.getVisibility()) - .assertThat().field("guid").is(moderatedSite.getGuid()) - .assertThat().field("description").is(moderatedSite.getDescription()) - .assertThat().field("id").is(moderatedSite.getId()) - .assertThat().field("preset").is("site-dashboard") - .assertThat().field("title").is(moderatedSite.getTitle()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site manager is not able to update membership request of another user") -// @Bug(id = "MNT-16919", description = "Not a bug, The presence of the personId in the URL does not mean it should be possible to act on any other users behalf.") - public void siteManagerIsNotAbleToUpdateSiteMembershipRequestOfAnotherUser() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingUser(newMember) - .updateSiteMembershipRequest(moderatedSite, updatedMessage); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site collaborator is not able to update membership request of another user") - // @Bug(id = "MNT-16919", description = "Not a bug, The presence of the personId in the URL does not mean it should be possible to act on any other users behalf.") - public void siteCollaboratorIsNotAbleToUpdateSiteMembershipRequestOfAnotherUser() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingUser(newMember) - .updateSiteMembershipRequest(moderatedSite, updatedMessage); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site contributor is not able to update membership request of another user") - // @Bug(id = "MNT-16919", description = "Not a bug, The presence of the personId in the URL does not mean it should be possible to act on any other users behalf.") - public void siteContributorIsNotAbleToUpdateSiteMembershipRequestOfAnotherUser() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingUser(newMember) - .updateSiteMembershipRequest(moderatedSite, updatedMessage); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site consumer is not able to update membership request of another user") - // @Bug(id = "MNT-16919", description = "Not a bug, The presence of the personId in the URL does not mean it should be possible to act on any other users behalf.") - public void siteConsumerIsNotAbleToUpdateSiteMembershipRequestOfAnotherUser() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingUser(newMember) - .updateSiteMembershipRequest(moderatedSite, updatedMessage); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify one user is not able to update membership request of another user") - // @Bug(id = "MNT-16919", description = "Not a bug, The presence of the personId in the URL does not mean it should be possible to act on any other users behalf.") - public void regularUserIsNotAbleToUpdateSiteMembershipRequestOfAnotherUser() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - UserModel otherMember = dataUser.createRandomTestUser(); - - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - - restClient.authenticateUser(otherMember).withCoreAPI().usingUser(newMember).updateSiteMembershipRequest(moderatedSite, updatedMessage); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify admin is not able to update membership request of another user") - // @Bug(id = "MNT-16919", description = "Not a bug, The presence of the personId in the URL does not mean it should be possible to act on any other users behalf.") - public void adminIsNotAbleToUpdateSiteMembershipRequestOfAnotherUser() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - - restClient.authenticateUser(adminUser).withCoreAPI().usingUser(newMember).updateSiteMembershipRequest(moderatedSite, updatedMessage); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify unauthorized user is not able to update user site membership request") - public void unauthorizedUserIsNotAbleToUpdateSiteMembershipRequest() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - newMember.setPassword("fakePass"); - restClient.withCoreAPI().usingUser(newMember).updateSiteMembershipRequest(moderatedSite, updatedMessage); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError().containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is able to update its own site membership request using -me-") - public void usingMeUpdateSiteMembershipRequest() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - requestUpdateModel = restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(moderatedSite, updatedMessage); - restClient.assertStatusCodeIs(HttpStatus.OK); - requestUpdateModel.assertMembershipRequestMessageIs(updatedMessage).and().field("id").is(moderatedSite.getId()).and().field("modifiedAt").isNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify inexistent user is not able to update its own site membership request") - public void inexistentUserCannotUpdateSiteMembershipRequest() throws Exception - { - UserModel inexistentUser = UserModel.getRandomUserModel(); - restClient.authenticateUser(managerUser).withCoreAPI().usingUser(inexistentUser).updateSiteMembershipRequest(moderatedSite, updatedMessage); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, inexistentUser.getUsername())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to update its own site membership request for inexistent site") - public void userCannotUpdateSiteMembershipRequestForInexistentSite() throws Exception - { - SiteModel randomSite = SiteModel.getRandomSiteModel(); - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingMe().updateSiteMembershipRequest(randomSite, updatedMessage); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, newMember.getUsername(), randomSite.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is able not to update its own site membership request for public site") - public void userCannotUpdateSiteMembershipRequestForPublicSite() throws Exception - { - SiteModel publicSite = dataSite.usingUser(managerUser).createPublicRandomSite(); - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(publicSite); - restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(publicSite, updatedMessage); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, newMember.getUsername(), publicSite.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to update its own site membership request for private site") - public void userCannotUpdateSiteMembershipRequestForPrivateSite() throws Exception - { - SiteModel privateSite = dataSite.usingUser(managerUser).createPrivateRandomSite(); - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(privateSite); - restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(privateSite, updatedMessage); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, newMember.getUsername(), privateSite.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is able to update its own site membership request with initial message") - public void userCanUpdateSiteMembershipRequestWithInitialMessage() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(updatedMessage, moderatedSite, "Accept me"); - requestUpdateModel = restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(moderatedSite, updatedMessage); - restClient.assertStatusCodeIs(HttpStatus.OK); - requestUpdateModel.assertMembershipRequestMessageIs(updatedMessage).and().field("id").is(moderatedSite.getId()).and().field("modifiedAt").isNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is able to update its own site membership request with different message") - public void userCanUpdateSiteMembershipRequestWithDifferentMessage() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest("", moderatedSite, "Accept me"); - requestUpdateModel = restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(moderatedSite, updatedMessage); - restClient.assertStatusCodeIs(HttpStatus.OK); - requestUpdateModel.assertMembershipRequestMessageIs(updatedMessage).and().field("id").is(moderatedSite.getId()).and().field("modifiedAt").isNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify modifiedAt field for update siteMembership request call") - public void verifyModifiedAtForUpdateSiteMembershipRequest() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite); - String firstModifiedAt = restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(moderatedSite, "first message").getModifiedAt(); - String secondModifiedAt = restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(moderatedSite, "second message").getModifiedAt(); - Assert.assertNotEquals(firstModifiedAt, secondModifiedAt); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify user is not able to update membership request of admin") - public void userIsNotAbleToUpdateSiteMembershipRequestOfAdmin() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser() - .addSiteMembershipRequest(moderatedSite); - - restClient.authenticateUser(newMember).withCoreAPI().usingUser(adminUser) - .updateSiteMembershipRequest(moderatedSite, updatedMessage); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format("The entity with id: " + RestErrorModel.ENTITY_NOT_FOUND, adminUser.getUsername())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify site manager is able to update site membership request") - public void updateSiteMembershipRequestAfterUserIsAddedAsMember() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser() - .addSiteMembershipRequest(moderatedSite); - dataUser.usingUser(managerUser).addUserToSite(newMember, moderatedSite, UserRole.SiteManager); - requestUpdateModel = restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser() - .updateSiteMembershipRequest(moderatedSite, updatedMessage); - - restClient.assertStatusCodeIs(HttpStatus.OK); - requestUpdateModel.assertThat().field("id").is(moderatedSite.getId()) - .assertThat().field("message").is(updatedMessage) - .assertThat().field("modifiedAt").isNotEmpty() - .assertThat().field("createdAt").isNotEmpty(); - requestUpdateModel.getSite().assertThat().field("role").is(UserRole.SiteManager) - .assertThat().field("visibility").is(moderatedSite.getVisibility()) - .assertThat().field("guid").is(moderatedSite.getGuid()) - .assertThat().field("description").is(moderatedSite.getDescription()) - .assertThat().field("id").is(moderatedSite.getId()) - .assertThat().field("preset").is("site-dashboard") - .assertThat().field("title").is(moderatedSite.getTitle()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify admin is able to update site membership request") - public void adminIsAbleToUpdateHisSiteMembershipRequest() throws Exception - { - UserModel regularUser = dataUser.createRandomTestUser(); - SiteModel anotherModeratedSite = dataSite.usingUser(regularUser).createModeratedRandomSite(); - requestUpdateModel = restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser() - .addSiteMembershipRequest(anotherModeratedSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - requestUpdateModel = restClient.withCoreAPI().usingAuthUser() - .updateSiteMembershipRequest(anotherModeratedSite, updatedMessage); - - restClient.assertStatusCodeIs(HttpStatus.OK); - requestUpdateModel.assertThat().field("id").is(anotherModeratedSite.getId()) - .assertThat().field("message").is("Please review my request") - .assertThat().field("modifiedAt").isNotEmpty() - .assertThat().field("createdAt").isNotEmpty(); - requestUpdateModel.getSite().assertThat().field("visibility").is(anotherModeratedSite.getVisibility()) - .assertThat().field("guid").is(anotherModeratedSite.getGuid()) - .assertThat().field("description").is(anotherModeratedSite.getDescription()) - .assertThat().field("id").is(anotherModeratedSite.getId()) - .assertThat().field("preset").is("site-dashboard") - .assertThat().field("title").is(anotherModeratedSite.getTitle()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify user update site membership request with no message then adds a new message") - public void userUpdateSiteMembershipRequestWithNoMessageThenAddsNewMessage() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - requestUpdateModel = restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser() - .addSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - requestUpdateModel.assertThat().field("id").is(moderatedSite.getId()) - .assertThat().field("message").is("Please accept me"); - - requestUpdateModel = restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(moderatedSite, ""); - restClient.assertStatusCodeIs(HttpStatus.OK); - requestUpdateModel.assertThat().field("id").is(moderatedSite.getId()) - .and().field("modifiedAt").isNotEmpty() - .assertThat().field("message").isNull(); - - requestUpdateModel = restClient.withCoreAPI().usingMe().updateSiteMembershipRequest(moderatedSite, updatedMessage); - requestUpdateModel.assertThat().field("id").is(moderatedSite.getId()) - .assertThat().field("message").is(updatedMessage) - .assertThat().field("modifiedAt").isNotEmpty() - .assertThat().field("createdAt").isNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify user updates site membership request and verifies 'ModifiedAt' field using GET") - public void userUpdateSiteMembershipRequestAndCheckModifiedAtWithGet() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - requestUpdateModel = restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser() - .addSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - requestUpdateModel.assertThat().field("id").is(moderatedSite.getId()) - .assertThat().field("message").is("Please accept me"); - - requestUpdateModel = restClient.withCoreAPI().usingAuthUser().updateSiteMembershipRequest(moderatedSite, updatedMessage); - requestGetModel = restClient.withCoreAPI().usingAuthUser().getSiteMembershipRequest(moderatedSite); - - restClient.assertStatusCodeIs(HttpStatus.OK); - requestGetModel.assertThat().field("id").is(requestUpdateModel.getId()) - .and().field("modifiedAt").is(requestUpdateModel.getModifiedAt()) - .assertThat().field("message").is(requestUpdateModel.getMessage()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Update membership request - empty body") - public void emptyBodyUpdateSiteMembershipRequest() throws Exception - { - restClient.authenticateUser(adminUser).withCoreAPI(); - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"\": \"\",\"\": \"\", \"\": \"\"}", - "people/{personId}/site-membership-requests/{siteId}", adminUser.getUsername(), moderatedSite.getId()); - restClient.processModel(RestSiteMembershipRequestModel.class, request); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.NO_CONTENT, "Unrecognized field " + "\"\"")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Update membership request - missing 'Title' field from Json") - public void missingTitleFieldBodyUpdateSiteMembershipRequest() throws Exception - { - SiteModel moderatedSite = dataSite.usingUser(managerUser).createModeratedRandomSite(); - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser() - .addSiteMembershipRequest(moderatedSite); - - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, - "{\"message\":\"Please review my request\",\"id\":\"" + moderatedSite.getId() + "\"}", - "people/{personId}/site-membership-requests/{siteId}", - newMember.getUsername(), moderatedSite.getId()); - requestUpdateModel = restClient.processModel(RestSiteMembershipRequestModel.class, request); - - restClient.assertStatusCodeIs(HttpStatus.OK); - requestUpdateModel.assertThat().field("id").is(moderatedSite.getId()) - .assertThat().field("message").is(updatedMessage) - .assertThat().field("site").isNotEmpty() - .assertThat().field("modifiedAt").isNotEmpty() - .assertThat().field("createdAt").isNotEmpty(); - requestUpdateModel.getSite().assertThat().field("visibility").is(moderatedSite.getVisibility()) - .assertThat().field("guid").is(moderatedSite.getGuid()) - .assertThat().field("description").is(moderatedSite.getDescription()) - .assertThat().field("id").is(moderatedSite.getId()) - .assertThat().field("preset").is("site-dashboard") - .assertThat().field("title").is(moderatedSite.getTitle()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Update site membership request - missing JSON body") - public void missingJsonFieldBodyUpdateSiteMembershipRequest() throws Exception - { - SiteModel moderatedSite = dataSite.usingUser(managerUser).createModeratedRandomSite(); - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser() - .addSiteMembershipRequest(moderatedSite); - - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "", - "people/{personId}/site-membership-requests/{siteId}", newMember.getUsername(), - moderatedSite.getId()); - requestUpdateModel = restClient.processModel(RestSiteMembershipRequestModel.class, request); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsSummary(String.format(RestErrorModel.NO_CONTENT, "No content to map due to end-of-input")) - .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "No content to map due to end-of-input")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Update site membership request - empty JSON body") - public void emptyJsonFieldBodyUpdateSiteMembershipRequest() throws Exception - { - SiteModel moderatedSite = dataSite.usingUser(managerUser).createModeratedRandomSite(); - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser() - .addSiteMembershipRequest(moderatedSite); - - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{}", - "people/{personId}/site-membership-requests/{siteId}", newMember.getUsername(), - moderatedSite.getId()); - requestUpdateModel = restClient.processModel(RestSiteMembershipRequestModel.class, request); - - restClient.assertStatusCodeIs(HttpStatus.OK); - requestUpdateModel.assertThat().field("id").is(moderatedSite.getId()) - .assertThat().field("message").isNull() - .assertThat().field("site").isNotEmpty() - .assertThat().field("modifiedAt").isNotEmpty() - .assertThat().field("createdAt").isNotEmpty(); - requestUpdateModel.getSite().assertThat().field("visibility").is(moderatedSite.getVisibility()) - .assertThat().field("guid").is(moderatedSite.getGuid()) - .assertThat().field("description").is(moderatedSite.getDescription()) - .assertThat().field("id").is(moderatedSite.getId()) - .assertThat().field("preset").is("site-dashboard") - .assertThat().field("title").is(moderatedSite.getTitle()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Update site membership request - invalid SiteId") - public void invalidSiteIdUpdateSiteMembershipRequest() throws Exception - { - moderatedSite.setId("invalidSiteId"); - restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser() - .updateSiteMembershipRequest(moderatedSite, updatedMessage); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, managerUser.getUsername(), moderatedSite.getId())); - - moderatedSite.setId(moderatedSiteId); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Update site membership request - empty SiteId") - public void emptySiteIdUpdateSiteMembershipRequest() throws Exception - { - moderatedSite.setId(""); - restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser() - .updateSiteMembershipRequest(moderatedSite, updatedMessage); - - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) - .assertLastError() - .containsSummary(RestErrorModel.PUT_EMPTY_ARGUMENT) - .containsErrorKey(RestErrorModel.PUT_EMPTY_ARGUMENT) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - - moderatedSite.setId(moderatedSiteId); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify inexistent user is not able to update site membership request") - public void emptyUserCannotUpdateSiteMembershipRequest() throws Exception - { - UserModel emptyUser = new UserModel("", "password"); - restClient.authenticateUser(emptyUser).withCoreAPI().usingAuthUser() - .updateSiteMembershipRequest(moderatedSite, updatedMessage); - - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Update site membership request - rejected Request") - public void rejectRequestThenUpdateSiteMembershipRequest() throws Exception - { - UserModel userWithRejectedRequests = dataUser.createRandomTestUser(); - restClient.authenticateUser(userWithRejectedRequests).withCoreAPI().usingAuthUser() - .addSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - RestTaskModel taskModel = restClient.authenticateUser(userWithRejectedRequests).withWorkflowAPI().getTasks() - .getTaskModelByDescription(moderatedSite); - workflow.approveSiteMembershipRequest(managerUser.getUsername(), managerUser.getPassword(), taskModel.getId(), false, "Rejected"); - - requestUpdateModel = restClient.authenticateUser(userWithRejectedRequests).withCoreAPI().usingMe() - .updateSiteMembershipRequest(moderatedSite, updatedMessage); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, userWithRejectedRequests.getUsername(), moderatedSite.getId())) - .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Update site membership request - approved Request") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - public void approveRequestThenUpdateSiteMembershipRequest() throws Exception - { - UserModel userWithApprovedRequests = dataUser.createRandomTestUser(); - restClient.authenticateUser(userWithApprovedRequests).withCoreAPI().usingAuthUser() - .addSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - RestTaskModel taskModel = restClient.authenticateUser(userWithApprovedRequests).withWorkflowAPI().getTasks().getTaskModelByDescription(moderatedSite); - workflow.approveSiteMembershipRequest(managerUser.getUsername(), managerUser.getPassword(), taskModel.getId(), true, "Approve"); - - requestUpdateModel = restClient.authenticateUser(userWithApprovedRequests).withCoreAPI().usingMe() - .updateSiteMembershipRequest(moderatedSite, updatedMessage); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, userWithApprovedRequests.getUsername(), moderatedSite.getId())) - .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE}, executionType = ExecutionType.REGRESSION, - description = "Update site membership request using invalid network") - public void updateSiteMembershipRequestUsingInvalidNetwork() throws Exception - { - UserModel invalidUserNetwork = dataUser.createRandomTestUser(); - SiteModel site = dataSite.usingUser(invalidUserNetwork).createModeratedRandomSite(); - dataSite.usingUser(invalidUserNetwork).usingSite(site).addSiteToFavorites(); - invalidUserNetwork.setDomain("invalidNetwork"); - - requestUpdateModel = restClient.authenticateUser(invalidUserNetwork).withCoreAPI().usingMe() - .updateSiteMembershipRequest(site, updatedMessage); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE}, executionType = ExecutionType.REGRESSION, - description = "Verify user is not able to update a deleted site membership request") - public void userCantUpdateSiteMembershipRequestForDeletedRequest() throws Exception - { - SiteModel moderatedSite = dataSite.usingUser(managerUser).createModeratedRandomSite(); - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser() - .addSiteMembershipRequest(moderatedSite); - - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser() - .deleteSiteMembershipRequest(moderatedSite); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - requestUpdateModel = restClient.withCoreAPI().usingAuthUser() - .updateSiteMembershipRequest(moderatedSite, updatedMessage); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, newMember.getUsername(), moderatedSite.getId())); - } -} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/syncService/SyncServiceAPITests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/syncService/SyncServiceAPITests.java deleted file mode 100644 index 4c79218af..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/syncService/SyncServiceAPITests.java +++ /dev/null @@ -1,204 +0,0 @@ -package org.alfresco.service.search.rest.syncService; - -import java.util.LinkedList; -import java.util.List; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestSubscriberModel; -import org.alfresco.rest.model.RestSubscriberModelCollection; -import org.alfresco.rest.model.RestSyncNodeSubscriptionModel; -import org.alfresco.rest.model.RestSyncNodeSubscriptionModelCollection; -import org.alfresco.rest.model.RestSyncServiceHealthCheckModel; -import org.alfresco.rest.model.RestSyncSetChangesModel; -import org.alfresco.rest.model.RestSyncSetGetModel; -import org.alfresco.rest.model.RestSyncSetRequestModel; -import org.alfresco.rest.requests.syncServiceAPI.Healthcheck; -import org.alfresco.rest.requests.syncServiceAPI.Subscriptions.TYPE; -import org.alfresco.utility.LogFactory; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.slf4j.Logger; -import org.springframework.http.HttpStatus; -import org.testng.Assert; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Sanity tests for Testing Sync Service APIs - * - * @author mbhave - */ -@Test(groups = { TestGroup.SYNC_API, TestGroup.REQUIRES_AMP }) -public class SyncServiceAPITests extends RestTest -{ - private static Logger LOG = LogFactory.getLogger(); - - private UserModel adminUserModel; - private SiteModel siteModel; - private FolderModel targetFolder1; - private FolderModel targetFolder2; - - private RestSyncNodeSubscriptionModelCollection nodeSubscriptions; - - private String clientVersion; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - restClient.authenticateUser(adminUserModel); - - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - - targetFolder1 = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); - - targetFolder2 = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); - - siteModel.setGuid(restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(siteModel).getSite().getGuidWithoutVersion()); - - clientVersion = "1.1"; - } - - @Test(priority = 1) - public void testSyncServiceHealthCheck() throws Exception - { - // Perform HealthCheck - Healthcheck healthCheck = restClient.authenticateUser(adminUserModel).withPrivateAPI().doHealthCheck(); - - RestSyncServiceHealthCheckModel syncServiceHealthCheck = healthCheck.getHealthcheck(); - - Assert.assertTrue(syncServiceHealthCheck.getActiveMQConnection().getHealthy()); - Assert.assertTrue(syncServiceHealthCheck.getDatabaseConnection().getHealthy()); - Assert.assertTrue(syncServiceHealthCheck.getRepositoryConnection().getHealthy()); - Assert.assertTrue(syncServiceHealthCheck.getDeadlocks().getHealthy()); - Assert.assertTrue(syncServiceHealthCheck.getEventsHealthCheck().getHealthy()); - Assert.assertTrue(syncServiceHealthCheck.getSyncServiceIdCheck().getHealthy()); - Assert.assertTrue(syncServiceHealthCheck.getVersionCheck().getHealthy()); - } - - @Test(priority = 2) - public void testNewDeviceSubscription() throws Exception - { - // Register Device - RestSubscriberModel deviceSubscription = restClient.authenticateUser(adminUserModel).withPrivateAPI().withSubscribers() - .registerDevice("windows", clientVersion); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.onResponse().assertThat().body("entry.id", org.hamcrest.Matchers.notNullValue()); - restClient.onResponse().assertThat().body("entry.id", org.hamcrest.Matchers.equalTo(deviceSubscription.getId())); - - // Get Registered Devices - RestSubscriberModelCollection deviceSubscriptions = restClient.authenticateUser(adminUserModel).withParams("maxItems=500").withPrivateAPI() - .withSubscribers().getSubscribers(); - - restClient.onResponse().assertThat().body("list.entries.entry", org.hamcrest.Matchers.notNullValue()); - int noOfSubscriptions = deviceSubscriptions.getEntries().size(); - Assert.assertTrue(noOfSubscriptions > 0, "No Device subscriptions found when expected"); - Assert.assertTrue(deviceSubscriptions.getEntries().get(noOfSubscriptions - 1).onModel().getId().equals(deviceSubscription.getId()), "Not found: " - + deviceSubscription.getId()); - - } - - @Test(priority = 3) - public void testDeviceSubcriptionToNode() throws Exception - { - // Register Device - RestSubscriberModel deviceSubscription = restClient.authenticateUser(adminUserModel).withPrivateAPI().withSubscribers() - .registerDevice("windows", clientVersion); - - // Subscribe to a node - RestSyncNodeSubscriptionModel nodeSubscription = restClient.withPrivateAPI().withSubscriber(deviceSubscription) - .subscribeToNode(targetFolder1.getNodeRefWithoutVersion(), TYPE.BOTH); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.onResponse().assertThat().body("entry.deviceSubscriptionId", org.hamcrest.Matchers.notNullValue()); - restClient.onResponse().assertThat().body("entry.deviceSubscriptionId", org.hamcrest.Matchers.equalTo(deviceSubscription.getId())); - - restClient.onResponse().assertThat().body("entry.targetNodeId", org.hamcrest.Matchers.notNullValue()); - restClient.onResponse().assertThat().body("entry.targetNodeId", org.hamcrest.Matchers.equalTo(targetFolder1.getNodeRefWithoutVersion())); - - restClient.onResponse().assertThat().body("entry.id", org.hamcrest.Matchers.notNullValue()); - restClient.onResponse().assertThat().body("entry.id", org.hamcrest.Matchers.equalTo(nodeSubscription.getId())); - - // Get Sync Node Subscriptions - nodeSubscriptions = restClient.withPrivateAPI().withSubscriber(deviceSubscription).getSubscriptions(); - - nodeSubscriptions.assertThat().entriesListContains("id", nodeSubscription.getId()); - - restClient.onResponse().assertThat().body("list.entries.entry", org.hamcrest.Matchers.notNullValue()); - - int noOfSubscriptions = nodeSubscriptions.getEntries().size(); - Assert.assertTrue(noOfSubscriptions > 0, "No Sync subscriptions found when expected"); - LOG.info("Subscriptions: " + nodeSubscriptions); - Assert.assertEquals(nodeSubscriptions.getEntries().get(noOfSubscriptions - 1).onModel().getId(), nodeSubscription.getId()); - Assert.assertEquals(nodeSubscriptions.getEntries().get(noOfSubscriptions - 1).onModel().getDeviceSubscriptionId(), - nodeSubscription.getDeviceSubscriptionId()); - - // Get Sync Node Subscription by subscriptionId - RestSyncNodeSubscriptionModel subscription = restClient.withPrivateAPI().withSubscriber(deviceSubscription).getSubscription(nodeSubscription.getId()); - - subscription.assertThat().field("id").isNotNull().assertThat().field("id").is(nodeSubscription.getId()).assertThat().field("deviceSubscriptionId") - .isNotNull().assertThat().field("deviceSubscriptionId").is(nodeSubscription.getDeviceSubscriptionId()); - } - - @Test(priority = 4) - public void testDeviceSubcriptionToMultipleNodes() throws Exception - { - // Register Device - RestSubscriberModel deviceSubscription = restClient.authenticateUser(adminUserModel).withPrivateAPI().withSubscribers() - .registerDevice("windows", "1.2"); - - // Subscribe to a node - restClient.withPrivateAPI().withSubscriber(deviceSubscription) - .subscribeToNodes(siteModel.getGuid(), targetFolder1.getNodeRefWithoutVersion(), targetFolder2.getNodeRefWithoutVersion()); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - // Get Sync Node Subscriptions - RestSyncNodeSubscriptionModelCollection subscriptionList = restClient.withPrivateAPI().withSubscriber(deviceSubscription).getSubscriptions(); - - int countOfEntries = subscriptionList.getEntries().size(); - Assert.assertTrue(countOfEntries == 3, "Node subscriptions NOT found when expected"); - } - - @Test(priority = 5) - public void testSyncProcess() throws Exception - { - // Register Device - List clientChanges = new LinkedList<>(); - RestSubscriberModel deviceSubscription = restClient.authenticateUser(adminUserModel).withPrivateAPI().withSubscribers() - .registerDevice("windows", "1.2"); - - // Subscribe to a node - RestSyncNodeSubscriptionModel nodeSubscription = restClient.withPrivateAPI().withSubscriber(deviceSubscription) - .subscribeToNode(targetFolder1.getNodeRefWithoutVersion(), TYPE.BOTH); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - // Start Sync - RestSyncSetRequestModel syncRequest = restClient.authenticateUser(adminUserModel).withPrivateAPI().withSubscription(nodeSubscription) - .startSync(nodeSubscription, clientChanges, clientVersion); - - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - Assert.assertNotNull(syncRequest.getSyncId(), "Sync Id not expected to be null"); - String syncId = syncRequest.getSyncId(); - Assert.assertNotNull(syncRequest.getUrl(), "Sync URL not expected to be null"); - Assert.assertTrue(syncRequest.getUrl().endsWith(syncId), "Incorrect Sync URL, expected to end with syncId: " + syncId); - Assert.assertEquals(syncRequest.getStatus(), "ok", "Sync Status not ok. Actual: " + syncRequest.getStatus()); - Assert.assertNull(syncRequest.getMessage(), "Sync Message was expected to be null. Actual: " + syncRequest.getMessage()); - Assert.assertNull(syncRequest.getError(), "Sync Error expected to be null. Actual: " + syncRequest.getError()); - - // Get Sync Changes - RestSyncSetGetModel changeSet = restClient.withPrivateAPI().withSubscription(nodeSubscription).getSync(nodeSubscription, syncRequest); - - restClient.assertStatusCodeIs(HttpStatus.OK); - Assert.assertNotNull(changeSet.getSyncId(), "Sync Id not expected to be null"); - Assert.assertTrue(changeSet.getSyncId().equals(syncId), "Incorrect SyncId in the response"); - Assert.assertNotNull(changeSet.getMoreChanges(), "MoreChanges expected to be true or false. It's null"); - - // End Sync - restClient.withPrivateAPI().withSubscription(nodeSubscription).endSync(nodeSubscription, syncRequest); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/tags/GetTagTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/tags/GetTagTests.java deleted file mode 100644 index c155d472e..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/tags/GetTagTests.java +++ /dev/null @@ -1,139 +0,0 @@ -package org.alfresco.service.search.rest.tags; - -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestTagModel; -import org.alfresco.utility.constants.UserRole; -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; - -@Test(groups = {TestGroup.REQUIRE_SOLR}) -public class GetTagTests extends TagsDataPrep -{ - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - init(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify admin user gets tag using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void adminIsAbleToGetTag() throws Exception - { - RestTagModel returnedTag = restClient.authenticateUser(adminUserModel).withCoreAPI().getTag(documentTag); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedTag.assertThat().field("tag").is(documentTagValue.toLowerCase()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role gets tag using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) - public void userWithManagerRoleIsAbleToGetTag() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - - RestTagModel returnedTag = restClient.withCoreAPI().getTag(documentTag); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedTag.assertThat().field("tag").is(documentTagValue.toLowerCase()) - .assertThat().field("id").is(documentTag.getId()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify user with Collaborator role gets tag using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void userWithCollaboratorRoleIsAbleToGetTag() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - RestTagModel returnedTag = restClient.withCoreAPI().getTag(documentTag); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedTag.assertThat().field("tag").is(documentTagValue.toLowerCase()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify user with Contributor role gets tag using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void userWithContributorRoleIsAbleToGetTag() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - RestTagModel returnedTag = restClient.withCoreAPI().getTag(documentTag); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedTag.assertThat().field("tag").is(documentTagValue.toLowerCase()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify user with Consumer role gets tag using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void userWithConsumerRoleIsAbleToGetTag() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - RestTagModel returnedTag = restClient.withCoreAPI().getTag(documentTag); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedTag.assertThat().field("tag").is(documentTagValue.toLowerCase()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Manager user gets status code 401 if authentication call fails") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) -// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void managerIsNotAbleToGetTagIfAuthenticationFails() throws Exception - { - UserModel managerUser = dataUser.usingAdmin().createRandomTestUser(); - String managerPassword = managerUser.getPassword(); - dataUser.addUserToSite(managerUser, siteModel, UserRole.SiteManager); - managerUser.setPassword("wrongPassword"); - restClient.authenticateUser(managerUser).withCoreAPI().getTag(documentTag); - managerUser.setPassword(managerPassword); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that if tag id is invalid status code returned is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void invalidTagIdTest() throws Exception - { - String tagId = documentTag.getId(); - documentTag.setId("random_tag_value"); - restClient.authenticateUser(adminUserModel).withCoreAPI().getTag(documentTag); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "random_tag_value")); - documentTag.setId(tagId); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, - executionType = ExecutionType.REGRESSION, description = "Check that properties filter is applied when getting tag using Manager user.") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void checkPropertiesFilterIsApplied() throws Exception - { - RestTagModel returnedTag = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withParams("properties=id,tag").withCoreAPI().getTag(documentTag); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedTag.assertThat().field("id").is(documentTag.getId()) - .assertThat().field("tag").is(documentTag.getTag().toLowerCase()) - .assertThat().fieldsCount().is(2); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, - executionType = ExecutionType.REGRESSION, description = "Check that Manager user can get tag of a folder.") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void getTagOfAFolder() throws Exception - { - RestTagModel returnedTag = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().getTag(folderTag); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedTag.assertThat().field("tag").is(folderTagValue.toLowerCase()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, - executionType = ExecutionType.REGRESSION, description = "Check default error model schema. Use invalid skipCount parameter.") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void checkDefaultErrorModelSchema() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withParams("skipCount=abc").withCoreAPI().getTag(documentTag); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(String.format(RestErrorModel.INVALID_SKIPCOUNT, "abc")) - .containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "abc")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } -} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/tags/GetTagsTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/tags/GetTagsTests.java deleted file mode 100644 index d3e77911a..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/tags/GetTagsTests.java +++ /dev/null @@ -1,230 +0,0 @@ -package org.alfresco.service.search.rest.tags; - -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestTagModel; -import org.alfresco.rest.model.RestTagModelsCollection; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.RandomData; -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.BeforeClass; -import org.testng.annotations.Test; - -@Test(groups = {TestGroup.REQUIRE_SOLR}) -public class GetTagsTests extends TagsDataPrep -{ - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - init(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role gets tags using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) - public void getTagsWithManagerRole() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat().entriesListIsNotEmpty() - .and().entriesListContains("tag", documentTagValue.toLowerCase()) - .and().entriesListContains("tag", documentTagValue2.toLowerCase()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify user with Collaborator role gets tags using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void getTagsWithCollaboratorRole() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat().entriesListIsNotEmpty() - .and().entriesListContains("tag", documentTagValue.toLowerCase()) - .and().entriesListContains("tag", documentTagValue2.toLowerCase()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify user with Contributor role gets tags using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void getTagsWithContributorRole() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat().entriesListIsNotEmpty() - .and().entriesListContains("tag", documentTagValue.toLowerCase()) - .and().entriesListContains("tag", documentTagValue2.toLowerCase()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify user with Consumer role gets tags using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void getTagsWithConsumerRole() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat().entriesListIsNotEmpty() - .and().entriesListContains("tag", documentTagValue.toLowerCase()) - .and().entriesListContains("tag", documentTagValue2.toLowerCase()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Failed authentication get tags call returns status code 401 with Manager role") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) -// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void failedAuthenticationReturnsUnauthorizedStatus() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - userModel = dataUser.createRandomTestUser(); - userModel.setPassword("user wrong password"); - dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); - restClient.authenticateUser(userModel); - restClient.withCoreAPI().getTags(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that if maxItems is invalid status code returned is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION}) - public void maxItemsInvalidValueTest() throws Exception - { - restClient.authenticateUser(adminUserModel).withParams("maxItems=abc").withCoreAPI().getTags(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "abc")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that if skipCount is invalid status code returned is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION}) - public void skipCountInvalidValueTest() throws Exception - { - restClient.authenticateUser(adminUserModel).withParams("skipCount=abc").withCoreAPI().getTags(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "abc")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that file tag is retrieved") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION}) - public void fileTagIsRetrieved() throws Exception - { - restClient.authenticateUser(adminUserModel); - returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat().entriesListIsNotEmpty() - .and().entriesListContains("tag", documentTagValue.toLowerCase()) - .and().entriesListContains("tag", documentTagValue2.toLowerCase()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that folder tag is retrieved") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION}) - public void folderTagIsRetrieved() throws Exception - { - restClient.authenticateUser(adminUserModel); - returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat().entriesListIsNotEmpty() - .and().entriesListContains("tag", folderTagValue.toLowerCase()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify site Manager is able to get tags using properties parameter." - + "Check that properties filter is applied.") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void siteManagerIsAbleToRetrieveTagsWithPropertiesParameter() throws Exception - { - returnedCollection = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withParams("maxItems=5000&properties=tag").withCoreAPI().getTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat().entriesListIsNotEmpty() - .and().entriesListContains("tag", documentTagValue.toLowerCase()) - .and().entriesListContains("tag", documentTagValue2.toLowerCase()) - .and().entriesListDoesNotContain("id"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "With admin get tags and use skipCount parameter. Check pagination") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void useSkipCountCheckPagination() throws Exception - { - returnedCollection = restClient.authenticateUser(adminUserModel).withCoreAPI().getTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - RestTagModel firstTag = returnedCollection.getEntries().get(0).onModel(); - RestTagModel secondTag = returnedCollection.getEntries().get(1).onModel(); - RestTagModelsCollection tagsWithSkipCount = restClient.withParams("skipCount=2").withCoreAPI().getTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - tagsWithSkipCount.assertThat().entriesListDoesNotContain("tag", firstTag.getTag()) - .assertThat().entriesListDoesNotContain("tag", secondTag.getTag()); - tagsWithSkipCount.assertThat().paginationField("skipCount").is("2"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "With admin get tags and use maxItems parameter. Check pagination") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void useMaxItemsParameterCheckPagination() throws Exception - { - returnedCollection = restClient.authenticateUser(adminUserModel).withCoreAPI().getTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - RestTagModel firstTag = returnedCollection.getEntries().get(0).onModel(); - RestTagModel secondTag = returnedCollection.getEntries().get(1).onModel(); - RestTagModelsCollection tagsWithMaxItems = restClient.withParams("maxItems=2").withCoreAPI().getTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - tagsWithMaxItems.assertThat().entriesListContains("tag", firstTag.getTag()) - .assertThat().entriesListContains("tag", secondTag.getTag()) - .assertThat().entriesListCountIs(2); - tagsWithMaxItems.assertThat().paginationField("maxItems").is("2"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "With manager get tags and use high skipCount parameter. Check pagination") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void useHighSkipCountCheckPagination() throws Exception - { - returnedCollection = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withParams("skipCount=20000").withCoreAPI().getTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat().entriesListIsEmpty() - .getPagination().assertThat().field("maxItems").is(100) - .and().field("hasMoreItems").is("false") - .and().field("count").is("0") - .and().field("skipCount").is(20000) - .and().field("totalItems").isNull(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "With Collaborator user get tags and use maxItems with value zero. Check default error model schema") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void useMaxItemsWithValueZeroCheckDefaultErrorModelSchema() throws Exception - { - returnedCollection = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withParams("maxItems=0").withCoreAPI().getTags(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) - .containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "With Manager user delete tag. Check it is not retrieved anymore.") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void checkThatDeletedTagIsNotRetrievedAnymore() throws Exception - { - String removedTag = RandomData.getRandomName("tag3"); - - RestTagModel deletedTag = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(document).addTag(removedTag); - - restClient.withCoreAPI().usingResource(document).deleteTag(deletedTag); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); - returnedCollection.assertThat().entriesListIsNotEmpty() - .and().entriesListDoesNotContain("tag", removedTag.toLowerCase()); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/tags/TagsDataPrep.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/tags/TagsDataPrep.java deleted file mode 100644 index 974257df6..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/tags/TagsDataPrep.java +++ /dev/null @@ -1,70 +0,0 @@ -package org.alfresco.service.search.rest.tags; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestTagModel; -import org.alfresco.rest.model.RestTagModelsCollection; -import org.alfresco.utility.Utility; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.testng.annotations.Test; - -@Test(groups = {TestGroup.REQUIRE_SOLR}) -public class TagsDataPrep extends RestTest -{ - - protected static UserModel adminUserModel; - protected static UserModel userModel; - protected static ListUserWithRoles usersWithRoles; - protected static SiteModel siteModel; - protected static FileModel document; - protected static FolderModel folder; - protected static String documentTagValue, documentTagValue2, folderTagValue; - protected static RestTagModel documentTag, documentTag2, folderTag, returnedModel; - protected static RestTagModelsCollection returnedCollection; - private static boolean isInitialized = false; - - public void init() throws Exception - { - if(!isInitialized) - { - isInitialized = true; - initialization(); - } - } - - public void initialization() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - //Create public site - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - usersWithRoles = dataUser.usingAdmin().addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); - document = dataContent.usingUser(adminUserModel).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - folder = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); - - documentTagValue = RandomData.getRandomName("tag"); - documentTagValue2 = RandomData.getRandomName("tag"); - folderTagValue = RandomData.getRandomName("tag"); - - restClient.authenticateUser(adminUserModel); - documentTag = restClient.withCoreAPI().usingResource(document).addTag(documentTagValue); - documentTag2 = restClient.withCoreAPI().usingResource(document).addTag(documentTagValue2); - folderTag = restClient.withCoreAPI().usingResource(folder).addTag(folderTagValue); - - // Allow indexing to complete. - Utility.sleep(1000, 60000, () -> - { - returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags(); - returnedCollection.assertThat().entriesListContains("tag", documentTagValue.toLowerCase()) - .and().entriesListContains("tag", documentTagValue2.toLowerCase()) - .and().entriesListContains("tag", folderTagValue.toLowerCase()); - }); - - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/tags/UpdateTagTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/tags/UpdateTagTests.java deleted file mode 100644 index efa6b115e..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/tags/UpdateTagTests.java +++ /dev/null @@ -1,269 +0,0 @@ -package org.alfresco.service.search.rest.tags; - -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestTagModel; -import org.alfresco.utility.Utility; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.apache.commons.lang3.RandomStringUtils; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -/** - * Created by Claudia Agache on 10/4/2016. - */ -@Test(groups = {TestGroup.REQUIRE_SOLR}) -public class UpdateTagTests extends TagsDataPrep -{ - private RestTagModel oldTag; - private String randomTag = ""; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - init(); - } - - @BeforeMethod(alwaysRun=true) - public void addTagToDocument() throws Exception - { - restClient.authenticateUser(adminUserModel); - oldTag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("old")); - randomTag = RandomData.getRandomName("tag"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Admin user updates tags and status code is 200") - @Bug(id="REPO-1828") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) - public void adminIsAbleToUpdateTags() throws Exception - { - restClient.authenticateUser(adminUserModel); - returnedModel = restClient.withCoreAPI().usingTag(oldTag).update(randomTag); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedModel.assertThat().field("tag").is(randomTag); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify Manager user can't update tags with Rest API and status code is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void managerIsNotAbleToUpdateTag() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingTag(oldTag).update(randomTag); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, - executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user can't update tags with Rest API and status code is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void collaboratorIsNotAbleToUpdateTagCheckDefaultErrorModelSchema() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.withCoreAPI().usingTag(oldTag).update(randomTag); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, - executionType = ExecutionType.REGRESSION, description = "Verify Contributor user can't update tags with Rest API and status code is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void contributorIsNotAbleToUpdateTag() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - restClient.withCoreAPI().usingTag(oldTag).update(randomTag); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, - executionType = ExecutionType.SANITY, description = "Verify Consumer user can't update tags with Rest API and status code is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void consumerIsNotAbleToUpdateTag() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.withCoreAPI().usingTag(oldTag).update(randomTag); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, - executionType = ExecutionType.SANITY, description = "Verify user gets status code 401 if authentication call fails") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) -// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void userIsNotAbleToUpdateTagIfAuthenticationFails() throws Exception - { - UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); - String managerPassword = siteManager.getPassword(); - siteManager.setPassword("wrongPassword"); - restClient.authenticateUser(siteManager); - restClient.withCoreAPI().usingTag(oldTag).update(randomTag); - siteManager.setPassword(managerPassword); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify admin is not able to update tag with invalid id") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void adminIsNotAbleToUpdateTagWithInvalidId() throws Exception - { - String invalidTagId = "invalid-id"; - RestTagModel tag = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); - tag.setId(invalidTagId); - restClient.withCoreAPI().usingTag(tag).update(RandomData.getRandomName("tag")); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, invalidTagId)); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify admin is not able to update tag with empty id") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void adminIsNotAbleToUpdateTagWithEmptyId() throws Exception - { - RestTagModel tag = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); - tag.setId(""); - restClient.withCoreAPI().usingTag(tag).update(RandomData.getRandomName("tag")); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) - .assertLastError().containsSummary(RestErrorModel.PUT_EMPTY_ARGUMENT); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify admin is not able to update tag with invalid body") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void adminIsNotAbleToUpdateTagWithEmptyBody() throws Exception - { - RestTagModel tag = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); - restClient.withCoreAPI().usingTag(tag).update(""); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(RestErrorModel.EMPTY_TAG); - } - - @Bug(id="ACE-5629") - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify admin is not able to update tag with invalid body containing '|' symbol") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void adminIsNotAbleToUpdateTagWithInvalidBodyScenario1() throws Exception - { - String invalidTagBody = "|.\"/<>*"; - RestTagModel tag = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); - Utility.waitToLoopTime(20); - restClient.withCoreAPI().usingTag(tag).update(invalidTagBody); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_TAG, invalidTagBody)); - } - - @Bug(id="ACE-5629") - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify admin is not able to update tag with invalid body without '|' symbol") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void adminIsNotAbleToUpdateTagWithInvalidBodyScenario2() throws Exception - { - String invalidTagBody = ".\"/<>*"; - RestTagModel tag = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); - Utility.waitToLoopTime(20); - restClient.withCoreAPI().usingTag(tag).update(invalidTagBody); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_TAG, invalidTagBody)); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify admin user can provide large string for new tag value.") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - @Bug(id="REPO-1828") - public void adminIsAbleToUpdateTagsProvideLargeStringTag() throws Exception - { - String largeStringTag = RandomStringUtils.randomAlphanumeric(10000); - - restClient.authenticateUser(adminUserModel); - returnedModel = restClient.withCoreAPI().usingTag(oldTag).update(largeStringTag); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedModel.assertThat().field("tag").is(largeStringTag); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify admin user can provide short string for new tag value.") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - @Bug(id="REPO-1828") - public void adminIsAbleToUpdateTagsProvideShortStringTag() throws Exception - { - String shortStringTag = RandomStringUtils.randomAlphanumeric(2); - - restClient.authenticateUser(adminUserModel); - returnedModel = restClient.withCoreAPI().usingTag(oldTag).update(shortStringTag); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedModel.assertThat().field("tag").is(shortStringTag); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify admin user can provide string with special chars for new tag value.") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - @Bug(id="REPO-1828") - public void adminIsAbleToUpdateTagsProvideSpecialCharsStringTag() throws Exception - { - String specialCharsString = "!@#$%^&*()'\".,<>-_+=|\\"; - - restClient.authenticateUser(adminUserModel); - returnedModel = restClient.withCoreAPI().usingTag(oldTag).update(specialCharsString); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedModel.assertThat().field("tag").is(specialCharsString); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify Admin user can provide existing tag for new tag value.") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - @Bug(id="REPO-1828") - public void adminIsAbleToUpdateTagsProvideExistingTag() throws Exception - { - String existingTag = "oldTag"; - RestTagModel oldExistingTag = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(document).addTag(existingTag); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(adminUserModel); - returnedModel = restClient.withCoreAPI().usingTag(oldExistingTag).update(existingTag); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedModel.assertThat().field("tag").is(existingTag); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify Admin user can delete a tag, add tag and update it.") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - @Bug(id="REPO-1828") - public void adminDeleteTagAddTagUpdateTag() throws Exception - { - restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingResource(document).deleteTag(oldTag); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - String newTag = "addTag"; - RestTagModel newTagModel = restClient.withCoreAPI().usingResource(document).addTag(newTag); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - returnedModel = restClient.withCoreAPI().usingTag(newTagModel).update(newTag); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedModel.assertThat().field("tag").is(newTag); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify Admin user can update a tag, delete tag and add it.") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - @Bug(id="REPO-1828") - public void adminUpdateTagDeleteTagAddTag() throws Exception - { - String newTag = "addTag"; - - returnedModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingTag(oldTag).update(newTag); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedModel.assertThat().field("tag").is(newTag); - - restClient.withCoreAPI().usingResource(document).deleteTag(returnedModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingResource(document).addTag(newTag); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - } -} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/tags/nodes/AddTagTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/tags/nodes/AddTagTests.java deleted file mode 100644 index 9ecb92f39..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/tags/nodes/AddTagTests.java +++ /dev/null @@ -1,337 +0,0 @@ -package org.alfresco.service.search.rest.tags.nodes; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.model.RestCommentModel; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestTagModel; -import org.alfresco.rest.model.RestTagModelsCollection; -import org.alfresco.service.search.rest.tags.TagsDataPrep; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.apache.commons.lang3.RandomStringUtils; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -/** - * Created by Claudia Agache on 10/3/2016. - */ -@Test(groups = {TestGroup.REQUIRE_SOLR}) -public class AddTagTests extends TagsDataPrep -{ - private String tagValue; - private RestTagModel returnedModel; - private RestCommentModel returnedModelComment; - private RestTagModelsCollection returnedModelTags; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - init(); - } - - @BeforeMethod(alwaysRun = true) - public void generateRandomTag() - { - tagValue = RandomData.getRandomName("tag"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify admin user adds tags with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void adminIsAbleToAddTag() throws Exception - { - restClient.authenticateUser(adminUserModel); - returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedModel.assertThat().field("tag").is(tagValue) - .and().field("id").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, - description = "Verify Manager user adds tags with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) - public void managerIsAbleToTagAFile() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedModel.assertThat().field("tag").is(tagValue) - .and().field("id").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify Collaborator user adds tags with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void collaboratorIsAbleToTagAFile() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedModel.assertThat().field("tag").is(tagValue) - .and().field("id").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify Contributor user doesn't have permission to add tags with Rest API and status code is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void contributorIsNotAbleToAddTagToAnotherContent() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - restClient.withCoreAPI().usingResource(document).addTag(tagValue); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify Contributor user adds tags to his content with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void contributorIsAbleToAddTagToHisContent() throws Exception - { - userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); - restClient.authenticateUser(userModel); - FileModel contributorDoc = dataContent.usingSite(siteModel).usingUser(userModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - returnedModel = restClient.withCoreAPI().usingResource(contributorDoc).addTag(tagValue); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedModel.assertThat().field("id").isNotEmpty() - .and().field("tag").is(tagValue); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify Consumer user doesn't have permission to add tags with Rest API and status code is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void consumerIsNotAbleToTagAFile() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.withCoreAPI().usingResource(document).addTag(tagValue); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, - description = "Verify user gets status code 401 if authentication call fails") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) -// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void userIsNotAbleToAddTagIfAuthenticationFails() throws Exception - { - UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); - String managerPassword = siteManager.getPassword(); - siteManager.setPassword("wrongPassword"); - restClient.authenticateUser(siteManager); - restClient.withCoreAPI().usingResource(document).addTag("tagUnauthorized"); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - siteManager.setPassword(managerPassword); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that adding empty tag returns status code 400") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void emptyTagTest() throws Exception - { - restClient.authenticateUser(adminUserModel); - returnedModel = restClient.withCoreAPI().usingResource(document).addTag(""); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.NULL_ARGUMENT, "tag")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that adding tag with user that has no permissions returns status code 403") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void addTagWithUserThatDoesNotHavePermissions() throws Exception - { - restClient.authenticateUser(dataUser.createRandomTestUser()); - returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that adding tag to a node that does not exist returns status code 404") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void addTagToInexistentNode() throws Exception - { - String oldNodeRef = document.getNodeRef(); - String nodeRef = RandomStringUtils.randomAlphanumeric(10); - document.setNodeRef(nodeRef); - - restClient.authenticateUser(adminUserModel); - returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, nodeRef)); - document.setNodeRef(oldNodeRef); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, - description = "Verify that manager is able to tag a folder") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) - public void managerIsAbleToTagAFolder() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - returnedModel = restClient.withCoreAPI().usingResource(folderModel).addTag(tagValue); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedModel.assertThat().field("tag").is(tagValue).and().field("id").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that tagged file can be tagged again") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void addTagToATaggedFile() throws Exception - { - restClient.authenticateUser(adminUserModel); - - returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedModel.assertThat().field("tag").is(tagValue).and().field("id").isNotEmpty(); - - returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedModel.assertThat().field("tag").is(tagValue).and().field("id").isNotEmpty(); - - returnedModel = restClient.withCoreAPI().usingResource(document).addTag("random_tag_value"); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedModel.assertThat().field("tag").is("random_tag_value").and().field("id").isNotEmpty(); - - restClient.withCoreAPI().usingResource(document).getNodeTags().assertThat() - .entriesListContains("tag", tagValue.toLowerCase()) - .and().entriesListContains("tag", "random_tag_value"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that user cannot add invalid tag") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void addInvalidTag() throws Exception - { - restClient.authenticateUser(adminUserModel); - returnedModel = restClient.withCoreAPI().usingResource(document).addTag("-1~!|@#$%^&*()_="); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_TAG, "|")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that contributor is able to tag a folder created by self") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void contributorIsAbleToTagAFolderCreatedBySelf() throws Exception - { - FolderModel folderModel = dataContent.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingSite(siteModel).createFolder(); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - returnedModel = restClient.withCoreAPI().usingResource(folderModel).addTag(tagValue); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedModel.assertThat().field("tag").is(tagValue).and().field("id").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that collaborator is able to tag a folder") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void collaboratorIsAbleToTagAFolder() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - returnedModel = restClient.withCoreAPI().usingResource(folderModel).addTag(tagValue); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedModel.assertThat().field("tag").is(tagValue).and().field("id").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that consumer is not able to tag a folder. Check default error model schema.") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void consumerIsNotAbleToTagAFolder() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .withCoreAPI().usingResource(folderModel).addTag(tagValue); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that tagged folder can be tagged again") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void addTagToATaggedFolder() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - - returnedModel = restClient.withCoreAPI().usingResource(folderModel).addTag(tagValue); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedModel.assertThat().field("tag").is(tagValue).and().field("id").isNotEmpty(); - - returnedModel = restClient.withCoreAPI().usingResource(folderModel).addTag("random_tag_value"); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedModel.assertThat().field("tag").is("random_tag_value").and().field("id").isNotEmpty(); - - restClient.withCoreAPI().usingResource(folderModel).getNodeTags().assertThat() - .entriesListContains("tag", tagValue.toLowerCase()) - .and().entriesListContains("tag", "random_tag_value") - .and().entriesListCountIs(2); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Using collaborator provide more than one tag element") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void provideMoreThanOneTagElement() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); - String tagValue1 = RandomData.getRandomName("tag1"); - String tagValue2 = RandomData.getRandomName("tag2"); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - - returnedModelTags = restClient.withCoreAPI().usingResource(folderModel).addTags(tagValue, tagValue1, tagValue2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedModelTags.assertThat().entriesListContains("tag", tagValue) - .and().entriesListContains("tag", tagValue1) - .and().entriesListContains("tag", tagValue2) - .and().entriesListCountIs(3); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that manager cannot add tag with special characters.") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void addTagWithSpecialCharacters() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); - String specialCharsTag = "!@#$%^&*()'\".,<>-_+=|\\"; - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(folderModel).addTag(specialCharsTag); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_TAG, "|")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that you cannot tag a comment and it returns status code 405") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void addTagToAComment() throws Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - String comment = "comment for a tag"; - - restClient.authenticateUser(adminUserModel); - returnedModelComment = restClient.withCoreAPI().usingResource(file).addComment(comment); - file.setNodeRef(returnedModelComment.getId()); - restClient.withCoreAPI().usingResource(file).addTag(tagValue); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.CANNOT_TAG); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that you cannot tag a tag and it returns status code 405") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void addTagToATag() throws Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(adminUserModel); - returnedModel = restClient.withCoreAPI().usingResource(file).addTag(tagValue); - file.setNodeRef(returnedModel.getId()); - restClient.withCoreAPI().usingResource(file).addTag(tagValue); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.CANNOT_TAG); - } -} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/tags/nodes/AddTagsTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/tags/nodes/AddTagsTests.java deleted file mode 100644 index 8e2e8a452..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/tags/nodes/AddTagsTests.java +++ /dev/null @@ -1,150 +0,0 @@ -package org.alfresco.service.search.rest.tags.nodes; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestTagModel; -import org.alfresco.rest.model.RestTagModelsCollection; -import org.alfresco.service.search.rest.tags.TagsDataPrep; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.RandomData; -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.HttpStatus; -import org.testng.Assert; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -/** - * Created by Claudia Agache on 10/7/2016. - */ -@Test(groups = {TestGroup.REQUIRE_SOLR}) -public class AddTagsTests extends TagsDataPrep -{ - private FileModel contributorDoc; - private String tag1, tag2; - private RestTagModelsCollection returnedCollection; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - init(); - } - - @BeforeMethod(alwaysRun = true) - public void generateRandomTagsList() - { - tag1 = RandomData.getRandomName("tag"); - tag2 = RandomData.getRandomName("tag"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify admin user adds multiple tags with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void adminIsAbleToAddTags() throws Exception - { - restClient.authenticateUser(adminUserModel); - returnedCollection = restClient.withCoreAPI().usingResource(document).addTags(tag1, tag2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedCollection.assertThat().entriesListContains("tag", tag1) - .and().entriesListContains("tag", tag2); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, - description = "Verify Manager user adds multiple tags with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) - public void managerIsAbleToAddTags() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - returnedCollection = restClient.withCoreAPI().usingResource(document).addTags(tag1, tag2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedCollection.assertThat().entriesListContains("tag", tag1) - .and().entriesListContains("tag", tag2); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, - executionType = ExecutionType.SANITY, description = "Verify Collaborator user adds multiple tags with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void collaboratorIsAbleToAddTags() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - returnedCollection = restClient.withCoreAPI().usingResource(document).addTags(tag1, tag2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedCollection.assertThat().entriesListContains("tag", tag1) - .and().entriesListContains("tag", tag2); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify Contributor user doesn't have permission to add multiple tags with Rest API and status code is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void contributorIsNotAbleToAddTagsToAnotherContent() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - restClient.withCoreAPI().usingResource(document).addTags(tag1, tag2); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify Contributor user adds multiple tags to his content with Rest API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void contributorIsAbleToAddTagsToHisContent() throws Exception - { - userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); - restClient.authenticateUser(userModel); - contributorDoc = dataContent.usingSite(siteModel).usingUser(userModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - returnedCollection = restClient.withCoreAPI().usingResource(contributorDoc).addTags(tag1, tag2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - returnedCollection.assertThat().entriesListContains("tag", tag1) - .and().entriesListContains("tag", tag2); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify Consumer user doesn't have permission to add multiple tags with Rest API and status code is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void consumerIsNotAbleToAddTags() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingResource(document).addTags(tag1, tag2); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.TAGS }, executionType = ExecutionType.SANITY, - description = "Verify user gets status code 401 if authentication call fails") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) -// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void userIsNotAbleToAddTagsIfAuthenticationFails() throws Exception - { - UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); - String managerPassword = siteManager.getPassword(); - siteManager.setPassword("wrongPassword"); - restClient.authenticateUser(siteManager).withCoreAPI().usingResource(document).addTags(tag1, tag2); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - siteManager.setPassword(managerPassword); - } - - @TestRail(section = { TestGroup.REST_API, - TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify include count parameter") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void getTagsUsingCountParam() throws Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - String tagName = RandomData.getRandomName("tag"); - returnedModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addTag(RandomData.getRandomName("tag")); - RestTagModelsCollection tagsWithIncludeParamCount = restClient.withParams("include=count").withCoreAPI().getTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); - for (RestTagModel tagModel : tagsWithIncludeParamCount.getEntries()) - { - if (tagModel != null && tagModel.getTag() != null) - { - if (tagModel.getTag().equals(tagName)) - { - Assert.assertEquals(tagModel.getCount().intValue(), 1); - } - } - } - - } -} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/tags/nodes/DeleteTagTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/tags/nodes/DeleteTagTests.java deleted file mode 100644 index 75540fcbc..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/tags/nodes/DeleteTagTests.java +++ /dev/null @@ -1,287 +0,0 @@ -package org.alfresco.service.search.rest.tags.nodes; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestTagModel; -import org.alfresco.service.search.rest.tags.TagsDataPrep; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.apache.commons.lang3.RandomStringUtils; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Created by Claudia Agache on 10/4/2016. - */ -@Test(groups = {TestGroup.REQUIRE_SOLR}) -public class DeleteTagTests extends TagsDataPrep -{ - private RestTagModel tag; - private FileModel contributorDoc; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - init(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify Admin user deletes tags with Rest API and status code is 204") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void adminIsAbleToDeleteTags() throws Exception - { - restClient.authenticateUser(adminUserModel); - tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); - - restClient.withCoreAPI().usingResource(document).deleteTag(tag); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingResource(document).getNodeTags() - .assertThat().entriesListDoesNotContain("tag", tag.getTag()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, - description = "Verify Manager user deletes tags created by admin user with Rest API and status code is 204") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) - public void managerIsAbleToDeleteTags() throws Exception - { - restClient.authenticateUser(adminUserModel); - tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingResource(document).deleteTag(tag); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify Collaborator user deletes tags created by admin user with Rest API and status code is 204") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void collaboratorIsAbleToDeleteTags() throws Exception - { - restClient.authenticateUser(adminUserModel); - tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.withCoreAPI().usingResource(document).deleteTag(tag); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify Contributor user can't delete tags created by admin user with Rest API and status code is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void contributorIsNotAbleToDeleteTagsForAnotherUserContent() throws Exception - { - restClient.authenticateUser(adminUserModel); - tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - restClient.withCoreAPI().usingResource(document).deleteTag(tag); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify Contributor user deletes tags created by him with Rest API and status code is 204") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void contributorIsAbleToDeleteTagsForHisContent() throws Exception - { - userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); - restClient.authenticateUser(userModel); - contributorDoc = dataContent.usingSite(siteModel).usingUser(userModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);; - tag = restClient.withCoreAPI().usingResource(contributorDoc).addTag(RandomData.getRandomName("tag")); - - restClient.withCoreAPI().usingResource(document).deleteTag(tag); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify Consumer user can't delete tags created by admin user with Rest API and status code is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void consumerIsNotAbleToDeleteTags() throws Exception - { - restClient.authenticateUser(adminUserModel); - tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.withCoreAPI().usingResource(document).deleteTag(tag); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, - description = "Verify user gets status code 401 if authentication call fails") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) -// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void userIsNotAbleToDeleteTagIfAuthenticationFails() throws Exception - { - restClient.authenticateUser(adminUserModel); - tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); - - UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); - String managerPassword = siteManager.getPassword(); - siteManager.setPassword("wrongPassword"); - restClient.authenticateUser(siteManager); - restClient.withCoreAPI().usingResource(document).deleteTag(tag); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - siteManager.setPassword(managerPassword); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that if user has no permission to remove tag returned status code is 403. Check default error model schema") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void deleteTagWithUserWithoutPermissionCheckDefaultErrorModelSchema() throws Exception - { - restClient.authenticateUser(adminUserModel); - RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); - - restClient.authenticateUser(dataUser.createRandomTestUser()); - restClient.withCoreAPI().usingResource(document).deleteTag(tag); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that if node does not exist returned status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void deleteTagForANonexistentNode() throws Exception - { - restClient.authenticateUser(adminUserModel); - RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); - - FileModel document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - String nodeRef = RandomStringUtils.randomAlphanumeric(10); - document.setNodeRef(nodeRef); - restClient.withCoreAPI().usingResource(document).deleteTag(tag); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, nodeRef)); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that if tag does not exist returned status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void deleteTagThatDoesNotExist() throws Exception - { - restClient.authenticateUser(adminUserModel); - RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); - - tag.setId("abc"); - restClient.withCoreAPI().usingResource(document).deleteTag(tag); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "abc")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that if tag id is empty returned status code is 405") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void deleteTagWithEmptyId() throws Exception - { - restClient.authenticateUser(adminUserModel); - RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); - - tag.setId(""); - restClient.withCoreAPI().usingResource(document).deleteTag(tag); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.DELETE_EMPTY_ARGUMENT); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that folder tag can be deleted") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void deleteFolderTag() throws Exception - { - FolderModel folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder();; - restClient.authenticateUser(adminUserModel); - RestTagModel tag = restClient.withCoreAPI().usingResource(folderModel).addTag(RandomData.getRandomName("tag")); - restClient.withCoreAPI().usingResource(folderModel).deleteTag(tag); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withCoreAPI().usingResource(folderModel).getNodeTags() - .assertThat().entriesListDoesNotContain("tag", tag.getTag()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, - executionType = ExecutionType.REGRESSION, description = "Verify Manager user can't delete deleted tag.") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - @Bug(id = "ACE-5455") - public void managerCannotDeleteDeletedTag() throws Exception - { - tag = restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag")); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(document).deleteTag(tag); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingResource(document).deleteTag(tag); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, - executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user can delete long tag.") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void userCollaboratorCanDeleteLongTag() throws Exception - { - String longTag = RandomStringUtils.randomAlphanumeric(800); - - tag = restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingResource(document).addTag(longTag); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingResource(document).deleteTag(tag); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, - executionType = ExecutionType.REGRESSION, description = "Verify Manager user can delete short tag.") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void managerCanDeleteShortTag() throws Exception - { - String shortTag = RandomStringUtils.randomAlphanumeric(10); - - tag = restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingResource(document).addTag(shortTag); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(document).deleteTag(tag); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, - executionType = ExecutionType.REGRESSION, description = "Verify Admin can delete tag then add it again.") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void adminRemovesTagAndAddsItAgain() throws Exception - { - String tagValue = RandomStringUtils.randomAlphanumeric(10); - - tag = restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingResource(document).addTag(tagValue); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(document).deleteTag(tag); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - tag = restClient.authenticateUser(adminUserModel) - .withCoreAPI().usingResource(document).addTag(tagValue); - RestTagModel returnedTag = restClient.withCoreAPI().getTag(tag); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedTag.assertThat().field("tag").is(tagValue.toLowerCase()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, - executionType = ExecutionType.REGRESSION, description = "Verify Manager user can delete tag added by another user.") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void managerCanDeleteTagAddedByAnotherUser() throws Exception - { - tag = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingResource(document).addTag(RandomStringUtils.randomAlphanumeric(10)); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(document).deleteTag(tag); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } -} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/tags/nodes/GetNodeTagsTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/tags/nodes/GetNodeTagsTests.java deleted file mode 100644 index b144ab16f..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/tags/nodes/GetNodeTagsTests.java +++ /dev/null @@ -1,319 +0,0 @@ -package org.alfresco.service.search.rest.tags.nodes; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.service.search.rest.tags.TagsDataPrep; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.apache.commons.lang3.RandomStringUtils; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -@Test(groups = {TestGroup.REQUIRE_SOLR}) -public class GetNodeTagsTests extends TagsDataPrep -{ - private String tagValue; - private String tagValue2; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - init(); - tagValue = documentTagValue; - tagValue2 = documentTagValue2; - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, - executionType = ExecutionType.SANITY, description = "Verify site Manager is able to get node tags") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) - public void siteManagerIsAbleToRetrieveNodeTags() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - - returnedCollection = restClient.withCoreAPI().usingResource(document).getNodeTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat() - .entriesListContains("tag", tagValue.toLowerCase()) - .and().entriesListContains("tag", tagValue2.toLowerCase()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, - executionType = ExecutionType.REGRESSION, description = "Verify site Collaborator is able to get node tags") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void siteCollaboratorIsAbleToRetrieveNodeTags() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - - returnedCollection = restClient.withCoreAPI().usingResource(document).getNodeTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat() - .entriesListContains("tag", tagValue.toLowerCase()) - .and().entriesListContains("tag", tagValue2.toLowerCase()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, - executionType = ExecutionType.REGRESSION, description = "Verify site Contributor is able to get node tags") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void siteContributorIsAbleToRetrieveNodeTags() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - - returnedCollection = restClient.withCoreAPI().usingResource(document).getNodeTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat() - .entriesListContains("tag", tagValue.toLowerCase()) - .and().entriesListContains("tag", tagValue2.toLowerCase()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, - executionType = ExecutionType.REGRESSION, description = "Verify site Consumer is able to get node tags") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void siteConsumerIsAbleToRetrieveNodeTags() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - - returnedCollection = restClient.withCoreAPI().usingResource(document).getNodeTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat() - .entriesListContains("tag", tagValue.toLowerCase()) - .and().entriesListContains("tag", tagValue2.toLowerCase()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, - executionType = ExecutionType.REGRESSION, description = "Verify admin is able to get node tags") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void adminIsAbleToRetrieveNodeTags() throws Exception - { - restClient.authenticateUser(adminUserModel); - returnedCollection = restClient.withCoreAPI().usingResource(document).getNodeTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat() - .entriesListContains("tag", tagValue.toLowerCase()) - .and().entriesListContains("tag", tagValue2.toLowerCase()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, - executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to get node tags") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) -// @Bug(id = "MNT-16904", description = "fails only on environment with tenants") - public void unauthenticatedUserIsNotAbleToRetrieveNodeTags() throws Exception - { - restClient.authenticateUser(new UserModel("random user", "random password")); - restClient.withCoreAPI().usingResource(document).getNodeTags(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that using invalid value for skipCount parameter returns status code 400") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION}) - public void invalidSkipCountTest() throws Exception - { - restClient.withParams("skipCount=abc").withCoreAPI().usingResource(document).getNodeTags(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "abc")); - - restClient.withParams("skipCount=-1").withCoreAPI().usingResource(document).getNodeTags(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that using invalid value for maxItems parameter returns status code 400") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION}) - public void invalidMaxItemsTest() throws Exception - { - restClient.withParams("maxItems=abc").withCoreAPI().usingResource(document).getNodeTags(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "abc")); - - restClient.withParams("maxItems=-1").withCoreAPI().usingResource(document).getNodeTags(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that user without permissions returns status code 403") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION}) - public void userWithoutPermissionsTest() throws Exception - { - SiteModel moderatedSite = dataSite.usingUser(adminUserModel).createModeratedRandomSite(); - FileModel moderatedDocument = dataContent.usingSite(moderatedSite).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(dataUser.createRandomTestUser()).withCoreAPI().usingResource(moderatedDocument).getNodeTags(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that if node does not exist returns status code 403") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION}) - public void nonexistentNodeTest() throws Exception - { - FileModel badDocument = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - String nodeRef = RandomStringUtils.randomAlphanumeric(10); - badDocument.setNodeRef(nodeRef); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(badDocument).getNodeTags(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, nodeRef)); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that if node id is empty returns status code 403") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION}) - public void emptyNodeIdTest() throws Exception - { - FileModel badDocument = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - badDocument.setNodeRef(""); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(badDocument).getNodeTags(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify folder tags") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION}) - public void folderTagsTest() throws Exception - { - FolderModel folder = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); - - restClient.withCoreAPI().usingResource(folder).addTag(tagValue); - restClient.withCoreAPI().usingResource(folder).addTag(tagValue2); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(folder).getNodeTags() - .assertThat() - .entriesListContains("tag", tagValue.toLowerCase()) - .and().entriesListContains("tag", tagValue2.toLowerCase()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify site Manager is able to get node tags using properties parameter") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void siteManagerIsAbleToRetrieveNodeTagsWithPropertiesParameter() throws Exception - { - returnedCollection = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withParams("properties=tag").withCoreAPI().usingResource(document).getNodeTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat().entriesListContains("tag", tagValue.toLowerCase()) - .and().entriesListContains("tag", tagValue2.toLowerCase()) - .and().entriesListDoesNotContain("id"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that Collaborator user is not able to get node tags using site id instead of node id") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void collaboratorGetNodeTagsUseSiteIdInsteadOfNodeId() throws Exception - { - FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - - file.setNodeRef(siteModel.getId()); - returnedCollection = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(file).getNodeTags(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, file.getNodeRef())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "With admin get node tags and use skipCount parameter. Check pagination and maxItems") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void useSkipCountCheckPaginationAndMaxItems() throws Exception - { - returnedCollection = restClient.authenticateUser(adminUserModel) - .withParams("skipCount=1").withCoreAPI().usingResource(document).getNodeTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.getPagination().assertThat().field("maxItems").is(100) - .and().field("hasMoreItems").is("false") - .and().field("count").isGreaterThan(1); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "With admin get node tags and use maxItems parameter. Check pagination") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void useMaxItemsParameterCheckPagination() throws Exception - { - returnedCollection = restClient.authenticateUser(adminUserModel) - .withParams("maxItems=1").withCoreAPI().usingResource(document).getNodeTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.getPagination().assertThat().field("maxItems").is(1) - .and().field("hasMoreItems").is("true") - .and().field("count").is("1") - .and().field("skipCount").is("0"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Using manager user get only one tag.") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void usingManagerGetOnlyOneTag() throws Exception - { - FileModel file = dataContent.usingAdmin().usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addTag(tagValue); - - returnedCollection = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingResource(file).getNodeTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.getPagination().assertThat().field("maxItems").is(100) - .and().field("hasMoreItems").is("false") - .and().field("totalItems").is("1") - .and().field("count").is("1") - .and().field("skipCount").is("0"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Using admin get last 2 tags and skip first 2 tags") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void adminUserGetLast2TagsAndSkipFirst2Tags() throws Exception - { - String firstTag = "1st tag"; - String secondTag = "2nd tag"; - String thirdTag = "3rd tag"; - String fourthTag = "4th tag"; - FileModel file = dataContent.usingAdmin().usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - - restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addTag(firstTag); - restClient.withCoreAPI().usingResource(file).addTag(secondTag); - restClient.withCoreAPI().usingResource(file).addTag(thirdTag); - restClient.withCoreAPI().usingResource(file).addTag(fourthTag); - - returnedCollection = restClient.withParams("skipCount=2").withCoreAPI().usingResource(file).getNodeTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - returnedCollection.assertThat().entriesListContains("tag", thirdTag.toLowerCase()) - .and().entriesListContains("tag", fourthTag.toLowerCase()); - returnedCollection.getPagination().assertThat().field("maxItems").is(100) - .and().field("hasMoreItems").is("false") - .and().field("totalItems").is("4") - .and().field("count").is("2") - .and().field("skipCount").is("2"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "With admin get node tags and use maxItems=0.") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void getTagsWithZeroMaxItems() throws Exception - { - returnedCollection = restClient.authenticateUser(adminUserModel) - .withParams("maxItems=0").withCoreAPI().usingResource(document).getNodeTags(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, - description = "Verify that using high skipCount parameter returns status code 200.") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION }) - public void getTagsWithHighSkipCount() throws Exception - { - returnedCollection = restClient.authenticateUser(adminUserModel).withParams("skipCount=10000") - .withCoreAPI().usingResource(document).getNodeTags(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.getPagination().assertThat().field("maxItems").is(100) - .and().field("hasMoreItems").is("false") - .and().field("count").is("0") - .and().field("skipCount").is("10000"); - returnedCollection.assertThat().entriesListCountIs(0); - } -} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/trashcan/GetDeletedNodesTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/trashcan/GetDeletedNodesTests.java deleted file mode 100644 index 02ea3f126..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/trashcan/GetDeletedNodesTests.java +++ /dev/null @@ -1,245 +0,0 @@ -/* - * Copyright (C) 2005-2017 Alfresco Software Limited. - * This file is part of Alfresco - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ - -package org.alfresco.service.search.rest.trashcan; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestNodeModel; -import org.alfresco.rest.model.RestNodeModelsCollection; -import org.alfresco.rest.model.RestRenditionInfoModel; -import org.alfresco.rest.model.RestRenditionInfoModelCollection; -import org.alfresco.utility.Utility; -import org.alfresco.utility.exception.DataPreparationException; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Tests for /api-explorer/#!/trashcan/listDeletedNodes - * /api-explorer/#!/trashcan/deleteDeletedNode - * /api-explorer/#!/trashcan/getDeletedNode - * /api-explorer/#!/trashcan/restoreDeletedNode - * - * @author jcule - * - */ -public class GetDeletedNodesTests extends RestTest -{ - private UserModel adminUserModel; - private SiteModel deleteNodesSiteModel; - private FolderModel deleteNodesFolder1, deleteNodesFolder2, deleteNodesFolder3, deleteNodesFolder4, deleteNodesFolder5, getDeleteNodesFolder6; - private FileModel file, file1, file2, file3, file4; - - private RestNodeModelsCollection deletedNodes, deletedNodesMaxItem; - private RestNodeModel node; - - private RestRenditionInfoModelCollection nodeRenditionInfoCollection; - private RestRenditionInfoModel nodeRenditionInfo; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws DataPreparationException - { - adminUserModel = dataUser.getAdminUser(); - restClient.authenticateUser(adminUserModel); - deleteNodesSiteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - } - - @AfterClass(alwaysRun = true) - public void cleanup() throws Exception - { - dataSite.usingAdmin().deleteSite(deleteNodesSiteModel); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.REGRESSION }) - public void testDeletedNodesBiggerThanMaxCount() throws Exception - { - // get the number of item in the trashcan - deletedNodes = restClient.withCoreAPI().usingTrashcan().findDeletedNodes(); - int count = deletedNodes.getPagination().getCount(); - int totalItems = deletedNodes.getPagination().getTotalItems(); - - // create folders - deleteNodesFolder1 = dataContent.usingUser(adminUserModel).usingSite(deleteNodesSiteModel).createFolder(); - deleteNodesFolder2 = dataContent.usingUser(adminUserModel).usingSite(deleteNodesSiteModel).createFolder(); - deleteNodesFolder3 = dataContent.usingUser(adminUserModel).usingSite(deleteNodesSiteModel).createFolder(); - - // delete folders - dataContent.usingUser(adminUserModel).usingResource(deleteNodesFolder1).deleteContent(); - dataContent.usingUser(adminUserModel).usingResource(deleteNodesFolder2).deleteContent(); - dataContent.usingUser(adminUserModel).usingResource(deleteNodesFolder3).deleteContent(); - - int maxItems = count + 1; - deletedNodesMaxItem = restClient.withCoreAPI().usingTrashcan().usingParams(String.format("maxItems=%s", maxItems)).findDeletedNodes(); - - String countMaxItem = Integer.toString(maxItems); - String totalItemsMaxItem = Integer.toString(totalItems + 3); - String hasMoreItemsMaxItem = Boolean.toString(deletedNodesMaxItem.getPagination().isHasMoreItems()); - String skipCount = Integer.toString(deletedNodesMaxItem.getPagination().getSkipCount()); - - restClient.assertStatusCodeIs(HttpStatus.OK); - deletedNodesMaxItem.getPagination().assertThat().field("totalItems").is(totalItemsMaxItem).and().field("count").is(countMaxItem); - deletedNodesMaxItem.getPagination().assertThat().field("hasMoreItems").is(hasMoreItemsMaxItem).and().field("skipCount").is(skipCount); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TRASHCAN }, executionType = ExecutionType.SANITY, description = "Sanity tests for GET /deleted-nodes and GET /deleted-nodes/{nodeId}") - @Test(groups = { TestGroup.REST_API, TestGroup.TRASHCAN, TestGroup.SANITY }) - public void testGetDeletedNodesFromTrashcan() throws Exception - { - // Create a folder and a file - deleteNodesFolder4 = dataContent.usingUser(adminUserModel).usingSite(deleteNodesSiteModel).createFolder(); - file = dataContent.usingUser(adminUserModel).usingSite(deleteNodesSiteModel).createContent(DocumentType.TEXT_PLAIN); - - // Delete file and folder - dataContent.usingUser(adminUserModel).usingResource(deleteNodesFolder4).deleteContent(); - dataContent.usingUser(adminUserModel).usingResource(file).deleteContent(); - - // GET /deleted-nodes: deleted file and folder are in the trashcan list - deletedNodes = restClient.withCoreAPI().usingTrashcan().findDeletedNodes(); - restClient.assertStatusCodeIs(HttpStatus.OK); - deletedNodes.getEntryByIndex(0).assertThat().field("name").is(file.getName()).and() - .field("id").is(file.getNodeRefWithoutVersion()); - deletedNodes.getEntryByIndex(1).assertThat().field("name").is(deleteNodesFolder4.getName()).and() - .field("id").is(deleteNodesFolder4.getNodeRefWithoutVersion()); - - // GET /deleted-nodes/{nodeId}: check a single deleted object - node = restClient.withCoreAPI().usingTrashcan().findDeletedNode(deleteNodesFolder4); - restClient.assertStatusCodeIs(HttpStatus.OK); - node.assertThat().field("name").is(deleteNodesFolder4.getName()).and() - .field("id").is(deleteNodesFolder4.getNodeRefWithoutVersion()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TRASHCAN }, executionType = ExecutionType.SANITY, description = "Sanity tests for DELETE /deleted-nodes/{nodeId} and POST /deleted-nodes/{nodeId}/restore") - @Test(groups = { TestGroup.REST_API, TestGroup.TRASHCAN, TestGroup.SANITY }) - public void testDeleteAndRestoreNodeFromTrashcan() throws Exception - { - // Create a folder and a file - deleteNodesFolder5 = dataContent.usingUser(adminUserModel).usingSite(deleteNodesSiteModel).createFolder(); - String docLibNodeRef = dataContent.usingUser(adminUserModel).usingSite(deleteNodesSiteModel).getNodeRef(); - file1 = dataContent.usingUser(adminUserModel).usingSite(deleteNodesSiteModel).createContent(DocumentType.TEXT_PLAIN); - - // Delete file and folder - dataContent.usingUser(adminUserModel).usingResource(deleteNodesFolder5).deleteContent(); - dataContent.usingUser(adminUserModel).usingResource(file1).deleteContent(); - - // DELETE /deleted-nodes/{nodeId}: delete an object from trashcan - restClient.withCoreAPI().usingTrashcan().deleteNodeFromTrashcan(file1); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withCoreAPI().usingTrashcan().findDeletedNode(file1); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - - // POST /deleted-nodes/{nodeId}/restore: restore to repository a deleted object - node = restClient.withCoreAPI().usingTrashcan().restoreNodeFromTrashcan(deleteNodesFolder5); - restClient.assertStatusCodeIs(HttpStatus.OK); - node.assertThat().field("id").is(deleteNodesFolder5.getNodeRefWithoutVersion()).and() - .field("parentId").is(docLibNodeRef); - - // Checks that the node was removed from trashcan - restClient.withCoreAPI().usingTrashcan().findDeletedNode(deleteNodesFolder5); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TRASHCAN }, executionType = ExecutionType.SANITY, description = "Sanity tests for GET /deleted-nodes/{nodeId}/content") - @Test(groups = { TestGroup.REST_API, TestGroup.TRASHCAN, TestGroup.SANITY }) - public void testGetDeletedNodesContent() throws Exception - { - // Create file2 based on existing resource - FileModel newFile = FileModel.getFileModelBasedOnTestDataFile("sampleContent.txt"); - newFile.setName("sampleContent.txt"); - file2 = dataContent.usingUser(adminUserModel).usingSite(deleteNodesSiteModel).createContent(newFile); - - // Delete file2 to be moved in trashcan - dataContent.usingUser(adminUserModel).usingResource(file2).deleteContent(); - - // Make GET /deleted-nodes/{nodeId}/content and check file content - restClient.withCoreAPI().usingTrashcan().getDeletedNodeContent(file2); - restClient.assertStatusCodeIs(HttpStatus.OK); - restClient.assertHeaderValueContains("Content-Disposition", file2.getName()); - restClient.onResponse().getResponse().body().asString().contains("Sample text."); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.TRASHCAN, TestGroup.REQUIRE_SOLR }, executionType = ExecutionType.SANITY, - description = "Sanity tests for GET /deleted-nodes/{nodeId}/renditions, GET /deleted-nodes/{nodeId}/renditions/{renditionId}, GET /deleted-nodes/{nodeId}/renditions/{renditionId}/content") - @Test(groups = { TestGroup.REST_API, TestGroup.TRASHCAN, TestGroup.SANITY }) - public void testGetDeletedNodesRenditions() throws Exception - { - // Create file3 based on existing resource - file3 = dataContent.usingUser(adminUserModel).usingSite(deleteNodesSiteModel).createContent(DocumentType.TEXT_PLAIN); - - // Create rendition and delete file3 to be moved in trashcan - restClient.withCoreAPI().usingNode(file3).createNodeRendition("pdf"); - restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); - dataContent.usingUser(adminUserModel).usingResource(file3).deleteContent(); - - // GET /deleted-nodes/{nodeId}/renditions - Utility.sleep(1000, 30000, () -> - { - nodeRenditionInfoCollection = restClient.authenticateUser(adminUserModel).withCoreAPI().usingTrashcan().getDeletedNodeRenditions(file3); - restClient.assertStatusCodeIs(HttpStatus.OK); - - // Check if renditions are retrieved, created or not. Entries are ordered - nodeRenditionInfoCollection.assertThat().entriesListContains("id", "doclib"); - nodeRenditionInfoCollection.getEntryByIndex(5).assertThat().field("id").is("pdf").and() - .field("status").is("CREATED"); - }); - - // GET /deleted-nodes/{nodeId}/renditions/{id} - nodeRenditionInfo = restClient.authenticateUser(adminUserModel).withCoreAPI().usingTrashcan().getDeletedNodeRendition(file3, "pdf"); - restClient.assertStatusCodeIs(HttpStatus.OK); - nodeRenditionInfo.assertThat().field("id").is("pdf").and() - .field("status").is("CREATED"); - - // GET /deleted-nodes/{nodeId}/renditions/{id}/content - restClient.authenticateUser(adminUserModel).withCoreAPI().usingTrashcan().getDeletedNodeRenditionContent(file3, "pdf"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restClient.assertHeaderValueContains("Content-Type","application/pdf;charset=UTF-8"); - Assert.assertTrue(restClient.onResponse().getResponse().body().asInputStream().available() > 0); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.TRASHCAN, TestGroup.REQUIRE_SOLR}, executionType = ExecutionType.SANITY, - description = "Sanity test to verify Range request header on GET /deleted-nodes/{nodeId}/renditions/{renditionId}/content endpoint") - @Test(groups = {TestGroup.REST_API, TestGroup.TRASHCAN, TestGroup.SANITY}) - public void testGetDeletedNodesRenditionsandVerifyRangeRequestheader() throws Exception - { - // Create file4 based on existing resource - file4 = dataContent.usingUser(adminUserModel).usingSite(deleteNodesSiteModel).createContent(DocumentType.TEXT_PLAIN); - - // Create rendition and delete file4 to be moved in trashcan - restClient.withCoreAPI().usingNode(file4).createNodeRendition("pdf"); - restClient.assertStatusCodeIs(HttpStatus.ACCEPTED); - dataContent.usingUser(adminUserModel).usingResource(file4).deleteContent(); - - // GET /deleted-nodes/{nodeId}/renditions/{id}/content and verify range request header - Utility.sleep(1000, 30000, () -> - { - restClient.configureRequestSpec().addHeader("content-range", "bytes=1-10"); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingTrashcan().getDeletedNodeRenditionContent(file4, "pdf"); - restClient.assertStatusCodeIs(HttpStatus.PARTIAL_CONTENT); - restClient.assertHeaderValueContains("Content-Type", "application/pdf;charset=UTF-8"); - restClient.assertHeaderValueContains("content-range", "bytes 1-10"); - restClient.assertHeaderValueContains("content-length", String.valueOf(10)); - }); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/WorkflowNetworkDeploymentsTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/WorkflowNetworkDeploymentsTests.java deleted file mode 100644 index b28409dc0..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/WorkflowNetworkDeploymentsTests.java +++ /dev/null @@ -1,124 +0,0 @@ -package org.alfresco.service.search.rest.workflow; - -import java.util.List; - -import org.alfresco.service.search.rest.NetworkDataPrep; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestDeploymentModel; -import org.alfresco.rest.model.RestDeploymentModelsCollection; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class WorkflowNetworkDeploymentsTests extends NetworkDataPrep -{ - private RestDeploymentModel expectedDeployment, actualDeployment; - private RestDeploymentModelsCollection deployments; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - init(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, - executionType = ExecutionType.REGRESSION, - description = "Verify if network admin user gets a network deployment using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION, TestGroup.NETWORKS}) - public void adminGetsNetworkDeploymentWithSuccess() throws Exception - { - - expectedDeployment = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getDeployments().getOneRandomEntry().onModel(); - actualDeployment = restClient.withWorkflowAPI().usingDeployment(expectedDeployment).getDeployment(); - restClient.assertStatusCodeIs(HttpStatus.OK); - actualDeployment.assertThat().field("deployedAt").isNotEmpty() - .and().field("name").is(expectedDeployment.getName()) - .and().field("id").is(expectedDeployment.getId()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, - executionType = ExecutionType.REGRESSION, - description = "Verify non admin user is forbidden to get a network deployment using REST API (403)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void nonAdminUserIsForbiddenToGetNetworkDeployment() throws Exception - { - expectedDeployment = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getDeployments().getOneRandomEntry().onModel(); - - restClient.authenticateUser(tenantUser).withWorkflowAPI().usingDeployment(expectedDeployment).getDeployment(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Bug(id = "MNT-16996") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, - executionType = ExecutionType.REGRESSION, - description = "Verify get deployments returns an empty list after deleting all network deployments.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION, TestGroup.NETWORKS}) - public void getNetworkDeploymentsAfterDeletingAllNetworkDeployments() throws Exception - { - - List networkDeployments = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getDeployments().getEntries(); - for (RestDeploymentModel networkDeployment: networkDeployments) - { - restClient.withWorkflowAPI().usingDeployment(networkDeployment.onModel()).deleteDeployment(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - deployments = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getDeployments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - deployments.assertThat().entriesListIsEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, - executionType = ExecutionType.REGRESSION, - description = "Verify non admin user is not able to get network deployments using REST API and status code is Forbidden") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION, TestGroup.NETWORKS}) - public void nonAdminUserCanNotGetNetworkDeployments() throws Exception - { - restClient.authenticateUser(tenantUser).withWorkflowAPI().getDeployments(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, - executionType = ExecutionType.REGRESSION, - description = "Verify that network admin user is not able to get a deployment from other network using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION, TestGroup.NETWORKS}) - public void adminDoesNotGetDeploymentFromOtherNetwork() throws Exception - { - expectedDeployment = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getDeployments().getOneRandomEntry().onModel(); - actualDeployment = restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().usingDeployment(expectedDeployment).getDeployment(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, expectedDeployment.getId())) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, - executionType = ExecutionType.REGRESSION, - description = "Verify that network admin user is not able to get a deployment from other network using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION, TestGroup.NETWORKS}) - public void adminDoesNotGetDeploymentsFromOtherNetwork() throws Exception - { - RestDeploymentModel deployment = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getDeployments().getOneRandomEntry().onModel(); - deployments = restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().getDeployments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - deployments.assertThat().entriesListDoesNotContain("id", deployment.getId()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.SANITY, - description = "Verify Tenant Admin user gets network deployments using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.SANITY, TestGroup.NETWORKS}) - public void getNetworkDeploymentsWithAdmin() throws JsonToModelConversionException, Exception - { - deployments = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getDeployments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - deployments.assertThat().entriesListIsNotEmpty(); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/WorkflowNetworkProcessDefinitionsTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/WorkflowNetworkProcessDefinitionsTests.java deleted file mode 100644 index f20cb20dc..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/WorkflowNetworkProcessDefinitionsTests.java +++ /dev/null @@ -1,221 +0,0 @@ -package org.alfresco.service.search.rest.workflow; - -import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.service.search.rest.NetworkDataPrep; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestProcessDefinitionModel; -import org.alfresco.rest.model.RestProcessDefinitionModelsCollection; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class WorkflowNetworkProcessDefinitionsTests extends NetworkDataPrep -{ - private RestProcessDefinitionModel randomProcessDefinition, returnedProcessDefinition; - private RestProcessModel addedProcess; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - init(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, - executionType = ExecutionType.REGRESSION, - description = "Verify network admin is able to get a process definition using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void networkAdminGetProcessDefinition() throws Exception - { - randomProcessDefinition = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry().onModel(); - returnedProcessDefinition = restClient.withWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinition(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedProcessDefinition.assertThat().field("name").is(randomProcessDefinition.getName()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, - executionType = ExecutionType.REGRESSION, - description = "Verify network user is able to get a process definition using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void networkUserGetProcessDefinition() throws Exception - { - randomProcessDefinition = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() - .getAllProcessDefinitions().getOneRandomEntry().onModel(); - returnedProcessDefinition = restClient.authenticateUser(tenantUser).withWorkflowAPI() - .usingProcessDefinitions(randomProcessDefinition).getProcessDefinition(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedProcessDefinition.assertThat().field("name").is(randomProcessDefinition.getName()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, - description = "Verify get process definitions using any network user for network enabled deployments with REST API status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION, TestGroup.NETWORKS}) - public void networkUserGetsProcessDefinitions() throws Exception - { - restClient.authenticateUser(tenantUser) - .withWorkflowAPI() - .getAllProcessDefinitions() - .assertThat().entriesListIsNotEmpty(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, - executionType = ExecutionType.REGRESSION, - description = "Verify Network user is not able to get a process definition from another network") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.NETWORKS, TestGroup.REGRESSION }) - public void getProcessDefinitionFromAnotherNetwork() throws Exception - { - randomProcessDefinition = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() - .getAllProcessDefinitions().getOneRandomEntry().onModel(); - restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI() - .usingProcessDefinitions(randomProcessDefinition).getProcessDefinition(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, randomProcessDefinition.getId())) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, - executionType = ExecutionType.REGRESSION, - description = "Verify Tenant User doesn't get process definitions for another network deployment using REST API") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void networkUserIsNotAbleToGetProcessDefinitionsForAnotherNetwork() throws Exception - { - RestProcessDefinitionModel randomProcessDefinitionTenant1 = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() - .getAllProcessDefinitions().getOneRandomEntry().onModel(); - RestProcessDefinitionModelsCollection processDefinitionsTenant2 = restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI() - .getAllProcessDefinitions(); - restClient.assertStatusCodeIs(HttpStatus.OK); - processDefinitionsTenant2.assertThat().entriesListDoesNotContain("id", randomProcessDefinitionTenant1.getId()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, - executionType = ExecutionType.REGRESSION, - description = "Verify network admin is able to get a process definition image using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION, TestGroup.NETWORKS}) - @Bug(id = "MNT-17243") - public void networkAdminGetProcessDefinitionImage() throws Exception - { - randomProcessDefinition = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry().onModel(); - restClient.withWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionImage() - .assertResponseContainsImage(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESS_DEFINITION }, - executionType = ExecutionType.REGRESSION, - description = "Verify network user is able to get a process definition image using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION, TestGroup.NETWORKS}) - @Bug(id = "MNT-17243") - public void networkUserGetProcessDefinitionImage() throws Exception - { - randomProcessDefinition = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() - .getAllProcessDefinitions().getOneRandomEntry().onModel(); - restClient.authenticateUser(tenantUser).withWorkflowAPI() - .usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionImage() - .assertResponseContainsImage(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, - executionType = ExecutionType.SANITY, description = "Verify Tenant Admin user gets process definitions for network deployments using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY, TestGroup.NETWORKS}) - public void networkAdminGetsProcessDefinitions() throws Exception - { - restClient.authenticateUser(adminTenantUser); - restClient.withWorkflowAPI().getAllProcessDefinitions().assertThat().entriesListIsNotEmpty(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, - executionType = ExecutionType.REGRESSION, - description = "Verify Tenant User doesn't get process definition image for another network deployment using REST API") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void networkUserIsNotAbleToGetProcessDefinitionImageForAnotherNetwork() throws Exception - { - RestProcessDefinitionModel randomProcessDefinition = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() - .getAllProcessDefinitions().getOneRandomEntry().onModel(); - restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI() - .usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionImage(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, randomProcessDefinition.getId())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, - executionType = ExecutionType.REGRESSION, - description = "Verify Tenant User gets a model of the start form type definition for network deployments using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void networkUserGetsStartFormModel() throws Exception - { - randomProcessDefinition = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() - .getAllProcessDefinitions().getOneRandomEntry().onModel(); - restClient.authenticateUser(tenantUser).withWorkflowAPI() - .usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionStartFormModel() - .assertThat().entriesListIsNotEmpty(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, - executionType = ExecutionType.REGRESSION, - description = "Verify Tenant User doesn't get a model of the start form type definition for another network deployment using REST API") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void networkUserIsNotAbleToGetStartFormModelForAnotherNetwork() throws Exception - { - RestProcessDefinitionModel randomProcessDefinition = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() - .getAllProcessDefinitions().getOneRandomEntry().onModel(); - restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI() - .usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionStartFormModel(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, randomProcessDefinition.getId())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, - executionType = ExecutionType.SANITY, - description = "Verify Tenant Admin gets a model of the start form type definition for network deployments using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY, TestGroup.NETWORKS }) - public void networkAdminGetsStartFormModel() throws Exception - { - restClient.authenticateUser(adminTenantUser); - randomProcessDefinition = restClient.withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry().onModel(); - restClient.withWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionStartFormModel().assertThat().entriesListIsNotEmpty(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify network user can start new process with processDefinitionKey from same network using REST API and status code is 201") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS}) - public void networkUserCanStartNewProcessWithProcessDefinitionFromSameNetwork() throws JsonToModelConversionException, Exception - { - RestProcessDefinitionModel firstProcessDefTenant1 = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getAllProcessDefinitions().getEntries().get(0).onModel(); - - String processDefinitionKey = firstProcessDefTenant1.getKey(); - addedProcess = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess(processDefinitionKey, secondTenantUser, false, Priority.Normal); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - addedProcess.assertThat().field("processDefinitionId").is(firstProcessDefTenant1.getId()) - .and().field("startUserId").is(tenantUser.getEmailAddress().substring(0,2)+tenantUser.getEmailAddress().substring(2).toLowerCase()) - .and().field("processDefinitionKey").is(processDefinitionKey); - } - - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify network user cannot start new process with processDefinitionKey from another network using REST API and status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS}) - public void networkUserCannotStartNewProcessWithProcessDefinitionFromAnotherNetwork() throws JsonToModelConversionException, Exception - { - RestProcessDefinitionModel firstProcessDefTenant1 = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getAllProcessDefinitions().getEntries().get(0).onModel(); - - String processDefinitionKey = firstProcessDefTenant1.getId().substring(0,firstProcessDefTenant1.getId().indexOf(":")); - addedProcess = restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().addProcess(processDefinitionKey, differentNetworkTenantUser, false, Priority.Normal); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(String.format(RestErrorModel.NO_WORKFLOW_DEFINITION_FOUND, processDefinitionKey)) - .containsSummary(String.format(RestErrorModel.NO_WORKFLOW_DEFINITION_FOUND, processDefinitionKey)) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/WorkflowNetworkProcessesTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/WorkflowNetworkProcessesTests.java deleted file mode 100644 index 866da43e5..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/WorkflowNetworkProcessesTests.java +++ /dev/null @@ -1,540 +0,0 @@ -package org.alfresco.service.search.rest.workflow; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestItemModel; -import org.alfresco.rest.model.RestItemModelsCollection; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.model.RestProcessModelsCollection; -import org.alfresco.rest.model.RestProcessVariableCollection; -import org.alfresco.rest.model.RestProcessVariableModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.report.Bug; -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; -import org.alfresco.service.search.rest.NetworkDataPrep; - -public class WorkflowNetworkProcessesTests extends NetworkDataPrep -{ - private RestProcessModel processModel; - private RestProcessModelsCollection processes; - private RestItemModel processItem; - private RestItemModelsCollection processItems; - private RestProcessVariableModel variableModel, processVariable; - private RestProcessVariableCollection variables; - protected SiteModel siteModel; - protected FileModel document, document2; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - init(); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - document2 = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW, - TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Verify network user is able to start new process using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY, TestGroup.NETWORKS }) - public void networkUserStartsNewProcess() throws JsonToModelConversionException, Exception - { - processModel = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - processModel.assertThat().field("id").is(processModel.getId()) - .and().field("startUserId").is(processModel.getStartUserId()); - - processes = restClient.withWorkflowAPI().getProcesses(); - restClient.assertStatusCodeIs(HttpStatus.OK); - processes.assertThat().entriesListContains("id", processModel.getId()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES}, executionType = ExecutionType.REGRESSION, - description = "Verify that non network user cannot get process from a network") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - @Bug(id = "REPO-2092") - public void nonNetworkUserCannotAccessNetworkProcess() throws Exception - { - RestProcessModel networkProcess1 = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().addProcess("activitiReview", tenantUser, false, CMISUtil.Priority.High); - - restClient.authenticateUser(adminUserModel).withWorkflowAPI().usingProcess(networkProcess1).getProcess(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError().containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify that tenant user can get process from the same network") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void tenantUserCanGetProcessFromTheSameNetwork() throws Exception - { - RestProcessModel networkProcess1 = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().addProcess("activitiReview", tenantUser, false, CMISUtil.Priority.High); - - restClient.authenticateUser(tenantUser).withWorkflowAPI().usingProcess(networkProcess1).getProcess(); - restClient.assertStatusCodeIs(HttpStatus.OK); - networkProcess1.assertThat().field("id").is(networkProcess1.getId()) - .and().field("startUserId").is(networkProcess1.getStartUserId());; - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES}, executionType = ExecutionType.REGRESSION, - description = "Verify that tenant user cannot get process from another network") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - @Bug(id = "REPO-2092") - public void tenantUserCannotGetProcessFromAnotherNetwork() throws Exception - { - RestProcessModel networkProcess1 = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().addProcess("activitiReview", tenantUser, false, CMISUtil.Priority.High); - - restClient.authenticateUser(differentNetworkTenantUser).withWorkflowAPI().usingProcess(networkProcess1).getProcess(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError().containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin user can get process started by a network user") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void adminUserCanGetProcessFromANetwork() throws Exception - { - RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiReview", adminTenantUser, false, CMISUtil.Priority.High); - - restClient.authenticateUser(dataUser.getAdminUser()).withWorkflowAPI().usingProcess(networkProcess1).getProcess(); - restClient.assertStatusCodeIs(HttpStatus.OK); - networkProcess1.assertThat().field("processDefinitionId").contains(String.format("@%s%s", tenantUser.getDomain().toLowerCase(), "@activitiReview:1")) - .and().field("startUserId").is(tenantUser.getEmailAddress().substring(0, 2)+tenantUser.getEmailAddress().substring(2).toLowerCase()) - .and().field("startActivityId").is("start") - .and().field("startedAt").isNotEmpty() - .and().field("id").is(networkProcess1.getId()) - .and().field("completed").is(false) - .and().field("processDefinitionKey").is("activitiReview"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Add multiple process items using by admin in other network.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void addMultipleProcessItemsByAdminInOtherNetwork() throws Exception - { - processModel = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUser, false, Priority.Normal); - restClient.authenticateUser(secondAdminTenantUser); - - processItems = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItems(document, document2); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError() - .containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Add multiple process items using by the admin in same network.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void addMultipleProcessItemsByAdminSameNetwork() throws Exception - { - processModel = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); - - siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); - document = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - document2 = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - processItems = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().usingProcess(processModel).addProcessItems(document, document2); - - restClient.assertStatusCodeIs(HttpStatus.CREATED); - processItems.getEntries().get(0).onModel().assertThat() - .field("createdAt").isNotEmpty().and() - .field("size").is("19").and() - .field("createdBy").is(adminTenantUser.getUsername().toLowerCase()).and() - .field("modifiedAt").isNotEmpty().and() - .field("name").is(document.getName()).and() - .field("modifiedBy").is(adminTenantUser.getUsername().toLowerCase()).and() - .field("id").isNotEmpty().and() - .field("mimeType").is(document.getFileType().mimeType); - processItems.getEntries().get(1).onModel().assertThat() - .field("createdAt").isNotEmpty().and() - .field("size").is("19").and() - .field("createdBy").is(adminTenantUser.getUsername().toLowerCase()).and() - .field("modifiedAt").isNotEmpty().and() - .field("name").is(document2.getName()).and() - .field("modifiedBy").is(adminTenantUser.getUsername().toLowerCase()).and() - .field("id").isNotEmpty().and() - .field("mimeType").is(document2.getFileType().mimeType); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Add process item using by admin in other network.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void addProcessItemByAdminInOtherNetwork() throws Exception - { - processModel = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUser, false, Priority.Normal); - restClient.authenticateUser(secondAdminTenantUser); - processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Add process item using by the admin in same network.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void addProcessItemByAdminSameNetwork() throws Exception - { - processModel = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); - - siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); - document = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - processItem = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().usingProcess(processModel).addProcessItem(document); - - restClient.assertStatusCodeIs(HttpStatus.CREATED); - processItem.assertThat().field("createdAt").isNotEmpty().and().field("size").is("19").and().field("createdBy").is(adminTenantUser.getUsername().toLowerCase()).and() - .field("modifiedAt").isNotEmpty().and().field("name").is(document.getName()).and().field("modifiedBy").is(adminTenantUser.getUsername().toLowerCase()).and() - .field("id").isNotEmpty().and().field("mimeType").is(document.getFileType().mimeType); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Delete process item using by admin in other network.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void deleteProcessItemByAdminInOtherNetwork() throws Exception - { - processModel = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, CMISUtil.Priority.Normal); - processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().usingProcess(processModel) - .deleteProcessItem(processItem); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError() - .containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .containsErrorKey(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT) - .stackTraceIs(RestErrorModel.STACKTRACE); - - //restore document - document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Delete process item using by the admin in same network.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void deleteProcessItemByAdminSameNetwork() throws Exception - { - processModel = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, CMISUtil.Priority.Normal); - - processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(adminTenantUser).withWorkflowAPI().usingProcess(processModel) - .deleteProcessItem(processItem); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() - .assertThat().entriesListDoesNotContain("name", processItem.getName()); - - //restore document - document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Get process items using admin from different network") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void getProcessItemsReturnsOnlyItemsInsideNetwork() throws Exception - { - processModel = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, CMISUtil.Priority.Normal); - - siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); - document = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestProcessModel processModel2 = restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondAdminTenantUser, false, CMISUtil.Priority.Normal); - - SiteModel siteModel2 = dataSite.usingUser(secondAdminTenantUser).createPublicRandomSite(); - document2 = dataContent.usingUser(secondAdminTenantUser).usingSite(siteModel2).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().usingProcess(processModel2).addProcessItem(document2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - processItems = restClient.withWorkflowAPI().usingProcess(processModel2).getProcessItems(); - restClient.assertStatusCodeIs(HttpStatus.OK); - processItems.assertThat().entriesListDoesNotContain("name", document.getName()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Get process items using admin from different network") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void getProcessItemsUsingAdminUserFromDifferentNetwork() throws Exception - { - processModel = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, CMISUtil.Priority.Normal); - - siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); - document = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().usingProcess(processModel).getProcessItems(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Add process variable using by admin in other network.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void addProcessVariableByAdminInOtherNetwork() throws Exception - { - processModel = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); - - restClient.authenticateUser(secondAdminTenantUser); - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError() - .containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Add process variable using admin user from same network") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY, TestGroup.NETWORKS }) - public void addProcessVariableByAdmin() throws Exception - { - restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - - processVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - processVariable.assertThat().field("name").is(variableModel.getName()) - .and().field("type").is(variableModel.getType()) - .and().field("value").is(variableModel.getValue()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin from different network is not able to delete network process variables") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void deleteProcessVariablesWithAdminFromDifferentNetwork() throws Exception - { - RestProcessModel processModel = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() - .addProcess("activitiAdhoc", tenantUser, false, Priority.Normal); - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser).withWorkflowAPI() - .getProcesses().getProcessModelByProcessDefId(processModel.getId()); - restClient.withWorkflowAPI().usingProcess(networkProcess1).addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(adminUserModel).withWorkflowAPI().usingProcess(networkProcess1) - .deleteProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); - restClient.assertLastError().containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .containsErrorKey(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT) - .stackTraceIs(RestErrorModel.STACKTRACE); - - restClient.authenticateUser(tenantUser).withWorkflowAPI().usingProcess(networkProcess1).getProcessVariables().assertThat() - .entriesListContains("name", variableModel.getName()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin from the same network is able to delete network process variables") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void deleteProcessVariablesWithAdminFromSameNetwork() throws Exception - { - RestProcessModel processModel = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() - .addProcess("activitiAdhoc", tenantUser, false, Priority.Normal); - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser).withWorkflowAPI() - .getProcesses().getProcessModelByProcessDefId(processModel.getId()); - restClient.withWorkflowAPI().usingProcess(networkProcess1).addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(adminTenantUser).withWorkflowAPI().usingProcess(networkProcess1) - .deleteProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withWorkflowAPI().usingProcess(networkProcess1).getProcessVariables() - .assertThat() - .entriesListDoesNotContain("name", variableModel.getName()); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin from different network is not able to retrieve network process variables") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void getProcessVariablesWithAdminFromDifferentNetwork() throws Exception - { - RestProcessModel networkProcess1 = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() - .addProcess("activitiReview", tenantUser, false, CMISUtil.Priority.High); - - variables = restClient.authenticateUser(adminUserModel).withWorkflowAPI().usingProcess(networkProcess1).getProcessVariables(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT); - } - - @TestRail(section = {TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin from the same network is able to retrieve network process variables") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void getProcessVariablesWithAdminFromSameNetwork() throws Exception - { - RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser).withWorkflowAPI() - .addProcess("activitiReview", tenantUser, false, CMISUtil.Priority.High); - - variables = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().usingProcess(networkProcess1).getProcessVariables(); - restClient.assertStatusCodeIs(HttpStatus.OK); - variables.assertThat().entriesListIsNotEmpty(); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify admin gets all processes from same network") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void getProcessFromSameNetworkUsingAdmin() throws Exception - { - RestProcessModel process = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); - - RestProcessModelsCollection tenantProcesses = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getProcesses(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - tenantProcesses.assertThat().entriesListContains("id", process.getId()); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Get process items using admin from same network") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY, TestGroup.NETWORKS }) - public void getProcessItemsUsingAdminUserFromSameNetwork() throws Exception - { - processModel = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); - - siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); - document = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); - - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - processItems = restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems(); - restClient.assertStatusCodeIs(HttpStatus.OK); - processItems.assertThat().entriesListContains("name", document.getName()); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Add multiple process variables using admin user from same network") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY, TestGroup.NETWORKS }) - public void addMultipleProcessVariablesByAdminSameNetwork() throws Exception - { - restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processVariable = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - - variables = restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariables(variableModel, processVariable); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - variables.assertThat().entriesListContains("name", variableModel.getName()) - .assertThat().entriesListContains("name", processVariable.getName()); - - variables.getEntries().get(0).onModel().assertThat() - .field("name").is(variableModel.getName()).and() - .field("value").is(variableModel.getValue()).and() - .field("type").is(variableModel.getType()); - variables.getEntries().get(1).onModel().assertThat() - .field("name").is(processVariable.getName()).and() - .field("value").is(processVariable.getValue()).and() - .field("type").is(processVariable.getType()); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Add process variables using admin user from same network") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY, TestGroup.NETWORKS }) - public void addProcessVariableByAdminSameNetwork() throws Exception - { - restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - - processVariable = restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - processVariable.assertThat().field("name").is(variableModel.getName()) - .and().field("type").is(variableModel.getType()) - .and().field("value").is(variableModel.getValue()); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify any user cannot get processes from same network") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void getProcessFromSameNetworkUsingAnyUser() throws Exception - { - restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); - - restClient.authenticateUser(tenantUser).withWorkflowAPI().getProcesses(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify getProcessTasks using admin from different network with REST API and status code is FORBIDDEN (403)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void getProcessTasksWithAdminFromDifferentNetwork() throws Exception - { - siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); - dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - RestProcessModel processModel = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, CMISUtil.Priority.Normal); - - restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI() - .usingProcess(processModel).getProcessTasks().assertThat().entriesListIsEmpty(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify getProcessTasks using admin from same network with REST API and status code is OK") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void getProcessTasksWithAdminFromSameNetwork() throws Exception - { - siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); - dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - - RestProcessModel processModel = restClient.authenticateUser(secondTenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, CMISUtil.Priority.Normal); - - restClient.authenticateUser(adminTenantUser).withWorkflowAPI() - .usingProcess(processModel).getProcessTasks().assertThat().entriesListIsNotEmpty(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW,TestGroup.PROCESSES}, executionType = ExecutionType.REGRESSION, - description = "Add multiple process variables using by Admin in other network.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void addMultipleProcessVariablesByAdminInOtherNetwork() throws Exception - { - - siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); - dataWorkflow.usingUser(tenantUser).usingSite(siteModel).usingResource(document) - .createNewTaskAndAssignTo(secondTenantUser); - - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processVariable = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); - restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().usingProcess(processModel) - .addProcessVariables(variableModel, processVariable); - - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError() - .containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .containsErrorKey(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES}, executionType = ExecutionType.REGRESSION, - description = "Add process variables using by Admin in other network.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void addProcessVariablesByAdminInOtherNetwork() throws Exception - { - siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); - dataWorkflow.usingUser(tenantUser).usingSite(siteModel).usingResource(document) - .createNewTaskAndAssignTo(secondTenantUser); - - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); - processVariable = restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().usingProcess(processModel) - .addProcessVariable(variableModel); - - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError() - .containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .containsErrorKey(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/WorkflowNetworkTasksTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/WorkflowNetworkTasksTests.java deleted file mode 100644 index 19be57be2..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/WorkflowNetworkTasksTests.java +++ /dev/null @@ -1,578 +0,0 @@ -package org.alfresco.service.search.rest.workflow; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.service.search.rest.NetworkDataPrep; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestFormModelsCollection; -import org.alfresco.rest.model.RestItemModel; -import org.alfresco.rest.model.RestItemModelsCollection; -import org.alfresco.rest.model.RestProcessDefinitionModel; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.model.RestTaskModel; -import org.alfresco.rest.model.RestTaskModelsCollection; -import org.alfresco.rest.model.RestVariableModel; -import org.alfresco.rest.model.RestVariableModelsCollection; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TaskModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class WorkflowNetworkTasksTests extends NetworkDataPrep -{ - private TaskModel taskModel; - private RestFormModelsCollection returnedCollection; - private RestTaskModel restTaskModel; - private RestTaskModelsCollection taskModels; - private RestVariableModel variableModel, variableModel1; - private RestVariableModelsCollection restVariableCollection; - private RestProcessModel restProcessModel; - private RestItemModelsCollection itemModels; - private RestItemModel restTaskItem; - protected SiteModel siteModel; - protected FileModel document, document2; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - init(); - siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - document2 = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, - executionType = ExecutionType.REGRESSION, description = "Verify network admin user gets all task form models inside his network with Rest API and response is successful (200)") - public void networkAdminGetsTaskFormModels() throws Exception - { - RestProcessModel networkProcess = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() - .addProcess("activitiReview", tenantUser, false, CMISUtil.Priority.High); - RestTaskModel networkTask = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() - .usingProcess(networkProcess).getProcessTasks().getOneRandomEntry().onModel(); - - restClient.authenticateUser(adminUserModel).withWorkflowAPI().usingTask(networkTask).getTaskFormModel(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - - returnedCollection = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().usingTask(networkTask).getTaskFormModel(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat().entriesListIsNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Add multiple task item using by admin in other network.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void addMultipleTaskItemByAdminInOtherNetwork() throws Exception - { - - SiteModel siteModel1 = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); - document = dataContent.usingUser(adminTenantUser).usingSite(siteModel1).createContent(DocumentType.XML); - document2 = dataContent.usingSite(siteModel1).createContent(DocumentType.XML); - - RestProcessModel addedProcess = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); - RestTaskModel addedTask = restClient.withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess); - restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().usingTask(addedTask).addTaskItems(document, document2); - - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .stackTraceIs(RestErrorModel.STACKTRACE);; - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Add task item using by admin in other network.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void addTaskItemByAdminInOtherNetwork() throws Exception - { - document = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(DocumentType.XML); - RestProcessModel addedProcess = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); - RestTaskModel addedTask = restClient.withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess); - restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().usingTask(addedTask).addTaskItem(document); - - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Bug(id = "REPO-1980") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify tenant admin can update only task from its network and response is 200") - public void adminTenantCanUpdateOnlyTaskInItsNetwork() throws Exception - { - FileModel fileModel1 = dataContent.usingUser(tenantUser).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - RestProcessDefinitionModel def1 = restClient.authenticateUser(tenantUser).withWorkflowAPI().getAllProcessDefinitions().getEntries().get(0).onModel(); - TaskModel taskModel1 = dataWorkflow.usingUser(tenantUser).usingSite(siteModel).usingResource(fileModel1) - .createTaskWithProcessDefAndAssignTo(def1.getId(), secondTenantUser); - - SiteModel siteModel2 = dataSite.usingUser(differentNetworkTenantUser).createPublicRandomSite(); - FileModel fileModel2 = dataContent.usingUser(differentNetworkTenantUser).usingSite(siteModel2).createContent(DocumentType.TEXT_PLAIN); - RestProcessDefinitionModel def2 = restClient.authenticateUser(differentNetworkTenantUser).withWorkflowAPI().getAllProcessDefinitions().getEntries().get(0).onModel(); - TaskModel taskModel2 = dataWorkflow.usingUser(differentNetworkTenantUser).usingSite(siteModel2).usingResource(fileModel2) - .createTaskWithProcessDefAndAssignTo(def2.getId(), secondAdminTenantUser); - - restTaskModel = restClient.authenticateUser(secondAdminTenantUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel2).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel2.getId()) - .and().field("state").is("completed"); - - restTaskModel = restClient.authenticateUser(secondAdminTenantUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel1).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin from the same network is able to add multiple task variables") - public void addMultipleTaskVariablesByTenantAdmin() throws Exception - { - RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser).withWorkflowAPI() - .addProcess("activitiReview", tenantUser, false, CMISUtil.Priority.High); - RestTaskModel task = restClient.authenticateUser(adminTenantUser) - .withWorkflowAPI().usingProcess(networkProcess1).getProcessTasks().getOneRandomEntry(); - restClient.authenticateUser(adminTenantUser); - - variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - variableModel1 = RestVariableModel.getRandomTaskVariableModel("global", "d:text"); - - restVariableCollection = restClient.withWorkflowAPI().usingTask(task.onModel()) - .addTaskVariables(variableModel, variableModel1); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restVariableCollection.getEntries().get(0).onModel().assertThat() - .field("scope").is(variableModel.getScope()) - .and().field("name").is(variableModel.getName()) - .and().field("value").is(variableModel.getValue()) - .and().field("type").is(variableModel.getType()); - - restVariableCollection.getEntries().get(1).onModel().assertThat() - .field("scope").is(variableModel1.getScope()) - .and().field("name").is(variableModel1.getName()) - .and().field("value").is(variableModel1.getValue()) - .and().field("type").is(variableModel1.getType()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin from the same network is able to add and remove task variables") - public void addAndRemoveTaskVariablesByTenantAdmin() throws Exception - { - RestProcessModel networkProcess1 = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() - .addProcess("activitiReview", adminTenantUser, false, CMISUtil.Priority.High); - RestTaskModel task = restClient.authenticateUser(adminTenantUser) - .withWorkflowAPI().usingProcess(networkProcess1).getProcessTasks().getOneRandomEntry(); - restClient.authenticateUser(adminTenantUser); - RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - variableModel = restClient.withWorkflowAPI() - .usingTask(task.onModel()) - .addTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - variableModel.assertThat() - .field("scope").is(variableModel.getScope()) - .and().field("name").is(variableModel.getName()) - .and().field("value").is(variableModel.getValue()) - .and().field("type").is(variableModel.getType()); - - restClient.withWorkflowAPI().usingTask(task.onModel()).deleteTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withWorkflowAPI().usingTask(task.onModel()).getTaskVariables() - .assertThat().entriesListDoesNotContain("name", variableModel.getName()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin from the other network is not able to remove task variables") - public void addTaskVariablesByTenantAdminOtherNetwork() throws Exception - { - RestProcessModel networkProcess1 = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() - .addProcess("activitiReview", adminTenantUser, false, CMISUtil.Priority.High); - RestTaskModel task = restClient.authenticateUser(adminTenantUser) - .withWorkflowAPI().usingProcess(networkProcess1).getProcessTasks().getOneRandomEntry(); - restClient.authenticateUser(adminTenantUser); - RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - restClient.withWorkflowAPI() - .usingTask(task.onModel()) - .addTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().usingTask(task.onModel()).deleteTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin from another network is not able to add task variables") - public void addTaskVariablesByTenantFromAnotherNetwork() throws Exception - { - RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser).withWorkflowAPI() - .addProcess("activitiReview", tenantUser, false, CMISUtil.Priority.High); - RestTaskModel task = restClient.authenticateUser(adminTenantUser) - .withWorkflowAPI().usingProcess(networkProcess1).getProcessTasks().getOneRandomEntry(); - RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - variableModel = restClient.authenticateUser(secondTenantUser).withWorkflowAPI() - .usingTask(task.onModel()) - .addTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin from another network is not able to add multiple task variables") - public void addMultipleTaskVariablesByTenantFromAnotherNetwork() throws Exception - { - RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser).withWorkflowAPI() - .addProcess("activitiReview", tenantUser, false, CMISUtil.Priority.High); - RestTaskModel task = restClient.authenticateUser(adminTenantUser) - .withWorkflowAPI().usingProcess(networkProcess1).getProcessTasks().getOneRandomEntry(); - restClient.authenticateUser(adminTenantUser); - - variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - variableModel1 = RestVariableModel.getRandomTaskVariableModel("global", "d:text"); - restVariableCollection = restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI() - .usingTask(task.onModel()) - .addTaskVariables(variableModel,variableModel1); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin from another network is not able to update task variables") - public void updateTaskVariablesByTenantFromAnotherNetwork() throws Exception - { - RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser).withWorkflowAPI() - .addProcess("activitiReview", tenantUser, false, CMISUtil.Priority.High); - RestTaskModel task = restClient.authenticateUser(adminTenantUser) - .withWorkflowAPI().usingProcess(networkProcess1).getProcessTasks().getOneRandomEntry(); - restClient.authenticateUser(adminTenantUser); - RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - variableModel = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().usingTask(task.onModel()) - .addTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().usingTask(task.onModel()) - .updateTaskVariable(variableModel); - - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, - executionType = ExecutionType.REGRESSION, description = "Check that for admin network gets tasks only from its network.") - public void adminTenantGetsTasksOnlyFromItsNetwork() throws Exception - { - RestProcessModel processOnTenant1 = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Low); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestProcessModel processOnTenant2 = restClient.authenticateUser(differentNetworkTenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondAdminTenantUser, false, Priority.Normal); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestTaskModelsCollection tenantTasks1 = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - tenantTasks1.assertThat().entriesListIsNotEmpty() - .and().entriesListIsNotEmpty() - .and().entriesListContains("assignee", String.format("sTenant@%s", secondTenantUser.getDomain().toLowerCase())) - .and().entriesListContains("processId", processOnTenant1.getId()) - .and().entriesListDoesNotContain("assignee", String.format("admin@%s", secondAdminTenantUser.getDomain().toLowerCase())) - .and().entriesListDoesNotContain("processId", processOnTenant2.getId()); - - RestTaskModelsCollection tenantTasks2 = restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - tenantTasks2.assertThat().entriesListIsNotEmpty() - .and().entriesListIsNotEmpty() - .and().entriesListContains("assignee", String.format("admin@%s", secondAdminTenantUser.getDomain().toLowerCase())) - .and().entriesListContains("processId", processOnTenant2.getId()) - .and().entriesListDoesNotContain("assignee", String.format("sTenant@%s", secondTenantUser.getDomain().toLowerCase())) - .and().entriesListDoesNotContain("processId", processOnTenant1.getId()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check that for network enabled only that network tasks are returned.") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) - public void networkEnabledTasksReturned() throws Exception - { - restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); - - taskModels = restClient.authenticateUser(secondTenantUser).withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - taskModels.assertThat().entriesListIsNotEmpty().and().entriesListContains("assignee", - String.format("sTenant@%s", secondTenantUser.getDomain().toLowerCase())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify gets task items call with admin from different network") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void getTaskItemsByAdminFromAnotherNetwork() throws Exception - { - - siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); - document = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(DocumentType.XML); - restProcessModel = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); - restTaskModel = restClient.withWorkflowAPI().getTasks().getTaskModelByProcess(restProcessModel); - restClient.withWorkflowAPI().usingTask(restTaskModel).addTaskItem(document); - - restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().usingTask(restTaskModel).getTaskItems(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify gets task items call returns only task items inside network") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) - public void getTaskItemsReturnsOnlyItemsFromThatNetwork() throws Exception - { - SiteModel siteModel1 = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); - FileModel fileModel1 = dataContent.usingUser(adminTenantUser).usingSite(siteModel1).createContent(DocumentType.XML); - - RestProcessModel addedProcess1 = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUser, false, Priority.Normal); - RestTaskModel addedTask1 = restClient.withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess1); - RestItemModel taskItem1 = restClient.withWorkflowAPI().usingTask(addedTask1).addTaskItem(fileModel1); - - SiteModel siteModel2 = dataSite.usingUser(secondAdminTenantUser).createPublicRandomSite(); - FileModel fileModel2 = dataContent.usingUser(secondAdminTenantUser).usingSite(siteModel2).createContent(DocumentType.XML); - - RestProcessModel addedProcess2 = restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().addProcess("activitiAdhoc", differentNetworkTenantUser, false, Priority.Normal); - RestTaskModel addedTask2 = restClient.withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess2); - RestItemModel taskItem2 = restClient.withWorkflowAPI().usingTask(addedTask2).addTaskItem(fileModel2); - - itemModels = restClient.withWorkflowAPI().usingTask(addedTask2).getTaskItems(); - restClient.assertStatusCodeIs(HttpStatus.OK); - itemModels.assertThat() - .entriesListIsNotEmpty().and() - .entriesListContains("id", taskItem2.getId()).and() - .entriesListContains("name", fileModel2.getName()).and() - .entriesListDoesNotContain("id", taskItem1.getId()).and() - .entriesListDoesNotContain("name", fileModel1.getName()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, - executionType = ExecutionType.REGRESSION, description = "Check that for admin network gets task only from its network.") - public void adminTenantGetsTaskOnlyFromItsNetwork() throws Exception - { - RestProcessModel processOnTenant1 = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Low); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestProcessModel processOnTenant2 = restClient.authenticateUser(differentNetworkTenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondAdminTenantUser, false, Priority.Normal); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestTaskModelsCollection tenantTasks2 = restClient.authenticateUser(differentNetworkTenantUser).withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - tenantTasks2.assertThat().entriesListIsNotEmpty() - .and().entriesListCountIs(1) - .and().entriesListContains("assignee", String.format("admin@%s", secondAdminTenantUser.getDomain().toLowerCase())) - .and().entriesListContains("processId", processOnTenant2.getId()) - .and().entriesListDoesNotContain("assignee", String.format("admin@%s", secondTenantUser.getDomain().toLowerCase())) - .and().entriesListDoesNotContain("processId", processOnTenant1.getId()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify that in a network only tasks inside network are returned.") - @Test(groups = {TestGroup.NETWORKS,TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void tasksInsideNetworkReturned() throws Exception - { - - RestProcessModel addedProcess = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, - Priority.Normal); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - taskModel = restClient.withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess); - restTaskModel = restClient.authenticateUser(secondTenantUser).withWorkflowAPI().usingTask(taskModel).getTask(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("assignee").is(String.format("sTenant@%s", secondTenantUser.getDomain().toLowerCase())).and() - .field("processId").is(addedProcess.getId()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, - description = "Verify that user that started the process gets task items") - @Test(groups = { TestGroup.NETWORKS,TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY}) - public void getTaskItemsByAdminInSameNetwork() throws Exception - { - - siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); - document = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(DocumentType.XML); - RestProcessModel addedProcess = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); - RestTaskModel addedTask = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess); - restTaskItem = restClient.withWorkflowAPI().usingTask(addedTask).addTaskItem(document); - - itemModels = restClient.withWorkflowAPI().usingTask(addedTask).getTaskItems(); - restClient.assertStatusCodeIs(HttpStatus.OK); - itemModels.assertThat() - .entriesListIsNotEmpty().and() - .entriesListContains("id", restTaskItem.getId()).and() - .entriesListContains("name", document.getName()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin from the same network is able to retrieve network task variables") - public void getTaskVariablesByTenantAdmin() throws Exception - { - RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser).withWorkflowAPI() - .addProcess("activitiReview", tenantUser, false, CMISUtil.Priority.High); - RestTaskModel task = restClient.authenticateUser(adminTenantUser) - .withWorkflowAPI().usingProcess(networkProcess1).getProcessTasks().getOneRandomEntry(); - - restVariableCollection = restClient.withWorkflowAPI().usingTask(task.onModel()).getTaskVariables(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restVariableCollection.assertThat().entriesListIsNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin from another network is not able to retrieve network task variables") - public void getTaskVariablesByTenantFromAnotherNetwork() throws Exception - { - RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser).withWorkflowAPI() - .addProcess("activitiReview", tenantUser, false, CMISUtil.Priority.High); - RestTaskModel task = restClient.authenticateUser(adminTenantUser) - .withWorkflowAPI().usingProcess(networkProcess1).getProcessTasks().getOneRandomEntry(); - - restVariableCollection = restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().usingTask(task.onModel()).getTaskVariables(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } - - @Test(groups = { TestGroup.NETWORKS,TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Add task item using admin user from same network") - public void addMultipleTaskItemByAdminSameNetwork() throws Exception - { - - siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); - document = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(DocumentType.XML); - document2 = dataContent.usingUser(adminTenantUser).usingUser(adminTenantUser).usingSite(siteModel).createContent(DocumentType.XML); - RestProcessModel addedProcess = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); - RestTaskModel addedTask = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess); - - itemModels = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().usingTask(addedTask) - .addTaskItems(document2,document); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - itemModels.getEntries().get(0).onModel() - .assertThat().field("createdAt").is(itemModels.getEntries().get(0).onModel().getCreatedAt()) - .assertThat().field("size").is(itemModels.getEntries().get(0).onModel().getSize()) - .assertThat().field("createdBy").is(itemModels.getEntries().get(0).onModel().getCreatedBy()) - .assertThat().field("modifiedAt").is(itemModels.getEntries().get(0).onModel().getModifiedAt()) - .assertThat().field("name").is(itemModels.getEntries().get(0).onModel().getName()) - .assertThat().field("modifiedBy").is(itemModels.getEntries().get(0).onModel().getModifiedBy()) - .assertThat().field("id").is(itemModels.getEntries().get(0).onModel().getId()) - .assertThat().field("mimeType").is(itemModels.getEntries().get(0).onModel().getMimeType()); - - itemModels.getEntries().get(1).onModel() - .assertThat().field("createdAt").is(itemModels.getEntries().get(1).onModel().getCreatedAt()) - .assertThat().field("size").is(itemModels.getEntries().get(1).onModel().getSize()) - .assertThat().field("createdBy").is(itemModels.getEntries().get(1).onModel().getCreatedBy()) - .assertThat().field("modifiedAt").is(itemModels.getEntries().get(1).onModel().getModifiedAt()) - .assertThat().field("name").is(itemModels.getEntries().get(1).onModel().getName()) - .assertThat().field("modifiedBy").is(itemModels.getEntries().get(1).onModel().getModifiedBy()) - .assertThat().field("id").is(itemModels.getEntries().get(1).onModel().getId()); - } - - @Test(groups = { TestGroup.NETWORKS,TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Add task item using admin user from same network") - public void addTaskItemByAdminSameNetwork() throws Exception - { - siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); - document = dataContent.usingUser(adminTenantUser).usingSite(siteModel).createContent(DocumentType.XML); - RestProcessModel addedProcess = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", secondTenantUser, false, Priority.Normal); - RestTaskModel addedTask = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess); - - restTaskItem = restClient.withWorkflowAPI().usingTask(addedTask).addTaskItem(document); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restTaskItem.assertThat().field("createdAt").is(restTaskItem.getCreatedAt()) - .and().field("size").is(restTaskItem.getSize()) - .and().field("createdBy").is(restTaskItem.getCreatedBy()) - .and().field("modifiedAt").is(restTaskItem.getModifiedAt()) - .and().field("name").is(restTaskItem.getName()) - .and().field("modifiedBy").is(restTaskItem.getModifiedBy()) - .and().field("id").is(restTaskItem.getId()) - .and().field("mimeType").is(restTaskItem.getMimeType()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS}) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Update existing task variable by admin in the same network") - public void updateTaskVariableByAdminInSameNetwork() throws Exception - { - RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser).withWorkflowAPI() - .addProcess("activitiReview", tenantUser, false, CMISUtil.Priority.High); - RestTaskModel task = restClient.authenticateUser(adminTenantUser) - .withWorkflowAPI().usingProcess(networkProcess1).getProcessTasks().getOneRandomEntry(); - - variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - variableModel1 = restClient.withWorkflowAPI().usingTask(task.onModel()) - .updateTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - variableModel1.assertThat().field("scope").is(variableModel1.getScope()) - .and().field("name").is(variableModel1.getName()) - .and().field("type").is(variableModel1.getType()) - .and().field("value").is(variableModel1.getValue()); - - variableModel.setValue("updatedValue"); - variableModel1 = restClient.withWorkflowAPI().usingTask(task.onModel()).updateTaskVariable(variableModel).and().field("value").is("updatedValue"); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify tenant user that created the task can update task only in its network and response is 200, for other networks is 403") - public void ownerTenantCanUpdatedTaskOnlyInItsNetwork() throws Exception - { - - - SiteModel siteModel1 = dataSite.usingUser(tenantUser).createPublicRandomSite(); - FileModel fileModel1 = dataContent.usingUser(tenantUser).usingSite(siteModel1).createContent(DocumentType.TEXT_PLAIN); - RestProcessDefinitionModel def1 = restClient.authenticateUser(tenantUser).withWorkflowAPI().getAllProcessDefinitions().getEntries().get(0).onModel(); - TaskModel taskModel1 = dataWorkflow.usingUser(tenantUser).usingSite(siteModel1).usingResource(fileModel1) - .createTaskWithProcessDefAndAssignTo(def1.getId(), secondTenantUser); - - SiteModel siteModel2 = dataSite.usingUser(differentNetworkTenantUser).createPublicRandomSite(); - FileModel fileModel2 = dataContent.usingUser(differentNetworkTenantUser).usingSite(siteModel2).createContent(DocumentType.TEXT_PLAIN); - RestProcessDefinitionModel def2 = restClient.authenticateUser(differentNetworkTenantUser).withWorkflowAPI().getAllProcessDefinitions().getEntries().get(0).onModel(); - TaskModel taskModel2 = dataWorkflow.usingUser(differentNetworkTenantUser).usingSite(siteModel2).usingResource(fileModel2) - .createTaskWithProcessDefAndAssignTo(def2.getId(), secondAdminTenantUser); - - restTaskModel = restClient.authenticateUser(differentNetworkTenantUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel2).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel2.getId()) - .and().field("state").is("completed"); - - restTaskModel = restClient.authenticateUser(differentNetworkTenantUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel1).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/DeleteDeploymentTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/DeleteDeploymentTests.java deleted file mode 100644 index 244231747..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/DeleteDeploymentTests.java +++ /dev/null @@ -1,144 +0,0 @@ -package org.alfresco.service.search.rest.workflow.deployments; - -import java.util.List; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestDeploymentModel; -import org.alfresco.rest.model.RestDeploymentModelsCollection; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestProcessDefinitionModel; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.model.RestTaskModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Tests for REST API call DELETE "/deployments/{deploymentId}" - * Class has priority 100 in order to be executed last in the list of tests classes - * - * @author Cristina Axinte - * - */ -public class DeleteDeploymentTests extends RestTest -{ - private UserModel adminUser, userModel; - private RestDeploymentModel deployment; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userModel = dataUser.createRandomTestUser(); - } - - @Bug(id = "REPO-1930") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, - executionType = ExecutionType.SANITY, description = "Verify admin user deletes a specific deployment using REST API and status code is successful (204)") - @Test(groups = { TestGroup.REST_API, TestGroup.DEPLOYMENTS, TestGroup.SANITY, TestGroup.WORKFLOW }, priority = 100) - public void adminDeletesDeploymentWithSuccess() throws Exception - { - dataContent.assertExtensionAmpExists("alfresco-workflow-extension"); - // The deployment with name "customWorkflowExtentionForRest.bpmn" is created by Workflow Extention Point - RestDeploymentModelsCollection allDeployments = restClient.authenticateUser(adminUser).withWorkflowAPI().getDeployments(); - allDeployments.assertThat().entriesListContains("name", "customWorkflowExtentionForRest.bpmn"); - deployment = allDeployments.getDeploymentByName("customWorkflowExtentionForRest.bpmn"); - - RestProcessDefinitionModel processDefinitionAssociated = - restClient.withWorkflowAPI().getAllProcessDefinitions().getProcessDefinitionById(deployment.getId()); - - RestProcessModel addedProcess = - restClient.withWorkflowAPI().addProcess(processDefinitionAssociated.getName(), adminUser, false, CMISUtil.Priority.Normal); - - List processTasks = - restClient.withWorkflowAPI().usingProcess(addedProcess).getProcessTasks().getEntries(); - - restClient.withWorkflowAPI().usingDeployment(deployment).deleteDeployment(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - //check get deployment returns http status Not Found after deleting the deployment - restClient.withWorkflowAPI().usingDeployment(deployment).getDeployment(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, deployment.getId())); - - //check that process definitions contained by deployment are deleted - restClient.withWorkflowAPI().usingProcessDefinitions(processDefinitionAssociated).getProcessDefinition(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, processDefinitionAssociated.getId())); - - //check that history information associated with the deployment is deleted - restClient.withWorkflowAPI().usingProcess(addedProcess).getProcess(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, addedProcess.getId())); - - for (RestTaskModel processTask: processTasks) - { - restClient.withWorkflowAPI().usingTask(processTask).getTask(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, processTask.getId())); - } - - //check getProcessDefinitionStartFormModel after deletion of process definition - restClient.withWorkflowAPI().usingProcessDefinitions(processDefinitionAssociated).getProcessDefinitionStartFormModel(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, processDefinitionAssociated.getId())); - - //check getProcessDefinitionImage after deletion of process definition - restClient.withWorkflowAPI().usingProcessDefinitions(processDefinitionAssociated).getProcessDefinitionImage(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, processDefinitionAssociated.getId())); - - //delete deployment twice - restClient.withWorkflowAPI().usingDeployment(deployment).deleteDeployment(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, deployment.getId())) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Bug(id = "REPO-1930") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, - executionType = ExecutionType.SANITY, description = "Verify admin user cannot delete an inexistent deployment using REST API and status code is successful (204)") - @Test(groups = { TestGroup.REST_API, TestGroup.DEPLOYMENTS, TestGroup.SANITY, TestGroup.WORKFLOW }, priority = 100) - public void adminCannotDeleteInexistentDeployment() throws Exception - { - deployment = restClient.authenticateUser(adminUser).withWorkflowAPI().getDeployments().getOneRandomEntry().onModel(); - deployment.setId(String.valueOf(1000)); - - restClient.withWorkflowAPI().usingDeployment(deployment).deleteDeployment(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "1000")); - } - - @Bug(id = "REPO-1930") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, - description = "Verify deleteDeployment is unsupported for empty deployment id with REST API and status code is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION, TestGroup.WORKFLOW }) - public void deleteDeploymentIsUnsupportedForEmptyId() throws Exception - { - deployment = restClient.authenticateUser(adminUser).withWorkflowAPI().getDeployments().getOneRandomEntry().onModel(); - deployment.setId(""); - restClient.withWorkflowAPI().usingDeployment(deployment).deleteDeployment(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); - } - - @Bug(id = "REPO-1930") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, - description = "Verify deleteDeployment is forbidden using non admin user or different user than creator with REST API and status code is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION, TestGroup.WORKFLOW }) - public void deleteDeploymentUsingNonAdminUser() throws Exception - { - deployment = restClient.authenticateUser(adminUser).withWorkflowAPI().getDeployments().getOneRandomEntry().onModel(); - restClient.authenticateUser(userModel).withWorkflowAPI().usingDeployment(deployment).deleteDeployment(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentCoreTests.java deleted file mode 100644 index 29dcdcc91..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentCoreTests.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.alfresco.service.search.rest.workflow.deployments; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestDeploymentModel; -import org.alfresco.rest.model.RestErrorModel; -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; - -/** - * Created by Claudia Agache on 12/7/2016. - */ -public class GetDeploymentCoreTests extends RestTest -{ - private UserModel adminUser; - private RestDeploymentModel expectedDeployment; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, - executionType = ExecutionType.REGRESSION, - description = "Verify if get deployment request returns status code 404 when invalid deploymentId is used.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION }) - public void getNonNetworkDeploymentUsingInvalidDeploymentId() throws Exception - { - expectedDeployment = restClient.authenticateUser(adminUser).withWorkflowAPI().getDeployments().getOneRandomEntry().onModel(); - expectedDeployment.setId("invalidId"); - - restClient.withWorkflowAPI().usingDeployment(expectedDeployment).getDeployment(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidId")); - } - -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentFullTests.java deleted file mode 100644 index bf55fb084..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentFullTests.java +++ /dev/null @@ -1,57 +0,0 @@ -package org.alfresco.service.search.rest.workflow.deployments; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.core.RestRequest; -import org.alfresco.rest.model.RestDeploymentModel; -import org.alfresco.rest.model.RestDeploymentModelsCollection; -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; - -/** - * Created by Claudia Agache on 1/31/2017. - */ -public class GetDeploymentFullTests extends RestTest -{ - private UserModel adminUser; - private RestDeploymentModel expectedDeployment, actualDeployment; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, - executionType = ExecutionType.REGRESSION, - description = "Verify if get deployment request returns all deployments if empty deploymentId is used.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION }) - public void getNonNetworkDeploymentUsingEmptyDeploymentId() throws Exception - { - restClient.authenticateUser(adminUser).withWorkflowAPI(); - RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "deployments/{deploymentId}", ""); - RestDeploymentModelsCollection deployments = restClient.processModels(RestDeploymentModelsCollection.class, request); - restClient.assertStatusCodeIs(HttpStatus.OK); - deployments.assertThat().entriesListIsNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, - description = "Verify Admin user gets non-network deployments with properties parameter applied using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION}) - public void getNonNetworkDeploymentsWithValidProperties() throws Exception - { - expectedDeployment = restClient.authenticateUser(adminUser).withWorkflowAPI().getDeployments().getOneRandomEntry().onModel(); - actualDeployment = restClient.withParams("properties=id,name").withWorkflowAPI().usingDeployment(expectedDeployment).getDeployment(); - restClient.assertStatusCodeIs(HttpStatus.OK); - actualDeployment.assertThat() - .fieldsCount().is(2).and() - .field("id").is(expectedDeployment.getId()).and() - .field("deployedAt").isNull().and() - .field("name").is(expectedDeployment.getName()); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentSanityTests.java deleted file mode 100644 index 74c4aa754..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentSanityTests.java +++ /dev/null @@ -1,57 +0,0 @@ -package org.alfresco.service.search.rest.workflow.deployments; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestDeploymentModel; -import org.alfresco.rest.model.RestErrorModel; -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; - -/** - * Tests for REST API call GET "/deployments/{deploymentId}" - * - * @author Cristina Axinte - * - */ -public class GetDeploymentSanityTests extends RestTest -{ - private UserModel adminUser; - private UserModel anotherUser; - private RestDeploymentModel expectedDeployment, actualDeployment; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - anotherUser = dataUser.createRandomTestUser(); - - expectedDeployment = restClient.authenticateUser(adminUser).withWorkflowAPI().getDeployments().getOneRandomEntry().onModel(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, - executionType = ExecutionType.SANITY, description = "Verify admin user gets a non-network deployment using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.SANITY }) - public void adminGetsNonNetworkDeploymentWithSuccess() throws JsonToModelConversionException, Exception - { - actualDeployment = restClient.authenticateUser(adminUser).withWorkflowAPI().usingDeployment(expectedDeployment).getDeployment(); - restClient.assertStatusCodeIs(HttpStatus.OK); - actualDeployment.assertThat().field("deployedAt").isNotEmpty() - .and().field("name").is(expectedDeployment.getName()) - .and().field("id").is(expectedDeployment.getId()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, - executionType = ExecutionType.SANITY, description = "Verify non admin user is forbidden to get a non-network deployment using REST API (403)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.SANITY }) - public void nonAdminIsForbiddenToGetNonNetworkDeployment() throws JsonToModelConversionException, Exception - { - restClient.authenticateUser(anotherUser).withWorkflowAPI().usingDeployment(expectedDeployment).getDeployment(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentsCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentsCoreTests.java deleted file mode 100644 index 406621f77..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentsCoreTests.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.alfresco.service.search.rest.workflow.deployments; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -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.Test; - -/** - * Created by Claudia Agache on 12/7/2016. - */ -public class GetDeploymentsCoreTests extends RestTest -{ - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, - executionType = ExecutionType.REGRESSION, - description = "Verify non admin user is not able to get non-network deployments using REST API and status code is Forbidden") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION}) - public void nonAdminUserCanNotGetNonNetworkDeployments() throws Exception - { - UserModel userModel = dataUser.createRandomTestUser(); - restClient.authenticateUser(userModel).withWorkflowAPI().getDeployments(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentsFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentsFullTests.java deleted file mode 100644 index 586711559..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentsFullTests.java +++ /dev/null @@ -1,146 +0,0 @@ -package org.alfresco.service.search.rest.workflow.deployments; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestDeploymentModel; -import org.alfresco.rest.model.RestDeploymentModelsCollection; -import org.alfresco.rest.model.RestErrorModel; -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; - -/** - * Created by Claudia Agache on 1/30/2017. - */ -public class GetDeploymentsFullTests extends RestTest -{ - private UserModel adminUserModel; - private RestDeploymentModelsCollection deployments; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - restClient.authenticateUser(adminUserModel); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, - description = "Verify Admin user gets non-network deployments with skipCount parameter applied using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION}) - public void getNonNetworkDeploymentsWithValidSkipCount() throws JsonToModelConversionException, Exception - { - deployments = restClient.withWorkflowAPI().getDeployments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - RestDeploymentModel firstDeployment = deployments.getEntries().get(0).onModel(); - RestDeploymentModel secondDeployment = deployments.getEntries().get(1).onModel(); - RestDeploymentModelsCollection deploymentsWithSkipCount = restClient.withParams("skipCount=2").withWorkflowAPI().getDeployments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - deploymentsWithSkipCount - .assertThat().entriesListDoesNotContain("name", firstDeployment.getName()) - .assertThat().entriesListDoesNotContain("name", secondDeployment.getName()) - .assertThat().entriesListCountIs(deployments.getEntries().size()-2); - deploymentsWithSkipCount.assertThat().paginationField("skipCount").is("2"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, - description = "Verify Admin user doesn't get non-network deployments when negative skipCount parameter is applied using REST API and status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION}) - public void getNonNetworkDeploymentsWithNegativeSkipCount() throws JsonToModelConversionException, Exception - { - restClient.withParams("skipCount=-1").withWorkflowAPI().getDeployments(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT) - .containsErrorKey(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE) - .statusCodeIs(HttpStatus.BAD_REQUEST); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, - description = "Verify Admin user doesn't get non-network deployments when non numeric skipCount parameter is applied using REST API and status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION}) - public void getNonNetworkDeploymentsWithNotNumericSkipCount() throws JsonToModelConversionException, Exception - { - restClient.withParams("skipCount=A").withWorkflowAPI().getDeployments(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "A")); - } - - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, - description = "Verify Admin user gets non-network deployments with maxItems parameter applied using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION}) - public void getNonNetworkDeploymentsWithValidMaxItems() throws JsonToModelConversionException, Exception - { - deployments = restClient.withWorkflowAPI().getDeployments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - RestDeploymentModel firstDeployment = deployments.getEntries().get(0).onModel(); - RestDeploymentModel secondDeployment = deployments.getEntries().get(1).onModel(); - RestDeploymentModelsCollection deploymentsWithMaxItems = restClient.withParams("maxItems=2").withWorkflowAPI().getDeployments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - deploymentsWithMaxItems - .assertThat().entriesListContains("name", firstDeployment.getName()) - .assertThat().entriesListContains("name", secondDeployment.getName()) - .assertThat().entriesListCountIs(2); - deploymentsWithMaxItems.assertThat().paginationField("maxItems").is("2"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, - description = "Verify Admin user doesn't get non-network deployments when negative maxItems parameter is applied using REST API and status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION}) - public void getNonNetworkDeploymentsWithNegativeMaxItems() throws JsonToModelConversionException, Exception - { - restClient.withParams("maxItems=-1").withWorkflowAPI().getDeployments(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) - .containsErrorKey(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE) - .statusCodeIs(HttpStatus.BAD_REQUEST); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, - description = "Verify Admin user doesn't get non-network deployments when non numeric maxItems parameter is applied using REST API and status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION}) - public void getNonNetworkDeploymentsWithNotNumericMaxItems() throws JsonToModelConversionException, Exception - { - restClient.withParams("maxItems=A").withWorkflowAPI().getDeployments(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "A")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, - description = "Verify Admin user gets non-network deployments with properties parameter applied using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION}) - public void getNonNetworkDeploymentsWithValidProperties() throws JsonToModelConversionException, Exception - { - deployments = restClient.withParams("properties=name").withWorkflowAPI().getDeployments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - deployments.assertThat().entriesListIsNotEmpty(); - deployments.getOneRandomEntry().onModel().assertThat() - .fieldsCount().is(1).and() - .field("id").isNull().and() - .field("deployedAt").isNull().and() - .field("name").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.REGRESSION, - description = "Verify Admin user gets non-network deployments with non existing properties parameter applied using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.REGRESSION}) - public void getNonNetworkDeploymentsWithNonExistingProperties() throws JsonToModelConversionException, Exception - { - deployments = restClient.withParams("properties=TAS").withWorkflowAPI().getDeployments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - deployments.assertThat().entriesListIsNotEmpty(); - deployments.getOneRandomEntry().onModel().assertThat() - .fieldsCount().is(0).and() - .field("id").isNull().and() - .field("deployedAt").isNull().and() - .field("name").isNull(); - } - -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentsSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentsSanityTests.java deleted file mode 100644 index 2253c1df5..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/deployments/GetDeploymentsSanityTests.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.alfresco.service.search.rest.workflow.deployments; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestDeploymentModelsCollection; -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; - -/** - * Created by Claudia Agache on 10/4/2016. - */ -public class GetDeploymentsSanityTests extends RestTest -{ - private UserModel adminUserModel; - private RestDeploymentModelsCollection deployments; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - restClient.authenticateUser(adminUserModel); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS }, executionType = ExecutionType.SANITY, - description = "Verify Admin user gets non-network deployments using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.DEPLOYMENTS, TestGroup.SANITY}) - public void getNonNetworkDeploymentsWithAdmin() throws JsonToModelConversionException, Exception - { - deployments = restClient.authenticateUser(adminUserModel).withWorkflowAPI().getDeployments(); - restClient.assertStatusCodeIs(HttpStatus.OK); - deployments.assertThat().entriesListIsNotEmpty(); - deployments.getOneRandomEntry().onModel().assertThat() - .fieldsCount().is(3).and() - .field("id").isNotEmpty().and() - .field("deployedAt").isNotEmpty().and() - .field("name").isNotEmpty(); - } - -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionCoreTests.java deleted file mode 100644 index f1a1205f6..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionCoreTests.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processDefinitions; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestProcessDefinitionModel; -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; - -/** - * Created by Claudia Agache on 12/5/2016. - */ -public class GetProcessDefinitionCoreTests extends RestTest -{ - private UserModel adminUser; - private RestProcessDefinitionModel randomProcessDefinition; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, - executionType = ExecutionType.REGRESSION, - description = "Verify if get process definition returns status code 404 when invalid processDefinitionId is used") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) - public void getProcessDefinitionUsingInvalidProcessDefinitionId() throws Exception - { - restClient.authenticateUser(adminUser); - randomProcessDefinition = restClient.withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry().onModel(); - randomProcessDefinition.setId("invalidID"); - restClient.withWorkflowAPI() - .usingProcessDefinitions(randomProcessDefinition).getProcessDefinition(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidID")) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionFullTests.java deleted file mode 100644 index 601aeb14d..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionFullTests.java +++ /dev/null @@ -1,67 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processDefinitions; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.core.RestRequest; -import org.alfresco.rest.model.RestProcessDefinitionModel; -import org.alfresco.rest.model.RestProcessDefinitionModelsCollection; -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; - -/** - * Created by Claudia Agache on 2/1/2017. - */ -public class GetProcessDefinitionFullTests extends RestTest -{ - private UserModel adminUser; - private RestProcessDefinitionModel randomProcessDefinition, returnedProcessDefinition; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, - executionType = ExecutionType.REGRESSION, - description = "Verify if get process definition returns all process definitions when empty processDefinitionId is used") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) - public void getProcessDefinitionUsingEmptyProcessDefinitionId() throws Exception - { - restClient.authenticateUser(adminUser).withWorkflowAPI(); - RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "/process-definitions/{processDefinitionId}", ""); - RestProcessDefinitionModelsCollection processDefinitions = restClient.processModels(RestProcessDefinitionModelsCollection.class, request); - restClient.assertStatusCodeIs(HttpStatus.OK); - processDefinitions.assertThat().entriesListIsNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, - executionType = ExecutionType.REGRESSION, - description = "Verify Admin user gets a process definition with properties parameter applied using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) - public void getProcessDefinitionWithValidProperties() throws Exception - { - randomProcessDefinition = restClient.authenticateUser(adminUser).withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry().onModel(); - returnedProcessDefinition = restClient.withParams("properties=id,name,graphicNotationDefined,version") - .withWorkflowAPI() - .usingProcessDefinitions(randomProcessDefinition).getProcessDefinition(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedProcessDefinition.assertThat() - .fieldsCount().is(4).and() - .field("deploymentId").isNull().and() - .field("description").isNull().and() - .field("id").is(randomProcessDefinition.getId()).and() - .field("startFormResourceKey").isNull().and() - .field("category").isNull().and() - .field("title").isNull().and() - .field("version").is(randomProcessDefinition.getVersion()).and() - .field("graphicNotationDefined").is(randomProcessDefinition.getGraphicNotationDefined()).and() - .field("key").isNull().and() - .field("name").is(randomProcessDefinition.getName()); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionImageCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionImageCoreTests.java deleted file mode 100644 index 9b5a2f64b..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionImageCoreTests.java +++ /dev/null @@ -1,46 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processDefinitions; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestProcessDefinitionModel; -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; - -/** - * Created by Claudia Agache on 12/6/2016. - */ -public class GetProcessDefinitionImageCoreTests extends RestTest -{ - private UserModel adminUser; - private RestProcessDefinitionModel randomProcessDefinition; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, - executionType = ExecutionType.REGRESSION, - description = "Verify if get process definition image returns status code 404 when invalid processDefinitionId is used") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) - public void getProcessDefinitionImageUsingInvalidProcessDefinitionId() throws Exception - { - restClient.authenticateUser(adminUser); - randomProcessDefinition = restClient.withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry().onModel(); - randomProcessDefinition.setId("invalidID"); - - restClient.withWorkflowAPI() - .usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionImage(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidID")) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionImageFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionImageFullTests.java deleted file mode 100644 index 194e0ebcc..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionImageFullTests.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processDefinitions; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestProcessDefinitionModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Created by Claudia Agache on 2/1/2017. - */ -public class GetProcessDefinitionImageFullTests extends RestTest -{ - private UserModel adminUser; - private RestProcessDefinitionModel randomProcessDefinition; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - } - - @Bug(id = "REPO-1911") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, - executionType = ExecutionType.REGRESSION, - description = "Verify if get process definition image returns status code 404 when empty processDefinitionId is used") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) - public void getProcessDefinitionImageUsingEmptyProcessDefinitionId() throws Exception - { - restClient.authenticateUser(adminUser); - randomProcessDefinition = restClient.withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry().onModel(); - randomProcessDefinition.setId(""); - restClient.withWorkflowAPI() - .usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionImage(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java deleted file mode 100644 index 1e3c81cb7..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processDefinitions; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestProcessDefinitionModel; -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; - -/** - * Created by Claudia Agache on 10/13/2016. - */ -public class GetProcessDefinitionImageSanityTests extends RestTest -{ - private UserModel testUser; - private RestProcessDefinitionModel randomProcessDefinition; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - testUser = dataUser.createRandomTestUser(); - restClient.authenticateUser(dataUser.getAdminUser()); - randomProcessDefinition = restClient.withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry().onModel(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.SANITY, - description = "Verify Any user gets a specific process definition image for non-network deployments using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY, TestGroup.REQUIRE_TRANSFORMATION }) - public void anyUserGetsProcessDefinitionImage() throws Exception - { - restClient.authenticateUser(testUser); - restClient.withWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionImage() - .assertResponseContainsImage(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.SANITY, - description = "Verify Admin user gets a specific process definition image for non-network deployments using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY, TestGroup.REQUIRE_TRANSFORMATION }) - public void adminGetsProcessDefinitionImage() throws Exception - { - restClient.withWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionImage() - .assertResponseContainsImage(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java deleted file mode 100644 index 0ac6e6496..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionSanityTests.java +++ /dev/null @@ -1,62 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processDefinitions; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestProcessDefinitionModel; -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; - -/** - * Created by Claudia Agache on 10/13/2016. - */ -public class GetProcessDefinitionSanityTests extends RestTest -{ - private UserModel testUser; - private RestProcessDefinitionModel randomProcessDefinition, firstRandomProcessDefinition, returnedProcessDefinition; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - testUser = dataUser.createRandomTestUser(); - restClient.authenticateUser(dataUser.getAdminUser()); - randomProcessDefinition = restClient.withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry().onModel(); - firstRandomProcessDefinition = restClient.withWorkflowAPI().getAllProcessDefinitions().getProcessDefinitionByDeploymentId("1"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, - executionType = ExecutionType.SANITY, - description = "Verify Admin user gets a specific process definition for non-network deployments using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY }) - public void adminGetsProcessDefinition() throws Exception - { - returnedProcessDefinition = restClient.withWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinition(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedProcessDefinition.assertThat().field("name").is(randomProcessDefinition.getName()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, - executionType = ExecutionType.SANITY, - description = "Verify Any user gets a specific process definition for non-network deployments using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY }) - public void anyUserGetsProcessDefinition() throws Exception - { - restClient.authenticateUser(testUser); - returnedProcessDefinition = restClient.withWorkflowAPI().usingProcessDefinitions(firstRandomProcessDefinition).getProcessDefinition(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedProcessDefinition.assertThat() - .field("name").is(firstRandomProcessDefinition.getName()).and() - .field("deploymentId").is(firstRandomProcessDefinition.getDeploymentId()).and() - .field("description").is(firstRandomProcessDefinition.getDescription()).and() - .field("id").is(firstRandomProcessDefinition.getId()).and() - .field("startFormResourceKey").is(firstRandomProcessDefinition.getStartFormResourceKey()).and() - .field("category").is(firstRandomProcessDefinition.getCategory()).and() - .field("title").is(firstRandomProcessDefinition.getTitle()).and() - .field("version").is(firstRandomProcessDefinition.getVersion()).and() - .field("graphicNotationDefined").is(firstRandomProcessDefinition.getGraphicNotationDefined()).and() - .field("key").is(firstRandomProcessDefinition.getKey()); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java deleted file mode 100644 index 4458d5b31..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelCoreTests.java +++ /dev/null @@ -1,80 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processDefinitions; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestProcessDefinitionModel; -import org.alfresco.rest.model.RestProcessDefinitionModelsCollection; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Created by Claudia Agache on 12/6/2016. - */ -public class GetProcessDefinitionStartFormModelCoreTests extends RestTest -{ - private UserModel adminUser; - private RestProcessDefinitionModel randomProcessDefinition; - private RestProcessDefinitionModelsCollection allProcessDefinitions; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - allProcessDefinitions = restClient.authenticateUser(adminUser).withWorkflowAPI().getAllProcessDefinitions(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, - executionType = ExecutionType.REGRESSION, - description = "Verify any user gets a model of the start form type definition for non-network deployments using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) - public void nonNetworkUserGetsStartFormModel() throws Exception - { - UserModel nonNetworkUser = dataUser.createRandomTestUser(); - randomProcessDefinition = allProcessDefinitions.getOneRandomEntry().onModel(); - restClient.authenticateUser(nonNetworkUser).withWorkflowAPI() - .usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionStartFormModel() - .assertThat().entriesListIsNotEmpty(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Bug(id = "ALF-20187") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, - executionType = ExecutionType.REGRESSION, - description = "Verify if get request returns status code 404 when invalid processDefinitionId is used") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) - public void getStartFormModelUsingInvalidProcessDefinitionId() throws Exception - { - randomProcessDefinition = allProcessDefinitions.getOneRandomEntry().onModel(); - randomProcessDefinition.setId("invalidID"); - - restClient.authenticateUser(adminUser).withWorkflowAPI() - .usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionStartFormModel(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format("no deployed process definition found with id '%s'", "invalidID")) - .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Bug(id = "ALF-20187") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, - executionType = ExecutionType.REGRESSION, - description = "Verify if get request returns status code 404 when empty processDefinitionId is used") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) - public void getStartFormModelUsingEmptyProcessDefinitionId() throws Exception - { - randomProcessDefinition = allProcessDefinitions.getOneRandomEntry().onModel(); - randomProcessDefinition.setId(""); - - restClient.authenticateUser(adminUser).withWorkflowAPI() - .usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionStartFormModel(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary("no deployed process definition found with id ''"); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelFullTests.java deleted file mode 100644 index dfd483433..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelFullTests.java +++ /dev/null @@ -1,71 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processDefinitions; - -import java.util.Arrays; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestFormModelsCollection; -import org.alfresco.rest.model.RestProcessDefinitionModel; -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; - -/** - * Created by Claudia Agache on 1/31/2017. - */ -public class GetProcessDefinitionStartFormModelFullTests extends RestTest -{ - private UserModel adminUser; - private RestProcessDefinitionModel activitiAdhoc; - private RestFormModelsCollection returnedResponse; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - activitiAdhoc = restClient.authenticateUser(adminUser).withWorkflowAPI().getAllProcessDefinitions().getProcessDefinitionByDeploymentId("1"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, - executionType = ExecutionType.REGRESSION, - description = "Verify admin gets a model of the start form type definition for specific process definition using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) - public void adminGetsStartFormModelForActivitiAdhocProcessDefinition() throws Exception - { - returnedResponse = restClient.authenticateUser(adminUser).withWorkflowAPI() - .usingProcessDefinitions(activitiAdhoc).getProcessDefinitionStartFormModel(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedResponse.assertThat().entriesListContains("qualifiedName", "{http://www.alfresco.org/model/bpm/1.0}workflowPriority"); - returnedResponse.getStartFormModelByQualifiedName("{http://www.alfresco.org/model/bpm/1.0}workflowPriority") - .assertThat().field("defaultValue").is("2") - .and().field("dataType").is("d:int") - .and().field("name").is("bpm_workflowPriority") - .and().field("title").is("Workflow Priority") - .and().field("required").is("false") - .and().field("allowedValues").is(Arrays.asList("1", "2", "3")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, - executionType = ExecutionType.REGRESSION, - description = "Verify admin gets a model of the start form type definition with properties parameter applied using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) - public void adminGetsStartFormModelWithPropertiesParameterApplied() throws Exception - { - returnedResponse = restClient.authenticateUser(adminUser).withParams("properties=qualifiedName,dataType,title").withWorkflowAPI() - .usingProcessDefinitions(activitiAdhoc).getProcessDefinitionStartFormModel(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedResponse.assertThat().entriesListContains("qualifiedName", "{http://www.alfresco.org/model/bpm/1.0}workflowPriority"); - returnedResponse.getStartFormModelByQualifiedName("{http://www.alfresco.org/model/bpm/1.0}workflowPriority") - .assertThat().fieldsCount().is(3) - .and().field("qualifiedName").is("{http://www.alfresco.org/model/bpm/1.0}workflowPriority") - .and().field("defaultValue").isNull() - .and().field("dataType").is("d:int") - .and().field("name").isNull() - .and().field("title").is("Workflow Priority") - .and().field("required").isNull() - .and().field("allowedValues").isNull(); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java deleted file mode 100644 index 3309c3540..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processDefinitions; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestProcessDefinitionModel; -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; - -/** - * Created by Claudia Agache on 10/18/2016. - */ -public class GetProcessDefinitionStartFormModelSanityTests extends RestTest -{ - private UserModel adminUserModel; - private RestProcessDefinitionModel randomProcessDefinition; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - restClient.authenticateUser(adminUserModel); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, - executionType = ExecutionType.SANITY, - description = "Verify Admin gets a model of the start form type definition for non-network deployments using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY }) - public void nonNetworkAdminGetsStartFormModel() throws Exception - { - randomProcessDefinition = restClient.withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry().onModel(); - restClient.withWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionStartFormModel().assertThat().entriesListIsNotEmpty(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionsCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionsCoreTests.java deleted file mode 100644 index 04849dd5e..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionsCoreTests.java +++ /dev/null @@ -1,53 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processDefinitions; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class GetProcessDefinitionsCoreTests extends RestTest -{ - private UserModel userModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, - description = "Verify call to get process definitions with invalid orderBy parameter with REST API and status code is BAD_REQUEST (400)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) - public void userGetProcessDefinitionsWithInvalidOrderBy() throws Exception - { - restClient.authenticateUser(userModel) - .withParams("orderBy=test") - .withWorkflowAPI() - .getAllProcessDefinitions() - .assertThat().entriesListIsEmpty(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_ORDERBY, "test", "deploymentId, name, id, category, version, key")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, - description = "Verify call to get process definitions with invalid where parameter with REST API and status code is BAD_REQUEST (400)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) - public void userGetProcessDefinitionsWithInvalidWhere() throws Exception - { - restClient.authenticateUser(userModel) - .withParams("where=test") - .withWorkflowAPI() - .getAllProcessDefinitions() - .assertThat().entriesListIsEmpty(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_WHERE_QUERY, "test")) - .containsErrorKey(RestErrorModel.INVALID_QUERY_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionsFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionsFullTests.java deleted file mode 100644 index 44b7d93bf..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionsFullTests.java +++ /dev/null @@ -1,174 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processDefinitions; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestProcessDefinitionModel; -import org.alfresco.rest.model.RestProcessDefinitionModelsCollection; -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; - -/** - * Created by Claudia Agache on 2/1/2017. - */ -public class GetProcessDefinitionsFullTests extends RestTest -{ - private UserModel adminUserModel; - private RestProcessDefinitionModelsCollection processDefinitions; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, - description = "Verify admin gets process definitions with valid skipCount parameter applied using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) - public void getProcessDefinitionsWithValidSkipCount() throws Exception - { - processDefinitions = restClient.authenticateUser(adminUserModel) - .withWorkflowAPI().getAllProcessDefinitions(); - restClient.assertStatusCodeIs(HttpStatus.OK); - RestProcessDefinitionModel firstProcessDefinition = processDefinitions.getEntries().get(0).onModel(); - RestProcessDefinitionModel secondProcessDefinition = processDefinitions.getEntries().get(1).onModel(); - - RestProcessDefinitionModelsCollection procDefWithSkipCount = restClient.withParams("skipCount=2").withWorkflowAPI().getAllProcessDefinitions(); - restClient.assertStatusCodeIs(HttpStatus.OK); - procDefWithSkipCount - .assertThat().entriesListDoesNotContain("name", firstProcessDefinition.getName()) - .assertThat().entriesListDoesNotContain("name", secondProcessDefinition.getName()) - .assertThat().entriesListCountIs(processDefinitions.getEntries().size()-2); - procDefWithSkipCount.assertThat().paginationField("skipCount").is("2"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, - description = "Verify admin doesn't get process definitions with negative skipCount parameter applied using REST API") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) - public void getProcessDefinitionsWithNegativeSkipCount() throws Exception - { - restClient.authenticateUser(adminUserModel).withParams("skipCount=-1").withWorkflowAPI().getAllProcessDefinitions(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT) - .containsErrorKey(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE) - .statusCodeIs(HttpStatus.BAD_REQUEST); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, - description = "Verify admin doesn't get process definitions with non numeric skipCount parameter applied using REST API") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) - public void getProcessDefinitionsWithNonNumericSkipCount() throws Exception - { - restClient.authenticateUser(adminUserModel).withParams("skipCount=A").withWorkflowAPI().getAllProcessDefinitions(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "A")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, - description = "Verify admin gets process definitions with valid maxItems parameter applied using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) - public void getProcessDefinitionsWithValidMaxItems() throws Exception - { - processDefinitions = restClient.authenticateUser(adminUserModel) - .withWorkflowAPI().getAllProcessDefinitions(); - restClient.assertStatusCodeIs(HttpStatus.OK); - RestProcessDefinitionModel firstProcessDefinition = processDefinitions.getEntries().get(0).onModel(); - RestProcessDefinitionModel secondProcessDefinition = processDefinitions.getEntries().get(1).onModel(); - - RestProcessDefinitionModelsCollection procDefWithMaxItems = restClient.withParams("maxItems=2").withWorkflowAPI().getAllProcessDefinitions(); - restClient.assertStatusCodeIs(HttpStatus.OK); - procDefWithMaxItems - .assertThat().entriesListContains("name", firstProcessDefinition.getName()) - .assertThat().entriesListContains("name", secondProcessDefinition.getName()) - .assertThat().entriesListCountIs(2); - procDefWithMaxItems.assertThat().paginationField("maxItems").is("2"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, - description = "Verify admin doesn't get process definitions with negative maxItems parameter applied using REST API") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) - public void getProcessDefinitionsWithNegativeMaxItems() throws Exception - { - restClient.authenticateUser(adminUserModel).withParams("maxItems=-1").withWorkflowAPI().getAllProcessDefinitions(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) - .containsErrorKey(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE) - .statusCodeIs(HttpStatus.BAD_REQUEST); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, - description = "Verify admin doesn't get process definitions with non numeric maxItems parameter applied using REST API") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) - public void getProcessDefinitionsWithNonNumericMaxItems() throws Exception - { - restClient.authenticateUser(adminUserModel).withParams("maxItems=A").withWorkflowAPI().getAllProcessDefinitions(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "A")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, - description = "Verify Admin user gets process definitions with properties parameter applied using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) - public void getProcessDefinitionsWithValidProperties() throws Exception - { - processDefinitions =restClient.authenticateUser(adminUserModel).withParams("properties=name,graphicNotationDefined,version").withWorkflowAPI().getAllProcessDefinitions(); - restClient.assertStatusCodeIs(HttpStatus.OK); - processDefinitions.assertThat().entriesListIsNotEmpty(); - processDefinitions.getOneRandomEntry().onModel().assertThat() - .fieldsCount().is(3).and() - .field("deploymentId").isNull().and() - .field("description").isNull().and() - .field("id").isNull().and() - .field("startFormResourceKey").isNull().and() - .field("category").isNull().and() - .field("title").isNull().and() - .field("version").isNotEmpty().and() - .field("graphicNotationDefined").isNotEmpty().and() - .field("key").isNull().and() - .field("name").isNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, - description = "Verify admin gets process definitions ordered by name ascendant using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) - public void getProcessDefinitionsOrderedByNameAsc() throws Exception - { - processDefinitions = restClient.authenticateUser(adminUserModel) - .withParams("orderBy=name ASC").withWorkflowAPI().getAllProcessDefinitions(); - restClient.assertStatusCodeIs(HttpStatus.OK); - processDefinitions.assertThat().entriesListIsSortedAscBy("name"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, - description = "Verify admin doesn't get process definitions when many fields are used for orderBy parameter") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) - public void getProcessDefinitionsOrderedByManyFields() throws Exception - { - restClient.authenticateUser(adminUserModel) - .withParams("orderBy=name,id").withWorkflowAPI().getAllProcessDefinitions(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(RestErrorModel.ONLY_ONE_ORDERBY); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, - description = "Verify admin gets process definitions when where parameter is applied") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.REGRESSION }) - public void getProcessDefinitionsFilteredByKey() throws Exception - { - processDefinitions = restClient.authenticateUser(adminUserModel) - .withParams("where=(key matches('activitiParallel%'))").withWorkflowAPI().getAllProcessDefinitions(); - restClient.assertStatusCodeIs(HttpStatus.OK); - processDefinitions.assertThat().entriesListCountIs(2) - .assertThat().entriesListContains("key", "activitiParallelReview") - .assertThat().entriesListContains("key", "activitiParallelGroupReview"); - } - -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java deleted file mode 100644 index 69833ca4c..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processDefinitions/GetProcessDefinitionsSanityTests.java +++ /dev/null @@ -1,48 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processDefinitions; - -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestProcessDefinitionModelsCollection; -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; - -/** - * Created by Claudia Agache on 10/13/2016. - */ -public class GetProcessDefinitionsSanityTests extends RestTest -{ - private UserModel adminUserModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - restClient.authenticateUser(adminUserModel); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION }, - executionType = ExecutionType.SANITY, description = "Verify Admin user gets process definitions for non-network deployments using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY }) - public void nonNetworkAdminGetsProcessDefinitions() throws Exception - { - RestProcessDefinitionModelsCollection processDefinitions = restClient.authenticateUser(adminUserModel) - .withWorkflowAPI() - .getAllProcessDefinitions(); - restClient.assertStatusCodeIs(HttpStatus.OK); - processDefinitions.assertThat().entriesListIsNotEmpty(); - processDefinitions.getProcessDefinitionByDeploymentId("1").assertThat() - .field("name").is("Adhoc Activiti Process").and() - .field("description").is("Assign a new task to yourself or a colleague").and() - .field("id").is("activitiAdhoc:1:4").and() - .field("startFormResourceKey").is("wf:submitAdhocTask").and() - .field("category").is("http://alfresco.org").and() - .field("title").is("New Task").and() - .field("version").is("1").and() - .field("graphicNotationDefined").is("true").and() - .field("key").is("activitiAdhoc"); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/AddProcessCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/AddProcessCoreTests.java deleted file mode 100644 index 8704b6147..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/AddProcessCoreTests.java +++ /dev/null @@ -1,130 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes; - -import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.core.RestRequest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestProcessDefinitionModel; -import org.alfresco.rest.model.RestProcessDefinitionModelsCollection; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.model.RestProcessModelsCollection; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.testng.annotations.Test; - -/** - * - * @author Cristina Axinte - * - */ -public class AddProcessCoreTests extends RestTest -{ - private UserModel assignee, adminUser; - private RestProcessModel addedProcess; - private RestProcessModelsCollection processes; - private RestProcessDefinitionModel processDefinition; - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, - executionType = ExecutionType.REGRESSION, description = "Verify non network admin is able to start new process using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void nonNetworkAdminUserStartsNewProcess() throws JsonToModelConversionException, Exception - { - adminUser = dataUser.getAdminUser(); - assignee = dataUser.createRandomTestUser(); - - addedProcess = restClient.authenticateUser(adminUser).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - addedProcess.assertThat().field("id").is(addedProcess.getId()) - .and().field("startUserId").is(adminUser.getUsername()); - - processDefinition = restClient.authenticateUser(adminUser).withWorkflowAPI().getAllProcessDefinitions().getProcessDefinitionByKey("activitiAdhoc"); - processes = restClient.withWorkflowAPI().getProcesses(); - restClient.assertStatusCodeIs(HttpStatus.OK); - processes.assertThat().entriesListContains("id", addedProcess.getId()) - .assertThat().entriesListContains("processDefinitionId", processDefinition.getId()) - .assertThat().entriesListContains("startUserId", adminUser.getUsername()) - .assertThat().entriesListContains("startActivityId", "start") - .assertThat().entriesListContains("completed", "false") - .assertThat().entriesListContains("processDefinitionKey", "activitiAdhoc"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, - executionType = ExecutionType.REGRESSION, description = "Verify start new process with empty request body using REST API returns status code is Bad Request (400)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void startNewProcessWithEmptyProcessBody() throws JsonToModelConversionException, Exception - { - adminUser = dataUser.getAdminUser(); - assignee = dataUser.createRandomTestUser(); - - restClient.authenticateUser(adminUser).withWorkflowAPI(); - RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "", "processes"); - restClient.processModel(RestProcessModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - } - - @Bug(id = "REPO-1936") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, - executionType = ExecutionType.REGRESSION, description = "Verify start new process with invalid request body using REST API returns status code is Bad Request (400)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void startNewProcessWithInvalidProcessDefInProcessBody() throws JsonToModelConversionException, Exception - { - adminUser = dataUser.getAdminUser(); - assignee = dataUser.createRandomTestUser(); - - restClient.authenticateUser(adminUser).withWorkflowAPI(); - RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{\"processDefinitionKey\":\"activitiAdhoc\"}", "processes"); - restClient.processModel(RestProcessModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, - executionType = ExecutionType.REGRESSION, description = "Verify start new process with invalid request body using REST API returns status code is Bad Request (400)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void startNewProcessWithInvalidVariablesInProcessBody1() throws JsonToModelConversionException, Exception - { - adminUser = dataUser.getAdminUser(); - assignee = dataUser.createRandomTestUser(); - - restClient.authenticateUser(adminUser).withWorkflowAPI(); - RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{\"variables\":{\"bpm_sendEMailNotifications\":false}}", "processes"); - restClient.processModel(RestProcessModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary("Either processDefinitionId or processDefinitionKey is required"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, - executionType = ExecutionType.REGRESSION, description = "Verify start new process with invalid request body using REST API returns status code is Bad Request (400)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void startNewProcessWithInvalidVariablesInProcessBody2() throws JsonToModelConversionException, Exception - { - adminUser = dataUser.getAdminUser(); - assignee = dataUser.createRandomTestUser(); - - restClient.authenticateUser(adminUser).withWorkflowAPI(); - RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{\"variables\":{\"bpm_assignee\":\"admin\"}}", "processes"); - restClient.processModel(RestProcessModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary("Either processDefinitionId or processDefinitionKey is required"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, - executionType = ExecutionType.REGRESSION, description = "Verify start new process with invalid request body using REST API returns status code is Bad Request (400)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void startNewProcessWithInvalidVariablesInProcessBody3() throws JsonToModelConversionException, Exception - { - adminUser = dataUser.getAdminUser(); - assignee = dataUser.createRandomTestUser(); - - restClient.authenticateUser(adminUser).withWorkflowAPI(); - RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{\"variables\":{\"bpm_workflowPriority\":2}}", "processes"); - restClient.processModel(RestProcessModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary("Either processDefinitionId or processDefinitionKey is required"); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/AddProcessFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/AddProcessFullTests.java deleted file mode 100644 index 61b609c63..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/AddProcessFullTests.java +++ /dev/null @@ -1,150 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes; - -import javax.json.JsonObject; - -import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.core.JsonBodyGenerator; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * - * @author Cristina Axinte - * - */ -public class AddProcessFullTests extends RestTest -{ - private UserModel userWhoStartsProcess, assignee; - RestProcessModel addedProcess; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - assignee = dataUser.createRandomTestUser(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify user cannot start new process with invalid processDefinitionKey using REST API and status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void userStartsNewProcessWithInvalidProcessDefinitionKey() throws JsonToModelConversionException, Exception - { - userWhoStartsProcess = dataUser.createRandomTestUser(); - - addedProcess = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcess("activitiAdhocc", assignee, false, Priority.Normal); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(String.format(RestErrorModel.NO_WORKFLOW_DEFINITION_FOUND, "activitiAdhocc")) - .containsSummary(String.format(RestErrorModel.NO_WORKFLOW_DEFINITION_FOUND, "activitiAdhocc")) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } - - @Bug(id = "REPO-1970") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify user cannot start new process with invalid processDefinitionKey using REST API and status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void userStartsNewProcessWithEmptyVariablesBody() throws JsonToModelConversionException, Exception - { - userWhoStartsProcess = dataUser.createRandomTestUser(); - - JsonObject postJson = JsonBodyGenerator.defineJSON() - .add("processDefinitionKey", "activitiAdhoc") - .add("variables", - JsonBodyGenerator.defineJSON().build() - ).build(); - addedProcess = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcessWithBody(postJson); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(String.format(RestErrorModel.NO_WORKFLOW_DEFINITION_FOUND, "activitiAdhoc")); - } - - @Bug(id = "REPO-1970") - @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify user cannot start new process with invalid processDefinitionKey using REST API and status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void userStartsNewProcessWithNoAssigneeInVariablesBody() throws JsonToModelConversionException, Exception - { - userWhoStartsProcess = dataUser.createRandomTestUser(); - - JsonObject postJson = JsonBodyGenerator.defineJSON() - .add("processDefinitionKey", "activitiAdhoc") - .add("variables", - JsonBodyGenerator.defineJSON() - .add("bpm_sendEMailNotifications", false) - .add("bpm_workflowPriority", Priority.Low.getLevel()).build() - ).build(); - addedProcess = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcessWithBody(postJson); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(String.format(RestErrorModel.NO_WORKFLOW_DEFINITION_FOUND, "activitiAdhoc")); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify user cannot start new process with invalid assignee using REST API and status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void userStartsNewProcessWithInvalidAssignee() throws JsonToModelConversionException, Exception - { - userWhoStartsProcess = dataUser.createRandomTestUser(); - UserModel invalidAssignee = new UserModel("invalidAssignee", "password"); - - addedProcess = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcess("activitiAdhoc", invalidAssignee, false, Priority.Normal); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(String.format(RestErrorModel.INVALID_USER_ID, invalidAssignee.getUsername())) - .containsSummary(String.format(RestErrorModel.INVALID_USER_ID, invalidAssignee.getUsername())) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } - - @Bug(id = "REPO-1970") - @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify user cannot start new process with invalid sendEMailNotifications value using REST API and status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void userStartsNewProcessWithInvalidEmailNotification() throws JsonToModelConversionException, Exception - { - userWhoStartsProcess = dataUser.createRandomTestUser(); - JsonObject postJson = JsonBodyGenerator.defineJSON() - .add("processDefinitionKey", "activitiAdhoc") - .add("variables", - JsonBodyGenerator.defineJSON() - .add("bpm_assignee", assignee.getUsername()) - .add("bpm_sendEMailNotifications", "111") - .add("bpm_workflowPriority", Priority.Low.getLevel()).build() - ).build(); - - addedProcess = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcessWithBody(postJson); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(String.format(RestErrorModel.UNSUPPORTED_TYPE, "111")) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } - - @Bug(id = "REPO-1970") - @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify user cannot start new process with invalid priority using REST API and status code is 400") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void userStartsNewProcessWithInvalidPriority() throws JsonToModelConversionException, Exception - { - userWhoStartsProcess = dataUser.createRandomTestUser(); - JsonObject postJson = JsonBodyGenerator.defineJSON() - .add("processDefinitionKey", "activitiAdhoc") - .add("variables", - JsonBodyGenerator.defineJSON() - .add("bpm_assignee", assignee.getUsername()) - .add("bpm_sendEMailNotifications", false) - .add("bpm_workflowPriority", "test").build() - ).build(); - - addedProcess = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcessWithBody(postJson); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(String.format(RestErrorModel.UNSUPPORTED_TYPE, "test")) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/AddProcessSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/AddProcessSanityTests.java deleted file mode 100644 index 4be323242..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/AddProcessSanityTests.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes; - -import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.model.RestProcessModelsCollection; -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.Test; - -/** - * Created by Claudia Agache on 10/18/2016. - */ -public class AddProcessSanityTests extends RestTest -{ - private UserModel userWhoStartsProcess, assignee; - private RestProcessModel addedProcess; - private RestProcessModelsCollection processes; - - @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW, - TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Verify non network user is able to start new process using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) - public void nonNetworkUserStartsNewProcess() throws JsonToModelConversionException, Exception - { - userWhoStartsProcess = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - - addedProcess = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - addedProcess.assertThat().field("id").is(addedProcess.getId()) - .and().field("startUserId").is(addedProcess.getStartUserId()); - - processes = restClient.withWorkflowAPI().getProcesses(); - restClient.assertStatusCodeIs(HttpStatus.OK); - processes.assertThat().entriesListContains("id", addedProcess.getId()); - - } - -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/DeleteProcessCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/DeleteProcessCoreTests.java deleted file mode 100644 index 8d0525e1e..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/DeleteProcessCoreTests.java +++ /dev/null @@ -1,69 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes; - -import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class DeleteProcessCoreTests extends RestTest -{ - private UserModel userWhoAddsProcess, assignee; - private RestProcessModel process; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - userWhoAddsProcess = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW, - TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify admin user is able to delete a process started by another user.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void deleteProcessByAdminUser() throws Exception - { - process = restClient.authenticateUser(userWhoAddsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.authenticateUser(dataUser.getAdminUser()) - .withWorkflowAPI().usingProcess(process).deleteProcess(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withWorkflowAPI().getProcesses() - .assertThat().entriesListDoesNotContain("id", process.getId()); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW, - TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify User is not able to delete process with invalid id") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void deleteProcessWithInvalidId() throws Exception - { - process = restClient.authenticateUser(userWhoAddsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - process.setId("00001"); - restClient.withWorkflowAPI().usingProcess(process).deleteProcess(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "00001")); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW, - TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify User is not able to delete process with empty id") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void deleteProcessWithEmptyId() throws Exception - { - process = restClient.authenticateUser(userWhoAddsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - process.setId(""); - restClient.withWorkflowAPI().usingProcess(process).deleteProcess(); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) - .assertLastError().containsSummary(RestErrorModel.DELETE_EMPTY_ARGUMENT); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/DeleteProcessFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/DeleteProcessFullTests.java deleted file mode 100644 index dad9826f2..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/DeleteProcessFullTests.java +++ /dev/null @@ -1,52 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes; - -import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestProcessModel; -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 Cristina Axinte - * - */ -public class DeleteProcessFullTests extends RestTest -{ - private UserModel userWhoAddsProcess, assignee; - private RestProcessModel process; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - userWhoAddsProcess = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify user is NOT able to delete process started by him twice using REST API and status code is NOT FOUND (404)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void deleteProcessByUserWhoStartedProcessTwice() throws Exception - { - process = restClient.authenticateUser(userWhoAddsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.withWorkflowAPI().usingProcess(process).deleteProcess(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withWorkflowAPI().usingProcess(process).deleteProcess(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.ENTITY_WAS_NOT_FOUND, process.getId())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - - restClient.withWorkflowAPI().getProcesses().assertThat().entriesListDoesNotContain("id", process.getId()); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/DeleteProcessSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/DeleteProcessSanityTests.java deleted file mode 100644 index 6cea148d8..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/DeleteProcessSanityTests.java +++ /dev/null @@ -1,69 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes; - -import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestProcessModel; -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; - -/** - * Created by Claudia Agache on 10/12/2016. - */ -public class DeleteProcessSanityTests extends RestTest -{ - private UserModel userWhoAddsProcess, assignee, anotherUser; - private RestProcessModel process; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - userWhoAddsProcess = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - anotherUser = dataUser.createRandomTestUser(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Verify User is able to delete process started by him using REST API and status code is OK (204)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) - public void deleteProcessByUserWhoStartedProcess() throws Exception - { - process = restClient.authenticateUser(userWhoAddsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.withWorkflowAPI().usingProcess(process).deleteProcess(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withWorkflowAPI().getProcesses().assertThat().entriesListDoesNotContain("id", process.getId()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Verify User is able to delete process assigned to him using REST API and status code is OK (204)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) - public void deleteProcessByAssignedUser() throws Exception - { - process = restClient.authenticateUser(userWhoAddsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(process).deleteProcess(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withWorkflowAPI().getProcesses().assertThat().entriesListDoesNotContain("id", process.getId()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Verify User that is not involved in a process is not authorized to delete it using REST API and status code is 403") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) - public void deleteProcessByAnotherUser() throws Exception - { - process = restClient.authenticateUser(userWhoAddsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(anotherUser).withWorkflowAPI().usingProcess(process).deleteProcess(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("user is not allowed to access information about process"); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessCoreTests.java deleted file mode 100644 index bc97bb842..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessCoreTests.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.apache.commons.lang3.RandomStringUtils; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class GetProcessCoreTests extends RestTest -{ - private UserModel userWhoStartsProcess, assignee; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - userWhoStartsProcess = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify that using invalid process ID returns status code 404") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION}) - public void invalidProcessIdTest() throws Exception - { - RestProcessModel newProcess = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.High); - String processId = RandomStringUtils.randomAlphanumeric(10); - newProcess.setId(processId); - restClient.authenticateUser(dataUser.getAdminUser()) - .withWorkflowAPI().usingProcess(newProcess).getProcess(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, processId)) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } -} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessFullTests.java deleted file mode 100644 index e7214bba5..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessFullTests.java +++ /dev/null @@ -1,85 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestProcessDefinitionModel; -import org.alfresco.rest.model.RestProcessModel; -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 Cristina Axinte - * - */ -public class GetProcessFullTests extends RestTest -{ - private UserModel userWhoStartsProcess, assignee; - private RestProcessModel addedProcess, process; - private RestProcessDefinitionModel adhocProcessDefinition; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - userWhoStartsProcess = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - addedProcess = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.High); - adhocProcessDefinition = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getAllProcessDefinitions().getProcessDefinitionByKey("activitiAdhoc"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify user is able to get the process with properties parameter applied using REST API") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void getProcessWithPropertiesParameter() throws Exception - { - process = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingParams("properties=startUserId,id").usingProcess(addedProcess).getProcess(); - restClient.assertStatusCodeIs(HttpStatus.OK); - process.assertThat().fieldsCount().is(2) - .and().field("startUserId").is(addedProcess.getStartUserId()) - .and().field("id").is(addedProcess.getId()) - .and().field("processDefinitionKey").isNull(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify user is able to get a process that was deleted, but it has 'deleted through REST API call' deleteReason") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void getDeletedProcess() throws Exception - { - addedProcess = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.High); - - process = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingProcess(addedProcess).getProcess(); - restClient.assertStatusCodeIs(HttpStatus.OK); - process.assertThat() - .field("processDefinitionId").is(adhocProcessDefinition.getId()) - .and().field("startUserId").is(addedProcess.getStartUserId()) - .and().field("startActivityId").is("start") - .and().field("startedAt").isNotEmpty() - .and().field("id").is(addedProcess.getId()) - .and().field("completed").is(false) - .and().field("processDefinitionKey").is("activitiAdhoc"); - - restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingProcess(addedProcess).deleteProcess(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - process = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingProcess(addedProcess).getProcess(); - restClient.assertStatusCodeIs(HttpStatus.OK); - process.assertThat() - .field("processDefinitionId").is(adhocProcessDefinition.getId()) - .and().field("durationInMs").isNotNull() - .and().field("startUserId").is(addedProcess.getStartUserId()) - .and().field("startActivityId").is("start") - .and().field("endedAt").isNotEmpty() - .and().field("startedAt").isNotEmpty() - .and().field("id").is(addedProcess.getId()) - .and().field("completed").is(true) - .and().field("deleteReason").is("deleted through REST API call") - .and().field("processDefinitionKey").is("activitiAdhoc"); - - restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().assertThat().entriesListDoesNotContain("id", process.getId()); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessSanityTests.java deleted file mode 100644 index 33649ebf5..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessSanityTests.java +++ /dev/null @@ -1,62 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestProcessModel; -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; - -/** - * Created by Claudia Agache on 10/19/2016. - */ -public class GetProcessSanityTests extends RestTest -{ - private UserModel userWhoStartsProcess, assignee; - private RestProcessModel addedProcess, process; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - userWhoStartsProcess = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - addedProcess = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.High); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Verify user is able to get the process started by him using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) - public void getProcessByOwner() throws Exception - { - process = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingProcess(addedProcess).getProcess(); - restClient.assertStatusCodeIs(HttpStatus.OK); - process.assertThat().field("id").is(addedProcess.getId()) - .and().field("startUserId").is(addedProcess.getStartUserId()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Verify user is able to get the process assigned to him using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) - public void getProcessByAssignee() throws Exception - { - process = restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(addedProcess).getProcess(); - restClient.assertStatusCodeIs(HttpStatus.OK); - process.assertThat().field("id").is(addedProcess.getId()) - .and().field("startUserId").is(addedProcess.getStartUserId()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Verify admin is able to get any process using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) - public void getProcessByAdmin() throws Exception - { - process = restClient.authenticateUser(dataUser.getAdminUser()).withWorkflowAPI().usingProcess(addedProcess).getProcess(); - restClient.assertStatusCodeIs(HttpStatus.OK); - process.assertThat().field("id").is(addedProcess.getId()) - .and().field("startUserId").is(addedProcess.getStartUserId()); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessesCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessesCoreTests.java deleted file mode 100644 index d2532d36a..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessesCoreTests.java +++ /dev/null @@ -1,80 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes; - -import java.util.List; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestProcessDefinitionModel; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.model.RestProcessModelsCollection; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.ProcessModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TaskModel; -import org.alfresco.utility.model.TestGroup; -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 Cristina Axinte - * - */ -public class GetProcessesCoreTests extends RestTest -{ - private FileModel document; - private SiteModel siteModel; - private UserModel adminUser, userWhoStartsTask, assignee ; - private TaskModel task1, task2; - private ProcessModel process3; - private RestProcessDefinitionModel adhocProcessDefinition; - private RestProcessDefinitionModel activitiReviewProcessDefinition; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userWhoStartsTask = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - task1 = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); - task2 = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(adminUser); - process3 = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createSingleReviewerTaskAndAssignTo(assignee); - adhocProcessDefinition = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getAllProcessDefinitions().getProcessDefinitionByKey("activitiAdhoc"); - activitiReviewProcessDefinition = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getAllProcessDefinitions().getProcessDefinitionByKey("activitiReview"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify user gets all processes started by him ordered descending by id") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void getProcessesOrderedByIdDESC() throws Exception - { - RestProcessModelsCollection processes = restClient.authenticateUser(userWhoStartsTask).withParams("orderBy=id DESC") - .withWorkflowAPI().getProcesses(); - restClient.assertStatusCodeIs(HttpStatus.OK); - processes.assertThat().entriesListIsNotEmpty(); - List processesList = processes.getEntries(); - processesList.get(0).onModel().assertThat().field("id").is(process3.getId()); - processesList.get(1).onModel().assertThat().field("id").is(task2.getProcessId()); - processesList.get(2).onModel().assertThat().field("id").is(task1.getProcessId()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify user gets processes that matches a where clause") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void getProcessesWithWhereClauseAsParameter() throws JsonToModelConversionException, Exception - { - RestProcessModelsCollection processes = restClient.authenticateUser(userWhoStartsTask).where("processDefinitionKey='activitiReview'") - .withWorkflowAPI().getProcesses(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - processes.assertThat().entriesListIsNotEmpty().and().entriesListContains("processDefinitionId", activitiReviewProcessDefinition.getId()) - .and().entriesListDoesNotContain("processDefinitionId", adhocProcessDefinition.getId()); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessesFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessesFullTests.java deleted file mode 100644 index 0c5b63b5e..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessesFullTests.java +++ /dev/null @@ -1,160 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes; - -import java.util.List; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.model.RestProcessModelsCollection; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.ProcessModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TaskModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * - * @author Cristina Axinte - * - */ -public class GetProcessesFullTests extends RestTest -{ - private FileModel document; - private SiteModel siteModel; - private UserModel adminUser, userWhoStartsTask, assignee; - private TaskModel task1, task2; - private ProcessModel process3; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userWhoStartsTask = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - task1 = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); - task2 = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(adminUser); - process3 = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createSingleReviewerTaskAndAssignTo(assignee); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify user gets processes when skipCount parameter is applied") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void getProcessesWithSkipCountParameter() throws Exception - { - RestProcessModelsCollection processes = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getProcesses(); - restClient.assertStatusCodeIs(HttpStatus.OK); - processes.assertThat().paginationField("count").is("3"); - RestProcessModel process1 = processes.getEntries().get(0).onModel(); - RestProcessModel process2 = processes.getEntries().get(1).onModel(); - RestProcessModel process3 = processes.getEntries().get(2).onModel(); - - processes = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingParams("skipCount=2").getProcesses(); - restClient.assertStatusCodeIs(HttpStatus.OK); - processes.assertThat().paginationField("count").is("1"); - processes.assertThat().paginationField("skipCount").is("2"); - processes.assertThat().entriesListDoesNotContain("id", process1.getId()); - processes.assertThat().entriesListDoesNotContain("id", process2.getId()); - processes.getEntries().get(0).onModel().assertThat().field("id").is(process3.getId()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify user gets processes when maxItems parameter is applied") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void getProcessesWithMaxItemsParameter() throws Exception - { - RestProcessModelsCollection processes = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getProcesses(); - restClient.assertStatusCodeIs(HttpStatus.OK); - processes.assertThat().paginationField("count").is("3"); - RestProcessModel process1 = processes.getEntries().get(0).onModel(); - RestProcessModel process2 = processes.getEntries().get(1).onModel(); - RestProcessModel process3 = processes.getEntries().get(2).onModel(); - - processes = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingParams("maxItems=2").getProcesses(); - restClient.assertStatusCodeIs(HttpStatus.OK); - processes.assertThat().paginationField("count").is("2"); - processes.assertThat().paginationField("maxItems").is("2"); - processes.assertThat().entriesListDoesNotContain("id", process3.getId()); - processes.getEntries().get(0).onModel().assertThat().field("id").is(process1.getId()); - processes.getEntries().get(1).onModel().assertThat().field("id").is(process2.getId()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify user gets processes when properties parameter is applied") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void getProcessesWithPropertiesParameter() throws Exception - { - RestProcessModelsCollection processes = restClient.authenticateUser(userWhoStartsTask).withParams("properties=id") - .withWorkflowAPI().getProcesses(); - restClient.assertStatusCodeIs(HttpStatus.OK); - List processesList = processes.getEntries(); - processesList.get(0).onModel().assertThat().fieldsCount().is(1) - .and().field("id").isNotEmpty() - .and().field("processDefinitionId").isNull() - .and().field("startUserId").isNull(); - processesList.get(1).onModel().assertThat().fieldsCount().is(1) - .and().field("id").isNotEmpty() - .and().field("processDefinitionId").isNull() - .and().field("startUserId").isNull(); - processesList.get(2).onModel().assertThat().fieldsCount().is(1) - .and().field("id").isNotEmpty() - .and().field("processDefinitionId").isNull() - .and().field("startUserId").isNull(); - processes.assertThat().entriesListIsNotEmpty() - .and().entriesListContains("id", process3.getId()) - .and().entriesListContains("id", task2.getProcessId()) - .and().entriesListContains("id", task1.getProcessId()); - } - - @Bug(id = "REPO-1958") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify user cannot get processes when using an invalid orderBy parameter") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void getProcessesWithInvalidOrderByParameter() throws Exception - { - restClient.authenticateUser(userWhoStartsTask).withParams("orderBy=test") - .withWorkflowAPI().getProcesses(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(String.format(RestErrorModel.INVALID_ORDERBY, "test", "processDefinitionId, startUserId, startActivityId,startedAt, id, completed, processDefinitionKey")) - .containsSummary(String.format(RestErrorModel.INVALID_ORDERBY, "test", "processDefinitionId, startUserId, startActivityId,startedAt, id, completed, processDefinitionKey")) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify user cannot get processes when using an invalid parameter in where clause") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void getProcessesWithInvalidWhereParameter() throws Exception - { - restClient.authenticateUser(userWhoStartsTask).where("startUserIdd='" + userWhoStartsTask.getUsername() + "'") - .withWorkflowAPI().getProcesses(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(RestErrorModel.INVALID_PROPERTY_ERRORKEY) - .containsSummary(String.format(RestErrorModel.PROPERTY_IS_NOT_SUPPORTED_EQUALS, "startUserIdd", userWhoStartsTask.getUsername())) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify user cannot get processes when using an invalid where clause expression") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void getProcessesWithInvalidWhereClauseExpression() throws Exception - { - restClient.authenticateUser(userWhoStartsTask).where("startUserId AND '" + userWhoStartsTask.getUsername() + "'") - .withWorkflowAPI().getProcesses(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(RestErrorModel.INVALID_QUERY_ERRORKEY) - .containsSummary(String.format(RestErrorModel.INVALID_WHERE_QUERY, "(startUserId AND '" + userWhoStartsTask.getUsername() + "')")) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessesSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessesSanityTests.java deleted file mode 100644 index 58d5b8032..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/GetProcessesSanityTests.java +++ /dev/null @@ -1,78 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestProcessModelsCollection; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TaskModel; -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; - -/** - * Created by Claudia Agache on 10/11/2016. - */ -public class GetProcessesSanityTests extends RestTest -{ - private FileModel document; - private SiteModel siteModel; - private UserModel userWhoStartsTask, assignee, anotherUser; - private TaskModel task; - private RestProcessModelsCollection allProcesses; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - userWhoStartsTask = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - anotherUser = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - task = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Verify User gets all processes started by him using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) - public void getProcessesByUserWhoStartedProcess() throws Exception - { - allProcesses = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getProcesses(); - restClient.assertStatusCodeIs(HttpStatus.OK); - allProcesses.assertThat().entriesListContains("id", task.getProcessId()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Verify User gets all processes assigned to him using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) - public void getProcessesByAssignedUser() throws Exception - { - allProcesses = restClient.authenticateUser(assignee).withWorkflowAPI().getProcesses(); - restClient.assertStatusCodeIs(HttpStatus.OK); - allProcesses.assertThat().entriesListContains("id", task.getProcessId()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Verify User that is not involved in a process can not get that process using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) - public void getProcessesByAnotherUser() throws Exception - { - allProcesses = restClient.authenticateUser(anotherUser).withWorkflowAPI().getProcesses(); - restClient.assertStatusCodeIs(HttpStatus.OK); - allProcesses.assertThat().entriesListDoesNotContain("id", task.getProcessId()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Verify Admin gets all processes, even if he isn't involved in a process, using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) - public void getProcessesByAdmin() throws Exception - { - allProcesses = restClient.authenticateUser(dataUser.getAdminUser()).withWorkflowAPI().getProcesses(); - restClient.assertStatusCodeIs(HttpStatus.OK); - allProcesses.assertThat().entriesListContains("id", task.getProcessId()); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/AddProcessItemCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/AddProcessItemCoreTests.java deleted file mode 100644 index 86e6d4489..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/AddProcessItemCoreTests.java +++ /dev/null @@ -1,181 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes.items; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.core.RestRequest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestItemModel; -import org.alfresco.rest.model.RestItemModelsCollection; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.model.RestProcessModelsCollection; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class AddProcessItemCoreTests extends RestTest -{ - private FileModel document, document2; - private SiteModel siteModel; - private UserModel userWhoStartsProcess, assignee, adminUser, anotherUser; - private RestProcessModel processModel; - private RestItemModel processItem; - private RestItemModelsCollection processItems; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userWhoStartsProcess = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - document2 = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Add process item using by the user who started the process.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void addProcessItemByUserThatStartedTheProcess() throws Exception - { - processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); - - restClient.assertStatusCodeIs(HttpStatus.CREATED); - processItem.assertThat().field("createdAt").isNotEmpty().and().field("size").is("19").and().field("createdBy").is(adminUser.getUsername()).and() - .field("modifiedAt").isNotEmpty().and().field("name").is(document.getName()).and().field("modifiedBy").is(userWhoStartsProcess.getUsername()) - .and().field("id").isNotEmpty().and().field("mimeType").is(document.getFileType().mimeType); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Add multiple process items using by the user who started the process.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void addMultipleProcessItemsByUserThatStartedTheProcess() throws Exception - { - processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - processItems = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItems(document, document2); - - restClient.assertStatusCodeIs(HttpStatus.CREATED); - processItems.getEntries().get(0).onModel().assertThat() - .field("createdAt").isNotEmpty().and() - .field("size").is("19").and() - .field("createdBy").is(adminUser.getUsername()).and() - .field("modifiedAt").isNotEmpty().and() - .field("name").is(document.getName()).and() - .field("modifiedBy").is(userWhoStartsProcess.getUsername()).and() - .field("id").isNotEmpty().and() - .field("mimeType").is(document.getFileType().mimeType); - processItems.getEntries().get(1).onModel().assertThat() - .field("createdAt").isNotEmpty().and() - .field("size").is("19").and() - .field("createdBy").is(adminUser.getUsername()).and() - .field("modifiedAt").isNotEmpty().and() - .field("name").is(document2.getName()).and() - .field("modifiedBy").is(userWhoStartsProcess.getUsername()).and() - .field("id").isNotEmpty().and() - .field("mimeType").is(document2.getFileType().mimeType); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Add process item by a random user.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void addProcessItemByAnyUser() throws Exception - { - anotherUser = dataUser.createRandomTestUser(); - - document2 = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - processModel = restClient.authenticateUser(adminUser).withParams("maxItems=1").withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - processItem = restClient.authenticateUser(anotherUser).withWorkflowAPI().usingProcess(processModel).addProcessItem(document2); - - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsSummary(String.format(RestErrorModel.ACCESS_INFORMATION_NOT_ALLOWED, processModel.getId())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Add multiple process item by a random user.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void addMultipleProcessItemByAnyUser() throws Exception - { - anotherUser = dataUser.createRandomTestUser(); - - document2 = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - processModel = restClient.authenticateUser(adminUser).withParams("maxItems=1").withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - processItems = restClient.authenticateUser(anotherUser).withWorkflowAPI().usingProcess(processModel) - .addProcessItems(document2, document); - - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsSummary(String.format(RestErrorModel.ACCESS_INFORMATION_NOT_ALLOWED, processModel.getId())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding process item is falling in case of invalid process id is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void failedAddingProcessItemIfInvalidProcessIdIsProvided() throws Exception - { - RestProcessModelsCollection processes = restClient.authenticateUser(adminUser).withParams("maxItems=1").withWorkflowAPI().getProcesses(); - processModel = processes.assertThat().entriesListIsNotEmpty().when().getOneRandomEntry().onModel(); - FileModel testDocument = dataContent.usingAdmin().usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - - processModel.setId("invalidProcessId"); - processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(testDocument); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidProcessId")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding multiple process items is falling in case of invalid process id is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void failedAddingMultipleProcessItemsIfInvalidProcessIdIsProvided() throws Exception - { - RestProcessModelsCollection processes = restClient.authenticateUser(adminUser).withParams("maxItems=1").withWorkflowAPI().getProcesses(); - processModel = processes.assertThat().entriesListIsNotEmpty().when().getOneRandomEntry().onModel(); - FileModel testDocument = dataContent.usingAdmin().usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - - processModel.setId("invalidProcessId"); - processItems = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItems(testDocument, document); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidProcessId")); - } - - @Bug(id = "REPO-1937") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding process item is falling in case of invalid body item is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void failedAddingProcessItemIfInvalidItemBodyIsProvided() throws Exception - { - document.setNodeRef("invalidNodeRef"); - processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidId")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding multiple process items is falling in case of empty body item value is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void failedAddingMultipleProcessItemIfEmptyItemBodyIsProvided() throws Exception - { - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - document.setNodeRef(""); - processItems = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItems(document, document2); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.REQUIRED_TO_ADD, "itemId")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding process item is falling in case of incomplete body (empty) is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void failedAddingProcessItemIfIncompleteBodyIsProvided() throws Exception - { - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{}", "processes/{processId}/items", processModel.getId()); - restClient.processModel(RestItemModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.REQUIRED_TO_ADD, "itemId")); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/AddProcessItemFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/AddProcessItemFullTests.java deleted file mode 100644 index 49a8f28a2..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/AddProcessItemFullTests.java +++ /dev/null @@ -1,131 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes.items; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestItemModel; -import org.alfresco.rest.model.RestItemModelsCollection; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.ProcessModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class AddProcessItemFullTests extends RestTest -{ - private FileModel document, document2; - private SiteModel siteModel; - private UserModel userWhoStartsProcess, assignee, adminUser; - private ProcessModel processModel; - private RestItemModel processItem; - private RestItemModelsCollection processItems; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userWhoStartsProcess = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - document2 = dataContent.usingSite(siteModel).createContent(DocumentType.MSPOWERPOINT); - dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding multiple process items is falling in case of empty process id is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void failedAddingMultipleProcessItemsIfEmptyProcessIdIsProvided() throws Exception - { - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - FileModel testDocument = dataContent.usingAdmin().usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - - processModel.setId(""); - processItems = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItems(testDocument, document); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_WAS_NOT_FOUND, "")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding process items is falling in case of empty process id is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void failedAddingProcessItemsIfEmptyProcessIdIsProvided() throws Exception - { - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - FileModel testDocument = dataContent.usingAdmin().usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - - processModel.setId(""); - processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(testDocument); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_WAS_NOT_FOUND, "")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding process item is falling in case of empty body item value is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void failedAddingProcessItemIfEmptyItemBodyIsProvided() throws Exception - { - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - document.setNodeRef(""); - processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.REQUIRED_TO_ADD, "itemId")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding multiple process items is falling in case of empty body item value is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void failedAddingMultipleProcessItemsIfEmptyItemBodyIsProvided() throws Exception - { - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - document.setNodeRef(""); - - processItems = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItems(document, document2); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.REQUIRED_TO_ADD, "itemId")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Add a new process item, update the item and then delete.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void createDeleteCreateMultipleProcessItems() throws Exception - { - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - document2 = dataContent.usingAdmin().usingSite(siteModel).createContent(DocumentType.MSPOWERPOINT); - processItems = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItems(document, document2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.withWorkflowAPI().usingProcess(processModel).deleteProcessItem(processItems.getEntries().get(0).onModel()); - - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems() - .assertThat().entriesListDoesNotContain("name", processItems.getEntries().get(0).onModel().getName()); - - processItems = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItems(document); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Add a new process item, delete the item and create it again.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void createDeleteCreateProcessItem() throws Exception - { - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem( document2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.withWorkflowAPI().usingProcess(processModel).deleteProcessItem(processItem); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems() - .assertThat().entriesListDoesNotContain("name", processItem.getName()); - - processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems() - .assertThat().entriesListContains("name", processItem.getName()); - } - -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/AddProcessItemSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/AddProcessItemSanityTests.java deleted file mode 100644 index e31365974..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/AddProcessItemSanityTests.java +++ /dev/null @@ -1,175 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes.items; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestItemModel; -import org.alfresco.rest.model.RestItemModelsCollection; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.FileType; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -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 AddProcessItemSanityTests extends RestTest -{ - private FileModel document, document2; - private SiteModel siteModel; - private UserModel userWhoStartsTask, assignee, adminUser; - private RestProcessModel processModel; - private RestItemModel processItem; - private RestItemModelsCollection processItems; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userWhoStartsTask = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Create non-existing process item") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY}) - public void addProcessItem() throws JsonToModelConversionException, Exception - { - document2 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file content"); - dataContent.usingSite(siteModel).createContent(document2); - - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - processItem.assertThat().field("createdAt").isNotEmpty() - .and().field("size").is(document2.getContent().length()) - .and().field("createdBy").is(adminUser.getUsername()) - .and().field("modifiedAt").isNotEmpty() - .and().field("name").is(document2.getName()) - .and().field("modifiedBy").is(adminUser.getUsername()) - .and().field("id").isNotEmpty() - .and().field("mimeType").is(document2.getFileType().mimeType); - - restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems() - .assertThat().entriesListContains("id", processItem.getId()); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Create non-existing process item") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY}) - public void addMultipleProcessItem() throws JsonToModelConversionException, Exception - { - document2 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file content"); - dataContent.usingSite(siteModel).createContent(document2); - document = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file content"); - dataContent.usingSite(siteModel).createContent(document); - - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - processItems = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItems(document2, document); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - processItems.getEntries().get(0).onModel() - .assertThat().field("createdAt").isNotEmpty() - .and().field("size").is(document2.getContent().length()) - .and().field("createdBy").is(adminUser.getUsername()) - .and().field("modifiedAt").isNotEmpty() - .and().field("name").is(document2.getName()) - .and().field("modifiedBy").is(adminUser.getUsername()) - .and().field("id").isNotEmpty() - .and().field("mimeType").is(document2.getFileType().mimeType); - - processItems.getEntries().get(1).onModel() - .assertThat().field("createdAt").isNotEmpty() - .and().field("size").is(document.getContent().length()) - .and().field("createdBy").is(adminUser.getUsername()) - .and().field("modifiedAt").isNotEmpty() - .and().field("name").is(document.getName()) - .and().field("modifiedBy").is(adminUser.getUsername()) - .and().field("id").isNotEmpty() - .and().field("mimeType").is(document.getFileType().mimeType); - - restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems() - .assertThat().entriesListContains("id", processItems.getEntries().get(0).onModel().getId()) - .assertThat().entriesListContains("id", processItems.getEntries().get(1).onModel().getId()); - } - - @Bug(id= "REPO-1927") - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Add process item that already exists") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY}) - public void addProcessItemThatAlreadyExists() throws JsonToModelConversionException, Exception - { - document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - processItem.assertThat().field("createdAt").isNotEmpty() - .and().field("size").is("19") - .and().field("createdBy").is(adminUser.getUsername()) - .and().field("modifiedAt").isNotEmpty() - .and().field("name").is(document2.getName()) - .and().field("modifiedBy").is(adminUser.getUsername()) - .and().field("id").isNotEmpty() - .and().field("mimeType").is(document2.getFileType().mimeType); - - restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems() - .assertThat().entriesListContains("id", processItem.getId()) - .and().entriesListContains("name", document2.getName()); - restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document2); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - } - - @Bug(id= "REPO-1927") - @TestRail(section = {TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Add process item that already exists") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY}) - public void addMultipleProcessItemThatAlreadyExists() throws JsonToModelConversionException, Exception - { - document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - document = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - processItems = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItems(document2, document); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - processItems.getEntries().get(0).onModel() - .assertThat().field("createdAt").isNotEmpty() - .and().field("size").is("19") - .and().field("createdBy").is(adminUser.getUsername()) - .and().field("modifiedAt").isNotEmpty() - .and().field("name").is(document2.getName()) - .and().field("modifiedBy").is(adminUser.getUsername()) - .and().field("id").isNotEmpty() - .and().field("mimeType").is(document2.getFileType().mimeType); - - processItems.getEntries().get(1).onModel() - .assertThat().field("createdAt").isNotEmpty() - .and().field("size").is("19") - .and().field("createdBy").is(adminUser.getUsername()) - .and().field("modifiedAt").isNotEmpty() - .and().field("name").is(document.getName()) - .and().field("modifiedBy").is(adminUser.getUsername()) - .and().field("id").isNotEmpty() - .and().field("mimeType").is(document.getFileType().mimeType); - - restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems() - .assertThat().entriesListContains("id", processItems.getEntries().get(0).onModel().getId()) - .and().entriesListContains("name", document2.getName()) - .assertThat().entriesListContains("id", processItems.getEntries().get(1).onModel().getId()) - .and().entriesListContains("name", document.getName()); - - restClient.withWorkflowAPI().usingProcess(processModel).addProcessItems(document2, document); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/DeleteProcessItemCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/DeleteProcessItemCoreTests.java deleted file mode 100644 index ae9d60211..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/DeleteProcessItemCoreTests.java +++ /dev/null @@ -1,85 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes.items; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestItemModel; -import org.alfresco.rest.model.RestItemModelsCollection; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.ProcessModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class DeleteProcessItemCoreTests extends RestTest -{ - private FileModel document, secondDoc; - private SiteModel siteModel; - private UserModel userWhoStartsTask, assignee; - private RestProcessModel restProcessModel; - private ProcessModel processModel; - private RestItemModelsCollection items; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - userWhoStartsTask = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - processModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document) - .createSingleReviewerTaskAndAssignTo(assignee); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Delete process item with invalid id") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void deleteProcessItemWithInvalidItemId() throws Exception - { - restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() - .getProcesses().getProcessModelByProcessDefId(processModel.getId()); - secondDoc = dataContent.usingUser(userWhoStartsTask).usingSite(siteModel).createContent(DocumentType.MSWORD); - RestItemModel processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(secondDoc); - processItem.setId("invalid-id"); - restClient.withWorkflowAPI().usingProcess(processModel).deleteProcessItem(processItem); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.PROCESS_ENTITY_NOT_FOUND, "invalid-id")); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Delete process item with empty id") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void deleteProcessItemWithEmptyItemId() throws Exception - { - restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() - .getProcesses().getProcessModelByProcessDefId(processModel.getId()); - secondDoc = dataContent.usingUser(userWhoStartsTask).usingSite(siteModel).createContent(DocumentType.MSWORD); - RestItemModel processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(secondDoc); - processItem.setId(""); - restClient.withWorkflowAPI().usingProcess(processModel).deleteProcessItem(processItem); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) - .assertLastError().containsSummary(String.format(RestErrorModel.DELETE_EMPTY_ARGUMENT)); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Delete process item twice") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void deleteProcessItemTwice() throws Exception - { - restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() - .getProcesses().getProcessModelByProcessDefId(processModel.getId()); - items = restClient.withWorkflowAPI().usingProcess(restProcessModel).getProcessItems(); - RestItemModel processItem = items.getEntries().get(0); - restClient.withWorkflowAPI().usingProcess(processModel).deleteProcessItem(processItem.onModel()); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withWorkflowAPI().usingProcess(processModel).deleteProcessItem(processItem.onModel()); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.PROCESS_ENTITY_NOT_FOUND, processItem.onModel().getId())); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/DeleteProcessItemFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/DeleteProcessItemFullTests.java deleted file mode 100644 index 2be92a1aa..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/DeleteProcessItemFullTests.java +++ /dev/null @@ -1,215 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes.items; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.exception.EmptyRestModelCollectionException; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestItemModel; -import org.alfresco.rest.model.RestItemModelsCollection; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.ProcessModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class DeleteProcessItemFullTests extends RestTest -{ - private FileModel document, document2; - private SiteModel siteModel; - private UserModel userWhoStartsProcess, assignee, adminUser, anotherUser; - private ProcessModel processModel; - private RestItemModelsCollection items; - private RestItemModel processItem; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userWhoStartsProcess = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userWhoStartsProcess).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Try to delete existing process item using empty processId") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void deleteProcessItemUsingEmptyProcessId() throws Exception - { - processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI() - .addProcess("activitiAdhoc", assignee, false, Priority.Normal); - document2 = dataContent.usingAdmin().usingSite(siteModel).createContent(DocumentType.MSPOWERPOINT); - processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - processModel.setId(""); - restClient.withWorkflowAPI().usingProcess(processModel).deleteProcessItem(processItem); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "The entity with id: ")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Add a new process item, update the item and then delete.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void createUpdateDeleteProcessItem() throws Exception - { - processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI() - .addProcess("activitiAdhoc", assignee, false, Priority.Normal); - document2 = dataContent.usingAdmin().usingSite(siteModel).createContent(DocumentType.MSPOWERPOINT); - processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - processItem.setName("newItemName"); - processItem.assertThat().field("name").is("newItemName"); - - restClient.withWorkflowAPI().usingProcess(processModel).deleteProcessItem(processItem); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems() - .assertThat().entriesListDoesNotContain("name", processItem.getName()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Delete process item using any user.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void deleteProcessItemByAnyUser() throws Exception - { - anotherUser = dataUser.createRandomTestUser(); - - document2 = dataContent.usingAdmin().usingSite(siteModel).createContent(DocumentType.HTML); - processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(anotherUser).withWorkflowAPI().usingProcess(processModel) - .deleteProcessItem(processItem); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError() - .containsSummary(String.format(RestErrorModel.ACCESS_INFORMATION_NOT_ALLOWED, processModel.getId())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .containsErrorKey(String.format(RestErrorModel.ACCESS_INFORMATION_NOT_ALLOWED, processModel.getId())) - .stackTraceIs(RestErrorModel.STACKTRACE);; - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Delete process item with admin.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void deleteProcessItemWithAdmin() throws Exception - { - processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI() - .addProcess("activitiAdhoc", assignee, false, Priority.Normal); - - document2 = dataContent.usingAdmin().usingSite(siteModel).createContent(DocumentType.HTML); - processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(adminUser).withWorkflowAPI().usingProcess(processModel) - .deleteProcessItem(processItem); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() - .assertThat().entriesListDoesNotContain("name", processItem.getName()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Delete process item by the user who is involved in the process.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void deleteProcessItemByUserInvolvedInTheProcess() throws Exception - { - processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI() - .addProcess("activitiAdhoc", assignee, false, Priority.Normal); - - processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(processModel) - .deleteProcessItem(processItem); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() - .assertThat().entriesListDoesNotContain("name", processItem.getName()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Delete process item by the user who started the process.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void deleteProcessItemByUserThatStartedTheProcess() throws Exception - { - processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI() - .addProcess("activitiAdhoc", assignee, false, Priority.Normal); - processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingProcess(processModel) - .deleteProcessItem(processItem); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() - .assertThat().entriesListDoesNotContain("name", processItem.getName()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Delete process item for a deleted process.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void deleteProcessItemsForDeletedProcess() throws Exception - { - processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI() - .addProcess("activitiAdhoc", assignee, false, Priority.Normal); - processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.withWorkflowAPI().usingProcess(processModel).deleteProcess(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withWorkflowAPI().usingProcess(processModel).deleteProcessItem(processItem); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, processModel.getId())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Delete process item by inexistent user.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void deleteProcessItemByInexistentUser() throws Exception - { - processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI() - .addProcess("activitiAdhoc", assignee, false, Priority.Normal); - processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(UserModel.getRandomUserModel()).withWorkflowAPI().usingProcess(processModel) - .deleteProcessItem(processItem); - - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Delete process item for process without items.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION}, - expectedExceptions = EmptyRestModelCollectionException.class) - public void deleteProcessItemsForProcessWithoutItems() throws Exception - { - processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI() - .addProcess("activitiAdhoc", assignee, false, Priority.Normal); - - items = restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems(); - restClient.assertStatusCodeIs(HttpStatus.OK); - items.assertThat().entriesListIsEmpty(); - - restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingProcess(processModel) - .deleteProcessItem(items.getOneRandomEntry()); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/DeleteProcessItemSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/DeleteProcessItemSanityTests.java deleted file mode 100644 index 341dc6fa1..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/DeleteProcessItemSanityTests.java +++ /dev/null @@ -1,67 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes.items; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestItemModel; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.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 DeleteProcessItemSanityTests extends RestTest -{ - private FileModel document, document2; - private SiteModel siteModel; - private UserModel userWhoStartsTask, assignee, adminUser; - private RestProcessModel processModel; - private RestItemModel processItem; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userWhoStartsTask = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); - } - - @TestRail(section = {TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Delete existing process item") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) - public void deleteProcessItem() throws Exception - { - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - document2 = dataContent.usingAdmin().usingSite(siteModel).createContent(DocumentType.MSWORD); - processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.withWorkflowAPI().usingProcess(processModel).deleteProcessItem(processItem); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems() - .assertThat().entriesListDoesNotContain("id", processItem.getId()); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Try to delete existing process item using invalid processId") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) - public void deleteProcessItemUsingInvalidProcessId() throws Exception - { - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - document2 = dataContent.usingAdmin().usingSite(siteModel).createContent(DocumentType.MSPOWERPOINT); - processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - processModel.setId("incorrectProcessId"); - restClient.withWorkflowAPI().usingProcess(processModel).deleteProcessItem(processItem); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/GetProcessItemsCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/GetProcessItemsCoreTests.java deleted file mode 100644 index c121a9d47..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/GetProcessItemsCoreTests.java +++ /dev/null @@ -1,70 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes.items; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class GetProcessItemsCoreTests extends RestTest -{ - private FileModel document; - private SiteModel siteModel; - private UserModel adminUser, userWhoStartsTask, assignee; - private RestProcessModel processModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userWhoStartsTask = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin calling getProcessItems can see anything with REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void getProcessItemsAsAdminReturnsAnything() throws Exception - { - processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document); - - restClient.authenticateUser(adminUser).withWorkflowAPI().usingProcess(processModel).getProcessItems().assertThat().entriesListIsNotEmpty(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify getProcessItems for invalid processId with REST API and status code is NOT_FOUND (404)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void getProcessItemsForInvalidProcessId() throws Exception - { - processModel = restClient.authenticateUser(assignee).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - processModel.setId("invalidProcessId"); - restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems().assertThat().entriesListIsEmpty(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidProcessId")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify getProcessItems for empty processId with REST API and status code is NOT_FOUND (404)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void getProcessItemsForEmptyProcessId() throws Exception - { - processModel = restClient.authenticateUser(assignee).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - processModel.setId(""); - restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems().assertThat().entriesListIsEmpty(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/GetProcessItemsFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/GetProcessItemsFullTests.java deleted file mode 100644 index b22e118db..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/GetProcessItemsFullTests.java +++ /dev/null @@ -1,198 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes.items; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestItemModelsCollection; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Created by Claudia Agache on 2/2/2017. - */ -public class GetProcessItemsFullTests extends RestTest -{ - private FileModel document1, document2, document3; - private SiteModel siteModel; - private UserModel userWhoStartsTask, assignee; - private RestProcessModel processModel; - private RestItemModelsCollection items; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - userWhoStartsTask = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); - document1 = dataContent.usingUser(userWhoStartsTask).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - document2 = dataContent.usingUser(userWhoStartsTask).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - document3 = dataContent.usingUser(userWhoStartsTask).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Get process items for process without items") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION}) - public void getProcessItemsForProcessWithoutItems() throws Exception - { - processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.Normal); - items = restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems(); - restClient.assertStatusCodeIs(HttpStatus.OK); - items.assertThat().entriesListIsEmpty(); - } - - @Bug(id = "REPO-1989") - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Get process items for process with valid skipCount parameter") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION}) - public void getProcessItemsWithValidSkipCount() throws Exception - { - processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.Normal); - restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document1); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document3); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - items = restClient.authenticateUser(assignee).withParams("skipCount=2").withWorkflowAPI().usingProcess(processModel).getProcessItems(); - restClient.assertStatusCodeIs(HttpStatus.OK); - items.assertThat().entriesListContains("name", document3.getName()) - .assertThat().entriesListDoesNotContain("name", document1.getName()) - .assertThat().entriesListDoesNotContain("name", document2.getName()) - .assertThat().entriesListCountIs(1) - .assertThat().paginationField("skipCount").is("2"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Get process items for process with negative skipCount") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION}) - public void getProcessItemsWithNegativeSkipCount() throws Exception - { - processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.Normal); - restClient.authenticateUser(assignee).withParams("skipCount=-2").withWorkflowAPI().usingProcess(processModel).getProcessItems(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT) - .containsErrorKey(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE) - .statusCodeIs(HttpStatus.BAD_REQUEST); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Get process items for process with non numeric skipCount") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION}) - public void getProcessItemsWithNonNumericSkipCount() throws Exception - { - processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.Normal); - restClient.authenticateUser(assignee).withParams("skipCount=A").withWorkflowAPI().usingProcess(processModel).getProcessItems(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "A")); - } - - @Bug(id = "MNT-17438") - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Get process items for process with valid maxItems parameter") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION}) - public void getProcessItemsWithValidMaxItems() throws Exception - { - processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.Normal); - restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document1); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document3); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - items = restClient.authenticateUser(assignee).withParams("maxItems=2").withWorkflowAPI().usingProcess(processModel).getProcessItems(); - restClient.assertStatusCodeIs(HttpStatus.OK); - items.assertThat().entriesListDoesNotContain("name", document3.getName()) - .assertThat().entriesListContains("name", document1.getName()) - .assertThat().entriesListContains("name", document2.getName()) - .assertThat().entriesListCountIs(2) - .assertThat().paginationField("maxItems").is("2"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Get process items for process with negative maxItems") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION}) - public void getProcessItemsWithNegativeMaxItems() throws Exception - { - processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.Normal); - restClient.authenticateUser(assignee).withParams("maxItems=-2").withWorkflowAPI().usingProcess(processModel).getProcessItems(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) - .containsErrorKey(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE) - .statusCodeIs(HttpStatus.BAD_REQUEST); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Get process items for process with non numeric maxItems") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION}) - public void getProcessItemsWithNonNumericMaxItems() throws Exception - { - processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.Normal); - restClient.authenticateUser(assignee).withParams("maxItems=A").withWorkflowAPI().usingProcess(processModel).getProcessItems(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "A")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify get all process items with properties parameter.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void getProcessItemsWithPropertiesParameter() throws Exception - { - processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.Normal); - restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document1); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - items = restClient.authenticateUser(assignee).withParams("properties=createdBy,name,mimeType,size").withWorkflowAPI().usingProcess(processModel).getProcessItems(); - restClient.assertStatusCodeIs(HttpStatus.OK); - items.assertThat().entriesListIsNotEmpty(); - items.getProcessItemByName(document1.getName()) - .assertThat().field("createdBy").is(userWhoStartsTask.getUsername()) - .assertThat().field("name").is(document1.getName()) - .assertThat().field("mimeType").is(document1.getFileType().mimeType) - .assertThat().field("size").isNotNull() - .assertThat().field("modifiedAt").isNull() - .assertThat().field("modifiedBy").isNull() - .assertThat().field("id").isNull() - .assertThat().field("createdAt ").isNull() - .assertThat().fieldsCount().is(4); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify get all process items after process is deleted.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void getProcessItemsAfterDeletingProcess() throws Exception - { - processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.Normal); - restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document1); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.withWorkflowAPI().usingProcess(processModel).deleteProcess(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - items = restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(processModel).getProcessItems(); - restClient.assertStatusCodeIs(HttpStatus.OK); - items.assertThat().entriesListIsNotEmpty(); - items.getProcessItemByName(document1.getName()) - .assertThat().field("createdBy").is(userWhoStartsTask.getUsername()) - .assertThat().field("name").is(document1.getName()) - .assertThat().field("mimeType").is(document1.getFileType().mimeType) - .assertThat().field("size").isNotNull() - .assertThat().field("modifiedAt").isNotNull() - .assertThat().field("modifiedBy").is(userWhoStartsTask.getUsername()) - .assertThat().field("id").is(document1.getNodeRefWithoutVersion()) - .assertThat().field("createdAt ").isNotNull(); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/GetProcessItemsSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/GetProcessItemsSanityTests.java deleted file mode 100644 index 5b293fd0d..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/items/GetProcessItemsSanityTests.java +++ /dev/null @@ -1,59 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes.items; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestItemModelsCollection; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.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 GetProcessItemsSanityTests extends RestTest -{ - private FileModel document; - private SiteModel siteModel; - private UserModel userWhoStartsTask, assignee; - private RestProcessModel processModel; - private RestItemModelsCollection items; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - userWhoStartsTask = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); - document = dataContent.usingUser(userWhoStartsTask).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Verify that user that started the process gets all process items") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) - public void getProcessItemsUsingTheUserWhoStartedProcess() throws Exception - { - processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - items = restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems(); - restClient.assertStatusCodeIs(HttpStatus.OK); - items.assertThat().entriesListIsNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Verify that user that is involved in the process gets all process items") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) - public void getProcessItemsUsingUserInvolvedInProcess() throws Exception - { - processModel = restClient.authenticateUser(assignee).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - items = restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems(); - restClient.assertStatusCodeIs(HttpStatus.OK); - items.assertThat().entriesListIsNotEmpty(); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/tasks/GetProcessTasksCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/tasks/GetProcessTasksCoreTests.java deleted file mode 100644 index fc6b6d3bc..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/tasks/GetProcessTasksCoreTests.java +++ /dev/null @@ -1,98 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes.tasks; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestTaskModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.GroupModel; -import org.alfresco.utility.model.ProcessModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class GetProcessTasksCoreTests extends RestTest -{ - private FileModel document, document1, document2; - private SiteModel siteModel; - private UserModel userWhoStartsProcess, candidate, anotherAssignee, assignee; - private ProcessModel process; - private GroupModel group; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - userWhoStartsProcess = dataUser.createRandomTestUser(); - candidate = dataUser.createRandomTestUser(); - anotherAssignee = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userWhoStartsProcess).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - document1 = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - document2 = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - process = dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document) - .createSingleReviewerTaskAndAssignTo(assignee); - group = dataGroup.createRandomGroup(); - dataGroup.addListOfUsersToGroup(group, candidate); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "getProcessTasks with user that is candidate with REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void getProcessTasksWithUserThatIsCandidate() throws Exception - { - ProcessModel processModel = dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document1) - .createGroupReviewTaskAndAssignTo(group); - - restClient.authenticateUser(candidate).withWorkflowAPI() - .usingProcess(processModel).getProcessTasks().assertThat().entriesListIsNotEmpty() - .and().entriesListContains("assignee", candidate.getUsername()); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "getProcessTasks for invalid processId with REST API and status code is NOT_FOUND (404)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void getProcessTasksUsingInvalidProcessId() throws Exception - { - ProcessModel processModel = process; - processModel.setId("invalidProcessId"); - restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI() - .usingProcess(processModel).getProcessTasks().assertThat().entriesListIsEmpty(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "getProcessTasks for empty processId with REST API and status code is NOT_FOUND (404)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void getProcessTasksUsingEmptyProcessId() throws Exception - { - ProcessModel processModel = process; - processModel.setId(""); - restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI() - .usingProcess(processModel).getProcessTasks().assertThat().entriesListIsEmpty(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "User completes task then getProcessTasks with REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void completeTaskThenGetProcessTasks() throws Exception - { - ProcessModel processModel = dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document2) - .createMoreReviewersWorkflowAndAssignTo(anotherAssignee); - RestTaskModel restTaskModel = restClient.authenticateUser(anotherAssignee).withWorkflowAPI() - .usingProcess(processModel).getProcessTasks().assertThat().entriesListIsNotEmpty().getOneRandomEntry().onModel(); - restTaskModel = restClient.withParams("select=state").withWorkflowAPI().usingTask(restTaskModel).updateTask("completed"); - restTaskModel.assertThat().field("id").is(restTaskModel.getId()).and().field("state").is("completed"); - restClient.withWorkflowAPI().getTasks().assertThat().entriesListIsEmpty(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/tasks/GetProcessTasksFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/tasks/GetProcessTasksFullTests.java deleted file mode 100644 index bdd935e42..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/tasks/GetProcessTasksFullTests.java +++ /dev/null @@ -1,207 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes.tasks; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestTaskModelsCollection; -import org.alfresco.utility.model.*; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Created by Claudia Agache on 2/3/2017. - */ -public class GetProcessTasksFullTests extends RestTest -{ - private FileModel document; - private SiteModel publicSite; - private UserModel adminUser, userWhoStartsProcess, assignee1, assignee2, assignee3; - private ProcessModel processWithSingleTask, processWithMultipleTasks; - private RestTaskModelsCollection processTasks; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userWhoStartsProcess = dataUser.createRandomTestUser(); - assignee1 = dataUser.createRandomTestUser("A_1"); - assignee2 = dataUser.createRandomTestUser("B_2"); - assignee3 = dataUser.createRandomTestUser("C_3"); - publicSite = dataSite.usingUser(userWhoStartsProcess).createPublicRandomSite(); - document = dataContent.usingSite(publicSite).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - processWithSingleTask = dataWorkflow.usingUser(userWhoStartsProcess).usingSite(publicSite).usingResource(document) - .createSingleReviewerTaskAndAssignTo(assignee1); - processWithMultipleTasks = dataWorkflow.usingUser(userWhoStartsProcess).usingSite(publicSite).usingResource(document) - .createMoreReviewersWorkflowAndAssignTo(assignee1, assignee2, assignee3); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify admin user is able to getProcessTasks even if he wasn't involved in process. Check status code is OK") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void getProcessTasksWithAdmin() throws Exception - { - processTasks = restClient.authenticateUser(adminUser).withWorkflowAPI() - .usingProcess(processWithSingleTask).getProcessTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - processTasks.assertThat().entriesListCountIs(1) - .and().entriesListContains("assignee", assignee1.getUsername()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Get process tasks with valid skipCount parameter applied") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION}) - public void getProcessTasksWithValidSkipCount() throws Exception - { - processTasks = restClient.authenticateUser(userWhoStartsProcess) - .withParams("orderBy=assignee ASC&skipCount=2").withWorkflowAPI() - .usingProcess(processWithMultipleTasks).getProcessTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - processTasks.assertThat().entriesListContains("assignee", assignee3.getUsername()) - .assertThat().entriesListDoesNotContain("assignee", assignee1.getUsername()) - .assertThat().entriesListDoesNotContain("assignee", assignee2.getUsername()) - .assertThat().entriesListCountIs(1) - .assertThat().paginationField("skipCount").is("2"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Get process tasks with negative skipCount parameter applied") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION}) - public void getProcessTasksWithNegativeSkipCount() throws Exception - { - restClient.authenticateUser(userWhoStartsProcess) - .withParams("skipCount=-2").withWorkflowAPI() - .usingProcess(processWithMultipleTasks).getProcessTasks(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT) - .containsErrorKey(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE) - .statusCodeIs(HttpStatus.BAD_REQUEST); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Get process tasks with non numeric skipCount parameter applied") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION}) - public void getProcessTasksWithNonNumericSkipCount() throws Exception - { - restClient.authenticateUser(userWhoStartsProcess) - .withParams("skipCount=A").withWorkflowAPI() - .usingProcess(processWithMultipleTasks).getProcessTasks(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "A")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Get process tasks with valid maxItems parameter applied") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION}) - public void getProcessTasksWithValidMaxItems() throws Exception - { - processTasks = restClient.authenticateUser(userWhoStartsProcess) - .withParams("orderBy=assignee ASC&maxItems=2").withWorkflowAPI() - .usingProcess(processWithMultipleTasks).getProcessTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - processTasks.assertThat().entriesListDoesNotContain("assignee", assignee3.getUsername()) - .assertThat().entriesListContains("assignee", assignee1.getUsername()) - .assertThat().entriesListContains("assignee", assignee2.getUsername()) - .assertThat().entriesListCountIs(2) - .assertThat().paginationField("maxItems").is("2"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Get process tasks with negative maxItems parameter applied") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION}) - public void getProcessTasksWithNegativeMaxItems() throws Exception - { - restClient.authenticateUser(userWhoStartsProcess) - .withParams("maxItems=-2").withWorkflowAPI() - .usingProcess(processWithMultipleTasks).getProcessTasks(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) - .containsErrorKey(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE) - .statusCodeIs(HttpStatus.BAD_REQUEST); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Get process tasks with non numeric maxItems parameter applied") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION}) - public void getProcessTasksWithNonNumericMaxItems() throws Exception - { - restClient.authenticateUser(userWhoStartsProcess) - .withParams("maxItems=A").withWorkflowAPI() - .usingProcess(processWithMultipleTasks).getProcessTasks(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "A")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify getProcessTasks with properties parameter") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void getProcessTasksWithPropertiesParameter() throws Exception - { - processTasks = restClient.authenticateUser(adminUser) - .withParams("properties=name,assignee,state").withWorkflowAPI() - .usingProcess(processWithSingleTask).getProcessTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - processTasks.assertThat().entriesListCountIs(1); - processTasks.getOneRandomEntry().onModel().assertThat() - .field("dueAt").isNull().and() - .field("processDefinitionId").isNull().and() - .field("processId").isNull().and() - .field("description").isNull().and() - .field("startedAt").isNull().and() - .field("id").isNull().and() - .field("activityDefinitionId").isNull().and() - .field("priority").isNull().and() - .field("formResourceKey").isNull().and() - .field("name").is("Review Task").and() - .field("state").is("claimed").and() - .field("assignee").is(assignee1.getUsername()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify admin gets Process Tasks ordered by assignee ascendant using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void getProcessTasksOrderedByAssignee() throws Exception - { - processTasks = restClient.authenticateUser(adminUser) - .withParams("orderBy=assignee").withWorkflowAPI() - .usingProcess(processWithMultipleTasks).getProcessTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - processTasks.assertThat().entriesListIsSortedAscBy("assignee"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify admin doesn't get Process Tasks ordered by many fields") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void getProcessTasksOrderedByMultipleFields() throws Exception - { - restClient.authenticateUser(adminUser) - .withParams("orderBy=assignee,state").withWorkflowAPI() - .usingProcess(processWithMultipleTasks).getProcessTasks(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary("Only one order by parameter is supported"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify get all process tasks after process is deleted.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void getProcessTasksAfterDeletingProcess() throws Exception - { - ProcessModel processModel = dataWorkflow.usingUser(userWhoStartsProcess).usingSite(publicSite).usingResource(document) - .createSingleReviewerTaskAndAssignTo(assignee1); - - restClient.authenticateUser(adminUser).withWorkflowAPI().usingProcess(processModel).deleteProcess(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - processTasks = restClient.authenticateUser(adminUser).withWorkflowAPI() - .usingProcess(processModel).getProcessTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - processTasks.assertThat().entriesListIsEmpty(); - } - -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/tasks/GetProcessTasksSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/tasks/GetProcessTasksSanityTests.java deleted file mode 100644 index f94b72e14..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/tasks/GetProcessTasksSanityTests.java +++ /dev/null @@ -1,86 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes.tasks; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestTaskModelsCollection; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.ProcessModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Tests for GET "/processes/{processId}/tasks" REST API call - * - * @author Cristina Axinte - */ -public class GetProcessTasksSanityTests extends RestTest -{ - private FileModel document; - private SiteModel siteModel; - private UserModel userModel, assignee1, assignee2, assignee3; - private ProcessModel process; - private RestTaskModelsCollection processTasks; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - assignee1 = dataUser.createRandomTestUser(); - assignee2 = dataUser.createRandomTestUser(); - assignee3 = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - process = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(document) - .createMoreReviewersWorkflowAndAssignTo(assignee1, assignee2, assignee3); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Verify user who started the process gets all tasks of started process with Rest API and response is successfull (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) - public void userWhoStartedProcessCanGetProcessTasks() throws JsonToModelConversionException, Exception - { - processTasks = restClient.authenticateUser(userModel).withWorkflowAPI().usingProcess(process).getProcessTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - processTasks.assertThat() - .entriesListCountIs(3).and() - .entriesListContains("assignee", assignee1.getUsername()).and() - .entriesListContains("assignee", assignee2.getUsername()).and() - .entriesListContains("assignee", assignee3.getUsername()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Verify any assignee user of the process gets all tasks of the process with Rest API and response is successfull (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) - public void assigneeUserCanGetAllProcessTasks() throws JsonToModelConversionException, Exception - { - processTasks = restClient.authenticateUser(assignee1).withWorkflowAPI().usingProcess(process).getProcessTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - processTasks.assertThat() - .entriesListContains("assignee", assignee1.getUsername()).and() - .entriesListContains("assignee", assignee2.getUsername()).and() - .entriesListContains("assignee", assignee3.getUsername()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Verify any assignee user of the process gets all tasks of the process with Rest API and response is successfull (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) - public void involvedUserCanGetAllProcessTasks() throws JsonToModelConversionException, Exception - { - ProcessModel process = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(document) - .createMoreReviewersWorkflowAndAssignTo(assignee1, assignee2, assignee3); - dataWorkflow.usingUser(assignee1).approveTask(process); - - processTasks = restClient.authenticateUser(assignee2).withWorkflowAPI().usingProcess(process).getProcessTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - processTasks.assertThat() - .entriesListIsNotEmpty().assertThat() - .entriesListContains("assignee", userModel.getUsername()); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariableCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariableCoreTests.java deleted file mode 100644 index cf2ddf39e..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariableCoreTests.java +++ /dev/null @@ -1,188 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes.variables; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.core.RestRequest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.model.RestProcessVariableModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class AddProcessVariableCoreTests extends RestTest -{ - private FileModel document; - private SiteModel siteModel; - private UserModel userWhoStartsProcess, assignee, adminUser, anotherUser; - private RestProcessModel processModel; - private RestProcessVariableModel variableModel, processVariable; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - anotherUser = dataUser.createRandomTestUser(); - userWhoStartsProcess = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userWhoStartsProcess).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Add process variable using by the user who started the process.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void addProcessVariableByUserThatStartedTheProcess() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); - - processVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - processVariable.assertThat().field("name").is(variableModel.getName()) - .and().field("type").is(variableModel.getType()) - .and().field("value").is(variableModel.getValue()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Add process variable using by a random user.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void addProcessVariableByAnyUser() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(anotherUser).withWorkflowAPI().addProcess("activitiAdhoc", anotherUser, false, Priority.Normal); - - processVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - processVariable.assertThat().field("name").is(variableModel.getName()) - .and().field("type").is(variableModel.getType()) - .and().field("value").is(variableModel.getValue()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding process variable is falling in case invalid type is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void failedAddingProcessVariableIfInvalidTypeIsProvided() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:textarea"); - - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsErrorKey(String.format(RestErrorModel.UNSUPPORTED_TYPE, "d:textarea")) - .containsSummary(String.format(RestErrorModel.UNSUPPORTED_TYPE, "d:textarea")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Bug(id = "REPO-1938") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding process variable is falling in case invalid type prefix is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void failedAddingProcessVariableIfInvalidTypePrefixIsProvided() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("ddt:text"); - - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .containsSummary(String.format(RestErrorModel.INVALID_NAMEPACE_PREFIX, "ddt")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding process variable is falling in case invalid value is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void failedAddingProcessVariableIfInvalidValueIsProvided() throws Exception - { - RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:int"); - variableModel.setValue("invalidValue"); - - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .containsSummary(String.format(RestErrorModel.FOR_INPUT_STRING, "invalidValue")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding process variable is falling in case missing required variable body (name) is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void failedAddingProcessVariableIfMissingRequiredVariableNameBodyIsProvided() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"value\": \"missingVariableName\",\"type\": \"d:text\"}", - "processes/{processId}/variables/{variableName}", processModel.getId(), variableModel.getName()); - restClient.processModel(RestProcessVariableModel.class, request); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsErrorKey(RestErrorModel.VARIABLE_NAME_REQUIRED) - .containsSummary(RestErrorModel.VARIABLE_NAME_REQUIRED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding process variable is falling in case invalid variableBody (adding extra parameter in body) is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void failedAddingProcessVariableIfInvalidBodyIsProvided() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"scope\": \"local\",\"value\": \"testing\",\"type\": \"d:text\"}", - "processes/{processId}/variables/{variableName}", processModel.getId(), variableModel.getName()); - restClient.processModel(RestProcessVariableModel.class, request); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "Unrecognized field \"scope\"")) - .containsSummary(String.format(RestErrorModel.NO_CONTENT, "Unrecognized field \"scope\"")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding process variable is falling in case empty name is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void failedAddingProcessVariableIfEmptyNameIsProvided() throws Exception - { - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); - RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - variableModel.setName(""); - - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); - - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) - .assertLastError() - .containsErrorKey(RestErrorModel.PUT_EMPTY_ARGUMENT) - .containsSummary(RestErrorModel.PUT_EMPTY_ARGUMENT) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariableFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariableFullTests.java deleted file mode 100644 index 63abe5c76..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariableFullTests.java +++ /dev/null @@ -1,182 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes.variables; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.core.RestRequest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.model.RestProcessVariableModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.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 AddProcessVariableFullTests extends RestTest -{ - private FileModel document; - private SiteModel siteModel; - private UserModel userWhoStartsProcess, assignee, adminUser; - private RestProcessModel processModel; - private RestProcessVariableModel variableModel, processVariable, updatedProcessVariable; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userWhoStartsProcess = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userWhoStartsProcess).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify addProcessVariable by any user for invalid processID with REST API and status code is NOT_FOUND (404)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void addProcessVariableWithInvalidProcessId() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - processModel.setId("invalidProcessID"); - - processVariable = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingProcess(processModel) - .updateProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidProcessID")); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify addProcessVariable by any user for empty processID with REST API and status code is NOT_FOUND (404)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void addProcessVariableWithEmptyProcessId() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - processModel.setId(""); - - processVariable = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingProcess(processModel) - .updateProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding process variable in case of having only 'name' field is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void addingProcessVariableWithOnlyNameProvided() throws Exception - { - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"name\": \"variableName\"}", - "processes/{processId}/variables/{variableName}", processModel.getId(), "variableName"); - processVariable = restClient.processModel(RestProcessVariableModel.class, request); - - restClient.assertStatusCodeIs(HttpStatus.OK); - processVariable.assertThat().field("name").is("variableName") - .and().field("type").is("d:any") - .and().field("value").isNull(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding process variable in case of missing type field is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void addingProcessVariableIfMissingValueIsProvided() throws Exception - { - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"name\": \"variableName\", \"type\": \"d:text\"}", - "processes/{processId}/variables/{variableName}", processModel.getId(), "variableName"); - processVariable = restClient.processModel(RestProcessVariableModel.class, request); - - restClient.assertStatusCodeIs(HttpStatus.OK); - processVariable.assertThat().field("name").is("variableName") - .and().field("type").is("d:text") - .and().field("value").isNull(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding process variable in case of missing type field is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void addingProcessVariableIfMissingTypeIsProvided() throws Exception - { - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"value\": \"variableValue\", \"name\": \"variableName\"}", - "processes/{processId}/variables/{variableName}", processModel.getId(), "variableValue"); - processVariable = restClient.processModel(RestProcessVariableModel.class, request); - - restClient.assertStatusCodeIs(HttpStatus.OK); - processVariable.assertThat().field("name").is("variableName") - .and().field("type").is("d:text") - .and().field("value").is("variableValue"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding process variable is case of empty type value is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void addingProcessVariableIfEmptyTypeIsProvided() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel(""); - - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - processVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); - - restClient.assertStatusCodeIs(HttpStatus.OK); - processVariable.assertThat().field("name").is(variableModel.getName()) - .and().field("type").is("d:text") - .and().field("value").is(variableModel.getValue()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding process variable in case of empty body field is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void addingProcessVariableWithEmptyBodyProvided() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel(""); - - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{ }", - "processes/{processId}/variables/{variableName}", processModel.getId(), variableModel.getName()); - processVariable = restClient.processModel(RestProcessVariableModel.class, request); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsErrorKey(RestErrorModel.VARIABLE_NAME_REQUIRED) - .containsSummary(RestErrorModel.VARIABLE_NAME_REQUIRED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Update twice in a row the same variable.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void updateTwiceInARowSameProcessVariable() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - - processVariable = restClient.withWorkflowAPI().usingProcess(processModel) - .updateProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - processVariable.assertThat().field("name").is(variableModel.getName()) - .and().field("type").is(variableModel.getType()) - .and().field("value").is(variableModel.getValue()); - - restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() - .assertThat().entriesListContains("name", variableModel.getName()); - - updatedProcessVariable = restClient.withWorkflowAPI().usingProcess(processModel) - .updateProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedProcessVariable.assertThat().field("name").is(variableModel.getName()) - .and().field("type").is(variableModel.getType()) - .and().field("value").is(variableModel.getValue()); - - restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() - .assertThat().entriesListContains("name", variableModel.getName()); - } - -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariableSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariableSanityTests.java deleted file mode 100644 index bcdc5c7fc..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariableSanityTests.java +++ /dev/null @@ -1,95 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes.variables; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.model.RestProcessVariableModel; -import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.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 AddProcessVariableSanityTests extends RestTest -{ - private FileModel document; - private SiteModel siteModel; - private UserModel userWhoStartsTask, assignee, adminUser; - private RestProcessModel processModel; - private RestProcessVariableModel variableModel, processVariable; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userWhoStartsTask = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Create non-existing variable") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) - public void addProcessVariable() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - - processVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - processVariable.assertThat().field("name").is(variableModel.getName()) - .and().field("type").is(variableModel.getType()) - .and().field("value").is(variableModel.getValue()); - - restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() - .assertThat().entriesListContains("name", variableModel.getName()); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Update existing variable") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) - public void updateExistingProcessVariable() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - processVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - processVariable.assertThat().field("name").is(variableModel.getName()) - .and().field("type").is(variableModel.getType()) - .and().field("value").is(variableModel.getValue()); - - String newValue = RandomData.getRandomName("value"); - variableModel.setValue(newValue); - processVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - processVariable.assertThat().field("value").is(newValue); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Adding process variable is falling in case invalid variableBody is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) - public void failedAddingProcessVariableIfInvalidBodyIsProvided() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("incorrect type"); - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - - restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsErrorKey(String.format(RestErrorModel.UNSUPPORTED_TYPE, "incorrect type")) - .containsSummary(String.format(RestErrorModel.UNSUPPORTED_TYPE, "incorrect type")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariablesCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariablesCoreTests.java deleted file mode 100644 index ca5ca5358..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariablesCoreTests.java +++ /dev/null @@ -1,101 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes.variables; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.model.RestProcessVariableModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class AddProcessVariablesCoreTests extends RestTest -{ - private FileModel document; - private SiteModel siteModel; - private UserModel userWhoStartsProcess, assignee; - private RestProcessModel processModel; - private RestProcessVariableModel variableModel, processVariable, variableModel1; - - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - userWhoStartsProcess = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userWhoStartsProcess).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify addProcessVariable by any user for invalid processID with REST API and status code is NOT_FOUND (404)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void addProcessVariableForInvalidProcessIdIsNotFound() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - processModel.setId("invalidProcessID"); - - processVariable = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingProcess(processModel) - .addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidProcessID")); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify addProcessVariable by any user for empty processID with REST API and status code is NOT_FOUND (404)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void addProcessVariableForEmptyProcessIdIsEmpty() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - processModel.setId(""); - - processVariable = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingProcess(processModel) - .addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding multiple process variables is falling in case invalid process id is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void addMultipleProcessVariablesInvalidProcessId() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:int"); - variableModel1 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - - processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - processModel.setId("invalidProcessID"); - - restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(processModel) - .addProcessVariables(variableModel1, variableModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidProcessID")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding multiple process variables is falling in case empty process id is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void addMultipleProcessVariablesEmptyProcessId() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:int"); - variableModel1 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - processModel.setId(""); - - restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(processModel) - .addProcessVariables(variableModel1, variableModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariablesFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariablesFullTests.java deleted file mode 100644 index 88256f3b1..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariablesFullTests.java +++ /dev/null @@ -1,395 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes.variables; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.core.RestRequest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.model.RestProcessVariableCollection; -import org.alfresco.rest.model.RestProcessVariableModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.ProcessModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class AddProcessVariablesFullTests extends RestTest -{ - private FileModel document; - private SiteModel siteModel; - private UserModel userWhoStartsProcess, assignee, adminUser; - private ProcessModel processModel; - private RestProcessModel restProcessModel; - private RestProcessVariableModel variableModel, processVariable, variableModel1, variableModel2, variableModel3; - private RestProcessVariableCollection processVariableCollection; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userWhoStartsProcess = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userWhoStartsProcess).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - processModel = dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document).createSingleReviewerTaskAndAssignTo(assignee); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Add process variables using by the user involved in the process.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void addProcessVariableByUserInvolvedTheProcess() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - restProcessModel = restClient.authenticateUser(assignee).withWorkflowAPI().getProcesses() - .getProcessModelByProcessDefId(processModel.getId()); - - processVariable = restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(restProcessModel) - .addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - processVariable.assertThat().field("name").is(variableModel.getName()) - .and().field("type").is(variableModel.getType()) - .and().field("value").is(variableModel.getValue()); - - restClient.withWorkflowAPI().usingProcess(restProcessModel).getProcessVariables() - .assertThat().entriesListContains("name", variableModel.getName()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Add process variables using by the user involved in the process.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void addMultipleProcessVariableByUserInvolvedTheProcess() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - variableModel1 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - restProcessModel = restClient.authenticateUser(assignee).withWorkflowAPI().getProcesses() - .getProcessModelByProcessDefId(processModel.getId()); - - processVariableCollection = restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(restProcessModel) - .addProcessVariables(variableModel, variableModel1); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - processVariableCollection.getEntries().get(0).onModel() - .assertThat().field("name").is(variableModel.getName()) - .and().field("type").is(variableModel.getType()) - .and().field("value").is(variableModel.getValue()); - - processVariableCollection.getEntries().get(1).onModel() - .assertThat().field("name").is(variableModel1.getName()) - .and().field("type").is(variableModel1.getType()) - .and().field("value").is(variableModel1.getValue()); - - restClient.withWorkflowAPI().usingProcess(restProcessModel).getProcessVariables() - .assertThat().entriesListContains("name", variableModel.getName()) - .assertThat().entriesListContains("name", variableModel1.getName()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Add process variables using by inexistent user.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void addProcessVariableByInexistentUser() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - restProcessModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses() - .getProcessModelByProcessDefId(processModel.getId()); - - processVariable = restClient.authenticateUser(UserModel.getRandomUserModel()).withWorkflowAPI() - .usingProcess(restProcessModel) - .addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Add multiple process variables using by inexistent user.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void addMultipleProcessVariableByInexistentUser() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - variableModel1 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - restProcessModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses() - .getProcessModelByProcessDefId(processModel.getId()); - - processVariableCollection = restClient.authenticateUser(UserModel.getRandomUserModel()).withWorkflowAPI() - .usingProcess(restProcessModel) - .addProcessVariables(variableModel,variableModel1); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding process variables is falling in case invalid type is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void failedAddingProcessVariableIfInvalidTypeIsProvided() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:textarea"); - restProcessModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses() - .getProcessModelByProcessDefId(processModel.getId()); - - restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary( - String.format(RestErrorModel.UNSUPPORTED_TYPE, "d:textarea")) - .containsErrorKey(String.format(RestErrorModel.UNSUPPORTED_TYPE, "d:textarea")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Bug(id = "REPO-1938") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding process variables is falling in case invalid type prefix is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void failedAddingProcessVariableIfInvalidTypePrefixIsProvided() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("ddt:text"); - restProcessModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses() - .getProcessModelByProcessDefId(processModel.getId()); - - restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsSummary(String.format(RestErrorModel.INVALID_NAMEPACE_PREFIX, "ddt")) - .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding process variables is falling in case invalid value is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void failedAddingProcessVariableIfInvalidValueIsProvided() throws Exception - { - RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:int"); - variableModel.setValue("invalidValue"); - restProcessModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses() - .getProcessModelByProcessDefId(processModel.getId()); - - restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .containsSummary(String.format(RestErrorModel.FOR_INPUT_STRING, "invalidValue")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding process variables is falling in case invalid variableBody (adding extra parameter in body:scope) is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void failedAddingProcessVariableIfInvalidBodyIsProvided() throws Exception - { - restProcessModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses() - .getProcessModelByProcessDefId(processModel.getId()); - - RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{\"name\": \"variableName\",\"scope\": \"local\",\"value\": \"testing\",\"type\": \"d:text\"}", - "processes/{processId}/variables", processModel.getId()); - restClient.processModel(RestProcessVariableModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsSummary(String.format(RestErrorModel.NO_CONTENT, "Unrecognized field \"scope\"")) - .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "Unrecognized field \"scope\"")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - //@Bug(id="REPO-1985") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding process variables is falling in case empty name is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void failedAddingProcessVariableIfEmptyNameIsProvided() throws Exception - { - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); - restProcessModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses() - .getProcessModelByProcessDefId(processModel.getId()); - RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - variableModel.setName(""); - - restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsSummary(RestErrorModel.VARIABLE_NAME_REQUIRED) - .containsErrorKey(RestErrorModel.VARIABLE_NAME_REQUIRED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - //@Bug(id="REPO-1985") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding process variables is falling in case invalid name is provided: ony white spaces") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void failedAddingProcessVariableUsingOnlyWhiteSpaceInName() throws Exception - { - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); - restProcessModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses() - .getProcessModelByProcessDefId(processModel.getId()); - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - variableModel.setName(" "); - - processVariable = restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - processVariable.assertThat().field("name").isNull() - .and().field("type").is(variableModel.getType()) - .and().field("value").is(variableModel.getValue()); - - restClient.withWorkflowAPI().usingProcess(restProcessModel).getProcessVariables() - .assertThat().entriesListContains("value", variableModel.getValue()); - } - - @Bug(id="REPO-1987") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding process variables is falling in case invalid name is provided: symbols") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void failedAddingProcessVariableWithSymbolsInName() throws Exception - { - restProcessModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses() - .getProcessModelByProcessDefId(processModel.getId()); - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - variableModel.setName("123_%^&: õÈ,Ì,Ò"); - - processVariable = restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - processVariable.assertThat().field("name").is(variableModel.getName()) - .and().field("type").is(variableModel.getType()) - .and().field("value").is(variableModel.getValue()); - - restClient.withWorkflowAPI().usingProcess(restProcessModel).getProcessVariables() - .assertThat().entriesListContains("name", variableModel.getName()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Add two process variables using by the user involved in the process.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void addingMultipleValidProcessVariables() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - variableModel2 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - variableModel3 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - restProcessModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses() - .getProcessModelByProcessDefId(processModel.getId()); - - processVariableCollection = restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(restProcessModel) - .addProcessVariables(variableModel, variableModel2, variableModel3); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - processVariableCollection.assertThat().entriesListContains("name", variableModel.getName()) - .assertThat().entriesListContains("name", variableModel2.getName()) - .assertThat().entriesListContains("name", variableModel3.getName()); - - processVariableCollection.getEntries().get(0).onModel().assertThat() - .field("name").is(variableModel.getName()).and() - .field("value").is(variableModel.getValue()).and() - .field("type").is(variableModel.getType()); - processVariableCollection.getEntries().get(1).onModel().assertThat() - .field("name").is(variableModel2.getName()).and() - .field("value").is(variableModel2.getValue()).and() - .field("type").is(variableModel2.getType()); - processVariableCollection.getEntries().get(2).onModel().assertThat() - .field("name").is(variableModel3.getName()).and() - .field("value").is(variableModel3.getValue()).and() - .field("type").is(variableModel3.getType()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Add two process variables using by the user involved in the process.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void failedAddingMultipleProcessVariablesInvalidType() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - variableModel.setType("d:string"); - variableModel2 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - restProcessModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses() - .getProcessModelByProcessDefId(processModel.getId()); - - processVariableCollection = restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(restProcessModel) - .addProcessVariables(variableModel, variableModel2); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.UNSUPPORTED_TYPE, "d:string")) - .containsErrorKey(String.format(RestErrorModel.UNSUPPORTED_TYPE, "d:string")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Bug(id = "REPO-1938") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Add two process variables using by the user involved in the process.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void failledAddingMultipleProcessVariablesInvalidTypePrefix() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - variableModel.setType("e:text"); - variableModel2 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - restProcessModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses() - .getProcessModelByProcessDefId(processModel.getId()); - - processVariableCollection = restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(restProcessModel) - .addProcessVariables(variableModel, variableModel2); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsSummary(String.format(RestErrorModel.INVALID_NAMEPACE_PREFIX, "e")) - .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding process variables is falling in case invalid value is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void failledAddingMultipleProcessVariablesInvalidValue() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:int"); - variableModel.setValue("invalidValue"); - variableModel1 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - variableModel2 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - restProcessModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses() - .getProcessModelByProcessDefId(processModel.getId()); - - processVariableCollection = restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(restProcessModel) - .addProcessVariables(variableModel, variableModel1, variableModel2); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .containsSummary(String.format(RestErrorModel.FOR_INPUT_STRING, "invalidValue")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding process variables is falling in case invalid value is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void failledAddingMultipleInvalidProcessVariables() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:int"); - variableModel.setValue("invalidValue"); - variableModel1 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - variableModel1.setType(""); - restProcessModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses() - .getProcessModelByProcessDefId(processModel.getId()); - - processVariableCollection = restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(restProcessModel) - .addProcessVariables(variableModel1, variableModel); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .containsSummary(String.format(RestErrorModel.FOR_INPUT_STRING, "invalidValue")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariablesSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariablesSanityTests.java deleted file mode 100644 index d11230ff6..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/AddProcessVariablesSanityTests.java +++ /dev/null @@ -1,158 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes.variables; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.model.RestProcessVariableCollection; -import org.alfresco.rest.model.RestProcessVariableModel; -import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class AddProcessVariablesSanityTests extends RestTest -{ - private FileModel document; - private SiteModel siteModel; - private UserModel userWhoStartsProcess, assignee, adminUser; - private RestProcessModel processModel; - private RestProcessVariableModel variableModel, variableModel1, variableModel2, processVariable; - private RestProcessVariableCollection processVariableCollection; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userWhoStartsProcess = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userWhoStartsProcess).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Create non-existing variable") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) - public void addProcessVariable() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - - processVariable = restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - processVariable.assertThat().field("name").is(variableModel.getName()) - .and().field("type").is(variableModel.getType()) - .and().field("value").is(variableModel.getValue()); - - restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() - .assertThat().entriesListContains("name", variableModel.getName()); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Create non-existing variable") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) - public void addMultipleProcessVariable() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - variableModel1 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - variableModel2 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - - processVariableCollection = restClient.withWorkflowAPI().usingProcess(processModel) - .addProcessVariables(variableModel, variableModel1, variableModel2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - processVariableCollection.getEntries().get(0).onModel() - .assertThat().field("name").is( variableModel.getName()) - .and().field("type").is( variableModel.getType()) - .and().field("value").is( variableModel.getValue()); - - processVariableCollection.getEntries().get(1).onModel() - .assertThat().field("name").is(variableModel1.getName()) - .and().field("type").is(variableModel1.getType()) - .and().field("value").is(variableModel1.getValue()); - - processVariableCollection.getEntries().get(2).onModel() - .assertThat().field("name").is(variableModel2.getName()) - .and().field("type").is(variableModel2.getType()) - .and().field("value").is(variableModel2.getValue()); - - restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() - .assertThat().entriesListContains("name", variableModel.getName()) - .assertThat().entriesListContains("name", variableModel1.getName()) - .assertThat().entriesListContains("name", variableModel2.getName()); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Update existing variables") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) - public void updateExistingProcessVariable() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - - processVariable = restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - processVariable.assertThat().field("name").is(variableModel.getName()) - .and().field("type").is(variableModel.getType()) - .and().field("value").is(variableModel.getValue()); - - String newValue = RandomData.getRandomName("value"); - variableModel.setValue(newValue); - processVariable = restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - processVariable.assertThat().field("value").is(newValue); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Update existing variables") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) - public void updateExistingMultipleProcessVariable() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - variableModel1 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - - processVariableCollection = restClient.withWorkflowAPI().usingProcess(processModel) - .addProcessVariables(variableModel, variableModel1); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - processVariableCollection.getEntries().get(0).onModel() - .assertThat().field("name").is(variableModel.getName()) - .and().field("type").is(variableModel.getType()) - .and().field("value").is(variableModel.getValue()); - - processVariableCollection.getEntries().get(1).onModel() - .assertThat().field("name").is(variableModel1.getName()) - .and().field("type").is(variableModel1.getType()) - .and().field("value").is(variableModel1.getValue()); - - String newValueVar = RandomData.getRandomName("valueVar"); - variableModel.setValue(newValueVar); - String newValueVar1 = RandomData.getRandomName("valueVar1"); - variableModel1.setValue(newValueVar1); - - processVariableCollection = restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariables(variableModel, variableModel1); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - processVariableCollection.getEntries().get(0).onModel().assertThat().field("value").is(newValueVar); - processVariableCollection.getEntries().get(1).onModel().assertThat().field("value").is(newValueVar1); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Adding process variables is falling in case invalid variableBody is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) - public void failedAddingProcessVariableIfInvalidBodyIsProvided() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("incorrect type"); - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - - restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary("Unsupported type of variable: 'incorrect type'."); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/DeleteProcessVariableCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/DeleteProcessVariableCoreTests.java deleted file mode 100644 index 1e5681d81..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/DeleteProcessVariableCoreTests.java +++ /dev/null @@ -1,118 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes.variables; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.model.RestProcessVariableModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.ProcessModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * - * @author bogdan.bocancea - * - */ -public class DeleteProcessVariableCoreTests extends RestTest -{ - private FileModel document; - private SiteModel siteModel; - private UserModel userWhoStartsTask, assignee, adminUser; - private RestProcessModel restProcessModel; - private ProcessModel processModel; - private RestProcessVariableModel variableModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userWhoStartsTask = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - processModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document) - .createSingleReviewerTaskAndAssignTo(assignee); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Delete invalid process variable") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void deleteInvalidProcessVariable() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("x:InvalidVar"); - restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() - .getProcesses().getProcessModelByProcessDefId(processModel.getId()); - restClient.withWorkflowAPI().usingProcess(restProcessModel).deleteProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, variableModel.getName())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Delete process variable twice") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void deleteProcessVariableTwice() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() - .getProcesses().getProcessModelByProcessDefId(processModel.getId()); - restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.withWorkflowAPI().usingProcess(restProcessModel).deleteProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withWorkflowAPI().usingProcess(restProcessModel).deleteProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, variableModel.getName())); - } - - @TestRail(section = {TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Remove process variables with empty processId") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void deleteProcessVariableEmptyProcessId() throws JsonToModelConversionException, Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() - .getProcesses().getProcessModelByProcessDefId(processModel.getId()); - restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restProcessModel.setId(""); - restClient.withWorkflowAPI().usingProcess(restProcessModel).deleteProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Delete process variable with admin.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void deleteProcessVariableWithAdmin() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() - .getProcesses().getProcessModelByProcessDefId(processModel.getId()); - restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(adminUser).withWorkflowAPI().usingProcess(processModel) - .deleteProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() - .assertThat().entriesListDoesNotContain("name", variableModel.getName()); - } - -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/DeleteProcessVariableFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/DeleteProcessVariableFullTests.java deleted file mode 100644 index a48260f8f..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/DeleteProcessVariableFullTests.java +++ /dev/null @@ -1,196 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes.variables; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.model.RestProcessVariableModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.ProcessModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class DeleteProcessVariableFullTests extends RestTest -{ - private FileModel document; - private SiteModel siteModel; - private UserModel userWhoStartsTask, assignee; - private RestProcessModel restProcessModel; - private ProcessModel processModel; - private RestProcessVariableModel variableModel; - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - userWhoStartsTask = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - processModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createSingleReviewerTaskAndAssignTo(assignee); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Delete empty process variable") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void deleteEmptyProcessVariable() throws Exception - { - variableModel = new RestProcessVariableModel("", "", "bpm:workflowPackage"); - restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getProcesses() - .getProcessModelByProcessDefId(processModel.getId()); - - restClient.withWorkflowAPI().usingProcess(restProcessModel) - .deleteProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) - .assertLastError() - .containsSummary(RestErrorModel.DELETE_EMPTY_ARGUMENT) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .containsErrorKey(RestErrorModel.DELETE_EMPTY_ARGUMENT) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Delete process then delete process variables, status OK should be returned") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void deleteProcessVariablesForADeletedProcess() throws Exception - { - UserModel userWhoStartsTask = dataUser.createRandomTestUser(); - UserModel assignee = dataUser.createRandomTestUser(); - - RestProcessModel processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() - .addProcess("activitiAdhoc", assignee, false, Priority.Normal); - - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() - .getProcesses().getProcessModelByProcessDefId(processModel.getId()); - restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingProcess(processModel) - .deleteProcess(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withWorkflowAPI().usingProcess(processModel).deleteProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, processModel.getId())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Delete process variable using by the user who started the process.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void deleteProcessVariableByUserThatStartedTheProcess() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() - .addProcess("activitiAdhoc", assignee, false, Priority.Normal); - - restProcessModel = restClient.withWorkflowAPI().getProcesses() - .getProcessModelByProcessDefId(processModel.getId()); - restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.withWorkflowAPI().usingProcess(processModel) - .deleteProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() - .assertThat() - .entriesListDoesNotContain("name", variableModel.getName()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Delete process variable using by the user involved in the process.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void deleteProcessVariableByUserInvolvedInTheProcess() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() - .addProcess("activitiAdhoc", assignee, false, Priority.Normal); - - restProcessModel = restClient.withWorkflowAPI().getProcesses() - .getProcessModelByProcessDefId(processModel.getId()); - restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(processModel) - .deleteProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() - .assertThat() - .entriesListDoesNotContain("name", variableModel.getName()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Delete process variable with invalid type") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void deleteProcessVariableInvalidType() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() - .getProcesses().getProcessModelByProcessDefId(processModel.getId()); - restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - variableModel.setType("invalid-type"); - restClient.withWorkflowAPI().usingProcess(restProcessModel).deleteProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() - .assertThat() - .entriesListDoesNotContain("name", variableModel.getName()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Delete process variable by non assigned user") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void deleteProcessVarialbleByNonAssignedUser() throws Exception - { - UserModel nonAssigned = dataUser.createRandomTestUser(); - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() - .getProcesses().getProcessModelByProcessDefId(processModel.getId()); - restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(nonAssigned).withWorkflowAPI().usingProcess(restProcessModel) - .deleteProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError() - .containsSummary(String.format(RestErrorModel.ACCESS_INFORMATION_NOT_ALLOWED, processModel.getId())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .containsErrorKey(String.format(RestErrorModel.ACCESS_INFORMATION_NOT_ALLOWED, processModel.getId())) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Delete process variable by inexistent user") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void deleteProcessVarialbleByInexistentUser() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() - .addProcess("activitiAdhoc", userWhoStartsTask, false, Priority.Normal); - restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() - .getProcesses().getProcessModelByProcessDefId(processModel.getId()); - restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.authenticateUser(UserModel.getRandomUserModel()).withWorkflowAPI() - .usingProcess(restProcessModel) - .deleteProcessVariable(variableModel); - - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .stackTraceIs(RestErrorModel.STACKTRACE); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/DeleteProcessVariableSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/DeleteProcessVariableSanityTests.java deleted file mode 100644 index d46a55890..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/DeleteProcessVariableSanityTests.java +++ /dev/null @@ -1,69 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes.variables; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.model.RestProcessVariableModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.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 DeleteProcessVariableSanityTests extends RestTest -{ - private FileModel document; - private SiteModel siteModel; - private UserModel userWhoStartsTask, assignee, adminUser; - private RestProcessModel processModel; - private RestProcessVariableModel variableModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userWhoStartsTask = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().addProcess("activitiAdhoc", adminUser, false, Priority.Normal); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Delete existing variable") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) - public void deleteProcessVariable() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.withWorkflowAPI().usingProcess(processModel).deleteProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() - .assertThat().entriesListDoesNotContain("name", variableModel.getName()); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Try to delete existing variable using invalid processId") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) - public void deleteProcessVariableUsingInvalidProcessId() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - processModel.setId("incorrectProcessId"); - restClient.withWorkflowAPI().usingProcess(processModel).deleteProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "incorrectProcessId")); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/GetProcessVariablesCoreTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/GetProcessVariablesCoreTests.java deleted file mode 100644 index 77abbdbf0..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/GetProcessVariablesCoreTests.java +++ /dev/null @@ -1,88 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes.variables; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.model.RestProcessModelsCollection; -import org.alfresco.rest.model.RestProcessVariableCollection; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.apache.commons.lang3.RandomStringUtils; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class GetProcessVariablesCoreTests extends RestTest -{ - private FileModel document; - private SiteModel siteModel; - private UserModel userWhoStartsTask, assignee, admin; - private RestProcessModel processModel; - private RestProcessVariableCollection variables; - - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - admin = dataUser.getAdminUser(); - userWhoStartsTask = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Get process variables using invalid process ID") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void getProcessVariablesUsingInvalidProcessId() throws Exception - { - restClient.authenticateUser(userWhoStartsTask).withParams("maxItems=2").withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); - RestProcessModelsCollection processes = restClient.authenticateUser(userWhoStartsTask).withParams("maxItems=2").withWorkflowAPI().getProcesses(); - processModel = processes.assertThat().entriesListIsNotEmpty().when().getOneRandomEntry().onModel(); - - String id = RandomStringUtils.randomAlphanumeric(10); - processModel.setId(id); - variables = restClient.withParams("maxItems=2").withWorkflowAPI().usingProcess(processModel).getProcessVariables(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, id)) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Get process variables using empty process ID") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void getProcessVariablesUsingEmptyProcessId() throws Exception - { - processModel = restClient.authenticateUser(userWhoStartsTask).withParams("maxItems=2").withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - processModel.setId(""); - variables = restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Delete process then get process variables, status OK should be returned") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void getProcessVariablesForADeletedProcess() throws Exception - { - UserModel userWhoStartsTask = dataUser.createRandomTestUser(); - UserModel assignee = dataUser.createRandomTestUser(); - - RestProcessModel processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); - - restClient.authenticateUser(admin).withWorkflowAPI().usingProcess(processModel).deleteProcess(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - RestProcessVariableCollection variables = restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables(); - restClient.assertStatusCodeIs(HttpStatus.OK); - variables.assertThat().entriesListIsNotEmpty(); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/GetProcessVariablesFullTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/GetProcessVariablesFullTests.java deleted file mode 100644 index abbc93811..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/GetProcessVariablesFullTests.java +++ /dev/null @@ -1,161 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes.variables; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.model.RestProcessVariableCollection; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Created by Claudia Agache on 2/2/2017. - */ -public class GetProcessVariablesFullTests extends RestTest -{ - private UserModel userWhoStartsProcess, assignee, admin; - private RestProcessModel processModel; - private RestProcessVariableCollection variables; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - admin = dataUser.getAdminUser(); - userWhoStartsProcess = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.Normal); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify get all process variables call using admin user. Admin can see the process even if he isn't involved in it.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void getProcessVariablesUsingAdmin() throws Exception - { - variables = restClient.authenticateUser(admin).withWorkflowAPI().usingProcess(processModel).getProcessVariables(); - restClient.assertStatusCodeIs(HttpStatus.OK); - variables.assertThat().entriesListIsNotEmpty(); - variables.getProcessVariableByName("initiator") - .assertThat().field("name").is("initiator") - .assertThat().field("type").is("d:noderef") - .assertThat().field("value").is(userWhoStartsProcess.getUsername()); - variables.getProcessVariableByName("bpm_assignee") - .assertThat().field("name").is("bpm_assignee") - .assertThat().field("type").is("cm:person") - .assertThat().field("value").is(assignee.getUsername()); - variables.getProcessVariableByName("bpm_sendEMailNotifications") - .assertThat().field("name").is("bpm_sendEMailNotifications") - .assertThat().field("type").is("d:boolean") - .assertThat().field("value").is(false); - variables.getProcessVariableByName("bpm_priority") - .assertThat().field("name").is("bpm_priority") - .assertThat().field("type").is("d:int") - .assertThat().field("value").is(CMISUtil.Priority.Normal.getLevel()); - } - - @Bug(id = "MNT-17438") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify get all process variables with valid skip count parameter applied.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void getProcessVariablesWithValidSkipCount() throws Exception - { - variables = restClient.authenticateUser(admin).withWorkflowAPI().usingProcess(processModel).getProcessVariables(); - restClient.assertStatusCodeIs(HttpStatus.OK); - variables.assertThat().entriesListIsNotEmpty(); - - RestProcessVariableCollection variablesSkipped = restClient.authenticateUser(admin).withParams("skipCount=2").withWorkflowAPI().usingProcess(processModel).getProcessVariables(); - restClient.assertStatusCodeIs(HttpStatus.OK); - variablesSkipped - .assertThat().entriesListDoesNotContain("name", variables.getEntries().get(0).onModel().getName()) - .assertThat().entriesListDoesNotContain("name", variables.getEntries().get(1).onModel().getName()) - .assertThat().entriesListCountIs(variables.getEntries().size()-2) - .assertThat().paginationField("skipCount").is("2"); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify get all process variables with negative skip count parameter applied.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void getProcessVariablesWithNegativeSkipCount() throws Exception - { - restClient.authenticateUser(admin).withParams("skipCount=-2").withWorkflowAPI().usingProcess(processModel).getProcessVariables(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT) - .containsErrorKey(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE) - .statusCodeIs(HttpStatus.BAD_REQUEST); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify get all process variables with not numeric skip count parameter applied.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void getProcessVariablesWithNonNumericSkipCount() throws Exception - { - restClient.authenticateUser(admin).withParams("skipCount=A").withWorkflowAPI().usingProcess(processModel).getProcessVariables(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "A")); - } - - @Bug(id = "MNT-17438") - @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify get all process variables with valid maxItems parameter applied.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void getProcessVariablesWithValidMaxItems() throws Exception - { - variables = restClient.authenticateUser(admin).withWorkflowAPI().usingProcess(processModel).getProcessVariables(); - restClient.assertStatusCodeIs(HttpStatus.OK); - variables.assertThat().entriesListIsNotEmpty(); - - RestProcessVariableCollection variablesSkipped = restClient.authenticateUser(admin).withParams("maxItems=2").withWorkflowAPI().usingProcess(processModel).getProcessVariables(); - restClient.assertStatusCodeIs(HttpStatus.OK); - variablesSkipped - .assertThat().entriesListContains("name", variables.getEntries().get(0).onModel().getName()) - .assertThat().entriesListContains("name", variables.getEntries().get(1).onModel().getName()) - .assertThat().entriesListCountIs(2) - .assertThat().paginationField("maxItems").is("2"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify get all process variables with negative maxItems parameter applied.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void getProcessVariablesWithNegativeMaxItems() throws Exception - { - restClient.authenticateUser(admin).withParams("maxItems=-2").withWorkflowAPI().usingProcess(processModel).getProcessVariables(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) - .containsErrorKey(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE) - .statusCodeIs(HttpStatus.BAD_REQUEST); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify get all process variables with not numeric maxItems parameter applied.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void getProcessVariablesWithNonNumericMaxItems() throws Exception - { - restClient.authenticateUser(admin).withParams("maxItems=A").withWorkflowAPI().usingProcess(processModel).getProcessVariables(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "A")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify get all process variables with properties parameter.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void getProcessVariablesWithPropertiesParameter() throws Exception - { - variables = restClient.authenticateUser(admin).withParams("properties=name").withWorkflowAPI().usingProcess(processModel).getProcessVariables(); - restClient.assertStatusCodeIs(HttpStatus.OK); - variables.assertThat().entriesListIsNotEmpty(); - variables.getProcessVariableByName("initiator") - .assertThat().field("name").is("initiator") - .assertThat().field("type").isNull() - .assertThat().field("value").isNull() - .assertThat().fieldsCount().is(1); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/GetProcessVariablesSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/GetProcessVariablesSanityTests.java deleted file mode 100644 index 77d769435..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/GetProcessVariablesSanityTests.java +++ /dev/null @@ -1,60 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes.variables; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.model.RestProcessVariableCollection; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.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 GetProcessVariablesSanityTests extends RestTest -{ - private FileModel document; - private SiteModel siteModel; - private UserModel userWhoStartsTask, assignee; - private RestProcessModel processModel; - private RestProcessVariableCollection variables; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - userWhoStartsTask = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Verify that user that started the process gets all process variables") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) - public void getProcessVariablesUsingTheUserWhoStartedProcess() throws JsonToModelConversionException, Exception - { - processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - variables = restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables(); - restClient.assertStatusCodeIs(HttpStatus.OK); - variables.assertThat().entriesListIsNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, - description = "Verify get all process variables call using a user that is involved in the process") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) - public void getProcessVariablesUsingUserInvolvedInProcess() throws JsonToModelConversionException, Exception - { - processModel = restClient.authenticateUser(assignee).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - variables = restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables(); - restClient.assertStatusCodeIs(HttpStatus.OK); - variables.assertThat().entriesListIsNotEmpty(); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/UpdateProcessVariableTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/UpdateProcessVariableTests.java deleted file mode 100644 index a504bd082..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/processes/variables/UpdateProcessVariableTests.java +++ /dev/null @@ -1,139 +0,0 @@ -package org.alfresco.service.search.rest.workflow.processes.variables; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.model.RestProcessVariableModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - - -public class UpdateProcessVariableTests extends RestTest -{ - private FileModel document; - private SiteModel siteModel; - private UserModel userWhoStartsProcess, assignee; - private RestProcessModel processModel; - private RestProcessVariableModel variableModel, updatedVariable; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - userWhoStartsProcess = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userWhoStartsProcess).createPublicRandomSite(); - document = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Update existing variable using PUT call - invalid type") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void updateProcessVariableInvalidType() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - variableModel.setType("dd"); - - updatedVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsErrorKey(String.format(RestErrorModel.UNSUPPORTED_TYPE, "dd")) - .containsSummary(String.format(RestErrorModel.UNSUPPORTED_TYPE, "dd")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Update existing variable using PUT call - invalid type") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void updateProcessVariableTwoUsers() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:any"); - processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - variableModel.setType("d:text"); - updatedVariable = restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(processModel) - .updateProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedVariable.assertThat().field("type").is("d:text"); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Update existing variable using PUT call - value") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) - public void updateProcessVariableValue() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - variableModel.setValue("newValue"); - - updatedVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedVariable.assertThat().field("value").is("newValue"); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Update existing variable using PUT call - name") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void updateProcessVariableName() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - variableModel.setName("newVariableName"); - - updatedVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedVariable.assertThat().field("name").is("newVariableName"); - } - - @TestRail(section = {TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Update existing variable created by the user who started the process using put call with a user that is not involved in the process- value") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) - public void cantUpdateProcessVariableValueCreatedWithAnyUser() throws Exception - { - UserModel anotherUser = dataUser.createRandomTestUser(); - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - variableModel.setValue("newValue"); - - restClient.authenticateUser(anotherUser).withWorkflowAPI().usingProcess(processModel) - .updateProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(String.format(RestErrorModel.ACCESS_INFORMATION_NOT_ALLOWED, processModel.getId())); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Try to add process variable using an invalid processId") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) - public void updateProcessVariableUsingInvalidProcessId() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - restClient.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - processModel.setId("abc"); - - restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "abc")); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/GetTaskFormModelTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/GetTaskFormModelTests.java deleted file mode 100644 index 559fc29b9..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/GetTaskFormModelTests.java +++ /dev/null @@ -1,256 +0,0 @@ -package org.alfresco.service.search.rest.workflow.tasks; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.*; -import org.alfresco.utility.model.*; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Created by Claudia Agache on 2/3/2017. - */ -public class GetTaskFormModelTests extends RestTest -{ - UserModel userModel, adminUser; - SiteModel siteModel; - FileModel fileModel; - TaskModel taskModel; - RestFormModelsCollection returnedCollection; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, - executionType = ExecutionType.SANITY, description = "Verify admin user gets all task form models with Rest API and response is successful (200)") - public void adminGetsTaskFormModels() throws Exception - { - taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(userModel); - returnedCollection = restClient.authenticateUser(dataUser.getAdminUser()).withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat().entriesListIsNotEmpty(); - - String[] qualifiedNames = { - "{http://www.alfresco.org/model/bpm/1.0}percentComplete", - "{http://www.alfresco.org/model/bpm/1.0}context", - "{http://www.alfresco.org/model/bpm/1.0}completedItems", - "{http://www.alfresco.org/model/content/1.0}name", - "{http://www.alfresco.org/model/bpm/1.0}packageActionGroup", - "{http://www.alfresco.org/model/bpm/1.0}reassignable", - "{http://www.alfresco.org/model/content/1.0}owner", - "{http://www.alfresco.org/model/bpm/1.0}outcome", - "{http://www.alfresco.org/model/bpm/1.0}taskId", - "{http://www.alfresco.org/model/bpm/1.0}packageItemActionGroup", - "{http://www.alfresco.org/model/bpm/1.0}completionDate"}; - - for(String formQualifiedName : qualifiedNames) - { - returnedCollection.assertThat().entriesListContains("qualifiedName", formQualifiedName); - } - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, - executionType = ExecutionType.SANITY, description = "Verify user involved in task gets all the task form models with Rest API and response is successful (200)") - public void involvedUserGetsTaskFormModels() throws Exception - { - taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(userModel); - returnedCollection = restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat().entriesListIsNotEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, - executionType = ExecutionType.REGRESSION, - description = "Verify that non involved user in task cannot get form models with Rest API and response is FORBIDDEN (403)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void nonInvolvedUserCannotGetTaskFormModels() throws Exception - { - taskModel = dataWorkflow.usingUser(userModel) - .usingSite(siteModel) - .usingResource(fileModel).createNewTaskAndAssignTo(userModel); - UserModel nonInvolvedUser = dataUser.createRandomTestUser(); - restClient.authenticateUser(nonInvolvedUser); - restClient.withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, - executionType = ExecutionType.REGRESSION, - description = "Verify user involved in task cannot get task form models with invalid task id") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void getTaskFormModelsInvalidTaskId() throws Exception - { - taskModel = dataWorkflow.usingUser(userModel) - .usingSite(siteModel) - .usingResource(fileModel).createNewTaskAndAssignTo(userModel); - taskModel.setId("0000"); - restClient.authenticateUser(userModel); - restClient.withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "0000")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, - executionType = ExecutionType.REGRESSION, - description = "Verify user involved in task cannot get task form models with invalid task id") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void getTaskFormModelsEmptyTaskId() throws Exception - { - taskModel = dataWorkflow.usingUser(userModel) - .usingSite(siteModel) - .usingResource(fileModel).createNewTaskAndAssignTo(userModel); - taskModel.setId(""); - restClient.authenticateUser(userModel); - restClient.withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, - executionType = ExecutionType.REGRESSION, - description = "Verify user involved in task can get completed task form models") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void getTaskFormModelsForCompletedTask() throws Exception - { - UserModel assignedUser = dataUser.createRandomTestUser(); - taskModel = dataWorkflow.usingUser(userModel) - .usingSite(siteModel) - .usingResource(fileModel).createNewTaskAndAssignTo(assignedUser); - dataWorkflow.usingUser(assignedUser).taskDone(taskModel); - dataWorkflow.usingUser(userModel).taskDone(taskModel); - restClient.authenticateUser(userModel); - returnedCollection = restClient.withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat().entriesListIsNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, - executionType = ExecutionType.REGRESSION, description = "Verify admin user gets all task form models with properties parameter applied and response is successful (200)") - public void adminGetsTaskFormModelsWithPropertiesParameter() throws Exception - { - taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(userModel); - returnedCollection = restClient.authenticateUser(adminUser).withParams("properties=qualifiedName,required").withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat().entriesListIsNotEmpty(); - returnedCollection.getOneRandomEntry().onModel() - .assertThat() - .field("qualifiedName").isNotEmpty().and() - .field("required").isNotEmpty().and() - .field("dataType").isNull().and() - .field("name").isNull().and() - .field("title").isNull().and() - .field("defaultValue").isNull().and() - .field("allowedValues").isNull().and() - .fieldsCount().is(2); - } - - @Bug(id = "MNT-17438") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify admin gets task form model with valid skipCount parameter applied using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void getTaskFormModelWithValidSkipCount() throws Exception - { - taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(userModel); - returnedCollection = restClient.authenticateUser(adminUser) - .withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); - restClient.assertStatusCodeIs(HttpStatus.OK); - RestFormModel firstTaskFormModel = returnedCollection.getEntries().get(0).onModel(); - RestFormModel secondTaskFormModel = returnedCollection.getEntries().get(1).onModel(); - - RestFormModelsCollection formModelsWithSkipCount = restClient.withParams("skipCount=2").withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); - restClient.assertStatusCodeIs(HttpStatus.OK); - formModelsWithSkipCount - .assertThat().entriesListDoesNotContain("name", firstTaskFormModel.getName()) - .assertThat().entriesListDoesNotContain("name", secondTaskFormModel.getName()) - .assertThat().entriesListCountIs(returnedCollection.getEntries().size()-2); - formModelsWithSkipCount.assertThat().paginationField("skipCount").is("2"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify admin doesn't get task form model with negative skipCount parameter applied using REST API") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void getTaskFormModelWithNegativeSkipCount() throws Exception - { - taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(userModel); - restClient.authenticateUser(adminUser).withParams("skipCount=-1").withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT) - .containsErrorKey(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE) - .statusCodeIs(HttpStatus.BAD_REQUEST); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify admin doesn't get task form model with non numeric skipCount parameter applied using REST API") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void getTaskFormModelWithNonNumericSkipCount() throws Exception - { - taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(userModel); - restClient.authenticateUser(adminUser).withParams("skipCount=A").withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "A")); - } - - @Bug(id = "MNT-17438") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify admin gets task form model with valid maxItems parameter applied using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void getTaskFormModelWithValidMaxItems() throws Exception - { - taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(userModel); - returnedCollection = restClient.authenticateUser(adminUser) - .withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); - restClient.assertStatusCodeIs(HttpStatus.OK); - RestFormModel firstTaskFormModel = returnedCollection.getEntries().get(0).onModel(); - RestFormModel secondTaskFormModel = returnedCollection.getEntries().get(1).onModel(); - - RestFormModelsCollection formModelsWithMaxItems = restClient.withParams("maxItems=2").withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); - restClient.assertStatusCodeIs(HttpStatus.OK); - formModelsWithMaxItems - .assertThat().entriesListContains("name", firstTaskFormModel.getName()) - .assertThat().entriesListContains("name", secondTaskFormModel.getName()) - .assertThat().entriesListCountIs(2); - formModelsWithMaxItems.assertThat().paginationField("maxItems").is("2"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify admin doesn't get task form model with negative maxItems parameter applied using REST API") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void getTaskFormModelWithNegativeMaxItems() throws Exception - { - taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(userModel); - restClient.authenticateUser(adminUser).withParams("maxItems=-1").withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) - .containsErrorKey(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE) - .statusCodeIs(HttpStatus.BAD_REQUEST); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify admin doesn't get task form model with non numeric maxItems parameter applied using REST API") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void getTaskFormModelWithNonNumericMaxItems() throws Exception - { - taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(userModel); - restClient.authenticateUser(adminUser).withParams("maxItems=A").withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "A")); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/GetTaskTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/GetTaskTests.java deleted file mode 100644 index a09d69c39..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/GetTaskTests.java +++ /dev/null @@ -1,212 +0,0 @@ -package org.alfresco.service.search.rest.workflow.tasks; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.core.RestRequest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestTaskModel; -import org.alfresco.rest.model.RestTaskModelsCollection; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.GroupModel; -import org.alfresco.utility.model.ProcessModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TaskModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.apache.commons.lang3.RandomStringUtils; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -/** - * - * @author Cristina Axinte - * - */ -public class GetTaskTests extends RestTest -{ - UserModel userModel, assigneeUser; - UserModel adminTenantUser, tenantUser, tenantUserAssignee, adminUser; - SiteModel siteModel; - FileModel fileModel; - TaskModel taskModel; - RestTaskModel restTaskModel, tenantTask; - RestTaskModelsCollection taskModels; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - assigneeUser = dataUser.createRandomTestUser(); - } - - @BeforeMethod(alwaysRun=true) - public void createTask() throws Exception - { - taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify admin user gets any existing task with Rest API and response is successfull (200)") - public void adminUserGetsAnyTaskWithSuccess() throws Exception - { - restTaskModel = restClient.authenticateUser(adminUser).withWorkflowAPI().usingTask(taskModel).getTask(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("description").is(taskModel.getMessage()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify assignee user gets its assigned task with Rest API and response is successfull (200)") - public void assigneeUserGetsItsTaskWithSuccess() throws Exception - { - restTaskModel = restClient.authenticateUser(assigneeUser).withWorkflowAPI().usingTask(taskModel).getTask(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("description").is(taskModel.getMessage()).and().field("assignee") - .is(assigneeUser.getUsername()); - - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify user that started the task gets the started task with Rest API and response is successfull (200)") - public void starterUserGetsItsTaskWithSuccess() throws Exception - { - restTaskModel = restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).getTask(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("description").is(taskModel.getMessage()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify any user with no relation to task id forbidden to get other task with Rest API (403)") - public void anyUserIsForbiddenToGetOtherTask() throws Exception - { - UserModel anyUser = dataUser.createRandomTestUser(); - - restTaskModel = restClient.authenticateUser(anyUser).withWorkflowAPI().usingTask(taskModel).getTask(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify candidate user gets its specific task and no other user claimed the task with Rest API and response is successfull (200)") - public void candidateUserGetsItsTasks() throws Exception - { - UserModel userModel1 = dataUser.createRandomTestUser(); - UserModel userModel2 = dataUser.createRandomTestUser(); - GroupModel group = dataGroup.createRandomGroup(); - dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); - TaskModel taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); - - restTaskModel = restClient.authenticateUser(userModel1).withWorkflowAPI().usingTask(taskModel).getTask(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("description").is(taskModel.getMessage()); - - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @Bug(id = "MNT-17051") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify involved user in a task without claim it gets the task with Rest API and response is successfull (200)") - public void involvedUserWithoutClaimTaskGetsTask() throws Exception - { - UserModel userModel1 = dataUser.createRandomTestUser(); - UserModel userModel2 = dataUser.createRandomTestUser(); - GroupModel group = dataGroup.createRandomGroup(); - dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); - TaskModel taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); - dataWorkflow.usingUser(userModel1).claimTask(taskModel); - - restTaskModel = restClient.authenticateUser(userModel2).withWorkflowAPI().usingTask(taskModel).getTask(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("description").is(taskModel.getMessage()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, - executionType = ExecutionType.REGRESSION, description = "Verify user who started a task gets the task with empty taskId with Rest API") - public void starterUserGetsTaskWithEmptyTaskId() throws Exception - { - UserModel userWhoStartsTask = dataUser.createRandomTestUser(); - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(userWhoStartsTask); - - restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI(); - RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "tasks/{taskId}", ""); - RestTaskModelsCollection tasks = restClient.processModels(RestTaskModelsCollection.class, request); - - restClient.assertStatusCodeIs(HttpStatus.OK); - tasks.assertThat().entriesListIsNotEmpty() - .and().entriesListCountIs(1) - .and().entriesListContains("id", taskModel.getId()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, - executionType = ExecutionType.REGRESSION, description = "Verify user who started a task gets the task with properties parameter with Rest API") - public void starterUserGetsTaskWithPropertiesParameter() throws Exception - { - restTaskModel = restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).usingParams("properties=id,assignee,formResourceKey").getTask(); - - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().fieldsCount().is(3) - .and().field("id").is(taskModel.getId()) - .and().field("assignee").is(taskModel.getAssignee()) - .and().field("formResourceKey").is("wf:adhocTask") - .and().field("processDefinitionId").isNull() - .and().field("processId").isNull(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, - executionType = ExecutionType.REGRESSION, description = "Verify user who started a task gets the task after it is deleted with Rest API") - public void starterUserGetsDeletedTask() throws Exception - { - restTaskModel = restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).getTask(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()); - - ProcessModel process = new ProcessModel(); - process.setId(taskModel.getProcessId()); - dataWorkflow.usingUser(userModel).deleteProcess(process); - - restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).getTask(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, taskModel.getId())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify if using invalid taskId status code 404 is returned.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void invalidTaskId() throws Exception - { - taskModel.setId(RandomStringUtils.randomAlphanumeric(20)); - restTaskModel = restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).getTask(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, taskModel.getId())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify if using empty taskId status code 200 is returned.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void emptyTaskId() throws Exception - { - restClient.authenticateUser(userModel).withWorkflowAPI(); - RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "tasks/{taskId}", ""); - taskModels = restClient.processModels(RestTaskModelsCollection.class, request); - restClient.assertStatusCodeIs(HttpStatus.OK); - taskModels.assertThat().entriesListIsNotEmpty(); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/GetTasksTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/GetTasksTests.java deleted file mode 100644 index 7f84dcbdf..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/GetTasksTests.java +++ /dev/null @@ -1,234 +0,0 @@ -package org.alfresco.service.search.rest.workflow.tasks; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestTaskModel; -import org.alfresco.rest.model.RestTaskModelsCollection; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.GroupModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TaskModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class GetTasksTests extends RestTest -{ - UserModel userModel, userNotInvolved, assigneeUser, adminUser; - UserModel adminTenantUser, tenantUser, tenantUserAssignee; - SiteModel siteModel; - FileModel fileModel; - RestTaskModelsCollection taskModels, taskCollections, tenantTask; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userModel = dataUser.createRandomTestUser(); - userNotInvolved = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - - assigneeUser = dataUser.createRandomTestUser(); - dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify admin user gets all existing tasks with Rest API and response is successfull (200)") - public void adminUserGetsAllTasks() throws Exception - { - UserModel adminUser = dataUser.getAdminUser(); - - taskModels = restClient.authenticateUser(adminUser).withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - taskModels.assertThat().entriesListIsNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify asignee user gets its existing tasks with Rest API and response is successfull (200)") - public void assigneeUserGetsItsTasks() throws Exception - { - taskModels = restClient.authenticateUser(assigneeUser).withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - taskModels.assertThat().entriesListIsNotEmpty().and().entriesListCountIs(1).and().entriesListContains("assignee", assigneeUser.getUsername()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify candidate user that claims the task gets its existing tasks with Rest API and response is successfull (200)") - @Bug(id = "MNT-16967") - public void candidateUserGetsItsTasks() throws Exception - { - UserModel userModel1 = dataUser.createRandomTestUser(); - UserModel userModel2 = dataUser.createRandomTestUser(); - GroupModel group = dataGroup.createRandomGroup(); - - dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); - dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); - - taskModels = restClient.authenticateUser(userModel1).withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - taskModels.assertThat().entriesListIsNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify candidate user that claims the task gets its existing tasks with Rest API and response is successfull (200)") - public void candidateUserThatClaimsTaskGetsItsTasks() throws Exception - { - UserModel userModel1 = dataUser.createRandomTestUser(); - UserModel userModel2 = dataUser.createRandomTestUser(); - GroupModel group = dataGroup.createRandomGroup(); - dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); - TaskModel taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); - dataWorkflow.usingUser(userModel1).claimTask(taskModel); - - taskModels = restClient.authenticateUser(userModel1).withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - taskModels.assertThat().entriesListIsNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify candidate user without claim gets no tasks with Rest API and response is successfull (200)") - public void candidateUserWithoutClaimTaskGetsNoTasks() throws Exception - { - UserModel userModel1 = dataUser.createRandomTestUser(); - UserModel userModel2 = dataUser.createRandomTestUser(); - GroupModel group = dataGroup.createRandomGroup(); - - dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); - TaskModel taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); - dataWorkflow.usingUser(userModel1).claimTask(taskModel); - - taskModels = restClient.authenticateUser(userModel2).withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - taskModels.assertThat().entriesListIsEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check that skipCount parameter is applied.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void skipCountParameterApplied() throws Exception - { - taskCollections = restClient.authenticateUser(dataUser.getAdminUser()).withParams("orderBy=description ASC").withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - RestTaskModel firstTask = taskCollections.getEntries().get(0).onModel(); - RestTaskModel secondTask = taskCollections.getEntries().get(1).onModel(); - - taskModels = restClient.withParams("orderBy=description ASC&skipCount=2").withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - taskModels.assertThat().entriesListDoesNotContain("id", firstTask.getId()) - .assertThat().entriesListDoesNotContain("id", secondTask.getId()); - taskModels.assertThat().paginationField("skipCount").is("2"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check that maxItems parameter is applied.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void maxItemsParameterApplied() throws Exception - { - restClient.authenticateUser(userModel).withWorkflowAPI().addProcess("activitiAdhoc", assigneeUser, false, Priority.Low); - restClient.authenticateUser(userModel).withWorkflowAPI().addProcess("activitiAdhoc", adminUser, false, Priority.Low); - taskCollections = restClient.authenticateUser(userModel).withParams("orderBy=assignee ASC").withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - taskModels = restClient.withParams("orderBy=startedAt DESC&maxItems=2").withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - taskModels.assertThat().entriesListIsNotEmpty() - .assertThat().entriesListContains("assignee", assigneeUser.getUsername()) - .assertThat().entriesListDoesNotContain("assignee", userModel.getUsername()); - taskModels.assertThat().paginationField("maxItems").is("2"); - taskModels.assertThat().paginationField("count").is("2"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check that properties parameter is applied.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void propertiesParameterApplied() throws Exception - { - taskModels = restClient.authenticateUser(dataUser.getAdminUser()).withParams("properties=name,description").withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - taskModels.assertThat().entriesListIsNotEmpty() - .assertThat().entriesListContains("name") - .assertThat().entriesListContains("description") - .assertThat().entriesListDoesNotContain("processDefinitionId") - .assertThat().entriesListDoesNotContain("processId") - .assertThat().entriesListDoesNotContain("startedAt") - .assertThat().entriesListDoesNotContain("id") - .assertThat().entriesListDoesNotContain("state") - .assertThat().entriesListDoesNotContain("activityDefinitionId") - .assertThat().entriesListDoesNotContain("priority") - .assertThat().entriesListDoesNotContain("formResourceKey"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Use invalid where parameter. Check default error model schema.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void invalidWhereParameterCheckDefaultErrorModelSchema() throws Exception - { - restClient.authenticateUser(dataUser.getAdminUser()).where("assignee AND '" + assigneeUser.getUsername() + "'").withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(RestErrorModel.INVALID_QUERY_ERRORKEY) - .containsSummary(String.format(RestErrorModel.INVALID_WHERE_QUERY, "(assignee AND '" + assigneeUser.getUsername() + "')")) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify the request in case of any user which is not involved.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void requestWithUserNotInvolved() throws Exception - { - taskModels = restClient.authenticateUser(userNotInvolved).withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - taskModels.assertThat().entriesListIsEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check that orderBy parameter is applied.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void orderByParameterApplied() throws Exception - { - taskModels = restClient.authenticateUser(dataUser.getAdminUser()).withParams("orderBy=id").withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - taskModels.assertThat().entriesListIsNotEmpty(). - and().entriesListIsSortedAscBy("id"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check that orderBy parameter is applied and supports only one parameter.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void orderByParameterSupportsOnlyOneParameter() throws Exception - { - taskModels = restClient.authenticateUser(dataUser.getAdminUser()).withParams("orderBy=id,processDefinitionId").withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Only one order by parameter is supported"); - taskModels.assertThat().entriesListIsEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check that where parameter is applied.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void whereParameterApplied() throws Exception - { - UserModel anotherAssignee = dataUser.createRandomTestUser(); - dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(anotherAssignee); - taskModels = restClient.authenticateUser(dataUser.getAdminUser()).withParams("where=(assignee='" + anotherAssignee.getUsername() + "')").withWorkflowAPI() - .getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - taskModels.assertThat().entriesListIsNotEmpty().and().entriesListContains("assignee", anotherAssignee.getUsername()).and().entriesListCountIs(1); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check that invalid orderBy parameter applied returns 400 status code.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void invalidOrderByParameterApplied() throws Exception - { - restClient.authenticateUser(dataUser.getAdminUser()).withParams("orderBy=invalidParameter").withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("invalidParameter is not supported"); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/UpdateTaskTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/UpdateTaskTests.java deleted file mode 100644 index 304f57b03..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/UpdateTaskTests.java +++ /dev/null @@ -1,1639 +0,0 @@ -package org.alfresco.service.search.rest.workflow.tasks; - -import java.util.HashMap; - -import javax.json.JsonObject; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.core.JsonBodyGenerator; -import org.alfresco.rest.core.RestRequest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestProcessDefinitionModel; -import org.alfresco.rest.model.RestTaskModel; -import org.alfresco.rest.model.RestVariableModelsCollection; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.GroupModel; -import org.alfresco.utility.model.ProcessModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TaskModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -public class UpdateTaskTests extends RestTest -{ - UserModel owner, anyUser; - SiteModel siteModel; - FileModel fileModel; - UserModel assigneeUser; - TaskModel taskModel; - RestTaskModel restTaskModel; - UserModel adminUser; - RestProcessDefinitionModel activitiReviewProcessDefinition; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - owner = dataUser.createRandomTestUser(); - anyUser = dataUser.createRandomTestUser(); - assigneeUser = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - activitiReviewProcessDefinition = restClient.authenticateUser(adminUser).withWorkflowAPI().getAllProcessDefinitions().getProcessDefinitionByKey("activitiReviewPooled"); - } - - @BeforeMethod(alwaysRun = true) - public void createTask() throws Exception - { - taskModel = dataWorkflow.usingUser(owner).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify admin user updates task with Rest API and response is successfull (200)") - public void adminUserUpdatesAnyTaskWithSuccess() throws Exception - { - restTaskModel = restClient.authenticateUser(adminUser).withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("description").is(taskModel.getMessage()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify assignee user updates its assigned task with Rest API and response is successfull (200)") - public void assigneeUserUpdatesItsTaskWithSuccess() throws Exception - { - restTaskModel = restClient.authenticateUser(assigneeUser).withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("description").is(taskModel.getMessage()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify user that started the task updates the started task with Rest API and response is successfull (200)") - public void starterUserUpdatesItsTaskWithSuccess() throws Exception - { - restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify any user with no relation to task is forbidden to update other task with Rest API (403)") - public void anyUserIsForbiddenToUpdateOtherTask() throws Exception - { - restTaskModel = restClient.authenticateUser(anyUser).withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify candidate user updates its specific task and no other user claimed the task with Rest API and response is successfull (200)") - public void candidateUserUpdatesItsTasks() throws Exception - { - UserModel userModel1 = dataUser.createRandomTestUser(); - UserModel userModel2 = dataUser.createRandomTestUser(); - GroupModel group = dataGroup.createRandomGroup(); - dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); - TaskModel taskModel = dataWorkflow.usingUser(owner).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); - - restTaskModel = restClient.authenticateUser(userModel1).withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat() - .field("dueAt").isNotEmpty() - .and().field("processDefinitionId").is(activitiReviewProcessDefinition.getId()) - .and().field("processId").is(taskModel.getProcessId()) - .and().field("name").is("Review Task") - .and().field("description").is(taskModel.getMessage()) - .and().field("startedAt").isNotEmpty() - .and().field("id").is(taskModel.getId()) - .and().field("state").is("unclaimed") - .and().field("activityDefinitionId").is("reviewTask") - .and().field("priority").is(taskModel.getPriority().getLevel()) - .and().field("formResourceKey").is("wf:activitiReviewTask"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task owner can update twice task with status resolve successfully (200)") - public void taskOwnerCanUpdateTaskWithResolveStateTwice() throws Exception - { - restTaskModel = restClient.authenticateUser(assigneeUser) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("resolved"); - - restClient.authenticateUser(owner) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task asignee cannot update twice task with status resolve - Forbidden (403)") - public void taskAssigneeCanNotUpdateTaskWithResolveStateTwice() throws Exception - { - restTaskModel = restClient.authenticateUser(assigneeUser) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("resolved"); - - restClient.authenticateUser(assigneeUser) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task cannot be update using a invalid json body property - Bad Request (400)") - public void taskCanNotBeUpdatedWithInvalidJsonBodyProperty() throws Exception - { - String invalidJsonProperty= "states"; - restClient.authenticateUser(assigneeUser) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel); - String postBody = JsonBodyGenerator.keyValueJson(invalidJsonProperty, "completed"); - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); - restClient.processModel(RestTaskModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.NO_CONTENT, "Unrecognized field \""+invalidJsonProperty+"\"")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task cannot be update using a invalid state - Bad Request (400)") - public void taskCanNotBeUpdatedWithInvalidState() throws Exception - { - restTaskModel = restClient.authenticateUser(assigneeUser) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("continued"); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_VALUE, "task state", "continued")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task cannot be update using a invalid property - Bad Request (400)") - public void taskCanNotBeUpdatedWithInvalidSelectProperty() throws Exception - { - String invalidProperty= "states"; - restClient.authenticateUser(assigneeUser) - .withParams("select=" + invalidProperty).withWorkflowAPI().usingTask(taskModel); - String postBody = JsonBodyGenerator.keyValueJson("state", "completed"); - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); - restClient.processModel(RestTaskModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.PROPERTY_DOES_NOT_EXIST, invalidProperty)); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task can be update using multiple select values successfully (200)") - public void taskCanBeUpdatedWithMultipleSelectValues() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("state", "resolved") - .add("assignee", "admin").build(); - - restTaskModel = restClient.authenticateUser(assigneeUser) - .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("resolved"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, - description = "Verify task assignee can complete task successfully (200)") - public void taskAssigneeCanCompleteTask() throws Exception - { - restTaskModel = restClient.authenticateUser(assigneeUser) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("completed"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, - description = "Verify task owner can complete task successfully (200))") - public void taskOwnerCanCompleteTask() throws Exception - { - restTaskModel = restClient.authenticateUser(assigneeUser) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("completed"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify any user cannot complete task - Forbidden (403))") - public void anyUserCannotCompleteTask() throws Exception - { - UserModel anyUser = dataUser.createRandomTestUser(); - - restTaskModel = restClient.authenticateUser(anyUser) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @Bug(id = "REPO-2062") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task owner cannot complete task with invalid name - Bad Request(400))") - public void taskOwnerCannotCompleteTaskWithInvalidName() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("state", "completed") - .add("variables", JsonBodyGenerator.defineJSONArray() - .add(JsonBodyGenerator.defineJSON() - .add("name", "bpmx_priorityx") - .add("type", "d:int") - .add("value", 1) - .add("scope", "global").build()) - ).build(); - - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state,variables").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.UNSUPPORTED_TYPE,"bpm_priorityx")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task owner cannot complete task with invalid Type - Bad Request(400))") - public void taskOwnerCannotCompleteTaskWithInvalidType() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("state", "completed") - .add("variables", JsonBodyGenerator.defineJSONArray() - .add(JsonBodyGenerator.defineJSON() - .add("name", "bpmx_priority") - .add("type", "d_int") - .add("value", 1) - .add("scope", "global").build()) - ).build(); - - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state,variables").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.UNSUPPORTED_TYPE,"d_int")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @Bug(id = "REPO-2062") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task owner cannot complete task with invalid value - Bad Request(400))") - public void taskOwnerCannotCompleteTaskWithInvalidValue() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("state", "completed") - .add("variables", JsonBodyGenerator.defineJSONArray() - .add(JsonBodyGenerator.defineJSON() - .add("name", "bpmx_priority") - .add("type", "d:int") - .add("value", "text") - .add("scope", "global").build()) - ).build(); - - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state,variables").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.UNSUPPORTED_TYPE, "text")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task owner cannot complete task with invalid scope - Bad Request(400))") - public void taskOwnerCannotCompleteTaskWithInvalidScope() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("state", "completed") - .add("variables", JsonBodyGenerator.defineJSONArray() - .add(JsonBodyGenerator.defineJSON() - .add("name", "bpmx_priority") - .add("type", "d:int") - .add("value", 1) - .add("scope", "globalscope").build()) - ).build(); - - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state,variables").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.ILLEGAL_SCOPE, "globalscope")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task assignee can claim task successfully (200)") - public void taskAssigneeCanClaimTask() throws Exception - { - restTaskModel = restClient.authenticateUser(assigneeUser) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("claimed"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task assignee can unclaim task successfully (200)") - public void taskAssigneeCanUnclaimTask() throws Exception - { - restTaskModel = restClient.authenticateUser(assigneeUser) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("unclaimed"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task assignee can delegate task successfully (200)") - public void taskAssigneeCanDelegateTask() throws Exception - { - UserModel delagateToUser = dataUser.createRandomTestUser(); - - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("state", "delegated") - .add("assignee", delagateToUser.getUsername()).build(); - - restTaskModel = restClient.authenticateUser(assigneeUser) - .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("delegated") - .and().field("assignee").is(delagateToUser.getUsername()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task owner can delegate task to same assignee successfully (200)") - public void taskOwnerCanDelegateTaskToSameAssignee() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("state", "delegated") - .add("assignee", assigneeUser.getUsername()).build(); - - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("delegated") - .and().field("assignee").is(assigneeUser.getUsername()); - } - - - @Bug(id = "REPO-2063") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task assignee cannot delegate task to task owner - (400)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void taskAssigneeCannotDelegateTaskToTaskOwner() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("state", "delegated") - .add("assignee", owner.getUsername()).build(); - - restTaskModel = restClient.authenticateUser(assigneeUser) - .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @Bug(id = "REPO-2063") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task assignee cannot delegate task to invalid assignee - (400)") - public void taskAssigneeCannotDelegateTaskToInvalidAssignee() throws Exception - { - UserModel invalidAssignee = new UserModel("invalidAssignee", "password"); - - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("state", "delegated") - .add("assignee", invalidAssignee.getUsername()).build(); - - restTaskModel = restClient.authenticateUser(assigneeUser) - .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task assignee can update task with status resolve") - public void resolveTaskAsCurrentAssignee() throws Exception - { - restTaskModel = restClient.authenticateUser(assigneeUser) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("resolved"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify update task using invalid taskId") - public void updateTaskUsingInvalidTaskId() throws Exception - { - taskModel.setId("invalidId"); - - restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidId")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify update task using another name") - public void updateTaskUsingAnotherName() throws Exception - { - restClient.authenticateUser(owner).withParams("select=name").withWorkflowAPI().usingTask(taskModel); - String postBody = "{\"name\":\"newNameTask\"}"; - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); - restTaskModel = restClient.processModel(RestTaskModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("name").is("newNameTask"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify update task using another description") - public void updateTaskUsingAnotherDescription() throws Exception - { - restClient.authenticateUser(owner).withParams("select=description").withWorkflowAPI().usingTask(taskModel); - String postBody = "{\"description\":\"newDescription\"}"; - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); - restTaskModel = restClient.processModel(RestTaskModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("description").is("newDescription"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify update task using another priority") - public void updateTaskUsingAnotherPriority() throws Exception - { - restClient.authenticateUser(owner).withParams("select=priority").withWorkflowAPI().usingTask(taskModel); - String postBody = "{\"priority\":3}"; - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); - restTaskModel = restClient.processModel(RestTaskModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("priority").is(CMISUtil.Priority.Low.getLevel()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify update task using another priority") - public void updateTaskUsingAnotherOwner() throws Exception - { - UserModel newOwner = dataUser.createRandomTestUser(); - - restClient.authenticateUser(owner).withParams("select=owner").withWorkflowAPI().usingTask(taskModel); - String postBody = "{\"owner\":\""+newOwner.getUsername()+"\"}"; - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); - restTaskModel = restClient.processModel(RestTaskModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("owner").is(newOwner.getUsername()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can not update task from completed to claimed and response is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void taskOwnerCanNotUpdateTaskFromCompletedToClaimed() throws Exception - { - restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("completed"); - restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() - .containsSummary(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can not update task from completed to unclaimed and response is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void taskOwnerCanNotUpdateTaskFromCompletedToUnclaimed() throws Exception - { - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("completed"); - restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() - .containsSummary(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can not update task from completed to completed and response is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void taskOwnerCanNotUpdateTaskWithCompleteStateTwice() throws Exception - { - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("completed"); - restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() - .containsSummary(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can update task from claimed to completed and response is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void taskOwnerCanUpdateTaskFromClaimedToCompleted() throws Exception - { - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("claimed"); - restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("completed"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify user can update task from claimed to claimed and response is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void userCanUpdateTaskWithClaimedStateTwice() throws Exception - { - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("claimed"); - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("claimed"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can update task from unclaimed to completed and response is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void taskOwnerCanUpdateTaskFromUnclaimedToCompleted() throws Exception - { - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); - restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("completed"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can not update task from unclaimed to unclaimed and response is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void taskOwnerCanNotUpdateTaskWithUnclaimedStateTwice() throws Exception - { - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); - restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); - } - - @Bug(id = "REPO-1924") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can not update task from delegated to completed and response is 422") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void taskOwnerCanNotUpdateTaskFromDelegatedToCompleted() throws Exception - { - restClient.authenticateUser(owner).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel); - HashMap body = new HashMap(); - body.put("state", "delegated"); - body.put("assignee", assigneeUser.getUsername()); - String postBody = JsonBodyGenerator.keyValueJson(body); - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), - restClient.getParameters()); - restTaskModel = restClient.processModel(RestTaskModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated").and().field("assignee") - .is(assigneeUser.getUsername()); - - restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(RestErrorModel.DELEGATED_TASK_CAN_NOT_BE_COMPLETED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can not update task from delegated to delegated and response is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void taskOwnerCanNotUpdateTaskWithDelegatedStateTwice() throws Exception - { - restClient.authenticateUser(owner).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel); - HashMap body = new HashMap(); - body.put("state", "delegated"); - body.put("assignee", assigneeUser.getUsername()); - String postBody = JsonBodyGenerator.keyValueJson(body); - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), - restClient.getParameters()); - restTaskModel = restClient.processModel(RestTaskModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated").and().field("assignee") - .is(assigneeUser.getUsername()); - - request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); - restTaskModel = restClient.processModel(RestTaskModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated").and().field("assignee") - .is(assigneeUser.getUsername()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can update task from resolved to completed and response is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void taskOwnerCanUpdateTaskFromResolvedToCompleted() throws Exception - { - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("resolved"); - - restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("completed"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify owner cannot update task from status completed to delegated and response is 404") - public void ownerCannotUpdateTaskFromCompletedToDelegated() throws Exception - { - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("completed"); - - restClient.authenticateUser(owner) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("delegated"); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() - .containsErrorKey(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) - .containsSummary(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify assignee cannot update task from status completed to delegated and response is 404") - public void assigneeCannotUpdateTaskFromCompletedToDelegated() throws Exception - { - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("completed"); - - restClient.authenticateUser(assigneeUser) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("delegated"); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() - .containsErrorKey(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) - .containsSummary(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify owner cannot update task from status completed to resolved and response is 404") - public void ownerCannotUpdateTaskFromCompletedToResolved() throws Exception - { - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("completed"); - - restClient.authenticateUser(owner) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() - .containsErrorKey(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) - .containsSummary(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify assignee cannot update task from status completed to resolved and response is 404") - public void assigneeCannotUpdateTaskFromCompletedToResolved() throws Exception - { - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("completed"); - - restClient.authenticateUser(assigneeUser) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() - .containsErrorKey(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) - .containsSummary(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify owner cannot update task from status completed to completed and response is 404") - public void ownerCannotUpdateTaskFromCompletedToCompleted() throws Exception - { - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("completed"); - - restClient.authenticateUser(owner) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() - .containsErrorKey(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) - .containsSummary(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify assignee cannot update task from status completed to completed and response is 404") - public void assigneeCannotUpdateTaskFromCompletedToCompleted() throws Exception - { - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("completed"); - - restClient.authenticateUser(assigneeUser) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() - .containsErrorKey(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) - .containsSummary(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify owner can update task from status claimed to unclaimed and response is 200") - public void ownerCanUpdateTaskFromClaimedToUnclaimed() throws Exception - { - restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).getTask(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("claimed"); - - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("unclaimed"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify assignee can update task from status claimed to unclaimed and response is 200") - public void assigneeCanUpdateTaskFromClaimedToUnclaimed() throws Exception - { - restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).getTask(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("claimed"); - - restTaskModel = restClient.authenticateUser(assigneeUser) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("unclaimed"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify owner can update task from status claimed to delegated and response is 200") - public void ownerCanUpdateTaskFromClaimedToDelegated() throws Exception - { - restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).getTask(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("claimed"); - - UserModel newAssignee = dataUser.createRandomTestUser(); - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("state", "delegated") - .add("assignee", newAssignee.getUsername()).build(); - - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("delegated") - .and().field("assignee").is(newAssignee.getUsername()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify assignee can update task from status claimed to delegated and response is 200") - public void assigneeCanUpdateTaskFromClaimedToDelegated() throws Exception - { - restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).getTask(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("claimed"); - - UserModel newAssignee = dataUser.createRandomTestUser(); - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("state", "delegated") - .add("assignee", newAssignee.getUsername()).build(); - - restTaskModel = restClient.authenticateUser(assigneeUser) - .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("delegated") - .and().field("assignee").is(newAssignee.getUsername()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify owner can update task from status claimed to resolved and response is 200") - public void ownerCanUpdateTaskFromClaimedToResolved() throws Exception - { - restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).getTask(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("claimed"); - - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("resolved"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify assignee can update task from status claimed to resolved and response is 200") - public void assigneeCanUpdateTaskFromClaimedToResolved() throws Exception - { - restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).getTask(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("claimed"); - - restTaskModel = restClient.authenticateUser(assigneeUser) - .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("resolved"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify owner cannot update task from status claimed to claimed and response is 409") - public void ownerCannotUpdateTaskFromClaimedToClaimed() throws Exception - { - restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).getTask(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("claimed"); - - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); - restClient.assertStatusCodeIs(HttpStatus.CONFLICT).assertLastError() - .containsErrorKey(RestErrorModel.TASK_ALREADY_CLAIMED) - .containsSummary(RestErrorModel.TASK_ALREADY_CLAIMED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify assignee can update task from status claimed to claimed and response is 200") - public void assigneeCanUpdateTaskFromClaimedToClaimed() throws Exception - { - restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).getTask(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("claimed"); - - restTaskModel = restClient.authenticateUser(assigneeUser) - .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("claimed"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task owner can complete task with valid variables and response is 200") - public void taskOwnerCanCompleteTaskWithValidVariables() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("state", "completed") - .add("variables", JsonBodyGenerator.defineJSONArray() - .add(JsonBodyGenerator.defineJSON() - .add("name", "bpm_priority") - .add("type", "d:int") - .add("value", 3) - .add("scope", "global").build()) - ).build(); - - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state,variables").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("priority").is(1) - .and().field("state").is("completed") - .and().field("assignee").is(taskModel.getAssignee()); - RestVariableModelsCollection variables = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(restTaskModel).getTaskVariables(); - restClient.assertStatusCodeIs(HttpStatus.OK); - variables.getVariableByName("bpm_priority").assertThat().field("scope").is("global") - .and().field("name").is("bpm_priority") - .and().field("type").is("d:int") - .and().field("value").is(3); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task owner cannot complete task with empty variables array and response is 200") - public void taskOwnerCannotUpdateTaskWithEmptyVariablesArray() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("state", "completed") - .add("variables", JsonBodyGenerator.defineJSONArray() - ).build(); - - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state,variables").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("priority").is(1) - .and().field("state").is("completed") - .and().field("assignee").is(taskModel.getAssignee()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task owner cannot complete task with empty variables json body and response is 200") - public void taskOwnerCannotUpdateTaskWithEmptyVariablesJsonBody() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("state", "completed") - .add("variables", JsonBodyGenerator.defineJSONArray() - .add(JsonBodyGenerator.defineJSON().build()) - ).build(); - - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state,variables").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(RestErrorModel.VARIABLE_NAME_REQUIRED) - .containsSummary(RestErrorModel.VARIABLE_NAME_REQUIRED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify any user with no relation to task is forbidden to delegate other task with Rest API (403)") - public void anyUserIsForbiddenToDelegateOtherTask() throws Exception - { - restTaskModel = restClient.authenticateUser(anyUser).withWorkflowAPI().usingTask(taskModel).updateTask("delegated"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify any user with no relation to task is forbidden to resolve other task with Rest API (403)") - public void anyUserIsForbiddenToResolveOtherTask() throws Exception - { - restTaskModel = restClient.authenticateUser(anyUser).withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify any user with no relation to task is forbidden to claim other task with Rest API (403)") - public void anyUserIsForbiddenToClaimOtherTask() throws Exception - { - restTaskModel = restClient.authenticateUser(anyUser).withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify any user with no relation to task is forbidden to unclaim other task with Rest API (403)") - public void anyUserIsForbiddenToUnclaimOtherTask() throws Exception - { - restTaskModel = restClient.authenticateUser(anyUser).withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify user cannot delegate task with emty assignee name and response is 400") - public void updateTaskWithEmptyAssigneeValue() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("state", "delegated") - .add("assignee", "") - .build(); - - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(RestErrorModel.DELEGATING_ASSIGNEE_PROVIDED) - .containsSummary(RestErrorModel.DELEGATING_ASSIGNEE_PROVIDED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify owner can resolve task when assignee is the owner and response is 200") - public void taskOwnerUpdateTaskResolveStateAndOwnerAssignee() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("state", "resolved") - .add("assignee", owner.getUsername()) - .build(); - - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("state").is("resolved") - .and().field("assignee").isNull(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify owner cannot update task after it was deleted and response is 404") - public void updateTaskAfterItWasDeleted() throws Exception - { - ProcessModel process = new ProcessModel(); - process.setId(taskModel.getProcessId()); - dataWorkflow.usingUser(owner).deleteProcess(process); - - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.ENTITY_WAS_NOT_FOUND, taskModel.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task owner cannot update task with empty input body and response is 400") - public void taskOwnerCannotUpdateTaskWithEmptyInputBody() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON().build(); - - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(String.format(RestErrorModel.TASK_INVALID_STATE, "null")) - .containsSummary(String.format(RestErrorModel.TASK_INVALID_STATE, "null")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify any user cannot update task using another name") - public void anyUserCannotUpdateTaskUsingAnotherName() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("name", "Review Task-updated") - .build(); - - restClient.authenticateUser(anyUser).withParams("select=name").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify any user cannot update task using another description") - public void anyUserCannotUpdateTaskUsingAnotherDescription() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("description", "description updated") - .build(); - - restClient.authenticateUser(anyUser).withParams("select=description").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify any user cannot update task using another dueAt") - public void anyUserCannotUpdateTaskUsingAnotherDueAt() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("dueAt", "2025-01-01T11:57:32.000+0000") - .build(); - - restClient.authenticateUser(anyUser).withParams("select=dueAt").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify any user cannot update task using another priority") - public void anyUserCannotUpdateTaskUsingAnotherPriority() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("priority", 3) - .build(); - - restClient.authenticateUser(anyUser).withParams("select=priority").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify any user cannot update task using another priority") - public void anyUserCannotUpdateTaskUsingAnotherOwner() throws Exception - { - UserModel newOwner = dataUser.createRandomTestUser(); - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("owner", newOwner.getUsername()) - .build(); - - - restClient.authenticateUser(anyUser).withParams("select=owner").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify any user cannot update task using invalid name") - public void anyUserCannotUpdateTaskUsingInvalidName() throws Exception - { - restClient.authenticateUser(owner).withParams("select=name").withWorkflowAPI().usingTask(taskModel); - String postBody = "{\"name\":\"invalid-\"a\"}"; - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); - restTaskModel = restClient.processModel(RestTaskModel.class, request); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "Unexpected character ('a'")) - .containsSummary(String.format(RestErrorModel.NO_CONTENT, "Unexpected character ('a'")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify any user cannot update task using invalid description") - public void anyUserCannotUpdateTaskUsingInvalidDescription() throws Exception - { - restClient.authenticateUser(owner).withParams("select=description").withWorkflowAPI().usingTask(taskModel); - String postBody = "{\"description\":\"invalid-\"a\"}"; - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); - restTaskModel = restClient.processModel(RestTaskModel.class, request); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "Unexpected character ('a'")) - .containsSummary(String.format(RestErrorModel.NO_CONTENT, "Unexpected character ('a'")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify any user cannot update task using invalid dueAt") - public void anyUserCannotUpdateTaskUsingInvalidDueAt() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("dueAt", "invalid-date") - .build(); - - restClient.authenticateUser(anyUser).withParams("select=dueAt").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify any user cannot update task using invalid priority") - public void anyUserCannotUpdateTaskUsingInvalidPriority() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("priority", "a") - .build(); - - restClient.authenticateUser(anyUser).withParams("select=priority").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify any user cannot update task using invalid priority") - public void anyUserCannotUpdateTaskUsingInvalidOwner() throws Exception - { - restClient.authenticateUser(owner).withParams("select=owner").withWorkflowAPI().usingTask(taskModel); - String postBody = "{\"owner\":\"invalid-\"a\"}"; - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); - restTaskModel = restClient.processModel(RestTaskModel.class, request); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "Unexpected character ('a'")) - .containsSummary(String.format(RestErrorModel.NO_CONTENT, "Unexpected character ('a'")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from unclaimed to claimed by task creator") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void taskCreatorCanUpdateTaskFromUnclaimedToClaimed() throws Exception - { - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); - restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("claimed"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task cannot be updated from unclaimed to claimed by a regular user not connected to the task") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void regularUserCannotUpdateTaskFromUnclaimedToClaimed() throws Exception - { - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from unclaimed to delegated by task creator") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void taskCreatorCanUpdateTaskFromUnclaimedToDelegated() throws Exception - { - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); - - JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", owner.getUsername()).build(); - - restTaskModel = restClient.authenticateUser(owner).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task cannot be updated from unclaimed to delegated by a regular user not connected to the task") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void regularUserCannotUpdateTaskFromUnclaimedToDelegated() throws Exception - { - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); - - JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); - - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from unclaimed to resolved by task creator") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void taskCreatorCanUpdateTaskFromUnclaimedToResolved() throws Exception - { - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); - restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("resolved"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from unclaimed to resolved by a regular user not connected to the task") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void regularCanNotUpdateTaskFromUnclaimedToResolved() throws Exception - { - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from unclaimed to unclaimed by task creator") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void taskCreatorCanUpdateTaskFromUnclaimedToUnclaimed() throws Exception - { - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); - restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from unclaimed to unclaimed by a regular user not connected to the task") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void regularUserCannotUpdateTaskFromUnclaimedToUnclaimed() throws Exception - { - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Bug(id = "REPO-1982") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from delegated to unclaimed by task creator") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void taskCreatorCanUpdateTaskFromDelegatedToUnclaimed() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); - - restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); - } - - @Bug(id = "REPO-1982") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from delegated to unclaimed by task assignee") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void taskAssigneeCanUpdateTaskFromDelegatedToUnclaimed() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); - - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task cannot be updated from delegated to claimed since it is already claimed by task creator") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void taskCreatorCannotUpdateTaskFromDelegatedToClaimed() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); - - restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); - restClient.assertStatusCodeIs(HttpStatus.CONFLICT).assertLastError() - .containsErrorKey(RestErrorModel.TASK_ALREADY_CLAIMED) - .containsSummary(RestErrorModel.TASK_ALREADY_CLAIMED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from delegated to claimed since it is already claimed by task assignee") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void taskAssigneeCanUpdateTaskFromDelegatedToClaimed() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); - - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); - } - - @Bug(id = "REPO-1924") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from delegated to completed by task creator") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void taskCreatorCanUpdateTaskFromDelegatedToCompleted() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); - - restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() - .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .containsSummary(RestErrorModel.DELEGATED_TASK_CAN_NOT_BE_COMPLETED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Bug(id = "REPO-1924") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from delegated to completed by task assignee") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void taskAssigneeCanUpdateTaskFromDelegatedToCompleted() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); - - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() - .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .containsSummary(RestErrorModel.DELEGATED_TASK_CAN_NOT_BE_COMPLETED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from delegated to resolved") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void taskCreatorCanUpdateTaskFromDelegatedToResolved() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); - - restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("resolved"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from delegated to resolved by task assignee") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void taskAssigneeCanUpdateTaskFromDelegatedToResolved() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); - - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("resolved"); - } - - @Bug(id = "REPO-1982") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from resolved to unclaimed by task creator") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void taskCreatorCanUpdateTaskFromResolvedToUnclaimed() throws Exception - { - restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - - restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("resolved"); - } - - @Bug(id = "REPO-1982") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task cannot be updated from resolved to unclaimed by task assignee") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void taskAssigneeCannotUpdateTaskFromResolvedToUnclaimed() throws Exception - { - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Bug(id = "REPO-1982") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task cannot be updated from resolved to claimed by task owner") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void taskOwnerCanUpdateTaskFromResolvedToClaimed() throws Exception - { - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - - restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("resolved"); - } - - @Bug(id = "REPO-1982") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task cannot be updated from resolved to claimed by task assignee") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void taskAssigneeCanUpdateTaskFromResolvedToClaimed() throws Exception - { - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Bug(id = "REPO-1982") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from resolved to delegated by task creator") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void taskCreatorCannotUpdateTaskFromResolvedToDelegated() throws Exception - { - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - - JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); - restTaskModel = restClient.authenticateUser(owner).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from resolved to delegated by task assignee") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void taskAssigneeCannotUpdateTaskFromResolvedToDelegated() throws Exception - { - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - - JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Bug(id = "REPO-1982") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from resolved to resolved by task creator") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void taskCreatorCannotUpdateTaskFromResolvedToResolved() throws Exception - { - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - - restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("resolved"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from resolved to resolved by task assignee") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void taskAssigneeCannotUpdateTaskFromResolvedToResolved() throws Exception - { - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Bug(id = "REPO-1982") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Update task by providing empty select value") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void updateTaskByProvidingEmptySelectValue() throws Exception - { - restTaskModel = restClient.authenticateUser(owner).withParams("select=").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(RestErrorModel.INVALID_SELECT_ERRORKEY) - .containsSummary(RestErrorModel.INVALID_SELECT) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Update task by providing empty state value") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void updateTaskByProvidingEmptyStateValue() throws Exception - { - restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask(" "); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(String.format(RestErrorModel.TASK_INVALID_STATE, " ")) - .containsSummary(String.format(RestErrorModel.TASK_INVALID_STATE, " ")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/candidates/GetTaskCandidatesRegressionTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/candidates/GetTaskCandidatesRegressionTests.java deleted file mode 100644 index c3c9cc5fc..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/candidates/GetTaskCandidatesRegressionTests.java +++ /dev/null @@ -1,268 +0,0 @@ -package org.alfresco.service.search.rest.workflow.tasks.candidates; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestCandidateModelsCollection; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.GroupModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TaskModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * - * @author bogdan.bocancea - * - */ -public class GetTaskCandidatesRegressionTests extends RestTest -{ - private UserModel userModel, userModel1, userModel2; - private SiteModel siteModel; - private FileModel fileModel; - private TaskModel taskModel; - private GroupModel group; - private RestCandidateModelsCollection candidateModels; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - userModel1 = dataUser.createRandomTestUser(); - userModel2 = dataUser.createRandomTestUser(); - group = dataGroup.createRandomGroup(); - dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify get task candidates with invalid task id") - public void getTaskCandidatesWithInvalidTaskId() throws Exception - { - taskModel = dataWorkflow.usingUser(userModel) - .usingSite(siteModel) - .usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); - taskModel.setId("invalid-id"); - restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).getTaskCandidates(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalid-id")) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify get task candidates with empty task id") - public void getTaskCandidatesWithEmptyTaskId() throws Exception - { - taskModel = dataWorkflow.usingUser(userModel) - .usingSite(siteModel) - .usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); - taskModel.setId(""); - restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).getTaskCandidates(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify get task candidates for completed task") - public void getTaskCandidatesForCompletedTask() throws Exception - { - taskModel = dataWorkflow.usingUser(userModel) - .usingSite(siteModel) - .usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); - - restClient.authenticateUser(userModel1).withWorkflowAPI().usingTask(taskModel).getTaskCandidates(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - dataWorkflow.usingUser(userModel1).taskDone(taskModel); - - restClient.authenticateUser(userModel1).withWorkflowAPI().usingTask(taskModel).getTaskCandidates(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, taskModel.getId())); - - restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).getTaskCandidates(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, taskModel.getId())); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify get task candidates by non candidate user") - public void getTaskCandidatesByNonCandidateUser() throws Exception - { - UserModel outsider = dataUser.createRandomTestUser(); - taskModel = dataWorkflow.usingUser(userModel) - .usingSite(siteModel) - .usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); - restClient.authenticateUser(outsider).withWorkflowAPI().usingTask(taskModel).getTaskCandidates(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Bug(id="MNT-17438") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Get task candidates with skip count parameter") - public void getTaskCandidatesWithSkipCount() throws Exception - { - taskModel = dataWorkflow.usingUser(userModel) - .usingSite(siteModel) - .usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); - candidateModels = restClient.authenticateUser(userModel).withWorkflowAPI() - .usingParams("skipCount=1").usingTask(taskModel).getTaskCandidates(); - restClient.assertStatusCodeIs(HttpStatus.OK); - candidateModels.assertThat() - .entriesListIsNotEmpty() - .and().paginationField("count").is("0"); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Get task candidates with max items parameter set to 0") - public void getTaskCandidatesWithZeroMaxItems() throws Exception - { - taskModel = dataWorkflow.usingUser(userModel) - .usingSite(siteModel) - .usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); - candidateModels = restClient.authenticateUser(userModel).withWorkflowAPI() - .usingParams("maxItems=0").usingTask(taskModel).getTaskCandidates(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsErrorKey(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) - .containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Get task candidates with max items parameter") - public void getTaskCandidatesWithMaxItems() throws Exception - { - taskModel = dataWorkflow.usingUser(userModel) - .usingSite(siteModel) - .usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); - candidateModels = restClient.authenticateUser(userModel).withWorkflowAPI() - .usingParams("maxItems=2").usingTask(taskModel).getTaskCandidates(); - restClient.assertStatusCodeIs(HttpStatus.OK); - candidateModels.assertThat() - .entriesListIsNotEmpty() - .and().paginationField("count").is("1"); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Get task candidates with properties") - public void getTaskCandidatesWithProperties() throws Exception - { - taskModel = dataWorkflow.usingUser(userModel) - .usingSite(siteModel) - .usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); - candidateModels = restClient.authenticateUser(userModel).withWorkflowAPI() - .usingParams("properties=candidateId").usingTask(taskModel).getTaskCandidates(); - restClient.assertStatusCodeIs(HttpStatus.OK); - candidateModels.getEntries().get(0).onModel().assertThat() - .field("candidateId").contains(group.getGroupIdentifier()).and() - .field("candidateType").isNull(); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Get task candidates with invalid properties") - public void getTaskCandidatesWithInvalidProperties() throws Exception - { - taskModel = dataWorkflow.usingUser(userModel) - .usingSite(siteModel) - .usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); - candidateModels = restClient.authenticateUser(userModel).withWorkflowAPI() - .usingParams("properties=unknown-prop").usingTask(taskModel).getTaskCandidates(); - restClient.assertStatusCodeIs(HttpStatus.OK); - candidateModels.getEntries().get(0).onModel().assertThat() - .fieldsCount().is(0).and(); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Get task candidates by deleted candidate") - public void getTaskCandidatesByDeletedCandidate() throws Exception - { - UserModel newUser = dataUser.createRandomTestUser(); - dataGroup.addListOfUsersToGroup(group, newUser); - taskModel = dataWorkflow.usingUser(userModel) - .usingSite(siteModel) - .usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); - restClient.authenticateUser(newUser).withWorkflowAPI() - .usingTask(taskModel).getTaskCandidates(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - dataUser.usingAdmin().deleteUser(newUser); - - restClient.authenticateUser(newUser).withWorkflowAPI() - .usingTask(taskModel).getTaskCandidates(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError().containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Get task candidates by deleted group") - public void getTaskCandidatesByDeletedGroup() throws Exception - { - GroupModel deletedGroup = dataGroup.createRandomGroup(); - UserModel newUser = dataUser.createRandomTestUser(); - dataGroup.addListOfUsersToGroup(deletedGroup, userModel2, newUser); - taskModel = dataWorkflow.usingUser(userModel) - .usingSite(siteModel) - .usingResource(fileModel).createPooledReviewTaskAndAssignTo(deletedGroup); - restClient.authenticateUser(newUser).withWorkflowAPI() - .usingTask(taskModel).getTaskCandidates(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - dataGroup.usingAdmin().deleteGroup(deletedGroup); - - restClient.authenticateUser(newUser).withWorkflowAPI() - .usingTask(taskModel).getTaskCandidates(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Get task candidates by user that was removed from group") - public void getTaskCandidatesByUserRemovedFromGroup() throws Exception - { - UserModel newUser = dataUser.createRandomTestUser(); - dataGroup.addListOfUsersToGroup(group, newUser); - taskModel = dataWorkflow.usingUser(userModel) - .usingSite(siteModel) - .usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); - restClient.authenticateUser(newUser).withWorkflowAPI() - .usingTask(taskModel).getTaskCandidates(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - dataGroup.usingAdmin().removeUserFromGroup(group, newUser); - - restClient.authenticateUser(newUser).withWorkflowAPI() - .usingTask(taskModel).getTaskCandidates(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .stackTraceIs(RestErrorModel.STACKTRACE); - } -} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/candidates/GetTaskCandidatesSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/candidates/GetTaskCandidatesSanityTests.java deleted file mode 100644 index cbd17f10f..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/candidates/GetTaskCandidatesSanityTests.java +++ /dev/null @@ -1,79 +0,0 @@ -package org.alfresco.service.search.rest.workflow.tasks.candidates; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestCandidateModelsCollection; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.GroupModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TaskModel; -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 Cristina Axinte - * - */ - -public class GetTaskCandidatesSanityTests extends RestTest -{ - private UserModel userModel, user, userModel1, userModel2; - private SiteModel siteModel; - private FileModel fileModel; - private TaskModel taskModel; - private GroupModel group; - private RestCandidateModelsCollection candidateModels; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - user = dataUser.createRandomTestUser(); - userModel1 = dataUser.createRandomTestUser(); - userModel2 = dataUser.createRandomTestUser(); - group = dataGroup.createRandomGroup(); - dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); - taskModel = dataWorkflow.usingUser(user).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, - description = "Verify that admin gets task candidates") - public void getTaskCandidatesByAdmin() throws Exception - { - candidateModels = restClient.authenticateUser(dataUser.getAdminUser()).withWorkflowAPI().usingTask(taskModel).getTaskCandidates(); - restClient.assertStatusCodeIs(HttpStatus.OK); - candidateModels.assertThat().entriesListContains("candidateType", "group") - .and().entriesListContains("candidateId", String.format("GROUP_%s", group.getGroupIdentifier())); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, - description = "Verify that user that started the process gets task candidates") - public void getTaskCandidatesByUserWhoStartedProcess() throws Exception - { - candidateModels = restClient.authenticateUser(user).withWorkflowAPI().usingTask(taskModel).getTaskCandidates(); - restClient.assertStatusCodeIs(HttpStatus.OK); - candidateModels.assertThat().entriesListContains("candidateType", "group") - .and().entriesListContains("candidateId", String.format("GROUP_%s", group.getGroupIdentifier())); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, - description = "Verify that user from the assighed group to the process gets task candidates") - public void getTaskCandidatesByCandidateUser() throws Exception - { - candidateModels = restClient.authenticateUser(userModel1).withWorkflowAPI().usingTask(taskModel).getTaskCandidates(); - restClient.assertStatusCodeIs(HttpStatus.OK); - candidateModels.assertThat().entriesListContains("candidateType", "group") - .and().entriesListContains("candidateId", String.format("GROUP_%s", group.getGroupIdentifier())); - } -} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/AddTaskItemTestsBulk1.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/AddTaskItemTestsBulk1.java deleted file mode 100644 index 84856161f..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/AddTaskItemTestsBulk1.java +++ /dev/null @@ -1,158 +0,0 @@ -package org.alfresco.service.search.rest.workflow.tasks.items; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestItemModel; -import org.alfresco.rest.model.RestItemModelsCollection; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TaskModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - - -public class AddTaskItemTestsBulk1 extends RestTest -{ - private UserModel userModel, userWhoStartsTask, assigneeUser; - private SiteModel siteModel; - private FileModel fileModel, document2, document3; - private TaskModel taskModel; - private RestItemModelsCollection taskItems; - private RestItemModel taskItem; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - userWhoStartsTask = dataUser.createRandomTestUser(); - assigneeUser = dataUser.createRandomTestUser(); - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, - description = "Create non-existing task item") - public void createTaskItem() throws Exception - { - UserModel adminUser = dataUser.getAdminUser(); - restClient.authenticateUser(adminUser); - document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - - taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - taskItem.assertThat().field("createdAt").is(taskItem.getCreatedAt()) - .assertThat().field("size").is(taskItem.getSize()) - .assertThat().field("createdBy").is(taskItem.getCreatedBy()) - .assertThat().field("modifiedAt").is(taskItem.getModifiedAt()) - .assertThat().field("name").is(taskItem.getName()) - .assertThat().field("modifiedBy").is(taskItem.getModifiedBy()) - .assertThat().field("id").is(taskItem.getId()) - .assertThat().field("mimeType").is(taskItem.getMimeType()); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, - description = "Create multiple non-existing task item") - public void createMultipleTaskItem() throws Exception - { - UserModel adminUser = dataUser.getAdminUser(); - restClient.authenticateUser(adminUser); - document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - - taskItems = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItems(document2, fileModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - taskItems.getEntries().get(0).onModel() - .assertThat().field("createdAt").is(taskItems.getEntries().get(0).onModel().getCreatedAt()) - .assertThat().field("size").is(taskItems.getEntries().get(0).onModel().getSize()) - .assertThat().field("createdBy").is(taskItems.getEntries().get(0).onModel().getCreatedBy()) - .assertThat().field("modifiedAt").is(taskItems.getEntries().get(0).onModel().getModifiedAt()) - .assertThat().field("name").is(taskItems.getEntries().get(0).onModel().getName()) - .assertThat().field("modifiedBy").is(taskItems.getEntries().get(0).onModel().getModifiedBy()) - .assertThat().field("id").is(taskItems.getEntries().get(0).onModel().getId()) - .assertThat().field("mimeType").is(taskItems.getEntries().get(0).onModel().getMimeType()); - - taskItems.getEntries().get(1).onModel() - .assertThat().field("createdAt").is(taskItems.getEntries().get(1).onModel().getCreatedAt()) - .assertThat().field("size").is(taskItems.getEntries().get(1).onModel().getSize()) - .assertThat().field("createdBy").is(taskItems.getEntries().get(1).onModel().getCreatedBy()) - .assertThat().field("modifiedAt").is(taskItems.getEntries().get(1).onModel().getModifiedAt()) - .assertThat().field("name").is(taskItems.getEntries().get(1).onModel().getName()) - .assertThat().field("modifiedBy").is(taskItems.getEntries().get(1).onModel().getModifiedBy()) - .assertThat().field("id").is(taskItems.getEntries().get(1).onModel().getId()) - .assertThat().field("mimeType").is(taskItems.getEntries().get(1).onModel().getMimeType()); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @Bug(id = "MNT-16966") - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that in case task item exists the request fails") - public void createTaskItemThatAlreadyExists() throws Exception - { - UserModel adminUser = dataUser.getAdminUser(); - restClient.authenticateUser(adminUser); - document3 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - - taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document3); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - taskItem.assertThat().field("createdAt").is(taskItem.getCreatedAt()) - .assertThat().field("size").is(taskItem.getSize()) - .and().field("createdBy").is(taskItem.getCreatedBy()) - .and().field("modifiedAt").is(taskItem.getModifiedAt()) - .and().field("name").is(taskItem.getName()) - .and().field("modifiedBy").is(taskItem.getModifiedBy()) - .and().field("id").is(taskItem.getId()) - .and().field("mimeType").is(taskItem.getMimeType()); - - taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document3); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @Bug(id = "MNT-16966") - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that in case task item exists the request fails") - public void createMultipleTaskItemThatAlreadyExists() throws Exception - { - UserModel adminUser = dataUser.getAdminUser(); - restClient.authenticateUser(adminUser); - document3 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - - taskItems = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItems(document3, document2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - taskItems.getEntries().get(0).onModel() - .assertThat().field("createdAt").is(taskItems.getEntries().get(0).onModel().getCreatedAt()) - .assertThat().field("size").is(taskItems.getEntries().get(0).onModel().getSize()) - .assertThat().field("createdBy").is(taskItems.getEntries().get(0).onModel().getCreatedBy()) - .assertThat().field("modifiedAt").is(taskItems.getEntries().get(0).onModel().getModifiedAt()) - .assertThat().field("name").is(taskItems.getEntries().get(0).onModel().getName()) - .assertThat().field("modifiedBy").is(taskItems.getEntries().get(0).onModel().getModifiedBy()) - .assertThat().field("id").is(taskItems.getEntries().get(0).onModel().getId()) - .assertThat().field("mimeType").is(taskItems.getEntries().get(0).onModel().getMimeType()); - - taskItems.getEntries().get(1).onModel() - .assertThat().field("createdAt").is(taskItems.getEntries().get(1).onModel().getCreatedAt()) - .assertThat().field("size").is(taskItems.getEntries().get(1).onModel().getSize()) - .assertThat().field("createdBy").is(taskItems.getEntries().get(1).onModel().getCreatedBy()) - .assertThat().field("modifiedAt").is(taskItems.getEntries().get(1).onModel().getModifiedAt()) - .assertThat().field("name").is(taskItems.getEntries().get(1).onModel().getName()) - .assertThat().field("modifiedBy").is(taskItems.getEntries().get(1).onModel().getModifiedBy()) - .assertThat().field("id").is(taskItems.getEntries().get(1).onModel().getId()) - .assertThat().field("mimeType").is(taskItems.getEntries().get(1).onModel().getMimeType()); - - taskItems = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItems(document3, document2); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - } -} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/AddTaskItemTestsBulk2.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/AddTaskItemTestsBulk2.java deleted file mode 100644 index 54ccf0cdc..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/AddTaskItemTestsBulk2.java +++ /dev/null @@ -1,175 +0,0 @@ -package org.alfresco.service.search.rest.workflow.tasks.items; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.core.RestRequest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestVariableModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TaskModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class AddTaskItemTestsBulk2 extends RestTest -{ - private UserModel userModel, assigneeUser, anotherUser; - private SiteModel siteModel; - private FileModel fileModel, fileModel1; - private TaskModel taskModel; - private String taskId; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - fileModel1 = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - assigneeUser = dataUser.createRandomTestUser(); - taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - - taskId = taskModel.getId(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Add task item using random user.") - public void addTaskItemByRandomUser() throws Exception - { - anotherUser = dataUser.createRandomTestUser(); - restClient.authenticateUser(anotherUser).withWorkflowAPI().usingTask(taskModel).addTaskItem(fileModel); - - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError() - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Add multiple task item using random user.") - public void addMultipleTaskItemByRandomUser() throws Exception - { - anotherUser = dataUser.createRandomTestUser(); - restClient.authenticateUser(anotherUser).withWorkflowAPI().usingTask(taskModel) - .addTaskItems(fileModel,fileModel1); - - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE);; - } - - @Bug(id = "ACE-5683") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Adding task item, is falling in case invalid itemBody is provided") - public void failedAddingTaskItemIfInvalidItemBodyIsProvided() throws Exception - { - fileModel.setNodeRef("invalidNodeRef"); - restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).addTaskItem(fileModel); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidNodeRef")) - .containsErrorKey(RestErrorModel.NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Bug(id = "ACE-5683") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Adding multiple task item, is falling in case invalid itemBody is provided") - public void failedAddingMultipleTaskItemIfInvalidItemBodyIsProvided() throws Exception - { - fileModel.setNodeRef("invalidNodeRef"); - restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel) - .addTaskItems(fileModel, fileModel1); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidNodeRef")) - .containsErrorKey(RestErrorModel.NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE);; - } - - @Bug(id = "ACE-5675") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Adding task item is falling in case empty item body is provided") - public void failedAddingTaskItemIfEmptyItemBodyIsProvided() throws Exception - { - fileModel.setNodeRef(""); - restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).addTaskItem(fileModel); - - // TODO - expected error message to be added - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(""); - } - - @Bug(id = "ACE-5675") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Adding multiple task item is falling in case empty item body is provided") - public void failedAddingMultipleTaskItemIfEmptyItemBodyIsProvided() throws Exception - { - fileModel.setNodeRef(""); - restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).addTaskItems(fileModel, fileModel1); - - // TODO - expected error message to be added - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(""); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Adding task item is falling in case invalid task id is provided") - public void failedAddingTaskItemIfInvalidTaskIdIsProvided() throws Exception - { - taskModel.setId("invalidTaskId"); - restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).addTaskItem(fileModel); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidTaskId")) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE);; - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Adding task item is falling in case invalid task id is provided") - public void failedAddingMultipleTaskItemIfInvalidTaskIdIsProvided() throws Exception - { - taskModel.setId("invalidTaskId"); - restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).addTaskItems(fileModel,fileModel1); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidTaskId")) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Bug(id = "ACE-5675") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Adding task item is falling in case incomplete body type is provided") - public void failedAddingTaskVariableIfIncompleteBodyIsProvided() throws Exception - { - RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{}", "tasks/{taskId}/items", taskId); - restClient.processModel(RestVariableModel.class, request); - - // TODO - expected error message to be added - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(""); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/AddTaskItemTestsBulk3.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/AddTaskItemTestsBulk3.java deleted file mode 100644 index 10bb83f4c..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/AddTaskItemTestsBulk3.java +++ /dev/null @@ -1,128 +0,0 @@ -package org.alfresco.service.search.rest.workflow.tasks.items; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestItemModel; -import org.alfresco.rest.model.RestItemModelsCollection; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TaskModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class AddTaskItemTestsBulk3 extends RestTest -{ - private UserModel userModel,userWhoStartsTask, assigneeUser; - private SiteModel siteModel; - private FileModel fileModel, fileModel1, document1, document2,document3; - private TaskModel taskModel; - private RestItemModelsCollection taskItems; - private RestItemModel taskItem; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - userWhoStartsTask = dataUser.createRandomTestUser(); - assigneeUser = dataUser.createRandomTestUser(); - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Add task item using random user.") - public void addTaskItemByTheUserThatStartedTheProcess() throws Exception - { - taskItem = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingTask(taskModel).addTaskItem(fileModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - taskItem.assertThat().field("createdAt").is(taskItem.getCreatedAt()) - .and().field("size").is(taskItem.getSize()) - .and().field("createdBy").is(taskItem.getCreatedBy()) - .and().field("modifiedAt").is(taskItem.getModifiedAt()) - .and().field("name").is(taskItem.getName()) - .and().field("modifiedBy").is(taskItem.getModifiedBy()) - .and().field("id").is(taskItem.getId()) - .and().field("mimeType").is(taskItem.getMimeType()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Add multiple task item using random user.") - public void addMultipleTaskItemByTheUserThatStartedTheProcess() throws Exception - { - fileModel1 = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - taskItems = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingTask(taskModel) - .addTaskItems(fileModel, fileModel1); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - taskItems.getEntries().get(0).onModel() - .assertThat().field("createdAt").is(taskItems.getEntries().get(0).onModel().getCreatedAt()) - .and().field("size").is(taskItems.getEntries().get(0).onModel().getSize()) - .and().field("createdBy").is(taskItems.getEntries().get(0).onModel().getCreatedBy()) - .and().field("modifiedAt").is(taskItems.getEntries().get(0).onModel().getModifiedAt()) - .and().field("name").is(taskItems.getEntries().get(0).onModel().getName()) - .and().field("modifiedBy").is(taskItems.getEntries().get(0).onModel().getModifiedBy()) - .and().field("id").is(taskItems.getEntries().get(0).onModel().getId()) - .and().field("mimeType").is(taskItems.getEntries().get(0).onModel().getMimeType()); - - taskItems.getEntries().get(1).onModel() - .assertThat().field("createdAt").is(taskItems.getEntries().get(1).onModel().getCreatedAt()) - .assertThat().field("size").is(taskItems.getEntries().get(1).onModel().getSize()) - .assertThat().field("createdBy").is(taskItems.getEntries().get(1).onModel().getCreatedBy()) - .assertThat().field("modifiedAt").is(taskItems.getEntries().get(1).onModel().getModifiedAt()) - .assertThat().field("name").is(taskItems.getEntries().get(1).onModel().getName()) - .assertThat().field("modifiedBy").is(taskItems.getEntries().get(1).onModel().getModifiedBy()) - .assertThat().field("id").is(taskItems.getEntries().get(1).onModel().getId()) - .assertThat().field("mimeType").is(taskItems.getEntries().get(1).onModel().getMimeType()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Delete task item then create it again") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION}) - public void deleteTaskItemThenCreateItAgain() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel) - .createNewTaskAndAssignTo(assigneeUser); - restClient.authenticateUser(userWhoStartsTask); - document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Delete multiple task item then create it again") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION}) - public void deleteMultipleTaskItemsThenCreateThemAgain() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel) - .createNewTaskAndAssignTo(assigneeUser); - restClient.authenticateUser(userWhoStartsTask); - document1 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - document3 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - taskItems = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItems(document2, document1, document3); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItems.getEntries().get(0).onModel()); - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItems.getEntries().get(1).onModel()); - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItems.getEntries().get(2).onModel()); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - restClient.withWorkflowAPI().usingTask(taskModel).addTaskItems(document2, document1, document3); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/GetTaskItemsRegressionTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/GetTaskItemsRegressionTests.java deleted file mode 100644 index d1e3bd9ab..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/GetTaskItemsRegressionTests.java +++ /dev/null @@ -1,260 +0,0 @@ -package org.alfresco.service.search.rest.workflow.tasks.items; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.dataprep.CMISUtil.Priority; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestItemModel; -import org.alfresco.rest.model.RestItemModelsCollection; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.model.RestTaskModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TaskModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Created by Claudia Agache on 12/8/2016. - */ -public class GetTaskItemsRegressionTests extends RestTest -{ - private UserModel userWhoStartsTask, assignee; - private SiteModel siteModel; - private FileModel fileModel; - private TaskModel taskModel; - private RestItemModelsCollection itemModels; - private RestProcessModel addedProcess; - private RestTaskModel addedTask; - private RestItemModel taskItem; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - userWhoStartsTask = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify if get task items call return status code 404 when invalid taskId is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void getTaskItemsUsingInvalidTaskId() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); - taskModel.setId("invalidId"); - - restClient.authenticateUser(assignee).withWorkflowAPI() - .usingTask(taskModel).getTaskItems(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidId")); - - taskModel.setId(""); - - restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() - .usingTask(taskModel).getTaskItems(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, - executionType = ExecutionType.REGRESSION, - description = "Verify if get task items request returns status code 200 after the task is finished.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void getTaskItemsAfterFinishingTask() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); - dataWorkflow.usingUser(assignee).taskDone(taskModel); - restClient.authenticateUser(userWhoStartsTask); - itemModels = restClient.withWorkflowAPI().usingTask(taskModel).getTaskItems(); - restClient.assertStatusCodeIs(HttpStatus.OK); - itemModels.assertThat().entriesListIsNotEmpty().and().entriesListContains("name", fileModel.getName()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, - executionType = ExecutionType.REGRESSION, - description = "Verify if get task items request returns status code 200 after the process is deleted (Task state is now completed.)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void getTaskItemsAfterDeletingProcess() throws Exception - { - addedProcess = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); - addedTask = restClient.withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess); - restClient.withWorkflowAPI().usingTask(addedTask).addTaskItem(fileModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.withWorkflowAPI().usingProcess(addedProcess).deleteProcess(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - itemModels = restClient.withWorkflowAPI().usingTask(addedTask).getTaskItems(); - restClient.assertStatusCodeIs(HttpStatus.OK); - itemModels.assertThat().entriesListIsNotEmpty().and().entriesListContains("name", fileModel.getName()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Check default error model schema for get task items api call") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void getTaskItemsUsingCheckErrorModel() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); - taskModel.setId("invalidId"); - restClient.authenticateUser(assignee).withWorkflowAPI() - .usingTask(taskModel).getTaskItems(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidId")) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin user can get task items") - public void getTaskItemsByAdminUser() throws Exception - { - restClient.authenticateUser(userWhoStartsTask); - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); - taskItem = restClient.withWorkflowAPI().usingTask(taskModel).getTaskItems().getOneRandomEntry(); - - itemModels = restClient.authenticateUser(dataUser.getAdminUser()).withWorkflowAPI().usingTask(taskModel).getTaskItems(); - restClient.assertStatusCodeIs(HttpStatus.OK); - itemModels.assertThat() - .entriesListIsNotEmpty().and() - .entriesListContains("id", taskItem.onModel().getId()).and() - .entriesListContains("name", taskItem.onModel().getName()) - .getEntries().get(0).onModel() - .assertThat().field("createdAt").isNotNull() - .assertThat().field("size").isNotNull() - .assertThat().field("createdBy").contains(dataUser.getAdminUser().getUsername()) - .assertThat().field("modifiedAt").isNotNull() - .assertThat().field("name").contains(fileModel.getName()) - .assertThat().field("modifiedBy").contains(userWhoStartsTask.getUsername()) - .assertThat().field("id").contains(fileModel.getNodeRef().split(";")[0]) - .assertThat().field("mimeType").contains(fileModel.getFileType().mimeType); - } - - @Bug(id="MNT-17438") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that user who started the process can get task items with skip count parameter") - public void getTaskItemsWithSkipCount() throws Exception - { - restClient.authenticateUser(userWhoStartsTask); - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); - FileModel document1 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document1); - itemModels = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() - .usingParams("skipCount=1").usingTask(taskModel).getTaskItems(); - restClient.assertStatusCodeIs(HttpStatus.OK); - itemModels.assertThat() - .entriesListIsNotEmpty() - .and().paginationField("count").is("1"); - } - - @Bug(id="MNT-17438") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that user who started the process can get task items with max items parameter") - public void getTaskItemsWithMaxItems() throws Exception - { - restClient.authenticateUser(userWhoStartsTask); - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); - FileModel document1 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document1); - itemModels = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() - .usingParams("maxItems=1").usingTask(taskModel).getTaskItems(); - restClient.assertStatusCodeIs(HttpStatus.OK); - itemModels.assertThat() - .entriesListIsNotEmpty() - .and().paginationField("count").is("1"); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that user who started the process can get task items with valid properties") - public void getTaskItemsWithValidProperties() throws Exception - { - restClient.authenticateUser(userWhoStartsTask); - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); - taskItem = restClient.withWorkflowAPI().usingTask(taskModel).getTaskItems().getOneRandomEntry(); - itemModels = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() - .usingParams("properties=createdAt,createdBy,id,size").usingTask(taskModel).getTaskItems(); - restClient.assertStatusCodeIs(HttpStatus.OK); - itemModels.getOneRandomEntry().onModel().assertThat() - .fieldsCount().is(4).and() - .field("createdAt").isNotNull().and() - .field("size").isNotNull().and() - .field("createdBy").isNotNull().and() - .field("modifiedAt").isNull().and() - .field("name").isNull().and() - .field("modifiedBy").isNull().and() - .field("id").isNotNull().and() - .field("mimeType").isNull(); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that user who started the process can get task items with an invalid property") - public void getTaskItemsWithInvalidProperties() throws Exception - { - restClient.authenticateUser(userWhoStartsTask); - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); - taskItem = restClient.withWorkflowAPI().usingTask(taskModel).getTaskItems().getOneRandomEntry(); - itemModels = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() - .usingParams("properties=size,fake-prop").usingTask(taskModel).getTaskItems(); - restClient.assertStatusCodeIs(HttpStatus.OK); - itemModels.getOneRandomEntry().onModel().assertThat() - .fieldsCount().is(1).and() - .field("createdAt").isNull().and() - .field("size").isNotNull().and() - .field("createdBy").isNull().and() - .field("modifiedAt").isNull().and() - .field("name").isNull().and() - .field("modifiedBy").isNull().and() - .field("id").isNull().and() - .field("mimeType").isNull(); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that involved user in process that was deleted cannot get task items") - public void getTaskItemsByDeletedUserInvolvedInProcess() throws Exception - { - UserModel assigneeDeleted = dataUser.createRandomTestUser(); - restClient.authenticateUser(userWhoStartsTask); - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeDeleted); - - dataUser.usingAdmin().deleteUser(assigneeDeleted); - - itemModels = restClient.authenticateUser(assigneeDeleted).withWorkflowAPI().usingTask(taskModel).getTaskItems(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError().containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that involved user in process that was disabled cannot get task items") - public void getTaskItemsByDisabledUserInvolvedInProcess() throws Exception - { - UserModel assigneeDisabled = dataUser.createRandomTestUser(); - restClient.authenticateUser(userWhoStartsTask); - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeDisabled); - - dataUser.usingAdmin().disableUser(assigneeDisabled); - - itemModels = restClient.authenticateUser(assigneeDisabled).withWorkflowAPI().usingTask(taskModel).getTaskItems(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError().containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/GetTaskItemsSanityTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/GetTaskItemsSanityTests.java deleted file mode 100644 index 42421e2dd..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/GetTaskItemsSanityTests.java +++ /dev/null @@ -1,75 +0,0 @@ -package org.alfresco.service.search.rest.workflow.tasks.items; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestItemModel; -import org.alfresco.rest.model.RestItemModelsCollection; -import org.alfresco.utility.Utility; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TaskModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - - -public class GetTaskItemsSanityTests extends RestTest -{ - private UserModel userModel, userWhoStartsTask, assignee; - private SiteModel siteModel; - private FileModel fileModel, document1; - private TaskModel taskModel; - private RestItemModel taskItem; - private RestItemModelsCollection itemModels; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - userWhoStartsTask = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, - description = "Verify that user that started the process gets task items") - public void getTaskItemsByUserWhoStartedProcess() throws Exception - { - restClient.authenticateUser(userWhoStartsTask); - document1 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document1); - Utility.checkObjectIsInitialized(taskItem, "taskItem"); - - itemModels = restClient.withWorkflowAPI().usingTask(taskModel).getTaskItems(); - restClient.assertStatusCodeIs(HttpStatus.OK); - itemModels.assertThat() - .entriesListIsNotEmpty().and() - .entriesListContains("id", taskItem.getId()).and() - .entriesListContains("name", document1.getName()); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, - description = "Verify that involved user in process gets task items") - public void getTaskItemsByUserInvolvedInProcess() throws Exception - { - restClient.authenticateUser(assignee); - document1 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document1); - - itemModels = restClient.withWorkflowAPI().usingTask(taskModel).getTaskItems(); - restClient.assertStatusCodeIs(HttpStatus.OK); - itemModels.assertThat() - .entriesListIsNotEmpty().and() - .entriesListContains("id", taskItem.getId()).and() - .entriesListContains("name", document1.getName()); - - } -} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/RemoveTaskItemTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/RemoveTaskItemTests.java deleted file mode 100644 index 6aa66a19f..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/items/RemoveTaskItemTests.java +++ /dev/null @@ -1,256 +0,0 @@ -package org.alfresco.service.search.rest.workflow.tasks.items; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestItemModel; -import org.alfresco.utility.model.*; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * @author bogdan.bocancea - */ -public class RemoveTaskItemTests extends RestTest -{ - private UserModel adminUser, userWhoStartsTask, assigneeUser; - private SiteModel siteModel; - private FileModel fileModel, document2; - private TaskModel taskModel; - private RestItemModel taskItem; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userWhoStartsTask = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - assigneeUser = dataUser.createRandomTestUser(); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, - description = "Delete existing task item") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - public void deleteTaskItem() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - restClient.authenticateUser(adminUser); - document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - - taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withWorkflowAPI().usingTask(taskModel).getTaskItems() - .assertThat().entriesListDoesNotContain("id", taskItem.getId()).and() - .entriesListDoesNotContain("name", document2.getName()); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Try to Delete existing task item using invalid taskId") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void deleteTaskItemUsingInvalidTaskId() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - restClient.authenticateUser(adminUser); - document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - - taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); - taskModel.setId("invalidTaskId"); - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidTaskId")); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Try to Delete existing task item using invalid itemId") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void deleteTaskItemUsingInvalidItemId() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - restClient.authenticateUser(adminUser); - document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); - taskItem.setId("incorrectItemId"); - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.PROCESS_ENTITY_NOT_FOUND, "incorrectItemId")); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Delete existing task item with empty task id") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void deleteTaskItemEmptyTaskId() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - restClient.authenticateUser(userWhoStartsTask); - document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); - taskModel.setId(""); - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Delete existing task item with empty item id") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void deleteTaskItemEmptyItemId() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - restClient.authenticateUser(userWhoStartsTask); - document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); - taskItem.setId(""); - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) - .assertLastError().containsSummary(RestErrorModel.DELETE_EMPTY_ARGUMENT); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Delete existing task item for completed task") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void deleteTaskItemForCompletedTask() throws Exception - { - TaskModel completedTask = dataWorkflow.usingUser(userWhoStartsTask) - .usingSite(siteModel) - .usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - restClient.authenticateUser(userWhoStartsTask); - document2 = dataContent.usingUser(userWhoStartsTask).usingSite(siteModel).createContent(DocumentType.XML); - taskItem = restClient.withWorkflowAPI().usingTask(completedTask).addTaskItem(document2); - dataWorkflow.usingUser(assigneeUser).taskDone(completedTask); - dataWorkflow.usingUser(userWhoStartsTask).taskDone(completedTask); - restClient.withWorkflowAPI().usingTask(completedTask).deleteTaskItem(taskItem); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, completedTask.getId())); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, - description = "Delete existing task item with candidate user") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - public void deleteTaskItemWithCandidateUser() throws Exception - { - GroupModel group = dataGroup.createRandomGroup(); - dataGroup.addListOfUsersToGroup(group, assigneeUser); - TaskModel groupTask = dataWorkflow.usingUser(userWhoStartsTask) - .usingSite(siteModel) - .usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); - - restClient.authenticateUser(userWhoStartsTask); - document2 = dataContent.usingUser(userWhoStartsTask).usingSite(siteModel).createContent(DocumentType.XML); - taskItem = restClient.withWorkflowAPI().usingTask(groupTask).addTaskItem(document2); - restClient.authenticateUser(assigneeUser) - .withWorkflowAPI().usingTask(groupTask).deleteTaskItem(taskItem); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Delete existing task item with unauthorized user") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void deleteTaskItemWithUnauthorizedUser() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - UserModel unauthorizedUser = dataUser.createRandomTestUser(); - document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - taskItem = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); - restClient.authenticateUser(unauthorizedUser).withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, - description = "Delete existing task item with inexistent user") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) -// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void deleteTaskItemWithInexistentUser() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - taskItem = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); - restClient.authenticateUser(UserModel.getRandomUserModel()).withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Delete existing task item for deleted task") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void deleteTaskItemFromDeletedProcess() throws Exception - { - ProcessModel deletedProcess = dataWorkflow.usingUser(userWhoStartsTask) - .usingSite(siteModel) - .usingResource(fileModel).createMoreReviewersWorkflowAndAssignTo(assigneeUser); - TaskModel task = restClient.authenticateUser(userWhoStartsTask) - .withWorkflowAPI().usingProcess(deletedProcess).getProcessTasks().getEntries().get(0).onModel(); - - document2 = dataContent.usingUser(userWhoStartsTask).usingSite(siteModel).createContent(DocumentType.XML); - taskItem = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingTask(task).addTaskItem(document2); - dataWorkflow.usingUser(userWhoStartsTask).deleteProcess(deletedProcess); - restClient.withWorkflowAPI().usingTask(task).deleteTaskItem(taskItem); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, task.getId())); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Delete task item twice") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void deleteTaskItemTwice() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - restClient.authenticateUser(userWhoStartsTask); - document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); - - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.PROCESS_ENTITY_NOT_FOUND, document2.getNodeRefWithoutVersion())) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Delete task item with locked document") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void deleteTaskItemWithLockedDocument() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - restClient.authenticateUser(userWhoStartsTask); - document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); - - dataContent.usingUser(userWhoStartsTask).usingResource(document2).checkOutDocument(); - - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); - restClient.assertStatusCodeIs(HttpStatus.CONFLICT) - .assertLastError().containsSummary(String.format(RestErrorModel.LOCKED_NODE_OPERATION, document2.getNodeRefWithoutVersion())) - .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Delete task item with deleted document") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void deleteTaskItemWithDeletedDocument() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - restClient.authenticateUser(userWhoStartsTask); - document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); - - dataContent.usingUser(userWhoStartsTask).usingResource(document2).deleteContent(); - - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.PROCESS_ENTITY_NOT_FOUND, document2.getNodeRefWithoutVersion())) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } -} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk1.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk1.java deleted file mode 100644 index 370df5668..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk1.java +++ /dev/null @@ -1,198 +0,0 @@ -package org.alfresco.service.search.rest.workflow.tasks.variables; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestVariableModel; -import org.alfresco.rest.model.RestVariableModelsCollection; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TaskModel; -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 AddTaskVariablesTestsBulk1 extends RestTest -{ - private UserModel userModel, userWhoStartsTask; - private SiteModel siteModel; - private FileModel fileModel; - private UserModel assigneeUser; - private TaskModel taskModel; - private RestVariableModel restVariablemodel; - private RestVariableModelsCollection restVariableCollection; - private RestVariableModel variableModel, variableModel1; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - userWhoStartsTask = dataUser.createRandomTestUser(); - assigneeUser = dataUser.createRandomTestUser(); - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, - description = "Create non-existing task variable with admin") - public void createTaskVariableWithAdmin() throws Exception - { - UserModel adminUser = dataUser.getAdminUser(); - restClient.authenticateUser(adminUser); - RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - - restVariablemodel = restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restVariablemodel.assertThat() - .field("scope").is(variableModel.getScope()) - .and().field("name").is(variableModel.getName()) - .and().field("value").is(variableModel.getValue()) - .and().field("type").is(variableModel.getType()); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Create non-existing task variable with admin") - public void createMultipleTaskVariablesWithAdmin() throws Exception - { - UserModel adminUser = dataUser.getAdminUser(); - restClient.authenticateUser(adminUser); - variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - variableModel1 = RestVariableModel.getRandomTaskVariableModel("global", "d:text"); - - restVariableCollection = restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariables(variableModel,variableModel1); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restVariableCollection.getEntries().get(0).onModel().assertThat() - .field("scope").is(variableModel.getScope()) - .and().field("name").is(variableModel.getName()) - .and().field("value").is(variableModel.getValue()) - .and().field("type").is(variableModel.getType()); - - restVariableCollection.getEntries().get(1).onModel().assertThat() - .field("scope").is(variableModel1.getScope()) - .and().field("name").is(variableModel1.getName()) - .and().field("value").is(variableModel1.getValue()) - .and().field("type").is(variableModel1.getType()); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, - description = "Create non-existing task variable with user involved in the process") - public void createTaskVariableWithInvolvedUser() throws Exception - { - restClient.authenticateUser(assigneeUser); - RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - - restVariablemodel = restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restVariablemodel.assertThat().field("scope").is(variableModel.getScope()) - .and().field("name").is(variableModel.getName()) - .and().field("value").is(variableModel.getValue()) - .and().field("type").is(variableModel.getType()); - - restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables().assertThat().entriesListContains("name", variableModel.getName()); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Create multiple non-existing task variable with involved user") - public void createMultipleTaskVariableWithInvolvedUser() throws Exception - { - restClient.authenticateUser(assigneeUser); - variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - variableModel1 = RestVariableModel.getRandomTaskVariableModel("global", "d:text"); - - restVariableCollection = restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariables(variableModel,variableModel1); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restVariableCollection.getEntries().get(0).onModel().assertThat() - .field("scope").is(variableModel.getScope()) - .and().field("name").is(variableModel.getName()) - .and().field("value").is(variableModel.getValue()) - .and().field("type").is(variableModel.getType()); - - restVariableCollection.getEntries().get(1).onModel().assertThat() - .field("scope").is(variableModel1.getScope()) - .and().field("name").is(variableModel1.getName()) - .and().field("value").is(variableModel1.getValue()) - .and().field("type").is(variableModel1.getType()); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, - description = "Create non-existing task variable with task owner") - public void createTaskVariableWithTaskOwner() throws Exception - { - restClient.authenticateUser(userWhoStartsTask); - RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - - restVariablemodel = restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restVariablemodel.assertThat().field("scope").is(variableModel.getScope()) - .and().field("name").is(variableModel.getName()) - .and().field("value").is(variableModel.getValue()) - .and().field("type").is(variableModel.getType()); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Create multiple non-existing task variable with task owner") - public void createMultipleTaskVariableWithTaskOwner() throws Exception - { - restClient.authenticateUser(userWhoStartsTask); - variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - variableModel1 = RestVariableModel.getRandomTaskVariableModel("global", "d:text"); - - restVariableCollection = restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariables(variableModel,variableModel1); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restVariableCollection.getEntries().get(0).onModel().assertThat() - .field("scope").is(variableModel.getScope()) - .and().field("name").is(variableModel.getName()) - .and().field("value").is(variableModel.getValue()) - .and().field("type").is(variableModel.getType()); - - restVariableCollection.getEntries().get(1).onModel().assertThat() - .field("scope").is(variableModel1.getScope()) - .and().field("name").is(variableModel1.getName()) - .and().field("value").is(variableModel1.getValue()) - .and().field("type").is(variableModel1.getType()); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Create non-existing task variable with any user") - public void createTaskVariableWithRandomUser() throws Exception - { - userModel = dataUser.createRandomTestUser(); - restClient.authenticateUser(userModel); - RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - - restVariablemodel = restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Create multiple non-existing task variable with any user") - public void createMultipleTaskVariableWithRandomUser() throws Exception - { - restClient.authenticateUser(userModel); - variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - variableModel1 = RestVariableModel.getRandomTaskVariableModel("global", "d:text"); - - restVariableCollection = restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariables(variableModel,variableModel1); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); - } - -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk2.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk2.java deleted file mode 100644 index bee35a55b..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk2.java +++ /dev/null @@ -1,241 +0,0 @@ -package org.alfresco.service.search.rest.workflow.tasks.variables; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.core.RestRequest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestVariableModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TaskModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - - -public class AddTaskVariablesTestsBulk2 extends RestTest -{ - private UserModel userWhoStartsTask, adminUser; - private SiteModel siteModel; - private FileModel fileModel; - private UserModel assigneeUser; - private TaskModel taskModel; - private RestVariableModel invalidVariableModel, variableModel, variableModel1; - - private String taskId; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userWhoStartsTask = dataUser.createRandomTestUser(); - assigneeUser = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - - taskId = taskModel.getId(); - restClient.authenticateUser(adminUser); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case invalid variableBody is provided") - public void failedAddingTaskVariableIfInvalidBodyIsProvided() throws Exception - { - invalidVariableModel = RestVariableModel.getRandomTaskVariableModel("instance", "d:char"); - restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(invalidVariableModel); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Illegal value for variable scope: 'instance'."); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Adding multiple task variable is falling in case invalid variableBody is provided") - public void failedAddingMultipleTaskVariableIfInvalidBodyIsProvided() throws Exception - { - variableModel = RestVariableModel.getRandomTaskVariableModel("instance", "d:char"); - variableModel1 = RestVariableModel.getRandomTaskVariableModel("global", "d:text"); - restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariables(variableModel, variableModel1); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Illegal value for variable scope: 'instance'."); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case empty body type is provided") - public void failedAddingTaskVariableIfEmptyBodyIsProvided() throws Exception - { - RestVariableModel invalidVariableModel = RestVariableModel.getRandomTaskVariableModel("", ""); - restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(invalidVariableModel); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary("Variable scope is required and can only be 'local' or 'global'."); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Adding multiple task variable is falling in case empty body type is provided") - public void failedAddingMultipleTaskVariableIfEmptyBodyIsProvided() throws Exception - { - RestVariableModel invalidVariableModel = RestVariableModel.getRandomTaskVariableModel("", ""); - variableModel1 = RestVariableModel.getRandomTaskVariableModel("global", "d:text"); - restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariables(invalidVariableModel, variableModel1); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary("Variable scope is required and can only be 'local' or 'global'."); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case incomplete body type is provided") - public void failedAddingTaskVariableIfIncompleteBodyIsProvided() throws Exception - { - RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{\"name\": \"missingVariableScope\",\"value\": \"test\",\"type\": \"d:text\"}", - "tasks/{taskId}/variables", taskId); - restClient.processModel(RestVariableModel.class, request); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary("Variable scope is required and can only be 'local' or 'global'."); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case incomplete body - missing required: name type is provided") - public void failedAddingTaskVariableIfIncompleteRequiredBodyIsProvided() throws Exception - { - RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{\"scope\": \"local\",\"value\": \"missingVariableName\",\"type\": \"d:text\"}", - "tasks/{taskId}/variables", taskId); - restClient.processModel(RestVariableModel.class, request); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Variable name is required."); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case invalid type is provided") - public void failedAddingTaskVariableIfInvalidTypeIsProvided() throws Exception - { - RestVariableModel invalidVariableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:char"); - taskModel.setId(taskId); - - restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(invalidVariableModel); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Unsupported type of variable: 'd:char'."); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Adding multiple task variable is falling in case invalid type is provided") - public void failedAddingMultipleTaskVariableIfInvalidTypeIsProvided() throws Exception - { - RestVariableModel invalidVariableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:char"); - taskModel.setId(taskId); - variableModel1 = RestVariableModel.getRandomTaskVariableModel("global", "d:text"); - - restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariables(invalidVariableModel, variableModel1); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Unsupported type of variable: 'd:char'."); - } - - @Bug(id = "ACE-5674") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case invalid type prefix is provided") - public void failedAddingTaskVariableIfInvalidTypePrefixIsProvided() throws Exception - { - RestVariableModel invalidVariableModel = RestVariableModel.getRandomTaskVariableModel("local", "ddm:text"); - taskModel.setId(taskId); - - restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(invalidVariableModel); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Namespace prefix ddm is not mapped to a namespace URI"); - } - - @Bug(id = "ACE-5674") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Adding multiple task variable is falling in case invalid type prefix is provided") - public void failedAddingMultipleTaskVariableIfInvalidTypePrefixIsProvided() throws Exception - { - RestVariableModel invalidVariableModel = RestVariableModel.getRandomTaskVariableModel("local", "ddm:text"); - taskModel.setId(taskId); - variableModel1 = RestVariableModel.getRandomTaskVariableModel("global", "d:text"); - variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - - restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariables(invalidVariableModel,variableModel1, variableModel); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Namespace prefix ddm is not mapped to a namespace URI"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case invalid scope is provided") - public void failedAddingTaskVariableIfInvalidScopeIsProvided() throws Exception - { - RestVariableModel invalidVariableModel = RestVariableModel.getRandomTaskVariableModel("instance", "d:text"); - taskModel.setId(taskId); - - restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(invalidVariableModel); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Illegal value for variable scope: 'instance'."); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Adding multiple task variable is falling in case invalid scope is provided") - public void failedAddingMultipleTaskVariableIfInvalidScopeIsProvided() throws Exception - { - RestVariableModel invalidVariableModel = RestVariableModel.getRandomTaskVariableModel("instance", "d:text"); - taskModel.setId(taskId); - variableModel1 = RestVariableModel.getRandomTaskVariableModel("global", "d:text"); - variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - - restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariables(invalidVariableModel, variableModel, variableModel1); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Illegal value for variable scope: 'instance'."); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case invalid task id is provided") - public void failedAddingTaskVariableIfInvalidTaskIdIsProvided() throws Exception - { - RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - taskModel.setId(taskModel.getId() + "TEST"); - restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, taskModel.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Adding multiple task variable is falling in case invalid task id is provided") - public void failedAddingMultipleTaskVariableIfInvalidTaskIdIsProvided() throws Exception - { - variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - taskModel.setId(taskModel.getId() + "TEST"); - variableModel1 = RestVariableModel.getRandomTaskVariableModel("global", "d:text"); - restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariables(variableModel, variableModel1); - - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, taskModel.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case invalid task id is provided") - public void failedAddingTaskVariableIfInvalidValueIsProvided() throws Exception - { - RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:int"); - variableModel.setValue("invalidValue"); - - restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("For input string: \"invalidValue\""); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Adding multiple task variable is falling in case invalid task id is provided") - public void failedAddingMultipleTaskVariableIfInvalidValueIsProvided() throws Exception - { - variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:int"); - variableModel.setValue("invalidValue"); - variableModel1 = RestVariableModel.getRandomTaskVariableModel("global", "d:text"); - - restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariables(variableModel, variableModel1); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("For input string: \"invalidValue\""); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk3.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk3.java deleted file mode 100644 index c819511b9..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk3.java +++ /dev/null @@ -1,155 +0,0 @@ -package org.alfresco.service.search.rest.workflow.tasks.variables; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.core.RestRequest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestVariableModel; -import org.alfresco.rest.model.RestVariableModelsCollection; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TaskModel; -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 AddTaskVariablesTestsBulk3 extends RestTest -{ - private UserModel userWhoStartsTask, adminUser; - private SiteModel siteModel; - private FileModel fileModel; - private UserModel assigneeUser; - private TaskModel taskModel; - private RestVariableModel restVariablemodel, variableModel, variableModel1; - private RestVariableModelsCollection restVariableCollection; - private String taskId; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userWhoStartsTask = dataUser.createRandomTestUser(); - assigneeUser = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - - taskId = taskModel.getId(); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Create task variable with name containing symbols") - public void createTaskVariableWithSymbolsInName() throws Exception - { - UserModel adminUser = dataUser.getAdminUser(); - restClient.authenticateUser(adminUser); - RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - variableModel.setName("!@#$%^&*({}<>.,;'=_|"); - restVariablemodel = restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restVariablemodel.assertThat() - .field("scope").is(variableModel.getScope()) - .and().field("name").is(variableModel.getName()) - .and().field("value").is(variableModel.getValue()) - .and().field("type").is(variableModel.getType()); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Create multiple task variable with name containing symbols") - public void createMultipleTaskVariableWithSymbolsInName() throws Exception - { - UserModel adminUser = dataUser.getAdminUser(); - restClient.authenticateUser(adminUser); - variableModel1 = RestVariableModel.getRandomTaskVariableModel("global", "d:text"); - variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - variableModel.setName("!@#$%^&*({}<>.,;'=_|"); - - restVariableCollection = restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariables(variableModel,variableModel1); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restVariableCollection.getEntries().get(0).onModel().assertThat() - .field("scope").is(variableModel.getScope()) - .and().field("name").is(variableModel.getName()) - .and().field("value").is(variableModel.getValue()) - .and().field("type").is(variableModel.getType()); - - restVariableCollection.getEntries().get(1).onModel().assertThat() - .field("scope").is(variableModel1.getScope()) - .and().field("name").is(variableModel1.getName()) - .and().field("value").is(variableModel1.getValue()) - .and().field("type").is(variableModel1.getType()); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Create task variable with empty name") - public void createTaskVariableWithEmptyName() throws Exception - { - UserModel adminUser = dataUser.getAdminUser(); - restClient.authenticateUser(adminUser); - RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - variableModel.setName(""); - restVariablemodel = restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsErrorKey(RestErrorModel.VARIABLE_NAME_REQUIRED) - .containsSummary(RestErrorModel.VARIABLE_NAME_REQUIRED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Update task variable with invalid variable name") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void createTaskVariableWithInvalidVariableName() throws Exception - { - restClient.authenticateUser(adminUser).withWorkflowAPI(); - RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{\"scope\": \"local\",\"names\": \"varName\",\"value\": \"test\"," - + "\"type\": \"d:text\"}", "tasks/{taskId}/variables", taskId); - restClient.processModel(RestVariableModel.class, request); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsSummary(String.format(RestErrorModel.NO_CONTENT,"Unrecognized field " + "\"names\"")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Create task variable with invalid name") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void createTaskVariableWithInvalidName() throws Exception - { - restClient.authenticateUser(adminUser).withWorkflowAPI(); - RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{\"scope\": \"local\",\"name\": ',\"value\": \"test\"," - + "\"type\": \"d:text\"}", "tasks/{taskId}/variables", taskId); - restClient.processModel(RestVariableModel.class, request); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsSummary(String.format(RestErrorModel.NO_CONTENT,"Unexpected character " + "('''")); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Create task variable with empty name") - public void failedCreatingMultipleTaskVariableWithEmptyName() throws Exception - { - UserModel adminUser = dataUser.getAdminUser(); - restClient.authenticateUser(adminUser); - variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - variableModel1 = RestVariableModel.getRandomTaskVariableModel("global", "d:text"); - variableModel.setName(""); - - restVariableCollection = restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariables(variableModel, variableModel1); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsErrorKey(RestErrorModel.VARIABLE_NAME_REQUIRED) - .containsSummary(RestErrorModel.VARIABLE_NAME_REQUIRED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/DeleteTaskVariableTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/DeleteTaskVariableTests.java deleted file mode 100644 index 8a41452c1..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/DeleteTaskVariableTests.java +++ /dev/null @@ -1,231 +0,0 @@ -package org.alfresco.service.search.rest.workflow.tasks.variables; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestVariableModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TaskModel; -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 bogdan.bocancea - */ -public class DeleteTaskVariableTests extends RestTest -{ - private UserModel userModel, assigneeUser, adminUser; - private SiteModel siteModel; - private FileModel fileModel; - private TaskModel taskModel; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userModel = dataUser.createRandomTestUser(); - assigneeUser = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, - description = "Delete existing task variable") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - public void deleteTaskVariable() throws Exception - { - restClient.authenticateUser(adminUser); - RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - - restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables() - .assertThat().entriesListDoesNotContain("name", variableModel.getName()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Try to delete existing task variable using invalid task id") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void tryToDeleteTaskVariableUsingInvalidTaskId() throws Exception - { - restClient.authenticateUser(adminUser); - RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - - restClient.withWorkflowAPI().usingTask(taskModel).updateTaskVariable(variableModel); - taskModel.setId("incorrectTaskId"); - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, - description = "Delete task variable with any user") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - public void deleteTaskVariableByAnyUser() throws Exception - { - restClient.authenticateUser(userModel); - RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - - restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables() - .assertThat().entriesListDoesNotContain("name", variableModel.getName()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Delete task variable with invalid type") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void deleteTaskVariableInvalidType() throws Exception - { - restClient.authenticateUser(userModel); - RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); - variableModel.setType("invalid-type"); - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables() - . assertThat().entriesListDoesNotContain("name", variableModel.getName()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Delete task variable with invalid name") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void deleteTaskVariableInvalidName() throws Exception - { - restClient.authenticateUser(userModel); - RestVariableModel variableModel = new RestVariableModel("local", "<>.,;/|-+=%", "d:text", "invalid name"); - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Create, update, delete task variable with any user") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void createUpdateDeleteTaskVariableByAnyUser() throws Exception - { - restClient.authenticateUser(userModel); - RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - - restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); - variableModel.setName("new-variable"); - restClient.withWorkflowAPI().usingTask(taskModel).updateTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables() - .assertThat().entriesListDoesNotContain("name", variableModel.getName()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Delete task variable by non assigned user") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void deleteTaskVariableByNonAssignedUser() throws Exception - { - UserModel nonAssigned = dataUser.createRandomTestUser(); - RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - - restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); - restClient.authenticateUser(nonAssigned).withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Delete task variable by inexistent user") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) -// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void deleteTaskVariableByInexistentUser() throws Exception - { - RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); - restClient.authenticateUser(UserModel.getRandomUserModel()) - .withWorkflowAPI() - .usingTask(taskModel) - .deleteTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Delete task variable twice") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void deleteTaskVariableTwice() throws Exception - { - restClient.authenticateUser(userModel); - RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - - restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables() - .assertThat().entriesListDoesNotContain("name", variableModel.getName()); - - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, variableModel.getName())) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Delete task variable with empty variable name") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void deleteTaskEmptyVariableName() throws Exception - { - restClient.authenticateUser(userModel); - RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - - restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); - variableModel.setName(""); - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) - .assertLastError().containsErrorKey(RestErrorModel.DELETE_EMPTY_ARGUMENT) - .containsSummary(RestErrorModel.DELETE_EMPTY_ARGUMENT) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Delete task variable with empty variable scope") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void deleteTaskEmptyVariableScope() throws Exception - { - restClient.authenticateUser(userModel); - RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - - restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); - variableModel.setScope(""); - variableModel.setType(""); - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables() - .assertThat().entriesListDoesNotContain("name", variableModel.getName()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Delete task variable with invalid variable name") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void deleteTaskInvalidVariableName() throws Exception - { - restClient.authenticateUser(userModel); - RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - - restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); - variableModel.setName("invalid-name"); - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalid-name")) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/GetTaskVariablesTests.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/GetTaskVariablesTests.java deleted file mode 100644 index e0113fc4e..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/GetTaskVariablesTests.java +++ /dev/null @@ -1,252 +0,0 @@ -package org.alfresco.service.search.rest.workflow.tasks.variables; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.model.RestTaskModel; -import org.alfresco.rest.model.RestVariableModelsCollection; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TaskModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class GetTaskVariablesTests extends RestTest -{ - private UserModel userWhoStartsTask, assignee; - private SiteModel siteModel; - private FileModel fileModel; - private TaskModel taskModel; - private RestVariableModelsCollection variableModels; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - userWhoStartsTask = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, - description = "Verify that user that started the process gets task variables") - public void getTaskVariablesByUserWhoStartedProcess() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask) - .usingSite(siteModel).usingResource(fileModel) - .createNewTaskAndAssignTo(assignee); - restClient.authenticateUser(userWhoStartsTask); - variableModels = restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables(); - restClient.assertStatusCodeIs(HttpStatus.OK); - variableModels.assertThat().entriesListIsNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, - description = "Verify that user that is involved in the process gets task variables") - public void getTaskVariablesByUserInvolvedInProcess() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask) - .usingSite(siteModel).usingResource(fileModel) - .createNewTaskAndAssignTo(assignee); - restClient.authenticateUser(assignee); - variableModels = restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables(); - restClient.assertStatusCodeIs(HttpStatus.OK); - variableModels.assertThat().entriesListIsNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, - description = "Verify that user that is not involved in the process gets task variables") - public void getTaskVariablesUsingAnyUser() throws Exception - { - UserModel randomUser = dataUser.createRandomTestUser(); - taskModel = dataWorkflow.usingUser(userWhoStartsTask) - .usingSite(siteModel).usingResource(fileModel) - .createNewTaskAndAssignTo(assignee); - restClient.authenticateUser(randomUser); - restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, - description = "Verify that admin is able to task variables") - public void getTaskVariablesUsingAdmin() throws Exception - { - UserModel adminUser = dataUser.getAdminUser(); - taskModel = dataWorkflow.usingUser(userWhoStartsTask) - .usingSite(siteModel).usingResource(fileModel) - .createNewTaskAndAssignTo(assignee); - restClient.authenticateUser(adminUser); - variableModels = restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables(); - restClient.assertStatusCodeIs(HttpStatus.OK); - variableModels.assertThat().entriesListIsNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify if get task variables request returns status code 404 when invalid taskId is used") - public void getTaskVariablesUsingInvalidTaskId() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask) - .usingSite(siteModel).usingResource(fileModel) - .createNewTaskAndAssignTo(assignee); - taskModel.setId("invalidId"); - - restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingTask(taskModel).getTaskVariables(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidId")) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify if get task variables request returns status code 404 when empty taskId is used") - public void getTaskVariablesUsingEmptyTaskId() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); - taskModel.setId(""); - - restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingTask(taskModel).getTaskVariables(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify if get task variables request returns status code 200 after the task is finished.") - public void getTaskVariablesAfterFinishingTask() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); - dataWorkflow.usingUser(assignee).taskDone(taskModel); - - variableModels = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingTask(taskModel).getTaskVariables(); - restClient.assertStatusCodeIs(HttpStatus.OK); - variableModels.assertThat().entriesListIsNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify if get task variables request returns status code 200 after the process is deleted (Task state is now completed.)") - public void getTaskVariablesAfterDeletingProcess() throws Exception - { - RestProcessModel addedProcess = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.Normal); - RestTaskModel addedTask = restClient.withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess); - restClient.withWorkflowAPI().usingProcess(addedProcess).deleteProcess(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - variableModels = restClient.withWorkflowAPI().usingTask(addedTask).getTaskVariables(); - restClient.assertStatusCodeIs(HttpStatus.OK); - variableModels.assertThat().entriesListIsNotEmpty(); - } - - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify user gets task variables that matches a where clause.") - public void getTaskVariablesWithWhereClauseAsParameter() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); - variableModels = restClient.authenticateUser(userWhoStartsTask).where("scope='local'") - .withWorkflowAPI().usingTask(taskModel).getTaskVariables(); - restClient.assertStatusCodeIs(HttpStatus.OK); - variableModels.assertThat().entriesListIsNotEmpty() - .and().entriesListDoesNotContain("scope", "global") - .and().paginationField("totalItems").is("8"); - - variableModels = restClient.authenticateUser(userWhoStartsTask) - .withWorkflowAPI().usingTask(taskModel).getTaskVariables(); - restClient.assertStatusCodeIs(HttpStatus.OK); - variableModels.assertThat().entriesListContains("scope", "global") - .and().paginationField("totalItems").is("30"); - } - - @Bug(id="MNT-17438") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify user gets task with 'maxItems' parameter") - public void getTaskVariablesWithMaxItems() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); - variableModels = restClient.authenticateUser(userWhoStartsTask) - .withWorkflowAPI().usingParams("maxItems=2").usingTask(taskModel).getTaskVariables(); - restClient.assertStatusCodeIs(HttpStatus.OK); - variableModels.assertThat().entriesListIsNotEmpty() - .and().paginationField("count").is("2"); - } - - @Bug(id="MNT-17438") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify user gets task with 'skipCount' parameter") - public void getTaskVariablesWithSkipCount() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); - variableModels = restClient.authenticateUser(userWhoStartsTask) - .withWorkflowAPI().usingParams("skipCount=10").usingTask(taskModel).getTaskVariables(); - restClient.assertStatusCodeIs(HttpStatus.OK); - variableModels.assertThat().entriesListIsNotEmpty() - .and().paginationField("count").is("20"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify user cannot get task variables with invalid where clause.") - public void getTaskVariablesWithInvalidWhereClauseAsParameter() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); - variableModels = restClient.authenticateUser(userWhoStartsTask).where("scope='fake-where'") - .withWorkflowAPI().usingTask(taskModel).getTaskVariables(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_WHERE_QUERY, "Invalid value for 'scope' used in query: fake-where.")) - .containsErrorKey(RestErrorModel.INVALID_QUERY_ERRORKEY) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify user gets tasks variables with 'properties' parameter") - public void getTaskVariablesWithValidProperties() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); - variableModels = restClient.authenticateUser(userWhoStartsTask).withParams("properties=scope,name") - .withWorkflowAPI().usingTask(taskModel).getTaskVariables(); - restClient.assertStatusCodeIs(HttpStatus.OK); - variableModels.assertThat().entriesListIsNotEmpty(); - variableModels.getOneRandomEntry().onModel().assertThat() - .fieldsCount().is(2).and() - .field("type").isNull().and() - .field("value").isNull().and() - .field("scope").isNotEmpty().and() - .field("name").isNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify user cannot get tasks variables with invalid 'properties' parameter") - public void getTaskVariablesWithInvalidProperties() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); - variableModels = restClient.authenticateUser(userWhoStartsTask).withParams("properties=fake") - .withWorkflowAPI().usingTask(taskModel).getTaskVariables(); - restClient.assertStatusCodeIs(HttpStatus.OK); - variableModels.getOneRandomEntry().onModel().assertThat() - .fieldsCount().is(0).and() - .field("type").isNull().and() - .field("value").isNull().and() - .field("scope").isNull().and() - .field("name").isNull(); - } -} diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk1.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk1.java deleted file mode 100644 index 4e2bed673..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk1.java +++ /dev/null @@ -1,79 +0,0 @@ -package org.alfresco.service.search.rest.workflow.tasks.variables; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestVariableModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TaskModel; -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 UpdateTaskVariableTestsBulk1 extends RestTest -{ - private UserModel userModel; - private UserModel adminUser; - private SiteModel siteModel; - private FileModel fileModel; - private UserModel assigneeUser; - private TaskModel taskModel; - - private RestVariableModel taskVariable; - private RestVariableModel variableModel; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - assigneeUser = dataUser.createRandomTestUser(); - taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, - description = "Create non-existing task variable") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - public void createTaskVariable() throws Exception - { - restClient.authenticateUser(adminUser); - variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - - taskVariable = restClient.withWorkflowAPI().usingTask(taskModel).updateTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - taskVariable.assertThat().field("scope").is(taskVariable.getScope()) - .and().field("name").is(taskVariable.getName()) - .and().field("type").is(taskVariable.getType()) - .and().field("value").is(taskVariable.getValue()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, - description = "Update existing task variable") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - public void updateExistingTaskVariable() throws Exception - { - restClient.authenticateUser(adminUser); - variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - - taskVariable = restClient.withWorkflowAPI().usingTask(taskModel).updateTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - taskVariable.assertThat().field("scope").is(taskVariable.getScope()) - .and().field("name").is(taskVariable.getName()) - .and().field("type").is(taskVariable.getType()) - .and().field("value").is(taskVariable.getValue()); - - variableModel.setValue("updatedValue"); - taskVariable = restClient.withWorkflowAPI().usingTask(taskModel).updateTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - taskVariable.assertThat().field("value").is("updatedValue"); - } -} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk2.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk2.java deleted file mode 100644 index 13b2ea472..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk2.java +++ /dev/null @@ -1,173 +0,0 @@ -package org.alfresco.service.search.rest.workflow.tasks.variables; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestVariableModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TaskModel; -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 bogdan.bocancea - */ -public class UpdateTaskVariableTestsBulk2 extends RestTest -{ - private UserModel userModel; - private SiteModel siteModel; - private FileModel fileModel; - private UserModel assigneeUser; - private TaskModel taskModel; - private RestVariableModel taskVariable; - private RestVariableModel variableModel; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - assigneeUser = dataUser.createRandomTestUser(); - taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, - description = "Update task variable by user who started the process") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - public void updateTaskVariableByUserWhoStartedProcess() throws Exception - { - variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - taskVariable = restClient.authenticateUser(userModel) - .withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - variableModel.setValue("new-value"); - variableModel.setName("new-name"); - taskVariable = restClient.authenticateUser(userModel). - withWorkflowAPI().usingTask(taskModel).updateTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - taskVariable.assertThat().field("value").is("new-value") - .and().field("name").is("new-name"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Update task variable with symbols in name") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void updateTaskVariableWithSymbolsInName() throws Exception - { - String symbolName = "<>.,;-'+=%|[]#*&-+"; - variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - taskVariable = restClient.authenticateUser(userModel) - .withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - variableModel.setName(symbolName); - taskVariable = restClient.authenticateUser(userModel). - withWorkflowAPI().usingTask(taskModel).updateTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - taskVariable.assertThat().field("name").is(symbolName); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Update task variable with invalid task id") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void updateTaskVariableWithInvalidTaskId() throws Exception - { - TaskModel invalidTask = new TaskModel(userModel.getUsername()); - invalidTask.setId("invalid-task-id"); - taskVariable = restClient.authenticateUser(userModel). - withWorkflowAPI().usingTask(invalidTask) - .updateTaskVariable(RestVariableModel.getRandomTaskVariableModel("local", "d:text")); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, invalidTask.getId())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Update task variable with invalid scope") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void updateTaskVariableWithInvalidScope() throws Exception - { - variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - taskVariable = restClient.authenticateUser(userModel) - .withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - variableModel.setScope("invalid-scope"); - taskVariable = restClient.authenticateUser(userModel). - withWorkflowAPI().usingTask(taskModel).updateTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.ILLEGAL_SCOPE, "invalid-scope")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Update task variable with invalid type") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void updateTaskVariableWithInvalidType() throws Exception - { - variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - taskVariable = restClient.authenticateUser(userModel) - .withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - variableModel.setType("d:invalidType"); - taskVariable = restClient.authenticateUser(userModel). - withWorkflowAPI().usingTask(taskModel).updateTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.UNSUPPORTED_TYPE, "d:invalidType")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Update task variable with symbols in value") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void updateTaskVariableWithSymbolsInValue() throws Exception - { - String symbolValue = "<>.,;-'+=%|[]#*&-+/\\#!@"; - variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - taskVariable = restClient.authenticateUser(userModel) - .withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - variableModel.setValue(symbolValue); - taskVariable = restClient.authenticateUser(userModel). - withWorkflowAPI().usingTask(taskModel).updateTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - taskVariable.assertThat().field("value").is(symbolValue); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Update task variable by non assigned user") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void updateTaskVariableByNonAssignedUser() throws Exception - { - UserModel nonAssigned = dataUser.createRandomTestUser(); - variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - taskVariable = restClient.authenticateUser(userModel) - .withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - variableModel.setName("new-name"); - taskVariable = restClient.authenticateUser(nonAssigned) - .withWorkflowAPI().usingTask(taskModel).updateTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Update task variable by inexistent user") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) -// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void updateTaskVariableByNonexistentUser() throws Exception - { - variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - taskVariable = restClient.authenticateUser(userModel) - .withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - variableModel.setName("new-name"); - taskVariable = restClient.authenticateUser(UserModel.getRandomUserModel()) - .withWorkflowAPI().usingTask(taskModel).updateTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - -} \ No newline at end of file diff --git a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk3.java b/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk3.java deleted file mode 100644 index 30823d3a2..000000000 --- a/e2e-test/src/test/java/org/alfresco/service/search/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk3.java +++ /dev/null @@ -1,247 +0,0 @@ -package org.alfresco.service.search.rest.workflow.tasks.variables; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.service.search.rest.RestTest; -import org.alfresco.rest.core.RestRequest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestVariableModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TaskModel; -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 UpdateTaskVariableTestsBulk3 extends RestTest -{ - private SiteModel siteModel; - private FileModel fileModel; - private TaskModel taskModel; - private UserModel userModel; - private RestVariableModel taskVariable, updatedTaskVariable; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(userModel); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Update task variable with invalid name - PUT call") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void updateTaskVariableWithInvalidVariableName() throws Exception - { - taskVariable = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - restClient.authenticateUser(userModel) - .withWorkflowAPI().usingTask(taskModel).addTaskVariable(taskVariable); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"scope\": \"local\",\"names\": \"varName\",\"value\": \"test\"," - + "\"type\": \"d:text\"}", - "tasks/{taskId}/variables/{variableName}", taskModel.getId(), taskVariable.getName()); - restClient.processModel(RestVariableModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsSummary(String.format(RestErrorModel.NO_CONTENT,"Unrecognized field " + "\"names\"")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Update task variable with invalid name - PUT call") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void updateTaskVariableWithInvalidVariableValue() throws Exception - { - taskVariable = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - restClient.authenticateUser(userModel) - .withWorkflowAPI().usingTask(taskModel).addTaskVariable(taskVariable); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"scope\": \"local\",\"name\": \"varName\",\"values\": \"test\"," - + "\"type\": \"d:text\"}", - "tasks/{taskId}/variables/{variableName}", taskModel.getId(), taskVariable.getName()); - restClient.processModel(RestVariableModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsSummary(String.format(RestErrorModel.NO_CONTENT,"Unrecognized field " + "\"values\"")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Update task variable with invalid name - PUT call") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void updateTaskVariableWithEmptyVariableName() throws Exception - { - taskVariable = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - restClient.authenticateUser(userModel) - .withWorkflowAPI().usingTask(taskModel).addTaskVariable(taskVariable); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"scope\": \"local\",\"\": \"varName\",\"value\": \"test\"," - + "\"type\": \"d:text\"}", - "tasks/{taskId}/variables/{variableName}", taskModel.getId(), taskVariable.getName()); - restClient.processModel(RestVariableModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsSummary(String.format(RestErrorModel.NO_CONTENT,"Unrecognized field " + "\"\"")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Update task variable with empty name - PUT call") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void updateTaskVariableWithEmptyName() throws Exception - { - taskVariable = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).addTaskVariable(taskVariable); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - taskVariable.setName(""); - restClient.withWorkflowAPI().usingTask(taskModel).updateTaskVariable(taskVariable); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) - .assertLastError().containsErrorKey(RestErrorModel.PUT_EMPTY_ARGUMENT) - .containsSummary(RestErrorModel.PUT_EMPTY_ARGUMENT) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Update task variable with empty name - PUT call") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void updateTaskVariableWithInvalidName() throws Exception - { - taskVariable = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).addTaskVariable(taskVariable); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"scope\": \"local\",\"name\": ',\"value\": \"test\"," - + "\"type\": \"d:text\"}", - "tasks/{taskId}/variables/{variableName}", taskModel.getId(), taskVariable.getName()); - restClient.processModel(RestVariableModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsSummary(String.format(RestErrorModel.NO_CONTENT,"Unexpected character " + "('''")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Update task variable with empty name - PUT call") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void updateTaskVariableWithInvalidValue() throws Exception - { - taskVariable = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).addTaskVariable(taskVariable); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"scope\": \"local\",\"name\": \"varName\",\"value\"::," - + "\"type\": \"d:text\"}", - "tasks/{taskId}/variables/{variableName}", taskModel.getId(), taskVariable.getName()); - restClient.processModel(RestVariableModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsSummary(String.format(RestErrorModel.NO_CONTENT,"Unexpected character " + "(':'")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Update task variable with empty name - PUT call") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void updateTaskVariableWithMissingType() throws Exception - { - taskVariable = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - restClient.authenticateUser(userModel) - .withWorkflowAPI().usingTask(taskModel).addTaskVariable(taskVariable); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"scope\": \"local\",\"name\": \"varName\",\"value\": \"test\"}", - "tasks/{taskId}/variables/{variableName}", taskModel.getId(), taskVariable.getName()); - restClient.processModel(RestVariableModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.OK); - taskVariable.assertThat().field("scope").is(taskVariable.getScope()) - .and().field("name").is(taskVariable.getName()) - .and().field("type").is("d:text") - .and().field("value").is(taskVariable.getValue()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Update task variable with empty name - PUT call") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void updateTaskVariableWithMissingTypeAndValue() throws Exception - { - taskVariable = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - restClient.authenticateUser(userModel) - .withWorkflowAPI().usingTask(taskModel).addTaskVariable(taskVariable); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"scope\": \"local\",\"name\": \"varName\"}", - "tasks/{taskId}/variables/{variableName}", taskModel.getId(), taskVariable.getName()); - updatedTaskVariable = restClient.processModel(RestVariableModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedTaskVariable.assertThat().field("scope").is(updatedTaskVariable.getScope()) - .and().field("name").is(updatedTaskVariable.getName()) - .and().field("type").is("d:any"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Update task variable with invalid name - PUT call") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void updateTaskVariableWithEmptyBody() throws Exception - { - taskVariable = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - restClient.authenticateUser(userModel) - .withWorkflowAPI().usingTask(taskModel).addTaskVariable(taskVariable); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{}", - "tasks/{taskId}/variables/{variableName}", taskModel.getId(), taskVariable.getName()); - restClient.processModel(RestVariableModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsErrorKey(RestErrorModel.VARIABLE_NAME_REQUIRED) - .containsSummary(RestErrorModel.VARIABLE_NAME_REQUIRED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Update task variable with invalid name - PUT call") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void updateTaskVariableWithInvalidBody() throws Exception - { - taskVariable = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - restClient.authenticateUser(userModel) - .withWorkflowAPI().usingTask(taskModel).addTaskVariable(taskVariable); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"scope\": \"local\",\"name\": \"varName\",\"value\": \"test\"," - + "\"type\": \"d:text\", \"errorKey\": \"invalidBody\"}", - "tasks/{taskId}/variables/{variableName}", taskModel.getId(), taskVariable.getName()); - restClient.processModel(RestVariableModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError() - .containsSummary(String.format(RestErrorModel.NO_CONTENT,"Unrecognized field " + "\"errorKey\"")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Update task variable with empty name - PUT call") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void updateTwiceInARowSameTaskVariable() throws Exception - { - taskVariable = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).addTaskVariable(taskVariable); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - taskVariable.setName("newName"); - taskVariable.setScope("global"); - updatedTaskVariable = restClient.withWorkflowAPI().usingTask(taskModel).updateTaskVariable(taskVariable); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedTaskVariable.assertThat().field("scope").is("global"); - updatedTaskVariable.assertThat().field("name").is("newName"); - - updatedTaskVariable = restClient.withWorkflowAPI().usingTask(taskModel).updateTaskVariable(taskVariable); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedTaskVariable.assertThat().field("scope").is("global"); - updatedTaskVariable.assertThat().field("name").is("newName"); - } -} From e3b5fbcbf7bbcb47b7b41b0d583a5636bb0b4824 Mon Sep 17 00:00:00 2001 From: agazzarini Date: Mon, 1 Apr 2019 20:05:21 +0200 Subject: [PATCH 1484/1491] [ SEARCH-1485 ] removed test/resources from a wrong merge --- e2e-test/resources/SearchSuite.xml | 50 ------ .../resources/alfresco-restapi-context.xml | 17 -- e2e-test/resources/default.properties | 84 --------- e2e-test/resources/log4j.properties | 26 --- e2e-test/resources/models/SEARCH-1063.xml | 159 ------------------ 5 files changed, 336 deletions(-) delete mode 100644 e2e-test/resources/SearchSuite.xml delete mode 100644 e2e-test/resources/alfresco-restapi-context.xml delete mode 100644 e2e-test/resources/default.properties delete mode 100644 e2e-test/resources/log4j.properties delete mode 100755 e2e-test/resources/models/SEARCH-1063.xml diff --git a/e2e-test/resources/SearchSuite.xml b/e2e-test/resources/SearchSuite.xml deleted file mode 100644 index 88af99b0e..000000000 --- a/e2e-test/resources/SearchSuite.xml +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/e2e-test/resources/alfresco-restapi-context.xml b/e2e-test/resources/alfresco-restapi-context.xml deleted file mode 100644 index 8b2ce79cb..000000000 --- a/e2e-test/resources/alfresco-restapi-context.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - diff --git a/e2e-test/resources/default.properties b/e2e-test/resources/default.properties deleted file mode 100644 index 08d38d82f..000000000 --- a/e2e-test/resources/default.properties +++ /dev/null @@ -1,84 +0,0 @@ -# dataprep related -alfresco.scheme=http -alfresco.server=localhost -alfresco.port=8081 - -# sync service related -sync.scheme=http -sync.server=localhost -sync.port=9090 - -# Solr Server Settings -solr.scheme=http -solr.server=localhost -solr.port=8083 - -#Solr Indexing Time -solrWaitTimeInSeconds=20 - -# credentials -admin.user=admin -admin.password=admin - -# in containers we cannot access directly JMX, so we will use http://jolokia.org agent -# disabling this we will use direct JMX calls to server -jmx.useJolokiaAgent=false - -# Server Health section -# in ServerHealth#isServerReachable() - could also be shown. -# enable this option to view if on server there are tenants or not -serverHealth.showTenants=false - -# TEST MANAGEMENT SECTION - Test Rail -# -# (currently supporting Test Rail v5.2.1.3472 integration) -# -# Example of configuration: -# ------------------------------------------------------ -# if testManagement.enabled=true we enabled TestRailExecutorListener (if used in your suite xml file) -# testManagement.updateTestExecutionResultsOnly=true (this will just update the results of a test: no step will be updated - good for performance) -# testManagement.endPoint=https://alfresco.testrail.com/ -# testManagement.username= -# testManagement.apiKey= -# testManagement.project= -# testManagement.includeOnlyTestCasesExecuted=true #if you want to include in your run ONLY the test cases that you run, then set this value to false -# testManagement.rateLimitInSeconds=1 #is the default rate limit after what minimum time, should we upload the next request. http://docs.gurock.com/testrail-api2/introduction #Rate Limit -# testManagement.suiteId=23 (the id of the Master suite) -# ------------------------------------------------------ -testManagement.enabled=false -testManagement.endPoint=https://alfresco.testrail.com/ -testManagement.username=tas.alfresco@gmail.com -testManagement.apiKey=EYpY7.fV0AoMGWbmyuVC-k5u.nzwHy6a.QWzJq8.S -testManagement.project=7 -testManagement.includeOnlyTestCasesExecuted=true -testManagement.rateLimitInSeconds=1 -testManagement.testRun=MyTestRunInTestRail -testManagement.suiteId=12 - -# The location of the reports path -reports.path=./target/reports - -# -# Database Section -# You should provide here the database URL, that can be a differed server as alfresco. -# https://docs.oracle.com/javase/tutorial/jdbc/basics/connecting.html -# -# Current supported db.url: -# -# MySQL: -# db.url = jdbc:mysql://${alfresco.server}:3306/alfresco -# -# PostgreSQL: -# db.url = jdbc:postgresql://:3306/alfresco -# -# Oracle: -# db.url = jdbc:oracle://:3306/alfresco -# -# MariaDB: -# db.url = jdbc:mariadb://:3306/alfresco -# -db.url = jdbc:mysql://${alfresco.server}:3306/alfresco -db.username = alfresco -db.password = alfresco - diff --git a/e2e-test/resources/log4j.properties b/e2e-test/resources/log4j.properties deleted file mode 100644 index 00e9b5a11..000000000 --- a/e2e-test/resources/log4j.properties +++ /dev/null @@ -1,26 +0,0 @@ -# Root logger option -log4j.rootLogger=INFO, file, stdout - -# Direct log messages to a log file -log4j.appender.file=org.apache.log4j.RollingFileAppender -log4j.appender.file.File=./target/reports/alfresco-tas.log -log4j.appender.file.MaxBackupIndex=10 -log4j.appender.file.layout=org.apache.log4j.PatternLayout -log4j.appender.file.layout.ConversionPattern=[%t] %d{HH:mm:ss} %-5p %c{1}:%L - %m%n - -# Direct log messages to stdout -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.Target=System.out -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=[%t] %d{HH:mm:ss} %-5p %c{1}:%L - %m%n - -# TestRail particular log file -# Direct log messages to a log file -log4j.appender.testrailLog=org.apache.log4j.RollingFileAppender -log4j.appender.testrailLog.File=./target/reports/alfresco-testrail.log -log4j.appender.testrailLog.MaxBackupIndex=10 -log4j.appender.testrailLog.layout=org.apache.log4j.PatternLayout -log4j.appender.testrailLog.layout.ConversionPattern=%d{HH:mm:ss} %-5p %c{1}:%L - %m%n - -log4j.category.testrail=INFO, testrailLog -log4j.additivity.testrail=false \ No newline at end of file diff --git a/e2e-test/resources/models/SEARCH-1063.xml b/e2e-test/resources/models/SEARCH-1063.xml deleted file mode 100755 index 816afd2bc..000000000 --- a/e2e-test/resources/models/SEARCH-1063.xml +++ /dev/null @@ -1,159 +0,0 @@ - - - Administrator admin user - - - - - - - - - - - - - - - - - song - cm:content - - - Name - d:text - false - - true - BOTH - false - - - - Genre - d:text - false - - true - BOTH - false - - - - Producer - d:text - false - - true - BOTH - false - - - - - - - - - Artist - cm:content - - - Name - d:text - false - - true - BOTH - false - - - - Voice Type - d:text - false - - true - BOTH - false - - - - - - - - - - Bassist - cm:content - - - Name - d:text - false - - true - BOTH - false - - - - - - - - - Drummer - cm:content - - - Name - d:text - false - - true - BOTH - false - - - - - - - - - Sax - cm:content - - - Name - d:text - false - - true - BOTH - false - - - - - - - - - - \ No newline at end of file From 3d1c5c6ecee1f1fb572004111f0fd6f8a9d5c45d Mon Sep 17 00:00:00 2001 From: agazzarini Date: Mon, 1 Apr 2019 20:13:37 +0200 Subject: [PATCH 1485/1491] [ SEARCH-1485 ] moved restapi models in main/resources folder --- .../resources/models => main/resources/model}/SEARCH-1063.xml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename e2e-test/src/{test/resources/models => main/resources/model}/SEARCH-1063.xml (100%) diff --git a/e2e-test/src/test/resources/models/SEARCH-1063.xml b/e2e-test/src/main/resources/model/SEARCH-1063.xml similarity index 100% rename from e2e-test/src/test/resources/models/SEARCH-1063.xml rename to e2e-test/src/main/resources/model/SEARCH-1063.xml From cffa40fd81425b03489be2aaa25141feab3237f0 Mon Sep 17 00:00:00 2001 From: agazzarini Date: Mon, 1 Apr 2019 20:13:56 +0200 Subject: [PATCH 1486/1491] [ SEARCH-1485 ] removed restapi Spring application context --- .../test/resources/alfresco-restapi-context.xml | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 e2e-test/src/test/resources/alfresco-restapi-context.xml diff --git a/e2e-test/src/test/resources/alfresco-restapi-context.xml b/e2e-test/src/test/resources/alfresco-restapi-context.xml deleted file mode 100644 index 8b2ce79cb..000000000 --- a/e2e-test/src/test/resources/alfresco-restapi-context.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - From 78e51422f9fe187a407f629984f06e1bf1b9da13 Mon Sep 17 00:00:00 2001 From: agazzarini Date: Mon, 1 Apr 2019 21:50:53 +0200 Subject: [PATCH 1487/1491] [ SEARCH-1485 ] Minor fixes to Search tests --- .../sql/SearchSQLWithQuotedIdentifiers.java | 2 +- e2e-test/src/test/resources/SearchSuite.xml | 34 +++++++------------ 2 files changed, 14 insertions(+), 22 deletions(-) diff --git a/e2e-test/src/test/java/org/alfresco/service/search/e2e/insightEngine/sql/SearchSQLWithQuotedIdentifiers.java b/e2e-test/src/test/java/org/alfresco/service/search/e2e/insightEngine/sql/SearchSQLWithQuotedIdentifiers.java index c51613711..427afb047 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/e2e/insightEngine/sql/SearchSQLWithQuotedIdentifiers.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/e2e/insightEngine/sql/SearchSQLWithQuotedIdentifiers.java @@ -99,7 +99,7 @@ public class SearchSQLWithQuotedIdentifiers extends AbstractSearchTest userModel = dataUser.createRandomTestUser(); - dataContent.usingAdmin().deployContentModel("models/SEARCH-1063.xml"); + dataContent.usingAdmin().deployContentModel("model/SEARCH-1063.xml"); dataUser.addUserToSite(userModel, testSite, UserRole.SiteContributor); diff --git a/e2e-test/src/test/resources/SearchSuite.xml b/e2e-test/src/test/resources/SearchSuite.xml index a455134d5..63e01a9eb 100644 --- a/e2e-test/src/test/resources/SearchSuite.xml +++ b/e2e-test/src/test/resources/SearchSuite.xml @@ -9,45 +9,37 @@ - - - - - + + + + + - - - - - - + + + + + + - + - + - - - - - - - - From 393030e14041844b705240240c334c6981b6dd60 Mon Sep 17 00:00:00 2001 From: agazzarini Date: Tue, 2 Apr 2019 11:55:17 +0200 Subject: [PATCH 1488/1491] [ SEARCH-1485 ] minor fix for properly load a custom model in a test coming from restapi --- .../e2e/insightEngine/sql/SearchSQLWithQuotedIdentifiers.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/src/test/java/org/alfresco/service/search/e2e/insightEngine/sql/SearchSQLWithQuotedIdentifiers.java b/e2e-test/src/test/java/org/alfresco/service/search/e2e/insightEngine/sql/SearchSQLWithQuotedIdentifiers.java index 427afb047..48225ef4f 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/e2e/insightEngine/sql/SearchSQLWithQuotedIdentifiers.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/e2e/insightEngine/sql/SearchSQLWithQuotedIdentifiers.java @@ -99,7 +99,7 @@ public class SearchSQLWithQuotedIdentifiers extends AbstractSearchTest userModel = dataUser.createRandomTestUser(); - dataContent.usingAdmin().deployContentModel("model/SEARCH-1063.xml"); + dataContent.deployContentModel("model/SEARCH-1063.xml"); dataUser.addUserToSite(userModel, testSite, UserRole.SiteContributor); From 2f6a38c98293602afa7c60190616727411643853 Mon Sep 17 00:00:00 2001 From: agazzarini Date: Tue, 2 Apr 2019 14:44:06 +0200 Subject: [PATCH 1489/1491] [ SEARCH-1485 ] Minor fix in SQLIdentifiers Test --- .../model/{SEARCH-1063.xml => search-1063-model.xml} | 0 .../e2e/insightEngine/sql/SearchSQLWithQuotedIdentifiers.java | 4 ++-- 2 files changed, 2 insertions(+), 2 deletions(-) rename e2e-test/src/main/resources/model/{SEARCH-1063.xml => search-1063-model.xml} (100%) diff --git a/e2e-test/src/main/resources/model/SEARCH-1063.xml b/e2e-test/src/main/resources/model/search-1063-model.xml similarity index 100% rename from e2e-test/src/main/resources/model/SEARCH-1063.xml rename to e2e-test/src/main/resources/model/search-1063-model.xml diff --git a/e2e-test/src/test/java/org/alfresco/service/search/e2e/insightEngine/sql/SearchSQLWithQuotedIdentifiers.java b/e2e-test/src/test/java/org/alfresco/service/search/e2e/insightEngine/sql/SearchSQLWithQuotedIdentifiers.java index 48225ef4f..0b358b7c6 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/e2e/insightEngine/sql/SearchSQLWithQuotedIdentifiers.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/e2e/insightEngine/sql/SearchSQLWithQuotedIdentifiers.java @@ -84,7 +84,7 @@ public class SearchSQLWithQuotedIdentifiers extends AbstractSearchTest * @throws Exception hopefully never, otherwise the test fails. */ @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception + public void localDataPreparation() throws Exception { songName = "The Dry Cleaner from Des Moines "; genre = "Jazz, vocal jazz "; @@ -99,7 +99,7 @@ public class SearchSQLWithQuotedIdentifiers extends AbstractSearchTest userModel = dataUser.createRandomTestUser(); - dataContent.deployContentModel("model/SEARCH-1063.xml"); + dataContent.deployContentModel("model/search-1063-model.xml"); dataUser.addUserToSite(userModel, testSite, UserRole.SiteContributor); From bab8a3cd2ad1038e2c9f9cd036c37ead833f3de0 Mon Sep 17 00:00:00 2001 From: agazzarini Date: Tue, 2 Apr 2019 15:35:10 +0200 Subject: [PATCH 1490/1491] [ SEARCH-1485 ] Use admin user for deploying custom model --- .../e2e/insightEngine/sql/SearchSQLWithQuotedIdentifiers.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/src/test/java/org/alfresco/service/search/e2e/insightEngine/sql/SearchSQLWithQuotedIdentifiers.java b/e2e-test/src/test/java/org/alfresco/service/search/e2e/insightEngine/sql/SearchSQLWithQuotedIdentifiers.java index 0b358b7c6..0ea1973c4 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/e2e/insightEngine/sql/SearchSQLWithQuotedIdentifiers.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/e2e/insightEngine/sql/SearchSQLWithQuotedIdentifiers.java @@ -99,7 +99,7 @@ public class SearchSQLWithQuotedIdentifiers extends AbstractSearchTest userModel = dataUser.createRandomTestUser(); - dataContent.deployContentModel("model/search-1063-model.xml"); + dataContent.usingAdmin().deployContentModel("model/search-1063-model.xml"); dataUser.addUserToSite(userModel, testSite, UserRole.SiteContributor); From 9729196085e0b32dfae1c0c2780db41166d447e5 Mon Sep 17 00:00:00 2001 From: agazzarini Date: Wed, 3 Apr 2019 08:39:27 +0200 Subject: [PATCH 1491/1491] [ SEARCH-1485 ] Use TestSite created in the superclass --- .../insightEngine/sql/SearchSQLWithQuotedIdentifiers.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/e2e-test/src/test/java/org/alfresco/service/search/e2e/insightEngine/sql/SearchSQLWithQuotedIdentifiers.java b/e2e-test/src/test/java/org/alfresco/service/search/e2e/insightEngine/sql/SearchSQLWithQuotedIdentifiers.java index 0ea1973c4..50077f086 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/e2e/insightEngine/sql/SearchSQLWithQuotedIdentifiers.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/e2e/insightEngine/sql/SearchSQLWithQuotedIdentifiers.java @@ -97,11 +97,11 @@ public class SearchSQLWithQuotedIdentifiers extends AbstractSearchTest drummerName = "Peter Erskine"; saxophonistName = "Wayne Shorter"; - userModel = dataUser.createRandomTestUser(); - dataContent.usingAdmin().deployContentModel("model/search-1063-model.xml"); - dataUser.addUserToSite(userModel, testSite, UserRole.SiteContributor); + dataUser.addUserToSite(userModel, siteModel, UserRole.SiteContributor); + + testSite = siteModel; FolderModel testFolder = dataContent.usingSite(testSite).usingUser(userModel).createFolder();